From daa887ee65d753cd8e068a3fcb8caaeff9341424 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Tue, 15 Aug 2017 18:26:31 +0800 Subject: [PATCH 1/6] [WIP] Integrate micropython --- Makefile | 8 +- user/mpy/_frozen_mpy.c | 112 + user/mpy/build.mk | 69 + user/mpy/build/genhdr/mpversion.h | 8 + user/mpy/build/genhdr/qstr.i.last | 286426 +++++++++++++++ user/mpy/build/genhdr/qstr.split | 0 .../qstr/user__mpy__py__builtinevex.c.qstr | 1 + .../qstr/user__mpy__py__builtinimport.c.qstr | 6 + .../genhdr/qstr/user__mpy__py__compile.c.qstr | 15 + .../genhdr/qstr/user__mpy__py__emitbc.c.qstr | 1 + .../qstr/user__mpy__py__modbuiltins.c.qstr | 83 + .../qstr/user__mpy__py__modmicropython.c.qstr | 6 + .../genhdr/qstr/user__mpy__py__objbool.c.qstr | 1 + .../qstr/user__mpy__py__objboundmeth.c.qstr | 1 + .../qstr/user__mpy__py__objclosure.c.qstr | 1 + .../genhdr/qstr/user__mpy__py__objdict.c.qstr | 17 + .../qstr/user__mpy__py__objexcept.c.qstr | 29 + .../genhdr/qstr/user__mpy__py__objfun.c.qstr | 6 + .../qstr/user__mpy__py__objgenerator.c.qstr | 5 + .../qstr/user__mpy__py__objgetitemiter.c.qstr | 1 + .../genhdr/qstr/user__mpy__py__objint.c.qstr | 5 + .../genhdr/qstr/user__mpy__py__objlist.c.qstr | 14 + .../genhdr/qstr/user__mpy__py__objmap.c.qstr | 1 + .../qstr/user__mpy__py__objmodule.c.qstr | 7 + .../genhdr/qstr/user__mpy__py__objnone.c.qstr | 1 + .../qstr/user__mpy__py__objobject.c.qstr | 1 + .../qstr/user__mpy__py__objpolyiter.c.qstr | 1 + .../qstr/user__mpy__py__objrange.c.qstr | 5 + .../qstr/user__mpy__py__objsingleton.c.qstr | 1 + .../genhdr/qstr/user__mpy__py__objstr.c.qstr | 27 + .../qstr/user__mpy__py__objtuple.c.qstr | 3 + .../genhdr/qstr/user__mpy__py__objtype.c.qstr | 30 + .../genhdr/qstr/user__mpy__py__objzip.c.qstr | 1 + .../genhdr/qstr/user__mpy__py__runtime.c.qstr | 16 + .../genhdr/qstr/user__mpy__py__scope.c.qstr | 6 + .../genhdr/qstr/user__mpy__py__stream.c.qstr | 1 + .../genhdr/qstr/user__mpy__py__vm.c.qstr | 2 + user/mpy/build/genhdr/qstrdefs.collected.h | 589 + .../build/genhdr/qstrdefs.collected.h.hash | 1 + user/mpy/build/genhdr/qstrdefs.generated.h | 202 + user/mpy/build/genhdr/qstrdefs.preprocessed.h | 1243 + user/mpy/extmod/crypto-algorithms/sha256.c | 157 + user/mpy/extmod/crypto-algorithms/sha256.h | 34 + user/mpy/extmod/lwip-include/arch/cc.h | 41 + user/mpy/extmod/lwip-include/arch/perf.h | 7 + user/mpy/extmod/lwip-include/lwipopts.h | 35 + user/mpy/extmod/machine_i2c.c | 640 + user/mpy/extmod/machine_i2c.h | 56 + user/mpy/extmod/machine_mem.c | 103 + user/mpy/extmod/machine_mem.h | 49 + user/mpy/extmod/machine_pinbase.c | 88 + user/mpy/extmod/machine_pinbase.h | 33 + user/mpy/extmod/machine_pulse.c | 65 + user/mpy/extmod/machine_pulse.h | 36 + user/mpy/extmod/machine_signal.c | 183 + user/mpy/extmod/machine_signal.h | 33 + user/mpy/extmod/machine_spi.c | 339 + user/mpy/extmod/machine_spi.h | 61 + user/mpy/extmod/misc.h | 44 + user/mpy/extmod/modbtree.c | 379 + user/mpy/extmod/modframebuf.c | 596 + user/mpy/extmod/modlwip.c | 1380 + user/mpy/extmod/modonewire.c | 162 + user/mpy/extmod/modubinascii.c | 244 + user/mpy/extmod/modubinascii.h | 41 + user/mpy/extmod/moductypes.c | 716 + user/mpy/extmod/moduhashlib.c | 159 + user/mpy/extmod/moduheapq.c | 122 + user/mpy/extmod/modujson.c | 299 + user/mpy/extmod/modurandom.c | 226 + user/mpy/extmod/modure.c | 255 + user/mpy/extmod/moduselect.c | 378 + user/mpy/extmod/modussl_axtls.c | 232 + user/mpy/extmod/modussl_mbedtls.c | 314 + user/mpy/extmod/modutimeq.c | 232 + user/mpy/extmod/moduzlib.c | 225 + user/mpy/extmod/modwebrepl.c | 354 + user/mpy/extmod/modwebsocket.c | 318 + user/mpy/extmod/modwebsocket.h | 10 + user/mpy/extmod/re1.5/charclass.c | 33 + user/mpy/extmod/re1.5/compilecode.c | 216 + user/mpy/extmod/re1.5/dumpcode.c | 65 + user/mpy/extmod/re1.5/re1.5.h | 151 + user/mpy/extmod/re1.5/recursiveloop.c | 84 + user/mpy/extmod/uos_dupterm.c | 92 + user/mpy/extmod/utime_mphal.c | 102 + user/mpy/extmod/utime_mphal.h | 41 + user/mpy/extmod/uzlib/adler32.c | 78 + user/mpy/extmod/uzlib/crc32.c | 63 + user/mpy/extmod/uzlib/tinf.h | 117 + user/mpy/extmod/uzlib/tinfgzip.c | 110 + user/mpy/extmod/uzlib/tinflate.c | 551 + user/mpy/extmod/uzlib/tinfzlib.c | 66 + user/mpy/extmod/vfs.c | 457 + user/mpy/extmod/vfs.h | 85 + user/mpy/extmod/vfs_fat.c | 345 + user/mpy/extmod/vfs_fat.h | 64 + user/mpy/extmod/vfs_fat_diskio.c | 280 + user/mpy/extmod/vfs_fat_file.c | 300 + user/mpy/extmod/vfs_fat_misc.c | 109 + user/mpy/extmod/vfs_reader.c | 87 + user/mpy/extmod/virtpin.c | 39 + user/mpy/extmod/virtpin.h | 47 + user/mpy/forzentest.mpy | 16 + user/mpy/lib/README.md | 2 + user/mpy/lib/axtls/.gitignore | 11 + user/mpy/lib/axtls/Makefile | 185 + user/mpy/lib/axtls/README | 3 + user/mpy/lib/axtls/axtlswrap/Makefile | 68 + user/mpy/lib/axtls/axtlswrap/axtlswrap.c | 379 + user/mpy/lib/axtls/bindings/Config.in | 105 + user/mpy/lib/axtls/bindings/Makefile | 86 + user/mpy/lib/axtls/bindings/README | 43 + user/mpy/lib/axtls/bindings/csharp/Makefile | 35 + user/mpy/lib/axtls/bindings/csharp/axTLS.cs | 491 + .../axtls/bindings/generate_SWIG_interface.pl | 392 + .../lib/axtls/bindings/generate_interface.pl | 322 + user/mpy/lib/axtls/bindings/java/Makefile | 94 + user/mpy/lib/axtls/bindings/java/SSL.java | 137 + user/mpy/lib/axtls/bindings/java/SSLCTX.java | 229 + .../lib/axtls/bindings/java/SSLClient.java | 81 + .../axtls/bindings/java/SSLReadHolder.java | 61 + .../lib/axtls/bindings/java/SSLServer.java | 72 + user/mpy/lib/axtls/bindings/java/SSLUtil.java | 116 + user/mpy/lib/axtls/bindings/lua/Makefile | 67 + user/mpy/lib/axtls/bindings/perl/Makefile | 91 + user/mpy/lib/axtls/bindings/vbnet/Makefile | 35 + user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb | 200 + user/mpy/lib/axtls/config/Config.in | 130 + user/mpy/lib/axtls/config/JMeter.jmx | 247 + user/mpy/lib/axtls/config/Rules.mak | 221 + user/mpy/lib/axtls/config/axhttpd.aip | 136 + user/mpy/lib/axtls/config/axtls.RES | Bin 0 -> 22748 bytes user/mpy/lib/axtls/config/axtls.rc | 32 + user/mpy/lib/axtls/config/linuxconfig | 126 + user/mpy/lib/axtls/config/makefile.conf | 138 + .../mpy/lib/axtls/config/makefile.dotnet.conf | 65 + user/mpy/lib/axtls/config/makefile.java.conf | 58 + user/mpy/lib/axtls/config/makefile.post | 19 + .../scripts/config/Kconfig-language.txt | 255 + .../lib/axtls/config/scripts/config/Makefile | 121 + .../lib/axtls/config/scripts/config/conf.c | 583 + .../axtls/config/scripts/config/confdata.c | 458 + .../lib/axtls/config/scripts/config/expr.c | 1099 + .../lib/axtls/config/scripts/config/expr.h | 195 + .../config/scripts/config/lex.zconf.c_shipped | 3688 + .../mpy/lib/axtls/config/scripts/config/lkc.h | 123 + .../axtls/config/scripts/config/lkc_proto.h | 40 + .../scripts/config/lxdialog/BIG.FAT.WARNING | 4 + .../scripts/config/lxdialog/checklist.c | 372 + .../config/scripts/config/lxdialog/colors.h | 161 + .../config/scripts/config/lxdialog/dialog.h | 199 + .../config/scripts/config/lxdialog/inputbox.c | 240 + .../config/scripts/config/lxdialog/menubox.c | 438 + .../config/scripts/config/lxdialog/msgbox.c | 85 + .../config/scripts/config/lxdialog/textbox.c | 556 + .../config/scripts/config/lxdialog/util.c | 375 + .../config/scripts/config/lxdialog/yesno.c | 118 + .../lib/axtls/config/scripts/config/mconf.c | 977 + .../lib/axtls/config/scripts/config/menu.c | 390 + .../lib/axtls/config/scripts/config/mkconfigs | 67 + .../lib/axtls/config/scripts/config/symbol.c | 809 + .../lib/axtls/config/scripts/config/util.c | 109 + .../lib/axtls/config/scripts/config/zconf.l | 366 + .../config/scripts/config/zconf.tab.c_shipped | 2130 + .../config/scripts/config/zconf.tab.h_shipped | 125 + .../lib/axtls/config/scripts/config/zconf.y | 690 + user/mpy/lib/axtls/config/upyconfig | 117 + user/mpy/lib/axtls/config/upyconfig.client | 116 + user/mpy/lib/axtls/config/win32config | 119 + user/mpy/lib/axtls/crypto/Makefile | 52 + user/mpy/lib/axtls/crypto/aes.c | 452 + user/mpy/lib/axtls/crypto/bigint.c | 1516 + user/mpy/lib/axtls/crypto/bigint.h | 99 + user/mpy/lib/axtls/crypto/bigint_impl.h | 131 + user/mpy/lib/axtls/crypto/crypto.h | 273 + user/mpy/lib/axtls/crypto/crypto_misc.c | 378 + user/mpy/lib/axtls/crypto/hmac.c | 145 + user/mpy/lib/axtls/crypto/md5.c | 433 + user/mpy/lib/axtls/crypto/os_int.h | 67 + user/mpy/lib/axtls/crypto/rc4.c | 97 + user/mpy/lib/axtls/crypto/rsa.c | 284 + user/mpy/lib/axtls/crypto/sha1.c | 249 + user/mpy/lib/axtls/crypto/sha256.c | 278 + user/mpy/lib/axtls/crypto/sha384.c | 77 + user/mpy/lib/axtls/crypto/sha512.c | 220 + user/mpy/lib/axtls/docsrc/Makefile | 39 + user/mpy/lib/axtls/docsrc/axTLS.dox | 1372 + user/mpy/lib/axtls/docsrc/doco_footer.html | 3 + user/mpy/lib/axtls/docsrc/images/axolotl.jpg | Bin 0 -> 3041 bytes user/mpy/lib/axtls/docsrc/images/tsbasbw.gif | Bin 0 -> 2481 bytes user/mpy/lib/axtls/httpd/Config.in | 160 + user/mpy/lib/axtls/httpd/Makefile | 130 + user/mpy/lib/axtls/httpd/axhttp.h | 156 + user/mpy/lib/axtls/httpd/axhttpd.c | 713 + user/mpy/lib/axtls/httpd/htpasswd.c | 142 + .../kepler-1.1-snapshot-20070521-1825.tar.gz | Bin 0 -> 768249 bytes user/mpy/lib/axtls/httpd/kepler.patch | 64 + user/mpy/lib/axtls/httpd/proc.c | 1254 + user/mpy/lib/axtls/httpd/tdate_parse.c | 115 + user/mpy/lib/axtls/samples/Config.in | 63 + user/mpy/lib/axtls/samples/Makefile | 62 + user/mpy/lib/axtls/samples/c/Makefile | 77 + user/mpy/lib/axtls/samples/c/axssl.c | 904 + user/mpy/lib/axtls/samples/csharp/Makefile | 48 + user/mpy/lib/axtls/samples/csharp/axssl.cs | 758 + user/mpy/lib/axtls/samples/java/Makefile | 51 + user/mpy/lib/axtls/samples/java/axssl.java | 760 + user/mpy/lib/axtls/samples/java/manifest.mf | 1 + user/mpy/lib/axtls/samples/lua/Makefile | 43 + user/mpy/lib/axtls/samples/lua/axssl.lua | 562 + user/mpy/lib/axtls/samples/perl/Makefile | 43 + user/mpy/lib/axtls/samples/perl/axssl.pl | 634 + user/mpy/lib/axtls/samples/vbnet/Makefile | 48 + user/mpy/lib/axtls/samples/vbnet/axssl.vb | 702 + user/mpy/lib/axtls/ssl/BigIntConfig.in | 145 + user/mpy/lib/axtls/ssl/Config.in | 341 + user/mpy/lib/axtls/ssl/Makefile | 125 + user/mpy/lib/axtls/ssl/asn1.c | 776 + user/mpy/lib/axtls/ssl/cert.h | 54 + user/mpy/lib/axtls/ssl/crypto_misc.h | 213 + user/mpy/lib/axtls/ssl/gen_cert.c | 370 + user/mpy/lib/axtls/ssl/loader.c | 492 + user/mpy/lib/axtls/ssl/openssl.c | 318 + user/mpy/lib/axtls/ssl/os_port.c | 0 user/mpy/lib/axtls/ssl/os_port.h | 1 + user/mpy/lib/axtls/ssl/os_port_micropython.h | 85 + user/mpy/lib/axtls/ssl/p12.c | 483 + user/mpy/lib/axtls/ssl/private_key.h | 54 + user/mpy/lib/axtls/ssl/ssl.h | 538 + user/mpy/lib/axtls/ssl/test/Makefile | 100 + user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem | 27 + user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer | Bin 0 -> 786 bytes user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.pem | 19 + .../axtls/ssl/test/axTLS.ca_x509_sha256.pem | 19 + .../mpy/lib/axtls/ssl/test/axTLS.encrypted.p8 | Bin 0 -> 673 bytes .../lib/axtls/ssl/test/axTLS.encrypted_pem.p8 | 17 + user/mpy/lib/axtls/ssl/test/axTLS.key_1024 | Bin 0 -> 609 bytes .../mpy/lib/axtls/ssl/test/axTLS.key_1024.pem | 15 + user/mpy/lib/axtls/ssl/test/axTLS.key_2048 | Bin 0 -> 1192 bytes .../mpy/lib/axtls/ssl/test/axTLS.key_2048.pem | 27 + user/mpy/lib/axtls/ssl/test/axTLS.key_4096 | Bin 0 -> 2347 bytes .../mpy/lib/axtls/ssl/test/axTLS.key_4096.pem | 51 + .../lib/axtls/ssl/test/axTLS.key_aes128.pem | 18 + .../lib/axtls/ssl/test/axTLS.key_aes256.pem | 18 + .../lib/axtls/ssl/test/axTLS.key_device.pem | 27 + .../axtls/ssl/test/axTLS.key_end_chain.pem | 27 + .../ssl/test/axTLS.key_intermediate_ca.pem | 27 + .../ssl/test/axTLS.key_intermediate_ca2.pem | 27 + user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 | Bin 0 -> 1612 bytes .../lib/axtls/ssl/test/axTLS.unencrypted.p8 | Bin 0 -> 635 bytes .../axtls/ssl/test/axTLS.unencrypted_pem.p8 | 16 + user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 | Bin 0 -> 2521 bytes .../lib/axtls/ssl/test/axTLS.withoutCA.p12 | Bin 0 -> 1702 bytes .../lib/axtls/ssl/test/axTLS.x509_1024.cer | Bin 0 -> 604 bytes .../lib/axtls/ssl/test/axTLS.x509_1024.pem | 15 + .../axtls/ssl/test/axTLS.x509_1024_sha256.pem | 15 + .../axtls/ssl/test/axTLS.x509_1024_sha384.pem | 15 + .../axtls/ssl/test/axTLS.x509_1024_sha512.pem | 15 + .../lib/axtls/ssl/test/axTLS.x509_2048.cer | Bin 0 -> 736 bytes .../lib/axtls/ssl/test/axTLS.x509_2048.pem | 18 + .../lib/axtls/ssl/test/axTLS.x509_4096.cer | Bin 0 -> 992 bytes .../lib/axtls/ssl/test/axTLS.x509_4096.pem | 23 + .../lib/axtls/ssl/test/axTLS.x509_aes128.pem | 15 + .../lib/axtls/ssl/test/axTLS.x509_aes256.pem | 15 + .../axtls/ssl/test/axTLS.x509_bad_after.pem | 15 + .../axtls/ssl/test/axTLS.x509_bad_before.pem | 15 + .../lib/axtls/ssl/test/axTLS.x509_device.cer | Bin 0 -> 466 bytes .../lib/axtls/ssl/test/axTLS.x509_device.pem | 34 + .../axtls/ssl/test/axTLS.x509_end_chain.pem | 19 + .../ssl/test/axTLS.x509_end_chain_bad.pem | 19 + .../ssl/test/axTLS.x509_intermediate_ca.pem | 19 + .../ssl/test/axTLS.x509_intermediate_ca2.pem | 37 + user/mpy/lib/axtls/ssl/test/ca-bundle.crt | 3585 + .../axtls/ssl/test/camster_duckdns_org.crt | 31 + user/mpy/lib/axtls/ssl/test/comodo.sha384.cer | 32 + .../axtls/ssl/test/deutsche_telecom.x509_ca | Bin 0 -> 670 bytes user/mpy/lib/axtls/ssl/test/equifax.x509_ca | Bin 0 -> 646 bytes user/mpy/lib/axtls/ssl/test/gnutls.cer | Bin 0 -> 599 bytes user/mpy/lib/axtls/ssl/test/header_issue.dat | Bin 0 -> 1159 bytes user/mpy/lib/axtls/ssl/test/killgnutls.sh | 2 + user/mpy/lib/axtls/ssl/test/killopenssl.sh | 2 + user/mpy/lib/axtls/ssl/test/make_certs.sh | 253 + user/mpy/lib/axtls/ssl/test/microsoft.x509_ca | Bin 0 -> 1046 bytes .../lib/axtls/ssl/test/microsoft.x509_ca.pem | 24 + user/mpy/lib/axtls/ssl/test/ms_iis.cer | 13 + user/mpy/lib/axtls/ssl/test/perf_bigint.c | 234 + .../mpy/lib/axtls/ssl/test/qualityssl.com.der | Bin 0 -> 1385 bytes user/mpy/lib/axtls/ssl/test/socgen.cer | Bin 0 -> 980 bytes user/mpy/lib/axtls/ssl/test/ssltest.c | 2589 + user/mpy/lib/axtls/ssl/test/test_axssl.sh | 163 + user/mpy/lib/axtls/ssl/test/thawte.x509_ca | Bin 0 -> 811 bytes .../lib/axtls/ssl/test/verisign.x509_ca.pem | 16 + .../axtls/ssl/test/verisign.x509_my_cert.pem | 25 + user/mpy/lib/axtls/ssl/tls1.c | 2464 + user/mpy/lib/axtls/ssl/tls1.h | 329 + user/mpy/lib/axtls/ssl/tls1_clnt.c | 546 + user/mpy/lib/axtls/ssl/tls1_svr.c | 533 + user/mpy/lib/axtls/ssl/x509.c | 861 + user/mpy/lib/axtls/www/bin/.htaccess | 2 + user/mpy/lib/axtls/www/favicon.ico | Bin 0 -> 22486 bytes user/mpy/lib/axtls/www/index.html | 7103 + user/mpy/lib/axtls/www/lua/download.lua | 75 + user/mpy/lib/axtls/www/lua/env.lua | 26 + user/mpy/lib/axtls/www/lua/overview.lp | 64 + user/mpy/lib/axtls/www/lua/prepara_sql2.lua | 31 + user/mpy/lib/axtls/www/lua/test_conc.lua | 38 + user/mpy/lib/axtls/www/lua/test_cookies.lp | 13 + user/mpy/lib/axtls/www/lua/test_cookies.lua | 14 + user/mpy/lib/axtls/www/lua/test_err.lua | 4 + user/mpy/lib/axtls/www/lua/test_fs.lua | 23 + user/mpy/lib/axtls/www/lua/test_htk.lua | 22 + user/mpy/lib/axtls/www/lua/test_lib.lua | 31 + user/mpy/lib/axtls/www/lua/test_main.html | 127 + user/mpy/lib/axtls/www/lua/test_main.lp | 31 + user/mpy/lib/axtls/www/lua/test_main.lua | 46 + user/mpy/lib/axtls/www/lua/test_session.lua | 43 + user/mpy/lib/axtls/www/lua/test_sql.lua | 13 + user/mpy/lib/axtls/www/lua/test_sql2.lua | 24 + user/mpy/lib/axtls/www/lua/test_variables.lp | 14 + user/mpy/lib/axtls/www/test_dir/bin/.htaccess | 1 + .../lib/axtls/www/test_dir/no_http/.htaccess | 1 + .../lib/axtls/www/test_dir/no_http/.htpasswd | 2 + .../lib/axtls/www/test_dir/no_http/index.html | 6 + .../lib/axtls/www/test_dir/no_ssl/.htaccess | 1 + .../lib/axtls/www/test_dir/no_ssl/index.html | 6 + user/mpy/lib/berkeley-db-1.xx/Makefile.inc | 10 + user/mpy/lib/berkeley-db-1.xx/PORT/Makefile | 102 + user/mpy/lib/berkeley-db-1.xx/PORT/README | 131 + .../berkeley-db-1.xx/PORT/aix.3.2/Makefile | 102 + .../lib/berkeley-db-1.xx/PORT/aix.3.2/clib | 1 + .../PORT/aix.3.2/include/cdefs.h | 1 + .../PORT/aix.3.2/include/compat.h | 231 + .../PORT/aix.3.2/include/db.h | 1 + .../PORT/aix.3.2/include/mpool.h | 1 + .../PORT/aix.3.2/include/ndbm.h | 1 + .../PORT/aix.3.2/include/queue.h | 1 + .../mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys | 1 + .../berkeley-db-1.xx/PORT/bsd.4.4/Makefile | 1 + .../lib/berkeley-db-1.xx/PORT/bsd.4.4/clib | 1 + .../PORT/bsd.4.4/include/cdefs.h | 1 + .../PORT/bsd.4.4/include/compat.h | 1 + .../PORT/bsd.4.4/include/db.h | 222 + .../PORT/bsd.4.4/include/mpool.h | 1 + .../PORT/bsd.4.4/include/ndbm.h | 1 + .../PORT/bsd.4.4/include/queue.h | 1 + .../mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys | 1 + .../berkeley-db-1.xx/PORT/bsdi.1.0/Makefile | 1 + .../PORT/bsdi.1.0/OTHER_PATCHES | 19 + .../lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib | 1 + .../PORT/bsdi.1.0/include/assert.h | 54 + .../PORT/bsdi.1.0/include/cdefs.h | 1 + .../PORT/bsdi.1.0/include/compat.h | 231 + .../PORT/bsdi.1.0/include/db.h | 1 + .../PORT/bsdi.1.0/include/mpool.h | 1 + .../PORT/bsdi.1.0/include/ndbm.h | 1 + .../PORT/bsdi.1.0/include/queue.h | 1 + .../PORT/bsdi.1.0/local/local.h | 87 + .../PORT/bsdi.1.0/local/makebuf.c | 118 + .../PORT/bsdi.1.0/local/setvbuf.c | 148 + .../lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys | 1 + .../lib/berkeley-db-1.xx/PORT/clib/memmove.c | 139 + .../lib/berkeley-db-1.xx/PORT/clib/mktemp.c | 126 + .../lib/berkeley-db-1.xx/PORT/clib/snprintf.c | 54 + .../lib/berkeley-db-1.xx/PORT/clib/strerror.c | 67 + .../berkeley-db-1.xx/PORT/dgux.5.4/Makefile | 103 + .../lib/berkeley-db-1.xx/PORT/dgux.5.4/clib | 1 + .../PORT/dgux.5.4/include/cdefs.h | 1 + .../PORT/dgux.5.4/include/compat.h | 231 + .../PORT/dgux.5.4/include/db.h | 1 + .../PORT/dgux.5.4/include/mpool.h | 1 + .../PORT/dgux.5.4/include/ndbm.h | 1 + .../PORT/dgux.5.4/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/dgux.5.4/sys | 1 + user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 | 1 + .../berkeley-db-1.xx/PORT/hpux.9.01/Makefile | 102 + .../lib/berkeley-db-1.xx/PORT/hpux.9.01/clib | 1 + .../PORT/hpux.9.01/include/cdefs.h | 1 + .../PORT/hpux.9.01/include/compat.h | 231 + .../PORT/hpux.9.01/include/db.h | 1 + .../PORT/hpux.9.01/include/mpool.h | 1 + .../PORT/hpux.9.01/include/ndbm.h | 1 + .../PORT/hpux.9.01/include/queue.h | 1 + .../PORT/hpux.9.01/local/hp_siglist.c | 75 + .../lib/berkeley-db-1.xx/PORT/hpux.9.01/sys | 1 + .../berkeley-db-1.xx/PORT/include/bsd-queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/include/cdefs.h | 122 + .../berkeley-db-1.xx/PORT/include/compat.h | 233 + .../lib/berkeley-db-1.xx/PORT/include/db.h | 1 + .../PORT/include/filevtable.h | 1 + .../lib/berkeley-db-1.xx/PORT/include/mpool.h | 1 + .../lib/berkeley-db-1.xx/PORT/include/ndbm.h | 77 + .../lib/berkeley-db-1.xx/PORT/include/queue.h | 245 + .../berkeley-db-1.xx/PORT/irix.4.05F/Makefile | 103 + .../PORT/irix.4.05F/OTHER_PATCHES | 32 + .../lib/berkeley-db-1.xx/PORT/irix.4.05F/clib | 1 + .../PORT/irix.4.05F/include/cdefs.h | 1 + .../PORT/irix.4.05F/include/compat.h | 231 + .../PORT/irix.4.05F/include/db.h | 1 + .../PORT/irix.4.05F/include/mpool.h | 1 + .../PORT/irix.4.05F/include/ndbm.h | 1 + .../PORT/irix.4.05F/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/irix.4.05F/sys | 1 + .../lib/berkeley-db-1.xx/PORT/linux/Makefile | 102 + .../berkeley-db-1.xx/PORT/linux/OTHER_PATCHES | 29 + user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib | 1 + .../PORT/linux/include/compat.h | 231 + .../berkeley-db-1.xx/PORT/linux/include/db.h | 1 + .../PORT/linux/include/mpool.h | 1 + .../PORT/linux/include/ndbm.h | 1 + user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys | 1 + .../berkeley-db-1.xx/PORT/osf.1.0.2/Makefile | 102 + .../lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib | 1 + .../PORT/osf.1.0.2/include/cdefs.h | 1 + .../PORT/osf.1.0.2/include/compat.h | 231 + .../PORT/osf.1.0.2/include/db.h | 1 + .../PORT/osf.1.0.2/include/mpool.h | 1 + .../PORT/osf.1.0.2/include/ndbm.h | 1 + .../PORT/osf.1.0.2/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys | 1 + user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 | 1 + user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 | 1 + .../berkeley-db-1.xx/PORT/ptx.2.0/Makefile | 104 + .../PORT/ptx.2.0/OTHER_PATCHES | 95 + .../lib/berkeley-db-1.xx/PORT/ptx.2.0/clib | 1 + .../PORT/ptx.2.0/include/cdefs.h | 1 + .../PORT/ptx.2.0/include/compat.h | 232 + .../PORT/ptx.2.0/include/db.h | 1 + .../PORT/ptx.2.0/include/mpool.h | 1 + .../PORT/ptx.2.0/include/ndbm.h | 1 + .../PORT/ptx.2.0/include/pathnames.h | 45 + .../PORT/ptx.2.0/include/queue.h | 1 + .../mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys | 1 + .../berkeley-db-1.xx/PORT/sinix.5.41/Makefile | 102 + .../lib/berkeley-db-1.xx/PORT/sinix.5.41/clib | 1 + .../PORT/sinix.5.41/include/cdefs.h | 1 + .../PORT/sinix.5.41/include/compat.h | 231 + .../PORT/sinix.5.41/include/db.h | 1 + .../PORT/sinix.5.41/include/mpool.h | 1 + .../PORT/sinix.5.41/include/ndbm.h | 1 + .../PORT/sinix.5.41/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/sinix.5.41/sys | 1 + .../mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 | 1 + .../PORT/sunos.4.1.1/Makefile | 102 + .../berkeley-db-1.xx/PORT/sunos.4.1.1/clib | 1 + .../PORT/sunos.4.1.1/include/cdefs.h | 1 + .../PORT/sunos.4.1.1/include/compat.h | 231 + .../PORT/sunos.4.1.1/include/db.h | 1 + .../PORT/sunos.4.1.1/include/mpool.h | 1 + .../PORT/sunos.4.1.1/include/ndbm.h | 1 + .../PORT/sunos.4.1.1/include/pathnames.h | 45 + .../PORT/sunos.4.1.1/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys | 1 + .../mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 | 1 + .../mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 | 1 + .../berkeley-db-1.xx/PORT/sunos.5.2/Makefile | 102 + .../lib/berkeley-db-1.xx/PORT/sunos.5.2/clib | 1 + .../PORT/sunos.5.2/include/cdefs.h | 1 + .../PORT/sunos.5.2/include/compat.h | 236 + .../PORT/sunos.5.2/include/db.h | 1 + .../PORT/sunos.5.2/include/mpool.h | 1 + .../PORT/sunos.5.2/include/ndbm.h | 1 + .../PORT/sunos.5.2/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/sunos.5.2/sys | 1 + .../berkeley-db-1.xx/PORT/ultrix.4.2/Makefile | 102 + .../lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib | 1 + .../PORT/ultrix.4.2/include/cdefs.h | 1 + .../PORT/ultrix.4.2/include/compat.h | 231 + .../PORT/ultrix.4.2/include/db.h | 230 + .../PORT/ultrix.4.2/include/mpool.h | 1 + .../PORT/ultrix.4.2/include/ndbm.h | 1 + .../PORT/ultrix.4.2/include/queue.h | 1 + .../lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys | 1 + user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 | 1 + user/mpy/lib/berkeley-db-1.xx/README | 40 + .../lib/berkeley-db-1.xx/btree/Makefile.inc | 7 + .../mpy/lib/berkeley-db-1.xx/btree/bt_close.c | 179 + user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c | 221 + .../mpy/lib/berkeley-db-1.xx/btree/bt_debug.c | 329 + .../lib/berkeley-db-1.xx/btree/bt_delete.c | 657 + user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c | 105 + user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c | 412 + .../lib/berkeley-db-1.xx/btree/bt_overflow.c | 228 + user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c | 100 + user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c | 321 + .../lib/berkeley-db-1.xx/btree/bt_search.c | 213 + user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c | 460 + .../mpy/lib/berkeley-db-1.xx/btree/bt_split.c | 834 + .../mpy/lib/berkeley-db-1.xx/btree/bt_utils.c | 260 + user/mpy/lib/berkeley-db-1.xx/btree/btree.h | 384 + user/mpy/lib/berkeley-db-1.xx/btree/extern.h | 70 + user/mpy/lib/berkeley-db-1.xx/btree/tags | 1 + user/mpy/lib/berkeley-db-1.xx/changelog | 103 + user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc | 5 + user/mpy/lib/berkeley-db-1.xx/db/db.c | 99 + user/mpy/lib/berkeley-db-1.xx/db/tags | 205 + user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps | Bin 0 -> 16754 bytes .../mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps | Bin 0 -> 26477 bytes user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps | Bin 0 -> 11349 bytes .../lib/berkeley-db-1.xx/docs/hash.usenix.ps | Bin 0 -> 158771 bytes .../lib/berkeley-db-1.xx/docs/libtp.usenix.ps | Bin 0 -> 168201 bytes user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps | Bin 0 -> 13573 bytes user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps | Bin 0 -> 14632 bytes .../lib/berkeley-db-1.xx/hash/Makefile.inc | 6 + user/mpy/lib/berkeley-db-1.xx/hash/README | 72 + user/mpy/lib/berkeley-db-1.xx/hash/extern.h | 65 + user/mpy/lib/berkeley-db-1.xx/hash/hash.c | 994 + user/mpy/lib/berkeley-db-1.xx/hash/hash.h | 293 + .../lib/berkeley-db-1.xx/hash/hash_bigkey.c | 667 + user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c | 355 + .../mpy/lib/berkeley-db-1.xx/hash/hash_func.c | 212 + .../mpy/lib/berkeley-db-1.xx/hash/hash_log2.c | 54 + .../mpy/lib/berkeley-db-1.xx/hash/hash_page.c | 944 + user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c | 107 + user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c | 202 + user/mpy/lib/berkeley-db-1.xx/hash/page.h | 92 + user/mpy/lib/berkeley-db-1.xx/hash/search.h | 51 + user/mpy/lib/berkeley-db-1.xx/hash/tags | 1 + user/mpy/lib/berkeley-db-1.xx/include/db.h | 237 + .../lib/berkeley-db-1.xx/include/filevtable.h | 54 + user/mpy/lib/berkeley-db-1.xx/include/mpool.h | 101 + user/mpy/lib/berkeley-db-1.xx/include/tags | 1 + .../mpy/lib/berkeley-db-1.xx/man/Makefile.inc | 7 + user/mpy/lib/berkeley-db-1.xx/man/btree.3 | 233 + user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 | 476 + user/mpy/lib/berkeley-db-1.xx/man/hash.3 | 159 + user/mpy/lib/berkeley-db-1.xx/man/mpool.3 | 219 + user/mpy/lib/berkeley-db-1.xx/man/recno.3 | 216 + .../lib/berkeley-db-1.xx/mpool/Makefile.inc | 5 + user/mpy/lib/berkeley-db-1.xx/mpool/README | 7 + user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c | 452 + .../lib/berkeley-db-1.xx/mpool/mpool.libtp | 746 + user/mpy/lib/berkeley-db-1.xx/mpool/tags | 1 + .../lib/berkeley-db-1.xx/recno/Makefile.inc | 6 + user/mpy/lib/berkeley-db-1.xx/recno/extern.h | 54 + .../lib/berkeley-db-1.xx/recno/rec_close.c | 182 + .../lib/berkeley-db-1.xx/recno/rec_delete.c | 197 + user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c | 311 + .../mpy/lib/berkeley-db-1.xx/recno/rec_open.c | 241 + user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c | 280 + .../lib/berkeley-db-1.xx/recno/rec_search.c | 126 + user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c | 131 + .../lib/berkeley-db-1.xx/recno/rec_utils.c | 122 + user/mpy/lib/berkeley-db-1.xx/recno/recno.h | 39 + user/mpy/lib/berkeley-db-1.xx/recno/tags | 1 + user/mpy/lib/berkeley-db-1.xx/test/Makefile | 23 + user/mpy/lib/berkeley-db-1.xx/test/README | 74 + .../berkeley-db-1.xx/test/btree.tests/main.c | 765 + user/mpy/lib/berkeley-db-1.xx/test/dbtest.c | 753 + .../test/hash.tests/driver2.c | 114 + .../test/hash.tests/makedb.sh | 13 + .../test/hash.tests/tcreat3.c | 105 + .../berkeley-db-1.xx/test/hash.tests/tdel.c | 122 + .../berkeley-db-1.xx/test/hash.tests/testit | 147 + .../berkeley-db-1.xx/test/hash.tests/thash4.c | 132 + .../berkeley-db-1.xx/test/hash.tests/tread2.c | 105 + .../berkeley-db-1.xx/test/hash.tests/tseq.c | 88 + .../test/hash.tests/tverify.c | 107 + user/mpy/lib/berkeley-db-1.xx/test/run.test | 705 + user/mpy/lib/cmsis/inc/cmsis_armcc.h | 734 + user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h | 1800 + user/mpy/lib/cmsis/inc/cmsis_gcc.h | 1373 + user/mpy/lib/cmsis/inc/core_cm0.h | 798 + user/mpy/lib/cmsis/inc/core_cm0plus.h | 914 + user/mpy/lib/cmsis/inc/core_cm3.h | 1763 + user/mpy/lib/cmsis/inc/core_cm4.h | 1937 + user/mpy/lib/cmsis/inc/core_cm7.h | 2512 + user/mpy/lib/cmsis/inc/core_cmFunc.h | 87 + user/mpy/lib/cmsis/inc/core_cmInstr.h | 87 + user/mpy/lib/cmsis/inc/core_cmSimd.h | 96 + user/mpy/lib/cmsis/inc/core_sc000.h | 926 + user/mpy/lib/cmsis/inc/core_sc300.h | 1745 + user/mpy/lib/embed/abort_.c | 7 + user/mpy/lib/libc/string0.c | 219 + user/mpy/lib/libffi/.gitignore | 36 + user/mpy/lib/libffi/.travis.yml | 22 + user/mpy/lib/libffi/ChangeLog.libffi | 584 + user/mpy/lib/libffi/ChangeLog.libffi-3.1 | 6000 + user/mpy/lib/libffi/ChangeLog.libgcj | 40 + user/mpy/lib/libffi/ChangeLog.v1 | 764 + user/mpy/lib/libffi/LICENSE | 21 + user/mpy/lib/libffi/Makefile.am | 174 + user/mpy/lib/libffi/README | 450 + user/mpy/lib/libffi/acinclude.m4 | 92 + user/mpy/lib/libffi/autogen.sh | 2 + user/mpy/lib/libffi/configure.ac | 372 + user/mpy/lib/libffi/configure.host | 259 + user/mpy/lib/libffi/doc/libffi.texi | 765 + user/mpy/lib/libffi/doc/version.texi | 4 + .../generate-darwin-source-and-headers.py | 209 + user/mpy/lib/libffi/include/Makefile.am | 10 + user/mpy/lib/libffi/include/ffi.h.in | 503 + user/mpy/lib/libffi/include/ffi_cfi.h | 55 + user/mpy/lib/libffi/include/ffi_common.h | 132 + user/mpy/lib/libffi/libffi.pc.in | 11 + .../libffi/libffi.xcodeproj/project.pbxproj | 637 + user/mpy/lib/libffi/libtool-version | 29 + user/mpy/lib/libffi/m4/asmcfi.m4 | 13 + user/mpy/lib/libffi/m4/ax_append_flag.m4 | 69 + user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 | 181 + user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 | 122 + .../lib/libffi/m4/ax_check_compile_flag.m4 | 72 + user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 | 84 + user/mpy/lib/libffi/m4/ax_configure_args.m4 | 70 + user/mpy/lib/libffi/m4/ax_enable_builddir.m4 | 301 + user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 | 225 + user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 | 79 + user/mpy/lib/libffi/man/Makefile.am | 8 + user/mpy/lib/libffi/man/ffi.3 | 41 + user/mpy/lib/libffi/man/ffi_call.3 | 103 + user/mpy/lib/libffi/man/ffi_prep_cif.3 | 68 + user/mpy/lib/libffi/man/ffi_prep_cif_var.3 | 73 + user/mpy/lib/libffi/msvcc.sh | 257 + user/mpy/lib/libffi/src/aarch64/ffi.c | 1152 + user/mpy/lib/libffi/src/aarch64/ffitarget.h | 73 + user/mpy/lib/libffi/src/aarch64/internal.h | 67 + user/mpy/lib/libffi/src/aarch64/sysv.S | 434 + user/mpy/lib/libffi/src/alpha/ffi.c | 521 + user/mpy/lib/libffi/src/alpha/ffitarget.h | 57 + user/mpy/lib/libffi/src/alpha/internal.h | 23 + user/mpy/lib/libffi/src/alpha/osf.S | 282 + user/mpy/lib/libffi/src/arc/arcompact.S | 135 + user/mpy/lib/libffi/src/arc/ffi.c | 268 + user/mpy/lib/libffi/src/arc/ffitarget.h | 53 + user/mpy/lib/libffi/src/arm/ffi.c | 1043 + user/mpy/lib/libffi/src/arm/ffitarget.h | 69 + user/mpy/lib/libffi/src/arm/internal.h | 7 + user/mpy/lib/libffi/src/arm/sysv.S | 335 + user/mpy/lib/libffi/src/avr32/ffi.c | 423 + user/mpy/lib/libffi/src/avr32/ffitarget.h | 55 + user/mpy/lib/libffi/src/avr32/sysv.S | 208 + user/mpy/lib/libffi/src/bfin/ffi.c | 196 + user/mpy/lib/libffi/src/bfin/ffitarget.h | 43 + user/mpy/lib/libffi/src/bfin/sysv.S | 179 + user/mpy/lib/libffi/src/closures.c | 688 + user/mpy/lib/libffi/src/cris/ffi.c | 386 + user/mpy/lib/libffi/src/cris/ffitarget.h | 56 + user/mpy/lib/libffi/src/cris/sysv.S | 215 + user/mpy/lib/libffi/src/debug.c | 64 + user/mpy/lib/libffi/src/dlmalloc.c | 5161 + user/mpy/lib/libffi/src/frv/eabi.S | 128 + user/mpy/lib/libffi/src/frv/ffi.c | 292 + user/mpy/lib/libffi/src/frv/ffitarget.h | 62 + user/mpy/lib/libffi/src/ia64/ffi.c | 586 + user/mpy/lib/libffi/src/ia64/ffitarget.h | 55 + user/mpy/lib/libffi/src/ia64/ia64_flags.h | 40 + user/mpy/lib/libffi/src/ia64/unix.S | 560 + user/mpy/lib/libffi/src/java_raw_api.c | 374 + user/mpy/lib/libffi/src/m32r/ffi.c | 232 + user/mpy/lib/libffi/src/m32r/ffitarget.h | 53 + user/mpy/lib/libffi/src/m32r/sysv.S | 121 + user/mpy/lib/libffi/src/m68k/ffi.c | 362 + user/mpy/lib/libffi/src/m68k/ffitarget.h | 54 + user/mpy/lib/libffi/src/m68k/sysv.S | 330 + user/mpy/lib/libffi/src/m88k/ffi.c | 400 + user/mpy/lib/libffi/src/m88k/ffitarget.h | 49 + user/mpy/lib/libffi/src/m88k/obsd.S | 209 + user/mpy/lib/libffi/src/metag/ffi.c | 330 + user/mpy/lib/libffi/src/metag/ffitarget.h | 53 + user/mpy/lib/libffi/src/metag/sysv.S | 311 + user/mpy/lib/libffi/src/microblaze/ffi.c | 321 + .../mpy/lib/libffi/src/microblaze/ffitarget.h | 53 + user/mpy/lib/libffi/src/microblaze/sysv.S | 302 + user/mpy/lib/libffi/src/mips/ffi.c | 1050 + user/mpy/lib/libffi/src/mips/ffitarget.h | 247 + user/mpy/lib/libffi/src/mips/n32.S | 576 + user/mpy/lib/libffi/src/mips/o32.S | 381 + user/mpy/lib/libffi/src/moxie/eabi.S | 101 + user/mpy/lib/libffi/src/moxie/ffi.c | 272 + user/mpy/lib/libffi/src/moxie/ffitarget.h | 52 + user/mpy/lib/libffi/src/nios2/ffi.c | 304 + user/mpy/lib/libffi/src/nios2/ffitarget.h | 52 + user/mpy/lib/libffi/src/nios2/sysv.S | 136 + user/mpy/lib/libffi/src/or1k/ffi.c | 328 + user/mpy/lib/libffi/src/or1k/ffitarget.h | 58 + user/mpy/lib/libffi/src/or1k/sysv.S | 107 + user/mpy/lib/libffi/src/pa/ffi.c | 719 + user/mpy/lib/libffi/src/pa/ffitarget.h | 85 + user/mpy/lib/libffi/src/pa/hpux32.S | 368 + user/mpy/lib/libffi/src/pa/linux.S | 357 + user/mpy/lib/libffi/src/powerpc/aix.S | 328 + user/mpy/lib/libffi/src/powerpc/aix_closure.S | 447 + user/mpy/lib/libffi/src/powerpc/asm.h | 125 + user/mpy/lib/libffi/src/powerpc/darwin.S | 378 + .../lib/libffi/src/powerpc/darwin_closure.S | 571 + user/mpy/lib/libffi/src/powerpc/ffi.c | 173 + user/mpy/lib/libffi/src/powerpc/ffi_darwin.c | 1359 + user/mpy/lib/libffi/src/powerpc/ffi_linux64.c | 945 + user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h | 94 + user/mpy/lib/libffi/src/powerpc/ffi_sysv.c | 934 + user/mpy/lib/libffi/src/powerpc/ffitarget.h | 195 + user/mpy/lib/libffi/src/powerpc/linux64.S | 228 + .../lib/libffi/src/powerpc/linux64_closure.S | 488 + user/mpy/lib/libffi/src/powerpc/ppc_closure.S | 397 + user/mpy/lib/libffi/src/powerpc/sysv.S | 175 + user/mpy/lib/libffi/src/prep_cif.c | 242 + user/mpy/lib/libffi/src/raw_api.c | 267 + user/mpy/lib/libffi/src/s390/ffi.c | 756 + user/mpy/lib/libffi/src/s390/ffitarget.h | 70 + user/mpy/lib/libffi/src/s390/internal.h | 11 + user/mpy/lib/libffi/src/s390/sysv.S | 325 + user/mpy/lib/libffi/src/sh/ffi.c | 717 + user/mpy/lib/libffi/src/sh/ffitarget.h | 54 + user/mpy/lib/libffi/src/sh/sysv.S | 850 + user/mpy/lib/libffi/src/sh64/ffi.c | 469 + user/mpy/lib/libffi/src/sh64/ffitarget.h | 58 + user/mpy/lib/libffi/src/sh64/sysv.S | 539 + user/mpy/lib/libffi/src/sparc/ffi.c | 468 + user/mpy/lib/libffi/src/sparc/ffi64.c | 608 + user/mpy/lib/libffi/src/sparc/ffitarget.h | 81 + user/mpy/lib/libffi/src/sparc/internal.h | 26 + user/mpy/lib/libffi/src/sparc/v8.S | 443 + user/mpy/lib/libffi/src/sparc/v9.S | 440 + user/mpy/lib/libffi/src/tile/ffi.c | 355 + user/mpy/lib/libffi/src/tile/ffitarget.h | 65 + user/mpy/lib/libffi/src/tile/tile.S | 360 + user/mpy/lib/libffi/src/types.c | 106 + user/mpy/lib/libffi/src/vax/elfbsd.S | 195 + user/mpy/lib/libffi/src/vax/ffi.c | 276 + user/mpy/lib/libffi/src/vax/ffitarget.h | 49 + user/mpy/lib/libffi/src/x86/ffi.c | 729 + user/mpy/lib/libffi/src/x86/ffi64.c | 824 + user/mpy/lib/libffi/src/x86/ffitarget.h | 139 + user/mpy/lib/libffi/src/x86/ffiw64.c | 281 + user/mpy/lib/libffi/src/x86/internal.h | 29 + user/mpy/lib/libffi/src/x86/internal64.h | 22 + user/mpy/lib/libffi/src/x86/sysv.S | 1040 + user/mpy/lib/libffi/src/x86/unix64.S | 546 + user/mpy/lib/libffi/src/x86/win64.S | 219 + user/mpy/lib/libffi/src/xtensa/ffi.c | 298 + user/mpy/lib/libffi/src/xtensa/ffitarget.h | 53 + user/mpy/lib/libffi/src/xtensa/sysv.S | 253 + user/mpy/lib/libffi/stamp-h.in | 1 + user/mpy/lib/libffi/testsuite/Makefile.am | 85 + .../lib/libffi/testsuite/config/default.exp | 1 + user/mpy/lib/libffi/testsuite/lib/libffi.exp | 431 + .../libffi/testsuite/lib/target-libpath.exp | 283 + user/mpy/lib/libffi/testsuite/lib/wrapper.exp | 45 + .../lib/libffi/testsuite/libffi.call/call.exp | 30 + .../testsuite/libffi.call/closure_fn0.c | 89 + .../testsuite/libffi.call/closure_fn1.c | 81 + .../testsuite/libffi.call/closure_fn2.c | 81 + .../testsuite/libffi.call/closure_fn3.c | 82 + .../testsuite/libffi.call/closure_fn4.c | 89 + .../testsuite/libffi.call/closure_fn5.c | 92 + .../testsuite/libffi.call/closure_fn6.c | 90 + .../testsuite/libffi.call/closure_loc_fn0.c | 95 + .../testsuite/libffi.call/closure_simple.c | 55 + .../libffi/testsuite/libffi.call/cls_12byte.c | 94 + .../libffi/testsuite/libffi.call/cls_16byte.c | 95 + .../libffi/testsuite/libffi.call/cls_18byte.c | 96 + .../libffi/testsuite/libffi.call/cls_19byte.c | 102 + .../testsuite/libffi.call/cls_1_1byte.c | 89 + .../libffi/testsuite/libffi.call/cls_20byte.c | 91 + .../testsuite/libffi.call/cls_20byte1.c | 93 + .../libffi/testsuite/libffi.call/cls_24byte.c | 113 + .../libffi/testsuite/libffi.call/cls_2byte.c | 90 + .../testsuite/libffi.call/cls_3_1byte.c | 95 + .../libffi/testsuite/libffi.call/cls_3byte1.c | 90 + .../libffi/testsuite/libffi.call/cls_3byte2.c | 90 + .../testsuite/libffi.call/cls_4_1byte.c | 98 + .../libffi/testsuite/libffi.call/cls_4byte.c | 90 + .../testsuite/libffi.call/cls_5_1_byte.c | 109 + .../libffi/testsuite/libffi.call/cls_5byte.c | 98 + .../libffi/testsuite/libffi.call/cls_64byte.c | 124 + .../testsuite/libffi.call/cls_6_1_byte.c | 113 + .../libffi/testsuite/libffi.call/cls_6byte.c | 99 + .../testsuite/libffi.call/cls_7_1_byte.c | 117 + .../libffi/testsuite/libffi.call/cls_7byte.c | 97 + .../libffi/testsuite/libffi.call/cls_8byte.c | 88 + .../libffi/testsuite/libffi.call/cls_9byte1.c | 90 + .../libffi/testsuite/libffi.call/cls_9byte2.c | 91 + .../testsuite/libffi.call/cls_align_double.c | 93 + .../testsuite/libffi.call/cls_align_float.c | 91 + .../libffi.call/cls_align_longdouble.c | 92 + .../libffi.call/cls_align_longdouble_split.c | 132 + .../libffi.call/cls_align_longdouble_split2.c | 115 + .../testsuite/libffi.call/cls_align_pointer.c | 95 + .../testsuite/libffi.call/cls_align_sint16.c | 91 + .../testsuite/libffi.call/cls_align_sint32.c | 91 + .../testsuite/libffi.call/cls_align_sint64.c | 92 + .../testsuite/libffi.call/cls_align_uint16.c | 91 + .../testsuite/libffi.call/cls_align_uint32.c | 91 + .../testsuite/libffi.call/cls_align_uint64.c | 93 + .../testsuite/libffi.call/cls_dbls_struct.c | 66 + .../libffi/testsuite/libffi.call/cls_double.c | 43 + .../testsuite/libffi.call/cls_double_va.c | 61 + .../libffi/testsuite/libffi.call/cls_float.c | 42 + .../testsuite/libffi.call/cls_longdouble.c | 105 + .../testsuite/libffi.call/cls_longdouble_va.c | 61 + .../libffi.call/cls_many_mixed_args.c | 70 + .../libffi.call/cls_many_mixed_float_double.c | 55 + .../testsuite/libffi.call/cls_multi_schar.c | 74 + .../testsuite/libffi.call/cls_multi_sshort.c | 74 + .../libffi.call/cls_multi_sshortchar.c | 86 + .../testsuite/libffi.call/cls_multi_uchar.c | 91 + .../testsuite/libffi.call/cls_multi_ushort.c | 74 + .../libffi.call/cls_multi_ushortchar.c | 86 + .../testsuite/libffi.call/cls_pointer.c | 74 + .../testsuite/libffi.call/cls_pointer_stack.c | 142 + .../libffi/testsuite/libffi.call/cls_schar.c | 44 + .../libffi/testsuite/libffi.call/cls_sint.c | 42 + .../libffi/testsuite/libffi.call/cls_sshort.c | 42 + .../testsuite/libffi.call/cls_struct_va1.c | 114 + .../libffi/testsuite/libffi.call/cls_uchar.c | 42 + .../testsuite/libffi.call/cls_uchar_va.c | 44 + .../libffi/testsuite/libffi.call/cls_uint.c | 43 + .../testsuite/libffi.call/cls_uint_va.c | 45 + .../testsuite/libffi.call/cls_ulong_va.c | 45 + .../testsuite/libffi.call/cls_ulonglong.c | 47 + .../libffi/testsuite/libffi.call/cls_ushort.c | 43 + .../testsuite/libffi.call/cls_ushort_va.c | 44 + .../testsuite/libffi.call/err_bad_abi.c | 36 + .../testsuite/libffi.call/err_bad_typedef.c | 26 + .../libffi/testsuite/libffi.call/ffitest.h | 135 + .../lib/libffi/testsuite/libffi.call/float.c | 59 + .../lib/libffi/testsuite/libffi.call/float1.c | 60 + .../lib/libffi/testsuite/libffi.call/float2.c | 58 + .../lib/libffi/testsuite/libffi.call/float3.c | 74 + .../lib/libffi/testsuite/libffi.call/float4.c | 62 + .../libffi/testsuite/libffi.call/float_va.c | 107 + .../testsuite/libffi.call/huge_struct.c | 341 + .../lib/libffi/testsuite/libffi.call/many.c | 59 + .../lib/libffi/testsuite/libffi.call/many2.c | 57 + .../testsuite/libffi.call/many_double.c | 70 + .../libffi/testsuite/libffi.call/many_mixed.c | 78 + .../lib/libffi/testsuite/libffi.call/negint.c | 52 + .../testsuite/libffi.call/nested_struct.c | 152 + .../testsuite/libffi.call/nested_struct1.c | 161 + .../testsuite/libffi.call/nested_struct10.c | 133 + .../testsuite/libffi.call/nested_struct11.c | 121 + .../testsuite/libffi.call/nested_struct2.c | 110 + .../testsuite/libffi.call/nested_struct3.c | 111 + .../testsuite/libffi.call/nested_struct4.c | 111 + .../testsuite/libffi.call/nested_struct5.c | 112 + .../testsuite/libffi.call/nested_struct6.c | 131 + .../testsuite/libffi.call/nested_struct7.c | 111 + .../testsuite/libffi.call/nested_struct8.c | 131 + .../testsuite/libffi.call/nested_struct9.c | 131 + .../libffi/testsuite/libffi.call/pr1172638.c | 127 + .../libffi/testsuite/libffi.call/problem1.c | 90 + .../libffi/testsuite/libffi.call/promotion.c | 59 + .../libffi/testsuite/libffi.call/pyobjc-tc.c | 114 + .../libffi/testsuite/libffi.call/return_dbl.c | 36 + .../testsuite/libffi.call/return_dbl1.c | 43 + .../testsuite/libffi.call/return_dbl2.c | 42 + .../libffi/testsuite/libffi.call/return_fl.c | 35 + .../libffi/testsuite/libffi.call/return_fl1.c | 36 + .../libffi/testsuite/libffi.call/return_fl2.c | 49 + .../libffi/testsuite/libffi.call/return_fl3.c | 42 + .../libffi/testsuite/libffi.call/return_ldl.c | 34 + .../libffi/testsuite/libffi.call/return_ll.c | 41 + .../libffi/testsuite/libffi.call/return_ll1.c | 43 + .../libffi/testsuite/libffi.call/return_sc.c | 36 + .../libffi/testsuite/libffi.call/return_sl.c | 38 + .../libffi/testsuite/libffi.call/return_uc.c | 38 + .../libffi/testsuite/libffi.call/return_ul.c | 38 + .../testsuite/libffi.call/stret_large.c | 145 + .../testsuite/libffi.call/stret_large2.c | 148 + .../testsuite/libffi.call/stret_medium.c | 124 + .../testsuite/libffi.call/stret_medium2.c | 125 + .../lib/libffi/testsuite/libffi.call/strlen.c | 44 + .../libffi/testsuite/libffi.call/strlen2.c | 49 + .../libffi/testsuite/libffi.call/strlen3.c | 49 + .../libffi/testsuite/libffi.call/strlen4.c | 55 + .../libffi/testsuite/libffi.call/struct1.c | 67 + .../libffi/testsuite/libffi.call/struct2.c | 67 + .../libffi/testsuite/libffi.call/struct3.c | 60 + .../libffi/testsuite/libffi.call/struct4.c | 64 + .../libffi/testsuite/libffi.call/struct5.c | 66 + .../libffi/testsuite/libffi.call/struct6.c | 64 + .../libffi/testsuite/libffi.call/struct7.c | 74 + .../libffi/testsuite/libffi.call/struct8.c | 81 + .../libffi/testsuite/libffi.call/struct9.c | 68 + .../testsuite/libffi.call/testclosure.c | 70 + .../testsuite/libffi.call/uninitialized.c | 61 + .../testsuite/libffi.call/unwindtest.cc | 117 + .../libffi.call/unwindtest_ffi_call.cc | 54 + .../lib/libffi/testsuite/libffi.call/va_1.c | 196 + .../libffi/testsuite/libffi.call/va_struct1.c | 121 + .../libffi/testsuite/libffi.call/va_struct2.c | 123 + .../libffi/testsuite/libffi.call/va_struct3.c | 125 + .../libffi.complex/cls_align_complex.inc | 91 + .../libffi.complex/cls_align_complex_double.c | 10 + .../libffi.complex/cls_align_complex_float.c | 10 + .../cls_align_complex_longdouble.c | 10 + .../testsuite/libffi.complex/cls_complex.inc | 42 + .../libffi.complex/cls_complex_double.c | 10 + .../libffi.complex/cls_complex_float.c | 10 + .../libffi.complex/cls_complex_longdouble.c | 10 + .../libffi.complex/cls_complex_struct.inc | 71 + .../cls_complex_struct_double.c | 10 + .../libffi.complex/cls_complex_struct_float.c | 10 + .../cls_complex_struct_longdouble.c | 10 + .../libffi.complex/cls_complex_va.inc | 80 + .../libffi.complex/cls_complex_va_double.c | 10 + .../libffi.complex/cls_complex_va_float.c | 16 + .../cls_complex_va_longdouble.c | 10 + .../testsuite/libffi.complex/complex.exp | 36 + .../testsuite/libffi.complex/complex.inc | 51 + .../libffi.complex/complex_defs_double.inc | 7 + .../libffi.complex/complex_defs_float.inc | 7 + .../complex_defs_longdouble.inc | 7 + .../testsuite/libffi.complex/complex_double.c | 10 + .../testsuite/libffi.complex/complex_float.c | 10 + .../testsuite/libffi.complex/complex_int.c | 86 + .../libffi.complex/complex_longdouble.c | 10 + .../libffi/testsuite/libffi.complex/ffitest.h | 1 + .../testsuite/libffi.complex/many_complex.inc | 78 + .../libffi.complex/many_complex_double.c | 10 + .../libffi.complex/many_complex_float.c | 10 + .../libffi.complex/many_complex_longdouble.c | 10 + .../libffi.complex/return_complex.inc | 37 + .../libffi.complex/return_complex1.inc | 41 + .../libffi.complex/return_complex1_double.c | 10 + .../libffi.complex/return_complex1_float.c | 10 + .../return_complex1_longdouble.c | 10 + .../libffi.complex/return_complex2.inc | 44 + .../libffi.complex/return_complex2_double.c | 10 + .../libffi.complex/return_complex2_float.c | 10 + .../return_complex2_longdouble.c | 10 + .../libffi.complex/return_complex_double.c | 10 + .../libffi.complex/return_complex_float.c | 10 + .../return_complex_longdouble.c | 10 + .../libffi/testsuite/libffi.go/aa-direct.c | 34 + .../lib/libffi/testsuite/libffi.go/closure1.c | 28 + .../lib/libffi/testsuite/libffi.go/ffitest.h | 1 + .../mpy/lib/libffi/testsuite/libffi.go/go.exp | 36 + .../libffi/testsuite/libffi.go/static-chain.h | 19 + user/mpy/lib/libffi/texinfo.tex | 10079 + user/mpy/lib/libm/acoshf.c | 32 + user/mpy/lib/libm/asinfacosf.c | 130 + user/mpy/lib/libm/asinhf.c | 34 + user/mpy/lib/libm/atan2f.c | 89 + user/mpy/lib/libm/atanf.c | 100 + user/mpy/lib/libm/atanhf.c | 34 + user/mpy/lib/libm/ef_rem_pio2.c | 202 + user/mpy/lib/libm/ef_sqrt.c | 102 + user/mpy/lib/libm/erf_lgamma.c | 255 + user/mpy/lib/libm/fdlibm.h | 227 + user/mpy/lib/libm/fmodf.c | 70 + user/mpy/lib/libm/kf_cos.c | 68 + user/mpy/lib/libm/kf_rem_pio2.c | 218 + user/mpy/lib/libm/kf_sin.c | 58 + user/mpy/lib/libm/kf_tan.c | 105 + user/mpy/lib/libm/libm.h | 54 + user/mpy/lib/libm/log1pf.c | 83 + user/mpy/lib/libm/math.c | 822 + user/mpy/lib/libm/nearbyintf.c | 21 + user/mpy/lib/libm/roundf.c | 33 + user/mpy/lib/libm/sf_cos.c | 71 + user/mpy/lib/libm/sf_erf.c | 257 + user/mpy/lib/libm/sf_frexp.c | 70 + user/mpy/lib/libm/sf_ldexp.c | 53 + user/mpy/lib/libm/sf_modf.c | 82 + user/mpy/lib/libm/sf_sin.c | 71 + user/mpy/lib/libm/sf_tan.c | 66 + user/mpy/lib/libm/thumb_vfp_sqrtf.c | 11 + user/mpy/lib/libm/wf_lgamma.c | 98 + user/mpy/lib/libm/wf_tgamma.c | 69 + user/mpy/lib/libm_dbl/README | 32 + user/mpy/lib/libm_dbl/__cos.c | 71 + user/mpy/lib/libm_dbl/__expo2.c | 16 + user/mpy/lib/libm_dbl/__fpclassify.c | 11 + user/mpy/lib/libm_dbl/__rem_pio2.c | 177 + user/mpy/lib/libm_dbl/__rem_pio2_large.c | 442 + user/mpy/lib/libm_dbl/__signbit.c | 12 + user/mpy/lib/libm_dbl/__sin.c | 64 + user/mpy/lib/libm_dbl/__tan.c | 110 + user/mpy/lib/libm_dbl/acos.c | 101 + user/mpy/lib/libm_dbl/acosh.c | 24 + user/mpy/lib/libm_dbl/asin.c | 107 + user/mpy/lib/libm_dbl/asinh.c | 28 + user/mpy/lib/libm_dbl/atan.c | 116 + user/mpy/lib/libm_dbl/atan2.c | 107 + user/mpy/lib/libm_dbl/atanh.c | 29 + user/mpy/lib/libm_dbl/ceil.c | 31 + user/mpy/lib/libm_dbl/cos.c | 77 + user/mpy/lib/libm_dbl/cosh.c | 40 + user/mpy/lib/libm_dbl/erf.c | 273 + user/mpy/lib/libm_dbl/exp.c | 134 + user/mpy/lib/libm_dbl/expm1.c | 201 + user/mpy/lib/libm_dbl/floor.c | 31 + user/mpy/lib/libm_dbl/fmod.c | 68 + user/mpy/lib/libm_dbl/frexp.c | 23 + user/mpy/lib/libm_dbl/ldexp.c | 6 + user/mpy/lib/libm_dbl/lgamma.c | 8 + user/mpy/lib/libm_dbl/libm.h | 96 + user/mpy/lib/libm_dbl/log.c | 118 + user/mpy/lib/libm_dbl/log10.c | 7 + user/mpy/lib/libm_dbl/log1p.c | 122 + user/mpy/lib/libm_dbl/modf.c | 34 + user/mpy/lib/libm_dbl/nearbyint.c | 20 + user/mpy/lib/libm_dbl/pow.c | 328 + user/mpy/lib/libm_dbl/rint.c | 28 + user/mpy/lib/libm_dbl/scalbn.c | 33 + user/mpy/lib/libm_dbl/sin.c | 78 + user/mpy/lib/libm_dbl/sinh.c | 39 + user/mpy/lib/libm_dbl/sqrt.c | 185 + user/mpy/lib/libm_dbl/tan.c | 70 + user/mpy/lib/libm_dbl/tanh.c | 5 + user/mpy/lib/libm_dbl/tgamma.c | 222 + user/mpy/lib/libm_dbl/trunc.c | 19 + user/mpy/lib/lwip/CHANGELOG | 3339 + user/mpy/lib/lwip/COPYING | 33 + user/mpy/lib/lwip/FILES | 4 + user/mpy/lib/lwip/README | 89 + user/mpy/lib/lwip/UPGRADING | 144 + user/mpy/lib/lwip/doc/FILES | 6 + user/mpy/lib/lwip/doc/contrib.txt | 63 + user/mpy/lib/lwip/doc/rawapi.txt | 511 + user/mpy/lib/lwip/doc/savannah.txt | 135 + user/mpy/lib/lwip/doc/snmp_agent.txt | 181 + user/mpy/lib/lwip/doc/sys_arch.txt | 267 + user/mpy/lib/lwip/src/FILES | 13 + user/mpy/lib/lwip/src/api/api_lib.c | 780 + user/mpy/lib/lwip/src/api/api_msg.c | 1565 + user/mpy/lib/lwip/src/api/err.c | 75 + user/mpy/lib/lwip/src/api/netbuf.c | 245 + user/mpy/lib/lwip/src/api/netdb.c | 353 + user/mpy/lib/lwip/src/api/netifapi.c | 160 + user/mpy/lib/lwip/src/api/sockets.c | 2374 + user/mpy/lib/lwip/src/api/tcpip.c | 511 + user/mpy/lib/lwip/src/core/def.c | 108 + user/mpy/lib/lwip/src/core/dhcp.c | 1770 + user/mpy/lib/lwip/src/core/dns.c | 970 + user/mpy/lib/lwip/src/core/init.c | 332 + user/mpy/lib/lwip/src/core/ipv4/autoip.c | 528 + user/mpy/lib/lwip/src/core/ipv4/icmp.c | 339 + user/mpy/lib/lwip/src/core/ipv4/igmp.c | 805 + user/mpy/lib/lwip/src/core/ipv4/inet.c | 42 + user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c | 450 + user/mpy/lib/lwip/src/core/ipv4/ip.c | 924 + user/mpy/lib/lwip/src/core/ipv4/ip_addr.c | 312 + user/mpy/lib/lwip/src/core/ipv4/ip_frag.c | 863 + user/mpy/lib/lwip/src/core/ipv6/README | 1 + user/mpy/lib/lwip/src/core/ipv6/icmp6.c | 179 + user/mpy/lib/lwip/src/core/ipv6/inet6.c | 163 + user/mpy/lib/lwip/src/core/ipv6/ip6.c | 397 + user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c | 72 + user/mpy/lib/lwip/src/core/mem.c | 659 + user/mpy/lib/lwip/src/core/memp.c | 470 + user/mpy/lib/lwip/src/core/netif.c | 774 + user/mpy/lib/lwip/src/core/pbuf.c | 1179 + user/mpy/lib/lwip/src/core/raw.c | 350 + user/mpy/lib/lwip/src/core/snmp/asn1_dec.c | 657 + user/mpy/lib/lwip/src/core/snmp/asn1_enc.c | 611 + user/mpy/lib/lwip/src/core/snmp/mib2.c | 4146 + user/mpy/lib/lwip/src/core/snmp/mib_structs.c | 1174 + user/mpy/lib/lwip/src/core/snmp/msg_in.c | 1453 + user/mpy/lib/lwip/src/core/snmp/msg_out.c | 674 + user/mpy/lib/lwip/src/core/stats.c | 176 + user/mpy/lib/lwip/src/core/sys.c | 68 + user/mpy/lib/lwip/src/core/tcp.c | 1742 + user/mpy/lib/lwip/src/core/tcp_in.c | 1619 + user/mpy/lib/lwip/src/core/tcp_out.c | 1485 + user/mpy/lib/lwip/src/core/timers.c | 487 + user/mpy/lib/lwip/src/core/udp.c | 1013 + .../lib/lwip/src/include/ipv4/lwip/autoip.h | 118 + .../mpy/lib/lwip/src/include/ipv4/lwip/icmp.h | 111 + .../mpy/lib/lwip/src/include/ipv4/lwip/igmp.h | 106 + .../mpy/lib/lwip/src/include/ipv4/lwip/inet.h | 107 + .../lwip/src/include/ipv4/lwip/inet_chksum.h | 90 + user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h | 223 + .../lib/lwip/src/include/ipv4/lwip/ip_addr.h | 244 + .../lib/lwip/src/include/ipv4/lwip/ip_frag.h | 88 + .../mpy/lib/lwip/src/include/ipv6/lwip/icmp.h | 100 + .../mpy/lib/lwip/src/include/ipv6/lwip/inet.h | 68 + user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h | 130 + .../lib/lwip/src/include/ipv6/lwip/ip_addr.h | 97 + user/mpy/lib/lwip/src/include/lwip/api.h | 297 + user/mpy/lib/lwip/src/include/lwip/api_msg.h | 177 + user/mpy/lib/lwip/src/include/lwip/arch.h | 217 + user/mpy/lib/lwip/src/include/lwip/debug.h | 99 + user/mpy/lib/lwip/src/include/lwip/def.h | 123 + user/mpy/lib/lwip/src/include/lwip/dhcp.h | 242 + user/mpy/lib/lwip/src/include/lwip/dns.h | 124 + user/mpy/lib/lwip/src/include/lwip/err.h | 85 + user/mpy/lib/lwip/src/include/lwip/init.h | 72 + user/mpy/lib/lwip/src/include/lwip/mem.h | 123 + user/mpy/lib/lwip/src/include/lwip/memp.h | 116 + user/mpy/lib/lwip/src/include/lwip/memp_std.h | 122 + user/mpy/lib/lwip/src/include/lwip/netbuf.h | 101 + user/mpy/lib/lwip/src/include/lwip/netdb.h | 124 + user/mpy/lib/lwip/src/include/lwip/netif.h | 328 + user/mpy/lib/lwip/src/include/lwip/netifapi.h | 108 + user/mpy/lib/lwip/src/include/lwip/opt.h | 2133 + user/mpy/lib/lwip/src/include/lwip/pbuf.h | 178 + user/mpy/lib/lwip/src/include/lwip/raw.h | 98 + user/mpy/lib/lwip/src/include/lwip/sio.h | 141 + user/mpy/lib/lwip/src/include/lwip/snmp.h | 367 + .../mpy/lib/lwip/src/include/lwip/snmp_asn1.h | 101 + user/mpy/lib/lwip/src/include/lwip/snmp_msg.h | 315 + .../lib/lwip/src/include/lwip/snmp_structs.h | 268 + user/mpy/lib/lwip/src/include/lwip/sockets.h | 379 + user/mpy/lib/lwip/src/include/lwip/stats.h | 292 + user/mpy/lib/lwip/src/include/lwip/sys.h | 337 + user/mpy/lib/lwip/src/include/lwip/tcp.h | 379 + user/mpy/lib/lwip/src/include/lwip/tcp_impl.h | 486 + user/mpy/lib/lwip/src/include/lwip/tcpip.h | 167 + user/mpy/lib/lwip/src/include/lwip/timers.h | 100 + user/mpy/lib/lwip/src/include/lwip/udp.h | 171 + user/mpy/lib/lwip/src/include/netif/etharp.h | 222 + user/mpy/lib/lwip/src/include/netif/ppp_oe.h | 190 + user/mpy/lib/lwip/src/include/netif/slipif.h | 81 + user/mpy/lib/lwip/src/include/posix/netdb.h | 33 + .../lib/lwip/src/include/posix/sys/socket.h | 33 + user/mpy/lib/lwip/src/netif/FILES | 29 + user/mpy/lib/lwip/src/netif/etharp.c | 1399 + user/mpy/lib/lwip/src/netif/ethernetif.c | 317 + user/mpy/lib/lwip/src/netif/ppp/auth.c | 1334 + user/mpy/lib/lwip/src/netif/ppp/auth.h | 111 + user/mpy/lib/lwip/src/netif/ppp/chap.c | 908 + user/mpy/lib/lwip/src/netif/ppp/chap.h | 150 + user/mpy/lib/lwip/src/netif/ppp/chpms.c | 396 + user/mpy/lib/lwip/src/netif/ppp/chpms.h | 64 + user/mpy/lib/lwip/src/netif/ppp/fsm.c | 890 + user/mpy/lib/lwip/src/netif/ppp/fsm.h | 157 + user/mpy/lib/lwip/src/netif/ppp/ipcp.c | 1411 + user/mpy/lib/lwip/src/netif/ppp/ipcp.h | 106 + user/mpy/lib/lwip/src/netif/ppp/lcp.c | 2066 + user/mpy/lib/lwip/src/netif/ppp/lcp.h | 151 + user/mpy/lib/lwip/src/netif/ppp/magic.c | 80 + user/mpy/lib/lwip/src/netif/ppp/magic.h | 63 + user/mpy/lib/lwip/src/netif/ppp/md5.c | 320 + user/mpy/lib/lwip/src/netif/ppp/md5.h | 55 + user/mpy/lib/lwip/src/netif/ppp/pap.c | 628 + user/mpy/lib/lwip/src/netif/ppp/pap.h | 118 + user/mpy/lib/lwip/src/netif/ppp/ppp.c | 2045 + user/mpy/lib/lwip/src/netif/ppp/ppp.h | 201 + user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h | 363 + user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c | 1132 + user/mpy/lib/lwip/src/netif/ppp/pppdebug.h | 73 + user/mpy/lib/lwip/src/netif/ppp/randm.c | 249 + user/mpy/lib/lwip/src/netif/ppp/randm.h | 81 + user/mpy/lib/lwip/src/netif/ppp/vj.c | 652 + user/mpy/lib/lwip/src/netif/ppp/vj.h | 156 + user/mpy/lib/lwip/src/netif/slipif.c | 510 + user/mpy/lib/lwip/test/unit/core/test_mem.c | 73 + user/mpy/lib/lwip/test/unit/core/test_mem.h | 8 + .../lib/lwip/test/unit/etharp/test_etharp.c | 262 + .../lib/lwip/test/unit/etharp/test_etharp.h | 8 + user/mpy/lib/lwip/test/unit/lwip_check.h | 37 + user/mpy/lib/lwip/test/unit/lwip_unittests.c | 45 + user/mpy/lib/lwip/test/unit/lwipopts.h | 50 + user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c | 294 + user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h | 52 + user/mpy/lib/lwip/test/unit/tcp/test_tcp.c | 667 + user/mpy/lib/lwip/test/unit/tcp/test_tcp.h | 8 + .../mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c | 944 + .../mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h | 8 + user/mpy/lib/lwip/test/unit/udp/test_udp.c | 68 + user/mpy/lib/lwip/test/unit/udp/test_udp.h | 8 + user/mpy/lib/memzip/README.md | 28 + user/mpy/lib/memzip/import.c | 17 + user/mpy/lib/memzip/lexermemzip.c | 19 + user/mpy/lib/memzip/make-memzip.py | 79 + user/mpy/lib/memzip/memzip.c | 106 + user/mpy/lib/memzip/memzip.h | 83 + user/mpy/lib/mp-readline/readline.c | 447 + user/mpy/lib/mp-readline/readline.h | 48 + user/mpy/lib/netutils/netutils.c | 96 + user/mpy/lib/netutils/netutils.h | 50 + user/mpy/lib/oofatfs/diskio.h | 83 + user/mpy/lib/oofatfs/ff.c | 5594 + user/mpy/lib/oofatfs/ff.h | 380 + user/mpy/lib/oofatfs/ffconf.h | 349 + user/mpy/lib/oofatfs/option/ccsbcs.c | 388 + user/mpy/lib/oofatfs/option/unicode.c | 17 + user/mpy/lib/timeutils/timeutils.c | 215 + user/mpy/lib/timeutils/timeutils.h | 54 + user/mpy/lib/utils/interrupt_char.c | 50 + user/mpy/lib/utils/interrupt_char.h | 33 + user/mpy/lib/utils/printf.c | 135 + user/mpy/lib/utils/pyexec.c | 531 + user/mpy/lib/utils/pyexec.h | 54 + user/mpy/lib/utils/stdout_helpers.c | 26 + user/mpy/lib/utils/sys_stdio_mphal.c | 163 + user/mpy/mkrules.mk | 16 + user/mpy/mpconfigport.h | 97 + user/mpy/mphalport.c | 18 + user/mpy/mphalport.h | 4 + user/mpy/py.mk | 319 + .../__pycache__/makeqstrdata.cpython-35.pyc | Bin 0 -> 4914 bytes .../__pycache__/makeqstrdata.cpython-36.pyc | Bin 0 -> 4503 bytes user/mpy/py/argcheck.c | 147 + user/mpy/py/asmarm.c | 368 + user/mpy/py/asmarm.h | 205 + user/mpy/py/asmbase.c | 102 + user/mpy/py/asmbase.h | 69 + user/mpy/py/asmthumb.c | 379 + user/mpy/py/asmthumb.h | 321 + user/mpy/py/asmx64.c | 632 + user/mpy/py/asmx64.h | 200 + user/mpy/py/asmx86.c | 511 + user/mpy/py/asmx86.h | 198 + user/mpy/py/asmxtensa.c | 174 + user/mpy/py/asmxtensa.h | 324 + user/mpy/py/bc.c | 417 + user/mpy/py/bc.h | 122 + user/mpy/py/bc0.h | 119 + user/mpy/py/binary.c | 392 + user/mpy/py/binary.h | 44 + user/mpy/py/builtin.h | 123 + user/mpy/py/builtinevex.c | 168 + user/mpy/py/builtinhelp.c | 180 + user/mpy/py/builtinimport.c | 475 + user/mpy/py/compile.c | 3522 + user/mpy/py/compile.h | 54 + user/mpy/py/emit.h | 286 + user/mpy/py/emitbc.c | 1076 + user/mpy/py/emitcommon.c | 77 + user/mpy/py/emitglue.c | 170 + user/mpy/py/emitglue.h | 77 + user/mpy/py/emitinlinethumb.c | 822 + user/mpy/py/emitinlinextensa.c | 345 + user/mpy/py/emitnative.c | 2350 + user/mpy/py/formatfloat.c | 428 + user/mpy/py/formatfloat.h | 35 + user/mpy/py/frozenmod.c | 156 + user/mpy/py/frozenmod.h | 41 + user/mpy/py/gc.c | 918 + user/mpy/py/gc.h | 67 + user/mpy/py/grammar.h | 357 + user/mpy/py/lexer.c | 763 + user/mpy/py/lexer.h | 195 + user/mpy/py/makeqstrdata.py | 158 + user/mpy/py/makeqstrdefs.py | 111 + user/mpy/py/makeversionhdr.py | 107 + user/mpy/py/malloc.c | 199 + user/mpy/py/map.c | 436 + user/mpy/py/misc.h | 226 + user/mpy/py/mkenv.mk | 70 + user/mpy/py/mkrules.mk | 175 + user/mpy/py/modarray.c | 43 + user/mpy/py/modbuiltins.c | 774 + user/mpy/py/modcmath.c | 166 + user/mpy/py/modcollections.c | 46 + user/mpy/py/modgc.c | 125 + user/mpy/py/modio.c | 215 + user/mpy/py/modmath.c | 275 + user/mpy/py/modmicropython.c | 188 + user/mpy/py/modstruct.c | 266 + user/mpy/py/modsys.c | 222 + user/mpy/py/modthread.c | 294 + user/mpy/py/moduerrno.c | 122 + user/mpy/py/mpconfig.h | 1266 + user/mpy/py/mperrno.h | 150 + user/mpy/py/mphal.h | 83 + user/mpy/py/mpprint.c | 555 + user/mpy/py/mpprint.h | 74 + user/mpy/py/mpstate.c | 33 + user/mpy/py/mpstate.h | 251 + user/mpy/py/mpthread.h | 61 + user/mpy/py/mpz.c | 1766 + user/mpy/py/mpz.h | 143 + user/mpy/py/nativeglue.c | 183 + user/mpy/py/nlr.h | 115 + user/mpy/py/nlrsetjmp.c | 42 + user/mpy/py/nlrthumb.c | 136 + user/mpy/py/nlrx64.c | 136 + user/mpy/py/nlrx86.c | 113 + user/mpy/py/nlrxtensa.c | 103 + user/mpy/py/obj.c | 513 + user/mpy/py/obj.h | 867 + user/mpy/py/objarray.c | 634 + user/mpy/py/objarray.h | 42 + user/mpy/py/objattrtuple.c | 95 + user/mpy/py/objbool.c | 89 + user/mpy/py/objboundmeth.c | 109 + user/mpy/py/objcell.c | 71 + user/mpy/py/objclosure.c | 97 + user/mpy/py/objcomplex.c | 256 + user/mpy/py/objdict.c | 615 + user/mpy/py/objenumerate.c | 92 + user/mpy/py/objexcept.c | 479 + user/mpy/py/objexcept.h | 40 + user/mpy/py/objfilter.c | 72 + user/mpy/py/objfloat.c | 314 + user/mpy/py/objfun.c | 573 + user/mpy/py/objfun.h | 44 + user/mpy/py/objgenerator.c | 243 + user/mpy/py/objgenerator.h | 34 + user/mpy/py/objgetitemiter.c | 77 + user/mpy/py/objint.c | 479 + user/mpy/py/objint.h | 66 + user/mpy/py/objint_longlong.c | 298 + user/mpy/py/objint_mpz.c | 438 + user/mpy/py/objlist.c | 533 + user/mpy/py/objlist.h | 38 + user/mpy/py/objmap.c | 73 + user/mpy/py/objmodule.c | 272 + user/mpy/py/objmodule.h | 37 + user/mpy/py/objnamedtuple.c | 165 + user/mpy/py/objnone.c | 53 + user/mpy/py/objobject.c | 81 + user/mpy/py/objpolyiter.c | 54 + user/mpy/py/objproperty.c | 108 + user/mpy/py/objrange.c | 205 + user/mpy/py/objreversed.c | 81 + user/mpy/py/objset.c | 609 + user/mpy/py/objsingleton.c | 57 + user/mpy/py/objslice.c | 103 + user/mpy/py/objstr.c | 2169 + user/mpy/py/objstr.h | 105 + user/mpy/py/objstringio.c | 269 + user/mpy/py/objstringio.h | 40 + user/mpy/py/objstrunicode.c | 314 + user/mpy/py/objtuple.c | 291 + user/mpy/py/objtuple.h | 64 + user/mpy/py/objtype.c | 1207 + user/mpy/py/objtype.h | 52 + user/mpy/py/objzip.c | 76 + user/mpy/py/opmethods.c | 52 + user/mpy/py/parse.c | 1084 + user/mpy/py/parse.h | 107 + user/mpy/py/parsenum.c | 306 + user/mpy/py/parsenum.h | 37 + user/mpy/py/parsenumbase.c | 71 + user/mpy/py/parsenumbase.h | 33 + user/mpy/py/persistentcode.c | 400 + user/mpy/py/persistentcode.h | 40 + user/mpy/py/py.mk | 324 + user/mpy/py/qstr.c | 321 + user/mpy/py/qstr.h | 79 + user/mpy/py/qstrdefs.h | 61 + user/mpy/py/reader.c | 135 + user/mpy/py/reader.h | 46 + user/mpy/py/repl.c | 278 + user/mpy/py/repl.h | 38 + user/mpy/py/ringbuf.h | 72 + user/mpy/py/runtime.c | 1444 + user/mpy/py/runtime.h | 181 + user/mpy/py/runtime0.h | 155 + user/mpy/py/runtime_utils.c | 50 + user/mpy/py/scheduler.c | 117 + user/mpy/py/scope.c | 150 + user/mpy/py/scope.h | 97 + user/mpy/py/sequence.c | 279 + user/mpy/py/showbc.c | 568 + user/mpy/py/smallint.c | 75 + user/mpy/py/smallint.h | 68 + user/mpy/py/stackctrl.c | 65 + user/mpy/py/stackctrl.h | 48 + user/mpy/py/stream.c | 567 + user/mpy/py/stream.h | 106 + user/mpy/py/unicode.c | 184 + user/mpy/py/unicode.h | 34 + user/mpy/py/vm.c | 1461 + user/mpy/py/vmentrytable.h | 118 + user/mpy/py/vstr.c | 276 + user/mpy/py/warning.c | 50 + user/mpy/tools/.gitattributes | 1 + user/mpy/tools/.gitignore | 8 + user/mpy/tools/bootstrap_upip.sh | 30 + user/mpy/tools/build-stm-latest.sh | 42 + user/mpy/tools/cc1 | 262 + user/mpy/tools/check_code_size.sh | 23 + user/mpy/tools/codestats.sh | 187 + user/mpy/tools/dfu.py | 121 + user/mpy/tools/file2h.py | 30 + user/mpy/tools/gen-changelog.sh | 12 + user/mpy/tools/gen-cpydiff.py | 226 + user/mpy/tools/gendoc.py | 528 + user/mpy/tools/insert-usb-ids.py | 34 + user/mpy/tools/make-frozen.py | 83 + user/mpy/tools/mpy-tool.py | 593 + user/mpy/tools/mpy_bin2res.py | 18 + user/mpy/tools/mpy_cross_all.py | 38 + user/mpy/tools/pyboard.py | 461 + user/mpy/tools/pydfu.py | 540 + user/mpy/tools/tinytest-codegen.py | 70 + user/mpy/tools/tinytest/README | 18 + user/mpy/tools/tinytest/tinytest.c | 474 + user/mpy/tools/tinytest/tinytest.h | 98 + user/mpy/tools/tinytest/tinytest_macros.h | 184 + user/mpy/tools/upip.py | 307 + user/mpy/tools/upip_utarfile.py | 94 + user/pyhton.c | 96 + 1379 files changed, 614605 insertions(+), 1 deletion(-) create mode 100644 user/mpy/_frozen_mpy.c create mode 100644 user/mpy/build.mk create mode 100644 user/mpy/build/genhdr/mpversion.h create mode 100644 user/mpy/build/genhdr/qstr.i.last create mode 100644 user/mpy/build/genhdr/qstr.split create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr create mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr create mode 100644 user/mpy/build/genhdr/qstrdefs.collected.h create mode 100644 user/mpy/build/genhdr/qstrdefs.collected.h.hash create mode 100644 user/mpy/build/genhdr/qstrdefs.generated.h create mode 100644 user/mpy/build/genhdr/qstrdefs.preprocessed.h create mode 100644 user/mpy/extmod/crypto-algorithms/sha256.c create mode 100644 user/mpy/extmod/crypto-algorithms/sha256.h create mode 100644 user/mpy/extmod/lwip-include/arch/cc.h create mode 100644 user/mpy/extmod/lwip-include/arch/perf.h create mode 100644 user/mpy/extmod/lwip-include/lwipopts.h create mode 100644 user/mpy/extmod/machine_i2c.c create mode 100644 user/mpy/extmod/machine_i2c.h create mode 100644 user/mpy/extmod/machine_mem.c create mode 100644 user/mpy/extmod/machine_mem.h create mode 100644 user/mpy/extmod/machine_pinbase.c create mode 100644 user/mpy/extmod/machine_pinbase.h create mode 100644 user/mpy/extmod/machine_pulse.c create mode 100644 user/mpy/extmod/machine_pulse.h create mode 100644 user/mpy/extmod/machine_signal.c create mode 100644 user/mpy/extmod/machine_signal.h create mode 100644 user/mpy/extmod/machine_spi.c create mode 100644 user/mpy/extmod/machine_spi.h create mode 100644 user/mpy/extmod/misc.h create mode 100644 user/mpy/extmod/modbtree.c create mode 100644 user/mpy/extmod/modframebuf.c create mode 100644 user/mpy/extmod/modlwip.c create mode 100644 user/mpy/extmod/modonewire.c create mode 100644 user/mpy/extmod/modubinascii.c create mode 100644 user/mpy/extmod/modubinascii.h create mode 100644 user/mpy/extmod/moductypes.c create mode 100644 user/mpy/extmod/moduhashlib.c create mode 100644 user/mpy/extmod/moduheapq.c create mode 100644 user/mpy/extmod/modujson.c create mode 100644 user/mpy/extmod/modurandom.c create mode 100644 user/mpy/extmod/modure.c create mode 100644 user/mpy/extmod/moduselect.c create mode 100644 user/mpy/extmod/modussl_axtls.c create mode 100644 user/mpy/extmod/modussl_mbedtls.c create mode 100644 user/mpy/extmod/modutimeq.c create mode 100644 user/mpy/extmod/moduzlib.c create mode 100644 user/mpy/extmod/modwebrepl.c create mode 100644 user/mpy/extmod/modwebsocket.c create mode 100644 user/mpy/extmod/modwebsocket.h create mode 100644 user/mpy/extmod/re1.5/charclass.c create mode 100644 user/mpy/extmod/re1.5/compilecode.c create mode 100644 user/mpy/extmod/re1.5/dumpcode.c create mode 100644 user/mpy/extmod/re1.5/re1.5.h create mode 100644 user/mpy/extmod/re1.5/recursiveloop.c create mode 100644 user/mpy/extmod/uos_dupterm.c create mode 100644 user/mpy/extmod/utime_mphal.c create mode 100644 user/mpy/extmod/utime_mphal.h create mode 100644 user/mpy/extmod/uzlib/adler32.c create mode 100644 user/mpy/extmod/uzlib/crc32.c create mode 100644 user/mpy/extmod/uzlib/tinf.h create mode 100644 user/mpy/extmod/uzlib/tinfgzip.c create mode 100644 user/mpy/extmod/uzlib/tinflate.c create mode 100644 user/mpy/extmod/uzlib/tinfzlib.c create mode 100644 user/mpy/extmod/vfs.c create mode 100644 user/mpy/extmod/vfs.h create mode 100644 user/mpy/extmod/vfs_fat.c create mode 100644 user/mpy/extmod/vfs_fat.h create mode 100644 user/mpy/extmod/vfs_fat_diskio.c create mode 100644 user/mpy/extmod/vfs_fat_file.c create mode 100644 user/mpy/extmod/vfs_fat_misc.c create mode 100644 user/mpy/extmod/vfs_reader.c create mode 100644 user/mpy/extmod/virtpin.c create mode 100644 user/mpy/extmod/virtpin.h create mode 100644 user/mpy/forzentest.mpy create mode 100644 user/mpy/lib/README.md create mode 100644 user/mpy/lib/axtls/.gitignore create mode 100644 user/mpy/lib/axtls/Makefile create mode 100644 user/mpy/lib/axtls/README create mode 100755 user/mpy/lib/axtls/axtlswrap/Makefile create mode 100755 user/mpy/lib/axtls/axtlswrap/axtlswrap.c create mode 100644 user/mpy/lib/axtls/bindings/Config.in create mode 100644 user/mpy/lib/axtls/bindings/Makefile create mode 100644 user/mpy/lib/axtls/bindings/README create mode 100644 user/mpy/lib/axtls/bindings/csharp/Makefile create mode 100644 user/mpy/lib/axtls/bindings/csharp/axTLS.cs create mode 100755 user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl create mode 100755 user/mpy/lib/axtls/bindings/generate_interface.pl create mode 100644 user/mpy/lib/axtls/bindings/java/Makefile create mode 100644 user/mpy/lib/axtls/bindings/java/SSL.java create mode 100644 user/mpy/lib/axtls/bindings/java/SSLCTX.java create mode 100644 user/mpy/lib/axtls/bindings/java/SSLClient.java create mode 100644 user/mpy/lib/axtls/bindings/java/SSLReadHolder.java create mode 100644 user/mpy/lib/axtls/bindings/java/SSLServer.java create mode 100644 user/mpy/lib/axtls/bindings/java/SSLUtil.java create mode 100644 user/mpy/lib/axtls/bindings/lua/Makefile create mode 100644 user/mpy/lib/axtls/bindings/perl/Makefile create mode 100644 user/mpy/lib/axtls/bindings/vbnet/Makefile create mode 100644 user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb create mode 100644 user/mpy/lib/axtls/config/Config.in create mode 100755 user/mpy/lib/axtls/config/JMeter.jmx create mode 100644 user/mpy/lib/axtls/config/Rules.mak create mode 100755 user/mpy/lib/axtls/config/axhttpd.aip create mode 100644 user/mpy/lib/axtls/config/axtls.RES create mode 100644 user/mpy/lib/axtls/config/axtls.rc create mode 100644 user/mpy/lib/axtls/config/linuxconfig create mode 100644 user/mpy/lib/axtls/config/makefile.conf create mode 100644 user/mpy/lib/axtls/config/makefile.dotnet.conf create mode 100644 user/mpy/lib/axtls/config/makefile.java.conf create mode 100644 user/mpy/lib/axtls/config/makefile.post create mode 100644 user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt create mode 100644 user/mpy/lib/axtls/config/scripts/config/Makefile create mode 100644 user/mpy/lib/axtls/config/scripts/config/conf.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/confdata.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/expr.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/expr.h create mode 100644 user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped create mode 100644 user/mpy/lib/axtls/config/scripts/config/lkc.h create mode 100644 user/mpy/lib/axtls/config/scripts/config/lkc_proto.h create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/mconf.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/menu.c create mode 100755 user/mpy/lib/axtls/config/scripts/config/mkconfigs create mode 100644 user/mpy/lib/axtls/config/scripts/config/symbol.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/util.c create mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.l create mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped create mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped create mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.y create mode 100644 user/mpy/lib/axtls/config/upyconfig create mode 100644 user/mpy/lib/axtls/config/upyconfig.client create mode 100644 user/mpy/lib/axtls/config/win32config create mode 100644 user/mpy/lib/axtls/crypto/Makefile create mode 100644 user/mpy/lib/axtls/crypto/aes.c create mode 100644 user/mpy/lib/axtls/crypto/bigint.c create mode 100644 user/mpy/lib/axtls/crypto/bigint.h create mode 100644 user/mpy/lib/axtls/crypto/bigint_impl.h create mode 100644 user/mpy/lib/axtls/crypto/crypto.h create mode 100644 user/mpy/lib/axtls/crypto/crypto_misc.c create mode 100644 user/mpy/lib/axtls/crypto/hmac.c create mode 100644 user/mpy/lib/axtls/crypto/md5.c create mode 100644 user/mpy/lib/axtls/crypto/os_int.h create mode 100644 user/mpy/lib/axtls/crypto/rc4.c create mode 100644 user/mpy/lib/axtls/crypto/rsa.c create mode 100644 user/mpy/lib/axtls/crypto/sha1.c create mode 100644 user/mpy/lib/axtls/crypto/sha256.c create mode 100644 user/mpy/lib/axtls/crypto/sha384.c create mode 100644 user/mpy/lib/axtls/crypto/sha512.c create mode 100644 user/mpy/lib/axtls/docsrc/Makefile create mode 100644 user/mpy/lib/axtls/docsrc/axTLS.dox create mode 100644 user/mpy/lib/axtls/docsrc/doco_footer.html create mode 100644 user/mpy/lib/axtls/docsrc/images/axolotl.jpg create mode 100644 user/mpy/lib/axtls/docsrc/images/tsbasbw.gif create mode 100644 user/mpy/lib/axtls/httpd/Config.in create mode 100644 user/mpy/lib/axtls/httpd/Makefile create mode 100644 user/mpy/lib/axtls/httpd/axhttp.h create mode 100644 user/mpy/lib/axtls/httpd/axhttpd.c create mode 100644 user/mpy/lib/axtls/httpd/htpasswd.c create mode 100755 user/mpy/lib/axtls/httpd/kepler-1.1-snapshot-20070521-1825.tar.gz create mode 100644 user/mpy/lib/axtls/httpd/kepler.patch create mode 100644 user/mpy/lib/axtls/httpd/proc.c create mode 100644 user/mpy/lib/axtls/httpd/tdate_parse.c create mode 100644 user/mpy/lib/axtls/samples/Config.in create mode 100644 user/mpy/lib/axtls/samples/Makefile create mode 100644 user/mpy/lib/axtls/samples/c/Makefile create mode 100644 user/mpy/lib/axtls/samples/c/axssl.c create mode 100644 user/mpy/lib/axtls/samples/csharp/Makefile create mode 100644 user/mpy/lib/axtls/samples/csharp/axssl.cs create mode 100644 user/mpy/lib/axtls/samples/java/Makefile create mode 100644 user/mpy/lib/axtls/samples/java/axssl.java create mode 100644 user/mpy/lib/axtls/samples/java/manifest.mf create mode 100644 user/mpy/lib/axtls/samples/lua/Makefile create mode 100755 user/mpy/lib/axtls/samples/lua/axssl.lua create mode 100644 user/mpy/lib/axtls/samples/perl/Makefile create mode 100755 user/mpy/lib/axtls/samples/perl/axssl.pl create mode 100644 user/mpy/lib/axtls/samples/vbnet/Makefile create mode 100644 user/mpy/lib/axtls/samples/vbnet/axssl.vb create mode 100644 user/mpy/lib/axtls/ssl/BigIntConfig.in create mode 100644 user/mpy/lib/axtls/ssl/Config.in create mode 100644 user/mpy/lib/axtls/ssl/Makefile create mode 100644 user/mpy/lib/axtls/ssl/asn1.c create mode 100644 user/mpy/lib/axtls/ssl/cert.h create mode 100644 user/mpy/lib/axtls/ssl/crypto_misc.h create mode 100644 user/mpy/lib/axtls/ssl/gen_cert.c create mode 100644 user/mpy/lib/axtls/ssl/loader.c create mode 100644 user/mpy/lib/axtls/ssl/openssl.c create mode 100644 user/mpy/lib/axtls/ssl/os_port.c create mode 120000 user/mpy/lib/axtls/ssl/os_port.h create mode 100644 user/mpy/lib/axtls/ssl/os_port_micropython.h create mode 100644 user/mpy/lib/axtls/ssl/p12.c create mode 100644 user/mpy/lib/axtls/ssl/private_key.h create mode 100644 user/mpy/lib/axtls/ssl/ssl.h create mode 100644 user/mpy/lib/axtls/ssl/test/Makefile create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_x509_sha256.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.encrypted.p8 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_1024 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_2048 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_4096 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.unencrypted.p8 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.withoutCA.p12 create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.cer create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024_sha256.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024_sha384.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024_sha512.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.cer create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.cer create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_aes128.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_aes256.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_bad_after.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_bad_before.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_device.cer create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem create mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem create mode 100644 user/mpy/lib/axtls/ssl/test/ca-bundle.crt create mode 100644 user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt create mode 100644 user/mpy/lib/axtls/ssl/test/comodo.sha384.cer create mode 100644 user/mpy/lib/axtls/ssl/test/deutsche_telecom.x509_ca create mode 100644 user/mpy/lib/axtls/ssl/test/equifax.x509_ca create mode 100755 user/mpy/lib/axtls/ssl/test/gnutls.cer create mode 100755 user/mpy/lib/axtls/ssl/test/header_issue.dat create mode 100755 user/mpy/lib/axtls/ssl/test/killgnutls.sh create mode 100755 user/mpy/lib/axtls/ssl/test/killopenssl.sh create mode 100755 user/mpy/lib/axtls/ssl/test/make_certs.sh create mode 100644 user/mpy/lib/axtls/ssl/test/microsoft.x509_ca create mode 100644 user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem create mode 100755 user/mpy/lib/axtls/ssl/test/ms_iis.cer create mode 100644 user/mpy/lib/axtls/ssl/test/perf_bigint.c create mode 100644 user/mpy/lib/axtls/ssl/test/qualityssl.com.der create mode 100755 user/mpy/lib/axtls/ssl/test/socgen.cer create mode 100644 user/mpy/lib/axtls/ssl/test/ssltest.c create mode 100755 user/mpy/lib/axtls/ssl/test/test_axssl.sh create mode 100644 user/mpy/lib/axtls/ssl/test/thawte.x509_ca create mode 100644 user/mpy/lib/axtls/ssl/test/verisign.x509_ca.pem create mode 100644 user/mpy/lib/axtls/ssl/test/verisign.x509_my_cert.pem create mode 100755 user/mpy/lib/axtls/ssl/tls1.c create mode 100755 user/mpy/lib/axtls/ssl/tls1.h create mode 100644 user/mpy/lib/axtls/ssl/tls1_clnt.c create mode 100644 user/mpy/lib/axtls/ssl/tls1_svr.c create mode 100644 user/mpy/lib/axtls/ssl/x509.c create mode 100644 user/mpy/lib/axtls/www/bin/.htaccess create mode 100644 user/mpy/lib/axtls/www/favicon.ico create mode 100755 user/mpy/lib/axtls/www/index.html create mode 100644 user/mpy/lib/axtls/www/lua/download.lua create mode 100644 user/mpy/lib/axtls/www/lua/env.lua create mode 100644 user/mpy/lib/axtls/www/lua/overview.lp create mode 100644 user/mpy/lib/axtls/www/lua/prepara_sql2.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_conc.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_cookies.lp create mode 100644 user/mpy/lib/axtls/www/lua/test_cookies.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_err.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_fs.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_htk.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_lib.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_main.html create mode 100644 user/mpy/lib/axtls/www/lua/test_main.lp create mode 100644 user/mpy/lib/axtls/www/lua/test_main.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_session.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_sql.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_sql2.lua create mode 100644 user/mpy/lib/axtls/www/lua/test_variables.lp create mode 100644 user/mpy/lib/axtls/www/test_dir/bin/.htaccess create mode 100644 user/mpy/lib/axtls/www/test_dir/no_http/.htaccess create mode 100644 user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd create mode 100644 user/mpy/lib/axtls/www/test_dir/no_http/index.html create mode 100644 user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess create mode 100644 user/mpy/lib/axtls/www/test_dir/no_ssl/index.html create mode 100644 user/mpy/lib/berkeley-db-1.xx/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/Makefile create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/README create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys create mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/README create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/btree.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/extern.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/btree/tags create mode 100644 user/mpy/lib/berkeley-db-1.xx/changelog create mode 100644 user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/db/db.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/db/tags create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/hash.usenix.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/libtp.usenix.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/README create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/extern.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/page.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/search.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/hash/tags create mode 100644 user/mpy/lib/berkeley-db-1.xx/include/db.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/include/filevtable.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/include/mpool.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/include/tags create mode 100644 user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/man/btree.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/man/hash.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/man/mpool.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/man/recno.3 create mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/README create mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp create mode 120000 user/mpy/lib/berkeley-db-1.xx/mpool/tags create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/extern.h create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/recno.h create mode 120000 user/mpy/lib/berkeley-db-1.xx/recno/tags create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/Makefile create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/README create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/dbtest.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c create mode 100644 user/mpy/lib/berkeley-db-1.xx/test/run.test create mode 100644 user/mpy/lib/cmsis/inc/cmsis_armcc.h create mode 100644 user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h create mode 100644 user/mpy/lib/cmsis/inc/cmsis_gcc.h create mode 100644 user/mpy/lib/cmsis/inc/core_cm0.h create mode 100644 user/mpy/lib/cmsis/inc/core_cm0plus.h create mode 100644 user/mpy/lib/cmsis/inc/core_cm3.h create mode 100644 user/mpy/lib/cmsis/inc/core_cm4.h create mode 100644 user/mpy/lib/cmsis/inc/core_cm7.h create mode 100644 user/mpy/lib/cmsis/inc/core_cmFunc.h create mode 100644 user/mpy/lib/cmsis/inc/core_cmInstr.h create mode 100644 user/mpy/lib/cmsis/inc/core_cmSimd.h create mode 100644 user/mpy/lib/cmsis/inc/core_sc000.h create mode 100644 user/mpy/lib/cmsis/inc/core_sc300.h create mode 100644 user/mpy/lib/embed/abort_.c create mode 100644 user/mpy/lib/libc/string0.c create mode 100644 user/mpy/lib/libffi/.gitignore create mode 100644 user/mpy/lib/libffi/.travis.yml create mode 100644 user/mpy/lib/libffi/ChangeLog.libffi create mode 100644 user/mpy/lib/libffi/ChangeLog.libffi-3.1 create mode 100644 user/mpy/lib/libffi/ChangeLog.libgcj create mode 100644 user/mpy/lib/libffi/ChangeLog.v1 create mode 100644 user/mpy/lib/libffi/LICENSE create mode 100644 user/mpy/lib/libffi/Makefile.am create mode 100644 user/mpy/lib/libffi/README create mode 100644 user/mpy/lib/libffi/acinclude.m4 create mode 100755 user/mpy/lib/libffi/autogen.sh create mode 100644 user/mpy/lib/libffi/configure.ac create mode 100644 user/mpy/lib/libffi/configure.host create mode 100644 user/mpy/lib/libffi/doc/libffi.texi create mode 100644 user/mpy/lib/libffi/doc/version.texi create mode 100644 user/mpy/lib/libffi/generate-darwin-source-and-headers.py create mode 100644 user/mpy/lib/libffi/include/Makefile.am create mode 100644 user/mpy/lib/libffi/include/ffi.h.in create mode 100644 user/mpy/lib/libffi/include/ffi_cfi.h create mode 100644 user/mpy/lib/libffi/include/ffi_common.h create mode 100644 user/mpy/lib/libffi/libffi.pc.in create mode 100644 user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj create mode 100644 user/mpy/lib/libffi/libtool-version create mode 100644 user/mpy/lib/libffi/m4/asmcfi.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_append_flag.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_configure_args.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_enable_builddir.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 create mode 100644 user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 create mode 100644 user/mpy/lib/libffi/man/Makefile.am create mode 100644 user/mpy/lib/libffi/man/ffi.3 create mode 100644 user/mpy/lib/libffi/man/ffi_call.3 create mode 100644 user/mpy/lib/libffi/man/ffi_prep_cif.3 create mode 100644 user/mpy/lib/libffi/man/ffi_prep_cif_var.3 create mode 100755 user/mpy/lib/libffi/msvcc.sh create mode 100644 user/mpy/lib/libffi/src/aarch64/ffi.c create mode 100644 user/mpy/lib/libffi/src/aarch64/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/aarch64/internal.h create mode 100644 user/mpy/lib/libffi/src/aarch64/sysv.S create mode 100644 user/mpy/lib/libffi/src/alpha/ffi.c create mode 100644 user/mpy/lib/libffi/src/alpha/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/alpha/internal.h create mode 100644 user/mpy/lib/libffi/src/alpha/osf.S create mode 100644 user/mpy/lib/libffi/src/arc/arcompact.S create mode 100644 user/mpy/lib/libffi/src/arc/ffi.c create mode 100644 user/mpy/lib/libffi/src/arc/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/arm/ffi.c create mode 100644 user/mpy/lib/libffi/src/arm/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/arm/internal.h create mode 100644 user/mpy/lib/libffi/src/arm/sysv.S create mode 100644 user/mpy/lib/libffi/src/avr32/ffi.c create mode 100644 user/mpy/lib/libffi/src/avr32/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/avr32/sysv.S create mode 100644 user/mpy/lib/libffi/src/bfin/ffi.c create mode 100644 user/mpy/lib/libffi/src/bfin/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/bfin/sysv.S create mode 100644 user/mpy/lib/libffi/src/closures.c create mode 100644 user/mpy/lib/libffi/src/cris/ffi.c create mode 100644 user/mpy/lib/libffi/src/cris/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/cris/sysv.S create mode 100644 user/mpy/lib/libffi/src/debug.c create mode 100644 user/mpy/lib/libffi/src/dlmalloc.c create mode 100644 user/mpy/lib/libffi/src/frv/eabi.S create mode 100644 user/mpy/lib/libffi/src/frv/ffi.c create mode 100644 user/mpy/lib/libffi/src/frv/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/ia64/ffi.c create mode 100644 user/mpy/lib/libffi/src/ia64/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/ia64/ia64_flags.h create mode 100644 user/mpy/lib/libffi/src/ia64/unix.S create mode 100644 user/mpy/lib/libffi/src/java_raw_api.c create mode 100644 user/mpy/lib/libffi/src/m32r/ffi.c create mode 100644 user/mpy/lib/libffi/src/m32r/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/m32r/sysv.S create mode 100644 user/mpy/lib/libffi/src/m68k/ffi.c create mode 100644 user/mpy/lib/libffi/src/m68k/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/m68k/sysv.S create mode 100644 user/mpy/lib/libffi/src/m88k/ffi.c create mode 100644 user/mpy/lib/libffi/src/m88k/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/m88k/obsd.S create mode 100644 user/mpy/lib/libffi/src/metag/ffi.c create mode 100644 user/mpy/lib/libffi/src/metag/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/metag/sysv.S create mode 100644 user/mpy/lib/libffi/src/microblaze/ffi.c create mode 100644 user/mpy/lib/libffi/src/microblaze/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/microblaze/sysv.S create mode 100644 user/mpy/lib/libffi/src/mips/ffi.c create mode 100644 user/mpy/lib/libffi/src/mips/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/mips/n32.S create mode 100644 user/mpy/lib/libffi/src/mips/o32.S create mode 100644 user/mpy/lib/libffi/src/moxie/eabi.S create mode 100644 user/mpy/lib/libffi/src/moxie/ffi.c create mode 100644 user/mpy/lib/libffi/src/moxie/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/nios2/ffi.c create mode 100644 user/mpy/lib/libffi/src/nios2/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/nios2/sysv.S create mode 100644 user/mpy/lib/libffi/src/or1k/ffi.c create mode 100644 user/mpy/lib/libffi/src/or1k/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/or1k/sysv.S create mode 100644 user/mpy/lib/libffi/src/pa/ffi.c create mode 100644 user/mpy/lib/libffi/src/pa/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/pa/hpux32.S create mode 100644 user/mpy/lib/libffi/src/pa/linux.S create mode 100644 user/mpy/lib/libffi/src/powerpc/aix.S create mode 100644 user/mpy/lib/libffi/src/powerpc/aix_closure.S create mode 100644 user/mpy/lib/libffi/src/powerpc/asm.h create mode 100644 user/mpy/lib/libffi/src/powerpc/darwin.S create mode 100644 user/mpy/lib/libffi/src/powerpc/darwin_closure.S create mode 100644 user/mpy/lib/libffi/src/powerpc/ffi.c create mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_darwin.c create mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_linux64.c create mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h create mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_sysv.c create mode 100644 user/mpy/lib/libffi/src/powerpc/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/powerpc/linux64.S create mode 100644 user/mpy/lib/libffi/src/powerpc/linux64_closure.S create mode 100644 user/mpy/lib/libffi/src/powerpc/ppc_closure.S create mode 100644 user/mpy/lib/libffi/src/powerpc/sysv.S create mode 100644 user/mpy/lib/libffi/src/prep_cif.c create mode 100644 user/mpy/lib/libffi/src/raw_api.c create mode 100644 user/mpy/lib/libffi/src/s390/ffi.c create mode 100644 user/mpy/lib/libffi/src/s390/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/s390/internal.h create mode 100644 user/mpy/lib/libffi/src/s390/sysv.S create mode 100644 user/mpy/lib/libffi/src/sh/ffi.c create mode 100644 user/mpy/lib/libffi/src/sh/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/sh/sysv.S create mode 100644 user/mpy/lib/libffi/src/sh64/ffi.c create mode 100644 user/mpy/lib/libffi/src/sh64/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/sh64/sysv.S create mode 100644 user/mpy/lib/libffi/src/sparc/ffi.c create mode 100644 user/mpy/lib/libffi/src/sparc/ffi64.c create mode 100644 user/mpy/lib/libffi/src/sparc/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/sparc/internal.h create mode 100644 user/mpy/lib/libffi/src/sparc/v8.S create mode 100644 user/mpy/lib/libffi/src/sparc/v9.S create mode 100644 user/mpy/lib/libffi/src/tile/ffi.c create mode 100644 user/mpy/lib/libffi/src/tile/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/tile/tile.S create mode 100644 user/mpy/lib/libffi/src/types.c create mode 100644 user/mpy/lib/libffi/src/vax/elfbsd.S create mode 100644 user/mpy/lib/libffi/src/vax/ffi.c create mode 100644 user/mpy/lib/libffi/src/vax/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/x86/ffi.c create mode 100644 user/mpy/lib/libffi/src/x86/ffi64.c create mode 100644 user/mpy/lib/libffi/src/x86/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/x86/ffiw64.c create mode 100644 user/mpy/lib/libffi/src/x86/internal.h create mode 100644 user/mpy/lib/libffi/src/x86/internal64.h create mode 100644 user/mpy/lib/libffi/src/x86/sysv.S create mode 100644 user/mpy/lib/libffi/src/x86/unix64.S create mode 100644 user/mpy/lib/libffi/src/x86/win64.S create mode 100644 user/mpy/lib/libffi/src/xtensa/ffi.c create mode 100644 user/mpy/lib/libffi/src/xtensa/ffitarget.h create mode 100644 user/mpy/lib/libffi/src/xtensa/sysv.S create mode 100644 user/mpy/lib/libffi/stamp-h.in create mode 100644 user/mpy/lib/libffi/testsuite/Makefile.am create mode 100644 user/mpy/lib/libffi/testsuite/config/default.exp create mode 100644 user/mpy/lib/libffi/testsuite/lib/libffi.exp create mode 100644 user/mpy/lib/libffi/testsuite/lib/target-libpath.exp create mode 100644 user/mpy/lib/libffi/testsuite/lib/wrapper.exp create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/call.exp create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float4.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float_va.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/huge_struct.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/negint.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/problem1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/promotion.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct4.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct5.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct6.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct7.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct8.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct9.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/closure1.c create mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h create mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/go.exp create mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h create mode 100644 user/mpy/lib/libffi/texinfo.tex create mode 100644 user/mpy/lib/libm/acoshf.c create mode 100644 user/mpy/lib/libm/asinfacosf.c create mode 100644 user/mpy/lib/libm/asinhf.c create mode 100644 user/mpy/lib/libm/atan2f.c create mode 100644 user/mpy/lib/libm/atanf.c create mode 100644 user/mpy/lib/libm/atanhf.c create mode 100644 user/mpy/lib/libm/ef_rem_pio2.c create mode 100644 user/mpy/lib/libm/ef_sqrt.c create mode 100644 user/mpy/lib/libm/erf_lgamma.c create mode 100644 user/mpy/lib/libm/fdlibm.h create mode 100644 user/mpy/lib/libm/fmodf.c create mode 100644 user/mpy/lib/libm/kf_cos.c create mode 100644 user/mpy/lib/libm/kf_rem_pio2.c create mode 100644 user/mpy/lib/libm/kf_sin.c create mode 100644 user/mpy/lib/libm/kf_tan.c create mode 100644 user/mpy/lib/libm/libm.h create mode 100644 user/mpy/lib/libm/log1pf.c create mode 100644 user/mpy/lib/libm/math.c create mode 100644 user/mpy/lib/libm/nearbyintf.c create mode 100644 user/mpy/lib/libm/roundf.c create mode 100644 user/mpy/lib/libm/sf_cos.c create mode 100644 user/mpy/lib/libm/sf_erf.c create mode 100644 user/mpy/lib/libm/sf_frexp.c create mode 100644 user/mpy/lib/libm/sf_ldexp.c create mode 100644 user/mpy/lib/libm/sf_modf.c create mode 100644 user/mpy/lib/libm/sf_sin.c create mode 100644 user/mpy/lib/libm/sf_tan.c create mode 100644 user/mpy/lib/libm/thumb_vfp_sqrtf.c create mode 100644 user/mpy/lib/libm/wf_lgamma.c create mode 100644 user/mpy/lib/libm/wf_tgamma.c create mode 100644 user/mpy/lib/libm_dbl/README create mode 100644 user/mpy/lib/libm_dbl/__cos.c create mode 100644 user/mpy/lib/libm_dbl/__expo2.c create mode 100644 user/mpy/lib/libm_dbl/__fpclassify.c create mode 100644 user/mpy/lib/libm_dbl/__rem_pio2.c create mode 100644 user/mpy/lib/libm_dbl/__rem_pio2_large.c create mode 100644 user/mpy/lib/libm_dbl/__signbit.c create mode 100644 user/mpy/lib/libm_dbl/__sin.c create mode 100644 user/mpy/lib/libm_dbl/__tan.c create mode 100644 user/mpy/lib/libm_dbl/acos.c create mode 100644 user/mpy/lib/libm_dbl/acosh.c create mode 100644 user/mpy/lib/libm_dbl/asin.c create mode 100644 user/mpy/lib/libm_dbl/asinh.c create mode 100644 user/mpy/lib/libm_dbl/atan.c create mode 100644 user/mpy/lib/libm_dbl/atan2.c create mode 100644 user/mpy/lib/libm_dbl/atanh.c create mode 100644 user/mpy/lib/libm_dbl/ceil.c create mode 100644 user/mpy/lib/libm_dbl/cos.c create mode 100644 user/mpy/lib/libm_dbl/cosh.c create mode 100644 user/mpy/lib/libm_dbl/erf.c create mode 100644 user/mpy/lib/libm_dbl/exp.c create mode 100644 user/mpy/lib/libm_dbl/expm1.c create mode 100644 user/mpy/lib/libm_dbl/floor.c create mode 100644 user/mpy/lib/libm_dbl/fmod.c create mode 100644 user/mpy/lib/libm_dbl/frexp.c create mode 100644 user/mpy/lib/libm_dbl/ldexp.c create mode 100644 user/mpy/lib/libm_dbl/lgamma.c create mode 100644 user/mpy/lib/libm_dbl/libm.h create mode 100644 user/mpy/lib/libm_dbl/log.c create mode 100644 user/mpy/lib/libm_dbl/log10.c create mode 100644 user/mpy/lib/libm_dbl/log1p.c create mode 100644 user/mpy/lib/libm_dbl/modf.c create mode 100644 user/mpy/lib/libm_dbl/nearbyint.c create mode 100644 user/mpy/lib/libm_dbl/pow.c create mode 100644 user/mpy/lib/libm_dbl/rint.c create mode 100644 user/mpy/lib/libm_dbl/scalbn.c create mode 100644 user/mpy/lib/libm_dbl/sin.c create mode 100644 user/mpy/lib/libm_dbl/sinh.c create mode 100644 user/mpy/lib/libm_dbl/sqrt.c create mode 100644 user/mpy/lib/libm_dbl/tan.c create mode 100644 user/mpy/lib/libm_dbl/tanh.c create mode 100644 user/mpy/lib/libm_dbl/tgamma.c create mode 100644 user/mpy/lib/libm_dbl/trunc.c create mode 100644 user/mpy/lib/lwip/CHANGELOG create mode 100644 user/mpy/lib/lwip/COPYING create mode 100644 user/mpy/lib/lwip/FILES create mode 100644 user/mpy/lib/lwip/README create mode 100644 user/mpy/lib/lwip/UPGRADING create mode 100644 user/mpy/lib/lwip/doc/FILES create mode 100644 user/mpy/lib/lwip/doc/contrib.txt create mode 100644 user/mpy/lib/lwip/doc/rawapi.txt create mode 100644 user/mpy/lib/lwip/doc/savannah.txt create mode 100644 user/mpy/lib/lwip/doc/snmp_agent.txt create mode 100644 user/mpy/lib/lwip/doc/sys_arch.txt create mode 100644 user/mpy/lib/lwip/src/FILES create mode 100644 user/mpy/lib/lwip/src/api/api_lib.c create mode 100644 user/mpy/lib/lwip/src/api/api_msg.c create mode 100644 user/mpy/lib/lwip/src/api/err.c create mode 100644 user/mpy/lib/lwip/src/api/netbuf.c create mode 100644 user/mpy/lib/lwip/src/api/netdb.c create mode 100644 user/mpy/lib/lwip/src/api/netifapi.c create mode 100644 user/mpy/lib/lwip/src/api/sockets.c create mode 100644 user/mpy/lib/lwip/src/api/tcpip.c create mode 100644 user/mpy/lib/lwip/src/core/def.c create mode 100644 user/mpy/lib/lwip/src/core/dhcp.c create mode 100644 user/mpy/lib/lwip/src/core/dns.c create mode 100644 user/mpy/lib/lwip/src/core/init.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/autoip.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/icmp.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/igmp.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/inet.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/ip.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/ip_addr.c create mode 100644 user/mpy/lib/lwip/src/core/ipv4/ip_frag.c create mode 100644 user/mpy/lib/lwip/src/core/ipv6/README create mode 100644 user/mpy/lib/lwip/src/core/ipv6/icmp6.c create mode 100644 user/mpy/lib/lwip/src/core/ipv6/inet6.c create mode 100644 user/mpy/lib/lwip/src/core/ipv6/ip6.c create mode 100644 user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c create mode 100644 user/mpy/lib/lwip/src/core/mem.c create mode 100644 user/mpy/lib/lwip/src/core/memp.c create mode 100644 user/mpy/lib/lwip/src/core/netif.c create mode 100644 user/mpy/lib/lwip/src/core/pbuf.c create mode 100644 user/mpy/lib/lwip/src/core/raw.c create mode 100644 user/mpy/lib/lwip/src/core/snmp/asn1_dec.c create mode 100644 user/mpy/lib/lwip/src/core/snmp/asn1_enc.c create mode 100644 user/mpy/lib/lwip/src/core/snmp/mib2.c create mode 100644 user/mpy/lib/lwip/src/core/snmp/mib_structs.c create mode 100644 user/mpy/lib/lwip/src/core/snmp/msg_in.c create mode 100644 user/mpy/lib/lwip/src/core/snmp/msg_out.c create mode 100644 user/mpy/lib/lwip/src/core/stats.c create mode 100644 user/mpy/lib/lwip/src/core/sys.c create mode 100644 user/mpy/lib/lwip/src/core/tcp.c create mode 100644 user/mpy/lib/lwip/src/core/tcp_in.c create mode 100644 user/mpy/lib/lwip/src/core/tcp_out.c create mode 100644 user/mpy/lib/lwip/src/core/timers.c create mode 100644 user/mpy/lib/lwip/src/core/udp.c create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h create mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h create mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h create mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h create mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h create mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/api.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/api_msg.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/arch.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/debug.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/def.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/dhcp.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/dns.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/err.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/init.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/mem.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/memp.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/memp_std.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/netbuf.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/netdb.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/netif.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/netifapi.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/opt.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/pbuf.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/raw.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/sio.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp_msg.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp_structs.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/sockets.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/stats.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/sys.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/tcp.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/tcp_impl.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/tcpip.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/timers.h create mode 100644 user/mpy/lib/lwip/src/include/lwip/udp.h create mode 100644 user/mpy/lib/lwip/src/include/netif/etharp.h create mode 100644 user/mpy/lib/lwip/src/include/netif/ppp_oe.h create mode 100644 user/mpy/lib/lwip/src/include/netif/slipif.h create mode 100644 user/mpy/lib/lwip/src/include/posix/netdb.h create mode 100644 user/mpy/lib/lwip/src/include/posix/sys/socket.h create mode 100644 user/mpy/lib/lwip/src/netif/FILES create mode 100644 user/mpy/lib/lwip/src/netif/etharp.c create mode 100644 user/mpy/lib/lwip/src/netif/ethernetif.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/auth.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/auth.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/chap.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/chap.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/chpms.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/chpms.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/fsm.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/fsm.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/ipcp.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/ipcp.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/lcp.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/lcp.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/magic.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/magic.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/md5.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/md5.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/pap.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/pap.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/pppdebug.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/randm.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/randm.h create mode 100644 user/mpy/lib/lwip/src/netif/ppp/vj.c create mode 100644 user/mpy/lib/lwip/src/netif/ppp/vj.h create mode 100644 user/mpy/lib/lwip/src/netif/slipif.c create mode 100644 user/mpy/lib/lwip/test/unit/core/test_mem.c create mode 100644 user/mpy/lib/lwip/test/unit/core/test_mem.h create mode 100644 user/mpy/lib/lwip/test/unit/etharp/test_etharp.c create mode 100644 user/mpy/lib/lwip/test/unit/etharp/test_etharp.h create mode 100644 user/mpy/lib/lwip/test/unit/lwip_check.h create mode 100644 user/mpy/lib/lwip/test/unit/lwip_unittests.c create mode 100644 user/mpy/lib/lwip/test/unit/lwipopts.h create mode 100644 user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c create mode 100644 user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h create mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp.c create mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp.h create mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c create mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h create mode 100644 user/mpy/lib/lwip/test/unit/udp/test_udp.c create mode 100644 user/mpy/lib/lwip/test/unit/udp/test_udp.h create mode 100644 user/mpy/lib/memzip/README.md create mode 100644 user/mpy/lib/memzip/import.c create mode 100644 user/mpy/lib/memzip/lexermemzip.c create mode 100755 user/mpy/lib/memzip/make-memzip.py create mode 100644 user/mpy/lib/memzip/memzip.c create mode 100644 user/mpy/lib/memzip/memzip.h create mode 100644 user/mpy/lib/mp-readline/readline.c create mode 100644 user/mpy/lib/mp-readline/readline.h create mode 100644 user/mpy/lib/netutils/netutils.c create mode 100644 user/mpy/lib/netutils/netutils.h create mode 100644 user/mpy/lib/oofatfs/diskio.h create mode 100644 user/mpy/lib/oofatfs/ff.c create mode 100644 user/mpy/lib/oofatfs/ff.h create mode 100644 user/mpy/lib/oofatfs/ffconf.h create mode 100644 user/mpy/lib/oofatfs/option/ccsbcs.c create mode 100644 user/mpy/lib/oofatfs/option/unicode.c create mode 100644 user/mpy/lib/timeutils/timeutils.c create mode 100644 user/mpy/lib/timeutils/timeutils.h create mode 100644 user/mpy/lib/utils/interrupt_char.c create mode 100644 user/mpy/lib/utils/interrupt_char.h create mode 100644 user/mpy/lib/utils/printf.c create mode 100644 user/mpy/lib/utils/pyexec.c create mode 100644 user/mpy/lib/utils/pyexec.h create mode 100644 user/mpy/lib/utils/stdout_helpers.c create mode 100644 user/mpy/lib/utils/sys_stdio_mphal.c create mode 100644 user/mpy/mkrules.mk create mode 100644 user/mpy/mpconfigport.h create mode 100644 user/mpy/mphalport.c create mode 100644 user/mpy/mphalport.h create mode 100644 user/mpy/py.mk create mode 100644 user/mpy/py/__pycache__/makeqstrdata.cpython-35.pyc create mode 100644 user/mpy/py/__pycache__/makeqstrdata.cpython-36.pyc create mode 100644 user/mpy/py/argcheck.c create mode 100644 user/mpy/py/asmarm.c create mode 100644 user/mpy/py/asmarm.h create mode 100644 user/mpy/py/asmbase.c create mode 100644 user/mpy/py/asmbase.h create mode 100644 user/mpy/py/asmthumb.c create mode 100644 user/mpy/py/asmthumb.h create mode 100644 user/mpy/py/asmx64.c create mode 100644 user/mpy/py/asmx64.h create mode 100644 user/mpy/py/asmx86.c create mode 100644 user/mpy/py/asmx86.h create mode 100644 user/mpy/py/asmxtensa.c create mode 100644 user/mpy/py/asmxtensa.h create mode 100644 user/mpy/py/bc.c create mode 100644 user/mpy/py/bc.h create mode 100644 user/mpy/py/bc0.h create mode 100644 user/mpy/py/binary.c create mode 100644 user/mpy/py/binary.h create mode 100644 user/mpy/py/builtin.h create mode 100644 user/mpy/py/builtinevex.c create mode 100644 user/mpy/py/builtinhelp.c create mode 100644 user/mpy/py/builtinimport.c create mode 100644 user/mpy/py/compile.c create mode 100644 user/mpy/py/compile.h create mode 100644 user/mpy/py/emit.h create mode 100644 user/mpy/py/emitbc.c create mode 100644 user/mpy/py/emitcommon.c create mode 100644 user/mpy/py/emitglue.c create mode 100644 user/mpy/py/emitglue.h create mode 100644 user/mpy/py/emitinlinethumb.c create mode 100644 user/mpy/py/emitinlinextensa.c create mode 100644 user/mpy/py/emitnative.c create mode 100644 user/mpy/py/formatfloat.c create mode 100644 user/mpy/py/formatfloat.h create mode 100644 user/mpy/py/frozenmod.c create mode 100644 user/mpy/py/frozenmod.h create mode 100644 user/mpy/py/gc.c create mode 100644 user/mpy/py/gc.h create mode 100644 user/mpy/py/grammar.h create mode 100644 user/mpy/py/lexer.c create mode 100644 user/mpy/py/lexer.h create mode 100644 user/mpy/py/makeqstrdata.py create mode 100644 user/mpy/py/makeqstrdefs.py create mode 100644 user/mpy/py/makeversionhdr.py create mode 100644 user/mpy/py/malloc.c create mode 100644 user/mpy/py/map.c create mode 100644 user/mpy/py/misc.h create mode 100644 user/mpy/py/mkenv.mk create mode 100644 user/mpy/py/mkrules.mk create mode 100644 user/mpy/py/modarray.c create mode 100644 user/mpy/py/modbuiltins.c create mode 100644 user/mpy/py/modcmath.c create mode 100644 user/mpy/py/modcollections.c create mode 100644 user/mpy/py/modgc.c create mode 100644 user/mpy/py/modio.c create mode 100644 user/mpy/py/modmath.c create mode 100644 user/mpy/py/modmicropython.c create mode 100644 user/mpy/py/modstruct.c create mode 100644 user/mpy/py/modsys.c create mode 100644 user/mpy/py/modthread.c create mode 100644 user/mpy/py/moduerrno.c create mode 100644 user/mpy/py/mpconfig.h create mode 100644 user/mpy/py/mperrno.h create mode 100644 user/mpy/py/mphal.h create mode 100644 user/mpy/py/mpprint.c create mode 100644 user/mpy/py/mpprint.h create mode 100644 user/mpy/py/mpstate.c create mode 100644 user/mpy/py/mpstate.h create mode 100644 user/mpy/py/mpthread.h create mode 100644 user/mpy/py/mpz.c create mode 100644 user/mpy/py/mpz.h create mode 100644 user/mpy/py/nativeglue.c create mode 100644 user/mpy/py/nlr.h create mode 100644 user/mpy/py/nlrsetjmp.c create mode 100644 user/mpy/py/nlrthumb.c create mode 100644 user/mpy/py/nlrx64.c create mode 100644 user/mpy/py/nlrx86.c create mode 100644 user/mpy/py/nlrxtensa.c create mode 100644 user/mpy/py/obj.c create mode 100644 user/mpy/py/obj.h create mode 100644 user/mpy/py/objarray.c create mode 100644 user/mpy/py/objarray.h create mode 100644 user/mpy/py/objattrtuple.c create mode 100644 user/mpy/py/objbool.c create mode 100644 user/mpy/py/objboundmeth.c create mode 100644 user/mpy/py/objcell.c create mode 100644 user/mpy/py/objclosure.c create mode 100644 user/mpy/py/objcomplex.c create mode 100644 user/mpy/py/objdict.c create mode 100644 user/mpy/py/objenumerate.c create mode 100644 user/mpy/py/objexcept.c create mode 100644 user/mpy/py/objexcept.h create mode 100644 user/mpy/py/objfilter.c create mode 100644 user/mpy/py/objfloat.c create mode 100644 user/mpy/py/objfun.c create mode 100644 user/mpy/py/objfun.h create mode 100644 user/mpy/py/objgenerator.c create mode 100644 user/mpy/py/objgenerator.h create mode 100644 user/mpy/py/objgetitemiter.c create mode 100644 user/mpy/py/objint.c create mode 100644 user/mpy/py/objint.h create mode 100644 user/mpy/py/objint_longlong.c create mode 100644 user/mpy/py/objint_mpz.c create mode 100644 user/mpy/py/objlist.c create mode 100644 user/mpy/py/objlist.h create mode 100644 user/mpy/py/objmap.c create mode 100644 user/mpy/py/objmodule.c create mode 100644 user/mpy/py/objmodule.h create mode 100644 user/mpy/py/objnamedtuple.c create mode 100644 user/mpy/py/objnone.c create mode 100644 user/mpy/py/objobject.c create mode 100644 user/mpy/py/objpolyiter.c create mode 100644 user/mpy/py/objproperty.c create mode 100644 user/mpy/py/objrange.c create mode 100644 user/mpy/py/objreversed.c create mode 100644 user/mpy/py/objset.c create mode 100644 user/mpy/py/objsingleton.c create mode 100644 user/mpy/py/objslice.c create mode 100644 user/mpy/py/objstr.c create mode 100644 user/mpy/py/objstr.h create mode 100644 user/mpy/py/objstringio.c create mode 100644 user/mpy/py/objstringio.h create mode 100644 user/mpy/py/objstrunicode.c create mode 100644 user/mpy/py/objtuple.c create mode 100644 user/mpy/py/objtuple.h create mode 100644 user/mpy/py/objtype.c create mode 100644 user/mpy/py/objtype.h create mode 100644 user/mpy/py/objzip.c create mode 100644 user/mpy/py/opmethods.c create mode 100644 user/mpy/py/parse.c create mode 100644 user/mpy/py/parse.h create mode 100644 user/mpy/py/parsenum.c create mode 100644 user/mpy/py/parsenum.h create mode 100644 user/mpy/py/parsenumbase.c create mode 100644 user/mpy/py/parsenumbase.h create mode 100644 user/mpy/py/persistentcode.c create mode 100644 user/mpy/py/persistentcode.h create mode 100644 user/mpy/py/py.mk create mode 100644 user/mpy/py/qstr.c create mode 100644 user/mpy/py/qstr.h create mode 100644 user/mpy/py/qstrdefs.h create mode 100644 user/mpy/py/reader.c create mode 100644 user/mpy/py/reader.h create mode 100644 user/mpy/py/repl.c create mode 100644 user/mpy/py/repl.h create mode 100644 user/mpy/py/ringbuf.h create mode 100644 user/mpy/py/runtime.c create mode 100644 user/mpy/py/runtime.h create mode 100644 user/mpy/py/runtime0.h create mode 100644 user/mpy/py/runtime_utils.c create mode 100644 user/mpy/py/scheduler.c create mode 100644 user/mpy/py/scope.c create mode 100644 user/mpy/py/scope.h create mode 100644 user/mpy/py/sequence.c create mode 100644 user/mpy/py/showbc.c create mode 100644 user/mpy/py/smallint.c create mode 100644 user/mpy/py/smallint.h create mode 100644 user/mpy/py/stackctrl.c create mode 100644 user/mpy/py/stackctrl.h create mode 100644 user/mpy/py/stream.c create mode 100644 user/mpy/py/stream.h create mode 100644 user/mpy/py/unicode.c create mode 100644 user/mpy/py/unicode.h create mode 100644 user/mpy/py/vm.c create mode 100644 user/mpy/py/vmentrytable.h create mode 100644 user/mpy/py/vstr.c create mode 100644 user/mpy/py/warning.c create mode 100644 user/mpy/tools/.gitattributes create mode 100644 user/mpy/tools/.gitignore create mode 100755 user/mpy/tools/bootstrap_upip.sh create mode 100755 user/mpy/tools/build-stm-latest.sh create mode 100755 user/mpy/tools/cc1 create mode 100755 user/mpy/tools/check_code_size.sh create mode 100755 user/mpy/tools/codestats.sh create mode 100755 user/mpy/tools/dfu.py create mode 100644 user/mpy/tools/file2h.py create mode 100755 user/mpy/tools/gen-changelog.sh create mode 100644 user/mpy/tools/gen-cpydiff.py create mode 100644 user/mpy/tools/gendoc.py create mode 100644 user/mpy/tools/insert-usb-ids.py create mode 100755 user/mpy/tools/make-frozen.py create mode 100755 user/mpy/tools/mpy-tool.py create mode 100755 user/mpy/tools/mpy_bin2res.py create mode 100755 user/mpy/tools/mpy_cross_all.py create mode 100755 user/mpy/tools/pyboard.py create mode 100755 user/mpy/tools/pydfu.py create mode 100755 user/mpy/tools/tinytest-codegen.py create mode 100644 user/mpy/tools/tinytest/README create mode 100644 user/mpy/tools/tinytest/tinytest.c create mode 100644 user/mpy/tools/tinytest/tinytest.h create mode 100644 user/mpy/tools/tinytest/tinytest_macros.h create mode 100644 user/mpy/tools/upip.py create mode 100644 user/mpy/tools/upip_utarfile.py create mode 100644 user/pyhton.c diff --git a/Makefile b/Makefile index 0d11530..bb549aa 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME = piko # select QEMU when the target is unspecified -TARGET ?= stm32f429 +TARGET ?= stm32p103 CMSIS = external/cmsis # The platform Makefile contains hw details and flags @@ -32,6 +32,9 @@ CSRC += \ libc/piko/mman.c \ $(LIBPIKO_CSRC) +# micropython +include user/mpy/build.mk + OBJS += $(SSRC:.S=.o) $(CSRC:.c=.o) OBJS := $(sort $(OBJS)) @@ -57,6 +60,9 @@ clean: ifneq "$(wildcard $(CMSIS) )" "" find $(CMSIS) -name "*.o" -type f -delete endif + rm -rf user/mpy/build + rm -rf user/mpy/*.o.d + rm -f user/mpy/py/*.o rm -f $(NAME).map $(NAME).lds rm -f $(NAME).elf $(NAME).bin diff --git a/user/mpy/_frozen_mpy.c b/user/mpy/_frozen_mpy.c new file mode 100644 index 0000000..45594a3 --- /dev/null +++ b/user/mpy/_frozen_mpy.c @@ -0,0 +1,112 @@ +#include "py/mpconfig.h" +#include "py/objint.h" +#include "py/objstr.h" +#include "py/emitglue.h" + +#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE +#error "MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE not supported with frozen mpy files" +#endif + +#if MICROPY_LONGINT_IMPL != 0 +#error "incompatible MICROPY_LONGINT_IMPL" +#endif + +#if MICROPY_PY_BUILTINS_FLOAT +typedef struct _mp_obj_float_t { + mp_obj_base_t base; + mp_float_t value; +} mp_obj_float_t; +#endif + +enum { + MP_QSTR_frozentest_dot_py = MP_QSTRnumber_of, + MP_QSTR_uPy, + MP_QSTR_i, +}; + +extern const qstr_pool_t mp_qstr_const_pool; +const qstr_pool_t mp_qstr_frozen_const_pool = { + (qstr_pool_t*)&mp_qstr_const_pool, // previous pool + MP_QSTRnumber_of, // previous pool size + 3, // allocated entries + 3, // used entries + { + (const byte*)"\xfe\x0d" "frozentest.py", + (const byte*)"\xf9\x03" "uPy", + (const byte*)"\xcc\x01" "i", + }, +}; + +// frozen bytecode for file frozentest.py, scope frozentest_ +STATIC const byte bytecode_data_frozentest__lt_module_gt_[92] = { + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, + MP_QSTR__lt_module_gt_ & 0xff, MP_QSTR__lt_module_gt_ >> 8, + MP_QSTR_frozentest_dot_py & 0xff, MP_QSTR_frozentest_dot_py >> 8, + 0x2a, 0x28, 0x28, 0x28, 0x2b, 0x28, 0x00, 0x00, 0xff, + 0x1c, MP_QSTR_print & 0xff, MP_QSTR_print >> 8, + 0x16, MP_QSTR_uPy & 0xff, MP_QSTR_uPy >> 8, + 0x64, 0x01, + 0x32, + 0x1c, MP_QSTR_print & 0xff, MP_QSTR_print >> 8, + 0x17, 0x00, + 0x64, 0x01, + 0x32, + 0x1c, MP_QSTR_print & 0xff, MP_QSTR_print >> 8, + 0x17, 0x01, + 0x64, 0x01, + 0x32, + 0x1c, MP_QSTR_print & 0xff, MP_QSTR_print >> 8, + 0x17, 0x02, + 0x64, 0x01, + 0x32, + 0x1c, MP_QSTR_print & 0xff, MP_QSTR_print >> 8, + 0x14, 0xba, 0xef, 0x9a, 0x15, + 0x64, 0x01, + 0x32, + 0x80, + 0x35, 0x0f, 0x80, + 0x30, + 0x24, MP_QSTR_i & 0xff, MP_QSTR_i >> 8, + 0x1c, MP_QSTR_print & 0xff, MP_QSTR_print >> 8, + 0x1c, MP_QSTR_i & 0xff, MP_QSTR_i >> 8, + 0x64, 0x01, + 0x32, + 0x81, + 0xe9, + 0x30, + 0x84, + 0xf0, + 0x36, 0xeb, 0x7f, + 0x32, + 0x11, + 0x5b, +}; +STATIC const mp_obj_str_t const_obj_frozentest__lt_module_gt__0 = {{&mp_type_str}, 0, 34, (const byte*)"\x61\x20\x6c\x6f\x6e\x67\x20\x73\x74\x72\x69\x6e\x67\x20\x74\x68\x61\x74\x20\x69\x73\x20\x6e\x6f\x74\x20\x69\x6e\x74\x65\x72\x6e\x65\x64"}; +STATIC const mp_obj_str_t const_obj_frozentest__lt_module_gt__1 = {{&mp_type_str}, 0, 38, (const byte*)"\x61\x20\x73\x74\x72\x69\x6e\x67\x20\x74\x68\x61\x74\x20\x68\x61\x73\x20\x75\x6e\x69\x63\x6f\x64\x65\x20\xce\xb1\xce\xb2\xce\xb3\x20\x63\x68\x61\x72\x73"}; +STATIC const mp_obj_str_t const_obj_frozentest__lt_module_gt__2 = {{&mp_type_bytes}, 0, 11, (const byte*)"\x62\x79\x74\x65\x73\x20\x31\x32\x33\x34\x01"}; +STATIC const mp_uint_t const_table_data_frozentest__lt_module_gt_[3] = { + (mp_uint_t)&const_obj_frozentest__lt_module_gt__0, + (mp_uint_t)&const_obj_frozentest__lt_module_gt__1, + (mp_uint_t)&const_obj_frozentest__lt_module_gt__2, +}; +const mp_raw_code_t raw_code_frozentest__lt_module_gt_ = { + .kind = MP_CODE_BYTECODE, + .scope_flags = 0x00, + .n_pos_args = 0, + .data.u_byte = { + .bytecode = bytecode_data_frozentest__lt_module_gt_, + .const_table = const_table_data_frozentest__lt_module_gt_, + #if MICROPY_PERSISTENT_CODE_SAVE + .bc_len = 92, + .n_obj = 3, + .n_raw_code = 0, + #endif + }, +}; + +const char mp_frozen_mpy_names[] = { +"frozentest.py\0" +"\0"}; +const mp_raw_code_t *const mp_frozen_mpy_content[] = { + &raw_code_frozentest__lt_module_gt_, +}; diff --git a/user/mpy/build.mk b/user/mpy/build.mk new file mode 100644 index 0000000..e5de6ae --- /dev/null +++ b/user/mpy/build.mk @@ -0,0 +1,69 @@ +TOP = user/mpy +PY_SRC ?= $(TOP)/py +BUILD = $(TOP)/build +PY_BUILD = $(BUILD)/py + +# where autogenerated header files go +HEADER_BUILD = $(BUILD)/genhdr + +# file containing qstr defs for the core Python bit +PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h + +include $(TOP)/py.mk + +# If qstr autogeneration is not disabled we specify the output header +# for all collected qstrings. +ifneq ($(QSTR_AUTOGEN_DISABLE),1) +QSTR_DEFS_COLLECTED = $(HEADER_BUILD)/qstrdefs.collected.h +endif + +CP = cp +MKDIR = mkdir +SED = sed +PYTHON = python3 + +CFLAGS += \ + -Iuser/mpy \ + -Iuser/mpy/build \ + +CSRC += \ + $(wildcard user/mpy/py/*.c) \ + user/mpy/mphalport.c \ + user/mpy/_frozen_mpy.c \ + user/mpy/lib/utils/pyexec.c \ + user/mpy/lib/mp-readline/readline.c \ + user/mpy/extmod/moductypes.o \ + user/mpy/extmod/modujson.o \ + user/mpy/extmod/modure.o \ + # user/mpy/extmod/moduzlib.o \ + # user/mpy/extmod/moduheapq.o \ + # user/mpy/extmod/modutimeq.o \ + # user/mpy/extmod/moduhashlib.o \ + # user/mpy/extmod/modubinascii.o \ + # user/mpy/extmod/virtpin.o \ + # user/mpy/extmod/machine_mem.o \ + # user/mpy/extmod/machine_pinbase.o \ + # user/mpy/extmod/machine_signal.o \ + # user/mpy/extmod/machine_pulse.o \ + # user/mpy/extmod/machine_i2c.o \ + # user/mpy/extmod/machine_spi.o \ + # user/mpy/extmod/modussl_axtls.o \ + # user/mpy/extmod/modussl_mbedtls.o \ + # user/mpy/extmod/modurandom.o \ + # user/mpy/extmod/moduselect.o \ + # user/mpy/extmod/modwebsocket.o \ + # user/mpy/extmod/modwebrepl.o \ + # user/mpy/extmod/modframebuf.o \ + # user/mpy/extmod/vfs.o \ + # user/mpy/extmod/vfs_reader.o \ + # user/mpy/extmod/vfs_fat.o \ + # user/mpy/extmod/vfs_fat_diskio.o \ + # user/mpy/extmod/vfs_fat_file.o \ + # user/mpy/extmod/vfs_fat_misc.o \ + # user/mpy/extmod/utime_mphal.o \ + # user/mpy/extmod/uos_dupterm.o \ + # user/mpy/lib/embed/abort_.o \ + +CSRC := $(filter-out user/mpy/py/frozen_mpy.o, $(CSRC)) + +include $(TOP)/py/mkrules.mk diff --git a/user/mpy/build/genhdr/mpversion.h b/user/mpy/build/genhdr/mpversion.h new file mode 100644 index 0000000..7b33029 --- /dev/null +++ b/user/mpy/build/genhdr/mpversion.h @@ -0,0 +1,8 @@ +// This file was generated by py/makeversionhdr.py +#define MICROPY_GIT_TAG "1b8e0d5-dirty" +#define MICROPY_GIT_HASH "1b8e0d5-dirty" +#define MICROPY_BUILD_DATE "2017-08-15" +#define MICROPY_VERSION_MAJOR (0) +#define MICROPY_VERSION_MINOR (0) +#define MICROPY_VERSION_MICRO (1) +#define MICROPY_VERSION_STRING "0.0.1" diff --git a/user/mpy/build/genhdr/qstr.i.last b/user/mpy/build/genhdr/qstr.i.last new file mode 100644 index 0000000..b299947 --- /dev/null +++ b/user/mpy/build/genhdr/qstr.i.last @@ -0,0 +1,286426 @@ +# 1 "user/mpy/py/mpstate.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/mpstate.c" +# 27 "user/mpy/py/mpstate.c" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 28 "user/mpy/py/mpstate.c" 2 + + + + + +mp_state_ctx_t mp_state_ctx; +# 1 "user/mpy/py/malloc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/malloc.c" +# 27 "user/mpy/py/malloc.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/malloc.c" 2 +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 29 "user/mpy/py/malloc.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/malloc.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/malloc.c" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 33 "user/mpy/py/malloc.c" 2 +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 34 "user/mpy/py/malloc.c" 2 +# 46 "user/mpy/py/malloc.c" +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 47 "user/mpy/py/malloc.c" 2 +# 74 "user/mpy/py/malloc.c" +void *m_malloc(size_t num_bytes) { + void *ptr = gc_alloc((num_bytes), +# 75 "user/mpy/py/malloc.c" 3 4 + 0 +# 75 "user/mpy/py/malloc.c" + ); + if (ptr == +# 76 "user/mpy/py/malloc.c" 3 4 + ((void *)0) +# 76 "user/mpy/py/malloc.c" + && num_bytes != 0) { + return m_malloc_fail(num_bytes); + } + + + + + + (void)0; + return ptr; +} + +void *m_malloc_maybe(size_t num_bytes) { + void *ptr = gc_alloc((num_bytes), +# 89 "user/mpy/py/malloc.c" 3 4 + 0 +# 89 "user/mpy/py/malloc.c" + ); + + + + + + (void)0; + return ptr; +} +# 115 "user/mpy/py/malloc.c" +void *m_malloc0(size_t num_bytes) { + void *ptr = m_malloc(num_bytes); + if (ptr == +# 117 "user/mpy/py/malloc.c" 3 4 + ((void *)0) +# 117 "user/mpy/py/malloc.c" + && num_bytes != 0) { + return m_malloc_fail(num_bytes); + } + + + + + return ptr; +} + + + + +void *m_realloc(void *ptr, size_t new_num_bytes) { + + void *new_ptr = gc_realloc(ptr, new_num_bytes, +# 132 "user/mpy/py/malloc.c" 3 4 + 1 +# 132 "user/mpy/py/malloc.c" + ); + if (new_ptr == +# 133 "user/mpy/py/malloc.c" 3 4 + ((void *)0) +# 133 "user/mpy/py/malloc.c" + && new_num_bytes != 0) { + return m_malloc_fail(new_num_bytes); + } +# 147 "user/mpy/py/malloc.c" + (void)0; + return new_ptr; +} + + + + +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 154 "user/mpy/py/malloc.c" 3 4 + _Bool +# 154 "user/mpy/py/malloc.c" + allow_move) { + + void *new_ptr = gc_realloc(ptr, new_num_bytes, allow_move); +# 171 "user/mpy/py/malloc.c" + (void)0; + return new_ptr; +} + + + + +void m_free(void *ptr) { + + gc_free(ptr); + + + + (void)0; +} +# 1 "user/mpy/py/gc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/gc.c" +# 27 "user/mpy/py/gc.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/gc.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 35 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/gc.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/gc.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 32 "user/mpy/py/gc.c" 2 +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 33 "user/mpy/py/gc.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 35 "user/mpy/py/gc.c" 2 +# 106 "user/mpy/py/gc.c" +void gc_init(void *start, void *end) { + + end = (void*)((uintptr_t)end & (~(((4 * (sizeof(mp_uint_t)))) - 1))); + (void)0; + + + + + + + size_t total_byte_len = (byte*)end - (byte*)start; + + + + (mp_state_ctx.mem.gc_alloc_table_byte_len) = total_byte_len / (1 + (8) / 2 * ((4 * (sizeof(mp_uint_t))))); + + + (mp_state_ctx.mem.gc_alloc_table_start) = (byte*)start; + + + + + + + size_t gc_pool_block_len = (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); + (mp_state_ctx.mem.gc_pool_start) = (byte*)end - gc_pool_block_len * ((4 * (sizeof(mp_uint_t)))); + (mp_state_ctx.mem.gc_pool_end) = end; + + + + + + + memset((mp_state_ctx.mem.gc_alloc_table_start), 0, (mp_state_ctx.mem.gc_alloc_table_byte_len)); + + + + + + + + (mp_state_ctx.mem.gc_last_free_atb_index) = 0; + + + (mp_state_ctx.mem.gc_lock_depth) = 0; + + + (mp_state_ctx.mem.gc_auto_collect_enabled) = 1; +# 165 "user/mpy/py/gc.c" + (void)0; + (void)0; + + + + (void)0; +} + +void gc_lock(void) { + ; + (mp_state_ctx.mem.gc_lock_depth)++; + ; +} + +void gc_unlock(void) { + ; + (mp_state_ctx.mem.gc_lock_depth)--; + ; +} + + +# 185 "user/mpy/py/gc.c" 3 4 +_Bool +# 185 "user/mpy/py/gc.c" + gc_is_locked(void) { + return (mp_state_ctx.mem.gc_lock_depth) != 0; +} +# 214 "user/mpy/py/gc.c" +static void gc_drain_stack(void) { + while ((mp_state_ctx.mem.gc_sp) > (mp_state_ctx.mem.gc_stack)) { + + size_t block = *--(mp_state_ctx.mem.gc_sp); + + + size_t n_blocks = 0; + do { + n_blocks += 1; + } while ((((mp_state_ctx.mem.gc_alloc_table_start)[(block + n_blocks) / (4)] >> (2 * ((block + n_blocks) & ((4) - 1)))) & 3) == (2)); + + + void **ptrs = (void**)(((block) * ((4 * (sizeof(mp_uint_t)))) + (uintptr_t)(mp_state_ctx.mem.gc_pool_start))); + for (size_t i = n_blocks * ((4 * (sizeof(mp_uint_t)))) / sizeof(void*); i > 0; i--, ptrs++) { + void *ptr = *ptrs; + do { if (( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { size_t _block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); if ((((mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] >> (2 * ((_block) & ((4) - 1)))) & 3) == (1)) { (void)0; do { (mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] |= ((3) << (2 * ((_block) & ((4) - 1)))); } while (0); if ((mp_state_ctx.mem.gc_sp) < &(mp_state_ctx.mem.gc_stack)[(64)]) { *(mp_state_ctx.mem.gc_sp)++ = _block; } else { (mp_state_ctx.mem.gc_stack_overflow) = 1; } } } } while (0); + } + } +} + +static void gc_deal_with_stack_overflow(void) { + while ((mp_state_ctx.mem.gc_stack_overflow)) { + (mp_state_ctx.mem.gc_stack_overflow) = 0; + (mp_state_ctx.mem.gc_sp) = (mp_state_ctx.mem.gc_stack); + + + for (size_t block = 0; block < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); block++) { + + if ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (3)) { + *(mp_state_ctx.mem.gc_sp)++ = block; + gc_drain_stack(); + } + } + } +} + +static void gc_sweep(void) { + + + + + int free_tail = 0; + for (size_t block = 0; block < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); block++) { + switch ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3)) { + case (1): +# 281 "user/mpy/py/gc.c" + free_tail = 1; + (void)0; + + + + + + case (2): + if (free_tail) { + do { (mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] &= (~((3) << (2 * ((block) & ((4) - 1))))); } while (0); + } + break; + + case (3): + do { (mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] &= (~((2) << (2 * ((block) & ((4) - 1))))); } while (0); + free_tail = 0; + break; + } + } +} + +void gc_collect_start(void) { + ; + (mp_state_ctx.mem.gc_lock_depth)++; + + + + (mp_state_ctx.mem.gc_stack_overflow) = 0; + (mp_state_ctx.mem.gc_sp) = (mp_state_ctx.mem.gc_stack); + + + + void **ptrs = (void**)(void*)&mp_state_ctx; + gc_collect_root(ptrs, +# 314 "user/mpy/py/gc.c" 3 4 + __builtin_offsetof ( +# 314 "user/mpy/py/gc.c" + mp_state_ctx_t +# 314 "user/mpy/py/gc.c" 3 4 + , +# 314 "user/mpy/py/gc.c" + vm.qstr_last_chunk +# 314 "user/mpy/py/gc.c" 3 4 + ) +# 314 "user/mpy/py/gc.c" + / sizeof(void*)); +} + +void gc_collect_root(void **ptrs, size_t len) { + for (size_t i = 0; i < len; i++) { + void *ptr = ptrs[i]; + do { if (( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { size_t _block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); if ((((mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] >> (2 * ((_block) & ((4) - 1)))) & 3) == (1)) { (void)0; do { (mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] |= ((3) << (2 * ((_block) & ((4) - 1)))); } while (0); if ((mp_state_ctx.mem.gc_sp) < &(mp_state_ctx.mem.gc_stack)[(64)]) { *(mp_state_ctx.mem.gc_sp)++ = _block; } else { (mp_state_ctx.mem.gc_stack_overflow) = 1; } } } } while (0); + gc_drain_stack(); + } +} + +void gc_collect_end(void) { + gc_deal_with_stack_overflow(); + gc_sweep(); + (mp_state_ctx.mem.gc_last_free_atb_index) = 0; + (mp_state_ctx.mem.gc_lock_depth)--; + ; +} + +void gc_info(gc_info_t *info) { + ; + info->total = (mp_state_ctx.mem.gc_pool_end) - (mp_state_ctx.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; + +# 342 "user/mpy/py/gc.c" 3 4 + _Bool +# 342 "user/mpy/py/gc.c" + finish = +# 342 "user/mpy/py/gc.c" 3 4 + 0 +# 342 "user/mpy/py/gc.c" + ; + for (size_t block = 0, len = 0, len_free = 0; !finish;) { + size_t kind = (((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3); + switch (kind) { + case (0): + info->free += 1; + len_free += 1; + len = 0; + break; + + case (1): + info->used += 1; + len = 1; + break; + + case (2): + info->used += 1; + len += 1; + break; + + case (3): + + break; + } + + block++; + finish = (block == (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4)); + + if (!finish) { + kind = (((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3); + } + + if (finish || kind == (0) || kind == (1)) { + 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 == (1)) { + if (len_free > info->max_free) { + info->max_free = len_free; + } + len_free = 0; + } + } + } + + info->used *= ((4 * (sizeof(mp_uint_t)))); + info->free *= ((4 * (sizeof(mp_uint_t)))); + ; +} + +void *gc_alloc(size_t n_bytes, +# 397 "user/mpy/py/gc.c" 3 4 + _Bool +# 397 "user/mpy/py/gc.c" + has_finaliser) { + size_t n_blocks = ((n_bytes + ((4 * (sizeof(mp_uint_t)))) - 1) & (~(((4 * (sizeof(mp_uint_t)))) - 1))) / ((4 * (sizeof(mp_uint_t)))); + (void)0; + + + if (n_blocks == 0) { + return +# 403 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 403 "user/mpy/py/gc.c" + ; + } + + ; + + + if ((mp_state_ctx.mem.gc_lock_depth) > 0) { + ; + return +# 411 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 411 "user/mpy/py/gc.c" + ; + } + + size_t i; + size_t end_block; + size_t start_block; + size_t n_free = 0; + int collected = !(mp_state_ctx.mem.gc_auto_collect_enabled); +# 428 "user/mpy/py/gc.c" + for (;;) { + + + for (i = (mp_state_ctx.mem.gc_last_free_atb_index); i < (mp_state_ctx.mem.gc_alloc_table_byte_len); i++) { + byte a = (mp_state_ctx.mem.gc_alloc_table_start)[i]; + if ((((a) & (0x03)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 0; goto found; } } else { n_free = 0; } + if ((((a) & (0x0c)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 1; goto found; } } else { n_free = 0; } + if ((((a) & (0x30)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 2; goto found; } } else { n_free = 0; } + if ((((a) & (0xc0)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 3; goto found; } } else { n_free = 0; } + } + + ; + + if (collected) { + return +# 442 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 442 "user/mpy/py/gc.c" + ; + } + (void)0; + gc_collect(); + collected = 1; + ; + } + + +found: + + end_block = i; + start_block = i - n_free + 1; + + + + + + + if (n_free == 1) { + (mp_state_ctx.mem.gc_last_free_atb_index) = (i + 1) / (4); + } + + + do { (mp_state_ctx.mem.gc_alloc_table_start)[(start_block) / (4)] |= ((1) << (2 * ((start_block) & ((4) - 1)))); } while (0); + + + + for (size_t bl = start_block + 1; bl <= end_block; bl++) { + do { (mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] |= ((2) << (2 * ((bl) & ((4) - 1)))); } while (0); + } + + + + void *ret_ptr = (void*)((mp_state_ctx.mem.gc_pool_start) + start_block * ((4 * (sizeof(mp_uint_t))))); + (void)0; + + + + + + ; + + + + memset((byte*)ret_ptr, 0, (end_block - start_block + 1) * ((4 * (sizeof(mp_uint_t))))); +# 507 "user/mpy/py/gc.c" + (void)has_finaliser; + + + + + + + return ret_ptr; +} +# 529 "user/mpy/py/gc.c" +void gc_free(void *ptr) { + ; + if ((mp_state_ctx.mem.gc_lock_depth) > 0) { + + ; + return; + } + + (void)0; + + if (ptr == +# 539 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 539 "user/mpy/py/gc.c" + ) { + ; + } else { + + +# 543 "user/mpy/py/gc.c" 3 + (( +# 543 "user/mpy/py/gc.c" + ( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) ) +# 543 "user/mpy/py/gc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/gc.c", 543, __func__, +# 543 "user/mpy/py/gc.c" + "VERIFY_PTR(ptr)" +# 543 "user/mpy/py/gc.c" 3 + )) +# 543 "user/mpy/py/gc.c" + ; + size_t block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); + +# 545 "user/mpy/py/gc.c" 3 + (( +# 545 "user/mpy/py/gc.c" + (((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (1) +# 545 "user/mpy/py/gc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/gc.c", 545, __func__, +# 545 "user/mpy/py/gc.c" + "ATB_GET_KIND(block) == AT_HEAD" +# 545 "user/mpy/py/gc.c" 3 + )) +# 545 "user/mpy/py/gc.c" + ; + + + + + + + if (block / (4) < (mp_state_ctx.mem.gc_last_free_atb_index)) { + (mp_state_ctx.mem.gc_last_free_atb_index) = block / (4); + } + + + do { + do { (mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] &= (~((3) << (2 * ((block) & ((4) - 1))))); } while (0); + block += 1; + } while ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (2)); + + ; + + + + + } +} + +size_t gc_nbytes(const void *ptr) { + ; + if (( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { + size_t block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); + if ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (1)) { + + size_t n_blocks = 0; + do { + n_blocks += 1; + } while ((((mp_state_ctx.mem.gc_alloc_table_start)[(block + n_blocks) / (4)] >> (2 * ((block + n_blocks) & ((4) - 1)))) & 3) == (2)); + ; + return n_blocks * ((4 * (sizeof(mp_uint_t)))); + } + } + + + ; + return 0; +} +# 619 "user/mpy/py/gc.c" +void *gc_realloc(void *ptr_in, size_t n_bytes, +# 619 "user/mpy/py/gc.c" 3 4 + _Bool +# 619 "user/mpy/py/gc.c" + allow_move) { + + if (ptr_in == +# 621 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 621 "user/mpy/py/gc.c" + ) { + return gc_alloc(n_bytes, +# 622 "user/mpy/py/gc.c" 3 4 + 0 +# 622 "user/mpy/py/gc.c" + ); + } + + + if (n_bytes == 0) { + gc_free(ptr_in); + return +# 628 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 628 "user/mpy/py/gc.c" + ; + } + + void *ptr = ptr_in; + + + if (!( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { + return +# 635 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 635 "user/mpy/py/gc.c" + ; + } + + + size_t block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); + + ; + + + if ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) != (1)) { + ; + return +# 646 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 646 "user/mpy/py/gc.c" + ; + } + + if ((mp_state_ctx.mem.gc_lock_depth) > 0) { + ; + return +# 651 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 651 "user/mpy/py/gc.c" + ; + } + + + size_t new_blocks = (n_bytes + ((4 * (sizeof(mp_uint_t)))) - 1) / ((4 * (sizeof(mp_uint_t)))); + + + + + + + + size_t n_free = 0; + size_t n_blocks = 1; + size_t max_block = (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); + for (size_t bl = block + n_blocks; bl < max_block; bl++) { + byte block_type = (((mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] >> (2 * ((bl) & ((4) - 1)))) & 3); + if (block_type == (2)) { + n_blocks++; + continue; + } + if (block_type == (0)) { + n_free++; + if (n_blocks + n_free >= new_blocks) { + + break; + } + continue; + } + break; + } + + + if (new_blocks == n_blocks) { + ; + return ptr_in; + } + + + if (new_blocks < n_blocks) { + + for (size_t bl = block + new_blocks, count = n_blocks - new_blocks; count > 0; bl++, count--) { + do { (mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] &= (~((3) << (2 * ((bl) & ((4) - 1))))); } while (0); + } + + + if ((block + new_blocks) / (4) < (mp_state_ctx.mem.gc_last_free_atb_index)) { + (mp_state_ctx.mem.gc_last_free_atb_index) = (block + new_blocks) / (4); + } + + ; + + + + + + return ptr_in; + } + + + if (new_blocks <= n_blocks + n_free) { + + for (size_t bl = block + n_blocks; bl < block + new_blocks; bl++) { + +# 714 "user/mpy/py/gc.c" 3 + (( +# 714 "user/mpy/py/gc.c" + (((mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] >> (2 * ((bl) & ((4) - 1)))) & 3) == (0) +# 714 "user/mpy/py/gc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/gc.c", 714, __func__, +# 714 "user/mpy/py/gc.c" + "ATB_GET_KIND(bl) == AT_FREE" +# 714 "user/mpy/py/gc.c" 3 + )) +# 714 "user/mpy/py/gc.c" + ; + do { (mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] |= ((2) << (2 * ((bl) & ((4) - 1)))); } while (0); + } + + ; + + + + memset((byte*)ptr_in + n_blocks * ((4 * (sizeof(mp_uint_t)))), 0, (new_blocks - n_blocks) * ((4 * (sizeof(mp_uint_t))))); +# 732 "user/mpy/py/gc.c" + return ptr_in; + } + + + + + +# 738 "user/mpy/py/gc.c" 3 4 + _Bool +# 738 "user/mpy/py/gc.c" + ftb_state = +# 738 "user/mpy/py/gc.c" 3 4 + 0 +# 738 "user/mpy/py/gc.c" + ; + + + ; + + if (!allow_move) { + + return +# 745 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 745 "user/mpy/py/gc.c" + ; + } + + + void *ptr_out = gc_alloc(n_bytes, ftb_state); + + + if (ptr_out == +# 752 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 752 "user/mpy/py/gc.c" + ) { + return +# 753 "user/mpy/py/gc.c" 3 4 + ((void *)0) +# 753 "user/mpy/py/gc.c" + ; + } + + (void)0; + memcpy(ptr_out, ptr_in, n_blocks * ((4 * (sizeof(mp_uint_t))))); + gc_free(ptr_in); + return ptr_out; +} + + +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) { + ; + static const size_t DUMP_BYTES_PER_LINE = 64; + + + + mp_printf(&mp_plat_print, "GC memory layout; from %p:", (mp_state_ctx.mem.gc_pool_start)); + + for (size_t bl = 0; bl < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); bl++) { + if (bl % DUMP_BYTES_PER_LINE == 0) { + + { + + size_t bl2 = bl; + while (bl2 < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4) && (((mp_state_ctx.mem.gc_alloc_table_start)[(bl2) / (4)] >> (2 * ((bl2) & ((4) - 1)))) & 3) == (0)) { + bl2++; + } + if (bl2 - bl >= 2 * DUMP_BYTES_PER_LINE) { + + 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_ctx.mem.gc_alloc_table_byte_len) * (4)) { + + break; + } + } + } + + + + mp_printf(&mp_plat_print, "\n%05x: ", (uint)((bl * ((4 * (sizeof(mp_uint_t))))) & (uint32_t)0xfffff)); + } + int c = ' '; + switch ((((mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] >> (2 * ((bl) & ((4) - 1)))) & 3)) { + case (0): c = '.'; break; +# 834 "user/mpy/py/gc.c" + case (1): { + void **ptr = (void**)((mp_state_ctx.mem.gc_pool_start) + bl * ((4 * (sizeof(mp_uint_t))))); + 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'; } +# 849 "user/mpy/py/gc.c" + else if (*ptr == &mp_type_fun_bc) { c = 'B'; } + else if (*ptr == &mp_type_module) { c = 'M'; } + else { + c = 'h'; +# 870 "user/mpy/py/gc.c" + } + break; + } + case (2): c = '='; break; + case (3): c = 'm'; break; + } + mp_printf(&mp_plat_print, "%c", c); + } + mp_print_str(&mp_plat_print, "\n"); + ; +} +# 1 "user/mpy/py/qstr.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/qstr.c" +# 27 "user/mpy/py/qstr.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/qstr.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/qstr.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 61 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 30 "user/mpy/py/qstr.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 32 "user/mpy/py/qstr.c" 2 + +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 34 "user/mpy/py/qstr.c" 2 +# 84 "user/mpy/py/qstr.c" +mp_uint_t qstr_compute_hash(const byte *data, size_t len) { + + mp_uint_t hash = 5381; + for (const byte *top = data + len; data < top; data++) { + hash = ((hash << 5) + hash) ^ (*data); + } + hash &= (0xff); + + if (hash == 0) { + hash++; + } + return hash; +} + +const qstr_pool_t mp_qstr_const_pool = { + +# 99 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 99 "user/mpy/py/qstr.c" + , + 0, + 10, + MP_QSTRnumber_of, + { + + + + + + }, +}; + + +extern const qstr_pool_t mp_qstr_frozen_const_pool; + + + + + +void qstr_init(void) { + (mp_state_ctx.vm.last_pool) = (qstr_pool_t*)&mp_qstr_frozen_const_pool; + (mp_state_ctx.vm.qstr_last_chunk) = +# 121 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 121 "user/mpy/py/qstr.c" + ; + + + + +} + +static const byte *find_qstr(qstr q) { + + for (qstr_pool_t *pool = (mp_state_ctx.vm.last_pool); pool != +# 130 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 130 "user/mpy/py/qstr.c" + ; pool = pool->prev) { + if (q >= pool->total_prev_len) { + return pool->qstrs[q - pool->total_prev_len]; + } + } + + + return 0; +} + + +static qstr qstr_add(const byte *q_ptr) { + (void)0; + + + if ((mp_state_ctx.vm.last_pool)->len >= (mp_state_ctx.vm.last_pool)->alloc) { + qstr_pool_t *pool = ((qstr_pool_t*)m_malloc_maybe(sizeof(qstr_pool_t) + sizeof(const char*) * ((mp_state_ctx.vm.last_pool)->alloc * 2))); + if (pool == +# 147 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 147 "user/mpy/py/qstr.c" + ) { + ; + m_malloc_fail((mp_state_ctx.vm.last_pool)->alloc * 2); + } + pool->prev = (mp_state_ctx.vm.last_pool); + pool->total_prev_len = (mp_state_ctx.vm.last_pool)->total_prev_len + (mp_state_ctx.vm.last_pool)->len; + pool->alloc = (mp_state_ctx.vm.last_pool)->alloc * 2; + pool->len = 0; + (mp_state_ctx.vm.last_pool) = pool; + (void)0; + } + + + (mp_state_ctx.vm.last_pool)->qstrs[(mp_state_ctx.vm.last_pool)->len++] = q_ptr; + + + return (mp_state_ctx.vm.last_pool)->total_prev_len + (mp_state_ctx.vm.last_pool)->len - 1; +} + +qstr qstr_find_strn(const char *str, size_t str_len) { + + mp_uint_t str_hash = qstr_compute_hash((const byte*)str, str_len); + + + for (qstr_pool_t *pool = (mp_state_ctx.vm.last_pool); pool != +# 171 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 171 "user/mpy/py/qstr.c" + ; pool = pool->prev) { + for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { + if (((mp_uint_t)(*q)[0]) == str_hash && ((*q)[(1)]) == str_len && memcmp(((*q) + (1) + (1)), str, str_len) == 0) { + return pool->total_prev_len + (q - pool->qstrs); + } + } + } + + + return 0; +} + +qstr qstr_from_str(const char *str) { + return qstr_from_strn(str, strlen(str)); +} + +qstr qstr_from_strn(const char *str, size_t len) { + +# 188 "user/mpy/py/qstr.c" 3 + (( +# 188 "user/mpy/py/qstr.c" + len < (1 << (8 * (1))) +# 188 "user/mpy/py/qstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/qstr.c", 188, __func__, +# 188 "user/mpy/py/qstr.c" + "len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))" +# 188 "user/mpy/py/qstr.c" 3 + )) +# 188 "user/mpy/py/qstr.c" + ; + ; + qstr q = qstr_find_strn(str, len); + if (q == 0) { + + + + size_t n_bytes = (1) + (1) + len + 1; + + if ((mp_state_ctx.vm.qstr_last_chunk) != +# 197 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 197 "user/mpy/py/qstr.c" + && (mp_state_ctx.vm.qstr_last_used) + n_bytes > (mp_state_ctx.vm.qstr_last_alloc)) { + + byte *new_p = ((byte*)(m_realloc_maybe(((mp_state_ctx.vm.qstr_last_chunk)), sizeof(byte) * ((mp_state_ctx.vm.qstr_last_alloc) + n_bytes), ( +# 199 "user/mpy/py/qstr.c" 3 4 + 0 +# 199 "user/mpy/py/qstr.c" + )))); + if (new_p == +# 200 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 200 "user/mpy/py/qstr.c" + ) { + + (void)((byte*)(m_realloc_maybe(((mp_state_ctx.vm.qstr_last_chunk)), sizeof(byte) * ((mp_state_ctx.vm.qstr_last_used)), ( +# 202 "user/mpy/py/qstr.c" 3 4 + 0 +# 202 "user/mpy/py/qstr.c" + )))); + (mp_state_ctx.vm.qstr_last_chunk) = +# 203 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 203 "user/mpy/py/qstr.c" + ; + } else { + + (mp_state_ctx.vm.qstr_last_alloc) += n_bytes; + } + } + + if ((mp_state_ctx.vm.qstr_last_chunk) == +# 210 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 210 "user/mpy/py/qstr.c" + ) { + + size_t al = n_bytes; + if (al < (128)) { + al = (128); + } + (mp_state_ctx.vm.qstr_last_chunk) = ((byte*)(m_malloc_maybe(sizeof(byte) * (al)))); + if ((mp_state_ctx.vm.qstr_last_chunk) == +# 217 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 217 "user/mpy/py/qstr.c" + ) { + + (mp_state_ctx.vm.qstr_last_chunk) = ((byte*)(m_malloc_maybe(sizeof(byte) * (n_bytes)))); + if ((mp_state_ctx.vm.qstr_last_chunk) == +# 220 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 220 "user/mpy/py/qstr.c" + ) { + ; + m_malloc_fail(n_bytes); + } + al = n_bytes; + } + (mp_state_ctx.vm.qstr_last_alloc) = al; + (mp_state_ctx.vm.qstr_last_used) = 0; + } + + + byte *q_ptr = (mp_state_ctx.vm.qstr_last_chunk) + (mp_state_ctx.vm.qstr_last_used); + (mp_state_ctx.vm.qstr_last_used) += n_bytes; + + + mp_uint_t hash = qstr_compute_hash((const byte*)str, len); + do { (q_ptr)[0] = (hash); } while (0); + do { (q_ptr)[(1)] = (len); } while (0); + memcpy(q_ptr + (1) + (1), str, len); + q_ptr[(1) + (1) + len] = '\0'; + q = qstr_add(q_ptr); + } + ; + return q; +} + +byte *qstr_build_start(size_t len, byte **q_ptr) { + +# 247 "user/mpy/py/qstr.c" 3 + (( +# 247 "user/mpy/py/qstr.c" + len < (1 << (8 * (1))) +# 247 "user/mpy/py/qstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/qstr.c", 247, __func__, +# 247 "user/mpy/py/qstr.c" + "len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))" +# 247 "user/mpy/py/qstr.c" 3 + )) +# 247 "user/mpy/py/qstr.c" + ; + *q_ptr = ((byte*)(m_malloc(sizeof(byte) * ((1) + (1) + len + 1)))); + do { (*q_ptr)[(1)] = (len); } while (0); + return ((*q_ptr) + (1) + (1)); +} + +qstr qstr_build_end(byte *q_ptr) { + ; + qstr q = qstr_find_strn((const char*)((q_ptr) + (1) + (1)), ((q_ptr)[(1)])); + if (q == 0) { + size_t len = ((q_ptr)[(1)]); + mp_uint_t hash = qstr_compute_hash(((q_ptr) + (1) + (1)), len); + do { (q_ptr)[0] = (hash); } while (0); + q_ptr[(1) + (1) + len] = '\0'; + q = qstr_add(q_ptr); + } else { + ((void)(((1) + (1) + ((q_ptr)[(1)]) + 1)), m_free(q_ptr)); + } + ; + return q; +} + +mp_uint_t qstr_hash(qstr q) { + return ((mp_uint_t)(find_qstr(q))[0]); +} + +size_t qstr_len(qstr q) { + const byte *qd = find_qstr(q); + return ((qd)[(1)]); +} + +const char *qstr_str(qstr q) { + const byte *qd = find_qstr(q); + return (const char*)((qd) + (1) + (1)); +} + +const byte *qstr_data(qstr q, size_t *len) { + const byte *qd = find_qstr(q); + *len = ((qd)[(1)]); + return ((qd) + (1) + (1)); +} + +void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, size_t *n_total_bytes) { + ; + *n_pool = 0; + *n_qstr = 0; + *n_str_data_bytes = 0; + *n_total_bytes = 0; + for (qstr_pool_t *pool = (mp_state_ctx.vm.last_pool); pool != +# 295 "user/mpy/py/qstr.c" 3 4 + ((void *)0) +# 295 "user/mpy/py/qstr.c" + && pool != &mp_qstr_frozen_const_pool; pool = pool->prev) { + *n_pool += 1; + *n_qstr += pool->len; + for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { + *n_str_data_bytes += ((1) + (1) + ((*q)[(1)]) + 1); + } + + *n_total_bytes += gc_nbytes(pool); + + + + } + *n_total_bytes += *n_str_data_bytes; + ; +} +# 1 "user/mpy/py/vstr.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/vstr.c" +# 27 "user/mpy/py/vstr.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/vstr.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 29 "user/mpy/py/vstr.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/vstr.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/vstr.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 33 "user/mpy/py/vstr.c" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/vstr.c" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 35 "user/mpy/py/vstr.c" 2 + + + + + +void vstr_init(vstr_t *vstr, size_t alloc) { + if (alloc < 1) { + alloc = 1; + } + vstr->alloc = alloc; + vstr->len = 0; + vstr->buf = ((char*)(m_malloc(sizeof(char) * (vstr->alloc)))); + vstr->fixed_buf = +# 47 "user/mpy/py/vstr.c" 3 4 + 0 +# 47 "user/mpy/py/vstr.c" + ; +} + + + +void vstr_init_len(vstr_t *vstr, size_t len) { + vstr_init(vstr, len + 1); + vstr->len = len; +} + +void vstr_init_fixed_buf(vstr_t *vstr, size_t alloc, char *buf) { + vstr->alloc = alloc; + vstr->len = 0; + vstr->buf = buf; + vstr->fixed_buf = +# 61 "user/mpy/py/vstr.c" 3 4 + 1 +# 61 "user/mpy/py/vstr.c" + ; +} + +void vstr_init_print(vstr_t *vstr, size_t alloc, mp_print_t *print) { + vstr_init(vstr, alloc); + print->data = vstr; + print->print_strn = (mp_print_strn_t)vstr_add_strn; +} + +void vstr_clear(vstr_t *vstr) { + if (!vstr->fixed_buf) { + ((void)(vstr->alloc), m_free(vstr->buf)); + } + vstr->buf = +# 74 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 74 "user/mpy/py/vstr.c" + ; +} + +vstr_t *vstr_new(size_t alloc) { + vstr_t *vstr = (((vstr_t*)(m_malloc(sizeof(vstr_t) * (1))))); + vstr_init(vstr, alloc); + return vstr; +} + +void vstr_free(vstr_t *vstr) { + if (vstr != +# 84 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 84 "user/mpy/py/vstr.c" + ) { + if (!vstr->fixed_buf) { + ((void)(vstr->alloc), m_free(vstr->buf)); + } + (((void)(1), m_free(vstr))); + } +} + + +char *vstr_extend(vstr_t *vstr, size_t size) { + if (vstr->fixed_buf) { + return +# 95 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 95 "user/mpy/py/vstr.c" + ; + } + char *new_buf = ((char*)(m_realloc((vstr->buf), sizeof(char) * (vstr->alloc + size)))); + char *p = new_buf + vstr->alloc; + vstr->alloc += size; + vstr->buf = new_buf; + return p; +} + +static +# 104 "user/mpy/py/vstr.c" 3 4 + _Bool +# 104 "user/mpy/py/vstr.c" + vstr_ensure_extra(vstr_t *vstr, size_t size) { + if (vstr->len + size > vstr->alloc) { + if (vstr->fixed_buf) { + return +# 107 "user/mpy/py/vstr.c" 3 4 + 0 +# 107 "user/mpy/py/vstr.c" + ; + } + size_t new_alloc = ((((vstr->len + size) + 16) & ((~0U) - 7)) + 8); + char *new_buf = ((char*)(m_realloc((vstr->buf), sizeof(char) * (new_alloc)))); + vstr->alloc = new_alloc; + vstr->buf = new_buf; + } + return +# 114 "user/mpy/py/vstr.c" 3 4 + 1 +# 114 "user/mpy/py/vstr.c" + ; +} + +void vstr_hint_size(vstr_t *vstr, size_t size) { + vstr_ensure_extra(vstr, size); +} + +char *vstr_add_len(vstr_t *vstr, size_t len) { + if (!vstr_ensure_extra(vstr, len)) { + return +# 123 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 123 "user/mpy/py/vstr.c" + ; + } + char *buf = vstr->buf + vstr->len; + vstr->len += len; + return buf; +} + + +char *vstr_null_terminated_str(vstr_t *vstr) { + + if (vstr->alloc == vstr->len) { + if (vstr_extend(vstr, 1) == +# 134 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 134 "user/mpy/py/vstr.c" + ) { + return +# 135 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 135 "user/mpy/py/vstr.c" + ; + } + } + vstr->buf[vstr->len] = '\0'; + return vstr->buf; +} + +void vstr_add_byte(vstr_t *vstr, byte b) { + byte *buf = (byte*)vstr_add_len(vstr, 1); + if (buf == +# 144 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 144 "user/mpy/py/vstr.c" + ) { + return; + } + buf[0] = b; +} + +void vstr_add_char(vstr_t *vstr, unichar c) { +# 187 "user/mpy/py/vstr.c" + vstr_add_byte(vstr, c); + +} + +void vstr_add_str(vstr_t *vstr, const char *str) { + vstr_add_strn(vstr, str, strlen(str)); +} + +void vstr_add_strn(vstr_t *vstr, const char *str, size_t len) { + if (!vstr_ensure_extra(vstr, len)) { + + + if (vstr->fixed_buf && vstr->len < vstr->alloc) { + len = vstr->alloc - vstr->len; + goto copy; + } + return; + } +copy: + memmove(vstr->buf + vstr->len, str, len); + vstr->len += len; +} + +static char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) { + size_t l = vstr->len; + if (byte_pos > l) { + byte_pos = l; + } + if (byte_len > 0) { + + if (!vstr_ensure_extra(vstr, byte_len)) { + return +# 218 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 218 "user/mpy/py/vstr.c" + ; + } + + memmove(vstr->buf + byte_pos + byte_len, vstr->buf + byte_pos, l - byte_pos); + + vstr->len += byte_len; + } + return vstr->buf + byte_pos; +} + +void vstr_ins_byte(vstr_t *vstr, size_t byte_pos, byte b) { + char *s = vstr_ins_blank_bytes(vstr, byte_pos, 1); + if (s != +# 230 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 230 "user/mpy/py/vstr.c" + ) { + *s = b; + } +} + +void vstr_ins_char(vstr_t *vstr, size_t char_pos, unichar chr) { + + char *s = vstr_ins_blank_bytes(vstr, char_pos, 1); + if (s != +# 238 "user/mpy/py/vstr.c" 3 4 + ((void *)0) +# 238 "user/mpy/py/vstr.c" + ) { + *s = chr; + } +} + +void vstr_cut_head_bytes(vstr_t *vstr, size_t bytes_to_cut) { + vstr_cut_out_bytes(vstr, 0, bytes_to_cut); +} + +void vstr_cut_tail_bytes(vstr_t *vstr, size_t len) { + if (len > vstr->len) { + vstr->len = 0; + } else { + vstr->len -= len; + } +} + +void vstr_cut_out_bytes(vstr_t *vstr, size_t byte_pos, size_t bytes_to_cut) { + if (byte_pos >= vstr->len) { + return; + } else if (byte_pos + bytes_to_cut >= vstr->len) { + vstr->len = byte_pos; + } else { + memmove(vstr->buf + byte_pos, vstr->buf + byte_pos + bytes_to_cut, vstr->len - byte_pos - bytes_to_cut); + vstr->len -= bytes_to_cut; + } +} + +void vstr_printf(vstr_t *vstr, const char *fmt, ...) { + va_list ap; + +# 268 "user/mpy/py/vstr.c" 3 4 + __builtin_va_start( +# 268 "user/mpy/py/vstr.c" + ap +# 268 "user/mpy/py/vstr.c" 3 4 + , +# 268 "user/mpy/py/vstr.c" + fmt +# 268 "user/mpy/py/vstr.c" 3 4 + ) +# 268 "user/mpy/py/vstr.c" + ; + vstr_vprintf(vstr, fmt, ap); + +# 270 "user/mpy/py/vstr.c" 3 4 + __builtin_va_end( +# 270 "user/mpy/py/vstr.c" + ap +# 270 "user/mpy/py/vstr.c" 3 4 + ) +# 270 "user/mpy/py/vstr.c" + ; +} + +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap) { + mp_print_t print = {vstr, (mp_print_strn_t)vstr_add_strn}; + mp_vprintf(&print, fmt, ap); +} +# 1 "user/mpy/py/mpprint.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/mpprint.c" +# 27 "user/mpy/py/mpprint.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/mpprint.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 29 "user/mpy/py/mpprint.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpprint.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 35 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 31 "user/mpy/py/mpprint.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 32 "user/mpy/py/mpprint.c" 2 + +# 1 "user/mpy/py/mphal.h" 1 +# 29 "user/mpy/py/mphal.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/mphal.h" 2 + + + + +# 1 "user/mpy/mphalport.h" 1 +# 35 "user/mpy/py/mphal.h" 2 + + + +int mp_hal_stdin_rx_chr(void); + + + + + + + +void mp_hal_stdout_tx_strn(const char *str, size_t len); + + + + + + + +void mp_hal_delay_ms(mp_uint_t ms); + + + +void mp_hal_delay_us(mp_uint_t us); + + + + + + + +mp_uint_t mp_hal_ticks_us(void); + + + +mp_uint_t mp_hal_ticks_cpu(void); +# 80 "user/mpy/py/mphal.h" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 29 "user/mpy/extmod/virtpin.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/extmod/virtpin.h" 2 + + + + + + + +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 81 "user/mpy/py/mphal.h" 2 +# 34 "user/mpy/py/mpprint.c" 2 + + +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 + + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 37 "user/mpy/py/mpprint.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 38 "user/mpy/py/mpprint.c" 2 + + + + + +static const char pad_spaces[] = " "; +static const char pad_zeroes[] = "0000000000000000"; + +static void plat_print_strn(void *env, const char *str, size_t len) { + (void)env; + printk(str);; +} + +const mp_print_t mp_plat_print = { +# 51 "user/mpy/py/mpprint.c" 3 4 + ((void *)0) +# 51 "user/mpy/py/mpprint.c" + , plat_print_strn}; + +int mp_print_str(const mp_print_t *print, const char *str) { + size_t len = strlen(str); + if (len) { + print->print_strn(print->data, str, len); + } + return len; +} + +int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) { + int left_pad = 0; + int right_pad = 0; + int pad = width - len; + int pad_size; + int total_chars_printed = 0; + const char *pad_chars; + + if (!fill || fill == ' ') { + pad_chars = pad_spaces; + pad_size = sizeof(pad_spaces) - 1; + } else if (fill == '0') { + pad_chars = pad_zeroes; + pad_size = sizeof(pad_zeroes) - 1; + } else { + + + pad_chars = &fill; + pad_size = 1; + } + + if (flags & (0x080)) { + left_pad = pad / 2; + right_pad = pad - left_pad; + } else if (flags & (0x001)) { + right_pad = pad; + } else { + left_pad = pad; + } + + if (left_pad > 0) { + total_chars_printed += left_pad; + while (left_pad > 0) { + int p = left_pad; + if (p > pad_size) { + p = pad_size; + } + print->print_strn(print->data, pad_chars, p); + left_pad -= p; + } + } + if (len) { + print->print_strn(print->data, str, len); + total_chars_printed += len; + } + if (right_pad > 0) { + total_chars_printed += right_pad; + while (right_pad > 0) { + int p = right_pad; + if (p > pad_size) { + p = pad_size; + } + print->print_strn(print->data, pad_chars, p); + right_pad -= p; + } + } + return total_chars_printed; +} +# 130 "user/mpy/py/mpprint.c" +static int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) { + char sign = 0; + if (sgn) { + if ((mp_int_t)x < 0) { + sign = '-'; + x = -x; + } else if (flags & (0x002)) { + sign = '+'; + } else if (flags & (0x004)) { + sign = ' '; + } + } + + char buf[(sizeof(mp_int_t) * 4)]; + char *b = buf + (sizeof(mp_int_t) * 4); + + if (x == 0) { + *(--b) = '0'; + } else { + do { + int c = x % base; + x /= base; + if (c >= 10) { + c += base_char - 10; + } else { + c += '0'; + } + *(--b) = c; + } while (b > buf && x != 0); + } +# 175 "user/mpy/py/mpprint.c" + int len = 0; + if (flags & (0x040)) { + if (sign) { + len += mp_print_strn(print, &sign, 1, flags, fill, 1); + width--; + } + + + + + + + + } else { + + + + + + + if (sign && b > buf) { + *(--b) = sign; + } + } + + len += mp_print_strn(print, b, buf + (sizeof(mp_int_t) * 4) - b, flags, fill, width); + return len; +} + +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) { + + + + +# 208 "user/mpy/py/mpprint.c" 3 + (( +# 208 "user/mpy/py/mpprint.c" + base == 2 || base == 8 || base == 10 || base == 16 +# 208 "user/mpy/py/mpprint.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/mpprint.c", 208, __func__, +# 208 "user/mpy/py/mpprint.c" + "base == 2 || base == 8 || base == 10 || base == 16" +# 208 "user/mpy/py/mpprint.c" 3 + )) +# 208 "user/mpy/py/mpprint.c" + ; + + if (!(MP_OBJ_IS_SMALL_INT(x) || (MP_OBJ_IS_OBJ(x) && (((mp_obj_base_t*)((void*)x))->type == (&mp_type_int))))) { + + + x = ((mp_obj_t)((((mp_uint_t)(mp_obj_get_int(x))) << 1) | 1)); + } + + if ((flags & ((0x001) | (0x080))) == 0 && fill == '0') { + if (prec > width) { + width = prec; + } + prec = 0; + } + char prefix_buf[4]; + char *prefix = prefix_buf; + + if (mp_obj_int_sign(x) >= 0) { + if (flags & (0x002)) { + *prefix++ = '+'; + } else if (flags & (0x004)) { + *prefix++ = ' '; + } + } + + if (flags & (0x010)) { + if (base == 2) { + *prefix++ = '0'; + *prefix++ = base_char + 'b' - 'a'; + } else if (base == 8) { + *prefix++ = '0'; + if (flags & (0x200)) { + *prefix++ = base_char + 'o' - 'a'; + } + } else if (base == 16) { + *prefix++ = '0'; + *prefix++ = base_char + 'x' - 'a'; + } + } + *prefix = '\0'; + int prefix_len = prefix - prefix_buf; + prefix = prefix_buf; + + char comma = '\0'; + if (flags & (0x020)) { + comma = ','; + } + + + + char stack_buf[sizeof(mp_int_t) * 4]; + char *buf = stack_buf; + size_t buf_size = sizeof(stack_buf); + size_t fmt_size = 0; + char *str; + + if (prec > 1) { + flags |= (0x040); + } + char sign = '\0'; + if (flags & (0x040)) { + + + str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, + x, base, +# 272 "user/mpy/py/mpprint.c" 3 4 + ((void *)0) +# 272 "user/mpy/py/mpprint.c" + , base_char, comma); + if (*str == '-') { + sign = *str++; + fmt_size--; + } + } else { + str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, + x, base, prefix, base_char, comma); + } + + int spaces_before = 0; + int spaces_after = 0; + + if (prec > 1) { + + + + + int prec_width = fmt_size; + if (prec_width < prec) { + prec_width = prec; + } + if (flags & (0x040)) { + if (sign) { + prec_width++; + } + prec_width += prefix_len; + } + if (prec_width < width) { + if (flags & (0x001)) { + spaces_after = width - prec_width; + } else { + spaces_before = width - prec_width; + } + } + fill = '0'; + flags &= ~(0x001); + } + + int len = 0; + if (spaces_before) { + len += mp_print_strn(print, "", 0, 0, ' ', spaces_before); + } + if (flags & (0x040)) { + + if (sign) { + len += mp_print_strn(print, &sign, 1, 0, 0, 1); + width--; + } + if (prefix_len) { + len += mp_print_strn(print, prefix, prefix_len, 0, 0, 1); + width -= prefix_len; + } + } + if (prec > 1) { + width = prec; + } + + len += mp_print_strn(print, str, fmt_size, flags, fill, width); + + if (spaces_after) { + len += mp_print_strn(print, "", 0, 0, ' ', spaces_after); + } + + if (buf != stack_buf) { + ((void)(buf_size), m_free(buf)); + } + return len; +} +# 380 "user/mpy/py/mpprint.c" +int mp_printf(const mp_print_t *print, const char *fmt, ...) { + va_list ap; + +# 382 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_start( +# 382 "user/mpy/py/mpprint.c" + ap +# 382 "user/mpy/py/mpprint.c" 3 4 + , +# 382 "user/mpy/py/mpprint.c" + fmt +# 382 "user/mpy/py/mpprint.c" 3 4 + ) +# 382 "user/mpy/py/mpprint.c" + ; + int ret = mp_vprintf(print, fmt, ap); + +# 384 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_end( +# 384 "user/mpy/py/mpprint.c" + ap +# 384 "user/mpy/py/mpprint.c" 3 4 + ) +# 384 "user/mpy/py/mpprint.c" + ; + return ret; +} + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) { + int chrs = 0; + for (;;) { + { + const char *f = fmt; + while (*f != '\0' && *f != '%') { + ++f; + } + if (f > fmt) { + print->print_strn(print->data, fmt, f - fmt); + chrs += f - fmt; + fmt = f; + } + } + + if (*fmt == '\0') { + break; + } + + + ++fmt; + + + int flags = 0; + char fill = ' '; + while (*fmt != '\0') { + if (*fmt == '-') flags |= (0x001); + else if (*fmt == '+') flags |= (0x002); + else if (*fmt == ' ') flags |= (0x004); + else if (*fmt == '!') flags |= (0x008); + else if (*fmt == '0') { + flags |= (0x040); + fill = '0'; + } else break; + ++fmt; + } + + + int width = 0; + for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { + width = width * 10 + *fmt - '0'; + } + + + int prec = -1; + if (*fmt == '.') { + ++fmt; + if (*fmt == '*') { + ++fmt; + prec = +# 437 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 437 "user/mpy/py/mpprint.c" + args +# 437 "user/mpy/py/mpprint.c" 3 4 + , +# 437 "user/mpy/py/mpprint.c" + int +# 437 "user/mpy/py/mpprint.c" 3 4 + ) +# 437 "user/mpy/py/mpprint.c" + ; + } else { + prec = 0; + for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { + prec = prec * 10 + *fmt - '0'; + } + } + if (prec < 0) { + prec = 0; + } + } + + + + if (*fmt == 'l') { + ++fmt; + + } + + if (*fmt == '\0') { + break; + } + + switch (*fmt) { + case 'b': + if ( +# 462 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 462 "user/mpy/py/mpprint.c" + args +# 462 "user/mpy/py/mpprint.c" 3 4 + , +# 462 "user/mpy/py/mpprint.c" + int +# 462 "user/mpy/py/mpprint.c" 3 4 + ) +# 462 "user/mpy/py/mpprint.c" + ) { + chrs += mp_print_strn(print, "true", 4, flags, fill, width); + } else { + chrs += mp_print_strn(print, "false", 5, flags, fill, width); + } + break; + case 'c': + { + char str = +# 470 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 470 "user/mpy/py/mpprint.c" + args +# 470 "user/mpy/py/mpprint.c" 3 4 + , +# 470 "user/mpy/py/mpprint.c" + int +# 470 "user/mpy/py/mpprint.c" 3 4 + ) +# 470 "user/mpy/py/mpprint.c" + ; + chrs += mp_print_strn(print, &str, 1, flags, fill, width); + break; + } + case 'q': + { + qstr qst = +# 476 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 476 "user/mpy/py/mpprint.c" + args +# 476 "user/mpy/py/mpprint.c" 3 4 + , +# 476 "user/mpy/py/mpprint.c" + qstr +# 476 "user/mpy/py/mpprint.c" 3 4 + ) +# 476 "user/mpy/py/mpprint.c" + ; + size_t len; + const char *str = (const char*)qstr_data(qst, &len); + if (prec < 0) { + prec = len; + } + chrs += mp_print_strn(print, str, prec, flags, fill, width); + break; + } + case 's': + { + const char *str = +# 487 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 487 "user/mpy/py/mpprint.c" + args +# 487 "user/mpy/py/mpprint.c" 3 4 + , +# 487 "user/mpy/py/mpprint.c" + const char* +# 487 "user/mpy/py/mpprint.c" 3 4 + ) +# 487 "user/mpy/py/mpprint.c" + ; + if (str) { + if (prec < 0) { + prec = strlen(str); + } + chrs += mp_print_strn(print, str, prec, flags, fill, width); + } else { + chrs += mp_print_strn(print, "(null)", 6, flags, fill, width); + } + break; + } + case 'u': + chrs += mp_print_int(print, +# 499 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 499 "user/mpy/py/mpprint.c" + args +# 499 "user/mpy/py/mpprint.c" 3 4 + , +# 499 "user/mpy/py/mpprint.c" + unsigned int +# 499 "user/mpy/py/mpprint.c" 3 4 + ) +# 499 "user/mpy/py/mpprint.c" + , 0, 10, 'a', flags, fill, width); + break; + case 'd': + chrs += mp_print_int(print, +# 502 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 502 "user/mpy/py/mpprint.c" + args +# 502 "user/mpy/py/mpprint.c" 3 4 + , +# 502 "user/mpy/py/mpprint.c" + int +# 502 "user/mpy/py/mpprint.c" 3 4 + ) +# 502 "user/mpy/py/mpprint.c" + , 1, 10, 'a', flags, fill, width); + break; + case 'x': + chrs += mp_print_int(print, +# 505 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 505 "user/mpy/py/mpprint.c" + args +# 505 "user/mpy/py/mpprint.c" 3 4 + , +# 505 "user/mpy/py/mpprint.c" + unsigned int +# 505 "user/mpy/py/mpprint.c" 3 4 + ) +# 505 "user/mpy/py/mpprint.c" + , 0, 16, 'a', flags, fill, width); + break; + case 'X': + chrs += mp_print_int(print, +# 508 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 508 "user/mpy/py/mpprint.c" + args +# 508 "user/mpy/py/mpprint.c" 3 4 + , +# 508 "user/mpy/py/mpprint.c" + unsigned int +# 508 "user/mpy/py/mpprint.c" 3 4 + ) +# 508 "user/mpy/py/mpprint.c" + , 0, 16, 'A', flags, fill, width); + break; + case 'p': + case 'P': + chrs += mp_print_int(print, +# 512 "user/mpy/py/mpprint.c" 3 4 + __builtin_va_arg( +# 512 "user/mpy/py/mpprint.c" + args +# 512 "user/mpy/py/mpprint.c" 3 4 + , +# 512 "user/mpy/py/mpprint.c" + unsigned int +# 512 "user/mpy/py/mpprint.c" 3 4 + ) +# 512 "user/mpy/py/mpprint.c" + , 0, 16, 'a', flags, fill, width); + break; +# 545 "user/mpy/py/mpprint.c" + default: + + +# 547 "user/mpy/py/mpprint.c" 3 + (( +# 547 "user/mpy/py/mpprint.c" + *fmt == '%' || !"unsupported fmt char" +# 547 "user/mpy/py/mpprint.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/mpprint.c", 547, __func__, +# 547 "user/mpy/py/mpprint.c" + "*fmt == '%' || !\"unsupported fmt char\"" +# 547 "user/mpy/py/mpprint.c" 3 + )) +# 547 "user/mpy/py/mpprint.c" + ; + print->print_strn(print->data, fmt, 1); + chrs += 1; + break; + } + ++fmt; + } + return chrs; +} +# 1 "user/mpy/py/unicode.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/unicode.c" +# 27 "user/mpy/py/unicode.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/unicode.c" 2 + +# 1 "user/mpy/py/unicode.h" 1 +# 29 "user/mpy/py/unicode.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/unicode.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/unicode.h" 2 + +mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); +# 30 "user/mpy/py/unicode.c" 2 +# 51 "user/mpy/py/unicode.c" +static const uint8_t attr[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, ((0x02) | (0x01)), ((0x02) | (0x01)), ((0x02) | (0x01)), ((0x02) | (0x01)), ((0x02) | (0x01)), 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + ((0x02) | (0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), + ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), + ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), + ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), + ((0x01)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01)), + ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), + ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), + ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), + ((0x01)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01)), + ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), + ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), + ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), 0 +}; + + +unichar utf8_get_char(const byte *s) { +# 84 "user/mpy/py/unicode.c" + return *s; + +} + + +const byte *utf8_next_char(const byte *s) { + + + + + + + + return s + 1; + +} + +mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr) { + mp_uint_t i = 0; + while (ptr > s) { + if (!(((*--ptr) & 0xC0) == 0x80)) { + i++; + } + } + + return i; +} + + +mp_uint_t unichar_charlen(const char *str, mp_uint_t len) { +# 123 "user/mpy/py/unicode.c" + return len; + +} + + + +# 128 "user/mpy/py/unicode.c" 3 4 +_Bool +# 128 "user/mpy/py/unicode.c" + unichar_isspace(unichar c) { + return c < 128 && (attr[c] & (0x02)) != 0; +} + + +# 132 "user/mpy/py/unicode.c" 3 4 +_Bool +# 132 "user/mpy/py/unicode.c" + unichar_isalpha(unichar c) { + return c < 128 && (attr[c] & (0x08)) != 0; +} + + + + + + + + +# 142 "user/mpy/py/unicode.c" 3 4 +_Bool +# 142 "user/mpy/py/unicode.c" + unichar_isdigit(unichar c) { + return c < 128 && (attr[c] & (0x04)) != 0; +} + + +# 146 "user/mpy/py/unicode.c" 3 4 +_Bool +# 146 "user/mpy/py/unicode.c" + unichar_isxdigit(unichar c) { + return c < 128 && (attr[c] & (0x40)) != 0; +} + + +# 150 "user/mpy/py/unicode.c" 3 4 +_Bool +# 150 "user/mpy/py/unicode.c" + unichar_isident(unichar c) { + return c < 128 && ((attr[c] & ((0x08) | (0x04))) != 0 || c == '_'); +} + + +# 154 "user/mpy/py/unicode.c" 3 4 +_Bool +# 154 "user/mpy/py/unicode.c" + unichar_isupper(unichar c) { + return c < 128 && (attr[c] & (0x10)) != 0; +} + + +# 158 "user/mpy/py/unicode.c" 3 4 +_Bool +# 158 "user/mpy/py/unicode.c" + unichar_islower(unichar c) { + return c < 128 && (attr[c] & (0x20)) != 0; +} + +unichar unichar_tolower(unichar c) { + if (unichar_isupper(c)) { + return c + 0x20; + } + return c; +} + +unichar unichar_toupper(unichar c) { + if (unichar_islower(c)) { + return c - 0x20; + } + return c; +} + +mp_uint_t unichar_xdigit_value(unichar c) { + + mp_uint_t n = c - '0'; + if (n > 9) { + n &= ~('a' - 'A'); + n -= ('A' - ('9' + 1)); + } + return n; +} +# 1 "user/mpy/py/mpz.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/mpz.c" +# 27 "user/mpy/py/mpz.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/mpz.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/mpz.c" 2 + +# 1 "user/mpy/py/mpz.h" 1 +# 29 "user/mpy/py/mpz.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpz.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpz.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 33 "user/mpy/py/mpz.h" 2 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 31 "user/mpy/py/mpz.c" 2 +# 1 "user/mpy/py/reader.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/reader.c" +# 27 "user/mpy/py/reader.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/reader.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/reader.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/reader.c" 2 +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 32 "user/mpy/py/reader.c" 2 +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" + +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 33 "user/mpy/py/reader.c" 2 + +typedef struct _mp_reader_mem_t { + size_t free_len; + const byte *beg; + const byte *cur; + const byte *end; +} mp_reader_mem_t; + +static mp_uint_t mp_reader_mem_readbyte(void *data) { + mp_reader_mem_t *reader = (mp_reader_mem_t*)data; + if (reader->cur < reader->end) { + return *reader->cur++; + } else { + return ((mp_uint_t)(-1)); + } +} + +static void mp_reader_mem_close(void *data) { + mp_reader_mem_t *reader = (mp_reader_mem_t*)data; + if (reader->free_len > 0) { + ((void)(reader->free_len), m_free((char*)reader->beg)); + } + (((void)(1), m_free(reader))); +} + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len) { + mp_reader_mem_t *rm = (((mp_reader_mem_t*)(m_malloc(sizeof(mp_reader_mem_t) * (1))))); + rm->free_len = free_len; + rm->beg = buf; + rm->cur = buf; + rm->end = buf + len; + reader->data = rm; + reader->readbyte = mp_reader_mem_readbyte; + reader->close = mp_reader_mem_close; +} +# 1 "user/mpy/py/lexer.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/lexer.c" +# 27 "user/mpy/py/lexer.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/lexer.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/lexer.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/lexer.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 32 "user/mpy/py/lexer.c" 2 +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 33 "user/mpy/py/lexer.c" 2 +# 1 "user/mpy/py/lexer.h" 1 +# 41 "user/mpy/py/lexer.h" +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 34 "user/mpy/py/lexer.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 35 "user/mpy/py/lexer.c" 2 +# 46 "user/mpy/py/lexer.c" +static +# 46 "user/mpy/py/lexer.c" 3 4 + _Bool +# 46 "user/mpy/py/lexer.c" + is_end(mp_lexer_t *lex) { + return lex->chr0 == ((unichar)((mp_uint_t)(-1))); +} + +static +# 50 "user/mpy/py/lexer.c" 3 4 + _Bool +# 50 "user/mpy/py/lexer.c" + is_physical_newline(mp_lexer_t *lex) { + return lex->chr0 == '\n'; +} + +static +# 54 "user/mpy/py/lexer.c" 3 4 + _Bool +# 54 "user/mpy/py/lexer.c" + is_char(mp_lexer_t *lex, byte c) { + return lex->chr0 == c; +} + +static +# 58 "user/mpy/py/lexer.c" 3 4 + _Bool +# 58 "user/mpy/py/lexer.c" + is_char_or(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr0 == c1 || lex->chr0 == c2; +} + +static +# 62 "user/mpy/py/lexer.c" 3 4 + _Bool +# 62 "user/mpy/py/lexer.c" + is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) { + return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3; +} + +static +# 66 "user/mpy/py/lexer.c" 3 4 + _Bool +# 66 "user/mpy/py/lexer.c" + is_char_following(mp_lexer_t *lex, byte c) { + return lex->chr1 == c; +} + +static +# 70 "user/mpy/py/lexer.c" 3 4 + _Bool +# 70 "user/mpy/py/lexer.c" + is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr1 == c1 || lex->chr1 == c2; +} + +static +# 74 "user/mpy/py/lexer.c" 3 4 + _Bool +# 74 "user/mpy/py/lexer.c" + is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr2 == c1 || lex->chr2 == c2; +} + +static +# 78 "user/mpy/py/lexer.c" 3 4 + _Bool +# 78 "user/mpy/py/lexer.c" + is_char_and(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr0 == c1 && lex->chr1 == c2; +} + +static +# 82 "user/mpy/py/lexer.c" 3 4 + _Bool +# 82 "user/mpy/py/lexer.c" + is_whitespace(mp_lexer_t *lex) { + return unichar_isspace(lex->chr0); +} + +static +# 86 "user/mpy/py/lexer.c" 3 4 + _Bool +# 86 "user/mpy/py/lexer.c" + is_letter(mp_lexer_t *lex) { + return unichar_isalpha(lex->chr0); +} + +static +# 90 "user/mpy/py/lexer.c" 3 4 + _Bool +# 90 "user/mpy/py/lexer.c" + is_digit(mp_lexer_t *lex) { + return unichar_isdigit(lex->chr0); +} + +static +# 94 "user/mpy/py/lexer.c" 3 4 + _Bool +# 94 "user/mpy/py/lexer.c" + is_following_digit(mp_lexer_t *lex) { + return unichar_isdigit(lex->chr1); +} + +static +# 98 "user/mpy/py/lexer.c" 3 4 + _Bool +# 98 "user/mpy/py/lexer.c" + is_following_base_char(mp_lexer_t *lex) { + const unichar chr1 = lex->chr1 | 0x20; + return chr1 == 'b' || chr1 == 'o' || chr1 == 'x'; +} + +static +# 103 "user/mpy/py/lexer.c" 3 4 + _Bool +# 103 "user/mpy/py/lexer.c" + is_following_odigit(mp_lexer_t *lex) { + return lex->chr1 >= '0' && lex->chr1 <= '7'; +} + +static +# 107 "user/mpy/py/lexer.c" 3 4 + _Bool +# 107 "user/mpy/py/lexer.c" + is_string_or_bytes(mp_lexer_t *lex) { + return is_char_or(lex, '\'', '\"') + || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"')) + || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r')) + && is_char_following_following_or(lex, '\'', '\"')); +} + + +static +# 115 "user/mpy/py/lexer.c" 3 4 + _Bool +# 115 "user/mpy/py/lexer.c" + is_head_of_identifier(mp_lexer_t *lex) { + return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80; +} + +static +# 119 "user/mpy/py/lexer.c" 3 4 + _Bool +# 119 "user/mpy/py/lexer.c" + is_tail_of_identifier(mp_lexer_t *lex) { + return is_head_of_identifier(lex) || is_digit(lex); +} + +static void next_char(mp_lexer_t *lex) { + if (lex->chr0 == '\n') { + + ++lex->line; + lex->column = 1; + } else if (lex->chr0 == '\t') { + + lex->column = (((lex->column - 1 + (8)) / (8)) * (8)) + 1; + } else { + + ++lex->column; + } + + lex->chr0 = lex->chr1; + lex->chr1 = lex->chr2; + lex->chr2 = lex->reader.readbyte(lex->reader.data); + + if (lex->chr1 == '\r') { + + lex->chr1 = '\n'; + if (lex->chr2 == '\n') { + + lex->chr2 = lex->reader.readbyte(lex->reader.data); + } + } + + + if (lex->chr2 == ((unichar)((mp_uint_t)(-1))) && lex->chr1 != ((unichar)((mp_uint_t)(-1))) && lex->chr1 != '\n') { + lex->chr2 = '\n'; + } +} + +static void indent_push(mp_lexer_t *lex, size_t indent) { + if (lex->num_indent_level >= lex->alloc_indent_level) { + lex->indent_level = ((uint16_t*)(m_realloc((lex->indent_level), sizeof(uint16_t) * (lex->alloc_indent_level + (8))))); + lex->alloc_indent_level += (8); + } + lex->indent_level[lex->num_indent_level++] = indent; +} + +static size_t indent_top(mp_lexer_t *lex) { + return lex->indent_level[lex->num_indent_level - 1]; +} + +static void indent_pop(mp_lexer_t *lex) { + lex->num_indent_level -= 1; +} + + + + + + + +static const char *const tok_enc = + "()[]{},:;@~" + "e=c>e=" + "*e=c*e=" + "+e=" + "-e=e>" + "&e=" + "|e=" + "/e=c/e=" + "%e=" + "^e=" + "=e=" + "!."; + + +static const uint8_t tok_enc_kind[] = { + MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, MP_TOKEN_DEL_COLON, MP_TOKEN_DEL_SEMICOLON, MP_TOKEN_DEL_AT, MP_TOKEN_OP_TILDE, + + MP_TOKEN_OP_LESS, MP_TOKEN_OP_LESS_EQUAL, MP_TOKEN_OP_DBL_LESS, MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_OP_MORE, MP_TOKEN_OP_MORE_EQUAL, MP_TOKEN_OP_DBL_MORE, MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_OP_STAR, MP_TOKEN_DEL_STAR_EQUAL, MP_TOKEN_OP_DBL_STAR, MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_OP_PLUS, MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_OP_MINUS, MP_TOKEN_DEL_MINUS_EQUAL, MP_TOKEN_DEL_MINUS_MORE, + MP_TOKEN_OP_AMPERSAND, MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_OP_PIPE, MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_OP_SLASH, MP_TOKEN_DEL_SLASH_EQUAL, MP_TOKEN_OP_DBL_SLASH, MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_OP_PERCENT, MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_OP_CARET, MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_EQUAL, MP_TOKEN_OP_DBL_EQUAL, +}; + + + +static const char *const tok_kw[] = { + "False", + "None", + "True", + "__debug__", + "and", + "as", + "assert", + + + + + "break", + "class", + "continue", + "def", + "del", + "elif", + "else", + "except", + "finally", + "for", + "from", + "global", + "if", + "import", + "in", + "is", + "lambda", + "nonlocal", + "not", + "or", + "pass", + "raise", + "return", + "try", + "while", + "with", + "yield", +}; + + + + +static +# 258 "user/mpy/py/lexer.c" 3 4 + _Bool +# 258 "user/mpy/py/lexer.c" + get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) { + mp_uint_t num = 0; + while (num_digits-- != 0) { + next_char(lex); + unichar c = ((lex)->chr0); + if (!unichar_isxdigit(c)) { + return +# 264 "user/mpy/py/lexer.c" 3 4 + 0 +# 264 "user/mpy/py/lexer.c" + ; + } + num = (num << 4) + unichar_xdigit_value(c); + } + *result = num; + return +# 269 "user/mpy/py/lexer.c" 3 4 + 1 +# 269 "user/mpy/py/lexer.c" + ; +} + +static void parse_string_literal(mp_lexer_t *lex, +# 272 "user/mpy/py/lexer.c" 3 4 + _Bool +# 272 "user/mpy/py/lexer.c" + is_raw) { + + char quote_char = '\''; + if (is_char(lex, '\"')) { + quote_char = '\"'; + } + next_char(lex); + + + size_t num_quotes; + if (is_char_and(lex, quote_char, quote_char)) { + + next_char(lex); + next_char(lex); + num_quotes = 3; + } else { + + num_quotes = 1; + } + + size_t n_closing = 0; + while (!is_end(lex) && (num_quotes > 1 || !is_char(lex, '\n')) && n_closing < num_quotes) { + if (is_char(lex, quote_char)) { + n_closing += 1; + vstr_add_char(&lex->vstr, ((lex)->chr0)); + } else { + n_closing = 0; + if (is_char(lex, '\\')) { + next_char(lex); + unichar c = ((lex)->chr0); + if (is_raw) { + + vstr_add_char(&lex->vstr, '\\'); + } else { + switch (c) { + + + case '\n': c = ((unichar)((mp_uint_t)(-1))); break; + case '\\': break; + case '\'': break; + case '"': break; + case 'a': c = 0x07; break; + case 'b': c = 0x08; break; + case 't': c = 0x09; break; + case 'n': c = 0x0a; break; + case 'v': c = 0x0b; break; + case 'f': c = 0x0c; break; + case 'r': c = 0x0d; break; + case 'u': + case 'U': + if (lex->tok_kind == MP_TOKEN_BYTES) { + + vstr_add_char(&lex->vstr, '\\'); + break; + } + + case 'x': + { + mp_uint_t num = 0; + if (!get_hex(lex, (c == 'x' ? 2 : c == 'u' ? 4 : 8), &num)) { + + lex->tok_kind = MP_TOKEN_INVALID; + } + c = num; + break; + } + case 'N': + + + + + + mp_raise_NotImplementedError("unicode name escapes"); + break; + default: + if (c >= '0' && c <= '7') { + + size_t digits = 3; + mp_uint_t num = c - '0'; + while (is_following_odigit(lex) && --digits != 0) { + next_char(lex); + num = num * 8 + (((lex)->chr0) - '0'); + } + c = num; + } else { + + vstr_add_char(&lex->vstr, '\\'); + } + break; + } + } + if (c != ((unichar)((mp_uint_t)(-1)))) { + if ((0)) { + if (c < 0x110000 && lex->tok_kind == MP_TOKEN_STRING) { + vstr_add_char(&lex->vstr, c); + } else if (c < 0x100 && lex->tok_kind == MP_TOKEN_BYTES) { + vstr_add_byte(&lex->vstr, c); + } else { + + + lex->tok_kind = MP_TOKEN_INVALID; + } + } else { + + if (c < 0x100) { + vstr_add_byte(&lex->vstr, c); + } else { + + + lex->tok_kind = MP_TOKEN_INVALID; + } + } + } + } else { + + + vstr_add_byte(&lex->vstr, ((lex)->chr0)); + } + } + next_char(lex); + } + + + if (n_closing < num_quotes) { + lex->tok_kind = MP_TOKEN_LONELY_STRING_OPEN; + } + + + vstr_cut_tail_bytes(&lex->vstr, n_closing); +} + +static +# 403 "user/mpy/py/lexer.c" 3 4 + _Bool +# 403 "user/mpy/py/lexer.c" + skip_whitespace(mp_lexer_t *lex, +# 403 "user/mpy/py/lexer.c" 3 4 + _Bool +# 403 "user/mpy/py/lexer.c" + stop_at_newline) { + +# 404 "user/mpy/py/lexer.c" 3 4 + _Bool +# 404 "user/mpy/py/lexer.c" + had_physical_newline = +# 404 "user/mpy/py/lexer.c" 3 4 + 0 +# 404 "user/mpy/py/lexer.c" + ; + while (!is_end(lex)) { + if (is_physical_newline(lex)) { + if (stop_at_newline && lex->nested_bracket_level == 0) { + break; + } + had_physical_newline = +# 410 "user/mpy/py/lexer.c" 3 4 + 1 +# 410 "user/mpy/py/lexer.c" + ; + next_char(lex); + } else if (is_whitespace(lex)) { + next_char(lex); + } else if (is_char(lex, '#')) { + next_char(lex); + while (!is_end(lex) && !is_physical_newline(lex)) { + next_char(lex); + } + + } else if (is_char_and(lex, '\\', '\n')) { + + next_char(lex); + next_char(lex); + } else { + break; + } + } + return had_physical_newline; +} + +void mp_lexer_to_next(mp_lexer_t *lex) { + + vstr_reset(&lex->vstr); + + + +# 436 "user/mpy/py/lexer.c" 3 4 + _Bool +# 436 "user/mpy/py/lexer.c" + had_physical_newline = skip_whitespace(lex, +# 436 "user/mpy/py/lexer.c" 3 4 + 0 +# 436 "user/mpy/py/lexer.c" + ); + + + lex->tok_line = lex->line; + lex->tok_column = lex->column; + + if (lex->emit_dent < 0) { + lex->tok_kind = MP_TOKEN_DEDENT; + lex->emit_dent += 1; + + } else if (lex->emit_dent > 0) { + lex->tok_kind = MP_TOKEN_INDENT; + lex->emit_dent -= 1; + + } else if (had_physical_newline && lex->nested_bracket_level == 0) { + lex->tok_kind = MP_TOKEN_NEWLINE; + + size_t num_spaces = lex->column - 1; + if (num_spaces == indent_top(lex)) { + } else if (num_spaces > indent_top(lex)) { + indent_push(lex, num_spaces); + lex->emit_dent += 1; + } else { + while (num_spaces < indent_top(lex)) { + indent_pop(lex); + lex->emit_dent -= 1; + } + if (num_spaces != indent_top(lex)) { + lex->tok_kind = MP_TOKEN_DEDENT_MISMATCH; + } + } + + } else if (is_end(lex)) { + lex->tok_kind = MP_TOKEN_END; + + } else if (is_string_or_bytes(lex)) { +# 481 "user/mpy/py/lexer.c" + lex->tok_kind = MP_TOKEN_END; + + + do { + + +# 486 "user/mpy/py/lexer.c" 3 4 + _Bool +# 486 "user/mpy/py/lexer.c" + is_raw = +# 486 "user/mpy/py/lexer.c" 3 4 + 0 +# 486 "user/mpy/py/lexer.c" + ; + mp_token_kind_t kind = MP_TOKEN_STRING; + int n_char = 0; + if (is_char(lex, 'u')) { + n_char = 1; + } else if (is_char(lex, 'b')) { + kind = MP_TOKEN_BYTES; + n_char = 1; + if (is_char_following(lex, 'r')) { + is_raw = +# 495 "user/mpy/py/lexer.c" 3 4 + 1 +# 495 "user/mpy/py/lexer.c" + ; + n_char = 2; + } + } else if (is_char(lex, 'r')) { + is_raw = +# 499 "user/mpy/py/lexer.c" 3 4 + 1 +# 499 "user/mpy/py/lexer.c" + ; + n_char = 1; + if (is_char_following(lex, 'b')) { + kind = MP_TOKEN_BYTES; + n_char = 2; + } + } + + + if (lex->tok_kind == MP_TOKEN_END) { + lex->tok_kind = kind; + } else if (lex->tok_kind != kind) { + + break; + } + + + if (n_char != 0) { + next_char(lex); + if (n_char == 2) { + next_char(lex); + } + } + + + parse_string_literal(lex, is_raw); + + + skip_whitespace(lex, +# 527 "user/mpy/py/lexer.c" 3 4 + 1 +# 527 "user/mpy/py/lexer.c" + ); + + } while (is_string_or_bytes(lex)); + + } else if (is_head_of_identifier(lex)) { + lex->tok_kind = MP_TOKEN_NAME; + + + vstr_add_byte(&lex->vstr, ((lex)->chr0)); + next_char(lex); + + + while (!is_end(lex) && is_tail_of_identifier(lex)) { + vstr_add_byte(&lex->vstr, ((lex)->chr0)); + next_char(lex); + } + + + + + + const char *s = vstr_null_terminated_str(&lex->vstr); + for (size_t i = 0; i < (sizeof(tok_kw) / sizeof((tok_kw)[0])); i++) { + int cmp = strcmp(s, tok_kw[i]); + if (cmp == 0) { + lex->tok_kind = MP_TOKEN_KW_FALSE + i; + if (lex->tok_kind == MP_TOKEN_KW___DEBUG__) { + lex->tok_kind = ((mp_state_ctx.vm.mp_optimise_value) == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE); + } + break; + } else if (cmp < 0) { + + break; + } + } + + } else if (is_digit(lex) || (is_char(lex, '.') && is_following_digit(lex))) { + +# 564 "user/mpy/py/lexer.c" 3 4 + _Bool +# 564 "user/mpy/py/lexer.c" + forced_integer = +# 564 "user/mpy/py/lexer.c" 3 4 + 0 +# 564 "user/mpy/py/lexer.c" + ; + if (is_char(lex, '.')) { + lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; + } else { + lex->tok_kind = MP_TOKEN_INTEGER; + if (is_char(lex, '0') && is_following_base_char(lex)) { + forced_integer = +# 570 "user/mpy/py/lexer.c" 3 4 + 1 +# 570 "user/mpy/py/lexer.c" + ; + } + } + + + vstr_add_char(&lex->vstr, ((lex)->chr0)); + next_char(lex); + + + while (!is_end(lex)) { + if (!forced_integer && is_char_or(lex, 'e', 'E')) { + lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; + vstr_add_char(&lex->vstr, 'e'); + next_char(lex); + if (is_char(lex, '+') || is_char(lex, '-')) { + vstr_add_char(&lex->vstr, ((lex)->chr0)); + next_char(lex); + } + } else if (is_letter(lex) || is_digit(lex) || is_char(lex, '.')) { + if (is_char_or3(lex, '.', 'j', 'J')) { + lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; + } + vstr_add_char(&lex->vstr, ((lex)->chr0)); + next_char(lex); + } else { + break; + } + } + + } else { + + + const char *t = tok_enc; + size_t tok_enc_index = 0; + for (; *t != 0 && !is_char(lex, *t); t += 1) { + if (*t == 'e' || *t == 'c') { + t += 1; + } + tok_enc_index += 1; + } + + next_char(lex); + + if (*t == 0) { + + lex->tok_kind = MP_TOKEN_INVALID; + + } else if (*t == '!') { + + if (is_char(lex, '=')) { + next_char(lex); + lex->tok_kind = MP_TOKEN_OP_NOT_EQUAL; + } else { + lex->tok_kind = MP_TOKEN_INVALID; + } + + } else if (*t == '.') { + + if (is_char_and(lex, '.', '.')) { + next_char(lex); + next_char(lex); + lex->tok_kind = MP_TOKEN_ELLIPSIS; + } else { + lex->tok_kind = MP_TOKEN_DEL_PERIOD; + } + + } else { + + + + t += 1; + size_t t_index = tok_enc_index; + while (*t == 'c' || *t == 'e') { + t_index += 1; + if (is_char(lex, t[1])) { + next_char(lex); + tok_enc_index = t_index; + if (*t == 'e') { + break; + } + } else if (*t == 'c') { + break; + } + t += 2; + } + + + lex->tok_kind = tok_enc_kind[tok_enc_index]; + + + if (lex->tok_kind == MP_TOKEN_DEL_PAREN_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACKET_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACE_OPEN) { + lex->nested_bracket_level += 1; + } else if (lex->tok_kind == MP_TOKEN_DEL_PAREN_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACKET_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACE_CLOSE) { + lex->nested_bracket_level -= 1; + } + } + } +} + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) { + mp_lexer_t *lex = (((mp_lexer_t*)(m_malloc(sizeof(mp_lexer_t) * (1))))); + + lex->source_name = src_name; + lex->reader = reader; + lex->line = 1; + lex->column = (size_t)-2; + lex->emit_dent = 0; + lex->nested_bracket_level = 0; + lex->alloc_indent_level = (10); + lex->num_indent_level = 1; + lex->indent_level = ((uint16_t*)(m_malloc(sizeof(uint16_t) * (lex->alloc_indent_level)))); + vstr_init(&lex->vstr, 32); + + + lex->indent_level[0] = 0; + + + + lex->chr0 = lex->chr1 = lex->chr2 = 0; + next_char(lex); + next_char(lex); + next_char(lex); + + + mp_lexer_to_next(lex); + + + + if (lex->tok_column != 1) { + lex->tok_kind = MP_TOKEN_INDENT; + } + + return lex; +} + +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len) { + mp_reader_t reader; + mp_reader_new_mem(&reader, (const byte*)str, len, free_len); + return mp_lexer_new(src_name, reader); +} +# 731 "user/mpy/py/lexer.c" +void mp_lexer_free(mp_lexer_t *lex) { + if (lex) { + lex->reader.close(lex->reader.data); + vstr_clear(&lex->vstr); + ((void)(lex->alloc_indent_level), m_free(lex->indent_level)); + (((void)(1), m_free(lex))); + } +} +# 1 "user/mpy/py/parse.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/parse.c" +# 27 "user/mpy/py/parse.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 28 "user/mpy/py/parse.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 29 "user/mpy/py/parse.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 30 "user/mpy/py/parse.c" 2 +# 1 "/usr/arm-none-eabi/include/unistd.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/sys/unistd.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/unistd.h" 2 3 + +extern char **environ; + +void _exit (int __status ) __attribute__ ((__noreturn__)); + +int access (const char *__path, int __amode ); +unsigned alarm (unsigned __secs ); +int chdir (const char *__path ); +int chmod (const char *__path, mode_t __mode ); + +int chown (const char *__path, uid_t __owner, gid_t __group ); + + + + +int close (int __fildes ); +# 46 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int dup (int __fildes ); +int dup2 (int __fildes, int __fildes2 ); +# 61 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int execl (const char *__path, const char *, ... ); +int execle (const char *__path, const char *, ... ); +int execlp (const char *__file, const char *, ... ); + + + +int execv (const char *__path, char * const __argv[] ); +int execve (const char *__path, char * const __argv[], char * const __envp[] ); +int execvp (const char *__file, char * const __argv[] ); +# 79 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int fchmod (int __fildes, mode_t __mode ); + +int fchown (int __fildes, uid_t __owner, gid_t __group ); + + + + + + + +pid_t fork (void ); +long fpathconf (int __fd, int __name ); +int fsync (int __fd); +int fdatasync (int __fd); + + + +char * getcwd (char *__buf, size_t __size ); + + + + + + + +gid_t getegid (void ); +uid_t geteuid (void ); +gid_t getgid (void ); + +int getgroups (int __gidsetsize, gid_t __grouplist[] ); + + + +char * getlogin (void ); + + + +char * getpass (const char *__prompt); +int getpagesize (void); + + + +pid_t getpgid (pid_t); +pid_t getpgrp (void ); +pid_t getpid (void ); +pid_t getppid (void ); + + + + +uid_t getuid (void ); +# 140 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int isatty (int __fildes ); + + + + +int lchown (const char *__path, uid_t __owner, gid_t __group ); + +int link (const char *__path1, const char *__path2 ); + + + +int nice (int __nice_value ); + +off_t lseek (int __fildes, off_t __offset, int __whence ); +# 162 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +long pathconf (const char *__path, int __name ); +int pause (void ); + + + +int pipe (int __fildes[2] ); + + + +ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset); +ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t __offset); +int read (int __fd, void *__buf, size_t __nbyte ); + + + + +int rmdir (const char *__path ); + + + +void * sbrk (ptrdiff_t __incr); + + + + + +int setgid (gid_t __gid ); + + + + + + + +int setpgid (pid_t __pid, pid_t __pgid ); +int setpgrp (void ); + + + + +pid_t setsid (void ); + +int setuid (uid_t __uid ); + + + + +unsigned sleep (unsigned int __seconds ); +void swab (const void *restrict, void *restrict, ssize_t); +long sysconf (int __name ); +pid_t tcgetpgrp (int __fildes ); +int tcsetpgrp (int __fildes, pid_t __pgrp_id ); +char * ttyname (int __fildes ); +int ttyname_r (int, char *, size_t); +int unlink (const char *__path ); +int usleep (useconds_t __useconds); +int vhangup (void ); +int write (int __fd, const void *__buf, size_t __nbyte ); + + + + + + +extern char *optarg; +extern int optind, opterr, optopt; +int getopt(int, char * const [], const char *); +extern int optreset; +# 257 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int ftruncate (int __fd, off_t __length); +int truncate (const char *, off_t __length); +# 5 "/usr/arm-none-eabi/include/unistd.h" 2 3 +# 31 "user/mpy/py/parse.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/parse.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 33 "user/mpy/py/parse.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/lexer.h" 1 +# 32 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 35 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 36 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 37 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 34 "user/mpy/py/parsenum.h" +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 38 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 39 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 40 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 + + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 41 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 42 "user/mpy/py/parse.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 43 "user/mpy/py/parse.c" 2 +# 63 "user/mpy/py/parse.c" +typedef struct _rule_t { + byte rule_id; + byte act; + + + + uint16_t arg[]; +} rule_t; + +enum { + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" + +RULE_file_input, +RULE_file_input_2, + + + +# 58 "user/mpy/py/grammar.h" + + +RULE_decorated, + + + + + + +RULE_funcdef, + + + + + + + + + + + + + + + + + + + + + + + + + + +RULE_simple_stmt_2, + + + + + + + + +RULE_expr_stmt, + + + + + +RULE_testlist_star_expr, + + +# 122 "user/mpy/py/grammar.h" +RULE_del_stmt, +RULE_pass_stmt, + +RULE_break_stmt, +RULE_continue_stmt, +RULE_return_stmt, +RULE_yield_stmt, +RULE_raise_stmt, + + +# 145 "user/mpy/py/grammar.h" + +RULE_import_name, +RULE_import_from, + + + + + + + + + + + + +RULE_global_stmt, +RULE_nonlocal_stmt, + +RULE_assert_stmt, + +# 183 "user/mpy/py/grammar.h" + + +RULE_if_stmt, + + +RULE_while_stmt, +RULE_for_stmt, +RULE_try_stmt, + + + + + + + +RULE_with_stmt, + + + + + +RULE_suite_block_stmts, + + + + + + + +RULE_test_if_expr, + + +RULE_lambdef, +RULE_lambdef_nocond, +# 234 "user/mpy/py/grammar.h" +RULE_or_test, +RULE_and_test, + +RULE_not_test_2, +RULE_comparison, + + + + +RULE_star_expr, +RULE_expr, +RULE_xor_expr, +RULE_and_expr, +RULE_shift_expr, + +RULE_arith_expr, + +RULE_term, + + +RULE_factor_2, + +RULE_power, + + + + + + +RULE_atom_expr_normal, + + + + + + + + +RULE_atom_paren, + +RULE_atom_bracket, +RULE_atom_brace, + + + + + + +RULE_trailer_paren, +RULE_trailer_bracket, +RULE_trailer_period, +# 300 "user/mpy/py/grammar.h" +RULE_subscriptlist, + + + + + + + + +RULE_testlist, + + + + + + +RULE_dictorsetmaker_item, + + + + + + + +RULE_classdef, + + + + + + + + + +# 342 "user/mpy/py/grammar.h" + + + + + + + + + + + + + +RULE_yield_expr, + + +# 77 "user/mpy/py/parse.c" 2 + + + RULE_const_object, + + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" +RULE_single_input, + + +RULE_file_input_3, +RULE_eval_input, +RULE_eval_input_2, +# 58 "user/mpy/py/grammar.h" +RULE_decorator, +RULE_decorators, + + + + + +RULE_decorated_body, + + +RULE_funcdefrettype, + +RULE_typedargslist, +RULE_typedargslist_item, +RULE_typedargslist_name, +RULE_typedargslist_star, +RULE_typedargslist_dbl_star, +RULE_typedargslist_colon, +RULE_typedargslist_equal, +RULE_tfpdef, + +RULE_varargslist, +RULE_varargslist_item, +RULE_varargslist_name, +RULE_varargslist_star, +RULE_varargslist_dbl_star, +RULE_varargslist_equal, +RULE_vfpdef, + + + +RULE_stmt, + + + +RULE_simple_stmt, + + + + + + + + +RULE_small_stmt, + +RULE_expr_stmt_2, +RULE_expr_stmt_augassign, +RULE_expr_stmt_assign_list, +RULE_expr_stmt_assign, +RULE_expr_stmt_6, + +RULE_testlist_star_expr_2, +RULE_augassign, +# 122 "user/mpy/py/grammar.h" + + +RULE_flow_stmt, + + + + + +RULE_raise_stmt_arg, +RULE_raise_stmt_from, +# 145 "user/mpy/py/grammar.h" +RULE_import_stmt, + + +RULE_import_from_2, +RULE_import_from_2b, +RULE_import_from_3, +RULE_import_as_names_paren, +RULE_one_or_more_period_or_ellipsis, +RULE_period_or_ellipsis, +RULE_import_as_name, +RULE_dotted_as_name, +RULE_as_name, +RULE_import_as_names, +RULE_dotted_as_names, +RULE_dotted_name, + + +RULE_name_list, + +RULE_assert_stmt_extra, +# 183 "user/mpy/py/grammar.h" +RULE_compound_stmt, + + +RULE_if_stmt_elif_list, +RULE_if_stmt_elif, + + + +RULE_try_stmt_2, +RULE_try_stmt_except_and_more, +RULE_try_stmt_except, +RULE_try_stmt_as_name, +RULE_try_stmt_except_list, +RULE_try_stmt_finally, +RULE_else_stmt, + +RULE_with_stmt_list, +RULE_with_item, +RULE_with_item_as, +RULE_suite, +RULE_suite_block, + + + + + + + +RULE_test, + +RULE_test_if_else, +RULE_test_nocond, + + +# 234 "user/mpy/py/grammar.h" + + +RULE_not_test, + + +RULE_comp_op, +RULE_comp_op_not_in, +RULE_comp_op_is, +RULE_comp_op_is_not, + + + + + +RULE_shift_op, + +RULE_arith_op, + +RULE_term_op, +RULE_factor, + +RULE_factor_op, + + + + + +RULE_atom_expr, + + +RULE_atom_expr_trailers, +RULE_power_dbl_star, + + + + + +RULE_atom, + +RULE_atom_2b, + + +RULE_testlist_comp, +RULE_testlist_comp_2, +RULE_testlist_comp_3, +RULE_testlist_comp_3b, +RULE_testlist_comp_3c, +RULE_trailer, + + + +# 300 "user/mpy/py/grammar.h" + + + + + + + +RULE_exprlist, +RULE_exprlist_2, + + +RULE_dictorsetmaker, + + + + + + +RULE_dictorsetmaker_tail, +RULE_dictorsetmaker_list, +RULE_dictorsetmaker_list2, + + + + +RULE_classdef_2, + + + + +RULE_arglist, +RULE_arglist_2, +RULE_arglist_star, +RULE_arglist_dbl_star, +# 342 "user/mpy/py/grammar.h" +RULE_argument, +RULE_argument_2, +RULE_argument_3, +RULE_comp_iter, +RULE_comp_for, +RULE_comp_if, + + + + + + + + +RULE_yield_arg, +RULE_yield_arg_from, +# 85 "user/mpy/py/parse.c" 2 + + +}; +# 106 "user/mpy/py/parse.c" +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" +static const rule_t rule_single_input = { RULE_single_input, ((0x10) | 3), { ((0x1000) | MP_TOKEN_NEWLINE), ((0x2000) | RULE_simple_stmt), ((0x2000) | RULE_compound_stmt) } }; +static const rule_t rule_file_input = { RULE_file_input, ((0x20) | 1 | (0x40)), { ((0x3000) | RULE_file_input_2) } }; +static const rule_t rule_file_input_2 = { RULE_file_input_2, ((0x30) | 2), { ((0x2000) | RULE_file_input_3) } }; +static const rule_t rule_file_input_3 = { RULE_file_input_3, ((0x10) | 2), { ((0x1000) | MP_TOKEN_NEWLINE), ((0x2000) | RULE_stmt) } }; +static const rule_t rule_eval_input = { RULE_eval_input, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_testlist), ((0x3000) | RULE_eval_input_2) } }; +static const rule_t rule_eval_input_2 = { RULE_eval_input_2, ((0x20) | 1), { ((0x1000) | MP_TOKEN_NEWLINE) } }; +# 58 "user/mpy/py/grammar.h" +static const rule_t rule_decorator = { RULE_decorator, ((0x20) | 4), { ((0x1000) | MP_TOKEN_DEL_AT), ((0x2000) | RULE_dotted_name), ((0x3000) | RULE_trailer_paren), ((0x1000) | MP_TOKEN_NEWLINE) } }; +static const rule_t rule_decorators = { RULE_decorators, ((0x30) | 2), { ((0x2000) | RULE_decorator) } }; +static const rule_t rule_decorated = { RULE_decorated, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_decorators), ((0x2000) | RULE_decorated_body) } }; + + + + +static const rule_t rule_decorated_body = { RULE_decorated_body, ((0x10) | 2), { ((0x2000) | RULE_classdef), ((0x2000) | RULE_funcdef) } }; + +static const rule_t rule_funcdef = { RULE_funcdef, ((0x20) | 8 | (0x80)), { ((0x1000) | MP_TOKEN_KW_DEF), ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_typedargslist), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE), ((0x3000) | RULE_funcdefrettype), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_funcdefrettype = { RULE_funcdefrettype, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_MINUS_MORE), ((0x2000) | RULE_test) } }; + +static const rule_t rule_typedargslist = { RULE_typedargslist, ((0x30) | 3), { ((0x2000) | RULE_typedargslist_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_typedargslist_item = { RULE_typedargslist_item, ((0x10) | 3), { ((0x2000) | RULE_typedargslist_name), ((0x2000) | RULE_typedargslist_star), ((0x2000) | RULE_typedargslist_dbl_star) } }; +static const rule_t rule_typedargslist_name = { RULE_typedargslist_name, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_typedargslist_colon), ((0x3000) | RULE_typedargslist_equal) } }; +static const rule_t rule_typedargslist_star = { RULE_typedargslist_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x3000) | RULE_tfpdef) } }; +static const rule_t rule_typedargslist_dbl_star = { RULE_typedargslist_dbl_star, ((0x20) | 3), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_typedargslist_colon) } }; +static const rule_t rule_typedargslist_colon = { RULE_typedargslist_colon, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test) } }; +static const rule_t rule_typedargslist_equal = { RULE_typedargslist_equal, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_test) } }; +static const rule_t rule_tfpdef = { RULE_tfpdef, ((0x20) | 2), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_typedargslist_colon) } }; + +static const rule_t rule_varargslist = { RULE_varargslist, ((0x30) | 3), { ((0x2000) | RULE_varargslist_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_varargslist_item = { RULE_varargslist_item, ((0x10) | 3), { ((0x2000) | RULE_varargslist_name), ((0x2000) | RULE_varargslist_star), ((0x2000) | RULE_varargslist_dbl_star) } }; +static const rule_t rule_varargslist_name = { RULE_varargslist_name, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_varargslist_equal) } }; +static const rule_t rule_varargslist_star = { RULE_varargslist_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x3000) | RULE_vfpdef) } }; +static const rule_t rule_varargslist_dbl_star = { RULE_varargslist_dbl_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x1000) | MP_TOKEN_NAME) } }; +static const rule_t rule_varargslist_equal = { RULE_varargslist_equal, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_test) } }; +static const rule_t rule_vfpdef = { RULE_vfpdef, ((0x20) | 1 | (0x40)), { ((0x1000) | MP_TOKEN_NAME) } }; + + + +static const rule_t rule_stmt = { RULE_stmt, ((0x10) | 2), { ((0x2000) | RULE_compound_stmt), ((0x2000) | RULE_simple_stmt) } }; + + + +static const rule_t rule_simple_stmt = { RULE_simple_stmt, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_simple_stmt_2), ((0x1000) | MP_TOKEN_NEWLINE) } }; +static const rule_t rule_simple_stmt_2 = { RULE_simple_stmt_2, ((0x30) | 3), { ((0x2000) | RULE_small_stmt), ((0x1000) | MP_TOKEN_DEL_SEMICOLON) } }; + + + + + + + +static const rule_t rule_small_stmt = { RULE_small_stmt, ((0x10) | 8), { ((0x2000) | RULE_del_stmt), ((0x2000) | RULE_pass_stmt), ((0x2000) | RULE_flow_stmt), ((0x2000) | RULE_import_stmt), ((0x2000) | RULE_global_stmt), ((0x2000) | RULE_nonlocal_stmt), ((0x2000) | RULE_assert_stmt), ((0x2000) | RULE_expr_stmt) } }; +static const rule_t rule_expr_stmt = { RULE_expr_stmt, ((0x20) | 2), { ((0x2000) | RULE_testlist_star_expr), ((0x3000) | RULE_expr_stmt_2) } }; +static const rule_t rule_expr_stmt_2 = { RULE_expr_stmt_2, ((0x10) | 2), { ((0x2000) | RULE_expr_stmt_augassign), ((0x2000) | RULE_expr_stmt_assign_list) } }; +static const rule_t rule_expr_stmt_augassign = { RULE_expr_stmt_augassign, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_augassign), ((0x2000) | RULE_expr_stmt_6) } }; +static const rule_t rule_expr_stmt_assign_list = { RULE_expr_stmt_assign_list, ((0x30) | 2), { ((0x2000) | RULE_expr_stmt_assign) } }; +static const rule_t rule_expr_stmt_assign = { RULE_expr_stmt_assign, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_expr_stmt_6) } }; +static const rule_t rule_expr_stmt_6 = { RULE_expr_stmt_6, ((0x10) | 2), { ((0x2000) | RULE_yield_expr), ((0x2000) | RULE_testlist_star_expr) } }; +static const rule_t rule_testlist_star_expr = { RULE_testlist_star_expr, ((0x30) | 3), { ((0x2000) | RULE_testlist_star_expr_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_testlist_star_expr_2 = { RULE_testlist_star_expr_2, ((0x10) | 2), { ((0x2000) | RULE_star_expr), ((0x2000) | RULE_test) } }; +static const rule_t rule_augassign = { RULE_augassign, ((0x10) | 12), { ((0x1000) | MP_TOKEN_DEL_PLUS_EQUAL), ((0x1000) | MP_TOKEN_DEL_MINUS_EQUAL), ((0x1000) | MP_TOKEN_DEL_STAR_EQUAL), ((0x1000) | MP_TOKEN_DEL_SLASH_EQUAL), ((0x1000) | MP_TOKEN_DEL_PERCENT_EQUAL), ((0x1000) | MP_TOKEN_DEL_AMPERSAND_EQUAL), ((0x1000) | MP_TOKEN_DEL_PIPE_EQUAL), ((0x1000) | MP_TOKEN_DEL_CARET_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_LESS_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_MORE_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_STAR_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_SLASH_EQUAL) } }; +# 122 "user/mpy/py/grammar.h" +static const rule_t rule_del_stmt = { RULE_del_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_DEL), ((0x2000) | RULE_exprlist) } }; +static const rule_t rule_pass_stmt = { RULE_pass_stmt, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_PASS) } }; +static const rule_t rule_flow_stmt = { RULE_flow_stmt, ((0x10) | 5), { ((0x2000) | RULE_break_stmt), ((0x2000) | RULE_continue_stmt), ((0x2000) | RULE_return_stmt), ((0x2000) | RULE_raise_stmt), ((0x2000) | RULE_yield_stmt) } }; +static const rule_t rule_break_stmt = { RULE_break_stmt, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_BREAK) } }; +static const rule_t rule_continue_stmt = { RULE_continue_stmt, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_CONTINUE) } }; +static const rule_t rule_return_stmt = { RULE_return_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_RETURN), ((0x3000) | RULE_testlist) } }; +static const rule_t rule_yield_stmt = { RULE_yield_stmt, ((0x20) | 1), { ((0x2000) | RULE_yield_expr) } }; +static const rule_t rule_raise_stmt = { RULE_raise_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_RAISE), ((0x3000) | RULE_raise_stmt_arg) } }; +static const rule_t rule_raise_stmt_arg = { RULE_raise_stmt_arg, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_raise_stmt_from) } }; +static const rule_t rule_raise_stmt_from = { RULE_raise_stmt_from, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_KW_FROM), ((0x2000) | RULE_test) } }; +# 145 "user/mpy/py/grammar.h" +static const rule_t rule_import_stmt = { RULE_import_stmt, ((0x10) | 2), { ((0x2000) | RULE_import_name), ((0x2000) | RULE_import_from) } }; +static const rule_t rule_import_name = { RULE_import_name, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_IMPORT), ((0x2000) | RULE_dotted_as_names) } }; +static const rule_t rule_import_from = { RULE_import_from, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_FROM), ((0x2000) | RULE_import_from_2), ((0x1000) | MP_TOKEN_KW_IMPORT), ((0x2000) | RULE_import_from_3) } }; +static const rule_t rule_import_from_2 = { RULE_import_from_2, ((0x10) | 2), { ((0x2000) | RULE_dotted_name), ((0x2000) | RULE_import_from_2b) } }; +static const rule_t rule_import_from_2b = { RULE_import_from_2b, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_one_or_more_period_or_ellipsis), ((0x3000) | RULE_dotted_name) } }; +static const rule_t rule_import_from_3 = { RULE_import_from_3, ((0x10) | 3), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x2000) | RULE_import_as_names_paren), ((0x2000) | RULE_import_as_names) } }; +static const rule_t rule_import_as_names_paren = { RULE_import_as_names_paren, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x2000) | RULE_import_as_names), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; +static const rule_t rule_one_or_more_period_or_ellipsis = { RULE_one_or_more_period_or_ellipsis, ((0x30) | 2), { ((0x2000) | RULE_period_or_ellipsis) } }; +static const rule_t rule_period_or_ellipsis = { RULE_period_or_ellipsis, ((0x10) | 2), { ((0x1000) | MP_TOKEN_DEL_PERIOD), ((0x1000) | MP_TOKEN_ELLIPSIS) } }; +static const rule_t rule_import_as_name = { RULE_import_as_name, ((0x20) | 2), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_as_name) } }; +static const rule_t rule_dotted_as_name = { RULE_dotted_as_name, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_dotted_name), ((0x3000) | RULE_as_name) } }; +static const rule_t rule_as_name = { RULE_as_name, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_KW_AS), ((0x1000) | MP_TOKEN_NAME) } }; +static const rule_t rule_import_as_names = { RULE_import_as_names, ((0x30) | 3), { ((0x2000) | RULE_import_as_name), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_dotted_as_names = { RULE_dotted_as_names, ((0x30) | 1), { ((0x2000) | RULE_dotted_as_name), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_dotted_name = { RULE_dotted_name, ((0x30) | 1), { ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_DEL_PERIOD) } }; +static const rule_t rule_global_stmt = { RULE_global_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_GLOBAL), ((0x2000) | RULE_name_list) } }; +static const rule_t rule_nonlocal_stmt = { RULE_nonlocal_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_NONLOCAL), ((0x2000) | RULE_name_list) } }; +static const rule_t rule_name_list = { RULE_name_list, ((0x30) | 1), { ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_assert_stmt = { RULE_assert_stmt, ((0x20) | 3), { ((0x1000) | MP_TOKEN_KW_ASSERT), ((0x2000) | RULE_test), ((0x3000) | RULE_assert_stmt_extra) } }; +static const rule_t rule_assert_stmt_extra = { RULE_assert_stmt_extra, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_COMMA), ((0x2000) | RULE_test) } }; +# 183 "user/mpy/py/grammar.h" +static const rule_t rule_compound_stmt = { RULE_compound_stmt, ((0x10) | 8), { ((0x2000) | RULE_if_stmt), ((0x2000) | RULE_while_stmt), ((0x2000) | RULE_for_stmt), ((0x2000) | RULE_try_stmt), ((0x2000) | RULE_with_stmt), ((0x2000) | RULE_funcdef), ((0x2000) | RULE_classdef), ((0x2000) | RULE_decorated) } }; + +static const rule_t rule_if_stmt = { RULE_if_stmt, ((0x20) | 6), { ((0x1000) | MP_TOKEN_KW_IF), ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x3000) | RULE_if_stmt_elif_list), ((0x3000) | RULE_else_stmt) } }; +static const rule_t rule_if_stmt_elif_list = { RULE_if_stmt_elif_list, ((0x30) | 2), { ((0x2000) | RULE_if_stmt_elif) } }; +static const rule_t rule_if_stmt_elif = { RULE_if_stmt_elif, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_ELIF), ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_while_stmt = { RULE_while_stmt, ((0x20) | 5), { ((0x1000) | MP_TOKEN_KW_WHILE), ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x3000) | RULE_else_stmt) } }; +static const rule_t rule_for_stmt = { RULE_for_stmt, ((0x20) | 7), { ((0x1000) | MP_TOKEN_KW_FOR), ((0x2000) | RULE_exprlist), ((0x1000) | MP_TOKEN_KW_IN), ((0x2000) | RULE_testlist), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x3000) | RULE_else_stmt) } }; +static const rule_t rule_try_stmt = { RULE_try_stmt, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_TRY), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x2000) | RULE_try_stmt_2) } }; +static const rule_t rule_try_stmt_2 = { RULE_try_stmt_2, ((0x10) | 2), { ((0x2000) | RULE_try_stmt_except_and_more), ((0x2000) | RULE_try_stmt_finally) } }; +static const rule_t rule_try_stmt_except_and_more = { RULE_try_stmt_except_and_more, ((0x20) | 3 | (0x40)), { ((0x2000) | RULE_try_stmt_except_list), ((0x3000) | RULE_else_stmt), ((0x3000) | RULE_try_stmt_finally) } }; +static const rule_t rule_try_stmt_except = { RULE_try_stmt_except, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_EXCEPT), ((0x3000) | RULE_try_stmt_as_name), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_try_stmt_as_name = { RULE_try_stmt_as_name, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_as_name) } }; +static const rule_t rule_try_stmt_except_list = { RULE_try_stmt_except_list, ((0x30) | 2), { ((0x2000) | RULE_try_stmt_except) } }; +static const rule_t rule_try_stmt_finally = { RULE_try_stmt_finally, ((0x20) | 3), { ((0x1000) | MP_TOKEN_KW_FINALLY), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_else_stmt = { RULE_else_stmt, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_KW_ELSE), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_with_stmt = { RULE_with_stmt, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_WITH), ((0x2000) | RULE_with_stmt_list), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_with_stmt_list = { RULE_with_stmt_list, ((0x30) | 1), { ((0x2000) | RULE_with_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_with_item = { RULE_with_item, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_with_item_as) } }; +static const rule_t rule_with_item_as = { RULE_with_item_as, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_KW_AS), ((0x2000) | RULE_expr) } }; +static const rule_t rule_suite = { RULE_suite, ((0x10) | 2), { ((0x2000) | RULE_suite_block), ((0x2000) | RULE_simple_stmt) } }; +static const rule_t rule_suite_block = { RULE_suite_block, ((0x20) | 4 | (0x40)), { ((0x1000) | MP_TOKEN_NEWLINE), ((0x1000) | MP_TOKEN_INDENT), ((0x2000) | RULE_suite_block_stmts), ((0x1000) | MP_TOKEN_DEDENT) } }; +static const rule_t rule_suite_block_stmts = { RULE_suite_block_stmts, ((0x30) | 2), { ((0x2000) | RULE_stmt) } }; + + + + + + +static const rule_t rule_test = { RULE_test, ((0x10) | 2), { ((0x2000) | RULE_lambdef), ((0x2000) | RULE_test_if_expr) } }; +static const rule_t rule_test_if_expr = { RULE_test_if_expr, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_or_test), ((0x3000) | RULE_test_if_else) } }; +static const rule_t rule_test_if_else = { RULE_test_if_else, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_IF), ((0x2000) | RULE_or_test), ((0x1000) | MP_TOKEN_KW_ELSE), ((0x2000) | RULE_test) } }; +static const rule_t rule_test_nocond = { RULE_test_nocond, ((0x10) | 2), { ((0x2000) | RULE_lambdef_nocond), ((0x2000) | RULE_or_test) } }; +static const rule_t rule_lambdef = { RULE_lambdef, ((0x20) | 4 | (0x80)), { ((0x1000) | MP_TOKEN_KW_LAMBDA), ((0x3000) | RULE_varargslist), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test) } }; +static const rule_t rule_lambdef_nocond = { RULE_lambdef_nocond, ((0x20) | 4 | (0x80)), { ((0x1000) | MP_TOKEN_KW_LAMBDA), ((0x3000) | RULE_varargslist), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test_nocond) } }; +# 234 "user/mpy/py/grammar.h" +static const rule_t rule_or_test = { RULE_or_test, ((0x30) | 1), { ((0x2000) | RULE_and_test), ((0x1000) | MP_TOKEN_KW_OR) } }; +static const rule_t rule_and_test = { RULE_and_test, ((0x30) | 1), { ((0x2000) | RULE_not_test), ((0x1000) | MP_TOKEN_KW_AND) } }; +static const rule_t rule_not_test = { RULE_not_test, ((0x10) | 2), { ((0x2000) | RULE_not_test_2), ((0x2000) | RULE_comparison) } }; +static const rule_t rule_not_test_2 = { RULE_not_test_2, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_NOT), ((0x2000) | RULE_not_test) } }; +static const rule_t rule_comparison = { RULE_comparison, ((0x30) | 1), { ((0x2000) | RULE_expr), ((0x2000) | RULE_comp_op) } }; +static const rule_t rule_comp_op = { RULE_comp_op, ((0x10) | 9), { ((0x1000) | MP_TOKEN_OP_LESS), ((0x1000) | MP_TOKEN_OP_MORE), ((0x1000) | MP_TOKEN_OP_DBL_EQUAL), ((0x1000) | MP_TOKEN_OP_LESS_EQUAL), ((0x1000) | MP_TOKEN_OP_MORE_EQUAL), ((0x1000) | MP_TOKEN_OP_NOT_EQUAL), ((0x1000) | MP_TOKEN_KW_IN), ((0x2000) | RULE_comp_op_not_in), ((0x2000) | RULE_comp_op_is) } }; +static const rule_t rule_comp_op_not_in = { RULE_comp_op_not_in, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_NOT), ((0x1000) | MP_TOKEN_KW_IN) } }; +static const rule_t rule_comp_op_is = { RULE_comp_op_is, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_IS), ((0x3000) | RULE_comp_op_is_not) } }; +static const rule_t rule_comp_op_is_not = { RULE_comp_op_is_not, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_NOT) } }; +static const rule_t rule_star_expr = { RULE_star_expr, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x2000) | RULE_expr) } }; +static const rule_t rule_expr = { RULE_expr, ((0x30) | 1), { ((0x2000) | RULE_xor_expr), ((0x1000) | MP_TOKEN_OP_PIPE) } }; +static const rule_t rule_xor_expr = { RULE_xor_expr, ((0x30) | 1), { ((0x2000) | RULE_and_expr), ((0x1000) | MP_TOKEN_OP_CARET) } }; +static const rule_t rule_and_expr = { RULE_and_expr, ((0x30) | 1), { ((0x2000) | RULE_shift_expr), ((0x1000) | MP_TOKEN_OP_AMPERSAND) } }; +static const rule_t rule_shift_expr = { RULE_shift_expr, ((0x30) | 1), { ((0x2000) | RULE_arith_expr), ((0x2000) | RULE_shift_op) } }; +static const rule_t rule_shift_op = { RULE_shift_op, ((0x10) | 2), { ((0x1000) | MP_TOKEN_OP_DBL_LESS), ((0x1000) | MP_TOKEN_OP_DBL_MORE) } }; +static const rule_t rule_arith_expr = { RULE_arith_expr, ((0x30) | 1), { ((0x2000) | RULE_term), ((0x2000) | RULE_arith_op) } }; +static const rule_t rule_arith_op = { RULE_arith_op, ((0x10) | 2), { ((0x1000) | MP_TOKEN_OP_PLUS), ((0x1000) | MP_TOKEN_OP_MINUS) } }; +static const rule_t rule_term = { RULE_term, ((0x30) | 1), { ((0x2000) | RULE_factor), ((0x2000) | RULE_term_op) } }; +static const rule_t rule_term_op = { RULE_term_op, ((0x10) | 4), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x1000) | MP_TOKEN_OP_SLASH), ((0x1000) | MP_TOKEN_OP_PERCENT), ((0x1000) | MP_TOKEN_OP_DBL_SLASH) } }; +static const rule_t rule_factor = { RULE_factor, ((0x10) | 2), { ((0x2000) | RULE_factor_2), ((0x2000) | RULE_power) } }; +static const rule_t rule_factor_2 = { RULE_factor_2, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_factor_op), ((0x2000) | RULE_factor) } }; +static const rule_t rule_factor_op = { RULE_factor_op, ((0x10) | 3), { ((0x1000) | MP_TOKEN_OP_PLUS), ((0x1000) | MP_TOKEN_OP_MINUS), ((0x1000) | MP_TOKEN_OP_TILDE) } }; +static const rule_t rule_power = { RULE_power, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_atom_expr), ((0x3000) | RULE_power_dbl_star) } }; + + + + +static const rule_t rule_atom_expr = { RULE_atom_expr, ((0x10) | 1), { ((0x2000) | RULE_atom_expr_normal) } }; + +static const rule_t rule_atom_expr_normal = { RULE_atom_expr_normal, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_atom), ((0x3000) | RULE_atom_expr_trailers) } }; +static const rule_t rule_atom_expr_trailers = { RULE_atom_expr_trailers, ((0x30) | 2), { ((0x2000) | RULE_trailer) } }; +static const rule_t rule_power_dbl_star = { RULE_power_dbl_star, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x2000) | RULE_factor) } }; + + + + + +static const rule_t rule_atom = { RULE_atom, ((0x10) | 12), { ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_INTEGER), ((0x1000) | MP_TOKEN_FLOAT_OR_IMAG), ((0x1000) | MP_TOKEN_STRING), ((0x1000) | MP_TOKEN_BYTES), ((0x1000) | MP_TOKEN_ELLIPSIS), ((0x1000) | MP_TOKEN_KW_NONE), ((0x1000) | MP_TOKEN_KW_TRUE), ((0x1000) | MP_TOKEN_KW_FALSE), ((0x2000) | RULE_atom_paren), ((0x2000) | RULE_atom_bracket), ((0x2000) | RULE_atom_brace) } }; +static const rule_t rule_atom_paren = { RULE_atom_paren, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_atom_2b), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; +static const rule_t rule_atom_2b = { RULE_atom_2b, ((0x10) | 2), { ((0x2000) | RULE_yield_expr), ((0x2000) | RULE_testlist_comp) } }; +static const rule_t rule_atom_bracket = { RULE_atom_bracket, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_BRACKET_OPEN), ((0x3000) | RULE_testlist_comp), ((0x1000) | MP_TOKEN_DEL_BRACKET_CLOSE) } }; +static const rule_t rule_atom_brace = { RULE_atom_brace, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_BRACE_OPEN), ((0x3000) | RULE_dictorsetmaker), ((0x1000) | MP_TOKEN_DEL_BRACE_CLOSE) } }; +static const rule_t rule_testlist_comp = { RULE_testlist_comp, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_testlist_comp_2), ((0x3000) | RULE_testlist_comp_3) } }; +static const rule_t rule_testlist_comp_2 = { RULE_testlist_comp_2, ((0x10) | 2), { ((0x2000) | RULE_star_expr), ((0x2000) | RULE_test) } }; +static const rule_t rule_testlist_comp_3 = { RULE_testlist_comp_3, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_testlist_comp_3b) } }; +static const rule_t rule_testlist_comp_3b = { RULE_testlist_comp_3b, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_COMMA), ((0x3000) | RULE_testlist_comp_3c) } }; +static const rule_t rule_testlist_comp_3c = { RULE_testlist_comp_3c, ((0x30) | 3), { ((0x2000) | RULE_testlist_comp_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_trailer = { RULE_trailer, ((0x10) | 3), { ((0x2000) | RULE_trailer_paren), ((0x2000) | RULE_trailer_bracket), ((0x2000) | RULE_trailer_period) } }; +static const rule_t rule_trailer_paren = { RULE_trailer_paren, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_arglist), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; +static const rule_t rule_trailer_bracket = { RULE_trailer_bracket, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_BRACKET_OPEN), ((0x2000) | RULE_subscriptlist), ((0x1000) | MP_TOKEN_DEL_BRACKET_CLOSE) } }; +static const rule_t rule_trailer_period = { RULE_trailer_period, ((0x20) | 2), { ((0x1000) | MP_TOKEN_DEL_PERIOD), ((0x1000) | MP_TOKEN_NAME) } }; +# 300 "user/mpy/py/grammar.h" +static const rule_t rule_subscriptlist = { RULE_subscriptlist, ((0x30) | 3), { ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; + + + + + + +static const rule_t rule_exprlist = { RULE_exprlist, ((0x30) | 3), { ((0x2000) | RULE_exprlist_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_exprlist_2 = { RULE_exprlist_2, ((0x10) | 2), { ((0x2000) | RULE_star_expr), ((0x2000) | RULE_expr) } }; +static const rule_t rule_testlist = { RULE_testlist, ((0x30) | 3), { ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; + +static const rule_t rule_dictorsetmaker = { RULE_dictorsetmaker, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_dictorsetmaker_item), ((0x3000) | RULE_dictorsetmaker_tail) } }; + + + + +static const rule_t rule_dictorsetmaker_item = { RULE_dictorsetmaker_item, ((0x20) | 3), { ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test) } }; + +static const rule_t rule_dictorsetmaker_tail = { RULE_dictorsetmaker_tail, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_dictorsetmaker_list) } }; +static const rule_t rule_dictorsetmaker_list = { RULE_dictorsetmaker_list, ((0x20) | 2), { ((0x1000) | MP_TOKEN_DEL_COMMA), ((0x3000) | RULE_dictorsetmaker_list2) } }; +static const rule_t rule_dictorsetmaker_list2 = { RULE_dictorsetmaker_list2, ((0x30) | 3), { ((0x2000) | RULE_dictorsetmaker_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; + + + +static const rule_t rule_classdef = { RULE_classdef, ((0x20) | 5 | (0x80)), { ((0x1000) | MP_TOKEN_KW_CLASS), ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_classdef_2), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; +static const rule_t rule_classdef_2 = { RULE_classdef_2, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_arglist), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; + + + + +static const rule_t rule_arglist = { RULE_arglist, ((0x30) | 3), { ((0x2000) | RULE_arglist_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; +static const rule_t rule_arglist_2 = { RULE_arglist_2, ((0x10) | 3), { ((0x2000) | RULE_arglist_star), ((0x2000) | RULE_arglist_dbl_star), ((0x2000) | RULE_argument) } }; +static const rule_t rule_arglist_star = { RULE_arglist_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x2000) | RULE_test) } }; +static const rule_t rule_arglist_dbl_star = { RULE_arglist_dbl_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x2000) | RULE_test) } }; +# 342 "user/mpy/py/grammar.h" +static const rule_t rule_argument = { RULE_argument, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_argument_2) } }; +static const rule_t rule_argument_2 = { RULE_argument_2, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_argument_3) } }; +static const rule_t rule_argument_3 = { RULE_argument_3, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_test) } }; +static const rule_t rule_comp_iter = { RULE_comp_iter, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_comp_if) } }; +static const rule_t rule_comp_for = { RULE_comp_for, ((0x20) | 5 | (0x80)), { ((0x1000) | MP_TOKEN_KW_FOR), ((0x2000) | RULE_exprlist), ((0x1000) | MP_TOKEN_KW_IN), ((0x2000) | RULE_or_test), ((0x3000) | RULE_comp_iter) } }; +static const rule_t rule_comp_if = { RULE_comp_if, ((0x20) | 3), { ((0x1000) | MP_TOKEN_KW_IF), ((0x2000) | RULE_test_nocond), ((0x3000) | RULE_comp_iter) } }; + + + + + + + +static const rule_t rule_yield_expr = { RULE_yield_expr, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_YIELD), ((0x3000) | RULE_yield_arg) } }; +static const rule_t rule_yield_arg = { RULE_yield_arg, ((0x10) | 2), { ((0x2000) | RULE_yield_arg_from), ((0x2000) | RULE_testlist) } }; +static const rule_t rule_yield_arg_from = { RULE_yield_arg_from, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_FROM), ((0x2000) | RULE_test) } }; +# 107 "user/mpy/py/parse.c" 2 +# 118 "user/mpy/py/parse.c" +static const rule_t *const rules[] = { + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" + +&rule_file_input, +&rule_file_input_2, + + + +# 58 "user/mpy/py/grammar.h" + + +&rule_decorated, + + + + + + +&rule_funcdef, + + + + + + + + + + + + + + + + + + + + + + + + + + +&rule_simple_stmt_2, + + + + + + + + +&rule_expr_stmt, + + + + + +&rule_testlist_star_expr, + + +# 122 "user/mpy/py/grammar.h" +&rule_del_stmt, +&rule_pass_stmt, + +&rule_break_stmt, +&rule_continue_stmt, +&rule_return_stmt, +&rule_yield_stmt, +&rule_raise_stmt, + + +# 145 "user/mpy/py/grammar.h" + +&rule_import_name, +&rule_import_from, + + + + + + + + + + + + +&rule_global_stmt, +&rule_nonlocal_stmt, + +&rule_assert_stmt, + +# 183 "user/mpy/py/grammar.h" + + +&rule_if_stmt, + + +&rule_while_stmt, +&rule_for_stmt, +&rule_try_stmt, + + + + + + + +&rule_with_stmt, + + + + + +&rule_suite_block_stmts, + + + + + + + +&rule_test_if_expr, + + +&rule_lambdef, +&rule_lambdef_nocond, +# 234 "user/mpy/py/grammar.h" +&rule_or_test, +&rule_and_test, + +&rule_not_test_2, +&rule_comparison, + + + + +&rule_star_expr, +&rule_expr, +&rule_xor_expr, +&rule_and_expr, +&rule_shift_expr, + +&rule_arith_expr, + +&rule_term, + + +&rule_factor_2, + +&rule_power, + + + + + + +&rule_atom_expr_normal, + + + + + + + + +&rule_atom_paren, + +&rule_atom_bracket, +&rule_atom_brace, + + + + + + +&rule_trailer_paren, +&rule_trailer_bracket, +&rule_trailer_period, +# 300 "user/mpy/py/grammar.h" +&rule_subscriptlist, + + + + + + + + +&rule_testlist, + + + + + + +&rule_dictorsetmaker_item, + + + + + + + +&rule_classdef, + + + + + + + + + +# 342 "user/mpy/py/grammar.h" + + + + + + + + + + + + + +&rule_yield_expr, + + +# 123 "user/mpy/py/parse.c" 2 + + + +# 125 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 125 "user/mpy/py/parse.c" + , + + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" +&rule_single_input, + + +&rule_file_input_3, +&rule_eval_input, +&rule_eval_input_2, +# 58 "user/mpy/py/grammar.h" +&rule_decorator, +&rule_decorators, + + + + + +&rule_decorated_body, + + +&rule_funcdefrettype, + +&rule_typedargslist, +&rule_typedargslist_item, +&rule_typedargslist_name, +&rule_typedargslist_star, +&rule_typedargslist_dbl_star, +&rule_typedargslist_colon, +&rule_typedargslist_equal, +&rule_tfpdef, + +&rule_varargslist, +&rule_varargslist_item, +&rule_varargslist_name, +&rule_varargslist_star, +&rule_varargslist_dbl_star, +&rule_varargslist_equal, +&rule_vfpdef, + + + +&rule_stmt, + + + +&rule_simple_stmt, + + + + + + + + +&rule_small_stmt, + +&rule_expr_stmt_2, +&rule_expr_stmt_augassign, +&rule_expr_stmt_assign_list, +&rule_expr_stmt_assign, +&rule_expr_stmt_6, + +&rule_testlist_star_expr_2, +&rule_augassign, +# 122 "user/mpy/py/grammar.h" + + +&rule_flow_stmt, + + + + + +&rule_raise_stmt_arg, +&rule_raise_stmt_from, +# 145 "user/mpy/py/grammar.h" +&rule_import_stmt, + + +&rule_import_from_2, +&rule_import_from_2b, +&rule_import_from_3, +&rule_import_as_names_paren, +&rule_one_or_more_period_or_ellipsis, +&rule_period_or_ellipsis, +&rule_import_as_name, +&rule_dotted_as_name, +&rule_as_name, +&rule_import_as_names, +&rule_dotted_as_names, +&rule_dotted_name, + + +&rule_name_list, + +&rule_assert_stmt_extra, +# 183 "user/mpy/py/grammar.h" +&rule_compound_stmt, + + +&rule_if_stmt_elif_list, +&rule_if_stmt_elif, + + + +&rule_try_stmt_2, +&rule_try_stmt_except_and_more, +&rule_try_stmt_except, +&rule_try_stmt_as_name, +&rule_try_stmt_except_list, +&rule_try_stmt_finally, +&rule_else_stmt, + +&rule_with_stmt_list, +&rule_with_item, +&rule_with_item_as, +&rule_suite, +&rule_suite_block, + + + + + + + +&rule_test, + +&rule_test_if_else, +&rule_test_nocond, + + +# 234 "user/mpy/py/grammar.h" + + +&rule_not_test, + + +&rule_comp_op, +&rule_comp_op_not_in, +&rule_comp_op_is, +&rule_comp_op_is_not, + + + + + +&rule_shift_op, + +&rule_arith_op, + +&rule_term_op, +&rule_factor, + +&rule_factor_op, + + + + + +&rule_atom_expr, + + +&rule_atom_expr_trailers, +&rule_power_dbl_star, + + + + + +&rule_atom, + +&rule_atom_2b, + + +&rule_testlist_comp, +&rule_testlist_comp_2, +&rule_testlist_comp_3, +&rule_testlist_comp_3b, +&rule_testlist_comp_3c, +&rule_trailer, + + + +# 300 "user/mpy/py/grammar.h" + + + + + + + +&rule_exprlist, +&rule_exprlist_2, + + +&rule_dictorsetmaker, + + + + + + +&rule_dictorsetmaker_tail, +&rule_dictorsetmaker_list, +&rule_dictorsetmaker_list2, + + + + +&rule_classdef_2, + + + + +&rule_arglist, +&rule_arglist_2, +&rule_arglist_star, +&rule_arglist_dbl_star, +# 342 "user/mpy/py/grammar.h" +&rule_argument, +&rule_argument_2, +&rule_argument_3, +&rule_comp_iter, +&rule_comp_for, +&rule_comp_if, + + + + + + + + +&rule_yield_arg, +&rule_yield_arg_from, +# 131 "user/mpy/py/parse.c" 2 + + +}; + +typedef struct _rule_stack_t { + size_t src_line : 8 * sizeof(size_t) - 8; + size_t rule_id : 8; + size_t arg_i; +} rule_stack_t; + +typedef struct _mp_parse_chunk_t { + size_t alloc; + union { + size_t used; + struct _mp_parse_chunk_t *next; + } union_; + byte data[]; +} mp_parse_chunk_t; + +typedef struct _parser_t { + size_t rule_stack_alloc; + size_t rule_stack_top; + rule_stack_t *rule_stack; + + size_t result_stack_alloc; + size_t result_stack_top; + mp_parse_node_t *result_stack; + + mp_lexer_t *lexer; + + mp_parse_tree_t tree; + mp_parse_chunk_t *cur_chunk; + + + + +} parser_t; + +static void *parser_alloc(parser_t *parser, size_t num_bytes) { + + + mp_parse_chunk_t *chunk = parser->cur_chunk; + + if (chunk != +# 174 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 174 "user/mpy/py/parse.c" + && chunk->union_.used + num_bytes > chunk->alloc) { + + mp_parse_chunk_t *new_data = (mp_parse_chunk_t*)((byte*)(m_realloc_maybe((chunk), sizeof(byte) * (sizeof(mp_parse_chunk_t) + chunk->alloc + num_bytes), ( +# 176 "user/mpy/py/parse.c" 3 4 + 0 +# 176 "user/mpy/py/parse.c" + )))) + + ; + if (new_data == +# 179 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 179 "user/mpy/py/parse.c" + ) { + + (void)((byte*)(m_realloc_maybe((chunk), sizeof(byte) * (sizeof(mp_parse_chunk_t) + chunk->union_.used), ( +# 181 "user/mpy/py/parse.c" 3 4 + 0 +# 181 "user/mpy/py/parse.c" + )))) + ; + chunk->alloc = chunk->union_.used; + chunk->union_.next = parser->tree.chunk; + parser->tree.chunk = chunk; + chunk = +# 186 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 186 "user/mpy/py/parse.c" + ; + } else { + + chunk->alloc += num_bytes; + } + } + + if (chunk == +# 193 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 193 "user/mpy/py/parse.c" + ) { + + size_t alloc = (16); + if (alloc < num_bytes) { + alloc = num_bytes; + } + chunk = (mp_parse_chunk_t*)((byte*)(m_malloc(sizeof(byte) * (sizeof(mp_parse_chunk_t) + alloc)))); + chunk->alloc = alloc; + chunk->union_.used = 0; + parser->cur_chunk = chunk; + } + + byte *ret = chunk->data + chunk->union_.used; + chunk->union_.used += num_bytes; + return ret; +} + +static void push_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t arg_i) { + if (parser->rule_stack_top >= parser->rule_stack_alloc) { + rule_stack_t *rs = ((rule_stack_t*)(m_realloc((parser->rule_stack), sizeof(rule_stack_t) * (parser->rule_stack_alloc + (16))))); + parser->rule_stack = rs; + parser->rule_stack_alloc += (16); + } + rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++]; + rs->src_line = src_line; + rs->rule_id = rule->rule_id; + rs->arg_i = arg_i; +} + +static void push_rule_from_arg(parser_t *parser, size_t arg) { + +# 223 "user/mpy/py/parse.c" 3 + (( +# 223 "user/mpy/py/parse.c" + (arg & (0xf000)) == (0x2000) || (arg & (0xf000)) == (0x3000) +# 223 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 223, __func__, +# 223 "user/mpy/py/parse.c" + "(arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE" +# 223 "user/mpy/py/parse.c" 3 + )) +# 223 "user/mpy/py/parse.c" + ; + size_t rule_id = arg & (0x0fff); + push_rule(parser, parser->lexer->tok_line, rules[rule_id], 0); +} + +static void pop_rule(parser_t *parser, const rule_t **rule, size_t *arg_i, size_t *src_line) { + parser->rule_stack_top -= 1; + *rule = rules[parser->rule_stack[parser->rule_stack_top].rule_id]; + *arg_i = parser->rule_stack[parser->rule_stack_top].arg_i; + *src_line = parser->rule_stack[parser->rule_stack_top].src_line; +} + + +# 235 "user/mpy/py/parse.c" 3 4 +_Bool +# 235 "user/mpy/py/parse.c" + mp_parse_node_is_const_false(mp_parse_node_t pn) { + return ((pn) == ((0x0e) | ((MP_TOKEN_KW_FALSE) << 4))) + || ((((pn) & 0x1) == (0x1)) && (((mp_int_t)(intptr_t)(pn)) >> 1) == 0); +} + + +# 240 "user/mpy/py/parse.c" 3 4 +_Bool +# 240 "user/mpy/py/parse.c" + mp_parse_node_is_const_true(mp_parse_node_t pn) { + return ((pn) == ((0x0e) | ((MP_TOKEN_KW_TRUE) << 4))) + || ((((pn) & 0x1) == (0x1)) && (((mp_int_t)(intptr_t)(pn)) >> 1) != 0); +} + + +# 245 "user/mpy/py/parse.c" 3 4 +_Bool +# 245 "user/mpy/py/parse.c" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) { + if ((((pn) & 0x1) == (0x1))) { + *o = ((mp_obj_t)((((mp_uint_t)((((mp_int_t)(intptr_t)(pn)) >> 1))) << 1) | 1)); + return +# 248 "user/mpy/py/parse.c" 3 4 + 1 +# 248 "user/mpy/py/parse.c" + ; + } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (RULE_const_object))) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + + + + + *o = (mp_obj_t)pns->nodes[0]; + + return (MP_OBJ_IS_SMALL_INT(*o) || (MP_OBJ_IS_OBJ(*o) && (((mp_obj_base_t*)((void*)*o))->type == (&mp_type_int)))); + } else { + return +# 259 "user/mpy/py/parse.c" 3 4 + 0 +# 259 "user/mpy/py/parse.c" + ; + } +} + +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes) { + if (((*pn) == (0))) { + *nodes = +# 265 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 265 "user/mpy/py/parse.c" + ; + return 0; + } else if (((*pn) & 3)) { + *nodes = pn; + return 1; + } else { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)(*pn); + if (((pns)->kind_num_nodes & 0xff) != pn_kind) { + *nodes = pn; + return 1; + } else { + *nodes = pns->nodes; + return ((pns)->kind_num_nodes >> 8); + } + } +} +# 340 "user/mpy/py/parse.c" +static mp_parse_node_t pop_result(parser_t *parser) { + +# 341 "user/mpy/py/parse.c" 3 + (( +# 341 "user/mpy/py/parse.c" + parser->result_stack_top > 0 +# 341 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 341, __func__, +# 341 "user/mpy/py/parse.c" + "parser->result_stack_top > 0" +# 341 "user/mpy/py/parse.c" 3 + )) +# 341 "user/mpy/py/parse.c" + ; + return parser->result_stack[--parser->result_stack_top]; +} + +static mp_parse_node_t peek_result(parser_t *parser, size_t pos) { + +# 346 "user/mpy/py/parse.c" 3 + (( +# 346 "user/mpy/py/parse.c" + parser->result_stack_top > pos +# 346 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 346, __func__, +# 346 "user/mpy/py/parse.c" + "parser->result_stack_top > pos" +# 346 "user/mpy/py/parse.c" 3 + )) +# 346 "user/mpy/py/parse.c" + ; + return parser->result_stack[parser->result_stack_top - 1 - pos]; +} + +static void push_result_node(parser_t *parser, mp_parse_node_t pn) { + if (parser->result_stack_top >= parser->result_stack_alloc) { + mp_parse_node_t *stack = ((mp_parse_node_t*)(m_realloc((parser->result_stack), sizeof(mp_parse_node_t) * (parser->result_stack_alloc + (16))))); + parser->result_stack = stack; + parser->result_stack_alloc += (16); + } + parser->result_stack[parser->result_stack_top++] = pn; +} + +static mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) { + mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_obj_t)); + pn->source_line = src_line; + + + + + + + pn->kind_num_nodes = RULE_const_object | (1 << 8); + pn->nodes[0] = (uintptr_t)obj; + + return (mp_parse_node_t)pn; +} + +static void push_result_token(parser_t *parser, const rule_t *rule) { + mp_parse_node_t pn; + mp_lexer_t *lex = parser->lexer; + if (lex->tok_kind == MP_TOKEN_NAME) { + qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len); +# 393 "user/mpy/py/parse.c" + (void)rule; + pn = mp_parse_node_new_leaf((0x02), id); + + } else if (lex->tok_kind == MP_TOKEN_INTEGER) { + mp_obj_t o = mp_parse_num_integer(lex->vstr.buf, lex->vstr.len, 0, lex); + if (MP_OBJ_IS_SMALL_INT(o)) { + pn = mp_parse_node_new_small_int((((mp_int_t)(o)) >> 1)); + } else { + pn = make_node_const_object(parser, lex->tok_line, o); + } + } else if (lex->tok_kind == MP_TOKEN_FLOAT_OR_IMAG) { + mp_obj_t o = mp_parse_num_decimal(lex->vstr.buf, lex->vstr.len, +# 404 "user/mpy/py/parse.c" 3 4 + 1 +# 404 "user/mpy/py/parse.c" + , +# 404 "user/mpy/py/parse.c" 3 4 + 0 +# 404 "user/mpy/py/parse.c" + , lex); + pn = make_node_const_object(parser, lex->tok_line, o); + } else if (lex->tok_kind == MP_TOKEN_STRING || lex->tok_kind == MP_TOKEN_BYTES) { + + + qstr qst = MP_QSTR_NULL; + if (lex->vstr.len <= (10)) { + + qst = qstr_from_strn(lex->vstr.buf, lex->vstr.len); + } else { + + qst = qstr_find_strn(lex->vstr.buf, lex->vstr.len); + } + if (qst != MP_QSTR_NULL) { + + pn = mp_parse_node_new_leaf(lex->tok_kind == MP_TOKEN_STRING ? (0x06) : (0x0a), qst); + } else { + + mp_obj_t o = mp_obj_new_str_of_type( + lex->tok_kind == MP_TOKEN_STRING ? &mp_type_str : &mp_type_bytes, + (const byte*)lex->vstr.buf, lex->vstr.len); + pn = make_node_const_object(parser, lex->tok_line, o); + } + } else { + pn = mp_parse_node_new_leaf((0x0e), lex->tok_kind); + } + push_result_node(parser, pn); +} +# 447 "user/mpy/py/parse.c" +static void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args); + + +static +# 450 "user/mpy/py/parse.c" 3 4 + _Bool +# 450 "user/mpy/py/parse.c" + fold_logical_constants(parser_t *parser, const rule_t *rule, size_t *num_args) { + if (rule->rule_id == RULE_or_test + || rule->rule_id == RULE_and_test) { + + size_t copy_to = *num_args; + for (size_t i = copy_to; i > 0;) { + mp_parse_node_t pn = peek_result(parser, --i); + parser->result_stack[parser->result_stack_top - copy_to] = pn; + if (i == 0) { + + break; + } + if (rule->rule_id == RULE_or_test) { + if (mp_parse_node_is_const_true(pn)) { + + break; + } else if (!mp_parse_node_is_const_false(pn)) { + copy_to -= 1; + } + } else { + + if (mp_parse_node_is_const_false(pn)) { + break; + } else if (!mp_parse_node_is_const_true(pn)) { + copy_to -= 1; + } + } + } + copy_to -= 1; + + + for (size_t i = 0; i < copy_to; ++i) { + pop_result(parser); + } + *num_args -= copy_to; + + + return *num_args == 1; + + } else if (rule->rule_id == RULE_not_test_2) { + + mp_parse_node_t pn = peek_result(parser, 0); + if (mp_parse_node_is_const_false(pn)) { + pn = mp_parse_node_new_leaf((0x0e), MP_TOKEN_KW_TRUE); + } else if (mp_parse_node_is_const_true(pn)) { + pn = mp_parse_node_new_leaf((0x0e), MP_TOKEN_KW_FALSE); + } else { + return +# 497 "user/mpy/py/parse.c" 3 4 + 0 +# 497 "user/mpy/py/parse.c" + ; + } + pop_result(parser); + push_result_node(parser, pn); + return +# 501 "user/mpy/py/parse.c" 3 4 + 1 +# 501 "user/mpy/py/parse.c" + ; + } + + return +# 504 "user/mpy/py/parse.c" 3 4 + 0 +# 504 "user/mpy/py/parse.c" + ; +} + +static +# 507 "user/mpy/py/parse.c" 3 4 + _Bool +# 507 "user/mpy/py/parse.c" + fold_constants(parser_t *parser, const rule_t *rule, size_t num_args) { + + + + mp_obj_t arg0; + if (rule->rule_id == RULE_expr + || rule->rule_id == RULE_xor_expr + || rule->rule_id == RULE_and_expr) { + + mp_parse_node_t pn = peek_result(parser, num_args - 1); + if (!mp_parse_node_get_int_maybe(pn, &arg0)) { + return +# 518 "user/mpy/py/parse.c" 3 4 + 0 +# 518 "user/mpy/py/parse.c" + ; + } + mp_binary_op_t op; + if (rule->rule_id == RULE_expr) { + op = MP_BINARY_OP_OR; + } else if (rule->rule_id == RULE_xor_expr) { + op = MP_BINARY_OP_XOR; + } else { + op = MP_BINARY_OP_AND; + } + for (ssize_t i = num_args - 2; i >= 0; --i) { + pn = peek_result(parser, i); + mp_obj_t arg1; + if (!mp_parse_node_get_int_maybe(pn, &arg1)) { + return +# 532 "user/mpy/py/parse.c" 3 4 + 0 +# 532 "user/mpy/py/parse.c" + ; + } + arg0 = mp_binary_op(op, arg0, arg1); + } + } else if (rule->rule_id == RULE_shift_expr + || rule->rule_id == RULE_arith_expr + || rule->rule_id == RULE_term) { + + mp_parse_node_t pn = peek_result(parser, num_args - 1); + if (!mp_parse_node_get_int_maybe(pn, &arg0)) { + return +# 542 "user/mpy/py/parse.c" 3 4 + 0 +# 542 "user/mpy/py/parse.c" + ; + } + for (ssize_t i = num_args - 2; i >= 1; i -= 2) { + pn = peek_result(parser, i - 1); + mp_obj_t arg1; + if (!mp_parse_node_get_int_maybe(pn, &arg1)) { + return +# 548 "user/mpy/py/parse.c" 3 4 + 0 +# 548 "user/mpy/py/parse.c" + ; + } + mp_token_kind_t tok = (((uintptr_t)(peek_result(parser, i))) >> 4); + static const uint8_t token_to_op[] = { + MP_BINARY_OP_ADD, + MP_BINARY_OP_SUBTRACT, + MP_BINARY_OP_MULTIPLY, + 255, + 255, + MP_BINARY_OP_FLOOR_DIVIDE, + MP_BINARY_OP_MODULO, + 255, + MP_BINARY_OP_LSHIFT, + 255, + MP_BINARY_OP_RSHIFT, + }; + mp_binary_op_t op = token_to_op[tok - MP_TOKEN_OP_PLUS]; + if (op == (mp_binary_op_t)255) { + return +# 566 "user/mpy/py/parse.c" 3 4 + 0 +# 566 "user/mpy/py/parse.c" + ; + } + int rhs_sign = mp_obj_int_sign(arg1); + if (op <= MP_BINARY_OP_RSHIFT) { + + if (rhs_sign < 0) { + return +# 572 "user/mpy/py/parse.c" 3 4 + 0 +# 572 "user/mpy/py/parse.c" + ; + } + } else if (op >= MP_BINARY_OP_FLOOR_DIVIDE) { + + if (rhs_sign == 0) { + return +# 577 "user/mpy/py/parse.c" 3 4 + 0 +# 577 "user/mpy/py/parse.c" + ; + } + } + arg0 = mp_binary_op(op, arg0, arg1); + } + } else if (rule->rule_id == RULE_factor_2) { + + mp_parse_node_t pn = peek_result(parser, 0); + if (!mp_parse_node_get_int_maybe(pn, &arg0)) { + return +# 586 "user/mpy/py/parse.c" 3 4 + 0 +# 586 "user/mpy/py/parse.c" + ; + } + mp_token_kind_t tok = (((uintptr_t)(peek_result(parser, 1))) >> 4); + mp_unary_op_t op; + if (tok == MP_TOKEN_OP_PLUS) { + op = MP_UNARY_OP_POSITIVE; + } else if (tok == MP_TOKEN_OP_MINUS) { + op = MP_UNARY_OP_NEGATIVE; + } else { + +# 595 "user/mpy/py/parse.c" 3 + (( +# 595 "user/mpy/py/parse.c" + tok == MP_TOKEN_OP_TILDE +# 595 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 595, __func__, +# 595 "user/mpy/py/parse.c" + "tok == MP_TOKEN_OP_TILDE" +# 595 "user/mpy/py/parse.c" 3 + )) +# 595 "user/mpy/py/parse.c" + ; + op = MP_UNARY_OP_INVERT; + } + arg0 = mp_unary_op(op, arg0); +# 681 "user/mpy/py/parse.c" + } else { + return +# 682 "user/mpy/py/parse.c" 3 4 + 0 +# 682 "user/mpy/py/parse.c" + ; + } + + + + for (size_t i = num_args; i > 0; i--) { + pop_result(parser); + } + if (MP_OBJ_IS_SMALL_INT(arg0)) { + push_result_node(parser, mp_parse_node_new_small_int((((mp_int_t)(arg0)) >> 1))); + } else { + + push_result_node(parser, make_node_const_object(parser, 0, arg0)); + } + + return +# 697 "user/mpy/py/parse.c" 3 4 + 1 +# 697 "user/mpy/py/parse.c" + ; +} + + +static void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args) { + + if (rule->rule_id == RULE_atom_paren) { + + mp_parse_node_t pn = peek_result(parser, 0); + if (((pn) == (0))) { + + } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (RULE_testlist_comp))) { + + } else { + + return; + } + } + + + if (fold_logical_constants(parser, rule, &num_args)) { + + return; + } + if (fold_constants(parser, rule, num_args)) { + + return; + } + + + mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * num_args); + pn->source_line = src_line; + pn->kind_num_nodes = (rule->rule_id & 0xff) | (num_args << 8); + for (size_t i = num_args; i > 0; i--) { + pn->nodes[i - 1] = pop_result(parser); + } + push_result_node(parser, (mp_parse_node_t)pn); +} + +mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { + + + + parser_t parser; + + parser.rule_stack_alloc = (64); + parser.rule_stack_top = 0; + parser.rule_stack = ((rule_stack_t*)(m_malloc(sizeof(rule_stack_t) * (parser.rule_stack_alloc)))); + + parser.result_stack_alloc = (32); + parser.result_stack_top = 0; + parser.result_stack = ((mp_parse_node_t*)(m_malloc(sizeof(mp_parse_node_t) * (parser.result_stack_alloc)))); + + parser.lexer = lex; + + parser.tree.chunk = +# 752 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 752 "user/mpy/py/parse.c" + ; + parser.cur_chunk = +# 753 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 753 "user/mpy/py/parse.c" + ; + + + + + + + size_t top_level_rule; + switch (input_kind) { + case MP_PARSE_SINGLE_INPUT: top_level_rule = RULE_single_input; break; + case MP_PARSE_EVAL_INPUT: top_level_rule = RULE_eval_input; break; + default: top_level_rule = RULE_file_input; + } + push_rule(&parser, lex->tok_line, rules[top_level_rule], 0); + + + + size_t n, i; + size_t rule_src_line; + +# 772 "user/mpy/py/parse.c" 3 4 + _Bool +# 772 "user/mpy/py/parse.c" + backtrack = +# 772 "user/mpy/py/parse.c" 3 4 + 0 +# 772 "user/mpy/py/parse.c" + ; + const rule_t *rule = +# 773 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 773 "user/mpy/py/parse.c" + ; + + for (;;) { + next_rule: + if (parser.rule_stack_top == 0) { + break; + } + + pop_rule(&parser, &rule, &i, &rule_src_line); + n = rule->act & (0x0f); +# 793 "user/mpy/py/parse.c" + switch (rule->act & (0x30)) { + case (0x10): + if (i > 0 && !backtrack) { + goto next_rule; + } else { + backtrack = +# 798 "user/mpy/py/parse.c" 3 4 + 0 +# 798 "user/mpy/py/parse.c" + ; + } + for (; i < n; ++i) { + uint16_t kind = rule->arg[i] & (0xf000); + if (kind == (0x1000)) { + if (lex->tok_kind == (rule->arg[i] & (0x0fff))) { + push_result_token(&parser, rule); + mp_lexer_to_next(lex); + goto next_rule; + } + } else { + +# 809 "user/mpy/py/parse.c" 3 + (( +# 809 "user/mpy/py/parse.c" + kind == (0x2000) +# 809 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 809, __func__, +# 809 "user/mpy/py/parse.c" + "kind == RULE_ARG_RULE" +# 809 "user/mpy/py/parse.c" 3 + )) +# 809 "user/mpy/py/parse.c" + ; + if (i + 1 < n) { + push_rule(&parser, rule_src_line, rule, i + 1); + } + push_rule_from_arg(&parser, rule->arg[i]); + goto next_rule; + } + } + backtrack = +# 817 "user/mpy/py/parse.c" 3 4 + 1 +# 817 "user/mpy/py/parse.c" + ; + break; + + case (0x20): { + + + if (backtrack) { + +# 824 "user/mpy/py/parse.c" 3 + (( +# 824 "user/mpy/py/parse.c" + i > 0 +# 824 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 824, __func__, +# 824 "user/mpy/py/parse.c" + "i > 0" +# 824 "user/mpy/py/parse.c" 3 + )) +# 824 "user/mpy/py/parse.c" + ; + if ((rule->arg[i - 1] & (0xf000)) == (0x3000)) { + + push_result_node(&parser, (0)); + backtrack = +# 828 "user/mpy/py/parse.c" 3 4 + 0 +# 828 "user/mpy/py/parse.c" + ; + } else { + + if (i > 1) { + + goto syntax_error; + } else { + goto next_rule; + } + } + } + + + for (; i < n; ++i) { + if ((rule->arg[i] & (0xf000)) == (0x1000)) { + + mp_token_kind_t tok_kind = rule->arg[i] & (0x0fff); + if (lex->tok_kind == tok_kind) { + + if (tok_kind == MP_TOKEN_NAME) { + push_result_token(&parser, rule); + } + mp_lexer_to_next(lex); + } else { + + if (i > 0) { + + goto syntax_error; + } else { + + backtrack = +# 858 "user/mpy/py/parse.c" 3 4 + 1 +# 858 "user/mpy/py/parse.c" + ; + goto next_rule; + } + } + } else { + push_rule(&parser, rule_src_line, rule, i + 1); + push_rule_from_arg(&parser, rule->arg[i]); + goto next_rule; + } + } + + +# 869 "user/mpy/py/parse.c" 3 + (( +# 869 "user/mpy/py/parse.c" + i == n +# 869 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 869, __func__, +# 869 "user/mpy/py/parse.c" + "i == n" +# 869 "user/mpy/py/parse.c" 3 + )) +# 869 "user/mpy/py/parse.c" + ; + + + + + + if (input_kind != MP_PARSE_SINGLE_INPUT && rule->rule_id == RULE_expr_stmt && peek_result(&parser, 0) == (0)) { + mp_parse_node_t p = peek_result(&parser, 1); + if ((((p) & 3) && !(((p) & 0x0f) == (0x02))) + || ((p) != (0) && ((p) & 3) == 0 && (((mp_parse_node_struct_t*)(p))->kind_num_nodes & 0xff) == (RULE_const_object))) { + pop_result(&parser); + pop_result(&parser); + + + + push_result_rule(&parser, rule_src_line, rules[RULE_pass_stmt], 0); + break; + } + } + + + + i = 0; + size_t num_not_nil = 0; + for (size_t x = n; x > 0;) { + --x; + if ((rule->arg[x] & (0xf000)) == (0x1000)) { + mp_token_kind_t tok_kind = rule->arg[x] & (0x0fff); + if (tok_kind == MP_TOKEN_NAME) { + + i += 1; + num_not_nil += 1; + } + } else { + + if (peek_result(&parser, i) != (0)) { + num_not_nil += 1; + } + i += 1; + } + } + + if (num_not_nil == 1 && (rule->act & (0x40))) { + + mp_parse_node_t pn = (0); + for (size_t x = 0; x < i; ++x) { + mp_parse_node_t pn2 = pop_result(&parser); + if (pn2 != (0)) { + pn = pn2; + } + } + push_result_node(&parser, pn); + } else { + + + if (rule->act & (0x80)) { + + push_result_node(&parser, (0)); + i += 1; + } + + push_result_rule(&parser, rule_src_line, rule, i); + } + break; + } + + default: { + +# 936 "user/mpy/py/parse.c" 3 + (( +# 936 "user/mpy/py/parse.c" + (rule->act & (0x30)) == (0x30) +# 936 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 936, __func__, +# 936 "user/mpy/py/parse.c" + "(rule->act & RULE_ACT_KIND_MASK) == RULE_ACT_LIST" +# 936 "user/mpy/py/parse.c" 3 + )) +# 936 "user/mpy/py/parse.c" + ; + + + + + +# 941 "user/mpy/py/parse.c" 3 4 + _Bool +# 941 "user/mpy/py/parse.c" + had_trailing_sep; + if (backtrack) { + list_backtrack: + had_trailing_sep = +# 944 "user/mpy/py/parse.c" 3 4 + 0 +# 944 "user/mpy/py/parse.c" + ; + if (n == 2) { + if (i == 1) { + + goto next_rule; + } else { + + backtrack = +# 951 "user/mpy/py/parse.c" 3 4 + 0 +# 951 "user/mpy/py/parse.c" + ; + } + } else { + if (i == 1) { + + goto next_rule; + } else if ((i & 1) == 1) { + + if (n == 3) { + + had_trailing_sep = +# 961 "user/mpy/py/parse.c" 3 4 + 1 +# 961 "user/mpy/py/parse.c" + ; + backtrack = +# 962 "user/mpy/py/parse.c" 3 4 + 0 +# 962 "user/mpy/py/parse.c" + ; + } else { + + goto syntax_error; + } + } else { + + backtrack = +# 969 "user/mpy/py/parse.c" 3 4 + 0 +# 969 "user/mpy/py/parse.c" + ; + } + } + } else { + for (;;) { + size_t arg = rule->arg[i & 1 & n]; + if ((arg & (0xf000)) == (0x1000)) { + if (lex->tok_kind == (arg & (0x0fff))) { + if (i & 1 & n) { + + } else { + push_result_token(&parser, rule); + } + mp_lexer_to_next(lex); + + i += 1; + } else { + + i += 1; + backtrack = +# 988 "user/mpy/py/parse.c" 3 4 + 1 +# 988 "user/mpy/py/parse.c" + ; + goto list_backtrack; + } + } else { + +# 992 "user/mpy/py/parse.c" 3 + (( +# 992 "user/mpy/py/parse.c" + (arg & (0xf000)) == (0x2000) +# 992 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 992, __func__, +# 992 "user/mpy/py/parse.c" + "(arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE" +# 992 "user/mpy/py/parse.c" 3 + )) +# 992 "user/mpy/py/parse.c" + ; + push_rule(&parser, rule_src_line, rule, i + 1); + push_rule_from_arg(&parser, arg); + goto next_rule; + } + } + } + +# 999 "user/mpy/py/parse.c" 3 + (( +# 999 "user/mpy/py/parse.c" + i >= 1 +# 999 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 999, __func__, +# 999 "user/mpy/py/parse.c" + "i >= 1" +# 999 "user/mpy/py/parse.c" 3 + )) +# 999 "user/mpy/py/parse.c" + ; + + + i -= 1; + if ((n & 1) && (rule->arg[1] & (0xf000)) == (0x1000)) { + + i = (i + 1) / 2; + } + + if (i == 1) { + + if (had_trailing_sep) { + + push_result_rule(&parser, rule_src_line, rule, i); + } else { + + } + } else { + push_result_rule(&parser, rule_src_line, rule, i); + } + break; + } + } + } + + + + + + + if (parser.cur_chunk != +# 1029 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 1029 "user/mpy/py/parse.c" + ) { + (void)((byte*)(m_realloc_maybe((parser.cur_chunk), sizeof(byte) * (sizeof(mp_parse_chunk_t) + parser.cur_chunk->union_.used), ( +# 1030 "user/mpy/py/parse.c" 3 4 + 0 +# 1030 "user/mpy/py/parse.c" + )))) + + + ; + parser.cur_chunk->alloc = parser.cur_chunk->union_.used; + parser.cur_chunk->union_.next = parser.tree.chunk; + parser.tree.chunk = parser.cur_chunk; + } + + if ( + lex->tok_kind != MP_TOKEN_END + || parser.result_stack_top == 0 + ) { + syntax_error:; + mp_obj_t exc; + if (lex->tok_kind == MP_TOKEN_INDENT) { + exc = mp_obj_new_exception_msg(&mp_type_IndentationError, + "unexpected indent"); + } else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) { + exc = mp_obj_new_exception_msg(&mp_type_IndentationError, + "unindent does not match any outer indentation level"); + } else { + exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, + "invalid syntax"); + } + + + mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); + nlr_jump(((void*)exc)); + } + + + +# 1062 "user/mpy/py/parse.c" 3 + (( +# 1062 "user/mpy/py/parse.c" + parser.result_stack_top == 1 +# 1062 "user/mpy/py/parse.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 1062, __func__, +# 1062 "user/mpy/py/parse.c" + "parser.result_stack_top == 1" +# 1062 "user/mpy/py/parse.c" 3 + )) +# 1062 "user/mpy/py/parse.c" + ; + parser.tree.root = parser.result_stack[0]; + + + ((void)(parser.rule_stack_alloc), m_free(parser.rule_stack)); + ((void)(parser.result_stack_alloc), m_free(parser.result_stack)); + + + mp_lexer_free(lex); + + return parser.tree; +} + +void mp_parse_tree_clear(mp_parse_tree_t *tree) { + mp_parse_chunk_t *chunk = tree->chunk; + while (chunk != +# 1077 "user/mpy/py/parse.c" 3 4 + ((void *)0) +# 1077 "user/mpy/py/parse.c" + ) { + mp_parse_chunk_t *next = chunk->union_.next; + ((void)(sizeof(mp_parse_chunk_t) + chunk->alloc), m_free(chunk)); + chunk = next; + } +} +# 1 "user/mpy/py/scope.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/scope.c" +# 27 "user/mpy/py/scope.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/scope.c" 2 + +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 30 "user/mpy/py/parse.h" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 31 "user/mpy/py/parse.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 + +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 33 "user/mpy/py/parse.h" 2 + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 30 "user/mpy/py/scope.c" 2 + + + + +static const uint8_t scope_simple_name_table[] = { + [SCOPE_MODULE] = MP_QSTR__lt_module_gt_, + [SCOPE_LAMBDA] = MP_QSTR__lt_lambda_gt_, + [SCOPE_LIST_COMP] = MP_QSTR__lt_listcomp_gt_, + [SCOPE_DICT_COMP] = MP_QSTR__lt_dictcomp_gt_, + [SCOPE_SET_COMP] = MP_QSTR__lt_setcomp_gt_, + [SCOPE_GEN_EXPR] = MP_QSTR__lt_genexpr_gt_, +}; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options) { + scope_t *scope = ((scope_t*)(m_malloc0(sizeof(scope_t) * (1)))); + scope->kind = kind; + scope->pn = pn; + scope->source_file = source_file; + if (kind == SCOPE_FUNCTION || kind == SCOPE_CLASS) { + +# 49 "user/mpy/py/scope.c" 3 + (( +# 49 "user/mpy/py/scope.c" + ((pn) != (0) && ((pn) & 3) == 0) +# 49 "user/mpy/py/scope.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 49, __func__, +# 49 "user/mpy/py/scope.c" + "MP_PARSE_NODE_IS_STRUCT(pn)" +# 49 "user/mpy/py/scope.c" 3 + )) +# 49 "user/mpy/py/scope.c" + ; + scope->simple_name = (((uintptr_t)(((mp_parse_node_struct_t*)pn)->nodes[0])) >> 4); + } else { + scope->simple_name = scope_simple_name_table[kind]; + } + scope->raw_code = mp_emit_glue_new_raw_code(); + scope->emit_options = emit_options; + scope->id_info_alloc = (4); + scope->id_info = ((id_info_t*)(m_malloc(sizeof(id_info_t) * (scope->id_info_alloc)))); + + return scope; +} + +void scope_free(scope_t *scope) { + ((void)(scope->id_info_alloc), m_free(scope->id_info)); + ((void)(1), m_free(scope)); +} + +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qst, +# 67 "user/mpy/py/scope.c" 3 4 + _Bool +# 67 "user/mpy/py/scope.c" + *added) { + id_info_t *id_info = scope_find(scope, qst); + if (id_info != +# 69 "user/mpy/py/scope.c" 3 4 + ((void *)0) +# 69 "user/mpy/py/scope.c" + ) { + *added = +# 70 "user/mpy/py/scope.c" 3 4 + 0 +# 70 "user/mpy/py/scope.c" + ; + return id_info; + } + + + if (scope->id_info_len >= scope->id_info_alloc) { + scope->id_info = ((id_info_t*)(m_realloc((scope->id_info), sizeof(id_info_t) * (scope->id_info_alloc + (6))))); + scope->id_info_alloc += (6); + } + + + + + id_info = &scope->id_info[scope->id_info_len++]; + + id_info->kind = 0; + id_info->flags = 0; + id_info->local_num = 0; + id_info->qst = qst; + *added = +# 89 "user/mpy/py/scope.c" 3 4 + 1 +# 89 "user/mpy/py/scope.c" + ; + return id_info; +} + +id_info_t *scope_find(scope_t *scope, qstr qst) { + for (mp_uint_t i = 0; i < scope->id_info_len; i++) { + if (scope->id_info[i].qst == qst) { + return &scope->id_info[i]; + } + } + return +# 99 "user/mpy/py/scope.c" 3 4 + ((void *)0) +# 99 "user/mpy/py/scope.c" + ; +} + +id_info_t *scope_find_global(scope_t *scope, qstr qst) { + while (scope->parent != +# 103 "user/mpy/py/scope.c" 3 4 + ((void *)0) +# 103 "user/mpy/py/scope.c" + ) { + scope = scope->parent; + } + return scope_find(scope, qst); +} + +static void scope_close_over_in_parents(scope_t *scope, qstr qst) { + +# 110 "user/mpy/py/scope.c" 3 + (( +# 110 "user/mpy/py/scope.c" + scope->parent != +# 110 "user/mpy/py/scope.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 110, __func__, +# 110 "user/mpy/py/scope.c" + "scope->parent != NULL" +# 110 "user/mpy/py/scope.c" 3 + )) +# 110 "user/mpy/py/scope.c" + ; + for (scope_t *s = scope->parent;; s = s->parent) { + +# 112 "user/mpy/py/scope.c" 3 + (( +# 112 "user/mpy/py/scope.c" + s->parent != +# 112 "user/mpy/py/scope.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 112, __func__, +# 112 "user/mpy/py/scope.c" + "s->parent != NULL" +# 112 "user/mpy/py/scope.c" 3 + )) +# 112 "user/mpy/py/scope.c" + ; + +# 113 "user/mpy/py/scope.c" 3 4 + _Bool +# 113 "user/mpy/py/scope.c" + added; + id_info_t *id = scope_find_or_add_id(s, qst, &added); + if (added) { + + id->kind = ID_INFO_KIND_FREE; + } else { + + if (id->kind == ID_INFO_KIND_LOCAL) { + + id->kind = ID_INFO_KIND_CELL; + } else { + + + +# 126 "user/mpy/py/scope.c" 3 + (( +# 126 "user/mpy/py/scope.c" + id->kind == ID_INFO_KIND_FREE || id->kind == ID_INFO_KIND_CELL +# 126 "user/mpy/py/scope.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 126, __func__, +# 126 "user/mpy/py/scope.c" + "id->kind == ID_INFO_KIND_FREE || id->kind == ID_INFO_KIND_CELL" +# 126 "user/mpy/py/scope.c" 3 + )) +# 126 "user/mpy/py/scope.c" + ; + } + return; + } + } +} + +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst) { + if (scope->parent != +# 134 "user/mpy/py/scope.c" 3 4 + ((void *)0) +# 134 "user/mpy/py/scope.c" + ) { + for (scope_t *s = scope->parent; s->parent != +# 135 "user/mpy/py/scope.c" 3 4 + ((void *)0) +# 135 "user/mpy/py/scope.c" + ; s = s->parent) { + id_info_t *id2 = scope_find(s, qst); + if (id2 != +# 137 "user/mpy/py/scope.c" 3 4 + ((void *)0) +# 137 "user/mpy/py/scope.c" + ) { + if (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE) { + id->kind = ID_INFO_KIND_FREE; + scope_close_over_in_parents(scope, qst); + return; + } + break; + } + } + } + id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; +} +# 1 "user/mpy/py/compile.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/compile.c" +# 27 "user/mpy/py/compile.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 28 "user/mpy/py/compile.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 29 "user/mpy/py/compile.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 30 "user/mpy/py/compile.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/compile.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/compile.c" 2 + +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 35 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 33 "user/mpy/py/parse.h" 2 + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 34 "user/mpy/py/compile.c" 2 +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 + +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 35 "user/mpy/py/compile.c" 2 +# 1 "user/mpy/py/compile.h" 1 +# 34 "user/mpy/py/compile.h" +enum { + MP_EMIT_OPT_NONE, + MP_EMIT_OPT_BYTECODE, + MP_EMIT_OPT_NATIVE_PYTHON, + MP_EMIT_OPT_VIPER, + MP_EMIT_OPT_ASM, +}; + + + +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, +# 44 "user/mpy/py/compile.h" 3 4 + _Bool +# 44 "user/mpy/py/compile.h" + is_repl); + + + + + + + +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); +# 36 "user/mpy/py/compile.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/compile.c" 2 +# 1 "user/mpy/py/asmbase.h" 1 +# 35 "user/mpy/py/asmbase.h" +typedef struct _mp_asm_base_t { + int pass; + size_t code_offset; + size_t code_size; + uint8_t *code_base; + + size_t max_num_labels; + size_t *label_offsets; +} mp_asm_base_t; + +void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); +void mp_asm_base_deinit(mp_asm_base_t *as, +# 46 "user/mpy/py/asmbase.h" 3 4 + _Bool +# 46 "user/mpy/py/asmbase.h" + free_code); +void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); +uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); +void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); +void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); +void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); + +static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { + return as->code_offset; +} + +static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { + return as->code_size; +} + +static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { + + + + return as->code_base; + +} +# 38 "user/mpy/py/compile.c" 2 + + + + + + + +typedef enum { + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" + +PN_file_input, +PN_file_input_2, + + + +# 58 "user/mpy/py/grammar.h" + + +PN_decorated, + + + + + + +PN_funcdef, + + + + + + + + + + + + + + + + + + + + + + + + + + +PN_simple_stmt_2, + + + + + + + + +PN_expr_stmt, + + + + + +PN_testlist_star_expr, + + +# 122 "user/mpy/py/grammar.h" +PN_del_stmt, +PN_pass_stmt, + +PN_break_stmt, +PN_continue_stmt, +PN_return_stmt, +PN_yield_stmt, +PN_raise_stmt, + + +# 145 "user/mpy/py/grammar.h" + +PN_import_name, +PN_import_from, + + + + + + + + + + + + +PN_global_stmt, +PN_nonlocal_stmt, + +PN_assert_stmt, + +# 183 "user/mpy/py/grammar.h" + + +PN_if_stmt, + + +PN_while_stmt, +PN_for_stmt, +PN_try_stmt, + + + + + + + +PN_with_stmt, + + + + + +PN_suite_block_stmts, + + + + + + + +PN_test_if_expr, + + +PN_lambdef, +PN_lambdef_nocond, +# 234 "user/mpy/py/grammar.h" +PN_or_test, +PN_and_test, + +PN_not_test_2, +PN_comparison, + + + + +PN_star_expr, +PN_expr, +PN_xor_expr, +PN_and_expr, +PN_shift_expr, + +PN_arith_expr, + +PN_term, + + +PN_factor_2, + +PN_power, + + + + + + +PN_atom_expr_normal, + + + + + + + + +PN_atom_paren, + +PN_atom_bracket, +PN_atom_brace, + + + + + + +PN_trailer_paren, +PN_trailer_bracket, +PN_trailer_period, +# 300 "user/mpy/py/grammar.h" +PN_subscriptlist, + + + + + + + + +PN_testlist, + + + + + + +PN_dictorsetmaker_item, + + + + + + + +PN_classdef, + + + + + + + + + +# 342 "user/mpy/py/grammar.h" + + + + + + + + + + + + + +PN_yield_expr, + + +# 50 "user/mpy/py/compile.c" 2 + + + PN_const_object, + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" +PN_single_input, + + +PN_file_input_3, +PN_eval_input, +PN_eval_input_2, +# 58 "user/mpy/py/grammar.h" +PN_decorator, +PN_decorators, + + + + + +PN_decorated_body, + + +PN_funcdefrettype, + +PN_typedargslist, +PN_typedargslist_item, +PN_typedargslist_name, +PN_typedargslist_star, +PN_typedargslist_dbl_star, +PN_typedargslist_colon, +PN_typedargslist_equal, +PN_tfpdef, + +PN_varargslist, +PN_varargslist_item, +PN_varargslist_name, +PN_varargslist_star, +PN_varargslist_dbl_star, +PN_varargslist_equal, +PN_vfpdef, + + + +PN_stmt, + + + +PN_simple_stmt, + + + + + + + + +PN_small_stmt, + +PN_expr_stmt_2, +PN_expr_stmt_augassign, +PN_expr_stmt_assign_list, +PN_expr_stmt_assign, +PN_expr_stmt_6, + +PN_testlist_star_expr_2, +PN_augassign, +# 122 "user/mpy/py/grammar.h" + + +PN_flow_stmt, + + + + + +PN_raise_stmt_arg, +PN_raise_stmt_from, +# 145 "user/mpy/py/grammar.h" +PN_import_stmt, + + +PN_import_from_2, +PN_import_from_2b, +PN_import_from_3, +PN_import_as_names_paren, +PN_one_or_more_period_or_ellipsis, +PN_period_or_ellipsis, +PN_import_as_name, +PN_dotted_as_name, +PN_as_name, +PN_import_as_names, +PN_dotted_as_names, +PN_dotted_name, + + +PN_name_list, + +PN_assert_stmt_extra, +# 183 "user/mpy/py/grammar.h" +PN_compound_stmt, + + +PN_if_stmt_elif_list, +PN_if_stmt_elif, + + + +PN_try_stmt_2, +PN_try_stmt_except_and_more, +PN_try_stmt_except, +PN_try_stmt_as_name, +PN_try_stmt_except_list, +PN_try_stmt_finally, +PN_else_stmt, + +PN_with_stmt_list, +PN_with_item, +PN_with_item_as, +PN_suite, +PN_suite_block, + + + + + + + +PN_test, + +PN_test_if_else, +PN_test_nocond, + + +# 234 "user/mpy/py/grammar.h" + + +PN_not_test, + + +PN_comp_op, +PN_comp_op_not_in, +PN_comp_op_is, +PN_comp_op_is_not, + + + + + +PN_shift_op, + +PN_arith_op, + +PN_term_op, +PN_factor, + +PN_factor_op, + + + + + +PN_atom_expr, + + +PN_atom_expr_trailers, +PN_power_dbl_star, + + + + + +PN_atom, + +PN_atom_2b, + + +PN_testlist_comp, +PN_testlist_comp_2, +PN_testlist_comp_3, +PN_testlist_comp_3b, +PN_testlist_comp_3c, +PN_trailer, + + + +# 300 "user/mpy/py/grammar.h" + + + + + + + +PN_exprlist, +PN_exprlist_2, + + +PN_dictorsetmaker, + + + + + + +PN_dictorsetmaker_tail, +PN_dictorsetmaker_list, +PN_dictorsetmaker_list2, + + + + +PN_classdef_2, + + + + +PN_arglist, +PN_arglist_2, +PN_arglist_star, +PN_arglist_dbl_star, +# 342 "user/mpy/py/grammar.h" +PN_argument, +PN_argument_2, +PN_argument_3, +PN_comp_iter, +PN_comp_for, +PN_comp_if, + + + + + + + + +PN_yield_arg, +PN_yield_arg_from, +# 57 "user/mpy/py/compile.c" 2 + + +} pn_kind_t; +# 115 "user/mpy/py/compile.c" +typedef struct _compiler_t { + qstr source_file; + + uint8_t is_repl; + uint8_t pass; + uint8_t have_star; + + + mp_obj_t compile_error; + size_t compile_error_line; + + uint next_label; + + uint16_t num_dict_params; + uint16_t num_default_params; + + uint16_t break_label; + uint16_t continue_label; + uint16_t cur_except_level; + uint16_t break_continue_except_level; + + scope_t *scope_head; + scope_t *scope_cur; + + emit_t *emit; +# 148 "user/mpy/py/compile.c" +} compiler_t; + +static void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) { + + if (comp->compile_error_line == 0 && ((pn) != (0) && ((pn) & 3) == 0)) { + comp->compile_error_line = ((mp_parse_node_struct_t*)pn)->source_line; + } +} + +static void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const char *msg) { + + if (comp->compile_error == (((mp_obj_t)(void*)0))) { + comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); + compile_error_set_line(comp, pn); + } +} + +static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, +# 165 "user/mpy/py/compile.c" 3 4 + _Bool +# 165 "user/mpy/py/compile.c" + is_method_call, int n_positional_extra); +static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind); +static void compile_node(compiler_t *comp, mp_parse_node_t pn); + +static uint comp_next_label(compiler_t *comp) { + return comp->next_label++; +} + +static void compile_increase_except_level(compiler_t *comp) { + comp->cur_except_level += 1; + if (comp->cur_except_level > comp->scope_cur->exc_stack_size) { + comp->scope_cur->exc_stack_size = comp->cur_except_level; + } +} + +static void compile_decrease_except_level(compiler_t *comp) { + +# 181 "user/mpy/py/compile.c" 3 + (( +# 181 "user/mpy/py/compile.c" + comp->cur_except_level > 0 +# 181 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 181, __func__, +# 181 "user/mpy/py/compile.c" + "comp->cur_except_level > 0" +# 181 "user/mpy/py/compile.c" 3 + )) +# 181 "user/mpy/py/compile.c" + ; + comp->cur_except_level -= 1; +} + +static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) { + scope_t *scope = scope_new(kind, pn, comp->source_file, emit_options); + scope->parent = comp->scope_cur; + scope->next = +# 188 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 188 "user/mpy/py/compile.c" + ; + if (comp->scope_head == +# 189 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 189 "user/mpy/py/compile.c" + ) { + comp->scope_head = scope; + } else { + scope_t *s = comp->scope_head; + while (s->next != +# 193 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 193 "user/mpy/py/compile.c" + ) { + s = s->next; + } + s->next = scope; + } + return scope; +} + +typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn); + +static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) { + if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (pn_list_kind))) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + int num_nodes = ((pns)->kind_num_nodes >> 8); + for (int i = 0; i < num_nodes; i++) { + f(comp, pns->nodes[i]); + } + } else if (!((pn) == (0))) { + f(comp, pn); + } +} + +static void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) { + int num_nodes = ((pns)->kind_num_nodes >> 8); + for (int i = 0; i < num_nodes; i++) { + compile_node(comp, pns->nodes[i]); + if (comp->compile_error != (((mp_obj_t)(void*)0))) { + + compile_error_set_line(comp, pns->nodes[i]); + return; + } + } +} + +static void compile_load_id(compiler_t *comp, qstr qst) { + if (comp->pass == MP_PASS_SCOPE) { + mp_emit_common_get_id_for_load(comp->scope_cur, qst); + } else { + + + + mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_load_id_ops, comp->scope_cur, qst); + + } +} + +static void compile_store_id(compiler_t *comp, qstr qst) { + if (comp->pass == MP_PASS_SCOPE) { + mp_emit_common_get_id_for_modification(comp->scope_cur, qst); + } else { + + + + mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_store_id_ops, comp->scope_cur, qst); + + } +} + +static void compile_delete_id(compiler_t *comp, qstr qst) { + if (comp->pass == MP_PASS_SCOPE) { + mp_emit_common_get_id_for_modification(comp->scope_cur, qst); + } else { + + + + mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_delete_id_ops, comp->scope_cur, qst); + + } +} + +static void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) { + int total = 0; + if (!((pn) == (0))) { + compile_node(comp, pn); + total += 1; + } + if (pns_list != +# 269 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 269 "user/mpy/py/compile.c" + ) { + int n = ((pns_list)->kind_num_nodes >> 8); + for (int i = 0; i < n; i++) { + compile_node(comp, pns_list->nodes[i]); + } + total += n; + } + (mp_emit_bc_build_tuple(comp->emit, total)); +} + +static void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) { + + c_tuple(comp, (0), pns); +} + +static void c_if_cond(compiler_t *comp, mp_parse_node_t pn, +# 284 "user/mpy/py/compile.c" 3 4 + _Bool +# 284 "user/mpy/py/compile.c" + jump_if, int label) { + if (mp_parse_node_is_const_false(pn)) { + if (jump_if == +# 286 "user/mpy/py/compile.c" 3 4 + 0 +# 286 "user/mpy/py/compile.c" + ) { + (mp_emit_bc_jump(comp->emit, label)); + } + return; + } else if (mp_parse_node_is_const_true(pn)) { + if (jump_if == +# 291 "user/mpy/py/compile.c" 3 4 + 1 +# 291 "user/mpy/py/compile.c" + ) { + (mp_emit_bc_jump(comp->emit, label)); + } + return; + } else if (((pn) != (0) && ((pn) & 3) == 0)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + int n = ((pns)->kind_num_nodes >> 8); + if (((pns)->kind_num_nodes & 0xff) == PN_or_test) { + if (jump_if == +# 299 "user/mpy/py/compile.c" 3 4 + 0 +# 299 "user/mpy/py/compile.c" + ) { + and_or_logic1:; + uint label2 = comp_next_label(comp); + for (int i = 0; i < n - 1; i++) { + c_if_cond(comp, pns->nodes[i], !jump_if, label2); + } + c_if_cond(comp, pns->nodes[n - 1], jump_if, label); + (mp_emit_bc_label_assign(comp->emit, label2)); + } else { + and_or_logic2: + for (int i = 0; i < n; i++) { + c_if_cond(comp, pns->nodes[i], jump_if, label); + } + } + return; + } else if (((pns)->kind_num_nodes & 0xff) == PN_and_test) { + if (jump_if == +# 315 "user/mpy/py/compile.c" 3 4 + 0 +# 315 "user/mpy/py/compile.c" + ) { + goto and_or_logic2; + } else { + goto and_or_logic1; + } + } else if (((pns)->kind_num_nodes & 0xff) == PN_not_test_2) { + c_if_cond(comp, pns->nodes[0], !jump_if, label); + return; + } else if (((pns)->kind_num_nodes & 0xff) == PN_atom_paren) { + + if (((pns->nodes[0]) == (0))) { + + if (jump_if == +# 327 "user/mpy/py/compile.c" 3 4 + 0 +# 327 "user/mpy/py/compile.c" + ) { + (mp_emit_bc_jump(comp->emit, label)); + } + } else { + +# 331 "user/mpy/py/compile.c" 3 + (( +# 331 "user/mpy/py/compile.c" + ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp)) +# 331 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 331, __func__, +# 331 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)" +# 331 "user/mpy/py/compile.c" 3 + )) +# 331 "user/mpy/py/compile.c" + ; + + if (jump_if == +# 333 "user/mpy/py/compile.c" 3 4 + 1 +# 333 "user/mpy/py/compile.c" + ) { + (mp_emit_bc_jump(comp->emit, label)); + } + } + return; + } + } + + + compile_node(comp, pn); + (mp_emit_bc_pop_jump_if(comp->emit, jump_if, label)); +} + +typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t; +static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind); + +static void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) { + if (assign_kind != ASSIGN_AUG_STORE) { + compile_node(comp, pns->nodes[0]); + } + + if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns1)->kind_num_nodes & 0xff) == PN_atom_expr_trailers) { + int n = ((pns1)->kind_num_nodes >> 8); + if (assign_kind != ASSIGN_AUG_STORE) { + for (int i = 0; i < n - 1; i++) { + compile_node(comp, pns1->nodes[i]); + } + } + +# 363 "user/mpy/py/compile.c" 3 + (( +# 363 "user/mpy/py/compile.c" + ((pns1->nodes[n - 1]) != (0) && ((pns1->nodes[n - 1]) & 3) == 0) +# 363 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 363, __func__, +# 363 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])" +# 363 "user/mpy/py/compile.c" 3 + )) +# 363 "user/mpy/py/compile.c" + ; + pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; + } + if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_bracket) { + if (assign_kind == ASSIGN_AUG_STORE) { + (mp_emit_bc_rot_three(comp->emit)); + (mp_emit_bc_store_subscr(comp->emit)); + } else { + compile_node(comp, pns1->nodes[0]); + if (assign_kind == ASSIGN_AUG_LOAD) { + (mp_emit_bc_dup_top_two(comp->emit)); + (mp_emit_bc_load_subscr(comp->emit)); + } else { + (mp_emit_bc_store_subscr(comp->emit)); + } + } + } else if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_period) { + +# 380 "user/mpy/py/compile.c" 3 + (( +# 380 "user/mpy/py/compile.c" + (((pns1->nodes[0]) & 0x0f) == (0x02)) +# 380 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 380, __func__, +# 380 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_ID(pns1->nodes[0])" +# 380 "user/mpy/py/compile.c" 3 + )) +# 380 "user/mpy/py/compile.c" + ; + if (assign_kind == ASSIGN_AUG_LOAD) { + (mp_emit_bc_dup_top(comp->emit)); + (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(pns1->nodes[0])) >> 4))); + } else { + if (assign_kind == ASSIGN_AUG_STORE) { + (mp_emit_bc_rot_two(comp->emit)); + } + (mp_emit_bc_store_attr(comp->emit, (((uintptr_t)(pns1->nodes[0])) >> 4))); + } + } else { + goto cannot_assign; + } + } else { + goto cannot_assign; + } + + return; + +cannot_assign: + compile_syntax_error(comp, (mp_parse_node_t)pns, "can't assign to expression"); +} + + +static void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num_tail, mp_parse_node_t *nodes_tail) { + uint num_head = (node_head == (0)) ? 0 : 1; + + + uint have_star_index = -1; + if (num_head != 0 && ((node_head) != (0) && ((node_head) & 3) == 0 && (((mp_parse_node_struct_t*)(node_head))->kind_num_nodes & 0xff) == (PN_star_expr))) { + (mp_emit_bc_unpack_ex(comp->emit, 0, num_tail)); + have_star_index = 0; + } + for (uint i = 0; i < num_tail; i++) { + if (((nodes_tail[i]) != (0) && ((nodes_tail[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(nodes_tail[i]))->kind_num_nodes & 0xff) == (PN_star_expr))) { + if (have_star_index == (uint)-1) { + (mp_emit_bc_unpack_ex(comp->emit, num_head + i, num_tail - i - 1)); + have_star_index = num_head + i; + } else { + compile_syntax_error(comp, nodes_tail[i], "multiple *x in assignment"); + return; + } + } + } + if (have_star_index == (uint)-1) { + (mp_emit_bc_unpack_sequence(comp->emit, num_head + num_tail)); + } + if (num_head != 0) { + if (0 == have_star_index) { + c_assign(comp, ((mp_parse_node_struct_t*)node_head)->nodes[0], ASSIGN_STORE); + } else { + c_assign(comp, node_head, ASSIGN_STORE); + } + } + for (uint i = 0; i < num_tail; i++) { + if (num_head + i == have_star_index) { + c_assign(comp, ((mp_parse_node_struct_t*)nodes_tail[i])->nodes[0], ASSIGN_STORE); + } else { + c_assign(comp, nodes_tail[i], ASSIGN_STORE); + } + } +} + + +static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) { + +# 445 "user/mpy/py/compile.c" 3 + (( +# 445 "user/mpy/py/compile.c" + !((pn) == (0)) +# 445 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 445, __func__, +# 445 "user/mpy/py/compile.c" + "!MP_PARSE_NODE_IS_NULL(pn)" +# 445 "user/mpy/py/compile.c" 3 + )) +# 445 "user/mpy/py/compile.c" + ; + if (((pn) & 3)) { + if ((((pn) & 0x0f) == (0x02))) { + qstr arg = (((uintptr_t)(pn)) >> 4); + switch (assign_kind) { + case ASSIGN_STORE: + case ASSIGN_AUG_STORE: + compile_store_id(comp, arg); + break; + case ASSIGN_AUG_LOAD: + default: + compile_load_id(comp, arg); + break; + } + } else { + goto cannot_assign; + } + } else { + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + switch (((pns)->kind_num_nodes & 0xff)) { + case PN_atom_expr_normal: + + c_assign_atom_expr(comp, pns, assign_kind); + break; + + case PN_testlist_star_expr: + case PN_exprlist: + + if (assign_kind != ASSIGN_STORE) { + goto cannot_assign; + } + c_assign_tuple(comp, (0), ((pns)->kind_num_nodes >> 8), pns->nodes); + break; + + case PN_atom_paren: + + if (((pns->nodes[0]) == (0))) { + + goto cannot_assign; + } else { + +# 486 "user/mpy/py/compile.c" 3 + (( +# 486 "user/mpy/py/compile.c" + ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp)) +# 486 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 486, __func__, +# 486 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)" +# 486 "user/mpy/py/compile.c" 3 + )) +# 486 "user/mpy/py/compile.c" + ; + if (assign_kind != ASSIGN_STORE) { + goto cannot_assign; + } + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + goto testlist_comp; + } + break; + + case PN_atom_bracket: + + if (assign_kind != ASSIGN_STORE) { + goto cannot_assign; + } + if (((pns->nodes[0]) == (0))) { + + c_assign_tuple(comp, (0), 0, +# 502 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 502 "user/mpy/py/compile.c" + ); + } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp))) { + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + goto testlist_comp; + } else { + + c_assign_tuple(comp, pns->nodes[0], 0, +# 508 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 508 "user/mpy/py/compile.c" + ); + } + break; + + default: + goto cannot_assign; + } + return; + + testlist_comp: + + if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { + + +# 523 "user/mpy/py/compile.c" 3 + (( +# 523 "user/mpy/py/compile.c" + ((pns2->nodes[0]) == (0)) +# 523 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 523, __func__, +# 523 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_NULL(pns2->nodes[0])" +# 523 "user/mpy/py/compile.c" 3 + )) +# 523 "user/mpy/py/compile.c" + ; + c_assign_tuple(comp, pns->nodes[0], 0, +# 524 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 524 "user/mpy/py/compile.c" + ); + } else if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { + + uint n = ((pns2)->kind_num_nodes >> 8); + c_assign_tuple(comp, pns->nodes[0], n, pns2->nodes); + } else if (((pns2)->kind_num_nodes & 0xff) == PN_comp_for) { + goto cannot_assign; + } else { + + goto sequence_with_2_items; + } + } else { + + sequence_with_2_items: + c_assign_tuple(comp, (0), 2, pns->nodes); + } + return; + } + return; + + cannot_assign: + compile_syntax_error(comp, pn, "can't assign to expression"); +} + + + + + +static void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) { + +# 553 "user/mpy/py/compile.c" 3 + (( +# 553 "user/mpy/py/compile.c" + n_pos_defaults >= 0 +# 553 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 553, __func__, +# 553 "user/mpy/py/compile.c" + "n_pos_defaults >= 0" +# 553 "user/mpy/py/compile.c" 3 + )) +# 553 "user/mpy/py/compile.c" + ; + +# 554 "user/mpy/py/compile.c" 3 + (( +# 554 "user/mpy/py/compile.c" + n_kw_defaults >= 0 +# 554 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 554, __func__, +# 554 "user/mpy/py/compile.c" + "n_kw_defaults >= 0" +# 554 "user/mpy/py/compile.c" 3 + )) +# 554 "user/mpy/py/compile.c" + ; + + + if (n_kw_defaults > 0) { + this_scope->scope_flags |= (0x08); + } + this_scope->num_def_pos_args = n_pos_defaults; + + + + int nfree = 0; + if (comp->scope_cur->kind != SCOPE_MODULE) { + for (int i = 0; i < comp->scope_cur->id_info_len; i++) { + id_info_t *id = &comp->scope_cur->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { + for (int j = 0; j < this_scope->id_info_len; j++) { + id_info_t *id2 = &this_scope->id_info[j]; + if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { + + (mp_emit_bc_load_fast(comp->emit, id->qst, id->local_num)); + nfree += 1; + } + } + } + } + } + + + if (nfree == 0) { + (mp_emit_bc_make_function(comp->emit, this_scope, n_pos_defaults, n_kw_defaults)); + } else { + (mp_emit_bc_make_closure(comp->emit, this_scope, nfree, n_pos_defaults, n_kw_defaults)); + } +} + +static void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) { + + int pn_kind; + if ((((pn) & 0x0f) == (0x02))) { + pn_kind = -1; + } else { + +# 595 "user/mpy/py/compile.c" 3 + (( +# 595 "user/mpy/py/compile.c" + ((pn) != (0) && ((pn) & 3) == 0) +# 595 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 595, __func__, +# 595 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pn)" +# 595 "user/mpy/py/compile.c" 3 + )) +# 595 "user/mpy/py/compile.c" + ; + pn_kind = (((mp_parse_node_struct_t*)pn)->kind_num_nodes & 0xff); + } + + if (pn_kind == PN_typedargslist_star || pn_kind == PN_varargslist_star) { + comp->have_star = +# 600 "user/mpy/py/compile.c" 3 4 + 1 +# 600 "user/mpy/py/compile.c" + ; +# 610 "user/mpy/py/compile.c" + } else if (pn_kind == PN_typedargslist_dbl_star || pn_kind == PN_varargslist_dbl_star) { + + + + } else { + mp_parse_node_t pn_id; + mp_parse_node_t pn_colon; + mp_parse_node_t pn_equal; + if (pn_kind == -1) { + + + pn_id = pn; + pn_colon = (0); + pn_equal = (0); + + } else if (pn_kind == PN_typedargslist_name) { + + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + pn_id = pns->nodes[0]; + pn_colon = pns->nodes[1]; + pn_equal = pns->nodes[2]; + + } else { + +# 634 "user/mpy/py/compile.c" 3 + (( +# 634 "user/mpy/py/compile.c" + pn_kind == PN_varargslist_name +# 634 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 634, __func__, +# 634 "user/mpy/py/compile.c" + "pn_kind == PN_varargslist_name" +# 634 "user/mpy/py/compile.c" 3 + )) +# 634 "user/mpy/py/compile.c" + ; + + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + pn_id = pns->nodes[0]; + pn_equal = pns->nodes[1]; + } + + if (((pn_equal) == (0))) { + + + + if (!comp->have_star && comp->num_default_params != 0) { + compile_syntax_error(comp, pn, "non-default argument follows default argument"); + return; + } + + } else { + + + + if (comp->have_star) { + comp->num_dict_params += 1; + + if (comp->num_dict_params == 1) { + + + if (comp->num_default_params > 0) { + (mp_emit_bc_build_tuple(comp->emit, comp->num_default_params)); + } else { + (mp_emit_bc_load_null(comp->emit)); + } + + (mp_emit_bc_build_map(comp->emit, 0)); + } + + + compile_node(comp, pn_equal); + (mp_emit_bc_load_const_str(comp->emit, (((uintptr_t)(pn_id)) >> 4))); + (mp_emit_bc_store_map(comp->emit)); + } else { + comp->num_default_params += 1; + compile_node(comp, pn_equal); + } + } + + + (void)pn_colon; + } +} + +static void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) { + + + + +# 689 "user/mpy/py/compile.c" 3 4 + _Bool +# 689 "user/mpy/py/compile.c" + orig_have_star = comp->have_star; + uint16_t orig_num_dict_params = comp->num_dict_params; + uint16_t orig_num_default_params = comp->num_default_params; + + + comp->have_star = +# 694 "user/mpy/py/compile.c" 3 4 + 0 +# 694 "user/mpy/py/compile.c" + ; + comp->num_dict_params = 0; + comp->num_default_params = 0; + apply_to_single_or_list(comp, pn_params, pn_list_kind, compile_funcdef_lambdef_param); + + if (comp->compile_error != (((mp_obj_t)(void*)0))) { + return; + } + + + + if (comp->num_default_params > 0 && comp->num_dict_params == 0) { + (mp_emit_bc_build_tuple(comp->emit, comp->num_default_params)); + (mp_emit_bc_load_null(comp->emit)); + } + + + close_over_variables_etc(comp, scope, comp->num_default_params, comp->num_dict_params); + + + comp->have_star = orig_have_star; + comp->num_dict_params = orig_num_dict_params; + comp->num_default_params = orig_num_default_params; +} + + + +static qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { + if (comp->pass == MP_PASS_SCOPE) { + + scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options); + + pns->nodes[4] = (mp_parse_node_t)s; + } + + + scope_t *fscope = (scope_t*)pns->nodes[4]; + + + compile_funcdef_lambdef(comp, fscope, pns->nodes[1], PN_typedargslist); + + + return fscope->simple_name; +} + + + +static qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { + if (comp->pass == MP_PASS_SCOPE) { + + scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options); + + pns->nodes[3] = (mp_parse_node_t)s; + } + + (mp_emit_bc_load_build_class(comp->emit)); + + + scope_t *cscope = (scope_t*)pns->nodes[3]; + + + close_over_variables_etc(comp, cscope, 0, 0); + + + (mp_emit_bc_load_const_str(comp->emit, cscope->simple_name)); + + + + mp_parse_node_t parents = pns->nodes[1]; + if (((parents) != (0) && ((parents) & 3) == 0 && (((mp_parse_node_struct_t*)(parents))->kind_num_nodes & 0xff) == (PN_classdef_2))) { + parents = (0); + } + compile_trailer_paren_helper(comp, parents, +# 766 "user/mpy/py/compile.c" 3 4 + 0 +# 766 "user/mpy/py/compile.c" + , 2); + + + return cscope->simple_name; +} + + +static +# 773 "user/mpy/py/compile.c" 3 4 + _Bool +# 773 "user/mpy/py/compile.c" + compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_node_t *name_nodes, uint *emit_options) { + if ((((uintptr_t)(name_nodes[0])) >> 4) != MP_QSTR_micropython) { + return +# 775 "user/mpy/py/compile.c" 3 4 + 0 +# 775 "user/mpy/py/compile.c" + ; + } + + if (name_len != 2) { + compile_syntax_error(comp, name_nodes[0], "invalid micropython decorator"); + return +# 780 "user/mpy/py/compile.c" 3 4 + 1 +# 780 "user/mpy/py/compile.c" + ; + } + + qstr attr = (((uintptr_t)(name_nodes[1])) >> 4); + if (attr == MP_QSTR_bytecode) { + *emit_options = MP_EMIT_OPT_BYTECODE; +# 796 "user/mpy/py/compile.c" + } else { + compile_syntax_error(comp, name_nodes[1], "invalid micropython decorator"); + } + + return +# 800 "user/mpy/py/compile.c" 3 4 + 1 +# 800 "user/mpy/py/compile.c" + ; +} + +static void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) { + + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes); + + + uint emit_options = comp->scope_cur->emit_options; + + + int num_built_in_decorators = 0; + for (int i = 0; i < n; i++) { + +# 814 "user/mpy/py/compile.c" 3 + (( +# 814 "user/mpy/py/compile.c" + ((nodes[i]) != (0) && ((nodes[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(nodes[i]))->kind_num_nodes & 0xff) == (PN_decorator)) +# 814 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 814, __func__, +# 814 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(nodes[i], PN_decorator)" +# 814 "user/mpy/py/compile.c" 3 + )) +# 814 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns_decorator = (mp_parse_node_struct_t*)nodes[i]; + + + mp_parse_node_t *name_nodes; + int name_len = mp_parse_node_extract_list(&pns_decorator->nodes[0], PN_dotted_name, &name_nodes); + + + if (compile_built_in_decorator(comp, name_len, name_nodes, &emit_options)) { + + num_built_in_decorators += 1; + + } else { + + + + compile_node(comp, name_nodes[0]); + for (int j = 1; j < name_len; j++) { + +# 832 "user/mpy/py/compile.c" 3 + (( +# 832 "user/mpy/py/compile.c" + (((name_nodes[j]) & 0x0f) == (0x02)) +# 832 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 832, __func__, +# 832 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_ID(name_nodes[j])" +# 832 "user/mpy/py/compile.c" 3 + )) +# 832 "user/mpy/py/compile.c" + ; + (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(name_nodes[j])) >> 4))); + } + + + if (!((pns_decorator->nodes[1]) == (0))) { + + compile_node(comp, pns_decorator->nodes[1]); + } + } + } + + + mp_parse_node_struct_t *pns_body = (mp_parse_node_struct_t*)pns->nodes[1]; + qstr body_name = 0; + if (((pns_body)->kind_num_nodes & 0xff) == PN_funcdef) { + body_name = compile_funcdef_helper(comp, pns_body, emit_options); +# 857 "user/mpy/py/compile.c" + } else { + +# 858 "user/mpy/py/compile.c" 3 + (( +# 858 "user/mpy/py/compile.c" + ((pns_body)->kind_num_nodes & 0xff) == PN_classdef +# 858 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 858, __func__, +# 858 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_classdef" +# 858 "user/mpy/py/compile.c" 3 + )) +# 858 "user/mpy/py/compile.c" + ; + body_name = compile_classdef_helper(comp, pns_body, emit_options); + } + + + for (int i = 0; i < n - num_built_in_decorators; i++) { + (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); + } + + + compile_store_id(comp, body_name); +} + +static void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) { + qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options); + + compile_store_id(comp, fname); +} + +static void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) { + if ((((pn) & 0x0f) == (0x02))) { + compile_delete_id(comp, (((uintptr_t)(pn)) >> 4)); + } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_atom_expr_normal))) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + + compile_node(comp, pns->nodes[0]); + + if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns1)->kind_num_nodes & 0xff) == PN_atom_expr_trailers) { + int n = ((pns1)->kind_num_nodes >> 8); + for (int i = 0; i < n - 1; i++) { + compile_node(comp, pns1->nodes[i]); + } + +# 892 "user/mpy/py/compile.c" 3 + (( +# 892 "user/mpy/py/compile.c" + ((pns1->nodes[n - 1]) != (0) && ((pns1->nodes[n - 1]) & 3) == 0) +# 892 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 892, __func__, +# 892 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])" +# 892 "user/mpy/py/compile.c" 3 + )) +# 892 "user/mpy/py/compile.c" + ; + pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; + } + if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_bracket) { + compile_node(comp, pns1->nodes[0]); + (mp_emit_bc_delete_subscr(comp->emit)); + } else if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_period) { + +# 899 "user/mpy/py/compile.c" 3 + (( +# 899 "user/mpy/py/compile.c" + (((pns1->nodes[0]) & 0x0f) == (0x02)) +# 899 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 899, __func__, +# 899 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_ID(pns1->nodes[0])" +# 899 "user/mpy/py/compile.c" 3 + )) +# 899 "user/mpy/py/compile.c" + ; + (mp_emit_bc_delete_attr(comp->emit, (((uintptr_t)(pns1->nodes[0])) >> 4))); + } else { + goto cannot_delete; + } + } else { + goto cannot_delete; + } + + } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_atom_paren))) { + pn = ((mp_parse_node_struct_t*)pn)->nodes[0]; + if (((pn) == (0))) { + goto cannot_delete; + } else { + +# 913 "user/mpy/py/compile.c" 3 + (( +# 913 "user/mpy/py/compile.c" + ((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_testlist_comp)) +# 913 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 913, __func__, +# 913 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp)" +# 913 "user/mpy/py/compile.c" 3 + )) +# 913 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + + + if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns1)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { + + +# 921 "user/mpy/py/compile.c" 3 + (( +# 921 "user/mpy/py/compile.c" + ((pns1->nodes[0]) == (0)) +# 921 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 921, __func__, +# 921 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_NULL(pns1->nodes[0])" +# 921 "user/mpy/py/compile.c" 3 + )) +# 921 "user/mpy/py/compile.c" + ; + c_del_stmt(comp, pns->nodes[0]); + } else if (((pns1)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { + + int n = ((pns1)->kind_num_nodes >> 8); + c_del_stmt(comp, pns->nodes[0]); + for (int i = 0; i < n; i++) { + c_del_stmt(comp, pns1->nodes[i]); + } + } else if (((pns1)->kind_num_nodes & 0xff) == PN_comp_for) { + goto cannot_delete; + } else { + + goto sequence_with_2_items; + } + } else { + + sequence_with_2_items: + c_del_stmt(comp, pns->nodes[0]); + c_del_stmt(comp, pns->nodes[1]); + } + } + } else { + + goto cannot_delete; + } + + return; + +cannot_delete: + compile_syntax_error(comp, (mp_parse_node_t)pn, "can't delete expression"); +} + +static void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt); +} + +static void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->break_label == (0xffff)) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' outside loop"); + } + +# 962 "user/mpy/py/compile.c" 3 + (( +# 962 "user/mpy/py/compile.c" + comp->cur_except_level >= comp->break_continue_except_level +# 962 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 962, __func__, +# 962 "user/mpy/py/compile.c" + "comp->cur_except_level >= comp->break_continue_except_level" +# 962 "user/mpy/py/compile.c" 3 + )) +# 962 "user/mpy/py/compile.c" + ; + (mp_emit_bc_unwind_jump(comp->emit, comp->break_label, comp->cur_except_level - comp->break_continue_except_level)); +} + +static void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->continue_label == (0xffff)) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' outside loop"); + } + +# 970 "user/mpy/py/compile.c" 3 + (( +# 970 "user/mpy/py/compile.c" + comp->cur_except_level >= comp->break_continue_except_level +# 970 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 970, __func__, +# 970 "user/mpy/py/compile.c" + "comp->cur_except_level >= comp->break_continue_except_level" +# 970 "user/mpy/py/compile.c" 3 + )) +# 970 "user/mpy/py/compile.c" + ; + (mp_emit_bc_unwind_jump(comp->emit, comp->continue_label, comp->cur_except_level - comp->break_continue_except_level)); +} + +static void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->scope_cur->kind != SCOPE_FUNCTION) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' outside function"); + return; + } + if (((pns->nodes[0]) == (0))) { + + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + } else if ((0) + && ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_test_if_expr))) { + + mp_parse_node_struct_t *pns_test_if_expr = (mp_parse_node_struct_t*)pns->nodes[0]; + mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns_test_if_expr->nodes[1]; + + uint l_fail = comp_next_label(comp); + c_if_cond(comp, pns_test_if_else->nodes[0], +# 989 "user/mpy/py/compile.c" 3 4 + 0 +# 989 "user/mpy/py/compile.c" + , l_fail); + compile_node(comp, pns_test_if_expr->nodes[0]); + (mp_emit_bc_return_value(comp->emit)); + (mp_emit_bc_label_assign(comp->emit, l_fail)); + compile_node(comp, pns_test_if_else->nodes[1]); + } else { + compile_node(comp, pns->nodes[0]); + } + (mp_emit_bc_return_value(comp->emit)); +} + +static void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_pop_top(comp->emit)); +} + +static void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (((pns->nodes[0]) == (0))) { + + (mp_emit_bc_raise_varargs(comp->emit, 0)); + } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_raise_stmt_arg))) { + + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + compile_node(comp, pns->nodes[0]); + compile_node(comp, pns->nodes[1]); + (mp_emit_bc_raise_varargs(comp->emit, 2)); + } else { + + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_raise_varargs(comp->emit, 1)); + } +} + + + + +static void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) { + +# 1026 "user/mpy/py/compile.c" 3 4 + _Bool +# 1026 "user/mpy/py/compile.c" + is_as = +# 1026 "user/mpy/py/compile.c" 3 4 + 0 +# 1026 "user/mpy/py/compile.c" + ; + if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_dotted_as_name))) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + + *q_base = (((uintptr_t)(pns->nodes[1])) >> 4); + pn = pns->nodes[0]; + is_as = +# 1032 "user/mpy/py/compile.c" 3 4 + 1 +# 1032 "user/mpy/py/compile.c" + ; + } + if (((pn) == (0))) { + + *q_base = MP_QSTR_; + (mp_emit_bc_import_name(comp->emit, MP_QSTR_)); + } else if ((((pn) & 0x0f) == (0x02))) { + + qstr q_full = (((uintptr_t)(pn)) >> 4); + if (!is_as) { + *q_base = q_full; + } + (mp_emit_bc_import_name(comp->emit, q_full)); + } else { + +# 1046 "user/mpy/py/compile.c" 3 + (( +# 1046 "user/mpy/py/compile.c" + ((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_dotted_name)) +# 1046 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1046, __func__, +# 1046 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_name)" +# 1046 "user/mpy/py/compile.c" 3 + )) +# 1046 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + { + + if (!is_as) { + *q_base = (((uintptr_t)(pns->nodes[0])) >> 4); + } + int n = ((pns)->kind_num_nodes >> 8); + int len = n - 1; + for (int i = 0; i < n; i++) { + len += qstr_len((((uintptr_t)(pns->nodes[i])) >> 4)); + } + byte *q_ptr; + byte *str_dest = qstr_build_start(len, &q_ptr); + for (int i = 0; i < n; i++) { + if (i > 0) { + *str_dest++ = '.'; + } + size_t str_src_len; + const byte *str_src = qstr_data((((uintptr_t)(pns->nodes[i])) >> 4), &str_src_len); + memcpy(str_dest, str_src, str_src_len); + str_dest += str_src_len; + } + qstr q_full = qstr_build_end(q_ptr); + (mp_emit_bc_import_name(comp->emit, q_full)); + if (is_as) { + for (int i = 1; i < n; i++) { + (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(pns->nodes[i])) >> 4))); + } + } + } + } +} + +static void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) { + (mp_emit_bc_load_const_small_int(comp->emit, 0)); + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + qstr q_base; + do_import_name(comp, pn, &q_base); + compile_store_id(comp, q_base); +} + +static void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) { + apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name); +} + +static void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) { + mp_parse_node_t pn_import_source = pns->nodes[0]; + + + uint import_level = 0; + do { + mp_parse_node_t pn_rel; + if ((((pn_import_source) & 0x0f) == (0x0e)) || ((pn_import_source) != (0) && ((pn_import_source) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_import_source))->kind_num_nodes & 0xff) == (PN_one_or_more_period_or_ellipsis))) { + + pn_rel = pn_import_source; + pn_import_source = (0); + } else if (((pn_import_source) != (0) && ((pn_import_source) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_import_source))->kind_num_nodes & 0xff) == (PN_import_from_2b))) { + + mp_parse_node_struct_t *pns_2b = (mp_parse_node_struct_t*)pn_import_source; + pn_rel = pns_2b->nodes[0]; + pn_import_source = pns_2b->nodes[1]; + +# 1108 "user/mpy/py/compile.c" 3 + (( +# 1108 "user/mpy/py/compile.c" + !((pn_import_source) == (0)) +# 1108 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1108, __func__, +# 1108 "user/mpy/py/compile.c" + "!MP_PARSE_NODE_IS_NULL(pn_import_source)" +# 1108 "user/mpy/py/compile.c" 3 + )) +# 1108 "user/mpy/py/compile.c" + ; + } else { + + break; + } + + + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pn_rel, PN_one_or_more_period_or_ellipsis, &nodes); + + + for (int i = 0; i < n; i++) { + if (((nodes[i]) == ((0x0e) | ((MP_TOKEN_DEL_PERIOD) << 4)))) { + import_level++; + } else { + + import_level += 3; + } + } + } while (0); + + if (((pns->nodes[1]) == ((0x0e) | ((MP_TOKEN_OP_STAR) << 4)))) { + (mp_emit_bc_load_const_small_int(comp->emit, import_level)); + + + (mp_emit_bc_load_const_str(comp->emit, MP_QSTR__star_)); + (mp_emit_bc_build_tuple(comp->emit, 1)); + + + qstr dummy_q; + do_import_name(comp, pn_import_source, &dummy_q); + (mp_emit_bc_import_star(comp->emit)); + + } else { + (mp_emit_bc_load_const_small_int(comp->emit, import_level)); + + + mp_parse_node_t *pn_nodes; + int n = mp_parse_node_extract_list(&pns->nodes[1], PN_import_as_names, &pn_nodes); + for (int i = 0; i < n; i++) { + +# 1148 "user/mpy/py/compile.c" 3 + (( +# 1148 "user/mpy/py/compile.c" + ((pn_nodes[i]) != (0) && ((pn_nodes[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_nodes[i]))->kind_num_nodes & 0xff) == (PN_import_as_name)) +# 1148 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1148, __func__, +# 1148 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)" +# 1148 "user/mpy/py/compile.c" 3 + )) +# 1148 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; + qstr id2 = (((uintptr_t)(pns3->nodes[0])) >> 4); + (mp_emit_bc_load_const_str(comp->emit, id2)); + } + (mp_emit_bc_build_tuple(comp->emit, n)); + + + qstr dummy_q; + do_import_name(comp, pn_import_source, &dummy_q); + for (int i = 0; i < n; i++) { + +# 1159 "user/mpy/py/compile.c" 3 + (( +# 1159 "user/mpy/py/compile.c" + ((pn_nodes[i]) != (0) && ((pn_nodes[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_nodes[i]))->kind_num_nodes & 0xff) == (PN_import_as_name)) +# 1159 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1159, __func__, +# 1159 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)" +# 1159 "user/mpy/py/compile.c" 3 + )) +# 1159 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; + qstr id2 = (((uintptr_t)(pns3->nodes[0])) >> 4); + (mp_emit_bc_import_from(comp->emit, id2)); + if (((pns3->nodes[1]) == (0))) { + compile_store_id(comp, id2); + } else { + compile_store_id(comp, (((uintptr_t)(pns3->nodes[1])) >> 4)); + } + } + (mp_emit_bc_pop_top(comp->emit)); + } +} + +static void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, qstr qst) { + +# 1174 "user/mpy/py/compile.c" 3 4 + _Bool +# 1174 "user/mpy/py/compile.c" + added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); + if (!added && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) { + compile_syntax_error(comp, pn, "identifier redefined as global"); + return; + } + id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; + + + id_info = scope_find_global(comp->scope_cur, qst); + if (id_info != +# 1184 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 1184 "user/mpy/py/compile.c" + ) { + id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; + } +} + +static void compile_global_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->pass == MP_PASS_SCOPE) { + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); + for (int i = 0; i < n; i++) { + compile_declare_global(comp, (mp_parse_node_t)pns, (((uintptr_t)(nodes[i])) >> 4)); + } + } +} + +static void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, qstr qst) { + +# 1200 "user/mpy/py/compile.c" 3 4 + _Bool +# 1200 "user/mpy/py/compile.c" + added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); + if (added) { + scope_find_local_and_close_over(comp->scope_cur, id_info, qst); + if (id_info->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + compile_syntax_error(comp, pn, "no binding for nonlocal found"); + } + } else if (id_info->kind != ID_INFO_KIND_FREE) { + compile_syntax_error(comp, pn, "identifier redefined as nonlocal"); + } +} + +static void compile_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->pass == MP_PASS_SCOPE) { + if (comp->scope_cur->kind == SCOPE_MODULE) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "can't declare nonlocal in outer code"); + return; + } + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); + for (int i = 0; i < n; i++) { + compile_declare_nonlocal(comp, (mp_parse_node_t)pns, (((uintptr_t)(nodes[i])) >> 4)); + } + } +} + +static void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + + if ((mp_state_ctx.vm.mp_optimise_value) != 0) { + return; + } + + uint l_end = comp_next_label(comp); + c_if_cond(comp, pns->nodes[0], +# 1233 "user/mpy/py/compile.c" 3 4 + 1 +# 1233 "user/mpy/py/compile.c" + , l_end); + (mp_emit_bc_load_global(comp->emit, MP_QSTR_AssertionError)); + if (!((pns->nodes[1]) == (0))) { + + compile_node(comp, pns->nodes[1]); + (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); + } + (mp_emit_bc_raise_varargs(comp->emit, 1)); + (mp_emit_bc_label_assign(comp->emit, l_end)); +} + +static void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + uint l_end = comp_next_label(comp); + + + if (!mp_parse_node_is_const_false(pns->nodes[0])) { + uint l_fail = comp_next_label(comp); + c_if_cond(comp, pns->nodes[0], +# 1250 "user/mpy/py/compile.c" 3 4 + 0 +# 1250 "user/mpy/py/compile.c" + , l_fail); + + compile_node(comp, pns->nodes[1]); + + + if (mp_parse_node_is_const_true(pns->nodes[0])) { + goto done; + } + + if ( + + !(((pns->nodes[2]) == (0)) && ((pns->nodes[3]) == (0))) + + && !(mp_emit_bc_last_emit_was_return_value(comp->emit)) + ) { + + (mp_emit_bc_jump(comp->emit, l_end)); + } + + (mp_emit_bc_label_assign(comp->emit, l_fail)); + } + + + mp_parse_node_t *pn_elif; + int n_elif = mp_parse_node_extract_list(&pns->nodes[2], PN_if_stmt_elif_list, &pn_elif); + for (int i = 0; i < n_elif; i++) { + +# 1276 "user/mpy/py/compile.c" 3 + (( +# 1276 "user/mpy/py/compile.c" + ((pn_elif[i]) != (0) && ((pn_elif[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_elif[i]))->kind_num_nodes & 0xff) == (PN_if_stmt_elif)) +# 1276 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1276, __func__, +# 1276 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pn_elif[i], PN_if_stmt_elif)" +# 1276 "user/mpy/py/compile.c" 3 + )) +# 1276 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns_elif = (mp_parse_node_struct_t*)pn_elif[i]; + + + if (!mp_parse_node_is_const_false(pns_elif->nodes[0])) { + uint l_fail = comp_next_label(comp); + c_if_cond(comp, pns_elif->nodes[0], +# 1282 "user/mpy/py/compile.c" 3 4 + 0 +# 1282 "user/mpy/py/compile.c" + , l_fail); + + compile_node(comp, pns_elif->nodes[1]); + + + if (mp_parse_node_is_const_true(pns_elif->nodes[0])) { + goto done; + } + + + if (!(mp_emit_bc_last_emit_was_return_value(comp->emit))) { + (mp_emit_bc_jump(comp->emit, l_end)); + } + (mp_emit_bc_label_assign(comp->emit, l_fail)); + } + } + + + compile_node(comp, pns->nodes[3]); + +done: + (mp_emit_bc_label_assign(comp->emit, l_end)); +} +# 1321 "user/mpy/py/compile.c" +static void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + uint16_t old_break_label = comp->break_label; uint16_t old_continue_label = comp->continue_label; uint16_t old_break_continue_except_level = comp->break_continue_except_level; uint break_label = comp_next_label(comp); uint continue_label = comp_next_label(comp); comp->break_label = break_label; comp->continue_label = continue_label; comp->break_continue_except_level = comp->cur_except_level; + + if (!mp_parse_node_is_const_false(pns->nodes[0])) { + uint top_label = comp_next_label(comp); + if (!mp_parse_node_is_const_true(pns->nodes[0])) { + (mp_emit_bc_jump(comp->emit, continue_label)); + } + (mp_emit_bc_label_assign(comp->emit, top_label)); + compile_node(comp, pns->nodes[1]); + (mp_emit_bc_label_assign(comp->emit, continue_label)); + c_if_cond(comp, pns->nodes[0], +# 1332 "user/mpy/py/compile.c" 3 4 + 1 +# 1332 "user/mpy/py/compile.c" + , top_label); + } + + + comp->break_label = old_break_label; comp->continue_label = old_continue_label; comp->break_continue_except_level = old_break_continue_except_level; + + compile_node(comp, pns->nodes[2]); + + (mp_emit_bc_label_assign(comp->emit, break_label)); +} +# 1359 "user/mpy/py/compile.c" +static void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) { + uint16_t old_break_label = comp->break_label; uint16_t old_continue_label = comp->continue_label; uint16_t old_break_continue_except_level = comp->break_continue_except_level; uint break_label = comp_next_label(comp); uint continue_label = comp_next_label(comp); comp->break_label = break_label; comp->continue_label = continue_label; comp->break_continue_except_level = comp->cur_except_level; + + uint top_label = comp_next_label(comp); + uint entry_label = comp_next_label(comp); + + + +# 1366 "user/mpy/py/compile.c" 3 4 + _Bool +# 1366 "user/mpy/py/compile.c" + end_on_stack = !(((pn_end) & 0x1) == (0x1)); + if (end_on_stack) { + compile_node(comp, pn_end); + } + + + compile_node(comp, pn_start); + + (mp_emit_bc_jump(comp->emit, entry_label)); + (mp_emit_bc_label_assign(comp->emit, top_label)); + + + (mp_emit_bc_dup_top(comp->emit)); + c_assign(comp, pn_var, ASSIGN_STORE); + + + compile_node(comp, pn_body); + + (mp_emit_bc_label_assign(comp->emit, continue_label)); + + + compile_node(comp, pn_step); + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_INPLACE_ADD)); + + (mp_emit_bc_label_assign(comp->emit, entry_label)); + + + if (end_on_stack) { + (mp_emit_bc_dup_top_two(comp->emit)); + (mp_emit_bc_rot_two(comp->emit)); + } else { + (mp_emit_bc_dup_top(comp->emit)); + compile_node(comp, pn_end); + } + +# 1400 "user/mpy/py/compile.c" 3 + (( +# 1400 "user/mpy/py/compile.c" + (((pn_step) & 0x1) == (0x1)) +# 1400 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1400, __func__, +# 1400 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_SMALL_INT(pn_step)" +# 1400 "user/mpy/py/compile.c" 3 + )) +# 1400 "user/mpy/py/compile.c" + ; + if ((((mp_int_t)(intptr_t)(pn_step)) >> 1) >= 0) { + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_LESS)); + } else { + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_MORE)); + } + (mp_emit_bc_pop_jump_if(comp->emit, +# 1406 "user/mpy/py/compile.c" 3 4 + 1 +# 1406 "user/mpy/py/compile.c" + , top_label)); + + + comp->break_label = old_break_label; comp->continue_label = old_continue_label; comp->break_continue_except_level = old_break_continue_except_level; + + + + uint end_label = 0; + if (!((pn_else) == (0))) { + + (mp_emit_bc_pop_top(comp->emit)); + if (end_on_stack) { + (mp_emit_bc_pop_top(comp->emit)); + } + compile_node(comp, pn_else); + end_label = comp_next_label(comp); + (mp_emit_bc_jump(comp->emit, end_label)); + (mp_emit_bc_adjust_stack_size(comp->emit, 1 + end_on_stack)); + } + + (mp_emit_bc_label_assign(comp->emit, break_label)); + + + (mp_emit_bc_pop_top(comp->emit)); + + + if (end_on_stack) { + (mp_emit_bc_pop_top(comp->emit)); + } + + if (!((pn_else) == (0))) { + (mp_emit_bc_label_assign(comp->emit, end_label)); + } +} + +static void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + + + + if ( (((pns->nodes[0]) & 0x0f) == (0x02)) && ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_atom_expr_normal))) { + mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1]; + if ((((pns_it->nodes[0]) & 0x0f) == (0x02)) + && (((uintptr_t)(pns_it->nodes[0])) >> 4) == MP_QSTR_range + && (((mp_parse_node_struct_t*)pns_it->nodes[1])->kind_num_nodes & 0xff) == PN_trailer_paren) { + mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0]; + mp_parse_node_t *args; + int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args); + mp_parse_node_t pn_range_start; + mp_parse_node_t pn_range_end; + mp_parse_node_t pn_range_step; + +# 1456 "user/mpy/py/compile.c" 3 4 + _Bool +# 1456 "user/mpy/py/compile.c" + optimize = +# 1456 "user/mpy/py/compile.c" 3 4 + 0 +# 1456 "user/mpy/py/compile.c" + ; + if (1 <= n_args && n_args <= 3) { + optimize = +# 1458 "user/mpy/py/compile.c" 3 4 + 1 +# 1458 "user/mpy/py/compile.c" + ; + if (n_args == 1) { + pn_range_start = mp_parse_node_new_small_int(0); + pn_range_end = args[0]; + pn_range_step = mp_parse_node_new_small_int(1); + } else if (n_args == 2) { + pn_range_start = args[0]; + pn_range_end = args[1]; + pn_range_step = mp_parse_node_new_small_int(1); + } else { + pn_range_start = args[0]; + pn_range_end = args[1]; + pn_range_step = args[2]; + + if (!(((pn_range_step) & 0x1) == (0x1)) + || (((mp_int_t)(intptr_t)(pn_range_step)) >> 1) == 0) { + optimize = +# 1474 "user/mpy/py/compile.c" 3 4 + 0 +# 1474 "user/mpy/py/compile.c" + ; + } + } + + if (optimize && ((pn_range_start) != (0) && ((pn_range_start) & 3) == 0)) { + int k = (((mp_parse_node_struct_t*)pn_range_start)->kind_num_nodes & 0xff); + if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { + optimize = +# 1481 "user/mpy/py/compile.c" 3 4 + 0 +# 1481 "user/mpy/py/compile.c" + ; + } + } + if (optimize && ((pn_range_end) != (0) && ((pn_range_end) & 3) == 0)) { + int k = (((mp_parse_node_struct_t*)pn_range_end)->kind_num_nodes & 0xff); + if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { + optimize = +# 1487 "user/mpy/py/compile.c" 3 4 + 0 +# 1487 "user/mpy/py/compile.c" + ; + } + } + } + if (optimize) { + compile_for_stmt_optimised_range(comp, pns->nodes[0], pn_range_start, pn_range_end, pn_range_step, pns->nodes[2], pns->nodes[3]); + return; + } + } + } + + uint16_t old_break_label = comp->break_label; uint16_t old_continue_label = comp->continue_label; uint16_t old_break_continue_except_level = comp->break_continue_except_level; uint break_label = comp_next_label(comp); uint continue_label = comp_next_label(comp); comp->break_label = break_label; comp->continue_label = continue_label; comp->break_continue_except_level = comp->cur_except_level; + comp->break_label |= (0x8000); + + uint pop_label = comp_next_label(comp); + + compile_node(comp, pns->nodes[1]); + (mp_emit_bc_get_iter(comp->emit, +# 1504 "user/mpy/py/compile.c" 3 4 + 1 +# 1504 "user/mpy/py/compile.c" + )); + (mp_emit_bc_label_assign(comp->emit, continue_label)); + (mp_emit_bc_for_iter(comp->emit, pop_label)); + c_assign(comp, pns->nodes[0], ASSIGN_STORE); + compile_node(comp, pns->nodes[2]); + if (!(mp_emit_bc_last_emit_was_return_value(comp->emit))) { + (mp_emit_bc_jump(comp->emit, continue_label)); + } + (mp_emit_bc_label_assign(comp->emit, pop_label)); + (mp_emit_bc_for_iter_end(comp->emit)); + + + comp->break_label = old_break_label; comp->continue_label = old_continue_label; comp->break_continue_except_level = old_break_continue_except_level; + + compile_node(comp, pns->nodes[3]); + + (mp_emit_bc_label_assign(comp->emit, break_label)); +} + +static void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) { + + uint l1 = comp_next_label(comp); + uint success_label = comp_next_label(comp); + + (mp_emit_bc_setup_except(comp->emit, l1)); + compile_increase_except_level(comp); + + compile_node(comp, pn_body); + (mp_emit_bc_pop_block(comp->emit)); + (mp_emit_bc_jump(comp->emit, success_label)); + + (mp_emit_bc_label_assign(comp->emit, l1)); + (mp_emit_bc_start_except_handler(comp->emit)); + + + + uint l2 = comp_next_label(comp); + + for (int i = 0; i < n_except; i++) { + +# 1543 "user/mpy/py/compile.c" 3 + (( +# 1543 "user/mpy/py/compile.c" + ((pn_excepts[i]) != (0) && ((pn_excepts[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_excepts[i]))->kind_num_nodes & 0xff) == (PN_try_stmt_except)) +# 1543 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1543, __func__, +# 1543 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pn_excepts[i], PN_try_stmt_except)" +# 1543 "user/mpy/py/compile.c" 3 + )) +# 1543 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns_except = (mp_parse_node_struct_t*)pn_excepts[i]; + + qstr qstr_exception_local = 0; + uint end_finally_label = comp_next_label(comp); + + if (((pns_except->nodes[0]) == (0))) { + + if (i + 1 != n_except) { + compile_syntax_error(comp, pn_excepts[i], "default 'except' must be last"); + compile_decrease_except_level(comp); + return; + } + } else { + + mp_parse_node_t pns_exception_expr = pns_except->nodes[0]; + if (((pns_exception_expr) != (0) && ((pns_exception_expr) & 3) == 0)) { + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns_exception_expr; + if (((pns3)->kind_num_nodes & 0xff) == PN_try_stmt_as_name) { + + pns_exception_expr = pns3->nodes[0]; + qstr_exception_local = (((uintptr_t)(pns3->nodes[1])) >> 4); + } + } + (mp_emit_bc_dup_top(comp->emit)); + compile_node(comp, pns_exception_expr); + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_EXCEPTION_MATCH)); + (mp_emit_bc_pop_jump_if(comp->emit, +# 1570 "user/mpy/py/compile.c" 3 4 + 0 +# 1570 "user/mpy/py/compile.c" + , end_finally_label)); + } + + + if (qstr_exception_local == 0) { + (mp_emit_bc_pop_top(comp->emit)); + } else { + compile_store_id(comp, qstr_exception_local); + } + + uint l3 = 0; + if (qstr_exception_local != 0) { + l3 = comp_next_label(comp); + (mp_emit_bc_setup_finally(comp->emit, l3)); + compile_increase_except_level(comp); + } + compile_node(comp, pns_except->nodes[1]); + if (qstr_exception_local != 0) { + (mp_emit_bc_pop_block(comp->emit)); + } + (mp_emit_bc_pop_except(comp->emit)); + if (qstr_exception_local != 0) { + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + (mp_emit_bc_label_assign(comp->emit, l3)); + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + compile_store_id(comp, qstr_exception_local); + compile_delete_id(comp, qstr_exception_local); + + compile_decrease_except_level(comp); + (mp_emit_bc_end_finally(comp->emit)); + } + (mp_emit_bc_jump(comp->emit, l2)); + (mp_emit_bc_label_assign(comp->emit, end_finally_label)); + (mp_emit_bc_adjust_stack_size(comp->emit, 1)); + } + + compile_decrease_except_level(comp); + (mp_emit_bc_end_finally(comp->emit)); + (mp_emit_bc_end_except_handler(comp->emit)); + + (mp_emit_bc_label_assign(comp->emit, success_label)); + compile_node(comp, pn_else); + (mp_emit_bc_label_assign(comp->emit, l2)); +} + +static void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) { + uint l_finally_block = comp_next_label(comp); + + (mp_emit_bc_setup_finally(comp->emit, l_finally_block)); + compile_increase_except_level(comp); + + if (n_except == 0) { + +# 1622 "user/mpy/py/compile.c" 3 + (( +# 1622 "user/mpy/py/compile.c" + ((pn_else) == (0)) +# 1622 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1622, __func__, +# 1622 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_NULL(pn_else)" +# 1622 "user/mpy/py/compile.c" 3 + )) +# 1622 "user/mpy/py/compile.c" + ; + (mp_emit_bc_adjust_stack_size(comp->emit, 3)); + compile_node(comp, pn_body); + (mp_emit_bc_adjust_stack_size(comp->emit, -3)); + } else { + compile_try_except(comp, pn_body, n_except, pn_except, pn_else); + } + (mp_emit_bc_pop_block(comp->emit)); + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + (mp_emit_bc_label_assign(comp->emit, l_finally_block)); + compile_node(comp, pn_finally); + + compile_decrease_except_level(comp); + (mp_emit_bc_end_finally(comp->emit)); +} + +static void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + +# 1639 "user/mpy/py/compile.c" 3 + (( +# 1639 "user/mpy/py/compile.c" + ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0) +# 1639 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1639, __func__, +# 1639 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])" +# 1639 "user/mpy/py/compile.c" 3 + )) +# 1639 "user/mpy/py/compile.c" + ; + { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns2)->kind_num_nodes & 0xff) == PN_try_stmt_finally) { + + compile_try_finally(comp, pns->nodes[0], 0, +# 1644 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 1644 "user/mpy/py/compile.c" + , (0), pns2->nodes[0]); + } else if (((pns2)->kind_num_nodes & 0xff) == PN_try_stmt_except_and_more) { + + mp_parse_node_t *pn_excepts; + int n_except = mp_parse_node_extract_list(&pns2->nodes[0], PN_try_stmt_except_list, &pn_excepts); + if (((pns2->nodes[2]) == (0))) { + + compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1]); + } else { + + compile_try_finally(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1], ((mp_parse_node_struct_t*)pns2->nodes[2])->nodes[0]); + } + } else { + + mp_parse_node_t *pn_excepts; + int n_except = mp_parse_node_extract_list(&pns->nodes[1], PN_try_stmt_except_list, &pn_excepts); + compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, (0)); + } + } +} + +static void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, mp_parse_node_t body) { + if (n == 0) { + + compile_node(comp, body); + } else { + uint l_end = comp_next_label(comp); + if (((0) || (0) || (0) || (0) || (0)) && comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) { + + + comp_next_label(comp); + } + if (((nodes[0]) != (0) && ((nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(nodes[0]))->kind_num_nodes & 0xff) == (PN_with_item))) { + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0]; + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_setup_with(comp->emit, l_end)); + c_assign(comp, pns->nodes[1], ASSIGN_STORE); + } else { + + compile_node(comp, nodes[0]); + (mp_emit_bc_setup_with(comp->emit, l_end)); + (mp_emit_bc_pop_top(comp->emit)); + } + compile_increase_except_level(comp); + + compile_with_stmt_helper(comp, n - 1, nodes + 1, body); + + (mp_emit_bc_with_cleanup(comp->emit, l_end)); + compile_decrease_except_level(comp); + (mp_emit_bc_end_finally(comp->emit)); + } +} + +static void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes); + +# 1702 "user/mpy/py/compile.c" 3 + (( +# 1702 "user/mpy/py/compile.c" + n > 0 +# 1702 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1702, __func__, +# 1702 "user/mpy/py/compile.c" + "n > 0" +# 1702 "user/mpy/py/compile.c" 3 + )) +# 1702 "user/mpy/py/compile.c" + ; + + + compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]); +} + +static void compile_yield_from(compiler_t *comp) { + (mp_emit_bc_get_iter(comp->emit, +# 1709 "user/mpy/py/compile.c" 3 4 + 0 +# 1709 "user/mpy/py/compile.c" + )); + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + (mp_emit_bc_yield_from(comp->emit)); +} +# 1889 "user/mpy/py/compile.c" +static void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (((pns->nodes[1]) == (0))) { + if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) { + + compile_load_id(comp, MP_QSTR___repl_print__); + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); + (mp_emit_bc_pop_top(comp->emit)); + + } else { + + if ((((pns->nodes[0]) & 3) && !(((pns->nodes[0]) & 0x0f) == (0x02))) + || ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_const_object))) { + + } else { + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_pop_top(comp->emit)); + } + } + } else if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + int kind = ((pns1)->kind_num_nodes & 0xff); + if (kind == PN_expr_stmt_augassign) { + c_assign(comp, pns->nodes[0], ASSIGN_AUG_LOAD); + compile_node(comp, pns1->nodes[1]); + +# 1914 "user/mpy/py/compile.c" 3 + (( +# 1914 "user/mpy/py/compile.c" + (((pns1->nodes[0]) & 0x0f) == (0x0e)) +# 1914 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1914, __func__, +# 1914 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_TOKEN(pns1->nodes[0])" +# 1914 "user/mpy/py/compile.c" 3 + )) +# 1914 "user/mpy/py/compile.c" + ; + mp_binary_op_t op; + switch ((((uintptr_t)(pns1->nodes[0])) >> 4)) { + case MP_TOKEN_DEL_PIPE_EQUAL: op = MP_BINARY_OP_INPLACE_OR; break; + case MP_TOKEN_DEL_CARET_EQUAL: op = MP_BINARY_OP_INPLACE_XOR; break; + case MP_TOKEN_DEL_AMPERSAND_EQUAL: op = MP_BINARY_OP_INPLACE_AND; break; + case MP_TOKEN_DEL_DBL_LESS_EQUAL: op = MP_BINARY_OP_INPLACE_LSHIFT; break; + case MP_TOKEN_DEL_DBL_MORE_EQUAL: op = MP_BINARY_OP_INPLACE_RSHIFT; break; + case MP_TOKEN_DEL_PLUS_EQUAL: op = MP_BINARY_OP_INPLACE_ADD; break; + case MP_TOKEN_DEL_MINUS_EQUAL: op = MP_BINARY_OP_INPLACE_SUBTRACT; break; + case MP_TOKEN_DEL_STAR_EQUAL: op = MP_BINARY_OP_INPLACE_MULTIPLY; break; + case MP_TOKEN_DEL_DBL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_FLOOR_DIVIDE; break; + case MP_TOKEN_DEL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_TRUE_DIVIDE; break; + case MP_TOKEN_DEL_PERCENT_EQUAL: op = MP_BINARY_OP_INPLACE_MODULO; break; + case MP_TOKEN_DEL_DBL_STAR_EQUAL: default: op = MP_BINARY_OP_INPLACE_POWER; break; + } + (mp_emit_bc_binary_op(comp->emit, op)); + c_assign(comp, pns->nodes[0], ASSIGN_AUG_STORE); + } else if (kind == PN_expr_stmt_assign_list) { + int rhs = ((pns1)->kind_num_nodes >> 8) - 1; + compile_node(comp, pns1->nodes[rhs]); + + if (rhs > 0) { + (mp_emit_bc_dup_top(comp->emit)); + } + c_assign(comp, pns->nodes[0], ASSIGN_STORE); + for (int i = 0; i < rhs; i++) { + if (i + 1 < rhs) { + (mp_emit_bc_dup_top(comp->emit)); + } + c_assign(comp, pns1->nodes[i], ASSIGN_STORE); + } + } else { + plain_assign: + if ((0) + && ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) + && ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) + && (((mp_parse_node_struct_t*)pns->nodes[1])->kind_num_nodes >> 8) == 2 + && (((mp_parse_node_struct_t*)pns->nodes[0])->kind_num_nodes >> 8) == 2) { + + mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; + mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (((pns0->nodes[0]) != (0) && ((pns0->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[0]))->kind_num_nodes & 0xff) == (PN_star_expr)) + || ((pns0->nodes[1]) != (0) && ((pns0->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[1]))->kind_num_nodes & 0xff) == (PN_star_expr))) { + + goto no_optimisation; + } + compile_node(comp, pns10->nodes[0]); + compile_node(comp, pns10->nodes[1]); + (mp_emit_bc_rot_two(comp->emit)); + c_assign(comp, pns0->nodes[0], ASSIGN_STORE); + c_assign(comp, pns0->nodes[1], ASSIGN_STORE); + } else if ((0) + && ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) + && ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) + && (((mp_parse_node_struct_t*)pns->nodes[1])->kind_num_nodes >> 8) == 3 + && (((mp_parse_node_struct_t*)pns->nodes[0])->kind_num_nodes >> 8) == 3) { + + mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; + mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (((pns0->nodes[0]) != (0) && ((pns0->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[0]))->kind_num_nodes & 0xff) == (PN_star_expr)) + || ((pns0->nodes[1]) != (0) && ((pns0->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[1]))->kind_num_nodes & 0xff) == (PN_star_expr)) + || ((pns0->nodes[2]) != (0) && ((pns0->nodes[2]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[2]))->kind_num_nodes & 0xff) == (PN_star_expr))) { + + goto no_optimisation; + } + compile_node(comp, pns10->nodes[0]); + compile_node(comp, pns10->nodes[1]); + compile_node(comp, pns10->nodes[2]); + (mp_emit_bc_rot_three(comp->emit)); + (mp_emit_bc_rot_two(comp->emit)); + c_assign(comp, pns0->nodes[0], ASSIGN_STORE); + c_assign(comp, pns0->nodes[1], ASSIGN_STORE); + c_assign(comp, pns0->nodes[2], ASSIGN_STORE); + } else { + no_optimisation: + compile_node(comp, pns->nodes[1]); + c_assign(comp, pns->nodes[0], ASSIGN_STORE); + } + } + } else { + goto plain_assign; + } +} + +static void c_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns, mp_binary_op_t binary_op) { + int num_nodes = ((pns)->kind_num_nodes >> 8); + compile_node(comp, pns->nodes[0]); + for (int i = 1; i < num_nodes; i += 1) { + compile_node(comp, pns->nodes[i]); + (mp_emit_bc_binary_op(comp->emit, binary_op)); + } +} + +static void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + +# 2009 "user/mpy/py/compile.c" 3 + (( +# 2009 "user/mpy/py/compile.c" + ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_test_if_else)) +# 2009 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2009, __func__, +# 2009 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else)" +# 2009 "user/mpy/py/compile.c" 3 + )) +# 2009 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns->nodes[1]; + + uint l_fail = comp_next_label(comp); + uint l_end = comp_next_label(comp); + c_if_cond(comp, pns_test_if_else->nodes[0], +# 2014 "user/mpy/py/compile.c" 3 4 + 0 +# 2014 "user/mpy/py/compile.c" + , l_fail); + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_jump(comp->emit, l_end)); + (mp_emit_bc_label_assign(comp->emit, l_fail)); + (mp_emit_bc_adjust_stack_size(comp->emit, -1)); + compile_node(comp, pns_test_if_else->nodes[1]); + (mp_emit_bc_label_assign(comp->emit, l_end)); +} + +static void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->pass == MP_PASS_SCOPE) { + + scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options); + + pns->nodes[2] = (mp_parse_node_t)s; + } + + + scope_t *this_scope = (scope_t*)pns->nodes[2]; + + + compile_funcdef_lambdef(comp, this_scope, pns->nodes[0], PN_varargslist); +} + +static void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns, +# 2038 "user/mpy/py/compile.c" 3 4 + _Bool +# 2038 "user/mpy/py/compile.c" + cond) { + uint l_end = comp_next_label(comp); + int n = ((pns)->kind_num_nodes >> 8); + for (int i = 0; i < n; i += 1) { + compile_node(comp, pns->nodes[i]); + if (i + 1 < n) { + (mp_emit_bc_jump_if_or_pop(comp->emit, cond, l_end)); + } + } + (mp_emit_bc_label_assign(comp->emit, l_end)); +} + +static void compile_or_test(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_or_and_test(comp, pns, +# 2051 "user/mpy/py/compile.c" 3 4 + 1 +# 2051 "user/mpy/py/compile.c" + ); +} + +static void compile_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_or_and_test(comp, pns, +# 2055 "user/mpy/py/compile.c" 3 4 + 0 +# 2055 "user/mpy/py/compile.c" + ); +} + +static void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_unary_op(comp->emit, MP_UNARY_OP_NOT)); +} + +static void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) { + int num_nodes = ((pns)->kind_num_nodes >> 8); + compile_node(comp, pns->nodes[0]); + +# 2066 "user/mpy/py/compile.c" 3 4 + _Bool +# 2066 "user/mpy/py/compile.c" + multi = (num_nodes > 3); + uint l_fail = 0; + if (multi) { + l_fail = comp_next_label(comp); + } + for (int i = 1; i + 1 < num_nodes; i += 2) { + compile_node(comp, pns->nodes[i + 1]); + if (i + 2 < num_nodes) { + (mp_emit_bc_dup_top(comp->emit)); + (mp_emit_bc_rot_three(comp->emit)); + } + if ((((pns->nodes[i]) & 0x0f) == (0x0e))) { + mp_binary_op_t op; + switch ((((uintptr_t)(pns->nodes[i])) >> 4)) { + case MP_TOKEN_OP_LESS: op = MP_BINARY_OP_LESS; break; + case MP_TOKEN_OP_MORE: op = MP_BINARY_OP_MORE; break; + case MP_TOKEN_OP_DBL_EQUAL: op = MP_BINARY_OP_EQUAL; break; + case MP_TOKEN_OP_LESS_EQUAL: op = MP_BINARY_OP_LESS_EQUAL; break; + case MP_TOKEN_OP_MORE_EQUAL: op = MP_BINARY_OP_MORE_EQUAL; break; + case MP_TOKEN_OP_NOT_EQUAL: op = MP_BINARY_OP_NOT_EQUAL; break; + case MP_TOKEN_KW_IN: default: op = MP_BINARY_OP_IN; break; + } + (mp_emit_bc_binary_op(comp->emit, op)); + } else { + +# 2090 "user/mpy/py/compile.c" 3 + (( +# 2090 "user/mpy/py/compile.c" + ((pns->nodes[i]) != (0) && ((pns->nodes[i]) & 3) == 0) +# 2090 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2090, __func__, +# 2090 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pns->nodes[i])" +# 2090 "user/mpy/py/compile.c" 3 + )) +# 2090 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[i]; + int kind = ((pns2)->kind_num_nodes & 0xff); + if (kind == PN_comp_op_not_in) { + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_NOT_IN)); + } else { + +# 2096 "user/mpy/py/compile.c" 3 + (( +# 2096 "user/mpy/py/compile.c" + kind == PN_comp_op_is +# 2096 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2096, __func__, +# 2096 "user/mpy/py/compile.c" + "kind == PN_comp_op_is" +# 2096 "user/mpy/py/compile.c" 3 + )) +# 2096 "user/mpy/py/compile.c" + ; + if (((pns2->nodes[0]) == (0))) { + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_IS)); + } else { + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_IS_NOT)); + } + } + } + if (i + 2 < num_nodes) { + (mp_emit_bc_jump_if_or_pop(comp->emit, +# 2105 "user/mpy/py/compile.c" 3 4 + 0 +# 2105 "user/mpy/py/compile.c" + , l_fail)); + } + } + if (multi) { + uint l_end = comp_next_label(comp); + (mp_emit_bc_jump(comp->emit, l_end)); + (mp_emit_bc_label_assign(comp->emit, l_fail)); + (mp_emit_bc_adjust_stack_size(comp->emit, 1)); + (mp_emit_bc_rot_two(comp->emit)); + (mp_emit_bc_pop_top(comp->emit)); + (mp_emit_bc_label_assign(comp->emit, l_end)); + } +} + +static void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "*x must be assignment target"); +} + +static void compile_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + c_binary_op(comp, pns, MP_BINARY_OP_OR); +} + +static void compile_xor_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + c_binary_op(comp, pns, MP_BINARY_OP_XOR); +} + +static void compile_and_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + c_binary_op(comp, pns, MP_BINARY_OP_AND); +} + +static void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) { + int num_nodes = ((pns)->kind_num_nodes >> 8); + compile_node(comp, pns->nodes[0]); + for (int i = 1; i + 1 < num_nodes; i += 2) { + compile_node(comp, pns->nodes[i + 1]); + mp_binary_op_t op; + mp_token_kind_t tok = (((uintptr_t)(pns->nodes[i])) >> 4); + switch (tok) { + case MP_TOKEN_OP_PLUS: op = MP_BINARY_OP_ADD; break; + case MP_TOKEN_OP_MINUS: op = MP_BINARY_OP_SUBTRACT; break; + case MP_TOKEN_OP_STAR: op = MP_BINARY_OP_MULTIPLY; break; + case MP_TOKEN_OP_DBL_SLASH: op = MP_BINARY_OP_FLOOR_DIVIDE; break; + case MP_TOKEN_OP_SLASH: op = MP_BINARY_OP_TRUE_DIVIDE; break; + case MP_TOKEN_OP_PERCENT: op = MP_BINARY_OP_MODULO; break; + case MP_TOKEN_OP_DBL_LESS: op = MP_BINARY_OP_LSHIFT; break; + default: + +# 2151 "user/mpy/py/compile.c" 3 + (( +# 2151 "user/mpy/py/compile.c" + tok == MP_TOKEN_OP_DBL_MORE +# 2151 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2151, __func__, +# 2151 "user/mpy/py/compile.c" + "tok == MP_TOKEN_OP_DBL_MORE" +# 2151 "user/mpy/py/compile.c" 3 + )) +# 2151 "user/mpy/py/compile.c" + ; + op = MP_BINARY_OP_RSHIFT; + break; + } + (mp_emit_bc_binary_op(comp->emit, op)); + } +} + +static void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[1]); + mp_unary_op_t op; + mp_token_kind_t tok = (((uintptr_t)(pns->nodes[0])) >> 4); + switch (tok) { + case MP_TOKEN_OP_PLUS: op = MP_UNARY_OP_POSITIVE; break; + case MP_TOKEN_OP_MINUS: op = MP_UNARY_OP_NEGATIVE; break; + default: + +# 2167 "user/mpy/py/compile.c" 3 + (( +# 2167 "user/mpy/py/compile.c" + tok == MP_TOKEN_OP_TILDE +# 2167 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2167, __func__, +# 2167 "user/mpy/py/compile.c" + "tok == MP_TOKEN_OP_TILDE" +# 2167 "user/mpy/py/compile.c" 3 + )) +# 2167 "user/mpy/py/compile.c" + ; + op = MP_UNARY_OP_INVERT; + break; + } + (mp_emit_bc_unary_op(comp->emit, op)); +} + +static void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) { + + compile_node(comp, pns->nodes[0]); + + + if (((pns->nodes[1]) == (0))) { + return; + } + + + size_t num_trail = 1; + mp_parse_node_struct_t **pns_trail = (mp_parse_node_struct_t**)&pns->nodes[1]; + if (((pns_trail[0])->kind_num_nodes & 0xff) == PN_atom_expr_trailers) { + num_trail = ((pns_trail[0])->kind_num_nodes >> 8); + pns_trail = (mp_parse_node_struct_t**)&pns_trail[0]->nodes[0]; + } + + + size_t i = 0; + + + if (comp->scope_cur->kind == SCOPE_FUNCTION + && (((pns->nodes[0]) & 0x0f) == (0x02)) + && (((uintptr_t)(pns->nodes[0])) >> 4) == MP_QSTR_super + && ((pns_trail[0])->kind_num_nodes & 0xff) == PN_trailer_paren + && ((pns_trail[0]->nodes[0]) == (0))) { + + + + compile_load_id(comp, MP_QSTR___class__); + + + +# 2206 "user/mpy/py/compile.c" 3 4 + _Bool +# 2206 "user/mpy/py/compile.c" + found = +# 2206 "user/mpy/py/compile.c" 3 4 + 0 +# 2206 "user/mpy/py/compile.c" + ; + id_info_t *id = &comp->scope_cur->id_info[0]; + for (size_t n = comp->scope_cur->id_info_len; n > 0; --n, ++id) { + if (id->flags & ID_FLAG_IS_PARAM) { + + compile_load_id(comp, id->qst); + found = +# 2212 "user/mpy/py/compile.c" 3 4 + 1 +# 2212 "user/mpy/py/compile.c" + ; + break; + } + } + if (!found) { + compile_syntax_error(comp, (mp_parse_node_t)pns_trail[0], + "super() can't find self"); + return; + } + + if (num_trail >= 3 + && ((pns_trail[1])->kind_num_nodes & 0xff) == PN_trailer_period + && ((pns_trail[2])->kind_num_nodes & 0xff) == PN_trailer_paren) { + + mp_parse_node_struct_t *pns_period = pns_trail[1]; + mp_parse_node_struct_t *pns_paren = pns_trail[2]; + (mp_emit_bc_load_method(comp->emit, (((uintptr_t)(pns_period->nodes[0])) >> 4), +# 2228 "user/mpy/py/compile.c" 3 4 + 1 +# 2228 "user/mpy/py/compile.c" + )); + compile_trailer_paren_helper(comp, pns_paren->nodes[0], +# 2229 "user/mpy/py/compile.c" 3 4 + 1 +# 2229 "user/mpy/py/compile.c" + , 0); + i = 3; + } else { + + (mp_emit_bc_call_function(comp->emit, 2, 0, 0)); + i = 1; + } + } + + + for (; i < num_trail; i++) { + if (i + 1 < num_trail + && ((pns_trail[i])->kind_num_nodes & 0xff) == PN_trailer_period + && ((pns_trail[i + 1])->kind_num_nodes & 0xff) == PN_trailer_paren) { + + mp_parse_node_struct_t *pns_period = pns_trail[i]; + mp_parse_node_struct_t *pns_paren = pns_trail[i + 1]; + (mp_emit_bc_load_method(comp->emit, (((uintptr_t)(pns_period->nodes[0])) >> 4), +# 2246 "user/mpy/py/compile.c" 3 4 + 0 +# 2246 "user/mpy/py/compile.c" + )); + compile_trailer_paren_helper(comp, pns_paren->nodes[0], +# 2247 "user/mpy/py/compile.c" 3 4 + 1 +# 2247 "user/mpy/py/compile.c" + , 0); + i += 1; + } else { + + compile_node(comp, (mp_parse_node_t)pns_trail[i]); + } + } +} + +static void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_generic_all_nodes(comp, pns); + (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_POWER)); +} + +static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, +# 2261 "user/mpy/py/compile.c" 3 4 + _Bool +# 2261 "user/mpy/py/compile.c" + is_method_call, int n_positional_extra) { + + + + mp_parse_node_t *args; + int n_args = mp_parse_node_extract_list(&pn_arglist, PN_arglist, &args); + + + + + + int n_positional = n_positional_extra; + uint n_keyword = 0; + uint star_flags = 0; + mp_parse_node_struct_t *star_args_node = +# 2275 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 2275 "user/mpy/py/compile.c" + , *dblstar_args_node = +# 2275 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 2275 "user/mpy/py/compile.c" + ; + for (int i = 0; i < n_args; i++) { + if (((args[i]) != (0) && ((args[i]) & 3) == 0)) { + mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t*)args[i]; + if (((pns_arg)->kind_num_nodes & 0xff) == PN_arglist_star) { + if (star_flags & (0x01)) { + compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple *x"); + return; + } + star_flags |= (0x01); + star_args_node = pns_arg; + } else if (((pns_arg)->kind_num_nodes & 0xff) == PN_arglist_dbl_star) { + if (star_flags & (0x02)) { + compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple **x"); + return; + } + star_flags |= (0x02); + dblstar_args_node = pns_arg; + } else if (((pns_arg)->kind_num_nodes & 0xff) == PN_argument) { + if (!((pns_arg->nodes[1]) != (0) && ((pns_arg->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns_arg->nodes[1]))->kind_num_nodes & 0xff) == (PN_comp_for))) { + if (!(((pns_arg->nodes[0]) & 0x0f) == (0x02))) { + compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id"); + return; + } + (mp_emit_bc_load_const_str(comp->emit, (((uintptr_t)(pns_arg->nodes[0])) >> 4))); + compile_node(comp, pns_arg->nodes[1]); + n_keyword += 1; + } else { + compile_comprehension(comp, pns_arg, SCOPE_GEN_EXPR); + n_positional++; + } + } else { + goto normal_argument; + } + } else { + normal_argument: + if (star_flags) { + compile_syntax_error(comp, args[i], "non-keyword arg after */**"); + return; + } + if (n_keyword > 0) { + compile_syntax_error(comp, args[i], "non-keyword arg after keyword arg"); + return; + } + compile_node(comp, args[i]); + n_positional++; + } + } + + + + if (star_flags != 0) { + if (star_args_node == +# 2327 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 2327 "user/mpy/py/compile.c" + ) { + (mp_emit_bc_load_null(comp->emit)); + } else { + compile_node(comp, star_args_node->nodes[0]); + } + if (dblstar_args_node == +# 2332 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 2332 "user/mpy/py/compile.c" + ) { + (mp_emit_bc_load_null(comp->emit)); + } else { + compile_node(comp, dblstar_args_node->nodes[0]); + } + } + + + if (is_method_call) { + (mp_emit_bc_call_method(comp->emit, n_positional, n_keyword, star_flags)); + } else { + (mp_emit_bc_call_function(comp->emit, n_positional, n_keyword, star_flags)); + } +} + + +static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) { + +# 2349 "user/mpy/py/compile.c" 3 + (( +# 2349 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes >> 8) == 2 +# 2349 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2349, __func__, +# 2349 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2" +# 2349 "user/mpy/py/compile.c" 3 + )) +# 2349 "user/mpy/py/compile.c" + ; + +# 2350 "user/mpy/py/compile.c" 3 + (( +# 2350 "user/mpy/py/compile.c" + ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_comp_for)) +# 2350 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2350, __func__, +# 2350 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)" +# 2350 "user/mpy/py/compile.c" 3 + )) +# 2350 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; + + if (comp->pass == MP_PASS_SCOPE) { + + scope_t *s = scope_new_and_link(comp, kind, (mp_parse_node_t)pns, comp->scope_cur->emit_options); + + pns_comp_for->nodes[3] = (mp_parse_node_t)s; + } + + + scope_t *this_scope = (scope_t*)pns_comp_for->nodes[3]; + + + close_over_variables_etc(comp, this_scope, 0, 0); + + compile_node(comp, pns_comp_for->nodes[1]); + if (kind == SCOPE_GEN_EXPR) { + (mp_emit_bc_get_iter(comp->emit, +# 2368 "user/mpy/py/compile.c" 3 4 + 0 +# 2368 "user/mpy/py/compile.c" + )); + } + (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); +} + +static void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (((pns->nodes[0]) == (0))) { + + c_tuple(comp, (0), +# 2376 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 2376 "user/mpy/py/compile.c" + ); + } else { + +# 2378 "user/mpy/py/compile.c" 3 + (( +# 2378 "user/mpy/py/compile.c" + ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp)) +# 2378 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2378, __func__, +# 2378 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)" +# 2378 "user/mpy/py/compile.c" 3 + )) +# 2378 "user/mpy/py/compile.c" + ; + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + +# 2380 "user/mpy/py/compile.c" 3 + (( +# 2380 "user/mpy/py/compile.c" + !((pns->nodes[1]) == (0)) +# 2380 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2380, __func__, +# 2380 "user/mpy/py/compile.c" + "!MP_PARSE_NODE_IS_NULL(pns->nodes[1])" +# 2380 "user/mpy/py/compile.c" 3 + )) +# 2380 "user/mpy/py/compile.c" + ; + if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { + + +# 2385 "user/mpy/py/compile.c" 3 + (( +# 2385 "user/mpy/py/compile.c" + ((pns2->nodes[0]) == (0)) +# 2385 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2385, __func__, +# 2385 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_NULL(pns2->nodes[0])" +# 2385 "user/mpy/py/compile.c" 3 + )) +# 2385 "user/mpy/py/compile.c" + ; + c_tuple(comp, pns->nodes[0], +# 2386 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 2386 "user/mpy/py/compile.c" + ); + } else if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { + + c_tuple(comp, pns->nodes[0], pns2); + } else if (((pns2)->kind_num_nodes & 0xff) == PN_comp_for) { + + compile_comprehension(comp, pns, SCOPE_GEN_EXPR); + } else { + + goto tuple_with_2_items; + } + } else { + + tuple_with_2_items: + c_tuple(comp, (0), pns); + } + } +} + +static void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (((pns->nodes[0]) == (0))) { + + (mp_emit_bc_build_list(comp->emit, 0)); + } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp))) { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (((pns2->nodes[1]) != (0) && ((pns2->nodes[1]) & 3) == 0)) { + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns2->nodes[1]; + if (((pns3)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { + + +# 2415 "user/mpy/py/compile.c" 3 + (( +# 2415 "user/mpy/py/compile.c" + ((pns3->nodes[0]) == (0)) +# 2415 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2415, __func__, +# 2415 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_NULL(pns3->nodes[0])" +# 2415 "user/mpy/py/compile.c" 3 + )) +# 2415 "user/mpy/py/compile.c" + ; + compile_node(comp, pns2->nodes[0]); + (mp_emit_bc_build_list(comp->emit, 1)); + } else if (((pns3)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { + + compile_node(comp, pns2->nodes[0]); + compile_generic_all_nodes(comp, pns3); + (mp_emit_bc_build_list(comp->emit, 1 + ((pns3)->kind_num_nodes >> 8))); + } else if (((pns3)->kind_num_nodes & 0xff) == PN_comp_for) { + + compile_comprehension(comp, pns2, SCOPE_LIST_COMP); + } else { + + goto list_with_2_items; + } + } else { + + list_with_2_items: + compile_node(comp, pns2->nodes[0]); + compile_node(comp, pns2->nodes[1]); + (mp_emit_bc_build_list(comp->emit, 2)); + } + } else { + + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_build_list(comp->emit, 1)); + } +} + +static void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) { + mp_parse_node_t pn = pns->nodes[0]; + if (((pn) == (0))) { + + (mp_emit_bc_build_map(comp->emit, 0)); + } else if (((pn) != (0) && ((pn) & 3) == 0)) { + pns = (mp_parse_node_struct_t*)pn; + if (((pns)->kind_num_nodes & 0xff) == PN_dictorsetmaker_item) { + + (mp_emit_bc_build_map(comp->emit, 1)); + compile_node(comp, pn); + (mp_emit_bc_store_map(comp->emit)); + } else if (((pns)->kind_num_nodes & 0xff) == PN_dictorsetmaker) { + +# 2457 "user/mpy/py/compile.c" 3 + (( +# 2457 "user/mpy/py/compile.c" + ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0) +# 2457 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2457, __func__, +# 2457 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])" +# 2457 "user/mpy/py/compile.c" 3 + )) +# 2457 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (((pns1)->kind_num_nodes & 0xff) == PN_dictorsetmaker_list) { + + + + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns1->nodes[0], PN_dictorsetmaker_list2, &nodes); + + + +# 2467 "user/mpy/py/compile.c" 3 4 + _Bool +# 2467 "user/mpy/py/compile.c" + is_dict; + if (!(0) || ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_dictorsetmaker_item))) { + + (mp_emit_bc_build_map(comp->emit, 1 + n)); + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_store_map(comp->emit)); + is_dict = +# 2473 "user/mpy/py/compile.c" 3 4 + 1 +# 2473 "user/mpy/py/compile.c" + ; + } else { + + compile_node(comp, pns->nodes[0]); + is_dict = +# 2477 "user/mpy/py/compile.c" 3 4 + 0 +# 2477 "user/mpy/py/compile.c" + ; + } + + + for (int i = 0; i < n; i++) { + mp_parse_node_t pn_i = nodes[i]; + +# 2483 "user/mpy/py/compile.c" 3 4 + _Bool +# 2483 "user/mpy/py/compile.c" + is_key_value = ((pn_i) != (0) && ((pn_i) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_i))->kind_num_nodes & 0xff) == (PN_dictorsetmaker_item)); + compile_node(comp, pn_i); + if (is_dict) { + if (!is_key_value) { + if (((1)) == (1)) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); + } else { + compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict"); + } + return; + } + (mp_emit_bc_store_map(comp->emit)); + } else { + if (is_key_value) { + if (((1)) == (1)) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); + } else { + compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set"); + } + return; + } + } + } + + + + + + + + } else { + +# 2514 "user/mpy/py/compile.c" 3 + (( +# 2514 "user/mpy/py/compile.c" + ((pns1)->kind_num_nodes & 0xff) == PN_comp_for +# 2514 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2514, __func__, +# 2514 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for" +# 2514 "user/mpy/py/compile.c" 3 + )) +# 2514 "user/mpy/py/compile.c" + ; + + if (!(0) || ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_dictorsetmaker_item))) { + + compile_comprehension(comp, pns, SCOPE_DICT_COMP); + } else { + + compile_comprehension(comp, pns, SCOPE_SET_COMP); + } + } + } else { + + goto set_with_one_element; + } + } else { + + set_with_one_element: + + + + + +# 2535 "user/mpy/py/compile.c" 3 + (( +# 2535 "user/mpy/py/compile.c" + 0 +# 2535 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2535, __func__, +# 2535 "user/mpy/py/compile.c" + "0" +# 2535 "user/mpy/py/compile.c" 3 + )) +# 2535 "user/mpy/py/compile.c" + ; + + } +} + +static void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_trailer_paren_helper(comp, pns->nodes[0], +# 2541 "user/mpy/py/compile.c" 3 4 + 0 +# 2541 "user/mpy/py/compile.c" + , 0); +} + +static void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { + + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_load_subscr(comp->emit)); +} + +static void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) { + + (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(pns->nodes[0])) >> 4))); +} +# 2613 "user/mpy/py/compile.c" +static void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) { + + compile_node(comp, pns->nodes[1]); + compile_node(comp, pns->nodes[0]); +} + +static void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) { + qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options); + + compile_store_id(comp, cname); +} + +static void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'yield' outside function"); + return; + } + if (((pns->nodes[0]) == (0))) { + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + (mp_emit_bc_yield_value(comp->emit)); + } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_yield_arg_from))) { + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + compile_node(comp, pns->nodes[0]); + compile_yield_from(comp); + } else { + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_yield_value(comp->emit)); + } +} +# 2654 "user/mpy/py/compile.c" +static mp_obj_t get_const_object(mp_parse_node_struct_t *pns) { + + + + + return (mp_obj_t)pns->nodes[0]; + +} + +static void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) { + (mp_emit_bc_load_const_obj(comp->emit, get_const_object(pns))); +} + +typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*); +static const compile_function_t compile_function[] = { + + + + +# 1 "user/mpy/py/grammar.h" 1 +# 40 "user/mpy/py/grammar.h" + +compile_generic_all_nodes, +compile_generic_all_nodes, + + + +# 58 "user/mpy/py/grammar.h" + + +compile_decorated, + + + + + + +compile_funcdef, + + + + + + + + + + + + + + + + + + + + + + + + + + +compile_generic_all_nodes, + + + + + + + + +compile_expr_stmt, + + + + + +compile_generic_tuple, + + +# 122 "user/mpy/py/grammar.h" +compile_del_stmt, +compile_generic_all_nodes, + +compile_break_stmt, +compile_continue_stmt, +compile_return_stmt, +compile_yield_stmt, +compile_raise_stmt, + + +# 145 "user/mpy/py/grammar.h" + +compile_import_name, +compile_import_from, + + + + + + + + + + + + +compile_global_stmt, +compile_nonlocal_stmt, + +compile_assert_stmt, + +# 183 "user/mpy/py/grammar.h" + + +compile_if_stmt, + + +compile_while_stmt, +compile_for_stmt, +compile_try_stmt, + + + + + + + +compile_with_stmt, + + + + + +compile_generic_all_nodes, + + + + + + + +compile_test_if_expr, + + +compile_lambdef, +compile_lambdef, +# 234 "user/mpy/py/grammar.h" +compile_or_test, +compile_and_test, + +compile_not_test_2, +compile_comparison, + + + + +compile_star_expr, +compile_expr, +compile_xor_expr, +compile_and_expr, +compile_term, + +compile_term, + +compile_term, + + +compile_factor_2, + +compile_power, + + + + + + +compile_atom_expr_normal, + + + + + + + + +compile_atom_paren, + +compile_atom_bracket, +compile_atom_brace, + + + + + + +compile_trailer_paren, +compile_trailer_bracket, +compile_trailer_period, +# 300 "user/mpy/py/grammar.h" +compile_generic_tuple, + + + + + + + + +compile_generic_tuple, + + + + + + +compile_dictorsetmaker_item, + + + + + + + +compile_classdef, + + + + + + + + + +# 342 "user/mpy/py/grammar.h" + + + + + + + + + + + + + +compile_yield_expr, + + +# 2674 "user/mpy/py/compile.c" 2 + + + + compile_const_object, +}; + +static void compile_node(compiler_t *comp, mp_parse_node_t pn) { + if (((pn) == (0))) { + + } else if ((((pn) & 0x1) == (0x1))) { + mp_int_t arg = (((mp_int_t)(intptr_t)(pn)) >> 1); +# 2700 "user/mpy/py/compile.c" + (mp_emit_bc_load_const_small_int(comp->emit, arg)); + + } else if (((pn) & 3)) { + uintptr_t arg = (((uintptr_t)(pn)) >> 4); + switch (((pn) & 0x0f)) { + case (0x02): compile_load_id(comp, arg); break; + case (0x06): (mp_emit_bc_load_const_str(comp->emit, arg)); break; + case (0x0a): + + if (comp->pass != MP_PASS_EMIT) { + (mp_emit_bc_load_const_obj(comp->emit, (((mp_obj_t)&mp_const_none_obj)))); + } else { + size_t len; + const byte *data = qstr_data(arg, &len); + (mp_emit_bc_load_const_obj(comp->emit, mp_obj_new_bytes(data, len))); + } + break; + case (0x0e): default: + if (arg == MP_TOKEN_NEWLINE) { + + + + } else { + (mp_emit_bc_load_const_tok(comp->emit, arg)); + } + break; + } + } else { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + (mp_emit_bc_set_source_line(comp->emit, pns->source_line)); + +# 2730 "user/mpy/py/compile.c" 3 + (( +# 2730 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes & 0xff) <= PN_const_object +# 2730 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2730, __func__, +# 2730 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND(pns) <= PN_const_object" +# 2730 "user/mpy/py/compile.c" 3 + )) +# 2730 "user/mpy/py/compile.c" + ; + compile_function_t f = compile_function[((pns)->kind_num_nodes & 0xff)]; + f(comp, pns); + } +} + +static void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) { + + if ((comp->scope_cur->scope_flags & (0x02)) != 0) { + compile_syntax_error(comp, pn, "invalid syntax"); + return; + } + + qstr param_name = MP_QSTR_NULL; + uint param_flag = ID_FLAG_IS_PARAM; + if ((((pn) & 0x0f) == (0x02))) { + param_name = (((uintptr_t)(pn)) >> 4); + if (comp->have_star) { + + comp->scope_cur->num_kwonly_args += 1; + } else { + + comp->scope_cur->num_pos_args += 1; + } + } else { + +# 2755 "user/mpy/py/compile.c" 3 + (( +# 2755 "user/mpy/py/compile.c" + ((pn) != (0) && ((pn) & 3) == 0) +# 2755 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2755, __func__, +# 2755 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(pn)" +# 2755 "user/mpy/py/compile.c" 3 + )) +# 2755 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if (((pns)->kind_num_nodes & 0xff) == pn_name) { + param_name = (((uintptr_t)(pns->nodes[0])) >> 4); + if (comp->have_star) { + + comp->scope_cur->num_kwonly_args += 1; + } else { + + comp->scope_cur->num_pos_args += 1; + } + } else if (((pns)->kind_num_nodes & 0xff) == pn_star) { + if (comp->have_star) { + + compile_syntax_error(comp, pn, "invalid syntax"); + return; + } + comp->have_star = +# 2772 "user/mpy/py/compile.c" 3 4 + 1 +# 2772 "user/mpy/py/compile.c" + ; + param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_STAR_PARAM; + if (((pns->nodes[0]) == (0))) { + + + + } else if ((((pns->nodes[0]) & 0x0f) == (0x02))) { + + comp->scope_cur->scope_flags |= (0x01); + param_name = (((uintptr_t)(pns->nodes[0])) >> 4); + } else { + +# 2783 "user/mpy/py/compile.c" 3 + (( +# 2783 "user/mpy/py/compile.c" + ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_tfpdef)) +# 2783 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2783, __func__, +# 2783 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)" +# 2783 "user/mpy/py/compile.c" 3 + )) +# 2783 "user/mpy/py/compile.c" + ; + + comp->scope_cur->scope_flags |= (0x01); + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + param_name = (((uintptr_t)(pns->nodes[0])) >> 4); + } + } else { + +# 2790 "user/mpy/py/compile.c" 3 + (( +# 2790 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes & 0xff) == pn_dbl_star +# 2790 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2790, __func__, +# 2790 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND(pns) == pn_dbl_star" +# 2790 "user/mpy/py/compile.c" 3 + )) +# 2790 "user/mpy/py/compile.c" + ; + param_name = (((uintptr_t)(pns->nodes[0])) >> 4); + param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_DBL_STAR_PARAM; + comp->scope_cur->scope_flags |= (0x02); + } + } + + if (param_name != MP_QSTR_NULL) { + +# 2798 "user/mpy/py/compile.c" 3 4 + _Bool +# 2798 "user/mpy/py/compile.c" + added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, param_name, &added); + if (!added) { + compile_syntax_error(comp, pn, "name reused for argument"); + return; + } + id_info->kind = ID_INFO_KIND_LOCAL; + id_info->flags = param_flag; + } +} + +static void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) { + compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star); +} + +static void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) { + compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star); +} +# 2860 "user/mpy/py/compile.c" +static void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) { + uint l_top = comp_next_label(comp); + uint l_end = comp_next_label(comp); + (mp_emit_bc_label_assign(comp->emit, l_top)); + (mp_emit_bc_for_iter(comp->emit, l_end)); + c_assign(comp, pns_comp_for->nodes[0], ASSIGN_STORE); + mp_parse_node_t pn_iter = pns_comp_for->nodes[2]; + + tail_recursion: + if (((pn_iter) == (0))) { + + compile_node(comp, pn_inner_expr); + if (comp->scope_cur->kind == SCOPE_GEN_EXPR) { + (mp_emit_bc_yield_value(comp->emit)); + (mp_emit_bc_pop_top(comp->emit)); + } else { + (mp_emit_bc_store_comp(comp->emit, comp->scope_cur->kind, 4 * for_depth + 5)); + } + } else if ((((mp_parse_node_struct_t*)pn_iter)->kind_num_nodes & 0xff) == PN_comp_if) { + + mp_parse_node_struct_t *pns_comp_if = (mp_parse_node_struct_t*)pn_iter; + c_if_cond(comp, pns_comp_if->nodes[0], +# 2881 "user/mpy/py/compile.c" 3 4 + 0 +# 2881 "user/mpy/py/compile.c" + , l_top); + pn_iter = pns_comp_if->nodes[1]; + goto tail_recursion; + } else { + +# 2885 "user/mpy/py/compile.c" 3 + (( +# 2885 "user/mpy/py/compile.c" + (((mp_parse_node_struct_t*)pn_iter)->kind_num_nodes & 0xff) == PN_comp_for +# 2885 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2885, __func__, +# 2885 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_for" +# 2885 "user/mpy/py/compile.c" 3 + )) +# 2885 "user/mpy/py/compile.c" + ; + + mp_parse_node_struct_t *pns_comp_for2 = (mp_parse_node_struct_t*)pn_iter; + compile_node(comp, pns_comp_for2->nodes[1]); + (mp_emit_bc_get_iter(comp->emit, +# 2889 "user/mpy/py/compile.c" 3 4 + 1 +# 2889 "user/mpy/py/compile.c" + )); + compile_scope_comp_iter(comp, pns_comp_for2, pn_inner_expr, for_depth + 1); + } + + (mp_emit_bc_jump(comp->emit, l_top)); + (mp_emit_bc_label_assign(comp->emit, l_end)); + (mp_emit_bc_for_iter_end(comp->emit)); +} + +static void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) { +# 2938 "user/mpy/py/compile.c" + (void)comp; + (void)pn; + +} + +static void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { + comp->pass = pass; + comp->scope_cur = scope; + comp->next_label = 0; + (mp_emit_bc_start_pass(comp->emit, pass, scope)); + + if (comp->pass == MP_PASS_SCOPE) { + + + scope->stack_size = 0; + scope->exc_stack_size = 0; + } + + + if (((scope->pn) != (0) && ((scope->pn) & 3) == 0 && (((mp_parse_node_struct_t*)(scope->pn))->kind_num_nodes & 0xff) == (PN_eval_input))) { + +# 2958 "user/mpy/py/compile.c" 3 + (( +# 2958 "user/mpy/py/compile.c" + scope->kind == SCOPE_MODULE +# 2958 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2958, __func__, +# 2958 "user/mpy/py/compile.c" + "scope->kind == SCOPE_MODULE" +# 2958 "user/mpy/py/compile.c" 3 + )) +# 2958 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + compile_node(comp, pns->nodes[0]); + (mp_emit_bc_return_value(comp->emit)); + } else if (scope->kind == SCOPE_MODULE) { + if (!comp->is_repl) { + check_for_doc_string(comp, scope->pn); + } + compile_node(comp, scope->pn); + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + (mp_emit_bc_return_value(comp->emit)); + } else if (scope->kind == SCOPE_FUNCTION) { + +# 2970 "user/mpy/py/compile.c" 3 + (( +# 2970 "user/mpy/py/compile.c" + ((scope->pn) != (0) && ((scope->pn) & 3) == 0) +# 2970 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2970, __func__, +# 2970 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(scope->pn)" +# 2970 "user/mpy/py/compile.c" 3 + )) +# 2970 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + +# 2972 "user/mpy/py/compile.c" 3 + (( +# 2972 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes & 0xff) == PN_funcdef +# 2972 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2972, __func__, +# 2972 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef" +# 2972 "user/mpy/py/compile.c" 3 + )) +# 2972 "user/mpy/py/compile.c" + ; + + + + if (comp->pass == MP_PASS_SCOPE) { + comp->have_star = +# 2977 "user/mpy/py/compile.c" 3 4 + 0 +# 2977 "user/mpy/py/compile.c" + ; + apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param); + } +# 3002 "user/mpy/py/compile.c" + compile_node(comp, pns->nodes[3]); + + if (!(mp_emit_bc_last_emit_was_return_value(comp->emit))) { + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + (mp_emit_bc_return_value(comp->emit)); + } + } else if (scope->kind == SCOPE_LAMBDA) { + +# 3009 "user/mpy/py/compile.c" 3 + (( +# 3009 "user/mpy/py/compile.c" + ((scope->pn) != (0) && ((scope->pn) & 3) == 0) +# 3009 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3009, __func__, +# 3009 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(scope->pn)" +# 3009 "user/mpy/py/compile.c" 3 + )) +# 3009 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + +# 3011 "user/mpy/py/compile.c" 3 + (( +# 3011 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes >> 8) == 3 +# 3011 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3011, __func__, +# 3011 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3" +# 3011 "user/mpy/py/compile.c" 3 + )) +# 3011 "user/mpy/py/compile.c" + ; + + + + if (comp->pass == MP_PASS_SCOPE) { + comp->have_star = +# 3016 "user/mpy/py/compile.c" 3 4 + 0 +# 3016 "user/mpy/py/compile.c" + ; + apply_to_single_or_list(comp, pns->nodes[0], PN_varargslist, compile_scope_lambda_param); + } + + compile_node(comp, pns->nodes[1]); + + + if (scope->scope_flags & (0x04)) { + (mp_emit_bc_pop_top(comp->emit)); + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + } + (mp_emit_bc_return_value(comp->emit)); + } else if (scope->kind == SCOPE_LIST_COMP || scope->kind == SCOPE_DICT_COMP || scope->kind == SCOPE_SET_COMP || scope->kind == SCOPE_GEN_EXPR) { + + + +# 3031 "user/mpy/py/compile.c" 3 + (( +# 3031 "user/mpy/py/compile.c" + ((scope->pn) != (0) && ((scope->pn) & 3) == 0) +# 3031 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3031, __func__, +# 3031 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(scope->pn)" +# 3031 "user/mpy/py/compile.c" 3 + )) +# 3031 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + +# 3033 "user/mpy/py/compile.c" 3 + (( +# 3033 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes >> 8) == 2 +# 3033 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3033, __func__, +# 3033 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2" +# 3033 "user/mpy/py/compile.c" 3 + )) +# 3033 "user/mpy/py/compile.c" + ; + +# 3034 "user/mpy/py/compile.c" 3 + (( +# 3034 "user/mpy/py/compile.c" + ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_comp_for)) +# 3034 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3034, __func__, +# 3034 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)" +# 3034 "user/mpy/py/compile.c" 3 + )) +# 3034 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; + + + + + + qstr qstr_arg = MP_QSTR_; + if (comp->pass == MP_PASS_SCOPE) { + +# 3043 "user/mpy/py/compile.c" 3 4 + _Bool +# 3043 "user/mpy/py/compile.c" + added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qstr_arg, &added); + +# 3045 "user/mpy/py/compile.c" 3 + (( +# 3045 "user/mpy/py/compile.c" + added +# 3045 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3045, __func__, +# 3045 "user/mpy/py/compile.c" + "added" +# 3045 "user/mpy/py/compile.c" 3 + )) +# 3045 "user/mpy/py/compile.c" + ; + id_info->kind = ID_INFO_KIND_LOCAL; + scope->num_pos_args = 1; + } + + if (scope->kind == SCOPE_LIST_COMP) { + (mp_emit_bc_build_list(comp->emit, 0)); + } else if (scope->kind == SCOPE_DICT_COMP) { + (mp_emit_bc_build_map(comp->emit, 0)); + + + + + } + + + + if (scope->kind == SCOPE_GEN_EXPR) { + + (mp_emit_bc_load_null(comp->emit)); + compile_load_id(comp, qstr_arg); + (mp_emit_bc_load_null(comp->emit)); + (mp_emit_bc_load_null(comp->emit)); + } else { + compile_load_id(comp, qstr_arg); + (mp_emit_bc_get_iter(comp->emit, +# 3070 "user/mpy/py/compile.c" 3 4 + 1 +# 3070 "user/mpy/py/compile.c" + )); + } + + compile_scope_comp_iter(comp, pns_comp_for, pns->nodes[0], 0); + + if (scope->kind == SCOPE_GEN_EXPR) { + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + } + (mp_emit_bc_return_value(comp->emit)); + } else { + +# 3080 "user/mpy/py/compile.c" 3 + (( +# 3080 "user/mpy/py/compile.c" + scope->kind == SCOPE_CLASS +# 3080 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3080, __func__, +# 3080 "user/mpy/py/compile.c" + "scope->kind == SCOPE_CLASS" +# 3080 "user/mpy/py/compile.c" 3 + )) +# 3080 "user/mpy/py/compile.c" + ; + +# 3081 "user/mpy/py/compile.c" 3 + (( +# 3081 "user/mpy/py/compile.c" + ((scope->pn) != (0) && ((scope->pn) & 3) == 0) +# 3081 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3081, __func__, +# 3081 "user/mpy/py/compile.c" + "MP_PARSE_NODE_IS_STRUCT(scope->pn)" +# 3081 "user/mpy/py/compile.c" 3 + )) +# 3081 "user/mpy/py/compile.c" + ; + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + +# 3083 "user/mpy/py/compile.c" 3 + (( +# 3083 "user/mpy/py/compile.c" + ((pns)->kind_num_nodes & 0xff) == PN_classdef +# 3083 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3083, __func__, +# 3083 "user/mpy/py/compile.c" + "MP_PARSE_NODE_STRUCT_KIND(pns) == PN_classdef" +# 3083 "user/mpy/py/compile.c" 3 + )) +# 3083 "user/mpy/py/compile.c" + ; + + if (comp->pass == MP_PASS_SCOPE) { + +# 3086 "user/mpy/py/compile.c" 3 4 + _Bool +# 3086 "user/mpy/py/compile.c" + added; + id_info_t *id_info = scope_find_or_add_id(scope, MP_QSTR___class__, &added); + +# 3088 "user/mpy/py/compile.c" 3 + (( +# 3088 "user/mpy/py/compile.c" + added +# 3088 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3088, __func__, +# 3088 "user/mpy/py/compile.c" + "added" +# 3088 "user/mpy/py/compile.c" 3 + )) +# 3088 "user/mpy/py/compile.c" + ; + id_info->kind = ID_INFO_KIND_LOCAL; + } + + compile_load_id(comp, MP_QSTR___name__); + compile_store_id(comp, MP_QSTR___module__); + (mp_emit_bc_load_const_str(comp->emit, (((uintptr_t)(pns->nodes[0])) >> 4))); + compile_store_id(comp, MP_QSTR___qualname__); + + check_for_doc_string(comp, pns->nodes[2]); + compile_node(comp, pns->nodes[2]); + + id_info_t *id = scope_find(scope, MP_QSTR___class__); + +# 3101 "user/mpy/py/compile.c" 3 + (( +# 3101 "user/mpy/py/compile.c" + id != +# 3101 "user/mpy/py/compile.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3101, __func__, +# 3101 "user/mpy/py/compile.c" + "id != NULL" +# 3101 "user/mpy/py/compile.c" 3 + )) +# 3101 "user/mpy/py/compile.c" + ; + if (id->kind == ID_INFO_KIND_LOCAL) { + (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); + } else { + (mp_emit_bc_load_fast(comp->emit, MP_QSTR___class__, id->local_num)); + } + (mp_emit_bc_return_value(comp->emit)); + } + + (mp_emit_bc_end_pass(comp->emit)); + + + +# 3113 "user/mpy/py/compile.c" 3 + (( +# 3113 "user/mpy/py/compile.c" + comp->cur_except_level == 0 +# 3113 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3113, __func__, +# 3113 "user/mpy/py/compile.c" + "comp->cur_except_level == 0" +# 3113 "user/mpy/py/compile.c" 3 + )) +# 3113 "user/mpy/py/compile.c" + ; +} +# 3277 "user/mpy/py/compile.c" +static void scope_compute_things(scope_t *scope) { + + if (scope->scope_flags & (0x01)) { + id_info_t *id_param = +# 3280 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3280 "user/mpy/py/compile.c" + ; + for (int i = scope->id_info_len - 1; i >= 0; i--) { + id_info_t *id = &scope->id_info[i]; + if (id->flags & ID_FLAG_IS_STAR_PARAM) { + if (id_param != +# 3284 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3284 "user/mpy/py/compile.c" + ) { + + id_info_t temp = *id_param; *id_param = *id; *id = temp; + } + break; + } else if (id_param == +# 3289 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3289 "user/mpy/py/compile.c" + && id->flags == ID_FLAG_IS_PARAM) { + id_param = id; + } + } + } + + + + scope->num_locals = 0; + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (scope->kind == SCOPE_CLASS && id->qst == MP_QSTR___class__) { + + continue; + } + if (((scope->kind) >= SCOPE_LAMBDA) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; + } + + if (id->kind == ID_INFO_KIND_LOCAL || (id->flags & ID_FLAG_IS_PARAM)) { + id->local_num = scope->num_locals++; + } + } + + + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + + + + if (id->kind == ID_INFO_KIND_CELL && !(id->flags & ID_FLAG_IS_PARAM)) { + id->local_num = scope->num_locals; + scope->num_locals += 1; + } + } + + + + if (scope->parent != +# 3327 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3327 "user/mpy/py/compile.c" + ) { + int num_free = 0; + for (int i = 0; i < scope->parent->id_info_len; i++) { + id_info_t *id = &scope->parent->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { + for (int j = 0; j < scope->id_info_len; j++) { + id_info_t *id2 = &scope->id_info[j]; + if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { + +# 3335 "user/mpy/py/compile.c" 3 + (( +# 3335 "user/mpy/py/compile.c" + !(id2->flags & ID_FLAG_IS_PARAM) +# 3335 "user/mpy/py/compile.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3335, __func__, +# 3335 "user/mpy/py/compile.c" + "!(id2->flags & ID_FLAG_IS_PARAM)" +# 3335 "user/mpy/py/compile.c" 3 + )) +# 3335 "user/mpy/py/compile.c" + ; + + id2->local_num = num_free; + num_free += 1; + } + } + } + } + + if (num_free > 0) { + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (id->kind != ID_INFO_KIND_FREE || (id->flags & ID_FLAG_IS_PARAM)) { + id->local_num += num_free; + } + } + scope->num_pos_args += num_free; + scope->num_locals += num_free; + } + } +} + + +static + +mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, +# 3360 "user/mpy/py/compile.c" 3 4 + _Bool +# 3360 "user/mpy/py/compile.c" + is_repl) { + + compiler_t comp_state = {0}; + compiler_t *comp = &comp_state; + + comp->source_file = source_file; + comp->is_repl = is_repl; + comp->break_label = (0xffff); + comp->continue_label = (0xffff); + + + scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, parse_tree->root, emit_opt); + + + emit_t *emit_bc = emit_bc_new(); + + + comp->emit = emit_bc; + + + + uint max_num_labels = 0; + for (scope_t *s = comp->scope_head; s != +# 3382 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3382 "user/mpy/py/compile.c" + && comp->compile_error == (((mp_obj_t)(void*)0)); s = s->next) { + if ( +# 3383 "user/mpy/py/compile.c" 3 4 + 0 +# 3383 "user/mpy/py/compile.c" + ) { + + + + + } else { + compile_scope(comp, s, MP_PASS_SCOPE); + } + + + if (comp->next_label > max_num_labels) { + max_num_labels = comp->next_label; + } + } + + + for (scope_t *s = comp->scope_head; s != +# 3399 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3399 "user/mpy/py/compile.c" + && comp->compile_error == (((mp_obj_t)(void*)0)); s = s->next) { + scope_compute_things(s); + } + + + emit_bc_set_max_num_labels(emit_bc, max_num_labels); + + + + + + for (scope_t *s = comp->scope_head; s != +# 3410 "user/mpy/py/compile.c" 3 4 + ((void *)0) +# 3410 "user/mpy/py/compile.c" + && comp->compile_error == (((mp_obj_t)(void*)0)); s = s->next) { + if ( +# 3411 "user/mpy/py/compile.c" 3 4 + 0 +# 3411 "user/mpy/py/compile.c" + ) { +# 3434 "user/mpy/py/compile.c" + } else { + + + + switch (s->emit_options) { +# 3452 "user/mpy/py/compile.c" + default: + comp->emit = emit_bc; + + + + break; + } + + + compile_scope(comp, s, MP_PASS_STACK_SIZE); + + + if (comp->compile_error == (((mp_obj_t)(void*)0))) { + compile_scope(comp, s, MP_PASS_CODE_SIZE); + } + + + if (comp->compile_error == (((mp_obj_t)(void*)0))) { + compile_scope(comp, s, MP_PASS_EMIT); + } + } + } + + if (comp->compile_error != (((mp_obj_t)(void*)0))) { + + + compile_error_set_line(comp, comp->scope_cur->pn); + + mp_obj_exception_add_traceback(comp->compile_error, comp->source_file, + comp->compile_error_line, comp->scope_cur->simple_name); + } + + + + emit_bc_free(emit_bc); +# 3499 "user/mpy/py/compile.c" + mp_parse_tree_clear(parse_tree); + + + mp_raw_code_t *outer_raw_code = module_scope->raw_code; + for (scope_t *s = module_scope; s;) { + scope_t *next = s->next; + scope_free(s); + s = next; + } + + if (comp->compile_error != (((mp_obj_t)(void*)0))) { + nlr_jump(((void*)comp->compile_error)); + } else { + return outer_raw_code; + } +} + +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, +# 3516 "user/mpy/py/compile.c" 3 4 + _Bool +# 3516 "user/mpy/py/compile.c" + is_repl) { + mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl); + + return mp_make_function_from_raw_code(rc, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))); +} +# 1 "user/mpy/py/emitcommon.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/emitcommon.c" +# 27 "user/mpy/py/emitcommon.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/emitcommon.c" 2 + +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 29 "user/mpy/py/lexer.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/lexer.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 31 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 30 "user/mpy/py/emitcommon.c" 2 + + + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst) { + + +# 35 "user/mpy/py/emitcommon.c" 3 4 + _Bool +# 35 "user/mpy/py/emitcommon.c" + added; + id_info_t *id = scope_find_or_add_id(scope, qst, &added); + if (added) { + scope_find_local_and_close_over(scope, id, qst); + } +} + +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst) { + + +# 44 "user/mpy/py/emitcommon.c" 3 4 + _Bool +# 44 "user/mpy/py/emitcommon.c" + added; + id_info_t *id = scope_find_or_add_id(scope, qst, &added); + if (added) { + if (((scope->kind) >= SCOPE_LAMBDA)) { + id->kind = ID_INFO_KIND_LOCAL; + } else { + id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; + } + } else if (((scope->kind) >= SCOPE_LAMBDA) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + + id->kind = ID_INFO_KIND_LOCAL; + } +} + +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst) { + + + id_info_t *id = scope_find(scope, qst); + +# 62 "user/mpy/py/emitcommon.c" 3 + (( +# 62 "user/mpy/py/emitcommon.c" + id != +# 62 "user/mpy/py/emitcommon.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/emitcommon.c", 62, __func__, +# 62 "user/mpy/py/emitcommon.c" + "id != NULL" +# 62 "user/mpy/py/emitcommon.c" 3 + )) +# 62 "user/mpy/py/emitcommon.c" + ; + + + if (id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + emit_method_table->name(emit, qst); + } else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) { + emit_method_table->global(emit, qst); + } else if (id->kind == ID_INFO_KIND_LOCAL) { + emit_method_table->fast(emit, qst, id->local_num); + } else { + +# 72 "user/mpy/py/emitcommon.c" 3 + (( +# 72 "user/mpy/py/emitcommon.c" + id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE +# 72 "user/mpy/py/emitcommon.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitcommon.c", 72, __func__, +# 72 "user/mpy/py/emitcommon.c" + "id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE" +# 72 "user/mpy/py/emitcommon.c" 3 + )) +# 72 "user/mpy/py/emitcommon.c" + ; + emit_method_table->deref(emit, qst, id->local_num); + } +} +# 1 "user/mpy/py/emitbc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/emitbc.c" +# 27 "user/mpy/py/emitbc.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 28 "user/mpy/py/emitbc.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 29 "user/mpy/py/emitbc.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 30 "user/mpy/py/emitbc.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/emitbc.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/emitbc.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 31 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 35 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 34 "user/mpy/py/emitbc.c" 2 +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 31 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 35 "user/mpy/py/emitbc.c" 2 +# 1 "user/mpy/py/bc0.h" 1 +# 36 "user/mpy/py/emitbc.c" 2 + + + + + + +struct _emit_t { + + + + byte dummy_data[((((sizeof(mp_uint_t)) * 8 + 6) / 7))]; + + pass_kind_t pass : 8; + mp_uint_t last_emit_was_return_value : 8; + + int stack_size; + + scope_t *scope; + + mp_uint_t last_source_line_offset; + mp_uint_t last_source_line; + + mp_uint_t max_num_labels; + mp_uint_t *label_offsets; + + size_t code_info_offset; + size_t code_info_size; + size_t bytecode_offset; + size_t bytecode_size; + byte *code_base; + + + uint16_t ct_cur_obj; + uint16_t ct_num_obj; + uint16_t ct_cur_raw_code; + + mp_uint_t *const_table; +}; + +emit_t *emit_bc_new(void) { + emit_t *emit = ((emit_t*)(m_malloc0(sizeof(emit_t) * (1)))); + return emit; +} + +void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels) { + emit->max_num_labels = max_num_labels; + emit->label_offsets = ((mp_uint_t*)(m_malloc(sizeof(mp_uint_t) * (emit->max_num_labels)))); +} + +void emit_bc_free(emit_t *emit) { + ((void)(emit->max_num_labels), m_free(emit->label_offsets)); + (((void)(1), m_free(emit))); +} + +typedef byte *(*emit_allocator_t)(emit_t *emit, int nbytes); + +static void emit_write_uint(emit_t *emit, emit_allocator_t allocator, mp_uint_t val) { + + byte buf[(((sizeof(mp_uint_t)) * 8 + 6) / 7)]; + byte *p = buf + sizeof(buf); + + do { + *--p = val & 0x7f; + val >>= 7; + } while (val != 0); + byte *c = allocator(emit, buf + sizeof(buf) - p); + while (p != buf + sizeof(buf) - 1) { + *c++ = *p++ | 0x80; + } + *c = *p; +} + + +static byte *emit_get_cur_to_write_code_info(emit_t *emit, int num_bytes_to_write) { + + if (emit->pass < MP_PASS_EMIT) { + emit->code_info_offset += num_bytes_to_write; + return emit->dummy_data; + } else { + +# 115 "user/mpy/py/emitbc.c" 3 + (( +# 115 "user/mpy/py/emitbc.c" + emit->code_info_offset + num_bytes_to_write <= emit->code_info_size +# 115 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 115, __func__, +# 115 "user/mpy/py/emitbc.c" + "emit->code_info_offset + num_bytes_to_write <= emit->code_info_size" +# 115 "user/mpy/py/emitbc.c" 3 + )) +# 115 "user/mpy/py/emitbc.c" + ; + byte *c = emit->code_base + emit->code_info_offset; + emit->code_info_offset += num_bytes_to_write; + return c; + } +} + +static void emit_write_code_info_byte(emit_t* emit, byte val) { + *emit_get_cur_to_write_code_info(emit, 1) = val; +} + +static void emit_write_code_info_uint(emit_t* emit, mp_uint_t val) { + emit_write_uint(emit, emit_get_cur_to_write_code_info, val); +} + +static void emit_write_code_info_qstr(emit_t *emit, qstr qst) { + + +# 132 "user/mpy/py/emitbc.c" 3 + (( +# 132 "user/mpy/py/emitbc.c" + (qst >> 16) == 0 +# 132 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 132, __func__, +# 132 "user/mpy/py/emitbc.c" + "(qst >> 16) == 0" +# 132 "user/mpy/py/emitbc.c" 3 + )) +# 132 "user/mpy/py/emitbc.c" + ; + byte *c = emit_get_cur_to_write_code_info(emit, 2); + c[0] = qst; + c[1] = qst >> 8; + + + +} +# 172 "user/mpy/py/emitbc.c" +static byte *emit_get_cur_to_write_bytecode(emit_t *emit, int num_bytes_to_write) { + + if (emit->pass < MP_PASS_EMIT) { + emit->bytecode_offset += num_bytes_to_write; + return emit->dummy_data; + } else { + +# 178 "user/mpy/py/emitbc.c" 3 + (( +# 178 "user/mpy/py/emitbc.c" + emit->bytecode_offset + num_bytes_to_write <= emit->bytecode_size +# 178 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 178, __func__, +# 178 "user/mpy/py/emitbc.c" + "emit->bytecode_offset + num_bytes_to_write <= emit->bytecode_size" +# 178 "user/mpy/py/emitbc.c" 3 + )) +# 178 "user/mpy/py/emitbc.c" + ; + byte *c = emit->code_base + emit->code_info_size + emit->bytecode_offset; + emit->bytecode_offset += num_bytes_to_write; + return c; + } +} + +static void emit_write_bytecode_byte(emit_t *emit, byte b1) { + byte *c = emit_get_cur_to_write_bytecode(emit, 1); + c[0] = b1; +} + +static void emit_write_bytecode_byte_byte(emit_t* emit, byte b1, byte b2) { + byte *c = emit_get_cur_to_write_bytecode(emit, 2); + c[0] = b1; + c[1] = b2; +} + + +static void emit_write_bytecode_byte_int(emit_t *emit, byte b1, mp_int_t num) { + emit_write_bytecode_byte(emit, b1); + + + byte buf[(((sizeof(mp_uint_t)) * 8 + 6) / 7)]; + byte *p = buf + sizeof(buf); + + do { + *--p = num & 0x7f; + num >>= 7; + } while (num != 0 && num != -1); + + + if (num == -1 && (*p & 0x40) == 0) { + *--p = 0x7f; + } else if (num == 0 && (*p & 0x40) != 0) { + *--p = 0; + } + + byte *c = emit_get_cur_to_write_bytecode(emit, buf + sizeof(buf) - p); + while (p != buf + sizeof(buf) - 1) { + *c++ = *p++ | 0x80; + } + *c = *p; +} + +static void emit_write_bytecode_byte_uint(emit_t *emit, byte b, mp_uint_t val) { + emit_write_bytecode_byte(emit, b); + emit_write_uint(emit, emit_get_cur_to_write_bytecode, val); +} + + +static void emit_write_bytecode_byte_const(emit_t *emit, byte b, mp_uint_t n, mp_uint_t c) { + if (emit->pass == MP_PASS_EMIT) { + emit->const_table[n] = c; + } + emit_write_bytecode_byte_uint(emit, b, n); +} + + +static void emit_write_bytecode_byte_qstr(emit_t* emit, byte b, qstr qst) { + + +# 239 "user/mpy/py/emitbc.c" 3 + (( +# 239 "user/mpy/py/emitbc.c" + (qst >> 16) == 0 +# 239 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 239, __func__, +# 239 "user/mpy/py/emitbc.c" + "(qst >> 16) == 0" +# 239 "user/mpy/py/emitbc.c" 3 + )) +# 239 "user/mpy/py/emitbc.c" + ; + byte *c = emit_get_cur_to_write_bytecode(emit, 3); + c[0] = b; + c[1] = qst; + c[2] = qst >> 8; + + + +} + +static void emit_write_bytecode_byte_obj(emit_t *emit, byte b, mp_obj_t obj) { + + emit_write_bytecode_byte_const(emit, b, + emit->scope->num_pos_args + emit->scope->num_kwonly_args + + emit->ct_cur_obj++, (mp_uint_t)obj); +# 263 "user/mpy/py/emitbc.c" +} + +static void emit_write_bytecode_byte_raw_code(emit_t *emit, byte b, mp_raw_code_t *rc) { + + emit_write_bytecode_byte_const(emit, b, + emit->scope->num_pos_args + emit->scope->num_kwonly_args + + emit->ct_num_obj + emit->ct_cur_raw_code++, (mp_uint_t)(uintptr_t)rc); +# 279 "user/mpy/py/emitbc.c" +} + + +static void emit_write_bytecode_byte_unsigned_label(emit_t *emit, byte b1, mp_uint_t label) { + mp_uint_t bytecode_offset; + if (emit->pass < MP_PASS_EMIT) { + bytecode_offset = 0; + } else { + bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3; + } + byte *c = emit_get_cur_to_write_bytecode(emit, 3); + c[0] = b1; + c[1] = bytecode_offset; + c[2] = bytecode_offset >> 8; +} + + +static void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint_t label) { + int bytecode_offset; + if (emit->pass < MP_PASS_EMIT) { + bytecode_offset = 0; + } else { + bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3 + 0x8000; + } + byte *c = emit_get_cur_to_write_bytecode(emit, 3); + c[0] = b1; + c[1] = bytecode_offset; + c[2] = bytecode_offset >> 8; +} + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { + emit->pass = pass; + emit->stack_size = 0; + emit->last_emit_was_return_value = +# 312 "user/mpy/py/emitbc.c" 3 4 + 0 +# 312 "user/mpy/py/emitbc.c" + ; + emit->scope = scope; + emit->last_source_line_offset = 0; + emit->last_source_line = 1; + if (pass < MP_PASS_EMIT) { + memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(mp_uint_t)); + } + emit->bytecode_offset = 0; + emit->code_info_offset = 0; + + + { + mp_uint_t n_state = scope->num_locals + scope->stack_size; + if (n_state == 0) { + + + + n_state = 1; + } + emit_write_code_info_uint(emit, n_state); + emit_write_code_info_uint(emit, scope->exc_stack_size); + } + + + + emit_write_code_info_byte(emit, emit->scope->scope_flags); + emit_write_code_info_byte(emit, emit->scope->num_pos_args); + emit_write_code_info_byte(emit, emit->scope->num_kwonly_args); + emit_write_code_info_byte(emit, emit->scope->num_def_pos_args); + + + + + if (pass == MP_PASS_EMIT) { + emit_write_code_info_uint(emit, emit->code_info_size - emit->code_info_offset); + } else { + emit_get_cur_to_write_code_info(emit, 2); + } + + + emit_write_code_info_qstr(emit, scope->simple_name); + emit_write_code_info_qstr(emit, scope->source_file); + + + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL) { + +# 359 "user/mpy/py/emitbc.c" 3 + (( +# 359 "user/mpy/py/emitbc.c" + id->local_num < 255 +# 359 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 359, __func__, +# 359 "user/mpy/py/emitbc.c" + "id->local_num < 255" +# 359 "user/mpy/py/emitbc.c" 3 + )) +# 359 "user/mpy/py/emitbc.c" + ; + emit_write_bytecode_byte(emit, id->local_num); + } + } + emit_write_bytecode_byte(emit, 255); + + + emit->ct_cur_obj = 0; + emit->ct_cur_raw_code = 0; + + + if (pass == MP_PASS_EMIT) { +# 386 "user/mpy/py/emitbc.c" + for (int i = 0; i < scope->num_pos_args + scope->num_kwonly_args; i++) { + qstr qst = MP_QSTR__star_; + for (int j = 0; j < scope->id_info_len; ++j) { + id_info_t *id = &scope->id_info[j]; + if ((id->flags & ID_FLAG_IS_PARAM) && id->local_num == i) { + qst = id->qst; + break; + } + } + emit->const_table[i] = (mp_uint_t)((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)); + } + } +} + +void mp_emit_bc_end_pass(emit_t *emit) { + if (emit->pass == MP_PASS_SCOPE) { + return; + } + + + +# 406 "user/mpy/py/emitbc.c" 3 + (( +# 406 "user/mpy/py/emitbc.c" + emit->stack_size == 0 +# 406 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 406, __func__, +# 406 "user/mpy/py/emitbc.c" + "emit->stack_size == 0" +# 406 "user/mpy/py/emitbc.c" 3 + )) +# 406 "user/mpy/py/emitbc.c" + ; + + emit_write_code_info_byte(emit, 0); + + + +# 411 "user/mpy/py/emitbc.c" 3 + (( +# 411 "user/mpy/py/emitbc.c" + emit->pass <= MP_PASS_STACK_SIZE || (emit->ct_num_obj == emit->ct_cur_obj) +# 411 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 411, __func__, +# 411 "user/mpy/py/emitbc.c" + "emit->pass <= MP_PASS_STACK_SIZE || (emit->ct_num_obj == emit->ct_cur_obj)" +# 411 "user/mpy/py/emitbc.c" 3 + )) +# 411 "user/mpy/py/emitbc.c" + ; + emit->ct_num_obj = emit->ct_cur_obj; + + + if (emit->pass == MP_PASS_CODE_SIZE) { + + + + + + + emit->code_info_size = emit->code_info_offset; + emit->bytecode_size = emit->bytecode_offset; + emit->code_base = ((byte*)(m_malloc0(sizeof(byte) * (emit->code_info_size + emit->bytecode_size)))); + + + emit->const_table = ((mp_uint_t*)(m_malloc0(sizeof(mp_uint_t) * (emit->scope->num_pos_args + emit->scope->num_kwonly_args + emit->ct_cur_obj + emit->ct_cur_raw_code)))) + + ; + + + + + + } else if (emit->pass == MP_PASS_EMIT) { + mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base, + emit->code_info_size + emit->bytecode_size, + emit->const_table, + + + + emit->scope->scope_flags); + } +} + + +# 446 "user/mpy/py/emitbc.c" 3 4 +_Bool +# 446 "user/mpy/py/emitbc.c" + mp_emit_bc_last_emit_was_return_value(emit_t *emit) { + return emit->last_emit_was_return_value; +} + +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta) { + if (emit->pass == MP_PASS_SCOPE) { + return; + } + +# 454 "user/mpy/py/emitbc.c" 3 + (( +# 454 "user/mpy/py/emitbc.c" + (mp_int_t)emit->stack_size + delta >= 0 +# 454 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 454, __func__, +# 454 "user/mpy/py/emitbc.c" + "(mp_int_t)emit->stack_size + delta >= 0" +# 454 "user/mpy/py/emitbc.c" 3 + )) +# 454 "user/mpy/py/emitbc.c" + ; + emit->stack_size += delta; + if (emit->stack_size > emit->scope->stack_size) { + emit->scope->stack_size = emit->stack_size; + } + emit->last_emit_was_return_value = +# 459 "user/mpy/py/emitbc.c" 3 4 + 0 +# 459 "user/mpy/py/emitbc.c" + ; +} + +static inline void emit_bc_pre(emit_t *emit, mp_int_t stack_size_delta) { + mp_emit_bc_adjust_stack_size(emit, stack_size_delta); +} + +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) { +# 481 "user/mpy/py/emitbc.c" + (void)emit; + (void)source_line; + +} + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) { + emit_bc_pre(emit, 0); + if (emit->pass == MP_PASS_SCOPE) { + return; + } + +# 491 "user/mpy/py/emitbc.c" 3 + (( +# 491 "user/mpy/py/emitbc.c" + l < emit->max_num_labels +# 491 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 491, __func__, +# 491 "user/mpy/py/emitbc.c" + "l < emit->max_num_labels" +# 491 "user/mpy/py/emitbc.c" 3 + )) +# 491 "user/mpy/py/emitbc.c" + ; + if (emit->pass < MP_PASS_EMIT) { + + +# 494 "user/mpy/py/emitbc.c" 3 + (( +# 494 "user/mpy/py/emitbc.c" + emit->label_offsets[l] == (mp_uint_t)-1 +# 494 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 494, __func__, +# 494 "user/mpy/py/emitbc.c" + "emit->label_offsets[l] == (mp_uint_t)-1" +# 494 "user/mpy/py/emitbc.c" 3 + )) +# 494 "user/mpy/py/emitbc.c" + ; + emit->label_offsets[l] = emit->bytecode_offset; + } else { + + + +# 499 "user/mpy/py/emitbc.c" 3 + (( +# 499 "user/mpy/py/emitbc.c" + emit->label_offsets[l] == emit->bytecode_offset +# 499 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 499, __func__, +# 499 "user/mpy/py/emitbc.c" + "emit->label_offsets[l] == emit->bytecode_offset" +# 499 "user/mpy/py/emitbc.c" 3 + )) +# 499 "user/mpy/py/emitbc.c" + ; + } +} + +void mp_emit_bc_import_name(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_qstr(emit, (0x68), qst); +} + +void mp_emit_bc_import_from(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, (0x69), qst); +} + +void mp_emit_bc_import_star(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, (0x6a)); +} + +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { + emit_bc_pre(emit, 1); + switch (tok) { + case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, (0x10)); break; + case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, (0x11)); break; + case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, (0x12)); break; + default: + +# 525 "user/mpy/py/emitbc.c" 3 + (( +# 525 "user/mpy/py/emitbc.c" + tok == MP_TOKEN_ELLIPSIS +# 525 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 525, __func__, +# 525 "user/mpy/py/emitbc.c" + "tok == MP_TOKEN_ELLIPSIS" +# 525 "user/mpy/py/emitbc.c" 3 + )) +# 525 "user/mpy/py/emitbc.c" + ; + emit_write_bytecode_byte_obj(emit, (0x17), ((mp_obj_t)&mp_const_ellipsis_obj)); + break; + } +} + +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) { + emit_bc_pre(emit, 1); + if (-16 <= arg && arg <= 47) { + emit_write_bytecode_byte(emit, (0x70) + 16 + arg); + } else { + emit_write_bytecode_byte_int(emit, (0x14), arg); + } +} + +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, (0x16), qst); +} + +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_obj(emit, (0x17), obj); +} + +void mp_emit_bc_load_null(emit_t *emit) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte(emit, (0x18)); +}; + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, 1); + if (local_num <= 15) { + emit_write_bytecode_byte(emit, (0xb0) + local_num); + } else { + emit_write_bytecode_byte_uint(emit, (0x19), local_num); + } +} + +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_uint(emit, (0x1a), local_num); +} + +void mp_emit_bc_load_name(emit_t *emit, qstr qst) { + (void)qst; + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, (0x1b), qst); + if ((0)) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_load_global(emit_t *emit, qstr qst) { + (void)qst; + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, (0x1c), qst); + if ((0)) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_load_attr(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_qstr(emit, (0x1d), qst); + if ((0)) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 597 "user/mpy/py/emitbc.c" 3 4 + _Bool +# 597 "user/mpy/py/emitbc.c" + is_super) { + emit_bc_pre(emit, 1 - 2 * is_super); + emit_write_bytecode_byte_qstr(emit, is_super ? (0x1f) : (0x1e), qst); +} + +void mp_emit_bc_load_build_class(emit_t *emit) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte(emit, (0x20)); +} + +void mp_emit_bc_load_subscr(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, (0x21)); +} + +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, -1); + if (local_num <= 15) { + emit_write_bytecode_byte(emit, (0xc0) + local_num); + } else { + emit_write_bytecode_byte_uint(emit, (0x22), local_num); + } +} + +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_uint(emit, (0x23), local_num); +} + +void mp_emit_bc_store_name(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_qstr(emit, (0x24), qst); +} + +void mp_emit_bc_store_global(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_qstr(emit, (0x25), qst); +} + +void mp_emit_bc_store_attr(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -2); + emit_write_bytecode_byte_qstr(emit, (0x26), qst); + if ((0)) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_store_subscr(emit_t *emit) { + emit_bc_pre(emit, -3); + emit_write_bytecode_byte(emit, (0x27)); +} + +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_write_bytecode_byte_uint(emit, (0x28), local_num); +} + +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_write_bytecode_byte_uint(emit, (0x29), local_num); +} + +void mp_emit_bc_delete_name(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_qstr(emit, (0x2a), qst); +} + +void mp_emit_bc_delete_global(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_qstr(emit, (0x2b), qst); +} + +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst) { + mp_emit_bc_load_null(emit); + mp_emit_bc_rot_two(emit); + mp_emit_bc_store_attr(emit, qst); +} + +void mp_emit_bc_delete_subscr(emit_t *emit) { + mp_emit_bc_load_null(emit); + mp_emit_bc_rot_three(emit); + mp_emit_bc_store_subscr(emit); +} + +void mp_emit_bc_dup_top(emit_t *emit) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte(emit, (0x30)); +} + +void mp_emit_bc_dup_top_two(emit_t *emit) { + emit_bc_pre(emit, 2); + emit_write_bytecode_byte(emit, (0x31)); +} + +void mp_emit_bc_pop_top(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, (0x32)); +} + +void mp_emit_bc_rot_two(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, (0x33)); +} + +void mp_emit_bc_rot_three(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, (0x34)); +} + +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_signed_label(emit, (0x35), label); +} + +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 713 "user/mpy/py/emitbc.c" 3 4 + _Bool +# 713 "user/mpy/py/emitbc.c" + cond, mp_uint_t label) { + emit_bc_pre(emit, -1); + if (cond) { + emit_write_bytecode_byte_signed_label(emit, (0x36), label); + } else { + emit_write_bytecode_byte_signed_label(emit, (0x37), label); + } +} + +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 722 "user/mpy/py/emitbc.c" 3 4 + _Bool +# 722 "user/mpy/py/emitbc.c" + cond, mp_uint_t label) { + emit_bc_pre(emit, -1); + if (cond) { + emit_write_bytecode_byte_signed_label(emit, (0x38), label); + } else { + emit_write_bytecode_byte_signed_label(emit, (0x39), label); + } +} + +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { + if (except_depth == 0) { + emit_bc_pre(emit, 0); + if (label & (0x8000)) { + + emit_write_bytecode_byte(emit, (0x32)); + + for (size_t i = 0; i < ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) - 1; ++i) { + emit_write_bytecode_byte(emit, (0x32)); + } + } + emit_write_bytecode_byte_signed_label(emit, (0x35), label & ~(0x8000)); + } else { + emit_write_bytecode_byte_signed_label(emit, (0x46), label & ~(0x8000)); + emit_write_bytecode_byte(emit, ((label & (0x8000)) ? 0x80 : 0) | except_depth); + } +} + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label) { + + + emit_bc_pre(emit, 2); + emit_write_bytecode_byte_unsigned_label(emit, (0x3d), label); +} + +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label) { + mp_emit_bc_pop_block(emit); + mp_emit_bc_load_const_tok(emit, MP_TOKEN_KW_NONE); + mp_emit_bc_label_assign(emit, label); + emit_bc_pre(emit, 2); + emit_write_bytecode_byte(emit, (0x3e)); + emit_bc_pre(emit, -4); +} + +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_unsigned_label(emit, (0x3f), label); +} + +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_unsigned_label(emit, (0x40), label); +} + +void mp_emit_bc_end_finally(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, (0x41)); +} + +void mp_emit_bc_get_iter(emit_t *emit, +# 780 "user/mpy/py/emitbc.c" 3 4 + _Bool +# 780 "user/mpy/py/emitbc.c" + use_stack) { + emit_bc_pre(emit, use_stack ? ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) - 1 : 0); + emit_write_bytecode_byte(emit, use_stack ? (0x47) : (0x42)); +} + +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_unsigned_label(emit, (0x43), label); +} + +void mp_emit_bc_for_iter_end(emit_t *emit) { + emit_bc_pre(emit, -((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t))); +} + +void mp_emit_bc_pop_block(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, (0x44)); +} + +void mp_emit_bc_pop_except(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, (0x45)); +} + +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, (0xd0) + op); +} + +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op) { + +# 810 "user/mpy/py/emitbc.c" 3 4 + _Bool +# 810 "user/mpy/py/emitbc.c" + invert = +# 810 "user/mpy/py/emitbc.c" 3 4 + 0 +# 810 "user/mpy/py/emitbc.c" + ; + if (op == MP_BINARY_OP_NOT_IN) { + invert = +# 812 "user/mpy/py/emitbc.c" 3 4 + 1 +# 812 "user/mpy/py/emitbc.c" + ; + op = MP_BINARY_OP_IN; + } else if (op == MP_BINARY_OP_IS_NOT) { + invert = +# 815 "user/mpy/py/emitbc.c" 3 4 + 1 +# 815 "user/mpy/py/emitbc.c" + ; + op = MP_BINARY_OP_IS; + } + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, (0xd7) + op); + if (invert) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, (0xd0) + MP_UNARY_OP_NOT); + } +} + +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1 - n_args); + emit_write_bytecode_byte_uint(emit, (0x50), n_args); +} + +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1 - n_args); + emit_write_bytecode_byte_uint(emit, (0x51), n_args); +} + +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_uint(emit, (0x53), n_args); +} + +void mp_emit_bc_store_map(emit_t *emit) { + emit_bc_pre(emit, -2); + emit_write_bytecode_byte(emit, (0x54)); +} +# 860 "user/mpy/py/emitbc.c" +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_stack_index) { + int t; + int n; + if (kind == SCOPE_LIST_COMP) { + n = 0; + t = 0; + } else if (!(0) || kind == SCOPE_DICT_COMP) { + n = 1; + t = 1; + } else if ((0)) { + n = 0; + t = 2; + } + emit_bc_pre(emit, -1 - n); + + emit_write_bytecode_byte_uint(emit, (0x57), ((collection_stack_index + n) << 2) | t); +} + +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, -1 + n_args); + emit_write_bytecode_byte_uint(emit, (0x59), n_args); +} + +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) { + emit_bc_pre(emit, -1 + n_left + n_right + 1); + emit_write_bytecode_byte_uint(emit, (0x5a), n_left | (n_right << 8)); +} + +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { + if (n_pos_defaults == 0 && n_kw_defaults == 0) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_raw_code(emit, (0x60), scope->raw_code); + } else { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_raw_code(emit, (0x61), scope->raw_code); + } +} + +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { + if (n_pos_defaults == 0 && n_kw_defaults == 0) { + emit_bc_pre(emit, -n_closed_over + 1); + emit_write_bytecode_byte_raw_code(emit, (0x62), scope->raw_code); + emit_write_bytecode_byte(emit, n_closed_over); + } else { + +# 904 "user/mpy/py/emitbc.c" 3 + (( +# 904 "user/mpy/py/emitbc.c" + n_closed_over <= 255 +# 904 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 904, __func__, +# 904 "user/mpy/py/emitbc.c" + "n_closed_over <= 255" +# 904 "user/mpy/py/emitbc.c" 3 + )) +# 904 "user/mpy/py/emitbc.c" + ; + emit_bc_pre(emit, -2 - (mp_int_t)n_closed_over + 1); + emit_write_bytecode_byte_raw_code(emit, (0x63), scope->raw_code); + emit_write_bytecode_byte(emit, n_closed_over); + } +} + +static void emit_bc_call_function_method_helper(emit_t *emit, mp_int_t stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + if (star_flags) { + emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword - 2); + emit_write_bytecode_byte_uint(emit, bytecode_base + 1, (n_keyword << 8) | n_positional); + } else { + emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword); + emit_write_bytecode_byte_uint(emit, bytecode_base, (n_keyword << 8) | n_positional); + } +} + +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + emit_bc_call_function_method_helper(emit, 0, (0x64), n_positional, n_keyword, star_flags); +} + +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + emit_bc_call_function_method_helper(emit, -1, (0x66), n_positional, n_keyword, star_flags); +} + +void mp_emit_bc_return_value(emit_t *emit) { + emit_bc_pre(emit, -1); + emit->last_emit_was_return_value = +# 931 "user/mpy/py/emitbc.c" 3 4 + 1 +# 931 "user/mpy/py/emitbc.c" + ; + emit_write_bytecode_byte(emit, (0x5b)); +} + +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args) { + +# 936 "user/mpy/py/emitbc.c" 3 + (( +# 936 "user/mpy/py/emitbc.c" + n_args <= 2 +# 936 "user/mpy/py/emitbc.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 936, __func__, +# 936 "user/mpy/py/emitbc.c" + "n_args <= 2" +# 936 "user/mpy/py/emitbc.c" 3 + )) +# 936 "user/mpy/py/emitbc.c" + ; + emit_bc_pre(emit, -n_args); + emit_write_bytecode_byte_byte(emit, (0x5c), n_args); +} + +void mp_emit_bc_yield_value(emit_t *emit) { + emit_bc_pre(emit, 0); + emit->scope->scope_flags |= (0x04); + emit_write_bytecode_byte(emit, (0x5d)); +} + +void mp_emit_bc_yield_from(emit_t *emit) { + emit_bc_pre(emit, -1); + emit->scope->scope_flags |= (0x04); + emit_write_bytecode_byte(emit, (0x5e)); +} + +void mp_emit_bc_start_except_handler(emit_t *emit) { + mp_emit_bc_adjust_stack_size(emit, 4); +} + +void mp_emit_bc_end_except_handler(emit_t *emit) { + mp_emit_bc_adjust_stack_size(emit, -3); +} +# 1054 "user/mpy/py/emitbc.c" +const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops = { + mp_emit_bc_load_fast, + mp_emit_bc_load_deref, + mp_emit_bc_load_name, + mp_emit_bc_load_global, +}; + +const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops = { + mp_emit_bc_store_fast, + mp_emit_bc_store_deref, + mp_emit_bc_store_name, + mp_emit_bc_store_global, +}; + +const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops = { + mp_emit_bc_delete_fast, + mp_emit_bc_delete_deref, + mp_emit_bc_delete_name, + mp_emit_bc_delete_global, +}; +# 1 "user/mpy/py/asmbase.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/asmbase.c" +# 27 "user/mpy/py/asmbase.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/asmbase.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/asmbase.c" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 31 "user/mpy/py/asmbase.c" 2 + +# 1 "user/mpy/py/asmbase.h" 1 +# 35 "user/mpy/py/asmbase.h" +typedef struct _mp_asm_base_t { + int pass; + size_t code_offset; + size_t code_size; + uint8_t *code_base; + + size_t max_num_labels; + size_t *label_offsets; +} mp_asm_base_t; + +void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); +void mp_asm_base_deinit(mp_asm_base_t *as, +# 46 "user/mpy/py/asmbase.h" 3 4 + _Bool +# 46 "user/mpy/py/asmbase.h" + free_code); +void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); +uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); +void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); +void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); +void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); + +static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { + return as->code_offset; +} + +static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { + return as->code_size; +} + +static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { + + + + return as->code_base; + +} +# 33 "user/mpy/py/asmbase.c" 2 +# 1 "user/mpy/py/asmx64.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/asmx64.c" +# 27 "user/mpy/py/asmx64.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/asmx64.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/asmx64.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/asmx64.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/asmx64.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 33 "user/mpy/py/asmx64.c" 2 +# 1 "user/mpy/py/asmx86.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/asmx86.c" +# 27 "user/mpy/py/asmx86.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/asmx86.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/asmx86.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/asmx86.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/asmx86.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 33 "user/mpy/py/asmx86.c" 2 +# 1 "user/mpy/py/asmthumb.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/asmthumb.c" +# 27 "user/mpy/py/asmthumb.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/asmthumb.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/asmthumb.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/asmthumb.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/asmthumb.c" 2 +# 1 "user/mpy/py/emitinlinethumb.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/emitinlinethumb.c" +# 27 "user/mpy/py/emitinlinethumb.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/emitinlinethumb.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/emitinlinethumb.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/emitinlinethumb.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 31 "user/mpy/py/emitinlinethumb.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/emitinlinethumb.c" 2 + +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 31 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 31 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 34 "user/mpy/py/emitinlinethumb.c" 2 +# 1 "user/mpy/py/asmthumb.h" 1 +# 30 "user/mpy/py/asmthumb.h" +# 1 "user/mpy/py/asmbase.h" 1 +# 35 "user/mpy/py/asmbase.h" +typedef struct _mp_asm_base_t { + int pass; + size_t code_offset; + size_t code_size; + uint8_t *code_base; + + size_t max_num_labels; + size_t *label_offsets; +} mp_asm_base_t; + +void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); +void mp_asm_base_deinit(mp_asm_base_t *as, +# 46 "user/mpy/py/asmbase.h" 3 4 + _Bool +# 46 "user/mpy/py/asmbase.h" + free_code); +void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); +uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); +void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); +void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); +void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); + +static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { + return as->code_offset; +} + +static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { + return as->code_size; +} + +static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { + + + + return as->code_base; + +} +# 31 "user/mpy/py/asmthumb.h" 2 +# 65 "user/mpy/py/asmthumb.h" +typedef struct _asm_thumb_t { + mp_asm_base_t base; + uint32_t push_reglist; + uint32_t stack_adjust; +} asm_thumb_t; + +void asm_thumb_end_pass(asm_thumb_t *as); + +void asm_thumb_entry(asm_thumb_t *as, int num_locals); +void asm_thumb_exit(asm_thumb_t *as); +# 93 "user/mpy/py/asmthumb.h" +void asm_thumb_op16(asm_thumb_t *as, uint op); +void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2); + +static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask) + { asm_thumb_op16(as, (0xbf00) | (cc << 4) | mask); } +# 108 "user/mpy/py/asmthumb.h" +static inline void asm_thumb_format_1(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, uint offset) { + +# 109 "user/mpy/py/asmthumb.h" 3 + (( +# 109 "user/mpy/py/asmthumb.h" + rlo_dest < (8) +# 109 "user/mpy/py/asmthumb.h" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 109, __func__, +# 109 "user/mpy/py/asmthumb.h" + "rlo_dest < ASM_THUMB_REG_R8" +# 109 "user/mpy/py/asmthumb.h" 3 + )) +# 109 "user/mpy/py/asmthumb.h" + ; + +# 110 "user/mpy/py/asmthumb.h" 3 + (( +# 110 "user/mpy/py/asmthumb.h" + rlo_src < (8) +# 110 "user/mpy/py/asmthumb.h" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 110, __func__, +# 110 "user/mpy/py/asmthumb.h" + "rlo_src < ASM_THUMB_REG_R8" +# 110 "user/mpy/py/asmthumb.h" 3 + )) +# 110 "user/mpy/py/asmthumb.h" + ; + asm_thumb_op16(as, ((op) | ((offset) << 6) | ((rlo_src) << 3) | (rlo_dest))); +} +# 124 "user/mpy/py/asmthumb.h" +static inline void asm_thumb_format_2(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, int src_b) { + +# 125 "user/mpy/py/asmthumb.h" 3 + (( +# 125 "user/mpy/py/asmthumb.h" + rlo_dest < (8) +# 125 "user/mpy/py/asmthumb.h" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 125, __func__, +# 125 "user/mpy/py/asmthumb.h" + "rlo_dest < ASM_THUMB_REG_R8" +# 125 "user/mpy/py/asmthumb.h" 3 + )) +# 125 "user/mpy/py/asmthumb.h" + ; + +# 126 "user/mpy/py/asmthumb.h" 3 + (( +# 126 "user/mpy/py/asmthumb.h" + rlo_src < (8) +# 126 "user/mpy/py/asmthumb.h" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 126, __func__, +# 126 "user/mpy/py/asmthumb.h" + "rlo_src < ASM_THUMB_REG_R8" +# 126 "user/mpy/py/asmthumb.h" 3 + )) +# 126 "user/mpy/py/asmthumb.h" + ; + asm_thumb_op16(as, ((op) | ((src_b) << 6) | ((rlo_src) << 3) | (rlo_dest))); +} + +static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) + { asm_thumb_format_2(as, (0x1800) | (0x0000), rlo_dest, rlo_src_a, rlo_src_b); } +static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) + { asm_thumb_format_2(as, (0x1800) | (0x0400), rlo_dest, rlo_src_a, i3_src); } +static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) + { asm_thumb_format_2(as, (0x1a00) | (0x0000), rlo_dest, rlo_src_a, rlo_src_b); } +static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) + { asm_thumb_format_2(as, (0x1a00) | (0x0400), rlo_dest, rlo_src_a, i3_src); } +# 149 "user/mpy/py/asmthumb.h" +static inline void asm_thumb_format_3(asm_thumb_t *as, uint op, uint rlo, int i8) { + +# 150 "user/mpy/py/asmthumb.h" 3 + (( +# 150 "user/mpy/py/asmthumb.h" + rlo < (8) +# 150 "user/mpy/py/asmthumb.h" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 150, __func__, +# 150 "user/mpy/py/asmthumb.h" + "rlo < ASM_THUMB_REG_R8" +# 150 "user/mpy/py/asmthumb.h" 3 + )) +# 150 "user/mpy/py/asmthumb.h" + ; + asm_thumb_op16(as, ((op) | ((rlo) << 8) | (i8))); +} + +static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x2000), rlo, i8); } +static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x2800), rlo, i8); } +static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x3000), rlo, i8); } +static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x3800), rlo, i8); } +# 178 "user/mpy/py/asmthumb.h" +void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src); + +static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src) { asm_thumb_format_4(as, (0x4280), rlo_dest, rlo_src); } +# 200 "user/mpy/py/asmthumb.h" +static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_base, uint offset) + { asm_thumb_op16(as, ((op) | (((offset) << 6) & 0x07c0) | ((rlo_base) << 3) | (rlo_dest))); } + +static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint word_offset) + { asm_thumb_format_9_10(as, (0x6000) | (0x0000), rlo_src, rlo_base, word_offset); } +static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, (0x6000) | (0x1000), rlo_src, rlo_base, byte_offset); } +static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, (0x8000), rlo_src, rlo_base, byte_offset); } +static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint word_offset) + { asm_thumb_format_9_10(as, (0x6800) | (0x0000), rlo_dest, rlo_base, word_offset); } +static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, (0x6800) | (0x1000) , rlo_dest, rlo_base, byte_offset); } +static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, (0x8800), rlo_dest, rlo_base, byte_offset); } + + + + + + +void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src); +void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src); + + + +# 225 "user/mpy/py/asmthumb.h" 3 4 +_Bool +# 225 "user/mpy/py/asmthumb.h" + asm_thumb_b_n_label(asm_thumb_t *as, uint label); + +# 226 "user/mpy/py/asmthumb.h" 3 4 +_Bool +# 226 "user/mpy/py/asmthumb.h" + asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, +# 226 "user/mpy/py/asmthumb.h" 3 4 + _Bool +# 226 "user/mpy/py/asmthumb.h" + wide); + +# 227 "user/mpy/py/asmthumb.h" 3 4 +_Bool +# 227 "user/mpy/py/asmthumb.h" + asm_thumb_bl_label(asm_thumb_t *as, uint label); + +void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32_src); +void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32_src); +void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32); +void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num_dest, uint rlo_src); +void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num); +void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num); + +void asm_thumb_b_label(asm_thumb_t *as, uint label); +void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); +void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); +# 35 "user/mpy/py/emitinlinethumb.c" 2 +# 1 "user/mpy/py/asmarm.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/asmarm.c" +# 28 "user/mpy/py/asmarm.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/asmarm.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/asmarm.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/asmarm.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 33 "user/mpy/py/asmarm.c" 2 +# 1 "user/mpy/py/asmxtensa.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/asmxtensa.c" +# 27 "user/mpy/py/asmxtensa.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/asmxtensa.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/asmxtensa.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 31 "user/mpy/py/asmxtensa.c" 2 +# 1 "user/mpy/py/emitinlinextensa.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/emitinlinextensa.c" +# 27 "user/mpy/py/emitinlinextensa.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/emitinlinextensa.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/emitinlinextensa.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/emitinlinextensa.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 31 "user/mpy/py/emitinlinextensa.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/emitinlinextensa.c" 2 + +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 31 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 31 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 34 "user/mpy/py/emitinlinextensa.c" 2 +# 1 "user/mpy/py/asmxtensa.h" 1 +# 29 "user/mpy/py/asmxtensa.h" +# 1 "user/mpy/py/asmbase.h" 1 +# 35 "user/mpy/py/asmbase.h" +typedef struct _mp_asm_base_t { + int pass; + size_t code_offset; + size_t code_size; + uint8_t *code_base; + + size_t max_num_labels; + size_t *label_offsets; +} mp_asm_base_t; + +void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); +void mp_asm_base_deinit(mp_asm_base_t *as, +# 46 "user/mpy/py/asmbase.h" 3 4 + _Bool +# 46 "user/mpy/py/asmbase.h" + free_code); +void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); +uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); +void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); +void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); +void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); + +static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { + return as->code_offset; +} + +static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { + return as->code_size; +} + +static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { + + + + return as->code_base; + +} +# 30 "user/mpy/py/asmxtensa.h" 2 +# 98 "user/mpy/py/asmxtensa.h" +typedef struct _asm_xtensa_t { + mp_asm_base_t base; + uint32_t cur_const; + uint32_t num_const; + uint32_t *const_table; + uint32_t stack_adjust; +} asm_xtensa_t; + +void asm_xtensa_end_pass(asm_xtensa_t *as); + +void asm_xtensa_entry(asm_xtensa_t *as, int num_locals); +void asm_xtensa_exit(asm_xtensa_t *as); + +void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op); +void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op); + + + +static inline void asm_xtensa_op_add(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ((((uint32_t)8) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); +} + +static inline void asm_xtensa_op_addi(asm_xtensa_t *as, uint reg_dest, uint reg_src, int imm8) { + asm_xtensa_op24(as, ((((uint32_t)imm8 & 0xff) << 16) | ((12) << 12) | ((reg_dest) << 8) | ((reg_src) << 4) | (2))); +} + +static inline void asm_xtensa_op_and(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ((((uint32_t)1) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); +} + +static inline void asm_xtensa_op_bcc(asm_xtensa_t *as, uint cond, uint reg_src1, uint reg_src2, int32_t rel8) { + asm_xtensa_op24(as, ((((uint32_t)rel8 & 0xff) << 16) | ((cond) << 12) | ((reg_src1) << 8) | ((reg_src2) << 4) | (7))); +} + +static inline void asm_xtensa_op_bccz(asm_xtensa_t *as, uint cond, uint reg_src, int32_t rel12) { + asm_xtensa_op24(as, (((rel12 & 0xfff) << 12) | ((reg_src) << 8) | ((cond) << 6) | ((1) << 4) | (6))); +} + +static inline void asm_xtensa_op_callx0(asm_xtensa_t *as, uint reg) { + asm_xtensa_op24(as, ((((uint32_t)0) << 20) | (((uint32_t)0) << 16) | ((0) << 12) | ((reg) << 8) | ((3) << 6) | ((0) << 4) | (0))); +} + +static inline void asm_xtensa_op_j(asm_xtensa_t *as, int32_t rel18) { + asm_xtensa_op24(as, (((rel18 & 0x3ffff) << 6) | ((0) << 4) | (6))); +} + +static inline void asm_xtensa_op_jx(asm_xtensa_t *as, uint reg) { + asm_xtensa_op24(as, ((((uint32_t)0) << 20) | (((uint32_t)0) << 16) | ((0) << 12) | ((reg) << 8) | ((2) << 6) | ((2) << 4) | (0))); +} + +static inline void asm_xtensa_op_l8ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint byte_offset) { + asm_xtensa_op24(as, ((((uint32_t)byte_offset & 0xff) << 16) | ((0) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (2))); +} + +static inline void asm_xtensa_op_l16ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint half_word_offset) { + asm_xtensa_op24(as, ((((uint32_t)half_word_offset & 0xff) << 16) | ((1) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (2))); +} + +static inline void asm_xtensa_op_l32i(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { + asm_xtensa_op24(as, ((((uint32_t)word_offset & 0xff) << 16) | ((2) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (2))); +} + +static inline void asm_xtensa_op_l32i_n(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { + asm_xtensa_op16(as, (((word_offset & 0xf) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (8))); +} + +static inline void asm_xtensa_op_l32r(asm_xtensa_t *as, uint reg_dest, uint32_t op_off, uint32_t dest_off) { + asm_xtensa_op24(as, (((((dest_off - ((op_off + 3) & ~3)) >> 2) & 0xffff) << 8) | ((reg_dest) << 4) | (1))); +} + +static inline void asm_xtensa_op_mov_n(asm_xtensa_t *as, uint reg_dest, uint reg_src) { + asm_xtensa_op16(as, (((0) << 12) | ((reg_src) << 8) | ((reg_dest) << 4) | (13))); +} + +static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t imm12) { + asm_xtensa_op24(as, ((((uint32_t)imm12 & 0xff) << 16) | ((10) << 12) | (((imm12 >> 8) & 0xf) << 8) | ((reg_dest) << 4) | (2))); +} + +static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) { + asm_xtensa_op16(as, ((((imm4) & 0xf) << 12) | ((reg_dest) << 8) | ((imm4) & 0x70) | (12))); +} + +static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ((((uint32_t)8) << 20) | (((uint32_t)2) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); +} + +static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ((((uint32_t)2) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); +} + +static inline void asm_xtensa_op_ret_n(asm_xtensa_t *as) { + asm_xtensa_op16(as, (((15) << 12) | ((0) << 8) | ((0) << 4) | (13))); +} + +static inline void asm_xtensa_op_s8i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint byte_offset) { + asm_xtensa_op24(as, ((((uint32_t)byte_offset & 0xff) << 16) | ((4) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (2))); +} + +static inline void asm_xtensa_op_s16i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint half_word_offset) { + asm_xtensa_op24(as, ((((uint32_t)half_word_offset & 0xff) << 16) | ((5) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (2))); +} + +static inline void asm_xtensa_op_s32i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { + asm_xtensa_op24(as, ((((uint32_t)word_offset & 0xff) << 16) | ((6) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (2))); +} + +static inline void asm_xtensa_op_s32i_n(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { + asm_xtensa_op16(as, (((word_offset & 0xf) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (9))); +} + +static inline void asm_xtensa_op_sll(asm_xtensa_t *as, uint reg_dest, uint reg_src) { + asm_xtensa_op24(as, ((((uint32_t)10) << 20) | (((uint32_t)1) << 16) | ((reg_dest) << 12) | ((reg_src) << 8) | ((0) << 4) | (0))); +} + +static inline void asm_xtensa_op_sra(asm_xtensa_t *as, uint reg_dest, uint reg_src) { + asm_xtensa_op24(as, ((((uint32_t)11) << 20) | (((uint32_t)1) << 16) | ((reg_dest) << 12) | ((0) << 8) | ((reg_src) << 4) | (0))); +} + +static inline void asm_xtensa_op_ssl(asm_xtensa_t *as, uint reg_src) { + asm_xtensa_op24(as, ((((uint32_t)4) << 20) | (((uint32_t)0) << 16) | ((1) << 12) | ((reg_src) << 8) | ((0) << 4) | (0))); +} + +static inline void asm_xtensa_op_ssr(asm_xtensa_t *as, uint reg_src) { + asm_xtensa_op24(as, ((((uint32_t)4) << 20) | (((uint32_t)0) << 16) | ((0) << 12) | ((reg_src) << 8) | ((0) << 4) | (0))); +} + +static inline void asm_xtensa_op_sub(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ((((uint32_t)12) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); +} + +static inline void asm_xtensa_op_xor(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ((((uint32_t)3) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); +} + + +void asm_xtensa_j_label(asm_xtensa_t *as, uint label); +void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label); +void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label); +void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2); +void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32); +void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src); +void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num); +void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num); +# 35 "user/mpy/py/emitinlinextensa.c" 2 +# 1 "user/mpy/py/formatfloat.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/formatfloat.c" +# 27 "user/mpy/py/formatfloat.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/formatfloat.c" 2 +# 1 "user/mpy/py/parsenumbase.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/parsenumbase.c" +# 27 "user/mpy/py/parsenumbase.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/parsenumbase.c" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 29 "user/mpy/py/parsenumbase.c" 2 +# 1 "user/mpy/py/parsenumbase.h" 1 +# 31 "user/mpy/py/parsenumbase.h" +size_t mp_parse_num_base(const char *str, size_t len, int *base); +# 30 "user/mpy/py/parsenumbase.c" 2 + + + +size_t mp_parse_num_base(const char *str, size_t len, int *base) { + const byte *p = (const byte*)str; + if (len <= 1) { + goto no_prefix; + } + unichar c = *(p++); + if ((*base == 0 || *base == 16) && c == '0') { + c = *(p++); + if ((c | 32) == 'x') { + *base = 16; + } else if (*base == 0 && (c | 32) == 'o') { + *base = 8; + } else if (*base == 0 && (c | 32) == 'b') { + *base = 2; + } else { + if (*base == 0) { + *base = 10; + } + p -= 2; + } + } else if (*base == 8 && c == '0') { + c = *(p++); + if ((c | 32) != 'o') { + p -= 2; + } + } else if (*base == 2 && c == '0') { + c = *(p++); + if ((c | 32) != 'b') { + p -= 2; + } + } else { + p--; + no_prefix: + if (*base == 0) { + *base = 10; + } + } + return p - (const byte*)str; +} +# 1 "user/mpy/py/parsenum.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/parsenum.c" +# 27 "user/mpy/py/parsenum.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 28 "user/mpy/py/parsenum.c" 2 +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 29 "user/mpy/py/parsenum.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 35 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/parsenum.c" 2 +# 1 "user/mpy/py/parsenumbase.h" 1 +# 31 "user/mpy/py/parsenumbase.h" +size_t mp_parse_num_base(const char *str, size_t len, int *base); +# 32 "user/mpy/py/parsenum.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 33 "user/mpy/py/parsenum.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 34 "user/mpy/py/parsenum.c" 2 + + + + + +static __attribute__((noreturn)) void raise_exc(mp_obj_t exc, mp_lexer_t *lex) { + + + if (lex != +# 42 "user/mpy/py/parsenum.c" 3 4 + ((void *)0) +# 42 "user/mpy/py/parsenum.c" + ) { + ((mp_obj_base_t*)((void*)exc))->type = &mp_type_SyntaxError; + mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); + } + nlr_jump(((void*)exc)); +} + +mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, mp_lexer_t *lex) { + const byte *restrict str = (const byte *)str_; + const byte *restrict top = str + len; + +# 52 "user/mpy/py/parsenum.c" 3 4 + _Bool +# 52 "user/mpy/py/parsenum.c" + neg = +# 52 "user/mpy/py/parsenum.c" 3 4 + 0 +# 52 "user/mpy/py/parsenum.c" + ; + mp_obj_t ret_val; + + + if ((base != 0 && base < 2) || base > 36) { + + mp_raise_ValueError("int() arg 2 must be >= 2 and <= 36"); + } + + + for (; str < top && unichar_isspace(*str); str++) { + } + + + if (str < top) { + if (*str == '+') { + str++; + } else if (*str == '-') { + str++; + neg = +# 71 "user/mpy/py/parsenum.c" 3 4 + 1 +# 71 "user/mpy/py/parsenum.c" + ; + } + } + + + str += mp_parse_num_base((const char*)str, top - str, &base); + + + mp_int_t int_val = 0; + const byte *restrict str_val_start = str; + for (; str < top; str++) { + + mp_uint_t dig = *str; + if ('0' <= dig && dig <= '9') { + dig -= '0'; + } else { + dig |= 0x20; + if ('a' <= dig && dig <= 'z') { + dig -= 'a' - 10; + } else { + + break; + } + } + if (dig >= (mp_uint_t)base) { + break; + } + + + if (mp_small_int_mul_overflow(int_val, base)) { + goto overflow; + } + int_val = int_val * base + dig; + if (!((((int_val) ^ ((int_val) << 1)) & (((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) == 0)) { + goto overflow; + } + } + + + if (neg) { + int_val = -int_val; + } + + + ret_val = ((mp_obj_t)((((mp_uint_t)(int_val)) << 1) | 1)); + +have_ret_val: + + if (str == str_val_start) { + goto value_error; + } + + + for (; str < top && unichar_isspace(*str); str++) { + } + + + if (str != top) { + goto value_error; + } + + + return ret_val; + +overflow: + + { + const char *s2 = (const char*)str_val_start; + ret_val = mp_obj_new_int_from_str_len(&s2, top - str_val_start, neg, base); + str = (const byte*)s2; + goto have_ret_val; + } + +value_error: + if (((1)) == (1)) { + mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_ValueError, + "invalid syntax for integer"); + raise_exc(exc, lex); + } else if (((1)) == (2)) { + mp_obj_t exc = mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "invalid syntax for integer with base %d", base); + raise_exc(exc, lex); + } else { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 50, &print); + mp_printf(&print, "invalid syntax for integer with base %d: ", base); + mp_str_print_quoted(&print, str_val_start, top - str_val_start, +# 158 "user/mpy/py/parsenum.c" 3 4 + 1 +# 158 "user/mpy/py/parsenum.c" + ); + mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_ValueError, + mp_obj_new_str_from_vstr(&mp_type_str, &vstr)); + raise_exc(exc, lex); + } +} + +typedef enum { + PARSE_DEC_IN_INTG, + PARSE_DEC_IN_FRAC, + PARSE_DEC_IN_EXP, +} parse_dec_in_t; + +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 171 "user/mpy/py/parsenum.c" 3 4 + _Bool +# 171 "user/mpy/py/parsenum.c" + allow_imag, +# 171 "user/mpy/py/parsenum.c" 3 4 + _Bool +# 171 "user/mpy/py/parsenum.c" + force_complex, mp_lexer_t *lex) { +# 304 "user/mpy/py/parsenum.c" + raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "decimal numbers not supported"), lex); + +} +# 1 "user/mpy/py/emitglue.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/emitglue.c" +# 29 "user/mpy/py/emitglue.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/emitglue.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 31 "user/mpy/py/emitglue.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 32 "user/mpy/py/emitglue.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 33 "user/mpy/py/emitglue.c" 2 + +# 1 "user/mpy/py/emitglue.h" 1 +# 29 "user/mpy/py/emitglue.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/emitglue.h" 2 + + + +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 35 "user/mpy/py/emitglue.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 36 "user/mpy/py/emitglue.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 29 "user/mpy/py/bc.h" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/bc.h" 2 + +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 37 "user/mpy/py/emitglue.c" 2 +# 52 "user/mpy/py/emitglue.c" +mp_raw_code_t *mp_emit_glue_new_raw_code(void) { + mp_raw_code_t *rc = ((mp_raw_code_t*)(m_malloc0(sizeof(mp_raw_code_t) * (1)))); + rc->kind = MP_CODE_RESERVED; + return rc; +} + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags) { + + rc->kind = MP_CODE_BYTECODE; + rc->scope_flags = scope_flags; + rc->data.u_byte.bytecode = code; + rc->data.u_byte.const_table = const_table; +# 83 "user/mpy/py/emitglue.c" +} +# 116 "user/mpy/py/emitglue.c" +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args) { + (void)0; + +# 118 "user/mpy/py/emitglue.c" 3 + (( +# 118 "user/mpy/py/emitglue.c" + rc != +# 118 "user/mpy/py/emitglue.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 118, __func__, +# 118 "user/mpy/py/emitglue.c" + "rc != NULL" +# 118 "user/mpy/py/emitglue.c" 3 + )) +# 118 "user/mpy/py/emitglue.c" + ; + + + +# 121 "user/mpy/py/emitglue.c" 3 + (( +# 121 "user/mpy/py/emitglue.c" + def_args == (((mp_obj_t)(void*)0)) || (MP_OBJ_IS_OBJ(def_args) && (((mp_obj_base_t*)((void*)def_args))->type == (&mp_type_tuple))) +# 121 "user/mpy/py/emitglue.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 121, __func__, +# 121 "user/mpy/py/emitglue.c" + "def_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_args, &mp_type_tuple)" +# 121 "user/mpy/py/emitglue.c" 3 + )) +# 121 "user/mpy/py/emitglue.c" + ; + + + +# 124 "user/mpy/py/emitglue.c" 3 + (( +# 124 "user/mpy/py/emitglue.c" + def_kw_args == (((mp_obj_t)(void*)0)) || (MP_OBJ_IS_OBJ(def_kw_args) && (((mp_obj_base_t*)((void*)def_kw_args))->type == (&mp_type_dict))) +# 124 "user/mpy/py/emitglue.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 124, __func__, +# 124 "user/mpy/py/emitglue.c" + "def_kw_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_kw_args, &mp_type_dict)" +# 124 "user/mpy/py/emitglue.c" 3 + )) +# 124 "user/mpy/py/emitglue.c" + ; + + + mp_obj_t fun; + switch (rc->kind) { +# 142 "user/mpy/py/emitglue.c" + default: + + +# 144 "user/mpy/py/emitglue.c" 3 + (( +# 144 "user/mpy/py/emitglue.c" + rc->kind == MP_CODE_BYTECODE +# 144 "user/mpy/py/emitglue.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 144, __func__, +# 144 "user/mpy/py/emitglue.c" + "rc->kind == MP_CODE_BYTECODE" +# 144 "user/mpy/py/emitglue.c" 3 + )) +# 144 "user/mpy/py/emitglue.c" + ; + fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table); + break; + } + + + if ((rc->scope_flags & (0x04)) != 0) { + fun = mp_obj_new_gen_wrap(fun); + } + + return fun; +} + +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args) { + (void)0; + + mp_obj_t ffun; + if (n_closed_over & 0x100) { + + ffun = mp_make_function_from_raw_code(rc, args[0], args[1]); + } else { + + ffun = mp_make_function_from_raw_code(rc, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))); + } + + return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2)); +} +# 1 "user/mpy/py/persistentcode.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/persistentcode.c" +# 27 "user/mpy/py/persistentcode.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/persistentcode.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/persistentcode.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/persistentcode.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/persistentcode.c" 2 + +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 33 "user/mpy/py/persistentcode.c" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 34 "user/mpy/py/persistentcode.c" 2 +# 1 "user/mpy/py/persistentcode.h" 1 +# 33 "user/mpy/py/persistentcode.h" +mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader); +mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len); +mp_raw_code_t *mp_raw_code_load_file(const char *filename); + +void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print); +void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename); +# 35 "user/mpy/py/persistentcode.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 29 "user/mpy/py/bc.h" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/bc.h" 2 + +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 36 "user/mpy/py/persistentcode.c" 2 +# 1 "user/mpy/py/runtime.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/runtime.c" +# 27 "user/mpy/py/runtime.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/runtime.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/runtime.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/runtime.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 32 "user/mpy/py/runtime.c" 2 + +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 34 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/compile.h" 1 +# 30 "user/mpy/py/compile.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 31 "user/mpy/py/compile.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 32 "user/mpy/py/compile.h" 2 + + +enum { + MP_EMIT_OPT_NONE, + MP_EMIT_OPT_BYTECODE, + MP_EMIT_OPT_NATIVE_PYTHON, + MP_EMIT_OPT_VIPER, + MP_EMIT_OPT_ASM, +}; + + + +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, +# 44 "user/mpy/py/compile.h" 3 4 + _Bool +# 44 "user/mpy/py/compile.h" + is_repl); + + + + + + + +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); +# 35 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 36 "user/mpy/py/runtime.c" 2 + + +# 1 "user/mpy/py/objmodule.h" 1 +# 31 "user/mpy/py/objmodule.h" +extern const mp_map_t mp_builtin_module_map; +extern const mp_map_t mp_builtin_module_weak_links_map; + +mp_obj_t mp_module_get(qstr module_name); +void mp_module_register(qstr qstr, mp_obj_t module); +# 39 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/objgenerator.h" 1 +# 30 "user/mpy/py/objgenerator.h" +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objgenerator.h" 2 + +mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); +# 40 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 41 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 42 "user/mpy/py/runtime.c" 2 + +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 44 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 45 "user/mpy/py/runtime.c" 2 +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 46 "user/mpy/py/runtime.c" 2 +# 56 "user/mpy/py/runtime.c" +const mp_obj_module_t mp_module___main__ = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&(mp_state_ctx.vm.dict_main), +}; + +void mp_init(void) { + qstr_init(); + + + (mp_state_ctx.vm.mp_pending_exception) = (((mp_obj_t)(void*)0)); +# 90 "user/mpy/py/runtime.c" + (mp_state_ctx.vm.mp_optimise_value) = 0; + + + mp_obj_dict_init(&(mp_state_ctx.vm.mp_loaded_modules_dict), 3); + + + mp_obj_dict_init(&(mp_state_ctx.vm.dict_main), 1); + mp_obj_dict_store(((mp_obj_t)&(mp_state_ctx.vm.dict_main)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___main__)) << 2) | 2))); + + + mp_locals_set(&(mp_state_ctx.vm.dict_main)); + mp_globals_set(&(mp_state_ctx.vm.dict_main)); +# 123 "user/mpy/py/runtime.c" + ; +} + +void mp_deinit(void) { + + + + + + + +} + +mp_obj_t mp_load_name(qstr qst) { + + (void)0; + + if (mp_locals_get() != mp_globals_get()) { + mp_map_elem_t *elem = mp_map_lookup(&mp_locals_get()->map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 142 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 142 "user/mpy/py/runtime.c" + ) { + return elem->value; + } + } + return mp_load_global(qst); +} + +mp_obj_t mp_load_global(qstr qst) { + + (void)0; + mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem == +# 153 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 153 "user/mpy/py/runtime.c" + ) { +# 163 "user/mpy/py/runtime.c" + elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem == +# 164 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 164 "user/mpy/py/runtime.c" + ) { + if (((1)) == (1)) { + mp_raise_msg(&mp_type_NameError, "name not defined"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_NameError, "name '%q' is not defined", qst))) + ; + } + } + } + return elem->value; +} + +mp_obj_t mp_load_build_class(void) { + (void)0; +# 187 "user/mpy/py/runtime.c" + return ((mp_obj_t)&mp_builtin___build_class___obj); +} + +void mp_store_name(qstr qst, mp_obj_t obj) { + (void)0; + mp_obj_dict_store(((mp_obj_t)mp_locals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), obj); +} + +void mp_delete_name(qstr qst) { + (void)0; + + mp_obj_dict_delete(((mp_obj_t)mp_locals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))); +} + +void mp_store_global(qstr qst, mp_obj_t obj) { + (void)0; + mp_obj_dict_store(((mp_obj_t)mp_globals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), obj); +} + +void mp_delete_global(qstr qst) { + (void)0; + + mp_obj_dict_delete(((mp_obj_t)mp_globals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))); +} + +mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) { + (void)0; + + if (op == MP_UNARY_OP_NOT) { + + return mp_obj_new_bool(mp_obj_is_true(arg) == 0); + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + mp_int_t val = (((mp_int_t)(arg)) >> 1); + switch (op) { + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(val != 0); + case MP_UNARY_OP_HASH: + return arg; + case MP_UNARY_OP_POSITIVE: + return arg; + case MP_UNARY_OP_NEGATIVE: + + if (val == ((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))) { + return mp_obj_new_int(-val); + } else { + return ((mp_obj_t)((((mp_uint_t)(-val)) << 1) | 1)); + } + default: + +# 235 "user/mpy/py/runtime.c" 3 + (( +# 235 "user/mpy/py/runtime.c" + op == MP_UNARY_OP_INVERT +# 235 "user/mpy/py/runtime.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 235, __func__, +# 235 "user/mpy/py/runtime.c" + "op == MP_UNARY_OP_INVERT" +# 235 "user/mpy/py/runtime.c" 3 + )) +# 235 "user/mpy/py/runtime.c" + ; + return ((mp_obj_t)((((mp_uint_t)(~val)) << 1) | 1)); + } + } else if (op == MP_UNARY_OP_HASH && (MP_OBJ_IS_QSTR(arg) || (MP_OBJ_IS_OBJ(arg) && ((mp_obj_base_t*)((void*)arg))->type->binary_op == mp_obj_str_binary_op))) { + + mp_uint_t h; if (MP_OBJ_IS_QSTR(arg)) { h = qstr_hash((((mp_uint_t)(arg)) >> 2)); } else { h = ((mp_obj_str_t*)((void*)arg))->hash; }; + if (h == 0) { + const byte *data; size_t len; if (MP_OBJ_IS_QSTR(arg)) { data = qstr_data((((mp_uint_t)(arg)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)arg))->len; data = ((mp_obj_str_t*)((void*)arg))->data; }; + h = qstr_compute_hash(data, len); + } + return ((mp_obj_t)((((mp_uint_t)(h)) << 1) | 1)); + } else { + mp_obj_type_t *type = mp_obj_get_type(arg); + if (type->unary_op != +# 248 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 248 "user/mpy/py/runtime.c" + ) { + mp_obj_t result = type->unary_op(op, arg); + if (result != (((mp_obj_t)(void*)0))) { + return result; + } + } + if (((1)) == (1)) { + mp_raise_TypeError("unsupported type for operator"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported type for %q: '%s'", mp_unary_op_method_name[op], mp_obj_get_type_str(arg)))) + + ; + } + } +} + +mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + (void)0; +# 277 "user/mpy/py/runtime.c" + if (op == MP_BINARY_OP_IS) { + return mp_obj_new_bool(lhs == rhs); + } + + + if (op == MP_BINARY_OP_EQUAL || op == MP_BINARY_OP_NOT_EQUAL) { + if (mp_obj_equal(lhs, rhs)) { + if (op == MP_BINARY_OP_EQUAL) { + return (((mp_obj_t)&mp_const_true_obj)); + } else { + return (((mp_obj_t)&mp_const_false_obj)); + } + } else { + if (op == MP_BINARY_OP_EQUAL) { + return (((mp_obj_t)&mp_const_false_obj)); + } else { + return (((mp_obj_t)&mp_const_true_obj)); + } + } + } + + + if (op == MP_BINARY_OP_EXCEPTION_MATCH) { + + if (mp_obj_is_exception_type(rhs)) { + if (mp_obj_exception_match(lhs, rhs)) { + return (((mp_obj_t)&mp_const_true_obj)); + } else { + return (((mp_obj_t)&mp_const_false_obj)); + } + } else if ((MP_OBJ_IS_OBJ(rhs) && (((mp_obj_base_t*)((void*)rhs))->type == (&mp_type_tuple)))) { + mp_obj_tuple_t *tuple = ((void*)rhs); + for (size_t i = 0; i < tuple->len; i++) { + rhs = tuple->items[i]; + if (!mp_obj_is_exception_type(rhs)) { + goto unsupported_op; + } + if (mp_obj_exception_match(lhs, rhs)) { + return (((mp_obj_t)&mp_const_true_obj)); + } + } + return (((mp_obj_t)&mp_const_false_obj)); + } + goto unsupported_op; + } + + if (MP_OBJ_IS_SMALL_INT(lhs)) { + mp_int_t lhs_val = (((mp_int_t)(lhs)) >> 1); + if (MP_OBJ_IS_SMALL_INT(rhs)) { + mp_int_t rhs_val = (((mp_int_t)(rhs)) >> 1); +# 336 "user/mpy/py/runtime.c" + switch (op) { + case MP_BINARY_OP_OR: + case MP_BINARY_OP_INPLACE_OR: lhs_val |= rhs_val; break; + case MP_BINARY_OP_XOR: + case MP_BINARY_OP_INPLACE_XOR: lhs_val ^= rhs_val; break; + case MP_BINARY_OP_AND: + case MP_BINARY_OP_INPLACE_AND: lhs_val &= rhs_val; break; + case MP_BINARY_OP_LSHIFT: + case MP_BINARY_OP_INPLACE_LSHIFT: { + if (rhs_val < 0) { + + mp_raise_ValueError("negative shift count"); + } else if (rhs_val >= (mp_int_t)((8) * (sizeof(mp_uint_t))) || lhs_val > (((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))))) >> rhs_val) || lhs_val < (((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) >> rhs_val)) { + + lhs = mp_obj_new_int_from_ll(lhs_val); + goto generic_binary_op; + } else { + + lhs_val <<= rhs_val; + } + break; + } + case MP_BINARY_OP_RSHIFT: + case MP_BINARY_OP_INPLACE_RSHIFT: + if (rhs_val < 0) { + + mp_raise_ValueError("negative shift count"); + } else { + + if (rhs_val >= (mp_int_t)((8) * (sizeof(mp_uint_t)))) { + + + rhs_val = ((8) * (sizeof(mp_uint_t))) - 1; + } + lhs_val >>= rhs_val; + } + break; + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break; + case MP_BINARY_OP_SUBTRACT: + case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break; + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: { +# 395 "user/mpy/py/runtime.c" + if (mp_small_int_mul_overflow(lhs_val, rhs_val)) { + + lhs = mp_obj_new_int_from_ll(lhs_val); + goto generic_binary_op; + } else { + + return ((mp_obj_t)((((mp_uint_t)(lhs_val * rhs_val)) << 1) | 1)); + } + break; + } + case MP_BINARY_OP_FLOOR_DIVIDE: + case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: + if (rhs_val == 0) { + goto zero_division; + } + lhs_val = mp_small_int_floor_divide(lhs_val, rhs_val); + break; +# 422 "user/mpy/py/runtime.c" + case MP_BINARY_OP_MODULO: + case MP_BINARY_OP_INPLACE_MODULO: { + if (rhs_val == 0) { + goto zero_division; + } + lhs_val = mp_small_int_modulo(lhs_val, rhs_val); + break; + } + + case MP_BINARY_OP_POWER: + case MP_BINARY_OP_INPLACE_POWER: + if (rhs_val < 0) { + + + + + mp_raise_ValueError("negative power with no float support"); + + } else { + mp_int_t ans = 1; + while (rhs_val > 0) { + if (rhs_val & 1) { + if (mp_small_int_mul_overflow(ans, lhs_val)) { + goto power_overflow; + } + ans *= lhs_val; + } + if (rhs_val == 1) { + break; + } + rhs_val /= 2; + if (mp_small_int_mul_overflow(lhs_val, lhs_val)) { + goto power_overflow; + } + lhs_val *= lhs_val; + } + lhs_val = ans; + } + break; + + power_overflow: + + lhs = mp_obj_new_int_from_ll((((mp_int_t)(lhs)) >> 1)); + goto generic_binary_op; + + case MP_BINARY_OP_DIVMOD: { + if (rhs_val == 0) { + goto zero_division; + } + + mp_obj_tuple_t *tuple = ((void*)mp_obj_new_tuple(2, +# 472 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 472 "user/mpy/py/runtime.c" + )); + tuple->items[0] = ((mp_obj_t)((((mp_uint_t)(mp_small_int_floor_divide(lhs_val, rhs_val))) << 1) | 1)); + tuple->items[1] = ((mp_obj_t)((((mp_uint_t)(mp_small_int_modulo(lhs_val, rhs_val))) << 1) | 1)); + return ((mp_obj_t)tuple); + } + + case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val); break; + case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val); break; + case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val); break; + case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val); break; + + default: + goto unsupported_op; + } + + if (((((lhs_val) ^ ((lhs_val) << 1)) & (((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) == 0)) { + return ((mp_obj_t)((((mp_uint_t)(lhs_val)) << 1) | 1)); + } else { + return mp_obj_new_int(lhs_val); + } +# 510 "user/mpy/py/runtime.c" + } + } + + + + + + + if (op == MP_BINARY_OP_IN) { + mp_obj_type_t *type = mp_obj_get_type(rhs); + if (type->binary_op != +# 520 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 520 "user/mpy/py/runtime.c" + ) { + mp_obj_t res = type->binary_op(op, rhs, lhs); + if (res != (((mp_obj_t)(void*)0))) { + return res; + } + } + if (type->getiter != +# 526 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 526 "user/mpy/py/runtime.c" + ) { + + mp_obj_iter_buf_t iter_buf; + mp_obj_t iter = mp_getiter(rhs, &iter_buf); + mp_obj_t next; + while ((next = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { + if (mp_obj_equal(next, lhs)) { + return (((mp_obj_t)&mp_const_true_obj)); + } + } + return (((mp_obj_t)&mp_const_false_obj)); + } + + if (((1)) == (1)) { + mp_raise_TypeError("object not iterable"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not iterable", mp_obj_get_type_str(rhs)))) + ; + } + } + + + mp_obj_type_t *type; +generic_binary_op: + type = mp_obj_get_type(lhs); + if (type->binary_op != +# 551 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 551 "user/mpy/py/runtime.c" + ) { + mp_obj_t result = type->binary_op(op, lhs, rhs); + if (result != (((mp_obj_t)(void*)0))) { + return result; + } + } + + + +unsupported_op: + if (((1)) == (1)) { + mp_raise_TypeError("unsupported type for operator"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported types for %q: '%s', '%s'", mp_binary_op_method_name[op], mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs)))) + + ; + } + +zero_division: + mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); +} + +mp_obj_t mp_call_function_0(mp_obj_t fun) { + return mp_call_function_n_kw(fun, 0, 0, +# 574 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 574 "user/mpy/py/runtime.c" + ); +} + +mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg) { + return mp_call_function_n_kw(fun, 1, 0, &arg); +} + +mp_obj_t mp_call_function_2(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { + mp_obj_t args[2]; + args[0] = arg1; + args[1] = arg2; + return mp_call_function_n_kw(fun, 2, 0, args); +} + + +mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + + + + (void)0; + + + mp_obj_type_t *type = mp_obj_get_type(fun_in); + + + if (type->call != +# 599 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 599 "user/mpy/py/runtime.c" + ) { + return type->call(fun_in, n_args, n_kw, args); + } + + if (((1)) == (1)) { + mp_raise_TypeError("object not callable"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not callable", mp_obj_get_type_str(fun_in)))) + ; + } +} + + + +mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)0; + int adjust = (args[1] == (((mp_obj_t)(void*)0))) ? 0 : 1; + return mp_call_function_n_kw(args[0], n_args + adjust, n_kw, args + 2 - adjust); +} + + + +static + +void mp_call_prepare_args_n_kw_var( +# 623 "user/mpy/py/runtime.c" 3 4 + _Bool +# 623 "user/mpy/py/runtime.c" + have_self, size_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args) { + mp_obj_t fun = *args++; + mp_obj_t self = (((mp_obj_t)(void*)0)); + if (have_self) { + self = *args++; + } + uint n_args = n_args_n_kw & 0xff; + uint n_kw = (n_args_n_kw >> 8) & 0xff; + mp_obj_t pos_seq = args[n_args + 2 * n_kw]; + mp_obj_t kw_dict = args[n_args + 2 * n_kw + 1]; + + (void)0; + + + + + + + mp_obj_t *args2; + uint args2_alloc; + uint args2_len = 0; + + + uint kw_dict_len = 0; + if (kw_dict != (((mp_obj_t)(void*)0)) && (MP_OBJ_IS_OBJ(kw_dict) && (((mp_obj_base_t*)((void*)kw_dict))->type == (&mp_type_dict)))) { + kw_dict_len = mp_obj_dict_len(kw_dict); + } + + + + if (pos_seq == (((mp_obj_t)(void*)0))) { + + + + args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len); + args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (args2_alloc)))); + + + if (self != (((mp_obj_t)(void*)0))) { + args2[args2_len++] = self; + } + + + memcpy(args2 + args2_len, args, n_args * sizeof(mp_obj_t)); + args2_len += n_args; + + } else if ((MP_OBJ_IS_OBJ(pos_seq) && (((mp_obj_base_t*)((void*)pos_seq))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(pos_seq) && (((mp_obj_base_t*)((void*)pos_seq))->type == (&mp_type_list)))) { + + + + size_t len; + mp_obj_t *items; + mp_obj_get_array(pos_seq, &len, &items); + + + args2_alloc = 1 + n_args + len + 2 * (n_kw + kw_dict_len); + args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (args2_alloc)))); + + + if (self != (((mp_obj_t)(void*)0))) { + args2[args2_len++] = self; + } + + + { memcpy(args2 + args2_len, args, (n_args) * sizeof(mp_obj_t)); memcpy(args2 + args2_len + (n_args), items, (len) * sizeof(mp_obj_t)); }; + args2_len += n_args + len; + + } else { + + + + args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len) + 3; + args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (args2_alloc)))); + + + if (self != (((mp_obj_t)(void*)0))) { + args2[args2_len++] = self; + } + + + memcpy(args2 + args2_len, args, n_args * sizeof(mp_obj_t)); + args2_len += n_args; + + + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(pos_seq, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + if (args2_len >= args2_alloc) { + args2 = ((mp_obj_t*)(m_realloc((args2), sizeof(mp_obj_t) * (args2_alloc * 2)))); + args2_alloc *= 2; + } + args2[args2_len++] = item; + } + } + + + uint pos_args_len = args2_len; + + + memcpy(args2 + args2_len, args + n_args, 2 * n_kw * sizeof(mp_obj_t)); + args2_len += 2 * n_kw; + + + + if (kw_dict == (((mp_obj_t)(void*)0))) { + + } else if ((MP_OBJ_IS_OBJ(kw_dict) && (((mp_obj_base_t*)((void*)kw_dict))->type == (&mp_type_dict)))) { + + mp_map_t *map = mp_obj_dict_get_map(kw_dict); + +# 733 "user/mpy/py/runtime.c" 3 + (( +# 733 "user/mpy/py/runtime.c" + args2_len + 2 * map->used <= args2_alloc +# 733 "user/mpy/py/runtime.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 733, __func__, +# 733 "user/mpy/py/runtime.c" + "args2_len + 2 * map->used <= args2_alloc" +# 733 "user/mpy/py/runtime.c" 3 + )) +# 733 "user/mpy/py/runtime.c" + ; + for (size_t i = 0; i < map->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + + mp_obj_t key = map->table[i].key; + if ((MP_OBJ_IS_OBJ(key) && (((mp_obj_base_t*)((void*)key))->type == (&mp_type_str)))) { + key = mp_obj_str_intern(key); + } + args2[args2_len++] = key; + args2[args2_len++] = map->table[i].value; + } + } + } else { + + + + + + mp_obj_t dest[3]; + mp_load_method(kw_dict, MP_QSTR_keys, dest); + mp_obj_t iterable = mp_getiter(mp_call_method_n_kw(0, 0, dest), +# 753 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 753 "user/mpy/py/runtime.c" + ); + + mp_obj_t key; + while ((key = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + + if (args2_len + 1 >= args2_alloc) { + uint new_alloc = args2_alloc * 2; + if (new_alloc < 4) { + new_alloc = 4; + } + args2 = ((mp_obj_t*)(m_realloc((args2), sizeof(mp_obj_t) * (new_alloc)))); + args2_alloc = new_alloc; + } + + + if ((MP_OBJ_IS_OBJ(key) && (((mp_obj_base_t*)((void*)key))->type == (&mp_type_str)))) { + key = mp_obj_str_intern(key); + } + + + mp_load_method(kw_dict, MP_QSTR___getitem__, dest); + dest[2] = key; + mp_obj_t value = mp_call_method_n_kw(1, 0, dest); + + + args2[args2_len++] = key; + args2[args2_len++] = value; + } + } + + out_args->fun = fun; + out_args->args = args2; + out_args->n_args = pos_args_len; + out_args->n_kw = (args2_len - pos_args_len) / 2; + out_args->n_alloc = args2_alloc; +} + +mp_obj_t mp_call_method_n_kw_var( +# 790 "user/mpy/py/runtime.c" 3 4 + _Bool +# 790 "user/mpy/py/runtime.c" + have_self, size_t n_args_n_kw, const mp_obj_t *args) { + mp_call_args_t out_args; + mp_call_prepare_args_n_kw_var(have_self, n_args_n_kw, args, &out_args); + + mp_obj_t res = mp_call_function_n_kw(out_args.fun, out_args.n_args, out_args.n_kw, out_args.args); + ((void)(out_args.n_alloc), m_free(out_args.args)); + + return res; +} + + +void mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) { + size_t seq_len; + if ((MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_list)))) { + mp_obj_t *seq_items; + mp_obj_get_array(seq_in, &seq_len, &seq_items); + if (seq_len < num) { + goto too_short; + } else if (seq_len > num) { + goto too_long; + } + for (size_t i = 0; i < num; i++) { + items[i] = seq_items[num - 1 - i]; + } + } else { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(seq_in, &iter_buf); + + for (seq_len = 0; seq_len < num; seq_len++) { + mp_obj_t el = mp_iternext(iterable); + if (el == (((mp_obj_t)(void*)4))) { + goto too_short; + } + items[num - 1 - seq_len] = el; + } + if (mp_iternext(iterable) != (((mp_obj_t)(void*)4))) { + goto too_long; + } + } + return; + +too_short: + if (((1)) == (1)) { + mp_raise_ValueError("wrong number of values to unpack"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "need more than %d values to unpack", (int)seq_len))) + ; + } +too_long: + if (((1)) == (1)) { + mp_raise_ValueError("wrong number of values to unpack"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "too many values to unpack (expected %d)", (int)num))) + ; + } +} + + +void mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) { + size_t num_left = num_in & 0xff; + size_t num_right = (num_in >> 8) & 0xff; + (void)0; + size_t seq_len; + if ((MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_list)))) { + mp_obj_t *seq_items; + mp_obj_get_array(seq_in, &seq_len, &seq_items); + if (seq_len < num_left + num_right) { + goto too_short; + } + for (size_t i = 0; i < num_right; i++) { + items[i] = seq_items[seq_len - 1 - i]; + } + items[num_right] = mp_obj_new_list(seq_len - num_left - num_right, seq_items + num_left); + for (size_t i = 0; i < num_left; i++) { + items[num_right + 1 + i] = seq_items[num_left - 1 - i]; + } + } else { + + + + + mp_obj_t iterable = mp_getiter(seq_in, +# 871 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 871 "user/mpy/py/runtime.c" + ); + mp_obj_t item; + for (seq_len = 0; seq_len < num_left; seq_len++) { + item = mp_iternext(iterable); + if (item == (((mp_obj_t)(void*)4))) { + goto too_short; + } + items[num_left + num_right + 1 - 1 - seq_len] = item; + } + mp_obj_list_t *rest = ((void*)mp_obj_new_list(0, +# 880 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 880 "user/mpy/py/runtime.c" + )); + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + mp_obj_list_append(((mp_obj_t)rest), item); + } + if (rest->len < num_right) { + goto too_short; + } + items[num_right] = ((mp_obj_t)rest); + for (size_t i = 0; i < num_right; i++) { + items[num_right - 1 - i] = rest->items[rest->len - num_right + i]; + } + mp_obj_list_set_len(((mp_obj_t)rest), rest->len - num_right); + } + return; + +too_short: + if (((1)) == (1)) { + mp_raise_ValueError("wrong number of values to unpack"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "need more than %d values to unpack", (int)seq_len))) + ; + } +} + +mp_obj_t mp_load_attr(mp_obj_t base, qstr attr) { + (void)0; + + mp_obj_t dest[2]; + mp_load_method(base, attr, dest); + if (dest[1] == (((mp_obj_t)(void*)0))) { + + return dest[0]; + } else { + + return mp_obj_new_bound_meth(dest[0], dest[1]); + } +} +# 966 "user/mpy/py/runtime.c" +void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest) { + if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type == (&mp_type_staticmethod)))) { + + dest[0] = ((mp_obj_static_class_method_t*)((void*)member))->fun; + } else if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type == (&mp_type_classmethod)))) { + + + + if (self != (((mp_obj_t)(void*)0))) { + type = mp_obj_get_type(self); + } + dest[0] = ((mp_obj_static_class_method_t*)((void*)member))->fun; + dest[1] = ((mp_obj_t)type); + } else if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type == (&mp_type_type)))) { + + dest[0] = member; + } else if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type->name == MP_QSTR_function)) + || (MP_OBJ_IS_OBJ(member) + && (((mp_obj_base_t*)((void*)member))->type->name == MP_QSTR_closure + || ((mp_obj_base_t*)((void*)member))->type->name == MP_QSTR_generator))) { +# 1000 "user/mpy/py/runtime.c" + { + + dest[0] = member; + dest[1] = self; + } + } else { + + dest[0] = member; + } +} + + + + +void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { + + dest[0] = (((mp_obj_t)(void*)0)); + dest[1] = (((mp_obj_t)(void*)0)); + + + mp_obj_type_t *type = mp_obj_get_type(obj); + + + if (0) { + + + + + + + } else if (attr == MP_QSTR___next__ && type->iternext != +# 1030 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1030 "user/mpy/py/runtime.c" + ) { + dest[0] = ((mp_obj_t)&mp_builtin_next_obj); + dest[1] = obj; + + } else if (type->attr != +# 1034 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1034 "user/mpy/py/runtime.c" + ) { + + type->attr(obj, attr, dest); + + } else if (type->locals_dict != +# 1038 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1038 "user/mpy/py/runtime.c" + ) { + + + +# 1041 "user/mpy/py/runtime.c" 3 + (( +# 1041 "user/mpy/py/runtime.c" + type->locals_dict->base.type == &mp_type_dict +# 1041 "user/mpy/py/runtime.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1041, __func__, +# 1041 "user/mpy/py/runtime.c" + "type->locals_dict->base.type == &mp_type_dict" +# 1041 "user/mpy/py/runtime.c" 3 + )) +# 1041 "user/mpy/py/runtime.c" + ; + mp_map_t *locals_map = &type->locals_dict->map; + mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 1044 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1044 "user/mpy/py/runtime.c" + ) { + mp_convert_member_lookup(obj, type, elem->value, dest); + } + } +} + +void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { + (void)0; + + mp_load_method_maybe(base, attr, dest); + + if (dest[0] == (((mp_obj_t)(void*)0))) { + + if (((1)) == (1)) { + mp_raise_msg(&mp_type_AttributeError, "no such attribute"); + } else { + + if ((MP_OBJ_IS_OBJ(base) && (((mp_obj_base_t*)((void*)base))->type == (&mp_type_type)))) { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_AttributeError, "type object '%q' has no attribute '%q'", ((mp_obj_type_t*)((void*)base))->name, attr))) + + ; + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_AttributeError, "'%s' object has no attribute '%q'", mp_obj_get_type_str(base), attr))) + + ; + } + } + } +} + +void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { + (void)0; + mp_obj_type_t *type = mp_obj_get_type(base); + if (type->attr != +# 1077 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1077 "user/mpy/py/runtime.c" + ) { + mp_obj_t dest[2] = {(((mp_obj_t)(void*)8)), value}; + type->attr(base, attr, dest); + if (dest[0] == (((mp_obj_t)(void*)0))) { + + return; + } + } + if (((1)) == (1)) { + mp_raise_msg(&mp_type_AttributeError, "no such attribute"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_AttributeError, "'%s' object has no attribute '%q'", mp_obj_get_type_str(base), attr))) + + ; + } +} + +mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + +# 1095 "user/mpy/py/runtime.c" 3 + (( +# 1095 "user/mpy/py/runtime.c" + o_in +# 1095 "user/mpy/py/runtime.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1095, __func__, +# 1095 "user/mpy/py/runtime.c" + "o_in" +# 1095 "user/mpy/py/runtime.c" 3 + )) +# 1095 "user/mpy/py/runtime.c" + ; + mp_obj_type_t *type = mp_obj_get_type(o_in); + + + + if (type->getiter == mp_identity_getiter) { + return o_in; + } + + + if (iter_buf == +# 1105 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1105 "user/mpy/py/runtime.c" + ) { + iter_buf = (((mp_obj_iter_buf_t*)(m_malloc(sizeof(mp_obj_iter_buf_t) * (1))))); + } + + + if (type->getiter != +# 1110 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1110 "user/mpy/py/runtime.c" + ) { + mp_obj_t iter = type->getiter(o_in, iter_buf); + if (iter != (((mp_obj_t)(void*)0))) { + return iter; + } + } + + + mp_obj_t dest[2]; + mp_load_method_maybe(o_in, MP_QSTR___getitem__, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + + return mp_obj_new_getitem_iter(dest, iter_buf); + } + + + if (((1)) == (1)) { + mp_raise_TypeError("object not iterable"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not iterable", mp_obj_get_type_str(o_in)))) + ; + } +} + + + +mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->iternext != +# 1138 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1138 "user/mpy/py/runtime.c" + ) { + return type->iternext(o_in); + } else { + + mp_obj_t dest[2]; + mp_load_method_maybe(o_in, MP_QSTR___next__, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + + return mp_call_method_n_kw(0, 0, dest); + } else { + if (((1)) == (1)) { + mp_raise_TypeError("object not an iterator"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not an iterator", mp_obj_get_type_str(o_in)))) + ; + } + } + } +} + + + +mp_obj_t mp_iternext(mp_obj_t o_in) { + ; + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->iternext != +# 1163 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1163 "user/mpy/py/runtime.c" + ) { + return type->iternext(o_in); + } else { + + mp_obj_t dest[2]; + mp_load_method_maybe(o_in, MP_QSTR___next__, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t ret = mp_call_method_n_kw(0, 0, dest); + nlr_pop(); + return ret; + } else { + if (mp_obj_is_subclass_fast(((mp_obj_t)((mp_obj_base_t*)nlr.ret_val)->type), ((mp_obj_t)&mp_type_StopIteration))) { + return (((mp_obj_t)(void*)4)); + } else { + nlr_jump(nlr.ret_val); + } + } + } else { + if (((1)) == (1)) { + mp_raise_TypeError("object not an iterator"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not an iterator", mp_obj_get_type_str(o_in)))) + ; + } + } + } +} + + +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) { + +# 1196 "user/mpy/py/runtime.c" 3 + (( +# 1196 "user/mpy/py/runtime.c" + (send_value != (((mp_obj_t)(void*)0))) ^ (throw_value != (((mp_obj_t)(void*)0))) +# 1196 "user/mpy/py/runtime.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1196, __func__, +# 1196 "user/mpy/py/runtime.c" + "(send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL)" +# 1196 "user/mpy/py/runtime.c" 3 + )) +# 1196 "user/mpy/py/runtime.c" + ; + mp_obj_type_t *type = mp_obj_get_type(self_in); + + if (type == &mp_type_gen_instance) { + return mp_obj_gen_resume(self_in, send_value, throw_value, ret_val); + } + + if (type->iternext != +# 1203 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1203 "user/mpy/py/runtime.c" + && send_value == (((mp_obj_t)&mp_const_none_obj))) { + mp_obj_t ret = type->iternext(self_in); + if (ret != (((mp_obj_t)(void*)4))) { + *ret_val = ret; + return MP_VM_RETURN_YIELD; + } else { + + + *ret_val = (((mp_obj_t)(void*)0)); + return MP_VM_RETURN_NORMAL; + } + } + + mp_obj_t dest[3]; + + + if (send_value == (((mp_obj_t)&mp_const_none_obj))) { + mp_load_method_maybe(self_in, MP_QSTR___next__, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + *ret_val = mp_call_method_n_kw(0, 0, dest); + nlr_pop(); + return MP_VM_RETURN_YIELD; + } else { + *ret_val = ((mp_obj_t)nlr.ret_val); + return MP_VM_RETURN_EXCEPTION; + } + } + } + + + + if (send_value != (((mp_obj_t)(void*)0))) { + mp_load_method(self_in, MP_QSTR_send, dest); + dest[2] = send_value; + + + + + *ret_val = mp_call_method_n_kw(1, 0, dest); + return MP_VM_RETURN_YIELD; + } + + +# 1247 "user/mpy/py/runtime.c" 3 + (( +# 1247 "user/mpy/py/runtime.c" + throw_value != (((mp_obj_t)(void*)0)) +# 1247 "user/mpy/py/runtime.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1247, __func__, +# 1247 "user/mpy/py/runtime.c" + "throw_value != MP_OBJ_NULL" +# 1247 "user/mpy/py/runtime.c" 3 + )) +# 1247 "user/mpy/py/runtime.c" + ; + { + if (mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(throw_value)), ((mp_obj_t)&mp_type_GeneratorExit))) { + mp_load_method_maybe(self_in, MP_QSTR_close, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + + + *ret_val = mp_call_method_n_kw(0, 0, dest); + + return MP_VM_RETURN_NORMAL; + } + } else { + mp_load_method_maybe(self_in, MP_QSTR_throw, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + dest[2] = throw_value; + *ret_val = mp_call_method_n_kw(1, 0, dest); + + + return MP_VM_RETURN_YIELD; + } + } + + + + + + *ret_val = throw_value; + return MP_VM_RETURN_EXCEPTION; + } +} + +mp_obj_t mp_make_raise_obj(mp_obj_t o) { + (void)0; + if (mp_obj_is_exception_type(o)) { + + + + + return mp_call_function_n_kw(o, 0, 0, +# 1285 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1285 "user/mpy/py/runtime.c" + ); + } else if (mp_obj_is_exception_instance(o)) { + + return o; + } else { + + return mp_obj_new_exception_msg(&mp_type_TypeError, "exceptions must derive from BaseException"); + } +} + +mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level) { + (void)0; + + + mp_obj_t args[5]; + args[0] = ((mp_obj_t)((((mp_uint_t)(name)) << 2) | 2)); + args[1] = (((mp_obj_t)&mp_const_none_obj)); + args[2] = (((mp_obj_t)&mp_const_none_obj)); + args[3] = fromlist; + args[4] = level; + + + return mp_builtin___import__(5, args); +} + +mp_obj_t mp_import_from(mp_obj_t module, qstr name) { + (void)0; + + mp_obj_t dest[2]; + + mp_load_method_maybe(module, name, dest); + + if (dest[1] != (((mp_obj_t)(void*)0))) { + +import_error: + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ImportError, "cannot import name %q", name))); + } + + if (dest[0] != (((mp_obj_t)(void*)0))) { + return dest[0]; + } + + + if (!mp_obj_is_package(module)) { + goto import_error; + } + + mp_load_method_maybe(module, MP_QSTR___name__, dest); + size_t pkg_name_len; + const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len); + + const uint dot_name_len = pkg_name_len + 1 + qstr_len(name); + char *dot_name = +# 1337 "user/mpy/py/runtime.c" 3 + __builtin_alloca( +# 1337 "user/mpy/py/runtime.c" + dot_name_len +# 1337 "user/mpy/py/runtime.c" 3 + ) +# 1337 "user/mpy/py/runtime.c" + ; + memcpy(dot_name, pkg_name, pkg_name_len); + dot_name[pkg_name_len] = '.'; + memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name)); + qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len); + + mp_obj_t args[5]; + args[0] = ((mp_obj_t)((((mp_uint_t)(dot_name_q)) << 2) | 2)); + args[1] = (((mp_obj_t)&mp_const_none_obj)); + args[2] = (((mp_obj_t)&mp_const_none_obj)); + args[3] = (((mp_obj_t)&mp_const_true_obj)); + args[4] = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); + + + return mp_builtin___import__(5, args); +} + +void mp_import_all(mp_obj_t module) { + (void)0; + + + mp_map_t *map = mp_obj_dict_get_map(((mp_obj_t)mp_obj_module_get_globals(module))); + for (size_t i = 0; i < map->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + qstr name = (((mp_uint_t)(map->table[i].key)) >> 2); + if (*qstr_str(name) != '_') { + mp_store_name(name, map->table[i].value); + } + } + } +} + + + + +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { + + mp_obj_dict_t *volatile old_globals = mp_globals_get(); + mp_obj_dict_t *volatile old_locals = mp_locals_get(); + + + mp_globals_set(globals); + mp_locals_set(locals); + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + qstr source_name = lex->source_name; + mp_parse_tree_t parse_tree = mp_parse(lex, parse_input_kind); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, +# 1385 "user/mpy/py/runtime.c" 3 4 + 0 +# 1385 "user/mpy/py/runtime.c" + ); + + mp_obj_t ret; + if ((0) && globals == +# 1388 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1388 "user/mpy/py/runtime.c" + ) { + + ret = module_fun; + } else { + + ret = mp_call_function_0(module_fun); + } + + + nlr_pop(); + mp_globals_set(old_globals); + mp_locals_set(old_locals); + return ret; + } else { + + mp_globals_set(old_globals); + mp_locals_set(old_locals); + nlr_jump(nlr.ret_val); + } +} + + + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes) { + (void)0; + + if (gc_is_locked()) { + mp_raise_msg(&mp_type_MemoryError, "memory allocation failed, heap is locked"); + } + + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_MemoryError, "memory allocation failed, allocating %u bytes", (uint)num_bytes))) + ; +} + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) { + if (msg == +# 1423 "user/mpy/py/runtime.c" 3 4 + ((void *)0) +# 1423 "user/mpy/py/runtime.c" + ) { + nlr_jump(((void*)mp_obj_new_exception(exc_type))); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg(exc_type, msg))); + } +} + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg) { + mp_raise_msg(&mp_type_ValueError, msg); +} + +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg) { + mp_raise_msg(&mp_type_TypeError, msg); +} + +__attribute__((noreturn)) void mp_raise_OSError(int errno_) { + nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_OSError, ((mp_obj_t)((((mp_uint_t)(errno_)) << 1) | 1))))); +} + +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg) { + mp_raise_msg(&mp_type_NotImplementedError, msg); +} +# 1 "user/mpy/py/runtime_utils.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/runtime_utils.c" +# 28 "user/mpy/py/runtime_utils.c" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 29 "user/mpy/py/runtime_utils.c" 2 + + + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_call_function_1(fun, arg); + nlr_pop(); + } else { + mp_obj_print_exception(&mp_plat_print, ((mp_obj_t)nlr.ret_val)); + } +} + +void mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_call_function_2(fun, arg1, arg2); + nlr_pop(); + } else { + mp_obj_print_exception(&mp_plat_print, ((mp_obj_t)nlr.ret_val)); + } +} +# 1 "user/mpy/py/scheduler.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/scheduler.c" +# 27 "user/mpy/py/scheduler.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/scheduler.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/scheduler.c" 2 +# 109 "user/mpy/py/scheduler.c" +void mp_handle_pending(void) { + if ((mp_state_ctx.vm.mp_pending_exception) != (((mp_obj_t)(void*)0))) { + mp_obj_t obj = (mp_state_ctx.vm.mp_pending_exception); + (mp_state_ctx.vm.mp_pending_exception) = (((mp_obj_t)(void*)0)); + nlr_jump(((void*)obj)); + } +} +# 1 "user/mpy/py/nativeglue.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/nativeglue.c" +# 27 "user/mpy/py/nativeglue.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/nativeglue.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/nativeglue.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/nativeglue.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/nativeglue.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/nativeglue.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/nativeglue.c" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 35 "user/mpy/py/nativeglue.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 31 "user/mpy/py/bc.h" +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 36 "user/mpy/py/nativeglue.c" 2 +# 1 "user/mpy/py/stackctrl.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/stackctrl.c" +# 27 "user/mpy/py/stackctrl.c" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 28 "user/mpy/py/stackctrl.c" 2 + + +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/stackctrl.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 32 "user/mpy/py/stackctrl.c" 2 + +void mp_stack_ctrl_init(void) { + volatile int stack_dummy; + (mp_state_ctx.thread.stack_top) = (char*)&stack_dummy; +} + +void mp_stack_set_top(void *top) { + (mp_state_ctx.thread.stack_top) = top; +} + +mp_uint_t mp_stack_usage(void) { + + volatile int stack_dummy; + return (mp_state_ctx.thread.stack_top) - (char*)&stack_dummy; +} +# 1 "user/mpy/py/argcheck.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/argcheck.c" +# 27 "user/mpy/py/argcheck.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/argcheck.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/argcheck.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/argcheck.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/argcheck.c" 2 + +void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 33 "user/mpy/py/argcheck.c" 3 4 + _Bool +# 33 "user/mpy/py/argcheck.c" + takes_kw) { + + + if (n_kw && !takes_kw) { + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + mp_raise_TypeError("function does not take keyword arguments"); + } + } + + if (n_args_min == n_args_max) { + if (n_args != n_args_min) { + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function takes %d positional arguments but %d were given", n_args_min, n_args))) + + ; + } + } + } else { + if (n_args < n_args_min) { + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function missing %d required positional arguments", n_args_min - n_args))) + + ; + } + } else if (n_args > n_args_max) { + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function expected at most %d arguments, got %d", n_args_max, n_args))) + + ; + } + } + } +} + +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) { + size_t pos_found = 0, kws_found = 0; + for (size_t i = 0; i < n_allowed; i++) { + mp_obj_t given_arg; + if (i < n_pos) { + if (allowed[i].flags & MP_ARG_KW_ONLY) { + goto extra_positional; + } + pos_found++; + given_arg = pos[i]; + } else { + mp_map_elem_t *kw = mp_map_lookup(kws, ((mp_obj_t)((((mp_uint_t)(allowed[i].qst)) << 2) | 2)), MP_MAP_LOOKUP); + if (kw == +# 87 "user/mpy/py/argcheck.c" 3 4 + ((void *)0) +# 87 "user/mpy/py/argcheck.c" + ) { + if (allowed[i].flags & MP_ARG_REQUIRED) { + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%q' argument required", allowed[i].qst))) + ; + } + } + out_vals[i] = allowed[i].defval; + continue; + } else { + kws_found++; + given_arg = kw->value; + } + } + if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_BOOL) { + out_vals[i].u_bool = mp_obj_is_true(given_arg); + } else if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_INT) { + out_vals[i].u_int = mp_obj_get_int(given_arg); + } else { + +# 108 "user/mpy/py/argcheck.c" 3 + (( +# 108 "user/mpy/py/argcheck.c" + (allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_OBJ +# 108 "user/mpy/py/argcheck.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/argcheck.c", 108, __func__, +# 108 "user/mpy/py/argcheck.c" + "(allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_OBJ" +# 108 "user/mpy/py/argcheck.c" 3 + )) +# 108 "user/mpy/py/argcheck.c" + ; + out_vals[i].u_obj = given_arg; + } + } + if (pos_found < n_pos) { + extra_positional: + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + + mp_raise_TypeError("extra positional arguments given"); + } + } + if (kws_found < kws->used) { + if (((1)) == (1)) { + mp_arg_error_terse_mismatch(); + } else { + + mp_raise_TypeError("extra keyword arguments given"); + } + } +} + +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) { + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, args + n_pos); + mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals); +} + + +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void) { + mp_raise_TypeError("argument num/types mismatch"); +} +# 1 "user/mpy/py/warning.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/warning.c" +# 27 "user/mpy/py/warning.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 + +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 28 "user/mpy/py/warning.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/warning.c" 2 + +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 29 "user/mpy/py/lexer.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/lexer.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 31 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 31 "user/mpy/py/warning.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/warning.c" 2 +# 1 "user/mpy/py/map.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/map.c" +# 27 "user/mpy/py/map.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/map.c" 2 +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 29 "user/mpy/py/map.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/map.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/map.c" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 33 "user/mpy/py/map.c" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/map.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/map.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 36 "user/mpy/py/map.c" 2 + + + +const mp_map_t mp_const_empty_map = { + .all_keys_are_qstrs = 0, + .is_fixed = 1, + .is_ordered = 1, + .used = 0, + .alloc = 0, + .table = +# 45 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 45 "user/mpy/py/map.c" + , +}; + + + + + +static const uint16_t hash_allocation_sizes[] = { + 0, 2, 4, 6, 8, 10, 12, + 17, 23, 29, 37, 47, 59, 73, + 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, + 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, +}; + +static size_t get_hash_alloc_greater_or_equal_to(size_t x) { + for (size_t i = 0; i < (sizeof(hash_allocation_sizes) / sizeof((hash_allocation_sizes)[0])); i++) { + if (hash_allocation_sizes[i] >= x) { + return hash_allocation_sizes[i]; + } + } + + + return (x + x / 2) | 1; +} + + + + +void mp_map_init(mp_map_t *map, size_t n) { + if (n == 0) { + map->alloc = 0; + map->table = +# 76 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 76 "user/mpy/py/map.c" + ; + } else { + map->alloc = n; + map->table = ((mp_map_elem_t*)(m_malloc0(sizeof(mp_map_elem_t) * (map->alloc)))); + } + map->used = 0; + map->all_keys_are_qstrs = 1; + map->is_fixed = 0; + map->is_ordered = 0; +} + +void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table) { + map->alloc = n; + map->used = n; + map->all_keys_are_qstrs = 1; + map->is_fixed = 1; + map->is_ordered = 1; + map->table = (mp_map_elem_t*)table; +} + +mp_map_t *mp_map_new(size_t n) { + mp_map_t *map = ((mp_map_t*)(m_malloc(sizeof(mp_map_t) * (1)))); + mp_map_init(map, n); + return map; +} + + +void mp_map_deinit(mp_map_t *map) { + if (!map->is_fixed) { + ((void)(map->alloc), m_free(map->table)); + } + map->used = map->alloc = 0; +} + +void mp_map_free(mp_map_t *map) { + mp_map_deinit(map); + (((void)(1), m_free(map))); +} + +void mp_map_clear(mp_map_t *map) { + if (!map->is_fixed) { + ((void)(map->alloc), m_free(map->table)); + } + map->alloc = 0; + map->used = 0; + map->all_keys_are_qstrs = 1; + map->is_fixed = 0; + map->table = +# 123 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 123 "user/mpy/py/map.c" + ; +} + +static void mp_map_rehash(mp_map_t *map) { + size_t old_alloc = map->alloc; + size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1); + mp_map_elem_t *old_table = map->table; + mp_map_elem_t *new_table = ((mp_map_elem_t*)(m_malloc0(sizeof(mp_map_elem_t) * (new_alloc)))); + + map->alloc = new_alloc; + map->used = 0; + map->all_keys_are_qstrs = 1; + map->table = new_table; + for (size_t i = 0; i < old_alloc; i++) { + if (old_table[i].key != (((mp_obj_t)(void*)0)) && old_table[i].key != (((mp_obj_t)(void*)8))) { + mp_map_lookup(map, old_table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = old_table[i].value; + } + } + ((void)(old_alloc), m_free(old_table)); +} + + + + + + + +mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { + + if (map->is_fixed && lookup_kind != MP_MAP_LOOKUP) { + + return +# 154 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 154 "user/mpy/py/map.c" + ; + } + + + +# 158 "user/mpy/py/map.c" 3 4 + _Bool +# 158 "user/mpy/py/map.c" + compare_only_ptrs = map->all_keys_are_qstrs; + if (compare_only_ptrs) { + if (MP_OBJ_IS_QSTR(index)) { + + } else if ((MP_OBJ_IS_OBJ(index) && (((mp_obj_base_t*)((void*)index))->type == (&mp_type_str)))) { + + + + + + compare_only_ptrs = +# 168 "user/mpy/py/map.c" 3 4 + 0 +# 168 "user/mpy/py/map.c" + ; + } else if (lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + + + return +# 172 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 172 "user/mpy/py/map.c" + ; + } + } + + + if (map->is_ordered) { + for (mp_map_elem_t *elem = &map->table[0], *top = &map->table[map->used]; elem < top; elem++) { + if (elem->key == index || (!compare_only_ptrs && mp_obj_equal(elem->key, index))) { + if (__builtin_expect((lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND), 0)) { + + mp_obj_t value = elem->value; + --map->used; + memmove(elem, elem + 1, (top - elem - 1) * sizeof(*elem)); + + elem = &map->table[map->used]; + elem->key = (((mp_obj_t)(void*)0)); + elem->value = value; + } + return elem; + } + } + if (__builtin_expect((lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND), 1)) { + return +# 194 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 194 "user/mpy/py/map.c" + ; + } + if (map->used == map->alloc) { + + map->alloc += 4; + map->table = ((mp_map_elem_t*)(m_realloc((map->table), sizeof(mp_map_elem_t) * (map->alloc)))); + memset((byte*)(map->table) + (map->used) * (sizeof(*map->table)), 0, ((map->alloc) - (map->used)) * (sizeof(*map->table))); + } + mp_map_elem_t *elem = map->table + map->used++; + elem->key = index; + if (!MP_OBJ_IS_QSTR(index)) { + map->all_keys_are_qstrs = 0; + } + return elem; + } + + + + if (map->alloc == 0) { + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + mp_map_rehash(map); + } else { + return +# 216 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 216 "user/mpy/py/map.c" + ; + } + } + + + mp_uint_t hash; + if (MP_OBJ_IS_QSTR(index)) { + hash = qstr_hash((((mp_uint_t)(index)) >> 2)); + } else { + hash = (((mp_int_t)(mp_unary_op(MP_UNARY_OP_HASH, index))) >> 1); + } + + size_t pos = hash % map->alloc; + size_t start_pos = pos; + mp_map_elem_t *avail_slot = +# 230 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 230 "user/mpy/py/map.c" + ; + for (;;) { + mp_map_elem_t *slot = &map->table[pos]; + if (slot->key == (((mp_obj_t)(void*)0))) { + + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + map->used += 1; + if (avail_slot == +# 237 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 237 "user/mpy/py/map.c" + ) { + avail_slot = slot; + } + avail_slot->key = index; + avail_slot->value = (((mp_obj_t)(void*)0)); + if (!MP_OBJ_IS_QSTR(index)) { + map->all_keys_are_qstrs = 0; + } + return avail_slot; + } else { + return +# 247 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 247 "user/mpy/py/map.c" + ; + } + } else if (slot->key == (((mp_obj_t)(void*)8))) { + + if (avail_slot == +# 251 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 251 "user/mpy/py/map.c" + ) { + avail_slot = slot; + } + } else if (slot->key == index || (!compare_only_ptrs && mp_obj_equal(slot->key, index))) { + + + if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + + map->used--; + if (map->table[(pos + 1) % map->alloc].key == (((mp_obj_t)(void*)0))) { + + slot->key = (((mp_obj_t)(void*)0)); + } else { + slot->key = (((mp_obj_t)(void*)8)); + } + + } + return slot; + } + + + pos = (pos + 1) % map->alloc; + + if (pos == start_pos) { + + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + if (avail_slot != +# 277 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 277 "user/mpy/py/map.c" + ) { + + map->used++; + avail_slot->key = index; + avail_slot->value = (((mp_obj_t)(void*)0)); + if (!MP_OBJ_IS_QSTR(index)) { + map->all_keys_are_qstrs = 0; + } + return avail_slot; + } else { + + mp_map_rehash(map); + + start_pos = pos = hash % map->alloc; + } + } else { + return +# 293 "user/mpy/py/map.c" 3 4 + ((void *)0) +# 293 "user/mpy/py/map.c" + ; + } + } + } +} +# 1 "user/mpy/py/obj.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/obj.c" +# 27 "user/mpy/py/obj.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/obj.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/obj.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 30 "user/mpy/py/obj.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/obj.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 33 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 34 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/objtype.h" 1 +# 33 "user/mpy/py/objtype.h" +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 35 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 + + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 36 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 37 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 38 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 39 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 40 "user/mpy/py/obj.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 41 "user/mpy/py/obj.c" 2 + +mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { + if (MP_OBJ_IS_SMALL_INT(o_in)) { + return (mp_obj_type_t*)&mp_type_int; + } else if (MP_OBJ_IS_QSTR(o_in)) { + return (mp_obj_type_t*)&mp_type_str; + + + + + } else { + const mp_obj_base_t *o = ((void*)o_in); + return (mp_obj_type_t*)o->type; + } +} + +const char *mp_obj_get_type_str(mp_const_obj_t o_in) { + return qstr_str(mp_obj_get_type(o_in)->name); +} + +void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + + ; + + if (o_in == (((mp_obj_t)(void*)0))) { + mp_print_str(print, "(nil)"); + return; + } + + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->print != +# 71 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 71 "user/mpy/py/obj.c" + ) { + type->print((mp_print_t*)print, o_in, kind); + } else { + mp_printf(print, "<%q>", type->name); + } +} + +void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_print_helper(&mp_plat_print, o_in, kind); +} + + +void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { + if (mp_obj_is_exception_instance(exc)) { + size_t n, *values; + mp_obj_exception_get_traceback(exc, &n, &values); + if (n > 0) { + +# 88 "user/mpy/py/obj.c" 3 + (( +# 88 "user/mpy/py/obj.c" + n % 3 == 0 +# 88 "user/mpy/py/obj.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/obj.c", 88, __func__, +# 88 "user/mpy/py/obj.c" + "n % 3 == 0" +# 88 "user/mpy/py/obj.c" 3 + )) +# 88 "user/mpy/py/obj.c" + ; + mp_print_str(print, "Traceback (most recent call last):\n"); + for (int i = n - 3; i >= 0; i -= 3) { + + + + mp_printf(print, " File \"%q\"", values[i]); + + + qstr block = values[i + 2]; + if (block == MP_QSTR_NULL) { + mp_print_str(print, "\n"); + } else { + mp_printf(print, ", in %q\n", block); + } + } + } + } + mp_obj_print_helper(print, exc, PRINT_EXC); + mp_print_str(print, "\n"); +} + + +# 110 "user/mpy/py/obj.c" 3 4 +_Bool +# 110 "user/mpy/py/obj.c" + mp_obj_is_true(mp_obj_t arg) { + if (arg == (((mp_obj_t)&mp_const_false_obj))) { + return 0; + } else if (arg == (((mp_obj_t)&mp_const_true_obj))) { + return 1; + } else if (arg == (((mp_obj_t)&mp_const_none_obj))) { + return 0; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + if ((((mp_int_t)(arg)) >> 1) == 0) { + return 0; + } else { + return 1; + } + } else { + mp_obj_type_t *type = mp_obj_get_type(arg); + if (type->unary_op != +# 125 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 125 "user/mpy/py/obj.c" + ) { + mp_obj_t result = type->unary_op(MP_UNARY_OP_BOOL, arg); + if (result != (((mp_obj_t)(void*)0))) { + return result == (((mp_obj_t)&mp_const_true_obj)); + } + } + + mp_obj_t len = mp_obj_len_maybe(arg); + if (len != (((mp_obj_t)(void*)0))) { + + return len != ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); + } else { + + return 1; + } + } +} + + +# 143 "user/mpy/py/obj.c" 3 4 +_Bool +# 143 "user/mpy/py/obj.c" + mp_obj_is_callable(mp_obj_t o_in) { + mp_call_fun_t call = mp_obj_get_type(o_in)->call; + if (call != mp_obj_instance_call) { + return call != +# 146 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 146 "user/mpy/py/obj.c" + ; + } + return mp_obj_instance_is_callable(o_in); +} +# 164 "user/mpy/py/obj.c" + +# 164 "user/mpy/py/obj.c" 3 4 +_Bool +# 164 "user/mpy/py/obj.c" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2) { + if (o1 == o2) { + return +# 166 "user/mpy/py/obj.c" 3 4 + 1 +# 166 "user/mpy/py/obj.c" + ; + } + if (o1 == (((mp_obj_t)&mp_const_none_obj)) || o2 == (((mp_obj_t)&mp_const_none_obj))) { + return +# 169 "user/mpy/py/obj.c" 3 4 + 0 +# 169 "user/mpy/py/obj.c" + ; + } + + + if (MP_OBJ_IS_SMALL_INT(o1)) { + if (MP_OBJ_IS_SMALL_INT(o2)) { + + return +# 176 "user/mpy/py/obj.c" 3 4 + 0 +# 176 "user/mpy/py/obj.c" + ; + } else { + mp_obj_t temp = o2; o2 = o1; o1 = temp; + + + } + } + + + if ((MP_OBJ_IS_QSTR(o1) || (MP_OBJ_IS_OBJ(o1) && (((mp_obj_base_t*)((void*)o1))->type == (&mp_type_str))))) { + if ((MP_OBJ_IS_QSTR(o2) || (MP_OBJ_IS_OBJ(o2) && (((mp_obj_base_t*)((void*)o2))->type == (&mp_type_str))))) { + + return mp_obj_str_equal(o1, o2); + } else { + + goto str_cmp_err; + } + } else if ((MP_OBJ_IS_QSTR(o2) || (MP_OBJ_IS_OBJ(o2) && (((mp_obj_base_t*)((void*)o2))->type == (&mp_type_str))))) { + + str_cmp_err: + + + + + + return +# 201 "user/mpy/py/obj.c" 3 4 + 0 +# 201 "user/mpy/py/obj.c" + ; + } + + + mp_obj_type_t *type = mp_obj_get_type(o1); + if (type->binary_op != +# 206 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 206 "user/mpy/py/obj.c" + ) { + mp_obj_t r = type->binary_op(MP_BINARY_OP_EQUAL, o1, o2); + if (r != (((mp_obj_t)(void*)0))) { + return r == (((mp_obj_t)&mp_const_true_obj)) ? +# 209 "user/mpy/py/obj.c" 3 4 + 1 +# 209 "user/mpy/py/obj.c" + : +# 209 "user/mpy/py/obj.c" 3 4 + 0 +# 209 "user/mpy/py/obj.c" + ; + } + } + + + + return +# 215 "user/mpy/py/obj.c" 3 4 + 0 +# 215 "user/mpy/py/obj.c" + ; +} + +mp_int_t mp_obj_get_int(mp_const_obj_t arg) { + + + + if (arg == (((mp_obj_t)&mp_const_false_obj))) { + return 0; + } else if (arg == (((mp_obj_t)&mp_const_true_obj))) { + return 1; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + return (((mp_int_t)(arg)) >> 1); + } else if ((MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int)))) { + return mp_obj_int_get_checked(arg); + } else { + if (((1)) == (1)) { + mp_raise_TypeError("can't convert to int"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't convert %s to int", mp_obj_get_type_str(arg)))) + ; + } + } +} + +mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg) { + if ((MP_OBJ_IS_SMALL_INT(arg) || (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int))))) { + return mp_obj_int_get_truncated(arg); + } else { + return mp_obj_get_int(arg); + } +} + + + + + +# 251 "user/mpy/py/obj.c" 3 4 +_Bool +# 251 "user/mpy/py/obj.c" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value) { + if (arg == (((mp_obj_t)&mp_const_false_obj))) { + *value = 0; + } else if (arg == (((mp_obj_t)&mp_const_true_obj))) { + *value = 1; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + *value = (((mp_int_t)(arg)) >> 1); + } else if ((MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int)))) { + *value = mp_obj_int_get_checked(arg); + } else { + return +# 261 "user/mpy/py/obj.c" 3 4 + 0 +# 261 "user/mpy/py/obj.c" + ; + } + return +# 263 "user/mpy/py/obj.c" 3 4 + 1 +# 263 "user/mpy/py/obj.c" + ; +} +# 324 "user/mpy/py/obj.c" +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) { + if ((MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_tuple)))) { + mp_obj_tuple_get(o, len, items); + } else if ((MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_list)))) { + mp_obj_list_get(o, len, items); + } else { + if (((1)) == (1)) { + mp_raise_TypeError("expected tuple/list"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "object '%s' is not a tuple or list", mp_obj_get_type_str(o)))) + ; + } + } +} + + +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) { + size_t seq_len; + mp_obj_get_array(o, &seq_len, items); + if (seq_len != len) { + if (((1)) == (1)) { + mp_raise_ValueError("tuple/list has wrong length"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "requested length %d but object has length %d", (int)len, (int)seq_len))) + ; + } + } +} + + +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 354 "user/mpy/py/obj.c" 3 4 + _Bool +# 354 "user/mpy/py/obj.c" + is_slice) { + mp_int_t i; + if (MP_OBJ_IS_SMALL_INT(index)) { + i = (((mp_int_t)(index)) >> 1); + } else if (!mp_obj_get_int_maybe(index, &i)) { + if (((1)) == (1)) { + mp_raise_TypeError("indices must be integers"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "%q indices must be integers, not %s", type->name, mp_obj_get_type_str(index)))) + + ; + } + } + + if (i < 0) { + i += len; + } + if (is_slice) { + if (i < 0) { + i = 0; + } else if ((mp_uint_t)i > len) { + i = len; + } + } else { + if (i < 0 || (mp_uint_t)i >= len) { + if (((1)) == (1)) { + mp_raise_msg(&mp_type_IndexError, "index out of range"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_IndexError, "%q index out of range", type->name))) + ; + } + } + } + + + return (size_t)i; +} + +mp_obj_t mp_obj_id(mp_obj_t o_in) { + mp_int_t id = (mp_int_t)o_in; + if (!MP_OBJ_IS_OBJ(o_in)) { + return mp_obj_new_int(id); + } else if (id >= 0) { + + + + + return ((mp_obj_t)((((mp_uint_t)(id)) << 1) | 1)); + } else { + + + + return mp_obj_new_int_from_uint((mp_uint_t)id); + } +} + + +mp_obj_t mp_obj_len(mp_obj_t o_in) { + mp_obj_t len = mp_obj_len_maybe(o_in); + if (len == (((mp_obj_t)(void*)0))) { + if (((1)) == (1)) { + mp_raise_TypeError("object has no len"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "object of type '%s' has no len()", mp_obj_get_type_str(o_in)))) + ; + } + } else { + return len; + } +} + + +mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { + if ( + + + (MP_OBJ_IS_QSTR(o_in) || (MP_OBJ_IS_OBJ(o_in) && (((mp_obj_base_t*)((void*)o_in))->type == (&mp_type_str)))) || + + (MP_OBJ_IS_OBJ(o_in) && (((mp_obj_base_t*)((void*)o_in))->type == (&mp_type_bytes)))) { + size_t l; if (MP_OBJ_IS_QSTR(o_in)) { l = qstr_len((((mp_uint_t)(o_in)) >> 2)); } else { l = ((mp_obj_str_t*)((void*)o_in))->len; }; + return ((mp_obj_t)((((mp_uint_t)(l)) << 1) | 1)); + } else { + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->unary_op != +# 437 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 437 "user/mpy/py/obj.c" + ) { + return type->unary_op(MP_UNARY_OP_LEN, o_in); + } else { + return (((mp_obj_t)(void*)0)); + } + } +} + +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(base); + if (type->subscr != +# 447 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 447 "user/mpy/py/obj.c" + ) { + mp_obj_t ret = type->subscr(base, index, value); + if (ret != (((mp_obj_t)(void*)0))) { + return ret; + } + + } + if (value == (((mp_obj_t)(void*)0))) { + if (((1)) == (1)) { + mp_raise_TypeError("object does not support item deletion"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object does not support item deletion", mp_obj_get_type_str(base)))) + ; + } + } else if (value == (((mp_obj_t)(void*)8))) { + if (((1)) == (1)) { + mp_raise_TypeError("object is not subscriptable"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not subscriptable", mp_obj_get_type_str(base)))) + ; + } + } else { + if (((1)) == (1)) { + mp_raise_TypeError("object does not support item assignment"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object does not support item assignment", mp_obj_get_type_str(base)))) + ; + } + } +} + + + +mp_obj_t mp_identity(mp_obj_t self) { + return self; +} +const mp_obj_fun_builtin_fixed_t mp_identity_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_identity}; + +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf) { + (void)iter_buf; + return self; +} + + +# 490 "user/mpy/py/obj.c" 3 4 +_Bool +# 490 "user/mpy/py/obj.c" + mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + mp_obj_type_t *type = mp_obj_get_type(obj); + if (type->buffer_p.get_buffer == +# 492 "user/mpy/py/obj.c" 3 4 + ((void *)0) +# 492 "user/mpy/py/obj.c" + ) { + return +# 493 "user/mpy/py/obj.c" 3 4 + 0 +# 493 "user/mpy/py/obj.c" + ; + } + int ret = type->buffer_p.get_buffer(obj, bufinfo, flags); + if (ret != 0) { + return +# 497 "user/mpy/py/obj.c" 3 4 + 0 +# 497 "user/mpy/py/obj.c" + ; + } + return +# 499 "user/mpy/py/obj.c" 3 4 + 1 +# 499 "user/mpy/py/obj.c" + ; +} + +void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + if (!mp_get_buffer(obj, bufinfo, flags)) { + mp_raise_TypeError("object with buffer protocol required"); + } +} + +mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in) { + switch (op) { + case MP_UNARY_OP_HASH: return ((mp_obj_t)((((mp_uint_t)((mp_uint_t)o_in)) << 1) | 1)); + default: return (((mp_obj_t)(void*)0)); + } +} +# 1 "user/mpy/py/objarray.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objarray.c" +# 28 "user/mpy/py/objarray.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/objarray.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objarray.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 31 "user/mpy/py/objarray.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 33 "user/mpy/py/objarray.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 34 "user/mpy/py/objarray.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 35 "user/mpy/py/objarray.c" 2 +# 1 "user/mpy/py/binary.h" 1 +# 35 "user/mpy/py/binary.h" +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 36 "user/mpy/py/objarray.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 37 "user/mpy/py/objarray.c" 2 +# 1 "user/mpy/py/objarray.h" 1 +# 32 "user/mpy/py/objarray.h" +typedef struct _mp_obj_array_t { + mp_obj_base_t base; + size_t typecode : 8; + + + size_t free : (8 * sizeof(size_t) - 8); + size_t len; + void *items; +} mp_obj_array_t; +# 38 "user/mpy/py/objarray.c" 2 +# 1 "user/mpy/py/objattrtuple.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objattrtuple.c" +# 27 "user/mpy/py/objattrtuple.c" +# 1 "user/mpy/py/objtuple.h" 1 +# 29 "user/mpy/py/objtuple.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtuple.h" 2 + +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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 28 "user/mpy/py/objattrtuple.c" 2 +# 1 "user/mpy/py/objbool.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objbool.c" +# 27 "user/mpy/py/objbool.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objbool.c" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objbool.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 31 "user/mpy/py/objbool.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/objbool.c" 2 + +typedef struct _mp_obj_bool_t { + mp_obj_base_t base; + +# 35 "user/mpy/py/objbool.c" 3 4 + _Bool +# 35 "user/mpy/py/objbool.c" + value; +} mp_obj_bool_t; + +static void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_obj_bool_t *self = ((void*)self_in); + if ((0) && kind == PRINT_JSON) { + if (self->value) { + mp_print_str(print, "true"); + } else { + mp_print_str(print, "false"); + } + } else { + if (self->value) { + mp_print_str(print, "True"); + } else { + mp_print_str(print, "False"); + } + } +} + +static mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 1, +# 57 "user/mpy/py/objbool.c" 3 4 + 0 +# 57 "user/mpy/py/objbool.c" + ); + + if (n_args == 0) { + return (((mp_obj_t)&mp_const_false_obj)); + } else { + return mp_obj_new_bool(mp_obj_is_true(args[0])); + } +} + +static mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { + if (op == MP_UNARY_OP_LEN) { + return (((mp_obj_t)(void*)0)); + } + mp_obj_bool_t *self = ((void*)o_in); + return mp_unary_op(op, ((mp_obj_t)((((mp_uint_t)(self->value)) << 1) | 1))); +} + +static mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_bool_t *self = ((void*)lhs_in); + return mp_binary_op(op, ((mp_obj_t)((((mp_uint_t)(self->value)) << 1) | 1)), rhs_in); +} + +const mp_obj_type_t mp_type_bool = { + { &mp_type_type }, + .name = MP_QSTR_bool, + .print = bool_print, + .make_new = bool_make_new, + .unary_op = bool_unary_op, + .binary_op = bool_binary_op, +}; + +const mp_obj_bool_t mp_const_false_obj = {{&mp_type_bool}, +# 88 "user/mpy/py/objbool.c" 3 4 + 0 +# 88 "user/mpy/py/objbool.c" + }; +const mp_obj_bool_t mp_const_true_obj = {{&mp_type_bool}, +# 89 "user/mpy/py/objbool.c" 3 4 + 1 +# 89 "user/mpy/py/objbool.c" + }; +# 1 "user/mpy/py/objboundmeth.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objboundmeth.c" +# 27 "user/mpy/py/objboundmeth.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objboundmeth.c" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objboundmeth.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objboundmeth.c" 2 + +typedef struct _mp_obj_bound_meth_t { + mp_obj_base_t base; + mp_obj_t meth; + mp_obj_t self; +} mp_obj_bound_meth_t; +# 50 "user/mpy/py/objboundmeth.c" +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) { + + size_t n_total = n_args + 2 * n_kw; + mp_obj_t *args2 = +# 53 "user/mpy/py/objboundmeth.c" 3 4 + ((void *)0) +# 53 "user/mpy/py/objboundmeth.c" + ; + mp_obj_t *free_args2 = +# 54 "user/mpy/py/objboundmeth.c" 3 4 + ((void *)0) +# 54 "user/mpy/py/objboundmeth.c" + ; + if (n_total > 4) { + + args2 = ((mp_obj_t*)(m_malloc_maybe(sizeof(mp_obj_t) * (1 + n_total)))); + free_args2 = args2; + } + if (args2 == +# 60 "user/mpy/py/objboundmeth.c" 3 4 + ((void *)0) +# 60 "user/mpy/py/objboundmeth.c" + ) { + + args2 = +# 62 "user/mpy/py/objboundmeth.c" 3 + __builtin_alloca( +# 62 "user/mpy/py/objboundmeth.c" + sizeof(mp_obj_t) * (1 + n_total) +# 62 "user/mpy/py/objboundmeth.c" 3 + ) +# 62 "user/mpy/py/objboundmeth.c" + ; + } + args2[0] = self; + memcpy(args2 + 1, args, n_total * sizeof(mp_obj_t)); + mp_obj_t res = mp_call_function_n_kw(meth, n_args + 1, n_kw, args2); + if (free_args2 != +# 67 "user/mpy/py/objboundmeth.c" 3 4 + ((void *)0) +# 67 "user/mpy/py/objboundmeth.c" + ) { + ((void)(1 + n_total), m_free(free_args2)); + } + return res; +} + +static mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_bound_meth_t *self = ((void*)self_in); + return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args); +} +# 91 "user/mpy/py/objboundmeth.c" +static const mp_obj_type_t mp_type_bound_meth = { + { &mp_type_type }, + .name = MP_QSTR_bound_method, + + + + .call = bound_meth_call, + + + +}; + +mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) { + mp_obj_bound_meth_t *o = (((mp_obj_bound_meth_t*)(m_malloc(sizeof(mp_obj_bound_meth_t) * (1))))); + o->base.type = &mp_type_bound_meth; + o->meth = meth; + o->self = self; + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objcell.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objcell.c" +# 27 "user/mpy/py/objcell.c" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 28 "user/mpy/py/objcell.c" 2 + +typedef struct _mp_obj_cell_t { + mp_obj_base_t base; + mp_obj_t obj; +} mp_obj_cell_t; + +mp_obj_t mp_obj_cell_get(mp_obj_t self_in) { + mp_obj_cell_t *self = ((void*)self_in); + return self->obj; +} + +void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) { + mp_obj_cell_t *self = ((void*)self_in); + self->obj = obj; +} +# 58 "user/mpy/py/objcell.c" +static const mp_obj_type_t mp_type_cell = { + { &mp_type_type }, + .name = MP_QSTR_, + + + +}; + +mp_obj_t mp_obj_new_cell(mp_obj_t obj) { + mp_obj_cell_t *o = (((mp_obj_cell_t*)(m_malloc(sizeof(mp_obj_cell_t) * (1))))); + o->base.type = &mp_type_cell; + o->obj = obj; + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objclosure.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objclosure.c" +# 27 "user/mpy/py/objclosure.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objclosure.c" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objclosure.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objclosure.c" 2 + +typedef struct _mp_obj_closure_t { + mp_obj_base_t base; + mp_obj_t fun; + size_t n_closed; + mp_obj_t closed[]; +} mp_obj_closure_t; + +static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_closure_t *self = ((void*)self_in); + + + + size_t n_total = self->n_closed + n_args + 2 * n_kw; + if (n_total <= 5) { + + mp_obj_t args2[5]; + memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); + memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + return mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); + } else { + + mp_obj_t *args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (n_total)))); + memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); + memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + mp_obj_t res = mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); + ((void)(n_total), m_free(args2)); + return res; + } +} +# 81 "user/mpy/py/objclosure.c" +const mp_obj_type_t closure_type = { + { &mp_type_type }, + .name = MP_QSTR_closure, + + + + .call = closure_call, +}; + +mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) { + mp_obj_closure_t *o = ((mp_obj_closure_t*)m_malloc(sizeof(mp_obj_closure_t) + sizeof(mp_obj_t) * (n_closed_over))); + o->base.type = &closure_type; + o->fun = fun; + o->n_closed = n_closed_over; + memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t)); + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objcomplex.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objcomplex.c" +# 27 "user/mpy/py/objcomplex.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objcomplex.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 61 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/objcomplex.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objcomplex.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objcomplex.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 33 "user/mpy/py/objcomplex.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 34 "user/mpy/py/objcomplex.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/objcomplex.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 36 "user/mpy/py/objcomplex.c" 2 +# 1 "user/mpy/py/objdict.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objdict.c" +# 27 "user/mpy/py/objdict.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objdict.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objdict.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objdict.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 32 "user/mpy/py/objdict.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/objdict.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/objdict.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 35 "user/mpy/py/objdict.c" 2 +# 1 "user/mpy/py/objtype.h" 1 +# 33 "user/mpy/py/objtype.h" +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 36 "user/mpy/py/objdict.c" 2 + + + +static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); + + + + +static mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) { + size_t max = dict->map.alloc; + mp_map_t *map = &dict->map; + + for (size_t i = *cur; i < max; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + *cur = i + 1; + return &(map->table[i]); + } + } + + return +# 55 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 55 "user/mpy/py/objdict.c" + ; +} + +static void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_obj_dict_t *self = ((void*)self_in); + +# 60 "user/mpy/py/objdict.c" 3 4 + _Bool +# 60 "user/mpy/py/objdict.c" + first = +# 60 "user/mpy/py/objdict.c" 3 4 + 1 +# 60 "user/mpy/py/objdict.c" + ; + if (!((0) && kind == PRINT_JSON)) { + kind = PRINT_REPR; + } + if ((0) && self->base.type != &mp_type_dict) { + mp_printf(print, "%q(", self->base.type->name); + } + mp_print_str(print, "{"); + size_t cur = 0; + mp_map_elem_t *next = +# 69 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 69 "user/mpy/py/objdict.c" + ; + while ((next = dict_iter_next(self, &cur)) != +# 70 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 70 "user/mpy/py/objdict.c" + ) { + if (!first) { + mp_print_str(print, ", "); + } + first = +# 74 "user/mpy/py/objdict.c" 3 4 + 0 +# 74 "user/mpy/py/objdict.c" + ; + mp_obj_print_helper(print, next->key, kind); + mp_print_str(print, ": "); + mp_obj_print_helper(print, next->value, kind); + } + mp_print_str(print, "}"); + if ((0) && self->base.type != &mp_type_dict) { + mp_print_str(print, ")"); + } +} + +static mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_t dict_out = mp_obj_new_dict(0); + mp_obj_dict_t *dict = ((void*)dict_out); + dict->base.type = type; + + + + + + if (n_args > 0 || n_kw > 0) { + mp_obj_t args2[2] = {dict_out, args[0]}; + mp_map_t kwargs; + mp_map_init_fixed_table(&kwargs, n_kw, args + n_args); + dict_update(n_args + 1, args2, &kwargs); + } + return dict_out; +} + +static mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_dict_t *self = ((void*)self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0); + case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(self->map.used)) << 1) | 1)); + + + + + + + default: return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_dict_t *o = ((void*)lhs_in); + switch (op) { + case MP_BINARY_OP_IN: { + mp_map_elem_t *elem = mp_map_lookup(&o->map, rhs_in, MP_MAP_LOOKUP); + return mp_obj_new_bool(elem != +# 123 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 123 "user/mpy/py/objdict.c" + ); + } + case MP_BINARY_OP_EQUAL: { +# 140 "user/mpy/py/objdict.c" + if ((MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_dict)))) { + mp_obj_dict_t *rhs = ((void*)rhs_in); + if (o->map.used != rhs->map.used) { + return (((mp_obj_t)&mp_const_false_obj)); + } + + size_t cur = 0; + mp_map_elem_t *next = +# 147 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 147 "user/mpy/py/objdict.c" + ; + while ((next = dict_iter_next(o, &cur)) != +# 148 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 148 "user/mpy/py/objdict.c" + ) { + mp_map_elem_t *elem = mp_map_lookup(&rhs->map, next->key, MP_MAP_LOOKUP); + if (elem == +# 150 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 150 "user/mpy/py/objdict.c" + || !mp_obj_equal(next->value, elem->value)) { + return (((mp_obj_t)&mp_const_false_obj)); + } + } + return (((mp_obj_t)&mp_const_true_obj)); + } else { + + return (((mp_obj_t)&mp_const_false_obj)); + } + } + default: + + return (((mp_obj_t)(void*)0)); + } +} + + +mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { + mp_obj_dict_t *self = ((void*)self_in); + mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); + if (elem == +# 170 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 170 "user/mpy/py/objdict.c" + ) { + nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, index))); + } else { + return elem->value; + } +} + +static mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == (((mp_obj_t)(void*)0))) { + + mp_obj_dict_delete(self_in, index); + return (((mp_obj_t)&mp_const_none_obj)); + } else if (value == (((mp_obj_t)(void*)8))) { + + mp_obj_dict_t *self = ((void*)self_in); + mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); + if (elem == +# 186 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 186 "user/mpy/py/objdict.c" + ) { + nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, index))); + } else { + return elem->value; + } + } else { + + mp_obj_dict_store(self_in, index, value); + return (((mp_obj_t)&mp_const_none_obj)); + } +} + + + + +typedef struct _mp_obj_dict_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t dict; + size_t cur; +} mp_obj_dict_it_t; + +static mp_obj_t dict_it_iternext(mp_obj_t self_in) { + mp_obj_dict_it_t *self = ((void*)self_in); + mp_map_elem_t *next = dict_iter_next(((void*)self->dict), &self->cur); + + if (next == +# 212 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 212 "user/mpy/py/objdict.c" + ) { + return (((mp_obj_t)(void*)4)); + } else { + return next->key; + } +} + +static mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { + +# 220 "user/mpy/py/objdict.c" 3 + (( +# 220 "user/mpy/py/objdict.c" + sizeof(mp_obj_dict_it_t) <= sizeof(mp_obj_iter_buf_t) +# 220 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 220, __func__, +# 220 "user/mpy/py/objdict.c" + "sizeof(mp_obj_dict_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 220 "user/mpy/py/objdict.c" 3 + )) +# 220 "user/mpy/py/objdict.c" + ; + mp_obj_dict_it_t *o = (mp_obj_dict_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = dict_it_iternext; + o->dict = self_in; + o->cur = 0; + return ((mp_obj_t)o); +} + + + + +static mp_obj_t dict_clear(mp_obj_t self_in) { + +# 233 "user/mpy/py/objdict.c" 3 + (( +# 233 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) +# 233 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 233, __func__, +# 233 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" +# 233 "user/mpy/py/objdict.c" 3 + )) +# 233 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)self_in); + + mp_map_clear(&self->map); + + return (((mp_obj_t)&mp_const_none_obj)); +} +static const mp_obj_fun_builtin_fixed_t dict_clear_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_clear}; + +static mp_obj_t dict_copy(mp_obj_t self_in) { + +# 243 "user/mpy/py/objdict.c" 3 + (( +# 243 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) +# 243 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 243, __func__, +# 243 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" +# 243 "user/mpy/py/objdict.c" 3 + )) +# 243 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)self_in); + mp_obj_t other_out = mp_obj_new_dict(self->map.alloc); + mp_obj_dict_t *other = ((void*)other_out); + other->base.type = self->base.type; + other->map.used = self->map.used; + other->map.all_keys_are_qstrs = self->map.all_keys_are_qstrs; + other->map.is_fixed = 0; + other->map.is_ordered = self->map.is_ordered; + memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t)); + return other_out; +} +static const mp_obj_fun_builtin_fixed_t dict_copy_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_copy}; + + +static mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) { + mp_obj_t iter = mp_getiter(args[1], +# 259 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 259 "user/mpy/py/objdict.c" + ); + mp_obj_t value = (((mp_obj_t)&mp_const_none_obj)); + mp_obj_t next = (((mp_obj_t)(void*)0)); + + if (n_args > 2) { + value = args[2]; + } + + + mp_obj_t self_out; + mp_obj_t len = mp_obj_len_maybe(args[1]); + if (len == (((mp_obj_t)(void*)0))) { + + self_out = mp_obj_new_dict(0); + } else { + self_out = mp_obj_new_dict((((mp_int_t)(len)) >> 1)); + } + + mp_obj_dict_t *self = ((void*)self_out); + while ((next = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { + mp_map_lookup(&self->map, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + } + + return self_out; +} +static const mp_obj_fun_builtin_var_t dict_fromkeys_fun_obj = {{&mp_type_fun_builtin_var}, +# 284 "user/mpy/py/objdict.c" 3 4 + 0 +# 284 "user/mpy/py/objdict.c" + , 2, 3, .fun.var = dict_fromkeys}; +static const mp_rom_obj_static_class_method_t dict_fromkeys_obj = {{&mp_type_classmethod}, (&dict_fromkeys_fun_obj)}; + +static mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) { + +# 288 "user/mpy/py/objdict.c" 3 + (( +# 288 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new) +# 288 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 288, __func__, +# 288 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new)" +# 288 "user/mpy/py/objdict.c" 3 + )) +# 288 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)args[0]); + mp_map_elem_t *elem = mp_map_lookup(&self->map, args[1], lookup_kind); + mp_obj_t value; + if (elem == +# 292 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 292 "user/mpy/py/objdict.c" + || elem->value == (((mp_obj_t)(void*)0))) { + if (n_args == 2) { + if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, args[1]))); + } else { + value = (((mp_obj_t)&mp_const_none_obj)); + } + } else { + value = args[2]; + } + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + elem->value = value; + } + } else { + value = elem->value; + if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + elem->value = (((mp_obj_t)(void*)0)); + } + } + return value; +} + +static mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) { + return dict_get_helper(n_args, args, MP_MAP_LOOKUP); +} +static const mp_obj_fun_builtin_var_t dict_get_obj = {{&mp_type_fun_builtin_var}, +# 317 "user/mpy/py/objdict.c" 3 4 + 0 +# 317 "user/mpy/py/objdict.c" + , 2, 3, .fun.var = dict_get}; + +static mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) { + return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); +} +static const mp_obj_fun_builtin_var_t dict_pop_obj = {{&mp_type_fun_builtin_var}, +# 322 "user/mpy/py/objdict.c" 3 4 + 0 +# 322 "user/mpy/py/objdict.c" + , 2, 3, .fun.var = dict_pop}; + +static mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) { + return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); +} +static const mp_obj_fun_builtin_var_t dict_setdefault_obj = {{&mp_type_fun_builtin_var}, +# 327 "user/mpy/py/objdict.c" 3 4 + 0 +# 327 "user/mpy/py/objdict.c" + , 2, 3, .fun.var = dict_setdefault}; + +static mp_obj_t dict_popitem(mp_obj_t self_in) { + +# 330 "user/mpy/py/objdict.c" 3 + (( +# 330 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) +# 330 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 330, __func__, +# 330 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" +# 330 "user/mpy/py/objdict.c" 3 + )) +# 330 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)self_in); + size_t cur = 0; + mp_map_elem_t *next = dict_iter_next(self, &cur); + if (next == +# 334 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 334 "user/mpy/py/objdict.c" + ) { + mp_raise_msg(&mp_type_KeyError, "popitem(): dictionary is empty"); + } + self->map.used--; + mp_obj_t items[] = {next->key, next->value}; + next->key = (((mp_obj_t)(void*)8)); + next->value = (((mp_obj_t)(void*)0)); + mp_obj_t tuple = mp_obj_new_tuple(2, items); + + return tuple; +} +static const mp_obj_fun_builtin_fixed_t dict_popitem_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_popitem}; + +static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + +# 348 "user/mpy/py/objdict.c" 3 + (( +# 348 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new) +# 348 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 348, __func__, +# 348 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new)" +# 348 "user/mpy/py/objdict.c" 3 + )) +# 348 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)args[0]); + + mp_arg_check_num(n_args, kwargs->used, 1, 2, +# 351 "user/mpy/py/objdict.c" 3 4 + 1 +# 351 "user/mpy/py/objdict.c" + ); + + if (n_args == 2) { + + + if ((MP_OBJ_IS_OBJ(args[1]) && ((mp_obj_base_t*)((void*)args[1]))->type->make_new == dict_make_new)) { + + if (args[1] != args[0]) { + size_t cur = 0; + mp_map_elem_t *elem = +# 360 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 360 "user/mpy/py/objdict.c" + ; + while ((elem = dict_iter_next((mp_obj_dict_t*)((void*)args[1]), &cur)) != +# 361 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 361 "user/mpy/py/objdict.c" + ) { + mp_map_lookup(&self->map, elem->key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = elem->value; + } + } + } else { + + mp_obj_t iter = mp_getiter(args[1], +# 367 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 367 "user/mpy/py/objdict.c" + ); + mp_obj_t next = (((mp_obj_t)(void*)0)); + while ((next = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { + mp_obj_t inneriter = mp_getiter(next, +# 370 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 370 "user/mpy/py/objdict.c" + ); + mp_obj_t key = mp_iternext(inneriter); + mp_obj_t value = mp_iternext(inneriter); + mp_obj_t stop = mp_iternext(inneriter); + if (key == (((mp_obj_t)(void*)4)) + || value == (((mp_obj_t)(void*)4)) + || stop != (((mp_obj_t)(void*)4))) { + mp_raise_ValueError("dict update sequence has wrong length"); + } else { + mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + } + } + } + } + + + for (size_t i = 0; i < kwargs->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) { + mp_map_lookup(&self->map, kwargs->table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = kwargs->table[i].value; + } + } + + return (((mp_obj_t)&mp_const_none_obj)); +} +static const mp_obj_fun_builtin_var_t dict_update_obj = {{&mp_type_fun_builtin_var}, +# 394 "user/mpy/py/objdict.c" 3 4 + 1 +# 394 "user/mpy/py/objdict.c" + , 1, (0xffff), .fun.kw = dict_update}; + + + + + +static const mp_obj_type_t dict_view_type; +static const mp_obj_type_t dict_view_it_type; + +typedef enum _mp_dict_view_kind_t { + MP_DICT_VIEW_ITEMS, + MP_DICT_VIEW_KEYS, + MP_DICT_VIEW_VALUES, +} mp_dict_view_kind_t; + +static const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"}; + +typedef struct _mp_obj_dict_view_it_t { + mp_obj_base_t base; + mp_dict_view_kind_t kind; + mp_obj_t dict; + size_t cur; +} mp_obj_dict_view_it_t; + +typedef struct _mp_obj_dict_view_t { + mp_obj_base_t base; + mp_obj_t dict; + mp_dict_view_kind_t kind; +} mp_obj_dict_view_t; + +static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) { + +# 425 "user/mpy/py/objdict.c" 3 + (( +# 425 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_it_type))) +# 425 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 425, __func__, +# 425 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_it_type)))" +# 425 "user/mpy/py/objdict.c" 3 + )) +# 425 "user/mpy/py/objdict.c" + ; + mp_obj_dict_view_it_t *self = ((void*)self_in); + mp_map_elem_t *next = dict_iter_next(((void*)self->dict), &self->cur); + + if (next == +# 429 "user/mpy/py/objdict.c" 3 4 + ((void *)0) +# 429 "user/mpy/py/objdict.c" + ) { + return (((mp_obj_t)(void*)4)); + } else { + switch (self->kind) { + case MP_DICT_VIEW_ITEMS: + default: { + mp_obj_t items[] = {next->key, next->value}; + return mp_obj_new_tuple(2, items); + } + case MP_DICT_VIEW_KEYS: + return next->key; + case MP_DICT_VIEW_VALUES: + return next->value; + } + } +} + +static const mp_obj_type_t dict_view_it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = dict_view_it_iternext, +}; + +static mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) { + +# 454 "user/mpy/py/objdict.c" 3 + (( +# 454 "user/mpy/py/objdict.c" + sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t) +# 454 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 454, __func__, +# 454 "user/mpy/py/objdict.c" + "sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 454 "user/mpy/py/objdict.c" 3 + )) +# 454 "user/mpy/py/objdict.c" + ; + +# 455 "user/mpy/py/objdict.c" 3 + (( +# 455 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(view_in) && (((mp_obj_base_t*)((void*)view_in))->type == (&dict_view_type))) +# 455 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 455, __func__, +# 455 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(view_in) && (((mp_obj_base_t*)((void*)view_in))->type == (&dict_view_type)))" +# 455 "user/mpy/py/objdict.c" 3 + )) +# 455 "user/mpy/py/objdict.c" + ; + mp_obj_dict_view_t *view = ((void*)view_in); + mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t*)iter_buf; + o->base.type = &dict_view_it_type; + o->kind = view->kind; + o->dict = view->dict; + o->cur = 0; + return ((mp_obj_t)o); +} + +static void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + +# 467 "user/mpy/py/objdict.c" 3 + (( +# 467 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_type))) +# 467 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 467, __func__, +# 467 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_type)))" +# 467 "user/mpy/py/objdict.c" 3 + )) +# 467 "user/mpy/py/objdict.c" + ; + mp_obj_dict_view_t *self = ((void*)self_in); + +# 469 "user/mpy/py/objdict.c" 3 4 + _Bool +# 469 "user/mpy/py/objdict.c" + first = +# 469 "user/mpy/py/objdict.c" 3 4 + 1 +# 469 "user/mpy/py/objdict.c" + ; + mp_print_str(print, mp_dict_view_names[self->kind]); + mp_print_str(print, "(["); + mp_obj_iter_buf_t iter_buf; + mp_obj_t self_iter = dict_view_getiter(self_in, &iter_buf); + mp_obj_t next = (((mp_obj_t)(void*)0)); + while ((next = dict_view_it_iternext(self_iter)) != (((mp_obj_t)(void*)4))) { + if (!first) { + mp_print_str(print, ", "); + } + first = +# 479 "user/mpy/py/objdict.c" 3 4 + 0 +# 479 "user/mpy/py/objdict.c" + ; + mp_obj_print_helper(print, next, PRINT_REPR); + } + mp_print_str(print, "])"); +} + +static mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + + mp_obj_dict_view_t *o = ((void*)lhs_in); + if (o->kind != MP_DICT_VIEW_KEYS) { + return (((mp_obj_t)(void*)0)); + } + if (op != MP_BINARY_OP_IN) { + return (((mp_obj_t)(void*)0)); + } + return dict_binary_op(op, o->dict, rhs_in); +} + +static const mp_obj_type_t dict_view_type = { + { &mp_type_type }, + .name = MP_QSTR_dict_view, + .print = dict_view_print, + .binary_op = dict_view_binary_op, + .getiter = dict_view_getiter, +}; + +static mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) { + mp_obj_dict_view_t *o = (((mp_obj_dict_view_t*)(m_malloc(sizeof(mp_obj_dict_view_t) * (1))))); + o->base.type = &dict_view_type; + o->dict = dict; + o->kind = kind; + return ((mp_obj_t)o); +} + +static mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) { + +# 514 "user/mpy/py/objdict.c" 3 + (( +# 514 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) +# 514 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 514, __func__, +# 514 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" +# 514 "user/mpy/py/objdict.c" 3 + )) +# 514 "user/mpy/py/objdict.c" + ; + return mp_obj_new_dict_view(self_in, kind); +} + +static mp_obj_t dict_items(mp_obj_t self_in) { + return dict_view(self_in, MP_DICT_VIEW_ITEMS); +} +static const mp_obj_fun_builtin_fixed_t dict_items_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_items}; + +static mp_obj_t dict_keys(mp_obj_t self_in) { + return dict_view(self_in, MP_DICT_VIEW_KEYS); +} +static const mp_obj_fun_builtin_fixed_t dict_keys_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_keys}; + +static mp_obj_t dict_values(mp_obj_t self_in) { + return dict_view(self_in, MP_DICT_VIEW_VALUES); +} +static const mp_obj_fun_builtin_fixed_t dict_values_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_values}; + + + + +static const mp_rom_map_elem_t dict_locals_dict_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_clear)) << 2) | 2)), (&dict_clear_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_copy)) << 2) | 2)), (&dict_copy_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_fromkeys)) << 2) | 2)), (&dict_fromkeys_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_get)) << 2) | 2)), (&dict_get_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_items)) << 2) | 2)), (&dict_items_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_keys)) << 2) | 2)), (&dict_keys_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_pop)) << 2) | 2)), (&dict_pop_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_popitem)) << 2) | 2)), (&dict_popitem_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_setdefault)) << 2) | 2)), (&dict_setdefault_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_update)) << 2) | 2)), (&dict_update_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_values)) << 2) | 2)), (&dict_values_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___getitem__)) << 2) | 2)), (&mp_op_getitem_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___setitem__)) << 2) | 2)), (&mp_op_setitem_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___delitem__)) << 2) | 2)), (&mp_op_delitem_obj) }, +}; + +static const mp_obj_dict_t dict_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(dict_locals_dict_table) / sizeof((dict_locals_dict_table)[0])), .alloc = (sizeof(dict_locals_dict_table) / sizeof((dict_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)dict_locals_dict_table, }, }; + +const mp_obj_type_t mp_type_dict = { + { &mp_type_type }, + .name = MP_QSTR_dict, + .print = dict_print, + .make_new = dict_make_new, + .unary_op = dict_unary_op, + .binary_op = dict_binary_op, + .subscr = dict_subscr, + .getiter = dict_getiter, + .locals_dict = (mp_obj_dict_t*)&dict_locals_dict, +}; +# 582 "user/mpy/py/objdict.c" +void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args) { + dict->base.type = &mp_type_dict; + mp_map_init(&dict->map, n_args); +} + +mp_obj_t mp_obj_new_dict(size_t n_args) { + mp_obj_dict_t *o = (((mp_obj_dict_t*)(m_malloc(sizeof(mp_obj_dict_t) * (1))))); + mp_obj_dict_init(o, n_args); + return ((mp_obj_t)o); +} + +size_t mp_obj_dict_len(mp_obj_t self_in) { + mp_obj_dict_t *self = ((void*)self_in); + return self->map.used; +} + +mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) { + +# 599 "user/mpy/py/objdict.c" 3 + (( +# 599 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) +# 599 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 599, __func__, +# 599 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" +# 599 "user/mpy/py/objdict.c" 3 + )) +# 599 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)self_in); + mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + return self_in; +} + +mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key) { + mp_obj_t args[2] = {self_in, key}; + dict_get_helper(2, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); + return self_in; +} + +mp_map_t *mp_obj_dict_get_map(mp_obj_t self_in) { + +# 612 "user/mpy/py/objdict.c" 3 + (( +# 612 "user/mpy/py/objdict.c" + (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) +# 612 "user/mpy/py/objdict.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 612, __func__, +# 612 "user/mpy/py/objdict.c" + "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" +# 612 "user/mpy/py/objdict.c" 3 + )) +# 612 "user/mpy/py/objdict.c" + ; + mp_obj_dict_t *self = ((void*)self_in); + return &self->map; +} +# 1 "user/mpy/py/objenumerate.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objenumerate.c" +# 27 "user/mpy/py/objenumerate.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objenumerate.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objenumerate.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objenumerate.c" 2 +# 1 "user/mpy/py/objexcept.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objexcept.c" +# 27 "user/mpy/py/objexcept.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objexcept.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 29 "user/mpy/py/objexcept.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objexcept.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 61 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 31 "user/mpy/py/objexcept.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 33 "user/mpy/py/objexcept.c" 2 + +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 35 "user/mpy/py/objexcept.c" 2 + +# 1 "user/mpy/py/objtype.h" 1 +# 33 "user/mpy/py/objtype.h" +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 37 "user/mpy/py/objexcept.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 38 "user/mpy/py/objexcept.c" 2 +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 39 "user/mpy/py/objexcept.c" 2 +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 40 "user/mpy/py/objexcept.c" 2 + + + +# 42 "user/mpy/py/objexcept.c" +const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, 0, 0, +# 42 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 42 "user/mpy/py/objexcept.c" + , (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; +# 92 "user/mpy/py/objexcept.c" +const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, +# 92 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 92 "user/mpy/py/objexcept.c" + , (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; + +static void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_exception_t *o = ((void*)o_in); + mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; + +# 97 "user/mpy/py/objexcept.c" 3 4 + _Bool +# 97 "user/mpy/py/objexcept.c" + is_subclass = kind & PRINT_EXC_SUBCLASS; + if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) { + mp_print_str(print, qstr_str(o->base.type->name)); + } + + if (k == PRINT_EXC) { + mp_print_str(print, ": "); + } + + if (k == PRINT_STR || k == PRINT_EXC) { + if (o->args == +# 107 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 107 "user/mpy/py/objexcept.c" + || o->args->len == 0) { + mp_print_str(print, ""); + return; + } else if (o->args->len == 1) { +# 121 "user/mpy/py/objexcept.c" + mp_obj_print_helper(print, o->args->items[0], PRINT_STR); + return; + } + } + mp_obj_tuple_print(print, ((mp_obj_t)o->args), kind); +} + +mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, (0xffff), +# 129 "user/mpy/py/objexcept.c" 3 4 + 0 +# 129 "user/mpy/py/objexcept.c" + ); + mp_obj_exception_t *o = ((mp_obj_exception_t*)m_malloc_maybe(sizeof(mp_obj_exception_t) + sizeof(mp_obj_t) * (0))); + if (o == +# 131 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 131 "user/mpy/py/objexcept.c" + ) { + + o = &(mp_state_ctx.vm.mp_emergency_exception_obj); + + o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; + } else { + o->args = ((void*)mp_obj_new_tuple(n_args, args)); + } + o->base.type = type; + o->traceback_data = +# 140 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 140 "user/mpy/py/objexcept.c" + ; + return ((mp_obj_t)o); +} + + +mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) { + mp_obj_exception_t *self = ((void*)self_in); + if (self->args->len == 0) { + return (((mp_obj_t)&mp_const_none_obj)); + } else { + return self->args->items[0]; + } +} + +static void exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + mp_obj_exception_t *self = ((void*)self_in); + if (dest[0] != (((mp_obj_t)(void*)0))) { + + if (attr == MP_QSTR___traceback__ && dest[1] == (((mp_obj_t)&mp_const_none_obj))) { + + + + + + + self->traceback_len = 0; + dest[0] = (((mp_obj_t)(void*)0)); + } + return; + } + if (attr == MP_QSTR_args) { + dest[0] = ((mp_obj_t)self->args); + } else if (self->base.type == &mp_type_StopIteration && attr == MP_QSTR_value) { + dest[0] = mp_obj_exception_get_value(self_in); + } +} + +static mp_obj_t exc___init__(size_t n_args, const mp_obj_t *args) { + mp_obj_exception_t *self = ((void*)args[0]); + mp_obj_t argst = mp_obj_new_tuple(n_args - 1, args + 1); + self->args = ((void*)argst); + return (((mp_obj_t)&mp_const_none_obj)); +} +static const mp_obj_fun_builtin_var_t exc___init___obj = {{&mp_type_fun_builtin_var}, +# 183 "user/mpy/py/objexcept.c" 3 4 + 0 +# 183 "user/mpy/py/objexcept.c" + , 1, (0xffff), .fun.var = exc___init__}; + +static const mp_rom_map_elem_t exc_locals_dict_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___init__)) << 2) | 2)), (&exc___init___obj) }, +}; + +static const mp_obj_dict_t exc_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(exc_locals_dict_table) / sizeof((exc_locals_dict_table)[0])), .alloc = (sizeof(exc_locals_dict_table) / sizeof((exc_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)exc_locals_dict_table, }, }; + +const mp_obj_type_t mp_type_BaseException = { + { &mp_type_type }, + .name = MP_QSTR_BaseException, + .print = mp_obj_exception_print, + .make_new = mp_obj_exception_make_new, + .attr = exception_attr, + .locals_dict = (mp_obj_dict_t*)&exc_locals_dict, +}; +# 212 "user/mpy/py/objexcept.c" +const mp_obj_type_t mp_type_SystemExit = { { &mp_type_type }, .name = MP_QSTR_SystemExit, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; +const mp_obj_type_t mp_type_KeyboardInterrupt = { { &mp_type_type }, .name = MP_QSTR_KeyboardInterrupt, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; +const mp_obj_type_t mp_type_GeneratorExit = { { &mp_type_type }, .name = MP_QSTR_GeneratorExit, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; +const mp_obj_type_t mp_type_Exception = { { &mp_type_type }, .name = MP_QSTR_Exception, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; + + + + const mp_obj_type_t mp_type_StopIteration = { { &mp_type_type }, .name = MP_QSTR_StopIteration, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_ArithmeticError = { { &mp_type_type }, .name = MP_QSTR_ArithmeticError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + + const mp_obj_type_t mp_type_OverflowError = { { &mp_type_type }, .name = MP_QSTR_OverflowError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_ArithmeticError, }; + const mp_obj_type_t mp_type_ZeroDivisionError = { { &mp_type_type }, .name = MP_QSTR_ZeroDivisionError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_ArithmeticError, }; + const mp_obj_type_t mp_type_AssertionError = { { &mp_type_type }, .name = MP_QSTR_AssertionError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_AttributeError = { { &mp_type_type }, .name = MP_QSTR_AttributeError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + + + const mp_obj_type_t mp_type_EOFError = { { &mp_type_type }, .name = MP_QSTR_EOFError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_ImportError = { { &mp_type_type }, .name = MP_QSTR_ImportError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + + const mp_obj_type_t mp_type_LookupError = { { &mp_type_type }, .name = MP_QSTR_LookupError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_IndexError = { { &mp_type_type }, .name = MP_QSTR_IndexError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_LookupError, }; + const mp_obj_type_t mp_type_KeyError = { { &mp_type_type }, .name = MP_QSTR_KeyError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_LookupError, }; + const mp_obj_type_t mp_type_MemoryError = { { &mp_type_type }, .name = MP_QSTR_MemoryError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_NameError = { { &mp_type_type }, .name = MP_QSTR_NameError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + + + + const mp_obj_type_t mp_type_OSError = { { &mp_type_type }, .name = MP_QSTR_OSError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; +# 260 "user/mpy/py/objexcept.c" + const mp_obj_type_t mp_type_RuntimeError = { { &mp_type_type }, .name = MP_QSTR_RuntimeError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_NotImplementedError = { { &mp_type_type }, .name = MP_QSTR_NotImplementedError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_RuntimeError, }; + const mp_obj_type_t mp_type_SyntaxError = { { &mp_type_type }, .name = MP_QSTR_SyntaxError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + const mp_obj_type_t mp_type_IndentationError = { { &mp_type_type }, .name = MP_QSTR_IndentationError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_SyntaxError, }; + + + + + const mp_obj_type_t mp_type_TypeError = { { &mp_type_type }, .name = MP_QSTR_TypeError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; + + + + const mp_obj_type_t mp_type_ValueError = { { &mp_type_type }, .name = MP_QSTR_ValueError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; +# 291 "user/mpy/py/objexcept.c" +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) { + return mp_obj_new_exception_args(exc_type, 0, +# 292 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 292 "user/mpy/py/objexcept.c" + ); +} + + +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { + return mp_obj_new_exception_args(exc_type, 1, &arg); +} + +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args) { + +# 301 "user/mpy/py/objexcept.c" 3 + (( +# 301 "user/mpy/py/objexcept.c" + exc_type->make_new == mp_obj_exception_make_new +# 301 "user/mpy/py/objexcept.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 301, __func__, +# 301 "user/mpy/py/objexcept.c" + "exc_type->make_new == mp_obj_exception_make_new" +# 301 "user/mpy/py/objexcept.c" 3 + )) +# 301 "user/mpy/py/objexcept.c" + ; + return exc_type->make_new(exc_type, n_args, 0, args); +} + +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg) { + return mp_obj_new_exception_msg_varg(exc_type, msg); +} + +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...) { + + +# 311 "user/mpy/py/objexcept.c" 3 + (( +# 311 "user/mpy/py/objexcept.c" + exc_type->make_new == mp_obj_exception_make_new +# 311 "user/mpy/py/objexcept.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 311, __func__, +# 311 "user/mpy/py/objexcept.c" + "exc_type->make_new == mp_obj_exception_make_new" +# 311 "user/mpy/py/objexcept.c" 3 + )) +# 311 "user/mpy/py/objexcept.c" + ; + + + mp_obj_exception_t *o = ((mp_obj_exception_t*)m_malloc_maybe(sizeof(mp_obj_exception_t) + sizeof(mp_obj_t) * (0))); + if (o == +# 315 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 315 "user/mpy/py/objexcept.c" + ) { + + + o = &(mp_state_ctx.vm.mp_emergency_exception_obj); + o->base.type = exc_type; + o->traceback_data = +# 320 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 320 "user/mpy/py/objexcept.c" + ; + o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; +# 366 "user/mpy/py/objexcept.c" + } else { + o->base.type = exc_type; + o->traceback_data = +# 368 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 368 "user/mpy/py/objexcept.c" + ; + o->args = ((void*)mp_obj_new_tuple(1, +# 369 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 369 "user/mpy/py/objexcept.c" + )); + + +# 371 "user/mpy/py/objexcept.c" 3 + (( +# 371 "user/mpy/py/objexcept.c" + fmt != +# 371 "user/mpy/py/objexcept.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 371, __func__, +# 371 "user/mpy/py/objexcept.c" + "fmt != NULL" +# 371 "user/mpy/py/objexcept.c" 3 + )) +# 371 "user/mpy/py/objexcept.c" + ; + { + if (strchr(fmt, '%') == +# 373 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 373 "user/mpy/py/objexcept.c" + ) { + + o->args->items[0] = mp_obj_new_str(fmt, strlen(fmt), +# 375 "user/mpy/py/objexcept.c" 3 4 + 0 +# 375 "user/mpy/py/objexcept.c" + ); + } else { + + va_list ap; + vstr_t vstr; + vstr_init(&vstr, 16); + +# 381 "user/mpy/py/objexcept.c" 3 4 + __builtin_va_start( +# 381 "user/mpy/py/objexcept.c" + ap +# 381 "user/mpy/py/objexcept.c" 3 4 + , +# 381 "user/mpy/py/objexcept.c" + fmt +# 381 "user/mpy/py/objexcept.c" 3 4 + ) +# 381 "user/mpy/py/objexcept.c" + ; + vstr_vprintf(&vstr, fmt, ap); + +# 383 "user/mpy/py/objexcept.c" 3 4 + __builtin_va_end( +# 383 "user/mpy/py/objexcept.c" + ap +# 383 "user/mpy/py/objexcept.c" 3 4 + ) +# 383 "user/mpy/py/objexcept.c" + ; + o->args->items[0] = mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + } + } + } + + return ((mp_obj_t)o); +} + + + +# 393 "user/mpy/py/objexcept.c" 3 4 +_Bool +# 393 "user/mpy/py/objexcept.c" + mp_obj_is_exception_type(mp_obj_t self_in) { + if ((MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_type)))) { + + mp_obj_type_t *self = ((void*)self_in); + if (self->make_new == mp_obj_exception_make_new) { + return +# 398 "user/mpy/py/objexcept.c" 3 4 + 1 +# 398 "user/mpy/py/objexcept.c" + ; + } + } + return mp_obj_is_subclass_fast(self_in, ((mp_obj_t)&mp_type_BaseException)); +} + + + +# 405 "user/mpy/py/objexcept.c" 3 4 +_Bool +# 405 "user/mpy/py/objexcept.c" + mp_obj_is_exception_instance(mp_obj_t self_in) { + return mp_obj_is_exception_type(((mp_obj_t)mp_obj_get_type(self_in))); +} + + + + + +# 412 "user/mpy/py/objexcept.c" 3 4 +_Bool +# 412 "user/mpy/py/objexcept.c" + mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { + + if (mp_obj_is_exception_instance(exc)) { + exc = ((mp_obj_t)mp_obj_get_type(exc)); + } + return mp_obj_is_subclass_fast(exc, exc_type); +} +# 432 "user/mpy/py/objexcept.c" +void mp_obj_exception_clear_traceback(mp_obj_t self_in) { + +# 433 "user/mpy/py/objexcept.c" 3 + (( +# 433 "user/mpy/py/objexcept.c" + mp_obj_is_exception_instance(self_in) +# 433 "user/mpy/py/objexcept.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 433, __func__, +# 433 "user/mpy/py/objexcept.c" + "mp_obj_is_exception_instance(self_in)" +# 433 "user/mpy/py/objexcept.c" 3 + )) +# 433 "user/mpy/py/objexcept.c" + ; mp_obj_exception_t *self; if ((mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new)) { self = ((void*)self_in); } else { self = ((void*)((mp_obj_instance_t*)((void*)self_in))->subobj[0]); }; + + + self->traceback_data = +# 436 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 436 "user/mpy/py/objexcept.c" + ; +} + +void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { + +# 440 "user/mpy/py/objexcept.c" 3 + (( +# 440 "user/mpy/py/objexcept.c" + mp_obj_is_exception_instance(self_in) +# 440 "user/mpy/py/objexcept.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 440, __func__, +# 440 "user/mpy/py/objexcept.c" + "mp_obj_is_exception_instance(self_in)" +# 440 "user/mpy/py/objexcept.c" 3 + )) +# 440 "user/mpy/py/objexcept.c" + ; mp_obj_exception_t *self; if ((mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new)) { self = ((void*)self_in); } else { self = ((void*)((mp_obj_instance_t*)((void*)self_in))->subobj[0]); }; + + + + + if (self->traceback_data == +# 445 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 445 "user/mpy/py/objexcept.c" + ) { + self->traceback_data = ((size_t*)(m_malloc_maybe(sizeof(size_t) * (3)))); + if (self->traceback_data == +# 447 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 447 "user/mpy/py/objexcept.c" + ) { + return; + } + self->traceback_alloc = 3; + self->traceback_len = 0; + } else if (self->traceback_len + 3 > self->traceback_alloc) { + + size_t *tb_data = ((size_t*)(m_realloc_maybe((self->traceback_data), sizeof(size_t) * (self->traceback_alloc + 3), ( +# 454 "user/mpy/py/objexcept.c" 3 4 + 1 +# 454 "user/mpy/py/objexcept.c" + )))); + if (tb_data == +# 455 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 455 "user/mpy/py/objexcept.c" + ) { + return; + } + self->traceback_data = tb_data; + self->traceback_alloc += 3; + } + + size_t *tb_data = &self->traceback_data[self->traceback_len]; + self->traceback_len += 3; + tb_data[0] = file; + tb_data[1] = line; + tb_data[2] = block; +} + +void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values) { + +# 470 "user/mpy/py/objexcept.c" 3 + (( +# 470 "user/mpy/py/objexcept.c" + mp_obj_is_exception_instance(self_in) +# 470 "user/mpy/py/objexcept.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 470, __func__, +# 470 "user/mpy/py/objexcept.c" + "mp_obj_is_exception_instance(self_in)" +# 470 "user/mpy/py/objexcept.c" 3 + )) +# 470 "user/mpy/py/objexcept.c" + ; mp_obj_exception_t *self; if ((mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new)) { self = ((void*)self_in); } else { self = ((void*)((mp_obj_instance_t*)((void*)self_in))->subobj[0]); }; + + if (self->traceback_data == +# 472 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 472 "user/mpy/py/objexcept.c" + ) { + *n = 0; + *values = +# 474 "user/mpy/py/objexcept.c" 3 4 + ((void *)0) +# 474 "user/mpy/py/objexcept.c" + ; + } else { + *n = self->traceback_len; + *values = self->traceback_data; + } +} +# 1 "user/mpy/py/objfilter.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objfilter.c" +# 27 "user/mpy/py/objfilter.c" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 28 "user/mpy/py/objfilter.c" 2 +# 1 "user/mpy/py/objfloat.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objfloat.c" +# 27 "user/mpy/py/objfloat.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objfloat.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 61 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/objfloat.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/objfloat.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/objfloat.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 33 "user/mpy/py/objfloat.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 32 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 34 "user/mpy/py/objfloat.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/objfloat.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 36 "user/mpy/py/objfloat.c" 2 +# 1 "user/mpy/py/objfun.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objfun.c" +# 28 "user/mpy/py/objfun.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/objfun.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objfun.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objfun.c" 2 +# 1 "user/mpy/py/objtuple.h" 1 +# 29 "user/mpy/py/objtuple.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtuple.h" 2 + +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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 33 "user/mpy/py/objfun.c" 2 +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 34 "user/mpy/py/objfun.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/objfun.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 32 "user/mpy/py/objexcept.h" +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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 36 "user/mpy/py/objfun.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 37 "user/mpy/py/objfun.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 38 "user/mpy/py/objfun.c" 2 +# 53 "user/mpy/py/objfun.c" +static mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)args; + +# 55 "user/mpy/py/objfun.c" 3 + (( +# 55 "user/mpy/py/objfun.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_0))) +# 55 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 55, __func__, +# 55 "user/mpy/py/objfun.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_0)" +# 55 "user/mpy/py/objfun.c" 3 + )) +# 55 "user/mpy/py/objfun.c" + ; + mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); + mp_arg_check_num(n_args, n_kw, 0, 0, +# 57 "user/mpy/py/objfun.c" 3 4 + 0 +# 57 "user/mpy/py/objfun.c" + ); + return self->fun._0(); +} + +const mp_obj_type_t mp_type_fun_builtin_0 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_0_call, + .unary_op = mp_generic_unary_op, +}; + +static mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + +# 69 "user/mpy/py/objfun.c" 3 + (( +# 69 "user/mpy/py/objfun.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_1))) +# 69 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 69, __func__, +# 69 "user/mpy/py/objfun.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_1)" +# 69 "user/mpy/py/objfun.c" 3 + )) +# 69 "user/mpy/py/objfun.c" + ; + mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); + mp_arg_check_num(n_args, n_kw, 1, 1, +# 71 "user/mpy/py/objfun.c" 3 4 + 0 +# 71 "user/mpy/py/objfun.c" + ); + return self->fun._1(args[0]); +} + +const mp_obj_type_t mp_type_fun_builtin_1 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_1_call, + .unary_op = mp_generic_unary_op, +}; + +static mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + +# 83 "user/mpy/py/objfun.c" 3 + (( +# 83 "user/mpy/py/objfun.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_2))) +# 83 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 83, __func__, +# 83 "user/mpy/py/objfun.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_2)" +# 83 "user/mpy/py/objfun.c" 3 + )) +# 83 "user/mpy/py/objfun.c" + ; + mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); + mp_arg_check_num(n_args, n_kw, 2, 2, +# 85 "user/mpy/py/objfun.c" 3 4 + 0 +# 85 "user/mpy/py/objfun.c" + ); + return self->fun._2(args[0], args[1]); +} + +const mp_obj_type_t mp_type_fun_builtin_2 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_2_call, + .unary_op = mp_generic_unary_op, +}; + +static mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + +# 97 "user/mpy/py/objfun.c" 3 + (( +# 97 "user/mpy/py/objfun.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_3))) +# 97 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 97, __func__, +# 97 "user/mpy/py/objfun.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_3)" +# 97 "user/mpy/py/objfun.c" 3 + )) +# 97 "user/mpy/py/objfun.c" + ; + mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); + mp_arg_check_num(n_args, n_kw, 3, 3, +# 99 "user/mpy/py/objfun.c" 3 4 + 0 +# 99 "user/mpy/py/objfun.c" + ); + return self->fun._3(args[0], args[1], args[2]); +} + +const mp_obj_type_t mp_type_fun_builtin_3 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_3_call, + .unary_op = mp_generic_unary_op, +}; + +static mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + +# 111 "user/mpy/py/objfun.c" 3 + (( +# 111 "user/mpy/py/objfun.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_var))) +# 111 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 111, __func__, +# 111 "user/mpy/py/objfun.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_var)" +# 111 "user/mpy/py/objfun.c" 3 + )) +# 111 "user/mpy/py/objfun.c" + ; + mp_obj_fun_builtin_var_t *self = ((void*)self_in); + + + mp_arg_check_num(n_args, n_kw, self->n_args_min, self->n_args_max, self->is_kw); + + if (self->is_kw) { + + + + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); + + return self->fun.kw(n_args, args, &kw_args); + + } else { + + + return self->fun.var(n_args, args); + } +} + +const mp_obj_type_t mp_type_fun_builtin_var = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_var_call, + .unary_op = mp_generic_unary_op, +}; + + + + +qstr mp_obj_code_get_name(const byte *code_info) { + code_info = mp_decode_uint_skip(code_info); + + return code_info[0] | (code_info[1] << 8); + + + +} + + + + + +qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) { + const mp_obj_fun_bc_t *fun = ((void*)fun_in); + + + + + + + + const byte *bc = fun->bytecode; + bc = mp_decode_uint_skip(bc); + bc = mp_decode_uint_skip(bc); + bc++; + bc++; + bc++; + bc++; + return mp_obj_code_get_name(bc); +} +# 232 "user/mpy/py/objfun.c" +static mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + ; + + (void)0; + (void)0; + (void)0; + (void)0; + (void)0; + mp_obj_fun_bc_t *self = ((void*)self_in); + (void)0; + + + size_t n_state = mp_decode_uint_value(self->bytecode); + size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode)); + + + + + + + size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t); + mp_code_state_t *code_state = +# 253 "user/mpy/py/objfun.c" 3 4 + ((void *)0) +# 253 "user/mpy/py/objfun.c" + ; + if (state_size > (11 * sizeof(mp_uint_t))) { + code_state = ((mp_code_state_t*)m_malloc_maybe(sizeof(mp_code_state_t) + sizeof(byte) * (state_size))); + } + if (code_state == +# 257 "user/mpy/py/objfun.c" 3 4 + ((void *)0) +# 257 "user/mpy/py/objfun.c" + ) { + code_state = +# 258 "user/mpy/py/objfun.c" 3 + __builtin_alloca( +# 258 "user/mpy/py/objfun.c" + sizeof(mp_code_state_t) + state_size +# 258 "user/mpy/py/objfun.c" 3 + ) +# 258 "user/mpy/py/objfun.c" + ; + state_size = 0; + } + + code_state->fun_bc = self; + code_state->ip = 0; + mp_setup_code_state(code_state, n_args, n_kw, args); + + + code_state->old_globals = mp_globals_get(); + mp_globals_set(self->globals); + mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode(code_state, (((mp_obj_t)(void*)0))); + mp_globals_set(code_state->old_globals); +# 298 "user/mpy/py/objfun.c" + mp_obj_t result; + if (vm_return_kind == MP_VM_RETURN_NORMAL) { + + result = *code_state->sp; + } else { + + +# 304 "user/mpy/py/objfun.c" 3 + (( +# 304 "user/mpy/py/objfun.c" + vm_return_kind == MP_VM_RETURN_EXCEPTION +# 304 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 304, __func__, +# 304 "user/mpy/py/objfun.c" + "vm_return_kind == MP_VM_RETURN_EXCEPTION" +# 304 "user/mpy/py/objfun.c" 3 + )) +# 304 "user/mpy/py/objfun.c" + ; + + result = code_state->state[n_state - 1]; + } + + + if (state_size != 0) { + ((void)(state_size), m_free(code_state)); + } + + if (vm_return_kind == MP_VM_RETURN_NORMAL) { + return result; + } else { + nlr_jump(((void*)result)); + } +} +# 333 "user/mpy/py/objfun.c" +const mp_obj_type_t mp_type_fun_bc = { + { &mp_type_type }, + .name = MP_QSTR_function, + + + + .call = fun_bc_call, + .unary_op = mp_generic_unary_op, + + + +}; + +mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) { + size_t n_def_args = 0; + size_t n_extra_args = 0; + mp_obj_tuple_t *def_args = ((void*)def_args_in); + if (def_args_in != (((mp_obj_t)(void*)0))) { + +# 351 "user/mpy/py/objfun.c" 3 + (( +# 351 "user/mpy/py/objfun.c" + (MP_OBJ_IS_OBJ(def_args_in) && (((mp_obj_base_t*)((void*)def_args_in))->type == (&mp_type_tuple))) +# 351 "user/mpy/py/objfun.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 351, __func__, +# 351 "user/mpy/py/objfun.c" + "MP_OBJ_IS_TYPE(def_args_in, &mp_type_tuple)" +# 351 "user/mpy/py/objfun.c" 3 + )) +# 351 "user/mpy/py/objfun.c" + ; + n_def_args = def_args->len; + n_extra_args = def_args->len; + } + if (def_kw_args != (((mp_obj_t)(void*)0))) { + n_extra_args += 1; + } + mp_obj_fun_bc_t *o = ((mp_obj_fun_bc_t*)m_malloc(sizeof(mp_obj_fun_bc_t) + sizeof(mp_obj_t) * (n_extra_args))); + o->base.type = &mp_type_fun_bc; + o->globals = mp_globals_get(); + o->bytecode = code; + o->const_table = const_table; + if (def_args != +# 363 "user/mpy/py/objfun.c" 3 4 + ((void *)0) +# 363 "user/mpy/py/objfun.c" + ) { + memcpy(o->extra_args, def_args->items, n_def_args * sizeof(mp_obj_t)); + } + if (def_kw_args != (((mp_obj_t)(void*)0))) { + o->extra_args[n_def_args] = def_kw_args; + } + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objgenerator.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objgenerator.c" +# 28 "user/mpy/py/objgenerator.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 29 "user/mpy/py/objgenerator.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objgenerator.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objgenerator.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 33 "user/mpy/py/objgenerator.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/objgenerator.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 31 "user/mpy/py/bc.h" +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 35 "user/mpy/py/objgenerator.c" 2 +# 1 "user/mpy/py/objgenerator.h" 1 +# 32 "user/mpy/py/objgenerator.h" +mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); +# 36 "user/mpy/py/objgenerator.c" 2 + + + + + +typedef struct _mp_obj_gen_wrap_t { + mp_obj_base_t base; + mp_obj_t *fun; +} mp_obj_gen_wrap_t; + +typedef struct _mp_obj_gen_instance_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + mp_code_state_t code_state; +} mp_obj_gen_instance_t; + +static mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_gen_wrap_t *self = ((void*)self_in); + mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun; + +# 55 "user/mpy/py/objgenerator.c" 3 + (( +# 55 "user/mpy/py/objgenerator.c" + self_fun->base.type == &mp_type_fun_bc +# 55 "user/mpy/py/objgenerator.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objgenerator.c", 55, __func__, +# 55 "user/mpy/py/objgenerator.c" + "self_fun->base.type == &mp_type_fun_bc" +# 55 "user/mpy/py/objgenerator.c" 3 + )) +# 55 "user/mpy/py/objgenerator.c" + ; + + + size_t n_state = mp_decode_uint_value(self_fun->bytecode); + size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode)); + + + mp_obj_gen_instance_t *o = ((mp_obj_gen_instance_t*)m_malloc(sizeof(mp_obj_gen_instance_t) + sizeof(byte) * (n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t)))) + ; + o->base.type = &mp_type_gen_instance; + + o->globals = self_fun->globals; + o->code_state.fun_bc = self_fun; + o->code_state.ip = 0; + mp_setup_code_state(&o->code_state, n_args, n_kw, args); + return ((mp_obj_t)o); +} + +const mp_obj_type_t mp_type_gen_wrap = { + { &mp_type_type }, + .name = MP_QSTR_generator, + .call = gen_wrap_call, + .unary_op = mp_generic_unary_op, +}; + +mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) { + mp_obj_gen_wrap_t *o = (((mp_obj_gen_wrap_t*)(m_malloc(sizeof(mp_obj_gen_wrap_t) * (1))))); + o->base.type = &mp_type_gen_wrap; + o->fun = ((void*)fun); + return ((mp_obj_t)o); +} + + + + +static void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_gen_instance_t *self = ((void*)self_in); + mp_printf(print, "", mp_obj_fun_get_name(((mp_obj_t)self->code_state.fun_bc)), self); +} + +mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) { + +# 97 "user/mpy/py/objgenerator.c" 3 + (( +# 97 "user/mpy/py/objgenerator.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_gen_instance))) +# 97 "user/mpy/py/objgenerator.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objgenerator.c", 97, __func__, +# 97 "user/mpy/py/objgenerator.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_gen_instance)))" +# 97 "user/mpy/py/objgenerator.c" 3 + )) +# 97 "user/mpy/py/objgenerator.c" + ; + mp_obj_gen_instance_t *self = ((void*)self_in); + if (self->code_state.ip == 0) { + + *ret_val = (((mp_obj_t)(void*)4)); + return MP_VM_RETURN_NORMAL; + } + if (self->code_state.sp == self->code_state.state - 1) { + if (send_value != (((mp_obj_t)&mp_const_none_obj))) { + mp_raise_TypeError("can't send non-None value to a just-started generator"); + } + } else { + *self->code_state.sp = send_value; + } + mp_obj_dict_t *old_globals = mp_globals_get(); + mp_globals_set(self->globals); + mp_vm_return_kind_t ret_kind = mp_execute_bytecode(&self->code_state, throw_value); + mp_globals_set(old_globals); + + switch (ret_kind) { + case MP_VM_RETURN_NORMAL: + default: + + + + + + self->code_state.ip = 0; + *ret_val = *self->code_state.sp; + break; + + case MP_VM_RETURN_YIELD: + *ret_val = *self->code_state.sp; + if (*ret_val == (((mp_obj_t)(void*)4))) { + self->code_state.ip = 0; + } + break; + + case MP_VM_RETURN_EXCEPTION: { + size_t n_state = mp_decode_uint_value(self->code_state.fun_bc->bytecode); + self->code_state.ip = 0; + *ret_val = self->code_state.state[n_state - 1]; + break; + } + } + + return ret_kind; +} + +static mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value) { + mp_obj_t ret; + switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) { + case MP_VM_RETURN_NORMAL: + default: + + if (ret == (((mp_obj_t)&mp_const_none_obj)) || ret == (((mp_obj_t)(void*)4))) { + return (((mp_obj_t)(void*)4)); + } else { + nlr_jump(((void*)mp_obj_new_exception_args(&mp_type_StopIteration, 1, &ret))); + } + + case MP_VM_RETURN_YIELD: + return ret; + + case MP_VM_RETURN_EXCEPTION: + + + + if (mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(ret)), ((mp_obj_t)&mp_type_StopIteration))) { + mp_obj_t val = mp_obj_exception_get_value(ret); + if (val == (((mp_obj_t)&mp_const_none_obj))) { + return (((mp_obj_t)(void*)4)); + } + } + nlr_jump(((void*)ret)); + } +} + +static mp_obj_t gen_instance_iternext(mp_obj_t self_in) { + return gen_resume_and_raise(self_in, (((mp_obj_t)&mp_const_none_obj)), (((mp_obj_t)(void*)0))); +} + +static mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) { + mp_obj_t ret = gen_resume_and_raise(self_in, send_value, (((mp_obj_t)(void*)0))); + if (ret == (((mp_obj_t)(void*)4))) { + nlr_jump(((void*)mp_obj_new_exception(&mp_type_StopIteration))); + } else { + return ret; + } +} + +static const mp_obj_fun_builtin_fixed_t gen_instance_send_obj = {{&mp_type_fun_builtin_2}, .fun._2 = gen_instance_send}; + +static mp_obj_t gen_instance_close(mp_obj_t self_in); +static mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) { + mp_obj_t exc = (n_args == 2) ? args[1] : args[2]; + + mp_obj_t ret = gen_resume_and_raise(args[0], (((mp_obj_t)&mp_const_none_obj)), exc); + if (ret == (((mp_obj_t)(void*)4))) { + nlr_jump(((void*)mp_obj_new_exception(&mp_type_StopIteration))); + } else { + return ret; + } +} + +static const mp_obj_fun_builtin_var_t gen_instance_throw_obj = {{&mp_type_fun_builtin_var}, +# 202 "user/mpy/py/objgenerator.c" 3 4 + 0 +# 202 "user/mpy/py/objgenerator.c" + , 2, 4, .fun.var = gen_instance_throw}; + +static mp_obj_t gen_instance_close(mp_obj_t self_in) { + mp_obj_t ret; + switch (mp_obj_gen_resume(self_in, (((mp_obj_t)&mp_const_none_obj)), ((mp_obj_t)&mp_const_GeneratorExit_obj), &ret)) { + case MP_VM_RETURN_YIELD: + mp_raise_msg(&mp_type_RuntimeError, "generator ignored GeneratorExit"); + + + case MP_VM_RETURN_EXCEPTION: + + if (mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(ret)), ((mp_obj_t)&mp_type_GeneratorExit)) || + mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(ret)), ((mp_obj_t)&mp_type_StopIteration))) { + return (((mp_obj_t)&mp_const_none_obj)); + } + nlr_jump(((void*)ret)); + + default: + + return (((mp_obj_t)&mp_const_none_obj)); + } +} + +static const mp_obj_fun_builtin_fixed_t gen_instance_close_obj = {{&mp_type_fun_builtin_1}, .fun._1 = gen_instance_close}; + +static const mp_rom_map_elem_t gen_instance_locals_dict_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_close)) << 2) | 2)), (&gen_instance_close_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_send)) << 2) | 2)), (&gen_instance_send_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_throw)) << 2) | 2)), (&gen_instance_throw_obj) }, +}; + +static const mp_obj_dict_t gen_instance_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(gen_instance_locals_dict_table) / sizeof((gen_instance_locals_dict_table)[0])), .alloc = (sizeof(gen_instance_locals_dict_table) / sizeof((gen_instance_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)gen_instance_locals_dict_table, }, }; + +const mp_obj_type_t mp_type_gen_instance = { + { &mp_type_type }, + .name = MP_QSTR_generator, + .print = gen_instance_print, + .unary_op = mp_generic_unary_op, + .getiter = mp_identity_getiter, + .iternext = gen_instance_iternext, + .locals_dict = (mp_obj_dict_t*)&gen_instance_locals_dict, +}; +# 1 "user/mpy/py/objgetitemiter.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objgetitemiter.c" +# 27 "user/mpy/py/objgetitemiter.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objgetitemiter.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 30 "user/mpy/py/objgetitemiter.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objgetitemiter.c" 2 + + + +typedef struct _mp_obj_getitem_iter_t { + mp_obj_base_t base; + mp_obj_t args[3]; +} mp_obj_getitem_iter_t; + +static mp_obj_t it_iternext(mp_obj_t self_in) { + mp_obj_getitem_iter_t *self = ((void*)self_in); + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + + mp_obj_t value = mp_call_method_n_kw(1, 0, self->args); + self->args[2] = ((mp_obj_t)((((mp_uint_t)((((mp_int_t)(self->args[2])) >> 1) + 1)) << 1) | 1)); + nlr_pop(); + return value; + } else { + + mp_obj_type_t *t = (mp_obj_type_t*)((mp_obj_base_t*)nlr.ret_val)->type; + if (t == &mp_type_StopIteration || t == &mp_type_IndexError) { + + return (((mp_obj_t)(void*)4)); + } else { + + nlr_jump(nlr.ret_val); + } + } +} + +static const mp_obj_type_t it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = it_iternext, +}; + + +mp_obj_t mp_obj_new_getitem_iter(mp_obj_t *args, mp_obj_iter_buf_t *iter_buf) { + +# 70 "user/mpy/py/objgetitemiter.c" 3 + (( +# 70 "user/mpy/py/objgetitemiter.c" + sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t) +# 70 "user/mpy/py/objgetitemiter.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objgetitemiter.c", 70, __func__, +# 70 "user/mpy/py/objgetitemiter.c" + "sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t)" +# 70 "user/mpy/py/objgetitemiter.c" 3 + )) +# 70 "user/mpy/py/objgetitemiter.c" + ; + mp_obj_getitem_iter_t *o = (mp_obj_getitem_iter_t*)iter_buf; + o->base.type = &it_type; + o->args[0] = args[0]; + o->args[1] = args[1]; + o->args[2] = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objint.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objint.c" +# 27 "user/mpy/py/objint.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objint.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objint.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/objint.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 32 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 33 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 34 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 + + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 35 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 36 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 37 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 38 "user/mpy/py/objint.c" 2 +# 1 "user/mpy/py/binary.h" 1 +# 35 "user/mpy/py/binary.h" +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 39 "user/mpy/py/objint.c" 2 + + + + + + +static mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 2, +# 47 "user/mpy/py/objint.c" 3 4 + 0 +# 47 "user/mpy/py/objint.c" + ); + + switch (n_args) { + case 0: + return ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); + + case 1: + if ((MP_OBJ_IS_SMALL_INT(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_int))))) { + + return args[0]; + } else if ((MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))) { + + size_t l; + const char *s = mp_obj_str_get_data(args[0], &l); + return mp_parse_num_integer(s, l, 0, +# 61 "user/mpy/py/objint.c" 3 4 + ((void *)0) +# 61 "user/mpy/py/objint.c" + ); + + + + + } else { + + return ((mp_obj_t)((((mp_uint_t)(mp_obj_get_int(args[0]))) << 1) | 1)); + } + + case 2: + default: { + + + size_t l; + const char *s = mp_obj_str_get_data(args[0], &l); + return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]), +# 77 "user/mpy/py/objint.c" 3 4 + ((void *)0) +# 77 "user/mpy/py/objint.c" + ); + } + } +} +# 175 "user/mpy/py/objint.c" +typedef mp_int_t fmt_int_t; +typedef mp_uint_t fmt_uint_t; + + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + + + char stack_buf[sizeof(fmt_int_t) * 4]; + char *buf = stack_buf; + size_t buf_size = sizeof(stack_buf); + size_t fmt_size; + + char *str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, self_in, 10, +# 188 "user/mpy/py/objint.c" 3 4 + ((void *)0) +# 188 "user/mpy/py/objint.c" + , '\0', '\0'); + mp_print_str(print, str); + + if (buf != stack_buf) { + ((void)(buf_size), m_free(buf)); + } +} + +static const uint8_t log_base2_floor[] = { + 0, 1, 1, 2, + 2, 2, 2, 3, + 3, 3, 3, 3, + 3, 3, 3, 4, + + + + + + +}; + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma) { + +# 210 "user/mpy/py/objint.c" 3 + (( +# 210 "user/mpy/py/objint.c" + 2 <= base && base <= 16 +# 210 "user/mpy/py/objint.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objint.c", 210, __func__, +# 210 "user/mpy/py/objint.c" + "2 <= base && base <= 16" +# 210 "user/mpy/py/objint.c" 3 + )) +# 210 "user/mpy/py/objint.c" + ; + size_t num_digits = num_bits / log_base2_floor[base - 1] + 1; + size_t num_commas = comma ? num_digits / 3 : 0; + size_t prefix_len = prefix ? strlen(prefix) : 0; + return num_digits + num_commas + prefix_len + 2; +} +# 224 "user/mpy/py/objint.c" +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma) { + fmt_int_t num; + if (MP_OBJ_IS_SMALL_INT(self_in)) { + + num = (((mp_int_t)(self_in)) >> 1); +# 242 "user/mpy/py/objint.c" + } else { + + **buf = '\0'; + *fmt_size = 0; + return *buf; + } + + char sign = '\0'; + if (num < 0) { + num = -num; + sign = '-'; + } + + size_t needed_size = mp_int_format_size(sizeof(fmt_int_t) * 8, base, prefix, comma); + if (needed_size > *buf_size) { + *buf = ((char*)(m_malloc(sizeof(char) * (needed_size)))); + *buf_size = needed_size; + } + char *str = *buf; + + char *b = str + needed_size; + *(--b) = '\0'; + char *last_comma = b; + + if (num == 0) { + *(--b) = '0'; + } else { + do { + + int c = (fmt_uint_t)num % base; + num = (fmt_uint_t)num / base; + if (c >= 10) { + c += base_char - 10; + } else { + c += '0'; + } + *(--b) = c; + if (comma && num != 0 && b > str && (last_comma - b) == 3) { + *(--b) = comma; + last_comma = b; + } + } + while (b > str && num != 0); + } + if (prefix) { + size_t prefix_len = strlen(prefix); + char *p = b - prefix_len; + if (p > str) { + b = p; + while (*prefix) { + *p++ = *prefix++; + } + } + } + if (sign && b > str) { + *(--b) = sign; + } + *fmt_size = *buf + needed_size - b - 1; + + return b; +} + + + +int mp_obj_int_sign(mp_obj_t self_in) { + mp_int_t val = mp_obj_get_int(self_in); + if (val < 0) { + return -1; + } else if (val > 0) { + return 1; + } else { + return 0; + } +} + + + +mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { + mp_int_t val = mp_obj_get_int(self_in); + if (val < 0) { + val = -val; + } + return ((mp_obj_t)((((mp_uint_t)(val)) << 1) | 1)); +} + + +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { + return (((mp_obj_t)(void*)0)); +} + + +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); +} + + +mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, +# 338 "user/mpy/py/objint.c" 3 4 + _Bool +# 338 "user/mpy/py/objint.c" + neg, unsigned int base) { + mp_raise_msg(&mp_type_OverflowError, "long int not supported in this build"); + return (((mp_obj_t)&mp_const_none_obj)); +} + + +mp_obj_t mp_obj_new_int_from_ll(long long val) { + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return (((mp_obj_t)&mp_const_none_obj)); +} + + +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return (((mp_obj_t)&mp_const_none_obj)); +} + +mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { + + + if ((value & ~~((((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1)) | ((((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1)) >> 1))) == 0) { + return ((mp_obj_t)((((mp_uint_t)(value)) << 1) | 1)); + } + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return (((mp_obj_t)&mp_const_none_obj)); +} + +mp_obj_t mp_obj_new_int(mp_int_t value) { + if (((((value) ^ ((value) << 1)) & (((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) == 0)) { + return ((mp_obj_t)((((mp_uint_t)(value)) << 1) | 1)); + } + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return (((mp_obj_t)&mp_const_none_obj)); +} + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { + return (((mp_int_t)(self_in)) >> 1); +} + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { + return (((mp_int_t)(self_in)) >> 1); +} + + + + + +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + if (rhs_in == (((mp_obj_t)&mp_const_false_obj))) { + + return mp_binary_op(op, lhs_in, ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1))); + } else if (rhs_in == (((mp_obj_t)&mp_const_true_obj))) { + + return mp_binary_op(op, lhs_in, ((mp_obj_t)((((mp_uint_t)(1)) << 1) | 1))); + } else if (op == MP_BINARY_OP_MULTIPLY) { + if ((MP_OBJ_IS_QSTR(rhs_in) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_str)))) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_bytes))) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_list)))) { + + return mp_binary_op(op, rhs_in, lhs_in); + } + } + return (((mp_obj_t)(void*)0)); +} + + +static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) { + + (void)n_args; + + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, (1)); + + const byte* buf = (const byte*)bufinfo.buf; + int delta = 1; + if (args[2] == ((mp_obj_t)((((mp_uint_t)(MP_QSTR_little)) << 2) | 2))) { + buf += bufinfo.len - 1; + delta = -1; + } + + mp_uint_t value = 0; + size_t len = bufinfo.len; + for (; len--; buf += delta) { + + + + + + + value = (value << 8) | *buf; + } + return mp_obj_new_int_from_uint(value); +} + +static const mp_obj_fun_builtin_var_t int_from_bytes_fun_obj = {{&mp_type_fun_builtin_var}, +# 431 "user/mpy/py/objint.c" 3 4 + 0 +# 431 "user/mpy/py/objint.c" + , 3, 4, .fun.var = int_from_bytes}; +static const mp_rom_obj_static_class_method_t int_from_bytes_obj = {{&mp_type_classmethod}, (&int_from_bytes_fun_obj)}; + +static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) { + + (void)n_args; + + mp_int_t len = mp_obj_get_int(args[1]); + if (len < 0) { + mp_raise_ValueError( +# 440 "user/mpy/py/objint.c" 3 4 + ((void *)0) +# 440 "user/mpy/py/objint.c" + ); + } + +# 442 "user/mpy/py/objint.c" 3 4 + _Bool +# 442 "user/mpy/py/objint.c" + big_endian = args[2] != ((mp_obj_t)((((mp_uint_t)(MP_QSTR_little)) << 2) | 2)); + + vstr_t vstr; + vstr_init_len(&vstr, len); + byte *data = (byte*)vstr.buf; + memset(data, 0, len); + + + + + + + { + mp_int_t val = (((mp_int_t)(args[0])) >> 1); + size_t l = (((size_t)len) < (sizeof(val)) ? ((size_t)len) : (sizeof(val))); + mp_binary_set_int(l, big_endian, data + (big_endian ? (len - l) : 0), val); + } + + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +static const mp_obj_fun_builtin_var_t int_to_bytes_obj = {{&mp_type_fun_builtin_var}, +# 462 "user/mpy/py/objint.c" 3 4 + 0 +# 462 "user/mpy/py/objint.c" + , 3, 4, .fun.var = int_to_bytes}; + +static const mp_rom_map_elem_t int_locals_dict_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_from_bytes)) << 2) | 2)), (&int_from_bytes_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_to_bytes)) << 2) | 2)), (&int_to_bytes_obj) }, +}; + +static const mp_obj_dict_t int_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(int_locals_dict_table) / sizeof((int_locals_dict_table)[0])), .alloc = (sizeof(int_locals_dict_table) / sizeof((int_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)int_locals_dict_table, }, }; + +const mp_obj_type_t mp_type_int = { + { &mp_type_type }, + .name = MP_QSTR_int, + .print = mp_obj_int_print, + .make_new = mp_obj_int_make_new, + .unary_op = mp_obj_int_unary_op, + .binary_op = mp_obj_int_binary_op, + .locals_dict = (mp_obj_dict_t*)&int_locals_dict, +}; +# 1 "user/mpy/py/objint_longlong.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objint_longlong.c" +# 28 "user/mpy/py/objint_longlong.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 29 "user/mpy/py/objint_longlong.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/objint_longlong.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objint_longlong.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 30 "user/mpy/py/smallint.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/smallint.h" 2 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 33 "user/mpy/py/objint_longlong.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 31 "user/mpy/py/objint.h" 2 + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 34 "user/mpy/py/objint_longlong.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/objint_longlong.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 36 "user/mpy/py/objint_longlong.c" 2 +# 1 "user/mpy/py/objint_mpz.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objint_mpz.c" +# 27 "user/mpy/py/objint_mpz.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objint_mpz.c" 2 +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 61 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/objint_mpz.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objint_mpz.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objint_mpz.c" 2 +# 1 "user/mpy/py/parsenumbase.h" 1 +# 31 "user/mpy/py/parsenumbase.h" +size_t mp_parse_num_base(const char *str, size_t len, int *base); +# 33 "user/mpy/py/objint_mpz.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 30 "user/mpy/py/smallint.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/smallint.h" 2 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 34 "user/mpy/py/objint_mpz.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 31 "user/mpy/py/objint.h" 2 + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 35 "user/mpy/py/objint_mpz.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 36 "user/mpy/py/objint_mpz.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/objint_mpz.c" 2 +# 1 "user/mpy/py/objlist.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objlist.c" +# 27 "user/mpy/py/objlist.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objlist.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objlist.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objlist.c" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 29 "user/mpy/py/objlist.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objlist.h" 2 + +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; +# 32 "user/mpy/py/objlist.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/objlist.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + + +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/objlist.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 35 "user/mpy/py/objlist.c" 2 + +static mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf); +static mp_obj_list_t *list_new(size_t n); +static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in); +static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); + + + + + + + +static void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_list_t *o = ((void*)o_in); + if (!((0) && kind == PRINT_JSON)) { + kind = PRINT_REPR; + } + mp_print_str(print, "["); + for (size_t i = 0; i < o->len; i++) { + if (i > 0) { + mp_print_str(print, ", "); + } + mp_obj_print_helper(print, o->items[i], kind); + } + mp_print_str(print, "]"); +} + +static mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) { + mp_obj_t iter = mp_getiter(iterable, +# 63 "user/mpy/py/objlist.c" 3 4 + ((void *)0) +# 63 "user/mpy/py/objlist.c" + ); + mp_obj_t item; + while ((item = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { + mp_obj_list_append(list, item); + } + return list; +} + +static mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 1, +# 73 "user/mpy/py/objlist.c" 3 4 + 0 +# 73 "user/mpy/py/objlist.c" + ); + + switch (n_args) { + case 0: + + return mp_obj_new_list(0, +# 78 "user/mpy/py/objlist.c" 3 4 + ((void *)0) +# 78 "user/mpy/py/objlist.c" + ); + + case 1: + default: { + + + mp_obj_t list = mp_obj_new_list(0, +# 84 "user/mpy/py/objlist.c" 3 4 + ((void *)0) +# 84 "user/mpy/py/objlist.c" + ); + return list_extend_from_iter(list, args[0]); + } + } +} + + +static +# 91 "user/mpy/py/objlist.c" 3 4 + _Bool +# 91 "user/mpy/py/objlist.c" + list_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { + +# 92 "user/mpy/py/objlist.c" 3 + (( +# 92 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 92 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 92, __func__, +# 92 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 92 "user/mpy/py/objlist.c" 3 + )) +# 92 "user/mpy/py/objlist.c" + ; + if (!(MP_OBJ_IS_OBJ(another_in) && (((mp_obj_base_t*)((void*)another_in))->type == (&mp_type_list)))) { + return +# 94 "user/mpy/py/objlist.c" 3 4 + 0 +# 94 "user/mpy/py/objlist.c" + ; + } + mp_obj_list_t *self = ((void*)self_in); + mp_obj_list_t *another = ((void*)another_in); + + return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); +} + +static mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_list_t *self = ((void*)self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); + case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(self->len)) << 1) | 1)); + + + + + + + default: return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t list_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + mp_obj_list_t *o = ((void*)lhs); + switch (op) { + case MP_BINARY_OP_ADD: { + if (!(MP_OBJ_IS_OBJ(rhs) && (((mp_obj_base_t*)((void*)rhs))->type == (&mp_type_list)))) { + return (((mp_obj_t)(void*)0)); + } + mp_obj_list_t *p = ((void*)rhs); + mp_obj_list_t *s = list_new(o->len + p->len); + { memcpy(s->items, o->items, (o->len) * sizeof(mp_obj_t)); memcpy(s->items + (o->len), p->items, (p->len) * sizeof(mp_obj_t)); }; + return ((mp_obj_t)s); + } + case MP_BINARY_OP_INPLACE_ADD: { + list_extend(lhs, rhs); + return lhs; + } + case MP_BINARY_OP_MULTIPLY: { + mp_int_t n; + if (!mp_obj_get_int_maybe(rhs, &n)) { + return (((mp_obj_t)(void*)0)); + } + if (n < 0) { + n = 0; + } + mp_obj_list_t *s = list_new(o->len * n); + mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); + return ((mp_obj_t)s); + } + case MP_BINARY_OP_EQUAL: + case MP_BINARY_OP_LESS: + case MP_BINARY_OP_LESS_EQUAL: + case MP_BINARY_OP_MORE: + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(list_cmp_helper(op, lhs, rhs)); + + default: + return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == (((mp_obj_t)(void*)0))) { +# 178 "user/mpy/py/objlist.c" + mp_obj_t args[2] = {self_in, index}; + list_pop(2, args); + return (((mp_obj_t)&mp_const_none_obj)); + } else if (value == (((mp_obj_t)(void*)8))) { + + mp_obj_list_t *self = ((void*)self_in); +# 195 "user/mpy/py/objlist.c" + size_t index_val = mp_get_index(self->base.type, self->len, index, +# 195 "user/mpy/py/objlist.c" 3 4 + 0 +# 195 "user/mpy/py/objlist.c" + ); + return self->items[index_val]; + } else { +# 229 "user/mpy/py/objlist.c" + mp_obj_list_store(self_in, index, value); + return (((mp_obj_t)&mp_const_none_obj)); + } +} + +static mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + return mp_obj_new_list_iterator(o_in, 0, iter_buf); +} + +mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) { + +# 239 "user/mpy/py/objlist.c" 3 + (( +# 239 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 239 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 239, __func__, +# 239 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 239 "user/mpy/py/objlist.c" 3 + )) +# 239 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)self_in); + if (self->len >= self->alloc) { + self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (self->alloc * 2)))); + self->alloc *= 2; + memset((byte*)(self->items) + (self->len + 1) * (sizeof(*self->items)), 0, ((self->alloc) - (self->len + 1)) * (sizeof(*self->items))); + } + self->items[self->len++] = arg; + return (((mp_obj_t)&mp_const_none_obj)); +} + +static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { + +# 251 "user/mpy/py/objlist.c" 3 + (( +# 251 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 251 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 251, __func__, +# 251 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 251 "user/mpy/py/objlist.c" 3 + )) +# 251 "user/mpy/py/objlist.c" + ; + if ((MP_OBJ_IS_OBJ(arg_in) && (((mp_obj_base_t*)((void*)arg_in))->type == (&mp_type_list)))) { + mp_obj_list_t *self = ((void*)self_in); + mp_obj_list_t *arg = ((void*)arg_in); + + if (self->len + arg->len > self->alloc) { + + self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (self->len + arg->len + 4)))); + self->alloc = self->len + arg->len + 4; + memset((byte*)(self->items) + (self->len + arg->len) * (sizeof(*self->items)), 0, ((self->alloc) - (self->len + arg->len)) * (sizeof(*self->items))); + } + + memcpy(self->items + self->len, arg->items, sizeof(mp_obj_t) * arg->len); + self->len += arg->len; + } else { + list_extend_from_iter(self_in, arg_in); + } + return (((mp_obj_t)&mp_const_none_obj)); +} + +static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) { + +# 272 "user/mpy/py/objlist.c" 3 + (( +# 272 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list))) +# 272 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 272, __func__, +# 272 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list)))" +# 272 "user/mpy/py/objlist.c" 3 + )) +# 272 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)args[0]); + if (self->len == 0) { + mp_raise_msg(&mp_type_IndexError, "pop from empty list"); + } + size_t index = mp_get_index(self->base.type, self->len, n_args == 1 ? ((mp_obj_t)((((mp_uint_t)(-1)) << 1) | 1)) : args[1], +# 277 "user/mpy/py/objlist.c" 3 4 + 0 +# 277 "user/mpy/py/objlist.c" + ); + mp_obj_t ret = self->items[index]; + self->len -= 1; + memmove(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t)); + + self->items[self->len] = (((mp_obj_t)(void*)0)); + if (self->alloc > 4 && self->alloc > 2 * self->len) { + self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (self->alloc/2)))); + self->alloc /= 2; + } + return ret; +} + +static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) { + ; + while (head < tail) { + mp_obj_t *h = head - 1; + mp_obj_t *t = tail; + mp_obj_t v = key_fn == (((mp_obj_t)(void*)0)) ? tail[0] : mp_call_function_1(key_fn, tail[0]); + for (;;) { + do ++h; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, key_fn == (((mp_obj_t)(void*)0)) ? h[0] : mp_call_function_1(key_fn, h[0]), v) == binop_less_result); + do --t; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, v, key_fn == (((mp_obj_t)(void*)0)) ? t[0] : mp_call_function_1(key_fn, t[0])) == binop_less_result); + if (h >= t) break; + mp_obj_t x = h[0]; + h[0] = t[0]; + t[0] = x; + } + mp_obj_t x = h[0]; + h[0] = tail[0]; + tail[0] = x; + + if (t - head < tail - h - 1) { + mp_quicksort(head, t, key_fn, binop_less_result); + head = h + 1; + } else { + mp_quicksort(h + 1, tail, key_fn, binop_less_result); + tail = t; + } + } +} + + +mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + static const mp_arg_t allowed_args[] = { + { MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = (&mp_const_none_obj)} }, + { MP_QSTR_reverse, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = +# 322 "user/mpy/py/objlist.c" 3 4 + 0 +# 322 "user/mpy/py/objlist.c" + } }, + }; + + + struct { + mp_arg_val_t key, reverse; + } args; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + (sizeof(allowed_args) / sizeof((allowed_args)[0])), allowed_args, (mp_arg_val_t*)&args); + + +# 332 "user/mpy/py/objlist.c" 3 + (( +# 332 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(pos_args[0]) && (((mp_obj_base_t*)((void*)pos_args[0]))->type == (&mp_type_list))) +# 332 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 332, __func__, +# 332 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(pos_args[0]) && (((mp_obj_base_t*)((void*)pos_args[0]))->type == (&mp_type_list)))" +# 332 "user/mpy/py/objlist.c" 3 + )) +# 332 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)pos_args[0]); + + if (self->len > 1) { + mp_quicksort(self->items, self->items + self->len - 1, + args.key.u_obj == (((mp_obj_t)&mp_const_none_obj)) ? (((mp_obj_t)(void*)0)) : args.key.u_obj, + args.reverse.u_bool ? (((mp_obj_t)&mp_const_false_obj)) : (((mp_obj_t)&mp_const_true_obj))); + } + + return (((mp_obj_t)&mp_const_none_obj)); +} + +static mp_obj_t list_clear(mp_obj_t self_in) { + +# 345 "user/mpy/py/objlist.c" 3 + (( +# 345 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 345 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 345, __func__, +# 345 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 345 "user/mpy/py/objlist.c" 3 + )) +# 345 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)self_in); + self->len = 0; + self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (4)))); + self->alloc = 4; + memset((byte*)(self->items) + (0) * (sizeof(*self->items)), 0, ((self->alloc) - (0)) * (sizeof(*self->items))); + return (((mp_obj_t)&mp_const_none_obj)); +} + +static mp_obj_t list_copy(mp_obj_t self_in) { + +# 355 "user/mpy/py/objlist.c" 3 + (( +# 355 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 355 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 355, __func__, +# 355 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 355 "user/mpy/py/objlist.c" 3 + )) +# 355 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)self_in); + return mp_obj_new_list(self->len, self->items); +} + +static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { + +# 361 "user/mpy/py/objlist.c" 3 + (( +# 361 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 361 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 361, __func__, +# 361 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 361 "user/mpy/py/objlist.c" 3 + )) +# 361 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)self_in); + return mp_seq_count_obj(self->items, self->len, value); +} + +static mp_obj_t list_index(size_t n_args, const mp_obj_t *args) { + +# 367 "user/mpy/py/objlist.c" 3 + (( +# 367 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list))) +# 367 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 367, __func__, +# 367 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list)))" +# 367 "user/mpy/py/objlist.c" 3 + )) +# 367 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)args[0]); + return mp_seq_index_obj(self->items, self->len, n_args, args); +} + +static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) { + +# 373 "user/mpy/py/objlist.c" 3 + (( +# 373 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 373 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 373, __func__, +# 373 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 373 "user/mpy/py/objlist.c" 3 + )) +# 373 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)self_in); + + mp_int_t index = (((mp_int_t)(idx)) >> 1); + if (index < 0) { + index += self->len; + } + if (index < 0) { + index = 0; + } + if ((size_t)index > self->len) { + index = self->len; + } + + mp_obj_list_append(self_in, (((mp_obj_t)&mp_const_none_obj))); + + for (mp_int_t i = self->len-1; i > index; i--) { + self->items[i] = self->items[i-1]; + } + self->items[index] = obj; + + return (((mp_obj_t)&mp_const_none_obj)); +} + +mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) { + +# 398 "user/mpy/py/objlist.c" 3 + (( +# 398 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 398 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 398, __func__, +# 398 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 398 "user/mpy/py/objlist.c" 3 + )) +# 398 "user/mpy/py/objlist.c" + ; + mp_obj_t args[] = {self_in, value}; + args[1] = list_index(2, args); + list_pop(2, args); + + return (((mp_obj_t)&mp_const_none_obj)); +} + +static mp_obj_t list_reverse(mp_obj_t self_in) { + +# 407 "user/mpy/py/objlist.c" 3 + (( +# 407 "user/mpy/py/objlist.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) +# 407 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 407, __func__, +# 407 "user/mpy/py/objlist.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" +# 407 "user/mpy/py/objlist.c" 3 + )) +# 407 "user/mpy/py/objlist.c" + ; + mp_obj_list_t *self = ((void*)self_in); + + mp_int_t len = self->len; + for (mp_int_t i = 0; i < len/2; i++) { + mp_obj_t a = self->items[i]; + self->items[i] = self->items[len-i-1]; + self->items[len-i-1] = a; + } + + return (((mp_obj_t)&mp_const_none_obj)); +} + +static const mp_obj_fun_builtin_fixed_t list_append_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_obj_list_append}; +static const mp_obj_fun_builtin_fixed_t list_extend_obj = {{&mp_type_fun_builtin_2}, .fun._2 = list_extend}; +static const mp_obj_fun_builtin_fixed_t list_clear_obj = {{&mp_type_fun_builtin_1}, .fun._1 = list_clear}; +static const mp_obj_fun_builtin_fixed_t list_copy_obj = {{&mp_type_fun_builtin_1}, .fun._1 = list_copy}; +static const mp_obj_fun_builtin_fixed_t list_count_obj = {{&mp_type_fun_builtin_2}, .fun._2 = list_count}; +static const mp_obj_fun_builtin_var_t list_index_obj = {{&mp_type_fun_builtin_var}, +# 425 "user/mpy/py/objlist.c" 3 4 + 0 +# 425 "user/mpy/py/objlist.c" + , 2, 4, .fun.var = list_index}; +static const mp_obj_fun_builtin_fixed_t list_insert_obj = {{&mp_type_fun_builtin_3}, .fun._3 = list_insert}; +static const mp_obj_fun_builtin_var_t list_pop_obj = {{&mp_type_fun_builtin_var}, +# 427 "user/mpy/py/objlist.c" 3 4 + 0 +# 427 "user/mpy/py/objlist.c" + , 1, 2, .fun.var = list_pop}; +static const mp_obj_fun_builtin_fixed_t list_remove_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_obj_list_remove}; +static const mp_obj_fun_builtin_fixed_t list_reverse_obj = {{&mp_type_fun_builtin_1}, .fun._1 = list_reverse}; +static const mp_obj_fun_builtin_var_t list_sort_obj = {{&mp_type_fun_builtin_var}, +# 430 "user/mpy/py/objlist.c" 3 4 + 1 +# 430 "user/mpy/py/objlist.c" + , 1, (0xffff), .fun.kw = mp_obj_list_sort}; + +static const mp_rom_map_elem_t list_locals_dict_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_append)) << 2) | 2)), (&list_append_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_clear)) << 2) | 2)), (&list_clear_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_copy)) << 2) | 2)), (&list_copy_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_count)) << 2) | 2)), (&list_count_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_extend)) << 2) | 2)), (&list_extend_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_index)) << 2) | 2)), (&list_index_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_insert)) << 2) | 2)), (&list_insert_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_pop)) << 2) | 2)), (&list_pop_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_remove)) << 2) | 2)), (&list_remove_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_reverse)) << 2) | 2)), (&list_reverse_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sort)) << 2) | 2)), (&list_sort_obj) }, +}; + +static const mp_obj_dict_t list_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(list_locals_dict_table) / sizeof((list_locals_dict_table)[0])), .alloc = (sizeof(list_locals_dict_table) / sizeof((list_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)list_locals_dict_table, }, }; + +const mp_obj_type_t mp_type_list = { + { &mp_type_type }, + .name = MP_QSTR_list, + .print = list_print, + .make_new = list_make_new, + .unary_op = list_unary_op, + .binary_op = list_binary_op, + .subscr = list_subscr, + .getiter = list_getiter, + .locals_dict = (mp_obj_dict_t*)&list_locals_dict, +}; + +void mp_obj_list_init(mp_obj_list_t *o, size_t n) { + o->base.type = &mp_type_list; + o->alloc = n < 4 ? 4 : n; + o->len = n; + o->items = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (o->alloc)))); + memset((byte*)(o->items) + (n) * (sizeof(*o->items)), 0, ((o->alloc) - (n)) * (sizeof(*o->items))); +} + +static mp_obj_list_t *list_new(size_t n) { + mp_obj_list_t *o = (((mp_obj_list_t*)(m_malloc(sizeof(mp_obj_list_t) * (1))))); + mp_obj_list_init(o, n); + return o; +} + +mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items) { + mp_obj_list_t *o = list_new(n); + if (items != +# 476 "user/mpy/py/objlist.c" 3 4 + ((void *)0) +# 476 "user/mpy/py/objlist.c" + ) { + for (size_t i = 0; i < n; i++) { + o->items[i] = items[i]; + } + } + return ((mp_obj_t)o); +} + +void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { + mp_obj_list_t *self = ((void*)self_in); + *len = self->len; + *items = self->items; +} + +void mp_obj_list_set_len(mp_obj_t self_in, size_t len) { + + + mp_obj_list_t *self = ((void*)self_in); + self->len = len; +} + +void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_list_t *self = ((void*)self_in); + size_t i = mp_get_index(self->base.type, self->len, index, +# 499 "user/mpy/py/objlist.c" 3 4 + 0 +# 499 "user/mpy/py/objlist.c" + ); + self->items[i] = value; +} + + + + +typedef struct _mp_obj_list_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t list; + size_t cur; +} mp_obj_list_it_t; + +static mp_obj_t list_it_iternext(mp_obj_t self_in) { + mp_obj_list_it_t *self = ((void*)self_in); + mp_obj_list_t *list = ((void*)self->list); + if (self->cur < list->len) { + mp_obj_t o_out = list->items[self->cur]; + self->cur += 1; + return o_out; + } else { + return (((mp_obj_t)(void*)4)); + } +} + +mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf) { + +# 526 "user/mpy/py/objlist.c" 3 + (( +# 526 "user/mpy/py/objlist.c" + sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t) +# 526 "user/mpy/py/objlist.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 526, __func__, +# 526 "user/mpy/py/objlist.c" + "sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 526 "user/mpy/py/objlist.c" 3 + )) +# 526 "user/mpy/py/objlist.c" + ; + mp_obj_list_it_t *o = (mp_obj_list_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = list_it_iternext; + o->list = list; + o->cur = cur; + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objmap.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objmap.c" +# 27 "user/mpy/py/objmap.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objmap.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objmap.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objmap.c" 2 + +typedef struct _mp_obj_map_t { + mp_obj_base_t base; + size_t n_iters; + mp_obj_t fun; + mp_obj_t iters[]; +} mp_obj_map_t; + +static mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, (0xffff), +# 40 "user/mpy/py/objmap.c" 3 4 + 0 +# 40 "user/mpy/py/objmap.c" + ); + mp_obj_map_t *o = ((mp_obj_map_t*)m_malloc(sizeof(mp_obj_map_t) + sizeof(mp_obj_t) * (n_args - 1))); + o->base.type = type; + o->n_iters = n_args - 1; + o->fun = args[0]; + for (size_t i = 0; i < n_args - 1; i++) { + o->iters[i] = mp_getiter(args[i + 1], +# 46 "user/mpy/py/objmap.c" 3 4 + ((void *)0) +# 46 "user/mpy/py/objmap.c" + ); + } + return ((mp_obj_t)o); +} + +static mp_obj_t map_iternext(mp_obj_t self_in) { + +# 52 "user/mpy/py/objmap.c" 3 + (( +# 52 "user/mpy/py/objmap.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_map))) +# 52 "user/mpy/py/objmap.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objmap.c", 52, __func__, +# 52 "user/mpy/py/objmap.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_map)))" +# 52 "user/mpy/py/objmap.c" 3 + )) +# 52 "user/mpy/py/objmap.c" + ; + mp_obj_map_t *self = ((void*)self_in); + mp_obj_t *nextses = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (self->n_iters)))); + + for (size_t i = 0; i < self->n_iters; i++) { + mp_obj_t next = mp_iternext(self->iters[i]); + if (next == (((mp_obj_t)(void*)4))) { + ((void)(self->n_iters), m_free(nextses)); + return (((mp_obj_t)(void*)4)); + } + nextses[i] = next; + } + return mp_call_function_n_kw(self->fun, self->n_iters, 0, nextses); +} + +const mp_obj_type_t mp_type_map = { + { &mp_type_type }, + .name = MP_QSTR_map, + .make_new = map_make_new, + .getiter = mp_identity_getiter, + .iternext = map_iternext, +}; +# 1 "user/mpy/py/objmodule.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objmodule.c" +# 27 "user/mpy/py/objmodule.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objmodule.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objmodule.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 31 "user/mpy/py/objmodule.c" 2 + +# 1 "user/mpy/py/objmodule.h" 1 +# 31 "user/mpy/py/objmodule.h" +extern const mp_map_t mp_builtin_module_map; +extern const mp_map_t mp_builtin_module_weak_links_map; + +mp_obj_t mp_module_get(qstr module_name); +void mp_module_register(qstr qstr, mp_obj_t module); +# 33 "user/mpy/py/objmodule.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/objmodule.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 35 "user/mpy/py/objmodule.c" 2 + +static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_module_t *self = ((void*)self_in); + + const char *module_name = ""; + mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 42 "user/mpy/py/objmodule.c" 3 4 + ((void *)0) +# 42 "user/mpy/py/objmodule.c" + ) { + module_name = mp_obj_str_get_str(elem->value); + } +# 56 "user/mpy/py/objmodule.c" + mp_printf(print, "", module_name); +} + +static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + mp_obj_module_t *self = ((void*)self_in); + if (dest[0] == (((mp_obj_t)(void*)0))) { + + mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 64 "user/mpy/py/objmodule.c" 3 4 + ((void *)0) +# 64 "user/mpy/py/objmodule.c" + ) { + dest[0] = elem->value; + } + } else { + + mp_obj_dict_t *dict = self->globals; + if (dict->map.is_fixed) { +# 79 "user/mpy/py/objmodule.c" + { + + return; + } + } + if (dest[1] == (((mp_obj_t)(void*)0))) { + + mp_obj_dict_delete(((mp_obj_t)dict), ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2))); + } else { + + + mp_obj_dict_store(((mp_obj_t)dict), ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), dest[1]); + } + dest[0] = (((mp_obj_t)(void*)0)); + } +} + +const mp_obj_type_t mp_type_module = { + { &mp_type_type }, + .name = MP_QSTR_module, + .print = module_print, + .attr = module_attr, +}; + +mp_obj_t mp_obj_new_module(qstr module_name) { + mp_map_t *mp_loaded_modules_map = &(mp_state_ctx.vm.mp_loaded_modules_dict).map; + mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + + + if (el->value != (((mp_obj_t)(void*)0))) { + return el->value; + } + + + mp_obj_module_t *o = (((mp_obj_module_t*)(m_malloc(sizeof(mp_obj_module_t) * (1))))); + o->base.type = &mp_type_module; + o->globals = ((void*)mp_obj_new_dict((1))); + + + mp_obj_dict_store(((mp_obj_t)o->globals), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2))); + + + el->value = ((mp_obj_t)o); + + + return ((mp_obj_t)o); +} + +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) { + +# 128 "user/mpy/py/objmodule.c" 3 + (( +# 128 "user/mpy/py/objmodule.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_module))) +# 128 "user/mpy/py/objmodule.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objmodule.c", 128, __func__, +# 128 "user/mpy/py/objmodule.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_module)" +# 128 "user/mpy/py/objmodule.c" 3 + )) +# 128 "user/mpy/py/objmodule.c" + ; + mp_obj_module_t *self = ((void*)self_in); + return self->globals; +} + + + + +static const mp_rom_map_elem_t mp_builtin_module_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___main__)) << 2) | 2)), (&mp_module___main__) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_builtins)) << 2) | 2)), (&mp_module_builtins) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_micropython)) << 2) | 2)), (&mp_module_micropython) }, +# 227 "user/mpy/py/objmodule.c" + +}; + +const mp_map_t mp_builtin_module_map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(mp_builtin_module_table) / sizeof((mp_builtin_module_table)[0])), .alloc = (sizeof(mp_builtin_module_table) / sizeof((mp_builtin_module_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)mp_builtin_module_table, }; +# 241 "user/mpy/py/objmodule.c" +mp_obj_t mp_module_get(qstr module_name) { + mp_map_t *mp_loaded_modules_map = &(mp_state_ctx.vm.mp_loaded_modules_dict).map; + + mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2)), MP_MAP_LOOKUP); + + if (el == +# 246 "user/mpy/py/objmodule.c" 3 4 + ((void *)0) +# 246 "user/mpy/py/objmodule.c" + ) { + + el = mp_map_lookup((mp_map_t*)&mp_builtin_module_map, ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2)), MP_MAP_LOOKUP); + if (el == +# 249 "user/mpy/py/objmodule.c" 3 4 + ((void *)0) +# 249 "user/mpy/py/objmodule.c" + ) { + return (((mp_obj_t)(void*)0)); + } + + if ((0)) { + + mp_obj_t dest[2]; + mp_load_method_maybe(el->value, MP_QSTR___init__, dest); + if (dest[0] != (((mp_obj_t)(void*)0))) { + mp_call_method_n_kw(0, 0, dest); + + mp_module_register(module_name, el->value); + } + } + } + + + return el->value; +} + +void mp_module_register(qstr qst, mp_obj_t module) { + mp_map_t *mp_loaded_modules_map = &(mp_state_ctx.vm.mp_loaded_modules_dict).map; + mp_map_lookup(mp_loaded_modules_map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; +} +# 1 "user/mpy/py/objobject.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objobject.c" +# 27 "user/mpy/py/objobject.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objobject.c" 2 + +# 1 "user/mpy/py/objtype.h" 1 +# 29 "user/mpy/py/objtype.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtype.h" 2 + + + +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 30 "user/mpy/py/objobject.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objobject.c" 2 + +typedef struct _mp_obj_object_t { + mp_obj_base_t base; +} mp_obj_object_t; + +static mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)args; + mp_arg_check_num(n_args, n_kw, 0, 0, +# 38 "user/mpy/py/objobject.c" 3 4 + 0 +# 38 "user/mpy/py/objobject.c" + ); + mp_obj_object_t *o = (((mp_obj_object_t*)(m_malloc(sizeof(mp_obj_object_t) * (1))))); + o->base.type = type; + return ((mp_obj_t)o); +} +# 74 "user/mpy/py/objobject.c" +const mp_obj_type_t mp_type_object = { + { &mp_type_type }, + .name = MP_QSTR_object, + .make_new = object_make_new, + + + +}; +# 1 "user/mpy/py/objpolyiter.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objpolyiter.c" +# 27 "user/mpy/py/objpolyiter.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objpolyiter.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 30 "user/mpy/py/objpolyiter.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/objpolyiter.c" 2 + + + + + + + +typedef struct _mp_obj_polymorph_iter_t { + mp_obj_base_t base; + mp_fun_1_t iternext; +} mp_obj_polymorph_iter_t; + +static mp_obj_t polymorph_it_iternext(mp_obj_t self_in) { + mp_obj_polymorph_iter_t *self = ((void*)self_in); + + return self->iternext(self_in); +} + +const mp_obj_type_t mp_type_polymorph_iter = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = polymorph_it_iternext, +}; +# 1 "user/mpy/py/objproperty.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objproperty.c" +# 27 "user/mpy/py/objproperty.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objproperty.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objproperty.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objproperty.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/objproperty.c" 2 +# 1 "user/mpy/py/objnone.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objnone.c" +# 27 "user/mpy/py/objnone.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objnone.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 30 "user/mpy/py/objnone.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 31 "user/mpy/py/objnone.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/objnone.c" 2 + +typedef struct _mp_obj_none_t { + mp_obj_base_t base; +} mp_obj_none_t; + +static void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)self_in; + if ((0) && kind == PRINT_JSON) { + mp_print_str(print, "null"); + } else { + mp_print_str(print, "None"); + } +} + +const mp_obj_type_t mp_type_NoneType = { + { &mp_type_type }, + .name = MP_QSTR_NoneType, + .print = none_print, + .unary_op = mp_generic_unary_op, +}; + +const mp_obj_none_t mp_const_none_obj = {{&mp_type_NoneType}}; +# 1 "user/mpy/py/objnamedtuple.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objnamedtuple.c" +# 28 "user/mpy/py/objnamedtuple.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/objnamedtuple.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objnamedtuple.c" 2 +# 1 "user/mpy/py/objtuple.h" 1 +# 29 "user/mpy/py/objtuple.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtuple.h" 2 + +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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 32 "user/mpy/py/objnamedtuple.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 32 "user/mpy/py/objexcept.h" +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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/objnamedtuple.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 34 "user/mpy/py/objnamedtuple.c" 2 +# 1 "user/mpy/py/objrange.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objrange.c" +# 27 "user/mpy/py/objrange.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objrange.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 30 "user/mpy/py/objrange.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 31 "user/mpy/py/objrange.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/objrange.c" 2 + + + + +typedef struct _mp_obj_range_it_t { + mp_obj_base_t base; + + mp_int_t cur; + mp_int_t stop; + mp_int_t step; +} mp_obj_range_it_t; + +static mp_obj_t range_it_iternext(mp_obj_t o_in) { + mp_obj_range_it_t *o = ((void*)o_in); + if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) { + mp_obj_t o_out = ((mp_obj_t)((((mp_uint_t)(o->cur)) << 1) | 1)); + o->cur += o->step; + return o_out; + } else { + return (((mp_obj_t)(void*)4)); + } +} + +static const mp_obj_type_t range_it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = range_it_iternext, +}; + +static mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) { + +# 63 "user/mpy/py/objrange.c" 3 + (( +# 63 "user/mpy/py/objrange.c" + sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t) +# 63 "user/mpy/py/objrange.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objrange.c", 63, __func__, +# 63 "user/mpy/py/objrange.c" + "sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 63 "user/mpy/py/objrange.c" 3 + )) +# 63 "user/mpy/py/objrange.c" + ; + mp_obj_range_it_t *o = (mp_obj_range_it_t*)iter_buf; + o->base.type = &range_it_type; + o->cur = cur; + o->stop = stop; + o->step = step; + return ((mp_obj_t)o); +} + + + + +typedef struct _mp_obj_range_t { + mp_obj_base_t base; + + mp_int_t start; + mp_int_t stop; + mp_int_t step; +} mp_obj_range_t; + +static void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_range_t *self = ((void*)self_in); + mp_printf(print, "range(" "%d" ", " "%d" "", self->start, self->stop); + if (self->step == 1) { + mp_print_str(print, ")"); + } else { + mp_printf(print, ", " "%d" ")", self->step); + } +} + +static mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 3, +# 95 "user/mpy/py/objrange.c" 3 4 + 0 +# 95 "user/mpy/py/objrange.c" + ); + + mp_obj_range_t *o = (((mp_obj_range_t*)(m_malloc(sizeof(mp_obj_range_t) * (1))))); + o->base.type = type; + o->start = 0; + o->step = 1; + + if (n_args == 1) { + o->stop = mp_obj_get_int(args[0]); + } else { + o->start = mp_obj_get_int(args[0]); + o->stop = mp_obj_get_int(args[1]); + if (n_args == 3) { + o->step = mp_obj_get_int(args[2]); + if (o->step == 0) { + mp_raise_ValueError("zero step"); + } + } + } + + return ((mp_obj_t)o); +} + +static mp_int_t range_len(mp_obj_range_t *self) { + + mp_int_t len = self->stop - self->start + self->step; + if (self->step > 0) { + len -= 1; + } else { + len += 1; + } + len = len / self->step; + if (len < 0) { + len = 0; + } + return len; +} + +static mp_obj_t range_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_range_t *self = ((void*)self_in); + mp_int_t len = range_len(self); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len > 0); + case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(len)) << 1) | 1)); + default: return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == (((mp_obj_t)(void*)8))) { + + mp_obj_range_t *self = ((void*)self_in); + mp_int_t len = range_len(self); +# 164 "user/mpy/py/objrange.c" + size_t index_val = mp_get_index(self->base.type, len, index, +# 164 "user/mpy/py/objrange.c" 3 4 + 0 +# 164 "user/mpy/py/objrange.c" + ); + return ((mp_obj_t)((((mp_uint_t)(self->start + index_val * self->step)) << 1) | 1)); + } else { + return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + mp_obj_range_t *o = ((void*)o_in); + return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf); +} + + + +static void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != (((mp_obj_t)(void*)0))) { + + return; + } + mp_obj_range_t *o = ((void*)o_in); + if (attr == MP_QSTR_start) { + dest[0] = mp_obj_new_int(o->start); + } else if (attr == MP_QSTR_stop) { + dest[0] = mp_obj_new_int(o->stop); + } else if (attr == MP_QSTR_step) { + dest[0] = mp_obj_new_int(o->step); + } +} + + +const mp_obj_type_t mp_type_range = { + { &mp_type_type }, + .name = MP_QSTR_range, + .print = range_print, + .make_new = range_make_new, + .unary_op = range_unary_op, + .subscr = range_subscr, + .getiter = range_getiter, + + .attr = range_attr, + +}; +# 1 "user/mpy/py/objreversed.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objreversed.c" +# 27 "user/mpy/py/objreversed.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objreversed.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objreversed.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objreversed.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/objreversed.c" 2 +# 1 "user/mpy/py/objset.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objset.c" +# 27 "user/mpy/py/objset.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 28 "user/mpy/py/objset.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/objset.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objset.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objset.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 35 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/objset.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 34 "user/mpy/py/objset.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 35 "user/mpy/py/objset.c" 2 +# 1 "user/mpy/py/objsingleton.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objsingleton.c" +# 27 "user/mpy/py/objsingleton.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objsingleton.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objsingleton.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objsingleton.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 32 "user/mpy/py/objsingleton.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/objsingleton.c" 2 + + + + +typedef struct _mp_obj_singleton_t { + mp_obj_base_t base; + qstr name; +} mp_obj_singleton_t; + +static void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_singleton_t *self = ((void*)self_in); + mp_printf(print, "%q", self->name); +} + +const mp_obj_type_t mp_type_singleton = { + { &mp_type_type }, + .name = MP_QSTR_, + .print = singleton_print, +}; + +const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis}; +# 1 "user/mpy/py/objslice.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objslice.c" +# 27 "user/mpy/py/objslice.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objslice.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objslice.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objslice.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 32 "user/mpy/py/objslice.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/objslice.c" 2 +# 1 "user/mpy/py/objstr.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objstr.c" +# 28 "user/mpy/py/objstr.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/objstr.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objstr.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objstr.c" 2 +# 1 "user/mpy/py/unicode.h" 1 +# 30 "user/mpy/py/unicode.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/unicode.h" 2 + +mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); +# 33 "user/mpy/py/objstr.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 29 "user/mpy/py/objstr.h" +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objstr.h" 2 + +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 34 "user/mpy/py/objstr.c" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 35 "user/mpy/py/objstr.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 36 "user/mpy/py/objstr.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + + +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/objstr.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 38 "user/mpy/py/objstr.c" 2 + +static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict); + +static mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); +static __attribute__((noreturn)) void bad_implicit_conversion(mp_obj_t self_in); + + + + +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 47 "user/mpy/py/objstr.c" 3 4 + _Bool +# 47 "user/mpy/py/objstr.c" + is_bytes) { + + +# 49 "user/mpy/py/objstr.c" 3 4 + _Bool +# 49 "user/mpy/py/objstr.c" + has_single_quote = +# 49 "user/mpy/py/objstr.c" 3 4 + 0 +# 49 "user/mpy/py/objstr.c" + ; + +# 50 "user/mpy/py/objstr.c" 3 4 + _Bool +# 50 "user/mpy/py/objstr.c" + has_double_quote = +# 50 "user/mpy/py/objstr.c" 3 4 + 0 +# 50 "user/mpy/py/objstr.c" + ; + for (const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) { + if (*s == '\'') { + has_single_quote = +# 53 "user/mpy/py/objstr.c" 3 4 + 1 +# 53 "user/mpy/py/objstr.c" + ; + } else if (*s == '"') { + has_double_quote = +# 55 "user/mpy/py/objstr.c" 3 4 + 1 +# 55 "user/mpy/py/objstr.c" + ; + } + } + int quote_char = '\''; + if (has_single_quote && !has_double_quote) { + quote_char = '"'; + } + mp_printf(print, "%c", quote_char); + for (const byte *s = str_data, *top = str_data + str_len; s < top; s++) { + if (*s == quote_char) { + mp_printf(print, "\\%c", quote_char); + } else if (*s == '\\') { + mp_print_str(print, "\\\\"); + } else if (*s >= 0x20 && *s != 0x7f && (!is_bytes || *s < 0x80)) { + + + + mp_printf(print, "%c", *s); + } else if (*s == '\n') { + mp_print_str(print, "\\n"); + } else if (*s == '\r') { + mp_print_str(print, "\\r"); + } else if (*s == '\t') { + mp_print_str(print, "\\t"); + } else { + mp_printf(print, "\\x%02x", *s); + } + } + mp_printf(print, "%c", quote_char); +} +# 112 "user/mpy/py/objstr.c" +static void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(self_in)) { str_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)self_in))->len; str_data = ((mp_obj_str_t*)((void*)self_in))->data; }; + + + + + + + + +# 121 "user/mpy/py/objstr.c" 3 4 + _Bool +# 121 "user/mpy/py/objstr.c" + is_bytes = (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_bytes))); + + + + if (kind == PRINT_RAW || (!(0) && kind == PRINT_STR && !is_bytes)) { + mp_printf(print, "%.*s", str_len, str_data); + } else { + if (is_bytes) { + mp_print_str(print, "b"); + } + mp_str_print_quoted(print, str_data, str_len, is_bytes); + } +} + +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + + + + + + + mp_arg_check_num(n_args, n_kw, 0, 3, +# 142 "user/mpy/py/objstr.c" 3 4 + 0 +# 142 "user/mpy/py/objstr.c" + ); + + switch (n_args) { + case 0: + return ((mp_obj_t)((((mp_uint_t)(MP_QSTR_)) << 2) | 2)); + + case 1: { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + mp_obj_print_helper(&print, args[0], PRINT_STR); + return mp_obj_new_str_from_vstr(type, &vstr); + } + + default: + + if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_bytes)))) { + const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str_data = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str_data = ((mp_obj_str_t*)((void*)args[0]))->data; }; + mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(args[0])) { str_hash = qstr_hash((((mp_uint_t)(args[0])) >> 2)); } else { str_hash = ((mp_obj_str_t*)((void*)args[0]))->hash; }; + if (str_hash == 0) { + str_hash = qstr_compute_hash(str_data, str_len); + } + mp_obj_str_t *o = ((void*)mp_obj_new_str_of_type(type, +# 164 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 164 "user/mpy/py/objstr.c" + , str_len)); + o->data = str_data; + o->hash = str_hash; + return ((mp_obj_t)o); + } else { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, (1)); + return mp_obj_new_str(bufinfo.buf, bufinfo.len, +# 171 "user/mpy/py/objstr.c" 3 4 + 0 +# 171 "user/mpy/py/objstr.c" + ); + } + } +} + +static mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + + + + + + (void)n_kw; + + + if (n_args == 0) { + return (((mp_obj_t)&mp_const_empty_bytes_obj)); + } + + if ((MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_str))))) { + if (n_args < 2 || n_args > 3) { + goto wrong_args; + } + const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str_data = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str_data = ((mp_obj_str_t*)((void*)args[0]))->data; }; + mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(args[0])) { str_hash = qstr_hash((((mp_uint_t)(args[0])) >> 2)); } else { str_hash = ((mp_obj_str_t*)((void*)args[0]))->hash; }; + if (str_hash == 0) { + str_hash = qstr_compute_hash(str_data, str_len); + } + mp_obj_str_t *o = ((void*)mp_obj_new_str_of_type(&mp_type_bytes, +# 200 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 200 "user/mpy/py/objstr.c" + , str_len)); + o->data = str_data; + o->hash = str_hash; + return ((mp_obj_t)o); + } + + if (n_args > 1) { + goto wrong_args; + } + + if (MP_OBJ_IS_SMALL_INT(args[0])) { + uint len = (((mp_int_t)(args[0])) >> 1); + vstr_t vstr; + vstr_init_len(&vstr, len); + memset(vstr.buf, 0, len); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); + } + + + mp_buffer_info_t bufinfo; + if (mp_get_buffer(args[0], &bufinfo, (1))) { + return mp_obj_new_str_of_type(&mp_type_bytes, bufinfo.buf, bufinfo.len); + } + + vstr_t vstr; + + mp_obj_t len_in = mp_obj_len_maybe(args[0]); + if (len_in == (((mp_obj_t)(void*)0))) { + vstr_init(&vstr, 16); + } else { + mp_int_t len = (((mp_int_t)(len_in)) >> 1); + vstr_init(&vstr, len); + } + + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(args[0], &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + mp_int_t val = mp_obj_get_int(item); + + if (val < 0 || val > 255) { + mp_raise_ValueError("bytes value out of range"); + } + + vstr_add_byte(&vstr, val); + } + + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); + +wrong_args: + mp_raise_TypeError("wrong number of arguments"); +} + + + +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction) { + if (hlen >= nlen) { + size_t str_index, str_index_end; + if (direction > 0) { + str_index = 0; + str_index_end = hlen - nlen; + } else { + str_index = hlen - nlen; + str_index_end = 0; + } + for (;;) { + if (memcmp(&haystack[str_index], needle, nlen) == 0) { + + return haystack + str_index; + } + if (str_index == str_index_end) { + + break; + } + str_index += direction; + } + } + return +# 277 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 277 "user/mpy/py/objstr.c" + ; +} + + + + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + + if (op == MP_BINARY_OP_MODULO) { + mp_obj_t *args = &rhs_in; + size_t n_args = 1; + mp_obj_t dict = (((mp_obj_t)(void*)0)); + if ((MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_tuple)))) { + + mp_obj_tuple_get(rhs_in, &n_args, &args); + } else if ((MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_dict)))) { + dict = rhs_in; + } + return str_modulo_format(lhs_in, n_args, args, dict); + } + + + mp_obj_type_t *lhs_type = mp_obj_get_type(lhs_in); + const byte *lhs_data; size_t lhs_len; if (MP_OBJ_IS_QSTR(lhs_in)) { lhs_data = qstr_data((((mp_uint_t)(lhs_in)) >> 2), &lhs_len); } else { lhs_len = ((mp_obj_str_t*)((void*)lhs_in))->len; lhs_data = ((mp_obj_str_t*)((void*)lhs_in))->data; }; + + + if (op == MP_BINARY_OP_MULTIPLY) { + mp_int_t n; + if (!mp_obj_get_int_maybe(rhs_in, &n)) { + return (((mp_obj_t)(void*)0)); + } + if (n <= 0) { + if (lhs_type == &mp_type_str) { + return ((mp_obj_t)((((mp_uint_t)(MP_QSTR_)) << 2) | 2)); + } else { + return (((mp_obj_t)&mp_const_empty_bytes_obj)); + } + } + vstr_t vstr; + vstr_init_len(&vstr, lhs_len * n); + mp_seq_multiply(lhs_data, sizeof(*lhs_data), lhs_len, n, vstr.buf); + return mp_obj_new_str_from_vstr(lhs_type, &vstr); + } +# 336 "user/mpy/py/objstr.c" + const byte *rhs_data; + size_t rhs_len; + if (lhs_type == mp_obj_get_type(rhs_in)) { + const byte *rhs_data_; size_t rhs_len_; if (MP_OBJ_IS_QSTR(rhs_in)) { rhs_data_ = qstr_data((((mp_uint_t)(rhs_in)) >> 2), &rhs_len_); } else { rhs_len_ = ((mp_obj_str_t*)((void*)rhs_in))->len; rhs_data_ = ((mp_obj_str_t*)((void*)rhs_in))->data; }; + rhs_data = rhs_data_; + rhs_len = rhs_len_; + } else if (lhs_type == &mp_type_bytes) { + mp_buffer_info_t bufinfo; + if (!mp_get_buffer(rhs_in, &bufinfo, (1))) { + return (((mp_obj_t)(void*)0)); + } + rhs_data = bufinfo.buf; + rhs_len = bufinfo.len; + } else { + + + bad_implicit_conversion(rhs_in); + } + + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: { + if (lhs_len == 0 && mp_obj_get_type(rhs_in) == lhs_type) { + return rhs_in; + } + if (rhs_len == 0) { + return lhs_in; + } + + vstr_t vstr; + vstr_init_len(&vstr, lhs_len + rhs_len); + memcpy(vstr.buf, lhs_data, lhs_len); + memcpy(vstr.buf + lhs_len, rhs_data, rhs_len); + return mp_obj_new_str_from_vstr(lhs_type, &vstr); + } + + case MP_BINARY_OP_IN: + + return mp_obj_new_bool(find_subbytes(lhs_data, lhs_len, rhs_data, rhs_len, 1) != +# 374 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 374 "user/mpy/py/objstr.c" + ); + + + case MP_BINARY_OP_EQUAL: + case MP_BINARY_OP_LESS: + case MP_BINARY_OP_LESS_EQUAL: + case MP_BINARY_OP_MORE: + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_data, lhs_len, rhs_data, rhs_len)); + } + + return (((mp_obj_t)(void*)0)); +} + + + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 391 "user/mpy/py/objstr.c" 3 4 + _Bool +# 391 "user/mpy/py/objstr.c" + is_slice) { + size_t index_val = mp_get_index(type, self_len, index, is_slice); + return self_data + index_val; +} + + + +static mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + const byte *self_data; size_t self_len; if (MP_OBJ_IS_QSTR(self_in)) { self_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &self_len); } else { self_len = ((mp_obj_str_t*)((void*)self_in))->len; self_data = ((mp_obj_str_t*)((void*)self_in))->data; }; + if (value == (((mp_obj_t)(void*)8))) { +# 412 "user/mpy/py/objstr.c" + size_t index_val = mp_get_index(type, self_len, index, +# 412 "user/mpy/py/objstr.c" 3 4 + 0 +# 412 "user/mpy/py/objstr.c" + ); + + if ((0) || type == &mp_type_bytes) { + return ((mp_obj_t)((((mp_uint_t)(self_data[index_val])) << 1) | 1)); + } else { + return mp_obj_new_str((char*)&self_data[index_val], 1, +# 417 "user/mpy/py/objstr.c" 3 4 + 1 +# 417 "user/mpy/py/objstr.c" + ); + } + } else { + return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { + +# 425 "user/mpy/py/objstr.c" 3 + (( +# 425 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op)) +# 425 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 425, __func__, +# 425 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op))" +# 425 "user/mpy/py/objstr.c" 3 + )) +# 425 "user/mpy/py/objstr.c" + ; + const mp_obj_type_t *self_type = mp_obj_get_type(self_in); + + + const byte *sep_str; size_t sep_len; if (MP_OBJ_IS_QSTR(self_in)) { sep_str = qstr_data((((mp_uint_t)(self_in)) >> 2), &sep_len); } else { sep_len = ((mp_obj_str_t*)((void*)self_in))->len; sep_str = ((mp_obj_str_t*)((void*)self_in))->data; }; + + + size_t seq_len; + mp_obj_t *seq_items; + + if (!(MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_list))) && !(MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_tuple)))) { + + + arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); + } + mp_obj_get_array(arg, &seq_len, &seq_items); + + + size_t required_len = 0; + for (size_t i = 0; i < seq_len; i++) { + if (mp_obj_get_type(seq_items[i]) != self_type) { + mp_raise_TypeError( + "join expects a list of str/bytes objects consistent with self object"); + } + if (i > 0) { + required_len += sep_len; + } + size_t l; if (MP_OBJ_IS_QSTR(seq_items[i])) { l = qstr_len((((mp_uint_t)(seq_items[i])) >> 2)); } else { l = ((mp_obj_str_t*)((void*)seq_items[i]))->len; }; + required_len += l; + } + + + vstr_t vstr; + vstr_init_len(&vstr, required_len); + byte *data = (byte*)vstr.buf; + for (size_t i = 0; i < seq_len; i++) { + if (i > 0) { + memcpy(data, sep_str, sep_len); + data += sep_len; + } + const byte *s; size_t l; if (MP_OBJ_IS_QSTR(seq_items[i])) { s = qstr_data((((mp_uint_t)(seq_items[i])) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)seq_items[i]))->len; s = ((mp_obj_str_t*)((void*)seq_items[i]))->data; }; + memcpy(data, s, l); + data += l; + } + + + return mp_obj_new_str_from_vstr(self_type, &vstr); +} +const mp_obj_fun_builtin_fixed_t str_join_obj = {{&mp_type_fun_builtin_2}, .fun._2 = str_join}; + +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + mp_int_t splits = -1; + mp_obj_t sep = (((mp_obj_t)&mp_const_none_obj)); + if (n_args > 1) { + sep = args[1]; + if (n_args > 2) { + splits = mp_obj_get_int(args[2]); + } + } + + mp_obj_t res = mp_obj_new_list(0, +# 486 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 486 "user/mpy/py/objstr.c" + ); + const byte *s; size_t len; if (MP_OBJ_IS_QSTR(args[0])) { s = qstr_data((((mp_uint_t)(args[0])) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)args[0]))->len; s = ((mp_obj_str_t*)((void*)args[0]))->data; }; + const byte *top = s + len; + + if (sep == (((mp_obj_t)&mp_const_none_obj))) { + + + + while (s < top && unichar_isspace(*s)) s++; + while (s < top && splits != 0) { + const byte *start = s; + while (s < top && !unichar_isspace(*s)) s++; + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); + if (s >= top) { + break; + } + while (s < top && unichar_isspace(*s)) s++; + if (splits > 0) { + splits--; + } + } + + if (s < top) { + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, s, top - s)); + } + + } else { + + if (mp_obj_get_type(sep) != self_type) { + bad_implicit_conversion(sep); + } + + size_t sep_len; + const char *sep_str = mp_obj_str_get_data(sep, &sep_len); + + if (sep_len == 0) { + mp_raise_ValueError("empty separator"); + } + + for (;;) { + const byte *start = s; + for (;;) { + if (splits == 0 || s + sep_len > top) { + s = top; + break; + } else if (memcmp(s, sep_str, sep_len) == 0) { + break; + } + s++; + } + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); + if (s >= top) { + break; + } + s += sep_len; + if (splits > 0) { + splits--; + } + } + } + + return res; +} +const mp_obj_fun_builtin_var_t str_split_obj = {{&mp_type_fun_builtin_var}, +# 549 "user/mpy/py/objstr.c" 3 4 +0 +# 549 "user/mpy/py/objstr.c" +, 1, 3, .fun.var = mp_obj_str_split}; +# 598 "user/mpy/py/objstr.c" +static mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) { + if (n_args < 3) { + + + return mp_obj_str_split(n_args, args); + } + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + mp_obj_t sep = args[1]; + const byte *s; size_t len; if (MP_OBJ_IS_QSTR(args[0])) { s = qstr_data((((mp_uint_t)(args[0])) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)args[0]))->len; s = ((mp_obj_str_t*)((void*)args[0]))->data; }; + + mp_int_t splits = mp_obj_get_int(args[2]); + if (splits < 0) { + + return mp_obj_str_split(n_args, args); + } + + mp_int_t org_splits = splits; + + + mp_obj_list_t *res = ((void*)mp_obj_new_list(splits + 1, +# 617 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 617 "user/mpy/py/objstr.c" + )); + mp_int_t idx = splits; + + if (sep == (((mp_obj_t)&mp_const_none_obj))) { + mp_raise_NotImplementedError("rsplit(None,n)"); + } else { + size_t sep_len; + const char *sep_str = mp_obj_str_get_data(sep, &sep_len); + + if (sep_len == 0) { + mp_raise_ValueError("empty separator"); + } + + const byte *beg = s; + const byte *last = s + len; + for (;;) { + s = last - sep_len; + for (;;) { + if (splits == 0 || s < beg) { + break; + } else if (memcmp(s, sep_str, sep_len) == 0) { + break; + } + s--; + } + if (s < beg || splits == 0) { + res->items[idx] = mp_obj_new_str_of_type(self_type, beg, last - beg); + break; + } + res->items[idx--] = mp_obj_new_str_of_type(self_type, s + sep_len, last - s - sep_len); + last = s; + if (splits > 0) { + splits--; + } + } + if (idx != 0) { + + size_t used = org_splits + 1 - idx; + memmove(res->items, &res->items[idx], used * sizeof(mp_obj_t)); + memset((byte*)(res->items) + (used) * (sizeof(*res->items)), 0, ((res->alloc) - (used)) * (sizeof(*res->items))); + res->len = used; + } + } + + return ((mp_obj_t)res); +} +const mp_obj_fun_builtin_var_t str_rsplit_obj = {{&mp_type_fun_builtin_var}, +# 663 "user/mpy/py/objstr.c" 3 4 +0 +# 663 "user/mpy/py/objstr.c" +, 1, 3, .fun.var = str_rsplit}; + +static mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, +# 665 "user/mpy/py/objstr.c" 3 4 + _Bool +# 665 "user/mpy/py/objstr.c" + is_index) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + +# 667 "user/mpy/py/objstr.c" 3 + (( +# 667 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) +# 667 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 667, __func__, +# 667 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" +# 667 "user/mpy/py/objstr.c" 3 + )) +# 667 "user/mpy/py/objstr.c" + ; + + + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + + const byte *haystack; size_t haystack_len; if (MP_OBJ_IS_QSTR(args[0])) { haystack = qstr_data((((mp_uint_t)(args[0])) >> 2), &haystack_len); } else { haystack_len = ((mp_obj_str_t*)((void*)args[0]))->len; haystack = ((mp_obj_str_t*)((void*)args[0]))->data; }; + const byte *needle; size_t needle_len; if (MP_OBJ_IS_QSTR(args[1])) { needle = qstr_data((((mp_uint_t)(args[1])) >> 2), &needle_len); } else { needle_len = ((mp_obj_str_t*)((void*)args[1]))->len; needle = ((mp_obj_str_t*)((void*)args[1]))->data; }; + + const byte *start = haystack; + const byte *end = haystack + haystack_len; + if (n_args >= 3 && args[2] != (((mp_obj_t)&mp_const_none_obj))) { + start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], +# 680 "user/mpy/py/objstr.c" 3 4 + 1 +# 680 "user/mpy/py/objstr.c" + ); + } + if (n_args >= 4 && args[3] != (((mp_obj_t)&mp_const_none_obj))) { + end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], +# 683 "user/mpy/py/objstr.c" 3 4 + 1 +# 683 "user/mpy/py/objstr.c" + ); + } + + const byte *p = find_subbytes(start, end - start, needle, needle_len, direction); + if (p == +# 687 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 687 "user/mpy/py/objstr.c" + ) { + + if (is_index) { + mp_raise_ValueError("substring not found"); + } else { + return ((mp_obj_t)((((mp_uint_t)(-1)) << 1) | 1)); + } + } else { + + + + + + + return ((mp_obj_t)((((mp_uint_t)(p - haystack)) << 1) | 1)); + } +} + +static mp_obj_t str_find(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, 1, +# 706 "user/mpy/py/objstr.c" 3 4 + 0 +# 706 "user/mpy/py/objstr.c" + ); +} +const mp_obj_fun_builtin_var_t str_find_obj = {{&mp_type_fun_builtin_var}, +# 708 "user/mpy/py/objstr.c" 3 4 +0 +# 708 "user/mpy/py/objstr.c" +, 2, 4, .fun.var = str_find}; + +static mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, -1, +# 711 "user/mpy/py/objstr.c" 3 4 + 0 +# 711 "user/mpy/py/objstr.c" + ); +} +const mp_obj_fun_builtin_var_t str_rfind_obj = {{&mp_type_fun_builtin_var}, +# 713 "user/mpy/py/objstr.c" 3 4 +0 +# 713 "user/mpy/py/objstr.c" +, 2, 4, .fun.var = str_rfind}; + +static mp_obj_t str_index(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, 1, +# 716 "user/mpy/py/objstr.c" 3 4 + 1 +# 716 "user/mpy/py/objstr.c" + ); +} +const mp_obj_fun_builtin_var_t str_index_obj = {{&mp_type_fun_builtin_var}, +# 718 "user/mpy/py/objstr.c" 3 4 +0 +# 718 "user/mpy/py/objstr.c" +, 2, 4, .fun.var = str_index}; + +static mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, -1, +# 721 "user/mpy/py/objstr.c" 3 4 + 1 +# 721 "user/mpy/py/objstr.c" + ); +} +const mp_obj_fun_builtin_var_t str_rindex_obj = {{&mp_type_fun_builtin_var}, +# 723 "user/mpy/py/objstr.c" 3 4 +0 +# 723 "user/mpy/py/objstr.c" +, 2, 4, .fun.var = str_rindex}; + + +static mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + const byte *str; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; + const byte *prefix; size_t prefix_len; if (MP_OBJ_IS_QSTR(args[1])) { prefix = qstr_data((((mp_uint_t)(args[1])) >> 2), &prefix_len); } else { prefix_len = ((mp_obj_str_t*)((void*)args[1]))->len; prefix = ((mp_obj_str_t*)((void*)args[1]))->data; }; + const byte *start = str; + if (n_args > 2) { + start = str_index_to_ptr(self_type, str, str_len, args[2], +# 732 "user/mpy/py/objstr.c" 3 4 + 1 +# 732 "user/mpy/py/objstr.c" + ); + } + if (prefix_len + (start - str) > str_len) { + return (((mp_obj_t)&mp_const_false_obj)); + } + return mp_obj_new_bool(memcmp(start, prefix, prefix_len) == 0); +} +const mp_obj_fun_builtin_var_t str_startswith_obj = {{&mp_type_fun_builtin_var}, +# 739 "user/mpy/py/objstr.c" 3 4 +0 +# 739 "user/mpy/py/objstr.c" +, 2, 3, .fun.var = str_startswith}; + +static mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) { + const byte *str; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; + const byte *suffix; size_t suffix_len; if (MP_OBJ_IS_QSTR(args[1])) { suffix = qstr_data((((mp_uint_t)(args[1])) >> 2), &suffix_len); } else { suffix_len = ((mp_obj_str_t*)((void*)args[1]))->len; suffix = ((mp_obj_str_t*)((void*)args[1]))->data; }; + if (n_args > 2) { + mp_raise_NotImplementedError("start/end indices"); + } + + if (suffix_len > str_len) { + return (((mp_obj_t)&mp_const_false_obj)); + } + return mp_obj_new_bool(memcmp(str + (str_len - suffix_len), suffix, suffix_len) == 0); +} +const mp_obj_fun_builtin_var_t str_endswith_obj = {{&mp_type_fun_builtin_var}, +# 753 "user/mpy/py/objstr.c" 3 4 +0 +# 753 "user/mpy/py/objstr.c" +, 2, 3, .fun.var = str_endswith}; + +enum { LSTRIP, RSTRIP, STRIP }; + +static mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) { + +# 758 "user/mpy/py/objstr.c" 3 + (( +# 758 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) +# 758 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 758, __func__, +# 758 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" +# 758 "user/mpy/py/objstr.c" 3 + )) +# 758 "user/mpy/py/objstr.c" + ; + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + + const byte *chars_to_del; + uint chars_to_del_len; + static const byte whitespace[] = " \t\n\r\v\f"; + + if (n_args == 1) { + chars_to_del = whitespace; + chars_to_del_len = sizeof(whitespace); + } else { + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + const byte *s; size_t l; if (MP_OBJ_IS_QSTR(args[1])) { s = qstr_data((((mp_uint_t)(args[1])) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)args[1]))->len; s = ((mp_obj_str_t*)((void*)args[1]))->data; }; + chars_to_del = s; + chars_to_del_len = l; + } + + const byte *orig_str; size_t orig_str_len; if (MP_OBJ_IS_QSTR(args[0])) { orig_str = qstr_data((((mp_uint_t)(args[0])) >> 2), &orig_str_len); } else { orig_str_len = ((mp_obj_str_t*)((void*)args[0]))->len; orig_str = ((mp_obj_str_t*)((void*)args[0]))->data; }; + + size_t first_good_char_pos = 0; + +# 780 "user/mpy/py/objstr.c" 3 4 + _Bool +# 780 "user/mpy/py/objstr.c" + first_good_char_pos_set = +# 780 "user/mpy/py/objstr.c" 3 4 + 0 +# 780 "user/mpy/py/objstr.c" + ; + size_t last_good_char_pos = 0; + size_t i = 0; + int delta = 1; + if (type == RSTRIP) { + i = orig_str_len - 1; + delta = -1; + } + for (size_t len = orig_str_len; len > 0; len--) { + if (find_subbytes(chars_to_del, chars_to_del_len, &orig_str[i], 1, 1) == +# 789 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 789 "user/mpy/py/objstr.c" + ) { + if (!first_good_char_pos_set) { + first_good_char_pos_set = +# 791 "user/mpy/py/objstr.c" 3 4 + 1 +# 791 "user/mpy/py/objstr.c" + ; + first_good_char_pos = i; + if (type == LSTRIP) { + last_good_char_pos = orig_str_len - 1; + break; + } else if (type == RSTRIP) { + first_good_char_pos = 0; + last_good_char_pos = i; + break; + } + } + last_good_char_pos = i; + } + i += delta; + } + + if (!first_good_char_pos_set) { + + if (self_type == &mp_type_str) { + return ((mp_obj_t)((((mp_uint_t)(MP_QSTR_)) << 2) | 2)); + } else { + return (((mp_obj_t)&mp_const_empty_bytes_obj)); + } + } + + +# 816 "user/mpy/py/objstr.c" 3 + (( +# 816 "user/mpy/py/objstr.c" + last_good_char_pos >= first_good_char_pos +# 816 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 816, __func__, +# 816 "user/mpy/py/objstr.c" + "last_good_char_pos >= first_good_char_pos" +# 816 "user/mpy/py/objstr.c" 3 + )) +# 816 "user/mpy/py/objstr.c" + ; + + size_t stripped_len = last_good_char_pos - first_good_char_pos + 1; + if (stripped_len == orig_str_len) { + + + +# 822 "user/mpy/py/objstr.c" 3 + (( +# 822 "user/mpy/py/objstr.c" + first_good_char_pos == 0 +# 822 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 822, __func__, +# 822 "user/mpy/py/objstr.c" + "first_good_char_pos == 0" +# 822 "user/mpy/py/objstr.c" 3 + )) +# 822 "user/mpy/py/objstr.c" + ; + return args[0]; + } + return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len); +} + +static mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) { + return str_uni_strip(STRIP, n_args, args); +} +const mp_obj_fun_builtin_var_t str_strip_obj = {{&mp_type_fun_builtin_var}, +# 831 "user/mpy/py/objstr.c" 3 4 +0 +# 831 "user/mpy/py/objstr.c" +, 1, 2, .fun.var = str_strip}; + +static mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) { + return str_uni_strip(LSTRIP, n_args, args); +} +const mp_obj_fun_builtin_var_t str_lstrip_obj = {{&mp_type_fun_builtin_var}, +# 836 "user/mpy/py/objstr.c" 3 4 +0 +# 836 "user/mpy/py/objstr.c" +, 1, 2, .fun.var = str_lstrip}; + +static mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) { + return str_uni_strip(RSTRIP, n_args, args); +} +const mp_obj_fun_builtin_var_t str_rstrip_obj = {{&mp_type_fun_builtin_var}, +# 841 "user/mpy/py/objstr.c" 3 4 +0 +# 841 "user/mpy/py/objstr.c" +, 1, 2, .fun.var = str_rstrip}; +# 863 "user/mpy/py/objstr.c" +static const char *str_to_int(const char *str, const char *top, int *num) { + if (str < top && '0' <= *str && *str <= '9') { + *num = 0; + do { + *num = *num * 10 + (*str - '0'); + str++; + } + while (str < top && '0' <= *str && *str <= '9'); + } + return str; +} + +static +# 875 "user/mpy/py/objstr.c" 3 4 + _Bool +# 875 "user/mpy/py/objstr.c" + isalignment(char ch) { + return ch && strchr("<>=^", ch) != +# 876 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 876 "user/mpy/py/objstr.c" + ; +} + +static +# 879 "user/mpy/py/objstr.c" 3 4 + _Bool +# 879 "user/mpy/py/objstr.c" + istype(char ch) { + return ch && strchr("bcdeEfFgGnosxX%", ch) != +# 880 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 880 "user/mpy/py/objstr.c" + ; +} + +static +# 883 "user/mpy/py/objstr.c" 3 4 + _Bool +# 883 "user/mpy/py/objstr.c" + arg_looks_integer(mp_obj_t arg) { + return (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_bool))) || (MP_OBJ_IS_SMALL_INT(arg) || (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int)))); +} + +static +# 887 "user/mpy/py/objstr.c" 3 4 + _Bool +# 887 "user/mpy/py/objstr.c" + arg_looks_numeric(mp_obj_t arg) { + return arg_looks_integer(arg) + + + + ; +} + +static mp_obj_t arg_as_int(mp_obj_t arg) { + + + + + + return arg; +} + + +static __attribute__((noreturn)) void terse_str_format_value_error(void) { + mp_raise_ValueError("bad format string"); +} + + + + + +static vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + + for (; str < top; str++) { + if (*str == '}') { + str++; + if (str < top && *str == '}') { + vstr_add_byte(&vstr, '}'); + continue; + } + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("single '}' encountered in format string"); + } + } + if (*str != '{') { + vstr_add_byte(&vstr, *str); + continue; + } + + str++; + if (str < top && *str == '{') { + vstr_add_byte(&vstr, '{'); + continue; + } + + + + const char *field_name = +# 944 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 944 "user/mpy/py/objstr.c" + ; + const char *field_name_top = +# 945 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 945 "user/mpy/py/objstr.c" + ; + char conversion = '\0'; + const char *format_spec = +# 947 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 947 "user/mpy/py/objstr.c" + ; + + if (str < top && *str != '}' && *str != '!' && *str != ':') { + field_name = (const char *)str; + while (str < top && *str != '}' && *str != '!' && *str != ':') { + ++str; + } + field_name_top = (const char *)str; + } + + + + if (str < top && *str == '!') { + str++; + if (str < top && (*str == 'r' || *str == 's')) { + conversion = *str++; + } else { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else if (((1)) == (2)) { + mp_raise_ValueError("bad conversion specifier"); + } else { + if (str >= top) { + mp_raise_ValueError( + "end of format while looking for conversion specifier"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown conversion specifier %c", *str))) + ; + } + } + } + } + + if (str < top && *str == ':') { + str++; + + + + + + if (*str != '}') { + format_spec = str; + for (int nest = 1; str < top;) { + if (*str == '{') { + ++nest; + } else if (*str == '}') { + if (--nest == 0) { + break; + } + } + ++str; + } + } + } + if (str >= top) { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("unmatched '{' in format"); + } + } + if (*str != '}') { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("expected ':' after format specifier"); + } + } + + mp_obj_t arg = (((mp_obj_t)&mp_const_none_obj)); + + if (field_name) { + int index = 0; + if (__builtin_expect((unichar_isdigit(*field_name)), 1)) { + if (*arg_i > 0) { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "can't switch from automatic field numbering to manual field specification"); + } + } + field_name = str_to_int(field_name, field_name_top, &index); + if ((uint)index >= n_args - 1) { + mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); + } + arg = args[index + 1]; + *arg_i = -1; + } else { + const char *lookup; + for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++); + mp_obj_t field_q = mp_obj_new_str(field_name, lookup - field_name, +# 1038 "user/mpy/py/objstr.c" 3 4 + 1 +# 1038 "user/mpy/py/objstr.c" + ); + field_name = lookup; + mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP); + if (key_elem == +# 1041 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1041 "user/mpy/py/objstr.c" + ) { + nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, field_q))); + } + arg = key_elem->value; + } + if (field_name < field_name_top) { + mp_raise_NotImplementedError("attributes not supported yet"); + } + } else { + if (*arg_i < 0) { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "can't switch from manual field specification to automatic field numbering"); + } + } + if ((uint)*arg_i >= n_args - 1) { + mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); + } + arg = args[(*arg_i) + 1]; + (*arg_i)++; + } + if (!format_spec && !conversion) { + conversion = 's'; + } + if (conversion) { + mp_print_kind_t print_kind; + if (conversion == 's') { + print_kind = PRINT_STR; + } else { + +# 1072 "user/mpy/py/objstr.c" 3 + (( +# 1072 "user/mpy/py/objstr.c" + conversion == 'r' +# 1072 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1072, __func__, +# 1072 "user/mpy/py/objstr.c" + "conversion == 'r'" +# 1072 "user/mpy/py/objstr.c" 3 + )) +# 1072 "user/mpy/py/objstr.c" + ; + print_kind = PRINT_REPR; + } + vstr_t arg_vstr; + mp_print_t arg_print; + vstr_init_print(&arg_vstr, 16, &arg_print); + mp_obj_print_helper(&arg_print, arg, print_kind); + arg = mp_obj_new_str_from_vstr(&mp_type_str, &arg_vstr); + } + + char fill = '\0'; + char align = '\0'; + int width = -1; + int precision = -1; + char type = '\0'; + int flags = 0; + + if (format_spec) { +# 1101 "user/mpy/py/objstr.c" + ; + vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs); + const char *s = vstr_null_terminated_str(&format_spec_vstr); + const char *stop = s + format_spec_vstr.len; + if (isalignment(*s)) { + align = *s++; + } else if (*s && isalignment(s[1])) { + fill = *s++; + align = *s++; + } + if (*s == '+' || *s == '-' || *s == ' ') { + if (*s == '+') { + flags |= (0x002); + } else if (*s == ' ') { + flags |= (0x004); + } + s++; + } + if (*s == '#') { + flags |= (0x010); + s++; + } + if (*s == '0') { + if (!align) { + align = '='; + } + if (!fill) { + fill = '0'; + } + } + s = str_to_int(s, stop, &width); + if (*s == ',') { + flags |= (0x020); + s++; + } + if (*s == '.') { + s++; + s = str_to_int(s, stop, &precision); + } + if (istype(*s)) { + type = *s++; + } + if (*s) { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("invalid format specifier"); + } + } + vstr_clear(&format_spec_vstr); + } + if (!align) { + if (arg_looks_numeric(arg)) { + align = '>'; + } else { + align = '<'; + } + } + if (!fill) { + fill = ' '; + } + + if (flags & ((0x002) | (0x004))) { + if (type == 's') { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("sign not allowed in string format specifier"); + } + } + if (type == 'c') { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "sign not allowed with integer format specifier 'c'"); + } + } + } + + switch (align) { + case '<': flags |= (0x001); break; + case '=': flags |= (0x040); break; + case '^': flags |= (0x080); break; + } + + if (arg_looks_integer(arg)) { + switch (type) { + case 'b': + mp_print_mp_int(&print, arg, 2, 'a', flags, fill, width, 0); + continue; + + case 'c': + { + char ch = mp_obj_get_int(arg); + mp_print_strn(&print, &ch, 1, flags, fill, width); + continue; + } + + case '\0': + case 'n': + case 'd': + mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0); + continue; + + case 'o': + if (flags & (0x010)) { + flags |= (0x200); + } + + mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, 0); + continue; + + case 'X': + case 'x': + mp_print_mp_int(&print, arg, 16, type - ('X' - 'A'), flags, fill, width, 0); + continue; + + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + case '%': + + + break; + + default: + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown format code '%c' for object of type '%s'", type, mp_obj_get_type_str(arg)))) + + ; + } + } + } + + + + if (arg_looks_numeric(arg)) { + if (!type) { +# 1273 "user/mpy/py/objstr.c" + type = 'g'; + } + if (type == 'n') { + type = 'g'; + } + + switch (type) { +# 1302 "user/mpy/py/objstr.c" + default: + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown format code '%c' for object of type 'float'", type, mp_obj_get_type_str(arg)))) + + ; + } + } + } else { + + + if (align == '=') { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "'=' alignment not allowed in string format specifier"); + } + } + + switch (type) { + case '\0': + case 's': { + size_t slen; + const char *s = mp_obj_str_get_data(arg, &slen); + if (precision < 0) { + precision = slen; + } + if (slen > (size_t)precision) { + slen = precision; + } + mp_print_strn(&print, s, slen, flags, fill, width); + break; + } + + default: + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown format code '%c' for object of type 'str'", type, mp_obj_get_type_str(arg)))) + + ; + } + } + } + } + + return vstr; +} + +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + +# 1354 "user/mpy/py/objstr.c" 3 + (( +# 1354 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) +# 1354 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1354, __func__, +# 1354 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" +# 1354 "user/mpy/py/objstr.c" 3 + )) +# 1354 "user/mpy/py/objstr.c" + ; + + const byte *str; size_t len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; + int arg_i = 0; + vstr_t vstr = mp_obj_str_format_helper((const char*)str, (const char*)str + len, &arg_i, n_args, args, kwargs); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} +const mp_obj_fun_builtin_var_t str_format_obj = {{&mp_type_fun_builtin_var}, +# 1361 "user/mpy/py/objstr.c" 3 4 +1 +# 1361 "user/mpy/py/objstr.c" +, 1, (0xffff), .fun.kw = mp_obj_str_format}; + +static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) { + +# 1364 "user/mpy/py/objstr.c" 3 + (( +# 1364 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(pattern) || (MP_OBJ_IS_OBJ(pattern) && ((mp_obj_base_t*)((void*)pattern))->type->binary_op == mp_obj_str_binary_op)) +# 1364 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1364, __func__, +# 1364 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(pattern) || (MP_OBJ_IS_OBJ(pattern) && ((mp_obj_base_t*)((void*)pattern))->type->binary_op == mp_obj_str_binary_op))" +# 1364 "user/mpy/py/objstr.c" 3 + )) +# 1364 "user/mpy/py/objstr.c" + ; + + const byte *str; size_t len; if (MP_OBJ_IS_QSTR(pattern)) { str = qstr_data((((mp_uint_t)(pattern)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)pattern))->len; str = ((mp_obj_str_t*)((void*)pattern))->data; }; + const byte *start_str = str; + +# 1368 "user/mpy/py/objstr.c" 3 4 + _Bool +# 1368 "user/mpy/py/objstr.c" + is_bytes = (MP_OBJ_IS_OBJ(pattern) && (((mp_obj_base_t*)((void*)pattern))->type == (&mp_type_bytes))); + size_t arg_i = 0; + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + + for (const byte *top = str + len; str < top; str++) { + mp_obj_t arg = (((mp_obj_t)(void*)0)); + if (*str != '%') { + vstr_add_byte(&vstr, *str); + continue; + } + if (++str >= top) { + goto incomplete_format; + } + if (*str == '%') { + vstr_add_byte(&vstr, '%'); + continue; + } + + + if (*str == '(') { + if (dict == (((mp_obj_t)(void*)0))) { + mp_raise_TypeError("format requires a dict"); + } + arg_i = 1; + const byte *key = ++str; + while (*str != ')') { + if (str >= top) { + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("incomplete format key"); + } + } + ++str; + } + mp_obj_t k_obj = mp_obj_new_str((const char*)key, str - key, +# 1405 "user/mpy/py/objstr.c" 3 4 + 1 +# 1405 "user/mpy/py/objstr.c" + ); + arg = mp_obj_dict_get(dict, k_obj); + str++; + } + + int flags = 0; + char fill = ' '; + int alt = 0; + while (str < top) { + if (*str == '-') flags |= (0x001); + else if (*str == '+') flags |= (0x002); + else if (*str == ' ') flags |= (0x004); + else if (*str == '#') alt = (0x010); + else if (*str == '0') { + flags |= (0x040); + fill = '0'; + } else break; + str++; + } + + int width = 0; + if (str < top) { + if (*str == '*') { + if (arg_i >= n_args) { + goto not_enough_args; + } + width = mp_obj_get_int(args[arg_i++]); + str++; + } else { + str = (const byte*)str_to_int((const char*)str, (const char*)top, &width); + } + } + int prec = -1; + if (str < top && *str == '.') { + if (++str < top) { + if (*str == '*') { + if (arg_i >= n_args) { + goto not_enough_args; + } + prec = mp_obj_get_int(args[arg_i++]); + str++; + } else { + prec = 0; + str = (const byte*)str_to_int((const char*)str, (const char*)top, &prec); + } + } + } + + if (str >= top) { +incomplete_format: + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("incomplete format"); + } + } + + + if (arg == (((mp_obj_t)(void*)0))) { + if (arg_i >= n_args) { +not_enough_args: + mp_raise_TypeError("not enough arguments for format string"); + } + arg = args[arg_i++]; + } + switch (*str) { + case 'c': + if ((MP_OBJ_IS_QSTR(arg) || (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_str))))) { + size_t slen; + const char *s = mp_obj_str_get_data(arg, &slen); + if (slen != 1) { + mp_raise_TypeError("%%c requires int or char"); + } + mp_print_strn(&print, s, 1, flags, ' ', width); + } else if (arg_looks_integer(arg)) { + char ch = mp_obj_get_int(arg); + mp_print_strn(&print, &ch, 1, flags, ' ', width); + } else { + mp_raise_TypeError("integer required"); + } + break; + + case 'd': + case 'i': + case 'u': + mp_print_mp_int(&print, arg_as_int(arg), 10, 'a', flags, fill, width, prec); + break; +# 1504 "user/mpy/py/objstr.c" + case 'o': + if (alt) { + flags |= ((0x010) | (0x200)); + } + mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, prec); + break; + + case 'r': + case 's': + { + vstr_t arg_vstr; + mp_print_t arg_print; + vstr_init_print(&arg_vstr, 16, &arg_print); + mp_print_kind_t print_kind = (*str == 'r' ? PRINT_REPR : PRINT_STR); + if (print_kind == PRINT_STR && is_bytes && (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_bytes)))) { + + + print_kind = PRINT_RAW; + } + mp_obj_print_helper(&arg_print, arg, print_kind); + uint vlen = arg_vstr.len; + if (prec < 0) { + prec = vlen; + } + if (vlen > (uint)prec) { + vlen = prec; + } + mp_print_strn(&print, arg_vstr.buf, vlen, flags, ' ', width); + vstr_clear(&arg_vstr); + break; + } + + case 'X': + case 'x': + mp_print_mp_int(&print, arg, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec); + break; + + default: + if (((1)) == (1)) { + terse_str_format_value_error(); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unsupported format character '%c' (0x%x) at index %d", *str, *str, str - start_str))) + + ; + } + } + } + + if (arg_i != n_args) { + mp_raise_TypeError("not all arguments converted during string formatting"); + } + + return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr); +} + + + +static mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) { + +# 1562 "user/mpy/py/objstr.c" 3 + (( +# 1562 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) +# 1562 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1562, __func__, +# 1562 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" +# 1562 "user/mpy/py/objstr.c" 3 + )) +# 1562 "user/mpy/py/objstr.c" + ; + + mp_int_t max_rep = -1; + if (n_args == 4) { + max_rep = mp_obj_get_int(args[3]); + if (max_rep == 0) { + return args[0]; + } else if (max_rep < 0) { + max_rep = -1; + } + } + + + + + + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + + if (mp_obj_get_type(args[2]) != self_type) { + bad_implicit_conversion(args[2]); + } + + + + const byte *str; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; + const byte *old; size_t old_len; if (MP_OBJ_IS_QSTR(args[1])) { old = qstr_data((((mp_uint_t)(args[1])) >> 2), &old_len); } else { old_len = ((mp_obj_str_t*)((void*)args[1]))->len; old = ((mp_obj_str_t*)((void*)args[1]))->data; }; + const byte *new; size_t new_len; if (MP_OBJ_IS_QSTR(args[2])) { new = qstr_data((((mp_uint_t)(args[2])) >> 2), &new_len); } else { new_len = ((mp_obj_str_t*)((void*)args[2]))->len; new = ((mp_obj_str_t*)((void*)args[2]))->data; }; + + + if (old_len > str_len) { + return args[0]; + } + + + byte *data = +# 1600 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1600 "user/mpy/py/objstr.c" + ; + vstr_t vstr; + + + + + for (;;) { + size_t replaced_str_index = 0; + size_t num_replacements_done = 0; + const byte *old_occurrence; + const byte *offset_ptr = str; + size_t str_len_remain = str_len; + if (old_len == 0) { + + + if (data != +# 1615 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1615 "user/mpy/py/objstr.c" + ) { + memcpy(data, new, new_len); + } + replaced_str_index += new_len; + num_replacements_done++; + } + while (num_replacements_done != (size_t)max_rep && str_len_remain > 0 && (old_occurrence = find_subbytes(offset_ptr, str_len_remain, old, old_len, 1)) != +# 1621 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1621 "user/mpy/py/objstr.c" + ) { + if (old_len == 0) { + old_occurrence += 1; + } + + if (data != +# 1626 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1626 "user/mpy/py/objstr.c" + ) { + memcpy(data + replaced_str_index, offset_ptr, old_occurrence - offset_ptr); + } + replaced_str_index += old_occurrence - offset_ptr; + + if (data != +# 1631 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1631 "user/mpy/py/objstr.c" + ) { + memcpy(data + replaced_str_index, new, new_len); + } + replaced_str_index += new_len; + offset_ptr = old_occurrence + old_len; + str_len_remain = str + str_len - offset_ptr; + num_replacements_done++; + } + + + if (data != +# 1641 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1641 "user/mpy/py/objstr.c" + ) { + memcpy(data + replaced_str_index, offset_ptr, str_len_remain); + } + replaced_str_index += str_len_remain; + + if (data == +# 1646 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1646 "user/mpy/py/objstr.c" + ) { + + if (num_replacements_done == 0) { + + return args[0]; + } else { + + vstr_init_len(&vstr, replaced_str_index); + data = (byte*)vstr.buf; + +# 1655 "user/mpy/py/objstr.c" 3 + (( +# 1655 "user/mpy/py/objstr.c" + data != +# 1655 "user/mpy/py/objstr.c" 3 4 + ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1655, __func__, +# 1655 "user/mpy/py/objstr.c" + "data != NULL" +# 1655 "user/mpy/py/objstr.c" 3 + )) +# 1655 "user/mpy/py/objstr.c" + ; + } + } else { + + break; + } + } + + return mp_obj_new_str_from_vstr(self_type, &vstr); +} +const mp_obj_fun_builtin_var_t str_replace_obj = {{&mp_type_fun_builtin_var}, +# 1665 "user/mpy/py/objstr.c" 3 4 +0 +# 1665 "user/mpy/py/objstr.c" +, 3, 4, .fun.var = str_replace}; + +static mp_obj_t str_count(size_t n_args, const mp_obj_t *args) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + +# 1669 "user/mpy/py/objstr.c" 3 + (( +# 1669 "user/mpy/py/objstr.c" + (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) +# 1669 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1669, __func__, +# 1669 "user/mpy/py/objstr.c" + "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" +# 1669 "user/mpy/py/objstr.c" 3 + )) +# 1669 "user/mpy/py/objstr.c" + ; + + + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + + const byte *haystack; size_t haystack_len; if (MP_OBJ_IS_QSTR(args[0])) { haystack = qstr_data((((mp_uint_t)(args[0])) >> 2), &haystack_len); } else { haystack_len = ((mp_obj_str_t*)((void*)args[0]))->len; haystack = ((mp_obj_str_t*)((void*)args[0]))->data; }; + const byte *needle; size_t needle_len; if (MP_OBJ_IS_QSTR(args[1])) { needle = qstr_data((((mp_uint_t)(args[1])) >> 2), &needle_len); } else { needle_len = ((mp_obj_str_t*)((void*)args[1]))->len; needle = ((mp_obj_str_t*)((void*)args[1]))->data; }; + + const byte *start = haystack; + const byte *end = haystack + haystack_len; + if (n_args >= 3 && args[2] != (((mp_obj_t)&mp_const_none_obj))) { + start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], +# 1682 "user/mpy/py/objstr.c" 3 4 + 1 +# 1682 "user/mpy/py/objstr.c" + ); + } + if (n_args >= 4 && args[3] != (((mp_obj_t)&mp_const_none_obj))) { + end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], +# 1685 "user/mpy/py/objstr.c" 3 4 + 1 +# 1685 "user/mpy/py/objstr.c" + ); + } + + + if (needle_len == 0) { + return ((mp_obj_t)((((mp_uint_t)(unichar_charlen((const char*)start, end - start) + 1)) << 1) | 1)); + } + + + mp_int_t num_occurrences = 0; + for (const byte *haystack_ptr = start; haystack_ptr + needle_len <= end;) { + if (memcmp(haystack_ptr, needle, needle_len) == 0) { + num_occurrences++; + haystack_ptr += needle_len; + } else { + haystack_ptr = utf8_next_char(haystack_ptr); + } + } + + return ((mp_obj_t)((((mp_uint_t)(num_occurrences)) << 1) | 1)); +} +const mp_obj_fun_builtin_var_t str_count_obj = {{&mp_type_fun_builtin_var}, +# 1706 "user/mpy/py/objstr.c" 3 4 +0 +# 1706 "user/mpy/py/objstr.c" +, 2, 4, .fun.var = str_count}; +# 1763 "user/mpy/py/objstr.c" +static mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) { + const byte *self_data; size_t self_len; if (MP_OBJ_IS_QSTR(self_in)) { self_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &self_len); } else { self_len = ((mp_obj_str_t*)((void*)self_in))->len; self_data = ((mp_obj_str_t*)((void*)self_in))->data; }; + vstr_t vstr; + vstr_init_len(&vstr, self_len); + byte *data = (byte*)vstr.buf; + for (size_t i = 0; i < self_len; i++) { + *data++ = op(*self_data++); + } + return mp_obj_new_str_from_vstr(mp_obj_get_type(self_in), &vstr); +} + +static mp_obj_t str_lower(mp_obj_t self_in) { + return str_caseconv(unichar_tolower, self_in); +} +const mp_obj_fun_builtin_fixed_t str_lower_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_lower}; + +static mp_obj_t str_upper(mp_obj_t self_in) { + return str_caseconv(unichar_toupper, self_in); +} +const mp_obj_fun_builtin_fixed_t str_upper_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_upper}; + +static mp_obj_t str_uni_istype( +# 1784 "user/mpy/py/objstr.c" 3 4 + _Bool +# 1784 "user/mpy/py/objstr.c" + (*f)(unichar), mp_obj_t self_in) { + const byte *self_data; size_t self_len; if (MP_OBJ_IS_QSTR(self_in)) { self_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &self_len); } else { self_len = ((mp_obj_str_t*)((void*)self_in))->len; self_data = ((mp_obj_str_t*)((void*)self_in))->data; }; + + if (self_len == 0) { + return (((mp_obj_t)&mp_const_false_obj)); + } + + if (f != unichar_isupper && f != unichar_islower) { + for (size_t i = 0; i < self_len; i++) { + if (!f(*self_data++)) { + return (((mp_obj_t)&mp_const_false_obj)); + } + } + } else { + +# 1798 "user/mpy/py/objstr.c" 3 4 + _Bool +# 1798 "user/mpy/py/objstr.c" + contains_alpha = +# 1798 "user/mpy/py/objstr.c" 3 4 + 0 +# 1798 "user/mpy/py/objstr.c" + ; + + for (size_t i = 0; i < self_len; i++) { + if (unichar_isalpha(*self_data++)) { + contains_alpha = +# 1802 "user/mpy/py/objstr.c" 3 4 + 1 +# 1802 "user/mpy/py/objstr.c" + ; + if (!f(*(self_data - 1))) { + return (((mp_obj_t)&mp_const_false_obj)); + } + } + } + + if (!contains_alpha) { + return (((mp_obj_t)&mp_const_false_obj)); + } + } + + return (((mp_obj_t)&mp_const_true_obj)); +} + +static mp_obj_t str_isspace(mp_obj_t self_in) { + return str_uni_istype(unichar_isspace, self_in); +} +const mp_obj_fun_builtin_fixed_t str_isspace_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isspace}; + +static mp_obj_t str_isalpha(mp_obj_t self_in) { + return str_uni_istype(unichar_isalpha, self_in); +} +const mp_obj_fun_builtin_fixed_t str_isalpha_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isalpha}; + +static mp_obj_t str_isdigit(mp_obj_t self_in) { + return str_uni_istype(unichar_isdigit, self_in); +} +const mp_obj_fun_builtin_fixed_t str_isdigit_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isdigit}; + +static mp_obj_t str_isupper(mp_obj_t self_in) { + return str_uni_istype(unichar_isupper, self_in); +} +const mp_obj_fun_builtin_fixed_t str_isupper_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isupper}; + +static mp_obj_t str_islower(mp_obj_t self_in) { + return str_uni_istype(unichar_islower, self_in); +} +const mp_obj_fun_builtin_fixed_t str_islower_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_islower}; +# 1872 "user/mpy/py/objstr.c" +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + if (flags == (1)) { + const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(self_in)) { str_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)self_in))->len; str_data = ((mp_obj_str_t*)((void*)self_in))->data; }; + bufinfo->buf = (void*)str_data; + bufinfo->len = str_len; + bufinfo->typecode = 'B'; + return 0; + } else { + + bufinfo->buf = +# 1881 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1881 "user/mpy/py/objstr.c" + ; + bufinfo->len = 0; + bufinfo->typecode = -1; + return 1; + } +} + +static const mp_rom_map_elem_t str8_locals_dict_table[] = { +# 1900 "user/mpy/py/objstr.c" + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_find)) << 2) | 2)), (&str_find_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rfind)) << 2) | 2)), (&str_rfind_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_index)) << 2) | 2)), (&str_index_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rindex)) << 2) | 2)), (&str_rindex_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_join)) << 2) | 2)), (&str_join_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_split)) << 2) | 2)), (&str_split_obj) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rsplit)) << 2) | 2)), (&str_rsplit_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_startswith)) << 2) | 2)), (&str_startswith_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_endswith)) << 2) | 2)), (&str_endswith_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_strip)) << 2) | 2)), (&str_strip_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_lstrip)) << 2) | 2)), (&str_lstrip_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rstrip)) << 2) | 2)), (&str_rstrip_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_format)) << 2) | 2)), (&str_format_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_replace)) << 2) | 2)), (&str_replace_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_count)) << 2) | 2)), (&str_count_obj) }, + + + + + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_lower)) << 2) | 2)), (&str_lower_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_upper)) << 2) | 2)), (&str_upper_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isspace)) << 2) | 2)), (&str_isspace_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isalpha)) << 2) | 2)), (&str_isalpha_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isdigit)) << 2) | 2)), (&str_isdigit_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isupper)) << 2) | 2)), (&str_isupper_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_islower)) << 2) | 2)), (&str_islower_obj) }, +}; + +static const mp_obj_dict_t str8_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(str8_locals_dict_table) / sizeof((str8_locals_dict_table)[0])), .alloc = (sizeof(str8_locals_dict_table) / sizeof((str8_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)str8_locals_dict_table, }, }; + + +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); + +const mp_obj_type_t mp_type_str = { + { &mp_type_type }, + .name = MP_QSTR_str, + .print = str_print, + .make_new = mp_obj_str_make_new, + .binary_op = mp_obj_str_binary_op, + .subscr = bytes_subscr, + .getiter = mp_obj_new_str_iterator, + .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, +}; + + + +const mp_obj_type_t mp_type_bytes = { + { &mp_type_type }, + .name = MP_QSTR_bytes, + .print = str_print, + .make_new = bytes_make_new, + .binary_op = mp_obj_str_binary_op, + .subscr = bytes_subscr, + .getiter = mp_obj_new_bytes_iterator, + .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, +}; + + +const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, +# 1966 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 1966 "user/mpy/py/objstr.c" + }; + + + +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len) { + mp_obj_str_t *o = (((mp_obj_str_t*)(m_malloc(sizeof(mp_obj_str_t) * (1))))); + o->base.type = type; + o->len = len; + if (data) { + o->hash = qstr_compute_hash(data, len); + byte *p = ((byte*)(m_malloc(sizeof(byte) * (len + 1)))); + o->data = p; + memcpy(p, data, len * sizeof(byte)); + p[len] = '\0'; + } + return ((mp_obj_t)o); +} + + + + +mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) { + + if (type == &mp_type_str) { + qstr q = qstr_find_strn(vstr->buf, vstr->len); + if (q != MP_QSTR_NULL) { + vstr_clear(vstr); + vstr->alloc = 0; + return ((mp_obj_t)((((mp_uint_t)(q)) << 2) | 2)); + } + } + + + mp_obj_str_t *o = (((mp_obj_str_t*)(m_malloc(sizeof(mp_obj_str_t) * (1))))); + o->base.type = type; + o->len = vstr->len; + o->hash = qstr_compute_hash((byte*)vstr->buf, vstr->len); + if (vstr->len + 1 == vstr->alloc) { + o->data = (byte*)vstr->buf; + } else { + o->data = (byte*)((char*)(m_realloc((vstr->buf), sizeof(char) * (vstr->len + 1)))); + } + ((byte*)o->data)[o->len] = '\0'; + vstr->buf = +# 2009 "user/mpy/py/objstr.c" 3 4 + ((void *)0) +# 2009 "user/mpy/py/objstr.c" + ; + vstr->alloc = 0; + return ((mp_obj_t)o); +} + +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 2014 "user/mpy/py/objstr.c" 3 4 + _Bool +# 2014 "user/mpy/py/objstr.c" + make_qstr_if_not_already) { + if (make_qstr_if_not_already) { + + return ((mp_obj_t)((((mp_uint_t)(qstr_from_strn(data, len))) << 2) | 2)); + } else { + qstr q = qstr_find_strn(data, len); + if (q != MP_QSTR_NULL) { + + return ((mp_obj_t)((((mp_uint_t)(q)) << 2) | 2)); + } else { + + return mp_obj_new_str_of_type(&mp_type_str, (const byte*)data, len); + } + } +} + +mp_obj_t mp_obj_str_intern(mp_obj_t str) { + const byte *data; size_t len; if (MP_OBJ_IS_QSTR(str)) { data = qstr_data((((mp_uint_t)(str)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)str))->len; data = ((mp_obj_str_t*)((void*)str))->data; }; + return ((mp_obj_t)((((mp_uint_t)(qstr_from_strn((const char*)data, len))) << 2) | 2)); +} + +mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) { + return mp_obj_new_str_of_type(&mp_type_bytes, data, len); +} + + +# 2039 "user/mpy/py/objstr.c" 3 4 +_Bool +# 2039 "user/mpy/py/objstr.c" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { + if (MP_OBJ_IS_QSTR(s1) && MP_OBJ_IS_QSTR(s2)) { + return s1 == s2; + } else { + mp_uint_t h1; if (MP_OBJ_IS_QSTR(s1)) { h1 = qstr_hash((((mp_uint_t)(s1)) >> 2)); } else { h1 = ((mp_obj_str_t*)((void*)s1))->hash; }; + mp_uint_t h2; if (MP_OBJ_IS_QSTR(s2)) { h2 = qstr_hash((((mp_uint_t)(s2)) >> 2)); } else { h2 = ((mp_obj_str_t*)((void*)s2))->hash; }; + + if (h1 != 0 && h2 != 0 && h1 != h2) { + return +# 2047 "user/mpy/py/objstr.c" 3 4 + 0 +# 2047 "user/mpy/py/objstr.c" + ; + } + const byte *d1; size_t l1; if (MP_OBJ_IS_QSTR(s1)) { d1 = qstr_data((((mp_uint_t)(s1)) >> 2), &l1); } else { l1 = ((mp_obj_str_t*)((void*)s1))->len; d1 = ((mp_obj_str_t*)((void*)s1))->data; }; + const byte *d2; size_t l2; if (MP_OBJ_IS_QSTR(s2)) { d2 = qstr_data((((mp_uint_t)(s2)) >> 2), &l2); } else { l2 = ((mp_obj_str_t*)((void*)s2))->len; d2 = ((mp_obj_str_t*)((void*)s2))->data; }; + if (l1 != l2) { + return +# 2052 "user/mpy/py/objstr.c" 3 4 + 0 +# 2052 "user/mpy/py/objstr.c" + ; + } + return memcmp(d1, d2, l1) == 0; + } +} + +static void bad_implicit_conversion(mp_obj_t self_in) { + if (((1)) == (1)) { + mp_raise_TypeError("can't convert to str implicitly"); + } else { + const qstr src_name = mp_obj_get_type(self_in)->name; + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't convert '%q' object to %q implicitly", src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str))) + + ; + } +} + + + +qstr mp_obj_str_get_qstr(mp_obj_t self_in) { + if (MP_OBJ_IS_QSTR(self_in)) { + return (((mp_uint_t)(self_in)) >> 2); + } else if ((MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_str)))) { + mp_obj_str_t *self = ((void*)self_in); + return qstr_from_strn((char*)self->data, self->len); + } else { + bad_implicit_conversion(self_in); + } +} + + + +const char *mp_obj_str_get_str(mp_obj_t self_in) { + if ((MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op))) { + const byte *s; size_t l; if (MP_OBJ_IS_QSTR(self_in)) { s = qstr_data((((mp_uint_t)(self_in)) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)self_in))->len; s = ((mp_obj_str_t*)((void*)self_in))->data; }; + (void)l; + return (const char*)s; + } else { + bad_implicit_conversion(self_in); + } +} + +const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len) { + if ((MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op))) { + const byte *s; size_t l; if (MP_OBJ_IS_QSTR(self_in)) { s = qstr_data((((mp_uint_t)(self_in)) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)self_in))->len; s = ((mp_obj_str_t*)((void*)self_in))->data; }; + *len = l; + return (const char*)s; + } else { + bad_implicit_conversion(self_in); + } +} +# 2118 "user/mpy/py/objstr.c" +typedef struct _mp_obj_str8_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t str; + size_t cur; +} mp_obj_str8_it_t; + + +static mp_obj_t str_it_iternext(mp_obj_t self_in) { + mp_obj_str8_it_t *self = ((void*)self_in); + const byte *str; size_t len; if (MP_OBJ_IS_QSTR(self->str)) { str = qstr_data((((mp_uint_t)(self->str)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)self->str))->len; str = ((mp_obj_str_t*)((void*)self->str))->data; }; + if (self->cur < len) { + mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, +# 2130 "user/mpy/py/objstr.c" 3 4 + 1 +# 2130 "user/mpy/py/objstr.c" + ); + self->cur += 1; + return o_out; + } else { + return (((mp_obj_t)(void*)4)); + } +} + +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { + +# 2139 "user/mpy/py/objstr.c" 3 + (( +# 2139 "user/mpy/py/objstr.c" + sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t) +# 2139 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 2139, __func__, +# 2139 "user/mpy/py/objstr.c" + "sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 2139 "user/mpy/py/objstr.c" 3 + )) +# 2139 "user/mpy/py/objstr.c" + ; + mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = str_it_iternext; + o->str = str; + o->cur = 0; + return ((mp_obj_t)o); +} + + +static mp_obj_t bytes_it_iternext(mp_obj_t self_in) { + mp_obj_str8_it_t *self = ((void*)self_in); + const byte *str; size_t len; if (MP_OBJ_IS_QSTR(self->str)) { str = qstr_data((((mp_uint_t)(self->str)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)self->str))->len; str = ((mp_obj_str_t*)((void*)self->str))->data; }; + if (self->cur < len) { + mp_obj_t o_out = ((mp_obj_t)((((mp_uint_t)(str[self->cur])) << 1) | 1)); + self->cur += 1; + return o_out; + } else { + return (((mp_obj_t)(void*)4)); + } +} + +mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { + +# 2162 "user/mpy/py/objstr.c" 3 + (( +# 2162 "user/mpy/py/objstr.c" + sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t) +# 2162 "user/mpy/py/objstr.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 2162, __func__, +# 2162 "user/mpy/py/objstr.c" + "sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 2162 "user/mpy/py/objstr.c" 3 + )) +# 2162 "user/mpy/py/objstr.c" + ; + mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = bytes_it_iternext; + o->str = str; + o->cur = 0; + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objstrunicode.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objstrunicode.c" +# 28 "user/mpy/py/objstrunicode.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/objstrunicode.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 30 "user/mpy/py/objstrunicode.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objstrunicode.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 29 "user/mpy/py/objstr.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objstr.h" 2 + +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 33 "user/mpy/py/objstrunicode.c" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 34 "user/mpy/py/objstrunicode.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/objstrunicode.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + + +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 36 "user/mpy/py/objstrunicode.c" 2 +# 1 "user/mpy/py/objstringio.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objstringio.c" +# 28 "user/mpy/py/objstringio.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/objstringio.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/objstringio.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/objstringio.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 29 "user/mpy/py/objstr.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objstr.h" 2 + +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 33 "user/mpy/py/objstringio.c" 2 +# 1 "user/mpy/py/objstringio.h" 1 +# 31 "user/mpy/py/objstringio.h" +typedef struct _mp_obj_stringio_t { + mp_obj_base_t base; + vstr_t *vstr; + + mp_uint_t pos; + + mp_obj_t ref_obj; +} mp_obj_stringio_t; +# 34 "user/mpy/py/objstringio.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 35 "user/mpy/py/objstringio.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 36 "user/mpy/py/objstringio.c" 2 +# 1 "user/mpy/py/objtuple.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objtuple.c" +# 27 "user/mpy/py/objtuple.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/objtuple.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objtuple.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/objtuple.c" 2 +# 1 "user/mpy/py/objtuple.h" 1 +# 29 "user/mpy/py/objtuple.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtuple.h" 2 + +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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 32 "user/mpy/py/objtuple.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/objtuple.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 32 "user/mpy/py/objexcept.h" +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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/objtuple.c" 2 + + + + +void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_tuple_t *o = ((void*)o_in); + if ((0) && kind == PRINT_JSON) { + mp_print_str(print, "["); + } else { + mp_print_str(print, "("); + kind = PRINT_REPR; + } + for (size_t i = 0; i < o->len; i++) { + if (i > 0) { + mp_print_str(print, ", "); + } + mp_obj_print_helper(print, o->items[i], kind); + } + if ((0) && kind == PRINT_JSON) { + mp_print_str(print, "]"); + } else { + if (o->len == 1) { + mp_print_str(print, ","); + } + mp_print_str(print, ")"); + } +} + +static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + mp_arg_check_num(n_args, n_kw, 0, 1, +# 65 "user/mpy/py/objtuple.c" 3 4 + 0 +# 65 "user/mpy/py/objtuple.c" + ); + + switch (n_args) { + case 0: + + return (((mp_obj_t)&mp_const_empty_tuple_obj)); + + case 1: + default: { + + if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_tuple)))) { + return args[0]; + } + + + + size_t alloc = 4; + size_t len = 0; + mp_obj_t *items = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (alloc)))); + + mp_obj_t iterable = mp_getiter(args[0], +# 85 "user/mpy/py/objtuple.c" 3 4 + ((void *)0) +# 85 "user/mpy/py/objtuple.c" + ); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + if (len >= alloc) { + items = ((mp_obj_t*)(m_realloc((items), sizeof(mp_obj_t) * (alloc * 2)))); + alloc *= 2; + } + items[len++] = item; + } + + mp_obj_t tuple = mp_obj_new_tuple(len, items); + ((void)(alloc), m_free(items)); + + return tuple; + } + } +} + + +static +# 104 "user/mpy/py/objtuple.c" 3 4 + _Bool +# 104 "user/mpy/py/objtuple.c" + tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { + + +# 106 "user/mpy/py/objtuple.c" 3 + (( +# 106 "user/mpy/py/objtuple.c" + mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter +# 106 "user/mpy/py/objtuple.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 106, __func__, +# 106 "user/mpy/py/objtuple.c" + "mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter" +# 106 "user/mpy/py/objtuple.c" 3 + )) +# 106 "user/mpy/py/objtuple.c" + ; + mp_obj_type_t *another_type = mp_obj_get_type(another_in); + mp_obj_tuple_t *self = ((void*)self_in); + if (another_type->getiter != mp_obj_tuple_getiter) { + + another_in = mp_instance_cast_to_native_base(another_in, ((mp_obj_t)&mp_type_tuple)); + if (another_in == (((mp_obj_t)(void*)0))) { + return +# 113 "user/mpy/py/objtuple.c" 3 4 + 0 +# 113 "user/mpy/py/objtuple.c" + ; + } + } + mp_obj_tuple_t *another = ((void*)another_in); + + return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); +} + +mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_tuple_t *self = ((void*)self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); + case MP_UNARY_OP_HASH: { + + mp_int_t hash = (mp_int_t)(((mp_obj_t)&mp_const_empty_tuple_obj)); + for (size_t i = 0; i < self->len; i++) { + hash += (((mp_int_t)(mp_unary_op(MP_UNARY_OP_HASH, self->items[i]))) >> 1); + } + return ((mp_obj_t)((((mp_uint_t)(hash)) << 1) | 1)); + } + case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(self->len)) << 1) | 1)); + default: return (((mp_obj_t)(void*)0)); + } +} + +mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + mp_obj_tuple_t *o = ((void*)lhs); + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: { + if (!mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(rhs)), ((mp_obj_t)&mp_type_tuple))) { + return (((mp_obj_t)(void*)0)); + } + mp_obj_tuple_t *p = ((void*)rhs); + mp_obj_tuple_t *s = ((void*)mp_obj_new_tuple(o->len + p->len, +# 147 "user/mpy/py/objtuple.c" 3 4 + ((void *)0) +# 147 "user/mpy/py/objtuple.c" + )); + { memcpy(s->items, o->items, (o->len) * sizeof(mp_obj_t)); memcpy(s->items + (o->len), p->items, (p->len) * sizeof(mp_obj_t)); }; + return ((mp_obj_t)s); + } + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: { + mp_int_t n; + if (!mp_obj_get_int_maybe(rhs, &n)) { + return (((mp_obj_t)(void*)0)); + } + if (n <= 0) { + return (((mp_obj_t)&mp_const_empty_tuple_obj)); + } + mp_obj_tuple_t *s = ((void*)mp_obj_new_tuple(o->len * n, +# 160 "user/mpy/py/objtuple.c" 3 4 + ((void *)0) +# 160 "user/mpy/py/objtuple.c" + )); + mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); + return ((mp_obj_t)s); + } + case MP_BINARY_OP_EQUAL: + case MP_BINARY_OP_LESS: + case MP_BINARY_OP_LESS_EQUAL: + case MP_BINARY_OP_MORE: + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(tuple_cmp_helper(op, lhs, rhs)); + + default: + return (((mp_obj_t)(void*)0)); + } +} + +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == (((mp_obj_t)(void*)8))) { + + mp_obj_tuple_t *self = ((void*)self_in); +# 191 "user/mpy/py/objtuple.c" + size_t index_value = mp_get_index(self->base.type, self->len, index, +# 191 "user/mpy/py/objtuple.c" 3 4 + 0 +# 191 "user/mpy/py/objtuple.c" + ); + return self->items[index_value]; + } else { + return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) { + +# 199 "user/mpy/py/objtuple.c" 3 + (( +# 199 "user/mpy/py/objtuple.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple))) +# 199 "user/mpy/py/objtuple.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 199, __func__, +# 199 "user/mpy/py/objtuple.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple)))" +# 199 "user/mpy/py/objtuple.c" 3 + )) +# 199 "user/mpy/py/objtuple.c" + ; + mp_obj_tuple_t *self = ((void*)self_in); + return mp_seq_count_obj(self->items, self->len, value); +} +static const mp_obj_fun_builtin_fixed_t tuple_count_obj = {{&mp_type_fun_builtin_2}, .fun._2 = tuple_count}; + +static mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) { + +# 206 "user/mpy/py/objtuple.c" 3 + (( +# 206 "user/mpy/py/objtuple.c" + (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_tuple))) +# 206 "user/mpy/py/objtuple.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 206, __func__, +# 206 "user/mpy/py/objtuple.c" + "(MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_tuple)))" +# 206 "user/mpy/py/objtuple.c" 3 + )) +# 206 "user/mpy/py/objtuple.c" + ; + mp_obj_tuple_t *self = ((void*)args[0]); + return mp_seq_index_obj(self->items, self->len, n_args, args); +} +static const mp_obj_fun_builtin_var_t tuple_index_obj = {{&mp_type_fun_builtin_var}, +# 210 "user/mpy/py/objtuple.c" 3 4 + 0 +# 210 "user/mpy/py/objtuple.c" + , 2, 4, .fun.var = tuple_index}; + +static const mp_rom_map_elem_t tuple_locals_dict_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_count)) << 2) | 2)), (&tuple_count_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_index)) << 2) | 2)), (&tuple_index_obj) }, +}; + +static const mp_obj_dict_t tuple_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(tuple_locals_dict_table) / sizeof((tuple_locals_dict_table)[0])), .alloc = (sizeof(tuple_locals_dict_table) / sizeof((tuple_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)tuple_locals_dict_table, }, }; + +const mp_obj_type_t mp_type_tuple = { + { &mp_type_type }, + .name = MP_QSTR_tuple, + .print = mp_obj_tuple_print, + .make_new = mp_obj_tuple_make_new, + .unary_op = mp_obj_tuple_unary_op, + .binary_op = mp_obj_tuple_binary_op, + .subscr = mp_obj_tuple_subscr, + .getiter = mp_obj_tuple_getiter, + .locals_dict = (mp_obj_dict_t*)&tuple_locals_dict, +}; + + +const mp_obj_tuple_t mp_const_empty_tuple_obj = {{&mp_type_tuple}, 0}; + +mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) { + if (n == 0) { + return (((mp_obj_t)&mp_const_empty_tuple_obj)); + } + mp_obj_tuple_t *o = ((mp_obj_tuple_t*)m_malloc(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t) * (n))); + o->base.type = &mp_type_tuple; + o->len = n; + if (items) { + for (size_t i = 0; i < n; i++) { + o->items[i] = items[i]; + } + } + return ((mp_obj_t)o); +} + +void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { + +# 250 "user/mpy/py/objtuple.c" 3 + (( +# 250 "user/mpy/py/objtuple.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple))) +# 250 "user/mpy/py/objtuple.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 250, __func__, +# 250 "user/mpy/py/objtuple.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)" +# 250 "user/mpy/py/objtuple.c" 3 + )) +# 250 "user/mpy/py/objtuple.c" + ; + mp_obj_tuple_t *self = ((void*)self_in); + *len = self->len; + *items = &self->items[0]; +} + +void mp_obj_tuple_del(mp_obj_t self_in) { + +# 257 "user/mpy/py/objtuple.c" 3 + (( +# 257 "user/mpy/py/objtuple.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple))) +# 257 "user/mpy/py/objtuple.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 257, __func__, +# 257 "user/mpy/py/objtuple.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)" +# 257 "user/mpy/py/objtuple.c" 3 + )) +# 257 "user/mpy/py/objtuple.c" + ; + mp_obj_tuple_t *self = ((void*)self_in); + ((void)(self->len), m_free(self)); +} + + + + +typedef struct _mp_obj_tuple_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_tuple_t *tuple; + size_t cur; +} mp_obj_tuple_it_t; + +static mp_obj_t tuple_it_iternext(mp_obj_t self_in) { + mp_obj_tuple_it_t *self = ((void*)self_in); + if (self->cur < self->tuple->len) { + mp_obj_t o_out = self->tuple->items[self->cur]; + self->cur += 1; + return o_out; + } else { + return (((mp_obj_t)(void*)4)); + } +} + +mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + +# 284 "user/mpy/py/objtuple.c" 3 + (( +# 284 "user/mpy/py/objtuple.c" + sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t) +# 284 "user/mpy/py/objtuple.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 284, __func__, +# 284 "user/mpy/py/objtuple.c" + "sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t)" +# 284 "user/mpy/py/objtuple.c" 3 + )) +# 284 "user/mpy/py/objtuple.c" + ; + mp_obj_tuple_it_t *o = (mp_obj_tuple_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = tuple_it_iternext; + o->tuple = ((void*)o_in); + o->cur = 0; + return ((mp_obj_t)o); +} +# 1 "user/mpy/py/objtype.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objtype.c" +# 28 "user/mpy/py/objtype.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/objtype.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/objtype.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/objtype.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/objtype.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 34 "user/mpy/py/objtype.c" 2 +# 1 "user/mpy/py/objtype.h" 1 +# 29 "user/mpy/py/objtype.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtype.h" 2 + + + +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 35 "user/mpy/py/objtype.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 36 "user/mpy/py/objtype.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/objtype.c" 2 +# 46 "user/mpy/py/objtype.c" +static mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +static mp_obj_t mp_obj_new_instance(const mp_obj_type_t *class, size_t subobjs) { + mp_obj_instance_t *o = ((mp_obj_instance_t*)m_malloc(sizeof(mp_obj_instance_t) + sizeof(mp_obj_t) * (subobjs))); + o->base.type = class; + mp_map_init(&o->members, 0); + memset((byte*)(o->subobj) + (0) * (sizeof(*o->subobj)), 0, ((subobjs) - (0)) * (sizeof(*o->subobj))); + return ((mp_obj_t)o); +} + +static int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) { + int count = 0; + for (;;) { + if (type == &mp_type_object) { + + return count; + } else if (((type)->make_new != mp_obj_instance_make_new)) { + + *last_native_base = type; + return count + 1; + } else if (type->parent == +# 69 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 69 "user/mpy/py/objtype.c" + ) { + + return count; + } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { + + const mp_obj_tuple_t *parent_tuple = type->parent; + const mp_obj_t *item = parent_tuple->items; + const mp_obj_t *top = item + parent_tuple->len; + for (; item < top; ++item) { + +# 78 "user/mpy/py/objtype.c" 3 + (( +# 78 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(*item) && (((mp_obj_base_t*)((void*)*item))->type == (&mp_type_type))) +# 78 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 78, __func__, +# 78 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(*item, &mp_type_type)" +# 78 "user/mpy/py/objtype.c" 3 + )) +# 78 "user/mpy/py/objtype.c" + ; + const mp_obj_type_t *bt = (const mp_obj_type_t *)((void*)*item); + count += instance_count_native_bases(bt, last_native_base); + } + return count; + } else { + + type = type->parent; + } + } +} +# 104 "user/mpy/py/objtype.c" +struct class_lookup_data { + mp_obj_instance_t *obj; + qstr attr; + size_t meth_offset; + mp_obj_t *dest; + +# 109 "user/mpy/py/objtype.c" 3 4 + _Bool +# 109 "user/mpy/py/objtype.c" + is_type; +}; + +static void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) { + +# 113 "user/mpy/py/objtype.c" 3 + (( +# 113 "user/mpy/py/objtype.c" + lookup->dest[0] == (((mp_obj_t)(void*)0)) +# 113 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 113, __func__, +# 113 "user/mpy/py/objtype.c" + "lookup->dest[0] == MP_OBJ_NULL" +# 113 "user/mpy/py/objtype.c" 3 + )) +# 113 "user/mpy/py/objtype.c" + ; + +# 114 "user/mpy/py/objtype.c" 3 + (( +# 114 "user/mpy/py/objtype.c" + lookup->dest[1] == (((mp_obj_t)(void*)0)) +# 114 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 114, __func__, +# 114 "user/mpy/py/objtype.c" + "lookup->dest[1] == MP_OBJ_NULL" +# 114 "user/mpy/py/objtype.c" 3 + )) +# 114 "user/mpy/py/objtype.c" + ; + for (;;) { + + + + + if (lookup->meth_offset != 0 && ((type)->make_new != mp_obj_instance_make_new)) { + if (*(void**)((char*)type + lookup->meth_offset) != +# 121 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 121 "user/mpy/py/objtype.c" + ) { + (void)0; + lookup->dest[0] = (((mp_obj_t)(void*)8)); + return; + } + } + + if (type->locals_dict != +# 128 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 128 "user/mpy/py/objtype.c" + ) { + + +# 130 "user/mpy/py/objtype.c" 3 + (( +# 130 "user/mpy/py/objtype.c" + type->locals_dict->base.type == &mp_type_dict +# 130 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 130, __func__, +# 130 "user/mpy/py/objtype.c" + "type->locals_dict->base.type == &mp_type_dict" +# 130 "user/mpy/py/objtype.c" 3 + )) +# 130 "user/mpy/py/objtype.c" + ; + mp_map_t *locals_map = &type->locals_dict->map; + mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(lookup->attr)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 133 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 133 "user/mpy/py/objtype.c" + ) { + if (lookup->is_type) { + + + const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj; + mp_convert_member_lookup((((mp_obj_t)(void*)0)), org_type, elem->value, lookup->dest); + } else { + mp_obj_instance_t *obj = lookup->obj; + mp_obj_t obj_obj; + if (obj != +# 142 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 142 "user/mpy/py/objtype.c" + && ((type)->make_new != mp_obj_instance_make_new) && type != &mp_type_object ) { + + obj_obj = obj->subobj[0]; + } else { + obj_obj = ((mp_obj_t)obj); + } + mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest); + } + + + + + + return; + } + } + + + + + if (lookup->obj != +# 162 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 162 "user/mpy/py/objtype.c" + && !lookup->is_type && ((type)->make_new != mp_obj_instance_make_new) && type != &mp_type_object ) { + mp_load_method_maybe(lookup->obj->subobj[0], lookup->attr, lookup->dest); + if (lookup->dest[0] != (((mp_obj_t)(void*)0))) { + return; + } + } + + + + if (type->parent == +# 171 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 171 "user/mpy/py/objtype.c" + ) { + return; + } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { + const mp_obj_tuple_t *parent_tuple = type->parent; + const mp_obj_t *item = parent_tuple->items; + const mp_obj_t *top = item + parent_tuple->len - 1; + for (; item < top; ++item) { + +# 178 "user/mpy/py/objtype.c" 3 + (( +# 178 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(*item) && (((mp_obj_base_t*)((void*)*item))->type == (&mp_type_type))) +# 178 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 178, __func__, +# 178 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(*item, &mp_type_type)" +# 178 "user/mpy/py/objtype.c" 3 + )) +# 178 "user/mpy/py/objtype.c" + ; + mp_obj_type_t *bt = (mp_obj_type_t*)((void*)*item); + if (bt == &mp_type_object) { + + continue; + } + mp_obj_class_lookup(lookup, bt); + if (lookup->dest[0] != (((mp_obj_t)(void*)0))) { + return; + } + } + + + +# 191 "user/mpy/py/objtype.c" 3 + (( +# 191 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(*item) && (((mp_obj_base_t*)((void*)*item))->type == (&mp_type_type))) +# 191 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 191, __func__, +# 191 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(*item, &mp_type_type)" +# 191 "user/mpy/py/objtype.c" 3 + )) +# 191 "user/mpy/py/objtype.c" + ; + type = (mp_obj_type_t*)((void*)*item); + } else { + type = type->parent; + } + if (type == &mp_type_object) { + + return; + } + } +} + +static void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_obj_instance_t *self = ((void*)self_in); + qstr meth = (kind == PRINT_STR) ? MP_QSTR___str__ : MP_QSTR___repr__; + mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = self, + .attr = meth, + .meth_offset = +# 210 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 210 "user/mpy/py/objtype.c" + mp_obj_type_t +# 210 "user/mpy/py/objtype.c" 3 4 + , +# 210 "user/mpy/py/objtype.c" + print +# 210 "user/mpy/py/objtype.c" 3 4 + ) +# 210 "user/mpy/py/objtype.c" + , + .dest = member, + .is_type = +# 212 "user/mpy/py/objtype.c" 3 4 + 0 +# 212 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == (((mp_obj_t)(void*)0)) && kind == PRINT_STR) { + + lookup.attr = MP_QSTR___repr__; + lookup.meth_offset = 0; + mp_obj_class_lookup(&lookup, self->base.type); + } + + if (member[0] == (((mp_obj_t)(void*)8))) { + + if ((mp_obj_get_type(self->subobj[0])->make_new == mp_obj_exception_make_new)) { + if (kind != PRINT_STR) { + mp_print_str(print, qstr_str(self->base.type->name)); + } + mp_obj_print_helper(print, self->subobj[0], kind | PRINT_EXC_SUBCLASS); + } else { + mp_obj_print_helper(print, self->subobj[0], kind); + } + return; + } + + if (member[0] != (((mp_obj_t)(void*)0))) { + mp_obj_t r = mp_call_function_1(member[0], self_in); + mp_obj_print_helper(print, r, PRINT_STR); + return; + } + + + mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self); +} + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { + +# 246 "user/mpy/py/objtype.c" 3 + (( +# 246 "user/mpy/py/objtype.c" + ((self)->make_new == mp_obj_instance_make_new) +# 246 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 246, __func__, +# 246 "user/mpy/py/objtype.c" + "mp_obj_is_instance_type(self)" +# 246 "user/mpy/py/objtype.c" 3 + )) +# 246 "user/mpy/py/objtype.c" + ; + + const mp_obj_type_t *native_base; + size_t num_native_bases = instance_count_native_bases(self, &native_base); + +# 250 "user/mpy/py/objtype.c" 3 + (( +# 250 "user/mpy/py/objtype.c" + num_native_bases < 2 +# 250 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 250, __func__, +# 250 "user/mpy/py/objtype.c" + "num_native_bases < 2" +# 250 "user/mpy/py/objtype.c" 3 + )) +# 250 "user/mpy/py/objtype.c" + ; + + mp_obj_instance_t *o = ((void*)mp_obj_new_instance(self, num_native_bases)); + + + + + + if (n_args == 1 && *args == (((mp_obj_t)(void*)8))) { + return ((mp_obj_t)o); + } + + + mp_obj_t init_fn[2] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = +# 265 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 265 "user/mpy/py/objtype.c" + , + .attr = MP_QSTR___new__, + .meth_offset = +# 267 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 267 "user/mpy/py/objtype.c" + mp_obj_type_t +# 267 "user/mpy/py/objtype.c" 3 4 + , +# 267 "user/mpy/py/objtype.c" + make_new +# 267 "user/mpy/py/objtype.c" 3 4 + ) +# 267 "user/mpy/py/objtype.c" + , + .dest = init_fn, + .is_type = +# 269 "user/mpy/py/objtype.c" 3 4 + 0 +# 269 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self); + + mp_obj_t new_ret = ((mp_obj_t)o); + if (init_fn[0] == (((mp_obj_t)(void*)8))) { + + + o->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args); + } else if (init_fn[0] != (((mp_obj_t)(void*)0))) { + + if (n_args == 0 && n_kw == 0) { + mp_obj_t args2[1] = {((mp_obj_t)self)}; + new_ret = mp_call_function_n_kw(init_fn[0], 1, 0, args2); + } else { + mp_obj_t *args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (1 + n_args + 2 * n_kw)))); + args2[0] = ((mp_obj_t)self); + memcpy(args2 + 1, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + new_ret = mp_call_function_n_kw(init_fn[0], n_args + 1, n_kw, args2); + ((void)(1 + n_args + 2 * n_kw), m_free(args2)); + } + + } + + + + if (mp_obj_get_type(new_ret) != self) { + return new_ret; + } + + o = ((void*)new_ret); + + + init_fn[0] = init_fn[1] = (((mp_obj_t)(void*)0)); + lookup.obj = o; + lookup.attr = MP_QSTR___init__; + lookup.meth_offset = 0; + mp_obj_class_lookup(&lookup, self); + if (init_fn[0] != (((mp_obj_t)(void*)0))) { + mp_obj_t init_ret; + if (n_args == 0 && n_kw == 0) { + init_ret = mp_call_method_n_kw(0, 0, init_fn); + } else { + mp_obj_t *args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (2 + n_args + 2 * n_kw)))); + args2[0] = init_fn[0]; + args2[1] = init_fn[1]; + memcpy(args2 + 2, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + init_ret = mp_call_method_n_kw(n_args, n_kw, args2); + ((void)(2 + n_args + 2 * n_kw), m_free(args2)); + } + if (init_ret != (((mp_obj_t)&mp_const_none_obj))) { + if (((1)) == (1)) { + mp_raise_TypeError("__init__() should return None"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "__init__() should return None, not '%s'", mp_obj_get_type_str(init_ret)))) + ; + } + } + + } + + return ((mp_obj_t)o); +} + +const qstr mp_unary_op_method_name[] = { + [MP_UNARY_OP_BOOL] = MP_QSTR___bool__, + [MP_UNARY_OP_LEN] = MP_QSTR___len__, + [MP_UNARY_OP_HASH] = MP_QSTR___hash__, +# 345 "user/mpy/py/objtype.c" + [MP_UNARY_OP_NOT] = MP_QSTR_, +}; + +static mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_instance_t *self = ((void*)self_in); +# 363 "user/mpy/py/objtype.c" + qstr op_name = mp_unary_op_method_name[op]; + + + + + + mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = self, + .attr = op_name, + .meth_offset = +# 373 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 373 "user/mpy/py/objtype.c" + mp_obj_type_t +# 373 "user/mpy/py/objtype.c" 3 4 + , +# 373 "user/mpy/py/objtype.c" + unary_op +# 373 "user/mpy/py/objtype.c" 3 4 + ) +# 373 "user/mpy/py/objtype.c" + , + .dest = member, + .is_type = +# 375 "user/mpy/py/objtype.c" 3 4 + 0 +# 375 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == (((mp_obj_t)(void*)8))) { + return mp_unary_op(op, self->subobj[0]); + } else if (member[0] != (((mp_obj_t)(void*)0))) { + mp_obj_t val = mp_call_function_1(member[0], self_in); + + if (op == MP_UNARY_OP_HASH) { + val = ((mp_obj_t)((((mp_uint_t)(mp_obj_get_int_truncated(val))) << 1) | 1)); + } + return val; + } else { + if (op == MP_UNARY_OP_HASH) { + lookup.attr = MP_QSTR___eq__; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == (((mp_obj_t)(void*)0))) { + + + + + + return ((mp_obj_t)((((mp_uint_t)((mp_uint_t)self_in)) << 1) | 1)); + } + + + } + + return (((mp_obj_t)(void*)0)); + } +} + +const qstr mp_binary_op_method_name[] = { + + + + + + + + [MP_BINARY_OP_ADD] = MP_QSTR___add__, + [MP_BINARY_OP_SUBTRACT] = MP_QSTR___sub__, +# 440 "user/mpy/py/objtype.c" + [MP_BINARY_OP_LESS] = MP_QSTR___lt__, + [MP_BINARY_OP_MORE] = MP_QSTR___gt__, + [MP_BINARY_OP_EQUAL] = MP_QSTR___eq__, + [MP_BINARY_OP_LESS_EQUAL] = MP_QSTR___le__, + [MP_BINARY_OP_MORE_EQUAL] = MP_QSTR___ge__, + + + + [MP_BINARY_OP_IN] = MP_QSTR___contains__, + + + + [MP_BINARY_OP_EXCEPTION_MATCH] = MP_QSTR_, +}; + +static mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + + + mp_obj_instance_t *lhs = ((void*)lhs_in); + qstr op_name = mp_binary_op_method_name[op]; + + + + + + mp_obj_t dest[3] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = lhs, + .attr = op_name, + .meth_offset = +# 469 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 469 "user/mpy/py/objtype.c" + mp_obj_type_t +# 469 "user/mpy/py/objtype.c" 3 4 + , +# 469 "user/mpy/py/objtype.c" + binary_op +# 469 "user/mpy/py/objtype.c" 3 4 + ) +# 469 "user/mpy/py/objtype.c" + , + .dest = dest, + .is_type = +# 471 "user/mpy/py/objtype.c" 3 4 + 0 +# 471 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, lhs->base.type); + if (dest[0] == (((mp_obj_t)(void*)8))) { + return mp_binary_op(op, lhs->subobj[0], rhs_in); + } else if (dest[0] != (((mp_obj_t)(void*)0))) { + dest[2] = rhs_in; + return mp_call_method_n_kw(1, 0, dest); + } else { + return (((mp_obj_t)(void*)0)); + } +} + +static void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + + +# 486 "user/mpy/py/objtype.c" 3 + (( +# 486 "user/mpy/py/objtype.c" + ((mp_obj_get_type(self_in))->make_new == mp_obj_instance_make_new) +# 486 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 486, __func__, +# 486 "user/mpy/py/objtype.c" + "mp_obj_is_instance_type(mp_obj_get_type(self_in))" +# 486 "user/mpy/py/objtype.c" 3 + )) +# 486 "user/mpy/py/objtype.c" + ; + mp_obj_instance_t *self = ((void*)self_in); + + mp_map_elem_t *elem = mp_map_lookup(&self->members, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 490 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 490 "user/mpy/py/objtype.c" + ) { + + + dest[0] = elem->value; + return; + } +# 512 "user/mpy/py/objtype.c" + struct class_lookup_data lookup = { + .obj = self, + .attr = attr, + .meth_offset = 0, + .dest = dest, + .is_type = +# 517 "user/mpy/py/objtype.c" 3 4 + 0 +# 517 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self->base.type); + mp_obj_t member = dest[0]; + if (member != (((mp_obj_t)(void*)0))) { +# 554 "user/mpy/py/objtype.c" + return; + } + + + if (attr != MP_QSTR___getattr__) { +# 568 "user/mpy/py/objtype.c" + mp_obj_t dest2[3]; + mp_load_method_maybe(self_in, MP_QSTR___getattr__, dest2); + if (dest2[0] != (((mp_obj_t)(void*)0))) { + + + dest2[2] = ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)); + dest[0] = mp_call_method_n_kw(1, 0, dest2); + return; + } + } +} + +static +# 580 "user/mpy/py/objtype.c" 3 4 + _Bool +# 580 "user/mpy/py/objtype.c" + mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) { + mp_obj_instance_t *self = ((void*)self_in); +# 659 "user/mpy/py/objtype.c" + if (value == (((mp_obj_t)(void*)0))) { +# 673 "user/mpy/py/objtype.c" + mp_map_elem_t *elem = mp_map_lookup(&self->members, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_REMOVE_IF_FOUND); + return elem != +# 674 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 674 "user/mpy/py/objtype.c" + ; + } else { +# 690 "user/mpy/py/objtype.c" + mp_map_lookup(&self->members, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + return +# 691 "user/mpy/py/objtype.c" 3 4 + 1 +# 691 "user/mpy/py/objtype.c" + ; + } +} + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] == (((mp_obj_t)(void*)0))) { + mp_obj_instance_load_attr(self_in, attr, dest); + } else { + if (mp_obj_instance_store_attr(self_in, attr, dest[1])) { + dest[0] = (((mp_obj_t)(void*)0)); + } + } +} + +static mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_instance_t *self = ((void*)self_in); + mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = self, + .meth_offset = +# 710 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 710 "user/mpy/py/objtype.c" + mp_obj_type_t +# 710 "user/mpy/py/objtype.c" 3 4 + , +# 710 "user/mpy/py/objtype.c" + subscr +# 710 "user/mpy/py/objtype.c" 3 4 + ) +# 710 "user/mpy/py/objtype.c" + , + .dest = member, + .is_type = +# 712 "user/mpy/py/objtype.c" 3 4 + 0 +# 712 "user/mpy/py/objtype.c" + , + }; + size_t meth_args; + if (value == (((mp_obj_t)(void*)0))) { + + lookup.attr = MP_QSTR___delitem__; + mp_obj_class_lookup(&lookup, self->base.type); + meth_args = 2; + } else if (value == (((mp_obj_t)(void*)8))) { + + lookup.attr = MP_QSTR___getitem__; + mp_obj_class_lookup(&lookup, self->base.type); + meth_args = 2; + } else { + + lookup.attr = MP_QSTR___setitem__; + mp_obj_class_lookup(&lookup, self->base.type); + meth_args = 3; + } + if (member[0] == (((mp_obj_t)(void*)8))) { + return mp_obj_subscr(self->subobj[0], index, value); + } else if (member[0] != (((mp_obj_t)(void*)0))) { + mp_obj_t args[3] = {self_in, index, value}; + + mp_obj_t ret = mp_call_function_n_kw(member[0], meth_args, 0, args); + if (value == (((mp_obj_t)(void*)8))) { + return ret; + } else { + return (((mp_obj_t)&mp_const_none_obj)); + } + } else { + return (((mp_obj_t)(void*)0)); + } +} + +static mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) { + mp_obj_instance_t *self = ((void*)self_in); + struct class_lookup_data lookup = { + .obj = self, + .attr = MP_QSTR___call__, + .meth_offset = +# 752 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 752 "user/mpy/py/objtype.c" + mp_obj_type_t +# 752 "user/mpy/py/objtype.c" 3 4 + , +# 752 "user/mpy/py/objtype.c" + call +# 752 "user/mpy/py/objtype.c" 3 4 + ) +# 752 "user/mpy/py/objtype.c" + , + .dest = member, + .is_type = +# 754 "user/mpy/py/objtype.c" 3 4 + 0 +# 754 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self->base.type); + return member[0]; +} + + +# 760 "user/mpy/py/objtype.c" 3 4 +_Bool +# 760 "user/mpy/py/objtype.c" + mp_obj_instance_is_callable(mp_obj_t self_in) { + mp_obj_t member[2] = {(((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))}; + return mp_obj_instance_get_call(self_in, member) != (((mp_obj_t)(void*)0)); +} + +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_t member[2] = {(((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))}; + mp_obj_t call = mp_obj_instance_get_call(self_in, member); + if (call == (((mp_obj_t)(void*)0))) { + if (((1)) == (1)) { + mp_raise_TypeError("object not callable"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not callable", mp_obj_get_type_str(self_in)))) + ; + } + } + mp_obj_instance_t *self = ((void*)self_in); + if (call == (((mp_obj_t)(void*)8))) { + return mp_call_function_n_kw(self->subobj[0], n_args, n_kw, args); + } + + return mp_call_method_self_n_kw(member[0], member[1], n_args, n_kw, args); +} + +static mp_obj_t instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { + mp_obj_instance_t *self = ((void*)self_in); + mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = self, + .attr = MP_QSTR___iter__, + .meth_offset = +# 790 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 790 "user/mpy/py/objtype.c" + mp_obj_type_t +# 790 "user/mpy/py/objtype.c" 3 4 + , +# 790 "user/mpy/py/objtype.c" + getiter +# 790 "user/mpy/py/objtype.c" 3 4 + ) +# 790 "user/mpy/py/objtype.c" + , + .dest = member, + .is_type = +# 792 "user/mpy/py/objtype.c" 3 4 + 0 +# 792 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == (((mp_obj_t)(void*)0))) { + return (((mp_obj_t)(void*)0)); + } else if (member[0] == (((mp_obj_t)(void*)8))) { + mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); + return type->getiter(self->subobj[0], iter_buf); + } else { + return mp_call_method_n_kw(0, 0, member); + } +} + +static mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + mp_obj_instance_t *self = ((void*)self_in); + mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; + struct class_lookup_data lookup = { + .obj = self, + .attr = MP_QSTR_, + .meth_offset = +# 811 "user/mpy/py/objtype.c" 3 4 + __builtin_offsetof ( +# 811 "user/mpy/py/objtype.c" + mp_obj_type_t +# 811 "user/mpy/py/objtype.c" 3 4 + , +# 811 "user/mpy/py/objtype.c" + buffer_p.get_buffer +# 811 "user/mpy/py/objtype.c" 3 4 + ) +# 811 "user/mpy/py/objtype.c" + , + .dest = member, + .is_type = +# 813 "user/mpy/py/objtype.c" 3 4 + 0 +# 813 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == (((mp_obj_t)(void*)8))) { + mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); + return type->buffer_p.get_buffer(self->subobj[0], bufinfo, flags); + } else { + return 1; + } +} + + + + + + + +static void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_type_t *self = ((void*)self_in); + mp_printf(print, "", self->name); +} + +static mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + mp_arg_check_num(n_args, n_kw, 1, 3, +# 839 "user/mpy/py/objtype.c" 3 4 + 0 +# 839 "user/mpy/py/objtype.c" + ); + + switch (n_args) { + case 1: + return ((mp_obj_t)mp_obj_get_type(args[0])); + + case 3: + + + + return mp_obj_new_type(mp_obj_str_get_qstr(args[0]), args[1], args[2]); + + default: + mp_raise_TypeError("type takes 1 or 3 arguments"); + } +} + +static mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + + + mp_obj_type_t *self = ((void*)self_in); + + if (self->make_new == +# 861 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 861 "user/mpy/py/objtype.c" + ) { + if (((1)) == (1)) { + mp_raise_TypeError("cannot create instance"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "cannot create '%q' instances", self->name))) + ; + } + } + + + mp_obj_t o = self->make_new(self, n_args, n_kw, args); + + + return o; +} + +static void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + +# 878 "user/mpy/py/objtype.c" 3 + (( +# 878 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_type))) +# 878 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 878, __func__, +# 878 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_type)" +# 878 "user/mpy/py/objtype.c" 3 + )) +# 878 "user/mpy/py/objtype.c" + ; + mp_obj_type_t *self = ((void*)self_in); + + if (dest[0] == (((mp_obj_t)(void*)0))) { + + + + + + + + struct class_lookup_data lookup = { + .obj = (mp_obj_instance_t*)self, + .attr = attr, + .meth_offset = 0, + .dest = dest, + .is_type = +# 894 "user/mpy/py/objtype.c" 3 4 + 1 +# 894 "user/mpy/py/objtype.c" + , + }; + mp_obj_class_lookup(&lookup, self); + } else { + + + + + if (self->locals_dict != +# 902 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 902 "user/mpy/py/objtype.c" + ) { + +# 903 "user/mpy/py/objtype.c" 3 + (( +# 903 "user/mpy/py/objtype.c" + self->locals_dict->base.type == &mp_type_dict +# 903 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 903, __func__, +# 903 "user/mpy/py/objtype.c" + "self->locals_dict->base.type == &mp_type_dict" +# 903 "user/mpy/py/objtype.c" 3 + )) +# 903 "user/mpy/py/objtype.c" + ; + mp_map_t *locals_map = &self->locals_dict->map; + if (dest[1] == (((mp_obj_t)(void*)0))) { + + mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_REMOVE_IF_FOUND); + + if (elem != +# 909 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 909 "user/mpy/py/objtype.c" + ) { + dest[0] = (((mp_obj_t)(void*)0)); + } + } else { + + mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + + if (elem != +# 916 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 916 "user/mpy/py/objtype.c" + ) { + elem->value = dest[1]; + dest[0] = (((mp_obj_t)(void*)0)); + } + } + } + } +} + +const mp_obj_type_t mp_type_type = { + { &mp_type_type }, + .name = MP_QSTR_type, + .print = type_print, + .make_new = type_make_new, + .call = type_call, + .unary_op = mp_generic_unary_op, + .attr = type_attr, +}; + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) { + +# 936 "user/mpy/py/objtype.c" 3 + (( +# 936 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(bases_tuple) && (((mp_obj_base_t*)((void*)bases_tuple))->type == (&mp_type_tuple))) +# 936 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 936, __func__, +# 936 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(bases_tuple, &mp_type_tuple)" +# 936 "user/mpy/py/objtype.c" 3 + )) +# 936 "user/mpy/py/objtype.c" + ; + +# 937 "user/mpy/py/objtype.c" 3 + (( +# 937 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(locals_dict) && (((mp_obj_base_t*)((void*)locals_dict))->type == (&mp_type_dict))) +# 937 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 937, __func__, +# 937 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(locals_dict, &mp_type_dict)" +# 937 "user/mpy/py/objtype.c" 3 + )) +# 937 "user/mpy/py/objtype.c" + ; + + + + + size_t len; + mp_obj_t *items; + mp_obj_tuple_get(bases_tuple, &len, &items); + for (size_t i = 0; i < len; i++) { + +# 946 "user/mpy/py/objtype.c" 3 + (( +# 946 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(items[i]) && (((mp_obj_base_t*)((void*)items[i]))->type == (&mp_type_type))) +# 946 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 946, __func__, +# 946 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(items[i], &mp_type_type)" +# 946 "user/mpy/py/objtype.c" 3 + )) +# 946 "user/mpy/py/objtype.c" + ; + mp_obj_type_t *t = ((void*)items[i]); + + if (t->make_new == +# 949 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 949 "user/mpy/py/objtype.c" + ) { + if (((1)) == (1)) { + mp_raise_TypeError("type is not an acceptable base type"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "type '%q' is not an acceptable base type", t->name))) + ; + } + } + } + + mp_obj_type_t *o = ((mp_obj_type_t*)(m_malloc0(sizeof(mp_obj_type_t) * (1)))); + o->base.type = &mp_type_type; + o->name = name; + o->print = instance_print; + o->make_new = mp_obj_instance_make_new; + o->call = mp_obj_instance_call; + o->unary_op = instance_unary_op; + o->binary_op = instance_binary_op; + o->attr = mp_obj_instance_attr; + o->subscr = instance_subscr; + o->getiter = instance_getiter; + + o->buffer_p.get_buffer = instance_get_buffer; + + if (len > 0) { + + + + + o->protocol = ((mp_obj_type_t*)((void*)items[0]))->protocol; + + if (len >= 2) { + o->parent = ((void*)bases_tuple); + } else { + o->parent = ((void*)items[0]); + } + } + + o->locals_dict = ((void*)locals_dict); + + const mp_obj_type_t *native_base; + size_t num_native_bases = instance_count_native_bases(o, &native_base); + if (num_native_bases > 1) { + mp_raise_TypeError("multiple bases have instance lay-out conflict"); + } + + mp_map_t *locals_map = &o->locals_dict->map; + mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(MP_QSTR___new__)) << 2) | 2)), MP_MAP_LOOKUP); + if (elem != +# 997 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 997 "user/mpy/py/objtype.c" + ) { + + if ((MP_OBJ_IS_OBJ(elem->value) && (((mp_obj_base_t*)((void*)elem->value))->type->name == MP_QSTR_function))) { + + elem->value = static_class_method_make_new(&mp_type_staticmethod, 1, 0, &elem->value); + } + } + + return ((mp_obj_t)o); +} + + + + +typedef struct _mp_obj_super_t { + mp_obj_base_t base; + mp_obj_t type; + mp_obj_t obj; +} mp_obj_super_t; + +static void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_super_t *self = ((void*)self_in); + mp_print_str(print, "type, PRINT_STR); + mp_print_str(print, ", "); + mp_obj_print_helper(print, self->obj, PRINT_STR); + mp_print_str(print, ">"); +} + +static mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + + mp_arg_check_num(n_args, n_kw, 2, 2, +# 1031 "user/mpy/py/objtype.c" 3 4 + 0 +# 1031 "user/mpy/py/objtype.c" + ); + mp_obj_super_t *o = (((mp_obj_super_t*)(m_malloc(sizeof(mp_obj_super_t) * (1))))); + *o = (mp_obj_super_t){{type_in}, args[0], args[1]}; + return ((mp_obj_t)o); +} + +static void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != (((mp_obj_t)(void*)0))) { + + return; + } + + +# 1043 "user/mpy/py/objtype.c" 3 + (( +# 1043 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_super))) +# 1043 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1043, __func__, +# 1043 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(self_in, &mp_type_super)" +# 1043 "user/mpy/py/objtype.c" 3 + )) +# 1043 "user/mpy/py/objtype.c" + ; + mp_obj_super_t *self = ((void*)self_in); + + +# 1046 "user/mpy/py/objtype.c" 3 + (( +# 1046 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(self->type) && (((mp_obj_base_t*)((void*)self->type))->type == (&mp_type_type))) +# 1046 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1046, __func__, +# 1046 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(self->type, &mp_type_type)" +# 1046 "user/mpy/py/objtype.c" 3 + )) +# 1046 "user/mpy/py/objtype.c" + ; + + mp_obj_type_t *type = ((void*)self->type); + + struct class_lookup_data lookup = { + .obj = ((void*)self->obj), + .attr = attr, + .meth_offset = 0, + .dest = dest, + .is_type = +# 1055 "user/mpy/py/objtype.c" 3 4 + 0 +# 1055 "user/mpy/py/objtype.c" + , + }; + + if (type->parent == +# 1058 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 1058 "user/mpy/py/objtype.c" + ) { + + } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { + const mp_obj_tuple_t *parent_tuple = type->parent; + size_t len = parent_tuple->len; + const mp_obj_t *items = parent_tuple->items; + for (size_t i = 0; i < len; i++) { + +# 1065 "user/mpy/py/objtype.c" 3 + (( +# 1065 "user/mpy/py/objtype.c" + (MP_OBJ_IS_OBJ(items[i]) && (((mp_obj_base_t*)((void*)items[i]))->type == (&mp_type_type))) +# 1065 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1065, __func__, +# 1065 "user/mpy/py/objtype.c" + "MP_OBJ_IS_TYPE(items[i], &mp_type_type)" +# 1065 "user/mpy/py/objtype.c" 3 + )) +# 1065 "user/mpy/py/objtype.c" + ; + mp_obj_class_lookup(&lookup, (mp_obj_type_t*)((void*)items[i])); + if (dest[0] != (((mp_obj_t)(void*)0))) { + return; + } + } + } else { + mp_obj_class_lookup(&lookup, type->parent); + if (dest[0] != (((mp_obj_t)(void*)0))) { + return; + } + } + + mp_obj_class_lookup(&lookup, &mp_type_object); +} + +const mp_obj_type_t mp_type_super = { + { &mp_type_type }, + .name = MP_QSTR_super, + .print = super_print, + .make_new = super_make_new, + .attr = super_attr, +}; + +void mp_load_super_method(qstr attr, mp_obj_t *dest) { + mp_obj_super_t super = {{&mp_type_super}, dest[1], dest[2]}; + mp_load_method(((mp_obj_t)&super), attr, dest); +} + + + + + + + +# 1099 "user/mpy/py/objtype.c" 3 4 +_Bool +# 1099 "user/mpy/py/objtype.c" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) { + for (;;) { + if (object == classinfo) { + return +# 1102 "user/mpy/py/objtype.c" 3 4 + 1 +# 1102 "user/mpy/py/objtype.c" + ; + } + + + + + if (!(MP_OBJ_IS_OBJ(object) && (((mp_obj_base_t*)((void*)object))->type == (&mp_type_type)))) { + return +# 1109 "user/mpy/py/objtype.c" 3 4 + 0 +# 1109 "user/mpy/py/objtype.c" + ; + } + + const mp_obj_type_t *self = ((void*)object); + + if (self->parent == +# 1114 "user/mpy/py/objtype.c" 3 4 + ((void *)0) +# 1114 "user/mpy/py/objtype.c" + ) { + + return +# 1116 "user/mpy/py/objtype.c" 3 4 + 0 +# 1116 "user/mpy/py/objtype.c" + ; + } else if (((mp_obj_base_t*)self->parent)->type == &mp_type_tuple) { + + const mp_obj_tuple_t *parent_tuple = self->parent; + const mp_obj_t *item = parent_tuple->items; + const mp_obj_t *top = item + parent_tuple->len - 1; + + + for (; item < top; ++item) { + if (mp_obj_is_subclass_fast(*item, classinfo)) { + return +# 1126 "user/mpy/py/objtype.c" 3 4 + 1 +# 1126 "user/mpy/py/objtype.c" + ; + } + } + + + object = *item; + } else { + + object = ((mp_obj_t)self->parent); + } + } +} + +static mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) { + size_t len; + mp_obj_t *items; + if ((MP_OBJ_IS_OBJ(classinfo) && (((mp_obj_base_t*)((void*)classinfo))->type == (&mp_type_type)))) { + len = 1; + items = &classinfo; + } else if ((MP_OBJ_IS_OBJ(classinfo) && (((mp_obj_base_t*)((void*)classinfo))->type == (&mp_type_tuple)))) { + mp_obj_tuple_get(classinfo, &len, &items); + } else { + mp_raise_TypeError("issubclass() arg 2 must be a class or a tuple of classes"); + } + + for (size_t i = 0; i < len; i++) { + + if (items[i] == ((mp_obj_t)&mp_type_object) || mp_obj_is_subclass_fast(object, items[i])) { + return (((mp_obj_t)&mp_const_true_obj)); + } + } + return (((mp_obj_t)&mp_const_false_obj)); +} + +static mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) { + if (!(MP_OBJ_IS_OBJ(object) && (((mp_obj_base_t*)((void*)object))->type == (&mp_type_type)))) { + mp_raise_TypeError("issubclass() arg 1 must be a class"); + } + return mp_obj_is_subclass(object, classinfo); +} + +const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_issubclass}; + +static mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) { + return mp_obj_is_subclass(((mp_obj_t)mp_obj_get_type(object)), classinfo); +} + +const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_isinstance}; + +mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t native_type) { + mp_obj_type_t *self_type = mp_obj_get_type(self_in); + if (!mp_obj_is_subclass_fast(((mp_obj_t)self_type), native_type)) { + return (((mp_obj_t)(void*)0)); + } + mp_obj_instance_t *self = (mp_obj_instance_t*)((void*)self_in); + return self->subobj[0]; +} + + + + +static mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { + +# 1188 "user/mpy/py/objtype.c" 3 + (( +# 1188 "user/mpy/py/objtype.c" + self == &mp_type_staticmethod || self == &mp_type_classmethod +# 1188 "user/mpy/py/objtype.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1188, __func__, +# 1188 "user/mpy/py/objtype.c" + "self == &mp_type_staticmethod || self == &mp_type_classmethod" +# 1188 "user/mpy/py/objtype.c" 3 + )) +# 1188 "user/mpy/py/objtype.c" + ; + + mp_arg_check_num(n_args, n_kw, 1, 1, +# 1190 "user/mpy/py/objtype.c" 3 4 + 0 +# 1190 "user/mpy/py/objtype.c" + ); + + mp_obj_static_class_method_t *o = (((mp_obj_static_class_method_t*)(m_malloc(sizeof(mp_obj_static_class_method_t) * (1))))); + *o = (mp_obj_static_class_method_t){{self}, args[0]}; + return ((mp_obj_t)o); +} + +const mp_obj_type_t mp_type_staticmethod = { + { &mp_type_type }, + .name = MP_QSTR_staticmethod, + .make_new = static_class_method_make_new, +}; + +const mp_obj_type_t mp_type_classmethod = { + { &mp_type_type }, + .name = MP_QSTR_classmethod, + .make_new = static_class_method_make_new, +}; +# 1 "user/mpy/py/objzip.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/objzip.c" +# 27 "user/mpy/py/objzip.c" +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 28 "user/mpy/py/objzip.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/objzip.c" 2 + +# 1 "user/mpy/py/objtuple.h" 1 +# 29 "user/mpy/py/objtuple.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objtuple.h" 2 + +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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/py/objzip.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 32 "user/mpy/py/objexcept.h" +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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/objzip.c" 2 + +typedef struct _mp_obj_zip_t { + mp_obj_base_t base; + size_t n_iters; + mp_obj_t iters[]; +} mp_obj_zip_t; + +static mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, (0xffff), +# 40 "user/mpy/py/objzip.c" 3 4 + 0 +# 40 "user/mpy/py/objzip.c" + ); + + mp_obj_zip_t *o = ((mp_obj_zip_t*)m_malloc(sizeof(mp_obj_zip_t) + sizeof(mp_obj_t) * (n_args))); + o->base.type = type; + o->n_iters = n_args; + for (size_t i = 0; i < n_args; i++) { + o->iters[i] = mp_getiter(args[i], +# 46 "user/mpy/py/objzip.c" 3 4 + ((void *)0) +# 46 "user/mpy/py/objzip.c" + ); + } + return ((mp_obj_t)o); +} + +static mp_obj_t zip_iternext(mp_obj_t self_in) { + +# 52 "user/mpy/py/objzip.c" 3 + (( +# 52 "user/mpy/py/objzip.c" + (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_zip))) +# 52 "user/mpy/py/objzip.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/objzip.c", 52, __func__, +# 52 "user/mpy/py/objzip.c" + "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_zip)))" +# 52 "user/mpy/py/objzip.c" 3 + )) +# 52 "user/mpy/py/objzip.c" + ; + mp_obj_zip_t *self = ((void*)self_in); + if (self->n_iters == 0) { + return (((mp_obj_t)(void*)4)); + } + mp_obj_tuple_t *tuple = ((void*)mp_obj_new_tuple(self->n_iters, +# 57 "user/mpy/py/objzip.c" 3 4 + ((void *)0) +# 57 "user/mpy/py/objzip.c" + )); + + for (size_t i = 0; i < self->n_iters; i++) { + mp_obj_t next = mp_iternext(self->iters[i]); + if (next == (((mp_obj_t)(void*)4))) { + mp_obj_tuple_del(((mp_obj_t)tuple)); + return (((mp_obj_t)(void*)4)); + } + tuple->items[i] = next; + } + return ((mp_obj_t)tuple); +} + +const mp_obj_type_t mp_type_zip = { + { &mp_type_type }, + .name = MP_QSTR_zip, + .make_new = zip_make_new, + .getiter = mp_identity_getiter, + .iternext = zip_iternext, +}; +# 1 "user/mpy/py/opmethods.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/opmethods.c" +# 27 "user/mpy/py/opmethods.c" +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 28 "user/mpy/py/opmethods.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 29 "user/mpy/py/builtin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/builtin.h" 2 + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 29 "user/mpy/py/opmethods.c" 2 + +static mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + return type->subscr(self_in, key_in, (((mp_obj_t)(void*)8))); +} +const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj = {{&mp_type_fun_builtin_2}, .fun._2 = op_getitem}; + +static mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + return type->subscr(self_in, key_in, value_in); +} +const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj = {{&mp_type_fun_builtin_3}, .fun._3 = op_setitem}; + +static mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + return type->subscr(self_in, key_in, (((mp_obj_t)(void*)0))); +} +const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj = {{&mp_type_fun_builtin_2}, .fun._2 = op_delitem}; + +static mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_type_t *type = mp_obj_get_type(lhs_in); + return type->binary_op(MP_BINARY_OP_IN, lhs_in, rhs_in); +} +const mp_obj_fun_builtin_fixed_t mp_op_contains_obj = {{&mp_type_fun_builtin_2}, .fun._2 = op_contains}; +# 1 "user/mpy/py/sequence.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/sequence.c" +# 28 "user/mpy/py/sequence.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/sequence.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/sequence.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 32 "user/mpy/py/sequence.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/sequence.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/sequence.c" 2 + + + + + + + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest) { + for (size_t i = 0; i < times; i++) { + size_t copy_sz = item_sz * len; + memcpy(dest, items, copy_sz); + dest = (char*)dest + copy_sz; + } +} +# 129 "user/mpy/py/sequence.c" +mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) { + (void)len; + + mp_int_t start = indexes->start, stop = indexes->stop; + mp_int_t step = indexes->step; + + mp_obj_t res = mp_obj_new_list(0, +# 135 "user/mpy/py/sequence.c" 3 4 + ((void *)0) +# 135 "user/mpy/py/sequence.c" + ); + + if (step < 0) { + while (start >= stop) { + mp_obj_list_append(res, seq[start]); + start += step; + } + } else { + while (start < stop) { + mp_obj_list_append(res, seq[start]); + start += step; + } + } + return res; +} + + + + +# 153 "user/mpy/py/sequence.c" 3 4 +_Bool +# 153 "user/mpy/py/sequence.c" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2) { + if (op == MP_BINARY_OP_EQUAL && len1 != len2) { + return +# 155 "user/mpy/py/sequence.c" 3 4 + 0 +# 155 "user/mpy/py/sequence.c" + ; + } + + + if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { + { const byte* t = data2; data2 = data1; data1 = t; }; + { size_t t = len2; len2 = len1; len1 = t; }; + if (op == MP_BINARY_OP_LESS) { + op = MP_BINARY_OP_MORE; + } else { + op = MP_BINARY_OP_MORE_EQUAL; + } + } + size_t min_len = len1 < len2 ? len1 : len2; + int res = memcmp(data1, data2, min_len); + if (op == MP_BINARY_OP_EQUAL) { + + return res == 0; + } + if (res < 0) { + return +# 175 "user/mpy/py/sequence.c" 3 4 + 0 +# 175 "user/mpy/py/sequence.c" + ; + } + if (res > 0) { + return +# 178 "user/mpy/py/sequence.c" 3 4 + 1 +# 178 "user/mpy/py/sequence.c" + ; + } + + + + if (len1 != len2) { + if (len1 < len2) { + + return +# 186 "user/mpy/py/sequence.c" 3 4 + 0 +# 186 "user/mpy/py/sequence.c" + ; + } + } else if (op == MP_BINARY_OP_MORE) { + + return +# 190 "user/mpy/py/sequence.c" 3 4 + 0 +# 190 "user/mpy/py/sequence.c" + ; + } + return +# 192 "user/mpy/py/sequence.c" 3 4 + 1 +# 192 "user/mpy/py/sequence.c" + ; +} + + + + +# 197 "user/mpy/py/sequence.c" 3 4 +_Bool +# 197 "user/mpy/py/sequence.c" + mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, size_t len1, const mp_obj_t *items2, size_t len2) { + if (op == MP_BINARY_OP_EQUAL && len1 != len2) { + return +# 199 "user/mpy/py/sequence.c" 3 4 + 0 +# 199 "user/mpy/py/sequence.c" + ; + } + + + if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { + { const mp_obj_t * t = items2; items2 = items1; items1 = t; }; + { size_t t = len2; len2 = len1; len1 = t; }; + if (op == MP_BINARY_OP_LESS) { + op = MP_BINARY_OP_MORE; + } else { + op = MP_BINARY_OP_MORE_EQUAL; + } + } + + size_t len = len1 < len2 ? len1 : len2; + for (size_t i = 0; i < len; i++) { + + if (mp_obj_equal(items1[i], items2[i])) { + continue; + } + + + if (op == MP_BINARY_OP_EQUAL) { + + return +# 223 "user/mpy/py/sequence.c" 3 4 + 0 +# 223 "user/mpy/py/sequence.c" + ; + } + + + return (mp_binary_op(op, items1[i], items2[i]) == (((mp_obj_t)&mp_const_true_obj))); + } + + + + if (len1 != len2) { + if (len1 < len2) { + + return +# 235 "user/mpy/py/sequence.c" 3 4 + 0 +# 235 "user/mpy/py/sequence.c" + ; + } + } else if (op == MP_BINARY_OP_MORE) { + + return +# 239 "user/mpy/py/sequence.c" 3 4 + 0 +# 239 "user/mpy/py/sequence.c" + ; + } + + return +# 242 "user/mpy/py/sequence.c" 3 4 + 1 +# 242 "user/mpy/py/sequence.c" + ; +} + + +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_type_t *type = mp_obj_get_type(args[0]); + mp_obj_t value = args[1]; + size_t start = 0; + size_t stop = len; + + if (n_args >= 3) { + start = mp_get_index(type, len, args[2], +# 253 "user/mpy/py/sequence.c" 3 4 + 1 +# 253 "user/mpy/py/sequence.c" + ); + if (n_args >= 4) { + stop = mp_get_index(type, len, args[3], +# 255 "user/mpy/py/sequence.c" 3 4 + 1 +# 255 "user/mpy/py/sequence.c" + ); + } + } + + for (size_t i = start; i < stop; i++) { + if (mp_obj_equal(items[i], value)) { + + return ((mp_obj_t)((((mp_uint_t)(i)) << 1) | 1)); + } + } + + mp_raise_ValueError("object not in sequence"); +} + +mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) { + size_t count = 0; + for (size_t i = 0; i < len; i++) { + if (mp_obj_equal(items[i], value)) { + count++; + } + } + + + return ((mp_obj_t)((((mp_uint_t)(count)) << 1) | 1)); +} +# 1 "user/mpy/py/stream.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/stream.c" +# 28 "user/mpy/py/stream.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/stream.c" 2 +# 1 "/usr/arm-none-eabi/include/unistd.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/sys/unistd.h" 1 3 +# 12 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 13 "/usr/arm-none-eabi/include/sys/unistd.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/unistd.h" 2 3 + +extern char **environ; + +void _exit (int __status ) __attribute__ ((__noreturn__)); + +int access (const char *__path, int __amode ); +unsigned alarm (unsigned __secs ); +int chdir (const char *__path ); +int chmod (const char *__path, mode_t __mode ); + +int chown (const char *__path, uid_t __owner, gid_t __group ); + + + + +int close (int __fildes ); +# 46 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int dup (int __fildes ); +int dup2 (int __fildes, int __fildes2 ); +# 61 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int execl (const char *__path, const char *, ... ); +int execle (const char *__path, const char *, ... ); +int execlp (const char *__file, const char *, ... ); + + + +int execv (const char *__path, char * const __argv[] ); +int execve (const char *__path, char * const __argv[], char * const __envp[] ); +int execvp (const char *__file, char * const __argv[] ); +# 79 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int fchmod (int __fildes, mode_t __mode ); + +int fchown (int __fildes, uid_t __owner, gid_t __group ); + + + + + + + +pid_t fork (void ); +long fpathconf (int __fd, int __name ); +int fsync (int __fd); +int fdatasync (int __fd); + + + +char * getcwd (char *__buf, size_t __size ); + + + + + + + +gid_t getegid (void ); +uid_t geteuid (void ); +gid_t getgid (void ); + +int getgroups (int __gidsetsize, gid_t __grouplist[] ); + + + +char * getlogin (void ); + + + +char * getpass (const char *__prompt); +int getpagesize (void); + + + +pid_t getpgid (pid_t); +pid_t getpgrp (void ); +pid_t getpid (void ); +pid_t getppid (void ); + + + + +uid_t getuid (void ); +# 140 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int isatty (int __fildes ); + + + + +int lchown (const char *__path, uid_t __owner, gid_t __group ); + +int link (const char *__path1, const char *__path2 ); + + + +int nice (int __nice_value ); + +off_t lseek (int __fildes, off_t __offset, int __whence ); +# 162 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +long pathconf (const char *__path, int __name ); +int pause (void ); + + + +int pipe (int __fildes[2] ); + + + +ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset); +ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t __offset); +int read (int __fd, void *__buf, size_t __nbyte ); + + + + +int rmdir (const char *__path ); + + + +void * sbrk (ptrdiff_t __incr); + + + + + +int setgid (gid_t __gid ); + + + + + + + +int setpgid (pid_t __pid, pid_t __pgid ); +int setpgrp (void ); + + + + +pid_t setsid (void ); + +int setuid (uid_t __uid ); + + + + +unsigned sleep (unsigned int __seconds ); +void swab (const void *restrict, void *restrict, ssize_t); +long sysconf (int __name ); +pid_t tcgetpgrp (int __fildes ); +int tcsetpgrp (int __fildes, pid_t __pgrp_id ); +char * ttyname (int __fildes ); +int ttyname_r (int, char *, size_t); +int unlink (const char *__path ); +int usleep (useconds_t __useconds); +int vhangup (void ); +int write (int __fd, const void *__buf, size_t __nbyte ); + + + + + + +extern char *optarg; +extern int optind, opterr, optopt; +int getopt(int, char * const [], const char *); +extern int optreset; +# 257 "/usr/arm-none-eabi/include/sys/unistd.h" 3 +int ftruncate (int __fd, off_t __length); +int truncate (const char *, off_t __length); +# 5 "/usr/arm-none-eabi/include/unistd.h" 2 3 +# 30 "user/mpy/py/stream.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/stream.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 29 "user/mpy/py/objstr.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objstr.h" 2 + +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 33 "user/mpy/py/stream.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 34 "user/mpy/py/stream.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 35 "user/mpy/py/stream.c" 2 +# 49 "user/mpy/py/stream.c" +static mp_obj_t stream_readall(mp_obj_t self_in); + + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode, byte flags) { + byte *buf = buf_; + mp_obj_base_t* s = (mp_obj_base_t*)((void*)stream); + typedef mp_uint_t (*io_func_t)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + io_func_t io_func; + const mp_stream_p_t *stream_p = s->type->protocol; + if (flags & 2) { + io_func = (io_func_t)stream_p->write; + } else { + io_func = stream_p->read; + } + + *errcode = 0; + mp_uint_t done = 0; + while (size > 0) { + mp_uint_t out_sz = io_func(stream, buf, size, errcode); + + + + if (out_sz == 0) { + return done; + } + if (out_sz == ((mp_uint_t)-1)) { + + if ((0) && done != 0) { + *errcode = 0; + } + return done; + } + if (flags & 1) { + return out_sz; + } + + buf += out_sz; + size -= out_sz; + done += out_sz; + } + return done; +} + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + const mp_stream_p_t *stream_p = type->protocol; + if (stream_p == +# 99 "user/mpy/py/stream.c" 3 4 + ((void *)0) + +# 100 "user/mpy/py/stream.c" + || ((flags & (1)) && stream_p->read == +# 100 "user/mpy/py/stream.c" 3 4 + ((void *)0) +# 100 "user/mpy/py/stream.c" + ) + || ((flags & (2)) && stream_p->write == +# 101 "user/mpy/py/stream.c" 3 4 + ((void *)0) +# 101 "user/mpy/py/stream.c" + ) + || ((flags & (4)) && stream_p->ioctl == +# 102 "user/mpy/py/stream.c" 3 4 + ((void *)0) +# 102 "user/mpy/py/stream.c" + )) { + + mp_raise_msg(&mp_type_OSError, "stream operation not supported"); + } + return stream_p; +} + +mp_obj_t mp_stream_close(mp_obj_t stream) { + + mp_obj_t dest[2]; + mp_load_method(stream, MP_QSTR_close, dest); + return mp_call_method_n_kw(0, 0, dest); +} + +static mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (1)); + + + + + mp_int_t sz; + if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) { + return stream_readall(args[0]); + } +# 216 "user/mpy/py/stream.c" + vstr_t vstr; + vstr_init_len(&vstr, sz); + int error; + mp_uint_t out_sz = mp_stream_rw(args[0], vstr.buf, sz, &error, flags); + if (error != 0) { + vstr_clear(&vstr); + if ((0)) { + + + + + + return (((mp_obj_t)&mp_const_none_obj)); + } + mp_raise_OSError(error); + } else { + vstr.len = out_sz; + return mp_obj_new_str_from_vstr((((stream_p)->is_text) ? &mp_type_str : &mp_type_bytes), &vstr); + } +} + +static mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) { + return stream_read_generic(n_args, args, 0); +} +const mp_obj_fun_builtin_var_t mp_stream_read_obj = {{&mp_type_fun_builtin_var}, +# 240 "user/mpy/py/stream.c" 3 4 +0 +# 240 "user/mpy/py/stream.c" +, 1, 2, .fun.var = stream_read}; + +static mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) { + return stream_read_generic(n_args, args, 0 | 1); +} +const mp_obj_fun_builtin_var_t mp_stream_read1_obj = {{&mp_type_fun_builtin_var}, +# 245 "user/mpy/py/stream.c" 3 4 +0 +# 245 "user/mpy/py/stream.c" +, 1, 2, .fun.var = stream_read1}; + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags) { + mp_get_stream_raise(self_in, (2)); + + int error; + mp_uint_t out_sz = mp_stream_rw(self_in, (void*)buf, len, &error, flags); + if (error != 0) { + if ((0)) { + + + + return (((mp_obj_t)&mp_const_none_obj)); + } + mp_raise_OSError(error); + } else { + return ((mp_obj_t)((((mp_uint_t)(out_sz)) << 1) | 1)); + } +} + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len) { + mp_stream_write(((mp_obj_t)self), buf, len, 2); +} + +static mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, (1)); + size_t max_len = (size_t)-1; + size_t off = 0; + if (n_args == 3) { + max_len = mp_obj_get_int_truncated(args[2]); + } else if (n_args == 4) { + off = mp_obj_get_int_truncated(args[2]); + max_len = mp_obj_get_int_truncated(args[3]); + if (off > bufinfo.len) { + off = bufinfo.len; + } + } + bufinfo.len -= off; + return mp_stream_write(args[0], (byte*)bufinfo.buf + off, ((bufinfo.len) < (max_len) ? (bufinfo.len) : (max_len)), 2); +} +const mp_obj_fun_builtin_var_t mp_stream_write_obj = {{&mp_type_fun_builtin_var}, +# 287 "user/mpy/py/stream.c" 3 4 +0 +# 287 "user/mpy/py/stream.c" +, 2, 4, .fun.var = stream_write_method}; + +static mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(arg, &bufinfo, (1)); + return mp_stream_write(self_in, bufinfo.buf, bufinfo.len, 2 | 1); +} +const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj = {{&mp_type_fun_builtin_2}, .fun._2 = stream_write1_method}; + +static mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) { + mp_get_stream_raise(args[0], (1)); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, (2)); + + + + + mp_uint_t len = bufinfo.len; + if (n_args > 2) { + len = mp_obj_get_int(args[2]); + if (len > bufinfo.len) { + len = bufinfo.len; + } + } + + int error; + mp_uint_t out_sz = mp_stream_rw(args[0], bufinfo.buf, len, &error, 0); + if (error != 0) { + if ((0)) { + return (((mp_obj_t)&mp_const_none_obj)); + } + mp_raise_OSError(error); + } else { + return ((mp_obj_t)((((mp_uint_t)(out_sz)) << 1) | 1)); + } +} +const mp_obj_fun_builtin_var_t mp_stream_readinto_obj = {{&mp_type_fun_builtin_var}, +# 323 "user/mpy/py/stream.c" 3 4 +0 +# 323 "user/mpy/py/stream.c" +, 2, 3, .fun.var = stream_readinto}; + +static mp_obj_t stream_readall(mp_obj_t self_in) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(self_in, (1)); + + mp_uint_t total_size = 0; + vstr_t vstr; + vstr_init(&vstr, 256); + char *p = vstr.buf; + mp_uint_t current_read = 256; + while ( +# 333 "user/mpy/py/stream.c" 3 4 + 1 +# 333 "user/mpy/py/stream.c" + ) { + int error; + mp_uint_t out_sz = stream_p->read(self_in, p, current_read, &error); + if (out_sz == ((mp_uint_t)-1)) { + if ((0)) { + + + + if (total_size == 0) { + return (((mp_obj_t)&mp_const_none_obj)); + } + break; + } + mp_raise_OSError(error); + } + if (out_sz == 0) { + break; + } + total_size += out_sz; + if (out_sz < current_read) { + current_read -= out_sz; + p += out_sz; + } else { + p = vstr_extend(&vstr, 256); + current_read = 256; + } + } + + vstr.len = total_size; + return mp_obj_new_str_from_vstr((((stream_p)->is_text) ? &mp_type_str : &mp_type_bytes), &vstr); +} + + +static mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (1)); + + mp_int_t max_size = -1; + if (n_args > 1) { + max_size = (((mp_int_t)(args[1])) >> 1); + } + + vstr_t vstr; + if (max_size != -1) { + vstr_init(&vstr, max_size); + } else { + vstr_init(&vstr, 16); + } + + while (max_size == -1 || max_size-- != 0) { + char *p = vstr_add_len(&vstr, 1); + if (p == +# 383 "user/mpy/py/stream.c" 3 4 + ((void *)0) +# 383 "user/mpy/py/stream.c" + ) { + mp_raise_msg(&mp_type_MemoryError, "out of memory"); + } + + int error; + mp_uint_t out_sz = stream_p->read(args[0], p, 1, &error); + if (out_sz == ((mp_uint_t)-1)) { + if ((0)) { + if (vstr.len == 1) { + + + + + + + vstr_clear(&vstr); + return (((mp_obj_t)&mp_const_none_obj)); + } else { + goto done; + } + } + mp_raise_OSError(error); + } + if (out_sz == 0) { +done: + + + + vstr_cut_tail_bytes(&vstr, 1); + break; + } + if (*p == '\n') { + break; + } + } + + return mp_obj_new_str_from_vstr((((stream_p)->is_text) ? &mp_type_str : &mp_type_bytes), &vstr); +} +const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj = {{&mp_type_fun_builtin_var}, +# 421 "user/mpy/py/stream.c" 3 4 +0 +# 421 "user/mpy/py/stream.c" +, 1, 2, .fun.var = stream_unbuffered_readline}; + + +static mp_obj_t stream_unbuffered_readlines(mp_obj_t self) { + mp_obj_t lines = mp_obj_new_list(0, +# 425 "user/mpy/py/stream.c" 3 4 + ((void *)0) +# 425 "user/mpy/py/stream.c" + ); + for (;;) { + mp_obj_t line = stream_unbuffered_readline(1, &self); + if (!mp_obj_is_true(line)) { + break; + } + mp_obj_list_append(lines, line); + } + return lines; +} +const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj = {{&mp_type_fun_builtin_1}, .fun._1 = stream_unbuffered_readlines}; + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self) { + mp_obj_t l_in = stream_unbuffered_readline(1, &self); + if (mp_obj_is_true(l_in)) { + return l_in; + } + return (((mp_obj_t)(void*)4)); +} + +static mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (4)); + + struct mp_stream_seek_t seek_s; + + seek_s.offset = mp_obj_get_int(args[1]); + seek_s.whence = 0; + if (n_args == 3) { + seek_s.whence = mp_obj_get_int(args[2]); + } + + int error; + mp_uint_t res = stream_p->ioctl(args[0], (2), (mp_uint_t)(uintptr_t)&seek_s, &error); + if (res == ((mp_uint_t)-1)) { + mp_raise_OSError(error); + } + + + return mp_obj_new_int_from_uint(seek_s.offset); +} +const mp_obj_fun_builtin_var_t mp_stream_seek_obj = {{&mp_type_fun_builtin_var}, +# 465 "user/mpy/py/stream.c" 3 4 +0 +# 465 "user/mpy/py/stream.c" +, 2, 3, .fun.var = stream_seek}; + +static mp_obj_t stream_tell(mp_obj_t self) { + mp_obj_t offset = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); + mp_obj_t whence = ((mp_obj_t)((((mp_uint_t)( +# 469 "user/mpy/py/stream.c" 3 + 1 +# 469 "user/mpy/py/stream.c" + )) << 1) | 1)); + const mp_obj_t args[3] = {self, offset, whence}; + return stream_seek(3, args); +} +const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj = {{&mp_type_fun_builtin_1}, .fun._1 = stream_tell}; + +static mp_obj_t stream_flush(mp_obj_t self) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(self, (4)); + int error; + mp_uint_t res = stream_p->ioctl(self, (1), 0, &error); + if (res == ((mp_uint_t)-1)) { + mp_raise_OSError(error); + } + return (((mp_obj_t)&mp_const_none_obj)); +} +const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj = {{&mp_type_fun_builtin_1}, .fun._1 = stream_flush}; + +static mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (4)); + + mp_buffer_info_t bufinfo; + uintptr_t val = 0; + if (n_args > 2) { + if (mp_get_buffer(args[2], &bufinfo, (2))) { + val = (uintptr_t)bufinfo.buf; + } else { + val = mp_obj_get_int_truncated(args[2]); + } + } + + int error; + mp_uint_t res = stream_p->ioctl(args[0], mp_obj_get_int(args[1]), val, &error); + if (res == ((mp_uint_t)-1)) { + mp_raise_OSError(error); + } + + return mp_obj_new_int(res); +} +const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj = {{&mp_type_fun_builtin_var}, +# 507 "user/mpy/py/stream.c" 3 4 +0 +# 507 "user/mpy/py/stream.c" +, 2, 3, .fun.var = stream_ioctl}; +# 1 "user/mpy/py/binary.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/binary.c" +# 27 "user/mpy/py/binary.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/binary.c" 2 +# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 +# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 +# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 +# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 + + +typedef struct +{ + int quot; + int rem; +} div_t; + +typedef struct +{ + long quot; + long rem; +} ldiv_t; + + +typedef struct +{ + long long int quot; + long long int rem; +} lldiv_t; + + + + +typedef int (*__compar_fn_t) (const void *, const void *); + + + + + + + +int __locale_mb_cur_max (void); + + + +void abort (void) __attribute__ ((__noreturn__)); +int abs (int); + + + + + +int atexit (void (*__func)(void)); +double atof (const char *__nptr); + + + +int atoi (const char *__nptr); +int _atoi_r (struct _reent *, const char *__nptr); +long atol (const char *__nptr); +long _atol_r (struct _reent *, const char *__nptr); +void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) + + + + ; +void * calloc (size_t __nmemb, size_t __size) ; +div_t div (int __numer, int __denom); +void exit (int __status) __attribute__ ((__noreturn__)); +void free (void *) ; +char * getenv (const char *__string); +char * _getenv_r (struct _reent *, const char *__string); +char * _findenv (const char *, int *); +char * _findenv_r (struct _reent *, const char *, int *); + + + + +long labs (long); +ldiv_t ldiv (long __numer, long __denom); +void * malloc (size_t __size) ; +int mblen (const char *, size_t); +int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); +int mbtowc (wchar_t *restrict, const char *restrict, size_t); +int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +int wctomb (char *, wchar_t); +int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); +size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); +size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); +size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); +size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); +# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * _mkdtemp_r (struct _reent *, char *); +int _mkostemp_r (struct _reent *, char *, int); +int _mkostemps_r (struct _reent *, char *, int, int); +int _mkstemp_r (struct _reent *, char *); +int _mkstemps_r (struct _reent *, char *, int); +char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); +void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); +int rand (void); +void * realloc (void * __r, size_t __size) ; +# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 +void srand (unsigned __seed); +double strtod (const char *restrict __n, char **restrict __end_PTR); +double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); + +float strtof (const char *restrict __n, char **restrict __end_PTR); + + + + + + + +long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); +long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); +unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); +# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 +int system (const char *__string); +# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 +void _Exit (int __status) __attribute__ ((__noreturn__)); + + + + +int _putenv_r (struct _reent *, char *__string); +void * _reallocf_r (struct _reent *, void *, size_t); + + + +int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); +# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 +char * __itoa (int, char *, int); +char * __utoa (unsigned, char *, int); +# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 +long long atoll (const char *__nptr); + +long long _atoll_r (struct _reent *, const char *__nptr); + +long long llabs (long long); +lldiv_t lldiv (long long __numer, long long __denom); +long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); + +long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); + +unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); +# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 +int _unsetenv_r (struct _reent *, const char *__string); + + + + + + +char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); + +void * _malloc_r (struct _reent *, size_t) ; +void * _calloc_r (struct _reent *, size_t, size_t) ; +void _free_r (struct _reent *, void *) ; +void * _realloc_r (struct _reent *, void *, size_t) ; +void _mstats_r (struct _reent *, char *); + +int _system_r (struct _reent *, const char *); + +void __eprintf (const char *, const char *, unsigned int, const char *); +# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 +extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); + +extern long double strtold (const char *restrict, char **restrict); +# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 + +# 29 "user/mpy/py/binary.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/binary.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 31 "user/mpy/py/binary.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 32 "user/mpy/py/binary.c" 2 + +# 1 "user/mpy/py/binary.h" 1 +# 29 "user/mpy/py/binary.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/binary.h" 2 + + + + + +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 34 "user/mpy/py/binary.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 35 "user/mpy/py/binary.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 + + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 36 "user/mpy/py/binary.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/binary.c" 2 + + + + + + + +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) { + size_t size = 0; + int align = 1; + switch (struct_type) { + case '<': case '>': + switch (val_type) { + case 'b': case 'B': + size = 1; break; + case 'h': case 'H': + size = 2; break; + case 'i': case 'I': + size = 4; break; + case 'l': case 'L': + size = 4; break; + case 'q': case 'Q': + size = 8; break; + case 'P': case 'O': case 'S': + size = sizeof(void*); break; + case 'f': + size = sizeof(float); break; + case 'd': + size = sizeof(double); break; + } + break; + case '@': { + + + + + + + + switch (val_type) { + case 0: + case 'b': case 'B': + align = size = 1; break; + case 'h': case 'H': + align = +# 81 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 81 "user/mpy/py/binary.c" + struct { char c; short t; } +# 81 "user/mpy/py/binary.c" 3 4 + , +# 81 "user/mpy/py/binary.c" + t +# 81 "user/mpy/py/binary.c" 3 4 + ) +# 81 "user/mpy/py/binary.c" + ; + size = sizeof(short); break; + case 'i': case 'I': + align = +# 84 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 84 "user/mpy/py/binary.c" + struct { char c; int t; } +# 84 "user/mpy/py/binary.c" 3 4 + , +# 84 "user/mpy/py/binary.c" + t +# 84 "user/mpy/py/binary.c" 3 4 + ) +# 84 "user/mpy/py/binary.c" + ; + size = sizeof(int); break; + case 'l': case 'L': + align = +# 87 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 87 "user/mpy/py/binary.c" + struct { char c; long t; } +# 87 "user/mpy/py/binary.c" 3 4 + , +# 87 "user/mpy/py/binary.c" + t +# 87 "user/mpy/py/binary.c" 3 4 + ) +# 87 "user/mpy/py/binary.c" + ; + size = sizeof(long); break; + case 'q': case 'Q': + align = +# 90 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 90 "user/mpy/py/binary.c" + struct { char c; long long t; } +# 90 "user/mpy/py/binary.c" 3 4 + , +# 90 "user/mpy/py/binary.c" + t +# 90 "user/mpy/py/binary.c" 3 4 + ) +# 90 "user/mpy/py/binary.c" + ; + size = sizeof(long long); break; + case 'P': case 'O': case 'S': + align = +# 93 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 93 "user/mpy/py/binary.c" + struct { char c; void* t; } +# 93 "user/mpy/py/binary.c" 3 4 + , +# 93 "user/mpy/py/binary.c" + t +# 93 "user/mpy/py/binary.c" 3 4 + ) +# 93 "user/mpy/py/binary.c" + ; + size = sizeof(void*); break; + case 'f': + align = +# 96 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 96 "user/mpy/py/binary.c" + struct { char c; float t; } +# 96 "user/mpy/py/binary.c" 3 4 + , +# 96 "user/mpy/py/binary.c" + t +# 96 "user/mpy/py/binary.c" 3 4 + ) +# 96 "user/mpy/py/binary.c" + ; + size = sizeof(float); break; + case 'd': + align = +# 99 "user/mpy/py/binary.c" 3 4 + __builtin_offsetof ( +# 99 "user/mpy/py/binary.c" + struct { char c; double t; } +# 99 "user/mpy/py/binary.c" 3 4 + , +# 99 "user/mpy/py/binary.c" + t +# 99 "user/mpy/py/binary.c" 3 4 + ) +# 99 "user/mpy/py/binary.c" + ; + size = sizeof(double); break; + } + } + } + + if (size == 0) { + mp_raise_ValueError("bad typecode"); + } + + if (palign != +# 109 "user/mpy/py/binary.c" 3 4 + ((void *)0) +# 109 "user/mpy/py/binary.c" + ) { + *palign = align; + } + return size; +} + +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { + mp_int_t val = 0; + switch (typecode) { + case 'b': + val = ((signed char*)p)[index]; + break; + case 0: + case 'B': + val = ((unsigned char*)p)[index]; + break; + case 'h': + val = ((short*)p)[index]; + break; + case 'H': + val = ((unsigned short*)p)[index]; + break; + case 'i': + return mp_obj_new_int(((int*)p)[index]); + case 'I': + return mp_obj_new_int_from_uint(((unsigned int*)p)[index]); + case 'l': + return mp_obj_new_int(((long*)p)[index]); + case 'L': + return mp_obj_new_int_from_uint(((unsigned long*)p)[index]); +# 152 "user/mpy/py/binary.c" + case 'O': + return ((mp_obj_t*)p)[index]; + + case 'P': + return mp_obj_new_int((mp_int_t)(uintptr_t)((void**)p)[index]); + } + return ((mp_obj_t)((((mp_uint_t)(val)) << 1) | 1)); +} + + + + +long long mp_binary_get_int(mp_uint_t size, +# 164 "user/mpy/py/binary.c" 3 4 + _Bool +# 164 "user/mpy/py/binary.c" + is_signed, +# 164 "user/mpy/py/binary.c" 3 4 + _Bool +# 164 "user/mpy/py/binary.c" + big_endian, const byte *src) { + int delta; + if (!big_endian) { + delta = -1; + src += size - 1; + } else { + delta = 1; + } + + long long val = 0; + if (is_signed && *src & 0x80) { + val = -1; + } + for (uint i = 0; i < size; i++) { + val <<= 8; + val |= *src; + src += delta; + } + + return val; +} + + +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) { + byte *p = *ptr; + mp_uint_t align; + + size_t size = mp_binary_get_size(struct_type, val_type, &align); + if (struct_type == '@') { + + p = (byte*)(void*)(((uintptr_t)(p) + (((size_t)align) - 1)) & ~(((size_t)align) - 1)); + + struct_type = '<'; + + + + } + *ptr = p + size; + + long long val = mp_binary_get_int(size, (val_type > 'Z'), (struct_type == '>'), p); + + if (val_type == 'O') { + return (mp_obj_t)(mp_uint_t)val; + } else if (val_type == 'S') { + const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val; + return mp_obj_new_str(s_val, strlen(s_val), +# 209 "user/mpy/py/binary.c" 3 4 + 0 +# 209 "user/mpy/py/binary.c" + ); +# 218 "user/mpy/py/binary.c" + } else if ((val_type > 'Z')) { + if ((long long)((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) <= val && val <= (long long)((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)))))) { + return mp_obj_new_int((mp_int_t)val); + } else { + return mp_obj_new_int_from_ll(val); + } + } else { + if ((unsigned long long)val <= (unsigned long long)((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)))))) { + return mp_obj_new_int_from_uint((mp_uint_t)val); + } else { + return mp_obj_new_int_from_ull(val); + } + } +} + +void mp_binary_set_int(mp_uint_t val_sz, +# 233 "user/mpy/py/binary.c" 3 4 + _Bool +# 233 "user/mpy/py/binary.c" + big_endian, byte *dest, mp_uint_t val) { + if ((1) && !big_endian) { + memcpy(dest, &val, val_sz); + } else if ((!(1)) && big_endian) { + + memcpy(dest, (byte*)&val + sizeof(mp_uint_t) - val_sz, val_sz); + } else { + const byte *src; + if ((1)) { + src = (const byte*)&val + val_sz; + } else { + src = (const byte*)&val + sizeof(mp_uint_t); + } + while (val_sz--) { + *dest++ = *--src; + } + } +} + +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr) { + byte *p = *ptr; + mp_uint_t align; + + size_t size = mp_binary_get_size(struct_type, val_type, &align); + if (struct_type == '@') { + + p = (byte*)(void*)(((uintptr_t)(p) + (((size_t)align) - 1)) & ~(((size_t)align) - 1)); + if ((1)) { + struct_type = '<'; + } else { + struct_type = '>'; + } + } + *ptr = p + size; + + mp_uint_t val; + switch (val_type) { + case 'O': + val = (mp_uint_t)val_in; + break; +# 294 "user/mpy/py/binary.c" + default: + + + + + + + { + val = mp_obj_get_int(val_in); + + if ((sizeof(mp_uint_t)) < 8 && size > sizeof(val)) { + int c = ((val_type > 'Z') && (mp_int_t)val < 0) ? 0xff : 0x00; + memset(p, c, size); + if (struct_type == '>') { + p += size - sizeof(val); + } + } + } + } + + mp_binary_set_int((((size_t)size) < (sizeof(val)) ? ((size_t)size) : (sizeof(val))), struct_type == '>', p, val); +} + +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) { + switch (typecode) { +# 328 "user/mpy/py/binary.c" + case 'O': + ((mp_obj_t*)p)[index] = val_in; + break; + default: +# 340 "user/mpy/py/binary.c" + mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in)); + } +} + +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val) { + switch (typecode) { + case 'b': + ((signed char*)p)[index] = val; + break; + case 0: + case 'B': + ((unsigned char*)p)[index] = val; + break; + case 'h': + ((short*)p)[index] = val; + break; + case 'H': + ((unsigned short*)p)[index] = val; + break; + case 'i': + ((int*)p)[index] = val; + break; + case 'I': + ((unsigned int*)p)[index] = val; + break; + case 'l': + ((long*)p)[index] = val; + break; + case 'L': + ((unsigned long*)p)[index] = val; + break; +# 388 "user/mpy/py/binary.c" + case 'P': + ((void**)p)[index] = (void*)(uintptr_t)val; + break; + } +} +# 1 "user/mpy/py/builtinimport.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/builtinimport.c" +# 28 "user/mpy/py/builtinimport.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/builtinimport.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/builtinimport.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/builtinimport.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 33 "user/mpy/py/builtinimport.c" 2 +# 1 "user/mpy/py/compile.h" 1 +# 29 "user/mpy/py/compile.h" +# 1 "user/mpy/py/lexer.h" 1 +# 32 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/compile.h" 2 +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 31 "user/mpy/py/compile.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 32 "user/mpy/py/compile.h" 2 + + +enum { + MP_EMIT_OPT_NONE, + MP_EMIT_OPT_BYTECODE, + MP_EMIT_OPT_NATIVE_PYTHON, + MP_EMIT_OPT_VIPER, + MP_EMIT_OPT_ASM, +}; + + + +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, +# 44 "user/mpy/py/compile.h" 3 4 + _Bool +# 44 "user/mpy/py/compile.h" + is_repl); + + + + + + + +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); +# 34 "user/mpy/py/builtinimport.c" 2 +# 1 "user/mpy/py/objmodule.h" 1 +# 31 "user/mpy/py/objmodule.h" +extern const mp_map_t mp_builtin_module_map; +extern const mp_map_t mp_builtin_module_weak_links_map; + +mp_obj_t mp_module_get(qstr module_name); +void mp_module_register(qstr qstr, mp_obj_t module); +# 35 "user/mpy/py/builtinimport.c" 2 +# 1 "user/mpy/py/persistentcode.h" 1 +# 33 "user/mpy/py/persistentcode.h" +mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader); +mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len); +mp_raw_code_t *mp_raw_code_load_file(const char *filename); + +void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print); +void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename); +# 36 "user/mpy/py/builtinimport.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/builtinimport.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 38 "user/mpy/py/builtinimport.c" 2 +# 1 "user/mpy/py/frozenmod.h" 1 +# 31 "user/mpy/py/frozenmod.h" +enum { + MP_FROZEN_NONE, + MP_FROZEN_STR, + MP_FROZEN_MPY, +}; + +int mp_find_frozen_module(const char *str, size_t len, void **data); +const char *mp_find_frozen_str(const char *str, size_t *len); +mp_import_stat_t mp_frozen_stat(const char *str); +# 39 "user/mpy/py/builtinimport.c" 2 +# 50 "user/mpy/py/builtinimport.c" + +# 50 "user/mpy/py/builtinimport.c" 3 4 +_Bool +# 50 "user/mpy/py/builtinimport.c" + mp_obj_is_package(mp_obj_t module) { + mp_obj_t dest[2]; + mp_load_method_maybe(module, MP_QSTR___path__, dest); + return dest[0] != (((mp_obj_t)(void*)0)); +} + + + +static mp_import_stat_t mp_import_stat_any(const char *path) { + + mp_import_stat_t st = mp_frozen_stat(path); + if (st != MP_IMPORT_STAT_NO_EXIST) { + return st; + } + + return mp_import_stat(path); +} + +static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { + mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + if (stat == MP_IMPORT_STAT_FILE) { + return stat; + } +# 82 "user/mpy/py/builtinimport.c" + return MP_IMPORT_STAT_NO_EXIST; +} + +static mp_import_stat_t stat_dir_or_file(vstr_t *path) { + mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + (void)0; + if (stat == MP_IMPORT_STAT_DIR) { + return stat; + } + + + vstr_add_str(path, ".py"); + return stat_file_py_or_mpy(path); +} + +static mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { +# 107 "user/mpy/py/builtinimport.c" + vstr_add_strn(dest, file_str, file_len); + return stat_dir_or_file(dest); +# 131 "user/mpy/py/builtinimport.c" +} + + +static void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) { + + + + + + + mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); + mp_parse_compile_execute(lex, MP_PARSE_FILE_INPUT, mod_globals, mod_globals); +} + + + +static void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code) { + + + + + + + + mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); + + + mp_obj_dict_t *volatile old_globals = mp_globals_get(); + mp_obj_dict_t *volatile old_locals = mp_locals_get(); + + + mp_globals_set(mod_globals); + mp_locals_set(mod_globals); + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t module_fun = mp_make_function_from_raw_code(raw_code, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))); + mp_call_function_0(module_fun); + + + nlr_pop(); + mp_globals_set(old_globals); + mp_locals_set(old_locals); + } else { + + mp_globals_set(old_globals); + mp_locals_set(old_locals); + nlr_jump(nlr.ret_val); + } +} + + +static void do_load(mp_obj_t module_obj, vstr_t *file) { + + char *file_str = vstr_null_terminated_str(file); + + + + + + void *modref; + int frozen_type = mp_find_frozen_module(file_str, file->len, &modref); +# 207 "user/mpy/py/builtinimport.c" + if (frozen_type == MP_FROZEN_MPY) { + do_execute_raw_code(module_obj, modref); + return; + } +# 225 "user/mpy/py/builtinimport.c" + { + mp_lexer_t *lex = mp_lexer_new_from_file(file_str); + do_load_from_lexer(module_obj, lex); + return; + } + + + + + +} + +static void chop_component(const char *start, const char **end) { + const char *p = *end; + while (p > start) { + if (*--p == '.') { + *end = p; + return; + } + } + *end = p; +} + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { +# 258 "user/mpy/py/builtinimport.c" + mp_obj_t module_name = args[0]; + mp_obj_t fromtuple = (((mp_obj_t)&mp_const_none_obj)); + mp_int_t level = 0; + if (n_args >= 4) { + fromtuple = args[3]; + if (n_args >= 5) { + level = (((mp_int_t)(args[4])) >> 1); + if (level < 0) { + mp_raise_ValueError( +# 266 "user/mpy/py/builtinimport.c" 3 4 + ((void *)0) +# 266 "user/mpy/py/builtinimport.c" + ); + } + } + } + + size_t mod_len; + const char *mod_str = mp_obj_str_get_data(module_name, &mod_len); + + if (level != 0) { + + + + + + + + level--; + mp_obj_t this_name_q = mp_obj_dict_get(((mp_obj_t)mp_globals_get()), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2))); + +# 284 "user/mpy/py/builtinimport.c" 3 + (( +# 284 "user/mpy/py/builtinimport.c" + this_name_q != (((mp_obj_t)(void*)0)) +# 284 "user/mpy/py/builtinimport.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/builtinimport.c", 284, __func__, +# 284 "user/mpy/py/builtinimport.c" + "this_name_q != MP_OBJ_NULL" +# 284 "user/mpy/py/builtinimport.c" 3 + )) +# 284 "user/mpy/py/builtinimport.c" + ; + + + + + + + mp_map_t *globals_map = &mp_globals_get()->map; + mp_map_elem_t *elem = mp_map_lookup(globals_map, ((mp_obj_t)((((mp_uint_t)(MP_QSTR___path__)) << 2) | 2)), MP_MAP_LOOKUP); + +# 293 "user/mpy/py/builtinimport.c" 3 4 + _Bool +# 293 "user/mpy/py/builtinimport.c" + is_pkg = (elem != +# 293 "user/mpy/py/builtinimport.c" 3 4 + ((void *)0) +# 293 "user/mpy/py/builtinimport.c" + ); +# 302 "user/mpy/py/builtinimport.c" + size_t this_name_l; + const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l); + + const char *p = this_name + this_name_l; + if (!is_pkg) { + + + chop_component(this_name, &p); + } + + while (level--) { + chop_component(this_name, &p); + } + + + if (p == this_name) { + mp_raise_ValueError("cannot perform relative import"); + } + + uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); + char *new_mod = +# 322 "user/mpy/py/builtinimport.c" 3 + __builtin_alloca( +# 322 "user/mpy/py/builtinimport.c" + new_mod_l +# 322 "user/mpy/py/builtinimport.c" 3 + ) +# 322 "user/mpy/py/builtinimport.c" + ; + memcpy(new_mod, this_name, p - this_name); + if (mod_len != 0) { + new_mod[p - this_name] = '.'; + memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len); + } + + qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); + (void)0; + module_name = ((mp_obj_t)((((mp_uint_t)(new_mod_q)) << 2) | 2)); + mod_str = new_mod; + mod_len = new_mod_l; + } + + + qstr module_name_qstr = mp_obj_str_get_qstr(module_name); + mp_obj_t module_obj = mp_module_get(module_name_qstr); + if (module_obj != (((mp_obj_t)(void*)0))) { + (void)0; + + char *p = strchr(mod_str, '.'); + if (p == +# 343 "user/mpy/py/builtinimport.c" 3 4 + ((void *)0) +# 343 "user/mpy/py/builtinimport.c" + ) { + return module_obj; + } + + if (fromtuple != (((mp_obj_t)&mp_const_none_obj))) { + return module_obj; + } + + qstr pkg_name = qstr_from_strn(mod_str, p - mod_str); + return mp_module_get(pkg_name); + } + (void)0; + + uint last = 0; + vstr_t path; char path_buf[((256))]; vstr_init_fixed_buf(&path, ((256)), path_buf); + module_obj = (((mp_obj_t)(void*)0)); + mp_obj_t top_module_obj = (((mp_obj_t)(void*)0)); + mp_obj_t outer_module_obj = (((mp_obj_t)(void*)0)); + uint i; + for (i = 1; i <= mod_len; i++) { + if (i == mod_len || mod_str[i] == '.') { + + qstr mod_name = qstr_from_strn(mod_str, i); + (void)0; + (void)0; + + + mp_import_stat_t stat; + if (vstr_len(&path) == 0) { + + stat = find_file(mod_str, i, &path); + } else { + + vstr_add_char(&path, '/'); + vstr_add_strn(&path, mod_str + last, i - last); + stat = stat_dir_or_file(&path); + } + (void)0; + + if (stat == MP_IMPORT_STAT_NO_EXIST) { +# 395 "user/mpy/py/builtinimport.c" + { + + + if (((1)) == (1)) { + mp_raise_msg(&mp_type_ImportError, "module not found"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ImportError, "no module named '%q'", mod_name))) + ; + } + } + } else { + + module_obj = mp_module_get(mod_name); + } + + if (module_obj == (((mp_obj_t)(void*)0))) { + + + module_obj = mp_obj_new_module(mod_name); +# 423 "user/mpy/py/builtinimport.c" + if (i == mod_len && fromtuple == (((mp_obj_t)&mp_const_false_obj)) && stat != MP_IMPORT_STAT_DIR) { + mp_obj_module_t *o = ((void*)module_obj); + mp_obj_dict_store(((mp_obj_t)o->globals), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___main__)) << 2) | 2))); + + + + + + + } + + if (stat == MP_IMPORT_STAT_DIR) { + (void)0; + + + mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(&path), vstr_len(&path), +# 438 "user/mpy/py/builtinimport.c" 3 4 + 0 +# 438 "user/mpy/py/builtinimport.c" + )); + size_t orig_path_len = path.len; + vstr_add_char(&path, '/'); + vstr_add_str(&path, "__init__.py"); + if (stat_file_py_or_mpy(&path) != MP_IMPORT_STAT_FILE) { + + } else { + do_load(module_obj, &path); + } + path.len = orig_path_len; + } else { + do_load(module_obj, &path); + + + + + } + } + if (outer_module_obj != (((mp_obj_t)(void*)0))) { + qstr s = qstr_from_strn(mod_str + last, i - last); + mp_store_attr(outer_module_obj, s, module_obj); + } + outer_module_obj = module_obj; + if (top_module_obj == (((mp_obj_t)(void*)0))) { + top_module_obj = module_obj; + } + last = i + 1; + } + } + + + if (fromtuple != (((mp_obj_t)&mp_const_none_obj))) { + return module_obj; + } + + return top_module_obj; +} +const mp_obj_fun_builtin_var_t mp_builtin___import___obj = {{&mp_type_fun_builtin_var}, +# 475 "user/mpy/py/builtinimport.c" 3 4 +0 +# 475 "user/mpy/py/builtinimport.c" +, 1, 5, .fun.var = mp_builtin___import__}; +# 1 "user/mpy/py/builtinevex.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/builtinevex.c" +# 27 "user/mpy/py/builtinevex.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/builtinevex.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 4 +# 5 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 9 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 + +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 30 "user/mpy/py/builtinevex.c" 2 +# 1 "user/mpy/py/objfun.h" 1 +# 29 "user/mpy/py/objfun.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objfun.h" 2 + +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 31 "user/mpy/py/builtinevex.c" 2 +# 1 "user/mpy/py/compile.h" 1 +# 29 "user/mpy/py/compile.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/compile.h" 2 +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 31 "user/mpy/py/compile.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 32 "user/mpy/py/compile.h" 2 + + +enum { + MP_EMIT_OPT_NONE, + MP_EMIT_OPT_BYTECODE, + MP_EMIT_OPT_NATIVE_PYTHON, + MP_EMIT_OPT_VIPER, + MP_EMIT_OPT_ASM, +}; + + + +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, +# 44 "user/mpy/py/compile.h" 3 4 + _Bool +# 44 "user/mpy/py/compile.h" + is_repl); + + + + + + + +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); +# 32 "user/mpy/py/builtinevex.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/builtinevex.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 34 "user/mpy/py/builtinevex.c" 2 +# 112 "user/mpy/py/builtinevex.c" +static mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) { + + mp_obj_dict_t *globals = mp_globals_get(); + mp_obj_dict_t *locals = mp_locals_get(); + for (size_t i = 1; i < 3 && i < n_args; ++i) { + if (args[i] != (((mp_obj_t)&mp_const_none_obj))) { + if (!(MP_OBJ_IS_OBJ(args[i]) && (((mp_obj_base_t*)((void*)args[i]))->type == (&mp_type_dict)))) { + mp_raise_TypeError( +# 119 "user/mpy/py/builtinevex.c" 3 4 + ((void *)0) +# 119 "user/mpy/py/builtinevex.c" + ); + } + locals = ((void*)args[i]); + if (i == 1) { + globals = locals; + } + } + } + + + + + + + + size_t str_len; + const char *str = mp_obj_str_get_data(args[0], &str_len); + + + + mp_lexer_t *lex; + if ((0) && parse_input_kind == MP_PARSE_SINGLE_INPUT) { + lex = mp_lexer_new_from_file(str); + parse_input_kind = MP_PARSE_FILE_INPUT; + } else { + lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0); + } + + return mp_parse_compile_execute(lex, parse_input_kind, globals, locals); +} + +static mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) { + return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT); +} +const mp_obj_fun_builtin_var_t mp_builtin_eval_obj = {{&mp_type_fun_builtin_var}, +# 153 "user/mpy/py/builtinevex.c" 3 4 +0 +# 153 "user/mpy/py/builtinevex.c" +, 1, 3, .fun.var = mp_builtin_eval}; + +static mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) { + return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT); +} +const mp_obj_fun_builtin_var_t mp_builtin_exec_obj = {{&mp_type_fun_builtin_var}, +# 158 "user/mpy/py/builtinevex.c" 3 4 +0 +# 158 "user/mpy/py/builtinevex.c" +, 1, 3, .fun.var = mp_builtin_exec}; +# 1 "user/mpy/py/builtinhelp.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/builtinhelp.c" +# 27 "user/mpy/py/builtinhelp.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/builtinhelp.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/builtinhelp.c" 2 + +# 1 "user/mpy/py/builtin.h" 1 +# 29 "user/mpy/py/builtin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/builtin.h" 2 + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 31 "user/mpy/py/builtinhelp.c" 2 +# 1 "user/mpy/py/objmodule.h" 1 +# 31 "user/mpy/py/objmodule.h" +extern const mp_map_t mp_builtin_module_map; +extern const mp_map_t mp_builtin_module_weak_links_map; + +mp_obj_t mp_module_get(qstr module_name); +void mp_module_register(qstr qstr, mp_obj_t module); +# 32 "user/mpy/py/builtinhelp.c" 2 +# 1 "user/mpy/py/modarray.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modarray.c" +# 27 "user/mpy/py/modarray.c" +# 1 "user/mpy/py/builtin.h" 1 +# 29 "user/mpy/py/builtin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/builtin.h" 2 + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 28 "user/mpy/py/modarray.c" 2 +# 1 "user/mpy/py/modbuiltins.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modbuiltins.c" +# 27 "user/mpy/py/modbuiltins.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/modbuiltins.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/modbuiltins.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 30 "user/mpy/py/smallint.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/smallint.h" 2 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 32 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 31 "user/mpy/py/objint.h" 2 + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 33 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 34 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/objtype.h" 1 +# 33 "user/mpy/py/objtype.h" +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 35 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 36 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 38 "user/mpy/py/modbuiltins.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 39 "user/mpy/py/modbuiltins.c" 2 +# 51 "user/mpy/py/modbuiltins.c" +static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) { + +# 52 "user/mpy/py/modbuiltins.c" 3 + (( +# 52 "user/mpy/py/modbuiltins.c" + 2 <= n_args +# 52 "user/mpy/py/modbuiltins.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/modbuiltins.c", 52, __func__, +# 52 "user/mpy/py/modbuiltins.c" + "2 <= n_args" +# 52 "user/mpy/py/modbuiltins.c" 3 + )) +# 52 "user/mpy/py/modbuiltins.c" + ; + + + mp_obj_dict_t *old_locals = mp_locals_get(); + mp_obj_t class_locals = mp_obj_new_dict(0); + mp_locals_set(((void*)class_locals)); + + + mp_obj_t cell = mp_call_function_0(args[0]); + + + mp_locals_set(old_locals); + + + mp_obj_t meta; + if (n_args == 2) { + + meta = ((mp_obj_t)&mp_type_type); + } else { + + meta = ((mp_obj_t)mp_obj_get_type(args[2])); + } + + + + + mp_obj_t meta_args[3]; + meta_args[0] = args[1]; + meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); + meta_args[2] = class_locals; + mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args); + + + if (cell != (((mp_obj_t)&mp_const_none_obj))) { + mp_obj_cell_set(cell, new_class); + } + + return new_class; +} +const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj = {{&mp_type_fun_builtin_var}, +# 91 "user/mpy/py/modbuiltins.c" 3 4 +0 +# 91 "user/mpy/py/modbuiltins.c" +, 2, (0xffff), .fun.var = mp_builtin___build_class__}; + +static mp_obj_t mp_builtin_abs(mp_obj_t o_in) { +# 113 "user/mpy/py/modbuiltins.c" + return mp_obj_int_abs(o_in); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_abs}; + +static mp_obj_t mp_builtin_all(mp_obj_t o_in) { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(o_in, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + if (!mp_obj_is_true(item)) { + return (((mp_obj_t)&mp_const_false_obj)); + } + } + return (((mp_obj_t)&mp_const_true_obj)); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_all}; + +static mp_obj_t mp_builtin_any(mp_obj_t o_in) { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(o_in, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + if (mp_obj_is_true(item)) { + return (((mp_obj_t)&mp_const_true_obj)); + } + } + return (((mp_obj_t)&mp_const_false_obj)); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_any}; + +static mp_obj_t mp_builtin_bin(mp_obj_t o_in) { + mp_obj_t args[] = { ((mp_obj_t)((((mp_uint_t)(MP_QSTR__brace_open__colon__hash_b_brace_close_)) << 2) | 2)), o_in }; + return mp_obj_str_format((sizeof(args) / sizeof((args)[0])), args, +# 145 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 145 "user/mpy/py/modbuiltins.c" + ); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_bin}; + +static mp_obj_t mp_builtin_callable(mp_obj_t o_in) { + if (mp_obj_is_callable(o_in)) { + return (((mp_obj_t)&mp_const_true_obj)); + } else { + return (((mp_obj_t)&mp_const_false_obj)); + } +} +const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_callable}; + +static mp_obj_t mp_builtin_chr(mp_obj_t o_in) { +# 185 "user/mpy/py/modbuiltins.c" + mp_int_t ord = mp_obj_get_int(o_in); + if (0 <= ord && ord <= 0xff) { + char str[1] = {ord}; + return mp_obj_new_str(str, 1, +# 188 "user/mpy/py/modbuiltins.c" 3 4 + 1 +# 188 "user/mpy/py/modbuiltins.c" + ); + } else { + mp_raise_ValueError("chr() arg not in range(256)"); + } + +} +const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_chr}; + +static mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { + + + mp_obj_dict_t *dict = +# 199 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 199 "user/mpy/py/modbuiltins.c" + ; + mp_map_t *members = +# 200 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 200 "user/mpy/py/modbuiltins.c" + ; + if (n_args == 0) { + + dict = mp_locals_get(); + } else { + + if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_module)))) { + dict = mp_obj_module_get_globals(args[0]); + } else { + mp_obj_type_t *type; + if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_type)))) { + type = ((void*)args[0]); + } else { + type = mp_obj_get_type(args[0]); + } + if (type->locals_dict != +# 215 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 215 "user/mpy/py/modbuiltins.c" + && type->locals_dict->base.type == &mp_type_dict) { + dict = type->locals_dict; + } + } + if (((mp_obj_get_type(args[0]))->make_new == mp_obj_instance_make_new)) { + mp_obj_instance_t *inst = ((void*)args[0]); + members = &inst->members; + } + } + + mp_obj_t dir = mp_obj_new_list(0, +# 225 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 225 "user/mpy/py/modbuiltins.c" + ); + if (dict != +# 226 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 226 "user/mpy/py/modbuiltins.c" + ) { + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + mp_obj_list_append(dir, dict->map.table[i].key); + } + } + } + if (members != +# 233 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 233 "user/mpy/py/modbuiltins.c" + ) { + for (size_t i = 0; i < members->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(members, i)) { + mp_obj_list_append(dir, members->table[i].key); + } + } + } + return dir; +} +const mp_obj_fun_builtin_var_t mp_builtin_dir_obj = {{&mp_type_fun_builtin_var}, +# 242 "user/mpy/py/modbuiltins.c" 3 4 +0 +# 242 "user/mpy/py/modbuiltins.c" +, 0, 1, .fun.var = mp_builtin_dir}; + +static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) { + return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_divmod}; + +static mp_obj_t mp_builtin_hash(mp_obj_t o_in) { + + return mp_unary_op(MP_UNARY_OP_HASH, o_in); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_hash}; + +static mp_obj_t mp_builtin_hex(mp_obj_t o_in) { + return mp_binary_op(MP_BINARY_OP_MODULO, ((mp_obj_t)((((mp_uint_t)(MP_QSTR__percent__hash_x)) << 2) | 2)), o_in); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_hex}; +# 289 "user/mpy/py/modbuiltins.c" +static mp_obj_t mp_builtin_iter(mp_obj_t o_in) { + return mp_getiter(o_in, +# 290 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 290 "user/mpy/py/modbuiltins.c" + ); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_iter}; +# 350 "user/mpy/py/modbuiltins.c" +static mp_obj_t mp_builtin_next(mp_obj_t o) { + mp_obj_t ret = mp_iternext_allow_raise(o); + if (ret == (((mp_obj_t)(void*)4))) { + nlr_jump(((void*)mp_obj_new_exception(&mp_type_StopIteration))); + } else { + return ret; + } +} +const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_next}; + +static mp_obj_t mp_builtin_oct(mp_obj_t o_in) { + return mp_binary_op(MP_BINARY_OP_MODULO, ((mp_obj_t)((((mp_uint_t)(MP_QSTR__percent__hash_o)) << 2) | 2)), o_in); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_oct}; + +static mp_obj_t mp_builtin_ord(mp_obj_t o_in) { + size_t len; + const char *str = mp_obj_str_get_data(o_in, &len); +# 392 "user/mpy/py/modbuiltins.c" + if (len == 1) { + + return mp_obj_new_int(((const byte*)str)[0]); + } + + + if (((1)) == (1)) { + mp_raise_TypeError("ord expects a character"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "ord() expected a character, but string of length %d found", (int)len))) + ; + } +} +const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_ord}; + +static mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) { + switch (n_args) { + case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]); + default: + + mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported"); + + + + + + } +} +const mp_obj_fun_builtin_var_t mp_builtin_pow_obj = {{&mp_type_fun_builtin_var}, +# 420 "user/mpy/py/modbuiltins.c" 3 4 +0 +# 420 "user/mpy/py/modbuiltins.c" +, 2, 3, .fun.var = mp_builtin_pow}; + +static mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sep)) << 2) | 2)), MP_MAP_LOOKUP); + mp_map_elem_t *end_elem = mp_map_lookup(kwargs, ((mp_obj_t)((((mp_uint_t)(MP_QSTR_end)) << 2) | 2)), MP_MAP_LOOKUP); + const char *sep_data = " "; + size_t sep_len = 1; + const char *end_data = "\n"; + size_t end_len = 1; + if (sep_elem != +# 429 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 429 "user/mpy/py/modbuiltins.c" + && sep_elem->value != (((mp_obj_t)&mp_const_none_obj))) { + sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len); + } + if (end_elem != +# 432 "user/mpy/py/modbuiltins.c" 3 4 + ((void *)0) +# 432 "user/mpy/py/modbuiltins.c" + && end_elem->value != (((mp_obj_t)&mp_const_none_obj))) { + end_data = mp_obj_str_get_data(end_elem->value, &end_len); + } +# 444 "user/mpy/py/modbuiltins.c" + for (size_t i = 0; i < n_args; i++) { + if (i > 0) { + + + + mp_print_strn(&mp_plat_print, sep_data, sep_len, 0, 0, 0); + + } + + + + mp_obj_print_helper(&mp_plat_print, args[i], PRINT_STR); + + } + + + + mp_print_strn(&mp_plat_print, end_data, end_len, 0, 0, 0); + + return (((mp_obj_t)&mp_const_none_obj)); +} +const mp_obj_fun_builtin_var_t mp_builtin_print_obj = {{&mp_type_fun_builtin_var}, +# 465 "user/mpy/py/modbuiltins.c" 3 4 +1 +# 465 "user/mpy/py/modbuiltins.c" +, 0, (0xffff), .fun.kw = mp_builtin_print}; + +static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { + if (o != (((mp_obj_t)&mp_const_none_obj))) { + mp_obj_print_helper(&mp_plat_print, o, PRINT_REPR); + mp_print_str(&mp_plat_print, "\n"); + + + + + + } + return (((mp_obj_t)&mp_const_none_obj)); +} +const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin___repl_print__}; + +static mp_obj_t mp_builtin_repr(mp_obj_t o_in) { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + mp_obj_print_helper(&print, o_in, PRINT_REPR); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_repr}; + +static mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) { + mp_obj_t o_in = args[0]; + if ((MP_OBJ_IS_SMALL_INT(o_in) || (MP_OBJ_IS_OBJ(o_in) && (((mp_obj_base_t*)((void*)o_in))->type == (&mp_type_int))))) { + return o_in; + } +# 509 "user/mpy/py/modbuiltins.c" + mp_int_t r = mp_obj_get_int(o_in); + return mp_obj_new_int(r); + +} +const mp_obj_fun_builtin_var_t mp_builtin_round_obj = {{&mp_type_fun_builtin_var}, +# 513 "user/mpy/py/modbuiltins.c" 3 4 +0 +# 513 "user/mpy/py/modbuiltins.c" +, 1, 2, .fun.var = mp_builtin_round}; + +static mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) { + mp_obj_t value; + switch (n_args) { + case 1: value = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); break; + default: value = args[1]; break; + } + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(args[0], &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { + value = mp_binary_op(MP_BINARY_OP_ADD, value, item); + } + return value; +} +const mp_obj_fun_builtin_var_t mp_builtin_sum_obj = {{&mp_type_fun_builtin_var}, +# 529 "user/mpy/py/modbuiltins.c" 3 4 +0 +# 529 "user/mpy/py/modbuiltins.c" +, 1, 2, .fun.var = mp_builtin_sum}; + +static mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + if (n_args > 1) { + mp_raise_TypeError("must use keyword argument for key function"); + } + mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); + mp_obj_list_sort(1, &self, kwargs); + + return self; +} +const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj = {{&mp_type_fun_builtin_var}, +# 540 "user/mpy/py/modbuiltins.c" 3 4 +1 +# 540 "user/mpy/py/modbuiltins.c" +, 1, (0xffff), .fun.kw = mp_builtin_sorted}; + + +static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t defval) { + mp_obj_t dest[2]; + + ((defval == (((mp_obj_t)(void*)0))) ? mp_load_method : mp_load_method_maybe)(base, attr, dest); + if (dest[0] == (((mp_obj_t)(void*)0))) { + return defval; + } else if (dest[1] == (((mp_obj_t)(void*)0))) { + + return dest[0]; + } else { + + return mp_obj_new_bound_meth(dest[0], dest[1]); + } +} + +static mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) { + mp_obj_t defval = (((mp_obj_t)(void*)0)); + if (n_args > 2) { + defval = args[2]; + } + return mp_load_attr_default(args[0], mp_obj_str_get_qstr(args[1]), defval); +} +const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj = {{&mp_type_fun_builtin_var}, +# 565 "user/mpy/py/modbuiltins.c" 3 4 +0 +# 565 "user/mpy/py/modbuiltins.c" +, 2, 3, .fun.var = mp_builtin_getattr}; + +static mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) { + mp_store_attr(base, mp_obj_str_get_qstr(attr), value); + return (((mp_obj_t)&mp_const_none_obj)); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj = {{&mp_type_fun_builtin_3}, .fun._3 = mp_builtin_setattr}; +# 580 "user/mpy/py/modbuiltins.c" +static mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { + qstr attr = mp_obj_str_get_qstr(attr_in); + + mp_obj_t dest[2]; + + + + + mp_load_method_maybe(object_in, attr, dest); + + return mp_obj_new_bool(dest[0] != (((mp_obj_t)(void*)0))); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_hasattr}; + +static mp_obj_t mp_builtin_globals(void) { + return ((mp_obj_t)mp_globals_get()); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_builtin_globals}; + +static mp_obj_t mp_builtin_locals(void) { + return ((mp_obj_t)mp_locals_get()); +} +const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_builtin_locals}; + + +const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_obj_id}; +const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_obj_len}; + +static const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR_builtins)) << 2) | 2)) }, + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___build_class__)) << 2) | 2)), (&mp_builtin___build_class___obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___import__)) << 2) | 2)), (&mp_builtin___import___obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___repl_print__)) << 2) | 2)), (&mp_builtin___repl_print___obj) }, + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_bool)) << 2) | 2)), (&mp_type_bool) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_bytes)) << 2) | 2)), (&mp_type_bytes) }, + + + + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_dict)) << 2) | 2)), (&mp_type_dict) }, +# 638 "user/mpy/py/modbuiltins.c" + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_int)) << 2) | 2)), (&mp_type_int) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_list)) << 2) | 2)), (&mp_type_list) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_map)) << 2) | 2)), (&mp_type_map) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_object)) << 2) | 2)), (&mp_type_object) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_range)) << 2) | 2)), (&mp_type_range) }, +# 658 "user/mpy/py/modbuiltins.c" + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_str)) << 2) | 2)), (&mp_type_str) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_super)) << 2) | 2)), (&mp_type_super) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_tuple)) << 2) | 2)), (&mp_type_tuple) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_type)) << 2) | 2)), (&mp_type_type) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_zip)) << 2) | 2)), (&mp_type_zip) }, + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_classmethod)) << 2) | 2)), (&mp_type_classmethod) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_staticmethod)) << 2) | 2)), (&mp_type_staticmethod) }, + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_Ellipsis)) << 2) | 2)), (&mp_const_ellipsis_obj) }, + + + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_abs)) << 2) | 2)), (&mp_builtin_abs_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_all)) << 2) | 2)), (&mp_builtin_all_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_any)) << 2) | 2)), (&mp_builtin_any_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_bin)) << 2) | 2)), (&mp_builtin_bin_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_callable)) << 2) | 2)), (&mp_builtin_callable_obj) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_chr)) << 2) | 2)), (&mp_builtin_chr_obj) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_dir)) << 2) | 2)), (&mp_builtin_dir_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_divmod)) << 2) | 2)), (&mp_builtin_divmod_obj) }, + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_eval)) << 2) | 2)), (&mp_builtin_eval_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_exec)) << 2) | 2)), (&mp_builtin_exec_obj) }, + + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_getattr)) << 2) | 2)), (&mp_builtin_getattr_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_setattr)) << 2) | 2)), (&mp_builtin_setattr_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_globals)) << 2) | 2)), (&mp_builtin_globals_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_hasattr)) << 2) | 2)), (&mp_builtin_hasattr_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_hash)) << 2) | 2)), (&mp_builtin_hash_obj) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_hex)) << 2) | 2)), (&mp_builtin_hex_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_id)) << 2) | 2)), (&mp_builtin_id_obj) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isinstance)) << 2) | 2)), (&mp_builtin_isinstance_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_issubclass)) << 2) | 2)), (&mp_builtin_issubclass_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_iter)) << 2) | 2)), (&mp_builtin_iter_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_len)) << 2) | 2)), (&mp_builtin_len_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_locals)) << 2) | 2)), (&mp_builtin_locals_obj) }, + + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_next)) << 2) | 2)), (&mp_builtin_next_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_oct)) << 2) | 2)), (&mp_builtin_oct_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ord)) << 2) | 2)), (&mp_builtin_ord_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_pow)) << 2) | 2)), (&mp_builtin_pow_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_print)) << 2) | 2)), (&mp_builtin_print_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_repr)) << 2) | 2)), (&mp_builtin_repr_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_round)) << 2) | 2)), (&mp_builtin_round_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sorted)) << 2) | 2)), (&mp_builtin_sorted_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sum)) << 2) | 2)), (&mp_builtin_sum_obj) }, + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_BaseException)) << 2) | 2)), (&mp_type_BaseException) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ArithmeticError)) << 2) | 2)), (&mp_type_ArithmeticError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_AssertionError)) << 2) | 2)), (&mp_type_AssertionError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_AttributeError)) << 2) | 2)), (&mp_type_AttributeError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_EOFError)) << 2) | 2)), (&mp_type_EOFError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_Exception)) << 2) | 2)), (&mp_type_Exception) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_GeneratorExit)) << 2) | 2)), (&mp_type_GeneratorExit) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ImportError)) << 2) | 2)), (&mp_type_ImportError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_IndentationError)) << 2) | 2)), (&mp_type_IndentationError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_IndexError)) << 2) | 2)), (&mp_type_IndexError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_KeyboardInterrupt)) << 2) | 2)), (&mp_type_KeyboardInterrupt) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_KeyError)) << 2) | 2)), (&mp_type_KeyError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_LookupError)) << 2) | 2)), (&mp_type_LookupError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_MemoryError)) << 2) | 2)), (&mp_type_MemoryError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_NameError)) << 2) | 2)), (&mp_type_NameError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_NotImplementedError)) << 2) | 2)), (&mp_type_NotImplementedError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_OSError)) << 2) | 2)), (&mp_type_OSError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_OverflowError)) << 2) | 2)), (&mp_type_OverflowError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_RuntimeError)) << 2) | 2)), (&mp_type_RuntimeError) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_StopIteration)) << 2) | 2)), (&mp_type_StopIteration) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_SyntaxError)) << 2) | 2)), (&mp_type_SyntaxError) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_SystemExit)) << 2) | 2)), (&mp_type_SystemExit) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_TypeError)) << 2) | 2)), (&mp_type_TypeError) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ValueError)) << 2) | 2)), (&mp_type_ValueError) }, + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ZeroDivisionError)) << 2) | 2)), (&mp_type_ZeroDivisionError) }, + + + + + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_open)) << 2) | 2)), (mp_obj_t)&mp_builtin_open_obj }, +}; + +const mp_obj_dict_t mp_module_builtins_globals = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(mp_module_builtins_globals_table) / sizeof((mp_module_builtins_globals_table)[0])), .alloc = (sizeof(mp_module_builtins_globals_table) / sizeof((mp_module_builtins_globals_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)mp_module_builtins_globals_table, }, }; + +const mp_obj_module_t mp_module_builtins = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_builtins_globals, +}; +# 1 "user/mpy/py/modcollections.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modcollections.c" +# 27 "user/mpy/py/modcollections.c" +# 1 "user/mpy/py/builtin.h" 1 +# 29 "user/mpy/py/builtin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/builtin.h" 2 + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 28 "user/mpy/py/modcollections.c" 2 +# 1 "user/mpy/py/modgc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modgc.c" +# 27 "user/mpy/py/modgc.c" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 28 "user/mpy/py/modgc.c" 2 + +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 30 "user/mpy/py/modgc.c" 2 +# 1 "user/mpy/py/modio.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modio.c" +# 27 "user/mpy/py/modio.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/modio.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/modio.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/modio.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 32 "user/mpy/py/modio.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 33 "user/mpy/py/modio.c" 2 +# 1 "user/mpy/py/objstringio.h" 1 +# 31 "user/mpy/py/objstringio.h" +typedef struct _mp_obj_stringio_t { + mp_obj_base_t base; + vstr_t *vstr; + + mp_uint_t pos; + + mp_obj_t ref_obj; +} mp_obj_stringio_t; +# 34 "user/mpy/py/modio.c" 2 +# 1 "user/mpy/py/frozenmod.h" 1 +# 29 "user/mpy/py/frozenmod.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/frozenmod.h" 2 + +enum { + MP_FROZEN_NONE, + MP_FROZEN_STR, + MP_FROZEN_MPY, +}; + +int mp_find_frozen_module(const char *str, size_t len, void **data); +const char *mp_find_frozen_str(const char *str, size_t *len); +mp_import_stat_t mp_frozen_stat(const char *str); +# 35 "user/mpy/py/modio.c" 2 +# 1 "user/mpy/py/modmath.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modmath.c" +# 27 "user/mpy/py/modmath.c" +# 1 "user/mpy/py/builtin.h" 1 +# 29 "user/mpy/py/builtin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/builtin.h" 2 + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 28 "user/mpy/py/modmath.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 29 "user/mpy/py/modmath.c" 2 +# 1 "user/mpy/py/modcmath.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modcmath.c" +# 27 "user/mpy/py/modcmath.c" +# 1 "user/mpy/py/builtin.h" 1 +# 29 "user/mpy/py/builtin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/builtin.h" 2 + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 28 "user/mpy/py/modcmath.c" 2 +# 1 "user/mpy/py/modmicropython.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modmicropython.c" +# 27 "user/mpy/py/modmicropython.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/modmicropython.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/py/modmicropython.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 31 "user/mpy/py/modmicropython.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 32 "user/mpy/py/modmicropython.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/modmicropython.c" 2 +# 1 "user/mpy/py/gc.h" 1 +# 34 "user/mpy/py/gc.h" +void gc_init(void *start, void *end); + + + +void gc_lock(void); +void gc_unlock(void); + +# 40 "user/mpy/py/gc.h" 3 4 +_Bool +# 40 "user/mpy/py/gc.h" + gc_is_locked(void); + + +void gc_collect(void); +void gc_collect_start(void); +void gc_collect_root(void **ptrs, size_t len); +void gc_collect_end(void); + +void *gc_alloc(size_t n_bytes, +# 48 "user/mpy/py/gc.h" 3 4 + _Bool +# 48 "user/mpy/py/gc.h" + has_finaliser); +void gc_free(void *ptr); +size_t gc_nbytes(const void *ptr); +void *gc_realloc(void *ptr, size_t n_bytes, +# 51 "user/mpy/py/gc.h" 3 4 + _Bool +# 51 "user/mpy/py/gc.h" + 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); +# 34 "user/mpy/py/modmicropython.c" 2 +# 1 "user/mpy/py/mphal.h" 1 +# 34 "user/mpy/py/mphal.h" +# 1 "user/mpy/mphalport.h" 1 +# 35 "user/mpy/py/mphal.h" 2 + + + +int mp_hal_stdin_rx_chr(void); + + + + + + + +void mp_hal_stdout_tx_strn(const char *str, size_t len); + + + + + + + +void mp_hal_delay_ms(mp_uint_t ms); + + + +void mp_hal_delay_us(mp_uint_t us); + + + + + + + +mp_uint_t mp_hal_ticks_us(void); + + + +mp_uint_t mp_hal_ticks_cpu(void); +# 80 "user/mpy/py/mphal.h" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 37 "user/mpy/extmod/virtpin.h" +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 81 "user/mpy/py/mphal.h" 2 +# 35 "user/mpy/py/modmicropython.c" 2 + + + + +static mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + return ((mp_obj_t)((((mp_uint_t)((mp_state_ctx.vm.mp_optimise_value))) << 1) | 1)); + } else { + (mp_state_ctx.vm.mp_optimise_value) = mp_obj_get_int(args[0]); + return (((mp_obj_t)&mp_const_none_obj)); + } +} +static const mp_obj_fun_builtin_var_t mp_micropython_opt_level_obj = {{&mp_type_fun_builtin_var}, +# 47 "user/mpy/py/modmicropython.c" 3 4 + 0 +# 47 "user/mpy/py/modmicropython.c" + , 0, 1, .fun.var = mp_micropython_opt_level}; +# 117 "user/mpy/py/modmicropython.c" +static mp_obj_t mp_micropython_heap_lock(void) { + gc_lock(); + return (((mp_obj_t)&mp_const_none_obj)); +} +static const mp_obj_fun_builtin_fixed_t mp_micropython_heap_lock_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_micropython_heap_lock}; + +static mp_obj_t mp_micropython_heap_unlock(void) { + gc_unlock(); + return (((mp_obj_t)&mp_const_none_obj)); +} +static const mp_obj_fun_builtin_fixed_t mp_micropython_heap_unlock_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_micropython_heap_unlock}; +# 152 "user/mpy/py/modmicropython.c" +static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = { + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR_micropython)) << 2) | 2)) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_const)) << 2) | 2)), (&mp_identity_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_opt_level)) << 2) | 2)), (&mp_micropython_opt_level_obj) }, +# 172 "user/mpy/py/modmicropython.c" + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_heap_lock)) << 2) | 2)), (&mp_micropython_heap_lock_obj) }, + { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_heap_unlock)) << 2) | 2)), (&mp_micropython_heap_unlock_obj) }, + + + + + + + +}; + +static const mp_obj_dict_t mp_module_micropython_globals = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(mp_module_micropython_globals_table) / sizeof((mp_module_micropython_globals_table)[0])), .alloc = (sizeof(mp_module_micropython_globals_table) / sizeof((mp_module_micropython_globals_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)mp_module_micropython_globals_table, }, }; + +const mp_obj_module_t mp_module_micropython = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_micropython_globals, +}; +# 1 "user/mpy/py/modstruct.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modstruct.c" +# 28 "user/mpy/py/modstruct.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/modstruct.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/modstruct.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/modstruct.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 33 "user/mpy/py/modstruct.c" 2 + +# 1 "user/mpy/py/binary.h" 1 +# 35 "user/mpy/py/binary.h" +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 35 "user/mpy/py/modstruct.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 36 "user/mpy/py/modstruct.c" 2 +# 1 "user/mpy/py/modsys.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modsys.c" +# 28 "user/mpy/py/modsys.c" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 29 "user/mpy/py/modsys.c" 2 + +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 31 "user/mpy/py/modsys.c" 2 + + +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 34 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/objint.h" 1 +# 29 "user/mpy/py/objint.h" +# 1 "user/mpy/py/mpz.h" 1 +# 62 "user/mpy/py/mpz.h" +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +# 89 "user/mpy/py/mpz.h" +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + + + + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, +# 107 "user/mpy/py/mpz.h" 3 4 + _Bool +# 107 "user/mpy/py/mpz.h" + is_signed); + + + +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, +# 111 "user/mpy/py/mpz.h" 3 4 + _Bool +# 111 "user/mpy/py/mpz.h" + neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, +# 112 "user/mpy/py/mpz.h" 3 4 + _Bool +# 112 "user/mpy/py/mpz.h" + big_endian, size_t len, const byte *buf); + +static inline +# 114 "user/mpy/py/mpz.h" 3 4 + _Bool +# 114 "user/mpy/py/mpz.h" + mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline +# 115 "user/mpy/py/mpz.h" 3 4 + _Bool +# 115 "user/mpy/py/mpz.h" + mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } +mp_int_t mpz_hash(const mpz_t *z); + +# 135 "user/mpy/py/mpz.h" 3 4 +_Bool +# 135 "user/mpy/py/mpz.h" + mpz_as_int_checked(const mpz_t *z, mp_int_t *value); + +# 136 "user/mpy/py/mpz.h" 3 4 +_Bool +# 136 "user/mpy/py/mpz.h" + mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, +# 137 "user/mpy/py/mpz.h" 3 4 + _Bool +# 137 "user/mpy/py/mpz.h" + big_endian, size_t len, byte *buf); + + + +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); +# 30 "user/mpy/py/objint.h" 2 + + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; + + + + + +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + + + + + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl( +# 57 "user/mpy/py/objint.h" 3 4 + _Bool +# 57 "user/mpy/py/objint.h" + big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, +# 58 "user/mpy/py/objint.h" 3 4 + _Bool +# 58 "user/mpy/py/objint.h" + big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); +# 35 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/objtype.h" 1 +# 33 "user/mpy/py/objtype.h" +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 36 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 37 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 38 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 39 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 40 "user/mpy/py/modsys.c" 2 +# 1 "user/mpy/py/moduerrno.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/moduerrno.c" +# 27 "user/mpy/py/moduerrno.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/moduerrno.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/moduerrno.c" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 31 "user/mpy/py/moduerrno.c" 2 +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 32 "user/mpy/py/moduerrno.c" 2 +# 1 "user/mpy/py/modthread.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/modthread.c" +# 27 "user/mpy/py/modthread.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/modthread.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/modthread.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/modthread.c" 2 +# 1 "user/mpy/py/stackctrl.h" 1 +# 31 "user/mpy/py/stackctrl.h" +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); +# 32 "user/mpy/py/modthread.c" 2 +# 1 "user/mpy/py/vm.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/vm.c" +# 28 "user/mpy/py/vm.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 29 "user/mpy/py/vm.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/vm.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/vm.c" 2 + +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 33 "user/mpy/py/vm.c" 2 + +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 35 "user/mpy/py/vm.c" 2 +# 1 "user/mpy/py/objtype.h" 1 +# 33 "user/mpy/py/objtype.h" +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + +} mp_obj_instance_t; + + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + + + +# 44 "user/mpy/py/objtype.h" 3 4 +_Bool +# 44 "user/mpy/py/objtype.h" + mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + + + + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 36 "user/mpy/py/vm.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 32 "user/mpy/py/runtime.h" +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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 37 "user/mpy/py/vm.c" 2 +# 1 "user/mpy/py/bc0.h" 1 +# 38 "user/mpy/py/vm.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 31 "user/mpy/py/bc.h" +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 39 "user/mpy/py/vm.c" 2 +# 56 "user/mpy/py/vm.c" +typedef enum { + UNWIND_RETURN = 1, + UNWIND_JUMP, +} mp_unwind_reason_t; +# 129 "user/mpy/py/vm.c" +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { +# 165 "user/mpy/py/vm.c" + mp_obj_t * fastn; + mp_exc_stack_t * exc_stack; + { + size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); + fastn = &code_state->state[n_state - 1]; + exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); + } + + + volatile +# 174 "user/mpy/py/vm.c" 3 4 + _Bool +# 174 "user/mpy/py/vm.c" + currently_in_except_block = ((uintptr_t)(code_state->exc_sp) & 1); + mp_exc_stack_t *volatile exc_sp = ((void*)((uintptr_t)(code_state->exc_sp) & ~((uintptr_t)3))); +# 184 "user/mpy/py/vm.c" + for (;;) { + nlr_buf_t nlr; +outer_dispatch_loop: + if (nlr_push(&nlr) == 0) { + + const byte *ip = code_state->ip; + mp_obj_t *sp = code_state->sp; + mp_obj_t obj_shared; + + + + + + + + if (inject_exc != (((mp_obj_t)(void*)0)) && *ip != (0x5e)) { + mp_obj_t exc = inject_exc; + inject_exc = (((mp_obj_t)(void*)0)); + exc = mp_make_raise_obj(exc); + do { nlr_pop(); nlr.ret_val = ((void*)exc); goto exception_handler; } while (0); + } + + + for (;;) { +dispatch_loop: + + + + ; + { code_state->ip = ip; }; + switch (*ip++) { + + + case (0x10): + *++sp = ((((mp_obj_t)&mp_const_false_obj))); + break; + + case (0x11): + *++sp = ((((mp_obj_t)&mp_const_none_obj))); + break; + + case (0x12): + *++sp = ((((mp_obj_t)&mp_const_true_obj))); + break; + + case (0x14): { + mp_int_t num = 0; + if ((ip[0] & 0x40) != 0) { + + num--; + } + do { + num = (num << 7) | (*ip & 0x7f); + } while ((*ip++ & 0x80) != 0); + *++sp = (((mp_obj_t)((((mp_uint_t)(num)) << 1) | 1))); + break; + } + + case (0x16): { + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + *++sp = (((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))); + break; + } + + case (0x17): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); mp_obj_t obj = (mp_obj_t)code_state->fun_bc->const_table[unum]; + *++sp = (obj); + break; + } + + case (0x18): + *++sp = ((((mp_obj_t)(void*)0))); + break; + + case (0x19): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + obj_shared = fastn[-unum]; + load_check: + if (obj_shared == (((mp_obj_t)(void*)0))) { + local_name_error: { + ; + mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NameError, "local variable referenced before assignment"); + do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); + } + } + *++sp = (obj_shared); + break; + } + + case (0x1a): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + obj_shared = mp_obj_cell_get(fastn[-unum]); + goto load_check; + } + + + case (0x1b): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + *++sp = (mp_load_name(qst)); + break; + } +# 309 "user/mpy/py/vm.c" + case (0x1c): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + *++sp = (mp_load_global(qst)); + break; + } +# 338 "user/mpy/py/vm.c" + case (0x1d): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + *sp = (mp_load_attr((*sp), qst)); + break; + } +# 375 "user/mpy/py/vm.c" + case (0x1e): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_load_method(*sp, qst, sp); + sp += 1; + break; + } + + case (0x1f): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + sp -= 1; + mp_load_super_method(qst, sp - 1); + break; + } + + case (0x20): + ; + *++sp = (mp_load_build_class()); + break; + + case (0x21): { + ; + mp_obj_t index = (*sp--); + *sp = (mp_obj_subscr((*sp), index, (((mp_obj_t)(void*)8)))); + break; + } + + case (0x22): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + fastn[-unum] = (*sp--); + break; + } + + case (0x23): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + mp_obj_cell_set(fastn[-unum], (*sp--)); + break; + } + + case (0x24): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_store_name(qst, (*sp--)); + break; + } + + case (0x25): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_store_global(qst, (*sp--)); + break; + } + + + case (0x26): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_store_attr(sp[0], qst, sp[-1]); + sp -= 2; + break; + } +# 475 "user/mpy/py/vm.c" + case (0x27): + ; + mp_obj_subscr(sp[-1], sp[0], sp[-2]); + sp -= 3; + break; + + case (0x28): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + if (fastn[-unum] == (((mp_obj_t)(void*)0))) { + goto local_name_error; + } + fastn[-unum] = (((mp_obj_t)(void*)0)); + break; + } + + case (0x29): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + if (mp_obj_cell_get(fastn[-unum]) == (((mp_obj_t)(void*)0))) { + goto local_name_error; + } + mp_obj_cell_set(fastn[-unum], (((mp_obj_t)(void*)0))); + break; + } + + case (0x2a): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_delete_name(qst); + break; + } + + case (0x2b): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_delete_global(qst); + break; + } + + case (0x30): { + mp_obj_t top = (*sp); + *++sp = (top); + break; + } + + case (0x31): + sp += 2; + sp[0] = sp[-2]; + sp[-1] = sp[-3]; + break; + + case (0x32): + sp -= 1; + break; + + case (0x33): { + mp_obj_t top = sp[0]; + sp[0] = sp[-1]; + sp[-1] = top; + break; + } + + case (0x34): { + mp_obj_t top = sp[0]; + sp[0] = sp[-1]; + sp[-1] = sp[-2]; + sp[-2] = top; + break; + } + + case (0x35): { + size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; + ip += slab; + goto pending_exception_check; + } + + case (0x36): { + size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; + if (mp_obj_is_true((*sp--))) { + ip += slab; + } + goto pending_exception_check; + } + + case (0x37): { + size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; + if (!mp_obj_is_true((*sp--))) { + ip += slab; + } + goto pending_exception_check; + } + + case (0x38): { + size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; + if (mp_obj_is_true((*sp))) { + ip += slab; + } else { + sp--; + } + goto pending_exception_check; + } + + case (0x39): { + size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; + if (mp_obj_is_true((*sp))) { + sp--; + } else { + ip += slab; + } + goto pending_exception_check; + } + + case (0x3d): { + ; + + mp_obj_t obj = (*sp); + mp_load_method(obj, MP_QSTR___exit__, sp); + mp_load_method(obj, MP_QSTR___enter__, sp + 2); + mp_obj_t ret = mp_call_method_n_kw(0, 0, sp + 2); + sp += 1; + do { size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; ++exc_sp; exc_sp->handler = ip + ulab; exc_sp->val_sp = ((void*)((uintptr_t)(sp) | (((1) << 1) | currently_in_except_block))); exc_sp->prev_exc = +# 596 "user/mpy/py/vm.c" 3 4 + ((void *)0) +# 596 "user/mpy/py/vm.c" + ; currently_in_except_block = 0; } while (0); + *++sp = (ret); + + break; + } + + case (0x3e): { + ; + + + + + + + if ((*sp) == (((mp_obj_t)&mp_const_none_obj))) { + + sp[1] = (((mp_obj_t)&mp_const_none_obj)); + sp[2] = (((mp_obj_t)&mp_const_none_obj)); + sp -= 2; + mp_call_method_n_kw(3, 0, sp); + *sp = ((((mp_obj_t)&mp_const_none_obj))); + } else if (MP_OBJ_IS_SMALL_INT((*sp))) { + mp_int_t cause_val = (((mp_int_t)((*sp))) >> 1); + if (cause_val == UNWIND_RETURN) { + + mp_obj_t ret_val = sp[-1]; + sp[-1] = (((mp_obj_t)&mp_const_none_obj)); + sp[0] = (((mp_obj_t)&mp_const_none_obj)); + sp[1] = (((mp_obj_t)&mp_const_none_obj)); + mp_call_method_n_kw(3, 0, sp - 3); + sp[-3] = ret_val; + sp[-2] = ((mp_obj_t)((((mp_uint_t)(UNWIND_RETURN)) << 1) | 1)); + } else { + +# 629 "user/mpy/py/vm.c" 3 + (( +# 629 "user/mpy/py/vm.c" + cause_val == UNWIND_JUMP +# 629 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 629, __func__, +# 629 "user/mpy/py/vm.c" + "cause_val == UNWIND_JUMP" +# 629 "user/mpy/py/vm.c" 3 + )) +# 629 "user/mpy/py/vm.c" + ; + + mp_obj_t dest_ip = sp[-2]; + mp_obj_t num_exc = sp[-1]; + sp[-2] = (((mp_obj_t)&mp_const_none_obj)); + sp[-1] = (((mp_obj_t)&mp_const_none_obj)); + sp[0] = (((mp_obj_t)&mp_const_none_obj)); + mp_call_method_n_kw(3, 0, sp - 4); + sp[-4] = dest_ip; + sp[-3] = num_exc; + sp[-2] = ((mp_obj_t)((((mp_uint_t)(UNWIND_JUMP)) << 1) | 1)); + } + sp -= 2; + } else { + +# 643 "user/mpy/py/vm.c" 3 + (( +# 643 "user/mpy/py/vm.c" + mp_obj_is_exception_instance((*sp)) +# 643 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 643, __func__, +# 643 "user/mpy/py/vm.c" + "mp_obj_is_exception_instance(TOP())" +# 643 "user/mpy/py/vm.c" 3 + )) +# 643 "user/mpy/py/vm.c" + ; + + + sp[1] = sp[0]; + sp[0] = ((mp_obj_t)mp_obj_get_type(sp[0])); + sp[2] = (((mp_obj_t)&mp_const_none_obj)); + sp -= 2; + mp_obj_t ret_value = mp_call_method_n_kw(3, 0, sp); + if (mp_obj_is_true(ret_value)) { + + + + + *sp = ((((mp_obj_t)&mp_const_none_obj))); + +# 657 "user/mpy/py/vm.c" 3 + (( +# 657 "user/mpy/py/vm.c" + exc_sp >= exc_stack +# 657 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 657, __func__, +# 657 "user/mpy/py/vm.c" + "exc_sp >= exc_stack" +# 657 "user/mpy/py/vm.c" 3 + )) +# 657 "user/mpy/py/vm.c" + ; + currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; + } else { + + + sp[0] = sp[3]; + } + } + break; + } + + case (0x46): { + ; + size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; + *++sp = ((mp_obj_t)(mp_uint_t)(uintptr_t)(ip + slab)); + *++sp = ((mp_obj_t)(mp_uint_t)(*ip)); +unwind_jump:; + mp_uint_t unum = (mp_uint_t)(*sp--); + while ((unum & 0x7f) > 0) { + unum -= 1; + +# 677 "user/mpy/py/vm.c" 3 + (( +# 677 "user/mpy/py/vm.c" + exc_sp >= exc_stack +# 677 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 677, __func__, +# 677 "user/mpy/py/vm.c" + "exc_sp >= exc_stack" +# 677 "user/mpy/py/vm.c" 3 + )) +# 677 "user/mpy/py/vm.c" + ; + if (((uintptr_t)(exc_sp->val_sp) & 2)) { +# 687 "user/mpy/py/vm.c" + *++sp = ((mp_obj_t)unum); + *++sp = (((mp_obj_t)((((mp_uint_t)(UNWIND_JUMP)) << 1) | 1))); + ip = exc_sp->handler; + exc_sp--; + goto dispatch_loop; + } + currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; + } + ip = (const byte*)((void*)(*sp--)); + if (unum != 0) { + + sp -= ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)); + } + goto pending_exception_check; + } + + + case (0x3f): + case (0x40): { + ; + + + + do { size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; ++exc_sp; exc_sp->handler = ip + ulab; exc_sp->val_sp = ((void*)((uintptr_t)(sp) | ((((code_state->ip[0] == (0x40)) ? 1 : 0) << 1) | currently_in_except_block))); exc_sp->prev_exc = +# 710 "user/mpy/py/vm.c" 3 4 + ((void *)0) +# 710 "user/mpy/py/vm.c" + ; currently_in_except_block = 0; } while (0); + + break; + } + + case (0x41): + ; + + + + if ((*sp) == (((mp_obj_t)&mp_const_none_obj))) { + sp--; + } else if (MP_OBJ_IS_SMALL_INT((*sp))) { + + + mp_unwind_reason_t reason = (((mp_int_t)((*sp--))) >> 1); + if (reason == UNWIND_RETURN) { + goto unwind_return; + } else { + +# 729 "user/mpy/py/vm.c" 3 + (( +# 729 "user/mpy/py/vm.c" + reason == UNWIND_JUMP +# 729 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 729, __func__, +# 729 "user/mpy/py/vm.c" + "reason == UNWIND_JUMP" +# 729 "user/mpy/py/vm.c" 3 + )) +# 729 "user/mpy/py/vm.c" + ; + goto unwind_jump; + } + } else { + +# 733 "user/mpy/py/vm.c" 3 + (( +# 733 "user/mpy/py/vm.c" + mp_obj_is_exception_instance((*sp)) +# 733 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 733, __func__, +# 733 "user/mpy/py/vm.c" + "mp_obj_is_exception_instance(TOP())" +# 733 "user/mpy/py/vm.c" 3 + )) +# 733 "user/mpy/py/vm.c" + ; + do { nlr_pop(); nlr.ret_val = ((void*)(*sp)); goto exception_handler; } while (0); + } + break; + + case (0x42): + ; + *sp = (mp_getiter((*sp), +# 740 "user/mpy/py/vm.c" 3 4 + ((void *)0) +# 740 "user/mpy/py/vm.c" + )); + break; + + + + + + case (0x47): { + ; + mp_obj_t obj = (*sp); + mp_obj_iter_buf_t *iter_buf = (mp_obj_iter_buf_t*)sp; + sp += ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) - 1; + obj = mp_getiter(obj, iter_buf); + if (obj != ((mp_obj_t)iter_buf)) { + + sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 1] = (((mp_obj_t)(void*)0)); + sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 2] = obj; + } + break; + } + + case (0x43): { + ; + size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; + code_state->sp = sp; + mp_obj_t obj; + if (sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 1] == (((mp_obj_t)(void*)0))) { + obj = sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 2]; + } else { + obj = ((mp_obj_t)&sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 1]); + } + mp_obj_t value = mp_iternext_allow_raise(obj); + if (value == (((mp_obj_t)(void*)4))) { + sp -= ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)); + ip += ulab; + } else { + *++sp = (value); + } + break; + } + + + case (0x44): + + +# 784 "user/mpy/py/vm.c" 3 + (( +# 784 "user/mpy/py/vm.c" + exc_sp >= exc_stack +# 784 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 784, __func__, +# 784 "user/mpy/py/vm.c" + "exc_sp >= exc_stack" +# 784 "user/mpy/py/vm.c" 3 + )) +# 784 "user/mpy/py/vm.c" + ; + currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; + break; + + + case (0x45): + +# 790 "user/mpy/py/vm.c" 3 + (( +# 790 "user/mpy/py/vm.c" + exc_sp >= exc_stack +# 790 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 790, __func__, +# 790 "user/mpy/py/vm.c" + "exc_sp >= exc_stack" +# 790 "user/mpy/py/vm.c" 3 + )) +# 790 "user/mpy/py/vm.c" + ; + +# 791 "user/mpy/py/vm.c" 3 + (( +# 791 "user/mpy/py/vm.c" + currently_in_except_block +# 791 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 791, __func__, +# 791 "user/mpy/py/vm.c" + "currently_in_except_block" +# 791 "user/mpy/py/vm.c" 3 + )) +# 791 "user/mpy/py/vm.c" + ; + currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; + break; + + case (0x50): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + sp -= unum - 1; + *sp = (mp_obj_new_tuple(unum, sp)); + break; + } + + case (0x51): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + sp -= unum - 1; + *sp = (mp_obj_new_list(unum, sp)); + break; + } + + case (0x53): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + *++sp = (mp_obj_new_dict(unum)); + break; + } + + case (0x54): + ; + sp -= 2; + mp_obj_dict_store(sp[0], sp[2], sp[1]); + break; +# 852 "user/mpy/py/vm.c" + case (0x57): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + mp_obj_t obj = sp[-(unum >> 2)]; + if ((unum & 3) == 0) { + mp_obj_list_append(obj, sp[0]); + sp--; + } else if (!(0) || (unum & 3) == 1) { + mp_obj_dict_store(obj, sp[0], sp[-1]); + sp -= 2; + + + + + + } + break; + } + + case (0x59): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + mp_unpack_sequence(sp[0], unum, sp); + sp += unum - 1; + break; + } + + case (0x5a): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + mp_unpack_ex(sp[0], unum, sp); + sp += (unum & 0xff) + ((unum >> 8) & 0xff); + break; + } + + case (0x60): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; + *++sp = (mp_make_function_from_raw_code(ptr, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0)))); + break; + } + + case (0x61): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; + + mp_obj_t def_dict = (*sp--); + *sp = (mp_make_function_from_raw_code(ptr, (*sp), def_dict)); + break; + } + + case (0x62): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; + size_t n_closed_over = *ip++; + + sp -= n_closed_over - 1; + *sp = (mp_make_closure_from_raw_code(ptr, n_closed_over, sp)); + break; + } + + case (0x63): { + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; + size_t n_closed_over = *ip++; + + sp -= 2 + n_closed_over - 1; + *sp = (mp_make_closure_from_raw_code(ptr, 0x100 | n_closed_over, sp)); + break; + } + + case (0x64): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + + + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe); +# 945 "user/mpy/py/vm.c" + *sp = (mp_call_function_n_kw(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1)); + break; + } + + case (0x65): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + + + + + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 2; +# 982 "user/mpy/py/vm.c" + *sp = (mp_call_method_n_kw_var( +# 982 "user/mpy/py/vm.c" 3 4 + 0 +# 982 "user/mpy/py/vm.c" + , unum, sp)); + break; + } + + case (0x66): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + + + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 1; +# 1016 "user/mpy/py/vm.c" + *sp = (mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp)); + break; + } + + case (0x67): { + ; + mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); + + + + + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 3; +# 1053 "user/mpy/py/vm.c" + *sp = (mp_call_method_n_kw_var( +# 1053 "user/mpy/py/vm.c" 3 4 + 1 +# 1053 "user/mpy/py/vm.c" + , unum, sp)); + break; + } + + case (0x5b): + ; + + + + + + if (currently_in_except_block) { + currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; + } +unwind_return: + while (exc_sp >= exc_stack) { + if (((uintptr_t)(exc_sp->val_sp) & 2)) { +# 1079 "user/mpy/py/vm.c" + mp_obj_t *finally_sp = ((void*)((uintptr_t)(exc_sp->val_sp) & ~((uintptr_t)3))); + finally_sp[1] = sp[0]; + sp = &finally_sp[1]; + + + + + *++sp = (((mp_obj_t)((((mp_uint_t)(UNWIND_RETURN)) << 1) | 1))); + ip = exc_sp->handler; + exc_sp--; + goto dispatch_loop; + } + exc_sp--; + } + nlr_pop(); + code_state->sp = sp; + +# 1095 "user/mpy/py/vm.c" 3 + (( +# 1095 "user/mpy/py/vm.c" + exc_sp == exc_stack - 1 +# 1095 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 1095, __func__, +# 1095 "user/mpy/py/vm.c" + "exc_sp == exc_stack - 1" +# 1095 "user/mpy/py/vm.c" 3 + )) +# 1095 "user/mpy/py/vm.c" + ; + +# 1106 "user/mpy/py/vm.c" + return MP_VM_RETURN_NORMAL; + + case (0x5c): { + ; + mp_uint_t unum = *ip++; + mp_obj_t obj; + if (unum == 2) { + ; + + sp--; + } + if (unum == 0) { + + obj = (((mp_obj_t)(void*)0)); + for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; e--) { + if (e->prev_exc != +# 1121 "user/mpy/py/vm.c" 3 4 + ((void *)0) +# 1121 "user/mpy/py/vm.c" + ) { + obj = ((mp_obj_t)e->prev_exc); + break; + } + } + if (obj == (((mp_obj_t)(void*)0))) { + obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, "No active exception to reraise"); + do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); + } + } else { + obj = (*sp--); + } + obj = mp_make_raise_obj(obj); + do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); + } + + case (0x5d): +yield: + nlr_pop(); + code_state->ip = ip; + code_state->sp = sp; + code_state->exc_sp = ((void*)((uintptr_t)(exc_sp) | (currently_in_except_block))); + return MP_VM_RETURN_YIELD; + + case (0x5e): { + ; + + + + mp_vm_return_kind_t ret_kind; + mp_obj_t send_value = (*sp--); + mp_obj_t t_exc = (((mp_obj_t)(void*)0)); + mp_obj_t ret_value; + if (inject_exc != (((mp_obj_t)(void*)0))) { + t_exc = inject_exc; + inject_exc = (((mp_obj_t)(void*)0)); + ret_kind = mp_resume((*sp), (((mp_obj_t)(void*)0)), t_exc, &ret_value); + } else { + ret_kind = mp_resume((*sp), send_value, (((mp_obj_t)(void*)0)), &ret_value); + } + + if (ret_kind == MP_VM_RETURN_YIELD) { + ip--; + *++sp = (ret_value); + goto yield; + } else if (ret_kind == MP_VM_RETURN_NORMAL) { + + sp--; + + if (ret_value == (((mp_obj_t)(void*)0)) || ret_value == (((mp_obj_t)(void*)4))) { + + + *++sp = ((((mp_obj_t)&mp_const_none_obj))); + } else { + *++sp = (ret_value); + } + + + + if (t_exc != (((mp_obj_t)(void*)0)) && mp_obj_exception_match(t_exc, ((mp_obj_t)&mp_type_GeneratorExit))) { do { nlr_pop(); nlr.ret_val = ((void*)t_exc); goto exception_handler; } while (0); }; + break; + } else { + +# 1183 "user/mpy/py/vm.c" 3 + (( +# 1183 "user/mpy/py/vm.c" + ret_kind == MP_VM_RETURN_EXCEPTION +# 1183 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 1183, __func__, +# 1183 "user/mpy/py/vm.c" + "ret_kind == MP_VM_RETURN_EXCEPTION" +# 1183 "user/mpy/py/vm.c" 3 + )) +# 1183 "user/mpy/py/vm.c" + ; + + sp--; + if (mp_obj_exception_match(ret_value, ((mp_obj_t)&mp_type_StopIteration))) { + *++sp = (mp_obj_exception_get_value(ret_value)); + + + if (t_exc != (((mp_obj_t)(void*)0)) && mp_obj_exception_match(t_exc, ((mp_obj_t)&mp_type_GeneratorExit))) { do { nlr_pop(); nlr.ret_val = ((void*)t_exc); goto exception_handler; } while (0); }; + break; + } else { + do { nlr_pop(); nlr.ret_val = ((void*)ret_value); goto exception_handler; } while (0); + } + } + } + + case (0x68): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_obj_t obj = (*sp--); + *sp = (mp_import_name(qst, obj, (*sp))); + break; + } + + case (0x69): { + ; + qstr qst = ip[0] | ip[1] << 8; ip += 2;; + mp_obj_t obj = mp_import_from((*sp), qst); + *++sp = (obj); + break; + } + + case (0x6a): + ; + mp_import_all((*sp--)); + break; +# 1248 "user/mpy/py/vm.c" + default: + if (ip[-1] < (0x70) + 64) { + *++sp = (((mp_obj_t)((((mp_uint_t)((mp_int_t)ip[-1] - (0x70) - 16)) << 1) | 1))); + break; + } else if (ip[-1] < (0xb0) + 16) { + obj_shared = fastn[(0xb0) - (mp_int_t)ip[-1]]; + goto load_check; + } else if (ip[-1] < (0xc0) + 16) { + fastn[(0xc0) - (mp_int_t)ip[-1]] = (*sp--); + break; + } else if (ip[-1] < (0xd0) + 7) { + *sp = (mp_unary_op(ip[-1] - (0xd0), (*sp))); + break; + } else if (ip[-1] < (0xd7) + 36) { + mp_obj_t rhs = (*sp--); + mp_obj_t lhs = (*sp); + *sp = (mp_binary_op(ip[-1] - (0xd7), lhs, rhs)); + break; + } else + + { + mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NotImplementedError, "byte code not implemented"); + nlr_pop(); + fastn[0] = obj; + return MP_VM_RETURN_EXCEPTION; + } + + + } + + +pending_exception_check: + +# 1300 "user/mpy/py/vm.c" + if ((mp_state_ctx.vm.mp_pending_exception) != (((mp_obj_t)(void*)0))) { + ; + mp_obj_t obj = (mp_state_ctx.vm.mp_pending_exception); + (mp_state_ctx.vm.mp_pending_exception) = (((mp_obj_t)(void*)0)); + do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); + } +# 1326 "user/mpy/py/vm.c" + } + + } else { +exception_handler: +# 1341 "user/mpy/py/vm.c" + if (mp_obj_is_subclass_fast(((mp_obj_t)((mp_obj_base_t*)nlr.ret_val)->type), ((mp_obj_t)&mp_type_StopIteration))) { + if (code_state->ip) { + + if (*code_state->ip == (0x43)) { + const byte *ip = code_state->ip + 1; + size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; + code_state->ip = ip + ulab; + code_state->sp -= ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)); + goto outer_dispatch_loop; + } else if (*code_state->ip == (0x5e)) { + + + *++code_state->sp = mp_obj_exception_get_value(((mp_obj_t)nlr.ret_val)); + code_state->ip++; + goto outer_dispatch_loop; + } + } + } +# 1367 "user/mpy/py/vm.c" + if (nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) { + const byte *ip = code_state->fun_bc->bytecode; + ip = mp_decode_uint_skip(ip); + ip = mp_decode_uint_skip(ip); + ip++; + ip++; + ip++; + ip++; + size_t bc = code_state->ip - ip; + size_t code_info_size = mp_decode_uint_value(ip); + ip = mp_decode_uint_skip(ip); + bc -= code_info_size; + + qstr block_name = ip[0] | (ip[1] << 8); + qstr source_file = ip[2] | (ip[3] << 8); + ip += 4; + + + + + + + size_t source_line = 1; + size_t c; + while ((c = *ip)) { + size_t b, l; + if ((c & 0x80) == 0) { + + b = c & 0x1f; + l = c >> 5; + ip += 1; + } else { + + b = c & 0xf; + l = ((c << 4) & 0x700) | ip[1]; + ip += 2; + } + if (bc >= b) { + bc -= b; + source_line += l; + } else { + + break; + } + } + mp_obj_exception_add_traceback(((mp_obj_t)nlr.ret_val), source_file, source_line, block_name); + } + + while (currently_in_except_block) { + + + +# 1418 "user/mpy/py/vm.c" 3 + (( +# 1418 "user/mpy/py/vm.c" + exc_sp >= exc_stack +# 1418 "user/mpy/py/vm.c" 3 + ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 1418, __func__, +# 1418 "user/mpy/py/vm.c" + "exc_sp >= exc_stack" +# 1418 "user/mpy/py/vm.c" 3 + )) +# 1418 "user/mpy/py/vm.c" + ; + + + + + + currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; + } + + if (exc_sp >= exc_stack) { + + currently_in_except_block = 1; + + + code_state->ip = exc_sp->handler; + mp_obj_t *sp = ((void*)((uintptr_t)(exc_sp->val_sp) & ~((uintptr_t)3))); + + exc_sp->prev_exc = nlr.ret_val; + + *++sp = (((mp_obj_t)nlr.ret_val)); + code_state->sp = sp; +# 1453 "user/mpy/py/vm.c" + } else { + + + fastn[0] = ((mp_obj_t)nlr.ret_val); + return MP_VM_RETURN_EXCEPTION; + } + } + } +} +# 1 "user/mpy/py/bc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/bc.c" +# 28 "user/mpy/py/bc.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 29 "user/mpy/py/bc.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/bc.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 31 "user/mpy/py/bc.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 33 "user/mpy/py/bc.c" 2 +# 1 "user/mpy/py/objfun.h" 1 +# 29 "user/mpy/py/objfun.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 35 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objfun.h" 2 + +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 34 "user/mpy/py/bc.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 35 "user/mpy/py/bc.c" 2 +# 1 "user/mpy/py/bc0.h" 1 +# 36 "user/mpy/py/bc.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 29 "user/mpy/py/bc.h" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 37 "user/mpy/py/bc.c" 2 +# 45 "user/mpy/py/bc.c" +mp_uint_t mp_decode_uint(const byte **ptr) { + mp_uint_t unum = 0; + byte val; + const byte *p = *ptr; + do { + val = *p++; + unum = (unum << 7) | (val & 0x7f); + } while ((val & 0x80) != 0); + *ptr = p; + return unum; +} + + + + + + + +mp_uint_t mp_decode_uint_value(const byte *ptr) { + return mp_decode_uint(&ptr); +} + + + +const byte *mp_decode_uint_skip(const byte *ptr) { + while ((*ptr++) & 0x80) { + } + return ptr; +} + +static __attribute__((noreturn)) void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) { + + + (void)f; + (void)expected; + (void)given; + mp_arg_error_terse_mismatch(); +# 91 "user/mpy/py/bc.c" +} +# 110 "user/mpy/py/bc.c" +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) { + + + + + mp_obj_fun_bc_t *self = code_state->fun_bc; + + + code_state->ip = self->bytecode + (size_t)code_state->ip; + + + + + + + size_t n_state = mp_decode_uint(&code_state->ip); + code_state->ip = mp_decode_uint_skip(code_state->ip); + size_t scope_flags = *code_state->ip++; + size_t n_pos_args = *code_state->ip++; + size_t n_kwonly_args = *code_state->ip++; + size_t n_def_pos_args = *code_state->ip++; + + code_state->sp = &code_state->state[0] - 1; + code_state->exc_sp = (mp_exc_stack_t*)(code_state->state + n_state) - 1; + + + memset(code_state->state, 0, n_state * sizeof(*code_state->state)); + + const mp_obj_t *kwargs = args + n_args; + + + mp_obj_t *var_pos_kw_args = &code_state->state[n_state - 1 - n_pos_args - n_kwonly_args]; + + + + if (n_args > n_pos_args) { + + if ((scope_flags & (0x01)) == 0) { + fun_pos_args_mismatch(self, n_pos_args, n_args); + } + + *var_pos_kw_args-- = mp_obj_new_tuple(n_args - n_pos_args, args + n_pos_args); + n_args = n_pos_args; + } else { + if ((scope_flags & (0x01)) != 0) { + (void)0; + *var_pos_kw_args-- = (((mp_obj_t)&mp_const_empty_tuple_obj)); + } + + + if (n_kw == 0 && (scope_flags & (0x08)) == 0) { + if (n_args >= (size_t)(n_pos_args - n_def_pos_args)) { + + for (size_t i = n_args; i < n_pos_args; i++) { + code_state->state[n_state - 1 - i] = self->extra_args[i - (n_pos_args - n_def_pos_args)]; + } + } else { + fun_pos_args_mismatch(self, n_pos_args - n_def_pos_args, n_args); + } + } + } + + + for (size_t i = 0; i < n_args; i++) { + code_state->state[n_state - 1 - i] = args[i]; + } + + + + if (n_kw != 0 || (scope_flags & (0x08)) != 0) { + (void)0; + (void)0; + + mp_obj_t dict = (((mp_obj_t)(void*)0)); + if ((scope_flags & (0x02)) != 0) { + dict = mp_obj_new_dict(n_kw); + *var_pos_kw_args = dict; + } + + + const mp_obj_t *arg_names = (const mp_obj_t*)self->const_table; + + for (size_t i = 0; i < n_kw; i++) { + + mp_obj_t wanted_arg_name = kwargs[2 * i]; + for (size_t j = 0; j < n_pos_args + n_kwonly_args; j++) { + if (wanted_arg_name == arg_names[j]) { + if (code_state->state[n_state - 1 - j] != (((mp_obj_t)(void*)0))) { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function got multiple values for argument '%q'", (((mp_uint_t)(wanted_arg_name)) >> 2)))) + ; + } + code_state->state[n_state - 1 - j] = kwargs[2 * i + 1]; + goto continue2; + } + } + + if ((scope_flags & (0x02)) == 0) { + if (((1)) == (1)) { + mp_raise_TypeError("unexpected keyword argument"); + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unexpected keyword argument '%q'", (((mp_uint_t)(wanted_arg_name)) >> 2)))) + ; + } + } + mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]); +continue2:; + } + + (void)0; + (void)0; + + + mp_obj_t *d = &code_state->state[n_state - n_pos_args]; + mp_obj_t *s = &self->extra_args[n_def_pos_args - 1]; + for (size_t i = n_def_pos_args; i > 0; i--, d++, s--) { + if (*d == (((mp_obj_t)(void*)0))) { + *d = *s; + } + } + + (void)0; + (void)0; + + + while (d < &code_state->state[n_state]) { + if (*d++ == (((mp_obj_t)(void*)0))) { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function missing required positional argument #%d", &code_state->state[n_state] - d))) + ; + } + } + + + + for (size_t i = 0; i < n_kwonly_args; i++) { + if (code_state->state[n_state - 1 - n_pos_args - i] == (((mp_obj_t)(void*)0))) { + mp_map_elem_t *elem = +# 245 "user/mpy/py/bc.c" 3 4 + ((void *)0) +# 245 "user/mpy/py/bc.c" + ; + if ((scope_flags & (0x08)) != 0) { + elem = mp_map_lookup(&((mp_obj_dict_t*)((void*)self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP); + } + if (elem != +# 249 "user/mpy/py/bc.c" 3 4 + ((void *)0) +# 249 "user/mpy/py/bc.c" + ) { + code_state->state[n_state - 1 - n_pos_args - i] = elem->value; + } else { + nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function missing required keyword argument '%q'", (((mp_uint_t)(arg_names[n_pos_args + i])) >> 2)))) + ; + } + } + } + + } else { + + if (n_kwonly_args != 0) { + mp_raise_TypeError("function missing keyword-only argument"); + } + if ((scope_flags & (0x02)) != 0) { + *var_pos_kw_args = mp_obj_new_dict(0); + } + } + + + const byte *ip = code_state->ip; + + + ip += mp_decode_uint_value(ip); + + + size_t local_num; + while ((local_num = *ip++) != 255) { + code_state->state[n_state - 1 - local_num] = + mp_obj_new_cell(code_state->state[n_state - 1 - local_num]); + } + + + code_state->ip = ip; + + (void)0; + (void)0; + (void)0; +} +# 1 "user/mpy/py/showbc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/showbc.c" +# 27 "user/mpy/py/showbc.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/showbc.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/showbc.c" 2 + +# 1 "user/mpy/py/bc0.h" 1 +# 31 "user/mpy/py/showbc.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 29 "user/mpy/py/bc.h" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/bc.h" 2 + +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 32 "user/mpy/py/showbc.c" 2 +# 1 "user/mpy/py/repl.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/repl.c" +# 27 "user/mpy/py/repl.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/repl.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 29 "user/mpy/py/repl.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/repl.c" 2 +# 1 "user/mpy/py/repl.h" 1 +# 34 "user/mpy/py/repl.h" + +# 34 "user/mpy/py/repl.h" 3 4 +_Bool +# 34 "user/mpy/py/repl.h" + mp_repl_continue_with_input(const char *input); +size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str); +# 31 "user/mpy/py/repl.c" 2 + + + +static +# 34 "user/mpy/py/repl.c" 3 4 + _Bool +# 34 "user/mpy/py/repl.c" + str_startswith_word(const char *str, const char *head) { + size_t i; + for (i = 0; str[i] && head[i]; i++) { + if (str[i] != head[i]) { + return +# 38 "user/mpy/py/repl.c" 3 4 + 0 +# 38 "user/mpy/py/repl.c" + ; + } + } + return head[i] == '\0' && (str[i] == '\0' || !unichar_isident(str[i])); +} + + +# 44 "user/mpy/py/repl.c" 3 4 +_Bool +# 44 "user/mpy/py/repl.c" + mp_repl_continue_with_input(const char *input) { + + if (input[0] == '\0') { + return +# 47 "user/mpy/py/repl.c" 3 4 + 0 +# 47 "user/mpy/py/repl.c" + ; + } + + + +# 51 "user/mpy/py/repl.c" 3 4 + _Bool +# 51 "user/mpy/py/repl.c" + starts_with_compound_keyword = + input[0] == '@' + || str_startswith_word(input, "if") + || str_startswith_word(input, "while") + || str_startswith_word(input, "for") + || str_startswith_word(input, "try") + || str_startswith_word(input, "with") + || str_startswith_word(input, "def") + || str_startswith_word(input, "class") + + + + ; + + + + + + + + int n_paren = 0; + int n_brack = 0; + int n_brace = 0; + int in_quote = (0); + const char *i; + for (i = input; *i; i++) { + if (*i == '\'') { + if ((in_quote == (0) || in_quote == (3)) && i[1] == '\'' && i[2] == '\'') { + i += 2; + in_quote = (3) - in_quote; + } else if (in_quote == (0) || in_quote == (1)) { + in_quote = (1) - in_quote; + } + } else if (*i == '"') { + if ((in_quote == (0) || in_quote == (4)) && i[1] == '"' && i[2] == '"') { + i += 2; + in_quote = (4) - in_quote; + } else if (in_quote == (0) || in_quote == (2)) { + in_quote = (2) - in_quote; + } + } else if (*i == '\\' && (i[1] == '\'' || i[1] == '"' || i[1] == '\\')) { + if (in_quote != (0)) { + i++; + } + } else if (in_quote == (0)) { + switch (*i) { + case '(': n_paren += 1; break; + case ')': n_paren -= 1; break; + case '[': n_brack += 1; break; + case ']': n_brack -= 1; break; + case '{': n_brace += 1; break; + case '}': n_brace -= 1; break; + default: break; + } + } + } + + + if (n_paren > 0 || n_brack > 0 || n_brace > 0 || in_quote == (3) || in_quote == (4)) { + return +# 110 "user/mpy/py/repl.c" 3 4 + 1 +# 110 "user/mpy/py/repl.c" + ; + } + + + if (i[-1] == '\\') { + return +# 115 "user/mpy/py/repl.c" 3 4 + 1 +# 115 "user/mpy/py/repl.c" + ; + } + + + if (starts_with_compound_keyword && i[-1] != '\n') { + return +# 120 "user/mpy/py/repl.c" 3 4 + 1 +# 120 "user/mpy/py/repl.c" + ; + } + + + return +# 124 "user/mpy/py/repl.c" 3 4 + 0 +# 124 "user/mpy/py/repl.c" + ; +} + +size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str) { + + const char *org_str = str; + const char *top = str + len; + for (const char *s = top; --s >= str;) { + if (!(unichar_isalpha(*s) || unichar_isdigit(*s) || *s == '_' || *s == '.')) { + ++s; + str = s; + break; + } + } + + + mp_obj_dict_t *dict = mp_locals_get(); + + for (;;) { + + const char *s_start = str; + while (str < top && *str != '.') { + ++str; + } + size_t s_len = str - s_start; + + if (str < top) { + + + mp_obj_t obj = (((mp_obj_t)(void*)0)); + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + size_t d_len; + const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); + if (s_len == d_len && strncmp(s_start, d_str, d_len) == 0) { + obj = dict->map.table[i].value; + break; + } + } + } + + if (obj == (((mp_obj_t)(void*)0))) { + + return 0; + } + + + if ((MP_OBJ_IS_OBJ(obj) && (((mp_obj_base_t*)((void*)obj))->type == (&mp_type_module)))) { + dict = mp_obj_module_get_globals(obj); + } else { + mp_obj_type_t *type; + if ((MP_OBJ_IS_OBJ(obj) && (((mp_obj_base_t*)((void*)obj))->type == (&mp_type_type)))) { + type = ((void*)obj); + } else { + type = mp_obj_get_type(obj); + } + if (type->locals_dict != +# 180 "user/mpy/py/repl.c" 3 4 + ((void *)0) +# 180 "user/mpy/py/repl.c" + && type->locals_dict->base.type == &mp_type_dict) { + dict = type->locals_dict; + } else { + + return 0; + } + } + + + ++str; + + } else { + + + + int n_found = 0; + const char *match_str = +# 196 "user/mpy/py/repl.c" 3 4 + ((void *)0) +# 196 "user/mpy/py/repl.c" + ; + size_t match_len = 0; + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + size_t d_len; + const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); + if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { + if (match_str == +# 203 "user/mpy/py/repl.c" 3 4 + ((void *)0) +# 203 "user/mpy/py/repl.c" + ) { + match_str = d_str; + match_len = d_len; + } else { + + + for (size_t j = s_len; j <= match_len && j <= d_len; ++j) { + if (match_str[j] != d_str[j]) { + match_len = j; + break; + } + } + } + ++n_found; + } + } + } + + + if (n_found == 0) { + + + if (s_start == org_str) { + static const char import_str[] = "import "; + if (memcmp(s_start, import_str, s_len) == 0) { + *compl_str = import_str + s_len; + return sizeof(import_str) - 1 - s_len; + } + } + + return 0; + } + + + if (n_found == 1 || match_len > s_len) { + *compl_str = match_str + s_len; + return match_len - s_len; + } + + + + + + + int line_len = (4 * (16)); + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + size_t d_len; + const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); + if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { + int gap = (line_len + (16) - 1) / (16) * (16) - line_len; + if (gap < 2) { + gap += (16); + } + if (line_len + gap + d_len <= (4 * (16))) { + + for (int j = 0; j < gap; ++j) { + mp_print_str(print, " "); + } + mp_print_str(print, d_str); + line_len += gap + d_len; + } else { + mp_printf(print, "\n%s", d_str); + line_len = d_len; + } + } + } + } + mp_print_str(print, "\n"); + + return (size_t)(-1); + } + } +} +# 1 "user/mpy/py/smallint.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/smallint.c" +# 27 "user/mpy/py/smallint.c" +# 1 "user/mpy/py/smallint.h" 1 +# 29 "user/mpy/py/smallint.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/smallint.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/smallint.h" 2 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 28 "user/mpy/py/smallint.c" 2 + + +# 29 "user/mpy/py/smallint.c" 3 4 +_Bool +# 29 "user/mpy/py/smallint.c" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y) { + + if (x > 0) { + if (y > 0) { + if (x > (((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))))) / y)) { + return +# 34 "user/mpy/py/smallint.c" 3 4 + 1 +# 34 "user/mpy/py/smallint.c" + ; + } + } else { + if (y < (((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) / x)) { + return +# 38 "user/mpy/py/smallint.c" 3 4 + 1 +# 38 "user/mpy/py/smallint.c" + ; + } + } + } else { + if (y > 0) { + if (x < (((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) / y)) { + return +# 44 "user/mpy/py/smallint.c" 3 4 + 1 +# 44 "user/mpy/py/smallint.c" + ; + } + } else { + if (x != 0 && y < (((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))))) / x)) { + return +# 48 "user/mpy/py/smallint.c" 3 4 + 1 +# 48 "user/mpy/py/smallint.c" + ; + } + } + } + return +# 52 "user/mpy/py/smallint.c" 3 4 + 0 +# 52 "user/mpy/py/smallint.c" + ; +} + +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor) { + + dividend %= divisor; + if ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0)) { + dividend += divisor; + } + return dividend; +} + +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom) { + if (num >= 0) { + if (denom < 0) { + num += -denom - 1; + } + } else { + if (denom >= 0) { + num += -denom + 1; + } + } + return num / denom; +} +# 1 "user/mpy/py/frozenmod.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/frozenmod.c" +# 28 "user/mpy/py/frozenmod.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/frozenmod.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/frozenmod.c" 2 + +# 1 "user/mpy/py/lexer.h" 1 +# 31 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 32 "user/mpy/py/frozenmod.c" 2 +# 1 "user/mpy/py/frozenmod.h" 1 +# 31 "user/mpy/py/frozenmod.h" +enum { + MP_FROZEN_NONE, + MP_FROZEN_STR, + MP_FROZEN_MPY, +}; + +int mp_find_frozen_module(const char *str, size_t len, void **data); +const char *mp_find_frozen_str(const char *str, size_t *len); +mp_import_stat_t mp_frozen_stat(const char *str); +# 33 "user/mpy/py/frozenmod.c" 2 +# 80 "user/mpy/py/frozenmod.c" +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 81 "user/mpy/py/frozenmod.c" 2 + +extern const char mp_frozen_mpy_names[]; +extern const mp_raw_code_t *const mp_frozen_mpy_content[]; + +static const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t len) { + const char *name = mp_frozen_mpy_names; + for (size_t i = 0; *name != 0; i++) { + size_t l = strlen(name); + if (l == len && !memcmp(str, name, l)) { + return mp_frozen_mpy_content[i]; + } + name += l + 1; + } + return +# 94 "user/mpy/py/frozenmod.c" 3 4 + ((void *)0) +# 94 "user/mpy/py/frozenmod.c" + ; +} + + + + + +static mp_import_stat_t mp_frozen_stat_helper(const char *name, const char *str) { + size_t len = strlen(str); + + for (int i = 0; *name != 0; i++) { + size_t l = strlen(name); + if (l >= len && !memcmp(str, name, len)) { + if (name[len] == 0) { + return MP_IMPORT_STAT_FILE; + } else if (name[len] == '/') { + return MP_IMPORT_STAT_DIR; + } + } + name += l + 1; + } + return MP_IMPORT_STAT_NO_EXIST; +} + +mp_import_stat_t mp_frozen_stat(const char *str) { + mp_import_stat_t stat; +# 129 "user/mpy/py/frozenmod.c" + stat = mp_frozen_stat_helper(mp_frozen_mpy_names, str); + if (stat != MP_IMPORT_STAT_NO_EXIST) { + return stat; + } + + + return MP_IMPORT_STAT_NO_EXIST; +} + +int mp_find_frozen_module(const char *str, size_t len, void **data) { +# 147 "user/mpy/py/frozenmod.c" + const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len); + if (rc != +# 148 "user/mpy/py/frozenmod.c" 3 4 + ((void *)0) +# 148 "user/mpy/py/frozenmod.c" + ) { + *data = (void*)rc; + return MP_FROZEN_MPY; + } + + return MP_FROZEN_NONE; +} +# 1 "user/mpy/py/../extmod/moductypes.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/moductypes.c" +# 27 "user/mpy/py/../extmod/moductypes.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/../extmod/moductypes.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/moductypes.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/../extmod/moductypes.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/../extmod/moductypes.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/../extmod/moductypes.c" 2 + +# 1 "user/mpy/py/binary.h" 1 +# 35 "user/mpy/py/binary.h" +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 35 "user/mpy/py/../extmod/moductypes.c" 2 +# 1 "user/mpy/py/../extmod/modujson.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modujson.c" +# 27 "user/mpy/py/../extmod/modujson.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modujson.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 30 "user/mpy/py/../extmod/modujson.c" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 29 "user/mpy/py/objlist.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objlist.h" 2 + +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; +# 31 "user/mpy/py/../extmod/modujson.c" 2 +# 1 "user/mpy/py/objstringio.h" 1 +# 31 "user/mpy/py/objstringio.h" +typedef struct _mp_obj_stringio_t { + mp_obj_base_t base; + vstr_t *vstr; + + mp_uint_t pos; + + mp_obj_t ref_obj; +} mp_obj_stringio_t; +# 32 "user/mpy/py/../extmod/modujson.c" 2 +# 1 "user/mpy/py/parsenum.h" 1 +# 30 "user/mpy/py/parsenum.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 31 "user/mpy/py/parsenum.h" 2 + + + +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + allow_imag, +# 35 "user/mpy/py/parsenum.h" 3 4 + _Bool +# 35 "user/mpy/py/parsenum.h" + force_complex, mp_lexer_t *lex); +# 33 "user/mpy/py/../extmod/modujson.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + + +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/../extmod/modujson.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 35 "user/mpy/py/../extmod/modujson.c" 2 +# 1 "user/mpy/py/../extmod/modure.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modure.c" +# 27 "user/mpy/py/../extmod/modure.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modure.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/../extmod/modure.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/../extmod/modure.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/../extmod/modure.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/../extmod/modure.c" 2 +# 1 "user/mpy/py/binary.h" 1 +# 35 "user/mpy/py/binary.h" +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 34 "user/mpy/py/../extmod/modure.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 35 "user/mpy/py/../extmod/modure.c" 2 +# 1 "user/mpy/py/../extmod/moduzlib.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/moduzlib.c" +# 27 "user/mpy/py/../extmod/moduzlib.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/moduzlib.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/moduzlib.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/../extmod/moduzlib.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/../extmod/moduzlib.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 33 "user/mpy/py/../extmod/moduzlib.c" 2 +# 1 "user/mpy/py/../extmod/moduheapq.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/moduheapq.c" +# 27 "user/mpy/py/../extmod/moduheapq.c" +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 4 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 4 +# 5 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 9 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 + +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 28 "user/mpy/py/../extmod/moduheapq.c" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 29 "user/mpy/py/objlist.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objlist.h" 2 + +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; +# 29 "user/mpy/py/../extmod/moduheapq.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 30 "user/mpy/py/../extmod/moduheapq.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + + +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/../extmod/moduheapq.c" 2 +# 1 "user/mpy/py/../extmod/modutimeq.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modutimeq.c" +# 28 "user/mpy/py/../extmod/modutimeq.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/modutimeq.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/../extmod/modutimeq.c" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 29 "user/mpy/py/objlist.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/objlist.h" 2 + +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; +# 32 "user/mpy/py/../extmod/modutimeq.c" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 33 "user/mpy/py/../extmod/modutimeq.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + + +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/../extmod/modutimeq.c" 2 +# 1 "user/mpy/py/smallint.h" 1 +# 64 "user/mpy/py/smallint.h" + +# 64 "user/mpy/py/smallint.h" 3 4 +_Bool +# 64 "user/mpy/py/smallint.h" + mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); +# 35 "user/mpy/py/../extmod/modutimeq.c" 2 +# 1 "user/mpy/py/../extmod/moduhashlib.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/moduhashlib.c" +# 27 "user/mpy/py/../extmod/moduhashlib.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/../extmod/moduhashlib.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/moduhashlib.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/../extmod/moduhashlib.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/../extmod/moduhashlib.c" 2 +# 1 "user/mpy/py/../extmod/modubinascii.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modubinascii.c" +# 27 "user/mpy/py/../extmod/modubinascii.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modubinascii.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 29 "user/mpy/py/../extmod/modubinascii.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/../extmod/modubinascii.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/../extmod/modubinascii.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/../extmod/modubinascii.c" 2 +# 1 "user/mpy/py/binary.h" 1 +# 35 "user/mpy/py/binary.h" +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + is_signed, +# 41 "user/mpy/py/binary.h" 3 4 + _Bool +# 41 "user/mpy/py/binary.h" + big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, +# 42 "user/mpy/py/binary.h" 3 4 + _Bool +# 42 "user/mpy/py/binary.h" + big_endian, byte *dest, mp_uint_t val); +# 34 "user/mpy/py/../extmod/modubinascii.c" 2 +# 1 "user/mpy/extmod/modubinascii.h" 1 +# 29 "user/mpy/extmod/modubinascii.h" +extern mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args); +extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data); +extern mp_obj_t mod_binascii_a2b_base64(mp_obj_t data); +extern mp_obj_t mod_binascii_b2a_base64(mp_obj_t data); +extern mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mod_binascii_hexlify_obj; +extern const mp_obj_fun_builtin_fixed_t mod_binascii_unhexlify_obj; +extern const mp_obj_fun_builtin_fixed_t mod_binascii_a2b_base64_obj; +extern const mp_obj_fun_builtin_fixed_t mod_binascii_b2a_base64_obj; +extern const mp_obj_fun_builtin_var_t mod_binascii_crc32_obj; +# 35 "user/mpy/py/../extmod/modubinascii.c" 2 + +# 1 "user/mpy/py/../extmod/uzlib/tinf.h" 1 +# 44 "user/mpy/py/../extmod/uzlib/tinf.h" +typedef struct { + unsigned short table[16]; + unsigned short trans[288]; +} TINF_TREE; + +struct TINF_DATA; +typedef struct TINF_DATA { + const unsigned char *source; + + + unsigned char (*readSource)(struct TINF_DATA *data); + + unsigned int tag; + unsigned int bitcount; + + + unsigned char *destStart; + + unsigned int destSize; + + unsigned char *dest; + + unsigned int destRemaining; + + + unsigned int checksum; + char checksum_type; + + int btype; + int bfinal; + unsigned int curlen; + int lzOff; + unsigned char *dict_ring; + unsigned int dict_size; + unsigned int dict_idx; + + TINF_TREE ltree; + TINF_TREE dtree; +} TINF_DATA; + + + + + + + +unsigned char uzlib_get_byte(TINF_DATA *d); + + + +void uzlib_init(void); +void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen); +int uzlib_uncompress(TINF_DATA *d); +int uzlib_uncompress_chksum(TINF_DATA *d); + +int uzlib_zlib_parse_header(TINF_DATA *d); +int uzlib_gzip_parse_header(TINF_DATA *d); + + + +void uzlib_compress(void *data, const uint8_t *src, unsigned slen); + + + + +uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum); + +uint32_t uzlib_crc32(const void *data, unsigned int length, uint32_t crc); +# 37 "user/mpy/py/../extmod/modubinascii.c" 2 + +mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { + + + const char *sep = +# 41 "user/mpy/py/../extmod/modubinascii.c" 3 4 + ((void *)0) +# 41 "user/mpy/py/../extmod/modubinascii.c" + ; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, (1)); + + + + if (bufinfo.len == 0) { + return (((mp_obj_t)&mp_const_empty_bytes_obj)); + } + + vstr_t vstr; + size_t out_len = bufinfo.len * 2; + if (n_args > 1) { + + out_len += bufinfo.len - 1; + sep = mp_obj_str_get_str(args[1]); + } + vstr_init_len(&vstr, out_len); + byte *in = bufinfo.buf, *out = (byte*)vstr.buf; + for (mp_uint_t i = bufinfo.len; i--;) { + byte d = (*in >> 4); + if (d > 9) { + d += 'a' - '9' - 1; + } + *out++ = d + '0'; + d = (*in++ & 0xf); + if (d > 9) { + d += 'a' - '9' - 1; + } + *out++ = d + '0'; + if (sep != +# 71 "user/mpy/py/../extmod/modubinascii.c" 3 4 + ((void *)0) +# 71 "user/mpy/py/../extmod/modubinascii.c" + && i != 0) { + *out++ = *sep; + } + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +const mp_obj_fun_builtin_var_t mod_binascii_hexlify_obj = {{&mp_type_fun_builtin_var}, +# 77 "user/mpy/py/../extmod/modubinascii.c" 3 4 +0 +# 77 "user/mpy/py/../extmod/modubinascii.c" +, 1, 2, .fun.var = mod_binascii_hexlify}; + +mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, (1)); + + if ((bufinfo.len & 1) != 0) { + mp_raise_ValueError("odd-length string"); + } + vstr_t vstr; + vstr_init_len(&vstr, bufinfo.len / 2); + byte *in = bufinfo.buf, *out = (byte*)vstr.buf; + byte hex_byte = 0; + for (mp_uint_t i = bufinfo.len; i--;) { + byte hex_ch = *in++; + if (unichar_isxdigit(hex_ch)) { + hex_byte += unichar_xdigit_value(hex_ch); + } else { + mp_raise_ValueError("non-hex digit found"); + } + if (i & 1) { + hex_byte <<= 4; + } else { + *out++ = hex_byte; + hex_byte = 0; + } + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +const mp_obj_fun_builtin_fixed_t mod_binascii_unhexlify_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mod_binascii_unhexlify}; + +mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, (1)); + if (bufinfo.len % 4 != 0) { + mp_raise_ValueError("incorrect padding"); + } + + vstr_t vstr; + byte *in = bufinfo.buf; + if (bufinfo.len == 0) { + vstr_init_len(&vstr, 0); + } + else { + vstr_init_len(&vstr, ((bufinfo.len / 4) * 3) - ((in[bufinfo.len-1] == '=') ? ((in[bufinfo.len-2] == '=') ? 2 : 1 ) : 0)); + } + byte *out = (byte*)vstr.buf; + for (mp_uint_t i = bufinfo.len; i; i -= 4) { + char hold[4]; + for (int j = 4; j--;) { + if (in[j] >= 'A' && in[j] <= 'Z') { + hold[j] = in[j] - 'A'; + } else if (in[j] >= 'a' && in[j] <= 'z') { + hold[j] = in[j] - 'a' + 26; + } else if (in[j] >= '0' && in[j] <= '9') { + hold[j] = in[j] - '0' + 52; + } else if (in[j] == '+') { + hold[j] = 62; + } else if (in[j] == '/') { + hold[j] = 63; + } else if (in[j] == '=') { + if (j < 2 || i > 4) { + mp_raise_ValueError("incorrect padding"); + } + hold[j] = 64; + } else { + mp_raise_ValueError("invalid character"); + } + } + in += 4; + + *out++ = (hold[0]) << 2 | (hold[1]) >> 4; + if (hold[2] != 64) { + *out++ = (hold[1] & 0x0F) << 4 | hold[2] >> 2; + if (hold[3] != 64) { + *out++ = (hold[2] & 0x03) << 6 | hold[3]; + } + } + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +const mp_obj_fun_builtin_fixed_t mod_binascii_a2b_base64_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mod_binascii_a2b_base64}; + +mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, (1)); + + vstr_t vstr; + vstr_init_len(&vstr, ((bufinfo.len != 0) ? (((bufinfo.len - 1) / 3) + 1) * 4 : 0) + 1); + + + byte *in = bufinfo.buf, *out = (byte*)vstr.buf; + mp_uint_t i; + for (i = bufinfo.len; i >= 3; i -= 3) { + *out++ = (in[0] & 0xFC) >> 2; + *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; + *out++ = (in[1] & 0x0F) << 2 | (in[2] & 0xC0) >> 6; + *out++ = in[2] & 0x3F; + in += 3; + } + if (i != 0) { + *out++ = (in[0] & 0xFC) >> 2; + if (i == 2) { + *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; + *out++ = (in[1] & 0x0F) << 2; + } + else { + *out++ = (in[0] & 0x03) << 4; + *out++ = 64; + } + *out++ = 64; + } + + + out = (byte*)vstr.buf; + for (mp_uint_t j = vstr.len - 1; j--;) { + if (*out < 26) { + *out += 'A'; + } else if (*out < 52) { + *out += 'a' - 26; + } else if (*out < 62) { + *out += '0' - 52; + } else if (*out == 62) { + *out ='+'; + } else if (*out == 63) { + *out = '/'; + } else { + *out = '='; + } + out++; + } + *out = '\n'; + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +const mp_obj_fun_builtin_fixed_t mod_binascii_b2a_base64_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mod_binascii_b2a_base64}; +# 1 "user/mpy/py/../extmod/virtpin.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/virtpin.c" +# 27 "user/mpy/py/../extmod/virtpin.c" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 29 "user/mpy/extmod/virtpin.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/extmod/virtpin.h" 2 + + + + + + + +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 28 "user/mpy/py/../extmod/virtpin.c" 2 + +int mp_virtual_pin_read(mp_obj_t pin) { + mp_obj_base_t* s = (mp_obj_base_t*)((void*)pin); + mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; + return pin_p->ioctl(pin, (1), 0, +# 32 "user/mpy/py/../extmod/virtpin.c" 3 4 + ((void *)0) +# 32 "user/mpy/py/../extmod/virtpin.c" + ); +} + +void mp_virtual_pin_write(mp_obj_t pin, int value) { + mp_obj_base_t* s = (mp_obj_base_t*)((void*)pin); + mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; + pin_p->ioctl(pin, (2), value, +# 38 "user/mpy/py/../extmod/virtpin.c" 3 4 + ((void *)0) +# 38 "user/mpy/py/../extmod/virtpin.c" + ); +} +# 1 "user/mpy/py/../extmod/machine_mem.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/machine_mem.c" +# 27 "user/mpy/py/../extmod/machine_mem.c" +# 1 "user/mpy/extmod/machine_mem.h" 1 +# 29 "user/mpy/extmod/machine_mem.h" +# 1 "user/mpy/py/obj.h" 1 +# 29 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/extmod/machine_mem.h" 2 + +typedef struct _machine_mem_obj_t { + mp_obj_base_t base; + unsigned elem_size; +} machine_mem_obj_t; + +extern const mp_obj_type_t machine_mem_type; + +extern const machine_mem_obj_t machine_mem8_obj; +extern const machine_mem_obj_t machine_mem16_obj; +extern const machine_mem_obj_t machine_mem32_obj; +# 28 "user/mpy/py/../extmod/machine_mem.c" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 29 "user/mpy/py/../extmod/machine_mem.c" 2 +# 1 "user/mpy/py/../extmod/machine_pinbase.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/machine_pinbase.c" +# 27 "user/mpy/py/../extmod/machine_pinbase.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../extmod/machine_pinbase.c" 2 +# 1 "user/mpy/py/../extmod/machine_signal.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/machine_signal.c" +# 27 "user/mpy/py/../extmod/machine_signal.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../extmod/machine_signal.c" 2 +# 1 "user/mpy/py/../extmod/machine_pulse.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/machine_pulse.c" +# 27 "user/mpy/py/../extmod/machine_pulse.c" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 28 "user/mpy/py/../extmod/machine_pulse.c" 2 +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 29 "user/mpy/py/../extmod/machine_pulse.c" 2 +# 1 "user/mpy/extmod/machine_pulse.h" 1 +# 30 "user/mpy/extmod/machine_pulse.h" +# 1 "user/mpy/py/mphal.h" 1 +# 34 "user/mpy/py/mphal.h" +# 1 "user/mpy/mphalport.h" 1 +# 35 "user/mpy/py/mphal.h" 2 + + + + +# 38 "user/mpy/py/mphal.h" +int mp_hal_stdin_rx_chr(void); + + + + + + + +void mp_hal_stdout_tx_strn(const char *str, size_t len); + + + + + + + +void mp_hal_delay_ms(mp_uint_t ms); + + + +void mp_hal_delay_us(mp_uint_t us); + + + + + + + +mp_uint_t mp_hal_ticks_us(void); + + + +mp_uint_t mp_hal_ticks_cpu(void); +# 80 "user/mpy/py/mphal.h" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 37 "user/mpy/extmod/virtpin.h" +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 81 "user/mpy/py/mphal.h" 2 +# 31 "user/mpy/extmod/machine_pulse.h" 2 + +mp_uint_t machine_time_pulse_us(mp_obj_t pin, int pulse_level, mp_uint_t timeout_us); + +extern const mp_obj_fun_builtin_var_t machine_time_pulse_us_obj; +# 30 "user/mpy/py/../extmod/machine_pulse.c" 2 +# 1 "user/mpy/py/../extmod/machine_i2c.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/machine_i2c.c" +# 27 "user/mpy/py/../extmod/machine_i2c.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/machine_i2c.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 29 "user/mpy/py/../extmod/machine_i2c.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/../extmod/machine_i2c.c" 2 + +# 1 "user/mpy/py/mperrno.h" 1 +# 29 "user/mpy/py/mperrno.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 30 "user/mpy/py/mperrno.h" 2 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 32 "user/mpy/py/../extmod/machine_i2c.c" 2 +# 1 "user/mpy/py/mphal.h" 1 +# 34 "user/mpy/py/mphal.h" +# 1 "user/mpy/mphalport.h" 1 +# 35 "user/mpy/py/mphal.h" 2 + + + + +# 38 "user/mpy/py/mphal.h" +int mp_hal_stdin_rx_chr(void); + + + + + + + +void mp_hal_stdout_tx_strn(const char *str, size_t len); + + + + + + + +void mp_hal_delay_ms(mp_uint_t ms); + + + +void mp_hal_delay_us(mp_uint_t us); + + + + + + + +mp_uint_t mp_hal_ticks_us(void); + + + +mp_uint_t mp_hal_ticks_cpu(void); +# 80 "user/mpy/py/mphal.h" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 29 "user/mpy/extmod/virtpin.h" +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/extmod/virtpin.h" 2 + + + + + + + +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 81 "user/mpy/py/mphal.h" 2 +# 33 "user/mpy/py/../extmod/machine_i2c.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/../extmod/machine_i2c.c" 2 +# 1 "user/mpy/extmod/machine_i2c.h" 1 +# 33 "user/mpy/extmod/machine_i2c.h" +typedef struct _mp_machine_i2c_p_t { + int (*start)(mp_obj_base_t *obj); + int (*stop)(mp_obj_base_t *obj); + int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, +# 36 "user/mpy/extmod/machine_i2c.h" 3 4 + _Bool +# 36 "user/mpy/extmod/machine_i2c.h" + nack); + int (*write)(mp_obj_base_t *obj, const uint8_t *src, size_t len); + int (*readfrom)(mp_obj_base_t *obj, uint16_t addr, uint8_t *dest, size_t len, +# 38 "user/mpy/extmod/machine_i2c.h" 3 4 + _Bool +# 38 "user/mpy/extmod/machine_i2c.h" + stop); + int (*writeto)(mp_obj_base_t *obj, uint16_t addr, const uint8_t *src, size_t len, +# 39 "user/mpy/extmod/machine_i2c.h" 3 4 + _Bool +# 39 "user/mpy/extmod/machine_i2c.h" + stop); +} mp_machine_i2c_p_t; + +typedef struct _mp_machine_soft_i2c_obj_t { + mp_obj_base_t base; + uint32_t us_delay; + uint32_t us_timeout; + mp_obj_t scl; + mp_obj_t sda; +} mp_machine_soft_i2c_obj_t; + +extern const mp_obj_type_t machine_i2c_type; +extern const mp_obj_dict_t mp_machine_soft_i2c_locals_dict; + +int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, +# 53 "user/mpy/extmod/machine_i2c.h" 3 4 + _Bool +# 53 "user/mpy/extmod/machine_i2c.h" + stop); +int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, +# 54 "user/mpy/extmod/machine_i2c.h" 3 4 + _Bool +# 54 "user/mpy/extmod/machine_i2c.h" + stop); +# 35 "user/mpy/py/../extmod/machine_i2c.c" 2 +# 1 "user/mpy/py/../extmod/machine_spi.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/machine_spi.c" +# 27 "user/mpy/py/../extmod/machine_spi.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/machine_spi.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/machine_spi.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/../extmod/machine_spi.c" 2 +# 1 "user/mpy/extmod/machine_spi.h" 1 +# 30 "user/mpy/extmod/machine_spi.h" +# 1 "user/mpy/py/mphal.h" 1 +# 34 "user/mpy/py/mphal.h" +# 1 "user/mpy/mphalport.h" 1 +# 35 "user/mpy/py/mphal.h" 2 + + + +int mp_hal_stdin_rx_chr(void); + + + + + + + +void mp_hal_stdout_tx_strn(const char *str, size_t len); + + + + + + + +void mp_hal_delay_ms(mp_uint_t ms); + + + +void mp_hal_delay_us(mp_uint_t us); + + + + + + + +mp_uint_t mp_hal_ticks_us(void); + + + +mp_uint_t mp_hal_ticks_cpu(void); +# 80 "user/mpy/py/mphal.h" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 37 "user/mpy/extmod/virtpin.h" +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 81 "user/mpy/py/mphal.h" 2 +# 31 "user/mpy/extmod/machine_spi.h" 2 + + +typedef struct _mp_machine_spi_p_t { + void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); + void (*deinit)(mp_obj_base_t *obj); + void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); +} mp_machine_spi_p_t; + +typedef struct _mp_machine_soft_spi_obj_t { + mp_obj_base_t base; + uint32_t delay_half; + uint8_t polarity; + uint8_t phase; + mp_obj_t sck; + mp_obj_t mosi; + mp_obj_t miso; +} mp_machine_soft_spi_obj_t; + +extern const mp_obj_type_t mp_machine_soft_spi_type; +extern const mp_obj_dict_t mp_machine_spi_locals_dict; + +void mp_machine_soft_spi_transfer(mp_obj_base_t *self, size_t len, const uint8_t *src, uint8_t *dest); + +mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_machine_spi_read_obj; +extern const mp_obj_fun_builtin_var_t mp_machine_spi_readinto_obj; +extern const mp_obj_fun_builtin_fixed_t mp_machine_spi_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_machine_spi_write_readinto_obj; +# 32 "user/mpy/py/../extmod/machine_spi.c" 2 +# 1 "user/mpy/py/../extmod/modussl_axtls.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modussl_axtls.c" +# 27 "user/mpy/py/../extmod/modussl_axtls.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modussl_axtls.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/modussl_axtls.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/../extmod/modussl_axtls.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/../extmod/modussl_axtls.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 33 "user/mpy/py/../extmod/modussl_axtls.c" 2 +# 1 "user/mpy/py/../extmod/modussl_mbedtls.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modussl_mbedtls.c" +# 27 "user/mpy/py/../extmod/modussl_mbedtls.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../extmod/modussl_mbedtls.c" 2 +# 1 "user/mpy/py/../extmod/modurandom.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modurandom.c" +# 27 "user/mpy/py/../extmod/modurandom.c" +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 9 "/usr/arm-none-eabi/include/assert.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 + +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 28 "user/mpy/py/../extmod/modurandom.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 11 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/modurandom.c" 2 + + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/../extmod/modurandom.c" 2 +# 1 "user/mpy/py/../extmod/moduselect.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/moduselect.c" +# 27 "user/mpy/py/../extmod/moduselect.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../extmod/moduselect.c" 2 +# 1 "user/mpy/py/../extmod/modwebsocket.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modwebsocket.c" +# 27 "user/mpy/py/../extmod/modwebsocket.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 29 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/../extmod/modwebsocket.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 33 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 35 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "user/mpy/extmod/modwebsocket.h" 1 + + + + +enum { + FRAME_CONT, FRAME_TXT, FRAME_BIN, + FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG +}; +# 36 "user/mpy/py/../extmod/modwebsocket.c" 2 +# 1 "user/mpy/py/../extmod/modwebrepl.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modwebrepl.c" +# 27 "user/mpy/py/../extmod/modwebrepl.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 29 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 30 "user/mpy/py/../extmod/modwebrepl.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 32 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 33 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 34 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 35 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "user/mpy/py/builtin.h" 1 +# 31 "user/mpy/py/builtin.h" +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; +extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; +extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; + +extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; +extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; + +extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; +extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + + +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *mp_help_default_text; +# 36 "user/mpy/py/../extmod/modwebrepl.c" 2 + + + +# 1 "user/mpy/extmod/modwebsocket.h" 1 + + + + +enum { + FRAME_CONT, FRAME_TXT, FRAME_BIN, + FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG +}; +# 40 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "user/mpy/build/genhdr/mpversion.h" 1 +# 41 "user/mpy/py/../extmod/modwebrepl.c" 2 +# 1 "user/mpy/py/../extmod/modframebuf.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/modframebuf.c" +# 27 "user/mpy/py/../extmod/modframebuf.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/modframebuf.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/modframebuf.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/../extmod/modframebuf.c" 2 +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 32 "user/mpy/py/../extmod/modframebuf.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 33 "user/mpy/py/../extmod/modframebuf.c" 2 +# 1 "user/mpy/py/../extmod/vfs.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/vfs.c" +# 27 "user/mpy/py/../extmod/vfs.c" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 28 "user/mpy/py/../extmod/vfs.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/vfs.c" 2 + +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" + +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 31 "user/mpy/py/../extmod/vfs.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 31 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/../extmod/vfs.c" 2 +# 1 "user/mpy/py/objstr.h" 1 +# 31 "user/mpy/py/objstr.h" +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + + size_t len; + const byte *data; +} mp_obj_str_t; +# 64 "user/mpy/py/objstr.h" +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, +# 74 "user/mpy/py/objstr.h" 3 4 + _Bool +# 74 "user/mpy/py/objstr.h" + is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +extern const mp_obj_fun_builtin_var_t str_encode_obj; +extern const mp_obj_fun_builtin_var_t str_find_obj; +extern const mp_obj_fun_builtin_var_t str_rfind_obj; +extern const mp_obj_fun_builtin_var_t str_index_obj; +extern const mp_obj_fun_builtin_var_t str_rindex_obj; +extern const mp_obj_fun_builtin_fixed_t str_join_obj; +extern const mp_obj_fun_builtin_var_t str_split_obj; +extern const mp_obj_fun_builtin_var_t str_splitlines_obj; +extern const mp_obj_fun_builtin_var_t str_rsplit_obj; +extern const mp_obj_fun_builtin_var_t str_startswith_obj; +extern const mp_obj_fun_builtin_var_t str_endswith_obj; +extern const mp_obj_fun_builtin_var_t str_strip_obj; +extern const mp_obj_fun_builtin_var_t str_lstrip_obj; +extern const mp_obj_fun_builtin_var_t str_rstrip_obj; +extern const mp_obj_fun_builtin_var_t str_format_obj; +extern const mp_obj_fun_builtin_var_t str_replace_obj; +extern const mp_obj_fun_builtin_var_t str_count_obj; +extern const mp_obj_fun_builtin_fixed_t str_partition_obj; +extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; +extern const mp_obj_fun_builtin_fixed_t str_center_obj; +extern const mp_obj_fun_builtin_fixed_t str_lower_obj; +extern const mp_obj_fun_builtin_fixed_t str_upper_obj; +extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; +extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; +extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; +extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; +extern const mp_obj_fun_builtin_fixed_t str_islower_obj; +# 33 "user/mpy/py/../extmod/vfs.c" 2 +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 34 "user/mpy/py/../extmod/vfs.c" 2 +# 1 "user/mpy/extmod/vfs.h" 1 +# 29 "user/mpy/extmod/vfs.h" +# 1 "user/mpy/py/lexer.h" 1 +# 33 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" + +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/extmod/vfs.h" 2 +# 48 "user/mpy/extmod/vfs.h" +typedef struct _mp_vfs_mount_t { + const char *str; + size_t len; + mp_obj_t obj; + struct _mp_vfs_mount_t *next; +} mp_vfs_mount_t; + +mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); +mp_import_stat_t mp_vfs_import_stat(const char *path); +mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +mp_obj_t mp_vfs_umount(mp_obj_t mnt_in); +mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +mp_obj_t mp_vfs_chdir(mp_obj_t path_in); +mp_obj_t mp_vfs_getcwd(void); +mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_vfs_mkdir(mp_obj_t path_in); +mp_obj_t mp_vfs_remove(mp_obj_t path_in); +mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in); +mp_obj_t mp_vfs_rmdir(mp_obj_t path_in); +mp_obj_t mp_vfs_stat(mp_obj_t path_in); +mp_obj_t mp_vfs_statvfs(mp_obj_t path_in); + +extern const mp_obj_fun_builtin_var_t mp_vfs_mount_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_umount_obj; +extern const mp_obj_fun_builtin_var_t mp_vfs_open_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_chdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_getcwd_obj; +extern const mp_obj_fun_builtin_var_t mp_vfs_ilistdir_obj; +extern const mp_obj_fun_builtin_var_t mp_vfs_listdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_mkdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_remove_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_rename_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_rmdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_stat_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_statvfs_obj; +# 35 "user/mpy/py/../extmod/vfs.c" 2 +# 1 "user/mpy/py/../extmod/vfs_reader.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/vfs_reader.c" +# 27 "user/mpy/py/../extmod/vfs_reader.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 28 "user/mpy/py/../extmod/vfs_reader.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 29 "user/mpy/py/../extmod/vfs_reader.c" 2 + +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 31 "user/mpy/py/../extmod/vfs_reader.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 32 "user/mpy/py/../extmod/vfs_reader.c" 2 +# 1 "user/mpy/py/reader.h" 1 +# 36 "user/mpy/py/reader.h" +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 33 "user/mpy/py/../extmod/vfs_reader.c" 2 +# 1 "user/mpy/extmod/vfs.h" 1 +# 29 "user/mpy/extmod/vfs.h" +# 1 "user/mpy/py/lexer.h" 1 +# 41 "user/mpy/py/lexer.h" +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/extmod/vfs.h" 2 +# 48 "user/mpy/extmod/vfs.h" +typedef struct _mp_vfs_mount_t { + const char *str; + size_t len; + mp_obj_t obj; + struct _mp_vfs_mount_t *next; +} mp_vfs_mount_t; + +mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); +mp_import_stat_t mp_vfs_import_stat(const char *path); +mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +mp_obj_t mp_vfs_umount(mp_obj_t mnt_in); +mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +mp_obj_t mp_vfs_chdir(mp_obj_t path_in); +mp_obj_t mp_vfs_getcwd(void); +mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_vfs_mkdir(mp_obj_t path_in); +mp_obj_t mp_vfs_remove(mp_obj_t path_in); +mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in); +mp_obj_t mp_vfs_rmdir(mp_obj_t path_in); +mp_obj_t mp_vfs_stat(mp_obj_t path_in); +mp_obj_t mp_vfs_statvfs(mp_obj_t path_in); + +extern const mp_obj_fun_builtin_var_t mp_vfs_mount_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_umount_obj; +extern const mp_obj_fun_builtin_var_t mp_vfs_open_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_chdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_getcwd_obj; +extern const mp_obj_fun_builtin_var_t mp_vfs_ilistdir_obj; +extern const mp_obj_fun_builtin_var_t mp_vfs_listdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_mkdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_remove_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_rename_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_rmdir_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_stat_obj; +extern const mp_obj_fun_builtin_fixed_t mp_vfs_statvfs_obj; +# 34 "user/mpy/py/../extmod/vfs_reader.c" 2 +# 1 "user/mpy/py/../extmod/vfs_fat.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/vfs_fat.c" +# 28 "user/mpy/py/../extmod/vfs_fat.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 29 "user/mpy/py/../extmod/vfs_fat.c" 2 +# 1 "user/mpy/py/../extmod/vfs_fat_diskio.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/vfs_fat_diskio.c" +# 30 "user/mpy/py/../extmod/vfs_fat_diskio.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 31 "user/mpy/py/../extmod/vfs_fat_diskio.c" 2 +# 1 "user/mpy/py/../extmod/vfs_fat_file.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/vfs_fat_file.c" +# 27 "user/mpy/py/../extmod/vfs_fat_file.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../extmod/vfs_fat_file.c" 2 +# 1 "user/mpy/py/../extmod/vfs_fat_misc.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/vfs_fat_misc.c" +# 27 "user/mpy/py/../extmod/vfs_fat_misc.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../extmod/vfs_fat_misc.c" 2 +# 1 "user/mpy/py/../extmod/utime_mphal.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/utime_mphal.c" +# 28 "user/mpy/py/../extmod/utime_mphal.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 29 "user/mpy/py/../extmod/utime_mphal.c" 2 +# 1 "user/mpy/py/../extmod/uos_dupterm.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../extmod/uos_dupterm.c" +# 27 "user/mpy/py/../extmod/uos_dupterm.c" +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 10 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 + + + + + + +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/string.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 28 "user/mpy/py/../extmod/uos_dupterm.c" 2 +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 29 "user/mpy/py/../extmod/uos_dupterm.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 31 "user/mpy/py/../extmod/uos_dupterm.c" 2 +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 32 "user/mpy/py/../extmod/uos_dupterm.c" 2 + +# 1 "user/mpy/py/objarray.h" 1 +# 32 "user/mpy/py/objarray.h" +typedef struct _mp_obj_array_t { + mp_obj_base_t base; + size_t typecode : 8; + + + size_t free : (8 * sizeof(size_t) - 8); + size_t len; + void *items; +} mp_obj_array_t; +# 34 "user/mpy/py/../extmod/uos_dupterm.c" 2 +# 1 "user/mpy/py/stream.h" 1 +# 30 "user/mpy/py/stream.h" +# 1 "user/mpy/py/mperrno.h" 1 +# 89 "user/mpy/py/mperrno.h" +# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 + + + + + +# 5 "/usr/arm-none-eabi/include/errno.h" 3 +typedef int error_t; + + + +# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 +# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 +extern int *__errno (void); + + + + +extern const char * const _sys_errlist[]; +extern int _sys_nerr; +# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 +# 90 "user/mpy/py/mperrno.h" 2 +# 31 "user/mpy/py/stream.h" 2 +# 52 "user/mpy/py/stream.h" + +# 52 "user/mpy/py/stream.h" +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; +extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; +extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; + + + + + + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + + + + + +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); + + + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); +# 35 "user/mpy/py/../extmod/uos_dupterm.c" 2 +# 1 "user/mpy/py/../lib/embed/abort_.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../lib/embed/abort_.c" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 29 "user/mpy/py/mpstate.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 30 "user/mpy/py/mpstate.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 32 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 34 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 +# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + + + + +# 38 "user/mpy/py/nlr.h" +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 35 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/obj.h" 1 +# 31 "user/mpy/py/obj.h" +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 2 "user/mpy/py/../lib/embed/abort_.c" 2 + +__attribute__((noreturn)) void abort_(void); + +__attribute__((noreturn)) void abort_(void) { + nlr_jump(((void*)mp_obj_new_exception_msg(&mp_type_RuntimeError, "abort() called"))); +} +# 1 "user/mpy/py/../lib/utils/printf.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/../lib/utils/printf.c" +# 27 "user/mpy/py/../lib/utils/printf.c" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "user/mpy/py/../lib/utils/printf.c" 2 + + + + +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 12 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 13 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 33 "user/mpy/py/../lib/utils/printf.c" 2 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __gnuc_va_list va_list; +# 34 "user/mpy/py/../lib/utils/printf.c" 2 + +# 1 "user/mpy/py/obj.h" 1 +# 30 "user/mpy/py/obj.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + + +# 37 "user/mpy/py/misc.h" +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 191 "user/mpy/py/misc.h" +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); + + + +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/qstr.h" 1 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 32 "user/mpy/py/obj.h" 2 +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 36 "user/mpy/py/../lib/utils/printf.c" 2 +# 1 "user/mpy/py/mphal.h" 1 +# 34 "user/mpy/py/mphal.h" +# 1 "user/mpy/mphalport.h" 1 +# 35 "user/mpy/py/mphal.h" 2 + + + +int mp_hal_stdin_rx_chr(void); + + + + + + + +void mp_hal_stdout_tx_strn(const char *str, size_t len); + + + + + + + +void mp_hal_delay_ms(mp_uint_t ms); + + + +void mp_hal_delay_us(mp_uint_t us); + + + + + + + +mp_uint_t mp_hal_ticks_us(void); + + + +mp_uint_t mp_hal_ticks_cpu(void); +# 80 "user/mpy/py/mphal.h" +# 1 "user/mpy/extmod/virtpin.h" 1 +# 37 "user/mpy/extmod/virtpin.h" +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + + +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +# 81 "user/mpy/py/mphal.h" 2 +# 37 "user/mpy/py/../lib/utils/printf.c" 2 + + + + + + +int printf(const char *fmt, ...); +int vprintf(const char *fmt, va_list ap); +int putchar(int c); +int puts(const char *s); +int vsnprintf(char *str, size_t size, const char *fmt, va_list ap); +int snprintf(char *str, size_t size, const char *fmt, ...); + +int printf(const char *fmt, ...) { + va_list ap; + +# 52 "user/mpy/py/../lib/utils/printf.c" 3 4 + __builtin_va_start( +# 52 "user/mpy/py/../lib/utils/printf.c" + ap +# 52 "user/mpy/py/../lib/utils/printf.c" 3 4 + , +# 52 "user/mpy/py/../lib/utils/printf.c" + fmt +# 52 "user/mpy/py/../lib/utils/printf.c" 3 4 + ) +# 52 "user/mpy/py/../lib/utils/printf.c" + ; + int ret = mp_vprintf(&mp_plat_print, fmt, ap); + +# 54 "user/mpy/py/../lib/utils/printf.c" 3 4 + __builtin_va_end( +# 54 "user/mpy/py/../lib/utils/printf.c" + ap +# 54 "user/mpy/py/../lib/utils/printf.c" 3 4 + ) +# 54 "user/mpy/py/../lib/utils/printf.c" + ; + return ret; +} + +int vprintf(const char *fmt, va_list ap) { + return mp_vprintf(&mp_plat_print, fmt, ap); +} +# 77 "user/mpy/py/../lib/utils/printf.c" +int putchar(int c) { + char chr = c; + printk(&chr);; + return chr; +} + + +int puts(const char *s) { + printk(s);; + char chr = '\n'; + printk(&chr);; + return 1; +} + +typedef struct _strn_print_env_t { + char *cur; + size_t remain; +} strn_print_env_t; + +static void strn_print_strn(void *data, const char *str, size_t len) { + strn_print_env_t *strn_print_env = data; + if (len > strn_print_env->remain) { + len = strn_print_env->remain; + } + memcpy(strn_print_env->cur, str, len); + strn_print_env->cur += len; + strn_print_env->remain -= len; +} + + + + +int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias ("vsnprintf"))); + + +int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { + strn_print_env_t strn_print_env = {str, size}; + mp_print_t print = {&strn_print_env, strn_print_strn}; + int len = mp_vprintf(&print, fmt, ap); + + if (size > 0) { + if (strn_print_env.remain == 0) { + strn_print_env.cur[-1] = 0; + } else { + strn_print_env.cur[0] = 0; + } + } + return len; +} + +int snprintf(char *str, size_t size, const char *fmt, ...) { + va_list ap; + +# 129 "user/mpy/py/../lib/utils/printf.c" 3 4 + __builtin_va_start( +# 129 "user/mpy/py/../lib/utils/printf.c" + ap +# 129 "user/mpy/py/../lib/utils/printf.c" 3 4 + , +# 129 "user/mpy/py/../lib/utils/printf.c" + fmt +# 129 "user/mpy/py/../lib/utils/printf.c" 3 4 + ) +# 129 "user/mpy/py/../lib/utils/printf.c" + ; + int ret = vsnprintf(str, size, fmt, ap); + +# 131 "user/mpy/py/../lib/utils/printf.c" 3 4 + __builtin_va_end( +# 131 "user/mpy/py/../lib/utils/printf.c" + ap +# 131 "user/mpy/py/../lib/utils/printf.c" 3 4 + ) +# 131 "user/mpy/py/../lib/utils/printf.c" + ; + return ret; +} +# 1 "user/mpy/py/emitnative.c" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "user/mpy/py/emitnative.c" +# 45 "user/mpy/py/emitnative.c" +# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 +# 29 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 14 "/usr/arm-none-eabi/include/newlib.h" 3 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 +# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 +# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + + +# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 +# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 +# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 60 "/usr/arm-none-eabi/include/stdio.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + +typedef __builtin_va_list __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 +# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __uint8_t u_int8_t; + + +typedef __uint16_t u_int16_t; + + +typedef __uint32_t u_int32_t; + + +typedef __uint64_t u_int64_t; + +typedef int register_t; +# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 + +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __blkcnt_t blkcnt_t; + + + + +typedef __blksize_t blksize_t; + + + + +typedef unsigned long clock_t; + + + + + +typedef long time_t; + + + + + +typedef long daddr_t; + + + +typedef char * caddr_t; + + + + +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; + + + + +typedef __id_t id_t; + + + + +typedef __ino_t ino_t; +# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 +typedef __off_t off_t; + + + +typedef __dev_t dev_t; + + + +typedef __uid_t uid_t; + + + +typedef __gid_t gid_t; + + + + +typedef __pid_t pid_t; + + + + +typedef __key_t key_t; + + + + +typedef _ssize_t ssize_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __clockid_t clockid_t; + + + + + +typedef __timer_t timer_t; + + + + + +typedef __useconds_t useconds_t; + + + + +typedef __suseconds_t suseconds_t; + + + +typedef __int64_t sbintime_t; + + +# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 +# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 +# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 +# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 +struct sched_param { + int sched_priority; +# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 +}; +# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 +# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_t; +# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef struct { + int is_initialized; + void *stackaddr; + int stacksize; + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + + + + + + int detachstate; +} pthread_attr_t; +# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 +typedef __uint32_t pthread_mutex_t; + +typedef struct { + int is_initialized; +# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 + int recursive; +} pthread_mutexattr_t; + + + + + + +typedef __uint32_t pthread_cond_t; + + + +typedef struct { + int is_initialized; + clock_t clock; + + + +} pthread_condattr_t; + + + +typedef __uint32_t pthread_key_t; + +typedef struct { + int is_initialized; + int init_executed; +} pthread_once_t; +# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 +# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 +# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 + + + + +typedef __FILE FILE; + + + + + + +typedef _fpos_t fpos_t; + + + + + +# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 +# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 +# 186 "/usr/arm-none-eabi/include/stdio.h" 3 +FILE * tmpfile (void); +char * tmpnam (char *); + + + +int fclose (FILE *); +int fflush (FILE *); +FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); +void setbuf (FILE *restrict, char *restrict); +int setvbuf (FILE *restrict, char *restrict, int, size_t); +int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) + ; +int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) + ; +int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) + ; +int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int fgetc (FILE *); +char * fgets (char *restrict, int, FILE *restrict); +int fputc (int, FILE *); +int fputs (const char *restrict, FILE *restrict); +int getc (FILE *); +int getchar (void); +char * gets (char *); +int putc (int, FILE *); +int putchar (int); +int puts (const char *); +int ungetc (int, FILE *); +size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); + + + +int fgetpos (FILE *restrict, fpos_t *restrict); + +int fseek (FILE *, long, int); + + + +int fsetpos (FILE *, const fpos_t *); + +long ftell ( FILE *); +void rewind (FILE *); +void clearerr (FILE *); +int feof (FILE *); +int ferror (FILE *); +void perror (const char *); + +FILE * fopen (const char *restrict _name, const char *restrict _type); +int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int remove (const char *); +int rename (const char *, const char *); +# 266 "/usr/arm-none-eabi/include/stdio.h" 3 +int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) + ; +int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +# 393 "/usr/arm-none-eabi/include/stdio.h" 3 +int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fclose_r (struct _reent *, FILE *); +int _fcloseall_r (struct _reent *); +FILE * _fdopen_r (struct _reent *, int, const char *); +int _fflush_r (struct _reent *, FILE *); +int _fgetc_r (struct _reent *, FILE *); +int _fgetc_unlocked_r (struct _reent *, FILE *); +char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); +char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); + + + + +int _fgetpos_r (struct _reent *, FILE *, fpos_t *); +int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); + +int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); +FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); +FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); +int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _fpurge_r (struct _reent *, FILE *); +int _fputc_r (struct _reent *, int, FILE *); +int _fputc_unlocked_r (struct _reent *, int, FILE *); +int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); +int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); +size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); +int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _fseek_r (struct _reent *, FILE *, long, int); +int _fseeko_r (struct _reent *, FILE *, _off_t, int); +long _ftell_r (struct _reent *, FILE *); +_off_t _ftello_r (struct _reent *, FILE *); +void _rewind_r (struct _reent *, FILE *); +size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); +int _getc_r (struct _reent *, FILE *); +int _getc_unlocked_r (struct _reent *, FILE *); +int _getchar_r (struct _reent *); +int _getchar_unlocked_r (struct _reent *); +char * _gets_r (struct _reent *, char *); +int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +FILE * _open_memstream_r (struct _reent *, char **, size_t *); +void _perror_r (struct _reent *, const char *); +int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) + ; +int _putc_r (struct _reent *, int, FILE *); +int _putc_unlocked_r (struct _reent *, int, FILE *); +int _putchar_unlocked_r (struct _reent *, int); +int _putchar_r (struct _reent *, int); +int _puts_r (struct _reent *, const char *); +int _remove_r (struct _reent *, const char *); +int _rename_r (struct _reent *, const char *_old, const char *_new) + ; +int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) + ; +int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) + ; +int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) + ; +int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) + ; +char * _tempnam_r (struct _reent *, const char *, const char *); +FILE * _tmpfile_r (struct _reent *); +char * _tmpnam_r (struct _reent *, char *); +int _ungetc_r (struct _reent *, int, FILE *); +int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) + ; +int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) + ; +int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; +int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) + ; +int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) + ; +int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) + ; + + + +int fpurge (FILE *); +ssize_t __getdelim (char **, size_t *, int, FILE *); +ssize_t __getline (char **, size_t *, FILE *); +# 574 "/usr/arm-none-eabi/include/stdio.h" 3 +int __srget_r (struct _reent *, FILE *); +int __swbuf_r (struct _reent *, int, FILE *); +# 684 "/usr/arm-none-eabi/include/stdio.h" 3 +static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { + + + + + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf_r(_ptr, _c, _p)); +} +# 767 "/usr/arm-none-eabi/include/stdio.h" 3 + +# 46 "user/mpy/py/emitnative.c" 2 +# 1 "/usr/arm-none-eabi/include/string.h" 1 3 +# 17 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 18 "/usr/arm-none-eabi/include/string.h" 2 3 + + + + + + + +void * memchr (const void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void * memcpy (void * restrict, const void * restrict, size_t); +void * memmove (void *, const void *, size_t); +void * memset (void *, int, size_t); +char *strcat (char *restrict, const char *restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strcoll (const char *, const char *); +char *strcpy (char *restrict, const char *restrict); +size_t strcspn (const char *, const char *); +char *strerror (int); +size_t strlen (const char *); +char *strncat (char *restrict, const char *restrict, size_t); +int strncmp (const char *, const char *, size_t); +char *strncpy (char *restrict, const char *restrict, size_t); +char *strpbrk (const char *, const char *); +char *strrchr (const char *, int); +size_t strspn (const char *, const char *); +char *strstr (const char *, const char *); + +char *strtok (char *restrict, const char *restrict); + +size_t strxfrm (char *restrict, const char *restrict, size_t); +# 102 "/usr/arm-none-eabi/include/string.h" 3 +char *_strdup_r (struct _reent *, const char *); + + + +char *_strndup_r (struct _reent *, const char *, size_t); +# 133 "/usr/arm-none-eabi/include/string.h" 3 +char * _strerror_r (struct _reent *, int, int, int *); +# 155 "/usr/arm-none-eabi/include/string.h" 3 +char *strsignal (int __signo); +# 192 "/usr/arm-none-eabi/include/string.h" 3 +# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 +# 193 "/usr/arm-none-eabi/include/string.h" 2 3 + + +# 47 "user/mpy/py/emitnative.c" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 48 "user/mpy/py/emitnative.c" 2 + +# 1 "user/mpy/py/nlr.h" 1 +# 32 "user/mpy/py/nlr.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 + + + + + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 +# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 +# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 +# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 +# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 +# 33 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 +# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 + + +# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 +typedef int jmp_buf[23]; + + + + +# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 + + + + +void longjmp (jmp_buf __jmpb, int __retval) + __attribute__ ((__noreturn__)); + + + +int setjmp (jmp_buf __jmpb); + + +# 34 "user/mpy/py/nlr.h" 2 +# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 +# 39 "/usr/arm-none-eabi/include/assert.h" 3 +void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) + ; +void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) + ; +# 35 "user/mpy/py/nlr.h" 2 + +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 37 "user/mpy/py/nlr.h" 2 + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + + nlr_buf_t *prev; + void *ret_val; +# 53 "user/mpy/py/nlr.h" + void *regs[10]; +# 65 "user/mpy/py/nlr.h" +}; +# 77 "user/mpy/py/nlr.h" +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +__attribute__((noreturn)) void nlr_jump(void *val); + + + + + +__attribute__((noreturn)) void nlr_jump_fail(void *val); +# 50 "user/mpy/py/emitnative.c" 2 +# 1 "user/mpy/py/emit.h" 1 +# 29 "user/mpy/py/emit.h" +# 1 "user/mpy/py/lexer.h" 1 +# 32 "user/mpy/py/lexer.h" +# 1 "user/mpy/py/qstr.h" 1 +# 30 "user/mpy/py/qstr.h" +# 1 "user/mpy/py/misc.h" 1 +# 33 "user/mpy/py/misc.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 +# 34 "user/mpy/py/misc.h" 2 + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 36 "user/mpy/py/misc.h" 2 + +typedef unsigned char byte; +typedef unsigned int uint; +# 82 "user/mpy/py/misc.h" +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); + + + + + +void *m_realloc(void *ptr, size_t new_num_bytes); +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, +# 92 "user/mpy/py/misc.h" 3 4 + _Bool +# 92 "user/mpy/py/misc.h" + allow_move); +void m_free(void *ptr); + +__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); +# 119 "user/mpy/py/misc.h" +typedef uint unichar; + + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + + +# 125 "user/mpy/py/misc.h" 3 4 +_Bool +# 125 "user/mpy/py/misc.h" + unichar_isspace(unichar c); + +# 126 "user/mpy/py/misc.h" 3 4 +_Bool +# 126 "user/mpy/py/misc.h" + unichar_isalpha(unichar c); + +# 127 "user/mpy/py/misc.h" 3 4 +_Bool +# 127 "user/mpy/py/misc.h" + unichar_isprint(unichar c); + +# 128 "user/mpy/py/misc.h" 3 4 +_Bool +# 128 "user/mpy/py/misc.h" + unichar_isdigit(unichar c); + +# 129 "user/mpy/py/misc.h" 3 4 +_Bool +# 129 "user/mpy/py/misc.h" + unichar_isxdigit(unichar c); + +# 130 "user/mpy/py/misc.h" 3 4 +_Bool +# 130 "user/mpy/py/misc.h" + unichar_isident(unichar c); + +# 131 "user/mpy/py/misc.h" 3 4 +_Bool +# 131 "user/mpy/py/misc.h" + unichar_isupper(unichar c); + +# 132 "user/mpy/py/misc.h" 3 4 +_Bool +# 132 "user/mpy/py/misc.h" + unichar_islower(unichar c); +unichar unichar_tolower(unichar c); +unichar unichar_toupper(unichar c); +mp_uint_t unichar_xdigit_value(unichar c); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); + + + + + +typedef struct _vstr_t { + size_t alloc; + size_t len; + char *buf; + +# 146 "user/mpy/py/misc.h" 3 4 + _Bool +# 146 "user/mpy/py/misc.h" + fixed_buf : 1; +} vstr_t; + + + + +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, ...); +# 195 "user/mpy/py/misc.h" +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + + + + + + +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +# 31 "user/mpy/py/qstr.h" 2 +# 39 "user/mpy/py/qstr.h" +enum { + + + + + + MP_QSTRnumber_of, +}; + +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; + + + +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); + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); +# 33 "user/mpy/py/lexer.h" 2 +# 1 "user/mpy/py/reader.h" 1 +# 29 "user/mpy/py/reader.h" +# 1 "user/mpy/py/obj.h" 1 +# 32 "user/mpy/py/obj.h" +# 1 "user/mpy/py/mpprint.h" 1 +# 48 "user/mpy/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; + + + +extern const mp_print_t mp_plat_print; + + + + + +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); + + + + +int mp_printf(const mp_print_t *print, const char *fmt, ...); +# 33 "user/mpy/py/obj.h" 2 +# 41 "user/mpy/py/obj.h" +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; + + + + +typedef struct _mp_obj_type_t mp_obj_type_t; + + + +struct _mp_obj_base_t { + const mp_obj_type_t *type ; +}; +typedef struct _mp_obj_base_t mp_obj_base_t; +# 83 "user/mpy/py/obj.h" +static inline +# 83 "user/mpy/py/obj.h" 3 4 + _Bool +# 83 "user/mpy/py/obj.h" + MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) != 0); } + + + +static inline +# 88 "user/mpy/py/obj.h" 3 4 + _Bool +# 88 "user/mpy/py/obj.h" + MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 2); } +# 104 "user/mpy/py/obj.h" +static inline +# 104 "user/mpy/py/obj.h" 3 4 + _Bool +# 104 "user/mpy/py/obj.h" + MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } +# 238 "user/mpy/py/obj.h" +typedef mp_const_obj_t mp_rom_obj_t; +# 264 "user/mpy/py/obj.h" +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline +# 266 "user/mpy/py/obj.h" 3 4 + _Bool +# 266 "user/mpy/py/obj.h" + mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } +# 340 "user/mpy/py/obj.h" +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; + size_t is_ordered : 1; + size_t used : (8 * sizeof(size_t) - 3); + size_t alloc; + mp_map_elem_t *table; +} mp_map_t; + + +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, +} mp_map_lookup_kind_t; + +extern const mp_map_t mp_const_empty_map; + +static inline +# 374 "user/mpy/py/obj.h" 3 4 + _Bool +# 374 "user/mpy/py/obj.h" + MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } + +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); + + + +typedef struct _mp_set_t { + size_t alloc; + size_t used; + mp_obj_t *table; +} mp_set_t; + +static inline +# 393 "user/mpy/py/obj.h" 3 4 + _Bool +# 393 "user/mpy/py/obj.h" + MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } + +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); + + + +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 *); + + +typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); + +typedef enum { + PRINT_STR = 0, + PRINT_REPR = 1, + PRINT_EXC = 2, + PRINT_JSON = 3, + PRINT_RAW = 4, + PRINT_EXC_SUBCLASS = 0x80, +} 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; + + + + + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); + + +typedef struct _mp_buffer_info_t { + + + + + + void *buf; + size_t len; + int typecode; + + + + +} mp_buffer_info_t; + + + +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; + +# 459 "user/mpy/py/obj.h" 3 4 +_Bool +# 459 "user/mpy/py/obj.h" + 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); + + +typedef struct _mp_stream_p_t { + + + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; +} mp_stream_p_t; + +struct _mp_obj_type_t { + + mp_obj_base_t base; + + + qstr name; + + + mp_print_fun_t print; + + + mp_make_new_fun_t make_new; + + + mp_call_fun_t call; + + + + mp_unary_op_fun_t unary_op; + mp_binary_op_fun_t binary_op; +# 504 "user/mpy/py/obj.h" + mp_attr_fun_t attr; + + + + + + + mp_subscr_fun_t subscr; + + + + + mp_getiter_fun_t getiter; + + + + mp_fun_1_t iternext; + + + mp_buffer_p_t buffer_p; + + + const void *protocol; + + + + + + const void *parent; + + + struct _mp_obj_dict_t *locals_dict; +}; + + +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; +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_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_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; + + +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_TimeoutError; +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; +# 618 "user/mpy/py/obj.h" +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + + + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } +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, +# 636 "user/mpy/py/obj.h" 3 4 + _Bool +# 636 "user/mpy/py/obj.h" + neg, unsigned int base); +mp_obj_t mp_obj_new_int_from_ll(long long val); +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); +mp_obj_t mp_obj_new_str(const char* data, size_t len, +# 639 "user/mpy/py/obj.h" 3 4 + _Bool +# 639 "user/mpy/py/obj.h" + make_qstr_if_not_already); +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); + + + + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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); + +# 671 "user/mpy/py/obj.h" 3 4 +_Bool +# 671 "user/mpy/py/obj.h" + mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); +mp_obj_t mp_instance_cast_to_native_base(mp_const_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); + + +# 678 "user/mpy/py/obj.h" 3 4 +_Bool +# 678 "user/mpy/py/obj.h" + mp_obj_is_true(mp_obj_t arg); + +# 679 "user/mpy/py/obj.h" 3 4 +_Bool +# 679 "user/mpy/py/obj.h" + mp_obj_is_callable(mp_obj_t o_in); + +# 680 "user/mpy/py/obj.h" 3 4 +_Bool +# 680 "user/mpy/py/obj.h" + mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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); + +# 684 "user/mpy/py/obj.h" 3 4 +_Bool +# 684 "user/mpy/py/obj.h" + mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); + + + + + +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, +# 692 "user/mpy/py/obj.h" 3 4 + _Bool +# 692 "user/mpy/py/obj.h" + 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); +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_uint_t op, mp_obj_t o_in); + + +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); + + + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); + + + + +# 711 "user/mpy/py/obj.h" 3 4 +_Bool +# 711 "user/mpy/py/obj.h" + mp_obj_is_exception_type(mp_obj_t self_in); + +# 712 "user/mpy/py/obj.h" 3 4 +_Bool +# 712 "user/mpy/py/obj.h" + mp_obj_is_exception_instance(mp_obj_t self_in); + +# 713 "user/mpy/py/obj.h" 3 4 +_Bool +# 713 "user/mpy/py/obj.h" + 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); + + + +# 723 "user/mpy/py/obj.h" 3 4 +_Bool +# 723 "user/mpy/py/obj.h" + mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); +qstr mp_obj_str_get_qstr(mp_obj_t self_in); +const char *mp_obj_str_get_str(mp_obj_t self_in); +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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, +# 728 "user/mpy/py/obj.h" 3 4 + _Bool +# 728 "user/mpy/py/obj.h" + is_bytes); +# 747 "user/mpy/py/obj.h" +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); + + +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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); + + +typedef struct _mp_obj_dict_t { + mp_obj_base_t base; + mp_map_t map; +} mp_obj_dict_t; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + + + +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; + +# 794 "user/mpy/py/obj.h" 3 4 + _Bool +# 794 "user/mpy/py/obj.h" + is_kw : 1; + mp_uint_t n_args_min : 15; + mp_uint_t n_args_max : 16; + 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); +extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); + + +typedef struct _mp_obj_module_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; +} mp_obj_module_t; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); + + +# 817 "user/mpy/py/obj.h" 3 4 +_Bool +# 817 "user/mpy/py/obj.h" + mp_obj_is_package(mp_obj_t module); + + + +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; + + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); + + + + +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); + + + + + + +# 848 "user/mpy/py/obj.h" 3 4 +_Bool +# 848 "user/mpy/py/obj.h" + mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); + +# 849 "user/mpy/py/obj.h" 3 4 +_Bool +# 849 "user/mpy/py/obj.h" + 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); +# 30 "user/mpy/py/reader.h" 2 + + + + + + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, +# 44 "user/mpy/py/reader.h" 3 4 + _Bool +# 44 "user/mpy/py/reader.h" + close_fd); +# 34 "user/mpy/py/lexer.h" 2 + + + + + + + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + + + + + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + + + +typedef struct _mp_lexer_t { + qstr source_name; + mp_reader_t reader; + + unichar chr0, chr1, chr2; + + size_t line; + size_t column; + + mp_int_t emit_dent; + mp_int_t nested_bracket_level; + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; + size_t tok_column; + mp_token_kind_t tok_kind; + vstr_t vstr; +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + + + + + + + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); +# 30 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/scope.h" 1 +# 29 "user/mpy/py/scope.h" +# 1 "user/mpy/py/parse.h" 1 +# 29 "user/mpy/py/parse.h" +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 30 "user/mpy/py/parse.h" 2 + + + + +struct _mp_lexer_t; +# 52 "user/mpy/py/parse.h" +typedef uintptr_t mp_parse_node_t; + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; + uint32_t kind_num_nodes; + mp_parse_node_t nodes[]; +} mp_parse_node_struct_t; +# 79 "user/mpy/py/parse.h" +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} + +# 85 "user/mpy/py/parse.h" 3 4 +_Bool +# 85 "user/mpy/py/parse.h" + mp_parse_node_is_const_false(mp_parse_node_t pn); + +# 86 "user/mpy/py/parse.h" 3 4 +_Bool +# 86 "user/mpy/py/parse.h" + mp_parse_node_is_const_true(mp_parse_node_t pn); + +# 87 "user/mpy/py/parse.h" 3 4 +_Bool +# 87 "user/mpy/py/parse.h" + mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + + + +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); +# 30 "user/mpy/py/scope.h" 2 +# 1 "user/mpy/py/emitglue.h" 1 +# 33 "user/mpy/py/emitglue.h" +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + + + + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); +# 31 "user/mpy/py/scope.h" 2 + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, + ID_INFO_KIND_CELL, + ID_INFO_KIND_FREE, +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + + + uint16_t local_num; + qstr qst; +} id_info_t; + + + + +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; + uint16_t simple_name; + mp_raw_code_t *raw_code; + uint8_t scope_flags; + uint8_t emit_options; + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; + uint16_t exc_stack_size; + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, +# 92 "user/mpy/py/scope.h" 3 4 + _Bool +# 92 "user/mpy/py/scope.h" + *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); +# 31 "user/mpy/py/emit.h" 2 +# 1 "user/mpy/py/runtime0.h" 1 +# 45 "user/mpy/py/runtime0.h" +typedef enum { + MP_UNARY_OP_BOOL, + MP_UNARY_OP_LEN, + MP_UNARY_OP_HASH, + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + + 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, + + MP_BINARY_OP_NOT_IN, + MP_BINARY_OP_IS_NOT, +} mp_binary_op_t; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, + + + + + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, + + + + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; +# 32 "user/mpy/py/emit.h" 2 +# 43 "user/mpy/py/emit.h" +typedef enum { + MP_PASS_SCOPE = 1, + MP_PASS_STACK_SIZE = 2, + MP_PASS_CODE_SIZE = 3, + MP_PASS_EMIT = 4, +} pass_kind_t; +# 59 "user/mpy/py/emit.h" +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + +# 72 "user/mpy/py/emit.h" 3 4 + _Bool +# 72 "user/mpy/py/emit.h" + (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, +# 90 "user/mpy/py/emit.h" 3 4 + _Bool +# 90 "user/mpy/py/emit.h" + is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, +# 103 "user/mpy/py/emit.h" 3 4 + _Bool +# 103 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, +# 104 "user/mpy/py/emit.h" 3 4 + _Bool +# 104 "user/mpy/py/emit.h" + cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, +# 112 "user/mpy/py/emit.h" 3 4 + _Bool +# 112 "user/mpy/py/emit.h" + use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + + + + + + + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + + + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); + +# 180 "user/mpy/py/emit.h" 3 4 +_Bool +# 180 "user/mpy/py/emit.h" + mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, +# 207 "user/mpy/py/emit.h" 3 4 + _Bool +# 207 "user/mpy/py/emit.h" + is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, +# 220 "user/mpy/py/emit.h" 3 4 + _Bool +# 220 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, +# 221 "user/mpy/py/emit.h" 3 4 + _Bool +# 221 "user/mpy/py/emit.h" + cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, +# 230 "user/mpy/py/emit.h" 3 4 + _Bool +# 230 "user/mpy/py/emit.h" + use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); + + + + + + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + +# 267 "user/mpy/py/emit.h" 3 4 + _Bool +# 267 "user/mpy/py/emit.h" + (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); +# 51 "user/mpy/py/emitnative.c" 2 +# 1 "user/mpy/py/bc.h" 1 +# 29 "user/mpy/py/bc.h" +# 1 "user/mpy/py/runtime.h" 1 +# 29 "user/mpy/py/runtime.h" +# 1 "user/mpy/py/mpstate.h" 1 +# 32 "user/mpy/py/mpstate.h" +# 1 "user/mpy/py/mpthread.h" 1 +# 33 "user/mpy/py/mpstate.h" 2 + + + +# 1 "user/mpy/py/objlist.h" 1 +# 31 "user/mpy/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; +# 37 "user/mpy/py/mpstate.h" 2 +# 1 "user/mpy/py/objexcept.h" 1 +# 30 "user/mpy/py/objexcept.h" +# 1 "user/mpy/py/objtuple.h" 1 +# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; +# 62 "user/mpy/py/objtuple.h" +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); +# 31 "user/mpy/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; +# 38 "user/mpy/py/mpstate.h" 2 +# 58 "user/mpy/py/mpstate.h" +typedef struct _mp_sched_item_t { + mp_obj_t func; + mp_obj_t arg; +} mp_sched_item_t; + + +typedef struct _mp_state_mem_t { + + + + + + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + + + + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[(64)]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + + + + uint16_t gc_auto_collect_enabled; + + + + + + + size_t gc_last_free_atb_index; +# 104 "user/mpy/py/mpstate.h" +} mp_state_mem_t; + + + +typedef struct _mp_state_vm_t { + + + + + + + qstr_pool_t *last_pool; + + + mp_obj_exception_t mp_emergency_exception_obj; +# 137 "user/mpy/py/mpstate.h" + mp_obj_dict_t mp_loaded_modules_dict; + + + volatile mp_obj_t mp_pending_exception; +# 154 "user/mpy/py/mpstate.h" + mp_obj_dict_t dict_main; + + + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + + + + + + + + const char *readline_hist[8]; +# 190 "user/mpy/py/mpstate.h" + byte *qstr_last_chunk; + size_t qstr_last_alloc; + size_t qstr_last_used; + + + + + + + mp_uint_t mp_optimise_value; +# 210 "user/mpy/py/mpstate.h" +} mp_state_vm_t; + + + +typedef struct _mp_state_thread_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + + nlr_buf_t *nlr_top; + + + char *stack_top; + + + + +} mp_state_thread_t; + + + + + +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; +# 30 "user/mpy/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 { + +# 48 "user/mpy/py/runtime.h" 3 4 + _Bool +# 48 "user/mpy/py/runtime.h" + 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; + + +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); +# 78 "user/mpy/py/runtime.h" +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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, +# 80 "user/mpy/py/runtime.h" 3 4 + _Bool +# 80 "user/mpy/py/runtime.h" + 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); +__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); +__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); + +static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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( +# 107 "user/mpy/py/runtime.h" 3 4 + _Bool +# 107 "user/mpy/py/runtime.h" + 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); + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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; +# 127 "user/mpy/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_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); +mp_obj_t mp_iternext(mp_obj_t o); +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); + +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); + +__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); + +__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); +__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); +__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); +__attribute__((noreturn)) void mp_raise_OSError(int errno_); +__attribute__((noreturn)) void mp_exc_recursion_depth(void); +# 167 "user/mpy/py/runtime.h" +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); +# 30 "user/mpy/py/bc.h" 2 + +# 1 "user/mpy/py/objfun.h" 1 +# 31 "user/mpy/py/objfun.h" +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + const byte *bytecode; + const mp_uint_t *const_table; + + + + + + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; +# 32 "user/mpy/py/bc.h" 2 +# 64 "user/mpy/py/bc.h" +typedef struct _mp_exc_stack_t { + const byte *handler; + + + mp_obj_t *val_sp; + + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + + + + + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + + + + + mp_obj_t state[0]; + + +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +# 52 "user/mpy/py/emitnative.c" 2 diff --git a/user/mpy/build/genhdr/qstr.split b/user/mpy/build/genhdr/qstr.split new file mode 100644 index 0000000..e69de29 diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr new file mode 100644 index 0000000..18a2b0b --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr @@ -0,0 +1 @@ +Q(_lt_string_gt_) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr new file mode 100644 index 0000000..9f4b09f --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr @@ -0,0 +1,6 @@ +Q(__path__) +Q(__name__) +Q(__path__) +Q(__name__) +Q(__main__) +Q(__path__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr new file mode 100644 index 0000000..6d5f3c7 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr @@ -0,0 +1,15 @@ +Q(micropython) +Q(bytecode) +Q(_star_) +Q(AssertionError) +Q(range) +Q(__repl_print__) +Q(super) +Q(__class__) +Q(__class__) +Q(__name__) +Q(__module__) +Q(__qualname__) +Q(__class__) +Q(__class__) +Q(__class__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr new file mode 100644 index 0000000..0a6805e --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr @@ -0,0 +1 @@ +Q(_star_) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr new file mode 100644 index 0000000..38b4956 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr @@ -0,0 +1,83 @@ +Q(_brace_open__colon__hash_b_brace_close_) +Q(_percent__hash_x) +Q(_percent__hash_o) +Q(sep) +Q(end) +Q(__name__) +Q(builtins) +Q(__build_class__) +Q(__import__) +Q(__repl_print__) +Q(bool) +Q(bytes) +Q(dict) +Q(int) +Q(list) +Q(map) +Q(object) +Q(range) +Q(str) +Q(super) +Q(tuple) +Q(type) +Q(zip) +Q(classmethod) +Q(staticmethod) +Q(Ellipsis) +Q(abs) +Q(all) +Q(any) +Q(bin) +Q(callable) +Q(chr) +Q(dir) +Q(divmod) +Q(eval) +Q(exec) +Q(getattr) +Q(setattr) +Q(globals) +Q(hasattr) +Q(hash) +Q(hex) +Q(id) +Q(isinstance) +Q(issubclass) +Q(iter) +Q(len) +Q(locals) +Q(next) +Q(oct) +Q(ord) +Q(pow) +Q(print) +Q(repr) +Q(round) +Q(sorted) +Q(sum) +Q(BaseException) +Q(ArithmeticError) +Q(AssertionError) +Q(AttributeError) +Q(EOFError) +Q(Exception) +Q(GeneratorExit) +Q(ImportError) +Q(IndentationError) +Q(IndexError) +Q(KeyboardInterrupt) +Q(KeyError) +Q(LookupError) +Q(MemoryError) +Q(NameError) +Q(NotImplementedError) +Q(OSError) +Q(OverflowError) +Q(RuntimeError) +Q(StopIteration) +Q(SyntaxError) +Q(SystemExit) +Q(TypeError) +Q(ValueError) +Q(ZeroDivisionError) +Q(open) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr new file mode 100644 index 0000000..a39383a --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr @@ -0,0 +1,6 @@ +Q(__name__) +Q(micropython) +Q(const) +Q(opt_level) +Q(heap_lock) +Q(heap_unlock) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr new file mode 100644 index 0000000..b293a1a --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr @@ -0,0 +1 @@ +Q(bool) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr new file mode 100644 index 0000000..7ef4862 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr @@ -0,0 +1 @@ +Q(bound_method) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr new file mode 100644 index 0000000..60ff1c1 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr @@ -0,0 +1 @@ +Q(closure) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr new file mode 100644 index 0000000..acc0b3a --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr @@ -0,0 +1,17 @@ +Q(iterator) +Q(dict_view) +Q(clear) +Q(copy) +Q(fromkeys) +Q(get) +Q(items) +Q(keys) +Q(pop) +Q(popitem) +Q(setdefault) +Q(update) +Q(values) +Q(__getitem__) +Q(__setitem__) +Q(__delitem__) +Q(dict) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr new file mode 100644 index 0000000..42b1066 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr @@ -0,0 +1,29 @@ +Q(__traceback__) +Q(args) +Q(value) +Q(__init__) +Q(BaseException) +Q(SystemExit) +Q(KeyboardInterrupt) +Q(GeneratorExit) +Q(Exception) +Q(StopIteration) +Q(ArithmeticError) +Q(OverflowError) +Q(ZeroDivisionError) +Q(AssertionError) +Q(AttributeError) +Q(EOFError) +Q(ImportError) +Q(LookupError) +Q(IndexError) +Q(KeyError) +Q(MemoryError) +Q(NameError) +Q(OSError) +Q(RuntimeError) +Q(NotImplementedError) +Q(SyntaxError) +Q(IndentationError) +Q(TypeError) +Q(ValueError) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr new file mode 100644 index 0000000..0c3de3e --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr @@ -0,0 +1,6 @@ +Q(function) +Q(function) +Q(function) +Q(function) +Q(function) +Q(function) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr new file mode 100644 index 0000000..451d0ca --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr @@ -0,0 +1,5 @@ +Q(generator) +Q(close) +Q(send) +Q(throw) +Q(generator) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr new file mode 100644 index 0000000..5bd02f4 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr @@ -0,0 +1 @@ +Q(iterator) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr new file mode 100644 index 0000000..20c96a7 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr @@ -0,0 +1,5 @@ +Q(little) +Q(little) +Q(from_bytes) +Q(to_bytes) +Q(int) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr new file mode 100644 index 0000000..d1b1f6d --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr @@ -0,0 +1,14 @@ +Q(key) +Q(reverse) +Q(append) +Q(clear) +Q(copy) +Q(count) +Q(extend) +Q(index) +Q(insert) +Q(pop) +Q(remove) +Q(reverse) +Q(sort) +Q(list) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr new file mode 100644 index 0000000..90548b5 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr @@ -0,0 +1 @@ +Q(map) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr new file mode 100644 index 0000000..e4113ea --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr @@ -0,0 +1,7 @@ +Q(__name__) +Q(module) +Q(__name__) +Q(__main__) +Q(builtins) +Q(micropython) +Q(__init__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr new file mode 100644 index 0000000..8efc009 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr @@ -0,0 +1 @@ +Q(NoneType) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr new file mode 100644 index 0000000..fbeb75f --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr @@ -0,0 +1 @@ +Q(object) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr new file mode 100644 index 0000000..5bd02f4 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr @@ -0,0 +1 @@ +Q(iterator) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr new file mode 100644 index 0000000..470b232 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr @@ -0,0 +1,5 @@ +Q(iterator) +Q(start) +Q(stop) +Q(step) +Q(range) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr new file mode 100644 index 0000000..177e65a --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr @@ -0,0 +1 @@ +Q(Ellipsis) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr new file mode 100644 index 0000000..36ce57b --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr @@ -0,0 +1,27 @@ +Q(find) +Q(rfind) +Q(index) +Q(rindex) +Q(join) +Q(split) +Q(rsplit) +Q(startswith) +Q(endswith) +Q(strip) +Q(lstrip) +Q(rstrip) +Q(format) +Q(replace) +Q(count) +Q(lower) +Q(upper) +Q(isspace) +Q(isalpha) +Q(isdigit) +Q(isupper) +Q(islower) +Q(str) +Q(bytes) +Q(str) +Q(bytes) +Q(str) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr new file mode 100644 index 0000000..78c28c3 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr @@ -0,0 +1,3 @@ +Q(count) +Q(index) +Q(tuple) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr new file mode 100644 index 0000000..9929a26 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr @@ -0,0 +1,30 @@ +Q(__str__) +Q(__repr__) +Q(__repr__) +Q(__new__) +Q(__init__) +Q(__bool__) +Q(__len__) +Q(__hash__) +Q(__eq__) +Q(__add__) +Q(__sub__) +Q(__lt__) +Q(__gt__) +Q(__eq__) +Q(__le__) +Q(__ge__) +Q(__contains__) +Q(__getattr__) +Q(__getattr__) +Q(__delitem__) +Q(__getitem__) +Q(__setitem__) +Q(__call__) +Q(__iter__) +Q(type) +Q(__new__) +Q(function) +Q(super) +Q(staticmethod) +Q(classmethod) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr new file mode 100644 index 0000000..87119c4 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr @@ -0,0 +1 @@ +Q(zip) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr new file mode 100644 index 0000000..922ead4 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr @@ -0,0 +1,16 @@ +Q(__name__) +Q(__main__) +Q(keys) +Q(__getitem__) +Q(function) +Q(closure) +Q(generator) +Q(__next__) +Q(__getitem__) +Q(__next__) +Q(__next__) +Q(__next__) +Q(send) +Q(close) +Q(throw) +Q(__name__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr new file mode 100644 index 0000000..5317711 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr @@ -0,0 +1,6 @@ +Q(_lt_module_gt_) +Q(_lt_lambda_gt_) +Q(_lt_listcomp_gt_) +Q(_lt_dictcomp_gt_) +Q(_lt_setcomp_gt_) +Q(_lt_genexpr_gt_) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr new file mode 100644 index 0000000..abbac45 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr @@ -0,0 +1 @@ +Q(close) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr new file mode 100644 index 0000000..5b6ae33 --- /dev/null +++ b/user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr @@ -0,0 +1,2 @@ +Q(__exit__) +Q(__enter__) diff --git a/user/mpy/build/genhdr/qstrdefs.collected.h b/user/mpy/build/genhdr/qstrdefs.collected.h new file mode 100644 index 0000000..9727df5 --- /dev/null +++ b/user/mpy/build/genhdr/qstrdefs.collected.h @@ -0,0 +1,589 @@ +Q(ArithmeticError) + +Q(ArithmeticError) + +Q(AssertionError) + +Q(AssertionError) + +Q(AssertionError) + +Q(AttributeError) + +Q(AttributeError) + +Q(BaseException) + +Q(BaseException) + +Q(EOFError) + +Q(EOFError) + +Q(Ellipsis) + +Q(Ellipsis) + +Q(Exception) + +Q(Exception) + +Q(GeneratorExit) + +Q(GeneratorExit) + +Q(ImportError) + +Q(ImportError) + +Q(IndentationError) + +Q(IndentationError) + +Q(IndexError) + +Q(IndexError) + +Q(KeyError) + +Q(KeyError) + +Q(KeyboardInterrupt) + +Q(KeyboardInterrupt) + +Q(LookupError) + +Q(LookupError) + +Q(MemoryError) + +Q(MemoryError) + +Q(NameError) + +Q(NameError) + +Q(NoneType) + +Q(NotImplementedError) + +Q(NotImplementedError) + +Q(OSError) + +Q(OSError) + +Q(OverflowError) + +Q(OverflowError) + +Q(RuntimeError) + +Q(RuntimeError) + +Q(StopIteration) + +Q(StopIteration) + +Q(SyntaxError) + +Q(SyntaxError) + +Q(SystemExit) + +Q(SystemExit) + +Q(TypeError) + +Q(TypeError) + +Q(ValueError) + +Q(ValueError) + +Q(ZeroDivisionError) + +Q(ZeroDivisionError) + +Q(__add__) + +Q(__bool__) + +Q(__build_class__) + +Q(__call__) + +Q(__class__) + +Q(__class__) + +Q(__class__) + +Q(__class__) + +Q(__class__) + +Q(__contains__) + +Q(__delitem__) + +Q(__delitem__) + +Q(__enter__) + +Q(__eq__) + +Q(__eq__) + +Q(__exit__) + +Q(__ge__) + +Q(__getattr__) + +Q(__getattr__) + +Q(__getitem__) + +Q(__getitem__) + +Q(__getitem__) + +Q(__getitem__) + +Q(__gt__) + +Q(__hash__) + +Q(__import__) + +Q(__init__) + +Q(__init__) + +Q(__init__) + +Q(__iter__) + +Q(__le__) + +Q(__len__) + +Q(__lt__) + +Q(__main__) + +Q(__main__) + +Q(__main__) + +Q(__module__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__new__) + +Q(__new__) + +Q(__next__) + +Q(__next__) + +Q(__next__) + +Q(__next__) + +Q(__path__) + +Q(__path__) + +Q(__path__) + +Q(__qualname__) + +Q(__repl_print__) + +Q(__repl_print__) + +Q(__repr__) + +Q(__repr__) + +Q(__setitem__) + +Q(__setitem__) + +Q(__str__) + +Q(__sub__) + +Q(__traceback__) + +Q(_brace_open__colon__hash_b_brace_close_) + +Q(_lt_dictcomp_gt_) + +Q(_lt_genexpr_gt_) + +Q(_lt_lambda_gt_) + +Q(_lt_listcomp_gt_) + +Q(_lt_module_gt_) + +Q(_lt_setcomp_gt_) + +Q(_lt_string_gt_) + +Q(_percent__hash_o) + +Q(_percent__hash_x) + +Q(_star_) + +Q(_star_) + +Q(abs) + +Q(all) + +Q(any) + +Q(append) + +Q(args) + +Q(bin) + +Q(bool) + +Q(bool) + +Q(bound_method) + +Q(builtins) + +Q(builtins) + +Q(bytecode) + +Q(bytes) + +Q(bytes) + +Q(bytes) + +Q(callable) + +Q(chr) + +Q(classmethod) + +Q(classmethod) + +Q(clear) + +Q(clear) + +Q(close) + +Q(close) + +Q(close) + +Q(closure) + +Q(closure) + +Q(const) + +Q(copy) + +Q(copy) + +Q(count) + +Q(count) + +Q(count) + +Q(dict) + +Q(dict) + +Q(dict_view) + +Q(dir) + +Q(divmod) + +Q(end) + +Q(endswith) + +Q(eval) + +Q(exec) + +Q(extend) + +Q(find) + +Q(format) + +Q(from_bytes) + +Q(fromkeys) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(generator) + +Q(generator) + +Q(generator) + +Q(get) + +Q(getattr) + +Q(globals) + +Q(hasattr) + +Q(hash) + +Q(heap_lock) + +Q(heap_unlock) + +Q(hex) + +Q(id) + +Q(index) + +Q(index) + +Q(index) + +Q(insert) + +Q(int) + +Q(int) + +Q(isalpha) + +Q(isdigit) + +Q(isinstance) + +Q(islower) + +Q(isspace) + +Q(issubclass) + +Q(isupper) + +Q(items) + +Q(iter) + +Q(iterator) + +Q(iterator) + +Q(iterator) + +Q(iterator) + +Q(join) + +Q(key) + +Q(keys) + +Q(keys) + +Q(len) + +Q(list) + +Q(list) + +Q(little) + +Q(little) + +Q(locals) + +Q(lower) + +Q(lstrip) + +Q(map) + +Q(map) + +Q(micropython) + +Q(micropython) + +Q(micropython) + +Q(module) + +Q(next) + +Q(object) + +Q(object) + +Q(oct) + +Q(open) + +Q(opt_level) + +Q(ord) + +Q(pop) + +Q(pop) + +Q(popitem) + +Q(pow) + +Q(print) + +Q(range) + +Q(range) + +Q(range) + +Q(remove) + +Q(replace) + +Q(repr) + +Q(reverse) + +Q(reverse) + +Q(rfind) + +Q(rindex) + +Q(round) + +Q(rsplit) + +Q(rstrip) + +Q(send) + +Q(send) + +Q(sep) + +Q(setattr) + +Q(setdefault) + +Q(sort) + +Q(sorted) + +Q(split) + +Q(start) + +Q(startswith) + +Q(staticmethod) + +Q(staticmethod) + +Q(step) + +Q(stop) + +Q(str) + +Q(str) + +Q(str) + +Q(str) + +Q(strip) + +Q(sum) + +Q(super) + +Q(super) + +Q(super) + +Q(throw) + +Q(throw) + +Q(to_bytes) + +Q(tuple) + +Q(tuple) + +Q(type) + +Q(type) + +Q(update) + +Q(upper) + +Q(value) + +Q(values) + +Q(zip) + +Q(zip) diff --git a/user/mpy/build/genhdr/qstrdefs.collected.h.hash b/user/mpy/build/genhdr/qstrdefs.collected.h.hash new file mode 100644 index 0000000..25fee4f --- /dev/null +++ b/user/mpy/build/genhdr/qstrdefs.collected.h.hash @@ -0,0 +1 @@ +8aecabe383bd222126dadade55becad1 \ No newline at end of file diff --git a/user/mpy/build/genhdr/qstrdefs.generated.h b/user/mpy/build/genhdr/qstrdefs.generated.h new file mode 100644 index 0000000..a8a9128 --- /dev/null +++ b/user/mpy/build/genhdr/qstrdefs.generated.h @@ -0,0 +1,202 @@ +// This file was automatically generated by makeqstrdata.py + +QDEF(MP_QSTR_NULL, (const byte*)"\x00\x00" "") +QDEF(MP_QSTR_, (const byte*)"\x05\x00" "") +QDEF(MP_QSTR__star_, (const byte*)"\x8f\x01" "*") +QDEF(MP_QSTR__, (const byte*)"\xfa\x01" "_") +QDEF(MP_QSTR__slash_, (const byte*)"\x8a\x01" "/") +QDEF(MP_QSTR__percent__hash_o, (const byte*)"\x6c\x03" "%#o") +QDEF(MP_QSTR__percent__hash_x, (const byte*)"\x7b\x03" "%#x") +QDEF(MP_QSTR__brace_open__colon__hash_b_brace_close_, (const byte*)"\x58\x05" "{:#b}") +QDEF(MP_QSTR__0x0a_, (const byte*)"\xaf\x01" "\x0a") +QDEF(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, (const byte*)"\x73\x20" "maximum recursion depth exceeded") +QDEF(MP_QSTR__lt_module_gt_, (const byte*)"\xbd\x08" "") +QDEF(MP_QSTR__lt_lambda_gt_, (const byte*)"\x80\x08" "") +QDEF(MP_QSTR__lt_listcomp_gt_, (const byte*)"\xd4\x0a" "") +QDEF(MP_QSTR__lt_dictcomp_gt_, (const byte*)"\xcc\x0a" "") +QDEF(MP_QSTR__lt_setcomp_gt_, (const byte*)"\x54\x09" "") +QDEF(MP_QSTR__lt_genexpr_gt_, (const byte*)"\x34\x09" "") +QDEF(MP_QSTR__lt_string_gt_, (const byte*)"\x52\x08" "") +QDEF(MP_QSTR__lt_stdin_gt_, (const byte*)"\xe3\x07" "") +QDEF(MP_QSTR_utf_hyphen_8, (const byte*)"\xb7\x05" "utf-8") +QDEF(MP_QSTR___locals__, (const byte*)"\x7b\x0a" "__locals__") +QDEF(MP_QSTR_BufferError, (const byte*)"\x1d\x0b" "BufferError") +QDEF(MP_QSTR_FileExistsError, (const byte*)"\x5b\x0f" "FileExistsError") +QDEF(MP_QSTR_FileNotFoundError, (const byte*)"\x78\x11" "FileNotFoundError") +QDEF(MP_QSTR_FloatingPointError, (const byte*)"\x01\x12" "FloatingPointError") +QDEF(MP_QSTR_UnboundLocalError, (const byte*)"\x99\x11" "UnboundLocalError") +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___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___call__, (const byte*)"\xa7\x08" "__call__") +QDEF(MP_QSTR___class__, (const byte*)"\x2b\x09" "__class__") +QDEF(MP_QSTR___contains__, (const byte*)"\xc6\x0c" "__contains__") +QDEF(MP_QSTR___delitem__, (const byte*)"\xfd\x0b" "__delitem__") +QDEF(MP_QSTR___enter__, (const byte*)"\x6d\x09" "__enter__") +QDEF(MP_QSTR___eq__, (const byte*)"\x71\x06" "__eq__") +QDEF(MP_QSTR___exit__, (const byte*)"\x45\x08" "__exit__") +QDEF(MP_QSTR___ge__, (const byte*)"\xa7\x06" "__ge__") +QDEF(MP_QSTR___getattr__, (const byte*)"\x40\x0b" "__getattr__") +QDEF(MP_QSTR___getitem__, (const byte*)"\x26\x0b" "__getitem__") +QDEF(MP_QSTR___gt__, (const byte*)"\xb6\x06" "__gt__") +QDEF(MP_QSTR___hash__, (const byte*)"\xf7\x08" "__hash__") +QDEF(MP_QSTR___import__, (const byte*)"\x38\x0a" "__import__") +QDEF(MP_QSTR___init__, (const byte*)"\x5f\x08" "__init__") +QDEF(MP_QSTR___iter__, (const byte*)"\xcf\x08" "__iter__") +QDEF(MP_QSTR___le__, (const byte*)"\xcc\x06" "__le__") +QDEF(MP_QSTR___len__, (const byte*)"\xe2\x07" "__len__") +QDEF(MP_QSTR___lt__, (const byte*)"\x5d\x06" "__lt__") +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___path__, (const byte*)"\xc8\x08" "__path__") +QDEF(MP_QSTR___qualname__, (const byte*)"\x6b\x0c" "__qualname__") +QDEF(MP_QSTR___repl_print__, (const byte*)"\x01\x0e" "__repl_print__") +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___sub__, (const byte*)"\x21\x07" "__sub__") +QDEF(MP_QSTR___traceback__, (const byte*)"\x4f\x0d" "__traceback__") +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_bin, (const byte*)"\xe0\x03" "bin") +QDEF(MP_QSTR_bool, (const byte*)"\xeb\x04" "bool") +QDEF(MP_QSTR_bound_method, (const byte*)"\x97\x0c" "bound_method") +QDEF(MP_QSTR_builtins, (const byte*)"\xf7\x08" "builtins") +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_closure, (const byte*)"\x74\x07" "closure") +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_dict_view, (const byte*)"\x2d\x09" "dict_view") +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_fromkeys, (const byte*)"\x37\x08" "fromkeys") +QDEF(MP_QSTR_function, (const byte*)"\x27\x08" "function") +QDEF(MP_QSTR_generator, (const byte*)"\x96\x09" "generator") +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_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_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_iterator, (const byte*)"\x47\x08" "iterator") +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_map, (const byte*)"\xb9\x03" "map") +QDEF(MP_QSTR_micropython, (const byte*)"\x0b\x0b" "micropython") +QDEF(MP_QSTR_module, (const byte*)"\xbf\x06" "module") +QDEF(MP_QSTR_next, (const byte*)"\x42\x04" "next") +QDEF(MP_QSTR_object, (const byte*)"\x90\x06" "object") +QDEF(MP_QSTR_oct, (const byte*)"\xfd\x03" "oct") +QDEF(MP_QSTR_open, (const byte*)"\xd1\x04" "open") +QDEF(MP_QSTR_opt_level, (const byte*)"\x87\x09" "opt_level") +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_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_send, (const byte*)"\xb9\x04" "send") +QDEF(MP_QSTR_sep, (const byte*)"\x23\x03" "sep") +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_value, (const byte*)"\x4e\x05" "value") +QDEF(MP_QSTR_values, (const byte*)"\x7d\x06" "values") +QDEF(MP_QSTR_zip, (const byte*)"\xe6\x03" "zip") diff --git a/user/mpy/build/genhdr/qstrdefs.preprocessed.h b/user/mpy/build/genhdr/qstrdefs.preprocessed.h new file mode 100644 index 0000000..ddbba1d --- /dev/null +++ b/user/mpy/build/genhdr/qstrdefs.preprocessed.h @@ -0,0 +1,1243 @@ +# 1 "" +# 1 "/home/grd/kernel/pikoRT//" +# 1 "" +# 1 "" +# 1 "" +# 27 "" +# 1 "user/mpy/py/mpconfig.h" 1 +# 45 "user/mpy/py/mpconfig.h" +# 1 "user/mpy/mpconfigport.h" 1 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 +# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 +# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 + + + + + + + +# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 +# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 +# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 +# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 +# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 + +# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int8_t; + +typedef unsigned char __uint8_t; +# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int16_t; + +typedef short unsigned int __uint16_t; +# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int32_t; + +typedef long unsigned int __uint32_t; +# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int64_t; + +typedef long long unsigned int __uint64_t; +# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef signed char __int_least8_t; + +typedef unsigned char __uint_least8_t; +# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef short int __int_least16_t; + +typedef short unsigned int __uint_least16_t; +# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long int __int_least32_t; + +typedef long unsigned int __uint_least32_t; +# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __int_least64_t; + +typedef long long unsigned int __uint_least64_t; +# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 +typedef long long int __intmax_t; + + + + + + + +typedef long long unsigned int __uintmax_t; + + + + + + + +typedef int __intptr_t; + +typedef unsigned int __uintptr_t; +# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 +# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 + + + + + + + +# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 +# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 +# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 +typedef __int8_t int8_t ; + + + +typedef __uint8_t uint8_t ; + + + + + + + +typedef __int16_t int16_t ; + + + +typedef __uint16_t uint16_t ; + + + + + + + +typedef __int32_t int32_t ; + + + +typedef __uint32_t uint32_t ; + + + + + + + +typedef __int64_t int64_t ; + + + +typedef __uint64_t uint64_t ; + + + + + + +typedef __intmax_t intmax_t; + + + + +typedef __uintmax_t uintmax_t; + + + + +typedef __intptr_t intptr_t; + + + + +typedef __uintptr_t uintptr_t; +# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 + + + + + + +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; + + + + +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; + + + + +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; + + + + +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast8_t; + typedef unsigned int uint_fast8_t; +# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast16_t; + typedef unsigned int uint_fast16_t; +# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef int int_fast32_t; + typedef unsigned int uint_fast32_t; +# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 + typedef long long int int_fast64_t; + typedef long long unsigned int uint_fast64_t; +# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 +# 2 "user/mpy/mpconfigport.h" 2 +# 68 "user/mpy/mpconfigport.h" + +# 68 "user/mpy/mpconfigport.h" +typedef int mp_int_t; +typedef unsigned mp_uint_t; + +typedef long mp_off_t; +# 80 "user/mpy/mpconfigport.h" +# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 +# 10 "/usr/arm-none-eabi/include/alloca.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 +# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 +# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 + + + +# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 +# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 +# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 +# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 +# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 +# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 +# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 + +# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef int ptrdiff_t; +# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wchar_t; +# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 +# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 +# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 +# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 +# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 +# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 +typedef int _LOCK_T; +typedef int _LOCK_RECURSIVE_T; +# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + +typedef long __blkcnt_t; + + + +typedef long __blksize_t; + + + +typedef __uint64_t __fsblkcnt_t; + + + +typedef __uint32_t __fsfilcnt_t; + + + +typedef long _off_t; + + + + + +typedef int __pid_t; + + + +typedef short __dev_t; + + + +typedef unsigned short __uid_t; + + +typedef unsigned short __gid_t; + + + +typedef __uint32_t __id_t; + + + + + + + +typedef unsigned short __ino_t; +# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef __uint32_t __mode_t; + + + + + +__extension__ typedef long long _off64_t; + + + + + +typedef _off_t __off_t; + + +typedef _off64_t __loff_t; + + +typedef long __key_t; + + + + + + + +typedef long _fpos_t; +# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef unsigned int __size_t; +# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef signed int _ssize_t; +# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 +typedef _ssize_t __ssize_t; + + +# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 +# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 +typedef unsigned int wint_t; +# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 + + + +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; +} _mbstate_t; + + + +typedef _LOCK_RECURSIVE_T _flock_t; + + + + +typedef void *_iconv_t; + + + +typedef unsigned long __clock_t; + + +typedef long __time_t; + + +typedef unsigned long __clockid_t; + + +typedef unsigned long __timer_t; + + +typedef __uint8_t __sa_family_t; + + + +typedef __uint32_t __socklen_t; + + +typedef unsigned short __nlink_t; +typedef long __suseconds_t; +typedef unsigned long __useconds_t; + + + + +typedef char * __va_list; +# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 + + + + + + +typedef unsigned long __ULong; +# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent; + +struct __locale_t; + + + + + + +struct _Bigint +{ + struct _Bigint *_next; + int _k, _maxwds, _sign, _wds; + __ULong _x[1]; +}; + + +struct __tm +{ + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + + + + + + + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + + __ULong _fntypes; + + + __ULong _is_cxa; +}; +# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _atexit { + struct _atexit *_next; + int _ind; + + void (*_fns[32])(void); + struct _on_exit_args _on_exit_args; +}; +# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sbuf { + unsigned char *_base; + int _size; +}; +# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct __sFILE { + unsigned char *_p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + + + + + + + void * _cookie; + + int (* _read) (struct _reent *, void *, char *, int) + ; + int (* _write) (struct _reent *, void *, const char *, int) + + ; + _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); + int (* _close) (struct _reent *, void *); + + + struct __sbuf _ub; + unsigned char *_up; + int _ur; + + + unsigned char _ubuf[3]; + unsigned char _nbuf[1]; + + + struct __sbuf _lb; + + + int _blksize; + _off_t _offset; + + + struct _reent *_data; + + + + _flock_t _lock; + + _mbstate_t _mbstate; + int _flags2; +}; +# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 +typedef struct __sFILE __FILE; + + + +struct _glue +{ + struct _glue *_next; + int _niobs; + __FILE *_iobs; +}; +# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _rand48 { + unsigned short _seed[3]; + unsigned short _mult[3]; + unsigned short _add; + + + + +}; +# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 +struct _reent +{ + int _errno; + + + + + __FILE *_stdin, *_stdout, *_stderr; + + int _inc; + char _emergency[25]; + + + int _unspecified_locale_info; + struct __locale_t *_locale; + + int __sdidinit; + + void (* __cleanup) (struct _reent *); + + + struct _Bigint *_result; + int _result_k; + struct _Bigint *_p5s; + struct _Bigint **_freelist; + + + int _cvtlen; + char *_cvtbuf; + + union + { + struct + { + unsigned int _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + struct __tm _localtime_buf; + int _gamma_signgam; + __extension__ unsigned long long _rand_next; + struct _rand48 _r48; + _mbstate_t _mblen_state; + _mbstate_t _mbtowc_state; + _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + _mbstate_t _mbrlen_state; + _mbstate_t _mbrtowc_state; + _mbstate_t _mbsrtowcs_state; + _mbstate_t _wcrtomb_state; + _mbstate_t _wcsrtombs_state; + int _h_errno; + } _reent; + + + + struct + { + + unsigned char * _nextf[30]; + unsigned int _nmalloc[30]; + } _unused; + } _new; + + + + struct _atexit *_atexit; + struct _atexit _atexit0; + + + + void (**(_sig_func))(int); + + + + + struct _glue __sglue; + __FILE __sf[3]; +}; +# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 +extern struct _reent *_impure_ptr ; +extern struct _reent *const _global_impure_ptr ; + +void _reclaim_reent (struct _reent *); +# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 +# 81 "user/mpy/mpconfigport.h" 2 +# 46 "user/mpy/py/mpconfig.h" 2 +# 28 "" 2 + + + + + + +# 33 "" +QCFG(BYTES_IN_LEN, (1)) +QCFG(BYTES_IN_HASH, (1)) + +Q() +Q(*) +Q(_) +Q(/) +Q(%#o) +Q(%#x) +Q({:#b}) +Q(\n) +Q(maximum recursion depth exceeded) +Q() +Q() +Q() +Q() +Q() +Q() +Q() +Q() +Q(utf-8) + + +Q(__locals__) +Q(BufferError) +Q(FileExistsError) +Q(FileNotFoundError) +Q(FloatingPointError) +Q(UnboundLocalError) +Q(ArithmeticError) + +Q(ArithmeticError) + +Q(AssertionError) + +Q(AssertionError) + +Q(AssertionError) + +Q(AttributeError) + +Q(AttributeError) + +Q(BaseException) + +Q(BaseException) + +Q(EOFError) + +Q(EOFError) + +Q(Ellipsis) + +Q(Ellipsis) + +Q(Exception) + +Q(Exception) + +Q(GeneratorExit) + +Q(GeneratorExit) + +Q(ImportError) + +Q(ImportError) + +Q(IndentationError) + +Q(IndentationError) + +Q(IndexError) + +Q(IndexError) + +Q(KeyError) + +Q(KeyError) + +Q(KeyboardInterrupt) + +Q(KeyboardInterrupt) + +Q(LookupError) + +Q(LookupError) + +Q(MemoryError) + +Q(MemoryError) + +Q(NameError) + +Q(NameError) + +Q(NoneType) + +Q(NotImplementedError) + +Q(NotImplementedError) + +Q(OSError) + +Q(OSError) + +Q(OverflowError) + +Q(OverflowError) + +Q(RuntimeError) + +Q(RuntimeError) + +Q(StopIteration) + +Q(StopIteration) + +Q(SyntaxError) + +Q(SyntaxError) + +Q(SystemExit) + +Q(SystemExit) + +Q(TypeError) + +Q(TypeError) + +Q(ValueError) + +Q(ValueError) + +Q(ZeroDivisionError) + +Q(ZeroDivisionError) + +Q(__add__) + +Q(__bool__) + +Q(__build_class__) + +Q(__call__) + +Q(__class__) + +Q(__class__) + +Q(__class__) + +Q(__class__) + +Q(__class__) + +Q(__contains__) + +Q(__delitem__) + +Q(__delitem__) + +Q(__enter__) + +Q(__eq__) + +Q(__eq__) + +Q(__exit__) + +Q(__ge__) + +Q(__getattr__) + +Q(__getattr__) + +Q(__getitem__) + +Q(__getitem__) + +Q(__getitem__) + +Q(__getitem__) + +Q(__gt__) + +Q(__hash__) + +Q(__import__) + +Q(__init__) + +Q(__init__) + +Q(__init__) + +Q(__iter__) + +Q(__le__) + +Q(__len__) + +Q(__lt__) + +Q(__main__) + +Q(__main__) + +Q(__main__) + +Q(__module__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__name__) + +Q(__new__) + +Q(__new__) + +Q(__next__) + +Q(__next__) + +Q(__next__) + +Q(__next__) + +Q(__path__) + +Q(__path__) + +Q(__path__) + +Q(__qualname__) + +Q(__repl_print__) + +Q(__repl_print__) + +Q(__repr__) + +Q(__repr__) + +Q(__setitem__) + +Q(__setitem__) + +Q(__str__) + +Q(__sub__) + +Q(__traceback__) + +Q(_brace_open__colon__hash_b_brace_close_) + +Q(_lt_dictcomp_gt_) + +Q(_lt_genexpr_gt_) + +Q(_lt_lambda_gt_) + +Q(_lt_listcomp_gt_) + +Q(_lt_module_gt_) + +Q(_lt_setcomp_gt_) + +Q(_lt_string_gt_) + +Q(_percent__hash_o) + +Q(_percent__hash_x) + +Q(_star_) + +Q(_star_) + +Q(abs) + +Q(all) + +Q(any) + +Q(append) + +Q(args) + +Q(bin) + +Q(bool) + +Q(bool) + +Q(bound_method) + +Q(builtins) + +Q(builtins) + +Q(bytecode) + +Q(bytes) + +Q(bytes) + +Q(bytes) + +Q(callable) + +Q(chr) + +Q(classmethod) + +Q(classmethod) + +Q(clear) + +Q(clear) + +Q(close) + +Q(close) + +Q(close) + +Q(closure) + +Q(closure) + +Q(const) + +Q(copy) + +Q(copy) + +Q(count) + +Q(count) + +Q(count) + +Q(dict) + +Q(dict) + +Q(dict_view) + +Q(dir) + +Q(divmod) + +Q(end) + +Q(endswith) + +Q(eval) + +Q(exec) + +Q(extend) + +Q(find) + +Q(format) + +Q(from_bytes) + +Q(fromkeys) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(function) + +Q(generator) + +Q(generator) + +Q(generator) + +Q(get) + +Q(getattr) + +Q(globals) + +Q(hasattr) + +Q(hash) + +Q(heap_lock) + +Q(heap_unlock) + +Q(hex) + +Q(id) + +Q(index) + +Q(index) + +Q(index) + +Q(insert) + +Q(int) + +Q(int) + +Q(isalpha) + +Q(isdigit) + +Q(isinstance) + +Q(islower) + +Q(isspace) + +Q(issubclass) + +Q(isupper) + +Q(items) + +Q(iter) + +Q(iterator) + +Q(iterator) + +Q(iterator) + +Q(iterator) + +Q(join) + +Q(key) + +Q(keys) + +Q(keys) + +Q(len) + +Q(list) + +Q(list) + +Q(little) + +Q(little) + +Q(locals) + +Q(lower) + +Q(lstrip) + +Q(map) + +Q(map) + +Q(micropython) + +Q(micropython) + +Q(micropython) + +Q(module) + +Q(next) + +Q(object) + +Q(object) + +Q(oct) + +Q(open) + +Q(opt_level) + +Q(ord) + +Q(pop) + +Q(pop) + +Q(popitem) + +Q(pow) + +Q(print) + +Q(range) + +Q(range) + +Q(range) + +Q(remove) + +Q(replace) + +Q(repr) + +Q(reverse) + +Q(reverse) + +Q(rfind) + +Q(rindex) + +Q(round) + +Q(rsplit) + +Q(rstrip) + +Q(send) + +Q(send) + +Q(sep) + +Q(setattr) + +Q(setdefault) + +Q(sort) + +Q(sorted) + +Q(split) + +Q(start) + +Q(startswith) + +Q(staticmethod) + +Q(staticmethod) + +Q(step) + +Q(stop) + +Q(str) + +Q(str) + +Q(str) + +Q(str) + +Q(strip) + +Q(sum) + +Q(super) + +Q(super) + +Q(super) + +Q(throw) + +Q(throw) + +Q(to_bytes) + +Q(tuple) + +Q(tuple) + +Q(type) + +Q(type) + +Q(update) + +Q(upper) + +Q(value) + +Q(values) + +Q(zip) + +Q(zip) diff --git a/user/mpy/extmod/crypto-algorithms/sha256.c b/user/mpy/extmod/crypto-algorithms/sha256.c new file mode 100644 index 0000000..276611c --- /dev/null +++ b/user/mpy/extmod/crypto-algorithms/sha256.c @@ -0,0 +1,157 @@ +/********************************************************************* +* Filename: sha256.c +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Implementation of the SHA-256 hashing algorithm. + SHA-256 is one of the three algorithms in the SHA2 + specification. The others, SHA-384 and SHA-512, are not + offered in this implementation. + Algorithm specification can be found here: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + This implementation uses little endian byte order. +*********************************************************************/ + +/*************************** HEADER FILES ***************************/ +#include +#include "sha256.h" + +/****************************** MACROS ******************************/ +#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b)))) +#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b)))) + +#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z))) +#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) +#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22)) +#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25)) +#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3)) +#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10)) + +/**************************** VARIABLES *****************************/ +static const WORD k[64] = { + 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5, + 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174, + 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da, + 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967, + 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85, + 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070, + 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3, + 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +}; + +/*********************** FUNCTION DEFINITIONS ***********************/ +static void sha256_transform(CRYAL_SHA256_CTX *ctx, const BYTE data[]) +{ + WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64]; + + for (i = 0, j = 0; i < 16; ++i, j += 4) + m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]); + for ( ; i < 64; ++i) + m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16]; + + a = ctx->state[0]; + b = ctx->state[1]; + c = ctx->state[2]; + d = ctx->state[3]; + e = ctx->state[4]; + f = ctx->state[5]; + g = ctx->state[6]; + h = ctx->state[7]; + + for (i = 0; i < 64; ++i) { + t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i]; + t2 = EP0(a) + MAJ(a,b,c); + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + + ctx->state[0] += a; + ctx->state[1] += b; + ctx->state[2] += c; + ctx->state[3] += d; + ctx->state[4] += e; + ctx->state[5] += f; + ctx->state[6] += g; + ctx->state[7] += h; +} + +void sha256_init(CRYAL_SHA256_CTX *ctx) +{ + ctx->datalen = 0; + ctx->bitlen = 0; + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + ctx->state[7] = 0x5be0cd19; +} + +void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len) +{ + WORD i; + + for (i = 0; i < len; ++i) { + ctx->data[ctx->datalen] = data[i]; + ctx->datalen++; + if (ctx->datalen == 64) { + sha256_transform(ctx, ctx->data); + ctx->bitlen += 512; + ctx->datalen = 0; + } + } +} + +void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]) +{ + WORD i; + + i = ctx->datalen; + + // Pad whatever data is left in the buffer. + if (ctx->datalen < 56) { + ctx->data[i++] = 0x80; + while (i < 56) + ctx->data[i++] = 0x00; + } + else { + ctx->data[i++] = 0x80; + while (i < 64) + ctx->data[i++] = 0x00; + sha256_transform(ctx, ctx->data); + memset(ctx->data, 0, 56); + } + + // Append to the padding the total message's length in bits and transform. + ctx->bitlen += ctx->datalen * 8; + ctx->data[63] = ctx->bitlen; + ctx->data[62] = ctx->bitlen >> 8; + ctx->data[61] = ctx->bitlen >> 16; + ctx->data[60] = ctx->bitlen >> 24; + ctx->data[59] = ctx->bitlen >> 32; + ctx->data[58] = ctx->bitlen >> 40; + ctx->data[57] = ctx->bitlen >> 48; + ctx->data[56] = ctx->bitlen >> 56; + sha256_transform(ctx, ctx->data); + + // Since this implementation uses little endian byte ordering and SHA uses big endian, + // reverse all the bytes when copying the final state to the output hash. + for (i = 0; i < 4; ++i) { + hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff; + hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff; + hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff; + hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff; + hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff; + hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff; + hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff; + hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff; + } +} diff --git a/user/mpy/extmod/crypto-algorithms/sha256.h b/user/mpy/extmod/crypto-algorithms/sha256.h new file mode 100644 index 0000000..caa1f81 --- /dev/null +++ b/user/mpy/extmod/crypto-algorithms/sha256.h @@ -0,0 +1,34 @@ +/********************************************************************* +* Filename: sha256.h +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Defines the API for the corresponding SHA1 implementation. +*********************************************************************/ + +#ifndef SHA256_H +#define SHA256_H + +/*************************** HEADER FILES ***************************/ +#include + +/****************************** MACROS ******************************/ +#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest + +/**************************** DATA TYPES ****************************/ +typedef unsigned char BYTE; // 8-bit byte +typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines + +typedef struct { + BYTE data[64]; + WORD datalen; + unsigned long long bitlen; + WORD state[8]; +} CRYAL_SHA256_CTX; + +/*********************** FUNCTION DECLARATIONS **********************/ +void sha256_init(CRYAL_SHA256_CTX *ctx); +void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len); +void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]); + +#endif // SHA256_H diff --git a/user/mpy/extmod/lwip-include/arch/cc.h b/user/mpy/extmod/lwip-include/arch/cc.h new file mode 100644 index 0000000..400dc6e --- /dev/null +++ b/user/mpy/extmod/lwip-include/arch/cc.h @@ -0,0 +1,41 @@ +#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H +#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H + +#include + +// Generate lwip's internal types from stdint + +typedef uint8_t u8_t; +typedef int8_t s8_t; +typedef uint16_t u16_t; +typedef int16_t s16_t; +typedef uint32_t u32_t; +typedef int32_t s32_t; + +typedef u32_t mem_ptr_t; + +#define U16_F "hu" +#define S16_F "hd" +#define X16_F "hx" +#define U32_F "u" +#define S32_F "d" +#define X32_F "x" + +#define X8_F "02x" +#define SZT_F "u" + +#define BYTE_ORDER LITTLE_ENDIAN + +#define LWIP_CHKSUM_ALGORITHM 2 + +#include +#define LWIP_PLATFORM_DIAG(x) +#define LWIP_PLATFORM_ASSERT(x) { assert(1); } + +//#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) +#define PACK_STRUCT_FIELD(x) x +#define PACK_STRUCT_STRUCT __attribute__((packed)) +#define PACK_STRUCT_BEGIN +#define PACK_STRUCT_END + +#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H diff --git a/user/mpy/extmod/lwip-include/arch/perf.h b/user/mpy/extmod/lwip-include/arch/perf.h new file mode 100644 index 0000000..d310fc3 --- /dev/null +++ b/user/mpy/extmod/lwip-include/arch/perf.h @@ -0,0 +1,7 @@ +#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H +#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H + +#define PERF_START /* null definition */ +#define PERF_STOP(x) /* null definition */ + +#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H diff --git a/user/mpy/extmod/lwip-include/lwipopts.h b/user/mpy/extmod/lwip-include/lwipopts.h new file mode 100644 index 0000000..2122f30 --- /dev/null +++ b/user/mpy/extmod/lwip-include/lwipopts.h @@ -0,0 +1,35 @@ +#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H +#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H + +#include +#include +#include + +// We're running without an OS for this port. We don't provide any services except light protection. +#define NO_SYS 1 + +#define SYS_LIGHTWEIGHT_PROT 1 +#include +typedef uint32_t sys_prot_t; + +#define TCP_LISTEN_BACKLOG 1 + +// We'll put these into a proper ifdef once somebody implements an ethernet driver +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 + +#define LWIP_DNS 1 + +#define LWIP_NETCONN 0 +#define LWIP_SOCKET 0 + +#ifdef MICROPY_PY_LWIP_SLIP +#define LWIP_HAVE_SLIPIF 1 +#endif + +// For now, we can simply define this as a macro for the timer code. But this function isn't +// universal and other ports will need to do something else. It may be necessary to move +// things like this into a port-provided header file. +#define sys_now mp_hal_ticks_ms + +#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H diff --git a/user/mpy/extmod/machine_i2c.c b/user/mpy/extmod/machine_i2c.c new file mode 100644 index 0000000..c0a51a6 --- /dev/null +++ b/user/mpy/extmod/machine_i2c.c @@ -0,0 +1,640 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include +#include + +#include "py/mperrno.h" +#include "py/mphal.h" +#include "py/runtime.h" +#include "extmod/machine_i2c.h" + +#if MICROPY_PY_MACHINE_I2C + +typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t; + +STATIC void mp_hal_i2c_delay(machine_i2c_obj_t *self) { + // We need to use an accurate delay to get acceptable I2C + // speeds (eg 1us should be not much more than 1us). + mp_hal_delay_us_fast(self->us_delay); +} + +STATIC void mp_hal_i2c_scl_low(machine_i2c_obj_t *self) { + mp_hal_pin_od_low(self->scl); +} + +STATIC int mp_hal_i2c_scl_release(machine_i2c_obj_t *self) { + uint32_t count = self->us_timeout; + + mp_hal_pin_od_high(self->scl); + mp_hal_i2c_delay(self); + // For clock stretching, wait for the SCL pin to be released, with timeout. + for (; mp_hal_pin_read(self->scl) == 0 && count; --count) { + mp_hal_delay_us_fast(1); + } + if (count == 0) { + return -MP_ETIMEDOUT; + } + return 0; // success +} + +STATIC void mp_hal_i2c_sda_low(machine_i2c_obj_t *self) { + mp_hal_pin_od_low(self->sda); +} + +STATIC void mp_hal_i2c_sda_release(machine_i2c_obj_t *self) { + mp_hal_pin_od_high(self->sda); +} + +STATIC int mp_hal_i2c_sda_read(machine_i2c_obj_t *self) { + return mp_hal_pin_read(self->sda); +} + +STATIC int mp_hal_i2c_start(machine_i2c_obj_t *self) { + mp_hal_i2c_sda_release(self); + mp_hal_i2c_delay(self); + int ret = mp_hal_i2c_scl_release(self); + if (ret != 0) { + return ret; + } + mp_hal_i2c_sda_low(self); + mp_hal_i2c_delay(self); + return 0; // success +} + +STATIC int mp_hal_i2c_stop(machine_i2c_obj_t *self) { + mp_hal_i2c_delay(self); + mp_hal_i2c_sda_low(self); + mp_hal_i2c_delay(self); + int ret = mp_hal_i2c_scl_release(self); + mp_hal_i2c_sda_release(self); + mp_hal_i2c_delay(self); + return ret; +} + +STATIC void mp_hal_i2c_init(machine_i2c_obj_t *self, uint32_t freq) { + self->us_delay = 500000 / freq; + if (self->us_delay == 0) { + self->us_delay = 1; + } + mp_hal_pin_open_drain(self->scl); + mp_hal_pin_open_drain(self->sda); + mp_hal_i2c_stop(self); // ignore error +} + +// return value: +// 0 - byte written and ack received +// 1 - byte written and nack received +// <0 - error, with errno being the negative of the return value +STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) { + mp_hal_i2c_delay(self); + mp_hal_i2c_scl_low(self); + + for (int i = 7; i >= 0; i--) { + if ((val >> i) & 1) { + mp_hal_i2c_sda_release(self); + } else { + mp_hal_i2c_sda_low(self); + } + mp_hal_i2c_delay(self); + int ret = mp_hal_i2c_scl_release(self); + if (ret != 0) { + mp_hal_i2c_sda_release(self); + return ret; + } + mp_hal_i2c_scl_low(self); + } + + mp_hal_i2c_sda_release(self); + mp_hal_i2c_delay(self); + int ret = mp_hal_i2c_scl_release(self); + if (ret != 0) { + return ret; + } + + int ack = mp_hal_i2c_sda_read(self); + mp_hal_i2c_delay(self); + mp_hal_i2c_scl_low(self); + + return ack; +} + +// return value: +// 0 - success +// <0 - error, with errno being the negative of the return value +STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack) { + mp_hal_i2c_delay(self); + mp_hal_i2c_scl_low(self); + mp_hal_i2c_delay(self); + + uint8_t data = 0; + for (int i = 7; i >= 0; i--) { + int ret = mp_hal_i2c_scl_release(self); + if (ret != 0) { + return ret; + } + data = (data << 1) | mp_hal_i2c_sda_read(self); + mp_hal_i2c_scl_low(self); + mp_hal_i2c_delay(self); + } + *val = data; + + // send ack/nack bit + if (!nack) { + mp_hal_i2c_sda_low(self); + } + mp_hal_i2c_delay(self); + int ret = mp_hal_i2c_scl_release(self); + if (ret != 0) { + mp_hal_i2c_sda_release(self); + return ret; + } + mp_hal_i2c_scl_low(self); + mp_hal_i2c_sda_release(self); + + return 0; // success +} + +// return value: +// >=0 - number of acks received +// <0 - error, with errno being the negative of the return value +int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop) { + machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; + + // start the I2C transaction + int ret = mp_hal_i2c_start(self); + if (ret != 0) { + return ret; + } + + // write the slave address + ret = mp_hal_i2c_write_byte(self, addr << 1); + if (ret < 0) { + return ret; + } else if (ret != 0) { + // nack received, release the bus cleanly + mp_hal_i2c_stop(self); + return -MP_ENODEV; + } + + // write the buffer to the I2C memory + int num_acks = 0; + while (len--) { + ret = mp_hal_i2c_write_byte(self, *src++); + if (ret < 0) { + return ret; + } else if (ret != 0) { + // nack received, stop sending + break; + } + ++num_acks; + } + + // finish the I2C transaction + if (stop) { + ret = mp_hal_i2c_stop(self); + if (ret != 0) { + return ret; + } + } + + return num_acks; +} + +// return value: +// 0 - success +// <0 - error, with errno being the negative of the return value +int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) { + machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; + + // start the I2C transaction + int ret = mp_hal_i2c_start(self); + if (ret != 0) { + return ret; + } + + // write the slave address + ret = mp_hal_i2c_write_byte(self, (addr << 1) | 1); + if (ret < 0) { + return ret; + } else if (ret != 0) { + // nack received, release the bus cleanly + mp_hal_i2c_stop(self); + return -MP_ENODEV; + } + + // read the bytes from the slave + while (len--) { + ret = mp_hal_i2c_read_byte(self, dest++, len == 0); + if (ret != 0) { + return ret; + } + } + + // finish the I2C transaction + if (stop) { + ret = mp_hal_i2c_stop(self); + if (ret != 0) { + return ret; + } + } + + return 0; // success +} + +/******************************************************************************/ +// MicroPython bindings for I2C + +STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_scl, ARG_sda, ARG_freq, ARG_timeout }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_sda, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_freq, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 400000} }, + { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 255} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + self->scl = mp_hal_get_pin_obj(args[ARG_scl].u_obj); + self->sda = mp_hal_get_pin_obj(args[ARG_sda].u_obj); + self->us_timeout = args[ARG_timeout].u_int; + mp_hal_i2c_init(self, args[ARG_freq].u_int); +} + +STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + // check the id argument, if given + if (n_args > 0) { + if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) { + #if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW) + // dispatch to port-specific constructor + extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); + return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args); + #else + mp_raise_ValueError("invalid I2C peripheral"); + #endif + } + --n_args; + ++args; + } + + // create new soft I2C object + machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t); + self->base.type = &machine_i2c_type; + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); + machine_i2c_obj_init_helper(self, n_args, args, &kw_args); + return (mp_obj_t)self; +} + +STATIC mp_obj_t machine_i2c_obj_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + machine_i2c_obj_init_helper(args[0], n_args - 1, args + 1, kw_args); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init); + +STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) { + mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_obj_t list = mp_obj_new_list(0, NULL); + // 7-bit addresses 0b0000xxx and 0b1111xxx are reserved + for (int addr = 0x08; addr < 0x78; ++addr) { + int ret = i2c_p->writeto(self, addr, NULL, 0, true); + if (ret == 0) { + mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr)); + } + } + return list; +} +MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan); + +STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + if (i2c_p->start == NULL) { + mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); + } + int ret = i2c_p->start(self); + if (ret != 0) { + mp_raise_OSError(-ret); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start); + +STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + if (i2c_p->stop == NULL) { + mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); + } + int ret = i2c_p->stop(self); + if (ret != 0) { + mp_raise_OSError(-ret); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop); + +STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + if (i2c_p->read == NULL) { + mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); + } + + // get the buffer to read into + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); + + // work out if we want to send a nack at the end + bool nack = (n_args == 2) ? true : mp_obj_is_true(args[2]); + + // do the read + int ret = i2c_p->read(self, bufinfo.buf, bufinfo.len, nack); + if (ret != 0) { + mp_raise_OSError(-ret); + } + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_readinto); + +STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + if (i2c_p->write == NULL) { + mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); + } + + // get the buffer to write from + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); + + // do the write + int ret = i2c_p->write(self, bufinfo.buf, bufinfo.len); + if (ret < 0) { + mp_raise_OSError(-ret); + } + + // return number of acks received + return MP_OBJ_NEW_SMALL_INT(ret); +} +MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write); + +STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_int_t addr = mp_obj_get_int(args[1]); + vstr_t vstr; + vstr_init_len(&vstr, mp_obj_get_int(args[2])); + bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]); + int ret = i2c_p->readfrom(self, addr, (uint8_t*)vstr.buf, vstr.len, stop); + if (ret < 0) { + mp_raise_OSError(-ret); + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_readfrom); + +STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_int_t addr = mp_obj_get_int(args[1]); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE); + bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]); + int ret = i2c_p->readfrom(self, addr, bufinfo.buf, bufinfo.len, stop); + if (ret < 0) { + mp_raise_OSError(-ret); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine_i2c_readfrom_into); + +STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_int_t addr = mp_obj_get_int(args[1]); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); + bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]); + int ret = i2c_p->writeto(self, addr, bufinfo.buf, bufinfo.len, stop); + if (ret < 0) { + mp_raise_OSError(-ret); + } + // return number of acks received + return MP_OBJ_NEW_SMALL_INT(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machine_i2c_writeto); + +STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + uint8_t memaddr_buf[4]; + size_t memaddr_len = 0; + for (int16_t i = addrsize - 8; i >= 0; i -= 8) { + memaddr_buf[memaddr_len++] = memaddr >> i; + } + int ret = i2c_p->writeto(self, addr, memaddr_buf, memaddr_len, false); + if (ret != memaddr_len) { + // must generate STOP + i2c_p->writeto(self, addr, NULL, 0, true); + return ret; + } + return i2c_p->readfrom(self, addr, buf, len, true); +} + +#define MAX_MEMADDR_SIZE (4) +#define BUF_STACK_SIZE (12) + +STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) { + mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + + // need some memory to create the buffer to send; try to use stack if possible + uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE]; + uint8_t *buf2; + size_t buf2_alloc = 0; + if (len <= BUF_STACK_SIZE) { + buf2 = buf2_stack; + } else { + buf2_alloc = MAX_MEMADDR_SIZE + len; + buf2 = m_new(uint8_t, buf2_alloc); + } + + // create the buffer to send + size_t memaddr_len = 0; + for (int16_t i = addrsize - 8; i >= 0; i -= 8) { + buf2[memaddr_len++] = memaddr >> i; + } + memcpy(buf2 + memaddr_len, buf, len); + + int ret = i2c_p->writeto(self, addr, buf2, memaddr_len + len, true); + if (buf2_alloc != 0) { + m_del(uint8_t, buf2, buf2_alloc); + } + return ret; +} + +STATIC const mp_arg_t machine_i2c_mem_allowed_args[] = { + { MP_QSTR_addr, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_memaddr, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_arg, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_addrsize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} }, +}; + +STATIC mp_obj_t machine_i2c_readfrom_mem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_addr, ARG_memaddr, ARG_n, ARG_addrsize }; + mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args); + + // create the buffer to store data into + vstr_t vstr; + vstr_init_len(&vstr, mp_obj_get_int(args[ARG_n].u_obj)); + + // do the transfer + int ret = read_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int, + args[ARG_addrsize].u_int, (uint8_t*)vstr.buf, vstr.len); + if (ret < 0) { + mp_raise_OSError(-ret); + } + + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_readfrom_mem_obj, 1, machine_i2c_readfrom_mem); + + +STATIC mp_obj_t machine_i2c_readfrom_mem_into(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_addr, ARG_memaddr, ARG_buf, ARG_addrsize }; + mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args); + + // get the buffer to store data into + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_WRITE); + + // do the transfer + int ret = read_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int, + args[ARG_addrsize].u_int, bufinfo.buf, bufinfo.len); + if (ret < 0) { + mp_raise_OSError(-ret); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_readfrom_mem_into_obj, 1, machine_i2c_readfrom_mem_into); + +STATIC mp_obj_t machine_i2c_writeto_mem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_addr, ARG_memaddr, ARG_buf, ARG_addrsize }; + mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args); + + // get the buffer to write the data from + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_READ); + + // do the transfer + int ret = write_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int, + args[ARG_addrsize].u_int, bufinfo.buf, bufinfo.len); + if (ret < 0) { + mp_raise_OSError(-ret); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_writeto_mem_obj, 1, machine_i2c_writeto_mem); + +STATIC const mp_rom_map_elem_t machine_i2c_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_i2c_init_obj) }, + { MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&machine_i2c_scan_obj) }, + + // primitive I2C operations + { MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&machine_i2c_start_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&machine_i2c_stop_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&machine_i2c_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&machine_i2c_write_obj) }, + + // standard bus operations + { MP_ROM_QSTR(MP_QSTR_readfrom), MP_ROM_PTR(&machine_i2c_readfrom_obj) }, + { MP_ROM_QSTR(MP_QSTR_readfrom_into), MP_ROM_PTR(&machine_i2c_readfrom_into_obj) }, + { MP_ROM_QSTR(MP_QSTR_writeto), MP_ROM_PTR(&machine_i2c_writeto_obj) }, + + // memory operations + { MP_ROM_QSTR(MP_QSTR_readfrom_mem), MP_ROM_PTR(&machine_i2c_readfrom_mem_obj) }, + { MP_ROM_QSTR(MP_QSTR_readfrom_mem_into), MP_ROM_PTR(&machine_i2c_readfrom_mem_into_obj) }, + { MP_ROM_QSTR(MP_QSTR_writeto_mem), MP_ROM_PTR(&machine_i2c_writeto_mem_obj) }, +}; + +MP_DEFINE_CONST_DICT(mp_machine_soft_i2c_locals_dict, machine_i2c_locals_dict_table); + +int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size_t len, bool nack) { + machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; + while (len--) { + int ret = mp_hal_i2c_read_byte(self, dest++, nack && (len == 0)); + if (ret != 0) { + return ret; + } + } + return 0; // success +} + +int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t len) { + machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; + int num_acks = 0; + while (len--) { + int ret = mp_hal_i2c_write_byte(self, *src++); + if (ret < 0) { + return ret; + } else if (ret != 0) { + // nack received, stop sending + break; + } + ++num_acks; + } + return num_acks; +} + +STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = { + .start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start, + .stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop, + .read = mp_machine_soft_i2c_read, + .write = mp_machine_soft_i2c_write, + .readfrom = mp_machine_soft_i2c_readfrom, + .writeto = mp_machine_soft_i2c_writeto, +}; + +const mp_obj_type_t machine_i2c_type = { + { &mp_type_type }, + .name = MP_QSTR_I2C, + .make_new = machine_i2c_make_new, + .protocol = &mp_machine_soft_i2c_p, + .locals_dict = (mp_obj_dict_t*)&mp_machine_soft_i2c_locals_dict, +}; + +#endif // MICROPY_PY_MACHINE_I2C diff --git a/user/mpy/extmod/machine_i2c.h b/user/mpy/extmod/machine_i2c.h new file mode 100644 index 0000000..f5af665 --- /dev/null +++ b/user/mpy/extmod/machine_i2c.h @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_EXTMOD_MACHINE_I2C_H +#define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H + +#include "py/obj.h" + +// I2C protocol +// the first 4 methods can be NULL, meaning operation is not supported +typedef struct _mp_machine_i2c_p_t { + int (*start)(mp_obj_base_t *obj); + int (*stop)(mp_obj_base_t *obj); + int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack); + int (*write)(mp_obj_base_t *obj, const uint8_t *src, size_t len); + int (*readfrom)(mp_obj_base_t *obj, uint16_t addr, uint8_t *dest, size_t len, bool stop); + int (*writeto)(mp_obj_base_t *obj, uint16_t addr, const uint8_t *src, size_t len, bool stop); +} mp_machine_i2c_p_t; + +typedef struct _mp_machine_soft_i2c_obj_t { + mp_obj_base_t base; + uint32_t us_delay; + uint32_t us_timeout; + mp_hal_pin_obj_t scl; + mp_hal_pin_obj_t sda; +} mp_machine_soft_i2c_obj_t; + +extern const mp_obj_type_t machine_i2c_type; +extern const mp_obj_dict_t mp_machine_soft_i2c_locals_dict; + +int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop); +int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop); + +#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H diff --git a/user/mpy/extmod/machine_mem.c b/user/mpy/extmod/machine_mem.c new file mode 100644 index 0000000..af987cb --- /dev/null +++ b/user/mpy/extmod/machine_mem.c @@ -0,0 +1,103 @@ +/* + * 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. + */ + +#include "extmod/machine_mem.h" +#include "py/nlr.h" + +#if MICROPY_PY_MACHINE + +// If you wish to override the functions for mapping the machine_mem read/write +// address, then add a #define for MICROPY_MACHINE_MEM_GET_READ_ADDR and/or +// MICROPY_MACHINE_MEM_GET_WRITE_ADDR in your mpconfigport.h. Since the +// prototypes are identical, it is allowable for both of the macros to evaluate +// the to same function. +// +// It is expected that the modmachine.c file for a given port will provide the +// implementations, if the default implementation isn't used. + +#if !defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) || !defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR) +STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) { + uintptr_t addr = mp_obj_int_get_truncated(addr_o); + if ((addr & (align - 1)) != 0) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "address %08x is not aligned to %d bytes", addr, align)); + } + return addr; +} +#if !defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) +#define MICROPY_MACHINE_MEM_GET_READ_ADDR machine_mem_get_addr +#endif +#if !defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR) +#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR machine_mem_get_addr +#endif +#endif + +STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); +} + +STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + // TODO support slice index to read/write multiple values at once + machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (value == MP_OBJ_NULL) { + // delete + return MP_OBJ_NULL; // op not supported + } else if (value == MP_OBJ_SENTINEL) { + // load + uintptr_t addr = MICROPY_MACHINE_MEM_GET_READ_ADDR(index, self->elem_size); + uint32_t val; + switch (self->elem_size) { + case 1: val = (*(uint8_t*)addr); break; + case 2: val = (*(uint16_t*)addr); break; + default: val = (*(uint32_t*)addr); break; + } + return mp_obj_new_int(val); + } else { + // store + uintptr_t addr = MICROPY_MACHINE_MEM_GET_WRITE_ADDR(index, self->elem_size); + uint32_t val = mp_obj_get_int_truncated(value); + switch (self->elem_size) { + case 1: (*(uint8_t*)addr) = val; break; + case 2: (*(uint16_t*)addr) = val; break; + default: (*(uint32_t*)addr) = val; break; + } + return mp_const_none; + } +} + +const mp_obj_type_t machine_mem_type = { + { &mp_type_type }, + .name = MP_QSTR_mem, + .print = machine_mem_print, + .subscr = machine_mem_subscr, +}; + +const machine_mem_obj_t machine_mem8_obj = {{&machine_mem_type}, 1}; +const machine_mem_obj_t machine_mem16_obj = {{&machine_mem_type}, 2}; +const machine_mem_obj_t machine_mem32_obj = {{&machine_mem_type}, 4}; + +#endif // MICROPY_PY_MACHINE diff --git a/user/mpy/extmod/machine_mem.h b/user/mpy/extmod/machine_mem.h new file mode 100644 index 0000000..a48a52c --- /dev/null +++ b/user/mpy/extmod/machine_mem.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 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_EXTMOD_MACHINE_MEM_H +#define MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H + +#include "py/obj.h" + +typedef struct _machine_mem_obj_t { + mp_obj_base_t base; + unsigned elem_size; // in bytes +} machine_mem_obj_t; + +extern const mp_obj_type_t machine_mem_type; + +extern const machine_mem_obj_t machine_mem8_obj; +extern const machine_mem_obj_t machine_mem16_obj; +extern const machine_mem_obj_t machine_mem32_obj; + +#if defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) +uintptr_t MICROPY_MACHINE_MEM_GET_READ_ADDR(mp_obj_t addr_o, uint align); +#endif +#if defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR) +uintptr_t MICROPY_MACHINE_MEM_GET_WRITE_ADDR(mp_obj_t addr_o, uint align); +#endif + +#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H diff --git a/user/mpy/extmod/machine_pinbase.c b/user/mpy/extmod/machine_pinbase.c new file mode 100644 index 0000000..3c1f094 --- /dev/null +++ b/user/mpy/extmod/machine_pinbase.c @@ -0,0 +1,88 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_PY_MACHINE + +#include "py/obj.h" +#include "py/runtime.h" +#include "extmod/virtpin.h" + +// PinBase class + +// As this is abstract class, its instance is null. +// But there should be an instance, as the rest of instance code +// expects that there will be concrete object for inheritance. +typedef struct _mp_pinbase_t { + mp_obj_base_t base; +} mp_pinbase_t; + +STATIC const mp_obj_type_t pinbase_type; + +STATIC mp_pinbase_t pinbase_singleton = { + .base = { &pinbase_type }, +}; + +STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type; + (void)n_args; + (void)n_kw; + (void)args; + return MP_OBJ_FROM_PTR(&pinbase_singleton); +} + +mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) { + (void)errcode; + switch (request) { + case MP_PIN_READ: { + mp_obj_t dest[2]; + mp_load_method(obj, MP_QSTR_value, dest); + return mp_obj_get_int(mp_call_method_n_kw(0, 0, dest)); + } + case MP_PIN_WRITE: { + mp_obj_t dest[3]; + mp_load_method(obj, MP_QSTR_value, dest); + dest[2] = (arg == 0 ? mp_const_false : mp_const_true); + mp_call_method_n_kw(1, 0, dest); + return 0; + } + } + return -1; +} + +STATIC const mp_pin_p_t pinbase_pin_p = { + .ioctl = pinbase_ioctl, +}; + +const mp_obj_type_t machine_pinbase_type = { + { &mp_type_type }, + .name = MP_QSTR_PinBase, + .make_new = pinbase_make_new, + .protocol = &pinbase_pin_p, +}; + +#endif // MICROPY_PY_MACHINE diff --git a/user/mpy/extmod/machine_pinbase.h b/user/mpy/extmod/machine_pinbase.h new file mode 100644 index 0000000..c96abbc --- /dev/null +++ b/user/mpy/extmod/machine_pinbase.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ +#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H +#define MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H + +#include "py/obj.h" + +extern const mp_obj_type_t machine_pinbase_type; + +#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H diff --git a/user/mpy/extmod/machine_pulse.c b/user/mpy/extmod/machine_pulse.c new file mode 100644 index 0000000..5f83747 --- /dev/null +++ b/user/mpy/extmod/machine_pulse.c @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include "py/runtime.h" +#include "py/mperrno.h" +#include "extmod/machine_pulse.h" + +#if MICROPY_PY_MACHINE_PULSE + +mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) { + mp_uint_t start = mp_hal_ticks_us(); + while (mp_hal_pin_read(pin) != pulse_level) { + if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) { + return (mp_uint_t)-2; + } + } + start = mp_hal_ticks_us(); + while (mp_hal_pin_read(pin) == pulse_level) { + if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) { + return (mp_uint_t)-1; + } + } + return mp_hal_ticks_us() - start; +} + +STATIC mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *args) { + mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(args[0]); + int level = 0; + if (mp_obj_is_true(args[1])) { + level = 1; + } + mp_uint_t timeout_us = 1000000; + if (n_args > 2) { + timeout_us = mp_obj_get_int(args[2]); + } + mp_uint_t us = machine_time_pulse_us(pin, level, timeout_us); + // May return -1 or -2 in case of timeout + return mp_obj_new_int(us); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj, 2, 3, machine_time_pulse_us_); + +#endif diff --git a/user/mpy/extmod/machine_pulse.h b/user/mpy/extmod/machine_pulse.h new file mode 100644 index 0000000..e303dca --- /dev/null +++ b/user/mpy/extmod/machine_pulse.h @@ -0,0 +1,36 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_EXTMOD_MACHINE_PULSE_H +#define MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H + +#include "py/obj.h" +#include "py/mphal.h" + +mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us); + +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj); + +#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H diff --git a/user/mpy/extmod/machine_signal.c b/user/mpy/extmod/machine_signal.c new file mode 100644 index 0000000..78d0c3f --- /dev/null +++ b/user/mpy/extmod/machine_signal.c @@ -0,0 +1,183 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_PY_MACHINE + +#include + +#include "py/obj.h" +#include "py/runtime.h" +#include "extmod/virtpin.h" +#include "extmod/machine_signal.h" + +// Signal class + +typedef struct _machine_signal_t { + mp_obj_base_t base; + mp_obj_t pin; + bool invert; +} machine_signal_t; + +STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_t pin = args[0]; + bool invert = false; + + #if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW) + mp_pin_p_t *pin_p = NULL; + + if (MP_OBJ_IS_OBJ(pin)) { + mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); + pin_p = (mp_pin_p_t*)pin_base->type->protocol; + } + + if (pin_p == NULL) { + // If first argument isn't a Pin-like object, we filter out "invert" + // from keyword arguments and pass them all to the exported Pin + // constructor to create one. + mp_obj_t pin_args[n_args + n_kw * 2]; + memcpy(pin_args, args, n_args * sizeof(mp_obj_t)); + const mp_obj_t *src = args + n_args; + mp_obj_t *dst = pin_args + n_args; + mp_obj_t *sig_value = NULL; + for (size_t cnt = n_kw; cnt; cnt--) { + if (*src == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) { + invert = mp_obj_is_true(src[1]); + n_kw--; + } else { + *dst++ = *src; + *dst++ = src[1]; + } + if (*src == MP_OBJ_NEW_QSTR(MP_QSTR_value)) { + // Value is pertained to Signal, so we should invert + // it for Pin if needed, and we should do it only when + // inversion status is guaranteedly known. + sig_value = dst - 1; + } + src += 2; + } + + if (invert && sig_value != NULL) { + *sig_value = mp_obj_is_true(*sig_value) ? MP_OBJ_NEW_SMALL_INT(0) : MP_OBJ_NEW_SMALL_INT(1); + } + + // Here we pass NULL as a type, hoping that mp_pin_make_new() + // will just ignore it as set a concrete type. If not, we'd need + // to expose port's "default" pin type too. + pin = MICROPY_PY_MACHINE_PIN_MAKE_NEW(NULL, n_args, n_kw, pin_args); + } + else + #endif + // Otherwise there should be 1 or 2 args + { + if (n_args == 1) { + if (n_kw == 0) { + } else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) { + invert = mp_obj_is_true(args[2]); + } else { + goto error; + } + } else { + error: + mp_raise_TypeError(NULL); + } + } + + machine_signal_t *o = m_new_obj(machine_signal_t); + o->base.type = type; + o->pin = pin; + o->invert = invert; + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { + (void)errcode; + machine_signal_t *self = MP_OBJ_TO_PTR(self_in); + + switch (request) { + case MP_PIN_READ: { + return mp_virtual_pin_read(self->pin) ^ self->invert; + } + case MP_PIN_WRITE: { + mp_virtual_pin_write(self->pin, arg ^ self->invert); + return 0; + } + } + return -1; +} + +// fast method for getting/setting signal value +STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); + if (n_args == 0) { + // get pin + return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in)); + } else { + // set pin + mp_virtual_pin_write(self_in, mp_obj_is_true(args[0])); + return mp_const_none; + } +} + +STATIC mp_obj_t signal_value(size_t n_args, const mp_obj_t *args) { + return signal_call(args[0], n_args - 1, 0, args + 1); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(signal_value_obj, 1, 2, signal_value); + +STATIC mp_obj_t signal_on(mp_obj_t self_in) { + mp_virtual_pin_write(self_in, 1); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_on_obj, signal_on); + +STATIC mp_obj_t signal_off(mp_obj_t self_in) { + mp_virtual_pin_write(self_in, 0); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_off_obj, signal_off); + +STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&signal_value_obj) }, + { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&signal_on_obj) }, + { MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&signal_off_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table); + +STATIC const mp_pin_p_t signal_pin_p = { + .ioctl = signal_ioctl, +}; + +const mp_obj_type_t machine_signal_type = { + { &mp_type_type }, + .name = MP_QSTR_Signal, + .make_new = signal_make_new, + .call = signal_call, + .protocol = &signal_pin_p, + .locals_dict = (void*)&signal_locals_dict, +}; + +#endif // MICROPY_PY_MACHINE diff --git a/user/mpy/extmod/machine_signal.h b/user/mpy/extmod/machine_signal.h new file mode 100644 index 0000000..df1c3e2 --- /dev/null +++ b/user/mpy/extmod/machine_signal.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 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. + */ +#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H +#define MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H + +#include "py/obj.h" + +extern const mp_obj_type_t machine_signal_type; + +#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H diff --git a/user/mpy/extmod/machine_spi.c b/user/mpy/extmod/machine_spi.c new file mode 100644 index 0000000..a67d294 --- /dev/null +++ b/user/mpy/extmod/machine_spi.c @@ -0,0 +1,339 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include + +#include "py/runtime.h" +#include "extmod/machine_spi.h" + +#if MICROPY_PY_MACHINE_SPI + +// if a port didn't define MSB/LSB constants then provide them +#ifndef MICROPY_PY_MACHINE_SPI_MSB +#define MICROPY_PY_MACHINE_SPI_MSB (0) +#define MICROPY_PY_MACHINE_SPI_LSB (1) +#endif + +void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) { + mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in; + uint32_t delay_half = self->delay_half; + + // only MSB transfer is implemented + + // If a port defines MICROPY_PY_MACHINE_SPI_MIN_DELAY, and the configured + // delay_half is equal to this value, then the software SPI implementation + // will run as fast as possible, limited only by CPU speed and GPIO time. + #ifdef MICROPY_PY_MACHINE_SPI_MIN_DELAY + if (delay_half == MICROPY_PY_MACHINE_SPI_MIN_DELAY) { + for (size_t i = 0; i < len; ++i) { + uint8_t data_out = src[i]; + uint8_t data_in = 0; + for (int j = 0; j < 8; ++j, data_out <<= 1) { + mp_hal_pin_write(self->mosi, (data_out >> 7) & 1); + mp_hal_pin_write(self->sck, 1 - self->polarity); + data_in = (data_in << 1) | mp_hal_pin_read(self->miso); + mp_hal_pin_write(self->sck, self->polarity); + } + if (dest != NULL) { + dest[i] = data_in; + } + } + return; + } + #endif + + for (size_t i = 0; i < len; ++i) { + uint8_t data_out = src[i]; + uint8_t data_in = 0; + for (int j = 0; j < 8; ++j, data_out <<= 1) { + mp_hal_pin_write(self->mosi, (data_out >> 7) & 1); + if (self->phase == 0) { + mp_hal_delay_us_fast(delay_half); + mp_hal_pin_write(self->sck, 1 - self->polarity); + } else { + mp_hal_pin_write(self->sck, 1 - self->polarity); + mp_hal_delay_us_fast(delay_half); + } + data_in = (data_in << 1) | mp_hal_pin_read(self->miso); + if (self->phase == 0) { + mp_hal_delay_us_fast(delay_half); + mp_hal_pin_write(self->sck, self->polarity); + } else { + mp_hal_pin_write(self->sck, self->polarity); + mp_hal_delay_us_fast(delay_half); + } + } + if (dest != NULL) { + dest[i] = data_in; + } + } +} + +/******************************************************************************/ +// MicroPython bindings for generic machine.SPI + +STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); + +mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + // check the id argument, if given + if (n_args > 0) { + if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) { + #if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW) + // dispatch to port-specific constructor + extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); + return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args); + #else + mp_raise_ValueError("invalid SPI peripheral"); + #endif + } + --n_args; + ++args; + } + + // software SPI + return mp_machine_soft_spi_make_new(type, n_args, n_kw, args); +} + +STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; + spi_p->init(s, n_args - 1, args + 1, kw_args); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init); + +STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) { + mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; + if (spi_p->deinit != NULL) { + spi_p->deinit(s); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit); + +STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) { + mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; + spi_p->transfer(s, len, src, dest); +} + +STATIC mp_obj_t mp_machine_spi_read(size_t n_args, const mp_obj_t *args) { + vstr_t vstr; + vstr_init_len(&vstr, mp_obj_get_int(args[1])); + memset(vstr.buf, n_args == 3 ? mp_obj_get_int(args[2]) : 0, vstr.len); + mp_machine_spi_transfer(args[0], vstr.len, vstr.buf, vstr.buf); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj, 2, 3, mp_machine_spi_read); + +STATIC mp_obj_t mp_machine_spi_readinto(size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); + memset(bufinfo.buf, n_args == 3 ? mp_obj_get_int(args[2]) : 0, bufinfo.len); + mp_machine_spi_transfer(args[0], bufinfo.len, bufinfo.buf, bufinfo.buf); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj, 2, 3, mp_machine_spi_readinto); + +STATIC mp_obj_t mp_machine_spi_write(mp_obj_t self, mp_obj_t wr_buf) { + mp_buffer_info_t src; + mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ); + mp_machine_spi_transfer(self, src.len, (const uint8_t*)src.buf, NULL); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj, mp_machine_spi_write); + +STATIC mp_obj_t mp_machine_spi_write_readinto(mp_obj_t self, mp_obj_t wr_buf, mp_obj_t rd_buf) { + mp_buffer_info_t src; + mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ); + mp_buffer_info_t dest; + mp_get_buffer_raise(rd_buf, &dest, MP_BUFFER_WRITE); + if (src.len != dest.len) { + mp_raise_ValueError("buffers must be the same length"); + } + mp_machine_spi_transfer(self, src.len, src.buf, dest.buf); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_3(mp_machine_spi_write_readinto_obj, mp_machine_spi_write_readinto); + +STATIC const mp_rom_map_elem_t machine_spi_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_spi_init_obj) }, + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_spi_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_machine_spi_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_machine_spi_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_machine_spi_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&mp_machine_spi_write_readinto_obj) }, + + { MP_ROM_QSTR(MP_QSTR_MSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_MSB) }, + { MP_ROM_QSTR(MP_QSTR_LSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_LSB) }, +}; + +MP_DEFINE_CONST_DICT(mp_machine_spi_locals_dict, machine_spi_locals_dict_table); + +/******************************************************************************/ +// Implementation of soft SPI + +STATIC uint32_t baudrate_from_delay_half(uint32_t delay_half) { + #ifdef MICROPY_PY_MACHINE_SPI_MIN_DELAY + if (delay_half == MICROPY_PY_MACHINE_SPI_MIN_DELAY) { + return MICROPY_PY_MACHINE_SPI_MAX_BAUDRATE; + } else + #endif + { + return 500000 / delay_half; + } +} + +STATIC uint32_t baudrate_to_delay_half(uint32_t baudrate) { + #ifdef MICROPY_PY_MACHINE_SPI_MIN_DELAY + if (baudrate >= MICROPY_PY_MACHINE_SPI_MAX_BAUDRATE) { + return MICROPY_PY_MACHINE_SPI_MIN_DELAY; + } else + #endif + { + uint32_t delay_half = 500000 / baudrate; + // round delay_half up so that: actual_baudrate <= requested_baudrate + if (500000 % baudrate != 0) { + delay_half += 1; + } + return delay_half; + } +} + +STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_machine_soft_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "SoftSPI(baudrate=%u, polarity=%u, phase=%u," + " sck=" MP_HAL_PIN_FMT ", mosi=" MP_HAL_PIN_FMT ", miso=" MP_HAL_PIN_FMT ")", + baudrate_from_delay_half(self->delay_half), self->polarity, self->phase, + mp_hal_pin_name(self->sck), mp_hal_pin_name(self->mosi), mp_hal_pin_name(self->miso)); +} + +STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} }, + { MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} }, + { MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = MICROPY_PY_MACHINE_SPI_MSB} }, + { MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + // create new object + mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t); + self->base.type = &mp_machine_soft_spi_type; + + // set parameters + self->delay_half = baudrate_to_delay_half(args[ARG_baudrate].u_int); + self->polarity = args[ARG_polarity].u_int; + self->phase = args[ARG_phase].u_int; + if (args[ARG_bits].u_int != 8) { + mp_raise_ValueError("bits must be 8"); + } + if (args[ARG_firstbit].u_int != MICROPY_PY_MACHINE_SPI_MSB) { + mp_raise_ValueError("firstbit must be MSB"); + } + if (args[ARG_sck].u_obj == MP_OBJ_NULL + || args[ARG_mosi].u_obj == MP_OBJ_NULL + || args[ARG_miso].u_obj == MP_OBJ_NULL) { + mp_raise_ValueError("must specify all of sck/mosi/miso"); + } + self->sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj); + self->mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj); + self->miso = mp_hal_get_pin_obj(args[ARG_miso].u_obj); + + // configure pins + mp_hal_pin_write(self->sck, self->polarity); + mp_hal_pin_output(self->sck); + mp_hal_pin_output(self->mosi); + mp_hal_pin_input(self->miso); + + return MP_OBJ_FROM_PTR(self); +} + +STATIC void mp_machine_soft_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in; + + enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_sck, ARG_mosi, ARG_miso }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = -1} }, + { MP_QSTR_polarity, MP_ARG_INT, {.u_int = -1} }, + { MP_QSTR_phase, MP_ARG_INT, {.u_int = -1} }, + { MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + if (args[ARG_baudrate].u_int != -1) { + self->delay_half = baudrate_to_delay_half(args[ARG_baudrate].u_int); + } + if (args[ARG_polarity].u_int != -1) { + self->polarity = args[ARG_polarity].u_int; + } + if (args[ARG_phase].u_int != -1) { + self->phase = args[ARG_phase].u_int; + } + if (args[ARG_sck].u_obj != MP_OBJ_NULL) { + self->sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj); + } + if (args[ARG_mosi].u_obj != MP_OBJ_NULL) { + self->mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj); + } + if (args[ARG_miso].u_obj != MP_OBJ_NULL) { + self->miso = mp_hal_get_pin_obj(args[ARG_miso].u_obj); + } + + // configure pins + mp_hal_pin_write(self->sck, self->polarity); + mp_hal_pin_output(self->sck); + mp_hal_pin_output(self->mosi); + mp_hal_pin_input(self->miso); +} + +STATIC const mp_machine_spi_p_t mp_machine_soft_spi_p = { + .init = mp_machine_soft_spi_init, + .deinit = NULL, + .transfer = mp_machine_soft_spi_transfer, +}; + +const mp_obj_type_t mp_machine_soft_spi_type = { + { &mp_type_type }, + .name = MP_QSTR_SoftSPI, + .print = mp_machine_soft_spi_print, + .make_new = mp_machine_spi_make_new, // delegate to master constructor + .protocol = &mp_machine_soft_spi_p, + .locals_dict = (mp_obj_dict_t*)&mp_machine_spi_locals_dict, +}; + +#endif // MICROPY_PY_MACHINE_SPI diff --git a/user/mpy/extmod/machine_spi.h b/user/mpy/extmod/machine_spi.h new file mode 100644 index 0000000..e24e41e --- /dev/null +++ b/user/mpy/extmod/machine_spi.h @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_EXTMOD_MACHINE_SPI_H +#define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H + +#include "py/obj.h" +#include "py/mphal.h" + +// SPI protocol +typedef struct _mp_machine_spi_p_t { + void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); + void (*deinit)(mp_obj_base_t *obj); // can be NULL + void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); +} mp_machine_spi_p_t; + +typedef struct _mp_machine_soft_spi_obj_t { + mp_obj_base_t base; + uint32_t delay_half; // microsecond delay for half SCK period + uint8_t polarity; + uint8_t phase; + mp_hal_pin_obj_t sck; + mp_hal_pin_obj_t mosi; + mp_hal_pin_obj_t miso; +} mp_machine_soft_spi_obj_t; + +extern const mp_obj_type_t mp_machine_soft_spi_type; +extern const mp_obj_dict_t mp_machine_spi_locals_dict; + +void mp_machine_soft_spi_transfer(mp_obj_base_t *self, size_t len, const uint8_t *src, uint8_t *dest); + +mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); + +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj); +MP_DECLARE_CONST_FUN_OBJ_3(mp_machine_spi_write_readinto_obj); + +#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H diff --git a/user/mpy/extmod/misc.h b/user/mpy/extmod/misc.h new file mode 100644 index 0000000..6c13592 --- /dev/null +++ b/user/mpy/extmod/misc.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014-2016 Damien P. George + * Copyright (c) 2016 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. + */ +#ifndef MICROPY_INCLUDED_EXTMOD_MISC_H +#define MICROPY_INCLUDED_EXTMOD_MISC_H + +// This file contains cumulative declarations for extmod/ . + +#include +#include "py/runtime.h" + +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj); + +#if MICROPY_PY_OS_DUPTERM +void mp_uos_dupterm_tx_strn(const char *str, size_t len); +void mp_uos_deactivate(const char *msg, mp_obj_t exc); +#else +#define mp_uos_dupterm_tx_strn(s, l) +#endif + +#endif // MICROPY_INCLUDED_EXTMOD_MISC_H diff --git a/user/mpy/extmod/modbtree.c b/user/mpy/extmod/modbtree.c new file mode 100644 index 0000000..229daaf --- /dev/null +++ b/user/mpy/extmod/modbtree.c @@ -0,0 +1,379 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include +#include // for declaration of global errno variable +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/runtime0.h" +#include "py/stream.h" + +#if MICROPY_PY_BTREE + +#include +#include <../../btree/btree.h> + +typedef struct _mp_obj_btree_t { + mp_obj_base_t base; + DB *db; + mp_obj_t start_key; + mp_obj_t end_key; + #define FLAG_END_KEY_INCL 1 + #define FLAG_DESC 2 + #define FLAG_ITER_TYPE_MASK 0xc0 + #define FLAG_ITER_KEYS 0x40 + #define FLAG_ITER_VALUES 0x80 + #define FLAG_ITER_ITEMS 0xc0 + byte flags; + byte next_flags; +} mp_obj_btree_t; + +STATIC const mp_obj_type_t btree_type; + +#define CHECK_ERROR(res) \ + if (res == RET_ERROR) { \ + mp_raise_OSError(errno); \ + } + +void __dbpanic(DB *db) { + printf("__dbpanic(%p)\n", db); +} + +STATIC mp_obj_btree_t *btree_new(DB *db) { + mp_obj_btree_t *o = m_new_obj(mp_obj_btree_t); + o->base.type = &btree_type; + o->db = db; + o->start_key = mp_const_none; + o->end_key = mp_const_none; + o->next_flags = 0; + return o; +} + +STATIC void btree_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "", self->db); +} + +STATIC mp_obj_t btree_flush(mp_obj_t self_in) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(__bt_sync(self->db, 0)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(btree_flush_obj, btree_flush); + +STATIC mp_obj_t btree_close(mp_obj_t self_in) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(__bt_close(self->db)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(btree_close_obj, btree_close); + +STATIC mp_obj_t btree_put(size_t n_args, const mp_obj_t *args) { + (void)n_args; + mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); + DBT key, val; + key.data = (void*)mp_obj_str_get_data(args[1], &key.size); + val.data = (void*)mp_obj_str_get_data(args[2], &val.size); + return MP_OBJ_NEW_SMALL_INT(__bt_put(self->db, &key, &val, 0)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_put_obj, 3, 4, btree_put); + +STATIC mp_obj_t btree_get(size_t n_args, const mp_obj_t *args) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); + DBT key, val; + key.data = (void*)mp_obj_str_get_data(args[1], &key.size); + int res = __bt_get(self->db, &key, &val, 0); + if (res == RET_SPECIAL) { + if (n_args > 2) { + return args[2]; + } else { + return mp_const_none; + } + } + CHECK_ERROR(res); + return mp_obj_new_bytes(val.data, val.size); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_get_obj, 2, 3, btree_get); + +STATIC mp_obj_t btree_seq(size_t n_args, const mp_obj_t *args) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); + int flags = MP_OBJ_SMALL_INT_VALUE(args[1]); + DBT key, val; + if (n_args > 2) { + key.data = (void*)mp_obj_str_get_data(args[2], &key.size); + } + + int res = __bt_seq(self->db, &key, &val, flags); + CHECK_ERROR(res); + if (res == RET_SPECIAL) { + return mp_const_none; + } + + mp_obj_t pair_o = mp_obj_new_tuple(2, NULL); + mp_obj_tuple_t *pair = MP_OBJ_TO_PTR(pair_o); + pair->items[0] = mp_obj_new_bytes(key.data, key.size); + pair->items[1] = mp_obj_new_bytes(val.data, val.size); + return pair_o; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_seq_obj, 2, 4, btree_seq); + +STATIC mp_obj_t btree_init_iter(size_t n_args, const mp_obj_t *args, byte type) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); + self->next_flags = type; + self->start_key = mp_const_none; + self->end_key = mp_const_none; + if (n_args > 1) { + self->start_key = args[1]; + if (n_args > 2) { + self->end_key = args[2]; + if (n_args > 3) { + self->next_flags = type | MP_OBJ_SMALL_INT_VALUE(args[3]); + } + } + } + return args[0]; +} + +STATIC mp_obj_t btree_keys(size_t n_args, const mp_obj_t *args) { + return btree_init_iter(n_args, args, FLAG_ITER_KEYS); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_keys_obj, 1, 4, btree_keys); + +STATIC mp_obj_t btree_values(size_t n_args, const mp_obj_t *args) { + return btree_init_iter(n_args, args, FLAG_ITER_VALUES); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_values_obj, 1, 4, btree_values); + +STATIC mp_obj_t btree_items(size_t n_args, const mp_obj_t *args) { + return btree_init_iter(n_args, args, FLAG_ITER_ITEMS); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_items_obj, 1, 4, btree_items); + +STATIC mp_obj_t btree_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { + (void)iter_buf; + mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + if (self->next_flags != 0) { + // If we're called immediately after keys(), values(), or items(), + // use their setup for iteration. + self->flags = self->next_flags; + self->next_flags = 0; + } else { + // Otherwise, iterate over all keys. + self->flags = FLAG_ITER_KEYS; + self->start_key = mp_const_none; + self->end_key = mp_const_none; + } + + return self_in; +} + +STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + DBT key, val; + int res; + bool desc = self->flags & FLAG_DESC; + if (self->start_key != MP_OBJ_NULL) { + int flags = R_FIRST; + if (self->start_key != mp_const_none) { + key.data = (void*)mp_obj_str_get_data(self->start_key, &key.size); + flags = R_CURSOR; + } else if (desc) { + flags = R_LAST; + } + res = __bt_seq(self->db, &key, &val, flags); + self->start_key = MP_OBJ_NULL; + } else { + res = __bt_seq(self->db, &key, &val, desc ? R_PREV : R_NEXT); + } + + if (res == RET_SPECIAL) { + return MP_OBJ_STOP_ITERATION; + } + CHECK_ERROR(res); + + if (self->end_key != mp_const_none) { + DBT end_key; + end_key.data = (void*)mp_obj_str_get_data(self->end_key, &end_key.size); + BTREE *t = self->db->internal; + int cmp = t->bt_cmp(&key, &end_key); + if (desc) { + cmp = -cmp; + } + if (self->flags & FLAG_END_KEY_INCL) { + cmp--; + } + if (cmp >= 0) { + self->end_key = MP_OBJ_NULL; + return MP_OBJ_STOP_ITERATION; + } + } + + switch (self->flags & FLAG_ITER_TYPE_MASK) { + case FLAG_ITER_KEYS: + return mp_obj_new_bytes(key.data, key.size); + case FLAG_ITER_VALUES: + return mp_obj_new_bytes(val.data, val.size); + default: { + mp_obj_t pair_o = mp_obj_new_tuple(2, NULL); + mp_obj_tuple_t *pair = MP_OBJ_TO_PTR(pair_o); + pair->items[0] = mp_obj_new_bytes(key.data, key.size); + pair->items[1] = mp_obj_new_bytes(val.data, val.size); + return pair_o; + } + } +} + +STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + if (value == MP_OBJ_NULL) { + // delete + DBT key; + key.data = (void*)mp_obj_str_get_data(index, &key.size); + int res = __bt_delete(self->db, &key, 0); + if (res == RET_SPECIAL) { + nlr_raise(mp_obj_new_exception(&mp_type_KeyError)); + } + CHECK_ERROR(res); + return mp_const_none; + } else if (value == MP_OBJ_SENTINEL) { + // load + DBT key, val; + key.data = (void*)mp_obj_str_get_data(index, &key.size); + int res = __bt_get(self->db, &key, &val, 0); + if (res == RET_SPECIAL) { + nlr_raise(mp_obj_new_exception(&mp_type_KeyError)); + } + CHECK_ERROR(res); + return mp_obj_new_bytes(val.data, val.size); + } else { + // store + DBT key, val; + key.data = (void*)mp_obj_str_get_data(index, &key.size); + val.data = (void*)mp_obj_str_get_data(value, &val.size); + int res = __bt_put(self->db, &key, &val, 0); + CHECK_ERROR(res); + return mp_const_none; + } +} + +STATIC mp_obj_t btree_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_btree_t *self = MP_OBJ_TO_PTR(lhs_in); + switch (op) { + case MP_BINARY_OP_IN: { + DBT key, val; + key.data = (void*)mp_obj_str_get_data(rhs_in, &key.size); + int res = __bt_get(self->db, &key, &val, 0); + CHECK_ERROR(res); + return mp_obj_new_bool(res != RET_SPECIAL); + } + default: + // op not supported + return MP_OBJ_NULL; + } +} + +STATIC const mp_rom_map_elem_t btree_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&btree_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&btree_flush_obj) }, + { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&btree_get_obj) }, + { MP_ROM_QSTR(MP_QSTR_put), MP_ROM_PTR(&btree_put_obj) }, + { MP_ROM_QSTR(MP_QSTR_seq), MP_ROM_PTR(&btree_seq_obj) }, + { MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&btree_keys_obj) }, + { MP_ROM_QSTR(MP_QSTR_values), MP_ROM_PTR(&btree_values_obj) }, + { MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&btree_items_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(btree_locals_dict, btree_locals_dict_table); + +STATIC const mp_obj_type_t btree_type = { + { &mp_type_type }, + // Save on qstr's, reuse same as for module + .name = MP_QSTR_btree, + .print = btree_print, + .getiter = btree_getiter, + .iternext = btree_iternext, + .binary_op = btree_binary_op, + .subscr = btree_subscr, + .locals_dict = (void*)&btree_locals_dict, +}; + +STATIC FILEVTABLE btree_stream_fvtable = { + mp_stream_posix_read, + mp_stream_posix_write, + mp_stream_posix_lseek, + mp_stream_posix_fsync +}; + +STATIC mp_obj_t mod_btree_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + static const mp_arg_t allowed_args[] = { + { MP_QSTR_flags, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_cachesize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_pagesize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_minkeypage, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + }; + + // Make sure we got a stream object + mp_get_stream_raise(pos_args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); + + struct { + mp_arg_val_t flags; + mp_arg_val_t cachesize; + mp_arg_val_t pagesize; + mp_arg_val_t minkeypage; + } args; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); + BTREEINFO openinfo = {0}; + openinfo.flags = args.flags.u_int; + openinfo.cachesize = args.cachesize.u_int; + openinfo.psize = args.pagesize.u_int; + openinfo.minkeypage = args.minkeypage.u_int; + + DB *db = __bt_open(pos_args[0], &btree_stream_fvtable, &openinfo, /*dflags*/0); + if (db == NULL) { + mp_raise_OSError(errno); + } + return MP_OBJ_FROM_PTR(btree_new(db)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_btree_open_obj, 1, mod_btree_open); + +STATIC const mp_rom_map_elem_t mp_module_btree_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_btree) }, + { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mod_btree_open_obj) }, + { MP_ROM_QSTR(MP_QSTR_INCL), MP_ROM_INT(FLAG_END_KEY_INCL) }, + { MP_ROM_QSTR(MP_QSTR_DESC), MP_ROM_INT(FLAG_DESC) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_btree_globals, mp_module_btree_globals_table); + +const mp_obj_module_t mp_module_btree = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_btree_globals, +}; + +#endif // MICROPY_PY_BTREE diff --git a/user/mpy/extmod/modframebuf.c b/user/mpy/extmod/modframebuf.c new file mode 100644 index 0000000..f4e8571 --- /dev/null +++ b/user/mpy/extmod/modframebuf.c @@ -0,0 +1,596 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" + +#if MICROPY_PY_FRAMEBUF + +#include "stmhal/font_petme128_8x8.h" + +typedef struct _mp_obj_framebuf_t { + mp_obj_base_t base; + mp_obj_t buf_obj; // need to store this to prevent GC from reclaiming buf + void *buf; + uint16_t width, height, stride; + uint8_t format; +} mp_obj_framebuf_t; + +typedef void (*setpixel_t)(const mp_obj_framebuf_t*, int, int, uint32_t); +typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int); +typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t); + +typedef struct _mp_framebuf_p_t { + setpixel_t setpixel; + getpixel_t getpixel; + fill_rect_t fill_rect; +} mp_framebuf_p_t; + +// constants for formats +#define FRAMEBUF_MVLSB (0) +#define FRAMEBUF_RGB565 (1) +#define FRAMEBUF_GS4_HMSB (2) +#define FRAMEBUF_MHLSB (3) +#define FRAMEBUF_MHMSB (4) + +// Functions for MHLSB and MHMSB + +STATIC void mono_horiz_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { + size_t index = (x + y * fb->stride) >> 3; + int offset = fb->format == FRAMEBUF_MHMSB ? x & 0x07 : 7 - (x & 0x07); + ((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((col != 0) << offset); +} + +STATIC uint32_t mono_horiz_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { + size_t index = (x + y * fb->stride) >> 3; + int offset = fb->format == FRAMEBUF_MHMSB ? x & 0x07 : 7 - (x & 0x07); + return (((uint8_t*)fb->buf)[index] >> (offset)) & 0x01; +} + +STATIC void mono_horiz_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { + int reverse = fb->format == FRAMEBUF_MHMSB; + int advance = fb->stride >> 3; + while (w--) { + uint8_t *b = &((uint8_t*)fb->buf)[(x >> 3) + y * advance]; + int offset = reverse ? x & 7 : 7 - (x & 7); + for (int hh = h; hh; --hh) { + *b = (*b & ~(0x01 << offset)) | ((col != 0) << offset); + b += advance; + } + ++x; + } +} + +// Functions for MVLSB format + +STATIC void mvlsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { + size_t index = (y >> 3) * fb->stride + x; + uint8_t offset = y & 0x07; + ((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((col != 0) << offset); +} + +STATIC uint32_t mvlsb_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { + return (((uint8_t*)fb->buf)[(y >> 3) * fb->stride + x] >> (y & 0x07)) & 0x01; +} + +STATIC void mvlsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { + while (h--) { + uint8_t *b = &((uint8_t*)fb->buf)[(y >> 3) * fb->stride + x]; + uint8_t offset = y & 0x07; + for (int ww = w; ww; --ww) { + *b = (*b & ~(0x01 << offset)) | ((col != 0) << offset); + ++b; + } + ++y; + } +} + +// Functions for RGB565 format + +STATIC void rgb565_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { + ((uint16_t*)fb->buf)[x + y * fb->stride] = col; +} + +STATIC uint32_t rgb565_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { + return ((uint16_t*)fb->buf)[x + y * fb->stride]; +} + +STATIC void rgb565_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { + uint16_t *b = &((uint16_t*)fb->buf)[x + y * fb->stride]; + while (h--) { + for (int ww = w; ww; --ww) { + *b++ = col; + } + b += fb->stride - w; + } +} + +// Functions for GS4_HMSB format + +STATIC void gs4_hmsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { + uint8_t *pixel = &((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1]; + + if (x % 2) { + *pixel = ((uint8_t)col & 0x0f) | (*pixel & 0xf0); + } else { + *pixel = ((uint8_t)col << 4) | (*pixel & 0x0f); + } +} + +STATIC uint32_t gs4_hmsb_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { + if (x % 2) { + return ((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1] & 0x0f; + } + + return ((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1] >> 4; +} + +STATIC void gs4_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { + col &= 0x0f; + uint8_t *pixel_pair = &((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1]; + uint8_t col_shifted_left = col << 4; + uint8_t col_pixel_pair = col_shifted_left | col; + int pixel_count_till_next_line = (fb->stride - w) >> 1; + bool odd_x = (x % 2 == 1); + + while (h--) { + int ww = w; + + if (odd_x && ww > 0) { + *pixel_pair = (*pixel_pair & 0xf0) | col; + pixel_pair++; + ww--; + } + + memset(pixel_pair, col_pixel_pair, ww >> 1); + pixel_pair += ww >> 1; + + if (ww % 2) { + *pixel_pair = col_shifted_left | (*pixel_pair & 0x0f); + if (!odd_x) { + pixel_pair++; + } + } + + pixel_pair += pixel_count_till_next_line; + } +} + +STATIC mp_framebuf_p_t formats[] = { + [FRAMEBUF_MVLSB] = {mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect}, + [FRAMEBUF_RGB565] = {rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect}, + [FRAMEBUF_GS4_HMSB] = {gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect}, + [FRAMEBUF_MHLSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, + [FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, +}; + +static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { + formats[fb->format].setpixel(fb, x, y, col); +} + +static inline uint32_t getpixel(const mp_obj_framebuf_t *fb, int x, int y) { + return formats[fb->format].getpixel(fb, x, y); +} + +STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { + if (h < 1 || w < 1 || x + w <= 0 || y + h <= 0 || y >= fb->height || x >= fb->width) { + // No operation needed. + return; + } + + // clip to the framebuffer + int xend = MIN(fb->width, x + w); + int yend = MIN(fb->height, y + h); + x = MAX(x, 0); + y = MAX(y, 0); + + formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col); +} + +STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 4, 5, false); + + mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t); + o->base.type = type; + o->buf_obj = args[0]; + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_WRITE); + o->buf = bufinfo.buf; + + o->width = mp_obj_get_int(args[1]); + o->height = mp_obj_get_int(args[2]); + o->format = mp_obj_get_int(args[3]); + if (n_args >= 5) { + o->stride = mp_obj_get_int(args[4]); + } else { + o->stride = o->width; + } + + switch (o->format) { + case FRAMEBUF_MVLSB: + case FRAMEBUF_RGB565: + break; + case FRAMEBUF_MHLSB: + case FRAMEBUF_MHMSB: + o->stride = (o->stride + 7) & ~7; + break; + case FRAMEBUF_GS4_HMSB: + o->stride = (o->stride + 1) & ~1; + break; + default: + mp_raise_ValueError("invalid format"); + } + + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + (void)flags; + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); + bufinfo->buf = self->buf; + bufinfo->len = self->stride * self->height * (self->format == FRAMEBUF_RGB565 ? 2 : 1); + bufinfo->typecode = 'B'; // view framebuf as bytes + return 0; +} + +STATIC mp_obj_t framebuf_fill(mp_obj_t self_in, mp_obj_t col_in) { + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t col = mp_obj_get_int(col_in); + formats[self->format].fill_rect(self, 0, 0, self->width, self->height, col); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(framebuf_fill_obj, framebuf_fill); + +STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) { + (void)n_args; + + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t x = mp_obj_get_int(args[1]); + mp_int_t y = mp_obj_get_int(args[2]); + mp_int_t width = mp_obj_get_int(args[3]); + mp_int_t height = mp_obj_get_int(args[4]); + mp_int_t col = mp_obj_get_int(args[5]); + + fill_rect(self, x, y, width, height, col); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_fill_rect_obj, 6, 6, framebuf_fill_rect); + +STATIC mp_obj_t framebuf_pixel(size_t n_args, const mp_obj_t *args) { + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t x = mp_obj_get_int(args[1]); + mp_int_t y = mp_obj_get_int(args[2]); + if (0 <= x && x < self->width && 0 <= y && y < self->height) { + if (n_args == 3) { + // get + return MP_OBJ_NEW_SMALL_INT(getpixel(self, x, y)); + } else { + // set + setpixel(self, x, y, mp_obj_get_int(args[3])); + } + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_pixel_obj, 3, 4, framebuf_pixel); + +STATIC mp_obj_t framebuf_hline(size_t n_args, const mp_obj_t *args) { + (void)n_args; + + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t x = mp_obj_get_int(args[1]); + mp_int_t y = mp_obj_get_int(args[2]); + mp_int_t w = mp_obj_get_int(args[3]); + mp_int_t col = mp_obj_get_int(args[4]); + + fill_rect(self, x, y, w, 1, col); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_hline_obj, 5, 5, framebuf_hline); + +STATIC mp_obj_t framebuf_vline(size_t n_args, const mp_obj_t *args) { + (void)n_args; + + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t x = mp_obj_get_int(args[1]); + mp_int_t y = mp_obj_get_int(args[2]); + mp_int_t h = mp_obj_get_int(args[3]); + mp_int_t col = mp_obj_get_int(args[4]); + + fill_rect(self, x, y, 1, h, col); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_vline_obj, 5, 5, framebuf_vline); + +STATIC mp_obj_t framebuf_rect(size_t n_args, const mp_obj_t *args) { + (void)n_args; + + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t x = mp_obj_get_int(args[1]); + mp_int_t y = mp_obj_get_int(args[2]); + mp_int_t w = mp_obj_get_int(args[3]); + mp_int_t h = mp_obj_get_int(args[4]); + mp_int_t col = mp_obj_get_int(args[5]); + + fill_rect(self, x, y, w, 1, col); + fill_rect(self, x, y + h- 1, w, 1, col); + fill_rect(self, x, y, 1, h, col); + fill_rect(self, x + w- 1, y, 1, h, col); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_rect_obj, 6, 6, framebuf_rect); + +STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) { + (void)n_args; + + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t x1 = mp_obj_get_int(args[1]); + mp_int_t y1 = mp_obj_get_int(args[2]); + mp_int_t x2 = mp_obj_get_int(args[3]); + mp_int_t y2 = mp_obj_get_int(args[4]); + mp_int_t col = mp_obj_get_int(args[5]); + + mp_int_t dx = x2 - x1; + mp_int_t sx; + if (dx > 0) { + sx = 1; + } else { + dx = -dx; + sx = -1; + } + + mp_int_t dy = y2 - y1; + mp_int_t sy; + if (dy > 0) { + sy = 1; + } else { + dy = -dy; + sy = -1; + } + + bool steep; + if (dy > dx) { + mp_int_t temp; + temp = x1; x1 = y1; y1 = temp; + temp = dx; dx = dy; dy = temp; + temp = sx; sx = sy; sy = temp; + steep = true; + } else { + steep = false; + } + + mp_int_t e = 2 * dy - dx; + for (mp_int_t i = 0; i < dx; ++i) { + if (steep) { + if (0 <= y1 && y1 < self->width && 0 <= x1 && x1 < self->height) { + setpixel(self, y1, x1, col); + } + } else { + if (0 <= x1 && x1 < self->width && 0 <= y1 && y1 < self->height) { + setpixel(self, x1, y1, col); + } + } + while (e >= 0) { + y1 += sy; + e -= 2 * dx; + } + x1 += sx; + e += 2 * dy; + } + + if (0 <= x2 && x2 < self->width && 0 <= y2 && y2 < self->height) { + setpixel(self, x2, y2, col); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_line_obj, 6, 6, framebuf_line); + +STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *source = MP_OBJ_TO_PTR(args[1]); + mp_int_t x = mp_obj_get_int(args[2]); + mp_int_t y = mp_obj_get_int(args[3]); + mp_int_t key = -1; + if (n_args > 4) { + key = mp_obj_get_int(args[4]); + } + + if ( + (x >= self->width) || + (y >= self->height) || + (-x >= source->width) || + (-y >= source->height) + ) { + // Out of bounds, no-op. + return mp_const_none; + } + + // Clip. + int x0 = MAX(0, x); + int y0 = MAX(0, y); + int x1 = MAX(0, -x); + int y1 = MAX(0, -y); + int x0end = MIN(self->width, x + source->width); + int y0end = MIN(self->height, y + source->height); + + for (; y0 < y0end; ++y0) { + int cx1 = x1; + for (int cx0 = x0; cx0 < x0end; ++cx0) { + uint32_t col = getpixel(source, cx1, y1); + if (col != (uint32_t)key) { + setpixel(self, cx0, y0, col); + } + ++cx1; + } + ++y1; + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 5, framebuf_blit); + +STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) { + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t xstep = mp_obj_get_int(xstep_in); + mp_int_t ystep = mp_obj_get_int(ystep_in); + int sx, y, xend, yend, dx, dy; + if (xstep < 0) { + sx = 0; + xend = self->width + xstep; + dx = 1; + } else { + sx = self->width - 1; + xend = xstep - 1; + dx = -1; + } + if (ystep < 0) { + y = 0; + yend = self->height + ystep; + dy = 1; + } else { + y = self->height - 1; + yend = ystep - 1; + dy = -1; + } + for (; y != yend; y += dy) { + for (int x = sx; x != xend; x += dx) { + setpixel(self, x, y, getpixel(self, x - xstep, y - ystep)); + } + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(framebuf_scroll_obj, framebuf_scroll); + +STATIC mp_obj_t framebuf_text(size_t n_args, const mp_obj_t *args) { + // extract arguments + mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + const char *str = mp_obj_str_get_str(args[1]); + mp_int_t x0 = mp_obj_get_int(args[2]); + mp_int_t y0 = mp_obj_get_int(args[3]); + mp_int_t col = 1; + if (n_args >= 5) { + col = mp_obj_get_int(args[4]); + } + + // loop over chars + for (; *str; ++str) { + // get char and make sure its in range of font + int chr = *(uint8_t*)str; + if (chr < 32 || chr > 127) { + chr = 127; + } + // get char data + const uint8_t *chr_data = &font_petme128_8x8[(chr - 32) * 8]; + // loop over char data + for (int j = 0; j < 8; j++, x0++) { + if (0 <= x0 && x0 < self->width) { // clip x + uint vline_data = chr_data[j]; // each byte is a column of 8 pixels, LSB at top + for (int y = y0; vline_data; vline_data >>= 1, y++) { // scan over vertical column + if (vline_data & 1) { // only draw if pixel set + if (0 <= y && y < self->height) { // clip y + setpixel(self, x0, y, col); + } + } + } + } + } + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_text_obj, 4, 5, framebuf_text); + +STATIC const mp_rom_map_elem_t framebuf_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&framebuf_fill_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill_rect), MP_ROM_PTR(&framebuf_fill_rect_obj) }, + { MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&framebuf_pixel_obj) }, + { MP_ROM_QSTR(MP_QSTR_hline), MP_ROM_PTR(&framebuf_hline_obj) }, + { MP_ROM_QSTR(MP_QSTR_vline), MP_ROM_PTR(&framebuf_vline_obj) }, + { MP_ROM_QSTR(MP_QSTR_rect), MP_ROM_PTR(&framebuf_rect_obj) }, + { MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&framebuf_line_obj) }, + { MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&framebuf_blit_obj) }, + { MP_ROM_QSTR(MP_QSTR_scroll), MP_ROM_PTR(&framebuf_scroll_obj) }, + { MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&framebuf_text_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(framebuf_locals_dict, framebuf_locals_dict_table); + +STATIC const mp_obj_type_t mp_type_framebuf = { + { &mp_type_type }, + .name = MP_QSTR_FrameBuffer, + .make_new = framebuf_make_new, + .buffer_p = { .get_buffer = framebuf_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&framebuf_locals_dict, +}; + +// this factory function is provided for backwards compatibility with old FrameBuffer1 class +STATIC mp_obj_t legacy_framebuffer1(size_t n_args, const mp_obj_t *args) { + mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t); + o->base.type = &mp_type_framebuf; + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_WRITE); + o->buf = bufinfo.buf; + + o->width = mp_obj_get_int(args[1]); + o->height = mp_obj_get_int(args[2]); + o->format = FRAMEBUF_MVLSB; + if (n_args >= 4) { + o->stride = mp_obj_get_int(args[3]); + } else { + o->stride = o->width; + } + + return MP_OBJ_FROM_PTR(o); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(legacy_framebuffer1_obj, 3, 4, legacy_framebuffer1); + +STATIC const mp_rom_map_elem_t framebuf_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_framebuf) }, + { MP_ROM_QSTR(MP_QSTR_FrameBuffer), MP_ROM_PTR(&mp_type_framebuf) }, + { MP_ROM_QSTR(MP_QSTR_FrameBuffer1), MP_ROM_PTR(&legacy_framebuffer1_obj) }, + { MP_ROM_QSTR(MP_QSTR_MVLSB), MP_ROM_INT(FRAMEBUF_MVLSB) }, + { MP_ROM_QSTR(MP_QSTR_MONO_VLSB), MP_ROM_INT(FRAMEBUF_MVLSB) }, + { MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_INT(FRAMEBUF_RGB565) }, + { MP_ROM_QSTR(MP_QSTR_GS4_HMSB), MP_ROM_INT(FRAMEBUF_GS4_HMSB) }, + { MP_ROM_QSTR(MP_QSTR_MONO_HLSB), MP_ROM_INT(FRAMEBUF_MHLSB) }, + { MP_ROM_QSTR(MP_QSTR_MONO_HMSB), MP_ROM_INT(FRAMEBUF_MHMSB) }, +}; + +STATIC MP_DEFINE_CONST_DICT(framebuf_module_globals, framebuf_module_globals_table); + +const mp_obj_module_t mp_module_framebuf = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&framebuf_module_globals, +}; + +#endif // MICROPY_PY_FRAMEBUF diff --git a/user/mpy/extmod/modlwip.c b/user/mpy/extmod/modlwip.c new file mode 100644 index 0000000..cc10523 --- /dev/null +++ b/user/mpy/extmod/modlwip.c @@ -0,0 +1,1380 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2015 Galen Hazelwood + * Copyright (c) 2015-2017 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/runtime.h" +#include "py/stream.h" +#include "py/mperrno.h" +#include "py/mphal.h" + +#include "lib/netutils/netutils.h" + +#include "lwip/init.h" +#include "lwip/timers.h" +#include "lwip/tcp.h" +#include "lwip/udp.h" +//#include "lwip/raw.h" +#include "lwip/dns.h" +#include "lwip/tcp_impl.h" +#include "lwip/igmp.h" + +#if 0 // print debugging info +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +// All socket options should be globally distinct, +// because we ignore option levels for efficiency. +#define IP_ADD_MEMBERSHIP 0x400 + +// For compatibilily with older lwIP versions. +#ifndef ip_set_option +#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) +#endif +#ifndef ip_reset_option +#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt)) +#endif + +#ifdef MICROPY_PY_LWIP_SLIP +#include "netif/slipif.h" +#include "lwip/sio.h" +#endif + +#ifdef MICROPY_PY_LWIP_SLIP +/******************************************************************************/ +// Slip object for modlwip. Requires a serial driver for the port that supports +// the lwip serial callback functions. + +typedef struct _lwip_slip_obj_t { + mp_obj_base_t base; + struct netif lwip_netif; +} lwip_slip_obj_t; + +// Slip object is unique for now. Possibly can fix this later. FIXME +STATIC lwip_slip_obj_t lwip_slip_obj; + +// Declare these early. +void mod_lwip_register_poll(void (*poll)(void *arg), void *poll_arg); +void mod_lwip_deregister_poll(void (*poll)(void *arg), void *poll_arg); + +STATIC void slip_lwip_poll(void *netif) { + slipif_poll((struct netif*)netif); +} + +STATIC const mp_obj_type_t lwip_slip_type; + +// lwIP SLIP callback functions +sio_fd_t sio_open(u8_t dvnum) { + // We support singleton SLIP interface, so just return any truish value. + return (sio_fd_t)1; +} + +void sio_send(u8_t c, sio_fd_t fd) { + mp_obj_type_t *type = mp_obj_get_type(MP_STATE_VM(lwip_slip_stream)); + int error; + type->stream_p->write(MP_STATE_VM(lwip_slip_stream), &c, 1, &error); +} + +u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len) { + mp_obj_type_t *type = mp_obj_get_type(MP_STATE_VM(lwip_slip_stream)); + int error; + mp_uint_t out_sz = type->stream_p->read(MP_STATE_VM(lwip_slip_stream), data, len, &error); + if (out_sz == MP_STREAM_ERROR) { + if (mp_is_nonblocking_error(error)) { + return 0; + } + // Can't do much else, can we? + return 0; + } + return out_sz; +} + +// constructor lwip.slip(device=integer, iplocal=string, ipremote=string) +STATIC mp_obj_t lwip_slip_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 3, 3, false); + + lwip_slip_obj.base.type = &lwip_slip_type; + + MP_STATE_VM(lwip_slip_stream) = args[0]; + + ip_addr_t iplocal, ipremote; + if (!ipaddr_aton(mp_obj_str_get_str(args[1]), &iplocal)) { + mp_raise_ValueError("not a valid local IP"); + } + if (!ipaddr_aton(mp_obj_str_get_str(args[2]), &ipremote)) { + mp_raise_ValueError("not a valid remote IP"); + } + + struct netif *n = &lwip_slip_obj.lwip_netif; + if (netif_add(n, &iplocal, IP_ADDR_BROADCAST, &ipremote, NULL, slipif_init, ip_input) == NULL) { + mp_raise_ValueError("out of memory"); + } + netif_set_up(n); + netif_set_default(n); + mod_lwip_register_poll(slip_lwip_poll, n); + + return (mp_obj_t)&lwip_slip_obj; +} + +STATIC mp_obj_t lwip_slip_status(mp_obj_t self_in) { + // Null function for now. + return mp_const_none; +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_1(lwip_slip_status_obj, lwip_slip_status); + +STATIC const mp_rom_map_elem_t lwip_slip_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_status), MP_ROM_PTR(&lwip_slip_status_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(lwip_slip_locals_dict, lwip_slip_locals_dict_table); + +STATIC const mp_obj_type_t lwip_slip_type = { + { &mp_type_type }, + .name = MP_QSTR_slip, + .make_new = lwip_slip_make_new, + .locals_dict = (mp_obj_dict_t*)&lwip_slip_locals_dict, +}; + +#endif // MICROPY_PY_LWIP_SLIP + +/******************************************************************************/ +// Table to convert lwIP err_t codes to socket errno codes, from the lwIP +// socket API. + +// Extension to lwIP error codes +#define _ERR_BADF -16 +// TODO: We just know that change happened somewhere between 1.4.0 and 1.4.1, +// investigate in more detail. +#if LWIP_VERSION < 0x01040100 +static const int error_lookup_table[] = { + 0, /* ERR_OK 0 No error, everything OK. */ + MP_ENOMEM, /* ERR_MEM -1 Out of memory error. */ + MP_ENOBUFS, /* ERR_BUF -2 Buffer error. */ + MP_EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */ + MP_EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ + MP_EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ + MP_EINVAL, /* ERR_VAL -6 Illegal value. */ + MP_EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ + + MP_ECONNABORTED, /* ERR_ABRT -8 Connection aborted. */ + MP_ECONNRESET, /* ERR_RST -9 Connection reset. */ + MP_ENOTCONN, /* ERR_CLSD -10 Connection closed. */ + MP_ENOTCONN, /* ERR_CONN -11 Not connected. */ + MP_EIO, /* ERR_ARG -12 Illegal argument. */ + MP_EADDRINUSE, /* ERR_USE -13 Address in use. */ + -1, /* ERR_IF -14 Low-level netif error */ + MP_EALREADY, /* ERR_ISCONN -15 Already connected. */ + MP_EBADF, /* _ERR_BADF -16 Closed socket (null pcb) */ +}; +#else +static const int error_lookup_table[] = { + 0, /* ERR_OK 0 No error, everything OK. */ + MP_ENOMEM, /* ERR_MEM -1 Out of memory error. */ + MP_ENOBUFS, /* ERR_BUF -2 Buffer error. */ + MP_EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */ + MP_EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ + MP_EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ + MP_EINVAL, /* ERR_VAL -6 Illegal value. */ + MP_EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ + + MP_EADDRINUSE, /* ERR_USE -8 Address in use. */ + MP_EALREADY, /* ERR_ISCONN -9 Already connected. */ + MP_ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */ + MP_ECONNRESET, /* ERR_RST -11 Connection reset. */ + MP_ENOTCONN, /* ERR_CLSD -12 Connection closed. */ + MP_ENOTCONN, /* ERR_CONN -13 Not connected. */ + MP_EIO, /* ERR_ARG -14 Illegal argument. */ + -1, /* ERR_IF -15 Low-level netif error */ + MP_EBADF, /* _ERR_BADF -16 Closed socket (null pcb) */ +}; +#endif + +/*******************************************************************************/ +// The socket object provided by lwip.socket. + +#define MOD_NETWORK_AF_INET (2) +#define MOD_NETWORK_AF_INET6 (10) + +#define MOD_NETWORK_SOCK_STREAM (1) +#define MOD_NETWORK_SOCK_DGRAM (2) +#define MOD_NETWORK_SOCK_RAW (3) + +typedef struct _lwip_socket_obj_t { + mp_obj_base_t base; + + volatile union { + struct tcp_pcb *tcp; + struct udp_pcb *udp; + } pcb; + volatile union { + struct pbuf *pbuf; + struct tcp_pcb *connection; + } incoming; + mp_obj_t callback; + byte peer[4]; + mp_uint_t peer_port; + mp_uint_t timeout; + uint16_t recv_offset; + + uint8_t domain; + uint8_t type; + + #define STATE_NEW 0 + #define STATE_CONNECTING 1 + #define STATE_CONNECTED 2 + #define STATE_PEER_CLOSED 3 + // Negative value is lwIP error + int8_t state; +} lwip_socket_obj_t; + +static inline void poll_sockets(void) { +#ifdef MICROPY_EVENT_POLL_HOOK + MICROPY_EVENT_POLL_HOOK; +#else + mp_hal_delay_ms(1); +#endif +} + +/*******************************************************************************/ +// Callback functions for the lwIP raw API. + +static inline void exec_user_callback(lwip_socket_obj_t *socket) { + if (socket->callback != MP_OBJ_NULL) { + mp_call_function_1_protected(socket->callback, socket); + } +} + +// Callback for incoming UDP packets. We simply stash the packet and the source address, +// in case we need it for recvfrom. +STATIC void _lwip_udp_incoming(void *arg, struct udp_pcb *upcb, struct pbuf *p, ip_addr_t *addr, u16_t port) { + lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; + + if (socket->incoming.pbuf != NULL) { + // That's why they call it "unreliable". No room in the inn, drop the packet. + pbuf_free(p); + } else { + socket->incoming.pbuf = p; + socket->peer_port = (mp_uint_t)port; + memcpy(&socket->peer, addr, sizeof(socket->peer)); + } +} + +// Callback for general tcp errors. +STATIC void _lwip_tcp_error(void *arg, err_t err) { + lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; + + // Pass the error code back via the connection variable. + socket->state = err; + // If we got here, the lwIP stack either has deallocated or will deallocate the pcb. + socket->pcb.tcp = NULL; +} + +// Callback for tcp connection requests. Error code err is unused. (See tcp.h) +STATIC err_t _lwip_tcp_connected(void *arg, struct tcp_pcb *tpcb, err_t err) { + lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; + + socket->state = STATE_CONNECTED; + return ERR_OK; +} + +// By default, a child socket of listen socket is created with recv +// handler which discards incoming pbuf's. We don't want to do that, +// so set this handler which requests lwIP to keep pbuf's and deliver +// them later. We cannot cache pbufs in child socket on Python side, +// until it is created in accept(). +STATIC err_t _lwip_tcp_recv_unaccepted(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { + return ERR_BUF; +} + +// "Poll" (idle) callback to be called ASAP after accept callback +// to execute Python callback function, as it can't be executed +// from accept callback itself. +STATIC err_t _lwip_tcp_accept_finished(void *arg, struct tcp_pcb *pcb) +{ + lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; + tcp_poll(pcb, NULL, 0); + exec_user_callback(socket); + return ERR_OK; +} + +// Callback for incoming tcp connections. +STATIC err_t _lwip_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err) { + lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; + tcp_recv(newpcb, _lwip_tcp_recv_unaccepted); + + if (socket->incoming.connection != NULL) { + DEBUG_printf("_lwip_tcp_accept: Tried to queue >1 pcb waiting for accept\n"); + // We need to handle this better. This single-level structure makes the + // backlog setting kind of pointless. FIXME + return ERR_BUF; + } else { + socket->incoming.connection = newpcb; + if (socket->callback != MP_OBJ_NULL) { + // Schedule accept callback to be called when lwIP is done + // with processing this incoming connection on its side and + // is idle. + tcp_poll(newpcb, _lwip_tcp_accept_finished, 1); + } + return ERR_OK; + } +} + +// Callback for inbound tcp packets. +STATIC err_t _lwip_tcp_recv(void *arg, struct tcp_pcb *tcpb, struct pbuf *p, err_t err) { + lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; + + if (p == NULL) { + // Other side has closed connection. + DEBUG_printf("_lwip_tcp_recv[%p]: other side closed connection\n", socket); + socket->state = STATE_PEER_CLOSED; + exec_user_callback(socket); + return ERR_OK; + } + + if (socket->incoming.pbuf == NULL) { + socket->incoming.pbuf = p; + } else { + #ifdef SOCKET_SINGLE_PBUF + return ERR_BUF; + #else + pbuf_cat(socket->incoming.pbuf, p); + #endif + } + + exec_user_callback(socket); + + return ERR_OK; +} + +/*******************************************************************************/ +// Functions for socket send/receive operations. Socket send/recv and friends call +// these to do the work. + +// Helper function for send/sendto to handle UDP packets. +STATIC mp_uint_t lwip_udp_send(lwip_socket_obj_t *socket, const byte *buf, mp_uint_t len, byte *ip, mp_uint_t port, int *_errno) { + if (len > 0xffff) { + // Any packet that big is probably going to fail the pbuf_alloc anyway, but may as well try + len = 0xffff; + } + + // FIXME: maybe PBUF_ROM? + struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM); + if (p == NULL) { + *_errno = MP_ENOMEM; + return -1; + } + + memcpy(p->payload, buf, len); + + err_t err; + if (ip == NULL) { + err = udp_send(socket->pcb.udp, p); + } else { + ip_addr_t dest; + IP4_ADDR(&dest, ip[0], ip[1], ip[2], ip[3]); + err = udp_sendto(socket->pcb.udp, p, &dest, port); + } + + pbuf_free(p); + + // udp_sendto can return 1 on occasion for ESP8266 port. It's not known why + // but it seems that the send actually goes through without error in this case. + // So we treat such cases as a success until further investigation. + if (err != ERR_OK && err != 1) { + *_errno = error_lookup_table[-err]; + return -1; + } + + return len; +} + +// Helper function for recv/recvfrom to handle UDP packets +STATIC mp_uint_t lwip_udp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_t len, byte *ip, mp_uint_t *port, int *_errno) { + + if (socket->incoming.pbuf == NULL) { + if (socket->timeout != -1) { + for (mp_uint_t retries = socket->timeout / 100; retries--;) { + mp_hal_delay_ms(100); + if (socket->incoming.pbuf != NULL) break; + } + if (socket->incoming.pbuf == NULL) { + *_errno = MP_ETIMEDOUT; + return -1; + } + } else { + while (socket->incoming.pbuf == NULL) { + poll_sockets(); + } + } + } + + if (ip != NULL) { + memcpy(ip, &socket->peer, sizeof(socket->peer)); + *port = socket->peer_port; + } + + struct pbuf *p = socket->incoming.pbuf; + + u16_t result = pbuf_copy_partial(p, buf, ((p->tot_len > len) ? len : p->tot_len), 0); + pbuf_free(p); + socket->incoming.pbuf = NULL; + + return (mp_uint_t) result; +} + +// For use in stream virtual methods +#define STREAM_ERROR_CHECK(socket) \ + if (socket->state < 0) { \ + *_errno = error_lookup_table[-socket->state]; \ + return MP_STREAM_ERROR; \ + } \ + assert(socket->pcb.tcp); + + +// Helper function for send/sendto to handle TCP packets +STATIC mp_uint_t lwip_tcp_send(lwip_socket_obj_t *socket, const byte *buf, mp_uint_t len, int *_errno) { + // Check for any pending errors + STREAM_ERROR_CHECK(socket); + + u16_t available = tcp_sndbuf(socket->pcb.tcp); + + if (available == 0) { + // Non-blocking socket + if (socket->timeout == 0) { + *_errno = MP_EAGAIN; + return MP_STREAM_ERROR; + } + + mp_uint_t start = mp_hal_ticks_ms(); + // Assume that STATE_PEER_CLOSED may mean half-closed connection, where peer closed it + // sending direction, but not receiving. Consequently, check for both STATE_CONNECTED + // and STATE_PEER_CLOSED as normal conditions and still waiting for buffers to be sent. + // If peer fully closed socket, we would have socket->state set to ERR_RST (connection + // reset) by error callback. + // Avoid sending too small packets, so wait until at least 16 bytes available + while (socket->state >= STATE_CONNECTED && (available = tcp_sndbuf(socket->pcb.tcp)) < 16) { + if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) { + *_errno = MP_ETIMEDOUT; + return MP_STREAM_ERROR; + } + poll_sockets(); + } + + // While we waited, something could happen + STREAM_ERROR_CHECK(socket); + } + + u16_t write_len = MIN(available, len); + + err_t err = tcp_write(socket->pcb.tcp, buf, write_len, TCP_WRITE_FLAG_COPY); + + if (err != ERR_OK) { + *_errno = error_lookup_table[-err]; + return MP_STREAM_ERROR; + } + + return write_len; +} + +// Helper function for recv/recvfrom to handle TCP packets +STATIC mp_uint_t lwip_tcp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_t len, int *_errno) { + // Check for any pending errors + STREAM_ERROR_CHECK(socket); + + if (socket->incoming.pbuf == NULL) { + + // Non-blocking socket + if (socket->timeout == 0) { + if (socket->state == STATE_PEER_CLOSED) { + return 0; + } + *_errno = MP_EAGAIN; + return -1; + } + + mp_uint_t start = mp_hal_ticks_ms(); + while (socket->state == STATE_CONNECTED && socket->incoming.pbuf == NULL) { + if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) { + *_errno = MP_ETIMEDOUT; + return -1; + } + poll_sockets(); + } + + if (socket->state == STATE_PEER_CLOSED) { + if (socket->incoming.pbuf == NULL) { + // socket closed and no data left in buffer + return 0; + } + } else if (socket->state != STATE_CONNECTED) { + assert(socket->state < 0); + *_errno = error_lookup_table[-socket->state]; + return -1; + } + } + + assert(socket->pcb.tcp != NULL); + + struct pbuf *p = socket->incoming.pbuf; + + mp_uint_t remaining = p->len - socket->recv_offset; + if (len > remaining) { + len = remaining; + } + + memcpy(buf, (byte*)p->payload + socket->recv_offset, len); + + remaining -= len; + if (remaining == 0) { + socket->incoming.pbuf = p->next; + // If we don't ref here, free() will free the entire chain, + // if we ref, it does what we need: frees 1st buf, and decrements + // next buf's refcount back to 1. + pbuf_ref(p->next); + pbuf_free(p); + socket->recv_offset = 0; + } else { + socket->recv_offset += len; + } + tcp_recved(socket->pcb.tcp, len); + + return len; +} + +/*******************************************************************************/ +// The socket functions provided by lwip.socket. + +STATIC const mp_obj_type_t lwip_socket_type; + +STATIC void lwip_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + lwip_socket_obj_t *self = self_in; + mp_printf(print, "", self->state, self->timeout, + self->incoming.pbuf, self->recv_offset); +} + +// FIXME: Only supports two arguments at present +STATIC mp_obj_t lwip_socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 4, false); + + lwip_socket_obj_t *socket = m_new_obj_with_finaliser(lwip_socket_obj_t); + socket->base.type = (mp_obj_t)&lwip_socket_type; + socket->domain = MOD_NETWORK_AF_INET; + socket->type = MOD_NETWORK_SOCK_STREAM; + socket->callback = MP_OBJ_NULL; + if (n_args >= 1) { + socket->domain = mp_obj_get_int(args[0]); + if (n_args >= 2) { + socket->type = mp_obj_get_int(args[1]); + } + } + + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: socket->pcb.tcp = tcp_new(); break; + case MOD_NETWORK_SOCK_DGRAM: socket->pcb.udp = udp_new(); break; + //case MOD_NETWORK_SOCK_RAW: socket->pcb.raw = raw_new(); break; + default: mp_raise_OSError(MP_EINVAL); + } + + if (socket->pcb.tcp == NULL) { + mp_raise_OSError(MP_ENOMEM); + } + + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + // Register the socket object as our callback argument. + tcp_arg(socket->pcb.tcp, (void*)socket); + // Register our error callback. + tcp_err(socket->pcb.tcp, _lwip_tcp_error); + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + // Register our receive callback now. Since UDP sockets don't require binding or connection + // before use, there's no other good time to do it. + udp_recv(socket->pcb.udp, _lwip_udp_incoming, (void*)socket); + break; + } + } + + socket->incoming.pbuf = NULL; + socket->timeout = -1; + socket->state = STATE_NEW; + socket->recv_offset = 0; + return socket; +} + +STATIC mp_obj_t lwip_socket_close(mp_obj_t self_in) { + lwip_socket_obj_t *socket = self_in; + bool socket_is_listener = false; + + if (socket->pcb.tcp == NULL) { + return mp_const_none; + } + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + if (socket->pcb.tcp->state == LISTEN) { + socket_is_listener = true; + } + if (tcp_close(socket->pcb.tcp) != ERR_OK) { + DEBUG_printf("lwip_close: had to call tcp_abort()\n"); + tcp_abort(socket->pcb.tcp); + } + break; + } + case MOD_NETWORK_SOCK_DGRAM: udp_remove(socket->pcb.udp); break; + //case MOD_NETWORK_SOCK_RAW: raw_remove(socket->pcb.raw); break; + } + socket->pcb.tcp = NULL; + socket->state = _ERR_BADF; + if (socket->incoming.pbuf != NULL) { + if (!socket_is_listener) { + pbuf_free(socket->incoming.pbuf); + } else { + tcp_abort(socket->incoming.connection); + } + socket->incoming.pbuf = NULL; + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(lwip_socket_close_obj, lwip_socket_close); + +STATIC mp_obj_t lwip_socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { + lwip_socket_obj_t *socket = self_in; + + uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; + mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); + + ip_addr_t bind_addr; + IP4_ADDR(&bind_addr, ip[0], ip[1], ip[2], ip[3]); + + err_t err = ERR_ARG; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + err = tcp_bind(socket->pcb.tcp, &bind_addr, port); + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + err = udp_bind(socket->pcb.udp, &bind_addr, port); + break; + } + } + + if (err != ERR_OK) { + mp_raise_OSError(error_lookup_table[-err]); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_bind_obj, lwip_socket_bind); + +STATIC mp_obj_t lwip_socket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { + lwip_socket_obj_t *socket = self_in; + mp_int_t backlog = mp_obj_get_int(backlog_in); + + if (socket->pcb.tcp == NULL) { + mp_raise_OSError(MP_EBADF); + } + if (socket->type != MOD_NETWORK_SOCK_STREAM) { + mp_raise_OSError(MP_EOPNOTSUPP); + } + + struct tcp_pcb *new_pcb = tcp_listen_with_backlog(socket->pcb.tcp, (u8_t)backlog); + if (new_pcb == NULL) { + mp_raise_OSError(MP_ENOMEM); + } + socket->pcb.tcp = new_pcb; + tcp_accept(new_pcb, _lwip_tcp_accept); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_listen_obj, lwip_socket_listen); + +STATIC mp_obj_t lwip_socket_accept(mp_obj_t self_in) { + lwip_socket_obj_t *socket = self_in; + + if (socket->pcb.tcp == NULL) { + mp_raise_OSError(MP_EBADF); + } + if (socket->type != MOD_NETWORK_SOCK_STREAM) { + mp_raise_OSError(MP_EOPNOTSUPP); + } + // I need to do this because "tcp_accepted", later, is a macro. + struct tcp_pcb *listener = socket->pcb.tcp; + if (listener->state != LISTEN) { + mp_raise_OSError(MP_EINVAL); + } + + // accept incoming connection + if (socket->incoming.connection == NULL) { + if (socket->timeout == 0) { + mp_raise_OSError(MP_EAGAIN); + } else if (socket->timeout != -1) { + for (mp_uint_t retries = socket->timeout / 100; retries--;) { + mp_hal_delay_ms(100); + if (socket->incoming.connection != NULL) break; + } + if (socket->incoming.connection == NULL) { + mp_raise_OSError(MP_ETIMEDOUT); + } + } else { + while (socket->incoming.connection == NULL) { + poll_sockets(); + } + } + } + + // create new socket object + lwip_socket_obj_t *socket2 = m_new_obj_with_finaliser(lwip_socket_obj_t); + socket2->base.type = (mp_obj_t)&lwip_socket_type; + + // We get a new pcb handle... + socket2->pcb.tcp = socket->incoming.connection; + socket->incoming.connection = NULL; + + // ...and set up the new socket for it. + socket2->domain = MOD_NETWORK_AF_INET; + socket2->type = MOD_NETWORK_SOCK_STREAM; + socket2->incoming.pbuf = NULL; + socket2->timeout = socket->timeout; + socket2->state = STATE_CONNECTED; + socket2->recv_offset = 0; + socket2->callback = MP_OBJ_NULL; + tcp_arg(socket2->pcb.tcp, (void*)socket2); + tcp_err(socket2->pcb.tcp, _lwip_tcp_error); + tcp_recv(socket2->pcb.tcp, _lwip_tcp_recv); + + tcp_accepted(listener); + + // make the return value + uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; + memcpy(ip, &(socket2->pcb.tcp->remote_ip), sizeof(ip)); + mp_uint_t port = (mp_uint_t)socket2->pcb.tcp->remote_port; + mp_obj_tuple_t *client = mp_obj_new_tuple(2, NULL); + client->items[0] = socket2; + client->items[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); + + return client; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(lwip_socket_accept_obj, lwip_socket_accept); + +STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { + lwip_socket_obj_t *socket = self_in; + + if (socket->pcb.tcp == NULL) { + mp_raise_OSError(MP_EBADF); + } + + // get address + uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; + mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); + + ip_addr_t dest; + IP4_ADDR(&dest, ip[0], ip[1], ip[2], ip[3]); + + err_t err = ERR_ARG; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + if (socket->state != STATE_NEW) { + if (socket->state == STATE_CONNECTED) { + mp_raise_OSError(MP_EISCONN); + } else { + mp_raise_OSError(MP_EALREADY); + } + } + // Register our receive callback. + tcp_recv(socket->pcb.tcp, _lwip_tcp_recv); + socket->state = STATE_CONNECTING; + err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected); + if (err != ERR_OK) { + socket->state = STATE_NEW; + mp_raise_OSError(error_lookup_table[-err]); + } + socket->peer_port = (mp_uint_t)port; + memcpy(socket->peer, &dest, sizeof(socket->peer)); + // And now we wait... + if (socket->timeout != -1) { + for (mp_uint_t retries = socket->timeout / 100; retries--;) { + mp_hal_delay_ms(100); + if (socket->state != STATE_CONNECTING) break; + } + if (socket->state == STATE_CONNECTING) { + mp_raise_OSError(MP_EINPROGRESS); + } + } else { + while (socket->state == STATE_CONNECTING) { + poll_sockets(); + } + } + if (socket->state == STATE_CONNECTED) { + err = ERR_OK; + } else { + err = socket->state; + } + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + err = udp_connect(socket->pcb.udp, &dest, port); + break; + } + } + + if (err != ERR_OK) { + mp_raise_OSError(error_lookup_table[-err]); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_connect_obj, lwip_socket_connect); + +STATIC void lwip_socket_check_connected(lwip_socket_obj_t *socket) { + if (socket->pcb.tcp == NULL) { + // not connected + int _errno = error_lookup_table[-socket->state]; + socket->state = _ERR_BADF; + mp_raise_OSError(_errno); + } +} + +STATIC mp_obj_t lwip_socket_send(mp_obj_t self_in, mp_obj_t buf_in) { + lwip_socket_obj_t *socket = self_in; + int _errno; + + lwip_socket_check_connected(socket); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); + + mp_uint_t ret = 0; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + ret = lwip_tcp_send(socket, bufinfo.buf, bufinfo.len, &_errno); + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + ret = lwip_udp_send(socket, bufinfo.buf, bufinfo.len, NULL, 0, &_errno); + break; + } + } + if (ret == -1) { + mp_raise_OSError(_errno); + } + + return mp_obj_new_int_from_uint(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_send_obj, lwip_socket_send); + +STATIC mp_obj_t lwip_socket_recv(mp_obj_t self_in, mp_obj_t len_in) { + lwip_socket_obj_t *socket = self_in; + int _errno; + + lwip_socket_check_connected(socket); + + mp_int_t len = mp_obj_get_int(len_in); + vstr_t vstr; + vstr_init_len(&vstr, len); + + mp_uint_t ret = 0; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + ret = lwip_tcp_receive(socket, (byte*)vstr.buf, len, &_errno); + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + ret = lwip_udp_receive(socket, (byte*)vstr.buf, len, NULL, NULL, &_errno); + break; + } + } + if (ret == -1) { + mp_raise_OSError(_errno); + } + + if (ret == 0) { + return mp_const_empty_bytes; + } + vstr.len = ret; + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_recv_obj, lwip_socket_recv); + +STATIC mp_obj_t lwip_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { + lwip_socket_obj_t *socket = self_in; + int _errno; + + lwip_socket_check_connected(socket); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_READ); + + uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; + mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); + + mp_uint_t ret = 0; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + ret = lwip_tcp_send(socket, bufinfo.buf, bufinfo.len, &_errno); + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + ret = lwip_udp_send(socket, bufinfo.buf, bufinfo.len, ip, port, &_errno); + break; + } + } + if (ret == -1) { + mp_raise_OSError(_errno); + } + + return mp_obj_new_int_from_uint(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(lwip_socket_sendto_obj, lwip_socket_sendto); + +STATIC mp_obj_t lwip_socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) { + lwip_socket_obj_t *socket = self_in; + int _errno; + + lwip_socket_check_connected(socket); + + mp_int_t len = mp_obj_get_int(len_in); + vstr_t vstr; + vstr_init_len(&vstr, len); + byte ip[4]; + mp_uint_t port; + + mp_uint_t ret = 0; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + memcpy(ip, &socket->peer, sizeof(socket->peer)); + port = (mp_uint_t) socket->peer_port; + ret = lwip_tcp_receive(socket, (byte*)vstr.buf, len, &_errno); + break; + } + case MOD_NETWORK_SOCK_DGRAM: { + ret = lwip_udp_receive(socket, (byte*)vstr.buf, len, ip, &port, &_errno); + break; + } + } + if (ret == -1) { + mp_raise_OSError(_errno); + } + + mp_obj_t tuple[2]; + if (ret == 0) { + tuple[0] = mp_const_empty_bytes; + } else { + vstr.len = ret; + tuple[0] = mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); + } + tuple[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); + return mp_obj_new_tuple(2, tuple); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_recvfrom_obj, lwip_socket_recvfrom); + +STATIC mp_obj_t lwip_socket_sendall(mp_obj_t self_in, mp_obj_t buf_in) { + lwip_socket_obj_t *socket = self_in; + lwip_socket_check_connected(socket); + + int _errno; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); + + mp_uint_t ret = 0; + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: { + if (socket->timeout == 0) { + // Behavior of sendall() for non-blocking sockets isn't explicitly specified. + // But it's specified that "On error, an exception is raised, there is no + // way to determine how much data, if any, was successfully sent." Then, the + // most useful behavior is: check whether we will be able to send all of input + // data without EAGAIN, and if won't be, raise it without sending any. + if (bufinfo.len > tcp_sndbuf(socket->pcb.tcp)) { + mp_raise_OSError(MP_EAGAIN); + } + } + // TODO: In CPython3.5, socket timeout should apply to the + // entire sendall() operation, not to individual send() chunks. + while (bufinfo.len != 0) { + ret = lwip_tcp_send(socket, bufinfo.buf, bufinfo.len, &_errno); + if (ret == -1) { + mp_raise_OSError(_errno); + } + bufinfo.len -= ret; + bufinfo.buf = (char*)bufinfo.buf + ret; + } + break; + } + case MOD_NETWORK_SOCK_DGRAM: + mp_raise_NotImplementedError(""); + break; + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_sendall_obj, lwip_socket_sendall); + +STATIC mp_obj_t lwip_socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { + lwip_socket_obj_t *socket = self_in; + mp_uint_t timeout; + if (timeout_in == mp_const_none) { + timeout = -1; + } else { + #if MICROPY_PY_BUILTINS_FLOAT + timeout = 1000 * mp_obj_get_float(timeout_in); + #else + timeout = 1000 * mp_obj_get_int(timeout_in); + #endif + } + socket->timeout = timeout; + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_settimeout_obj, lwip_socket_settimeout); + +STATIC mp_obj_t lwip_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { + lwip_socket_obj_t *socket = self_in; + bool val = mp_obj_is_true(flag_in); + if (val) { + socket->timeout = -1; + } else { + socket->timeout = 0; + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_setblocking_obj, lwip_socket_setblocking); + +STATIC mp_obj_t lwip_socket_setsockopt(mp_uint_t n_args, const mp_obj_t *args) { + (void)n_args; // always 4 + lwip_socket_obj_t *socket = args[0]; + + int opt = mp_obj_get_int(args[2]); + if (opt == 20) { + if (args[3] == mp_const_none) { + socket->callback = MP_OBJ_NULL; + } else { + socket->callback = args[3]; + } + return mp_const_none; + } + + switch (opt) { + // level: SOL_SOCKET + case SOF_REUSEADDR: { + mp_int_t val = mp_obj_get_int(args[3]); + // Options are common for UDP and TCP pcb's. + if (val) { + ip_set_option(socket->pcb.tcp, SOF_REUSEADDR); + } else { + ip_reset_option(socket->pcb.tcp, SOF_REUSEADDR); + } + break; + } + + // level: IPPROTO_IP + case IP_ADD_MEMBERSHIP: { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); + if (bufinfo.len != sizeof(ip_addr_t) * 2) { + mp_raise_ValueError(NULL); + } + + // POSIX setsockopt has order: group addr, if addr, lwIP has it vice-versa + err_t err = igmp_joingroup((ip_addr_t*)bufinfo.buf + 1, bufinfo.buf); + if (err != ERR_OK) { + mp_raise_OSError(error_lookup_table[-err]); + } + break; + } + + default: + printf("Warning: lwip.setsockopt() not implemented\n"); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_socket_setsockopt_obj, 4, 4, lwip_socket_setsockopt); + +STATIC mp_obj_t lwip_socket_makefile(mp_uint_t n_args, const mp_obj_t *args) { + (void)n_args; + return args[0]; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_socket_makefile_obj, 1, 3, lwip_socket_makefile); + +STATIC mp_uint_t lwip_socket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + lwip_socket_obj_t *socket = self_in; + + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: + return lwip_tcp_receive(socket, buf, size, errcode); + case MOD_NETWORK_SOCK_DGRAM: + return lwip_udp_receive(socket, buf, size, NULL, NULL, errcode); + } + // Unreachable + return MP_STREAM_ERROR; +} + +STATIC mp_uint_t lwip_socket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + lwip_socket_obj_t *socket = self_in; + + switch (socket->type) { + case MOD_NETWORK_SOCK_STREAM: + return lwip_tcp_send(socket, buf, size, errcode); + case MOD_NETWORK_SOCK_DGRAM: + return lwip_udp_send(socket, buf, size, NULL, 0, errcode); + } + // Unreachable + return MP_STREAM_ERROR; +} + +STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { + lwip_socket_obj_t *socket = self_in; + mp_uint_t ret; + + if (request == MP_STREAM_POLL) { + uintptr_t flags = arg; + ret = 0; + + if (flags & MP_STREAM_POLL_RD && socket->incoming.pbuf != NULL) { + ret |= MP_STREAM_POLL_RD; + } + + if (flags & MP_STREAM_POLL_WR && tcp_sndbuf(socket->pcb.tcp) > 0) { + ret |= MP_STREAM_POLL_WR; + } + + if (socket->state == STATE_PEER_CLOSED) { + // Peer-closed socket is both readable and writable: read will + // return EOF, write - error. Without this poll will hang on a + // socket which was closed by peer. + ret |= flags & (MP_STREAM_POLL_RD | MP_STREAM_POLL_WR); + } + + } else { + *errcode = MP_EINVAL; + ret = MP_STREAM_ERROR; + } + + return ret; +} + +STATIC const mp_rom_map_elem_t lwip_socket_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&lwip_socket_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&lwip_socket_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&lwip_socket_bind_obj) }, + { MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&lwip_socket_listen_obj) }, + { MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&lwip_socket_accept_obj) }, + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&lwip_socket_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&lwip_socket_send_obj) }, + { MP_ROM_QSTR(MP_QSTR_recv), MP_ROM_PTR(&lwip_socket_recv_obj) }, + { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&lwip_socket_sendto_obj) }, + { MP_ROM_QSTR(MP_QSTR_recvfrom), MP_ROM_PTR(&lwip_socket_recvfrom_obj) }, + { MP_ROM_QSTR(MP_QSTR_sendall), MP_ROM_PTR(&lwip_socket_sendall_obj) }, + { MP_ROM_QSTR(MP_QSTR_settimeout), MP_ROM_PTR(&lwip_socket_settimeout_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&lwip_socket_setblocking_obj) }, + { MP_ROM_QSTR(MP_QSTR_setsockopt), MP_ROM_PTR(&lwip_socket_setsockopt_obj) }, + { MP_ROM_QSTR(MP_QSTR_makefile), MP_ROM_PTR(&lwip_socket_makefile_obj) }, + + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table); + +STATIC const mp_stream_p_t lwip_socket_stream_p = { + .read = lwip_socket_read, + .write = lwip_socket_write, + .ioctl = lwip_socket_ioctl, +}; + +STATIC const mp_obj_type_t lwip_socket_type = { + { &mp_type_type }, + .name = MP_QSTR_socket, + .print = lwip_socket_print, + .make_new = lwip_socket_make_new, + .protocol = &lwip_socket_stream_p, + .locals_dict = (mp_obj_dict_t*)&lwip_socket_locals_dict, +}; + +/******************************************************************************/ +// Support functions for memory protection. lwIP has its own memory management +// routines for its internal structures, and since they might be called in +// interrupt handlers, they need some protection. +sys_prot_t sys_arch_protect() { + return (sys_prot_t)MICROPY_BEGIN_ATOMIC_SECTION(); +} + +void sys_arch_unprotect(sys_prot_t state) { + MICROPY_END_ATOMIC_SECTION((mp_uint_t)state); +} + +/******************************************************************************/ +// Polling callbacks for the interfaces connected to lwIP. Right now it calls +// itself a "list" but isn't; we only support a single interface. + +typedef struct nic_poll { + void (* poll)(void *arg); + void *poll_arg; +} nic_poll_t; + +STATIC nic_poll_t lwip_poll_list; + +void mod_lwip_register_poll(void (* poll)(void *arg), void *poll_arg) { + lwip_poll_list.poll = poll; + lwip_poll_list.poll_arg = poll_arg; +} + +void mod_lwip_deregister_poll(void (* poll)(void *arg), void *poll_arg) { + lwip_poll_list.poll = NULL; +} + +/******************************************************************************/ +// The lwip global functions. + +STATIC mp_obj_t mod_lwip_reset() { + lwip_init(); + lwip_poll_list.poll = NULL; + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(mod_lwip_reset_obj, mod_lwip_reset); + +STATIC mp_obj_t mod_lwip_callback() { + if (lwip_poll_list.poll != NULL) { + lwip_poll_list.poll(lwip_poll_list.poll_arg); + } + sys_check_timeouts(); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(mod_lwip_callback_obj, mod_lwip_callback); + +typedef struct _getaddrinfo_state_t { + volatile int status; + volatile ip_addr_t ipaddr; +} getaddrinfo_state_t; + +// Callback for incoming DNS requests. +STATIC void lwip_getaddrinfo_cb(const char *name, ip_addr_t *ipaddr, void *arg) { + getaddrinfo_state_t *state = arg; + if (ipaddr != NULL) { + state->status = 1; + state->ipaddr = *ipaddr; + } else { + // error + state->status = -2; + } +} + +// lwip.getaddrinfo +STATIC mp_obj_t lwip_getaddrinfo(size_t n_args, const mp_obj_t *args) { + if (n_args > 2) { + mp_warning("getaddrinfo constraints not supported"); + } + + mp_obj_t host_in = args[0], port_in = args[1]; + const char *host = mp_obj_str_get_str(host_in); + mp_int_t port = mp_obj_get_int(port_in); + + getaddrinfo_state_t state; + state.status = 0; + + err_t ret = dns_gethostbyname(host, (ip_addr_t*)&state.ipaddr, lwip_getaddrinfo_cb, &state); + switch (ret) { + case ERR_OK: + // cached + state.status = 1; + break; + case ERR_INPROGRESS: + while (state.status == 0) { + poll_sockets(); + } + break; + default: + state.status = ret; + } + + if (state.status < 0) { + // TODO: CPython raises gaierror, we raise with native lwIP negative error + // values, to differentiate from normal errno's at least in such way. + mp_raise_OSError(state.status); + } + + mp_obj_tuple_t *tuple = mp_obj_new_tuple(5, NULL); + tuple->items[0] = MP_OBJ_NEW_SMALL_INT(MOD_NETWORK_AF_INET); + tuple->items[1] = MP_OBJ_NEW_SMALL_INT(MOD_NETWORK_SOCK_STREAM); + tuple->items[2] = MP_OBJ_NEW_SMALL_INT(0); + tuple->items[3] = MP_OBJ_NEW_QSTR(MP_QSTR_); + tuple->items[4] = netutils_format_inet_addr((uint8_t*)&state.ipaddr, port, NETUTILS_BIG); + return mp_obj_new_list(1, (mp_obj_t*)&tuple); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_getaddrinfo_obj, 2, 6, lwip_getaddrinfo); + +// Debug functions + +STATIC mp_obj_t lwip_print_pcbs() { + tcp_debug_print_pcbs(); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(lwip_print_pcbs_obj, lwip_print_pcbs); + +#ifdef MICROPY_PY_LWIP + +STATIC const mp_rom_map_elem_t mp_module_lwip_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_lwip) }, + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mod_lwip_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&mod_lwip_callback_obj) }, + { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&lwip_getaddrinfo_obj) }, + { MP_ROM_QSTR(MP_QSTR_print_pcbs), MP_ROM_PTR(&lwip_print_pcbs_obj) }, + // objects + { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&lwip_socket_type) }, +#ifdef MICROPY_PY_LWIP_SLIP + { MP_ROM_QSTR(MP_QSTR_slip), MP_ROM_PTR(&lwip_slip_type) }, +#endif + // class constants + { MP_ROM_QSTR(MP_QSTR_AF_INET), MP_ROM_INT(MOD_NETWORK_AF_INET) }, + { MP_ROM_QSTR(MP_QSTR_AF_INET6), MP_ROM_INT(MOD_NETWORK_AF_INET6) }, + + { MP_ROM_QSTR(MP_QSTR_SOCK_STREAM), MP_ROM_INT(MOD_NETWORK_SOCK_STREAM) }, + { MP_ROM_QSTR(MP_QSTR_SOCK_DGRAM), MP_ROM_INT(MOD_NETWORK_SOCK_DGRAM) }, + { MP_ROM_QSTR(MP_QSTR_SOCK_RAW), MP_ROM_INT(MOD_NETWORK_SOCK_RAW) }, + + { MP_ROM_QSTR(MP_QSTR_SOL_SOCKET), MP_ROM_INT(1) }, + { MP_ROM_QSTR(MP_QSTR_SO_REUSEADDR), MP_ROM_INT(SOF_REUSEADDR) }, + + { MP_ROM_QSTR(MP_QSTR_IPPROTO_IP), MP_ROM_INT(0) }, + { MP_ROM_QSTR(MP_QSTR_IP_ADD_MEMBERSHIP), MP_ROM_INT(IP_ADD_MEMBERSHIP) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_lwip_globals, mp_module_lwip_globals_table); + +const mp_obj_module_t mp_module_lwip = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_lwip_globals, +}; + +#endif // MICROPY_PY_LWIP diff --git a/user/mpy/extmod/modonewire.c b/user/mpy/extmod/modonewire.c new file mode 100644 index 0000000..53c9456 --- /dev/null +++ b/user/mpy/extmod/modonewire.c @@ -0,0 +1,162 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015-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. + */ + +#include +#include + +#include "py/obj.h" +#include "py/mphal.h" + +/******************************************************************************/ +// Low-level 1-Wire routines + +#define TIMING_RESET1 (480) +#define TIMING_RESET2 (40) +#define TIMING_RESET3 (420) +#define TIMING_READ1 (5) +#define TIMING_READ2 (5) +#define TIMING_READ3 (40) +#define TIMING_WRITE1 (10) +#define TIMING_WRITE2 (50) +#define TIMING_WRITE3 (10) + +STATIC int onewire_bus_reset(mp_hal_pin_obj_t pin) { + mp_hal_pin_write(pin, 0); + mp_hal_delay_us(TIMING_RESET1); + uint32_t i = mp_hal_quiet_timing_enter(); + mp_hal_pin_write(pin, 1); + mp_hal_delay_us_fast(TIMING_RESET2); + int status = !mp_hal_pin_read(pin); + mp_hal_quiet_timing_exit(i); + mp_hal_delay_us(TIMING_RESET3); + return status; +} + +STATIC int onewire_bus_readbit(mp_hal_pin_obj_t pin) { + mp_hal_pin_write(pin, 1); + uint32_t i = mp_hal_quiet_timing_enter(); + mp_hal_pin_write(pin, 0); + mp_hal_delay_us_fast(TIMING_READ1); + mp_hal_pin_write(pin, 1); + mp_hal_delay_us_fast(TIMING_READ2); + int value = mp_hal_pin_read(pin); + mp_hal_quiet_timing_exit(i); + mp_hal_delay_us_fast(TIMING_READ3); + return value; +} + +STATIC void onewire_bus_writebit(mp_hal_pin_obj_t pin, int value) { + uint32_t i = mp_hal_quiet_timing_enter(); + mp_hal_pin_write(pin, 0); + mp_hal_delay_us_fast(TIMING_WRITE1); + if (value) { + mp_hal_pin_write(pin, 1); + } + mp_hal_delay_us_fast(TIMING_WRITE2); + mp_hal_pin_write(pin, 1); + mp_hal_delay_us_fast(TIMING_WRITE3); + mp_hal_quiet_timing_exit(i); +} + +/******************************************************************************/ +// MicroPython bindings + +STATIC mp_obj_t onewire_reset(mp_obj_t pin_in) { + return mp_obj_new_bool(onewire_bus_reset(mp_hal_get_pin_obj(pin_in))); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_reset_obj, onewire_reset); + +STATIC mp_obj_t onewire_readbit(mp_obj_t pin_in) { + return MP_OBJ_NEW_SMALL_INT(onewire_bus_readbit(mp_hal_get_pin_obj(pin_in))); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_readbit_obj, onewire_readbit); + +STATIC mp_obj_t onewire_readbyte(mp_obj_t pin_in) { + mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(pin_in); + uint8_t value = 0; + for (int i = 0; i < 8; ++i) { + value |= onewire_bus_readbit(pin) << i; + } + return MP_OBJ_NEW_SMALL_INT(value); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_readbyte_obj, onewire_readbyte); + +STATIC mp_obj_t onewire_writebit(mp_obj_t pin_in, mp_obj_t value_in) { + onewire_bus_writebit(mp_hal_get_pin_obj(pin_in), mp_obj_get_int(value_in)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(onewire_writebit_obj, onewire_writebit); + +STATIC mp_obj_t onewire_writebyte(mp_obj_t pin_in, mp_obj_t value_in) { + mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(pin_in); + int value = mp_obj_get_int(value_in); + for (int i = 0; i < 8; ++i) { + onewire_bus_writebit(pin, value & 1); + value >>= 1; + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(onewire_writebyte_obj, onewire_writebyte); + +STATIC mp_obj_t onewire_crc8(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); + uint8_t crc = 0; + for (size_t i = 0; i < bufinfo.len; ++i) { + uint8_t byte = ((uint8_t*)bufinfo.buf)[i]; + for (int b = 0; b < 8; ++b) { + uint8_t fb_bit = (crc ^ byte) & 0x01; + if (fb_bit == 0x01) { + crc = crc ^ 0x18; + } + crc = (crc >> 1) & 0x7f; + if (fb_bit == 0x01) { + crc = crc | 0x80; + } + byte = byte >> 1; + } + } + return MP_OBJ_NEW_SMALL_INT(crc); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_crc8_obj, onewire_crc8); + +STATIC const mp_rom_map_elem_t onewire_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_onewire) }, + + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&onewire_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_readbit), MP_ROM_PTR(&onewire_readbit_obj) }, + { MP_ROM_QSTR(MP_QSTR_readbyte), MP_ROM_PTR(&onewire_readbyte_obj) }, + { MP_ROM_QSTR(MP_QSTR_writebit), MP_ROM_PTR(&onewire_writebit_obj) }, + { MP_ROM_QSTR(MP_QSTR_writebyte), MP_ROM_PTR(&onewire_writebyte_obj) }, + { MP_ROM_QSTR(MP_QSTR_crc8), MP_ROM_PTR(&onewire_crc8_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(onewire_module_globals, onewire_module_globals_table); + +const mp_obj_module_t mp_module_onewire = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&onewire_module_globals, +}; diff --git a/user/mpy/extmod/modubinascii.c b/user/mpy/extmod/modubinascii.c new file mode 100644 index 0000000..d3092a4 --- /dev/null +++ b/user/mpy/extmod/modubinascii.c @@ -0,0 +1,244 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/binary.h" +#include "extmod/modubinascii.h" + +#include "uzlib/tinf.h" + +mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { + // Second argument is for an extension to allow a separator to be used + // between values. + const char *sep = NULL; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); + + // Code below assumes non-zero buffer length when computing size with + // separator, so handle the zero-length case here. + if (bufinfo.len == 0) { + return mp_const_empty_bytes; + } + + vstr_t vstr; + size_t out_len = bufinfo.len * 2; + if (n_args > 1) { + // 1-char separator between hex numbers + out_len += bufinfo.len - 1; + sep = mp_obj_str_get_str(args[1]); + } + vstr_init_len(&vstr, out_len); + byte *in = bufinfo.buf, *out = (byte*)vstr.buf; + for (mp_uint_t i = bufinfo.len; i--;) { + byte d = (*in >> 4); + if (d > 9) { + d += 'a' - '9' - 1; + } + *out++ = d + '0'; + d = (*in++ & 0xf); + if (d > 9) { + d += 'a' - '9' - 1; + } + *out++ = d + '0'; + if (sep != NULL && i != 0) { + *out++ = *sep; + } + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj, 1, 2, mod_binascii_hexlify); + +mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); + + if ((bufinfo.len & 1) != 0) { + mp_raise_ValueError("odd-length string"); + } + vstr_t vstr; + vstr_init_len(&vstr, bufinfo.len / 2); + byte *in = bufinfo.buf, *out = (byte*)vstr.buf; + byte hex_byte = 0; + for (mp_uint_t i = bufinfo.len; i--;) { + byte hex_ch = *in++; + if (unichar_isxdigit(hex_ch)) { + hex_byte += unichar_xdigit_value(hex_ch); + } else { + mp_raise_ValueError("non-hex digit found"); + } + if (i & 1) { + hex_byte <<= 4; + } else { + *out++ = hex_byte; + hex_byte = 0; + } + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj, mod_binascii_unhexlify); + +mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); + if (bufinfo.len % 4 != 0) { + mp_raise_ValueError("incorrect padding"); + } + + vstr_t vstr; + byte *in = bufinfo.buf; + if (bufinfo.len == 0) { + vstr_init_len(&vstr, 0); + } + else { + vstr_init_len(&vstr, ((bufinfo.len / 4) * 3) - ((in[bufinfo.len-1] == '=') ? ((in[bufinfo.len-2] == '=') ? 2 : 1 ) : 0)); + } + byte *out = (byte*)vstr.buf; + for (mp_uint_t i = bufinfo.len; i; i -= 4) { + char hold[4]; + for (int j = 4; j--;) { + if (in[j] >= 'A' && in[j] <= 'Z') { + hold[j] = in[j] - 'A'; + } else if (in[j] >= 'a' && in[j] <= 'z') { + hold[j] = in[j] - 'a' + 26; + } else if (in[j] >= '0' && in[j] <= '9') { + hold[j] = in[j] - '0' + 52; + } else if (in[j] == '+') { + hold[j] = 62; + } else if (in[j] == '/') { + hold[j] = 63; + } else if (in[j] == '=') { + if (j < 2 || i > 4) { + mp_raise_ValueError("incorrect padding"); + } + hold[j] = 64; + } else { + mp_raise_ValueError("invalid character"); + } + } + in += 4; + + *out++ = (hold[0]) << 2 | (hold[1]) >> 4; + if (hold[2] != 64) { + *out++ = (hold[1] & 0x0F) << 4 | hold[2] >> 2; + if (hold[3] != 64) { + *out++ = (hold[2] & 0x03) << 6 | hold[3]; + } + } + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj, mod_binascii_a2b_base64); + +mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); + + vstr_t vstr; + vstr_init_len(&vstr, ((bufinfo.len != 0) ? (((bufinfo.len - 1) / 3) + 1) * 4 : 0) + 1); + + // First pass, we convert input buffer to numeric base 64 values + byte *in = bufinfo.buf, *out = (byte*)vstr.buf; + mp_uint_t i; + for (i = bufinfo.len; i >= 3; i -= 3) { + *out++ = (in[0] & 0xFC) >> 2; + *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; + *out++ = (in[1] & 0x0F) << 2 | (in[2] & 0xC0) >> 6; + *out++ = in[2] & 0x3F; + in += 3; + } + if (i != 0) { + *out++ = (in[0] & 0xFC) >> 2; + if (i == 2) { + *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; + *out++ = (in[1] & 0x0F) << 2; + } + else { + *out++ = (in[0] & 0x03) << 4; + *out++ = 64; + } + *out++ = 64; + } + + // Second pass, we convert number base 64 values to actual base64 ascii encoding + out = (byte*)vstr.buf; + for (mp_uint_t j = vstr.len - 1; j--;) { + if (*out < 26) { + *out += 'A'; + } else if (*out < 52) { + *out += 'a' - 26; + } else if (*out < 62) { + *out += '0' - 52; + } else if (*out == 62) { + *out ='+'; + } else if (*out == 63) { + *out = '/'; + } else { + *out = '='; + } + out++; + } + *out = '\n'; + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64); + +#if MICROPY_PY_UBINASCII_CRC32 +mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); + uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0; + crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); + return mp_obj_new_int_from_uint(crc ^ 0xffffffff); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32); +#endif + +#if MICROPY_PY_UBINASCII + +STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubinascii) }, + { MP_ROM_QSTR(MP_QSTR_hexlify), MP_ROM_PTR(&mod_binascii_hexlify_obj) }, + { MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&mod_binascii_unhexlify_obj) }, + { MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) }, + { MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) }, + #if MICROPY_PY_UBINASCII_CRC32 + { MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); + +const mp_obj_module_t mp_module_ubinascii = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_binascii_globals, +}; + +#endif //MICROPY_PY_UBINASCII diff --git a/user/mpy/extmod/modubinascii.h b/user/mpy/extmod/modubinascii.h new file mode 100644 index 0000000..fb31692 --- /dev/null +++ b/user/mpy/extmod/modubinascii.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ +#ifndef MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H +#define MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H + +extern mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args); +extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data); +extern mp_obj_t mod_binascii_a2b_base64(mp_obj_t data); +extern mp_obj_t mod_binascii_b2a_base64(mp_obj_t data); +extern mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args); + +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj); + +#endif // MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H diff --git a/user/mpy/extmod/moductypes.c b/user/mpy/extmod/moductypes.c new file mode 100644 index 0000000..dc03f6d --- /dev/null +++ b/user/mpy/extmod/moductypes.c @@ -0,0 +1,716 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/objtuple.h" +#include "py/binary.h" + +#if MICROPY_PY_UCTYPES + +/// \module uctypes - Access data structures in memory +/// +/// The module allows to define layout of raw data structure (using terms +/// of C language), and then access memory buffers using this definition. +/// The module also provides convenience functions to access memory buffers +/// contained in Python objects or wrap memory buffers in Python objects. +/// \constant UINT8_1 - uint8_t value type + +/// \class struct - C-like structure +/// +/// Encapsulalation of in-memory data structure. This class doesn't define +/// any methods, only attribute access (for structure fields) and +/// indexing (for pointer and array fields). +/// +/// Usage: +/// +/// # Define layout of a structure with 2 fields +/// # 0 and 4 are byte offsets of fields from the beginning of struct +/// # they are logically ORed with field type +/// FOO_STRUCT = {"a": 0 | uctypes.UINT32, "b": 4 | uctypes.UINT8} +/// +/// # Example memory buffer to access (contained in bytes object) +/// buf = b"\x64\0\0\0\0x14" +/// +/// # Create structure object referring to address of +/// # the data in the buffer above +/// s = uctypes.struct(FOO_STRUCT, uctypes.addressof(buf)) +/// +/// # Access fields +/// print(s.a, s.b) +/// # Result: +/// # 100, 20 + +#define LAYOUT_LITTLE_ENDIAN (0) +#define LAYOUT_BIG_ENDIAN (1) +#define LAYOUT_NATIVE (2) + +#define VAL_TYPE_BITS 4 +#define BITF_LEN_BITS 5 +#define BITF_OFF_BITS 5 +#define OFFSET_BITS 17 +#if VAL_TYPE_BITS + BITF_LEN_BITS + BITF_OFF_BITS + OFFSET_BITS != 31 +#error Invalid encoding field length +#endif + +enum { + UINT8, INT8, UINT16, INT16, + UINT32, INT32, UINT64, INT64, + + BFUINT8, BFINT8, BFUINT16, BFINT16, + BFUINT32, BFINT32, + + FLOAT32, FLOAT64, +}; + +#define AGG_TYPE_BITS 2 + +enum { + STRUCT, PTR, ARRAY, BITFIELD, +}; + +// Here we need to set sign bit right +#define TYPE2SMALLINT(x, nbits) ((((int)x) << (32 - nbits)) >> 1) +#define GET_TYPE(x, nbits) (((x) >> (31 - nbits)) & ((1 << nbits) - 1)) +// Bit 0 is "is_signed" +#define GET_SCALAR_SIZE(val_type) (1 << ((val_type) >> 1)) +#define VALUE_MASK(type_nbits) ~((int)0x80000000 >> type_nbits) + +#define IS_SCALAR_ARRAY(tuple_desc) ((tuple_desc)->len == 2) +// We cannot apply the below to INT8, as their range [-128, 127] +#define IS_SCALAR_ARRAY_OF_BYTES(tuple_desc) (GET_TYPE(MP_OBJ_SMALL_INT_VALUE((tuple_desc)->items[1]), VAL_TYPE_BITS) == UINT8) + +// "struct" in uctypes context means "structural", i.e. aggregate, type. +STATIC const mp_obj_type_t uctypes_struct_type; + +typedef struct _mp_obj_uctypes_struct_t { + mp_obj_base_t base; + mp_obj_t desc; + byte *addr; + uint32_t flags; +} mp_obj_uctypes_struct_t; + +STATIC NORETURN void syntax_error(void) { + mp_raise_TypeError("syntax error in uctypes descriptor"); +} + +STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 3, false); + mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); + o->base.type = type; + o->addr = (void*)(uintptr_t)mp_obj_int_get_truncated(args[0]); + o->desc = args[1]; + o->flags = LAYOUT_NATIVE; + if (n_args == 3) { + o->flags = mp_obj_get_int(args[2]); + } + return MP_OBJ_FROM_PTR(o); +} + +STATIC void uctypes_struct_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); + const char *typen = "unk"; + if (MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) { + typen = "STRUCT"; + } else if (MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) { + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc); + mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]); + uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS); + switch (agg_type) { + case PTR: typen = "PTR"; break; + case ARRAY: typen = "ARRAY"; break; + } + } else { + typen = "ERROR"; + } + mp_printf(print, "", typen, self->addr); +} + +// Get size of any type descriptor +STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_t *max_field_size); + +// Get size of scalar type descriptor +static inline mp_uint_t uctypes_struct_scalar_size(int val_type) { + if (val_type == FLOAT32) { + return 4; + } else { + return GET_SCALAR_SIZE(val_type & 7); + } +} + +// Get size of aggregate type descriptor +STATIC mp_uint_t uctypes_struct_agg_size(mp_obj_tuple_t *t, int layout_type, mp_uint_t *max_field_size) { + mp_uint_t total_size = 0; + + mp_int_t offset_ = MP_OBJ_SMALL_INT_VALUE(t->items[0]); + mp_uint_t agg_type = GET_TYPE(offset_, AGG_TYPE_BITS); + + switch (agg_type) { + case STRUCT: + return uctypes_struct_size(t->items[1], layout_type, max_field_size); + case PTR: + if (sizeof(void*) > *max_field_size) { + *max_field_size = sizeof(void*); + } + return sizeof(void*); + case ARRAY: { + mp_int_t arr_sz = MP_OBJ_SMALL_INT_VALUE(t->items[1]); + uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS); + arr_sz &= VALUE_MASK(VAL_TYPE_BITS); + mp_uint_t item_s; + if (t->len == 2) { + // Elements of array are scalar + item_s = GET_SCALAR_SIZE(val_type); + if (item_s > *max_field_size) { + *max_field_size = item_s; + } + } else { + // Elements of array are aggregates + item_s = uctypes_struct_size(t->items[2], layout_type, max_field_size); + } + + return item_s * arr_sz; + } + default: + assert(0); + } + + return total_size; +} + +STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_t *max_field_size) { + if (!MP_OBJ_IS_TYPE(desc_in, &mp_type_dict)) { + if (MP_OBJ_IS_TYPE(desc_in, &mp_type_tuple)) { + return uctypes_struct_agg_size((mp_obj_tuple_t*)MP_OBJ_TO_PTR(desc_in), layout_type, max_field_size); + } else if (MP_OBJ_IS_SMALL_INT(desc_in)) { + // We allow sizeof on both type definitions and structures/structure fields, + // but scalar structure field is lowered into native Python int, so all + // type info is lost. So, we cannot say if it's scalar type description, + // or such lowered scalar. + mp_raise_TypeError("Cannot unambiguously get sizeof scalar"); + } + syntax_error(); + } + + mp_obj_dict_t *d = MP_OBJ_TO_PTR(desc_in); + mp_uint_t total_size = 0; + + for (mp_uint_t i = 0; i < d->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&d->map, i)) { + mp_obj_t v = d->map.table[i].value; + if (MP_OBJ_IS_SMALL_INT(v)) { + mp_uint_t offset = MP_OBJ_SMALL_INT_VALUE(v); + mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS); + offset &= VALUE_MASK(VAL_TYPE_BITS); + if (val_type >= BFUINT8 && val_type <= BFINT32) { + offset &= (1 << OFFSET_BITS) - 1; + } + mp_uint_t s = uctypes_struct_scalar_size(val_type); + if (s > *max_field_size) { + *max_field_size = s; + } + if (offset + s > total_size) { + total_size = offset + s; + } + } else { + if (!MP_OBJ_IS_TYPE(v, &mp_type_tuple)) { + syntax_error(); + } + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(v); + mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]); + offset &= VALUE_MASK(AGG_TYPE_BITS); + mp_uint_t s = uctypes_struct_agg_size(t, layout_type, max_field_size); + if (offset + s > total_size) { + total_size = offset + s; + } + } + } + } + + // Round size up to alignment of biggest field + if (layout_type == LAYOUT_NATIVE) { + total_size = (total_size + *max_field_size - 1) & ~(*max_field_size - 1); + } + return total_size; +} + +STATIC mp_obj_t uctypes_struct_sizeof(mp_obj_t obj_in) { + mp_uint_t max_field_size = 0; + if (MP_OBJ_IS_TYPE(obj_in, &mp_type_bytearray)) { + return mp_obj_len(obj_in); + } + int layout_type = LAYOUT_NATIVE; + // We can apply sizeof either to structure definition (a dict) + // or to instantiated structure + if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) { + // Extract structure definition + mp_obj_uctypes_struct_t *obj = MP_OBJ_TO_PTR(obj_in); + obj_in = obj->desc; + layout_type = obj->flags; + } + mp_uint_t size = uctypes_struct_size(obj_in, layout_type, &max_field_size); + return MP_OBJ_NEW_SMALL_INT(size); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(uctypes_struct_sizeof_obj, uctypes_struct_sizeof); + +static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_endian) { + char struct_type = big_endian ? '>' : '<'; + static const char type2char[16] = "BbHhIiQq------fd"; + return mp_binary_get_val(struct_type, type2char[val_type], &p); +} + +static inline void set_unaligned(uint val_type, byte *p, int big_endian, mp_obj_t val) { + char struct_type = big_endian ? '>' : '<'; + static const char type2char[16] = "BbHhIiQq------fd"; + mp_binary_set_val(struct_type, type2char[val_type], val, &p); +} + +static inline mp_uint_t get_aligned_basic(uint val_type, void *p) { + switch (val_type) { + case UINT8: + return *(uint8_t*)p; + case UINT16: + return *(uint16_t*)p; + case UINT32: + return *(uint32_t*)p; + } + assert(0); + return 0; +} + +static inline void set_aligned_basic(uint val_type, void *p, mp_uint_t v) { + switch (val_type) { + case UINT8: + *(uint8_t*)p = (uint8_t)v; return; + case UINT16: + *(uint16_t*)p = (uint16_t)v; return; + case UINT32: + *(uint32_t*)p = (uint32_t)v; return; + } + assert(0); +} + +STATIC mp_obj_t get_aligned(uint val_type, void *p, mp_int_t index) { + switch (val_type) { + case UINT8: + return MP_OBJ_NEW_SMALL_INT(((uint8_t*)p)[index]); + case INT8: + return MP_OBJ_NEW_SMALL_INT(((int8_t*)p)[index]); + case UINT16: + return MP_OBJ_NEW_SMALL_INT(((uint16_t*)p)[index]); + case INT16: + return MP_OBJ_NEW_SMALL_INT(((int16_t*)p)[index]); + case UINT32: + return mp_obj_new_int_from_uint(((uint32_t*)p)[index]); + case INT32: + return mp_obj_new_int(((int32_t*)p)[index]); + case UINT64: + return mp_obj_new_int_from_ull(((uint64_t*)p)[index]); + case INT64: + return mp_obj_new_int_from_ll(((int64_t*)p)[index]); + #if MICROPY_PY_BUILTINS_FLOAT + case FLOAT32: + return mp_obj_new_float(((float*)p)[index]); + case FLOAT64: + return mp_obj_new_float(((double*)p)[index]); + #endif + default: + assert(0); + return MP_OBJ_NULL; + } +} + +STATIC void set_aligned(uint val_type, void *p, mp_int_t index, mp_obj_t val) { + #if MICROPY_PY_BUILTINS_FLOAT + if (val_type == FLOAT32 || val_type == FLOAT64) { + mp_float_t v = mp_obj_get_float(val); + if (val_type == FLOAT32) { + ((float*)p)[index] = v; + } else { + ((double*)p)[index] = v; + } + return; + } + #endif + mp_int_t v = mp_obj_get_int_truncated(val); + switch (val_type) { + case UINT8: + ((uint8_t*)p)[index] = (uint8_t)v; return; + case INT8: + ((int8_t*)p)[index] = (int8_t)v; return; + case UINT16: + ((uint16_t*)p)[index] = (uint16_t)v; return; + case INT16: + ((int16_t*)p)[index] = (int16_t)v; return; + case UINT32: + ((uint32_t*)p)[index] = (uint32_t)v; return; + case INT32: + ((int32_t*)p)[index] = (int32_t)v; return; + case INT64: + case UINT64: + if (sizeof(mp_int_t) == 8) { + ((uint64_t*)p)[index] = (uint64_t)v; + } else { + // TODO: Doesn't offer atomic store semantics, but should at least try + set_unaligned(val_type, p, MP_ENDIANNESS_BIG, val); + } + return; + default: + assert(0); + } +} + +STATIC mp_obj_t uctypes_struct_attr_op(mp_obj_t self_in, qstr attr, mp_obj_t set_val) { + mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); + + // TODO: Support at least OrderedDict in addition + if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) { + mp_raise_TypeError("struct: no fields"); + } + + mp_obj_t deref = mp_obj_dict_get(self->desc, MP_OBJ_NEW_QSTR(attr)); + if (MP_OBJ_IS_SMALL_INT(deref)) { + mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(deref); + mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS); + offset &= VALUE_MASK(VAL_TYPE_BITS); +//printf("scalar type=%d offset=%x\n", val_type, offset); + + if (val_type <= INT64 || val_type == FLOAT32 || val_type == FLOAT64) { +// printf("size=%d\n", GET_SCALAR_SIZE(val_type)); + if (self->flags == LAYOUT_NATIVE) { + if (set_val == MP_OBJ_NULL) { + return get_aligned(val_type, self->addr + offset, 0); + } else { + set_aligned(val_type, self->addr + offset, 0, set_val); + return set_val; // just !MP_OBJ_NULL + } + } else { + if (set_val == MP_OBJ_NULL) { + return get_unaligned(val_type, self->addr + offset, self->flags); + } else { + set_unaligned(val_type, self->addr + offset, self->flags, set_val); + return set_val; // just !MP_OBJ_NULL + } + } + } else if (val_type >= BFUINT8 && val_type <= BFINT32) { + uint bit_offset = (offset >> 17) & 31; + uint bit_len = (offset >> 22) & 31; + offset &= (1 << 17) - 1; + mp_uint_t val; + if (self->flags == LAYOUT_NATIVE) { + val = get_aligned_basic(val_type & 6, self->addr + offset); + } else { + val = mp_binary_get_int(GET_SCALAR_SIZE(val_type & 7), val_type & 1, self->flags, self->addr + offset); + } + if (set_val == MP_OBJ_NULL) { + val >>= bit_offset; + val &= (1 << bit_len) - 1; + // TODO: signed + assert((val_type & 1) == 0); + return mp_obj_new_int(val); + } else { + mp_uint_t set_val_int = (mp_uint_t)mp_obj_get_int(set_val); + mp_uint_t mask = (1 << bit_len) - 1; + set_val_int &= mask; + set_val_int <<= bit_offset; + mask <<= bit_offset; + val = (val & ~mask) | set_val_int; + + if (self->flags == LAYOUT_NATIVE) { + set_aligned_basic(val_type & 6, self->addr + offset, val); + } else { + mp_binary_set_int(GET_SCALAR_SIZE(val_type & 7), self->flags == LAYOUT_BIG_ENDIAN, + self->addr + offset, val); + } + return set_val; // just !MP_OBJ_NULL + } + } + + assert(0); + return MP_OBJ_NULL; + } + + if (!MP_OBJ_IS_TYPE(deref, &mp_type_tuple)) { + syntax_error(); + } + + if (set_val != MP_OBJ_NULL) { + // Cannot assign to aggregate + syntax_error(); + } + + mp_obj_tuple_t *sub = MP_OBJ_TO_PTR(deref); + mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(sub->items[0]); + mp_uint_t agg_type = GET_TYPE(offset, AGG_TYPE_BITS); + offset &= VALUE_MASK(AGG_TYPE_BITS); +//printf("agg type=%d offset=%x\n", agg_type, offset); + + switch (agg_type) { + case STRUCT: { + mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); + o->base.type = &uctypes_struct_type; + o->desc = sub->items[1]; + o->addr = self->addr + offset; + o->flags = self->flags; + return MP_OBJ_FROM_PTR(o); + } + case ARRAY: { + mp_uint_t dummy; + if (IS_SCALAR_ARRAY(sub) && IS_SCALAR_ARRAY_OF_BYTES(sub)) { + return mp_obj_new_bytearray_by_ref(uctypes_struct_agg_size(sub, self->flags, &dummy), self->addr + offset); + } + // Fall thru to return uctypes struct object + } + case PTR: { + mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); + o->base.type = &uctypes_struct_type; + o->desc = MP_OBJ_FROM_PTR(sub); + o->addr = self->addr + offset; + o->flags = self->flags; +//printf("PTR/ARR base addr=%p\n", o->addr); + return MP_OBJ_FROM_PTR(o); + } + } + + // Should be unreachable once all cases are handled + return MP_OBJ_NULL; +} + +STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] == MP_OBJ_NULL) { + // load attribute + mp_obj_t val = uctypes_struct_attr_op(self_in, attr, MP_OBJ_NULL); + dest[0] = val; + } else { + // delete/store attribute + if (uctypes_struct_attr_op(self_in, attr, dest[1]) != MP_OBJ_NULL) { + dest[0] = MP_OBJ_NULL; // indicate success + } + } +} + +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { + mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); + + if (value == MP_OBJ_NULL) { + // delete + return MP_OBJ_NULL; // op not supported + } else { + // load / store + if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) { + mp_raise_TypeError("struct: cannot index"); + } + + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc); + mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]); + uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS); + + mp_int_t index = MP_OBJ_SMALL_INT_VALUE(index_in); + + if (agg_type == ARRAY) { + mp_int_t arr_sz = MP_OBJ_SMALL_INT_VALUE(t->items[1]); + uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS); + arr_sz &= VALUE_MASK(VAL_TYPE_BITS); + if (index >= arr_sz) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "struct: index out of range")); + } + + if (t->len == 2) { + // array of scalars + if (self->flags == LAYOUT_NATIVE) { + if (value == MP_OBJ_SENTINEL) { + return get_aligned(val_type, self->addr, index); + } else { + set_aligned(val_type, self->addr, index, value); + return value; // just !MP_OBJ_NULL + } + } else { + byte *p = self->addr + GET_SCALAR_SIZE(val_type) * index; + if (value == MP_OBJ_SENTINEL) { + return get_unaligned(val_type, p, self->flags); + } else { + set_unaligned(val_type, p, self->flags, value); + return value; // just !MP_OBJ_NULL + } + } + } else if (value == MP_OBJ_SENTINEL) { + mp_uint_t dummy = 0; + mp_uint_t size = uctypes_struct_size(t->items[2], self->flags, &dummy); + mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); + o->base.type = &uctypes_struct_type; + o->desc = t->items[2]; + o->addr = self->addr + size * index; + o->flags = self->flags; + return MP_OBJ_FROM_PTR(o); + } else { + return MP_OBJ_NULL; // op not supported + } + + } else if (agg_type == PTR) { + byte *p = *(void**)self->addr; + if (MP_OBJ_IS_SMALL_INT(t->items[1])) { + uint val_type = GET_TYPE(MP_OBJ_SMALL_INT_VALUE(t->items[1]), VAL_TYPE_BITS); + return get_aligned(val_type, p, index); + } else { + mp_uint_t dummy = 0; + mp_uint_t size = uctypes_struct_size(t->items[1], self->flags, &dummy); + mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); + o->base.type = &uctypes_struct_type; + o->desc = t->items[1]; + o->addr = p + size * index; + o->flags = self->flags; + return MP_OBJ_FROM_PTR(o); + } + } + + assert(0); + return MP_OBJ_NULL; + } +} + +STATIC mp_int_t uctypes_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + (void)flags; + mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); + mp_uint_t max_field_size = 0; + mp_uint_t size = uctypes_struct_size(self->desc, self->flags, &max_field_size); + + bufinfo->buf = self->addr; + bufinfo->len = size; + bufinfo->typecode = BYTEARRAY_TYPECODE; + return 0; +} + +/// \function addressof() +/// Return address of object's data (applies to object providing buffer +/// interface). +STATIC mp_obj_t uctypes_struct_addressof(mp_obj_t buf) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); + return mp_obj_new_int((mp_int_t)(uintptr_t)bufinfo.buf); +} +MP_DEFINE_CONST_FUN_OBJ_1(uctypes_struct_addressof_obj, uctypes_struct_addressof); + +/// \function bytearray_at() +/// Capture memory at given address of given size as bytearray. Memory is +/// captured by reference (and thus memory pointed by bytearray may change +/// or become invalid at later time). Use bytes_at() to capture by value. +STATIC mp_obj_t uctypes_struct_bytearray_at(mp_obj_t ptr, mp_obj_t size) { + return mp_obj_new_bytearray_by_ref(mp_obj_int_get_truncated(size), (void*)(uintptr_t)mp_obj_int_get_truncated(ptr)); +} +MP_DEFINE_CONST_FUN_OBJ_2(uctypes_struct_bytearray_at_obj, uctypes_struct_bytearray_at); + +/// \function bytes_at() +/// Capture memory at given address of given size as bytes. Memory is +/// captured by value, i.e. copied. Use bytearray_at() to capture by reference +/// ("zero copy"). +STATIC mp_obj_t uctypes_struct_bytes_at(mp_obj_t ptr, mp_obj_t size) { + return mp_obj_new_bytes((void*)(uintptr_t)mp_obj_int_get_truncated(ptr), mp_obj_int_get_truncated(size)); +} +MP_DEFINE_CONST_FUN_OBJ_2(uctypes_struct_bytes_at_obj, uctypes_struct_bytes_at); + + +STATIC const mp_obj_type_t uctypes_struct_type = { + { &mp_type_type }, + .name = MP_QSTR_struct, + .print = uctypes_struct_print, + .make_new = uctypes_struct_make_new, + .attr = uctypes_struct_attr, + .subscr = uctypes_struct_subscr, + .buffer_p = { .get_buffer = uctypes_get_buffer }, +}; + +STATIC const mp_rom_map_elem_t mp_module_uctypes_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uctypes) }, + { MP_ROM_QSTR(MP_QSTR_struct), MP_ROM_PTR(&uctypes_struct_type) }, + { MP_ROM_QSTR(MP_QSTR_sizeof), MP_ROM_PTR(&uctypes_struct_sizeof_obj) }, + { MP_ROM_QSTR(MP_QSTR_addressof), MP_ROM_PTR(&uctypes_struct_addressof_obj) }, + { MP_ROM_QSTR(MP_QSTR_bytes_at), MP_ROM_PTR(&uctypes_struct_bytes_at_obj) }, + { MP_ROM_QSTR(MP_QSTR_bytearray_at), MP_ROM_PTR(&uctypes_struct_bytearray_at_obj) }, + + /// \moduleref uctypes + + /// \constant NATIVE - Native structure layout - native endianness, + /// platform-specific field alignment + { MP_ROM_QSTR(MP_QSTR_NATIVE), MP_ROM_INT(LAYOUT_NATIVE) }, + /// \constant LITTLE_ENDIAN - Little-endian structure layout, tightly packed + /// (no alignment constraints) + { MP_ROM_QSTR(MP_QSTR_LITTLE_ENDIAN), MP_ROM_INT(LAYOUT_LITTLE_ENDIAN) }, + /// \constant BIG_ENDIAN - Big-endian structure layout, tightly packed + /// (no alignment constraints) + { MP_ROM_QSTR(MP_QSTR_BIG_ENDIAN), MP_ROM_INT(LAYOUT_BIG_ENDIAN) }, + + /// \constant VOID - void value type, may be used only as pointer target type. + { MP_ROM_QSTR(MP_QSTR_VOID), MP_ROM_INT(TYPE2SMALLINT(UINT8, VAL_TYPE_BITS)) }, + + /// \constant UINT8 - uint8_t value type + { MP_ROM_QSTR(MP_QSTR_UINT8), MP_ROM_INT(TYPE2SMALLINT(UINT8, 4)) }, + /// \constant INT8 - int8_t value type + { MP_ROM_QSTR(MP_QSTR_INT8), MP_ROM_INT(TYPE2SMALLINT(INT8, 4)) }, + /// \constant UINT16 - uint16_t value type + { MP_ROM_QSTR(MP_QSTR_UINT16), MP_ROM_INT(TYPE2SMALLINT(UINT16, 4)) }, + /// \constant INT16 - int16_t value type + { MP_ROM_QSTR(MP_QSTR_INT16), MP_ROM_INT(TYPE2SMALLINT(INT16, 4)) }, + /// \constant UINT32 - uint32_t value type + { MP_ROM_QSTR(MP_QSTR_UINT32), MP_ROM_INT(TYPE2SMALLINT(UINT32, 4)) }, + /// \constant INT32 - int32_t value type + { MP_ROM_QSTR(MP_QSTR_INT32), MP_ROM_INT(TYPE2SMALLINT(INT32, 4)) }, + /// \constant UINT64 - uint64_t value type + { MP_ROM_QSTR(MP_QSTR_UINT64), MP_ROM_INT(TYPE2SMALLINT(UINT64, 4)) }, + /// \constant INT64 - int64_t value type + { MP_ROM_QSTR(MP_QSTR_INT64), MP_ROM_INT(TYPE2SMALLINT(INT64, 4)) }, + + { MP_ROM_QSTR(MP_QSTR_BFUINT8), MP_ROM_INT(TYPE2SMALLINT(BFUINT8, 4)) }, + { MP_ROM_QSTR(MP_QSTR_BFINT8), MP_ROM_INT(TYPE2SMALLINT(BFINT8, 4)) }, + { MP_ROM_QSTR(MP_QSTR_BFUINT16), MP_ROM_INT(TYPE2SMALLINT(BFUINT16, 4)) }, + { MP_ROM_QSTR(MP_QSTR_BFINT16), MP_ROM_INT(TYPE2SMALLINT(BFINT16, 4)) }, + { MP_ROM_QSTR(MP_QSTR_BFUINT32), MP_ROM_INT(TYPE2SMALLINT(BFUINT32, 4)) }, + { MP_ROM_QSTR(MP_QSTR_BFINT32), MP_ROM_INT(TYPE2SMALLINT(BFINT32, 4)) }, + + { MP_ROM_QSTR(MP_QSTR_BF_POS), MP_ROM_INT(17) }, + { MP_ROM_QSTR(MP_QSTR_BF_LEN), MP_ROM_INT(22) }, + + #if MICROPY_PY_BUILTINS_FLOAT + { MP_ROM_QSTR(MP_QSTR_FLOAT32), MP_ROM_INT(TYPE2SMALLINT(FLOAT32, 4)) }, + { MP_ROM_QSTR(MP_QSTR_FLOAT64), MP_ROM_INT(TYPE2SMALLINT(FLOAT64, 4)) }, + #endif + + { MP_ROM_QSTR(MP_QSTR_PTR), MP_ROM_INT(TYPE2SMALLINT(PTR, AGG_TYPE_BITS)) }, + { MP_ROM_QSTR(MP_QSTR_ARRAY), MP_ROM_INT(TYPE2SMALLINT(ARRAY, AGG_TYPE_BITS)) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_uctypes_globals, mp_module_uctypes_globals_table); + +const mp_obj_module_t mp_module_uctypes = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_uctypes_globals, +}; + +#endif diff --git a/user/mpy/extmod/moduhashlib.c b/user/mpy/extmod/moduhashlib.c new file mode 100644 index 0000000..f3beb39 --- /dev/null +++ b/user/mpy/extmod/moduhashlib.c @@ -0,0 +1,159 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" + +#if MICROPY_PY_UHASHLIB + +#include "crypto-algorithms/sha256.h" +#if MICROPY_PY_UHASHLIB_SHA1 +#include "lib/axtls/crypto/crypto.h" +#endif + +typedef struct _mp_obj_hash_t { + mp_obj_base_t base; + char state[0]; +} mp_obj_hash_t; + +STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg); + +STATIC mp_obj_t hash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); + mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX)); + o->base.type = type; + sha256_init((CRYAL_SHA256_CTX*)o->state); + if (n_args == 1) { + hash_update(MP_OBJ_FROM_PTR(o), args[0]); + } + return MP_OBJ_FROM_PTR(o); +} + +#if MICROPY_PY_UHASHLIB_SHA1 +STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg); + +STATIC mp_obj_t sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); + mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(SHA1_CTX)); + o->base.type = type; + SHA1_Init((SHA1_CTX*)o->state); + if (n_args == 1) { + sha1_update(MP_OBJ_FROM_PTR(o), args[0]); + } + return MP_OBJ_FROM_PTR(o); +} +#endif + +STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg) { + mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); + sha256_update((CRYAL_SHA256_CTX*)self->state, bufinfo.buf, bufinfo.len); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(hash_update_obj, hash_update); + +#if MICROPY_PY_UHASHLIB_SHA1 +STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg) { + mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); + SHA1_Update((SHA1_CTX*)self->state, bufinfo.buf, bufinfo.len); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(sha1_update_obj, sha1_update); +#endif + +STATIC mp_obj_t hash_digest(mp_obj_t self_in) { + mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); + vstr_t vstr; + vstr_init_len(&vstr, SHA256_BLOCK_SIZE); + sha256_final((CRYAL_SHA256_CTX*)self->state, (byte*)vstr.buf); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_1(hash_digest_obj, hash_digest); + +#if MICROPY_PY_UHASHLIB_SHA1 +STATIC mp_obj_t sha1_digest(mp_obj_t self_in) { + mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); + vstr_t vstr; + vstr_init_len(&vstr, SHA1_SIZE); + SHA1_Final((byte*)vstr.buf, (SHA1_CTX*)self->state); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_1(sha1_digest_obj, sha1_digest); +#endif + +STATIC const mp_rom_map_elem_t hash_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&hash_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&hash_digest_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(hash_locals_dict, hash_locals_dict_table); + +STATIC const mp_obj_type_t sha256_type = { + { &mp_type_type }, + .name = MP_QSTR_sha256, + .make_new = hash_make_new, + .locals_dict = (void*)&hash_locals_dict, +}; + +#if MICROPY_PY_UHASHLIB_SHA1 +STATIC const mp_rom_map_elem_t sha1_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&sha1_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&sha1_digest_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(sha1_locals_dict, sha1_locals_dict_table); + +STATIC const mp_obj_type_t sha1_type = { + { &mp_type_type }, + .name = MP_QSTR_sha1, + .make_new = sha1_make_new, + .locals_dict = (void*)&sha1_locals_dict, +}; +#endif + +STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) }, + { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&sha256_type) }, + #if MICROPY_PY_UHASHLIB_SHA1 + { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&sha1_type) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table); + +const mp_obj_module_t mp_module_uhashlib = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_hashlib_globals, +}; + +#include "crypto-algorithms/sha256.c" + +#endif //MICROPY_PY_UHASHLIB diff --git a/user/mpy/extmod/moduheapq.c b/user/mpy/extmod/moduheapq.c new file mode 100644 index 0000000..4a620ba --- /dev/null +++ b/user/mpy/extmod/moduheapq.c @@ -0,0 +1,122 @@ +/* + * 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. + */ + +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_UHEAPQ + +// the algorithm here is modelled on CPython's heapq.py + +STATIC mp_obj_list_t *get_heap(mp_obj_t heap_in) { + if (!MP_OBJ_IS_TYPE(heap_in, &mp_type_list)) { + mp_raise_TypeError("heap must be a list"); + } + return MP_OBJ_TO_PTR(heap_in); +} + +STATIC void heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) { + mp_obj_t item = heap->items[pos]; + while (pos > start_pos) { + mp_uint_t parent_pos = (pos - 1) >> 1; + mp_obj_t parent = heap->items[parent_pos]; + if (mp_binary_op(MP_BINARY_OP_LESS, item, parent) == mp_const_true) { + heap->items[pos] = parent; + pos = parent_pos; + } else { + break; + } + } + heap->items[pos] = item; +} + +STATIC void heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) { + mp_uint_t start_pos = pos; + mp_uint_t end_pos = heap->len; + mp_obj_t item = heap->items[pos]; + for (mp_uint_t child_pos = 2 * pos + 1; child_pos < end_pos; child_pos = 2 * pos + 1) { + // choose right child if it's <= left child + if (child_pos + 1 < end_pos && mp_binary_op(MP_BINARY_OP_LESS, heap->items[child_pos], heap->items[child_pos + 1]) == mp_const_false) { + child_pos += 1; + } + // bubble up the smaller child + heap->items[pos] = heap->items[child_pos]; + pos = child_pos; + } + heap->items[pos] = item; + heap_siftdown(heap, start_pos, pos); +} + +STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) { + mp_obj_list_t *heap = get_heap(heap_in); + mp_obj_list_append(heap_in, item); + heap_siftdown(heap, 0, heap->len - 1); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush); + +STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) { + mp_obj_list_t *heap = get_heap(heap_in); + if (heap->len == 0) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap")); + } + mp_obj_t item = heap->items[0]; + heap->len -= 1; + heap->items[0] = heap->items[heap->len]; + heap->items[heap->len] = MP_OBJ_NULL; // so we don't retain a pointer + if (heap->len) { + heap_siftup(heap, 0); + } + return item; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heappop_obj, mod_uheapq_heappop); + +STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) { + mp_obj_list_t *heap = get_heap(heap_in); + for (mp_uint_t i = heap->len / 2; i > 0;) { + heap_siftup(heap, --i); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heapify_obj, mod_uheapq_heapify); + +STATIC const mp_rom_map_elem_t mp_module_uheapq_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uheapq) }, + { MP_ROM_QSTR(MP_QSTR_heappush), MP_ROM_PTR(&mod_uheapq_heappush_obj) }, + { MP_ROM_QSTR(MP_QSTR_heappop), MP_ROM_PTR(&mod_uheapq_heappop_obj) }, + { MP_ROM_QSTR(MP_QSTR_heapify), MP_ROM_PTR(&mod_uheapq_heapify_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_uheapq_globals, mp_module_uheapq_globals_table); + +const mp_obj_module_t mp_module_uheapq = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_uheapq_globals, +}; + +#endif //MICROPY_PY_UHEAPQ diff --git a/user/mpy/extmod/modujson.c b/user/mpy/extmod/modujson.c new file mode 100644 index 0000000..6c4aa16 --- /dev/null +++ b/user/mpy/extmod/modujson.c @@ -0,0 +1,299 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014-2016 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. + */ + +#include + +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/objstringio.h" +#include "py/parsenum.h" +#include "py/runtime.h" +#include "py/stream.h" + +#if MICROPY_PY_UJSON + +STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 8, &print); + mp_obj_print_helper(&print, obj, PRINT_JSON); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps); + +// The function below implements a simple non-recursive JSON parser. +// +// The JSON specification is at http://www.ietf.org/rfc/rfc4627.txt +// The parser here will parse any valid JSON and return the correct +// corresponding Python object. It allows through a superset of JSON, since +// it treats commas and colons as "whitespace", and doesn't care if +// brackets/braces are correctly paired. It will raise a ValueError if the +// input is outside it's specs. +// +// Most of the work is parsing the primitives (null, false, true, numbers, +// strings). It does 1 pass over the input stream. It tries to be fast and +// small in code size, while not using more RAM than necessary. + +typedef struct _ujson_stream_t { + mp_obj_t stream_obj; + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + int errcode; + byte cur; +} ujson_stream_t; + +#define S_EOF (0) // null is not allowed in json stream so is ok as EOF marker +#define S_END(s) ((s).cur == S_EOF) +#define S_CUR(s) ((s).cur) +#define S_NEXT(s) (ujson_stream_next(&(s))) + +STATIC byte ujson_stream_next(ujson_stream_t *s) { + mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode); + if (s->errcode != 0) { + mp_raise_OSError(s->errcode); + } + if (ret == 0) { + s->cur = S_EOF; + } + return s->cur; +} + +STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ); + ujson_stream_t s = {stream_obj, stream_p->read, 0, 0}; + vstr_t vstr; + vstr_init(&vstr, 8); + mp_obj_list_t stack; // we use a list as a simple stack for nested JSON + stack.len = 0; + stack.items = NULL; + mp_obj_t stack_top = MP_OBJ_NULL; + mp_obj_type_t *stack_top_type = NULL; + mp_obj_t stack_key = MP_OBJ_NULL; + S_NEXT(s); + for (;;) { + cont: + if (S_END(s)) { + break; + } + mp_obj_t next = MP_OBJ_NULL; + bool enter = false; + byte cur = S_CUR(s); + S_NEXT(s); + switch (cur) { + case ',': + case ':': + case ' ': + case '\t': + case '\n': + case '\r': + goto cont; + case 'n': + if (S_CUR(s) == 'u' && S_NEXT(s) == 'l' && S_NEXT(s) == 'l') { + S_NEXT(s); + next = mp_const_none; + } else { + goto fail; + } + break; + case 'f': + if (S_CUR(s) == 'a' && S_NEXT(s) == 'l' && S_NEXT(s) == 's' && S_NEXT(s) == 'e') { + S_NEXT(s); + next = mp_const_false; + } else { + goto fail; + } + break; + case 't': + if (S_CUR(s) == 'r' && S_NEXT(s) == 'u' && S_NEXT(s) == 'e') { + S_NEXT(s); + next = mp_const_true; + } else { + goto fail; + } + break; + case '"': + vstr_reset(&vstr); + for (; !S_END(s) && S_CUR(s) != '"';) { + byte c = S_CUR(s); + if (c == '\\') { + c = S_NEXT(s); + switch (c) { + case 'b': c = 0x08; break; + case 'f': c = 0x0c; break; + case 'n': c = 0x0a; break; + case 'r': c = 0x0d; break; + case 't': c = 0x09; break; + case 'u': { + mp_uint_t num = 0; + for (int i = 0; i < 4; i++) { + c = (S_NEXT(s) | 0x20) - '0'; + if (c > 9) { + c -= ('a' - ('9' + 1)); + } + num = (num << 4) | c; + } + vstr_add_char(&vstr, num); + goto str_cont; + } + } + } + vstr_add_byte(&vstr, c); + str_cont: + S_NEXT(s); + } + if (S_END(s)) { + goto fail; + } + S_NEXT(s); + next = mp_obj_new_str(vstr.buf, vstr.len, false); + break; + case '-': + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { + bool flt = false; + vstr_reset(&vstr); + for (;;) { + vstr_add_byte(&vstr, cur); + cur = S_CUR(s); + if (cur == '.' || cur == 'E' || cur == 'e') { + flt = true; + } else if (cur == '-' || unichar_isdigit(cur)) { + // pass + } else { + break; + } + S_NEXT(s); + } + if (flt) { + next = mp_parse_num_decimal(vstr.buf, vstr.len, false, false, NULL); + } else { + next = mp_parse_num_integer(vstr.buf, vstr.len, 10, NULL); + } + break; + } + case '[': + next = mp_obj_new_list(0, NULL); + enter = true; + break; + case '{': + next = mp_obj_new_dict(0); + enter = true; + break; + case '}': + case ']': { + if (stack_top == MP_OBJ_NULL) { + // no object at all + goto fail; + } + if (stack.len == 0) { + // finished; compound object + goto success; + } + stack.len -= 1; + stack_top = stack.items[stack.len]; + stack_top_type = mp_obj_get_type(stack_top); + goto cont; + } + default: + goto fail; + } + if (stack_top == MP_OBJ_NULL) { + stack_top = next; + stack_top_type = mp_obj_get_type(stack_top); + if (!enter) { + // finished; single primitive only + goto success; + } + } else { + // append to list or dict + if (stack_top_type == &mp_type_list) { + mp_obj_list_append(stack_top, next); + } else { + if (stack_key == MP_OBJ_NULL) { + stack_key = next; + if (enter) { + goto fail; + } + } else { + mp_obj_dict_store(stack_top, stack_key, next); + stack_key = MP_OBJ_NULL; + } + } + if (enter) { + if (stack.items == NULL) { + mp_obj_list_init(&stack, 1); + stack.items[0] = stack_top; + } else { + mp_obj_list_append(MP_OBJ_FROM_PTR(&stack), stack_top); + } + stack_top = next; + stack_top_type = mp_obj_get_type(stack_top); + } + } + } + success: + // eat trailing whitespace + while (unichar_isspace(S_CUR(s))) { + S_NEXT(s); + } + if (!S_END(s)) { + // unexpected chars + goto fail; + } + if (stack_top == MP_OBJ_NULL || stack.len != 0) { + // not exactly 1 object + goto fail; + } + vstr_clear(&vstr); + return stack_top; + + fail: + mp_raise_ValueError("syntax error in JSON"); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load); + +STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { + size_t len; + const char *buf = mp_obj_str_get_data(obj, &len); + vstr_t vstr = {len, len, (char*)buf, true}; + mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL}; + return mod_ujson_load(MP_OBJ_FROM_PTR(&sio)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads); + +STATIC const mp_rom_map_elem_t mp_module_ujson_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ujson) }, + { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_ujson_dumps_obj) }, + { MP_ROM_QSTR(MP_QSTR_load), MP_ROM_PTR(&mod_ujson_load_obj) }, + { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_ujson_loads_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_ujson_globals, mp_module_ujson_globals_table); + +const mp_obj_module_t mp_module_ujson = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_ujson_globals, +}; + +#endif //MICROPY_PY_UJSON diff --git a/user/mpy/extmod/modurandom.c b/user/mpy/extmod/modurandom.c new file mode 100644 index 0000000..4b63dac --- /dev/null +++ b/user/mpy/extmod/modurandom.c @@ -0,0 +1,226 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include + +//#include "py/nlr.h" +#include "py/runtime.h" + +#if MICROPY_PY_URANDOM + +// Yasmarang random number generator +// by Ilya Levin +// http://www.literatecode.com/yasmarang +// Public Domain + +STATIC uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233; +STATIC uint8_t yasmarang_dat = 0; + +STATIC uint32_t yasmarang(void) +{ + yasmarang_pad += yasmarang_dat + yasmarang_d * yasmarang_n; + yasmarang_pad = (yasmarang_pad<<3) + (yasmarang_pad>>29); + yasmarang_n = yasmarang_pad | 2; + yasmarang_d ^= (yasmarang_pad<<31) + (yasmarang_pad>>1); + yasmarang_dat ^= (char) yasmarang_pad ^ (yasmarang_d>>8) ^ 1; + + return (yasmarang_pad^(yasmarang_d<<5)^(yasmarang_pad>>18)^(yasmarang_dat<<1)); +} /* yasmarang */ + +// End of Yasmarang + +#if MICROPY_PY_URANDOM_EXTRA_FUNCS + +// returns an unsigned integer below the given argument +// n must not be zero +STATIC uint32_t yasmarang_randbelow(uint32_t n) { + uint32_t mask = 1; + while ((n & mask) < n) { + mask = (mask << 1) | 1; + } + uint32_t r; + do { + r = yasmarang() & mask; + } while (r >= n); + return r; +} + +#endif + +STATIC mp_obj_t mod_urandom_getrandbits(mp_obj_t num_in) { + int n = mp_obj_get_int(num_in); + if (n > 32 || n == 0) { + mp_raise_ValueError(NULL); + } + uint32_t mask = ~0; + // Beware of C undefined behavior when shifting by >= than bit size + mask >>= (32 - n); + return mp_obj_new_int_from_uint(yasmarang() & mask); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_getrandbits_obj, mod_urandom_getrandbits); + +STATIC mp_obj_t mod_urandom_seed(mp_obj_t seed_in) { + mp_uint_t seed = mp_obj_get_int_truncated(seed_in); + yasmarang_pad = seed; + yasmarang_n = 69; + yasmarang_d = 233; + yasmarang_dat = 0; + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_seed_obj, mod_urandom_seed); + +#if MICROPY_PY_URANDOM_EXTRA_FUNCS + +STATIC mp_obj_t mod_urandom_randrange(size_t n_args, const mp_obj_t *args) { + mp_int_t start = mp_obj_get_int(args[0]); + if (n_args == 1) { + // range(stop) + if (start > 0) { + return mp_obj_new_int(yasmarang_randbelow(start)); + } else { + goto error; + } + } else { + mp_int_t stop = mp_obj_get_int(args[1]); + if (n_args == 2) { + // range(start, stop) + if (start < stop) { + return mp_obj_new_int(start + yasmarang_randbelow(stop - start)); + } else { + goto error; + } + } else { + // range(start, stop, step) + mp_int_t step = mp_obj_get_int(args[2]); + mp_int_t n; + if (step > 0) { + n = (stop - start + step - 1) / step; + } else if (step < 0) { + n = (stop - start + step + 1) / step; + } else { + goto error; + } + if (n > 0) { + return mp_obj_new_int(start + step * yasmarang_randbelow(n)); + } else { + goto error; + } + } + } + +error: + mp_raise_ValueError(NULL); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_urandom_randrange_obj, 1, 3, mod_urandom_randrange); + +STATIC mp_obj_t mod_urandom_randint(mp_obj_t a_in, mp_obj_t b_in) { + mp_int_t a = mp_obj_get_int(a_in); + mp_int_t b = mp_obj_get_int(b_in); + if (a <= b) { + return mp_obj_new_int(a + yasmarang_randbelow(b - a + 1)); + } else { + mp_raise_ValueError(NULL); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); + +STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { + mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); + if (len > 0) { + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); + } else { + nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_choice_obj, mod_urandom_choice); + +#if MICROPY_PY_BUILTINS_FLOAT + +// returns a number in the range [0..1) using Yasmarang to fill in the fraction bits +STATIC mp_float_t yasmarang_float(void) { + #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE + typedef uint64_t mp_float_int_t; + #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT + typedef uint32_t mp_float_int_t; + #endif + union { + mp_float_t f; + #if MP_ENDIANNESS_LITTLE + struct { mp_float_int_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; + #else + struct { mp_float_int_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; + #endif + } u; + u.p.sgn = 0; + u.p.exp = (1 << (MP_FLOAT_EXP_BITS - 1)) - 1; + if (MP_FLOAT_FRAC_BITS <= 32) { + u.p.frc = yasmarang(); + } else { + u.p.frc = ((uint64_t)yasmarang() << 32) | (uint64_t)yasmarang(); + } + return u.f - 1; +} + +STATIC mp_obj_t mod_urandom_random(void) { + return mp_obj_new_float(yasmarang_float()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_urandom_random_obj, mod_urandom_random); + +STATIC mp_obj_t mod_urandom_uniform(mp_obj_t a_in, mp_obj_t b_in) { + mp_float_t a = mp_obj_get_float(a_in); + mp_float_t b = mp_obj_get_float(b_in); + return mp_obj_new_float(a + (b - a) * yasmarang_float()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_uniform_obj, mod_urandom_uniform); + +#endif + +#endif // MICROPY_PY_URANDOM_EXTRA_FUNCS + +STATIC const mp_rom_map_elem_t mp_module_urandom_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_urandom) }, + { MP_ROM_QSTR(MP_QSTR_getrandbits), MP_ROM_PTR(&mod_urandom_getrandbits_obj) }, + { MP_ROM_QSTR(MP_QSTR_seed), MP_ROM_PTR(&mod_urandom_seed_obj) }, + #if MICROPY_PY_URANDOM_EXTRA_FUNCS + { MP_ROM_QSTR(MP_QSTR_randrange), MP_ROM_PTR(&mod_urandom_randrange_obj) }, + { MP_ROM_QSTR(MP_QSTR_randint), MP_ROM_PTR(&mod_urandom_randint_obj) }, + { MP_ROM_QSTR(MP_QSTR_choice), MP_ROM_PTR(&mod_urandom_choice_obj) }, + #if MICROPY_PY_BUILTINS_FLOAT + { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mod_urandom_random_obj) }, + { MP_ROM_QSTR(MP_QSTR_uniform), MP_ROM_PTR(&mod_urandom_uniform_obj) }, + #endif + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_urandom_globals, mp_module_urandom_globals_table); + +const mp_obj_module_t mp_module_urandom = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_urandom_globals, +}; + +#endif //MICROPY_PY_URANDOM diff --git a/user/mpy/extmod/modure.c b/user/mpy/extmod/modure.c new file mode 100644 index 0000000..2baebde --- /dev/null +++ b/user/mpy/extmod/modure.c @@ -0,0 +1,255 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/binary.h" +#include "py/objstr.h" + +#if MICROPY_PY_URE + +#include "re1.5/re1.5.h" + +#define FLAG_DEBUG 0x1000 + +typedef struct _mp_obj_re_t { + mp_obj_base_t base; + ByteProg re; +} mp_obj_re_t; + +typedef struct _mp_obj_match_t { + mp_obj_base_t base; + int num_matches; + mp_obj_t str; + const char *caps[0]; +} mp_obj_match_t; + + +STATIC void match_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "", self->num_matches); +} + +STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) { + mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t no = mp_obj_get_int(no_in); + if (no < 0 || no >= self->num_matches) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, no_in)); + } + + const char *start = self->caps[no * 2]; + if (start == NULL) { + // no match for this group + return mp_const_none; + } + return mp_obj_new_str_of_type(mp_obj_get_type(self->str), + (const byte*)start, self->caps[no * 2 + 1] - start); +} +MP_DEFINE_CONST_FUN_OBJ_2(match_group_obj, match_group); + +STATIC const mp_rom_map_elem_t match_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_group), MP_ROM_PTR(&match_group_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(match_locals_dict, match_locals_dict_table); + +STATIC const mp_obj_type_t match_type = { + { &mp_type_type }, + .name = MP_QSTR_match, + .print = match_print, + .locals_dict = (void*)&match_locals_dict, +}; + +STATIC void re_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_re_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "", self); +} + +STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { + (void)n_args; + mp_obj_re_t *self = MP_OBJ_TO_PTR(args[0]); + Subject subj; + size_t len; + subj.begin = mp_obj_str_get_data(args[1], &len); + subj.end = subj.begin + len; + int caps_num = (self->re.sub + 1) * 2; + mp_obj_match_t *match = m_new_obj_var(mp_obj_match_t, char*, caps_num); + // cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char + memset((char*)match->caps, 0, caps_num * sizeof(char*)); + int res = re1_5_recursiveloopprog(&self->re, &subj, match->caps, caps_num, is_anchored); + if (res == 0) { + m_del_var(mp_obj_match_t, char*, caps_num, match); + return mp_const_none; + } + + match->base.type = &match_type; + match->num_matches = caps_num / 2; // caps_num counts start and end pointers + match->str = args[1]; + return MP_OBJ_FROM_PTR(match); +} + +STATIC mp_obj_t re_match(size_t n_args, const mp_obj_t *args) { + return ure_exec(true, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_match_obj, 2, 4, re_match); + +STATIC mp_obj_t re_search(size_t n_args, const mp_obj_t *args) { + return ure_exec(false, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_search_obj, 2, 4, re_search); + +STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) { + mp_obj_re_t *self = MP_OBJ_TO_PTR(args[0]); + Subject subj; + size_t len; + const mp_obj_type_t *str_type = mp_obj_get_type(args[1]); + subj.begin = mp_obj_str_get_data(args[1], &len); + subj.end = subj.begin + len; + int caps_num = (self->re.sub + 1) * 2; + + int maxsplit = 0; + if (n_args > 2) { + maxsplit = mp_obj_get_int(args[2]); + } + + mp_obj_t retval = mp_obj_new_list(0, NULL); + const char **caps = alloca(caps_num * sizeof(char*)); + while (true) { + // cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char + memset((char**)caps, 0, caps_num * sizeof(char*)); + int res = re1_5_recursiveloopprog(&self->re, &subj, caps, caps_num, false); + + // if we didn't have a match, or had an empty match, it's time to stop + if (!res || caps[0] == caps[1]) { + break; + } + + mp_obj_t s = mp_obj_new_str_of_type(str_type, (const byte*)subj.begin, caps[0] - subj.begin); + mp_obj_list_append(retval, s); + if (self->re.sub > 0) { + mp_raise_NotImplementedError("Splitting with sub-captures"); + } + subj.begin = caps[1]; + if (maxsplit > 0 && --maxsplit == 0) { + break; + } + } + + mp_obj_t s = mp_obj_new_str_of_type(str_type, (const byte*)subj.begin, subj.end - subj.begin); + mp_obj_list_append(retval, s); + return retval; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_split_obj, 2, 3, re_split); + +STATIC const mp_rom_map_elem_t re_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&re_match_obj) }, + { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&re_search_obj) }, + { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&re_split_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(re_locals_dict, re_locals_dict_table); + +STATIC const mp_obj_type_t re_type = { + { &mp_type_type }, + .name = MP_QSTR_ure, + .print = re_print, + .locals_dict = (void*)&re_locals_dict, +}; + +STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) { + const char *re_str = mp_obj_str_get_str(args[0]); + int size = re1_5_sizecode(re_str); + if (size == -1) { + goto error; + } + mp_obj_re_t *o = m_new_obj_var(mp_obj_re_t, char, size); + o->base.type = &re_type; + int flags = 0; + if (n_args > 1) { + flags = mp_obj_get_int(args[1]); + } + int error = re1_5_compilecode(&o->re, re_str); + if (error != 0) { +error: + mp_raise_ValueError("Error in regex"); + } + if (flags & FLAG_DEBUG) { + re1_5_dumpcode(&o->re); + } + return MP_OBJ_FROM_PTR(o); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile); + +STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { + (void)n_args; + mp_obj_t self = mod_re_compile(1, args); + + const mp_obj_t args2[] = {self, args[1]}; + mp_obj_t match = ure_exec(is_anchored, 2, args2); + return match; +} + +STATIC mp_obj_t mod_re_match(size_t n_args, const mp_obj_t *args) { + return mod_re_exec(true, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_match_obj, 2, 4, mod_re_match); + +STATIC mp_obj_t mod_re_search(size_t n_args, const mp_obj_t *args) { + return mod_re_exec(false, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_search_obj, 2, 4, mod_re_search); + +STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ure) }, + { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mod_re_compile_obj) }, + { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&mod_re_match_obj) }, + { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&mod_re_search_obj) }, + { MP_ROM_QSTR(MP_QSTR_DEBUG), MP_ROM_INT(FLAG_DEBUG) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table); + +const mp_obj_module_t mp_module_ure = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_re_globals, +}; + +// Source files #include'd here to make sure they're compiled in +// only if module is enabled by config setting. + +#define re1_5_fatal(x) assert(!x) +#include "re1.5/compilecode.c" +#include "re1.5/dumpcode.c" +#include "re1.5/recursiveloop.c" +#include "re1.5/charclass.c" + +#endif //MICROPY_PY_URE diff --git a/user/mpy/extmod/moduselect.c b/user/mpy/extmod/moduselect.c new file mode 100644 index 0000000..a9f25c1 --- /dev/null +++ b/user/mpy/extmod/moduselect.c @@ -0,0 +1,378 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_PY_USELECT + +#include + +#include "py/runtime.h" +#include "py/obj.h" +#include "py/objlist.h" +#include "py/stream.h" +#include "py/mperrno.h" +#include "py/mphal.h" + +// Flags for poll() +#define FLAG_ONESHOT (1) + +/// \module select - Provides select function to wait for events on a stream +/// +/// This module provides the select function. + +typedef struct _poll_obj_t { + mp_obj_t obj; + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, mp_uint_t arg, int *errcode); + mp_uint_t flags; + mp_uint_t flags_ret; +} poll_obj_t; + +STATIC void poll_map_add(mp_map_t *poll_map, const mp_obj_t *obj, mp_uint_t obj_len, mp_uint_t flags, bool or_flags) { + for (mp_uint_t i = 0; i < obj_len; i++) { + mp_map_elem_t *elem = mp_map_lookup(poll_map, mp_obj_id(obj[i]), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + if (elem->value == NULL) { + // object not found; get its ioctl and add it to the poll list + const mp_stream_p_t *stream_p = mp_get_stream_raise(obj[i], MP_STREAM_OP_IOCTL); + poll_obj_t *poll_obj = m_new_obj(poll_obj_t); + poll_obj->obj = obj[i]; + poll_obj->ioctl = stream_p->ioctl; + poll_obj->flags = flags; + poll_obj->flags_ret = 0; + elem->value = poll_obj; + } else { + // object exists; update its flags + if (or_flags) { + ((poll_obj_t*)elem->value)->flags |= flags; + } else { + ((poll_obj_t*)elem->value)->flags = flags; + } + } + } +} + +// poll each object in the map +STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, mp_uint_t *rwx_num) { + mp_uint_t n_ready = 0; + for (mp_uint_t i = 0; i < poll_map->alloc; ++i) { + if (!MP_MAP_SLOT_IS_FILLED(poll_map, i)) { + continue; + } + + poll_obj_t *poll_obj = (poll_obj_t*)poll_map->table[i].value; + int errcode; + mp_int_t ret = poll_obj->ioctl(poll_obj->obj, MP_STREAM_POLL, poll_obj->flags, &errcode); + poll_obj->flags_ret = ret; + + if (ret == -1) { + // error doing ioctl + mp_raise_OSError(errcode); + } + + if (ret != 0) { + // object is ready + n_ready += 1; + if (rwx_num != NULL) { + if (ret & MP_STREAM_POLL_RD) { + rwx_num[0] += 1; + } + if (ret & MP_STREAM_POLL_WR) { + rwx_num[1] += 1; + } + if ((ret & ~(MP_STREAM_POLL_RD | MP_STREAM_POLL_WR)) != 0) { + rwx_num[2] += 1; + } + } + } + } + return n_ready; +} + +/// \function select(rlist, wlist, xlist[, timeout]) +STATIC mp_obj_t select_select(uint n_args, const mp_obj_t *args) { + // get array data from tuple/list arguments + size_t rwx_len[3]; + mp_obj_t *r_array, *w_array, *x_array; + mp_obj_get_array(args[0], &rwx_len[0], &r_array); + mp_obj_get_array(args[1], &rwx_len[1], &w_array); + mp_obj_get_array(args[2], &rwx_len[2], &x_array); + + // get timeout + mp_uint_t timeout = -1; + if (n_args == 4) { + if (args[3] != mp_const_none) { + #if MICROPY_PY_BUILTINS_FLOAT + float timeout_f = mp_obj_get_float(args[3]); + if (timeout_f >= 0) { + timeout = (mp_uint_t)(timeout_f * 1000); + } + #else + timeout = mp_obj_get_int(args[3]) * 1000; + #endif + } + } + + // merge separate lists and get the ioctl function for each object + mp_map_t poll_map; + mp_map_init(&poll_map, rwx_len[0] + rwx_len[1] + rwx_len[2]); + poll_map_add(&poll_map, r_array, rwx_len[0], MP_STREAM_POLL_RD, true); + poll_map_add(&poll_map, w_array, rwx_len[1], MP_STREAM_POLL_WR, true); + poll_map_add(&poll_map, x_array, rwx_len[2], MP_STREAM_POLL_ERR | MP_STREAM_POLL_HUP, true); + + mp_uint_t start_tick = mp_hal_ticks_ms(); + rwx_len[0] = rwx_len[1] = rwx_len[2] = 0; + for (;;) { + // poll the objects + mp_uint_t n_ready = poll_map_poll(&poll_map, rwx_len); + + if (n_ready > 0 || (timeout != -1 && mp_hal_ticks_ms() - start_tick >= timeout)) { + // one or more objects are ready, or we had a timeout + mp_obj_t list_array[3]; + list_array[0] = mp_obj_new_list(rwx_len[0], NULL); + list_array[1] = mp_obj_new_list(rwx_len[1], NULL); + list_array[2] = mp_obj_new_list(rwx_len[2], NULL); + rwx_len[0] = rwx_len[1] = rwx_len[2] = 0; + for (mp_uint_t i = 0; i < poll_map.alloc; ++i) { + if (!MP_MAP_SLOT_IS_FILLED(&poll_map, i)) { + continue; + } + poll_obj_t *poll_obj = (poll_obj_t*)poll_map.table[i].value; + if (poll_obj->flags_ret & MP_STREAM_POLL_RD) { + ((mp_obj_list_t*)list_array[0])->items[rwx_len[0]++] = poll_obj->obj; + } + if (poll_obj->flags_ret & MP_STREAM_POLL_WR) { + ((mp_obj_list_t*)list_array[1])->items[rwx_len[1]++] = poll_obj->obj; + } + if ((poll_obj->flags_ret & ~(MP_STREAM_POLL_RD | MP_STREAM_POLL_WR)) != 0) { + ((mp_obj_list_t*)list_array[2])->items[rwx_len[2]++] = poll_obj->obj; + } + } + mp_map_deinit(&poll_map); + return mp_obj_new_tuple(3, list_array); + } + MICROPY_EVENT_POLL_HOOK + } +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); + +/// \class Poll - poll class + +typedef struct _mp_obj_poll_t { + mp_obj_base_t base; + mp_map_t poll_map; + short iter_cnt; + short iter_idx; + int flags; + // callee-owned tuple + mp_obj_t ret_tuple; +} mp_obj_poll_t; + +/// \method register(obj[, eventmask]) +STATIC mp_obj_t poll_register(uint n_args, const mp_obj_t *args) { + mp_obj_poll_t *self = args[0]; + mp_uint_t flags; + if (n_args == 3) { + flags = mp_obj_get_int(args[2]); + } else { + flags = MP_STREAM_POLL_RD | MP_STREAM_POLL_WR; + } + poll_map_add(&self->poll_map, &args[1], 1, flags, false); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_register_obj, 2, 3, poll_register); + +/// \method unregister(obj) +STATIC mp_obj_t poll_unregister(mp_obj_t self_in, mp_obj_t obj_in) { + mp_obj_poll_t *self = self_in; + mp_map_lookup(&self->poll_map, mp_obj_id(obj_in), MP_MAP_LOOKUP_REMOVE_IF_FOUND); + // TODO raise KeyError if obj didn't exist in map + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(poll_unregister_obj, poll_unregister); + +/// \method modify(obj, eventmask) +STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t eventmask_in) { + mp_obj_poll_t *self = self_in; + mp_map_elem_t *elem = mp_map_lookup(&self->poll_map, mp_obj_id(obj_in), MP_MAP_LOOKUP); + if (elem == NULL) { + mp_raise_OSError(MP_ENOENT); + } + ((poll_obj_t*)elem->value)->flags = mp_obj_get_int(eventmask_in); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_3(poll_modify_obj, poll_modify); + +STATIC mp_uint_t poll_poll_internal(uint n_args, const mp_obj_t *args) { + mp_obj_poll_t *self = args[0]; + + // work out timeout (its given already in ms) + mp_uint_t timeout = -1; + int flags = 0; + if (n_args >= 2) { + if (args[1] != mp_const_none) { + mp_int_t timeout_i = mp_obj_get_int(args[1]); + if (timeout_i >= 0) { + timeout = timeout_i; + } + } + if (n_args >= 3) { + flags = mp_obj_get_int(args[2]); + } + } + + self->flags = flags; + + mp_uint_t start_tick = mp_hal_ticks_ms(); + mp_uint_t n_ready; + for (;;) { + // poll the objects + n_ready = poll_map_poll(&self->poll_map, NULL); + if (n_ready > 0 || (timeout != -1 && mp_hal_ticks_ms() - start_tick >= timeout)) { + break; + } + MICROPY_EVENT_POLL_HOOK + } + + return n_ready; +} + +STATIC mp_obj_t poll_poll(uint n_args, const mp_obj_t *args) { + mp_obj_poll_t *self = args[0]; + mp_uint_t n_ready = poll_poll_internal(n_args, args); + + // one or more objects are ready, or we had a timeout + mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL); + n_ready = 0; + for (mp_uint_t i = 0; i < self->poll_map.alloc; ++i) { + if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) { + continue; + } + poll_obj_t *poll_obj = (poll_obj_t*)self->poll_map.table[i].value; + if (poll_obj->flags_ret != 0) { + mp_obj_t tuple[2] = {poll_obj->obj, MP_OBJ_NEW_SMALL_INT(poll_obj->flags_ret)}; + ret_list->items[n_ready++] = mp_obj_new_tuple(2, tuple); + if (self->flags & FLAG_ONESHOT) { + // Don't poll next time, until new event flags will be set explicitly + poll_obj->flags = 0; + } + } + } + return ret_list; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_poll_obj, 1, 3, poll_poll); + +STATIC mp_obj_t poll_ipoll(size_t n_args, const mp_obj_t *args) { + mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]); + + if (self->ret_tuple == MP_OBJ_NULL) { + self->ret_tuple = mp_obj_new_tuple(2, NULL); + } + + int n_ready = poll_poll_internal(n_args, args); + self->iter_cnt = n_ready; + self->iter_idx = 0; + + return args[0]; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_ipoll_obj, 1, 3, poll_ipoll); + +STATIC mp_obj_t poll_iternext(mp_obj_t self_in) { + mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->iter_cnt == 0) { + return MP_OBJ_STOP_ITERATION; + } + + self->iter_cnt--; + + for (mp_uint_t i = self->iter_idx; i < self->poll_map.alloc; ++i) { + self->iter_idx++; + if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) { + continue; + } + poll_obj_t *poll_obj = (poll_obj_t*)self->poll_map.table[i].value; + if (poll_obj->flags_ret != 0) { + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->ret_tuple); + t->items[0] = poll_obj->obj; + t->items[1] = MP_OBJ_NEW_SMALL_INT(poll_obj->flags_ret); + if (self->flags & FLAG_ONESHOT) { + // Don't poll next time, until new event flags will be set explicitly + poll_obj->flags = 0; + } + return MP_OBJ_FROM_PTR(t); + } + } + + assert(!"inconsistent number of poll active entries"); + self->iter_cnt = 0; + return MP_OBJ_STOP_ITERATION; +} + +STATIC const mp_rom_map_elem_t poll_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(&poll_register_obj) }, + { MP_ROM_QSTR(MP_QSTR_unregister), MP_ROM_PTR(&poll_unregister_obj) }, + { MP_ROM_QSTR(MP_QSTR_modify), MP_ROM_PTR(&poll_modify_obj) }, + { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&poll_poll_obj) }, + { MP_ROM_QSTR(MP_QSTR_ipoll), MP_ROM_PTR(&poll_ipoll_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table); + +STATIC const mp_obj_type_t mp_type_poll = { + { &mp_type_type }, + .name = MP_QSTR_poll, + .getiter = mp_identity_getiter, + .iternext = poll_iternext, + .locals_dict = (void*)&poll_locals_dict, +}; + +/// \function poll() +STATIC mp_obj_t select_poll(void) { + mp_obj_poll_t *poll = m_new_obj(mp_obj_poll_t); + poll->base.type = &mp_type_poll; + mp_map_init(&poll->poll_map, 0); + poll->iter_cnt = 0; + poll->ret_tuple = MP_OBJ_NULL; + return poll; +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll); + +STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) }, + { MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) }, + { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) }, + { MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(MP_STREAM_POLL_RD) }, + { MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(MP_STREAM_POLL_WR) }, + { MP_ROM_QSTR(MP_QSTR_POLLERR), MP_ROM_INT(MP_STREAM_POLL_ERR) }, + { MP_ROM_QSTR(MP_QSTR_POLLHUP), MP_ROM_INT(MP_STREAM_POLL_HUP) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table); + +const mp_obj_module_t mp_module_uselect = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_select_globals, +}; + +#endif // MICROPY_PY_USELECT diff --git a/user/mpy/extmod/modussl_axtls.c b/user/mpy/extmod/modussl_axtls.c new file mode 100644 index 0000000..b5d2412 --- /dev/null +++ b/user/mpy/extmod/modussl_axtls.c @@ -0,0 +1,232 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015-2017 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/stream.h" + +#if MICROPY_PY_USSL && MICROPY_SSL_AXTLS + +#include "ssl.h" + +typedef struct _mp_obj_ssl_socket_t { + mp_obj_base_t base; + mp_obj_t sock; + SSL_CTX *ssl_ctx; + SSL *ssl_sock; + byte *buf; + uint32_t bytes_left; +} mp_obj_ssl_socket_t; + +struct ssl_args { + mp_arg_val_t server_side; + mp_arg_val_t server_hostname; +}; + +STATIC const mp_obj_type_t ussl_socket_type; + +STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { + mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); + o->base.type = &ussl_socket_type; + o->buf = NULL; + o->bytes_left = 0; + o->sock = sock; + + uint32_t options = SSL_SERVER_VERIFY_LATER; + if ((o->ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_CLNT_SESS)) == NULL) { + mp_raise_OSError(MP_EINVAL); + } + + if (args->server_side.u_bool) { + o->ssl_sock = ssl_server_new(o->ssl_ctx, (long)sock); + } else { + SSL_EXTENSIONS *ext = ssl_ext_new(); + + if (args->server_hostname.u_obj != mp_const_none) { + ext->host_name = (char*)mp_obj_str_get_str(args->server_hostname.u_obj); + } + + o->ssl_sock = ssl_client_new(o->ssl_ctx, (long)sock, NULL, 0, ext); + + int res = ssl_handshake_status(o->ssl_sock); + // Pointer to SSL_EXTENSIONS as being passed to ssl_client_new() + // is saved in ssl_sock->extensions. + // As of axTLS 2.1.3, extensions aren't used beyond the initial + // handshake, and that's pretty much how it's expected to be. So + // we allocate them on stack and reset the pointer after handshake. + + if (res != SSL_OK) { + printf("ssl_handshake_status: %d\n", res); + ssl_display_error(res); + mp_raise_OSError(MP_EIO); + } + + } + + return o; +} + +STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "<_SSLSocket %p>", self->ssl_sock); +} + +STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { + mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); + + if (o->ssl_sock == NULL) { + *errcode = EBADF; + return MP_STREAM_ERROR; + } + + while (o->bytes_left == 0) { + mp_int_t r = ssl_read(o->ssl_sock, &o->buf); + if (r == SSL_OK) { + // SSL_OK from ssl_read() means "everything is ok, but there's + // not user data yet. So, we just keep reading. + continue; + } + if (r < 0) { + if (r == SSL_CLOSE_NOTIFY || r == SSL_ERROR_CONN_LOST) { + // EOF + return 0; + } + *errcode = r; + return MP_STREAM_ERROR; + } + o->bytes_left = r; + } + + if (size > o->bytes_left) { + size = o->bytes_left; + } + memcpy(buf, o->buf, size); + o->buf += size; + o->bytes_left -= size; + return size; +} + +STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { + mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); + + if (o->ssl_sock == NULL) { + *errcode = EBADF; + return MP_STREAM_ERROR; + } + + mp_int_t r = ssl_write(o->ssl_sock, buf, size); + if (r < 0) { + *errcode = r; + return MP_STREAM_ERROR; + } + return r; +} + +STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { + // Currently supports only blocking mode + (void)self_in; + if (!mp_obj_is_true(flag_in)) { + mp_raise_NotImplementedError(""); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking); + +STATIC mp_obj_t socket_close(mp_obj_t self_in) { + mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); + if (self->ssl_sock != NULL) { + ssl_free(self->ssl_sock); + ssl_ctx_free(self->ssl_ctx); + self->ssl_sock = NULL; + return mp_stream_close(self->sock); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close); + +STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socket_close_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); + +STATIC const mp_stream_p_t ussl_socket_stream_p = { + .read = socket_read, + .write = socket_write, +}; + +STATIC const mp_obj_type_t ussl_socket_type = { + { &mp_type_type }, + // Save on qstr's, reuse same as for module + .name = MP_QSTR_ussl, + .print = socket_print, + .getiter = NULL, + .iternext = NULL, + .protocol = &ussl_socket_stream_p, + .locals_dict = (void*)&ussl_socket_locals_dict, +}; + +STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + // TODO: Implement more args + static const mp_arg_t allowed_args[] = { + { MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + }; + + // TODO: Check that sock implements stream protocol + mp_obj_t sock = pos_args[0]; + + struct ssl_args args; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); + + return MP_OBJ_FROM_PTR(socket_new(sock, &args)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); + +STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, + { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); + +const mp_obj_module_t mp_module_ussl = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_ssl_globals, +}; + +#endif // MICROPY_PY_USSL diff --git a/user/mpy/extmod/modussl_mbedtls.c b/user/mpy/extmod/modussl_mbedtls.c new file mode 100644 index 0000000..597eaee --- /dev/null +++ b/user/mpy/extmod/modussl_mbedtls.c @@ -0,0 +1,314 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Linaro 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS + +#include +#include +#include // needed because mp_is_nonblocking_error uses system error codes + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/stream.h" + +// mbedtls_time_t +#include "mbedtls/platform.h" +#include "mbedtls/net.h" +#include "mbedtls/ssl.h" +#include "mbedtls/x509_crt.h" +#include "mbedtls/pk.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/debug.h" + +typedef struct _mp_obj_ssl_socket_t { + mp_obj_base_t base; + mp_obj_t sock; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_x509_crt cacert; + mbedtls_x509_crt cert; + mbedtls_pk_context pkey; +} mp_obj_ssl_socket_t; + +struct ssl_args { + mp_arg_val_t key; + mp_arg_val_t cert; + mp_arg_val_t server_side; + mp_arg_val_t server_hostname; +}; + +STATIC const mp_obj_type_t ussl_socket_type; + +static void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) { + printf("DBG:%s:%04d: %s\n", file, line, str); +} + +// TODO: FIXME! +int null_entropy_func(void *data, unsigned char *output, size_t len) { + // enjoy random bytes + return 0; +} + +int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) { + mp_obj_t sock = *(mp_obj_t*)ctx; + + const mp_stream_p_t *sock_stream = mp_get_stream_raise(sock, MP_STREAM_OP_WRITE); + int err; + + int out_sz = sock_stream->write(sock, buf, len, &err); + if (out_sz == MP_STREAM_ERROR) { + if (mp_is_nonblocking_error(err)) { + return MBEDTLS_ERR_SSL_WANT_WRITE; + } + return -err; + } else { + return out_sz; + } +} + +int _mbedtls_ssl_recv(void *ctx, byte *buf, size_t len) { + mp_obj_t sock = *(mp_obj_t*)ctx; + + const mp_stream_p_t *sock_stream = mp_get_stream_raise(sock, MP_STREAM_OP_READ); + int err; + + int out_sz = sock_stream->read(sock, buf, len, &err); + if (out_sz == MP_STREAM_ERROR) { + if (mp_is_nonblocking_error(err)) { + return MBEDTLS_ERR_SSL_WANT_READ; + } + return -err; + } else { + return out_sz; + } +} + + +STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { + mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); + o->base.type = &ussl_socket_type; + + int ret; + mbedtls_ssl_init(&o->ssl); + mbedtls_ssl_config_init(&o->conf); + mbedtls_x509_crt_init(&o->cacert); + mbedtls_x509_crt_init(&o->cert); + mbedtls_pk_init(&o->pkey); + mbedtls_ctr_drbg_init(&o->ctr_drbg); + // Debug level (0-4) + mbedtls_debug_set_threshold(0); + + mbedtls_entropy_init(&o->entropy); + const byte seed[] = "upy"; + ret = mbedtls_ctr_drbg_seed(&o->ctr_drbg, null_entropy_func/*mbedtls_entropy_func*/, &o->entropy, seed, sizeof(seed)); + if (ret != 0) { + printf("ret=%d\n", ret); + assert(0); + } + + ret = mbedtls_ssl_config_defaults(&o->conf, + args->server_side.u_bool ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT); + if (ret != 0) { + assert(0); + } + + mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_NONE); + mbedtls_ssl_conf_rng(&o->conf, mbedtls_ctr_drbg_random, &o->ctr_drbg); + mbedtls_ssl_conf_dbg(&o->conf, mbedtls_debug, NULL); + + ret = mbedtls_ssl_setup(&o->ssl, &o->conf); + if (ret != 0) { + assert(0); + } + + if (args->server_hostname.u_obj != mp_const_none) { + const char *sni = mp_obj_str_get_str(args->server_hostname.u_obj); + ret = mbedtls_ssl_set_hostname(&o->ssl, sni); + if (ret != 0) { + assert(0); + } + } + + o->sock = sock; + mbedtls_ssl_set_bio(&o->ssl, &o->sock, _mbedtls_ssl_send, _mbedtls_ssl_recv, NULL); + + if (args->key.u_obj != MP_OBJ_NULL) { + size_t key_len; + const byte *key = (const byte*)mp_obj_str_get_data(args->key.u_obj, &key_len); + // len should include terminating null + ret = mbedtls_pk_parse_key(&o->pkey, key, key_len + 1, NULL, 0); + assert(ret == 0); + + size_t cert_len; + const byte *cert = (const byte*)mp_obj_str_get_data(args->cert.u_obj, &cert_len); + // len should include terminating null + ret = mbedtls_x509_crt_parse(&o->cert, cert, cert_len + 1); + assert(ret == 0); + + ret = mbedtls_ssl_conf_own_cert(&o->conf, &o->cert, &o->pkey); + assert(ret == 0); + } + + while ((ret = mbedtls_ssl_handshake(&o->ssl)) != 0) { + if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { + //assert(0); + printf("mbedtls_ssl_handshake error: -%x\n", -ret); + mp_raise_OSError(MP_EIO); + } + } + + return o; +} + +STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "<_SSLSocket %p>", self); +} + +STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { + mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); + + int ret = mbedtls_ssl_read(&o->ssl, buf, size); + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // end of stream + return 0; + } + if (ret >= 0) { + return ret; + } + if (ret == MBEDTLS_ERR_SSL_WANT_READ) { + ret = MP_EWOULDBLOCK; + } + *errcode = ret; + return MP_STREAM_ERROR; +} + +STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { + mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); + + int ret = mbedtls_ssl_write(&o->ssl, buf, size); + if (ret >= 0) { + return ret; + } + if (ret == MBEDTLS_ERR_SSL_WANT_WRITE) { + ret = MP_EWOULDBLOCK; + } + *errcode = ret; + return MP_STREAM_ERROR; +} + +STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { + mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(self_in); + mp_obj_t sock = o->sock; + mp_obj_t dest[3]; + mp_load_method(sock, MP_QSTR_setblocking, dest); + dest[2] = flag_in; + return mp_call_method_n_kw(1, 0, dest); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking); + +STATIC mp_obj_t socket_close(mp_obj_t self_in) { + mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); + + mbedtls_pk_free(&self->pkey); + mbedtls_x509_crt_free(&self->cert); + mbedtls_x509_crt_free(&self->cacert); + mbedtls_ssl_free(&self->ssl); + mbedtls_ssl_config_free(&self->conf); + mbedtls_ctr_drbg_free(&self->ctr_drbg); + mbedtls_entropy_free(&self->entropy); + + return mp_stream_close(self->sock); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close); + +STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socket_close_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); + +STATIC const mp_stream_p_t ussl_socket_stream_p = { + .read = socket_read, + .write = socket_write, +}; + +STATIC const mp_obj_type_t ussl_socket_type = { + { &mp_type_type }, + // Save on qstr's, reuse same as for module + .name = MP_QSTR_ussl, + .print = socket_print, + .getiter = NULL, + .iternext = NULL, + .protocol = &ussl_socket_stream_p, + .locals_dict = (void*)&ussl_socket_locals_dict, +}; + +STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + // TODO: Implement more args + static const mp_arg_t allowed_args[] = { + { MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + }; + + // TODO: Check that sock implements stream protocol + mp_obj_t sock = pos_args[0]; + + struct ssl_args args; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); + + return MP_OBJ_FROM_PTR(socket_new(sock, &args)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); + +STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, + { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); + +const mp_obj_module_t mp_module_ussl = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_ssl_globals, +}; + +#endif // MICROPY_PY_USSL diff --git a/user/mpy/extmod/modutimeq.c b/user/mpy/extmod/modutimeq.c new file mode 100644 index 0000000..a19b3fd --- /dev/null +++ b/user/mpy/extmod/modutimeq.c @@ -0,0 +1,232 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Damien P. George + * Copyright (c) 2016-2017 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. + */ + +#include + +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/smallint.h" + +#if MICROPY_PY_UTIMEQ + +#define MODULO MICROPY_PY_UTIME_TICKS_PERIOD + +#define DEBUG 0 + +// the algorithm here is modelled on CPython's heapq.py + +struct qentry { + mp_uint_t time; + mp_uint_t id; + mp_obj_t callback; + mp_obj_t args; +}; + +typedef struct _mp_obj_utimeq_t { + mp_obj_base_t base; + mp_uint_t alloc; + mp_uint_t len; + struct qentry items[]; +} mp_obj_utimeq_t; + +STATIC mp_uint_t utimeq_id; + +STATIC mp_obj_utimeq_t *get_heap(mp_obj_t heap_in) { + return MP_OBJ_TO_PTR(heap_in); +} + +STATIC bool time_less_than(struct qentry *item, struct qentry *parent) { + mp_uint_t item_tm = item->time; + mp_uint_t parent_tm = parent->time; + mp_uint_t res = parent_tm - item_tm; + if (res == 0) { + // TODO: This actually should use the same "ring" logic + // as for time, to avoid artifacts when id's overflow. + return item->id < parent->id; + } + if ((mp_int_t)res < 0) { + res += MODULO; + } + return res && res < (MODULO / 2); +} + +STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); + mp_uint_t alloc = mp_obj_get_int(args[0]); + mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc); + o->base.type = type; + memset(o->items, 0, sizeof(*o->items) * alloc); + o->alloc = alloc; + o->len = 0; + return MP_OBJ_FROM_PTR(o); +} + +STATIC void heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) { + struct qentry item = heap->items[pos]; + while (pos > start_pos) { + mp_uint_t parent_pos = (pos - 1) >> 1; + struct qentry *parent = &heap->items[parent_pos]; + bool lessthan = time_less_than(&item, parent); + if (lessthan) { + heap->items[pos] = *parent; + pos = parent_pos; + } else { + break; + } + } + heap->items[pos] = item; +} + +STATIC void heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) { + mp_uint_t start_pos = pos; + mp_uint_t end_pos = heap->len; + struct qentry item = heap->items[pos]; + for (mp_uint_t child_pos = 2 * pos + 1; child_pos < end_pos; child_pos = 2 * pos + 1) { + // choose right child if it's <= left child + if (child_pos + 1 < end_pos) { + bool lessthan = time_less_than(&heap->items[child_pos], &heap->items[child_pos + 1]); + if (!lessthan) { + child_pos += 1; + } + } + // bubble up the smaller child + heap->items[pos] = heap->items[child_pos]; + pos = child_pos; + } + heap->items[pos] = item; + heap_siftdown(heap, start_pos, pos); +} + +STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) { + (void)n_args; + mp_obj_t heap_in = args[0]; + mp_obj_utimeq_t *heap = get_heap(heap_in); + if (heap->len == heap->alloc) { + mp_raise_msg(&mp_type_IndexError, "queue overflow"); + } + mp_uint_t l = heap->len; + heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]); + heap->items[l].id = utimeq_id++; + heap->items[l].callback = args[2]; + heap->items[l].args = args[3]; + heap_siftdown(heap, 0, heap->len); + heap->len++; + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush); + +STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) { + mp_obj_utimeq_t *heap = get_heap(heap_in); + if (heap->len == 0) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap")); + } + mp_obj_list_t *ret = MP_OBJ_TO_PTR(list_ref); + if (!MP_OBJ_IS_TYPE(list_ref, &mp_type_list) || ret->len < 3) { + mp_raise_TypeError(""); + } + + struct qentry *item = &heap->items[0]; + ret->items[0] = MP_OBJ_NEW_SMALL_INT(item->time); + ret->items[1] = item->callback; + ret->items[2] = item->args; + heap->len -= 1; + heap->items[0] = heap->items[heap->len]; + heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer + heap->items[heap->len].args = MP_OBJ_NULL; + if (heap->len) { + heap_siftup(heap, 0); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop); + +STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) { + mp_obj_utimeq_t *heap = get_heap(heap_in); + if (heap->len == 0) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap")); + } + + struct qentry *item = &heap->items[0]; + return MP_OBJ_NEW_SMALL_INT(item->time); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime); + +#if DEBUG +STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) { + mp_obj_utimeq_t *heap = get_heap(heap_in); + for (int i = 0; i < heap->len; i++) { + printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time, + MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args)); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_dump_obj, mod_utimeq_dump); +#endif + +STATIC mp_obj_t utimeq_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_utimeq_t *self = MP_OBJ_TO_PTR(self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC const mp_rom_map_elem_t utimeq_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_push), MP_ROM_PTR(&mod_utimeq_heappush_obj) }, + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&mod_utimeq_heappop_obj) }, + { MP_ROM_QSTR(MP_QSTR_peektime), MP_ROM_PTR(&mod_utimeq_peektime_obj) }, + #if DEBUG + { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_utimeq_dump_obj) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table); + +STATIC const mp_obj_type_t utimeq_type = { + { &mp_type_type }, + .name = MP_QSTR_utimeq, + .make_new = utimeq_make_new, + .unary_op = utimeq_unary_op, + .locals_dict = (void*)&utimeq_locals_dict, +}; + +STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utimeq) }, + { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&utimeq_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_utimeq_globals, mp_module_utimeq_globals_table); + +const mp_obj_module_t mp_module_utimeq = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_utimeq_globals, +}; + +#endif //MICROPY_PY_UTIMEQ diff --git a/user/mpy/extmod/moduzlib.c b/user/mpy/extmod/moduzlib.c new file mode 100644 index 0000000..b446dba --- /dev/null +++ b/user/mpy/extmod/moduzlib.c @@ -0,0 +1,225 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014-2016 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/stream.h" +#include "py/mperrno.h" + +#if MICROPY_PY_UZLIB + +#include "uzlib/tinf.h" + +#if 0 // print debugging info +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +typedef struct _mp_obj_decompio_t { + mp_obj_base_t base; + mp_obj_t src_stream; + TINF_DATA decomp; + bool eof; +} mp_obj_decompio_t; + +STATIC unsigned char read_src_stream(TINF_DATA *data) { + byte *p = (void*)data; + p -= offsetof(mp_obj_decompio_t, decomp); + mp_obj_decompio_t *self = (mp_obj_decompio_t*)p; + + const mp_stream_p_t *stream = mp_get_stream_raise(self->src_stream, MP_STREAM_OP_READ); + int err; + byte c; + mp_uint_t out_sz = stream->read(self->src_stream, &c, 1, &err); + if (out_sz == MP_STREAM_ERROR) { + mp_raise_OSError(err); + } + if (out_sz == 0) { + nlr_raise(mp_obj_new_exception(&mp_type_EOFError)); + } + return c; +} + +STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); + mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t); + o->base.type = type; + memset(&o->decomp, 0, sizeof(o->decomp)); + o->decomp.readSource = read_src_stream; + o->src_stream = args[0]; + o->eof = false; + + mp_int_t dict_opt = 0; + int dict_sz; + if (n_args > 1) { + dict_opt = mp_obj_get_int(args[1]); + } + + if (dict_opt >= 16) { + int st = uzlib_gzip_parse_header(&o->decomp); + if (st != TINF_OK) { + goto header_error; + } + dict_sz = 1 << (dict_opt - 16); + } else if (dict_opt >= 0) { + dict_opt = uzlib_zlib_parse_header(&o->decomp); + if (dict_opt < 0) { +header_error: + mp_raise_ValueError("compression header"); + } + dict_sz = 1 << dict_opt; + } else { + dict_sz = 1 << -dict_opt; + } + + uzlib_uncompress_init(&o->decomp, m_new(byte, dict_sz), dict_sz); + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_uint_t decompio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { + mp_obj_decompio_t *o = MP_OBJ_TO_PTR(o_in); + if (o->eof) { + return 0; + } + + o->decomp.dest = buf; + o->decomp.destSize = size; + int st = uzlib_uncompress_chksum(&o->decomp); + if (st == TINF_DONE) { + o->eof = true; + } + if (st < 0) { + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } + return o->decomp.dest - (byte*)buf; +} + +STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); + +STATIC const mp_stream_p_t decompio_stream_p = { + .read = decompio_read, +}; + +STATIC const mp_obj_type_t decompio_type = { + { &mp_type_type }, + .name = MP_QSTR_DecompIO, + .make_new = decompio_make_new, + .protocol = &decompio_stream_p, + .locals_dict = (void*)&decompio_locals_dict, +}; + +STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { + mp_obj_t data = args[0]; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); + + TINF_DATA *decomp = m_new_obj(TINF_DATA); + memset(decomp, 0, sizeof(*decomp)); + DEBUG_printf("sizeof(TINF_DATA)=" UINT_FMT "\n", sizeof(*decomp)); + uzlib_uncompress_init(decomp, NULL, 0); + mp_uint_t dest_buf_size = (bufinfo.len + 15) & ~15; + byte *dest_buf = m_new(byte, dest_buf_size); + + decomp->dest = dest_buf; + decomp->destSize = dest_buf_size; + DEBUG_printf("uzlib: Initial out buffer: " UINT_FMT " bytes\n", decomp->destSize); + decomp->source = bufinfo.buf; + + int st; + bool is_zlib = true; + + if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) { + is_zlib = false; + } + + if (is_zlib) { + st = uzlib_zlib_parse_header(decomp); + if (st < 0) { + goto error; + } + } + + while (1) { + st = uzlib_uncompress_chksum(decomp); + if (st < 0) { + goto error; + } + if (st == TINF_DONE) { + break; + } + size_t offset = decomp->dest - dest_buf; + dest_buf = m_renew(byte, dest_buf, dest_buf_size, dest_buf_size + 256); + dest_buf_size += 256; + decomp->dest = dest_buf + offset; + decomp->destSize = 256; + } + + mp_uint_t final_sz = decomp->dest - dest_buf; + DEBUG_printf("uzlib: Resizing from " UINT_FMT " to final size: " UINT_FMT " bytes\n", dest_buf_size, final_sz); + dest_buf = (byte*)m_renew(byte, dest_buf, dest_buf_size, final_sz); + mp_obj_t res = mp_obj_new_bytearray_by_ref(final_sz, dest_buf); + m_del_obj(TINF_DATA, decomp); + return res; + +error: + nlr_raise(mp_obj_new_exception_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st))); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress); + +STATIC const mp_rom_map_elem_t mp_module_uzlib_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uzlib) }, + { MP_ROM_QSTR(MP_QSTR_decompress), MP_ROM_PTR(&mod_uzlib_decompress_obj) }, + { MP_ROM_QSTR(MP_QSTR_DecompIO), MP_ROM_PTR(&decompio_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_uzlib_globals, mp_module_uzlib_globals_table); + +const mp_obj_module_t mp_module_uzlib = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_uzlib_globals, +}; + +// Source files #include'd here to make sure they're compiled in +// only if module is enabled by config setting. + +#include "uzlib/tinflate.c" +#include "uzlib/tinfzlib.c" +#include "uzlib/tinfgzip.c" +#include "uzlib/adler32.c" +#include "uzlib/crc32.c" + +#endif // MICROPY_PY_UZLIB diff --git a/user/mpy/extmod/modwebrepl.c b/user/mpy/extmod/modwebrepl.c new file mode 100644 index 0000000..d618f53 --- /dev/null +++ b/user/mpy/extmod/modwebrepl.c @@ -0,0 +1,354 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "py/stream.h" +#include "py/builtin.h" +#ifdef MICROPY_PY_WEBREPL_DELAY +#include "py/mphal.h" +#endif +#include "extmod/modwebsocket.h" +#include "genhdr/mpversion.h" + +#if MICROPY_PY_WEBREPL + +#if 0 // print debugging info +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +struct webrepl_file { + char sig[2]; + char type; + char flags; + uint64_t offset; + uint32_t size; + uint16_t fname_len; + char fname[64]; +} __attribute__((packed)); + +enum { PUT_FILE = 1, GET_FILE, GET_VER }; +enum { STATE_PASSWD, STATE_NORMAL }; + +typedef struct _mp_obj_webrepl_t { + mp_obj_base_t base; + mp_obj_t sock; + byte state; + byte hdr_to_recv; + uint32_t data_to_recv; + struct webrepl_file hdr; + mp_obj_t cur_file; +} mp_obj_webrepl_t; + +// These get passed to functions which aren't force-l32, so can't be const +STATIC char passwd_prompt[] = "Password: "; +STATIC char connected_prompt[] = "\r\nWebREPL connected\r\n>>> "; +STATIC char denied_prompt[] = "\r\nAccess denied\r\n"; + +STATIC char webrepl_passwd[10]; + +STATIC void write_webrepl(mp_obj_t websock, const void *buf, size_t len) { + const mp_stream_p_t *sock_stream = mp_get_stream_raise(websock, MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); + int err; + int old_opts = sock_stream->ioctl(websock, MP_STREAM_SET_DATA_OPTS, FRAME_BIN, &err); + sock_stream->write(websock, buf, len, &err); + sock_stream->ioctl(websock, MP_STREAM_SET_DATA_OPTS, old_opts, &err); +} + +#define SSTR(s) s, sizeof(s) - 1 +STATIC void write_webrepl_str(mp_obj_t websock, const char *str, int sz) { + int err; + const mp_stream_p_t *sock_stream = mp_get_stream_raise(websock, MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); + sock_stream->write(websock, str, sz, &err); +} + +STATIC void write_webrepl_resp(mp_obj_t websock, uint16_t code) { + char buf[4] = {'W', 'B', code & 0xff, code >> 8}; + write_webrepl(websock, buf, sizeof(buf)); +} + +STATIC mp_obj_t webrepl_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); + mp_get_stream_raise(args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); + DEBUG_printf("sizeof(struct webrepl_file) = %lu\n", sizeof(struct webrepl_file)); + mp_obj_webrepl_t *o = m_new_obj(mp_obj_webrepl_t); + o->base.type = type; + o->sock = args[0]; + o->hdr_to_recv = sizeof(struct webrepl_file); + o->data_to_recv = 0; + o->state = STATE_PASSWD; + write_webrepl_str(args[0], SSTR(passwd_prompt)); + return o; +} + +STATIC int write_file_chunk(mp_obj_webrepl_t *self) { + const mp_stream_p_t *file_stream = + mp_get_stream_raise(self->cur_file, MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); + byte readbuf[2 + 256]; + int err; + mp_uint_t out_sz = file_stream->read(self->cur_file, readbuf + 2, sizeof(readbuf) - 2, &err); + if (out_sz == MP_STREAM_ERROR) { + return out_sz; + } + readbuf[0] = out_sz; + readbuf[1] = out_sz >> 8; + DEBUG_printf("webrepl: Sending %d bytes of file\n", out_sz); + write_webrepl(self->sock, readbuf, 2 + out_sz); + return out_sz; +} + +STATIC void handle_op(mp_obj_webrepl_t *self) { + + // Handle operations not requiring opened file + + switch (self->hdr.type) { + case GET_VER: { + static char ver[] = {MICROPY_VERSION_MAJOR, MICROPY_VERSION_MINOR, MICROPY_VERSION_MICRO}; + write_webrepl(self->sock, ver, sizeof(ver)); + self->hdr_to_recv = sizeof(struct webrepl_file); + return; + } + } + + // Handle operations requiring opened file + + mp_obj_t open_args[2] = { + mp_obj_new_str(self->hdr.fname, strlen(self->hdr.fname), false), + MP_OBJ_NEW_QSTR(MP_QSTR_rb) + }; + + if (self->hdr.type == PUT_FILE) { + open_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_wb); + } + + self->cur_file = mp_builtin_open(2, open_args, (mp_map_t*)&mp_const_empty_map); + + #if 0 + struct mp_stream_seek_t seek = { .offset = self->hdr.offset, .whence = 0 }; + int err; + mp_uint_t res = file_stream->ioctl(self->cur_file, MP_STREAM_SEEK, (uintptr_t)&seek, &err); + assert(res != MP_STREAM_ERROR); + #endif + + write_webrepl_resp(self->sock, 0); + + if (self->hdr.type == PUT_FILE) { + self->data_to_recv = self->hdr.size; + } else if (self->hdr.type == GET_FILE) { + self->data_to_recv = 1; + } +} + +STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode); + +STATIC mp_uint_t webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + mp_uint_t out_sz; + do { + out_sz = _webrepl_read(self_in, buf, size, errcode); + } while (out_sz == -2); + return out_sz; +} + +STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + // We know that os.dupterm always calls with size = 1 + assert(size == 1); + mp_obj_webrepl_t *self = self_in; + const mp_stream_p_t *sock_stream = mp_get_stream_raise(self->sock, MP_STREAM_OP_READ); + mp_uint_t out_sz = sock_stream->read(self->sock, buf, size, errcode); + //DEBUG_printf("webrepl: Read %d initial bytes from websocket\n", out_sz); + if (out_sz == 0 || out_sz == MP_STREAM_ERROR) { + return out_sz; + } + + if (self->state == STATE_PASSWD) { + char c = *(char*)buf; + if (c == '\r' || c == '\n') { + self->hdr.fname[self->data_to_recv] = 0; + DEBUG_printf("webrepl: entered password: %s\n", self->hdr.fname); + + if (strcmp(self->hdr.fname, webrepl_passwd) != 0) { + write_webrepl_str(self->sock, SSTR(denied_prompt)); + return 0; + } + + self->state = STATE_NORMAL; + self->data_to_recv = 0; + write_webrepl_str(self->sock, SSTR(connected_prompt)); + } else if (self->data_to_recv < 10) { + self->hdr.fname[self->data_to_recv++] = c; + } + return -2; + } + + // If last read data belonged to text record (== REPL) + int err; + if (sock_stream->ioctl(self->sock, MP_STREAM_GET_DATA_OPTS, 0, &err) == 1) { + return out_sz; + } + + DEBUG_printf("webrepl: received bin data, hdr_to_recv: %d, data_to_recv=%d\n", self->hdr_to_recv, self->data_to_recv); + + if (self->hdr_to_recv != 0) { + char *p = (char*)&self->hdr + sizeof(self->hdr) - self->hdr_to_recv; + *p++ = *(char*)buf; + if (--self->hdr_to_recv != 0) { + mp_uint_t hdr_sz = sock_stream->read(self->sock, p, self->hdr_to_recv, errcode); + if (hdr_sz == MP_STREAM_ERROR) { + return hdr_sz; + } + self->hdr_to_recv -= hdr_sz; + if (self->hdr_to_recv != 0) { + return -2; + } + } + + DEBUG_printf("webrepl: op: %d, file: %s, chunk @%x, sz=%d\n", self->hdr.type, self->hdr.fname, (uint32_t)self->hdr.offset, self->hdr.size); + + handle_op(self); + + return -2; + } + + if (self->data_to_recv != 0) { + static byte filebuf[512]; + filebuf[0] = *(byte*)buf; + mp_uint_t buf_sz = 1; + if (--self->data_to_recv != 0) { + size_t to_read = MIN(sizeof(filebuf) - 1, self->data_to_recv); + mp_uint_t sz = sock_stream->read(self->sock, filebuf + 1, to_read, errcode); + if (sz == MP_STREAM_ERROR) { + return sz; + } + self->data_to_recv -= sz; + buf_sz += sz; + } + + if (self->hdr.type == PUT_FILE) { + DEBUG_printf("webrepl: Writing %lu bytes to file\n", buf_sz); + int err; + mp_uint_t res = mp_stream_write_exactly(self->cur_file, filebuf, buf_sz, &err); + if (err != 0 || res != buf_sz) { + assert(0); + } + } else if (self->hdr.type == GET_FILE) { + assert(buf_sz == 1); + assert(self->data_to_recv == 0); + assert(filebuf[0] == 0); + mp_uint_t out_sz = write_file_chunk(self); + if (out_sz != 0) { + self->data_to_recv = 1; + } + } + + if (self->data_to_recv == 0) { + mp_stream_close(self->cur_file); + self->hdr_to_recv = sizeof(struct webrepl_file); + DEBUG_printf("webrepl: Finished file operation %d\n", self->hdr.type); + write_webrepl_resp(self->sock, 0); + } + + #ifdef MICROPY_PY_WEBREPL_DELAY + // Some platforms may have broken drivers and easily gets + // overloaded with modest traffic WebREPL file transfers + // generate. The basic workaround is a crude rate control + // done in such way. + mp_hal_delay_ms(MICROPY_PY_WEBREPL_DELAY); + #endif + } + + return -2; +} + +STATIC mp_uint_t webrepl_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + mp_obj_webrepl_t *self = self_in; + if (self->state == STATE_PASSWD) { + // Don't forward output until passwd is entered + return size; + } + const mp_stream_p_t *stream_p = mp_get_stream_raise(self->sock, MP_STREAM_OP_WRITE); + return stream_p->write(self->sock, buf, size, errcode); +} + +STATIC mp_obj_t webrepl_close(mp_obj_t self_in) { + mp_obj_webrepl_t *self = MP_OBJ_TO_PTR(self_in); + // TODO: This is a place to do cleanup + return mp_stream_close(self->sock); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(webrepl_close_obj, webrepl_close); + +STATIC mp_obj_t webrepl_set_password(mp_obj_t passwd_in) { + size_t len; + const char *passwd = mp_obj_str_get_data(passwd_in, &len); + if (len > sizeof(webrepl_passwd) - 1) { + mp_raise_ValueError(""); + } + strcpy(webrepl_passwd, passwd); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(webrepl_set_password_obj, webrepl_set_password); + +STATIC const mp_rom_map_elem_t webrepl_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&webrepl_close_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table); + +STATIC const mp_stream_p_t webrepl_stream_p = { + .read = webrepl_read, + .write = webrepl_write, +}; + +STATIC const mp_obj_type_t webrepl_type = { + { &mp_type_type }, + .name = MP_QSTR__webrepl, + .make_new = webrepl_make_new, + .protocol = &webrepl_stream_p, + .locals_dict = (mp_obj_dict_t*)&webrepl_locals_dict, +}; + +STATIC const mp_rom_map_elem_t webrepl_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__webrepl) }, + { MP_ROM_QSTR(MP_QSTR__webrepl), MP_ROM_PTR(&webrepl_type) }, + { MP_ROM_QSTR(MP_QSTR_password), MP_ROM_PTR(&webrepl_set_password_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(webrepl_module_globals, webrepl_module_globals_table); + +const mp_obj_module_t mp_module_webrepl = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&webrepl_module_globals, +}; + +#endif // MICROPY_PY_WEBREPL diff --git a/user/mpy/extmod/modwebsocket.c b/user/mpy/extmod/modwebsocket.c new file mode 100644 index 0000000..6c6e32c --- /dev/null +++ b/user/mpy/extmod/modwebsocket.c @@ -0,0 +1,318 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "py/stream.h" +#include "extmod/modwebsocket.h" + +#if MICROPY_PY_WEBSOCKET + +enum { FRAME_HEADER, FRAME_OPT, PAYLOAD, CONTROL }; + +enum { BLOCKING_WRITE = 0x80 }; + +typedef struct _mp_obj_websocket_t { + mp_obj_base_t base; + mp_obj_t sock; + uint32_t msg_sz; + byte mask[4]; + byte state; + byte to_recv; + byte mask_pos; + byte buf_pos; + byte buf[6]; + byte opts; + // Copy of last data frame flags + byte ws_flags; + // Copy of current frame flags + byte last_flags; +} mp_obj_websocket_t; + +STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode); + +STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); + mp_obj_websocket_t *o = m_new_obj(mp_obj_websocket_t); + o->base.type = type; + o->sock = args[0]; + o->state = FRAME_HEADER; + o->to_recv = 2; + o->mask_pos = 0; + o->buf_pos = 0; + o->opts = FRAME_TXT; + if (n_args > 1 && args[1] == mp_const_true) { + o->opts |= BLOCKING_WRITE; + } + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); + const mp_stream_p_t *stream_p = mp_get_stream_raise(self->sock, MP_STREAM_OP_READ); + while (1) { + if (self->to_recv != 0) { + mp_uint_t out_sz = stream_p->read(self->sock, self->buf + self->buf_pos, self->to_recv, errcode); + if (out_sz == 0 || out_sz == MP_STREAM_ERROR) { + return out_sz; + } + self->buf_pos += out_sz; + self->to_recv -= out_sz; + if (self->to_recv != 0) { + *errcode = MP_EAGAIN; + return MP_STREAM_ERROR; + } + } + + switch (self->state) { + case FRAME_HEADER: { + // TODO: Split frame handling below is untested so far, so conservatively disable it + assert(self->buf[0] & 0x80); + + // "Control frames MAY be injected in the middle of a fragmented message." + // So, they must be processed before data frames (and not alter + // self->ws_flags) + byte frame_type = self->buf[0]; + self->last_flags = frame_type; + frame_type &= FRAME_OPCODE_MASK; + + if ((self->buf[0] & FRAME_OPCODE_MASK) == FRAME_CONT) { + // Preserve previous frame type + self->ws_flags = (self->ws_flags & FRAME_OPCODE_MASK) | (self->buf[0] & ~FRAME_OPCODE_MASK); + } else { + self->ws_flags = self->buf[0]; + } + + // Reset mask in case someone will use "simplified" protocol + // without masks. + memset(self->mask, 0, sizeof(self->mask)); + + int to_recv = 0; + size_t sz = self->buf[1] & 0x7f; + if (sz == 126) { + // Msg size is next 2 bytes + to_recv += 2; + } else if (sz == 127) { + // Msg size is next 8 bytes + assert(0); + } + if (self->buf[1] & 0x80) { + // Next 4 bytes is mask + to_recv += 4; + } + + self->buf_pos = 0; + self->to_recv = to_recv; + self->msg_sz = sz; // May be overridden by FRAME_OPT + if (to_recv != 0) { + self->state = FRAME_OPT; + } else { + if (frame_type >= FRAME_CLOSE) { + self->state = CONTROL; + } else { + self->state = PAYLOAD; + } + } + continue; + } + + case FRAME_OPT: { + if ((self->buf_pos & 3) == 2) { + // First two bytes are message length + self->msg_sz = (self->buf[0] << 8) | self->buf[1]; + } + if (self->buf_pos >= 4) { + // Last 4 bytes is mask + memcpy(self->mask, self->buf + self->buf_pos - 4, 4); + } + self->buf_pos = 0; + if ((self->last_flags & FRAME_OPCODE_MASK) >= FRAME_CLOSE) { + self->state = CONTROL; + } else { + self->state = PAYLOAD; + } + continue; + } + + case PAYLOAD: + case CONTROL: { + mp_uint_t out_sz = 0; + if (self->msg_sz == 0) { + // In case message had zero payload + goto no_payload; + } + + size_t sz = MIN(size, self->msg_sz); + out_sz = stream_p->read(self->sock, buf, sz, errcode); + if (out_sz == 0 || out_sz == MP_STREAM_ERROR) { + return out_sz; + } + + sz = out_sz; + for (byte *p = buf; sz--; p++) { + *p ^= self->mask[self->mask_pos++ & 3]; + } + + self->msg_sz -= out_sz; + if (self->msg_sz == 0) { + byte last_state; +no_payload: + last_state = self->state; + self->state = FRAME_HEADER; + self->to_recv = 2; + self->mask_pos = 0; + self->buf_pos = 0; + + // Handle control frame + if (last_state == CONTROL) { + byte frame_type = self->last_flags & FRAME_OPCODE_MASK; + if (frame_type == FRAME_CLOSE) { + static char close_resp[2] = {0x88, 0}; + int err; + websocket_write(self_in, close_resp, sizeof(close_resp), &err); + return 0; + } + + //DEBUG_printf("Finished receiving ctrl message %x, ignoring\n", self->last_flags); + continue; + } + } + + if (out_sz != 0) { + return out_sz; + } + // Empty (data) frame received is not EOF + continue; + } + + } + } +} + +STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); + assert(size < 0x10000); + byte header[4] = {0x80 | (self->opts & FRAME_OPCODE_MASK)}; + int hdr_sz; + if (size < 126) { + header[1] = size; + hdr_sz = 2; + } else { + header[1] = 126; + header[2] = size >> 8; + header[3] = size & 0xff; + hdr_sz = 4; + } + + mp_obj_t dest[3]; + if (self->opts & BLOCKING_WRITE) { + mp_load_method(self->sock, MP_QSTR_setblocking, dest); + dest[2] = mp_const_true; + mp_call_method_n_kw(1, 0, dest); + } + + mp_uint_t out_sz = mp_stream_write_exactly(self->sock, header, hdr_sz, errcode); + if (*errcode == 0) { + out_sz = mp_stream_write_exactly(self->sock, buf, size, errcode); + } + + if (self->opts & BLOCKING_WRITE) { + dest[2] = mp_const_false; + mp_call_method_n_kw(1, 0, dest); + } + + if (*errcode != 0) { + return MP_STREAM_ERROR; + } + return out_sz; +} + +STATIC mp_uint_t websocket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { + mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); + switch (request) { + case MP_STREAM_GET_DATA_OPTS: + return self->ws_flags & FRAME_OPCODE_MASK; + case MP_STREAM_SET_DATA_OPTS: { + int cur = self->opts & FRAME_OPCODE_MASK; + self->opts = (self->opts & ~FRAME_OPCODE_MASK) | (arg & FRAME_OPCODE_MASK); + return cur; + } + default: + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } +} + +STATIC mp_obj_t websocket_close(mp_obj_t self_in) { + mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); + // TODO: Send close signaling to the other side, otherwise it's + // abrupt close (connection abort). + return mp_stream_close(self->sock); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(websocket_close_obj, websocket_close); + +STATIC const mp_rom_map_elem_t websocket_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&mp_stream_ioctl_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&websocket_close_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table); + +STATIC const mp_stream_p_t websocket_stream_p = { + .read = websocket_read, + .write = websocket_write, + .ioctl = websocket_ioctl, +}; + +STATIC const mp_obj_type_t websocket_type = { + { &mp_type_type }, + .name = MP_QSTR_websocket, + .make_new = websocket_make_new, + .protocol = &websocket_stream_p, + .locals_dict = (void*)&websocket_locals_dict, +}; + +STATIC const mp_rom_map_elem_t websocket_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_websocket) }, + { MP_ROM_QSTR(MP_QSTR_websocket), MP_ROM_PTR(&websocket_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(websocket_module_globals, websocket_module_globals_table); + +const mp_obj_module_t mp_module_websocket = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&websocket_module_globals, +}; + +#endif // MICROPY_PY_WEBSOCKET diff --git a/user/mpy/extmod/modwebsocket.h b/user/mpy/extmod/modwebsocket.h new file mode 100644 index 0000000..2720147 --- /dev/null +++ b/user/mpy/extmod/modwebsocket.h @@ -0,0 +1,10 @@ +#ifndef MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H +#define MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H + +#define FRAME_OPCODE_MASK 0x0f +enum { + FRAME_CONT, FRAME_TXT, FRAME_BIN, + FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG +}; + +#endif // MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H diff --git a/user/mpy/extmod/re1.5/charclass.c b/user/mpy/extmod/re1.5/charclass.c new file mode 100644 index 0000000..7f6388c --- /dev/null +++ b/user/mpy/extmod/re1.5/charclass.c @@ -0,0 +1,33 @@ +#include "re1.5.h" + +int _re1_5_classmatch(const char *pc, const char *sp) +{ + // pc points to "cnt" byte after opcode + int is_positive = (pc[-1] == Class); + int cnt = *pc++; + while (cnt--) { + if (*sp >= *pc && *sp <= pc[1]) return is_positive; + pc += 2; + } + return !is_positive; +} + +int _re1_5_namedclassmatch(const char *pc, const char *sp) +{ + // pc points to name of class + int off = (*pc >> 5) & 1; + if ((*pc | 0x20) == 'd') { + if (!(*sp >= '0' && *sp <= '9')) { + off ^= 1; + } + } else if ((*pc | 0x20) == 's') { + if (!(*sp == ' ' || (*sp >= '\t' && *sp <= '\r'))) { + off ^= 1; + } + } else { // w + if (!((*sp >= 'A' && *sp <= 'Z') || (*sp >= 'a' && *sp <= 'z') || (*sp >= '0' && *sp <= '9') || *sp == '_')) { + off ^= 1; + } + } + return off; +} diff --git a/user/mpy/extmod/re1.5/compilecode.c b/user/mpy/extmod/re1.5/compilecode.c new file mode 100644 index 0000000..e4635f0 --- /dev/null +++ b/user/mpy/extmod/re1.5/compilecode.c @@ -0,0 +1,216 @@ +// Copyright 2014 Paul Sokolovsky. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "re1.5.h" + +#define INSERT_CODE(at, num, pc) \ + ((code ? memmove(code + at + num, code + at, pc - at) : (void)0), pc += num) +#define REL(at, to) (to - at - 2) +#define EMIT(at, byte) (code ? (code[at] = byte) : (void)(at)) +#define PC (prog->bytelen) + +static const char *_compilecode(const char *re, ByteProg *prog, int sizecode) +{ + char *code = sizecode ? NULL : prog->insts; + int start = PC; + int term = PC; + int alt_label = 0; + + for (; *re && *re != ')'; re++) { + switch (*re) { + case '\\': + re++; + if (!*re) return NULL; // Trailing backslash + if ((*re | 0x20) == 'd' || (*re | 0x20) == 's' || (*re | 0x20) == 'w') { + term = PC; + EMIT(PC++, NamedClass); + EMIT(PC++, *re); + prog->len++; + break; + } + default: + term = PC; + EMIT(PC++, Char); + EMIT(PC++, *re); + prog->len++; + break; + case '.': + term = PC; + EMIT(PC++, Any); + prog->len++; + break; + case '[': { + int cnt; + term = PC; + re++; + if (*re == '^') { + EMIT(PC++, ClassNot); + re++; + } else { + EMIT(PC++, Class); + } + PC++; // Skip # of pair byte + prog->len++; + for (cnt = 0; *re != ']'; re++, cnt++) { + if (!*re) return NULL; + EMIT(PC++, *re); + if (re[1] == '-') { + re += 2; + } + EMIT(PC++, *re); + } + EMIT(term + 1, cnt); + break; + } + case '(': { + term = PC; + int sub = 0; + int capture = re[1] != '?' || re[2] != ':'; + + if (capture) { + sub = ++prog->sub; + EMIT(PC++, Save); + EMIT(PC++, 2 * sub); + prog->len++; + } else { + re += 2; + } + + re = _compilecode(re + 1, prog, sizecode); + if (re == NULL || *re != ')') return NULL; // error, or no matching paren + + if (capture) { + EMIT(PC++, Save); + EMIT(PC++, 2 * sub + 1); + prog->len++; + } + + break; + } + case '?': + if (PC == term) return NULL; // nothing to repeat + INSERT_CODE(term, 2, PC); + if (re[1] == '?') { + EMIT(term, RSplit); + re++; + } else { + EMIT(term, Split); + } + EMIT(term + 1, REL(term, PC)); + prog->len++; + term = PC; + break; + case '*': + if (PC == term) return NULL; // nothing to repeat + INSERT_CODE(term, 2, PC); + EMIT(PC, Jmp); + EMIT(PC + 1, REL(PC, term)); + PC += 2; + if (re[1] == '?') { + EMIT(term, RSplit); + re++; + } else { + EMIT(term, Split); + } + EMIT(term + 1, REL(term, PC)); + prog->len += 2; + term = PC; + break; + case '+': + if (PC == term) return NULL; // nothing to repeat + if (re[1] == '?') { + EMIT(PC, Split); + re++; + } else { + EMIT(PC, RSplit); + } + EMIT(PC + 1, REL(PC, term)); + PC += 2; + prog->len++; + term = PC; + break; + case '|': + if (alt_label) { + EMIT(alt_label, REL(alt_label, PC) + 1); + } + INSERT_CODE(start, 2, PC); + EMIT(PC++, Jmp); + alt_label = PC++; + EMIT(start, Split); + EMIT(start + 1, REL(start, PC)); + prog->len += 2; + term = PC; + break; + case '^': + EMIT(PC++, Bol); + prog->len++; + term = PC; + break; + case '$': + EMIT(PC++, Eol); + prog->len++; + term = PC; + break; + } + } + + if (alt_label) { + EMIT(alt_label, REL(alt_label, PC) + 1); + } + return re; +} + +int re1_5_sizecode(const char *re) +{ + ByteProg dummyprog = { + // Save 0, Save 1, Match; more bytes for "search" (vs "match") prefix code + .bytelen = 5 + NON_ANCHORED_PREFIX + }; + + if (_compilecode(re, &dummyprog, /*sizecode*/1) == NULL) return -1; + + return dummyprog.bytelen; +} + +int re1_5_compilecode(ByteProg *prog, const char *re) +{ + prog->len = 0; + prog->bytelen = 0; + prog->sub = 0; + + // Add code to implement non-anchored operation ("search"), + // for anchored operation ("match"), this code will be just skipped. + // TODO: Implement search in much more efficient manner + prog->insts[prog->bytelen++] = RSplit; + prog->insts[prog->bytelen++] = 3; + prog->insts[prog->bytelen++] = Any; + prog->insts[prog->bytelen++] = Jmp; + prog->insts[prog->bytelen++] = -5; + prog->len += 3; + + prog->insts[prog->bytelen++] = Save; + prog->insts[prog->bytelen++] = 0; + prog->len++; + + re = _compilecode(re, prog, /*sizecode*/0); + if (re == NULL || *re) return 1; + + prog->insts[prog->bytelen++] = Save; + prog->insts[prog->bytelen++] = 1; + prog->len++; + + prog->insts[prog->bytelen++] = Match; + prog->len++; + + return 0; +} + +#if 0 +int main(int argc, char *argv[]) +{ + int pc = 0; + ByteProg *code = re1_5_compilecode(argv[1]); + re1_5_dumpcode(code); +} +#endif diff --git a/user/mpy/extmod/re1.5/dumpcode.c b/user/mpy/extmod/re1.5/dumpcode.c new file mode 100644 index 0000000..d7781d8 --- /dev/null +++ b/user/mpy/extmod/re1.5/dumpcode.c @@ -0,0 +1,65 @@ +// Copyright 2014 Paul Sokolovsky. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "re1.5.h" + +void re1_5_dumpcode(ByteProg *prog) +{ + int pc = 0; + char *code = prog->insts; + while (pc < prog->bytelen) { + printf("%2d: ", pc); + switch(code[pc++]) { + default: + assert(0); +// re1_5_fatal("printprog"); + case Split: + printf("split %d (%d)\n", pc + (signed char)code[pc] + 1, (signed char)code[pc]); + pc++; + break; + case RSplit: + printf("rsplit %d (%d)\n", pc + (signed char)code[pc] + 1, (signed char)code[pc]); + pc++; + break; + case Jmp: + printf("jmp %d (%d)\n", pc + (signed char)code[pc] + 1, (signed char)code[pc]); + pc++; + break; + case Char: + printf("char %c\n", code[pc++]); + break; + case Any: + printf("any\n"); + break; + case Class: + case ClassNot: { + int num = code[pc]; + printf("class%s %d", (code[pc - 1] == ClassNot ? "not" : ""), num); + pc++; + while (num--) { + printf(" 0x%02x-0x%02x", code[pc], code[pc + 1]); + pc += 2; + } + printf("\n"); + break; + } + case NamedClass: + printf("namedclass %c\n", code[pc++]); + break; + case Match: + printf("match\n"); + break; + case Save: + printf("save %d\n", (unsigned char)code[pc++]); + break; + case Bol: + printf("assert bol\n"); + break; + case Eol: + printf("assert eol\n"); + break; + } + } + printf("Bytes: %d, insts: %d\n", prog->bytelen, prog->len); +} diff --git a/user/mpy/extmod/re1.5/re1.5.h b/user/mpy/extmod/re1.5/re1.5.h new file mode 100644 index 0000000..815c5d3 --- /dev/null +++ b/user/mpy/extmod/re1.5/re1.5.h @@ -0,0 +1,151 @@ +// Copyright 2007-2009 Russ Cox. All Rights Reserved. +// Copyright 2014 Paul Sokolovsky. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#ifndef _RE1_5_REGEXP__H +#define _RE1_5_REGEXP__H + +#include +#include +#include +#include +#include + +#define nil ((void*)0) +#define nelem(x) (sizeof(x)/sizeof((x)[0])) + +typedef struct Regexp Regexp; +typedef struct Prog Prog; +typedef struct ByteProg ByteProg; +typedef struct Inst Inst; +typedef struct Subject Subject; + +struct Regexp +{ + int type; + int n; + int ch; + Regexp *left; + Regexp *right; +}; + +enum /* Regexp.type */ +{ + Alt = 1, + Cat, + Lit, + Dot, + Paren, + Quest, + Star, + Plus, +}; + +Regexp *parse(char*); +Regexp *reg(int type, Regexp *left, Regexp *right); +void printre(Regexp*); +#ifndef re1_5_fatal +void re1_5_fatal(char*); +#endif +void *mal(int); + +struct Prog +{ + Inst *start; + int len; +}; + +struct ByteProg +{ + int bytelen; + int len; + int sub; + char insts[0]; +}; + +struct Inst +{ + int opcode; + int c; + int n; + Inst *x; + Inst *y; + int gen; // global state, oooh! +}; + +enum /* Inst.opcode */ +{ + // Instructions which consume input bytes (and thus fail if none left) + CONSUMERS = 1, + Char = CONSUMERS, + Any, + Class, + ClassNot, + NamedClass, + + ASSERTS = 0x50, + Bol = ASSERTS, + Eol, + + // Instructions which take relative offset as arg + JUMPS = 0x60, + Jmp = JUMPS, + Split, + RSplit, + + // Other (special) instructions + Save = 0x7e, + Match = 0x7f, +}; + +#define inst_is_consumer(inst) ((inst) < ASSERTS) +#define inst_is_jump(inst) ((inst) & 0x70 == JUMPS) + +Prog *compile(Regexp*); +void printprog(Prog*); + +extern int gen; + +enum { + MAXSUB = 20 +}; + +typedef struct Sub Sub; + +struct Sub +{ + int ref; + int nsub; + const char *sub[MAXSUB]; +}; + +Sub *newsub(int n); +Sub *incref(Sub*); +Sub *copy(Sub*); +Sub *update(Sub*, int, const char*); +void decref(Sub*); + +struct Subject { + const char *begin; + const char *end; +}; + + +#define NON_ANCHORED_PREFIX 5 +#define HANDLE_ANCHORED(bytecode, is_anchored) ((is_anchored) ? (bytecode) + NON_ANCHORED_PREFIX : (bytecode)) + +int re1_5_backtrack(ByteProg*, Subject*, const char**, int, int); +int re1_5_pikevm(ByteProg*, Subject*, const char**, int, int); +int re1_5_recursiveloopprog(ByteProg*, Subject*, const char**, int, int); +int re1_5_recursiveprog(ByteProg*, Subject*, const char**, int, int); +int re1_5_thompsonvm(ByteProg*, Subject*, const char**, int, int); + +int re1_5_sizecode(const char *re); +int re1_5_compilecode(ByteProg *prog, const char *re); +void re1_5_dumpcode(ByteProg *prog); +void cleanmarks(ByteProg *prog); +int _re1_5_classmatch(const char *pc, const char *sp); +int _re1_5_namedclassmatch(const char *pc, const char *sp); + +#endif /*_RE1_5_REGEXP__H*/ diff --git a/user/mpy/extmod/re1.5/recursiveloop.c b/user/mpy/extmod/re1.5/recursiveloop.c new file mode 100644 index 0000000..e8fef03 --- /dev/null +++ b/user/mpy/extmod/re1.5/recursiveloop.c @@ -0,0 +1,84 @@ +// Copyright 2007-2009 Russ Cox. All Rights Reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "re1.5.h" + +static int +recursiveloop(char *pc, const char *sp, Subject *input, const char **subp, int nsubp) +{ + const char *old; + int off; + + for(;;) { + if(inst_is_consumer(*pc)) { + // If we need to match a character, but there's none left, it's fail + if(sp >= input->end) + return 0; + } + switch(*pc++) { + case Char: + if(*sp != *pc++) + return 0; + case Any: + sp++; + continue; + case Class: + case ClassNot: + if (!_re1_5_classmatch(pc, sp)) + return 0; + pc += *(unsigned char*)pc * 2 + 1; + sp++; + continue; + case NamedClass: + if (!_re1_5_namedclassmatch(pc, sp)) + return 0; + pc++; + sp++; + continue; + case Match: + return 1; + case Jmp: + off = (signed char)*pc++; + pc = pc + off; + continue; + case Split: + off = (signed char)*pc++; + if(recursiveloop(pc, sp, input, subp, nsubp)) + return 1; + pc = pc + off; + continue; + case RSplit: + off = (signed char)*pc++; + if(recursiveloop(pc + off, sp, input, subp, nsubp)) + return 1; + continue; + case Save: + off = (unsigned char)*pc++; + if(off >= nsubp) { + continue; + } + old = subp[off]; + subp[off] = sp; + if(recursiveloop(pc, sp, input, subp, nsubp)) + return 1; + subp[off] = old; + return 0; + case Bol: + if(sp != input->begin) + return 0; + continue; + case Eol: + if(sp != input->end) + return 0; + continue; + } + re1_5_fatal("recursiveloop"); + } +} + +int +re1_5_recursiveloopprog(ByteProg *prog, Subject *input, const char **subp, int nsubp, int is_anchored) +{ + return recursiveloop(HANDLE_ANCHORED(prog->insts, is_anchored), input->begin, input, subp, nsubp); +} diff --git a/user/mpy/extmod/uos_dupterm.c b/user/mpy/extmod/uos_dupterm.c new file mode 100644 index 0000000..29a62ab --- /dev/null +++ b/user/mpy/extmod/uos_dupterm.c @@ -0,0 +1,92 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include "py/mpconfig.h" + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/objtuple.h" +#include "py/objarray.h" +#include "py/stream.h" + +#if MICROPY_PY_OS_DUPTERM + +void mp_uos_deactivate(const char *msg, mp_obj_t exc) { + mp_obj_t term = MP_STATE_PORT(term_obj); + MP_STATE_PORT(term_obj) = NULL; + mp_printf(&mp_plat_print, msg); + if (exc != MP_OBJ_NULL) { + mp_obj_print_exception(&mp_plat_print, exc); + } + mp_stream_close(term); +} + +void mp_uos_dupterm_tx_strn(const char *str, size_t len) { + if (MP_STATE_PORT(term_obj) != MP_OBJ_NULL) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t write_m[3]; + mp_load_method(MP_STATE_PORT(term_obj), MP_QSTR_write, write_m); + + mp_obj_array_t *arr = MP_OBJ_TO_PTR(MP_STATE_PORT(dupterm_arr_obj)); + void *org_items = arr->items; + arr->items = (void*)str; + arr->len = len; + write_m[2] = MP_STATE_PORT(dupterm_arr_obj); + mp_call_method_n_kw(1, 0, write_m); + arr = MP_OBJ_TO_PTR(MP_STATE_PORT(dupterm_arr_obj)); + arr->items = org_items; + arr->len = 1; + nlr_pop(); + } else { + mp_uos_deactivate("dupterm: Exception in write() method, deactivating: ", nlr.ret_val); + } + } +} + +STATIC mp_obj_t mp_uos_dupterm(mp_uint_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + if (MP_STATE_PORT(term_obj) == MP_OBJ_NULL) { + return mp_const_none; + } else { + return MP_STATE_PORT(term_obj); + } + } else { + if (args[0] == mp_const_none) { + MP_STATE_PORT(term_obj) = MP_OBJ_NULL; + } else { + MP_STATE_PORT(term_obj) = args[0]; + if (MP_STATE_PORT(dupterm_arr_obj) == MP_OBJ_NULL) { + MP_STATE_PORT(dupterm_arr_obj) = mp_obj_new_bytearray(1, ""); + } + } + return mp_const_none; + } +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj, 0, 1, mp_uos_dupterm); + +#endif diff --git a/user/mpy/extmod/utime_mphal.c b/user/mpy/extmod/utime_mphal.c new file mode 100644 index 0000000..0fe3a3b --- /dev/null +++ b/user/mpy/extmod/utime_mphal.c @@ -0,0 +1,102 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 Damien P. George + * Copyright (c) 2016 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_PY_UTIME_MP_HAL + +#include + +#include "py/obj.h" +#include "py/mphal.h" +#include "py/smallint.h" +#include "py/runtime.h" +#include "extmod/utime_mphal.h" + +STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { + #if MICROPY_PY_BUILTINS_FLOAT + mp_hal_delay_ms((mp_uint_t)(1000 * mp_obj_get_float(seconds_o))); + #else + mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o)); + #endif + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep); + +STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) { + mp_int_t ms = mp_obj_get_int(arg); + if (ms > 0) { + mp_hal_delay_ms(ms); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms); + +STATIC mp_obj_t time_sleep_us(mp_obj_t arg) { + mp_int_t us = mp_obj_get_int(arg); + if (us > 0) { + mp_hal_delay_us(us); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj, time_sleep_us); + +STATIC mp_obj_t time_ticks_ms(void) { + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj, time_ticks_ms); + +STATIC mp_obj_t time_ticks_us(void) { + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj, time_ticks_us); + +STATIC mp_obj_t time_ticks_cpu(void) { + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj, time_ticks_cpu); + +STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) { + // we assume that the arguments come from ticks_xx so are small ints + mp_uint_t start = MP_OBJ_SMALL_INT_VALUE(start_in); + mp_uint_t end = MP_OBJ_SMALL_INT_VALUE(end_in); + // Optimized formula avoiding if conditions. We adjust difference "forward", + // wrap it around and adjust back. + mp_int_t diff = ((end - start + MICROPY_PY_UTIME_TICKS_PERIOD / 2) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)) + - MICROPY_PY_UTIME_TICKS_PERIOD / 2; + return MP_OBJ_NEW_SMALL_INT(diff); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_diff_obj, time_ticks_diff); + +STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) { + // we assume that first argument come from ticks_xx so is small int + mp_uint_t ticks = MP_OBJ_SMALL_INT_VALUE(ticks_in); + mp_uint_t delta = mp_obj_get_int(delta_in); + return MP_OBJ_NEW_SMALL_INT((ticks + delta) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj, time_ticks_add); + +#endif // MICROPY_PY_UTIME_MP_HAL diff --git a/user/mpy/extmod/utime_mphal.h b/user/mpy/extmod/utime_mphal.h new file mode 100644 index 0000000..88a9ed4 --- /dev/null +++ b/user/mpy/extmod/utime_mphal.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 Damien P. George + * Copyright (c) 2016 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. + */ +#ifndef MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H +#define MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H + +#include "py/obj.h" + +MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_utime_ticks_diff_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj); + +#endif // MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H diff --git a/user/mpy/extmod/uzlib/adler32.c b/user/mpy/extmod/uzlib/adler32.c new file mode 100644 index 0000000..1f17594 --- /dev/null +++ b/user/mpy/extmod/uzlib/adler32.c @@ -0,0 +1,78 @@ +/* + * Adler-32 checksum + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +/* + * Adler-32 algorithm taken from the zlib source, which is + * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + */ + +#include "tinf.h" + +#define A32_BASE 65521 +#define A32_NMAX 5552 + +uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum /* 1 */) +{ + const unsigned char *buf = (const unsigned char *)data; + + unsigned int s1 = prev_sum & 0xffff; + unsigned int s2 = prev_sum >> 16; + + while (length > 0) + { + int k = length < A32_NMAX ? length : A32_NMAX; + int i; + + for (i = k / 16; i; --i, buf += 16) + { + s1 += buf[0]; s2 += s1; s1 += buf[1]; s2 += s1; + s1 += buf[2]; s2 += s1; s1 += buf[3]; s2 += s1; + s1 += buf[4]; s2 += s1; s1 += buf[5]; s2 += s1; + s1 += buf[6]; s2 += s1; s1 += buf[7]; s2 += s1; + + s1 += buf[8]; s2 += s1; s1 += buf[9]; s2 += s1; + s1 += buf[10]; s2 += s1; s1 += buf[11]; s2 += s1; + s1 += buf[12]; s2 += s1; s1 += buf[13]; s2 += s1; + s1 += buf[14]; s2 += s1; s1 += buf[15]; s2 += s1; + } + + for (i = k % 16; i; --i) { s1 += *buf++; s2 += s1; } + + s1 %= A32_BASE; + s2 %= A32_BASE; + + length -= k; + } + + return (s2 << 16) | s1; +} diff --git a/user/mpy/extmod/uzlib/crc32.c b/user/mpy/extmod/uzlib/crc32.c new file mode 100644 index 0000000..e24c643 --- /dev/null +++ b/user/mpy/extmod/uzlib/crc32.c @@ -0,0 +1,63 @@ +/* + * CRC32 checksum + * + * Copyright (c) 1998-2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +/* + * CRC32 algorithm taken from the zlib source, which is + * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + */ + +#include "tinf.h" + +static const unsigned int tinf_crc32tab[16] = { + 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, + 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, + 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, + 0xbdbdf21c +}; + +/* crc is previous value for incremental computation, 0xffffffff initially */ +uint32_t uzlib_crc32(const void *data, unsigned int length, uint32_t crc) +{ + const unsigned char *buf = (const unsigned char *)data; + unsigned int i; + + for (i = 0; i < length; ++i) + { + crc ^= buf[i]; + crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); + crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); + } + + // return value suitable for passing in next time, for final value invert it + return crc/* ^ 0xffffffff*/; +} diff --git a/user/mpy/extmod/uzlib/tinf.h b/user/mpy/extmod/uzlib/tinf.h new file mode 100644 index 0000000..106203a --- /dev/null +++ b/user/mpy/extmod/uzlib/tinf.h @@ -0,0 +1,117 @@ +/* + * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2016 by Paul Sokolovsky + */ + +#ifndef TINF_H_INCLUDED +#define TINF_H_INCLUDED + +#include + +/* calling convention */ +#ifndef TINFCC + #ifdef __WATCOMC__ + #define TINFCC __cdecl + #else + #define TINFCC + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ok status, more data produced */ +#define TINF_OK 0 +/* end of compressed stream reached */ +#define TINF_DONE 1 +#define TINF_DATA_ERROR (-3) +#define TINF_CHKSUM_ERROR (-4) +#define TINF_DICT_ERROR (-5) + +/* checksum types */ +#define TINF_CHKSUM_NONE 0 +#define TINF_CHKSUM_ADLER 1 +#define TINF_CHKSUM_CRC 2 + +/* data structures */ + +typedef struct { + unsigned short table[16]; /* table of code length counts */ + unsigned short trans[288]; /* code -> symbol translation table */ +} TINF_TREE; + +struct TINF_DATA; +typedef struct TINF_DATA { + const unsigned char *source; + /* If source above is NULL, this function will be used to read + next byte from source stream */ + unsigned char (*readSource)(struct TINF_DATA *data); + + unsigned int tag; + unsigned int bitcount; + + /* Buffer start */ + unsigned char *destStart; + /* Buffer total size */ + unsigned int destSize; + /* Current pointer in buffer */ + unsigned char *dest; + /* Remaining bytes in buffer */ + unsigned int destRemaining; + + /* Accumulating checksum */ + unsigned int checksum; + char checksum_type; + + int btype; + int bfinal; + unsigned int curlen; + int lzOff; + unsigned char *dict_ring; + unsigned int dict_size; + unsigned int dict_idx; + + TINF_TREE ltree; /* dynamic length/symbol tree */ + TINF_TREE dtree; /* dynamic distance tree */ +} TINF_DATA; + +#define TINF_PUT(d, c) \ + { \ + *d->dest++ = c; \ + if (d->dict_ring) { d->dict_ring[d->dict_idx++] = c; if (d->dict_idx == d->dict_size) d->dict_idx = 0; } \ + } + +unsigned char TINFCC uzlib_get_byte(TINF_DATA *d); + +/* Decompression API */ + +void TINFCC uzlib_init(void); +void TINFCC uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen); +int TINFCC uzlib_uncompress(TINF_DATA *d); +int TINFCC uzlib_uncompress_chksum(TINF_DATA *d); + +int TINFCC uzlib_zlib_parse_header(TINF_DATA *d); +int TINFCC uzlib_gzip_parse_header(TINF_DATA *d); + +/* Compression API */ + +void TINFCC uzlib_compress(void *data, const uint8_t *src, unsigned slen); + +/* Checksum API */ + +/* prev_sum is previous value for incremental computation, 1 initially */ +uint32_t TINFCC uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum); +/* crc is previous value for incremental computation, 0xffffffff initially */ +uint32_t TINFCC uzlib_crc32(const void *data, unsigned int length, uint32_t crc); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TINF_H_INCLUDED */ diff --git a/user/mpy/extmod/uzlib/tinfgzip.c b/user/mpy/extmod/uzlib/tinfgzip.c new file mode 100644 index 0000000..f1afdd0 --- /dev/null +++ b/user/mpy/extmod/uzlib/tinfgzip.c @@ -0,0 +1,110 @@ +/* + * tinfgzip - tiny gzip decompressor + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2016 by Paul Sokolovsky + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +#include "tinf.h" + +#define FTEXT 1 +#define FHCRC 2 +#define FEXTRA 4 +#define FNAME 8 +#define FCOMMENT 16 + +void tinf_skip_bytes(TINF_DATA *d, int num); +uint16_t tinf_get_uint16(TINF_DATA *d); + +void tinf_skip_bytes(TINF_DATA *d, int num) +{ + while (num--) uzlib_get_byte(d); +} + +uint16_t tinf_get_uint16(TINF_DATA *d) +{ + unsigned int v = uzlib_get_byte(d); + v = (uzlib_get_byte(d) << 8) | v; + return v; +} + +int uzlib_gzip_parse_header(TINF_DATA *d) +{ + unsigned char flg; + + /* -- check format -- */ + + /* check id bytes */ + if (uzlib_get_byte(d) != 0x1f || uzlib_get_byte(d) != 0x8b) return TINF_DATA_ERROR; + + /* check method is deflate */ + if (uzlib_get_byte(d) != 8) return TINF_DATA_ERROR; + + /* get flag byte */ + flg = uzlib_get_byte(d); + + /* check that reserved bits are zero */ + if (flg & 0xe0) return TINF_DATA_ERROR; + + /* -- find start of compressed data -- */ + + /* skip rest of base header of 10 bytes */ + tinf_skip_bytes(d, 6); + + /* skip extra data if present */ + if (flg & FEXTRA) + { + unsigned int xlen = tinf_get_uint16(d); + tinf_skip_bytes(d, xlen); + } + + /* skip file name if present */ + if (flg & FNAME) { while (uzlib_get_byte(d)); } + + /* skip file comment if present */ + if (flg & FCOMMENT) { while (uzlib_get_byte(d)); } + + /* check header crc if present */ + if (flg & FHCRC) + { + /*unsigned int hcrc =*/ tinf_get_uint16(d); + + // TODO: Check! +// if (hcrc != (tinf_crc32(src, start - src) & 0x0000ffff)) +// return TINF_DATA_ERROR; + } + + /* initialize for crc32 checksum */ + d->checksum_type = TINF_CHKSUM_CRC; + d->checksum = ~0; + + return TINF_OK; +} diff --git a/user/mpy/extmod/uzlib/tinflate.c b/user/mpy/extmod/uzlib/tinflate.c new file mode 100644 index 0000000..58850eb --- /dev/null +++ b/user/mpy/extmod/uzlib/tinflate.c @@ -0,0 +1,551 @@ +/* + * tinflate - tiny inflate + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2016 by Paul Sokolovsky + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +#include +#include "tinf.h" + +uint32_t tinf_get_le_uint32(TINF_DATA *d); +uint32_t tinf_get_be_uint32(TINF_DATA *d); + +/* --------------------------------------------------- * + * -- uninitialized global data (static structures) -- * + * --------------------------------------------------- */ + +#ifdef RUNTIME_BITS_TABLES + +/* extra bits and base tables for length codes */ +unsigned char length_bits[30]; +unsigned short length_base[30]; + +/* extra bits and base tables for distance codes */ +unsigned char dist_bits[30]; +unsigned short dist_base[30]; + +#else + +const unsigned char length_bits[30] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, + 5, 5, 5, 5 +}; +const unsigned short length_base[30] = { + 3, 4, 5, 6, 7, 8, 9, 10, + 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, + 131, 163, 195, 227, 258 +}; + +const unsigned char dist_bits[30] = { + 0, 0, 0, 0, 1, 1, 2, 2, + 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, + 11, 11, 12, 12, 13, 13 +}; +const unsigned short dist_base[30] = { + 1, 2, 3, 4, 5, 7, 9, 13, + 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, + 4097, 6145, 8193, 12289, 16385, 24577 +}; + +#endif + +/* special ordering of code length codes */ +const unsigned char clcidx[] = { + 16, 17, 18, 0, 8, 7, 9, 6, + 10, 5, 11, 4, 12, 3, 13, 2, + 14, 1, 15 +}; + +/* ----------------------- * + * -- utility functions -- * + * ----------------------- */ + +#ifdef RUNTIME_BITS_TABLES +/* build extra bits and base tables */ +static void tinf_build_bits_base(unsigned char *bits, unsigned short *base, int delta, int first) +{ + int i, sum; + + /* build bits table */ + for (i = 0; i < delta; ++i) bits[i] = 0; + for (i = 0; i < 30 - delta; ++i) bits[i + delta] = i / delta; + + /* build base table */ + for (sum = first, i = 0; i < 30; ++i) + { + base[i] = sum; + sum += 1 << bits[i]; + } +} +#endif + +/* build the fixed huffman trees */ +static void tinf_build_fixed_trees(TINF_TREE *lt, TINF_TREE *dt) +{ + int i; + + /* build fixed length tree */ + for (i = 0; i < 7; ++i) lt->table[i] = 0; + + lt->table[7] = 24; + lt->table[8] = 152; + lt->table[9] = 112; + + for (i = 0; i < 24; ++i) lt->trans[i] = 256 + i; + for (i = 0; i < 144; ++i) lt->trans[24 + i] = i; + for (i = 0; i < 8; ++i) lt->trans[24 + 144 + i] = 280 + i; + for (i = 0; i < 112; ++i) lt->trans[24 + 144 + 8 + i] = 144 + i; + + /* build fixed distance tree */ + for (i = 0; i < 5; ++i) dt->table[i] = 0; + + dt->table[5] = 32; + + for (i = 0; i < 32; ++i) dt->trans[i] = i; +} + +/* given an array of code lengths, build a tree */ +static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, unsigned int num) +{ + unsigned short offs[16]; + unsigned int i, sum; + + /* clear code length count table */ + for (i = 0; i < 16; ++i) t->table[i] = 0; + + /* scan symbol lengths, and sum code length counts */ + for (i = 0; i < num; ++i) t->table[lengths[i]]++; + + t->table[0] = 0; + + /* compute offset table for distribution sort */ + for (sum = 0, i = 0; i < 16; ++i) + { + offs[i] = sum; + sum += t->table[i]; + } + + /* create code->symbol translation table (symbols sorted by code) */ + for (i = 0; i < num; ++i) + { + if (lengths[i]) t->trans[offs[lengths[i]]++] = i; + } +} + +/* ---------------------- * + * -- decode functions -- * + * ---------------------- */ + +unsigned char uzlib_get_byte(TINF_DATA *d) +{ + if (d->source) { + return *d->source++; + } + return d->readSource(d); +} + +uint32_t tinf_get_le_uint32(TINF_DATA *d) +{ + uint32_t val = 0; + int i; + for (i = 4; i--;) { + val = val >> 8 | uzlib_get_byte(d) << 24; + } + return val; +} + +uint32_t tinf_get_be_uint32(TINF_DATA *d) +{ + uint32_t val = 0; + int i; + for (i = 4; i--;) { + val = val << 8 | uzlib_get_byte(d); + } + return val; +} + +/* get one bit from source stream */ +static int tinf_getbit(TINF_DATA *d) +{ + unsigned int bit; + + /* check if tag is empty */ + if (!d->bitcount--) + { + /* load next tag */ + d->tag = uzlib_get_byte(d); + d->bitcount = 7; + } + + /* shift bit out of tag */ + bit = d->tag & 0x01; + d->tag >>= 1; + + return bit; +} + +/* read a num bit value from a stream and add base */ +static unsigned int tinf_read_bits(TINF_DATA *d, int num, int base) +{ + unsigned int val = 0; + + /* read num bits */ + if (num) + { + unsigned int limit = 1 << (num); + unsigned int mask; + + for (mask = 1; mask < limit; mask *= 2) + if (tinf_getbit(d)) val += mask; + } + + return val + base; +} + +/* given a data stream and a tree, decode a symbol */ +static int tinf_decode_symbol(TINF_DATA *d, TINF_TREE *t) +{ + int sum = 0, cur = 0, len = 0; + + /* get more bits while code value is above sum */ + do { + + cur = 2*cur + tinf_getbit(d); + + ++len; + + sum += t->table[len]; + cur -= t->table[len]; + + } while (cur >= 0); + + return t->trans[sum + cur]; +} + +/* given a data stream, decode dynamic trees from it */ +static void tinf_decode_trees(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) +{ + unsigned char lengths[288+32]; + unsigned int hlit, hdist, hclen; + unsigned int i, num, length; + + /* get 5 bits HLIT (257-286) */ + hlit = tinf_read_bits(d, 5, 257); + + /* get 5 bits HDIST (1-32) */ + hdist = tinf_read_bits(d, 5, 1); + + /* get 4 bits HCLEN (4-19) */ + hclen = tinf_read_bits(d, 4, 4); + + for (i = 0; i < 19; ++i) lengths[i] = 0; + + /* read code lengths for code length alphabet */ + for (i = 0; i < hclen; ++i) + { + /* get 3 bits code length (0-7) */ + unsigned int clen = tinf_read_bits(d, 3, 0); + + lengths[clcidx[i]] = clen; + } + + /* build code length tree, temporarily use length tree */ + tinf_build_tree(lt, lengths, 19); + + /* decode code lengths for the dynamic trees */ + for (num = 0; num < hlit + hdist; ) + { + int sym = tinf_decode_symbol(d, lt); + + switch (sym) + { + case 16: + /* copy previous code length 3-6 times (read 2 bits) */ + { + unsigned char prev = lengths[num - 1]; + for (length = tinf_read_bits(d, 2, 3); length; --length) + { + lengths[num++] = prev; + } + } + break; + case 17: + /* repeat code length 0 for 3-10 times (read 3 bits) */ + for (length = tinf_read_bits(d, 3, 3); length; --length) + { + lengths[num++] = 0; + } + break; + case 18: + /* repeat code length 0 for 11-138 times (read 7 bits) */ + for (length = tinf_read_bits(d, 7, 11); length; --length) + { + lengths[num++] = 0; + } + break; + default: + /* values 0-15 represent the actual code lengths */ + lengths[num++] = sym; + break; + } + } + + /* build dynamic trees */ + tinf_build_tree(lt, lengths, hlit); + tinf_build_tree(dt, lengths + hlit, hdist); +} + +/* ----------------------------- * + * -- block inflate functions -- * + * ----------------------------- */ + +/* given a stream and two trees, inflate a block of data */ +static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) +{ + if (d->curlen == 0) { + unsigned int offs; + int dist; + int sym = tinf_decode_symbol(d, lt); + //printf("huff sym: %02x\n", sym); + + /* literal byte */ + if (sym < 256) { + TINF_PUT(d, sym); + return TINF_OK; + } + + /* end of block */ + if (sym == 256) { + return TINF_DONE; + } + + /* substring from sliding dictionary */ + sym -= 257; + /* possibly get more bits from length code */ + d->curlen = tinf_read_bits(d, length_bits[sym], length_base[sym]); + + dist = tinf_decode_symbol(d, dt); + /* possibly get more bits from distance code */ + offs = tinf_read_bits(d, dist_bits[dist], dist_base[dist]); + if (d->dict_ring) { + if (offs > d->dict_size) { + return TINF_DICT_ERROR; + } + d->lzOff = d->dict_idx - offs; + if (d->lzOff < 0) { + d->lzOff += d->dict_size; + } + } else { + d->lzOff = -offs; + } + } + + /* copy next byte from dict substring */ + if (d->dict_ring) { + TINF_PUT(d, d->dict_ring[d->lzOff]); + if ((unsigned)++d->lzOff == d->dict_size) { + d->lzOff = 0; + } + } else { + d->dest[0] = d->dest[d->lzOff]; + d->dest++; + } + d->curlen--; + return TINF_OK; +} + +/* inflate an uncompressed block of data */ +static int tinf_inflate_uncompressed_block(TINF_DATA *d) +{ + if (d->curlen == 0) { + unsigned int length, invlength; + + /* get length */ + length = uzlib_get_byte(d) + 256 * uzlib_get_byte(d); + /* get one's complement of length */ + invlength = uzlib_get_byte(d) + 256 * uzlib_get_byte(d); + /* check length */ + if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR; + + /* increment length to properly return TINF_DONE below, without + producing data at the same time */ + d->curlen = length + 1; + + /* make sure we start next block on a byte boundary */ + d->bitcount = 0; + } + + if (--d->curlen == 0) { + return TINF_DONE; + } + + unsigned char c = uzlib_get_byte(d); + TINF_PUT(d, c); + return TINF_OK; +} + +/* ---------------------- * + * -- public functions -- * + * ---------------------- */ + +/* initialize global (static) data */ +void uzlib_init(void) +{ +#ifdef RUNTIME_BITS_TABLES + /* build extra bits and base tables */ + tinf_build_bits_base(length_bits, length_base, 4, 3); + tinf_build_bits_base(dist_bits, dist_base, 2, 1); + + /* fix a special case */ + length_bits[28] = 0; + length_base[28] = 258; +#endif +} + +/* initialize decompression structure */ +void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen) +{ + d->bitcount = 0; + d->bfinal = 0; + d->btype = -1; + d->dict_size = dictLen; + d->dict_ring = dict; + d->dict_idx = 0; + d->curlen = 0; +} + +/* inflate next byte of compressed stream */ +int uzlib_uncompress(TINF_DATA *d) +{ + do { + int res; + + /* start a new block */ + if (d->btype == -1) { +next_blk: + /* read final block flag */ + d->bfinal = tinf_getbit(d); + /* read block type (2 bits) */ + d->btype = tinf_read_bits(d, 2, 0); + + //printf("Started new block: type=%d final=%d\n", d->btype, d->bfinal); + + if (d->btype == 1) { + /* build fixed huffman trees */ + tinf_build_fixed_trees(&d->ltree, &d->dtree); + } else if (d->btype == 2) { + /* decode trees from stream */ + tinf_decode_trees(d, &d->ltree, &d->dtree); + } + } + + /* process current block */ + switch (d->btype) + { + case 0: + /* decompress uncompressed block */ + res = tinf_inflate_uncompressed_block(d); + break; + case 1: + case 2: + /* decompress block with fixed/dyanamic huffman trees */ + /* trees were decoded previously, so it's the same routine for both */ + res = tinf_inflate_block_data(d, &d->ltree, &d->dtree); + break; + default: + return TINF_DATA_ERROR; + } + + if (res == TINF_DONE && !d->bfinal) { + /* the block has ended (without producing more data), but we + can't return without data, so start procesing next block */ + goto next_blk; + } + + if (res != TINF_OK) { + return res; + } + + } while (--d->destSize); + + return TINF_OK; +} + +int uzlib_uncompress_chksum(TINF_DATA *d) +{ + int res; + unsigned char *data = d->dest; + + res = uzlib_uncompress(d); + + if (res < 0) return res; + + switch (d->checksum_type) { + + case TINF_CHKSUM_ADLER: + d->checksum = uzlib_adler32(data, d->dest - data, d->checksum); + break; + + case TINF_CHKSUM_CRC: + d->checksum = uzlib_crc32(data, d->dest - data, d->checksum); + break; + } + + if (res == TINF_DONE) { + unsigned int val; + + switch (d->checksum_type) { + + case TINF_CHKSUM_ADLER: + val = tinf_get_be_uint32(d); + if (d->checksum != val) { + return TINF_CHKSUM_ERROR; + } + break; + + case TINF_CHKSUM_CRC: + val = tinf_get_le_uint32(d); + if (~d->checksum != val) { + return TINF_CHKSUM_ERROR; + } + // Uncompressed size. TODO: Check + val = tinf_get_le_uint32(d); + break; + } + } + + return res; +} diff --git a/user/mpy/extmod/uzlib/tinfzlib.c b/user/mpy/extmod/uzlib/tinfzlib.c new file mode 100644 index 0000000..74fade3 --- /dev/null +++ b/user/mpy/extmod/uzlib/tinfzlib.c @@ -0,0 +1,66 @@ +/* + * tinfzlib - tiny zlib decompressor + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2016 by Paul Sokolovsky + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +#include "tinf.h" + +int uzlib_zlib_parse_header(TINF_DATA *d) +{ + unsigned char cmf, flg; + + /* -- get header bytes -- */ + + cmf = uzlib_get_byte(d); + flg = uzlib_get_byte(d); + + /* -- check format -- */ + + /* check checksum */ + if ((256*cmf + flg) % 31) return TINF_DATA_ERROR; + + /* check method is deflate */ + if ((cmf & 0x0f) != 8) return TINF_DATA_ERROR; + + /* check window size is valid */ + if ((cmf >> 4) > 7) return TINF_DATA_ERROR; + + /* check there is no preset dictionary */ + if (flg & 0x20) return TINF_DATA_ERROR; + + /* initialize for adler32 checksum */ + d->checksum_type = TINF_CHKSUM_ADLER; + d->checksum = 1; + + return cmf >> 4; +} diff --git a/user/mpy/extmod/vfs.c b/user/mpy/extmod/vfs.c new file mode 100644 index 0000000..3bdce80 --- /dev/null +++ b/user/mpy/extmod/vfs.c @@ -0,0 +1,457 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/objstr.h" +#include "py/mperrno.h" +#include "extmod/vfs.h" + +#if MICROPY_VFS + +#if MICROPY_VFS_FAT +#include "extmod/vfs_fat.h" +#endif + +// path is the path to lookup and *path_out holds the path within the VFS +// object (starts with / if an absolute path). +// Returns MP_VFS_ROOT for root dir (and then path_out is undefined) and +// MP_VFS_NONE for path not found. +mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out) { + if (*path == '/' || MP_STATE_VM(vfs_cur) == MP_VFS_ROOT) { + // an absolute path, or the current volume is root, so search root dir + bool is_abs = 0; + if (*path == '/') { + ++path; + is_abs = 1; + } + if (*path == '\0') { + // path is "" or "/" so return virtual root + return MP_VFS_ROOT; + } + for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { + size_t len = vfs->len - 1; + if (len == 0) { + *path_out = path - is_abs; + return vfs; + } + if (strncmp(path, vfs->str + 1, len) == 0) { + if (path[len] == '/') { + *path_out = path + len; + return vfs; + } else if (path[len] == '\0') { + *path_out = "/"; + return vfs; + } + } + } + + // if we get here then there's nothing mounted on / + + if (is_abs) { + // path began with / and was not found + return MP_VFS_NONE; + } + } + + // a relative path within a mounted device + *path_out = path; + return MP_STATE_VM(vfs_cur); +} + +// Version of mp_vfs_lookup_path that takes and returns uPy string objects. +STATIC mp_vfs_mount_t *lookup_path(mp_obj_t path_in, mp_obj_t *path_out) { + const char *path = mp_obj_str_get_str(path_in); + const char *p_out; + mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &p_out); + if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) { + *path_out = mp_obj_new_str_of_type(mp_obj_get_type(path_in), + (const byte*)p_out, strlen(p_out)); + } + return vfs; +} + +STATIC mp_obj_t mp_vfs_proxy_call(mp_vfs_mount_t *vfs, qstr meth_name, size_t n_args, const mp_obj_t *args) { + if (vfs == MP_VFS_NONE) { + // mount point not found + mp_raise_OSError(MP_ENODEV); + } + if (vfs == MP_VFS_ROOT) { + // can't do operation on root dir + mp_raise_OSError(MP_EPERM); + } + mp_obj_t meth[n_args + 2]; + mp_load_method(vfs->obj, meth_name, meth); + if (args != NULL) { + memcpy(meth + 2, args, n_args * sizeof(*args)); + } + return mp_call_method_n_kw(n_args, 0, meth); +} + +mp_import_stat_t mp_vfs_import_stat(const char *path) { + const char *path_out; + mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &path_out); + if (vfs == MP_VFS_NONE || vfs == MP_VFS_ROOT) { + return MP_IMPORT_STAT_NO_EXIST; + } + #if MICROPY_VFS_FAT + // fast paths for known VFS types + if (mp_obj_get_type(vfs->obj) == &mp_fat_vfs_type) { + return fat_vfs_import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out); + } + #endif + // TODO delegate to vfs.stat() method + return MP_IMPORT_STAT_NO_EXIST; +} + +mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_readonly, ARG_mkfs }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_false} }, + { MP_QSTR_mkfs, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_false} }, + }; + + // parse args + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + // get the mount point + size_t mnt_len; + const char *mnt_str = mp_obj_str_get_data(pos_args[1], &mnt_len); + + // see if we need to auto-detect and create the filesystem + mp_obj_t vfs_obj = pos_args[0]; + mp_obj_t dest[2]; + mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest); + if (dest[0] == MP_OBJ_NULL) { + // Input object has no mount method, assume it's a block device and try to + // auto-detect the filesystem and create the corresponding VFS entity. + // (At the moment we only support FAT filesystems.) + #if MICROPY_VFS_FAT + vfs_obj = mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &vfs_obj); + #endif + } + + // create new object + mp_vfs_mount_t *vfs = m_new_obj(mp_vfs_mount_t); + vfs->str = mnt_str; + vfs->len = mnt_len; + vfs->obj = vfs_obj; + vfs->next = NULL; + + // call the underlying object to do any mounting operation + mp_vfs_proxy_call(vfs, MP_QSTR_mount, 2, (mp_obj_t*)&args); + + // check that the destination mount point is unused + const char *path_out; + mp_vfs_mount_t *existing_mount = mp_vfs_lookup_path(mp_obj_str_get_str(pos_args[1]), &path_out); + if (existing_mount != MP_VFS_NONE && existing_mount != MP_VFS_ROOT) { + if (vfs->len != 1 && existing_mount->len == 1) { + // if root dir is mounted, still allow to mount something within a subdir of root + } else { + // mount point in use + mp_raise_OSError(MP_EPERM); + } + } + + // insert the vfs into the mount table + mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); + while (*vfsp != NULL) { + if ((*vfsp)->len == 1) { + // make sure anything mounted at the root stays at the end of the list + vfs->next = *vfsp; + break; + } + vfsp = &(*vfsp)->next; + } + *vfsp = vfs; + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_mount_obj, 2, mp_vfs_mount); + +mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) { + // remove vfs from the mount table + mp_vfs_mount_t *vfs = NULL; + size_t mnt_len; + const char *mnt_str = NULL; + if (MP_OBJ_IS_STR(mnt_in)) { + mnt_str = mp_obj_str_get_data(mnt_in, &mnt_len); + } + for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) { + if ((mnt_str != NULL && !memcmp(mnt_str, (*vfsp)->str, mnt_len + 1)) || (*vfsp)->obj == mnt_in) { + vfs = *vfsp; + *vfsp = (*vfsp)->next; + break; + } + } + + if (vfs == NULL) { + mp_raise_OSError(MP_EINVAL); + } + + // if we unmounted the current device then set current to root + if (MP_STATE_VM(vfs_cur) == vfs) { + MP_STATE_VM(vfs_cur) = MP_VFS_ROOT; + } + + // call the underlying object to do any unmounting operation + mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_umount_obj, mp_vfs_umount); + +// Note: buffering and encoding args are currently ignored +mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_file, ARG_mode, ARG_encoding }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + { MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} }, + { MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} }, + { MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + }; + + // parse args + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_vfs_mount_t *vfs = lookup_path((mp_obj_t)args[ARG_file].u_rom_obj, &args[ARG_file].u_obj); + return mp_vfs_proxy_call(vfs, MP_QSTR_open, 2, (mp_obj_t*)&args); +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_open_obj, 0, mp_vfs_open); + +mp_obj_t mp_vfs_chdir(mp_obj_t path_in) { + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + MP_STATE_VM(vfs_cur) = vfs; + if (vfs == MP_VFS_ROOT) { + // If we change to the root dir and a VFS is mounted at the root then + // we must change that VFS's current dir to the root dir so that any + // subsequent relative paths begin at the root of that VFS. + for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { + if (vfs->len == 1) { + mp_obj_t root = mp_obj_new_str("/", 1, false); + mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &root); + break; + } + } + } else { + mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &path_out); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj, mp_vfs_chdir); + +mp_obj_t mp_vfs_getcwd(void) { + if (MP_STATE_VM(vfs_cur) == MP_VFS_ROOT) { + return MP_OBJ_NEW_QSTR(MP_QSTR__slash_); + } + mp_obj_t cwd_o = mp_vfs_proxy_call(MP_STATE_VM(vfs_cur), MP_QSTR_getcwd, 0, NULL); + if (MP_STATE_VM(vfs_cur)->len == 1) { + // don't prepend "/" for vfs mounted at root + return cwd_o; + } + const char *cwd = mp_obj_str_get_str(cwd_o); + vstr_t vstr; + vstr_init(&vstr, MP_STATE_VM(vfs_cur)->len + strlen(cwd) + 1); + vstr_add_strn(&vstr, MP_STATE_VM(vfs_cur)->str, MP_STATE_VM(vfs_cur)->len); + if (!(cwd[0] == '/' && cwd[1] == 0)) { + vstr_add_str(&vstr, cwd); + } + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd); + +typedef struct _mp_vfs_ilistdir_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + union { + mp_vfs_mount_t *vfs; + mp_obj_t iter; + } cur; + bool is_str; + bool is_iter; +} mp_vfs_ilistdir_it_t; + +STATIC mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) { + mp_vfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); + if (self->is_iter) { + // continue delegating to root dir + return mp_iternext(self->cur.iter); + } else if (self->cur.vfs == NULL) { + // finished iterating mount points and no root dir is mounted + return MP_OBJ_STOP_ITERATION; + } else { + // continue iterating mount points + mp_vfs_mount_t *vfs = self->cur.vfs; + self->cur.vfs = vfs->next; + if (vfs->len == 1) { + // vfs is mounted at root dir, delegate to it + mp_obj_t root = mp_obj_new_str("/", 1, false); + self->is_iter = true; + self->cur.iter = mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &root); + return mp_iternext(self->cur.iter); + } else { + // a mounted directory + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); + t->items[0] = mp_obj_new_str_of_type( + self->is_str ? &mp_type_str : &mp_type_bytes, + (const byte*)vfs->str + 1, vfs->len - 1); + t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); + t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number + return MP_OBJ_FROM_PTR(t); + } + } +} + +mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args) { + mp_obj_t path_in; + if (n_args == 1) { + path_in = args[0]; + } else { + path_in = MP_OBJ_NEW_QSTR(MP_QSTR_); + } + + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + + if (vfs == MP_VFS_ROOT) { + // list the root directory + mp_vfs_ilistdir_it_t *iter = m_new_obj(mp_vfs_ilistdir_it_t); + iter->base.type = &mp_type_polymorph_iter; + iter->iternext = mp_vfs_ilistdir_it_iternext; + iter->cur.vfs = MP_STATE_VM(vfs_mount_table); + iter->is_str = mp_obj_get_type(path_in) == &mp_type_str; + iter->is_iter = false; + return MP_OBJ_FROM_PTR(iter); + } + + return mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &path_out); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj, 0, 1, mp_vfs_ilistdir); + +mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { + mp_obj_t iter = mp_vfs_ilistdir(n_args, args); + mp_obj_t dir_list = mp_obj_new_list(0, NULL); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + mp_obj_t *items; + mp_obj_get_array_fixed_n(next, 3, &items); + mp_obj_list_append(dir_list, items[0]); + } + return dir_list; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj, 0, 1, mp_vfs_listdir); + +mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) { + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + if (vfs == MP_VFS_ROOT || (vfs != MP_VFS_NONE && !strcmp(mp_obj_str_get_str(path_out), "/"))) { + mp_raise_OSError(MP_EEXIST); + } + return mp_vfs_proxy_call(vfs, MP_QSTR_mkdir, 1, &path_out); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj, mp_vfs_mkdir); + +mp_obj_t mp_vfs_remove(mp_obj_t path_in) { + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + return mp_vfs_proxy_call(vfs, MP_QSTR_remove, 1, &path_out); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_remove_obj, mp_vfs_remove); + +mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { + mp_obj_t args[2]; + mp_vfs_mount_t *old_vfs = lookup_path(old_path_in, &args[0]); + mp_vfs_mount_t *new_vfs = lookup_path(new_path_in, &args[1]); + if (old_vfs != new_vfs) { + // can't rename across filesystems + mp_raise_OSError(MP_EPERM); + } + return mp_vfs_proxy_call(old_vfs, MP_QSTR_rename, 2, args); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_vfs_rename_obj, mp_vfs_rename); + +mp_obj_t mp_vfs_rmdir(mp_obj_t path_in) { + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + return mp_vfs_proxy_call(vfs, MP_QSTR_rmdir, 1, &path_out); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj, mp_vfs_rmdir); + +mp_obj_t mp_vfs_stat(mp_obj_t path_in) { + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + if (vfs == MP_VFS_ROOT) { + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); + t->items[0] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); // st_mode + for (int i = 1; i <= 9; ++i) { + t->items[i] = MP_OBJ_NEW_SMALL_INT(0); // dev, nlink, uid, gid, size, atime, mtime, ctime + } + return MP_OBJ_FROM_PTR(t); + } + return mp_vfs_proxy_call(vfs, MP_QSTR_stat, 1, &path_out); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_stat_obj, mp_vfs_stat); + +mp_obj_t mp_vfs_statvfs(mp_obj_t path_in) { + mp_obj_t path_out; + mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); + if (vfs == MP_VFS_ROOT) { + // statvfs called on the root directory, see if there's anything mounted there + for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { + if (vfs->len == 1) { + break; + } + } + + // If there's nothing mounted at root then return a mostly-empty tuple + if (vfs == NULL) { + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); + + // fill in: bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flags + for (int i = 0; i <= 8; ++i) { + t->items[i] = MP_OBJ_NEW_SMALL_INT(0); + } + + // Put something sensible in f_namemax + t->items[9] = MP_OBJ_NEW_SMALL_INT(MICROPY_ALLOC_PATH_MAX); + + return MP_OBJ_FROM_PTR(t); + } + + // VFS mounted at root so delegate the call to it + path_out = MP_OBJ_NEW_QSTR(MP_QSTR__slash_); + } + return mp_vfs_proxy_call(vfs, MP_QSTR_statvfs, 1, &path_out); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj, mp_vfs_statvfs); + +#endif // MICROPY_VFS diff --git a/user/mpy/extmod/vfs.h b/user/mpy/extmod/vfs.h new file mode 100644 index 0000000..f2efdbe --- /dev/null +++ b/user/mpy/extmod/vfs.h @@ -0,0 +1,85 @@ +/* + * 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_EXTMOD_VFS_H +#define MICROPY_INCLUDED_EXTMOD_VFS_H + +#include "py/lexer.h" +#include "py/obj.h" + +// return values of mp_vfs_lookup_path +// ROOT is 0 so that the default current directory is the root directory +#define MP_VFS_NONE ((mp_vfs_mount_t*)1) +#define MP_VFS_ROOT ((mp_vfs_mount_t*)0) + +// MicroPython's port-standardized versions of stat constants +#define MP_S_IFDIR (0x4000) +#define MP_S_IFREG (0x8000) + +// constants for block protocol ioctl +#define BP_IOCTL_INIT (1) +#define BP_IOCTL_DEINIT (2) +#define BP_IOCTL_SYNC (3) +#define BP_IOCTL_SEC_COUNT (4) +#define BP_IOCTL_SEC_SIZE (5) + +typedef struct _mp_vfs_mount_t { + const char *str; // mount point with leading / + size_t len; + mp_obj_t obj; + struct _mp_vfs_mount_t *next; +} mp_vfs_mount_t; + +mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); +mp_import_stat_t mp_vfs_import_stat(const char *path); +mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +mp_obj_t mp_vfs_umount(mp_obj_t mnt_in); +mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +mp_obj_t mp_vfs_chdir(mp_obj_t path_in); +mp_obj_t mp_vfs_getcwd(void); +mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_vfs_mkdir(mp_obj_t path_in); +mp_obj_t mp_vfs_remove(mp_obj_t path_in); +mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in); +mp_obj_t mp_vfs_rmdir(mp_obj_t path_in); +mp_obj_t mp_vfs_stat(mp_obj_t path_in); +mp_obj_t mp_vfs_statvfs(mp_obj_t path_in); + +MP_DECLARE_CONST_FUN_OBJ_KW(mp_vfs_mount_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_umount_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_vfs_open_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_remove_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_vfs_rename_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_stat_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj); + +#endif // MICROPY_INCLUDED_EXTMOD_VFS_H diff --git a/user/mpy/extmod/vfs_fat.c b/user/mpy/extmod/vfs_fat.c new file mode 100644 index 0000000..0ec3fe6 --- /dev/null +++ b/user/mpy/extmod/vfs_fat.c @@ -0,0 +1,345 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Damien P. George + * Copyright (c) 2016 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_VFS_FAT + +#if !MICROPY_VFS +#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS" +#endif + +#include +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/mperrno.h" +#include "lib/oofatfs/ff.h" +#include "extmod/vfs_fat.h" +#include "lib/timeutils/timeutils.h" + +#if _MAX_SS == _MIN_SS +#define SECSIZE(fs) (_MIN_SS) +#else +#define SECSIZE(fs) ((fs)->ssize) +#endif + +#define mp_obj_fat_vfs_t fs_user_mount_t + +STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); + + // create new object + fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t); + vfs->base.type = type; + vfs->flags = FSUSER_FREE_OBJ; + vfs->fatfs.drv = vfs; + + // load block protocol methods + mp_load_method(args[0], MP_QSTR_readblocks, vfs->readblocks); + mp_load_method_maybe(args[0], MP_QSTR_writeblocks, vfs->writeblocks); + mp_load_method_maybe(args[0], MP_QSTR_ioctl, vfs->u.ioctl); + if (vfs->u.ioctl[0] != MP_OBJ_NULL) { + // device supports new block protocol, so indicate it + vfs->flags |= FSUSER_HAVE_IOCTL; + } else { + // no ioctl method, so assume the device uses the old block protocol + mp_load_method_maybe(args[0], MP_QSTR_sync, vfs->u.old.sync); + mp_load_method(args[0], MP_QSTR_count, vfs->u.old.count); + } + + return MP_OBJ_FROM_PTR(vfs); +} + +STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) { + // create new object + fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, 0, &bdev_in)); + + // make the filesystem + uint8_t working_buf[_MAX_SS]; + FRESULT res = f_mkfs(&vfs->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_mkfs_fun_obj, fat_vfs_mkfs); +STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(fat_vfs_mkfs_obj, MP_ROM_PTR(&fat_vfs_mkfs_fun_obj)); + +STATIC MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_open_obj, fatfs_builtin_open_self); + +STATIC mp_obj_t fat_vfs_ilistdir_func(size_t n_args, const mp_obj_t *args) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(args[0]); + bool is_str_type = true; + const char *path; + if (n_args == 2) { + if (mp_obj_get_type(args[1]) == &mp_type_bytes) { + is_str_type = false; + } + path = mp_obj_str_get_str(args[1]); + } else { + path = ""; + } + + return fat_vfs_ilistdir2(self, path, is_str_type); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fat_vfs_ilistdir_obj, 1, 2, fat_vfs_ilistdir_func); + +STATIC mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp_int_t attr) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + const char *path = mp_obj_str_get_str(path_in); + + FILINFO fno; + FRESULT res = f_stat(&self->fatfs, path, &fno); + + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + + // check if path is a file or directory + if ((fno.fattrib & AM_DIR) == attr) { + res = f_unlink(&self->fatfs, path); + + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + return mp_const_none; + } else { + mp_raise_OSError(attr ? MP_ENOTDIR : MP_EISDIR); + } +} + +STATIC mp_obj_t fat_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) { + return fat_vfs_remove_internal(vfs_in, path_in, 0); // 0 == file attribute +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_remove_obj, fat_vfs_remove); + +STATIC mp_obj_t fat_vfs_rmdir(mp_obj_t vfs_in, mp_obj_t path_in) { + return fat_vfs_remove_internal(vfs_in, path_in, AM_DIR); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_rmdir_obj, fat_vfs_rmdir); + +STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + const char *old_path = mp_obj_str_get_str(path_in); + const char *new_path = mp_obj_str_get_str(path_out); + FRESULT res = f_rename(&self->fatfs, old_path, new_path); + if (res == FR_EXIST) { + // if new_path exists then try removing it (but only if it's a file) + fat_vfs_remove_internal(vfs_in, path_out, 0); // 0 == file attribute + // try to rename again + res = f_rename(&self->fatfs, old_path, new_path); + } + if (res == FR_OK) { + return mp_const_none; + } else { + mp_raise_OSError(fresult_to_errno_table[res]); + } + +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_rename_obj, fat_vfs_rename); + +STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + const char *path = mp_obj_str_get_str(path_o); + FRESULT res = f_mkdir(&self->fatfs, path); + if (res == FR_OK) { + return mp_const_none; + } else { + mp_raise_OSError(fresult_to_errno_table[res]); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_mkdir_obj, fat_vfs_mkdir); + +/// Change current directory. +STATIC mp_obj_t fat_vfs_chdir(mp_obj_t vfs_in, mp_obj_t path_in) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + const char *path; + path = mp_obj_str_get_str(path_in); + + FRESULT res = f_chdir(&self->fatfs, path); + + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_chdir_obj, fat_vfs_chdir); + +/// Get the current directory. +STATIC mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + char buf[MICROPY_ALLOC_PATH_MAX + 1]; + FRESULT res = f_getcwd(&self->fatfs, buf, sizeof(buf)); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + return mp_obj_new_str(buf, strlen(buf), false); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getcwd_obj, fat_vfs_getcwd); + +/// \function stat(path) +/// Get the status of a file or directory. +STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + const char *path = mp_obj_str_get_str(path_in); + + FILINFO fno; + if (path[0] == 0 || (path[0] == '/' && path[1] == 0)) { + // stat root directory + fno.fsize = 0; + fno.fdate = 0x2821; // Jan 1, 2000 + fno.ftime = 0; + fno.fattrib = AM_DIR; + } else { + FRESULT res = f_stat(&self->fatfs, path, &fno); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + } + + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); + mp_int_t mode = 0; + if (fno.fattrib & AM_DIR) { + mode |= MP_S_IFDIR; + } else { + mode |= MP_S_IFREG; + } + mp_int_t seconds = timeutils_seconds_since_2000( + 1980 + ((fno.fdate >> 9) & 0x7f), + (fno.fdate >> 5) & 0x0f, + fno.fdate & 0x1f, + (fno.ftime >> 11) & 0x1f, + (fno.ftime >> 5) & 0x3f, + 2 * (fno.ftime & 0x1f) + ); + t->items[0] = MP_OBJ_NEW_SMALL_INT(mode); // st_mode + t->items[1] = MP_OBJ_NEW_SMALL_INT(0); // st_ino + t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // st_dev + t->items[3] = MP_OBJ_NEW_SMALL_INT(0); // st_nlink + t->items[4] = MP_OBJ_NEW_SMALL_INT(0); // st_uid + t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // st_gid + t->items[6] = MP_OBJ_NEW_SMALL_INT(fno.fsize); // st_size + t->items[7] = MP_OBJ_NEW_SMALL_INT(seconds); // st_atime + t->items[8] = MP_OBJ_NEW_SMALL_INT(seconds); // st_mtime + t->items[9] = MP_OBJ_NEW_SMALL_INT(seconds); // st_ctime + + return MP_OBJ_FROM_PTR(t); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_stat_obj, fat_vfs_stat); + +// Get the status of a VFS. +STATIC mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) { + mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); + (void)path_in; + + DWORD nclst; + FATFS *fatfs = &self->fatfs; + FRESULT res = f_getfree(fatfs, &nclst); + if (FR_OK != res) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); + + t->items[0] = MP_OBJ_NEW_SMALL_INT(fatfs->csize * SECSIZE(fatfs)); // f_bsize + t->items[1] = t->items[0]; // f_frsize + t->items[2] = MP_OBJ_NEW_SMALL_INT((fatfs->n_fatent - 2)); // f_blocks + t->items[3] = MP_OBJ_NEW_SMALL_INT(nclst); // f_bfree + t->items[4] = t->items[3]; // f_bavail + t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // f_files + t->items[6] = MP_OBJ_NEW_SMALL_INT(0); // f_ffree + t->items[7] = MP_OBJ_NEW_SMALL_INT(0); // f_favail + t->items[8] = MP_OBJ_NEW_SMALL_INT(0); // f_flags + t->items[9] = MP_OBJ_NEW_SMALL_INT(_MAX_LFN); // f_namemax + + return MP_OBJ_FROM_PTR(t); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_statvfs_obj, fat_vfs_statvfs); + +STATIC mp_obj_t vfs_fat_mount(mp_obj_t self_in, mp_obj_t readonly, mp_obj_t mkfs) { + fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); + + // Read-only device indicated by writeblocks[0] == MP_OBJ_NULL. + // User can specify read-only device by: + // 1. readonly=True keyword argument + // 2. nonexistent writeblocks method (then writeblocks[0] == MP_OBJ_NULL already) + if (mp_obj_is_true(readonly)) { + self->writeblocks[0] = MP_OBJ_NULL; + } + + // mount the block device + FRESULT res = f_mount(&self->fatfs); + + // check if we need to make the filesystem + if (res == FR_NO_FILESYSTEM && mp_obj_is_true(mkfs)) { + uint8_t working_buf[_MAX_SS]; + res = f_mkfs(&self->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); + } + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(vfs_fat_mount_obj, vfs_fat_mount); + +STATIC mp_obj_t vfs_fat_umount(mp_obj_t self_in) { + fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); + FRESULT res = f_umount(&self->fatfs); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_umount_obj, vfs_fat_umount); + +STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_mkfs), MP_ROM_PTR(&fat_vfs_mkfs_obj) }, + { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&fat_vfs_open_obj) }, + { MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&fat_vfs_ilistdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&fat_vfs_mkdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&fat_vfs_rmdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&fat_vfs_chdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&fat_vfs_getcwd_obj) }, + { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&fat_vfs_remove_obj) }, + { MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&fat_vfs_rename_obj) }, + { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&fat_vfs_stat_obj) }, + { MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&fat_vfs_statvfs_obj) }, + { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&vfs_fat_mount_obj) }, + { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&fat_vfs_umount_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table); + +const mp_obj_type_t mp_fat_vfs_type = { + { &mp_type_type }, + .name = MP_QSTR_VfsFat, + .make_new = fat_vfs_make_new, + .locals_dict = (mp_obj_dict_t*)&fat_vfs_locals_dict, +}; + +#endif // MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_fat.h b/user/mpy/extmod/vfs_fat.h new file mode 100644 index 0000000..443e4ed --- /dev/null +++ b/user/mpy/extmod/vfs_fat.h @@ -0,0 +1,64 @@ +/* + * 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_EXTMOD_VFS_FAT_H +#define MICROPY_INCLUDED_EXTMOD_VFS_FAT_H + +#include "py/lexer.h" +#include "py/obj.h" +#include "lib/oofatfs/ff.h" +#include "extmod/vfs.h" + +// these are the values for fs_user_mount_t.flags +#define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func +#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount +#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl + +typedef struct _fs_user_mount_t { + mp_obj_base_t base; + uint16_t flags; + mp_obj_t readblocks[4]; + mp_obj_t writeblocks[4]; + // new protocol uses just ioctl, old uses sync (optional) and count + union { + mp_obj_t ioctl[4]; + struct { + mp_obj_t sync[2]; + mp_obj_t count[2]; + } old; + } u; + FATFS fatfs; +} fs_user_mount_t; + +extern const byte fresult_to_errno_table[20]; +extern const mp_obj_type_t mp_fat_vfs_type; + +mp_import_stat_t fat_vfs_import_stat(struct _fs_user_mount_t *vfs, const char *path); +mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj); + +mp_obj_t fat_vfs_ilistdir2(struct _fs_user_mount_t *vfs, const char *path, bool is_str_type); + +#endif // MICROPY_INCLUDED_EXTMOD_VFS_FAT_H diff --git a/user/mpy/extmod/vfs_fat_diskio.c b/user/mpy/extmod/vfs_fat_diskio.c new file mode 100644 index 0000000..ff23c6b --- /dev/null +++ b/user/mpy/extmod/vfs_fat_diskio.c @@ -0,0 +1,280 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * Original template for this file comes from: + * Low level disk I/O module skeleton for FatFs, (C)ChaN, 2013 + * + * 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_VFS && MICROPY_VFS_FAT + +#include +#include + +#include "py/mphal.h" + +#include "py/runtime.h" +#include "lib/oofatfs/ff.h" +#include "lib/oofatfs/diskio.h" +#include "extmod/vfs_fat.h" + +#if _MAX_SS == _MIN_SS +#define SECSIZE(fs) (_MIN_SS) +#else +#define SECSIZE(fs) ((fs)->ssize) +#endif + +typedef void *bdev_t; +STATIC fs_user_mount_t *disk_get_device(void *bdev) { + return (fs_user_mount_t*)bdev; +} + +/*-----------------------------------------------------------------------*/ +/* Initialize a Drive */ +/*-----------------------------------------------------------------------*/ + +STATIC +DSTATUS disk_initialize ( + bdev_t pdrv /* Physical drive nmuber (0..) */ +) +{ + fs_user_mount_t *vfs = disk_get_device(pdrv); + if (vfs == NULL) { + return STA_NOINIT; + } + + if (vfs->flags & FSUSER_HAVE_IOCTL) { + // new protocol with ioctl; call ioctl(INIT, 0) + vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_INIT); + vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused + mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); + if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) { + // error initialising + return STA_NOINIT; + } + } + + if (vfs->writeblocks[0] == MP_OBJ_NULL) { + return STA_PROTECT; + } else { + return 0; + } +} + +/*-----------------------------------------------------------------------*/ +/* Get Disk Status */ +/*-----------------------------------------------------------------------*/ + +STATIC +DSTATUS disk_status ( + bdev_t pdrv /* Physical drive nmuber (0..) */ +) +{ + fs_user_mount_t *vfs = disk_get_device(pdrv); + if (vfs == NULL) { + return STA_NOINIT; + } + + if (vfs->writeblocks[0] == MP_OBJ_NULL) { + return STA_PROTECT; + } else { + return 0; + } +} + +/*-----------------------------------------------------------------------*/ +/* Read Sector(s) */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_read ( + bdev_t pdrv, /* Physical drive nmuber (0..) */ + BYTE *buff, /* Data buffer to store read data */ + DWORD sector, /* Sector address (LBA) */ + UINT count /* Number of sectors to read (1..128) */ +) +{ + fs_user_mount_t *vfs = disk_get_device(pdrv); + if (vfs == NULL) { + return RES_PARERR; + } + + if (vfs->flags & FSUSER_NATIVE) { + mp_uint_t (*f)(uint8_t*, uint32_t, uint32_t) = (void*)(uintptr_t)vfs->readblocks[2]; + if (f(buff, sector, count) != 0) { + return RES_ERROR; + } + } else { + vfs->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); + vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), buff); + mp_call_method_n_kw(2, 0, vfs->readblocks); + // TODO handle error return + } + + return RES_OK; +} + +/*-----------------------------------------------------------------------*/ +/* Write Sector(s) */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_write ( + bdev_t pdrv, /* Physical drive nmuber (0..) */ + const BYTE *buff, /* Data to be written */ + DWORD sector, /* Sector address (LBA) */ + UINT count /* Number of sectors to write (1..128) */ +) +{ + fs_user_mount_t *vfs = disk_get_device(pdrv); + if (vfs == NULL) { + return RES_PARERR; + } + + if (vfs->writeblocks[0] == MP_OBJ_NULL) { + // read-only block device + return RES_WRPRT; + } + + if (vfs->flags & FSUSER_NATIVE) { + mp_uint_t (*f)(const uint8_t*, uint32_t, uint32_t) = (void*)(uintptr_t)vfs->writeblocks[2]; + if (f(buff, sector, count) != 0) { + return RES_ERROR; + } + } else { + vfs->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); + vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), (void*)buff); + mp_call_method_n_kw(2, 0, vfs->writeblocks); + // TODO handle error return + } + + return RES_OK; +} + + +/*-----------------------------------------------------------------------*/ +/* Miscellaneous Functions */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_ioctl ( + bdev_t pdrv, /* Physical drive nmuber (0..) */ + BYTE cmd, /* Control code */ + void *buff /* Buffer to send/receive control data */ +) +{ + fs_user_mount_t *vfs = disk_get_device(pdrv); + if (vfs == NULL) { + return RES_PARERR; + } + + if (vfs->flags & FSUSER_HAVE_IOCTL) { + // new protocol with ioctl + switch (cmd) { + case CTRL_SYNC: + vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SYNC); + vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused + mp_call_method_n_kw(2, 0, vfs->u.ioctl); + return RES_OK; + + case GET_SECTOR_COUNT: { + vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SEC_COUNT); + vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused + mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); + *((DWORD*)buff) = mp_obj_get_int(ret); + return RES_OK; + } + + case GET_SECTOR_SIZE: { + vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SEC_SIZE); + vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused + mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); + if (ret == mp_const_none) { + // Default sector size + *((WORD*)buff) = 512; + } else { + *((WORD*)buff) = mp_obj_get_int(ret); + } + #if _MAX_SS != _MIN_SS + // need to store ssize because we use it in disk_read/disk_write + vfs->fatfs.ssize = *((WORD*)buff); + #endif + return RES_OK; + } + + case GET_BLOCK_SIZE: + *((DWORD*)buff) = 1; // erase block size in units of sector size + return RES_OK; + + case IOCTL_INIT: + *((DSTATUS*)buff) = disk_initialize(pdrv); + return RES_OK; + + case IOCTL_STATUS: + *((DSTATUS*)buff) = disk_status(pdrv); + return RES_OK; + + default: + return RES_PARERR; + } + } else { + // old protocol with sync and count + switch (cmd) { + case CTRL_SYNC: + if (vfs->u.old.sync[0] != MP_OBJ_NULL) { + mp_call_method_n_kw(0, 0, vfs->u.old.sync); + } + return RES_OK; + + case GET_SECTOR_COUNT: { + mp_obj_t ret = mp_call_method_n_kw(0, 0, vfs->u.old.count); + *((DWORD*)buff) = mp_obj_get_int(ret); + return RES_OK; + } + + case GET_SECTOR_SIZE: + *((WORD*)buff) = 512; // old protocol had fixed sector size + #if _MAX_SS != _MIN_SS + // need to store ssize because we use it in disk_read/disk_write + vfs->fatfs.ssize = 512; + #endif + return RES_OK; + + case GET_BLOCK_SIZE: + *((DWORD*)buff) = 1; // erase block size in units of sector size + return RES_OK; + + case IOCTL_INIT: + *((DSTATUS*)buff) = disk_initialize(pdrv); + return RES_OK; + + case IOCTL_STATUS: + *((DSTATUS*)buff) = disk_status(pdrv); + return RES_OK; + + default: + return RES_PARERR; + } + } +} + +#endif // MICROPY_VFS && MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_fat_file.c b/user/mpy/extmod/vfs_fat_file.c new file mode 100644 index 0000000..8fb48f0 --- /dev/null +++ b/user/mpy/extmod/vfs_fat_file.c @@ -0,0 +1,300 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_VFS && MICROPY_VFS_FAT + +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/stream.h" +#include "py/mperrno.h" +#include "lib/oofatfs/ff.h" +#include "extmod/vfs_fat.h" + +#define mp_type_fileio fatfs_type_fileio +#define mp_type_textio fatfs_type_textio + +extern const mp_obj_type_t mp_type_fileio; +extern const mp_obj_type_t mp_type_textio; + +// this table converts from FRESULT to POSIX errno +const byte fresult_to_errno_table[20] = { + [FR_OK] = 0, + [FR_DISK_ERR] = MP_EIO, + [FR_INT_ERR] = MP_EIO, + [FR_NOT_READY] = MP_EBUSY, + [FR_NO_FILE] = MP_ENOENT, + [FR_NO_PATH] = MP_ENOENT, + [FR_INVALID_NAME] = MP_EINVAL, + [FR_DENIED] = MP_EACCES, + [FR_EXIST] = MP_EEXIST, + [FR_INVALID_OBJECT] = MP_EINVAL, + [FR_WRITE_PROTECTED] = MP_EROFS, + [FR_INVALID_DRIVE] = MP_ENODEV, + [FR_NOT_ENABLED] = MP_ENODEV, + [FR_NO_FILESYSTEM] = MP_ENODEV, + [FR_MKFS_ABORTED] = MP_EIO, + [FR_TIMEOUT] = MP_EIO, + [FR_LOCKED] = MP_EIO, + [FR_NOT_ENOUGH_CORE] = MP_ENOMEM, + [FR_TOO_MANY_OPEN_FILES] = MP_EMFILE, + [FR_INVALID_PARAMETER] = MP_EINVAL, +}; + +typedef struct _pyb_file_obj_t { + mp_obj_base_t base; + FIL fp; +} pyb_file_obj_t; + +STATIC void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_printf(print, "", mp_obj_get_type_str(self_in), MP_OBJ_TO_PTR(self_in)); +} + +STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); + UINT sz_out; + FRESULT res = f_read(&self->fp, buf, size, &sz_out); + if (res != FR_OK) { + *errcode = fresult_to_errno_table[res]; + return MP_STREAM_ERROR; + } + return sz_out; +} + +STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); + UINT sz_out; + FRESULT res = f_write(&self->fp, buf, size, &sz_out); + if (res != FR_OK) { + *errcode = fresult_to_errno_table[res]; + return MP_STREAM_ERROR; + } + if (sz_out != size) { + // The FatFS documentation says that this means disk full. + *errcode = MP_ENOSPC; + return MP_STREAM_ERROR; + } + return sz_out; +} + + +STATIC mp_obj_t file_obj_close(mp_obj_t self_in) { + pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); + // if fs==NULL then the file is closed and in that case this method is a no-op + if (self->fp.obj.fs != NULL) { + FRESULT res = f_close(&self->fp); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(file_obj_close_obj, file_obj_close); + +STATIC mp_obj_t file_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + return file_obj_close(args[0]); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(file_obj___exit___obj, 4, 4, file_obj___exit__); + +STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { + pyb_file_obj_t *self = MP_OBJ_TO_PTR(o_in); + + if (request == MP_STREAM_SEEK) { + struct mp_stream_seek_t *s = (struct mp_stream_seek_t*)(uintptr_t)arg; + + switch (s->whence) { + case 0: // SEEK_SET + f_lseek(&self->fp, s->offset); + break; + + case 1: // SEEK_CUR + if (s->offset != 0) { + *errcode = MP_EOPNOTSUPP; + return MP_STREAM_ERROR; + } + // no-operation + break; + + case 2: // SEEK_END + f_lseek(&self->fp, f_size(&self->fp) + s->offset); + break; + } + + s->offset = f_tell(&self->fp); + return 0; + + } else if (request == MP_STREAM_FLUSH) { + FRESULT res = f_sync(&self->fp); + if (res != FR_OK) { + *errcode = fresult_to_errno_table[res]; + return MP_STREAM_ERROR; + } + return 0; + + } else { + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } +} + +// Note: encoding is ignored for now; it's also not a valid kwarg for CPython's FileIO, +// but by adding it here we can use one single mp_arg_t array for open() and FileIO's constructor +STATIC const mp_arg_t file_open_args[] = { + { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + { MP_QSTR_mode, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_r)} }, + { MP_QSTR_encoding, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, +}; +#define FILE_OPEN_NUM_ARGS MP_ARRAY_SIZE(file_open_args) + +STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_arg_val_t *args) { + int mode = 0; + const char *mode_s = mp_obj_str_get_str(args[1].u_obj); + // TODO make sure only one of r, w, x, a, and b, t are specified + while (*mode_s) { + switch (*mode_s++) { + case 'r': + mode |= FA_READ; + break; + case 'w': + mode |= FA_WRITE | FA_CREATE_ALWAYS; + break; + case 'x': + mode |= FA_WRITE | FA_CREATE_NEW; + break; + case 'a': + mode |= FA_WRITE | FA_OPEN_ALWAYS; + break; + case '+': + mode |= FA_READ | FA_WRITE; + break; + #if MICROPY_PY_IO_FILEIO + case 'b': + type = &mp_type_fileio; + break; + #endif + case 't': + type = &mp_type_textio; + break; + } + } + + pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); + o->base.type = type; + + const char *fname = mp_obj_str_get_str(args[0].u_obj); + assert(vfs != NULL); + FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); + if (res != FR_OK) { + m_del_obj(pyb_file_obj_t, o); + mp_raise_OSError(fresult_to_errno_table[res]); + } + + // for 'a' mode, we must begin at the end of the file + if ((mode & FA_OPEN_ALWAYS) != 0) { + f_lseek(&o->fp, f_size(&o->fp)); + } + + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; + mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals); + return file_open(NULL, type, arg_vals); +} + +// TODO gc hook to close the file if not already closed + +STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_readlines), MP_ROM_PTR(&mp_stream_unbuffered_readlines_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&file_obj_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) }, + { MP_ROM_QSTR(MP_QSTR_tell), MP_ROM_PTR(&mp_stream_tell_obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&file_obj_close_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&file_obj___exit___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); + +#if MICROPY_PY_IO_FILEIO +STATIC const mp_stream_p_t fileio_stream_p = { + .read = file_obj_read, + .write = file_obj_write, + .ioctl = file_obj_ioctl, +}; + +const mp_obj_type_t mp_type_fileio = { + { &mp_type_type }, + .name = MP_QSTR_FileIO, + .print = file_obj_print, + .make_new = file_obj_make_new, + .getiter = mp_identity_getiter, + .iternext = mp_stream_unbuffered_iter, + .protocol = &fileio_stream_p, + .locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict, +}; +#endif + +STATIC const mp_stream_p_t textio_stream_p = { + .read = file_obj_read, + .write = file_obj_write, + .ioctl = file_obj_ioctl, + .is_text = true, +}; + +const mp_obj_type_t mp_type_textio = { + { &mp_type_type }, + .name = MP_QSTR_TextIOWrapper, + .print = file_obj_print, + .make_new = file_obj_make_new, + .getiter = mp_identity_getiter, + .iternext = mp_stream_unbuffered_iter, + .protocol = &textio_stream_p, + .locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict, +}; + +// Factory function for I/O stream classes +mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode) { + // TODO: analyze buffering args and instantiate appropriate type + fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); + mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; + arg_vals[0].u_obj = path; + arg_vals[1].u_obj = mode; + arg_vals[2].u_obj = mp_const_none; + return file_open(self, &mp_type_textio, arg_vals); +} + +#endif // MICROPY_VFS && MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_fat_misc.c b/user/mpy/extmod/vfs_fat_misc.c new file mode 100644 index 0000000..7c16db7 --- /dev/null +++ b/user/mpy/extmod/vfs_fat_misc.c @@ -0,0 +1,109 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_VFS_FAT + +#include +#include "py/nlr.h" +#include "py/runtime.h" +#include "lib/oofatfs/ff.h" +#include "extmod/vfs_fat.h" +#include "py/lexer.h" + +typedef struct _mp_vfs_fat_ilistdir_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + bool is_str; + FF_DIR dir; +} mp_vfs_fat_ilistdir_it_t; + +STATIC mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) { + mp_vfs_fat_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); + + for (;;) { + FILINFO fno; + FRESULT res = f_readdir(&self->dir, &fno); + char *fn = fno.fname; + if (res != FR_OK || fn[0] == 0) { + // stop on error or end of dir + break; + } + + // Note that FatFS already filters . and .., so we don't need to + + // make 3-tuple with info about this entry + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); + if (self->is_str) { + t->items[0] = mp_obj_new_str(fn, strlen(fn), false); + } else { + t->items[0] = mp_obj_new_bytes((const byte*)fn, strlen(fn)); + } + if (fno.fattrib & AM_DIR) { + // dir + t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); + } else { + // file + t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFREG); + } + t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number + + return MP_OBJ_FROM_PTR(t); + } + + // ignore error because we may be closing a second time + f_closedir(&self->dir); + + return MP_OBJ_STOP_ITERATION; +} + +mp_obj_t fat_vfs_ilistdir2(fs_user_mount_t *vfs, const char *path, bool is_str_type) { + mp_vfs_fat_ilistdir_it_t *iter = m_new_obj(mp_vfs_fat_ilistdir_it_t); + iter->base.type = &mp_type_polymorph_iter; + iter->iternext = mp_vfs_fat_ilistdir_it_iternext; + iter->is_str = is_str_type; + FRESULT res = f_opendir(&vfs->fatfs, &iter->dir, path); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } + return MP_OBJ_FROM_PTR(iter); +} + +mp_import_stat_t fat_vfs_import_stat(fs_user_mount_t *vfs, const char *path) { + FILINFO fno; + assert(vfs != NULL); + FRESULT res = f_stat(&vfs->fatfs, path, &fno); + if (res == FR_OK) { + if ((fno.fattrib & AM_DIR) != 0) { + return MP_IMPORT_STAT_DIR; + } else { + return MP_IMPORT_STAT_FILE; + } + } + return MP_IMPORT_STAT_NO_EXIST; +} + +#endif // MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_reader.c b/user/mpy/extmod/vfs_reader.c new file mode 100644 index 0000000..891098a --- /dev/null +++ b/user/mpy/extmod/vfs_reader.c @@ -0,0 +1,87 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-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. + */ + +#include +#include + +#include "py/runtime.h" +#include "py/stream.h" +#include "py/reader.h" +#include "extmod/vfs.h" + +#if MICROPY_READER_VFS + +typedef struct _mp_reader_vfs_t { + mp_obj_t file; + uint16_t len; + uint16_t pos; + byte buf[24]; +} mp_reader_vfs_t; + +STATIC mp_uint_t mp_reader_vfs_readbyte(void *data) { + mp_reader_vfs_t *reader = (mp_reader_vfs_t*)data; + if (reader->pos >= reader->len) { + if (reader->len < sizeof(reader->buf)) { + return MP_READER_EOF; + } else { + int errcode; + reader->len = mp_stream_rw(reader->file, reader->buf, sizeof(reader->buf), + &errcode, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); + if (errcode != 0) { + // TODO handle errors properly + return MP_READER_EOF; + } + if (reader->len == 0) { + return MP_READER_EOF; + } + reader->pos = 0; + } + } + return reader->buf[reader->pos++]; +} + +STATIC void mp_reader_vfs_close(void *data) { + mp_reader_vfs_t *reader = (mp_reader_vfs_t*)data; + mp_stream_close(reader->file); + m_del_obj(mp_reader_vfs_t, reader); +} + +void mp_reader_new_file(mp_reader_t *reader, const char *filename) { + mp_reader_vfs_t *rf = m_new_obj(mp_reader_vfs_t); + mp_obj_t arg = mp_obj_new_str(filename, strlen(filename), false); + rf->file = mp_vfs_open(1, &arg, (mp_map_t*)&mp_const_empty_map); + int errcode; + rf->len = mp_stream_rw(rf->file, rf->buf, sizeof(rf->buf), &errcode, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); + if (errcode != 0) { + mp_raise_OSError(errcode); + } + rf->pos = 0; + reader->data = rf; + reader->readbyte = mp_reader_vfs_readbyte; + reader->close = mp_reader_vfs_close; +} + +#endif // MICROPY_READER_VFS diff --git a/user/mpy/extmod/virtpin.c b/user/mpy/extmod/virtpin.c new file mode 100644 index 0000000..dbfa21d --- /dev/null +++ b/user/mpy/extmod/virtpin.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include "extmod/virtpin.h" + +int mp_virtual_pin_read(mp_obj_t pin) { + mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); + mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; + return pin_p->ioctl(pin, MP_PIN_READ, 0, NULL); +} + +void mp_virtual_pin_write(mp_obj_t pin, int value) { + mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); + mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; + pin_p->ioctl(pin, MP_PIN_WRITE, value, NULL); +} diff --git a/user/mpy/extmod/virtpin.h b/user/mpy/extmod/virtpin.h new file mode 100644 index 0000000..706affc --- /dev/null +++ b/user/mpy/extmod/virtpin.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ +#ifndef MICROPY_INCLUDED_EXTMOD_VIRTPIN_H +#define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H + +#include "py/obj.h" + +#define MP_PIN_READ (1) +#define MP_PIN_WRITE (2) +#define MP_PIN_INPUT (3) +#define MP_PIN_OUTPUT (4) + +// Pin protocol +typedef struct _mp_pin_p_t { + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); +} mp_pin_p_t; + +int mp_virtual_pin_read(mp_obj_t pin); +void mp_virtual_pin_write(mp_obj_t pin, int value); + +// If a port exposes a Pin object, it's constructor should be like this +mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); + +#endif // MICROPY_INCLUDED_EXTMOD_VIRTPIN_H diff --git a/user/mpy/forzentest.mpy b/user/mpy/forzentest.mpy new file mode 100644 index 0000000..f0ed8d2 --- /dev/null +++ b/user/mpy/forzentest.mpy @@ -0,0 +1,16 @@ +4d02 021f 5c03 0000 0000 000d 0a00 f700 +2a28 2828 2b28 0000 ff1b c700 16f8 0064 +0132 1bc7 0017 0064 0132 1bc7 0017 0164 +0132 1bc7 0017 0264 0132 1bc7 0014 baef +9a15 6401 3280 350f 8030 24f9 001b c700 +1bf9 0064 0132 81e9 3084 f036 eb7f 3211 +5b08 3c6d 6f64 756c 653e 0d66 726f 7a65 +6e74 6573 742e 7079 0570 7269 6e74 0375 +5079 0570 7269 6e74 0570 7269 6e74 0570 +7269 6e74 0570 7269 6e74 0169 0570 7269 +6e74 0169 0300 7322 6120 6c6f 6e67 2073 +7472 696e 6720 7468 6174 2069 7320 6e6f +7420 696e 7465 726e 6564 7326 6120 7374 +7269 6e67 2074 6861 7420 6861 7320 756e +6963 6f64 6520 ceb1 ceb2 ceb3 2063 6861 +7273 620b 6279 7465 7320 3132 3334 01 diff --git a/user/mpy/lib/README.md b/user/mpy/lib/README.md new file mode 100644 index 0000000..e719821 --- /dev/null +++ b/user/mpy/lib/README.md @@ -0,0 +1,2 @@ +This directory contains standard, low-level C libraries with emphasis on +being independent and efficient. They can be used by any port. diff --git a/user/mpy/lib/axtls/.gitignore b/user/mpy/lib/axtls/.gitignore new file mode 100644 index 0000000..f2e3408 --- /dev/null +++ b/user/mpy/lib/axtls/.gitignore @@ -0,0 +1,11 @@ +*.o +_stage +.depend +.config* +config/config.h +config/scripts/config/conf +config/scripts/config/lex.zconf.c +config/scripts/config/lkc_defs.h +config/scripts/config/zconf.tab.c +config/scripts/config/zconf.tab.h +ssl/version.h diff --git a/user/mpy/lib/axtls/Makefile b/user/mpy/lib/axtls/Makefile new file mode 100644 index 0000000..045e34f --- /dev/null +++ b/user/mpy/lib/axtls/Makefile @@ -0,0 +1,185 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +-include config/.config + +ifneq ($(strip $(HAVE_DOT_CONFIG)),y) +all: menuconfig +else +all: target +endif + +include config/makefile.conf + +target : $(STAGE) $(TARGET) + +# VERSION has to come from the command line +RELEASE=axTLS-$(VERSION) + +# standard version +target: + $(MAKE) -C crypto + $(MAKE) -C ssl +ifdef CONFIG_AXHTTPD + $(MAKE) -C httpd +endif +ifdef CONFIG_AXTLSWRAP + $(MAKE) -C axtlswrap +endif +ifdef CONFIG_BINDINGS + $(MAKE) -C bindings +endif +ifdef CONFIG_SAMPLES + $(MAKE) -C samples +endif + +$(STAGE) : ssl/version.h + @mkdir -p $(STAGE) + +# create a version file with something in it. +ssl/version.h: + @echo "#define AXTLS_VERSION \"(no version)\"" > ssl/version.h + +$(PREFIX) : + @mkdir -p $(PREFIX)/lib + @mkdir -p $(PREFIX)/bin + +release: + $(MAKE) -C config/scripts/config clean + -$(MAKE) clean + -@rm config/*.msi config/*.back.aip config/config.h config/.config* + -@rm www/index.20* + -@rm -fr $(STAGE) + @echo "#define AXTLS_VERSION \"$(VERSION)\"" > ssl/version.h + cd ../; tar cvfz $(RELEASE).tar.gz --wildcards-match-slash --exclude .svn axtls-code; cd -; + +docs: + $(MAKE) -C docsrc doco + +# build the Win32 demo release version +win32_demo: + @echo "#define AXTLS_VERSION \"$(VERSION)\"" > ssl/version.h + $(MAKE) win32releaseconf + +install: $(PREFIX) all + cp --no-dereference $(STAGE)/libax* $(PREFIX)/lib + chmod 755 $(PREFIX)/lib/libax* +ifdef CONFIG_SAMPLES + install -m 755 $(STAGE)/ax* $(PREFIX)/bin +endif +ifdef CONFIG_HTTP_HAS_AUTHORIZATION + install -m 755 $(STAGE)/htpasswd $(PREFIX)/bin +endif +ifdef CONFIG_PLATFORM_CYGWIN + install -m 755 $(STAGE)/cygaxtls.dll $(PREFIX)/bin +endif +ifdef CONFIG_PERL_BINDINGS + install -m 755 $(STAGE)/axtlsp.pm `perl -e 'use Config; print $$Config{installarchlib};'` +endif + @mkdir -p -m 755 $(PREFIX)/include/axTLS + install -m 644 crypto/*.h $(PREFIX)/include/axTLS + install -m 644 ssl/*.h $(PREFIX)/include/axTLS + -rm $(PREFIX)/include/axTLS/cert.h + -rm $(PREFIX)/include/axTLS/private_key.h + install -m 644 config/config.h $(PREFIX)/include/axTLS + +installclean: + -@rm $(PREFIX)/lib/libax* > /dev/null 2>&1 + -@rm $(PREFIX)/bin/ax* > /dev/null 2>&1 + -@rm $(PREFIX)/bin/axhttpd* > /dev/null 2>&1 + -@rm `perl -e 'use Config; print $$Config{installarchlib};'`/axtlsp.pm > /dev/null 2>&1 + +test: + cd $(STAGE); ssltest; ../ssl/test/test_axssl.sh; cd -; + +# tidy up things +clean:: + @cd crypto; $(MAKE) clean + @cd ssl; $(MAKE) clean + @cd httpd; $(MAKE) clean + @cd axtlswrap; $(MAKE) clean + @cd samples; $(MAKE) clean + @cd docsrc; $(MAKE) clean + @cd bindings; $(MAKE) clean + +# --------------------------------------------------------------------------- +# mconf stuff +# --------------------------------------------------------------------------- + +CONFIG_CONFIG_IN = config/Config.in +CONFIG_DEFCONFIG = config/defconfig + +config/scripts/config/conf: config/scripts/config/Makefile + $(MAKE) -C config/scripts/config conf + -@if [ ! -f config/.config ] ; then \ + cp $(CONFIG_DEFCONFIG) config/.config; \ + fi + +config/scripts/config/mconf: config/scripts/config/Makefile + $(MAKE) -C config/scripts/config ncurses conf mconf + -@if [ ! -f config/.config ] ; then \ + cp $(CONFIG_DEFCONFIG) .config; \ + fi + +cleanconf: + $(MAKE) -C config/scripts/config clean + @rm -f config/.config + +menuconfig: config/scripts/config/mconf + @./config/scripts/config/mconf $(CONFIG_CONFIG_IN) + +config: config/scripts/config/conf + @./config/scripts/config/conf $(CONFIG_CONFIG_IN) + +oldconfig: config/scripts/config/conf + @./config/scripts/config/conf -o $(CONFIG_CONFIG_IN) + +default: config/scripts/config/conf + @./config/scripts/config/conf -d $(CONFIG_CONFIG_IN) > /dev/null + $(MAKE) + +randconfig: config/scripts/config/conf + @./config/scripts/config/conf -r $(CONFIG_CONFIG_IN) + +allnoconfig: config/scripts/config/conf + @./config/scripts/config/conf -n $(CONFIG_CONFIG_IN) + +allyesconfig: config/scripts/config/conf + @./config/scripts/config/conf -y $(CONFIG_CONFIG_IN) + +# The special win32 release configuration +win32releaseconf: config/scripts/config/conf + @./config/scripts/config/conf -D config/win32config $(CONFIG_CONFIG_IN) > /dev/null + $(MAKE) + +# The special linux release configuration +linuxconf: config/scripts/config/conf + @./config/scripts/config/conf -D config/linuxconfig $(CONFIG_CONFIG_IN) > /dev/null + $(MAKE) diff --git a/user/mpy/lib/axtls/README b/user/mpy/lib/axtls/README new file mode 100644 index 0000000..c8926d9 --- /dev/null +++ b/user/mpy/lib/axtls/README @@ -0,0 +1,3 @@ + +See www/index.html for the README, CHANGELOG, LICENSE and other notes. + diff --git a/user/mpy/lib/axtls/axtlswrap/Makefile b/user/mpy/lib/axtls/axtlswrap/Makefile new file mode 100755 index 0000000..b14825a --- /dev/null +++ b/user/mpy/lib/axtls/axtlswrap/Makefile @@ -0,0 +1,68 @@ +# +# Copyright (c) 2009, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +all : sslwrap + +AXTLS_HOME=.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +ifdef CONFIG_PLATFORM_CYGWIN +TARGET=$(AXTLS_HOME)/$(STAGE)/axtlswrap.exe +else # linux +TARGET=$(AXTLS_HOME)/$(STAGE)/axtlswrap +endif + +ifdef CONFIG_HTTP_STATIC_BUILD +LIBS=$(AXTLS_HOME)/$(STAGE)/libaxtls.a +else +LIBS=-L$(AXTLS_HOME)/$(STAGE) -laxtls +endif + +ifndef CONFIG_AXTLSWRAP +sslwrap: +else +sslwrap : $(TARGET) + +OBJ= axtlswrap.o +include $(AXTLS_HOME)/config/makefile.post + +$(TARGET): $(OBJ) $(AXTLS_HOME)/$(STAGE)/libaxtls.a + $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) +ifdef CONFIG_STRIP_UNWANTED_SECTIONS + $(STRIP) --remove-section=.comment $(TARGET) +endif + +endif # CONFIG_AXTLSWRAP + +clean:: + -@rm -f $(TARGET)* + diff --git a/user/mpy/lib/axtls/axtlswrap/axtlswrap.c b/user/mpy/lib/axtls/axtlswrap/axtlswrap.c new file mode 100755 index 0000000..43b448e --- /dev/null +++ b/user/mpy/lib/axtls/axtlswrap/axtlswrap.c @@ -0,0 +1,379 @@ +/* + * Copyright (c) 2009, Steve Bennett + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * sslwrap re-implemented with axTLS - a way to wrap an existing webserver + * with axTLS. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +/* If nothing is received or sent in this many seconds, give up */ +static int opt_timeout = 60; + +static int opt_verbose = 0; + +int main(int argc, char *argv[]) +{ + int log_opts = LOG_PERROR; + int fd[2]; /* output from child */ + int df[2]; /* input to child */ + int pid; + unsigned char *readbuf; + int readlen; + + SSL_CTX *ssl_ctx; + SSL *ssl; + + /* This relies on stdin and stdout being one and the same */ + int sslfd = fileno(stdin); + + while (argc > 2 && argv[1][0] == '-') + { + if (argc > 3 && strcmp(argv[1], "-t") == 0) + { + opt_timeout = atoi(argv[2]); + argv += 2; + argc -= 2; + continue; + } + + if (strcmp(argv[1], "-q") == 0) + { + log_opts = 0; + argv++; + argc--; + continue; + } + + if (strcmp(argv[1], "-v") == 0) + { + opt_verbose++; + argv++; + argc--; + continue; + } + } + + if (argc < 2) + { + fprintf(stderr, "Usage: axtlswrap [-v] [-q] " + "[-t timeout] command ...\n"); + return 1; + } + + if (access(argv[1], X_OK) != 0) + { + fprintf(stderr, "Not an executabled: %s\n", argv[1]); + return 1; + } + + openlog("axtlswrap", LOG_PID | log_opts, LOG_DAEMON); + + /* Create an SSL context with the required options */ + ssl_ctx = ssl_ctx_new(opt_verbose > 1 ? + SSL_DISPLAY_STATES | SSL_DISPLAY_CERTS : 0, 1); + + if (ssl_ctx == NULL) + { + syslog(LOG_ERR, "Failed to create SSL ctx"); + return 1; + } + + /* And create an ssl session attached to sslfd */ + ssl = ssl_server_new(ssl_ctx, sslfd); + if (ssl == NULL) + { + syslog(LOG_ERR, "Failed to create SSL connection"); + return 1; + } + + /* Get past the handshaking */ + while ((readlen = ssl_read(ssl, &readbuf)) == SSL_OK) + { + /* Still handshaking */ + } + + if (readlen < 0) + { + syslog(LOG_ERR, "SSL handshake failed: %d", readlen); + return 1; + } + + if (opt_verbose) + { + syslog(LOG_INFO, "SSL handshake OK"); + } + + /* Looks OK, we have data, so fork the child and start */ + if (pipe(fd) < 0 || pipe(df) < 0) + { + syslog(LOG_ERR, "pipe failed: %m"); + return 1; + } + + /* Give some indication to the child that we are running SSL + * It would be possible to provide other details + * too. Perhaps as in: http://httpd.apache.org/docs/2.0/mod/mod_ssl.html + */ + setenv("SSL_PROTOCOL", "TLSv1", 1); + +#ifndef NOMMU + if (opt_verbose) + { + pid = fork(); + } + else +#endif + pid = vfork(); + if (pid < 0) + { + syslog(LOG_ERR, "vfork failed: %m"); + return 1; + } + + if (pid > 0) + { + /* This is the parent */ + unsigned char writebuf[4096]; + int writelen = 0; + struct pollfd pfd[3]; + int timeout_count = 0; + + int cwfd = df[1]; /* write to child */ + int crfd = fd[0]; /* read from child */ + + int child_alive = 1; + + /* Don't die on SIGPIPE */ + signal(SIGPIPE, SIG_IGN); + + close(df[0]); + close(fd[1]); + + pfd[0].fd = sslfd; + pfd[1].fd = cwfd; + pfd[2].fd = crfd; + + /* While the child is alive or there is something to return... */ + while (child_alive || writelen > 0) + { + /* Work out what to read and what to write */ + int ret; + + pfd[0].events = 0; + pfd[0].revents = 0; + + /* Only want to read ssl data if there is nothing else to do */ + if (readlen == 0) + { + /* can read ssl data */ + pfd[0].events |= POLLIN; + } + + if (writelen > 0) + { + /* can write ssl data - will block to do this */ + pfd[0].events |= POLLOUT; + } + + pfd[1].events = 0; + pfd[1].revents = 0; + + if (child_alive && readlen > 0) + { + pfd[1].events |= POLLOUT; + } + + pfd[2].events = 0; + pfd[2].revents = 0; + + if (child_alive && writelen == 0) + { + pfd[2].events |= POLLIN; + } + + /* Timeout after 1 second so we can increment timeout_count */ + ret = poll(pfd, 3, 1000); + + if (ret < 0) + { + if (errno != EAGAIN) + { + /* Kill off the child */ + kill(pid, SIGTERM); + break; + } + + continue; + } + + if (ret == 0) + { + if (++timeout_count >= opt_timeout) + { + /* Kill off the child */ + kill(pid, SIGTERM); + break; + } + + continue; + } + + timeout_count = 0; + + if (pfd[2].revents & POLLNVAL) + { + /* REVISIT: This can probably be removed */ + syslog(LOG_ERR, "Child closed output pipe"); + child_alive = 0; + } + else if (pfd[2].revents & POLLIN) + { + /* Can read from (3) */ + writelen = read(crfd, writebuf, sizeof(writebuf)); + if (writelen <= 0) + { + if (writelen < 0) + { + syslog(LOG_WARNING, "Failed to read from child: len=%d", + writelen); + } + break; + } + } + else if ((pfd[2].revents & POLLHUP) && kill(pid, 0) == 0) + { + if (opt_verbose) + { + syslog(LOG_INFO, "Child died and pipe gave POLLHUP"); + } + + child_alive = 0; + } + + if (writelen > 0) + { + const unsigned char *pt = writebuf; + while (writelen > 0) + { + ret = ssl_write(ssl, pt, writelen); + if (ret <= 0) + { + syslog(LOG_WARNING, "Failed to write ssl: ret=%d", ret); + /* Kill off the child now */ + kill(pid, SIGTERM); + writelen = -1; + break; + } + else + { + pt += ret; + writelen -= ret; + } + } + if (writelen < 0) + { + break; + } + } + else if (pfd[0].revents & POLLIN) + { + readlen = ssl_read(ssl, &readbuf); + if (readlen <= 0 && opt_verbose) + { + syslog(LOG_INFO, "ssl_read() returned %d", readlen); + } + + if (readlen < 0) + { + /* Kill off the child */ + kill(pid, SIGTERM); + break; + } + } + + if (pfd[1].revents & POLLNVAL) + { + /* REVISIT: This can probably be removed */ + syslog(LOG_ERR, "Child closed input pipe"); + readlen = -1; + child_alive = 0; + } + else if (pfd[1].revents & POLLOUT) + { + const unsigned char *pt = readbuf; + while (readlen > 0) + { + int len = write(cwfd, pt, readlen); + if (len <= 0) + { + syslog(LOG_WARNING, "Failed to write to child: len=%d", + len); + break; + } + + readlen -= len; + pt += len; + } + } + + } + + ssl_free(ssl); +#if 0 + fprintf(stderr, "[%d] SSL done: timeout_count=%d, readlen=%d, writelen=%d, child_alive=%d\n", + getpid(), timeout_count, readlen, writelen, child_alive); +#endif + return 0; + } + + /* Child */ + close(df[1]); + close(fd[0]); + + dup2(df[0],0); + dup2(fd[1],1); + + close(df[0]); + close(fd[1]); + + execv(argv[1], argv + 1); + _exit(1); +} diff --git a/user/mpy/lib/axtls/bindings/Config.in b/user/mpy/lib/axtls/bindings/Config.in new file mode 100644 index 0000000..443fc1a --- /dev/null +++ b/user/mpy/lib/axtls/bindings/Config.in @@ -0,0 +1,105 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/config/Kconfig-language.txt +# +menu "Language Bindings" + +config CONFIG_BINDINGS + bool "Create language bindings" + default n + help + axTLS supports language bindings in C#, VB.NET, Java and Perl. + + Select Y here if you want to build the various language bindings. + +config CONFIG_CSHARP_BINDINGS + bool "Create C# bindings" + default n + depends on CONFIG_BINDINGS + help + Build C# bindings. + + This requires .NET to be installed on Win32 platforms and mono to be + installed on all other platforms. + +config CONFIG_VBNET_BINDINGS + bool "Create VB.NET bindings" + default n + depends on CONFIG_BINDINGS + help + Build VB.NET bindings. + + This requires the .NET to be installed and is only built under Win32 + platforms. + +menu ".Net Framework" +depends on CONFIG_CSHARP_BINDINGS || CONFIG_VBNET_BINDINGS +config CONFIG_DOT_NET_FRAMEWORK_BASE + string "Location of .NET Framework" + default "c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727" +endmenu + +config CONFIG_JAVA_BINDINGS + bool "Create Java bindings" + default n + depends on CONFIG_BINDINGS + help + Build Java bindings. + + Current Issues (see README): + * Needs Java 1.4 or better. + * If building under Win32 it will use the Win32 JDK. + +menu "Java Home" +depends on CONFIG_JAVA_BINDINGS +config CONFIG_JAVA_HOME + string "Location of JDK" + default "c:\\Program Files\\Java\\jdk1.5.0_06" if CONFIG_PLATFORM_WIN32 || CONFIG_PLATFORM_CYGWIN + default "/usr/lib/jvm/java-7-openjdk-amd64" if !CONFIG_PLATFORM_WIN32 && !CONFIG_PLATFORM_CYGWIN + depends on CONFIG_JAVA_BINDINGS + help + The location of Sun's JDK. +endmenu + +config CONFIG_PERL_BINDINGS + bool "Create Perl bindings" + default n + depends on CONFIG_BINDINGS + help + Build Perl bindings. + + Current Issues (see README): + * 64 bit versions don't work at present. + * libperl.so needs to be in the shared library path. + +menu "Perl Home" +depends on CONFIG_PERL_BINDINGS && CONFIG_PLATFORM_WIN32 +config CONFIG_PERL_CORE + string "Location of Perl CORE" + default "c:\\perl\\lib\\CORE" + help: + works with ActiveState + "http://www.activestate.com/Products/ActivePerl" + +config CONFIG_PERL_LIB + string "Name of Perl Library" + default "perl58.lib" +endmenu + +config CONFIG_LUA_BINDINGS + bool "Create Lua bindings" + default n + depends on CONFIG_BINDINGS && !CONFIG_PLATFORM_WIN32 + help + Build Lua bindings (see www.lua.org). + +menu "Lua Home" +depends on CONFIG_LUA_BINDINGS +config CONFIG_LUA_CORE + string "Location of Lua CORE" + default "/usr/local" + help: + If the Lua exists on another directory then this needs to be changed +endmenu + +endmenu diff --git a/user/mpy/lib/axtls/bindings/Makefile b/user/mpy/lib/axtls/bindings/Makefile new file mode 100644 index 0000000..7654fbb --- /dev/null +++ b/user/mpy/lib/axtls/bindings/Makefile @@ -0,0 +1,86 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +all: + +include ../config/.config +include ../config/makefile.conf + +ifdef CONFIG_CSHARP_BINDINGS +all: csharp/axInterface.cs +endif + +ifdef CONFIG_VBNET_BINDINGS +all: vbnet/axInterface.vb +endif + +ifdef CONFIG_JAVA_BINDINGS +all: java/axtlsj.java +endif + +ifdef CONFIG_PERL_BINDINGS +all: perl/axTLSp_wrap.c +endif + +ifdef CONFIG_LUA_BINDINGS +all: lua/axTLSl_wrap.c +endif + +csharp/axInterface.cs: ../ssl/ssl.h + @perl ./generate_interface.pl -csharp + +vbnet/axInterface.vb: ../ssl/ssl.h + @perl ./generate_interface.pl -vbnet + +java/axTLSj.i: ../ssl/ssl.h + @perl ./generate_SWIG_interface.pl -java + +java/axtlsj.java: java/axTLSj.i $(wildcard java/SSL*.java) + @cd java; swig -java -package axTLSj axTLSj.i; $(MAKE) + +perl/axTLSp.i: ../ssl/ssl.h + @perl ./generate_SWIG_interface.pl -perl + +perl/axTLSp_wrap.c: perl/axTLSp.i + @cd perl; swig -perl5 axTLSp.i; $(MAKE) + +lua/axTLSl.i: ../ssl/ssl.h + @perl ./generate_SWIG_interface.pl -lua + +lua/axTLSl_wrap.c: lua/axTLSl.i + @cd lua; swig -lua axTLSl.i; $(MAKE) + +clean:: + $(MAKE) -C csharp clean + $(MAKE) -C vbnet clean + $(MAKE) -C java clean + $(MAKE) -C perl clean + $(MAKE) -C lua clean + diff --git a/user/mpy/lib/axtls/bindings/README b/user/mpy/lib/axtls/bindings/README new file mode 100644 index 0000000..8bc3109 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/README @@ -0,0 +1,43 @@ +=============================================================================== += Language Bindings = +=============================================================================== + +The tools to generate the various language bindings are done here. +SWIG 1.3.24 or better is required for creating the Java and Perl bindings. + +Perl scripts are used to parse ssl.h and automagically give the appropriate +bindings. + +At present, the four languages supported are: + +* C# +* VB.NET +* Java +* Perl + +To generate each binding run the following: + +C#: +> generate_interface.pl -csharp + +VB.NET: +> generate_interface.pl -vbnet + + +Java: +> generate_SWIG_interface.pl -java +> cd java; swig -java -package axTLSj -noextern axTLSj.i + +Perl: +> generate_SWIG_interface.pl -perl +> cd perl; swig -noextern -perl axTLSp.i + +Java and Perl both create a library each called libaxtlsj.so and libaxtlsp.so +(or axtlsj.dll and atlsp.dll on Win32 platforms). + +Note: the "-noextern" is deprecated in swig 1.3.27 and newer. The "-noextern" +option was required to get Win32 bindings to work (which is why is has probably +been deprecated). + +Each binding (except for Perl) has an extra helper interface to make life +easier. diff --git a/user/mpy/lib/axtls/bindings/csharp/Makefile b/user/mpy/lib/axtls/bindings/csharp/Makefile new file mode 100644 index 0000000..3414f85 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/csharp/Makefile @@ -0,0 +1,35 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf + +clean:: + @rm -f axssl* axInterface.cs diff --git a/user/mpy/lib/axtls/bindings/csharp/axTLS.cs b/user/mpy/lib/axtls/bindings/csharp/axTLS.cs new file mode 100644 index 0000000..6a2f6b0 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/csharp/axTLS.cs @@ -0,0 +1,491 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * A wrapper around the unmanaged interface to give a semi-decent C# API + */ + +using System; +using System.Runtime.InteropServices; +using System.Net.Sockets; + +/** + * @defgroup csharp_api C# API. + * + * Ensure that the appropriate Dispose() methods are called when finished with + * various objects - otherwise memory leaks will result. + * @{ + */ +namespace axTLS +{ + /** + * @class SSL + * @ingroup csharp_api + * @brief A representation of an SSL connection. + */ + public class SSL + { + public IntPtr m_ssl; /**< A pointer to the real SSL type */ + + /** + * @brief Store the reference to an SSL context. + * @param ip [in] A reference to an SSL object. + */ + public SSL(IntPtr ip) + { + m_ssl = ip; + } + + /** + * @brief Free any used resources on this connection. + * + * A "Close Notify" message is sent on this connection (if possible). + * It is up to the application to close the socket. + */ + public void Dispose() + { + axtls.ssl_free(m_ssl); + } + + /** + * @brief Return the result of a handshake. + * @return SSL_OK if the handshake is complete and ok. + * @see ssl.h for the error code list. + */ + public int HandshakeStatus() + { + return axtls.ssl_handshake_status(m_ssl); + } + + /** + * @brief Return the SSL cipher id. + * @return The cipher id which is one of: + * - SSL_AES128_SHA (0x2f) + * - SSL_AES256_SHA (0x35) + * - SSL_AES128_SHA256 (0x3c) + * - SSL_AES256_SHA256 (0x3d) + */ + public byte GetCipherId() + { + return axtls.ssl_get_cipher_id(m_ssl); + } + + /** + * @brief Get the session id for a handshake. + * + * This will be a 32 byte sequence and is available after the first + * handshaking messages are sent. + * @return The session id as a 32 byte sequence. + * @note A SSLv23 handshake may have only 16 valid bytes. + */ + public byte[] GetSessionId() + { + IntPtr ptr = axtls.ssl_get_session_id(m_ssl); + byte sess_id_size = axtls.ssl_get_session_id_size(m_ssl); + byte[] result = new byte[sess_id_size]; + Marshal.Copy(ptr, result, 0, sess_id_size); + return result; + } + + /** + * @brief Retrieve an X.509 distinguished name component. + * + * When a handshake is complete and a certificate has been exchanged, + * then the details of the remote certificate can be retrieved. + * + * This will usually be used by a client to check that the server's + * common name matches the URL. + * + * A full handshake needs to occur for this call to work. + * + * @param component [in] one of: + * - SSL_X509_CERT_COMMON_NAME + * - SSL_X509_CERT_ORGANIZATION + * - SSL_X509_CERT_ORGANIZATIONAL_NAME + * - SSL_X509_CA_CERT_COMMON_NAME + * - SSL_X509_CA_CERT_ORGANIZATION + * - SSL_X509_CA_CERT_ORGANIZATIONAL_NAME + * @return The appropriate string (or null if not defined) + */ + public string GetCertificateDN(int component) + { + return axtls.ssl_get_cert_dn(m_ssl, component); + } + } + + /** + * @class SSLUtil + * @ingroup csharp_api + * @brief Some global helper functions. + */ + public class SSLUtil + { + + /** + * @brief Return the build mode of the axTLS project. + * @return The build mode is one of: + * - SSL_BUILD_SERVER_ONLY + * - SSL_BUILD_ENABLE_VERIFICATION + * - SSL_BUILD_ENABLE_CLIENT + * - SSL_BUILD_FULL_MODE + */ + public static int BuildMode() + { + return axtls.ssl_get_config(axtls.SSL_BUILD_MODE); + } + + /** + * @brief Return the number of chained certificates that the + * client/server supports. + * @return The number of supported server certificates. + */ + public static int MaxCerts() + { + return axtls.ssl_get_config(axtls.SSL_MAX_CERT_CFG_OFFSET); + } + + /** + * @brief Return the number of CA certificates that the client/server + * supports. + * @return The number of supported CA certificates. + */ + public static int MaxCACerts() + { + return axtls.ssl_get_config(axtls.SSL_MAX_CA_CERT_CFG_OFFSET); + } + + /** + * @brief Indicate if PEM is supported. + * @return true if PEM supported. + */ + public static bool HasPEM() + { + return axtls.ssl_get_config(axtls.SSL_HAS_PEM) > 0 ? true : false; + } + + /** + * @brief Display the text string of the error. + * @param error_code [in] The integer error code. + */ + public static void DisplayError(int error_code) + { + axtls.ssl_display_error(error_code); + } + + /** + * @brief Return the version of the axTLS project. + */ + public static string Version() + { + return axtls.ssl_version(); + } + } + + /** + * @class SSLCTX + * @ingroup csharp_api + * @brief A base object for SSLServer/SSLClient. + */ + public class SSLCTX + { + /** + * @brief A reference to the real client/server context. + */ + protected IntPtr m_ctx; + + /** + * @brief Establish a new client/server context. + * + * This function is called before any client/server SSL connections are + * made. If multiple threads are used, then each thread will have its + * own SSLCTX context. Any number of connections may be made with a + * single context. + * + * Each new connection will use the this context's private key and + * certificate chain. If a different certificate chain is required, + * then a different context needs to be be used. + * + * @param options [in] Any particular options. At present the options + * supported are: + * - SSL_SERVER_VERIFY_LATER (client only): Don't stop a handshake if + * the server authentication fails. The certificate can be + * authenticated later with a call to VerifyCert(). + * - SSL_CLIENT_AUTHENTICATION (server only): Enforce client + * authentication i.e. each handshake will include a "certificate + * request" message from the server. + * - SSL_DISPLAY_BYTES (full mode build only): Display the byte + * sequences during the handshake. + * - SSL_DISPLAY_STATES (full mode build only): Display the state + * changes during the handshake. + * - SSL_DISPLAY_CERTS (full mode build only): Display the + * certificates that are passed during a handshake. + * - SSL_DISPLAY_RSA (full mode build only): Display the RSA key + * details that are passed during a handshake. + * @param num_sessions [in] The number of sessions to be used for + * session caching. If this value is 0, then there is no session + * caching. + * @return A client/server context. + */ + protected SSLCTX(uint options, int num_sessions) + { + m_ctx = axtls.ssl_ctx_new(options, num_sessions); + } + + /** + * @brief Remove a client/server context. + * + * Frees any used resources used by this context. Each connection will + * be sent a "Close Notify" alert (if possible). + */ + public void Dispose() + { + axtls.ssl_ctx_free(m_ctx); + } + + /** + * @brief Read the SSL data stream. + * @param ssl [in] An SSL object reference. + * @param in_data [out] After a successful read, the decrypted data + * will be here. It will be null otherwise. + * @return The number of decrypted bytes: + * - if > 0, then the handshaking is complete and we are returning the + * number of decrypted bytes. + * - SSL_OK if the handshaking stage is successful (but not yet + * complete). + * - < 0 if an error. + * @see ssl.h for the error code list. + * @note Use in_data before doing any successive ssl calls. + */ + public int Read(SSL ssl, out byte[] in_data) + { + IntPtr ptr = IntPtr.Zero; + int ret = axtls.ssl_read(ssl.m_ssl, ref ptr); + + if (ret > axtls.SSL_OK) + { + in_data = new byte[ret]; + Marshal.Copy(ptr, in_data, 0, ret); + } + else + { + in_data = null; + } + + return ret; + } + + /** + * @brief Write to the SSL data stream. + * @param ssl [in] An SSL obect reference. + * @param out_data [in] The data to be written + * @return The number of bytes sent, or if < 0 if an error. + * @see ssl.h for the error code list. + */ + public int Write(SSL ssl, byte[] out_data) + { + return axtls.ssl_write(ssl.m_ssl, out_data, out_data.Length); + } + + /** + * @brief Write to the SSL data stream. + * @param ssl [in] An SSL obect reference. + * @param out_data [in] The data to be written + * @param out_len [in] The number of bytes to be written + * @return The number of bytes sent, or if < 0 if an error. + * @see ssl.h for the error code list. + */ + public int Write(SSL ssl, byte[] out_data, int out_len) + { + return axtls.ssl_write(ssl.m_ssl, out_data, out_len); + } + + /** + * @brief Find an ssl object based on a Socket reference. + * + * Goes through the list of SSL objects maintained in a client/server + * context to look for a socket match. + * @param s [in] A reference to a Socket object. + * @return A reference to the SSL object. Returns null if the object + * could not be found. + */ + public SSL Find(Socket s) + { + int client_fd = s.Handle.ToInt32(); + return new SSL(axtls. ssl_find(m_ctx, client_fd)); + } + + /** + * @brief Authenticate a received certificate. + * + * This call is usually made by a client after a handshake is complete + * and the context is in SSL_SERVER_VERIFY_LATER mode. + * @param ssl [in] An SSL object reference. + * @return SSL_OK if the certificate is verified. + */ + public int VerifyCert(SSL ssl) + { + return axtls.ssl_verify_cert(ssl.m_ssl); + } + + /** + * @brief Force the client to perform its handshake again. + * + * For a client this involves sending another "client hello" message. + * For the server is means sending a "hello request" message. + * + * This is a blocking call on the client (until the handshake + * completes). + * @param ssl [in] An SSL object reference. + * @return SSL_OK if renegotiation instantiation was ok + */ + public int Renegotiate(SSL ssl) + { + return axtls.ssl_renegotiate(ssl.m_ssl); + } + + /** + * @brief Load a file into memory that is in binary DER or ASCII PEM + * format. + * + * These are temporary objects that are used to load private keys, + * certificates etc into memory. + * @param obj_type [in] The format of the file. Can be one of: + * - SSL_OBJ_X509_CERT (no password required) + * - SSL_OBJ_X509_CACERT (no password required) + * - SSL_OBJ_RSA_KEY (AES128/AES256 PEM encryption supported) + * - SSL_OBJ_P8 (RC4-128 encrypted data supported) + * - SSL_OBJ_P12 (RC4-128 encrypted data supported) + * + * PEM files are automatically detected (if supported). + * @param filename [in] The location of a file in DER/PEM format. + * @param password [in] The password used. Can be null if not required. + * @return SSL_OK if all ok + */ + public int ObjLoad(int obj_type, string filename, string password) + { + return axtls.ssl_obj_load(m_ctx, obj_type, filename, password); + } + + /** + * @brief Transfer binary data into the object loader. + * + * These are temporary objects that are used to load private keys, + * certificates etc into memory. + * @param obj_type [in] The format of the memory data. + * @param data [in] The binary data to be loaded. + * @param len [in] The amount of data to be loaded. + * @param password [in] The password used. Can be null if not required. + * @return SSL_OK if all ok + */ + public int ObjLoad(int obj_type, byte[] data, int len, string password) + { + return axtls.ssl_obj_memory_load(m_ctx, obj_type, + data, len, password); + } + } + + /** + * @class SSLServer + * @ingroup csharp_api + * @brief The server context. + * + * All server connections are started within a server context. + */ + public class SSLServer : SSLCTX + { + /** + * @brief Start a new server context. + * + * @see SSLCTX for details. + */ + public SSLServer(uint options, int num_sessions) : + base(options, num_sessions) {} + + /** + * @brief Establish a new SSL connection to an SSL client. + * + * It is up to the application to establish the initial socket + * connection. + * + * Call Dispose() when the connection is to be removed. + * @param s [in] A reference to a Socket object. + * @return An SSL object reference. + */ + public SSL Connect(Socket s) + { + int client_fd = s.Handle.ToInt32(); + return new SSL(axtls.ssl_server_new(m_ctx, client_fd)); + } + } + + /** + * @class SSLClient + * @ingroup csharp_api + * @brief The client context. + * + * All client connections are started within a client context. + */ + public class SSLClient : SSLCTX + { + /** + * @brief Start a new client context. + * + * @see SSLCTX for details. + */ + public SSLClient(uint options, int num_sessions) : + base(options, num_sessions) {} + + /** + * @brief Establish a new SSL connection to an SSL server. + * + * It is up to the application to establish the initial socket + * connection. + * + * This is a blocking call - it will finish when the handshake is + * complete (or has failed). + * + * Call Dispose() when the connection is to be removed. + * @param s [in] A reference to a Socket object. + * @param session_id [in] A 32 byte session id for session resumption. + * This can be null if no session resumption is not required. + * @return An SSL object reference. Use SSL.handshakeStatus() to check + * if a handshake succeeded. + */ + public SSL Connect(Socket s, byte[] session_id) + { + int client_fd = s.Handle.ToInt32(); + byte sess_id_size = (byte)(session_id != null ? + session_id.Length : 0); + return new SSL(axtls.ssl_client_new(m_ctx, client_fd, session_id, + sess_id_size)); + } + } +} +/** @} */ diff --git a/user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl b/user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl new file mode 100755 index 0000000..90c4ba3 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl @@ -0,0 +1,392 @@ +#!/usr/bin/perl + +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +#=============================================================== +# Transforms function signature into SWIG format +sub transformSignature +{ + foreach $item (@_) + { + $line =~ s/STDCALL //g; + $line =~ s/EXP_FUNC/extern/g; + + # make API Java more 'byte' friendly + $line =~ s/uint32_t/int/g; + $line =~ s/const uint8_t \* /const unsigned char \* /g; + $line =~ s/\(void\)/()/g; + if ($ARGV[0] eq "-java") + { + $line =~ s/.*ssl_read.*//g; + $line =~ s/const uint8_t \*(\w+)/const signed char $1\[\]/g; + $line =~ s/uint8_t/signed char/g; + } + elsif ($ARGV[0] eq "-perl") + { + $line =~ s/const uint8_t \*(\w+)/const unsigned char $1\[\]/g; + $line =~ s/uint8_t/unsigned char/g; + } + else # lua + { + $line =~ s/const uint8_t \*session_id/const unsigned char session_id\[\]/g; + $line =~ s/const uint8_t \*\w+/unsigned char *INPUT/g; + $line =~ s/uint8_t/unsigned char/g; + } + } + + return $line; +} + +# Parse input file +sub parseFile +{ + foreach $line (@_) + { + next if $line =~ /ssl_x509_create/; # ignore for now + + # test for a #define + if (!$skip && $line =~ m/^#define/) + { + $splitDefine = 1 if $line =~ m/\\$/; + print DATA_OUT $line; + + # check line is not split + next if $splitDefine == 1; + } + + # pick up second line of #define statement + if ($splitDefine) + { + print DATA_OUT $line; + + # check line is not split + $splitDefine = ($line =~ m/\\$/); + next; + } + + # test for function declaration + if (!$skip && $line =~ /EXP_FUNC/ && $line !~/\/\*/) + { + $line = transformSignature($line); + $splitFunctionDeclaration = $line !~ /;/; + print DATA_OUT $line; + next; + } + + if ($splitFunctionDeclaration) + { + $line = transformSignature($line); + $splitFunctionDeclaration = $line !~ /;/; + print DATA_OUT $line; + next; + } + } +} + +#=============================================================== + +# Determine which module to build from cammand-line options +use strict; +use Getopt::Std; + +my $module; +my $interfaceFile; +my $data_file; +my $skip; +my $splitLine; +my @raw_data; + +if (not defined $ARGV[0]) +{ + die "Usage: $0 [-java | -perl | -lua]\n"; +} + +if ($ARGV[0] eq "-java") +{ + print "Generating Java interface file\n"; + $module = "axtlsj"; + $interfaceFile = "java/axTLSj.i"; +} +elsif ($ARGV[0] eq "-perl") +{ + print "Generating Perl interface file\n"; + $module = "axtlsp"; + $interfaceFile = "perl/axTLSp.i"; +} +elsif ($ARGV[0] eq "-lua") +{ + print "Generating lua interface file\n"; + $module = "axtlsl"; + $interfaceFile = "lua/axTLSl.i"; +} +else +{ + die "Usage: $0 [-java | -perl | -lua]\n"; +} + +# Input file required to generate SWIG interface file. +$data_file = "../ssl/ssl.h"; + +# Open input files +open(DATA_IN, $data_file) || die("Could not open file ($data_file)!"); +@raw_data = ; + +# Open output file +open(DATA_OUT, ">$interfaceFile") || die("Cannot Open File"); + +# +# I wish I could say it was easy to generate the Perl/Java/Lua bindings, +# but each had their own set of challenges... :-(. +# +print DATA_OUT << "END"; +%module $module\n + +/* include our own header */ +%inline %{ +#include "ssl.h" +%} + +%include "typemaps.i" +/* Some SWIG magic to make the API a bit more Java friendly */ +#ifdef SWIGJAVA + +%apply long { SSL * }; +%apply long { SSL_CTX * }; +%apply long { SSLObjLoader * }; + +/* allow "unsigned char []" to become "byte[]" */ +%include "arrays_java.i" + +/* convert these pointers to use long */ +%apply signed char[] {unsigned char *}; +%apply signed char[] {signed char *}; + +/* allow ssl_get_session_id() to return "byte[]" */ +%typemap(out) unsigned char * ssl_get_session_id \"if (result) jresult = SWIG_JavaArrayOutSchar(jenv, result, ssl_get_session_id_size((SSL const *)arg1));\" + +/* allow ssl_client_new() to have a null session_id input */ +%typemap(in) const signed char session_id[] (jbyte *jarr) { + if (jarg3 == NULL) + { + jresult = (jint)ssl_client_new(arg1,arg2,NULL,0); + return jresult; + } + + if (!SWIG_JavaArrayInSchar(jenv, &jarr, &arg3, jarg3)) return 0; +} + +/* Lot's of work required for an ssl_read() due to its various custom + * requirements. + */ +%native (ssl_read) int ssl_read(SSL *ssl, jobject in_data); +%{ +JNIEXPORT jint JNICALL Java_axTLSj_axtlsjJNI_ssl_1read(JNIEnv *jenv, jclass jcls, jint jarg1, jobject jarg2) { + jint jresult = 0 ; + SSL *arg1; + unsigned char *arg2; + jbyte *jarr; + int result; + JNIEnv e = *jenv; + jclass holder_class; + jfieldID fid; + + arg1 = (SSL *)jarg1; + result = (int)ssl_read(arg1, &arg2); + + /* find the "m_buf" entry in the SSLReadHolder class */ + if (!(holder_class = e->GetObjectClass(jenv,jarg2)) || + !(fid = e->GetFieldID(jenv,holder_class, "m_buf", "[B"))) + return SSL_NOT_OK; + + if (result > SSL_OK) + { + int i; + + /* create a new byte array to hold the read data */ + jbyteArray jarray = e->NewByteArray(jenv, result); + + /* copy the bytes across to the java byte array */ + jarr = e->GetByteArrayElements(jenv, jarray, 0); + for (i = 0; i < result; i++) + jarr[i] = (jbyte)arg2[i]; + + /* clean up and set the new m_buf object */ + e->ReleaseByteArrayElements(jenv, jarray, jarr, 0); + e->SetObjectField(jenv, jarg2, fid, jarray); + } + else /* set to null */ + e->SetObjectField(jenv, jarg2, fid, NULL); + + jresult = (jint)result; + return jresult; +} +%} + +/* Big hack to get hold of a socket's file descriptor */ +%typemap (jtype) long "Object" +%typemap (jstype) long "Object" +%native (getFd) int getFd(long sock); +%{ +JNIEXPORT jint JNICALL Java_axTLSj_axtlsjJNI_getFd(JNIEnv *env, jclass jcls, jobject sock) +{ + JNIEnv e = *env; + jfieldID fid; + jobject impl; + jobject fdesc; + + /* get the SocketImpl from the Socket */ + if (!(jcls = e->GetObjectClass(env,sock)) || + !(fid = e->GetFieldID(env,jcls,"impl","Ljava/net/SocketImpl;")) || + !(impl = e->GetObjectField(env,sock,fid))) return -1; + + /* get the FileDescriptor from the SocketImpl */ + if (!(jcls = e->GetObjectClass(env,impl)) || + !(fid = e->GetFieldID(env,jcls,"fd","Ljava/io/FileDescriptor;")) || + !(fdesc = e->GetObjectField(env,impl,fid))) return -1; + + /* get the fd from the FileDescriptor */ + if (!(jcls = e->GetObjectClass(env,fdesc)) || + !(fid = e->GetFieldID(env,jcls,"fd","I"))) return -1; + + /* return the descriptor */ + return e->GetIntField(env,fdesc,fid); +} +%} + +#endif + +/* Some SWIG magic to make the API a bit more Perl friendly */ +#ifdef SWIGPERL + +/* for ssl_session_id() */ +%typemap(out) const unsigned char * { + SV *svs = newSVpv((unsigned char *)\$1, ssl_get_session_id_size((SSL const *)arg1)); + \$result = newRV(svs); + sv_2mortal(\$result); + argvi++; +} + +/* for ssl_write() */ +%typemap(in) const unsigned char out_data[] { + SV* tempsv; + if (!SvROK(\$input)) + croak("Argument \$argnum is not a reference."); + tempsv = SvRV(\$input); + if (SvTYPE(tempsv) != SVt_PV) + croak("Argument \$argnum is not an string."); + \$1 = (unsigned char *)SvPV(tempsv, PL_na); +} + +/* for ssl_read() */ +%typemap(in) unsigned char **in_data (unsigned char *buf) { + \$1 = &buf; +} + +%typemap(argout) unsigned char **in_data { + if (result > SSL_OK) { + SV *svs = newSVpv(*\$1, result); + \$result = newRV(svs); + sv_2mortal(\$result); + argvi++; + } +} + +/* for ssl_client_new() */ +%typemap(in) const unsigned char session_id[] { + /* check for a reference */ + if (SvOK(\$input) && SvROK(\$input)) { + SV* tempsv = SvRV(\$input); + if (SvTYPE(tempsv) != SVt_PV) + croak("Argument \$argnum is not an string."); + \$1 = (unsigned char *)SvPV(tempsv, PL_na); + } + else + \$1 = NULL; +} + +#endif + +/* Some SWIG magic to make the API a bit more Lua friendly */ +#ifdef SWIGLUA +SWIG_NUMBER_TYPEMAP(unsigned char); +SWIG_TYPEMAP_NUM_ARR(uchar,unsigned char); + +/* for ssl_session_id() */ +%typemap(out) const unsigned char * { + int i; + lua_newtable(L); + for (i = 0; i < ssl_get_session_id_size((SSL const *)arg1); i++){ + lua_pushnumber(L,(lua_Number)result[i]); + lua_rawseti(L,-2,i+1); /* -1 is the number, -2 is the table */ + } + SWIG_arg++; +} + +/* for ssl_read() */ +%typemap(in) unsigned char **in_data (unsigned char *buf) { + \$1 = &buf; +} + +%typemap(argout) unsigned char **in_data { + if (result > SSL_OK) { + int i; + lua_newtable(L); + for (i = 0; i < result; i++){ + lua_pushnumber(L,(lua_Number)buf2[i]); + lua_rawseti(L,-2,i+1); /* -1 is the number, -2 is the table */ + } + SWIG_arg++; + } +} + +/* for ssl_client_new() */ +%typemap(in) const unsigned char session_id[] { + if (lua_isnil(L,\$input)) + \$1 = NULL; + else + \$1 = SWIG_get_uchar_num_array_fixed(L,\$input, ssl_get_session_id((SSL const *)\$1)); +} + +#endif + +END + +# Initialise loop variables +$skip = 1; +$splitLine = 0; + +parseFile(@raw_data); + +close(DATA_IN); +close(DATA_OUT); + +#=============================================================== + diff --git a/user/mpy/lib/axtls/bindings/generate_interface.pl b/user/mpy/lib/axtls/bindings/generate_interface.pl new file mode 100755 index 0000000..c24bff9 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/generate_interface.pl @@ -0,0 +1,322 @@ +#!/usr/bin/perl -w + +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +#=============================================================== +# This application transforms ssl.h into interfaces that can be used by +# other language bindings. It is "SWIG"-like in nature in that various +# files are generated based on the axTLS API. +# +# The file produced is axInterface.? (depending on the file extension). +# +#=============================================================== + +use strict; + +my $CSHARP = 0; +my $VBNET = 1; + +my $binding; +my $skip = 0; +my $signature_ret_type; + +# Transforms function signature into an Interface format +sub transformSignature +{ + my $item; + my ($line) = @_; + + foreach $item ($line) + { + # our very basic preprocessor + if ($binding == $CSHARP) + { + $line =~ s/STDCALL //; + $line =~ s/EXP_FUNC/ [DllImport ("axtls")]\n public static extern/; + $line =~ s/uint32_t/uint/g; + $line =~ s/uint8_t \*\*/ref IntPtr /g; + $line =~ s/const uint8_t \* /IntPtr /g; + $line =~ s/const uint8_t \*/byte[] /g; # note: subtle diff + $line =~ s/uint8_t \* ?/byte[] /g; + $line =~ s/uint8_t ?/byte /g; + $line =~ s/const char \* ?/string /g; + $line =~ s/const SSL_CTX \* ?/IntPtr /g; + $line =~ s/SSL_CTX \* ?/IntPtr /g; + $line =~ s/SSLObjLoader \* ?/IntPtr /g; + $line =~ s/const SSL \* ?/IntPtr /g; + $line =~ s/SSL \* ?/IntPtr /g; + $line =~ s/\(void\)/()/g; + } + elsif ($binding == $VBNET) + { + if ($line =~ /EXP_FUNC/) + { + # Procedure or function? + my $invariant = $line =~ /void /; + + my $proc = $invariant ? "Sub" : "Function"; + ($signature_ret_type) = $line =~ /EXP_FUNC (.*) STDCALL/; + $line =~ s/EXP_FUNC .* STDCALL / Public Shared $proc _\n /; + + $signature_ret_type =~ s/const uint8_t \*/As IntPtr/; + $signature_ret_type =~ s/const char \*/As String/; + $signature_ret_type =~ s/SSL_CTX \*/As IntPtr/; + $signature_ret_type =~ s/SSLObjLoader \*/As IntPtr/; + $signature_ret_type =~ s/SSL \*/As IntPtr/; + $signature_ret_type =~ s/uint8_t/As Byte/; + $signature_ret_type =~ s/int/As Integer/; + $signature_ret_type =~ s/void//; + $signature_ret_type .= "\n End $proc\n\n"; + } + + $line =~ s/uint32_t (\w+)/ByVal $1 As Integer/g; + $line =~ s/int (\w+)/ByVal $1 As Integer/g; + $line =~ s/uint8_t \*\* ?(\w+)/ByRef $1 As IntPtr/g; + $line =~ s/const uint8_t \* ?(\w+)/ByVal $1() As Byte/g; + $line =~ s/uint8_t \* ?(\w+)/ByVal $1() As Byte/g; + $line =~ s/uint8_t ?(\w+)/ByVal $1 As Byte/g; + $line =~ s/const char \* ?(\w+)/ByVal $1 As String/g; + $line =~ s/const SSL_CTX \* ?(\w+)/ByVal $1 As IntPtr/g; + $line =~ s/SSL_CTX \* ?(\w+)/ByVal $1 As IntPtr/g; + $line =~ s/SSLObjLoader \* ?(\w+)/ByVal $1 As IntPtr/g; + $line =~ s/const SSL \* ?(\w+)/ByVal $1 As IntPtr/g; + $line =~ s/SSL \* ?(\w+)/ByVal $1 As IntPtr/g; + $line =~ s/void \* ?(\w+)/Byval $1 As IntPtr/g; + $line =~ s/\(void\)/()/g; + $line =~ s/void//g; + $line =~ s/;\n/ $signature_ret_type;/; + } + } + + return $line; +} + +# Parse input file +sub parseFile +{ + my (@file) = @_; + my $line; + my $splitDefine = 0; + my $splitFunctionDeclaration; + my $vb_hack = " "; + my $vb_line_hack = 0; + + $skip = 0; + + foreach $line (@file) + { + next if $line =~ /sl_x509_create/; # ignore for now + + # test for a #define + if (!$skip && $line =~ m/^#define/) + { + $splitDefine = 1 if $line =~ m/\\$/; + + if ($binding == $VBNET) + { + $line =~ s/\|/Or/g; + $line =~ s/ 0x/ &H/; + } + + my ($name, $value) = $line =~ /#define (\w+) +([^\\]*)[\\]?\n/; + + if (defined $name && defined $value) + { + # C# constant translation + if ($binding == $CSHARP) + { + $line = " public const int $name = $value"; + } + # VB.NET constant translation + elsif ($binding == $VBNET) + { + $line = " Public Const $name As Integer = $value"; + } + } + + next if $line =~ /#define/; # ignore any other defines + + print DATA_OUT $line; + + # check line is not split + next if $splitDefine == 1; + print DATA_OUT ";" if $binding == $CSHARP; + print DATA_OUT "\n"; + } + + # pick up second line of #define statement + if ($splitDefine) + { + if ($line !~ /\\$/) + { + $line =~ s/$/;/ if $binding == $CSHARP; # add the ";" + } + + $line =~ s/ ?\| ?/ Or /g + if ($binding == $VBNET); + + # check line is not split + $splitDefine = ($line =~ m/\\$/); + + # ignore trailing "\" + $line =~ s/\\$// if $binding == $CSHARP; + $line =~ s/\\$/_/ if $binding == $VBNET; + print DATA_OUT $line; + next; + } + + # test for function declaration + if (!$skip && $line =~ /EXP_FUNC/ && $line !~ /\/\*/) + { + $line = transformSignature($line); + $splitFunctionDeclaration = $line !~ /;/; + $line =~ s/;// if ($binding == $VBNET); + $line =~ s/\n$/ _\n/ if ($binding == $VBNET) && + $splitFunctionDeclaration; + print DATA_OUT $line; + next; + } + + if ($splitFunctionDeclaration) + { + $line = transformSignature($line); + $splitFunctionDeclaration = $line !~ /;/; + $line =~ s/;// if ($binding == $VBNET); + $line =~ s/\n/ _\n/ if ($binding == $VBNET) && + $splitFunctionDeclaration == 1; + print DATA_OUT $line; + next; + } + } +} + +#=============================================================== + +# Determine which module to build from command-line options +use strict; +use Getopt::Std; + +my $binding_prefix; +my $binding_suffix; +my $data_file; +my @raw_data; + +if (not defined $ARGV[0]) +{ + goto ouch; +} + +if ($ARGV[0] eq "-csharp") +{ + print "Generating C# interface file\n"; + $binding_prefix = "csharp"; + $binding_suffix = "cs"; + $binding = $CSHARP; +} +elsif ($ARGV[0] eq "-vbnet") +{ + print "Generating VB.NET interface file\n"; + $binding_prefix = "vbnet"; + $binding_suffix = "vb"; + $binding = $VBNET; +} +else +{ +ouch: + die "Usage: $0 [-csharp | -vbnet]\n"; +} + +my $interfaceFile = "$binding_prefix/axInterface.$binding_suffix"; + +# Input file required to generate interface file. +$data_file = "../ssl/ssl.h"; + +# Open input files +open(DATA_IN, $data_file) || die("Could not open file ($data_file)!"); +@raw_data = ; + + +# Open output file +if ($binding == $CSHARP || $binding == $VBNET) +{ + open(DATA_OUT, ">$interfaceFile") || die("Cannot Open File"); +} + +# SPEC interface file header +if ($binding == $CSHARP) +{ + # generate the C#/C interface file + print DATA_OUT << "END"; +// The C# to C interface definition file for the axTLS project +// Do not modify - this file is generated + +using System; +using System.Runtime.InteropServices; + +namespace axTLS +{ + public class axtls + { +END +} +elsif ($binding == $VBNET) +{ + # generate the VB.NET/C interface file + print DATA_OUT << "END"; +' The VB.NET to C interface definition file for the axTLS project +' Do not modify - this file is generated + +Imports System +Imports System.Runtime.InteropServices + +Namespace axTLSvb + Public Class axtls +END +} + +parseFile(@raw_data); + +# finish up +if ($binding == $CSHARP) +{ + print DATA_OUT " };\n"; + print DATA_OUT "};\n"; +} +elsif ($binding == $VBNET) +{ + print DATA_OUT " End Class\nEnd Namespace\n"; +} + +close(DATA_IN); +close(DATA_OUT); + +#=============================================================== + diff --git a/user/mpy/lib/axtls/bindings/java/Makefile b/user/mpy/lib/axtls/bindings/java/Makefile new file mode 100644 index 0000000..8df1d0a --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/Makefile @@ -0,0 +1,94 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +AXTLS_HOME=../.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf +include $(AXTLS_HOME)/config/makefile.java.conf + +all: lib jar + +JAR=$(AXTLS_HOME)/$(STAGE)/axtls.jar + +ifdef CONFIG_PLATFORM_WIN32 +TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsj.dll +else +TARGET=$(AXTLS_HOME)/$(STAGE)/libaxtlsj.so +endif + +lib: $(TARGET) +axTLSj_wrap.o : axTLSj_wrap.c + +JAVA_FILES= \ + axtlsjJNI.java \ + axtlsjConstants.java \ + axtlsj.java \ + SSLReadHolder.java \ + SSL.java \ + SSLUtil.java \ + SSLCTX.java \ + SSLServer.java \ + SSLClient.java + +OBJ=axTLSj_wrap.o + +JAVA_CLASSES:=$(JAVA_FILES:%.java=classes/axTLSj/%.class) + +ifdef CONFIG_PLATFORM_WIN32 +LDFLAGS += axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)" + +include $(AXTLS_HOME)/config/makefile.post + +$(TARGET) : $(OBJ) + $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ) +else # Not Win32 + +$(TARGET) : $(OBJ) + $(LD) $(LDFLAGS) -L $(AXTLS_HOME)/$(STAGE) $(LDSHARED) -o $@ $(OBJ) -laxtls +endif + +jar: $(OBJ) $(JAR) + +# if we are doing the samples then defer creating the jar until then +$(JAR): $(JAVA_CLASSES) +ifndef CONFIG_JAVA_SAMPLES + jar cvf $@ -C classes axTLSj +else + @if [ ! -f $(JAR) ]; then touch $(JAR); fi +endif + +classes/axTLSj/%.class : %.java + javac -d classes -classpath classes $^ + +clean:: + @rm -f $(JAR) $(TARGET) SWIG* axtls* *.i *.c + @rm -fr classes/* + diff --git a/user/mpy/lib/axtls/bindings/java/SSL.java b/user/mpy/lib/axtls/bindings/java/SSL.java new file mode 100644 index 0000000..e0400b6 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/SSL.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A wrapper around the unmanaged interface to give a semi-decent Java API + */ + +package axTLSj; + +import java.io.*; +import java.util.*; + +/** + * @defgroup java_api Java API. + * + * Ensure that the appropriate dispose() methods are called when finished with + * various objects - otherwise memory leaks will result. + */ + +/** + * @class SSL + * @ingroup java_api + * @brief A representation of an SSL connection. + * + */ +public class SSL +{ + public int m_ssl; /**< A pointer to the real SSL type */ + + /** + * @brief Store the reference to an SSL context. + * @param ip [in] A reference to an SSL object. + */ + public SSL(int ip) + { + m_ssl = ip; + } + + /** + * @brief Free any used resources on this connection. + * + * A "Close Notify" message is sent on this connection (if possible). It + * is up to the application to close the socket. + */ + public void dispose() + { + axtlsj.ssl_free(m_ssl); + } + + /** + * @brief Return the result of a handshake. + * @return SSL_OK if the handshake is complete and ok. + * @see ssl.h for the error code list. + */ + public int handshakeStatus() + { + return axtlsj.ssl_handshake_status(m_ssl); + } + + /** + * @brief Return the SSL cipher id. + * @return The cipher id which is one of: + * - SSL_AES128_SHA (0x2f) + * - SSL_AES256_SHA (0x35) + * - SSL_AES128_SHA256 (0x3c) + * - SSL_AES256_SHA256 (0x3d) + */ + public byte getCipherId() + { + return axtlsj.ssl_get_cipher_id(m_ssl); + } + + /** + * @brief Get the session id for a handshake. + * + * This will be a 32 byte sequence and is available after the first + * handshaking messages are sent. + * @return The session id as a 32 byte sequence. + * @note A SSLv23 handshake may have only 16 valid bytes. + */ + public byte[] getSessionId() + { + return axtlsj.ssl_get_session_id(m_ssl); + } + + /** + * @brief Retrieve an X.509 distinguished name component. + * + * When a handshake is complete and a certificate has been exchanged, + * then the details of the remote certificate can be retrieved. + * + * This will usually be used by a client to check that the server's common + * name matches the URL. + * + * A full handshake needs to occur for this call to work. + * + * @param component [in] one of: + * - SSL_X509_CERT_COMMON_NAME + * - SSL_X509_CERT_ORGANIZATION + * - SSL_X509_CERT_ORGANIZATIONAL_NAME + * - SSL_X509_CA_CERT_COMMON_NAME + * - SSL_X509_CA_CERT_ORGANIZATION + * - SSL_X509_CA_CERT_ORGANIZATIONAL_NAME + * @return The appropriate string (or null if not defined) + */ + public String getCertificateDN(int component) + { + return axtlsj.ssl_get_cert_dn(m_ssl, component); + } +} diff --git a/user/mpy/lib/axtls/bindings/java/SSLCTX.java b/user/mpy/lib/axtls/bindings/java/SSLCTX.java new file mode 100644 index 0000000..1cd3e03 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/SSLCTX.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A wrapper around the unmanaged interface to give a semi-decent Java API + */ + +package axTLSj; + +import java.net.*; + +/** + * @class SSLCTX + * @ingroup java_api + * @brief A base object for SSLServer/SSLClient. + */ +public class SSLCTX +{ + /** + * A reference to the real client/server context. + */ + protected int m_ctx; + + /** + * @brief Establish a new client/server context. + * + * This function is called before any client/server SSL connections are + * made. If multiple threads are used, then each thread will have its + * own SSLCTX context. Any number of connections may be made with a single + * context. + * + * Each new connection will use the this context's private key and + * certificate chain. If a different certificate chain is required, then a + * different context needs to be be used. + * + * @param options [in] Any particular options. At present the options + * supported are: + * - SSL_SERVER_VERIFY_LATER (client only): Don't stop a handshake if the + * server authentication fails. The certificate can be authenticated later + * with a call to verifyCert(). + * - SSL_CLIENT_AUTHENTICATION (server only): Enforce client authentication + * i.e. each handshake will include a "certificate request" message from + * the server. + * - SSL_DISPLAY_BYTES (full mode build only): Display the byte sequences + * during the handshake. + * - SSL_DISPLAY_STATES (full mode build only): Display the state changes + * during the handshake. + * - SSL_DISPLAY_CERTS (full mode build only): Display the certificates that + * are passed during a handshake. + * - SSL_DISPLAY_RSA (full mode build only): Display the RSA key details + * that are passed during a handshake. + * + * @param num_sessions [in] The number of sessions to be used for session + * caching. If this value is 0, then there is no session caching. + * + * If this option is null, then the default internal private key/ + * certificate pair is used (if CONFIG_SSL_USE_DEFAULT_KEY is set). + * + * The resources used by this object are automatically freed. + * @return A client/server context. + */ + protected SSLCTX(int options, int num_sessions) + { + m_ctx = axtlsj.ssl_ctx_new(options, num_sessions); + } + + /** + * @brief Remove a client/server context. + * + * Frees any used resources used by this context. Each connection will be + * sent a "Close Notify" alert (if possible). + */ + public void dispose() + { + axtlsj.ssl_ctx_free(m_ctx); + } + + /** + * @brief Read the SSL data stream. + * @param ssl [in] An SSL object reference. + * @param rh [out] After a successful read, the decrypted data can be + * retrieved with rh.getData(). It will be null otherwise. + * @return The number of decrypted bytes: + * - if > 0, then the handshaking is complete and we are returning the + * number of decrypted bytes. + * - SSL_OK if the handshaking stage is successful (but not yet complete). + * - < 0 if an error. + * @see ssl.h for the error code list. + * @note Use rh before doing any successive ssl calls. + */ + public int read(SSL ssl, SSLReadHolder rh) + { + return axtlsj.ssl_read(ssl.m_ssl, rh); + } + + /** + * @brief Write to the SSL data stream. + * @param ssl [in] An SSL obect reference. + * @param out_data [in] The data to be written + * @return The number of bytes sent, or if < 0 if an error. + * @see ssl.h for the error code list. + */ + public int write(SSL ssl, byte[] out_data) + { + return axtlsj.ssl_write(ssl.m_ssl, out_data, out_data.length); + } + + /** + * @brief Write to the SSL data stream. + * @param ssl [in] An SSL obect reference. + * @param out_data [in] The data to be written + * @param out_len [in] The number of bytes to be written + * @return The number of bytes sent, or if < 0 if an error. + * @see ssl.h for the error code list. + */ + public int write(SSL ssl, byte[] out_data, int out_len) + { + return axtlsj.ssl_write(ssl.m_ssl, out_data, out_len); + } + + /** + * @brief Find an ssl object based on a Socket reference. + * + * Goes through the list of SSL objects maintained in a client/server + * context to look for a socket match. + * @param s [in] A reference to a Socket object. + * @return A reference to the SSL object. Returns null if the object + * could not be found. + */ + public SSL find(Socket s) + { + int client_fd = axtlsj.getFd(s); + return new SSL(axtlsj.ssl_find(m_ctx, client_fd)); + } + + /** + * @brief Authenticate a received certificate. + * + * This call is usually made by a client after a handshake is complete + * and the context is in SSL_SERVER_VERIFY_LATER mode. + * @param ssl [in] An SSL object reference. + * @return SSL_OK if the certificate is verified. + */ + public int verifyCert(SSL ssl) + { + return axtlsj.ssl_verify_cert(ssl.m_ssl); + } + + /** + * @brief Force the client to perform its handshake again. + * + * For a client this involves sending another "client hello" message. + * For the server is means sending a "hello request" message. + * + * This is a blocking call on the client (until the handshake completes). + * @param ssl [in] An SSL object reference. + * @return SSL_OK if renegotiation instantiation was ok + */ + public int renegotiate(SSL ssl) + { + return axtlsj.ssl_renegotiate(ssl.m_ssl); + } + + /** + * @brief Load a file into memory that is in binary DER or ASCII PEM format. + * + * These are temporary objects that are used to load private keys, + * certificates etc into memory. + * @param obj_type [in] The format of the file. Can be one of: + * - SSL_OBJ_X509_CERT (no password required) + * - SSL_OBJ_X509_CACERT (no password required) + * - SSL_OBJ_RSA_KEY (AES128/AES256 PEM encryption supported) + * - SSL_OBJ_P8 (RC4-128 encrypted data supported) + * - SSL_OBJ_P12 (RC4-128 encrypted data supported) + * + * PEM files are automatically detected (if supported). + * @param filename [in] The location of a file in DER/PEM format. + * @param password [in] The password used. Can be null if not required. + * @return SSL_OK if all ok + */ + public int objLoad(int obj_type, String filename, String password) + { + return axtlsj.ssl_obj_load(m_ctx, obj_type, filename, password); + } + + /** + * @brief Transfer binary data into the object loader. + * + * These are temporary objects that are used to load private keys, + * certificates etc into memory. + * @param obj_type [in] The format of the memory data. + * @param data [in] The binary data to be loaded. + * @param len [in] The amount of data to be loaded. + * @param password [in] The password used. Can be null if not required. + * @return SSL_OK if all ok + */ + + public int objLoad(int obj_type, byte[] data, int len, String password) + { + return axtlsj.ssl_obj_memory_load(m_ctx, obj_type, data, len, password); + } +} diff --git a/user/mpy/lib/axtls/bindings/java/SSLClient.java b/user/mpy/lib/axtls/bindings/java/SSLClient.java new file mode 100644 index 0000000..f65fe9c --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/SSLClient.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A wrapper around the unmanaged interface to give a semi-decent Java API + */ + +package axTLSj; + +import java.net.*; + +/** + * @class SSLClient + * @ingroup java_api + * @brief The client context. + * + * All client connections are started within a client context. + */ +public class SSLClient extends SSLCTX +{ + /** + * @brief Start a new client context. + * + * @see SSLCTX for details. + */ + public SSLClient(int options, int num_sessions) + { + super(options, num_sessions); + } + + /** + * @brief Establish a new SSL connection to an SSL server. + * + * It is up to the application to establish the initial socket connection. + * + * This is a blocking call - it will finish when the handshake is + * complete (or has failed). + * + * Call dispose() when the connection is to be removed. + * @param s [in] A reference to a Socket object. + * @param session_id [in] A 32 byte session id for session resumption. This + * can be null if no session resumption is not required. + * @return An SSL object reference. Use SSL.handshakeStatus() to check + * if a handshake succeeded. + */ + public SSL connect(Socket s, byte[] session_id) + { + int client_fd = axtlsj.getFd(s); + byte sess_id_size = (byte)(session_id != null ? + session_id.length : 0); + return new SSL(axtlsj.ssl_client_new(m_ctx, client_fd, session_id, + sess_id_size)); + } +} diff --git a/user/mpy/lib/axtls/bindings/java/SSLReadHolder.java b/user/mpy/lib/axtls/bindings/java/SSLReadHolder.java new file mode 100644 index 0000000..91fd76b --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/SSLReadHolder.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A wrapper around the unmanaged interface to give a semi-decent Java API + */ + +package axTLSj; + +/** + * @class SSLReadHolder + * @ingroup java_api + * @brief A holder for data read in an SSL read. + */ +public class SSLReadHolder +{ + /** + * @brief Contruct a new read holder object. + */ + public SSLReadHolder() + { + m_buf = null; + } + + /** + * @brief Retrieve the reference to the read data. + */ + public byte[] getData() + { + return m_buf; + } + + private byte[] m_buf; +} diff --git a/user/mpy/lib/axtls/bindings/java/SSLServer.java b/user/mpy/lib/axtls/bindings/java/SSLServer.java new file mode 100644 index 0000000..514ccb0 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/SSLServer.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A wrapper around the unmanaged interface to give a semi-decent Java API + */ + +package axTLSj; + +import java.net.*; + +/** + * @class SSLServer + * @ingroup java_api + * @brief The server context. + * + * All server connections are started within a server context. + */ +public class SSLServer extends SSLCTX +{ + /** + * @brief Start a new server context. + * + * @see SSLCTX for details. + */ + public SSLServer(int options, int num_sessions) + { + super(options, num_sessions); + } + + /** + * @brief Establish a new SSL connection to an SSL client. + * + * It is up to the application to establish the initial socket connection. + * + * Call dispose() when the connection is to be removed. + * @param s [in] A reference to a Socket object. + * @return An SSL object reference. + */ + public SSL connect(Socket s) + { + int client_fd = axtlsj.getFd(s); + return new SSL(axtlsj.ssl_server_new(m_ctx, client_fd)); + } +} diff --git a/user/mpy/lib/axtls/bindings/java/SSLUtil.java b/user/mpy/lib/axtls/bindings/java/SSLUtil.java new file mode 100644 index 0000000..3d53de5 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/java/SSLUtil.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A wrapper around the unmanaged interface to give a semi-decent Java API + */ + +package axTLSj; + +import java.io.*; +import java.util.*; + +/** + * @class SSLUtil + * @ingroup java_api + * @brief Some global helper functions. + * + */ +public class SSLUtil +{ + /** + * @brief Load up the ddl/shared library + */ + static + { + System.loadLibrary("axtlsj"); + } + + /** + * @brief Return the build mode of the axTLS project. + * @return The build mode is one of: + * - SSL_BUILD_SERVER_ONLY + * - SSL_BUILD_ENABLE_VERIFICATION + * - SSL_BUILD_ENABLE_CLIENT + * - SSL_BUILD_FULL_MODE + */ + public static int buildMode() + { + return axtlsj.ssl_get_config(axtlsj.SSL_BUILD_MODE); + } + + /** + * @brief Return the number of chained certificates that the client/server + * supports. + * @return The number of supported client/server certificates. + */ + public static int maxCerts() + { + return axtlsj.ssl_get_config(axtlsj.SSL_MAX_CERT_CFG_OFFSET); + } + + /** + * @brief Return the number of CA certificates that the client/server + * supports. + * @return The number of supported CA certificates. + */ + public static int maxCACerts() + { + return axtlsj.ssl_get_config(axtlsj.SSL_MAX_CA_CERT_CFG_OFFSET); + } + + /** + * @brief Indicate if PEM is supported. + * @return true if PEM supported. + */ + public static boolean hasPEM() + { + return axtlsj.ssl_get_config(axtlsj.SSL_HAS_PEM) > 0 ? true : false; + } + + /** + * @brief Display the text string of the error. + * @param error_code [in] The integer error code. + * @see ssl.h for the error code list. + */ + public static void displayError(int error_code) + { + axtlsj.ssl_display_error(error_code); + } + + /** + * @brief Return the version of the axTLS project. + */ + public static String version() + { + return axtlsj.ssl_version(); + } +} + diff --git a/user/mpy/lib/axtls/bindings/lua/Makefile b/user/mpy/lib/axtls/bindings/lua/Makefile new file mode 100644 index 0000000..daacf92 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/lua/Makefile @@ -0,0 +1,67 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +AXTLS_HOME=../.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +all: lib + + +ifdef CONFIG_PLATFORM_WIN32 +TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsl.dll +else +TARGET=$(CONFIG_LUA_CORE)/lib/lua/5.1/axtlsl.so +endif + +ifneq ($(MAKECMDGOALS), clean) + +lib: $(TARGET) +OBJ:=axTLSl_wrap.o +include $(AXTLS_HOME)/config/makefile.post + +# there are a few static functions that aren't used +CFLAGS += -funit-at-a-time + +$(TARGET) : $(OBJ) + $(LD) $(LDFLAGS) $(LDSHARED) -o $@ $^ -L$(AXTLS_HOME)/$(STAGE) -L$(CONFIG_LUA_CORE)/lib -laxtls -llua + +CFLAGS += -I $(CONFIG_LUA_CORE)/include +else +CFLAGS += /I"`cygpath -w $(CONFIG_LUA_CORE)/include`" +LDFLAGS += axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)" + +$(TARGET) : $(OBJ) + $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ) +endif # WIN32 + +clean:: + @rm -f $(TARGET) *.i axTLSl* .depend diff --git a/user/mpy/lib/axtls/bindings/perl/Makefile b/user/mpy/lib/axtls/bindings/perl/Makefile new file mode 100644 index 0000000..92fd3c5 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/perl/Makefile @@ -0,0 +1,91 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +AXTLS_HOME=../.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +all: lib + +ifdef CONFIG_PLATFORM_WIN32 +TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsp.dll +else +TARGET=$(AXTLS_HOME)/$(STAGE)/libaxtlsp.so +endif + +ifneq ($(MAKECMDGOALS), clean) + +ifdef CONFIG_PLATFORM_WIN32 +PERL5_CORE:=$(shell cygpath -w "$(CONFIG_PERL_CORE)") +else +PERL5_CORE= $(shell perl -e 'use Config; print $$Config{archlib};')/CORE +endif + +all: test_perl + +test_perl: + @if ! [ -d "$(PERL5_CORE)" ]; then \ + echo "*** Error: Perl not installed at $(CONFIG_PERL_CORE) - go to " \ + "http://www.cpan.org/authors/id/G/GR/GRAHAMC/SiePerl-5.8.0-bin-1.0-Win32.INSTALL.exe" && exit 1; \ + fi + +endif + +lib: $(TARGET) +OBJ:=axTLSp_wrap.o +include $(AXTLS_HOME)/config/makefile.post + +ifndef CONFIG_PLATFORM_WIN32 # Linux/Unix/Cygwin + +# +# Could have used libperl.a, but it increases the library to over 1MB, so just +# use libperl.so. But this needs to be in the shared library path for things to +# work. +# +$(TARGET) : $(OBJ) + $(LD) $(LDFLAGS) -L$(AXTLS_HOME)/$(STAGE) -L$(PERL5_CORE) $(LDSHARED) -o $@ $(OBJ) -laxtls -lperl +ifdef CONFIG_PLATFORM_CYGWIN + cd $(AXTLS_HOME)/$(STAGE); ln -sf $(notdir $@) axtlsp.dll +endif + @install axtlsp.pm $(AXTLS_HOME)/$(STAGE) + +CFLAGS += -D_GNU_SOURCE -I$(PERL5_CORE) +else +CFLAGS += /I"$(PERL5_CORE)" +LDFLAGS += $(CONFIG_PERL_LIB) /libpath:"$(PERL5_CORE)" axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)" + +$(TARGET) : $(OBJ) + $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ) + install axtlsp.pm $(AXTLS_HOME)/$(STAGE) +endif # WIN32 + +clean:: + @rm -f $(TARGET) axtls* *.i axTLSp* *.c .depend $(AXTLS_HOME)/$(STAGE)/axtlsp.pm diff --git a/user/mpy/lib/axtls/bindings/vbnet/Makefile b/user/mpy/lib/axtls/bindings/vbnet/Makefile new file mode 100644 index 0000000..7da60d0 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/vbnet/Makefile @@ -0,0 +1,35 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf + +clean:: + @rm -f axssl* axInterface.vb diff --git a/user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb b/user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb new file mode 100644 index 0000000..9388273 --- /dev/null +++ b/user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb @@ -0,0 +1,200 @@ +' +' Copyright (c) 2007, Cameron Rich +' +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without +' modification, are permitted provided that the following conditions are met: +' +' * Redistributions of source code must retain the above copyright notice, +' this list of conditions and the following disclaimer. +' * Redistributions in binary form must reproduce the above copyright +' notice, this list of conditions and the following disclaimer in the +' documentation and/or other materials provided with the distribution. +' * Neither the name of the axTLS project nor the names of its +' contributors may be used to endorse or promote products derived +' from this software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +' CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +' TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +' OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +' NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +' THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +' + +' +' A wrapper around the unmanaged Integererface to give a semi-decent VB.NET API +' + +Imports System +Imports System.Runtime.InteropServices +Imports System.Net.Sockets +Imports axTLSvb + +Namespace axTLSvb + Public Class SSL + Public m_ssl As IntPtr + + Public Sub New(ByRef ip As IntPtr) + m_ssl = ip + End Sub + + Public Sub Dispose() + axtls.ssl_free(m_ssl) + End Sub + + Public Function HandshakeStatus() As Integer + Return axtls.ssl_handshake_status(m_ssl) + End Function + + Public Function GetCipherId() As Byte + Return axtls.ssl_get_cipher_id(m_ssl) + End Function + + Public Function GetSessionId() As Byte() + Dim ptr As IntPtr = axtls.ssl_get_session_id(m_ssl) + Dim sess_id_size As Integer = axtls.ssl_get_session_id_size(m_ssl) + Dim result(sess_id_size-1) As Byte + Marshal.Copy(ptr, result, 0, sess_id_size) + Return result + End Function + + Public Function GetCertificateDN(component As Integer) As String + Return axtls.ssl_get_cert_dn(m_ssl, component) + End Function + End Class + + Public Class SSLUtil + Private dummy As Integer ' need something here + + Public Shared Function BuildMode() As Integer + Return axtls.ssl_get_config(axtls.SSL_BUILD_MODE) + End Function + + Public Shared Function MaxCerts() As Integer + Return axtls.ssl_get_config(axtls.SSL_MAX_CERT_CFG_OFFSET) + End Function + + Public Shared Function MaxCACerts() As Integer + Return axtls.ssl_get_config(axtls.SSL_MAX_CA_CERT_CFG_OFFSET) + End Function + + Public Shared Function HasPEM() As Boolean + If axtls.ssl_get_config(axtls.SSL_HAS_PEM) > 0 Then + Return True + Else + Return False + End If + End Function + + Public Shared Sub DisplayError(ByVal error_code As Integer) + axtls.ssl_display_error(error_code) + End Sub + + Public Shared Function Version() As String + Return axtls.ssl_version() + End Function + End Class + + Public Class SSLCTX + Protected m_ctx As IntPtr + + Protected Sub New(ByVal options As Integer, _ + ByVal num_sessions As Integer) + m_ctx = axtls.ssl_ctx_new(options, num_sessions) + End Sub + + Public Sub Dispose() + axtls.ssl_ctx_free(m_ctx) + End Sub + + Public Function Read(ByVal ssl As SSL, ByRef in_data As Byte()) As Integer + Dim ptr As IntPtr = IntPtr.Zero + Dim ret as Integer = axtls.ssl_read(ssl.m_ssl, ptr) + + If ret > axtls.SSL_OK Then + ReDim in_data(ret) + Marshal.Copy(ptr, in_data, 0, ret) + Else + in_data = Nothing + End If + + Return ret + End Function + + Public Function Write(ByVal ssl As SSL, _ + ByVal data As Byte(), len As Integer) As Integer + Return axtls.ssl_write(ssl.m_ssl, data, len) + End Function + + Public Function Find(ByVal s As Socket) As SSL + Dim client_fd As Integer = s.Handle.ToInt32() + Return New SSL(axtls.ssl_find(m_ctx, client_fd)) + End Function + + Public Function VerifyCert(ByVal ssl As SSL) As Integer + Return axtls.ssl_verify_cert(ssl.m_ssl) + End Function + + Public Function Renegotiate(ByVal ssl As SSL) As Integer + Return axtls.ssl_renegotiate(ssl.m_ssl) + End Function + + Public Function ObjLoad(ByVal obj_type As Integer, _ + ByVal filename As String, _ + password As String) As Integer + Return axtls.ssl_obj_load(m_ctx, obj_type, filename, password) + End Function + + Public Function ObjLoad(ByVal obj_type As Integer, _ + ByVal data As Byte(), ByVal len As Integer, _ + password As String) As Integer + Return axtls.ssl_obj_memory_load( _ + m_ctx, obj_type, data, len, password) + End Function + End Class + + Public Class SSLServer + Inherits SSLCTX + + Public Sub New(ByVal options As Integer, _ + ByVal num_sessions As Integer) + MyBase.New(options, num_sessions) + End Sub + + Public Function Connect(ByVal s As Socket) As SSL + Dim client_fd As Integer = s.Handle.ToInt32() + Return New SSL(axtls.ssl_server_new(m_ctx, client_fd)) + End Function + End Class + + Public Class SSLClient + Inherits SSLCTX + + Public Sub New(ByVal options As Integer, _ + ByVal num_sessions As Integer) + MyBase.New(options, num_sessions) + End Sub + + Public Function Connect(ByVal s As Socket, _ + ByVal session_id As Byte()) As SSL + Dim client_fd As Integer = s.Handle.ToInt32() + Dim sess_id_size As Byte + If session_id is Nothing Then + sess_id_size = 0 + Else + sess_id_size = session_id.Length + End If + + Return New SSL(axtls.ssl_client_new(m_ctx, client_fd, session_id, _ + sess_id_size)) + End Function + + End Class +End Namespace diff --git a/user/mpy/lib/axtls/config/Config.in b/user/mpy/lib/axtls/config/Config.in new file mode 100644 index 0000000..c42bcef --- /dev/null +++ b/user/mpy/lib/axtls/config/Config.in @@ -0,0 +1,130 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/config/Kconfig-language.txt +# + +mainmenu "axTLS Configuration" + +config HAVE_DOT_CONFIG + bool + default y + +choice + prompt "Platform" + default CONFIG_PLATFORM_LINUX + +config CONFIG_PLATFORM_LINUX + bool "Linux" + +config CONFIG_PLATFORM_CYGWIN + bool "Cygwin" + +config CONFIG_PLATFORM_WIN32 + bool "Win32" + +endchoice + +menu "General Configuration" + +config PREFIX + string "axTLS installation prefix" + depends on !CONFIG_PLATFORM_WIN32 + default "/usr/local" + help + Define your directory to install axTLS files/subdirs in. + +config CONFIG_DEBUG + bool "Build axTLS with Debugging symbols" + default n + help + Say Y here if you wish to compile axTLS with debugging symbols. + This will allow you to use a debugger to examine axTLS internals. + This increases the size of the binary considerably and should only be + used when doing development. + If you are doing development and want to debug axTLS, answer Y. + + Most people should answer N. + +config CONFIG_STRIP_UNWANTED_SECTIONS + depends on !CONFIG_PLATFORM_WIN32 && !CONFIG_DEBUG + bool "Strip unwanted sections from elf binaries" + default y + help + Strip unwanted sections from the resulting binaries + +menu "Microsoft Compiler Options" +depends on CONFIG_PLATFORM_WIN32 + +choice + prompt "Compiler" + depends on CONFIG_PLATFORM_WIN32 + default CONFIG_VISUAL_STUDIO_10_0 + +config CONFIG_VISUAL_STUDIO_7_0 + bool "Visual Studio 7.0 (2003)" + help + Use Microsoft's Visual Studio 2003 platform. + +config CONFIG_VISUAL_STUDIO_8_0 + bool "Visual Studio 8.0 (2005)" + help + Use Microsoft's Visual Studio 2005 platform. + +config CONFIG_VISUAL_STUDIO_10_0 + bool "Visual Studio 10.0 (2010)" + help + Use Microsoft's Visual Studio 2010 platform. +endchoice + +config CONFIG_VISUAL_STUDIO_7_0_BASE + string "Base" + depends on CONFIG_VISUAL_STUDIO_7_0 + default "c:\\Program Files\\Microsoft Visual Studio .NET 2003" + +config CONFIG_VISUAL_STUDIO_8_0_BASE + string "Base" + depends on CONFIG_VISUAL_STUDIO_8_0 + default "c:\\Program Files\\Microsoft Visual Studio 8" + +config CONFIG_VISUAL_STUDIO_10_0_BASE + string "Base" + depends on CONFIG_VISUAL_STUDIO_10_0 + default "c:\\Program Files\\Microsoft Visual Studio 10.0" +endmenu + +config CONFIG_EXTRA_CFLAGS_OPTIONS + string "Any extra CFLAGS options for the compiler?" + help + Do you want to pass any extra CFLAGS options to the compiler as + you build axTLS? If so, this is the option for you... For + example, if you want to add some simple compiler switches (like + -march=i686), or check for warnings using -Werror, just those + options here. + +config CONFIG_EXTRA_LDFLAGS_OPTIONS + string "Any extra LDFLAGS options for the compiler?" + help + Do you want to pass any extra LDFLAGS options to the compiler? + +endmenu + +source ssl/Config.in +config CONFIG_AXTLSWRAP + depends on !CONFIG_PLATFORM_WIN32 + bool "Enable axtlswrap" + default n + help + axtlswrap is similar to sslwrap - http://www.rickk.com/sslwrap. + It enables SSL for processes that don't have native SSL support. + +config CONFIG_AXHTTPD + bool "Enable HTTP/HTTPS Web Server" + default y + help + Build the AXHTTPD web server + +source httpd/Config.in +source bindings/Config.in +source samples/Config.in +source ssl/BigIntConfig.in + diff --git a/user/mpy/lib/axtls/config/JMeter.jmx b/user/mpy/lib/axtls/config/JMeter.jmx new file mode 100755 index 0000000..f62c03f --- /dev/null +++ b/user/mpy/lib/axtls/config/JMeter.jmx @@ -0,0 +1,247 @@ + + + + + + + + true + false + + + + + 1152004173000 + + + 16 + false + + 10 + false + + 1152004173000 + stopthread + 0 + + + + /index.html + GET + true + + true + 80 + + + + + + false + 127.0.0.1 + + false + + + + + 1152004173000 + + + 16 + false + + 10 + false + + 1152004173000 + stopthread + 0 + + + + /index.html + GET + true + HTTPS + true + 443 + + + + + + false + 127.0.0.1 + + false + + + + + 1152004173000 + + + 16 + false + + 10 + false + + 1152004173000 + stopthread + 0 + + + + /index.html + GET + true + HTTPS + true + 2443 + + + + + + false + 127.0.0.1 + + false + + + + + 1152004173000 + + + 16 + false + + 10 + false + + 1152004173000 + stopthread + 0 + + + + /index.html + GET + true + HTTPS + true + 3443 + + + + + + false + 127.0.0.1 + + false + + + + + 1152004173000 + + + 16 + false + + 10 + false + + 1152004173000 + stopthread + 0 + + + + /index.html + GET + true + HTTPS + true + 1443 + + + + + + false + 127.0.0.1 + + false + + + + + + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + + saveConfig + + + false + + + + + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + + saveConfig + + + false + + + + + diff --git a/user/mpy/lib/axtls/config/Rules.mak b/user/mpy/lib/axtls/config/Rules.mak new file mode 100644 index 0000000..7b6f2b3 --- /dev/null +++ b/user/mpy/lib/axtls/config/Rules.mak @@ -0,0 +1,221 @@ +# Rules.make for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under GPLv2, see the file LICENSE in this tarball for details. +# + +# Pull in the user's busybox configuration +ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) +-include $(top_builddir)/.config +endif + +#-------------------------------------------------------- +PROG := busybox +MAJOR_VERSION :=1 +MINOR_VERSION :=1 +SUBLEVEL_VERSION:=0 +EXTRAVERSION := +VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION) +BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") + + +#-------------------------------------------------------- +# With a modern GNU make(1) (highly recommended, that's what all the +# developers use), all of the following configuration values can be +# overridden at the command line. For example: +# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app +#-------------------------------------------------------- + +# If you are running a cross compiler, you will want to set 'CROSS' +# to something more interesting... Target architecture is determined +# by asking the CC compiler what arch it compiles things for, so unless +# your compiler is broken, you should not need to specify TARGET_ARCH +CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) +CC = $(CROSS)gcc +AR = $(CROSS)ar +AS = $(CROSS)as +LD = $(CROSS)ld +NM = $(CROSS)nm +STRIP = $(CROSS)strip +CPP = $(CC) -E +# MAKEFILES = $(top_builddir)/.config +RM = rm +RM_F = $(RM) -f +LN = ln +LN_S = $(LN) -s +MKDIR = mkdir +MKDIR_P = $(MKDIR) -p +MV = mv +CP = cp + + +# What OS are you compiling busybox for? This allows you to include +# OS specific things, syscall overrides, etc. +TARGET_OS=linux + +# Select the compiler needed to build binaries for your development system +HOSTCC = gcc +HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer + +# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. +LC_ALL:= C + +# If you want to add some simple compiler switches (like -march=i686), +# especially from the command line, use this instead of CFLAGS directly. +# For optimization overrides, it's better still to set OPTIMIZATION. +CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS))) + +# To compile vs some other alternative libc, you may need to use/adjust +# the following lines to meet your needs... +# +# If you are using Red Hat 6.x with the compatible RPMs (for developing under +# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about +# using the compatible RPMs (compat-*) at http://www.redhat.com ! +#LIBCDIR:=/usr/i386-glibc20-linux +# +# For other libraries, you are on your own. But these may (or may not) help... +#LDFLAGS+=-nostdlib +#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc +#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char +#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") + +WARNINGS=-Wall -Wstrict-prototypes -Wshadow +CFLAGS=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) +ARFLAGS=cru + + +# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest +# get the CC MAJOR/MINOR version +CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) +CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1)) + +#-------------------------------------------------------- +export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP +ifeq ($(strip $(TARGET_ARCH)),) +TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ + -e 's/i.86/i386/' \ + -e 's/sparc.*/sparc/' \ + -e 's/arm.*/arm/g' \ + -e 's/m68k.*/m68k/' \ + -e 's/ppc/powerpc/g' \ + -e 's/v850.*/v850/g' \ + -e 's/sh[234]/sh/' \ + -e 's/mips-.*/mips/' \ + -e 's/mipsel-.*/mipsel/' \ + -e 's/cris.*/cris/' \ + ) +endif + +# A nifty macro to make testing gcc features easier +check_gcc=$(shell \ + if [ "$(1)" != "" ]; then \ + if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi \ + fi) + +# Setup some shortcuts so that silent mode is silent like it should be +ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS)) +export MAKE_IS_SILENT=n +SECHO=@echo +else +export MAKE_IS_SILENT=y +SECHO=-@false +endif + +CFLAGS+=$(call check_gcc,-funsigned-char,) + +#-------------------------------------------------------- +# Arch specific compiler optimization stuff should go here. +# Unless you want to override the defaults, do not set anything +# for OPTIMIZATION... + +# use '-Os' optimization if available, else use -O2 +OPTIMIZATION:=$(call check_gcc,-Os,-O2) + +# Some nice architecture specific optimizations +ifeq ($(strip $(TARGET_ARCH)),arm) + OPTIMIZATION+=-fstrict-aliasing +endif +ifeq ($(strip $(TARGET_ARCH)),i386) + OPTIMIZATION+=$(call check_gcc,-march=i386,) + OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,) + OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\ + -malign-functions=0 -malign-jumps=0 -malign-loops=0) +endif +OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer + +# +#-------------------------------------------------------- +# If you're going to do a lot of builds with a non-vanilla configuration, +# it makes sense to adjust parameters above, so you can type "make" +# by itself, instead of following it by the same half-dozen overrides +# every time. The stuff below, on the other hand, is probably less +# prone to casual user adjustment. +# + +ifeq ($(strip $(CONFIG_LFS)),y) + # For large file summit support + CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +endif +ifeq ($(strip $(CONFIG_DMALLOC)),y) + # For testing mem leaks with dmalloc + CFLAGS+=-DDMALLOC + LIBRARIES:=-ldmalloc +else + ifeq ($(strip $(CONFIG_EFENCE)),y) + LIBRARIES:=-lefence + endif +endif +ifeq ($(strip $(CONFIG_DEBUG)),y) + CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE + LDFLAGS +=-Wl,-warn-common + STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging +else + CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG + LDFLAGS += -Wl,-warn-common + STRIPCMD:=echo + #$(STRIP) -s --remove-section=.note --remove-section=.comment +endif +ifeq ($(strip $(CONFIG_STATIC)),y) + LDFLAGS += --static +endif + +ifeq ($(strip $(CONFIG_SELINUX)),y) + LIBRARIES += -lselinux +endif + +ifeq ($(strip $(PREFIX)),) + PREFIX:=`pwd`/_install +endif + +# Additional complications due to support for pristine source dir. +# Include files in the build directory should take precedence over +# the copy in top_srcdir, both during the compilation phase and the +# shell script that finds the list of object files. +# Work in progress by . + + +OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o +CFLAGS += $(CROSS_CFLAGS) +ifdef BB_INIT_SCRIPT + CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' +endif + +# Put user-supplied flags at the end, where they +# have a chance of winning. +CFLAGS += $(CFLAGS_EXTRA) + +#------------------------------------------------------------ +# Installation options +ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y) +INSTALL_OPTS=--hardlinks +endif +ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y) +INSTALL_OPTS=--symlinks +endif +ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y) +INSTALL_OPTS= +endif + +.PHONY: dummy diff --git a/user/mpy/lib/axtls/config/axhttpd.aip b/user/mpy/lib/axtls/config/axhttpd.aip new file mode 100755 index 0000000..412fe3b --- /dev/null +++ b/user/mpy/lib/axtls/config/axhttpd.aip @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/user/mpy/lib/axtls/config/axtls.RES b/user/mpy/lib/axtls/config/axtls.RES new file mode 100644 index 0000000000000000000000000000000000000000..2929b3b679fddfb78bb58ebbccc5c0c4a9eb37d8 GIT binary patch literal 22748 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 /dev/null 2>&1; then \ + echo "Mono not installed! - go " \ + "to http://www.mono-project.com/Main_Page" && exit 1; \ + fi + +endif # Linux + +endif # not 'clean' diff --git a/user/mpy/lib/axtls/config/makefile.java.conf b/user/mpy/lib/axtls/config/makefile.java.conf new file mode 100644 index 0000000..9b22462 --- /dev/null +++ b/user/mpy/lib/axtls/config/makefile.java.conf @@ -0,0 +1,58 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +ifneq ($(MAKECMDGOALS), clean) + +ifdef CONFIG_PLATFORM_CYGWIN +CFLAGS += -I"$(CONFIG_JAVA_HOME)/include" +CFLAGS += -I"$(CONFIG_JAVA_HOME)/include/win32" +JAVA_BIN:=$(CONFIG_JAVA_HOME)/bin +else + +ifdef CONFIG_PLATFORM_WIN32 +CFLAGS += /I"$(shell cygpath -w $(CONFIG_JAVA_HOME)/include)" +CFLAGS += /I"$(shell cygpath -w $(CONFIG_JAVA_HOME)/include/win32)" +JAVA_BIN:=$(shell cygpath -u $(CONFIG_JAVA_HOME)/bin) +else # Linux +CFLAGS += -I$(CONFIG_JAVA_HOME)/include + +ifdef CONFIG_PLATFORM_SOLARIS +CFLAGS += -I$(CONFIG_JAVA_HOME)/include/solaris +else +CFLAGS += -I$(CONFIG_JAVA_HOME)/include/linux +endif + +JAVA_BIN:=$(CONFIG_JAVA_HOME)/bin +endif +endif + +PATH:=$(JAVA_BIN):$(PATH) + +endif # not 'clean' diff --git a/user/mpy/lib/axtls/config/makefile.post b/user/mpy/lib/axtls/config/makefile.post new file mode 100644 index 0000000..033981c --- /dev/null +++ b/user/mpy/lib/axtls/config/makefile.post @@ -0,0 +1,19 @@ + +ifneq ($(MAKECMDGOALS), clean) +ifndef CONFIG_PLATFORM_WIN32 +ifndef CONFIG_PLATFORM_SOLARIS +# do dependencies +-include .depend +all : .depend +.depend: $(wildcard *.c) + @$(CC) $(CFLAGS) -MM $^ > $@ +endif # 'not' solaris +endif # 'not' win32 + +ifdef CONFIG_PLATFORM_WIN32 +OBJ:=$(OBJ:.o=.obj) +%.obj : %.c + $(CC) $(CFLAGS) $< +endif # win32 + +endif # end of 'not' clean diff --git a/user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt b/user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt new file mode 100644 index 0000000..493749b --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt @@ -0,0 +1,255 @@ +Introduction +------------ + +The configuration database is collection of configuration options +organized in a tree structure: + + +- Code maturity level options + | +- Prompt for development and/or incomplete code/drivers + +- General setup + | +- Networking support + | +- System V IPC + | +- BSD Process Accounting + | +- Sysctl support + +- Loadable module support + | +- Enable loadable module support + | +- Set version information on all module symbols + | +- Kernel module loader + +- ... + +Every entry has its own dependencies. These dependencies are used +to determine the visible of an entry. Any child entry is only +visible if its parent entry is also visible. + +Menu entries +------------ + +Most entries define a config option, all other entries help to organize +them. A single configuration option is defined like this: + +config MODVERSIONS + bool "Set version information on all module symbols" + depends MODULES + help + Usually, modules have to be recompiled whenever you switch to a new + kernel. ... + +Every line starts with a key word and can be followed by multiple +arguments. "config" starts a new config entry. The following lines +define attributes for this config option. Attributes can be the type of +the config option, input prompt, dependencies, help text and default +values. A config option can be defined multiple times with the same +name, but every definition can have only a single input prompt and the +type must not conflict. + +Menu attributes +--------------- + +A menu entry can have a number of attributes. Not all of them are +applicable everywhere (see syntax). + +- type definition: "bool"/"tristate"/"string"/"hex"/"integer" + Every config option must have a type. There are only two basic types: + tristate and string, the other types base on these two. The type + definition optionally accepts an input prompt, so these two examples + are equivalent: + + bool "Networking support" + and + bool + prompt "Networking support" + +- input prompt: "prompt" ["if" ] + Every menu entry can have at most one prompt, which is used to display + to the user. Optionally dependencies only for this prompt can be added + with "if". + +- default value: "default" ["if" ] + A config option can have any number of default values. If multiple + default values are visible, only the first defined one is active. + Default values are not limited to the menu entry, where they are + defined, this means the default can be defined somewhere else or be + overriden by an earlier definition. + The default value is only assigned to the config symbol if no other + value was set by the user (via the input prompt above). If an input + prompt is visible the default value is presented to the user and can + be overridden by him. + Optionally dependencies only for this default value can be added with + "if". + +- dependencies: "depends on"/"requires" + This defines a dependency for this menu entry. If multiple + dependencies are defined they are connected with '&&'. Dependencies + are applied to all other options within this menu entry (which also + accept "if" expression), so these two examples are equivalent: + + bool "foo" if BAR + default y if BAR + and + depends on BAR + bool "foo" + default y + +- help text: "help" + This defines a help text. The end of the help text is determined by + the level indentation, this means it ends at the first line which has + a smaller indentation than the first line of the help text. + + +Menu dependencies +----------------- + +Dependencies define the visibility of a menu entry and can also reduce +the input range of tristate symbols. The tristate logic used in the +expressions uses one more state than normal boolean logic to express the +module state. Dependency expressions have the following syntax: + + ::= (1) + '=' (2) + '!=' (3) + '(' ')' (4) + '!' (5) + '||' (6) + '&&' (7) + +Expressions are listed in decreasing order of precedence. + +(1) Convert the symbol into an expression. Boolean and tristate symbols + are simply converted into the respective expression values. All + other symbol types result in 'n'. +(2) If the values of both symbols are equal, it returns 'y', + otherwise 'n'. +(3) If the values of both symbols are equal, it returns 'n', + otherwise 'y'. +(4) Returns the value of the expression. Used to override precedence. +(5) Returns the result of (2-/expr/). +(6) Returns the result of min(/expr/, /expr/). +(7) Returns the result of max(/expr/, /expr/). + +An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 +respectively for calculations). A menu entry becomes visible when it's +expression evaluates to 'm' or 'y'. + +There are two type of symbols: constant and nonconstant symbols. +Nonconstant symbols are the most common ones and are defined with the +'config' statement. Nonconstant symbols consist entirely of alphanumeric +characters or underscores. +Constant symbols are only part of expressions. Constant symbols are +always surrounded by single or double quotes. Within the quote any +other character is allowed and the quotes can be escaped using '\'. + +Menu structure +-------------- + +The position of a menu entry in the tree is determined in two ways. First +it can be specified explicitely: + +menu "Network device support" + depends NET + +config NETDEVICES + ... + +endmenu + +All entries within the "menu" ... "endmenu" block become a submenu of +"Network device support". All subentries inherit the dependencies from +the menu entry, e.g. this means the dependency "NET" is added to the +dependency list of the config option NETDEVICES. + +The other way to generate the menu structure is done by analyzing the +dependencies. If a menu entry somehow depends on the previous entry, it +can be made a submenu of it. First the the previous (parent) symbol must +be part of the dependency list and then one of these two condititions +must be true: +- the child entry must become invisible, if the parent is set to 'n' +- the child entry must only be visible, if the parent is visible + +config MODULES + bool "Enable loadable module support" + +config MODVERSIONS + bool "Set version information on all module symbols" + depends MODULES + +comment "module support disabled" + depends !MODULES + +MODVERSIONS directly depends on MODULES, this means it's only visible if +MODULES is different from 'n'. The comment on the other hand is always +visible when MODULES it's visible (the (empty) dependency of MODULES is +also part of the comment dependencies). + + +Kconfig syntax +-------------- + +The configuration file describes a series of menu entries, where every +line starts with a keyword (except help texts). The following keywords +end a menu entry: +- config +- choice/endchoice +- comment +- menu/endmenu +- if/endif +- source +The first four also start the definition of a menu entry. + +config: + + "config" + + +This defines a config symbol and accepts any of above +attributes as options. + +choices: + + "choice" + + + "endchoice" + +This defines a choice group and accepts any of above attributes as +options. A choice can only be of type bool or tristate, while a boolean +choice only allows a single config entry to be selected, a tristate +choice also allows any number of config entries to be set to 'm'. This +can be used if multiple drivers for a single hardware exists and only a +single driver can be compiled/loaded into the kernel, but all drivers +can be compiled as modules. +A choice accepts another option "optional", which allows to set the +choice to 'n' and no entry needs to be selected. + +comment: + + "comment" + + +This defines a comment which is displayed to the user during the +configuration process and is also echoed to the output files. The only +possible options are dependencies. + +menu: + + "menu" + + + "endmenu" + +This defines a menu block, see "Menu structure" above for more +information. The only possible options are dependencies. + +if: + + "if" + + "endif" + +This defines an if block. The dependency expression is appended +to all enclosed menu entries. + +source: + + "source" + +This reads the specified configuration file. This file is always parsed. diff --git a/user/mpy/lib/axtls/config/scripts/config/Makefile b/user/mpy/lib/axtls/config/scripts/config/Makefile new file mode 100644 index 0000000..7399501 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/Makefile @@ -0,0 +1,121 @@ +# Makefile for axTLS +# +# Copyright (C) 2002 Erik Andersen + +top_srcdir=../.. +top_builddir=../.. +srcdir=$(top_srcdir)/scripts/config +include $(top_srcdir)/Rules.mak + +all: ncurses conf mconf + +ifeq ($(shell uname),SunOS) +LIBS = -lcurses +else +LIBS = -lncurses +endif +ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) + HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) + HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h)) + HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h)) + HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) + HOSTNCURSES += -DCURSES_LOC="" +else + HOSTNCURSES += -DCURSES_LOC="" +endif +endif +endif +endif +endif + +CONF_SRC = conf.c +MCONF_SRC = mconf.c +LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \ + lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \ + lxdialog/msgbox.c + +SHARED_SRC = zconf.tab.c +SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ + lkc_defs.h $(srcdir)/expr.h zconf.tab.h +CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC)) +MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC)) +SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC)) + +conf: $(CONF_OBJS) $(SHARED_OBJS) + $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ + +mconf: $(MCONF_OBJS) $(SHARED_OBJS) + $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS) + +$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@ + +$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS) + @[ -d $(@D) ] || mkdir -v $(@D) + $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@ + +lkc_defs.h: $(srcdir)/lkc_proto.h + @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' + +### +# The following requires flex/bison +# By default we use the _shipped versions, uncomment the +# following line if you are modifying the flex/bison src. +#LKC_GENPARSER := 1 + +ifdef LKC_GENPARSER + +%.tab.c %.tab.h: $(srcdir)/%.y + bison -t -d -v -b $* -p $(notdir $*) $< + +lex.%.c: $(srcdir)/%.l + flex -P$(notdir $*) -o$@ $< +else + +lex.zconf.o: lex.zconf.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) -I$(srcdir) -c $< -o $@ + +lex.zconf.c: $(srcdir)/lex.zconf.c_shipped + cp $< $@ + +zconf.tab.c: $(srcdir)/zconf.tab.c_shipped + cp $< $@ + +zconf.tab.h: $(srcdir)/zconf.tab.h_shipped + cp $< $@ +endif + +zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \ + $(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS) + $(HOSTCC) $(HOSTCFLAGS) -I$(srcdir) -I. -c $< -o $@ + +.PHONY: ncurses + +ncurses: + @echo "main() {}" > lxtemp.c + @if $(HOSTCC) lxtemp.c $(LIBS) ; then \ + rm -f lxtemp.c a.out; \ + else \ + rm -f lxtemp.c; \ + echo -e "\007" ;\ + echo ">> Unable to find the Ncurses libraries." ;\ + echo ">>" ;\ + echo ">> You must have Ncurses installed in order" ;\ + echo ">> to use 'make menuconfig'" ;\ + echo ;\ + exit 1 ;\ + fi + +clean: + rm -f *.o *~ ../../*~ core *.exe $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) + rm -f conf conf.exe mconf mconf.exe zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h + rm -f ../..config.h + diff --git a/user/mpy/lib/axtls/config/scripts/config/conf.c b/user/mpy/lib/axtls/config/scripts/config/conf.c new file mode 100644 index 0000000..1524467 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/conf.c @@ -0,0 +1,583 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +static void conf(struct menu *menu); +static void check_conf(struct menu *menu); + +enum { + ask_all, + ask_new, + ask_silent, + set_default, + set_yes, + set_mod, + set_no, + set_random +} input_mode = ask_all; +char *defconfig_file; + +static int indent = 1; +static int valid_stdin = 1; +static int conf_cnt; +static char line[128]; +static struct menu *rootEntry; + +static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; + +static void strip(char *str) +{ + char *p = str; + int l; + + while ((isspace(*p))) + p++; + l = strlen(p); + if (p != str) + memmove(str, p, l + 1); + if (!l) + return; + p = str + l - 1; + while ((isspace(*p))) + *p-- = 0; +} + +static void check_stdin(void) +{ + if (!valid_stdin && input_mode == ask_silent) { + printf("aborted!\n\n"); + printf("Console input/output is redirected. "); + printf("Run 'make oldconfig' to update configuration.\n\n"); + exit(1); + } +} + +static void conf_askvalue(struct symbol *sym, const char *def) +{ + enum symbol_type type = sym_get_type(sym); + tristate val; + + if (!sym_has_value(sym)) + printf("(NEW) "); + + line[0] = '\n'; + line[1] = 0; + + if (!sym_is_changable(sym)) { + printf("%s\n", def); + line[0] = '\n'; + line[1] = 0; + return; + } + + switch (input_mode) { + case ask_new: + case ask_silent: + if (sym_has_value(sym)) { + printf("%s\n", def); + return; + } + check_stdin(); + case ask_all: + fflush(stdout); + fgets(line, 128, stdin); + return; + case set_default: + printf("%s\n", def); + return; + default: + break; + } + + switch (type) { + case S_INT: + case S_HEX: + case S_STRING: + printf("%s\n", def); + return; + default: + ; + } + switch (input_mode) { + case set_yes: + if (sym_tristate_within_range(sym, yes)) { + line[0] = 'y'; + line[1] = '\n'; + line[2] = 0; + break; + } + case set_mod: + if (type == S_TRISTATE) { + if (sym_tristate_within_range(sym, mod)) { + line[0] = 'm'; + line[1] = '\n'; + line[2] = 0; + break; + } + } else { + if (sym_tristate_within_range(sym, yes)) { + line[0] = 'y'; + line[1] = '\n'; + line[2] = 0; + break; + } + } + case set_no: + if (sym_tristate_within_range(sym, no)) { + line[0] = 'n'; + line[1] = '\n'; + line[2] = 0; + break; + } + case set_random: + do { + val = (tristate)(random() % 3); + } while (!sym_tristate_within_range(sym, val)); + switch (val) { + case no: line[0] = 'n'; break; + case mod: line[0] = 'm'; break; + case yes: line[0] = 'y'; break; + } + line[1] = '\n'; + line[2] = 0; + break; + default: + break; + } + printf("%s", line); +} + +int conf_string(struct menu *menu) +{ + struct symbol *sym = menu->sym; + const char *def, *help; + + while (1) { + printf("%*s%s ", indent - 1, "", menu->prompt->text); + printf("(%s) ", sym->name); + def = sym_get_string_value(sym); + if (sym_get_string_value(sym)) + printf("[%s] ", def); + conf_askvalue(sym, def); + switch (line[0]) { + case '\n': + break; + case '?': + /* print help */ + if (line[1] == '\n') { + help = nohelp_text; + if (menu->sym->help) + help = menu->sym->help; + printf("\n%s\n", menu->sym->help); + def = NULL; + break; + } + default: + line[strlen(line)-1] = 0; + def = line; + } + if (def && sym_set_string_value(sym, def)) + return 0; + } +} + +static int conf_sym(struct menu *menu) +{ + struct symbol *sym = menu->sym; + int type; + tristate oldval, newval; + const char *help; + + while (1) { + printf("%*s%s ", indent - 1, "", menu->prompt->text); + if (sym->name) + printf("(%s) ", sym->name); + type = sym_get_type(sym); + putchar('['); + oldval = sym_get_tristate_value(sym); + switch (oldval) { + case no: + putchar('N'); + break; + case mod: + putchar('M'); + break; + case yes: + putchar('Y'); + break; + } + if (oldval != no && sym_tristate_within_range(sym, no)) + printf("/n"); + if (oldval != mod && sym_tristate_within_range(sym, mod)) + printf("/m"); + if (oldval != yes && sym_tristate_within_range(sym, yes)) + printf("/y"); + if (sym->help) + printf("/?"); + printf("] "); + conf_askvalue(sym, sym_get_string_value(sym)); + strip(line); + + switch (line[0]) { + case 'n': + case 'N': + newval = no; + if (!line[1] || !strcmp(&line[1], "o")) + break; + continue; + case 'm': + case 'M': + newval = mod; + if (!line[1]) + break; + continue; + case 'y': + case 'Y': + newval = yes; + if (!line[1] || !strcmp(&line[1], "es")) + break; + continue; + case 0: + newval = oldval; + break; + case '?': + goto help; + default: + continue; + } + if (sym_set_tristate_value(sym, newval)) + return 0; +help: + help = nohelp_text; + if (sym->help) + help = sym->help; + printf("\n%s\n", help); + } +} + +static int conf_choice(struct menu *menu) +{ + struct symbol *sym, *def_sym; + struct menu *child; + int type; + bool is_new; + + sym = menu->sym; + type = sym_get_type(sym); + is_new = !sym_has_value(sym); + if (sym_is_changable(sym)) { + conf_sym(menu); + sym_calc_value(sym); + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: + return 0; + case yes: + break; + } + } else { + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: + printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + return 0; + case yes: + break; + } + } + + while (1) { + int cnt, def; + + printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + def_sym = sym_get_choice_value(sym); + cnt = def = 0; + line[0] = '0'; + line[1] = 0; + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + if (!child->sym) { + printf("%*c %s\n", indent, '*', menu_get_prompt(child)); + continue; + } + cnt++; + if (child->sym == def_sym) { + def = cnt; + printf("%*c", indent, '>'); + } else + printf("%*c", indent, ' '); + printf(" %d. %s", cnt, menu_get_prompt(child)); + if (child->sym->name) + printf(" (%s)", child->sym->name); + if (!sym_has_value(child->sym)) + printf(" (NEW)"); + printf("\n"); + } + printf("%*schoice", indent - 1, ""); + if (cnt == 1) { + printf("[1]: 1\n"); + goto conf_childs; + } + printf("[1-%d", cnt); + if (sym->help) + printf("?"); + printf("]: "); + switch (input_mode) { + case ask_new: + case ask_silent: + if (!is_new) { + cnt = def; + printf("%d\n", cnt); + break; + } + check_stdin(); + case ask_all: + fflush(stdout); + fgets(line, 128, stdin); + strip(line); + if (line[0] == '?') { + printf("\n%s\n", menu->sym->help ? + menu->sym->help : nohelp_text); + continue; + } + if (!line[0]) + cnt = def; + else if (isdigit(line[0])) + cnt = atoi(line); + else + continue; + break; + case set_random: + def = (random() % cnt) + 1; + case set_default: + case set_yes: + case set_mod: + case set_no: + cnt = def; + printf("%d\n", cnt); + break; + } + + conf_childs: + for (child = menu->list; child; child = child->next) { + if (!child->sym || !menu_is_visible(child)) + continue; + if (!--cnt) + break; + } + if (!child) + continue; + if (line[strlen(line) - 1] == '?') { + printf("\n%s\n", child->sym->help ? + child->sym->help : nohelp_text); + continue; + } + sym_set_choice_value(sym, child->sym); + if (child->list) { + indent += 2; + conf(child->list); + indent -= 2; + } + return 1; + } +} + +static void conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + prop = menu->prompt; + if (prop) { + const char *prompt; + + switch (prop->type) { + case P_MENU: + if (input_mode == ask_silent && rootEntry != menu) { + check_conf(menu); + return; + } + case P_COMMENT: + prompt = menu_get_prompt(menu); + if (prompt) + printf("%*c\n%*c %s\n%*c\n", + indent, '*', + indent, '*', prompt, + indent, '*'); + default: + ; + } + } + + if (!sym) + goto conf_childs; + + if (sym_is_choice(sym)) { + conf_choice(menu); + if (sym->curr.tri != mod) + return; + goto conf_childs; + } + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + conf_string(menu); + break; + default: + conf_sym(menu); + break; + } + +conf_childs: + if (sym) + indent += 2; + for (child = menu->list; child; child = child->next) + conf(child); + if (sym) + indent -= 2; +} + +static void check_conf(struct menu *menu) +{ + struct symbol *sym; + struct menu *child; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + if (sym) { + if (sym_is_changable(sym) && !sym_has_value(sym)) { + if (!conf_cnt++) + printf("*\n* Restart config...\n*\n"); + rootEntry = menu_get_parent_menu(menu); + conf(rootEntry); + } + if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod) + return; + } + + for (child = menu->list; child; child = child->next) + check_conf(child); +} + +int main(int ac, char **av) +{ + int i = 1; + const char *name; + struct stat tmpstat; + + if (ac > i && av[i][0] == '-') { + switch (av[i++][1]) { + case 'o': + input_mode = ask_new; + break; + case 's': + input_mode = ask_silent; + valid_stdin = isatty(0) && isatty(1) && isatty(2); + break; + case 'd': + input_mode = set_default; + break; + case 'D': + input_mode = set_default; + defconfig_file = av[i++]; + if (!defconfig_file) { + printf("%s: No default config file specified\n", + av[0]); + exit(1); + } + break; + case 'n': + input_mode = set_no; + break; + case 'm': + input_mode = set_mod; + break; + case 'y': + input_mode = set_yes; + break; + case 'r': + input_mode = set_random; + srandom(time(NULL)); + break; + case 'h': + case '?': + printf("%s [-o|-s] config\n", av[0]); + exit(0); + } + } + name = av[i]; + if (!name) { + printf("%s: configuration file missing\n", av[0]); + } + conf_parse(name); + //zconfdump(stdout); + switch (input_mode) { + case set_default: + if (!defconfig_file) + defconfig_file = conf_get_default_confname(); + if (conf_read(defconfig_file)) { + printf("***\n" + "*** Can't find default configuration \"%s\"!\n" + "***\n", defconfig_file); + exit(1); + } + break; + case ask_silent: + if (stat(".config", &tmpstat)) { + printf("***\n" + "*** You have not yet configured axTLS!\n" + "***\n" + "*** Please run some configurator (e.g. \"make oldconfig\" or\n" + "*** \"make menuconfig\" or \"make config\").\n" + "***\n"); + exit(1); + } + case ask_all: + case ask_new: + conf_read(NULL); + break; + default: + break; + } + + if (input_mode != ask_silent) { + rootEntry = &rootmenu; + conf(&rootmenu); + if (input_mode == ask_all) { + input_mode = ask_silent; + valid_stdin = 1; + } + } + do { + conf_cnt = 0; + check_conf(&rootmenu); + } while (conf_cnt); + if (conf_write(NULL)) { + fprintf(stderr, "\n*** Error during writing of the axTLS configuration.\n\n"); + return 1; + } + return 0; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/confdata.c b/user/mpy/lib/axtls/config/scripts/config/confdata.c new file mode 100644 index 0000000..a59e245 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/confdata.c @@ -0,0 +1,458 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +const char conf_def_filename[] = "config/.config"; + +const char conf_defname[] = "config/defconfig"; + +const char *conf_confnames[] = { + "config/.config", + conf_defname, + NULL, +}; + +static char *conf_expand_value(const char *in) +{ + struct symbol *sym; + const char *src; + static char res_value[SYMBOL_MAXLENGTH]; + char *dst, name[SYMBOL_MAXLENGTH]; + + res_value[0] = 0; + dst = name; + while ((src = strchr(in, '$'))) { + strncat(res_value, in, src - in); + src++; + dst = name; + while (isalnum(*src) || *src == '_') + *dst++ = *src++; + *dst = 0; + sym = sym_lookup(name, 0); + sym_calc_value(sym); + strcat(res_value, sym_get_string_value(sym)); + in = src; + } + strcat(res_value, in); + + return res_value; +} + +char *conf_get_default_confname(void) +{ + struct stat buf; + static char fullname[PATH_MAX+1]; + char *env, *name; + + name = conf_expand_value(conf_defname); + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + if (!stat(fullname, &buf)) + return fullname; + } + return name; +} + +int conf_read(const char *name) +{ + FILE *in = NULL; + char line[1024]; + char *p, *p2; + int lineno = 0; + struct symbol *sym; + struct property *prop; + struct expr *e; + int i; + + if (name) { + in = zconf_fopen(name); + } else { + const char **names = conf_confnames; + while ((name = *names++)) { + name = conf_expand_value(name); + in = zconf_fopen(name); + if (in) { + printf("#\n" + "# using defaults found in %s\n" + "#\n", name); + break; + } + } + } + + if (!in) + return 1; + + for_all_symbols(i, sym) { + sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; + sym->flags &= ~SYMBOL_VALID; + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + if (sym->user.val) + free(sym->user.val); + default: + sym->user.val = NULL; + sym->user.tri = no; + } + } + + while (fgets(line, sizeof(line), in)) { + lineno++; + sym = NULL; + switch (line[0]) { + case '#': + if (line[1]!=' ') + continue; + p = strchr(line + 2, ' '); + if (!p) + continue; + *p++ = 0; + if (strncmp(p, "is not set", 10)) + continue; + sym = sym_find(line + 2); + if (!sym) { + fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2); + break; + } + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + sym->user.tri = no; + sym->flags &= ~SYMBOL_NEW; + break; + default: + ; + } + break; + + case 'A' ... 'Z': + p = strchr(line, '='); + if (!p) + continue; + *p++ = 0; + p2 = strchr(p, '\n'); + if (p2) + *p2 = 0; + sym = sym_find(line); + if (!sym) { + fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); + break; + } + switch (sym->type) { + case S_TRISTATE: + if (p[0] == 'm') { + sym->user.tri = mod; + sym->flags &= ~SYMBOL_NEW; + break; + } + case S_BOOLEAN: + if (p[0] == 'y') { + sym->user.tri = yes; + sym->flags &= ~SYMBOL_NEW; + break; + } + if (p[0] == 'n') { + sym->user.tri = no; + sym->flags &= ~SYMBOL_NEW; + break; + } + break; + case S_STRING: + if (*p++ != '"') + break; + for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { + if (*p2 == '"') { + *p2 = 0; + break; + } + memmove(p2, p2 + 1, strlen(p2)); + } + if (!p2) { + fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); + exit(1); + } + case S_INT: + case S_HEX: + if (sym_string_valid(sym, p)) { + sym->user.val = strdup(p); + sym->flags &= ~SYMBOL_NEW; + } else { + fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); + exit(1); + } + break; + default: + ; + } + break; + case '\n': + break; + default: + continue; + } + if (sym && sym_is_choice_value(sym)) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + switch (sym->user.tri) { + case no: + break; + case mod: + if (cs->user.tri == yes) + /* warn? */; + break; + case yes: + if (cs->user.tri != no) + /* warn? */; + cs->user.val = sym; + break; + } + cs->user.tri = E_OR(cs->user.tri, sym->user.tri); + cs->flags &= ~SYMBOL_NEW; + } + } + fclose(in); + + if (modules_sym) + sym_calc_value(modules_sym); + for_all_symbols(i, sym) { + sym_calc_value(sym); + if (sym_has_value(sym) && !sym_is_choice_value(sym)) { + if (sym->visible == no) + sym->flags |= SYMBOL_NEW; + switch (sym->type) { + case S_STRING: + case S_INT: + case S_HEX: + if (!sym_string_within_range(sym, sym->user.val)) + sym->flags |= SYMBOL_NEW; + default: + break; + } + } + if (!sym_is_choice(sym)) + continue; + prop = sym_get_choice_prop(sym); + for (e = prop->expr; e; e = e->left.expr) + if (e->right.sym->visible != no) + sym->flags |= e->right.sym->flags & SYMBOL_NEW; + } + + sym_change_count = 1; + + return 0; +} + +struct menu *next_menu(struct menu *menu) +{ + if (menu->list) return menu->list; + do { + if (menu->next) { + menu = menu->next; + break; + } + } while ((menu = menu->parent)); + + return menu; +} + +#define SYMBOL_FORCEWRITE (1<<31) + +int conf_write(const char *name) +{ + FILE *out, *out_h; + struct symbol *sym; + struct menu *menu; + const char *basename; + char dirname[128], tmpname[128], newname[128]; + int type, l; + const char *str; + + dirname[0] = 0; + if (name && name[0]) { + struct stat st; + char *slash; + + if (!stat(name, &st) && S_ISDIR(st.st_mode)) { + strcpy(dirname, name); + strcat(dirname, "/"); + basename = conf_def_filename; + } else if ((slash = strrchr(name, '/'))) { + int size = slash - name + 1; + memcpy(dirname, name, size); + dirname[size] = 0; + if (slash[1]) + basename = slash + 1; + else + basename = conf_def_filename; + } else + basename = name; + } else + basename = conf_def_filename; + + sprintf(newname, "config/%s.tmpconfig.%d", dirname, (int)getpid()); + out = fopen(newname, "w"); + if (!out) + return 1; + out_h = NULL; + if (!name) { + out_h = fopen("config/.tmpconfig.h", "w"); + if (!out_h) + return 1; + } + fprintf(out, "#\n" + "# Automatically generated make config: don't edit\n" + "#\n"); + if (out_h) { + fprintf(out_h, "/*\n" + " * Automatically generated header file: don't edit\n" + " */\n\n"); +#if 0 + "/* Version Number */\n" + "#define BB_VER \"%s\"\n" + "#define BB_BT \"%s\"\n", + getenv("VERSION"), + getenv("BUILDTIME")); + if (getenv("EXTRA_VERSION")) + fprintf(out_h, "#define BB_EXTRA_VERSION \"%s\"\n", + getenv("EXTRA_VERSION")); + fprintf(out_h, "\n"); +#endif + } + + if (!sym_change_count) + sym_clear_all_valid(); + + /* Force write of all non-duplicate symbols. */ + + /* Write out everything by default. */ + for(menu = rootmenu.list; menu; menu = next_menu(menu)) + if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE; + + menu = rootmenu.list; + while (menu) { + sym = menu->sym; + if (!sym) { + if (!menu_is_visible(menu)) + goto next; + str = menu_get_prompt(menu); + fprintf(out, "\n" + "#\n" + "# %s\n" + "#\n", str); + if (out_h) + fprintf(out_h, "\n" + "/*\n" + " * %s\n" + " */\n", str); + } else if (!(sym->flags & SYMBOL_CHOICE)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_FORCEWRITE)) + goto next; + + sym->flags &= ~SYMBOL_FORCEWRITE; + type = sym->type; + if (type == S_TRISTATE) { + sym_calc_value(modules_sym); + if (modules_sym->curr.tri == no) + type = S_BOOLEAN; + } + switch (type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (sym_get_tristate_value(sym)) { + case no: + fprintf(out, "# %s is not set\n", sym->name); + if (out_h) + fprintf(out_h, "#undef %s\n", sym->name); + break; + case mod: +#if 0 + fprintf(out, "%s=m\n", sym->name); + if (out_h) + fprintf(out_h, "#define %s_MODULE 1\n", sym->name); +#endif + break; + case yes: + fprintf(out, "%s=y\n", sym->name); + if (out_h) + fprintf(out_h, "#define %s 1\n", sym->name); + break; + } + break; + case S_STRING: + // fix me + str = sym_get_string_value(sym); + fprintf(out, "%s=\"", sym->name); + if (out_h) + fprintf(out_h, "#define %s \"", sym->name); + do { + l = strcspn(str, "\"\\"); + if (l) { + fwrite(str, l, 1, out); + if (out_h) + fwrite(str, l, 1, out_h); + } + str += l; + while (*str == '\\' || *str == '"') { + fprintf(out, "\\%c", *str); + if (out_h) + fprintf(out_h, "\\%c", *str); + str++; + } + } while (*str); + fputs("\"\n", out); + if (out_h) + fputs("\"\n", out_h); + break; + case S_HEX: + str = sym_get_string_value(sym); + if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { + fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); + if (out_h) + fprintf(out_h, "#define %s 0x%s\n", sym->name, str); + break; + } + case S_INT: + str = sym_get_string_value(sym); + fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); + if (out_h) + fprintf(out_h, "#define %s %s\n", sym->name, str); + break; + } + } +next: + menu = next_menu(menu); + } + fclose(out); + if (out_h) { + fclose(out_h); + rename("config/.tmpconfig.h", "config/config.h"); + file_write_dep(NULL); + } + if (!name || basename != conf_def_filename) { + if (!name) + name = conf_def_filename; + sprintf(tmpname, "%s.old", name); + rename(name, tmpname); + } + sprintf(tmpname, "%s%s", dirname, basename); + if (rename(newname, tmpname)) + return 1; + + sym_change_count = 0; + + return 0; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/expr.c b/user/mpy/lib/axtls/config/scripts/config/expr.c new file mode 100644 index 0000000..30e4f9d --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/expr.c @@ -0,0 +1,1099 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define DEBUG_EXPR 0 + +struct expr *expr_alloc_symbol(struct symbol *sym) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = E_SYMBOL; + e->left.sym = sym; + return e; +} + +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.expr = ce; + return e; +} + +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.expr = e1; + e->right.expr = e2; + return e; +} + +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.sym = s1; + e->right.sym = s2; + return e; +} + +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_AND, e1, e2) : e1; +} + +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; +} + +struct expr *expr_copy(struct expr *org) +{ + struct expr *e; + + if (!org) + return NULL; + + e = malloc(sizeof(*org)); + memcpy(e, org, sizeof(*org)); + switch (org->type) { + case E_SYMBOL: + e->left = org->left; + break; + case E_NOT: + e->left.expr = expr_copy(org->left.expr); + break; + case E_EQUAL: + case E_UNEQUAL: + e->left.sym = org->left.sym; + e->right.sym = org->right.sym; + break; + case E_AND: + case E_OR: + case E_CHOICE: + e->left.expr = expr_copy(org->left.expr); + e->right.expr = expr_copy(org->right.expr); + break; + default: + printf("can't copy type %d\n", e->type); + free(e); + e = NULL; + break; + } + + return e; +} + +void expr_free(struct expr *e) +{ + if (!e) + return; + + switch (e->type) { + case E_SYMBOL: + break; + case E_NOT: + expr_free(e->left.expr); + return; + case E_EQUAL: + case E_UNEQUAL: + break; + case E_OR: + case E_AND: + expr_free(e->left.expr); + expr_free(e->right.expr); + break; + default: + printf("how to free type %d?\n", e->type); + break; + } + free(e); +} + +static int trans_count; + +#define e1 (*ep1) +#define e2 (*ep2) + +static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ + if (e1->type == type) { + __expr_eliminate_eq(type, &e1->left.expr, &e2); + __expr_eliminate_eq(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + __expr_eliminate_eq(type, &e1, &e2->left.expr); + __expr_eliminate_eq(type, &e1, &e2->right.expr); + return; + } + if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO))) + return; + if (!expr_eq(e1, e2)) + return; + trans_count++; + expr_free(e1); expr_free(e2); + switch (type) { + case E_OR: + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + break; + case E_AND: + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + break; + default: + ; + } +} + +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) +{ + if (!e1 || !e2) + return; + switch (e1->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e1->type, ep1, ep2); + default: + ; + } + if (e1->type != e2->type) switch (e2->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e2->type, ep1, ep2); + default: + ; + } + e1 = expr_eliminate_yn(e1); + e2 = expr_eliminate_yn(e2); +} + +#undef e1 +#undef e2 + +int expr_eq(struct expr *e1, struct expr *e2) +{ + int res, old_count; + + if (e1->type != e2->type) + return 0; + switch (e1->type) { + case E_EQUAL: + case E_UNEQUAL: + return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; + case E_SYMBOL: + return e1->left.sym == e2->left.sym; + case E_NOT: + return expr_eq(e1->left.expr, e2->left.expr); + case E_AND: + case E_OR: + e1 = expr_copy(e1); + e2 = expr_copy(e2); + old_count = trans_count; + expr_eliminate_eq(&e1, &e2); + res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym); + expr_free(e1); + expr_free(e2); + trans_count = old_count; + return res; + case E_CHOICE: + case E_RANGE: + case E_NONE: + /* panic */; + } + + if (DEBUG_EXPR) { + expr_fprint(e1, stdout); + printf(" = "); + expr_fprint(e2, stdout); + printf(" ?\n"); + } + + return 0; +} + +struct expr *expr_eliminate_yn(struct expr *e) +{ + struct expr *tmp; + + if (e) switch (e->type) { + case E_AND: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } + } + break; + case E_OR: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + break; + default: + ; + } + return e; +} + +/* + * bool FOO!=n => FOO + */ +struct expr *expr_trans_bool(struct expr *e) +{ + if (!e) + return NULL; + switch (e->type) { + case E_AND: + case E_OR: + case E_NOT: + e->left.expr = expr_trans_bool(e->left.expr); + e->right.expr = expr_trans_bool(e->right.expr); + break; + case E_UNEQUAL: + // FOO!=n -> FOO + if (e->left.sym->type == S_TRISTATE) { + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + } + } + break; + default: + ; + } + return e; +} + +/* + * e1 || e2 -> ? + */ +struct expr *expr_join_or(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='m') -> (a!='n') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='n') -> (a!='m') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { + // (a='m') || (a='n') -> (a!='y') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes); + } + } + if (sym1->type == S_BOOLEAN && sym1 == sym2) { + if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || + (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) + return expr_alloc_symbol(&symbol_yes); + } + + if (DEBUG_EXPR) { + printf("optimize ("); + expr_fprint(e1, stdout); + printf(") || ("); + expr_fprint(e2, stdout); + printf(")?\n"); + } + return NULL; +} + +struct expr *expr_join_and(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) + // (a) && (a='y') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) + // (a) && (a!='n') -> (a) + return expr_alloc_symbol(sym1); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod)) + // (a) && (a!='m') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e1->right.sym; + if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e2->right.sym; + if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='m') -> (a='n') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_no); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) + // (a!='m') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || + (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) + return NULL; + } + + if (DEBUG_EXPR) { + printf("optimize ("); + expr_fprint(e1, stdout); + printf(") && ("); + expr_fprint(e2, stdout); + printf(")?\n"); + } + return NULL; +} + +static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp; + + if (e1->type == type) { + expr_eliminate_dups1(type, &e1->left.expr, &e2); + expr_eliminate_dups1(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups1(type, &e1, &e2->left.expr); + expr_eliminate_dups1(type, &e1, &e2->right.expr); + return; + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e1->type, &e1, &e1); + default: + ; + } + + switch (type) { + case E_OR: + tmp = expr_join_or(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_no); + e2 = tmp; + trans_count++; + } + break; + case E_AND: + tmp = expr_join_and(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_yes); + e2 = tmp; + trans_count++; + } + break; + default: + ; + } +#undef e1 +#undef e2 +} + +static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp, *tmp1, *tmp2; + + if (e1->type == type) { + expr_eliminate_dups2(type, &e1->left.expr, &e2); + expr_eliminate_dups2(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups2(type, &e1, &e2->left.expr); + expr_eliminate_dups2(type, &e1, &e2->right.expr); + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: + expr_eliminate_dups2(e1->type, &e1, &e1); + // (FOO || BAR) && (!FOO && !BAR) -> n + tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); + tmp2 = expr_copy(e2); + tmp = expr_extract_eq_and(&tmp1, &tmp2); + if (expr_is_yes(tmp1)) { + expr_free(e1); + e1 = expr_alloc_symbol(&symbol_no); + trans_count++; + } + expr_free(tmp2); + expr_free(tmp1); + expr_free(tmp); + break; + case E_AND: + expr_eliminate_dups2(e1->type, &e1, &e1); + // (FOO && BAR) || (!FOO || !BAR) -> y + tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); + tmp2 = expr_copy(e2); + tmp = expr_extract_eq_or(&tmp1, &tmp2); + if (expr_is_no(tmp1)) { + expr_free(e1); + e1 = expr_alloc_symbol(&symbol_yes); + trans_count++; + } + expr_free(tmp2); + expr_free(tmp1); + expr_free(tmp); + break; + default: + ; + } +#undef e1 +#undef e2 +} + +struct expr *expr_eliminate_dups(struct expr *e) +{ + int oldcount; + if (!e) + return e; + + oldcount = trans_count; + while (1) { + trans_count = 0; + switch (e->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e->type, &e, &e); + expr_eliminate_dups2(e->type, &e, &e); + default: + ; + } + if (!trans_count) + break; + e = expr_eliminate_yn(e); + } + trans_count = oldcount; + return e; +} + +struct expr *expr_transform(struct expr *e) +{ + struct expr *tmp; + + if (!e) + return NULL; + switch (e->type) { + case E_EQUAL: + case E_UNEQUAL: + case E_SYMBOL: + case E_CHOICE: + break; + default: + e->left.expr = expr_transform(e->left.expr); + e->right.expr = expr_transform(e->right.expr); + } + + switch (e->type) { + case E_EQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + break; + case E_UNEQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + break; + case E_NOT: + switch (e->left.expr->type) { + case E_NOT: + // !!a -> a + tmp = e->left.expr->left.expr; + free(e->left.expr); + free(e); + e = tmp; + e = expr_transform(e); + break; + case E_EQUAL: + case E_UNEQUAL: + // !a='x' -> a!='x' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; + break; + case E_OR: + // !(a || b) -> !a && !b + tmp = e->left.expr; + e->type = E_AND; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_AND: + // !(a && b) -> !a || !b + tmp = e->left.expr; + e->type = E_OR; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_SYMBOL: + if (e->left.expr->left.sym == &symbol_yes) { + // !'y' -> 'n' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + break; + } + if (e->left.expr->left.sym == &symbol_mod) { + // !'m' -> 'm' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_mod; + break; + } + if (e->left.expr->left.sym == &symbol_no) { + // !'n' -> 'y' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + break; + } + break; + default: + ; + } + break; + default: + ; + } + return e; +} + +int expr_contains_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return 0; + + switch (dep->type) { + case E_AND: + case E_OR: + return expr_contains_symbol(dep->left.expr, sym) || + expr_contains_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + case E_UNEQUAL: + return dep->left.sym == sym || + dep->right.sym == sym; + case E_NOT: + return expr_contains_symbol(dep->left.expr, sym); + default: + ; + } + return 0; +} + +bool expr_depends_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return false; + + switch (dep->type) { + case E_AND: + return expr_depends_symbol(dep->left.expr, sym) || + expr_depends_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) + return true; + } + break; + case E_UNEQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_no) + return true; + } + break; + default: + ; + } + return false; +} + +struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) +{ + struct expr *tmp = NULL; + expr_extract_eq(E_AND, &tmp, ep1, ep2); + if (tmp) { + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); + } + return tmp; +} + +struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) +{ + struct expr *tmp = NULL; + expr_extract_eq(E_OR, &tmp, ep1, ep2); + if (tmp) { + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); + } + return tmp; +} + +void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + if (e1->type == type) { + expr_extract_eq(type, ep, &e1->left.expr, &e2); + expr_extract_eq(type, ep, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_extract_eq(type, ep, ep1, &e2->left.expr); + expr_extract_eq(type, ep, ep1, &e2->right.expr); + return; + } + if (expr_eq(e1, e2)) { + *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1; + expr_free(e2); + if (type == E_AND) { + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + } else if (type == E_OR) { + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + } + } +#undef e1 +#undef e2 +} + +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) +{ + struct expr *e1, *e2; + + if (!e) { + e = expr_alloc_symbol(sym); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + } + switch (e->type) { + case E_AND: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_AND, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_OR, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_OR: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_OR, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_AND, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_NOT: + return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); + case E_UNEQUAL: + case E_EQUAL: + if (type == E_EQUAL) { + if (sym == &symbol_yes) + return expr_copy(e); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_no); + if (sym == &symbol_no) + return expr_alloc_one(E_NOT, expr_copy(e)); + } else { + if (sym == &symbol_yes) + return expr_alloc_one(E_NOT, expr_copy(e)); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_yes); + if (sym == &symbol_no) + return expr_copy(e); + } + break; + case E_SYMBOL: + return expr_alloc_comp(type, e->left.sym, sym); + case E_CHOICE: + case E_RANGE: + case E_NONE: + /* panic */; + } + return NULL; +} + +tristate expr_calc_value(struct expr *e) +{ + tristate val1, val2; + const char *str1, *str2; + + if (!e) + return yes; + + switch (e->type) { + case E_SYMBOL: + sym_calc_value(e->left.sym); + return e->left.sym->curr.tri; + case E_AND: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return E_AND(val1, val2); + case E_OR: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return E_OR(val1, val2); + case E_NOT: + val1 = expr_calc_value(e->left.expr); + return E_NOT(val1); + case E_EQUAL: + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + return !strcmp(str1, str2) ? yes : no; + case E_UNEQUAL: + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + return !strcmp(str1, str2) ? no : yes; + default: + printf("expr_calc_value: %d?\n", e->type); + return no; + } +} + +int expr_compare_type(enum expr_type t1, enum expr_type t2) +{ +#if 0 + return 1; +#else + if (t1 == t2) + return 0; + switch (t1) { + case E_EQUAL: + case E_UNEQUAL: + if (t2 == E_NOT) + return 1; + case E_NOT: + if (t2 == E_AND) + return 1; + case E_AND: + if (t2 == E_OR) + return 1; + case E_OR: + if (t2 == E_CHOICE) + return 1; + case E_CHOICE: + if (t2 == 0) + return 1; + default: + return -1; + } + printf("[%dgt%d?]", t1, t2); + return 0; +#endif +} + +void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken) +{ + if (!e) { + fn(data, "y"); + return; + } + + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, "("); + switch (e->type) { + case E_SYMBOL: + if (e->left.sym->name) + fn(data, e->left.sym->name); + else + fn(data, ""); + break; + case E_NOT: + fn(data, "!"); + expr_print(e->left.expr, fn, data, E_NOT); + break; + case E_EQUAL: + fn(data, e->left.sym->name); + fn(data, "="); + fn(data, e->right.sym->name); + break; + case E_UNEQUAL: + fn(data, e->left.sym->name); + fn(data, "!="); + fn(data, e->right.sym->name); + break; + case E_OR: + expr_print(e->left.expr, fn, data, E_OR); + fn(data, " || "); + expr_print(e->right.expr, fn, data, E_OR); + break; + case E_AND: + expr_print(e->left.expr, fn, data, E_AND); + fn(data, " && "); + expr_print(e->right.expr, fn, data, E_AND); + break; + case E_CHOICE: + fn(data, e->right.sym->name); + if (e->left.expr) { + fn(data, " ^ "); + expr_print(e->left.expr, fn, data, E_CHOICE); + } + break; + case E_RANGE: + fn(data, "["); + fn(data, e->left.sym->name); + fn(data, " "); + fn(data, e->right.sym->name); + fn(data, "]"); + break; + default: + { + char buf[32]; + sprintf(buf, "", e->type); + fn(data, buf); + break; + } + } + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, ")"); +} + +static void expr_print_file_helper(void *data, const char *str) +{ + fwrite(str, strlen(str), 1, data); +} + +void expr_fprint(struct expr *e, FILE *out) +{ + expr_print(e, expr_print_file_helper, out, E_NONE); +} + +static void expr_print_gstr_helper(void *data, const char *str) +{ + str_append((struct gstr*)data, str); +} + +void expr_gstr_print(struct expr *e, struct gstr *gs) +{ + expr_print(e, expr_print_gstr_helper, gs, E_NONE); +} diff --git a/user/mpy/lib/axtls/config/scripts/config/expr.h b/user/mpy/lib/axtls/config/scripts/config/expr.h new file mode 100644 index 0000000..7d39ff4 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/expr.h @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef EXPR_H +#define EXPR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifndef __cplusplus +#include +#endif + +struct file { + struct file *next; + struct file *parent; + char *name; + int lineno; + int flags; +}; + +#define FILE_BUSY 0x0001 +#define FILE_SCANNED 0x0002 +#define FILE_PRINTED 0x0004 + +typedef enum tristate { + no, mod, yes +} tristate; + +enum expr_type { + E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE +}; + +union expr_data { + struct expr *expr; + struct symbol *sym; +}; + +struct expr { + enum expr_type type; + union expr_data left, right; +}; + +#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) +#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) +#define E_NOT(dep) (2-(dep)) + +struct expr_value { + struct expr *expr; + tristate tri; +}; + +struct symbol_value { + void *val; + tristate tri; +}; + +enum symbol_type { + S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER +}; + +struct symbol { + struct symbol *next; + char *name; + char *help; + enum symbol_type type; + struct symbol_value curr, user; + tristate visible; + int flags; + struct property *prop; + struct expr *dep, *dep2; + struct expr_value rev_dep; +}; + +#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) + +#define SYMBOL_YES 0x0001 +#define SYMBOL_MOD 0x0002 +#define SYMBOL_NO 0x0004 +#define SYMBOL_CONST 0x0007 +#define SYMBOL_CHECK 0x0008 +#define SYMBOL_CHOICE 0x0010 +#define SYMBOL_CHOICEVAL 0x0020 +#define SYMBOL_PRINTED 0x0040 +#define SYMBOL_VALID 0x0080 +#define SYMBOL_OPTIONAL 0x0100 +#define SYMBOL_WRITE 0x0200 +#define SYMBOL_CHANGED 0x0400 +#define SYMBOL_NEW 0x0800 +#define SYMBOL_AUTO 0x1000 +#define SYMBOL_CHECKED 0x2000 +#define SYMBOL_CHECK_DONE 0x4000 +#define SYMBOL_WARNED 0x8000 + +#define SYMBOL_MAXLENGTH 256 +#define SYMBOL_HASHSIZE 257 +#define SYMBOL_HASHMASK 0xff + +enum prop_type { + P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE +}; + +struct property { + struct property *next; + struct symbol *sym; + enum prop_type type; + const char *text; + struct expr_value visible; + struct expr *expr; + struct menu *menu; + struct file *file; + int lineno; +}; + +#define for_all_properties(sym, st, tok) \ + for (st = sym->prop; st; st = st->next) \ + if (st->type == (tok)) +#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) +#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) +#define for_all_prompts(sym, st) \ + for (st = sym->prop; st; st = st->next) \ + if (st->text) + +struct menu { + struct menu *next; + struct menu *parent; + struct menu *list; + struct symbol *sym; + struct property *prompt; + struct expr *dep; + unsigned int flags; + //char *help; + struct file *file; + int lineno; + void *data; +}; + +#define MENU_CHANGED 0x0001 +#define MENU_ROOT 0x0002 + +#ifndef SWIG + +extern struct file *file_list; +extern struct file *current_file; +struct file *lookup_file(const char *name); + +extern struct symbol symbol_yes, symbol_no, symbol_mod; +extern struct symbol *modules_sym; +extern int cdebug; +struct expr *expr_alloc_symbol(struct symbol *sym); +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); +struct expr *expr_copy(struct expr *org); +void expr_free(struct expr *e); +int expr_eq(struct expr *e1, struct expr *e2); +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); +tristate expr_calc_value(struct expr *e); +struct expr *expr_eliminate_yn(struct expr *e); +struct expr *expr_trans_bool(struct expr *e); +struct expr *expr_eliminate_dups(struct expr *e); +struct expr *expr_transform(struct expr *e); +int expr_contains_symbol(struct expr *dep, struct symbol *sym); +bool expr_depends_symbol(struct expr *dep, struct symbol *sym); +struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); +struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); +void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); + +void expr_fprint(struct expr *e, FILE *out); +struct gstr; /* forward */ +void expr_gstr_print(struct expr *e, struct gstr *gs); + +static inline int expr_is_yes(struct expr *e) +{ + return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); +} + +static inline int expr_is_no(struct expr *e) +{ + return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); +} +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EXPR_H */ diff --git a/user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped b/user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped new file mode 100644 index 0000000..b877bb6 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped @@ -0,0 +1,3688 @@ + +#line 3 "lex.zconf.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 31 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE zconfrestart(zconfin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int zconfleng; + +extern FILE *zconfin, *zconfout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via zconfrestart()), so that the user can continue scanning by + * just pointing zconfin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when zconftext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int zconfleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow zconfwrap()'s to do buffer switches + * instead of setting up a fresh zconfin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void zconfrestart (FILE *input_file ); +void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); +void zconf_delete_buffer (YY_BUFFER_STATE b ); +void zconf_flush_buffer (YY_BUFFER_STATE b ); +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); +void zconfpop_buffer_state (void ); + +static void zconfensure_buffer_stack (void ); +static void zconf_load_buffer_state (void ); +static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); + +void *zconfalloc (yy_size_t ); +void *zconfrealloc (void *,yy_size_t ); +void zconffree (void * ); + +#define yy_new_buffer zconf_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define zconfwrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; + +typedef int yy_state_type; + +extern int zconflineno; + +int zconflineno = 1; + +extern char *zconftext; +#define yytext_ptr zconftext +static yyconst flex_int16_t yy_nxt[][38] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, + 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, + 27, 18, 28, 29, 30, 18, 18, 16 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, + 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, + 27, 18, 28, 29, 30, 18, 18, 16 + + }, + + { + 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31 + }, + + { + 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31 + }, + + { + 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, + 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, + + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34 + }, + + { + 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, + 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34 + }, + + { + 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, + 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 52 + + }, + + { + 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, + 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 52 + }, + + { + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11 + }, + + { + 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12 + }, + + { + 11, -13, 53, 54, -13, -13, 55, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13 + }, + + { + 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14 + + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16 + }, + + { + 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17 + }, + + { + 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, 58, -18, -18, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -18 + }, + + { + 11, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, 58, -19, -19, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 59, + 58, 58, 58, 58, 58, 58, 58, -19 + + }, + + { + 11, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, 58, -20, -20, 58, 58, 58, 58, + 58, 58, 58, 58, 60, 58, 58, 58, 58, 61, + 58, 58, 58, 58, 58, 58, 58, -20 + }, + + { + 11, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, 58, -21, -21, 58, 58, 58, 58, + 58, 62, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -21 + }, + + { + 11, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, 58, -22, -22, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 63, 58, + 58, 58, 58, 58, 58, 58, 58, -22 + }, + + { + 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, 58, -23, -23, 58, 58, 58, 58, + 58, 64, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -23 + }, + + { + 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, 58, -24, -24, 58, 58, 58, 58, + 58, 58, 65, 58, 58, 58, 58, 58, 66, 58, + 58, 58, 58, 58, 58, 58, 58, -24 + + }, + + { + 11, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, 58, -25, -25, 58, 67, 58, 58, + 58, 68, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -25 + }, + + { + 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, 58, -26, -26, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 69, 58, 58, 58, 58, 58, 58, -26 + }, + + { + 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -27, -27, -27, 58, -27, -27, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 70, 58, 58, 58, 58, -27 + }, + + { + 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, 58, -28, -28, 58, 71, 58, 58, + 58, 72, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -28 + }, + + { + 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, 58, -29, -29, 58, 58, 58, 58, + 58, 73, 58, 58, 58, 58, 58, 58, 58, 74, + 58, 58, 58, 58, 75, 58, 58, -29 + + }, + + { + 11, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, 58, -30, -30, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 76, 58, 58, 58, 58, -30 + }, + + { + 11, 77, 77, -31, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77 + }, + + { + 11, -32, 78, 79, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32 + }, + + { + 11, 80, -33, -33, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80 + }, + + { + 11, 81, 81, 82, 81, -34, 81, 81, -34, 81, + 81, 81, 81, 81, 81, -34, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81 + + }, + + { + 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35 + }, + + { + 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36 + }, + + { + 11, 83, 83, 84, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83 + }, + + { + 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38 + }, + + { + 11, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39 + + }, + + { + 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, 85, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40 + }, + + { + 11, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41 + }, + + { + 11, 86, 86, -42, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86 + }, + + { + 11, -43, -43, -43, -43, -43, -43, 87, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43 + }, + + { + 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44 + + }, + + { + 11, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45 + }, + + { + 11, -46, -46, -46, -46, -46, -46, -46, -46, -46, + -46, 88, 89, 89, -46, -46, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -46 + }, + + { + 11, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, 89, 89, 89, -47, -47, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -47 + }, + + { + 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48 + }, + + { + 11, -49, -49, 90, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49 + + }, + + { + 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, 89, 89, 89, -50, -50, 89, 89, 89, 89, + 89, 89, 91, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -50 + }, + + { + 11, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, 89, 89, 89, -51, -51, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 92, 89, + 89, 89, 89, 89, 89, 89, 89, -51 + }, + + { + 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, 93 + }, + + { + 11, -53, 53, 54, -53, -53, 55, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53 + }, + + { + 11, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54 + + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56 + }, + + { + 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57 + }, + + { + 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, 58, -58, -58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -58 + }, + + { + 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, 58, -59, -59, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, + 58, 58, 58, 58, 58, 58, 58, -59 + + }, + + { + 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, 58, -60, -60, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 95, + 58, 58, 58, 58, 58, 58, 58, -60 + }, + + { + 11, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, 58, -61, -61, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 96, 97, 58, + 58, 58, 58, 58, 58, 58, 58, -61 + }, + + { + 11, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, 58, -62, -62, 58, 58, 58, 58, + + 58, 58, 98, 58, 58, 58, 58, 58, 58, 58, + 99, 58, 58, 58, 58, 58, 58, -62 + }, + + { + 11, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, 58, -63, -63, 58, 100, 58, 58, + 101, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -63 + }, + + { + 11, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, 58, -64, -64, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 102, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 103, -64 + + }, + + { + 11, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, 58, -65, -65, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -65 + }, + + { + 11, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, 58, -66, -66, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 104, 58, 58, -66 + }, + + { + 11, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, 58, -67, -67, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 105, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -67 + }, + + { + 11, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, 58, -68, -68, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 106, 58, + 58, 58, 58, 58, 58, 58, 58, -68 + }, + + { + 11, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, 58, -69, -69, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 107, 58, 58, -69 + + }, + + { + 11, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, 58, -70, -70, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 108, + 58, 58, 58, 58, 58, 58, 58, -70 + }, + + { + 11, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, 58, -71, -71, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 109, 58, + 58, 58, 58, 58, 58, 58, 58, -71 + }, + + { + 11, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, 58, -72, -72, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 110, 58, 58, 58, 58, 58, -72 + }, + + { + 11, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, 58, -73, -73, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 111, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -73 + }, + + { + 11, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, 58, -74, -74, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 112, 58, -74 + + }, + + { + 11, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, 58, -75, -75, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 113, 58, 58, 58, 58, -75 + }, + + { + 11, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, 58, -76, -76, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 114, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -76 + }, + + { + 11, 77, 77, -77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77 + }, + + { + 11, -78, 78, 79, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78 + }, + + { + 11, 80, -79, -79, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80 + + }, + + { + 11, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80 + }, + + { + 11, 81, 81, 82, 81, -81, 81, 81, -81, 81, + 81, 81, 81, 81, 81, -81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81 + }, + + { + 11, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82 + }, + + { + 11, -83, -83, 84, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83 + }, + + { + 11, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84 + + }, + + { + 11, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85 + }, + + { + 11, 86, 86, -86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86 + }, + + { + 11, -87, -87, -87, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, + + -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, -87 + }, + + { + 11, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, 115, 89, 89, -88, -88, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -88 + }, + + { + 11, -89, -89, -89, -89, -89, -89, -89, -89, -89, + -89, 89, 89, 89, -89, -89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -89 + + }, + + { + 11, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90 + }, + + { + 11, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, 89, 89, 89, -91, -91, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -91 + }, + + { + 11, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, 89, 89, 89, -92, -92, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -92 + }, + + { + 11, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93 + }, + + { + 11, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, 58, -94, -94, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 116, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -94 + + }, + + { + 11, -95, -95, -95, -95, -95, -95, -95, -95, -95, + -95, -95, -95, 58, -95, -95, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 117, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -95 + }, + + { + 11, -96, -96, -96, -96, -96, -96, -96, -96, -96, + -96, -96, -96, 58, -96, -96, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 118, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -96 + }, + + { + 11, -97, -97, -97, -97, -97, -97, -97, -97, -97, + -97, -97, -97, 58, -97, -97, 58, 58, 58, 58, + + 58, 58, 119, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -97 + }, + + { + 11, -98, -98, -98, -98, -98, -98, -98, -98, -98, + -98, -98, -98, 58, -98, -98, 120, 121, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -98 + }, + + { + 11, -99, -99, -99, -99, -99, -99, -99, -99, -99, + -99, -99, -99, 58, -99, -99, 58, 58, 58, 58, + 58, 122, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -99 + + }, + + { + 11, -100, -100, -100, -100, -100, -100, -100, -100, -100, + -100, -100, -100, 58, -100, -100, 58, 58, 123, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -100 + }, + + { + 11, -101, -101, -101, -101, -101, -101, -101, -101, -101, + -101, -101, -101, 58, -101, -101, 58, 58, 58, 124, + 58, 58, 58, 58, 58, 125, 58, 126, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -101 + }, + + { + 11, -102, -102, -102, -102, -102, -102, -102, -102, -102, + -102, -102, -102, 58, -102, -102, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 127, 58, 58, 58, 58, 58, 58, -102 + }, + + { + 11, -103, -103, -103, -103, -103, -103, -103, -103, -103, + -103, -103, -103, 58, -103, -103, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -103 + }, + + { + 11, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, 58, -104, -104, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -104 + + }, + + { + 11, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, 58, -105, -105, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 128, 58, + 58, 58, 58, 58, 58, 58, 58, -105 + }, + + { + 11, -106, -106, -106, -106, -106, -106, -106, -106, -106, + -106, -106, -106, 58, -106, -106, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 129, 58, -106 + }, + + { + 11, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, 58, -107, -107, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 130, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -107 + }, + + { + 11, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, 58, -108, -108, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 131, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -108 + }, + + { + 11, -109, -109, -109, -109, -109, -109, -109, -109, -109, + -109, -109, -109, 58, -109, -109, 58, 58, 58, 58, + 58, 58, 58, 132, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -109 + + }, + + { + 11, -110, -110, -110, -110, -110, -110, -110, -110, -110, + -110, -110, -110, 58, -110, -110, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 133, 58, -110 + }, + + { + 11, -111, -111, -111, -111, -111, -111, -111, -111, -111, + -111, -111, -111, 58, -111, -111, 58, 58, 58, 58, + 58, 134, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -111 + }, + + { + 11, -112, -112, -112, -112, -112, -112, -112, -112, -112, + -112, -112, -112, 58, -112, -112, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 135, 58, 58, 58, 58, -112 + }, + + { + 11, -113, -113, -113, -113, -113, -113, -113, -113, -113, + -113, -113, -113, 58, -113, -113, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -113 + }, + + { + 11, -114, -114, -114, -114, -114, -114, -114, -114, -114, + -114, -114, -114, 58, -114, -114, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 137, 58, 58, 58, -114 + + }, + + { + 11, -115, -115, -115, -115, -115, -115, -115, -115, -115, + -115, 89, 89, 89, -115, -115, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, -115 + }, + + { + 11, -116, -116, -116, -116, -116, -116, -116, -116, -116, + -116, -116, -116, 58, -116, -116, 58, 58, 58, 58, + 58, 138, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -116 + }, + + { + 11, -117, -117, -117, -117, -117, -117, -117, -117, -117, + -117, -117, -117, 58, -117, -117, 58, 58, 58, 139, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -117 + }, + + { + 11, -118, -118, -118, -118, -118, -118, -118, -118, -118, + -118, -118, -118, 58, -118, -118, 58, 58, 58, 58, + 58, 140, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -118 + }, + + { + 11, -119, -119, -119, -119, -119, -119, -119, -119, -119, + -119, -119, -119, 58, -119, -119, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 141, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -119 + + }, + + { + 11, -120, -120, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, 58, -120, -120, 58, 58, 142, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 143, 58, 58, -120 + }, + + { + 11, -121, -121, -121, -121, -121, -121, -121, -121, -121, + -121, -121, -121, 58, -121, -121, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 144, 58, -121 + }, + + { + 11, -122, -122, -122, -122, -122, -122, -122, -122, -122, + -122, -122, -122, 58, -122, -122, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 145, 58, + 58, 58, 58, 58, 58, 58, 58, -122 + }, + + { + 11, -123, -123, -123, -123, -123, -123, -123, -123, -123, + -123, -123, -123, 58, -123, -123, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 146, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -123 + }, + + { + 11, -124, -124, -124, -124, -124, -124, -124, -124, -124, + -124, -124, -124, 58, -124, -124, 58, 58, 58, 58, + 58, 58, 58, 58, 147, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -124 + + }, + + { + 11, -125, -125, -125, -125, -125, -125, -125, -125, -125, + -125, -125, -125, 58, -125, -125, 58, 58, 58, 58, + 58, 58, 148, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -125 + }, + + { + 11, -126, -126, -126, -126, -126, -126, -126, -126, -126, + -126, -126, -126, 58, -126, -126, 58, 58, 58, 58, + 58, 149, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -126 + }, + + { + 11, -127, -127, -127, -127, -127, -127, -127, -127, -127, + -127, -127, -127, 58, -127, -127, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -127 + }, + + { + 11, -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, 58, -128, -128, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 150, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -128 + }, + + { + 11, -129, -129, -129, -129, -129, -129, -129, -129, -129, + -129, -129, -129, 58, -129, -129, 58, 58, 58, 151, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -129 + + }, + + { + 11, -130, -130, -130, -130, -130, -130, -130, -130, -130, + -130, -130, -130, 58, -130, -130, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 152, + 58, 58, 58, 58, 58, 58, 58, -130 + }, + + { + 11, -131, -131, -131, -131, -131, -131, -131, -131, -131, + -131, -131, -131, 58, -131, -131, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 153, 58, 58, 58, 58, 58, 58, -131 + }, + + { + 11, -132, -132, -132, -132, -132, -132, -132, -132, -132, + -132, -132, -132, 58, -132, -132, 58, 58, 58, 58, + + 58, 154, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -132 + }, + + { + 11, -133, -133, -133, -133, -133, -133, -133, -133, -133, + -133, -133, -133, 58, -133, -133, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 155, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -133 + }, + + { + 11, -134, -134, -134, -134, -134, -134, -134, -134, -134, + -134, -134, -134, 58, -134, -134, 58, 58, 58, 156, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -134 + + }, + + { + 11, -135, -135, -135, -135, -135, -135, -135, -135, -135, + -135, -135, -135, 58, -135, -135, 58, 58, 58, 157, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -135 + }, + + { + 11, -136, -136, -136, -136, -136, -136, -136, -136, -136, + -136, -136, -136, 58, -136, -136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 158, 58, + 58, 58, 58, 58, 58, 58, 58, -136 + }, + + { + 11, -137, -137, -137, -137, -137, -137, -137, -137, -137, + -137, -137, -137, 58, -137, -137, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 159, 58, 58, -137 + }, + + { + 11, -138, -138, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, 58, -138, -138, 58, 160, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -138 + }, + + { + 11, -139, -139, -139, -139, -139, -139, -139, -139, -139, + -139, -139, -139, 58, -139, -139, 58, 58, 58, 58, + 58, 161, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -139 + + }, + + { + 11, -140, -140, -140, -140, -140, -140, -140, -140, -140, + -140, -140, -140, 58, -140, -140, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 162, 58, + 58, 58, 58, 58, 58, 58, 58, -140 + }, + + { + 11, -141, -141, -141, -141, -141, -141, -141, -141, -141, + -141, -141, -141, 58, -141, -141, 58, 58, 58, 58, + 58, 58, 58, 163, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -141 + }, + + { + 11, -142, -142, -142, -142, -142, -142, -142, -142, -142, + -142, -142, -142, 58, -142, -142, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 164, + 58, 58, 58, 58, 58, 58, 58, -142 + }, + + { + 11, -143, -143, -143, -143, -143, -143, -143, -143, -143, + -143, -143, -143, 58, -143, -143, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 165, 58, 58, 58, 58, -143 + }, + + { + 11, -144, -144, -144, -144, -144, -144, -144, -144, -144, + -144, -144, -144, 58, -144, -144, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 166, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -144 + + }, + + { + 11, -145, -145, -145, -145, -145, -145, -145, -145, -145, + -145, -145, -145, 58, -145, -145, 58, 58, 58, 58, + 167, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -145 + }, + + { + 11, -146, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, 58, -146, -146, 58, 58, 58, 58, + 58, 168, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -146 + }, + + { + 11, -147, -147, -147, -147, -147, -147, -147, -147, -147, + -147, -147, -147, 58, -147, -147, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 169, + 58, 58, 58, 58, 58, 58, 58, -147 + }, + + { + 11, -148, -148, -148, -148, -148, -148, -148, -148, -148, + -148, -148, -148, 58, -148, -148, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -148 + }, + + { + 11, -149, -149, -149, -149, -149, -149, -149, -149, -149, + -149, -149, -149, 58, -149, -149, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 170, 58, + 58, 58, 58, 58, 58, 58, 58, -149 + + }, + + { + 11, -150, -150, -150, -150, -150, -150, -150, -150, -150, + -150, -150, -150, 58, -150, -150, 58, 58, 58, 58, + 58, 171, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -150 + }, + + { + 11, -151, -151, -151, -151, -151, -151, -151, -151, -151, + -151, -151, -151, 58, -151, -151, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 172, + 58, 58, 58, 58, 58, 58, 58, -151 + }, + + { + 11, -152, -152, -152, -152, -152, -152, -152, -152, -152, + -152, -152, -152, 58, -152, -152, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 173, 58, + 58, 58, 58, 58, 58, 58, 58, -152 + }, + + { + 11, -153, -153, -153, -153, -153, -153, -153, -153, -153, + -153, -153, -153, 58, -153, -153, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 174, 58, 58, -153 + }, + + { + 11, -154, -154, -154, -154, -154, -154, -154, -154, -154, + -154, -154, -154, 58, -154, -154, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -154 + + }, + + { + 11, -155, -155, -155, -155, -155, -155, -155, -155, -155, + -155, -155, -155, 58, -155, -155, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 175, 58, 58, 58, 58, -155 + }, + + { + 11, -156, -156, -156, -156, -156, -156, -156, -156, -156, + -156, -156, -156, 58, -156, -156, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 176, 58, 58, -156 + }, + + { + 11, -157, -157, -157, -157, -157, -157, -157, -157, -157, + -157, -157, -157, 58, -157, -157, 58, 58, 58, 58, + + 58, 177, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -157 + }, + + { + 11, -158, -158, -158, -158, -158, -158, -158, -158, -158, + -158, -158, -158, 58, -158, -158, 58, 58, 58, 58, + 58, 58, 58, 178, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -158 + }, + + { + 11, -159, -159, -159, -159, -159, -159, -159, -159, -159, + -159, -159, -159, 58, -159, -159, 58, 179, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -159 + + }, + + { + 11, -160, -160, -160, -160, -160, -160, -160, -160, -160, + -160, -160, -160, 58, -160, -160, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 180, 58, + 58, 58, 58, 58, 58, 58, 58, -160 + }, + + { + 11, -161, -161, -161, -161, -161, -161, -161, -161, -161, + -161, -161, -161, 58, -161, -161, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -161 + }, + + { + 11, -162, -162, -162, -162, -162, -162, -162, -162, -162, + -162, -162, -162, 58, -162, -162, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 181, 58, 58, -162 + }, + + { + 11, -163, -163, -163, -163, -163, -163, -163, -163, -163, + -163, -163, -163, 58, -163, -163, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -163 + }, + + { + 11, -164, -164, -164, -164, -164, -164, -164, -164, -164, + -164, -164, -164, 58, -164, -164, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 182, + 58, 58, 58, 58, 58, 58, 58, -164 + + }, + + { + 11, -165, -165, -165, -165, -165, -165, -165, -165, -165, + -165, -165, -165, 58, -165, -165, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 183, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -165 + }, + + { + 11, -166, -166, -166, -166, -166, -166, -166, -166, -166, + -166, -166, -166, 58, -166, -166, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 184, 58, 58, -166 + }, + + { + 11, -167, -167, -167, -167, -167, -167, -167, -167, -167, + -167, -167, -167, 58, -167, -167, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 185, 58, 58, 58, -167 + }, + + { + 11, -168, -168, -168, -168, -168, -168, -168, -168, -168, + -168, -168, -168, 58, -168, -168, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -168 + }, + + { + 11, -169, -169, -169, -169, -169, -169, -169, -169, -169, + -169, -169, -169, 58, -169, -169, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 186, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -169 + + }, + + { + 11, -170, -170, -170, -170, -170, -170, -170, -170, -170, + -170, -170, -170, 58, -170, -170, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 187, 58, -170 + }, + + { + 11, -171, -171, -171, -171, -171, -171, -171, -171, -171, + -171, -171, -171, 58, -171, -171, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 188, 58, + 58, 58, 58, 58, 58, 58, 58, -171 + }, + + { + 11, -172, -172, -172, -172, -172, -172, -172, -172, -172, + -172, -172, -172, 58, -172, -172, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 189, 58, + 58, 58, 58, 58, 58, 58, 58, -172 + }, + + { + 11, -173, -173, -173, -173, -173, -173, -173, -173, -173, + -173, -173, -173, 58, -173, -173, 58, 190, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -173 + }, + + { + 11, -174, -174, -174, -174, -174, -174, -174, -174, -174, + -174, -174, -174, 58, -174, -174, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -174 + + }, + + { + 11, -175, -175, -175, -175, -175, -175, -175, -175, -175, + -175, -175, -175, 58, -175, -175, 58, 58, 58, 58, + 58, 191, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -175 + }, + + { + 11, -176, -176, -176, -176, -176, -176, -176, -176, -176, + -176, -176, -176, 58, -176, -176, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -176 + }, + + { + 11, -177, -177, -177, -177, -177, -177, -177, -177, -177, + -177, -177, -177, 58, -177, -177, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -177 + }, + + { + 11, -178, -178, -178, -178, -178, -178, -178, -178, -178, + -178, -178, -178, 58, -178, -178, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -178 + }, + + { + 11, -179, -179, -179, -179, -179, -179, -179, -179, -179, + -179, -179, -179, 58, -179, -179, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 192, 58, 58, -179 + + }, + + { + 11, -180, -180, -180, -180, -180, -180, -180, -180, -180, + -180, -180, -180, 58, -180, -180, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -180 + }, + + { + 11, -181, -181, -181, -181, -181, -181, -181, -181, -181, + -181, -181, -181, 58, -181, -181, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -181 + }, + + { + 11, -182, -182, -182, -182, -182, -182, -182, -182, -182, + -182, -182, -182, 58, -182, -182, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 193, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -182 + }, + + { + 11, -183, -183, -183, -183, -183, -183, -183, -183, -183, + -183, -183, -183, 58, -183, -183, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 194, 58, 58, 58, -183 + }, + + { + 11, -184, -184, -184, -184, -184, -184, -184, -184, -184, + -184, -184, -184, 58, -184, -184, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -184 + + }, + + { + 11, -185, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, 58, -185, -185, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -185 + }, + + { + 11, -186, -186, -186, -186, -186, -186, -186, -186, -186, + -186, -186, -186, 58, -186, -186, 58, 58, 58, 195, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -186 + }, + + { + 11, -187, -187, -187, -187, -187, -187, -187, -187, -187, + -187, -187, -187, 58, -187, -187, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -187 + }, + + { + 11, -188, -188, -188, -188, -188, -188, -188, -188, -188, + -188, -188, -188, 58, -188, -188, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 196, 58, -188 + }, + + { + 11, -189, -189, -189, -189, -189, -189, -189, -189, -189, + -189, -189, -189, 58, -189, -189, 58, 58, 58, 58, + 58, 58, 197, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -189 + + }, + + { + 11, -190, -190, -190, -190, -190, -190, -190, -190, -190, + -190, -190, -190, 58, -190, -190, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 198, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -190 + }, + + { + 11, -191, -191, -191, -191, -191, -191, -191, -191, -191, + -191, -191, -191, 58, -191, -191, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 199, 58, 58, 58, -191 + }, + + { + 11, -192, -192, -192, -192, -192, -192, -192, -192, -192, + -192, -192, -192, 58, -192, -192, 58, 58, 58, 58, + + 58, 200, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -192 + }, + + { + 11, -193, -193, -193, -193, -193, -193, -193, -193, -193, + -193, -193, -193, 58, -193, -193, 58, 58, 58, 58, + 58, 201, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -193 + }, + + { + 11, -194, -194, -194, -194, -194, -194, -194, -194, -194, + -194, -194, -194, 58, -194, -194, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 202, 58, 58, -194 + + }, + + { + 11, -195, -195, -195, -195, -195, -195, -195, -195, -195, + -195, -195, -195, 58, -195, -195, 58, 58, 58, 58, + 58, 203, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -195 + }, + + { + 11, -196, -196, -196, -196, -196, -196, -196, -196, -196, + -196, -196, -196, 58, -196, -196, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -196 + }, + + { + 11, -197, -197, -197, -197, -197, -197, -197, -197, -197, + -197, -197, -197, 58, -197, -197, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 204, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -197 + }, + + { + 11, -198, -198, -198, -198, -198, -198, -198, -198, -198, + -198, -198, -198, 58, -198, -198, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -198 + }, + + { + 11, -199, -199, -199, -199, -199, -199, -199, -199, -199, + -199, -199, -199, 58, -199, -199, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -199 + + }, + + { + 11, -200, -200, -200, -200, -200, -200, -200, -200, -200, + -200, -200, -200, 58, -200, -200, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -200 + }, + + { + 11, -201, -201, -201, -201, -201, -201, -201, -201, -201, + -201, -201, -201, 58, -201, -201, 58, 205, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -201 + }, + + { + 11, -202, -202, -202, -202, -202, -202, -202, -202, -202, + -202, -202, -202, 58, -202, -202, 58, 206, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -202 + }, + + { + 11, -203, -203, -203, -203, -203, -203, -203, -203, -203, + -203, -203, -203, 58, -203, -203, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -203 + }, + + { + 11, -204, -204, -204, -204, -204, -204, -204, -204, -204, + -204, -204, -204, 58, -204, -204, 58, 58, 58, 58, + 58, 58, 58, 207, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -204 + + }, + + { + 11, -205, -205, -205, -205, -205, -205, -205, -205, -205, + -205, -205, -205, 58, -205, -205, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 208, 58, + 58, 58, 58, 58, 58, 58, 58, -205 + }, + + { + 11, -206, -206, -206, -206, -206, -206, -206, -206, -206, + -206, -206, -206, 58, -206, -206, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 209, 58, 58, -206 + }, + + { + 11, -207, -207, -207, -207, -207, -207, -207, -207, -207, + -207, -207, -207, 58, -207, -207, 58, 58, 58, 58, + + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -207 + }, + + { + 11, -208, -208, -208, -208, -208, -208, -208, -208, -208, + -208, -208, -208, 58, -208, -208, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -208 + }, + + { + 11, -209, -209, -209, -209, -209, -209, -209, -209, -209, + -209, -209, -209, 58, -209, -209, 58, 58, 58, 58, + 58, 210, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -209 + + }, + + { + 11, -210, -210, -210, -210, -210, -210, -210, -210, -210, + -210, -210, -210, 58, -210, -210, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, -210 + }, + + } ; + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up zconftext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + zconfleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[211] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 65, 5, 4, 3, 2, 36, 37, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 63, 60, 62, 55, 59, 58, 57, 53, 48, 42, + 47, 51, 53, 40, 41, 50, 50, 43, 53, 50, + 50, 53, 4, 3, 2, 2, 1, 35, 35, 35, + 35, 35, 35, 35, 16, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 63, 60, 62, 61, + 55, 54, 57, 56, 44, 51, 38, 50, 50, 52, + 45, 46, 39, 35, 35, 35, 35, 35, 35, 35, + + 35, 35, 30, 29, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 49, 25, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 15, 35, 7, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 17, 35, 35, + 35, 35, 35, 34, 35, 35, 35, 35, 35, 35, + 10, 35, 13, 35, 35, 35, 35, 33, 35, 35, + 35, 35, 35, 22, 35, 32, 9, 31, 35, 26, + 12, 35, 35, 21, 18, 35, 8, 35, 35, 35, + 35, 35, 27, 35, 35, 6, 35, 20, 19, 23, + + 35, 35, 11, 35, 35, 35, 14, 28, 35, 24 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, + 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 1, 15, 1, 1, 16, 1, 17, 18, 19, 20, + + 21, 22, 23, 24, 25, 13, 13, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 13, 13, 36, + 13, 13, 1, 37, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +extern int zconf_flex_debug; +int zconf_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *zconftext; + +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define START_STRSIZE 16 + +char *text; +static char *text_ptr; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static struct buffer *zconf_endfile(void); + +void new_string(void) +{ + text = malloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_ptr = text; + text_size = 0; + *text_ptr = 0; +} + +void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + text = realloc(text, new_size); + text_asize = new_size; + text_ptr = text + text_size; + } + memcpy(text_ptr, str, size); + text_ptr += size; + text_size += size; + *text_ptr = 0; +} + +void alloc_string(const char *str, int size) +{ + text = malloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +#define INITIAL 0 +#define COMMAND 1 +#define HELP 2 +#define STRING 3 +#define PARAM 4 + +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int zconfwrap (void ); +#else +extern int zconfwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + errno=0; \ + while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(zconfin); \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int zconflex (void); + +#define YY_DECL int zconflex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after zconftext and zconfleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + int str = 0; + int ts, i; + + if ( (yy_init) ) + { + (yy_init) = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! zconfin ) + zconfin = stdin; + + if ( ! zconfout ) + zconfout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of zconftext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) + ++yy_cp; + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 2: +YY_RULE_SETUP + + YY_BREAK +case 3: +/* rule 3 can match eol */ +YY_RULE_SETUP +current_file->lineno++; return T_EOL; + YY_BREAK +case 4: +YY_RULE_SETUP +{ + BEGIN(COMMAND); +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ + unput(zconftext[0]); + BEGIN(COMMAND); +} + YY_BREAK + +case 6: +YY_RULE_SETUP +BEGIN(PARAM); return T_MAINMENU; + YY_BREAK +case 7: +YY_RULE_SETUP +BEGIN(PARAM); return T_MENU; + YY_BREAK +case 8: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDMENU; + YY_BREAK +case 9: +YY_RULE_SETUP +BEGIN(PARAM); return T_SOURCE; + YY_BREAK +case 10: +YY_RULE_SETUP +BEGIN(PARAM); return T_CHOICE; + YY_BREAK +case 11: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDCHOICE; + YY_BREAK +case 12: +YY_RULE_SETUP +BEGIN(PARAM); return T_COMMENT; + YY_BREAK +case 13: +YY_RULE_SETUP +BEGIN(PARAM); return T_CONFIG; + YY_BREAK +case 14: +YY_RULE_SETUP +BEGIN(PARAM); return T_MENUCONFIG; + YY_BREAK +case 15: +YY_RULE_SETUP +BEGIN(PARAM); return T_HELP; + YY_BREAK +case 16: +YY_RULE_SETUP +BEGIN(PARAM); return T_IF; + YY_BREAK +case 17: +YY_RULE_SETUP +BEGIN(PARAM); return T_ENDIF; + YY_BREAK +case 18: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEPENDS; + YY_BREAK +case 19: +YY_RULE_SETUP +BEGIN(PARAM); return T_REQUIRES; + YY_BREAK +case 20: +YY_RULE_SETUP +BEGIN(PARAM); return T_OPTIONAL; + YY_BREAK +case 21: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEFAULT; + YY_BREAK +case 22: +YY_RULE_SETUP +BEGIN(PARAM); return T_PROMPT; + YY_BREAK +case 23: +YY_RULE_SETUP +BEGIN(PARAM); return T_TRISTATE; + YY_BREAK +case 24: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_TRISTATE; + YY_BREAK +case 25: +YY_RULE_SETUP +BEGIN(PARAM); return T_BOOLEAN; + YY_BREAK +case 26: +YY_RULE_SETUP +BEGIN(PARAM); return T_BOOLEAN; + YY_BREAK +case 27: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_BOOLEAN; + YY_BREAK +case 28: +YY_RULE_SETUP +BEGIN(PARAM); return T_DEF_BOOLEAN; + YY_BREAK +case 29: +YY_RULE_SETUP +BEGIN(PARAM); return T_INT; + YY_BREAK +case 30: +YY_RULE_SETUP +BEGIN(PARAM); return T_HEX; + YY_BREAK +case 31: +YY_RULE_SETUP +BEGIN(PARAM); return T_STRING; + YY_BREAK +case 32: +YY_RULE_SETUP +BEGIN(PARAM); return T_SELECT; + YY_BREAK +case 33: +YY_RULE_SETUP +BEGIN(PARAM); return T_SELECT; + YY_BREAK +case 34: +YY_RULE_SETUP +BEGIN(PARAM); return T_RANGE; + YY_BREAK +case 35: +YY_RULE_SETUP +{ + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 36: +YY_RULE_SETUP + + YY_BREAK +case 37: +/* rule 37 can match eol */ +YY_RULE_SETUP +current_file->lineno++; BEGIN(INITIAL); + YY_BREAK + +case 38: +YY_RULE_SETUP +return T_AND; + YY_BREAK +case 39: +YY_RULE_SETUP +return T_OR; + YY_BREAK +case 40: +YY_RULE_SETUP +return T_OPEN_PAREN; + YY_BREAK +case 41: +YY_RULE_SETUP +return T_CLOSE_PAREN; + YY_BREAK +case 42: +YY_RULE_SETUP +return T_NOT; + YY_BREAK +case 43: +YY_RULE_SETUP +return T_EQUAL; + YY_BREAK +case 44: +YY_RULE_SETUP +return T_UNEQUAL; + YY_BREAK +case 45: +YY_RULE_SETUP +return T_IF; + YY_BREAK +case 46: +YY_RULE_SETUP +return T_ON; + YY_BREAK +case 47: +YY_RULE_SETUP +{ + str = zconftext[0]; + new_string(); + BEGIN(STRING); + } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +BEGIN(INITIAL); current_file->lineno++; return T_EOL; + YY_BREAK +case 49: +YY_RULE_SETUP +/* ignore */ + YY_BREAK +case 50: +YY_RULE_SETUP +{ + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 51: +YY_RULE_SETUP +/* comment */ + YY_BREAK +case 52: +/* rule 52 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 53: +YY_RULE_SETUP + + YY_BREAK +case YY_STATE_EOF(PARAM): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 54: +/* rule 54 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 55: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + } + YY_BREAK +case 56: +/* rule 56 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 57: +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + } + YY_BREAK +case 58: +YY_RULE_SETUP +{ + if (str == zconftext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(zconftext, 1); + } + YY_BREAK +case 59: +/* rule 59 can match eol */ +YY_RULE_SETUP +{ + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + YY_BREAK +case YY_STATE_EOF(STRING): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 60: +YY_RULE_SETUP +{ + ts = 0; + for (i = 0; i < zconfleng; i++) { + if (zconftext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + YY_BREAK +case 61: +/* rule 61 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK +case 62: +/* rule 62 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + append_string("\n", 1); + } + YY_BREAK +case 63: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + if (!first_ts) + first_ts = last_ts; + } + YY_BREAK +case YY_STATE_EOF(HELP): +{ + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMAND): +{ + if (current_buf) { + zconf_endfile(); + return T_EOF; + } + fclose(zconfin); + yyterminate(); +} + YY_BREAK +case 64: +YY_RULE_SETUP +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed zconfin at a new source and called + * zconflex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( zconfwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * zconftext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of zconflex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + zconfrestart(zconfin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + + yy_current_state = yy_nxt[yy_current_state][1]; + yy_is_jam = (yy_current_state <= 0); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up zconftext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + zconfrestart(zconfin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( zconfwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve zconftext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void zconfrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); + zconf_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * zconfpop_buffer_state(); + * zconfpush_buffer_state(new_buffer); + */ + zconfensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + zconf_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (zconfwrap()) processing, but the only time this flag + * is looked at is after zconfwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void zconf_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + zconf_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with zconf_create_buffer() + * + */ + void zconf_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + zconffree((void *) b->yy_ch_buf ); + + zconffree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a zconfrestart() or at EOF. + */ + static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + zconf_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then zconf_init_buffer was _probably_ + * called from zconfrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void zconf_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + zconf_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + zconfensure_buffer_stack(); + + /* This block is copied from zconf_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from zconf_switch_to_buffer. */ + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void zconfpop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void zconfensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + zconf_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to zconflex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * zconf_scan_bytes() instead. + */ +YY_BUFFER_STATE zconf_scan_string (yyconst char * str ) +{ + + return zconf_scan_bytes(str,strlen(str) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) zconfalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = zconf_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + zconftext[zconfleng] = (yy_hold_char); \ + (yy_c_buf_p) = zconftext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + zconfleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int zconfget_lineno (void) +{ + + return zconflineno; +} + +/** Get the input stream. + * + */ +FILE *zconfget_in (void) +{ + return zconfin; +} + +/** Get the output stream. + * + */ +FILE *zconfget_out (void) +{ + return zconfout; +} + +/** Get the length of the current token. + * + */ +int zconfget_leng (void) +{ + return zconfleng; +} + +/** Get the current token. + * + */ + +char *zconfget_text (void) +{ + return zconftext; +} + +/** Set the current line number. + * @param line_number + * + */ +void zconfset_lineno (int line_number ) +{ + + zconflineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see zconf_switch_to_buffer + */ +void zconfset_in (FILE * in_str ) +{ + zconfin = in_str ; +} + +void zconfset_out (FILE * out_str ) +{ + zconfout = out_str ; +} + +int zconfget_debug (void) +{ + return zconf_flex_debug; +} + +void zconfset_debug (int bdebug ) +{ + zconf_flex_debug = bdebug ; +} + +/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ +int zconflex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + zconfpop_buffer_state(); + } + + /* Destroy the stack itself. */ + zconffree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *zconfalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *zconfrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void zconffree (void * ptr ) +{ + free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef yytext_ptr +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = malloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; + current_file->flags = FILE_BUSY; +} + +void zconf_nextfile(const char *name) +{ + struct file *file = file_lookup(name); + struct buffer *buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", name); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", name); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +static struct buffer *zconf_endfile(void) +{ + struct buffer *parent; + + current_file->flags |= FILE_SCANNED; + current_file->flags &= ~FILE_BUSY; + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(zconfin); + zconf_delete_buffer(YY_CURRENT_BUFFER); + zconf_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; + + return parent; +} + +int zconf_lineno(void) +{ + if (current_buf) + return current_file->lineno - 1; + else + return 0; +} + +char *zconf_curname(void) +{ + if (current_buf) + return current_file->name; + else + return ""; +} + diff --git a/user/mpy/lib/axtls/config/scripts/config/lkc.h b/user/mpy/lib/axtls/config/scripts/config/lkc.h new file mode 100644 index 0000000..b8a67fc --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lkc.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef LKC_H +#define LKC_H + +#include "expr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LKC_DIRECT_LINK +#define P(name,type,arg) extern type name arg +#else +#include "lkc_defs.h" +#define P(name,type,arg) extern type (*name ## _p) arg +#endif +#include "lkc_proto.h" +#undef P + +#define SRCTREE "srctree" + +int zconfparse(void); +void zconfdump(FILE *out); + +extern int zconfdebug; +void zconf_starthelp(void); +FILE *zconf_fopen(const char *name); +void zconf_initscan(const char *name); +void zconf_nextfile(const char *name); +int zconf_lineno(void); +char *zconf_curname(void); + +/* confdata.c */ +extern const char conf_def_filename[]; +extern char conf_filename[]; + +char *conf_get_default_confname(void); + +/* kconfig_load.c */ +void kconfig_load(void); + +/* menu.c */ +void menu_init(void); +void menu_add_menu(void); +void menu_end_menu(void); +void menu_add_entry(struct symbol *sym); +void menu_end_entry(void); +void menu_add_dep(struct expr *dep); +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); +void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); +void menu_finalize(struct menu *parent); +void menu_set_type(int type); + +/* util.c */ +struct file *file_lookup(const char *name); +int file_write_dep(const char *name); + +struct gstr { + size_t len; + char *s; +}; +struct gstr str_new(void); +struct gstr str_assign(const char *s); +void str_free(struct gstr *gs); +void str_append(struct gstr *gs, const char *s); +void str_printf(struct gstr *gs, const char *fmt, ...); +const char *str_get(struct gstr *gs); + +/* symbol.c */ +void sym_init(void); +void sym_clear_all_valid(void); +void sym_set_changed(struct symbol *sym); +struct symbol *sym_check_deps(struct symbol *sym); +struct property *prop_alloc(enum prop_type type, struct symbol *sym); +struct symbol *prop_get_symbol(struct property *prop); + +static inline tristate sym_get_tristate_value(struct symbol *sym) +{ + return sym->curr.tri; +} + + +static inline struct symbol *sym_get_choice_value(struct symbol *sym) +{ + return (struct symbol *)sym->curr.val; +} + +static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) +{ + return sym_set_tristate_value(chval, yes); +} + +static inline bool sym_is_choice(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICE ? true : false; +} + +static inline bool sym_is_choice_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICEVAL ? true : false; +} + +static inline bool sym_is_optional(struct symbol *sym) +{ + return sym->flags & SYMBOL_OPTIONAL ? true : false; +} + +static inline bool sym_has_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_NEW ? false : true; +} + +#ifdef __cplusplus +} +#endif + +#endif /* LKC_H */ diff --git a/user/mpy/lib/axtls/config/scripts/config/lkc_proto.h b/user/mpy/lib/axtls/config/scripts/config/lkc_proto.h new file mode 100644 index 0000000..6dc6d0c --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lkc_proto.h @@ -0,0 +1,40 @@ + +/* confdata.c */ +P(conf_parse,void,(const char *name)); +P(conf_read,int,(const char *name)); +P(conf_write,int,(const char *name)); + +/* menu.c */ +P(rootmenu,struct menu,); + +P(menu_is_visible,bool,(struct menu *menu)); +P(menu_get_prompt,const char *,(struct menu *menu)); +P(menu_get_root_menu,struct menu *,(struct menu *menu)); +P(menu_get_parent_menu,struct menu *,(struct menu *menu)); + +/* symbol.c */ +P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); +P(sym_change_count,int,); + +P(sym_lookup,struct symbol *,(const char *name, int isconst)); +P(sym_find,struct symbol *,(const char *name)); +P(sym_re_search,struct symbol **,(const char *pattern)); +P(sym_type_name,const char *,(enum symbol_type type)); +P(sym_calc_value,void,(struct symbol *sym)); +P(sym_get_type,enum symbol_type,(struct symbol *sym)); +P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); +P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); +P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); +P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); +P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); +P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); +P(sym_is_changable,bool,(struct symbol *sym)); +P(sym_get_choice_prop,struct property *,(struct symbol *sym)); +P(sym_get_default_prop,struct property *,(struct symbol *sym)); +P(sym_get_string_value,const char *,(struct symbol *sym)); + +P(prop_get_type_name,const char *,(enum prop_type type)); + +/* expr.c */ +P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); +P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)); diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING b/user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING new file mode 100644 index 0000000..a8999d8 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING @@ -0,0 +1,4 @@ +This is NOT the official version of dialog. This version has been +significantly modified from the original. It is for use by the Linux +kernel configuration script. Please do not bother Savio Lam with +questions about this program. diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c new file mode 100644 index 0000000..71de4a1 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c @@ -0,0 +1,372 @@ +/* + * checklist.c -- implements the checklist box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension + * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static int list_width, check_x, item_x, checkflag; + +/* + * Print list item + */ +static void +print_item (WINDOW * win, const char *item, int status, + int choice, int selected) +{ + int i; + + /* Clear 'residue' of last item */ + wattrset (win, menubox_attr); + wmove (win, choice, 0); + for (i = 0; i < list_width; i++) + waddch (win, ' '); + + wmove (win, choice, check_x); + wattrset (win, selected ? check_selected_attr : check_attr); + if (checkflag == FLAG_CHECK) + wprintw (win, "[%c]", status ? 'X' : ' '); + else + wprintw (win, "(%c)", status ? 'X' : ' '); + + wattrset (win, selected ? tag_selected_attr : tag_attr); + mvwaddch(win, choice, item_x, item[0]); + wattrset (win, selected ? item_selected_attr : item_attr); + waddstr (win, (char *)item+1); + if (selected) { + wmove (win, choice, check_x+1); + wrefresh (win); + } +} + +/* + * Print the scroll indicators. + */ +static void +print_arrows (WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) +{ + wmove(win, y, x); + + if (scroll > 0) { + wattrset (win, uarrow_attr); + waddch (win, ACS_UARROW); + waddstr (win, "(-)"); + } + else { + wattrset (win, menubox_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset (win, darrow_attr); + waddch (win, ACS_DARROW); + waddstr (win, "(+)"); + } + else { + wattrset (win, menubox_border_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } +} + +/* + * Display the termination buttons + */ +static void +print_buttons( WINDOW *dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button (dialog, "Select", y, x, selected == 0); + print_button (dialog, " Help ", y, x + 14, selected == 1); + + wmove(dialog, y, x+1 + 14*selected); + wrefresh (dialog); +} + +/* + * Display a dialog box with a list of options that can be turned on or off + * The `flag' parameter is used to select between radiolist and checklist. + */ +int +dialog_checklist (const char *title, const char *prompt, int height, int width, + int list_height, int item_no, struct dialog_list_item ** items, + int flag) + +{ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; + WINDOW *dialog, *list; + + checkflag = flag; + + /* Allocate space for storing item on/off status */ + if ((status = malloc (sizeof (int) * item_no)) == NULL) { + endwin (); + fprintf (stderr, + "\nCan't allocate memory in dialog_checklist().\n"); + exit (-1); + } + + /* Initializes status */ + for (i = 0; i < item_no; i++) { + status[i] = (items[i]->selected == 1); /* ON */ + if ((!choice && status[i]) || items[i]->selected == 2) /* SELECTED */ + choice = i + 1; + } + if (choice) + choice--; + + max_choice = MIN (list_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1); + + keypad (list, TRUE); + + /* draw a box around the list items */ + draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, + menubox_border_attr, menubox_attr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + for (i = 0; i < item_no; i++) + check_x = MAX (check_x, + strlen (items[i]->name) + 4); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + print_item (list, items[scroll + i]->name, + status[i+scroll], i, i == choice); + } + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh (list); + wnoutrefresh (dialog); + doupdate (); + + while (key != ESC) { + key = wgetch (dialog); + + for (i = 0; i < max_choice; i++) + if (toupper(key) == toupper(items[scroll + i]->name[0])) + break; + + + if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-' ) { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + print_item (list, items[scroll]->name, + status[scroll], 0, FALSE); + scrollok (list, TRUE); + wscrl (list, -1); + scrollok (list, FALSE); + } + scroll--; + print_item (list, items[scroll]->name, + status[scroll], 0, TRUE); + wnoutrefresh (list); + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + wrefresh (dialog); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_no - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + print_item (list, items[scroll + max_choice - 1]->name, + status[scroll + max_choice - 1], + max_choice - 1, FALSE); + scrollok (list, TRUE); + scroll (list); + scrollok (list, FALSE); + } + scroll++; + print_item (list, items[scroll + max_choice - 1]->name, + status[scroll + max_choice - 1], + max_choice - 1, TRUE); + wnoutrefresh (list); + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + wrefresh (dialog); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + print_item (list, items[scroll + choice]->name, + status[scroll + choice], choice, FALSE); + /* Highlight new item */ + choice = i; + print_item (list, items[scroll + choice]->name, + status[scroll + choice], choice, TRUE); + wnoutrefresh (list); + wrefresh (dialog); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + for (i = 0; i < item_no; i++) + items[i]->selected = 0; + items[scroll + choice]->selected = 1; + delwin (dialog); + free (status); + return 1; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh (dialog); + break; + case 'S': + case 's': + case ' ': + case '\n': + if (!button) { + if (flag == FLAG_CHECK) { + status[scroll + choice] = !status[scroll + choice]; + wmove (list, choice, check_x); + wattrset (list, check_selected_attr); + wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); + } else { + if (!status[scroll + choice]) { + for (i = 0; i < item_no; i++) + status[i] = 0; + status[scroll + choice] = 1; + for (i = 0; i < max_choice; i++) + print_item (list, items[scroll + i]->name, + status[scroll + i], i, i == choice); + } + } + wnoutrefresh (list); + wrefresh (dialog); + + for (i = 0; i < item_no; i++) { + items[i]->selected = status[i]; + } + } else { + for (i = 0; i < item_no; i++) + items[i]->selected = 0; + items[scroll + choice]->selected = 1; + } + delwin (dialog); + free (status); + return button; + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + + /* Now, update everything... */ + doupdate (); + } + + + delwin (dialog); + free (status); + return -1; /* ESC pressed */ +} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h b/user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h new file mode 100644 index 0000000..d34dd37 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h @@ -0,0 +1,161 @@ +/* + * colors.h -- color attribute definitions + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * Default color definitions + * + * *_FG = foreground + * *_BG = background + * *_HL = highlight? + */ +#define SCREEN_FG COLOR_CYAN +#define SCREEN_BG COLOR_BLUE +#define SCREEN_HL TRUE + +#define SHADOW_FG COLOR_BLACK +#define SHADOW_BG COLOR_BLACK +#define SHADOW_HL TRUE + +#define DIALOG_FG COLOR_BLACK +#define DIALOG_BG COLOR_WHITE +#define DIALOG_HL FALSE + +#define TITLE_FG COLOR_YELLOW +#define TITLE_BG COLOR_WHITE +#define TITLE_HL TRUE + +#define BORDER_FG COLOR_WHITE +#define BORDER_BG COLOR_WHITE +#define BORDER_HL TRUE + +#define BUTTON_ACTIVE_FG COLOR_WHITE +#define BUTTON_ACTIVE_BG COLOR_BLUE +#define BUTTON_ACTIVE_HL TRUE + +#define BUTTON_INACTIVE_FG COLOR_BLACK +#define BUTTON_INACTIVE_BG COLOR_WHITE +#define BUTTON_INACTIVE_HL FALSE + +#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE +#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE +#define BUTTON_KEY_ACTIVE_HL TRUE + +#define BUTTON_KEY_INACTIVE_FG COLOR_RED +#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE +#define BUTTON_KEY_INACTIVE_HL FALSE + +#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW +#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE +#define BUTTON_LABEL_ACTIVE_HL TRUE + +#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK +#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE +#define BUTTON_LABEL_INACTIVE_HL TRUE + +#define INPUTBOX_FG COLOR_BLACK +#define INPUTBOX_BG COLOR_WHITE +#define INPUTBOX_HL FALSE + +#define INPUTBOX_BORDER_FG COLOR_BLACK +#define INPUTBOX_BORDER_BG COLOR_WHITE +#define INPUTBOX_BORDER_HL FALSE + +#define SEARCHBOX_FG COLOR_BLACK +#define SEARCHBOX_BG COLOR_WHITE +#define SEARCHBOX_HL FALSE + +#define SEARCHBOX_TITLE_FG COLOR_YELLOW +#define SEARCHBOX_TITLE_BG COLOR_WHITE +#define SEARCHBOX_TITLE_HL TRUE + +#define SEARCHBOX_BORDER_FG COLOR_WHITE +#define SEARCHBOX_BORDER_BG COLOR_WHITE +#define SEARCHBOX_BORDER_HL TRUE + +#define POSITION_INDICATOR_FG COLOR_YELLOW +#define POSITION_INDICATOR_BG COLOR_WHITE +#define POSITION_INDICATOR_HL TRUE + +#define MENUBOX_FG COLOR_BLACK +#define MENUBOX_BG COLOR_WHITE +#define MENUBOX_HL FALSE + +#define MENUBOX_BORDER_FG COLOR_WHITE +#define MENUBOX_BORDER_BG COLOR_WHITE +#define MENUBOX_BORDER_HL TRUE + +#define ITEM_FG COLOR_BLACK +#define ITEM_BG COLOR_WHITE +#define ITEM_HL FALSE + +#define ITEM_SELECTED_FG COLOR_WHITE +#define ITEM_SELECTED_BG COLOR_BLUE +#define ITEM_SELECTED_HL TRUE + +#define TAG_FG COLOR_YELLOW +#define TAG_BG COLOR_WHITE +#define TAG_HL TRUE + +#define TAG_SELECTED_FG COLOR_YELLOW +#define TAG_SELECTED_BG COLOR_BLUE +#define TAG_SELECTED_HL TRUE + +#define TAG_KEY_FG COLOR_YELLOW +#define TAG_KEY_BG COLOR_WHITE +#define TAG_KEY_HL TRUE + +#define TAG_KEY_SELECTED_FG COLOR_YELLOW +#define TAG_KEY_SELECTED_BG COLOR_BLUE +#define TAG_KEY_SELECTED_HL TRUE + +#define CHECK_FG COLOR_BLACK +#define CHECK_BG COLOR_WHITE +#define CHECK_HL FALSE + +#define CHECK_SELECTED_FG COLOR_WHITE +#define CHECK_SELECTED_BG COLOR_BLUE +#define CHECK_SELECTED_HL TRUE + +#define UARROW_FG COLOR_GREEN +#define UARROW_BG COLOR_WHITE +#define UARROW_HL TRUE + +#define DARROW_FG COLOR_GREEN +#define DARROW_BG COLOR_WHITE +#define DARROW_HL TRUE + +/* End of default color definitions */ + +#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) +#define COLOR_NAME_LEN 10 +#define COLOR_COUNT 8 + +/* + * Global variables + */ + +typedef struct { + char name[COLOR_NAME_LEN]; + int value; +} color_names_st; + +extern color_names_st color_names[]; +extern int color_table[][3]; diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h b/user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h new file mode 100644 index 0000000..7bab3ad --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h @@ -0,0 +1,199 @@ + +/* + * dialog.h -- common declarations for all dialog modules + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef CURSES_LOC +#ifdef __sun__ +#define CURS_MACROS +#endif +#include CURSES_LOC + +/* + * Colors in ncurses 1.9.9e do not work properly since foreground and + * background colors are OR'd rather than separately masked. This version + * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible + * with standard curses. The simplest fix (to make this work with standard + * curses) uses the wbkgdset() function, not used in the original hack. + * Turn it off if we're building with 1.9.9e, since it just confuses things. + */ +#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) +#define OLD_NCURSES 1 +#undef wbkgdset +#define wbkgdset(w,p) /*nothing*/ +#else +#define OLD_NCURSES 0 +#endif + +#define TR(params) _tracef params + +#define ESC 27 +#define TAB 9 +#define MAX_LEN 2048 +#define BUF_SIZE (10*1024) +#define MIN(x,y) (x < y ? x : y) +#define MAX(x,y) (x > y ? x : y) + + +#ifndef ACS_ULCORNER +#define ACS_ULCORNER '+' +#endif +#ifndef ACS_LLCORNER +#define ACS_LLCORNER '+' +#endif +#ifndef ACS_URCORNER +#define ACS_URCORNER '+' +#endif +#ifndef ACS_LRCORNER +#define ACS_LRCORNER '+' +#endif +#ifndef ACS_HLINE +#define ACS_HLINE '-' +#endif +#ifndef ACS_VLINE +#define ACS_VLINE '|' +#endif +#ifndef ACS_LTEE +#define ACS_LTEE '+' +#endif +#ifndef ACS_RTEE +#define ACS_RTEE '+' +#endif +#ifndef ACS_UARROW +#define ACS_UARROW '^' +#endif +#ifndef ACS_DARROW +#define ACS_DARROW 'v' +#endif + +/* + * Attribute names + */ +#define screen_attr attributes[0] +#define shadow_attr attributes[1] +#define dialog_attr attributes[2] +#define title_attr attributes[3] +#define border_attr attributes[4] +#define button_active_attr attributes[5] +#define button_inactive_attr attributes[6] +#define button_key_active_attr attributes[7] +#define button_key_inactive_attr attributes[8] +#define button_label_active_attr attributes[9] +#define button_label_inactive_attr attributes[10] +#define inputbox_attr attributes[11] +#define inputbox_border_attr attributes[12] +#define searchbox_attr attributes[13] +#define searchbox_title_attr attributes[14] +#define searchbox_border_attr attributes[15] +#define position_indicator_attr attributes[16] +#define menubox_attr attributes[17] +#define menubox_border_attr attributes[18] +#define item_attr attributes[19] +#define item_selected_attr attributes[20] +#define tag_attr attributes[21] +#define tag_selected_attr attributes[22] +#define tag_key_attr attributes[23] +#define tag_key_selected_attr attributes[24] +#define check_attr attributes[25] +#define check_selected_attr attributes[26] +#define uarrow_attr attributes[27] +#define darrow_attr attributes[28] + +/* number of attributes */ +#define ATTRIBUTE_COUNT 29 + +/* + * Global variables + */ +extern bool use_colors; + +extern chtype attributes[]; +#endif + +extern const char *backtitle; + +struct dialog_list_item { + char *name; + int namelen; + char *tag; + int selected; /* Set to 1 by dialog_*() function. */ +}; + +/* + * Function prototypes + */ + +void init_dialog (void); +void end_dialog (void); +void dialog_clear (void); +#ifdef CURSES_LOC +void attr_clear (WINDOW * win, int height, int width, chtype attr); +void color_setup (void); +void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); +void print_button (WINDOW * win, const char *label, int y, int x, int selected); +void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow (WINDOW * win, int y, int x, int height, int width); +#endif + +int first_alpha (const char *string, const char *exempt); +int dialog_yesno (const char *title, const char *prompt, int height, int width); +int dialog_msgbox (const char *title, const char *prompt, int height, + int width, int pause); +int dialog_textbox (const char *title, const char *file, int height, int width); +int dialog_menu (const char *title, const char *prompt, int height, int width, + int menu_height, const char *choice, int item_no, + struct dialog_list_item ** items); +int dialog_checklist (const char *title, const char *prompt, int height, + int width, int list_height, int item_no, + struct dialog_list_item ** items, int flag); +extern unsigned char dialog_input_result[]; +int dialog_inputbox (const char *title, const char *prompt, int height, + int width, const char *init); + +struct dialog_list_item *first_sel_item(int item_no, + struct dialog_list_item ** items); + +/* + * This is the base for fictitious keys, which activate + * the buttons. + * + * Mouse-generated keys are the following: + * -- the first 32 are used as numbers, in addition to '0'-'9' + * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') + * -- uppercase chars are used to invoke the button (M_EVENT + 'O') + */ +#ifdef CURSES_LOC +#define M_EVENT (KEY_MAX+1) +#endif + + +/* + * The `flag' parameter in checklist is used to select between + * radiolist and checklist + */ +#define FLAG_CHECK 1 +#define FLAG_RADIO 0 diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c new file mode 100644 index 0000000..fa7bebc --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c @@ -0,0 +1,240 @@ +/* + * inputbox.c -- implements the input box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +unsigned char dialog_input_result[MAX_LEN + 1]; + +/* + * Print the termination buttons + */ +static void +print_buttons(WINDOW *dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button (dialog, " Ok ", y, x, selected==0); + print_button (dialog, " Help ", y, x + 14, selected==1); + + wmove(dialog, y, x+1+14*selected); + wrefresh(dialog); +} + +/* + * Display a dialog box for inputing a string + */ +int +dialog_inputbox (const char *title, const char *prompt, int height, int width, + const char *init) +{ + int i, x, y, box_y, box_x, box_width; + int input_x = 0, scroll = 0, key = 0, button = -1; + unsigned char *instr = dialog_input_result; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx (dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, + border_attr, dialog_attr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove (dialog, box_y, box_x); + wattrset (dialog, inputbox_attr); + + if (!init) + instr[0] = '\0'; + else + strcpy (instr, init); + + input_x = strlen (instr); + + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch (dialog, instr[scroll + i]); + } else + waddstr (dialog, instr); + + wmove (dialog, box_y, box_x + input_x); + + wrefresh (dialog); + + while (key != ESC) { + key = wgetch (dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + continue; + case KEY_RIGHT: + continue; + case KEY_BACKSPACE: + case 127: + if (input_x || scroll) { + wattrset (dialog, inputbox_attr); + if (!input_x) { + scroll = scroll < box_width - 1 ? + 0 : scroll - (box_width - 1); + wmove (dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch (dialog, instr[scroll + input_x + i] ? + instr[scroll + input_x + i] : ' '); + input_x = strlen (instr) - scroll; + } else + input_x--; + instr[scroll + input_x] = '\0'; + mvwaddch (dialog, box_y, input_x + box_x, ' '); + wmove (dialog, box_y, input_x + box_x); + wrefresh (dialog); + } + continue; + default: + if (key < 0x100 && isprint (key)) { + if (scroll + input_x < MAX_LEN) { + wattrset (dialog, inputbox_attr); + instr[scroll + input_x] = key; + instr[scroll + input_x + 1] = '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove (dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch (dialog, instr[scroll + i]); + } else { + wmove (dialog, box_y, input_x++ + box_x); + waddch (dialog, key); + } + wrefresh (dialog); + } else + flash (); /* Alarm user about overflow */ + continue; + } + } + } + switch (key) { + case 'O': + case 'o': + delwin (dialog); + return 0; + case 'H': + case 'h': + delwin (dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove (dialog, box_y, box_x + input_x); + wrefresh (dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove (dialog, box_y, box_x + input_x); + wrefresh (dialog); + break; + } + break; + case ' ': + case '\n': + delwin (dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + } + + delwin (dialog); + return -1; /* ESC pressed */ +} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c new file mode 100644 index 0000000..873dc58 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c @@ -0,0 +1,438 @@ +/* + * menubox.c -- implements the menu box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Changes by Clifford Wolf (god@clifford.at) + * + * [ 1998-06-13 ] + * + * *) A bugfix for the Page-Down problem + * + * *) Formerly when I used Page Down and Page Up, the cursor would be set + * to the first position in the menu box. Now lxdialog is a bit + * smarter and works more like other menu systems (just have a look at + * it). + * + * *) Formerly if I selected something my scrolling would be broken because + * lxdialog is re-invoked by the Menuconfig shell script, can't + * remember the last scrolling position, and just sets it so that the + * cursor is at the bottom of the box. Now it writes the temporary file + * lxdialog.scrltmp which contains this information. The file is + * deleted by lxdialog if the user leaves a submenu or enters a new + * one, but it would be nice if Menuconfig could make another "rm -f" + * just to be sure. Just try it out - you will recognise a difference! + * + * [ 1998-06-14 ] + * + * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files + * and menus change their size on the fly. + * + * *) If for some reason the last scrolling position is not saved by + * lxdialog, it sets the scrolling so that the selected item is in the + * middle of the menu box, not at the bottom. + * + * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) + * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. + * This fixes a bug in Menuconfig where using ' ' to descend into menus + * would leave mis-synchronized lxdialog.scrltmp files lying around, + * fscanf would read in 'scroll', and eventually that value would get used. + */ + +#include "dialog.h" + +static int menu_width, item_x; + +/* + * Print menu item + */ +static void +print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey) +{ + int j; + char menu_item[menu_width+1]; + + strncpy(menu_item, item, menu_width); + menu_item[menu_width] = 0; + j = first_alpha(menu_item, "YyNnMmHh"); + + /* Clear 'residue' of last item */ + wattrset (win, menubox_attr); + wmove (win, choice, 0); +#if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch (win, ' '); + } +#else + wclrtoeol(win); +#endif + wattrset (win, selected ? item_selected_attr : item_attr); + mvwaddstr (win, choice, item_x, menu_item); + if (hotkey) { + wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); + mvwaddch(win, choice, item_x+j, menu_item[j]); + } + if (selected) { + wmove (win, choice, item_x+1); + wrefresh (win); + } +} + +/* + * Print the scroll indicators. + */ +static void +print_arrows (WINDOW * win, int item_no, int scroll, + int y, int x, int height) +{ + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset (win, uarrow_attr); + waddch (win, ACS_UARROW); + waddstr (win, "(-)"); + } + else { + wattrset (win, menubox_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset (win, darrow_attr); + waddch (win, ACS_DARROW); + waddstr (win, "(+)"); + } + else { + wattrset (win, menubox_border_attr); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + waddch (win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); +} + +/* + * Display the termination buttons. + */ +static void +print_buttons (WINDOW *win, int height, int width, int selected) +{ + int x = width / 2 - 16; + int y = height - 2; + + print_button (win, "Select", y, x, selected == 0); + print_button (win, " Exit ", y, x + 12, selected == 1); + print_button (win, " Help ", y, x + 24, selected == 2); + + wmove(win, y, x+1+12*selected); + wrefresh (win); +} + +/* + * Display a menu for choosing among a number of options + */ +int +dialog_menu (const char *title, const char *prompt, int height, int width, + int menu_height, const char *current, int item_no, + struct dialog_list_item ** items) +{ + int i, j, x, y, box_x, box_y; + int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice; + WINDOW *dialog, *menu; + FILE *f; + + max_choice = MIN (menu_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + wbkgdset (dialog, dialog_attr & A_COLOR); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin (dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad (menu, TRUE); + + /* draw a box around the menu items */ + draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2, + menubox_border_attr, menubox_attr); + + /* + * Find length of longest item in order to center menu. + * Set 'choice' to default item. + */ + item_x = 0; + for (i = 0; i < item_no; i++) { + item_x = MAX (item_x, MIN(menu_width, strlen (items[i]->name) + 2)); + if (strcmp(current, items[i]->tag) == 0) choice = i; + } + + item_x = (menu_width - item_x) / 2; + + /* get the scroll info from the temp file */ + if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) { + if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) && + (scroll+max_choice > choice) && (scroll >= 0) && + (scroll+max_choice <= item_no) ) { + first_item = scroll; + choice = choice - scroll; + fclose(f); + } else { + scroll=0; + remove("lxdialog.scrltmp"); + fclose(f); + f=NULL; + } + } + if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { + if (choice >= item_no-max_choice/2) + scroll = first_item = item_no-max_choice; + else + scroll = first_item = choice - max_choice/2; + choice = choice - scroll; + } + + /* Print the menu */ + for (i=0; i < max_choice; i++) { + print_item (menu, items[first_item + i]->name, i, i == choice, + (items[first_item + i]->tag[0] != ':')); + } + + wnoutrefresh (menu); + + print_arrows(dialog, item_no, scroll, + box_y, box_x+item_x+1, menu_height); + + print_buttons (dialog, height, width, 0); + wmove (menu, choice, item_x+1); + wrefresh (menu); + + while (key != ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) key = tolower(key); + + if (strchr("ynmh", key)) + i = max_choice; + else { + for (i = choice+1; i < max_choice; i++) { + j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); + if (key == tolower(items[scroll + i]->name[j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); + if (key == tolower(items[scroll + i]->name[j])) + break; + } + } + + if (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE) { + + print_item (menu, items[scroll + choice]->name, choice, FALSE, + (items[scroll + choice]->tag[0] != ':')); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + scrollok (menu, TRUE); + wscrl (menu, -1); + scrollok (menu, FALSE); + + scroll--; + + print_item (menu, items[scroll]->name, 0, FALSE, + (items[scroll]->tag[0] != ':')); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + + print_item (menu, items[scroll + choice]->name, choice, FALSE, + (items[scroll + choice]->tag[0] != ':')); + + if ((choice > max_choice-3) && + (scroll + max_choice < item_no) + ) { + /* Scroll menu up */ + scrollok (menu, TRUE); + scroll (menu); + scrollok (menu, FALSE); + + scroll++; + + print_item (menu, items[scroll + max_choice - 1]->name, + max_choice-1, FALSE, + (items[scroll + max_choice - 1]->tag[0] != ':')); + } else + choice = MIN(choice+1, max_choice-1); + + } else if (key == KEY_PPAGE) { + scrollok (menu, TRUE); + for (i=0; (i < max_choice); i++) { + if (scroll > 0) { + wscrl (menu, -1); + scroll--; + print_item (menu, items[scroll]->name, 0, FALSE, + (items[scroll]->tag[0] != ':')); + } else { + if (choice > 0) + choice--; + } + } + scrollok (menu, FALSE); + + } else if (key == KEY_NPAGE) { + for (i=0; (i < max_choice); i++) { + if (scroll+max_choice < item_no) { + scrollok (menu, TRUE); + scroll(menu); + scrollok (menu, FALSE); + scroll++; + print_item (menu, items[scroll + max_choice - 1]->name, + max_choice-1, FALSE, + (items[scroll + max_choice - 1]->tag[0] != ':')); + } else { + if (choice+1 < max_choice) + choice++; + } + } + + } else + choice = i; + + print_item (menu, items[scroll + choice]->name, choice, TRUE, + (items[scroll + choice]->tag[0] != ':')); + + print_arrows(dialog, item_no, scroll, + box_y, box_x+item_x+1, menu_height); + + wnoutrefresh (dialog); + wrefresh (menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 2 : (button > 2 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh (menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + case '/': + /* save scroll info */ + if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { + fprintf(f,"%d\n",scroll); + fclose(f); + } + delwin (dialog); + items[scroll + choice]->selected = 1; + switch (key) { + case 's': return 3; + case 'y': return 3; + case 'n': return 4; + case 'm': return 5; + case ' ': return 6; + case '/': return 7; + } + return 0; + case 'h': + case '?': + button = 2; + case '\n': + delwin (dialog); + items[scroll + choice]->selected = 1; + + remove("lxdialog.scrltmp"); + return button; + case 'e': + case 'x': + key = ESC; + case ESC: + break; + } + } + + delwin (dialog); + remove("lxdialog.scrltmp"); + return -1; /* ESC pressed */ +} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c new file mode 100644 index 0000000..93692e1 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c @@ -0,0 +1,85 @@ +/* + * msgbox.c -- implements the message box and info box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display a message box. Program will pause and display an "OK" button + * if the parameter 'pause' is non-zero. + */ +int +dialog_msgbox (const char *title, const char *prompt, int height, int width, + int pause) +{ + int i, x, y, key = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 2); + + if (pause) { + wattrset (dialog, border_attr); + mvwaddch (dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + print_button (dialog, " Ok ", + height - 2, width / 2 - 4, TRUE); + + wrefresh (dialog); + while (key != ESC && key != '\n' && key != ' ' && + key != 'O' && key != 'o' && key != 'X' && key != 'x') + key = wgetch (dialog); + } else { + key = '\n'; + wrefresh (dialog); + } + + delwin (dialog); + return key == ESC ? -1 : 0; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c new file mode 100644 index 0000000..a5a460b --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c @@ -0,0 +1,556 @@ +/* + * textbox.c -- implements the text box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void back_lines (int n); +static void print_page (WINDOW * win, int height, int width); +static void print_line (WINDOW * win, int row, int width); +static char *get_line (void); +static void print_position (WINDOW * win, int height, int width); + +static int hscroll, fd, file_size, bytes_read; +static int begin_reached = 1, end_reached, page_length; +static char *buf, *page; + +/* + * Display text from a file in a dialog box. + */ +int +dialog_textbox (const char *title, const char *file, int height, int width) +{ + int i, x, y, cur_x, cur_y, fpos, key = 0; + int passed_end; + char search_term[MAX_LEN + 1]; + WINDOW *dialog, *text; + + search_term[0] = '\0'; /* no search term entered yet */ + + /* Open input file for reading */ + if ((fd = open (file, O_RDONLY)) == -1) { + endwin (); + fprintf (stderr, + "\nCan't open input file in dialog_textbox().\n"); + exit (-1); + } + /* Get file size. Actually, 'file_size' is the real file size - 1, + since it's only the last byte offset from the beginning */ + if ((file_size = lseek (fd, 0, SEEK_END)) == -1) { + endwin (); + fprintf (stderr, "\nError getting file size in dialog_textbox().\n"); + exit (-1); + } + /* Restore file pointer to beginning of file after getting file size */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + /* Allocate space for read buffer */ + if ((buf = malloc (BUF_SIZE + 1)) == NULL) { + endwin (); + fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n"); + exit (-1); + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in dialog_textbox().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; /* mark end of valid data */ + page = buf; /* page is pointer to start of page to be displayed */ + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + /* Create window for text region, used for scrolling text */ + text = subwin (dialog, height - 4, width - 2, y + 1, x + 1); + wattrset (text, dialog_attr); + wbkgdset (text, dialog_attr & A_COLOR); + + keypad (text, TRUE); + + /* register the new window, along with its borders */ + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + wbkgdset (dialog, dialog_attr & A_COLOR); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE); + wnoutrefresh (dialog); + getyx (dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear (text, height - 4, width - 2, dialog_attr); + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + + while ((key != ESC) && (key != '\n')) { + key = wgetch (dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + delwin (dialog); + free (buf); + close (fd); + return 0; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + /* First page not in buffer? */ + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + if (fpos > bytes_read) { /* Yes, we have to read it in */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "dialog_textbox().\n"); + exit (-1); + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, + "\nError reading file in dialog_textbox().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } + page = buf; + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* Last page not in buffer? */ + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + if (fpos < file_size) { /* Yes, we have to read it in */ + if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit (-1); + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, + "\nError reading file in dialog_textbox().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } + page = buf + bytes_read; + back_lines (height - 4); + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (!begin_reached) { + back_lines (page_length + 1); + + /* We don't call print_page() here but use scrolling to ensure + faster screen update. However, 'end_reached' and + 'page_length' should still be updated, and 'page' should + point to start of next page. This is done by calling + get_line() in the following 'for' loop. */ + scrollok (text, TRUE); + wscrl (text, -1); /* Scroll text region down one line */ + scrollok (text, FALSE); + page_length = 0; + passed_end = 0; + for (i = 0; i < height - 4; i++) { + if (!i) { + /* print first line of page */ + print_line (text, 0, width - 2); + wnoutrefresh (text); + } else + /* Called to update 'end_reached' and 'page' */ + get_line (); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + } + break; + case 'B': /* Previous page */ + case 'b': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines (page_length + height - 4); + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (!end_reached) { + begin_reached = 0; + scrollok (text, TRUE); + scroll (text); /* Scroll text region up one line */ + scrollok (text, FALSE); + print_line (text, height - 5, width - 2); + wnoutrefresh (text); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh (dialog); + } + break; + case KEY_NPAGE: /* Next page */ + case ' ': + if (end_reached) + break; + + begin_reached = 0; + print_page (text, height - 4, width - 2); + print_position (dialog, height, width); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines (page_length); + print_page (text, height - 4, width - 2); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines (page_length); + print_page (text, height - 4, width - 2); + wmove (dialog, cur_y, cur_x); + wrefresh (dialog); + break; + case ESC: + break; + } + } + + delwin (dialog); + free (buf); + close (fd); + return 1; /* ESC pressed */ +} + +/* + * Go back 'n' lines in text file. Called by dialog_textbox(). + * 'page' will be updated to point to the desired line in 'buf'. + */ +static void +back_lines (int n) +{ + int i, fpos; + + begin_reached = 0; + /* We have to distinguish between end_reached and !end_reached + since at end of file, the line is not ended by a '\n'. + The code inside 'if' basically does a '--page' to move one + character backward so as to skip '\n' of the previous line */ + if (!end_reached) { + /* Either beginning of buffer or beginning of file reached? */ + if (page == buf) { + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "back_lines().\n"); + exit (-1); + } + if (fpos > bytes_read) { /* Not beginning of file yet */ + /* We've reached beginning of buffer, but not beginning of + file yet, so read previous part of file into buffer. + Note that we only move backward for BUF_SIZE/2 bytes, + but not BUF_SIZE bytes to avoid re-reading again in + print_page() later */ + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "back_lines().\n"); + exit (-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) + == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer " + "in back_lines().\n"); + exit (-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in back_lines().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } + } + if (*(--page) != '\n') { /* '--page' here */ + /* Something's wrong... */ + endwin (); + fprintf (stderr, "\nInternal error in back_lines().\n"); + exit (-1); + } + } + /* Go back 'n' lines */ + for (i = 0; i < n; i++) + do { + if (page == buf) { + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, + "\nError moving file pointer in back_lines().\n"); + exit (-1); + } + if (fpos > bytes_read) { + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek (fd, 0, SEEK_SET) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer " + "in back_lines().\n"); + exit (-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), + SEEK_CUR) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer" + " in back_lines().\n"); + exit (-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in " + "back_lines().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } + } + } while (*(--page) != '\n'); + page++; +} + +/* + * Print a new page of text. Called by dialog_textbox(). + */ +static void +print_page (WINDOW * win, int height, int width) +{ + int i, passed_end = 0; + + page_length = 0; + for (i = 0; i < height; i++) { + print_line (win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh (win); +} + +/* + * Print a new line of text. Called by dialog_textbox() and print_page(). + */ +static void +print_line (WINDOW * win, int row, int width) +{ + int y, x; + char *line; + + line = get_line (); + line += MIN (strlen (line), hscroll); /* Scroll horizontally */ + wmove (win, row, 0); /* move cursor to correct line */ + waddch (win, ' '); + waddnstr (win, line, MIN (strlen (line), width - 2)); + + getyx (win, y, x); + /* Clear 'residue' of previous line */ +#if OLD_NCURSES + { + int i; + for (i = 0; i < width - x; i++) + waddch (win, ' '); + } +#else + wclrtoeol(win); +#endif +} + +/* + * Return current line of text. Called by dialog_textbox() and print_line(). + * 'page' should point to start of current line before calling, and will be + * updated to point to start of next line. + */ +static char * +get_line (void) +{ + int i = 0, fpos; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + /* Either end of file or end of buffer reached */ + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in " + "get_line().\n"); + exit (-1); + } + if (fpos < file_size) { /* Not end of file yet */ + /* We've reached end of buffer, but not end of file yet, + so read next part of file into buffer */ + if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { + endwin (); + fprintf (stderr, "\nError reading file in get_line().\n"); + exit (-1); + } + buf[bytes_read] = '\0'; + page = buf; + } else { + if (!end_reached) + end_reached = 1; + break; + } + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; + } + } + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move pass '\n' */ + + return line; +} + +/* + * Print current position + */ +static void +print_position (WINDOW * win, int height, int width) +{ + int fpos, percent; + + if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { + endwin (); + fprintf (stderr, "\nError moving file pointer in print_position().\n"); + exit (-1); + } + wattrset (win, position_indicator_attr); + wbkgdset (win, position_indicator_attr & A_COLOR); + percent = !file_size ? + 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; + wmove (win, height - 3, width - 9); + wprintw (win, "(%3d%%)", percent); +} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c new file mode 100644 index 0000000..6f83951 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c @@ -0,0 +1,375 @@ +/* + * util.c + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + + +/* use colors by default? */ +bool use_colors = 1; + +const char *backtitle = NULL; + +const char *dialog_result; + +/* + * Attribute values, default is for mono display + */ +chtype attributes[] = +{ + A_NORMAL, /* screen_attr */ + A_NORMAL, /* shadow_attr */ + A_NORMAL, /* dialog_attr */ + A_BOLD, /* title_attr */ + A_NORMAL, /* border_attr */ + A_REVERSE, /* button_active_attr */ + A_DIM, /* button_inactive_attr */ + A_REVERSE, /* button_key_active_attr */ + A_BOLD, /* button_key_inactive_attr */ + A_REVERSE, /* button_label_active_attr */ + A_NORMAL, /* button_label_inactive_attr */ + A_NORMAL, /* inputbox_attr */ + A_NORMAL, /* inputbox_border_attr */ + A_NORMAL, /* searchbox_attr */ + A_BOLD, /* searchbox_title_attr */ + A_NORMAL, /* searchbox_border_attr */ + A_BOLD, /* position_indicator_attr */ + A_NORMAL, /* menubox_attr */ + A_NORMAL, /* menubox_border_attr */ + A_NORMAL, /* item_attr */ + A_REVERSE, /* item_selected_attr */ + A_BOLD, /* tag_attr */ + A_REVERSE, /* tag_selected_attr */ + A_BOLD, /* tag_key_attr */ + A_REVERSE, /* tag_key_selected_attr */ + A_BOLD, /* check_attr */ + A_REVERSE, /* check_selected_attr */ + A_BOLD, /* uarrow_attr */ + A_BOLD /* darrow_attr */ +}; + + +#include "colors.h" + +/* + * Table of color values + */ +int color_table[][3] = +{ + {SCREEN_FG, SCREEN_BG, SCREEN_HL}, + {SHADOW_FG, SHADOW_BG, SHADOW_HL}, + {DIALOG_FG, DIALOG_BG, DIALOG_HL}, + {TITLE_FG, TITLE_BG, TITLE_HL}, + {BORDER_FG, BORDER_BG, BORDER_HL}, + {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, + {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, + {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, + {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, + {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, + {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, + BUTTON_LABEL_INACTIVE_HL}, + {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, + {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, + {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, + {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, + {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, + {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, + {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, + {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, + {ITEM_FG, ITEM_BG, ITEM_HL}, + {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, + {TAG_FG, TAG_BG, TAG_HL}, + {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, + {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, + {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, + {CHECK_FG, CHECK_BG, CHECK_HL}, + {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, + {UARROW_FG, UARROW_BG, UARROW_HL}, + {DARROW_FG, DARROW_BG, DARROW_HL}, +}; /* color_table */ + +/* + * Set window to attribute 'attr' + */ +void +attr_clear (WINDOW * win, int height, int width, chtype attr) +{ + int i, j; + + wattrset (win, attr); + for (i = 0; i < height; i++) { + wmove (win, i, 0); + for (j = 0; j < width; j++) + waddch (win, ' '); + } + touchwin (win); +} + +void dialog_clear (void) +{ + attr_clear (stdscr, LINES, COLS, screen_attr); + /* Display background title if it exists ... - SLH */ + if (backtitle != NULL) { + int i; + + wattrset (stdscr, screen_attr); + mvwaddstr (stdscr, 0, 1, (char *)backtitle); + wmove (stdscr, 1, 1); + for (i = 1; i < COLS - 1; i++) + waddch (stdscr, ACS_HLINE); + } + wnoutrefresh (stdscr); +} + +/* + * Do some initialization for dialog + */ +void +init_dialog (void) +{ + initscr (); /* Init curses */ + keypad (stdscr, TRUE); + cbreak (); + noecho (); + + + if (use_colors) /* Set up colors */ + color_setup (); + + + dialog_clear (); +} + +/* + * Setup for color display + */ +void +color_setup (void) +{ + int i; + + if (has_colors ()) { /* Terminal supports color? */ + start_color (); + + /* Initialize color pairs */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + init_pair (i + 1, color_table[i][0], color_table[i][1]); + + /* Setup color attributes */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + attributes[i] = C_ATTR (color_table[i][2], i + 1); + } +} + +/* + * End using dialog functions. + */ +void +end_dialog (void) +{ + endwin (); +} + + +/* + * Print a string of text in a window, automatically wrap around to the + * next line if the string is too long to fit on one line. Newline + * characters '\n' are replaced by spaces. We start on a new line + * if there is no room for at least 4 nonblanks following a double-space. + */ +void +print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) +{ + int newl, cur_x, cur_y; + int i, prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + + strcpy (tempstr, prompt); + + prompt_len = strlen(tempstr); + + /* + * Remove newlines + */ + for(i=0; i room || + (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room + && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { + cur_y++; + cur_x = x; + } + wmove (win, cur_y, cur_x); + waddstr (win, word); + getyx (win, cur_y, cur_x); + cur_x++; + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' '); + newl = 1; + } else + newl = 0; + word = sp; + } + } +} + +/* + * Print a button + */ +void +print_button (WINDOW * win, const char *label, int y, int x, int selected) +{ + int i, temp; + + wmove (win, y, x); + wattrset (win, selected ? button_active_attr : button_inactive_attr); + waddstr (win, "<"); + temp = strspn (label, " "); + label += temp; + wattrset (win, selected ? button_label_active_attr + : button_label_inactive_attr); + for (i = 0; i < temp; i++) + waddch (win, ' '); + wattrset (win, selected ? button_key_active_attr + : button_key_inactive_attr); + waddch (win, label[0]); + wattrset (win, selected ? button_label_active_attr + : button_label_inactive_attr); + waddstr (win, (char *)label + 1); + wattrset (win, selected ? button_active_attr : button_inactive_attr); + waddstr (win, ">"); + wmove (win, y, x + temp + 1); +} + +/* + * Draw a rectangular box with line drawing characters + */ +void +draw_box (WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) +{ + int i, j; + + wattrset (win, 0); + for (i = 0; i < height; i++) { + wmove (win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch (win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch (win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch (win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch (win, box | ACS_LRCORNER); + else if (!i) + waddch (win, border | ACS_HLINE); + else if (i == height - 1) + waddch (win, box | ACS_HLINE); + else if (!j) + waddch (win, border | ACS_VLINE); + else if (j == width - 1) + waddch (win, box | ACS_VLINE); + else + waddch (win, box | ' '); + } +} + +/* + * Draw shadows along the right and bottom edge to give a more 3D look + * to the boxes + */ +void +draw_shadow (WINDOW * win, int y, int x, int height, int width) +{ + int i; + + if (has_colors ()) { /* Whether terminal supports color? */ + wattrset (win, shadow_attr); + wmove (win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch (win, winch (win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove (win, i, x + width); + waddch (win, winch (win) & A_CHARTEXT); + waddch (win, winch (win) & A_CHARTEXT); + } + wnoutrefresh (win); + } +} + +/* + * Return the position of the first alphabetic character in a string. + */ +int +first_alpha(const char *string, const char *exempt) +{ + int i, in_paren=0, c; + + for (i = 0; i < strlen(string); i++) { + c = tolower(string[i]); + + if (strchr("<[(", c)) ++in_paren; + if (strchr(">])", c) && in_paren > 0) --in_paren; + + if ((! in_paren) && isalpha(c) && + strchr(exempt, c) == 0) + return i; + } + + return 0; +} + +/* + * Get the first selected item in the dialog_list_item list. + */ +struct dialog_list_item * +first_sel_item(int item_no, struct dialog_list_item ** items) +{ + int i; + + for (i = 0; i < item_no; i++) { + if (items[i]->selected) + return items[i]; + } + + return NULL; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c new file mode 100644 index 0000000..11fcc25 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c @@ -0,0 +1,118 @@ +/* + * yesno.c -- implements the yes/no box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display termination buttons + */ +static void +print_buttons(WINDOW *dialog, int height, int width, int selected) +{ + int x = width / 2 - 10; + int y = height - 2; + + print_button (dialog, " Yes ", y, x, selected == 0); + print_button (dialog, " No ", y, x + 13, selected == 1); + + wmove(dialog, y, x+1 + 13*selected ); + wrefresh (dialog); +} + +/* + * Display a dialog box with two buttons - Yes and No + */ +int +dialog_yesno (const char *title, const char *prompt, int height, int width) +{ + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow (stdscr, y, x, height, width); + + dialog = newwin (height, width, y, x); + keypad (dialog, TRUE); + + draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset (dialog, border_attr); + mvwaddch (dialog, height-3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch (dialog, ACS_HLINE); + wattrset (dialog, dialog_attr); + waddch (dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width-2 ) { + /* truncate long title -- mec */ + char * title2 = malloc(width-2+1); + memcpy( title2, title, width-2 ); + title2[width-2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset (dialog, title_attr); + mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); + waddstr (dialog, (char *)title); + waddch (dialog, ' '); + } + + wattrset (dialog, dialog_attr); + print_autowrap (dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != ESC) { + key = wgetch (dialog); + switch (key) { + case 'Y': + case 'y': + delwin (dialog); + return 0; + case 'N': + case 'n': + delwin (dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh (dialog); + break; + case ' ': + case '\n': + delwin (dialog); + return button; + case ESC: + break; + } + } + + delwin (dialog); + return -1; /* ESC pressed */ +} diff --git a/user/mpy/lib/axtls/config/scripts/config/mconf.c b/user/mpy/lib/axtls/config/scripts/config/mconf.c new file mode 100644 index 0000000..406eb29 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/mconf.c @@ -0,0 +1,977 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + * + * Introduced single menu mode (show all sub-menus in one large tree). + * 2002-11-06 Petr Baudis + * + * Directly use liblxdialog library routines. + * 2002-11-14 Petr Baudis + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lxdialog/dialog.h" + +#define LKC_DIRECT_LINK +#include "lkc.h" + +static char menu_backtitle[128]; +static const char mconf_readme[] = +"Overview\n" +"--------\n" +"Some features may be built directly into axTLS. Some features\n" +"may be completely removed altogether. There are also certain\n" +"parameters which are not really features, but must be\n" +"entered in as decimal or hexadecimal numbers or possibly text.\n" +"\n" +"Menu items beginning with [*] or [ ] represent features\n" +"configured to be built in or removed respectively.\n" +"\n" +"To change any of these features, highlight it with the cursor\n" +"keys and press to build it in or to removed it.\n" +"You may also press the to cycle\n" +"through the available options (ie. Y->N->Y).\n" +"\n" +"Some additional keyboard hints:\n" +"\n" +"Menus\n" +"----------\n" +"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" +" you wish to change or submenu wish to select and press .\n" +" Submenus are designated by \"--->\".\n" +"\n" +" Shortcut: Press the option's highlighted letter (hotkey).\n" +" Pressing a hotkey more than once will sequence\n" +" through all visible items which use that hotkey.\n" +"\n" +" You may also use the and keys to scroll\n" +" unseen options into view.\n" +"\n" +"o To exit a menu use the cursor keys to highlight the button\n" +" and press .\n" +"\n" +" Shortcut: Press or or if there is no hotkey\n" +" using those letters. You may press a single , but\n" +" there is a delayed response which you may find annoying.\n" +"\n" +" Also, the and cursor keys will cycle between and\n" +" \n" +"\n" +"\n" +"Data Entry\n" +"-----------\n" +"o Enter the requested information and press \n" +" If you are entering hexadecimal values, it is not necessary to\n" +" add the '0x' prefix to the entry.\n" +"\n" +"o For help, use the or cursor keys to highlight the help option\n" +" and press . You can try as well.\n" +"\n" +"\n" +"Text Box (Help Window)\n" +"--------\n" +"o Use the cursor keys to scroll up/down/left/right. The VI editor\n" +" keys h,j,k,l function here as do and for those\n" +" who are familiar with less and lynx.\n" +"\n" +"o Press , , or to exit.\n" +"\n" +"\n" +"Alternate Configuration Files\n" +"-----------------------------\n" +"Menuconfig supports the use of alternate configuration files for\n" +"those who, for various reasons, find it necessary to switch\n" +"between different configurations.\n" +"\n" +"At the end of the main menu you will find two options. One is\n" +"for saving the current configuration to a file of your choosing.\n" +"The other option is for loading a previously saved alternate\n" +"configuration.\n" +"\n" +"Even if you don't use alternate configuration files, but you\n" +"find during a Menuconfig session that you have completely messed\n" +"up your settings, you may use the \"Load Alternate...\" option to\n" +"restore your previously saved settings from \".config\" without\n" +"restarting Menuconfig.\n" +"\n" +"Other information\n" +"-----------------\n" +"If you use Menuconfig in an XTERM window make sure you have your\n" +"$TERM variable set to point to a xterm definition which supports color.\n" +"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n" +"display correctly in a RXVT window because rxvt displays only one\n" +"intensity of color, bright.\n" +"\n" +"Menuconfig will display larger menus on screens or xterms which are\n" +"set to display more than the standard 25 row by 80 column geometry.\n" +"In order for this to work, the \"stty size\" command must be able to\n" +"display the screen's current row and column geometry. I STRONGLY\n" +"RECOMMEND that you make sure you do NOT have the shell variables\n" +"LINES and COLUMNS exported into your environment. Some distributions\n" +"export those variables via /etc/profile. Some ncurses programs can\n" +"become confused when those variables (LINES & COLUMNS) don't reflect\n" +"the true screen size.\n" +"\n" +"Optional personality available\n" +"------------------------------\n" +"If you prefer to have all of the options listed in a single\n" +"menu, rather than the default multimenu hierarchy, run the menuconfig\n" +"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" +"\n" +"make MENUCONFIG_MODE=single_menu menuconfig\n" +"\n" +" will then unroll the appropriate category, or enfold it if it\n" +"is already unrolled.\n" +"\n" +"Note that this mode can eventually be a little more CPU expensive\n" +"(especially with a larger number of unrolled categories) than the\n" +"default mode.\n", +menu_instructions[] = + "Arrow keys navigate the menu. " + " selects submenus --->. " + "Highlighted letters are hotkeys. " + "Pressing selectes a feature, while will exclude a feature. " + "Press to exit, for Help, for Search. " + "Legend: [*] feature is selected [ ] feature is excluded", +radiolist_instructions[] = + "Use the arrow keys to navigate this window or " + "press the hotkey of the item you wish to select " + "followed by the . " + "Press for additional information about this option.", +inputbox_instructions_int[] = + "Please enter a decimal value. " + "Fractions will not be accepted. " + "Use the key to move from the input field to the buttons below it.", +inputbox_instructions_hex[] = + "Please enter a hexadecimal value. " + "Use the key to move from the input field to the buttons below it.", +inputbox_instructions_string[] = + "Please enter a string value. " + "Use the key to move from the input field to the buttons below it.", +setmod_text[] = + "This feature depends on another which has been configured as a module.\n" + "As a result, this feature will be built as a module.", +nohelp_text[] = + "There is no help available for this option.\n", +load_config_text[] = + "Enter the name of the configuration file you wish to load. " + "Accept the name shown to restore the configuration you " + "last retrieved. Leave blank to abort.", +load_config_help[] = + "\n" + "For various reasons, one may wish to keep several different axTLS\n" + "configurations available on a single machine.\n" + "\n" + "If you have saved a previous configuration in a file other than the\n" + "axTLS's default, entering the name of the file here will allow you\n" + "to modify that configuration.\n" + "\n" + "If you are uncertain, then you have probably never used alternate\n" + "configuration files. You should therefor leave this blank to abort.\n", +save_config_text[] = + "Enter a filename to which this configuration should be saved " + "as an alternate. Leave blank to abort.", +save_config_help[] = + "\n" + "For various reasons, one may wish to keep different axTLS\n" + "configurations available on a single machine.\n" + "\n" + "Entering a file name here will allow you to later retrieve, modify\n" + "and use the current configuration as an alternate to whatever\n" + "configuration options you have selected at that time.\n" + "\n" + "If you are uncertain what all this means then you should probably\n" + "leave this blank.\n", +search_help[] = + "\n" + "Search for CONFIG_ symbols and display their relations.\n" + "Example: search for \"^FOO\"\n" + "Result:\n" + "-----------------------------------------------------------------\n" + "Symbol: FOO [=m]\n" + "Prompt: Foo bus is used to drive the bar HW\n" + "Defined at drivers/pci/Kconfig:47\n" + "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" + "Location:\n" + " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" + " -> PCI support (PCI [=y])\n" + " -> PCI access mode ( [=y])\n" + "Selects: LIBCRC32\n" + "Selected by: BAR\n" + "-----------------------------------------------------------------\n" + "o The line 'Prompt:' shows the text used in the menu structure for\n" + " this CONFIG_ symbol\n" + "o The 'Defined at' line tell at what file / line number the symbol\n" + " is defined\n" + "o The 'Depends on:' line tell what symbols needs to be defined for\n" + " this symbol to be visible in the menu (selectable)\n" + "o The 'Location:' lines tell where in the menu structure this symbol\n" + " is located\n" + " A location followed by a [=y] indicate that this is a selectable\n" + " menu item - and current value is displayed inside brackets.\n" + "o The 'Selects:' line tell what symbol will be automatically\n" + " selected if this symbol is selected (y or m)\n" + "o The 'Selected by' line tell what symbol has selected this symbol\n" + "\n" + "Only relevant lines are shown.\n" + "\n\n" + "Search examples:\n" + "Examples: USB => find all CONFIG_ symbols containing USB\n" + " ^USB => find all CONFIG_ symbols starting with USB\n" + " USB$ => find all CONFIG_ symbols ending with USB\n" + "\n"; + +static char filename[PATH_MAX+1] = ".config"; +static int indent; +static struct termios ios_org; +static int rows = 0, cols = 0; +static struct menu *current_menu; +static int child_count; +static int single_menu_mode; + +static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */ +static int item_no; + +static void conf(struct menu *menu); +static void conf_choice(struct menu *menu); +static void conf_string(struct menu *menu); +static void conf_load(void); +static void conf_save(void); +static void show_textbox(const char *title, const char *text, int r, int c); +static void show_helptext(const char *title, const char *text); +static void show_help(struct menu *menu); +static void show_file(const char *filename, const char *title, int r, int c); + +static void init_wsize(void) +{ + struct winsize ws; + char *env; + + if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { + rows = ws.ws_row; + cols = ws.ws_col; + } + + if (!rows) { + env = getenv("LINES"); + if (env) + rows = atoi(env); + if (!rows) + rows = 24; + } + if (!cols) { + env = getenv("COLUMNS"); + if (env) + cols = atoi(env); + if (!cols) + cols = 80; + } + + if (rows < 19 || cols < 80) { + fprintf(stderr, "Your display is too small to run Menuconfig!\n"); + fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); + exit(1); + } + + rows -= 4; + cols -= 5; +} + +static void cinit(void) +{ + item_no = 0; +} + +static void cmake(void) +{ + items[item_no] = malloc(sizeof(struct dialog_list_item)); + memset(items[item_no], 0, sizeof(struct dialog_list_item)); + items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0; + items[item_no]->name = malloc(512); items[item_no]->name[0] = 0; + items[item_no]->namelen = 0; + item_no++; +} + +static int cprint_name(const char *fmt, ...) +{ + va_list ap; + int res; + + if (!item_no) + cmake(); + va_start(ap, fmt); + res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen, + 512 - items[item_no - 1]->namelen, fmt, ap); + if (res > 0) + items[item_no - 1]->namelen += res; + va_end(ap); + + return res; +} + +static int cprint_tag(const char *fmt, ...) +{ + va_list ap; + int res; + + if (!item_no) + cmake(); + va_start(ap, fmt); + res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap); + va_end(ap); + + return res; +} + +static void cdone(void) +{ + int i; + + for (i = 0; i < item_no; i++) { + free(items[i]->tag); + free(items[i]->name); + free(items[i]); + } + + item_no = 0; +} + +static void get_prompt_str(struct gstr *r, struct property *prop) +{ + int i, j; + struct menu *submenu[8], *menu; + + str_printf(r, "Prompt: %s\n", prop->text); + str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, + prop->menu->lineno); + if (!expr_is_yes(prop->visible.expr)) { + str_append(r, " Depends on: "); + expr_gstr_print(prop->visible.expr, r); + str_append(r, "\n"); + } + menu = prop->menu->parent; + for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) + submenu[i++] = menu; + if (i > 0) { + str_printf(r, " Location:\n"); + for (j = 4; --i >= 0; j += 2) { + menu = submenu[i]; + str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); + if (menu->sym) { + str_printf(r, " (%s [=%s])", menu->sym->name ? + menu->sym->name : "", + sym_get_string_value(menu->sym)); + } + str_append(r, "\n"); + } + } +} + +static void get_symbol_str(struct gstr *r, struct symbol *sym) +{ + bool hit; + struct property *prop; + + str_printf(r, "Symbol: %s [=%s]\n", sym->name, + sym_get_string_value(sym)); + for_all_prompts(sym, prop) + get_prompt_str(r, prop); + hit = false; + for_all_properties(sym, prop, P_SELECT) { + if (!hit) { + str_append(r, " Selects: "); + hit = true; + } else + str_printf(r, " && "); + expr_gstr_print(prop->expr, r); + } + if (hit) + str_append(r, "\n"); + if (sym->rev_dep.expr) { + str_append(r, " Selected by: "); + expr_gstr_print(sym->rev_dep.expr, r); + str_append(r, "\n"); + } + str_append(r, "\n\n"); +} + +static struct gstr get_relations_str(struct symbol **sym_arr) +{ + struct symbol *sym; + struct gstr res = str_new(); + int i; + + for (i = 0; sym_arr && (sym = sym_arr[i]); i++) + get_symbol_str(&res, sym); + if (!i) + str_append(&res, "No matches found.\n"); + return res; +} + +static void search_conf(void) +{ + struct symbol **sym_arr; + struct gstr res; + +again: + switch (dialog_inputbox("Search Configuration Parameter", + "Enter Keyword", 10, 75, + NULL)) { + case 0: + break; + case 1: + show_helptext("Search Configuration", search_help); + goto again; + default: + return; + } + + sym_arr = sym_re_search(dialog_input_result); + res = get_relations_str(sym_arr); + free(sym_arr); + show_textbox("Search Results", str_get(&res), 0, 0); + str_free(&res); +} + +static void build_conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + int type, tmp, doint = 2; + tristate val; + char ch; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + prop = menu->prompt; + if (!sym) { + if (prop && menu != current_menu) { + const char *prompt = menu_get_prompt(menu); + switch (prop->type) { + case P_MENU: + child_count++; + cmake(); + cprint_tag("m%p", menu); + + if (single_menu_mode) { + cprint_name("%s%*c%s", + menu->data ? "-->" : "++>", + indent + 1, ' ', prompt); + } else { + cprint_name(" %*c%s --->", indent + 1, ' ', prompt); + } + + if (single_menu_mode && menu->data) + goto conf_childs; + return; + default: + if (prompt) { + child_count++; + cmake(); + cprint_tag(":%p", menu); + cprint_name("---%*c%s", indent + 1, ' ', prompt); + } + } + } else + doint = 0; + goto conf_childs; + } + + cmake(); + type = sym_get_type(sym); + if (sym_is_choice(sym)) { + struct symbol *def_sym = sym_get_choice_value(sym); + struct menu *def_menu = NULL; + + child_count++; + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child) && child->sym == def_sym) + def_menu = child; + } + + val = sym_get_tristate_value(sym); + if (sym_is_changable(sym)) { + cprint_tag("t%p", menu); + switch (type) { + case S_BOOLEAN: + cprint_name("[%c]", val == no ? ' ' : '*'); + break; + case S_TRISTATE: + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + cprint_name("<%c>", ch); + break; + } + } else { + cprint_tag("%c%p", def_menu ? 't' : ':', menu); + cprint_name(" "); + } + + cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + if (val == yes) { + if (def_menu) { + cprint_name(" (%s)", menu_get_prompt(def_menu)); + cprint_name(" --->"); + if (def_menu->list) { + indent += 2; + build_conf(def_menu); + indent -= 2; + } + } + return; + } + } else { + if (menu == current_menu) { + cprint_tag(":%p", menu); + cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + goto conf_childs; + } + child_count++; + val = sym_get_tristate_value(sym); + if (sym_is_choice_value(sym) && val == yes) { + cprint_tag(":%p", menu); + cprint_name(" "); + } else { + switch (type) { + case S_BOOLEAN: + cprint_tag("t%p", menu); + if (sym_is_changable(sym)) + cprint_name("[%c]", val == no ? ' ' : '*'); + else + cprint_name("---"); + break; + case S_TRISTATE: + cprint_tag("t%p", menu); + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + if (sym_is_changable(sym)) + cprint_name("<%c>", ch); + else + cprint_name("---"); + break; + default: + cprint_tag("s%p", menu); + tmp = cprint_name("(%s)", sym_get_string_value(sym)); + tmp = indent - tmp + 4; + if (tmp < 0) + tmp = 0; + cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : " (NEW)"); + goto conf_childs; + } + } + cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : " (NEW)"); + if (menu->prompt->type == P_MENU) { + cprint_name(" --->"); + return; + } + } + +conf_childs: + indent += doint; + for (child = menu->list; child; child = child->next) + build_conf(child); + indent -= doint; +} + +static void conf(struct menu *menu) +{ + struct dialog_list_item *active_item = NULL; + struct menu *submenu; + const char *prompt = menu_get_prompt(menu); + struct symbol *sym; + char active_entry[40]; + int stat, type; + + unlink("lxdialog.scrltmp"); + active_entry[0] = 0; + while (1) { + indent = 0; + child_count = 0; + current_menu = menu; + cdone(); cinit(); + build_conf(menu); + if (!child_count) + break; + if (menu == &rootmenu) { + cmake(); cprint_tag(":"); cprint_name("--- "); + cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); + cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); + } + dialog_clear(); + stat = dialog_menu(prompt ? prompt : "Main Menu", + menu_instructions, rows, cols, rows - 10, + active_entry, item_no, items); + if (stat < 0) + return; + + if (stat == 1 || stat == 255) + break; + + active_item = first_sel_item(item_no, items); + if (!active_item) + continue; + active_item->selected = 0; + strncpy(active_entry, active_item->tag, sizeof(active_entry)); + active_entry[sizeof(active_entry)-1] = 0; + type = active_entry[0]; + if (!type) + continue; + + sym = NULL; + submenu = NULL; + if (sscanf(active_entry + 1, "%p", &submenu) == 1) + sym = submenu->sym; + + switch (stat) { + case 0: + switch (type) { + case 'm': + if (single_menu_mode) + submenu->data = (void *) (long) !submenu->data; + else + conf(submenu); + break; + case 't': + if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) + conf_choice(submenu); + else if (submenu->prompt->type == P_MENU) + conf(submenu); + break; + case 's': + conf_string(submenu); + break; + case 'L': + conf_load(); + break; + case 'S': + conf_save(); + break; + } + break; + case 2: + if (sym) + show_help(submenu); + else + show_helptext("README", mconf_readme); + break; + case 3: + if (type == 't') { + if (sym_set_tristate_value(sym, yes)) + break; + if (sym_set_tristate_value(sym, mod)) + show_textbox(NULL, setmod_text, 6, 74); + } + break; + case 4: + if (type == 't') + sym_set_tristate_value(sym, no); + break; + case 5: + if (type == 't') + sym_set_tristate_value(sym, mod); + break; + case 6: + if (type == 't') + sym_toggle_tristate_value(sym); + else if (type == 'm') + conf(submenu); + break; + case 7: + search_conf(); + break; + } + } +} + +static void show_textbox(const char *title, const char *text, int r, int c) +{ + int fd; + + fd = creat(".help.tmp", 0777); + write(fd, text, strlen(text)); + close(fd); + show_file(".help.tmp", title, r, c); + unlink(".help.tmp"); +} + +static void show_helptext(const char *title, const char *text) +{ + show_textbox(title, text, 0, 0); +} + +static void show_help(struct menu *menu) +{ + struct gstr help = str_new(); + struct symbol *sym = menu->sym; + + if (sym->help) + { + if (sym->name) { + str_printf(&help, "%s:\n\n", sym->name); + str_append(&help, sym->help); + str_append(&help, "\n"); + } + } else { + str_append(&help, nohelp_text); + } + get_symbol_str(&help, sym); + show_helptext(menu_get_prompt(menu), str_get(&help)); + str_free(&help); +} + +static void show_file(const char *filename, const char *title, int r, int c) +{ + while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) + ; +} + +static void conf_choice(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + struct menu *child; + struct symbol *active; + + active = sym_get_choice_value(menu->sym); + while (1) { + current_menu = menu; + cdone(); cinit(); + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + cmake(); + cprint_tag("%p", child); + cprint_name("%s", menu_get_prompt(child)); + if (child->sym == sym_get_choice_value(menu->sym)) + items[item_no - 1]->selected = 1; /* ON */ + else if (child->sym == active) + items[item_no - 1]->selected = 2; /* SELECTED */ + else + items[item_no - 1]->selected = 0; /* OFF */ + } + + switch (dialog_checklist(prompt ? prompt : "Main Menu", + radiolist_instructions, 15, 70, 6, + item_no, items, FLAG_RADIO)) { + case 0: + if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) != 1) + break; + sym_set_tristate_value(child->sym, yes); + return; + case 1: + if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) == 1) { + show_help(child); + active = child->sym; + } else + show_help(menu); + break; + case 255: + return; + } + } +} + +static void conf_string(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + + while (1) { + char *heading; + + switch (sym_get_type(menu->sym)) { + case S_INT: + heading = (char *) inputbox_instructions_int; + break; + case S_HEX: + heading = (char *) inputbox_instructions_hex; + break; + case S_STRING: + heading = (char *) inputbox_instructions_string; + break; + default: + heading = "Internal mconf error!"; + /* panic? */; + } + + switch (dialog_inputbox(prompt ? prompt : "Main Menu", + heading, 10, 75, + sym_get_string_value(menu->sym))) { + case 0: + if (sym_set_string_value(menu->sym, dialog_input_result)) + return; + show_textbox(NULL, "You have made an invalid entry.", 5, 43); + break; + case 1: + show_help(menu); + break; + case 255: + return; + } + } +} + +static void conf_load(void) +{ + while (1) { + switch (dialog_inputbox(NULL, load_config_text, 11, 55, + filename)) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_read(dialog_input_result)) + return; + show_textbox(NULL, "File does not exist!", 5, 38); + break; + case 1: + show_helptext("Load Alternate Configuration", load_config_help); + break; + case 255: + return; + } + } +} + +static void conf_save(void) +{ + while (1) { + switch (dialog_inputbox(NULL, save_config_text, 11, 55, + filename)) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_write(dialog_input_result)) + return; + show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); + break; + case 1: + show_helptext("Save Alternate Configuration", save_config_help); + break; + case 255: + return; + } + } +} + +static void conf_cleanup(void) +{ + tcsetattr(1, TCSAFLUSH, &ios_org); + unlink(".help.tmp"); +} + +static void winch_handler(int sig) +{ + struct winsize ws; + + if (ioctl(1, TIOCGWINSZ, &ws) == -1) { + rows = 24; + cols = 80; + } else { + rows = ws.ws_row; + cols = ws.ws_col; + } + + if (rows < 19 || cols < 80) { + end_dialog(); + fprintf(stderr, "Your display is too small to run Menuconfig!\n"); + fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); + exit(1); + } + + rows -= 4; + cols -= 5; + +} + +int main(int ac, char **av) +{ + struct symbol *sym; + char *mode; + int stat; + + conf_parse(av[1]); + conf_read(NULL); + + sym = sym_lookup("VERSION", 0); + sym_calc_value(sym); + snprintf(menu_backtitle, 128, "axTLS v%s Configuration", + sym_get_string_value(sym)); + + mode = getenv("MENUCONFIG_MODE"); + if (mode) { + if (!strcasecmp(mode, "single_menu")) + single_menu_mode = 1; + } + + tcgetattr(1, &ios_org); + atexit(conf_cleanup); + init_wsize(); + init_dialog(); + signal(SIGWINCH, winch_handler); + conf(&rootmenu); + end_dialog(); + + /* Restart dialog to act more like when lxdialog was still separate */ + init_dialog(); + do { + stat = dialog_yesno(NULL, + "Do you wish to save your new axTLS configuration?", 5, 60); + } while (stat < 0); + end_dialog(); + + if (stat == 0) { + conf_write(NULL); + printf("\n\n" + "*** End of axTLS configuration.\n" + "*** Check the top-level Makefile for additional configuration options.\n\n"); + } else + printf("\n\nYour axTLS configuration changes were NOT saved.\n\n"); + + return 0; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/menu.c b/user/mpy/lib/axtls/config/scripts/config/menu.c new file mode 100644 index 0000000..0c13156 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/menu.c @@ -0,0 +1,390 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +struct menu rootmenu; +static struct menu **last_entry_ptr; + +struct file *file_list; +struct file *current_file; + +static void menu_warn(struct menu *menu, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +static void prop_warn(struct property *prop, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +void menu_init(void) +{ + current_entry = current_menu = &rootmenu; + last_entry_ptr = &rootmenu.list; +} + +void menu_add_entry(struct symbol *sym) +{ + struct menu *menu; + + menu = malloc(sizeof(*menu)); + memset(menu, 0, sizeof(*menu)); + menu->sym = sym; + menu->parent = current_menu; + menu->file = current_file; + menu->lineno = zconf_lineno(); + + *last_entry_ptr = menu; + last_entry_ptr = &menu->next; + current_entry = menu; +} + +void menu_end_entry(void) +{ +} + +void menu_add_menu(void) +{ + current_menu = current_entry; + last_entry_ptr = ¤t_entry->list; +} + +void menu_end_menu(void) +{ + last_entry_ptr = ¤t_menu->next; + current_menu = current_menu->parent; +} + +struct expr *menu_check_dep(struct expr *e) +{ + if (!e) + return e; + + switch (e->type) { + case E_NOT: + e->left.expr = menu_check_dep(e->left.expr); + break; + case E_OR: + case E_AND: + e->left.expr = menu_check_dep(e->left.expr); + e->right.expr = menu_check_dep(e->right.expr); + break; + case E_SYMBOL: + /* change 'm' into 'm' && MODULES */ + if (e->left.sym == &symbol_mod) + return expr_alloc_and(e, expr_alloc_symbol(modules_sym)); + break; + default: + break; + } + return e; +} + +void menu_add_dep(struct expr *dep) +{ + current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); +} + +void menu_set_type(int type) +{ + struct symbol *sym = current_entry->sym; + + if (sym->type == type) + return; + if (sym->type == S_UNKNOWN) { + sym->type = type; + return; + } + menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'\n", + sym->name ? sym->name : "", + sym_type_name(sym->type), sym_type_name(type)); +} + +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) +{ + struct property *prop = prop_alloc(type, current_entry->sym); + + prop->menu = current_entry; + prop->text = prompt; + prop->expr = expr; + prop->visible.expr = menu_check_dep(dep); + + if (prompt) { + if (current_entry->prompt) + menu_warn(current_entry, "prompt redefined\n"); + current_entry->prompt = prop; + } + + return prop; +} + +void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) +{ + menu_add_prop(type, prompt, NULL, dep); +} + +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) +{ + menu_add_prop(type, NULL, expr, dep); +} + +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) +{ + menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); +} + +void sym_check_prop(struct symbol *sym) +{ + struct property *prop; + struct symbol *sym2; + for (prop = sym->prop; prop; prop = prop->next) { + switch (prop->type) { + case P_DEFAULT: + if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && + prop->expr->type != E_SYMBOL) + prop_warn(prop, + "default for config symbol '%'" + " must be a single symbol", sym->name); + break; + case P_SELECT: + sym2 = prop_get_symbol(prop); + if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) + prop_warn(prop, + "config symbol '%s' uses select, but is " + "not boolean or tristate", sym->name); + else if (sym2->type == S_UNKNOWN) + prop_warn(prop, + "'select' used by config symbol '%s' " + "refer to undefined symbol '%s'", + sym->name, sym2->name); + else if (sym2->type != S_BOOLEAN && sym2->type != S_TRISTATE) + prop_warn(prop, + "'%s' has wrong type. 'select' only " + "accept arguments of boolean and " + "tristate type", sym2->name); + break; + case P_RANGE: + if (sym->type != S_INT && sym->type != S_HEX) + prop_warn(prop, "range is only allowed " + "for int or hex symbols"); + if (!sym_string_valid(sym, prop->expr->left.sym->name) || + !sym_string_valid(sym, prop->expr->right.sym->name)) + prop_warn(prop, "range is invalid"); + break; + default: + ; + } + } +} + +void menu_finalize(struct menu *parent) +{ + struct menu *menu, *last_menu; + struct symbol *sym; + struct property *prop; + struct expr *parentdep, *basedep, *dep, *dep2, **ep; + + sym = parent->sym; + if (parent->list) { + if (sym && sym_is_choice(sym)) { + /* find the first choice value and find out choice type */ + for (menu = parent->list; menu; menu = menu->next) { + if (menu->sym) { + current_entry = parent; + menu_set_type(menu->sym->type); + current_entry = menu; + menu_set_type(sym->type); + break; + } + } + parentdep = expr_alloc_symbol(sym); + } else if (parent->prompt) + parentdep = parent->prompt->visible.expr; + else + parentdep = parent->dep; + + for (menu = parent->list; menu; menu = menu->next) { + basedep = expr_transform(menu->dep); + basedep = expr_alloc_and(expr_copy(parentdep), basedep); + basedep = expr_eliminate_dups(basedep); + menu->dep = basedep; + if (menu->sym) + prop = menu->sym->prop; + else + prop = menu->prompt; + for (; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + dep = expr_transform(prop->visible.expr); + dep = expr_alloc_and(expr_copy(basedep), dep); + dep = expr_eliminate_dups(dep); + if (menu->sym && menu->sym->type != S_TRISTATE) + dep = expr_trans_bool(dep); + prop->visible.expr = dep; + if (prop->type == P_SELECT) { + struct symbol *es = prop_get_symbol(prop); + es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, + expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); + } + } + } + for (menu = parent->list; menu; menu = menu->next) + menu_finalize(menu); + } else if (sym) { + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; + basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); + basedep = expr_eliminate_dups(expr_transform(basedep)); + last_menu = NULL; + for (menu = parent->next; menu; menu = menu->next) { + dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; + if (!expr_contains_symbol(dep, sym)) + break; + if (expr_depends_symbol(dep, sym)) + goto next; + dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); + dep = expr_eliminate_dups(expr_transform(dep)); + dep2 = expr_copy(basedep); + expr_eliminate_eq(&dep, &dep2); + expr_free(dep); + if (!expr_is_yes(dep2)) { + expr_free(dep2); + break; + } + expr_free(dep2); + next: + menu_finalize(menu); + menu->parent = parent; + last_menu = menu; + } + if (last_menu) { + parent->list = parent->next; + parent->next = last_menu->next; + last_menu->next = NULL; + } + } + for (menu = parent->list; menu; menu = menu->next) { + if (sym && sym_is_choice(sym) && menu->sym) { + menu->sym->flags |= SYMBOL_CHOICEVAL; + if (!menu->prompt) + menu_warn(menu, "choice value must have a prompt"); + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_PROMPT && prop->menu != menu) { + prop_warn(prop, "choice values " + "currently only support a " + "single prompt"); + } + if (prop->type == P_DEFAULT) + prop_warn(prop, "defaults for choice " + "values not supported"); + } + current_entry = menu; + menu_set_type(sym->type); + menu_add_symbol(P_CHOICE, sym, NULL); + prop = sym_get_choice_prop(sym); + for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr) + ; + *ep = expr_alloc_one(E_CHOICE, NULL); + (*ep)->right.sym = menu->sym; + } + if (menu->list && (!menu->prompt || !menu->prompt->text)) { + for (last_menu = menu->list; ; last_menu = last_menu->next) { + last_menu->parent = parent; + if (!last_menu->next) + break; + } + last_menu->next = menu->next; + menu->next = menu->list; + menu->list = NULL; + } + } + + if (sym && !(sym->flags & SYMBOL_WARNED)) { + if (sym->type == S_UNKNOWN) + menu_warn(parent, "config symbol defined " + "without type\n"); + + if (sym_is_choice(sym) && !parent->prompt) + menu_warn(parent, "choice must have a prompt\n"); + + /* Check properties connected to this symbol */ + sym_check_prop(sym); + sym->flags |= SYMBOL_WARNED; + } + + if (sym && !sym_is_optional(sym) && parent->prompt) { + sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, + expr_alloc_and(parent->prompt->visible.expr, + expr_alloc_symbol(&symbol_mod))); + } +} + +bool menu_is_visible(struct menu *menu) +{ + struct menu *child; + struct symbol *sym; + tristate visible; + + if (!menu->prompt) + return false; + sym = menu->sym; + if (sym) { + sym_calc_value(sym); + visible = menu->prompt->visible.tri; + } else + visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); + + if (visible != no) + return true; + if (!sym || sym_get_tristate_value(menu->sym) == no) + return false; + + for (child = menu->list; child; child = child->next) + if (menu_is_visible(child)) + return true; + return false; +} + +const char *menu_get_prompt(struct menu *menu) +{ + if (menu->prompt) + return menu->prompt->text; + else if (menu->sym) + return menu->sym->name; + return NULL; +} + +struct menu *menu_get_root_menu(struct menu *menu) +{ + return &rootmenu; +} + +struct menu *menu_get_parent_menu(struct menu *menu) +{ + enum prop_type type; + + for (; menu != &rootmenu; menu = menu->parent) { + type = menu->prompt ? menu->prompt->type : 0; + if (type == P_MENU) + break; + } + return menu; +} + diff --git a/user/mpy/lib/axtls/config/scripts/config/mkconfigs b/user/mpy/lib/axtls/config/scripts/config/mkconfigs new file mode 100755 index 0000000..3cb7bb1 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/mkconfigs @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Copyright (C) 2002 Khalid Aziz +# Copyright (C) 2002 Randy Dunlap +# Copyright (C) 2002 Al Stone +# Copyright (C) 2002 Hewlett-Packard Company +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Busybox version by Matteo Croce <3297627799 at wind.it> +# +# Rules to generate bbconfig.h from .config: +# - Retain lines that begin with "CONFIG_" +# - Retain lines that begin with "# CONFIG_" +# - lines that use double-quotes must \\-escape-quote them + +if [ $# -lt 1 ] +then + config=.config +else config=$1 +fi + +echo "#ifndef _BBCONFIG_H" +echo "#define _BBCONFIG_H" +echo \ +"/* + * busybox configuration options. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * + * This file is generated automatically by scripts/config/mkconfigs. + * Do not edit. + * + */" + +echo "static char const bbconfig_config[] =" +echo "\"CONFIG_BEGIN=n\\n\\" +echo "`sed 's/\"/\\\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{ print $0 "\\\\n\\\\" }' `" +echo "CONFIG_END=n\\n\";" +echo "#endif /* _BBCONFIG_H */" diff --git a/user/mpy/lib/axtls/config/scripts/config/symbol.c b/user/mpy/lib/axtls/config/scripts/config/symbol.c new file mode 100644 index 0000000..ea62972 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/symbol.c @@ -0,0 +1,809 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +struct symbol symbol_yes = { + .name = "y", + .curr = { "y", yes }, + .flags = SYMBOL_YES|SYMBOL_VALID, +}, symbol_mod = { + .name = "m", + .curr = { "m", mod }, + .flags = SYMBOL_MOD|SYMBOL_VALID, +}, symbol_no = { + .name = "n", + .curr = { "n", no }, + .flags = SYMBOL_NO|SYMBOL_VALID, +}, symbol_empty = { + .name = "", + .curr = { "", no }, + .flags = SYMBOL_VALID, +}; + +int sym_change_count; +struct symbol *modules_sym; +tristate modules_val; + +void sym_add_default(struct symbol *sym, const char *def) +{ + struct property *prop = prop_alloc(P_DEFAULT, sym); + + prop->expr = expr_alloc_symbol(sym_lookup(def, 1)); +} + +void sym_init(void) +{ + struct symbol *sym; + char *p; + static bool inited = false; + + if (inited) + return; + inited = true; + + sym = sym_lookup("VERSION", 0); + sym->type = S_STRING; + sym->flags |= SYMBOL_AUTO; + p = getenv("VERSION"); + if (p) + sym_add_default(sym, p); + + sym = sym_lookup("TARGET_ARCH", 0); + sym->type = S_STRING; + sym->flags |= SYMBOL_AUTO; + p = getenv("TARGET_ARCH"); + if (p) + sym_add_default(sym, p); + +} + +enum symbol_type sym_get_type(struct symbol *sym) +{ + enum symbol_type type = sym->type; + + if (type == S_TRISTATE) { + if (sym_is_choice_value(sym) && sym->visible == yes) + type = S_BOOLEAN; + else if (modules_val == no) + type = S_BOOLEAN; + } + return type; +} + +const char *sym_type_name(enum symbol_type type) +{ + switch (type) { + case S_BOOLEAN: + return "boolean"; + case S_TRISTATE: + return "tristate"; + case S_INT: + return "integer"; + case S_HEX: + return "hex"; + case S_STRING: + return "string"; + case S_UNKNOWN: + return "unknown"; + case S_OTHER: + break; + } + return "???"; +} + +struct property *sym_get_choice_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_choices(sym, prop) + return prop; + return NULL; +} + +struct property *sym_get_default_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +struct property *sym_get_range_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_properties(sym, prop, P_RANGE) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +static void sym_calc_visibility(struct symbol *sym) +{ + struct property *prop; + tristate tri; + + /* any prompt visible? */ + tri = no; + for_all_prompts(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + tri = E_OR(tri, prop->visible.tri); + } + if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) + tri = yes; + if (sym->visible != tri) { + sym->visible = tri; + sym_set_changed(sym); + } + if (sym_is_choice_value(sym)) + return; + tri = no; + if (sym->rev_dep.expr) + tri = expr_calc_value(sym->rev_dep.expr); + if (tri == mod && sym_get_type(sym) == S_BOOLEAN) + tri = yes; + if (sym->rev_dep.tri != tri) { + sym->rev_dep.tri = tri; + sym_set_changed(sym); + } +} + +static struct symbol *sym_calc_choice(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + + /* is the user choice visible? */ + def_sym = sym->user.val; + if (def_sym) { + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + return def_sym; + } + + /* any of the defaults visible? */ + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri == no) + continue; + def_sym = prop_get_symbol(prop); + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + return def_sym; + } + + /* just get the first visible value */ + prop = sym_get_choice_prop(sym); + for (e = prop->expr; e; e = e->left.expr) { + def_sym = e->right.sym; + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + return def_sym; + } + + /* no choice? reset tristate value */ + sym->curr.tri = no; + return NULL; +} + +void sym_calc_value(struct symbol *sym) +{ + struct symbol_value newval, oldval; + struct property *prop; + struct expr *e; + + if (!sym) + return; + + if (sym->flags & SYMBOL_VALID) + return; + sym->flags |= SYMBOL_VALID; + + oldval = sym->curr; + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + newval = symbol_empty.curr; + break; + case S_BOOLEAN: + case S_TRISTATE: + newval = symbol_no.curr; + break; + default: + sym->curr.val = sym->name; + sym->curr.tri = no; + return; + } + if (!sym_is_choice_value(sym)) + sym->flags &= ~SYMBOL_WRITE; + + sym_calc_visibility(sym); + + /* set default if recursively called */ + sym->curr = newval; + + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_is_choice_value(sym) && sym->visible == yes) { + prop = sym_get_choice_prop(sym); + newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; + } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) { + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) + newval.tri = sym->user.tri; + else if (!sym_is_choice(sym)) { + prop = sym_get_default_prop(sym); + if (prop) + newval.tri = expr_calc_value(prop->expr); + } + newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri); + } else if (!sym_is_choice(sym)) { + prop = sym_get_default_prop(sym); + if (prop) { + sym->flags |= SYMBOL_WRITE; + newval.tri = expr_calc_value(prop->expr); + } + } + if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) + newval.tri = yes; + break; + case S_STRING: + case S_HEX: + case S_INT: + if (sym->visible != no) { + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) { + newval.val = sym->user.val; + break; + } + } + prop = sym_get_default_prop(sym); + if (prop) { + struct symbol *ds = prop_get_symbol(prop); + if (ds) { + sym->flags |= SYMBOL_WRITE; + sym_calc_value(ds); + newval.val = ds->curr.val; + } + } + break; + default: + ; + } + + sym->curr = newval; + if (sym_is_choice(sym) && newval.tri == yes) + sym->curr.val = sym_calc_choice(sym); + + if (memcmp(&oldval, &sym->curr, sizeof(oldval))) + sym_set_changed(sym); + if (modules_sym == sym) + modules_val = modules_sym->curr.tri; + + if (sym_is_choice(sym)) { + int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); + prop = sym_get_choice_prop(sym); + for (e = prop->expr; e; e = e->left.expr) { + e->right.sym->flags |= flags; + if (flags & SYMBOL_CHANGED) + sym_set_changed(e->right.sym); + } + } +} + +void sym_clear_all_valid(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_VALID; + sym_change_count++; + if (modules_sym) + sym_calc_value(modules_sym); +} + +void sym_set_changed(struct symbol *sym) +{ + struct property *prop; + + sym->flags |= SYMBOL_CHANGED; + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu) + prop->menu->flags |= MENU_CHANGED; + } +} + +void sym_set_all_changed(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym_set_changed(sym); +} + +bool sym_tristate_within_range(struct symbol *sym, tristate val) +{ + int type = sym_get_type(sym); + + if (sym->visible == no) + return false; + + if (type != S_BOOLEAN && type != S_TRISTATE) + return false; + + if (type == S_BOOLEAN && val == mod) + return false; + if (sym->visible <= sym->rev_dep.tri) + return false; + if (sym_is_choice_value(sym) && sym->visible == yes) + return val == yes; + return val >= sym->rev_dep.tri && val <= sym->visible; +} + +bool sym_set_tristate_value(struct symbol *sym, tristate val) +{ + tristate oldval = sym_get_tristate_value(sym); + + if (oldval != val && !sym_tristate_within_range(sym, val)) + return false; + + if (sym->flags & SYMBOL_NEW) { + sym->flags &= ~SYMBOL_NEW; + sym_set_changed(sym); + } + if (sym_is_choice_value(sym) && val == yes) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + + cs->user.val = sym; + cs->flags &= ~SYMBOL_NEW; + } + + sym->user.tri = val; + if (oldval != val) { + sym_clear_all_valid(); + if (sym == modules_sym) + sym_set_all_changed(); + } + + return true; +} + +tristate sym_toggle_tristate_value(struct symbol *sym) +{ + tristate oldval, newval; + + oldval = newval = sym_get_tristate_value(sym); + do { + switch (newval) { + case no: + newval = mod; + break; + case mod: + newval = yes; + break; + case yes: + newval = no; + break; + } + if (sym_set_tristate_value(sym, newval)) + break; + } while (oldval != newval); + return newval; +} + +bool sym_string_valid(struct symbol *sym, const char *str) +{ + signed char ch; + + switch (sym->type) { + case S_STRING: + return true; + case S_INT: + ch = *str++; + if (ch == '-') + ch = *str++; + if (!isdigit(ch)) + return false; + if (ch == '0' && *str != 0) + return false; + while ((ch = *str++)) { + if (!isdigit(ch)) + return false; + } + return true; + case S_HEX: + if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + str += 2; + ch = *str++; + do { + if (!isxdigit(ch)) + return false; + } while ((ch = *str++)); + return true; + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + case 'm': case 'M': + case 'n': case 'N': + return true; + } + return false; + default: + return false; + } +} + +bool sym_string_within_range(struct symbol *sym, const char *str) +{ + struct property *prop; + int val; + + switch (sym->type) { + case S_STRING: + return sym_string_valid(sym, str); + case S_INT: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtol(str, NULL, 10); + return val >= strtol(prop->expr->left.sym->name, NULL, 10) && + val <= strtol(prop->expr->right.sym->name, NULL, 10); + case S_HEX: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtol(str, NULL, 16); + return val >= strtol(prop->expr->left.sym->name, NULL, 16) && + val <= strtol(prop->expr->right.sym->name, NULL, 16); + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + return sym_tristate_within_range(sym, yes); + case 'm': case 'M': + return sym_tristate_within_range(sym, mod); + case 'n': case 'N': + return sym_tristate_within_range(sym, no); + } + return false; + default: + return false; + } +} + +bool sym_set_string_value(struct symbol *sym, const char *newval) +{ + const char *oldval; + char *val; + int size; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (newval[0]) { + case 'y': case 'Y': + return sym_set_tristate_value(sym, yes); + case 'm': case 'M': + return sym_set_tristate_value(sym, mod); + case 'n': case 'N': + return sym_set_tristate_value(sym, no); + } + return false; + default: + ; + } + + if (!sym_string_within_range(sym, newval)) + return false; + + if (sym->flags & SYMBOL_NEW) { + sym->flags &= ~SYMBOL_NEW; + sym_set_changed(sym); + } + + oldval = sym->user.val; + size = strlen(newval) + 1; + if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { + size += 2; + sym->user.val = val = malloc(size); + *val++ = '0'; + *val++ = 'x'; + } else if (!oldval || strcmp(oldval, newval)) + sym->user.val = val = malloc(size); + else + return true; + + strcpy(val, newval); + free((void *)oldval); + sym_clear_all_valid(); + + return true; +} + +const char *sym_get_string_value(struct symbol *sym) +{ + tristate val; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + val = sym_get_tristate_value(sym); + switch (val) { + case no: + return "n"; + case mod: + return "m"; + case yes: + return "y"; + } + break; + default: + ; + } + return (const char *)sym->curr.val; +} + +bool sym_is_changable(struct symbol *sym) +{ + return sym->visible > sym->rev_dep.tri; +} + +struct symbol *sym_lookup(const char *name, int isconst) +{ + struct symbol *symbol; + const char *ptr; + char *new_name; + int hash = 0; + + if (name) { + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + for (ptr = name; *ptr; ptr++) + hash += *ptr; + hash &= 0xff; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (!strcmp(symbol->name, name)) { + if ((isconst && symbol->flags & SYMBOL_CONST) || + (!isconst && !(symbol->flags & SYMBOL_CONST))) + return symbol; + } + } + new_name = strdup(name); + } else { + new_name = NULL; + hash = 256; + } + + symbol = malloc(sizeof(*symbol)); + memset(symbol, 0, sizeof(*symbol)); + symbol->name = new_name; + symbol->type = S_UNKNOWN; + symbol->flags = SYMBOL_NEW; + if (isconst) + symbol->flags |= SYMBOL_CONST; + + symbol->next = symbol_hash[hash]; + symbol_hash[hash] = symbol; + + return symbol; +} + +struct symbol *sym_find(const char *name) +{ + struct symbol *symbol = NULL; + const char *ptr; + int hash = 0; + + if (!name) + return NULL; + + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + for (ptr = name; *ptr; ptr++) + hash += *ptr; + hash &= 0xff; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (!strcmp(symbol->name, name) && + !(symbol->flags & SYMBOL_CONST)) + break; + } + + return symbol; +} + +struct symbol **sym_re_search(const char *pattern) +{ + struct symbol *sym, **sym_arr = NULL; + int i, cnt, size; + regex_t re; + + cnt = size = 0; + /* Skip if empty */ + if (strlen(pattern) == 0) + return NULL; + if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) + return NULL; + + for_all_symbols(i, sym) { + if (sym->flags & SYMBOL_CONST || !sym->name) + continue; + if (regexec(&re, sym->name, 0, NULL, 0)) + continue; + if (cnt + 1 >= size) { + void *tmp = sym_arr; + size += 16; + sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); + if (!sym_arr) { + free(tmp); + return NULL; + } + } + sym_arr[cnt++] = sym; + } + if (sym_arr) + sym_arr[cnt] = NULL; + regfree(&re); + + return sym_arr; +} + + +struct symbol *sym_check_deps(struct symbol *sym); + +static struct symbol *sym_check_expr_deps(struct expr *e) +{ + struct symbol *sym; + + if (!e) + return NULL; + switch (e->type) { + case E_OR: + case E_AND: + sym = sym_check_expr_deps(e->left.expr); + if (sym) + return sym; + return sym_check_expr_deps(e->right.expr); + case E_NOT: + return sym_check_expr_deps(e->left.expr); + case E_EQUAL: + case E_UNEQUAL: + sym = sym_check_deps(e->left.sym); + if (sym) + return sym; + return sym_check_deps(e->right.sym); + case E_SYMBOL: + return sym_check_deps(e->left.sym); + default: + break; + } + printf("Oops! How to check %d?\n", e->type); + return NULL; +} + +struct symbol *sym_check_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + + if (sym->flags & SYMBOL_CHECK_DONE) + return NULL; + if (sym->flags & SYMBOL_CHECK) { + printf("Warning! Found recursive dependency: %s", sym->name); + return sym; + } + + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_expr_deps(sym->rev_dep.expr); + if (sym2) + goto out; + + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->type == P_CHOICE || prop->type == P_SELECT) + continue; + sym2 = sym_check_expr_deps(prop->visible.expr); + if (sym2) + goto out; + if (prop->type != P_DEFAULT || sym_is_choice(sym)) + continue; + sym2 = sym_check_expr_deps(prop->expr); + if (sym2) + goto out; + } +out: + if (sym2) + printf(" %s", sym->name); + sym->flags &= ~SYMBOL_CHECK; + return sym2; +} + +struct property *prop_alloc(enum prop_type type, struct symbol *sym) +{ + struct property *prop; + struct property **propp; + + prop = malloc(sizeof(*prop)); + memset(prop, 0, sizeof(*prop)); + prop->type = type; + prop->sym = sym; + prop->file = current_file; + prop->lineno = zconf_lineno(); + + /* append property to the prop list of symbol */ + if (sym) { + for (propp = &sym->prop; *propp; propp = &(*propp)->next) + ; + *propp = prop; + } + + return prop; +} + +struct symbol *prop_get_symbol(struct property *prop) +{ + if (prop->expr && (prop->expr->type == E_SYMBOL || + prop->expr->type == E_CHOICE)) + return prop->expr->left.sym; + return NULL; +} + +const char *prop_get_type_name(enum prop_type type) +{ + switch (type) { + case P_PROMPT: + return "prompt"; + case P_COMMENT: + return "comment"; + case P_MENU: + return "menu"; + case P_DEFAULT: + return "default"; + case P_CHOICE: + return "choice"; + case P_SELECT: + return "select"; + case P_RANGE: + return "range"; + case P_UNKNOWN: + break; + } + return "unknown"; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/util.c b/user/mpy/lib/axtls/config/scripts/config/util.c new file mode 100644 index 0000000..8fc95a2 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/util.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2002-2005 Roman Zippel + * Copyright (C) 2002-2005 Sam Ravnborg + * + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include "lkc.h" + +/* file already present in list? If not add it */ +struct file *file_lookup(const char *name) +{ + struct file *file; + + for (file = file_list; file; file = file->next) { + if (!strcmp(name, file->name)) + return file; + } + + file = malloc(sizeof(*file)); + memset(file, 0, sizeof(*file)); + file->name = strdup(name); + file->next = file_list; + file_list = file; + return file; +} + +/* write a dependency file as used by kbuild to track dependencies */ +int file_write_dep(const char *name) +{ + struct file *file; + FILE *out; + + if (!name) + name = "config/.config.cmd"; + out = fopen("config/.config.tmp", "w"); + if (!out) + return 1; + fprintf(out, "deps_config := \\\n"); + for (file = file_list; file; file = file->next) { + if (file->next) + fprintf(out, "\t%s \\\n", file->name); + else + fprintf(out, "\t%s\n", file->name); + } + fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); + fclose(out); + rename(".config.tmp", name); + return 0; +} + + +/* Allocate initial growable sting */ +struct gstr str_new(void) +{ + struct gstr gs; + gs.s = malloc(sizeof(char) * 64); + gs.len = 16; + strcpy(gs.s, "\0"); + return gs; +} + +/* Allocate and assign growable string */ +struct gstr str_assign(const char *s) +{ + struct gstr gs; + gs.s = strdup(s); + gs.len = strlen(s) + 1; + return gs; +} + +/* Free storage for growable string */ +void str_free(struct gstr *gs) +{ + if (gs->s) + free(gs->s); + gs->s = NULL; + gs->len = 0; +} + +/* Append to growable string */ +void str_append(struct gstr *gs, const char *s) +{ + size_t l = strlen(gs->s) + strlen(s) + 1; + if (l > gs->len) { + gs->s = realloc(gs->s, l); + gs->len = l; + } + strcat(gs->s, s); +} + +/* Append printf formatted string to growable string */ +void str_printf(struct gstr *gs, const char *fmt, ...) +{ + va_list ap; + char s[10000]; /* big enough... */ + va_start(ap, fmt); + vsnprintf(s, sizeof(s), fmt, ap); + str_append(gs, s); + va_end(ap); +} + +/* Retreive value of growable string */ +const char *str_get(struct gstr *gs) +{ + return gs->s; +} + diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.l b/user/mpy/lib/axtls/config/scripts/config/zconf.l new file mode 100644 index 0000000..55517b2 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/zconf.l @@ -0,0 +1,366 @@ +%option backup nostdinit noyywrap never-interactive full ecs +%option 8bit backup nodefault perf-report perf-report +%x COMMAND HELP STRING PARAM +%{ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define START_STRSIZE 16 + +char *text; +static char *text_ptr; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static struct buffer *zconf_endfile(void); + +void new_string(void) +{ + text = malloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_ptr = text; + text_size = 0; + *text_ptr = 0; +} + +void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + text = realloc(text, new_size); + text_asize = new_size; + text_ptr = text + text_size; + } + memcpy(text_ptr, str, size); + text_ptr += size; + text_size += size; + *text_ptr = 0; +} + +void alloc_string(const char *str, int size) +{ + text = malloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} +%} + +ws [ \n\t] +n [A-Za-z0-9_] + +%% + int str = 0; + int ts, i; + +[ \t]*#.*\n current_file->lineno++; +[ \t]*#.* + +[ \t]*\n current_file->lineno++; return T_EOL; + +[ \t]+ { + BEGIN(COMMAND); +} + +. { + unput(yytext[0]); + BEGIN(COMMAND); +} + + +{ + "mainmenu" BEGIN(PARAM); return T_MAINMENU; + "menu" BEGIN(PARAM); return T_MENU; + "endmenu" BEGIN(PARAM); return T_ENDMENU; + "source" BEGIN(PARAM); return T_SOURCE; + "choice" BEGIN(PARAM); return T_CHOICE; + "endchoice" BEGIN(PARAM); return T_ENDCHOICE; + "comment" BEGIN(PARAM); return T_COMMENT; + "config" BEGIN(PARAM); return T_CONFIG; + "menuconfig" BEGIN(PARAM); return T_MENUCONFIG; + "help" BEGIN(PARAM); return T_HELP; + "if" BEGIN(PARAM); return T_IF; + "endif" BEGIN(PARAM); return T_ENDIF; + "depends" BEGIN(PARAM); return T_DEPENDS; + "requires" BEGIN(PARAM); return T_REQUIRES; + "optional" BEGIN(PARAM); return T_OPTIONAL; + "default" BEGIN(PARAM); return T_DEFAULT; + "prompt" BEGIN(PARAM); return T_PROMPT; + "tristate" BEGIN(PARAM); return T_TRISTATE; + "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE; + "bool" BEGIN(PARAM); return T_BOOLEAN; + "boolean" BEGIN(PARAM); return T_BOOLEAN; + "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN; + "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN; + "int" BEGIN(PARAM); return T_INT; + "hex" BEGIN(PARAM); return T_HEX; + "string" BEGIN(PARAM); return T_STRING; + "select" BEGIN(PARAM); return T_SELECT; + "enable" BEGIN(PARAM); return T_SELECT; + "range" BEGIN(PARAM); return T_RANGE; + {n}+ { + alloc_string(yytext, yyleng); + zconflval.string = text; + return T_WORD; + } + . + \n current_file->lineno++; BEGIN(INITIAL); +} + +{ + "&&" return T_AND; + "||" return T_OR; + "(" return T_OPEN_PAREN; + ")" return T_CLOSE_PAREN; + "!" return T_NOT; + "=" return T_EQUAL; + "!=" return T_UNEQUAL; + "if" return T_IF; + "on" return T_ON; + \"|\' { + str = yytext[0]; + new_string(); + BEGIN(STRING); + } + \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; + --- /* ignore */ + ({n}|[-/.])+ { + alloc_string(yytext, yyleng); + zconflval.string = text; + return T_WORD; + } + #.* /* comment */ + \\\n current_file->lineno++; + . + <> { + BEGIN(INITIAL); + } +} + +{ + [^'"\\\n]+/\n { + append_string(yytext, yyleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + [^'"\\\n]+ { + append_string(yytext, yyleng); + } + \\.?/\n { + append_string(yytext + 1, yyleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + \\.? { + append_string(yytext + 1, yyleng - 1); + } + \'|\" { + if (str == yytext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(yytext, 1); + } + \n { + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + <> { + BEGIN(INITIAL); + } +} + +{ + [ \t]+ { + ts = 0; + for (i = 0; i < yyleng; i++) { + if (yytext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + [ \t]*\n/[^ \t\n] { + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + [ \t]*\n { + current_file->lineno++; + append_string("\n", 1); + } + [^ \t\n].* { + append_string(yytext, yyleng); + if (!first_ts) + first_ts = last_ts; + } + <> { + zconf_endhelp(); + return T_HELPTEXT; + } +} + +<> { + if (current_buf) { + zconf_endfile(); + return T_EOF; + } + fclose(yyin); + yyterminate(); +} + +%% +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + yyin = zconf_fopen(name); + if (!yyin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = malloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; + current_file->flags = FILE_BUSY; +} + +void zconf_nextfile(const char *name) +{ + struct file *file = file_lookup(name); + struct buffer *buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + yyin = zconf_fopen(name); + if (!yyin) { + printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + exit(1); + } + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", name); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", name); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +static struct buffer *zconf_endfile(void) +{ + struct buffer *parent; + + current_file->flags |= FILE_SCANNED; + current_file->flags &= ~FILE_BUSY; + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(yyin); + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; + + return parent; +} + +int zconf_lineno(void) +{ + if (current_buf) + return current_file->lineno - 1; + else + return 0; +} + +char *zconf_curname(void) +{ + if (current_buf) + return current_file->name; + else + return ""; +} diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped b/user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped new file mode 100644 index 0000000..cc68dcb --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped @@ -0,0 +1,2130 @@ +/* A Bison parser, made by GNU Bison 1.875a. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* If NAME_PREFIX is specified substitute the variables and functions + names. */ +#define yyparse zconfparse +#define yylex zconflex +#define yyerror zconferror +#define yylval zconflval +#define yychar zconfchar +#define yydebug zconfdebug +#define yynerrs zconfnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_MAINMENU = 258, + T_MENU = 259, + T_ENDMENU = 260, + T_SOURCE = 261, + T_CHOICE = 262, + T_ENDCHOICE = 263, + T_COMMENT = 264, + T_CONFIG = 265, + T_MENUCONFIG = 266, + T_HELP = 267, + T_HELPTEXT = 268, + T_IF = 269, + T_ENDIF = 270, + T_DEPENDS = 271, + T_REQUIRES = 272, + T_OPTIONAL = 273, + T_PROMPT = 274, + T_DEFAULT = 275, + T_TRISTATE = 276, + T_DEF_TRISTATE = 277, + T_BOOLEAN = 278, + T_DEF_BOOLEAN = 279, + T_STRING = 280, + T_INT = 281, + T_HEX = 282, + T_WORD = 283, + T_WORD_QUOTE = 284, + T_UNEQUAL = 285, + T_EOF = 286, + T_EOL = 287, + T_CLOSE_PAREN = 288, + T_OPEN_PAREN = 289, + T_ON = 290, + T_SELECT = 291, + T_RANGE = 292, + T_OR = 293, + T_AND = 294, + T_EQUAL = 295, + T_NOT = 296 + }; +#endif +#define T_MAINMENU 258 +#define T_MENU 259 +#define T_ENDMENU 260 +#define T_SOURCE 261 +#define T_CHOICE 262 +#define T_ENDCHOICE 263 +#define T_COMMENT 264 +#define T_CONFIG 265 +#define T_MENUCONFIG 266 +#define T_HELP 267 +#define T_HELPTEXT 268 +#define T_IF 269 +#define T_ENDIF 270 +#define T_DEPENDS 271 +#define T_REQUIRES 272 +#define T_OPTIONAL 273 +#define T_PROMPT 274 +#define T_DEFAULT 275 +#define T_TRISTATE 276 +#define T_DEF_TRISTATE 277 +#define T_BOOLEAN 278 +#define T_DEF_BOOLEAN 279 +#define T_STRING 280 +#define T_INT 281 +#define T_HEX 282 +#define T_WORD 283 +#define T_WORD_QUOTE 284 +#define T_UNEQUAL 285 +#define T_EOF 286 +#define T_EOL 287 +#define T_CLOSE_PAREN 288 +#define T_OPEN_PAREN 289 +#define T_ON 290 +#define T_SELECT 291 +#define T_RANGE 292 +#define T_OR 293 +#define T_AND 294 +#define T_EQUAL 295 +#define T_NOT 296 + + + + +/* Copy the first part of user declarations. */ + + +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(int token, int starttoken, int endtoken); + +struct symbol *symbol_hash[257]; + +static struct menu *current_menu, *current_entry; + +#define YYERROR_VERBOSE + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) + +typedef union YYSTYPE { + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} YYSTYPE; +/* Line 191 of yacc.c. */ + +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +#define LKC_DIRECT_LINK +#include "lkc.h" + + +/* Line 214 of yacc.c. */ + + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || (defined (_ALLOCA_H) && defined (__GNUC__)) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 201 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 41 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 104 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 182 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 296 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, + 21, 23, 26, 28, 30, 32, 34, 36, 38, 42, + 45, 49, 52, 53, 56, 59, 62, 65, 69, 74, + 78, 83, 87, 91, 95, 100, 105, 110, 116, 119, + 122, 124, 128, 131, 132, 135, 138, 141, 144, 149, + 153, 157, 160, 165, 166, 169, 173, 175, 179, 182, + 183, 186, 189, 192, 196, 199, 201, 205, 208, 209, + 212, 215, 218, 222, 226, 228, 232, 235, 238, 241, + 242, 245, 248, 253, 257, 261, 262, 265, 267, 269, + 272, 275, 278, 280, 282, 283, 286, 288, 292, 296, + 300, 303, 307, 311, 313 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 43, 0, -1, -1, 43, 44, -1, 45, -1, 55, + -1, 66, -1, 3, 77, 79, -1, 5, -1, 15, + -1, 8, -1, 1, 79, -1, 61, -1, 71, -1, + 47, -1, 49, -1, 69, -1, 79, -1, 10, 28, + 32, -1, 46, 50, -1, 11, 28, 32, -1, 48, + 50, -1, -1, 50, 51, -1, 50, 75, -1, 50, + 73, -1, 50, 32, -1, 21, 76, 32, -1, 22, + 81, 80, 32, -1, 23, 76, 32, -1, 24, 81, + 80, 32, -1, 26, 76, 32, -1, 27, 76, 32, + -1, 25, 76, 32, -1, 19, 77, 80, 32, -1, + 20, 81, 80, 32, -1, 36, 28, 80, 32, -1, + 37, 82, 82, 80, 32, -1, 7, 32, -1, 52, + 56, -1, 78, -1, 53, 58, 54, -1, 53, 58, + -1, -1, 56, 57, -1, 56, 75, -1, 56, 73, + -1, 56, 32, -1, 19, 77, 80, 32, -1, 21, + 76, 32, -1, 23, 76, 32, -1, 18, 32, -1, + 20, 28, 80, 32, -1, -1, 58, 45, -1, 14, + 81, 32, -1, 78, -1, 59, 62, 60, -1, 59, + 62, -1, -1, 62, 45, -1, 62, 66, -1, 62, + 55, -1, 4, 77, 32, -1, 63, 74, -1, 78, + -1, 64, 67, 65, -1, 64, 67, -1, -1, 67, + 45, -1, 67, 66, -1, 67, 55, -1, 67, 1, + 32, -1, 6, 77, 32, -1, 68, -1, 9, 77, + 32, -1, 70, 74, -1, 12, 32, -1, 72, 13, + -1, -1, 74, 75, -1, 74, 32, -1, 16, 35, + 81, 32, -1, 16, 81, 32, -1, 17, 81, 32, + -1, -1, 77, 80, -1, 28, -1, 29, -1, 5, + 79, -1, 8, 79, -1, 15, 79, -1, 32, -1, + 31, -1, -1, 14, 81, -1, 82, -1, 82, 40, + 82, -1, 82, 30, 82, -1, 34, 81, 33, -1, + 41, 81, -1, 81, 38, 81, -1, 81, 39, 81, + -1, 28, -1, 29, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 94, 94, 95, 98, 99, 100, 101, 102, 103, + 104, 105, 109, 110, 111, 112, 113, 114, 120, 128, + 134, 142, 152, 154, 155, 156, 157, 160, 166, 173, + 179, 186, 192, 198, 204, 210, 216, 222, 230, 239, + 245, 254, 255, 261, 263, 264, 265, 266, 269, 275, + 281, 287, 293, 299, 301, 306, 315, 324, 325, 331, + 333, 334, 335, 340, 347, 353, 362, 363, 369, 371, + 372, 373, 374, 377, 383, 390, 397, 404, 410, 417, + 418, 419, 422, 427, 432, 440, 442, 447, 448, 451, + 452, 453, 457, 457, 459, 460, 463, 464, 465, 466, + 467, 468, 469, 472, 473 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", + "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", + "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", + "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", + "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT", + "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL", + "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR", + "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block", + "common_block", "config_entry_start", "config_stmt", + "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", + "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", + "choice_option_list", "choice_option", "choice_block", "if", "if_end", + "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", + "menu_block", "source", "source_stmt", "comment", "comment_stmt", + "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", + "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, + 44, 44, 45, 45, 45, 45, 45, 45, 46, 47, + 48, 49, 50, 50, 50, 50, 50, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, + 54, 55, 55, 56, 56, 56, 56, 56, 57, 57, + 57, 57, 57, 58, 58, 59, 60, 61, 61, 62, + 62, 62, 62, 63, 64, 65, 66, 66, 67, 67, + 67, 67, 67, 68, 69, 70, 71, 72, 73, 74, + 74, 74, 75, 75, 75, 76, 76, 77, 77, 78, + 78, 78, 79, 79, 80, 80, 81, 81, 81, 81, + 81, 81, 81, 82, 82 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, + 3, 2, 0, 2, 2, 2, 2, 3, 4, 3, + 4, 3, 3, 3, 4, 4, 4, 5, 2, 2, + 1, 3, 2, 0, 2, 2, 2, 2, 4, 3, + 3, 2, 4, 0, 2, 3, 1, 3, 2, 0, + 2, 2, 2, 3, 2, 1, 3, 2, 0, 2, + 2, 2, 3, 3, 1, 3, 2, 2, 2, 0, + 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, + 2, 2, 1, 1, 0, 2, 1, 3, 3, 3, + 2, 3, 3, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 2, 0, 1, 0, 0, 0, 8, 0, 0, 10, + 0, 0, 0, 0, 9, 93, 92, 3, 4, 22, + 14, 22, 15, 43, 53, 5, 59, 12, 79, 68, + 6, 74, 16, 79, 13, 17, 11, 87, 88, 0, + 0, 0, 38, 0, 0, 0, 103, 104, 0, 0, + 0, 96, 19, 21, 39, 42, 58, 64, 0, 76, + 7, 63, 73, 75, 18, 20, 0, 100, 55, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, + 85, 0, 85, 85, 85, 26, 0, 0, 23, 0, + 25, 24, 0, 0, 0, 85, 85, 47, 44, 46, + 45, 0, 0, 0, 54, 41, 40, 60, 62, 57, + 61, 56, 81, 80, 0, 69, 71, 66, 70, 65, + 99, 101, 102, 98, 97, 77, 0, 0, 0, 94, + 94, 0, 94, 94, 0, 94, 0, 0, 0, 94, + 0, 78, 51, 94, 94, 0, 0, 89, 90, 91, + 72, 0, 83, 84, 0, 0, 0, 27, 86, 0, + 29, 0, 33, 31, 32, 0, 94, 0, 0, 49, + 50, 82, 95, 34, 35, 28, 30, 36, 0, 48, + 52, 37 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short yydefgoto[] = +{ + -1, 1, 17, 18, 19, 20, 21, 22, 52, 88, + 23, 24, 105, 25, 54, 98, 55, 26, 109, 27, + 56, 28, 29, 117, 30, 58, 31, 32, 33, 34, + 89, 90, 57, 91, 131, 132, 106, 35, 155, 50, + 51 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -99 +static const short yypact[] = +{ + -99, 48, -99, 38, 46, 46, -99, 46, -29, -99, + 46, -17, -3, -11, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, -99, -99, -99, -99, -99, 38, + 12, 15, -99, 18, 51, 62, -99, -99, -11, -11, + 4, -24, 138, 138, 160, 121, 110, -4, 81, -4, + -99, -99, -99, -99, -99, -99, -19, -99, -99, -11, + -11, 70, 70, 73, 32, -11, 46, -11, 46, -11, + 46, -11, 46, 46, 46, -99, 36, 70, -99, 95, + -99, -99, 96, 46, 106, 46, 46, -99, -99, -99, + -99, 38, 38, 38, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, 112, -99, -99, -99, -99, -99, + -99, 117, -99, -99, -99, -99, -11, 33, 65, 131, + 1, 119, 131, 1, 136, 1, 153, 154, 155, 131, + 70, -99, -99, 131, 131, 156, 157, -99, -99, -99, + -99, 101, -99, -99, -11, 158, 159, -99, -99, 161, + -99, 162, -99, -99, -99, 163, 131, 164, 165, -99, + -99, -99, 99, -99, -99, -99, -99, -99, 166, -99, + -99, -99 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short yypgoto[] = +{ + -99, -99, -99, 111, -99, -99, -99, -99, 178, -99, + -99, -99, -99, 91, -99, -99, -99, -99, -99, -99, + -99, -99, -99, -99, 115, -99, -99, -99, -99, -99, + -99, 146, 168, 89, 27, 0, 126, -1, -98, -48, + -63 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -68 +static const short yytable[] = +{ + 66, 67, 36, 42, 39, 40, 71, 41, 123, 124, + 43, 44, 74, 75, 120, 154, 72, 46, 47, 69, + 70, 121, 122, 48, 140, 45, 127, 128, 112, 130, + 49, 133, 156, 135, 158, 159, 68, 161, 60, 69, + 70, 165, 69, 70, 61, 167, 168, 62, 2, 3, + 63, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 46, 47, 13, 14, 139, 152, 48, 126, 178, 15, + 16, 69, 70, 49, 37, 38, 129, 166, 151, 15, + 16, -67, 114, 64, -67, 5, 101, 7, 8, 102, + 10, 11, 12, 143, 65, 13, 103, 153, 46, 47, + 147, 148, 149, 69, 70, 125, 172, 134, 141, 136, + 137, 138, 15, 16, 5, 101, 7, 8, 102, 10, + 11, 12, 145, 146, 13, 103, 101, 7, 142, 102, + 10, 11, 12, 171, 144, 13, 103, 69, 70, 69, + 70, 15, 16, 100, 150, 154, 113, 108, 113, 116, + 73, 157, 15, 16, 74, 75, 70, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 104, 107, 160, 115, + 85, 110, 73, 118, 86, 87, 74, 75, 92, 93, + 94, 95, 111, 96, 119, 162, 163, 164, 169, 170, + 173, 174, 97, 175, 176, 177, 179, 180, 181, 53, + 99, 59 +}; + +static const unsigned char yycheck[] = +{ + 48, 49, 3, 32, 4, 5, 30, 7, 71, 72, + 10, 28, 16, 17, 33, 14, 40, 28, 29, 38, + 39, 69, 70, 34, 87, 28, 74, 75, 32, 77, + 41, 79, 130, 81, 132, 133, 32, 135, 39, 38, + 39, 139, 38, 39, 32, 143, 144, 32, 0, 1, + 32, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 28, 29, 14, 15, 28, 32, 34, 35, 166, 31, + 32, 38, 39, 41, 28, 29, 76, 140, 126, 31, + 32, 0, 1, 32, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 93, 32, 14, 15, 32, 28, 29, + 101, 102, 103, 38, 39, 32, 154, 80, 13, 82, + 83, 84, 31, 32, 4, 5, 6, 7, 8, 9, + 10, 11, 95, 96, 14, 15, 5, 6, 32, 8, + 9, 10, 11, 32, 28, 14, 15, 38, 39, 38, + 39, 31, 32, 54, 32, 14, 57, 56, 59, 58, + 12, 32, 31, 32, 16, 17, 39, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 55, 56, 32, 58, + 32, 56, 12, 58, 36, 37, 16, 17, 18, 19, + 20, 21, 56, 23, 58, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 21, + 54, 33 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 43, 0, 1, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 14, 15, 31, 32, 44, 45, 46, + 47, 48, 49, 52, 53, 55, 59, 61, 63, 64, + 66, 68, 69, 70, 71, 79, 79, 28, 29, 77, + 77, 77, 32, 77, 28, 28, 28, 29, 34, 41, + 81, 82, 50, 50, 56, 58, 62, 74, 67, 74, + 79, 32, 32, 32, 32, 32, 81, 81, 32, 38, + 39, 30, 40, 12, 16, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 32, 36, 37, 51, 72, + 73, 75, 18, 19, 20, 21, 23, 32, 57, 73, + 75, 5, 8, 15, 45, 54, 78, 45, 55, 60, + 66, 78, 32, 75, 1, 45, 55, 65, 66, 78, + 33, 81, 81, 82, 82, 32, 35, 81, 81, 77, + 81, 76, 77, 81, 76, 81, 76, 76, 76, 28, + 82, 13, 32, 77, 28, 76, 76, 79, 79, 79, + 32, 81, 32, 32, 14, 80, 80, 32, 80, 80, + 32, 80, 32, 32, 32, 80, 82, 80, 80, 32, + 32, 32, 81, 32, 32, 32, 32, 32, 80, 32, + 32, 32 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.first_line = Rhs[1].first_line; \ + Current.first_column = Rhs[1].first_column; \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (cinluded). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylineno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylineno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 8: + + { zconfprint("unexpected 'endmenu' statement"); ;} + break; + + case 9: + + { zconfprint("unexpected 'endif' statement"); ;} + break; + + case 10: + + { zconfprint("unexpected 'endchoice' statement"); ;} + break; + + case 11: + + { zconfprint("syntax error"); yyerrok; ;} + break; + + case 18: + + { + struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 19: + + { + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 20: + + { + struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 21: + + { + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 27: + + { + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 28: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 29: + + { + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 30: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 31: + + { + menu_set_type(S_INT); + printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 32: + + { + menu_set_type(S_HEX); + printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 33: + + { + menu_set_type(S_STRING); + printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 34: + + { + menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 35: + + { + menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 36: + + { + menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 37: + + { + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 38: + + { + struct symbol *sym = sym_lookup(NULL, 0); + sym->flags |= SYMBOL_CHOICE; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 39: + + { + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 40: + + { + if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 42: + + { + printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 48: + + { + menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 49: + + { + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 50: + + { + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 51: + + { + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 52: + + { + menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 55: + + { + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep(yyvsp[-1].expr); + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 56: + + { + if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 58: + + { + printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 63: + + { + menu_add_entry(NULL); + menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 64: + + { + menu_end_entry(); + menu_add_menu(); +;} + break; + + case 65: + + { + if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 67: + + { + printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +;} + break; + + case 72: + + { zconfprint("invalid menu option"); yyerrok; ;} + break; + + case 73: + + { + yyval.string = yyvsp[-1].string; + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); +;} + break; + + case 74: + + { + zconf_nextfile(yyvsp[0].string); +;} + break; + + case 75: + + { + menu_add_entry(NULL); + menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 76: + + { + menu_end_entry(); +;} + break; + + case 77: + + { + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +;} + break; + + case 78: + + { + current_entry->sym->help = yyvsp[0].string; +;} + break; + + case 82: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 83: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 84: + + { + menu_add_dep(yyvsp[-1].expr); + printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 86: + + { + menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); +;} + break; + + case 89: + + { yyval.token = T_ENDMENU; ;} + break; + + case 90: + + { yyval.token = T_ENDCHOICE; ;} + break; + + case 91: + + { yyval.token = T_ENDIF; ;} + break; + + case 94: + + { yyval.expr = NULL; ;} + break; + + case 95: + + { yyval.expr = yyvsp[0].expr; ;} + break; + + case 96: + + { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;} + break; + + case 97: + + { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} + break; + + case 98: + + { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} + break; + + case 99: + + { yyval.expr = yyvsp[-1].expr; ;} + break; + + case 100: + + { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;} + break; + + case 101: + + { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;} + break; + + case 102: + + { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;} + break; + + case 103: + + { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;} + break; + + case 104: + + { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;} + break; + + + } + +/* Line 999 of yacc.c. */ + + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("syntax error, unexpected ") + 1; + yysize += yystrlen (yytname[yytype]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* Return failure if at end of input. */ + if (yychar == YYEOF) + { + /* Pop the error token. */ + YYPOPSTACK; + /* Pop the rest of the stack. */ + while (yyss < yyssp) + { + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + YYPOPSTACK; + } + YYABORT; + } + + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*----------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action. | +`----------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + yyvsp--; + yystate = *--yyssp; + + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + + + + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + menu_init(); + modules_sym = sym_lookup("MODULES", 0); + rootmenu.prompt = menu_add_prop(P_MENU, "axTLS Configuration", NULL, NULL); + + //zconfdebug = 1; + zconfparse(); + if (zconfnerrs) + exit(1); + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) + printf("\n"); + else + sym->flags |= SYMBOL_CHECK_DONE; + } + + sym_change_count = 1; +} + +const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + } + return ""; +} + +static bool zconf_endtoken(int token, int starttoken, int endtoken) +{ + if (token != endtoken) { + zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfprint("location of the '%s'", zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "choice\n"); + else + fprintf(out, "config %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (sym->help) { + int len = strlen(sym->help); + while (sym->help[--len] == '\n') + sym->help[len] = 0; + fprintf(out, " help\n%s\n", sym->help); + } + fputc('\n', out); +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + fputs("\n", out); + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "lex.zconf.c" +#include "util.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" + + diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped b/user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped new file mode 100644 index 0000000..3b191ef --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped @@ -0,0 +1,125 @@ +/* A Bison parser, made from zconf.y, by GNU bison 1.75. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +#ifndef BISON_ZCONF_TAB_H +# define BISON_ZCONF_TAB_H + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_MAINMENU = 258, + T_MENU = 259, + T_ENDMENU = 260, + T_SOURCE = 261, + T_CHOICE = 262, + T_ENDCHOICE = 263, + T_COMMENT = 264, + T_CONFIG = 265, + T_HELP = 266, + T_HELPTEXT = 267, + T_IF = 268, + T_ENDIF = 269, + T_DEPENDS = 270, + T_REQUIRES = 271, + T_OPTIONAL = 272, + T_PROMPT = 273, + T_DEFAULT = 274, + T_TRISTATE = 275, + T_BOOLEAN = 276, + T_INT = 277, + T_HEX = 278, + T_WORD = 279, + T_STRING = 280, + T_UNEQUAL = 281, + T_EOF = 282, + T_EOL = 283, + T_CLOSE_PAREN = 284, + T_OPEN_PAREN = 285, + T_ON = 286, + T_OR = 287, + T_AND = 288, + T_EQUAL = 289, + T_NOT = 290 + }; +#endif +#define T_MAINMENU 258 +#define T_MENU 259 +#define T_ENDMENU 260 +#define T_SOURCE 261 +#define T_CHOICE 262 +#define T_ENDCHOICE 263 +#define T_COMMENT 264 +#define T_CONFIG 265 +#define T_HELP 266 +#define T_HELPTEXT 267 +#define T_IF 268 +#define T_ENDIF 269 +#define T_DEPENDS 270 +#define T_REQUIRES 271 +#define T_OPTIONAL 272 +#define T_PROMPT 273 +#define T_DEFAULT 274 +#define T_TRISTATE 275 +#define T_BOOLEAN 276 +#define T_INT 277 +#define T_HEX 278 +#define T_WORD 279 +#define T_STRING 280 +#define T_UNEQUAL 281 +#define T_EOF 282 +#define T_EOL 283 +#define T_CLOSE_PAREN 284 +#define T_OPEN_PAREN 285 +#define T_ON 286 +#define T_OR 287 +#define T_AND 288 +#define T_EQUAL 289 +#define T_NOT 290 + + + + +#ifndef YYSTYPE +#line 33 "zconf.y" +typedef union { + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} yystype; +/* Line 1281 of /usr/share/bison/yacc.c. */ +#line 118 "zconf.tab.h" +# define YYSTYPE yystype +#endif + +extern YYSTYPE zconflval; + + +#endif /* not BISON_ZCONF_TAB_H */ + diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.y b/user/mpy/lib/axtls/config/scripts/config/zconf.y new file mode 100644 index 0000000..cf45da0 --- /dev/null +++ b/user/mpy/lib/axtls/config/scripts/config/zconf.y @@ -0,0 +1,690 @@ +%{ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#include +#include +#include +#include +#include +#include + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(int token, int starttoken, int endtoken); + +struct symbol *symbol_hash[257]; + +static struct menu *current_menu, *current_entry; + +#define YYERROR_VERBOSE +%} +%expect 40 + +%union +{ + int token; + char *string; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; +} + +%token T_MAINMENU +%token T_MENU +%token T_ENDMENU +%token T_SOURCE +%token T_CHOICE +%token T_ENDCHOICE +%token T_COMMENT +%token T_CONFIG +%token T_MENUCONFIG +%token T_HELP +%token T_HELPTEXT +%token T_IF +%token T_ENDIF +%token T_DEPENDS +%token T_REQUIRES +%token T_OPTIONAL +%token T_PROMPT +%token T_DEFAULT +%token T_TRISTATE +%token T_DEF_TRISTATE +%token T_BOOLEAN +%token T_DEF_BOOLEAN +%token T_STRING +%token T_INT +%token T_HEX +%token T_WORD +%token T_WORD_QUOTE +%token T_UNEQUAL +%token T_EOF +%token T_EOL +%token T_CLOSE_PAREN +%token T_OPEN_PAREN +%token T_ON +%token T_SELECT +%token T_RANGE + +%left T_OR +%left T_AND +%left T_EQUAL T_UNEQUAL +%nonassoc T_NOT + +%type prompt +%type source +%type symbol +%type expr +%type if_expr +%type end + +%{ +#define LKC_DIRECT_LINK +#include "lkc.h" +%} +%% +input: /* empty */ + | input block +; + +block: common_block + | choice_stmt + | menu_stmt + | T_MAINMENU prompt nl_or_eof + | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); } + | T_ENDIF { zconfprint("unexpected 'endif' statement"); } + | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); } + | error nl_or_eof { zconfprint("syntax error"); yyerrok; } +; + +common_block: + if_stmt + | comment_stmt + | config_stmt + | menuconfig_stmt + | source_stmt + | nl_or_eof +; + + +/* config/menuconfig entry */ + +config_entry_start: T_CONFIG T_WORD T_EOL +{ + struct symbol *sym = sym_lookup($2, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +config_stmt: config_entry_start config_option_list +{ + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +}; + +menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL +{ + struct symbol *sym = sym_lookup($2, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +menuconfig_stmt: menuconfig_entry_start config_option_list +{ + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +}; + +config_option_list: + /* empty */ + | config_option_list config_option + | config_option_list depends + | config_option_list help + | config_option_list T_EOL +; + +config_option: T_TRISTATE prompt_stmt_opt T_EOL +{ + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEF_TRISTATE expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_BOOLEAN prompt_stmt_opt T_EOL +{ + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEF_BOOLEAN expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_INT prompt_stmt_opt T_EOL +{ + menu_set_type(S_INT); + printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_HEX prompt_stmt_opt T_EOL +{ + menu_set_type(S_HEX); + printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_STRING prompt_stmt_opt T_EOL +{ + menu_set_type(S_STRING); + printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_PROMPT prompt if_expr T_EOL +{ + menu_add_prompt(P_PROMPT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEFAULT expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_SELECT T_WORD if_expr T_EOL +{ + menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_RANGE symbol symbol if_expr T_EOL +{ + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +}; + +/* choice entry */ + +choice: T_CHOICE T_EOL +{ + struct symbol *sym = sym_lookup(NULL, 0); + sym->flags |= SYMBOL_CHOICE; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +}; + +choice_entry: choice choice_option_list +{ + menu_end_entry(); + menu_add_menu(); +}; + +choice_end: end +{ + if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +}; + +choice_stmt: + choice_entry choice_block choice_end + | choice_entry choice_block +{ + printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +}; + +choice_option_list: + /* empty */ + | choice_option_list choice_option + | choice_option_list depends + | choice_option_list help + | choice_option_list T_EOL +; + +choice_option: T_PROMPT prompt if_expr T_EOL +{ + menu_add_prompt(P_PROMPT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_TRISTATE prompt_stmt_opt T_EOL +{ + menu_set_type(S_TRISTATE); + printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_BOOLEAN prompt_stmt_opt T_EOL +{ + menu_set_type(S_BOOLEAN); + printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_OPTIONAL T_EOL +{ + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_DEFAULT T_WORD if_expr T_EOL +{ + menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); + printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); +}; + +choice_block: + /* empty */ + | choice_block common_block +; + +/* if entry */ + +if: T_IF expr T_EOL +{ + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep($2); + menu_end_entry(); + menu_add_menu(); +}; + +if_end: end +{ + if (zconf_endtoken($1, T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +}; + +if_stmt: + if if_block if_end + | if if_block +{ + printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +}; + +if_block: + /* empty */ + | if_block common_block + | if_block menu_stmt + | if_block choice_stmt +; + +/* menu entry */ + +menu: T_MENU prompt T_EOL +{ + menu_add_entry(NULL); + menu_add_prop(P_MENU, $2, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +}; + +menu_entry: menu depends_list +{ + menu_end_entry(); + menu_add_menu(); +}; + +menu_end: end +{ + if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +}; + +menu_stmt: + menu_entry menu_block menu_end + | menu_entry menu_block +{ + printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); + zconfnerrs++; +}; + +menu_block: + /* empty */ + | menu_block common_block + | menu_block menu_stmt + | menu_block choice_stmt + | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; } +; + +source: T_SOURCE prompt T_EOL +{ + $$ = $2; + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +source_stmt: source +{ + zconf_nextfile($1); +}; + +/* comment entry */ + +comment: T_COMMENT prompt T_EOL +{ + menu_add_entry(NULL); + menu_add_prop(P_COMMENT, $2, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +}; + +comment_stmt: comment depends_list +{ + menu_end_entry(); +}; + +/* help option */ + +help_start: T_HELP T_EOL +{ + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +}; + +help: help_start T_HELPTEXT +{ + current_entry->sym->help = $2; +}; + +/* depends option */ + +depends_list: /* empty */ + | depends_list depends + | depends_list T_EOL +; + +depends: T_DEPENDS T_ON expr T_EOL +{ + menu_add_dep($3); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +} + | T_DEPENDS expr T_EOL +{ + menu_add_dep($2); + printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); +} + | T_REQUIRES expr T_EOL +{ + menu_add_dep($2); + printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); +}; + +/* prompt statement */ + +prompt_stmt_opt: + /* empty */ + | prompt if_expr +{ + menu_add_prop(P_PROMPT, $1, NULL, $2); +}; + +prompt: T_WORD + | T_WORD_QUOTE +; + +end: T_ENDMENU nl_or_eof { $$ = T_ENDMENU; } + | T_ENDCHOICE nl_or_eof { $$ = T_ENDCHOICE; } + | T_ENDIF nl_or_eof { $$ = T_ENDIF; } +; + +nl_or_eof: + T_EOL | T_EOF; + +if_expr: /* empty */ { $$ = NULL; } + | T_IF expr { $$ = $2; } +; + +expr: symbol { $$ = expr_alloc_symbol($1); } + | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } + | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } + | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } + | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } + | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } + | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } +; + +symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } + | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); } +; + +%% + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + menu_init(); + modules_sym = sym_lookup("MODULES", 0); + rootmenu.prompt = menu_add_prop(P_MENU, "axTLS Configuration", NULL, NULL); + + //zconfdebug = 1; + zconfparse(); + if (zconfnerrs) + exit(1); + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) + printf("\n"); + else + sym->flags |= SYMBOL_CHECK_DONE; + } + + sym_change_count = 1; +} + +const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + } + return ""; +} + +static bool zconf_endtoken(int token, int starttoken, int endtoken) +{ + if (token != endtoken) { + zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); + zconfprint("location of the '%s'", zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "choice\n"); + else + fprintf(out, "config %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (sym->help) { + int len = strlen(sym->help); + while (sym->help[--len] == '\n') + sym->help[len] = 0; + fprintf(out, " help\n%s\n", sym->help); + } + fputc('\n', out); +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + fputs("\n", out); + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "lex.zconf.c" +#include "util.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" diff --git a/user/mpy/lib/axtls/config/upyconfig b/user/mpy/lib/axtls/config/upyconfig new file mode 100644 index 0000000..f3a26f3 --- /dev/null +++ b/user/mpy/lib/axtls/config/upyconfig @@ -0,0 +1,117 @@ +# +# Automatically generated make config: don't edit +# +HAVE_DOT_CONFIG=y +CONFIG_PLATFORM_LINUX=y +# CONFIG_PLATFORM_CYGWIN is not set +# CONFIG_PLATFORM_WIN32 is not set + +# +# General Configuration +# +PREFIX="/usr/local" +# CONFIG_DEBUG is not set +# CONFIG_STRIP_UNWANTED_SECTIONS is not set +# CONFIG_VISUAL_STUDIO_7_0 is not set +# CONFIG_VISUAL_STUDIO_8_0 is not set +# CONFIG_VISUAL_STUDIO_10_0 is not set +CONFIG_VISUAL_STUDIO_7_0_BASE="" +CONFIG_VISUAL_STUDIO_8_0_BASE="" +CONFIG_VISUAL_STUDIO_10_0_BASE="" +CONFIG_EXTRA_CFLAGS_OPTIONS="" +CONFIG_EXTRA_LDFLAGS_OPTIONS="" + +# +# SSL Library +# +# CONFIG_SSL_SERVER_ONLY is not set +# CONFIG_SSL_CERT_VERIFICATION is not set +# CONFIG_SSL_FULL_MODE is not set +CONFIG_SSL_SKELETON_MODE=y +CONFIG_SSL_ENABLE_SERVER=y +CONFIG_SSL_ENABLE_CLIENT=y +# CONFIG_SSL_DIAGNOSTICS is not set +CONFIG_SSL_PROT_LOW=y +# CONFIG_SSL_PROT_MEDIUM is not set +# CONFIG_SSL_PROT_HIGH is not set +CONFIG_SSL_AES=y +CONFIG_SSL_USE_DEFAULT_KEY=y +CONFIG_SSL_PRIVATE_KEY_LOCATION="" +CONFIG_SSL_PRIVATE_KEY_PASSWORD="" +CONFIG_SSL_X509_CERT_LOCATION="" +# CONFIG_SSL_GENERATE_X509_CERT is not set +CONFIG_SSL_X509_COMMON_NAME="" +CONFIG_SSL_X509_ORGANIZATION_NAME="" +CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME="" +# CONFIG_SSL_ENABLE_V23_HANDSHAKE is not set +# CONFIG_SSL_HAS_PEM is not set +# CONFIG_SSL_USE_PKCS12 is not set +CONFIG_SSL_EXPIRY_TIME=0 +CONFIG_X509_MAX_CA_CERTS=0 +CONFIG_SSL_MAX_CERTS=3 +# CONFIG_SSL_CTX_MUTEXING is not set +# CONFIG_USE_DEV_URANDOM is not set +# CONFIG_WIN32_USE_CRYPTO_LIB is not set +# CONFIG_OPENSSL_COMPATIBLE is not set +# CONFIG_PERFORMANCE_TESTING is not set +# CONFIG_SSL_TEST is not set +# CONFIG_AXTLSWRAP is not set +# CONFIG_AXHTTPD is not set +# CONFIG_HTTP_STATIC_BUILD is not set +CONFIG_HTTP_PORT=0 +CONFIG_HTTP_HTTPS_PORT=0 +CONFIG_HTTP_SESSION_CACHE_SIZE=0 +CONFIG_HTTP_WEBROOT="" +CONFIG_HTTP_TIMEOUT=0 +# CONFIG_HTTP_HAS_CGI is not set +CONFIG_HTTP_CGI_EXTENSIONS="" +# CONFIG_HTTP_ENABLE_LUA is not set +CONFIG_HTTP_LUA_PREFIX="" +# CONFIG_HTTP_BUILD_LUA is not set +CONFIG_HTTP_CGI_LAUNCHER="" +# CONFIG_HTTP_DIRECTORIES is not set +# CONFIG_HTTP_HAS_AUTHORIZATION is not set +# CONFIG_HTTP_HAS_IPV6 is not set +# CONFIG_HTTP_ENABLE_DIFFERENT_USER is not set +CONFIG_HTTP_USER="" +# CONFIG_HTTP_VERBOSE is not set +# CONFIG_HTTP_IS_DAEMON is not set + +# +# Language Bindings +# +# CONFIG_BINDINGS is not set +# CONFIG_CSHARP_BINDINGS is not set +# CONFIG_VBNET_BINDINGS is not set +CONFIG_DOT_NET_FRAMEWORK_BASE="" +# CONFIG_JAVA_BINDINGS is not set +CONFIG_JAVA_HOME="" +# CONFIG_PERL_BINDINGS is not set +CONFIG_PERL_CORE="" +CONFIG_PERL_LIB="" +# CONFIG_LUA_BINDINGS is not set +CONFIG_LUA_CORE="" + +# +# Samples +# +# CONFIG_SAMPLES is not set +# CONFIG_C_SAMPLES is not set +# CONFIG_CSHARP_SAMPLES is not set +# CONFIG_VBNET_SAMPLES is not set +# CONFIG_JAVA_SAMPLES is not set +# CONFIG_PERL_SAMPLES is not set +# CONFIG_LUA_SAMPLES is not set +# CONFIG_BIGINT_CLASSICAL is not set +# CONFIG_BIGINT_MONTGOMERY is not set +# CONFIG_BIGINT_BARRETT is not set +# CONFIG_BIGINT_CRT is not set +# CONFIG_BIGINT_KARATSUBA is not set +MUL_KARATSUBA_THRESH=0 +SQU_KARATSUBA_THRESH=0 +# CONFIG_BIGINT_SLIDING_WINDOW is not set +# CONFIG_BIGINT_SQUARE is not set +# CONFIG_BIGINT_CHECK_ON is not set +# CONFIG_INTEGER_32BIT is not set +# CONFIG_INTEGER_16BIT is not set +# CONFIG_INTEGER_8BIT is not set diff --git a/user/mpy/lib/axtls/config/upyconfig.client b/user/mpy/lib/axtls/config/upyconfig.client new file mode 100644 index 0000000..6dffa19 --- /dev/null +++ b/user/mpy/lib/axtls/config/upyconfig.client @@ -0,0 +1,116 @@ +# +# Automatically generated make config: don't edit +# +HAVE_DOT_CONFIG=y +CONFIG_PLATFORM_LINUX=y +# CONFIG_PLATFORM_CYGWIN is not set +# CONFIG_PLATFORM_WIN32 is not set + +# +# General Configuration +# +PREFIX="/usr/local" +# CONFIG_DEBUG is not set +# CONFIG_STRIP_UNWANTED_SECTIONS is not set +# CONFIG_VISUAL_STUDIO_7_0 is not set +# CONFIG_VISUAL_STUDIO_8_0 is not set +# CONFIG_VISUAL_STUDIO_10_0 is not set +CONFIG_VISUAL_STUDIO_7_0_BASE="" +CONFIG_VISUAL_STUDIO_8_0_BASE="" +CONFIG_VISUAL_STUDIO_10_0_BASE="" +CONFIG_EXTRA_CFLAGS_OPTIONS="" +CONFIG_EXTRA_LDFLAGS_OPTIONS="" + +# +# SSL Library +# +# CONFIG_SSL_SERVER_ONLY is not set +# CONFIG_SSL_CERT_VERIFICATION is not set +# CONFIG_SSL_FULL_MODE is not set +CONFIG_SSL_SKELETON_MODE=y +CONFIG_SSL_ENABLE_CLIENT=y +# CONFIG_SSL_DIAGNOSTICS is not set +CONFIG_SSL_PROT_LOW=y +# CONFIG_SSL_PROT_MEDIUM is not set +# CONFIG_SSL_PROT_HIGH is not set +CONFIG_SSL_AES=y +# CONFIG_SSL_USE_DEFAULT_KEY is not set +CONFIG_SSL_PRIVATE_KEY_LOCATION="" +CONFIG_SSL_PRIVATE_KEY_PASSWORD="" +CONFIG_SSL_X509_CERT_LOCATION="" +# CONFIG_SSL_GENERATE_X509_CERT is not set +CONFIG_SSL_X509_COMMON_NAME="" +CONFIG_SSL_X509_ORGANIZATION_NAME="" +CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME="" +# CONFIG_SSL_ENABLE_V23_HANDSHAKE is not set +# CONFIG_SSL_HAS_PEM is not set +# CONFIG_SSL_USE_PKCS12 is not set +CONFIG_SSL_EXPIRY_TIME=0 +CONFIG_X509_MAX_CA_CERTS=0 +CONFIG_SSL_MAX_CERTS=3 +# CONFIG_SSL_CTX_MUTEXING is not set +# CONFIG_USE_DEV_URANDOM is not set +# CONFIG_WIN32_USE_CRYPTO_LIB is not set +# CONFIG_OPENSSL_COMPATIBLE is not set +# CONFIG_PERFORMANCE_TESTING is not set +# CONFIG_SSL_TEST is not set +# CONFIG_AXTLSWRAP is not set +# CONFIG_AXHTTPD is not set +# CONFIG_HTTP_STATIC_BUILD is not set +CONFIG_HTTP_PORT=0 +CONFIG_HTTP_HTTPS_PORT=0 +CONFIG_HTTP_SESSION_CACHE_SIZE=0 +CONFIG_HTTP_WEBROOT="" +CONFIG_HTTP_TIMEOUT=0 +# CONFIG_HTTP_HAS_CGI is not set +CONFIG_HTTP_CGI_EXTENSIONS="" +# CONFIG_HTTP_ENABLE_LUA is not set +CONFIG_HTTP_LUA_PREFIX="" +# CONFIG_HTTP_BUILD_LUA is not set +CONFIG_HTTP_CGI_LAUNCHER="" +# CONFIG_HTTP_DIRECTORIES is not set +# CONFIG_HTTP_HAS_AUTHORIZATION is not set +# CONFIG_HTTP_HAS_IPV6 is not set +# CONFIG_HTTP_ENABLE_DIFFERENT_USER is not set +CONFIG_HTTP_USER="" +# CONFIG_HTTP_VERBOSE is not set +# CONFIG_HTTP_IS_DAEMON is not set + +# +# Language Bindings +# +# CONFIG_BINDINGS is not set +# CONFIG_CSHARP_BINDINGS is not set +# CONFIG_VBNET_BINDINGS is not set +CONFIG_DOT_NET_FRAMEWORK_BASE="" +# CONFIG_JAVA_BINDINGS is not set +CONFIG_JAVA_HOME="" +# CONFIG_PERL_BINDINGS is not set +CONFIG_PERL_CORE="" +CONFIG_PERL_LIB="" +# CONFIG_LUA_BINDINGS is not set +CONFIG_LUA_CORE="" + +# +# Samples +# +# CONFIG_SAMPLES is not set +# CONFIG_C_SAMPLES is not set +# CONFIG_CSHARP_SAMPLES is not set +# CONFIG_VBNET_SAMPLES is not set +# CONFIG_JAVA_SAMPLES is not set +# CONFIG_PERL_SAMPLES is not set +# CONFIG_LUA_SAMPLES is not set +# CONFIG_BIGINT_CLASSICAL is not set +# CONFIG_BIGINT_MONTGOMERY is not set +# CONFIG_BIGINT_BARRETT is not set +# CONFIG_BIGINT_CRT is not set +# CONFIG_BIGINT_KARATSUBA is not set +MUL_KARATSUBA_THRESH=0 +SQU_KARATSUBA_THRESH=0 +# CONFIG_BIGINT_SLIDING_WINDOW is not set +# CONFIG_BIGINT_SQUARE is not set +# CONFIG_BIGINT_CHECK_ON is not set +# CONFIG_INTEGER_32BIT is not set +# CONFIG_INTEGER_16BIT is not set +# CONFIG_INTEGER_8BIT is not set diff --git a/user/mpy/lib/axtls/config/win32config b/user/mpy/lib/axtls/config/win32config new file mode 100644 index 0000000..6c8d607 --- /dev/null +++ b/user/mpy/lib/axtls/config/win32config @@ -0,0 +1,119 @@ +# +# Automatically generated make config: don't edit +# +HAVE_DOT_CONFIG=y +# CONFIG_PLATFORM_LINUX is not set +# CONFIG_PLATFORM_CYGWIN is not set +# CONFIG_PLATFORM_SOLARIS is not set +CONFIG_PLATFORM_WIN32=y + +# +# General Configuration +# +PREFIX="" +# CONFIG_DEBUG is not set +# CONFIG_STRIP_UNWANTED_SECTIONS is not set + +# +# Microsoft Compiler Options +# +# CONFIG_VISUAL_STUDIO_7_0 is not set +CONFIG_VISUAL_STUDIO_8_0=y +CONFIG_VISUAL_STUDIO_7_0_BASE="" +CONFIG_VISUAL_STUDIO_8_0_BASE="c:\\Program Files\\Microsoft Visual Studio 8" +CONFIG_EXTRA_CFLAGS_OPTIONS="" +CONFIG_EXTRA_LDFLAGS_OPTIONS="" + +# +# SSL Library +# +# CONFIG_SSL_SERVER_ONLY is not set +# CONFIG_SSL_CERT_VERIFICATION is not set +# CONFIG_SSL_ENABLE_CLIENT is not set +CONFIG_SSL_FULL_MODE=y +# CONFIG_SSL_SKELETON_MODE is not set +# CONFIG_SSL_PROT_LOW is not set +CONFIG_SSL_PROT_MEDIUM=y +# CONFIG_SSL_PROT_HIGH is not set +CONFIG_SSL_USE_DEFAULT_KEY=y +CONFIG_SSL_PRIVATE_KEY_LOCATION="" +CONFIG_SSL_PRIVATE_KEY_PASSWORD="" +CONFIG_SSL_X509_CERT_LOCATION="" +CONFIG_SSL_GENERATE_X509_CERT=y +CONFIG_SSL_X509_COMMON_NAME="" +CONFIG_SSL_X509_ORGANIZATION_NAME="" +CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME="" +CONFIG_SSL_ENABLE_V23_HANDSHAKE=y +CONFIG_SSL_HAS_PEM=y +CONFIG_SSL_USE_PKCS12=y +CONFIG_SSL_EXPIRY_TIME=24 +CONFIG_X509_MAX_CA_CERTS=4 +CONFIG_SSL_MAX_CERTS=2 +# CONFIG_SSL_CTX_MUTEXING is not set +# CONFIG_USE_DEV_URANDOM is not set +CONFIG_WIN32_USE_CRYPTO_LIB=y +# CONFIG_OPENSSL_COMPATIBLE is not set +# CONFIG_PERFORMANCE_TESTING is not set +# CONFIG_SSL_TEST is not set +CONFIG_AXHTTPD=y + +# +# Axhttpd Configuration +# +# CONFIG_HTTP_STATIC_BUILD is not set +CONFIG_HTTP_PORT=80 +CONFIG_HTTP_HTTPS_PORT=443 +CONFIG_HTTP_SESSION_CACHE_SIZE=5 +CONFIG_HTTP_WEBROOT="www" +CONFIG_HTTP_TIMEOUT=300 +# CONFIG_HTTP_HAS_CGI is not set +CONFIG_HTTP_CGI_EXTENSIONS="" +# CONFIG_HTTP_ENABLE_LUA is not set +CONFIG_HTTP_LUA_PREFIX="" +CONFIG_HTTP_LUA_CGI_LAUNCHER="" +# CONFIG_HTTP_BUILD_LUA is not set +CONFIG_HTTP_DIRECTORIES=y +CONFIG_HTTP_HAS_AUTHORIZATION=y +# CONFIG_HTTP_HAS_IPV6 is not set +CONFIG_HTTP_VERBOSE=y +# CONFIG_HTTP_IS_DAEMON is not set + +# +# Language Bindings +# +# CONFIG_BINDINGS is not set +# CONFIG_CSHARP_BINDINGS is not set +# CONFIG_VBNET_BINDINGS is not set +CONFIG_DOT_NET_FRAMEWORK_BASE="" +# CONFIG_JAVA_BINDINGS is not set +CONFIG_JAVA_HOME="" +# CONFIG_PERL_BINDINGS is not set +CONFIG_PERL_CORE="" +CONFIG_PERL_LIB="" +# CONFIG_LUA_BINDINGS is not set +CONFIG_LUA_CORE="" + +# +# Samples +# +CONFIG_SAMPLES=y +CONFIG_C_SAMPLES=y +# CONFIG_CSHARP_SAMPLES is not set +# CONFIG_VBNET_SAMPLES is not set +# CONFIG_JAVA_SAMPLES is not set +# CONFIG_PERL_SAMPLES is not set +# CONFIG_LUA_SAMPLES is not set + +# +# BigInt Options +# +# CONFIG_BIGINT_CLASSICAL is not set +# CONFIG_BIGINT_MONTGOMERY is not set +CONFIG_BIGINT_BARRETT=y +CONFIG_BIGINT_CRT=y +# CONFIG_BIGINT_KARATSUBA is not set +MUL_KARATSUBA_THRESH=0 +SQU_KARATSUBA_THRESH=0 +CONFIG_BIGINT_SLIDING_WINDOW=y +CONFIG_BIGINT_SQUARE=y +# CONFIG_BIGINT_CHECK_ON is not set diff --git a/user/mpy/lib/axtls/crypto/Makefile b/user/mpy/lib/axtls/crypto/Makefile new file mode 100644 index 0000000..126ae78 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/Makefile @@ -0,0 +1,52 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../config/.config +include ../config/makefile.conf + +AXTLS_HOME=.. + +OBJ=\ + aes.o \ + bigint.o \ + crypto_misc.o \ + hmac.o \ + md5.o \ + rc4.o \ + rsa.o \ + sha1.o \ + sha256.o \ + sha384.o \ + sha512.o + +include ../config/makefile.post + +all: $(OBJ) + diff --git a/user/mpy/lib/axtls/crypto/aes.c b/user/mpy/lib/axtls/crypto/aes.c new file mode 100644 index 0000000..d573f77 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/aes.c @@ -0,0 +1,452 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * AES implementation - this is a small code version. There are much faster + * versions around but they are much larger in size (i.e. they use large + * submix tables). + */ + +#include +#include "os_port.h" +#include "crypto.h" + +#define rot1(x) (((x) << 24) | ((x) >> 8)) +#define rot2(x) (((x) << 16) | ((x) >> 16)) +#define rot3(x) (((x) << 8) | ((x) >> 24)) + +/* + * This cute trick does 4 'mul by two' at once. Stolen from + * Dr B. R. Gladman but I'm sure the u-(u>>7) is + * a standard graphics trick + * The key to this is that we need to xor with 0x1b if the top bit is set. + * a 1xxx xxxx 0xxx 0xxx First we mask the 7bit, + * b 1000 0000 0000 0000 then we shift right by 7 putting the 7bit in 0bit, + * c 0000 0001 0000 0000 we then subtract (c) from (b) + * d 0111 1111 0000 0000 and now we and with our mask + * e 0001 1011 0000 0000 + */ +#define mt 0x80808080 +#define ml 0x7f7f7f7f +#define mh 0xfefefefe +#define mm 0x1b1b1b1b +#define mul2(x,t) ((t)=((x)&mt), \ + ((((x)+(x))&mh)^(((t)-((t)>>7))&mm))) + +#define inv_mix_col(x,f2,f4,f8,f9) (\ + (f2)=mul2(x,f2), \ + (f4)=mul2(f2,f4), \ + (f8)=mul2(f4,f8), \ + (f9)=(x)^(f8), \ + (f8)=((f2)^(f4)^(f8)), \ + (f2)^=(f9), \ + (f4)^=(f9), \ + (f8)^=rot3(f2), \ + (f8)^=rot2(f4), \ + (f8)^rot1(f9)) + +/* + * AES S-box + */ +static const uint8_t aes_sbox[256] = +{ + 0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5, + 0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76, + 0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0, + 0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0, + 0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC, + 0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15, + 0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A, + 0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75, + 0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0, + 0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84, + 0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B, + 0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF, + 0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85, + 0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8, + 0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5, + 0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2, + 0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17, + 0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73, + 0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88, + 0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB, + 0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C, + 0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79, + 0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9, + 0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08, + 0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6, + 0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A, + 0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E, + 0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E, + 0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94, + 0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF, + 0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68, + 0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16, +}; + +/* + * AES is-box + */ +static const uint8_t aes_isbox[256] = +{ + 0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38, + 0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb, + 0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87, + 0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb, + 0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d, + 0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e, + 0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2, + 0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25, + 0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16, + 0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92, + 0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda, + 0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84, + 0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a, + 0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06, + 0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02, + 0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b, + 0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea, + 0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73, + 0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85, + 0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e, + 0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89, + 0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b, + 0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20, + 0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4, + 0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31, + 0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f, + 0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d, + 0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef, + 0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0, + 0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61, + 0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26, + 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d +}; + +static const unsigned char Rcon[30]= +{ + 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, + 0x1b,0x36,0x6c,0xd8,0xab,0x4d,0x9a,0x2f, + 0x5e,0xbc,0x63,0xc6,0x97,0x35,0x6a,0xd4, + 0xb3,0x7d,0xfa,0xef,0xc5,0x91, +}; + +/* ----- static functions ----- */ +static void AES_encrypt(const AES_CTX *ctx, uint32_t *data); +static void AES_decrypt(const AES_CTX *ctx, uint32_t *data); + +/* Perform doubling in Galois Field GF(2^8) using the irreducible polynomial + x^8+x^4+x^3+x+1 */ +static unsigned char AES_xtime(uint32_t x) +{ + return (x&0x80) ? (x<<1)^0x1b : x<<1; +} + +/** + * Set up AES with the key/iv and cipher size. + */ +void AES_set_key(AES_CTX *ctx, const uint8_t *key, + const uint8_t *iv, AES_MODE mode) +{ + int i, ii; + uint32_t *W, tmp, tmp2; + const unsigned char *ip; + int words; + + switch (mode) + { + case AES_MODE_128: + i = 10; + words = 4; + break; + + case AES_MODE_256: + i = 14; + words = 8; + break; + + default: /* fail silently */ + return; + } + + ctx->rounds = i; + ctx->key_size = words; + W = ctx->ks; + for (i = 0; i < words; i+=2) + { + W[i+0]= ((uint32_t)key[ 0]<<24)| + ((uint32_t)key[ 1]<<16)| + ((uint32_t)key[ 2]<< 8)| + ((uint32_t)key[ 3] ); + W[i+1]= ((uint32_t)key[ 4]<<24)| + ((uint32_t)key[ 5]<<16)| + ((uint32_t)key[ 6]<< 8)| + ((uint32_t)key[ 7] ); + key += 8; + } + + ip = Rcon; + ii = 4 * (ctx->rounds+1); + for (i = words; i> 8)&0xff]<<16; + tmp2|=(uint32_t)aes_sbox[(tmp>>16)&0xff]<<24; + tmp2|=(uint32_t)aes_sbox[(tmp>>24) ]; + tmp=tmp2^(((unsigned int)*ip)<<24); + ip++; + } + + if ((words == 8) && ((i % words) == 4)) + { + tmp2 =(uint32_t)aes_sbox[(tmp )&0xff] ; + tmp2|=(uint32_t)aes_sbox[(tmp>> 8)&0xff]<< 8; + tmp2|=(uint32_t)aes_sbox[(tmp>>16)&0xff]<<16; + tmp2|=(uint32_t)aes_sbox[(tmp>>24) ]<<24; + tmp=tmp2; + } + + W[i]=W[i-words]^tmp; + } + + /* copy the iv across */ + memcpy(ctx->iv, iv, 16); +} + +/** + * Change a key for decryption. + */ +void AES_convert_key(AES_CTX *ctx) +{ + int i; + uint32_t *k,w,t1,t2,t3,t4; + + k = ctx->ks; + k += 4; + + for (i= ctx->rounds*4; i > 4; i--) + { + w= *k; + w = inv_mix_col(w,t1,t2,t3,t4); + *k++ =w; + } +} + +/** + * Encrypt a byte sequence (with a block size 16) using the AES cipher. + */ +void AES_cbc_encrypt(AES_CTX *ctx, const uint8_t *msg, uint8_t *out, int length) +{ + int i; + uint32_t tin[4], tout[4], iv[4]; + + memcpy(iv, ctx->iv, AES_IV_SIZE); + for (i = 0; i < 4; i++) + tout[i] = ntohl(iv[i]); + + for (length -= AES_BLOCKSIZE; length >= 0; length -= AES_BLOCKSIZE) + { + uint32_t msg_32[4]; + uint32_t out_32[4]; + memcpy(msg_32, msg, AES_BLOCKSIZE); + msg += AES_BLOCKSIZE; + + for (i = 0; i < 4; i++) + tin[i] = ntohl(msg_32[i])^tout[i]; + + AES_encrypt(ctx, tin); + + for (i = 0; i < 4; i++) + { + tout[i] = tin[i]; + out_32[i] = htonl(tout[i]); + } + + memcpy(out, out_32, AES_BLOCKSIZE); + out += AES_BLOCKSIZE; + } + + for (i = 0; i < 4; i++) + iv[i] = htonl(tout[i]); + memcpy(ctx->iv, iv, AES_IV_SIZE); +} + +/** + * Decrypt a byte sequence (with a block size 16) using the AES cipher. + */ +void AES_cbc_decrypt(AES_CTX *ctx, const uint8_t *msg, uint8_t *out, int length) +{ + int i; + uint32_t tin[4], xor[4], tout[4], data[4], iv[4]; + + memcpy(iv, ctx->iv, AES_IV_SIZE); + for (i = 0; i < 4; i++) + xor[i] = ntohl(iv[i]); + + for (length -= 16; length >= 0; length -= 16) + { + uint32_t msg_32[4]; + uint32_t out_32[4]; + memcpy(msg_32, msg, AES_BLOCKSIZE); + msg += AES_BLOCKSIZE; + + for (i = 0; i < 4; i++) + { + tin[i] = ntohl(msg_32[i]); + data[i] = tin[i]; + } + + AES_decrypt(ctx, data); + + for (i = 0; i < 4; i++) + { + tout[i] = data[i]^xor[i]; + xor[i] = tin[i]; + out_32[i] = htonl(tout[i]); + } + + memcpy(out, out_32, AES_BLOCKSIZE); + out += AES_BLOCKSIZE; + } + + for (i = 0; i < 4; i++) + iv[i] = htonl(xor[i]); + memcpy(ctx->iv, iv, AES_IV_SIZE); +} + +/** + * Encrypt a single block (16 bytes) of data + */ +static void AES_encrypt(const AES_CTX *ctx, uint32_t *data) +{ + /* To make this code smaller, generate the sbox entries on the fly. + * This will have a really heavy effect upon performance. + */ + uint32_t tmp[4]; + uint32_t tmp1, old_a0, a0, a1, a2, a3, row; + int curr_rnd; + int rounds = ctx->rounds; + const uint32_t *k = ctx->ks; + + /* Pre-round key addition */ + for (row = 0; row < 4; row++) + data[row] ^= *(k++); + + /* Encrypt one block. */ + for (curr_rnd = 0; curr_rnd < rounds; curr_rnd++) + { + /* Perform ByteSub and ShiftRow operations together */ + for (row = 0; row < 4; row++) + { + a0 = (uint32_t)aes_sbox[(data[row%4]>>24)&0xFF]; + a1 = (uint32_t)aes_sbox[(data[(row+1)%4]>>16)&0xFF]; + a2 = (uint32_t)aes_sbox[(data[(row+2)%4]>>8)&0xFF]; + a3 = (uint32_t)aes_sbox[(data[(row+3)%4])&0xFF]; + + /* Perform MixColumn iff not last round */ + if (curr_rnd < (rounds - 1)) + { + tmp1 = a0 ^ a1 ^ a2 ^ a3; + old_a0 = a0; + a0 ^= tmp1 ^ AES_xtime(a0 ^ a1); + a1 ^= tmp1 ^ AES_xtime(a1 ^ a2); + a2 ^= tmp1 ^ AES_xtime(a2 ^ a3); + a3 ^= tmp1 ^ AES_xtime(a3 ^ old_a0); + } + + tmp[row] = ((a0 << 24) | (a1 << 16) | (a2 << 8) | a3); + } + + /* KeyAddition - note that it is vital that this loop is separate from + the MixColumn operation, which must be atomic...*/ + for (row = 0; row < 4; row++) + data[row] = tmp[row] ^ *(k++); + } +} + +/** + * Decrypt a single block (16 bytes) of data + */ +static void AES_decrypt(const AES_CTX *ctx, uint32_t *data) +{ + uint32_t tmp[4]; + uint32_t xt0,xt1,xt2,xt3,xt4,xt5,xt6; + uint32_t a0, a1, a2, a3, row; + int curr_rnd; + int rounds = ctx->rounds; + const uint32_t *k = ctx->ks + ((rounds+1)*4); + + /* pre-round key addition */ + for (row=4; row > 0;row--) + data[row-1] ^= *(--k); + + /* Decrypt one block */ + for (curr_rnd = 0; curr_rnd < rounds; curr_rnd++) + { + /* Perform ByteSub and ShiftRow operations together */ + for (row = 4; row > 0; row--) + { + a0 = aes_isbox[(data[(row+3)%4]>>24)&0xFF]; + a1 = aes_isbox[(data[(row+2)%4]>>16)&0xFF]; + a2 = aes_isbox[(data[(row+1)%4]>>8)&0xFF]; + a3 = aes_isbox[(data[row%4])&0xFF]; + + /* Perform MixColumn iff not last round */ + if (curr_rnd<(rounds-1)) + { + /* The MDS cofefficients (0x09, 0x0B, 0x0D, 0x0E) + are quite large compared to encryption; this + operation slows decryption down noticeably. */ + xt0 = AES_xtime(a0^a1); + xt1 = AES_xtime(a1^a2); + xt2 = AES_xtime(a2^a3); + xt3 = AES_xtime(a3^a0); + xt4 = AES_xtime(xt0^xt1); + xt5 = AES_xtime(xt1^xt2); + xt6 = AES_xtime(xt4^xt5); + + xt0 ^= a1^a2^a3^xt4^xt6; + xt1 ^= a0^a2^a3^xt5^xt6; + xt2 ^= a0^a1^a3^xt4^xt6; + xt3 ^= a0^a1^a2^xt5^xt6; + tmp[row-1] = ((xt0<<24)|(xt1<<16)|(xt2<<8)|xt3); + } + else + tmp[row-1] = ((a0<<24)|(a1<<16)|(a2<<8)|a3); + } + + for (row = 4; row > 0; row--) + data[row-1] = tmp[row-1] ^ *(--k); + } +} diff --git a/user/mpy/lib/axtls/crypto/bigint.c b/user/mpy/lib/axtls/crypto/bigint.c new file mode 100644 index 0000000..c8b9a6a --- /dev/null +++ b/user/mpy/lib/axtls/crypto/bigint.c @@ -0,0 +1,1516 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @defgroup bigint_api Big Integer API + * @brief The bigint implementation as used by the axTLS project. + * + * The bigint library is for RSA encryption/decryption as well as signing. + * This code tries to minimise use of malloc/free by maintaining a small + * cache. A bigint context may maintain state by being made "permanent". + * It be be later released with a bi_depermanent() and bi_free() call. + * + * It supports the following reduction techniques: + * - Classical + * - Barrett + * - Montgomery + * + * It also implements the following: + * - Karatsuba multiplication + * - Squaring + * - Sliding window exponentiation + * - Chinese Remainder Theorem (implemented in rsa.c). + * + * All the algorithms used are pretty standard, and designed for different + * data bus sizes. Negative numbers are not dealt with at all, so a subtraction + * may need to be tested for negativity. + * + * This library steals some ideas from Jef Poskanzer + * + * and GMP . It gets most of its implementation + * detail from "The Handbook of Applied Cryptography" + * + * @{ + */ + +#include +#include +#include +#include +#include +#include "os_port.h" +#include "bigint.h" + +#define V1 v->comps[v->size-1] /**< v1 for division */ +#define V2 v->comps[v->size-2] /**< v2 for division */ +#define U(j) tmp_u->comps[tmp_u->size-j-1] /**< uj for division */ +#define Q(j) quotient->comps[quotient->size-j-1] /**< qj for division */ + +static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bi, comp i); +static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom); +static bigint *alloc(BI_CTX *ctx, int size); +static bigint *trim(bigint *bi); +static void more_comps(bigint *bi, int n); +#if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \ + defined(CONFIG_BIGINT_MONTGOMERY) +static bigint *comp_right_shift(bigint *biR, int num_shifts); +static bigint *comp_left_shift(bigint *biR, int num_shifts); +#endif + +#ifdef CONFIG_BIGINT_CHECK_ON +static void check(const bigint *bi); +#else +#define check(A) /**< disappears in normal production mode */ +#endif + + +/** + * @brief Start a new bigint context. + * @return A bigint context. + */ +BI_CTX *bi_initialize(void) +{ + /* calloc() sets everything to zero */ + BI_CTX *ctx = (BI_CTX *)calloc(1, sizeof(BI_CTX)); + + /* the radix */ + ctx->bi_radix = alloc(ctx, 2); + ctx->bi_radix->comps[0] = 0; + ctx->bi_radix->comps[1] = 1; + bi_permanent(ctx->bi_radix); + return ctx; +} + +/** + * @brief Close the bigint context and free any resources. + * + * Free up any used memory - a check is done if all objects were not + * properly freed. + * @param ctx [in] The bigint session context. + */ +void bi_terminate(BI_CTX *ctx) +{ + bi_depermanent(ctx->bi_radix); + bi_free(ctx, ctx->bi_radix); + + if (ctx->active_count != 0) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("bi_terminate: there were %d un-freed bigints\n", + ctx->active_count); +#endif + abort(); + } + + bi_clear_cache(ctx); + free(ctx); +} + +/** + *@brief Clear the memory cache. + */ +void bi_clear_cache(BI_CTX *ctx) +{ + bigint *p, *pn; + + if (ctx->free_list == NULL) + return; + + for (p = ctx->free_list; p != NULL; p = pn) + { + pn = p->next; + free(p->comps); + free(p); + } + + ctx->free_count = 0; + ctx->free_list = NULL; +} + +/** + * @brief Increment the number of references to this object. + * It does not do a full copy. + * @param bi [in] The bigint to copy. + * @return A reference to the same bigint. + */ +bigint *bi_copy(bigint *bi) +{ + check(bi); + if (bi->refs != PERMANENT) + bi->refs++; + return bi; +} + +/** + * @brief Simply make a bigint object "unfreeable" if bi_free() is called on it. + * + * For this object to be freed, bi_depermanent() must be called. + * @param bi [in] The bigint to be made permanent. + */ +void bi_permanent(bigint *bi) +{ + check(bi); + if (bi->refs != 1) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("bi_permanent: refs was not 1\n"); +#endif + abort(); + } + + bi->refs = PERMANENT; +} + +/** + * @brief Take a permanent object and make it eligible for freedom. + * @param bi [in] The bigint to be made back to temporary. + */ +void bi_depermanent(bigint *bi) +{ + check(bi); + if (bi->refs != PERMANENT) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("bi_depermanent: bigint was not permanent\n"); +#endif + abort(); + } + + bi->refs = 1; +} + +/** + * @brief Free a bigint object so it can be used again. + * + * The memory itself it not actually freed, just tagged as being available + * @param ctx [in] The bigint session context. + * @param bi [in] The bigint to be freed. + */ +void bi_free(BI_CTX *ctx, bigint *bi) +{ + check(bi); + if (bi->refs == PERMANENT) + { + return; + } + + if (--bi->refs > 0) + { + return; + } + + bi->next = ctx->free_list; + ctx->free_list = bi; + ctx->free_count++; + + if (--ctx->active_count < 0) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("bi_free: active_count went negative " + "- double-freed bigint?\n"); +#endif + abort(); + } +} + +/** + * @brief Convert an (unsigned) integer into a bigint. + * @param ctx [in] The bigint session context. + * @param i [in] The (unsigned) integer to be converted. + * + */ +bigint *int_to_bi(BI_CTX *ctx, comp i) +{ + bigint *biR = alloc(ctx, 1); + biR->comps[0] = i; + return biR; +} + +/** + * @brief Do a full copy of the bigint object. + * @param ctx [in] The bigint session context. + * @param bi [in] The bigint object to be copied. + */ +bigint *bi_clone(BI_CTX *ctx, const bigint *bi) +{ + bigint *biR = alloc(ctx, bi->size); + check(bi); + memcpy(biR->comps, bi->comps, bi->size*COMP_BYTE_SIZE); + return biR; +} + +/** + * @brief Perform an addition operation between two bigints. + * @param ctx [in] The bigint session context. + * @param bia [in] A bigint. + * @param bib [in] Another bigint. + * @return The result of the addition. + */ +bigint *bi_add(BI_CTX *ctx, bigint *bia, bigint *bib) +{ + int n; + comp carry = 0; + comp *pa, *pb; + + check(bia); + check(bib); + + n = max(bia->size, bib->size); + more_comps(bia, n+1); + more_comps(bib, n); + pa = bia->comps; + pb = bib->comps; + + do + { + comp sl, rl, cy1; + sl = *pa + *pb++; + rl = sl + carry; + cy1 = sl < *pa; + carry = cy1 | (rl < sl); + *pa++ = rl; + } while (--n != 0); + + *pa = carry; /* do overflow */ + bi_free(ctx, bib); + return trim(bia); +} + +/** + * @brief Perform a subtraction operation between two bigints. + * @param ctx [in] The bigint session context. + * @param bia [in] A bigint. + * @param bib [in] Another bigint. + * @param is_negative [out] If defined, indicates that the result was negative. + * is_negative may be null. + * @return The result of the subtraction. The result is always positive. + */ +bigint *bi_subtract(BI_CTX *ctx, + bigint *bia, bigint *bib, int *is_negative) +{ + int n = bia->size; + comp *pa, *pb, carry = 0; + + check(bia); + check(bib); + + more_comps(bib, n); + pa = bia->comps; + pb = bib->comps; + + do + { + comp sl, rl, cy1; + sl = *pa - *pb++; + rl = sl - carry; + cy1 = sl > *pa; + carry = cy1 | (rl > sl); + *pa++ = rl; + } while (--n != 0); + + if (is_negative) /* indicate a negative result */ + { + *is_negative = carry; + } + + bi_free(ctx, trim(bib)); /* put bib back to the way it was */ + return trim(bia); +} + +/** + * Perform a multiply between a bigint an an (unsigned) integer + */ +static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bia, comp b) +{ + int j = 0, n = bia->size; + bigint *biR = alloc(ctx, n + 1); + comp carry = 0; + comp *r = biR->comps; + comp *a = bia->comps; + + check(bia); + + /* clear things to start with */ + memset(r, 0, ((n+1)*COMP_BYTE_SIZE)); + + do + { + long_comp tmp = *r + (long_comp)a[j]*b + carry; + *r++ = (comp)tmp; /* downsize */ + carry = (comp)(tmp >> COMP_BIT_SIZE); + } while (++j < n); + + *r = carry; + bi_free(ctx, bia); + return trim(biR); +} + +/** + * @brief Does both division and modulo calculations. + * + * Used extensively when doing classical reduction. + * @param ctx [in] The bigint session context. + * @param u [in] A bigint which is the numerator. + * @param v [in] Either the denominator or the modulus depending on the mode. + * @param is_mod [n] Determines if this is a normal division (0) or a reduction + * (1). + * @return The result of the division/reduction. + */ +bigint *bi_divide(BI_CTX *ctx, bigint *u, bigint *v, int is_mod) +{ + int n = v->size, m = u->size-n; + int j = 0, orig_u_size = u->size; + uint8_t mod_offset = ctx->mod_offset; + comp d; + bigint *quotient, *tmp_u; + comp q_dash; + + check(u); + check(v); + + /* if doing reduction and we are < mod, then return mod */ + if (is_mod && bi_compare(v, u) > 0) + { + bi_free(ctx, v); + return u; + } + + quotient = alloc(ctx, m+1); + tmp_u = alloc(ctx, n+1); + v = trim(v); /* make sure we have no leading 0's */ + d = (comp)((long_comp)COMP_RADIX/(V1+1)); + + /* clear things to start with */ + memset(quotient->comps, 0, ((quotient->size)*COMP_BYTE_SIZE)); + + /* normalise */ + if (d > 1) + { + u = bi_int_multiply(ctx, u, d); + + if (is_mod) + { + v = ctx->bi_normalised_mod[mod_offset]; + } + else + { + v = bi_int_multiply(ctx, v, d); + } + } + + if (orig_u_size == u->size) /* new digit position u0 */ + { + more_comps(u, orig_u_size + 1); + } + + do + { + /* get a temporary short version of u */ + memcpy(tmp_u->comps, &u->comps[u->size-n-1-j], (n+1)*COMP_BYTE_SIZE); + + /* calculate q' */ + if (U(0) == V1) + { + q_dash = COMP_RADIX-1; + } + else + { + q_dash = (comp)(((long_comp)U(0)*COMP_RADIX + U(1))/V1); + + if (v->size > 1 && V2) + { + /* we are implementing the following: + if (V2*q_dash > (((U(0)*COMP_RADIX + U(1) - + q_dash*V1)*COMP_RADIX) + U(2))) ... */ + comp inner = (comp)((long_comp)COMP_RADIX*U(0) + U(1) - + (long_comp)q_dash*V1); + if ((long_comp)V2*q_dash > (long_comp)inner*COMP_RADIX + U(2)) + { + q_dash--; + } + } + } + + /* multiply and subtract */ + if (q_dash) + { + int is_negative; + tmp_u = bi_subtract(ctx, tmp_u, + bi_int_multiply(ctx, bi_copy(v), q_dash), &is_negative); + more_comps(tmp_u, n+1); + + Q(j) = q_dash; + + /* add back */ + if (is_negative) + { + Q(j)--; + tmp_u = bi_add(ctx, tmp_u, bi_copy(v)); + + /* lop off the carry */ + tmp_u->size--; + v->size--; + } + } + else + { + Q(j) = 0; + } + + /* copy back to u */ + memcpy(&u->comps[u->size-n-1-j], tmp_u->comps, (n+1)*COMP_BYTE_SIZE); + } while (++j <= m); + + bi_free(ctx, tmp_u); + bi_free(ctx, v); + + if (is_mod) /* get the remainder */ + { + bi_free(ctx, quotient); + return bi_int_divide(ctx, trim(u), d); + } + else /* get the quotient */ + { + bi_free(ctx, u); + return trim(quotient); + } +} + +/* + * Perform an integer divide on a bigint. + */ +static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom) +{ + int i = biR->size - 1; + long_comp r = 0; + + check(biR); + + do + { + r = (r<comps[i]; + biR->comps[i] = (comp)(r / denom); + r %= denom; + } while (--i >= 0); + + return trim(biR); +} + +#ifdef CONFIG_BIGINT_MONTGOMERY +/** + * There is a need for the value of integer N' such that B^-1(B-1)-N^-1N'=1, + * where B^-1(B-1) mod N=1. Actually, only the least significant part of + * N' is needed, hence the definition N0'=N' mod b. We reproduce below the + * simple algorithm from an article by Dusse and Kaliski to efficiently + * find N0' from N0 and b */ +static comp modular_inverse(bigint *bim) +{ + int i; + comp t = 1; + comp two_2_i_minus_1 = 2; /* 2^(i-1) */ + long_comp two_2_i = 4; /* 2^i */ + comp N = bim->comps[0]; + + for (i = 2; i <= COMP_BIT_SIZE; i++) + { + if ((long_comp)N*t%two_2_i >= two_2_i_minus_1) + { + t += two_2_i_minus_1; + } + + two_2_i_minus_1 <<= 1; + two_2_i <<= 1; + } + + return (comp)(COMP_RADIX-t); +} +#endif + +#if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \ + defined(CONFIG_BIGINT_MONTGOMERY) +/** + * Take each component and shift down (in terms of components) + */ +static bigint *comp_right_shift(bigint *biR, int num_shifts) +{ + int i = biR->size-num_shifts; + comp *x = biR->comps; + comp *y = &biR->comps[num_shifts]; + + check(biR); + + if (i <= 0) /* have we completely right shifted? */ + { + biR->comps[0] = 0; /* return 0 */ + biR->size = 1; + return biR; + } + + do + { + *x++ = *y++; + } while (--i > 0); + + biR->size -= num_shifts; + return biR; +} + +/** + * Take each component and shift it up (in terms of components) + */ +static bigint *comp_left_shift(bigint *biR, int num_shifts) +{ + int i = biR->size-1; + comp *x, *y; + + check(biR); + + if (num_shifts <= 0) + { + return biR; + } + + more_comps(biR, biR->size + num_shifts); + + x = &biR->comps[i+num_shifts]; + y = &biR->comps[i]; + + do + { + *x-- = *y--; + } while (i--); + + memset(biR->comps, 0, num_shifts*COMP_BYTE_SIZE); /* zero LS comps */ + return biR; +} +#endif + +/** + * @brief Allow a binary sequence to be imported as a bigint. + * @param ctx [in] The bigint session context. + * @param data [in] The data to be converted. + * @param size [in] The number of bytes of data. + * @return A bigint representing this data. + */ +bigint *bi_import(BI_CTX *ctx, const uint8_t *data, int size) +{ + bigint *biR = alloc(ctx, (size+COMP_BYTE_SIZE-1)/COMP_BYTE_SIZE); + int i, j = 0, offset = 0; + + memset(biR->comps, 0, biR->size*COMP_BYTE_SIZE); + + for (i = size-1; i >= 0; i--) + { + biR->comps[offset] += data[i] << (j*8); + + if (++j == COMP_BYTE_SIZE) + { + j = 0; + offset ++; + } + } + + return trim(biR); +} + +#ifdef CONFIG_SSL_FULL_MODE +/** + * @brief The testharness uses this code to import text hex-streams and + * convert them into bigints. + * @param ctx [in] The bigint session context. + * @param data [in] A string consisting of hex characters. The characters must + * be in upper case. + * @return A bigint representing this data. + */ +bigint *bi_str_import(BI_CTX *ctx, const char *data) +{ + int size = strlen(data); + bigint *biR = alloc(ctx, (size+COMP_NUM_NIBBLES-1)/COMP_NUM_NIBBLES); + int i, j = 0, offset = 0; + memset(biR->comps, 0, biR->size*COMP_BYTE_SIZE); + + for (i = size-1; i >= 0; i--) + { + int num = (data[i] <= '9') ? (data[i] - '0') : (data[i] - 'A' + 10); + biR->comps[offset] += num << (j*4); + + if (++j == COMP_NUM_NIBBLES) + { + j = 0; + offset ++; + } + } + + return biR; +} + +void bi_print(const char *label, bigint *x) +{ + int i, j; + + if (x == NULL) + { + printf("%s: (null)\n", label); + return; + } + + printf("%s: (size %d)\n", label, x->size); + for (i = x->size-1; i >= 0; i--) + { + for (j = COMP_NUM_NIBBLES-1; j >= 0; j--) + { + comp mask = 0x0f << (j*4); + comp num = (x->comps[i] & mask) >> (j*4); + putc((num <= 9) ? (num + '0') : (num + 'A' - 10), stdout); + } + } + + printf("\n"); +} +#endif + +/** + * @brief Take a bigint and convert it into a byte sequence. + * + * This is useful after a decrypt operation. + * @param ctx [in] The bigint session context. + * @param x [in] The bigint to be converted. + * @param data [out] The converted data as a byte stream. + * @param size [in] The maximum size of the byte stream. Unused bytes will be + * zeroed. + */ +void bi_export(BI_CTX *ctx, bigint *x, uint8_t *data, int size) +{ + int i, j, k = size-1; + + check(x); + memset(data, 0, size); /* ensure all leading 0's are cleared */ + + for (i = 0; i < x->size; i++) + { + for (j = 0; j < COMP_BYTE_SIZE; j++) + { + comp mask = 0xff << (j*8); + int num = (x->comps[i] & mask) >> (j*8); + data[k--] = num; + + if (k < 0) + { + goto buf_done; + } + } + } +buf_done: + + bi_free(ctx, x); +} + +/** + * @brief Pre-calculate some of the expensive steps in reduction. + * + * This function should only be called once (normally when a session starts). + * When the session is over, bi_free_mod() should be called. bi_mod_power() + * relies on this function being called. + * @param ctx [in] The bigint session context. + * @param bim [in] The bigint modulus that will be used. + * @param mod_offset [in] There are three moduluii that can be stored - the + * standard modulus, and its two primes p and q. This offset refers to which + * modulus we are referring to. + * @see bi_free_mod(), bi_mod_power(). + */ +void bi_set_mod(BI_CTX *ctx, bigint *bim, int mod_offset) +{ + int k = bim->size; + comp d = (comp)((long_comp)COMP_RADIX/(bim->comps[k-1]+1)); +#ifdef CONFIG_BIGINT_MONTGOMERY + bigint *R, *R2; +#endif + + ctx->bi_mod[mod_offset] = bim; + bi_permanent(ctx->bi_mod[mod_offset]); + ctx->bi_normalised_mod[mod_offset] = bi_int_multiply(ctx, bim, d); + bi_permanent(ctx->bi_normalised_mod[mod_offset]); + +#if defined(CONFIG_BIGINT_MONTGOMERY) + /* set montgomery variables */ + R = comp_left_shift(bi_clone(ctx, ctx->bi_radix), k-1); /* R */ + R2 = comp_left_shift(bi_clone(ctx, ctx->bi_radix), k*2-1); /* R^2 */ + ctx->bi_RR_mod_m[mod_offset] = bi_mod(ctx, R2); /* R^2 mod m */ + ctx->bi_R_mod_m[mod_offset] = bi_mod(ctx, R); /* R mod m */ + + bi_permanent(ctx->bi_RR_mod_m[mod_offset]); + bi_permanent(ctx->bi_R_mod_m[mod_offset]); + + ctx->N0_dash[mod_offset] = modular_inverse(ctx->bi_mod[mod_offset]); + +#elif defined (CONFIG_BIGINT_BARRETT) + ctx->bi_mu[mod_offset] = + bi_divide(ctx, comp_left_shift( + bi_clone(ctx, ctx->bi_radix), k*2-1), ctx->bi_mod[mod_offset], 0); + bi_permanent(ctx->bi_mu[mod_offset]); +#endif +} + +/** + * @brief Used when cleaning various bigints at the end of a session. + * @param ctx [in] The bigint session context. + * @param mod_offset [in] The offset to use. + * @see bi_set_mod(). + */ +void bi_free_mod(BI_CTX *ctx, int mod_offset) +{ + bi_depermanent(ctx->bi_mod[mod_offset]); + bi_free(ctx, ctx->bi_mod[mod_offset]); +#if defined (CONFIG_BIGINT_MONTGOMERY) + bi_depermanent(ctx->bi_RR_mod_m[mod_offset]); + bi_depermanent(ctx->bi_R_mod_m[mod_offset]); + bi_free(ctx, ctx->bi_RR_mod_m[mod_offset]); + bi_free(ctx, ctx->bi_R_mod_m[mod_offset]); +#elif defined(CONFIG_BIGINT_BARRETT) + bi_depermanent(ctx->bi_mu[mod_offset]); + bi_free(ctx, ctx->bi_mu[mod_offset]); +#endif + bi_depermanent(ctx->bi_normalised_mod[mod_offset]); + bi_free(ctx, ctx->bi_normalised_mod[mod_offset]); +} + +/** + * Perform a standard multiplication between two bigints. + * + * Barrett reduction has no need for some parts of the product, so ignore bits + * of the multiply. This routine gives Barrett its big performance + * improvements over Classical/Montgomery reduction methods. + */ +static bigint *regular_multiply(BI_CTX *ctx, bigint *bia, bigint *bib, + int inner_partial, int outer_partial) +{ + int i = 0, j; + int n = bia->size; + int t = bib->size; + bigint *biR = alloc(ctx, n + t); + comp *sr = biR->comps; + comp *sa = bia->comps; + comp *sb = bib->comps; + + check(bia); + check(bib); + + /* clear things to start with */ + memset(biR->comps, 0, ((n+t)*COMP_BYTE_SIZE)); + + do + { + long_comp tmp; + comp carry = 0; + int r_index = i; + j = 0; + + if (outer_partial && outer_partial-i > 0 && outer_partial < n) + { + r_index = outer_partial-1; + j = outer_partial-i-1; + } + + do + { + if (inner_partial && r_index >= inner_partial) + { + break; + } + + tmp = sr[r_index] + ((long_comp)sa[j])*sb[i] + carry; + sr[r_index++] = (comp)tmp; /* downsize */ + carry = tmp >> COMP_BIT_SIZE; + } while (++j < n); + + sr[r_index] = carry; + } while (++i < t); + + bi_free(ctx, bia); + bi_free(ctx, bib); + return trim(biR); +} + +#ifdef CONFIG_BIGINT_KARATSUBA +/* + * Karatsuba improves on regular multiplication due to only 3 multiplications + * being done instead of 4. The additional additions/subtractions are O(N) + * rather than O(N^2) and so for big numbers it saves on a few operations + */ +static bigint *karatsuba(BI_CTX *ctx, bigint *bia, bigint *bib, int is_square) +{ + bigint *x0, *x1; + bigint *p0, *p1, *p2; + int m; + + if (is_square) + { + m = (bia->size + 1)/2; + } + else + { + m = (max(bia->size, bib->size) + 1)/2; + } + + x0 = bi_clone(ctx, bia); + x0->size = m; + x1 = bi_clone(ctx, bia); + comp_right_shift(x1, m); + bi_free(ctx, bia); + + /* work out the 3 partial products */ + if (is_square) + { + p0 = bi_square(ctx, bi_copy(x0)); + p2 = bi_square(ctx, bi_copy(x1)); + p1 = bi_square(ctx, bi_add(ctx, x0, x1)); + } + else /* normal multiply */ + { + bigint *y0, *y1; + y0 = bi_clone(ctx, bib); + y0->size = m; + y1 = bi_clone(ctx, bib); + comp_right_shift(y1, m); + bi_free(ctx, bib); + + p0 = bi_multiply(ctx, bi_copy(x0), bi_copy(y0)); + p2 = bi_multiply(ctx, bi_copy(x1), bi_copy(y1)); + p1 = bi_multiply(ctx, bi_add(ctx, x0, x1), bi_add(ctx, y0, y1)); + } + + p1 = bi_subtract(ctx, + bi_subtract(ctx, p1, bi_copy(p2), NULL), bi_copy(p0), NULL); + + comp_left_shift(p1, m); + comp_left_shift(p2, 2*m); + return bi_add(ctx, p1, bi_add(ctx, p0, p2)); +} +#endif + +/** + * @brief Perform a multiplication operation between two bigints. + * @param ctx [in] The bigint session context. + * @param bia [in] A bigint. + * @param bib [in] Another bigint. + * @return The result of the multiplication. + */ +bigint *bi_multiply(BI_CTX *ctx, bigint *bia, bigint *bib) +{ + check(bia); + check(bib); + +#ifdef CONFIG_BIGINT_KARATSUBA + if (min(bia->size, bib->size) < MUL_KARATSUBA_THRESH) + { + return regular_multiply(ctx, bia, bib, 0, 0); + } + + return karatsuba(ctx, bia, bib, 0); +#else + return regular_multiply(ctx, bia, bib, 0, 0); +#endif +} + +#ifdef CONFIG_BIGINT_SQUARE +/* + * Perform the actual square operion. It takes into account overflow. + */ +static bigint *regular_square(BI_CTX *ctx, bigint *bi) +{ + int t = bi->size; + int i = 0, j; + bigint *biR = alloc(ctx, t*2+1); + comp *w = biR->comps; + comp *x = bi->comps; + long_comp carry; + memset(w, 0, biR->size*COMP_BYTE_SIZE); + + do + { + long_comp tmp = w[2*i] + (long_comp)x[i]*x[i]; + w[2*i] = (comp)tmp; + carry = tmp >> COMP_BIT_SIZE; + + for (j = i+1; j < t; j++) + { + uint8_t c = 0; + long_comp xx = (long_comp)x[i]*x[j]; + if ((COMP_MAX-xx) < xx) + c = 1; + + tmp = (xx<<1); + + if ((COMP_MAX-tmp) < w[i+j]) + c = 1; + + tmp += w[i+j]; + + if ((COMP_MAX-tmp) < carry) + c = 1; + + tmp += carry; + w[i+j] = (comp)tmp; + carry = tmp >> COMP_BIT_SIZE; + + if (c) + carry += COMP_RADIX; + } + + tmp = w[i+t] + carry; + w[i+t] = (comp)tmp; + w[i+t+1] = tmp >> COMP_BIT_SIZE; + } while (++i < t); + + bi_free(ctx, bi); + return trim(biR); +} + +/** + * @brief Perform a square operation on a bigint. + * @param ctx [in] The bigint session context. + * @param bia [in] A bigint. + * @return The result of the multiplication. + */ +bigint *bi_square(BI_CTX *ctx, bigint *bia) +{ + check(bia); + +#ifdef CONFIG_BIGINT_KARATSUBA + if (bia->size < SQU_KARATSUBA_THRESH) + { + return regular_square(ctx, bia); + } + + return karatsuba(ctx, bia, NULL, 1); +#else + return regular_square(ctx, bia); +#endif +} +#endif + +/** + * @brief Compare two bigints. + * @param bia [in] A bigint. + * @param bib [in] Another bigint. + * @return -1 if smaller, 1 if larger and 0 if equal. + */ +int bi_compare(bigint *bia, bigint *bib) +{ + int r, i; + + check(bia); + check(bib); + + if (bia->size > bib->size) + r = 1; + else if (bia->size < bib->size) + r = -1; + else + { + comp *a = bia->comps; + comp *b = bib->comps; + + /* Same number of components. Compare starting from the high end + * and working down. */ + r = 0; + i = bia->size - 1; + + do + { + if (a[i] > b[i]) + { + r = 1; + break; + } + else if (a[i] < b[i]) + { + r = -1; + break; + } + } while (--i >= 0); + } + + return r; +} + +/* + * Allocate and zero more components. Does not consume bi. + */ +static void more_comps(bigint *bi, int n) +{ + if (n > bi->max_comps) + { + bi->max_comps = max(bi->max_comps * 2, n); + bi->comps = (comp*)realloc(bi->comps, bi->max_comps * COMP_BYTE_SIZE); + } + + if (n > bi->size) + { + memset(&bi->comps[bi->size], 0, (n-bi->size)*COMP_BYTE_SIZE); + } + + bi->size = n; +} + +/* + * Make a new empty bigint. It may just use an old one if one is available. + * Otherwise get one off the heap. + */ +static bigint *alloc(BI_CTX *ctx, int size) +{ + bigint *biR; + + /* Can we recycle an old bigint? */ + if (ctx->free_list != NULL) + { + biR = ctx->free_list; + ctx->free_list = biR->next; + ctx->free_count--; + + if (biR->refs != 0) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("alloc: refs was not 0\n"); +#endif + abort(); /* create a stack trace from a core dump */ + } + + more_comps(biR, size); + } + else + { + /* No free bigints available - create a new one. */ + biR = (bigint *)malloc(sizeof(bigint)); + biR->comps = (comp*)malloc(size * COMP_BYTE_SIZE); + biR->max_comps = size; /* give some space to spare */ + } + + biR->size = size; + biR->refs = 1; + biR->next = NULL; + ctx->active_count++; + return biR; +} + +/* + * Work out the highest '1' bit in an exponent. Used when doing sliding-window + * exponentiation. + */ +static int find_max_exp_index(bigint *biexp) +{ + int i = COMP_BIT_SIZE-1; + comp shift = COMP_RADIX/2; + comp test = biexp->comps[biexp->size-1]; /* assume no leading zeroes */ + + check(biexp); + + do + { + if (test & shift) + { + return i+(biexp->size-1)*COMP_BIT_SIZE; + } + + shift >>= 1; + } while (i-- != 0); + + return -1; /* error - must have been a leading 0 */ +} + +/* + * Is a particular bit is an exponent 1 or 0? Used when doing sliding-window + * exponentiation. + */ +static int exp_bit_is_one(bigint *biexp, int offset) +{ + comp test = biexp->comps[offset / COMP_BIT_SIZE]; + int num_shifts = offset % COMP_BIT_SIZE; + comp shift = 1; + int i; + + check(biexp); + + for (i = 0; i < num_shifts; i++) + { + shift <<= 1; + } + + return (test & shift) != 0; +} + +#ifdef CONFIG_BIGINT_CHECK_ON +/* + * Perform a sanity check on bi. + */ +static void check(const bigint *bi) +{ + if (bi->refs <= 0) + { + printf("check: zero or negative refs in bigint\n"); + abort(); + } + + if (bi->next != NULL) + { + printf("check: attempt to use a bigint from " + "the free list\n"); + abort(); + } +} +#endif + +/* + * Delete any leading 0's (and allow for 0). + */ +static bigint *trim(bigint *bi) +{ + check(bi); + + while (bi->comps[bi->size-1] == 0 && bi->size > 1) + { + bi->size--; + } + + return bi; +} + +#if defined(CONFIG_BIGINT_MONTGOMERY) +/** + * @brief Perform a single montgomery reduction. + * @param ctx [in] The bigint session context. + * @param bixy [in] A bigint. + * @return The result of the montgomery reduction. + */ +bigint *bi_mont(BI_CTX *ctx, bigint *bixy) +{ + int i = 0, n; + uint8_t mod_offset = ctx->mod_offset; + bigint *bim = ctx->bi_mod[mod_offset]; + comp mod_inv = ctx->N0_dash[mod_offset]; + + check(bixy); + + if (ctx->use_classical) /* just use classical instead */ + { + return bi_mod(ctx, bixy); + } + + n = bim->size; + + do + { + bixy = bi_add(ctx, bixy, comp_left_shift( + bi_int_multiply(ctx, bim, bixy->comps[i]*mod_inv), i)); + } while (++i < n); + + comp_right_shift(bixy, n); + + if (bi_compare(bixy, bim) >= 0) + { + bixy = bi_subtract(ctx, bixy, bim, NULL); + } + + return bixy; +} + +#elif defined(CONFIG_BIGINT_BARRETT) +/* + * Stomp on the most significant components to give the illusion of a "mod base + * radix" operation + */ +static bigint *comp_mod(bigint *bi, int mod) +{ + check(bi); + + if (bi->size > mod) + { + bi->size = mod; + } + + return bi; +} + +/** + * @brief Perform a single Barrett reduction. + * @param ctx [in] The bigint session context. + * @param bi [in] A bigint. + * @return The result of the Barrett reduction. + */ +bigint *bi_barrett(BI_CTX *ctx, bigint *bi) +{ + bigint *q1, *q2, *q3, *r1, *r2, *r; + uint8_t mod_offset = ctx->mod_offset; + bigint *bim = ctx->bi_mod[mod_offset]; + int k = bim->size; + + check(bi); + check(bim); + + /* use Classical method instead - Barrett cannot help here */ + if (bi->size > k*2) + { + return bi_mod(ctx, bi); + } + + q1 = comp_right_shift(bi_clone(ctx, bi), k-1); + + /* do outer partial multiply */ + q2 = regular_multiply(ctx, q1, ctx->bi_mu[mod_offset], 0, k-1); + q3 = comp_right_shift(q2, k+1); + r1 = comp_mod(bi, k+1); + + /* do inner partial multiply */ + r2 = comp_mod(regular_multiply(ctx, q3, bim, k+1, 0), k+1); + r = bi_subtract(ctx, r1, r2, NULL); + + /* if (r >= m) r = r - m; */ + if (bi_compare(r, bim) >= 0) + { + r = bi_subtract(ctx, r, bim, NULL); + } + + return r; +} +#endif /* CONFIG_BIGINT_BARRETT */ + +#ifdef CONFIG_BIGINT_SLIDING_WINDOW +/* + * Work out g1, g3, g5, g7... etc for the sliding-window algorithm + */ +static void precompute_slide_window(BI_CTX *ctx, int window, bigint *g1) +{ + int k = 1, i; + bigint *g2; + + for (i = 0; i < window-1; i++) /* compute 2^(window-1) */ + { + k <<= 1; + } + + ctx->g = (bigint **)malloc(k*sizeof(bigint *)); + ctx->g[0] = bi_clone(ctx, g1); + bi_permanent(ctx->g[0]); + g2 = bi_residue(ctx, bi_square(ctx, ctx->g[0])); /* g^2 */ + + for (i = 1; i < k; i++) + { + ctx->g[i] = bi_residue(ctx, bi_multiply(ctx, ctx->g[i-1], bi_copy(g2))); + bi_permanent(ctx->g[i]); + } + + bi_free(ctx, g2); + ctx->window = k; +} +#endif + +/** + * @brief Perform a modular exponentiation. + * + * This function requires bi_set_mod() to have been called previously. This is + * one of the optimisations used for performance. + * @param ctx [in] The bigint session context. + * @param bi [in] The bigint on which to perform the mod power operation. + * @param biexp [in] The bigint exponent. + * @return The result of the mod exponentiation operation + * @see bi_set_mod(). + */ +bigint *bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp) +{ + int i = find_max_exp_index(biexp), j, window_size = 1; + bigint *biR = int_to_bi(ctx, 1); + +#if defined(CONFIG_BIGINT_MONTGOMERY) + uint8_t mod_offset = ctx->mod_offset; + if (!ctx->use_classical) + { + /* preconvert */ + bi = bi_mont(ctx, + bi_multiply(ctx, bi, ctx->bi_RR_mod_m[mod_offset])); /* x' */ + bi_free(ctx, biR); + biR = ctx->bi_R_mod_m[mod_offset]; /* A */ + } +#endif + + check(bi); + check(biexp); + +#ifdef CONFIG_BIGINT_SLIDING_WINDOW + for (j = i; j > 32; j /= 5) /* work out an optimum size */ + window_size++; + + /* work out the slide constants */ + precompute_slide_window(ctx, window_size, bi); +#else /* just one constant */ + ctx->g = (bigint **)malloc(sizeof(bigint *)); + ctx->g[0] = bi_clone(ctx, bi); + ctx->window = 1; + bi_permanent(ctx->g[0]); +#endif + + /* if sliding-window is off, then only one bit will be done at a time and + * will reduce to standard left-to-right exponentiation */ + do + { +#ifdef __ets__ + void ets_loop_iter(void); + ets_loop_iter(); +#endif + if (exp_bit_is_one(biexp, i)) + { + int l = i-window_size+1; + int part_exp = 0; + + if (l < 0) /* LSB of exponent will always be 1 */ + l = 0; + else + { + while (exp_bit_is_one(biexp, l) == 0) + l++; /* go back up */ + } + + /* build up the section of the exponent */ + for (j = i; j >= l; j--) + { + biR = bi_residue(ctx, bi_square(ctx, biR)); + if (exp_bit_is_one(biexp, j)) + part_exp++; + + if (j != l) + part_exp <<= 1; + } + + part_exp = (part_exp-1)/2; /* adjust for array */ + biR = bi_residue(ctx, bi_multiply(ctx, biR, ctx->g[part_exp])); + i = l-1; + } + else /* square it */ + { + biR = bi_residue(ctx, bi_square(ctx, biR)); + i--; + } + } while (i >= 0); + + /* cleanup */ + for (i = 0; i < ctx->window; i++) + { + bi_depermanent(ctx->g[i]); + bi_free(ctx, ctx->g[i]); + } + + free(ctx->g); + bi_free(ctx, bi); + bi_free(ctx, biexp); +#if defined CONFIG_BIGINT_MONTGOMERY + return ctx->use_classical ? biR : bi_mont(ctx, biR); /* convert back */ +#else /* CONFIG_BIGINT_CLASSICAL or CONFIG_BIGINT_BARRETT */ + return biR; +#endif +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION +/** + * @brief Perform a modular exponentiation using a temporary modulus. + * + * We need this function to check the signatures of certificates. The modulus + * of this function is temporary as it's just used for authentication. + * @param ctx [in] The bigint session context. + * @param bi [in] The bigint to perform the exp/mod. + * @param bim [in] The temporary modulus. + * @param biexp [in] The bigint exponent. + * @return The result of the mod exponentiation operation + * @see bi_set_mod(). + */ +bigint *bi_mod_power2(BI_CTX *ctx, bigint *bi, bigint *bim, bigint *biexp) +{ + bigint *biR, *tmp_biR; + + /* Set up a temporary bigint context and transfer what we need between + * them. We need to do this since we want to keep the original modulus + * which is already in this context. This operation is only called when + * doing peer verification, and so is not expensive :-) */ + BI_CTX *tmp_ctx = bi_initialize(); + bi_set_mod(tmp_ctx, bi_clone(tmp_ctx, bim), BIGINT_M_OFFSET); + tmp_biR = bi_mod_power(tmp_ctx, + bi_clone(tmp_ctx, bi), + bi_clone(tmp_ctx, biexp)); + biR = bi_clone(ctx, tmp_biR); + bi_free(tmp_ctx, tmp_biR); + bi_free_mod(tmp_ctx, BIGINT_M_OFFSET); + bi_terminate(tmp_ctx); + + bi_free(ctx, bi); + bi_free(ctx, bim); + bi_free(ctx, biexp); + return biR; +} +#endif + +#ifdef CONFIG_BIGINT_CRT +/** + * @brief Use the Chinese Remainder Theorem to quickly perform RSA decrypts. + * + * @param ctx [in] The bigint session context. + * @param bi [in] The bigint to perform the exp/mod. + * @param dP [in] CRT's dP bigint + * @param dQ [in] CRT's dQ bigint + * @param p [in] CRT's p bigint + * @param q [in] CRT's q bigint + * @param qInv [in] CRT's qInv bigint + * @return The result of the CRT operation + */ +bigint *bi_crt(BI_CTX *ctx, bigint *bi, + bigint *dP, bigint *dQ, + bigint *p, bigint *q, bigint *qInv) +{ + bigint *m1, *m2, *h; + + /* Montgomery has a condition the 0 < x, y < m and these products violate + * that condition. So disable Montgomery when using CRT */ +#if defined(CONFIG_BIGINT_MONTGOMERY) + ctx->use_classical = 1; +#endif + ctx->mod_offset = BIGINT_P_OFFSET; + m1 = bi_mod_power(ctx, bi_copy(bi), dP); + + ctx->mod_offset = BIGINT_Q_OFFSET; + m2 = bi_mod_power(ctx, bi, dQ); + + h = bi_subtract(ctx, bi_add(ctx, m1, p), bi_copy(m2), NULL); + h = bi_multiply(ctx, h, qInv); + ctx->mod_offset = BIGINT_P_OFFSET; + h = bi_residue(ctx, h); +#if defined(CONFIG_BIGINT_MONTGOMERY) + ctx->use_classical = 0; /* reset for any further operation */ +#endif + return bi_add(ctx, m2, bi_multiply(ctx, q, h)); +} +#endif +/** @} */ diff --git a/user/mpy/lib/axtls/crypto/bigint.h b/user/mpy/lib/axtls/crypto/bigint.h new file mode 100644 index 0000000..2966a3e --- /dev/null +++ b/user/mpy/lib/axtls/crypto/bigint.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef BIGINT_HEADER +#define BIGINT_HEADER + +#include "crypto.h" + +BI_CTX *bi_initialize(void); +void bi_terminate(BI_CTX *ctx); +void bi_permanent(bigint *bi); +void bi_depermanent(bigint *bi); +void bi_clear_cache(BI_CTX *ctx); +void bi_free(BI_CTX *ctx, bigint *bi); +bigint *bi_copy(bigint *bi); +bigint *bi_clone(BI_CTX *ctx, const bigint *bi); +void bi_export(BI_CTX *ctx, bigint *bi, uint8_t *data, int size); +bigint *bi_import(BI_CTX *ctx, const uint8_t *data, int len); +bigint *int_to_bi(BI_CTX *ctx, comp i); + +/* the functions that actually do something interesting */ +bigint *bi_add(BI_CTX *ctx, bigint *bia, bigint *bib); +bigint *bi_subtract(BI_CTX *ctx, bigint *bia, + bigint *bib, int *is_negative); +bigint *bi_divide(BI_CTX *ctx, bigint *bia, bigint *bim, int is_mod); +bigint *bi_multiply(BI_CTX *ctx, bigint *bia, bigint *bib); +bigint *bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp); +bigint *bi_mod_power2(BI_CTX *ctx, bigint *bi, bigint *bim, bigint *biexp); +int bi_compare(bigint *bia, bigint *bib); +void bi_set_mod(BI_CTX *ctx, bigint *bim, int mod_offset); +void bi_free_mod(BI_CTX *ctx, int mod_offset); + +#ifdef CONFIG_SSL_FULL_MODE +void bi_print(const char *label, bigint *bi); +bigint *bi_str_import(BI_CTX *ctx, const char *data); +#endif + +/** + * @def bi_mod + * Find the residue of B. bi_set_mod() must be called before hand. + */ +#define bi_mod(A, B) bi_divide(A, B, ctx->bi_mod[ctx->mod_offset], 1) + +/** + * bi_residue() is technically the same as bi_mod(), but it uses the + * appropriate reduction technique (which is bi_mod() when doing classical + * reduction). + */ +#if defined(CONFIG_BIGINT_MONTGOMERY) +#define bi_residue(A, B) bi_mont(A, B) +bigint *bi_mont(BI_CTX *ctx, bigint *bixy); +#elif defined(CONFIG_BIGINT_BARRETT) +#define bi_residue(A, B) bi_barrett(A, B) +bigint *bi_barrett(BI_CTX *ctx, bigint *bi); +#else /* if defined(CONFIG_BIGINT_CLASSICAL) */ +#define bi_residue(A, B) bi_mod(A, B) +#endif + +#ifdef CONFIG_BIGINT_SQUARE +bigint *bi_square(BI_CTX *ctx, bigint *bi); +#else +#define bi_square(A, B) bi_multiply(A, bi_copy(B), B) +#endif + +#ifdef CONFIG_BIGINT_CRT +bigint *bi_crt(BI_CTX *ctx, bigint *bi, + bigint *dP, bigint *dQ, + bigint *p, bigint *q, + bigint *qInv); +#endif + +#endif diff --git a/user/mpy/lib/axtls/crypto/bigint_impl.h b/user/mpy/lib/axtls/crypto/bigint_impl.h new file mode 100644 index 0000000..fef6e03 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/bigint_impl.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef BIGINT_IMPL_HEADER +#define BIGINT_IMPL_HEADER + +/* Maintain a number of precomputed variables when doing reduction */ +#define BIGINT_M_OFFSET 0 /**< Normal modulo offset. */ +#ifdef CONFIG_BIGINT_CRT +#define BIGINT_P_OFFSET 1 /**< p modulo offset. */ +#define BIGINT_Q_OFFSET 2 /**< q module offset. */ +#define BIGINT_NUM_MODS 3 /**< The number of modulus constants used. */ +#else +#define BIGINT_NUM_MODS 1 +#endif + +/* Architecture specific functions for big ints */ +#if defined(CONFIG_INTEGER_8BIT) +#define COMP_RADIX 256U /**< Max component + 1 */ +#define COMP_MAX 0xFFFFU/**< (Max dbl comp -1) */ +#define COMP_BIT_SIZE 8 /**< Number of bits in a component. */ +#define COMP_BYTE_SIZE 1 /**< Number of bytes in a component. */ +#define COMP_NUM_NIBBLES 2 /**< Used For diagnostics only. */ +typedef uint8_t comp; /**< A single precision component. */ +typedef uint16_t long_comp; /**< A double precision component. */ +typedef int16_t slong_comp; /**< A signed double precision component. */ +#elif defined(CONFIG_INTEGER_16BIT) +#define COMP_RADIX 65536U /**< Max component + 1 */ +#define COMP_MAX 0xFFFFFFFFU/**< (Max dbl comp -1) */ +#define COMP_BIT_SIZE 16 /**< Number of bits in a component. */ +#define COMP_BYTE_SIZE 2 /**< Number of bytes in a component. */ +#define COMP_NUM_NIBBLES 4 /**< Used For diagnostics only. */ +typedef uint16_t comp; /**< A single precision component. */ +typedef uint32_t long_comp; /**< A double precision component. */ +typedef int32_t slong_comp; /**< A signed double precision component. */ +#else /* regular 32 bit */ +#ifdef WIN32 +#define COMP_RADIX 4294967296i64 +#define COMP_MAX 0xFFFFFFFFFFFFFFFFui64 +#else +#define COMP_RADIX 4294967296ULL /**< Max component + 1 */ +#define COMP_MAX 0xFFFFFFFFFFFFFFFFULL/**< (Max dbl comp -1) */ +#endif +#define COMP_BIT_SIZE 32 /**< Number of bits in a component. */ +#define COMP_BYTE_SIZE 4 /**< Number of bytes in a component. */ +#define COMP_NUM_NIBBLES 8 /**< Used For diagnostics only. */ +typedef uint32_t comp; /**< A single precision component. */ +typedef uint64_t long_comp; /**< A double precision component. */ +typedef int64_t slong_comp; /**< A signed double precision component. */ +#endif + +/** + * @struct _bigint + * @brief A big integer basic object + */ +struct _bigint +{ + struct _bigint* next; /**< The next bigint in the cache. */ + short size; /**< The number of components in this bigint. */ + short max_comps; /**< The heapsize allocated for this bigint */ + int refs; /**< An internal reference count. */ + comp* comps; /**< A ptr to the actual component data */ +}; + +typedef struct _bigint bigint; /**< An alias for _bigint */ + +/** + * Maintains the state of the cache, and a number of variables used in + * reduction. + */ +typedef struct /**< A big integer "session" context. */ +{ + bigint *active_list; /**< Bigints currently used. */ + bigint *free_list; /**< Bigints not used. */ + bigint *bi_radix; /**< The radix used. */ + bigint *bi_mod[BIGINT_NUM_MODS]; /**< modulus */ + +#if defined(CONFIG_BIGINT_MONTGOMERY) + bigint *bi_RR_mod_m[BIGINT_NUM_MODS]; /**< R^2 mod m */ + bigint *bi_R_mod_m[BIGINT_NUM_MODS]; /**< R mod m */ + comp N0_dash[BIGINT_NUM_MODS]; +#elif defined(CONFIG_BIGINT_BARRETT) + bigint *bi_mu[BIGINT_NUM_MODS]; /**< Storage for mu */ +#endif + bigint *bi_normalised_mod[BIGINT_NUM_MODS]; /**< Normalised mod storage. */ + bigint **g; /**< Used by sliding-window. */ + int window; /**< The size of the sliding window */ + int active_count; /**< Number of active bigints. */ + int free_count; /**< Number of free bigints. */ + +#ifdef CONFIG_BIGINT_MONTGOMERY + uint8_t use_classical; /**< Use classical reduction. */ +#endif + uint8_t mod_offset; /**< The mod offset we are using */ +} BI_CTX; + +#ifndef WIN32 +#define max(a,b) ((a)>(b)?(a):(b)) /**< Find the maximum of 2 numbers. */ +#define min(a,b) ((a)<(b)?(a):(b)) /**< Find the minimum of 2 numbers. */ +#endif + +#define PERMANENT 0x7FFF55AA /**< A magic number for permanents. */ + +#endif diff --git a/user/mpy/lib/axtls/crypto/crypto.h b/user/mpy/lib/axtls/crypto/crypto.h new file mode 100644 index 0000000..0949e52 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/crypto.h @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file crypto.h + */ + +#ifndef HEADER_CRYPTO_H +#define HEADER_CRYPTO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "bigint_impl.h" +#include "bigint.h" + +#ifndef STDCALL +#define STDCALL +#endif +#ifndef EXP_FUNC +#define EXP_FUNC +#endif + + +/* enable features based on a 'super-set' capbaility. */ +#if 0 +#if defined(CONFIG_SSL_FULL_MODE) +#define CONFIG_SSL_ENABLE_CLIENT +#define CONFIG_SSL_CERT_VERIFICATION +#elif defined(CONFIG_SSL_ENABLE_CLIENT) +#define CONFIG_SSL_CERT_VERIFICATION +#endif +#endif + +/************************************************************************** + * AES declarations + **************************************************************************/ + +#define AES_MAXROUNDS 14 +#define AES_BLOCKSIZE 16 +#define AES_IV_SIZE 16 + +typedef struct aes_key_st +{ + uint16_t rounds; + uint16_t key_size; + uint32_t ks[(AES_MAXROUNDS+1)*8]; + uint8_t iv[AES_IV_SIZE]; +} AES_CTX; + +typedef enum +{ + AES_MODE_128, + AES_MODE_256 +} AES_MODE; + +void AES_set_key(AES_CTX *ctx, const uint8_t *key, + const uint8_t *iv, AES_MODE mode); +void AES_cbc_encrypt(AES_CTX *ctx, const uint8_t *msg, + uint8_t *out, int length); +void AES_cbc_decrypt(AES_CTX *ks, const uint8_t *in, uint8_t *out, int length); +void AES_convert_key(AES_CTX *ctx); + +/************************************************************************** + * RC4 declarations + **************************************************************************/ + +typedef struct +{ + uint8_t x, y, m[256]; +} RC4_CTX; + +void RC4_setup(RC4_CTX *s, const uint8_t *key, int length); +void RC4_crypt(RC4_CTX *s, const uint8_t *msg, uint8_t *data, int length); + +/************************************************************************** + * SHA1 declarations + **************************************************************************/ + +#define SHA1_SIZE 20 + +/* + * This structure will hold context information for the SHA-1 + * hashing operation + */ +typedef struct +{ + uint32_t Intermediate_Hash[SHA1_SIZE/4]; /* Message Digest */ + uint32_t Length_Low; /* Message length in bits */ + uint32_t Length_High; /* Message length in bits */ + uint16_t Message_Block_Index; /* Index into message block array */ + uint8_t Message_Block[64]; /* 512-bit message blocks */ +} SHA1_CTX; + +void SHA1_Init(SHA1_CTX *); +void SHA1_Update(SHA1_CTX *, const uint8_t * msg, int len); +void SHA1_Final(uint8_t *digest, SHA1_CTX *); + +/************************************************************************** + * SHA256 declarations + **************************************************************************/ + +#define SHA256_SIZE 32 + +#ifndef SHA256_CTX +#define SHA256_CTX SHA256_CTX +typedef struct +{ + uint32_t total[2]; + uint32_t state[8]; + uint8_t buffer[64]; +} SHA256_CTX; + +void SHA256_Init(SHA256_CTX *c); +void SHA256_Update(SHA256_CTX *, const uint8_t *input, int len); +void SHA256_Final(uint8_t *digest, SHA256_CTX *); +#endif + +/************************************************************************** + * SHA512 declarations + **************************************************************************/ + +#define SHA512_SIZE 64 + +typedef struct +{ + union + { + uint64_t h[8]; + uint8_t digest[64]; + } h_dig; + union + { + uint64_t w[80]; + uint8_t buffer[128]; + } w_buf; + size_t size; + uint64_t totalSize; +} SHA512_CTX; + +void SHA512_Init(SHA512_CTX *c); +void SHA512_Update(SHA512_CTX *, const uint8_t *input, int len); +void SHA512_Final(uint8_t *digest, SHA512_CTX *); + +/************************************************************************** + * SHA384 declarations + **************************************************************************/ + +#define SHA384_SIZE 48 + +typedef SHA512_CTX SHA384_CTX; +void SHA384_Init(SHA384_CTX *c); +void SHA384_Update(SHA384_CTX *, const uint8_t *input, int len); +void SHA384_Final(uint8_t *digest, SHA384_CTX *); + +/************************************************************************** + * MD5 declarations + **************************************************************************/ + +#define MD5_SIZE 16 + +typedef struct +{ + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + uint8_t buffer[64]; /* input buffer */ +} MD5_CTX; + +EXP_FUNC void STDCALL MD5_Init(MD5_CTX *); +EXP_FUNC void STDCALL MD5_Update(MD5_CTX *, const uint8_t *msg, int len); +EXP_FUNC void STDCALL MD5_Final(uint8_t *digest, MD5_CTX *); + +/************************************************************************** + * HMAC declarations + **************************************************************************/ +void ssl_hmac_md5(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest); +void ssl_hmac_sha1(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest); +void hmac_sha256(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest); + +/************************************************************************** + * RSA declarations + **************************************************************************/ + +typedef struct +{ + bigint *m; /* modulus */ + bigint *e; /* public exponent */ + bigint *d; /* private exponent */ +#ifdef CONFIG_BIGINT_CRT + bigint *p; /* p as in m = pq */ + bigint *q; /* q as in m = pq */ + bigint *dP; /* d mod (p-1) */ + bigint *dQ; /* d mod (q-1) */ + bigint *qInv; /* q^-1 mod p */ +#endif + int num_octets; + BI_CTX *bi_ctx; +} RSA_CTX; + +void RSA_priv_key_new(RSA_CTX **rsa_ctx, + const uint8_t *modulus, int mod_len, + const uint8_t *pub_exp, int pub_len, + const uint8_t *priv_exp, int priv_len +#ifdef CONFIG_BIGINT_CRT + , const uint8_t *p, int p_len, + const uint8_t *q, int q_len, + const uint8_t *dP, int dP_len, + const uint8_t *dQ, int dQ_len, + const uint8_t *qInv, int qInv_len +#endif + ); +void RSA_pub_key_new(RSA_CTX **rsa_ctx, + const uint8_t *modulus, int mod_len, + const uint8_t *pub_exp, int pub_len); +void RSA_free(RSA_CTX *ctx); +int RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint8_t *out_data, + int out_len, int is_decryption); +bigint *RSA_private(const RSA_CTX *c, bigint *bi_msg); +// Don't bother to ifdef prototypes, let them be +//#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_GENERATE_X509_CERT) +bigint *RSA_sign_verify(BI_CTX *ctx, const uint8_t *sig, int sig_len, + bigint *modulus, bigint *pub_exp); +bigint *RSA_public(const RSA_CTX * c, bigint *bi_msg); +int RSA_encrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint16_t in_len, + uint8_t *out_data, int is_signing); +void RSA_print(const RSA_CTX *ctx); +//#endif + +/************************************************************************** + * RNG declarations + **************************************************************************/ +EXP_FUNC void STDCALL RNG_initialize(void); +EXP_FUNC void STDCALL RNG_custom_init(const uint8_t *seed_buf, int size); +EXP_FUNC void STDCALL RNG_terminate(void); +EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data); +int get_random_NZ(int num_rand_bytes, uint8_t *rand_data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/axtls/crypto/crypto_misc.c b/user/mpy/lib/axtls/crypto/crypto_misc.c new file mode 100644 index 0000000..2d7803f --- /dev/null +++ b/user/mpy/lib/axtls/crypto/crypto_misc.c @@ -0,0 +1,378 @@ +/* + * Copyright (c) 2007-2015, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Some misc. routines to help things out + */ + +#include +#include +#include +#include +#include "os_port.h" +#include "crypto_misc.h" +#ifdef CONFIG_WIN32_USE_CRYPTO_LIB +#include "wincrypt.h" +#endif + +#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) +static int rng_fd = -1; +#elif defined(CONFIG_WIN32_USE_CRYPTO_LIB) +static HCRYPTPROV gCryptProv; +#endif + +#if (!defined(CONFIG_USE_DEV_URANDOM) && !defined(CONFIG_WIN32_USE_CRYPTO_LIB)) +/* change to processor registers as appropriate */ +#define ENTROPY_POOL_SIZE 32 +#define ENTROPY_COUNTER1 ((((uint64_t)tv.tv_sec)<<32) | tv.tv_usec) +#define ENTROPY_COUNTER2 rand() +static uint8_t entropy_pool[ENTROPY_POOL_SIZE]; +#endif + +const char * const unsupported_str = "Error: Feature not supported\n"; + +#ifndef CONFIG_SSL_SKELETON_MODE +/** + * Retrieve a file and put it into memory + * @return The size of the file, or -1 on failure. + */ +int get_file(const char *filename, uint8_t **buf) +{ + int total_bytes = 0; + int bytes_read = 0; + int filesize; + FILE *stream = fopen(filename, "rb"); + + if (stream == NULL) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("file '%s' does not exist\n", filename); TTY_FLUSH(); +#endif + return -1; + } + + /* Win CE doesn't support stat() */ + fseek(stream, 0, SEEK_END); + filesize = ftell(stream); + *buf = (uint8_t *)malloc(filesize); + fseek(stream, 0, SEEK_SET); + + do + { + bytes_read = fread(*buf+total_bytes, 1, filesize-total_bytes, stream); + total_bytes += bytes_read; + } while (total_bytes < filesize && bytes_read > 0); + + fclose(stream); + return filesize; +} +#endif + +/** + * Initialise the Random Number Generator engine. + * - On Win32 use the platform SDK's crypto engine. + * - On Linux use /dev/urandom + * - If none of these work then use a custom RNG. + */ +EXP_FUNC void STDCALL RNG_initialize() +{ +#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) + rng_fd = open("/dev/urandom", O_RDONLY); +#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB) + if (!CryptAcquireContext(&gCryptProv, + NULL, NULL, PROV_RSA_FULL, 0)) + { + if (GetLastError() == NTE_BAD_KEYSET && + !CryptAcquireContext(&gCryptProv, + NULL, + NULL, + PROV_RSA_FULL, + CRYPT_NEWKEYSET)) + { + printf("CryptoLib: %x\n", unsupported_str, GetLastError()); + exit(1); + } + } +#elif !defined(__ets__) + /* start of with a stack to copy across */ + int i; + memcpy(entropy_pool, &i, ENTROPY_POOL_SIZE); + rand_r((unsigned int *)entropy_pool); +#endif +} + +/** + * If no /dev/urandom, then initialise the RNG with something interesting. + */ +EXP_FUNC void STDCALL RNG_custom_init(const uint8_t *seed_buf, int size) +{ +#if defined(WIN32) || defined(CONFIG_WIN32_USE_CRYPTO_LIB) + int i; + + for (i = 0; i < ENTROPY_POOL_SIZE && i < size; i++) + entropy_pool[i] ^= seed_buf[i]; +#endif +} + +/** + * Terminate the RNG engine. + */ +EXP_FUNC void STDCALL RNG_terminate(void) +{ +#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) + close(rng_fd); +#elif defined(CONFIG_WIN32_USE_CRYPTO_LIB) + CryptReleaseContext(gCryptProv, 0); +#endif +} + +/** + * Set a series of bytes with a random number. Individual bytes can be 0 + */ +EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data) +{ +#ifdef __ets__ +// see http://esp8266-re.foogod.com/wiki/Random_Number_Generator +#define WDEV_HWRNG ((volatile uint32_t*)0x3ff20e44) + while (num_rand_bytes--) { + *rand_data++ = *WDEV_HWRNG; + } +#elif !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) + /* use the Linux default - read from /dev/urandom */ + if (read(rng_fd, rand_data, num_rand_bytes) < 0) + return -1; +#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB) + /* use Microsoft Crypto Libraries */ + CryptGenRandom(gCryptProv, num_rand_bytes, rand_data); +#else /* nothing else to use, so use a custom RNG */ + /* The method we use when we've got nothing better. Use RC4, time + and a couple of random seeds to generate a random sequence */ + AES_CTX rng_ctx; + struct timeval tv; + MD5_CTX rng_digest_ctx; + uint8_t digest[MD5_SIZE]; + uint64_t *ep; + int i; + + /* A proper implementation would use counters etc for entropy */ + gettimeofday(&tv, NULL); + ep = (uint64_t *)entropy_pool; + ep[0] ^= ENTROPY_COUNTER1; + ep[1] ^= ENTROPY_COUNTER2; + + /* use a digested version of the entropy pool as a key */ + MD5_Init(&rng_digest_ctx); + MD5_Update(&rng_digest_ctx, entropy_pool, ENTROPY_POOL_SIZE); + MD5_Final(digest, &rng_digest_ctx); + + /* come up with the random sequence */ + AES_set_key(&rng_ctx, digest, (const uint8_t *)ep, AES_MODE_128); /* use as a key */ + memcpy(rand_data, entropy_pool, num_rand_bytes < ENTROPY_POOL_SIZE ? + num_rand_bytes : ENTROPY_POOL_SIZE); + AES_cbc_encrypt(&rng_ctx, rand_data, rand_data, num_rand_bytes); + + /* move things along */ + for (i = ENTROPY_POOL_SIZE-1; i >= MD5_SIZE ; i--) + entropy_pool[i] = entropy_pool[i-MD5_SIZE]; + + /* insert the digest at the start of the entropy pool */ + memcpy(entropy_pool, digest, MD5_SIZE); +#endif + return 0; +} + +/** + * Set a series of bytes with a random number. Individual bytes are not zero. + */ +int get_random_NZ(int num_rand_bytes, uint8_t *rand_data) +{ + int i; + if (get_random(num_rand_bytes, rand_data)) + return -1; + + for (i = 0; i < num_rand_bytes; i++) + { + while (rand_data[i] == 0) /* can't be 0 */ + rand_data[i] = (uint8_t)(rand()); + } + + return 0; +} + +/** + * Some useful diagnostic routines + */ +#if defined(CONFIG_SSL_DIAGNOSTICS) || defined(CONFIG_DEBUG) +int hex_finish; +int hex_index; + +static void print_hex_init(int finish) +{ + hex_finish = finish; + hex_index = 0; +} + +static void print_hex(uint8_t hex) +{ + static int column; + + if (hex_index == 0) + { + column = 0; + } + + printf("%02x ", hex); + if (++column == 8) + { + printf(": "); + } + else if (column >= 16) + { + printf("\n"); + column = 0; + } + + if (++hex_index >= hex_finish && column > 0) + { + printf("\n"); + } +} + +/** + * Spit out a blob of data for diagnostics. The data is is a nice column format + * for easy reading. + * + * @param format [in] The string (with possible embedded format characters) + * @param size [in] The number of numbers to print + * @param data [in] The start of data to use + * @param ... [in] Any additional arguments + */ +EXP_FUNC void STDCALL print_blob(const char *format, + const uint8_t *data, int size, ...) +{ + int i; + char tmp[80]; + va_list(ap); + + va_start(ap, size); + snprintf(tmp, sizeof(tmp), "%s\n", format); + vprintf(tmp, ap); + print_hex_init(size); + for (i = 0; i < size; i++) + { + print_hex(data[i]); + } + + va_end(ap); + TTY_FLUSH(); +} +#elif defined(WIN32) +/* VC6.0 doesn't handle variadic macros */ +EXP_FUNC void STDCALL print_blob(const char *format, const unsigned char *data, + int size, ...) {} +#endif + +#if defined(CONFIG_SSL_HAS_PEM) || defined(CONFIG_HTTP_HAS_AUTHORIZATION) +/* base64 to binary lookup table */ +static const uint8_t map[128] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, + 255, 254, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 255, 255, 255, 255, 255 +}; + +EXP_FUNC int STDCALL base64_decode(const char *in, int len, + uint8_t *out, int *outlen) +{ + int g, t, x, y, z; + uint8_t c; + int ret = -1; + + g = 3; + for (x = y = z = t = 0; x < len; x++) + { + if ((c = map[in[x]&0x7F]) == 0xff) + continue; + + if (c == 254) /* this is the end... */ + { + c = 0; + + if (--g < 0) + goto error; + } + else if (g != 3) /* only allow = at end */ + goto error; + + t = (t<<6) | c; + + if (++y == 4) + { + out[z++] = (uint8_t)((t>>16)&255); + + if (g > 1) + out[z++] = (uint8_t)((t>>8)&255); + + if (g > 2) + out[z++] = (uint8_t)(t&255); + + y = t = 0; + } + + /* check that we don't go past the output buffer */ + if (z > *outlen) + goto error; + } + + if (y != 0) + goto error; + + *outlen = z; + ret = 0; + +error: +#ifdef CONFIG_SSL_FULL_MODE + if (ret < 0) + printf("Error: Invalid base64\n"); TTY_FLUSH(); +#endif + TTY_FLUSH(); + return ret; + +} +#endif + diff --git a/user/mpy/lib/axtls/crypto/hmac.c b/user/mpy/lib/axtls/crypto/hmac.c new file mode 100644 index 0000000..ac5bb18 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/hmac.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * HMAC implementation - This code was originally taken from RFC2104 + * See http://www.ietf.org/rfc/rfc2104.txt and + * http://www.faqs.org/rfcs/rfc2202.html + */ + +#include +#include "os_port.h" +#include "crypto.h" + +/** + * Perform HMAC-MD5 + * NOTE: does not handle keys larger than the block size. + */ +void ssl_hmac_md5(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest) +{ + MD5_CTX context; + uint8_t k_pad[64]; + int i; + + memset(k_pad, 0, sizeof k_pad); + memcpy(k_pad, key, key_len); + for (i = 0; i < 64; i++) + { + k_pad[i] ^= 0x36; + } + + MD5_Init(&context); + MD5_Update(&context, k_pad, 64); + MD5_Update(&context, msg, length); + MD5_Final(digest, &context); + + memset(k_pad, 0, sizeof k_pad); + memcpy(k_pad, key, key_len); + for (i = 0; i < 64; i++) + { + k_pad[i] ^= 0x5c; + } + + MD5_Init(&context); + MD5_Update(&context, k_pad, 64); + MD5_Update(&context, digest, MD5_SIZE); + MD5_Final(digest, &context); +} + +/** + * Perform HMAC-SHA1 + * NOTE: does not handle keys larger than the block size. + */ +void ssl_hmac_sha1(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest) +{ + SHA1_CTX context; + uint8_t k_pad[64]; + int i; + + memset(k_pad, 0, sizeof k_pad); + memcpy(k_pad, key, key_len); + for (i = 0; i < 64; i++) + { + k_pad[i] ^= 0x36; + } + + SHA1_Init(&context); + SHA1_Update(&context, k_pad, 64); + SHA1_Update(&context, msg, length); + SHA1_Final(digest, &context); + + memset(k_pad, 0, sizeof k_pad); + memcpy(k_pad, key, key_len); + for (i = 0; i < 64; i++) + { + k_pad[i] ^= 0x5c; + } + + SHA1_Init(&context); + SHA1_Update(&context, k_pad, 64); + SHA1_Update(&context, digest, SHA1_SIZE); + SHA1_Final(digest, &context); +} + +/** + * Perform HMAC-SHA256 + * NOTE: does not handle keys larger than the block size. + */ +void hmac_sha256(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest) +{ + SHA256_CTX context; + uint8_t k_ipad[64]; + uint8_t k_opad[64]; + int i; + + memset(k_ipad, 0, sizeof k_ipad); + memset(k_opad, 0, sizeof k_opad); + memcpy(k_ipad, key, key_len); + memcpy(k_opad, key, key_len); + + for (i = 0; i < 64; i++) + { + k_ipad[i] ^= 0x36; + k_opad[i] ^= 0x5c; + } + + SHA256_Init(&context); + SHA256_Update(&context, k_ipad, 64); + SHA256_Update(&context, msg, length); + SHA256_Final(digest, &context); + SHA256_Init(&context); + SHA256_Update(&context, k_opad, 64); + SHA256_Update(&context, digest, SHA256_SIZE); + SHA256_Final(digest, &context); +} + diff --git a/user/mpy/lib/axtls/crypto/md5.c b/user/mpy/lib/axtls/crypto/md5.c new file mode 100644 index 0000000..86534c8 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/md5.c @@ -0,0 +1,433 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * This file implements the MD5 algorithm as defined in RFC1321 + */ + +#include +#include "os_port.h" +#include "crypto.h" + +/* Constants for MD5Transform routine. + */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +/* ----- static functions ----- */ +static void MD5Transform(uint32_t state[4], const uint8_t block[64]); +static void Encode(uint8_t *output, uint32_t *input, uint32_t len); +static void Decode(uint32_t *output, const uint8_t *input, uint32_t len); + +static const uint8_t PADDING[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G, H and I are basic MD5 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* Versions for size-optimized code. */ +#define IDX(v) ((v) & 3) +#define F_(a, i) ((a[IDX(i + 1)] & a[IDX(i + 2)]) | (~a[IDX(i + 1)] & a[IDX(i + 3)])) +#define G_(a, i) ((a[IDX(i + 1)] & a[IDX(i + 3)]) | (a[IDX(i + 2)] & ~a[IDX(i + 3)])) +#define H_(a, i) (a[IDX(i + 1)] ^ a[IDX(i + 2)] ^ a[IDX(i + 3)]) +#define I_(a, i) (a[IDX(i + 2)] ^ (a[IDX(i + 1)] | ~a[IDX(i + 3)])) + +/* ROTATE_LEFT rotates x left n bits. */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + Rotation is separate from addition to prevent recomputation. */ +#define FF(a, b, c, d, x, s, ac) { \ + (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) { \ + (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) { \ + (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) { \ + (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +/** + * MD5 initialization - begins an MD5 operation, writing a new ctx. + */ +EXP_FUNC void STDCALL MD5_Init(MD5_CTX *ctx) +{ + ctx->count[0] = ctx->count[1] = 0; + + /* Load magic initialization constants. + */ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->state[3] = 0x10325476; +} + +/** + * Accepts an array of octets as the next portion of the message. + */ +EXP_FUNC void STDCALL MD5_Update(MD5_CTX *ctx, const uint8_t * msg, int len) +{ + uint32_t x; + int i, partLen; + + /* Compute number of bytes mod 64 */ + x = (uint32_t)((ctx->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if ((ctx->count[0] += ((uint32_t)len << 3)) < ((uint32_t)len << 3)) + ctx->count[1]++; + ctx->count[1] += ((uint32_t)len >> 29); + + partLen = 64 - x; + + /* Transform as many times as possible. */ + if (len >= partLen) + { + memcpy(&ctx->buffer[x], msg, partLen); + MD5Transform(ctx->state, ctx->buffer); + + for (i = partLen; i + 63 < len; i += 64) + MD5Transform(ctx->state, &msg[i]); + + x = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy(&ctx->buffer[x], &msg[i], len-i); +} + +/** + * Return the 128-bit message digest into the user's array + */ +EXP_FUNC void STDCALL MD5_Final(uint8_t *digest, MD5_CTX *ctx) +{ + uint8_t bits[8]; + uint32_t x, padLen; + + /* Save number of bits */ + Encode(bits, ctx->count, 8); + + /* Pad out to 56 mod 64. + */ + x = (uint32_t)((ctx->count[0] >> 3) & 0x3f); + padLen = (x < 56) ? (56 - x) : (120 - x); + MD5_Update(ctx, PADDING, padLen); + + /* Append length (before padding) */ + MD5_Update(ctx, bits, 8); + + /* Store state in digest */ + Encode(digest, ctx->state, MD5_SIZE); +} + +/** + * MD5 basic transformation. Transforms state based on block. + */ +#if OPTIMIZE_FOR_SPEED + +static void MD5Transform(uint32_t state[4], const uint8_t block[64]) +{ + uint32_t a = state[0], b = state[1], c = state[2], + d = state[3], x[MD5_SIZE]; + + Decode(x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; +} + +#else + +static void MD5Transform(uint32_t state[4], const uint8_t block[64]) +{ + uint32_t arr[4], x[MD5_SIZE]; + memcpy(arr, state, sizeof(arr)); + + Decode(x, block, 64); + + static const uint32_t round_ac[] = { + 0xd76aa478, /* 1 */ + 0xe8c7b756, /* 2 */ + 0x242070db, /* 3 */ + 0xc1bdceee, /* 4 */ + 0xf57c0faf, /* 5 */ + 0x4787c62a, /* 6 */ + 0xa8304613, /* 7 */ + 0xfd469501, /* 8 */ + 0x698098d8, /* 9 */ + 0x8b44f7af, /* 10 */ + 0xffff5bb1, /* 11 */ + 0x895cd7be, /* 12 */ + 0x6b901122, /* 13 */ + 0xfd987193, /* 14 */ + 0xa679438e, /* 15 */ + 0x49b40821, /* 16 */ + 0xf61e2562, /* 17 */ + 0xc040b340, /* 18 */ + 0x265e5a51, /* 19 */ + 0xe9b6c7aa, /* 20 */ + 0xd62f105d, /* 21 */ + 0x2441453, /* 22 */ + 0xd8a1e681, /* 23 */ + 0xe7d3fbc8, /* 24 */ + 0x21e1cde6, /* 25 */ + 0xc33707d6, /* 26 */ + 0xf4d50d87, /* 27 */ + 0x455a14ed, /* 28 */ + 0xa9e3e905, /* 29 */ + 0xfcefa3f8, /* 30 */ + 0x676f02d9, /* 31 */ + 0x8d2a4c8a, /* 32 */ + 0xfffa3942, /* 33 */ + 0x8771f681, /* 34 */ + 0x6d9d6122, /* 35 */ + 0xfde5380c, /* 36 */ + 0xa4beea44, /* 37 */ + 0x4bdecfa9, /* 38 */ + 0xf6bb4b60, /* 39 */ + 0xbebfbc70, /* 40 */ + 0x289b7ec6, /* 41 */ + 0xeaa127fa, /* 42 */ + 0xd4ef3085, /* 43 */ + 0x4881d05, /* 44 */ + 0xd9d4d039, /* 45 */ + 0xe6db99e5, /* 46 */ + 0x1fa27cf8, /* 47 */ + 0xc4ac5665, /* 48 */ + 0xf4292244, /* 49 */ + 0x432aff97, /* 50 */ + 0xab9423a7, /* 51 */ + 0xfc93a039, /* 52 */ + 0x655b59c3, /* 53 */ + 0x8f0ccc92, /* 54 */ + 0xffeff47d, /* 55 */ + 0x85845dd1, /* 56 */ + 0x6fa87e4f, /* 57 */ + 0xfe2ce6e0, /* 58 */ + 0xa3014314, /* 59 */ + 0x4e0811a1, /* 60 */ + 0xf7537e82, /* 61 */ + 0xbd3af235, /* 62 */ + 0x2ad7d2bb, /* 63 */ + 0xeb86d391, /* 64 */ + }; + + static const uint8_t round1_s[] = { + 7, 12, 17, 22, + 5, 9, 14, 20, + 4, 11, 16, 23, + 6, 10, 15, 21, + }; + + static const uint8_t round_order[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, + 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, + 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9, + }; + + unsigned i; + + const uint8_t *round_s = round1_s - 4; + for (i = 0; i < 64; i++) { + int off = IDX(4 - i); + uint32_t v; + + // Code size is bigger + //round_s = round1_s + (i >> 4) * 4; + if ((i & 15) == 0) { + round_s += 4; + } + + if (i < 32) { + if (i < 16) { + v = F_(arr, off); + } else { + v = G_(arr, off); + } + } else { + if (i < 48) { + v = H_(arr, off); + } else { + v = I_(arr, off); + } + } + v += arr[off]; + v += x[round_order[i]] + round_ac[i]; + v = ROTATE_LEFT(v, round_s[i & 3]); + v += arr[IDX(off + 1)]; + arr[off] = v; + } + + state[0] += arr[0]; + state[1] += arr[1]; + state[2] += arr[2]; + state[3] += arr[3]; +} +#endif // OPTIMIZE_FOR_SPEED + +/** + * Encodes input (uint32_t) into output (uint8_t). Assumes len is + * a multiple of 4. + */ +static void Encode(uint8_t *output, uint32_t *input, uint32_t len) +{ + uint32_t i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + { + output[j] = (uint8_t)(input[i] & 0xff); + output[j+1] = (uint8_t)((input[i] >> 8) & 0xff); + output[j+2] = (uint8_t)((input[i] >> 16) & 0xff); + output[j+3] = (uint8_t)((input[i] >> 24) & 0xff); + } +} + +/** + * Decodes input (uint8_t) into output (uint32_t). Assumes len is + * a multiple of 4. + */ +static void Decode(uint32_t *output, const uint8_t *input, uint32_t len) +{ + uint32_t i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | + (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); +} diff --git a/user/mpy/lib/axtls/crypto/os_int.h b/user/mpy/lib/axtls/crypto/os_int.h new file mode 100644 index 0000000..a849e5b --- /dev/null +++ b/user/mpy/lib/axtls/crypto/os_int.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file os_int.h + * + * Ensure a consistent bit size + */ + +#ifndef HEADER_OS_INT_H +#define HEADER_OS_INT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(WIN32) +typedef UINT8 uint8_t; +typedef INT8 int8_t; +typedef UINT16 uint16_t; +typedef INT16 int16_t; +typedef UINT32 uint32_t; +typedef INT32 int32_t; +typedef UINT64 uint64_t; +typedef INT64 int64_t; +#else /* Not Win32 */ + +#ifdef CONFIG_PLATFORM_SOLARIS +#include +#else +#include +#endif /* Not Solaris */ + +#endif /* Not Win32 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/axtls/crypto/rc4.c b/user/mpy/lib/axtls/crypto/rc4.c new file mode 100644 index 0000000..edfb27a --- /dev/null +++ b/user/mpy/lib/axtls/crypto/rc4.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * An implementation of the RC4/ARC4 algorithm. + * Originally written by Christophe Devine. + */ + +#include +#include "os_port.h" +#include "crypto.h" + +/* only used for PKCS12 now */ +#ifdef CONFIG_SSL_USE_PKCS12 + +/** + * Get ready for an encrypt/decrypt operation + */ +void RC4_setup(RC4_CTX *ctx, const uint8_t *key, int length) +{ + int i, j = 0, k = 0, a; + uint8_t *m; + + ctx->x = 0; + ctx->y = 0; + m = ctx->m; + + for (i = 0; i < 256; i++) + m[i] = i; + + for (i = 0; i < 256; i++) + { + a = m[i]; + j = (uint8_t)(j + a + key[k]); + m[i] = m[j]; + m[j] = a; + + if (++k >= length) + k = 0; + } +} + +/** + * Perform the encrypt/decrypt operation (can use it for either since + * this is a stream cipher). + * NOTE: *msg and *out must be the same pointer (performance tweak) + */ +void RC4_crypt(RC4_CTX *ctx, const uint8_t *msg, uint8_t *out, int length) +{ + int i; + uint8_t *m, x, y, a, b; + + x = ctx->x; + y = ctx->y; + m = ctx->m; + + for (i = 0; i < length; i++) + { + a = m[++x]; + y += a; + m[x] = b = m[y]; + m[y] = a; + out[i] ^= m[(uint8_t)(a + b)]; + } + + ctx->x = x; + ctx->y = y; +} + +#endif diff --git a/user/mpy/lib/axtls/crypto/rsa.c b/user/mpy/lib/axtls/crypto/rsa.c new file mode 100644 index 0000000..742cd71 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/rsa.c @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2007-2014, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Implements the RSA public encryption algorithm. Uses the bigint library to + * perform its calculations. + */ + +#include +#include +#include +#include +#include "os_port.h" +#include "crypto.h" + +void RSA_priv_key_new(RSA_CTX **ctx, + const uint8_t *modulus, int mod_len, + const uint8_t *pub_exp, int pub_len, + const uint8_t *priv_exp, int priv_len +#if CONFIG_BIGINT_CRT + , const uint8_t *p, int p_len, + const uint8_t *q, int q_len, + const uint8_t *dP, int dP_len, + const uint8_t *dQ, int dQ_len, + const uint8_t *qInv, int qInv_len +#endif + ) +{ + RSA_CTX *rsa_ctx; + BI_CTX *bi_ctx; + RSA_pub_key_new(ctx, modulus, mod_len, pub_exp, pub_len); + rsa_ctx = *ctx; + bi_ctx = rsa_ctx->bi_ctx; + rsa_ctx->d = bi_import(bi_ctx, priv_exp, priv_len); + bi_permanent(rsa_ctx->d); + +#ifdef CONFIG_BIGINT_CRT + rsa_ctx->p = bi_import(bi_ctx, p, p_len); + rsa_ctx->q = bi_import(bi_ctx, q, q_len); + rsa_ctx->dP = bi_import(bi_ctx, dP, dP_len); + rsa_ctx->dQ = bi_import(bi_ctx, dQ, dQ_len); + rsa_ctx->qInv = bi_import(bi_ctx, qInv, qInv_len); + bi_permanent(rsa_ctx->dP); + bi_permanent(rsa_ctx->dQ); + bi_permanent(rsa_ctx->qInv); + bi_set_mod(bi_ctx, rsa_ctx->p, BIGINT_P_OFFSET); + bi_set_mod(bi_ctx, rsa_ctx->q, BIGINT_Q_OFFSET); +#endif +} + +void RSA_pub_key_new(RSA_CTX **ctx, + const uint8_t *modulus, int mod_len, + const uint8_t *pub_exp, int pub_len) +{ + RSA_CTX *rsa_ctx; + BI_CTX *bi_ctx; + + if (*ctx) /* if we load multiple certs, dump the old one */ + RSA_free(*ctx); + + bi_ctx = bi_initialize(); + *ctx = (RSA_CTX *)calloc(1, sizeof(RSA_CTX)); + rsa_ctx = *ctx; + rsa_ctx->bi_ctx = bi_ctx; + rsa_ctx->num_octets = mod_len; + rsa_ctx->m = bi_import(bi_ctx, modulus, mod_len); + bi_set_mod(bi_ctx, rsa_ctx->m, BIGINT_M_OFFSET); + rsa_ctx->e = bi_import(bi_ctx, pub_exp, pub_len); + bi_permanent(rsa_ctx->e); +} + +/** + * Free up any RSA context resources. + */ +void RSA_free(RSA_CTX *rsa_ctx) +{ + BI_CTX *bi_ctx; + if (rsa_ctx == NULL) /* deal with ptrs that are null */ + return; + + bi_ctx = rsa_ctx->bi_ctx; + + bi_depermanent(rsa_ctx->e); + bi_free(bi_ctx, rsa_ctx->e); + bi_free_mod(rsa_ctx->bi_ctx, BIGINT_M_OFFSET); + + if (rsa_ctx->d) + { + bi_depermanent(rsa_ctx->d); + bi_free(bi_ctx, rsa_ctx->d); +#ifdef CONFIG_BIGINT_CRT + bi_depermanent(rsa_ctx->dP); + bi_depermanent(rsa_ctx->dQ); + bi_depermanent(rsa_ctx->qInv); + bi_free(bi_ctx, rsa_ctx->dP); + bi_free(bi_ctx, rsa_ctx->dQ); + bi_free(bi_ctx, rsa_ctx->qInv); + bi_free_mod(rsa_ctx->bi_ctx, BIGINT_P_OFFSET); + bi_free_mod(rsa_ctx->bi_ctx, BIGINT_Q_OFFSET); +#endif + } + + bi_terminate(bi_ctx); + free(rsa_ctx); +} + +/** + * @brief Use PKCS1.5 for decryption/verification. + * @param ctx [in] The context + * @param in_data [in] The data to decrypt (must be < modulus size-11) + * @param out_data [out] The decrypted data. + * @param out_len [int] The size of the decrypted buffer in bytes + * @param is_decryption [in] Decryption or verify operation. + * @return The number of bytes that were originally encrypted. -1 on error. + * @see http://www.rsasecurity.com/rsalabs/node.asp?id=2125 + */ +int RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data, + uint8_t *out_data, int out_len, int is_decryption) +{ + const int byte_size = ctx->num_octets; + int i = 0, size; + bigint *decrypted_bi, *dat_bi; + uint8_t *block = (uint8_t *)alloca(byte_size); + int pad_count = 0; + + if (out_len < byte_size) /* check output has enough size */ + return -1; + + memset(out_data, 0, out_len); /* initialise */ + + /* decrypt */ + dat_bi = bi_import(ctx->bi_ctx, in_data, byte_size); +#ifdef CONFIG_SSL_CERT_VERIFICATION + decrypted_bi = is_decryption ? /* decrypt or verify? */ + RSA_private(ctx, dat_bi) : RSA_public(ctx, dat_bi); +#else /* always a decryption */ + decrypted_bi = RSA_private(ctx, dat_bi); +#endif + + /* convert to a normal block */ + bi_export(ctx->bi_ctx, decrypted_bi, block, byte_size); + + if (block[i++] != 0) /* leading 0? */ + return -1; + +#ifdef CONFIG_SSL_CERT_VERIFICATION + if (is_decryption == 0) /* PKCS1.5 signing pads with "0xff"s */ + { + if (block[i++] != 0x01) /* BT correct? */ + return -1; + + while (block[i++] == 0xff && i < byte_size) + pad_count++; + } + else /* PKCS1.5 encryption padding is random */ +#endif + { + if (block[i++] != 0x02) /* BT correct? */ + return -1; + + while (block[i++] && i < byte_size) + pad_count++; + } + + /* check separator byte 0x00 - and padding must be 8 or more bytes */ + if (i == byte_size || pad_count < 8) + return -1; + + size = byte_size - i; + + /* get only the bit we want */ + memcpy(out_data, &block[i], size); + return size; +} + +/** + * Performs m = c^d mod n + */ +bigint *RSA_private(const RSA_CTX *c, bigint *bi_msg) +{ +#ifdef CONFIG_BIGINT_CRT + return bi_crt(c->bi_ctx, bi_msg, c->dP, c->dQ, c->p, c->q, c->qInv); +#else + BI_CTX *ctx = c->bi_ctx; + ctx->mod_offset = BIGINT_M_OFFSET; + return bi_mod_power(ctx, bi_msg, c->d); +#endif +} + +#ifdef CONFIG_SSL_FULL_MODE +/** + * Used for diagnostics. + */ +void RSA_print(const RSA_CTX *rsa_ctx) +{ + if (rsa_ctx == NULL) + return; + + printf("----------------- RSA DEBUG ----------------\n"); + printf("Size:\t%d\n", rsa_ctx->num_octets); + bi_print("Modulus", rsa_ctx->m); + bi_print("Public Key", rsa_ctx->e); + bi_print("Private Key", rsa_ctx->d); +} +#endif + +#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_GENERATE_X509_CERT) || (CONFIG_SSL_ENABLE_CLIENT) +/** + * Performs c = m^e mod n + */ +bigint *RSA_public(const RSA_CTX * c, bigint *bi_msg) +{ + c->bi_ctx->mod_offset = BIGINT_M_OFFSET; + return bi_mod_power(c->bi_ctx, bi_msg, c->e); +} + +/** + * Use PKCS1.5 for encryption/signing. + * see http://www.rsasecurity.com/rsalabs/node.asp?id=2125 + */ +int RSA_encrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint16_t in_len, + uint8_t *out_data, int is_signing) +{ + int byte_size = ctx->num_octets; + int num_pads_needed = byte_size-in_len-3; + bigint *dat_bi, *encrypt_bi; + + /* note: in_len+11 must be > byte_size */ + out_data[0] = 0; /* ensure encryption block is < modulus */ + + if (is_signing) + { + out_data[1] = 1; /* PKCS1.5 signing pads with "0xff"'s */ + memset(&out_data[2], 0xff, num_pads_needed); + } + else /* randomize the encryption padding with non-zero bytes */ + { + out_data[1] = 2; + if (get_random_NZ(num_pads_needed, &out_data[2]) < 0) + return -1; + } + + out_data[2+num_pads_needed] = 0; + memcpy(&out_data[3+num_pads_needed], in_data, in_len); + + /* now encrypt it */ + dat_bi = bi_import(ctx->bi_ctx, out_data, byte_size); + encrypt_bi = is_signing ? RSA_private(ctx, dat_bi) : + RSA_public(ctx, dat_bi); + bi_export(ctx->bi_ctx, encrypt_bi, out_data, byte_size); + + /* save a few bytes of memory */ + bi_clear_cache(ctx->bi_ctx); + return byte_size; +} + +#endif /* CONFIG_SSL_CERT_VERIFICATION */ diff --git a/user/mpy/lib/axtls/crypto/sha1.c b/user/mpy/lib/axtls/crypto/sha1.c new file mode 100644 index 0000000..1082733 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/sha1.c @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * SHA1 implementation - as defined in FIPS PUB 180-1 published April 17, 1995. + * This code was originally taken from RFC3174 + */ + +#include +#include "os_port.h" +#include "crypto.h" + +/* + * Define the SHA1 circular left shift macro + */ +#define SHA1CircularShift(bits,word) \ + (((word) << (bits)) | ((word) >> (32-(bits)))) + +/* ----- static functions ----- */ +static void SHA1PadMessage(SHA1_CTX *ctx); +static void SHA1ProcessMessageBlock(SHA1_CTX *ctx); + +/** + * Initialize the SHA1 context + */ +void SHA1_Init(SHA1_CTX *ctx) +{ + ctx->Length_Low = 0; + ctx->Length_High = 0; + ctx->Message_Block_Index = 0; + ctx->Intermediate_Hash[0] = 0x67452301; + ctx->Intermediate_Hash[1] = 0xEFCDAB89; + ctx->Intermediate_Hash[2] = 0x98BADCFE; + ctx->Intermediate_Hash[3] = 0x10325476; + ctx->Intermediate_Hash[4] = 0xC3D2E1F0; +} + +/** + * Accepts an array of octets as the next portion of the message. + */ +void SHA1_Update(SHA1_CTX *ctx, const uint8_t *msg, int len) +{ + while (len--) + { + ctx->Message_Block[ctx->Message_Block_Index++] = (*msg & 0xFF); + ctx->Length_Low += 8; + + if (ctx->Length_Low == 0) + ctx->Length_High++; + + if (ctx->Message_Block_Index == 64) + SHA1ProcessMessageBlock(ctx); + + msg++; + } +} + +/** + * Return the 160-bit message digest into the user's array + */ +void SHA1_Final(uint8_t *digest, SHA1_CTX *ctx) +{ + int i; + + SHA1PadMessage(ctx); + memset(ctx->Message_Block, 0, 64); + ctx->Length_Low = 0; /* and clear length */ + ctx->Length_High = 0; + + for (i = 0; i < SHA1_SIZE; i++) + { + digest[i] = ctx->Intermediate_Hash[i>>2] >> 8 * ( 3 - ( i & 0x03 ) ); + } +} + +/** + * Process the next 512 bits of the message stored in the array. + */ +static void SHA1ProcessMessageBlock(SHA1_CTX *ctx) +{ + const uint32_t K[] = { /* Constants defined in SHA-1 */ + 0x5A827999, + 0x6ED9EBA1, + 0x8F1BBCDC, + 0xCA62C1D6 + }; + int t; /* Loop counter */ + uint32_t temp; /* Temporary word value */ + uint32_t W[80]; /* Word sequence */ + uint32_t A, B, C, D, E; /* Word buffers */ + + /* + * Initialize the first 16 words in the array W + */ + for (t = 0; t < 16; t++) + { + W[t] = ctx->Message_Block[t * 4] << 24; + W[t] |= ctx->Message_Block[t * 4 + 1] << 16; + W[t] |= ctx->Message_Block[t * 4 + 2] << 8; + W[t] |= ctx->Message_Block[t * 4 + 3]; + } + + for (t = 16; t < 80; t++) + { + W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); + } + + A = ctx->Intermediate_Hash[0]; + B = ctx->Intermediate_Hash[1]; + C = ctx->Intermediate_Hash[2]; + D = ctx->Intermediate_Hash[3]; + E = ctx->Intermediate_Hash[4]; + + for (t = 0; t < 20; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + + B = A; + A = temp; + } + + for (t = 20; t < 40; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for (t = 40; t < 60; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for (t = 60; t < 80; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + ctx->Intermediate_Hash[0] += A; + ctx->Intermediate_Hash[1] += B; + ctx->Intermediate_Hash[2] += C; + ctx->Intermediate_Hash[3] += D; + ctx->Intermediate_Hash[4] += E; + ctx->Message_Block_Index = 0; +} + +/* + * According to the standard, the message must be padded to an even + * 512 bits. The first padding bit must be a '1'. The last 64 + * bits represent the length of the original message. All bits in + * between should be 0. This function will pad the message + * according to those rules by filling the Message_Block array + * accordingly. It will also call the ProcessMessageBlock function + * provided appropriately. When it returns, it can be assumed that + * the message digest has been computed. + * + * @param ctx [in, out] The SHA1 context + */ +static void SHA1PadMessage(SHA1_CTX *ctx) +{ + /* + * Check to see if the current message block is too small to hold + * the initial padding bits and length. If so, we will pad the + * block, process it, and then continue padding into a second + * block. + */ + if (ctx->Message_Block_Index > 55) + { + ctx->Message_Block[ctx->Message_Block_Index++] = 0x80; + while(ctx->Message_Block_Index < 64) + { + ctx->Message_Block[ctx->Message_Block_Index++] = 0; + } + + SHA1ProcessMessageBlock(ctx); + + while (ctx->Message_Block_Index < 56) + { + ctx->Message_Block[ctx->Message_Block_Index++] = 0; + } + } + else + { + ctx->Message_Block[ctx->Message_Block_Index++] = 0x80; + while(ctx->Message_Block_Index < 56) + { + + ctx->Message_Block[ctx->Message_Block_Index++] = 0; + } + } + + /* + * Store the message length as the last 8 octets + */ + ctx->Message_Block[56] = ctx->Length_High >> 24; + ctx->Message_Block[57] = ctx->Length_High >> 16; + ctx->Message_Block[58] = ctx->Length_High >> 8; + ctx->Message_Block[59] = ctx->Length_High; + ctx->Message_Block[60] = ctx->Length_Low >> 24; + ctx->Message_Block[61] = ctx->Length_Low >> 16; + ctx->Message_Block[62] = ctx->Length_Low >> 8; + ctx->Message_Block[63] = ctx->Length_Low; + SHA1ProcessMessageBlock(ctx); +} diff --git a/user/mpy/lib/axtls/crypto/sha256.c b/user/mpy/lib/axtls/crypto/sha256.c new file mode 100644 index 0000000..e15e315 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/sha256.c @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2015, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "os_port.h" +#include "crypto.h" + +#ifndef SHA256_CTX + +#define GET_UINT32(n,b,i) \ +{ \ + (n) = ((uint32_t) (b)[(i) ] << 24) \ + | ((uint32_t) (b)[(i) + 1] << 16) \ + | ((uint32_t) (b)[(i) + 2] << 8) \ + | ((uint32_t) (b)[(i) + 3] ); \ +} + +#define PUT_UINT32(n,b,i) \ +{ \ + (b)[(i) ] = (uint8_t) ((n) >> 24); \ + (b)[(i) + 1] = (uint8_t) ((n) >> 16); \ + (b)[(i) + 2] = (uint8_t) ((n) >> 8); \ + (b)[(i) + 3] = (uint8_t) ((n) ); \ +} + +static const uint8_t sha256_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/** + * Initialize the SHA256 context + */ +void SHA256_Init(SHA256_CTX *ctx) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x6A09E667; + ctx->state[1] = 0xBB67AE85; + ctx->state[2] = 0x3C6EF372; + ctx->state[3] = 0xA54FF53A; + ctx->state[4] = 0x510E527F; + ctx->state[5] = 0x9B05688C; + ctx->state[6] = 0x1F83D9AB; + ctx->state[7] = 0x5BE0CD19; +} + +static void SHA256_Process(const uint8_t digest[64], SHA256_CTX *ctx) +{ + uint32_t temp1, temp2, W[64]; + uint32_t A, B, C, D, E, F, G, H; + + GET_UINT32(W[0], digest, 0); + GET_UINT32(W[1], digest, 4); + GET_UINT32(W[2], digest, 8); + GET_UINT32(W[3], digest, 12); + GET_UINT32(W[4], digest, 16); + GET_UINT32(W[5], digest, 20); + GET_UINT32(W[6], digest, 24); + GET_UINT32(W[7], digest, 28); + GET_UINT32(W[8], digest, 32); + GET_UINT32(W[9], digest, 36); + GET_UINT32(W[10], digest, 40); + GET_UINT32(W[11], digest, 44); + GET_UINT32(W[12], digest, 48); + GET_UINT32(W[13], digest, 52); + GET_UINT32(W[14], digest, 56); + GET_UINT32(W[15], digest, 60); + +#define SHR(x,n) ((x & 0xFFFFFFFF) >> n) +#define ROTR(x,n) (SHR(x,n) | (x << (32 - n))) + +#define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3)) +#define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10)) + +#define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22)) +#define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25)) + +#define F0(x,y,z) ((x & y) | (z & (x | y))) +#define F1(x,y,z) (z ^ (x & (y ^ z))) + +#define R(t) \ +( \ + W[t] = S1(W[t - 2]) + W[t - 7] + \ + S0(W[t - 15]) + W[t - 16] \ +) + +#define P(a,b,c,d,e,f,g,h,x,K) \ +{ \ + temp1 = h + S3(e) + F1(e,f,g) + K + x; \ + temp2 = S2(a) + F0(a,b,c); \ + d += temp1; h = temp1 + temp2; \ +} + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + F = ctx->state[5]; + G = ctx->state[6]; + H = ctx->state[7]; + + P(A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98); + P(H, A, B, C, D, E, F, G, W[ 1], 0x71374491); + P(G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF); + P(F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5); + P(E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B); + P(D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1); + P(C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4); + P(B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5); + P(A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98); + P(H, A, B, C, D, E, F, G, W[ 9], 0x12835B01); + P(G, H, A, B, C, D, E, F, W[10], 0x243185BE); + P(F, G, H, A, B, C, D, E, W[11], 0x550C7DC3); + P(E, F, G, H, A, B, C, D, W[12], 0x72BE5D74); + P(D, E, F, G, H, A, B, C, W[13], 0x80DEB1FE); + P(C, D, E, F, G, H, A, B, W[14], 0x9BDC06A7); + P(B, C, D, E, F, G, H, A, W[15], 0xC19BF174); + P(A, B, C, D, E, F, G, H, R(16), 0xE49B69C1); + P(H, A, B, C, D, E, F, G, R(17), 0xEFBE4786); + P(G, H, A, B, C, D, E, F, R(18), 0x0FC19DC6); + P(F, G, H, A, B, C, D, E, R(19), 0x240CA1CC); + P(E, F, G, H, A, B, C, D, R(20), 0x2DE92C6F); + P(D, E, F, G, H, A, B, C, R(21), 0x4A7484AA); + P(C, D, E, F, G, H, A, B, R(22), 0x5CB0A9DC); + P(B, C, D, E, F, G, H, A, R(23), 0x76F988DA); + P(A, B, C, D, E, F, G, H, R(24), 0x983E5152); + P(H, A, B, C, D, E, F, G, R(25), 0xA831C66D); + P(G, H, A, B, C, D, E, F, R(26), 0xB00327C8); + P(F, G, H, A, B, C, D, E, R(27), 0xBF597FC7); + P(E, F, G, H, A, B, C, D, R(28), 0xC6E00BF3); + P(D, E, F, G, H, A, B, C, R(29), 0xD5A79147); + P(C, D, E, F, G, H, A, B, R(30), 0x06CA6351); + P(B, C, D, E, F, G, H, A, R(31), 0x14292967); + P(A, B, C, D, E, F, G, H, R(32), 0x27B70A85); + P(H, A, B, C, D, E, F, G, R(33), 0x2E1B2138); + P(G, H, A, B, C, D, E, F, R(34), 0x4D2C6DFC); + P(F, G, H, A, B, C, D, E, R(35), 0x53380D13); + P(E, F, G, H, A, B, C, D, R(36), 0x650A7354); + P(D, E, F, G, H, A, B, C, R(37), 0x766A0ABB); + P(C, D, E, F, G, H, A, B, R(38), 0x81C2C92E); + P(B, C, D, E, F, G, H, A, R(39), 0x92722C85); + P(A, B, C, D, E, F, G, H, R(40), 0xA2BFE8A1); + P(H, A, B, C, D, E, F, G, R(41), 0xA81A664B); + P(G, H, A, B, C, D, E, F, R(42), 0xC24B8B70); + P(F, G, H, A, B, C, D, E, R(43), 0xC76C51A3); + P(E, F, G, H, A, B, C, D, R(44), 0xD192E819); + P(D, E, F, G, H, A, B, C, R(45), 0xD6990624); + P(C, D, E, F, G, H, A, B, R(46), 0xF40E3585); + P(B, C, D, E, F, G, H, A, R(47), 0x106AA070); + P(A, B, C, D, E, F, G, H, R(48), 0x19A4C116); + P(H, A, B, C, D, E, F, G, R(49), 0x1E376C08); + P(G, H, A, B, C, D, E, F, R(50), 0x2748774C); + P(F, G, H, A, B, C, D, E, R(51), 0x34B0BCB5); + P(E, F, G, H, A, B, C, D, R(52), 0x391C0CB3); + P(D, E, F, G, H, A, B, C, R(53), 0x4ED8AA4A); + P(C, D, E, F, G, H, A, B, R(54), 0x5B9CCA4F); + P(B, C, D, E, F, G, H, A, R(55), 0x682E6FF3); + P(A, B, C, D, E, F, G, H, R(56), 0x748F82EE); + P(H, A, B, C, D, E, F, G, R(57), 0x78A5636F); + P(G, H, A, B, C, D, E, F, R(58), 0x84C87814); + P(F, G, H, A, B, C, D, E, R(59), 0x8CC70208); + P(E, F, G, H, A, B, C, D, R(60), 0x90BEFFFA); + P(D, E, F, G, H, A, B, C, R(61), 0xA4506CEB); + P(C, D, E, F, G, H, A, B, R(62), 0xBEF9A3F7); + P(B, C, D, E, F, G, H, A, R(63), 0xC67178F2); + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; + ctx->state[5] += F; + ctx->state[6] += G; + ctx->state[7] += H; +} + +/** + * Accepts an array of octets as the next portion of the message. + */ +void SHA256_Update(SHA256_CTX *ctx, const uint8_t * msg, int len) +{ + uint32_t left = ctx->total[0] & 0x3F; + uint32_t fill = 64 - left; + + ctx->total[0] += len; + ctx->total[0] &= 0xFFFFFFFF; + + if (ctx->total[0] < len) + ctx->total[1]++; + + if (left && len >= fill) + { + memcpy((void *) (ctx->buffer + left), (void *)msg, fill); + SHA256_Process(ctx->buffer, ctx); + len -= fill; + msg += fill; + left = 0; + } + + while (len >= 64) + { + SHA256_Process(msg, ctx); + len -= 64; + msg += 64; + } + + if (len) + { + memcpy((void *) (ctx->buffer + left), (void *) msg, len); + } +} + +/** + * Return the 256-bit message digest into the user's array + */ +void SHA256_Final(uint8_t *digest, SHA256_CTX *ctx) +{ + uint32_t last, padn; + uint32_t high, low; + uint8_t msglen[8]; + + high = (ctx->total[0] >> 29) + | (ctx->total[1] << 3); + low = (ctx->total[0] << 3); + + PUT_UINT32(high, msglen, 0); + PUT_UINT32(low, msglen, 4); + + last = ctx->total[0] & 0x3F; + padn = (last < 56) ? (56 - last) : (120 - last); + + SHA256_Update(ctx, sha256_padding, padn); + SHA256_Update(ctx, msglen, 8); + + PUT_UINT32(ctx->state[0], digest, 0); + PUT_UINT32(ctx->state[1], digest, 4); + PUT_UINT32(ctx->state[2], digest, 8); + PUT_UINT32(ctx->state[3], digest, 12); + PUT_UINT32(ctx->state[4], digest, 16); + PUT_UINT32(ctx->state[5], digest, 20); + PUT_UINT32(ctx->state[6], digest, 24); + PUT_UINT32(ctx->state[7], digest, 28); +} + +#endif // SHA256_CTX diff --git a/user/mpy/lib/axtls/crypto/sha384.c b/user/mpy/lib/axtls/crypto/sha384.c new file mode 100644 index 0000000..f1071be --- /dev/null +++ b/user/mpy/lib/axtls/crypto/sha384.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "os_port.h" +#include "crypto.h" + +/** +* Initialize the SHA384 context +*/ + void SHA384_Init(SHA384_CTX *ctx) + { + //Set initial hash value + ctx->h_dig.h[0] = 0xCBBB9D5DC1059ED8LL; + ctx->h_dig.h[1] = 0x629A292A367CD507LL; + ctx->h_dig.h[2] = 0x9159015A3070DD17LL; + ctx->h_dig.h[3] = 0x152FECD8F70E5939LL; + ctx->h_dig.h[4] = 0x67332667FFC00B31LL; + ctx->h_dig.h[5] = 0x8EB44A8768581511LL; + ctx->h_dig.h[6] = 0xDB0C2E0D64F98FA7LL; + ctx->h_dig.h[7] = 0x47B5481DBEFA4FA4LL; + + // Number of bytes in the buffer + ctx->size = 0; + // Total length of the message + ctx->totalSize = 0; + } + +/** +* Accepts an array of octets as the next portion of the message. +*/ +void SHA384_Update(SHA384_CTX *ctx, const uint8_t * msg, int len) +{ + // The function is defined in the exact same manner as SHA-512 + SHA512_Update(ctx, msg, len); +} + +/** +* Return the 384-bit message digest into the user's array +*/ +void SHA384_Final(uint8_t *digest, SHA384_CTX *ctx) +{ + // The function is defined in the exact same manner as SHA-512 + SHA512_Final(NULL, ctx); + + // Copy the resulting digest + if (digest != NULL) + memcpy(digest, ctx->h_dig.digest, SHA384_SIZE); +} + diff --git a/user/mpy/lib/axtls/crypto/sha512.c b/user/mpy/lib/axtls/crypto/sha512.c new file mode 100644 index 0000000..aa2f589 --- /dev/null +++ b/user/mpy/lib/axtls/crypto/sha512.c @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2015, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "os_port.h" +#include "crypto.h" + +#define SHR64(a, n) ((a) >> (n)) +#define ROR64(a, n) (((a) >> (n)) | ((a) << (64 - (n)))) +#define CH(x, y, z) (((x) & (y)) | (~(x) & (z))) +#define MAJ(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) +#define SIGMA1(x) (ROR64(x, 28) ^ ROR64(x, 34) ^ ROR64(x, 39)) +#define SIGMA2(x) (ROR64(x, 14) ^ ROR64(x, 18) ^ ROR64(x, 41)) +#define SIGMA3(x) (ROR64(x, 1) ^ ROR64(x, 8) ^ SHR64(x, 7)) +#define SIGMA4(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ SHR64(x, 6)) +#define MIN(x, y) ((x) < (y) ? x : y) + +static const uint8_t padding[128] = +{ + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +static const uint64_t k[80] = +{ + 0x428A2F98D728AE22LL, 0x7137449123EF65CDLL, 0xB5C0FBCFEC4D3B2FLL, 0xE9B5DBA58189DBBCLL, + 0x3956C25BF348B538LL, 0x59F111F1B605D019LL, 0x923F82A4AF194F9BLL, 0xAB1C5ED5DA6D8118LL, + 0xD807AA98A3030242LL, 0x12835B0145706FBELL, 0x243185BE4EE4B28CLL, 0x550C7DC3D5FFB4E2LL, + 0x72BE5D74F27B896FLL, 0x80DEB1FE3B1696B1LL, 0x9BDC06A725C71235LL, 0xC19BF174CF692694LL, + 0xE49B69C19EF14AD2LL, 0xEFBE4786384F25E3LL, 0x0FC19DC68B8CD5B5LL, 0x240CA1CC77AC9C65LL, + 0x2DE92C6F592B0275LL, 0x4A7484AA6EA6E483LL, 0x5CB0A9DCBD41FBD4LL, 0x76F988DA831153B5LL, + 0x983E5152EE66DFABLL, 0xA831C66D2DB43210LL, 0xB00327C898FB213FLL, 0xBF597FC7BEEF0EE4LL, + 0xC6E00BF33DA88FC2LL, 0xD5A79147930AA725LL, 0x06CA6351E003826FLL, 0x142929670A0E6E70LL, + 0x27B70A8546D22FFCLL, 0x2E1B21385C26C926LL, 0x4D2C6DFC5AC42AEDLL, 0x53380D139D95B3DFLL, + 0x650A73548BAF63DELL, 0x766A0ABB3C77B2A8LL, 0x81C2C92E47EDAEE6LL, 0x92722C851482353BLL, + 0xA2BFE8A14CF10364LL, 0xA81A664BBC423001LL, 0xC24B8B70D0F89791LL, 0xC76C51A30654BE30LL, + 0xD192E819D6EF5218LL, 0xD69906245565A910LL, 0xF40E35855771202ALL, 0x106AA07032BBD1B8LL, + 0x19A4C116B8D2D0C8LL, 0x1E376C085141AB53LL, 0x2748774CDF8EEB99LL, 0x34B0BCB5E19B48A8LL, + 0x391C0CB3C5C95A63LL, 0x4ED8AA4AE3418ACBLL, 0x5B9CCA4F7763E373LL, 0x682E6FF3D6B2B8A3LL, + 0x748F82EE5DEFB2FCLL, 0x78A5636F43172F60LL, 0x84C87814A1F0AB72LL, 0x8CC702081A6439ECLL, + 0x90BEFFFA23631E28LL, 0xA4506CEBDE82BDE9LL, 0xBEF9A3F7B2C67915LL, 0xC67178F2E372532BLL, + 0xCA273ECEEA26619CLL, 0xD186B8C721C0C207LL, 0xEADA7DD6CDE0EB1ELL, 0xF57D4F7FEE6ED178LL, + 0x06F067AA72176FBALL, 0x0A637DC5A2C898A6LL, 0x113F9804BEF90DAELL, 0x1B710B35131C471BLL, + 0x28DB77F523047D84LL, 0x32CAAB7B40C72493LL, 0x3C9EBE0A15C9BEBCLL, 0x431D67C49C100D4CLL, + 0x4CC5D4BECB3E42B6LL, 0x597F299CFC657E2ALL, 0x5FCB6FAB3AD6FAECLL, 0x6C44198C4A475817LL +}; + +/** +* Initialize the SHA512 context +*/ +void SHA512_Init(SHA512_CTX *ctx) +{ + ctx->h_dig.h[0] = 0x6A09E667F3BCC908LL; + ctx->h_dig.h[1] = 0xBB67AE8584CAA73BLL; + ctx->h_dig.h[2] = 0x3C6EF372FE94F82BLL; + ctx->h_dig.h[3] = 0xA54FF53A5F1D36F1LL; + ctx->h_dig.h[4] = 0x510E527FADE682D1LL; + ctx->h_dig.h[5] = 0x9B05688C2B3E6C1FLL; + ctx->h_dig.h[6] = 0x1F83D9ABFB41BD6BLL; + ctx->h_dig.h[7] = 0x5BE0CD19137E2179LL; + ctx->size = 0; + ctx->totalSize = 0; +} + +static void SHA512_Process(SHA512_CTX *ctx) +{ + int t; + uint64_t temp1; + uint64_t temp2; + + // Initialize the 8 working registers + uint64_t a = ctx->h_dig.h[0]; + uint64_t b = ctx->h_dig.h[1]; + uint64_t c = ctx->h_dig.h[2]; + uint64_t d = ctx->h_dig.h[3]; + uint64_t e = ctx->h_dig.h[4]; + uint64_t f = ctx->h_dig.h[5]; + uint64_t g = ctx->h_dig.h[6]; + uint64_t h = ctx->h_dig.h[7]; + + // Process message in 16-word blocks + uint64_t *w = ctx->w_buf.w; + + // Convert from big-endian byte order to host byte order + for (t = 0; t < 16; t++) + w[t] = be64toh(w[t]); + + // Prepare the message schedule + for (t = 16; t < 80; t++) + w[t] = SIGMA4(w[t - 2]) + w[t - 7] + SIGMA3(w[t - 15]) + w[t - 16]; + + // SHA-512 hash computation + for (t = 0; t < 80; t++) + { + // Calculate T1 and T2 + temp1 = h + SIGMA2(e) + CH(e, f, g) + k[t] + w[t]; + temp2 = SIGMA1(a) + MAJ(a, b, c); + + // Update the working registers + h = g; + g = f; + f = e; + e = d + temp1; + d = c; + c = b; + b = a; + a = temp1 + temp2; + } + + // Update the hash value + ctx->h_dig.h[0] += a; + ctx->h_dig.h[1] += b; + ctx->h_dig.h[2] += c; + ctx->h_dig.h[3] += d; + ctx->h_dig.h[4] += e; + ctx->h_dig.h[5] += f; + ctx->h_dig.h[6] += g; + ctx->h_dig.h[7] += h; + } + +/** +* Accepts an array of octets as the next portion of the message. +*/ +void SHA512_Update(SHA512_CTX *ctx, const uint8_t * msg, int len) +{ + // Process the incoming data + while (len > 0) + { + // The buffer can hold at most 128 bytes + size_t n = MIN(len, 128 - ctx->size); + + // Copy the data to the buffer + memcpy(ctx->w_buf.buffer + ctx->size, msg, n); + + // Update the SHA-512 ctx + ctx->size += n; + ctx->totalSize += n; + // Advance the data pointer + msg = (uint8_t *) msg + n; + // Remaining bytes to process + len -= n; + + // Process message in 16-word blocks + if (ctx->size == 128) + { + // Transform the 16-word block + SHA512_Process(ctx); + // Empty the buffer + ctx->size = 0; + } + } +} + +/** +* Return the 512-bit message digest into the user's array +*/ +void SHA512_Final(uint8_t *digest, SHA512_CTX *ctx) +{ + int i; + size_t paddingSize; + uint64_t totalSize; + + // Length of the original message (before padding) + totalSize = ctx->totalSize * 8; + + // Pad the message so that its length is congruent to 112 modulo 128 + paddingSize = (ctx->size < 112) ? (112 - ctx->size) : + (128 + 112 - ctx->size); + // Append padding + SHA512_Update(ctx, padding, paddingSize); + + // Append the length of the original message + ctx->w_buf.w[14] = 0; + ctx->w_buf.w[15] = be64toh(totalSize); + + // Calculate the message digest + SHA512_Process(ctx); + + // Convert from host byte order to big-endian byte order + for (i = 0; i < 8; i++) + ctx->h_dig.h[i] = be64toh(ctx->h_dig.h[i]); + + // Copy the resulting digest + if (digest != NULL) + memcpy(digest, ctx->h_dig.digest, SHA512_SIZE); + } + diff --git a/user/mpy/lib/axtls/docsrc/Makefile b/user/mpy/lib/axtls/docsrc/Makefile new file mode 100644 index 0000000..2826686 --- /dev/null +++ b/user/mpy/lib/axtls/docsrc/Makefile @@ -0,0 +1,39 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../config/makefile.conf + +all: + +doco: + doxygen ./axTLS.dox + +clean:: + @-rm -fr html *~ diff --git a/user/mpy/lib/axtls/docsrc/axTLS.dox b/user/mpy/lib/axtls/docsrc/axTLS.dox new file mode 100644 index 0000000..bca7d81 --- /dev/null +++ b/user/mpy/lib/axtls/docsrc/axTLS.dox @@ -0,0 +1,1372 @@ +# Doxyfile 1.5.5 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = axTLS + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = NO + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../bindings/csharp/axTLS.cs \ + ../bindings/java/SSL.java \ + ../bindings/java/SSLUtil.java \ + ../bindings/java/SSLCTX.java \ + ../bindings/java/SSLServer.java \ + ../bindings/java/SSLClient.java \ + ../bindings/java/SSLReadHolder.java \ + ../ssl/ssl.h \ + ../crypto/bigint.c \ + ../crypto/bigint.h + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = images + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = doco_footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = YES + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = YES + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = CONFIG_SSL_CERT_VERIFICATION \ + CONFIG_SSL_ENABLE_CLIENT \ + CONFIG_SSL_GENERATE_X509_CERT \ + CONFIG_BIGINT_MONTGOMERY \ + CONFIG_BIGINT_BARRETT \ + CONFIG_BIGINT_CRT \ + "EXP_FUNC=" \ + "STDCALL=" + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = NO + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = NO + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = NO + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = NO + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = NO + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = NO + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is enabled by default, which results in a transparent +# background. Warning: Depending on the platform used, enabling this option +# may lead to badly anti-aliased labels on the edges of a graph (i.e. they +# become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/user/mpy/lib/axtls/docsrc/doco_footer.html b/user/mpy/lib/axtls/docsrc/doco_footer.html new file mode 100644 index 0000000..20c4e70 --- /dev/null +++ b/user/mpy/lib/axtls/docsrc/doco_footer.html @@ -0,0 +1,3 @@ +

+

+Copyright © 2007 Cameron Rich diff --git a/user/mpy/lib/axtls/docsrc/images/axolotl.jpg b/user/mpy/lib/axtls/docsrc/images/axolotl.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7352bbae836739e469c837a7fdb8114f786b2130 GIT binary patch literal 3041 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 literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/httpd/Config.in b/user/mpy/lib/axtls/httpd/Config.in new file mode 100644 index 0000000..486ae80 --- /dev/null +++ b/user/mpy/lib/axtls/httpd/Config.in @@ -0,0 +1,160 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/config/Kconfig-language.txt +# + +menu "Axhttpd Configuration" +depends on CONFIG_AXHTTPD + +config CONFIG_HTTP_STATIC_BUILD + bool "Static Build" + default n + help + Select y if you want axhttpd to be a static build (i.e. don't use the + axtls shared library or dll). + +config CONFIG_HTTP_PORT + int "HTTP port" + default 80 + help + The port number of the normal HTTP server. + + You must be a root user in order to use the default port. + +config CONFIG_HTTP_HTTPS_PORT + int "HTTPS port" + default 443 + help + The port number of the HTTPS server. + + You must be a root user in order to use the default port. + +config CONFIG_HTTP_SESSION_CACHE_SIZE + int "SSL session cache size" + default 5 + help + The size of the SSL session cache. + + This is not actually related to the number of concurrent users, but + for optimum performance they should be the same (with a penalty + in memory usage). + +config CONFIG_HTTP_WEBROOT + string "Web root location" + default "../www" if !CONFIG_PLATFORM_WIN32 + default "..\\www" if CONFIG_PLATFORM_WIN32 + help + The location of the web root in relation to axhttpd. This is + the directory where index.html lives. + +config CONFIG_HTTP_TIMEOUT + int "Timeout" + default 300 + help + Set the timeout of a connection in seconds. + +menu "CGI" +depends on !CONFIG_PLATFORM_WIN32 + +config CONFIG_HTTP_HAS_CGI + bool "Enable CGI" + default y + depends on !CONFIG_PLATFORM_WIN32 + help + Enable the CGI capability. Not available on Win32 platforms. + +config CONFIG_HTTP_CGI_EXTENSIONS + string "CGI File Extension(s)" + default ".lua,.lp,.php" + depends on CONFIG_HTTP_HAS_CGI + help + Tell axhhtpd what file extension(s) are used for CGI. + + This is a comma separated list - e.g. ".php,.pl" etc + +config CONFIG_HTTP_ENABLE_LUA + bool "Enable Lua" + default y + depends on CONFIG_HTTP_HAS_CGI + help + Lua is a powerful, fast, light-weight, embeddable scripting language. + + See http://www.lua.org for details. + +config CONFIG_HTTP_LUA_PREFIX + string "Lua's Installation Prefix" + default "/usr" + depends on CONFIG_HTTP_ENABLE_LUA + + help + The location of Lua's installation prefix. + +config CONFIG_HTTP_BUILD_LUA + bool "Build Lua" + default n + depends on CONFIG_HTTP_ENABLE_LUA + help + Build Lua and install in /usr/bin by default. + +config CONFIG_HTTP_CGI_LAUNCHER + string "CGI launcher location" + default "/usr/bin/cgi" + depends on CONFIG_HTTP_HAS_CGI + help + The location of the CGI launcher application (could be /usr/bin/php5). + The default is to use Lua's CGI launcher. +endmenu + +config CONFIG_HTTP_DIRECTORIES + bool "Enable Directory Listing" + default y + help + Enable directory listing. + +config CONFIG_HTTP_HAS_AUTHORIZATION + bool "Enable authorization" + default y + help + Pages/directories can have passwords associated with them. + +config CONFIG_HTTP_HAS_IPV6 + bool "Enable IPv6" + default n + depends on !CONFIG_PLATFORM_WIN32 + help + Use IPv6 instead of IPv4. + + Does not work under Win32 + +config CONFIG_HTTP_ENABLE_DIFFERENT_USER + bool "Enable different user" + default n + depends on !CONFIG_PLATFORM_WIN32 + help + Allow the web server to be run as a different user + +config CONFIG_HTTP_USER + string "As User" + default "nobody" + depends on CONFIG_HTTP_ENABLE_DIFFERENT_USER + help + The user name that will be used to run axhttpd. + +config CONFIG_HTTP_VERBOSE + bool "Verbose Mode" + default y if CONFIG_SSL_FULL_MODE + default n if !CONFIG_SSL_FULL_MODE + help + Enable extra statements used when using axhttpd. + +config CONFIG_HTTP_IS_DAEMON + bool "Run as a daemon" + default n + depends on !CONFIG_PLATFORM_WIN32 + help + Run axhttpd as a background process. + + Does not work under Win32 + +endmenu + diff --git a/user/mpy/lib/axtls/httpd/Makefile b/user/mpy/lib/axtls/httpd/Makefile new file mode 100644 index 0000000..fbf2fae --- /dev/null +++ b/user/mpy/lib/axtls/httpd/Makefile @@ -0,0 +1,130 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +all : web_server lua + +AXTLS_HOME=.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +ifndef CONFIG_PLATFORM_WIN32 + +ifdef CONFIG_PLATFORM_CYGWIN +TARGET=$(AXTLS_HOME)/$(STAGE)/axhttpd.exe +TARGET2=$(AXTLS_HOME)/$(STAGE)/htpasswd.exe +else +TARGET=$(AXTLS_HOME)/$(STAGE)/axhttpd +TARGET2=$(AXTLS_HOME)/$(STAGE)/htpasswd +endif + +ifdef CONFIG_HTTP_STATIC_BUILD +LIBS=$(AXTLS_HOME)/$(STAGE)/libaxtls.a +else +LIBS=-L$(AXTLS_HOME)/$(STAGE) -laxtls +endif + +ifdef CONFIG_HTTP_BUILD_LUA +lua: kepler-1.1 + +kepler-1.1: + @tar xvfz kepler-1.1-snapshot-20070521-1825.tar.gz + @cat kepler.patch | patch -p0 + cd kepler-1.1; ./configure --prefix=$(CONFIG_HTTP_LUA_PREFIX) --launcher=cgi --lua-suffix= ; make install +else +lua: +endif + +else # win32 build +lua: + +TARGET=$(AXTLS_HOME)/$(STAGE)/axhttpd.exe +TARGET2=$(AXTLS_HOME)/$(STAGE)/htpasswd.exe + +ifdef CONFIG_HTTP_STATIC_BUILD +LIBS=$(AXTLS_HOME)/$(STAGE)/axtls.static.lib $(AXTLS_HOME)\\config\\axtls.res +else +LIBS=$(AXTLS_HOME)/$(STAGE)/axtls.lib $(AXTLS_HOME)\\config\\axtls.res +endif +endif + +ifndef CONFIG_AXHTTPD +web_server: +else + +web_server :: $(TARGET) + +ifdef CONFIG_HTTP_HAS_AUTHORIZATION +web_server :: $(TARGET2) +endif + +OBJ= \ + axhttpd.o \ + proc.o \ + tdate_parse.o + +include $(AXTLS_HOME)/config/makefile.post + +ifndef CONFIG_PLATFORM_WIN32 + +$(TARGET): $(OBJ) $(AXTLS_HOME)/$(STAGE)/libaxtls.a + $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) +ifdef CONFIG_STRIP_UNWANTED_SECTIONS + $(STRIP) --remove-section=.comment $(TARGET) +endif + +$(TARGET2): htpasswd.o $(AXTLS_HOME)/$(STAGE)/libaxtls.a + $(LD) $(LDFLAGS) -o $@ htpasswd.o $(LIBS) +ifdef CONFIG_STRIP_UNWANTED_SECTIONS + $(STRIP) --remove-section=.comment $(TARGET2) +endif + +else # Win32 + +OBJ:=$(OBJ:.o=.obj) +%.obj : %.c + $(CC) $(CFLAGS) $< + +htpasswd.obj : htpasswd.c + $(CC) $(CFLAGS) $? + +$(TARGET): $(OBJ) + $(LD) $(LDFLAGS) /out:$@ $(LIBS) $? + +$(TARGET2): htpasswd.obj + $(LD) $(LDFLAGS) /out:$@ $(LIBS) $? +endif + +endif # CONFIG_AXHTTPD + +clean:: + -@rm -f $(TARGET)* + -@rm -fr kepler-1.1 + diff --git a/user/mpy/lib/axtls/httpd/axhttp.h b/user/mpy/lib/axtls/httpd/axhttp.h new file mode 100644 index 0000000..3b4b5a5 --- /dev/null +++ b/user/mpy/lib/axtls/httpd/axhttp.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "os_port.h" +#include "ssl.h" + +#define BACKLOG 15 +#define VERSION "1.0.0" +#ifdef CONFIG_HTTP_HAS_IPV6 +#define HAVE_IPV6 +#endif + +#define MAXPOSTDATASIZE 30000 /* adjust for file upload + size*/ +#define MAXREQUESTLENGTH 256 +#define MAXREADLENGTH 8800 /* FF3=4096, IE7=8760 */ +#define BLOCKSIZE 4096 + +#define INITIAL_CONNECTION_SLOTS 10 +#define CONFIG_HTTP_DEFAULT_SSL_OPTIONS SSL_DISPLAY_CERTS + +#define STATE_WANT_TO_READ_HEAD 1 +#define STATE_WANT_TO_SEND_HEAD 2 +#define STATE_WANT_TO_READ_FILE 3 +#define STATE_WANT_TO_SEND_FILE 4 +#define STATE_DOING_DIR 5 + +enum +{ + TYPE_GET, + TYPE_HEAD, + TYPE_POST +}; + +struct connstruct +{ + struct connstruct *next; + int state; + int reqtype; + int networkdesc; + int filedesc; + SSL *ssl; + +#if defined(CONFIG_HTTP_DIRECTORIES) +#ifdef WIN32 + HANDLE dirp; + WIN32_FIND_DATA file_data; +#else + DIR *dirp; +#endif +#endif + + time_t timeout; + char actualfile[MAXREQUESTLENGTH]; + char filereq[MAXREQUESTLENGTH]; + char dirname[MAXREQUESTLENGTH]; + char server_name[MAXREQUESTLENGTH]; + int numbytes; + char databuf[BLOCKSIZE]; + uint8_t is_ssl; + uint8_t is_v1_0; + uint8_t close_when_done; + time_t if_modified_since; + +#if defined(CONFIG_HTTP_HAS_CGI) + uint8_t is_cgi; + char cgicontenttype[MAXREQUESTLENGTH]; + int content_length; + char remote_addr[MAXREQUESTLENGTH]; + char uri_request[MAXREQUESTLENGTH]; + char uri_path_info[MAXREQUESTLENGTH]; + char uri_query[MAXREQUESTLENGTH]; + char cookie[MAXREQUESTLENGTH]; +#endif +#if defined(CONFIG_HTTP_HAS_AUTHORIZATION) + char authorization[MAXREQUESTLENGTH]; +#endif + int post_read; + int post_state; + char *post_data; +}; + +struct serverstruct +{ + struct serverstruct *next; + int sd; + int is_ssl; + SSL_CTX *ssl_ctx; +}; + +#if defined(CONFIG_HTTP_HAS_CGI) +struct cgiextstruct +{ + struct cgiextstruct *next; + char *ext; +}; +#endif + +/* global prototypes */ +extern struct serverstruct *servers; +extern struct connstruct *usedconns; +extern struct connstruct *freeconns; +extern const char * const server_version; + +#if defined(CONFIG_HTTP_HAS_CGI) +extern struct cgiextstruct *cgiexts; +#endif + +/* conn.c prototypes */ +void removeconnection(struct connstruct *cn); + +/* proc.c prototypes */ +void procdodir(struct connstruct *cn); +void procreadhead(struct connstruct *cn); +void procsendhead(struct connstruct *cn); +void procreadfile(struct connstruct *cn); +void procsendfile(struct connstruct *cn); +#if defined(CONFIG_HTTP_HAS_CGI) +void read_post_data(struct connstruct *cn); +#endif + +/* misc.c prototypes */ +char *my_strncpy(char *dest, const char *src, size_t n); +int isdir(const char *name); + +/* tdate prototypes */ +void tdate_init(void); +time_t tdate_parse(const char* str); + diff --git a/user/mpy/lib/axtls/httpd/axhttpd.c b/user/mpy/lib/axtls/httpd/axhttpd.c new file mode 100644 index 0000000..6718dd3 --- /dev/null +++ b/user/mpy/lib/axtls/httpd/axhttpd.c @@ -0,0 +1,713 @@ +/* + * Copyright (c) Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +#if !defined(WIN32) +#include +#endif +#include "axhttp.h" + +struct serverstruct *servers; +struct connstruct *usedconns; +struct connstruct *freeconns; +const char * const server_version = "axhttpd/"AXTLS_VERSION; +static const char *webroot = CONFIG_HTTP_WEBROOT; + +static void addtoservers(int sd); +static int openlistener(char *address, int port); +static void handlenewconnection(int listenfd, int is_ssl); +static void addconnection(int sd, char *ip, int is_ssl); +static void ax_chdir(void); + +#if defined(CONFIG_HTTP_HAS_CGI) +struct cgiextstruct *cgiexts; +static void addcgiext(const char *tp); + +#if !defined(WIN32) +static void reaper(int sigtype) +{ + while (wait3(NULL, WNOHANG, NULL) > 0) + continue; +} +#endif +#endif + +#ifdef CONFIG_HTTP_VERBOSE /* should really be in debug mode or something */ +/* clean up memory for valgrind */ +static void sigint_cleanup(int sig) +{ + struct serverstruct *sp; + struct connstruct *tp; + + while (servers != NULL) + { + if (servers->is_ssl) + ssl_ctx_free(servers->ssl_ctx); + + sp = servers->next; + free(servers); + servers = sp; + } + + while (freeconns != NULL) + { + tp = freeconns->next; + free(freeconns); + freeconns = tp; + } + + while (usedconns != NULL) + { + tp = usedconns->next; + free(usedconns); + usedconns = tp; + } + +#if defined(CONFIG_HTTP_HAS_CGI) + while (cgiexts) + { + struct cgiextstruct *cp = cgiexts->next; + if (cp == NULL) /* last entry */ + free(cgiexts->ext); + free(cgiexts); + cgiexts = cp; + } +#endif + + exit(0); +} + +static void die(int sigtype) +{ + exit(0); +} +#endif + +int main(int argc, char *argv[]) +{ + fd_set rfds, wfds; + struct connstruct *tp, *to; + struct serverstruct *sp; + int rnum, wnum, active; + int i = 1; + time_t currtime; + char *httpAddress = NULL; + int httpPort = CONFIG_HTTP_PORT; + char *httpsAddress = NULL; + int httpsPort = CONFIG_HTTP_HTTPS_PORT; + uint32_t options = CONFIG_HTTP_DEFAULT_SSL_OPTIONS; + char *portStr; + char *private_key = NULL; + char *cert = NULL; + +#ifdef WIN32 + WORD wVersionRequested = MAKEWORD(2, 2); + WSADATA wsaData; + WSAStartup(wVersionRequested,&wsaData); +#else + signal(SIGPIPE, SIG_IGN); +#if defined(CONFIG_HTTP_HAS_CGI) + signal(SIGCHLD, reaper); +#endif +#ifdef CONFIG_HTTP_VERBOSE + signal(SIGQUIT, die); +#endif +#endif + +#ifdef CONFIG_HTTP_VERBOSE + signal(SIGTERM, die); + signal(SIGINT, sigint_cleanup); +#endif + tdate_init(); + + /* get some command-line parameters */ + while (argv[i] != NULL) + { + if (strcmp(argv[i], "-p") == 0 && argv[i+1] != NULL) + { + if ((portStr = strchr(argv[i+1], ':')) != NULL) + { + httpAddress = argv[i+1]; + *portStr = 0; + httpPort = atoi(portStr + 1); + } + else + httpPort = atoi(argv[i+1]); + + i += 2; + continue; + } + + if (strcmp(argv[i], "-s") == 0 && argv[i+1] != NULL) + { + if ((portStr = strchr(argv[i+1], ':')) != NULL) + { + httpsAddress = argv[i+1]; + *portStr = 0; + httpsPort = atoi(portStr + 1); + } + else + httpsPort = atoi(argv[i+1]); + + i += 2; + continue; + } + + if (strcmp(argv[i], "-w") == 0 && argv[i+1] != NULL) + { + webroot = argv[i+1]; + i += 2; + continue; + } + + if (strcmp(argv[i], "-cert") == 0 && argv[i+1] != NULL) + { + cert = argv[i+1]; + i += 2; + continue; + } + + if (strcmp(argv[i], "-key") == 0 && argv[i+1] != NULL) + { + private_key = argv[i+1]; + i += 2; + continue; + } + printf("%s:\n" + " [-p [address:]httpport]\n" + " [-s [address:]httpsport]\n" + " [-key private_key]\n" + " [-cert cert]\n" + " [-w webroot]\n", argv[0]); + exit(1); + } + + for (i = 0; i < INITIAL_CONNECTION_SLOTS; i++) + { + tp = freeconns; + freeconns = (struct connstruct *)calloc(1, sizeof(struct connstruct)); + freeconns->next = tp; + } + + if ((active = openlistener(httpAddress, httpPort)) == -1) + { +#ifdef CONFIG_HTTP_VERBOSE + fprintf(stderr, "ERR: Couldn't bind to port %d\n", httpPort); +#endif + exit(1); + } + + addtoservers(active); + + if ((active = openlistener(httpsAddress, httpsPort)) == -1) + { +#ifdef CONFIG_HTTP_VERBOSE + fprintf(stderr, "ERR: Couldn't bind to port %d\n", httpsPort); +#endif + exit(1); + } + + addtoservers(active); + + if (cert != NULL && private_key != NULL) + options |= SSL_NO_DEFAULT_KEY; + + servers->ssl_ctx = ssl_ctx_new(options, CONFIG_HTTP_SESSION_CACHE_SIZE); + servers->is_ssl = 1; + + if (cert != NULL && private_key != NULL) + { + printf("YEAH\n"); + if (ssl_obj_load(servers->ssl_ctx, SSL_OBJ_RSA_KEY, private_key, + NULL)) + { +#ifdef CONFIG_HTTP_VERBOSE + fprintf(stderr, "ERR: Couldn't load private key %s\n", private_key); +#endif + exit(1); + } + + if (ssl_obj_load(servers->ssl_ctx, SSL_OBJ_X509_CERT, cert, + NULL)) + { +#ifdef CONFIG_HTTP_VERBOSE + fprintf(stderr, "ERR: Couldn't load cert %s\n", cert); +#endif + exit(1); + } + } + +#if defined(CONFIG_HTTP_HAS_CGI) + addcgiext(CONFIG_HTTP_CGI_EXTENSIONS); +#endif + +#if defined(CONFIG_HTTP_VERBOSE) +#if defined(CONFIG_HTTP_HAS_CGI) + printf("addcgiext %s\n", CONFIG_HTTP_CGI_EXTENSIONS); +#endif + printf("%s: listening on ports %d (http) and %d (https)\n", + server_version, httpPort, httpsPort); + TTY_FLUSH(); +#endif + + ax_chdir(); + +#ifdef CONFIG_HTTP_ENABLE_DIFFERENT_USER + { + struct passwd *pd = getpwnam(CONFIG_HTTP_USER); + + if (pd != NULL) + { + int res = setuid(pd->pw_uid); + res |= setgid(pd->pw_gid); + +#if defined(CONFIG_HTTP_VERBOSE) + if (res == 0) + { + printf("change to '%s' successful\n", CONFIG_HTTP_USER); + TTY_FLUSH(); + } +#endif + } + + } +#endif + +#ifndef WIN32 +#ifdef CONFIG_HTTP_IS_DAEMON + if (fork() > 0) /* parent will die */ + exit(0); + + setsid(); +#endif +#endif + + /* main loop */ + while (1) + { + struct timeval tv = { 10, 0 }; + FD_ZERO(&rfds); + FD_ZERO(&wfds); + rnum = wnum = -1; + sp = servers; + + while (sp != NULL) /* read each server port */ + { + FD_SET(sp->sd, &rfds); + + if (sp->sd > rnum) + rnum = sp->sd; + sp = sp->next; + } + + /* Add the established sockets */ + tp = usedconns; + currtime = time(NULL); + + while (tp != NULL) + { + if (currtime > tp->timeout) /* timed out? Kill it. */ + { + to = tp; + tp = tp->next; + removeconnection(to); + continue; + } + + if (tp->state == STATE_WANT_TO_READ_HEAD) + { + FD_SET(tp->networkdesc, &rfds); + if (tp->networkdesc > rnum) + rnum = tp->networkdesc; + } + + if (tp->state == STATE_WANT_TO_SEND_HEAD) + { + FD_SET(tp->networkdesc, &wfds); + if (tp->networkdesc > wnum) + wnum = tp->networkdesc; + } + + if (tp->state == STATE_WANT_TO_READ_FILE) + { + FD_SET(tp->filedesc, &rfds); + if (tp->filedesc > rnum) + rnum = tp->filedesc; + } + + if (tp->state == STATE_WANT_TO_SEND_FILE) + { + FD_SET(tp->networkdesc, &wfds); + if (tp->networkdesc > wnum) + wnum = tp->networkdesc; + } + +#if defined(CONFIG_HTTP_DIRECTORIES) + if (tp->state == STATE_DOING_DIR) + { + FD_SET(tp->networkdesc, &wfds); + if (tp->networkdesc > wnum) + wnum = tp->networkdesc; + } +#endif + tp = tp->next; + } + + active = select(wnum > rnum ? wnum+1 : rnum+1, + rnum != -1 ? &rfds : NULL, + wnum != -1 ? &wfds : NULL, + NULL, usedconns ? &tv : NULL); + + /* timeout? */ + if (active == 0) + continue; + + /* New connection? */ + sp = servers; + while (active > 0 && sp != NULL) + { + if (FD_ISSET(sp->sd, &rfds)) + { + handlenewconnection(sp->sd, sp->is_ssl); + active--; + } + + sp = sp->next; + } + + /* Handle the established sockets */ + tp = usedconns; + + while (active > 0 && tp != NULL) + { + to = tp; + tp = tp->next; + + if (to->state == STATE_WANT_TO_READ_HEAD && + FD_ISSET(to->networkdesc, &rfds)) + { + active--; +#if defined(CONFIG_HTTP_HAS_CGI) + if (to->post_state) + read_post_data(to); + else +#endif + procreadhead(to); + } + + if (to->state == STATE_WANT_TO_SEND_HEAD && + FD_ISSET(to->networkdesc, &wfds)) + { + active--; + procsendhead(to); + } + + if (to->state == STATE_WANT_TO_READ_FILE && + FD_ISSET(to->filedesc, &rfds)) + { + active--; + procreadfile(to); + } + + if (to->state == STATE_WANT_TO_SEND_FILE && + FD_ISSET(to->networkdesc, &wfds)) + { + active--; + procsendfile(to); + } + +#if defined(CONFIG_HTTP_DIRECTORIES) + if (to->state == STATE_DOING_DIR && + FD_ISSET(to->networkdesc, &wfds)) + { + active--; + procdodir(to); + } +#endif + } + } + + return 0; +} + +#if defined(CONFIG_HTTP_HAS_CGI) +static void addcgiext(const char *cgi_exts) +{ + char *cp = strdup(cgi_exts); + + /* extenstions are comma separated */ + do + { + struct cgiextstruct *ex = (struct cgiextstruct *) + malloc(sizeof(struct cgiextstruct)); + ex->ext = cp; + ex->next = cgiexts; + cgiexts = ex; + if ((cp = strchr(cp, ',')) != NULL) + *cp++ = 0; + } while (cp != NULL); +} +#endif + +static void addtoservers(int sd) +{ + struct serverstruct *tp = (struct serverstruct *) + calloc(1, sizeof(struct serverstruct)); + tp->next = servers; + tp->sd = sd; + servers = tp; +} + +#ifdef HAVE_IPV6 +static void handlenewconnection(int listenfd, int is_ssl) +{ + struct sockaddr_in6 their_addr; + socklen_t tp = sizeof(their_addr); + char ipbuf[100]; + int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp); + + if (tp == sizeof(struct sockaddr_in6)) + inet_ntop(AF_INET6, &their_addr.sin6_addr, ipbuf, sizeof(ipbuf)); + else if (tp == sizeof(struct sockaddr_in)) + inet_ntop(AF_INET, &(((struct sockaddr_in *)&their_addr)->sin_addr), + ipbuf, sizeof(ipbuf)); + else + *ipbuf = '\0'; + + if (connfd != -1) /* check for error condition */ + addconnection(connfd, ipbuf, is_ssl); +} + +#else +static void handlenewconnection(int listenfd, int is_ssl) +{ + struct sockaddr_in their_addr; + socklen_t tp = sizeof(struct sockaddr_in); + int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp); + addconnection(connfd, inet_ntoa(their_addr.sin_addr), is_ssl); +} +#endif + +static int openlistener(char *address, int port) +{ + int sd; +#ifdef WIN32 + char tp = 1; +#else + int tp = 1; +#endif +#ifndef HAVE_IPV6 + struct sockaddr_in my_addr; + + if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) + return -1; + + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; + my_addr.sin_port = htons((short)port); + my_addr.sin_addr.s_addr = address == NULL ? + INADDR_ANY : inet_addr(address); +#else + struct sockaddr_in6 my_addr; + + if ((sd = socket(AF_INET6, SOCK_STREAM, 0)) == -1) + return -1; + + my_addr.sin6_family = AF_INET6; + my_addr.sin6_port = htons(port); + + if (address == NULL) + my_addr.sin6_addr = in6addr_any; + else + inet_pton(AF_INET6, address, &my_addr.sin6_addr); +#endif + + setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp)); + if (bind(sd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) + { + close(sd); + return -1; + } + + listen(sd, BACKLOG); + return sd; +} + +/* Wrapper function for strncpy() that guarantees + a null-terminated string. This is to avoid any possible + issues due to strncpy()'s behaviour. + */ +char *my_strncpy(char *dest, const char *src, size_t n) +{ + strncpy(dest, src, n); + dest[n-1] = '\0'; + return dest; +} + +int isdir(const char *tpbuf) +{ + struct stat st; + char path[MAXREQUESTLENGTH]; + strcpy(path, tpbuf); + +#ifdef WIN32 /* win32 stat() can't handle trailing '\' */ + if (path[strlen(path)-1] == '\\') + path[strlen(path)-1] = 0; +#endif + + if (stat(path, &st) == -1) + return 0; + + if ((st.st_mode & S_IFMT) == S_IFDIR) + return 1; + + return 0; +} + +static void addconnection(int sd, char *ip, int is_ssl) +{ + struct connstruct *tp; + + /* Get ourselves a connstruct */ + if (freeconns == NULL) + tp = (struct connstruct *)calloc(1, sizeof(struct connstruct)); + else + { + tp = freeconns; + freeconns = tp->next; + } + + /* Attach it to the used list */ + tp->next = usedconns; + usedconns = tp; + tp->networkdesc = sd; + + if (is_ssl) + tp->ssl = ssl_server_new(servers->ssl_ctx, sd); + + tp->is_ssl = is_ssl; + tp->filedesc = -1; +#if defined(CONFIG_HTTP_HAS_DIRECTORIES) + tp->dirp = NULL; +#endif + *tp->actualfile = '\0'; + *tp->filereq = '\0'; + tp->state = STATE_WANT_TO_READ_HEAD; + tp->reqtype = TYPE_GET; + tp->close_when_done = 0; + tp->timeout = time(NULL) + CONFIG_HTTP_TIMEOUT; +#if defined(CONFIG_HTTP_HAS_CGI) + strcpy(tp->remote_addr, ip); +#endif +} + +void removeconnection(struct connstruct *cn) +{ + struct connstruct *tp; + int shouldret = 0; + + tp = usedconns; + + if (tp == NULL || cn == NULL) + shouldret = 1; + else if (tp == cn) + usedconns = tp->next; + else + { + while (tp != NULL) + { + if (tp->next == cn) + { + tp->next = (tp->next)->next; + shouldret = 0; + break; + } + + tp = tp->next; + shouldret = 1; + } + } + + if (shouldret) + return; + + /* If we did, add it to the free list */ + cn->next = freeconns; + freeconns = cn; + + /* Close it all down */ + if (cn->networkdesc != -1) + { + if (cn->is_ssl) + { + ssl_free(cn->ssl); + cn->ssl = NULL; + } + +#ifndef WIN32 + shutdown(cn->networkdesc, SHUT_WR); +#endif + SOCKET_CLOSE(cn->networkdesc); + } + + if (cn->filedesc != -1) + close(cn->filedesc); + +#if defined(CONFIG_HTTP_HAS_DIRECTORIES) + if (cn->dirp != NULL) +#ifdef WIN32 + FindClose(cn->dirp); +#else + closedir(cn->dirp); +#endif +#endif +} + +/* + * Change directories one way or the other. + */ + +static void ax_chdir(void) +{ + if (chdir(webroot)) + { +#ifdef CONFIG_HTTP_VERBOSE + fprintf(stderr, "'%s' is not a directory\n", webroot); +#endif + exit(1); + } +} + diff --git a/user/mpy/lib/axtls/httpd/htpasswd.c b/user/mpy/lib/axtls/httpd/htpasswd.c new file mode 100644 index 0000000..91feea1 --- /dev/null +++ b/user/mpy/lib/axtls/httpd/htpasswd.c @@ -0,0 +1,142 @@ +/* + * Copyright (c) Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +int tfd; + +void base64_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen) +{ + static const char b64str[64] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + while (inlen && outlen) + { + *out++ = b64str[(in[0] >> 2) & 0x3f]; + if (!--outlen) + break; + + *out++ = b64str[((in[0] << 4) + + (--inlen ? in[1] >> 4 : 0)) & 0x3f]; + if (!--outlen) + break; + *out++ = (inlen + ? b64str[((in[1] << 2) + + (--inlen ? in[2] >> 6 : 0)) + & 0x3f] + : '='); + if (!--outlen) + break; + *out++ = inlen ? b64str[in[2] & 0x3f] : '='; + if (!--outlen) + break; + if (inlen) + inlen--; + if (inlen) + in += 3; + } + + if (outlen) + *out = '\0'; +} + +static void usage(void) +{ + fprintf(stderr,"Usage: htpasswd username\n"); + exit(1); +} + +#ifdef WIN32 +static char * getpass(const char *prompt) +{ + static char buf[127]; + FILE *fp = stdin; + + printf(prompt); TTY_FLUSH(); +#if 0 + fp = fopen("/dev/tty", "w"); + if (fp == NULL) + { + printf("null\n"); TTY_FLUSH(); + fp = stdin; + } +#endif + + fgets(buf, sizeof(buf), fp); + while (buf[strlen(buf)-1] < ' ') + buf[strlen(buf)-1] = '\0'; + + //if (fp != stdin) + // fclose(fp); + return buf; +} +#endif + +int main(int argc, char *argv[]) +{ + char* pw; + uint8_t md5_salt[MD5_SIZE], md5_pass[MD5_SIZE]; + char b64_salt[MD5_SIZE+10], b64_pass[MD5_SIZE+10]; + MD5_CTX ctx; + + if (argc != 2) + usage(); + + pw = strdup(getpass("New password:")); + if (strcmp(pw, getpass("Re-type new password:")) != 0) + { + fprintf(stderr, "They don't match, sorry.\n" ); + exit(1); + } + + RNG_initialize(); + if (get_random(MD5_SIZE, md5_salt) < 0) + { + fprintf(stderr, "Can't get random data\n" ); + exit(1); + } + + RNG_terminate(); + base64_encode(md5_salt, MD5_SIZE, b64_salt, sizeof(b64_salt)); + + MD5_Init(&ctx); + MD5_Update(&ctx, md5_salt, MD5_SIZE); + MD5_Update(&ctx, (uint8_t *)pw, strlen(pw)); + MD5_Final(md5_pass, &ctx); + base64_encode(md5_pass, MD5_SIZE, b64_pass, sizeof(b64_pass)); + + printf("Add the following to your '.htpasswd' file\n"); + printf("%s:%s$%s\n", argv[1], b64_salt, b64_pass); + return 0; +} diff --git a/user/mpy/lib/axtls/httpd/kepler-1.1-snapshot-20070521-1825.tar.gz b/user/mpy/lib/axtls/httpd/kepler-1.1-snapshot-20070521-1825.tar.gz new file mode 100755 index 0000000000000000000000000000000000000000..d1caec5a53f93f043a32ec04807dff259223c32c GIT binary patch literal 768249 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 YXxC^qAC}G&Q`96+aR{7@ixnC?xYwp`@XY^ zXyWb8+YLaF)cVtg9}d@pEx+yycCO$?P;etGXu5&boyEesX?Tp=JJyxDWgU@Nt-Zxz zF$;cCgQI8u?7S;#-VDL1b0&7w!Pl7|g2@ZY%C4xNFW|1mI2&*wQ8PYKLLk(7JD8}E zSTcp&i-jZ20DA@5QruSemW{76wT=9{%*?c&q>#2X-(f!W)Kj$Re&T3VvkKcyz%7FC z0*RM1n8IxrBpTjtbxsH1racF|u6JS)a~jjcB@LybFV@Un73o5x~>c&njn+M><2O>>nsZnQkQ(V}-(126Tm z?X_EZr|Ie z?v7Y}FkN_$V@}{8sOyG2IGjEj2yzE(kFy~ufGw0r#x1EHC5=>HPGck8M^iDM$gREH znvTW%z=j{-Rj%F4kFMK#8d)tYD@T-J?9G>fGG#A3vsiMDgu!lwhvdL z&2`M1YTsXdUp}FxjfjGS4-UrJdSw9z=i>1#gy`E_mI-NWMVK!hF=xO%c=iV0&g~=&u&B8ui}4EE+zQ z9UQ!912m2YSI%8@Vb`G_?L#?u+bh>h@Y-T=v)o}fG)diJ4Y;0jTf)Iw?6^j7pEaMO zeAtmKLN0LVI^{YhxI7T~p*o{O#wDPRaH*Y}U1DADr01Ty9qC_GJvOJ1S9Q>1-}w)n z76?onv^Qpdcauv~>q8Sj2AX3vn~>WbJFpKqro^^l!EC2x;#}31>KW$&A}mpg@qoGH zNSoYSYxaC*6nY)YD{4d?lFy2%V&d8`vx}a>gf8SlP zAnLRh2pcA~zO|uyyUAFzyZ$D{lf7fq+H`4xA3E4Y}F?j7oXMmnq%39r0==veLG2b4lGJ z+lvTUU-K`s^|h6AkFqcC1@h%BY}yaG(>(v%Y&IGX*M!nOF|s*S~P^6 z(bAw>q{uHJ(Ud7Y$_wl{!JnC#EFp~}MD|l{u)AFPvdR!kDGO14n6F~$@Nu*v7ognA z5#)$~ARF*VrXUvRT_x4q-eVZASxjDDMzssvnk7LsnaTmA9sC;1-vBSbWzgpv^Nqpw zF1lF(HrMbv!m<>)d-nb6+ z)~02dRs)RH=qG+s`Jg04Jpw#KwMTQu^S0$~(@wh4Xf$8M9 zEQkm4kfKYBk`tICGv@WRHJ+`EJn8LzUx!FjmWHZaF-{Uli914wP~y+Cq$?(Kpo~!QiOdr?rZyrG7(>9{YUC%D;)37WNI;C8} z@%&mjY8g=NEu0u#1>7GrEhIYAtFxe|wYAJ}x_8K&++@h(9D<3fIEM%l546hO%s zUps=P?k0@%{OGNY9HCR(*Dz9T2#bx{vBNAl4iegFu;TCbL@6|bPePrhr>vn8U6`pk zM(n+yrifaF!{0pgGwgX2JHVKJZUcII-ihcK$AF1>F%dN}T%6lJ4@;v}+nq!lyHx79@{vPgtDUxft0q5{K9c3?=!Mvb^^tekr% zpgM2qaBZO^=W*}{@IDB=W;F<5IOdj{zrQwH7pju1=~Ya}-q98e2~AJNt=L4VfrL zaI15gT^6dQ9Aanle{dMO-STw04j|W?VSoz^Mk6fozVioW|1#iMpo=45Usblg!bT1tRcHatP>i;%Gk~n|p*JAyFfQXo-v+(oLQo4JchQ>03=Ds-d(x zGFSA_P=Y&66?MlPL{OBxkeJ&3pNtZhIv;!+{+w&OopS&1Tg&a+vr*sH&T^dQQ0hP zjR*=P9|Z>&X!b#wLeB9spiLZ7Zn^^jbM;RJ?_j{du!kLDwukbolV)~E%+^u59EkYX zr1a?9t{LKqD53|DeMW};n-celhD(c$BAXZ!df)aUspRUCOx^74!K`v%Ct<>}Ig5B{ zgdIali-<*cxQjNexpdKoY>KToZHQ)TfNL2`);olcJyOc((_tI-WGW1WJ2!eIS#}cO zDtX87y&~B@7&$Jm8j?$ZQZq9=Uyaxk+v;cEvHA}LX|TWezUD3A)zY?`Rdxeke|KU# zAhWR4wp~ojmR@qW@c>7Ibo+3ZP{*8=+kQ=uA|-%|At&h37|S}NN{cg9n)28paNQ1J zWWm+HWY>A72;l69z+97;gx*`r03t}#L$x4b7m0%NER<3%ei>CQhZM^3O(q!IRI<(mYwO*EK%PHCjDt5&@1()CuW+EUPt&Mx6h*i+he|r$X9G=#e z^BTxH+n%>IH`^;$0c9DQ2K;wjf^>-!K>sYuR(9|D{O>2Rk2`7Qb&Cd(-MektTV2p0 z__!T$B{Scyn8B~uY48g1bZ~8O=dE|D$HnXrW{dV`J%LTJd(PB2o&_3Xo=%(d*W%EZgsJS|&Lf9l{%~+rddjb35-+vR zb+10?7Z*_IqlV8Ik=pKKDIg(a40p%3I9lZGwE2m)*3X^PI*yYo=YSbF4;eDZvX(x@ zdEPDoG}BJj%USQSF1X-?8I(&_8iG2i0`rczw{=qC(#WEhqbyu=X0maqLP#`fE16)1 z!`TQEk0jzUM2-U3n5zgaSp%X;=yZs_S|ugNsTiI~kewMJ*31`LF9*4s8T0`&ZR{yi zVRtXWAzTFR6|YML#{^QD@-Xcn-87R)aO>PI^c<|J+o&DiFZ$$w1kM}1NhvoujS_7~ z_#9!bG~!$_QTHlmrNd;Z7ST}b-@Z@}m%Pnt0&*gI0wKV1+d^D(W^jcMdz9`K{k|D6 zQ1jIsQ-)WH=7aJHmXBANAS?>jcw-a(nsEyVTvrn28znj#T== zqtFhFm}smV1ZfFDcNu~=ktBkYiBYA8l8K@P2=_v9BO4dkOSLE5L+|nh`2qKnlr#O_ zvHPbhI>(c~b@e2eR^dQig~W~#g(Jf^W2%~Bf(c|QDoW|OkP8z=1}zY*;J(0^d6IRd z5HK~&AgPs&xIlyp+H#0l9k!}>SV7HjXId#`^H-6__Jxk)2$bx$n@>fFhHb0dI$Fs| z36}{r70b~#i%611k*sHyq4b!f7{>Gk$#$sy6YN7DYnmqh5jqm$Gu%n=Nhff>b zg=}!>O?iGGqa*mW0DEukx>InGBqUc(-GyAB-btK_6x;*}sEaWzF&F|j=b7ZZ5fdwN zp~uI8iW{>+Y**!AHf6IOb%{PQYtV9@Ia8YYbryOwDC1`9@ zl|gge19srUz>?Y7P za!09gtOEUy6V;OHPSB*zw6v)|SzQ;^Lu2`d9+EPaYMBDygaul~X<3bT#2b4T;FhcG zhz~5!nk2GAYEOpk0@0l@c^9V-mZ`Ov2skaKAF8*7*t#HwG~a}9!xpyCrr)NtzIK5gtmj~3?GMflt3AyI1C$sf#p)dnbpRtQ0_%DpAnOOMTMdrgm zqRG0c0x@nOW;gZ@AYgX}fFy-_;&%sd>JIe6qcwyR3l(T$X2`*-H zi9cu;aI7}vo?z2?*Xre`&)<0b(i2y=&R_UU>4$!%MN*$0uuqRLj@_j3;{fzwW37{5 z>W&P&H!1xzOg0ln-*1Lr;QkH|bt zd#x1HH*8SQtD-dF0l`zN6|u^8Evz%30<|_&3hB$38rF*gP56eGo!1RUsSUNUeaEEbPj~C*E=C%9Bsjx}u*)WZ*5kb|`H}oIAo<^0R(;v3PZK zb8of9Psh(j;qM;XY!)`$fgCj(z@J9!-e&to!;%c2vVE>4XLa+W>eFeda3 zhbw;SQ1*QyCyv46ItgMup|Sw>CS_vR7P`%iQ9!;Lj(%P{ro{Kg0rdTpzi>81)QMN# zS{L*R4q}14t89j`7}*VKwj|zPl#^SSJ&ue;UssBjbcxRV zAW4id0fywj6t=u9b6-=8tisvFLab4+?qp2o)&A2&HmMQWD;FQVbam^>yK7X|d*N-R z^RB;=q6%H-vCr%YEtWU-xWh@GiqjqDj_P3~bIFKyeYz+vy27iCqWFrL9x3x4cypa8)p6f#5!d1 zOt5cNF>=hfzOq3ugJ>G<7Af1su^oKgoe%IZhx@CjhK9sQNSG^^%?^t}0e$AaTXti@ z;X}^JQTCgQ939UlW55#hw*US9_P;+&mWClI!AU^n{D|h<>IG3LWz!vwcApuFoat$lEis;ke5#<;p)P zz!IRjwb8Y1Qb8)N5L$SW_mELRHwbMbg%+$%5jAtBC@N7GAl1#Q?`? zN7(T)j->rrF6kDc)5{lAExe*4yV)ppa{&&xz8dJr`FBRA3}d!uqc)4!`4J07evi*2 zKBq9s576qMuT^>05ZsUADCGP0tLlI{{B^#Y ztU->LS2@h3O3{iL$(SulGn)u4Lwc`(={eU;o~aonHUTaxF&v5u82MN`!w5#w;5W0r z;zEtEmOVRT4=|u)5f`juobXL3~X`*4S>SBM5I+G*V{`0TlSQnEW{y%SP^ zlj_)AfQ!%G9<_Eilg7qi$+5n~@rW>MYJzFjaV@tcfq)z6+@9LngWg(4$FQeKFhj*u zd>VEN_RgB*W}iVc;S%iRkd%ANC=cx6+9q}<^iWS$AUPG|(FNM+fov%|jA zoH^x}V@LmT?CkrX)$kTliXwd;+`#TAs;&t4acJ`*a-BXe-(yqlS$|XhiPf85_uYew zinDOfeJV_}g;fBw*qW**#bebn9o2Yld}84Q*rzYXLB+Tz?~WFZnD3T^zYFqtp+w6& zCsBZz*b!(_Q~+qY7?mlxaIj4+nsHJV0{xQIk5;Ji zH0MFpJ=P7erq+viVB2!UDBrw6YRtCJYOAe*PeK{wI5I_&eePuTB{D zwng!NTA^1<73<_JSpKqC4$dSyl-teIu7&~EQ9l6G=#Kby4SiSKHU+&Veh%(P6zV|y zw~~qLeqpLre8IQ~Y$Xli&6ZdK%TvMhDhlFj7u7JJYtU45=;RKk_)<3Z*io~t6~teFNF&1`oHVdJtt^drdV!nzehTqy#%O>XN zTVyb67WAhtZ(X^#>^@GK$BRpDp9x+>*2&2 z;vFyz_)~@U(_>F?uy2!=+pdB|<8Risv+cWpHH&YG?k(=aa@0s}P!Z#N-K_z>=FjH4 z!OzAA*`!}3EmrWylyM$)bYy|ucY zO_+2=3wkuAYE2CSj|m+@g?!K>UD4_~x|X{hneU;;vS(nIbPv+g?QkD1g;$ z#KvUmq9W;u>4|_U)#iwm*HD{Tuf`d|T2D^;@i~I|hZ;_rO1KVF98bfEofD*7KN--{ zbs4L!sG2|7nLlF)=tE}L6WIxNU#+r@D|4_(* zVI9fe3*TBf9#qf8?o9F}AQwz{4H$4@R(!WC`xZo%Zeh^D_VRhW#nSGW5v3Gx5u}l_ zAGCd@BhU?jUI>J*(5uxc3yB5>-tg?jY;I@qKLaaRs8C$MiiqQfq&|XD2Zq>;vk4$5 zAs`Y#L^*nmik>r(wm`*Q?6W7Va^z-wKcMOGhHm44z^ARn{79Qp)z|M{3b5`d>nWh{ zm*bWbcr@1@<2|_V5j4-OdcRtzv^Z+B^_E;J*4bCMqRYm^Cy+AD9YnB9f$Fzj+!#ku zpXg^$@kd_AQ-ECZFVD`r$!)wnL)oUr!;mqO>{;TTrj97(J0_-pb_-(JY`cw`fRnMg zC9Q&!(VBf6(%67qkS@teBON}Q3_-TCos31G1-rk#V>9a~!sAZNxH;oV7IK|xmLOum zh(;*FfMI?%JQGu96bK_*24ukL3Q+Pe_qDe(Hkqo%wyV=Wz$Z^o3Ddf%V{KE{TG(Ge zVp@eMu)diV?BF&s|Gf8JPiX=Aj5k50Ma79eK}c$QWuiBFF~XSfp4<8>e)bV-o`A8r z7caVh!T|22S+HqFvGuyDL^|L~nUC)qdDoG*;r$t_eX4F+yvQ&YcI{I>pc}Dk*;^?& z0`lpLz6()IoL%1UQe8T*#D2M$e2X!-{;hLSd+4GOo4ot1uP!SX%!k&L3|eC5=?CSs z3f%iHxu9Z-PV=<6ffwvUIj422x_NYIYjIk=*TRr)++=h24kdHdn+KmP+C5k(s+9_KP&Vl-^J%OlkmD&1adAyrCmDmII&ceQ zyEZejpI7R>R$nUAFsYs{Ah3ohdfIsd;}7ef*tqPA zt^P53J&x%jebqE20};bVOd+W(?m>c6_^BX2ea8+lUg|=OQG}ud+TvgeRiu|?+(F0) ze6^HwS70cPLFpvN_L}h6Qp&|)ffMjFAJ=(mRyxZVyhLpQFg{uM4TULZeg2uzzM6 zY#d}wbGya2GL;466KVy~XVV(*(V59=j3;hlCfSh!_OvEf=$;gU6eE5?<|C5~fGX#ax-e*H%oP#k_SQ>)xLY z$NF>lJ)g)xi5Q7_=cE7y=>h&F6b6B9eYORC*pz7lZ`|!-gife?vyoZYD^7sA?B$Y( zA0^~XoU^c388U{36w1u@q?#{*7d$qe?lo`tfwonf>ah(LwOrwOL%!}6*39omaG(-q@jW> z1Uv)9L?VbxsOrJ)Y$j`Ti4f{I*oE0eRNB()xg~anp}famwUcSOKdtE|$0V2m3@ptDj$K&)d&+UB|uF>sny zH^Je$*F*gKU7;6t=BH@iXC1MS!#ykPfD#OI%5j=M720;;>eiD_NioDgghT|5-SyK2 z>UyqRyt;M%%9d9Zr!u&O+AchK`SQgJer+xVkeMoT7@Hv6=hyr66JZ}6Gb@oa*|3~Z zI3J7YEkl$(bNk4gls4xpu`1IAZ9UZ3*dzz^AO?)@7yCuu>KSU?z@`Ce!^@c>3Rv^k z`r5{+d40LMb@8c&$@FvVU{)1~6Rc%c=(?;cE1=F@(^4q8eA|u*j0}|efd@gnCbz>GAO~0e;I}vG~JCQ;*4D#`4mN& z9q$H_hs|zr=oz1Sg~MBgWPqBQ;ffl{9G`WHw?+1qRf<-BWK{v;rCaj=?y&Z=oDeTY z1@3Vlg4e^HbvB=SKl^Fz)T0GrHJ57SPW_pEie%-$>jnAuFydJ@CHpr`m9XH4R5px8 zBdqFYON<9Gd7B2*A#^oNQIOtqbJ_9HFsM7zYd0mIx{XSu7lFH2Wb793z}i)HAa0lO z$SxBSo#u9cxt>mnT}(r#IBZM)I3;|_*<+SSJ2ZCz$Ri?H0eZN23D}(?SOY!r6rz5d zxo0ZGRg1=D=p4q$-CH52FfyHQ+k7*_c6dE)UGA7$b_qwFs=d%8W-74R8-nSx&lj-I zs^o1SOji?6V0}|2bqtV8R{SEMBcOq}buqnDp=+{|HRVIrSv01R3r6HTrFvssx+exL z*qyQ2T}F#2#cq3AUmkjpIKAP`d380p1O@_=NGuTK9Jrab#6JT`B zo5oAz;i%`4AI*2H8&4;IS#X24AAb@Lv(y3pml<|+sxa>eB48r96|JW8p(C3Cy5P(* zHvEm+R@8~XD+Ni66s$)0tiY{d7d5id3U&(bkgT@{cP546SIJ7R9GW8yl=Nt2?%t~y zG~C;M@^Jo1wZ)d)gEeJogxZD|9U66TnA{d=*7&Gd1KRu{_AG9$H%R+<(J*bnmvW%E zD*~(Qtqe9k)@6tKvW?Utp|&{Z+J%$=p4(*mJl>$uax8{pf8^e)MZ@IQxROmZb8-9I3Awjm2JzX#=_9`HrKSSn7(DS{ zjrI+1XHnY(EBh9PPc{0(r)P_X&wY8RhfmGW@MXqB9QoRO&_}m)sA_^KKUy>$$B{~J zeKuGwzlC8To@6jCP7JtUV1z{Zl8+3Vxs{>C@AYM`^q1{6mxe4ygT}pbLf8B)ur&~~ z3C_nJzz{#1KWZs;M_d~01k{Ed^JM_{-y!1BC)RO#sTww{2(+}X0|Xm0WPm4~V^Ha03my0lMt?%-lbGlgccdW$L<7uWvy#m9s8%#&JUO)zf0 zwXm+8ME~6Z?+;u$Kie#2NfMpMF{gYsEr;2ZU?0E+vTr85v`I+F|553$ z7^%`bpX6u@afJB*OF*>0_6(3H5wJaupZzw6pS@VwyrhXXFkv%|)rE=pl5KmZ(NA7G zEF(z1O*F%nYPm+E*j*gF#K?zC;~+|hp%w?2g+aV_c&+X1vy*pVZm8ocZ6dq^xu)SQ z7#@34`b)r0D!~1o$$-6OC~(bXdJ3%Y9e=x7d^Na=fwChs)Ddk!i!0)KZ1w|qh|zVu zV3n8gcaEvcrPw^n!mawDUlOB14Z#T7QjYOpvs^R(@4|EEkG00s+lR~U=@@rEZ_v!9 zdxLdD^}~5RAiXRgVpqe{cr`eRv^%`CE|~T}`rzFAX?yx!$NFNb3_~L@=Fn9K$A_m1 zHa{DsB}&dB#^S0}ZGtTXT{9<-k<;vQ(*|ZcMm+p~H{d|wEK~OvY?_$3q#n;XCietIL-B!;&0;u|dO0NWLbep4 z|2Zebz%!jfD#uYnE>(bnR2{;Z>SZA3Fwh)okT#=Km z2saCcCj>Kvh%|=mT5BdH>P=fSbl03@2lT3#9(h>#jQoQ2S}#?9{zU|{j>byJ(#T`t z;6QJXj1IF2$KTp2Aqfi{ShExQjEaaWs7GSQNdX*C!3Z0om{gcOKdx2QW!_;qocgEa zu)*jm(itYXUeYt6#3+}#C7+g6!7J+f%-+}M-0mbU7SB6c^O2iqM&9ZV+xXi%Ad4a)K+<5a>T`_4ZWU#IYm z><;S!ux>(dn^7?!U;`VS57REC3`;84K8ynH;AuO3lMkzCzC>>Rg!%G>8Iv@(y3xj6 zdji+Ud$ZnFA^ezQcBi#+ca^TDcUSL$9G!K!9W0r!|5_X}1-}{Kr+uvQ>+QBfFR(yB zm2`8{Oh7)C(d;0)=OGxMIT1<-TL8cii0Ko;3J^(v`Qrs7WIojVw|%{=N8ZK}!IqWvaAm}wc2hQ2qza58?$WCBdErdyW>GGrlZ8sxar{1+{naC3)XE8&z(TO= zv1S#JLGrXt0SuK@8uxHDFCTk|#~%V4GUb|{D!*Hc?-f9s)qF*5@B{B#56yyjxZ22_ z)a(Ig6qSe1Zw2N+m#$RqO)a}=x2~Ak2=f67UNLy2Ii(aQYiwN_dA3_z7Itq0^-pW5_V=kyx86yAaxZU_T{EX3nJ6kjfWt3wuAhgh#Gd;mld3 zDkxj}ePZZQjhbjRD$CE_$U3QmwqXzHN!H7^adUC9O;>}P@ZAiLZ(oTRJU2C)$`a@p z=EU}LcAwPq25Oht=%6%GX|qm#@e!*9O05Cumi=KS05GD#&j37y_%>5$sSf%hX-SBJ zW^61|)2>CKMvOmKo_->*#F!^FOHAf(+gg-bq~hB%@nDie+zXNm$*PDgBj3COm+7DR z|Db>7|7-oD`bjVo9HwR3ogc_H_Px!=O|IrvCp-=v&7%lOD9Hy1LROGo9+&`bu86a( zdc3H&u4Js&+tJ8~OdMw|IWweB$3|>h3wkZL@Vt>6BM)QKSfuCzxS~;fQDk_aAoO!o zHe^YDITB_D9a)?bHj+vcspE0eWg^a}>#Xi)#H*NeBwoulWl0=3J822T8nc`nW|~{p z9{Z@0Q`SLNx9VD^WA3EHju&<8oH&ftPuPQSbwdPGm;cYVrrCo%%?T&ZBKCyylZ06} z_2P6x#_)LKBluB?0&@aTd=lwUP|eS7Os?kM z)WRcE&DToq8PKvf803_+Vaa>&|f6NxR+dGO>gi<&>Yod1qhMMjI#_(@7;s_8^rnEk>Vc ztQBdGtp}VKBk|5Lq7g*$04fWoRy9|H$Ad!3m6Ua{q+%$oUWO6TL^(tI=}e+jM1{C} z@w~z4F8g^IYU&;g+(3xB+&$@74}!WOv+ePY$lsGwZ-us12F;kz4fyP=KzlEAh%8%M zTGg>L$UvWSQ1qvJ=5I4HvxYsJJhriFP%)xC%n)(bf8BkzD8K+31>)&oGUTOwXDt!z zbu0y{*w=vHw`w-Tuoz`-({$*vFx^LOnhXy5tSa1zRp=l4CDg&H!f~uZ*|B)a_wvK6 zZ{}!d#D7Gl&IaoHe&qX+b=wpbHaWN2k9tdeM9ss2%*-NB+Dmi!E}KC}D~fsXe%|#a zxqKs+8%F>(Go0k4USp(3x5h{}hA!1!E-|dR@k^ZHtYKII_-34kKBf)buQOsq=bdPc z=RBceI;W{-+qoE^J_1hY1j=mK4D7ERBAU1JsjqJ zV9UWS27F2+v4CM!cI?IVsm2M^Gx z67(s-?EICiyD++^3+#Ee+!7}Somr@`yAU@#4`+5WMGv;DYqwjjxBD7!5v zzMtKowBnQ9fZMs~yXe+*HA~B&oislLlRf!EVAQKsVbHhS2_X@N5uWlMswIW-a zi%E7+gSVAu^AD4h`p5*iHRA8En40MmXGImo1y@Qro7zP6cRrYl#L6Y2xy&T)=F?#E z&65QunhGs>oUf|<>fZKT5>tu1bQq5oJUmI0oV1E=-gUF-&*GvX7xgh0OAWf1gYwp_ z)L)3^GhPcjZ;N7PPNR&sQ_*U zXwq$Lo~piis--qhb?nXaaLIgtio>vwsjz3#v+4dzvu_j%*#5k_>e*A~qJS~DXrTPZ zEo#^1PHxjB;?5$ThWc{m42ASr`*@c;-`$PDtMNZ9+ujokN~p!SSpcVF#rt)Wix`}Q zhWdi?`Bc^;aa@?2e{K?hMd5_bQ(oeEAx;Wau?Q$$#DHj>&7iACiU9^}KM0H|f#+Vr z#z9O+UK<1MXdpf;eVEy`R+LgX0!pGS`OPrKz`#EFhgHhj~ zPhE)~U@f+;8(nmW1LrSrpp{^}qb_3?bw8ZuYmr1FrXG)^@v}uVjf*XDC_)&{XrZ}w zI7~H<_J%OIgbf?4ffxf=_8o-ol<~GMcSc|vdXG1VR?LEAM$wV-Bl4^B zR|TFdToX*6yR1vE^W9q{Un%&!KE(8>Z{h%YI|X~*>}KOXI0!u>Is<~FKacom;Y4Do zI|)W8{pI))xDyM=Cn`*conVz#2V-M6AKg~>tv;ZF!WSs-m;nI>Q4 z;HXk&0ZE5DWLbV<#t26Vf#s>g5EN2rL(NZyI%qfE(Fg>oCA zy9ILTHh-5>mN-5JvSGpMSlL!p5s4XDVy@YN!#Q0GHKSNKBxo^_dTWpG9Ba3=83Wx^ zSF;MjJ|PXXK;~0inGFKv*ff`{OXreiJsJgDvv}MDD1H=zXCDQ~*@)ts#glyD?OXPb z8of@Im`E9b`cjvQ~c;pGbR(#a$OhtG%+d>n6Ll zM>g+5r_gpZQ=IZyCR)kfr>J}lGj9=40U&*r4A^NI#AtK(t(&}!R|4@7XP0_vv3=*;buqPLFDi%mffIQGP^-_i`fn62*zdxb=U3) zzO-^v6{I}y_U|p{Jg6FS9#l)`Jg9CV=fQlc7MoJnL^Dl`WJ8!c@MW~04IAk=qx}P< z5}o9hNW`Mt1OdWMl8Ffcu_)t<%IvKz@VAvoABPI}lmX2D6ay%Gk zuD-?8Rs!tSvtUt|XEHQA-c@e`QMz+an<+i3ywiqH7Th~nX4!loTv`%>5a;T2*Dbj|b_)i$-BC*BHXfdo850_reUZfP;w`J=FcV*VMMmXRPc z`*8kT+hR-7whM&IOjCc^Mq$hc%caN;A}QQl!VWKjj>|-Gz0JYd7?x;cXnSu2!pG8M zRtXYusTo&`(iDn&{gkEa?Q=WX0Fo7Mb4htQ+XhP$teJg>N`O>HoEP(`zjh&q#nojmT#vB zJ~{3_JN^#SIEI}$syU|^D+?@HrYG}1YAsJY5?rY9M7GObXkewZcE0Fk5 zb90Xn@&u?6hUi2Rzs}nsO9B$jaiz1x=O{G9GG250zHO>)Bbo*7S#TMV=q;oh-Wzqy=jGdS!F0rNo4XO| z5_80fnjSN6Hj#*BLD|3~0c?b|f@q#-(YJ6%?^%<`q;^7(7QnU*GCo@vheXjKBiiW~ z7#S3ySs(?dxXBkKpIm;?AA`tCHV7!bpq73zZ$w zIypQv!8~-COlb9@oMX5EOHS9kd+K2;oCt<7o^Kd@>I4_Av+8;X#Rs5PD`kgygl3y> z9|WHj6eyg88a7d&s}nRL6jDH#sv)}1-$F4ec03m7SP6>edHyedQ7P{O#k$x4!DC7a zb;k>N)=WMXy0;X5Nly?^FYzAHku{m@Qrot7l8UNE^Qe|vV$$YKVk~slJ)NV;y~i)P zwn}?o!^76&=PsCnb-MVt=iAQ5^ zw$49v`C{zFBTqkZVe8V9(dwSQdhyD`=eN#BD}3zA#q$r_H!j!*-(J4-=wspMi}ob^ z3g=y!Ru|n4TsnsqK$muH7{=8x5i6G<$P4{dBWwZ|iPB$z zMfT_N-RMNBeI(;k!boh4RFkDP_Fq{Fm z?1m&gWR0C6Y}>P9FkO`dWxKEj=7VBjSVl1NU!pK>jIt|tFwt>F7*pAR+zFui#N1Ux z3C$$P)*v5$AOL%i0fY6tTjblpAEJBffxyv?$Vq^Av85@=&0<6ph5DESj;p!d084*T zQJzso%P)-(OY;puYv~FrPnD3q;#SA=hG?P$IFWii@WIk99JCIQbprv|!G{NOPK2&` zn~F`i@1C?Z;#3=9xdSt_%?0Ij87X%)Qm!gzlb&i>mxInSRJFO1yzXJSfhsqejVrH! zDmQDZ(=i+K`LLft-7G59n$TSVjdiT7H#8WOp_P;AjcU@n27LIXhp%4x?2Feoy>jN? z<4Lg(^mzi7_LDQzKiJLG&AFS;f4U7VELjUZI_vWelnlx9jI?~;g*42CL!CaWo; zVK<*5?FfS3@tMar6hM8g6TKc-QtkwvHyxBC2N?Y~gH*g*Dh^AJzK(Xi@D!xtac<;) zecU=p#4jHLJHB@V2Me$IGpo-Ydtfz2zw3%~o#b_l# zvLORny&AeF@XoPz#Q8M>Wt&r9MIlt|UBR}VPZv`U4^;{1fI1D-qlRZqb<3IYMxCWA z2-1kYq^Y0_+W2y>LmlS$3799yP+P@YRma(Dmz=mp_Esgo(J2O|fb)^u4&DUPgfukd z(~jG3449I5Q$TrZ^|RKNO01Zhcg1dtpkfP5>41y*s|)%Y#wn_!9CKj^N~@QLmM~lm zi5@bEECxES*p+Ek41!M&GA}s@?&Ch#*HS3V2`o9e!2nQ0Cm4Rz(L4sxmO35OqmR$1 zx`S#HE2$K40o}@xc1=$zGmmickcl-t8c?XA>k!Q7z8Me!=`}TuPH8!6)K}NzJyt3k zi+P`CRXHO38_>3hbFbf1XHRtu6vOM13+tqsuJ+7suB=a#spQDRK?TZjXwD!sb0$Go z4ObZ(d7M%QLgNM1I&|+u4bOnD1^cZLZ6{&^K|;l@>p-4$g5EkscMHE~#G4L@ zVB)Z@&FO4*9S|lpjO9SN$nDhTF$d2L%X)g_+ZG&#h{C#U5|U8iOfcEzYaWCJi$d zTOo_S-hzE;6M^Y!$N|uv`f^MZI?snF?tqWQQMVnRe8WlBj(LQC3@GxlK&rbig=NT7 z!J}sL(_`jss!A^Fmn*~xztNc53p&>;XQOGPhxmNH{y~?#rEcPvOZ0J=Rk2Bg$4m7P z3f@u&;ll;}Tg+F+`vryO#ZSR0?kI`wo@^5DbkrlBT;+Nygj1t~jP@B&T7|j;fL5%k z$XBF533U~j&Bg94lI$4+qDLk;^ya*aDyB*}PGTD}4Vt0t7v-#KP_!&7p_G$^?Om02 z-v=OOJWh2_lgENH`j~$}+sBzD8@yjjVol*E7^Uo}x~A1a&BRU5IZQFb{np*-rtsX7 z;0bdDR+fW^+=DhGF^pWO1yZ*$c};;PwO)=qHfDz`ASDJ^UyzAWgJq4Vbue^NMJJIc zZ`3Q-%yyvh)>=Wg&$G#uZ`+Ii>g|&d3Ut{0&R=;rSuihL48X z&f?uf&u#V)w{oFmdBWFcpTN6~MR)Eo1?$#X3zb^WXC*d+3zXZq>a~&7+o9NuAOlYAojY|mq2kniV% zhNdnr)08mW2YZlhUE?`|EkII)N)AjjQLK1?5=8uYpE{1DMabp!mgW{LHSCWu;si=~ zU{oR)=xWD7uw_~Z6H+rqQoL=XpPS^p(M_JP9t_mEV$>VV`ocfbGuS%4a!5cX?SQqb zTSr{ri6s3>T00)yMCS+|{a7e&ZFA0zn>195xN`rp!)MFc=cRNE4Z?C1QIp%F7&IKY z=?W?s_X z`d<^(tBl|?f|Skz28Z6((GS`Yt?x41OxZYXT_?ovW)a1sOVmA7d9r_paM3t$tPSS)GRdgl(1Y^i#lDH;~Zbd09ed zgE2RgNR%YC@4+*=o4=orr+XMvq=GN!?o!bK`F-N2OJ7=CKDK9JBAd}^8?P9NwoV^C5{5j{lL)jXJ^1a9tqpgmv9#D5^x*g zx-L75AoEm;>;$(C0&vQJZBl0_&d(a?cc+1XGkYp4;DpO!L|z4WN;oT{j=VCH{j|(1 zs*KI123k<`W&oyaPAGVGk#orr&K#4-sY+>2*aD7+yjpf#c_OZC$uj>x*)FDtFMxI1 z(5X90)dM#S**lc}HMm}?5QHPH#SGM?37SEy`X2Zl*Gls_T)?PAd*pH_wdZydtS4D`448L`q81;)1Yo>s|qml;X5$ zhY;C`Y_MutPwEciUJy}EJ@@%?hDc@JH*9+iGluw z){q92=>`I8p>6zJyF2O}*;Am5SNKv{PiziH1lc4(l_{eAT!LMRZlB>uec-l4I5*cW z;&qf03odTMGis#d@$*+}q*I>FCxK8ZAb#Y4k+%`sw0y$xhn@B<-=%y98NRX>eg*e+dmT#ap`D z!qB2C<}$tKu0i()c_wJu?mI{bE9@+%Ghsf&;>uFyVjoqw$@yeU{DPJqQBjFRUM9|} zq-fp_BU59w5QBjl)N(@AndAG+Y&d4BS_o2e-w0kgLSZvg1^g$}&=$Z1;;wK5?`7k0 zj!4gnQ|?3BUh?RMdt4A&L_ z>l_oWNvoO2ML7?uh!(Coma@0HWo56uVH|69JU#DIHnVn}jd!*rM+8BukL=p5C?aF{ z>PvoF(|s;E>zoN@3Ao3^5&)jKxFjtARtunFmlIl{j+aXjSw)o-)iG5()orMFVw*Lh z-GLcC?xIPbZfnhIXQ8GqnR_Hqhk2{|poXKd?B`1>zmKuw8kHnAoMipnDIH95ib6@w z&kl=00UDgk1g^+iYMr+Maaf@2wFL)K5cIC&Nx5GD|5U*>fw@3OhI$n_Z!o+Z5;VO? zRLBJq{VzjiWs+c^@7q~b^bnceR*9Z3l1xweI*N`a!8$X3D$!~eBaC+axb$!4I|k~DlgGqUHzcA zqs(VMm+oBU#b2^Z99EH_w`k2m@az&8lA0H+LckiFl#lPq@$?=$Z!lvt zdd~@Wl7SdyLp&wp19ptjzbbPHSAd1)oOqG_3v(urHXID-xItwUNh|N}c01_`^=v!q zJMrYrl2CG`OnL6Yz`7HZiMQee(b2UYN3yqB2+2-qsD3U0dEF5k%deYm0&nY7R1*P4X3+G2Q{ zUB2-U1tj0|P>1fkUVv5H?^l6y7c;SnU&PZu_0Y?QL?>LQ@zSE#b9xj~_j!Y_!?Wne zOH6@A%kyU;o+-UyT9(d|PT+NNvfSh)FUjO>xvpuTvZYg+;}pTr!wFVt-{#FO#jb}_ z%X2x3&E=e36!C9Zav~B33b^C1faPYyLt_B5H0F?b@D<{&7>b!iJ77K>Z`V8F9v^2r z$9MD6n|Z0d+^~ahCA;}cb>@R@+nkGh(R_wHq!jbT>Nn1a&ft3Kubtx4N0Av-a`Jc_*;FFa8`y@khSdsMeP^~19=Nk^^C;jlW}4x zM#t>z4zW!N8Y5!NW6sD=4gt%mDmBvIq{uy>#-0V__q~>VzUi%l=_ZUAyo_PJ;5XEb zzgzH2MhZ_BW)#82z>$P2i4W%*A6&7f6nUK`mf*@C(h04*Ad&G|QpzFVCU3z)vg|n?tW~Q`|yPbh1k^+-)TlHLmP3bZKswzon$=-*MA?Mu;eyT(Pr} z3N3f<1RsH?05!r>0&VCs94wTsDBOIQXAq1DXlZDpM71-{V-)~^SgXS$=-dc$ML+Ki zP=In8GZsgb6H6UWbh+8L6a<=*7Ze#hT~#m-P!J*pFi>FIE~%-HR0 zixv*%PALBf+Wk4b$z(Rb{szZqS$?kDPR{R4)ea6hcDwC-j@>@iT6Ayt3KKOUO_x<9 z@(6J*>}fSD2BtcVZQcUi&&G4ftsH5upYm`KOC;qYwv|SH_LA*-m;Kd{Yax;yKUMlT)6_F?)$L1h4}jS(I0YJY2wuNU<0vQf@yJFd_jH$kt|; zs4B=LKv2DKp0pRFc`7uOFv?xhGxE_as>D5_BHAO#hAAb!GX@G?8*Ko&C;&T)pF9I(a0Q`H>m5kC8t#zcVA#Fh2zHikE6; z&Qi$Gipm?CP7CTQoHK#7b0KtK)y>9Z7_}&14B2HRO>Ry}#iHP>npuYj2|d1Sb8do% zZ-K54Aj(Qj1wn3t3@s7e(~{#>IfA*Gm${BlP#BS>A1}rDH3lnI&-qe9O;h>kL@+&B zxd192mm0Vnr}w57^VudJy7G?O2vkAHK0>aF z{19)(UGy?3>(=?jG_C1+JpS!C|8jh}Zp6hS4#3*g)1~%LQ`!XL01%h{j*Jy#3(`x{ z_F9_bnFVPy^y4`ryeBBSoKAmQ&%k~=Yb!}IB$QT9fCdnWDIiAqK`b}A|6*xnL?3Z@ zy?W@;f@_`%&BI)R_w`x3Tmrl}Zt5A|bPS|tiboRA2NsfgGI}zF4otOB1L&D;!|4kz zpwsRcgnD?hM!+|ZKYe-Y%Ec}7yDfGOyy{eRF4L|sbQnCo*WngGy@Odidc0tUBebVK zH+hhndAB|arbgifQ3VT16f$F5XR=P>7Q$+^LH8WN&jroWPCXTrdhE&2;&%%^ z8KN}b&UXunDq~6{V<7FYU|s^#JKbwSTcy!sT-XHE%fg^FA#}!(4PFwn;;q^gck?OG z(wzVb-+!@SgXyBTqOX0b8Lud!UUl|hdkM(xvPiGn4HUpud(O_PwnB_}DR%r;g5pl0 z>oP#CrS+ijWv0J=$LSY~*ce@Q-Z_ul?afoKl-~|d33Us2Q0jMh!Xn(noHTPNk6wm5 zeYcuz`?F>qEXm?R(Iu1Y_|AySlxj}Hqe}(X*#&fhr%W5;BeHp_7=P=@XsGNY9}lt~ zam`0UkVd`S88p?0lEEd^3<(vnhvO*+_dupNCpdbl{2<(6?h?UO8gbBbj~CDuS8%Dt z($fo{H56Nv2r0~G5am0p?}OlBV;FI0p^M}PhB4`T41Rl7&oYHa?D1>rWbKG}L&m%U z;g#p=ioz`KoafX{&sdfs8)$(ae;%u|ib#1)HnJ)yu;r zHr8!%_QW;3Y>SW0CD0qW5T$qea*Mt}y-`$$g%O>|?Rrs3qkcAlSdZ~++U3Ls;C{ns z4hScjL!mj)#_;*;Q!^k+x5Zj0h<{mF`CYF%H;>SVM#xKW# zNapxV`?uvwPVyv*3FM8BggtOv4lA|~bkSonl+0jTCNLYoaXBLGmw9nBKZ@{#MTjpF=VplqCf#lG{dcr(kMu$zzeRpXZ&72nL zPOLZL!k(~qQVEHzD-VVkuNsnYFIce_i--P=l2Hvn`r)Le<7}j{$|I4i*%Zs@Uh*R? zVvvd+;hd`^3(~@*Zk6d)WF5e43b?UKeY0aW-5_yFoLT}?GqE^7DuJ#x<`&8m2R8Mv z#M3ii^mI|e%-JJwISq>K%G)FIaFGlt<>mq2KZzg+?1W9T5g3W&Oo$qe^C!;f@-%dS zp+^e{6cw7UweLp>(=lz!jxa6l^l~X;wac~*Z%dtwg=85wMypAh1L_k*h0g90{-{)w1L7QtwtYB<9^DU86cZG3oMQ5>$4OM|BxxyB6>3nM2W@npG z@$8JC?|`+wnICmQFDb!j7(Gc@7>C)&?I2ZNL^u^z>G~Y(<@r;c8c}gJk@d%pjesif z@Ie3KK;m88okaZtA>p~fK~5-e#SPfET_v#)#~YLE01#)vT>}EWojqKTWI|dn8-;_y zCwf>rlN|LVt|zcWh&<`cq}21qprhzg2RFg-CR^(>1wOT|@V;{KktZ&B*s1iy6MMGi zR`JA><`Z25KG0nOXOLMoF<<9QigT4Boscv~dL?yW(y>N8mk?aZea^%DjuV1dl(Z>~ zxzKCr&l3_}FW3zPJi;a=;Kt7yqN%~FIY>G$NS~nm%V~Sp7oA=Pb3hN5v%5K`6ZUS2 z2is?CQ=AAEjzb(hKRRNs?9eS|(InF~n2#Ki1#msZC?5c}E5R+1qd00;>tl#_H?xQV zUY69km%?)M7`^bM+%g=f$G;ZaWbSM(X!lwuz_FrDaH%vNz6TD%!=aX}pYpTd%Nu7MUH5_On}VUkbj52`)#uvX>B8dKI8FD>MQ2+iKnq zji(t1HvIJVojhDpu9V_2&adbnHs^W8kF+l{|Jx!EX?D-lv;0aN5^N$lL zdM&bL42tB3kl75feC(F=`D98CjmpDTBgfQwpl-JDr0manQSJh(@FpFfcs>QL0o&o= zhSfVl@;y1Ma(9KPaRfEsKGM~Ye5ZoI=WL$EENk>u!$MKHhyF5e!$V*WFA#$o3+^JG ztP9Cp;U{{J%;)qNlnl8B!Uh_a9x@O+ZB`s^LyA8Z8<_8=oaW{@3b#p3qnh5*|I!U_dCnQkg0;_<;Mr@!!V+SPcoZyjP+fdTqWg=EXDox<{$Lpo zRIAtFoI6(QB1cR#zvB8U3H-9DBuJwk?>l`mqt#mwsV*?+fb%&x(keUas^I+7$w947 z_RvGa60S4&NT;QNhl*y!QpD9$!wp=i^%@(`h;hgv#Xrxdy|~XyQ3+Zt<1$%rUJy~D zUUvzCEuYp%tfyDbUA4wvG5iKd%UjxB?pufjmp2GitP-064cJo*v@>1p7ZY<nwNf(tS^w520cHxQE!f+x~2E%w{pI^1%+d!@-0; zJA+i(JmF@I(RsZ$DG1`$un)MqNfI|@Cluv~J1yzw&=u6i*p@O05WOJXV~?wH;w7mS zaA&vp;qvNLEq8W`9xRkwUK}ud!&8O+K2;7GPN#Mo49)e92=o{D;2lx2qxvDXJJNQ@ zLl`3<-C394aF|SfN(y!?nYXe;Fwz><4UTeK ze}W#FxBuUVneJZ8UoT#hb|+pVFJ)LMKaSQLoPwsBYc@aiG+Hko zp#{~3-i+>Hv{E{F3+jaP7gh<+qBVMlbwR~N8CF}A(MkVY=LWK)!>ZH$!UhrZGo_0RMcC9;iyY^T6*=Q4FZ^r+rlU(|{`f5FQwdEgvAt zZ-qxnrHKIEqX+4pJf-esNCsh~0%dKH^zq1KN<9T4{~6*p9uGJpu?L(_fVw@i6z1L@ z9NF+|C^BM+M0kkAznop-2cf5m-ZM$9ar>~ufJrv7mO=WJw)WF&9pMbGw`-jLrK*~d z`atvtjB??WVLCAva|`=QSlTgi7T{}jb6_T{5d;OI?Q{4Rv9_3ZVmr84;rO=EiNCOB z?y(l<0^d$fZ%o#BN;61s9mI~&_)*KB6=oB^X@ywgrrBfBayOf7E8^-uh4kc8m`~H) z$Xqt??dHk^HI3PYF87FdT5`SI3^)W_nhIA}Im?SaWrYmDXJUIq3!1!&D^+Vo*97k`l5z6 zcLr*PBDcnt#6VT7+93Id8}@KW^S&4261^!iHF$?R^^wLB@AI>!ybeb;1U~Xysp|9asHk%DJ#$NKZjlJ2cY` zwEi&zWi7QS095vLsIj@_kvtk65>?|?zVWE+;~S6GHthMDakWL5Z8B7f$w~Ig0e6wh z=cD~%QjTyr1HGWRE_Tc}G7rdHJ!{SeyUT-p3NwX1axK(n(sk7CCxP{_i-Pd(MO=J z==Qz2cD<>yFdhu3q&Q{TM!JszlwFf+$*rVqZd>Z+BcLEXah`CT z8b|vttAYw{S}&+`pPMs>#W*u!i_9MVGBlxS%G@!S69+NxckG>aDbwA>dUe;ONg zX1z1Lwk~cQ=0f7f8|Lwbdi>U5(eIbj&G7F|G8>ERNOGTY{}jh`->$k~A-o`G2-I%D zOai}R&0~#{uEdU0TsNt9c6>%dyMFP-4OE(vW^|K_pn@hyMqs4m$=2LabcW^+gFO9{_rE?LvgCVIzfPudJ;@wC)VLb2_r$(f;U zRYcaa2KuqY_VO@3EN;g&5oQ{<*VSTJ82K5uhIccEd)Bk2gW+sfat70Y@Ia`HrvbnQ zTrmy!8Aw~riaUrgK}%a=+<`V-p)>H`OC7R1I}46XJA6*I(ctN4I6j;Fn}cI)MioRj z^9UvB*;)#8uWGkjI@49-B#rVztFDB9n+pKx_O%YVo;1$MdCFImSvwJs#7PFcTuvT% z%3j4(@KQ}xrXBCZ4crLq<;b}|C5-FlK#s+i&U)>de#cl391ndb4rgdEi};)KEnD{w zbp(R5O9Z{^%;^L68WWOGFOJi&6+5;haH1|cbEzJ7`BXMC> zcz=%=QV;c|W*be3M0xcX={%cEi{8u}4pO~K<{#G)$50Tj4mx?!#9NokiiY9bE^^8o zn_35F-1wtD+VtTH0PJPFfxbe16l@3!>;m(U?>?VIrBqsl?4t3fdO@_4aJZ^!b&6JqdsC-_KO|BoiyJd zV}VCHTzCrDg7mC|+z`oH>ACdBo3C4ALF=m!61AuqdI6KFLrIqAR&Nrwdh5(85KhBJ zzSZ1+)!rtp9nA_*ut;ZJ)@>#F9b-0l7x&Ee$w+rdiw?GQH$i=ufz0l-MGLD|jZ|1F=7M}7Eg?z15+Ze)_xLegKP0;`gYHd%2$OHgQL|_cy9Al`SAT06`_z;m; zU6)LO)L12Fe=}i!ZqcEPmF3jT>a@4#X+r(zH-Pt;RS2%7FGr3JEG)9R6iQoJx?Ps$ zn2p*xbLj+P)^?P09%Na|`<2xr3#iH^%)mxCJkcJbzos?}3apctLb8)cjv!^Du zGa7A4T};+K*~o;?-)R$tfPz2L*76(dijjhf{hSbXU9vo-c}LfsiRc##Ye}-=QZ?j~`W;C=;GPQ1<7G-c3In_sE_0o;+EAEK1rJ`1SrythB&>Giw zk{w_~j#MMR)7HKrCHouoHI3%5-CtLe6@>WgZ`jq7BU6m_%bSvnOXoqeCKEY|i@R^6 z0M&UAz+0?ULhi0UfJa4a03@f-hKQeDBkp|pZmVxS(SF;qKbu?zYqn*~_SnuHC$V_2 zl{eTb9BhZB{@R$Y9&^lU^;81IJ2DfU*i1NPO1T68Rn(k#nX&!GE1^8wSatg5 z6}!Z4mT9;#;g8%A96=Aj(Lg1jmdJ$j#s~HEIoHLu>Vsih^K+fvqNvc8}5u@kRRIxT9* zMS@Bdu{czo#eu1ueX?+0__&L1_E;Kgz1wBtWgAyb8;9$=zn%N~Cy5r#|!vY#< z(;n>5r@juL0+B&;tqY>fVUx$C*hSEZTQGUVk&NyTVVsse6p{Q+Td3XuOF*>00teuj zD*!s$EB4ECy(2kVqXYSgvjnU&vy^AzwB}r60XisE5vyDLPS($sg(dPd*$x6ClGy6} zh|@@^Sh#>vY-5ON>C`-=IYZ^jpex>+x#k1J+#xxgH&9+ad4Gr8G$FY&p1^I4cFVTS zc4A_)Mnd->hn(f<2^#Tv9_k5n6Uz(S(X;WGCT~z45F%RMHe1tl5EN9EtB)&r$W~G- zwB8Y0zBy&nJz@~#yU(tF2P<{*v>idZz83Rf;N?Ya3E2w!W?CUPH)uvWkYeH>hZ_>N zw_Sz&a9oZs`YHp*(3-=N@>gPaCDRQ$>7=fZ?}InCfW^Advk~HaWR)2^lR3lrlN15A8nY2x+?lBqWDv=O1_R=HL8W&G zL=1%_;t@7>1d$UL5HCAh0qye6tS89Xbj9f0Y&MlyaOdq#uVYKI}GP=?()lhnqn z3n-Oz&x&Y~xaY5R5Qb%BruhyI5|Uj@q})Lb1S1BE;R49RxU4E5X;xKGGG3QL|H_jU z);|@Z09XNKhL|?sigVtQDmie+eyFM9ihb-&ynD=&S?#&LJ=|02XuUYH6Yepr48IbT zWO=z@9cH7kO43Ka(iUP8fTacg^UU=Hz9*7CFSH`@bzJj#hFCN+p>%C|s!BaZp3jh$LG-OB4%BIFXvHp zlZTFk##+h1@hHNsI@bRg#lX<50_cQtQlPg;g(Y_tbK6pC%svY>5`4OQ+7V&%L*-Cu zcGY?ZK&?Ibgmu{B-?!mD@LfWc!xqdLZ)6ZFPIuRr z+{cHWTKCZDbqxczv@?FyWKON?j6H*@-fv=T0{sHPXOPO!@X7r_KJjhthk;gho-(=S zaw-Zv>n|Af^0e)q5A?_p8E1hCIqYqqL+&K*eyR1zc}j{A(X!_ZyN#YfosR%TbWK1z zd>J&+(G4+Q70r`Cs-9rJRg^cxMs4`9Q5!4gE|e29Y{>fYxC&y8gh+AlDMXh{@KP39Xa+mFZb=xoku^11u%10ad|96ss(i8>o3i6v+<0 zF8zdQuT$p81<8yWM`)XczV&5K3Gx zF&U?g0TJR=HTAe2Mr2b)a_^}(PGf$gauO!3B5WUDS8Y^YxJtsn5O1y{wb;Zm5cTCD zZH45xaX`0e8B`~S_F&{l@#btT_Bn8BMzzf;!ctsv4wM@Y&(bhM9}Ch;F4rZ3# z+hU|e@Euh3{uTFhPF#hqKyZZfzU|{tKDEt{Ks7M1(tNDxtOu|IDOgK65D98Yypcjv zv~9s*k2Ey45{4S#7W?W7sJFL=&<-5wCnU1wd(SOGtmrs*aF7bXdWmgyFv-UCO$AT? zK<`v#*1#F2X{~~JLZl45amX)C!hi@}Q?3C==scqadRXPmu_vJ^$Zji-4t4#*1dgW> zLKyi_2`X|^T1#;lMc0W2%q_j5M>^?j@c1}R5X>3Sk&Cbc!ft!SPmpe9h1gWF?dW6# zg&^p%;<4fw=1kCt)<+rO)Kef=_h?I{p8BI#|Z)_!j=c19S*wy8SccP z0w4S!o)1%OzW(iVDrU%Lf9 z*AXtN>Ue0MKFX-Z?_|>$*Qu=8e*P&9(G&RWIpLfXc!YAhL>o&WvZ6kI2~bwns`^;L zKIX*2c?ornD6+H1bMc&Iny1|xPn>`J;@rX8l8@Jl$wmmqNkNHi?F?W(f9m{&&piKV zy)8M%&|1=>yTLFNTsQ79!>bx@34N|X)-@z-otJ0SFIF5>-!_?fVm$tSvm&TI! zHl*+**DVWv9q5U@(-2%Y{8Vpr3i~is^>Y$R^T0Qdd#`sn?>VXr?~a0Yx!NiInezN# z==|d5=|l8=^cZuqj-Kk<#PE;eieTh}J}1k-FBt&CLTlND<1ivFPh}z7)5Kz52VH)4 zmSZD+_r{YPzODD~l9fc9t0>tOV6-h#1T*{+a{SJ&AyyjflfKiU{i^b8f@*KlEFuIZ zewkYD+GLzTlJ05gptd4gWUMgC^fQksLB;@lz!9xBD+VOv1)X4C_SX8*i*=;8OivQK z6EbpVH+Rr#Fn4wz{{mIDiVa;89iF|T zv6&iJ+e$EGDXJLr)ezj7>3dtrko1WHZ;o7dVPopD+h1P|?zMkQZTDz9F%~M76nCIj@Z%-(E#MR?*q`Fm0 zIN(WHPCcA(|1$EY6LonsMrZ!>nTBFYvqs$r$b=eYc;lNX+yMrvL&@XIo18VMAUFg8 zy0q&f{jX-*)K{<>rht8yA7ET)}dXfw+ogH08k6Do)R zb7-=*=_b@7@k`c+Gh1 zY{MY5xj^!-Av}CnXP@XS5!20#(mQYxQDC?W(N*Nu= zocdhRyr~e}0jo$&7sVg33e_FUGzB zlS}>b0I@Bb8{G7~iM$LzKul|_ZHMoCc8IH^wP;`r?WhyDRaSLQx|_7FmYsN2WQZX+ zcT$Q?%4yj%JE)#d#3g9csKEB2n!I+~(_o;c!8EW+IV6-RerjEQ5wROp_?4%egQ4=i zBn0+u^7IIyjgPstkTbJbP7EuGcLd35NJ?2zpE#Vd*|cPUYRc<~)`ffoeswnLGDsDs z!5c4-&&V>196FD2X}zTPywiKwkPfzPug=Dlroq34wU4I_ zi}&>Z%U!JDy&7DrhBr%?<38S%YJCZ!-QfMiwU9ZGrT5KEk=unASvaatN}swQ4(zSV z0*ig8MASK?S*3)_m{cnt!WL!N5MP^J<>sO&2S^+q5oNS|5avT!y!I$b3YH;Mh3>uP z&LQl`VK%vG;X1exXMhgil$1|q^oDnmS|1!7v??Q6Ap<0!IP-AJ$%?rm05>4BZo~KK z<$!b8-Xu<2Wa8B*BU=k_`u_Xc1m%KNupzbo>xqeyZ4#W(3N%szP+btRG2M@qs)RR%9sfU31MN)b2n~y5yxb$p=4(a=^i(`YaAHB4xyb>jLc1B zQBSMH1!u&7FI5gS6&Qw^(KvX^LOZ?Z+HlHuZ8!y~rf^Vmy^odB)%rIGT)y*5z`apV z*JEadDFX=N;{AYb89hp-Guvk5iVkPNf#^RlaZP)aJPpMYTock$yXY~DW_2o1$iZl8 zCG}9|QkZdYNJ7CBQwHco=QhZ)gi&-3Iw}JO*e0YK<-3?=CY4-C0pOMG*S6W52Znd3 zI&O^>TA>SxnpGU;n9b>Oy6WN*oepekFU;pMFDX#y-R&n+@q_$oP$S5ZqnV+Kog-ed z#DOT!IXr^CT&jY8NSuvPGPRlN^G>SK!j!V!%iBtB)vM*CpmbN&^r)_<)y;Jw$v_LN zH$pU$AQCAPDo~xlvbNw{*A!KI5NQaH%;mUz6c=u<5kV6$s2G&CukGCQp=%(_|gysEeWJ;eXr#TVMaLfeeIkhrSVT1(W z-w6+}Hz}*ii3p1V^l3q0{(?2a)UCGy3G`e(DN|$;m@Yu5t#(}GO?yC?=NMULk!8@6 zBZenrG405E!4e2bxYn>ksAh|$??smCM5izNjQ3~5aWLcXh)`_N_`ASaITq)ZrQ5{_ z=%0RFzX2aWMFqd_h&L$*KPpaXlB<>EYT@v3cSVQXYbs`P!uGXD@HeL>H zf&-ZiwGCsNLEjBDPA*b}>MSsj)T~@Ficz4;R^jAsQ@nt|UqzTNtj-?kktWOBgTN7h zOnw>F*m`A6b3!=kLu;(7lM3+X>b|*gY!_y1UyW|dBz=t zAdeEvoz)KrHiGn|q{dSxMr&W`aTjVtk_Z9D9 zt3ioeIEhQ(Nq4ym&ZF4{c=b9kuc!(wHKUGmB559zFl{A)0b3K%giH}SNEPAgT%zl2 z2se)*J{Igb&}3KC5b6yDa7#FN8*$FwaQ7i*Wnt!oY1uu2P(BELUk-kcg5P7ya5?W% zQDNCD)T%uba@?doi8Yfw)2WA2@3S5o=06izkhe*IqJbLhYF1dmeH*5FCr1NH)=xk> z5hWL?1#N8jnM4tCNVUSOu;91!%Nf-9?93cmhC2jV!+#7;sgRP{{3|zGtPg=Xz#j1j z(0pYCo;`AOcMT?l<1t~McC-013}As%${h(A`Y8t+c#0qIEVWMD{p^WOdctSGR;a5h zNQB=rLN{9I@`-i`xymW+RX6?2)GL0)@8O!?!&OruTmMR;vvF^^Z5g>M)Hwv=Y21tyE<$_LPnH{mefD|cu2t^lqwpFsj< zZ5_1f_cHLxIJ9!o=jn`2S|`DJ(Fx|tuH^)Mhs zX_RPGfAag{U=*JSP0b`d|Du{OsNgKlmzm)5tUp~hJL!IW##(nD+}l2j|Mg~WdhOCY^Px+gPQ${6XVW~=C$odr4UmmSa}+a9!V3fvE33ouI+4U`YoZ4WV-2^> z)tY#g6|u7r3L7oI%Q>lH3CEUQNu0e_@n9W`Q<{1n1R{~b960*zU^F^G4g>4KT}R7A z*`S!t=pGwp{XF9SY5U2xGwvLlfhsE;k-~ciBRlL2aP*)^8Co2?+bZtO-l=%=5a-}N zIFo=q-`eYnQKVZUu>~L<>J|^e1Na{WJ~Q^3Mmu2(zphk;kD)+k!9-bB+lzmd7Nw6}rVRcTxEq!J)aX z)iu}BEYynJ^ze_n*VDV#SC}VSU485BbTd6X%f&U{MW0f+<=QY!;9qO$-D~C_>x&y% zx_ZY2%2@8M?r~$nTAq*_qlYU)_fB24hv^evA)`S?YIuAjiKr>|bTg3Y`|S}d#X zuGvbX{rV88hWp^}`zEE?MbpyO#J}hF;ncmSp;5-+Gr!)#ZFg7Ocf-H!p>0)dVc0Zs zpU(8uQY8!W1SYM-C4VJ*&)VABb`Sm=tLOA`JS_s=h66?r+~W^f8!nt#L$0?3L3R<2 zf)IHtc0cNq)5`(9>_Vz9cDPeYVVHzLzB5hDPNlD`Z4q74NI7{xsa4XjDIkI5fmn$P zqJ%@^)?DQG%M%lm&TGQC7)X{hivUN5b=WN9w`m_KN4clx=E^oVpa zt96^QlEu&aoPI}pl5%wmvm8+4b%|O8YIbj!@7>_!o|-I;T}{N6XZMc0Wza%Fq%+jD zkWhJXGq4Ft>PklIiBQ`*_F!nd*hro`!+9f^6RFm%6@PVIoTdw9-^jcPCj#HDCBzd& zb{fv7na=gjGwpx|U@k=r1+D8Lw11njwz~Oz`H+1m!Oqc^$*MP*?#X^TJ5{L*RJ1l z@9L-VuF=5%zKfLC6ym{j4P$9K=ekHcm}@#i$%ixWdTy&s0VM3Z`HIzXcji?Re9Rj$ z{$+38mlDObsQLc9O8Q1>o;G|qnA`90D8=g-&#Pk$vdWAu%SEH8=2cXUjYPb#irKs> zYAkKMj)Qr1WP`CG44emaQEv|C)wE~icu5N}Z;763s>I*zNB{$WsI_>F?qK*^KXyVf z@m)DujgNb&)7Q1ZUu+H_lRoE`W7RDwU;Lv_F&@z!l(sO1D_X%25yyPl7I)4ufaCN< zv3|l=be>31S5v2rL?g(c&U|v5U|fTt89IuCyRN6OHXA?~Q;$QKjrbCQyDD&_QPpB{ zbd2`!h_!Gq+A@%EAchN$?dvZj2@+PuVL3b{t1=~Y8)9!Q+>6YY+73+qLH~zf{?HjT zAvm}7M4>y?hZMVVgHmciOv#~HlKoslXvBcX%W(I>4I6CQvTmo>ZrpuvJ$5LH*j=>I2sutK_Y3*_+zKt644h=I+7WtIK?cZ6h~W=Ui;J!Uc1E*XmAm>&OJu zlI#???&KaP>l+4ADZgvp_u%q>Gq>}ctv+W*;^sM9z58x?oS;?92$7I870vh2gY(|y zPY#AlN#-0rgV?si@q`Lx$< zGdJ&f-PV*Eb4O^YMcje??yHfV1mghGT)P?7mT-(KQUdBqhb~ic=?D&Fx;rUn<0|nZ zKtnz@$norGo!uL5#{iXJ=ua={NE)ypU5QmWC46vtX_^m1W>@q!g?UGdPc%`ppNYl# z2$)o7Go`!9T>jM=RFR5EX#~KXsXR#4>p6L%FwUDC>XdhO!zC1@Et0Um6ZUudn&^I0Hpm zwg>Kl6%({OIOI>8yAjuYlawddH6MgVdpX5_G@8pdDIN^w!ks~-7xLmGnylyKI;c$N z(Y|dX<8tKpuEycwoo)WX8Q9T(^q@3XGi0gnsR*qq)^#!aN*2utWqDxxx^1O{JemLI zh%YnffC{6U+cV4-pAFz*=*JV4qsIW;>;-BYP?PigSMMhKn75zS4e-`Fi4f%aU3ge!BwsAzX(D!a$Ln zGCy!XnR^CKVdb*{;Vsi}!8i%Xi~H8s4+toYZcp3!ZbA4&p6e62IWc4?5&$Znc;#7J zig`oCA<{PWmar)fG+d$)9g-MUKV?=xf)LGRSs$DEzSaxj{Un7e^MI_hi*fUI2`;eB zL9c;}TsV@LA53avc~i3#gR&xxlv-tsMmw@X3Tei;em*T2OUe-`HvLe?*G*UP38F;0 z^rbb$ph=$aXj-Z{I-G6Fvpz$Yml>!WFX->c!vL7oo?#sE>=4~6CUj1{4IF^^jXXaR zHZiucds^N0-3P6^t9#mQm!N@)PAs2k<8(PPL@bo*YnPFrN_c>oKF#9E(_&O&k{>9= z0*;FfHWc@-t`ytoim!ZIA?F(=@f2pFD%$8If`5!739B)EwiSh)I5{WJ@YI@mWkgh; zBQ&zsiDrX&25q=*OFU)T5!l58Leo8pE?GOvT5h(9+fID5^Ufg4va!pDLB28q$OyNU z^zlr3l7?*NivDrhgR#JtC1)_7EZ3DLCOFl->vyWZkrDxXJ9yR*>!?IDb|{d znBG+IGtN{E=DaE&>&WGZaqm$Iz>>kz#SW`tvr!U-WV$+${H@N7U3K7EalP9$ZFal- z^WOFA&1sZW!6oCD%@@kZ=T1I*rh2i=(WvKi-BF=>!TA{{T~_RRwY!LJ4x1wzh4woy zK2rC0QEFFg&m4z*5-c-4vkA$s86wuXPLtIXihBt^sbp2TkDmX!1}|V&gR*kuBdwpg zPEzd^J5y4XFzaEr4Y=6>3@GaJVdP)72B+ znsyG`ik{+xhT$}pox>~ukpvD)t@%NhEbK+w=v_?<$me9#YYS@E$l_k5lsj0;E&`f@ zXp^G@cL!yPVzi3hxh(sJ8{wM8-f%ijdNI0ws}rj(4(PwWJ1|h%`e(a<+%RhvdsG0s z=#SFR_6qUmWFT|QJ}_)%*U|k%o>~wglC*4U5gJEHAdan!vPGM}>_j_u6_UWZ7;0FY zcJt_xRM~Lni`&ru%(n`u>%3k7pn@6YOLv_?q=p zREnjh@M1KE?0{K-b!lNB^$_6GEE50iFx5kaf;bE_7R*cN1R#6acBQ|C-)ZY`nLEmq zEC;h`EhEw4a@2xa>y<(C=E1VB$LPisHaJ`CZoelRwXSTKzI4)~Tkp<&N3jld5=iDa6Tn$QKsO(4n>*PB zjkpXIAfg*G(4S<^b|-nITY{TKDZeWf-Hr+bPVYzkvArRz3}BzS?ImW%(DH#dIq+b~ zb*hFC;Z#ipv51&G7CykpE*kjbAE)p%Eq|Dr50dYAdCXm8s@)5Fw6|oJ_KwWevRw{} z=3~B07y9|G*8}r=*#m|4op3%ZD2L1gx#bxVav=%{wx1u4z5bZrOZLa{nZN|)Z?9%! z=okFO+SSFa?+nUv;2ar!q27Y?5+F>(A!-6`57I+&pqG9w!e1oR9yaCLLFy5bGvWx*QRr4Y49 z)2%#opCznOBZnkt^4ePWGz5#0r)Nt9NflCes9J@0OP&6`nM*clA2iI?mfPI;{;{VY zy?Emt=PeRU!Wpd^sUN60o(}rq>f)2MH8f1M>8L`^8L_^Kz>uX^b*4LKo#J0I|S54{L?8GoT^txbv zBYik-8eQEr2{z^IF2j;j;n>*Wr8*X{jzi=eZ?j{?=nizO?C$4C9lD8dEhrv9xQj)kWn7a_>p(> zw%*NnsmOW?XsWY~%RIc-a-5hUWH_Ep8BmXC)iTWIB=c`d^ZU+lG|a`c6?e1DWSV=V zUk-yV!K1WwZAj1_jmo@Q!h)#i44FvsWL)L5e!0qZqru9@?V%39dl?(c)Hd@0iQX5? zdOcC5yR!@gh#X`Da$9EDO0XXS3XhLteip zxkd7bUBn%}g}Z55Yr#Q0`FFZa+3Kd=srUpV)9;0_4fP(Zchcc?ZLQZGP?VvWuNf`f zt#ERZ=57sP8!dglsk$o9!;>P9=Ny=;dBiS2=Vt|LOe7$+VMCrth$(@>7MCfNXXMC& z;w{hQG6M?L6U%ESUJ|*^RJs@T=N9C;TbJspXPuVWK3H}}%t}l++hC;erAhf3*q&~e zn1>3V<@G&tbUnAVwx-^_uuHeFwvF8jRIU&BD%S^A&RrUffs`70^5kp^|9r#(r`GhY zd3x!-C+pq}3u@%k(T`AKygb}B-BXlm%XD>vjh!QY(>53YMHgikjMA=t z{HYpI7fVpH_zjHGc_YfemD611ed~i3RHKa;+C*lDN>oEOq8W|hs306lQtyNVw&}_W zNaZwh&U-$F8V3Dy@g{)@^7Op&R7)4eV(0bF=9W&Q^s_XbWZ5_MQ_?`8jlYI5J z)Fq^Vs!K#a7tCgaPqs;n5P}@2geXLYatOfyF$JthBNgXuBEpz!19*Qj9thu8r{)pf zm>Z=pF~uEcP{c~ftHKpHPSvmhoD~GC)=o*{6B(;Y+=r~)1J6g8s&JAOvXSsTAf}6B!_BZGwyp*(0jakO*M^CA zv1f^;A9BQ7?K6HQiqnE+qv@#}b@ApWw(~DBwjgeNoo~{4^t zIYCHsg4%b1^JE|k!K2^^)RoDK1km#dHv7;mUVD>5M5Ocqmj)DanvkGC#s#u5#z{s> zOz!0(vvEJ;N;-szFv<6e(u~x)FxHd(ydU;r`6|o~t!m$A_xio`s%h>;#}F16 zI77lyc215f^FvN>vvZpgVmo)iY{)qJ%GgMBL8R3oEhgoct>n0fEbt~NQF8$BK#KTAH+WQ?_Wdtkf6ywI_TeGlDCM}y*L~lUr-e@R+8Wq6DsQ5rC zZqA5HTQ_wQ0}PuT&};(Sq$D|U*;Gqrg1XF51--%aAx4M4`^YW&ZPT`%}!9@Jb7RG9q+rv&EmTtKx&3pI)F|9Rm zS!X>$#Th|s)fryeoC&F9#EA^b?q-v1P)2Z00l1~NF6OLG5N6+z|6Foz#a0!YOU z$P2{+zccn2k)2qnaa>*>9~fxmp3G}%YNL8kA|+4-)c#C8ZIigwcatYap3Wf+)Kh-U zT-f-a*0`O(v{l_K#$%1D1pqqcOR*OX*>Y2ZIHFzXIy1+S8fQd5q8sKs^ zwoIu*sCOH3$&Ovxu`5LWbgZd?_ROx`t08WVf>23+$A{I2U<>mphuNk#J<0(OjHCpF zsFz;{d86Ffsqz>?voe`Oe|Ph#A|A3uI>|84DvT?)RJ{haK>80RDK=<}Xp8mOq<&cM z4%Awpe_7&XYN@epG!!dzWCGJtg*pmTI}7aFs5h!ySJu*2w9}#D!W@vGitxw;ADE>J zK2VFf8OZiZmCFW-PADnE@`a8T)LC%MYFZhP+>fRj-8wqjF6Fq;7a7=Ys)kgborD*O zmqX!~T5WTHmKBYX^A=DEd@$MWW*YU?C;nb35Zxr?BAgb}ZhWW4jOf@CfA;KUfssY1 z5xgKlg&COMQEit2=G1U#xO&4I4vuPf*v@Pqw;23Ww@|AO2uePIJ1Fnt z{q5L2`YgqhWoiN52j79-MeOARA%vdE&9aU`tn@rHpIU`>yEY`un@B^#o47tC(@lD4 z#zA1R(eDSofi~`R+q+TRHb69X3Nhu9B*6j{A@wwpj=sB)CrPP0HEs zUd+M81zD9^zMJbPP*&g=(7Wlrq~A+P)3^l>i=mfdomC56jLue^)!mt2`bi^ z6JizHf{kl>1nN80LDc58uCah&=r`2d?8;lqeL%WHoIjNq6l=x1%hc9MT+ZYMxzgj~ zynPZR-QuliYPGI7k_SUfD;!~K9;L16hN0T)OGS#gbbEZAkQ@lrFl7}CA6!KBe8agRjMAr` zyn5+fo%Ef>sBgq;5-5<>Bc6f{$4rK822!yL2Q?z*CE;#nEZ6jIjoE=XTXJ0wObYi=gsHA}T=cS=wk7B+m;xJixhfR-qeK z$AR02zK}kuhi*BNVn-?;l_LQW%BXEDZ4INao>;)TdM>jT#nfAfVv4IU$A*2u9PW99 z0qU@FKe^wH-1Q`b?mMkDtQ*M`Q@Y*pFk9AWp6)@_W3M$*y)5GhXY&-Q8K4JgYd@Qy zchnN+(*qb1i@m9&n3N;raZFu>a!BT??f7dda;lWS2?6OBjmQUavJadSRMU_i&IkEa z`IG^Z*e?K|p)@?Wz3hqggNnMz!~7ZqIFVjR8A=C;P0BBkVrtPmz)x=;&;_hj4*KMM zYGmU1OAK$T$Xt-8DpyRkDZ)X|xpGHvUj7-V@+sYWY7*?Tw8eh|?2|coyJldE6+r%d zs`fk`RceM_de(9;XZI1MNTOnrnN0c++Ul8X)F*;yt9*uGK8PVC%;$?qu^J z=oY6ndhLlJ7d*zcxpDeZV4GA5v8dCznkEmaR~S>~d7R_t2>oH=OAzps5^+d$Q5Jde z>5NFM=H^AoYM~q-il3y7Z05R2-1k^%p(Q@2T{G1v6hpSzG43o-dvsGIkxyVdoWvKC z@j5CL)rnCgG+B%=uRkMo5d0Bw78?Xe*9PT6MEMd^E_kM7n_=8C z(l%i@*l?@dB7v){ct;>36R&t2j@`3)B5b@C91Bivxe7-|*BR&oJ#sRa6X34cA>JRyU3(9^z(9DB_RDH6#T|IXFW&`n-Slb2Devpgia% zkDCPq-y|R-<}ZX{^`Qcj{h}P8siMR@sMTyZ<~T=$wuWhhotU)p?ryh3+e^fNO7f1E z3cfONmwbjok67_db%;t>PAF6Z60D=6&Cu{OQ>xE>tFRZP4{bTlj9m}og(zxMIYbbu zSVAKqV@~hBy?r5(SpX5Pb{K31S>;55CweCqS5^)y{?PQ6ZzI1Q94C8tvy&KFAhSND z-_p#afBAbU=o0#dz2|LZb?Xylsqrr2y@`U-j8Y;TO1C~bdNe1zZ$t@LM=p!mK1ZTh zxeV60lT2o0o<>WQPIN3qz!wTFN>AfqB>aw)l@OImdPQB@u?8Aq$gqkYb_8huG~FGP z+mP4Vd`COf?$}O38w;8)tjQ|P;U6%sDm#hXY$^CGohJ_?WtYGk0-c}AN#9ETBdZ*x zc&R)HopXS@Vv5JxQPL#C*(3!IdP>nmJ3mxABTm_%mdcqia=Zrz`62tMjtui{b~Y>v z`0|gATz_Pck`jajN-oH*39shrre1(Kr@ci(eXMf2y;NP(2-D;=#LsHr1J=_NANj+N+_tARN2my+Yn8 zX=Nm4FbnLngEX`%HeP<%$Qmv)i^XWCtj!`kw6oZ`?&Oqf9dzPc!tSRmHc;Dy4VHBC zxEqD8Z#dt;9;TWL;O#m%LUH0q7qdQ%S)dSOO9t2Al!BCLixV?xsh6o&1}Dng^YIF- zAcmQ5r&;f2;$yDkJe^6f3Q|$7*#z~x+_p(Zg5z1XvMHuJZExy2)@{xv4?UWtu2?mj zi6U#48m2>w1|EW*uli@2@3LcP!%xurxVKw9&kL0x0J1Zk23TpkP3qp&jL>$#c8-+6HVQJ=?cMO$P0^@>CjLpum zxcEub293#Ut)H1%{=_AX@u@ggD!Uhd#HjYNL>uqz8r7!TT#;?0B^|oum$PrxR8TT! zp2@*y8xkh+kcvVn`U2W%n+QlP{yQj(Bo=Z}SiPA=JOIU~-#liuz}A^+D&DS>kUN_7 z4P&C_*U)XpRiQOq=Y)+T^nGG`5SS{kGYsTUUYxT`LA6{T0%Mu-v=>nDo2{i^-Lnf zNHdyA3*%Yf7MPTpgSWa2;Qw(QLz5p){X+06I|Ww$tWA!6gF%Ca(O3$K(|+VJ0L;K* zH9|OIaVR#-hvThnb;}NClJ6GgYCEcpMqVsdFOklkOGne{oODTbPI5|}W&1Z9BcZ5u zkDsS4SjSE}8{bKC#Ff|S&}`g9glgAkgEgd?1jvYDXMd^Ls$z0fW#uT`OPzFXmLO{- z3&g6q8`JlwV@;{bnbQrxs=bew9a*ESqOT|T-9hPyQo$Hnz1Seg0cQ3#!2o4b5ksGO zs2HYZt;$vWt%&rqQOFpom^ zP;>-V3Eqmy`O)T_W)Rht5z*e$9kqd9<>XGXmdsV^0r-tdux3gYw7u(00{#;{dGYo3R&Axm%3!gn# zZ%sqoP0rVxP`N>wZU==$fM9t)iDj!tEt@nHtJXXFd}U5^WDCXCh(*BfmEA9Nl}SsP z8P_}h7Jvacj@o|XyQHHt!1_5aVcz{K=ioNF3NBNt*`OTdJgMvF#A*w?)$Sf%TEMJq z=YUd@!;U8OU7&i0(|m-Qx`82PGc$SUy^CI-oGBXttk8j%RRwH8$0&LU{I`sNils*uhE{W%wZsh zrSzI%daLW#6)eh@)g2>DMO1)UC5V1-N+(}^EgGtGLPN$E)7Q)wCQl)GVHR zn&;?;@i}GBG==|6d)DHO$6E+xE{gE7rGW3|lAYSthPl#Gc`#+21R@?d(x;dP1z~#; z_)cawgvw~MR9KJd%67g-kVlp4X1cnc+O>Cby*)Y%C|sYpHpy5Lc+6b0SF^n{rz-RT zCh#G0V6m3P(UIr%=^yDHVUlrNd)$Rz-*T6qK7ZrV6PLE+dXwMk-a>m1ij5SjX$6Q+ zhglb&e0`og%buE2yS1i!g7;91RctCQcN?3aoTH8+APlI5B%Cw)vdJtsw%x#zgx(f!3@tvFU3Etb8HOO z6SFwm!Y%9D!#Z+_QaZt*dI-D$K6W#Ol*v2L_RSMl4I8D-Me8w_tN1OUXETQAfX|ev zCVe;fcG3^jQf(`YbF1d(-D=hQfX>7{qwYkG8e^VOa#|Nn&cL+n$3n12l(U&Ub~yT1 zTd&Q>9%so{55YSFRRBM7;9`hhU1N+W-P%MR3mH_P zLifT$i}ho?gtMkr?PRxv_D1i*u9Su)cQ+q8o$-G&{IPS?}vhT5ZHCukBZ z0an{6>uTl$_ifLxywltoF};S(M5Jfa=hJJe8`sT0R?NpM9rJ4)f0+)gbf}>GxweLH zu$#4a^wo47s-XI&8!PFHY9PTOsC9o^b>G_+POC>Q_OgRqitmnkxZxf)0WBn%0!`RV z2q%pAMRAcrcWt*-Eca%pGt8T^B=d3acDr)m72tZvYG9-^XsZZf0qGfdJ3>4ZWlM-( z7Y7*=cGBn37od{bh9Hk>MsY4qIm)EKkB#T!7{6d{Jay&C$DgwI3;)zgOm^MS!M#(8 z8&olz!em2x(h0`X9UOHebYz*HYy@4|SkRZoZjknneU43sk`~OEdEcMWRTWtQurqEs zm>^0)j9=R{VdBdw&Pp~ASdqbi21GBb6&~N&6T>5F;;p;W&Gf{I;b7G1L7#cU3z^L@ z&I)wYd3IL9*`_dlcMr(!8A(wtV1$`AdQ`EupmwIlxKq?A@Ldqw1r|ILoip7XXs>Jd z5P9s{zTb505_L}yUk}jl`Wf(7&(XDdK*HJtBiJ2q)TC%qFsK17W^cKY@y8H9;Z20n>{Vopn@HPaA-xLApyq5mAwn&IJ^ZMv))Q0xBIM zohwoT!YYVJt~8R;&C(%KA{|RF&63OJ{rJwg^T)mC{`1~BGw+-`^FB|_z21tZIFX)y z7sY}6QV+!t^gm4HAU^BSjO&g#mmxu1hzjaP@KMa;?(=9CbZRo4v<%`dkwmbWkVrRr zUTOx&01q@=AXGF#k!oa^TC!)_U7bX&%7?T$^ixqrx`h*b-*8V`C>D55T(t z74|eDs+F6DJ>ZXSpgL>6Awt?vyiZu(=Gd#pYd>cBc5C^@KSPi0sn36Ms>n^b9j`2c zZw$!jZ9Qo!@H!Zp5q2`A5q4;#I=Q8#Ud%e5W|2bGy1(M+H+xN*Q{Qt79vP|d^MEP+pCx31#VP)x0z1kI|pL5WC4Ts50BDP3TM?09hNnVC#bZCwuQ ztT>mWf5iTP@)%eVvi02gqsMpO-cnHoaY|)n!8iXrLX|$#4i(4jq`fLvOnYe;PrJ7& z?~R~rX8cbD^(Ou1Yktn}n;WK3ZLf^=1mzqFo81aj$o-IK67C$i(jJ#vWsgw|KL4U` ztP-|FNU+Kdq8h!VZ*%5%JrcLSk{;jhMFrDroxNLN7c9nf-e4P*HvQ~7le~7}i}&Q9 zxHUs*2~GZBI@SpkWOw)7)Ym!%jkx2C~4vm&KqF3Q1;$RLj_T!6vE69@JcKY{+*0Q=gm7;zMj* zw>~>@|0Z!J|JbmvV*4jBG}~LUb!{!Yd2ua6=bmei;N2LvTHKSGal^u4_cZp<>_zp3 z3)tSbZa1VwSWzL}*nrnKt^edpsEcVu9!Dr+1FyXH+x^^g@8#46Yc$?8orhZ|)UE3a zWnx3{&TKx@u-rEbCGL8>KX8s5z&FP2JD%XCj z{+Ew}K$49b-`GUbb+KjS$oXdOQ=>N1wrIi=it^QgLH%-Zi3N*v zALnWD-Ploo3}x^)B&&DQR$d@n%#G9Vl{8AZu8O{yTVzXPhiQv0ansW=b!AS{&tZmP z@Oy9An1ZS`-1nC&_imE->z*pTFvwB#l?&%*FbX*| z=AjH?{f=mIvTs~$Cpw1EJHF;wv6J`r5YiL-7uk>@V!_4#UXm^odcoGIQr>yjo+ju_ zGqe53|MF#iIi2cb@VP!|#~{a_<6E!!&bl}h=APVoRUZUR$7&8&H!{VN&0Bd)I_k{Q zCEUB1KQn1zX4__e>^oSrRJT8A7e7ZJ=lbI48^fr)*6UtVGMk=B<;pB~|6z%Jmk>9t z*yxLkImy4Ctz44~l)!rxrK($PFEcgQbc`Qiy8=$EHpE+VGd-Qr4?I+D+!X39`en^g z6hRH19|?x!62^AU%JeV?=iIn})>ghC{GA5Ky)Xvnt|Q;lUi^=T?P*fR;KCF?nO{Ym zs~$&eakV|Ojw2DaAUb%dKdV#E*mqE&k>|7G3R}-Y(wfT4JLl1QFJ{w*@E;_kHpX{f z--G80!s|Hymfux^tA`&25N=z_<@|?8LQy<6T(B_`{zoCvn8;kH)^kT1Q?grtd->mb z%;!dRMyr}&ukyHdi34W^FLTA_pZ~t)H%ga&|9KM_c<7c?p2K~4TP-A4cUoiqxS@cW zDq&=8{=>TqhEKuA+Dc6Pq2KL0rUb*x)%%tEyL}SsXmq$N_7=ZyDjhFdPv%o^%*fKYhZf*lxCF)PE?pbzGSa zt^~D~5O+GU1?U-pWm^avzllN`3V$ugaO#jzQRNM8=M}rY!sJd5!kza!B%#uwR2c$( zNf{5acDZSbsi^-`+=8wWvO0F}oiWvb51O%a>_T*Q;duPk2r^}aNyy-*==fb|*4btA zZBbry$v&^M5h!Q?zmX?uy*se5KvsN*xOwPpWm|O2Mb9EF&u0mLE;-|Ix4e8vu4kT{ z;jI!m@uUj4Ktd8g@<|F`jsKf%+qajs?PrHqgD+Rjo6OAu^OI!HkVMmx)#D2)qw0P5 z+Bg=A{n<7%dxTK%cRM6GL)*IVml%6`ETvT~#}9B4G9rtV4UZQ@%Q`&fY`i9Mph5_0 zAbjPc#nzAPY+Zzbeu@{*dhUhSkx|z~+d~O~ZV>8S$t^?kz*+|>1*O#g=1Z+)|GL$X zRTpdTSdUWnAMMa7X{nz+JqvPaPP{%UXvFMH$Hya3RuUC9s48=?vJxV)yeJ7MyAlI$ zV&mxfH_tDq+n-Q13QV87*t?iZ$yQ#LexUpNW`&OGvN1N2y+Cye_wz6uv2^woNxi_c z^#U33oLw*y1W`^?9~?Vi#^zL}@IP8a$b)U#nqz6#-0m8)+X~~VN|gkHqd7T?xvUqp z5!2ES4s2bW?G)*(T-smG2ZsN)1>uJS376i$xhS{=7c1XRL_+}dc#blG9-&113B#7v zwx5835jgSso!=6`={P10jOiR5l>oX0uCOp%3mn4>KiL2-co7)T3OW`bBHQ4Ez+!+X z4>@mwTzC_a0+@CITn!k*2uH~RCkO(osqVyFRs_ z^T0476HZIx)xLTTMh5_8(3sPOSPPFp=h}K$!q!S_ksS z9ekAs1J=M{C(d@bI`8`tTV`;q1Q;C)$-wKK?gxegO+XSHcml$i+W{N>w2*L=02u!r zg6}zlAWz%8iM_@^w{iFd6!P-4N`Tk{a}Qr|UqMZ9!Y`=oPUOL7rm$1uUPCniM2uVq z!a7cz!j}kuLeIisr#Qsq8k};whun5Gw(c#;sxW zBSx1HH%0Bv%8qf}Fx(P?SeaJs36#v2gK>KxV%2|_Wl%VtXdX6pJf?;(0RO@j9~1xJ zfJ<8dWgKxiK!gHI<>-j3jVhoe4t|(ZjVU#TjJ5$6Fj#=v6)VKi`S2$i?zqp_562_~ z9)@keF~89Vz`!#2WX~AL8ONQPLxNA-!42ry&XZZ<>1tcV#%!k&?zg-xzO)I@JlO}3 zYt{HYSO|d@*piPRxFdkfP~sug^_Vzrbw6WVRq0%U@a#euzt{{GEH8S$A|b$mLQG&6 z0D21y16lw$83aE6#|rJdjd{Jgyz+LpCa(HBTp|2364F(*Q{!|KR@u~s)?wr%CMQPJ-35!UKkvH59u?^Ca(rjylh##}w? zVhR-d&S8<0cLM|i^_N)opVhH#Jx5_Gdx4FnPOS7G?DUlm=u#0LcB%|Nd!>Z%nG5Y7 z?A)4yA0(x#?RP>@K7b;o9E=~Rz5?(yRB)eDG02(-821X;&QjZofm~fl5Y`LiucxUa zTm*8YGjyM~>A#2rUJ-B17l{?z2s&(-SAu{uw+S8*RU?W8hOgMd&esGmoy+h`V=(Tx z5p+Ujhgma+{QVslv4a}~p`-ymkEYC$(Li__E!hsb5+(Z*$ zA98-;evC^#2DV3uCB*I37AnYAAmkVvwpsw}9@_<9b-?^Cl$8mvt3qdBejL(&PF4*J zf-g3kj>FMuf$i)4kP|XQFaa4sIF4|+xUQ9}1Dp{r!jZ#AgJDa~5M+8dVHSQA6$n`w zT=CyhmIJ-L?zL|S>?dE)NghDl6d_#l0{zOJ$dLs^Y6DyqNHGQ$fkknBuDF^Y@BKRwf?fa-&Jcv3pr%Vt(B+yuk$}JzAQ6`_=AFl(5xZbwIsO86E-g>Q znu5_eU>}Sr-2a$tx4iR^HUS)dWCkg`a0aHwfm3J%!CAEl6PSymb%vvRtDo6*q}UQo ztzkg!`1Qxbp_EtfK)o6OKNPOMayBN8TyCv2Ma;@GiZ9`(0Rh3S7~qgVx%{AoIq=0w^3;9&z4wnF7V7 zFy`<_%w)K0Va$m~u;yPU4Ir#7IOzHhDUjIPD-i*364t4JKaAdCligSF+(lwbj=62{ zRvhTW7jgm*1C)s?RKPl-6Nz5A8bt&kc8&4F)#2O5Kw`Hj#AyM%vH%tV2GT>|Cv6~NkF;|{_&!9r^?F*xR_83^ssh7_NccXL+Saf! zb}|*R?F}c4hxdCE577`E+%#nO_X;e0a|MJutMulx+gU-lg=<~FfOTMGCGEYePlJ0? z*`Lbk#)sctaFgnNxUFvS@~$Ax@dmFthlYXX`!Ap4Ey>9X#r?aj)GKE?{u4XmU7xv` zKYOz=;j5d^;Ck|Z%$z1)fo$p2n5X9uua0vyz&}@KID1QZ@sA=R`z-vp&0FfEyd~fq!%^VV02E`{BSo1fuRua=yEw`AR&2zY#ATRcyV7o3Vudwl=3ctaB z2hN_bq~9ybVS066+i|N)TMOm=aRGc{>r1T>_G68|Fq@R)qvFUVW}JsU0)KNdhoaGg%c3(l_nFL5GGEn^B_o}GnEtb;+DPo#s3s``2` ziPb#!;BV=xj$qNSl+ddF4$h_|QK`cKHhIwcLBsv3qo2Dra57V5Q$vXOii&)J4r-G! zd7O6IZvLaT^q^=W(EiP}Q-=8B*w(8fV)H1mp`MVxO2Fm&ozZg}`z{R+ZRZ&@d1$Tu z$%q<&QM*`hZDg35FbSwU+B@AKihWu<@I4Y+ZXHYK#IM?C_!~u|ca%V0*lW9i&qeK* zMCd=G^URrkq5po`Sn$boi_L|MFAI~pYh+_Cg!b}4eJ^cPhioQ_1{RjEr#~CMMS%!w zgKGO%_!YcA-PDU?gbgKs&N7!@9j2->+-pHG&R%E5=kFP|U?r{0JLG`ZJICHO=&(uS z4S$;XHJ*J;TtI4Z|LvV!OIT;o_=MGXjyrq9Z1K?&T)}B)lCv%>Ht3IluY_O=W-giR zsJnimmni`L=)98zWtWGbAgCJRiROHuC72me-wj(4zvR3CmhO8{&D$}s4?ZIER zl#qv2OD%8JCryO+x6E?k71r@j@>Z)y((Um4xo^xY0*^I)-c4_LkJuQSHHh60m7=R} z^N5%Z2qx26H3?Ktg?C{%Cq7{Bn`=`AEqZT;-ff0Gpobntlgq~D-QMAB1 z^cWOzzu@HH=II+#iNrM77Eg}K^uONB@^D>#cPDP!=Wp}Ddl&)@V)&iebWu32@$UFy zM3_z~e(xUzj6QSOid*h>lf$CGMN$>~Edsr(=!8dKcGkx%k#OA>{(EWas^EGR`!C5Ku^c$@$5A zY=>*AG$#^_P2btmUQa(zO3Pv%ZU2W-Dj z9*S!keu zjiPxEO#*^)Yh}D=`Up)_q>RFr$8>5;W#OL$LSu?Xi8V^=Z-)u5cs zT)N7krD0DOW;UEM&M-pdt#9L>M;F?j4j$u48J^RuqhXa*(u4O+<&kd=32$q<&M+;t z`I%%Ko}gkw$Z6t=AqDCm~RNa zF>IcsLCf!?_293Q$!Q)EGODap!ddX^2p+B#AAgki@X*)RslMIW&VTE_o%$DO-o?&b zY-t1_F&f{y5&j5$*D&*L*6TL?hTGo$sbCukS8F@MB}v%jLLoAB!%l74R4(*IyKVP> zrp(n3PXku&wzr!!T>LiL0F-L( z1UM9)YwwS0os~#wMHVF;!91;hd36k9V8s<*A;A$bO}NA^3NZ>VvB@WAptqkOENc60 zVu&SgKEr6$i= zrS(slyJ9ZpY7zH@a{CRaIUI>g->dPQPgL7`r6&hi+zCUy9gPaTXqYm-89`ftuf`Ya zKcD~dQ)GM|p*LS2lghes8ax}0=Cd8qDPhgmpdC?Vu;Z%l3E54~G?cA#a+1F?8B(3LmM(zA6+H->)=hs1=k`i875 zYwzk@bzS|*?RPi*FDS)l%su>U?B15rKpVuRv8<}o4UQXM2_4m9p8C@ogzgPE9+9{8 zJ?wV%()~Rg`qU-N_K8^ornoezLwgP~=lMjxe4a6_pQO9rr(-_R&JP0ooXWhr`zaPG zQI%qW{hIEJ9Bmb5_5K6iU%RKoTDNBcB#KfLL;oY{&(m$Ic&_*!O1)=)zfx>~J=uO-ygKGHka^ksjNa0axk5_Hf$ zHMZz~oKAiuFSz|`W+e9f(`e_OW8wpGMCe^3FC*?gx6b|*e&N#Z;j+gb`RnVaLWU14 zrsSrW$0pHjhX;-J`p=JD(0{}odb)VYbY53=-cq{y`@Q$z36#(t^kv-Z?I+?V|IGw7HDh>>B;+x>EBdF9x=c=_vY2~K(pp*ney_D z7L{{n`!<(-!{gm?x)Nq4AHmgi9aLc|_|%jY>&jIsqtD>d>-Sc21@I3-6A;|y39OnD)BH8AW9NP)mWo{W%y(Gs$NywO`5&)7 zChsRqT|fc}9s6m=@TbC!ki<7#fnm*w`frJKuyyHN24jmfO4GlblINMw{eius~;AyIhI+BY1^uCdu@&~mbv){|;U)u5HhM0tQ zbD7--P)ho99;(9hFG|$(^sw|#GVc-{roMhth|1@l^c}2e7?c#{QD6#;6Hd)$W9*Rp zi0;*O*rB4H=2n-a>-+IV_I7OAk6+c_CmsmjQe2rkwY1=f&3~l7cJSoAj9p)-=pJ%5>vAJUibavk`zgJzfLW@^>Sphj)sGl zRL$iD!}G^;k}(PYj7iQk$--1g9&0A72dPwjxk35yb^F8Ak9Uh$@(%p__e8o?eJEw3 zoL0RQ$TD>H3meA|<(?*!qga2SX=F;ZNL@1Cu_V(%B%+ijeAiH`}cl6$i zP^sj4OwgI|_O3MfzIOf1tgl-X9YT4&k28kn1Lfv%XYj7^5&6F3%C9HI7)Wys0Y-*i z#(+y~s8ciE5u!cztxO(1Z7cgvFXi70@^Z~Dwmrra3>*)h*yVoR=Oo2-E8Yq%()?3A zck@14l|JS1Vb??R#2@~4cW4k{43tuSf*)89m%iOIpwPNYL-T<5!=E{m_L4h!)G1F> z9*S{Sk(+Bi38)khjWwwiEUU`=eDBUP4i%gHo+pl18Y^qR4wwWpJ}|Q<>Qaz@Pt)x5 z$zuy!bi7A&`#EW)lXu!fTEw&Sj1|n{+@JRt`%EYCFEKiec{2tKlpmt-bc z>gJCc4vVEP5cMX@S?kK~K{?D#%u`FnX9PXpO3a%Q8B(7z-!Pa%?6NR3Bw@Zz46)Q6 zb*W{NPW7}uvXF|Aw51H^Ui(W6#8R{WbQ9*kp|Nq zlP!%|4Tcbn+)NKD)uZ^=(P`B+fHqC>eZ@O@H>GJx>`Ttuc+5xaUvY0x_YrxkUPQ6; zAfvHb>H?b4f^r;rky7ef6mHaY#lBFAa!QK73=8DjSqh%df7m?}h*X`5lq2n<_UL z8%)rf?^<+>6u3kK`ajN%XttCjhaZ0x=*|;;1P?eLPOOqKM&qZvhapGP zYxwHPtQAde?@Yk9B^Cz}7w<)k0y*z2Z%^|+7~-i0Nn*J;nB~4v)rZiPPO2D`cww#W<)5YSdbM!d#tokoE*O+j4O>C4N{L3DB4^ z5QI_ujq5X+d}MHz7#9T#0~;3Kf3P^lSnx0Gt*Bvd#kto`5K5Z)W142QHo32x2u1Hl zHNS(x$5PScW{w}2_^WOxrbvF;X7TAY(AMvJaMw$k!zG<5N+RYiv-sDWkB!Qge(?M> zJ6shZsf4aMHa9p%v02EoS|v6(VSn74r0=QJ>23JtJxbp2CNe~w+IG&~BACNTlik46 zmt3##Map_%&Fi_6-8Zis@u=cJU*}m+j&oDa!^WCuqC|Jd4<9J5ppYpY-y~90hxg%(DWn&;?Ib zs**J7zaF6j6fgsK>cw|-4LBJ31hef>IRAB}v8cS~+Li3l@8$9-H7aQcgEjr08qV&x zn;W0#>1dODq$ioC+b`#L&(o@UF)*xLnCP4K=K%5@JrYuNrVNZ5wN$)y`;m8vSd)9t zj;Ai7k!5C4_+BB4CHZ9d-?Po;(P$qP-e%^)B<{f|{>|2)NR9UQI-%e9Q^;dtb%IVX zG`AKnUAvd45ZUS_h{Yt@vz7d!Bj+@oTgT~mLR>GzK`O{-`qGH7JszMI&T_M~2k zT&5Maeo|d=T017Ffi?5q*KSC1YsGDcPApAVLBZ!P^WQ5)x^QK^sAYq0~f=9(HoLgr=?+($ah z<{Ad-AhEbK%1*9=B*Ly=WwO$zCHn5t#=AkNNZb^RdqF8jUSIl=u$ zwhbmi8E+khuc_vrFN|i7|Lr%NK@x0;a=(L835=Zgaj`^T?Dznpv{la1fu zCpork+Z1`Y78$UW=GJ1Pr=EGUAtBns!Ljetos^F;Oq$HkIn=dTcxX77Z8TiJ8?oeG zENs}g={FPztpKRHma%4~Fu>pXAEfP*{4PY?D3%DR5Uby(X7 zygDqBvUjzm>1H+i7F=oC6B*}RVa>gf3FuI0aCX%)pnT|Ji- z(J$o1(a!HpKA3#VNH*frP4d|D_&g!$xo@DaUMH1sAa59RCRkka%_lvBsp|uqj^u|p zHY`8JUbQE`D-{{$Bmqk305{-OjS^ z$vG+2_-HGT75^AzVwt=bc8BT>MH1Orv7OIjT_r8HfhqQ$mo+}zys)19PcK$qFITy3 zygA8qa^3sFaN0|1GHp`j7skVwE8i_G?Z*>;)SX>98gCi^GN7DZ{#AF8%ONJ8LLb%p z#YcgTmy)-n!g6(12J8M(l%GNDg{0xl7)ieK#wx{^_oq?jO;~?J?Mih|8Mm9uOdCoY z(UiZwrWCl6*@E1n)n!w6-ToT)fC!F2*8lVKkQrNzhx3B{Y`PlpSXS?_Ub5pJSf}oF8G#X|8+YkN)XQd?l zh<=chx{Xj@^ij{|=VZGkSLWZoC>yIFIgH%qdQ%9(@JZEZj7=^DU?cSu$2qEn45}W)8*Ehh^Ee%c6~<= zzmcjGC)};@cd#?hq4Ue_R}NIx4YaO-at1YO)Og9>g88rJIaS46Iewa1MuI~3yFrit zQR&E%O+$^|BU6JyH;i5vadY!seBJ z!t{lQg?zOUCBdt+3S)Z69Iehe6wq&=^)2!Qf_hLy%$4oB(r;&|{Vx!t-X!uU=Y` zKi=>iOy&zco)g%6FD1Ndpc(ZveB!;o&=``lH}XSytS@G7E{5Z~O&JH+&xh~O&pe+@ zRf2p(uW*~j8$veBCo-9Jk2HjW{ez(grQG~nMyvF+{3+GH6!_004mvfr7JW9FtP$`p z61N*xlEjt?Y>ZN592tc$@ihHjEuZO0Km!$xr{YO<$l0%k6@jEoycu82mA`6> z(NOgbXy66yW?$G}(^pst{SLJ-GlUk&v62WVKtrasp^53J^B{_ z)O&zIr5fFNOFsyRS1+600J(lX4aq<_=4~EBiLW`CLH|0hN{Ij-3Jk&kqzlF}jJ_*64L)EaPMAI~Y@ya+2kKn`@r_WxPSsR;WK?)X#Spa4dcye(8yih=c zNRElI01mj3OSY{eV5t&Fc^F1KQAOd6qklo}{2`2gs;SR~jFh8_>^fHw5aO)rqY@^r zeFA12l6Z(egA;|CtW}C4n5LPzcf3!|;gFgpv;=S+KLA|8{xwhQg`dN_ArPW~z|RgN z#I=CO8V;mGFFWzayw?w#?*jyYAfG0P!JK&?u&Mx{ABPfQ+t~n2HE3raBH)D&1AwV8 z6&$$nXx(pLAO2CWQYlMxnDlGm+o9pNf*XSAW_QwM7c_GY$b)tDb`lKfidiLHlR|Eu z&u^g^=Qu1#J-v0>z(=>#4xg5Q1M*YHc6W(uQ>i;X$kiSB$=&CEr;dOO_HZ(Bqty56 zf_O5yRyVfxvy2_D9tEdh{8htKv3JRGi!5~q(>=CJ!|*D5>-9!-F#7aDIH(~h51V)7 zjk@>6i_u}AFu=bUn(H*s{oL@SURy8+`wxf1{?w0lFL5HWADNWhO}xL@LETq6@Vk6Z zCz&*-h(Fv--zzF+1RuekQsLrqhHjIzS%#z)J{fxGdS7EK0N;)@ZY&52s+<4`Xgez& z)ZdMSBXu(kVpUD-463IWE^F~T6;0!a8;2&c{|3xPQdk>4(#A9Bm*_;JZ#qO+#@YIx zt`DaYym^|-vqenUnr>Ku;%!TkV0T`fkaN`Z$T7Oz!T-~T!!Ed1)*J74xTR6mtbDM1 zzkZzXO0oAF?CuWmt4b`mvb!pCV><^tLlTx$B#eFc_hbDVmED#6w!rR72(p|ZNcE9e zBrv$0Lp(n{b=qZs(TczQ5$$)={;ij`&9Ez{q^`rd#eu2h7AI&v<0%s}#*}0*xcssm zPcQRhE#QH?0a=F?o`21`nZe_B)doFn#8~A<5?@4_(#EqAH@CH>{6xf7R&LmIRA9P! zZG||pAj-7Dc_a-*sm&nrVtPnbvUj`){Qj8SD+2NY{l{beEhXU*b)3v{D%BXa^$F0( z9&dL4dE%|#{fyn7l*=!N+DZmiR0$PM{E=EWvvc2%8z(2j=H*{o7Q%W-7&>|VoO497 zj95cJb8#a4yl-A?>v6d8*$DiEDCn}qd`Jy_k4E_k(=U<*7JJbi=7+d(xR>4j^>5%S zNJm7!*+DK(_12B73+RS!7>!*!hDD|E$1fpOt($reJpDq--G*#sK z2BSt^kuYBUS4`!u$Z*g>DX2W#%zTiWZe6KcKbj~sqkZ~@m3F`xV$R-cr^0>>&5jX{g?l*^*<8 zAdrRrH(pE;Z{U_{TF=#<-}ly$88ataU(LtyE`y~oCsyxszmU_LCz`|0;($BPie4q$ zlLo|XO+R1-=6(qLf(FI|SE%ms69Gtq@fH?%O#~{bc;5iy#@3)k0Jtk)48*BqmlI4M zBR$#P|8+IZa>6hEC74m&|Lj8(@Kv&c$@y;<){TzWq-#LvmpDr9N90H6A7tEk>W7~h z3)XIY@pi@;Sxny0&RG_^;2jWVLTdhR2v z*KRUHADLX|t#Fa4*j`l9`oStET~(^qt>;vo>b!H*yc%WB<|w*D9cc?jo@)`qV}~S1 zkLRC+6Mj9B`tSY>B}M3@_Wc=hE$ddMJ|iaDQuxW&X#OU>Z1#UMI z!=oRnL@N!AD~RDqJ-R9h?e_Er=bh!ApAXWl)hWiGNHy~0#0=!tX&W0g&G*$( z>O?KXFB-f?ebCh%wlqBM_mqi(&di{W7i0`m$sf(vH(V{ETFWGZ^b{e zx7u^;kXrtr?H#spF^XNBOujYLYx9V^>dll5bqwXOxt9L7hWUDru}?R*TV3NZO@>aJ zr2Z%j#fg{0$5ryB40o@ip0~cFZ`CHK4XF7&5=iO_Tj~u*tHtDmwx7!T$2D2o=87{! zm*6{1dmCjq<}O6SCM>%48J5oO&Ct@dE$O>Z&iUFKYR++Gf8x%!NqU^XGSxBM9%0{{ z*WH4m`Sb!^+n3*ak5O@=Ggq%vAd|nrvgLWY$)owczaW}s{VYhl)Pp+cAu)!_1JDm9#BF2-mCO4XFOSToNRr(SCyw#t5*||<>POtd1I0dN zmLBnz`?Wu*2tp)(tnXDq=4HyhQ|Ray=2O2&z_2C9#lEVXb94ImV}AZFV?|7C?9E)m z^>OE!(n8v^c_Ux(h2@PTgo9%GCsNNTmG)&UOWkJfM``(JMkD2~qE@Ztfg-2Jzk#pZ zzV}K?jg|^$NTX``cx@igkMaIx5xtUYNVqT4pasohs_(C-a{TGo5yoysfcI51&7X%7)_O}TXAb!BKwatdN;@#`v|s0v zk|UgYCsAp3V<+8&kxnll_qf-**?w_!Kt6R1qs7eU)c-5}7kf*-3=`GU&3B2u{mty3 z|BR}UtsufvI0-@TjzB^w_-C8hCL2eWPI26MT^}M|BqXX+CeVV&`n437`(j{T>-k@8 z*6;kkeU|EhXiw3;{?v?;*0za$tZj3}Eo8r-uYbpHnEG-5MQZ)k<(v9Sqr?S?>4#q0 zvZpugM_@d_ifRaPaf46-&Mia0@#2*Zm>gH1FNW`Ioss>!={kcVwS9>jQKLJfS@Qcs zbcSOmqa1Wkt68eJ`!e)XpTEnPWfXij!*|9OF*~JwjtO`PvIu?odc#HR1z7#dv^C&BCR^}BZubRC*ZqWuw|i$yYH<=Bw}~zuCsWhY zl}(b;M)E;eS(^tsq6*&vmLw?ByU#xm_G3ry&cT!UwRq13AJe~{Y|Qnk*DIRI=g?M; zzvJwO+B@@K9BOU!Anh2>eWGTzcjQ zY@S~=;o?Gbyw6|jZM-c1MH2ACJzye_#211OU@ud$MS90-9h0`1+iFdAq`72^Ohq&n zuU6eR=6{etMjz?v5ge3t&x^O1BYWvBHP7?hQM%?U##={T=DOWe@uVCRBn|5JsS7d3 z#U!5?f+7PbB#~`yH+4g%`vm>nB4?%YwG5HXe$CaH!lT|-_~tvDdMUjtK}_0~Z^4Z!O2EfJ5}LrIAz%MtyGqhH z%?tVMwQK>M@;UV_?ay}#l94zi1vbx@6#FatOrszA5Oj_g?kSr}M}O}}9eSR^zU?$D zbiU-=?TbLqkIA=*lqk1>Ww}^dK1@)OWQL4ar3~M=Gl_X?wtN`x(4$i0s=r0fj9*G& zeAMT1U(cgWxUnzDDs!oeuH@(Ug1lQTv|1f*%kF+#DNN)d;y26t852I)XIi~yki}1I z=&yNwaeaJvqxBc)Zq4NuM65kL9YSPh{1 z`tmQkw&_~hUr@3;lr1gnxtZ1%d<+q~@j4q8E!w^qp8q7Qr@EPI@Mk_1e@ZJw&CvVU zjm}|h!i~MM66P-CkD5#B{hlW$rX7X%nw$hFItLRw2(QX9>;`&*G5s>!12HJ{_=8*f=q_{L1_ z<+pT>SGBj?@EvS@&6;tl0skgpqI0X7#+$kdBDnLVa_6l|WL{CC(JDx9yVefAq>BzPEn&jz5a^dDKVm_vDnf#~CW>1R*clSB`ZyZaDS+p@;ub z4~+jhvI0F3CJXnUPQg-67|zQ#-#v3wXFavxaz& zl~nGap{uY4S?>>UbKqL|LN9TzswvFH+q?o1#D?au?0O`rAM;}PB1q&xf!K)rHC@vZF|?rApp*$sP&58UMx<2q)!t6!Jj zX*`ZIAg5fm_>T0I^L~E6n~dyZRt{~(kkF$CbDGnCV+y%7sr$&*9_1Rue&^+Lmldl1 zuA@$E_|~x~KOhs99!<6mGc5FULecNr@PEpVcx%$M{H2TbRY}wB zP`$oC^a`h?M$Rh>1ujj@Y6l5fCz@^LH&q){zL7A5oTjjJOpqU?>uC?VZ1%NLq+H#T?4GT7zT|c3FX-HA+d!_sf8j#DV1Lr?Xpnkkcp6GA!^6Yu zx5$E6WN@n26Y4#s4}Ii(X#b_Lts`ILmE%kxz+gEvoEs-N%HRI2A4U` zH$A;{eV(%@7mlyWG3YqH>_bi#tuNH6J>SW&&!iFjjPhdSqhQM}R&$q8Dbp%(;Ia_X za!yQCFt|%3bh+!U|DAQ3X^P4b^5CA1(_xyRJoUv*7x6 zTY2Phy&dswG}p8@}H)@Ab%J<^EtiBVktIy)pUSBAJd|}B$66q)|OWK=O)XmMJssH_S zDx=>xkYB*hz*06zLSy;sjD(*U&>5F;FZ4@(-tC&zaFdq}H*}ud(48h(HMGki<4w|< z@V@IazC>YJn_taVmiANY@;3Jgc2HcD!I!KsS`_vr$I&~S>GSFLy+?hyo${AysGn6_ z3Q?w$Wnbbw)5w~sC8l}XkdbieO!cp`8apwGj|w>=2HDj|Nq60IDDI2*EavWX+C)n6 zch*5y&~`ThiY%5hj)pSc@JDqO6!qua&vKglZT5k?h3w<9XZ>p#o2r9vd%dq zI}(Kh_MG(;&z4n_A`4F5??|u*QdDL3nu;MbOPG)3hotnJO5X{-<2u#bR=-u0^N}m?%X6O7W8j z^3|}c=@YkEO2383{^t}z9Ei>T0aHM%zaUZfss=;N&l1$Ir+ITNtVN%Bw>wCk>vN-d?~N9lYtZ-%Wyldt_6h8@ zT^s^euysC0F-2zIE}2E$}j#ZJ4l z^mS=ktV?;F+G0%rqY@NU`2CqW%24~Gt*m>cSu`qc-)Kp-IIgAf z!o4B9<(!6<%Ph`_>bvXt7sBq`vZ}e+c>#-Qgbz4d-e=)RrBJyq(|9t8Z}|Hp>D_|S zEE6J}0OO=?7#n>L`Y3a2hbEw)h~N)uGta)q4M~Qdn1EZ$R@Fv`kQ2;XQqxC3G(G#i zQaEMq68qKbsfsJYt0$z@F=uL#Ue6XYxt-~v?P#G=R%Wtad~3)4vQ$;;1Sx^JW!SZ$ z<&tj@P{xBxZG#(F@(*Ak3G}&SzPqro$-7x_%vVSlO#=fo2pLz4C5^ckLV;kLLX$bS zLDq5D=1N2eti!G9qY-M(L#+z!K?$iA+yBIU$nh>h^Yb5(fvL2N`q4R?yqdG|;JCJCfp|;MDV`vI zXFlgWaA+0-RMZdnY*i27dx`H^Yum4e&o%Z`6?Mv(cPkjZC*SlQ7Iw23DhF1;NZF|q zFSQ_?vM`+H+M8*%CBGHhQpK>`3T|`wma5}TF#%hAv)~U*#xWXjS zHV`&Me0wXN%G|Go87kEaK@C2{#aK@xTx(S!wA`v0!M8Zao##>|u5k2N!c5t1#sWhT z7f5qQQ}Wviv3AY?ye8(DP#P|*Rf*oWVZoT&)@t5HkIWvQy*M~M?wqm_IeRY& zhux6p*H-ja^oK|%x{Fnhx<3~y>+r(s_m6*c+|Sm;D6sgN`V%XLeCbX|$_Mk0uy}u- z8|fZLCO0R*aj^}F4XqM3dh^tsm=2%}Td|wfugeBT=!d6lmXyr59y(XRS^!e%|F`7N^O)u2mwg>0e=8VNep*_QPuMc@yD zpeOb5w9kH(vgZ{v?g#%>_py@W`eoqs)*caj)E5B+$6U{7l5c?o^edT6p!L8g&D3G8 zQ&f|Ti%EYt7<7vt5o=&i@}OXQY|wehxa6xIDohCUq^t&_@}w|L=kZlyTtYL$mh{%E z(b#opfc!-X;#$HcpuKfHGcfuy2oy0y>7re_!ELj<_`a#yIR4J@F7hgG<2GjB#_^tGp`zj*jpR#d zlTmpgRlYA$J;0D{8(BKKfxFPDbq5b?ODtuO%7l#yA*2^13FXC_4fp^p@OHl0CmL?O z^(nZ+PWv+vezyYSS&7tSBeq2lx@7mAm93%R*Krc}(L5La=xGB|SD6AxO-b)!n!X0V z6oS(4_K%`J%!Lh_mWrC@s{%;viyGJXT^E9Nq7LK_O*1?gSR(*Jy;~`Qp{`{+c~_`G z2$&Gmelr<@J=YujBcWzJPVD@REPGo{-*So?Zo~XQ8Ux}INl?7N5hIZltodkNZ81Go zTw6vYV_;(1XuS)hNC2WHs-2I?rS*K_dy54zUDbD#mK#D@pa7he$x_feZ^xR6C=WCCi?!vWkenC#}&vw4)9=v$g zc{X2me!6?yIXT@qKAq9rIiNuikIrriZA3r2$=#!agU+sK5(SgNbTm4bQA=hw@#0W4 zpvdymT~6+TsRTKEq z%x3RK8`t*-gM}JCIqf``km_D0mx=*UG6o*4^nfW(^!evW<0Y!2L};aH#_xuy5>2=Q_tHJ_`|aDGQp;X z;DT1UwOSL6-e#>9kSypOdsgd_X2k{cq%gRj&AsM=S3BSyr0>zuS7;Cx!;Cm!YYhUp z3~+#wD^nW*hZz5X`8{B-q*+@ra=I|)RuzUf=8=@YR5lP%pf#6c1SSmZ1sP(Ec z8f0^A8|mr=mRgwxpccT=DQ#^;iK+GyfW|`Ns)EY2YzbiY%7TV~Q*cyaQmy54De=V9 z>n{D_SH%)FcNGE%jGzZwMSRZP#~#|A_uBL-53^Q0x-+?Th%mcRi>-326*H+WLCBT zqN5bxR8s-OWzkh&M%_8dOg{}Ivv&bE452o%bJ+Gom#w6JRd`H8p9P%!#{rJs69GUC zhW;UMK{Jzo2|yS&-7H|rOBETUMU{7qKLc@A?9OvaE(Gm)@t-d~NQ~jx@t-#~9&D8I zzqTKI`g8o}pW@@kf4;!@&us|*{P5n!gM00VQR~;6?FXAmMlOYa-kDwxN5gn>BkuDs zeBr@u;zIvoI8b|PKyjQe+_26UOH1K6%19{oyKuv6IE~xH%iL1!D$#K`_+LEU{fzz3 zImX_=e>UV)kk!CFFFm z192F#!C=@MDh?2slWYL9TF2?9cH&V#>5VYk<3%!on0M1rAFdTamt7<&L=BGBzhj7$ z7dy)1b)tlZ^x;Z)LG2IrAJ2ze{$MA?mW4(aR=@^Ckp=P9jK-; zNd{`DDM!pk2vDqyB8oZo1X;1FC5OC`5E>Fn8WWAPyeq@5->E~a^+(YLnnMgRHf1UN zcJu|l+JuCc@L}ecSVatWP7e4+|MWveqVG8$ydwoY(%K{$XOlu|u2!m&htF@6m0pn7 zSg4i`x{%PatoyQ8_^#P*a$QW~%lzC5ynB#SW zeh_OMkPVf17WeJ-p!Sarcs>4cXuPUn*xE?DqJvl*SMW&R|e4O#OkXbNVK@Kf8C zG#Wkt^#;==nvtEhG)^eu^N_5t{fDUF9TU~p9kGHNc96&@By+WEM(8~QE>l{^%-etTmJM>Kp%QR~fa;M0xXH6x;g){;$z+?zw2ssLDC zJ_@-18H7De-c))iRFHJ073g1tx;vjcYZ6r!v_oe}p|j0IaYp`x9S)k&T1zt~P$NjwJD?ZxiPWaYtl*EdgG$GJPyNAYjYM(*&Z(ZEpi;T0eyWJr0J(-8|fH?%01&gh# zBM9?wbrbpG&~PEK?e|i$xpxkU6^o(MssLBhe&xb(NCO=i)`>;L26V70V;cyL$T)#j z5%W0GRlbl103(E%3b&`L_cJ9Ms3YS7)+)9$_6~$wqEs(aheEIL0Vv0$1FF($ssGyH zF#&^UnkyU|0D&>>hI99MmK7Ja^V~HYptxT8ta|I8QZBCmD<)@$7Z7yhNSwfXgt>Rs zWu{_IQkHStOI(b(Ohn8c+@fB>6sXcLF?=Ljn!DLoSVn*bXK+2(dR265!ED(15gto79E?o`9oKS(7b^!#M}FP0B{cF8SAA{=SY?&*@RCM5&*>2 zAynXQIld+E42osouu{Y!n6QaFUG>zt7?dZrTp}N|9*kgsHlQw7tq!Vd5l>X?o8{!- zvkrTrW{5#tFgcn&Slx1Tx)SL?nU7K}C>B)B6H|96$;()>RiT854Q^pHce)BAW>40M z42LW6gU24JCfKplfu7{=g2NCofw|(0xWF#lbyW*^9iaEG8}iPSfg_wf;l($j`*A?D z(30^$X0DmxOqrvobYsuXzW4NDS4v3qPA;Dr~=IWZYBD@Y(%M9q4xyI|g}+ zwn2n4Lu*WuD)NoqUAcq?t+O&%VCKpgR$O<2yb3!Pv^0-Do29Pfn20M+CXHDl&}evu%BH#7 zh2>Rf_&7ON6%9$*S9>B!RYSNhxV>m({Wn+%g)1>UgR?HGS2Ty*8x&xBS(HnaP`dUA zZ|9>CjaG2LMB9)J$-uV{vR#Q|6SmGvdkDwKa&*U@4LbDkUgj zM8xD;EnY5ESqI&LLO`?W1JXpTdvLU~*V(H%`Tu+|1cU}XMk{%6)o=ODOFx8o*Z3Q2 z62NE;S&gP?-&cegfmCi^Bh!*&m#qT)|Kvs|le~&2LlWJAda&fG*dQ2;5^qqV+CG-5Y6EPMPzi)uNG?Ab_9%zbW!9gn;aP=*fv2Yn^yO;(PRiD6 z_x<%Kt;IG5&UR?t+Xbj4x8qjCwZt@DSf#FTceSNM5@I#FmAv6<=mH3GkG9*gcGAJk zX|aAtGq$Rw;peI|&WA|h=f^j;S=AB9tYDa0(y3ZF!dA0*ErVks_0fK%ZZQYkIAaJb z!sB-Af*5bHx&)=1ys!X&j~h4$h_(j7JT{3u0GKeg*n8i?{X*>nx`$K~#%$Hkp6{G? zpLR|U8xAqn>`O4$Q8v!TmL{hhq}|Ah3ZebPI;5y{8A>R&2?qBre5rM5dsV)!0NuX= zOwbu=0o6(ko}KLfu5(hG#mMNx`4#lF9J!oRH6?=p)S^(8y3O7x1StY%9mJmB3`Zll z6(1_1pS?-TTn;0$!}&3j7QQ8TeO0U418q1gx{8b?`YORTd)Qc~S8!dY+L$?mVDs}< zgLB$uc!v^cHbv8wN~H#DmLRG+){TYFtXbyP2T)oI@V$k>7QH=a`E@Q#_YNqAj3&uM z;Vdz@uhQi&e1Q2~n%v1{?2w|E04_x)vZJ#+vuO*lC^xsqdh3oV|I#pC@0QB_Lc-iu5fli$vVglbBAaZRG_y94Oc=b9%$jSR)wFr0?%u}Hn zw!A9D+M;OU+)@)Ok7CvzfQpsTBiRaVNbQ@}&v-!-TJhe+q|S{luP-wx#0Vb7s0E8+ z8OV`Nm^KgsfT2d>zMHL56l(Y-OY~qavyxAH7m=$pMFy0d!3+ohY1YNeGs;}S_ z)vOgO*HU~N15~vJ{TdMjSXD=#bDJ557>Ty?P6k9=d!P>;C8OFAs8MC^5J(;}9&9s2 zR;qRZR)-3f=^C|oRZiSmq1&>0EfIqeKHA}ngdwUycV?4JRk=jgb{tR8!Vp9qdvCm$ zJZHpbhc6uPrE5Y?PpT{fcolBlOA4Z0Gnxx44Fllvjo4=PVapO*1 z{j>H6+mBF+J8@PtJg za_tDD-iU+xZgJi!dNH1bt$3(el!gs~T?!On^ktM0XjLhtS&qo>v@#D6jfTN9(uqNI zYf!wdDzD_LtF!LB4RbT6Ut!!RxVOhu$#}{gS*9oqRu`n6Ih)zJdhN~nR_OBeK&_Ks zsl$rB$Kbu9s8RE-&_OMH_saU=sWE-NEorJfKMOj4X^Q5|yi6{8;~SXZ7-4y3!%3lW zB?-)280nPSM^_`kF$I|y^qdk@(Yr6I!r_vlvn@u$o8l}PfDQuK3g;*{Ik@fmlhUQ5+VpOo|GuN!JUmC%@R^cE_1~42^kYq2<8jkAI@2H z8-55?OHU5>*=p#OYIT{JxoJB5y;>n9!6bd_!QqDW;M^EEzNX^^BJM&4LnZc+LkI_r z&^Alp)NN#MU(u;&0ELQgW!q9G5S;I@C`}mv2W@>U)J|a0BZuXvn%t>P;2JvA1sd_X z)$*ATsrz$**{SAVHvA2##S=Ni+%BL4JXdkS1@x9UGS$$=YKIF|u+4PSYx! zZfbnC$0HPdB%C)YuzWspRlwUW6T!3!b%J_2J?#Y-vb>HkJE50*e}Uit;?sRFcOtlJ z0Ba_W+Xsz5F=PiVPQZE|An;`Wpu^D_@Q4Ev`K`zKzf?FuZHTCi@>o=B_oOOvqczd8 zVK8VsDrf7OHC{X3?q?b18jCs zj>(`~7+|tfCJhc`r^=^u$sB-$aKT4m+otRtv5Awz^s) zjEfEgxZphM93KPzRU7?4)W&&W()~-+8d10r6NZo?DB6&Oc!#II*zqxRr0bvwcm=PO z++_fnrG7f?(O|uVm56Z$_9ZoFN%Ou9PNu23eHvi=QGDj!UN{ZNW%^rO83PliodKA0 z)a`oJCN-%w!$Nw9yh@Cw*fi9xm6j93;zFdcr08KA_7(_rD8E?NXYh-3c&&&}(p$&z z*(2D68*g8&P3E0;4;QR7-sp^0=U9X2@W$azd zJEt#>JKt`+gq{#IAM--!>6{HybW)a68NiKtVq2a8`m>thGTaK%gLLAqhJnMep+u+A zpc&GNGqKRy7Jx_;&OtJ7X`BThjtCx*19lz20D#8Od1^CbdwD~$jk-IzNpq$LE`W(H zoTnfN>A=p&C%)2iT=rOScg^B{crz_RJY^u!z*&D%J|%=$%QjzBvid|nx$TL5qE7T& zpXeu*CwfkikzAFYe*)`Lc$%0Rgkt(41s=~nI)nxfLb3W^BCIK*_fWP^A z&U#G!lZLNnB(8$QUO0ihkh70gaAI{cGukOL?Gy8|1+Ik&I&KK94c=*KR`&g5VW|>b z8FeY3THPWKyB!r11NV$#n(?pHVilo|M59cD5S_dQ9?@<^g^Oz1HQKl7(?z6FBk|w> z>o}g2jsHAeZ5*e=UdWh6qjt3$jvCTftyD3nD*~nVzuNiFcMkV=Hx-ezG1l2VJ;hM# z(9i+JyFrf`#lHrTvYKRS)7XG5IFEnCzJ3$~m8KC=h_QtZ7OV4GHt8VJi=aROrQ!mi zgg3(Y&EfSpIMmOdfA^oc@qa!*2(a1le_Hq3t%v3KKcD>^|L3Rp1mgc(VEmt7{ffi? zJh<0_a9|Mrr}gkB3;&}-f>9uxi&AJDComYq^-=FD!v6$f=FGMn4W8m)wpBX6NkP0- z;g*nBR?&8RTT8#d1J2A&_oV3Zuwl=RdO({vY&6_@IoE4`->~)YsMs)`8QJ(_jNZex zQx#x1dfquy^KsfY&INZy@!*x=WR_*zAfZm6k@5re|5Xh9 zvCE@lJAIho2bH)AKQ6ls}i4$n@$i(%br42 zO=*9l_iRQxRR^1?ic(Y2miFNdw>7=2j>fcAW!S}Y6;7j7jqkj>QyzSbi|o9ySV!Ft zG?Hp>U3VzZ*P(R?bv!y}3}sFu#>+I^#7@A?bgR;NQjCl55pFdww;Ah%Sv|B{fLV4> zo`oO{)^R`BZ~h0*^WR5bzbV*ZGj`YP(@cBXS2p0y10F|QSB5E>N#_Ean&eM0hAHK? zSU7k_C3rD-Pp}~}SqM^=Fj)yk6Dq?)%z{F_EJ*7X3%XMscBg72cmsGVo(As}XE8OC z5<BUnhGQzlPb((DS9)Eg|(Z&h0r^O>Db zXY(l^!W`YTK;N1(BxC6u#EILOI?pq9Mi!1QZr|~))!w-R_BX6b6zOHW>4O6?`uV_Mec0m7HaBfI@Po!* zxnXxuhUJca&;}eUnqgC>MCY4 zQ~fmRJzix+J1@s-RnCT^VR1vzF@!dO8l4tqaCb_>Ezbla6g(zMLBn6&M&zvG7qvlS z>8O(nyYko*+r(jMr`;&ow^lJ+)^fL0r`pVTMq`V$HLC?Q4_$l$)`&P%=l$=mO33kM zSX`jNSALTh$t9KobJ$6;#=0&q>b2BK9UdKbo-jXBUu!pErU$$JF0%lqfCdjs- zCR(SzUl`lcATgvE*xcY~>PM`pQSuIVz>v-`JIk|CQY5toohv#_XqiY8!>$@bww*tg zldmGtP}*xqQT0+wBi9yiMoaGQnsHKHK5Eb7H+1TGVf zgQ`gSpxcYm1Y)P_Dm-%R2ts7MLZgIbQ&Y(T*=Ur#!Nh^8NzBoi^^*}s%~fZ3dJeB% z4HQq5FJtb8X~Fywm*AV$AyXrdk?7od(7b%>_@>`errTB1>Qjs{sxywDjc zHX&9gQG;{L+lW`w_;D8p8nV66u~kOWVAE%2bxi!+vb;lmxuYsk)FeC^wIu~vL~`Vv z7DV3JPC4)nnV6KUs%AwfF#*;w77&_uBz@m5-TGBSEgNAMpp3H@a4Hwk zmSxB&3`*@L8K}rAfFYU=>H;)TExIJ+!{V{dY6;l}W~pU#OE{gHb|=Jy-j7<12(hYO z`>ufSTZrvkf?nj_(^1(OME!K8i7}SA)zod(HIMPpO$XDg!Z@G?1aF~Th}un^78&M5 zWwzlFn~DO0_v1;QQ=#N0XRZt~9;Y`vC2RRPb%RG*2Ox_*_AMcSQ+mr?UpB4Pp@)Sj zv4hnuJwq?}xgHu9Ytyf33dxWaT7!NgO1JE^q^_!sK5+n8PHAn_aGoV@_5JBsE;H|7;sqAIN0@F&QB48HGXb56_1(kTcu8 z4s(oMT(6rckdUaRro=?mr1q*o8`@$L4>A7-RuU1OVGybcSr~5^b7xF0K>eGl(0<%2 z6bh8XN;_*=w--~5)GVXFkbzjz)DGx4WRw*+P-0CN1Cho3ZBUtVd8o5bgg1e){<{o8b#*znCluq?V|l!ZOH`pAzA%YlZ2gMJPc-s--Go zYK8W2Wzd9NeL<1`V0* zF@`6^>yv$lV3W^*4c_GF6N)3CwQXn_bB)Loz^G`aJC6@Kwu~erg$Z5#vqrJ5EsODo!(lw8>20sdHAtawL^7$H()G+ z))8YbF1pCI%a~WOPdvX8nN!By_Noh!SVM<=!tK0SQrXK*=&mI1`)yDQ1DxqMvKMCw zh8Ibb^BB^D)w~n2BDIZ^Rikv>(GpoPu#$}MCR5!EM0%tQ1rAh=9n3*>BFwO2L{1 z|AgmLiK}uf&M^`#ZhX1sijUFicY=!#SbFNjm~%bu&Es4EtnD5VZWQRMwQif67`G|0 zUmQ#pNU8aDu80DFOYOW#pAW&qhBBts7Fb=KlH(SqYUy#?S=X~nNtrUx@bG5LSWR5ExnhV~oswd_OSY`*Of}<$%k?s)u>PDgu#uUfEhI z?_pLyo!EYM2fa**)V<<7o}9(!K@KF~-9+Eva{60v=Ki6Ut7+EID+{!DAcxktVJ6Zw z98wK)nj~0M0bv|Z^Mt>{ z&)uVggU;?L^{*ejI5h81PCKURN$2$W&Wn?d_zkb0y`Yg`=Z;WE)WB)m)5`_iPaO#UP2Z@a{PNUEP5AF-M%u46cGBvyf%$!i-NY(uqgJpX>xLe z1Sc5MDqNRX`RVLlYoq;OmN4uL1^~BN60-$enI!qlw))8+o{oxg8_pH>7JFTvVQc z?EvpuDN$9zb{r2URpF8snx(^1zyl6@P0=n)lyDx&IT#7VMK)HQGnVHy)$sgO%5ee z1|r~m5p5_zqaDW9;lHJo6u{Vc#{~tWn{H`6nY^O)V^BG+mhjA+H8gAfC5A(n zQO8OsNhT<=p0gp-D{{5bBE_b3Z^w-0ifW_%Bjt|93mpiys}MLZ$Yz$(6HKUWSAK9R zt8-#K+E-ImC7Td->2;EfbByaw%6-(n(&7)(D2AG#tD0OT{U{%0z-8sbeqs%m-gy3sWC?iDOg?hJpyQI$aPo z3_3RYtoUIo(x1N4Pdccz^`ek*$Yquhh}1z6MX^j`jc}Q9rCh2&LblkK_eCNWGaOIh z!i#4h6S|smgwO?2CWdxp)mdr7$vCuQ7Tu_A*P+EmZO)1MHg7SSQ2xt7MnJ> z2bnk{Jq7m3-5Ln+iZC2j?zP_F~vF2v5 zvlZBsCm?<=Zsj1TyIB*PRECmtg6?u<MDFnEF$O-+zsS8j5HhgQi7^7?uh zeGY3f#B>*{I;)X6S%%RgNIinDD=rCIu&hI^y~hw-fm>n?TtJr@G9I3eb7^_S{&gs) zF=_XyMXO}uUZIXg0@E3@kpzgJH%Id{ zbx!KCHB1=1zQ;i8cHk7e$&Ua}y{~S02+%9`aJH9>*2u=(%;-EhmDvwlG9gYb(=ylA~G!^hT{1w)yQP2A`cwjpCwo zRN^QI%-fndfzbV!!%_iDv}Ftdrj3^XcH6FV172ZJ;$JEShtDOQL6sKW%exqkzU&15 zHibI*k-Cl$XurBMu zNyT?Vs@f0CZqvrr%>UaazH%?1bP@L{7bU?+7olJL3eQXZ27mAix{=S9DnE+Xd0?tzz=?* zZ*cWH{oB4)(-JS$FZ(KYUghQ$G2HqU{W7l{sOAn-^8i%yGE}v_fG(nco7XPz^l$xI zog3zr`p%D8CTU9XjbB|mV7(S_C0QP?B$wW9eTYESyV*qX;Ak3e4fNlwIdW?h=UY6z z2Bzz>6z^C3>Scazc9(rMg0>LzpbjNowrh&K_FsT>ST*D-I7rdl? zJS)C0Yd?9GeXtDaX@Gj-%o-oD%u0{qbC<+j>ky%4b|pE5x~V$_yqf^94Y5CgKl<%{ z=U`7}qfNy%ubHWp@_b-}2nqL_6=qTf+M2!gU@a#H1J})oG`lyz3@4mLD)*RTC>#)2 zOO3W^*Z~z-(Jp#r_!3!N^z?J+Iyw3?pEkx6tLb*;_4To2T)T@Z~=?_UN!?$Eii?yyOiNu zVEkgnTQ_79UhY!pQEs%Yw2$B6N$^qg&cyN7G!aA8!qEn&bLd2#Ow-g{6bbqyRVen{ zw{n)zC*XOhwF2Q&KcD8~L{W*pRV+BF1#WG_nhb@EussRTvNjuR0R2c`?4uK*5{WKi z%m@@KI_&tHR46{c*!rFq%7z1*k zE%7jChaQXcuA%iJa&9jxNx4KqtO!fLwKPRMnt4gT^-JDFO>fFtY{LCx-_mb>3G~Rm zf?xasNsE4iKf*H2hYVP*=p$xhm=P0eM%+xOBw~g(y$4g*^3^$zrj>Mi;Q3WKx#&f# zcsUJJVw5LB{c}!Ow$txEt*~4woBZ1`2*=s(Q`#M>RqRkng@F5+ZeOU~MjWaE!;|XD zO`&mdU?4Uj4CQNx`QqM)%Te%aO(Nt3`4x=;GM|x=*fMGhU-5VFmyXb9+Yde*=Mgh{ z%u6zkV87IqMpF9Kv}SfVT3OyH&ZUixM8olwR`JrXfYUPyLNOd+3Q|f)teFm*`1jSD z<%)$i8dNCqW;hzbZGVj58&wDURuDvIh$))#%gnR$t7{-u$Psi~@N$%c5B%mCTo~L;c=ig5+$9X-0 zxMWFV?NI>+QuuA)W$8xmHzeLlh*DklAiB1c`0B~pqu0RcfBn_ri)SEQC(s^5lQ`=B z-HT_>`O!c;V)jI*k^HI)M!$7nikOlPa?Wz6L}DGt9y`s<29QX3GWMepT_NMi)5ijNJnQNAvs}r5ZoVaW4CGCE3TB} zWw=2Cla5J2y-|d%cm%BbP1M7?FXzTg2%VA5RKFeFg)Rnbk6`t`rD3kMUT%r8JncYi z{oSLzPTjx<1+k;&-Gif@y~F*3h7c(Mv|}9qcBHEA96#;uh>BZo!6LK89*2vmAy9jt zZ<9hpt-k)P>aVsmL?H%^;-OQ}T%9SQ-jhZ(TvyYzmReC&)fFU9N~35-y1W>Vfxmg8 zWx!IHgs-{))t$$?b-+Fgt|nulZr$FMa~uWmaT;C@{}5|qT)=H+6u#;L%6YhL?(-+5wO{fIQrBz8)YS*&}qQz5%0^-zQcpV%9?voz< zRphb=kge}8$Np9x_g-pEaW)tLGrEnn*XrZms^wwnmbngZfMCnDg#8kq<#nnKil1jY z-@p!0IAE^0zUk&SX%SzOvKFaij*7Chm}Dc4A*vW@w0nfuEySwxUIT1`!8dt~j+=m1 zt!u*iYTR2kwil>*LfZ?38Ik3vZcVNysxN3o?xdWeEP|Y!^rqnTk8zg z3?U(>U>&66$GUcK4wf@`G;Ym;l6$BRt2PH5Ej>7ATX3ipY7?A3Q}3N4uRb2a^@yu4 zgJ)ZTIgf`DgURyd%|(K7P!Lj>3O&7Hti6cUmd+6GlziBq_7XBCno?jhGG3v_5Lx$1 zZB>0E+3@0+fehazi9G}u=$x^WERAtAcE|IBZH)c1}*!?r#Y7p`+j2&?a9H(_)(T1BQ{~xaeKLVkrqYIN4OKp^oc+9zckpou?c< zR5SZVqCjcz0o5trx#QTP3>Vy?Eh78pIm7+9gZ9(>z%oHY#U6LWdMyrA^=2n0(e;+Hoc$I1abRs%D$ zd!}M;u>5-Z%qWPrJZf%6+;)_U>H!nh5*f<$^@To1wf!Qk0}PsWsSnuxFb8$@c>-Kx z=qQws$3ZZQ+2kWoFPi?{s9-}~#?Z7nXEEj40BrSvtWRXa#c-2FhL_sTs(8i(%r9|E zpUYtfW=liSD5a+=7VB+jW;BdBd&glzh@lLy-v-<~AGbFu8SH3f)Z!l7;tr|p@DWxH zGPiZAnk+(OW`v>sd>?u}9XLux9G5_E5&ESQM^|l{hO@~~rXH#T16VKZyd%sITwD%q zjZr(eCf4dGeAoyd8cdC%$`OJ=o>(C6tK@lt9z?nXX%rMcav5La6YKoxm)r)v`{Z^H?Hjh~I{qH>WyUhV7qxRmUfMmU?OvowV2XxVEzh6eV)350We{H{B z1+(hHT+q>07aR6D(#n@zHamwR7tM&)`1vGL2f@lfBd?JjM}0<)0cFU3t&zDXOdu=O zwqtkCU{zm_j4kca+4ptLg}?q5F%8_gQo16-7GA2O%rn6XmeV{VkrU#-GK}zBSk7_F zHTGB3U~;4B0c4#t?KP1#a%HT-AY^GWvRD(MwuSqNh%z@@L71|oVb!rTIj z&5y51Fs5PBb(i9lCWBG-M(;`{c^c-Qn;sfC33CT2ly}D|#-^jdV2liDNBTvXfN#_D*e9NE-h*?BKMs!pI z%e=S-faG*mW$+*G0@EqsSGiL_GES*C33kiN3$0G(_a}B8m&TL0#x9Ui( zrr(d#fx@aQJsGp`SNi&v^mm{o7lmO=ap?5i$Qur`caNerlX3hQy{*Iha-x63}%I#{WENCj(5)?y|ilc`#Y-DabG58!+1uD)-#E!l}CR0-syF5>b6)zh!>kY~6N<>-UclBLS4Ry?}f5 z1_$q4cikX-4b%jkPuPW6qQaA%gOkpt{&jl%qT@AJ2?T84kV>d2cX>s3UjR=<*|YIze-FH&%!9w<+cx;fi+#o1U2xWmekNR# zOzc zHo+JaY!f#ykH(`QQWgsA4^QD!WE0pK)yS`2%B^ti>MqpVdD;tyx(n%7lBjElpfU*n zPTD%o&~acOcYUV%lfHJ3XOGi9G0Km`8^i*Fk+0>r{Wz}0IJEl1AIQ8>l=K{>VH|(8 zAShUS;laWDRBXm#N`-(7vSAz>DO?d?-D|ioRU!tWq1{md_rnqv`HIWYU?#(EzQ0ax z?2Rd?B@Mq3JWR^G31%g7?&>NzmbPVPN}xV?(!{1b0ncAD7;b4G@UYCb>B-EO!pM{> zXzS-6dSyX5V7cUzJZY&AG-@078hBsoJ#)>RRDp#L6ZNTXOPYMLApdb)*oH&C^wRYR z%u&f_nL^Ncf*=$MXvK}%A!x#u5GYG32j6fl(YEe~N2gZaVN3ZnCs36!tEbW>rcPTK zYb5lnt%eC%TYZf4k=t5ZhMz-_>q#~}zp(KSe2ISM-kC9w6Nr7NO;nsM!NYMk{CPGU zpy)W4c|@~J=6ZW*G71J7i2T~;?p;)PiiMDBtdJ(ou_2-$6{9!tO^!0}7F%9kIG*RT z^?gpmt~e{3w{x4(q!N$ifuRY4r~bm8O2WV*lpkx_O{7JU$|F_yEI3*bCHoo!ev0EE z77+9y1E~)Q3gD>VqRrrB1vG zaf*3}Q!Iiw1C2O?S%?Ev9GLd^(lNXXLg=#|R&$=ZeLlg`tzjo~np=#1%+<)tS(Y^C zGtL(Hl+PEQ#GG3?bvAyOtIkE(T{e`sh{tdbK8wXgJXKzr8$iu1soC4oWDW{!v2DAxiFOe?^rmd6iNT+e8H`XN8EnGc!bl7OL4-`c3I;UG zFCnj}yclGoKE@Rhu26Pcwd9YsHAG|EoGbPIs@&7S>eUuGq=Jty;K##g%3K1nyyTOz-iZ=!rFe31$5fZ6ptuTo&M z+|}f9zsskL2Xj`!EO=l&OHyRuk&X3;!n%%GYOtmA_wrVh4n?|)(aEeQ=NzCDBk2RF zdG+}+n6SV4eA{eTK5nzt7R@GWZ_%)Aiy35c*an2sm1smFxrDpgjvNfDK`S8^+bs3p z1>8_3$zWJ^0E|F$zbJZ<9*rm7{v-(K-wF9bwATwf%hsJ6U-g?*?utvqUxs9C%slLl zyU+FyU!0T_>wI zLSe{?6Wr9yyBSEC${!P%7hK*gX0XVpRrB*lU2$ZXtuOht5Mn$YmNDbXRp$p*b?0!; zo4HoK;NY(ofb!9CpatY=7j9zr=x}%EG_VBn8uE(QfUm(!p7o6GPhO!H$nrcn7AFmi zoB4%YnMLy#2jZ9Er|kP9Sr@qvxg`X@c}0op9ile_7$Iq6vAQKUuPk2_L4rs7EzreS zAhp~WD!f!Efa`UFpjR?hVU@J(#BlZG{x)iiptpf3r6vJhUPSh8g{pG&gP&&f1&zLV zm(f@55_4m1J4f=|F6pX0t-Pb52Jwh=(bSO)yW#=M9&*C7*l)~e8!)RyY0r*rCc{(jT2%DPtP@6obrX1&8s zxZcK`dIzWFdIzWT`#T8q2bZ<;>OHOKZ{9ecR`gd6x`;80-X1;Je5aVQimNl&GwovSy$r;zKRbS<~)aEt+i(IZ)Q(BU@090R=khO(a& z!KdVlNql3p%#KGNdp&Vn5bKrBZg=!hj6EcnJ=^)FyMK6!&V8ykblh|O`rPnZ0KMVX zk`2w&%O;Z~A1l!VG!?iq0PxAB3I8-};Cg*ZgSRgr1>(C7+*^LT^j$&= zlzj;aV#g<;XBCKy!0OC78sqgf1%Do@CjBdJRpzlS0wU*lXL5cBs>L%>ag~ej28;J> zao?W-x1R`=p++C0H$#s-zD6AL2a!4mi88xag2Xh^aQy^k$WR1LO79&!f#~Na-RGU- z?vsNTCtqS(1}=UEsw!?oXBW{aS2>M4zx4p3>wK&i9aR`?e}*1~j;XkBsdKOom-jR$ zL{Q_y+vW%x+-+>z=Bm_Cvvw)|YrFMx{MVo2Q;Pq3(Y%UU>koca4*$Aw|HFoV{l##QDo%?7y->6C>rNCfXV_7Wez$ zebU4mP7I`nR6)^|*HQgVHXZfpJNS!mEEN+ij)LLonQI4+x)LYNSkEWPII0~T?{$uW zm#qPDy~(DUZBvuTVH(rR9GZdzWB^onptT@CMOoTvYVoP5<)Nk)aGF|TX=)Lq$@N&g z<6noJCd(T732@-V)i;?-=f53YV&{-sJvuhc96jDYR9}|f@-QLWnKOFQ{{CPUvQ4e% z)ZHEGCoiC-=q***647*pppEf#75i&r*I`UuEjzz#h|t4+kj|{R(*#D~j&JS?FY54S zRYr7l8-n=jN}6Ct)`T0ep8nb_L>{*o*L=SVdF7*9az8sB_k;XPWoz@eNdJHcU@8YZ z+ixY@-|dX0!)@HsBqZF(B1W7QQ@E|)LM13}A3CJ6rTL*Vg3B0+r(Csx7mG+7u6@g} zbu${77a^{Kj4T%JEeNBkfVUNcT=-`6suH~yzd@@Q!{T==SMrYKs$Gp>?0zC-fXqX65u}Ac@DtXgi<6n(MgpbpPb^__sDU zS7jPH>cM7m3U_fp%&cPbL@rvL-?uvBydE4xY0()$)6CBsH8V|~8ecwVd`Po(R!Ak( z*}SA9KOKdF5^^n{4+=g1|{uHf&V(Je<=r z#;$gI1Y7oViu1T|m!c0yx=EQJy`GU@w0Y4@I$@bbRqtCUr|s{YjIQORt6t`2uDRjV zJP6xa77*tXO|&npoiDjLT4>+ZIoc%{2yUE!{h+IUT6|UI zS0R($V3eLr-Bk4^{wo)=3omIp1^)#o)YTvxwEO})sV1eDZ8+9HKFJ>?S4srQrnrA6 z_5xU-NK0B>d3j{ryv^=_b$0_h@!F$LAd4cyh8Ny}R2MjWkwkkdj5XBLmX8(+D_TDG zd;0_r9Ygf69WTl=fux*{SOXu>2Vu_xXE4w02Uc7wlBudaqso~eEeTif=v_?ernlvj zWdmbPMJeHKHl6e!)oVOir|%3Qx70;8DY}Za=YsmDTXu+LL1#w{RG&(V2f^}ukLK2K zABM*C<{~brFnlx17o7cQnPKhp%qeZ4A8JTEsD|V;*j73n=hO&%tFE0^tOL*?ic~_ogL`mT7`e*Cm>WmTrRTncye$C`FlI5~yG_Ou{q-a2$6*X%`$!yI~f| z9+{P=T!`-x=v95L+GM3Aj=(z*WbsysFR*;-kGH&k9ZOjfs-VLC0GsVT51c{eCF2Gb z#E;ohgOXNtO5p%QY4UUg_YCOOG;bn1ZhH{W5=VU_?Y3vhB`w@R*DEHxC_ zw09Bh+Put0Re&qTTL{vCe4#fI7v&+O4GMY(AoSnJy@YnnFCc=m^nIMMfp8Y+QH^^C zOnX*c0T4#DS}6tw*TG4_X%|Z~=)t`;qoER7-k0NZ+t&&C+$8dd17CH1+x_zB=qm;3 z<%{JlkMY0Ave$zUw@=%2MW=r#x4S~$p#cCZCaA}4_(KgMWUHgDMnkPJV^KphxoHZg zV6BLi5YO-5%EcOiqG+mCrmsYEm|7jjxzf0+Ct?fhN}49*Rp0 zUn_ID7O5-*kU57yLl_@Y=M=y!fa;;(P#_}ShR8+YOPgMCZU`xPh=z}xd=Zvs1;C#m z&mrWm(b`JP21^c#Sfs&dqetMXTN=gDi^Ef~tKhw}Q)%kc)Ph7$ zxGBM6VKJ0|z#4a*IX5D#@a=GQ6)Zs&a4HI;^_^RGQdJga>lYqjVSa{BzS~$9Q_V|r z#f_$r2M~Ie2J%DiQ^N&76i}V4-rI3>087@WEJFE=(}F{stE7nErF)R3tQbILLs&If>xX;T?2JNhD;s)dLI0u|x(OR>D(sXtJm2giwhH zZs)#Zx#@8q%(0a@kn(i!0BahOrKti@DE(LS!Vz2H!q3`ETu#>#h*i0zh9v_c#Wp zm@b0xPvPyy#HfLfmi~<^*kFg|BAGyJVR&Zvdb>geIvv8f=9H}YmcyZSUSOqNa@8U_ z5aGyx9kk2lYA;Q}>cy)R^WFyeRD0gk37ug*8V)uJZb85s(H&+iS;hMyl%ZR?0K!m8 z$t~j+snH>seA|Aw!FkOG<7tuC;jWAtdK4)(BQN?&<`P`b0K~dFRc@kpL^j}`4J3$;m;~$wB0#0+%yBwQZmD6 zor9CsomTq}5Epbl8K8A5TGK@1cv9#mWcwy;PN{PHPHV%joG0k>AFS;m5sKJ@vnslS z0=K3iI3{d#TPv9I0{oE9k^wjom>IuXUteFgdDY)r!4Oijx9!1+N`dVeign2gIDCkE zS)to87a(6mEez%%^zIuv{|Cmy&)$fvLM9eI?`A{`M0%K8B^?x`Pq0z$i7e!E2D}nh z^7uTl(YJFpXw+G#gMED`6xjYd!jNJT_mVU9ZIepsbgm^04?tse)xEI5$s?E^Y1D>e z!r+bFf_!xiSW{fYY4nPbd6}MJBe@7~T%l&dL2y;6)HlnigHygvl5upNIWg(VKDGgP zeOD-4u4z6iQ)7nA)igfoSvwm}?hw5+o#nDXzizZq8gQ)4Sa#|{hz2tEY1Va^GH zVpIh=5wJrYfu)Msp*6ZPKk+sF4kqaSv2V3`moK^N%XpYB)E^X7r|vX;T{9<%%?>M@ z-dzT>3FlF<+?a`y(H9yUcO!WRhUyqN^IQa995|n=<^81ps5Ue1j$HhT>m`eT996*b zH%t-NB2DZy?=-(;P^C&j4e|}g$$5kpM4-gNwfv!mEP_Ha%`3fa;$t@QpcnkZzCv!a zDOhs*3U-Tm1wZU7)DD|>_{+Z37Dwj2eqf6jI~G&MJh6pXTWE^#Z!VC_Y30teayhNs znO5$MJ$J{Rmj;%X2bOyS%l(0wBZb~G$3ZVil!bp4V+5K_wLuT|A9r`2?`ykTNZnV> z>*C^T*FG)b?>$y+9PT{pGzlll81$Dm-unQb8TOw5te?RC^ZsY|%l>~4Kl}7&`_G@^ zQbySo);Zrn(w#A=Ouv)U0k#fSO9G_I>hM)p|K{?wXh zFwzIy25yQ1d5bvRn0hSNU4?&>Ez2jt57X{VShFxeJ#6f_#=NV^<`O_9Df#aK^jVhQ-I-lV;YNtQy;{d%%~z8>|bC<`i~ zaCn}^qXz6;*kIyR4ePg?Ruf2RA?#I&e`y5DAxuKS>OjTEl8zArs{RnrOB>!la7q<-!VWDT8--Nx&sc43#J+mDLLY0lN4`tc>0AMML@Ww z@fd&9%LJC|*UjQZUzBKgv`O|J0fCOKl80$OV7KHSd*u9EX*Q$7Dve3us7GBF)Ly+) z%U-wUU{8z;2hY^|W(3hkyu+f=&{rYOL4h4>RRt%-gET`!N<^P}how;1(H=M{UhhNL zfy*HfIp+jbP*h)(XslqTUaYpjBc2H)V=`7-!)<^eP#$eZDaVq(CRM_t z%X~R&X2ZOTO;9)2DjsLWq08{To<_J8!M_TUdc8TyF}}3-XBZ!I`DEFK*^LavtOJ#_ zfrp(auJ$U4S{OMkl(&v%-t0r>eiY@`756lOh!*0{8MxkTau`<@F)o=vv3KiWn*#5#www_7x^d?YYHHOt={MmP!`vR@qB-t0?ohoAi0?V> zfn121&T(NQ{WiSX5NupkR)2KuI(%2P)MF)oUdGobJwpA47jI!aNwA7GLT6cgti4>Y zIp|zA!m&qBPIq>#{V^jql!e?$@g%;?SMldC?<(OM{G{(jU+)}4Ah$1fPSl?UPSR`K zZ}8))HV!+TJ!(ammCOYOC2`>eI#6fb;np=Xc%wk}v@4&};!`X>RbaIRLHPK9a7spXC+fAE zxN-a0<5LFN zjt7wVJWe4Je=3YHN_OQqjGf8(GYk*z?Fth0Az&E9P{i28&p>y43ER?vn|-3EjDd_d zd72ZRTsfdR6nn85etx{^?0AT87cThKrUTUdldtL%V7$dXghK?ofY%q$Rx?wabBF+s~R1dnt#$*RimG)v;G-3 zdeRUtH7>>ry8V=&D8QCc5<3?kC zjULw64b`Y-;2|J+)%dTSal+XxM`S{hf7Rd-oyo1VVDEWl_xYmzAG^{InhGa`@x9g7 z>e-ffDOd_DqnHZ(>#-HG3iOL*P$w;WlCGy1kx*@;IMPAq=nBjcwOr)yOXP4 zHbt-EWhtxKhED_gh=@pUwOv{UZX38Vlxu7{uxdV{w`#eEzk|F(Vie^pOd>7i(azrE zqoV_fj=a;f&p3xCwFGZ`<*gFg8A*nsiq z^b8B2(DBvT^1@?L(0uXy>z#v5@A-*-UIL8X@Puj=vUV~n|{j&=^_Dr;$g zJpzEWOH?5q43vl)0f&hZl;bmSHGxfnH#3V)TF<%s`1x_iJTA@QzF1lCsLB+BG|8st z7lMp%Q%+{?nMa7$qfIfP4eWW4nkhkg4q$o{Px|p#X z!03!vkeQ&LLkc}Xb4I(-YINqohO_NNlsagk9(NCpPF@^${LQ5fjArz`&(TW$aV+{) zrI}S4E5c95jb9fw1Qx91z!Y7bd0)6pByD{hyvSm`oS+&nS>{9y<2;%6vo#^R zEq=(5il}_VROyoTPv}cS(JY65jpl2tB8oJngR2tz6F`pNmLs1db$yMv{Gs5HEx=@LGXgH z^l#(wyM|o>nz z_q7tl(T%dRcobn?1>e(6TrfG9dF}`f8n_N#o=e)U0Y!b)sz@e~c7M=89hH9R>xsx` z54Z^u-_A&UirK}KNe?j0$RKThpE zwy3!IBY^4>Y^=+$THqMN>uG&+JIxa%#%QEqyMStf`>uW+2#XS715_3kw`j>MjG>7m zRos*D>mW-;c|h37KoxKy@I5_%M%NX(tDn>Kb(*~~3hbegOZ=+j4H6*W%mDa=`=y?Z zL)&!H=N+<(3cb_Pmc6qJmSW-8nR$7y3pyjB&iO}b z-Y8~UfiZ_N!W)O(0vCIT3!y<(M?30fl&O>Qi)!Y@MFy^84Ei%`&kq4D*{rC#H9ZRe zCydBMf_U1UOj8r$vKAL$Y>gS_KFQ(#+FM?`+RZJwQMhOJ zWgEvx&s5)CTXN72t}dfi%Y18FE>AEEV~AmaBH$PUo61{wuNc1;7zKld9%?*}RQ*>g z4H8psFMxsLR_O_knSTRt^pdHDzU~$o2Ooi|cj0xzShygF$8DIHc8|l@EjlZ^B9(6@ znGQS=m={EuR%O9gEW#Uhf#9fV{~J7D6cJqIC-#){T6^xm`b@7Sw<3Mwwzs1KqgapJ&T< znV(l#-}lVHTM}o~s>4|c2b?wIGI6=A5%Ejbh4uRiZAQsv*l{p2`S`4$BaAV(G>EJP zGj!9`jF{*6V$9J?*38^UAn?a0{Y?TZH4L3MBLL0TlAl}sDY^Kom%*q)kYQl$kt%{l zdeZjI#`Z`f!g92El+1*ICD9t)3S8~beLj(Sq}u#a$Z#J!)^YlM0|vd<1y%MN9YLUT ze60R&ZIi7Rgtk$Wo)1>kh$rV$%&no_w8~YXN;5KphPc$slsF* zPaBLwdk|_}3EaX)p$d_G)k>1~u?>3+XmrxH-+yV(`@fFQy!a0vA_4TA{Lk%;2d#4c zuLnQJfA}dr<@gU582{luMSs|MaIgIk^FKe>Y;BaIKkQ7ehofOUxe+exs3`HmLV)?% zbhKb}2$L9^!aH2}@g6RgmV!|ftnndv|AV4z+_+Q69PsMsYl0ONgafLN+3c`^l-EfY zj0fTX?G@|w`k-N*S-?8Yc>tDC5ZO&MQ1T+bQ)ky~?QrgUST~lI0yz?IAqUM7=vV5M(2i!xstNVRz@PWN4)Ske7Eo`>NkDwv?)bZ6W^RF@AM*lzut zX7hiI&y4dw`yj!eKAIc<>A|P1&;0Yh)oT5G{{Ivo=lst&_|yGg!Ri0$J@`MK{`WuK zY&|HS{wJt81oZ?+wGj~zaK*|7Ah+H=7F1Gve>r}~#Gl#i<3PP@h^KS^!DZqHW4c8Y zsBt{WlgW=78fu#MrvTVMyeRSD55tTjNWH%sQwPqiwMo)b@~q?z-`96(iHuqSgFtQs zb9>N=p^X&83`28Tz`H+JfDl{Pys4=bO#a z^WztX&TyrxabwynYnNpD^ zgB8>er;G}N1skgW>FR|-vsmA?wW#yW>G4h%z1K`s3|4tTi7rJK0*>z4&Npybbz*{L zq3Y{RoTDR=+Ixdh_T~$z{~M;$Jdv@5Pz6~IFT^TIEUh3AeeQS2R`$^=MP0Jxa%ZeK zQt%y(vfl1KE007IR_o_Mc1CBUi zFL-QYkB@=*Rdl6CzQwswyE~g3nxXNC=4b@zF5Q>1n~Qn^P(aId3vBv8Nx~pJL9CG z=p`fs5i~QI5YD+Pf0ufo#W?;g#=IYWPtt3BWzfK+5fnqYQN|lF4xMBGQ4k1SsBfJ} zPtON&?tKmB+{h-1BKN|Z-Do&QeSBZOK7k27-9181OD)TIOVaMTIS*_DtA@^+D{M4j zRZl?-MiY{)NIl|^T=;!k{j>JyymzslCf5aBMxFPv_Vh|sR#EY$Yy_-{)0eGGko%XHT-}3}kEj`oIxKcRB`O~>#(`lk<#-}k^??>Cq zwkacDb=kmO|6b+U(N(J5FUcDqk;#Z$oW@joD^4^1-E+BugAc11PED{wc5PrP{$e^OdL>(k;bxgNxs!SACk)`VHU59hiWO-an`oqDXOQOVf1R;jylG^Yjwq$SE4Hss@Zf|Fu#5I^K z0mlyv8T>U*-55*o$HJX!keNPYxC5&;Fx6+MtLi4sC&>*uT+9~Opi!WFX+RL4LB8Cf zxsnzU9Bo_kMG9IfN*1R<0FDIvha9SdB)1d;`dkjv;pOy_vku`F;odFSYe7` zzR?0_}~?WI1R)4}i>tD{-3iMIl; zIj-DA5uXYBJn9?Jr5UNZ6o!z4no%!G1l6r>DKfxaFR@0ziw~rjs4cijj5wxWopgfF zp6{HpBTa*M`gl(4mLCuez&NN_C(9spOs(a`jhY12a^&k&J%jj1G~_igWHj(Z3oy`I zDQ0pK8&i*5B9b=NpA{j-V9ze?r>DCHr5La>W*-bnSa@K{%;=SBciGKOC*$)$9g4@t z)+I%0%xb<_s2Q!IX{T(mA*1)f@D%c_I*~sSYO9f^6FRa6dFv;rP(n-e=vBHb%wkeE zJ|LJWnI1ygskGK;uoWhZ26}DqHsJd%Vek(~7$Mpw=v8Q1 zU(uN#auGViA|(np%oPVxBy~UyB{ES%4gZ8EeNBlh6_Xo~PfnkO@1xNWN|+~V5u&)% zCWnv_=<@7_6*m-`{`46dgEuS%LNU^w+fZ!cAKS(vtZWZfTsDNkqGO{;JyKR|tgYaD z1hIbLC_x=F9xOJ|UR*@4pwhBf__4s5v0|z)bh9F{YYlhZ!BL3)d^{7d3R^dvsJ0~2 z+6p}OAXgm+lE`%eK(oVhJ2N$P%}ks}qc&OYkmT77q*~9}<(LiCSF@L$f$x&lh z+yi8B`c9RrGiO2a8p#A0tr6K{D7A^@@B+Ml5l=`wf&dqos?pa*T9#E&1!gQ84XGM} zU^*rMZ3yL9nqVh<)=P@$!U1dwBMw^;D)8}|o3t1uvqfG(vmq=>ikKGw_E);5{xS9ZN(Y*X$s9>@K^GR z9r2t zPEp4%CD}&-NO2<3@|fsTJc7)tH+aG%z@a34@AgNFU*O1ECLlocvII9q1y_`bC7-} zw$4GTTOve2mQF!SxB?mva{hzsp58j#cQl+>D=c-%bEPD4v&v6rvbX`U!VTwOaqPGI zorAqCL4f5{6r*0UqfZS|+eUUR9S=y`(8Pp{MoY3bvl$=+93#AGhYEh8e1wa_jCM+D zo5jdgF3WM})U1lkqr+@c@N{Pwaw1!;r_jU?xK!g}fGQ23bLQ67PpvZ(X;`CWMkoY` z((akKK2T=q7KArFo=|vkXyZ)`q^?QY4xgMq2GmZl6zj$drch`%C-V5zcOeU}+ER`6=oAvT2W2KW z;M8)WWg4^sC9P5hm}`tW%DY?v0gdk{zHA{{#mc|ANKzfysEKiupom_aa$|o znQ9%d4%#xq)flLHxEFa^`nj^yv6Q7?H=$&vEh-*u+lvHk`XUb@V|h_3XDNzzN)g zLHdmTs2rMz6WN!2zwE4u?v#{`0n43fIS_$sH6cjs&g7g0l{!8(rVF!tB!y{-aQZ`} z1TvCM6>cVSo|eC1wSm4q)RY8OocKo{8@M}%e}Fwj5TP$3c*z){ z37L?SdRgpa#H>1gk?@$66u}<#$K4tmYsFk)+lASp{?1S>yBdllzs5%p?IdC2kgkImF@5h+6XBgOMJaf zI%!Ni!>K~TWW^{uLODS^rr#wTAIq)e9v-&DhP#y=0OFy+7lS;wzLJA2{Rtf)l%hi{ z(yiK0vve(==3tkYlsaPc7OQPjC)xw(}qsVc|iZL)`rpi4zDX6`nE+H#9=B}m? zD#D6CrZ-BlVWG){2(P&!cX+&TH8cy7sWO)uc;F$El z_jcFtxIcsFGV$c5rnz0`W(pQnO9`y#Lj=$|k5L9;V-v70F=BxMq~2w-0J+xkWwQ{I z$TpbB?=VAA_Sv&?aW?9AkuKRs$sj~1rYU4MR$B@awLv{=xoZLKD)FIlWK7_Y0{sr# zaqxm65@R8AbI+}r-{tnKy|3Myyd3sbGFWI=5|pO1wxNlQkoC}vr0<19V9WQiB8mZP zH8sMbnjIN#VNgAL2kZ9q4z?>}mq~1IJ6c*3TBefH%sbCKLDs$AFa@LyhP$#-j*JagsI38CI>@-4~`&x?^{lb3r;VR``2C0=Kqb62;bxsh|}JMnKw7O?g2T$ ze_=!hom4_~{X0c4v)A#3Iw-(|;t!gR`i2q(B(kd82*)S;PY-uaUmSP7-FOL?imJ+s zE_qHxoAB$mJi!LvFa6=RUd!GG!WvQ_lrblkGgoi8u@pOX!21O)b_Nt;w;Az;`#Ink zrwSTTI^^w$;AylcU?mWJZt4nq4#o8s!*~QbYqLvD^gXSS#%A$p{_XIk7#KcdK!($A z^+shL(53SltHWqRDBCO{o@0Ek5n-%xz*6?{`XAJI|FEULa3nCD%^7h7rcaoU23q5F z_z~cG#zwH<)rZ2(pvhk;UJQ0Lm?TNKqrlex$^AcP`u~22;2$5&jsJ1~;e&@||KIk{ z{=YxP$MgTC;2)oH@Q+{JYd?rupKi7uZa(<+kL3PqgMDO9q>s!G^AYr@%>!<-#*Ni9 zR=Uzl8+X2A=BQ4TrQw?2uSMcH--^}K#tMWHX}~>SHmI{%KUtdL=~wWci>jY%65G>MPI5_@jz5+gd8e2YL4cIuyy|b_V)^a3!}l z#i}00!Z#4%alEs9TJ>>6!LryI9>t2N$9!7jmop>Q1KbhE+=pxXzBDf;R_bA!G>pSKVD z@&O~d82(dzj1EJ~$h$n(Fp(T3m+Ba2Ul{F-Y1ANE;bERM$rJMuX)kKY6phtA)Ty~f z!|FQJIZ6sUHns0@oYqsIZKwN3l)JYFW>mv`SGyMB?<57E=EVF?jaooz>A6cG$g=Hr z2@VH8Ivfr@031dPhYj=Fg~Mn*9N4CWo`9`WPpD7m=}Y19_w@q<)+gdf z@ptSaM)^8)3CthDS|sbqzcR*92M5wC-%fnIC4nHo4%OIkA1<`eQzBJUFS6+sylkLv z{-bR<9N*vS3R(cY9798x1K`_jTbu6AF*1Kl_r>`*BPBQEiMVE`=+1C=RX?|D0?A;t zp~kSlJ47d`6xr&zE;A6~R$CGP%J-yKrp=3FO%4@%iQohsV{%<+opcrc*i?EjwN33S z7Nf-~q%Fj*04s`uuXqTfG(y3J9U7P+8q(m;9dtto@+|>}b5ncYjj8 z?soXN-(WZxr$twQ2PQcVn+Mv_(?!}my6OGuF5Rgyd_pd5Fc} zas%&#z{k}b#y~R|&ySBzkI2<9tbF8$h+e(i+L2^Q9X zZu)qD(#4E=1oWo2EKPl{c#!qJ=9mq^`WkDRKBB21pJ13ye~MVK5n7H4>B!1J!fu7o ztggj2xTbdGKv!OynNi3UoLm9N9lDZ*(cq9|EuI4@4i2;rN4i#AP&Px8#~QO;gIN9w z{#`~Feyt5B7gw}DKjx&mcm}bpCGwtV!(j>g510GhH63r~BL3m`MJTOmpN*rjG0EJW1oucTZc$7<88qFt+a zLl${vDQ&hfhmG#V)Zl&~e*>TD^Z)z<-Tuxy z{~vtT`mCJ)W8>k^=l@Ufk>~%pzWp`%KOUk1;DgQk4>mUfm%mTr$r;4f-_1rN3=O;J zu|6x2$N4+l=>F7+JVIuNx6ICAXZ&>cE6hgPq;49`Bzv{`i|O_fI?O z+lgdnF5}mH2X)@OCd0|7UcYWoP;7JEV_Po0ylV&0i2mqa49TAGS^FH+EUF`n1K(DI z%>4$N5e{@ijg-H(VECpTR5ZKosAkHon28JC4ObBg)N^+TxvE^`S969Sj5Bi##-RAN zetp`wa|dibaTL>rz9ef#dd>En@xxoE@~Eq)P+i&f{8i_-zv=9JWe#P%&ivfz>g%0@ z7adVrmo?A1ZD(xke$a%p;1OpXOY>n~Bx&!ap0U|0sp5M?8(<%>>R$%|JnvCE8Qg-R zQP~YNP8&|OF5YiNZ`~1?LJ*;Ydvfndiw0We-nkQKITD4iX}kPM0ltR$MKN_=5%$&@RS^2)#+1XPIt;6Dg+oXEGrSDDXuDI;D z@4`q;(!D}z%A20j_zmoFeLr^YU-;HZ?`yh0&}nWm+K)w1N_2C2a(cXf_|)cnu^#oM zv@xeIPCCbXJEuFgG)oqjcsUEP`Blei<0NW2@J1`zU`TC!EkzKUq6-y-y+{?`KfxmI zJ^rN{t&2{Vg}Lr=U)Zjb)LseAoC;i}+j&T156&@=IeqD^=-oQmtIX}tRVGS1uB|}; z6nJ@Q?nf+0u#|6d5T1@UvavIQS@cE-livDy4=<|l0v!fm)`fn;m7;!Boi*t6bm#Fw z$L-+)JNQ7&e|fC-l-qvsAv?hPGPnKldpEBLT09*Un{uCSut%c5{Q;4R%V}xX)2`G1>zPN}%F9A08bnwPH><%u$D{cmD>oI0%L2OJ8!7LTD zsFi@OLk)GFSY}p@asOqoeT!?~U5p$Q0!+}R)f!TB>T`r=t43bb$q-^!=(z#Q|IAV%ZEbvN6 zv@WPKM&*6Fi(xI32J-zajc_$s|w^&_&y&_<+A9O_F>rG){s1-8?!a;cf~9x7du#ltyo z9j^#(m}f_O9m66+QQgN>`;yFi_o>B0HuHF-Riy_)6gFg|RZcyB+<5mTQz`X`~htgdkDa3G!R0 z@*f?cRgdKJ&m$oyMS*}t@>91nR}~$p$!zZn_auiJTb9N^ST`6Zc$;B_wx_$85ZaEI z>j(p@3!Wbo%QFnk&t{PE7z`mN;Jp?w0&-!l@I%0y_ex8n(8qE;XuZ@3F6gctZ6SE+ zO&~peJ~({oT~z~1e>;3>0wQ4W4Ao4ka04c@QlaPTLI<}7% zg8;9B(iP3I^vZA;Mry04u2~<_%?Mr%t)ILf8`K!RnGUq*CK>dPc_A7u#B|wGQCu2JJ#2mXZc&l@y{ub#u1| zJ5@=<5KAV(ARl-_^eIY(WivIomwMHG=(xl_Hhnj#8QA!wLa)SZGXpf^aM_i?$~G|4e2 z2*Aznb}agH4;TG%Mqg}DQtlD2h1QHcOK83UW0c^uD~wi%M-SqSxiBkXjtCz@$m7l! z!dReNi#Z?Z3B{ij*cR@5n?}B=iAH!Xqj#B$-?)hfQXx)SCv?E2ilD}q@wMIOJ&c28w8&K{q`V9|uX;nY zDx2z%v}ht%YDx7Za{cLW^$;&owLxA6P9qB>RIARQ#>x;KlN#)-ifr1uur3X`?dHLX zp7`f7m7O}5+bfTEPWE@ZyZc?Z7;xU3h+mc2Ebg@%Ivza|<>5JJuQP1LLg_K|;8rQ_ zfF5%$hir^r@7`sMX|L32>=?8FhrcSK7&N?!<=F&7A-wmLOsh0}FGQk4XV^WtL}dgT zk7O{@OuZUj0)YHb(C$%P)JN=?HpHAXCJdd;3OXuf1s#>Mf=Uu$gSL+XLEF)gP<3V! z2Q;{Ekrcoj0a;`l*@`k%iANY^I@f?RpUj?TH~tt2|v=NWtxCEw!x4irx#M=e6oSBS}c!(2-(MG-R(b5^EK2=7~>{ydcxc z-T-$%h`-lKG6vYX`feSfh^>!M9#!qPa!YIbK~e=peelsO-@(2VVrvn5?q84La`@Qmc#1L0ZFJ z2H>~^KPj`ojK>udCg&JCS?L*}MmrXsD~s(9?I>X@j~A?I;XKw3H>=S?HNj`XRx@5K zi*?IB6QVvF)Gs({<2PYjFubZ*;EIb4y&M}Qo|M(=hVo<7lpx{fl12s3ItfM(C3%Cg z*EvDhvz7b4lqcCKraikZL=67~qF27TNKii>!@Vp-`zO({2a$ZNDhO^rpcU57ksV2N zn5AptMwrh=c{fK|3aXD)@lb`r`FcbUhH$MH3ac@kF2Q%X32LNrD@B&A!wCdm2*5GxVzz)#dwy0>VFH_0|;>os#<7;6a+>c-n30y+@_W4_cAs8zD3tT+wNQy-5F<*!1gKSj z5tq&p3^aP0-vMI?9V8t`rD4Z+>o6Hs-8uFp){?^Erbz#37Racr40aG^_=*~=#!7L^ z3^C8ko5Hw&mKYa(nBr0dRfbZ1$5t^H)~v-*q6Q+y2dW5#t<>(#Y1`f_m6eY;GmTbo zX(ZH`_8Nk1Gzc5(3jH>i^`brfM(r>Ie1`!mamP}{=y;;aD~+JyG(7ql%2SbiQ0hJb zr^q!ZU9(Eg8*kWRx(W~51yzOw5_EH@U!Ln18;yp9shqaaU6v>B#p<7>k44iOL})Js zt%TdiXP(Pi3oxq=1b8ahy)3}mGw0!2i0k{#F_92)VIN|3eJgQY8yVfI>TEnx_H{O< zBULq77#TqxUG1%?#gNK60X~&?wP8_F9}k%2Jb8-wyX3c2QQv=o(aP=VOd}bSEKz3W_Lj08Iv*lGP1sXt+sD~g8;8! zAsf~6Ng}~GHP40#(r(A7jKh2aHe0n1$LKEO z9or_@FbMW|5kue$#s4$12DH&#GiRGXv=rmT4UnMC=8Q##KEeE+!1nVSvilTf2Ew)m zThQh;uhHxe-$iwF*2Ro)H$4#M-_P8X320ntL8%!+52AN#GC?=z}8bzdwIKQx3cbuc8OeE(C0i$Hr#^Wae3Dv!?{IDj0 zYFc~c5JCbG=76_mXLb-Jn=>O3UiwCJBC$sd!j7NMBhsfN#Q&s;3Bz$J;boH8(2`^} zj?jgLv+VY#xXqvLma=w7UbCu^_6h($E8-ChkCU{-jHs&ZWNfbUWXg6OrXP~F>z7k6 zi2rJfVPymJU?SOVv5hFAu9E|`-Q@g1q0|}ig_|0ZW?VHnfTdgBzU9n#elkV%p946Q zZngL1E{?Wp12ZE+T%+C+I54PTG8ov#Ff524gm)e>Fqge*wjBS5&gN~)K16>E9FY1v zR|hEO%tXNwC(N6b;TYm(%vot|8zPe(Leh0{EsTMYII=t7BeZ65DcA`%1IH8H4u=el zFU#Hq!RQ=xX?^(OS@(43=?M+X@LsU}3+Tf)xYy6OjHxf&^T6Bz!6Q%60Wb00trpO# zi!~kel<49y8*b?*<F>!aSk^B0;wfl6&TgVN6QEOP@nkXt z4R(sDf|g}7%v(rhyKR}rX*JrpIm~%OY4gb7=5d83*WJs*_eOcM9T@rv1Yw%uWwI0m z?G~`*&J;k=^gHJ9)^U$F7MLZ@h$upNlFl_;1@#EDPB;>62Ye5J0&i&5G{2aGIqde~ z&iK_BoE|4vkVn8&r`U_sxx515k%?(zVgmEtww5Nj#to}ouJanZ8a=D7)(B|S)ehFc z2{jsyO$5ll6cA)()5?tt`{b{38T6UaT7ep+poJ|yc0 z=H>&8rzj#UFP7tEA+I_db(uU$Z2Nqk;}x3`(6ulfxNP&Z5os1(!io3_8dx?sBZPe- z%4YbS?-sFrd|~pLhsN$Ik@XzJdP|+3X8!#}*Ge`*U47}O>s=guwC(V04Xs|f z0Gfu-P`ePz`&y4O;&K{lMa%K$8Z&zyWCZPnDL(S%D6i5DKCdDFu5dmG4u-UFXAj{E zj_Ec~cJ{5*g^D*#;acxNc}3PX;@^VMwOXFKO;KD1x+cON+jW!B-k!SC*+8azbsImzaYu(%FQ+4|(7?hbj38Gvw*zaf#=W)<4H#kmO3Sqn z2v*BySy{zlTtK0NwQX^H)uq>uTn)P%8Wqfah;inG)*i7^!K?qVs4uPu?6^M{0X7!f`@a>YnXaQ`+ThY=R15g$wm|2O_8w*w+` zX#quxx^V`ayDwPp%VVOxXZ%lV8%VY{Bbpxl*$_`8KGQDm{)#K zi_(Lv;kQ(|6yZfjn0QT)U)x=>GO&Jacu{XuMQ}$&hPx^H_%^6 z*ps%^v`ft*QL>KKm&4TPrG2ftl_=w!MKioogS>dSnzTcCIdebmy;$Wnlvb*QnP3>+uVcz{FKrGxWQja*Y)DO*yJCIyQ>R-3Y@Zg_y(`hst=J{Z3dB&;4dBi?tl5u z%=nK#P5$RkTkZRP{Kt*Y9{e2t@u&EB@gFJrbL-(^383FO{v(HVK6ipTpU({GOapzM z<@pefOr$Kiw(kiH1C^V)>Z{fVX*79RokMDiAi|fR886uijEqkNmF47f?#oN z_lBj#)PjXgh(=YKhA&#L%c(^$0dG)VRcC0kD#NI}x^keQsy1sze3MNJybA>!0bvl* zj1lX!tYp4q)ZavJ3H5d(T4SX)y7G|~A4Xl+Xy`Jn$}%lertOqL&O^VtuU<(}Zrvn!x;SAL{fr%Cl&v|yT$c@?jTTDo?;+o6sH$9^qC zvMvx+R-wI}{~a%^=XEeD>a`OY*Ab@fxMziW;=#?Gwc7~ZQas(QU0TWyH%8M;4tH7mEaf^P7P`_scy&}+!swXFyQRQ$n+pJMNRS0rBW2&NwS!1Bt z(je5Pztu2s=GC*dxd?6@IWd$0q0)vgTsUl_7cLvPiK%Ebq(KiCy^T7ix`kULe0UFC z>C9$kYT|y*`0#J@Q!W1w(_!&pGC<6c|6BJzE9ZZD(E3^a|0zCF{-+ghUPTHUI000v zeXsrNNQwXV+ncRcSp%@Istj$MRV9v(hG&zQoQ&bxO$q(I#k2zUV1jXYIUo-9AJ0hv zF;$~D^D-^O(`$Zctg6UaLX|$~9w+A!Rm;DHwCtdn{h?OFI6vU;)rCkrZz1{34>*LQ zojo;-!<}axTV$+gVtg)2!TpS12-!SaWdEpCVwl<2M<=D%S#DpSoF13nlfJ^1dA4)< zWvS3*TwK^9d*xxG2LhFVo6aWQcfMVEyG0qMRQc}C^L=wJ9CV=;KreKW?7?|Om7_ZW zs9+3%w*Xz%9zlcz{OZOy8c*|!o{pXXET}2m*m4T7+omod5+I@x9Q!A}%zDWVJ0oi~yTMsr{ffPV$ z*Qb3YJx2TYj-onPgy%Pki@t2|L2$Du@i#evlF1~^ASIAY6VxA;A0cUfG$)%7&gs^N zi9I+%CyY3&_K&*zhtFR~y^(r!^x_nrwf$pA!v_cKm!K9zn~+vuW}xC~5y}lLJ+FO|Z$_Ww3N*Sf zrf61k$tLy0#Jx3sh*gc$g4J|c1*7DgZc~%gozMNSp9hQvTMG)Vlk-_Ca_ecr!Wm11 zgRW|xUZ{%L6*O36wzajEjsjzp)!7&tR?xpwuRqy8=tL_k4Qve6LB@fgMM-3!#FsmV zdk39H!$rhl)YLO+jyq5H z6~pt}{lmS^H>I)ZOL%CO;|2WjkI~26ka60eF3hV*{3iMRl;UEnwFz1wG&L^!F)oTQ zfI&-P3&&~SW-4$R;$XwLzMYC(O-Z%Pyp!C$azRBoLipnG=6iTs0;>vrT|ZBWEdqCQliJBH}Op_ z5(m7ZMwewdiVlU&ZNONvT_B{)R*QuNx1v15{2&y%eh4j*b3=sVZ|cC**s6LBtB1Kn zpg}hpB!ehT-pm2w7@#Qk3??NN*vsL|s03|Os${cmi&?_3SXVo`v2Z}-!jIfux%#WN;S~8y6vn33WA`WGNVBHsR{1cM%cQ$Tc{7nHq1eh`O95 z6F~F1-uoRyw>y88YR9&!^aTCHdyk-JH^SfdEL~>1>Tm3 z*5EzHQ>V&xh)aSN)bBeU#a)E*&Dzre$e>!5YTCG_2z8B@!`YN|qOOkA1O%=g2215A zI6^~rn5S9F6x0$o2tbe&LyexD!>{*`j}Dng8~%qp?=uZjYxIV(JJrcG#RvzujV*=c zi5M7Fj67_|KqB`D7SrB6UwGSg!}4H_ zXfr(Z@n7xSaanQx2a=ck@E|BI$BP`Cp)qpR`mF{;FZ{t!S3rvbybv+tkP|$)cJ`B| zs58kJ*F#kmY(R$vaQWA@){IRlc`HL|KFJM_LfaE|90`QfFI=g@MQJ(xFcRg}NMyVkY(N|Bt}JBi`N%kz8lwgw zv>UmS#ujK_D=jox3D9;_LoD7L9r&ufH{tfc35F1- zV9&V1v{@ll%&<(JszO&3*4FnxL}0EK5a7)P**p#N3+*LuG|?gwqnMH+&*do(LeroD zzbiT#*f^@}StwCC1edvUX@GVC)a+SqTwK-jH$zN^mtbrGNPVH*9V0?NF1ZMchzRJa zS_XQ4X48m$eCv~SHW3PwAbrYK(w{lh$5|uh*%jladacrvSt0F*?RWZM287Pe9{hc` z7Pd(ND{u!;yUS@-yp6~wsNH*qRIG0fz`PfygZhA${qV)J$DQNu$?nc!GrCK9l9sPb zq@Dm|{UD4O4-6B{#57i$Bp!~8=a85HSTS{ztYr7#j2`pOfG`tT)AYl8klyyEA!Mt10I7F|Lp56+`TSk1EXB_jy+!bYoQ>bOmDu&00$81o#t+ zh!a=v8zov8B~M;K{d7chTvM>1CQo~jxsC$(aw}son-NOnpxYaNJ6dbKgq2wSE?sWO zF~@z3xuFKEcBRl5%XqC`DKu$wviRtGfLBR2T7F-kv;-2zpre9_dvWSEZk%LF7zImR zIwKjSnkF8i6Vo0bN1a||Z=y@gNR&l3_>HbK@sli3U!;W_-G~|sV=Z(YZTtAffsQ6O zW*m43;>ajQ>+q6~KI2rrAc|v$j{pGNb*isDFgiVUMqwP(0UO2n>%@35rVxO3fU$?i zMzsgsDhdvbY0415nN-IEO~LtF1Cr7eVYq!g&sXU(LzN=fXQVeej-RYd< zscJFaXvnbm%z}1!xv1K-6#8+z^ zP|$InOH$NUQKYqe9QR252?m8!iQf(tm!5A zd7HUuX2eddMGx>CFf-bs_SV(_cQjC=)Y?*5jt_l`VE_#iGMSEOCqz3RE1>$M?=16* zYchRH<_?d^F$nPb2&Oeqg1aSL_{dV?%8(tB{1Wn6j%FabfR70EEn6RP z>&Pn1ZrexfIW5QBvQ@C!Piaa1p{^Hv!$##-yB@-X0L|{6O2QQyqS{;#eU$Ed^kc7d zX{0)4iZ?jioTVF2xr}NbT*if5#+^UgW zgCcLWl<%vuXK2#k3A;a|8mz7p57Kd=PYXxUX3-mN5=JnH8`i3Q;m}~KhYOb`Jfd#G zyR90Jybe5r1ABoFEl>|`!ew#dC_zGIR3#t@Ek+4O?S>KD&yy5{b9Fp$3SI<^7jHi2 z!`MdY4X9D7RsufG^@d_ z7Zbl7K7+9;UHIbmlV_*eD8!ybFh=C4Hm#xD)M%*Klx z*~G1*NtU(LaTQI1e;q(BHX!0vN;z-UiYvv`-*Vx)`$vb5pEM)&_X+LscOO|G^ zRN!p{f8jLx0Bc4%EN{uw%=QUBQT_+9Y658YOG+ct-6X+1PjG_Ow0*!@s@?ks$3Deb z!wKcK-f;G|Z@@7E)~R|Ax-AZ{c)enqH_E*^%l%G$nH8vR-Lr{D(^TPkK-L^hW0ygu z_%&>v9^+SjtW8Gs-48!T^)o%julyJk-SiZ`>4#)&+O#)5{9;AosUq`K9f%n(_fcx)3ay{(D zqi83MM>l^+7L5NTT()|^8Mq|QU)eB5V$7-pU?8N{ZnkMf2(;BynuMKK|NK%)eB_6G_gW#ibW zGW+>q@&?tEs_GrLD&2+SEua5*vfQBjNJqzeo#W`ZbJ98fy0ZtQyDXI|Kz^gx)z?Xy zM~3~5qFRh9gc>UJ;Y%N-Rgk>(-=X4|sVu1*YJ-^Hs?(4}TRI%zyDdD#--rqDB^}bA zjC|yHWuO5D2%P8MG!T?MDEU0ryjzBT2dG@54l8y;5+#iP2~ zY0UCLO|)Gh*6*3VZAAa-oH7_{wiTSAqt&RTxYsj!lZ$xJZsJ6He=dqb=pKFhb9%2W z%qqU=s;xu%Z5UB)#H2tcE`;k$(D>A>n%QP(ls&9e=VXNGD7N6tPskYQ29n9QFvZo? zmz?4SRf~$bZ@A%Qzv+TaLeLhjD(RTs5u6W=Aa;5}w)!gtD@0E~?qYqp-XfHKjAwMx z9SpDQMQ-CNV{V=3O*ZN0B2~OidLyonIL<0x&wE|0wjc=m>Cso6!|p-nkh?4t$cp@G z-E<^V-wan

fDedKz!lqMsb^T21q>Hq=W=8SH4EA>zM;NrmJbFUrC zpUS2_>6u2Pp_&|-Tr&K#=Fa|QKtDv_Ev}1Ggu`sW>T7H9h;M#Rzv_Y%wdp+J{Mc?O zyfn~IFvMy3yNzX|)wk36U03W)OsYy{ygS^|`~gX@T?sIEi)wn}Pua0#&(BLRz&9|I zZwYB%vS@MC?OjaM*Ta6DlDdN7TR{WQv+1OlD56U>a5$=I+S3)Qoo{~9XD3~158lAR zOD9AV8ZbI*8s5@u{DBD1YUnj&UjF_BTTlSvl^4*`!qQ&1xR_*bbPFgh9Uq_k_V5(* z*tp=#Z_*-O2%<)ds5m;3=zZ{K$+Qrsk#$Y!q}yatnsKO#e8z1FI||# z0$)WE_e5Kc=!CZ!75fq-NiGGA4b*=Z3V@pOsxxVFgH-;NDkW0j7R4}!JNk@obRn!C zX?8Lz09(H`s*RS=euzrP#Hz^4$r6G4GYI3t%brG*8AR{~T2f~6SYrAR8k&1xtFza` zar6p!KbY@#a=NAJa78EC!;dj}P=inGP^-`$wfkKvT3%gscZB90_76|ZPH@nY7zf;> z=#^?Lph#6)#^|I7xH&W<7w>+ze-y3!p=l9`H#=dS8eu=_jlq^lL3w$7d5fO{5+3Lu zqbz$JV{S@5jDS#fj!tZb993WqOVAc&l?U+Xz_IIg2D$JO^`OHS&G=LubZ9ssp3$h` zQU$*-5`-BfO^cgu=4@WJp^nkyngY6OOZL>5kB+wNJ?Y&2&X(m$MC^RCzq@k~?HukL z{PuU9?cd(Tq>guuk^^@x8S$39#JiVtP|ofK;IbaH zG#VHOWHIEgMdldirqQ-NTane1hpS@&7e0Tr1?k$FO_4kPHbvt%=(Z8jFV%5*+=?!m zE#Zy(B)QyA2N{6ya;U!0s6iEvmREG&x~Z*rr{g}xAV1BP>*e^ynXAc{ufd23LiqBU3>#pf19wku{p6UNN`lkO{bxT zHASWw^vx8!!E5iiBe0ll_v^v+XhwG#T5FFc#;wkSS%ms`?O5+XY|~^kq)S_43*t{i z&Y?-uWozMnrlYyk;lQIFFOxiv&uxZ>fDEU`0E1KjAR47u9m60BmQD3xtxf!t%Gv-D zVp%MPPU37E=KbOMu&6ux5;`^};K4mzqT6h=pzCy&Ti@P1i`RGH?Q*DX)lGK%fAAHDi^7U$Vu z4+)$GsNogMk8}}J%R(uGP!8wpb)?M>eeWn1jh$VmZQW4#?Hv8i3jbwtST|Ja3s55( zuTZpZ;*0#b+5`NQYWK2BP?8aSReYteU?%Hm?V{i<2BeWtpd=klzfMZ;XU}&|y9Y|N zZ^+3h%(nSD+3=J%5OV#1bs8!3XW`}4A3zI0ZWxp|7y(QIsR*+}-prxSySU3=9Fm5inZL+q2 z&qJ-Q5E>EU(n1Gmv>Mgh>L0+c<{}g%s*n%V8PQ%bO*JZxi||PSM?pUsRk3A@9)llm zLn|MQ>PlK^tffj+5_Z5aohCB~p}qRf zA-*#KZF>a&AMkQs{w`kLs&W!KGlkBo3k^)6L3N?j6iTZLO-!Llb)mu(Dyj=znL=09 zg}&3iTjv>MgvqAo7v3pmshmgKLVSl=a=!&YY!4w&O*n~%5J)d&ISjQGKu_F31PB--Agk}YAs1)D2_$8XL*9G&(8r=j-0 zn8oKPS`XR5wHEQ6&%f3}=U(-xS2o-RTaJY_4pj`uyT}o9Ii?w$QPq-BJ8Moe<_&>b(YpahE9eg5ff6EB^(Grpz-%xfxlQTK%liV zun@~FkqQ!N7c$%Lu*bH=9^3ZE_=8~NEC4!xzvX!+>j8ZJo&)%Nu>l-(ss`}rJqPe; zu>m}-9Kb)k=K%g;u>l-b4xr}K?`3C1LWuGWw}fs}6c1y)+vj>osIHJtLt5(fTEnBm z6@@$ssRy=qbPAW5K%&;y*Ihy=qb;eTyGMt+JEx|wEF0LwVP4g&)Ou;9eA>cS2d>&U zNK)wjp-fU7Fe6j`Ltts(Hn)OJ@^lEp990nBjO4(DR=G^eozaI_+VXJ{fNL16KLYfe zKI75&B3|U)!WjwNIrr7e;Q$hsXOob%nf?fK4>`_~^e|(8IQKsb-?Yg3x8hwF;akIO ztJ5c%p7_Rk=wwu~&nt;)#>B*{z819+A2gxUl`^bnLaMrhuBCIux7d&-5}rF=A3;avq50y8>4_Q-yh}xqH`O9!7)Y@ zCS1_7VxJJZ@6vO7H)rfX5LCvl#k11WqY1*&62jofx1}a8JU4fE_PwQMKl}cCz|U;| zpNkLD$DI6s57ZCe|L6Y3#?SsgKgGxQ|GB{Qe-D3U{D0c_!T+ayfAfC(L;3&wVmL?@ zuSG6A7p_Oo#nN0~9OF4-b85>2?@s&SXK15x8D9@Cr`r9|;OeTtrl^gJQ14BBd{dgl`*=+<1n zn;HNH%2`hwpr>%BkW4Ni2YZy?T%KhkxCKo!uu(d@@x2L<@+$(nbGWAnsS6d9gC8Gv zcD`y-p}ixzRyjE7m@oTJ=<6XBf3l-rJ~=w3zb_7VPxp@wxeYGAe~5n$j&^qr$YN-p z{~n#r|Z{k=Fmg-erL3X_KJR z)Zz_Igc?HmRWihp6&l? zi%}_xCzJSwEFb6;e1&m2@VW={@$T)M?gWB`xNceCbp+mYu(PHqxZ&y(nPc=KGvn~v zZ?%4uxvk_fR$O~8kKm*QvmSQlwGFfR9=RrHdlDQ1G_JL+d{#pTr}VDWg5e!>Bbq-X z?`h`MVYYD(l+C#Jz@~}qNkHFgxiq$O1>0a`khFjGk9Az%pT+_g{W-|asa8? zraBi7&CnZ;F!iPP9tQ_MqmorH&-jTVC(JGla#nqsXJ}i)p89Z&2tcsr!?L$# zp*f4Fms~pNm=(%GeM{@_IWn4W8!mf%Z}*1q@B`vUxL_57T~Ye>PBRtYUCdp?9ml&k zg#DZ;{IBUVgZ~E&dj26qfO-7?gNJ_p?@v{QpZWiv;^XlDyy7SVeEMsf0sOP5_1R{t zy}7Xw5CO1KGdhd&VK0JHJ|_zU2;|Nz+baln8jnWEP^|TnvD*F#7?dLCG(;=++lmg@ zts_0?Co;Z(o|2b3R@K2^0)b!whEYK(_hSF>R0%$#sXC{M`|U0N^|Q`1czKyz`mgW} zzd$aJBIly*Y@A2=C4`Vp<6=6A6%Sj_Gm3xy3W^~&U>Hp}tPLZSBLiglJmDM*0|7T* z>3(i}x9^zHzV&~wL4McT4Y%w8%t)1`IYC+e#$}zt3N}$){R6fX>Mc9UkF8$5rh-f} z#Xn_dqvVn^M9TUc`TYXCO5oKS^(`@d;aHahC%>N-&(U^$tR_{rF37-t8qka>7z2oC zkP#KlEzv_zgCHKMTKdY@MH?jnbaxK+pB_HzDDa&|2i+H{7FO7zHaV6s3aziEIi$ce z8S^Z}mMII1VDd{{?d-Cj#;7}udxxym#6EELAW4zR4t-4k!ozg!0>bh}m=XS*b1|r` zhda-x_(U8Eym(5k$Ms$_Y23L}m+p#ilUtaRacJfxU}^$`{pWfQpFu)BYF_Qc!8WHfIS7~X8{79jeA)? zQG~d$BrsHyRkh(vUz%L%T||-hF}^;gtCm5gWUvB=qJO9Ta6?yD=L%K_w?`CrE)s1W zKtbo~dP3vu4T<*c2ID!dA%^BZKHYf?^wV}FpWeCOwrd~ilsmMREV^;WPtyrvW1c#V zn{!VswUV`7JNpA3K)gEmFuKA$l2c}y+ETWR#X;Nt5S+{*EH*^tl5IFIbbmiMjc>{E zY`vAhK@^I6lMJ>HTzO8i5hYd8q#qfE3rLR#LDt|Jgco0RIsyR`mR+GwWJdet&hZ{D z{AuUp^u(flmiD0?tc`7njf|595;ME>wFS+;Ygwh5|G$ij3rKkX{xQI2^Z%{;_c!kQ z{C}(U;Aj5-r}#+z->f(Z0H2Wnu<@&V?N31fxc_PJ4&X#5wS?*kC=KC8fCD|=Iv|*0 z&S3}+!wwC*vA=kvUi`0v{l{~{e^H7S?><2tdh|>cog!U%zHi!nz8}@^ueTnw9{#%h z>BIXEfA#Cneto}v|5pz_wa4u7&ffmc;Ys(o;_CJ~PmepDsQ!HaUh7vI>l+QvV;x4` zjn9I4`EF~tdC3-XZxbnXq3It{ciGMFiCB>8&&YVdI<(g4t8_#?)~(#1%ajt zzE>{`&IU@pdp~N^EY^)G_+Gs%I2$PW?)}6Iqgwo4xE3#r1o3-eLA>zt#P78}P`kZ& zN9~H9no;O^dm(&JhNA`XU6p+InGQx-Hd&D9LDBc<=`suEvk7#hN`82Vsz!sE0{Yn$ z#Ev1lWAcvym|#PN%3<6cj-7bF_HE^h!B`Hm9VXhpp9I6<1&H?VC&jxjhLWuo>t+mL ztv>WpjI#5^dRGPCeU7SfYh&SlS{v`)Q=)jTh57+?$UFDaPZot*u!nnPc4&T|lW-2I zMf+TNmp%uR3V1?^q+)MPszIwZYtnG`q{y9-%-@rv{=(~vMHkpFp!=!XECI?DKEyG5 zlAk%rPZMgA7TVz7IyEpfyIrwxTTA5-oNWlfxt%(JH)VSjjSbn36wEdI(dXE&HhbXw0_}=(ahbtgpvAhkI~uQCf=$=CL%t8+B^%6J4PZ-E-dS=KvVv zDk#xFTL)9F<4Sa3e}#?BK$258f1A516UH+h{#jDINs=_$KoGWUP2n8<)^^v@-N9{2 zG#!uOHUaL;Y(-euse@2VRdmveK=#en=i5_EkY2+(1_gdt&E#@i+|*>PAm=w(nKn$I zTIgNRsfBZTHC>)JtG1ri2vxgKOH3_y=Qf%>x60|atEWH0>9^l?`t|AB2&}_aM*$$b z8Z9pX2II;S&QJJe0?u*)T&$T;wu@}?Ty4)_QY_pv0ia6qu`w$*5-WH_uAle}BCke9 zfx=03K+c2bMm*HdbBrNw#Z&zp#3)EuX2dV?!d6f}_&JC@<~jV(&oj(16j`-_ec?Rk z$BL`6kJS%;tj=-!Sp6_5j4}*!Ze=I^LP-m@0{qf1Ce)N=ZFJtFzIcH@^b24{%?tQp zU)V0x4}Pr3zkRHJ=*I+T!$RoCN~#gh)i0A=>WzJ_e&|F@v6$Dy&HsqF$)eqbT+G4wgbQH3+H)7J}1(&9zhlyC}}mM_o{OJ zV6m!vPk!E43SgWY@<%_4C?$*|*It%-8AlwKR?OGx&MI`$Ge}; zHmvd2r%~(v=KY784?Zj3{XoXZ$soqCDABXzGMn5)&*C&be}_~s!Ys?)^CXw=kmCic zR=hi&Qr;Js>jHUSOo|snz<18FX@P z+F_lm*#XyKq;z&|G^6W=PI^W$8KX0}+sDg#XyeuOa=3x9stS2O;Aui5rJAqC%Q!!U z1ZdNhkCWbT0Q{fg+nW|_Xq&-Q9)}Ji1&ervLQ^Hjjc%G1Lsp&kvjhWGf|(fh_U2-! z#4=#Pe?J{6Zk%lSad348Od9PRp6o}v8jxlrG>9BK0Kr*_Mr=*SDc;b(nGF=k`$x&M zG4>0w%%$-HS`Vc#3MCPMc?cK*Lc&!5Cbv3>hog@h9O_zHo$UXvvvYjB^V>TQv_B@8 zTtDlcPqH_Vk=wV6ry>Y;GQVDNunqq}vX;EUSe{%gl)U5`fTIv$k_J#G3Nx@Dt*Q_i zWkA)iqBF^0bNAXtBBmK@#du+(eU>UUWCfUUlw2hs*^h=r;b%C1+MP^OBkY&~lYC^8 z&|t&t`BFfjt_ujYrj41<3l}gXqKMv(TP>?xY+E$k#!A~NSoF)!oz>Io7F$)mflRXKvo0eRX71xv<`w3)n_`V|@+;h)Gq0?5SxR8iPIz@%$91)$@_>cxuCJW0 zJ<=qoQCB~J#_?!)82Y&2oK3PZ2p^Qv{?Wl!M>czi%^dQq^Q<(=bp9ySaEh#mM`Y`# z%D4~KXoL{tE7fFxSJ0x(Uz+dv`9q)C{Qpnl|K0wq-7fL}pSFMI|9^^)&;OJ2$Nd)D zem%I?ei*fWz1e=S*$Oy+yf^=E>`sBxzi=7M@`loFh_ zI=|~w4zl_^iV)2jZXq<=ZftwQ)6741b(iWj&DczLr9tXx>2XF^O(kQd8VnV^Nnl)I zCY96&Mx*TJ`wooOsE_ap3nmMFgp^Zuc%8wmR+PP^kTq}Mz6{nB($>7XL1Apmy0qMm z{#T#>S=|3H=HGM9{|66S<^0c|J^1G4SH!a&;nH3izjcu*5z5;i;hmBZyHb#>IcgHW|;P~H|*0I zM|m-&uF12N`(9tfj9nzLw#1kw^T7?-6%R6=s0OcTtZ?b1)s*Ovwad#jOq>uV(E0PD zCwK1D^c_?U+p=kSZr$9`latQ#JGHLlwAB2bA9tSYe{-jHaI~|her`sBVZ#ydP-LC% zlb!v8J2mK@=SblS(6tOlHX3ySqA)f&4#obd>UZw6|@l;T==&1ylQ-vRCfRZF&}i$1~_YFL+my-zi89>(ol=IW~F~ z4@c;zr||1wm`<;o5gPfZKiNp3n%a{4$NS$jqbG_FeSEUlgvJh&0=`B&``<(l*4xeK z%jYk?iCSz?gdW1G%^O8&K*NVy7-`60q?q*y>~dEBL1QsaExDYM<9alTZ@^pv)VO1q zVyYf1Qe$?)`g`Oy3_V%zsW{`z3R496(mu=N9Y{5Fb zY(~eY2YcPaqu&@!6qeB!4*D9IgKB~m*@$$2jxC6);|%aU_kyvSv~3KuS(ka#=#Ny{ zIyOKXh{iv-_2>sUc14cfzS~Mitn5!lq3wI{f%ophJ6D{3(G((a{-_A=q5B)^m`_V` z%d!O8#bo9&?=Fl?(6{Y?}FHE&Wp zL!RZyaFiUzm&s0@gha~5>Z)i{%HQCRDBiK|5$1pD`)r3qjjfTNQt-_Ty zT+*PWXPCI5@F>a@k4M4TIEa$XEH76KHWh~&sxZICmk8hkMU6YO>9*u@CX;Vl z?O(mr(0zgd%brn^%bog@qvK~_bJ96E*?HRO?ms;|I#z!UPddk^C($1x@BNeGqi5Zd z-=3Uyo@oJ$77_=7LO=D{l&FzR8co)V8`!w?f=lVua7qnqu^RD_Jnc{V-+@ID{%A;3 z@%bbl&cXv?#Ow7h!B>6faJSR=5GR0XEuvH4K-J`~cIwQ^1Wo|6)O;iIm!$X#o1Ray z-cG+iQF!73sPYu3n8A-q^?!S?_al(~L!#eW?1}DaNoe0W1b#fK4zVTHvU~lTQJ*Ng z0w0Vf9z#eVFfw@6U5?I@0i?g(wXq&B9wKt|?4T#CDw*rp` zimJl%!xP1azV7sgM2~XVp<9+4z`K#*HF}bs3!M-h7$_o7t zBzOi9D5@Wx9H9{l90U88iVhwls_w$eiB5v8jnvHpHkvL~-cQxCOtSH0s9*+9b&dqy z05zC{&IuYTQU{r)YFjf}+)*c---uQlaC9HCOx}I|0t1uGY>gHixe=6j{3S7y>Jl_ zirnL9PH(d5sE_evB5(j<1E8~M0g8(&^m^z`IMfrF-CQ7*$aO;5`o~?MBi%6s%1VoR zLps91J{my+n0SQeE0jb$<`1JsYOWbk)9QI?HJ=~vf4y_siT+rnBMw!fK)YS_t#f>Qbj%Y! zJlRVWX~}N9!PfPRXihlBs)NvgPnGiBh8!YhX%teOl1;~lW&{pTPB1pG;<0lAahAQF zj_Kik8s0$i^v8O7+AdbPTpRX6XV2fCs4r;2l_^SCvkg{Z86|>t7?i^k=1q-kq{i5Ab_tM$rI?LrDDSJ4---zN$AL zZlv#r<0jaY3x8Mu?JRK{UDwJOWt8yF|0MqeynKuzo2a&79e1AYpPU~5 zcK>j%^9@VPgp`K;Nh2EM@qA|&4jJPWe678pX zGU>-f%#B#xfc7-RMxq;aLK~}Ak%I*053Y>XEiTken!J(yXr&24n9At{I4fLT(?hL} zNQ%ouEsX|Tt;?4KHKBUQy+Uhk@$wd{WB^J)wZAK%Z)mBheD(^uRD5itSt769?s+dN z;`2xi^&;zUD&}T1%Jo_==g})kW|pm-Lowhl5-17{QTA4#j=}-&yjKL>Yc;x;mWI9X zrg~{wCD@|DEs{Aou=mZ2GLZ{G=WD8t9gDW@i1(n~o zI`sNZ2t;B_>OEYzZQR^p z7;h`_7+;?W9dTqMnq>HXMcshv1 zeSf}hc>>N8lf+W1_vQB_#z9<3ipnVw1_W?W{jhFx|DdCuDdZU7{gZyHsM(~(hbkOn zYMamvHK-@dQ7ROA?v|jkN|M*~Ye2VVgX&lZ&JKXZPp%8a0gp$pO%`G?oWS|e4=1qW z4W;-QRA=p+etFV)-azzUT@_iF&4qk!XK3nzn!n*NS9*tBf?iFJRC8!_`2cqhw9A~X zsVb5k%wS+G0ZhLmabc#~!cnY3lOw()bhKL|i~iKzC|YB3%=vB@j`A!SRe~Qzh6_Cd z?1&^)B6H~DteHhXe<@*Fm=$B&y-#7JT(1%9u(yAVkhHv^ac;#+mcy_2kB<(Ku~0C< z?x3tCt^VbVrht0AtFDMpDm|#z#)@Vs(y*?Wp@x!CO(0*sq^ZeXL&_7qxrorjz1|eB z#5E2u>hf?Re?yq#wgDOQq(~jw>O}1HFCVg%H&uYH-Df+;UlH^dx~szRy6C1AIYf*M zg<-ZE{mKy8l553w=pZG!xNt(!$E==|djct%kFD5@Dq;5ZyY#yv&8V!_F*Hr13(Yau zkAizI)-fz7iD19aGJqnU<1EjIK#Sc2&^RIm2n#DcLh>(}gOwEU&EV<_|8{%PNwuLJ z&;_!Mn9#X^Zpj5wRNDmD0rOwl_C5*$2HBG&fMAU>AB$7!f+}GSdnB>ir${r|Cb0oD zg%gwoFxN8fwybx+wRE;4VpZ)jY41zi0hW%#XprgR-t4M;ylwo5^l~}{oRiY&lzFY3 zbfAOjXmsOYiIb`3H82-AnHkukP#{c{b!8viD6N=Nj;r%QxBnE#h5;rNZA4rIg7ZPu zRXG2n$c)XSN~S?W^3mw6QLf`}@#jZRYAB-WVul7+Z|P;|c3CF~kf)@bei&hQ=b~!` z{N|!-2k{M}GN`8>Su~P{q&ks9h$(g_gZmcOf=2>=PsJc#@R0*=6*d zi;nX-;Tm^kv4FLqR`=IxEW-Ahb{yUpTd4)d0ugCk+7Z;k8t8qo5EG{wkGvs$yZlMM z{IVu`n;~xE-h`~`X)@|6*luhI%Vm1ZHp|gUkbmzbG(icqzSQW55j?12 z?Cf#2jW^(6e}?Y$YV#-8QQOiE9}gT|tJYO^_QH$R4y;v?on_f5iBq#)CPDYGAl11O zYapm42U??{*pM3gEE~HK`6ROnZy~e;Tw)JZlhI7>)sa@*P0FZ(R+=MByP;1RvsXbR z1FaPzHSS7?XMlnmXz(F3khP+w{hL=q-P?U!{=IjfX=m2%n=Nr_38W->ax_c@u~H<= zN&H4laHu0l4Y@%um5jBEiiZKt4iB$xnJyb5uo;v#EJZGzbM1zZ;9R|+C*HyB0qgDc z=7L9&jnZhRAXUJIQuT*`8l=UcDF|7WVh55|pQcyA%|Ky_2w{421tku-h_EGOR;@To z=*H;?38H$56EQnuIT^T%dh1}&`900mgv3B zFy3DgPvHGvdiW?RS7gT}tvmy-QR*(o{bj9wonls$>?lVeD;7~7@{^4aBf5)KYVTY^HT&6|z>dk}aDiVsuWzg1ph)atCTG9b0f?HQv6^>lT0Yl$2NPNB(=?ioROFKk`N#8gL)BL#oMW3LXnz(F}?Ax{sE9`78SFl-E3wCr66 zGcMsc%($Rxkq4t;ufQEp5)dSARqyLE-i249v;z^;M}%rR)9E>gVYAI78MACeNYTH^j3E2b?`RdA01^Cc#*J{@~IgK(O2 zi76T%Iu_E3478*OA2ff-6NrLQ8PgYm4tDQ+KmZP$p6)z8=(qs%Eu~tH?K5GudAUJ5 z1=f_%9TwbFpUGQE#PT|2>FkewTy&jH+ptMER zew`BDaw1&Cdp4xw_|A)O;CA57o!WP;TG{Ea6rb6@)l$__8(t+>Cue-or<|6Vvn_?*j+S+C5Smj7h=nZ|Z2tFR}Ox5x`BZ^Bc(svzc zowSDZhJP&BnY214Z4h(_Rb8cWQ{1eY@4HRs-h?~aqA)|DsOg%=tMDuxGHWP^A*Mjq z29f40I{=H;Sq7#Q&k{74AcPc*J`5Nyd>91IGPWz`3dT8GBi6>thB=ARaEbI}XjrSz zY>naMszX_ixUpsMbNEs-a6tjlS#n!P(uw#@F7=PA?vYu-46AM>ozk>`VdJe2Fjy8q zIAA_}5GnDd%+g0;53|>Kvh(8Ll$!)uh#P|{ftGrrsa@OFuGg5`R!=mBk#xbt3|QLX zc?8lwc;Xo&%Yd%eT1dfNNzEbH&I2^>!AD_||9`Xh?hkDoN#gkZivNl+cQG1}014Yk zz&MAo>~QAc1)OBp@yUZUz}V7^Rx{$UiSKX!)~la0Bf$1%?>^sXH%6N2u6|WlS5?=; za#%MNt=s*|Y3GjWEoqI5xw-{wJC>OLI>|_xv(_*4psGcof~H9%K+<46Jm;3|*4&s& zT$qBZ(;&3$BGCjGsAi_*CvST?e08P0?LwKl{TcoBf6-?~{5Ot=|4)zq*6uv2i2wFy z{)a#2nYyo#jqP!oPJ^+N+rU`{CO9qpI}Zn1)To+crVL==Kr#xPXD?w+#oY zA_er3Df8o}4Wh|e=~yS65+E+zC|93%N8(@}SYi_rYS&`EM>xtQSb02!J1;%?wF@4Jt|wqnAm} zaoB}zKLD}6=$xJejcJ-EXULx6n=30E4B0!#RnIs>$<;PJzQQ~K?Z=8sLj^+P3gh!W zeae=5AgZ!X_>&06SHY9uJ8eaDrFBWlEw>RA{2*9sD^Xp=T(9ra6_o!rT>6gs)rf`7#g6DkhuK-DdKNvI ztcUB4>1cbMw?KcD{1*U+-EMZ^e{1r;hu;4l-S9sG^0@hB|05vZHoxqDUk}K4%`f}k z|64$C7wNkOz?&AKu)Pxjp-_Q843;*7?=}L&cKTvnroubHzN>dYwHzb{(TOso9GrYm z?m$8V7mK!1rRgUf*;}xM3R0aGtbCUrozOB}R9i}gK+zSPKq!iwdXYSYkXS|D>^1QGM4&9|p{`gM;1f*1iYlL{~<-aH6X-5tM6lzNl7KHSOU3 zeJ7VFf#2PE`Q!1MqweAJt>Z1Pk+IXr*fc`LynrUi?@N-1B=2X#Asj;_oD^*}C=K|m z??Bc+mCDRnZ#V=y1K05@XL}jRX}ZWaI#xKh#W)>|IarUpl>07(B`NE246j4Qv^tc3 zlFfo|(8`27C#Oxz7mWO>Otpop1&r8cKlx=L6pz^J6S}`RkFP+&>n9^PDQQemYBJlH z-qMi*U2Q;@i)=cy`rE{_%y_3-joFS}ZFOafvzCoU&~sXK`(RA+e2f|xisP-11)RdB z8bk=l&)@ijw41!|HK~k$5u1|%U?0pBvJwa|>Vq(;oG+^rP3wS6FyvW!a}0UJhgMwV zggG6$XxYUyBV$61BMJPDx5_eAX@Am_#LMb*CPQ&;?aI#7Ij6dL|IJ{b3IF!t-)~Og zzcG7GzW*j)koZBQ9C94>5L-#S76Z?j%KuT(1Wu_pBu}Bq+1Sk#P1Ho@LYcfNP1MFl zm4{SpjJ65(!Z!<+AF*W`Z6$-fVFHKJIKhis@JH=rXEq6vkjzEmj8y-G&@AK&>-ve? zYmC1Fvj7v&z)5JzV@)u`lG^khE6g|2>2Mg%n?lx1QdkBk`4mdd1qC} z2dnR7H#T@*IK74C3PZ0#`<)X?(d(WSD)ELM4xApsQpq8qR!LKca*yok^H=JIR!={x z)nRWM^(Eu=m$W{vS(S&2qQ@2cWnd4!d&jEAa}_8`5_b?qqm2^5ZXH`$kYPAu*p|hq z1ks%T2J_xJ<8T8}eD>0P;|#;z#^21}1VN`}u9}CnO6-L8s&J6^qW7lrh1kjerpUWV zGBY3x05V?cC;`fXha^K(ia%NAoas_qFo{w>6Ka9H0$(s3w9(M3H)x1uj*Z;LNK4GA zq{X)-#mmdf6*e_Fg)OtmwERY`P$5X81_`B^&2UcvO+ksuOMN&&8~V2jlZCD6lxYN~ ze?Cn=CdmCzf3m5UZ7+vV$Iinl$Zt2-pBcq} zE||kbMm9Zr)U2 zH}|LR{M&uP?a~;w+!;o*Cv8lI7FQ*2T-7A(8g3FgYFhntuUx|EFBd3H`CHi%^WxwA z&NQcHG){$^$j539*jGhIQpj=dk*6}^2Qmvu8qc0))$Xr2j9;NyZvvsXHHF*<`B^#t z2A&Iu`}-EEy)!H-PXNh6AQd4YvaQW!Pq?$#3}~(Huo9Lf`iy1qAi+$`TMLHL&%avh zYd$yX|Gz>CxY_#u&g#QQ-0 zAEWUEY0wka{7d4OyD9!nA~?}+pO+N%rF3v|8F1@-a3m2%XWT<#G4kLd;ZO$@LjZei zXD``0I_@2By_{n+ydMv{ThGn?!Ty^)e0en2Q00IZ)B5)=IV9-T&}oBPytnA4M>&3d zcyN5+0&(8IdHvJYuJyj-y?+k9de!}_RbtI_<4r0t{n6^s(%G2BS-FQgFr4`*m3_I* z0YUW_bEmM)N`@a}o!_ShDy4TGMg2)el5~@OGAO?euL*f^bL>c|658{^4RJejx9BV|WFB=4_ zDDL@V#U@2{ik-9TW5dT*%NUq@lI6H~MU1B^Zggvvih}KUvv5unsTnEzl=?JuOR`d~ zx-cnH-SWa(SC&6IKHS-V>6T|zWMy$Spmj=X^PS2H=**3wbKN@1RjIOyC~@5y+E=Qw ziqgq?<2Xkf>zaWO33AK3K5v!P91U>jEvi?bRh)>PKEt9C%eQk>g)EYaIF0)||$UQr`Tsp9ql^I_|r@;z&)h^u4&Js{^c zR1n+e5%mwHax|Dq`yig2eBdmZ)}6?GZv$Wv?g{N9{E6wb@rymAv;O&V;iN;Q)`rPN zoMMiOv*sNd!%~e~wuo~AUyJxKd9vSUNNCPSMHVc4ye*3fK<8^qV-ja}y^OO~`rS z16P`_=1t%^GpyCfS)Y@&8g>KL^eXh*<)c&8cTo*<);FPa==W;+&+e6(>pS(UIR9sN zj8EJN1ooeGh9n~?{{2=R4 z@9p3ZicaAUsHU7>4BbOAL9SBS zw0@YWHB5(Osk0e`VmO1Hvl@TVv8&4aEVaekKlMbRdq&bzcz9HN+!@#|zj_&C&h?bD zQyin!5vy8R*kz@KXkV%IvTS=SHBgM)?Y$XAR}paVX)u_MM%V6b0lZ5_(@{VL$nDI4 z7Y_^(Pg$+*%HX817eOCw6ekz)fS)>cZs$>cE?3oB$4wVj$h4De%N^dZCYWLuOd7!9 zbJ}QWMsV%G zRP{1WFRG_(N;5`Xw-q1SjqCL!D>9-#75WrZHp~ogLyL=JH>_E%oS`t$M>2>jpi-uGywE@o6&2Bb%=9E1b3S3*E_}Cx z1zkMd&H6vlEo26w@FZ8e%y_#*CwLV@Yo~oI1%%o-i;GicSEaiAGP%x7QFRZfltj2( zy0Z05=9Lml!nyGNqo{c>iV-JQJvOGc%GTr(SY$flptpvlHR@Q#; zo=&G@nE{sIu~juVktMQ8LUqU{qzE%-4<57MO761$Qwtxv|;Ht$3~&) z_y5fp_VCQjeIXuf*lunPos1076L^$ergq#Rqbk)fghS$7Ve&I*T%!LlCz{Za85Av) z_{>v^be5za(ZdgK^tlqcGU+OTJCsF?8?jOOh7`_xZ^w7gKp2TG;%iGU4qZYD?r3J^ zp(x9Ly*KAfmxaCC8}?361fjHH5JZW1msV$6n&kzuyP)*VR&EMw(WK$Gm=^bwhO$wC zzB3ze=`!iKWh$wGT;T6kz-KIQpsOFGHrEXgsfPxD#Vp-UtBZ;cqcv+i?JvV3gch9L z+rznE0mx|Wk>)#lNI0ig@wM3GTL-zTinow)ACu?FAnt#Vjs9 z62Ak@RIDI@GrE5el`bMeZt7Oj`-rtZQL&2JjC)nvUm@}7Fgg=@-hT3A9E{>9#poVq zoC~Kh4pquX@i>7o1Xlea((Dvlm(W0G9g=a>d4#VPf@m^{uAL*fir-NriAqa=IjTqo z8B|+lR}M!0g$LN_B$ggT>2-j=FfKY>abo`^MJY!jR?i7w)lsL;POBe!JoL;O&?g>= zMULOAfL}nyCd^(S4xCGJ#0G()Fp-zhHAZF`XP118cARUqA;4+mP0C4)YsL!X~0hmUq|dc1I2wE%=V<& zs47|GyHr`$bqcC1a#!z%N+7p3skdu?k*Tw`in-&*v5>y8H+M1ivw?lK!5te2-P5_{ z{?+ChU;Q(~{)gqDuiyYY+x}&;I9edu{bk`=3AJnYy?d7#^(E#Yt zO1r(X`d!fee*NL2^|i+p4#2lC?$M?^+(M<(t>Zu|JyB*m2ZztQhrz*X(pcHsRmYfl z-ODJ6P5u@Qa}Hi_A3X0KEwzzVnkjIgm214}Rt^Z}#^D z?7^`Np}Wstwh#8Vx8&h}?Y-tN-M>gFU7G(McaM(EH|Vjz*xHpo9B=LHnqQnyn7_X` zINUurc&&fDKJ3bmW9JnB-Q7{GZ0{Z%b9#aeT7sNN@Bog?N?I=M>G+YZKCle0tlyWb3wt!LX|FgJ(z{JMt-NgQLdT5chIE!mY2$?NL*J+$k=cDSiIzna=OcO9GFVmI~kRk=ahQ+~bG8yY;S zYjE|35gyfy&~MQ1=uu5aZ(2Y_H10YvNM3GQ1-}juqPtcBl6BWAK-}(H1<2r?TRFJ% zSb((Nb(;VYzH1dA*LU8G-Tj-Y9C}sw2&h9+r=i^17I0cPb=o&0cK0uLt+9K2=NetV zhChCP+u&LDIdx#0-gSrK*?8AF>P)>W_2JX^R`_EttDMH4QxDJdy5-uh8(mF%{^ zo<|oH5Q4kUiR+ZV<>TN4JMUg_=RqIiM_@H7nGJ{8C91plR$%?!-21JCU_JPbD#Nd5 z`0IQ1Yuowt>%?oSFzxFqHU; z?8aYh$PDF8>NC&By}-nX!l!z=_$i0kf3+OE!UFMC)Gvm7_pfXq*l>o!ArO4slSZEL zlNOZq`*m`SCj}03iQnD}{P&$jctatrlKwf?KaYl|PTSlj#;}|~#c`IRP1QZi+C=qb z`QBGVI?|KGFnzF{_UMWR4;?w_bDwCX&8 zdJTS~ARoLAof6wpVoMd+a^F9b_quD_-h1dgz1K6vRD>42Vty8b%b3DmH+bzs_N&PN zS<+<8d5S0ii>}n9=|>!muh|>*l;gOPGWyxh@zKuyajPx6626cr6aeR|n&ec?a`42f zq6f0K^$VIAKoR*g@ZLqL;jM;WGPjEA%1@uRl^GME6;lG(5Q62{8*+E8Z5AH%pl35$ z(i6GE|=S;avZCTVhQ5~8Jd7_NZ|MBLLiF~6=t`H)r$dt z^s3!Rn`88b`5*khMYY4#@X3=jgn!22%yw39)y}H4^FO9h?W^FP3L`enKaYoF4<+qm z$gxUz**z8|S0jNo=!WlLybWmIggHyXr%!qR;dLLkFWa!W8d}$SM;4eSxdzleVy z@E}w@frl!%U+=;0)YV+|)pQ+dG~K9QJPjw|k_E`VecwLpZXE;uKHF|&tYi;w+O9O}If;+y zmWuS|m{G_evbHKmmb0A~)CkZ7sy7zUUw_4D3 zx$J7LEY58O&*lyru+P>vVLF}xM#6`S(A}1lxzdGj9!X{Al*8*RDH?3+vW;h1HVmI_ zP>dKjo5ua6C8yf{&aU5y<>h777yO$hLtR5%WcgLdqH!9(efCZ|b}@ZTLqe_%>Xww-p-rM_%Vmrz^`=^acCyOh99Atj?$lsdDFk z`y}RQo58cDQwJ}jobni7S%$k2R1RKhZasfqF-zDv5c2G<@m*A1*_K~+?@a{`aoI(` z?DL(U>dLN^;2zZW_Zz?L>w}-`%Ko=s_RapDkBTjC5A7cu`$f>uQk9aO(B1b74de6- zgcKnDR?&O<4yhVRVdpH3h$~Z7oXQ5xz?03V!M4-OIW%H57f5cC zhuom4V^1TW4Fm;Y+>`4hch1S8EokDl*=}`0wTBzLkF2-PD5V~cT-`7kP!fl3MpZRy ze9NTp#H#01=)l>W$1%=K9I9E9n;)*53ng6I#2RR=2y>O3@(eurfrf#UfTrcQKrn^~ z!qQr}NyR>Km*ghOh1*ha0}I*I@;NaR*Kj@RJhMKGRzfueiAS963Qy^cmw@B~ed855%D#Pe^{(kJbsFmBTe8*9`MU43tkyj2h2z&=@8k z=@vr`ixgYi4AE;-^|92ZP!h&Z>aAN*ZIkMipbB;*z-_w(&E0!z-WK?N0LHhiT6uxa z6B)XZB{^{OO}y(E$Nl6qfh}~20z@Ab{xs{j+9YI22wDu4GcKg{28CV+XcU6Pj2~}- z-eY9Sd?9Ec0SKL&BqAnxLUxVmxE(cD$)%?0-FNr zkeYI})m{foBs(|#u+v&whb2c}Ip_Jq)}wV;A@6zcc-?6gF-c2nTdL5v>moa2A8|Ht z&OzkCyyS8rvNbu|LscqTa;iIdcIGhmQ+PU)8z~v$sT+L1lvm=gTp}`Eq!7cnHn1^H zvGb zv?DGlFARw!e}$xoM=F5Ubi`_RaSDn8WyNA6zom)TeX-NseSXw?-97BR*nM;K5h z)*pSlzWQB-^*_+IK{Oe_{wL?O^ei~K2EsSO)PcZCT;DqWr;6+uPbR6C(u@4)%h|wY zr1>(>iewafiNA1|o(sb6&a)fRenrzOYR`)-D$krm-&s!1N|Nfs^Hri8w0@pw5Wp!M z%Wv9`8zZjcL`b9r;Pr{xpnVM{yhVmjD+-g`_NPX^DDe}Ps#s`N5_CJQjfvdt)S@)) zUgmi#==uCN`Fik8KHm(~2q+&1r?-#O(5oqV$grjkyDXhp<4$}k&0~BO_oqc=GT#cY zIbmLd@>^!(!t}JwIW8r2ft#JgZBU}3SF~5PVk%WNc~V-<+08iEfNv#*v{`lJVa*(d z)!m}zZtB(~8{OC~yF!u8DBihY6j-&Pn#3Tl&S>O$SzVQ?9gtV9K4HAxXXmcy3btz;_$NXn>5Fh`G~LMGd0Vh1i1#-LwBbjrBsfDOJt9 z=o|{O@Q4$#&%#>+P?EP-FIgz@*kMqJ!jyc0v<{2qL_2O5K(5D_P4zvHh?%>1J8FDG zL#o#Z!xj7C_U^&m0Umghc%5&_e_H(A-(Z2=PaWvWd=C4hV zEz;tA^P5pK7(~~b-wc`oNM`Wr$0pj8ZGN){Bp~i@ese@tI6-hp#V%38zNW7qfd1x# zyx9B!s0|ePO!Hw!I9C0 zEDys%B^icwup_7et+c2ys;MK7gfnRW$?KL(1KxXaW5 zsUn~^9B#Qfru>tA{+m9NYGn0#MNn7;iMa9e(9l<&M>ye{RHwnbffd1|7-1H&k(&KQ z%1^a$U#FRPbG)rL2b6;b&qf64L803xD5+_RK45A3To;`h3PD^O4IMKf+43J(C_Q?P=w0QrWgqlBgRvazR4AZ zKfF9pR0BB|%+r94KRA(IamqQs_YFi^liEfQ|2~1FtcQ)9H1Z}BAqDNq?A(b;nL2TD zuTbOBV1UDDJUD4WV>(reHAh`y_Ih z)gPE1Nuaf~WT%tkRyi}yDQ!t+EG5GYF@8YO`?O+KJvBbb=S)N7nhep)BlF3uh{aRO zf>=pXE4e!CRu!pK#Lqi1vNX;na^&IFppquz0qO5CN*(I^^>QKcG&IrVG3rkz9CS2M z*^8`&GgPz4Ep#JVOW~84P+QUXjbw;HG4(+qk@!Bw0mXVMbeyw-wei_l_cLE+qJy-z zOqJ9o=3+p0{9;U(++s*~{BlB?+8q}lY-_(HZ~RuE_PU2V+f@8`XRrHd!*9}7 zk3-X}8mIQ>fmQ(e&0{3mh*HJR_i;C0+9jeN8=+|^?xLx>?bnI!K5?tTkNPD0|JiU+&Imf0lJvLm$3Ep zwDnZtI=|%yQNMs+ZE z^C6hFJR8|@nc3=yCkN%8REGt3042F@%LVtIsxGiSiW&E@|AtNsu~LH8J00Fa)-PJ;jE&kE-sZXUV>aXeyefQgm*O_-m#U3}OQ3T2lsecOMMeL-s*AX;>RYD1#1rdk?7mt zE2!I*idodC<&CiDz+bTI})(C<{X3`n7LB7 zg51vry!+`DEy1fEgLy>=faE%_BJX;lYg<#KT=k1)nyq%sGT~g7iJ1~zz%q%L_ns+9PxT81A)6uu}8O z0Z~Q&Ir&91IQsGMxVN|U3#zU%3Z`)Fr*C0(>g9QYIy}|QCte$&)tk3cXld!)vdl`r zcX|lODra}vE@~wPfuV2rKG|%1&xM?1sBbf zGo0D)6%q2;qWSsYqRF0q*(vb-EAkDwgAfC5G=ntskkf`+i#u#dglLf7gg+I+2#=e& z^`&%)Zya`TRY4FsYNCKvv7lH<#2u$T>fl@t`WzV4qFLGrG$phI6?-xoe3<5iDwiqxw;V~PvAA@IZDhGD>4uWP1ONud-)?W6Bl^MJa`cJFZraQ_v+vYZ3aSRhdp(w zVGT_nEG9Cs&u+fT#bkG>7BwsO7mosOfz93`KjSxD++V6yZ8_&q>r+jwRXGi@>Cayk zsn(0tRDp$%63rya3S4NnYLR7^9P0woD|}r?e@`|2)pKjD0IeWuV0I6-w@4+UpU`w^ z!c%GzF~Hj1SZzjO;XR!48a3<#fh(x9z}g;p98LP?M3ZaxhPN36udPkkY6D_pPC~?W zLuL@cNu=@BPU?sYD=^Z!|3F8BMQdOtDRSkR2hFRg_zj$Z2j2 zf__t$7bM|QC(RAM<{t^rPZBmj!e7W0JMaP#+C(IIa5l_NtV7W?`BT*^Oj5{>5KSc% z0@2#0p-S76kr!%YEC;BYx|3*jNEl-ooVXpQtpn_hrduSB(WGeNpckJSztD~2F@Kp1 zhiDu^E?<$+r5QsIHAZU5P(w9L5BL0`Yy`#R8bFTGP%4cLSTet|mYrw?Vh&6Xv1_O- zAX>naYlc&vbo}53b0iJxMB_;(s4{r!`z4H*Ne}E*6Rg~TLn_0h$W1;-3P{v~+KXj6 z#x<&CJ~l;F$WE?6cTC>A4(e3g?`_t*jR~7_ica5b?GCSEW z)Zq$h#Oxj(1DNHrj@gs1Feeq#*^Kd`?fX?RiSS$^rmMw3)MQxq0w}0zRRvX228nXD zkdqk@Cgh8Ur}nnw7RVY{HMXi1q_6OfRve#cvWRPfQflkLNrWR>M*Z?dLU}aLW1Y0P zAD3Htii<>`CA%x|*8&^gi$RS~eXu&B@qN7JIM{hEAfV|E>H`1uiifxr*y)buSN&Hv_zsGoKoBD74%ed zV%vECa}?g2bJdh2v9Z1$wW3=1(5y@v3$EG&KnRo7U( zNoH%i#v-(jwcG^Xq?IbkNr!GFLoPdrSpXrE^;myUdl$^D;s$+iU~QHQKM+JSdzCHdWF=@aY%xUF0iOnN&aSr z5Zyymo}P6(v&}~J#>%)$C6LHKsLfR-_+&|hm1f~vZpK_^>3kBIsOmL`<0)joD))@@pwr-%Ws4P{4Q@4mFXhpn< zGMzmBK&31K?{0EkJ^kqX8auy4$>}`PM}U4r^wdIE$?MHiU{Y(t8#{3{yzlVr7}B!3 z(xw3Ll53NFGV~Ok^9uZkD4R`PR-)2(jf>GFmR22WySkJ0dwu62aO z0{?YR$koZox~%oI$b=r8%Vz51HTqaqAIgu5stV=8rTYYAnktZUHa6ak4qB%gV*RQ* z7?8PQr4vu0WVA+`1QA9QmEY@Oh!;czCX-Ae`xFpE$d~*e%xu~b_d|scQpizv*1}e4 z)6M;Yc_3||Kb8es6}TPzj~ehtp>gn+Q-0b&KdPhf<4kDIA)$^9SqdB6Sb-bQ9(>K+ zig)wE_bSdD=&fp(oY|J6Cv?<z>cGVgSMF1 z;JETomPtxd7{`A+Dr`#{bIC3%PHJ7YNb_A4|F&}wEdHYz?47V<(IUIB*oGhGVo&7* zS7ZUC4LUG3%sWE}^l?JdC?%H>Jo35lM<)LllrEEWJY^3hRk9iUgLr`>MOW2jOJI)A zhE@83ZjW(7{aQXnjObq?!ghi(^S{1WMiiu5})NZmR6NgihDB8@wb9n4@<*ntBws2 zMx-x{#s+f&Q}yz2Yj1DsFgSd(+dT^C*%tzJk1p}Wt+hTQ9HtWm%e9^cZx@yqg5QIM z^@Vo<8I{r6)t_Yw7NtuMjPd~lYo&X*sIYf2E}^6r$tYG79Pyb(7Nh+FL{|Q_1fKMM z@ql6Lm;RxB%~6$a9y*tUp)b5$U}L?7cMCp>m-~#R+5ZcwP%ke+X9h0lLYd7JE)2G7 zBN}KW{0boh{0~KAo({#FaXXVkKAYrU;OJj&gb|JC8@92{vavXb@El)QsxTcZiiv}o zI9>~}MdhPH1z(2FYopclT=|d`PLRI$6W~@R16a0UOj$>)Dp7S6&M#jsUt~EnDORMl z#m6ya!9fM+2_9c`G)X`+??Sj=x%DchY_Z?hxTvcEIyTs*GkE`Y0cNWG9?%6%ap3Ds zd(tTE_?e@$vo`$NkoMAZ`$m!@gTWyp0pS=6l`me+2G{CM z!W_33ddCH_x!tPV1H9TR?X=AWrsOz8rRl~kddP}y4MK0_2bOB4q&CuVqN&NkDAAkT zLbKcef~!#A;F8oRZYpIE+(m*`o?3AhUg3gbPcKBOXEm`M%c3CjJqjLZ?Np;a^0mni z2%MgE0?cqXtoCF}VVk8$Zx$+%Dji$Zc;rkeEo&q%7^0Gbh8O}yFv4k2`JAbnK}JQj zc_jcrNl^)O>dPkB8t|%~;CrPj37N9cp9A&Yo8h}m5?VR#z1clJ>>jIqMsHdz6|{sd z^7`2nZ|}TYfClhqX?B@fCknxOH`nY%cSU^+aS!XTt9++C+N3a*TyOyPg1^J*JQ&9a1ofc)y}d2Yu|ZwnclA}X-$x_MUW8# z6QD+GZH68lSg<2B17&sUuI-3XNL4fAXi{J^hThn7I%DV+4bjD?x@mCC>ld0Z%Yakv z!;OW|ND*wy&o4eL5VkgHqcat=k1_|RbOJ5$^1x01cHDm_HugXfI;STM+RPYm4F#UK zp#7Kt8_nD>>4a(AI{0iI`MH=uw;<4=9X`!8OUR0@YpvIKnDd+FW+9pCY2TwLpYrwNpz z7eO__s3sXaJQ%eR_SL6k0bMdnX{y03Em^qkVY}H_rU%atj*m(`c)z^7yx>t2*RKK7 zLW)mPgWX~GUT+<%F!@$JwB*4s@G!>PS^(@yEwo-}*Xd=|qJe8&$R2>jFc;8sigyem=AkLxP{pUXIK&)e`VHCG? zXz&XfE`MG29Sf=H3K_StpiLiCSJmFH#c?cTMgOT<$*L=7jPf^J`ERBE; zBxe*QZqz^5P!+uYoc_Lev%h`3bFgn6ah7&iTC;2x?71Y{C*K+s78l3TzJ+>F7lj2T z?I0fu^!1aaZz8K#zTrf}NR+M68q&A2^0b9@$G;;RRikx@I<|nS zhh;si=yElD?YUmn3cs-%a2)vvezW8#S+iy=IpIwru?$jvL1i&`j|D9ZD|Oe13pV)D zd2F1sRf_D2W7z17j6;g+(85yZ{=q&;%~TP$9bfP&)rn4!?wx{!%leMgQb{q|NzgOH zuv+RQl@TINEhwHYNRan-svyPz-zZfl5|Q~feX%vCz%Jn6mdxR#H3o1#|HLVRDlPu# zjYFrM25AgD)F9~W&x>F|pUSG=fZ%LA-sdkmmuSX}@ za26pdnTSr3Q8c-}?NaK(t*3eym<0x&3PeA1;e{}Q_wVo~`u)1R&K+j-U99t`>PF0}S$$`I zi|($Q?v@tf7JV*nrrN7NtG6hZ)O1xfewQgn3g9ypwM>kwBrP9Y7oXi3y(@3tTzN7Y z598bIEmIcB~6JX22`4zl1(r3W_yea!8xXhcT&o?uR)hyw~40f;bfx!Oz@SW6QuklN44g!YW7ERa>)p?bGU0ZmuK+lxTA z5_@iQ;;Sv^9o;?=#SN+OdbR0C-MIr}V7BxPT@*>g4_PEc>rHw9JlPr4Ni&Rg#&K)K zLQ<%N`fcs6gJVSuVfqj8_l7mStp(@p-p>A;Bm4coyYF|q`y1{c9nf#~;qQh|ZJ#Bo z=O@XnyS}jGw!HQH`HX%ay?JK8UGzrvX4ihZ;=X;p^OODd8?Wwx)9!z}Z(kq$yx~kY zC$V2+&s|GB#+ z`_J712Zzr4gTqTqa9safV`f%sqaOe21bKfb^#jNGjSw)=`6Gi5HdP0IJTJ9N^?DqgE zqI!updPHY*Y0AFD(bL}38xC2SUY9V2vJ6M2JLfR>FnS8>_nwSZ7OdEmLf2F?wOnK~ z&{2JKC!D)3 zw)qf?cUq>NqC?MxYe=Zq!aCqst&e!e`ggOS=g~#1<``2USIjaaoEkA78>JyD2SRJm zOjGbOP4DPz{BD^D##4LdEeqNXk5$$JCyAG!a@Iu9vnRyNhcV2D$!%G;5`bm%5?BlJ-~zUqGXx?7&az~AsTWjH3K2{*8saS+Cu@AF67G%FwH}+{lUu%UwgctkQ&I{`|oZ3$DH~YsZbm{j8N9ztls`7;R$M$OJtmcbd_B*e%_~3VVXF<2L zHz<;{pE`S|8xMchW}`FzYWW7#@$6o<9Qw7xCl}K`@{Lo)S<9)S11MuGOA6(T3TGX< zO+`vZD$+VfibfI@TCS&9p963pe(>SI&PqQXsmL6(ex;|2%B#yW<=4S+8XW$k$suN% zDr`zKp#18jYSO2xjD%yb!cm9D#!WJuOs(!weh4qpV3UXDJVQ`us0?x*dxhbVDA5Zn zXyiT021em>u!HfXn?a7m9mv)hx=$h?1zIA$L{Q=s$p0|vv&$NatrP}^p7*oywVH3$ zraQ;W<>=5NJD(1deknR^#l#QK@8VEz2STyU{P~2tfF1!)1$Z@O@TY3<_=r; zQ<*Ap?7ZPQ{)Y{pv%jAm*9xC0TgaXL=iOhr&)w8nT)@Pc@x!($`I%aF?n15Zv@Hdp z2ahLUL){pZFoD7!;X;}<)NOpK>?cO3`ik8oa9`d_C4`gFwKVBi33$p3^w)3NSkbgc zWQ=Jk%aq+Dpsnv!hi87koW$286~2XaH!mp4Lm9^w1w=dcjDLUM#El0_Xh1)3rQ+5{fq?tDOsN zRLpS~eEl0OIfo)WcdMIzDacKpOi8ag%;QzT&eu8m za`V)f2B-XGFqmg_5)T_Za*f zrFVd3MM;CPy#zd|qb63A8kh2;p({kam2(V6lH}*Ys!O7kk~i!ar1e{^zEu>K|FHYI zyLBw56g3Yq(HND9p76JEWt)PVzZQKW)>h)`z6rD6+?j2LXQsIu_v^Z>-Rk{xA zWYkvF1l#7;U0j+J`o^_v6WI!ctRluB&y&z-^)ECO8mLWYnJI^fx2ocbm<-G=E~zLr zh!_mkW-bjnYxg?oYSUgO=fJhmtHjXsGt}|H!sqcQN&)S16f{%uYsIre2SSm4X!37n zB{{X`q`>M_sN8ee8-CxdxTAQze#?omi&oE#x82JVgpw*hHIp-=*@{gnCeiJxv(Vwt zvEWDdglAmCgF9aSsEJ6G$?^jyHvh*8tK@7_Wr=T0ixssfg%G8b@FtjrzySiH4-J|b zkLu4R7;yBCK^RX501ls3S;wy_92H+kqnD}hC^QrvK~vmD=ymXebr|O+zT1m~!`HB- zm9?T$7X|AsLd;M`SwsgV`9a(tMi{Ta>tv+^hmN0LDGi#}?palVbTEIYjk>uTm1hr5 zlnfD<0b|w4QrFMg?!iIDtW}GLRcz3)2V=D~9c2?yCD#`?+~OQ|;(PAQ0ve4^irk}L z6{mVbVS^0STj!7`gA$Kd?i{RqLn@Mr<5nsv151uC(Zqk=(!cNYX1WE(r3{hXfD^Ue zC**xg+QLvfq0BDKmn8Fwftp=7F93Ju(YV(y%gTN=Cu>#iEF$9K6j&#O_$^wA=)7vp zs%o5QOdqIa)dLHmP94tj3vJ;jY-4Lj#G{v+LEAY&yf~4&2V2iyd5R#8$VL~nd6g-PlzMVomWQEMqtuPluUEQgQbkDD3`d>$OOZ!5vi3_RL zQArd*w{R7;pp_2BoqZ;+b+*}MebHL8q;}FQ2JZuGgM9r7iPcffYM^|KI)1!UL9K#b zCkbI$gXJpL_*yB;ox=88i8!hp;5eKR6ode2@b3!w!`n!>K5f6{9aX!;7SN$2Mjcfc zUMHlyhstsnJ}Yp&aGrQ+t1ldk7w(P5`VSIB&~3z{WMzwhvlx9zl}i2i_>^d-CU5|tbnU@6-6QV!wLo-w`LFJ zmfoyePrnrUyYIXJsr5WFiQqrWp9DJ$kyZgwGo}7rySL9vcp_9nZWkubBS*Pl>)&-Q{>KUG*udko5x|gSJ``0^d|k@&I?Uk zO7W5KY_1DntX21L+RYY=Z*$BuA8#%#E=&p=i@Bt6Y-03kXC@p-z1N z$;>cbM>0SB*1olSXSt#KJg&aQbJ$@WGvuy}TYbQqnyb}K!y?w-6aD8t z^_EwMv(y^i$%z}IoR_saPO2)Z1r%}s!vzudD0?v^4uk4_l>=Wj`CeFF;92wC%c?xf z*B4Bn2i>5UBKY;~umDoHIy%7ZI9XK?Sy|;Qq^HOTY4&8;xTq*j9aYvaMO4wFQ*G!= zMxQX4XdQ;#s=og;l)=&MXzi=f?~s)+tB2p8N8@pv<_pRmh&fz3CTa{3Z?V;hK>uF4 zxUHwhW$S|rRxi4S2Fg%?FI?4?EBZo*<@V)#)1jS!&~a#R1<42zBs=M#2xz`S5hU4X zIWK7~R5N8O3T-N(aubwI8ZPQ>P$qH3)lzA454*>24z(8H&dLK?V8APA%+G~D7PP#n zNWM1r4D}a0)EBK1vdt@9S?KrQOHoiaG-;R+|Ak#LAurYD&YX@|1XhZd$grz+Qdj5B zrHP+f%Zg!H6L-S3;)pHG!&`Cg$|mN$VhkywWJp-$7+3)+_6}ZeA3X2c$Vl=&s%y7) zb_ta?bOp=m@+G73mRB>ZO0J`fF6_zmvL{&+Sc;7xQ^w|*HyD|aO^X>lO+9iS=ZL(0+cq!+QHSG8BJh=ci*d4#O zBx>AlKnH^FEraEEX3}6-8?k(n8)8(IHLTY8-wvKAmZjvmgL;5q6z6$#riOD1pI0<+ zb}637npTt=xq9@%1=z;SzGooa-ur-!t%QcHAKeZ7^8+7t+1^4HvXZ1hX%iyFz7(QH z>V=l)2Y2Y?3v}Xgd#RLZx^a1Mx6$+6xewd2MbO~Qv%9rWcI;HllLe=A8vAY6!zVGp zAApfDZd^YWGn_a|4kK?3Aq+)Tg;vDMW!IrpTHLgez={5;duErIy+U|omRG2>JVg!E zwiW2-L=5;0xo}9eYV+A)ck7kkq%j=3aZahe7dhz5dsp(|RorFeRPwp1QYl?VlN62@ z=V&T3RO}E@WB5n!U><(s8F~ADW8s}02rbE}^CI$;eZ^FSK`F<^aW(9ZHZ)f-^^};g zmV%^eMUPJGp$sLxv{p|`@$sQI8bcMLdL^t%F7MzMES0NI(O2dF^wp!G{@b6QS)Y&b zcoBy&4DqfmL^>QSh27;;$pv<=ff# znmwfVGoY>HVg$Igd`|9l|DK$tK+08Xy>pXqRzHD4oTNCIACeV8zI;A!Kg>=(#Qnm1 z_>UyRC(7~4ituG}t56p(85ec|*36A(e@Yzxt8jdGP-?ga_b+HANSq&Y^j!RJvO66K!(E}@$_j_gj zr}`nu;Hx@LK4TjJd+q3_cDie4M9Tfd0>xpiRc~ETdJGMaEC7n!C;aqZd#}BD)VcXE zL_ZfYf%0!Esl5cOf)Yy3n?;I0hZ4-&25=U+InehxF-0nN@}GjKQqPD|hAvNZ_RjZo@yM2-lWDwQn3U5S zij$G^f*u!kA3Yhpfe}{ep{ZyNVgxCPoiQ3C0MSJ^Ox`4QU2ka@*`-ktpuUPPzjA8!W^W=7?m~C^!SrJ2f!~p{mziqwT`(s&M6^%9~CmacXkw1sL~VA;~ej392Ma z^b6{q;zBmq`gEGdp-Gcu?~qdC>|83wfoR-|W(;<>%SrWs0aej8u83OjeAs2}6n@Gk zb9_x3`aCA$T&`m~b4VTXutoAE^Fgesl_qN3mlPDhaXOBbv=EK>@6!YpTKrkxr}$Lu z@kCOta0=KBCR*>u{RM1~_}lk*n;GzX3t2y?Miru}L^j$mfS?%Uw!J`EZ{u*CmQMbo zpYN)22|0@W%%Wqp+UMB>3ag}+v#LlLoobCYjKeHjdALZk zoreMN{_RKWk5^edL0-JZ9 zkZpq}5DYT!0i|_yAD#IR;HdSUjN*~^geS^>hIWbGL*g0yXCszU)Bt(FsF`V8g>w!3 zlAXfWU@0K7+WqDDaO>#x)^<14bug1K)oTo)3g(t*sDos&2?RF`gI0ZQOxVPAftIS; znnX7PAKtL4FQFE+_9D6r7VoOj2{e&o5DI?6>_XDtG4^nOD#_PE?1H# zXUJCWQmPO?cqkrD?C9nkIqjyyC0Pkj$*dh!V%yPhxPvS{XZoRIa<|=jidL|_e!`be zdzgOMo2q>>6^M&884~-`kjH4!BVN|ReJ`NCcEX{~$l~dJKUr|G zK%inH)=z0fy)k3PZ%cevy0b6yQZhFI=9Cx6tO|2U|c{8J(@Olc$ipS zk(zC~D{HN}iNiyI@5kcF6BTq>*pDz^2T;Xqa^0e&?QBd&*M_+t3g)y2T_7;tDCzCu zbif02_V^;IkzY3WZu`yto1^aY1{7q|54Fi@ES86gomCxH{an_(8Jt1UkY@Eql|X!z zW8YhHoz`{a6%bg0m|V|u*F8MkJCY?vxp)n6#V|S?Z3#nslyS?hOGZ}Z8KKR8jmB=t^DO&Velm*kk5*O0 ze|*e&Jx@utA^tYR z=pr7FU8MC8MlJ+v)hAVivlRxdoc^a`Np9LjQ1(TSYSX@vrEpx0(Ud_;ikcM4F|P1& zn~BMA*id_~p8?MVXE#=7y{xeUQdd!cYLhH0&iZHo0fjne{fr0b7lTbuET>3d>|FI8 z3By52(eo%jcOD2SQ*I&(!rur2i<}7J0knm`=)I=ILQ_h;GW!I(B`n&mY^?_FBmhCA zFvQ~1LDOQ%NV zq%=^y4(*UVK8}xnJnU{gSFXBd_cxG-dZ`x7Cc*8QG#Fb*6$!>x1g-h1_#7S7tEn#@ zOxAw4cE37q{jKj)gAEIcflx&Y+WvYc`QM(+^C>hfjHL9csn~CnpW9+6HuZ!|+cca1Cj*l%AZijVv#dCq^v-Nr> zaPb+@*`ifjh@ru$fAo{)d&9%;65qc_#|qa(a@|-w4I8-8aIka|yL-%-4eJ?E3#du3 zy@&XegeMOgP#p*dQWSNRk=oOt-G#D+lT9OMtmsb(fiRR!Qgje&8$bWJbKG5hwsYJJ zUhMqReGcE$88nI}A2~G~Zcau$_7ea+?Er+lp-Y+C&EUuZ?iSuBZa&U%tV5_Om zEK;rxNB3xOpWzu`t&V+;TAZ6X32>rnP6GHoj?%GshW*VuzdM~$MZvm5SjW!;SrbF{uqP5e@K|FRNB_^A&u*sACH+#L~t(Qme9V9G5tm19* z&gvHJ#%c7tH;FDM({wz^3i2T&TBF2-rtH=GluVv4$q;Es+z5PeW1Us}D4`_o{YYT* zN)2TuyK8mFcU7_|C3ZyWD577%i$Q1L|7ZQwI(_&ksbUv)h5fU4_=d5$MRm-`R^3D?nqUz)>x?0r#;?so z<}oHAD`FZM0@MDv@xRe|{qh0HY_+Wjp~w`xDje2Mf8J9pUjRyuO+O)E@n^YV1nq z?F+!Ff3+6+&(FW=bJP9LS1|v&>HeqvX!T*~{-@LV^Zw_L_>}K|&guTA^HA=8IxDM> z(fq6P?fRqdzsCKKHUMLO{oKF$Iltkir_%PT@ULjJG1xuJP-2*+XCFr6vf;@fvy4uv zL{im95@6>V4}hW%duK&R6>QC)DrhmDP@Kv1u&18#<%x>PK{B(B%z@F&p?zQ~_{5;# z=Gh2(gkjydj?*VgRSsv(BkO9(xnQvF&%g7FSjv3)G&+m6_8L3vU)Hd`l4pz5f7=JN zG{NE`a^zwT1f0iOCqTBn)+$09TOgl`*E<$u6G+|iTZTzF$)+Gd&=ghNBkB7b?AKB8 zac4jQO}GbiTx;IMwZP%B_-sRadeU1qV-v4OOUpqO<_eXq0U3ZA&}_7@V_A?bidIk= zbEV=zr~rgX?^RAHu zrCQE8j@aB+*D2=CB{Y|d{e(;Q6RRlxDwRC#CHd|&;*$5RdH{Dh$+t~Ot6Whexf-+$ z77gkxfaZ4cy?y1l&}6j}paaPg!kOl5FNFc`Yc3`oRm5+k1T)BwLMYERNuvCa0~$?? z*MX%05sBPGu>xI4MZi(_D-vi%#EA{PgP~qDy-J1&=E`AKISbw^z@BZ9t(35h^hB&R z?l(;JqRB~g7Aw7OX4y>{p;qh&l_413Uf?@2aKh=39vG4!!meY_g$p39Fv+#G#}+ja zv3XXT48GJV%Fu3`Bxlz&q$O^*iYkqPg@Hm(VAD=eM2d=RgjRXOYabBG=q?PB+6y+` zYA~SwFh)!a{mR13OMQyB&4iNd~ucGx3e3x4{R)n0y1>jN|KDTH-uv7sgO45Vaf62nyRUv_UonglnO`9~!cE9o@&eR)Nxt*u0L4w@RNQ#(*e1 z3j!kw!6BOT1Ei9w@9M^-7@p(~*nO_SvXFI8URPB;?2&zn z=0Xuz2K@m|0#RNA+S=EbL2DbOA$ zvn?!vk6xy*%I zra!#7A?3@h8|n|emd}CXAiH)NEZ?AX0!) zWCSGm^_~kyX^1ht${oSdBHw0m=sMKk4Ni|nTnBH{Yw}OY9NaZD$Y8CyT)R-VuBK2k zfTtww85e}x+Ei>Gm9sS8=#?RaDY=_Ro8i-W{hpyoSoROG+Tal+c zlS{P#{H@B!Qa$JHDA7&TGo5q{DKrQ)UIxtax03DY2d|qf1_G;mYllI10U5iDt|G77 zh-j*^)DE5ojlHd3=w{?NXemP)sULI`Fhy&}s_k~6t)FYwl%_!ix6Gw^IS zv9WN`hPLFlC9sIcULImlJob)Jk7Sn5?PpcCW!jEY6*8u5%=6ptBuec-*)0GG?T@b; zMZVOgn5i%jr`K!{+u#KYsazPo9U{st{JOfJ+@Hyfca@Q|ing3v8%g1n(`UhZO%~1_ zyvN<9?=%9tlx3<_xi?2MP=n~873f?woe1EbTAdc+pAFp&Y4%o*3 zs^nrvxg2D`22ZlffzpqPkx?OL_!>{NUH@IShJWT{8}};c7!A#Sihf?o2uJlxKuW%i z#_;LWN8yshY)Z7p0$TWFn0+rjYX*ZXT`2e>gp^%?{n*Fc0XS^y6J*%l9B#mar<>Rc zerwUUP>jn*<0)!n^ufW%aUT3PpxOD8C(xh9`O~MJaLFAIwn-TJ767*2F=A4KnKp~k z#)EGau6cIk;X6epgAC1YOqfo30=Q(TusXLa+JeC+Ea{kQ5{B8k7%&~tsexN-G;YvR zo?$qz38E-@-;pW22{}ocIch{=_YJglm1-f$@fq#)W{^Q$n2+=<7Q<#gTvn00ov@DppHn zrwXS9T8YHw!IB4w>!F-GgHSTA=R9Iepba2ovbm}upGu2iz%rT6t#*_a-QtY+O`M{U zZ7i&kKEHuo;JM_4GOT2^%=SXND?$~0qd&G^M#$A~ETTBIZ62q8+J^l<|G82A|L4d5 zYCn8bmjB!BKjr^F;!`32bNsJ|YpeiReYnzj6oB;KdAQ!L2mnx40DQUpZ<&aZq<>zL z{m<{+o9V?rTd=pB?}3^#$VP6Q?;ZU=Fc|Qz^%Q8i&!dMfAhu?n`f&KPS%Mb?#HyrD zOFEvQn$7OfGdg&o4s^g$#a4KGR@I)LM*zRxEGVh&=AJy$YKMMj(b*K*8e+ujlceC8 zF_MPm-Eyx&yLuaiiLI6WOs2vH@rA7P|MP)mX43y*a`MmD|2}&3@X@0`>Hojze^R*klugg>h5>$x2%k z5*yy%SsmO*ixboaR|S!Ao}vA(_Xr2)J*!kMLpe{myu0)42HkQry&~}QZZUc0-hjPl zDRlwuSAph4eF;vcTAbq3MnBZ_*%fQUMxSoH+yL;C-q4S+z|xhXWnz)A%V}=pASK_M zX7FIB9ZSa399E`?&)7R|XbS{wM|WrL^~YI0iHDeq!g*%ss0tQON?<66_Emx*N-Me! zC%_rM8O0Ic%L(58lcj5%x@wXJ)OotOipg-{Td;058{#Pq50}~%G4dz9e0p-z6gg)B z3xu<#%nTUm2x*mNG8(3)HJ_bO&8cM;kq%1rFe8Pjwbl$;ZC#UOWNPgRW>HWLx79m@ z_tcq`P};Dcd5|`-h!(C14Xgp@OH{1Yrp(YS`mxkDNsM$A!;;L;*Q1VFk4elI6SqOz zXJXp;8H+@((f(1z4Ux<@$_J~}3b{-)7|`CsR66=Y~&x{=DIruzLK@#%SW0 zonm-*w5zf{-+=IGs|5sN)tw5}4&lBcHJ`KiWG?s5qOy2g+(0Zl=uTRuvg3@rG;biY z2;UG|oaLsuk)_6;kYlp+L(|*_k1nKEo}$uL+8a8RpVDI;i9noIWZHV4kTol<@yH;D#R3~Rs z&*i9^`rJTH+Bmq))VZ&wRIyb%GBKGMV4qFS=$#pUpVa$(CmWmIzH|m?gx8Y$J;;d?7zfkpP4^Hq%RRmwzppQ z-t52F+21+(vHN_k0UW9G?)AaZ4$e2c>4YV3!95iDjK#il08IK6lf#N5gw8$Lbkf&i zf@KU@Bdg_`eC{8_M6tcyN%dRQ(6le)&eY!R8~vbR6%PqSZFV3><7VOm2&W5 z-j@+34a2#@C-_4RVE9hmV7jPbTPE521ncfvR8Dn`OuQXwVOXLGQnpuQD&U1X9xK%u zb=B&&xoXB=t=0w?d5UM0JPP&ItTR4*SvN-ARn^4J;}z|P8q2&J-_6FK{t(TA5UKrD zvrCPIuaeYki(_*dQ7R`w8gY>E+Ty>La3N6`?SZDZ4C6e=aTnmC>l27MB*hqG<(0?EOy^yzv9HzIi`I)TMpiT^KKzDz1ML+1k$^O8|JQ* z^-2}9Z|uFjLfW++;Se#5#9iQ@q1h#qm`$Gqca-#p=I}NOEkp~!Iu?cvmE_TId>#Sg zvB5dLHmq`eyIemlCd2A-1H0THIfH|@vfR)vCw;3bH@3@-@w}}rm)qsY*S@;k)Go&& zVP&~XcV6J=s4jP9m%ExV;D4BcjlKjwv`cA3P)e{q1vcwzCQv=s(=|i|8A4nS?!%w3 zL{kY*PA0(D$Ayb64wZ3##(jfCd2(jUK)7Mrq2ASuMqEa6+qpZ1Qf~gY?CnoRJY8BE z!vUlkvNt?!L}LhJ(G8;A2Jahv#U=xl49#YhNrFzh+)*R)(zRXt3+pIEgi()A6{~4!xbAQQn)f4WB65BbKR| zb*`3<*^L>XPNHFy_AB@+7ov4s)P5??c7yuFj~VnVOCjpSo2JqwedNt+v1T#HQwM>2 zp%AU)x#ZgzV5trL8x*laouq(o!hwhnA@l#{-kRP{N42(1@3g6W^ zXp$4_Ey7?x9K&jg26)D6G&0*(ju;q>8iF3?vS^Dd^=NX1E>6)+JlJhk_7?lkhzW^_ zWk!yqIc$lmWHcQG(jDZ9Kp-9Q#*=w(`Ko%{~Bnr!gvZI71B|L-BAiHlA zlWVf*$aph~<2FT$t87$%V7ChBv=LH4=@Ptref!AT(5*tpGfm#&WLrP8}oO@FpY z!F3*qL9REkj_mIXi6r{ci>H$3+(_qP6{$td=ZFqM(HAhKt&kx}sUeo2bs{G9S`|%?yofI;b%YwO40o4(Q-Cf-O1F8ea`k?Wbu9l9pNp`*L;S#e#Q`7rp+!+R9ZO zcepfU$m>e`Fxb$)HjveX^%S(mvv}+8QAmqulaPkITdGFE<(%DQN+<#-zYdRc8+t6ZVRk=PM;N12DXcKIo;T zG8y@bES#WM0&F8L1StT{vI1jHz?p&9KqE9vqaaz6xIdlbCM#bJZ`@e0a%4{mcVQK& zwgifBA#@`cNd+f`xSAB3N@{Fe>NFiqtJWPjImTy$Xg7ULR#{aO>XG4@Q5u&tU{M1L zd>NdlhSJl?f`G*ea^okuam~jv2j|Qaz)_o3idnN{DRPuYL0t@R^#PIY;RazuU?_!+ zkuF_WdI-|F)tyh?AWrolPA9;lCh^4Uy~`79@HdRKon+J8=~%F|8Fc&siTdcRqlc4rSnunTuiVmSaNMt0`{TJV|HIc@8=6j6PU0a% z>a71*V9(=7?QXMSs_49n?IbV%5TM4+h_7^LtHIcJTKJ)9Hj`#`U1Jo!P*al7{)_aS z7&($g>(Hdn-Or?1L>}x;f`>vWeLBSB^3m{vURyk{vospk6ICqN@kEUI zC{i+&OH_T)O0a$tE8S)9}?0n#_B7Q*U5YSH}WLDmw|`=eSCM#Ao0C^@4{^=cZD#3FDN z1B;O;IE%Eyv$l=FZ2Lw5%Bk5gH9JOeIP7>TwYF_;q&##m3lExMUSFQaip$g50|4<9 zdgD$VM{h$T5TqsAZ1?@Jy` z%w;khQaDAVi|kqS9tDr{iK#__7}~92M}^D-=n@^{Bo@b2W`HQefK*fFpy>9$O0+`6 zcGrf58*AWl(aaBR(qRq?s7gu{r}IdChv<2Et^4nY3nD>@$kahZ!xc3`leI0dP^)c= z0E#QfCKL4hrUgNT7R_i`HO3zpZflc)V015=m{bT=JWjk0+b~*qY^3h!rYr|!G#CIX zWy4r_3rkC8;M~C`;*-0hEQ=CPXiv1zZe>35%@!(e478PtWtvceqNPr6Hk3u5fb)7p zTd3tQ^x9<6pOmV}tpKOg7Nv`CLNa5!a|Z=MZ1hiw(h;VF2PBiYSV7DTGHPu&`5XeJL$)hq&3_U+Q57unNpJtqIg~K!IYyJJqHFl5XgxxSwa>n1a)&2UFPdIe zdFSCfSF1#n$=AuvHsx)Xba>;s@*OPS@ho_S8sA{SOSZr5P-V%b4UQF`;1(AUt6JaW zsJB?!J*!=tks&j*~SB0I@ovqzNZ?jcH;Dt!Ae=_hDu@%L$*7Z&#q!yKPX zJ~n`hQD$65&8S2>z=$;CP>#UnYCoY|!@(2=7%^`=M1n5Isk)4Hm;(x?!W;))z3>id zxA@DLP8hS@^Nu;gDr|Q1PAgwBB6wYiq0zwzW_H|LI*XuL+jOL^eNv1M*guC!*mNv~ ze!%{uKuM-km%y|L-vn>j>{1^$n-4KNEJ{~Dd|^j zV*pFOctG4@oAt;g4#D73=y0o5bK2%vx3rB8qg+u1deNd2Nr}Q$oV7zRxx1214^w_y zS|`I`JF3Q6fNX^F0imn{+TJ}M>FA~2I(wj$Ol zQbYBWS#Sju(Kp{3%xW3T8Eaok)Rp0sc7P(Xc@2RDqGJ(Dd?0asiEU^g34AatUzv<` z?HQFjVW}Rh5MQ;J-Bhuc{GF8RlMNozrOZ;GNGO-xs{#9sW%Ott z=z4d1o0PU_tS@>PRVV$LJ&N7h;a&!u%#vK~;#O{Nd5X>lKtf$cU7xb3MNRzx!etQQ zeGKY`@H(|RAe^_46-0;Rg6xcupl_PE8JiPF99z12>zaJEVxLu_bFF>8a6tO-FS(NF zW4^*R-#qhXV%2%k?{nm3%5|xC7jOWxT_4V9qhgT2(-}M3HSSkBaB&wV5Tp#hjB==f zf$TA~e7!Q=2SDAOugdQXvO}+ebG5x57Eiv0lvKg|>d<=30^21J2}_hmnA!z`?2Ik1mlInCbmVbesfvGB4Ybhq-s0umMmU4ci6vYr84&{}_xsb)bV!*t_!7Xf zHTE=7KAv%O@IL_8YVgh8eIm(n{#H=|6Sj#@&zftNO#VIlZ}y&b57)h?9K+D)|7b_i zbf0)rETK~^wT6MBe1|N>KT3o?+bfBX6xG2G-lV$(S1EuU3f`v_>f}vlxM|DW*Y6O; z95=nGLZ{V=X3!N59h2NXmf9(4O_j5nrh#kP>u*JQHLY;WAC;#HB-x;5W{6N;Iddr!k8GVN_$CkMWy>I{;!&Vr(QMRjV%e?s9_Ca_6%6Rv?6?JRn3tVuC;eHn zI99nq8uw3Wwiv(aX&Ij-Z<2b6p%{u>cn9H4d2P~<5*K`Hx6B!gspecQ))aU~HD$^n z8YK}N+nrd+YA({SnUE&AFZtZhpime2ZD1J(eB{5{F%TF4G0xfoIor@;& zuQ3EfCfb^b%Ci@Hv&c-fb@p2H0wIZzW*&dKS3VQ69roN^m*Qn!QzSv)WUYID$5MTmFDDwc+S$LY2zuHGd1{WW8s_czhD0T z`_l#7`tjQ8cX&l_MRcL~u*coKxkv2|w!jqSbQqmcB9=&?>&zWGA(sO1Vt4E1(cFA% zDfsu*dGQgQ(M=CfBggz$z^pEO(^{pT4i+dBTVtuciu8vKjgf!jfm{XS;S?>8CqP39 zHj=~eo;Rcy2ZwuG$2!~@buu(zHu2!v**|`9xVPKg$LHn0#D=uH}I!yjIXL9+ecDX)P z+ZOjDNfLTPgtyblsA$ShtWdTU#l+Hey$&9E`a^mt>Xh~>1Jv_T1bb|6ab(su`bJMAr6&js@-sY&l7-e}8 znu>D3FKdr4?Ui-AevBtTs&Y#W^4Y!lR6ms4%q34qHnDo7LR-khE)u;br%)iJAoeV(rA9_R2S>s_Sx9U99s-x|#po6j1v58xiZtIBfm1^6HJ!~%MfS4=4 zBgFupmX89N;F$*k)GO;cxuW6~`PY)PaBGfKDY>N=PXY_9Xf=sUMq;sy7t)T|cn0!sVcJ=mdI76uIlG#|jC_hNaE~lNMWlQS zc>du7?|RQ~H}}VBvCmdhcVnZ~hjb~z3GtK>D*)^fxly%OSKZr9xm&OfSxRtU$|NC4 zb2UBKaA3g4)$;g;vHU6N>HHb?H8euLZ(M@+H!Oi`)$HklX$>lHE%(~?(8-2bW$?(V zrD2YCUceO6;^)Epak@J^U#PtPtzn4RxYmjD@lBsDJZ4>TsE?||D>olD(Q01^HXQu+ zj&W@!t91xGLBi1B4+X%=Rdnm%SB&LU<1ju8IM(Z1MMm9TosbJ4W88+mgk6|8$H^@eYW)a{mfnomyz4t|xVFgNlL zzNu#z1wuW=@A6!M)i>Mn97G9u3g7fIiqEN^(=T~vI%4`k0W;(&edp(FQ-J?|;zXu4 zN83kajZI>V>Py8Q7t_k@RZa zuOw$qp_8)cju>!Sg)JuZ#gJ7%NINQ6lqGXIm|48{Gv9Gy>9L_$tCWFitZlx zcqnOQ95V8+4%Yoo_|(ULr&;(K;oonF|GxI^KgR9d&q@X77&i~#%aMve8<*{OyVeT+D} zd)`#ZyPE;!3D3`^P`HdBj=2JHgQyaU86YP(zXU!rniTmuFqx7p9)A$MaaN4D~$%85_tl zOsY(`WXM7Yl(#BpFxtYYku1l{%sDHTeZjn?abqP~5saOgBP4XiDS&^3YCOl7(LJHu zfmXB9UUr$fZSs`F80IC$V4Rl<$}o!t!D)m!Pl3Eg6wL_4ly8~=Ff7EJVVy~g(DL9c z%LdDml}6(KLFPRuCA|59+_t>!B};)^ENP^*HVw>m z=fC&1etEWYd_*@vfB}?f1s{L_UqGP0Bp*BtI*;x9A$&eJhtJ4pwDhK7*T$HkDxtPj zato8d%{AJ=lP9WTXhp_Egc)a-okr12C0|1047unA+BjoYzeXCea}+-fSsCmAz>M`r9w6+maF zc4sLI4OW8VRL9_Syv(39}?F$u7Ft>ilrL_SG);Qbx^8t`rGRG9VO zN@YZD`6QMllv0#r7#=%OEL>pI`y59r-Jy;wVj&o|@*|T(MMcx96i9{)Cr@YeRwnD6 zGL|6AycBN{+R923=oRK9RIAWnY-+8BhP{^@!!oH6g{YGsDT~vR*EMPe57K6!3%X`~ zZE;TFK8bN(^mg?f_9v3m%)&5RID;iZC%Q405szskv({OVxyK4#j*DE#r$kQY0sBWG zEW|o>a?nDCrRm2O%t_?0f&Bi7kpNcMjfhu}2^v10ZGq;D9K%5Z=#)h{s=VRV6+5+Z zU8Y8uITQ#_ef?(#2fN*^{R#kvG6g3y0POC({86W@tN>$3Krk+WQCg>&)z11}y-$`P zY2yG3rif?nq3i;(7V;%0#%(;FWMkw~V%mW~0*B0`32C%XDPgn-XHXanGWa>UOo&HX zv2U8F5;xtbK>|wFS|qvXd~GbSw=V1rYpLb(6I%FaEY=u82g%(>GHcOSK=3xf*YV#u z2{_`;#}LbSvAwjZjr?v23E-&$&Xi2HC7uBuH!!GyHZY$x^SI{(3@!riH^~|w4fEyT zMKXcuIm?i>91anP!)7}xApDwNz%bj$8zYDlkp9z@vP5C~x;Mb1# z@3M04J-^x3N5#jTL10!=d-ka%O@^|b-gKVQSV>c4jPsHF8GO;pjKEfbBqpfurqmDx zr+TKcIx>VHvz&{1rnCi@a_CiExQ>CkBDq_zSE(U>y=-j09hQ8pnc7h(CyV0YPBdt# z<12Gm31EtGdzkHph{KNHvTh_n811nff_CCzacD+WZ6Ul(_7S^?IkXd^;qNg-gr$QP zyg%pxm5culLejy>2b|PS0o#Z;Hd;6@Sc}l&GkAyR7TtCtC41i8dj6{WS6YJ{WdxWc zQsEE~9i2)(iYnP)97^SQXh~LK;!^-e0?kdWhT7WnS{5itE%DS=xUUGGp!Wm{ZcGtk z<%rH`k)^Q{f8@%6e{FSdloGg)NZF_>VnO(S1~M#x&u;712xQC3!01| z&*Ds;cqQoghP>mgGsH4Pxvyx&0{}rq$elplwxCgF3oVxke{7S?xG+aTGtiVhS+Z_G zpb#cr&T(8&488rGW;WadzzPih$?#>ZO@DM~ZeUn^ceqHJH7Twf=oxN7jpm6JZD{6b z?Sargyq6t7GsazRb@t$WUnPzyqBodx;C*H?4V?sIF*uBI&b}a%hK9A`r8VIE_LPQ} z<23`41oL^9Xdz7NZoqr?253v z&nS1Hze|h-w~os*QaUe+?ctR-K0-|y1Pd1YeFZ~p%cu!&b)m)0pyPNF;WQ=hD239<7@Wlz%gafo^+!7m zSqlF?F^yTWT^g0sb6`vOrOZhyRG!*NIzGEgC3sg?OVWi*}TIu zYxhnmXP9iJd^#Fw#rS)KwO}Q#3bYP@hePpQBF?9X*uecF1-99F!?R7?c+fm1u^OH| z*%YN3{-Es!uNF7;F2PD3e~y6Tr;&8v*;9{0R$EufI|muN z%6yo@ymCT8D3lZ~7l|p=;IZ+}v-U*kRDdbsxpIQM=^3;|mPwSJ!QSrtH%u9&-o%A^ zrz&#vX6E>zb;r-Ko^PNGXS$=qz8$$-uoc??8aC|n8^Q0XbH@^zd> zl!!|sC#67g(9chbWFM}dg|0SJa?eB!HwO1cfWcYAqMDGGS(Mb~)YU{OI^+ryv<=mP zpa$y4jaO4b$}E~*J=>~E*&G)*8Cu+nn649QIa^N6@DD%C3>4q%0m1@>>N5ypaRp$nYez2+l5tTKY|G zPv!i8^~g% z72+$|FxYe=;Mv%rWa7$qvgzDi1HB)reXV3=G@Y`Bh(+M>=_HQrj`4fVyeM@A3&&L0 zb%rEFoW#s?&B8$5#`68VV%Oo9Y&eM2l6Zo(ygoOt^$78`%rTVUm-L(oAl}R1b3$Zo zrbFy%B-o?cW!;d)@{RDAJDXTpI$hc#vagVB?1(Xa0-UjgI=bDpc_V6?fI9nFK|EJ0 z;r8{3)z{xDdz+t6lJuj!S#3(fU^dhdJBeFKimayD@|4{BBEryPCYz{z!X}#n1h8Fo z=9XuzebTbHS#%1Cm+>Q-1EDa^6M!OlrQogE10JZ1-*_g^B;BgNO^uHh;r?`Q=A3u} zx|W%kcqrWD5LW@kwL^m7pQDVSh^R|R-60AuO>Bh9c``Z|K2NEJ$m{f7jfYSN+q}PN z5oj}4xTR@s$gdL$HvRD^N+)r%W8O@9){zzv5umOyB@pKOW^!OE>>Y^unpB@NNt7x7#ccTGJ^(vp~K zF`jC-t23cE$4m{{2FEeVaqBK^THLQ{9xpQ^>zHx-;cYS_1zdp`rEYrl_-x)X{%En3 zE;~t3NTowWxmFEA>H%B%)9^a12n0dU7h1?AAzZ0B2v~6>UeFadswb!gkK9YxPhUZk zB}gr*-OH-TfvM0#K8?|gg3w)U2aD}#s9mD0Hn)32AiMY&wS{N>tbx`*CLD(1E{v(F z;cVbBdtKT*$^WdXi7n#MI78!Am0`O{{yhcJs*JmT5?Ud{z7u}8`?`}i(skf>) z9*Zeb&u(C4@6{gpS^-mie&eLt(#nQMDv6ZVkR$7!Q#yDX@-1Z@!y1cEt*lTf(pYDr zu0-Wsy2`VKR=)5aIK`mh_FqIvi_@eG_tH&UZ>Uc{QpH9rCR! zT|`8DXi=CDbzsS6<71w~C11*w5vu&G3!@FbhiG~?bExbRYdW$nRCWwWPOU8mJEzzK zznU?XqeV4#a%D&qX|hJW4!a2-vi+MpiZe+%VVhsGGQL z-@>MbN|(=02b7&(U|kNYQx$4qrCXlC`o>A@MaDC(P|G~j2qVW~YUHuUN;u3I4qrmz zSW=qCXu7CDoPtLsL{i9`nrsXz|3g}deU|o`xslS%8A=-dMWyiy@;JY6!(&%90wb8z zh4V?#45eC5U6R6c!1GZ(&&+7zv>LWm$^)d)*wO`is3htAO6X_Jhq_*`!fzT9&tfSw zpO6?9qPaJr>W&_a^VYhe)cH*`I2R7;<7J8mnRV?>q8yqB<5&nAP_;H1TUY6XM}V@5 zB8{(Sj%qo8i3PHV_pszEhWje?`-Owrbi#XIa?hLk~se(ZCiESY0h1wGQ${WWbAJMaKq|YdvM7!A-70*79LJHpyn_nfU#qAT{ft{!e!SDPw|zJ%oBpcZPaVy9>-f4_*1fL(RvNyWo(;88WzePPlAef4iqN~m=V9JK52a|J)LcB^-=M3 zWGSUBTMSjTE$}{mCA$~T5=CWzY{jyg@L9~x_UfA2%mWo}g6Z=p*BHv{A zILqGg28&0>2n!E*HmkyOqNvKAWYIH1KK`hSI0>+0l1R4ih?g6krvT&%X63*?`vF;%E$nqUt6`2VU_kgYB~bUPNibL1?o%X1BB-?a#Xu zo`o5YYp7lXI@xDwLvJzrYByN|&zDZPyb>B>Y~vn$Y`RDJjDbJ+IAh#&V%3eie16pr z-aE_wDTB|ohc}MjP>>r(ZQb=x(-XAC?8y;ioiC0D$%hKB61++Hz?33Eg!@N4$pT8l zB(_h2i$pv=XuT#0GVc?~DD=U0StKy3GQR#GY6ONM^hHa}9-@6P7x~;Z`uc%PzKj6) zA$VHFQBo|S{bQ3hL#|z2iBH@fqdYj7CPTR*JBctY(FCY@oa0HEXOn_`3(^?FWjPr& z0x`I8rNO!(q5Y!Dt8T4qqLPvrfkK2U%H(m9q^OaUhLtiO4hlEd`v-u6W-o0uYtHJT z8BHTu`Vg*IlULKt5q9$fo@zE_Q@<^hS7Nh1#}hIY7NrBBA$B`adVu%E!g8<`yjO3O z8;4TgYu6ovKm}eh5X!K9DdG@3TWY@(+KWL)2f->1rg*ELhU6EZjf-($zGl$f4OO?j zf?Jf;r+kt4fr6E31Z5N2Nz7>!ov}Mk5bHsMS2MH|otYE4v>_#=Y~2#yw8-uTP z_pMd-*V#+zl~@;)RFLj^D^}aPKrzQ+<-M9Vf>*wzq{Z`HAU+rlhRQ^_33p*9<8#R$ zQxUn{@Z&{1?>>9;GQ4+>c{oCp&vFRUX#lGjz)zNqdy;c(57F_XW1lAN&ZKO>G%KIi zf0h6LP4OSjzd{?c<3Fr+I%^Nh@gLfM#((%DKIQli=M?{;y=vk=tOo71b@>14M9q(pd}I->$EHx88nK!2oa&IFfIe2<$~^GRAx+q!PbXG$=ce&H%_zIgn0r z;ziQg-FbFHAf0G>g~M@!-Ap5SX5d3PqKJ)MikC9fkxy0fq0})tlH3GRgWU8T%?wNg zddwts;j6U`9x7w4wo7T!RP&vto0G^k{cnpCO6r)!mLdtNK!W-j$QZHu88?#9+F+CEua6j#lO!-`TSwG~pzsi+fZF*!iv; zmr!3(#}=Mp2gahP^Fl_`w`?UXNH;i?by@N{)7Yu#X0WI!b5uX>I>THsQr*E_{)pXN>A}OaROXz8{*7j@dMBQ>KlS^(d?FTX zH(!w3r|-~xn-qN2F}g1&7#rQ#{hKv)qId98&R53DwzieBjMuj6I%JqTD3~%mEclKC zyHHl=HKe={GI{IGvSD^ZIm28>}^1W*h9xExps){>pV@Wu(IFG~t{Dzaf$u2ihS#N;3Xe3HFR z6+{i>^?r4-m7$;QM5m>W$7;0_pv_TE#sN+Wfp}~!qLo4bV=vEBcItRs!(EjR@uZ9p zYnoriIH~5fxGouDL)i%(j$KZ&VNL25$G01Y=5y914p_aRjG5G~^uo_CNfqS29}^2u zfKj~j5{s;P2UaO30sFh(=Wh8aUYxvp@wgf28NPLp{4Wcaf>r-AP5K}49+i^Ioxr&; z2+%2aYj~DT;3OK6$>-j|^EbO&t+j<_a7f}Lh=_x;_!8=FV8vi-Fi3KkmY?H%hyf(p z-+#Zh96G^Mlv{GAN_&?y?aS{<8eREZ?vQM*2FB7uZ=0%SBK~t?d?;L=xub8T6$`Jg zyRaTCg~dX9oPYI;sHJEZ5G{&kFdD~cj-9$uN;uKsgIB- z65H(SJsGlg!se(#Pl6Nw9uPqc;ULE-DKv2Czq2@;3~PEtm-ZEFGvq&0$3J8UO-=34 z7O(?Rj_gkz12I7%F+@QB&&+nwjNT64VN}b;aA_K@bl!0^>9^B&^M4F|>J}fU!twp58 z#pH*<(ozzjXXcQQ2ECzQm)thW!-iTI7`k$)f71&`NAA;U=(FKERnBAp%#mwd4Itql zp4XT#8!?j#;lPZo)%u{v_CaRj=CMJo(%9BivTbKY;B2#5SYJ=O6u4>2+Gj*zscS)l_d+NU7p$e^O#=w5w+ae_ z8kLi!wvEgt%n{~pLem!&B#c6nv7Zd$f5K-Cv|$m#w&6SiKm zNfAbeo5@ngo*jpXet@^ARoy8ATsqBBz`hk&VtUrG=-*u@&xkBAtlXR6jZPgV%!9Vgu zbR12km(w|`kow?b{-)AZF~rSg9H~$w-W=(uP*mnLxoUXTwJQBW!Y=?`O6nv+7p2EFhV+`X z=4?{aT;11&4Q{>c8fh7`XEL z`rVG;(w;tfLa#OJ*~i#8=jfLn^$Smnq++yaeUpmqF=B;h-DI6y16lF4N^arInn5R` z&4_g2t~X~^;mb+dZIwTRa#@SCo`qIK8ztdb;*J5~C+{FA)7wGu5_nKmM(9!TR`vRw znmn1e1{C|j!2?XT?d$`Z5DbOm7Vt6J{;#dBcPdQ(?#%xgtN)Q>@{hl24gRr*!OvTV`{d9L2g!9d zMP>%$Go#vo)l`)B2R(++ubeZtH1A=Un|K_|E3Rf9dx5kKJAoycaPReY_MdluY4Z2| z?$7qmm)r7X@8Ee?zIOk@iNomb(HvkBt_6?ng&^vqAp##rP-W}+bE$mv=9z-{W>>yF z-}%Y3BHvyg{4C$z?C;69-R{2ncB~)Cm+gc7?Jf0mduvz0-k+OWsf_6_PHQv|sBpmp zZNpBscE$`y<`jju~Ks#c0A( zLjy~P(L{oqq$DRslQTC9{CSp%P`}1KrcI`0gOTJ!| zphb&73)4uN!O_mk-t!k|MvIznOw>pL%JNVuKBvW41!in+8K~bui`$2i)9?PO!)9Mny;EFLsBH5H1_vtf)gyR7go|Pc<1^FmerAk$ z#;gtT&>)!qCSMQco59$$UoP=0-Bkdz8~Vp~K;s%C7A!Q)O^^6D1}Z2U=PLz+I~r}L zr^VW}0R z$g6LtGovBj1f4IyBOrym5DIxU9rUd9)oo$^F&T?0%(mw;6RQEZHeKcpms5{>6>2R< z2N_kW_MScCZ~bAcjxmGKN<)kGfr6mgn4JPuPtH8g7b_r*nt;AN>AK5m_NEwBSC7NB zjiWWA8$&XSgHGsLl)rMCqCnX{pJK>=zS9*sPEJBT?wabbq@|Uu$)g#o3Fe7t&@4z~ zc{-2Y>>k7E6sp$Cp!G>B{pG7nufJkvQ8!Mual;_JWb23S55ZY9IYC?!{WQ-ls}xZ* zM10H5#kUOVK3QASGWGTD+ulCd-R*84D@LP!cUxzyIy0_5Qn% zUc2eT{PalPtvohDNzMRl3q$uV>AhBCy-!vX%u5*4b=QJ{fG(l&^L&wIoCDs0p-ye< z?jv22yxrIpD=m=PNakdq@yb01kqOE!qDd$tvkb(&TXCR!{%qCoOXjy|{fF_9QvbZ* z)hf}R)5O1ncaL&&m0<{vvJ)R>(E#i7sIc7czY95QF!Stq0`UQjZ{$F(=#H>&Gdh&t zt$!zEcTbICyOUv@HuCVR^;hwZx0*qr(9Cy}93d>|yyIhMR$8-0r5-utu`Pm%+d;bz z&}t7DjM2D~KO(Ox4A*7fSqXEuaql*4gN6Xqc^*Zzz1PR{K&9394v%nL&qr~DIL$+0 z$%YM8L_mNg#9siLnX5FO=eIoyM2=L|@dZDo|r}!9iaY=?q&iyMbC+ZM7oS8RlKfi+_!3^2Zd_lm1HlVN(Jw(pl2^F#*}Ozj5o42t4Dp437mDj_;jt! z5e|BSDe`1~lVtOGYoFdXFrY&fuVlIrV*rAD#x*$D63FesBLf)i50gO(0T z=pHH{BIr5}Z?dXo-x6C=0Y#$dS`y(?lQ0tbU2(+(d?J~`LXI+CtYIK!XTmcS5e2wo}Zl)DD zwRah7Ye?0}YK2OEWq)0bWcM@2z-yzhMyay2_5E~ z92T?-|9O;CT31S#PB+;2Dt`0}>%4(AOSiqN9=rF7%8 zsx0`IFlcd{s4x17p953}1%Pu_=?!6b3sM-E>uWdWnIc zY{3*5^cay~#bYgU8Bgzba?dOX5lCdSIH~Rl!xla8%Hwb$D&Yh(75_I*ko;B^I654%p-! z@Oh{WYiUiqW41x+)=j+^mx9iQvxcgKT0f`4(vr#(?sc3?$<_#6hy&}eq;kmRHZYGg zIa#6LHSeGKzHnJu{7*h2){GY^ynWDA4%rk^qxP%S4qO+k8@nigSkUCMRf#3q>a@zn zSdp}Dlo9bpXFRyFH0ih7SKYy&$#1&i>A^J`?%1w}Dl%dOjWx zUU|W*v5rFX|6FiHGS)ege<2i-U>^D$)rAaFVKKxh=INwsJmAR`c#;_X(!Q!k_ z=9kF1^1o{QeKrYdf*kTOr77x2e$6JT`mIEe4GgdCHN<U7(=hg?;GdDH!6=eYM`YiIY(VOJq(zATq?id52r3n3XBo+Q=lYjOSo5lZ;0{4OgL z5maNC<*_W2Vz33|@4rK9N~8XR(>=g-`g!zbd%Jsd^nc6IVW$1(A7cOCdHiVY(VzaG z|Dum)|9MXKpPlx1(d`XDTfr9W*DK(`@&xVOJ1!5p2mowBqyneIYI!v-= z@N5$O12emv7sYseW##hna(T#w>XQgqY6NBRkCai_lIlQ`wtE5naxF;FdeXNlRbhu+ zV^Cl>Pu+0A$QS(7Jv`bu*q@un@xz{(cixKmf_}T)nXjtd+kdk+_h_~4xx9*{!`!?X zd}BMr7+4QmuqNM@X3_<|_2&4;gTtd>ZvJpN*oh~=2@I1_-ao$vmS#ElaTyr%;6-va zjT1^X`ylvvIoOVean8;baFR?ulJGd5#Him-FpOj$jRhO;pTv3pDYU;3T3VbrZ1!m9 z<^I+&P{X+P3RQq?*FuNc(8AmXuBos`(i242_57j zpIn$uv{7ncItss93!ZYH19s|F2QelzQZk6$=3jTZyU*ub#ONL#9=_S1>-Z1(5_fLR zf4Kf#=hjvtAHKyK*^6 zpxDVU>wnBK#%W4-3c#zc45olzz_a5 za~`@K?;;UW9;P1JNl4>459=iB=$wal?CLrPi03?2@lWRF9=k7eqjTSSaDF`OZatry z`|h4lDv-NI(~p{u(N;M zeJLPzxbTLF>BxNh$cfCqa*xi7*E=@vFJZ7Rse)`1!q(u_Y%_K_qN?Jq@-wV5r+k^Wk}s{H?bhWU0Pb#ea5vZN~ihAe0jCb0HuVxkX*;G{(=OuFH0U z74?g;z1m*eRGxAi*R|c&-#Ya}P|@$c5+oIK^mdRO5+x!1t$EFEja(Mdw(ASg|LlcT z(OExxb(O7O9RR~`4dc{;CQse&WG5f6)a_=&P;ot&yKEICEpyVi8p|E_iFxlps649b zXH%bzs{WW(bk=%m784y9EULDR6piVseOP&?38qB7&1q#aMpT}lD!Y4q0?O&A_*_rz3!o|qC({|<)R)_K1x?lJXQhu!*mP1R z%I?NGP0e{)18ElhIGM4&sI{owZX)VbGZ0w4mLt@RdSUMk(m~y@JCKz_x!`Urkg^@G zCx7Zd$TFK$61a~BIV-v{VWhXwg(VL|?tups{oEXePK1=cd;pRo*X^;<5(d(`EK z@{SdE)}r7$&Hy!Ku^07-b*qE5>oE2#*C>nDpLq@OxC;pW6;CGE-x_JA8lXo;;Y+1x zYyrY~s073MEK-xj69r{(hqI<+Ln9W0PA{lo)U{RifmLDwY3WQKaO;~@?q@n$udUp2 zhDxBXYj;ZB(uuH%(Rgc@uCk80jVm1!a!RnPW6N@Nbo^q)rGVt|e+7iH5 zlxauEIZsK3FW&4Q`${r-{LI&qVYA)WzLpH0c8_0gy*cXoYBG9*RrcQO&V5_4-e+a? z2)?^Kk0c|lx5Oh5M&scyN@L)Z-DR#qX);@$p|!D!Qo7_Bl%$FlkePioKKOzctEbfI zL3-HJ8m6N{cO}%0t5t1}D(x35=Wy0OFRrqaG$qeQ6#VgYI^@WY`BwqF;s!%u8(++I ztxiHV`fXvpYFkq*=fAjpN_o!}l+5AXDpuIzw5jI5^4V8O|ZG8=W2t9ay)zfg! z=WhjIxi8vvC6Vs4=t<=hzahtcUlM@oJbu_Qoybo|?Dp!bX_;A>vl)3c9Y*;k2#!YH zhs2Q}D3y6Ffc>3aznV$kGP7y9Bq$A>81)-RPHOv7hqE-kxyJ|lr8#rLuva$xWV3`3 zo|8}>&i#5%w#rd44_D+H9-M(3V&oR7v)k(?wjC)YxB=umXYzTFBN10ncbeLv9fdICLXGJtla zX20s-7Ntwsa{aSDdDpAzZomPG;NvgtHgY}8K=Ed0o~m4i85}OdJkJ;Byed=O#ekzX z!TItPsJMZXc5aT5AjV@Y3Oa_6hLh!;|a#Q4H$+daHnJ*}c3I$sV@^RcxPVr9hLirv!_rZJ{ z{9~4tuS-m~Fc6r;FSJt;a0uQ~z#K_`1q}|%Kq^3B_@-IvCgvCG0NEu4AYOx)qQdB? zj0Q?seD#6lUlSPgObj)u<_qZ_iNm+*)!hJ!hrSD{UTSV@jCryX=w29)=-psCaJvTSPNm;yoXU3r*B6^!W=N ziTH(MtuB20bKB`N+zFQkf!c{ZK&V_kJo<>l>9CleS9dV=uFq4hGI zj`Ix)t=gD|R!A4Yjog&P`eHdyZUaNe))t`d<>#2kDWCKy#K6w;qn*EX-%$iUT@GUx zO^{Z_!8n>&nT3;HKe33JnN zEZ;*IuQAAA&e7`f08{AzsXm)TX%P>a0s8#o%HeFE#Z59DNw0%(JjtO#c7ka-ftR|s zNZ$41Yi)U$XQ#zwG~pcQQJ!c01eO3@wEN@?Db_&A5U`;ECj&s3Kax80AvH9JfxJl| zUiFFsAY@ZY5D8oytyfd*QMezfz%Usl(h4P1;<01ewVVRmjjx*+<}W$LzcCGNJUtmE z`8mc$9w4KZoJCPkPdI9TB{15x`D?ZIGo4k!h5zD^5x3~!?o^po#vbV$V_ z6nlcJF*b`Vukv$@Pj-UyE=D>7oa@LM*93b3r)Y{UBLSL))3NT2m$B&h$8KNjJostndG~oRzjXw^=bORLJI6mByg9~b)rVXA$A1kDUIbhFe+^y%vx_s{ z{pIyx_vk1%I1G07UhnR7pErY@{q5a1&v*7;2G5}8{=spuyR)}*3}BBBs7V2~(}j93 z0LWhVaQjDiu=Q+bcjx%8&EUn(@jgO*0bsX+*IS3jJKJw|w+>-v9KJp{>OvQu1K|Cg z{TFDS)!pmvAH#^CWq2BNe}bRE(T^BA6Pr`^qX10Xq6R-6>^|?p!)IOS9SXAC*#2K} zgYIta>@|buTYFnCyHxK0;2csx>EX{mcIgqcxCQ?wAsXjq`(Xe05Pss^93LDW>&idx z9Ce$)*5S?(PRxtL184vz7U~=j7^u15WjHwL*mHoPR|g8=SU^}d{dwNq0$%au5mvXC z5~kv-e#jEp53~Hg_A|@=pKYJNyp7rR|Bu$z%JKid{q|4$|3Bp8+W+&4lMldm9pwV> zkg`C1x8C`7y|Y$!0oaB*$=P&bPCGJKg!B2{Z9_nd*?ylO*{1vYiDjx!hhAQ9zRx52 za)yR`A5Hq_G@kkY{Lgtjyr5$PIYMOIXl_a!<`ZlA>ojj<{{Q?>HtgR&B4MPMWJ5|i zh^IVRmS$-yO7kQ*jiX`;Oat`*&xn^@jD*yX*-VO1rBAqo1CQ?Gkk=te)Pe`h4+8MP z;$bOH!^^%wY_Er=zuU*u$zIQu$MKmliN$L7Z9`go9ipe52KMvL{#wU{0gp6@3QOD` zQ1&;!xK;2m9Dh5%l%77{J$T)fvgynjITkNv+jTl@H)!LG2C5jKoKROu0T^?pxDL=f z1w)GG!7nQZ=o5Q%4G%{5{u6ivv{yQf`cToh^)!Bg6}u71fVCnp$o~C8sLMLXVO&BV zr>o^@*?V<#+}(R!dcJeCb$tBSidlr!Ej@j+d$9lVzYvNs&Q{a(dJ9+xWF+y&Hvi(J zo07Uq_`x{6NG4fIfleq>@d>i_=;(lRMfckr5+x(+1Rzr&j}_;zA*CVo0hg4a9LswK zV0NHDGWwqqY9$v-aL2zH6@m6zP$VjQo5NsFW0YfgEX%&0j)p6rdG)~cDcZKm%m9sZN zz4$o}@0>hvksbp1MfC=49hle&Ii3@>JWt{Yo)yoYS;;&pteWtZTg~^%jOm^=+bg%8Z0JXxc~eafN;92j^HoG0iX3%cYs#R}I*-Q@Fsm3H z=al9DQ8t(YA@`3opA6{p7x|?5m3cfcYd|9)JWnKezUD2tM^UGn~zIRvy8sFSJ?IK3AinlA3bA!`uO^%M!CE3S$7)UhZ5fF=lh!v1Pq!Y^y zQQzA-e5IgB2xJ0*>aZX*LN;&`N2oHi znI8#$fGAU(XE~8u6BZ3HqPu*y+(amtKZj^5l(HkIB@)$hgonL)j9?O$wpI-O@c|zO zuR%zIdAX)jXpkAE5yo#ar;RFE0m7P%3Oa#PIXC}<`$iTFh`GlNyyW67ml04-YJxFj zMm~WvkKEiSuMMoNx;7Rg^A*0)mS67tN3=`F#RQq0o=H|QKzEP=<}-D+FmJ$7mKO*` z9>U>i0GuTk$Rh`5SvG*F%1~NWF+s^{5)SYzJ(C^kus<}iIStB{-SA>XV<9DRB?%I+ z4`1n9cZIn+>v*XS>M94(WS}{Jt8O(Ds1{y2%lKt%H1U=aahI+tVJR-7Yl8HGSWRrM zA2)rDMq+s&%Bo%Ze0P^4_Yy(LSSyZz@V91qngnJPU29OhGi>Frk)@SXfnabNpS{`H zecszT>S1G0_l%hAuu`6|%Z6n!3{y*U71n{39$%r7IIN(! z<+900l@(Et>iCuB=0KE-C#lvNl4~nYV0KziDB6fL+G-+m3VfI0{Ty0tI#ccq>C%#7x%??<3?$Sx`5Z+NE~?@7_qWxktYL6D1^u8vTlNM^VK%Nxp+cPkg}S> zc245iP0dDmrup=u0?UK$@O0&@-$x(~3E7heYs(!vy763^gcb-m?dQ*v!5~ga52SK3 ziwhzGp;H8pbr`dboItVzv1@}`^$Acon3!JQK|WrhIS%*bz98>t3=}jP7bN>5YB}nd zm-}zFdp%OCH1yBK_UdY|6v)rLo&AGDEc0|TSX=E-*ud*!VpE!5UkFDeusf7yk;V=Si=z$eU7<)qNbgTGHR zPBjL{&Pb=itYrL{LPeJRjOoqb`~`woIywKci$P517v_Vj0RDB~9nH;2nfY(>`OrNP z={{G^9o)yG=!%@$(eRA649m3~p9*QB$X|SEje7)Dc6O>9Hb4oiyj-^&A2wMU8Fz5* z@#@#Kl_K4$l{c_&>yW>u{?yxLu*GbeZ}y$62pf-@&|Xlo0N#qCRuH*mK39%l4$Mvj zZUG7};3Y4sf)Y6BRF%tk0Z7_pn&Krgwm@u;WMLa#S4$nid31q^dw};qw%j@r5hYM( zK)SLO{3a(bf?=k!tT%8qW>(OGC(|^60h2b}F`%`>o6RM8gkM%ekIsl@)`nM+u2CM< zgYOCa9tEPz8uU8!&)ABJZ8mMl(RVg{u*@1Ru`C;j4={!-!%)a|<)k%)qVO z@oP)eRMxxP1nO3bItGH$!Cx`gafEl)xy`!Y<0vFpC>UG=+s_hY6Xya19Fk%(iN2Tz z((x5FfHL>WFF^c%8q8O`=-?ZCTOS)3rZOAgmVv+dZ~Ic_o&^uXVWc}7({j_AAhKc#=nt5Og5K@Q*t>9BJM1PS|EA6 zMBSD(Rg`oFKJAZ%ZQfv4S$oxh+LO?_WRO6YsXHcLY!O$=b znw|MBqKl12Ov3dEs#eHyW-$QPC(tv6lOg>KPNP1uFA3{`s>!Fi{RwBMs8#S+^bo3F zOVd7ev@*P$G{@mwgR`ZfDR<)}+|;kfoR5J`yB#WNQcs|V4eHZO+)CvcfiEazCx1D$+H7DmCE71n0Tv4-WA+5dkI3#;O_#DPmMe6-ofc{wZC_}+m zrzdE7$q6_;J7K=yJ&))VZDt!MO=l-H`RFi{$zF}ZWUNiw_L4fz63H-b+y zhF_|2LglrPsD;2!U(N&t?j`b0@8vdmlj%+9-kP8=uGAf#{~YG1xbB0{g@l6W@i+zs zG%cXa4E_?~zuZRDKo?NV^a9+A7WmfF$Vg&toVOq@M=k= z7|b{UEHDw;0OZ0r>VHIpRuICP!OEyA#{1LO;nv~H8yD^Z4XzMct99m^+Q;#{(0?E zQ8z2PkCrtvsEZlE&3@eX+W00N}@S?9CY7@Wf-1vF<#JeAF&6Bd~SQygObkQ zv!$k_7mX7(+7Zc)^JlP6q!#1x1(4&`HeT1*L-0V9t?T3zWbLz9@rZ0lh8LP(Bn4;i zLs^V2h4AQu1NRt@M7%IT)&~giWvZ{vM3N*r6r5nLiIZtTWl!SZ?^6uADsJV3yrdR9 zL-gI|c)omprY*ckg^eqSii%)M)t$ta_9;>B1u{>|=e5ETjA8r7?)EENSW=Z7fyYcB z@W+|MA4@WmEMyMZlM!ZA{8XX*+37voIX>FiKXw>2{KJGzJ$Eh^=!hTKT20*pa~-GG);@T3CBfSvZkZy$cQ_W0rI?mfyX!CAZ_^dba)9iZ`0d?rkR zTT&oTcQP)pZqJX;9aCpzTDE}8zaRt+_Qvosx(2Z=n|#a- zO}a$c4>)rq>13eBx9_|Jj~}*R<`DuO^|!WRNQ|o6+2DAk)p4B144X;pwcZ*JuI)GMNOqa1!^YlN`le`-CItuqEg)o4_35Md=2a z&=S)4cyVcA)}D8$|EDZCj}FC+oH|KlG3HgG$mN^ zz;3;Is#Lt}hu?kGunE@eG_b!T^rcsdh_Kc)B=@Y$$p)A2+7SXQ1q}!-ekLWG6UzpQ z?1D+#gb+mi;TfpDDm{80D+Gxc?}{u#KTJ5VWeI_l9c9|mJCE7(I6?v-Tr_Je z@Vb|o1!_RWlSj6AGC^``^P*y1K$1H zwy?I#!B0GEICP#Qoa;U*6C*WY1V>mHb3CzvC_81!Kr@4G<^L=n8b)L$XWm85ARfy- zj*zr%nUMzhUx#$vgts}@X@OU_7?wavqVl{z=hGA~+t^T2UvpJ#BqlmYbxM5$>A%!7 zvsfGq!Pv`;t$6U*w+1m?!27FBM5aTXN2?`mgKn(48*g6!w6*)DJEJSw%l!-cpjy)Q z1!Di!d-mqV3rv&pH+{dz8OwR2*n43ZO|L-e)9-1|`i#0c zntq_IGJqnt)*2IKh*rp^0o+mtwR5C^u&k0`Zr~U|MOtpnh`A~*CLIB8HK(k@v)T!> zr(|w!{+r?HeAR0hJHB0RKRlbawE@;J8#%@m%PAS(X`_*cO%DJE3M)|~GiDHK17g=< z8=NHt1*1Mon{2?&;SYXYEnN-jfkOwz(1Bu7WCLy=Z)^4XqZmc{3n;y)!f$E&T(nQa zBO6a;*0k~-Mr6}VTcLCzlU7UFLJC=5)dB#b!JrZGJ!}*%@%5`$B%hv`BCX0Iqv_BT zS*$EFNG?o~m1-!N)t8_Z0DF*4bn$AiaC9$y53&$CPYH6`hlaENiP> zp7qmS@93!85sO{6!flv$$=Y|1ZNtT&(cA0o{Ng^8asVSV-QG)(wq&P;X6Tz*dpkNo z{>=9@+B@3D1a*EuP>oiNq&Wzod%a$ik6^zJf`R#!VOQ=Q1YY6 z?K)2_@ZM8s0X0bhh3&mI3xRqi6e5ZQJ#_oSC%quFf2h#eZE-m(P`f3JEugGj6=d#4pSBn$dvr=@?xZa>g#MmMcxdbs&-x zX~2d`Nl6;RYfPVqL{xle$bb*&vg{AEzp`Lj7fghYch#mkJghgVbBy77w*Z23T;yDB z8bo1dU50llso7 zsdG8IxMe*QPIbtJHb{E$kc)Ec8Qs1$xp=83bX6DSA9-!WJ8INa9;H;t8#d{AE|a_* zSfSVJkB8G7|3jy7YTW9ezu2@=jooHHoTGEO;d`XO`r+#)urqK-0v1HUr=X8l$qmd% zf+lvqQDSJQX;OGoLT=|t&}w^>F6qHYK!l&8xZxP>0+_>V6AYp3!%XGrT;v4RWiBPfwG60^2y8H36zJ59Op8wCm>rM=Whf@lZxhGgLWF_|t>G_srdZ zx|&g2z^rxf0l40o%XP=jetus|7WJe>e~p=6XQ+$%(U>CBC`I`=D#(RLwB$gL22&Cb zhBz0UD|wiF&d}QNK4krcu6Zo5013krHUybo{-v| zIit61u^}^by!U#4YmaqKU4M?0KpnA#I)l?T(A=RqTF5>ksl&vgAq$V9!Df@>iI4nh~Kr0#4U1Jmq0RkKsxyt#ZkIojF0xriyg^8C0oXL%?mog4a3a&Kz zi09$B><5?SFu(OqI+d|>I5^B~pO(@x%vsliW}+J>%^1xHfQ*6c-XCA1sqp*?yd)>& zU+6O*ZeW2JsF;ic_6)EZ&$ih+e_#sK~>La z7nAvNl{K-2`-&%twzM>}^LS94Gl1@qk`;_x(uj6o?#Y*~qpe=g0Wa8?JX)ckBN{N^R^WA6o#0tQJIDHE=p~S z8@zr43)wUN{fzI}utdkO0a9VsFLPH4KyV5He*P zl?)F3;gAL1QxPW$Aiu}V3UV#lUAF!m1OPY(`5tl7U)hU3#fV`2M=dmNAsh9aBE z_69EFBOcJq4u;$t#gh}N#Avb|uw{npJrx9vpOqM5nVgSQ+tjN8H78F0Qx3a89j8~% z)jsE;qg&dd%(0SD*hdw_el^Fk#_Aky8Y@n`^`#qDV*JM@CW3u*aUd18wA1sxOPuxI z);1pSzql{|y8FDAJaMD4{~uCug~V1+VdQDo{Bm)X{X zU{Y_$?rvC9P^k1RO6p84yY2AC!sL~88>l=a$^UXg*=tE@;uQ5_!@M}$+wJP>F!8OV z0M-d!Gh1oU&9xKxBLUtk%Vxe0TUd6%_Vj(3f;Y zp*B)nrGkh4fj%2*%C9+sOvyc6s0vE6_+RMWZR*)U@6@3mdXI-VH>caJ3^wAxm<8gV z6IrGOQ%3CWX0fk{4Z;NAl7%_!8#VxZ=`fI$F?1^wpGR}1ded7cmj;|&t`~1 zbMQ3c**3%aS4Z9b-}9Lj{~3LQzC!rt8{$91_isz_pC7kZ|BV0qM||A)&$Qwc{(0>& zIzm2LX?IpS-v;e(*V~=-)zxzJXR(B|V^SsTN^qCR&(yLV_*p$LQvE#DW3T++Rea5{ zn1^wTm9R|DJzWpVHbAYP@1jpX2|8Hcbq(3wc}7nE^E$=lJmx~t5x6A#359|?iE=+j zB_>00r1-688X|dm)kCYw&FX{OG5t%jdQeGr1Dt~+4JXU%;bc|mG;KIX$A=maAGr0v zDsx%;0Qa_zf7B4sVxb-$zP$n3b2Itm?NSenUf%#sybc+jxGL5|lmgXhs{@kTP((58 zg&i&00?LV@Y=@@uq6GKc-P2=78ApZ}-?Ik20B4OJ^jBJE%(0;jkzKI|06g6 zeEQ#Bd-Ny$|06y&{l^st;@??*yryFR!~Y)z?MLg6zFU9veKqyJNG1gu$%)){Ytla> zfCfCGlgNEW>^+9~*I0fr>h(Qxe%P%#Gpr}H@$sSkEb|_q>fd{G=0C_NdyW5aOo{ot zrz8NCp7D5`hjb+P&qm&ZixHoLNLKj5gQD$l)SKw6B~~{5bKrz?GOA|}vSF5ubLY-$ zZ|j%iEs!=2UeC4344AWG9g{&fWjp(+S7dUH({NwH@SFNa8dCl*%MJ)CVG=M@i5EqZ zi&-303Pa%J(bpC;klRHhvIrJIBN%{nKo)g_M$QQ&@l7*$0H8u{E+Bt-ewjA0$#8=n zO9LtX`UL-xC}h1rHTlLpyr!0HXFuu4CVo=3qvGSvAfQhDCY`^U` z+p>k>JMOAIWx-~UnxUHaj$tFEl#{XZ#B_4h_0oDk=_Aa}$vIBl*=X}@e4^xSsK(=y zrkH@Bg`sq-v+V7NNj^nR828mW_sAxJ63J}_yRD}xt(-~x=2XmvgK?irV*C{Nfd$Pk zc*T!!ehKPR;SMC)b)1(-4DJn3Q&nU6~!4 z;^&ln9$zZ8xlS0_q$?XL`bp49ck+SXNhCo547=-o=*`d}b51ksR%(i4~;C$|89uP=Fem2hu*psJ@dc9d&uxL|=5-paw(Cz}DUC;U|Xyzg|B$3%s2Sh7QA%rs74 zQvnOB5f$ql@8KnKr3D87PpP|r zTCf3mC&FSE8O*||L`T9{#!lkBs^Uw~g>hSIwDZE)oYz(8K!uJ}=wMD7rvgtk`J1c0 zu7$Gc&?RhXGg#ZWXDx|=9JGQpv>?FOINh6+h%TErqlUS#z_nUt5_0Y(tp~pinbuaU zW;M+*>sMZ<$`$q3u2gT0SMz_}Dpgc~sfX@zg*7x}ylGhY%M7b9Gb^VU;f(V~JaBaZia zoC@1q;KN8)$aW3D9q&2NY=nV98Um!wI6Ugr?@#g-C^CRFc>5oUc2@!t9h`<}oI?oek6xC>^Ru&zAA5 zd3Fa4-Rhwwa(TvuD2$4>^}T+Utw=Jq0?m_(PDm1KATcmZ9* zCG3Qu+d=7#reoGf?p0_n{QZ&Z1KlhtRX74`e=|YGjqhcr^TU>Vbvq_ zi8B+=3G0Wf7eIy3P~=YvK@$w=*v_HZ{9<_+ryE|yiK#eoE8?4pTaj3ljSY2>V8_wg z6-8j^eFm}x@}Kq*gm3SY(nTRIJlQbEATuYdXydR$v^K$X%>H!me_dTLN4V-*oN|*G zxOga3l#V~V;b-zp72&`+$%=Cg-{DCJ3e3%f*Pc8h(V75rk~?gJ^juc}_T`6QHCSi; znRB9BMG)rjCYTDbsh|@d0Vet+=7<>+6~$aZ3JoNv>x@tWg%gPP(3^z~%ng(2_+Y5c zj7|&5TY!^f0fX{OOIinpk|VA=qEJh|PRzrJdT1%a9Q`TK)tve@aRz)^0}I2u?Elot#DB=jY~FQg zx_W77H!}4>mJYVxf_HStwA}=JLh#*nH+(n4E_~Sc?}80_lM)_W+=L26i9skj)rY@m zn$%S@BSg_A@l1Ync+GMU9Qx;hDWc`tC>O(t{hi%)=dQweN%tn}KAOaTS7-ttHJ+$O zZ2->>4tBd+`x?TDu7;gG(G?YwZY)`Yc5wf`ntlUtcjx7g$LJl2DTy@Lu>*E&zQ!^TGUPRh396c_$sqDzj28#W77Qff){zXfMCzCk($aA8lU0^UB3D=AY zjbFO%kj|YUo!@Op=hZ_xuN=~6^jyrs_3EAVo!;u7olxB*vItO;09G}}s+ABmEF=7f zOsGOMy2Vl5x`BZ-+9=qE{iyJFF)?TuCz8Joqg;6QK_*MW@^L{*CjgD+Ou-TrggC(|&1g}q%Ibp8I$PwJ;Mc9E!s|)C3@yM@ zXbDW5VexxxZQ~6kXa#D`jT%hp7GU=BK$%Mk9P195b8M*jEiN+^OowA|ZIGHeLcey5 zXaNh7<#{4bvs_o-rijiqGISC0INJ~AVAS4^69}>o2B9e-Ywr+@I21FlVbyMJc zxYUCOfxogTIl`qz!D)5V?`7)uQ&@To^SQV6OAj69j$wie;7iKND48qisfs~2Z)y1o z=6-!Op9B;mar19vi$zAs2=u|r#xA(Y-N93bO{ah+w-#ev&2e^5Vo)rO2x3MEYD;0dqP0&!SyYN7k7es?p z$u?&oxx7yo^stPJY@6Bq#lx14qAxDDhTjt(AIl})Q;1%NQNB6tgZIXFg_){ zvwu&#H9;L^^&N3k;&M+ak3z3dpY@4Ai3wTdISRKYP5RR>YdPS}qBd!0oG=<0bD9RU z96TTpCXEkl6h%Y&@3z zExQ_=vY{0?Dm_7vnD~beSg-ccn`d>kF{acFwfEla*44&vQ#aIpzVlOEZHz>9Q`-l% zl3{rJN?Kk^-b+s{&ReDmYsW}&m{a$qoDQgvdq$?Z|%mLZjs^wdR^b9nprEN)PO?s&lo)HlJsJc@fNZhO!V zC1%9^24c4GZJ$hy!>vXV&NYx*S$f$$-a35Q!zUE)ffCYkI7n7>=(CT*w34fumH9=( ze1C`T>`d!2VmPS zuvd5N+N&md{_Y&TYS^6%eh5A;(M^)~e0|nHUfppdrM90U0-1uZwMguNjaT=7}%QsRBe!JTE zv_S(gTr|hLQT1v60K)+EwONet%>Pv%GUnic+Pu~qRj>Q>dfR*LDNiORWGZPt>4$E6 zwP(Y`KOAt6I~84m1j8{@%oO`%eJ4s|Lr@b*M>5fp$j}|U*=`ll=_JYz|oD3?omPXvLi23 zmps*cd0YuVgs~|FuVR0UuD)RzZ3Yj5hHc0g{I2a9$pkVC4PyeVNvl<|vP9v{1?U(? z8ZJXyo6?<4U-PG8yJ;c@Vg0}Eba$UCmU#fEL8gwhWgYdpw?#n`&`O26EBx{rsCTF@ zh$fgq_5OX>0w6A+w<3jt#<*#6pr}-t5(zxPjgkxyP2W!tdsGlqqkZ%+S`=5?pOE8i2xv{@Q3LtvnyedO90Quy&BSh2(dO%MMv9nJ{ zSLk%kGumLR5crskIdGw6q70|aX|NsIsCt{Oks{Re%snxlX=K8W*6ip(q{&dxcMvyC zNiAUk7!aE$(H-Us#!PX#?Oq{u#12_AwNbl5NZTl4c>ea}UF+$^-P(S+d+=>Jt@Txt6MOm9Y35i>Dv)%lMR&nM7@4OpozVoXds8@q zyS8+6yE**qX_5_CH&wYeRb2ct22n!7H)9w?usFSt^HXrl!pV0&QnIETaIop_0oxXg z%QWw{Nsew>PJ0@N4!*M2^e$7e-~GAN)Xe=z1|sI=cKz-U(ep>;L_#(crzaE&6d6YQ zcfW4QxA_2hxebi{Q&PpSOodEn@nnS$s=3(iHW{ zU51S6k{M9*=}A-6DtCZNYLppJM^nCVgmQO)O6rvvPzT9HQ`9hb>FdGlc^zduuTbs| zP)Qv#1L_zGv$Xqk`8@Z_NzTG!pjdrk&G(#t*biqDVsebh}6H^WMP1$}!y@ zr}^IS>l~}j8N~NJr0r~-;BnPwHB`+>>6~vQKZ?fiB_d>5wvv1Aegz6Trz09mmw~YW)f|2(7hxYPoFcMBR(Z|x*NR?YREuZRk;MUIW-4OMUKtM|~;_U>b%?4@f z_^^9i!F5(4tzF~Rc#Hg6l(4#bJs3|54h4WY#_?8`)2Z9pyRtO)(PSIy?xd$#u-H!& zX3&OaFKJbif%+(h!CI$RE}pO$kGM+#5%?~os>oQ%H2TRB8vIZ>uT`}J*#5r)!=b;Z zxF$^ySp&W3saVE=r&71pRPbCCusRwnVKM{m5WQ+~KRp<9Ap=8aZ%!()gg>7M#%x5~+g-KPQp}-%>Sej1dR}i@EprZAwwIR_4%{aQ zlWB@~cENj$zP;di7Ta@~X4>4>Dr31PUB~&lUNlOp%%^(k1g9Ch@erMLdt6b*x?Njr z=(sUz7J&|n1q3r|4wPz?uS1U)2Z!iqZsUigl*)^EY^kN9rB1j}RW2D^@lqNCF;xY_ zi31dN8BfywM56!ul-q*F(X8xd+deOCJa<+Fe(;0sH3A)KGMutX!T+q=6{$`W2jrc% zGX-bD7!zE_!4FqEgMhjCbW9h;bg7T2HfTncmzV2nV^9!NABy6gb9`mjw=3UX;Q>hS z`mp=DURj3mc8Lyb)D#%2HN(ZKEhOlKcvMdvjGhpS^L0C=AyWC3tRZrk0c9GAy<~;H zyQy4DV3iF4&T7hqK(T}=p|TaXTxTb>bxX#CPB%Fgd?6gYQ?oo_cWn-*gj(y|tu>nY zS&hvw*0grAe5Y-6GWu#|i)tOnFk#F1@a>!%wf+~!y@D(Vg1q?ld+JU=+hZ34*L;qGDg;Hc|y zV-{z9CtC!B_2#go`Ng1w28cGBO#4F@(Sf&b1|KX9sWDF+YvYP5*SZ4g;3?jE3SV;T zabE%ny+DhC-9ER81ENOC7A7e^0x=VTZMcj3VG|bi!xN|of0mY-L=W6m77H!SL67^2 zTUItqE>|e6iQUMDcQtk-2@TF_kS{~l?01e|jak-*-nyOPcKzKjPdUtKY43Izjup^+ylaAAZf~?>ckA#mG+jLBH6K=Snq|vY1gWLIDRoA_JWQq+d z3CW+If7z%0{QpOieWe62H=O@#?X^|^{O^3*`Sbk$BR=-|Pb<#ZzuLk9JYHE{gRkrD zN9&ym4j>B7;xwL6s4+A*;C#@0wQ(BtKPMSXIm-)l>+We@NXzc$VHw4KE|sdxEI19s zPsnNVH;~6cz-#<%=O9@8heVR+5FPjjB^#UE!8!kr*3(^lY=>UN5E`oJG#zFrVv_WP zFSrgmB(wJk{J@;8&ESE)WXF0|EfQ?0ri6|F4uo>aZ`$z}y9a;6!T^q9DB^n&kKqwY zo~l<;9=l4u9g7Vt0FtH~LhNtQh3sQ=jww!^`M~aQE0+3GF6?;z8vh{11$v}ZFm4|` zffIo#(*UyueCt1uz&V(MWP{9HNN1c_76aIOPD)?`A(Y05g}m5Gf9uhWmv?^gNJ%x= zJETPlc&(az^ey6I@u+d>QJEog%*9Z|r!Vr9^6_p`T3%~;R;_h0F-?HOJ!P{s`oV6OZw*t z86VMZ4Nrn4_1M&~uxOQ5=gSwztP*rxqPsfbhJ0MyldwdK9DK-KEWUzxO52*l6A}He z_9F&mB3;^c-Vp>2!NYZfq+yBB5O8Gdx+zRw*TsL?a$BcKC}71 zucH9EiT_*eRPcX)=KuRcK0g1)*_P)KZZ6sOrZ~Ig9 z>Rcuk$R3+Vau%ZG5HJ&V3FKljk0tzAS(ZT)S@KvmnAwy4Hur1Z->pY?tMxEWCK+bW zT{IJHx4NsVUscuB)m3Hr?-i|hV8|@^eRkYe6z#6_l3r!Z*Rl+k$%nvcYK>;cuGMPf zy<>n(MGB%=8){0hGPdg#e+v`j=SHYcEfDy24Nn^y@SSf{HD)nhSPLka9x!{l@|qR= z^(vV9$nQ|W^Q#TKrP;J!w1HXW1Sy*(DK6=5yuUPgXP;a`V0D8^{KH&#OkEg*bc%bCSxmUGvsYuIH{PMF{%k_A1;$Al zN|SZvQBr#q%JnTSZSDlx7jT8%U_hn4h*GnnYOrL!BM!rjT01;4WQb&e^l_(33tZUK zJ}Tq>U7yAB-(WTxe;ozj68Z0Gd$V-@w+Y!F<-Z4bO!<#ToCLtmmJ9&B{%z+e1%Teb zBf#i-mNCixEhK{Oei#;S=S+T)=1Gk$JTrV)OZWzsdu`DlOkErsiVt zf*b~PUsKps(&XUJA0{EXU%RCbNHa)vov13RF30*i`Y}VvY#%BiNQP{NX>Wp2qwmBH zNfG;Y4bxtcey{H|VtchgvID%ymHOVBH0GFH)D)0!=1zy8B*Vs>3go=uW^kED71=CH zF&fKN0RW%_P*t$6{IR(%NFh4Fvs7NfTh>Ho*&3_xojb^;_fB87k5yiIJ*EOcb|6KR z_kfk694_uEkRv`jcS%)a<5dTAjG!fyieJi?eT;6G)!#x&NrIcBvV^Q&tQ{e}){p%`61Y`(zg?9Py_Q|Y^0 zIfn1V>NRwrLhEsFk~!t7$RgCL-W?Zucc)@*V+k*wrX^VAals2SPV7pIKkSs|g7h(t z?!}*@qjA`1)=RNERz>1|128_EhZm|hX@x0s2HDGbHz*0+G$7SsK1xTumU$2 zGy;#-B6<`6)9*yV>x9=3O$I_zM^8K5YN4K6zH`AX<`41M5+7swAQqNjr>( zi6W1B38)v6c);Wbcyb2Z2M>0~-X#5u8E6a*R?Fp~A6oDkdn0pcBe;AXx>P^*@67`{ z7M0`Uy|~ZDGE%}Pk6nhhDvJZSVAy^uZBV3LR@Tt-!*$6Qr`Z}J&D@}D3g!9*hLtJc zp#08DrzZDTQ5_$d)7xnXNJ|C@? z2d>Y7Fzj8v?(Xh)Pcb6I1q*KPF0Z-RwW@{r$hA|*uWDt97=^>U_XfUps)bz=bWx0z zJL-3rRHR{wj%o&EGs2W49Ycn6G7-|47Pz0^N32^%?h$>mbmiXC4=m_P33R_jgIVWA2k4?^K5(L*>iNK(KFA$)$}{zGu{#K)aQ4O0D)i>RkmS77WKQ9j3zu%yd{1jLX*~f+4 zbzxB(u!uP4s?!T`juQrprWY-M1i5x^yf7j=Zd!~`1YKOf>YS$Vv{wwTIZgA&@ zs;su1BVdCBukDjs5We`1oN!d)BHL$6jjn75iPJa_DO>yEPp*vHC02Dx+s@X%Ow4wg z9o%VRedbP?CbmTNPc*S}#tgDYcEpDu7-wdVT1BD#ML^rFX4A446sI5ssyOL&*4FsO zB^H(~v>{P`-O1JRu~gH-iZG5f&Di@fjWhsa9-Mb=O>&lU{zT_5@Fm$ANwujXp=B4k zY4U~EZ?38Y7%CqWFgN+OIslrX&l>42!)&*zi|sV4I%lkr&6bjEqGE>aauZWs zYQZX#ATkcwDFeC5fS5~A^{+9ySguy%ys({((HohhmzM@~(tXu*0y7rWWViQkap zMFBiz(`-4hb1fw(&1QI^_^O7crXClP6cq@Qkc1aU=d^p&-R*T97T4bXbc*qJwJEe( zo`e+!P|m1C@7>;Bx7U-%%l&O=(hT&AhCB4ekrUdYVTA617i;L5gRZ1!*9Yv8Ku^Rf`DYJ=%`ngwo@0cMBx4!K&o zgdZ|vrc{blP)AfD&_yxJZCD}`|7=T@Fm*UQ!^Xb5z8bTOAE`%o$#Mn&YO9&C@0f~o zRlU@;yWA|)hL(%Q4mZ~l@!A0=(9&*rzGnm zF2&llRpyI3WKCkAJ;wYwtO+3#8W15gtIj3aSYnz0o0y>b3ay=}OI59STvV=Irruy` zPOY|MuxfN{gV1v~`4JY-Y?iI9X_9cLT)wkH+f=Kl3@);0QzliyoGZCOrk<6AQc)#9 zR302EzP$pkH)@|R?#C2cgmb(QDb6QomQnVfv8|(0-cJ>|3t#p~( z4H&Fr$h(DoJFA6?XIKo`7mAsKQmi~>XT$uELJYv%yhpq%9P;OuK&s}HE5$^DfrYU) zVlr;HL(tY-HSsX{c_vd>abiv}aTVUkZaYHyM+STiHC#ukkL4uAT~-h$v#V>o%#cj( zXm*kz1A$0ev{2+Kp0laD@Xg#W*K?$Q6o zU&{h)iT)Sf7483@w%d>P{}1xy^uMuT0rs@L+yV?)+gGyytI*TNzs&}WHcbVc=~vX$ zF44(W+$3FUU`9sJcnwn8Zm){ImU5VHq1b@-WJl2D+MX;NB2+rZJUe~YJG*>!c)WXh z*zM^aJ3MIkPHNZxgSHrj)LM;P$=U2*v(dwhIdz=$Dygc35p_gfRd}a3>B;4ImR=7f zKk1?Im(-k*=kemfspUWxsWiNkjA#FnynS+E9O~}rY44}wv)vy_MwJH2*<=8;&a9%owlOm9CsiY_n`T}1TRquZDT5(U-#@Be6&L9IdjOG)s{E7E9B?x zOcA95n)y!7aL#vhm8Bj_*Zh0pYAbr|vcE}VJM7HE1JRfOuXltsi-Y+Xu!4?<{1G+MPB|Vc?)nHiPAslHb zRI1A~()%>jwRHx=VsWSlHh(aW}VC1Xn(f3(fWPd>G^(gPT~YJ5qPvOonuxWq*z zfT;tBRsX4#qKxw5DpS1Nbd@+^X>GfZ$2zmLDcap}GnL87lC~<_s$z>jENCtp*%>YU zK+UYOEiyf*DT};&ji{;(_{gD(Yf!Bn(|T`_*&d|SOazie)^*yHPnJ-2e2!7$QiHzC zu`rjDOLlQdZPN!O*^X~L<}PLca&Z;`WR`tMQ96>I_;RqVTxMm=R~*@rLQ0NorjyF4 zq^d?%si5Sdzb{K}2KO?v!18$*=47L&-#BHJvEPFBq2*uJIGwp_kye`x+SRqPjoyMv zj}jlKr&+Jeeoxnytq1SvXkIzhrE(K#r<6^a9p+n9$U|m_`5cv#N?8srq8gG|86BZZ z+|v_=J>rtNX67t3`!^C*oNWuV(miR-pVLb###W`BRs}NsbRI|6`D7N6Qahp(#@Pgy zW{u@(m^XVYy+^A@*ANI*s-d|VQ+4L^(z3JO6(jFMAUhpgHD%F}_6 z^squ!v{^G1Yse+qd=PWJ<}P>(FITVE*5rjAni}8Zyf`_ocyn-a`eyem|6-Mqw7;3} z)bxpT=*2ObPN3Lp})+;h!7%`QMX9r#~#Hn-aw+ntTC zuK$ycK%}bgx}^NOUVgh%Y1zJ&2qomx1CZDe!$~sA^qP6s0bh@I>`>hXA-%ui#Uz#i z5h|rdR6+XcR}V6!qBN2vH|O}ih!3SMZW$LUU5LTN;VeSWqe`8JfmA?#m0ghxh2)KV zX4Y(ScyRb1=N6DB!-7?qtfE$H&$l|C0S~>jC&OXrV+6@z2(`8$kXy zwl~__?X5id=S8lqxIg#E$H!xl1xEd!WvpLy-t!qY_EqNe*fJ$Y*D{Kh<>;vcfLeoO z$%+Gk?@tc*8)H0XFfV=EkW@GUpxUZ0Yfn?&qZuqGb>$W4X-XSzR!!qA;c0fu8eWWN zQ!LPUVm-N6!$@(D+*E27l@igUr|NgxN8#GZ+;yro)KA-7*WhO6|$*auM z&*kY?<{9Sl3@h`*xjb=Yo=Gmxq%zMmmuFg;=O&luCZ9(sDe1&5OxbED?_SLIIkFpU zVARl|%}=dHdqYgsz*pKEGs`Iz&orF*vHw^x-IM~Nl0}Ecq^ndwS6mdQ^NqqaafNXl zMtMDK)va-vS>G8KFNFoWt-uo7!lL-;i(qJ#vjl;OoOXHe=FHL8$rlvYdS`PT<}Q=x z3hJR;bah;{`lZ0$aaRVGqx;DKR62^0<1z>eV`2=3u>oBrC6FtRPj+~3KK3(b0Wz7^ zJ(*C#TU_}RHHpW|04G9M8Zr_YIH3!>Fz7}sBeswvgDO|X_}MiQ`)(nu8WWa6I5o;S zcg-kLDml&4)7%Tx;UUq(&&JRh^Gw&vVY)JaB?-wgoF5y>#lZ_Q#OF-sD}xKngz2y_ zWz28+u6glZ+IVZzeQV?@q3cGh7AcKJ5J!gUh}Yjb^8Lc)Z{J5r3l-!G0dj-f}p80gg{_ zR0!(=Ap_*++f|6VT)|&$qg7Oe=K$#byx6V!ZGXO~rqrw|fePMU{^iYEJJ)ULJ&@Bf z=#Rz-CHY|i=tn2J`+v<3&HL$&Kw6!rio=Ci8?nT;&BUIWn1jBOS`MqS4HZ95&X>y3 zim9ycU*O=NS?N91e|L29s$9R3T0$T-&m8;n3;RCsXS=VCx&`P*2iZ{Zq{5()%X%@J zaXT{fQ@O%kRfW6z`*{T3y~_Q5^Df`~{lo8bzu%txko(>J-?^VhXZfGqeB=5Q8%8#h z-q18E%^FV3O4*A#pl=r^u^!-Ty_Nv_ivjwJ0WRuiSX#M8tC*{WGzth@nnTk>$kn(8 zgm!)5>`|cy%ad?yIV2I&Dd@d3P(|+4L*l!xLCXmm;6idYF|9Sg=|Y0b^@++_rgi$% zxI{g4*;rZ@8y7`-J(Bq6c%9>=Wo=ujmA%7PbBD52Fm|b}U&z`E!o7JY%%=)zb`Fv1 zLx_|jqGm@AY4y27>ROFHpElUWaRVkBsaeZcQt^Bx-Ch|uD}xuJv4ZwFT2xp`9q3f) z3)7pz$l82auU7Cwf}{4*Lfd2LDdk54=8#jb6&#jS_$aB@dJRL8u}!Z{tGx=ZO+2}1 zR%MI=8bXJ866Z8Zrt+&KxcJLrgfe$0=272EYYnisa9qtiwnET6__Lj!@}^S2Lqv)1 zMY3vTn;?Ixp5ePrM!V&ivxG{9CC2x0-a4i%+86yxE%GR(uvBQJIN&x3jw@rllIp}} z=Pukx76r0U%40)%P4;1k+!csNqHtEBt8K%TN|%L94N&c}(L)kOf=>=(oOz}8L7 z+P2VVl2#E{v=Yz!O=3z1<=M7rs2fD(3C+Ta7-ln4&MhNF_xDiRbW|Bux2>Uk`=F&%e3;ck%cK{&muVv@fq? z$@y=)Q`Y}K+j{z_|9^<5*%Ua?c#C<2QFKrQ(-+^PkBD_HmOvLkj{r$ht-~(@O-vllA`T~O-;0=>$g6DP32qBG4y-spH-$^vX-*;W>|5&yC?(V*8{a;HZov5Uy1=LJAa~uSbch|7d9^m-oth+6GKlRSKZ<_nv zx839Y?(vx;yur^fH_+{49H0*#Z*o^>Cj_C}aXL72feNCfS)F{@Fk+#bq%EH;A?>ve zBi+c7o`<$7g#R*xc27@te_G#f+&b5|VP{}d;fjCUx{&5xf0UKqLFLy(e&Ly(-(6rH zR{7xTIlR7AuQ|i{{K9RsZiH~#sCt1SBAWO|LG;Ry>S|2VM3 zZ8*ISW3rv_gD3({G4bxQRxp_DbnM;64JzV9!EowKld-MwZ#(p+b=~YJL>Y7S;x>DM zjxM6%Ir`y%h9Io9IkuQGp5Lv?0&DZN&PAb#)GmyEH)DMFb}3BUc#;feen3eSSA-&1 zl5dq#JA#`ex(OPXEgO`(QOCJ+?#A#pbP+pjh{InT^`))?=iPVB6@>p0P?Q8Zqtb93NLJd8!mpi!7n?M)|ODro&z}Y>$tOq3C)f%14M3| zAg}yNdG9!{IZKq+tm}a1G*0`}p9Dd9RtzTIZ6lixP|~$5qyV1p&qlKd4Tz!iB%paV zj6(lIFfmpy&k#ABYR&SXXJd>|;a{uOfd0@Ogr^4BD@5CFf>! z(rw*j+Ige;ESY3&q$cL6kPp3AAWwdamN>lNKH;DAg4ay;hJVv5?6~X&{>tc(uh2rw zXjP{$!$S^*jh%!X0jZB*;sX89PXI0yc-`GSJwwtZI_#ZA{)PW`#I3sl)N=!N^WPmE z?srcqU)#vnF6Qh0`1a^zzbi8uz;yPu%DxHN4-R{;b>1vzTjo~ZIw}RrZppH*-kqIw zPY;fM(%82hv&yys%D`5oDNtL2i8fAN@?J54aRxa)8`Y!3gRUAo9QjE=lk_&>$)08$ z2gDp8h=5PUM8Gv%dYOZmCZmAl2~LF}f;EM#(x9>_GIPMpL40EjAsmHhPDhOXu1PK~ zpt!_D@)90AXUo~NOYh`>IqO@%mCLVjfSgUIv#xMOhA@k#VZ?fW-8?AbcJxxQ-nZAE zov;7JvTIO=q!&L5@InMr1x1`St5UTZOap$}<~t|rLHW&*Zy~bYkXOlFU z|ojM&I4jKZJ}SK!BsbsQlY4eAk1N}5e6C)E&_IAO8L zq?|OdHrviRbo?JJ%0527;aR-@8;1R_v;A9Y|KHgt`G0=ee)RwRAP=l-80aJh*(J<; z-4mnrJ^wl&#&Q!(&|6kO*3uZ%u3RMJHSn$hWUqGY9s`v@gSYtkI#HK;t)`+s*OgV9 zy0V6anjL$MzW}YSnbMhzGw(&s@oWN{%|MW*UZSY0rk{-=6qb^U3)>l8h02BJvo)FH z&hEch}Q1hA!n>%4)+cX@cEYv2){0ontA+#pv_t9HelNkk&VeOrx-rKr1HPN2!Aw z&IltJ@PZaU{s_gUNi2h{*mVYNS&kLMKPm;E*b?{%;CBklgW6$@BRtJ@0F+&aKd$U? z{K*+8VIXt-(Ube}S^C^V|2^CpgkJQ;Twodf-)I;0f6v;T_9Oj&hzALVCZAD~&L#o5 zq88)iHkb@&5$`M}o{mF04Cle1IZo(S&=}=RAUJdv=vfpcy&lz*XZaBVXaiCXZX6} zr^bOTXd9KK%F9$VF@&5LLvcWDjgwnqfn}bE%vC9H8*|6{6F>*Pp`cJ; zgu;-p3tC&%GTdfDA)W7$k6HOjJJ@ARY<#j}?9J4E6h^C`#p^#!CesI5|Lf1zpO)_b zZ$94te~<@-yW2#BBbWwg@{y@%J%KYI+u$2lr@dGNa}SG9Sc4Yb&A!HyQsDNU=+DAv z+6)bG#X?XP2?W6$gh}#8NHXKwOi&bW18)++esv5qLv%XrOkns0%Y%>*IWyczqpTA> zpYdK@iEtx#|ZCSHt+<$7vt~-w)?0n_hP6mYPDtn zX?`AEIP>$-g^Pb2{8^(-b$aWKWf=;rG69KZoTMZZXUcO|7QhmmnKsjqVdO?STj)ll zer5e}_}rZ-6*3eH;~NjepLn{B$gFi*tnT7rbq9g>SVhU6Pdr<{! z5@5`bAcG<@$X|@0@UBQtHqTC5^{H|{pqhd~eeV9l`iqA;w}YS$f8Tf$_`5rv(Dys| z`GE0NuEFupCtvZ0XBM76wi>H#sk=0$oPO(s_Oj`ulI?&z#3Qi`# zb)!4h7({7Om&F1Ps0!L%1%bfeWmrs-r4&Swir?b%rJuv~I zf#+YVBHL*4A^Ks8zF=T}*J}J7`S~cAUMB+%tCB=FxB-cin83k=2!5IIR){X94!Q6& z7?Hvo+XG#p0;{o+Qo|3TG@NnhTj-AXIta;ZP^g;}c@675R`(=`-;|1AVmL`+%p_== z&_};huW-X1tD0~9H5<;6b*J^u7eCypkNyT>_&*dYw zP|_-?ny3|&VEC4AxG@OW@#eS42!=D%Nj>ikXeUgWY0?)5Lg&H!X$bgct)ZV3L2)R$ z*g+`@??I}MQDC=R=ud(oH8cR^)3)$XhVOA?Xwq*-Tmf7R&;)BSBCl|?E(kY|4zz<2 zm4>Z*(8Q=hJZ$t^(C_TEIj)?+OVjX*rZz5)swp}jFizLOoc!O_A4Q0Vc^32kjB0*q z9m~#t*V{$=pQjt0$NL`-@}U0zvsq$&5JXeY?F7xIxaXfHFonF>4-6dw18oe^|BEy9 zoMB(95`4Get@Z71*9|p9>{yU)IX--PF8X${L?1r;%5*Ut!h6?4I~Vxu<0q;6ynfp7 zntl5@p_DuN^qqdwV|53qDpdVLJnZ!u=FnRm`p@%6rUvRhp^g!9j8jwn-p8i-*tDD} z`7i`lH%SsY1sw``T_Qwr;RdQdhaS0T$q=){hG(x18-Tx|?M%sll)BDF+}jHCU!B0s zcPtclu(+u|l1C)$(o(4=(D}hM7^eYs-2XkugXH@+>}tp!!*9FI^|rIsZsL77vdhTSM0*0rc8#*Re%tZeYn?XV z>#Efjk*bxAR(mMWU5~W?tQGXsH8bVlo*IU3mcdk5t@xH>wJd3| zChDr6_+zc}^k0^YEMEV{HvS9iShoJ3ZkFOdY(Cq3T>lU8;ME0Ku+sEPMiFOi9joNh z1v)u$9Dq8i+iO(EdMX?2EO41j1JeJJTG*R>Pzo$-)gnWZyK#sFBO^DyXpTiQ(#B!p zzljJLlMqr!o5e4*9;;qA@8K2cP?-uDH{2vi``}zUk&}#_D_0Q^*ssvCK3{3RY^)4c z?Ujp_bhUB*UGKtHel}apot1R0(OR|tm)xKxACwga{usNi)w8%#_yH~FT_k?Dq)CCM zDOW%_(BCYgA$PoLOZoeb|KjyuQs({UI+oi1ZxsFiJllHuX#e>j4;%L{*U{E-bpRQQ%|cA!MdQ{>&17f7X{E4(nLh$zS}S^KA4581PE`>wc8 zuFmn}B6}kfTxt47C1sb11vfzi+d=tL(~IjQ`OtuO@l>n*OSID5QxO~>Rxe(> z$aYt1M@BDgma(SUMS~n&EmKW{x;jWfbJ-pAw#~Guh}Sw-M92e^!IoYV`b*dn{$TYr$X0&dBdjfd!j%~1X+rBj>)DUXYP7qC|(fL zA$*s>+#`tRn24x4)`d_EtI~j#$1%l2ESP=x$Fckgyj8RGk6vv5g3mqlU+u8IxQ?az z|Bd4P->038NB!S}Jm`1tGwnd=mI6A<0+DlF_(?Py#i?lEJBP~HiXH4$?9HRX-aNW* zZ+;0|a}elq`|`+nV!dpfU#{F7Qwcm&-d0pUr_Jj# z0V&XwKYC~$retpJOi^mN)%Pm6S^Vca3# z0*CL*o9N2qLfNOmLh{DOEqvQ>e+Ua&xT538yXj0KJiHeaXa4UpNOxfn4S0`^kLL(1 z-gktz);I1fWmoLUMJHMs7-%-o2^qQGlunD84E)i(|HnUz*MDaI_@#9$TmS1@Mf>lk z8=H^*pC0644a-8?)@;qocn_^sYq6~nzLbklg@@qVA}cB16oF3w#la$y6t`SKd}F=q zbx$o4`O$4rU|c7GJRnd!Uf=%xo_qZNvjzHBsAK8+e_Hnc_Gtg}FpoU{TYR-3Bpv>p zxW!Yx^09!_`{Xpmp}r=m*SKQ1%M`)Gk9JY(tJJzkC7idrXRjY=!B>3l@&BOiD131p z%k;mS?ehK4$Me63dF1`i-*N+`@*H0@199w<%U?Z##D7aI0lSu$QaPy@$P2r?F+>u= zI-Wkpxvj=$Z86wC|GI-)iP9z_v`d=>vQCcBLfS+{;fPW0#NV%;I8gg2A%pnQESiR6 zB#zKke;+?F9bXch#@G>8pN??Bi?H^!411ibhT8Nf-(HorR4NDA!;g|dBX-2t7XQ?) zz>3`vXAZxL-Er(5qacRk$Ic{iOw3zq^*JII#EoNi3am#H$n*$0Wj4kEJkBY8j3&*c zFJYKAA7IbN{VlyQ4-!5eEw;VZ>I zpU4BBlC{|1tyU{+wX7$Wv(9wKFg4(>-?>^6EC`61VECPBA%Ie1DvNZStCGk#@owQY z8dc3LXTz?~-SzsN%YJ|g=>Glg$-nXHU$Fl7PTu}>didSzv#(Rfvitwfo|WSNJ$Knh71#3@y_U2hK0R30=K<={FXHU&{~i>?6x z1iA%C*;-5j9Zmvtf-{`nqJ1ce7O*Ullh3dw6yf>_$eNz-4T4eV*C_`GA;HAQd+X8% zI0YZ}`YDK((;<_yj)4t*v_f03Zy2iiDB0WcAoBZQ!t9f$4O-{q486x3|dKTFK<< zTiJxx^>h>ofZ%@Jr(WMn#&?tO>Ut^~d$#EO`Ollp^>+IiIavS%9P#$uUh_0epzgOA zBrBymIM7$95d$FRaG)w>{ z*V|s2CeV{8-wqOgmMQ+w`Zfjn4g+iTWC_crN(O-!)#Y7A^~&%dfQmrk4j94Jk7fhJ zLA{Q`Q7CJ`;?xgmox^-Ngr~#Nzwk4lW{qe42v(dU1|fp(!w|#ZVImEbgYEbh@2Lh+ zR0jxQpr@q5&S5K&1p5Z+mt92Wjknhz*5+CgrXa{qVyKb>kiqUDO{m771D~8)klTSI zf_aTi^OKl8BB$GR^nk(PXs9hb%)n(rpSzm|V4RJrd#`edRn_M51~j5&MV6}^*#vmbU(yW+4X-kzR(f4JY>7uIeMep`ycl2)m@c29N3d$Xy zoQb1DSnL4w>_lLN64YV0hrr%+PxoHK&)rvtM~7!WIrW3XvtxvLaB?bk#oOJ}v%|f2 zN4uvm(NEu=^tw>}K7c(wJU%#uTDot#$7d}8)k31^ehk}C#y~J_bl+tvv`YT}^<4kZvyA_5mF|CRu5Ug1 ze}9mNhg$jj5itJsdJj0v;c@Q_SDy;P2y}@FcqoI0At`E6*4KwUSSvqKR?qar11u`O zLgR2CaBLJFc_}iBDDaTc%bTV!<5$HGC>{Wr1SDRP>qtWu5lU|Gv{!lucnVP2=50X4 z)^InkeZT<6O2eyI3KYS73X6aY%!M}|0~=vq1}zOcN)u$R7?2Vj6Okx_u62r`M}R2+ zNgg!4i1ih!zE-7l(?SnKD34&s%qW;5wdd0^;*~dH8j@J_Bo((oAG!(^W78@T1;i4D zL>ryJpG`4FqwMa5f(?b>(qfI!o?81s5OW)Wr;kvA0QNf!&^{7-6PX^y0Z3-VzXJC6 zrZEs?&qvpV7S;^FQ(f_@*u4R9%{VbRDp9y3f0#brxmbfCCV2Q_2lE=@pW3lPtBx8z4t?5fnL=i3(beAT<-|T{;bb z00JMHMW}Az7-b+=+_l63Ifu*Wnnywk?2(WN?07Kkw4uEUaB_kyb4owRmdL$Wzzn0}cVpvK-)QNQc14Fx_OGg@hVk{h! z?1wN0&Y5a1mA0}LiCgJE(!UP;51GbD%Paqnz3%{zs%rjTiW07(fGF5rFAK^BH=Ar| z5=bC~0HFnwASiXqO>$)$dv^&DQ50;54G|l55gTG}fQkzGqM{-q0)l{u6vbXp@H;be z&Mmu}gr=YVU-CT4?%i`woik@<&dhHTz$2Z;I>C(vB)cWBBd>{MTylN@)|F04gph&3F*%GsA za3H#c#$>Y4lIlyfY_!?CEyi}vw9}0n!NexlYh$oqjExfL_Y&IeJjwvf1lACZG=(OsqWSll+RFr~? zT394J5S$Pug8IP^HDo^pW~Q6SeQ^Ci%VbOf&>FbTA{aHfEhu20L_;uaSUP$#n4Yb0 zBQT)rCd?5ygR{3x=P$j~kBZX%HWy@ver94}_`O^~I4R9iP~QVMJI4BYe6ctz4PWRm zy@8htylP>JhK?kRD}p8+)2;8o?OA>;v;c$ubrWLk=1|M+mpkx^G!6X7Pft zpa?2_R9c8NIOS|jk&g+=LD2?JAM|A5MivLeT(F4*1Y^!kL?vKCNhceKXcDbxsy7NY zAD~3+A(MF`QHA~AsmlPO4ky^K%!d_!nVlw{i0Wd5fFR!NUy7cD4`KX&JQ#t0;npAi zt-${Wl!-1MWX}yUF$JgyuSf7x1S-2r1&O<` zXig^o`jkja9Q!aR=mH;@OD>L*G9>!Vs$`E*c)*)G>;PIw`P}GYY`7|<3)L3h2?GEt z7C(FpX$%^MDyb$o-ce_;YzJ&QAMTSwup0#zGRBQO*!_`LZ_8)hb4jmKYe>-;Ud?f$N-|}a^yfN8-3i#Cx8fOF|XeU<| zY$_;H=dlY`B7QLfqUYIc`&Ypof1EKOuI1{FH6;jl+&+?vxoOBG&rx8aR?`bi77S%p zu>Y9~REJ`oiJ8`NtU^z;!c@&Ow$u&WU4hJd00r=A4;hau&ut!j2OnakO zx_hk;Wmb0NM8ollN@AAmbh3nu8KVN`t5(Fxr}?8#9~}lM?(x`_Xznj!sV3ogIgY%Od_U&sgWrCvTDI!MkYx_1}G#F z=!Fa8SP%yIQu0=~r4HAubH@xXJ4=EdUnRJ@b9(ULjT;vuEaeAzd~$KAJe&&R{h%l6 zH+)yfa7HRRXaeHEbZ~2chumJk+Q2p#>i+39Zo`gZ8)hBEHe{29S0x%anIIAudx#2$ z?%1C&2;)eGgFE8!jq^}X2{V8fk9jJ=7c8HI$^7Xt0| zhgIP2ZXP&R$J7#qbsIQIBA=7(R`eY^6>yY0(nTbe$j}XjaRlb#&uJ0L>4iz`g~=c? zg4-O&f2KRZK!D!TQoS~k(RM{htlEeX>^t9$m=GN9%E9^^Rl`v=riww~jT^sO7vm^5 z#ha6{QYD9D#l5bvaPV1*s~8?Udso*aZ+1GCrn?a6 zV>=n+B;0?Uy|N7!3o{;^!!<}$lkt>PqNEmR{1tYJK*W#MjV?48dEj#zDdC2au#XkN z{)q|=nei3hIMW%-roj`7ctW%bm}0;v)CZ&HCh`G z&ON5bHGxV*@{V!tGqn$6W8$1iq>2QU2M*02Q#81!3{7TC-_*e3Di_6om68RVkz7w8 zUa;2N(M|;^z{vRMlsSkD?gwDaN}xP>hEb3~M;*FzVB7@zN0voyMNSA+uV6=Vh|7(p zTw2`tX{<(q-AlKjfb|hhb+#`V!||}Cl`*^Q1Y{$+-HUgYk)IG&GPtmUi>jYt;-pfz z(h3_srl4hnZnYF~Va5cwDEKEZ5zhzaJg*u8iNMcc8q>uo%%xLSf`l6;FMv}MZ-}QL zX3G#k{C?Gdzhnm)6+*C`cI^Z0((&NKa9~py)l>{Bcf<{0{hX*&N#V*=`3m27ENO9a&YF^wgLl2d)Be`^Zo5(k(V?3dIo;h2X3}~Syb*qLx z0C(X1$S>(zQdmYENEYiYVxY0SDF%Etzii{Mrn=;8RDkdEJ8RRCJD5#Be9?7*46Y1t zmnUH)#U)no3KegU#JjYrtcIG77CJw`_Dxyma_G2Xj}nd$YzC;I(xX)prd9=rK$SxE z4Tmy#>b(i6*h)fiM$35ca|JIh&JpAK8dn2-`2-xVmDr7KQ;tM$Ruo}z=nPMI$;_bL zoh@pS?5KhyjS-XCc}0 zlMDh;P<&z|jD_O?W6Na#aJz@~zPD-3#D%CD5t=>XjRP;_o%Of7@^fqXl@fMa~XEXR_{T3bY>W?hI{akIwGM*AGd*0%jMO z8W|2~JJ5Y$c$}6l2azg-o;n6uxK8P8+h7xh01Z^6`bik9P-ueb@(!+@STm+08k+*u z8V+^M#ALBg9v`|80g=rj+&_S)zni|Aqh3}cMZ6b_U76y}!=Eh)@lQxXnU2g7mA)HKD~2f`X!tQ}xK zvBx9C#_c9eh4dV8xl3xGVK`&+L>h>=n-!)Gru-|qp$*&WUCcGs!oj^oX{0B(`vS>c zY!`^PhC4eB@}DD5!rR8EKLh+WyWs^Pev~JRdiGN@L*b2v$aE>DrO~it%r54t&UN#z zVW#>)F7})X$3-GQzFY?bhghdLW2V%CLp)Enh*NM|KzpC^*)ra%#?T@o#4vz9L{-t5 zARq~C({mxpoPN-En0{NqG#Kt7g@QjE2^sN7H-l}H?GrC-=+02_sV0%b=mPF;O>FO2 z7%XIUZ1QATTEw>t`v;7aF*wa)SmSGvQV4==74-mxn=A{))-uF6_{K=iZYVQCkVcV5 zuy%gPhvQ!1DuCeu$ZgPB1GJZNCZ5MI@(C0nd<$Lr`0>I$=#vC5lc>jJhzwo!Hi-Xh zU41Yv%*dXF7j7Eq9%$kLwFOI&W&kcDdXi%3Hmb`Y&eQhED4^2Oc!XxC0sxay_^6p- zWV<>M!`MGrnixhw@!*2OA!Rv?e;HDgo#wJE*}TRCl|aDDlx>9Zfpq~rB_pW7ysKK! z8WzF5DP)td2Z?gQe-2$n;1*f0uaXI?dcuzoUaL9Hq8(OL6^@RRF(i@hxhp*r#055D zi9&h4!w_|p0^1C6UzQ6eQaTdaX6S4HH{zy_aQ9DaN?1B5>cph*r{Fvm&NgX;GBGkr z&SjGkaiWQCa`JxCjU>8CY-~wGkY)sEvK{dYhxFvy^yop{nLw>X$Bwp4y@npN#Z)2m zNw;tbIn!7o)*d@@Nw5VmOXKzv%*$PaZ5tT3p#j4?4&jNGZg~kzjij^+Gl!K?=$^k; zOL27y84FJge$ijcrs#+QiL29oZVEL_;sm9mFvcSkKr-wAb{#2JfRF-`YXzCD&@Ct6 zPk1p=#o?v}R)wkuuP{+5tQ+ct#;y<6s&nDlt!Jj-`fiOE4@|!TUAJrLhXw_<&;%u7Yj{7;qy3tGbNug^h4Z~4!g7}F^ep?=1V17 zj=Tw-_jJ(?-40+%DL{+c3z%$1JjSkX`4lEv%kI=264BO$-b2KGQoM+^5`%QHgsx{o zAg`WHo-Z(n7I@GczU6S!a_p}jVRRk{4Wt+dRZ@HbxX9qPdZzx_NsO|ScLrGGYSPEy zYE=h#P2^G$HBw9G-J$3(X9vq{NCY69Bi zx+=0@!;ORAZ2xb#aUArY)&E0d8h{eZ$aZD1?}x1o4D#vJsYd)C_Lu1Y(W#5uCU-h) zJ*egHf8770mi4Eb{KL>jUGd-U&WZTHow^+H|M`3V+HeNl1`f+oTz>SJM)Aht%OSOq zB%^dOnXs@J955RDxo~({E>n_9iwg!6mW??t7s*H(R5YlNeR1O#{#$8rE|Hq6t%JRl z&i)Z^rOWgND-u+Licx^-NtcEWE*cKM#zX2v{;RoTl*fkX3)1{dUJ z6lKP>XeOFVGI?Pj|4vy_o4SgCf0WT$0ZNA8HfK2hvv$ZBp6kRThrG35DK` z)L&EJa2vTq36QG^d%056UBp=_)vxHmcCo0Uu%=Am31dq8<(CxZnmUdi4$$pP@D?!_ z9az-MT#!wYUaZZ2SLwEvt+7rvWujc~{IdL9Uqt_2IJ~d`z9-Bnikkd3Zyc&TF-%O! zem48tu<^GkD9Ekw`J^_z3;X2aRRpJ`-i5t}_LVbwBfa#?FC9}lbnuvgg@f4}eFoEe%Uw%g3aO)D4NTpMG&h7baZa+=Y9fL3L5j|)lqs*#8M|7Lhc{w#mB zoc~O(IXp7pfy;lLIzaxPBl6#0|5wNQ`$Gh5a7b;`A^&ym*dY=Brwb#2Bl6$h@z=d| z@8W{8^M@45{mKRnl!pxMHL$2awr6B!4(m{mnc2InH~rAjmF3RNEF5f?(ROAx0bx{i zKpc#+l1!kKj+q1n=kmw=_B^ROJj;{Vzlz7tzJd)J1;$)E6VUKd7CaW|ej*gZY;+`s z=E%JVmkJ|+-TLY{rMfB{^=sDmoQ4eRgqNN2U?m2&VfKS?_bD~%i>a}Il9#%@?wRzf z)Ey382r`6pv(*7bt5lSjU9OBO<+*m<+T`+StS?|N&9%cdOD240FK5!IrS9IazZ(8+ zosl8KGj@!heJFo&Mg~;pS0~86fJf7EsZyA4_@56fEbxI$bQ~neG`Wz!HH?!G&FdcX zlUGqLf33TRk1rYR1YS{tfb8dwRpz?0&tanh7exH%MQ@DUELNL&A?+Zp=Gt}k;);Z@ zo=i_3n`S@!FPge1U_*s(v2Y}hFQvsmC8D4N1e0X0j}q9i4-q~^UJpFh#}*C}2#`Gw zK0a=0`QYMV_6Ow~R+Myk!s|y`q1|@@x(w zFcCU6AZ=taq7kIX*!!W;p+Sn3*|O@-WfkVJZNvyao3+p8K2I79mpxGhVLB0GQnz7p zt9W-Mn8#+PdnWtWa;ryRmL`Z039ErPNp$KW;^w$P=xs$KX4?&}vN1I^qp4V)c+W5A z%9FZ#*({tD@@kQ8^nXk^nJaf!^L%g>ulh3JN%u@O&zV$~(W6JB!uT-*uDeqgRU=eR zjbwQIe%1q{FqWMRBpS<;yJwnu%cqQzXmgkf7y&j$<)IQ`VpoEZShY)xx;5gl$KVPG z$8?A*D)tT5#n#qTHCtQ0mq9@2?#(m(=16BF$`gGOm6(`)o>XG;N!LyAcyonqiLI^s zQGpekyEV$@!N$UeJl2{9YgC;yR^ulJjFc}f`=RcE7mybdx1<*hk@?GDNY}^jN~|K{ ziGqKr64iiB#`5xci%1SY3Fwp&GS?>yS8771Nvx4}ULFFM>RuQkQb5eLOcx5|!i^il zv_^c_q5Ca%%46!3lSdr04Tmx9vN@OlJ)kW6T#qSWg(av}7W*6kLD}#C1_du;;QrA` z+dZ+@Z2qAeAvJ(qz@^Z8fr0hb>q}O(m6X_iJ!m4TgOt=r3L;V?he$rgVle74*8cA! zA6ehXDM*H5P0V$cBbXp;?j(AV4w_zME4@gEKrV7Ba*=d$F;h!>#zGro2Rr0D5r6M5^Ws;EIJ(ELa7|7Yy|@aq4p!aTN% z%=$lUD%sHo?t;pqo{+|RCV9d2;gt|#2sc=Swj7pHZ4IC1 zf{06>5@SoJ_~V(E_(3+wjF$W0zpSpEy1HT$8OJH zR{duuI!sekfa1~AK(#>fVK1mr2_o-})*(KgqBqdi6RIX#kKT6^N-CG=*(ynbBwPg1 z4E7MG4h@>PN+xxV{jV$x5p@v%36W*3V9V^WcyNBVMlOVs#WQjg-QKSC*J9h6io%z8kDcU{NSB9~5bRhkSy$8;eLR4YN*L=vf(I{LHD4#n;3ziEs4cOC6^OakytiGQ4wpuKeYlCVL1wzsHq%A z8|+7YfFo?4u}C}^L2%)kUf|~vz9Nn!V_0knC)a6r6Osm7Y~sbbISHVtnOrIpNB~L? zT&6&t2tOkVik>Cb10e)Cz<7lisp(q_LrCyQ29Ae`%eb|Q6$c}@B#hwDjtM&^h*7+N zkBJ9tARMCu7QN88B*v-27@8*2(`?uh_D6dfg`z0%rlOiYYsPd3hW0tD~5RpCL<0O3G!zEqN9(?alMK8qts~U5>SqQ z67w?Y8jYQ>q9Jd9K#Ip*V>HJN z1)?ovbri{1+nH${Vz%3;k3}>_hA%tIRqKRQHkTwN(@RYhb$VpVy-bx|LA%tyA*He3j1-)WZgul(wON%U0$E*NMn9unE5 zWGV~uPQCG?xQ|jy(q$YZpopWIgbA)<##tglZp>I-a6}lVhUs)LFo5+FBJuLWP4{XE z_aunVASGYVr?@F0O(Fr)h>lFJ2qwiJ&1zYViVATUrg#W7y>3+mUL6>&fN`UEW7pY& zo$z~*lI$R)#S~vf)Kl(?#C;i2HSF?6?M})U>_~Ojf=k4+$+#aj<|aT9x;oX!p@0^1#3?MFngQu=(qz*E=r(J` zh2V^$Y{X^Aly<1Z&L49L8M}^OT$CF+W^N;DU5yC+#tAse0SFOwIviqKlfBGdz|8OZ z^n*$P5eJ8{nRCrM}63I38epjk~U#<=r7eLz}Ez~zM)cZ zQ?ganWSi!hfe*#34Huy3hGP;9OXT|DV3lhtftJ`CmGB z>6jG%=k9zY|L@=O_m7MJDslRrnQ8z=*05tjlHbb`uFCL{oagY>UsI z7Uo`6G_#1ttplKAMpABEBtrw-5#jt9ScqUYn zaW}|x89Qzi7hx9UI}7A2Imj-DEfCBku@!iL{;=shN38BANfu&F_Zww&$tJ6s09tuU z1!3wnkQhl3OQ1{vWCLl00RYi(#e@JWM%5}|9b#@u6?1}%T(g#WLj)%r7@#-d$Q;~p zm9e3)A2X3Sjq-3UgvE!J3?v@q(9@n^8cl?IWxH8ZF+PmvdG?2SiusU|j>FU|By9|< zG}(?EDe#MTZKG~b+FrHtCxw3WdhhF zrd;QIT4J3Gij;I5DV97(Ig+pWR3lm*R8%Gs-f$;o#yH5z3|qe3l7*C~W%n4VK;c&o zri)mu5E1CrS%GXYWwYaQf#|k;7L1@9s6rhxKp!$IP%b$id|IF!Sf0>u;CGQul^+Ke z?Hsv#{(d`-+Vf0x8?jefhipB)gh;t5 z6c$QN2aAJH<0k5X2{ne#nLH)Mu#%94_trJ-q8~8tz4&MJy_S#z)Y!ghusrcGbcIZQ zltDC$C{J)_yfQL2i$@+GSAFB87%YjtVRa~g3{L>=={!+iCA^1sE0}K$ldbTx0B$fP zlOF=(;GSwU-TQJz>Li60Y~+R^l+fUJk;sbQ>4njBDv8TT1F#QxGnEk;E5zGF^2_?^ zzewU~f$l`7oz{UJuSamJ6_AX*w5S^ zE`K0UODSFmsxmwM_o1!riJ50!94s*bo}Vb?!2~jX!;cq~6qvRn@u`VXvNIPXl{Qg> zs&Bgp=DFcaMHhgb9KIeWi%AgvaLT*H{hV3Ce&p2a%9ds0Xmb>#%kHjS@m%XDmyvUi zQywz3AfrSLOZYl$HN$`|Z0zvVP6aR{n*)VHD8$&u{)9*XBsP;4Q7SVrN_)DLk%86X zrr}q;VVblm#Y;0*0S@>8xXu&tF^Ph0@_=PMYuLYTvpf)Lhd}^R4co&d_s1OJv_%a- z57@+#d4HOAP=RF&C2uTbACgHV@#6iGznW*2JFvAqXv$AbCN4Lp6L(Ei(izhxFlPDx zmr4#3kwE%~kWMCk;LS|eszygcyfgL?w@VcLlk6PHW)95&At$&O-0!R($N*J9s=p(` z@t8zu;$@RQiB*`7b#@?{VLX_OGwyI&EU3b~(um?yp>z1vBm|aGR%D29(T_MLGO$@D zx<{n)h!VzBERdI0i&s>zl{FOnN+rOiU*aIfw8%NpYQ*h-9#lL`o15V=YMyo^M;L(i? zFe#XR07nxGhg&mQ0sF|hhZG+Ow6@@Wfc;8?={j8G#p*(97$cd%N|lAKR7`(!A#hhV zAMuKea&=;6JOa6B!Qc#;z+B1kUqi8gKL=G1V(M1T9qoiXwwp}li+G;59P*$t@gCi& z34On!VK4NAQCQFu07DB~CX4}em#!G^p^lpjun*5k+XhOF|fJp@$nbF^* zfGqnNU^dS&+nX{cW-xx30iDQ*M+0a`P{=RGE^+I*W0)EUsGgu)#w4zBN;J7!H4axF zDHAx=0QVf>dlkKV7>A4iM`FWfOX1GS$^borX;@9)N~bIvkQL; zNKAq^*nB`t(EvYNkw}isd!IlUC%zYC4v!`@!LuEq2NmFC`=|{_+yki=(4&Mxqd`;i zMKPNWwZZlmV+G*|TEQHHJTX?HN*nT3OS0`f*pP$ANg>+*ns zM8}eer3kJmlwh+K+}$JXckF8oM>gxDJx_vcOBf<9=LaC85v>u^_>8W>No>j%Y=lpv zj#~{L3W}5}kqv;faf3JVb4y|yM*JEh$A2u+(ZBGH<#4$gWOw+hTn*~F|BoF80H8YX ze>!J(=$Lr_pY6^*a{vE#{QcwZ|4mo%aCLHk_&@N9>B@iDuwhQQS2SFuLE2y4B|ygj zl2bSUm|Oja-}4{2=Klv@^B>G%^8e?W9}N?SbiyYHTTmgt_%v{Ua9=t4RYN}FGRU=T zzyTR(K-`Ty0SyRb@rjhzQ8EKT$^sGyEE*YJ+UIm{#vN1zPLM8h6JSRYQV>t^oQCpX zo&%;Zcq6;8O#A@rEH@g0*hgxYhfhJn0i_&nMTDl8gtQXEJ_FEuj+{hZYKUhDr%*{0 zsPJ@PdoUa&j}IsY_7-5fY&L@IU^K{*Takj~<)M>QlIuz;gsKAvq%tw1nh>e#LYFdP z*fe2a!uLvwho7JLVl+Ily3RKb2O3p=-@?I(-NwKXCS-=j1ICW?_fdbSO^j#xtRf-5{$_c(d!Pf?d zV@2sp2GVVf(b~xo?mWa+%^Q`f+XoumO|-TjT^Dv)D(el0AyxNZ95XIRYk$MV4Ztah z5T*=kGf;fr!ZJ%R^pN6G{(!F_-s5XLtF{Erm^dX`3OFjZqex^0xrEq*rH&L%D*Gp} zCCY32gJ4BS^r>RcE%tY7{JFqVQDc&E3C%boTGXQfe)nC(p)ue{aDs&B!2+=NNYP+* z=_sBabG_!kb{?WlbH=MkoPEh8JsRy7!$DA`V&gH>tXmh9UX{$R?oYIS!o0zK6pv)J zgy*B@7$Y;t2Of%vczig;{ z5W|eYN15u))Bw zpygXDDfO|lp2;>4P;R)(x3M;5&jXnQW-1+UZ~^8@Wr~f=r-gEuGmTy<31W@uVHYj^D+5JOPphhga`hhhe#WgCJ+FmS`h$<{!PK_$WO$?(ys}T{fzSM zTo^!Yi_R52T)SHLU}oLH+Qi8t0{C@rI^K+_G83vq&R-4R5Vqhph#>=a!F56@P(pSE z&&X>Bys6A@GU7E;r=4zt>1s8ggeo|&gIyBUbGsyxF@}UEvno$42APNS>4Fl_1IFU$ z?$%cs4~-LdvWzanuuSN=u2c!jjIg$(Cr9FAS|fgzo2UNo1Q7^=GX{~bEFCaZfXhH~ z01?7Oy>Rd%#v{oV1~36eLYNyO*?wZRX$FLt!Rsp}8J%y>a!){0^bJZh09Fj{n4^yn zy*hvog@Nz*5GL7B1Uh87VbMEeWsAP)vW>XiHg)LV283WjJ>xJ1HRXp%W_bzuVWfm~ zLN&v;;jwPUZevPXg!P;)3g0y*!NA;zr7Tm=VsQ#o;mB~P1J^^q+y#PRqT4u+L!a>Xmt<@%B6hT&4chm`tk7t4zY$A1l5jt`K zuj2DSKvJR?^=u_HmyFCkj=6A|jumukKNOvVMK zZ@YPd+3eaytL2s%#T^8y9Qbh}XHzCJrs9$~wqokp)LS91bQxn_*r7=gAWEun*(tG{ zV4Zf;?L#Vdkq=={+}a5sL>w>6uw5jDG#(7UsGT9eYbE^l$)d3l1$cDz$%zAnXXbEC zmCYinVW_4cbGHO8@LMH4l2O&b2NtX3u@DuWcm-YZ0Ey$ehvjkL-bu{zBK>Mo^a8EE z{s|E61*?~0JIDZ#qZ{Vz{R;DYBZ^Hj%SeG{%H#0ZUKb1QW{tqV*;zdFr;^`&a(TfL znIV*|9NHzhtS{_?Ec?kOW-p7gX>p&!gxd&I=w|=R>6o39?UwrvDkFR$ak~q}^CKR1 zT4uUk9bAlEJ0KW1U6vgsY&-Vz#4<4wE?vAf!p_JcmLaV2_EAv7Fi^L%IvEXSb>GLw@x0x0YV9?EtM z(^lxVU>JonQSh-x21AjMew;~XCuq8d$D>vUY{Hg6oFoTjw5kKTCcopB&|Qd|AbEfZ z>ZG0!zd2=vF@21A_nH#Vq`E1ANwBg}eL6~kJ>#V%Pnp9g)<`6yMs){XJZFuJ5@LS| zZ+mczgle2-(G%}Mx%o&U@lFeqnJAI1L&S?Y|D~?3gJh_3OB5Uw)snuo4Tygs-Psw} zCo6FcoZp@-UC~t%dO7G00eV(l9?H!mK(Gua^qI2&EyrYAk`fvg#wA^XWW?NCg%Acg z(G10l3M6R*A{4Iwl^8p2zybJRyc4oI8+XYve6xBdm?r|}fsABH-P4Cce&#Y+49$1Q zr03~@eTf&!{O5Rx?T~17gx~#`2}T&W$us|fAo6fQ*XV~>I2;%U*b%6pK`^G2EQRp{)W1LAf1<38YhC*x3|Io@U*S7H zn+p!Ryy-Lv7`g#J8E7;XMq$dB28*SxE?Lw94!B=}DYTXkRxL(3j3oi>KtPs{M^^I4 zD6_qfb8o!XHgyxl2$M~bEIdFQATXqo7LrASI(iH8gvn*~f5+cH+5f-D#KeUD0dbxO4hC3OFvJM}Udb^4PN~R5;;AD7iYzSn9~}{J zBqZRU91`#kJKSpt2{3o;pb1is3COeVAQ5?)5UlN%bvFkHu?9d1u(lE&kwD7<;05&9 zV6rZ*Fb~P(L94>608AM1D0>|>G#)ig*B^$PGzY|klozI_;O^lIqw!OYC>|de?E=*@ z2lS%|hIg0uv=CD2-OAJCfGfffSwB)2@xj3eufF&YHZvSdV)p`IvmWI%CsJb0nGQ|@l!=J9R z8aQQulp)p<^pddV384EJPe3eCR}9=f8Lx<{6dFH*^KrC!#WIN&FejIATQYv-fCNFt zn86GcC8QZA)J*qYV4LFjchC!PVu@=ULsCOXCcLW(Rm-Rc85Unu3u#P}MyfUTHK2}D zfK~zoSAsFN2sPjdX;okXFwiP0JLL7&(b@(na{E88NhvQdr%bZb8GJ7CnNtZkjfh~L-enV4aQ#-P-mK5|Z zDlsf2l7M%Cp9Y$La^fX5SW7{Rb;%MK;gIQsAQVCk$-!#Iy(5f900aZ9h3%lC%(xcK z#QV8Swqr4=7NZ@kvK=C9rtS#zBk_GE&PA14YOwUz1W#XH+(iNnvA_mzlq_rQPbQk2nr$uSfn+9tL|J~L zJH4dG{9qQ(3#`vGK^j9qofI$8^OVX+dT)li z8BA!IWLinsfpqsyFOh#|m4Qzb39z#Q*{NPk3v=Qz=lCuPkwd>OsF<;`1o(}IjyFyL zh+rE6u8Ofw3ZyQZphm+XyzQC5&MlB=G~M@$-1o`lgB&+fmB)KbN<);;1^tSwCQLLD zc@zVBjmF}U9Jyv1G$6}rqegQKlDJ#Y!Ewduuj3=OwtyqT1aS`n$;6rk)APpF09=Zh zQfeecLh!o@#zRw2E$}ATZo&b{1e?GoBNmo)*f)PQQ%zK#Nvgo>P#vOJfQxc3QIo;W z%)JRkPh2QieM|!iS|jx;wc0GMIx0TAV?8)01;09lr8f@oRYdL(U<{0a|DXQ;-# zLc9z(tX~(=jNyx2gS=Mk5|euv(w)A^T*iqxRG^fVa)3Ymv>c{SlNTKK82QH|;&ii+ zH_m55&orS68ZdQi3n?D0S^%IL_@{(-#&(sGw0XIRs5@J8Q+0xSIUpiJEFd`xSdu7l zN)lIQwea%OBlMQ5n;geg* za~;%;%J%QIg8zGzLkC=h~C(OVm@;@|EL@Thl!~YWrU!Xon86u}l7eZJvDH4P9!ROWt zAX179AbRQ#%5O|oygG8sNc*2-hV*bV4Zs5F7SI9-tsIt&5T?i+j%HD+hv)G4RMv|L zs)s`Fy$DAy5|{WqAxXzDFc4!{-)V3A!(g{&#R~{Y9aRWE+vZ4HSV_|=Qnp<%auP5l z21RLnx=a@bXw26w*ig2#bRauNz+5Qx#T_5{$Zz%&MMZ3N?w zlkP1reKug}fR##L>;kL>9H(%ZG##d0Q6RH$5d73Ap@~)Xc1fiQ#3|n9Gz488rzjDT`hjcI9PR^g`hy;DG15$9 z6W(fiPz;d+DW`Fb;(M@*Ixuhr#F4Q*L&HM+4&8)@vtJz2ovuY0v7uBE;zcpX5r~zH zLeyErL-rzogWWNiq&wv1-Wx6r*#*qg7`U3LZ3I=(dKp{sC$J~+(qD>ep z)fZAK*x9Ti>WJCcmd`I6&_O+hv(J|kZ_5G(MhAx;k%9_9f2mr~CFdh;7dUn74ik6> zjRK|s2-RCHAUh~VN_V(NU&iF{L&lvc@KE6?z7eg+l($DO%16uNG4Znzqi9J!q`v~p zJrct==%euh_rR4nHL(@u%T5lI3XCz)We#0{rI?Z!UkN@j;;Y_yi8}A(F~&x(fTjs!r&?z0S%FK}pb9KE zBVeZTqDF(4k+cSD45Fb)KskuCGQ2&!Ig<4(S-`Ia ztsBTe62z3VJwgHHV1{D9ahL*Q7xhs?WI;3HcE~*y?$yG9ICpqPPh=EfJW&i!5wU+V zbpyd0Ojt)izMLXuqEt!~Cl?I?(T3HnaZXD?JOqDKgi8)lS(5%3nuf$LA->~u=;ZNn zg}iX#DIIL>G~R9DK`oJ^E?EI#FBr}1@sKVV{QqTBHWIYGvL!P2RTB8+dZIhaB|w?^ zTHVhi3#9y5Sfwar_+V^Ry3I^33}c2N^H;=I(~HIg>v>Fi4=&YjQKBXvV~XZt6A{zF z4UMVBnKuv5dW{jTP=K{M`4LKhi5f+n3K5E5LeF{-8->Zc0c*Z_v?)XSYX_fca2dczG1SIC!(@ z)bFj1!HV^UqS!f&H3&*i2yc*Os1vE5y}}kZ$hz$}?_RuVrcFUdr~)EhS*3`l1;79= zgw$~mK;nV~jG#jC0BaSXFLMkr zfTDcO0OTmUz+6YYYK*R4C^saqUk#(E?bv~M#1z*Eyo>}FJDvP^(N_@;`^`d1jd}Ut z`kbv|T-7RxsldvBEe3Usr^X(t*gY;Hz);a&f{&haVZ<`6ReWHFCP`HAAyMA3LMfOlN+CUgFOCwz zy6B^6#0AJJHH?JtB#d6-z&*qV_0e-sS6)b0gm}l2o99HB$AMEq0)B%8M2V+u6BDOV ztd~A_Q6-3|JEqCAkV$dKx*SQ2h^K5!JvDU-mVoqA{sSOB6*vYK#`bWP#Fr3e3|oSjtK5QW7ZkUAs@gdntPnGZ{T4p|67vL>sLQ&Am9 z7CSgfNcmbs0ad|xO?)?R^1q3GQoK|dkAdBfUg2M?1a|=RW+Jyj(uW1$mK9`|Y3U-8 znCadksLq*W1HvT~u5G~QHA)dJD-rOCWKx2JwmApLH@bBeyj?@$q)W1LrGt94@INMRRh`wW0IZV&4tOz*ffeJM3gsb#PY@mMY;LeF14gI{GxD{I zaXXQ@BX|N+J?#hrN)jA3$KX8kJh%pkyJC~5rGe%lC=WNOBBSZFd*o4#!<{m`RiVD+4q#o1ZV2lud zVf}-bYrypeH8t)(%xWsDFmGsYvziLGNRFX^8VrgbG95!jOiiCbUW&#(=A;7LaMuzsxy^adj%<9;Q9SxL0WuQ^D)%r-bS!LUswn zu4>4Ll~@iIkmseUp<=Hh89K92kadlfw8&UEsQSpAU7sK@V0qAl28sUgVobujE*;Ag zCRZ=6V^j(rkAN9rVG6U_H{f6}0d#Tr1`mk6LJ4R39AvQ&^@~gsx?!6uz@Uhm?nfLU zi(X5fiiA6Ewzxwvkz5VHz$g=fB+{*6LNyhWMwkwD!y@Jpsl!+``ef5o20a`=4qW&> z)tbajL-eZ#cSvEsOz9^ni+u<>#h8*B^~HnaqR(gr!MmV4OoFUr^hntlBbd*@XSo&3 z4-qL^v`#o<`k=mM#jMurcw1R#@MO=HBBj)f(@8x5L-&Y6sxNChay z^fQcpWIG7Q$X28HB>~yQ=>FJcVAHUw8_#gvMK{oqyouvG%plE&&|;~$i$ z2Kha@v9b(#Cpcq2XJ)YfFZ~lP|NDp zLfK}$;(%6`wuF(JkT0@+=UVGFOQCZn5DIP}Ji#R0C75#JAQ|vE7gv~xHl6*WYl(P0 zo+N^Zbh?CeG!=Ls#15NsJs&!>D{Qg4k3@&8Gc7zF-M;;CBM);bW(hap!k8puk`#k= z3JN2^j57_qezV-a;awA-kd(w_(Ui3mnzGEV_Rxey%#vF=1@07+S@k&q7HUEw$6Ik> zfRwB_vt*!_xteI`iL%ZD1#iagQ}7D5M25_uO7VH<9|3bp^%<&+sD{xE}7%AupgVP`A?9j@4z zg~m@6SXPd&k%4N;#sUD?k{WhZMb((%FjcMVo$2YdX?25ue;iJ&4sMY1xSz1__cO&F z_gWM}Igw`72duVawL*JK}ajPXM6X3qw@3got zn&Y@}EAuRTz*59-<>IG4{1?l;HU?PY&)~L5xZ4W42SE&-5w(r_gYerE0AA=m07nC| zSe}82&j*+BMLSl{RKqcqqvKk+&5?MQe^I>45x}Q^(_bC&KNJ>zhzX$U$p73aMgC`Z zmm~R~|CYaha{LcZ>2*K}piMzPJpYGNrVJqLUo|w&DGiASBL@7F$Q6yTE{V}U)B!r( zjzs(%iTL>+i1?wb2Zuz7)?Cn7p~$(TXM;wa4?TL|=Y&+ai6}yp&k$kjlatbsy=-7>s7T{6FfBvc_IM-ad8^D7GYKqDTq z#gkaF#_H%!peQS&=PF`0)t*Z@)eIh3GGW%!Y_~OYMvciYtTE_(1`h|ZprU1`8tr*} zZG@85nv`+%;IYUojV0#OOUZ;K1pNL6H39)$z$ReOHq-!MXIqWk?5zaGDXTIydSP4P%=LEHA9_; z6m;suL{6Lvxv5z9EhS`k15^s?7kNDB9m%T%!c{s@m>-OiWVAqYwJCc6IniQ9L61fY zf%a%M=9J=W`^J=m1--6gztPXNU|;K|98CoSs|xqIz)biERllCF#Z2T5$o~Krr-b$I zu%iLRpMf?Q%s!p&Oe_N6Vx2phe()=G{E%F!l)yoJ)xN-?+G^_B)X+q#O%2a+Qv(gK z4eN_dbkgO~fo{@DCh+hq@#g)CEdX8P&IGf4m9><&S^`p{93ixIF>@Xv$pB~}<#<35 zccKvyfCm1$H}b%6m7cfO*~AYMtdIUJC=hK&W}TDrsh3| z=@3~1`hLR)Y&)@MxYsnUi(xjn{n=&MeY}VA1h^Br5u8AYZcQmU>Ds`OZm#B2C`HD; zB+B#ftVOt?75I!!-mx&`X~uw`Xk1*7cqt<=ghD|)A9sVQp<4brPuj@er^c*F0KuKo za%o|&UVi%L;19VdVu-qdl*b)SJIYsKx|w zR*@PXr4XnOfPxB8-qB3Cb2NUBh1u!Mf-)D{qWt(Z39m>~{GwT0X_Hf|hfB*f&>GAc zE!$r>XV^f}oZ(ZPGfpvwFkQw}dA#8$sM+Srbv-5qo0KRCGc}2`VY!x34_SVzeKMed zq`APfgE00=HZF+jKBy@%O#^v&6TyT@?NaI%u=-)^h7?4zL4DFQX;)ecrOc(BG{?eA zs6x2pLQEj{>*9%P4^X>G9<8oNa)X6I_@*x7ogR7t@CZ;CA^LlQJFb&rq?5@B!kZIG zO43P6P8@D(J+CM+bDSQ;&wf{ZaP>?{@X%2flaQ$zN5mlYOahGV5G%?wBb}B2W6lk!nsH=7SVOBJi>%%ErS^&!-8UbJ)4BQ2_0u>8M|&$h}Erp%Gp# zQOOF$4_)G`b&o;=NqZC?Iu1mOGN_2HALGoaEge=~%+WWh4`q0@4ox(WG(7PG$w7y9 zdT~b?oB-N|j9NS)Uv+KA5E=6S!c`@eJ#pOl6bC&5KklEdoRa6p^hHJ)5W|Z-G%j)q z;*Y_w6Y!wItQfwU5K0>kK{BflIuVQDR`R~2blOQ;W+DeKgT{2;EW8XW!vQ}xM?nXG zl}jo4wnYf^@i8LMMO8=)JKeC@Isc`q7bgL$@?{W#u6_vxp6f*i zzNATt`u^)*5?8_`-nUEKl!gN|8KL4 z=E1g6hyQoyF4-Lu^FL&n|U+wdVB|4X@rMO+BX7ZRh628;;Mv zz1byOKA(}ZV%{Yyx^`GG+Sw&MPE5T z+dF#b-hB`MxaGsUzKQkfciYDIC++znHu}|J3wCUHbW-@U`AxT-cFDAT4c2cw{ntNF zzoc!?9&g;x@T-bnZ?f$@wny`O@7dJ1{*N90=r`q(qaS&-+Xn@ajjzbl_AD&Tz3fk0 z{fA%dlQw?EQTIRB^0}(%lUn(96sNWRdg|hj&;0N#TV%tBCr``SFs13{(=NXF)R&K{ zdVR;YBcHr@>cmyvua}*A->fzbr;WY!xBT=*wq6&{-7~+REpvG3tGhmZX5Q0J&n(#y zIVYC$*&E0A2xQ;h%GYYkW5X7F`NbE*owGmx{PTJZjvnqjY3h=DgZTp*Y`o^t!ra!U zzrQxnf6#T$&0Ts~Q|Z`_y?g(4b%!gArwoCu`?yV(DmNdh^ zEz7REcE*e!mFFLA@!YzvZ*`5D**3j>`~FQ^`4&~YfA^j}dx~y8i*@Ma>-vm2XXftc<-fccem(&a<8|KX|m^L z+Xb`j??ej=3rCKe)3#`HyT?9WyJ}U76HhEm8-LT{_MdiKx%-s8&#v#Y_XXdxXX7AWOPVwZ9^d^*-|h{&o2~Rc-stlg zqps?)?czquPO~llerxHU`+oT?=k!hMx8!{F=ZPPzTJ_^+RU282>C>OS=%*d`-Yd84 zp1thNFXEqEo^w~}+Gf}6ZsohR^N0~6jydL-0RslKbd7wte_DpRw9SgMPxFL&d5mM*XQ|Z=Z8|o_yE!Z-4*sJ$nPMKOg+Xy=>^2Lnob4y?ySjdyf8TZRU>GS`-%b z>o|GPTLkQ!vQ9S?Q5$%@vpN+lz>E};;Hhb1Ae|hxnko>L>PIuQgiM>fVJddd|^$J$U7n z5B;?Bh6YoH%pJM=#p*U?6|3hCxb^w)#?hlk=T&{P{*lso(o0o4hlg`MyEg6PxzDf8 z39MN+XwdWjDL!vn({0x`Yh#zB^QPaWjagtjfA*h0Ex0s&`uDq@d4I(nod#^}vG}UI z7nhv>;DkQ?((bFe=F>aw9P#O@*onTCTi8yrz1*Q<$NO_$Y8blq-dn3)zu?TiclCe0 ztm!GIJo?Gb=RTP{@3IdzJi9FOiyyvsdhyZO?*&_Cj$S;z&vi}fkGD$ zY}qn2G;y+t$c%#&<}5mK(S_%<@6+On#se~YwQ5~9W+R)Y>R-QI>U-zj{nV6Bl8Z#3|Z7K_K`FTeb#f-Rdb ze^Yv3R<(WV2OI0jd3pUFzwMiy_kJ?PecY5STc*AilzzVcltMD}p0EDlOXZ!} z*Zn8=0;Sui`$xC>)ZM35oAV!<^z*F8$K3Ph$HUI-JmMJJ(I0pQPIJGr^w+JYH~gsO z_cyyGxk1*{CE=fUO?&GMN#t=%iG`H?UymFP7U==YY-{wRk7la z?5@>Qnoe6>WSf8H&gHk9J?x2*MFR)!nz{Y4Js7}Od;Egu+GXzU-mCetqvMTYH{bWhEAQPlReS5J4+}P2G;YI>+rPVT!K&Ow z%N~C4i{)#c+WqXaL*{K+`b$RJw_0^Lt6ke^bI$qhohi1-3+CJAN6)|Df;;ZK^Reay zSuYNL>DBYrG{1b^x?9HV`~KP=fBfb9@0X{2SJ1CG{p%BUHL!VSl=g2nGwr)f$HTX| zeS1$R-W3YQub%t)Y4sh_fPu$Wf4B5}TQFzT3m+`K>*4eE{W!0>UcJ+2tT-woxAl~q zPuw{ch)m$yGgC=ghcn@Ty;)il@1co>elV$+WLF zUi#yPvkkN)tIj_5P}0BksBA!Y{`y`0PIK#?yP`j;vSzzT0oVeePVw9$mMzEqd~S!Dmii z{m6Chi#A{L{-r-Xc4>pLGk%&i{XI{Qv1ha%)}Yzk7QWnND?7ZuYvl90I(YJ%kB+a% zpV#Kk-(MYY$=;paS}Yy>NR!q#w(WKGlabiPY56mIH{CqzdGE0cUVY`O&#HE}ShM@R zhtr16+_mn7%&e@)>(d%Pded7cY;1Y=b*s<&t)j=eJzH-*YG#Xj9gp8x|LdbKYal=M z_5EejGOxbOH^aTmJ8Av+JKK5+pIUKuZuG6|f6q8+>Q{@_xcfEFyZFV;zis>F^zOr@ zu~pwRS?XwIJ8JB-+jhS)Y0Vjbo-^*(Z?g(L8y=W?Q9oO8>$K5NZd@N&xbulYpMF|# z=6_!eKeh3)iy}$g>;r92M&s~4vbMHLeq-VVkJda;>T%()r&41^?qQ+w` z{_ffjhTPoh^0EEBIoq}l-M#+&IX7!hEn0MLlXv^~OS?TUH?NIvcr^O(DX(w+?3-0h z>c2QCW6{pv+izRa>iqfFSO1W={J-fpwe3-O-{h{}-8Cxs(e@e7l%JU~@;1it%3{wh z4Xi$Q`5kuzwyhZT+t2HszVy$9Pd@nIDXkl~&h@phwY|pCf9IRmOnv6**+(CB^3tBR zo{v3hpXR^)`4`SkyX@1)wb2dFKdJMHH|+SeNwc284<`k#zUUd}Gu?Kt|MjO&u9*47 z#%*ifvPs*Pzkg}ozOA=bJowq`VnV1fO_CVtUMyeS3c&H*Q?Fw68vXIsMtI`<}7) z@i9-{;Qn%bvsRUBUix9v{1GkNwY#ch`I{4l{eIu9ce2lH$jJZg(s}3QegAfg{_E1} z*&cM1&HUrI|NP zGZpWDv-Y{i7BBv6z(<2uzu$Ptf>$mYyJcCMz1hE;yae85=vdvm(JIJfY>|LxlM>a6Q*%dTwD zXvISh^|_&ydq`l*;@e)jeCpH%BVQ^RGUUeDv%lQ@WvtOX=S_L}o56F=Ik&X5L&b{I zcK>oreEvfZZM~*lUW1-+(ePD{aeq_;aU*5Ilt-f7PE1NcBQr~G>_=dD4GoJcn z^qqI!eRpql;gd_oA7@)xTD&)0Solm^Pv+0fzni`;{OaQ8pYNQRS-f-uBZVupZ7T-d zmgV{UwadJF7H+(EZQpvIZ=Y8+Y-p#Z_itO2+2!Te_bGRF8u!)rTeqYuIj4V9(){HQ zdZw*oO&lXPZqRt!jHaVTjoPx{lIPYbw|(LEX|1AO>$C1_(d_c{;P2nQ@%tHy!NUZt%#vvHSBpN^i``k0>4_Vp(>YSm!d^|NMOy)ImAv-NtS@xU|kyFGi=e@d6uT9=F^`lMSe)4Mh zt+#yqQ`aBP{czs9bGi z?#JT((osX^Y&r3gwjcG_H~x$DFCD#Pea_^OzrWD3vvGnRar(JaHoCdaQu4}St^Zga_l_#9wt2cIS<3VX^FgSV3b*FvhTyx&F z9j6VcuKsQH{1JEc**N&MQ|p!OedN(ccl`R@mYHp<7oX6!@vxzz_I~@u3AQWuWq+rw zsCVOsj(V|zZ!fBpY_IuOj_PsqoA#{0+Oi>|H?%$JvX&=h7Onhl%UfrkefE;6c{@Im ze%<%`ZlBld_4yX3#oR6P_I%ab=R2YG%J&9$`?jHd%3GU;lpVW4UK5zUZs6u={m$F@ z@$q?YH+cWro@rBWgTGeIZrYe0%eOr>$=SaBDLFC6#HMXF-_h1{)zr}1GTXg7kKcBG zPQZ4rT{_|7CmT*Yy<7b$OyIP+7LESav-ivQHoow}J2R){`mSuyGa8Madv3GJ*BdOD zG~m{~PhK#8`u%D3Cr-KkoGZhxq-V5$w6NdCF&~W?+sO9)592})Hty8*-uv#G|KJyr zZT!j2woQ5Jn?HUVaQ^vcesKPi*PL|a@n^W+iI$d@&Uchx3ve;Df{-T+EMn?Wer-s z_So#rjaS|4wyjz8+oXBYo1cwoc<-NkcCK8uY(nv#hi$#C{;&W0FHZfopDn&QYr(qn zJ6*qH%~OvqUw(Gl_B{)Kp4O`Ei5K4g)xfH|2G7badi|)Qo?}|*$+iY_?;4oCqMq-O zC!R>}@2FP;5X#hf*_DrXh_dc&pNzhy^B zn!Ebb4#z5U__nXnKC;=GG-|8<{57rp4V8~R{8jdpfmeTVew#kFj&0xk^S-Md z%3Ahbd3v{no4?((^3L>UyHySu`f+#PvOV+ezT^8pet4m<_pb{lW;fk2{LQrc7)6hG z=B%@OygIAt33ETcw&n4@-j9qdi&Zb5HGFpiCWdd1o&CX4^)9^d!amoXvh^0*X|@&j zyjuUYMPGb3c19~-vu69kuXHV*{m9_H`~KLr>y4`}mEV+SEbDT^(P`Vy*~U(SKi@e1 zhnB9>*a^wx=4P8V?K`@GXT}T9p0j-U9moA=(UZzM+aKsVpx%_GJ^D|+?$i?s@-E#c zO&ncs^UI$GPC72TWycBmQ&c8B78d3Y+w|qut%F`U=aX}`*|U1jYqR*a>P@E?&grnC zS?f#Adu;NSW$Ujy^@guvUp|@D;Ww^bJ}bR+)tqCFuc~ibwfgyA&l!`pWag@KS3gmlX1m`vtHd_& z>f5y&l?z6F_SKv%X;b>me6{J(pEdbU(+_(-_gu#3pZ=I}fBBZpn>TOSGU|h!H`(s! z{>b1*cfR;}3)?BD216%3HloR@hkG@g()8udk(<)zE}p+Iqf6(tw%6WhvDh_r?cCE^ z#Gfw&9slFFDVKJ+aqDS!T(JA|3nDM&gf`xJg7e|$K5l*gn#l|Q%=vcN z<|vo zTkz{UF1m6@lgl3{DO5MD4|Uwprp;8Zx0l^sf6!UE+n&Dv*~s99x16y3v!-n?c{#du zIjfDSIHQ_w%_to`d+W{ZiXWOg_lhg7sQ&H>&x~oCKIwb&fa7iK?45brIg#xv-P2z` z<FZuo9g*U;|Id`0*ZJgZZ#4Cml8#8(L;w^VfI%moNQb4W0+v`Ht&N%Jc&!_q> z+4Iqx4?g(8Ydsq*>-U8;Yu3n57yj}`qcgtvc=hNdYreSCcgthrZ@4>cO4AF2!QAni zr=_)DW&h~ZdTooc?|g5=`1Wg8?)>kdpX!aB;TSq|X0Oo`J^zorD}jfqd;cRUCTS0? zW3*6=r6PM-<1Hc;+Ke$6&B81xT2$I>?RhIAZ3-z%l(bV(QfLv879^#zmDK;7d+&^y zv81>9{eS<@|Lv1m?mYM0bDn#i=lPyYO0IXBZVahe*H*iD-MUA(i6PkohYizQ9&`dsr# zd^BX)9{rRjYG2=6I({-ZbF|!+g}u1ktO1dllX5JAgQ`eNQtG@kD52BS+oHcuVU%6S z470R$vVL0f^5e(joT?Gt-U+5V^hXuBY0;mqC}*UP*L?lgTAg$!S?|G-6VE&WajEe9 z!`k|Dy&C+pW|`M{r>aaXk}Al;rH%=_kQ-$k9CbadSe;yFk@GSmV|~&^?GTQw^acOo zZ(}c;`yD-UCGVsHTBfWZkO)|K zr9QY96Qd)C>Mm02vu>SHpzex^^qH}8VSZ}+XCL3XRl0fPxc7-6A9>!Ef46?Bw6U>K z!PUf1k~EUY(T{9QOq9dj$|v<5*cvFeX4&5s5c7K1{dSf0Yn6dZfLJOUT*NNpJ5MN#xJ8 zAL@K=|6K{n%?V*+MjLah1Fvob2CD}At7MPeI@5Yz12ZcYOB#!DGip@7WGEO)k8cd!V}In@&9IPLd6_G(H`XzSrnYJfGe2Iixqox` zh-n2L^Fl3a>YoR%`})GkHa{CwB$?iKu4bQ{>RUTM7=Ij_GwO(?Mfm8Es^54IaMP=X zhm2QIiMwz?pGb6jd246Yz39s;KU8k&C*SnGyu6@b$F5z26%}PjYq#a^nCy6GPgB#1 zv@td({2X$}%an2KY?dxnG_?#om??L0+`(S;w`Q3{#0L><>UK{YuwPf>_VXCaBMs@7 z*EAn2e`~tc_w>A4*TEY`%VnxGlnmQSl>WHHuYb0}wp}W=Hhw-do0>>Hj#SRz!Gkx; zDiUw7DU>5m=zXR&7x!!GZ8sa3j;(FeyU0NiQ?xgKzxRDq#wx`Rq!Vcw-{r1IocVhf zi6Rk0qiNw{9_@bPU7M%jDKTr;(Ro8Blxkno#a-!bRfjh}u-W%R<)C*_zWda#Y>^wC zo0n%M-G9VXuQx>}iB~30o$9#vQ{*R-p_|LiqbGt)UMAetW4pJ!eX>zv)FmkuVi4}k zh!d|~y(lFvkvw9ry?=4(*wN0Zl70K+N9r9dydSisHH7u*)xv}YiWF<}De*QFM@L+%q`t%>M=itFi##5aP*` z4p8?8-~8TiVio6gkyGMbVrmE{S1)0)UclW0+_W>>hpXaRTHi01xbi&4Y;%xdlT%6N z`*)Pt_Y?+~C|7CH94d3dnuB8}1-Y7P=HLUPI7iO8jyL^V>t?~>ogu@+aOw4O>yITT zCl?gV9n{D7?c=jSK~lJk=4S!rtE!@a`GRp(TG0%7sksyfxiN;1OG{Tbm-+d*9L4G7 zDZSyYEIxI6yYYqoN*gm(hHt9QRy#Cp`K?GjnWg6puYH(oopI?>T1HFkxX*3%W@XQ> z51Zm4d+zC8>)o-RK1I7^>gZ}DS=u|9n$~Nq)$(|D(H!?U<7~z0%w1+?ci-%rd*kE# zr+$}?9#zuPa@?U`BD6*Vn#e+hnuq1fakjCnjw;gri7Z zd6@9z>4Qp5g>lZuLC8&9Vqjv>x>MO|%+rgj?vM5xhr6=u`+-lnlUp}z42#+3^m>%$ z1O|ffMaD(ma@0rI59f4gbU`uurXP0h&M+!2FJS7au8 z&v%($JY|51VV^6O(t~pc9BbOMCyttzbAI-^#6#Nj$C^j(XMh37#ful$OZK(2vXZ<~ zQ+Pu4SY@Ui$+`~U;jp~iT>VuaUoz6mUf))mG<^M1yKnVd_J_!`*!%Nwafx$4*x2ws zhnVB!8gusCx!${SeyqveyLB3uS6AHCy}WJvc0+F5 zHTuISeV+Bxp*cBs?i6yW)}}JcjLbGm8B`6Fw=ay)NWaw9bpO#ZlcJK6i{$IuF1ImG zyM)e|zBuY?|0{ZHK4kBou)DTl;VRyuMF*eI*S_3orNb;$X|c1lwVg9(4wK2WwA_5v zwSYY+x>BaMd`VV7^X=UeqXXXQ)jiq3bb7bL)UPZ}Ysx2CB@fS|(Qi)ITwNtCg^QQy zANpjx^#Nle-<;5lj0{3l_~J{Y2cnl{1~d<7Z0xUaP?3_KPQXoDHtOUi$56``k$ToO zHD|T7h6l}MBsNyxf0K}~D<@~N!a8ooK(-$N-4H`6PrYg@wddTUU8|+kVD*y8Gs@`p9T+_RCw7T0-75d{dXBIBqFX_tB zlHIz*F5Q?^Mh^9r3sM+=J9^+0r3oK;E5+*9PP-SIKgKHm#Oy~Vw#7GPv`&U8kK6Wm zNMMu6SMtN^`-8mi`$;r5Huh@W^Pr-l;>;P%oeHueva=Es=PXevu`bVgsVaZ1C1$x9a@`eqYqfpzLIfHxe ztcFd2m1UoouTO6c>p#@2@Z;{164+-B>2W-&3l8^_CrJgSKl7h#XlSUZS>Uey`SWK* z+08{oMYj8`n%$m6I!C6arA;Fcu1x8Fy133@W&O2Cy^-$Djrcat`!O#X6oQ-N$(NfZ&(3?#KQQZU&D6ffv$EP!?ioKlOR=)I zzkk$v_i<3EAw%XlI_}xKmzw^RLZMg~E;!+AS*9FVu!^U@#L4OL=_Q!}K1eP5H1I(1 z4L!>}9~&B+OdHBqb1Zj#Q}!xYzs7>L=J}>o-`mQkqy~`WuS-(iwl$Zt==9lkc8_Ws zw{6?j%Y;Uw0Ze3KvhK##K@)b%7*pebV6q3>HvW;Z)-SUUY=_-KQDd-tY!+#Qh?c~~tk zpy{o(o!tOAx#N2-jLLb}tIXimoTmj*e$Q6D3Qm7JqpmF|Ft(t)jbt?LMygx3T)vjl zg+&g!uM~#lQ*CMt-m5J=&yJn=Hh%MtQ>RXW0Y=tRjXdofC&y`eU|boi0^%Pl;(hJs zK@*0DQ0ptMk_Mlg=NGoSkJG-I7u&ag|Cnb5T>GALf9>))RZ4Vo9`|ubPKjhM+30nb zxUX`zCC^@RCP{9$-n~5`!NI5E;=CA)VLR^y$5wMM052VKw1{-i=dF%JYL@+Wb>D4o z>l?O?BRhjp;)GEq-->Q*+c@mlrh(NppBHC^t_jsricwLg1aK6tln)j3!P z`kK}DF=;M|_wV0Vwh9LT-*{zx%+jQYajLqy&EQu61eVR6yCXujJUoXr?&Pd#dzg>U zT=h;fZfhu<#JCtj^>q!IzMYyKTz0}PLfQR>6Z>@SB_&BeOB>b5rw$Hoj}kL$zoeAv zZ!y&s2{v>_tjH{%lcQZ{@&Isqm&n+(KqnixpUi1zGbAQa*I#R2Lsj>nORv`Mg+o) zX&Y83zIr@lICr$fAh%G(upILB&2>*wsw%TXj#zDP`sSu?Fxax}Y<2L~RLBV%xp48~)vxdDx86NrkZGu;GW!s_%4na}m9Rq- z6IM($G+h1p%5pZF#7be%a=}{CK(zoR{6HnyI+I0L~2p^_U+5g(f8}iUbVg$ zp*MGVI9|=%yybGkgV1TqkGp#uYOOx9yR|tYEzKF!pfBO%bcau+Mu!*q$nCxFdwT9E zoX>7m*OJtiTgHxA(_Cg|vF~Vw-nDDWBZgMz-@Ety~xD_09`f#(kJML4xLsD9AoZRG6yZXdv(Df2Q z;GZ++@ZrP3v3nvS#_F+;W@J3}NU^s$F?)Y97y)}8S~UT93osy3Qc?n5_5GFglII5~ zE{T#oFTXGl|EB&Dz)?xyu7(@D``aks+@mA9hH1*zW|%*}D)&&MWwZR2xI&Ayb!v`t zKF*aNUmVr%bX%D2GuP1Z6DI77h|rxn)!f1YE->EOp+u!ppQf|EXM@4SinotRQR;1G zIQ8b63ef-!e0qKNuYGEY)4ccWi*8ED^kx~&cb|X6FZKJ1^ff_q!N3g+Bsm<8sp+*F z+lE+7-P=MdyTDt&emywJeyBy+tERx#aE+?!;rX|24NR`<(^`IA`EJ%m{mf0;r{*LN-8_`nTycBtqlg&q=_Of{ z{U#LMPQDZ6DQ~lj3y=y3hydqqoHxC^;w|uQ3BA)6xs0}5{JHwbcFi0`MMcRzvi0`U z%f}TQ;LV)!s<^ky!iCMC3*I?oWH4=7o0PI$t}|C}0H`*;-p$hYVL|KY1HBp>*kqppaYk-_?=rFp~V)JgB&t_T3|f9=|}Yu2m*H(<11=^%Oe6Km31lk3ZJUn`fYDOSk6(U~JV zLu%eB&$|+VcRdzmu1L&w+pkGBb#T}E2P()Ur5)OFx$-vVvli#B1UxfDKlpslU#f9AZOJ+b#xUEPHX z77QOgJbbK)v69kEs{f?S+GNu=b2eOBB;n%Y=iMuCoHek>k;bbtVpXd0qd0>kt-?nE zPpLT7Yp$znOtzbhoZRq{{nTR>DZ#OGZ7jl+c@r}zH|3o7$tZ#D1SCmD_VZ(m2Y!o+ ziCxF@k#LdgXKQ)*RTkKeg-r|Gl6gHKM4_1lmxB_ZW?B4tH<0(C*?*@q7o#24$kUcoU4 zMIT<=9AsLFD~ySWdHmQZG011<@HXv2qpRxXIJ=k&eyJr&ErC`MMvMpv$+lkKC8P$% z)Ons@j#YOlTkc+-TtC(<@cY8&#}!_zl`4P!z1MSxoAZi)UQR&xZ4nkBn1C4F#ENDBL$`r5-PKth>PT{8 zBo`MG-GGhw4w^7OJ%dbxxdUlTLI<9DXiyXm2{Iy6s9bP5)t#rY)*bGo)L?s1;GeeU z)M+H{O5mv+EX@e;n`m;kpDRiSEed}6m11-S#pwQ?Vy1V@U;lGOO&1iUC!X7WCY?^` zj#-~7?C%M9bhEy2ssSH1l>;ruz0-U62XYN`&+y-g_52*czi@Nmm0{L$jOQF-RznB? zINfuN^S9@t?qgOv8S^i@4}>fUvO62k5~p|;;Y>o)5YzmB&2M$JAzn~AxN8XNg`61t zV<_Jlh@{J@>>d&yq1pOi4hIewb7LYd1T759bBJberBN_;0Q9#X(|ycA7q z9;~3zF(!YQ<`td{LIiLTbh0Op3YrgkAI$sBfj9#i3JK;7rL{*4HOS!se^5h9K(Gl` zIZzIQPGBVAC$~mOJdmV#Xs+TPbO<#9jYK7(x+hZzcJl}-W)7<8eVfmutt6<-wgg}C z7zi>)1;8<(pv1xQveSf!w7h^{W6)ND3U#6!F(x~tT^z2Ub$(PjU9CN*IE^bvnSd80 z7e{r9bU^`07s_OWMpL9r$TpAWE*By3LGuOt8KMicY$2n@k`q7+=4US8TQovp(3xC^ zL(RzR?I)AEVOJPWnsA=eyA*Axem&L%yJ<5^pGmD zbFHBlz_doDfL?@JjYBoq=;R6Ce%&m<0vmO*PDY9YRYPGx#>y-=m_PZ7X(cNW6x4z7o? zx_1t#RX~AwvO7d#9(3wTni~zmGnjSV6v@Ow6Tj^gei%g+BEnaU0sb!UI|6l(dLRr@ zLe;RZYv>z7cIqEdvL4_fWgxUl?8`UP3r~_37 z$`i$p;V`J;#nW`7Y3|WFb(@x^CrxWdK|RO`({*!EMkAhw#~-6>gM|zEF66sPyRZ6r z;-XIR3sNkWdI;vo<@3IAx-dQglIfUZS19Q{JOsbBr{)$!V>}Nf-=^^g%LI{}>Lh|Q ziwDWgKsbg}uSn-WxFu;=#`slW(1GVOJwpC7WR#7ProrF%Eg-Ee& zu|#uN`Qq*qgcLlD3DaT2{s&QCr$Y*KB8ANYO@*nUd{`VBh6>TNK!{SsVu`K}f^)Gd zq8jb0k`NPe2;Mw^W9hWzSO#{qAp8$oi1bKI8oR&PmD`DwL9j(;YmoDh62)(xQ0Wl7 zl9xk;Pyoco!yMd#DIHX8*iahIq0y-b*BC(F917WoicIjZ$rL1;5CR2Y%;ATAJfc;! zjs(Q|AbbWAKv|vJI!rhwVElu2h$ZJ@iU&+VWbFVvx{S_9)Z&K+H5hP3m4Dj{& z=N`VB#9*ke?>@;_r@oMXdxW|+I!YqAcQ%9*8ri6!&I?Z#%m$#8!Fm&UBbb8w%=diYAmaGU zpd&T!8TJ-$0qnzA;N!zB0jloc>_kd}MmtkvW&%Sa1Z?2X2VrzF8^lgX3`hm`1&<=< znvqE67)>x{lt^+vejz;2b~l?5kGs^ZnvCwOuV2rgE1 zx{LO79g3BuKV^#h3JSyCNEB+ivwodn9W}U4<`h_5)ZUmv_6823{K(MWOn=?p5Ns&` zo5-{+vpquaS!!7xcs~9_ZYkEmQ0@Ej;EE7|2$2E_z7T&rrzmQ)$n`~yw%yi9go*GA zN=Z8r8HS^oaocBr1mTr~PIZXX3jr`3n9vZ5(7@-5T>+0=fq`8C;~?fzVF!dIftsr! zsXF=L6m)-!!1u5#zc(=t_LB6r2xo`s1lu*gpNZE z&B_2rHDp0?*tn9u3PlkfG&V5W_IB`_;YG%%l+jdV+TA8|z-$9cYvIY^xuJFfd!4o# zfk;}+Ud)`w?=9T+#vwnTFCcUii0~5;zJoU*gCdc-I-N;E{(cbB|D(ejykG=F_5>YX zj3k})=h7R3vO5M^a8M}Fsu6x>nV>rd(8=UHV*1zuGXX`Lf~28hbGT4fNJv=DgcB?L zU<>D-`8LVVLM>`Ep!>q!34$$f4O~84?pPOaanJ*>JlUwb!1J?&iY3RxaumCPNaD_? z{zWN$2{V~!qEitcgBOqk!|@LX3m_1CBlr$!GhFBp;|1=SOXKUXqgOM>yjpuu=C^C+ zJTq%+%uZR|s8Y=Ts6oBc(44_!5I33bG}u(cTeSmJWK6C}V8Ka6KN^RM4bx0T9Wm^J zWR6hXL>(W6$A-ZgkEuj_bx7cw5xsSCH(`7cUo83oxwt@)e0(kMAeSQ9j?RFT}bq$-l@2&r$<{zPEM>N3* zi`R~2fkjbJgP@=%AV`CZ;e5fK4&*fG8dTsiLY@6SFl2c{z~g@UT2i$O;yJ+7*4wn z3cF^~IV?52=*3vf_DNgxE}@UJfr|rw>xoVqqd81E+%A#DT^{o{%oBBG97y3ELm+ba zPfQgdE8YJf=AkR(zZmoQh5V72C)Bck67vwBjb?d5LI9FvRj6isOY#Hlflr#CkQ{c} z_J;kQ`6BGe3qdSG2I)PVFZ$;Zh{yZ`F$nF(#Li}hgu{~PoRVm4g7x}y#@8AAghzji z>0!^y{@juR9=Y9cJ>g#y6*EyX&y#^Z0{Xu?pWC&4{%5e_AF)&vEn?_U6f#!55VgoZ zi4{9Vihl+tiZA3MeF_g_)}}jf|WXCT21gxXj%;%`eD}F ze?eytL8s$CL3y1k2+e5BrgDIepd|~hEyJfN;ba=9D}~N;M-3Hr5A69&{tf*%_0|8W z)K^pg52U{O!TwK?eQy8s8r|>z)YQ_^(dm%?NlW+N{h$Adf5_5T0J^CYI2%tIQyqFu zeS#L1VIXpt4R`wqANK$_L*0YSpwU<96Nn3_Y-P}wvOAh-sP=W+=F zot!X}=}rc)We$tUBEsi`nJi>y3wn;1mKwoJ8~jZHe^WsPMe3#r>j0$iUQ@tNa0U^0 zRCO-P2df_V$w&Mg!4D(^00eZ_hOVmwWjkD_qtcLy!TOUIK}WL$T!zA;v)K9sW!Teo zJ&-E6(SeyEkIjfzatgnaY$^$ZPMGf8$du)t2v7rMQ79Ax;VN}i9l_C`X(l2IABoi` zAU?|gxgYFKI|*zrUPh#D{C0xF$fi&rLZB401i-)g+%^QaP!2^L~0^( zbCKJKHMIQz(k=B7Yyz6k<-#2xcrWc99GN0=r1MSz;sBPXUX1`hV^O~Ip8xyozsLUn z7f1lQ_y1bcrfO@8`~QFU|Nn>n{WtIbw?+*cPHtem5RMvnWctsO0U$-G5#}JLs}Zm* zP0@CV0F9PNGpSzOwq;lKEg}(6j zpNrH+^_}zyGeg`i-Z6NdjziIxw z(~86Lu@=s9?6!#lNoBZ?oyy_D-j00eX!IqkB_=+q+7 z7=4H5=yxNBKIl(0M&873b0@;9D0I-Zk+)9u^rOo8@EAU@$1r@lt{D841pFJ(7`${{ zB}9zFrGoO{>p!XvWLN;FgV(OB1ApzImJm@Yo6Q31N8WxQ3baZ^Zj`u35f^0gpgQ2| z4+N1V1DeMw*eLYV4^BXLWEf+6X8wr^k!@q(ddNGXMnX4&Bnlar8hGiZUYKCdRE`QG zi={y6@a@OKJ-b7waF6a0D*98($4)_3ZD0?E?>%)rzmc1#)7vW`bt7VgJze@8fuu6z z=K$D8K+qv(Q0;<3JQ_mF6C!$Q7v^uyN8h^?<8Mnx-@6pUHh>~;T?(O_4&iIh?V*;T?%{vF`Cj{L5R*eDvalj6#+f~8+7lk2<%x6 zaJv^+ILx!Qv+ZgB1vUGV*2-4{(b&;!ZV$(J0@aZz6sixn_2_$73U;GGn}x4kNl@r4 z4urn&txFjelZo^*>_b;_zzBS(RJLH8$p6xfJZ!N*p8usgc`ljDL51O`t|YOo7jW={ zeCSF})TebW!DXRSb;g2^-N<6~lSENl*A~iUXEa%9woaofHd@Q+XukGqWBq*UK0R{jqtEu~c-hcV7 zX-@z+Xmrvewy{WHk87{J_S$QNjd7D0taf4T$=hf1VzA!1Q!r1LnG>Vz^7CMnENteYRlgdxTE2l)BaG5-rT*{h%Hhcb=J^yU>{O7=KyX*vu2wT$#@zE3JWj#ba<+uS0&tJ~h(ncm!j>CL0xf$7a};xj}4tFJv*>0?Ix_tnn& zaxwmUr@eZo|GkaRZ(0A#5fCmL{~c>L{oTcvK{Qa&;9sKgCAu{?z4-#e+e7$`D|zp< zymwmO>(KIEqi~KR!()RYhtrYa$r##Kp&^Q);Y(54If^%i+Q1MY;o=bXw2phimeocy z?Qg%{L$Z)XS&17?5#1`cF`7aE^Bi9rScy+$^-B&dU^mwIK(^AojwT8giyA5lCa$LW6Vi6-JXl zbWGu}R{=*ZN4yUya5S_=K^W3x0Qb;7hWDeOpUO!n5I>Kk7dEU&f1@V|!b0QFjznzc zP-6%5-bZ@sA1Y^)*J+X`-DGgNi16Qa+E%E0_{Dtqw!j{r!umyss^}<#t~-HuiC#KR zFCD%Yu&4J)@+njf1bf&~43zMtL~?nK8jQT<>2pH|d-Ut5{ttDOQVQ4}2AE#ILCc z-wOo0_Y1-9y~<$s^ed;`FEiDe1g(uyvFfAD6L%QERhUU1b|P;H4!p^w&csO!VTdT6 zVLUiK38K{ZC3sY*d zZ#qI6&i&HJEnli}tZvOygI1K#3vHrDaL%CzApx1oC&4~R*B!fv1Y zFSqwz(L!$cy@aR)P&D$eJ4wSZ7k9=K_Uopp_Im%#p{gW(6OTz%b<`bJ1i)HZH4k>* z{AKq|p)R*SN9{vcko~vCu0_g7RguToTiW+AO94@~%&Pu>_h0Q+)b;-fTn{3`c%b<_ zWM;01&nvoCQrs`!BjEuCVuqi;>d3s#Mnrd3+JMSJqG}7L-BDgFg)x)#gGI4#sjAF} z5LYKND_`m2s!G43Xz#@leJGbx4&?Kcm9?LzRm3nV$G(h{$_X0J({~<@?8&29mCpuM z)fFUUEmK7yL|B%K!fJk*=?8lN>z!Hg@F+-s3S@5-Ayq-Aj}~x~Xh@2vfh0h)RS`Qv z2EaWqyBT1-4!&G*97O-^n-?l?!gJXCfCy*|C_Ahe2E;(ozgqt zG{$ij^uvaAE^rYU>H(MMBNmS!_}cQH*?A?1O+^Fen$?I%!LW(fNU5eY&{?zUF}aeO z&zN@6Suyb(cG|)Se3F|A5EFM24vbpZ^sOlpRii$x328L3G)tyNjEiigaKRx8L6F-r zPo!0xh|gr0ps6feWwS~b3^y#mq*$i39c$z?qv0R{G$xcM;q@N)A~kuVIOp31{N`w! z`lq30XQyE-Ov!LKjs@#7WxE6$Tk;tZAIDroAqx}*+Q4*t0L~1kUm+l+^3-p){CySb zu(}AIG88%h<8#mekDmy;$T*K88?^2;a+oO`E{kw!H8g|CR66Q@JZJK!ZcPF4ye_>X z0TaO)_f(Ukbzmd_{a#TtO2t9p>i;yzHvs}cocxzu7Fz&UjBz1>>nq7MCBuU+sV3Ei zI0^RfR+c!b8gLZ5UYPi1Y4|khJop%zctRAV31veVzaQ=pmEe0Co#0t)r{M}%YS0TY z)lJ_YMj7mXG`wMICXm$eOhOO%f?OhJ>7$CTFM7C`?uzk%0y`Wg9ND4CKX*6-n>gyNU2<3rT@))?XyQ#8IjsV6r*uV)>HG`gbGcbnEcN9?q7}kQj{+f`F*}s5ijW-0UIa_&a(;EbJ_13N{GtBG#P9?%o--NZbZ#$46kPm&s`;p ze zHi8X|0su+F8NBBl3?#|MP;LovW+a8@eQXUJ$rwrha}`86E@9vh?h=B0y$Iurb1o7T zwOI33bj_VOJk>LQIzXia&)=i@Tf=vTZV{=%Sk6fHZ3^SeRN@t+FrVOnU_OZj`4d|b zk%V8`I)|*r6U}7xv1j7ubcuIQ`C2zhg_qP~OQgwIou%%8j~oseAHyj<(1IpZ1qjY& zyu)#mcrXo^@Q{*-@$=I4063p48HRZ8;lN!J7P)k9v(tQePRys`h1rU;&HRVHC>kXM zOoC9&Lz_RBz!&z&USFGri?`s2O#vQGyqSH0OL;xdtWgKQYL5+ zL+_dCe!It#5!JQ>K9Z-93>sP2ctElO8m~v*R1Pz)dtvM?qymt%pfq#Q;?TM>Cp0)W z{0|~E1zF{D=`7&0@-!HY!uSuR`vdRzJ-F44LKfe^^Avd^Ny?mM;3^6oNVQG6 z+-p-ldY8>eU3qTLh@g%_Ek1cr9VFNKximyrdxx*y8SBOAMsHo)nK>v+;)tKZ>b3F( z1<(B2aX7$Gg2fkDg;<6x>Xu%&@GV}q7$>CZnj%-Fqq}LksaXsuwj$>$Q7&RP!-zJZ zqC`k_B=DLVif#f9ME@9%w_-!ZLr3J!HN2;38$?mdBzYtwaIt7T2sBRf}LBU z0(#un7Y|wR6V;uiaU+8(SUDK)bL!vk1^z)a_!Rgv#^n3mE>v5nJ(Y3!&s+X0w0W)h z(}ugim9z2jKTx&<9lt!6pnS?r3JQF|QgmH_0`~5u{BSKiVkA>=)87-S2@8q@LK#=I zmzS4ug)=e3MZ-d!42p< zl&sjOJ=9PrDG(0lf(Zu;lF;k99VsCd9otMDVkeCyt!NXI24)f7c8A*Zp$;1=0(?m$ zyab2gs4+X?VS!Omf)XppsS-nrEkrT>4Cgr~=s6K#jrNda8THsiI8E_FlOgk!<>|N! z;0zn{sl#di$wO7Os0!Dcw4^#QTlR7Egnvv^Ov%ovP)j+wE%m^ICweUw8K1PC+G?D$ zU%CY=hx-opMKHv<&Y?zXf8bKO-wM@PXLgw?W&AtTc9Di@b{F9&8YGyey?V%BB+u)- zI{ONwea^}a))E-2E z6q6jq$^(nWVL?V$9wTgYY)p+Hcz$-3Rx8RezgvXo$z1HKXmcVmztLszw|>d-SFE@6 zKv>_dO4sZgr3*0^fpuBI8`fDu2q`wA%)$_c;sppABKa1D4Qz@Ch@x7nB7y(<)sH?f zuZX!Siw?k$^W(O>O5UT2eFLV!e-jQv3Q$bAW82(3h)&`p4SNp|A2jdNVpDs?|I`kc zbp)jH_Xn`^qLdlHNh~EZahK&BZSK#=_8jP1=8i>vkY{b3Ftxot%h&nd?klytF+jAN zYxF;`l7be|u2|OL#7~4Czf#UqwG!6B~Q2s<;wFfwr9%!JZcmBigTYyFPJNjG-*tDgT8&yD`ai!4ZS|f z`c?Cgjm?T{O#TN5|05RoU0WLB6qRz zhKTaYJG(ixW}i@Up`RsSv2XhHrCGe)-v!41eR$`tweP%he=DC^{=X)E%;o!-?*H3) z)Lw5F{eRawD|i0CxAFNc`~R}lD5{o~N6sa@faPx~;`4OBU*dIH_pCd=^Z&i`|NYcsz-8hlc{rL;$|r;M{Q31H{C1UuG2L=;@#;G}PMz3pmL>FQV2!^NEaWFm4C zRx&SsSdx0#9(@R5j6-%s&zlKKC~TQzlmv#y#}x966j0iDpEk<7CM6Vs4L@IIv%_L) zx`6G@x?{2R&;mJ~5)R8?JU7uyCnQYrjycsFI)pIHa6M#fuJBjenm5U9nfxd`j`F5t zNXCCEYx(;kPad2%J#ykfkviXQ$iVX42;_O@u7#}LFbP~!c`}`Y0 zH)-6#IC)l$bhzg5jK1Kr8^=Du6u~|jTi8=BNkcSQAni?(DU<6Qt(-{@ z5Y0;3_F$o0%9c3RI9g~6SEx%t4PfdL#x?9QAmHdMn@vyG z>9PI*E^NsV2G2W2564(}&rIkT^+KQ^0ox1V&<4su08N&)$2A=Xg_sy*D##Hpl*hcf zGE89|`bk1kE9P_=4s|tP5!_j{8qFz5^i40Am~>48h@J9P5!;%sQfvCForYG3Qrht=~ztCMkNe%haSp8vn-J@&?Gh)BHLDk_~825BlE%g~&`GG19U_V-yY$kpZaAM_-Z{vze7QtL#L*3o}*=1mv*fxIaXhp)X{b z(+%?OY3S6Y*0h_c_Ju_(rP)!AWX!IoI)dA3i16IY!RKf=9{Rx$?wagHgLWnqm6_DQSp%Cs1275{1z=b}VCHXol{w;L*ccSb1p|-_ zqdZq!h&>L9#G*Ji9FgO$ixy~P83oK`gcIY0_tq+?%YX$hb<6PJ2qm+9HpR*m#VQQ6 z<-bbeMG;3xU>GEL@)eiXi=hOdPnZBqK(oI_T^vr-MOQ0XEn1#TAKDqJV$r}~%v2__ zZ4)f9tT+QULh-d8o#X{;nsbyTG~hrGy$V0zLrrlkoqDafL^Z^-KnGPpq==Yy1!%UB zYfs!F{Y{h$f;c|vo4YIrVl)6G=|+SmO+sr)7DMx)9Ymdr+h@u_n%FPsUIw&cm=Q8R9y0KB@Er>WC7DT|V#( z5d&)cws6E%#KLDMeJixMYE^^4E}Js`3*OzY$4=CvSxb}} z;B>-ZsKCjxsM+W8OGUgeY$Ndo*SF1~dSsXl@0x^7%Bo-5p>;}gLw=l%kDs(3FX12apu-RFM(^u~ulV77%<(grbLKF{R(u~zF2|?Bke%CSUN@gP zOIX!526=+66))$^Po1|M+ryoeVuwTFyQIAf3dZb)dk+iU`jfhy8a1UPa|awngE~Aa zKP6GmS79{~4!!Ykcn;hpU>mYQGqh+YD%1~gITVXloD~u7InXwun^xQw3@(Ts$07=2 z;!bhRlvz3ASEs4&lo)omj<&K*zxMa~{T}|WQE&awKv9sRilh8ZH?#?`X?GXk6WRup zBWoUfex8QmKSSk3nVbM#!hJUEj@k5eoU-Sy_>DL>o@rRkV&Fr{)K!Vua#JFrL?G%D z^>DB+PvIM#nu@=c;|iHjQK!XWz>#}_gE|R|1c>eVZUp$$vTlx{45-KS5~D?UaX=j zRq0U+44=&d+AQCtIKD$xexN8wYeQ8~N{r=(!XPGj<~@qjNc}-t$}!%Yy`sKDscqOj zQ8G{#CD5)q1H&Z&Rqe-KA0>F%3vW$FzmqxnQQwZAdyo3xLO>N zUf_9BYG1H#MwpJS3baAyg=KWBB$dwMdo$FxCTvI3|8BX+q)Ot>n}}K_1K|txnOKzdKG-JX4LWsdVffBzF!RzY_~|Bu6+*Gqd>$pR;Tp&iTjLwkcvcLH(xzH|S$bN~2X;Qnz9$=+S} z4~#kvJ4w5G7$1|?mHL_}`O~q^ovUbfG+SQaPq5)dmG}@iC2g|b^0(awco{?E43=vp z=}`IR2L)SyeOC}wt}#=a;%877#hcbvt1MlV*q*9zZhNWFkXWeLy<-8--FsI5x_f2I zPl4xEetT(;@6U8&W|gs0L_3)Xf&xfHT4iQP0x#}>lbz>|A4O||oNCY9<|Vj18j8f> zS-C$YilKn$jtHPx8C2e?(wr~CJYuid3S7q)DPpgf6rg_xV$B8&njg&}>|(<(qJjV) z<=tRJiz>_mH|+`3TugVdrI6Dpuw8B@si-gsKw$TZegQfs02&d+QI0p{UbEDnvw}Xi zRAHrqAlR)tm$2g?wHE_j?O48bO3$5*fgsKuT##Y>H~nPn8C1n^j$Ne$AP zlBo&GyS!=}nQ~#W45_q)@r@;n5VJWfU?v*Cc(wryi`yw0J=?hOFa_B#+69IRc4ZIO z;FLGRE03ww#ze2Yxx}4MBZ=thkUo*CO?RY|{V!Tnls2{eDe}l|yD=qejD28;m17eb zPwG@Gl4t0(?rw;gfVh&V|CDM*nPrjL<-6rpYkl?4=ry<3FHHj-TWEhiP-!8Egq_3e zhqPv-qeNWgY3amHnK#z9AXtCz)%LSzZ;rNK{Y_>hax02c>cR=STz2|#0$+RG(xx;!Cmf_= z9S=_>|5$8%hDm!TXOlS$S;45INiv4(?Z?!av)Eeo&Vo$bY*EVzS3uud8y%6KthiK` zAG8;S^-uYY$t&p9S;#F+g(|@^b~{?T;pYUO8$Rok1s{{x3zYAV(!x%|M+vEJ*?rP=0ofgb7lT*_&yAZeV34yG6Xc|P zp;Jj9+;izV9C&BA@7lXzlK1XhhtoEvGRy45U=>G|_PoWjqiOC;VpPW$7tdi00VX^4 z?@V9%RbDi6&7ka)PR0n%_pA$uiu{RiLipVjvl_xA3VYDm;amT}I(gkX!Zt>R6^0q$9XCH)?8_`A2HWeMWlDqb+E{qkuw6As~+81V5pLex` zQE{n-gRwHTSstWxHzT&+Nb))@;9opPojn`b6oV1;`>MM+=j=TO|EO!hg)Trv&k;dSui#H38Ho=qJ7KY4 z*Uk)9LOkm#>jAlj*HLy_uyVKd`lU(rWD^)oRxI|!dVB#(m?-8vcN7-#I2q^46c*_* znI$FG{ar^pRb+Ukvgbcj3jajF(_#9M(zY7Oes0Su zH{6ATVd4wLrfG&rooY*mQ9r z@!7;xEWC7=u<&xOR1@7U8V(aFw-!%{3q^w_2H<@$g30p%S&#PpV^{%F{#8N*}Z+QDO^I7;t`N)=$COgM&r7G{a4xlG5r*wMK)(+ z<03v;kYc(u@^F>wI=Aix>V{={5h=JUamOqGct@TrrT^^+q;PX8oW6m*scw4~5mf<1 zaE$Lp2vcBO-!(CUd_Vg9VLrptH(}6ojlCUKsYzrt?a8L4-K;acqG%f3U_I%asI)z|hd(|wZFF6@RClT?# zv#yP=)##jSqfV!#eF!R2d$P}XPfovLiqB}Kj#v;wX{1h=`^FbI~a4Ach6Yx!fza?n-Nl_ zRg|T+JSLb%iIalz2Df)Q9VtQ2H%{pi)xfIhdnI=Y1v;;o&aZ?;w5#k06FQN(Fm@bx zA5%#K%wwBfJPuEyI2J|&QO|YHbUa3;X(WqT$t#!<-LinNN{3vIudMi_E~&?yvV)$H zQLj?LioY2%@=8kF^0o(A(zN2nJM*281wQ9fkft)WMXcm!(8rjvgjyg3I3)$|z3|2qrX<0&&TES4Mef76>EWP`@SlIo zc~BpaZ#PaEtDE3;=+`}6x>522*7c1imZ4vqv4bpS6n)bk8B{%T6|?^k4LO>ysT8V% z=%XSEP%KC}42ih4X5(Y7LM(w5R3^~O0*k{$k{I|NR4I?~YIG7~*L+qi03jlt3ncc7 z7_;6*xHt;X0lNkqAJ^T4gMdJRFd>ouJS3tjT?0iW z*Dy^~3&N%OD$St8sH_!#V;&Ue(l6`?j=b4-qJ1N*5M@q5;4Qu20yH(PCm;zY%}Eh;)+H%_ z9C9$Dd_%5L)^!HMl>`H&ro>y#0SZD0zaj-uWdy`wcd;ifZ-WJQnA}eQCOZilM-TXr3gm1IKB@pMVTM3}7U@{W@PL-PW-k#^I_1VI*zaGK(*aS4U^;*boe1uakD z#kC|;Bt&lO0Fpt^1YY)><##NYSiMEYafA&FZiRwkSi!O-zL6{XDMllLH7p?{7{Vm@ z>RvH$Jmk>lk_>VCo;&D>d9i*lP$nYKOxUN6cx3LehrRd6y07w`Z+Nq|nD4yzP+UP*Q^ zMPbmkb;(*}iI$)hf=3gmZaFWfeLh^-P5i z6*UR-$S^qP%ytg?`Kvic{ruIY%Sf@Q8&oh=1T&?q*cs5b-#OcQ2!kAyM z0l8P9sm)0trVf-2PVC4N6YpPhBE4oRrbMSKpsHfNZva)5dd5Xoc}fVx=O%E97;@#q zWK5m2j)SJN>r6M$B;kgM4?-6d36P-ZmEujGo+}}1(?jZu;&{tek}VHa6it)^0Br{( zXp-1c6Kv~7kj*q%^XIi$qXeIG=Nyb2wh79*?3LvYt4 zLrJy0Rahz#zBAK9+$6$J8SmlEl}9D%tc}c3xErPLFcNAV?TT&##B)f*6J{OQjtL5? zPB2K8KORw2#JakcO5Li21Vz_<b&2T4b9o4X7ZP5?G;mF1!+Dmyr(Gst!-7IuJmc zkC$MU4*R0-NH|#%6BQ=w&UMOUNn3=Ib?3^vCm^wb&%~r0x(e9`kNLC~jnSW~Cqdk* zWMm9J6tGEHU7G?CeWB5LZh+}mDr~iCOh}wgHAGTp7O_obn1X?X_bs->O%2gVL2@mV zCM?P%9FOtH_69+Eq9`Tre2)80>P;=LMs6IZgLg|Z8+QBajYCgVM7$ACO=_8(Y`2Kk zswiX98S(Kw!`k`#2W(GLc#bPe7c-axrsefn!%;}h!d`&dW;UayR3>X}^G)x_R(!xg z`@~Vn?3ZH|o(GD2;!W)h61>{dHKRcG96-$EZj(VpfN~+&5vIV#RYK(f3$AIbN<`@? z?FpGG08nv50G%N#lN^o=vaBZsGhd3NT>=I?rZ~@@ByNLdU~b3gk?>J2_z}f*ChSG^ z3M(^`<4;jCF7Vo?AtkuzK36uI1?T>li+bJ#H=AzGZ^E}-&+C>!QTplIlLq!2RH zHhjFd(e+UIcStZ?atxK2c1l(ydXg&5Gm&G{gXUx=_uw>YRkit>s@juAHTg1W>jlf^ z-*=&hen+8)9^Hi=y3Wsx_&?*`jmQ64X}8zc%kh8i@;~3o=fd%SZa4hT+h^Ah`v)4i zaO@we@2L6EtpTIV%3jA}Gz6zXt4aq?b`>UD8Yfr4u zKk&QSp~WFV6Y_VW;?U?lkt!&8;9KkYR6F__iTCoPrX_rNQYGW7DIs5NmS?Iii8ofK zG(M=VVOizZ<}uT+89V*jY(xE;WvO4AVyf?ySMF=NLfKokP{W-;RyhMl7FuI}fLfK) zEC;W>;E2ejQ`zq+A7}Rx;^G)%Qf*ooqiPKErUWyp6ctShX5>w^yuXHE3zK)G0N+>+ zRK-=WravRNLUF@#c!j{(mWQXM=nCGn=n7i0?0T`GWLHI2@JwU{-;JzL5m=!ZSHV-a zR!dN)!YYvX)(NUm8B@ViF%{g93Vt!9LJ3?b4XRmQjd*FdBPy7H3S-ku=219>Tt!nr zNt_C%U}7n_p%m;$3TR*M1*JF&{v2@>ys2>%{3&r1ys9_~*X*A=8O={@%HbmWOfTI6 zPQM9(eGXB$QSGUVjd_+^rKCNpJfbGkBHMej;7Vz`;aU#6vyp2)m)UXo)VyxL*{SPf zPLR?%Rd~l1NYhLg+45pu#YuMZ`c-I(tG#5s$zHOwvNN4zy(#WpGjM{gP!gd<5fUb! zY)_+r;Tg^21rK{MN1cz;vc%q!nOyD-UO!5++++!5LPZc^)t)uzLc}L^c%WXjx7ZER zo|;tSy4~9*W3}cQU5s{|+_LDO1vPpBwI`RJiQ_u`3fhHHh9a#j$b*&SFVLH1!~~p9j(Po&p5U1pXVc)pZaTx?-~u!(WJdh-#Hxk&ummy)9)i znoyJ>5^^uT>17~xbFnv9FDhKW?u~HV6f+%KJZir%12h%m6uIIqDnQbJA!sRXy3V@} zQGz=sX9(sKm~-y?chX>QRAmg2v2`F~qc$eWI9pWhWnR&elN+B*L zhnuXR6@;=kMJxE;IDrP>%Zt;2pOf@sru|qX8~2=7TNO{XDM>Yu?xqfl;+0qwH20u{ zO>SC~x&+xF+$WuUHbAKqq7$AqVZR@BQPbBbnDbrPnQ4k#0vaz;XUC-pF>OvTvollR zkQYT(DPT$=e9I(O!XbIew~59v*|OcxRhGDBa)qwm*?79*sGzC!)j#_{&Bqxsn}gsS zhxsW?QBc|Peu6E6YHvgO$wI(Vev{ahtBnG>V^9YYvd8PE!3mNDBs5G#Fi~+2Cl@6t zI(pcC(SRRIl&E|V1;^1K%Fm~fj+q`&j(5Cwg^*UW!ZjB7?U<$7>awV{ty&3BFlD<3 z9W#TDSX3oPY{^1aPw(E=nP}qjZ8y3kPKX*1GTyaO!zCl;`ody=?Tu??l=vD3gsr--7uo9SAfIgXF{ z!hd>J_|I8XP~Z2QkmG=GcC2nKTCcqCYs^*hFL4m$l(D^H<>L@<@+BlzSq#u)nrJC` zStCI;)XhZp*2!IwYMsPMS`i_s^5V$E^%D2K5@DVcowOKEsT`fuCE*8=Na?G>E1H~? zXqW4;2!cKGO2)4H2Mj534XdILnMb-MSO5SXZZ91ilMIJVphjgZs$88dUsFCt5c!Pj z^mv4$Sy{gCoW;15WoN4!6AC+$#tKrcCBBy>)f}?FAp0VE>&S#}WFJ@WQYWH5ucI4K z->V9!Z@K2`q>mMm^+~`rBcT4|5cV3L2a>U+#0vXaVxfUu%Cin zgS>T`ei*Sb)Ey$r@nrabs+cf0>P9)gtCI3dPS==p2cfb^FA|5V22Yqu9Fz@2iRGI& zghH95Tq2G_>AqPJNx|m+tVjyplt>Exe32BqsgV>a11X5TZxt=OKo|vYVi<*)Q4|WE zP(<>26eD1q>p%+gcs6?lhi%Qw>d*L4IYlW@(Hzw6O1Ee+&yxE^Sw-;>3ik3-^^23-uP@92P4Uex($)FA zv%O01?CW-Ub%}yDbt+MXl1J(cS}?Kv1ulRE=cuCRs_nX3G)v z!xPn?&lA;~#}l<2rnao6oW~nA$aL1PxqMM8xg!BV(W6y-5Uusbn?}jG*f=11mvKOx zBD$J&Z+AiiQ>nZ+)jA-vC0~Bs5v&4O|AA>R%sq;)PZ}c#qt(UG%5~NdCtu_PZJAqM z<&}rn6DJE})L^z-NP^z){B`uWp5{k-`+{jR|a>-L?nexIh`SM(HPND}94>>~h z?kG(@MHutOx{Xm754fzLItL5nC>|xQ{&*Y##|!P_brNolAqF-IGOI2*=nO~b;(+0V zG5$tK6+Dt29HT6QeZ2$cHhIQ>6mkw$TY%~pdFy3}dl_?rXpV)U%o|=fmc>MvQp$9{^ zqhH1xiyfs=e;VYQ(DI*7@=bqZW6OVs53(*wmhsufhj&X$_$U~|y&;7w1wMs`_-qv9 zr~Gr1f1ZigD~l3(M67A4Wiy6x7N%%xk5B*W13p3J2>yDvLA?R_ za2v8~P&?|ORSA{>Pae0Tng><-l>iXxfi8V1Jdju-2s~hpEqF?bd4;c6-;AXc^V0Ma z51BhmFfR`zR}pSCwI$|DNsT*^bP4t@Q%O;1o8fQvK(II4>~MZhgDjjPBi3yvsTVMr zAd;Z+`}rIaQ0AiB@rvy@gPInduM|Y2JSH0kGsE*x+)q|npP>yV7hiQf3fAq8O(SvQHWFdHc58%X;8 znG?zshu4}yx@2U*((zJvskb@$;TO+)=y@j_n7kf7TfPt9y%XQpznv;4UTf)O(yNoD zNwtcs9%pP0|H&Y~_)U>9a^ovL*)1M+--b*u@erk4?Fbb>U`=1I<^yE7Eh3QSER zRU#!Znu8kmnB#Lxq)&rpi70)w%!*zlXBZfdG=-)eOxR$=%T10mrP3au`3BN4SQoen zNL_mn6jD#v72ztTXAPW#;vyJxhumreIKo5u+M}MDrd=$cM}!J;&}XQ)$b$aG&QUtG zY>qa&A0g+=G~=&XT( z1|vFY^28&Nu42bA;v))*n|_wCf>h2_wDQ4)qBUUjq{!Ajtv){W^qgj7<>RQl3{wl+ z1pq4RgF%T&5b*>eViqHd!xs@sO(j9Tea!n)nIJ^N%q!&U8iaicot})lr&IFo(G5r= zwaKzqf!Dsrm^}j>++e@FPS@(suh726ZPzr?^KU|Uk-*HCC7uGAn`;X-gEN;#Q2!;@ zFP-Rn7ahzgxeDfjiBUs_sx2rm3ezrC(s|a3Sz0ivDpfrN{-XzkYe=b>M!1s7nGBE! zNw3On?o~%uETZI&%z9!)=(WtPCyF%(!53<|!FHCjw$$%ghrLY>J<; z3M-Q3Dix1hX(-PFkga{R!r>pj)Kv-2>4uf^>5Dnc0WS+$M;s<~>_!qMb*6%@XIT(X zOb6=hqE{k2JH}w3fn#7>B}jNIUAEVu&kt5k_vwD)XC}y zK(2wxIf#S=g{g^sC6=~ZfR;<$lV~swmMEVWino6VwmRRE3n|k@7ccP%Mt&ANqeg2@ zerjV?tw7b5zPaL{scHwcT)m~)2(?cyQ(JRkmnZC+wB*@ zQtnRhmMWP}G?v!vcD_`ceK&KbFipD$pt)1vm-+4yX&8K*e2;KQu^fd!rSbHeeUq5h zFJDR}u5h)$jzH%el9P@Wc5i?y1zuter_FKl4Hxc9l2jJmV;|?_+C$72Us*hKRv@Du z>&TpW$#M=)i7{lNyUW$XIpXB3HdnvgJsr`jCG#}1%i>YAsOhtbkHf}~~cfg>|~vrSis4f`Cx$8UBH{Jm!z{vY>x8@}LY^ON6heTS#O>eBN1 zQhVKBUft+?x6x_)r04W^Kac!Bde=KyHnSMyal2z*MCk$CmiYBBqN|a9i@)_tj(Z8O zsZNW3wh#byxW#2Ta7?-=nx5%`@WU>ajB`~^fbB(nbaob1@yWaP2Y+kJUs&uda2PP* z&1hY=Xpk-DhU&FrS{fK*ILJaO$Sw18Rhk8qR%ui4EDc7g7=Eue3f=J}VEmX{2blXP zu5&X@stY~GJ+C}rE-B5BP5MWeHN78=hocr8{dESRdik|C*YDsngZ{(SzWZ?z?H;qs zp93@K|N3gt{6i87R5y8o8na7P1sRVGTuQu zaS|^o&oRmk_9+VZ))r-OXYZ053P}Q6S35>-=2(~}o#YZ~9(FPHOcz4YVnsV7acp?1 zcjF)|KCA358e~i&r>ohsTgE)#mB_HvHho{6AofS#y|M~?F z4z`{;3G=uP&l~<@zimzpG$YFEwYTWXx$!;*qOZt?UmzC#yT$l}|LbG41N|Z=MEE(% z>rCKrmD~w z69+P*zYHf8=TU$NMc`zFiStwR#zKK9W5P+8E05%SoJp9VH!rMU4rU0R7L%NC2H(F_0>3(i@gt6GFr=S$x1ZITr2@Q? zd3WR#`r`ZoNTi&e4PgMhDgnR;77i75VSV9!zR={Z{Dt@Nf;%-tstIK`eE6OxEXJyL z8&cgzw6L3~0`Z~+Vkj@W6ea0Lgokl&5!Zai;f~RI<#&?p9kEM3){^R?9xW9OR zv9*Z*-hTqat2uWuX1TWTV3$rPXfCWJy_w$p!n>bNKfHUBet5SVet7r1|KWc2U<>}M z)!+TS_TfRJwqSCi)=}nbkdKeiCDu=_cYjnwK2$@r8_DGzy}WIgPC0_Yw`VDlWv(ZEnP5R8Z{@&nm50;BjD0 zL}R0-t2cy+;tbXLbbR73tCkG^5srj|{n~f8>-fxd{~rQ7oSt7=05IeJzr0$^|JYfE zuXp$V+xWQLPo_k5lz!)gv+>mJy&d4b?xNv^JU;sIUG~AcqRwvOxYz`fl+16n{MyF* z+^^xc`tf4Wphq9g4F@^E!c`g{8Ih|gpnqzKt5un9&(4!H@Q+qLt!KqPYwR{R~$fEj_OnE&%=?2gz|TxNd;| zw10r&*%~1$S|fU|_ut@?&U)uNuPDF0&YlUQRK!Q@-rs(`cO&S8u{m({fAx=!$flJp zo@j-txeSv3plv2c(6!kDT6wkL>3KaLwIo&^RY0i%0+B1?F9cxI7tl2t#annQ3v(I~ zqGrRu_$g*(I2b|m>=D6PJEH|dN#^n-6jLK3R z5z1~&ZXIel!=QRb&VlpH6OPGUSFFs(XjJbswLAj`QRj}}?)vxpJ^Y_vzu$ukd}GGQ z;Q|Jv8US%m-|WKb(W?Am4P6#0vf$w!U#h6?zhMisYIvu*ch9*HLutAY!VU4>z4^Mq zf!`Cba9e;c-9Xx^y^m|tC&%Fq>KNaR@5y*HF|gG$l)kI4fN`}yVEXfWRg0Ajhj2lx z*PiV@-+Q$S7fVwSd06IYse>{WbSa7-%oiGyWpA%7+kg}i&ON;IMo1-8CAys6yXVww zH!6S&YfpvLiVFO2Hl}U|d$o`a>rDmW5cLKY1OerOd~QJcT%LtJ0qto(j#&_XxqZ0v zQvtvLUjQ$+qJCMxcEHoofE_Zm`f?%c#`au2t=~U**zoHu z+L1+3DU9-+YV!ljXWU0bWNjI%v-VC|wKVq#1?S#n)3F44n2IEDmLn~_S6a#cdAoNA zdsOXVyNgbH21&Jq{#JErUS5fg@j8z=I7)wtPEK#*EER_=^0FWl)+z^LeE0}ZP7a2t z_@eZH8g3-uulJ3rg=FR|FSpbpB~?k^NZJZ5iXy~0yInkT)Fm<#wH2)c-WKBXto&LO zvyZTnxf9*gC6Saa)GAsMm6EDWx+zRBK%AvTZ->36&l>M3yHYpz_oaHPf!p$rwes+x zEgpFd377gc#7R6B6n~;4L&Hpl3s`QUS22FeQj1PVY=h!x1A!WZXczq$_w5s$(%UyL zq=CF8-8A8=&TO%zCrO25vX&5=l-jkwZ`9xYedEK!hApt}H=re`-HeAQxpnZ6pP845XUD!_+I2u>)}tWc^lV}|vG1EPB7*rK222v?m68Mhx5 zRj+Ccu|r*;mv{X5gHh^Plm^FBQ1X>#Qe1NT0LPIqBT_XHVM#7ODeIIgj-1rVn&`-Q zYZD1)hKudcO&k@>z@exLUkqkYTPLAKWF_>1F@rED1kht#JRkAOHVA-nk#`m*bCJ)U zndx242Cmv)TUK@Vx&F^g`LEa>T}1{wBmV2^a%a65|8;$>b0`13jnDP+t|+nfPcaQ- zuWYCJTQt)wNV3FtH4ve877RX$mV99D(?ppe5Lgni@Dq^sj2a`Or!1%+?ZG9U0ayj9T|xw4W49O zJP&&D<%TZnFT<07$WhCGmf)n|3d0&Hj)wy5Bl*u>f6r$WW(9gY#{ep@bJHZt6wDJH z$reLqogvdjR-G6IhFr?K$>$N4buGCuyHby)A(VxPf&_gfJA2Bp>avK+cU=N#pn3;s z1_H&bY>}(PRkiSmILub7<=#<<^A$)Gq8LNlNA}kn3(2L;3E=en#%Za7}mQ9 z+X%JBF=i4bJD$cDr@EGxJ7(I_s5aHsqBAM(+#Hb7B5N#_-nBmvgSx+D)EIC zlWMtsT<;JHJFc6MBdF=Fi7bNHq&h~Z$T<{5)3(Jvmc&3jn2sy2bQ1DY%t7D>X91i4 zLxUSunzdzZZLRk&!G+kJ5rwqC%(>y2P6$PL#7Gdu@Jli|ZO^om51+~ydM%B5p_SIM zWzmuTWEGYalOp$Zw2bPbN_|XKs2r7LkftV9}Q<^Zk z*9@YMA$cm8%NUopx)A^4UzPt2vtyj@+0G0|d>F?OqUkKFG-pi;|B3mIQ%ZG=QexGT zcBjL6XEP>FmGmaSaoMOyq^RkeYl3V8CQ-l?h=Y)T4B07{>#$*2wT5j+qD{8}4((dr zG>G2Js-jR@vb|M}KJJmax5=4doBklkEPBi7Vz>M{e}Vl1=eq4;WOISGR}6ltxJLfK z(6#vk#+{+OftGxM60n7IH--cSQ!yblSpU!a@*9WM)uhmz;DyTEb^lbmCc~@D^@9(oum(SWD5= z3&>Q{UF?VL;&L09iuWcE!m#P{F{9jyFkd@RM2-~9-4q)*#)xG^vN<}$ASoQEk;=gS z?;>;*G%Dv&b>>>zLDbwA+!0VQ(YI*n9mAtVgxEo^$v&Te4BGKjr;tRaOl-s5RZ86s z2$6?r+*Hjq3fo3`aFiFF-xJ}ux$Pvw{2lBl9_g*@DczOxQb@ZXqrwi}Rz0QUN~ zRm+FdB58{2Uja{x4bTCj4@I>|fEZ^epv;RaQZMh(29BDWnF97oaLweNt(`1}f>%1* zY-2;)IuSn=$Cj+-v|5^KO~=0(+p$G^kQpH#EE zoLAUD>{xJ|q$M=?+D9FNh6HdJJMtK~-6p$%@z^woa2H7)>;Blqwu>&bOq{DxVtc*p zR&rEM`|KWDZFe#y-Liwt3d=ENa434_s;chrE4E7jvmRY-w{R1dnw*cD_65%x2e}ba z8oA4;XRV#e0sY&;?%OzaMEW|2C~mloprsX&0Z(9@CXJ=ys_yhQRcch`u!fwnJA=Suopu)DCyMji}D?_iQeX;7K8pk!`CL_xR+(~8otW;CnUbe@Jy;fYO~OSv=Q z3NLb3#)u$tP1mnqXtY00Z%;Oa)On`60Gj=gzLemp?B$y#<2dg$B|w@W?`QNw!lvt$ zw}5^{3oX)BXQACv&I;3yNzK{FD{{FLmIBnvA{a}ZpqpqIp}dC7#|WJRD!?#dgbD}U zY1;Vgwtp6U49BC&9<-)A7c;d|e`@<{*keZe9H~56N;RoYy%UaKO_l{hr!yK+ExR5Xm7 zsgNE!q)cBkMx^S`9+AVMm&P+n1`)7P=YEi3Cgjl|=(6z#2HP@*1Q?8=H&6%#Ff$B+ zaHz;Yb0l?}$CMaW$=M`QNg{aE91vC2v*bzg`0<4^O}y%MM=gr6%{*Cm^egi;Uuv}U z*x{ly`9yh?m5&JC-DN0EDpXk9N=B&=&7-v8RIsZmDpFRz>w?9Da{_@ZQhjaWq02j3 zQif1LM`|(Hw(3)rrN8#RjX4gyT^2tSo*ot9T%Zt&ixsg-aqGTQ;P~}Rp^iNQ{pO3U z*_8E}I2c{xrib&zWr!`Fl2mx*W3R-d+Zw+)c}j=JPi)@uYg;AWeQxVB!~Qo+1~(u7 zyS?5n#(!Av+{J&rmCyBF?JDCx1U+K9QTLei+3Ro^q#rS4+|`3W2!fgb;I|n1VU7sj zv!a6&9N;|$Y@89Z+b*0!aiZ@!%wkS&DCTyI0qh3RKf^lLm>zAMqiRnHK;D$*FA$0R zE++Ty<}-u-1HXM1q`j-10W;|T>T)Un1H8SX|F`l{iS^I`rXPHQKWKp`BJ-<+- z>Z$RH8yAd9eUT{CH9Lw}4ZmXWX$y1x#}QsPHxks{Y$W*oiQj6qq+){k=AyjbHfHn2 zKQr-3f=vdiB)~@31F<~H`TCuZeNe&TjpSHaU)ETlSy}!VCslh;let%x!9;jrTwm!l z^w1S4Q1+%WPBH95D}+o`kO*;HF-xjNjm!-8Jwe-OYsU;+WTZ+#R*=_l8Ls16ik2)g zG}gIecCk--mnk?+%oW4D07O8qFq1Sor2R#+#jwz@nLECkiV+oa$2!wyUM#9q;r33b zsKN?>Y%Cgffl?-5((_|GJwsuu+7Xyen)=*u#Sc+trP9Ra%Eh$reqk6vKM#2p3UQ@p zAeJcfMoNR|t)*O3Cq+wz3rk}um7sBA8Krvt zzl!u{rbqbn3_fyes4UXAO3V(NIZ@Ii?D8<+qn85Ipdc;_;T-Q}oB{fDJPcx^Fvaqg zPjl1_Ne7piK!BvGsd@MCg!iBL>ylvN-aU$D=r5ta`MrBoYzW25<=lc?@)S#|qOhQ< zs4m-CrJq!|S0grQI2__L3I@pk(m&A1fE_CfF;Cni5BJwv%l-QqaJX61A7HpM%Z{#G zwquno-bYFRK0eRGdBK~ZxbD~m?^6cvF~Fj|Y@mVRvyTB5_)LNL&rb!$#lpqXT>Rxz z1?W=wQU$K@ruUlu{cI^ymJK5`sP)Kpe#*QB{{5R5RVJvQdgY%Wvfi|ks> z%JC75Pr~|1l4J0*0bb^DdG+F^oHPjD1DL4*ZzCu}vS0f0WJ`%V?o~tAf`v zZG@lcc(H6-5W})MFAT1q)^Mj*oF&)zKw>r}#*d@uB;P$9t2`CLA8F`-M7}JF4jzVIm438cEeW(_85UOFr`(lGA)CprU6QT*w z1vrDRuyRgW7#2_Ai4Uw}wSg&X2*Nbo;2c)9_b7aruvsd6cy;yuV4R)SOV=TD8?r68 zWF{nLQubyS8&N|AldbAYDdZ7?B`H-81xZ87YDo7k+}MQQ#1tT_<0J;cr?h{@hE{MY zGv7_~AM=);l}wQEdNP!`VR5mz3D__rg`EGZK)R_EVbq&~`@h}9ZVq;36em)U z$)6M2{mH=YeAOxuIStx$bD8eTR{&6H@#;&65q6;%&DI`Xo6;qT)&e8qM8kmO| z-vhTsRCDYNS)`4UbXZOk`tBav$QLpnHKuN4ibm>YOQc7%bID5>z!s60)@e9SBOsYw zl5`~lbUUC>flyD0e-Wid32=r(8V$qSh?QZHYfDRjGc?38P7QuyFw`-P^4`>JbtZBw z-8sIPfV)m6Gdqvi^?*JAJ6a~P-OK#PXesr?fdqDnPi>s+v-2aF zRUz&GeL#Z0s7!$P048^KT+waFO)*{o=)NDrchOPS^qKGWar@`W=-|qJtm+m;$l4cK!?yh zTU~_%N076*07ZR$*OBNm^WFbv$bSZ-tBZeT#s6DhT`R`_TVH*2C;z#X&-KbgP@?nt znV*eEq#aWVpcjDGgCIT`1H!vfpFBwhAEUhGNPK|0^!%se^d!tk6!bFbMSW!Rfeu;X zAP&>Or6aOAhSMbF9vm?dBQZ&d+Ln~4?JqytSYF*&UA;jm(cxmLA2P#H1OftJ*l3BJ#xuem? z-zL!EtV}R7V(%%vmu?PqU*w=; z9d#0uonN$6<`N#TRZO(UQp`?iVzY7|ZFMiYo9i1Q+?g>Rx6yTxuI*zkjMm3oDb~sE z&W@rjT~eE<;B_x+=r&Fd6W{@?q1M?Oy&J?uuW0&Lrt_#%4E4cs7htHY8`CHZTy+r+QSiAZHYtPhte^_whl?hcEHkip4 zV_MNs&JO$b^>Q5NkqzP}{-YJsoei;%%-&j|oTo!occUO$;o$5>cT^2xPmGKBua4aa zbWYQ;wbqKiyy7qV2Z((@>Bgam^y=9u0bb_t5Q*eNA(r+J{w}5dg^m5o{~v1SU;e>s z_~!*M)%fSR|E~+RwIfl*DL3+>zao$K(Yp#Bx8d1qCIB+-Sb5h#A>xJ;E{eIc-=YZ< z7NEP`Kayh+|7JA5JuAjSRUt~0oB$O@uPHn;2YATQ2Bte1#hSu~piX8*pTY*IvWQLb znQBt`QfF|vZ_y|)kZKxcBRFY7xsz-k?Ck9!jSqvNIB@mCteZy1a={td5NN4ZqymZ# zq8Lsu!A=e-rhT&s@3WTg?;?!E;+H(bupQWnQ8&Pt6*PDr2`r-W4#y)r=%W2ii#z4o z!{D3(S6~xZ6xnaC`_o}nT@O%j)n8t%M8QE4pIjURS8oUdSMMzEZ5@}@sNY0MNQ_GN4l&9}I_p|ry<(k#d)E!o}tt=G} zmMCvBmio#js&Uw7n+O%if>1e9T)@-y;*Kj6n7VDIZoVB#ZYSsLD@4vYHsWPBB_6o1 zN?QBUY~4yYZ5kMD!m4TW<}q&=(~raQ@u!sEp?zFQE9SI<&8yBTIha`8S2j4{EzONb zsv*LOKq9_#bVi%(?VToiA@NR4nftuT;;f8)v0x+*1G*|%#{S>D>+jH z3?ngUIu)Hnxy6pSWl7hB*Jm0T^9ZK_VIfD3W==)gvWJY@yRfH6X@X{`6y*q)A?bF< zDS~61p`I8GJ5y_V1%lObSCxofO`}hZX+>5br-wVQ-H=70HC#LdFxs~-dbq3#^e~To zR2X9b0P8gsM=_GLbsUBmq81JDQ#4wziI*mM)-qxNK`V}g66Ds@Y0ZyAgj6Qf5TG#{ zggL>rbOKeA>CZ$n%rv@(Ip7^-5^8Z&&Pe8|U* zQuLaq%*KTc%D**7rlt+k(aJn$Y{AOR+bQPCNolr|ShuRdNq5&h!1DO)ql^aV-WVqi5K)On*FSA4`z+CI zjQgJQ{b4IPe_6RNz`N!U)+;!nTm`2ac&Dg;*Z#g^^5TvAwqQ3?6QyjP_JpCJ7AaFd zTl@!&v9x?u-fM_Zxh;Pg0ig#tjIyD)Nm4zXVxzEJVr&(Pz2g|IM2l!y1YmK+O(tCE zS;vTb_f7{~qvbg2^>td=+E2AsOD+kR=u+7x13e_oe7m{QZnRo8zK6&M%|H`^Lv81B z)hQAW*8gv}K7vgue*b-`qNxu=T|{EF7j6qEm#Xg8ZGrDS#{p0|^nyI0w)UVcZ6by7 zcjA0nGpa2v3E&-!hj?p1E~CECUmyt@u1f8tJIEny6BuN>^WBu@*~VbNF{oIM(Ic_j ze<|R@FD94Mk0Q6rI1BDVkrhOSF!25*nqskS?nad}1{~#gRDK zO`N(qQDuonRcq-nC;B#y`1t%tcmQB3vM~HuufgCui%PQ* zUBj;haT1>olQBB3xT6@11O*GiTDYy=UumuM?k{2;0!`D*u(4^-Z%Em|tj+&UVKY7Z zKsn+E3udV}YGK91`3)3T09Ritpm)?fYIgHMKQ06;V61OFcz1v4{`>bIFx5R_PN6LJ z%8$qdG#V%_Lm6#$87$sCzX+M103`3@9s2jb>EGA%@BLOgqc3mi-&gc+t%)s|Nzmfa zJn4l@9H}`jlQxc$;C#fh&^Lf`Q`U+f*xzX)jZNmTV%Xye5Z#gNL3pXq91|KykIa{d z{jJPZ{S*?} z*f8NI9S;&Ond%USHnF3_>W;XQ;{S>r**zgn$*+O)tH02&he0e|!(8FYL-~0EB%54S zh9Orlxy}}>iS+0>V+)LCeXXG+l|&9%kHfcbbt$v-KGJ|_ZS0DUSY6k*c2IZNt5gKR zUD^;B+$Of~4%z=tAUcjTLUqybCXPx~v1J6@fm_EgUxjJ(CQoAprqOe!;T*8@Orcjj z1tTx@%OV7)lLnvB#x_e~fIQhWw`duSQ{5v&I+4l(y9A32JjAa!*sUh5_?GCL|F!U7 zp(%uZ3()#s3mN>zU@2Q)5Gy>YI)#a%c(Hhjj>M|`t8xaThJA#25^Y`Y`H?I$onA0e zATOL%HIvwNeD1BVVH*Ef6>3l^fhl^DcJF8YeZms{}}_h>n)Ns4Bq>$9t+|ZW8}YvHvX$i%j-++M}DWhvAVv|>D+iE zh*_aNr-ca>5S2WMq$;P6FT@5#I=2YSFS;9Xi7kF$7$g-=UE+cIr2wI};rcHl^*)U8 zW>T;H!izLgi&V3VOO{QlK*6Xd6<5oz{QfwasCfSAp){fYCN;`#P41+QOOu*ov`xRp zB9$8$w>wy?EVbJUCjrn3+Is15tkT(CJl4C<)ju=N|2Mna&tC3cv5y(&|JwS>YVrK< zz@xkK{}w)EV9|pUsY`MYF)GQ}w1xEQ@P3GylgC-uAET{xKxQKzAJSQiZ8WI-gD88T zod3ce8-M#bx?7`XYgr0 z9b!%89^dlz@{B!mVXTzj4|7c`|LH1lHCR+6h{KL{5bUb$r!D@a+&0y>F@c- z`iDJEGfv)6GAIRt7KQx>$I^0M@w?d=?DXmDN~xc?!nUW}uE`agwn8o{;6e;%ETLs;@& z(qeF902a)9&nZB}ghY-Rvh`(eFb)cg2gfiP1gR(SZ+|+3MIg=uSA$DMVb)|wbpc(D z344U~!>L5Ehh|Hf;`jl&9bS%e^e9JRGS;pJ6jTXD(}#(r z7&A3j5rq*EB5^|yKhR2fJbJB)L9&W{Oba4a%J^tmFe}+1dAde`P0Ggm8QWo-6(Jx{ z+Hq1zQaCgy@HUPL^U{YVJP`vT%L1=@r>| z8V#^Ii%Eac3ivNLg?N_9FqGSS#hTb#K1_u&4ETDX?-%e0w*{{R4-TN5v2ogSK}?TP zlxbRGmJw=dQ%@Qu_X!P?1=)YY+2Ez)*!R49RWADEm0$4D_dGk|9fdN&vfOZ8;wfMh zg^i^pWZ^Ls0eo#>jwD)AWw>Rjyu_AGO_|(K7>9VCp6SnyRb_`BYKqC9N=K?{ggpGv_g?!5)PWHCC`A0 z;{2!@p%R&&@*U*=Plj`R^9v5B{%@F(k$p|A|DV@jS`s$b?SC9_LjEe3k|F1v0)s=B0A2_wfAS z40c$1VKH9tGdP+6`EU|2maH;AZqwt~JQ}sKrZ1M_FW>I`1fYXirhj03wqwxGz-K9{ zV)NQK?YuFEswDBvkT|jkL5I+$wMhYG`sk1ccmR+I;xHL!uns(aXJVMVP1e)X16wR^ zw3h!jgc$}h9LG(L1;(d~9Iu6_``;~px4Z!u{Q0~EM0R7P-TBTZ@(7#<9Y%y}S^y%0 zr}GhAow2$Ku}|V|Z$US*BGiz0`?q)L9JS z$mrqOo#iRTsFO_{enuNuYcmjA#sTao=up!42<|vEy%~5T5ccC~4=lp?Gpn^?z{jq? zf8hTWrto8u0MQ?JKQ=v*bG2^eYChxsr5nl2E+U zA=7om05DU;yb2*Xn#=kv$NatioXaneZ4;qzPfNV7vyA!mPaem=hqDmGdtRG zA$&~EQIfBJVO|UCMJ^x#u-Z4WENC!lbmjOR0n%_syGqjEJ*l9__vQ3tA=Cpna61|IB}|E&K~D z;2)}2`*IV&4+w!ML@b`xIq3HYWQ@8K)y zEX<=yCx@SJr59MEIx%=AsC07H^iQLcQ+$9KcFBAd+TwCezq7Uug|P&@*Rg+)cJ3CP6g}A~wIm1kMkj8~>s6u;av_Nk+;g`8u({ zAY2d!gYyg+##=(TYy{UV+M)_RvQ`Xy7d|Uh@LAPW#LU66%8(*!2Ek;Zl|e)0TG6g9 z45!N)$P0{Sn4Ng{(CiSu6|4@Wa1G53-vb9&bH-RO{opKAG=TeX{!{#Q7UM$0jT=G- zj#z@)Lb#sZEDGc%5~gKNCR%sTYX)&W;$XfND%S_w-gP5 zo|BmoK=bcQ_^--A$2Bkj>o^XxZZHb#_)HTqO6G*?b5Fvc-Mc3qcVe1E=1+N2$D;^q zLfhmCS!*z zj8@S`H6D)#gSu`*Ts%n*LE~Yp$-H|N`NgPDqC;E?;4Wm*J>l-jRNxhWOtDwZ5^XgL zq04V=DUJ=6eH?Q}CX{i}TM9bfaAK=Q6ws8&a z3M{@B-+0LmTQb)l~X_CXDU z!cPNQbb*D+g-bdKE%=q}jZGW4)3t{dJ?2C@e8*>dUd5}qz1zui%)nIOY`CR=ZE4rt zr}&v7|9!Eyv-|4cs>VP6XAb+{N5%YaYioD$zi;PbB(b#U{vhgxaTa=+}*l3DLHMls3AXasJ|r(qf%pQG+PChnn+v02cgiehp%+4}b!EeA4GzZ~bB zy~q!|E_B6uMpRlR{rn8A4oJtUIL96^V%@RP-mvLJ9naO;fz$vFnRM@XZ4=`M^@=!7 zvq+*h^HHy1~aZjb6!qLW#qRqvt*65rhHc=n{hBU3w_;>)A(L_BN zG<`hI(XtXB5*(YTi(5)Chwos(*^0DIRgI1nh?LtD0GbPksNb_wj(O+lnUHKEjiF06 zCFx;O3F`45k{p(z@=$~u2_DmnILtU(v;@cOu&$ODc)qBs%ttV=iCI;71$fV9HViN_ z2=W4JIw^KfLefaWMUx`0FwGY9|I@C2u>bt<=j}JU{@#KA`py1d_MYuN^K07&@EZ>1 zpZ5-b+JAfKLy0%ruMYp_??3mqU;WMh^WLjxO@H^Vuixw*9QgZhyuFvNU+nF|v%Ob4 zFWx@ed-bFL6zaX&KlEShz1%y5Mi2LW>`Uhclx`3Zh*Kizw=clfua_k8d0 z6}I_&|Bb)xzutaxxVQ86#r7Nj_1ibE_YZcV`)APXtG!px-#{%YC(`|+nk|EK*I&vxPA(_I+Z_R|-;+!ah}=f(Ek z%clQq`{nkJyHsl*T6yDPF&>@&^H00@2>aWH|L+{`?Z3il?Ciffd;>q5Fv~ZGy6Vq+ z2fIyw`_0|~4Ap!7W*?eIa6*lJY6R-N+T~Ud)V{MKPy~O!J=is4dA7U#0@^yj%68$~ z(N5ldZu&Fj{MWx**&x13AG6N?we{lp|7ZpN+@1fo@Oc?^(*zG)|1S}RLOjUfOiX}k z55{!VKBt%p&)L22FJdJ6U2A#y8}D_R;Gt8m{rcV0o$q&cpMJOa-P6_W#diDI^5S>T z+U>>Vr)r*BLBb#zpk(EuI%i#R~NtgZuQyX>h|vT z;`h%x%Zu%`?d7Mt+t0t-S=;_n`^LK`Js+^mNL_wDg9|izOn2c_!oDyVioAk4yK&F0 z_KjyAU2-zy#M9)z_C(s9?{>d?3KiRrpo!J*o+0?>ueqLSx@OYOmbXM1CA3 z$H4%~@fX#!TF{*&CNtSUB5(MkG*s`P(!FQl@fZd6^cNqz2?rr7kL4Q=!D+qJn~bL1 z8O+4)ZN4RM(O_EJU5wYe)7QiM*UwSB(z$RuPsh=q*IK@GD*^{+Jo4<)ZJ9BZTbc`- z=77;f+L;Wa`C6F|Mi*;qGK^;8<1SimWzjL3HJ;|J!-gzB~VKC6a^2u}0GsS;OM&v4U z4%bA|;IW-?5T8(bEA;U=flDJ=8su!z9EZ^0-m8N{xGo(X?C<<}_wWerPH%R%{#aL! z5BFd5v&ItRVzI)Dy{CoZ@T64u<=)HPX>H?q?G~QUE*0dN6!!@Jk*`B~cC^#53Y zx&7zehX2R^vZ3;v1QV#)M602}0A_r+?@V@M%YX0Pqm-g(Bn#hBj4fZy!@l{N4f(r= zP3cK+J1iDf1tp^v|0145RWksAdiH?#c$}6+UeN6(Ddz~F#1YAG7-E zYZJV?kMo&!{+mn9)%uum{y$n^jQu%gxJ_@&LB1qVI_z-Wne^E_8YPFZ~0S39> z;+wOn`QzKYXImGzH~%?2KZ8?>M!3?!Mrts+dyiiaf*dW!GW=zJ;t%PVD%6&!^paEj zv2$CM7My2RGuExBMvwQ&De0N=vfQcx73DV+D1I3BP?1sf-syrtC~fYjbW#Uljt^-_ z_Z}Z6$$-AeSpKrJ^I|6%j)1_X_>L>z+aKl8F#0DoyH#73r*LT@eLyhSW8O{;DGDDwPS zkKos{{htpukKP`D;RQvA$3E$4qMr04asA7OZv3-cJLKT^1?`m>g7q zg&#!6QuId&s#~0&GkGzYe-;3U;C5a)tWi%jc`!acIM4EMXa=-5#Ff`;R;X%5bBHR% z{3Ux#1JRlSvX^_$Ud({%Yq-1<^mji2fMyj=!;6$f*w0h+O~{7c&NiN0{O9oaAWT0+ zT|nmK^SP`}GOOBOU%tS_nYTFf@(kF6H z^~XyNot#dc9r@62l|J7NC4MyzCHChc#YLLhxdcsJy*`?{{9B@_?Hi)06;x8r_3%yD z4^!aPuwnIXH%7~^o&A?^HGG~7n2Wn3uXp7266Ce;hjA>kCtJWQjHoKeM&!0DYVSh8}4K^eA?{xH!&Ep{746-5q_nGUwjWLGJ9tK9n zI2lm;*VX4ck5(Q%Z!hjV+Fn~+U3s*=xV^l-zS!Ab={$p*!PcTea5vBE_|Sw7RPL64sy56gEU#s-hNsg-K6<5fjfU7@Yzt*fBEKd6mO;{+2%>q-~7ku1pW)@pUpJPCNJjtqi5Ue z+fUaQpMST!ytvw3Mm_AK?Zxj_o<41N+S}XDmfMqt&8tyZ*VcRZKM*%QG?9iAsWUBv zjL8~xAB%p7ADbVKmnts5Pkw6(oeO@Z$bVk#{(L=s%#i=ISJq1QpY7E<`;S}s{CpbZ z3z`2aJS#-*34Gv67W>iXrSYhT&O51SVL8~w1OF{O?rr#Sa^|a`D294&s&c?}q{$~N zNJ;=fP8&F z=!TMHGLUv_JDh=T5e?io?9gLNpBK;0&K7YLi{o^_kwtqo6XYB}^`D~w9I8YA5Y9bd z9jk^^oT-^)_$eAlC>M^UC9P5{^C*VFq{%2HZ>cuWKb7g+m(*qe5GNRz>HK;0xzzI+ zB{-FI&pxn&97shH$8pdnPdSQkOcvoDy`pMpWD8_VzWOh**LW)MKZ2^j@bp2TiG zIG2v1*jIY90+?F<@0(2D*k=m;zn0ja_?bcfmphM&@jusA*Y4tf-pWVOd^gA!A;6>n zMn6aKUtc$M=pr(4=cq<4-+#@bIP6^SC(IPuAIB0Ii5(E`ERe6`GiCovfY+rf_rXfOwTb&5KIQno zYyZbzyN3DA{QNK9|8uN=x7RzqQVg(J_FwDEkBau+>#KM6U$^p^Ghh?4l@%eG@G(YT z65nx2Tp(X1NrC#+`CweLDR^nUX5#-U9P=LoCk`Y&J%8dq?nPO5G3sH6RpywVd{EhI zvR3#xqNop+zpX?_q)Z9#Ryad~#8*XcH0VM8BjW z-OqmL4traO_YW}?@WcBV{Qpm<;b4$#X$BCVnjdf+{E32CZ>`sy2yJet9_phhyRaz~ zpecL5>2pjF2}?oyhVP+SQ-v3zyDPcMrvoM`Dk?^2*+OZ9s0uE8SKKP?Tp>#w;Kjx` zraxRwZkfh|U6(@akD8wl|3^WTW)fz?+6B}}(xONi^{DADZ1@X+!0_dLywIpzTJn*% z`e*m}uSWmpIRAUWIja4-gE+q&8!$`$w_42q)MBUf(1}gm;bRJE43Ar_R*jl-A~kVf6fzc2?^I;2m4?UR%Q#jIzlAfrro058 zIha1a&2_SSq>T;D<}rNB?i*bG;<7K>rbQuAlhZ_{fxhnZrOYx0jYXey6jsy1D@j<84!Z z>(X4L{Z^*c0_}fvTckh8fHBVtQ61&s6lz{LCM285%+rFune)Pmr+1Gst!yFRj294~ z-uHxj(+j+DQUSQENU$lFfZuZljh8_vjzQ6w`s!JTbqn}2xa@@Q) zKR@3Yf$z#^gj+^&{%i0i8a36p@$HG#g07~@=(FbMAj(PA&*4~6=}3o4G@>JAW7Y{H zH-$pqZWLTRbj*FhyC>&EZ5OZ$`{t04T!O&|P^}&X2IN$yQJ&Nby<@CQTdKtUM5Bfg z34O)GXb$?1dRw#@y)pW~`lw9**YD#0-OA^B2_uG1-!b&RoC~}+9*#trAltFWsoF45 zcgzIs$_Ipvu$E}(w|qf(P&ybe{grbz+^aqq?%m+2kd@AaW7NJlq(6dhK*!+nF@d#xi2cD+$Hi5NheAgP!2IoJkn;XgwHyZX@{!bx?N+i?3eBAGEpeD2F zX+NI~*quXzMq!500iQl+A* zmFCBAC{#F$dim)V{mUg8GH#u$P^mkBqhhP@@E^%>@ewXY@fl$eo^>wh_&uVhF{xl( z{6qs7xzofla0*}5AogmAKtfqXw6zT}rFc|^a6VzPAJ#^fn z{I`k^GDa@VaBDDXkwg$mSvDw1E6aOuAKhTRPoD5(>!kV*8%?9DckXG@AdTXJEn4b- zohAX8)LhctqbV&ivrI8t)*q%(YF87{(**6p6%y+ii+%L#B59wNI(L&rN;i z;Qy}d2QZ8O>y-JwcIPhs&#ipO{=cW99^l0c1M_1Xe&C1X@-6pw@g?%?OzEd|%J=B9 zh2&lmzlJJ>ynPk-tq)McOeKKznV51q6S@eN5@u8RyoX`^6R8NCsogfkuQ!z`gTOJy z^tar@fRI_vUK#lrU^;7};=XuF*@@u&H{%#O_q=-xL@%ulfl0tFeR^R!Uhq6%l6z5~ zyrN-t7)?J0_MzpYryb_%rfxY~bWAmAz-Q55;2n!)SlGi9?c5!{RlpooK!$+>uath( zN*&%!l7W`K;4Gm%Y}xURqRa!>tH)UtjKkOq)Wf|N2KiZl39+>_zlls)Na@5mApm95 z9&*e8m@WE_P(FEVNDdk|1$R@jG>b)|UX@lo|ycyxNUp!3la zcYx63Nl7MlZC_jl-OjUTPfM`lmN1bVrn`fA2g=3JD&F#6QNpZXFgW*Mvi1=I#0diP}R6H_9Ra_}&CKWe1 z?n7YxX{#37T9Of>-6fKl@SIXHQl<_sfvGBVr`alh${_R4!ofgBo=5R{ly*zYj=9d# zE^M!lp?{nvL9dI+$IPJA?vVwTk)W?8+(d#X&+rW}NkJSY<7`0ak)I`=6jVv%Dfe|a zh|#)Ti@R`V>_RDtj~eBk$d@u+99l(HizY~eG2`Sot3DEva{+{E9vvbDFLCz~mnq~g z9AI(~eTm2X_StE2mia2PJ!RSrOOuBC9Omk?NFt)4M`&n4mnb2t>PPSoEW;47tUP-! zV5)l-#6Y#5X=!3qQpb+{7r4ZjJRmnDRg2Pc!6?0()(Kn7phEE7- z&ruS6Q&Q3VK{*N&BTOn9zm7vXXX`Jz6(pm^26i&At;N0(rOklGH6Te*jlL^2&Ntdb ztSbg$q(VZUAEDf|YwyCZ_nC+Oo0I->eaxW$Yb&d3Mf$(Ga;N{fmCv;jJtV>h z%xkI>K=?^b@n>3rwdU3GTWHBj{?*^Q6__ab+d|jdTFsBYI`XtbPut(MFK8InE|L7U ze%En)V(AGBrFk*hv()_UMnj5rW)F(D%o>UbfSoYGP3vpQdO zQ%LP@yf$hFa@RXf#&M7QI1w}SwIwe|8A$G4aRurnVTS#8jil%dZ+Msi5hqC3EV#eJ zg=LW76`8D0BD~6<26$bg>tn!56@0}vD7-hu;Ta8t+zzum9d|LXh4C+j_wd?r2u|@n zM>&=p4Nw+ZN+FeUH_V4&9&i$1_|f!#Jvu^N-DjP9nRFB}E)qP_3LGlS`Wx4OQRV%n zA-tm!AIc88bfYE>5;r}uJszvm*p{t(f_iQRJ7G3_Z(4rKL(Ek<#~c`33JPxT#mRE1 z%K4RsjrzS}AxYDmjP$g4oaKp0hgkIAN>5hVuiZD4#-3@El?9=jcl4Ivnv6jZ5<9hiK`{Sy19G_g=rWtKr-;v1tV0)!=OIusMqJXF-b)Qva zk~hFnhD%z9i)Jz&rdb6@T`RWAq?D?0Z)$`|?-9eHS>$!7(gFDcgI?2+eO8$nm^i*EldUb3I=hF}7|)AHjxi0|%>vF-fCfVRb|IvJ@{pMV zs(Z9YV3Q;izu4L(Y7`~Ub-Q(`^>10N$#hD6xPtM((RZwgwTg6!x-LE>TWM=$Unz+& z5sh=nNrZ^>hd=xQyJMfAd-tlS+}Ad){vCX#-T&$%Uqp511!+xnQo4x4%6IrTmo`QQcDckc%9Qyox4~U*gX>Ej(^{HE+N~1*ndxILMaDOM-;|<; zuQ9XCHB#ss$}Dr^6#93agyxP^-;wIOG&D%J1A*7Yv(6lk(eU(Q^{zSbP52pQoENVL zd;BuBl8e{Ta*m5vO-5|Qcj1aG;k$UfygRx?B^DQ7yyCcbiQdi%z~s_p_Ntn}k~%io zn8Ej$Gt00pVUG_>eQ?Y0%Y5HmE~dL&Om`pinI`{DyH}6>kDrUj|6f~KU%rd~e;c0} z>u*?*EA%l#{=c$XA^%^yv;Vr4&(edf>-s!+?>+DpukWY8fslnStH^^a^H1Sa3DWNA zIl2c#qw#<(bRJliU^$%gAEVrR08brjFN27#vDfm_@*{tFbz^mTW6d@8dVh^GTk^gY z*@^#HT%}K+IM3h|!bj#=O^^7r=6Tl*=H1WiW~WVKvTL62(t~R=l%oOfpb~y zqcGkD=)xox??a5#-^-xjOaA7cohDgGAqg@}Ad%)={OE|>q{K3fo#h6k3@2DBd$86u z!xI5z018u}88|@25d3kL``uI6^AG4fM+$&KFOJgi#D9P&s$fq~p&?_!hApUCjZJ^) zfj`WB=o?GJ4{=OVCT>)RJckCD*iQhc%HzOBsdumFF$xYbso7zNEm$Vy812X=C zh89;!bFZAao;c1i7!33}kdvH^wWHcQ32+SX8)B>Z(t8jzXB-YtJX(Cihgqmo|@woqPrSoA^1qiAC z0gIm4Rub_590lQCt4B_mTA<4sbWE*gg@Sh$OX zlyHy-Gz8^MeH^0OgX5n`sMkbi33a?fOOitg&+@Yv36o< z0AI*$WbTS({@o!XUw$h{Mcd>nB9(P0Uvl>wfWP45VeCTOB?Vvp_vsJk)&HDcp^q8< z|Em@8|5n!4?({#m@%c9D$Gx!cZ@>NP-iy8MH%C8t-}cZ9G_)W6Hnl{49fPf@Aj5-m zk{+^QWscG;4v%H3vCbiDkalU?dLbeLlGCGb6n-ULwCL?IBMT*s1QQ6NT^E|7!)8kL zKoQby=?Q}lGPxyc8=tE%(nwwV++HTp6?xDYLg!P|6Xl7LQ3hz)3QcU#jC@~tp&M-j zRFF48ucsd=QHXwtUclHe4=+(?LZ(_p%1P0A<5{N#I?}S3g{z)O%lhE4fCF{iemHQn zJYyl`2q-wr5yg-X92_tLcSN4SAUWe1BrzIdqM!X^2HlfiA5+;UUt0c4#sFvtmq75` zf%!iYeT*%FtsNtDc6@{n2d5WAlMO3R8;phhm3CS~zr8P3V1;YI#eBaUjD; zBI(%+*D3(oAie?^4pk{+@GVRKF;v2FNZ|yr$*xZ(;%b3i2W!W^k~0_LHATt z2PSYRj!T14v;|xTT2iVI+ExZ(5es|45}eiz4dVD92#=~hvFbQZuwKR)TegPsasQ0TiR!g8hTo@AIPXt8$Cl$x_O<7 zzhYxom5`Piyz~We^BToV)ooo)7Ex+zUQT%a=B{vC+q{f8b#orA&nDn6W=ZIyCd@D& zs1f_xT+)B;X9oYT49c(6$8`R`v$D3bQsn=am+#^~-pc2?Ir}|~9%M zJnoT;R-we_Gx}24M~7+W(bqEhntqs?r!w4|u=m>INY_>(9ty;bOx|@{eq|Uqt4q{7 z4ZEMx;H*A6;;H$hgU+IVhDSNY@C|!%-aqB{4~~I~7aG9eAcYoYRS5=z3)J9pc&rsF z*@qbk_4U{vbdzzMn`Y>Qly)dKOXZ9Um9TFNe^Q2!-LcazwO~d8wXr=9Ek7a(%M3gx zMNv-^GHOz{^Ot+C^tBwm*FQJ?^M+rqe{T4X{W^U8!T;=Uz%w~PO~viMnu^}Yn3ba7+Hb)|(Vp*)iC5>}gmhP?jZVgeEi*cb5`Ms>BGe z-U#qn)wCD2+B{ayy7gHU(}K5a;uHT z>%Gzl#uxj{DXuKgU#6_u*kOXP(*PyFv?Xxu|HuOYB5oc z%|^e|QLAlNz&P+zim#F`)@W(DeNxUBx~k()9@4{yb`9)+$~!%AX?XOos`YlM^|ssK z6ZM?t?>3E(N=AM+zaYnp3~wR6h%wR6PC1`WI0#1ML@`cDFg^;|I~c{+l&c7t3!y@67hSNspMH8- z&v;|Po`f+9cU`an(3>19CZn6Ac{=*$t&u&|<9w9Qp;panBZT(7@wh|;%VclFn_tl* zi|7IUs?}V=2Y3}}=2_;>stJx00N3^KbDokCs~>&#m9Imcb49VvGl{zZn>e7DqEPTt zl#DS3b&Bl*vSi~yo;55ad_fQ-78-{2r(=7jL9eHV{HNn4wZgYeGh$g5QW1`V9K{Nm zO-24tJnK7-MT`S111RTks680eto@3uj+A%Ag9ZOjfAU8d!5n`M78GsNq5>k0dRqA5 zkf2jq37l3?dY~Ke-By$h9g$QV?lO;9nY1hD2xRPO0PIf4h6a`r=!el59-pI&R~>Hf zWr|B5;N6lEaEE*Sl4k@KpSTvDijxT zrkX)~PPob0+VFgY4vs@W-jE7Nwm5rsm_?9uj0ufH$?@R3$*u;_$uRvp$FpTEzGUVr zxbM6mvdcT6?jXiBonJ)em0eiH@m6vEq#-$=QKi)>C*AC^-<@ukJ#z4L!(d;SVG%Z< z#(6Zvh|f9vz921bMZvsjc#c;HGc4|Hyir7 zbz;*9k?_*xS5siR^H8lObpmG>4xs64h7CX5;lnL!aBSHAK<=wlz!KZhEtB z8}g6{2v;ZY0yl-RSJcf+;SSu+ZcR#SobTW#gt&wqg2Z z%#P5zHJqENo12bgf=-i>r-UvpI$aWZt_LB$IQ%n@f9J*i!S1t$LI-EE#1GyQCE~Ps zoNijo=mLM|jsM~~CDBFmzJFi}VS4`JIU6;?dsI3?8E6U3+&B{u4%k@Y*=b|h7B0%V zLE1x|9-7!04*zB`Z?+=&im2xv$98Io!Z2A^BUHP(Iy&pzPgY~g*pU=I&J zd^?LyV!VA}6ovQcLT2BW6oM97N*5aHI+EjT)CQm;);MLX4xG9s>)|XZxxoVL(BY-O}r~XE1taIa>XFye+ zb2qhD51`{r+e;U@2HH&4O$F17%Pl73=W4s5O>G*)8D-@h1m`!k^Dbf*QK_eL&rR$0 zL;+>@kquH%gXX}-BSP}@B4r*EGh;e7+>EL1IA9vn_4yK{Wa77Yh|?* z|8f1%qepl4pSST*hGMvtA2Gx1?h+EMqwETP zfKq!Bk4EvQWbla`fRODNB7x5+vc2C0Zi>BrfJ)=7%g+YMnd^k5Q;TMD3Y%fNv!NVn zOOjI!IOnd)d##+CnkbOXLf`^`$>xUi^u@7ckCPo{zPi}8d<8k+_<&J=px^k%VK*3O zp(XT>6Um7REu97D$Yl%zas{HWD~3nHF>$j*)XtLephwqEXp}UwmSc@T0f!U~Xkw_R z6P9alY2Ocy;eHiJhE+nP9wnknTBnwOjXE=i6b@cRe<2=EJNBp;)~5!tt%(N0>}}KT zd~E|^>j_TTwiwp)A>&}h5RfGXvJ}JsS|Ukx#IZ=ys)4GNG#OZSdQc0^fN>M^LqC_3 z|45G7UNT13McL};xMNG`b(SW1j+t}W{|W}vPd3<%kW#`&=>8#Ww2}^@W17}rZBjct z0e*uE&A&AtC=Cb~QHrkz4eagvy);6!8>2LX)j}HiO#_DC*mN7HK&pyH?#UeJ&~B1C zWK*@k4sC$V%so(g`G9WBIF|&$o8We#eS&QfH$}H7wOk)m06r`V!|=0_A_+1ERr!lv zrA@tj>WTkgq~A@q7Tvs@S>@)1ZIsG2=1}jKE6rncST(o{)~eLRIPOJ!z}llJrCnrGae`n`R>p zvuZ2Y*80+NXQ{L7ciJ26&c^B^;K9>0JP8KEtvMdeCdT&EP~1~}wai0nM97iZ@-8@| z$lbico0S8`SdtVwT%-M*?LuLA-P5$rF0>1+g@W<3Hajtqf0T$CO-9QWla@6aw~5^> z`W2CED?^T|my-Ls_^LV<5{ooUDe|Nzqt=IQOK3A~zF(YKyK|ToCbeR`U)<%&{*#x> z1iD=FCZz$m~h4S_Qt$gRM7*hwjMj zn5fQ(D}tp8cD{JK{bKJaW-48sQ?i_y^Q_O=LaB9<#V@iWB2521)XfZeL1P5EuBDntQb4=n`M6|(v0Old#)vSJRF;J#6&(VEUi6w#ZY zPzQ?l5Tl-R+2>`tG7}&o~XGcO)}SqV*FFC2D1bTfv!H%TKj@ z3&J*B;MDrs7m>TqSNUA>{(m8b;EenK^4iLJ>HfdAdUyZ7jn56<|CcHS0IaL|ZvOi} z>nC^iU%uWxJo@Q|*=zlo!e?)4Esc0Tg)uT{);N@;`FB86FS-Ar?EHPq$p5#xvi_*J z{~xvQ;=kU?XK~S6T(tK;{kkUkAGEdI?ItPdzEqXVRYG+z)~oq&nbq^{S`*%xFyoyGQ>GbbNyR|m&0x|iYlwh* z79cKEoSLsGWEtuNLQ3LtmZTpgxgt>XxEG{7xe-QTW}%3>?QRvXzl<>M!&Wam9-ly2 z`dfU-IIQ=Zz8r#Zu zwIg2aZ$I08R)WG@o3S-YLo7b$rqso^N)5Q1^vy1gs$9%dqe5{WhYCl}E9m`V^{RHiRcl%Y2bAK*WZNiG@{Zd0;N4^5 z>(`NH*0E3ny$foL5;a9Sfm*0Z-Ov0XIbwt`3tfzd1ievE0Gbhw+NUOASnvM6`QagK z$zI~!yVuo&?&64Rt(J2biAWm?3LFU8T6lUv4SWtu*5`oH_wL>6Z;%U-U&lB1#D=vC z-+_nq_#b(QVp>=Rt%C6IrCOYl=$M2tk--bWu=4WIi}Xk#MO{YkK$ZpCm5_yz){cXo zNhS7e8<~y&CzN3UW3kXiRrz(AXaMZr&l)v8>bUVnu}g)J+%4fcRH*&G0(LG~%gKcr z8epo4cZ@7HxR4i8KwSE?&!U98P!QkmP1CHE;W6{%~GcQ6Sj<6{4{~yU7(Cg zh+2R5_tu98jn?8Hk&xbR%W{keJ! zP5gTcW6VT(?fPh$Y*M9>`+vL=P=O91ml;g6BBz&9!iQfAXK&LwarF0{rnAaT|BJ&! zzBwqjtxq{p;lk*UleE03RIzGeq7X((5#gKFl0$SbA{$qoaCB=}RUF-9zppwc>vg&; zTWt~#W>_mJS+};L*@gxmtSwbse0#Yyb0upI%dJ)#&8vZh9|+9UPuvs=e07RRr=X89 zo`jg<6J6@)$CkP_)uHbyvaKH966Ho(A$O8@()9YG`pHiB+G z4h9&himrAo_yYClFFg2FjT5$_R7gYI;?%XZqyVIp)6yVlD*A=DGIrg#>6+@7E0tkh z(QuxQL-znFEwAE+iKH{ps<^lD9kUK(r(eX;eq(FP;ARbXPT+GKFHSPUlpS~@op7Sx zXtipMnj!SKf&1{RRa1|Wk3eRD^vhWTm;|T6LcO)vxZhepHM)0??Y@$aHYFejLQXMA zqdl`uaNyXsK3t#hhXQZyr5!d*zplRg|Ixd(X6$uHQr+7R)Y#SWSRWmcj&Xw#% z$-M%(P!uu?Lv$}!OW~3axdW?0b>2f7s1%|_hzLK|%jVMK3KCN2zs}3=k`Y``cNtN3 ziQI-I#k58xt3ZVWoKk@nBCDv?q|ypl_`Rhv9+9ZUzR4ljhHgftBDIy*h8nb5Ej@TL z=&2-rOewP}e4t9!{y6&45HAbyvLab@B($(M%H}My2x7%%j};No-L{TiZNJ<#gO%S~ zsy%u5QYzCABcx@nQ3I<+Y$NfEHMJxnx%TTFGEC9OcHcg+0k`C|?)!Brr5LBLt#2=X-y7eWTspSZ&{iJEw6qxOfg2nZa%6fN9-a5}1=gat!<+_628f(f_bq5Y0E! z^C{(|rLcE2r4Sr#6jpaikzR5Hhs|kK9~PS) z$C=KTrj(GuQxO+3stBe@ZYpgS{`lg3*}VP`C5P#`-v?ejNpC2e2x)-M(qL4Xprq1J zw;V*YeKo^+%iyz9wzqFP-XN2)rkG$nPgKG>YNX0{Lyr?5h@~X4e|2r6sf%Oe00||G z|1Z4G#7f&u1Ws@*hJ6(y<8r?6WhcOFRfyFhASUe%WuiYJzl>jKX3Cbf@W4#bj;Ze$ zkRz0}QLEaM_`(cyis`Fb)>}#w@tQaE&2BFQ?>L^gzYGK&tMsXH^ozmsr+R@+ialJh z$$weUm7BA)m|~o6H?i5xw-*bM}J2=(kzt^78GA!#BH!xG6CV+OiEkY(wDx zLi@S-9m|(U;)P%5ww!jB7Jy^pzk%m1?EuUPb#uwD_-LM-{K__~#Od>i%Es@@jRMK~ zy#!kNjeh34|J`W(r_TENTIv3`(z(0;-Nr}RSMUCHXZQ7?6#_~>xc-EI>S`#lY^tt? z7&9A~5FCF!X~_kcK4S4e*l7 zVm6(39YZnY9Cs-|*)5u;QDTo^NHOQ6mu}Ld_*I9eVTJ?IH@p*6?!okF0#Tm>vgScX z@zHfJ)M;jCKt~~1FAO-@LSSEmvQvuiWLfkCs94D)>WwH&A4qn9GgQ7r#8~%CCJB!5 zld2$zGU;KMWvCsg!*{CPz?me2L2`zJgsxg}u=riHSHoyJ<8C+1I1(0Rgpw2mJPz(Y z%2=Kl4VoA?3f}Uvi|0}=!7LR+3J7LquP2`PahRF8ONcKWVycE$J^fZ9eQ61<_`;UP z#B=ASSZiCOKvBLs}@Ng@KN6Je||n)*JD{4B~s!X5@*MloDvHuRJOCP@e|oXtov zqsGNlYLehtKc;0q4o`zm&{X&tSXV%sLG&>c+|~t6HyK7%B-Mo5R4)lL1S|%JIN6w%cYD44s2Kloef=)~_pN-cjkm`SYQvtJV^SygAzQ~FJ{hCsJ=;FI$9;=j zMaKDQl5Y6VXve(*Qg)1woeeAaNc(klRa`|@mfEZS^7k9ds~hb#XTx6a?5?>vnA@|k zJHYtXqI09@lS2ZX;&!@hy?&kjvewaJ&jLgM^qh3=6F=A|@Y~A&HQM{`HV(qS9 z57{tFYV&H_wdsj2Fir>Mw=H<8OXQ=90{KY4ALMbnV;7+Z@LF60Rh2%~x&Ebm&CxsA zaS)ii>t3}*oqY*;S7tRbm4_>5Mu7%^mhhQB9^nxgSh*s+!@ZZg`)>~cM(fMi95DI; z24K)z6+i!_;OG4}=pInh zegBvKhJI(Y8(7vCzyS^LT0n$t`}N+9Y(}y_Aj2MGW$^14|BGj=2#6oR)xpr?dgf;{SAk3*41lRy4GYa9dHsiyn}*p zFAg!(>}YUaS_NzeZ)m^PIxVznUs-8?X(;h9RzzDPc*sU5N_0DUEI8(x89MC|p*dDG znCdaqX$(>ffn-Z)XD)dqdKQNEsdiz&ID^toOsGRf8d|^Kd)T=DZ04VuRXu>)7Lbaj z-vcomTm>a~b}0Y?hv`!xOAqkl(j{?m~OTGa>{wZ4|tdSv;a zl2KE=cE8tB|Az%NgKik_f1-k0(A9&^+PeP`I>GdWUvR(Vz+) zrth(t6s?YxXg8LjqIwi7tZ3v8UDd2Y7@*Q3jjK2C2QDfaU)77Kucud}M#s3|*u}C{ zWnz~C!D&5l+37S|!B(()AnulEZ&&9t5|-E50LY`#D<4>rL1PKt+X$W-cTRFtt`|`& zYu@iQ39o2wr%h}{Io8ygwV7KPx<;f-Pb$fA<=&l(kWd6?{3ow!mr(>Ip$7VBG8@9F ztT+NJ!&0l7KGL0}nm)H8PU4uFM~t8;|6YLP@-M#3R5bvlDD4!Q#S;67XPKSAEC#Mm zpG3~~lirY>#NY1esFxo4P;FD{6%6;RZAyu>SOe0l%&$2kd*0FyEQe?0QO9wZb%Rk@ zcQAsgkUJ;<4Rb=*{{C+1{reAWpQw)@(~EX)v3o}8nTx(MP(3R38+*Zc;x#p2eCnW73 z8eMGuuL@nVDED6aceLteLa-(+&Zko z0fL1_*d*~fkZoHv&K2I}qYn&G=BH*5D-C4(xPuuMrsZNiu7Wi%_*Jjb!McbS$wkZx zQEM6sp%Kh%_Q61sG->1~$*_y~)-s{ZfUF^{eN!+&uZY>hHZ#MUfzZ5R&}>U0n+(Ic?3Fjg>!(D@W!iJ*|G>aQ+TX5UZq4z7UH;Qr4EJ{3` z5mB-KF+(zTvI*SX0 zVgNWSIF$+PtSw)J1!V6b_-9u4SVkQ2W(;8YLIXHS!%#^sE|06%vaWND_m^>0EgQ0d zg@tO@%&gnErpO+lo0+1GlX_MaH`A&cY2}?0M=RZm&)0RzG2yiODLOg5QCX>xg~D9Z zsE4j{3M`~7aPPZgKs+SHWXuA~ zJkFTe8p{YU_qB(1!KD#1ZPnpF899DK?|(HR^Tv|m;=|Tyf(eUi!zjy8tcpMJ+FUD2 zY)MXR)u69@7pAYa(75mH*uIGHsF=v{sInu>L%&;mN`BUafPE%B`l&&`zAfHz*pxos zSIu<$_Gaum8>GaQa7#)NfzqIR5}l{ERBL+oGT4>m-_M$ZFQr9bj2JtTb60R~@Mhdp zJvB-T1Lu--C4IpHouz2YBF`5vzLl?w!S~uit)iKE7I#D%g4*8^#9Q@NmckY0JcZ{=ygnF7=VMc;~wp6}v-HPhe>_h4u6X0o3Df?V~FT;ZNP%xz{QVosx zj-Nbl3x&3-BfGvsEA&Vd(P)&Z1}1bxt75K>-)yR3-dGEV4=+YFtQz!{sRn(WO*N<( zQw^?Mq#E?JL^br&2~?x6FB@i(4y{nSAop-9A``;T+3y0v36$X1FB;A*xu6PG!4Hnd zrp}(i(x^qnBB*=o26jK%L7r5jgw+Fm z6~!a9G!rGL7^4JNc2I&DDfiyvjF5g6Za}Eop+ZW?6+7(^H)aYnY^0ijGqCAS!f7G9;N$SnF!WU+2C0!O#qR24{fi+iVUEfg!GP{6n zNRG1@FNZE?5oa+9vz!dDwtw7xb!d*oqrdFFIoR8Obprs!ex>%9JUp=yi^!z&;8KDx)HecTG9+S1=R z_AR~>ofJC^U>n>dHO9gJut&`ZYbFHW*~|v%aqyv~c~HFp5hSrKK=T;L??-ALHE$fq z6-%=ciJt$P;hqh?zTu)MnN z_R}cOwKfa}sF@GZ8D#|fFjVucIdU2a_a|dOhlNz4wH4+Uho5-`{5sELNMZ1gF%8!M z(9FsTrB|nVdFEXr>723JM->nEBu*i^3@=U<6z^xXlGI8q0{?}(x5g@a{F6t1k_Se*=a#p^y498FCAu7;=EV)t|$e++xI4~{CiOr!)36*iq3s+c>VXE&ogqX|>! zHOrTceH|4{6Q`gr0myHY``86Hd10x)4Mf;SJ-VH5`x_s(IttRf z2yh%iqf{5~@YEfvFPs%BO&32ZB)RU*DS?Dw!t?-00IMchGoZl$kkB+^lOuI5x)e%% zmTAPy9sfJp=%|!xT8mn_Q7lBUyCUU5ZTWrrKF0rQ zWxR2AY|)7CuT)7hB?A<6VMh&j45c2aIXH=ASa>#Z_Y>Fdda1wTkAN5LukMf_I;N64 zf{9Bk_ewH;p$msF^OgfBaKdaG!xtD^ee7ywq)D_Z(I)T>N4<19!Dj&*>Xtngq(K#5 z28je4%$?5iN;oZhC6Hxau5W7MnxpP6Vv}{s6Paw%stPEh3BDV9v)qFczc@k;Et6>Hc+96Vi$|nus-}>Nql5eaU*2v^5gDd&1%ijMk^(H zm$#PmF~i3Iiz+HyasMI}APs|Mz8n&=sN_`@ZKfG(MzoxilCT-%KST1& z>3s@f8bKHf3lg$L=_zb=Ex$WP!GHnzkPSTCV@X|56?^{8inL zVK`bua#E`{T$pSeWLpgm$y9__q@itv<}hPp%Sze+t_2erTo#R2x`tV)GIW`I>*e-< z%cK2rzxUvN3;yxz_j~xiM!|kWcj|JR*bPk%+nQ^3YP(doUgT^TdUG{gKwo2^#Rw^8 zo%qKfE^5!>F)ZNRSSu_&;Z2G6o`_#XeV#6;tVS2Zm}71LE+XANMKic@6=KVwRP$YV z98rIT=WJ-6bCiD!Q4;0nH5bRr`$IxL&pRWxx#M&7X8tW>+wj?&r77UG++!SbyLk;ZId&(`Qh`5-;*poeY@aFpRmmD~6=W+8NL5n0=1B27M@ld}XFzfxcj*Z}MTo0yOw zt+YGe>HS=+MuXv6JT7$c zQZt`CLq(3w94+y_5@T7^5e1qK2D~HB%0-gx(by6L23M8jF8WxZXk|7%tg`-04)RXwjN+0AhldHD%Md@ zw4q;&1%bPWH2-(CfK-OjKLb5x=QdY+8e~zIxjVm(%BR-x`fA_pI6~^EVT=z8n}rJK)F28uP)Ub0B&#rz!^*hGxLmS^ z;+sdl;QWB-2AR>}Ph&|(YP1SdI!0KzM7Rh``-w)xdym}zEwqiXw8B0thRbX=qIzuX z?_8Bh_<1ylx)DbSOJYE+%&ZL5o3R!MdLDvUc-ls`vEHq=$-n*7|8Ch_2Mm>stsSq) zECHRZ;pDUzt29%(;TXsft1%pnbDT(o17ai#C@hnjByWIN;1n51MhGZ#V8za=1a#8S zkjTpxXH#)xS#9%doXOjSxX^r$+ZRN)l!;b@S{LS$JF6unFQbFC(xQu^N2FmdO4*a? z7nDE{S5qbPmS-(&h4I#v7uizWVp;U=%vhi+im^gvMpZQyEJInu8l`gDD}A|*OJsg_ z%4PN8Z|>9fPee<+UROQ;X?OdXC6j^=uC!?}RzuBnZR^ove{F&hoq*hM{|4#}hiDha zQj~$(TTKC>v%KoUWOZh(CtH4dd0Cu1F>X6rfK06A-pkRuDoM{UOKgwKE@-J0*;E9r ziQgD777Lsg&`u$WD>KP}WED`dX)cwj2kX$LKr5mD=J}4F1?QQ#a0*hree(kMKgLMG zbXCV$G63?x(a*AE7}~9{GeAZJj@CTG>?s_fP!(fq4y3lKEsNml30XG+C5)g_a{qSj z3;G@29gJW_?{$0YTaNf8wykN7Z3`>6WS6}`fbyi$n&H*{>2Ol{AbRkEYnkz z0Rmy}e#8ibfq#lY*v<^-<;*Hkkgf6~I@bBSjdD|Qp>VybK1$Cp(OEJQ6+Zkzoy{2r zy@T&(L7X?0zZ>b2r4ZT@Q8*UM6BkNToIPwHvhTaq$ROQA5b2w^gmMH?_PDXC zXf{E%hQpGc8VR2>x~5Y{|H6y5Ut}|*lNbfaXcGW4SVW0H6r)W7M_1%guw8(nnmAL~ z^=3ctHD3{((}^N4cdMRO3y-X^QBX#VwwlOpk!ViL=>vN~kvG|MoQ!xlKBn#B4VAh9 z@-v#o@nu2zd{Zzfs-}f~ye)|bF~KI)ViY)nxQZpvcj##=R}AZ+>~#xNzqtELFd}4< zZAcmhfCV}N7YA(4Q)|qP;;1U6Zn2@bHYzzIIjs`Xw5L*|;=!+|0lH&MFqPMu0yjL1 z95bbpVv;qz4#0Bk&fi|H2_7B|x3IxxM=;`72&1=bMc}b339-tP*CbtbgAramXw{cK zFP@#9E#h5v5hhDwMJ3@g6VjtnoRMF9y?=06a~8^uxlm>p3Xa__g`VbnFm^X%=r8@4i01Fii4^Bsu zdpyC@wz^A95%%oW!Nu}}`8Av_#{Mcmz*ot?u!Q!&E0$9)tkTv93&pKBx;Q67v2%)D z-wJbT2IQ@Q?KZpidXeZR^3+6Rx|7{px*A%QayWL+&DSGrD6CJd7iTpqe^FJMw3+#B zCZjgp!RFM&p>FLE$@!E0mM+~Ws$YyZsR&Z$|JFQR(kqO_v>#RNcz>tui z>&QhfykA~02w=Cyu7en>*MID$X`CM!Y+l;$qcuveHW?B4EGze8+Oz16RbM5*q=mh9 z{tFo|77_jq*e-M_#yo3$r5}Z1dK0*)kr3g6D2N@EP_XHbj?_Rhg^#k4@j33@qbR0P zZfc{AK^PzL$dBMFnX3}tgHIX`rs_@~jDV8W54MR}!lzCCgAH5}c~u_;P*sv_m9&K3*hPcu`2BmCQB@}|#I7k@+xc?$@nBaUANfoPaT45EiF3eh7MhjhOV z4pG6T{JjP&QoURSi)bttLL*aSCLUcMRjU+%{niQR>mbWQ<|8$)Xfu>~LZ<+kBCvDf z&1HALgsjaz>K{A^22qeX+@a>09#|Jt+<{Fs-Cnh1M89S()Xt$i0oggq)uh*@%R^D3 zqWYWMK{T4&e2u2A-lOrIa0c`ob?D49;;%59A`C*}K&9+0&szQZgVKxYJs4R#w0gMG zQn^^Aj7fc>hYvS-Lhz-a()=xrO^AbS2fs^(S&RMb>6XPh(8;Y}(qxYH#jD4{rSmx4%|+j2&hTL7eZg*uR| zlq4Dxj5v!}nh&RNJ3L=Q#bHVK$1ofM2G{?@1z-`h%#fcn^hFqd z5o6E~h7skFko7AS5ZmI@9Hv7lTA+=4xZ`19-QmapyY>JhJzF_|pv)htB%oH~yps#$ zVX{P{s#w+0ramUx#AH#Zk$>0&FUmpOZBPpw!Xm$Yb?|z3Miv;l0Q(j7HRh#bZG_NPfrL}{6}kW3u&pDzEw zTimiCFEKxreW0tOw;#8`Xeu=bd9rR0_v<*2+Wm1${r^5jnD|ow{~g1BUHGpD|HT&i zq-c(~?EmXu*y$EZQjEqN%XCNn!!18H6=1T(GIY)GpZJ}%HEihEeC?XAJ^or%7eQrF z4VoQv8t}EifBbmM|8BGN`gr>5?)29^i(hS z{paZw`y+$2AFbTkf8NFi4ux2s3P1VYx9|fUbky&!Zy$PyN2`QHj)s7( zLvr;+{U-?p#GBI&&XM%-RI&Skb{MyT4X$$Zh99Nh;81U z=%>1?Id7cP`oW1`Ms>S+DSh3hcOBgAre09~i`QJCgMde0n^ND*XV&?jT-p0$_W9pg zFXn$(Z?CN0o&UG-x&HHgG|rdy$C%X!-PH3m;6$hMxql?${2_=u0&XH9(vBYE_z(WT6rdP`_Y?kL zr(gQF$y)3O-Tbq#BH{$qKj!ZME16!gaodHQx(~Hv461pOc$z2LfCRa z32b@#Oi=6~2{_W6I++yBh-f3>q#^8akFKDs;q zZ{wry|NBQjnHvuN`0AX2eevgk6>q;JZ8w#}&m#&9qXJGq8x-%8G)IHrJWM&12T;Ud zNYZN@Q9>i)J2%|b1H6z^!J`~5I&bsf=0FwPS+@aj?& z2o&_A7y@%$sSCGE)QBS{cg5m~F+)S@<=s*16qT!&U2-cG-njF zu-I;vs^eICKHiy44L<&`LZ_)ZB%zd%Lt((CV-&OS(TJ7rLCv?X{`_kH=T}&DMf^Bz zq)ud_66eK;mY_Py2XMREhkX5ka77KjPJ`22k%k2gj^bE+&Lv|KihhVwk{K!Q4f_L? z49u}$qhhesNYxmzMI0LzxYE$<$zodUCRd`^GnfTCkv%6-f5!fO#%Hf)FB!ox9dUFnZUa|ph-ElUpn(l5=;MaBZRmiTR;5fOO zb!pl(UCGVBL98z{y-hu5{N+Cw(X;Ejt!>V{rEEGvxP2DE-7){y{+Yr5bEKs!CV-vJ z|F<7KD#`yIEw9}1|F`nFHpv5iC_&BPt9Hj<^q)tA+)8XADFQe%8V04$u9*B)Vy1RSpP6KJVp7#&4px<9Rb_bf`n22}4^GEv!|xpL4Zh)` z^EaGrXL%j;NFayTq`dd$xKe>NuQW*#k>Gs(@?+(yU2m^gD+OJKlQ2yPbl65H7^oi*U zF%u!jeV|Bf=x~(gSisGGu9MDF>MP^oC6WA0tXTL?O`~T{a#p8KRNgMrm({eYtfSmx zKWqWK;}zo*E;@$hl|(GC(O2BqpSccc=46F)~oe^p4Wp+MpcFTwHzoXJ0iUY8klfo348qEx#QTP!%q4=mwsj{RXv68GQ;PBsv0-<7^ z(nI`EzxeONawQt6Gz}%njTY14Rdq56D3ofdHWM_JfVKz5e-|s}Z1?W2vprx3lGQy~ zYd_EWsFusiQkf@_iqe*6Ub-gqg!>?YS1=l-$taCbi5^FTio|(UnFy_Ye9dI=fRBnB zBC^WkDfTH>marnl@TPViEfY7q5SO_k=a!VEN1DtTx~_xE0x>6>UKTWFG#p%?a^u>7 zxsn8x$gIjHS*Eo#ZyZFQvIg_Ci{0V7I*{AmAZ+5TPIru%yXbK-2J58p;K#}cibkhY ze*+`=*7YGiE5oByvJ&e#6)LxiMo}xIr~^)(7}1DvOzaJuEoi4hu&Fg1z^S$C2XR-S z3yUWLk*H1rCcTaN=XJO>mCs)Na54;w8C8#x6#XSpk(qX_a`1~amZ|_sw9~HbE>N8~ zQ(=qLGZ3^O$F(Z9y+$cvAtynBy(lw{M_Dmb3r>=}LNA3@5`_`7G@!v0{QsfGuEll% zzmQ%6t<(jI*vF0j+vN9{NQ-R{*(n8PAs`crN;sw=vblth6JW_DX5dpP4)YAYrGy>M zJQbLkgF+vyPdYO5O#E`ubUJ3Kw@z{H6_`YvVJ<9YIkl>WW)Wb_5W+B;e!miA#HaOb zz+w92qbP3j7nBN8ZXCq~nnZw<1E(K`lrqkGr>O5_Bo=t-4oX0`4(tU*aWXzt{;<&W zJ7oyqXDWj!BesTI&6DWqi^EQ71*N^Y^JMEr8I=9H^e{0=@?@}B1*MV6Wr|>&$@eUj z2ZW!Aye)n#)}XTP1cpqFA1C?m>5QmGw2(4y*XDtT{y|Mw4Z<3`8p!4N@3|M&6r90$ zo2kqw=|IQXhNYQITf%8LQmaiuipdN6zXOA>2cxE6D=e1P=9^*4y>S;FOAP)DFB6>}Fli37~(GN-UXoh?CL6g4m-<{Xu9 zGsSRuGfo61-B`Uqxr;1dB}sPg>l05`DLOaho-vyV%XZE8wF49u-soMB5G*3-0eWS5 zl7^XL@HyI!S@}|O3Z#6wm4r_2k^WYJ-72KBcUP>M%W>92XR5NHuJEbp=aa50IIqHG z1s)YA(T&6z-sf8)vz(n>)^4qsHrojx$oB66eEfYm#gU`;_o6hwkar z>U>MqSm`hx@am|@e7J~kWH7<4qv@xk7I7D`M41>Zq*EsEM+!yMZsgfw%setYqR9r< zR0GLaKF&}$6>vs*HSNOuDH*y<-_BTHB`nYoDrBm6bJSOFBKLHZ$_2nz?3Q^sxQVAj zdpfUO(Erb}|4`4a;s!Ru{`=AT>RQqMV{N5#Xa8{{{H*#jXn4vI!=T1oSdrz%)pKZETDJ4PgwyI zc4ZE;Ecz4$3B9bU=zd{8821VffC9i~6>o-XV+CiX z0lT@(0Fo4d5>if104Alz@gNC$Q_3OtRUJOzx}o)wOxM^D(RRkYzFst#*vMI@6B{Ny zJDZrs%v#e|UkL;%-EGdiNzFu*x^)HrmDXX7I23 z7_b>0!@urh#%XxNU!0f4TxGLztJM&ZYGUkf;g;^~NRSB2I9TQOC?7jX+V!n09RnXR z7K+~w&(IQSOfFhqVV5a~XXFWn=xgC*Z-K{l>J}`87mPw^ZGTbKT~uM3jRl|o1mmdv zKwmd>zOn0@Cc^S9Eg-W@!r9$8D62@30JDxB3Jw2-iSLimN?AX{){&YHLd^b+p<1#LIWCcK(S%!q?z7`A7#*^Sc=~P{jqQ%1TN8)47ZPb1NU^|8MZ#gaNRh{g&lK-#cQW2~r4ldhe{x^b@+_`~0;N z$enSTqGU+rQ4;znC)IVw5H6vHa>#*C%`9q%y>iOMclKZZ?akhgKOI8xon&;LMklAa zU*Boqx~wkZ;@GQO)x`GO!=Luw98ix=(d&-^PZ21BZi-?>7{+HggF+R|3D1a|x^Qapn#R{b|{_Bw9D7QOn<4cK?hpBd*rGQB9~yiy-C&i|Fw z<>iw9@7mhk`F|UqZ+Z85-}*1$R*Vv>esnVCuqWQPo;tl+ttEa1`%TyQ3HBz(QHc`@ zbwJs2PT`nFpPTdi6i@QwkW~((yNN?+(`rG<;;>MBqI4sSgt*zUv~219r~iGhvE{$_ z?wK<^!JkTMOFu+fOW&h}|7rm+{YplxvEU-HZlycoFDSUBFCrnP?;^bA0=o0*Ga16T z)FfW+z1)=<|Sr{UfEWBtW5tnlL5^B3Dc9yI*L#Q)=e6^nVM z#SPW^tOl$?P@P~P)ipe(RksRRpnnl%q(|(9aMbj|xEqBTK-j=>LyKoyUGw$SQ&8V9 zF`tySfWj>KTA|=6WZDo>E)-Q72#=9af+Tk(RN8tIEpx% z9kwQ-hhlZ}9xkEoWQya`1L4?HK50CBrRMM$$v0>lK+p8&)YIs=;j6DUNcF?X^T&ai zu6a=%iQO(J|#M$;a%>m711 zadYp+J>1)hk0~8+U;F(1+MikcAMM^N_A#CRTkou_td{aWtl#B-xRuX!%XM%|8tKi< z@Pps=qzt^R&FUcA^Dh|KJmV~F@|~1$L9^irGA#g3%P$5 z#AG~`r)XmxX5C;EQgE)Io3o`6ngQk4ZM&g@jOqLV6c6m}&ZetCr>8q_UOXp#aqWHj zKCV?2+5I0=XiG}ne8OqV*rIjK@UirDhyX{T!8}W+SzOp9kJne{EIE$nFZ;{9-H+qB zi~cg2e^y~Kn6qRr$xHGgDJl^Lu>{uYHq{gIGiRy`>u-0U z#QG|LFvvnvNZNxpaHmLmA(n$~urx)UH9f+g86BFoMnO-KSzNK9UU=z2Ibir@WT5cN zs5=NSH3U@jQe5WpstH7Mq%DEwqBu4pTS`(vN6GIbT1xP8WnK1&#!2 zUphX0LklL_&-gV!|KJ*?WHUV*B9mCII*ph5~DTqhQk{60l1_N$=_!!|2DK_Wt|NFJ8XdfBipi4i4Y` z<>$Zt?f(YHUEoMgPNRQ(91P=R^h=uM<4?U`WKL!qFJWloZO9FN$tN{>LD z!20yHPF^xcQH+Ysq!evTt{rQCr0wk{lKai$Z8xQu`@!JcKTgBoBYA)_4v=RxsxZXc zLLPSmbjbY_(gj5-wVQu_QnWuteKGdKRpSND za1fTFX;WQ}QbBQ@;SDu+|=2u{uu@3%d zD7ugj%;xMgg^BnRc35hFK(oc!Bm9RnD0@J-R_>6Xbu*xqrvGT&Y+k#ZKhVp9Wu^oh;ibd;1L#{wISAm|I*cgxMH7<-V`Nb*Ll|q@ zEMn6H*2fBEE9e&@yJZK6$r3Q;##xjBdwa&oA<2Q)YM6`>Ra0>^a4ZS+a}6lzykuR_T+fe5z$JDHZmwr2=#GcZnH%sRjYS7_U;My1=~} z1dEF^=WhC;h8{k&Gh9oT*=ZVP0Gzsu8C3|^&j3h3x4+$kv2!D4-p?s*0`tIpu>~SN zx+xMnO;q7~CDT>gP&GoV>8!1Zm8#)$qYq3!8}zoSp1;0Ys--yb=!34V>}7SCg{_4T zOyO?;@Y~(-a6F*65`5rAu_CZcgU4|m4g3}BIJI)}qCFTU0>TF9h+NUFz^N^F8qDoW zo<+e3mB}V=2C@WiBz6VHF)5zCFcekrM$q7b!YJ25zaXm6SOfLmVflv-anZV)#&>`Y z>Mei8COOz6^!#r1gW14Z@{3jv{-uqlro18#mdv0Qu3a-9#G zwy+0Aw}MkqsLG}PFXAsJlXQsH{DvDOVw&$s@8I;mIY8ns1-Y-C~ci(SPg2T z>91Ne*X635Fp|vM+`v}cjX8}I?jzYc#J03CxaQ~`+;R8FKLx=2*g)C zs8{Das8u-%8}s`)sOM68%tKc2T6hvCDTcBJyoq{7wVT-&O2dYAKlo38g=@Iy0F|pg z^q~u3WrG}mY&EJ_fz<*lz{PuT-Wt?HK9mO7oXiSr+3cd)+s=MnFIM^2R;fz+;#E2q zud?#tgT1eK!X3^1*3I_s_Z#;1|E^rEeYtAOx*8R8uIxEVI=i@g0K4&wr9;-bu`{x4 z$^Dr|zJ*6k!~X$J>J9aL#eUv_=PR29yqrdqWTZ{*ZK87_W`9Ey<6)xG&&fc)6yn_7 z5XWN41_$RzH3pH(zfhLYK3hv*tWuvCZLw)qQbZOEK4n5)-)Z{Kv_KG>V&1%`#m`A! zgmLLfnC0Sxf=_q+R?B}Tc}mf|rWbvRvIr&A$LIb^3%Wqz4_1az2T@F>*hIi|ZMc48 zT)SkPKhR@sNjB0j$Rg~KZMe^p@t}uEdeFYx1W~2t^Rq-HvL<@!Nn@dO&aB!o(C#xt zHncVgFj!BI2M_EXN{G3K-Wb7(&0{MRkcK0PorOBp-wpaiPqmy7S_+g4DV!!-LX0ED zL}S!hho8QP;IXX*kI_7m$H5|07q`zoM5@!n%XG-Y`&kLeC)%7S%FxRTcp;f#l z&fz;U$y6^R!_!?WaGRU$1Ca$aX{BUAij7`G3T!V1i&!(DS(wKRX9Qc9VzO08J*$Ch zjTo;DQwFJlGf|4Ad#OLbwaF7R{>65q(YUUa)Y4tOrW9S!0)tx1i70v_%Q&Bm&stS| z>{yN7hS1MFJ~+bioX3ZXc6f^i$m$gikXs?o73OLM0=;@ipnr1&T5dGAN1!iEn}1`} zw&{@DG|VQf&((?UMV97wLv%})TAHS2-BX~(Pz2q%>+Ju;8hq4$ho1pTsMrUVck8cz zMJM|gZ(iUl)TUBq=OG$O^J^}#vI6UpCgYP+e|?#Q-C+z$)y!xBG!%-hcXY9KXMJ+H z?}?dS={V1u{x}{WHi(j5l*FvbZAxlxYh;=i?}=4`dKV`oV&q(tvHxhDLzZJGD1;6I z0z*G0eO4qdvXU6L(3ZSAOca}sdkPN*+GWZMGz(S8O@I|#5lAZYbAnWcWOcAH&oHR% zSx80Ubi;^2O^z)II~Oy7;>37KF#p4Fh^OE69xm4&zzJ?Ix&KQM>nv#t>59loC&WYd zHQZ{FA?!HZ+<0b_Dv*?E3RQ1VD>&P7ccy;O@2sthqEA^Vl5$X+6c%c&tcY51eR)DP zvPmq|TJK0L*fO)LsaFf{^96Y;#*8AC&;|VB`$GLxz2A8=d-k?&RI5exd>Q3vGNK%Ua?EA(xX-T(HcD}^}J4x*X@#z=+Ptl(RcLdyJF?<>GAh=$!#9C zGnGI+D^!2V&z(6QS3KL{XQhdE)pP6FGk)ekqohJP%2TWnbv*-M*1iQX|egntT zJ|%>dAnwZ721q-}rjdN#gQ%vBPFnaj_y z?2V`sls>^G#jHaR&M+IJ4&fN{IH6G;5b0hR3^?xtoMS_ji|xnV&@SJUjGijizM7OA z&fO#h>Q2UZ!<#bhxM8n`>56`m`70nHA7ufTWqoWIDNL%cqQr7OagC9b&QcR~CDt!m zETMTW1q?c7_G0G^^FPEUWZ^I45ZB0(VAE`o;UFSjZ68G=0$N_7?I;#i$^(*jzmFFt zT2#5_QVKH|))nSX_;JPE_D3Y#YR@X@sL-wz?NykF*`O14i?}V40MJ#R(y%l0qRj{a zm&rK8F1wbTa+si2KL+Jao|(p2&)YWC$CJp;Q#4Q+QehlYFz-Z__>kA ztt5|XK=ZAz0FzglcAm4O!Qd=7&nB%Tb8F>=yc*IuLyD2Ztr%EgL=$ZpuLz=otsra0 zjK1F>kTDH11PU-$nIqnU{`;AI_W1oM4jkfo!)M7wJ=a_t?Fsh;+WX8Zn@xxt*QNPn z8)z8%#_xAjkWmp?zi7daIfN!`W_BgMjiA4-U>Htj*d)2-b^u$Yc%d{h;9o{0 z0@lO_9q{R!BBms(;N3RP_-dYpqX80s=gh?H72}vPPi(iYEKtS_8!Wa^)kRJWBz%0F zvk${>Tfkg&Tm~e!u{<#1QbsX%#x$kS;*Wh=AtZyOtF|+b`08D*l=x5Cts1=a!8E_5xZ^~k$l;2OSL)QO{n@p zV$Ar2HwR_`_6Kq&6zZgSd7#}_HmvKFpLafdD0QW;eL<`&6PrK?Nf#l*sF+_D7`OHs zhSllOH^akCGBFcOS}EKSCf~cD5441C05SUi+4~m2xT-SY^xcG4TR{*|Z>J=gNhgz; zByAySOVcK8gJ}|yl=2QYGdIblGjoTzcajDuwtxsei=ZOD3WDO|D#)(S6^o*v{;RN{ zvOYmsMO|G)SJvPC@ju^p&bjxTd+$7w&ZGr0N;-4zd3@(P-}%mWzVkg2u1a3K zmcAlwDr6382T2gwDq(n@m4TnD$muQaA-k z-3XsD$4YQ-NO1Z&Yzsf{{avNQC=`xUFwGbRdHder)3q2!p``+G6g&jLKYJDbah5%l z0(|&k!P}=e{@ARJf0l;-vWz6L9kvKGrBl(pCSkNG7pLj|ad8&6CE$>Hf|N_ZMwHMK z=v4`uA!cJ}pm>NVyPzR6N0=Fr;u_HN5w{$sOs1~Z?D&&{K23-zqb3b7JT$V92pf}2 zlYT~~$VQ&f0YhNNPD(()B(yUR6YwrhGx!LElMo7n_DlB98awQb(6y;(YJ8k}5J5~= zY$B^@R-D#0(varc0llVyRm23|XgUaoH)V$!SNaCS>|cfKvghp}KX*cw1%Rg$UaFu8 zB8{pbuMlQALQaTNR9>WxXU2#b&r!5akij{*uj5>Rh_iG|jw*y$aE{3&Xv4ZN8-to=)X)^9+Cw>VSz1os^UZ2N`s7SW> zT`}g;I$E7|_4Np}jUp}++ac(#fkL};*J!Ir*tKOTijvJ#M?w`OuyE|ExwM)Z(Z_OR zF(juVO1)7pG>;dV6g!l~NNWc*F3Ds>lH>^sV-;sfY2t}XESS&6tvyPC1ifxA74NMc zmyk<7uZxvu>Ef`66zLn*tf&N?M+)}tx>4ulbj9C-2YNbn0xNV5^yJmy-7h)Nlcr`v zWEfI+!%3Ri?BmXdsfJM#KZ^GITB5?2J=2Q0UC0iVb54H#hz|K~7LKjWuZ{^#bHJOAU_)-`kae`e*wv&>>Z>g|esTI9dW z9Tj>DoT9}fL3vXH(d4@rJsfz_gbp{kPD%vGSf3)a3;R@l=Xp5CgNy@*8`VPRM#unW zKqy??#0Iu*QJSNzYa&WF9?8*4k{mCP@X3k*uSz{WPSpVb1KIY*^)XNgB((_*SR^^J zkAguZ8qw$ujA~N1rr-$Wo9Bq;qmI3D^HJj@&rUXKF`7E;0s-thCg-5WLNiW3O(V{~ zx-w7mDElrXc=Jt9Cmg?&v6*q1xn#{p>{H7APhK2WA4T^6)-`L^dGbFu&*gufl~39D z27GE78(j$i*`+&#_)4njv79=lMW9qi&KfteZ6dFQ$6MTcvx%EC;mfUO!F%sE3R|>0 zVPLZoJ+rN)rLFlaX(KJ~P|MsL8C<6pPr{WAlX*aFArcOtQOZnQ-hOF*X)x3zhqK{r z?03>i$C}B5tae3CCmcM04+0_f8Za-urHLB}tG7$&hWK7L>=#VsEWD&oNC7%-+8X%@ zD4|vnVLP@Y_yT6t4A~0DjI3^rr&uPG8d?xe+gI(ap{3amD9^q^i}9?6H(*Xu5~hzH zHw=?L*OPc_Go_?eGE5eIX-uDh913VLNJnDVr&WXaE+n2pd5Iu26ozcNG5p)?=oZN~ z2)K_x`amoeQm)ycaGb!}NlV%vcS~eo0j4GjgoU?`AwfFfr~@e6qz=M*5sr_n&_G&G z1}+g{0t;MJ;HMQWn>Dh*KrX#IZA_+>-P)8A41jqeg_|2`QP|1jKqvsFwz4GyM@Ue> zfejk`3;)6NFhRriJi_=_I3e~NUsO+H=c8x7jbaJ$NUafCFA|@M6RH|n+Zt8^gsiY9 zyD7IdsN5)_NUd1IS7e~wusvR^1WLcah@K{*Zy4 zEwvCMKIa7^#t@Fhd5j|qd6@xfMbR!G4Fs0ducR&sbVM~a(EP0y*)9J!lSgy% z|15mUuis0h;QAlwMo^BGmI2%*H)V=~hrV5syfN{sD3t&I@s(A0D} znwn-Cf&mjoNotr-le}O$G?&?vEN?ZL#B3{Bg9sgfSGLl}iIAHtyX_jE%9Lh}!+g@t zJhMt3LosQB`DL(pA&Und(F#Yn%?-8Fi3k6Xk<0m6Dnd>)vW*Dor*R`TR96S`Xgrm1 z&Uf^U;3h|&aZ^&fy2Uau*^;FK0GBeyE^1vP#vDPZZZt?Hqx@j ztY_ywxAQj`Ug6P=UR9G;q$n6nT(RMSVgzZ-=7h*wG{b0C%bDozK!toYk;uZ`urM`P z0-onzYkVr4KE-8@9fy^{zMkR1zAbO+8iMb`16?}@yE-~M2gtlIm=d~4fdYZBR~;Jz zC5f#F5J0lxnc*~%EtBfhVFK0N-#^ed)Hgh|r9Z5YKf}F!on1X07ciiBhr2Z`LuAeg zt-LsRQ&(4iM^E>8U9RpDM%v06IjhXwb@ufR4fO3C>Y`M@dmG6bY9g+h1(@kfdfPnE z*U`D9V{l0BP0tLc$eBln4u_M5QD8@z)(m#{!}sAGJ9~z@q1WM_zP^6BYjU_COQv{# zWYOp1=m-P>RFitU;`@;q35^6QT5&)>x{1%x!Y;(DQeeyG3%3PrqVN$k1CM%kb_@>< zb!_hG3b`yIgapJ!T1-7WrddKa?QReRjDeq>J9US^M+i6pR$8ey()Hv(q$Lw@DW$~; zW3v0yBgtVSZH$7dDVQ5J#|ht}ZZDQ0_m+1AmY&iGiBDq~jzLHXqhM}c^{ktMBViNm z9g5UryALhqA^o22-fdk2f(u_=Qm3YH#%M69hYG9+%Ssj}P?kogpbJ(D-S1=~g^G+s zXE+cPnAk|jckfWhPBC1HxahyQg_{2Bo9r0FJGypk?iv`}-reu%Jwe14-hBmn?;Pms z_jF%wnX!YNH!3DGmQ%i$StgKjR=Wa-(~oH$Nsft248)jea2(k`xd_K$7a#R@NBMXT zGx5``Vbx-?uFDlVjO#3-r?SI#YeoC#slP-3^bD8i@@J|K*k|}kW5(_%A7=QV?Sc^# z_zAG)ae}I3u)7x|#^H|M3j~mujP8raKtq5qtvcz7rDWXOV3dw~VTfMb`?FlOqUf3^ z#%S5ntvQ?{u+Pa?@Z2FSLIb4nU_*ZJur}0G*2|Gzi&?4)bm#P>jH=}5Ws`w`E6H}% zYZ>a=m181~4qxHm*=@Ndi0-w5pwkkP*`3VjpkU!`cUm+sJ^f#a`rpGc0WD_#*|Mh9 zqyKG*&gp+=w6?jmBbg`~Pfw%DuM_ zBEdMW8EB+Y+T|~&HEPe{G3vR>ym%+~F>^x&SM%OM*2TOPH@{PmyE?Bq^^s!3Y%hgTjRbB?71 z=JCBC+pc3GfZ08$gAT}pG%1KPtEkH$k|ox-2u#c9iT5f-y@9aY*i$HI$zOj=|v~=7Nv**BUNW> z>cM!m^fqj`yZ5|~p6*VLVm3sqOEHZGuFk$gD`!200gJ4{MkRW-5{*RL6png|_+fOv zud`BQcM-75-+~=0ZX!^mF!*2=!nP#_wlEV}bfBPw!D)<^UL9jFvkG<`1iL>_6hnP7 z1c)u=3`kT3JNsvk-Ja6{BUSuM>wC1nyy~QHRZ8(fOc-$+?V(NQeK{$=bO(|}V{<;p z4IBJb-1#rFg(h31CJQ!#Hwp!ss06$AnibBz{K&9k7ePXnmtEewD{L;`y;WngK(5?~ z0PZE&t(A8+Ce&n3uFBs+^eMKeW5O#8n^@2~fwEe-s^Q4Dkn0k2$Q^2+^qkFGBX_>z zPBxN-CMOPgRnPbgD-fzJm_QK!X%lVKL$As!o?yY`m&tGb-Alt;z1kzV%#558GBV&p zmdci%0iUIEShU6u1rDuMT+`v*-P!R2@(1GdMB5cy*K8q>AKoN_1RdRjBJU_=cDSmg za5-OgFqVI@`%R!9JJ{>Sa#1ahdyj#90_sSfvy7VeEaSJs9PZjIxce9HKrB)EvQYgI zU%ZiJN{l{QePuG?q z!TiI1aAa?Yy43hM7)wDFA#kvgQB9W56mE|xnK~C9ET1)vmIQVsaB*xT*j68+F}>Kn z#uGi6@vNS)Kyzn!Iv_3N2%56VDX>&@^%hY&(kw(c_7Y|?LWpcd<3=vYH&B4X%H~jW zK(l+0<4uAvAO+KT;Fbs9po<_2kAacPScphS%Z-sABYE%6sI|&E3})37UE35}t3+dM z(dM@3x=LEB6jVJ+0iQTk&4qkAN5Tiar5=7K*J>(@W{ zQ``VUJ&*x}C{6amQX)CAC{Zc~OmU(_k>B=9!xUc`rqe8?2eDavVi&M7-j@+8W51t4 z>?$Gn6l)L2i^iZTC%(x%_h*f>m}=T8_mq+@_yrxTI?_#ALn)}tg3XwN%m{vfnive8w`v#!Z z<~8`n0ApL)8u@p7S5F_>=>kE+e@?II1oQ!Qx<`2mK@_qSRoSwwn;bKg zFsBDH8+6J-QnVbt+IH)iU@TmuLl&DS5BNY#L7m z@$aJAQ9dmGP;&221sYeP)GjRq@A`Dm~hj` zW#gLAU%ql0^ahd7A~gJ2xrR&lxD_lm%5!&i50$UWcoHI2`Lvd?UlppJG{*FFkg&*X z7>}8gMmAAw01$c@=%uG`TX*l_%olGFV>XVgZACaj&b>DaB&nLKy8dq$bL@~@z6!t#siJHh7*RE%67Osh`)#c6TS)Gc_}GMUd#@D zr;qZ;c%!6)AZdwE3IKl5r5C3!SPUPXrh`_ZkHU1duxNH6u%*G5xO>QSjOraKF@{n43$uu- z;&Ma@oeSnK?TR!+ z{f)WAF~41*CuLHwHMTG zuia5QSRZmI2TqxhEMeV7Di{qbXTb+FvCvgWVi&_4fuyTRH4A4GID=DtG#`^w4C_sy zV>;+E#x*qoc_kq#zY19{VIApKy{U|*kiBnxLn2eW z@v`KYWsdnRNU{LO)d|9{b6K03Xi75R=4`M6jz-`<*h@|ffowuHDA-+u|0amMir&ky zCl}STEFq1+$T4JUzBi<9y*-Skl)gtx)X%V~NW`A8`gVJ?8v;0GFfy3IKs{R@`Dlgj zbQ!`HQ-FB3FVP{xOhx!Bc`I_yyHABs-oiX!u}DZ963EV~AVrv3238Nx0Bf@chn$s^ zXDhV9kZ9T$fW}4|cRJzFx4?>pl^RU>gNpgMB(O^8r?C;93BB0^&*(&M%K1$Je^v4n z@Cv0*foswFELFBG_^nKKW-GQVRYj!XiZ3;1eL$4sCKMan(OsEr^cw=YX*8aB=9;q_ zV|NyWTN3M%Hi%gLcx{1m4ly4(XTyq zgfQ8>0yQe|4Ub-6wrMIp-`S@2oUf+YrpPF~=$wtuB}ln;G0syQ^vUM{frGiu0R^@} zMi}{<;XsHjd6zAci+7S;CnJlgKJ6XVMI~zD@|9}S_l#Zlngi*B&TAYTozDFT)s0FGglkDjz7NdEg zn$jX-6e`kC5MaQ_HDI!>k2_Qf@(w38y%86yg@k7ok zle#sIUFimCnnK`b1IW6g@iU@FDt<-)psYYxi+(mUikZ>k`lufFl2F-)Gzv>&cvp9C zOS3RQdtw7Mt57HJyvm8MXmZSQ<6&rA<7OR5W@;RC*FsbW_CU1_K^Ud#SyEdzyEWbgF{)aMNVj0UO1kEa#xbB5=D%fmZ<*=Rs7>f%pb1i& zND~@b*O~x?K01Z%@px=#+?%7BhEfrwV$>-_V}W28%fm->OD6bjxdEbbS3 zOeH?{9GzL%i-bn7XiNp=cwAx$b3A7yjLCG+6K-?dm;|?1p&JlCEkiCT#HVQf38rO7M!Jxsnr_%J8PfjrWz7M}nWgA0h#yB{<1 z^xlxSdl_Gvl{V5NM7rM%=lueR)vP?F#PLk3I#|SekZ(>F!U78iU^{K49bd5QXu@=U zO-jEs{AHuWJxr0H*ma=<*L3Dgq8oO&^$e08gqVXBS@rZA21|+?NqNX4aP?g>I4%H^ zx@l=XBtD{&ipH4S6J_6WVdsY`cI;4BDP$xr71kHn#*r0DgB1e|puKGOE9p}T*e7N5 zz(F&F4WW~Ufm~dWSrm1I)K=qykcW_S0ZR66;3Z_ngD1~&Ed0VtyVPYZt!7t~KFHGz ziaQShFhmMajDZV@X^l)_U`VkoH?83uvrP)Bz=qJ!FrJY|Ww(dX(0$tTZ9w$cVCR52 zkBwL4r?m6`;dy`*IsdO)*Wx+#zyV69#fF zt#|4D`g?X9p36o)&kUaVTXvzSi1&mY^-uLCK`C!%PIhl5in3%4-0Cf9|4zaKNnKCI z&+m}A6 ze*O5OLmFDq4g}kO*L@cb0z?sxWiB9>9lJOdCy;c&j>R1aqiH~>018}CPIvHfW9(=k z4Rpqcq-KlEUNIyf_LZHY9>Md?Q=d0Y{b6OPFDIV?k4ef`=@l*2ZJT;}H$CHk&Ifol zIac)y^~RdZ-#xoDwgbR|w$9WOny{1G?`kNJ7BvO{DB0JV%{}CtFxY(|cuqA(ThFYa zZ!Zd$T?yo%f~u=Hd!ynqmoJBYRS>CU?dch2%iz9PpW(Vp&V2&85Td>s$Y5`(k0_rX>K$mEgX9U z%&diBACea|g4XVpjd#JoDi5;qVl`F@8ae+0BziGRi#aLmu>@hiY_VJv7@2A$r}Z%+ zOL=Ai(}Qa9XIj9nuUDN7yvXfJx)%Hn^CyFj;IE zdAW@*^|^`0p&E(r_>&SZEwCS2FjP{=sUrFxB3d72@{g)w`k&^tYuCBsf2?h3UNfiv znT=1`Z>P8P^Keb2W&J=3qftC!vz%qiC*_ASgPb2+7m+VbmtYx@c0aMxj7bSY2ufx< zF-YZd$g(i?>=G`2Y7orr#MKK$im_93ky2DAQn(C?h(*efZ4@4v#oH>a+!)Pli8nIE zi)J*KwBkkWoAe^(_|{sa7`uinHea|;7RQTE!Y==U>?*AUycEnc!<#E!$TuSmUTwxR zoRiVGZl+&q6jDmcj50ht77v8^&hFrd=SCp~xH1BY*(pQ$L%STsKW|Ey61xPDx2r37 zWWUFL?E*fau*JrTi0jWTLIZ$HZQvuj0FAIN6~ISg0Zzezu!pF{Vth>q#rPws7%VZ` zqqI8hGN!kT=`KSVh=g7G$S%Q_iHIEbNa)Bj0q{r!#ElzM!i~K!u#mh~#6oTax@XDs zB2S_OXI()@uBGObVhlvY8++u8Tp(z2^&ipU>Wiz5s;juNpwe)dlow^o0f0(@(%&Z zy%8W;qU0uS=&Hn%5M0ybNsnzNnARro6-}BE&s>#4SL(f>l#gdv=-vFKY1Fw=OH(%r zxwH#JWh`stGF~_d;WgtcA3*V^nx5Jla6{m&sk={ry?nhjl^~chE|LMphSJFfC5S&luFT{4 zR)s4$1|8F|(;MdSA#8Lbc@uJH9LO&_RuV4WVR6v>h4f0oX7^YeIRBGDWhXQ*aFtsn z^4?$Z1>$?Es3{exGE+q^>cOZ_&f%UgO)*T7iptxHV3mc*<{?yPhw1nntIC5Gd5(T`+7)q&Q0r@}K@TQc63Zj~kGpU~siv$kTHpRRS&|Lu>3BcfnY=9G*qNR=8 z*tp_PK$RJ+Jt$9Fryg3{!9ug|j$6VRwY<|JBv)F=xQK3QsSN4WVIKZdR6cTaC0n$e zn87cK1r%oIan-T_IJg&g0-W+#@T3(UWs2z`E4ya=6eZH^Flb6+?v8NB=SVa!2D=Dv zox zv12{c9+{L0NkQ0cOLyOJC-~e8*GLpE@nqT(u)E>?ouY}V5WFu1W3Oc?NkTisQdZ+NxS zCG+%rhh#pzZZm%v%?3r-fSgI-Np^B+Qy)u{1CBWk;s(kbq3U2QInTU<(-iFh8q}N2c!%EO>f!uNx=sb+Q1WO(v!oynXsE? zp@t+zGx$WV;dpfl3l@?|`bfg1uia@%OGOv6d`2qDiM;2MBSegYESB#cnL5j2VzN4G2umbLjTg7wO%dr_q%YkwRb=g8(m6X9z)&tc(f@nk`V0yuT+)%W_dR~y3W=|vO zZvazPJueD@p8k5gTHcaPc`65<-JcJ5m78)RUeDIOm%j~ASrKZV6I?yoC`D1f5_g~O zYuTgx26T%ZnaX>BtsEf~Fd1ZI;G^LzaI~ZCFx@5uG#DNn8tCfS;T-2!t|>z4MjS(E zD&`a!Z^}olxso2g9L*M~Zr2mgBPbR9h;|z4PB5;~AcwYzVM-L$bcu9ASNSD4NBk|I z8qI1D5(Sf-9=4KHyavgmBgG<>RFS$*PzaZ#A!W5uA9#Hx zYfONfD@#nufB_hT9b1RHd%K398F9DZm+=t>YF2Yh+2F#NA}`U#xO12*%xFdnI6p^l zfQ)%lm7#8uwp4K1CPSnCEwMl|quh7<;hlid-b^$lYC5M>XmQGlFg zOjZel#HBQzH;d{wBgz(0vxjwS8l>8qj)=B9v>W28Ud&w$Oo}SvFfb;vPFZf$&$gs!xjWMO*PPoqJB0If`KgITcM&yU(16U;g_nKIA>05O9fnw;{Jh6q>PwMG}F=;}#uGqrs zp*lWyAe=Ir?5B3PVI`%fQRYagd&qzBtbvC&F6r&)?zQDS@;$gGtW1TJU~o@JS+4}i z*Rz#9N*j5`o3tx-obOcZIA5%|(YN9&#DS5Y7hxM6qq?F3PGw?gGpT7A&-Po)OGF8< zUcfcM+qc3!Mu@Zl?Ym0hGpCGW$)#|=lJcPm=EM%kWiRu{QLfYK_OS#jvn~q*@k)9I z(NF=hV&@>JGpbJPUxbj=B)_|{QjHt&H6*)CI#MEejOD=C0sgIs+P709>x^&_a;||J zs8lXKPP3--Tv17F)Z&4@$nVo+O7D$9z!1sUQbA z@-Gam%@bPOnH{o4P*YG^7COaC6gX3)ObQNxrZL7k&f>u_ZBVF_dWvi`<(*+ZXKaqi z+LWf4Pa`M{ovB=}L?cn9u1=Und?a4jF;!2atU~f>N36u50jjW@ZWN(It`$;N<9jrX z@o1NTr<3z0H0|4WVSsJu@~FPb10vb4?2f`B#34sDR`%tP%y0l$WXn>h&0F`cbxxWWl`Co&@<)H&qcnwG9#u z*$51i-jW2h)cW%rHJyX&+*nwNowY8i1a}T?2`O$~!t0jXx>r6!df5fy2(xl9TyE{| z>4MDa$|xgQUWfi7BOOEz3y1g)bE}@z;9Ib6)N*c0chLhX*|1n=WYIeNqKJ^S(HKQY zh~FJr3WN@`B8kZ!W3rQ+h@knVSR|^gBg+Y2K=wWUrXkqcd{*mOYu7cOwKfu^oG2a!ERHbjhcf)-igvDn(y*4A|`YonAs>}4nL5)jLEyyW== zVHXn=NLJDqO{i1Bx`{B_8}V|OkFp_zM>A(ohdq*sh&3^6YH@;3{F)=*5p!$lfcU|@ zd~`T_!3Ed^cy-!r7K*sGSKdNukh2P4VT2HJ8uexC?sGUY(}Gd%+lJBo=mB22D2xWR zm)J~$GG)bX44H^V=srOi3zTkC0wV$Jgl>qecewMXkLd=+RZmKgg_I*bhblNng-m%| z88g`A3Hz?E32vjGeI#JO*FdrbY#QCxkyyOAain=PeLct)+?>FEQm zV(}U_mkF~KiA%DAzB@%VkTqB3nPQK`G%F_BsDcFMWAm$WBc}vSYmLNL(wt4W9Eo5J z$Z`}^!Vv_~At0D;h()6)xKnY!wckTFLWS^KW+`m({g?X_r0H{V(%N9Z6pE(Bvca^{ zpv0p5BX|%vWjAgROGu5J#XqzjO>`ejt7(Ixrw+mvWJBPJAf2oPn6nauZYZ<-JLfA* zo^WrhNBUB0?o;xo#QWdFvH>e<|J5Ax-v2hw-T%(U$F~0>$HKmyVgg|2$vk(sBO(NEK9#sf$j)#aG9&_(Nnn;6+>(}AKggRWYRXv74MMb2B`cg zC^Pk>&UR&N&(RghO;OF3+!P*1Mt!v3Pvx7p0rTbkvkN4xbgWr? zj}JT<0V7tXB1r-Jv&L9fO;N?5nzqV~Hnu&I0j`Z!0Q_#A@tv9xl)ZfrMY!30mT>zi zB{*roMIi`(uu75o$V%nYX&cv#q01Gi5sZroYT`yh3oG$lHj5dRO)Vq5OcE)CC+CUV zX2QCfPCg6XeVC3vjAS7kg zgO-X8311`HI8| zm^oGifN@snzmbR%xHuhvf2CpBgVx~mfH}TR$j}E!wF_Z>8j5FvFa{=bf}uE60$A9U z$B@o3w$C%|DR$B$q*in$WFAB;VJW-^(@ABR91{}S9!y84>=kk!Vvz`Y-9}aE#%?b` za|}3C4{66D@e-)V#tAR#BupedVY);Pjw|Vqr!1fc2keub2vDGhl?l)~V=XRA)( zB@B;Sq&_N90UhN;$Up0mFb^zaBGZvVwGf{ccMUg9x_^6+WWTjlsRf~hk%`zY5j0Q6 zC3%8GNX4SY?qL27LQV$Ae57ThQYwI+N`w_P>m>6e-({rpd|OCgEK6M~fvZlzMMrAj z63miC7_#9krM_6D2)vM{E@(mqu8b-ru$3~bIjqVq#k(if#hiQv`vMrj&slCk7yx}) zsExdE&{m|^h1y|R(R`ZVZwl3B`O$o8^EXBMX8Iw&CJLhv(|WP&UclhBjFcCbrXb|o z0L-nBqcE(9%#3fu7N2Ak*dm!+DicwYNv97TCKq}F(>I}z(>a5mw`DW#IE~K*_hvZ) zel|IUDyzI}N65Fv(8(WF+levlwy75)+kfbW?SzX};(UwnK3)>gv)aO#7e=-!f zlVPa<*v3N>4Tt1R!*QRz+7VjX1pN)y*O1njKq<`y?K0lx1y#-oEHje0CsCaQiQg{k zlTHw>cH(=(bV?Zg9_e%G+-G(^Mf5+pMCJ4Ut!rNA_5W{anbZHw#;4qOJ3Bk4ng0(d zjH-3cn#=!(4*@0YQmMSIe9DY{`IJ|RGvBnb5tfo15Xx9anUe0YVxw6jb%c@#mfosa zdaJMCEP-ULmXIZol&VaYz@j<+jB<g) ztO~r~b(|^{&K*d2$SXQ`AQ@lTatD&OuCiklLC8DupkP8ks6Y_zUu8yF0X-ln^jQf> z{(OL$PE~iWCT5bl3eNg7>DjOPt31!3=z;)bYX{|K;la6aEkuS?>TyF()YEvviU9(> zA|RQ-sB%+t2={B*F|{UX&@ZanX<+fRocLN+mej*LON?H=v7Ux4undC8Ci4XAs`D6*KG%fSVRQxuRRmtGNIfd4R7Cvbth0lYn{ElA?=TBeREjU}^>jgei6-nxDH?bkw#L&xd5qQU7?o1&dc*;R zjfO^rPQo0pIumaf?W*MpWG^k45~A39of-hJS@C1=5URLrXO&dlC(IcVtBbeWc_#`` z~BLI&cxhFlKLW%)FgZHKpTyGz&)Qdd*NYP5>~2 zLKdaztbIaM#a6#`tr{Hc0FPCM8xb+DYBn)I52q$&6>vr+yFTbaXN5ZyPRU!0J;lpxLiJcG3dRZ`Yz zull8gE06L3$|9$bH}WhANvNZXVQ!E-22@~XVs917X_ z>*P7u%_S@@->P*dEOralM+nz0&RHPwZRMHfVG2?uk@S(ty`G;{jp(k6C5cbX4v#uQ z;m%(62_6M8%I^pT1oAC;3!A0HjiM$&PTVL( zWZ^QJPwK>%T^ht!?WY9)k4oo%gh0XG{EzGA{6A*n!yN+PdcukQMSoS!H>6YTA{0fMHCG{r}}4?ILz z25Ad}y~XRz@%Wa!fZrmRxt zMOk|C{kafaWhCm5 zT>d^%Qu=l@`obbr%F6@Qp z)A7sGACDjb&M@pegnZ9eQ#)PPJkripRM(7NcIm=?c~F|(bC+70-tS1IXXd~s14@6F z;({lGJiU4j@ZNeD41Bkyn4sH*v%XEa7>zHN0pC(gh^WSQt7G6!27&YP_~Y>)p6&!m zq!(`ZAaK1r>uK$JPaiJ*EnP6eZ6HLv#;8N&WuwautwJ|46>|fuoCOUv zWz`apIcl~{Y4ZESQHh7$ZIB-Y?kHv2cip(rQ4Kr&p$Sd8aU*%*Z-`dJxuFt(@h*$P z<}a*P7C5`lqR{z^$d#Vce9*mGEcl9H)y3^+V8fTLqzT{AXZ?M62+eE%ojy9vzYlM; zd{iabfBX2~Ps;$jJQE|Be6M7jL^rim#sXU+#z1DnU}%@BTQnfH6Gzf?TUaWpWdUp$ z$kM)M;deKr70I%w(l%XwiX(Y?7&xV}ct`ZiW0UFi9IB&rmu1Su^5QE&V zOszJU@rD!1L@;M;!d%~Gj#MV`jy$rP1+eYvGd3$xJTIJciC?gb+4Z#Atiz#=>?Vv|z$LM8 zKU@*!F(b96oZ{H_ha}7&L)S`fjLZ?z%91ZZrW6%;fMfUv1vlC*lh{zi%%z91juWi} ze!`Uz=_)tm zx0a8I_<5uVR~@tHk}}iVotnIiEUTpqOY>n>#n_sMlhKx@%gSgik(bdYE@tLxTp~E( zotK@7d$Si;Qo!cxZ74gHL$@!d&d%+59L8(XBMSr*tGPRbw@7%6K| zUf+iu7-yOXv!ZKX*2xrK`(7=`5hBOIaZZndt_iN_30KX6E+IKpX>GT!rPGYb(#uuF zO=R4d@%klA=#cX^G0Cp7-kQ<7=dg2(AFMfS@-xWmf1mUJnU#<2|B1Rk$8(PUtfY5PQBP2v8@GZj z#^oTDscA*qqe8xHutS6+1BkDCEQr(X@()!Nvai6UJnhZT84^hw9gfaAQvOCh&XAPl z%AP^R93;ICji8Jx9Cs$j{xZ-*ewaow2k)SsXBUXT(~cZDe`nj2PUOYC+PFFbk7Y(qX%snm z%bARow-RoSe(h`8TAL+SUfvOxxj8bnPK}&c$a#Y~c9ge$mMa>?Y;qvUYFFg+tQHI~ z*Rl{R07-($>)~zeH?{H?%F`6}p&ANgkZ(q0D#*j~<75Yw112Ef7LrRj+aEr!YhbXu zua}H30CX7x?iZ-QD7w;+P#*LOYywb64F_7yjH_gCRmO>UlhERN3e$6E$O_TYmdck% zcRG`^;0rl=wkace8k8!mDbmmg*quTT30xx7h>;fO?aOU~5XGv~#>zZo$3F$T51Mky zbLwh6X68nM5RWl<(WM=Y7pjd{MjOu>z9hsPQ_%c5?#XY>Dvui3lxhV7wY9a;W^l}6 z&qt;#jntym;7HALhnI7B1hf5F!=iyf@UBxawXqb3k$Q#S66Uly=r-7E?pA0tgQ{!?y21)u}OlFe2fw( zK8TCXGT6loDIHc~Yb(zrH|KOvoU#?l(uJUefe%0~R2|6>p1CFv$`14Aie1!xBu!u3 z$dYNx7&PXrI)XB$-E29B=32A7D+DWO!yK034RLikn;4i+sQ{T1xVQmLd!Q*GtyQTU zu0YhCA{fkQM@Cikps(l~ z=W4>+Co5@>mULcd!1ACYO%eCNVW=XPwFfQ@olUTC<*c>P7z9WgH9#PMmt$Eql_E!a zvU|j{`iMr2C@|M93&O@cc0kt0mZ6RH1dxqNTiXU@y%`_ZQrgD0rl$2O9zS(!YGc!S zz{bXQ@(*d>+<5l-D{@+PYU8T)qgfSq*NxbWQ-d}JS6g~|)Y!Ob{kUOT8{5`{YaK0X zzjKOiyoeM~O>>frbmJvh3i~A`K!{q;cJhr)d+o0-W=Y0@x=q-@@ra$v#x-0l7GxhC z#WS2{veF4{RLv!=HWBOWnKGd!NkR0A($x4ky#Vv@TcM&Q%>%tJ3zJo;5qS;fi_8J@ zodUralf{m!6B=Xkng()@h6Xr^Hu{ik-Z&XVp5u58D;#a~8(0}qe1#RjFpGuG>vKa{ zn6$8hb4Hd7n=&ZWH)68R0Q{t;B8AmA)q|LN6`S_Gpn?W-6+MA&*+4dcOZv7_q5zx< zv>=(#FrO2;JPEYIT_v9`9HRz8t+Xvw%-UN9`D}Y4Kz7mm~RG+Y! z1nC?d^l;_sChvi)skENtn_Jqj@IAzWC;z}+Ci5UtRxtAbwSm|H*xwRSfbesRCdlS5 zurY}*B6b3`rm(e1EX&7DiDx4C+nM1 zZNZ)|4PI0`c?tQic6DuIZRC=MP%Swr*zMc!m>~`aZ4?@7mv>O9YkQ#-?!Bpr?jw=_ znf8p`ZjH2(E^+X<$XK7`{{`WwJsT!Kgy9Mg479xs$`vK{PZxXPZrk16W<1@}W@BL~(Xve}?}!CJ0sA7n5@;0?*aox_=NN}5 z0P%?`wk(q>`qP9-nyACtV*f;C4O3^3N-%HfDTQzIG+7AOF{3WNnKzjiGk&AIscIs1x>r?$~u{te38@rn=gv z4!ovnE0GZ(G-7GzJ3!VZ4GbzEVAVy}yVwz~Ee2S%e;s%uBAP8)UP-KFfAzx0szD73 zCjATBgv4{i@k-5Y!scZ5RxM1VYg?eR7-(v8RU<#dt;ZP{6E%d&@(X83{`GB<$%lwm ziKws(3esOmLLTFJ%2!)w>AslmX%rTNh!K4TC|+w^(e7| z9Llf+q0MQiDsd{~6r>s}dM`-V1K;hK9*P}A?BPqV1;!Q>$}_bH_wDnxMvq7~43ZXw zD~N2(mQ=@gSg`Gj9r$YBIPd@#tK;rOtS1ea)p3=V)?1(|ejr z$@ETG)Ir%dWA?)kyC;^fQ}W%SFap)hVS6VfeJgoeVAk+?+DPbGa-=bE-Lghz;~XYm zrrF0X=OpHkuuZ_u@yj`3xlIk6gOziO&geOpHq}wB4fvgv&1qr#HJ;Ld1v(v!Xk=0~ zTO9&x+wv?Bc-!U@ZfL)@&ZxY2lh0w|IV;RYC#(>pe^?Ck0r;zUsS_!NR^`IKK+WmK z7$sk6joDH!p>?*ih zhT`9Fnl^kGV`IzOXVr_f15NBW!fsTn-FII{+Ca0ypJMjEJjKr8^id@LORTkJt;_y* zU2`ltXa74JpK^P6FdJUjn20<#q9^q$sr?Ld<-mMhX?;(@3}9fG1KUU1n51TN*<8kI z1ZEpyB{EuCO_FnnF^aCb=&478mx43ngrSqIC}&PJPO7>EEg9(~Xa>pSNnk?_DAaW~ z^-)LPQB_a!;Mt>k)+9SxQjKd7#m8%eF9>RGyq2ZWiZwMiE73FCT3XtgXFXGm@K7Hk zcp(pK@@3L0+oo#A&BQ4s;&cKw$)-ti48$)^Mm1A#%VCZsWp<)v@r%I6wQFd&zptmq zl|(0FBpFtif77mx?xC%n!vp**0(H83-LH3vulsfmx!-T$?}N1d)vR0yJz|&(Baq-I zgxF(v$Pm#CUr&am2%Fr=7v7Og$d3F39z6j6XhO-1CRk+7(L`hvag8E%`3I65hR`4fvURuhKIU$bdgcCqgO0MAWp$OGl!Ij!%-S)fVsjZ z3<5dXszKey!;9EG5TS`QoSlL`8e$sc4z7kh7B+4&s9+s|5ruUNqG(0WR>-*tT~Mp{ zGJBpNmfk>~Ds^?>>zp>=XIFRc(0~wp#4crz1dDnKMEyo;7cwWIj6J=i!=Q-7I%%f6 z1_nYB;MjHgFJ!M(fZASbwn z9a)34AOt%?95zVLpiy_56%66b(j|z3Ef@)sVJ9m`JB&fvUft<1->4htPR)N!O20Jx z<=8kC+x(>s*0a$&DChfp@$JXGpD335rMQ_WWH(V7omwHKL2>UW5Wa>B2t+u9!x~Nor{tmRMZ7Gz^q2VH9JcfO6~yr5D;Z zwzwVyA=(&6t=yIv?Z|GW(7I@)*ICaA;WHQY1mHJR;cVr(Pi^j~o$@5`iec({puvf=*wMMtKb>b)*gk zx{nr`NdGOK$z!e;6}@^*fx{%gGs+yGti%>@Wr9{m=o8=KTBTjqLDx*FNQf?|w6`k~t%&T2H$Wg#!7_;=$HfFf zB}j@6B?+6Y)CHqo${z6OMh?iDw~W26#f845ueY~jbKk&FSEsbxdl zcUyZM)|#$|BN{m4p;H}Owa&PA_P(jNZ&z=Hk^`m_v$P;EIjFQ8#8A-?DKyMebHt4t zgnMv~s`PP#iBTY=@&^8*ag}_cIbC)aNv9;LcwOy zXDE2FaP`#+=LFDZzDZH4B{KQdMn0j=v**iWR%Ppm@ccP z0s0D!dNhbM;me-<`H)9KfE<>-1n80mcpt@>*shls6SIt2WMh^wJw_(;FMAqFllJ{M z+_ZVs%()F2s}H{sx9xVpB6$|M$xK)KjAVqF3j?LEquE(312j>TZ;18Pz)noV0pnd6XE*~EzrLzX3e*L?TTji&A zWm@E3MD|sV1ieq79rf%HJajiBqA$2J!IhdRNi5a3LPVLt+bg$WN)#wXjSLp1O48Bc}B z($&$~Indp^bFj-92hZTHCc!3t3fu~ErY4Ms*6bbx{jpGu6}QdiJvBPEZ0Q$?*{%LrXSGx08RmuKehm``TNdBMZSj#%E z|5t3z|7$ircK#oB0u)jJ*-wr-A2DB#ESkz^9dpQvHbvKA{)cGWno2rkl^r>o2Rjw+ zyELjNwelxR6wDg%M$2)PLM{t_QlO_tqhZ@~S}K=I>!y`p1xHDVv=|2&!s3`@QoxuZ zK^5L=+H!S;Cj-_36Bl6~@iJNVbDJ`oz+}+mg(*4s0|tdTIfzYj%T;g7=PPSo+8J>9h$Bg~X zW(=~fNC`H^LQ-xg&Nt@LJG~4(MfU&6S@8c}+tS?X-TzzW_W#-V9ErVsm!58EF6aP$ z#N4}WdZ+H)YaI9PC?p1KjS*|<+GnOnB%(M8hQ;&J zq~}=N{z~&g+cntH*)h~X=2PudEtQ`3cJ&Q(DwF5YBvJ!33_3 z=yC3DYKzpA=F=2=hKR=>VpBnv`yfT8*DrkrK7@rl(q(USo3%NFl(&6;| zSYhJR>>k1)^ueU2WrD#@5K2fBF>*|5utI*@G9_I(p^rnnc^zG4Ki4^*bNb2Sg{Ii* zFtD5jD-j}QQ?nOB9bm4#tGl_{&i2A6{IrbGA(41qn-xYiQ{cO&!vanxe z!hnM~DjnR;BZuQVqMEz8XNqOm&Xq!g(|47Gm`S$v0Y*5c?dvAEFt7;ruAc1Ea6U1I z9eYU$a-81T(}|Wqg3lDZaJ(kH#?6)Vk<>&d2*>eZT+L*(v{?xU$h4(M9(RsS0fT9b z8ds+Y4>ajkLU0bU3(N;y1HmZ`3@CMTEN5Cem{tm#43!dME{`5^{z@o-y~*(@7&db$ z5$X|H21aObx4OZ;o?%Lh@O`*zV4!cnaoMCEn|0KDU+jpq4TduSZB|2f7?n9LMF2VV zr2l%LrzkoUVW=NEKh9pL1aj%!X|e^-dI9R$qg(YR3$2cRKSmCGhryRs4(h>Z2P{U< zhA(ZRHIL#W86ly~#fd0?oQOO;;T09rpd2A1N4N9M%6d-Q6)NaB z4Iz;rKDL3G@Zw2bv$5v!>MNUnbxE5}KH8PG6zYx2D)YdN&i<0NMG^x9-rZ#Tl(OVXnS|>HU%%|Ae*Xvluj$^^bi_~Qso3?F3%yA=^Owbess)+#!b7L91f%o&o*4UA9Z* z-E+&~h%bku)G0eRjQ6B!b}S=gATi=r(zzTBD_gt!dN+6Xg_Sxe_-gdDmhlujf_QqB z`%o9W`#efqpxKLAx}YuO!u(2bNG4c3Y@g&wxle9&cSM|$VTYTsUozK=&cJUNFL$Tw z)r`PS)3Mp5yDjE<>_I;I_f;3x%23LGQ)E?Fa4X{3;RT4fPFO z&@WW$XQoZcWEPF@rZUu@C_nhUeb`K2zl+YekreZy%-er&-{8*ve!^yafPj6$%w-^M zhySnv^+P@_aGxgtzi1XwT{>dC!8%1W_I5b#x0%VvCvvP*f9KZ;?c)$4>z^LuAEHaz=C7=+&%A zBfA?6S-@5?Po14)d+FG+-M3mUjq2@ue1g<=ZB4vxB5Pza)P1LPCk`5; z)+F3_;9aWJmO4V_r^MZIi@5z`o;}E8uVwug-R7NJ1*X?)@M}ObqY@rkm}|Nu2)0;s zhX@MF5`+fw)dxx_Sa)#yPS@Ns`oSA1b=1;0tFbLtOA{Xi8`0T5AH)Wc>+v?y2gJf=88yY8cGdJRx z9~RzL&+8gs4ADjCyL8;fB8g;DnV?Q?XpmrxD&*)g=GPW!sJpj&sJo-58&U4d+6HrR z7!+JkJAQyjOj97bX<4!ZrTizQ6N%XYaa)#r$qn%O2+?*HMhh( z{{PW6bN>Ic@!|1*c6s9e>^h?He+tJ4@b%fJ0f1Ux?g4jtOHc zV4a{alpYQ@S`7Qb49=y$ISYt0ROkhF5Fa(K7h%uTeBt~|A&u@|F2oICR(Me zDM#nUKCg2AUu^zCV&BnqczqPv|D&yInqBk1wzXw0{@<*8hQMH!oIxgZhz19yy9zlc z7%7b11{9!}@vNQ!w@6SQSO#?)bNt4V`bbvIPSucR;4BBXsiZk_E=o>CYHEhY*#^e@ z0FABIR)exSG;d}nvJpag;?b+Ik@c))$w9*|8c(LJd_}3HJL!)cU~?Gh2MoudeU_I8 zoT&=Z%tMOT+sX$E)stGnwZ2=L>16UqaLp7L`YJ-CRz^gM` z&TJty?7Jc`xerDnkr1w6))Cm$(9l+(H&Lx%E}c>1yMt^-*M6J0RiYNt&Tv}^3Kp9p95@BSG zWE&dkn@S|Yh9SPoQhQVn9)ZyW;ZGj?OwXDCMrSLI0v29ajUjH~I~%@JVA_qlp^uMi z@!i~nFKDI6945nxmQ*t)#0WzdS|gJQqoq+;QIkpVKM3)Ae=DV|CpB;{63x&^6|jB_ z073)uTUG)zcwjVuyBN}9AO-u~2zPVQ5^Mta2TVvvMdrF}-)++taLoqj2F{Hted^QI z7s#cxJsBFPiuxVY*P8W#FuijI1W9$=paTTgcp#uHGtV8G%huMJhZHX){t(N(v+qz| z#4gMQ#erd|Nq_vZDO5JX93g;GiJ1?@(@d$O5$BKrx1Ix+4>kuJoSH&?8@u!L=R0sl z$ayg13qfJ3@ol3Rc)Uy@0P;*vNuA2`krx6t(n?tXg&^@6w&Epf@-Olt#thirHQd>? zdFM8VC@AXtlNu=HnQEqIX9v@`(83@MgC0JWfi&8-=8ZGEa{+99|u|&RSMK-U!$%RmO?3zAsx{+1dKD$Kt?*j zIeT6L{Jx8+rVzxAs8SH%n&}Z_{*Nr^41+hKkuZZWCL$EjUvwTo`#l_1CNQiTeW4@_ zk)S~DiZw5qxFm#(jW-_fVZ?|J)bYlX-~W&{5s zQvKVcDQkdV(b=vP0`)ywA_%SsY~jfZoQlSno|jM#5sJqnMC?pLg{D@qNG3+!lPyW# zqaZGrgqtOTe_&4_Oq&Sd0F#7g5{@HQZidPU!}Qjj@~NA3)oy{>S#{D|`%1a?$P^i~ zRJ9eVqEP6nIa#FUNG290f12S>3;b!VVN5G1A0h(eC+P%NHJ90I6QMv@rY=?~3E?ne zq1EEgX8C7}{IfO04=3o_NS8R{A>ch7i$pTb+G9d{#I>f#q)Ds_Ppa_Qr`#lYk#Y#EyONAJPYQ}XPmR~Vu zL1qHY_G3{Rb_J1K!)V+&``VlVnF={V1kukR7Ukp&Ex3xS7mh^Ys}ddB*}UFp(lD~f zjl_zy8e7t_s7=;BOOcVY|KcI#>HN-U-H`t4FTOZk&sPk`#Z1T^h>g?-s)3e;GbT() zURt3qXO~b2BQ7(Uu&-d19c*0}nhwc`Rb$Q3aC0oYZe6%Fye1qCuM4-V4Y#(2W6@~H z#f^`8+IrQJRxz>~SCgY$QgJ4*S)x3$bD7N^s*CyXCTNY#e6#B{2qvWIMp|ULdq2ho zDnuQzQl>6X-R7BX^F?UMMtteyM0Q7lH-VzibuTYTvA45JQ>e3I8VO;j;Fb!?$D%9@ zRgxKUa@N(PBhv?J!Cu>fpo6tUl*dlE-h)2MfE{swdDqE(`H+$l6wbo@gviyTgrw|u z9_CrE)R z!b)=kjGsCvCJ_-K=_D+wgPD#oR70o0S6{*KAkU4hMRwD5bAwIUrD&f6tX{x|MT|P+ zNTDzh1a+);3?a&Tnk{NZL{FQPv4x|Ckln0vR>`#h2)<-1vh{+r>$^|`Y9Oo##E6B9 z(6GFgN+Msp0`a3=I<>Pyrrd?Q(tOu;OrK-Dhs%0rk*)GsJE}OVi)1UoT#o>?zJmDc z4A^QV_^Ly^v&~uI8enQzCP2@H&2+9&Dtil4{AMK(D0r{p(wm{G+}&^Cs~UQnSY1sU zkQ0~k2-LQrj>1vQsSEE`u$jsoQFN2~*9YT#KG9_--bR2OO$0+Ubq=sY=~1xx(w1h( zCn{T4sBv&vVkx`w5{TU=ATi`~1rO6OqOq8m?wc#IaW-W|8_d@jB`ATD<`NlaR>=<^ zpvlwez)Xr41UXN0eoYBvSjmlu0VZxR^vv!sGp5q8cOQbY`lN1INsZBNz3<%90kA;8 z;3TRfG>cv&2Bx{?5cUby2rl_UM6}Nw1JehlOACNWsuO})RY2jS$SMkZ%z5=*l39<} zj%3WREb^kB;

@=p+Pl2R74UBM^_PJ`jnJB7_apD|*_r0Aa>xzQ$l0NMjsep{<0T zps_n?fI(g&tC_i^CAPvQXpFl*@}78Akr)fkEne2=n_Tx~7M-+wrxo{RYVXLoF_rv3 z0GeC)g#2gA#olQ!>ozd@fe@F>6B_)PA-0i9_%j!#FciYd0F$)}Zw7+I1SP16e2FnTVC{GT#%@McLX<@sxoU4o^(l-xix8uy z$+~N+s6_&m4{b@C@db~KkvBzx5(E(dQun6EAPA7fV&8|_6p3bJO2BL!0WiFcLTFME z6;M#Dm|xE*9ztSbl{o85mU>zH7(@Y14UTj|i*aiaaY}4j3cC!HDKW@NQj}n=2{#NH zBQ!tAA(5U$>B@Sg+0(dX7`tKnr5V}`J1lvyb_{#4_zi}%-WV4&j6~(=gl%ob2!*Fz zDuq&3x=AJPjLWl2OIY!YJil?9e&Qm5*ekB2KC-lrc$IUuo{`KBDkO7p%@J9QDAiF}J+ zLJE{(fyeUBbh~G&>5~M^H93RXXR(m;n3F)W&kQH>@(Ai$rMa+-2KZV56xcz7Tquyo z;%u5F52Y+%SC}glrVwuczJfTim!9LWL-tOY0&sy%f1>2bA*De9bt1YMVViP6Si-YC z0a*q?oS&N99MNtSAvBF6nS&=|lPe}n#3htRlTrFo5L59>@7 z+D>E%2^pzi3=e6};jg#?0FhrnX*1iaXCSX120giMvKg z&jc!mk>gP~$X11*_0^-R_Zt@#$<+g?IFcOiVT(^>OiIhZ~)B>P?{P&Qv+LWNaM1jVdRyc7zlN- zWiMVvL?dfL1uBlvijI37>YoTi^sltzQT?l z>XYx)ye6qhrXz6ZC$BrsNLEvKdo0a4xmifk9t6^9bJ;+T@E0L3Zz(iS1(v`6{P7s^UPEpZ1X9hc#YR)0|`V=LWe^Iv!9vDmPwm z#NwO^)_a7HP*((eM!gXxOy-`z%oa%rkI-J`9jc}VcccLGj-b8}G}b2R%j3Agck(a` zrpr$F>;^3W8!i8ihYtG(JJhhB2|a5~@gFF)3O^voB1jX$BQ9Wwk6;_%zfIR~damHV z?E7k7*a6ZM`?kdp;ei_%(+iA46!sGyD=}QNH&o+`MHJ|5EHYdvd2w*K2y?FNrQeYK z!hXiCMV%j(A^gNHm2x4<#!E23QVrVvJdElj#V0GuwFE+0uYSROx9T}-u*RrZ$j_d# zK+KBJOE`Lcgr!`!avUtG8WfHzw!R)~$#+3^+o&4jLt)LklxpsSG^@+WANO=p&n;bY zxW?5ifmqApg$xJ8@eYW2pRDsdY6h9o^{h2|mbdPi(b!pM`8=f;2c?zvZP*V2A3$UF zxY1Ec;m#K}8$8F4SIX^0Okx2yu2`l!l;%N#wU(VsxG(g>fQ~ZcO0G)t_I}R zrH&n#r3@)<;6>Rv=J#x!&qJqM@u>it_*fi*{9G7oDHZax?+=VG+zw78J5sQ$z??JkxFZg;U3f6#r32|U4N zSLVjIpJ|&9^o5EwmsU)GzDTjc(7Vu|$DFkI7z#{6k&^jGQfMk%H!K+PK~F2Sk>*h| z5ca#L!BYo0;2i1rMsuISpHkv~@fdA0?W0)yzqQRRp7>u7|8Xw@>awC<3y9c|fCt8(|P0&>YcK|XPu?QUjYgKq2Od4u}sXh7I5Wkn> z)-$s@|0S(|dMh_$7EmnycZ)mzXLEGzy1Df~D<9z!Oie(f&LAi$LN(P?l?Ohlx)Fhl zNkJO0Kad?E;!8ENdK;yhLuTH~t*EP=$aJG^&@c;5P(5njzT1hdT&BLJp3;+QHb|Xa zg>uY~!kE;uTpXcc=+KH7Os)g9CXGdhHcq07I#11JZ%w}-gDG>2DjvxfxMngj-#s(z zqv~^-Zi~D@>Bxw z#m17x2o8(mB8YZpVP&^A6;>wHBt+P$ra|lCVAw*SMU5|c&lK#MaM=4Ca5$nz{8qE1$gcPkuGVn$L`k>7$3+M`8It z7G1Np)gAx8rFky?_pE%jb#Fa$ow~1TU)787Gh0+Hzu^t#cOhxPAM_&N=5}J9gaN)AOW@7cBM-U}}HhYK(K z)TNhx`r?c4z3j5jjEvkrHg>5tOnlk0zBo1Y<*Tmx%A4Q( z)oZT#%3I(1*8ThU-+1GV?|kPwZ@u-_4}S22AN}Y@_wD=Y!Gj0yzWeTb@4ffapZ@d% z4?OVs&wu`lU;N^O4?cL^bq~GutzWz8rmw&4ZQpp;yS{ngz$5Q@&!g{s@3%kjf$x0a z1OMlvAN}4PcYN>8J0HLM?tlB_C!hG_C!hSsfBeDy_y6$z`=9#ffBw;zzx>mG`InzQ z^w2}!_{KLLee}_P{nvjzbm-@gJ@(iSe(-}I|MleRx z{y+ZXh3B68({FzB=Rf@6FE70C!t>9+NIrl1(_deF@o)I~e}Dh`-;Xp2y>dQb_ycR9 zYUxW=tEx}me&4}|u3P$=hKnD)?~bp(b=j(OKD7P*JHPSvQ(7+n$)opw?2&gXTi$kh z_h;|=)-A!of4KNtpS}A#?~m3tzpdN+<%a_MFOOXRaLYj7hZmkyd*g~fKCWyse{pQ! z(dW)RXZxl_ThEQY=9!P(weT6G|FVViPP(>lg>vrvuH}zx(Qf?7f&Cw=xxH)t9iKh@ z46XXs56xe&a@;&{&Wcsl?};9F*Nx{6Uc3M4Pwjut^^YC8x3~URH$Ss!)4uP#f6>rW z&wS$U6Blm3{q(b*9zD3?j3pmlzyFv2Gjed@*4qz#@<)$7{;qlR7Kbl8^uZVB|Kzw& zead>zrgt6Mmb!4;+ss2>*uFXaKIOJwJhtqnsxL2j?guYjv~IyqnofV|j>N`CF3axU zcKdBZiTAAxoG|afzklSbd;j)_s&N0tg1eMHHeQ@ueuc)u8QEEST>!#GQJ^d?|d}?{M zGSKj$eNQg@{xS0(U03&x z#^aaWvFyarhnKF{R`skuJ@$_$UvuV-pIq|&n(8;k zm#*AWefm&UhjIMSp^ob2r7IV|@fU3mKXTg>Z@Azex4!$7n-6yEKI7?M_AWT-g|{5r zHBz^)>N9KqL%XDpfD*LLfpCpWZaUN`yR zn%nOB&V$EQ#TGQ|*}wGunw(N~chj$ae6Z@Tsk=@-_uXBeyxcSLLcYagddfFYCe?9Nv#rqZ>_nv(>9`nbQ3+8?C+}p4C z-uf3`S9kXpzjfbRU)ntSpX+l^Y0{ZNBl@s?UEkVqCrM!JmC= z{ifq@IOB|Ke?IW0H>^B%N1J;6{I35!?bDks-G1P-1=iP3op|uai>l_G{M{8pTR-x? z`43()?>h6(+Y|3T_EXjwZ@K5bD}Vi^`V;;(@$*FoH;>)B`MnF?KJ@uh)YnEjcHZ#Y zPyPD%FTZfh*Tef3CKjH0@-fGbzGMA&=KW{YEz6GmVdLLl{PVq^d9dp2Qx@KI?7crs z4gcw{zgxQUJvSWqe|LW`{pSU5oSb;#v>$vWxHRnNiSWuDmInCR8_Jle5f;#VK8y7kb73%~Wu;&s`D+t=K+=(1z)JmtT)SA{$K zb}szub$|TQ$#)$5P2bM!)b$JB@`I0Dzv=EJQ^$U6*>%CHW1hNW;uCLw_=Ni&_*&I- zhgNnkeQYrB$3=@n#=F%I9s0qur#!NK+5THzyyNw&S3PvY!V@1oV=A-rcVDaj=6Ch_ z*KfIb=;7;^qAXT*LbM<@$~$ITe=Q5_xv@ysj4Abz2dk3bl}0q|M3Gq zUp==OM1V* z{PDo%Meh&Xwfy8w$^}yweDw3@J-qwpH@|Puo%bwT_v}5v>g_|DzkBeB|86|*{;%Hj zSo?x2pL%%fAG+p0c5vIT4pyaqk-YM?sh6I+> z7v8&S!=dy3{>K;YP;07Qv+t^>jyrMJ*_2uRFT)(UD zjsN(wGyWRdcijKZyX80U?0oHiUi8t4`RBbWv+VqBy_eGF)A!GN?gxLl^So&18=tS5_ut2z^7XG)@2mdyz8(AjXaCZF z_+9VaZDaf2(9$*UyZZL$UpugL*S~+^@_GMr?WPqS^N#!8(AVoOzHQOSriD#ccO0`J z+Hw6mzVx+lU845{^}3hdxh(L5MHe<~9(dQn_l|w%(v4qyT}#b%KY3x~+4HYo+P8A> zX?63z-S@MeMq=EUG=Tc|~H`XU;yM@zd##Dqi<_Jt=-YL`}5n{pTBDP3-ir4HoxVbk57KS z>T_@S#IOJNv2)iw_08>@)ta|_>dQ;N)x7e$OyltW4Zr={!ykC6=K88d!Ka^%bzS!3 zn>YNnYGdZQhH>?no_qFx_mpGrs9Jy8$~T>V`qqOhZrFaq#8V&X{aM$)Dj(VL*)O&4 zx$m{d{o9MD&HJaPZ~MO=`})$S{`FtBeCLYl)4%`d?|=2f=XckidUf-P?Posn&sGdiouw&gta^oLtNQ}^?;<_EqQxc=FBpIiIv?|T3H%bySa*OT!>pR2uZ=g${zx^w3z zPTjiU&Z;Nwp8VyHKK!?D{AtmZ_cm4iI2j>$koyR$qPTq3ar-oY&BQ#aBKx^ucAFQ+Iu{@i=FEW7g7f2$h3VOjTMji-00|5 zn!j*SRp_b9|8U~@*Bz|-!6%ka9k}GhwQv4Z{jxJoNiKM->LhdOQ@>2#{Pc+zD)W}T z=IjNVa`PVD|J5s&9P{|%t&dGC?O3$@{mZ`7y5`t>VvpZ>#?Y?ox7|7Kk~?$TZtGI3 zs($uN^U1mEjvv`^>_ba8Jhd#jul4<(>&^Y8D! z`9H?zJvP{X?xMSci4&Biftwe;@V;e#|BpABkIehg=Te7GdB=%W^UnU*h3~v?-ovd` zRm(Qr^JrkjzTS(gsun8i<~=>HxF1zYL-*10;dH>Bzf3@db z&yBz9-J6#DzIA2qLrYd&cGgMDCf;?R>&p77u}v$_e!Ahmr>?2@l7(fgNV5{o*OW#M4e8Y-v?O?P zwb8%m_$QTlmn}GU`I4noLvMWir6s*}lk=(;f4Od1@8o&UC6+xN%%1aTY|Vi!BhjkR zre)VGOCR%C)mLs=_NGI_fq5r&RBe6Z!TG_1^Us@l@A)^q_m8KndhNbNZ&u!L;IgIT z2j?IA#JuymcdTDk^@dHcUp%w)T4izFq3D853o~~uj=rX9-d)Qs|GKs6ig&E4YdPUH zw_O{$?XxGn@sy|My}oMRFAXc> z)0SWN*eS>E-+RT9mUm6ue(h72H9UD+*1Y|l=VdnHhZkl)KnwtG5zV7j+JO63f zm+v`$vTOHe|GF-F=H{FKw5#Evl~H}!yY4&d1ylX*^~vLN$%(tqQ106my!j2sJ+$P6 zmo8JS#k&ulH@5wS(@wZ=-TQ7_o;hGGI?{2Un{DORm4z z`pbtmPi*+|`xfs0_=llsrSbEN9j>d$`Rz*X=2==@*3?RBr~ zzb^Xvz#U6>?>q3@6VLw1_dmS&!p!-ZTe6QWTv~nml1(4Ic+292``VXZxbri=eEs}Q zRU?^O>hIWbLr&jwaNhiffrXiYdb< z+`q8qz=yQU-*d$mTb}vV$DVz-?U*K!8Ko4 zS=GLF`GWVn^@o3b=fYLXtW67+J>Po8(huF2?fC4L1z%XV{Q6BF56@d#{q(IX_Ad>7 z?6%u~`}zkTYP;{$mR+l=mi4#Xxa$)q#FlQ|x3Io#{rvq)wW@`6oBF@~m*}2vMo+wK z{-*xL?fOk$xqZd;%NBj_xA!i1eCbvFi!XS7!I{ezG~PFV_4D)BJ-=Yr8SiXUXz`-{dIp_xcK=Uzdh$o+kfzx`5lWsaL=dT zabRWdrcYG8{oZve$JgAy_^#XUyY7zHr27|EANcgL4=&3ppE;vr>9**Jr(Sh`&$$b0 zltuqmx8fa}7S$f}*~Jen-5nh}^)G*3{*FV77u@^V70Z`=;GU&V{KK;Fy#!%Z4{m$l zls}%lL%DB7Y}10+(ypf$W)3{C>8g?B(+k_LJ!Rm&#i_>@C%(P-oC6C3f4gtTX)87c zmTcP;tUh?>?#C7mKDKztzyI^)U;bS3$Dd38?Q{R{)MZueNA!&A`sCIB;T>9J+)5=6 zyN|;9zvfs=izol*nl*Fzzh~vMer0FhmZ1y!yA+serGMwG z<^1hKJ9?B@B&rNrSv_twHFfpkwRd3LvNCN=O_P(8k;#^bksWIq8fe-B4aJ})``Tz? zwMfEB1UA;JhiCAQrY1JxmF;>rO1c4;F@&IET)NL94HiMB#pOzP>~N>)p52$vS#5NK2s9=B zOxCzuBk%$Ig!m(I(+ps=lnnt(+haAs@1~74)$8H9S%K<}U@JATA+W_rTUy#`93q7S zXn#b0v05<9b_Ki+OwHP`b7*Vhnb6AmCOYu-BSvCsV@=Kagg&9@i4EY+VX1mr%Mu(_ zJC6x)iCo-*hwf*?Nn^|iY+SFFFfdX~PmL*Rl7QDks#$u*01GIJ^nhY!;{*gpb_lDzLzq(6!0H#`AR386r@4lA@PXEZ72gvgFLb#zFkIv^wBy1$JhE zjh*aUY4r$)vyALiVB>c3rOu#ZCM(w{t-78@^AbxR(UZDGn&}oFBvdl@r8N}K5|XgU zptoe}GztazZIoIY))6e2t!h$(HEEcx5v*@wlgu7SEv3|SPEBG{fsH%x2UN~K-9iO| z0zw=xa0{r>L)!%gAh$whJ(*-Q+Ks=w3#G)y2m(fRvi!H;zd4^3S7JkKQ3f`W#i9(- zA0<|WL|(scOjkl90Srl7&zjL6c^d{BZ9>U^O0^QbJ+HTIE&1t5> z-%n>YkfjAS)^*caNGJ5TM)vPfb%ZlT%gve#t^t~-UDr&u1~%&>N!_rtxM~(Af4L$d zU1PTnG_r+$DKH{eO;aQEmDH~!s2}8Cr&HTBks%J!FQt#%R5Lmo^k7GSw^-5DVO&d_ zoJaJ)FMD~5!=#8XEydRB3Jm- zE4h@a5OT@lGEkK(a+;FSvMC6UNmw&E&}8`X1&dG$isu^IB}3VP)LLVrk0*Ck`ubkZ`2H#Uedw@g;mi~AWTMT zYIYJ#CI~hrRD#GcEiLdm2i+$5@&DPo7Wk-&bH53Jgn*hv5Jc3I@Y?8-2M?ium?bPp z6q1kx@C|2oPm+b*JRLLMitH|uiq=jmLoiT)X_!JwJ5+~~?j0gt92?r`K`O?%Uk(Qkb83>>A_%J@Q zoSc$m;o}fe9JdUEYF=D%?NFe&CVxqpG^0EQ3~J9alglc~*c(Oe=c+9<GBrBBIDW+;*tGCv`ipufU{&U)TR< zRTAaw0;X}(3IuIaC1?(`fkCoqnCGEu;?N>h8>iC=hS_B|n9%Pk3r%DrRMPJ&(m4|* z0^cr85={kunNU$N`8*=T61*3F8&9%+*+rTxMi5XiLjGjPW-A(Glr>}$at#P4$-aVd*-nf!vh*Puavz~_Wl$=OJ#B}b%)3cSm%e5q8mzpT?w%1dURfxj?vf{Zqg z->)Ba8Ft)3_G!7OhU#ZC-o%KGg!~OtR+D7Tz&)Hue9r}C+;Y8mAyK=0(GG`MRIBm0 zVk-*CjwM}@F@YchtV7D*3a2~aQVYq+iV>M|rVJuav3b`F(2r(Po-GT<%5X`8io0}1 zIew$BwHzQ@MyAp%;)l#E1t+bdY+_Oi){_qfbWplCB)F*%?n=;jP6?C`0ylL=(@uvfICpu|YMQ9X(7M6N|zh}>)y zJ35%T%D4)^AQf_?!lvZ>rKRJO^jrcL0%@YaCsV1AkG7}s2yjT|y^33_l4?BhP&iGe zIRbw`G4t6m56R0~9In#;Sqn+4F$l-Q5C|hTwk%6_*jm*t4?Ch1vAcT%jls$Yo{&Z<-5WKV=c5iQWZ(j$4JL480{wM?W{8ywkEiyGmS)uftaNRu@+ zEPG&&stDz$WGtaeW;Vhff!^JFbRE=tjMyiLz0w`p<= zwIs<@;VztV3stSFMkYwKA##&|r9yFIL)KOhykv%@@Dh&vcgrLg_72BNX$w0U)X<8sFFT-k79-ARtD>quLP zEMhD{WUEf5iDeV$re{5R2yg4W14205mL&IeKrU%lQ2?87Zsg1&J5URlT9bQ8oZR&I z!mCuJ(V#dpSwzrl&3DhJ@hdEujhe3#1`M&?mjP+W>DAM&){^nIP?ByrB2Ebpr8*Os z>W^v_k-0SYSJY+<_Tz$pT*wF;&LOIs5+YQc1$R(jT(c+$^QlEcs@)A2c!J!e+TwC+ zSu7bCPu_(L*`id}kk9BQuQyBzF_o~V8_qLXs{GD(CYOpNrTTINwNo`}>~BJo{4Gh(9jc8j&(t0R)!{) zRifH6L2?5_vdt4w;*=)|8z>q%%XOZnyGB#m;37_ThUpQcl$pn=p{BG<@}=@Wyg-I? zpPnweVp#*|u_Ni(#ZjoeQM3}g1yF)L7`ao(e{9f~6UP^!rG zNMvYn1x6(3EunBiod(a0uWuON+~}P*zNOY%e@1ha%{hgGNvM=}o0TM-5HMepiBlj- zi25MlI#bLII2L;_xB4<;u;p9yOIz&3N7n_XNroHN(?PnNh(@OJ%F6PJiBjd%X_KZ-n>07dW`f=*Kbs%X|kutatPf|5Y)0(qv2g*OW;U zru4;seH%Z0@n3!MUxyk0Wm0bi)%M>f5-c^$sKgo;md=CT7ZKJM5!M$G))x`h7ZKJM z5%y0I5ylQ^Qvg_xQO$i(U|(Mp7}!CaqP^tP?rAf9?jBo}`BAO;tn$S!U zV5-Ge%NEPSoUwcbSO^x7)ZolA3C%7<%Zj5lR1;t4k^C|_d+4_qGM0$jSSG38gaOK$ zyfj3D24IB<8l-iXDtSmI!d-*#E0af-4UhLA?4_iJd=36}87-~}<{F^H zl6=6xt%6V%WIXd9GDji$pz&EH+7Y60ivjBiFV(iRG=isrww0Z)uX?y1Es!qj3tewC zi?cP4QXgsBb)^C-leNX0{Xcwtoe2*lLnAix>_}*Ep#6*uCqTKA$F?P=v;I7Qz#NKr zBw&Y>MGGo1HKeidonUfR2yOETxy{-uXl+8T;u=D0qhYzVWdLG3z+VxhE}uhQ#UPn+ zLdjqeX+ye(nJ=EN(>OkQULnaHG%q%~pJ?08&Q8{}w2Zk|($7~91|g)e#(f$J0ET`V zNO8L}qVe%i!AoD05M2J;0Kw!CeUHHz z=&`fqau7@`z!w-EB8PQJFr9Tr2W#q05dUf{K$cw&vvVLO2jeCQ6AIe;)OqKW0GW1< zjnj22xlzcc% z5o{0ROVyyKfnUoAz0olCMw4bJk(nHAct$z-gKTT~EJ@x0_2}qlf&&tweU@1-8PehT3u)`6mjo zVDMB3au-xMBV-T4aFekG;#V=#z>*9*GMw0?r28iKw|jRFo;qj(uTBlG$e57mAebCr$j1VFy3Vcl3b&KB=O@ivKi)wC{`m`8Iy~;(z+$ zfBNvB`l5dNqJH|Ke)^(*`l5dNqJI8Oqkj5upn8e`VrGDpkRRPV@O8xf%(cMeq{RF< zBk@cF2e|=PL%nZcHfRk&USmKGat{?@2neG9OI4hRH2^9ASQ~QHQK@6COf)7KPPe$a zl4yv8)L?gY^1SJZ?qioH)x`9G8Y3EZYl8j-rjVNY1p*Y5k<{VHNlb=h=q~@foNoJ5DQ%aXL-#DZ> z;f8&PPIp#)r2b=Hjmf*o~yLI!KJo%+0V*%ZUXcP(K|19FB% zu&iL(l>`(Ln6V5Q!Bq4%vySLrrIgzfak72G?Q)#imw6-HH%=1X!vasqjoX6_$+Frx zOFZbfqk@Hc56NBzT9Mh2|3;Wz1;3Jee;9s=B|*T!Z+b#B`CY?LaSh4-E+>54p%5O8 zo9KlH4+aT7MW38!$nXmQ(Y<>(Ulk(0P$l|tGtTs=J8>eXmY7S5d>kC$I4_` zJAg~k-H1M^0C*2-eUtO(NFfGoiX3CJwhFn-2F2tpw8 zC4zAP22ooS>70P58j(n4!oZpv=CmyGHu0=W;Ezx~_$^ zX;>iD&9i*yk?QKJ=PszLpWQ&aoLe`Kd_K0CQPoQcL%t*(m|j=iFwfUiUFV%!ceZWw z**-F$lrM;6Sul@0-r{STS62_SYnXMqk4%hAlPE!Yv%2~@O{q_p0WGTQnyMGnH@A%S zBD2(!F-YFIH4El>rG{q7yP&0^$%m6|XvP=S(+|k2sv8>5YO1TLZ6PylGTv3)P~TiP z+t)-!(=3sujpXmKUP`2ezPe_qv7rg5Ti1-_ZSvJEB=oAQHpbULyYdlo&i2+f(6=vW zY4Ym*d1uwlt(#4VLYhE#^L%v;l#2DFSxbZEK^(|jZ*^TmJ&uZe>;tk@H#9Yk^%?Uf zlUmT+0RPb$%6PTS_$0zr^L)+o8aOZZxu+!2v(o3B>ihYJ{y6&o1nb-3z9YT=Z_>mG z6DqCsU#3jx^Z$J-KYjkcKL1}|{(qk*u+J0dkS5E0e?4Z%_BjCi9Dscez&;0Hp9An; z)dBb|LjcS$P_pr~fS#RCj1)&909@PYej>azx`S9!B5b}SPn6I>GljY#sAOeYJx1_w zslcv;C$%K(M@0;X&*a>YV#zqG1=FiTLvojeW2I%%0<7f1depr(2vtA^$`Zq9k%TsK zhRCe+3r$Lbqy|V#lT@pm<>@8niXXHbixGg$>Qw~7So{D6L(ytslqOfM5aSQm1M0Yq z$nk&;o~7i58<$5qlU%!$M4+scrXhd>j8Is%pxiQE0Hv5GO(N1a_{h-tOJP0Pr-IU{ zS7MMgivG*i6IQ}JYnG=9-Y$Jki~_+F8W=`rO;{LQU`?lu8BLS$C3B{=^7jUmknU2z z5veg7hn|YHCm^j08pptC0Exb#2%KPS>0x>SGQ4uJZlIT<(|3b=3b8BofT9%vepIfVv1AMvQ@{#8Y<3*llv8I9e^sc9H1 zK*kl(4=P9j^%&mXppov24kQkl8|3H@)~ZdI?}Ys?>JNPOaDHp(W3+(p zJIhS5k&}QF{ktfB5(@H)O?@kJLWP1M3hEn7;)aRPiU18#RK#EpMO(2fgD3|WRdo<^ zEUqD(EADg$a4GH!%JgB_8DbZNMBMEKX*Rrk6&5cMq70BnTV-+t(R_1DEi8~8tV8al zCqoW|sLW(QzAE*>iSBI(nUOKI$JCi=@mXmYvP;1m9|MDZP%TTXuazbr^ReUK_^Erhz^h8 z(-uxyHEEo3rhp_G6rew1yx$JF$9%t~>W|YMH%0vcw`|5?GS0PP=yo!S#YoiIuPMvN zCXgAnmUP>zGJ3KNNK0lsJhN@SF zq;o{jW@*@{DY8k$X|xE>$|QSK*E*76&f+PM-e_W=KupeNhLp90dI(&LByT%VR+XPH&`9zsqd;y^(j!BXl#W>UZGA>0?u{=p?MlO9R zS|iXMEM|*ZzZR;zNN)XjHsgLc8Y+^69OPUMMeW~}^1b*nrH5{*ik7ZpQwyn$h3b(A?sbc@Db_4<(E*qU)HTJqSfYp@*K< zRZ|iXxib`vL1=&_0a*VgGXm2Guu>z%C`#>(e<>CLN<$PcM96{SMPv>@rs$?GTjKY6 zH)u)6b(B?#Rf82DK)vIVH35~p)XX=HIgQ=AXUsY6nGiV@>crZo1^2`tG`q~&Pgu~9 zI7SO;YlknO=s;l^0SzcxMAdH@ED#kC%i?jYkz$1%U=LbBeT1{pY7~XJ*&0UqVOgu+ zl@i=y?L-A0`Dg76M#{Xb!qvbQqan@iz>(XF9?Q2PFX-4}fX2k73LhDwGI?lGW4qCC zpa{Gh0LOyo(~SIJUK6;tSYHBp`%tkG&>VPlpA-v`+a0#B=K&pz0$(782V)(YxGI3r zF;$p?d)XnA=w_NUwM@_^0fQ>TiJH%vn5t*@p_>*mAgdPFK zF9(+C@C%2@18Op1D{qA_Z8*ST=y2o&AwW}+_#Yi&SzcQFD+TLC@`))CfYYc$lIa#H z4@Bs8FxAU!iX(i4!Ia{2z(Npws_XA`13^I}3DQ3n_= z=FRv8l7hT4<0_Y=BQnZ1A|z-xbLk(@j|VSX%%D(u$m@ygMc!dqN&d08hWe$OhtqOE zJ0NhJ0#`6GYsNJJLhE8kG!6iKrfqd-Zux-snyerC?ZMH6X2ei)V{0meTZ#$Q6xYX; zc!j9YVTOi7x(%uc8pe%#m)XkDrtGj4;f9T-4SGL}^WzuIk36n6O2fuYCThXD0^$0a zakURqA?Oe!lg^%Lp_f4m8Bv6zn$y*Wa)qGm3t{pGnjzR>S-iT66E}?59%&K$Q{CLm z%-JSdgFR3%E#SUa{R$BVprRtZ)i?m^fk8XYjscb8t|FBg&L=e1WTP${H3Tc6IK^+} z2Erb_xha4_%!vY*VK69qnC9RSx^?W;@bB8VaVbV37?C*PY%E83YB9UMv$oDJi4g|c zOs7&p9U_F>1-zfIOQo0@ji{0sM*aZt%Bt zh=^IMf17WDu*JV1^i1f8-Z$)eD#mAx?`dE9(5t*?Fopmuf4r{Sl zZtSZAO;Y!yu$j`Eg27zCC*WihSVcS~88Q~TTk9t#-7s20^bkPO8klv#Se?#+#Qc8D zI;`LL6a=+o;>s9brlf$`2^56oKyz9Agb8;Z;~*s31|n=3pj(EXZO2AtcQsowL%Jptaf2%jrz27E^o<=+3FFIf zJ_Rv#r$brg;Tk+vIo6$TEJ!D=hH?9QQp*zqXQ+63(fbIblgZ>@NIk=QEj02&trGdX zEG$#^zI5uT(l{mB77l6c0`J$v7C(5~TrIM8TC6is_OcHXO zMGB59E90*&D;sB)ftDvt64B;6F5qlmXh=hwHws_cywagxlNcRmlA`q%(FwW|E0s;p zOSnyoYlk;!Zj%i`tPmAU(9YC`)gRV0;l3njVLU&($5=eeJ~qc;d7vyUum{r!5X>Jf zUqs3z!{Tm6iRUIKJlgw8@roov@Rf+04W3}5c7#gX*Z5jWg=iF_H?nXp%mj|e2_6L^ zQJ1uh<=zxe)ycAj@9CZJy-IYf0)ACCV^VRYzO(xMJ%z@?R zy_KRwHLf{Cbm?1DkMK}U0Upe#VRDqxG6qD&66tG=Zm~;h=kI{3BQOYN2_c_iO=qUL zIz_tZK`Jc7g^UN2H&gFt#(fezlsZN;Rd=1bcZhaTSVC&hTz&+vijYDSrg z)5w8>az4;bj$JC`PZP>kI5-v>`Tpgb!ovA!?ca&|kc`Cj`>4fMOO|K?!NCYMS zgPcwixE2Z<3t$bL}lrxtqg$`EwjMNL$_`!0W5l5(=0x59)Fh6$`3C zz?$PGHXRTuEwavLV042N>Hd%sCBdB8^eSG?ey)}zse z?K{1*G5o{cSZ?4~cI9yFE;H+mcp?5{k#NIouX?jLult z$kIz-NT05SgH)9LYCMPzB^}p2C_-={zB}FedIcND&>`W*cH!dGCZu&D>UX9b_d5BjS;Bk z@E#-DPJb1lgMVcLEm&#$b?g(a5_$j-+#`g}Q%YyhN*Ubz!t25SfEW$Ur&=o)285|1 zkU=jnhYfz$vj3fDg*(HkigfoOCSO+(mFt48+{wBd>sPi^y+uhC7SXj-p|aVS8eRAN`y2#bI5zwj|X#4P}B*C=b z2S@e)?Z*-S$sD6`Snuco|7l9aq?GzElPV|l;Xi#FKYjR5efUp(_)mTKPks1LeU)JT z9{@oy;gpK|)FZrCANW%r_|rc>_){PH)4u}xli7f-ixSM6PZcNJDDHJi0I-Q^F@+5= zh#xVt-M%ogLi0_)4n^a^s2@&CpcTciXmaO<&a5SZjZ;7afcffq1?3JUdQI&lHz?j% z5dePasZ2Y@5Mf}UW%^)L;@UZML@kjl_Lv)#^s48m4J-Ik@*69+>*Z)KdL>^|oD;L2 z^Bg<+l9a0GT+g-+a5{U8&C}*dHW<5y52F-xkE_9#f&LdlnZwCLUxqfacN9ZyOji{g zRxB#0AZR(}7GWUPZvdL0>Z&8as4~EEjCa#1T zmX#h!99288cSbhBH)YfhchjE8j9EveBKQ#uP45mpRp5T>Kp>*Hv4ez}1yz(UEX>E9 zGR{(SeR4J(HHHs|X{9BV>!t`BNMtE)U)TtzQs$}R`#OvRKe9~rYigJblTbd*CN{N`+%Y-P-oqxY zj)!Q%81M*tSZ4M%9g_z7;X5s8Y+1J2O>BuReFzD%=|odx85t_PAnmkR8_7*?#?m=d zLY_9?ALeX~J9f-p;7y5&uY|&+UmO9fQ@Lhc3W<-zF&5N#W{jjsy`7v_CgohLs>P6FIO;=-#FEinj9R5zH?tMO0dj*6wk=#7kp{E66 z;iw`EESAIyT0wZiu`>3BkRwb%FBPZL9<>*i_hN)2*hc;yqFQE*)rlm=xHBe7W9k55 z=W`Y?g45hWa0of}>3fYZ6LzjEI)RM1;6vbh`<<#O32NPqs6COv)Kqf&RW+>0(H>~w z#i(`Qbd3hELl$t59g!xhGDdbnlhpIHRTkrwA}lI8lL&AH4;vZ6VfD;U+`5>GfFVB= zN5&k2&VunATodg^EYeyL3~-0HPHHj%A)Y-h5^G1ei~O4byUyky zKlDoEptVsm17klS>Nj05zOfFNJgx`hGBw8@H3*|v*j8W@;3D7HE^at%*%5LWR7Dg{ zm_>S`>di7dwiaMwU5`XD-Hc`X;5tMDOGzQ1xCaQ8rSq z21Rn&Cy@ZEPq{E35RuXEjr;G+L zGb4lv@$>*+NcI>z-_0V?=zZiV8TcNIg zPD4hU!15+%VwoCBZt`0ODwN}a$>Q@Hg&I9FWY6Xn)*{n$iN%3`3*6LP-Bj1uvbf$m&u8YRuLTA)oe{wf z^3zasXw?P;hmI@MT;O1DjG$?oJ}+X*%hr!2|Gxc(Th5{^DNUH3=<;QRMd z4%y&TJ28f}X>VA=5zyD2vbd$Z$WUBgLUR(7Gg!xAZ<16X@HE5_TYihQ;CRhn3mI%l zU@ah!h6bjll3VFac%*NV5;k_CIE`;$fVdQH5R5np&<3!4mlc(W^-exEd_vyL3t^bb z(v2ee0n)&7N8umap^CC$i@;iLeF7<1w56s}NP=U+&Kc3e>!>X)^<^=g5QoMzcBLSk zxF)4-?;@g@r!)m+T`#r4z4DHp62mg82GQpJ(He;T6$wsXQeW})xGCZ_G*EA#}Yg5+% zc0)}oQtiumq-PFO>wgaR5P;_XjhVsL3{N$v9>P;}=b()XQ=a*CFcQ&A!y$hU7AxLH za+7~D_2r}*=@iLtL=E>)2Z@?3L_`(tbEJrMTz|EeK1%jPTWp4f{^CYLvhAnBr9%fq z5pE5KnYf;4%Xq(FI6Zc7(jsebwOHb4_Zry7UMg?a2s@<2RRn)`~z8IMAH z5CPB;YE$8oqA4sYRQKvzi?9d*z5wkZq7Xt1CfphT#E9t_hTWZ9HN#4WeAwP_p(0Uw zw!l_j15Yq#v}tKfD<{*1V)Z+NBH#RrFM{3GQ%~^#^4q6mpt-B3{Ev*{@11)|HNf$p z0~4iq;FQMRD{NK@5J$mp802Sf?P+3oWIB_oHDHpc7x14R*peRV40Tu66je$-48j)C zB{=9IV_^tT(}SboP~hNk%=}Fm3=eJ~3!WX!SIc03%2UG7WCriS(LbDg(FRD3DO}DR zCCAschaInI0Xdctd9h)JcFP_~Ymm}p)J%!F)13(!O$OmL60IR69L!)wLTk7_wE=7n z=_a%60WXWF)_olA)TsGVLGP4Rh9k|OKJ+rssI#$$;dlMnG%?u>{D^kA)F`oq=qMcH z#S8_DAsk#!HG_}PA`tqy8YQY`NKD+KudmdrEux~?p{8#>K_4oj);r*#$N}Y9wad{=ntT4umy7OV2bTPT&+S8ulMoy*kAui@s(z80lQ&BKZ zIZ=x@p%I%IgsS^kER~Qs;|_8mWrSr4u1lhN)hMj)82CDf_+ZuS5Nn%5M6qn;&Jd_h z`bE`{2J9nDtN^xhaHpr=$$@3*g00EdlDn*|tQRh9%x__gj$oFAF;*$S{2bj$IB4|} zAZZorSU8mEDNcd6$tb&kj~5~4xDtki-ZUyQG`*&X`6kRt0r65nY`xj1ws{HqDVB!i zS;{X=uE(@r%I^AYE7e_*T1k_T40ojIDYIEWrKG3rGZs5|YVF+Ar)&(NHf3;~p0ilV zZ0p>nK5I!sHT`MV-Vh3gkvg@NNuf6B%S^tO+CHVbwTHm#Tl=khsSk9=Cr^AXbp z#d2P$Ep;Q69;F_R*}l}I9GY~$bVIeI2bun~Z?6Y|=)c;vqf#q|g)QyAHMA2^`AADt z-HTv24pLje_x9i5ou64Ztlt?)j{G;fR;KVwQxv9STS_TYw3~BVv=f>F^&H!Fh;2K1 zXloiohvO(L;WeqTL8(ueatkc^0}gDO5_pkPp4Ryp9tU78XKMQdH@xb^9}tt;y>!qkca<{^!SexPN|qU#e)BM%B0H5KK#dTT5C5?b z|FIAMu@C?8{{jA^JpGh|OTp$deFjjxRO( zrZaFXo~aoKgBY?2miTZxnLXB{i$V>bR`5BobP-cU8H}-sBq7EIOQ3)pF>1_(JwiwT zJcq7-lr?dq4+h7?d|hy?$+Xy}7HXrFs(8>2uR=}K85Uk(Lu{t%3jN@mv_vSXiY1|> zh>8MFD5=YfWkCTs^!H2Nm>g(VJkq>SfCyK$H6hj2HG8BMH9|;E=zpe+Ay%v&6k9+A z7s3N+el+QGj;tl{mxvl%9EOsbbvRV?t9OKz1j|G+W@8kf@BpW_c_s?FuWT4dM#5ddgBkP z0hI^jnIhmQ03{%uSc+`v7+n}mV2O)X&BeDc1{dP?D7#=BxKPbWVedDG=9-FP(O7Lo ziYn1|hl*b;$SSB}gsdcZ@m1D8s}ip}^)au;)_3b*`A@R|*7Rw|C?%fc*li3i82I52;!%3;cw*CD=BH)7=dpzr0KYrjf?9^NtR><%9!EAvL@aI z026Umqt8lsX*@CiRKOkEskF zte*3`u(UkCqqkzHKL%YU2G0S)O!q-%&M5D^nTCyjbX z-T_o7j9=oYWV&1t&1JF1D`;67%MD`qR)+;l%9<(7S!E$t zr?FrwhDnNL{*+bJhbmZeAT1iVI0peimJrC5oC$}L?T`= zglf5Q-SVYMb&V2ENK0VFP6pgSZefxhoZH)X*P`ld^KK6Cf^SQC4Gr(sH;k}&RM$|_ z3kO={Hb}E>1S(kh0KZpkR=wBrteZ^^@g8+8Jb&4BFRtJBbV!>Jfb=;qLerdT={plE zJ+{L&-4S#KrI&V2Xo~{J7MP4A8B^j6GD1|OIXXj{9iiu)v0}gaLd1sqH0hN(Q%_ahw&m|R8Nt_54 zgD|6wnNMIxbTJRR2GEFpFv}*?@yt>{YanMjKwr~BUz5`SEmBI@AYi>Ahp~+I^Z<51 ziND$P&5(IuD^F3YQ948Z(APNJ#)c*bp=vfZ$TVv&rOtrBBvk$C#TMm5XliI_sBW0+ zOf|(uyB9BVX?0C;L%|lb8L^?$>wO-oX3yr-+%TtQk+&%gC%~M{3L9q5w;<5+Gw+1&YuL!CTK9wf_RZrWoP33!21b(Jz{ zzOKFo$ZiiL6s$vm9gNpA!rOHVfD$c*K{!@x5!FFNe9&uDq;#*3)2$`_NGULqk+V); zHnbTjoq=#N6c_aD)S64MwnE;S0xFsTE?~KKgJsa0Oth9q;o}hxMI65x19J`?0i6l6OC=5UGs(HeW^Nj=dB{?eophx@SsFRq zMxMo!p905k z>SZh9WQ~O6G^v-_X=xUwmneQLQA#$?hU3lYRWGcx&uq{c4fq?akCnnkw)KGY)pizU z7P&z=s98yjr!HE~Q4M+(AfZoMn<@>rMQs?5CTYWMIO!+aZz5@fEy=Y9Cx1{68<)#m zDClL=(nzQ11)pZLhi%370?)0LOEcF>@8M;>{}QAb^R#1ZQY3okw9 zn9B+aHw+!R@z`T8KmPddo^ZmIBSu_NTzu7-F;|zAY#K9Wb7|={rKQ(-Jl9U1d}C$h z^{1S2b7kdC)27`rZQ89fXWlkz)*Z8F-#%+rcWv#Rr=Nc3ym{N^&b_m-@$QzE@6Vrq z&!R=!&pPV|XPSDTzTb{*Ijqr_rCYNJMOq+&6=NgcXw~wwr%_N z?f2h*|HBVI{OF^PKK9sSPdxF&+O@kbyX+SmH$Hj!<-fe@s;4(?dghvIc3*$}b2s1o z{LMH2=N)(addrqyZ{50g+qU1_d+&?)-uu!IfB4FS55D@~gZqB`#x85#vA0T{m(q}&NI&(c=p)?&pr417hZUG z&z|>QeDM!2zx=_zeILH@#-Cn$?T>H0_11v{2lns(^ZW0=|K~sd`R%t4{{Hu$y#M~E zfB3^^fBMtspM3Jk!Gm9rpHDyi@{2G2ia-DR_rL%BAI(DlK0hA#2lj$1?5CKSTSb8<#pOSx0ZA*EnD~0#HNPZa)yrCQ1tO$sY-i$aLMlX=bv6%)ql?Xilg7U z^RAq?q{byVSwk;rD3a!9`wE|_RyO>0Q`epOxA?NRJT!8&GVr=vv-=gdYnx6l8a42m ziX-mYFu(bduKo9QU9)b_&h7Q%-rf9GRn?m3Z|vW)@2$JH4aup!W#o7Ew{{ne&b@6$ z*E@glcjwHxW#_%G?b&-(R@MN|lAYiCBKx;T+;?B%nyRaI)E}w z-czvA^?2_4uY7gRlzzW0ANkdm;LK;1#Jg&4xv3?1LvhJbSx@}^_Mcz)*FU*DjWY}9 z7Bm+1Ys&l4fb8dPo1Iq_9(iEa>Op(n>s~uJXaCxUF{N96SJgPux(w#?ksK`HR7fBx-a}} z`8Zd;H0F`(sv-rQjYYZl6%Le|Wtj}6pxGrbN{8O8PYcCk_ zhqtd8dFt|YH}sz`uPIvopS#u<*2SLN(~$r1=vQZ7GO7E#ZC|aP>0UEn`}v=3$liAB zQ*-KcJ84qv z*cDGqzUi*#pE$x*+3%#zuDl2Hlagy&`Ma-oyS|LvHEjOXzK7Ol?>}bruoI^@7Py`q z|KaBop7`|Rv6`#s{hc*G*!#_N_EdTY4 zFOD6%?XhQfT=vzh)<4cj?n@rMV?|APWbCOCvDKfyJ8Q!M*Q0losjH_v@w;bdR2{i~ z^yo|8Y&zqF;=%K#$?LLxe>?8}s`G0%9oH}MT<~pMLpaUhy^SH~sIn zUq?UdcjAhU7ms`8XYN^*?-zN0(mm~lU;gKW;qJ9xPRQPRZslEt?!Vmf-68i>-FsoK zKmYlwI!Y4RKiNOHaKZbo=#Zz^6vlR)tvtNDsPV;3bFQme_m#iotuH+9xQ;%sCU40u6224H!R5ca_z@I9k!+W4-E_AE7#>*`pWI= zs9DHZNTDNP^zAYVhfA^`Qc0BwG*ZVt*>+<$AmweoRK&g7QeCy6v4h(;$wxH|U zFSZAw;&3Vh8%!<}+o_yxUWe>b`?XN%hqC2Z)e``_K>Bmg{!`-f&uHviDtR8i8 z{NzW*j6N#otM+|=`z-H?QNH$B56{gjIcd#|z%6$j(IV#!y6M>QI|uHKW_MTnx+l#2 z(o^L+sbXN!2S3{M#NHp?{N~AR{m-3Rcu%Zr)oCZcSv#aFCsKM>&P7`5Ksm9u@XVZ( zmM*#TrJRCG)(`gIUR2!u(LVQ!n??+5AKta_z|>O)gpM3Nuw!ste&XzwO;7LMG<5z4 z+2yOU*Ebdii+8R4;s-yy`^JGgzkl?VImd7KX;s#Bb;S?7^>&T)Uq8EW>os@0{;X@{ z8K<9KF~^--|8n8pl3D$4EV-+2Se10v%Cqixbm3FW-rRgc|E>2FOgV6mdthzLtQWdp z{O|D#AN={oJ=6QG+V|9)Kl!rvbl1Gw?TWq~UUf|5tM|`)e(7CrE?M(XVb|ruc8-2M z?+t0k8#&uYow{@3-#`9ji=6K|dd&s9CJnp;5nCH^!55_CwbnbAH{_@2suA zan`goW3qEMygbjy`yMa6XWgQP z6My)-(O;IXIpS|w*Z$$k*~k3xoI5(Q7hV-BIJ2g{YQf^Mq5BSe=6Pmx!TPBsacRR% z-npR*_7-_Y7vxu!&l%a3_5LfLZ(Ue1`^1B;tp7e@_>(^$xMtvUYvy(Rr7Q0TAJ%W1 z*4A~xL|@hmq1uDTH03S&ub(W<`pYF%Mc%9*6+iuj zXKb+kD0%HyR~D4K(*Nv}W;I=vbA8+M=g)lX*opaTfBT95z?tjv8j73u%d>v7<9C1e zt$c35BOiWv)yc09m|U^6-!ZNcQ;YhKnL42;Sn$AUM~#1P_PE&I*FI{#^OwW79C`7I z;=exj*^M8(Hg4*u*Pc_}7&EV7*`qbn4_;9CNw#+4giG)F{)$IkkDPG#dw<(Af6Bh6 zYiG&%m)`ey-m?>m*T%*#?mG2@zdm*IzWjBr{_gz;Dt${{-+bx^u9>m5C$-Ci=HAow z!tlXcTr-XIp@)Q=fS$x9hh%uN(HW?CP)1u6SD-(7if7dQi>p zmMnIkv-;P^t{AiHqlbTd|ApgSle-H>@2SW+!PPZrdSymp*x$w>$D)+%|$W#23K z;|F_RzU}GdliNmrdhxQm-`V_^&YwJg@_XfPuXLT$-8gvPm(%VaH#&b-e8X`?(o40H z|NSFAI`XBBA3c1N`nTFMU;Q6-sx<6)*Z#fz+*QY1y5!GqR_(uHMAqzO!?sR5d(q!s zzWnx|KHc`a+xoTL=50&PE;+LD-u0C`|8(60W8eHvcFAKU>kec+a>{`Z>;L=lN8NvZ zDX{aAF*_E#nNziO!QCU~oVwNZ;^Zs7Sl*N%TF>!ilzKfABxdj+#s-t}z5 zpAI}f>cl%=x$Gj>?nS?GEi71n>i$QruP#`1-EUm2>kI1kj34Qh|2Ss#>uneB`uw;v zFYEXHNhe=;O2NiWxeK~;ul-`p$bf&){G4016*lh5sX7qfUbFhhGwW~2J?rOkmiNXy zAWvax%j?u1*3@L0mtErCP`PN``cwLSHDqftyJFSms`wk% zR%Wlc^s!f?B~vauvTJ$OKBJBME}#Fcg0oo8RUBkQS2E>}U-J-bVa z*3_Tta^*-%}BFi=4@v#NktV$||0Mva|#)X_IxQhL)vLr)yOKkIl`)}ZRrK`*x7 zu-7%>VAja)2`fLDSadLJ#GcC^{^a7ktp2}H3fJx#KDg_`<+&5D>bT{SeM?Sy>87}L z%asdb_dOe4^H^2Z&WrN9h8(-MeCv-29>3?z6~1K;eK{pQb=Kxj7oD`LxFS?=)sF9c zqRB6;3m=&bcWfIi?O5dAe8LgCa*z6IiJTa)tb1Ww?I*__wPVT+8wz8a68(n^y!GYV zUY|VY-YH|V8?SlvzuYIwO}XpNO?-aatd3J3zaeMY_lp|k{$GSzf^yk%=PeK6#--@bg?fU{#~#;%R;$;lgdOK#O2 z=T;BMSu?%x>;(_Jb9{D{%OAUT+?ILklcCP;tn7W~`-Uznyd+C$x_wku|A9NZ@4hxK z@XT!=tqi=d@woA^iL<8_U41a8^W%bhuf5`m&u=Zro>$Pl?5JIN^|5X9-}0=N`hEAy zk~hB$Jv-J_DJ?$g!JPa}w<=4oS^n6>x8A+;z*Ex(P0Vh|Eqto$u5lla|Eg&DfE7Pz z`~2uzuWO$ClVaEOQwsZCbJ?q3UYRqhAW_w?;NYa?dAII}dmpOq_me4w>#Dx*$;unJ z|GJ{CJolY9-SWZlPwbkuW5mQoqg(}z6E`fn`>4viIcsvpO`DP3m8ZCJ##S{x_jyI< z(-lLOWLGr~m>$~rvs;SR74-l02iyDY&AXs+z*z_TO)cm*enteQ^32wXZyo?d^Z_J@;R+ zskpxCZr69WPbqGn{NRAQZrQPR%hA!soPnF}FZf9v=SjuzAvs zqROg%m3hAXIk8O-S6$!_@6VZj$?&Ef10s6{1fLsl`lg(czwVfKT+z&u+?p!)!0xTf z_T)708Ib#5KVJIyBjMK{iT?GG{~b}_n*I;H<63?k?SDoB{b9eO2mBYX_FCSH5L}oeyB1-=*&n?GY-wP>{gcDAr~qqy_~dBP5G~aC>MlEMd799i%|7^y1ln3bYmWyYaAO`El&Xiv8h(zolCC_hACJz~6_4 z*iuV>ITV~0b}C3U3X$eLt>ia=$ijsCLjK92CfTP^2 z5g0HlUiRBciNjX+9$Cd3jB^Le}R%6l%@@hH8&{GJz>snP=zK*?--vHI3S|vFM zI3GAA@|Qsca$GZbl>mP)j3f#9C*hS`ZKF^OW%*~RNhu&l^%2PWoQ+{1MOE@v<3XHr zJQ;;akOp#erKFO##PfwFiFP>w30RP4qOop05_u1Ks+H&lFcet|hFWQ^ixig0E^miV z0RlQKPMM7f1`5RhH6=(XL-Ws+#7dZ@@oHRT4-Q+A1MTcn4?dG`eIaQMftvgeAR(*Y z90HIE=mhA8$TJ2>>4@@y4DhY-ZuZ(v86X_kEGe`Kd9bdoS%MU7in#)xP&Aja{FZjb zfC)BmA!PIWj3JX@8bt!q-izobDqU5mi z!^Y0fmo+T9I=QSue}%Y{xdIJsxf0Fck*bq%TohP7m@^p=bW>^5jiFORM}}Ulcg28! z)MPw>WxN#5Is8e&Ke*M&UP+-MSs1c{ZAw{GNt81}YTS^5*xq=`&w(}w_W`?_j?z3# zU4@5Mx*E@`nWQ4tEMzlh)8+|A=S-+5Z&qUE6DlfBInNxmYY+CZ09LIU)&B95%POTN zB~0XuLi#o9chI&PxK9%*<#N4}7tOGFre0ZLlnzGzWZZ7oxGq9S*nzwZIl0J9y*aZa z+GeFq*G)=<^i203jeia*{-j>I2C4^;Dba;S35bc>?79kx5`?}mE}O0q21A$Tq*JLi z)CqNj;|dTb2r}DvEgB85-UWX*JIl}%Q7ZIrq-e2N^>j=ivcSah)01Iffyo)M0NVk< z5Uipy^#BVKIyg^Xk9=3vFiHcH2l2m+K6Zfg z#4HOh3|rJnt&O26gKeXtZ**eA#I+C{nz5+B#6b@Gh0Ew<{AV`pN)jP;3Yu#njX=(k zCpUbwlKn2(mWso8a4VPOKIIfe1?V6$Rkkexj0zpsA(#4EkO@f}OMz@|63GTH6qoYA zodIVZBVmdA+-A>m7;bh(l{V4)Fd~_7o98@^K{=)A3p-R^mrCa^%stAJL;41zVVA)5 z6Y)ubGjcL3xMIQdumh$V+QODyRdAJGFbi^E6lI4dBX{Pu7=V1B;Fza$P%cGkfcP?U zBghLyJ3=DEFFg1F-Qlbt=4~;x^_Nem)NDq~STF2?luf*Z3ogtSV%o&Q0M(I^r6}Vc z*y))-Uc%8%XrW|D*k#9}^C-g3<}Nb|POntdU}R(|A(qkFA=`kZ6mCb>!h07DT^H*W zoC*BAX9H#d4Ni7|CIG3v6zgCiR(CQRj{*RA(z{tVXvqeL5gxBG| zU3_z6b9fJEU)dL`6z@U~DdNq~nW{yXF9y9@m3;))1o(9(<1rvUH-Khhe~sp3hnZ%> z)L^EwRyZE(u_E350rFW-L?sZoF;}=k!B%KZ%6P|?u^=0>!d5aK7LnZe{nkE|h4m@K zkQhto8C{4VJ4~|U<`uIHv3=Q25Vvun7_4d3*{GV#JZ;5{u>|ZS+)}_Fii6OCfvHP` zG5;a~(f|lY?B24N-C@|JdA=yLBbGE4hph;^p`kB7G-6&j5sN2{)@&Ru^iYa69sFL8 zJOZ>9FScyq=Po~O%sRszX@Dk)b;UAlGqDi}b^z?LYz4eE=Fw{yzd-(?VhJ-9>`L~s z64+rhzoD^y3GPAG^1PWMiPRC4es1HEBRKiWdnoYUR_9%vY;fHN)(A(#Dc}fs5mmuT z*u=av>QvfPAdOLWr|jW3N*MWYG)lZ5JJDnMMTgBSTa+={`r=00hlmNVU^`>16>+vZ zG_G_IJ!EG>;r$0SbR^RW*c-qpn7t5;jY|-KVGO5PrB*+9;)|7`RzkCxfB>KKO}6(S zEcG0?;nEVbZ_c<3Y0Fk)IFol8GiIbK9qtUKvXL@?UW7H&YR+B2o~cb&m%*lHVi4#T z(7nP&X!`Uiet630b07Rk5V{{o_gH&+8NtR~1T6#9-Tn+njj*&nM6gKkt!j0fjOE~0 zzVRCJz`|soiLx4~8g!7h9SLhd47n;1cPU#*3juTlgh|~=BDS!h&~hFpJV63%KO9*UFT z$sq=OD_e)QHP{!60%b-i8p!U9E)bT|QdQD4S|ygl*iO+1G`5M{K&qpl5EfhxS|;S4*4` zD|5Ui-x31OaNGhXWe^9Vq*BbVm>v=uqL9FXVSzEHgTliPikvlWlN3QO%4c__li5^z zELt0?sP@i+XTS!JYt|pS<>8_RHHA)iHqmSH+Y{r~TKoYL-4Gft0VL_^1Hi#K6JGN>-bH&ymgmejKx&uZu3G6fg_(rm6 zlgj`F$#m$WKv@JrV6zhhbx;8!(euL-#cCFufUqxkA~g5QW>Q&_8nUvvoue6Lbtb_m zu!n6Bly(byJ;qkWKx{5;jkIN9YaY}VwNO}UUtVbeY-lue!uB!}CfTE)u_tMOWG-Hv zW`oJniW0yEFJ_xWC<+yL9nf3eEmZ^oItGvw`jzIe-$4FU8Rd>b@^*(7yQQym+Y*i0_XcbxZ9tW#LEljY*Y(h> z>8J?`;Xy2EN=Peu@Jo3f=5kVvyero5v5t}PH`@ZZ`e=p(a`~!Nt9Vj>(2YbnmIWr+ zJPK-~o&yf9G&_N04&z$IDWZL?;uZ(RIJnJ;EYk4dh7LfRVG!8F05_e;urCDp-Zn6? z;bp0Pn9*z(xTQ3w7*vaR#kHBX^NUEeBqV$QF&&NT3|B3up8Wtd7#ODUH>iWn7;-&C zXAp(w!oEm<1it4c+p_h{?=G~O`Tb>+nBYh}X%(V5yow;EGkgQA;JJ{>(oBhYZlfjK z3%!rW$(ApcFkEY)@x(V`38QU2TLEC7$JO#3CafY{9=@!VMKb|h{a~bvN&JK2=hQ(3 zCjdXrMeGy|F@bHbgGGfZR4`@e3-^nrv3pz=S7sR3YXFbU~x{dB+JeoV*ILBLd)XC=Xqb?R5^ywzo z9B^9#K3-6|sK#QEuM)LbgpM-Pn>oD7*`i>7(Dr%Y-YjCtEN=Fi#(<5R(<@p>g?bj| zTqv1>XtM|GKW7PI8ZJA?3CK(h3@kuehQ;+j*p9Bkx6y>~PAfP*EY-k7MzVL1dQdZn z)**Qk7ie=bWhMsEXh=3-tD9INH_9k_gBCv8l_3AV91ORG(iffGlJv|@=g5EyY_SwE z^< zhKC&Yvr+Q}V<0y$=eiTlt?LN-vMCo~UUD>+9!!Vy^o9?vi33trFi^CUOHiaF(RYMm zL?qMw+*Hj@nV@)$Hs#8+U{k6h2FnWluiFOMMc8N`R5_j72klcH+Q+D@s)3jZ(?{)t z@_Y)||0rSo7S=HU{(EJ0MWxgJClngRe;<+0sQu5V{m=gZ{?n+{YUsMXJ?)z7Ha zYUC=S$!TL4L`C~op2@7F_N_ajSnn*BInYHGmNK!*ha*WQjKNFgF@_xEsgCKTqR z!RgME%BE8&#|P7(4htOQz#A$7agD7EiXcHhM_y;?WItoNKo8A|UC_9+EFN2F8mzG? z#+r6!ydGWSBH^MSJ}b!ISRL*lJs<=kbQ;0ATIErYM8r@iPlFCJHKPSn;Yt%-4jK&^ zh~hm#U5PAKCNh?HrNk+_V96r%PSQZ6K#dbiAcR#4!XZbvw%y=>M}xy2 za&xscR+?rC)vhp#X^;*O`cWLO^5l3vIuI&=O4?vX()d6bP5eat&(&X?Kc^SBh91|m1>8xxYDRECwFeuUy8|F}VYR&JMy{S&w!8|_HtUn%h7RP!8@DiW7sNBfX z42~3mY{QGeFebvd%m4{cRT+qZunzmeQe9tSrV&7d>V>gmz3WN?_6i_^!NOpR2kv%V zW&r0J76oGyKzNMK`vgk{b$W1_v0`kXSYgXbMq+4BWE+0c(2=vIw}t2M`U8aT#wZV$ z@`_h--Dxx=psfz^8pCN*4JfXLF#*xDhb_ARwle_O9ACE%`j8u8}mJ+QC&`yWI^lU&ge27rw-Pg?lm1Iv)Sf5U?DoLpwO)_eQ zHKN}nS9Fqw1-cdi0WH$Z8rzx;cO-kYZD8y4JC`K`<9n(K{*7Gp_s(}4~1>gO5Wx)%1^8!(nN zv@UE~+G?;A&2^2f2OCZEjk?Bzjr|)M=LJ0V2Q6u?Z)q`_nvI6VOBOZM&kGn0jdK?* zo!8K~z?j4GH8!;xiy9U;w6a25n+&Ls7u8VD^3C@wu5X^Zko~Ni)3B(a_27UpzoE4e z%AC&%tuvO?HMcg*UAm~Q*;ul)c}Y`CJ*$46r?IKAp>cjQtEGN%ePb&-B^p^(M*V^8 zhtaaIZqXvFs%|N3eKWRiZqt&3n;RA^Y&8}(Et*%~+~S#2&stVDXHh*>#X2>2QC-90 zfHALbaovJ?%+myGl3VpN{Q*AdM$mk{d& z^#eD&FovRl9#W(SZm}4X!aQ;}15;ViMzVoqh4ezT;1c8M38z0J0)^0wL0(l`>Ij1IVu+TLw1`M1h4-P~g^b6nJB;Y&=8o zv(zkVzJzV}@WxB|kTx|~f`Y?`ddwrp3qu6!$Z`oPyCEc#WJ#P5uFE~1j<6Mr5V)h6 zLQhsMxP|)!V}aNXwipqzl=-pV+Muzl8wLhqOQ;qggdUA7G+f4{$QO)+u=WDlg0MWY z9CjwM4rLq*n_{Do!#u1o4*m=>Yct)0tp$YxW5(F7V~aiD=|Isn>O};YF6b9xoftKw zmp$xBW)rBZ!Ppt#Bc-gb)!^3&sWAE2XZn%`V??@>(jOOd_W;a#Kuj}0ZN|X+f0-j- zibsRO1`Q3W2sN#aSW%{hs~T_%!ybuGtlfE_JD6Eg3fWp1d0e$3 z90F`4)~Q$;6;YNBojgdgke3!nbxHNCx^$#FmN9Ww7%i-})55U!7L`CT7&sJ@!$`-& z{b=!y3b&E*Tfb5zj^jpz+X@qDEPd zm9m*pV&rIOQDQu@L9m3d!~b1zV_F?kXW520%jqH`gAz#}9VRkJ8sYQ;zSaX5@0<`o z0*jOO4nOSdfr~8e0|&ktputnS$iqSH@kr7w13Dx|nJ1+%kNkwYl+R{H}py^2CvWN>DbY_rnRa@6&vdFyIV~ z%Yyn=^2TwLHWv}^Ir|}N*St&ej$+#E0?1*2{07fnustEKUU`=)m>H)V6!lc2bZ+56 z9109TfkvQLXyI1y4tInjD+SM)Ovk!nz(&Y!3yAw( z;dkFG+d>d*Ez_R@mJUzxJ_X}XJ(9KA#ulbBUq`_ZAeoMWLt2tYGSJ6bcTp3U@StZI zjXU7c+mvAz;ekWT%6c-gYCT@0ZNcc$9jPy6viTAe943f zOj-IMeh?sSpu@4^Px1=A0&rd-$#XWzqXnm9EK)Cb%%eMq1Tseq>NsN~1K4t7@qu&8 zIzdF$mrSozRHZ515zDy78nesu=+dam^qiMQqJCChxLOTCi4vID)WFPma#aa34`Ns}H}^nGcfRA| z9WG~dES*u~U`fQ3aI>jcM#GVz$|uZiYMd|XwO5eio9dxT3<>WptoHD#i|7`x{MpEh z0pg(V2AVEt*y;`oHq~szvk;*xEds8{H%fMj2v(uI7`Ip^TtKpr^C$U2MhFHbAEU3J zq&f}BU6GrpM4V^r5RhO#`H~~TnHUI3fsR|A#}WL+`Pv!&#RpeS#JkTc+y&kQBi6as zkn`SI1)gsO3#UV@Q1P}D&I(|hwQUP5FXrNs2|1b^o~Jt#&}U- za|zfc@O{3LuNNF9SldXsY^0TJa^(d>T|Wo47;y~0B82l&} z$;QJxj7d_P&Iq4Qd$Y69O^T1KuH5K?&JK(ghvZ67Uc3VWx24Kb05>_L7-fgZF2dzY zKZcfwkY_T)i6)((kgVb;V%$Uyzb-Cc9_P(R48O)T$1;f9Y4&6(Y#0g(fPdCl41ThD zP%@VUc@G8ZSZT_uZ3=|0gfhg(g>g~t3)1kZZ+=fPPZUkE>%Py+yW{nH%tX`=rKe4G zHe&!AG38QXg-|MC&ULA4sRmPE32xmVkZeLUS-A0B;OVu)CU`xCU=+ONnVwX+H*d#X z;6nVKJew;gHNLeE3EY|*lNo+#Lc*_ue;I?I3myS|B|x@-S9C`np&J{mvko&7CahN- zTuDxeb~5C<(8IZ#dq)~fXgs_i=ajnP&IxJ!4q-OQ9omGRY;_0R$fSRKvD9s z%DBIhaG9YNAwBcf&o^Zdw&XqSyV3RTY4!vd_2zYSy;w1=u zV1SYuY}2s*fC5|1ypQ^wi*$u6#Dn{&gWbv#36AbUvA=0&;X;ygN%DBwNB&{oGuRhX z+`VfJH(KF<+mX))yM;_p8)(}I$T`H+vg}ByoQsFsg#FSFSA9FzkE5sQRy^HF6afRmpw@(GZs%+t!Yi?1AuAF_1sdec3YP4OrA78mXFwl4RZl9>`3*LzNVHF7X&o zTJuY-+`{mfP{Ik^YuaiYfSSgWAQWO%w6h^>2gI3L<0wz@a&I}i3$Y zL1+!-4hBohX9Ha*W#4A7KY9{RF)T3q`DFv^6Y4CW3pSOOyx-fDtN@|}(pmDE;Rckj zZP7wq>Vo<5LQ7EC(Ri=)gxQ!tAw)2}>2RMHRi2On)z(}D&dP%@Z6;str2Mwu=RD#* z2a1@q#0u7^rc*zwcZ193xg3Gxf$OXbV3H>+`_0zVs^L|Jd559d;wr4E$^*tS_%pYq zg_Pz(=D<}Qc+QdFij#bHP{1BV{81@mB#TQE6}SYB8DImSwlatg%g+ms5aZxDX$6E}(37_p><@LoaS>22 z^xH)y=@Fxc>P$?)2wd|x#Z|k%O%ee_UZh$&auPD(Y?J<0;IuYtLma(0>^Oepp zkkceOFQYMw-Q@cP^9W_K-gp<9Y}pvglIeJKyjO_16jZj9^DC{8T6lwEk=20uBtyu$ z?OVRwgP_UmHQ*h4bOdE~KZ2iV4-UVzMj}YEeBrTSCgU%#%GS!D>#L)X@t94$qGDuD zDwH>@t#|w|RaM+6Ij#xit&TYD?F7RGFA|R$y!v@S2G~V|D-2ZBxQDgtA_c|F zkiZeRJ;N)*0edt)5vU}~*JFl-s07NUdj+G;YC%Lq^HqIx7RLKM959)SSHQ427NPZo zKy)f(rcMAm049%hoHM8tRg&E?J$Svvo-b7T*SQR^AaOAX+372$_H{=!8p++Dn%z z^OS2NFr^Oql5imS zB*&&<7%O&UP^- zUr^ubmxu)6Y$gdL0}bmuQ4_k$m4K>kVD+ObOu!ru=xJY!-Tsr@fj+OPpR3+VGrtmy zEjPiEY^~D(64_cAvL5f&MCGs<9j<1J9w&4>H%g*N7`aB5B6MxiB-eUgB&Nao$&dKnF7gxe5cXq5G^oc3E{Ghq`wXYnxqK?3rvyOZiES=iT>w`dGOfA zA)xWo8Y;fMZyH@zR+x4^+Yo$qDwoX$acw`AEsnCZhwxiTH5Zl^ym<5~k&ilKb0R0` zVE#eRQjW=Ow-Ln^Pd1d63?5C>M@6vLoO!gZWxc;Gu|z~P1xF_b(w$q93VoO@%77&< z{GPDBsd3fe_-TmwJd^|Ju0%()rnJ({JsL*MTwJYiZRQK<*i=}H*qbj+oEJ>~$#VK}4EG@k9Neq5&gv=%vuFIMPLo7}XI~_+GRkU0M(nW2N z9Vu~ETcSt&kO8Lo2p0#)%lq zjtU&06v8IVgYXftOxCso#mGSL8MLs4vkxzYY-iKYR5+G~4JNk?V}^uuK^U#sV!=rJ zcRUTdVJs8ZUDYR`2V-q&cfLn)3%Sq|BeE=OFRPi)Ds!I;dL`I{&iuR;Upgy1ySCByY z2o2H}xWuH{RRI*GFiBq9^mzSjaJ9WW7+I6piTVU>-tJaAcYrcCV~Y!61#V!r`|#u; z8&73#g{l7I)5ruEwn*}bcJ17QiE5J#AH$YnEY27l z#+DD-=?8EsSkBJ8@fhX}1|d^0h|kLTLsG9fbCk>K^a%pOrk&5&6V?Q|4N5B7*Uqr4JyQY9pS z13boflnuC#M1&OwT3*?O6i@ zxn7fm6a!Z>j4(w6Am0N5X52T*Dri4zAtph6`OnTEEdU>O_0zIKQLdX@o`ffHD@YGjuS`Kp7X~ zGx1ufHIVDB(mjSxDsmagNtK?Kxg)ZumBD?<=u;h=Dt^L>&BbU8?qM{rPhdE}Rj{LRpYT#hvl|oo zlZ=pg(Q1jhiZY$J5J1PB*bstBE3%O32EKW^kA%yK|tlpekV2ibc8G z2s_^D_Q6ptXb;L9RD&QPdjh&p+tq=jt++jGhL_!8%Y%1*TsmpE4&ec=mk5dYxg-uE zC3CVe;Gm@Bw;sxh+*cYnWO7Bt+ZWm|%c^-?G2!lx<>*R1ygK2smfp@a!RMgoA1i68WIxXFgu z<+FngsRgH=kX2yxDR#f)PF-o44Tia_hn=jRa5M_iAj2nX?Ka~nI8&XjHLQn>Zml#k zaD`wK!J3pXGv(-d-GVPrS|6J~= z;r3cA1GUK#QF3+!65mDqCU-~DwcjGS-PTLP0pK^Gt|YtQ@UuX27#?$jQ_kd6jwg|Tp3r(*KhNkWltO!QJ>#^YW zf7EJEF)@F1RH?T!I@VaVek`UHjSAW95Uw&7*jzuqzPY{`RDT5v(aaoeLktXm zJ1@iw^|+Mbp0lOC`M~<-_Qtx!_3V=8DK5^FY;JSIl2%Ga-2g9c#kRZF2%vmk-IkLN zGIS!KnR{A(!zDL+iiUNC$0KP$m_*a(&(mv_GM37d#LJTY3^xy4LV= z2?8=P-hi>1?T})Spuo1k&XMH>?_BAMM5&)8S&i*%k*Ybz5@%5Ua%N0mS_t=bun4or$b)c^JhqW31d)koyQ1 zdIxKP%pyoolohBI%Vh1Ml>c@7Z_QYU;J>Fy`0vU}qoT5=B2-ho&nW!&$b9nRf7@>n zTU1A3{O{^1)m2lS@jt7pt48s^0AxU$zenOTivK-||2>NTJ&OPRUyA=d8VU4&76_b^ zAPx6>K=k)f@b6LZ?=1lT9!3BD>Y{(!6_|2oL*a6F3za2*kc)T{bznE3$%sU65~4*4 z5{h`3MzT}cwhJwQTvlGq0zpGJgCk8S($eNcZ6Al4#0LJ0G4x+|-okhvj>P%ctk+{?() zePQ9v49ymt_s2c4OWn=fniF*83hKsgI$>V|1x8p5E&UsyAsFP)qH#7O5R_M7zzK03 zcm0I%XDy{+R|q3yAgP=U-KQym7UJ-3Q8L2M6>a*sF#$~y_DoNm(m+B~1dq@l?S*O*ZPeWGz}wH%-b#AgFeuFJ&gUfFpkR~M2FW=^$* z2lgZh<<4sOoHJBo$g3YtihnbgC~(K1TP@HJk;L$^Gco}4Vr^=705~HFS_FWeqtY}@ zC~bc@cf(QXln-TT)@PuPLz5C}8Z<&$vQa4jUB}AM#zC5T$+g7B5%aK)NSIu{c%XV+ zN-TY+u_)1M+&we6YdX3sfXvvJ(ZMAT7VjlMUf2*sh`n=3@syRr@{iRHTX)E zctXO|#ssc}4hZScA^;hn`G|?5Y{n%p4&}oZc*Uf0b|&@?1E4~ur?F%ZmA4Y{4wQVfU(tfFFUAT$_hp(w?zV^c zSq19S7D@o@kJ}W-d=1Hf$DDd=F7vCED`nOim`_V!cRYO__#` zLpq$W;?ic=j_J9#e49JM@|6=pmMZ2pxV$0>ID)xI6E0dPH?*oB3q%WcogApd0%`2zt`nLlAJOF*iDc;r^whwm z8;=vxf#CUVp3chAISVFCXxpO9sFm9^`CZ6R2Gl6C=Go zCHZddA@R}UR~$FBiMnNG?w{6}4jwC0;sro~@(>YGU(!67(O}0L6plfTIqv8` zH*U&1tOHBlc#477mVP#j)DqI%Pwb1xO-i#VE}fjQaQJR&0vrhrrK(l1PE+42_hAiA3)_Ely- z+AXC+n*M0+;f5}@lgD$w!VSOLS(Z%slyG#z*Cv@-x&fnM8^8a{JX zhMX>ktnZp2o<}Sov~1#%%rv^UN)S>}3VUEzmkIn*d$bHd*>G^)(Ij=r!F7wr4&-=U z-y)*DLwUa3cm&vZzdd@}-kO@kO*P^atGjA=WL+tHRhu#QZn5d|O@2<=O|z<+t70HB z!pzsL?KDLhljUF_1duD2onrl1CW;i)y2nW`Xt5PTvz;Cly%}Ihq*ir?Iu5a+QC%j8 zATM|x^X4nDJ4$WIAO~T6M1fKe&vPSAo9dP*z{n;t$tr&{hY01Ho}E%lc$ zkz6{f>)Wjup;lE)7u}A*TQ-?RU`oC*VNyg57{%Ve zFpdV*1Cs>SLQV;a9tqMd24t9y2A$a>ATB_l#lpBaA^Z&sv1b!jnnEv`I6WXRK+MbEg-tu7Ld}r`e5(R^!UX zbnrteNO0a^-Q*#4W4xuYJPan-&6wO^UblI7UgZ-Jt{ic@#cSaZ8CwQLa*I!ba^(Ki zec}F1y`Jl~Z-rzms1ngqGlGuM>k6*{n0nUOGRi1OH)AvfL>B^sacv>VPiPS!Q6=1B zD2ofdoQ6>_4xJcHM_~+>YgUoE!2n5o3h06)te&u;6840WJQEB>p`Bz}k#K5IBZ&zI zDe-U{#qc0iU3y12_(Gu$5P%4(ga^?JEw$kTd$Ir)GdM%-x~Pj7$7Y2rqZUB<0y$0E zC1_GhER&n5xfs9_vLT0Hq|(B1w!otOgat;;4UlkyC`7I~i9j|)v8y~;Fx&!b7_T-Y zi5S#^OZ1cuCn;10J5J@+YZtwsrn@%|RAlV6r z+kvOtyPyxk#Vhx;8|0}3k#-9V2L<8ma~63LK!8`feefZ$^;Q#c@P-UfPB|#O{S24 znD}-WuAvGV&EXh@tl&Muv7?KPkTWMF0;rWm(8Yj6d>_nk<{bbCXIaQ#81NT;!C-LE ziZvk98jG6ShcMVdib#mjZbZlQwzlZrsE)DC;` zBI!lz3M7v*0JziS$Yw8}cXxBIOWfKyo|m+-~JgTL-?#m-j(#N1Ri#@@!a^TWjNnoDZy z6!xS`Dt=yx!>CY+qSN_%t2>M7Q9E-}N_mDfdX1-CE46X4HYT-DQytzcwx90lrFL3= zbxTK-Dup1fZf_Nc8w{%j{!oRqtkqoxt zp9}3SxvO*b^e8f%9ghLQ;i~qL;BX=KwW=nxPfhjoQE<2+`{c!cljccVUPod4x610u zsnZd`9u#M)BW9@!v-A-$wD@M)BYNyYS!KQM|l5AY7pZFp32?iUqd? zSa73IaIR>K1pg+vgOSC61G#bwc^qOhbQ@&#-0(po2_z`T)R;SpCfG&Z%EpDwbf0u( z^aw*fv=b0MjX|T%fI^j%V@w2$05rLn)kEc?$puuad?P)Xr0`4Sz;Zo3*#yL<;i>|@ zk;p#Y!kk+48Y@T@^OC_{E8JmaFv>2uWI!J=xC+GI;V1(J$ZKP9aIoVa$2>4P2Z`PudMQPcWJp*tb|@G}4b@04Pi+Hggdl9}fYLLAc>`7n=f+ zIj8~%?T@^z7)ZH24KzmS5djLJSGJMo@O%*SAOS&(tZWKeYCLsMf>sh(58Y5G9e~pT|G9 zH7{TECQJ2;^i*1Z5PJZQU8N`POBx{Zg_EMj!@YqtKPb&mz_7g~45vKdzVesD>k28kV;w^w5RedPYeWVv;a)M!bV3t8CeO_4~l51fJZen*trMuFSAl+B-Y8;5_^%h__k~vbD^)P z9PaE)dV#*qZE9?-Z)|N}RNuIub)id#VJPEfqD%VF%EBZZ3wjsj52U(@Ey*+R;8O}} ztr*4)j77R-Q52p!lMxU*5*7hW#UtI&FhqDo>H%}HWNEAWxQiYkII39RVDB^NPAsTv ztzTAmaC-ymOY{7?xo$ma#e=RlX3@bWOB2qwV$x;284=PGeWq~Tp^r1LaWXSS*{Xp8 z%0=OWZne`(+1Xli6=OBfk6IRD8|FMy4~82&+-Wim5r2h!tVT)TLxD7<;YKWNbKNFu zK;8I-nq$Mi$k;|v8o9w%V?_kDUg+6GWFXdlIRt7*(RxfzF7Ya*Q4{YkpB1wD(SjX? zWm#~`=@9n9NC9k7tZ~}8b?GKeS`KD{bLx20M7&Tn<~q6-hvk7Wlj9H&%MR_M$%+L` zS`tyRFA696Wnp}}$}-8aRCm7>!@z)yedYGHu}$dJ0ZZ$f4{mR1ZEk2>kf%%fl-MZ& zEfQ+2ceYnY9i+}kmLc{b7vVRz3H85n8%K?{OkjsNBm|e+rfDWqj~;ZV|rDHU3=lg@04srhE|FW z&?3xyp${7PfHq6Wkl+}mO~xXcy&Tv>8?&IX)FQUuUb=JLvU=jNo*4J-=TU6YiDHw7 zXK72l+qxT0<_dGeKRV+)zaF&xW08^Q$8BZxi!4!+XVhd&4Yh|m0|yynaJRqnu{Z$x3kU;m*QAVHdHAt$6&*Y z{AVYISdMp=3F69;S~p=7wLq)|kFioql7xUPZeAn1-^XKN3#?{!vV|^kjP*d8n@X8s zjE_DvOYcyl?=RL&hQmBrI|&9**b^0r~}8+T*6!LX8Pm4~(^|@PHLREOshy33MfB)Fp(; zb(wUC>JEd%P++~Qw$q41fNKnjA;T9?{`TDbL7le*)M0ZKSyKWRB+xWDuqqtI+|!Ud z%xK<;;(`Vun>t2?lj+!zDhxuv-Mcnm1E3VI>5|GNL+m6;m{3U=TuCza#zwl6NeiJv zv}TiBBaOlaT4-7<5a8_5UX(AS9!^$ReiMOj`VFh!%CP6!G-8Q(Vp?u;qOiM51O`=) zYCa-vGCilLt`j7XLn5oAYD8QTya;b9q)tJP=p5K=-Jsl((7!S$d%DN)LV>cNa&+ew z5k=T{uhU(&Cu`Bz=ipPoJPAk?e)S_f61O4H;kVu9uaI9(fsx%rq#~|lG%Y)#i$ZCq zi?>)x12uC{O&q$ADQ?s42p0jf#l5qfL`;zfZ;P2JBjuP^&>jp8A&XHwstP)S<+;Xe z;nz1IKTDfPjb$4K*b!nACP=%HH;XcU<}_Pu&>@;9Thx$E+Mce#X7X)K!x_+n_NpB4 z@Ss=UAh!rbE#K7rv4uNB(BJ=c>s)CNiiWwB(?$(*|9|-8+W)e}RX((JfR*pGDO2*; z|Ki7C|63iJHnqr@GPKQb|NM{J|GLjV|2jl!%lBua*p<7{Xq{s-8XF#x-W7PYFQyGQC$hF#I*8? zDdnMRBUD{8Wok{Rl5w3qjKN1f!ZW0;^u&{(hiYFCAlsZ;`IW!nCW!0>$cq>!?X^QC zczL>bDmO_yCEkKfOYVDkD)V<*S_1Y|MU=Re_ zsuWyoS=K?M;^lR*J9B`?YzqKa+!;$m@e9b2()bONWRm>$`^Wru&@Jbe^awOku!@1MeQ~y z-&&e*h?NmBJ6HpG;+#aedEJWT_nle|s@AdxbItnS5!SBSdxzkvSc;7(71uNftHG5nUF>pQV)?xRRS^aJF;QygDP{w> zh-;4sGPpROhy**7_pR4}8Oi&)fW4GgQ}}r|zXn)&K7XP7D-u`$>#_8UK`j=C?QrI_ ziQSav5j2rz1h%5#qrdD)zrD!NOMd%sV%k>QBQ}*znEu!#Pw{2KQQno1ZQr-zu-CeO^83$r_p(F&~|CXhfVz zCgZ5>lE7lo{zSMZ7D0Q`6oQ_@_UZ{IVkxjHrch_lXf%36l>lrhb^x>=Sl`@YuVYHE zA{g=t3Pb)0N@V02+QX66AS8A?xG|pJXy+*8K`o9b0l5jujL@0R9;Szj;)b;Kyn(fb zo7{5vMoJfIyNm`tb`FMaN|u|2%dvBEiRU>Php=Pv*eDo-ydZ_bxZT0h^3q^XrU!B| zOfw)YCwNme0y$h`qrgObg@?jMtQASs0#w&(KZb3MCTs&F13`0%s0h5QVHz%NUZkx@ z2(9Z}ix6~GO9GH(Myn2Frw4uY33F`!aLtHYsBBL$<99eqi;umBg4ooWUE}o=UsGJn zxpnA+RqOS#C$UcI3{Ox@?|>rD_6FVXDt)}NVwm6JVh*tDE|Z651cOv0%VNTrG*A{B zT8vNP!C;TDYG5^>?qS(unqHDrrP2;aO+G4$oeRVk6vdu3$Zv(z>q1dyTrv(}_Z-&p z^5Age4TpYYm!v@n3@Tci4o@s;ZG3^rY!w0sDNO7S%fvSS@V*gqVCc7PjRx z!JrqeEtSK$&E|_iD`jh-l;e-b5Hwg4(T*_M(8l{ELL1v9sMUc}#t+2^Z5=lvggYtA zi5Z=~Q!(^)0f=Hf;I2`Mmw-}X=Zn8AEE>_U!H>+|D%lpXFfELPfG~gUO-oysENum6 z8u*RH(B0L*xIyTc7**?&a0)qY04orU$TCs3GyFPxly@`G78YDFGnel&%giX3>Ms2{#BQhsAvn zNw^aoKDGgh7v1ow=CQ$p#n;Y;74aBRf~LPWqDf*Fa0#?8Sl-n}f)j}}C^-mx$rei@ z7KaI@d6rK_df+74hp48{s|W&{(=IlrrLbcQ540DHAT|X54%__K3#U~PXC8KTL#GDU z2_X)$AOvI$EVcA-V&vB;LgOU3&Aoo?DRXV&5wry)qZJflH;|0b`jJLuHlBlgZ7{Ml z&mvJl^)iNQ)!E@wF-D&tDy&r~wne#g5HLR=iJlH!4`E~^i^@rc6wA#GCkW=1=IF2z zt2D@F41IBfD-tCZqYk1#tjwRoibCnW;Upkp0mV^!5 zyXLlXX4J|&2?5c{Q5?iOgRTXD8>*vL|boC1-V z$R@xP6)ywu3=V-BM3{xWz>9F(yhFW3=;}_Pn?-yJF9x{qYSBbo;#ufNE%`GyO8;iP zFbbNYqMZmE>h5G*3ve-{Q?F)T!*lc{c)N==NiIDbkwL|AfPon+RQJ*VHvj<={F^cCL_ca``G(ZUHn?AMOc#H`YH+?m7yZai(36dMeK)g z%#^H= zO93VV!r5!_YGRp@7PQMFRkG(k;X=wIo`%&53afjvpN5GL?eIQbtT|c`^h+vc=4_7K zK^wx^luK;D;CS-z(?Uk7#aKLmsz4mo-O@6_@R7z}m7okUfZ|3;_E=ql)3u3;os#=lLPX1A z*U#aaa;f$(eAFnZ<6#X_(RgSt+QM{o$Uqy>q&5Z~o9YMDJ6?}d_cLhK4+>jI*~Au+ zXkjQ2@}mf_T*`v@$cerLgJOu;H>%Bf6VFMCK=gTX4*&8LswkXtZm4hftPl%WTVvP( z=dwfu4m}a~A1%0kWg?#dXR0M2V(*u^G&TJk1zQQohO)&W+gz)f&+ZS@Y+N>wr3Mxb zu9#zLjneW`wFc3A1-0oothCq!b;F+dyd_pmc{%%2Vu5rAvhkYWyTiyybF22|e+{n8 zR1yS_87?6ZV%6cy4isZ1Jm8`VYfCDRZc)~OaTHGc@Omk%ly9Oht`y@SkX4gKf$ZXC3qe&RnR#KT&)Zdab)rIL}fxLx1h{( z9H2N3PJxVw;;m6uA8Pm`hz+2Xh1-x@ImoU8#v74RpCa1Mwgo-Kc8e|j7lH}cmZ<~h z#w+X_LFS|9wAn8@DzKM0uW9bm#Q-(c+|<JPF_mh@ zwT8%v?{#mMgx>MW0TL;Di6F3E_evBV`UZ*!dFbfphOHI7y#8Ww$mCRR>!vuF@|IU1 zv%MBLYmtnB<`ck504WC#URsZMmO4!{bw~{_o~wv=Aqi#D%22>SG^;xbR3V7u=TPfw zfP+BZilZ?r5>7{j@F|=kT+CFEzi8*M0qx*~hB-L%*p6&=&XDPVWnNo)j+d4<2Z60o z9!(r3zKZ9X#76stZ*dH3aVX*UYCg(t;S?Qh&;gdbg16ErNej>bi!k?WL9;D+1tQ72 zh;464H(Cx@(+|aflf1Bo=F3QyQ)?WxS|eO|y7QOAAT1cQoX3rz30qTn`6wWo8Pwgk z(A8JJ`Dz#6VL6fOqEV^SvkksBYVC54bH)xW{mW2op%Uf2dZ5w0yo|E>Rx*qzpnTX7~c7|jUZjwg+sL0W|)>+VQERQ zG+>0JiJD`~YxylBH>1$_yXL^DaW>r9E$AwCMk=uZU5Jm2>W6#_M(mDlyxd-e&~Oin zG{30>t{+4b#QfRKj5$%@KHs#gb1ojajATwqr{n}BB2*>936aunxE3ipvK))l#yG?R zpaol%QQV@qg?LMXj9Cn}O}250&KZ-d1Il1MDJ}K44a3^Q-WYg8EX~4xxj-(4qS!qx-0!g|mFWnB&_D9XM zyju*DF3mE$wlH%xD-JuvhElzE^rHwA5e}s$ng?|yi!~*YR7Q(JRo%sr9b`Gm0sz;J z72~$40%V+x9yp5d>?HA2C>3If=&MZZ^5Ij)*?hZvoyw%FQ`nSsa+|VFJ2|$Qd?@Fz zPN(^pv;}EMAR+`7S|g3cjKf5UrDQh-HX`7e)j3?Y#OgN6aX9r*gM(T&Z2gP5*OrB{ z_#5Hb<9z03PoDDA8?L$2D6XX)+MIAE>?T<@zRbpyNw_38M!223oNB|6Tp18{F13by z9kBT`()c7-I>e%s%|0GtoatR|54DR4a>+WVKI1*p2w?+|j)bJ25w{Oa+^!O{+lOcM zkS}@0Pus?x##2Bg8sW|iHP4MZcFscD?21_|{Sd2~ZM?88obqNZZtk>e_#6Yw80j1% z*P&eLb8VCFwpQgO3QmR?>(1UeO$-H$vJhEzI^HdhwfPDzKD^Tna_vFdFMH`JtB9}4 z+S8+QZ`snbkMD4=ye56-aTMpmf`I=8?*u3Rj38h2Yeqokh;@ZG;Y(EuCt5U z%C*08U%1Vt1>75H5=$*|Sa+*94GB?@;pR?TJg_rwaUmC7kpJ1EO?jNGjjP|g;|O*0 zNrs~N&DF}eq>`-3K2rRd%ek<6ShyiBkJKbo!?d*kjSOc{ldI8%h+Y44#2;QjGzds5 zN56ZT6iXrulc;17!%mA1kNS_gDC+3gymEWgxvXluzYp^XYfdQAZ6!{ z^K;{77&VVNv}Up0o*!hu-lP@eL=PpaUT8`@)LQ7P777H3=K$_U5L$U5-V+=*PQe_bQEH!+l`UWH;m1HOm#DTLJGvF6)m{v)B_u@5be;{Xyd5k2*D5%APD(5_?76o`M+Q!CIWNT+1})mK7*=JQ&FbdQ1fL<&aKk)|SS}MOgFP&K z9$!9SQj1QcGGdk%J+ahKfiH6>3=d@;Ko~-Rs^C7hxCmUur41Ch+F*Hz}^Id-tyV7GiRX8TD_J>oqrVIb%Z_x zoc|bgc1sz60nY!a71h(6=l|4D#pwAz5}zTwZ;}v>mW)C1j{7~X_>XE?AwMyV<3CoH zho%DlV@0T@YB=#9^PxKGXlIO45dH?YlVMf%{Xc`HH|+CnyXSV=>v`-MI)TBQM<0s+H*5ZP%F_1+YwQFFsJ{t;CZYHrX9f)7zvF>JH!i2Nd%c%LR(tu&JwZG7>{$7R?5VGTW@b zXw3bNlf=q3CB|T2bDNs>Z>UEIB0LCHYVQm@aKr;Rf@auL0Q2JGKf!*?nlyv`4`zTf zynX^q;9$%YH`ih}IE)`FE|?jBKvq?$qYgY5urlH1V6?aMsny&ZWYxSRje_$rV+X9@ zeZ-MDJgZ@z34Z66MgiE>pKSsHa24T%fJS&%ty<;X!hO71TQZ7G6gyJeiuqXxC;w1u zgghASlox`1(aIVw(evo%EAT0J|Bt7(SoRN}!uS7BMRoO5$Nhiml&PcfA4cRe)Fe|f zHAbu1lY%JX8t_Ll?H&+<))~qILX{&d3~&vqzz*C_GtnDBZ3W%q13)3+VQz4RLaD{g z6Qd#IND;t@zt%NkLLrF)`z}n_l8FeU5_T^lJc4|#1xwH@kF+=o@**D$2K_^Sg6g(M z(WGHRix)u`7^lEmgRG+$h31innc{3%5@Ttm(p;6%88hQ-y&N{-Xk#X16N;o9C!|?m>I#7m=s@8VHHg6qpE%2`pHjgzddH0?s3l#dHq>TVE)K6oI_ng zOc06`%k=@d<#p!dCF^DPoSGAKtx*(u{eA2*eWiw>y-WLV~DT>M6VFFu- z*N1d6P8E0YYQ4VYD^{#XtSD^*{7dhO6(u1rsq$F@D-+9r?xl1^x)d0>(iNqXOW9Y7 z>z*+VQ`@%`?9UnV!xm2@!#F)hEi2MgdRjBI7Xm7y#PXGvSf&0M1~5^y#@W^#E*`Zt z9ZpzrVG^AYM3?P1F~e@l6)i$U&it!Jq=?FbhOqI9HpngrAXRM#3lCO({3jd@SBaxb zCSZh%+3f6KZ%abP>{;k#YD+tFd`VeJ*@Ov@W5NXZK1=12d2l7#^Ocl9mXZ>;{I7GK3`pNcDHlYn9ZZ5Wo53@==#cc0^w;Ll-WVpw@c~Wfmq=0&-+0g=y zJ?saMNQ74;YTs;MN#7*@a$`lNZIZ8cwjY~28=8wX`w5&BgqJZ=#u*)HGrW>^oiLU3 zA>1Tercfy6gJ3~y+w$zx1}>CEKTq`l75998V2>f#9^3S6;mttA4UQ%k;~Oa^Lu8AC zpxC_~GyvEHftAXd!iE8Q&Smk!1-$5OCM1{^1voi^O?r7C!kG*8io zAY#l(Cc!QY6#uB8hg-i}iAboFoj?|`;A~@{$B+VFQX7jh^sbTiSX5A1EKYVVk#M9N zWJ{b=f?v|@dT6Vc2NQ$8pT(0j_CdQ>(g=Vk%J!=47^>WMp8XRr zs{B-}t#$#4%Ze|A}SV)W0gU~aXZu?*!F0H&28;1$6^$q_W((uJ4--`XwoC3 zaPfX#fo6TYS?B^z3?drnwHT>9o5;Im)T+usGz&mE#33V6Mn*!wx*;sM zVj1LvGO*H-!bk=H2BD@>4hN?Y%3jxojG*>KnjPY$`<4cSISAVAaPLNrfejnyPul6` z&adhcIIr#S+Ai18p;mI!311$&2JO zX4SA%#lpUaVy&_V4xB&6?XZVAXhH0mfC~zz03@hA5|06DPY27t5|P%EL5{-%X>(wM z^56wQS_fbdFP}8t-iU@@j5@od1+N(`azY8|MM*3n_rmCPp5i3V5ESShUQxbtjpRsg zIoJ>lEIwN8D&G}!&4gs50F__LV=3 zWynQe+Of$I5As(zahB~9fcD!ue*-MG2IJHN91h4)%Ao^gxP8f+kjm|Vzz{%b$g<4f zF#qx~=Y2VtFRWf*KrpybDHL0ZF^;qX9U$pgCMz%pLLTRlFywQilj=>eOGY%2dWE^Bp zzU5GhnMa2Yd@0$=91BJ~E&K{LK><@b7Y_QW=#<$2Ll-S7o(uY+EW_v53?SMA+FF&! zJ^Hu@46jI1f(8^5yqZCT;Vmok27|H?n>##5Y~^kYj#~zu793a8Z9}1|#icJOLln7v z-O)6pR(%q0YRT4s0uu97j9>RHKeQxLV%4-w_SckHliAM|3HH4-pn@P_uY1FBvPcvN zdjg<{;F;kKuW30vfqN&*LRN{|`0zA#zh{2U(MABTWdMDYcOVR&+ks7zmZ1>~4l?=L z290_kF+9*G6h`JF7^%SKS>ixJ5r!4P3;*sx@i!fMY*4+|p2k z{9uG8n#{qfa=pDF-VnYEmVu5LwoMFRf!!p@pGw|UmgMe}EgesA#NuWZ&d0OUKDPYg7o6QB*C46{85L ztQesy2SSBtfmjQ8gZClqdD23(A$i;P6LA3BAV%M$(oW8~3uVAEDd3rpw^?l`t&n!s z4;UuC>?Nb8CGob&jNwd1?Lsz?&Vr=TFe*G8Z`no#n=ja`RxR6}wO*h+UVWEB`DnYv zhLx3q)h&m=YAf;&-;vTlo10FP(|_SpJ?OPTuzFV{7RM;DOXvB>Xg1d())BNVNYW1a zE@sP>F6e@fuu+;eyRz|cx|Gj7$|mR>D71TIA!_>wJ2$l<1lf)Q3NGJS8Z|GtZ$xPn zMLXY~(QB}89^InO4vjI$sacU&nvh@_IxWJ;_PJ;i?xPDcVH;WpbK}!kD!x`(i#~AnPARDV zLG2SP+cM3S2DlhxSfeWZYWvVakrm{{nAx%&l`}lH_>?s4xQWQ!R*w)UA%+d@geohO@@j2=QD%7#2|9HY-#Ug?L5{_@p`_-us`fm|_-#yn zUG3pY+*Chc3B|bA5kKZR+=+qvACEZprx!0-bWfLOFKFVS4z@zzpaey?+fl1dP|n9K zXQ|tWj}hk|9YeOmhzPDWS3+Rs#(MH3PM%XkMx=|Qyhfs_Q6$-uXNd)nd4yEC(a-eD zYk)g3rOi$=Z6+ez4I-n1!m~oqz>AeFI8CJiMZEZ^F!q}dvC`1PomL_@VUjIX9S)Nr zb1hkQsc7!XGo)KiMgMXUpqmwjO#o|0OQ{9yhH{kf+UfF2SSlp*}cRj=e3 z3ZP;@_cA6LR>U$vqai^SQ-Ht>5;-<7IGAi?y2I+Cg0c^OTe0$QW31e_((LEm_S>Pp zi4m5saTNSPqbX(Edln4>YM$ieQ%^*oXBZ3UOgL^Ob7nfmLE*7GVaX-q^;lmimNs#! z3LY2KK79dgSZt#pFMD#3-7ZOs5l;zeGf_nXOCON$(4okYu%n=+SeNz$+_(;URfzA9 zZP{GDgBow~;D`l;Z%93INegSICat3Ho?>14B%A2O4AXxJSr-0a`IU4;lcD%vsGX)$ zx&{;P@-&s)smxNWkCIS0@47zCWJ;v6+f5atU{amT9;&#D4;%S^3MybJ09r{TiN4`3 z(t}Y^%hXxRk3ie)P+bn~mD*{7ER1vZf@ziURDnxVT&{l9YX>SF1Gacs#o{EF%);P# z1!cx13dy-B`2;&ho#P^J$KVk`KmxXWIqbQ%HVP_%)`^q{Q(};jfT8)0C=UlcX%_9$?1uZH46oX9Rfw(kC2|tWEV1`+`MH?Sq>52+n66B`_sc`d7WoOO=sMgB`#anGhid65_rA<6`-b!;|C~c{R zF)-Q^6hQ*1z@^WF)F|eb_}WM$nHJ#)fEg553S>&WoUsvDpva-ND5fdb0M!Q}S_`YU4*f*HENoy>w?RYj)ZgHE)4NN^u7UN27@1y{T z5{uK1JQ*4c5WqHkD3Ov?F%lLDYFTz6OQb*G_@Zr;&6jb%@z_e!XlQ8h8(e)&1RK<7Iql+l0mji5=i|i&~d822VnGD-QaW5{}LWwYX zu&Pr+G0VCFhO>iyr{sBQ!pf%DB_(4U@EU{NRJ0oX!wZS|KlLeS|ECN$w#W!@ApFm1 zl~s28zsibG^(g+=hznzrnVpyUK&W6FkcCNHycUZ8e2R#weZ8ee7JQcJ;=-`z>R&tygoFT-eRgS8M z1j-5F_r)%Rx<|(l4vD%Sic1`8xnD=P2L6DwusQL;S;I;DBX4o+iJW=%1yaE2FT-vb zaCkXIQN{3FM>L^Y;nW2=PHQ!@1R%dONGL(bpNF8AbOnZJoXQyVr>p&xt;H3cLq zkMQ$0mnSNC{xb%SBxJ*S{!f_}nwES1PaQq~N8&T2#23NS(n6@pV>*{%Jh#4NdZk4e zb|@96NC+ZEYotFS0wah=$}1p=#&TJ<7`dgd6^oiOmaC0}ur1gx1zS{jaFgk`umGpK zr^{2D<+jr>Td*U^vxMY>V=i8{Z9Xpt@IG3DF$Ijlj(Wc>f@IpvpF7QN`>R|s z58((p;rKPgjwtL&Y;Cfoc#+nAB2&w ziNJ;Rf1+PDW|lEU4lcgH(G?TH{uT3J*oL~D$4HT+jlIkusy(h=HgfDmgby++UKTBT z-rgB#w*u|Gk^nw+@27AsrlD} z*i-t3%cRA;@wdxijL1tolNJkws*&buB^IS30)hQRYiAxB*wJ!KI;f^|(ie6%3D*zz zTo31O6D1p5qbThb4k)KYG@fwa+K7UmR!Dn5EE2Jt^)x&nTTWj}j>yvyA~l=4INX+H z+VtCK_iC@g8Ob@%$(|VANPWM&9{1)wodj`ZX-GHeN?M(xa0KgquMh&uOhjKCnS|$@ zFE>43M1#*j>K-YlR_Cu<|2V;SYr0;Af4DS^GJ=X&ptXu)0M|ym1*#{T%>NH?|09NN zSmQs0s;j3|<-~ue8jb%nBA+2$tVm1kQlKueQW@M#h#NeVE z>x`M{Qj4z#*C@%5x;+M(+NeS)^GV%rj19c^(30rn3G7}eq>pxsc0vOSYgWP?VYu6a znXj7|fK?_4hiGIZoY5$PE1;z%Q9*evZoQGlkG9@utXO#oMxtQ{x)@@%yQ2Q#u@+K@ z;+r}OL)eZS@bH*!FK3&6zX+(R+^hI=JqETJPP1H=?nuDRyv2~ZPE3M3ZTW4uLPRlq zA}0h3^AgApcfsnGzBwFBh|Kc@FO=3C+Qe+r{nY6tBUNW0{8yX9w&oghUOD^0GUI5e z#RW9T@J$z=VOmP|=39=11@GSp`oRTiNJCpoKp;i zPv9W~;z?wvY1ZziUN%H+}J%^S>&t&cXHFNDt@dxu7YBN=M`0&0j8U_@C!XdBpMGiTeY} zy)n>cs;L-cuX34N;v4&|moJ;dw@N*B+~#CeyH5%lyNv)#t5FJt+HGQo_X-OGVJWBL z7$fwfpH1NMu8C4YpvC>MRzA6xr7xrVz}9s0QeVi^=llELmR3gI zG>04888vI1xK>&quQoMw6~5)3xZ0ZZUQgV@1n74SqbFc+CE$v0p8w>}arS6lggkRH ze=&P@ov&+Piq(0~)Z37y+U&0`%E9cq&lcF4b8Dr1rmD+lLpmWpMsMEKfhcJR{nFwy zzWbKkyoi)!fB9QzOdVk4pFj�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

2bm+X^54>e7*eCs3InBgzoH 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

+%Mc3Se$=H}jAx->R7 z|C_xhfroNye?-M3wA{9<%$-Wq7_zkJYC(|-#nobKFqn)PW+81_soNsAR4S>YLc3&1 zT9oQWNKzz~qLNT4$?`wvyze{nj_odA-~ImI|KI$|k9p5~mghYCInVQK(=?5+irQVY ztYY>rE-w45VzWknSX8^Tw!UcP1>f>hF4du)Hyf_5`}E>P>*m|XE~b4tx8OcUHRp#b zfOegooE%O$DN&|Qn7Ds3@AJE@ z%UYZDe0&bCSv)W9USa*MSI4unb2o%ApVkFrGt`91F(dnKvWo3SISBaDxpRW@tgZaZ z%>lpsQV0;8>6CKtk=%5Jwf8IU)^(G=d?!17()d_a3MG2VIiDh%mX@*ulbzWI;}$yh zD+}@p{}Nr2X5{20Hk?nHJ9loc0gTnOSD&g&0HfcVIAe6g=y1#ZQBg*d4u)v!R4+RB zB72w4#Hgs4ipqioX%}w>yiMuX$3On~aXVM9+M3p3F~TNu)y?eImai=1R{gn@sHmvD zzd{P{(mmzV1)^UE?!baZn31{zLgmL*l)OiB4rShzhX$oj!KVf*$@j zV`WKhuIky(!Jkfq-Z2q3E!{Bj;+8>&9WsyE%-^sfYP3%E-Y+$mn;q{LC&?YXk#knCT3TAFI_&4ww2grKOqlSozW#^){dY!0JbL)>gk$oysdH60Y;il=@c!i;(?fdW z;O9Z@r@IX)O;f z_q&foI`R$1no^b|HGZwRe5~Mgg2TzZ#+QH)&%S#%KqOjGbuw9bzkk>k%Yu8%h=}?H z7ZxP3*WX;Hr#y9g@l-i;^OTC0m#SWQ8&pqJ&P+;LH=bv>Yp2M_NXcTx5t^d$q!Omn ztNt1_N&fC?`{tOX_Rv4oT_hI2eDUIz$GO6U`8^dByffsc<%JKo_*7HIf4al%?A!XH z!~-T(NsAAa*DZFVFK=$V^2&R_zB$Q>!>6e+`dhtu)1w!)__T{}-b7Uu)xgx?R+FAR zW0KFWCm>5 zu+QDyWNyf)@LHb-4drzy*RI`-%XLjxi!bzZqyIPuOk{X6uT&rwPmj6fk>;@8i3zmE zy1Kf%ckeb{dr_I}Te{arTO2%T(!I>keWs>+W?bsNcCpj`%7zrT;uVLEykIX)*}TS@ z`+H!uLbqvVX7ao57&(tWpPrtck>PUE;YY>Vr&s0WO&&gddc7hiStlj0xnke_>6-`a zsiiBf4Q{UbHFj38|EZptR{;5MTy$s%P{}r!vOqs>mZjZRvrwOKGdix`Tk}qo%@?LSza3gOXowIq)swm6r8dDC8^X)!H&GG^- zXS!YNAmtgBmWt6~>Cf{^yRV_8c<0k~b#)Kff_*g@7S?mx_8AMU`W*z)HX*^Mxv{=c z!LNKqd1ds#T$e9&K}Gfu4UL{cH$QPw!l`$BUdxS7OC3wjoYr;Er@!EB&3wjiN>Mx8 z%XClot9m~J-DAI3$*RIJF%9#0$dt8CeJ7Sd3azwhR+?ycckfURBQF9P`j$7`-gaa>PX8QEEc=zAev$0Wo>W^8U|EbDq-PtLGLM zrvU`Mc+t_7vc>nhbyWPhrS(1ae(@?eUix~)s-~sgpI0gO$b9rDH8pjiD}~V=(9-4B zC+`aZX20WcjlC%p<&X7103F?$YXAs6H}^DbsJos)Np)iGxSjX*(GLRvpV{ITAru~u zzgDr+l{vq#sLCkkRrSz2xfU)?04qoF3t?q4~uewW6o<2Of? zRD1{vKF>PWecpnHai@FT^ZTOzo_TuTzLJ*aul0kc(s~^{b}aO^2R;6`F%h=b);qog zWv$;eAb-cG(u$kHXQo@9QKqy!T3_)s)8VnqeG%+kU`&-Tj*^M>wbImps(gR))f>r6~A^!^*8qU!GoH-)-yy zYisLSn^o-i+y`gUhhG&D5KEe1zL4Zo6ZL7(gCRRsQZqb%mz9JRF^66$Uhn;K&4{h(D{ z#iFuD#!qrr^qdwgvWm%9>%RDEqHDpRA9sXpy?yrAlb1EVe7v0rKkgMmvvp^(G!A@H ze@L-wKHA)i-Z%2VO0#aZ359A3hx|{Bo4jqIZ=;c$wY&ZZO6)wPOuZp;w_d8b?P8AL(bOHyK$!uQlx_HZXAgjX!AfMv2X94#o4=>yH%`cV7=JXk5hbaegZ4p@?O~#X1G>TNs%b6 z{^gy);o-+ujG<6gXRRRYHHfB zL$(=;N)!DXMX^WCfB=hLm8Q-0bZ4fYuXlkB!z10-9M?}Q>d;1JhRUPfN=gXD7 zMshhUL998ND58tgzxbBIZjVz#HSesGTtLD8H zMcq^^P*gS_=eS3;{|}echepU#Z08;-aS1I01SKpRzRqcJguzpQmcVNR>jp%D0)ju$B`M`nHTAz@qSAv!o7#Iw{d%)S} z{$>@G2Tz_Tn&>HK0^7U1iI!Zl&p)0-kgI6&2KXS6zFV)~wN?>T@uBwtV&KTaiL_h;&c-x?ds-1pVJd&kq<5m&HI*|S@1y;zYdSmLd=M#;GY$RU97#yne8VmB)w$Vm_75IB zIGp;%y*!J?=ylJ203)w78EA%@BbpvNuc-g!(K&YIxpN2h1?}1$-e>(%-@eM3BIA|C zCzTd$?|#rBK`0dFFL28EaF_0`>%X^miqpWTT%ZFPiET&x*7Vw@d*i3=`Cf7gYXYAr zP3xol_zY`ZbaeE)+@CURGTmE`_Gp((-v$p1Jps(S^CONBy;r z8f1@(zW%7B>eIp_g|5QDI>HBn_LXg8Cy2qD1O=mJ-yl|mzGyoS2q@i z@A@bTc6FWMGv-{44YP>-nP-15E%>staJe;5JhH|BiEj~hYWD2(3DtVz3=E#fgdIN5 zI(kS9FmFk+uVX`;UBURluFG@k@5PQkx;L=jrezWDO-$nW>4%D@D=o`QOW=5W*M9tX zKS-(2@NRVFrPfv3?p~gt9(v(|NtR~arO!Mz+oY(8sZ-i_X!C~~JF2UPm#zAGB0YWn zq1D~Gsh2I+72TlnDU`eWO?5^THUYcL3 zqq(C_PHvme1BD~UzCNo<$)7toqA}6<2c!%Z>4~8M|`QGoQVDK|X}T+c!qo{E}izisR7Db43=AD%rn zTXXt{h{%l7?@E1U&AKRR6dCU`S^3#hWDkgg9jX%XyGQ)#%gnFu@AQ{%{<=nfruVj= zs@}Yrs-{fUH=Gn5ad8A|kV~rmk6Y#Tai01;egE=6U7d@Ii(y|ST{X-2_(q{%uWi~x zO*KDl?fvXKKQCY`S63-2o6_=jA>YNN%3kM#kxx^>y%p7OZvhke(W4~0`sm%dpBaqD zTP8Hc7ryB?%KFTsx986r%3s~mZ#7Wb?z}YCy|rhCV~L;ltJ`1V5_u{P4(s2%8MKHJUu3a-V z+)4?%>71VOBqwL%SJMiE*_tEA_{eLz_#Jfqoxj2Y>xB?50`2L3(q>&Z^vcvB%P{)oLf2W-VL~)>3?4yFdHs+O^#%l)U+Q6VvXk zsCja{wWVf#>X!i*R=l72_NIoe*}`XOX=$U!j4>J(H8+dDi()@I!fD&@jUPWg#!5raj`HNmlRLY0TVEfGZfx9g=FA-H3VVBQ zrNFCs+tLEX-t1kw`Ho4y=QbVBTl|iuK5$@Vb#-%r&6L4~5kQvAnpIYId5Y)c{XhB0 zO?#TDI{eP>7aAMsj%-fk{{8nk-NHV_RMdq0?xCORWF5Qr@S&C$Ge3W-4jeKhJMHYy zet_Ie_r*$^F{OAsO;YZ&duX$e3?#qp?{Gq>yW?W%NrT5vr{mPT{pt{ETH5L3mZ|pAXQQuxX*wWH+ z;sm3|y1ECB{K1p74}{oir7lmNsC&BlS*D8c@m#$@50sSN-nWk~Ola<%qI^y9;IV$-LqY!+Wy)G+P#n#o=i0zT=!K z7YY=nv=pjSSH7&VgxMb1S6bNht@ zP(6SCJT1*wb4TQFzde8X(x|6WqF-QkdEMTK^!~-n;NajHGiEGa{B-}w ztZO#aTKI*~8^#$0Q}yKg$d?Gc!|Dm>YM0 z=gysRyHuzfx`o{=_e+V4GE$i4c6I?{K-jizDypgl-iFNG3C+ndF=i(n0BrB>czG+` za=rD6mGJXY5ajCW8XVkeXi}5tmHVqXogQvUQ>$It^se+`(hmzq^o^R}54e_(kI#^; z*0-h3%YwThh=XAexL;-kPyHm8SQx^yWbBI1UZ!^WmX z-D@w0OpFp-a?>PEMw_Paehb|ASt0&B5S>4ZrY{iTv7Hp!OkbF{)Qio7rIN7AcNW&a z&@8<9LJ?kAOUr{Dz;S1r`0;!NtUzsQcJ_r0@Q8TkbZhfdri<79hfb)!fBv1HPVaw^ z?#utHV|0E0!%)v)T)X=3;Dzt^KmLi&|F-zQ|1bF;|Bu8A{#T`c{2n^^pAQ|xF@y*f z{KI^j-y;UUM+|EnTIl1MKsKnF%x@_Dc|g9?*NVfl%8Y)QnXq&%{ebUVleg-r&&2lK&! z>3DJZZY)%Rodff>!EA0=0ykI}0!$ApM}bikQTK*w4`+lm!z&RZpo?JoCRC>w23oSX zoMl*W6;`)`2o0j*sqcuYB`~fHZZqBpOIC;V2*foD6*`f|&UMJ@N#Eh{MI;~S%>h6n z&5-Di)LjQWU-}iPGq6Xrb`MZwEKvbkHa{rB4t4SY)3uKsrAb2a!FF z=lEl|0BA-4w8moq$@s{W)LMbLbS`_o}CD(D2+hL}E}Ys4I@ zE2Exxc_`JST>iWP_Dv1eK-`X8l3Vytb+xVg|A~ zPo;6DGa*fRU>ih=P)9V333*t^jV2T$X~h!ZS*1x8oe(wvQW1!GJR)HDPgc+Z6I=q; zh2>3!nQO^P9O|1CJiY{ICmbP>2ms}|b>Ik~#DJNOy@9O8O6UQ!@NU-!Ig2hHbPFTU zVP;2(?gYslrZdDx2*5k{?YMJ1AvFYIS1?2wwq-%s5x}S&LQKSV_Y$x?nSNq-9RY{W zbQ9>V0&H2}4Cc^u3WC8*1K3j;21kgN1wx*f5-1lDR;_!*%hRia-y6 zLFr(lF+RcLaHSO!AzOw#2zwO`0hBwT5b|7DUX9}+?YJFq+pIMZI!$1PU9c8d_mBZM z5kgI>iow8s6y%F*PS}zeRML8Z(o9||gNo^xNHLRSm&Z2~D-}pXkPxsqP`5|OjUJOW z1<80fHq2=O)<*!2SUp@H!5#MtF7k z9&YY*_=bRu0|JgLY+LD(V254I!Bo`Pir5+Cr$ka6Y=WbNZR``O#6H0VALbJ9 z_`{VjutdLPLkn4}2;BHi5+!jVO)zMLs}wSO0DPD{8pnS|mlOt;Ni(65$V*F`Oi753 zi+~nPc0P0j8H4ceWp4s)=N^H3khc?0IZ9#zvvk#=oN?#~6=AxPx&0 z3o%Aa>ws?q1qICxCDf6bAA?3E0Shf3Lt0;`1i8T+`$8dRjEf{`&n5DepmiAz&0GS& zBoXg~HAe=y@t=k`?24uZT?kA>KIjW3Cco&Uo$xlCJO>k)MDllOHEAsQ2VgeP9jSzB z#FCKT)t$>1vN4<|&S0?BfQQEDp_aD9RFxd#!Sb<6u+**@mrpoM$lEUILc)ENY~Vfv zUIS}Ic#63&Ulo=fhtNz=RvjYm5j53ASb}&o2@eeRu%;Ez!Hxjd_=sou2M%p!zSG+*s#Z1m0nt%=aodq68M_rh z0w7C-yG}8qL}~;(Iq`h|Rt?pEy9zK!%pR7ePC-ng5PJPuNKp#A`zqJN98lh~LH zYbUkzWO2A+lvNF9wr<0xU|}X?t4zS71gGhkk6#j|w&mdOqO{pd!Q;;BFLX zzeANusR_6Dukn=YZwXmT&^3--KSF^5e>S;$a$cV zkOrH5N6J4yN+Das5{vkMzy)MlX}R(FTsDi>)ehLh_0zBeE50YDl+a-pG<+m@K_DgyJr zi-Y~4mD$1KJlP_5@6Hy79%?xvkB}n+k}GDWbZu7>wO4VA3G4-wT1a?dVvSh;OiyA# za2(0fg~Z7SkrkM9+JLQ;DC#Ob9f5#^$86}(lp932O;AUWEBu+EXe`3_)zKK(*({LL zJiKr0Oh=-20`BAm&u&>*PIB3a!5NUek?{5sU@4FsSX_K!Qs@%1lRAM&>E2;aBIy|# zVK;Jk9_aQ0_|+RbgC~(bHYf5iGY`Bbc1K4U$mWKF6J5cT`Hxyngq|p%K;CoHy z(Pj4??s`WngU#jBa=eelf&kENKS|Crq7;kW=~a;FjCyWhdp;T8FKg7aiC1s zWIsq7{6NcXj~eLu2nGrydnLO}Rce0=jG#qAC1`&L#iEIM9Dgx^-Oy!#3QQuhVGD7$ z0#ykj2@r4sJ}%#3C~Y>(KJO)Fq4eY^{k0f734!4b5-{LYXN5CHZYSXqnyenYsa|>sYWrXEF46>)Phkk zvPA<}TrsL}fK!T)ssy0HWlNpT@O2qqkdT-#Yy<0MOQ+gS2tawwKzFiWW^knXw>!&~ zF%keg(a{Ao3BXdN2V}Uygbs!=bp>BVyZ+D(Fzl=rgM62=!ky1WINO=H@B&DJH|g4P zkXlHvydq5tA)7XK*^DdpkI6XQwyR3ckU?&i2h@23 z`BGjfRTa>EZ0ytvlZ_ai67#@3czgjmO~n_%MDI-F!hHT6oyCwOW1E8oa*0$1>IHEL zq(S4-qD}n-33c1f#k=uvYkQ=FI^wj01a@N$J=9_|y_hsS4Z37g+WH2y=pJqe5uwW% z$vxsOB6Jy}D`JvIQa?Wam`>U!G>kS4<6Ln3j(o>|?m93Qd?4xQU-AaywAm4gLRJ98 zFl3RPu>lO>I$B9rPMgl=-+{LV-$5W%1wpcGwnKZcy&D}4g-NAv&Lm`xxBnYC1bG4f z0CV_`@ZSRA0oFooMW!MOM?D6%fO1!Bn5V}KvntzcMo9gkqZ&;Ukm(9lT&@^%nc zIbeIN0Zt1-bnpoG7X^EgyiF2+2i4Tv6slk|t*wD-hpEFt(p5u-%*5clkP8U6Sm8wy zY-U2Tf{QvqvV}@`YzY4!bcjjL?yxTjFD&Uu75Bi%cnT$s0B8vjZawKm;F(y_ChUS8 zw43ldX8I74e*t%>&|Z*S4@Oriz&;b}2fZ=%Aq2R9mINJM5$(WZ15pasm%lk@lRcA_ zWo_tg7KyX{b;kDJL1zE)V&(slI^|R)R1b!9u^%f{t}iJEW1vUV*EiNPFg9ve4o2yF zvGRZF(?0(Pz!cqYI|j`1G2Y0ill&j((xbiV)KKMZ~Q24i%c|3_bc>{$J_^`G<&^}px;`6oU)-{M0B(s!D< zjl^~!oeWFVT{D|G)NeBwar2*!helDqQNLgj7zvOfg}zbOTs}O2;Bwropz) z7XrIDLNn}AB3LsztS3E#cM&0) zhlk{M$uDhsGNJJ}-1ZNdkYAAh(xHuQ-xoeAygxxD4~Tw9mPd*T>(PeLrejC6^iBt|lX#;gfjGov ziZ&xk{`i|hjQlbm2oo>?U!fQ1!Vlg(LGp`f18{|bx@OS+)W&oK21KAfouU~aFkr&Rq<& z+MSXOt^+Z#OK;Ns)53N{!WgyN(-z(Xpe#(Le><6mO-3Tcqz3`tT8MSEdVtyZ`u~T$ z=KzeWIM&oy7YKx2lCVA-`_7zBcWO40Wss$lEv$x$3${6)?w+KFule4cWnm0~gb*OK zkU|MPv=AV`2SP$g2m}Za2n0yzCG-|ThYL+1c6I*_qiE zoZT%hOJr1-dA@Neqlskbe0Hm%xF`zWadS*&gfzn%7Xq(xVT}_?>56cXh%&El1UMJf zxn^19XdhP5d}CkfOx4*ecLLIk?|jL#XXzL-MPJpju4o!ubIL^`X9LqQOygXA*`3SudN!J8nkl9TQ1ET9)6=@|QA9=IfP0>u9^ zL5c7~yXs+iG_A385hBAvmNsE&GRk=3;(@bU1SL}*o8@CaVaFtkOj!qx4MSd&hL3aR zIioudO^q3oKYz@z^n4{bq}6F@k`Mc&Squ$=DoS^}l!eU^AJ#~an*Qs%0R2mfY3tyN zbst1l3_D$))+;d6n=mcc7^MHCnngzE3!{ycUL;Kzpow}nrTRTc_r2LX%!`svVT?;k z4hB=?prhY1K+Mf7(Ai>c(V({pfXgt?jXz1DA>4jWF%DWK1WLSs(=mvU z3$rYfB+r>%zma$3V1NdHohiWhh+>*Ao&+>a8sVw7m={-EfeWz{<9@PlWI4V%EW$jY zVP4r1umvMVV#`Hd%mr)ekQbG}%;ZH=Gm=+Iw|Fp)u|{4g?d%nOrKn4@fS_aszt@bJ z&IDxyq;GCZrqVN-$KL)AqMjAc0JL!X&l-PKP09XqBAzVcUo=DTQH=k*%IebiPsEdB z{7KOMv9?k8_}A7}m*)S3Jo$`2I0}uWjl#!&UUgMz{!hr0@Aw<8^eB)T3LgK;$|_%J z{!hp=y76aO^K7H=@vo}&mHdAuG=Ny0|>X+V(T5EITG9=W3IDEL^Mxuml^Cr^jkVpuwm^_RO32p9;T*1shLj=4gZtY;` zG_xq9-b)G#Im4laM*x+ZCT4;Wo{gF=RYVnPKrZdwjk_@@rzo|xB;(OORZc=EI#;E; z-m2@?`^Mhg_fBPy&vZ zOqIi0=2FC&STR>Cf{}p-)e8YMBWmkl472_wNu`Ds43pxq5S{n*gG+1#jty}mLMx`D zXs}Hp7zGJ zHb}Iur8&^ligOr>GWTG~1rGgZ;i*B#oxG=f*(JP@1-cq6SX>g;R_GH92}=GDH0iWOhOGvsz5ASva4J}RNle| z$!#l6*ohyySizCX!Z_aVuRI=dt3O+gXzc_8|HXx%o|F0>X|4q!3$M}=WXvY!> zE=T+~f0eJwr2qH%{r-~ve5O(gpGIbT4)3GMIyB z^6uf})UU+CO%W1CiG#_Yw6}G)^Xsv*KQ~fxAhzD+9xt!haUV;&z6i)2?~rz1?O1eL zaXjQL;IhK*KTt@VdvenNx!aY8xEFCjqo2u7*lOO%IXdgxOaI1#d5sG%%{RjR?hKVm~-p@Ltf%-6?@&?3q@Rw%QoL zrOFi^l)_`|i$_2~MxV~&HK7we%-1<{bn>U~x#xR+E@2{C^JBCH1pTvAmPhQq?4kP# zne5hxs~e4Rdd*WW?{K}F1Qs*_!33!sF_nV}8YRAb#E36>$iL0Ddg)Y@&*H@*^YJyz zk_S|Ce#EwN1cAyZQ{q8%Y= z!cKemO~ZU|W*%Qf?e5VASWS6l9^6k&jW)0!RGAIRq^#D9wGt2tiGru5AX0#K3g&WC zXa&}7iUkDEgv7<8ko6_PWF;fVYKC0+J7YEV*-34*vGb-5t!88|yhjtpVC(|YeF^Z0 zyVZ!h)nwq-9%LJEZ%im1n`lgg?jnlDqF6kRG3S_6OfAogQ+@6@a~hWe(S-3hL5R&K z)?6l4x+|%Q_fgnHq0^(?=ohC5S3^Kp(;yYE`L515)y#3`Hs2JZxEPc6q@b{MX6aI2 z1#ARPjHb;M#BK_V$k-#v!6R}`^4$>Hiy(+c*MSTkFp4)WYz@H_Gu7gOW|s@w4=hHJ5oD4H3pN z3zycpCg5ZY0T6SI9uJXL;OLE76eU4q$4L||1s*HHlg0k4U0N#-C=q$gZDhCq^7*T) zt1R|^^Gg2T6Y|U?7F&*knwK`9S+0W`mo)~LbhZcFj+yl63Wb%V1F{5rx|SSoYr&lY<>M?Du3SwIK;;#4NmvG` zSg*_N1|0X`pAE?CVAXUqwg(!RL6O7Z0BD1hwbwbyl2KHi95ABFQ5Ic`$J(4o18OQU zXpwf-U60UeM_D+ITx?jI-1vt+3~miN(giny8$DyPqYQF)!T%=$ zt8q3`dkD@jcMI1ef>XB93Y ziv`FSXiSe*VNoGuJe%iM(d@d0@@HYH(EsW6dN{-oP?ZAjWFzBrs1VdBTBy$!x%~9M6b7k{+}(z z&Wda$F&g!fTJSmBGL$nJ3t-v6Hg8z&PY-JO;`W(99Ef5Z=gJqB@j@LUB7~lGV1VW= z4uXZz>PjlHlnQpE1L+8&l9gypOaRDE2gMwERvBiOpqrxz!QcSlmo1P(Lva+9RTWD@ ze1N#D2Xe?pW6~yqGIKFP2Sah<9W`sC_GX_M%xU$^+FO>Isp|@n=d}9uH2Z>dXe(%^ z$7hOnCFO*aBmvwQdPc_qiw&D$pc52G;C~4@7FLC!r=lO>f_#|q%ccpyToXeV@lk@k z04ya1FvbbN92-*sa~zihdt|=@`znS&ksoe?LTbv2T12=SB$6K_LE}s`S$oAFIeUXI z{P!l(eAxnRk3(L|77!F-;LYG*#*S-(crvOSQ}Lp-9#=OatF#(i5Z95ClQESHHce7u zp-4I`GepdtOLibhI?v#Hg}Kav3f4S@t-=7@0;(GvcdA+}$K)iqSpr$%9YNuZaZ3_jsLW|3B9|d81P9@egwqD_mJTg% z?Wn30G7Kv*H6B`9Ns8eNN=!x_ox!HI)<8#Z5Tf9bKaQE00V@Lnq)yt+A*Yyzrxv6L z2~v6k0TdDk&5`WWLf~9AIN`uSa0wg_Cfgr@O zv?)N-?Mk%=np^wYSvjGUn4Sr3cCG2@cBOa$bEh&EfY6k71xUJGfsVj(y^K(Rr)O#e zB3#-vLelNg-EIq6)&eAkrcD8wZdWP*EYqeLl5RUM1KN}^&dWfrEx!8N+U&AJy3TLO zvJhk*5kWU{xz@*(usi5B<u01BaWEFBHSBWk^=bd1E@(*qT%=5m6qB{SQrw`rBcI8#BL+d>Vc6Ol9x*hpWQnu~_cfn;bJblOk}TsttxDhitlC@KO410JX_>K`$M zE}{Y#2yiU8KLZ~~cR*4itP%t8#Pvc=q0kVP#^>V3j0sUUi=YT)AoyWSiMXK0Wjuj4 z3X$&(z}RQO^)q)d>$fN`g4+*CDM;dx6q(^+B_1dZ)lEZkXf25dN#iOA1n(74z~>p7 zi+8!=q%aO4kh`9hMrd*A32vOZEf|6((9ZkBpPC}RG>$+JCQM%|zJ#ps6EG$uuqTcFf%WLQKOV;dA()TY@6Q(7+ki{MF1$b}|Be9wR) zT%!>~X3Odf*hwc%$f4!z5tB}ecK`J^6@%Q!L2AX7 ziCtJs%$!*mvlzr%VH}uVCcq-<4q_G_W6OzQ*a>r_rsMb%DT3KWI*Q;=kf4I!r43>I zaX0XCDhB$8j+K!p;kMf*7Q)=JH>v~WAsZC#i&Ae>lQF`-dGBLQ2HCgHrXG3)fF--( zvH+VMiCtA>gJCTKy9jG4Nd9$5>?{=wY&)xM6RhO3n zdK7xAJa4E3)W8|5AhGMsxl>BizJw)r)|@N^z9~B<=V-#V3<&8q)D!46QlOl&Elp$I z8%8e@Avv|k^}@$=jA>yY$0m{gG8a{tiV(k=M7m}-z*B!1h*rcBSVU_R$Dz)lSf+@8 zG-zf!2F6V0B<%#*O`y57W(*XW@6Z6Wx~j&vhDpK-{#Uz^p6(Hd?-u0%s*5mLDr9o$ zCMFM4hYa9bMB*hK0m0PvGvy-inMS`BFGqpeH8~nWUK6fj6s-sgq~NSl%KdA+EN(T; zmz0L_7%C)Fd6fq#Iru2p4i(4^kUD?{v93Vm~FTwq-a+WZzDN>Aj=D>nwTtqCg1Gyas6Ck}}EVtAkNEl?v z6ZSFG$625@{5c&{l|fK#k_B}x9RyV`*SVYkX{1}6;$p;VUUm(%#kK)-%ND1Xr}5jH z0PlQm`{~%R#!Zc}RMsGE5gNcVolOA`s&uoZQrMKl6De(E;I~faRn)%~NC_&#UqV9| zU69Fx=EUZ>xu`@d1)2g)I=AS+TSx0HPNX~9Y%kNNp^r?%OtY}8Ob~Xc6tYTLLj)1% zH2zJ%w9-6~{C`vhEBZmxIdhLxwB0DD-&`fdC<4Cw_)oAln2N zVyWOtBE-SjM;V2u5i=1f5*g9+(Xpfu6h63&nzdntHppy>Cy2-olc_77Q1t<$H*moL z4~ofT$4}bcBuqmBfnKpT>8M6TziEJ!+(e~hf*Orh^z8?pbo!P;L#Jt5?@Yznb%#tn zLnmAA0deGuGkwP))S!1~CQIX_LOUji46t_**8|Y~#1otslTLaeV>iQ<4MQgTpUu3D zGh*FtPp3~|vRyOs=YD#<5~3#MZk7fX#D#9{?y=iH-^B4oiQtBM^;{KDSWZ{FDw?Oi4nVn%vu9T2W4RMgm< z6tNskp%EEEoq)$Up-Nz<5IKSSWrGB(61fIyk&KE=B}Lk^k!~!4F6kp%H?s)29;7Nq z$U(RYW`ORlK|u@%ZJ<}H%yqk5beVMnP3}iB)>DdU6_yinZph@SaGZD%lNH9pRt(gS z1tCgGK&i9|(;Aa;Z6U3(u^`eOIqGJ;vjf4c3D7wfB!GhmZCtajp$!)Zd7^IQ3L2Ae z|1tZH4`{O;XL7qWis{xbcjQ;>=nIN!C+`UX18kU#FpO;;UFO5mmIsMb!H#+}!eZGQ z8DXKLSTHPnj%A!l^x7#+qYrlo*#Uubkn4r40BGVStplJSndr?tZpx8B<3h`e5NeDm z6M%GciDw+#;>v>X$LY02BnB?P&*q-icWV*_Lo5Bl4kyLqqr4XG01ftt zr!L%5MsBy3*;$ar7bVj)SF|}z^V0h*)}`g-h=&H)7*^j4sjo>1I{J@ljF7RFxeFt^#E!Lw%sJYV-o*xX?1XlVW;7; z6bTYc7{|q!W(o4+0D?CO4>nyfD|`q18mMB+xRUQ=7L^o6jz6w9;P&)fn?JFVSLpibts<3t2|z<;5zC9v^~B{ z?+xbU48~a84ovYF9tM*RUO0}kfoR9NK({uyoneWlOQwE0tTQX&;XFx2UayBS%b)ZBK*R2n7>96y zJqc4Ym6T$tWI1Qm7ZqA$wEVze-eRF`)_tErNMwdC1wqNJW5x)lW@M8Wq;RRd6Krk} z?Vl5AZeiMum)aRNYKI7EsI#M@v!%tZ3x?RJqwWXSQKsVJvc$EN7Be9e^JJ+OiL~ape9Fi>59dNIzPjKOtLP|l}p&Q zidESJUZWi2tLI7748$O#ilaf62xdxUBc?JLN31IM>4WX~QB+g4DCKT6Mg);<;7LeH zDO!g|Pi8hi#AZR3LPMef7Re>2$n_YK66S@WLRz2Q9Wfp>6jvFM#FG}8225mF6ZTU| z7gmJ(QY_MnCaj1h^qWacs(z;FC#r8#8U5xGn=;k*Wk?6@^4FO2LyrLqLT;P{S!>zU z)M*}w!f0~DPxOc_i4>O2HhP3ad-19Zik}!?Ml3rMjb=3w1v0xhq+IG3%_Xd>U|31Q z{Xk}`Ew&=^Mq`6@s54FU2vIp2$3mG?JE)l<2#PGfi}EPIr#&gb(V}oM3!u`&b~Qe? zo62xxOvrj0jH-jH{62EnT82j@7D|jDm-fknEQ_<-gZAH_tjm_21w}pG?-BISi2HifPf3KqzWKIj~b^KFe7B zpg4w5b|@ZJS3$&n{YLtYPSPKzM<2~i9`P%s7XF>S;T&aU8!7JLFT8K6w}n8bwwwUy zY7PSgY}3j!uvZh1L_+h3LaiYK7yWn^{%*)*kkNQfL!wQ;p=hSAlf72%Zu3JQ12BS~ zmgNyrY;qE%mLVreG2|o%-z*RLZTQL*q3k<*%iLow0a3~{3qh7y?6IRocdly8vXsY$ zo^n?rXdgYMQPEUASn%XVzg80w*+3rQSA8m0O$(i>V>0*6AcFEtIV4a!7Meu_ zHF7myR^~-dL`)nEk|^I&8Eys@6^nW#Gn8f4=wQi?DB=myvf8=_?Tp>gM!bxh=NYY? z%`Z%?)EUp|u^EXBjH}Fsz3S@@00n{11Pu2!E@~rDqWIl!Y{AgSBuFj3+DsPb5e4H# ziqQ3(4i0l`b7sj&RZBgAZk(69!3o)MbNWF^d6jwjvHE{z^#6^Al=;PR|IOk5TT@-> zGsl0bnO9wk|2H9z(f_wIDTOfc*f;?963^VlX+_1Gw1|YsUyjF!NAO~Z6*V*}k6=n; z)FF7@ml-q$LZQ|>qCGEa}9WIt%u1wgcosUwv`iuq7$En!gLH&1{-z2!P<-Lt)cOH2nCsj^$LZl zA0Sw}1c~y>ejw8Ql>(&jy`F(=besT)Q}PBKS#v>L=6RV_4Y#$!wN?wYLUKfo)thrt z3o%we1S2YKsOOl&zm;e@O5`+>RW)P<19T3BqLSAGIC`7uTmfL|w4rvbYzhfOA)*O^ z9!J1k!8B~0Orv+EM5FhoLMTTv?BRWsxo0v5vcP_h@~}4$)q%5Lao7*)Il~Q zpfG_;%}jc7s;30#(irm^Kol4(Kynt|*n_3cUMyG28xkIHphO#4Q7moaw0cCWgZa6j z&>l3xd@d)y-z2O}Mb$Iq;X|3ZrYY@EnHiO%v?R&LxiVu-Q_Isb3+@WG(9Of^(zcSk zT`kHPd#bFt+9i?o#B!HA0od-|H10zEx-jxwuvCS$Dn!%pY> z@j9@!-lmq|^48uZ!PbtJPD6cyWs4DSJ?RkcH#sIIE7S~Xm2T5OMs+sF%)H|CM_7EEhT0758^<1P1oa!dT5nMuj0s$`F^&?w1Gv;E|YM(>I z*JH{nLo}3mp>(mv#0gc z1J@j6(h#ZDC5lEM8F{FHM&x|L6b$xMWZMyslrLl_xttQCaOG5p)JDHi2ko+`93{tm zTDk|(zvhe#Xwo-1N-QjIKuIY!2-;i-3F2q2XvB64m?fNDGI`UQ+b85M_gmyw7$n^J z*_y)_b<1?q-FX*S1;D{M{->Vp-RPdp;V7fBCm~UumGBo*6P33`2GP^o-pgDtCYnW)WJj47c{k7ry-Y+3MGMxxyCY3eY6Y#4VDAqISs`!L#VI8dVTsbj5$beuxUwm zogty8*OaiVsmGYm*wSQ5SVj^G@36JYcvp@)Vd-j5>mdPJAj@#D>5FHcmzbA}90S)2 zmzWEdK|Ck3CN#oMcle7&y5g#dcp02@ujMww#1=(`u^-X^`;8&k&rkDnJYzXW8<)8i zxU2~opmd<)UrENFVvN7B^_QSE(9+n~)@y?i1CBml$F()wCE z>X;Z-Y*fwGM|T$W+i7EHzY zNg_QT^5^eAE1Js_z->+{vsBLyRV(dhg&ImKiBvpEmpy8hK{U74L7|h2j)gw;F-~z- z>QY9=M&tHAn^74@N>hPguw3kBFXsw9?n}gU)WS1wIfvhTqwjf(Sx+Sy9cS?+I za*4up-!PiFZ`jGW3MBC;3^qca!92EECL9q24JJr1xy3A{5SLAZkfKg0DFxscWHxax znsFUuJTD7ZWPH<>RTOa%1>i+8&B~s#&CwPe3v?Z_PQ`2#nm2W(V{2paVS1x3+kI5b zr2#=)PC`nIhFtDC)JHO-UYxfMNSPd%z^~OYrw0bntEA-UDw0fNgLr5jWGj55U)saw_4GZDCm?(V+>Z}?XQ`C)|lf)uA zWSTX0j+nxNo{^@DIFD?0&D>AfD*a_&{z3kZ#QVW{DdXaA6%j@)4vd2YFqT!nE#8mC z_%?c`#{3J&X{34QhGj0Ay$u$bIPnMNCQ;@ z@T|-Y2u4SW5+2c@4-@&M9fh!dbjwmWdk?H#Fi7&VX+yfEj1}TC0@8uyc^E{3AmQVs zKrQFOh4>c_YU=Fh=|$Qrt^oe{-EO26!qNu3LG6AwkZMy;u(iFbt+lDuPU5hQa3?}Z zd&Dx6#Yg{2Q#T>a-NbfUIT_dAGe&7l38F=~>i`Np5w5n>Ci%^-z} z5~rVQ5?TViO-q6uffc^qlVJfoaF%u|@qagmv62pU$iZk1ull?9jX{P1UvdSq~u znoNO|7)=mz zFi^uLZC}f0udvmHB+$fjtMNiZHEB4aYnhuaUQ3Am3*AR*(n}Uqz5&~G)yP#5TP|(R z3<=^xNotA1#+8}Z0TEmL-0}_RW01LXN!-k8LAUHHFR%Yn#I4F6g$PLy*dkl}sse)) z2;RR=yLOQwXj?W*V(y3^Pp&=(V|L znxJM+cB z>J9Ov7SBV765NyZ%-m+gVwo1H;zZjrYvv}c)#RAsZ;7RKafN8p9HN(cW*rPDR4}&j zf5hpJ5{~N3Q>3)U_R;|&x;7>YYl++mgGjnW={6W27%(dssWMYjXR%uwGRu@=VS#>^ zH8u6}S*U}MTSV2fNli9&$I(S=OZoi4=MDAOl# z-l8dN)UPA90vp2+I;#WU{KYsohZqZTNRdSfKVWBQ0^Ab#sY zNqGaYc@Wl0!T7-;nyqnBg|C0Q`H8?ibR!6=*%yivLkJ_^!#E(9HQV~;dWZKK!E_%{2&xtneNtx1z0BEw~WkCU@~@=V3?_}tpqy@Gi)X@+JG5ZpOw4ySh$;J z;+2iR@j+)|4itq)ZpN-hL*+XtYhYDz z$>``^7VKHs(c8Gf){fBxrg;!G58Hg!2;BiB8ycxePNwAn@>9EH1Hx?JRM>4n{N$6A zWU)bkA(B`mbbd0SpC=jj7J|z*l#5aq7wQqw-rm|9#5*;1_^DSVQy6h4GQjRVL$L!hW!(D!AOc$O^o0-fy z`|L-+#&O$}edzf4GK=ZYWO~Cnvt3kMD${ca4KaoV>jVAR%cv}&^^*k`ziFXkp=SjV zzLo9;!Z%bc%m7Cj8(nP@U4)F%eOtcron8En>w{a$E{0g-W=@5#a7 za98YSKMPrG8FSJqhCP|3QLmTueiDVhwdsQf$avxoHnsiopc3Oj5HsSXpkTY~!jn08 zt1Hj(z*j8b^8VN(l@=I~@Z{$uR5FTGDZfb!7BdA%Kq+;-CtJ^dwrSg8M1j zADZV@i02btIg3s!i?YnBPS>_awxN^_8s<#%&#DF&qcn5HvmuepHbJeW&nrFAs?YM9 z0UoVBYpnVvgP0+NB`M3Td_pGG6KzJ^P8dQAC7If!C=kX2` zvWx!RC5Mx7)GhTZvG{t0oOX7{`{iURj#}kp8t*=os2Um?@t|f!9*m<7c}VK_KozFA z;iHNYPAHK?39qV!DB-mgzWEiEl@KMoy0Wfj|A~tdo>HPbNcaE`*6j)|Z|$h6bPL&r zl~@>zZH@J0fQuFW-+}D2{vKM zdHZ^3@F^FW9H`St{^lE(TrZ&u1sS7~3z_qaNp2TIS=_AQFS!0CxDW7U$R=7hY%7G# zscs!nKtOU^C^7{NA5Fw?=mTH{`he%6O&_$_+kz%o?2D$+9bISQV~I&U+JMwt8rH8n z&l-(78I?%uLQrbJ8=SBL-iZ05r3-d;F~-QvIMXoI2SubK$St;&r5DUEA zD7@BB{)o`PZ;Pp6v{v+$i3pt$m80}+utBA$?VhX=p&`p?+?O+>kJed?xX?J;=tD!} zZ)Ptf*c>O*vO!a8b_a*U4clAnGO38+o1K=cMN%Rv8dg$6#z556>=y7xEC6DObP9{L z^y<+R2^vK#kML^17;#!9fn#BFo+ON&=A~cjvg9&GJj39a91oaF0Y+(0dt+N$Yez5Q z;iysct`;!K0ogx8&pJ=m&J0bS&;_2<&cZwhvEZw!9$UN z>lFIz0oXmraDO;FOk0mXx^V%92e*E;H;bzAe7{rvpP0MY!Qyy;KwH95b~=->^5-?Q-%P`qSGhUHWAwcOt27heO+3?+)1YE zEhS~(SQ0VfCN~=y`Mz%UK(`91IFxhQlcsi~B=gJ_(+K4-pVnYs$I_0@y^ZZ%b~TwQfl1Q6tg%h3BU|yd&W^<#P6J6< zoOLZl7qu=1w_vfMj+Mp~yhRFhw>H_r9cXH8H^9l}w~)dI$F6)!TW6!#RCmBoS#xLK zB8XaU*CowM*``Y!jomAaLug53C}ZiiE%YlfDLLY-FVo`iVSt~wbjfg{w>96sP@YB~hh z5DcUv5f6&RW93K4$++%_QEwBbka>~V_{fR7Aih44&BYM)|IrYNKlEvAL*e|v;6F#B zd6Q&FpiU6*%A6hqq%eHz=*iy;LiZjwXD{~?zZf7t$io?^5S*S7UrM*@3Z~+^g;qHi zJ&1b+$yM03)~#a1RfTO9z5KpMYWz%FU*%sTEU)ndGeHB`@taEX5-@2P{fG%y9Is(n zicoookg*gB#gk!nVKg`6hpd^HJM5JE$WGZjG3TV`)R9X#%lI8$m@2^{qD+uV2IDE7 z#08F!zP`hWI-?_4)nTn*EDEpHxHb~8dp53v`qL`|?AmQtGUPS{HX?Es#?TOT0wHzk zWpD-B`i|#1UEv*KJSr}`l?9YZMP<-?fZz>CdQgeh=4ba#MONKR{q9Ib0R#Y~FG&cfVAJ{Ka zR1x{PPQx3lQf1$3>41k59DJ9?)0io*CAMu$dOBmrp2MJNiW4x@5d0rZE4(y_HXNF0;e z0qBf+AlfE}X<>sIa!?wJ&~^rUJ9``3c)>FA&0L5A%{}Cjn2loQ4N+fw5Z=??J~6^Lpd3n?%spNx#UP{2p}Am2^J`bwp%b;_GJ?tdOV_s5=NIL znt(Y13lqQu$qX?EVybwiLJNz;h|DSgMzSRKs7o*9W;u;m7ea}0mTcxNCi&XWx4T*l zQGIF3F?!kKf*M86ddFx2gvN;bJGG_H5GIu8BcU^`IVEGxyn_+xQ5>1{t%r`(g>KG1 zbSBT;xy`{Y;TwTaLKbOcI%G~ zOH^3Y2bEq!r}D5~JQO3vnh>=R?1@uk9p&gWW))(K8nfoRerY_3-b~XkH^n0Yzav{N zzSm-hK zy?BtQd^TcPyjTm1>qcdf3~}9*#Heq&m^RATZ(5yv*U2`V8KSgl z+4bc(569N1w3gC~nu1#^GFe?wY?xRi<%|4WI-@TmAx~Q~nVf+@&AieSfr?RH0roQ( zX1`|wjAtfyV9?1N0dq8QOY;!)M7Z?zO;H&F7`nj*Ge2P)6AZ7F7qS)QZSsw#^6Y{s z3vZ+{s|35yawR5a^Mk-W8hXti1%?r9VcG;ULc#jxRPKZr6fMRi8OJR}a za!lee#g)@E2;9~dPzpLc4Zrn*Jt^n0Hj9>x?4}JlaZNOC-=JnJ^c1jxBg4)HT&SCc zDdYNXekGcYd3s>g(c5Fwj3CfuRO8z2KK0L*=!QbrEn{>-7I=n&t;O8Rgn@AaEi6;T zxonQn&B)sTWJfyMP12iS(dHUfer$$A_DMd5AcLOjI{) zgVbDD&4pGQt(omPvj#+d!=#1e(ql`hh(!I7j8THd7>p}7!!s}+HpgONh(u&rX4nxn z38z<(^2o4IG0m;bx|3&|EnA!v6liN4u+rVx*0!jzY3cakr3aMxfD<9s76}VjoTyg? z;-o%TOe_s=7;Y9L3Zm}0%!nhA@*4YkJ1Je!fB>*QbrKsuH_fDd4|aAi=~jpbIBspV zwD87?KdQFj(=D3QQHD^@;2WUrxeZ$$f*ehV$%{U+?4re3P&8~%%0jZ-+r~V{Oyie% z(|qaPqM&1(1vv@?X4063MTHVc{(fwyZk zskELx7)>l`F1R)mx@B}a&}=Tp7Q9Y$TN+~|JN>9Klusx-eq3HqEIVWhW+!q3E8izn z52m*4dP?mkc^gMU+pP>@ODLhkA;N!V=iJ3wY&C5|!e}5cu!sf)s`F}E3Jr2ToOaMQ z@u8+1NZ%X@vAfvrh_WJ{K@Sk7eb&C|p}`83jH2-~M#YB;<>0 zKN0lFFtK(l$HR8IodV*DW!1-J_X3RhdzoErmDws)RSn6qd*u(#RCg$Ql>P7!+wN!Hf6`G^XH1+D>qk!Ha15Q3Nj< z=a_o+dKiQu?bR%+8zaX zY#cD3*ni@>XY7t_9Wsm<=Rq3m&F~|R!S6x$z|1}YhG5%K<9duY|#uNpt zNlIcCkN;6soYy7}mRODP0zu>%a?4aIci1g+0UmlQuP{+# z43jmQXjnpV;fjEIp}3DoA5kfmmLgnD4JEr46XiF4<|YP%EYQqUjg7@@6Zsyi(AZeU zSY_c=Ag^nhIR6OaWv%F|622-EBEMR}t40&KDkJ6!cC4{Onr;AFc*H7mxGJ)1qz7V{ z|IJjWSs(dLnNc!6Y*8T!hiFC?qp_;FNn(E;V=RsSROofmc&puYFc>VV#HH3nvhr;D zjh)=bl5ODFQLv3gIjM|+W2sB*Z*iSgEmUH5sxTmfJE(FFUZ&xOe-YLNW`9IKFKoa) zjL~ajT|ymhqYj;Uqtdk`j-qkFdQdb(;yzcVHpwYwHt$n@3-~CUPKiHsCU;Xe^H~N- zm=dDOZVQ%^N=S-m7Yb7^$GrXh%8Vzy2Ew4WNm=|OH`#+NdeSTPhzQXO@)2 z8EqHZPr-H5>ep%G)`@btb!t>GVcwjMJi2V>nJIK-CO7P3<3>AWzU_w@P!ZEyThkHk zhG=tmzpRd(lV@p}aG%YtgG0E^q=AXmPfn-90&nYqm4!sh0)=i2Pkb#xFpsk+EHs4R z4MGXwrS!Z8eRdJJm`{+BJN9;AnEA>-FcN`OV> zD!gW)93Mf<|7If1!i=1Kh2a1-em(*n?g2`VN~xO(V4z0eOgIHGke?hf<> zd;7ZD@IReP*#boh@P(3Og%e`RQ7M|3(T6TDP-g1mB(CxNXac#YA%e3%0cD-;h6W!f zBTQe{OG)js7K|iD%(N6d8Ip7q@S8XYs2o*O&a9!C;b32Hr4RRW->}!sluH_XHX(baLxl)l{DENUR2IB86EwJKZc93o>!yvLt)1_t znZj)aCZ*o!Tv?zKWsYT)4i8^h&C)@6rRGqW7v`w<*jO-U@~s% z3MIWth{U7e zuK;pk0fME>K7E-)jn)CdHyrPr=A`f}R`6ht$l%l|L2M!rSg7s?4Wwhtl#9C&5@#dH zsI$^NQJH+8t>hM}BxqtN&O(smJ9r8py zcm;O_jfof?n4kpjT2IuC^SMoN1FY;PbL0cTEW}1U6-Jp&1{ztT&FvAjpho7NNh-<+ zT*i0?f>BH1!12JHM*f)zI8FIs^rN$biaDs*KxA}gVG9ZqL6A#?P~Wv@J=o`#?4nEH zXsy^YdX3wQl=*B=isJiCb}-qjzw>qQE;D&|W7N~Nmo4UQy=b9+-e&cP2nZcWoI+cv zw=*o~Yh!`V-$ud^`7betB4;Zu({fH_04C=Ng0`@1IjLR0ldHqb73-In7g+Bi+=C9N z7TMOzt>{KmHFpVe8g+PdZ!TGVJqq$+pQIY{F?py@h?_PRmz9`;S&?zP-1P-+n7Jb= z&X>tM8V1?G29*JmYb)`C5>O%T(PMFl))jMR zt+D;|(CXr31DR*fM#dd8+4eOw(CsqtfX0qyZNE(Q#0)DGV{+Ii=jc9~5(pu9#zw=v z`u>^?a=qY%%ux0b7We|w&vvlJ@N@fDo&WaMy4kg>EYm156 zExSN^=$*;sa*ST6c64Q04vfr0IHw0~2~$iM89lIUd)DID-2<~RA6tPhm-FeEeNQvt z!m!dz5^VIyDdZG<_nat^gqu@RBYNB`;iQ-B@#etYF>^fdHHI|I*rSpb7?3b%yaX6` zrI-wv3-5(Hx!NH=yBn*`2oSztH)f!q?~8@w#NBFkZk(r{{bXN3zl{-vKLB3=QIFhb zC#(u&(CN9L=#)w3ZtoBlUzkNU257w!W^wa|r4fUNow+n|)P!4v29@>XW&;BwK?x~| zw>re^TLSqAPW>>2CL{%?s1UUTlU|s*aUu|chKH1ttR^Hlr&K`d;u6UKE|Fq};(E1i z(tM@Xd^{%e61oeL4LF!8B}Ho&`a`?p5xo9%AHSiv%H~=;X_3sbyOW0Ubq*CoF8!zl zzuLH*!h|4-N@&MoA%|&^fT0KW1A@RPf(r!s5whs~IHy54NOm)JMr1wKt#H3sz#!9v z@^NG}`LX8b$ZGOqH5M8qBVt#iCSws8JKG|)S`o4Dm{P<2ZE@h;v^h)=qz*%DLOA#k zacQL7y#^NMu=fs)kmUKdVDuL_e?^ekTL+za_g|7v; zSlU6L6I)IIbcKomf{Y%QB9OLzmwJXQ-j{l&QTbp((M(;p^Tf32w&0Jcf3-SS3Mn=@ zML$g;#gH?TrzcZCvoGu|b6@j!{%wf8uRW5xoC$`v3W>YpTrtf7QO~ zlKQy0Q7$70JzxqN_!TVKg1VwrlI7f`tQkx9tZ<)KPU1;o9IGixA|_ z*Ek8gD68hE?E|d3TxP+9wGl-utzW+oi?J)MBGOUHw>)Sz%}vzP6v5;?o@glan?>{z zTJSRd&E$_}Nr$$RQpBQMwaKb0j2TdR7T$-XEJx+2%kmwn2$7paxt5=QVPjOuuRyn4 z6)R-2_;^f&_n-!ZzO2k8cowj(U9+KS+vfsE;#klibSk?D1jZdI;m&I&Z1}YMLcrvN zHLRxOgbQebPNUhl1zm5?msg{wp?04=H~47KsHnNKBVcJ)qe0C&*HBug!S2rG`4rCN z!N};h5HCi96QjW$(AJ5O!?tmh?u)2%5HK~BEWp;Tq!^#Y|^Yq%vi5}_>Xhf0eN>6H{?ZG+y0t+Y@e@3@S5p`p6ptKTY zk)0@Qkp?v2u(+6-IzL$)D2;5>VU@e;3z8$oUyR7dr?QwXm08zv?TmHu-Z&{5pcdx* zS-9`#Xk9?x5#!&*Z3`B_OVI27if+?h=AD#^#qM zW@+5nERdN}a3*pD;m+c(k?$pcWo1@?vH+ts%|?nZIT@K}@!UN${z~|e60_q&+R>H3 zinO4mDX^4cxdj_E2(JU$$B~R;>_qwpa35rS#CMl1LoaLI#N#!NRBW&;D9Ca@#-p9F@tjK<&?XCG9 z(R^KiM(y;HQ*z3ou_{zyHSTUN8KtK2zL;?gE;V_0)Buq%PEN;-e&mXE8^@Y2lV43f zRBBYjj_R60zTy#mh=6gbTB*;ZE7Mm~8+{9B4R)FnIOFJn@hDS*TU>CganDF;BA15&QX}&y6DZkJ<0S44f=Kj%whJ2KKrxf=h4*VnIKf$+^lmtUB==0}|mPmM$o-3B=%J(9<&`lUQXwKRB69g|(B8fstVk-F&j#8krcoCY< zZ8A8M2`f_C-gOX_BV{lKM^t3ZFq}(dBRieMjnv22aH9^N*Ju?Y361jEl+kZdr-xkA zfrVViHYKu83nRb0L77)ZH}MJUTNubTUIJ%|I#Ejq0er0q-Dgz+^M^f6w)TlTh1|gjpp+4mm9si+-CEZ<5smL zZ@H4UT%q1_`FX@;@Xn$$G=HbKY%6cxesP&j%qD?rTpp~iaM!r3xX&)HOj7SSI}2`N z@}A2tjutF=#ZBCk!~d(Q7!F{$?tiQF)mr?&YD@lK6Y@;3|CiMPtcrPnRWS#!>WV5K z^7-m2tLv&OQB+bxQc{i$O{5!G)tA5ztZHo7V!PvvM!d3LOj0K zl7o^vSjio%tEu+8EKR+fpf`S?&7C76;oP|G8Q zUlwOFSuOd5S#R6Rf=3%PehFQ}MnPC5f3Yd$FP34MFS&}9T*XSRV#RV5<3iYE@)k3} zB*Ihj3@dqt73?#WQ&510TpG2ByFQa7I;C92a&|i`hsdapx$7mrv6A1I{Y^|7#g)9q zG}E|TcE&7UF?`2#6^pgnyq(BWk`l4iuOyOiQA1V-GT6dW_c5p?4{LbNeKP6mEF>hd ztI4E;<7~dT-ejUu3%==#y@|IIPGMAjZ7$!kD$TjfunW(}t;{`v&SX`hZR++goR321fs+>$=iW0g^R24n`u62=eG@3#;Qp3n=c}#tenf(81@V_PhzlnG#Bcm>PY|x22UM0DZt+v89zoN1dE@Z2&tgG4I zcp+Q9cfOfC_P8tFd-R|}l z=vRMwU|^Ns=Uao>dqS1d;W%5rF(j~{8`9i1){cI@C&2}@JqeudrIMk<2y#IK9^@2U zN{HeOXGmbUQUh9!eG_=4!*Z{kBzyW1?+4CIKy)WhQ?x~YE|=e6Kmdy~$R{i}>5xI^p|D#p z>hLj9h&idOd zG@-^pTEIlkdOwUG$$;zd0P{c$zc;FCI?5z=nhB#Lj|pmmn8~pgE@(e|O`TmUyIU78 z>CHHLPJIz|HMwEsttyA*7cC{?8R|;L0kv6%D?`)Gfu5%B)-KpBW^TNVc>hy-B~^(g z04t!P9gy&9K9Gz@AwB@rqBbvT?Hg=5d93pP5WSGuuU*JoiGNnr`LX;z&n_NELA!u~7z92DGR~?6n9vfmEIRKs zN1-4|OoTUmqN^WgCw0gY!9vqeaFO4VLr@eUX8?53Oi`m7uSqe(S%AKnW{$Fvu`1Du zKTAbKTbHF0YKSUSV2UvTYZHqxp~v75q;cCA4949|wgsB*PR383tskrKkgWo{wH)Jv zk=W**pX2@5^Z)1wZ~{y}MQI}k|Hs0PCH|AIW?qT^Ps9^g(bd`A+e0KSQPWH);7d>a zrN@5$$3x2eqD}ui=6{V@{;R2}D$W0icrwj@pn%f!|MEW>=6|?9v{~nWZDr~FXF{Hg z^B+?{Y5srtAN%>Ah^wi=q^uT)2jrap)qb=5UsF@k|4hh}Y5sExDDi+V_hUc*skKnC zB!JxOzuEqyw$fjk{}b|Ln*WpnO0)mV{$!i~RYhU|xz~U5`A==-Jb!8aPsEdb{#TV4 zz?b~7&i{64tvsMacY{~+0oLvxB+=9Lh;yuGU#w{ z>&RIy`pu1#2IO_fIm=>%=|s*NpU;UaY42+64R$t=LgaUIYqz^XFu;sE*x7C8qJw%G zkYH^PN9^j6S-tqTRzW9j*U{76WXwDyzJ$RiyBZ;0*g2d82(#FK*309T?9wV7+m9f9qtQs*6k>hHzeQ? zw!N{bvu8!HIndSCxsv!K^fq=c4)iuS{a^r751nsv!{3&+#>G8uRF3g+AR<);JBc-q zn^%heZSHQxgAv3ZaT|`zn6Jw`Dj`Q1ZL>UN(`?2O0W&f18DLrtZ2oEF7w9>wMKV77m+xijM1(ng4r-m6#VM&Y0WC#s7V^X8mt% zZOQ(BVjh@-tsPAbp}N(0{PC<_&DcIzOu&p6zTkfx`kWO%U{=UJ7_$SHAbhg7fhd$6 zj8)+l+xnUV4Gw{IksMW(G{3eutmcbD|KaqNE)V^OI~?8+{0m$nf+|9&q9u-*RYhkd zs%WLW1-Ifx70tn>?%rTepsBAr5bWp#uG<}GYU~Z@oRfirdC~&HyjSBU!kDY+j60&l z)}jiWhX2R|bv%zefGXnYR2|`xcI;T^a&9DY%hndu(b|9iD_sqVjk&lik2u!*WDufxdHWe7QN|SL?Cz|L#Czb9r+5b$)Bieq0l{efIYp4szmjIF>++(ZRS(jMbx)oU;drPbtqQqtmgaaU4K}XSye4-Y35Rm?bKlabiJ zDtcDFPKjByH1I#^izyqBI-=rHp(PS>lEk@;g=8;oh$2T%!^4M(m=X@jPuZTaXVg;; zH$ieh30jpfBZU!>LIgw zj>^_1oTz0OL9SsEbh=-O!K$U_fGE^V+y)m?VcUW*n@d(i;vp$gf%5~|SKxh$p&>lU zEludFV}|<8m1BBI%0l%}0oz;&J#g?Hm{^o$gTgg_2P=yatpavfY*-f!^9!z~s*ERX z7}q(dq)6BtOw!=&$4XG}1btlt@sGyUcJ^RSn~-B+Jm8L*x^}4nl@sX0XeKb%HYJwc z;4pmdPeXK9RGyA;&+PCBCJZGMjKt$>(+OIzT?*kQRyZ6?J=1{jenO2qbcIp_@_Lz0 z2~M5>D7*wD6h;XNDGC0hxE~IUQq_bUQU(-ESnQ!Itz)LRnMCDn0zL_8!f2!N2>Bg~ zDB!zM9yvlQhQ|PkwOWet4YAgozGlz2HaZlK$`x^vqXK7Kf?xftKDB0_X2ARAT^gF03c>#`w&=CmM!-T-TEg5B6@tj}Di3OUSx z#S4d-(PLk|IVwfEXjWp@!&m7eiygnjIi%uWYR7K-AE>UhXb z217Xzu9Mb5ZUI2JAa(M0(1@70KphXC*WBINg@`*S-YLct;4?`x@fL*4t5)ItUlZQU z^#%+@T=ZT95QouvDGC0Dt{R`4MuU^1k`fV+;Kadb~yj;5!i^~yoP+Y=e z6xEAGNxJuNntotN8h}X2_BA9Gi8S3DPl_!^;lqL9cv5V6lLKTu#e)(+HVFyKrFd|0 zf7~b>ckp@*t<=beG}0uswoYc;kfg_rsJ5;!WrI&^A7#MiRz^d%y%@iVD$V;>p z8if&sMKudI>944)!9VLN=hs#F4B;k=18H`~M%Bo!+M1fG8aG5yAwd)ARV~QX)Ylzs z5A-hSZ0^C*R4g3@@eT`y#$16Fy@3wUwDyp@#UPK{Q6%Uw?iQsLEIIQMK3S-GGH`5*CkyIU`$B9{jw>=+bW5Y0z5G(WHIEQZqzqWIN$t z`$`NkQ`A$3)}89un%m$_*DlIdS)#rX%@qzy~H`gjX#dX>4q!?2mqYK$ogN!*8iG{DnF|9*Hu^5`7QPl#R0a6t9o;wrM07#-o;=ePH^pC ztq%(mSp^RkV0PliKjZudrX zJ*bfwP&Tt`F`xn;d;tNqM^1uS1O4X6+-d`^&5@~D^09cLb1w*q@d0`QLl3yA`6f|c z3x77C@=uz7lioOla~T2)n6i_4&?-Y)F7AgJE3%fS*J-9)z(NsMJnr zs(fzzUWNLV6e7|v#zZRt39L=2-HiwAPHF6K8de;}Qi82x%1Kka0+@aiIIM%X@wf&J zDWu}OJ`bAHxTvW)FbAT9{ZZH_2ue2mNDUg#%`*RJUXHFVv)I+EP4jA0@mI8;^dmlZS7{F+7E>FfW z&Y1C1Qcl1b9WyO8R!mU9PB#WBwUP|!SxUl1r>t0&Rt(0{QidS5IT=p~k-({;EUzoW zJo6dH)8!1~N{rOybR%;9G&RmcGOhn6^Vu=Ak$wI5`)jJq_8;?V{U!b1ggkcoe@EU% z0ll5Qjcvj1&gDIrU*ILYh$|4i+mhIJO9H1&4Z-0igkUBYvM2*^!-fL3{^aV+Vl7A7 zqN6bcer=+M0^>n&FC|glfI0~-$Yi<~dROM0IhqQECg8tb@0``KIaG_n^X<1A~4EvhVqVa>)la9J%AuMqOVqEcKP8@uy? z*v1zd_k^Lc2H-{*a-$262~AiyAre>>I2d>>5|>{mzg>o}Q*b2=UK*5GD4rxyt%ZVY z!A~Ve$muw}FGILGN2rzu7|;8j4H!-F;tCE3rDDu%qe?0T&FY>u*4uk50IHb)BsX|_ zP$C4T3NG=PT;92fP6JrV$5bD?8dJEGQ@mT#a)l;umda(LY?WU}X}asubfM*@Vo&sTNr@F} z7lxT88FDE(xXQoAjgHbcUyO@VLmQ(R45pbr6>mY%zA9QkcOMJUss)0P7=HDj1u*C7 zuLPzxydMiMT(f2k#tAg%Bg7R~y_nupE`}sZvn;TF1EOH@R9ro+oqefXgYZ-^7@e`K z&@j8688TLpj4>s`K67Z;=W6XUH>N`zAr7O39H^z@?2G_$PQWT9_lr|`on}}?yRing zOM(jxzTeVZb>nRqZRbfX%>?c%$Xvj1vtkm1YuIuM4e?#)oB{tF&zylu z_)`Ucs^L!!{HcXM^We|?Ic|NYrT4N->?X?6PetzvlR(%6r@Kgohj2YLnB%)zCpkBT zGerq+dmY-=*1oT%ovnceHR@%B0lz|89nE1qg|k|r2MeLsb0*R zLu*}7sW48)dSR%_%V{yZ9me}wyhk0V_6*c`25LP6^E?Cd#Vt3f4DeJ)32I3=;3tjc zS412NhUYp2SLbP+LRjGN8!%YM?l>pN@*BvRd|A=g0)rHpz~mTE^H8z@ z28-NHxyLnSRF|aq=o!)>nGR8k6tjF32SZ2GgpCJPD@l>Wkc9guCzTLdE03sO;$iX- zotDi|!8fY#$~a(p7ID}J_6XW0c-Z)e5pCpGYY1am$1s-1AjT}C7#Y7YBx@bn>P-PQ znCFUSKq?tVKqp1JkPc-;JjdkW@#1l!yqdGHeg~IUfx*!vdvU9ui*st|e&NZe|K(xy zif{&;%l@OrS83M&`b+WOC*~>6j@}q}q<~Xkk<4sQg8en)bP`-NBaqEKf@6C!&3_jC zvM3fHx#B-n&a>EmmF|C;pr<&q2@Z^iTYn*QUneoc%oi-cs;b7x0<1XI0M|>#!|4zS zMnyPZirjUH1pzGkVDSr`spS4A|6ir?u$Vqv0x)!HGa5q+_>vG{PT znZ*rr1v-||vkI_frUxrPTu^j#&z`COWas}?6XE~wud>L0wY8=A{}b~Rhf$1y|5s@X zfIrWeCB*@`v;yB}3EG+omaGJAtpusvxMm+nj2JY-K`_!We&UAjB`d;-v?5$(uq4cGN=WkoY?(U4 za!|{vIjS5Pn4`xUCFn~~1C-2mh)i7!=a%+1hNG}n6zUZ$6f?C{sP*A!>>Wh_bn8WX zi1M^d9EJU(&}ISK1#RqON`&B6H+OSZq-l|InB?V9$O+UyCY(A12Ye8+i?1I=XNb5# zyhqli&A2c|(gw4dbL*}|Hs_UiVq)yz0bvyDvX~ND-E0UtY2dG{N1_&X!^ePHo6rJb zu|#GTgxmD8;*103Fk1wM$+#mw-5(Tpu6~T;0-(V*-fTz6z^B@14Wh-wInoKUZ zbZbKD#&{1&wC*{cIdtbiF1`+VdDPiQONCOEu<_(XhMNQ=^5L<5g;o%*Cl#8w4VnR&w++ zqLwfN#yhxh7Kd$2tp=BEa2*Giakp+i-w)AfLtr3JE7xMq!hq%Bk*!_WFhs?%fRA|SN4qWgAaeDovmO@cZAR=pRB?{p^gs_vqds-EonDQNzd>Rdprcrrv zQ9@FV#@EY?0926zDlHTsY8O-NOo>Ev;IlDIN58lniiE_VR>MpV)XY~sT1;iW&cNDE za)p(F0SsR(FKyGM$H3I z-yr-Mf43L)eNuUS6(DZ_$Yg8pe7|uc*`%J6?k}KC( zI5Z?zt+C8;NUmOEnV&SmhJCVig46IA_Q}V+6LHg-z`0-zg_IX{aO9h)Lrbo-Pp-00Hc|(lZzk&C^UXvZe7>2egU`1dbHWk@ zYIFB}z`pN;_I)3+@4GT5_sr0HKPhHNe;ohGJU7Va%``P)11LLtnq&lo9TzXCSG~=_)BMlgLc&6}wRFmo9JF5od z8~~e3=bZKaIZj>ITj?>XLW$a!mc?JqHa+{Qo`HSCxEfx&f#k<};l`Z->&LV1R= zh7U@H$xUV9@tfDyaWN=SSWpU0b>g;@1PxoFaTrG(85@f`hL+xac?OZXmXothBBemI zTVb}D$56{ING;6=y+YT%xQC{blj%1|&Rb!p?CbN4o)_ zC^OZ{(5Mey7M#PtBYIg; z15IeIj2X&nty;=c0JQS99*L}Z(oAep zpji_|=DTD(uQRLj zoOW!?WqS%Ys&Oo?&l2;nD9{^8>=~`Y+_!vPmNeH6S`C4TR*(O(mpW~%SXLr!b2$BZCrAF}jM#@BMg5Ygq3bew_)KP%sN-;ib3BDn#HR5kE8& z2LRgx>u)rzlI2$lhiNDf;vFucl9Of}vN5VHeoPxJ);qZxGsh}#kqg}7g_?Me8WN+& z(~sg}M-s~Q`&NmHBR=dkUdx&FK2@8ujy%{r17uXa@)z2x)KF5EQ8b>E=~XwbR6K>T z+JLIvW9Vsr{yiO4{h@KLKRo^;Rc#)rGP_}FCQ`mee5SEBb|~wPz|b3(li2an@R%}a z{)fldrK)_1kM|0M63A;DsH(gaYhwX4_uLoF43Hjuy~w`cU*;?9%$L{Yb!}b73+pmp zRfo~o7MI8#oi(XNeC6wg3do^=GF0&U@9<_*Gx!`-)BW_qJ0B=g4t1?Mv|`QNeJkAF zxwByU?CS?n57$JCk=TDUBqc|18LQCgG?=TU zTb5TBjKIF$Bn9$rlf4pEdO$WoC&IJn5Yo@#b^JYJT65!!G{o`cQ2} zabt`^l-GGRH5u=J!H+5aYqh_+avG{BE*SRDS3Lf!{rKZ8i8qBAPI21Eb^njwZyx`e zn%de@{NIUq+FBQNH+HWqD{Jm9tWlq zh*=h-^g_!`@mp}dx{v+*XX{s39WF*2Ip%*=Wwqu02Y+o&oL7%Z|v@9?O0rgnmbWP zXDLYw7j!>X-`*UQvkKJwgqN595ajiI2>562HCETZ*Za` z_)oPjh}oI5!Moa$h)Fwv%25}VIbl22IgG{dh6U9NaZNO-VL{D8$Ht8t9h)|75)!M0 z#0lzz->wt>snv-ZyOF4wIwKJeDf5jz;3-oB{BVEB1U^fd65#Vo0*ze|Q>R2X=zTZF zPUvZqvI~nN@qQ^%mkWlf@q}S>uaIBvC!73dS}#Z4Mt1qn@2|zb4f0>55C1O7e-rV{ zL|G(2#=(gEhj~+n6qOrn1T0&&m9^rY#+XqNla zgN_;Pfu5em#R1b1Ex9uUMWwYe(dDAvI3lKM)P_F6&_u(vbhI}v4S4jL(kear32aEj zlPT2BD$zm!6E~1_OfR7SB2}S^0UN2-i-B=^?Fy}or%C)rs*oO`HaGeOY;aN)g9c+7 zuzK145gIC%o8UzyJcI}%j(ZYtpd(5QqX7>Xk~c`8nXVfR{7|zEK^e!yX;*VsTvZiN z&xVHL3RtcU&`8}vKc%ESP+8jRmLoFU1b|!+G&>BP&P`wLysD;M8EwTt@{5S~A)Au; zy{o&k3pK)hAzgB^iFCbLPROya91AHJBR-y|Clm@oF_^w~`y(-58z`8&;9SM&^*S9* zU0n^K2!u^{wD-0(M3pdo>F#N2NQTHy$Bfn%gq*Wncr4vca!`{S!4BT$qQ;&8>Qm)l zdrOlJv6f1(7NiI<^oiu?Os5j*RIph|BBxffn4vY6l9N$6tiT~h=4`!Ea!_XVXkRQq zWrars#p|tzDE-1Zs?}+Q$AYQ~GlZ>!v3ODrQtkmw>y4V>ZftI*9m2zgDq`_Sd@znG z+IvyO@+wrZcm=BHtV9*fnDkmZsw$o2XGe2jQQubtH}_#f6P~*#6ppD7|+BExk&Tn z)n1>svbKB}Xv?k$+`%QKDsTbk`1ZS{+uCZp!QAJoQ$MR(Syr`$Csml8aiIwVJUJ@JUF z|B})vUVT~#lOGxaf%#P6Rcr{aS9Psb^J^J|3^+n;qy+wt3@wF7jfd8XoZlwX==r|C_Zw}WLyF=K($%dg7HU! z?OG5lcrD0X!hS6XW?u_}U!k=i4AacaQWN2RFy^XLfU6`ec1P9I40qpZcN1;r0DeO0QU`(c$Rn?CWj{G+?Bx#{Z{G zXEjC%`&nM&^?O55Hh_20V##c^;hLa|h#I6M7#d}Hda7G+>D9DVjE2#b#8OGpzEMaa z<6<7AC9(u@XLF3w5FU&~{SY3dp=iAli)0@YBNm1V1E^b8^CBE26t54ZllA@4L_MD8 zn0zYnf2n#r3+t1EYW<)xP=9!05dSBWKTcDl@SDvB`ocH-OqdKgIRG{w(@mn=u(z{jY!g^uKmpnPmE3|M=^F?Gaqk z|JvvQ{8LZ=>)+h^Uo5w54*jpW-zEL;WZv_Ch4jDvank<^^Q;j4ukCVP(*N4={i&$` z&BXpUkN$VmYr*&V)VbJWn)zO-wZp5+*wQd-^rr?^-l`@Z`Lsx z8ts@&acy!={cp|q+yBm+S7p`zR+jX?6Y-2m|64Pa?SE^gsQquv6u1Aa$zuO&Hzwn$ z|E(E6`(N9xOfLOz&G_5@WHWjC$+SdTQsPnZSig8l-S{f^owl_m3CXK3Bo2lcZ=go-M zl9Jc3)#rGcDjHr6Z{F(N=HjV$p>6mxK{{QVu9g(KlX(lDk3ts@>SWxg=e0uzf-JHk zSDR9hJ*ut`Cn@JI zL`4h4I==c@`}H6%oor@_KS#bVqc)Z-)f26ZrSd@rU2I9Ay19*Nr_hsC|0@IuA4?m# z^uJY==KCM!)mD|_KTOCoYW*({DL?h}zYOxJrT^tqaZ2icMc@tkU)!M=Fa58%v0~|e z?K?4f^uK(jj+g#76JAUDU!%H!;c3d~e;K?JWZpX-YTevDD5-Qe-)Owvj{sTj{T@ zHOGIb^_A>@C*&Ee{?~9P=aka{i_lLgJ+NU)PDNd?r30cqIP+u=bJz;=_SZ$q=XtBW{z}kKjJg!gG9Y1ILUwHH z##up~C+bQ{>d9h~mS-S|#Jb67f0maDgOg;Dt&j7YZaT}$s@u*cCY1Eswrk1M(sAeD zixX?6JPFp93BY4XxjtFen6ZSXn4AkwAu4oEvg2#~Jc{KgFP(h$y-pr^zl^$hO{AD; z{k$&AlyvkZ9ewGsd$Q^O@&6SpQ;yjJJiGqC(qCCyX^H<_Rnq@Y$TM2~zfK!dPy4UK zKBaX3!gQR9ntv1cqTWB#fQ*yY-=?`D>HITxWYTE-g?T$p`u;4~Eou7=8X6r_Q$^RW zL%cbHKGW9AE4}l*{(0l9nz!v~DJaNfR-ELcoS$Txk-StQloX4skQe7tO`Z{*GcVI6 zt-B3RpISQitgL-v!#R(J&yRbzOA7MI!skb=AfIH+zYw)JCDZX$iW{cgXks;Ill*h$ z{4#33*~&f9dT%Z;l(gQPMeA*76vGLFk*m$TkSNa9)rQ%+T1urb8!4Pt^QbwU8kc(e zQ%PAKzlsYctvo9ZCi}+)XwWB)N5xbzHXi5*#SbdJb+w;iR%&P7+fa zlF{j4rzH+dHSvTT3r6%i_)1fB>O5KIe>Gg$SBy4t%>U|nepCDhf345&FU|jncq%Hg z*l7-GcA819J6A(VC6V$vDk>Z^**Pw9@~29ZhY0%>h)Y^}qzWG_WB_bsj|qYi2rz z5s?K8MMnebiYHU)!L+Q($h9ab9ic?rTDMg^Fv$PMM7CqZ)B?r3Z5SlkDuiSQ!`Ye3)PzCcgFgL?WFnbLxIZ8@a1t+lbk zF_Uij5vZ7gpb2r|RlgEfF2}+cu8Im)J+wv;7i@2A8W&1o_Qmk#Sk@C<7U=H5D_yX) zqootE7x?W!Ev;<uREd|gYz2FhQdo{k$+ZMi8FF^w+7t{BbR=d33M8=% zrMj>zhB+NEozGG^-Y0k%?|Nj zMuE$uWHvfw&0wU))QH5W0~5Um`SCz#6~cdWm_8EkYIQUf5xN&R8vd*P}=5b*# z!n#A4jNh;lHMjOOHFh^QE@}%PVaf_?D4>h-IVxcrw*{`YTA`M#j9nsGe<$XNU4+yK;+4gg9UfYJsa z7rsjyfU#}>?B#!czkG3I%$)XrRaIvDzv|kO{m+Cvn*ARg^4#WskPo>!lTs)myEB;q zLZ*@x;8b`r%zt*XS#jFPZU0+op8qwK)us7A5syCq*&Vbw=ReMuaoXc=rD;E<9{c$( zMou1k8@bni%lUuxJYQ-4PsF3mfAQjvTs(m1&BO=z_YyCd^iPiYUz7uYocjMN^ZH*~ zRb5*DC*&#V|4aJ+lK#J>{~wM1ze~GC1;H&UdD;NAhGj`n^FIRMYtcBJ0pzHDGaUkm z(%5*M0tiD_ItnNq1(c2g3TWv|brfJP|LX);3>h=m{=e2=ZI=K2)g}9%33)0iHg4?b z#3D);p51|trq)2urcFTKd2I_gyCL_YK&d{s(C`tg?zc|!^WObB}kH>#xB z%^fj$7{&WxX#kFZGID3j~nYYc6YX!a{GO7WsM~>1~6c*n1MlMJ@(J$7=QcuuSbwAMjN^He?H6n_m|>-Ovt0@ z|MXi1a%ul)&P=*L`n9C_n<9^K{>vL6zJ9UWfH^*|rY7V3$B$|LSIw)forY?P4T#u?|fK=PoiG{C@UZTzn^foyCK5vz?9-3%!qw=_^YD9hpJIUJT=GCI|2$>iTN9OL- zW$tRoQO24JK_;T>BW=$*Fk2yvcubm+NS&iBx;CsNQF#JUlw%MfyQ3_Wuz}x@A#6;k zN0AsRA3)_Q5)1Wu)wrb<0@18qy_MdINIdGrT*8#W5sJuC41<}BLfsaK=+HQ3qFJrs zI_(-o&w5O8RaHcVRssK?kAK!x`|GObqf|U9sc>Z?npF}c#`m$~|FE-a4-~JBT=IX- zJhT5#b#2YO691ow2aERs7<9PpR6;A-+Ykx*oJ87vmF)IXoJIfYb+o3C1Xob12-g62 zpbjRbsETK9ox@QM%HEKy@*2bOP#O*mKwXfO;TJACf;_nDw2Jy=xNsB#^WxHINQ#B= zuc7pytd&#Iu#y^zr&A~@N8`y6gm)WKB&En|J%ZM{ zd-DT#tE%w(EBy13zoriVziQs(;%;{HpRWAHYa_?}2OOE@Km5Pa{GW(tCTgW(2E92K zO8{~x6^9$~@Pgelf~QqoYWjnTe$d;4oS1H&>2FDk%%qLj_EX6?#C5wstfbin44FbC|M4 zYq7uz5ZE#m#3eg>P?%lFn{w##WCIqv0I)Ec32Kx!C6?acm}&UlpC;U|oY)S)Q9KIM z3xb1@czkU-K})tvA>70Yhl2@O4OD{j&RWL$x}II39ZN_1H$OXu7znOH&& zORhwhs)Mf!)G;> zR6?mtUt=;R=WsaW&Gt0QWSqwy+f&JWGroDm;e2hRh8!P zpI2Mb|4z)aU`BIi6R{zLQAS;Ti`rV7kh8p^VtG|lMMZOOGg`5v7jNSIULWcqQcp!i zpo3TiIfqiIL|sM2@bIvAxXK$(4p#JbS8RZa{7{npET_VfH=GJP7djR|8vG+m;f0Q} z1t}#Jkr#3`L>*BWP|+JU=^(L!$O}7fLD3L}^oSH2OiP3Ef(lv(5u6sl-Nh&=M;e@J zY6Mg7kSwR1XecQUG>Gt0x=&D}Gy*!NdT&Tooe1Q)1}ALkE8x8Xpv2;)grIo2ye_S* zZ*Vrnu^1OimG|PzP86bVtQ7RH9)*TL$&hO3>uo8Y549|)pnYD@9}kZ#bT}4-mGwvo zH#niRgr)r?Mo*cZoS?RMkZ4W|!ZpIqg$txSI_6xcNt6qe=pd3J7*0*?Ln;EDZG)4~ ze{Ui-NPAr&EnHB6o3?|1SSl`D(60^b6qQ7YuG1lWAEQCMX@x3f`A(ApFp| za7jEW1BP%Oo;PFenQ^>zTCd2%&V`-q7ey}4p0yliPN}r&T-ZbY&94mJMZ_X;2~W0W z_A9?~n8U&T7Wa()$gdQB$9wcxNXAfhYrpd=8^W7mC4~z%(I0u1g6RVDqKW=6lv+^1 zhK(f{Dv3(5v=m|E*G^utkDyRsCf>JE$|4lgD!gR@+gO3FXn_j!w>&GLT1)4`E~>rk zq*hb8yU%80fUW1k^t8bdobgZu!Mvkwp!RrJj_3_({6s9sco60yc;XJq-k6-KU~EX$ zWeW^FO(TdG%%Kn&0c3h|wvb9np|x_d;($T8H!6rHw!g}`a8Y^?_0lg^sPnE{4Mk1$ zHZAM1uaDwgf3riZ5|U$ZogzgpeG>+cR$=C50+%u|G`8jto;Fko?Ep(|aB{H?GiO}6 zKIk|P&Y4))i&-joVIX-!2rm>V)GtTk!wAnsDFx~^t{exQJE|m#^L~s;{3RB449IdA z^5C2)L=_XDQBqP~)XVhhf(qS`i{4_VI^cs=sRxk@8@X~lDXZy7O7$+NNDyE_aUYRX zRqGY*Z4y@Cr0k4rNH`r1qI|>sNyk#C0r?y{xD99{84%1mlc@kz*5gEeHh^5TpB{oX zw>EZ4+)LChF6Vy8>0!`&lXAl4gm==Cn-&72`Z)}DwY zle!Xh1ZY>ptpcx1AW6-J%M!Q9%q=JwhOxGVgjQ*XlDXMhr0G@;WttppMPQULB(108 zo6iK9tItlmc`{d+pf+=+5tHo@CQIY&?5DFMt;)c&U@{Cy5m?6YFHCDlawH;BNFItu z!pvG$Bv3EvNhcDRCDF+^%xeX{17uI;z9SxsjOY^;cP<`Mh_yXgk)ch}0otZ^3XNy5 zHpLyVnNlg-O4bR0@?mM(Co;S-RSC<+TouM_`7plaz+#~9%vv7$3p3s{m&bMbDg)#d zH8db6>46i#i0KC~<(T{^e5z?8^vjqOm3TU-PeBfgx9}+=Od9L7;8Vl+i%if$8AYxR zXXyh_IYkKU4KY3hI?o82eJ#cZgaM(dVlV)aL^G^{c=_QI8yCiM1gu_&&3J7}CBZI4 zRzb*MbrP&$+8oqmRFk~UrE(^$o4yhygh`H<`r~P; zkWMNMbl;74gG8xA6gXCOTq_1grL~k(Wt`7R6+p`%O;_#BaH1g@oLU>4RemStG~v`x zgLD3TC#qOT_b3Slp&G?Rf`1cR7lVqJn7q_5gTAVY$|~gZ)%o`alb4W`gcH~ZvwFdM z9a;^k){G>I5PJmbsxtnaD$^DarQ1SOI?OEa$)f+)RW4&}BbWZ)Uu%y4GtXbT|94`Z zlKy`R>;H9yQ+@{l1?m4a1zqU~Kv1Gmtv`Dyss2l<|GYH!{SXWT6E0|`>95ItX29z* zNO(>`oh+4(55APg2Rgfg%5|2-j}MFv19l6KDs2$gRm{N}S3q5vybBz5l|+<&x){+a z7+1!XP($Dm?TEkt&_Gg_5d;3|Tp2 z=9p+6 z5QAY4T8{Z4_+7a0M$1>RqRUP4Gn-(lBck}I#7+C`I-#!;&<%a1unaMa`4*C5p!nj& zc*qmXwJk%JWBP*Qmr7Ve3*;gQhhShBMFVIgo+exFG%WpgH4{^F1@j`Y6;j(G_JvRg zHAe2nTXjrisL~;6C}Xzje1PHuNb4%=<3K!(k;xS0985$&v_Yh{Y(l%*(n--6j&Q|< zmWxVL;glv!u&_#$Of;zitvaCMpmeMPHqvYGgii5-Va_59ybid86qXV|C8;Waohay0ccMiN6}MSdTL zsLEOsPKcOik0?IE1QJC^3oGJ$+`<Lu45@0XJp z53O=Ctx6Fks)mL}Jg6}iPR^F4P&y^oJDRvw57YKPHoIm9r2eE5l8Eb!L}zOu^owrL`l_WjnHbCqzb;?}qru0-2Lj7$t@oQk1#P5E6F?+XN+& ziq}Dw@{Z2(p039B^4=wl9ZP!-w9y@~1`*wgdL29vBw4bDK?>?zbYzom__5R)pkM$~7#h$o)RI zZRCEP`+bIC7@HXzn{7Ye-#_PZ{yFDy9*^_7KA*4m^To07^Qpy(g`LIs&o?gj$hzoD z+?SlS-f}qYv8&>25|B}FiYd%5nj(f9F+(2SBf9myoI&N(_G5-A1{9kE# zW;**Qh6vLhx_U~*var@(WOk0VZh6(Oqh_(-=<@Ff*I+_>Sg4@WcP#mjKW;oMZ&ZL$ z9+mm3(O)K*N0pEFs=rT4$O>o{9#YBmupBcomOO1!{-JwS`GkG*^%H?caY6sxeeyTJ z#{w`vjg$9!b;A44y?|8W#N9>H{y!4KgN74F$KPyUFFeR|`B zNf5SIHTVVgQG(poWwC_ckGz^+b-akAeC}}cc@-OX|9RAuEJ&)FbPO-naiu&Cg4Eij+-7=AJ9yFE^O|Y@nc;cm1Nt#kNMyvx4~=We}Nf zDW3#It>@*J#IJT3YKR@XR8cwUqWu2u^}SPH#%k+TqInZ+8~RQq9`DF{R`?I#?cHs_ zd%j0F_@m7spDf}1L$RRJW8)VRYyLSJ{yJf3ca2-9O3Ug6?}hr(Q{}@dF}&hu9X!q} ztsje2J1*WJcs%ok6K7q}xj0#Y<8Mt2P8t05DB!)U9D7&Nt+>lY<$Rjt9|i3vFZ0h$ z{7sbur(D&#A+#}R+8^UP@pZ^zr6NkkL?o^we)kJ0p$wc)aie9D7ww=%ev&feo|Jhd2nTHqOh_x{a2*Ph|Wli$8B1Uy`e>U#t^ z9dVQHCJq;jtT8B5n~=L2!Fw`I*X7o~DcqyWw+6=SUn<<@{*gPFHouaHIX*VSslIUA z%ZFb@%H34}0t_Ge--^i`Fyb_R?FejhjMK7z>e}_VrlvN3nsYIwkyBT`z zDogj{e9F*FrHK5$6)i20xxE+2OR=m5E_gSpq-f%p!sOB$fgpAH*7C%7yIDJsb@)?b zFF&ra=}0-B`;LhiM5zhbClM3Mp23Vy3$_fXYio5s(8JWH9{X^tV-v-x9?j9W&9h-U zGBshC<+<551QguQ(rU5_fh#zT#HR(-sd6=fuEcYQ{P$Mzl*buh(cjX_T1-@y=>L{< zJp60wV65KL`NJN0T|dPilqi#_kT4MY}E8gdr&K6 z{$X&^Bn@0xRaI71H;88xW!ygEc9qD`exIY`s(a%$OYBLj|ECL&V9}%gJcU*Mi!JxR z+ar~=-k-b5YsHVVP>;MjyslflX?a)?2~K^P@TIu48e`%E`ublWcJj>o~&2k6m&d{hk-^;5WTxW~94*JaPERcQhTloKjDa$J}kZnDRn`v(xB4 z<*t^2PBMbO3^4-sTwgg~k#BVlcKwv-eZ|bY{`2PF6-u6UziMd%y9SWHomC(H@5be* zy8AuHJo0~DbFq?2;119iZhQyt6p`fLc*J+=sP53`d7`*>|HkS1rMuOJCz>qeDetZs z{nPo>SV_6%F*N5^w3Hv>_=Eg`F7i24|M>B}Zwq^A+xzDpT?N@&$fnl#B{WJu6QD}k zzTx|HHahu}L(%Q2@qsavhOj3JKcw~C)^&>*{zC}d=ygYQmYeU^mpgwVe%_ZJdK1&W zP@N3_I`U9+>YsTRbN}6`Vl}&8XI6!=0(Ro}Bh{jIzC5@o>1pHnD4NTuU5@A0kFzVu zrqa*VZ#|9v5%h1oFv$C3K*WE1UYuJpD+Vpki-J-vl23m07@Jqhvx*CU{pIzJh<=AY zJm{3NdSFYk{!%CTdS~=wi{N9Ck`paW0A_G{FTPOXq%ZT;jfnIQF>pBiW~W0g^&d5&mM-sJ^jZ@2s_&gF-F}6~!4A=9MU6 zMO0sDm~-0Ip80%rFZT2D5!6A?d05oWw$eH-J!jx_`F`x;?ZAiGrw%!hrM9l8qwcy^ zEsx3)Wq1^RRo>IV&G{NkaYY(zjGA5e>fPN__W09Ttt5A^k7`xs_HNeaih|0Nu6s%_ zKNG(lnkMhrOEaxJXnZL>_)cCJbFs)hNa6E% zT@LqW+k=0!5)}sx0{mlIkgJ`!FF!i)KfXnXS$XAoqO`5OieIo#>&b1x&B`|~^{%Vx z9OL#cy7yD=Y1PZWDpOpgF~eV8uI;_xU$xNJmBuDpAnd^n`>&p34!I?MfKD`{uHC(T->-lCh_Ia{T$>(o; zPut4b!T1LqttmpkmXz|jv*z+X8UK#TS^YS-BUe`Vnr{8`R~b`Q?r4uxz3%ibJ5ta8 ziO=#78(mzagk`Ii|LL_pqP^P#?^$;(ZHa+e59g7=j{?dH(*WdH;7s~l05xD`a;q6aaO_o}X((z?V`ER2A;@uUqD1zkv@Wz)vA3-rSLCR1KT zz}KN*c7B&S0<%5*Y(rThhZfeRZQq}PTroE>lAy90u*_@V=V&0B@e3R;<&+B_D0bJK zhj*lPT}gWwqzmdWuy+VtNsGPmw%ZvEScqRR=<;!>CLFD?x7AL~VK1Ns8ka|tzNUe# znJ$A)AQD3DGLs5NAxP`SLJAHVY0dCng#z;2by?F#7~R9ZiyRn#YaP z<&mH148_Lf6rZFAl+^*k`g*3?78=T;%$l(wv>YH(FM?#M?aS;Wlsf~Ndko_9kpB1X zgYi)JnVKBa{YgH6{n{)z-6OG}bi0{JorRZz0%kF$Gkd?9s8hZRUyNtVk@Srm(|QWI zE0!I)srH6`Z7x&rUn(e<(vqk?S3yb|Ein0x+^Z}HQvjmA4JDMrYP1&NyNn76j)iFF zY%`naT#lp==X2BktH)CZ0aw(v2+jgqL8K(C_I?gdq7mHJpn;xikdQb)O-dkkC};q{ zcbFoOtxQ@ob8gz4NR-F{4{DO3hlZCg(-$QKnpV2aLbB9+T7lx5D7Ev6W#8HIyy>`l zqt`3~!c07L;k~ePL;yYqSf)c@HIZ_0A@KQM&4=@ja@JPQEfJOY%a1T>;h( z0Ubj2-j&!YXTMNdwEpdoy#qV|WWMlA9UES}G-Mw$QHBBGbKss4YcoR_X5J7n_oDEA z5`F7seNyQk6Hr8hz@+e*=s|5#^9G_0ut$_b$2kl)v9`vOiQ;oBQ39q&7kXd$EyDa^ zSGnH&P#E5+=l$=|L8!lzn;WewolT#lu@BI*rr%dJ%Ao$+`v6_G;z`_Y-K?+n!SYuD zz5RtIVq<-=xfUzI!nr$xCPKGwa7f zpr?JvS{_>G=wp-h=%W-gHZPz{Fe`ZgD?rO+D!e6dKKjb7M@hh=W z%C2s*0LD5<0_g6*rCXDvk{*^rHhu#qb09yS(W=&td#y$iVr{X)_zvKo$Y13Y& zGJ1|&q$=u%48f!n0H=cCdtVCBdbByTB7%sP1AH=N9DoH5R}?{8wUd(S9fOF?RIgPv zQvmg&RMP%nB%gpT!@I**Mr<1kRhM^c+{HyDYb=f8b3sJ33<>diZ$l1ypQs{e zc`06T-epD{OP_#Kr*M%9ld%$z`Yz_|78PBP8@|ylXm+@auomLtpb?w5_S#4~n84|< zUies>0F+W^Vhpt1-Hk096064uepqRprXr6bXKNtMbkIJwEmM`dNi0 zZ(5?CchlYk$|;Olm&{iH$Os{t_q_&GHF`~$3OnV^LE89eN7JW3nsH8!z>AK2!{Q3Ay_6J2BEJ@u%|SBj!BSN+_eHwpP83`=lNhr zC^L#HJA9R$b{K(`$qif0Y$72y=>&A>iv_bbQ6U}5T56w}7P&oMq45nB3}_%p_dg?Q zdC-8l&Fig3;ti}uLSs$=KxG#S*l(>9!N3&`mfq#CLZ_f?2G-5GoVA?etd-J(@YUFB zqoDTpsxGo4YC$|IOf(RSpl}1{q0rfAM|SA$@NTRhi?Tav27p6E^7G{D9F2|p0-=!Q zT#!R>uu(I4%5t$6s>j+lv33~N@{(C;cBMrS{e+>eFSmc1@XUvM?QJR->7lm1$rQtN zR%>8~%Y*4D7mK0aLs>~ar?{LCCQ<(ap;|yLXGhGOSOGg^Z@fzkIB6E+hgeBlx5tu) zJj_(GoAJ^px~2a?E4Xi!wf!TxjNZ{B1BcgQ*t?`yC3VnYktId10aUS5^4-Nud%K!R z#VdH1wO5g2pa3{Md)%)X(k^Z71Zh9lq%zqbK{tZ#w@H|4u3Sjy#ph~o;*z&7R}QGn zI=tYlG>k`@~fdRjoko#={-^GM=Bl^?O9m^9Ff(p&s2Qt1kj6)?KBk{0h z$ylA?uogTUP7NRdO_>L_?ifbIPc>HmcQgRHIPMrb-#F^qBw$Uf{6jeuV6$jj$jUYl z7q)KspROKrc>xCUn_47nglO|>n_F{>*0Z?ueAkta!$^AC zMHoOg;t_}eFM^>K2aTX~7)qXn(}rV_%Te7(y!BjY8y?W)H_2mayU3;!p@avpPTe8D2tWfI>?27`ppra8%kZrCSYjQK2CnDy-fUsU#;<$x!Ixj z4EKNlfVpe$hdhX<41ySYlThHYOpnLtof?r)ngaBIj5G!|Z?@_}g7)w*1iUY{Kp;0_ zZn8XMGypGFRUaxLq?4xTS9-i+$f0NX(fh@90C#FA!nEAVkn|{O*qaWaRCgwQr_ULIt1o9WHo?fijqK6% z7v`&3a%J_jT+n&KB>Zq``&bGO?P@bIS*ozwt0>QWau5JWVW|ymzhEkwqmamssmnyq!ZJFnu#o;BQq3(1Rms$ zWcnz&`T}>7At$~Pj+|wMN5X*sWpT}-L5%7Be3@F^#&SxMnG3fvss7T zZZ8yfc6H(J6*ujd-|`3X$Y_E+a_1fK_xKkQI)f$mM4yH^lHM=14xK>luQ6=H8^o>)R<`Gi;!IU`A8hB@ zQb!#O{Y{b>0g&qrm;DFE@_iW0AlA_3FzHAp1%6a5)O@f3a#(O0tAsNKlzWJNj0D|H? zY7>iP%+M4-8}aNp+P`PT?l1(G5YRbn`|yReu$F6Qlp=ad+yB+86Mej&-gX3o*PLe=utZpMF9q0p>M%e*d{T=Ex z&dm5eMbzQHBWKzjl_KhF{csd$-uKI39^w%+Qw;uCbG>4{R}%&qxT$9Ex3$qa%LfPT zkD`g`y10Gd(MqLQtbgZv0b31$h1MZoMi)%rweP$=Y?Zjeh{7df1Dn!< z8eh+nQcYlbh?33KJ-?j9^r;8&NeCP^Z|GY8O?6+L{etA2y;x}O-dNk@mXx#5)N3}= zED2ksKu@REdI57w^%yMma?$#QAMw7(u;p$kHe=9Sf+?<8gQAa@hvbgF|1JIGV;~B$ z%P1$#`48!hA{lF`W^624*z|kIO4WDgP`G;-t=Adm&tUu7R5sW8;ouPvc57c6^B|Sx z6tNiXSO?zA0go*X2BIU@y3K@q4hap$>Jj9Fn!xWs3>jO%+OY1b$G@BatunuxYPwDI z2s43`ZK#%ebKbYx*(>SVPZ({rd0Tp2J|^Fl@c@A5G_Xs$Ai`_eND=x@-QG(AMgNpc zGBz4S;t!w_d*tYNUpwGF(AlgUl~){69E?_^FKB+7!?zwG1Xuc;P;6#V>L?O{4fJD; z1`veV4BswJw$3J1th#QNXFjfLO7R3~=W~)V$Ad6)B`4BonzeBv_6O=!%snL(w;u$7e~61dG$RG{ofC;zPtDYxtN4-klDyObWQV0Mmcx()gQIFbh7D;hqklo9Ia8**s&gZj z5MD{h#qkPUI_kh=wAT@C<^1-rD{!CzuLpiPN(R`j8!{aIr`@_Fg5mlT0iR!w&p+1{`Ri0Z6n z&93TExBE~?>Tcjs;5`{kb8a|HYBFOo4SNAYgM^1{-TsUQ)l*15P$5 z+ksQrD$G8NT-{bN>;Q9w9??qF{od$EQ{9^r=~gOL5!>I=ogu86(dS*3v!snVpLOA* z7;)R_oO3B)DvZu{4DGiJo;3l4Ojo(F!{{{k!>#uu2S&Rj0-HImMMx6B(y=H&=#fXw zG8aUH1EKpY20VMe4a<66LCM3jcbjqf&P;9!@gh5vHm@n+I1@&Qrm;xTO@9;_`zz_r zoe6|5!1*`ROYgZ9*yEDM>AB=3OdcLvA4)!;!KzkjJPPEwU1Ne<*jCxWtHrZ`hJjv7 z{FPM$dv&TagWxskm~?5^8A5ND6M$HON4C_9^JSB47G0 zl*`@(uqwOeL6fK;QE?IOe zRdCyIVtIrY%Wodau02pkDO$6(&Ct;8;lCu`wW9=(g`+=HWUipoZ|gGuyRLg7Oo&uJ zyqmO`gKc7_cz{UE?*5KGV(7tCyrLeJf=)u#FsPzzzt)x+bXnt4EleVK%q>|bVjdP! z${73$LxnMo)19Fk-}AmoM7WW3sc%4dzwYSQgU$Ot<&6d%mEEa#Cnf6FrZ9eCw1sIb zXftbek}VTK`C{)k9=h-+CQ$<62<^C-gPwE_UA$F>7O3B!pB>b6xBTw_Mni*fx#iaU zVh3$Z0_c<#)4LpxwP`ZhmI2sf574ge{h49pI`~VAX%L!60D7KB=*Z~8`dR@$|fNlohB*$0Cd)IL2@iUlDVC&~Zu*{|5D-AjZyRE(BN0{6ahv3E0g{=5uO zsw`O6*eIOW25%_QuxhL5r z55>49w^@~kG+?@#cP5L&=T8@I^kaZ*mJ{d-sFhpho7iO4$}X6_t)bJz-uk^&hw+>( zACKiygm|$;vGbnATZ4(Jj@0FIQgTor#WtCDYp1r{F{l*fTC8cL$UG2KMk8@!&rCJ_ zSdEY;PN)V3wADBZpn)F`TW7fSD;F*lv8iwZJ!n~vCP8@8MN3on=gInlY zY+pJw=w-=9W&z9>^$RrFsLp~+q?ze5TmDEvnRHQhgbP`kF<1)1mXV7wU zQ7eUiYWr!9Lm+9?%hdOvYt&34%mq^>0HCiKqjiC;eo3BvfqOn^9P+{E;003o1V^M)aFycPp#eQ0B$_iQ7p4y-sbSevCo-QY(O(rA} z>e`!@;Yaw7pC60*m$2*#0UjQ5)tNGh%i4NPBzG99V)Pa?oJ9eeVOA9tVN`gle4XB( zh;e9B-Mr@!BJFEa@ghARMJE1{PYxqC;KjrDr@D`7Lgo)a$hYv#4`PgaizM1@&~}Y9 z78<-(rbwl)7s%8~)KC*8v>?ziMqahqEZJ*ZB0D_PS}Uwi9-ciNvc4$btL!ra9PUC( zKu7p|3N&9cHTL`7x0yLO&8qJNxUkmK*#?^HfAhsdSDX8=*}&1nT82y;gSEm`hq0KS z645N?4&qnnq1clO^*R425UQg`*vUJTzP?k9)&!3Z3!tnR)3L&Ohf{di12%JpwXy=G z4~%ShjG9i%>~A@a5?CV=t)qL%SOyLnp<6KS95l+OYOIY^g5v0t?$M2=Ai{436|(V{ zt@|Idqy4T78$aiKd%B6r>auRmiMTltIIcR$EAthDCN&h|K1zu*H*>5Vj97%dHdxqx z)kK{$V+P`kTBy#2 z%}ql)4$!h)jzS`ht4;5}I{9iWG2J0=)7{x(aO83d(oZ#l-d8+NH#ma>b>%oau%}~- z#Shko7-jV?XlX8Rc*n`uoInEJXp)8f!uDWdP0%dTw!EoF!+x3+Ad~#>r?S9(3F!VS zoeO7tYFEr$Vs)rtaEfRbl(k&lS9V5Rj2X15#Kl_6Omf3&6uj)*vSxdhUz|j4{~Op4 zO&?^etH!2@ZBLi8!FcZUJytIh3qyv?s`>#C)DK@F?0DGLL|6c$0j>v|TU}FBL&iks zyYe5Rjo|FVLfQ`VX0}$WVcOe+Z4of2c*=^sk)gN- zu80Ag_h^k*)Y)rcj-r@b1!=6q?P)Xdr{^M?fE|7)@Rke!p&nt2KS*c!yz$-Qvq$LB zD)REA%N!NLX~Y7FvSw-Wp{=^yq%%TyzW#8x0EOC{7*)?j&1n0r_6uVh*QecvyA&a- zo9&Ikq+ENz;m~*YKV!1D5lw12HM{vz0EdP>r%-6ZWCNZJL&ymv7j;uVF5R*2I(gE1 z`+UIK2U8Bo<2NMl-s8A$pnvaza5o_cYpM{`2%^v5;EwH1D*J{C*-sS`86Sg@av| zHzo_VW~v!Xy-Z}nah}zEuww{|`3o39!sdQSy+}SVy*U*^Oo-w9oi`xij)EM%cl6Q5 zkVk62>M=K09`qgo0XB@yeAh-3g>39^uSp;tqeQH!p4~bvLB~^|mnQMVMA|A09d(_cn%TU-@}G8n>>4SAY!bTI}wV@L^3f2IyRD zRhmTyU(#SiO_Wkg#dbG>V-wIJX3e|P6dtEJ1Z3^g%h-SUhKb=oCzSRdGjxx_Ot7sj zTrH}p<~wwT%ie5%zd6T?M6znwKTs@i`*UR;FdIDCIPG_kCU36>B+e<8HxZXCm8nVw z2LyVYrR6O@;4PhjInV%CAcc@S6JkZ$ds3B-0a4h#u(#w)&=ue{ItWxpyT;D>(cx7X9C+ej^!W+^g};{^q$kfOF9BVL3Y->p_Wq0NET@X8(>Q zHTjKI^UxyBBN+p&qM4VQ2>INujEjI8IxKqqwcB?;e(@6Ofnm~>OH=fvRQq0}9;H*1 zK%j;ID%eG)C*LPqg=A|5Z@3{9))9Ion85KN>ZNB{PEA{Xaf5)Bc({9rsBZYKR63xp zY&j+buG9Dsy7sp~NN)|gM4kogS4=jV0Gz5MBZww)dh`B`xriY0l3$r$;0vqHQ7)RI zyj|VOH}TZ3H%uC-GwJ};L0{(sP7(w+YKAO>g)ha-v52-`+$PbaIS;2*>`pxT4QQ$5 zy-dhj#RxnIc_gs9o?Fs6pI0it>s+&*Idii|0tTl>K3+VY+0Mx*@xU%V(vVMFmPmQes8k15jit2?N$r%SZ5Tg zrzPfhzlc}Ft2&g=EMeM02W)}KNF{z^*(Nrj0NW3aG@m|Mga;81H;T){wJzw);c5g~ z8nqQ3b~ByCbZXOf`z>pv4eHh6zYVW)@WJdO=WONRL=?82G?h>Ss0SMRUcD2@66Qqf z?Y14HGs%B0{=IZ589)^oEuAcLWE?TwI$`d#L%I3?aT9uAtzt&ck@);Tds7y_xWjO8 zhqkq)s^h4Zx}x7qDcpCiCe8yXHc~EYR}XpJWlYa)z5N%?ALe&+Gosgo_C)Mij@$Db z_T%yMYVH|Kr)>-sr`U`N7;{x`{)~7%kaYy>#|(4=vS-%kC6!~X(i`mfo_x1e1GeNk zHXRW|=h{>T{Pz(LGjsR6-^}8UNX8kNmujhJ&YYP-1;%*KhY_5`GqSTVP3nZw`P*%cog~yT46#`NZRe~T^+KW-*AqzWnAZ`@7k4y!t%kgee;{ zlbV@9HD8;X&ui`E1yek2c+O8bIz^st{b)7t>Xz$yOW{hFN4Bb`!O2&HF09#%UtPIn z4L1Kst-5z23~=Yf5a}V5_^0vYm8|gxa`7HFU4HKcpQ7E>NIQM|GFKyS;`IvA?n-wYegZI2G4>`;Lu8ve-tSz zINTp{#^HmdpnPSx%b(*)*9s4U1<%c0_=g*@1$rKzXUxCG+d0`$qdGaK9gfXFhFb6&uA^ z{HsQXPDlJVr}5~+;Og3q!nU&~@81cyhv7`nJ$-tq$Kspa>%6q3cb_DE;2R6?{PZI5jJ1)Amw(QNmH#E<+^ zCnXQGKHfUhp;nU03v<6|5OvzEJMD+eo5$lknOptEuM!&;IJ-EmKDqlIbQ(J?<@H`d zHttW+v#&qFCKG>_UxdwHgmoW$D5*5!Xx)yuKrwSU{;DCV`|Fo>?w+6GbDWQq`(6p^ zj^_P3I9z{uL;dQrZ^9x2&riP6aO*oO7k%EbyZQ^T$nD3E%o8?eiWCoFxttC0%ZJym zjb5zf{7=^N>DxW2W#rrGtEZ6q`u+1Z{$u&+U*s(J5-4lOA8*e;iA)w+IUC3Uypf)R z8rdJ+&Y$))Ifj2CB&*wu^8`OE+;b7K7BL?(^%o7f<|tAaC|Q_a+xKzvmN%a=LoVTF zxp<|z>&F|D8E2IQ$5TF@{4S}c+hJk$%OpMCKrS}-Ca!hU>K*2NL#ECrGg|(EyB48* zJOjBL_-Zxpjq~4^b3VaQ2A2NNk9jk7zdze8Mcw~&p(W;?ka*5h{x|BC-||IjxlfkY z^e8JF4~e`ty>NW4?lI?m`<8@@3vlz-QIUGZ2iO0deBz~+kzX=up7GfGLUqogg_5%C z4>`Gb6br{2^zpT_M<7MKn9PMs(VzT^mTkT$e|-dg@n4!poj4EmcogmAOks;soX2EQ z>NRK_?A$-r_Wz})UnipR6S2g+^ZRu9A!ZmA`q55y$rgCRnHp-&d*0#HfCuX5U1u~<5uC!rZ zzkA4`$Iw;(>h-s#7GWII4{(uur_@D1haXc`JGUPd!%gs4bIBC7(34XtY`z{%E=YlN zcD4MoKE1OjdCI2lQA9yT<8e6^4|t5RAV-Hl$(f0#H{VsD&+&yU24vYOHMdvTYg+_P zEWa`TuJr8hNt3hA39nM~=cG-zpSg9MK7F3=N)V^jpVs`z2LJP}9d%}%r*Fh~>Ad7L z)KEqKkvle;^*xLOC!**6*lBEH$%pWbFW}f>io;c>-J??{nP^{)P?I4_%(H4H!V z`R8KK>9ET9=>9tKW84#*vK;vpZi7h)H%l7|)43g?Drc{HDb(E=J&cG^Z8)a; zNCoE}sGk*OsGzcLcxvMEc=tVeAIIq*07Tv~HqU2#K*E&s;^$V_%<6x#o2uS*pE?Q;OxA>mGGCB0Y$QI~La@PEieyJBsb8&BzCLWl?4}qJ3~-5x5Nb)%X4R{_Q`m zJZf@nela=_KX&!L<{Qnsi2{vJGw1?x<}dstvsDd^bGXEAJeeME>o--c4PB9O7=pPD zofaG7;W=6vB<$_@3Fx$RROVoi?fW%*d0UYoIJTElc0h6 zdyXy5d*w0W1vtC!y3VSFoACt4C%GMcHEZL9ou>1&gdV2Tw#5gA%#Nyv%vXM8>J%l@J2#k&q~^{!!M7et=5i9hiA)1z!r zW!4g6_)rB!w3LK?h~477y#HwW+Npi1-f_wA*LLi<6yHY(gkYDku!?dZT~{{AvK z-KoxDEvcXTR8s$NJF4jURntfJt~d|)s&qeGy~^|P&gC;Ffjq)4=hq=YS^=lNT*}V! z4i1;TaBqSpYf}3mwp(q>y)Dm{U$5>&4_RFLj@Gdl&M|{s&wJ%RZ*UA=y0ck0TY0xS z(K|lD(s}yLRZh2LH;a$`N7JbXp;0P$-tZpesP22 z5?5qhu6y#Qt95Q^DToIe*Hg3n&MlnpJZH50tc@ zZ>{vNpPTnb;NBu5lL0+kO%~PxwG->73OOA_cialUiHHiAwM*J2YV;mIdEfQS$z{T# zf9B`sClQ*E|MsGlM{j}muKMVEpNqfvWbzc}iA?TDvAHx^Z`rIaqo)~frLQj4uXbZ( z^jx&WxX=F{IKs7@7$hwx9$gf+_T{qyY&KMu6&3;eGe8VEplc=k}s1ow=Ik`#kWfDU6;!Bo~?Z8^|*1l zVYz3kd;Bhc(yJuC+7p<7n3zm_cCOH`x{0W8m!|^Puij61b>3xZMoPB(c}32wgXhRJ zr)_oyBx#!Tq$BaVhkbv}bstLq2QBF-o-@j=Gh(>eub`Q^cA!WY>O=o(%S=_@x4#F= z{YoWi&(>_>O6hm5C)LQ_AjLMzUX{*@u|2Lk`1`KW2Q|h=%@4MuAIH@0s;HiwnD}#i zl|Sz5=d6(*mu}6;C;J+H?~q^m>vmP<8~RZ9VUM%vw`0>kr4Ma3q9l8~<3vgprev90 zr6V7ZsrR47`{vgx4YUns=u>^v4jth3c$umX!n}!g+Q~kwiRf#3nSvu2jlVaVuEG4j z#Cf)mx-K3YNfq;~^nD9%6)BEwTbfE*@47L0!rO;~g!2E+QRtbwvV1fwc+svoK)BrD zi^t}3pYKYlZW4CNXUgm&SJ@}EhdF}PeKW&;JvkY`V`8eS|B&F{ywPv>5@=H2GG*5m zrK0ERIyYJYKVec2Y%h2ATwAR4I%g4OZ3Y**EBO0+{EfMsb9T4Vt6x!!*9F#UyBZ0X zMgug>@0~a#pF#;8(|zhVsL~kz*(W|!J8{d_P&P;ZWMzG@-D(w2$5^6*+HA3mqA6KP zMNz_ns{ZN&2;(PV9DUE#Hoo;>LDk_GC8I9R zTOfufR#*DUapUoHj+wtN)RO{=w7L0p_2)SevcoB`rH3qnkmmbm&#%h^+%hh7{>x}z z6_eZyd=i`@HD@eau)QtPt)a?&Nl?Q(B4q;esU^v5NDuU=U7~@*Mf}@22N!`#>qi?G z^~v&raj3Gro^i$EL7NAw-E{>IiVbLz?y-}ii65JJC$iMMgO%>OM+-kFkZt$zZ`}3( zKl3g<3HfqGr}{HnM#La-6$dKn9bNLjmWBPkl&pLHOhg3emGtP}1Qu`CElre|>=!@1Y`m~54ZyLlV3QI1NfN#|0yZ^F+`g-SC|kNgM>nEse@&f3Kx z#}49l@Nr4f^ArF3zRyoTC7w<>+CPw=+tf28#zFV)N%7>q&lf{G zm!7Y7__%8z{x!S&NZt7JHS$REgD~?usFt_v^WsU^eR$t8CBlp6(bNA9xDoe!-66p} zvh1(Kl3S0~ICDCF_I3!=fB0^HjfgI6>D7WlxeFwRwCY@3+jBRygwM@b4;-D zvA~GqfBf?Lc}`Eu97e~E=lL6)_)uae^k1-IR?FM_B`IltZ}vvNO1t;ud#jp~a{eFv z@Yfl7SCv*TWk>u|X1qKjpknd`cJ~Aq=$h{KeL|&H=$f^*{cK)w%}?mcN=I9taZH+J znkDZeOBvJWuDO4~G^hW zq;ipf?eH8sAu!$m-D@vPh*!3OvOF=`EvA_cXtLN`yT9ZXDD3t`Q_pI#SEY-VW zlIVK5x^;@O8>vBz6V6UNto9!(eEGPdSj7@@&vivM*p;tiC{$B762;|lL+^4+ke9WF z>Nxop1||fn`l*BRyJdgNZC7EgO7YafNq2&1?f04d2iS{h8Ft()fNqIlaG`Ls zWRIy<<}0)aOgiSRP}kesO6AuY7K_C{tYmVJxt+3)l|Pwuq)e`XDzq3{3p8RFRYH4;h!Pu6I-OSU9Q-KZDm!0y zmdj9OfUKv;jr$?+>E3rc_8WxwkkbCMxq>KF{&~l@2RkBAwKH$wV9DF(QEHfaNL21= zjiBwx(-{^<4iz4GTgbcjftZYStpP$x9;>{Y?|!1a*IL+W1+XKUv1uQX}Et$ zE8vC=r~ancE_4&j6C`DnT4-SN5u|=r&re;Z;_1<(vW=i^)%96rSNq)Vy3KRssicyg z{`TC^U5~zjZqG!!%d@;O6(=65h4s;n@#sK|9}0<7>Dy?CrWw5Z+9l(^zsY@q<9HSR zT-Egt=<{mFcZj8Cz~Ex(J{bA>f*!@(+8SdYOqeJ=B3m$zpZrNNI`3*gZgT=#%*tJO zsC!ngvp19iQlbzYh4f1Dmh<$p1WYEjYCyE~><-zc#ai-lVSGlRm z*-nSXd>5YQ$TZoETfK1hvI+k@f|1S`wuYZ|yDWjVFZiz@DnL-Tv&H6<&!~MT+NqJ# z2vYUP(CB{&|2;hadHB-ImBV*ldT%#f0t>cg`^;JkJD=TPIf#C~X^-iX3J>X==au$R@vv5% zJlu2`h|8_b$mKH^-CUVTS#vQwXW04kH0j?*X#o;HC{&vudwBNva*UN#WRtn&gJgmv zmwAp94DEEXv_6dvGI7hM>1N4nj5ts{-IPUfBPY_|KhQ3^Un1`E`~LtMr! z+GM)0dg!DtYPHR0-Q!-X$?BJ0%9j#exH(`sgDI_D+9UkaveKx$g`%kp9tf6QY!#+# zMaf537MA)%4KD0>5#t`ZBDGyX&@$pRb2h<=8#9%zhZn?fvlycBNJHL)#xVy{wq;J* zWc!S>jok6s&%3&rM=nlx+Sgdt+Mi!zdCPUQ=`P|!{h-NCeYKT*4F!eEYy*QXCq_Su ze_F4@9q#otoepBdtJ^7jz;Bs{_+Y2$l0ku5${ZM2&koXZZLEK3pHka{rDtq&0Fo9R zwpL)X2?IuE(-^Btl{FY|Lkb&|v;|cWWrRB0TOoB&pPo%qWz=r&YIJ;0DM^D0cz+V? zRp+zCJ?3L@EJ!^u^T-80V0w zmi3LBM(fObj)tst_G1mL({2b|N`86&A(fo3N{moZ_j!gxio z>wV0i&Y zcj2t9IKbzIn%Ixp#x}-NppPZSMxeYU-Kf?^lvFt)>gMbt`-odlZ=;Gn>1k@paTgw&Y-7X$B(|}jv?c=qC%xdD5L4t+so211 zoEtM_LFDoVlJ^yrRr>(&UYV5bJJe3$^BRn<%{Ukk@>hBH%l7#I(6WGIb7>i|$a{u< z=dPS5c6s~B311eN4g{izH#~cf#tDw4I{~pYPdL(6hyxB!cfjFkjo{e33=N>MOb(bV zseZr7=G5ArlfF98^7Ptn;~)GEqp&CTTFagjgL^`9;Bwex>o=~}cu?EKnmmqbIKI|4 z*YVl!VIuLYn_D|}Vw65Q5Xv9wfpuz#Zn*YWH(>jVC*->7kOPBfE(a#h9G)1x7t{`P zwOJgvYCp?MyHF#iLKLiC^A+1X)N`vaZP|jnD*OwfyqEjl=nSZdG$*$S^PH-~Sr%SE zVmhV?S1~cyiQ-b!a2iEeZR8ZF7X_x7e0Ci^mF_l&nrv}sh4xBDVKE!o{yVOAh~N-S zwnFN4d)`F0_I|+}} zw#rw3knp-RRDD)ep>lcw;OR}fGS;mX1wNCmF0Sat>h_YUv&usk;2GIXK=LKe)b3kZ zj=Y{;yv+BI`Jh0`B^l9v+@@u^N4UvdA!nduE7~wMC0JHHYhmf+R@0A%`ztgn_;PDAoI9b?SmFo zaHvsCQ@KPqop|=Ab&TYaOMqv#34%HaW$W6KgNt6lP>fXUWz$7;hh(j6cLa12@Kq;) z!-By4-5TK5MB(MiCCKUF(e5_W3x|`lJDs^mzRf{$HiKBzttA2LzmB>Sqs`f*AK1h_ z88ME7mxg?eXEMs`#`-3XCXdHFsZX>-JSiiE&|epYoVx%V zV6@I^rT!{X76bIuT1c`hmBd{YkVlp61#xi+fMf2lZUm^y9<0*hoE5W9d1;{ms*7U?r>i?Nu#L20j!(43noxJ;1+7DLjw70)kBPtDS?c z>ilBmW<%%crku`(F|~B^Q+6v51YNacf)up{UR%k~<_%k%nxPjUnNp~Go!u>Eltj=> zdPX7OKA`~>pV5o6MlFA~x&%LAR@%Ywi6hCx$o>>EiFY3R%xK%74-ce9+VNB>xtyL_ zCj25`ap484X~b!4!tiS71E6_#*NImyM4 zuQIeE5Q$coai2AYt+~pb4^L2V4yL>4{=Xx#b^d=-p7`O3@nmX}3KStS&UT%)p3Qq2jQ4If~|iVnOw4N&Wm%Jbt|IEw!&%Dj=Q;<6cQ6@V70K2bI6s0(sM1>>>eh7tVF zg4?3qg=J*tw4s0|IP3;&@li<6{{mi9}HQ^linS4L%)4;2+U7TMg+08pftKmaSuExa_RXuBph zxOs!H(X`=KlewX@&9K{xXX8#egM3CU_H*0Y9Jh@yE^udYU%2FT?8x?zqC8No@#GYp zaO%|Zvg6aTRc}6;=*`7hNB32#pr&c%vP5j74vnSUw96@Z7)x9GH{)SOzoz4}ZRZ!7+Qy<*m71nh`-msPPc2Tl}~cy!hBADS38&Go<%cpA6V=i$z>&KBD4 zPgWa+->lp`XEw>X*3RU1cEWr$F1JqPZpS211E=$?Tn~>DHO{(LewPyx*4*L2D`#}L z6|szxYp=~Qb=-tn>$v_}1wFle0FQ@L@Jhzd-Yv_Z`|*!`oARKCMPh6)n(di}{_hHerg^+d1-}d>lF}FWkEV_$23#NXjQHTpj=?bT zqcT45lF2B>X`bc_3nTMVMTsAth@}wy=)s|Qbg*ZdP9^Q(Ku4fsdeW$tvl@lX@*#9r zo>4txVh$GWlVS>F5q6K#nk|rEmIQ~59hZ^dc$fqeJKA__ee}hF9g>D-29v3o$@t*G zWPE09d}b&W?1Gz$>hwNy>2KkiMf?hmMf{+IPXtO<5CT*4kjcTO_ zaPz!GAcSV%3#XTlpwI#yM6ePLr8O~3#>P`5emF6ivhxGsePsT4PA@ytpuI4E%Mje( zJ>cO7%)IeX4|rbh0R7I!tP*4S1_~( zjR;-go~{m(O_$4B9@GhDM>yM~s#y+F+f6W|7m*8up$3bht}KxgQ0N2{Ist`F zgz0?{X)`z5PXj}u@d`@eyV4hAB`APp$*9Im!X@dlG$Inq)9I7`o`dceEP+^sq zl~$gP#y0-TC=*pxT3JCz=RYuc8uT@4>60wfq|Njb_0)7x^;yQJqJd$NPNu05s+88t zCasOnHb;5D;P?XphR|o_oT{)`KL!v?&uyY2&g3;e+rr-CX*~aL$oB6F^M9x-5{lI9|Aw~o|4n(k=6}%I zmDTPG3vRJDhUwiQ9edzsPo&d*cZk>+X8XciO5g%RI79jr1f5BndX~awu?LF=MrumW z!}wBacA;QWFZD=Hxoz?w^(lO3lW*0)_{L>PHeHIUU26ZF-WP;-7|A}x-j`7nfeo-s zO)0Ao35wFUZD@Qjbz~w=@?}k{pj4Xz`PwILh+C{KR*6clq@@m~_`Xl2H}v&wi=|Sd zsHa!>vH_hWjhwi_m5}YjiNoFWTqin4`99_m{T;H)S0gzE(PLy1e@; zph-;b+&jlriB~SRYbluASMvpVzJg;;H(;J#0+t7kU&PY|>YT1(H`!$l2a1R$LW6=H zrZL01I&g;lT^dA( zDZL^Nei1{_R4p06`KBc03tRcJs>NI)pPdk4c|ZV2Wg}KuO_Yt);;@>*S$Z9V*L!c$ zHGI7T+*xC|$zEcz7H_re+lPksIb(r{)jWGxfIZjx|2)=iX0m0IB*_(pkU1+tG zYVqQ>WkQ51zju%cF8e{E?8D394Ydgpv&u5Zn5ysxGb+zCv!MGJVVn zi9Vtxb~;)26y1i^^m+6VH8qN2fdI{>D7?C!wdFTpJbCIY+34EXU{qNjppDM08T(e- z~;i)WXaW$ESQz@G-%$8(M18q>5F`d z@sL2!S5T2NBTxEJU6&R0sOnJu)u78(B8dZ5aYt@zuuDyFu1PxCC#NlemFhm~Bn8(r zyOAMQ#}U?*>oQBY7bzYdc8-~+SQ7=ICib~J9o1%UFsC(g_jb&1jn_pmeD-;myp+C0 z0uyf0?4ebS?o07s`cQVdt+2wN!t}3IHKai!L{&p_ zRlAsUTw?Jky4WN^N`|RZX>9j|bBx#1*(5QJB9;y^sG4E6`If2iZ&_KDDgw$JGhd5~ zA&&v9oi6>&bN$6y>QLpn9b&ZGM-3nrDXa5EKS^iIfYo}1TCg1=kX=5jQj3Zd2-dQS z&|o|?v@>s^pRU1~y&_71ElblyyOedpT)olkVLmpqalBY?!z$` z1wfyxYG?;Y6LTJKf67$zxa%`oO$P!2cD`jkU6~8a8@V>!PoOZ1YR8VcxbgB`Wieb% zEwi1_CMwKHNpS&Jw~1<#b^+J0A z-17h1jHh1zifs^v)TkN=Ov4|In*rO=6P-a)ZD@Xe}`vEFTiuQH&E2mDKQkIvOrNmAt@eDRdjKrB- zp`b;cO49r_57N{wL$Hp#$-a!Ld^Or|wR-{O^i% zMYiPsW<04m&D2O5w|V9?a;0uoK}+BhKsWB0qZFc>=O^_X3oVQpodNh11!o8ohJ35M zZm{2ktdde#=s=dpm<=R{2J$Oi0W`BU@QT@t^k$R*X=@-51Tl_(sc*WTaV6!PX^=<5 zb4}8_>wC_fp$0-OP|9T(YU(W~PCMD}x!MH1a9mM_jD=#sNP{*=54MrnvN7MIw9Zv3 zrJi7LVPPS_#v-SAz$oYKA$i97f2H-G=(+XaSi%1@)LnD_b9Z-lcx(J`#J3{!{2hX zXcw@5QBWi}>sdvR3;|P#Tgf3NVDJ*%ub0(CNvvlCP=coT+c>gax(oip^T zW>Tw|vvn|ac~-?6RZ=TxbnmIn3gEgj8~Ij(${Mg%n8?%vT3#<&)9H3HksO~Ou|mOE zn9$0Dw82AKNyGCHS#+Z45P2rES-d&rr8qWm<5x-^MT_4=x-y69gA)_cYyqY>O*xPn zjn3;i_L7_&jFz+Xr?M?EOo+Op4SLF_3fH0fG*kq#f!Ji695l6=1H*%M&8$>Pof+0} zN8M?T@oJ@1t;`JRWujV;2!zp#`kA zA~Jb`?ph`CMWd|EFadz*Y((z5#)gJiBcPW^uxJ#Fyg`BoQY3gNLV_cQ+4=P$V5`Jf zB&^b(V?*(QgCp$s45SZ@ADZNE2L=Yk&x4c6q0v$HGI}t^PM|}|43GN>UycCy;UN;t z@`^a?FyyR5f>H+l$clAPR;-b1YQ2njxS%7*BMiv7K+N#SL+YkAlu{f9gWXyg+dST` z25kv(<5U7lKZ@Fj z5013a#MtFf9^(|a3$st;ICPIzh=g&ai_=z_|IFuf{tMb-mJFjnU!bRQg*^X~&Yet` zL^g9yD+oA7L9>6Qs}%vhs^?g0E|V1*;AghPUo67XkP0vx&B46WlZfo;<~8S)ri?^O z$k893Ds5r0Aylp+(B(GMBY=ybB(!F(r~dFkxwLX#_n4IB6Ps-&alHWA9$SZ{fGEo3 z_`&30JPLC_q6nf8Cl8;hz${#$nPvv(b7nM~BX-SOU#6p0r4b(DxrFy@G}CxCn%SC-f;k*&Zb4qk zWze^#$J9!dr}`A-*+7q(D#xcPx$S3g;u11{TYPK?W(iweVj>OSnfB9ITWOff5~B?A zNZF{Ch{{4xQ4@t}PdeP2b_SB6+C%jrc8s2tRmH?9m23npAOcXWwp?IZ3eT1GER89YG;Tue z*U~v4#R`O)1A3Ht=YUXi^Syepunw}!t(q*3=FP3Hc}dM|iWBs#(VMN7do%N;UKq8& z4`KLQ>4mY=Th5!kd40C`rKLRl)#yK}3n~8QOwC?|LEy~U|5mjB+IIRi<5*$;r#rmc zwf__D=U4F^7s=dn!?A04* z&JgUvwvsK_#ZR7AV9y4u9^hu1fSa`X)*;xI;nzi>8ryGk%65~+T}ihbO$@ALv8}b% zvPpe$zQ9gJOS&#JqrM8<*buv7rOvL=b3oEENjvW0J5UmZ8}A| z8`-{j7{mt;%tvs4FHB?i(~CnD>AH=r;rNt$oa6sx`o`V*X+Nt!{}t)%+`V=FYcrnO z{?8fN4d#J0oc{}lw$A@;%H!St)s4LVVJ-dN-5J^H|IK*n_CL4rnl#Ms`f#kY|I-z& z@&BjyKX0x7&irFXDaL*#69)%I6N5x;4+alK27|$&)DStmKXqUfmwjZCMsf%S<74zT z1XVh_vJjyMR#M5}A_59wN&d5)1%L?TDmk@Z>BBVq50uk>8t$gAqE`x9KP)w`(n~#{ z-KR00GCKl9_!Sc9NJbO-f-E;HNv~fjYlWz4R+ixFoTgP&GFR4SqiVy0HNfP7tZAw= zFbak?TC4=|J&4y&%xjf2!Q$;0r21r39mEK4#Y#Kgcc`*>Z^a5Ph0WJ9%MfprTT)L^gO`ja;kf4<@k_|F9|G9GG`Ot~;$yORmn8_OPGEzS3VF=H{IM)J2tr8UHG{qdQ_HzT7 zHLfjCSP9~KR)k+Er?bbka&TWB4RSLu#`dWF1Jyi9u@81bR}I?C&O5;lUODLvjuFs) z^WY)*Y67)?l)Xv4z(Ba=iX<*vqJ@ikjDinxB#elP)CoeYj#Mf+dG~>Q31jI}zcN`Z zl?+oO3mTbApJc88vj%SF3aLltbgi5&XXloBph6{D4nt%Y(xz#_2gJcNZE`SUwLFV% z)sP;hDVcBprlByrNAO2P;XFVy0pPNRplP##1hg#SbCAiZg_YS!1Mcl)WWtObETI7y zg|6AJpcK@L3`Y;m*2XTuVR56V z---aoZ_fc#SOdbSLmg2VYQ4g1JR7pAOX0E#b81?VutFFuE!0znnY>Nig`xBqPBR4U zfe#|28G|7OQ)lQY!-+OAmgYC|xM_vu+jgddnP4`^*whLR#q#=;oCo}{j6jSMjv`zK zM>v=X2W@`FKwVJEj-<#70>ZEd#)ynj3`dSJQU_xs=-_`pImJ*i)Dd;r#vKv3BNlFJ ze7hu?kXu}wxxUf`lS|U2Ge(uIK1((7n)*SdVdWrJ`Pn%wdwgHDtVh|bSLUlty0)xU z3KCEqlR;@`Dgj>dfGg80sfU%NU~Gf6yN0*TMAb-0B@244G8a|%>`@6@p;9?XYe>f~ z{HAx$I8;@70Zk{rfF=?QNALog&aR$t$bG3O%mxe$1?wgfBZxNv?KQmk&Q|$-R2%3g zPa!*aUH#u))2$oF3g`bjI(CO^?tkjs(*HN*+0y^F^#4C&{hwEzsr>w9OYi?P()+1H zHwHuQAK<^9+y(;y$+6~9B?E$6bKbHYoORnltJ8L1iw=Ztiw|Ku;NqI;sq%|`P*dXq7sUZ2y5(+wq(HfhO(YOG)N6^D`n+C% z^$`?Dy%U(cm`j&)3ZNs2;JAeZ$^?WJLu$ZmS%X5xY-Ir>jM1wXOpWRBCVKAGA%4Lo zK1rJxdYGV#8Al+~QixN`DnzQF<6sq*`=HnI`x>!6p+Gng36MmEECAdbKbVrErwKAf zWsaljpjB;v)|SYK*p|w!F65`i@MK0tBcc%ED;x8mZ=1@hMkehe+SPapBhQS~r8MLw ziCMB_RB0SHdLG3Ka7HguKi+_hgn}F3Uns%5(7#9cSdy@kMrTT>yGba3C5xWMEaC0s z4V*Qqc(SEp^)Ipsttp|k^dO`)MImZynqp+k6@-Pw%Egu_xr#M$i_=21W33sSOzjK4 zq*@H35_l9wY(*5z^~ZAQQiY9&1*3c%&uBF0cqpJW#2J=whC71?(q%8C2lOH})-0k) zr)Zrh;$iIZWJeRILK3QuJ)(VGo~ZB~FGbe`+zuHotlPCL!tHdytplj3wW#12s zbqIS5#j8!hF3~JE`eD6nR>%asKt=E-s}lTMaC4QlghBY$GR8GHnFKKPd{N8sp5Orv zhtfs8V31T5LmcAGf$4IEo8oH5Rh`ARGd?0#!;AZ^MH8*3SU8D#;z=ud0T;$S$Fp%r zwi0c+BCRO&LdEF8EbU|C?UNI+1MR8(v9Zf1FY~BY)?S=}oCqlVJ~opIjs>ldg>~>Y zOOA_EW$A)RXOHY0p_f#M=#N5vmQ5kr%ceLq<_ZwmP|jf+qtxprctuvp)_s>y?WXU zXTDfvHUeHSm@f$-FfuVpRX>Ty7??$88Ya6YRl|dh(faSH-k9|YTl3vy;wx$bY=|9$!Povy`Bxz zO@LX*k-UBqd6O_Xk9H4skX?8`rAt7uQW+2N+a$pbfTq#w()pE!6lj_7$r%|Ei70N@ zqoc}AE3qKq#^V}GjE=$&OV`?C0?LGKjbUC})KH$&%Fv!1GwMvH><7!4(Kbbdj`Yish(Pq)X zYR>u5#STDcs(6X0Nk=e_6F;^i2&`jjg@OVQbldq&)XvYwxPi0*{G3E4wdBt6{L-U1sr};zQ+OR$GB%bvLdJ(lZ0rcRJTW%pC-K7*$@t_X8BZ#S0~4c(IHV=U21gGL zCB{a`0F=WBTce2si4*`$jT1!3K_%jo2<$*SIk+EQV*`oNMCyoN8BV0e5a#fBlElbF zESX9S9vqD&VF)EB#wX)|eh9#hCB}x6fF*t)K9&j)KnsZ^ekHt-$^Eg>QN*Rh4np;l zSV1y4K5-W5|~Q&!PKiOIO1#FB|gq{wh`{D5CUdP0eD3IxiH z#TgW&HF0zaWWo1?lW_|m8H&e70T%Snn4|x!em(1^%(LmUC!3e3C9}(R+3O;q&YrHl zJssgKm%TIn)VKdROa$w~(b)bM?&=PA*4Y1ccW>GMHsiT|Vr=AmB5-+L&kS5oo2KlPy>{@2AX*!D&LjyJTN^QH?f_`FI! z{*2gVmv!&G|3}JCzI4l;f4b|I$bJ9#%LiWm;(xgR5#J48y5$SxesaUpcD>X856@LE zctiUI=UqU0@9F(NA9(!VKlIouQjgw$)1&?!cm2<2ZhrR7Kl_glAFBT1^wh$Kr>--f zwJ-L6&w2QPbAJEI*S+VwZ`|?7^UmqH@D=K1&-}vp(;qnYyX#y2_OJFm=e@6vJ@~*m zw_R}W*Z$_(iIHc2=;BA-6Ki=@@!AW1I!&$`Z#n2-y^?i zZF$#y7rlG&+=1)N^B$Rh;90j_`^lf}&3`F$=QrNca{7x`{a5e%-m?Aa*B(3nRp0wX z%VqoDoBBn|(;gVPclsmx6F>O(QwzH8`{`#s_OUl!@bP1JJna+r+;!m>F8t2jchAnw zzV(e|YRQfB83;9C%0PvCp-f zzwr0(C)fVnt6$x_@bC*?_(K0%uWNbd*G~TU^MCQqug!kq9{*o|HTvkik^I+R_)z=z zZogpQ9Uu7B<>!9$n$XwxzHP_!q5KoS|Mjn@KK1|JwdacIWb)>==eOKAyf+Z2{O*z8 zz3#)ij^2Kj{aNaIS<_Z`tg_F zdiwO~TW-1Th8rRm{?)@fo`2VeyYBwQZ7=%r&)?oYaL+yW96562rkid$?|uEtkKOf- zuCErld#|{w7d>qc=Y%e5}y&qZ_;Kc+Z>fdsV3S zn#cZQ^3ji89gV-W^`}>VCpPum&uJGOy7lUZzID^(hY!E~wQqdwYhQct!&jzneDj;$ zR4$hveDJ})4qkol>8ahZb07U-XW!pH<3*n&kNSR=-|^YwPrv)I+papjckkXqAD#Zk zz2*o1b?|}2r7t@1$Ipj`$*q(wYcZb3$qgkFCQL$;%|Fj zG28vsub=bjmyXO2x19g@J8n7p*_SV6GC%pkv-kNwaK~qtAHV3LivaJtU;eAaFTeHr z{>N^)?Y7_C^tP+N_3J&IKWLwR`oar-^}5I3ar?=KE^67aW5?XBckjP?=GGfu@aT`f z`A>%~_6;38_^O`!jB_vh_~`R*I{EOu+upPM+m7t?Wb(fs`rhZBd-n~0apMUf-O|$D zmf!z8zwh=(e|Rc>?wh}yy7J1CzkB4zcf9(U=U(%n51seE*S+`^pMKx_e*C33ZvRo@ z){*mCKWbe1hoi?PrxKa;iJdK<``Nc|KJ<~pA3JgXonQINOAcJn`pqZ4f8WE=m;L7B z{=fYB_E&y);SD2Kq!P*xKC}1nA1r*LV|ZY&`l`F1d)dwJy5hzYvDp7-?>*qDe%r_K zV%Q)5-s8G!3T!Tv6T6n8US17KN=$rSMzGS+S%5Om zR@t78PpV}^@!$*z`uh5Ib}x>}dYrs5xa|gEBZfiAXsBi(pF@e8L0H(t$h-QG!RP!5 z%lHANX5V_LK@+ph!V`6l$aq)=^>pAeA4dG*5uuCQeSNi1H{KbrK6vmTZ2HHyB`jJ& zL057yD0KbE74J5HJZz|dfPnt~e!Uc4PG*kWlce6ptrxDmWPNSAjC;+O53K{cxSft} zB4%6hFruzc4KHsT;=#qd-{*Z-QCPd++&QO;;mxSTu@(j9W+N|6{jFP{y}06i)+96i z&>;(3Tj5V)^&_|x)%46vvA4#$x^<5-H!WMYIfg?Z0ky@?&(GR=70T1jWKYa1xi?wM zR?E1(C?g~X7~I~lA^q~Lo6I{-AC}Mfv0w>L4{9V`q8EcteY@{d`dZiHma*7Z0Qvx@ zaEWh|cDsMD=U&Q%0^sx5^Ymd|Jw3A%Nxvx2OgVFBAs~J)5rN=D2O55cG_VcPL@$C>m~?rt&LOWJyRQjS;UHg43F-5ZtnyowZPc&tE1=TvuIfwj%~;aka1?58e#4UKVY zw&z6of3Rjl-Kn%$k;=imLp|hDLzJ}d$py7{?|$#*zSY-yA)~n|A&gMbG3NXJQ6`|H zLSI+M78Mn}xwEIkr+i|xx9PaNn2L(SO8oFrHvbR&hXFXrY^@y9b*TyXW1-*mSJd$c zzWrn<%HGG z*{-d9_u}@_a-a6p>})lc+X)Q~4L_#7nE@O-_-a_R>b0XyK98VgQQh(V`@J+Yd|h0I z#s=g!5ue#wx3sm11uHK=#m63f6zFz(;?lLaYe566xVhKx@c~+ZRZ->qVVOD}ex7RC z2dbL5yccU)25Q{%hSke~fnk<=svC(tW{hfn{v7jD$iNbhfA_4={;ct_k$UH!G8jxE zhfLVW+d}(_rE3+$1q5!__ANx&;BP-o;?QM%d7bd+q3Gtw@w#H%t_(?=Rh-)~SD4Pd z3R=O8UhbN>f635GW!Jvu%0q(JmhkcNtzREkeCKj?l@`a;1}*=h&aKR>>?6%K-nKD2 zzjR*{uTS96KpCX&OG;|H)H~i>M zTBQEnd`Iy%6b7}NFTpK&$t#Yt28D5P598u87cP5`I(YD4v&)@s_XhoJY#vclvvQlu zVHu*^7S@196dH?lxOnvaz{!dj?9!N(EAP~pw0Saxlo_S4#K&@2Iy)~zRaI5-MSZad z51+gqHj3IpvgX-emz=!##x3KMPN_w?%`dNwJ}Xo%COSLeaO+Vl2eArl9_ju&1C|~R zjONi`1r!30U|p!AV^1s-_tJIux0j2D-cE2z;#!g|lV4G@h55WnszxNAN~Ks#i!0}S z1Jp)?Gi7BMlz%|@l_-@h>3D-wOg^Ca`655n92T(}zBRowHvC3Go`?mYehvzCHlOr) z?*HL(^rNf(rvQ&CIf0qU->@o?C>J7hdyuS_$cAM=XYSwmW9-=FTWU|Qg>*j2zrzn`Jy9BoNw7AaYqNg(ZtrdYc`+~Ek8Vtej;=7 zu$3VL2fusrqYTL-;@e9U<%3$U2DN7~@o%#^W?q)nz)8> zPfu*YvSg@N6f3VmacB-aE3B`tj~IC%JoR-*EK+;8F}!9x;q{$8mv4Q#Jv=yA&uYN4 zHb^DHzUIvlTtj2kkKt<(KR-^J^2%g@DO&Rfg)Sok{!l4F*TJy5=f>y;4-bI{4#jMb|~UAfA}zuEEDo4)w3< z<`GPg&fkyf>p!daeWGc#i_1nEyxnHo#bbpPH>V#F%j*L@N#6t3p_a#Ce4k&Rc&tdW z6v5xVae>$p$QWwO`B?8{nGXy1;04h%{K%bU3sTgs4t3WuYQ}BW8#)lqEwdvb#?ref z+p+C(j=Yz3$f;F{C!8g6)~3N>%x z*x0m0-d(pyH>uB1|J0pyNB+T6cdW~spvuUJKvUDk_+@IWYC{H5<{e%(?;Bs1dAEre zu-mi-yGQQPX4xZpJ4m*4;N zOw`DaZ`>P1PDd4g+@gw0Capy+lxAL-86PKPSXJw4byye0xuxzoYH8EHlNv9JTyEU_ zIr&)9vB8x+u4{p^hX;4m&xu_P4QnSRZ0uaOUUpiJs}pKGe&oqnGj54p^%Y&`+nG6T z|7bp?74dD@vE1j_`^GQ3qp+??wQ6A_lMM|j2JBl~-4}kfi;pTc!futSKl8aKqABZ` z3fZ%*va;wT`k3Wb$Csh~mhWofZ7X~pJg67b)YrUU&9eYyAW-17Ua9Qfs~ahM_GI4G zu3nBOpDSSH*EzLhiKr&WDk0@)W}W3~oP)O7n^I7ke)4@ve6?Yuhn-TQJB>75~#U&A$p zQ;tXVYE!mq%If_GzVP~A&15!^GxStn5r<`IWO`WTy>~-rbF(yHrz3`|7Dm1w+snY8 zz$N)TSF0!m`@Zwl`LxfYO?(|?1k)TfM{Oa!lLk}f4>@$ zFEKF@2xa3a`a(+{q*OQ=r4oqvNAH3 zPh0GDP~5d$c?(`Y0hE@|o69$^R(d{GNH#I$)1Ml;iV_#nepTALHIRMV_hnDkzOEG04 z?w!s0MCpkzxpLFW4|V|oFS~1~8Pc;EcQBO*n{BG^Mp_^K?jCdrp_U_)5MuvtZrKL6JtI7Zqe`jBA zXJvp^r9#vuu4%RD?-{#xaVGF=CYpI0jo(^xFXiJ@i&eY`z9jj_aDt>9N9K?{(Iilp zk)t=6qpGazLsjoh^070@(sjdE2QC5Ld+)n<6H$aMVq31CFDmkXbX;EG(W9PgwKt_s zzdf6i-CpuePctrIVdV`VRMS7Fc9tl%=B_)&{P8H%Szw$aUq)XM(3dgVQWwJ&iDVBsnzq}Umq$d}TKC_aKkEQy{ zViVS4yTa%n-Wx*=%Ue|&IW#9GCNdR#a}S4mzu$v8UXlZNKF5!L(3;>Jbl$dY>f5ax zX6fL=Imbv#V~jVl*=0zuo1XGgs5enG5NGTW&dGY%bouMifJ+MvQV;N{JDHoKoW58% zGdB~_0u@brdNe-Wo*WYfe1En>FBG1v-kiwHd(E*``njQ}kM+yVdshl<7r(+6owei@ zcWkvyB>4H>Ug~jUjPD$m(DnDP2^L9VhAYZD`T;^_wJ4yce>aPcTULaH@n+PQ{-?d)Cq`eddVh)dS$XNTmwv_DA`7ez zoNJC{vTe+f(zxGjF(_5Ugc3GgRdHsK#8L+fi<}Hwwk;0scNKStJKuCD42 z^71Ok#k97z@=kv^f;wKU6!CTNL+gboAHmlS%$b{V7Mv7V8m(+GxG)6ue^FR4q7;1iGt9(_-G72fDcPK%+{)z#(Xte-}!#0j}1 z)s}~Re0Si8I;xsSPhX96rmur|Io3>~cJ1a0B~;A*wPwmT=;5CNs5_gw9L^VbeL9oE zj!roG$eq}6R*Et4*{)r?_U_&L`rWESTu0P`FBY9Vxq`ncFDW|F!1B~aFJWcIsOPJ- zjtE75uzmmpYpCSI;X6bc8F1&z%9O+|pipI_3tv^+hgL6R5a%)i!ZJ-w#?ZF&I(w$R zIWw5shozpDKw;~a%Y5t%`&!!6Xt-jl&HLf9&oYPX^;V)@AF=%^YM7UjtgX@iV@hgj z3%bvhg|}mTxyHWS)A{+e_wL1qiK!sjB+w(pVCQlwtvvS(%082o$zs_mu!*{Nmm)h+S|dL=-aou zQO9>A**Zn0Z;J$jH+Y@-Om#i&O@EO-gj~~7&_S`3(r>C{Gyr4kokXvFg8!C(cdQ6Mro2mMy%Pdl> zmDVggd*;mUJ$tlb1oTn)Uowd|+1T0lrKEh@?eO_(YU)+g#4ZkTgLUgXGCCF>Tv>SZ zAUYth^4z(H4|-T*^eq!dS6Po<)IYSu+R}32t6d5D4o3R=9PbYs8L2Z%A2Y70sZk5( zzGZ78e>Lpluv~Kq`=QOZ&g$iwE-pX4M%%_lu=2#sr(@9Fqo(A-cYpC!IV zZ|$k+XRYnZN;T@{Zi9p{*BelphT& z;py4;Wa;A&Ng5(gp4eq0H3l_P$x}qX$zsiL)56Q*r1TN)NV9pIm&D>_Yjm;f^CxSv&pc6LRvMf%F9)BZegV)iy;@!sE zcI6F<6?b=Al#kEbrf9WKu?thfzYRY*pJvgrvUHnISlE$>uMR)Qdj?Ze4U-?mF4$U? z{;h96ik1IDYxv092YXivYd%%2PT_y=bg3C<6d&99j0XiU@s*H|iEU16m!KvlS})l0 zkwO~xxihh7-HHXk9H}xojb?!jW}y-xrz_H7?Klj7;pDj))nF` zRmZ59^XSg)B+W~+<KR)nq?tu3ZC|&3 z{m@U_%fT^ylA@x9o~Ab?-n@M)i8}4*rBcShLt-8%+^URqgBiF=FJ;{v$faqm>9Nn-8|GN`!S?X^mP`~eZVGn zUZ2>ELJO^QWq!@N{LO;ytbj|5EgLp|4NAQ`?ZAUW=?XJMUTL{L$#If@Mg=V9k~?>BC*G656r; zJCZRIZx5kz!6{Um3tJ`Z%I^PQXIAGdW#zxk{q`v*14=sBr~6rQb~GI2Wes|J45fZfQ$Ne@<&CM&KY!#Ud}HBnX+F7%%Z{Dh3orp!LyNncPemHG zFH;wfLpj(VmO;9yP;-|E%pTg4YAqINdfDrG7T@9yhTS5j5os653| zS9ic>Pv?Mae7x4g9zL~}ThZ3IJTDo8JKj$FzN`50S)sk5A$zE6Urb4!`j0PG%gw*0=L=jtAunc=>eo}OpV490 zIlZ)+p=gHzw>YZ#&7B^G>K$kuopkk|0a7tS1~se(-8{Vc4mKhv?iH6>zn)9E;~CpW#?kluD{Y8mU7svy*B2f znxZZ0gLP{`zE{|k|L|r(;jEJd4|DUho;<~&)+}KW5WQxwf}fdbn{#;o&HMM!7A7wi zh;!+wem;8CJf4BnxWOP|oxzIYj)B~~YuA5HY70jvqPc@t7IZ5+SNcnb8dN{yPGXSK zlVu)%99MRD-%v+|^YzeT=UY2pk=@>KcI@{jQSx#pk8r@uG7O-^=A%GW&|9AK)rXM@qk>)%H(g+(d6 z>rvxh`d6TeItWeK%agd4IA8Hn$FbBMOzaO>dS~|r-{+qWVhS`_H!|ZcGCtqDNm0;S z6I+wqKJ|6~3Ds+S%m-hcYU5=J(&@`#jxjxzw|ht`S5dJ9dDw=6;__^F&Y^jKCw!Fti!M2DY%|J?h|MrcEj#j45S zYs)%GW}O~6C&VNQWqI^3J1v)W7cx8XqQmoWLBSg1jSt*3b@RT|J0Gws7O3~S($*rU z)O#CScetQQU0suzQ`?E>l~*!j;3QCV$%s z{?MTpJ;dt)=uII6^Mh~h@foo!v6HwfUYA&0ciw7hsB?mZ(rdcCQuqLK5_9cJ;eFiV z&##7!UTMoSfX$6*(Ha zke5f^>+mKoapE&;8SK%kN*y^rzr3_34yEkfyE(G*B+27x|I>VviN{}B zZ9Rld?52NCJq4n=!M7@sC1>jE3qRfn`EnxUW~rUG+V@Xyoqx(0i0PskFPW}p%zD~2 zy)&zQ@W_utqiR>I&YC_b5tropoZi`$EPb`B_2elgoQm&@-Is4FofUg_Y6G_HwHh;H z%#{R|I-gXb{j1aDf_*eKH7mu_Mn)#ngp&Yo#+5)&taGnJZCPH*)ZCaPSa@*X1Gk6w z`&7NGzm1PeCzu=Teb@Im_eR8ML4hb%foVtGpsf38lbmcH1*2WN(o@uw0)9raX|B*r zEZ&`*{5EQe_ggSFb2p~$`N+Haw6rw7@IHRxARmT7?sQjW02BXdyl8l2#kTt1rml5L zl)l(Pw#IjT#*LqIbhEAqO3!QEbQ#UzYcCEifri)u{b?y zduxqikXN(~XH`&PGLK-!$HRdEFEpnF4zAu|tHu{1*ZlLLqHw}FuOD~!p1*uu#;#NA z-SV^HJ@t7nJ2V+%NVvTR4)AXFf1RxwQJoPGE4OweewlmlM_vO$QqspRHuM+M2p^x` zTR(>QeRuP|kbf!2bh!Kx=6OO^YqO}Bn9gS=;!gfyai!KP-hI25jJh4$EG0FOk{4So za)-zFxpYOuH`CmLs}*JIV>yy)b5D4G8?g4{W!T)ieEISw)o%_tYEhA2#O(G7=H}@M zM~=VoL1mtk`^=}qq$euaTfR&!)bn;icJ5^EMON9BR<9>`r{UaOiwgD74hY$ZTqR^S z_N9U`o}|>q5b-6OHIH(bw@w14@xxkT@;Cc9r>Urpa$hEv#ekReRB~`+k;HWkEsn?^ zlViGh0YAS_OlCHyE;Y?Ma!_cbW?_4iO6h)*abo8%rv%gSb#)1(U8Jjl@3f547mp=H zHLot1n3w>(!Q5PxvMScVJFo4_u9ln*4H1 z!S}@(lT3DY_AFk;%gE)a2GzVLjtb6`r{IfIQ zOX&5fs1=8IQL{q@9fKAn{T=g*&44jx41h?%avfawLizVSDA%p~lC)$`eL z3Yv-cj;jpChbP2v+&+53a_UL`%90YUvEi3GeJZHeYo}OGy?F7Wq(o-u7K3|Q=WXNq zrJVhG=C-yT6&|?CqOs}l zPe9!{3El0#sZhWpg_2EOo zR{^b+Eqitag^#sjrLIdmXjhgE+=<-Cq~w0X<<4%S49Oeg-AN~uL;TYFfL20J$4+s7 z?DabC;JMAt?%UT6y=RwHy^32Hx{5!ZYYC0hk_eluDx38bk2f%3+E>P%txmHp;i0({N*yW=eAj?EuNQa_uP2n zXcbr%)?b*D?s7|l?PRg8fx&|htru`O9Jly3juk6b+<*4gl;yL&#UXrC_Vt(7MrCA) zt5#VvCE8bOCs;-vCl4l{!1n6#gzvuOct`KRph8&SlhXzUpFbZs-FN2P!mj#Noic}+ z+J|0bqT)oP>sniZ82PfPnOTlXSjj8QGNF~4IQxK#1L=3NGVKqYa3oKX38syY;^JPE z$Xuv(wOyqXBFxKJT_V0KfhRXNuBYdYrRDG%X>|Cf*Ox>@4!M_Jw5?|3-rN|vS}*|! z{kXZfmadl3PATKcySbn3wI-8=+if?Q{zp2Gb}aROVaI#Oi1`rK$?EAgE8K&VZw z-23E=B?x8w}C&rqPggp1_6hqHMn^QYJoB_$;d4Gl@$Qj$*BpKmzbd&nnT z<<)Tmt9Y&HN+$_j*4CC5hpS`}W#wxnB_k8PIU$NSJN#0M;@Mv3hN1wUA%WvjdSg?Q zdO)|fp`l?L!0)$j%YD&EI-OS6(osQFj~w^+^z=;ORb^SSrlo@D9H6L=cKXu6P!YB4 z6H9oS$-$a@wKFgMZiNF8`O~wCy(QvJN3nU)(?5@!dwF_R^VF9NUaBuBu(PqTvA4H( zbaXT~_iu9y*}qQF@(uxj`0>?^h;PFZ+WXbwp0C;77N|l#$@(PTNjv7iy@7!NBSXVW z4ppgHS>lTc8ZqCxqHh%ynd_&VJb6+liEF`v1$*e za`6{%g$I>)p~63L4Yo{&0%i^H-mbm8gkjh8ynm2?jb6vl*O8Ht=H}*;C((tCNzdY6 zH4phSaSR(XZn0Y9+1;^+Y3cFQhuBTMyCXf6)S1c8d0($p+2^j>C$-_pg@Q@Gv52t~ zd!s6Gw$;;oo;F_HX3gQ_>I^*9+`)J1G*Kv&3R!0x83$)lL7@$N!JE)Ms8^i3hJgq4 z(0ZOk5*a=KjmEg)g9$jis=uFapi77d`(zT=D7Y8bK*v=3lID)MzjOcZFZX}boo)S} z!uX5*-&pCn`@f~7|GEF~Z~6R_|KXqf5C7zU_$U9v|6cwFgnK9%AO124??35Z|H&8e ze=7a!tfYT4c@~5)lW+e!X<*sG%m6boQv6{?SOYSgvvp1izi^-sczZXTFoG_jDDncr z13r2U9)1RoHhY4{@WB)Mv|O>2gtPciF!=$56?kZ$F8{1Qk|>jwkCs47NE<{70xv9q z?$ZGZK`8^--Glt#%oku%f?xuY)$v!^8xh(e4zHBFq%^(nD=06i0LZtL+00x52vy0|D>@SbN7(c?5xx z4kd{LI7FV%h4UnYrNG1%U{Nx3aXTe#EW0n@al@zMA)Sc_ub%;vNcw~!C!^^wB)Ypp z*(K2?^eIz;alixggcDPM*;9i8Y55Ms*;T--5NedXs?ZN{_7G13&Xbb*0)P&hG??8; zK?E|K!h&9>17+O7+?#0y6QmHpyb(lyxEdvm30Pf{-OLXU=E5Kbg1G|dnujxe;AdsxrH%=u zw@AJeIEe&3gV9J&nw@N5rlz8|aj>SMw{sMJqD$$4bjXd8E0{)bDER?Ia2K>2ArLSy zfG0x99`a{`iJc*s{%-CP{(uPqGYjKDN(1^IqBta!R91$wk|KB@J^C{jS_)2I1G+Nc z{}S?G3SKZHwGW9%Q(&_*FQaYz2%*p;UzaenAD)tb0(RK`bv25Xmc+_R$|_LL($5PN zNzn|epkL-`MiNqx&`8_t7?`iaf$v!G_IHH2MI_PlumhdP0wP1_wNUak&&|(Fx$Ovz zq25A87cbCf__YT0B1LmU7b?xTIt&zyKs-4p5PIx~523w+6hD{)+YeGuV1J=j@qvL* zG8$?ngwl%Y-)MPa(f4B{Y&KD1&; zwrIfr@k2uwynz7Rf&wWSrojFN`9m%y;+TRSRv?^@ClDAOe=sW#ocM}jL1CvBN|^=c zLI(A#i>nVFY8=WkMr)cL7ZTWGKwJG%_-NPEp)r3ZV^CpeG@y=y#D$$SM5`j=j4=Ff z;Ubxueg)T(BD_GS$#{rqXlOwGJ5%-KDfX*aB_{?VLgcE#6e+we$Ft~=1 z!AN)hb^)UNre*rKf6_KBZiGh<{Pv3x{GV7k2s$*3gxQf8a@!;NPdIFr7*h=h=!hV^ zFn5@!y{Ak}&IS!-!GlGY>b6l;7n~l0G$yAY=7Ixs61_HpO#s{|;CLYchCd!ha1R51xsWLlHXU8S zl>U&g!PUf(;Xv4dCc}spq^dJ;dKnB714&Se;-CTq4Ku+V$ukN1`QRIPoLtB*w7M`# z1ULsJ08|of3uXd@Wt^JRjoJ?a67Pd4_1s;8d?>FdY6hSWVsZe5>_-N#JM{z9ED*5( z!3u_iN75sT%wk5DU>6`52DK6b33Og(X&5$|7=sszQY9Ax3IPo9B>LbH!w0V0kfGFg z@P#8d+}g!nv6QpC20)f|_5DuPZoj20WUH)=a(u%pb(5U_MEx z1|`iP%t#d6!14fgFq~N^&Z`J#3pxG0Kv0fFm_yAJfo98KfW_4zR!C zG_^B>jD5?0#pzriXc(h4Uvp_35~|k2b|I($`Clp)Ykmq z01o;Ca0s8#1e6{Sc%K&JCIEijZxzbF=j6}tfl+-wst@)Xz@Sn14|@5K^`Y`S9DL2| z$1>#E^O{gHOf2@V?)CX673M#m|HNnR{x3iTr2exoz+GOO{ z{|oxe+W#ddBddTy%l~K5nE&(t`2Mf?#~=PGiTlsM`2GGrSy^dduxF0H{3fjIKl}gw zj*pZmJ7sl9;xD$|0bazP-0}$cJ{m!QyBVl7BXK`FnwCKygA<`kpFiuWKz1~oAR1vo z*d9vHwudrGax?9rC;(UxS>QseAU?aN+Kgvz;6fYyGXZcR3|fMd^c0|bi~yhc%q1uk zst-PNNAtt$v4As(F}Bfg-l}71WngCNY-(d7f{u(t&w7SdLCZ^H=~}~4*A$@!0S}7c z4s-x+6K!W;u4`bdqpxAAZL9=2X~_paKMNI!Cw#waGgkCfP(?Z;0$h1!=puw#i6$Z zaoBH!CKAx1)ag!i1mOAsRKXD7uV`@moWZtSi9{c~iysDP0ET`?Epn@z+g(&JE*nwlDZD1)X3h=i-98b+12zO}l z112_I4R^FE8bkXn0#r11hMe6Xa8?k+2d*hTlgA*OAVQ;6Rnew4#>OIOs4lp71L`qd zO#xRIH>z3?fT|*$aaW$NBS1g?jcy>FrvawoC`v<;LUUthDwYB+WHLCbN4aLj1rFhU zfwAaZltHS%#3vwP^vBpERcWIDKlqDbm@CHrwc&v90lM}->Des8{5=B%*eL)!JaZk0 zcOg^E6ta*_5(mPu5SK6#{1yt>cfidG)0YDqL3Z|lK|A%X8yt1jSQ)w~gy2qFr*J|0 z;(ftY52y!F@C-HsFB!oTnc$^M$lQP=Xo=>EG7zuNrS%-X_n$|8oq?+0CKd|gfYTd9 zcUmD>pNK+LL6R$@(Nd!HeWsh*^9iF-1wa!S84o-e-0}`B8iEk!Y6cJu(yUSvGW5gb z|4TUn(El~J&E+uv`Gn_pG=NI|SBUTnx%^{d(3@4z2*68(bGuJ(QGs&QbvsowO>fZ5 z5o|@JMCofm>tRT7qCc5dSOyTcKtP^A?`STkAxw!_T9|r}xpE@}LfB&H&=E&w@*n~C zpCRGDw%zlYQ+V4Uv@;DP2sB7LHjsotBTEA}(@M%vdmS5S?k+i&+C_qVI4sP zC~hZ!ILVoe76n%wRiSEg8vF0*jo*$MI2K^f2_$-Ep@|M45Hy<%Z%m=BO~Wf;i%K(*+0bw4z{ytk}(uE)p2i;es?l0}9IX4BAjF1wCnyh{{(S?MFk$lNbWd2ZzyZ zcM1VL5$bZHIt8*HW#|Cgwbj7%iXf=;4A7C;CZ1w#Rs z1uz5v32C4Y;D5?!0ubo>0so1K&4B_Afd?`Kzz7h;DB~jTA7l3D6&;pWBVT6A4Ohcy|Bn7C5!S8|b#s`w=%slNC zAWS$H@(kKT0VOEbzK-zt0JdUAw`eW+iiuHvMA65eM1T5l8Gc1;QW^n7uP#9)L47Dq>dO-3AFd(~A%53llMsYr`=$G6;-O`5HKoSuUhj9MAi{t)pbo}>0 z>;EnVC_4`SWlDfN;DP(S82oOm`6)aOYEy!T9}!ycB~rISQ?w)1qecV(!AE*Ne84R~ ze-+;9m|Ba1JH{xU@?7r}ehfT^e*J~Z4L%9-hipAG`G7%a4fZmKPLio{AQ;K}fQW`6 z-BqWv;PfVN{?Y=leup~{PU$odG62wMju7;ko|R}+W1rV;naBRj+Q13`o@Z7OJdUpB z=8OYNAO!&bh8B;?{#EOMjdTV=SWlwc?*V|t|0Mu(cHsV|eG=LEU+w_KTF^I3dySwC zo0Iul{cRwHY{dRG8>2<%3#1T+032k9CERBqPp9YSpIU)EBk(=AY+$LQXJBP*x!u52 zTW8yhhHxM&1_eTJ>BWxXb^fYbE+PAVew=0Lc@FC3K!Pf1_DpYw{Ldap06-{pS_libP1AH>+wi0dq#a?1wBi&U0a-?J zAYe+7s1&URs&Tj`7%rhhJn_)+Eok7t^UY*W(D_DMf`d{YpmRto{&ZdPxA&32I)Z8t z6fY5aOaYe(q!NH8;KI=@zs{VGm{AHX0cuwWGdCg>K~h%Hci@RW!v9lJV3m^qlV8 z3fdR6kVwKcE%Lj$|A$2=tEvLE)qujz42Y zicI=JW*M|wzmU#Z4CvtuA8h&^^TCU`fh01rMFaTh=Mv~aLZ+qwwL=DHn?yh%qqup< z7JbT3KZ?CTDnhOUtcm~=2s{gdPTx{>5>g$2KvlWW8ZmVwRAG$75Xpmv02W0wvhxHU z1BxL*)Se&c`hrJI0OdsTcfrAX@4>yra4iybb3MFMN0>BAQL1iWvUaL%7PGp)H{fP zHEerD=%za<_5}30;qQniO|!s$bkm76>@Yr5507G7;UPdP(Wx!y5ls!#CLw1il0pb%K-&N|1nWpo z3p9L!MA%1I37!WAEjisp?jLX-<%76-vs-pST86@qSuM{Y+D;5*M5IMT=qw00)efpt zXKQ+OG9QXqXsr<0wLp11tMnX9k+UaCvyg+NXU+x@dP2kgB|V{|W(;~1B5)vo@*~*H z@cXE9(nw!@iNRnN7!rAg%+8q&hDw9K;q!{f0eh-^Bd7z~8Ihp55!qZFHzUY{l^}@Q ze32_08P7jqHP;seCkK#%phF48XULh2dA7p2g~DGTg--Lb=SKX$*+=lFkw0}!3xGP~ z1>G7kj0c^OkpitNY;GW)1`jBKTXhH|Pdv?O_~pz3*mH5T?0ix3JVb#BFz@UEol^-P zawZEyxf)=`q}!tbp+qG*GFSimrSIPi=6tgoe>pEPXIfE)Hm&$ynpH%cq?sB^WJXLy zX9mG|7=b{wB}6(dn9~7S5fO^HMzYcZHVa;ng{eO?n1JTXU}2Z0YKu8+_$xAjpBb|n zbS@8pJTrKp#kF&NYk&y;7Q@!)yPq)wrj*lor3Lk)f;CIkhq+UoMVCLb+(AOw&i1+4n z7}>n4K_UUs1c`2A31AMOv#tJ=bCFP7LcfC)azg;&a0b)0%+-c$vm6dIWNMtX%*?l2 z8tCa;gEBjR8M?z5TE9MwL9I_&L_t$mQGNkhTgOVv(!ksrP*%SN{`+$#|2j}aJN_D= zF?_-WD=8x>`vo#4fcg6gblFUxw8d#jAi9 z=14PrH2UoV&d!k86`0>i1h=Ws9B&#>YIE>zC`!NK6&Ok>Nu+H+66e-5hBOBtsThRA z#UT{~+p^yfWj+`9x3r;{)cJ`t^X>mBYSG9Aa2v8e3(6Vl2Ps2nBM&GF^KEjV^5d+< zV_H|RG^fD$tlUpqH!*PfaeHU0s0f5 z?tnISM`}BJQqMk8AIv=E2_C+rR-$R+*+(XUM{J-Hg$43yBHp-y?;M2b)$Cekrn&}ts%S|mIPo?+J4MWdFz`DO;E_8%04*RiXO=?%Eg&x~EdVrPVy%3M&i?D3D*c)YICeG|t^|$_GyqI! z%kL_&Bl)lAkb%wD+l>&2mheZzg9E$(YqPWA{O967vw+*oC(39aKeU89T7rb8uVgJr zBC@mNz)4CacD6uYu!xZHFKF|R+xho>=IVb-9Sv<0o&O|^zw-ZNWas36k(K$!|NC1$ zl$#cybI!o`xi^RWE4PKPn}geD@Mtg%s2dSS0yorv_sP*N2m<#={DBwwj|%vkK6B+C zw%`9r7=Pve$;)ngf0g(CIm{5 zfLt~~D*;|gLA_u^gq`LasG_BUNP$v5M4XF{6i^;yIPkii8GwRZ=7Ip#(r??J-8e8( zfq1&+!3L;zUr?Kesv4MT&8UhL11rk|HSLfCg!9z4vjZKyU(^SpI<%P;+6@mxeQtO^ zGCR#FR0Vt^5I;AxAUM%!Oz;Z|Wfz?B-ZcnX4wne>qbv-%h55Po5^&B)UVEsfi3<(@ zv5g(+AmzFb%8p>#X<8B67ZHL1CbHGA1bbvAgO;!bw`xhan;U2W-@%_A9$@%R#!Dbm zjuN&w7ZO>*#fRVl{_rJ`z`IQ(0P8>|g6m}@;GrLMYk>rOnGW~>prsoz1o#3i!AKxS zrP+aT0fGSu1K2qQeu+RosDlRor1O;7VJ{jCJwTj6XB2D$cn%D(2M+2Z6e_{`5ek$P z{xVMb-xlw`{LIz=;D#~Me>4N&zmfk>0gL@7|KH#7`PKL%({I4v|2d4`+kY%}ll1KT ze+mk63jf&uzvE+W#KgP`_@5OelGiTXb0*g;68Mz^{AB_D!m;4`{mM&kOLJ&P7**ZL zsvcHkS|ER-Ce3XFPVd!z)~xI$k5u}HJkI#P9CcJk6v%s6@*>mYwrVI(rXf)+ELlbE z`H={|eP#lwpUshA)A3xZ_~#8kSyF7Hz-I_{fs_(S#& zIi>e%Ty?reR^tpb{8Rw^DwDdLIvG%?*G%9O6pAu!RcL8J%#`NX>2&)0p0w0G(tCA} zmu2Xyn5UZ<%USbVO>M2JGdHW#E#IE@bMhqvp-+h*rNuZn`Yr0)%L%R`)$mg%D1i|lJ=}xQjoQOjwO0AWf4!hncw6y!Oc*BeS2o7*eU8|2@5~XickiSuZzX+uD>2RdX8rp;MORH$Iy^1ERCumf{uJlU(luIH zihME~ykE#YQ9M6Tbfs=>wAZdXC%GDvWLAaV+iHcHvOezNpklw*veEwS7yO0=8%>4X z^WPVUEjad5C1-G)dBbg>bh*EtxC=p}a>UVUZI+;#npvd`K`ql@}CuHWYxOJ((H zoC^M4aW}s+F>QwBap@ub@Iysh0)5?xjn;)(q5~7V;S@}I$Y9CBUTi=kejq6_`AW>dE znY4uQ2Mdh@h{>^7+4~tBzROT3=FKn%AbJYdy7q@vhwfJonY3w_flTIho}yE2eBG%_ zO|sI@YsqXGe({z^@4nbYt#rB6b()xO6UZ$|Ddar}No*0;Uqb0?AKOK%R_W!W{SOBrUqNl)icJ`OSTnjm>$d4~KQ% z^Lo&ur_&#Ay#)1#L_Tdb;H>NHcfpt zU$DC5s(;F}wC-b}mStBpwL%t%x-Le`G(GLi+Z1YSnXMkGAh> z2>2mzQS3mJ!~ta^k&hZ_JsEn!J09SV^P8FMV>n^<)?-72w*h8pg6)k8mv^4)jPd^R zIpg^$)}NnT^4@B^`hml`b%{M8c^3A~uIjhk8VmCa7ex!iD6R-gY7@=AU9%!MCiAk3 z?t_yrZse9(9rBWsUbEKKe&_aw+qW{ZV;AB^bvVxMa?lMudnoWQhqr*GX_?weFW>wX zyp?*wNlxE;KkQCqWSQoOmY?`8d?i2kXV+PoDU9_lmff)4i=kbERaKh@m;jN@ZNN>Kv{W zIMRUxmQj@qgVkNuB^riD(k1bVXYtDI}NcTOy?)_;NW#)^V zOJm8mFDBWb&+}yD3aV#ZT(=@XuX-xm^#jA?B#!?ruf(aoL)Xp~Ex8-K-ak<^#0t&X zW}%q>rNO(|9}sjzha!lz!UW?q3icv#sz?U#MUPIStT ze2`mMzF&voxbWR=3Q^g&3$L?oj6kEm%W@nV=VjiITPX2vwBop2e!o#Z!JJ%%H!XSe z_3BGvrffk?&()*rw)Lnysn~5E@jCulVxZ*xm5pj#%+*Yb8*ax753O#$EVMAqK0-IR zGN^+^LS~E8?ri3X^5DL^1G$XncOE^#q_*c(`?K`0Yo!}9@{e)KG`Q_L<5A{%&m)

RcN`2aH6L*_J&fb5ixa(4defu)<^q>biA8-5Y2I~f z0zdf5w!hL;sJbA~5iNDT#nK=w?PbKxZFv#R&ZPn79{VR%>lCjG1SdN%I*cG~lf*In{uj@zFuxD`z{PphLBtAz`9Ur2~c4_MvVvr%lx>$O8n zJh{2`%pGhGj|XUQW;Ptsibxc=P>~>xiP?C;NCWK`8p$H>Wci^qL2Gl{kk>koz8~2n zwgU~aqI=Gr>LIiX-XhiaK2luMA%L}v$m5x=kqj72HuXn3qyOO!8U?X@mr9*TPG+3>3PVWrO5&z5N zAd0(CXVogs;-{sGRa^CY_q|6FAV6D@|M&lW9LO&(_nmX@dFQTk?|t_i?V5|+?~9jp z_JzNGx8Lr0VeGjzNyV%^Y5aXwhkRTFyOzR`(p9!I#4GB3SEXZ^BFX!9MM?4Lf*n6* z^$eJQcU{aqyUJ~x>)pm@RMZ4B81a7|ud3+yy@SuMJ(90_yZ)8-;G)+!ON(_O_rL02 zOR(#s{zJFs@WiuHtJDF(Y5sF;x+|5rGnR>Rhm~~d-#;sEWrDZ2S- z)bzVIl`B7UQr-yTYp7H9;I0dkF5N3jc_q3R{~+Pu=N25sA?Wai z;P|2$e~}%mOWr^K;z+*@>jxbfJU-@Ot~Q)IJGC${^l~DbeeyyMiLmMLmQLGcmT=67 znkD&zp$)Rfk2a-8eSTH2;LeuVM0QrME>~XnTj{r?Ecy|&`%U?XlQ-XK7p{J+NuD=0 z{}_MtNcYM)Q&Byk zhqsd8{Fl;|Yjk_pIF_p_-OJVdz1JTetNgO}?O5_zyRZZPz6AA|!F{UwXPoJv9Qvpm z|NPtZBHB^vo)v=bT}Oqy+ecgbWS>JmtL!zy`kPl%7ti7!ayK7I34HM5G&*<34uys8 z#Y zzVyUu!Se-Mcnel{xG`$Y_2K4T{Bx0^0Z#^G7Y}%MMRacMtAbmMjSCmYsTNd`M&BRO zYgJM4vT}!~y6SblzioK^2HrSjZuhUlo}Soy`OnV%@>X{-U*F?ghSWA|ba-i(dG4XB zDBfkOCXXuhoMWCwy=-^D%Ds31W!#u@ch114n*+zuqu!Q?2MqHa?i4$Ewo|61q*A;& z)cV54E4?bOY@r_X-y2uy5U9*NVCE6pw`T90H#N1FYo1)cn=Sr@BG~LY>7?~+&xq-z z-#pVr9i%9&`&Pa3?zgn}meAbT!ob{THnJ0ol5&MJyw*=#zAwJ$K zU)XdhJ7RBs1-aUSQ07*6d1u3+E0t8{N(M>L{yYmbAzZ>sc0}_-Ph{lWuaozloFV9vyaeoM7w8 zUN_eLViU74`gZ zTwI?bdUws~tXT1QSN5Q7v&m7zmTk0oU%NFDnp`Z}t+;V5?1AmIQH4}eZEgkWP^nLr z+kO&baMzw!clW%PzA*0R1${posI@4YWZvO5qj>9bm*j%<8N!W+_tz{u&^P(kx9(*! z$DL2cZtM2ptY2Dot$SeqOFY;4J#2C;_w#2$c}c&o8SHWXFdTt)? z+O?dW&w5ZiMZe!Ht-PpMdhXqnuy5R!=dTVc+7@>snEC3EbULR`F4H%x`=T7%qTZX2 zJG=SRoY=YRdj7#*Po&z_RQ#?ZaklbRvVcdoy}K^o_{-?W_H5;yTjv!J5;6oQ>^&IU2DuUy6@j|;x4(W;%;2brHbrH&c7iz{6I$Zp%oLK&Z!-9V>A7p*WFOb$z&3l zN*u{4A0PDiX76cRA7m?DE_%J~>fe=r!2m-StS_cT`_Q5$X+K>s-piAa)(aS?1ZxquCAO~c(uz{W4G7^^|d{A z;Be#~6|Z`t7k$tvXa6v}8S|d(JVmI@>pyho58p2T(a-VgzFV`MpN!gm_=3Icg|Gi@ z-F4q}t9@eD*<@QRcAca9%JSaiwedIm^9rYaYuRo1v;UF0d6q0WHOh9gHBc+o_WLx=%ZiJM_cxp$`O}ASRY#Jtk9?t?-hW!A`?O_oT_5e-Klv@sZbdJPcZ~U> z7msp>96CB+!w}SCIlmF!r6|ma$qIG8Ib@e+%ZKM*CU6#QwdrOZn>^qL|2&O_=yIm#%LAtlIh-0< zExzTx_^s$ze2*DrpI;lF`qJU8JO&mC&OM$X`g6pV!k5!K7^dW0!Zgb9_2W)YM}C!< z)tizhRXvEhz&#tzi4dGFDEF9u@s|ftoi(%&Un6sqwZq{^E~>0|@K_67)@F$9@0 zPHOs0D)iF5x(jj*K3(-VayltBJyilpA(=G+tNTsoi$Qn%8YZP@<3y(sPNzb&AZ+y88&on5jf zo$iEOgOADf-{!5~lvEf%W-Yh=)D~3uUky#R|5khh;GggRGbr@-{r@(BrpsU2YBk_r zls}C@YcKz{fac0y)=DNoOXEM)yW#miZyL4z{7;*JVd!3n43g{Vlhk1B10OI@%JpM5 zWIUdlLd5{WzvadQsX6ioW|FRL^i1vW_o2!5Pis8`;9vCrR1p8Qz5oC8&`kMDXc{5MLi?vv8}0x2P#Nv*zfHi?bIcgeRsw=?r9po{G7w-A99F}R z^?G`a8`o;tA>1JB5Sl`&P%2U<8?rM#5XT@}J zL^u^zrMVF6QW0*5a6}S00H|mfkzfU@1WC2+{=&meY^|tqO+B@vM2_#v-9OjjIP1+Re3*yuf9p{(iC~ zQ6VE5=}g|R7NPEOozay=GP*!yq&Im(jW?=;#?){FY8ZHCM)c5-iJaC17hv6z_4b4_ z@bQaGb%{pu&>9KU5-+$ZUNEgG@#sykq?3&|q!5-F7*C8hotSAPD7}%OEpdfg<_gmr ziHw)MAX%+O`XjWo?Hkn{eU(8H>Qx_?cCRk~C!w+ZmnQRW)ziQK>ijPi_ukK z;YEcD_{<IfV?B6cv*pETC+3#rV&#U&p%;(3!)u*QG5 z*9e3bOY$Gi7(vL$$RK29W*Q}W86~#5*da=_RHF22Ne23-l;J;J1KZ(038wr1*7X6` z()zCtqmln#^!=aq{{Pd1FbUSes81y@nG-3rI%Ecc4*=c}?wC!Bub&{(Ze(f-5F7gJ z1tWwO>Bp?VIr%@;S5v*`mc_|t>eqT$%5E9gyM3|(4Q^`{>7gcrNo)i+5M)F0bcoGds zI)xTcM`^nJo3;NmvR0{MEwq0xA4;SB9}1=Y{r@%rGPxNGFj3zsH85T;wK9z&C6z=V zlZ_l{*WJauY2$venS6mTn#JLXK^x~qa^u8;xQIX=SAfvAA`sAj$fyHBS`OMr3E8ni zPGk@_n#G1_`X^{0x+EbTxq}Mcx?(w?&fA*NLaVC*;;S{OxK|K6 zz(P&o4&_{!!Lf))0$y}f5L?UwAvg^X_kH^*YWFwhmyfhQ5ia3bk60+$&X63q-@ zL*PQp=S2ylL!#LNwg)7L4s4Jn4vb=s=5RU8NPz%QSBbY&-q^98W7x0T966pQjaUz3x5dH&P6VSN|o&ZrjXdYA#3IXCr@mSG8 z!ba%;8Fe5R!4!l;lyrImSFbo0J1{!L2nD%KqjKwlY1K=naP@(*Kspa3dVxNYizNu- z_-ufO|3p-dryzuZ><~^Q8qF$@%L@vJhyrwL0}Ra^Rf3v`-O?i&A!6OIltMJzsD}nX z#Ny~GP#+~lqM95jNe01@h#WaAQD~dM1;VjltWyDjK=rYDn!(2l z5a42A%0Q67Ch$3UpqM&guz{@!WG)CMppQ}j(CeEyPyz7w$7qgPsFBFwWC=2HZbm^o zguen2Dj47CFbD<=geHji8bun?zXj?PN_jK95mDtjS!&($Hmgh=_n+ufkOIpT5~W@W zL~Kt6i9(`bQPqs>4`T-GNEX5P8?SaEiKe;AiD!wZRHelnOCmWUH60NUDF!`5@Tu!Y zAT-pxJ=%8=>e`>a3+6`%q}@=l|LS9H3_G|GIGx-Fx?h zz@Xx9yufO5J+)bmhQ@>rAaWa0w zp9BfjkQ9|T6`11FspTTNl(Aw+N{;9Zqu@G=SbXmlzAf#C{e z1(6es*Re^66hx9K>^QX!l1WsM7L3XXlOYN2oLHy9{4k>dpOKtYdMORG(#e>)U$>8+ zEI|qlLR5u@q)akM3xa2oKoLQ3x+EFtE&TqG;DDuZrKzueqA6Z{wN|SDar9(KY6UWY zpl|fle=>>2v>2u`ih|Lg1VqS1DgmJk5b~BQk8AThG2#C$M^KRi!J9Gq1vCdRvEV~Y zrBXeK4{L(Zhh^d3!)3tjIi(IqAd`s!8EB2j@Nb;V1^fSe@VXF^9>nMS%akNI9VSEw zx&FxtIrbw;5ah3sp_c@EPA~)l@*rj8N(4Lp&FPO&msKEBz=oo=us9+($RL+K71fQH zt9RI5AA_e$P0^)_Sqcq^1B!DtMnFyWWLU01x`}4cgs2a53_*XVkxUxNmQvduo!FdATvWY4JBo=SlA;VB?OUGYNa|+4Ur>+(Eqacq|J@nN`AI} z1;V6KlX{k@%g2mlXJtvYwb9{{?vw(PMTvSutE zK%>!UbOViUK>Si7;@MXs_KHMo088PFSfICEI)`NUI8$!)z6|(N=cMl5UJm*&m1ht9 z1hVE=oQ`9H-vRJxgNQOmAzXSRTzZRA1pcv&)+Ig5&sEyXyIb4~i&FiGgj|^@JX;8+ z^Y@jH*F8XzN0OltIMeOu>Pk^%9mVGdXjFFO(=R}#ewT9}KE*r` z@eaEU&$f9ES`c(nBI-E#FYFUh@$&IB3qPL>>ZRh*$d*xa(LNpkNuIf|8K9UvUW4gmuTil};vv^KiAxk+O-AIYMNb)0T!YCu5$jlGT_Mo|rhT=ns zN9w1-LjA*I8Go&Jq>us!@?|DkD7Z=98_O&RbSwiIq#xX9`zn z!FoT3dIN>hZGb-Ur(a9};xn5~Et~x;N#hAz2KCG`<|YvaY{itiM)=C9p{Jhv*Nsab(u3LH^{|4s$^O2r!6m9chR`L{WS|0?|>EGv|2 ztW{;MMZ{o-`W9X2!RK#^W^K-GYeQG9=Y&oze9s47n_U~v2;S7^0OJ`8K;Nxr1W!Yj zo)JD3WXaHjeFyKkI$#g3Y3_Sl=%4pmy8h#P?LDcC75-lb`=xSp{b#S7p8xwI*Q3{e z7;n6uC7=PtC$jic4lVvLl;76+5AT9+atSDaduSCXsU4ncAt+MTsNu+u-5H2{x@nTh~h4R?L>Q8OGmt zMdKu393okC;15}dPGSH;?|g$rJmx@HVWLi!bE%cu>qudwHt0s{8=@C7=M!wq&)c^) zNB{d;U!SLcDY?x|c8gTk@?@{aaQ8%`-BN?ycQm^_(d70xbKBM|U)!~GZP&83WlPqU zEmvE&RBhQZwQWn(o3%V8+kbq&^lg-}D*ksrVgEG56m7Fx zZ#4&h|BY_%YlQ{6Q3zD-V6ID>#R&WBKAG+$jgVqL=z-U~V^V$4Ny(7km1{q_r zg)tj3m;YEiof~&}1xc>D&96g0zKuna@T-t7B&4nPI-Od#5l%`l^eQ=Zci8W>BdH5{ zG+MNJXaRZ0JZDC)O+ zC6E7Kc>lLp{CB$l+e=-`_J2Eg+Wv31GG>o%0T+Iov-R2XUEpY|7`TEBKd@UFM7Jeb2=skaU9gr6I@~_i_Qn6Gx%x6!_&BJW@mg;`X z?Cj7La(K&}C3klC!aBU+ceL;j=x9kCk9a{)gFs2^HG7UClB)seTeW`eq4s}tL4Q*) zbas`?KNbilK?ocE?y;bJjN*XS;h#0=vjLdJ^jQnYdi2={)I$2K;=<;=qt0x8P!RiM z$GLDLC^bcC&DH_py?A}IjAi;iAeWz1#&Z2%Jix`CnE!t{)&DPXRe!yo>h4ilM?xW& z7YHaB1J5BkLSJSWM%r04*b2WMXR2(Fz{Uuk_Te|f2U9%~{51qnWuINR2f0EXo?|;m zd6~~HTa6>(uj0o>xpq)K&7PEtdms!N4`fbW@4WJ9w6Im3E5 z63`#YojA}GLAS_Ix}^POAbqH4MrBsirLFd^JE!#{Ay1!c!*)lTX;bY_)vovFv!OOs zx$pU-bNcRi~%kDM04)+Ob5%L z=(wmrr7%k1l%E~dyf>v8XDRj_gr$aGB)!E9ZEnqBJaZIxtlW+JRPM&zDR)Djl(d`+ zO9g=?tF~=e4I14*+wh1x6j$h4L&XioukhgeN;vMmvMT1DmBmc%7eE-=TZa8hM%x{r zz2no~qfv7vjdYJjZSN}R596Gox7 zJpj?{%*_*NhLJ@95^8<2#6L!BQ0i75M2SxGjA zT61=*S;h=$?ok{CEU%l(y+IR`-=`d%SJUr^Tp2B@rng;A^A<{6%9KEZ^;07AtWM}g zp~nUKS_H4pb!Tp2Gv>?t3k&(8js~iAtH~h4jQa;}(KD>2n0@WEk@wb13?)Fn)QyMf zstR|c87MvFizS(+YOM#oHou3lJ+%GG%vCX@mzNC^0+XjL4iUKX`l}xx=zwq+WxiJumraC!lxG z?-KiHIOsCaM`Ll8kLr<=NA$=I@_Y+8d~Z_gNK9s++AFKMBnmSXB&i^I2ZCgIaB#}x zDU-irCg(BhDVL{Q{*JkvZ>5lOdCKMQn9IE#K2knU`TQO8Ip26D&~sQQ|<8b@+L{b#< zd!e+A<|(Gf!@pu_OOd)^+D`53p!G*m+F~s2;Jn}J{xO@{m$4}uNI|EaRK<%3`OwfXt4 z#r;w~J^%G3u1NbUhP-_q*u4EqrGve+{a@lrX#ctW{m*~S!;mm-{};HD+g}3>d!L&) zQ+*p{EFb?D@}<4#`EUFAVlf^6zrY~^fHptiW zVW&+BxjaGNYS|IRW|tmwDezOu?(Xh#ccq+Rjm2SKyhlI<%*k)FHqDk(97TXhIKIOl zRZ@=WVVPA&b6_stY3zL>b?d=&(EH7tXfok`eRO!(o=a7crDVBuZFYmlogN9c^8nNS ziK;pRnON%eQ4lf4;QSyviX-rNPPT1{<0cbM5v>s2ej! zojF-N`=T1$+A`F=yG_PJwzx~kyWlbGL(noOs1-6w?tEp1k5eLn9xES zjQ`qXXT#Dchse7t-549fv3DwKRa&El!f{obj)|lLo6-&aNYWl?S=a2W9Mie{xC*bk}xkj;juLbBN) z4W~fBF!^TEtu~feL6C4#U}(ZGpf%U2kx19PI-DC*)vE-xC9yO-l}lh>1pa8;q7R*V zCmi?q9TKl9Lh_~ga2;Z93&#WcyIvmm)IQ zO*n>51=Hh}kJ-kcWCp0d8Vqaf_}fHYNGz9&GQi$H+|oUGlnzRSV{WUB(JPToD}g(f zB;Tl(`0Lm*=H?a1kiy;`a>SSn*{8)-UJ2Zmr%}N5&x2%uVcI2j7hRLpnXU5v(q>Nq zmSZ5IvNIqOBjS@QFeWLBSk8>v{(TvTzWResW9-uG1S}X7HC|k@pw*eJAs@8`3kp=YBeR^gj8vHG#t0kv5ZX zl}My;PxzC|61jV5dcs3bGo~M|;nCT+CT?{l-8Qh!*Tx*V#qpcm#h5T`F#|AKW~8b! z;sB=sygSXA&=QM@&F<+`#LUyHjN*z;WL>iDKq@wxQXFrj@j1vA-jIX*PySHsNDpEW zX2t&tJ=bw_^6_v@!IlFgrqYe-)j7ab)saO+mX=eAxD*X0%N5=69ROa6Tp@s5u^`sw zV?=I089B*B(m4jXGprj%!jS=gSgCp1`8Gl{pDV44Xg)Cd45D_bS++yW`3O3+OR*e- z2Y>Zw!+OIWY*=sT6YSAl)cr65upP;k0q_hNn*y*L>>St!)|@GX5At3leY_DLC0Jn8 z=h6&%8krg(2{b>Jh?wkv*uVfo(;edzCdqbt*}+AvlO3Mdy1xznD*-b(G`P%V>c$l5 zZ&QJDr|KXT)E_)W@HpP{Ft;!$kGPwFBG%jtPgEFBM~0hoFAX zmxW_|2l9{T(4avIMwGIvdbvi9e5Lc6h_aSO#+*$H&Dfyh7PwBqXc>3vE#unxuX9T~ zVna>Kl}I=jq?5n+biD;Q*$h;cP1f@Qn>T*OcmCA>2bfu_+IRwAN(BLWy@I|Lhlc`T zGf7%wil#kZ1!EHv-D%~&tB$VcqQBaf}^CTm$AzJS3Zc@|4QY2YX5tQ z>s8tRh&R7^TZTT@(wAuHOYMA5vGZ+i=8GGw1a9+NW@SpveecoSms;&otKC|_w`8^B zBGXf2o(SEBtd6884eoKaH_~n42ps3i4yYSvYzd0 zM&?FUO&e`%1ZiR6T#1s7=yYEGl0;HzO(_Lu8^^Ii@ZgcIzf8{^9H5G0Bp$wL10?AJC08bq#{%b+HI=dQI66m zP>b*Z05TMk51M~Y&%C6KA2Ic=u*;CA*kwFW%zD8aUQsQmuEI>Gyjc{lxA}HMOJr!) zy$b(~b+6!@x0J<+ugfYqLTb8BXd)Zhz=lDFs^q+iUZ~bovu%z8k_svYV=AoUF5>{; z5*&<<)m_@I$N;Kkqh)l2<4$Y{iIP4;`3b;;Y~zw`8?r|Ictg~t-n=&XfQ={&cn;wg zT8N^8sNlW8{p9gjpwsULn8E!F?V#}zFgvSxhOzN3#dDWT4Mn@gUzJvib~Jmk>s!g- zrA>Puwg6om5P@TCRo62Bfl8$75O!<<0ZK8EpbjUIO-+{*Xv|PeG&^%Ww`NczGj0O^ z+XgKWRT#d(P& zpTSpdtt`X>MlLf4q&30qX0h04ZF2!}a^56^-s$j5t=}ZA0lDb+KDQdp1`%olcoufa zm)7tcJ#-;Ozt$c8PI{-L*8QFQ*6KEPN%QMPzd0C?UO&_7T(nzFc-QLI+n0@2_l%rC zzHVyrMb(;P9IXu=*TJ6^G_ub5CYuH7Yr@cO@k&9Y?*s5Q) zYklYx{fpk93B@-6Y`4`t?L#TePP03Nj?(JFOVa!dPh@ajYqzniOzjfT?<0bw-n;m{ z-#R-VlJj1>(S(;LO+XEOm04L(t9rZE>g|V<~rCPB+&>|TtQqs4ZZdUeisKG*kN?M zi48RK&;!DPsVrQg#PvQ0z&;$9$^HBTepzQ93))C*wLh(l7H44r{sMb`WCiXOXx# zhNX`oEtvGFFpc{>Z}c(}+XW#}nh_yTQ7&%zM?J2@6_kz|Q8 zRO)vcoW9rmNgfSbW0K^F2(VA=@w?(B#Q5Jz5f>s*Fs>NCsxBiUFc>o;3ge0rWH3CI z7fQiMUN}WZU~B{I7K7diCx&DCEMys)a-lQOWFA+`}VwM+^Ra$0!gX zJ1hj&2tnB3aqpVn=ywE9X$j*H-Vbbs7_W_cSgx;NW1oe=-2py?=N7n;#|^-eTxQTc zufPg5C>Q7oC=Js1gH1}aKeAqk5qJaXVQ7QzW*g<@nF*b}}{I(qsh z+URsx1@#Tf!1W3pz*ib*m{8#^fp1<#lShkS1KSFDL^CPAZG=mlj)j{L49}(l_e|IT z!9HeHddApw8uq+=_Av7lY&OaR(D^WMdUz3pco|5Uia+Bf7-(!Df<`@Xr~p;Q0wlsC z#fe~Wg~jF-UAVz%G>aqv>JF0t06vclcO*f9id9=e(V>Vo_{=d-NTYFsz-X$&Txqb8 z5%Dk(Gb{8bna-w@5n7lIJyaX@y$D-}6&Rprpsz>ftVELn7h7u>`~|dL^N%`m2`vpm zR#LyKsjl=8)bU{44toi7GB*;!{#f|{*B4O!!JY_#9V3q&;v7+JFwlp=s%Vlx4*^9r z`Z9D1`FnfCG78>KN$?6J5?)L~WkmD&*0yazu}MIg@YP9pk2_{;sOPe_wSqOQ>C7O6 zr5%V8@<+W9C}AL)!>8~yvjb`cx>R|VG+I?TST8$*FOJZ@q=jz$-=Tw*e=&nVCw@r_ zu>YSC12bpxsJRel2UI;E5(or9Be2Hr4N>z;6CSq0Kv1;=bir0os|ZIOD2;@dT)3Wz zm+i3-Hh6RhBk&837;G|lhLnaTmo46I$%LI_w-SUPp){_YgQ6x%mq&<355(dE2b+dx zu~;uLaf&lx+@!Ica@a_4AUBUe{aHBbfJmeKAQ1uy*az@P41;M@4i(jXB!CLyHtKGc zF;MQ%qz)a17uk4({L#pQ=XQiUi9<__n z!!QA0V;G^xckPeJ=|@}Ow=8ci@`dH$RdhTYebuBw!qAB4k9v#LOQVmdpK49mI>k)FTXP;5*&d!Zv-#g^Jb&F7%2=5o@3HL7sDh%!o;eH zO9!4c3&wT<=6z4V$Vzng8f-n3g8nz<3KR@jBuATy1!81n0D6F+l#fnE&lQ(8o6C_N z&x(e*)c;-bUiV!|qJzO*DIAax`bPrBG|;P)PM0h(OA(N{#6^A@ooh;IS-=Bt{s+YNnDkz?b<;kF|| zHm=UFT@ZuK!RvtV46^Qw!gJY05HxlpWv->$%H174)3-FwlRbZD(a|_jhumE^Ep~?F z3JQeCX;dZ{AJh!Ilprf!`ou!a$xAHIOH4gj&|uz)+@)vgLt~2Vl^n|6n$G^@we3x@ z=UaBmK~Ki|eHDtQ#MdKF*7)>^xy7+Np+<-) z7w{SCZMowc0!c!<=OnR11&&S%Sk!XsEq~3kDY54?yqc;9)u%#+FXdMukX2>>N~m=@ zE$x?O+pqT5Tr1f{8(R^_PQQCnB;dx&nL8_vpO)~Wv>=f^Q=nGJAEGQg*SEobM;gSe z-46A~tUYx)abe@)InaAMmEX{&-rfmzPGEWuMlj@fW`PIlpo#Zcq^nDzXWyG#DuDcdP zN}VZ{`Ia+auL)h$XsT{k;kPhu;@h~*Q>!gn;MgwzKG$7wkd^Sj0ns?Ywuh!Oe%j40 z?}&=<`V^L&y0)Z=JlP$x55ExHAT6Agv#EDTaIc3_YwpjrKFOC-Y5j}eCT|#%d%GPvR@|~lwQTLik9M_Z9Hvi8*zxinylGo<*PD$u zB^C=yl#S`CGHu!3l7IW~+iPRu*^RApCEp5ejxo1zd|&(q*1O`*+C7EujcMELfZ#jK z@+(RP?zb7~l**r0hCEN&5p9vyAY=ti*Gm*?v^exIY-@z$bf4vGHw>(i-mSl+G^#aI zD1a1@7BVTS>}G-28V$q8QQ~~U%5{B*{ayIZIseATWC`V%w9Tyjl*s-ptPGtvF(fL- z>gKCBMq1kL)kB8bGM9Kiy*r^!S;&uFJIlX0|E90ip@F0Wc2MHW$=zYAu1L*B^&{JQ z|A2y2aR&QBVQ;ur_JG3q80)mB4X35V-pH(yfkYefi#nOLp8D$QNjmX#4N>$D8DnX)b>_6n;T8?F~! z>*+Fo>SKLXP)$ne+V-XK{<$BA6i!B0NU8gYjk`~g|9sU{XIg}Z6zvwO{LfAM8zQ?? z?0xPY)Ulm!6*%$N6E4ChCr`8~QoAj;dVa`zL*emW`#2N#@9@)?$yn(GxhEzUA0Pkx)VHM6 zp`Vo9Tz5uWL~oxJJFUjdUGad$Vs=pOCUb-PP}MSrHXCVE9cjg?p{UJ|r)qJ=ZfdIU z=}9rjY096WEO3-8df!B(wcOmu=ibv#sp=thHjue_^I>7DJu~0;#$TQ--zpWZS)h`! zI_c^8U-wE`y0zCi3DVQ%Kk85PI_WMP*3CC>utw&UwF&30*!B<0O{>Nl_;&}@E9u^w z>nvhg6<@bppyrv~`|ZEE6^p-a71%hrSJ|;*+`jb@5>NOpPwIv}4j=Nl$6vBu^~Ib| zu^%O>Wn26bRwwKJdi?0)eX*Mtbg5)dE5BH$$LE>b-R!(Vdez5{5*rwKKUv5lA?j?e zT(05r;-Ev#s`pN<>oZZ4vMMOBOw3(daI-dd(({(vtq!HK3>Pg={VZh2;)Ry9u=Mq- z9PwWS?c10&UTk4Cz3OYeResFCFRQ@ z)hoqr6?&0|``evRmghU|wF}4>f3{fmEM-OjpGHVm-F0O9{@QDmKfkf`xESAN6sq$0 zWJtSN(!%vVy#iAOA^mkOhsz4bWL{!@YOm-WDtHxgreuY)oJg!=S8n0`b3N4i2YPRj zo}5(@T4S4<_(0Aq{<^L-bbQ9__fa2j1fu?+Y$)c{5lAj=($?3SF}00?x>uz41S?Ux zPZmaO*qe*+3uxyaqF1-_b!Pg;84ez1?d)v47PGA+r(CSUJXc=&x{qUt!iH^Vm{4pw zUQ%r=vWhL6y=D?cKRV;8;ox4@&Jc@nc91!%amC()eC9h$StsC_TD?-J>bIP$?{bQ_ zx2IFZ7bZ7H4DCu9UN48_ z`$D_}&-6{b+?8S3nT43{o0oOEJ%$waQ$_ri9npL3#_!WmteOyf%C;kYm6C%GU-I4s zpKo{zKo!enRBsJ+cC4m;l=*q!W^0~z0L3Zl`7)sr5w-rI2EVa#;|}-pRX=a5ed9Nw z!0X7Gx2)8N;?>Zxxbngmjn?m=6COiI{;LR*Y*hWx5^3tklkKens{(fM7io3ai)%yd z2frMQC)GUd_mxWYJ?Ut*nbtL^(-@i&6D_evZ|kmo#%VkAp@Da|7&=Q`t+I!z!lSAx zD~FCQ9ZEO(e4_g-sb*ZFFFN^2zi%H$ZEJO@o09WEzAcfE*359D4CWav31{2vp}7+Z z)b}p&e7UP$u727+=(g%w$2Xteylh!veMUP(hBLn+U()$(-b{|5g)yt{QvI%2v3(7C zirxYbf6866#1=|+)b0E=q8hR27aAKzr)obw9UR_*83D?5%tYt8t+6H zj|V)W_PknFCAn|R>CULrok^Zse%?&GdVHYHAXk9%yw)~TuYfJEOr-kQ&nAbwdnK=T zzlE8b)W}nJY)Q4eu6yV5$qQM>Mc~COqlc?~8#|&qHsocuiI@F)h@ZSlWo>Kv6h-x} z*OBYGJF^W3<8%iED4WlFJv!X~)bQ0^L(=w(J6;HJs!NXr>_~@bw;8QWSEuL8!}bRY zWEQq8n6++-l1Bz=Pty^v;|Ah+@RM{aSAN3@ukVyy7JD#8y1QR)mK6rW~mr=jPV+SNI1V1JCrJD z5X4_UQEd#|`?0yxXsE&mh(eWmeZHs0&r#&!A3hHfK_v90)5GC}XulK^V z^Wu*j4+*dyW|8&pK$7okDphVcLTi(dCMojvEF((uuylwC0}v1@_B*teg%ze(;cqFHMLo z4tij6TwC;fXHM&WJFQs?<)tYGaptz6oZwR_-4`xs*rV3qEoRIyPDDjnuXT9$OQFmy z)~_guV5G3 z1VSnC;nNd3cV^yicb_a%9nmCu_R+pKZ|2^ad+*%2bLY;y=Suc|_R1w&R+V;bpRZ>w zyrKNQD?fPo8w*Bft?W9wMn124_l)xwA9!iUZ@)I@`SWgDu=%7fx4yZx{nOv={npXv zw>))jUG;6J-+M~z)!|DI9%yPBS^kIWYuqo2j)6ShXBfIgVGv5r% zn}5dZ4}Ek1R6wi0q4aJredYIkd!uto7XI^RUw-hD)*U0$X52aLSjn-6gNGLMEgpPS z=)Pt7qM>J=tUvtK(2Sj@y+7}JH=MNpnWrw96L=^vbNgF|?)%{{J7+%nU+b0ibFLbx z``vk0c7AsDn-5HX>%XU^uH4*x&gzT4eeG?3eZRE*tfo`$oEQ7?js>w7o*ao>GyCy_ z=bt8D@ZxWN(D=QR&$u0?DOZ0(_{j$!%&0rG{^5;O&3JoKDHwGN#n@$r+4oB)+?80H{EpR z;ax8-s6W~3*FLGADIDP*-~H^vrTY$FviRw{kGxkYZ_}?h=h>>8x;NhAX_zVevc2nx zCGQ^CiQcB1GWH+^vWW5Ul4-a2b>-`;mS%PxyApFXSZ-aBgUd2aW+ zO?w}#J@)E7L;rbpN6mn)lr7$N_~3%a7x#9TH2Is4u0H$mA1iBa_9PdUw4$HCan+gf zl51A(ee=+f!<>(kL!sBNUVB!_O|t{x2R8m=;;)V#kxITl|5o27PP*;}aqD;g?e=$` zyJycwO80k5nhrekAu6jVzyGNpt@Q7d_PzFZuO?3YkL*)-uZq6<&Ys7f|G}J+uY9Lc z{r6wZn19`6LqD26bj>5XcRfOm0?iG}>+h?( zeA^f0keIqA^~&@AWrzQNoc}Hh;i>b#C*vx@fBc(H#VZmMhT}N?Us0Cw&;OCb^3?vH zNx3S^%RS`?(WM^7_##{D#2Bx{r2KUrDCykW0qdDf5bJ9#Ub0AF$h+7$%n(+iNP;?& z>%;Gh@7wm2S9(02`NpS)sesi(kw#XC9cd5+0x7m62q<*qNvk8H3>bV-2F;^U ztGb4KEh}q#FKuY=Xl`5HyL@FUhc<6Ud1j(y|w~hSA$W zqY5*Kh6PHKUH#^AFI@r$YC)9ofUyD_a|_s^d1*`)LbYb(9RY1-sr0}?GG-ZB&L+#n zjwNig$%E($F)Xxp2}%#FsAf|e^fPu6?*f}67i<9*AeGr}OOAEmuM>7qL zW>ANU zNgRHIP-VFh@OCl6JR*TFSZQG%RQ^CEQ1e%l?sZ-YAFa0kT#yq zB-T0`8gQ~+hp;`OQRppACgq%>wpQPeFEjiR zWn$yQ1mPgj%2`B^G8!DBp<{hB27yVem_b8$aNXVIyli}6{IT(*cwZc&KVig}_&hDm zfJ6Pe%=Y!r@EamH^cEC9!=GlqP=upzLBf5h8ommps!brMtPB~r@C&~`Kpt^tX00YT zQ$6Ui8bTSrzsiyXRnrUsg3bIjEn7lTm#Rom6?51jLm$b$$TnOR8~#Y9!tu{J#^G)YQPm_bu|DC( zuu17IL`U>F<0>P7^)J;*&^k~J?Z-0TxZ zIQV!%!C7Ri)u*jq5;G(BY4>Gd!7L@mPPxX&k1ss_|Ez=TeVgoZfJ*20VsoE>dq1{X zoZl5~8e^0!r3^vY^HhZb`Tj2dBcv2JFo1pW}iS#bJ(F55msE)Q3>uvcx%Tr#CYO~pq z0XBrt{gWwrPJd>|+SQ21R=eyF;|tsJz3^p$Lg^_r6;3Lr595)KD9B#(mG^9G1NX-j}4z}^&`LVOP_i8KwTkzba^`aVu&cQhR) z!2tw+@!Yiv*JB);FD#=Na^dQcM&isEIIS<9?y-T_keMPbrZ3tvJ2_Wz|NjI!|4WYR z|CdE2l<)r+m8tXpC*{iX|1;-5`3DM5spLicpKSEN|3$2a2k^*ldjB1MY}g;<@akJ< zu4b&mRs)u^zoO8?Z+P>I`OXb5)z{nF>yaed99bR95I@?;E)SgR1z(6C8Ds~=5*rvw zNn({{!@7J#Sxlt)&Y*Vskkz}(o>`u)ROT;kK z0Eo}nsl=hC+Kwg|{t3B0-|jAGHXC8vb!;qbRIzn7oWUchnxV70!CXqqAj~!uSfypM z)R(NOxRS#uY`CV;!uo}9E^00{lws7Y0Dx^QYgUC*VzYR7SD`p&-NM0QECbXz-B%w#I17hcTVGvG?l$AwMT>j@J_rdMRJ&D83}c8_jIg6ibWGeKJbnRG zI06ngM}yBF>FEqo(`&G>`}ru9Y+`Fy@n4wWI_29BWgZN<+dVIzl8 z8YPw%DY222*g&4Pk^)wVCVL57;4(k~e>d7PHQO`M*N}I!1r8d$PS0iFyG1}D9hyIq zOOcjl3R(&c1(`$oKpg+1i46)Yv1}wNER<`gvrCbCYBm*jIPs%eSW#6u9Kplns2)j# zR#jIZnj$6zKBPfr z9uIed93nN*BC4P(5eg)%Ny&I3;tE6*bRnVXgd+(_3iDx&+$Uu%#A}f-X-+7l3Nkj- z-GHc3UDBg`h!jldNmWV`A}e7f$%|T)5LOdaIT3Mh4rYQXMP)*hNH{DcSrZg3swpPH z^^g?d6Ye#Uh$ClO)W$(ZG8MRK;+D(kCISiIAeW14+taR1{fr zBvDN!ql6=B91}`X!<67rNd-i%5*rG|L(v40jYyJDBoa|d%%q-7%3&fukx)bqY1$Zl zC#golx=j0vE+%wEC&W}GY+p$Nt)b3G1VJ4`?86}`tVam;xF)GdQ6e-ERV}QEaiR+J zctp{ps6Y*L`}NNT!wA5b?BgSvZFt5n4+s@*u?M06AIquv+l2!%Von`%^uDezSA|O~!c*+X7o6E#h_jOlPqh=hbWgRO|{ zFlz(u11QXvoCus6fMPsL6uiX1^8~Pggn;+;bAExLz&BMSw*_9pc?FTP-~oKzgfCL~ zB7-jx$OaY@zG%P~34GB8ADSvy^%n_z$%HRZ_yU7(5Qbtg;Y$X5iNF_Z@S&}uReyoN z7ki9F6C1z86Xn;^;{5W3$}u6iGOV7Hv|hgcpn!=S?y0f^v2!pq9tJLTVIW561B?bz z&cN#D9atp?Rv=<@JbYd1!dHq`EP~eASkZx&@LL`azn8l3o8py<;1wNs1qWUt2mE;C zKsr%5XmXJQ3ClsKP!1%?T@H{u9zkew5d?|JK^{^N0~^vpF%X3D$U&2f97s$I^07Lb zT0{zz@kl|Fixfyq2=cLt4y;9FKpKw>$R{cT%`P$!F7Gdt0698_1SsQ?fMyp72vZ3t zGiej)E|IE(OJaN&KvC>1KpA*ui-@$+c+8toEfLIwk$ z56;x7mcR`G4lu$koGIkUg!3#~>p6BRHEp27V_V1<@d!rkFNe zTfXE-I*k;WvYLZj0?wrmW=7WZVX4Us5N_f*2~W@Sg9FhZ#pxSEJ_y5@No&272$q-*>g!pWF&VMK zVHLT@SdYgrsufew8H?W}bQREm6U$uBR$0uTI=F@`sSl^{FQznGK4oz;Mr0a>;U_i3 zWL0G14r4(%7_C)fSRdw%xEWGAoD-yAVYkTh3uzHYV+5Ku1WTn*z)Uo>)(a|cpVMtgh{|}VbupU5>3j~hkiseB$v%_P>~T-5&^%nz zyqTodi>b-Ln~Ce~anHyQ7bRO{VlXAJN|7m)1;&6<;{)Zogg7v?UGPVC_Qm&Tfy7t=k)rcH3uBFo+TZjVk zwv4FQ%=da&2mvCI0-lCdE85ySJ3RU8@KgQrkMDBn|9umQ<9PjFR`Sn(lf{rS)&D2s z%3uHQBkTVnTl<&re?0q)@p4R#=CA!bcm54zw2`!K?Dne||L(rzAgtAc4(T&jNa<7I z{yi%Oz*rM!voP4M@_ARr#}QHl3ma@x-xtlW3BFwVKW_cR;W$qJ7eu~b|F6PNo&Pu~ zS8xI^PcUdH5-dSPmB>t$L@GrA3DKA+$M8+wKH>?jg$E)~(!`eZ-qBtMS1xW))zXE zS%wv%AL8(N7x3b!H(;c~EDjg5mBY#uKjOcCY6|s_?8?*s#)qvY6vuJ(zbF;Pe@@wd zlXA_c8r$HzU1bYmrO4ykm=KQPn>>~6>8t@g9@`xR-0OH z7y0NrtV>f#{R-s0sNjqRFY<uBh$oZL1-L$bEftJ6CBtUm@dRrz^D8{Y6I& zGAx!1vYlO$v5L2G9*oSE5f4n@kH=5A8qIafYg-#Q6vG7o9_K05N8vkWsI_)UTgR&2 z`i2!PZL8sH?MoXvYrFzqA$h9+!x9euHn!9*?SMNBt+$QLoH-Pv^|7Ha5O~~M z7ISZP!c$5S1`{@%7|TVA$13DupGk}5)y7jguvSYAqu>yt%)l>5X<%t-VyLk4d6_Ed zz>z5c1Q`ef^4P)IlRb&Ft`5dLrNaX#m^3JoU$rl~OZ-_~F8aS>eQI#Ra2!wn^9Aw$ zA%05#PtKL6|AFsh3IDFw;@eW<77`M{N_~*9!XU&pR5NwJWgroKb|bpgOaEN|6&t1J04=s9*_LgpvTVa?Ck99tTa1=UR>3MSGfl&IaL<9 zt=I;8V+(Ahl#WP>lFA<|)3<`o`@)>jY$0cKrJOT*dCF*VNp@y2G zU!TH)yY}^WittRuq3eu@;pRGbz(jLZAP%KTOWD}Bpp56oNueF-1u^@E8M@BCWr={{ z@6JC25K$Y|6gE(#thdWry1tp?r)wj>&hN;sFTLdHQOwNZRYi~0YU*tTes@Bi_9;($ zSrjp=U*+u83G(g8WYsg&-&OB;zYphlIU3=LBo$Tl9=dwwfF`c;z#rko#7{79ZxyDc zG{TL+3ET`}MiFjRCc4KP&|_|N2`87a52&()mesRqgrQ2}DhOXXu7FIyI;FZV?Q6K& zpo`Mmmx^4R;Oi?S8clHog8Lv%BZnGE3ofZ>7hbm+Er#jzT3gT^6Q00oON8V6lk1-{ z{+H_iM_v8jsB)4W1K zxAT%({;;2I^^p9+2N)c$>Ps$G1=Et>idDvMIf~!3jKvwM4`86ivyiRfyN5M;E3sC7 z4Y8(WEGg)c8*yNrk-y={UV-4#b;N-IAc1!1u9)Ejx}gzo{%W~=KAz@S(EqsqCwc4) zFkg`WrQJ54^S?aBv9$m3_anN1-m(5`8EtFv`)|{Fe*gC*2h9J)J1(>Ya01mUm6F>e zhF;@IBI0x%KhI)7$MvP8_ky0?sV616SuD4r21;}im02b zLRZE0jb#9mS_&Sv2qhcp#BtmxWSgCo(e+v%Hau*qRwON4Q;~+Z{uA zrfqXeZ#lNp5~gTdd}UWGVrymCJOjkZwp`Eaa&#hXby_X6+iG%GcRj0hKWvu5*06P_ z!=1L?@H%G4)|-yy7~M9^T)=D7=-dxmTVbkX>` zqr+=AtoHq|Wxe3En+@J<3Eee?#kKHgwT-49mvxvZ0*}M+&V8O$TR{wjfW2IX#i`@ zyfJaYa*=WyC2H=Jk2ywW{$0h}@OwJ4ngV(KqZzn8u1%Mh`|xM}y}f2>8uPIRMEf$cz;wSw|^V0tOWtpUh7UIrVFq;gRo!aZzrHii$)7 zlqo`6N|(&4Qc6LvQOSjj9?lP*QWKD9_J8FHY=&MX?8D)!_j{WKrdc9`yYHzzL<$Mazmo}>EASJ~!UCW;BUG&J zv5dhrAVI4wEBZq;V_?9rWGWory9S!G&vx>=?Ik)ZLN#GdVgYMktB=n3tp>M}VrX>+ zOrj(!1O_pNhuykA)rc<_lzFae%di|rN#bM55oa9vj`9SZZxfG~6L6!J z6G0z3G`4PY{L})lcT3C0EeIvqUy2UJ_BH0v$_5i$ADGiAO9_GJ0KYY_KsLSsXht3ajXN~z1M-*q_eBj4S%Q2S= z?4yU(M7TbvhFglA@^~Z^p8UxTqHd+9OiHarK8P^k<;ZRlqBv7uBxrvWMzJ`T!yIcW z>R2T6)nFj$hrVI;Fbbkk#OjBqtbW#D^|#-XQ$>9MQnmk~VQO^xVX*i5<6C)t4)+H~ zXG3*$_`08+ejJ_*4i4nS!N*r`_7C=kKMYUz4$oD99(eQv;D0k_r5XB}@5;Nb z?PLYu)S0S_oUydq3TBis%pF_%jgF-#S45K}5yanwe7R8!#T~zlplysQBj5c>RuJBT zVKClWJ$4XCDQ-Cx3~}OyWw|tiPNA8V;nByF{$3CC@;*kiN0q*T0DCYMFDYJmv3D@s zyHk^^DfbKYxUo`?E4;UB@g;@6T!$NfSclJ(^9UN;RoZhRHRzA~phew9O?dw3n(*z9 zE7kc5iXKm||GBMMs@u;WtlRH~Sgza8Z`bYT&$_+t;uu=gkyF=3$NH^AOw+%i!e82^ z+w{Jx6o0wh51Ix*d4Cvy?k?5_QsvJzx1DY0>S{Z7wqbF&9dAc&unlX6?eX-NZJVd1nXAB9$>*$E?GyZ$ zYU7jKC|rb~$S1K976}t3`tHd4Y%WK6u#MMO}zZ2XAF5bc8F|cyF zJq8|+C)<7)`~i-R{{TnF4{O_rNbV&;z7uUbvv}K{Ot)d&f*hIflWxQ4*^Woa_Q?0P zf0>TpN6;^Ap;A0oLqJ|+YvsTC?btv6SpNR^FOUD*Y(MA!e3Ikg@qdly_`m<4W7YUi zE+4OsyY~MX`px*?X8U>kKgDs&=bE!9{+vv?n*LXPsKFgy`ybwJ&3&#pI$?vogS}H& z@xR+2Vn&7c!{b-|J%($+7hp#`?op{IgJG+9OD?U!>_g_#k5v_QtGCnIt^DUdG9`pf z29UCQ$ZrCD9^xpFsX5#h{jJq1DvIUOqQC$CdkK3}VyByr-txCWWbw{$QGpZos_j@A7yuD}-bDKb@18>f@ti|e@E{%^L>*>A4@O}+UX|Nm)@ofm_n zKKWE(7qjD!uMhV7Osm%GXN`WnJ~$n)@86vs9^lfS;?O&3y}tJWH!?G=6#VV7K@s0h zPwH2Q$UsPSO5t>zwC1L+wp-c3d-z9icbAOlozzbQv5P^}zLz3MyOYm^&4wbrfCb53 zNfg;3h38Lp>Jm(%plF}52zpwQUc=L|5UIw-vG97@ts&|_*lSLbXbfNF_q0@8rFFcn z?^eFrp^VrFUd7#T7d@>H_B~KhJ%z%wK^w0W6t-)da*HG)?R`9bQ|%y@ow{skWyg-( zYq)m(3+B5$4WYRYYY`0}W_N)$cjly;YS+T;bNp_h?e6eZwUO^>tiHQb=L)C}6|W!xH_8JEwm;h4fu4=R(XPV0Q&-nJb$WUW5?3Tn>`&3P zOWS?5*x!`sp#OHCLcz?Y_=#2_lYiLGi)wX_U94Iyb8!NUonvdrFZ>ag)q(681<7y@ zJv{@F{OT(Zqk^}7=!z>+eA@22Xd-gvWCsDUxnl)_m(c}w^AY^M@Wmx!+Nnd)dqT?` zecJAj{yr4ijV{9=;xP6G>g=HyK=om$9AJYyc_=)7yof>=DbR+pquWFApd4@;qeTKO z$Hm2i>4`DUBM{SRnQ*HM|p4^{7bEuU<8S-EFRY|?vD3_5C_>Kq@ zq4;?quZp@Cn6K1lFykI5Oi>F(T2~r0$;}}^GvjaYdFK3E!Y3QBsFh0EMk=Oxtq&tX zL)fv2q=e*EUADF~QpC$AJ%Fiv1+Y_W3{07cpnzMPdE%0lk*I`RNfz_Um0DHlJ&Iv+ zy#|mT_v7F?-$up*z>7J2Clv5?%r686ow{Z*W#|>|2-ApSU{ZRHF4Kt+6Io`K2yYf( z3{whaRYU$vOZ4uCY(zfb!6w!Zv}Z)3JF_hifh*mYF%Td6D2LFjY~mVojGGuIHO2tb zIPko0?`3S?5g>E**AOoWin1K0-r#yy2 zvw+8d`I28J7}5qb24(`g6n5gL3K%ZMbI>u!xSjG6#x;?-U!+| zig=K00%pR14V8}Ms)?JD_{c-{OpxF>mHn3SgR^&%3pbeiD(90bfiCU8fO(6;k!=!8 z$Iv+=ktP((R%Q%JaMDF5^1#Q)xw!Km<3C`t0Bwep(kV^RxRC+ZRI#;$eLOkXB#vO( zAq=i2Bk`!-BKARDgby9O6A=R1>}f0@J^ z-$2(upIr(SL7gMCO{Mihr(aIG4eh%#LiF^6mp z#Rh1vk8+n0xXFZ1{qIQS3z!RnpwJdH-(7ck%5$pn&WT}e#O)EmHH|PZBh$=HKZma= z1)_ifz2}QS4Q`%gwTfbjk{rkU8ih&4vn;oH+$eO96Gfk4I+kijU10bR&^C<{hx+n~ z(l@wI0BH7r;u($~PYOSbifquK9%9pgrx?6gjuVhbm0b(Ya6Khp@F&4FV0WUa4}A3E zXhJPkW7Eg22YGm8DQ7Z63-Uh}B4;0swoHc*noM78w)sf-&D0B!C7@G@*=eXL)ntT zq@geOkzjlCz>R1)LcjQOlZhQim!Nhsti-nkw33%;1V{-M6$DpUH%skTtXt%PEC||3 zJ>O&_Xm3bZ&4u(1QVrz10)PUF#=n*AxYJm)KV}H z)^DmFoCfmUM6izLC>;z7mw2(DHb6lpw4g$@p)LxwQLwHU^Z`yhNS5qT3P^&gkh)XG zG6Ri)-xp!#3zaCs$|09%oKHiVU(rgDTu)H`F2I4*tBMFe;KhE4mKa5+5l({9 zDD?lWL|4wkpkOIz2X{Vi=8{i(b8aZf($E?ueKZqLGh!e@C@?thXht*rO5l1_m3Pr0ZnsWe`Bs4dksa>&47!qFvH z0@x|D(TJisqimqG=X2mJ^ncAX2t~J3N^TQN0&D#VG92eDXH4+~A`E>9lQxmdPC#yO z9AfDa4F)A^fR0q&y6++M22;aQ5^r3FpixX&gOdn#QU(KtO_)l%bHrmC-3d@+U@{f%YU|1s&>xv~ z<%<7j?@QpLs?NnH3rhx-u&B7VW|I;KGmvOC+c}*8uoaAspKcW}W)Q%K z4ND{n-Z^vuz7VoGClWXc$U0ou04`o5Zx37maJ=@23JYVG^T27Tl_CxqJw`AIXhcsS$H7h}8KYMQU}QlX_yE`|9$9Nd)|u=qx{&ao zL<+JSkb0aQ$ey7`EH2?CP?{nz7r3#$xp}d6&UqQAaXBPDi3TBx1?TMUh{E#+eisp% za~#+gKYTuxA0IC6*C0Lt4~V)2!Z9&rG%g1tnB-hgRCCS{Y&Y50>2ri|9=u$88aZUK z7|%HvXx$*Qv~##DOc%ilXCU-Y$a09YKs(zRw_wE6pwO>

7vILk*vAofp%dpOsD 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 +#include +#include +#include +#include +#include +#include +#include +#include "axhttp.h" + +#define HTTP_VERSION "HTTP/1.1" + +static const char * index_file = "index.html"; +static const char * rfc1123_format = "%a, %d %b %Y %H:%M:%S GMT"; + +static int special_read(struct connstruct *cn, void *buf, size_t count); +static int special_write(struct connstruct *cn, + const char *buf, size_t count); +static void send_error(struct connstruct *cn, int err); +static int hexit(char c); +static void urldecode(char *buf); +static void buildactualfile(struct connstruct *cn); +static int sanitizefile(const char *buf); +static int sanitizehost(char *buf); +static int htaccess_check(struct connstruct *cn); +static const char *getmimetype(const char *name); + +#if defined(CONFIG_HTTP_DIRECTORIES) +static void urlencode(const uint8_t *s, char *t); +static void procdirlisting(struct connstruct *cn); +#endif +#if defined(CONFIG_HTTP_HAS_CGI) +static void proccgi(struct connstruct *cn); +static void decode_path_info(struct connstruct *cn, char *path_info); +static int init_read_post_data(char *buf, char *data, struct connstruct *cn, int old_rv); +#endif +#ifdef CONFIG_HTTP_HAS_AUTHORIZATION +static int auth_check(struct connstruct *cn); +#endif + +#if AXDEBUG +#define AXDEBUGSTART \ + { \ + FILE *axdout; \ + axdout = fopen("/var/log/axdebug", "a"); \ + +#define AXDEBUGEND \ + fclose(axdout); \ + } +#else /* AXDEBUG */ +#define AXDEBUGSTART +#define AXDEBUGEND +#endif /* AXDEBUG */ + +/* Returns 1 if elems should continue being read, 0 otherwise */ +static int procheadelem(struct connstruct *cn, char *buf) +{ + char *delim, *value; + + if ((delim = strchr(buf, ' ')) == NULL) + return 0; + + *delim = 0; + value = delim+1; + + if (strcmp(buf, "GET") == 0 || strcmp(buf, "HEAD") == 0 || + strcmp(buf, "POST") == 0) + { + if (buf[0] == 'H') + cn->reqtype = TYPE_HEAD; + else if (buf[0] == 'P') + cn->reqtype = TYPE_POST; + + if ((delim = strchr(value, ' ')) == NULL) /* expect HTTP type */ + return 0; + + *delim++ = 0; + urldecode(value); + + if (sanitizefile(value) == 0) + { + send_error(cn, 403); + return 0; + } + +#if defined(CONFIG_HTTP_HAS_CGI) + decode_path_info(cn, value); +#else + my_strncpy(cn->filereq, value, MAXREQUESTLENGTH); +#endif + cn->if_modified_since = -1; + if (strcmp(delim, "HTTP/1.0") == 0) /* v1.0 HTTP? */ + cn->is_v1_0 = 1; + } + else if (strcasecmp(buf, "Host:") == 0) + { + if (sanitizehost(value) == 0) + { + removeconnection(cn); + return 0; + } + + my_strncpy(cn->server_name, value, MAXREQUESTLENGTH); + } + else if (strcasecmp(buf, "Connection:") == 0 && strcmp(value, "close") == 0) + { + cn->close_when_done = 1; + } + else if (strcasecmp(buf, "If-Modified-Since:") == 0) + { + cn->if_modified_since = tdate_parse(value); + } + else if (strcasecmp(buf, "Expect:") == 0) + { + /* supposed to be safe to ignore 100-continue */ + if (strcasecmp(value, "100-continue") != 0) { + send_error(cn, 417); /* expectation failed */ + return 0; + } + } +#ifdef CONFIG_HTTP_HAS_AUTHORIZATION + else if (strcasecmp(buf, "Authorization:") == 0 && + strncmp(value, "Basic ", 6) == 0) + { + int size = sizeof(cn->authorization); + if (base64_decode(&value[6], strlen(&value[6]), + (uint8_t *)cn->authorization, &size)) + cn->authorization[0] = 0; /* error */ + else + cn->authorization[size] = 0; + } +#endif +#if defined(CONFIG_HTTP_HAS_CGI) + else if (strcasecmp(buf, "Content-Length:") == 0) + { + sscanf(value, "%d", &cn->content_length); + } + else if (strcasecmp(buf, "Content-Type:") == 0) + { + my_strncpy(cn->cgicontenttype, value, MAXREQUESTLENGTH); + } + else if (strcasecmp(buf, "Cookie:") == 0) + { + my_strncpy(cn->cookie, value, MAXREQUESTLENGTH); + } +#endif + + return 1; +} + +#if defined(CONFIG_HTTP_DIRECTORIES) +static void procdirlisting(struct connstruct *cn) +{ + char buf[MAXREQUESTLENGTH]; + char actualfile[1024]; + + if (cn->reqtype == TYPE_HEAD) + { + snprintf(buf, sizeof(buf), HTTP_VERSION + " 200 OK\nContent-Type: text/html\n\n"); + if (write(cn->networkdesc, buf, strlen(buf)) < 0) + { + printf("procdirlisting: could not write"); + TTY_FLUSH(); + } + + removeconnection(cn); + return; + } + + strcpy(actualfile, cn->actualfile); + +#ifdef WIN32 + strcat(actualfile, "*"); + cn->dirp = FindFirstFile(actualfile, &cn->file_data); + + if (cn->dirp == INVALID_HANDLE_VALUE) + { + send_error(cn, 404); + return; + } +#else + if ((cn->dirp = opendir(actualfile)) == NULL) + { + send_error(cn, 404); + return; + } +#endif + + snprintf(buf, sizeof(buf), HTTP_VERSION + " 200 OK\nContent-Type: text/html\n\n" + "\nDirectory Listing\n" + "

Directory listing of %s://%s%s


\n", + cn->is_ssl ? "https" : "http", cn->server_name, cn->filereq); + special_write(cn, buf, strlen(buf)); + cn->state = STATE_DOING_DIR; +} + +void procdodir(struct connstruct *cn) +{ +#ifndef WIN32 + struct dirent *dp; +#endif + char buf[MAXREQUESTLENGTH]; + char encbuf[1024]; + char *file; + + do + { + buf[0] = 0; + +#ifdef WIN32 + if (!FindNextFile(cn->dirp, &cn->file_data)) +#else + if ((dp = readdir(cn->dirp)) == NULL) +#endif + { + snprintf(buf, sizeof(buf), "\n"); + special_write(cn, buf, strlen(buf)); + removeconnection(cn); +#ifndef WIN32 + closedir(cn->dirp); +#endif + return; + } + +#ifdef WIN32 + file = cn->file_data.cFileName; +#else + file = dp->d_name; +#endif + + /* if no index file, don't display the ".." directory */ + if (cn->filereq[0] == '/' && cn->filereq[1] == '\0' && + strcmp(file, "..") == 0) + continue; + + /* don't display files beginning with "." */ + if (file[0] == '.' && file[1] != '.') + continue; + + /* make sure a '/' is at the end of a directory */ + if (cn->filereq[strlen(cn->filereq)-1] != '/') + strcat(cn->filereq, "/"); + + /* see if the dir + file is another directory */ + snprintf(buf, sizeof(buf), "%s%s", cn->actualfile, file); + if (isdir(buf)) + strcat(file, "/"); + + urlencode((uint8_t *)file, encbuf); + snprintf(buf, sizeof(buf), "
%s
\n", + cn->filereq, encbuf, file); + } while (special_write(cn, buf, strlen(buf))); +} + +/* Encode funny chars -> %xx in newly allocated storage */ +/* (preserves '/' !) */ +static void urlencode(const uint8_t *s, char *t) +{ + const uint8_t *p = s; + char *tp = t; + + for (; *p; p++) + { + if ((*p > 0x00 && *p < ',') || + (*p > '9' && *p < 'A') || + (*p > 'Z' && *p < '_') || + (*p > '_' && *p < 'a') || + (*p > 'z' && *p < 0xA1)) + { + sprintf((char *)tp, "%%%02X", *p); + tp += 3; + } + else + { + *tp = *p; + tp++; + } + } + + *tp='\0'; +} + +#endif + +void procreadhead(struct connstruct *cn) +{ + char buf[MAXREADLENGTH], *tp, *next; + int rv; + + memset(buf, 0, sizeof(buf)); + rv = special_read(cn, buf, sizeof(buf)-1); + if (rv <= 0) + { + if (rv < 0 || !cn->is_ssl) /* really dead? */ + removeconnection(cn); + return; + } + + buf[rv] = '\0'; + next = tp = buf; + +#ifdef CONFIG_HTTP_HAS_AUTHORIZATION + cn->authorization[0] = 0; +#endif + + /* Split up lines and send to procheadelem() */ + while (*next != '\0') + { + /* If we have a blank line, advance to next stage */ + if (*next == '\r' || *next == '\n') + { +#if defined(CONFIG_HTTP_HAS_CGI) + if (cn->reqtype == TYPE_POST && cn->content_length > 0) + { + if (init_read_post_data(buf, next, cn, rv) == 0) + return; + } +#endif + + buildactualfile(cn); + cn->state = STATE_WANT_TO_SEND_HEAD; + return; + } + + while (*next != '\r' && *next != '\n' && *next != '\0') + next++; + + if (*next == '\r') + { + *next = '\0'; + next += 2; + } + else if (*next == '\n') + *next++ = '\0'; + + if (procheadelem(cn, tp) == 0) + return; + + tp = next; + } +} + +/* In this function we assume that the file has been checked for + * maliciousness (".."s, etc) and has been decoded + */ +void procsendhead(struct connstruct *cn) +{ + char buf[MAXREQUESTLENGTH]; + struct stat stbuf; + time_t t_time; + struct tm *ptm; + char date[32]; + char last_modified[32]; + char expires[32]; + int file_exists; + + /* are we trying to access a file over the HTTP connection instead of a + * HTTPS connection? Or is this directory disabled? */ + if (htaccess_check(cn)) + { + send_error(cn, 403); + return; + } + +#ifdef CONFIG_HTTP_HAS_AUTHORIZATION + if (auth_check(cn)) /* see if there is a '.htpasswd' file */ + { +#ifdef CONFIG_HTTP_VERBOSE + printf("axhttpd: access to %s denied\n", cn->filereq); TTY_FLUSH(); +#endif + removeconnection(cn); + return; + } +#endif + + file_exists = stat(cn->actualfile, &stbuf); + +#if defined(CONFIG_HTTP_HAS_CGI) + if (file_exists != -1 && cn->is_cgi) + { + proccgi(cn); + return; + } +#endif + + /* look for "index.html"? */ + if (isdir(cn->actualfile)) + { + char tbuf[MAXREQUESTLENGTH]; + snprintf(tbuf, MAXREQUESTLENGTH, "%s%s", cn->actualfile, index_file); + + if ((file_exists = stat(tbuf, &stbuf)) != -1) + my_strncpy(cn->actualfile, tbuf, MAXREQUESTLENGTH); + else + { +#if defined(CONFIG_HTTP_DIRECTORIES) + /* If not, we do a directory listing of it */ + procdirlisting(cn); +#else + send_error(cn, 404); +#endif + return; + } + } + + if (file_exists == -1) + { + send_error(cn, 404); + return; + } + + + time(&t_time); + ptm = gmtime(&t_time); + strftime(date, sizeof(date), rfc1123_format, ptm); + + /* has the file been read before? */ + if (cn->if_modified_since != -1) + + { + ptm = gmtime(&stbuf.st_mtime); + t_time = mktime(ptm); + + if (cn->if_modified_since >= t_time) + { + snprintf(buf, sizeof(buf), HTTP_VERSION" 304 Not Modified\nServer: " + "%s\nDate: %s\n\n", server_version, date); + special_write(cn, buf, strlen(buf)); + cn->state = STATE_WANT_TO_READ_HEAD; + return; + } + } + + if (cn->reqtype == TYPE_HEAD) + { + removeconnection(cn); + return; + } + else + { + int flags = O_RDONLY; +#if defined(WIN32) || defined(CONFIG_PLATFORM_CYGWIN) + flags |= O_BINARY; +#endif + cn->filedesc = open(cn->actualfile, flags); + + if (cn->filedesc < 0) + { + send_error(cn, 404); + return; + } + + ptm = gmtime(&stbuf.st_mtime); + strftime(last_modified, sizeof(last_modified), rfc1123_format, ptm); + t_time += CONFIG_HTTP_TIMEOUT; + ptm = gmtime(&t_time); + strftime(expires, sizeof(expires), rfc1123_format, ptm); + + snprintf(buf, sizeof(buf), HTTP_VERSION" 200 OK\nServer: %s\n" + "Content-Type: %s\nContent-Length: %ld\n" + "Date: %s\nLast-Modified: %s\nExpires: %s\n\n", server_version, + getmimetype(cn->actualfile), (long) stbuf.st_size, + date, last_modified, expires); + + special_write(cn, buf, strlen(buf)); + +#ifdef CONFIG_HTTP_VERBOSE + printf("axhttpd: %s:/%s\n", cn->is_ssl ? "https" : "http", cn->filereq); + TTY_FLUSH(); +#endif + +#ifdef WIN32 + for (;;) + { + procreadfile(cn); + if (cn->filedesc == -1) + break; + + do + { + procsendfile(cn); + } while (cn->state != STATE_WANT_TO_READ_FILE); + } +#else + cn->state = STATE_WANT_TO_READ_FILE; +#endif + } +} + +void procreadfile(struct connstruct *cn) +{ + int rv = read(cn->filedesc, cn->databuf, BLOCKSIZE); + + if (rv <= 0) + { + close(cn->filedesc); + cn->filedesc = -1; + + if (cn->close_when_done) /* close immediately */ + removeconnection(cn); + else + { + if (cn->is_v1_0) /* die now */ + removeconnection(cn); + else /* keep socket open - HTTP 1.1 */ + { + cn->state = STATE_WANT_TO_READ_HEAD; + cn->numbytes = 0; + } + } + + return; + } + + cn->numbytes = rv; + cn->state = STATE_WANT_TO_SEND_FILE; +} + +void procsendfile(struct connstruct *cn) +{ + int rv = special_write(cn, cn->databuf, cn->numbytes); + + if (rv < 0) + removeconnection(cn); + else if (rv == cn->numbytes) + { + cn->state = STATE_WANT_TO_READ_FILE; + } + else if (rv == 0) + { + /* Do nothing */ + } + else + { + memmove(cn->databuf, cn->databuf + rv, cn->numbytes - rv); + cn->numbytes -= rv; + } +} + +#if defined(CONFIG_HTTP_HAS_CGI) +/* Should this be a bit more dynamic? It would mean more calls to malloc etc */ +#define CGI_ARG_SIZE 17 + +static void proccgi(struct connstruct *cn) +{ + int tpipe[2], spipe[2]; + char *myargs[3]; + char cgienv[CGI_ARG_SIZE][MAXREQUESTLENGTH]; + char * cgiptr[CGI_ARG_SIZE+4]; + const char *type = "HEAD"; + int cgi_index = 0, i; + pid_t pid; +#ifdef WIN32 + int tmp_stdout; +#endif + + snprintf(cgienv[0], MAXREQUESTLENGTH, + HTTP_VERSION" 200 OK\nServer: %s\n%s", + server_version, (cn->reqtype == TYPE_HEAD) ? "\n" : ""); + special_write(cn, cgienv[0], strlen(cgienv[0])); + + if (cn->reqtype == TYPE_HEAD) + { + removeconnection(cn); + return; + } + +#ifdef CONFIG_HTTP_VERBOSE + printf("[CGI]: %s:/%s\n", cn->is_ssl ? "https" : "http", cn->filereq); + TTY_FLUSH(); +#endif + + /* win32 cgi is a bit too painful */ +#ifndef WIN32 + /* set up pipe that is used for sending POST query data to CGI script*/ + if (cn->reqtype == TYPE_POST) + { + if (pipe(spipe) == -1) + { + printf("[CGI]: could not create pipe"); + TTY_FLUSH(); + return; + } + } + + if (pipe(tpipe) == -1) + { + printf("[CGI]: could not create pipe"); + TTY_FLUSH(); + return; + } + + /* + * use vfork() instead of fork() for performance + */ + if ((pid = vfork()) > 0) /* parent */ + { + /* Send POST query data to CGI script */ + if ((cn->reqtype == TYPE_POST) && (cn->content_length > 0)) + { + if (write(spipe[1], cn->post_data, cn->content_length) == -1) + { + printf("[CGI]: could write to pipe"); + TTY_FLUSH(); + return; + } + + close(spipe[0]); + close(spipe[1]); + + /* free the memory that is allocated in read_post_data() */ + free(cn->post_data); + cn->post_data = NULL; + } + + /* Close the write descriptor */ + close(tpipe[1]); + cn->filedesc = tpipe[0]; + cn->state = STATE_WANT_TO_READ_FILE; + cn->close_when_done = 1; + return; + } + + if (pid < 0) /* vfork failed */ + exit(1); + + /* The problem child... */ + + /* Our stdout/stderr goes to the socket */ + dup2(tpipe[1], 1); + dup2(tpipe[1], 2); + close(tpipe[0]); + close(tpipe[1]); + + /* If it was a POST request, send the socket data to our stdin */ + if (cn->reqtype == TYPE_POST) { + dup2(spipe[0], 0); + close(spipe[0]); + close(spipe[1]); + } else /* Otherwise we can shutdown the read side of the sock */ + shutdown(cn->networkdesc, 0); + + myargs[0] = CONFIG_HTTP_CGI_LAUNCHER; + myargs[1] = cn->actualfile; + myargs[2] = NULL; + + /* + * set the cgi args. A url is defined by: + * http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO?$QUERY_STRING + * TODO: other CGI parameters? + */ + sprintf(cgienv[cgi_index++], "SERVER_SOFTWARE=%s", server_version); + strcpy(cgienv[cgi_index++], "DOCUMENT_ROOT=" CONFIG_HTTP_WEBROOT); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "SERVER_NAME=%s", cn->server_name); + sprintf(cgienv[cgi_index++], "SERVER_PORT=%d", + cn->is_ssl ? CONFIG_HTTP_HTTPS_PORT : CONFIG_HTTP_PORT); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "REQUEST_URI=%s", cn->uri_request); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "SCRIPT_NAME=%s", cn->filereq); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "PATH_INFO=%s", cn->uri_path_info); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "QUERY_STRING=%s", cn->uri_query); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "REMOTE_ADDR=%s", cn->remote_addr); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "HTTP_COOKIE=%s", cn->cookie); /* note: small size */ +#if defined(CONFIG_HTTP_HAS_AUTHORIZATION) + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "REMOTE_USER=%s", cn->authorization); +#endif + + switch (cn->reqtype) + { + case TYPE_GET: + type = "GET"; + break; + +#if defined(CONFIG_HTTP_HAS_CGI) + case TYPE_POST: + type = "POST"; + sprintf(cgienv[cgi_index++], + "CONTENT_LENGTH=%d", cn->content_length); + snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, + "CONTENT_TYPE=%s", cn->cgicontenttype); + break; +#endif + } + + sprintf(cgienv[cgi_index++], "REQUEST_METHOD=%s", type); + + if (cn->is_ssl) + strcpy(cgienv[cgi_index++], "HTTPS=on"); + + if (cgi_index >= CGI_ARG_SIZE) + { + printf("Content-type: text/plain\n\nToo many CGI args (%d, %d)\n", + cgi_index, CGI_ARG_SIZE); + _exit(1); + } + + /* copy across the pointer indexes */ + for (i = 0; i < cgi_index; i++) + cgiptr[i] = cgienv[i]; + + cgiptr[i++] = "AUTH_TYPE=Basic"; + cgiptr[i++] = "GATEWAY_INTERFACE=CGI/1.1"; + cgiptr[i++] = "SERVER_PROTOCOL="HTTP_VERSION; + cgiptr[i] = NULL; + + execve(myargs[0], myargs, cgiptr); + printf("Content-type: text/plain\n\nshouldn't get here\n"); + _exit(1); +#endif +} + +static char * cgi_filetype_match(struct connstruct *cn, const char *fn) +{ + struct cgiextstruct *tp = cgiexts; + + while (tp != NULL) + { + char *t; + + if ((t = strstr(fn, tp->ext)) != NULL) + { + t += strlen(tp->ext); + + if (*t == '/' || *t == '\0') + return t; + else + return NULL; + + } + + tp = tp->next; + } + + return NULL; +} + +static void decode_path_info(struct connstruct *cn, char *path_info) +{ + char *cgi_delim; + +#if defined(CONFIG_HTTP_HAS_CGI) + cn->is_cgi = 0; +#endif + *cn->uri_request = '\0'; + *cn->uri_path_info = '\0'; + *cn->uri_query = '\0'; + + my_strncpy(cn->uri_request, path_info, MAXREQUESTLENGTH); + + /* query info? */ + if ((cgi_delim = strchr(path_info, '?'))) + { + *cgi_delim = '\0'; + my_strncpy(cn->uri_query, cgi_delim+1, MAXREQUESTLENGTH); + } + +#if defined(CONFIG_HTTP_HAS_CGI) + if ((cgi_delim = cgi_filetype_match(cn, path_info)) != NULL) + { + cn->is_cgi = 1; /* definitely a CGI script */ + + /* path info? */ + if (*cgi_delim != '\0') + { + my_strncpy(cn->uri_path_info, cgi_delim, MAXREQUESTLENGTH); + *cgi_delim = '\0'; + } + } +#endif + + /* the bit at the start must be the script name */ + my_strncpy(cn->filereq, path_info, MAXREQUESTLENGTH); +} + +static int init_read_post_data(char *buf, char *data, + struct connstruct *cn, int old_rv) +{ + char *next = data; + int rv = old_rv; + char *post_data; + + /* Too much Post data to send. MAXPOSTDATASIZE should be + configured (now it can be changed in the header file) */ + if (cn->content_length > MAXPOSTDATASIZE) + { + send_error(cn, 418); + return 0; + } + + /* remove CRLF */ + while ((*next == '\r' || *next == '\n') && (next < &buf[rv])) + next++; + + if (cn->post_data == NULL) + { + /* Allocate buffer for the POST data that will be used by proccgi + to send POST data to the CGI script */ + cn->post_data = (char *)calloc(1, (cn->content_length + 1)); + } + + cn->post_state = 0; + cn->post_read = 0; + post_data = cn->post_data; + + while (next < &buf[rv]) + { + /* copy POST data to buffer */ + *post_data++ = *next++; + cn->post_read++; + if (cn->post_read == cn->content_length) + { + /* No more POST data to be copied */ + *post_data = '\0'; + return 1; + } + } + + /* More POST data has to be read. read_post_data will continue with that */ + cn->post_state = 1; + return 0; +} + +void read_post_data(struct connstruct *cn) +{ + char buf[MAXREADLENGTH], *next; + char *post_data; + int rv; + + memset(buf, 0, sizeof(buf)); + rv = special_read(cn, buf, sizeof(buf)-1); + if (rv <= 0) + { + if (rv < 0 || !cn->is_ssl) /* really dead? */ + removeconnection(cn); + return; + } + + buf[rv] = '\0'; + next = buf; + post_data = &cn->post_data[cn->post_read]; + + while (next < &buf[rv]) + { + *post_data++ = *next++; + cn->post_read++; + + if (cn->post_read == cn->content_length) + { + /* No more POST data to be copied */ + *post_data='\0'; + cn->post_state = 0; + buildactualfile(cn); + cn->state = STATE_WANT_TO_SEND_HEAD; + return; + } + } + + /* More POST data to read */ +} + +#endif /* CONFIG_HTTP_HAS_CGI */ + +/* Decode string %xx -> char (in place) */ +static void urldecode(char *buf) +{ + int v; + char *p, *s, *w; + + w = p = buf; + + while (*p) + { + v = 0; + + if (*p == '%') + { + s = p; + s++; + + if (isxdigit((int) s[0]) && isxdigit((int) s[1])) + { + v = hexit(s[0])*16 + hexit(s[1]); + + if (v) + { + /* do not decode %00 to null char */ + *w = (char)v; + p = &s[1]; + } + } + + } + + if (!v) *w=*p; + p++; + w++; + } + + *w='\0'; +} + +static int hexit(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + else if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + else + return 0; +} + +static void buildactualfile(struct connstruct *cn) +{ + char *cp; + snprintf(cn->actualfile, MAXREQUESTLENGTH, ".%s", cn->filereq); + +#ifndef WIN32 + /* Add directory slash if not there */ + if (isdir(cn->actualfile) && + cn->actualfile[strlen(cn->actualfile)-1] != '/') + strcat(cn->actualfile, "/"); + + /* work out the directory name */ + strncpy(cn->dirname, cn->actualfile, MAXREQUESTLENGTH); + if ((cp = strrchr(cn->dirname, '/')) == NULL) + cn->dirname[0] = 0; + else + *cp = 0; +#else + { + char curr_dir[MAXREQUESTLENGTH]; + char path[MAXREQUESTLENGTH]; + char *t = cn->actualfile; + + GetCurrentDirectory(MAXREQUESTLENGTH, curr_dir); + + /* convert all the forward slashes to back slashes */ + while ((t = strchr(t, '/'))) + *t++ = '\\'; + + snprintf(path, MAXREQUESTLENGTH, "%s%s", curr_dir, cn->actualfile); + memcpy(cn->actualfile, path, MAXREQUESTLENGTH); + + /* Add directory slash if not there */ + if (isdir(cn->actualfile) && + cn->actualfile[strlen(cn->actualfile)-1] != '\\') + strcat(cn->actualfile, "\\"); + + /* work out the directory name */ + strncpy(cn->dirname, cn->actualfile, MAXREQUESTLENGTH); + if ((cp = strrchr(cn->dirname, '\\')) == NULL) + cn->dirname[0] = 0; + else + *cp = 0; + } +#endif +} + +static int sanitizefile(const char *buf) +{ + int len, i; + + /* Don't accept anything not starting with a / */ + if (*buf != '/') + return 0; + + len = strlen(buf); + for (i = 0; i < len; i++) + { + /* Check for "/." i.e. don't send files starting with a . */ + if (buf[i] == '/' && buf[i+1] == '.') + return 0; + } + + return 1; +} + +static int sanitizehost(char *buf) +{ + while (*buf != '\0') + { + /* Handle the port */ + if (*buf == ':') + { + *buf = '\0'; + return 1; + } + + /* Enforce some basic URL rules... */ + if ((isalnum((int)(*buf)) == 0 && *buf != '-' && *buf != '.') || + (*buf == '.' && *(buf+1) == '.') || + (*buf == '.' && *(buf+1) == '-') || + (*buf == '-' && *(buf+1) == '.')) + return 0; + + buf++; + } + + return 1; +} + +static FILE * exist_check(struct connstruct *cn, const char *check_file) +{ + char pathname[MAXREQUESTLENGTH]; + snprintf(pathname, MAXREQUESTLENGTH, "%s/%s", cn->dirname, check_file); + return fopen(pathname, "r"); +} + +#ifdef CONFIG_HTTP_HAS_AUTHORIZATION +static void send_authenticate(struct connstruct *cn, const char *realm) +{ + char buf[1024]; + + snprintf(buf, sizeof(buf), HTTP_VERSION" 401 Unauthorized\n" + "WWW-Authenticate: Basic\n" + "realm=\"%s\"\n", realm); + special_write(cn, buf, strlen(buf)); +} + +static int check_digest(char *salt, const char *msg_passwd) +{ + uint8_t b256_salt[MAXREQUESTLENGTH]; + uint8_t real_passwd[MD5_SIZE]; + int salt_size = sizeof(b256_salt); + int password_size = sizeof(real_passwd); + char *b64_passwd; + uint8_t md5_result[MD5_SIZE]; + MD5_CTX ctx; + + /* retrieve the salt */ + if ((b64_passwd = strchr(salt, '$')) == NULL) + return -1; + + *b64_passwd++ = 0; + if (base64_decode(salt, strlen(salt), b256_salt, &salt_size)) + return -1; + + if (base64_decode(b64_passwd, strlen(b64_passwd), real_passwd, + &password_size)) + return -1; + + /* very simple MD5 crypt algorithm, but then the salt we use is large */ + MD5_Init(&ctx); + MD5_Update(&ctx, b256_salt, salt_size); /* process the salt */ + MD5_Update(&ctx, (uint8_t *)msg_passwd, strlen(msg_passwd)); + MD5_Final(md5_result, &ctx); + return memcmp(md5_result, real_passwd, MD5_SIZE);/* 0 = ok */ +} + +static int auth_check(struct connstruct *cn) +{ + char line[MAXREQUESTLENGTH]; + FILE *fp; + char *cp; + + if ((fp = exist_check(cn, ".htpasswd")) == NULL) + return 0; /* no .htpasswd file, so let though */ + + if (cn->authorization[0] == 0) + goto error; + + /* cn->authorization is in form "username:password" */ + if ((cp = strchr(cn->authorization, ':')) == NULL) + goto error; + else + *cp++ = 0; /* cp becomes the password */ + + while (fgets(line, sizeof(line), fp) != NULL) + { + char *b64_file_passwd; + int l = strlen(line); + + /* nuke newline */ + if (line[l-1] == '\n') + line[l-1] = 0; + + /* line is form "username:salt(b64)$password(b64)" */ + if ((b64_file_passwd = strchr(line, ':')) == NULL) + continue; + + *b64_file_passwd++ = 0; + + if (strcmp(line, cn->authorization)) /* our user? */ + continue; + + if (check_digest(b64_file_passwd, cp) == 0) + { + fclose(fp); + return 0; + } + } + +error: + fclose(fp); + send_authenticate(cn, cn->server_name); + return -1; +} +#endif + +static int htaccess_check(struct connstruct *cn) +{ + char line[MAXREQUESTLENGTH]; + FILE *fp; + int ret = 0; + + if ((fp = exist_check(cn, ".htaccess")) == NULL) + return 0; /* no .htaccess file, so let though */ + + while (fgets(line, sizeof(line), fp) != NULL) + { + if (strstr(line, "Deny all") || /* access to this dir denied */ + /* Access will be denied unless SSL is active */ + (!cn->is_ssl && strstr(line, "SSLRequireSSL")) || + /* Access will be denied if SSL is active */ + (cn->is_ssl && strstr(line, "SSLDenySSL"))) + { + ret = -1; + break; + } + } + + fclose(fp); + return ret; +} + +static void send_error(struct connstruct *cn, int err) +{ + char buf[MAXREQUESTLENGTH]; + char *title; + char *text; + + switch (err) + { + case 403: + title = "Forbidden"; + text = "File is protected"; +#ifdef CONFIG_HTTP_VERBOSE + printf("axhttpd: access to %s denied\n", cn->filereq); TTY_FLUSH(); +#endif + break; + + case 404: + title = "Not Found"; + text = title; + break; + + case 418: + title = "POST data size is too large"; + text = title; + break; + + default: + title = "Unknown"; + text = "Unknown"; + break; + } + + snprintf(buf, sizeof(buf), HTTP_VERSION" 200 OK\n" + "Content-Type: text/html\n\n" + "\n%s\n" + "

Error %d - %s

\n\n", + title, err, text); + special_write(cn, buf, strlen(buf)); + +#ifdef CONFIG_HTTP_VERBOSE + printf("axhttpd: http error: %s [%d]\n", title, err); TTY_FLUSH(); +#endif + removeconnection(cn); +} + +static const char *getmimetype(const char *name) +{ + /* only bother with a few mime types - let the browser figure the rest out */ + if (strstr(name, ".htm")) + return "text/html"; + else if (strstr(name, ".css")) + return "text/css"; + else if (strstr(name, ".php")) + return "application/x-http-php"; + else + return "application/octet-stream"; +} + +static int special_write(struct connstruct *cn, + const char *buf, size_t count) +{ + if (cn->is_ssl) + { + SSL *ssl = cn->ssl; + return ssl ? ssl_write(ssl, (uint8_t *)buf, count) : -1; + } + else + return SOCKET_WRITE(cn->networkdesc, buf, count); +} + +static int special_read(struct connstruct *cn, void *buf, size_t count) +{ + int res; + + if (cn->is_ssl) + { + uint8_t *read_buf; + if ((res = ssl_read(cn->ssl, &read_buf)) > SSL_OK) + { + memcpy(buf, read_buf, res > (int)count ? count : res); + } + } + else + res = SOCKET_READ(cn->networkdesc, buf, count); + + return res; +} + diff --git a/user/mpy/lib/axtls/httpd/tdate_parse.c b/user/mpy/lib/axtls/httpd/tdate_parse.c new file mode 100644 index 0000000..7165bde --- /dev/null +++ b/user/mpy/lib/axtls/httpd/tdate_parse.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include "axhttp.h" + +struct day_mon_map +{ + const char* s; + uint8_t l; +}; + +static struct day_mon_map wday_tab[] = +{ + { "Sun", 0 }, { "Mon", 1 }, { "Tue", 2 }, { "Wed", 3 }, + { "Thu", 4 }, { "Fri", 5 }, { "Sat", 6 }, +}; + +static struct day_mon_map mon_tab[] = +{ + { "Jan", 0 }, { "Feb", 1 }, { "Mar", 2 }, { "Apr", 3 }, + { "May", 4 }, { "Jun", 5 }, { "Jul", 6 }, { "Aug", 7 }, + { "Sep", 8 }, { "Oct", 9 }, { "Nov", 10 }, { "Dec", 11 }, +}; + +static int day_mon_map_compare(const char *v1, const char *v2) +{ + return strcmp(((struct day_mon_map*)v1)->s, ((struct day_mon_map*)v2)->s); +} + +void tdate_init(void) +{ + qsort(wday_tab, sizeof(wday_tab)/sizeof(struct day_mon_map), + sizeof(struct day_mon_map), + (int (*)(const void *, const void *))day_mon_map_compare); + qsort(mon_tab, sizeof(mon_tab)/sizeof(struct day_mon_map), + sizeof(struct day_mon_map), + (int (*)(const void *, const void *))day_mon_map_compare); +} + +static int8_t day_mon_map_search(const char* str, + const struct day_mon_map* tab, int n) +{ + struct day_mon_map *search = bsearch(&str, tab, n, + sizeof(struct day_mon_map), + (int (*)(const void *, const void *))day_mon_map_compare); + return search ? search->l : -1; +} + +time_t tdate_parse(const char* str) +{ + struct tm tm; + char str_mon[4], str_wday[4]; + int tm_sec, tm_min, tm_hour, tm_mday, tm_year; + + /* Initialize. */ + memset(&tm, 0, sizeof(struct tm)); + + /* wdy, DD mth YY HH:MM:SS GMT */ + if (sscanf(str, "%3[a-zA-Z], %d %3[a-zA-Z] %d %d:%d:%d GMT", + str_wday, &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, + &tm_sec) == 7) + { + int8_t tm_wday = day_mon_map_search(str_wday, wday_tab, + sizeof(wday_tab)/sizeof(struct day_mon_map)); + int8_t tm_mon = day_mon_map_search(str_mon, mon_tab, + sizeof(mon_tab)/sizeof(struct day_mon_map)); + + if (tm_wday < 0 || tm_mon < 0) + return -1; + + tm.tm_wday = tm_wday; + tm.tm_mon = tm_mon; + tm.tm_mday = tm_mday; + tm.tm_hour = tm_hour; + tm.tm_min = tm_min; + tm.tm_sec = tm_sec; + tm.tm_year = tm_year - 1900; + return mktime(&tm); + } + + return -1; /* error */ +} diff --git a/user/mpy/lib/axtls/samples/Config.in b/user/mpy/lib/axtls/samples/Config.in new file mode 100644 index 0000000..ecad25e --- /dev/null +++ b/user/mpy/lib/axtls/samples/Config.in @@ -0,0 +1,63 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/config/Kconfig-language.txt +# +menu "Samples" + +config CONFIG_SAMPLES + bool "Create Samples" + default y + help + axTLS contains various sample code. + + Select Y here if you want to build the various samples. + +config CONFIG_C_SAMPLES + bool "axssl - C version" + default y + depends on CONFIG_SAMPLES + help + Build the "C" version of axssl. The features enabled are very + dependent on the build mode ('full' mode will give all features). + +config CONFIG_CSHARP_SAMPLES + bool "axssl - C# version" + default y + depends on CONFIG_SAMPLES && CONFIG_CSHARP_BINDINGS + help + Build the "C#" version of axssl. The features enabled are very + dependent on the build mode ('full' mode will give all features). + +config CONFIG_VBNET_SAMPLES + bool "axssl - VB.NET version" + default y + depends on CONFIG_SAMPLES && CONFIG_VBNET_BINDINGS + help + Build the "VB.NET" version of axssl. The features enabled are very + dependent on the build mode ('full' mode will give all features). + +config CONFIG_JAVA_SAMPLES + bool "axssl - Java version" + default y + depends on CONFIG_SAMPLES && CONFIG_JAVA_BINDINGS + help + Build the "Java" version of axssl. The features enabled are very + dependent on the build mode ('full' mode will give all features). + +config CONFIG_PERL_SAMPLES + bool "axssl - Perl version" + default y + depends on CONFIG_SAMPLES && CONFIG_PERL_BINDINGS + help + Build the "Perl" version of axssl. The features enabled are very + dependent on the build mode ('full' mode will give all features). + +config CONFIG_LUA_SAMPLES + bool "axssl - Lua version" + default y + depends on CONFIG_SAMPLES && CONFIG_LUA_BINDINGS + help + Build the "Lua" version of axssl. The features enabled are very + dependent on the build mode ('full' mode will give all features). +endmenu + diff --git a/user/mpy/lib/axtls/samples/Makefile b/user/mpy/lib/axtls/samples/Makefile new file mode 100644 index 0000000..afbdd43 --- /dev/null +++ b/user/mpy/lib/axtls/samples/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +all: + +include ../config/.config +include ../config/makefile.conf + +all: +ifdef CONFIG_C_SAMPLES + $(MAKE) -C c +endif +ifdef CONFIG_CSHARP_SAMPLES + $(MAKE) -C csharp +endif +ifdef CONFIG_VBNET_SAMPLES + $(MAKE) -C vbnet +endif +ifdef CONFIG_JAVA_SAMPLES + $(MAKE) -C java +endif +ifdef CONFIG_PERL_SAMPLES + $(MAKE) -C perl +endif +ifdef CONFIG_LUA_SAMPLES + $(MAKE) -C lua +endif + +clean:: + $(MAKE) -C c clean + $(MAKE) -C csharp clean + $(MAKE) -C vbnet clean + $(MAKE) -C java clean + $(MAKE) -C perl clean + $(MAKE) -C lua clean diff --git a/user/mpy/lib/axtls/samples/c/Makefile b/user/mpy/lib/axtls/samples/c/Makefile new file mode 100644 index 0000000..1966eec --- /dev/null +++ b/user/mpy/lib/axtls/samples/c/Makefile @@ -0,0 +1,77 @@ +# +# Copyright (c) 2007-2016, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +all : sample + +AXTLS_HOME=../.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +ifndef CONFIG_PLATFORM_WIN32 + +ifdef CONFIG_PLATFORM_CYGWIN +TARGET=$(AXTLS_HOME)/$(STAGE)/axssl.exe +else +TARGET=$(AXTLS_HOME)/$(STAGE)/axssl +endif # cygwin + +LIBS=$(AXTLS_HOME)/$(STAGE) +else +TARGET=$(AXTLS_HOME)/$(STAGE)/axssl.exe +endif + +ifndef CONFIG_C_SAMPLES +sample: + +else +sample : $(TARGET) +OBJ= axssl.o +include $(AXTLS_HOME)/config/makefile.post + +ifndef CONFIG_PLATFORM_WIN32 + +$(TARGET): $(OBJ) $(LIBS)/libaxtls.a + $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)/libaxtls.a +# $(LD) $(LDFLAGS) -o $@ $(OBJ) -L$(LIBS) -laxtls (shared library) +ifdef CONFIG_STRIP_UNWANTED_SECTIONS + $(STRIP) --remove-section=.comment $(TARGET) +endif # use strip +else # Win32 + +$(TARGET): $(OBJ) + $(LD) $(LDFLAGS) $(AXTLS_HOME)/config/axtls.res /out:$@ $^ /libpath:"$(AXTLS_HOME)/$(STAGE)" axtls.lib +endif + +endif # CONFIG_C_SAMPLES + +clean:: + -@rm -f $(AXTLS_HOME)/$(STAGE)/axssl* + diff --git a/user/mpy/lib/axtls/samples/c/axssl.c b/user/mpy/lib/axtls/samples/c/axssl.c new file mode 100644 index 0000000..8de9d60 --- /dev/null +++ b/user/mpy/lib/axtls/samples/c/axssl.c @@ -0,0 +1,904 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Demonstrate the use of the axTLS library in C with a set of + * command-line parameters similar to openssl. In fact, openssl clients + * should be able to communicate with axTLS servers and visa-versa. + * + * This code has various bits enabled depending on the configuration. To enable + * the most interesting version, compile with the 'full mode' enabled. + * + * To see what options you have, run the following: + * > axssl s_server -? + * > axssl s_client -? + * + * The axtls shared library must be in the same directory or be found + * by the OS. + */ +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +/* define standard input */ +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + +static void do_server(int argc, char *argv[]); +static void print_options(char *option); +static void print_server_options(char *option); +static void do_client(int argc, char *argv[]); +static void print_client_options(char *option); +static void display_cipher(SSL *ssl); +static void display_session_id(SSL *ssl); + +/** + * Main entry point. Doesn't do much except works out whether we are a client + * or a server. + */ +int main(int argc, char *argv[]) +{ +#ifdef WIN32 + WSADATA wsaData; + WORD wVersionRequested = MAKEWORD(2, 2); + WSAStartup(wVersionRequested, &wsaData); +#elif !defined(CONFIG_PLATFORM_SOLARIS) + signal(SIGPIPE, SIG_IGN); /* ignore pipe errors */ +#endif + + if (argc == 2 && strcmp(argv[1], "version") == 0) + { + printf("axssl %s %s\n", ssl_version(), __DATE__); + exit(0); + } + + if (argc < 2 || ( + strcmp(argv[1], "s_server") && strcmp(argv[1], "s_client"))) + print_options(argc > 1 ? argv[1] : ""); + +// strcmp(argv[1], "s_server") ? + do_client(argc, argv);// : do_server(argc, argv); + return 0; +} + +/** + * Implement the SSL server logic. + */ +static void do_server(int argc, char *argv[]) +{ + int i = 2; + uint16_t port = 4433; + uint32_t options = SSL_DISPLAY_CERTS; + int client_fd; + SSL_CTX *ssl_ctx; + int server_fd, res = 0; + socklen_t client_len; +#ifndef CONFIG_SSL_SKELETON_MODE + char *private_key_file = NULL; + const char *password = NULL; + char **cert; + int cert_index = 0; + int cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); +#endif +#ifdef WIN32 + char yes = 1; +#else + int yes = 1; +#endif + struct sockaddr_in serv_addr; + struct sockaddr_in client_addr; + int quiet = 0; +#ifdef CONFIG_SSL_CERT_VERIFICATION + int ca_cert_index = 0; + int ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); + char **ca_cert = (char **)calloc(1, sizeof(char *)*ca_cert_size); +#endif + fd_set read_set; + +#ifndef CONFIG_SSL_SKELETON_MODE + cert = (char **)calloc(1, sizeof(char *)*cert_size); +#endif + + while (i < argc) + { + if (strcmp(argv[i], "-accept") == 0) + { + if (i >= argc-1) + { + print_server_options(argv[i]); + } + + port = atoi(argv[++i]); + } +#ifndef CONFIG_SSL_SKELETON_MODE + else if (strcmp(argv[i], "-cert") == 0) + { + if (i >= argc-1 || cert_index >= cert_size) + { + print_server_options(argv[i]); + } + + cert[cert_index++] = argv[++i]; + } + else if (strcmp(argv[i], "-key") == 0) + { + if (i >= argc-1) + { + print_server_options(argv[i]); + } + + private_key_file = argv[++i]; + options |= SSL_NO_DEFAULT_KEY; + } + else if (strcmp(argv[i], "-pass") == 0) + { + if (i >= argc-1) + { + print_server_options(argv[i]); + } + + password = argv[++i]; + } +#endif + else if (strcmp(argv[i], "-quiet") == 0) + { + quiet = 1; + options &= ~SSL_DISPLAY_CERTS; + } +#ifdef CONFIG_SSL_CERT_VERIFICATION + else if (strcmp(argv[i], "-verify") == 0) + { + options |= SSL_CLIENT_AUTHENTICATION; + } + else if (strcmp(argv[i], "-CAfile") == 0) + { + if (i >= argc-1 || ca_cert_index >= ca_cert_size) + { + print_server_options(argv[i]); + } + + ca_cert[ca_cert_index++] = argv[++i]; + } +#endif +#ifdef CONFIG_SSL_FULL_MODE + else if (strcmp(argv[i], "-debug") == 0) + { + options |= SSL_DISPLAY_BYTES; + } + else if (strcmp(argv[i], "-state") == 0) + { + options |= SSL_DISPLAY_STATES; + } + else if (strcmp(argv[i], "-show-rsa") == 0) + { + options |= SSL_DISPLAY_RSA; + } +#endif + else /* don't know what this is */ + { + print_server_options(argv[i]); + } + + i++; + } + + if ((ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_SVR_SESS)) == NULL) + { + fprintf(stderr, "Error: Server context is invalid\n"); + exit(1); + } + +#ifndef CONFIG_SSL_SKELETON_MODE + if (private_key_file) + { + int obj_type = SSL_OBJ_RSA_KEY; + + /* auto-detect the key type from the file extension */ + if (strstr(private_key_file, ".p8")) + obj_type = SSL_OBJ_PKCS8; + else if (strstr(private_key_file, ".p12")) + obj_type = SSL_OBJ_PKCS12; + + if (ssl_obj_load(ssl_ctx, obj_type, private_key_file, password)) + { + fprintf(stderr, "Error: Private key '%s' is undefined.\n", + private_key_file); + exit(1); + } + } + + for (i = 0; i < cert_index; i++) + { + if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, cert[i], NULL)) + { + printf("Certificate '%s' is undefined.\n", cert[i]); + exit(1); + } + } +#endif + +#ifdef CONFIG_SSL_CERT_VERIFICATION + for (i = 0; i < ca_cert_index; i++) + { + if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, ca_cert[i], NULL)) + { + printf("Certificate '%s' is undefined.\n", ca_cert[i]); + exit(1); + } + } + + free(ca_cert); +#endif +#ifndef CONFIG_SSL_SKELETON_MODE + free(cert); +#endif + + /* Create socket for incoming connections */ + if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) + { + perror("socket"); + return; + } + + setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); + + /* Construct local address structure */ + memset(&serv_addr, 0, sizeof(serv_addr)); /* Zero out structure */ + serv_addr.sin_family = AF_INET; /* Internet address family */ + serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */ + serv_addr.sin_port = htons(port); /* Local port */ + + /* Bind to the local address */ + if (bind(server_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) + { + perror("bind"); + exit(1); + } + + if (listen(server_fd, 5) < 0) + { + perror("listen"); + exit(1); + } + + client_len = sizeof(client_addr); + + /************************************************************************* + * This is where the interesting stuff happens. Up until now we've + * just been setting up sockets etc. Now we do the SSL handshake. + *************************************************************************/ + for (;;) + { + SSL *ssl; + int reconnected = 0; + + if (!quiet) + { + printf("ACCEPT\n"); + TTY_FLUSH(); + } + + if ((client_fd = accept(server_fd, + (struct sockaddr *)&client_addr, &client_len)) < 0) + { + break; + } + + ssl = ssl_server_new(ssl_ctx, client_fd); + + /* now read (and display) whatever the client sends us */ + for (;;) + { + /* allow parallel reading of client and standard input */ + FD_ZERO(&read_set); + FD_SET(client_fd, &read_set); + +#ifndef WIN32 + /* win32 doesn't like mixing up stdin and sockets */ + if (isatty(STDIN_FILENO))/* but only if we are in an active shell */ + { + FD_SET(STDIN_FILENO, &read_set); + } + + if ((res = select(client_fd+1, &read_set, NULL, NULL, NULL)) > 0) + { + uint8_t buf[1024]; + + /* read standard input? */ + if (FD_ISSET(STDIN_FILENO, &read_set)) + { + if (fgets((char *)buf, sizeof(buf), stdin) == NULL) + { + res = SSL_ERROR_CONN_LOST; + } + else + { + /* small hack to check renegotiation */ + if (buf[0] == 'r' && (buf[1] == '\n' || buf[1] == '\r')) + { + res = ssl_renegotiate(ssl); + } + else /* write our ramblings to the client */ + { + res = ssl_write(ssl, buf, strlen((char *)buf)+1); + } + } + } + else /* a socket read */ +#endif + { + /* keep reading until we get something interesting */ + uint8_t *read_buf; + + if ((res = ssl_read(ssl, &read_buf)) == SSL_OK) + { + /* are we in the middle of doing a handshake? */ + if (ssl_handshake_status(ssl) != SSL_OK) + { + reconnected = 0; + } + else if (!reconnected) + { + /* we are connected/reconnected */ + if (!quiet) + { + display_session_id(ssl); + display_cipher(ssl); + } + + reconnected = 1; + } + } + + if (res > SSL_OK) /* display our interesting output */ + { + int written = 0; + while (written < res) + { + written += write(STDOUT_FILENO, read_buf+written, + res-written); + } + TTY_FLUSH(); + } + else if (res == SSL_CLOSE_NOTIFY) + { + printf("shutting down SSL\n"); + TTY_FLUSH(); + } + else if (res < SSL_OK && !quiet) + { + ssl_display_error(res); + } + } +#ifndef WIN32 + } +#endif + + if (res < SSL_OK) + { + if (!quiet) + { + printf("CONNECTION CLOSED\n"); + TTY_FLUSH(); + } + + break; + } + } + + /* client was disconnected or the handshake failed. */ + ssl_free(ssl); + SOCKET_CLOSE(client_fd); + } + + ssl_ctx_free(ssl_ctx); +} + +/** + * Implement the SSL client logic. + */ +static void do_client(int argc, char *argv[]) +{ +#ifdef CONFIG_SSL_ENABLE_CLIENT + int res, i = 2; + uint16_t port = 4433; + uint32_t options = SSL_SERVER_VERIFY_LATER|SSL_DISPLAY_CERTS; + int client_fd; + char *private_key_file = NULL; + struct sockaddr_in client_addr; + struct hostent *hostent; + int reconnect = 0; + uint32_t sin_addr; + SSL_CTX *ssl_ctx; + SSL *ssl = NULL; + int quiet = 0; + int cert_index = 0, ca_cert_index = 0; + int cert_size, ca_cert_size; + char **ca_cert, **cert; + uint8_t session_id[SSL_SESSION_ID_SIZE]; + fd_set read_set; + const char *password = NULL; + SSL_EXTENSIONS *extensions = NULL; + + FD_ZERO(&read_set); + sin_addr = inet_addr("127.0.0.1"); + cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); + ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); + ca_cert = (char **)calloc(1, sizeof(char *)*ca_cert_size); + cert = (char **)calloc(1, sizeof(char *)*cert_size); + + while (i < argc) + { + if (strcmp(argv[i], "-connect") == 0) + { + char *host, *ptr; + + if (i >= argc-1) + { + print_client_options(argv[i]); + } + + host = argv[++i]; + if ((ptr = strchr(host, ':')) == NULL) + { + print_client_options(argv[i]); + } + + *ptr++ = 0; + port = atoi(ptr); + hostent = gethostbyname(host); + + if (hostent == NULL) + { + print_client_options(argv[i]); + } + + sin_addr = *((uint32_t **)hostent->h_addr_list)[0]; + } + else if (strcmp(argv[i], "-cert") == 0) + { + if (i >= argc-1 || cert_index >= cert_size) + { + print_client_options(argv[i]); + } + + cert[cert_index++] = argv[++i]; + } + else if (strcmp(argv[i], "-key") == 0) + { + if (i >= argc-1) + { + print_client_options(argv[i]); + } + + private_key_file = argv[++i]; + options |= SSL_NO_DEFAULT_KEY; + } + else if (strcmp(argv[i], "-CAfile") == 0) + { + if (i >= argc-1 || ca_cert_index >= ca_cert_size) + { + print_client_options(argv[i]); + } + + ca_cert[ca_cert_index++] = argv[++i]; + } + else if (strcmp(argv[i], "-verify") == 0) + { + options &= ~SSL_SERVER_VERIFY_LATER; + } + else if (strcmp(argv[i], "-reconnect") == 0) + { + reconnect = 4; + } + else if (strcmp(argv[i], "-quiet") == 0) + { + quiet = 1; + options &= ~SSL_DISPLAY_CERTS; + } + else if (strcmp(argv[i], "-pass") == 0) + { + if (i >= argc-1) + { + print_client_options(argv[i]); + } + + password = argv[++i]; + } + else if (strcmp(argv[i], "-servername") == 0) + { + if (i >= argc-1) + { + print_client_options(argv[i]); + } + + extensions = ssl_ext_new(); + extensions->host_name = argv[++i]; + } +#ifdef CONFIG_SSL_FULL_MODE + else if (strcmp(argv[i], "-debug") == 0) + { + options |= SSL_DISPLAY_BYTES; + } + else if (strcmp(argv[i], "-state") == 0) + { + options |= SSL_DISPLAY_STATES; + } + else if (strcmp(argv[i], "-show-rsa") == 0) + { + options |= SSL_DISPLAY_RSA; + } +#endif + else /* don't know what this is */ + { + print_client_options(argv[i]); + } + + i++; + } + + if ((ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_CLNT_SESS)) == NULL) + { + fprintf(stderr, "Error: Client context is invalid\n"); + exit(1); + } + +#ifndef CONFIG_SSL_SKELETON_MODE + if (private_key_file) + { + int obj_type = SSL_OBJ_RSA_KEY; + + /* auto-detect the key type from the file extension */ + if (strstr(private_key_file, ".p8")) + obj_type = SSL_OBJ_PKCS8; + else if (strstr(private_key_file, ".p12")) + obj_type = SSL_OBJ_PKCS12; + + if (ssl_obj_load(ssl_ctx, obj_type, private_key_file, password)) + { + fprintf(stderr, "Error: Private key '%s' is undefined.\n", + private_key_file); + exit(1); + } + } + + for (i = 0; i < cert_index; i++) + { + if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, cert[i], NULL)) + { + printf("Certificate '%s' is undefined.\n", cert[i]); + exit(1); + } + } + + for (i = 0; i < ca_cert_index; i++) + { + if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, ca_cert[i], NULL)) + { + printf("Certificate '%s' is undefined.\n", ca_cert[i]); + exit(1); + } + } +#endif + + free(cert); + free(ca_cert); + + /************************************************************************* + * This is where the interesting stuff happens. Up until now we've + * just been setting up sockets etc. Now we do the SSL handshake. + *************************************************************************/ + client_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + memset(&client_addr, 0, sizeof(client_addr)); + client_addr.sin_family = AF_INET; + client_addr.sin_port = htons(port); + client_addr.sin_addr.s_addr = sin_addr; + + if (connect(client_fd, (struct sockaddr *)&client_addr, + sizeof(client_addr)) < 0) + { + perror("connect"); + exit(1); + } + + if (!quiet) + { + printf("CONNECTED\n"); + TTY_FLUSH(); + } + + /* Try session resumption? */ + if (reconnect) + { + while (reconnect--) + { + ssl = ssl_client_new(ssl_ctx, client_fd, session_id, + sizeof(session_id), extensions); + if ((res = ssl_handshake_status(ssl)) != SSL_OK) + { + if (!quiet) + { + ssl_display_error(res); + } + + ssl_free(ssl); + exit(1); + } + + display_session_id(ssl); + memcpy(session_id, ssl_get_session_id(ssl), SSL_SESSION_ID_SIZE); + + if (reconnect) + { + ssl_free(ssl); + SOCKET_CLOSE(client_fd); + + client_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + connect(client_fd, (struct sockaddr *)&client_addr, + sizeof(client_addr)); + } + } + } + else + { + ssl = ssl_client_new(ssl_ctx, client_fd, NULL, 0, extensions); + } + + /* check the return status */ + if ((res = ssl_handshake_status(ssl)) != SSL_OK) + { + if (!quiet) + { + ssl_display_error(res); + } + + exit(1); + } + + if (!quiet) + { + display_session_id(ssl); + display_cipher(ssl); + } + + for (;;) + { + uint8_t buf[1024]; + + /* allow parallel reading of server and standard input */ + FD_SET(client_fd, &read_set); +#ifndef WIN32 + /* win32 doesn't like mixing up stdin and sockets */ + FD_SET(STDIN_FILENO, &read_set); + + if ((res = select(client_fd+1, &read_set, NULL, NULL, NULL)) > 0) + { + /* read standard input? */ + if (FD_ISSET(STDIN_FILENO, &read_set)) +#endif + { + if (fgets((char *)buf, sizeof(buf), stdin) == NULL) + { + /* bomb out of here */ + ssl_free(ssl); + break; + } + else + { + /* small hack to check renegotiation */ + if (buf[0] == 'R' && (buf[1] == '\n' || buf[1] == '\r')) + { + res = ssl_renegotiate(ssl); + } + else + { + res = ssl_write(ssl, buf, strlen((char *)buf)); + } + } + } +#ifndef WIN32 + else /* a socket read */ + { + uint8_t *read_buf; + + res = ssl_read(ssl, &read_buf); + + if (res > 0) /* display our interesting output */ + { + int written = 0; + while (written < res) + { + written += write(STDOUT_FILENO, read_buf+written, + res-written); + } + TTY_FLUSH(); + } + } + } +#endif + + if (res < 0) + { + if (!quiet) + { + ssl_display_error(res); + } + + break; /* get outta here */ + } + } + + ssl_ctx_free(ssl_ctx); + SOCKET_CLOSE(client_fd); +#else + print_client_options(argv[1]); +#endif +} + +/** + * We've had some sort of command-line error. Print out the basic options. + */ +static void print_options(char *option) +{ + printf("axssl: Error: '%s' is an invalid command.\n", option); + printf("usage: axssl [s_server|s_client|version] [args ...]\n"); + exit(1); +} + +/** + * We've had some sort of command-line error. Print out the server options. + */ +static void print_server_options(char *option) +{ +#ifndef CONFIG_SSL_SKELETON_MODE + int cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); +#endif +#ifdef CONFIG_SSL_CERT_VERIFICATION + int ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); +#endif + + printf("unknown option %s\n", option); + printf("usage: s_server [args ...]\n"); + printf(" -accept arg\t- port to accept on (default is 4433)\n"); +#ifndef CONFIG_SSL_SKELETON_MODE + printf(" -cert arg\t- certificate file to add (in addition to default)" + " to chain -\n" + "\t\t Can repeat up to %d times\n", cert_size); + printf(" -key arg\t- Private key file to use\n"); + printf(" -pass\t\t- private key file pass phrase source\n"); +#endif + printf(" -quiet\t\t- No server output\n"); +#ifdef CONFIG_SSL_CERT_VERIFICATION + printf(" -verify\t- turn on peer certificate verification\n"); + printf(" -CAfile arg\t- Certificate authority\n"); + printf("\t\t Can repeat up to %d times\n", ca_cert_size); +#endif +#ifdef CONFIG_SSL_FULL_MODE + printf(" -debug\t\t- Print more output\n"); + printf(" -state\t\t- Show state messages\n"); + printf(" -show-rsa\t- Show RSA state\n"); +#endif + exit(1); +} + +/** + * We've had some sort of command-line error. Print out the client options. + */ +static void print_client_options(char *option) +{ +#ifdef CONFIG_SSL_ENABLE_CLIENT + int cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); + int ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); +#endif + + printf("unknown option %s\n", option); +#ifdef CONFIG_SSL_ENABLE_CLIENT + printf("usage: s_client [args ...]\n"); + printf(" -connect host:port - who to connect to (default " + "is localhost:4433)\n"); + printf(" -verify\t- turn on peer certificate verification\n"); + printf(" -cert arg\t- certificate file to use\n"); + printf("\t\t Can repeat up to %d times\n", cert_size); + printf(" -key arg\t- Private key file to use\n"); + printf(" -CAfile arg\t- Certificate authority\n"); + printf("\t\t Can repeat up to %d times\n", ca_cert_size); + printf(" -quiet\t\t- No client output\n"); + printf(" -reconnect\t- Drop and re-make the connection " + "with the same Session-ID\n"); + printf(" -pass\t\t- Private key file pass phrase source\n"); + printf(" -servername\t- Set TLS extension servername in ClientHello\n"); +#ifdef CONFIG_SSL_FULL_MODE + printf(" -debug\t\t- Print more output\n"); + printf(" -state\t\t- Show state messages\n"); + printf(" -show-rsa\t- Show RSA state\n"); +#endif +#else + printf("Change configuration to allow this feature\n"); +#endif + exit(1); +} + +/** + * Display what cipher we are using + */ +static void display_cipher(SSL *ssl) +{ + printf("CIPHER is "); + switch (ssl_get_cipher_id(ssl)) + { + case SSL_AES128_SHA: + printf("AES128-SHA"); + break; + + case SSL_AES256_SHA: + printf("AES256-SHA"); + break; + + case SSL_AES128_SHA256: + printf("AES128-SHA256"); + break; + + case SSL_AES256_SHA256: + printf("AES256-SHA256"); + break; + + default: + printf("Unknown - %d", ssl_get_cipher_id(ssl)); + break; + } + + printf("\n"); + TTY_FLUSH(); +} + +/** + * Display what session id we have. + */ +static void display_session_id(SSL *ssl) +{ + int i; + const uint8_t *session_id = ssl_get_session_id(ssl); + int sess_id_size = ssl_get_session_id_size(ssl); + + if (sess_id_size > 0) + { + printf("-----BEGIN SSL SESSION PARAMETERS-----\n"); + for (i = 0; i < sess_id_size; i++) + { + printf("%02x", session_id[i]); + } + + printf("\n-----END SSL SESSION PARAMETERS-----\n"); + TTY_FLUSH(); + } +} diff --git a/user/mpy/lib/axtls/samples/csharp/Makefile b/user/mpy/lib/axtls/samples/csharp/Makefile new file mode 100644 index 0000000..46c2421 --- /dev/null +++ b/user/mpy/lib/axtls/samples/csharp/Makefile @@ -0,0 +1,48 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf +include ../../config/makefile.dotnet.conf + +all : sample +TARGET=../../$(STAGE)/axssl.csharp.exe +sample : $(TARGET) + +$(TARGET): ../../bindings/csharp/axTLS.cs ../../bindings/csharp/axInterface.cs axssl.cs +ifdef GO_DOT_NET + csc.exe /nologo /t:exe /out:"`cygpath -w $@`" $(foreach file, $^, "`cygpath -w $(file)`") +else # use mono to build + mcs -out:$@ $^ + +endif # ARCH + +clean:: + -@rm -f $(TARGET) diff --git a/user/mpy/lib/axtls/samples/csharp/axssl.cs b/user/mpy/lib/axtls/samples/csharp/axssl.cs new file mode 100644 index 0000000..df3c576 --- /dev/null +++ b/user/mpy/lib/axtls/samples/csharp/axssl.cs @@ -0,0 +1,758 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Demonstrate the use of the axTLS library in C# with a set of + * command-line parameters similar to openssl. In fact, openssl clients + * should be able to communicate with axTLS servers and visa-versa. + * + * This code has various bits enabled depending on the configuration. To enable + * the most interesting version, compile with the 'full mode' enabled. + * + * To see what options you have, run the following: + * > axssl.csharp.exe s_server -? + * > axssl.csharp.exe s_client -? + * + * The axtls shared library must be in the same directory or be found + * by the OS. + */ + +using System; +using System.Net; +using System.Net.Sockets; +using axTLS; + +public class axssl +{ + /* + * Main() + */ + public static void Main(string[] args) + { + if (args.Length == 1 && args[0] == "version") + { + Console.WriteLine("axssl.csharp " + SSLUtil.Version()); + Environment.Exit(0); + } + + axssl runner = new axssl(); + + if (args.Length < 1 || (args[0] != "s_server" && args[0] != "s_client")) + runner.print_options(args.Length > 0 ? args[0] : ""); + + int build_mode = SSLUtil.BuildMode(); + + if (args[0] == "s_server") + runner.do_server(build_mode, args); + else + runner.do_client(build_mode, args); + } + + /* + * do_server() + */ + private void do_server(int build_mode, string[] args) + { + int i = 1; + int port = 4433; + uint options = axtls.SSL_DISPLAY_CERTS; + bool quiet = false; + string password = null; + string private_key_file = null; + + /* organise the cert/ca_cert lists */ + int cert_size = SSLUtil.MaxCerts(); + int ca_cert_size = SSLUtil.MaxCACerts(); + string[] cert = new string[cert_size]; + string[] ca_cert = new string[ca_cert_size]; + int cert_index = 0; + int ca_cert_index = 0; + + while (i < args.Length) + { + if (args[i] == "-accept") + { + if (i >= args.Length-1) + { + print_server_options(build_mode, args[i]); + } + + port = Int32.Parse(args[++i]); + } + else if (args[i] == "-quiet") + { + quiet = true; + options &= ~(uint)axtls.SSL_DISPLAY_CERTS; + } + else if (build_mode >= axtls.SSL_BUILD_SERVER_ONLY) + { + if (args[i] == "-cert") + { + if (i >= args.Length-1 || cert_index >= cert_size) + { + print_server_options(build_mode, args[i]); + } + + cert[cert_index++] = args[++i]; + } + else if (args[i] == "-key") + { + if (i >= args.Length-1) + { + print_server_options(build_mode, args[i]); + } + + private_key_file = args[++i]; + options |= axtls.SSL_NO_DEFAULT_KEY; + } + else if (args[i] == "-pass") + { + if (i >= args.Length-1) + { + print_server_options(build_mode, args[i]); + } + + password = args[++i]; + } + else if (build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION) + { + if (args[i] == "-verify") + { + options |= axtls.SSL_CLIENT_AUTHENTICATION; + } + else if (args[i] == "-CAfile") + { + if (i >= args.Length-1 || ca_cert_index >= ca_cert_size) + { + print_server_options(build_mode, args[i]); + } + + ca_cert[ca_cert_index++] = args[++i]; + } + else if (build_mode == axtls.SSL_BUILD_FULL_MODE) + { + if (args[i] == "-debug") + { + options |= axtls.SSL_DISPLAY_BYTES; + } + else if (args[i] == "-state") + { + options |= axtls.SSL_DISPLAY_STATES; + } + else if (args[i] == "-show-rsa") + { + options |= axtls.SSL_DISPLAY_RSA; + } + else + print_server_options(build_mode, args[i]); + } + else + print_server_options(build_mode, args[i]); + } + else + print_server_options(build_mode, args[i]); + } + else + print_server_options(build_mode, args[i]); + + i++; + } + + /* Create socket for incoming connections */ + IPEndPoint ep = new IPEndPoint(IPAddress.Any, port); + TcpListener server_sock = new TcpListener(ep); + server_sock.Start(); + + /********************************************************************** + * This is where the interesting stuff happens. Up until now we've + * just been setting up sockets etc. Now we do the SSL handshake. + **********************************************************************/ + SSLServer ssl_ctx = new SSLServer( + options, axtls.SSL_DEFAULT_SVR_SESS); + + if (ssl_ctx == null) + { + Console.Error.WriteLine("Error: Server context is invalid"); + Environment.Exit(1); + } + + if (private_key_file != null) + { + int obj_type = axtls.SSL_OBJ_RSA_KEY; + + if (private_key_file.EndsWith(".p8")) + obj_type = axtls.SSL_OBJ_PKCS8; + else if (private_key_file.EndsWith(".p12")) + obj_type = axtls.SSL_OBJ_PKCS12; + + if (ssl_ctx.ObjLoad(obj_type, + private_key_file, password) != axtls.SSL_OK) + { + Console.Error.WriteLine("Private key '" + private_key_file + + "' is undefined."); + Environment.Exit(1); + } + } + + for (i = 0; i < cert_index; i++) + { + if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, + cert[i], null) != axtls.SSL_OK) + { + Console.WriteLine("Certificate '" + cert[i] + + "' is undefined."); + Environment.Exit(1); + } + } + + for (i = 0; i < ca_cert_index; i++) + { + if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, + ca_cert[i], null) != axtls.SSL_OK) + { + Console.WriteLine("Certificate '" + cert[i] + + "' is undefined."); + Environment.Exit(1); + } + } + + byte[] buf = null; + int res; + + for (;;) + { + if (!quiet) + { + Console.WriteLine("ACCEPT"); + } + + Socket client_sock = server_sock.AcceptSocket(); + + SSL ssl = ssl_ctx.Connect(client_sock); + + /* do the actual SSL handshake */ + while ((res = ssl_ctx.Read(ssl, out buf)) == axtls.SSL_OK) + { + /* check when the connection has been established */ + if (ssl.HandshakeStatus() == axtls.SSL_OK) + break; + + /* could do something else here */ + } + + if (res == axtls.SSL_OK) /* connection established and ok */ + { + if (!quiet) + { + display_session_id(ssl); + display_cipher(ssl); + } + + /* now read (and display) whatever the client sends us */ + for (;;) + { + /* keep reading until we get something interesting */ + while ((res = ssl_ctx.Read(ssl, out buf)) == axtls.SSL_OK) + { + /* could do something else here */ + } + + if (res < axtls.SSL_OK) + { + if (!quiet) + { + Console.WriteLine("CONNECTION CLOSED"); + } + + break; + } + + /* convert to string */ + char[] str = new char[res]; + for (i = 0; i < res; i++) + { + str[i] = (char)buf[i]; + } + + Console.Write(str); + } + } + else if (!quiet) + { + SSLUtil.DisplayError(res); + } + + /* client was disconnected or the handshake failed. */ + ssl.Dispose(); + client_sock.Close(); + } + + /* ssl_ctx.Dispose(); */ + } + + /* + * do_client() + */ + private void do_client(int build_mode, string[] args) + { + if (build_mode < axtls.SSL_BUILD_ENABLE_CLIENT) + { + print_client_options(build_mode, args[1]); + } + + int i = 1, res; + int port = 4433; + bool quiet = false; + string password = null; + int reconnect = 0; + string private_key_file = null; + string hostname = "127.0.0.1"; + + /* organise the cert/ca_cert lists */ + int cert_index = 0; + int ca_cert_index = 0; + int cert_size = SSLUtil.MaxCerts(); + int ca_cert_size = SSLUtil.MaxCACerts(); + string[] cert = new string[cert_size]; + string[] ca_cert = new string[ca_cert_size]; + + uint options = axtls.SSL_SERVER_VERIFY_LATER|axtls.SSL_DISPLAY_CERTS; + byte[] session_id = null; + + while (i < args.Length) + { + if (args[i] == "-connect") + { + string host_port; + + if (i >= args.Length-1) + { + print_client_options(build_mode, args[i]); + } + + host_port = args[++i]; + int index_colon; + + if ((index_colon = host_port.IndexOf(':')) < 0) + print_client_options(build_mode, args[i]); + + hostname = new string(host_port.ToCharArray(), + 0, index_colon); + port = Int32.Parse(new String(host_port.ToCharArray(), + index_colon+1, host_port.Length-index_colon-1)); + } + else if (args[i] == "-cert") + { + if (i >= args.Length-1 || cert_index >= cert_size) + { + print_client_options(build_mode, args[i]); + } + + cert[cert_index++] = args[++i]; + } + else if (args[i] == "-key") + { + if (i >= args.Length-1) + { + print_client_options(build_mode, args[i]); + } + + private_key_file = args[++i]; + options |= axtls.SSL_NO_DEFAULT_KEY; + } + else if (args[i] == "-CAfile") + { + if (i >= args.Length-1 || ca_cert_index >= ca_cert_size) + { + print_client_options(build_mode, args[i]); + } + + ca_cert[ca_cert_index++] = args[++i]; + } + else if (args[i] == "-verify") + { + options &= ~(uint)axtls.SSL_SERVER_VERIFY_LATER; + } + else if (args[i] == "-reconnect") + { + reconnect = 4; + } + else if (args[i] == "-quiet") + { + quiet = true; + options &= ~(uint)axtls.SSL_DISPLAY_CERTS; + } + else if (args[i] == "-pass") + { + if (i >= args.Length-1) + { + print_client_options(build_mode, args[i]); + } + + password = args[++i]; + } + else if (build_mode == axtls.SSL_BUILD_FULL_MODE) + { + if (args[i] == "-debug") + { + options |= axtls.SSL_DISPLAY_BYTES; + } + else if (args[i] == "-state") + { + options |= axtls.SSL_DISPLAY_STATES; + } + else if (args[i] == "-show-rsa") + { + options |= axtls.SSL_DISPLAY_RSA; + } + else + print_client_options(build_mode, args[i]); + } + else /* don't know what this is */ + print_client_options(build_mode, args[i]); + + i++; + } + + // IPHostEntry hostInfo = Dns.Resolve(hostname); + IPHostEntry hostInfo = Dns.GetHostEntry(hostname); + IPAddress[] addresses = hostInfo.AddressList; + IPEndPoint ep = new IPEndPoint(addresses[0], port); + Socket client_sock = new Socket(AddressFamily.InterNetwork, + SocketType.Stream, ProtocolType.Tcp); + client_sock.Connect(ep); + + if (!client_sock.Connected) + { + Console.WriteLine("could not connect"); + Environment.Exit(1); + } + + if (!quiet) + { + Console.WriteLine("CONNECTED"); + } + + /********************************************************************** + * This is where the interesting stuff happens. Up until now we've + * just been setting up sockets etc. Now we do the SSL handshake. + **********************************************************************/ + SSLClient ssl_ctx = new SSLClient(options, + axtls.SSL_DEFAULT_CLNT_SESS); + + if (ssl_ctx == null) + { + Console.Error.WriteLine("Error: Client context is invalid"); + Environment.Exit(1); + } + + if (private_key_file != null) + { + int obj_type = axtls.SSL_OBJ_RSA_KEY; + + if (private_key_file.EndsWith(".p8")) + obj_type = axtls.SSL_OBJ_PKCS8; + else if (private_key_file.EndsWith(".p12")) + obj_type = axtls.SSL_OBJ_PKCS12; + + if (ssl_ctx.ObjLoad(obj_type, + private_key_file, password) != axtls.SSL_OK) + { + Console.Error.WriteLine("Private key '" + private_key_file + + "' is undefined."); + Environment.Exit(1); + } + } + + for (i = 0; i < cert_index; i++) + { + if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, + cert[i], null) != axtls.SSL_OK) + { + Console.WriteLine("Certificate '" + cert[i] + + "' is undefined."); + Environment.Exit(1); + } + } + + for (i = 0; i < ca_cert_index; i++) + { + if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, + ca_cert[i], null) != axtls.SSL_OK) + { + Console.WriteLine("Certificate '" + cert[i] + + "' is undefined."); + Environment.Exit(1); + } + } + + SSL ssl = new SSL(new IntPtr(0)); /* keep compiler happy */ + + /* Try session resumption? */ + if (reconnect > 0) + { + while (reconnect-- > 0) + { + ssl = ssl_ctx.Connect(client_sock, session_id); + + if ((res = ssl.HandshakeStatus()) != axtls.SSL_OK) + { + if (!quiet) + { + SSLUtil.DisplayError(res); + } + + ssl.Dispose(); + Environment.Exit(1); + } + + display_session_id(ssl); + session_id = ssl.GetSessionId(); + + if (reconnect > 0) + { + ssl.Dispose(); + client_sock.Close(); + + /* and reconnect */ + client_sock = new Socket(AddressFamily.InterNetwork, + SocketType.Stream, ProtocolType.Tcp); + client_sock.Connect(ep); + } + } + } + else + { + ssl = ssl_ctx.Connect(client_sock, null); + } + + /* check the return status */ + if ((res = ssl.HandshakeStatus()) != axtls.SSL_OK) + { + if (!quiet) + { + SSLUtil.DisplayError(res); + } + + Environment.Exit(1); + } + + if (!quiet) + { + string common_name = + ssl.GetCertificateDN(axtls.SSL_X509_CERT_COMMON_NAME); + + if (common_name != null) + { + Console.WriteLine("Common Name:\t\t\t" + common_name); + } + + display_session_id(ssl); + display_cipher(ssl); + } + + for (;;) + { + string user_input = Console.ReadLine(); + + if (user_input == null) + break; + + byte[] buf = new byte[user_input.Length+2]; + buf[buf.Length-2] = (byte)'\n'; /* add the carriage return */ + buf[buf.Length-1] = 0; /* null terminate */ + + for (i = 0; i < buf.Length-2; i++) + { + buf[i] = (byte)user_input[i]; + } + + if ((res = ssl_ctx.Write(ssl, buf, buf.Length)) < axtls.SSL_OK) + { + if (!quiet) + { + SSLUtil.DisplayError(res); + } + + break; + } + } + + ssl_ctx.Dispose(); + } + + /** + * We've had some sort of command-line error. Print out the basic options. + */ + private void print_options(string option) + { + Console.WriteLine("axssl: Error: '" + option + + "' is an invalid command."); + Console.WriteLine("usage: axssl.csharp [s_server|" + + "s_client|version] [args ...]"); + Environment.Exit(1); + } + + /** + * We've had some sort of command-line error. Print out the server options. + */ + private void print_server_options(int build_mode, string option) + { + int cert_size = SSLUtil.MaxCerts(); + int ca_cert_size = SSLUtil.MaxCACerts(); + + Console.WriteLine("unknown option " + option); + Console.WriteLine("usage: s_server [args ...]"); + Console.WriteLine(" -accept arg\t- port to accept on (default " + + "is 4433)"); + Console.WriteLine(" -quiet\t\t- No server output"); + + if (build_mode >= axtls.SSL_BUILD_SERVER_ONLY) + { + Console.WriteLine(" -cert arg\t- certificate file to add (in " + + "addition to default) to chain -"); + Console.WriteLine("\t\t Can repeat up to " + cert_size + " times"); + Console.WriteLine(" -key arg\t- Private key file to use"); + Console.WriteLine(" -pass\t\t- private key file pass phrase source"); + } + + if (build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION) + { + Console.WriteLine(" -verify\t- turn on peer certificate " + + "verification"); + Console.WriteLine(" -CAfile arg\t- Certificate authority."); + Console.WriteLine("\t\t Can repeat up to " + + ca_cert_size + "times"); + } + + if (build_mode == axtls.SSL_BUILD_FULL_MODE) + { + Console.WriteLine(" -debug\t\t- Print more output"); + Console.WriteLine(" -state\t\t- Show state messages"); + Console.WriteLine(" -show-rsa\t- Show RSA state"); + } + + Environment.Exit(1); + } + + /** + * We've had some sort of command-line error. Print out the client options. + */ + private void print_client_options(int build_mode, string option) + { + int cert_size = SSLUtil.MaxCerts(); + int ca_cert_size = SSLUtil.MaxCACerts(); + + Console.WriteLine("unknown option " + option); + + if (build_mode >= axtls.SSL_BUILD_ENABLE_CLIENT) + { + Console.WriteLine("usage: s_client [args ...]"); + Console.WriteLine(" -connect host:port - who to connect to " + + "(default is localhost:4433)"); + Console.WriteLine(" -verify\t- turn on peer certificate " + + "verification"); + Console.WriteLine(" -cert arg\t- certificate file to use"); + Console.WriteLine("\t\t Can repeat up to %d times", cert_size); + Console.WriteLine(" -key arg\t- Private key file to use"); + Console.WriteLine(" -CAfile arg\t- Certificate authority."); + Console.WriteLine("\t\t Can repeat up to " + ca_cert_size + + " times"); + Console.WriteLine(" -quiet\t\t- No client output"); + Console.WriteLine(" -pass\t\t- private key file pass " + + "phrase source"); + Console.WriteLine(" -reconnect\t- Drop and re-make the " + + "connection with the same Session-ID"); + + if (build_mode == axtls.SSL_BUILD_FULL_MODE) + { + Console.WriteLine(" -debug\t\t- Print more output"); + Console.WriteLine(" -state\t\t- Show state messages"); + Console.WriteLine(" -show-rsa\t- Show RSA state"); + } + } + else + { + Console.WriteLine("Change configuration to allow this feature"); + } + + Environment.Exit(1); + } + + /** + * Display what cipher we are using + */ + private void display_cipher(SSL ssl) + { + Console.Write("CIPHER is "); + + switch (ssl.GetCipherId()) + { + case axtls.SSL_AES128_SHA: + Console.WriteLine("AES128-SHA"); + break; + + case axtls.SSL_AES256_SHA: + Console.WriteLine("AES256-SHA"); + break; + + case axtls.SSL_AES128_SHA256: + Console.WriteLine("AES128-SHA256"); + break; + + case axtls.SSL_AES256_SHA256: + Console.WriteLine("AES128-SHA256"); + break; + + default: + Console.WriteLine("Unknown - " + ssl.GetCipherId()); + break; + } + } + + /** + * Display what session id we have. + */ + private void display_session_id(SSL ssl) + { + byte[] session_id = ssl.GetSessionId(); + + if (session_id.Length > 0) + { + Console.WriteLine("-----BEGIN SSL SESSION PARAMETERS-----"); + foreach (byte b in session_id) + { + Console.Write("{0:x02}", b); + } + + Console.WriteLine("\n-----END SSL SESSION PARAMETERS-----"); + } + } +} diff --git a/user/mpy/lib/axtls/samples/java/Makefile b/user/mpy/lib/axtls/samples/java/Makefile new file mode 100644 index 0000000..9c1ed6d --- /dev/null +++ b/user/mpy/lib/axtls/samples/java/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (c) 2007-2016, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf +include ../../config/makefile.java.conf + +all : sample +JAR=../../$(STAGE)/axtls.jar +CLASSES=../../bindings/java/classes +sample : $(JAR) + +$(JAR) : $(CLASSES)/axssl.class $(wildcard $(CLASSES)/axTLSj/*.class) + jar mcvf manifest.mf $@ -C $(CLASSES) axTLSj -C $(CLASSES) axssl.class + +JAVA_FILES=axssl.java +JAVA_CLASSES:=$(JAVA_FILES:%.java=$(CLASSES)/axTLSj/%.class) + +$(CLASSES)/%.class : %.java + javac -d $(CLASSES) -classpath $(CLASSES) $^ + +clean:: + -@rm -f $(TARGET) + diff --git a/user/mpy/lib/axtls/samples/java/axssl.java b/user/mpy/lib/axtls/samples/java/axssl.java new file mode 100644 index 0000000..e013c11 --- /dev/null +++ b/user/mpy/lib/axtls/samples/java/axssl.java @@ -0,0 +1,760 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Demonstrate the use of the axTLS library in Java with a set of + * command-line parameters similar to openssl. In fact, openssl clients + * should be able to communicate with axTLS servers and visa-versa. * + * This code has various bits enabled depending on the configuration. To enable + * the most interesting version, compile with the 'full mode' enabled. + * + * To see what options you have, run the following: + * > java -jar axtls.jar s_server -? + * > java -jar axtls.jar s_client -? + * + * The axtls/axtlsj shared libraries must be in the same directory or be found + * by the OS. + */ + +import java.io.*; +import java.util.*; +import java.net.*; +import axTLSj.*; + +public class axssl +{ + /* + * Main() + */ + public static void main(String[] args) + { + if (args.length == 1 && args[0].equals("version")) + { + System.out.println("axtls.jar " + SSLUtil.version()); + System.exit(0); + } + + axssl runner = new axssl(); + + try + { + if (args.length < 1 || + (!args[0].equals("s_server") && + !args[0].equals("s_client"))) + { + runner.print_options(args.length > 0 ? args[0] : ""); + } + + int build_mode = SSLUtil.buildMode(); + + if (args[0].equals("s_server")) + runner.do_server(build_mode, args); + else + runner.do_client(build_mode, args); + } + catch (Exception e) + { + System.out.println(e); + } + } + + /* + * do_server() + */ + private void do_server(int build_mode, String[] args) + throws Exception + { + int i = 1; + int port = 4433; + int options = axtlsj.SSL_DISPLAY_CERTS; + boolean quiet = false; + String password = null; + String private_key_file = null; + + /* organise the cert/ca_cert lists */ + int cert_size = SSLUtil.maxCerts(); + int ca_cert_size = SSLUtil.maxCACerts(); + String[] cert = new String[cert_size]; + String[] ca_cert = new String[ca_cert_size]; + int cert_index = 0; + int ca_cert_index = 0; + + while (i < args.length) + { + if (args[i].equals("-accept")) + { + if (i >= args.length-1) + { + print_server_options(build_mode, args[i]); + } + + port = Integer.parseInt(args[++i]); + } + else if (args[i].equals("-quiet")) + { + quiet = true; + options &= ~(int)axtlsj.SSL_DISPLAY_CERTS; + } + else if (build_mode >= axtlsj.SSL_BUILD_SERVER_ONLY) + { + if (args[i].equals("-cert")) + { + if (i >= args.length-1 || cert_index >= cert_size) + { + print_server_options(build_mode, args[i]); + } + + cert[cert_index++] = args[++i]; + } + else if (args[i].equals("-key")) + { + if (i >= args.length-1) + { + print_server_options(build_mode, args[i]); + } + + private_key_file = args[++i]; + options |= axtlsj.SSL_NO_DEFAULT_KEY; + } + else if (args[i].equals("-pass")) + { + if (i >= args.length-1) + { + print_server_options(build_mode, args[i]); + } + + password = args[++i]; + } + else if (build_mode >= axtlsj.SSL_BUILD_ENABLE_VERIFICATION) + { + if (args[i].equals("-verify")) + { + options |= axtlsj.SSL_CLIENT_AUTHENTICATION; + } + else if (args[i].equals("-CAfile")) + { + if (i >= args.length-1 || ca_cert_index >= ca_cert_size) + { + print_server_options(build_mode, args[i]); + } + + ca_cert[ca_cert_index++] = args[++i]; + } + else if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) + { + if (args[i].equals("-debug")) + { + options |= axtlsj.SSL_DISPLAY_BYTES; + } + else if (args[i].equals("-state")) + { + options |= axtlsj.SSL_DISPLAY_STATES; + } + else if (args[i].equals("-show-rsa")) + { + options |= axtlsj.SSL_DISPLAY_RSA; + } + else + print_server_options(build_mode, args[i]); + } + else + print_server_options(build_mode, args[i]); + } + else + print_server_options(build_mode, args[i]); + } + else + print_server_options(build_mode, args[i]); + + i++; + } + + /* Create socket for incoming connections */ + ServerSocket server_sock = new ServerSocket(port); + + /********************************************************************** + * This is where the interesting stuff happens. Up until now we've + * just been setting up sockets etc. Now we do the SSL handshake. + **********************************************************************/ + SSLServer ssl_ctx = new SSLServer(options, + axtlsj.SSL_DEFAULT_SVR_SESS); + + if (ssl_ctx == null) + throw new Exception("Error: Server context is invalid"); + + if (private_key_file != null) + { + int obj_type = axtlsj.SSL_OBJ_RSA_KEY; + + if (private_key_file.endsWith(".p8")) + obj_type = axtlsj.SSL_OBJ_PKCS8; + else if (private_key_file.endsWith(".p12")) + obj_type = axtlsj.SSL_OBJ_PKCS12; + + if (ssl_ctx.objLoad(obj_type, + private_key_file, password) != axtlsj.SSL_OK) + { + throw new Exception("Error: Private key '" + private_key_file + + "' is undefined."); + } + } + + for (i = 0; i < cert_index; i++) + { + if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CERT, + cert[i], null) != axtlsj.SSL_OK) + { + throw new Exception("Certificate '" + cert[i] + + "' is undefined."); + } + } + + for (i = 0; i < ca_cert_index; i++) + { + if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CACERT, + ca_cert[i], null) != axtlsj.SSL_OK) + { + throw new Exception("Certificate '" + ca_cert[i] + + "' is undefined."); + } + } + + int res; + SSLReadHolder rh = new SSLReadHolder(); + + for (;;) + { + if (!quiet) + { + System.out.println("ACCEPT"); + } + + Socket client_sock = server_sock.accept(); + + SSL ssl = ssl_ctx.connect(client_sock); + + while ((res = ssl_ctx.read(ssl, rh)) == axtlsj.SSL_OK) + { + /* check when the connection has been established */ + if (ssl.handshakeStatus() == axtlsj.SSL_OK) + break; + + /* could do something else here */ + } + + if (res == axtlsj.SSL_OK) /* connection established and ok */ + { + if (!quiet) + { + display_session_id(ssl); + display_cipher(ssl); + } + + /* now read (and display) whatever the client sends us */ + for (;;) + { + /* keep reading until we get something interesting */ + while ((res = ssl_ctx.read(ssl, rh)) == axtlsj.SSL_OK) + { + /* could do something else here */ + } + + if (res < axtlsj.SSL_OK) + { + if (!quiet) + { + System.out.println("CONNECTION CLOSED"); + } + + break; + } + + /* convert to String */ + byte[] buf = rh.getData(); + char[] str = new char[res]; + + for (i = 0; i < res; i++) + { + str[i] = (char)buf[i]; + } + + System.out.print(str); + } + } + else if (!quiet) + { + SSLUtil.displayError(res); + } + + /* client was disconnected or the handshake failed. */ + ssl.dispose(); + client_sock.close(); + } + + /* ssl_ctx.dispose(); */ + } + + /* + * do_client() + */ + private void do_client(int build_mode, String[] args) + throws Exception + { + if (build_mode < axtlsj.SSL_BUILD_ENABLE_CLIENT) + print_client_options(build_mode, args[1]); + + int i = 1, res; + int port = 4433; + boolean quiet = false; + String password = null; + int reconnect = 0; + String private_key_file = null; + String hostname = "127.0.0.1"; + + /* organise the cert/ca_cert lists */ + int cert_index = 0; + int ca_cert_index = 0; + int cert_size = SSLUtil.maxCerts(); + int ca_cert_size = SSLUtil.maxCACerts(); + String[] cert = new String[cert_size]; + String[] ca_cert = new String[ca_cert_size]; + + int options = axtlsj.SSL_SERVER_VERIFY_LATER|axtlsj.SSL_DISPLAY_CERTS; + byte[] session_id = null; + + while (i < args.length) + { + if (args[i].equals("-connect")) + { + String host_port; + + if (i >= args.length-1) + { + print_client_options(build_mode, args[i]); + } + + host_port = args[++i]; + int index_colon; + + if ((index_colon = host_port.indexOf(':')) < 0) + print_client_options(build_mode, args[i]); + + hostname = new String(host_port.toCharArray(), + 0, index_colon); + port = Integer.parseInt(new String(host_port.toCharArray(), + index_colon+1, host_port.length()-index_colon-1)); + } + else if (args[i].equals("-cert")) + { + if (i >= args.length-1 || cert_index >= cert_size) + { + print_client_options(build_mode, args[i]); + } + + cert[cert_index++] = args[++i]; + } + else if (args[i].equals("-CAfile")) + { + if (i >= args.length-1 || ca_cert_index >= ca_cert_size) + { + print_client_options(build_mode, args[i]); + } + + ca_cert[ca_cert_index++] = args[++i]; + } + else if (args[i].equals("-key")) + { + if (i >= args.length-1) + { + print_client_options(build_mode, args[i]); + } + + private_key_file = args[++i]; + options |= axtlsj.SSL_NO_DEFAULT_KEY; + } + else if (args[i].equals("-verify")) + { + options &= ~(int)axtlsj.SSL_SERVER_VERIFY_LATER; + } + else if (args[i].equals("-reconnect")) + { + reconnect = 4; + } + else if (args[i].equals("-quiet")) + { + quiet = true; + options &= ~(int)axtlsj.SSL_DISPLAY_CERTS; + } + else if (args[i].equals("-pass")) + { + if (i >= args.length-1) + { + print_server_options(build_mode, args[i]); + } + + password = args[++i]; + } + else if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) + { + if (args[i].equals("-debug")) + { + options |= axtlsj.SSL_DISPLAY_BYTES; + } + else if (args[i].equals("-state")) + { + options |= axtlsj.SSL_DISPLAY_STATES; + } + else if (args[i].equals("-show-rsa")) + { + options |= axtlsj.SSL_DISPLAY_RSA; + } + else + print_client_options(build_mode, args[i]); + } + else /* don't know what this is */ + print_client_options(build_mode, args[i]); + + i++; + } + + Socket client_sock = new Socket(hostname, port); + + if (!client_sock.isConnected()) + { + System.out.println("could not connect"); + throw new Exception(); + } + + if (!quiet) + { + System.out.println("CONNECTED"); + } + + /********************************************************************** + * This is where the interesting stuff happens. Up until now we've + * just been setting up sockets etc. Now we do the SSL handshake. + **********************************************************************/ + SSLClient ssl_ctx = new SSLClient(options, + axtlsj.SSL_DEFAULT_CLNT_SESS); + + if (ssl_ctx == null) + { + throw new Exception("Error: Client context is invalid"); + } + + if (private_key_file != null) + { + int obj_type = axtlsj.SSL_OBJ_RSA_KEY; + + if (private_key_file.endsWith(".p8")) + obj_type = axtlsj.SSL_OBJ_PKCS8; + else if (private_key_file.endsWith(".p12")) + obj_type = axtlsj.SSL_OBJ_PKCS12; + + if (ssl_ctx.objLoad(obj_type, + private_key_file, password) != axtlsj.SSL_OK) + { + throw new Exception("Error: Private key '" + private_key_file + + "' is undefined."); + } + } + + for (i = 0; i < cert_index; i++) + { + if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CERT, + cert[i], null) != axtlsj.SSL_OK) + { + throw new Exception("Certificate '" + cert[i] + + "' is undefined."); + } + } + + for (i = 0; i < ca_cert_index; i++) + { + if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CACERT, + ca_cert[i], null) != axtlsj.SSL_OK) + { + throw new Exception("Certificate '" + ca_cert[i] + + "' is undefined."); + } + } + + SSL ssl = null; + + /* Try session resumption? */ + if (reconnect > 0) + { + while (reconnect-- > 0) + { + ssl = ssl_ctx.connect(client_sock, session_id); + + if ((res = ssl.handshakeStatus()) != axtlsj.SSL_OK) + { + if (!quiet) + { + SSLUtil.displayError(res); + } + + ssl.dispose(); + throw new Exception(); + } + + display_session_id(ssl); + session_id = ssl.getSessionId(); + + if (reconnect > 0) + { + ssl.dispose(); + client_sock.close(); + + /* and reconnect */ + client_sock = new Socket(hostname, port); + } + } + } + else + { + ssl = ssl_ctx.connect(client_sock, null); + } + + /* check the return status */ + if ((res = ssl.handshakeStatus()) != axtlsj.SSL_OK) + { + if (!quiet) + { + SSLUtil.displayError(res); + } + + throw new Exception(); + } + + if (!quiet) + { + String common_name = + ssl.getCertificateDN(axtlsj.SSL_X509_CERT_COMMON_NAME); + + if (common_name != null) + { + System.out.println("Common Name:\t\t\t" + common_name); + } + + display_session_id(ssl); + display_cipher(ssl); + } + + BufferedReader in = new BufferedReader( + new InputStreamReader(System.in)); + + for (;;) + { + String user_input = in.readLine(); + + if (user_input == null) + break; + + byte[] buf = new byte[user_input.length()+2]; + buf[buf.length-2] = (byte)'\n'; /* add the carriage return */ + buf[buf.length-1] = 0; /* null terminate */ + + for (i = 0; i < buf.length-2; i++) + { + buf[i] = (byte)user_input.charAt(i); + } + + if ((res = ssl_ctx.write(ssl, buf)) < axtlsj.SSL_OK) + { + if (!quiet) + { + SSLUtil.displayError(res); + } + + break; + } + } + + ssl_ctx.dispose(); + } + + /** + * We've had some sort of command-line error. Print out the basic options. + */ + private void print_options(String option) + { + System.out.println("axssl: Error: '" + option + + "' is an invalid command."); + System.out.println("usage: axtlsj.jar [s_server|s_client|version] " + + "[args ...]"); + System.exit(1); + } + + /** + * We've had some sort of command-line error. Print out the server options. + */ + private void print_server_options(int build_mode, String option) + { + int cert_size = SSLUtil.maxCerts(); + int ca_cert_size = SSLUtil.maxCACerts(); + + System.out.println("unknown option " + option); + System.out.println("usage: s_server [args ...]"); + System.out.println(" -accept arg\t- port to accept on (default " + + "is 4433)"); + System.out.println(" -quiet\t\t- No server output"); + + if (build_mode >= axtlsj.SSL_BUILD_SERVER_ONLY) + { + System.out.println(" -cert arg\t- certificate file to add (in " + + "addition to default) to chain -"); + System.out.println("\t\t Can repeat up to " + cert_size + " times"); + System.out.println(" -key arg\t- Private key file to use"); + System.out.println(" -pass\t\t- private key file pass phrase source"); + } + + if (build_mode >= axtlsj.SSL_BUILD_ENABLE_VERIFICATION) + { + System.out.println(" -verify\t- turn on peer certificate " + + "verification"); + System.out.println(" -CAfile arg\t- Certificate authority. "); + System.out.println("\t\t Can repeat up to " + + ca_cert_size + " times"); + } + + if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) + { + System.out.println(" -debug\t\t- Print more output"); + System.out.println(" -state\t\t- Show state messages"); + System.out.println(" -show-rsa\t- Show RSA state"); + } + + System.exit(1); + } + + /** + * We've had some sort of command-line error. Print out the client options. + */ + private void print_client_options(int build_mode, String option) + { + int cert_size = SSLUtil.maxCerts(); + int ca_cert_size = SSLUtil.maxCACerts(); + + System.out.println("unknown option " + option); + + if (build_mode >= axtlsj.SSL_BUILD_ENABLE_CLIENT) + { + System.out.println("usage: s_client [args ...]"); + System.out.println(" -connect host:port - who to connect to " + + "(default is localhost:4433)"); + System.out.println(" -verify\t- turn on peer certificate " + + "verification"); + System.out.println(" -cert arg\t- certificate file to use"); + System.out.println(" -key arg\t- Private key file to use"); + System.out.println("\t\t Can repeat up to " + cert_size + + " times"); + System.out.println(" -CAfile arg\t- Certificate authority."); + System.out.println("\t\t Can repeat up to " + ca_cert_size + + " times"); + System.out.println(" -quiet\t\t- No client output"); + System.out.println(" -pass\t\t- private key file pass " + + "phrase source"); + System.out.println(" -reconnect\t- Drop and re-make the " + + "connection with the same Session-ID"); + + if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) + { + System.out.println(" -debug\t\t- Print more output"); + System.out.println(" -state\t\t- Show state messages"); + System.out.println(" -show-rsa\t- Show RSA state"); + } + } + else + { + System.out.println("Change configuration to allow this feature"); + } + + System.exit(1); + } + + /** + * Display what cipher we are using + */ + private void display_cipher(SSL ssl) + { + System.out.print("CIPHER is "); + + byte ciph_id = ssl.getCipherId(); + + if (ciph_id == axtlsj.SSL_AES128_SHA) + System.out.println("AES128-SHA"); + else if (ciph_id == axtlsj.SSL_AES256_SHA) + System.out.println("AES256-SHA"); + else if (ciph_id == axtlsj.SSL_AES128_SHA256) + System.out.println("AES128-SHA256"); + else if (ciph_id == axtlsj.SSL_AES256_SHA256) + System.out.println("AES256-SHA256"); + else + System.out.println("Unknown - " + ssl.getCipherId()); + } + + public char toHexChar(int i) + { + if ((0 <= i) && (i <= 9 )) + return (char)('0' + i); + else + return (char)('a' + (i-10)); + } + + public void bytesToHex(byte[] data) + { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < data.length; i++ ) + { + buf.append(toHexChar((data[i]>>>4)&0x0F)); + buf.append(toHexChar(data[i]&0x0F)); + } + + System.out.println(buf); + } + + + /** + * Display what session id we have. + */ + private void display_session_id(SSL ssl) + { + byte[] session_id = ssl.getSessionId(); + + if (session_id.length > 0) + { + System.out.println("-----BEGIN SSL SESSION PARAMETERS-----"); + bytesToHex(session_id); + System.out.println("-----END SSL SESSION PARAMETERS-----"); + } + } +} diff --git a/user/mpy/lib/axtls/samples/java/manifest.mf b/user/mpy/lib/axtls/samples/java/manifest.mf new file mode 100644 index 0000000..b906ed2 --- /dev/null +++ b/user/mpy/lib/axtls/samples/java/manifest.mf @@ -0,0 +1 @@ +Main-Class: axssl diff --git a/user/mpy/lib/axtls/samples/lua/Makefile b/user/mpy/lib/axtls/samples/lua/Makefile new file mode 100644 index 0000000..a460da3 --- /dev/null +++ b/user/mpy/lib/axtls/samples/lua/Makefile @@ -0,0 +1,43 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf + +all: samples +TARGET=../../$(STAGE)/axssl.lua +samples: $(TARGET) + +$(TARGET): axssl.lua + install $< $@ + +clean:: + -@rm -f $(TARGET) + diff --git a/user/mpy/lib/axtls/samples/lua/axssl.lua b/user/mpy/lib/axtls/samples/lua/axssl.lua new file mode 100755 index 0000000..b4f24ed --- /dev/null +++ b/user/mpy/lib/axtls/samples/lua/axssl.lua @@ -0,0 +1,562 @@ +#!/usr/local/bin/lua + +-- +-- Copyright (c) 2007-2016, Cameron Rich +-- +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are met: +-- +-- * Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of the axTLS project nor the names of its +-- contributors may be used to endorse or promote products derived +-- from this software without specific prior written permission. +-- +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +-- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +-- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-- + +-- +-- Demonstrate the use of the axTLS library in Lua with a set of +-- command-line parameters similar to openssl. In fact, openssl clients +-- should be able to communicate with axTLS servers and visa-versa. +-- +-- This code has various bits enabled depending on the configuration. To enable +-- the most interesting version, compile with the 'full mode' enabled. +-- +-- To see what options you have, run the following: +-- > [lua] axssl s_server -? +-- > [lua] axssl s_client -? +-- +-- The axtls/axtlsl shared libraries must be in the same directory or be found +-- by the OS. +-- +-- +require "bit" +require("axtlsl") +local socket = require("socket") + +-- print version? +if #arg == 1 and arg[1] == "version" then + print("axssl.lua "..axtlsl.ssl_version()) + os.exit(1) +end + +-- +-- We've had some sort of command-line error. Print out the basic options. +-- +function print_options(option) + print("axssl: Error: '"..option.."' is an invalid command.") + print("usage: axssl [s_server|s_client|version] [args ...]") + os.exit(1) +end + +-- +-- We've had some sort of command-line error. Print out the server options. +-- +function print_server_options(build_mode, option) + local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) + local ca_cert_size = axtlsl.ssl_get_config( + axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) + + print("unknown option "..option) + print("usage: s_server [args ...]") + print(" -accept\t- port to accept on (default is 4433)") + print(" -quiet\t\t- No server output") + + if build_mode >= axtlsl.SSL_BUILD_SERVER_ONLY then + print(" -cert arg\t- certificate file to add (in addition to ".. + "default) to chain -") + print("\t\t Can repeat up to "..cert_size.." times") + print(" -key arg\t- Private key file to use - default DER format") + print(" -pass\t\t- private key file pass phrase source") + end + + if build_mode >= axtlsl.SSL_BUILD_ENABLE_VERIFICATION then + print(" -verify\t- turn on peer certificate verification") + print(" -CAfile arg\t- Certificate authority - default DER format") + print("\t\t Can repeat up to "..ca_cert_size.." times") + end + + if build_mode == axtlsl.SSL_BUILD_FULL_MODE then + print(" -debug\t\t- Print more output") + print(" -state\t\t- Show state messages") + print(" -show-rsa\t- Show RSA state") + end + + os.exit(1) +end + +-- +-- We've had some sort of command-line error. Print out the client options. +-- +function print_client_options(build_mode, option) + local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) + local ca_cert_size = axtlsl.ssl_get_config( + axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) + + print("unknown option "..option) + + if build_mode >= axtlsl.SSL_BUILD_ENABLE_CLIENT then + print("usage: s_client [args ...]") + print(" -connect host:port - who to connect to (default ".. + "is localhost:4433)") + print(" -verify\t- turn on peer certificate verification") + print(" -cert arg\t- certificate file to use - default DER format") + print(" -key arg\t- Private key file to use - default DER format") + print("\t\t Can repeat up to "..cert_size.." times") + print(" -CAfile arg\t- Certificate authority - default DER format") + print("\t\t Can repeat up to "..ca_cert_size.."times") + print(" -quiet\t\t- No client output") + print(" -pass\t\t- private key file pass phrase source") + print(" -reconnect\t- Drop and re-make the connection ".. + "with the same Session-ID") + + if build_mode == axtlsl.SSL_BUILD_FULL_MODE then + print(" -debug\t\t- Print more output") + print(" -state\t\t- Show state messages") + print(" -show-rsa\t- Show RSA state") + end + else + print("Change configuration to allow this feature") + end + + os.exit(1) +end + +-- Implement the SSL server logic. +function do_server(build_mode) + local i = 2 + local v + local port = 4433 + local options = axtlsl.SSL_DISPLAY_CERTS + local quiet = false + local password = "" + local private_key_file = nil + local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) + local ca_cert_size = axtlsl. + ssl_get_config(axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) + local cert = {} + local ca_cert = {} + + while i <= #arg do + if arg[i] == "-accept" then + if i >= #arg then + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + port = arg[i] + elseif arg[i] == "-quiet" then + quiet = true + options = bit.band(options, bit.bnot(axtlsl.SSL_DISPLAY_CERTS)) + elseif build_mode >= axtlsl.SSL_BUILD_SERVER_ONLY then + if arg[i] == "-cert" then + if i >= #arg or #cert >= cert_size then + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + table.insert(cert, arg[i]) + elseif arg[i] == "-key" then + if i >= #arg then + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + private_key_file = arg[i] + options = bit.bor(options, axtlsl.SSL_NO_DEFAULT_KEY) + elseif arg[i] == "-pass" then + if i >= #arg then + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + password = arg[i] + elseif build_mode >= axtlsl.SSL_BUILD_ENABLE_VERIFICATION then + if arg[i] == "-verify" then + options = bit.bor(options, axtlsl.SSL_CLIENT_AUTHENTICATION) + elseif arg[i] == "-CAfile" then + if i >= #arg or #ca_cert >= ca_cert_size then + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + table.insert(ca_cert, arg[i]) + elseif build_mode == axtlsl.SSL_BUILD_FULL_MODE then + if arg[i] == "-debug" then + options = bit.bor(options, axtlsl.SSL_DISPLAY_BYTES) + elseif arg[i] == "-state" then + options = bit.bor(options, axtlsl.SSL_DISPLAY_STATES) + elseif arg[i] == "-show-rsa" then + options = bit.bor(options, axtlsl.SSL_DISPLAY_RSA) + else + print_server_options(build_mode, arg[i]) + end + else + print_server_options(build_mode, arg[i]) + end + else + print_server_options(build_mode, arg[i]) + end + else + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + end + + -- Create socket for incoming connections + local server_sock = socket.try(socket.bind("*", port)) + + --------------------------------------------------------------------------- + -- This is where the interesting stuff happens. Up until now we've + -- just been setting up sockets etc. Now we do the SSL handshake. + --------------------------------------------------------------------------- + local ssl_ctx = axtlsl.ssl_ctx_new(options, axtlsl.SSL_DEFAULT_SVR_SESS) + if ssl_ctx == nil then error("Error: Server context is invalid") end + + if private_key_file ~= nil then + local obj_type = axtlsl.SSL_OBJ_RSA_KEY + + if string.find(private_key_file, ".p8") then + obj_type = axtlsl.SSL_OBJ_PKCS8 + end + + if string.find(private_key_file, ".p12") then + obj_type = axtlsl.SSL_OBJ_PKCS12 + end + + if axtlsl.ssl_obj_load(ssl_ctx, obj_type, private_key_file, + password) ~= axtlsl.SSL_OK then + error("Private key '" .. private_key_file .. "' is undefined.") + end + end + + for _, v in ipairs(cert) do + if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CERT, v, "") ~= + axtlsl.SSL_OK then + error("Certificate '"..v .. "' is undefined.") + end + end + + for _, v in ipairs(ca_cert) do + if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CACERT, v, "") ~= + axtlsl.SSL_OK then + error("Certificate '"..v .."' is undefined.") + end + end + + while true do + if not quiet then print("ACCEPT") end + local client_sock = server_sock:accept(); + local ssl = axtlsl.ssl_server_new(ssl_ctx, client_sock:getfd()) + + -- do the actual SSL handshake + local connected = false + local res + local buf + + while true do + socket.select({client_sock}, nil) + res, buf = axtlsl.ssl_read(ssl) + + if res == axtlsl.SSL_OK then -- connection established and ok + if axtlsl.ssl_handshake_status(ssl) == axtlsl.SSL_OK then + if not quiet and not connected then + display_session_id(ssl) + display_cipher(ssl) + end + connected = true + end + end + + if res > axtlsl.SSL_OK then + for _, v in ipairs(buf) do + io.write(string.format("%c", v)) + end + elseif res < axtlsl.SSL_OK then + if not quiet then + axtlsl.ssl_display_error(res) + end + break + end + end + + -- client was disconnected or the handshake failed. + print("CONNECTION CLOSED") + axtlsl.ssl_free(ssl) + client_sock:close() + end + + axtlsl.ssl_ctx_free(ssl_ctx) +end + +-- +-- Implement the SSL client logic. +-- +function do_client(build_mode) + local i = 2 + local v + local port = 4433 + local options = + bit.bor(axtlsl.SSL_SERVER_VERIFY_LATER, axtlsl.SSL_DISPLAY_CERTS) + local private_key_file = nil + local reconnect = 0 + local quiet = false + local password = "" + local session_id = {} + local host = "127.0.0.1" + local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) + local ca_cert_size = axtlsl. + ssl_get_config(axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) + local cert = {} + local ca_cert = {} + + while i <= #arg do + if arg[i] == "-connect" then + if i >= #arg then + print_client_options(build_mode, arg[i]) + end + + i = i + 1 + local t = string.find(arg[i], ":") + host = string.sub(arg[i], 1, t-1) + port = string.sub(arg[i], t+1) + elseif arg[i] == "-cert" then + if i >= #arg or #cert >= cert_size then + print_client_options(build_mode, arg[i]) + end + + i = i + 1 + table.insert(cert, arg[i]) + elseif arg[i] == "-key" then + if i >= #arg then + print_client_options(build_mode, arg[i]) + end + + i = i + 1 + private_key_file = arg[i] + options = bit.bor(options, axtlsl.SSL_NO_DEFAULT_KEY) + elseif arg[i] == "-CAfile" then + if i >= #arg or #ca_cert >= ca_cert_size then + print_client_options(build_mode, arg[i]) + end + + i = i + 1 + table.insert(ca_cert, arg[i]) + elseif arg[i] == "-verify" then + options = bit.band(options, + bit.bnot(axtlsl.SSL_SERVER_VERIFY_LATER)) + elseif arg[i] == "-reconnect" then + reconnect = 4 + elseif arg[i] == "-quiet" then + quiet = true + options = bit.band(options, bnot(axtlsl.SSL_DISPLAY_CERTS)) + elseif arg[i] == "-pass" then + if i >= #arg then + print_server_options(build_mode, arg[i]) + end + + i = i + 1 + password = arg[i] + elseif build_mode == axtlsl.SSL_BUILD_FULL_MODE then + if arg[i] == "-debug" then + options = bit.bor(options, axtlsl.SSL_DISPLAY_BYTES) + elseif arg[i] == "-state" then + options = bit.bor(axtlsl.SSL_DISPLAY_STATES) + elseif arg[i] == "-show-rsa" then + options = bit.bor(axtlsl.SSL_DISPLAY_RSA) + else -- don't know what this is + print_client_options(build_mode, arg[i]) + end + else -- don't know what this is + print_client_options(build_mode, arg[i]) + end + + i = i + 1 + end + + local client_sock = socket.try(socket.connect(host, port)) + local ssl + local res + + if not quiet then print("CONNECTED") end + + --------------------------------------------------------------------------- + -- This is where the interesting stuff happens. Up until now we've + -- just been setting up sockets etc. Now we do the SSL handshake. + --------------------------------------------------------------------------- + local ssl_ctx = axtlsl.ssl_ctx_new(options, axtlsl.SSL_DEFAULT_CLNT_SESS) + + if ssl_ctx == nil then + error("Error: Client context is invalid") + end + + if private_key_file ~= nil then + local obj_type = axtlsl.SSL_OBJ_RSA_KEY + + if string.find(private_key_file, ".p8") then + obj_type = axtlsl.SSL_OBJ_PKCS8 + end + + if string.find(private_key_file, ".p12") then + obj_type = axtlsl.SSL_OBJ_PKCS12 + end + + if axtlsl.ssl_obj_load(ssl_ctx, obj_type, private_key_file, + password) ~= axtlsl.SSL_OK then + error("Private key '"..private_key_file.."' is undefined.") + end + end + + for _, v in ipairs(cert) do + if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CERT, v, "") ~= + axtlsl.SSL_OK then + error("Certificate '"..v .. "' is undefined.") + end + end + + for _, v in ipairs(ca_cert) do + if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CACERT, v, "") ~= + axtlsl.SSL_OK then + error("Certificate '"..v .."' is undefined.") + end + end + + -- Try session resumption? + if reconnect ~= 0 then + local session_id = nil + local sess_id_size = 0 + + while reconnect > 0 do + reconnect = reconnect - 1 + ssl = axtlsl.ssl_client_new(ssl_ctx, + client_sock:getfd(), session_id, sess_id_size) + + res = axtlsl.ssl_handshake_status(ssl) + if res ~= axtlsl.SSL_OK then + if not quiet then axtlsl.ssl_display_error(res) end + axtlsl.ssl_free(ssl) + os.exit(1) + end + + display_session_id(ssl) + session_id = axtlsl.ssl_get_session_id(ssl) + sess_id_size = axtlsl.ssl_get_session_id_size(ssl) + + if reconnect > 0 then + axtlsl.ssl_free(ssl) + client_sock:close() + client_sock = socket.try(socket.connect(host, port)) + end + + end + else + ssl = axtlsl.ssl_client_new(ssl_ctx, client_sock:getfd(), nil, 0) + end + + -- check the return status + res = axtlsl.ssl_handshake_status(ssl) + if res ~= axtlsl.SSL_OK then + if not quiet then axtlsl.ssl_display_error(res) end + os.exit(1) + end + + if not quiet then + local common_name = axtlsl.ssl_get_cert_dn(ssl, + axtlsl.SSL_X509_CERT_COMMON_NAME) + + if common_name ~= nil then + print("Common Name:\t\t\t"..common_name) + end + + display_session_id(ssl) + display_cipher(ssl) + end + + while true do + local line = io.read() + if line == nil then break end + local bytes = {} + + for i = 1, #line do + bytes[i] = line.byte(line, i) + end + + bytes[#line+1] = 10 -- add carriage return, null + bytes[#line+2] = 0 + + res = axtlsl.ssl_write(ssl, bytes, #bytes) + if res < axtlsl.SSL_OK then + if not quiet then axtlsl.ssl_display_error(res) end + break + end + end + + axtlsl.ssl_ctx_free(ssl_ctx) + client_sock:close() +end + +-- +-- Display what cipher we are using +-- +function display_cipher(ssl) + io.write("CIPHER is ") + local cipher_id = axtlsl.ssl_get_cipher_id(ssl) + + if cipher_id == axtlsl.SSL_AES128_SHA then + print("AES128-SHA") + elseif cipher_id == axtlsl.SSL_AES256_SHA then + print("AES256-SHA") + elseif axtlsl.SSL_AES128_SHA256 then + print("AES128-SHA256") + elseif axtlsl.SSL_AES256_SHA256 then + print("AES256-SHA256") + else + print("Unknown - "..cipher_id) + end +end + +-- +-- Display what session id we have. +-- +function display_session_id(ssl) + local session_id = axtlsl.ssl_get_session_id(ssl) + local v + + if #session_id > 0 then + print("-----BEGIN SSL SESSION PARAMETERS-----") + for _, v in ipairs(session_id) do + io.write(string.format("%02x", v)) + end + print("\n-----END SSL SESSION PARAMETERS-----") + end +end + +-- +-- Main entry point. Doesn't do much except works out whether we are a client +-- or a server. +-- +if #arg == 0 or (arg[1] ~= "s_server" and arg[1] ~= "s_client") then + print_options(#arg > 0 and arg[1] or "") +end + +local build_mode = axtlsl.ssl_get_config(axtlsl.SSL_BUILD_MODE) +_ = arg[1] == "s_server" and do_server(build_mode) or do_client(build_mode) +os.exit(0) + diff --git a/user/mpy/lib/axtls/samples/perl/Makefile b/user/mpy/lib/axtls/samples/perl/Makefile new file mode 100644 index 0000000..5200c43 --- /dev/null +++ b/user/mpy/lib/axtls/samples/perl/Makefile @@ -0,0 +1,43 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf + +all: samples +TARGET=../../$(STAGE)/axssl.pl +samples: $(TARGET) + +$(TARGET): axssl.pl + install $< $@ + +clean:: + -@rm -f $(TARGET) + diff --git a/user/mpy/lib/axtls/samples/perl/axssl.pl b/user/mpy/lib/axtls/samples/perl/axssl.pl new file mode 100755 index 0000000..f3b0449 --- /dev/null +++ b/user/mpy/lib/axtls/samples/perl/axssl.pl @@ -0,0 +1,634 @@ +#!/usr/bin/perl -w +# +# Copyright (c) 2007-2016, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# Demonstrate the use of the axTLS library in Perl with a set of +# command-line parameters similar to openssl. In fact, openssl clients +# should be able to communicate with axTLS servers and visa-versa. +# +# This code has various bits enabled depending on the configuration. To enable +# the most interesting version, compile with the 'full mode' enabled. +# +# To see what options you have, run the following: +# > [perl] axssl s_server -? +# > [perl] axssl s_client -? +# +# The axtls/axtlsp shared libraries must be in the same directory or be found +# by the OS. axtlsp.pm must be in this directory or be in @INC. +# +# Under Win32, ActivePerl was used (see +# http://www.activestate.com/Products/ActivePerl/?mp=1) +# +use axtlsp; +use IO::Socket; + +# To get access to Win32 file descriptor stuff +my $is_win32 = 0; + +if ($^O eq "MSWin32") +{ + eval("use Win32API::File 0.08 qw( :ALL )"); + $is_win32 = 1; +} + +use strict; + +# +# Win32 has some problems with socket handles +# +sub get_native_sock +{ + my ($sock) = @_; + return $is_win32 ? FdGetOsFHandle($sock) : $sock; +} + +# print version? +if ($#ARGV == 0 && $ARGV[0] eq "version") +{ + printf("axssl.pl ".axtlsp::ssl_version()."\n"); + exit 0; +} + +# +# Main entry point. Doesn't do much except works out whether we are a client +# or a server. +# +print_options($#ARGV > -1 ? $ARGV[0] : "") + if ($#ARGV < 0 || ($ARGV[0] ne "s_server" && $ARGV[0] ne "s_client")); + + +# Cygwin/Win32 issue - flush our output continuously +select STDOUT; +local $|=1; + +my $build_mode = axtlsp::ssl_get_config($axtlsp::SSL_BUILD_MODE); +$ARGV[0] eq "s_server" ? do_server($build_mode) : do_client($build_mode); + +# +# Implement the SSL server logic. +# +sub do_server +{ + my ($build_mode) = @_; + my $i = 1; + my $port = 4433; + my $options = $axtlsp::SSL_DISPLAY_CERTS; + my $quiet = 0; + my $password = undef; + my $private_key_file = undef; + my $cert_size = axtlsp::ssl_get_config($axtlsp::SSL_MAX_CERT_CFG_OFFSET); + my $ca_cert_size = axtlsp::ssl_get_config( + $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); + my @cert; + my @ca_cert; + + while ($i <= $#ARGV) + { + if ($ARGV[$i] eq "-accept") + { + print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; + $port = $ARGV[++$i]; + } + elsif ($ARGV[$i] eq "-quiet") + { + $quiet = 1; + $options &= ~$axtlsp::SSL_DISPLAY_CERTS; + } + elsif ($build_mode >= $axtlsp::SSL_BUILD_SERVER_ONLY) + { + if ($ARGV[$i] eq "-cert") + { + print_server_options($build_mode, $ARGV[$i]) + if $i >= $#ARGV || $#cert >= $cert_size-1; + + push @cert, $ARGV[++$i]; + } + elsif ($ARGV[$i] eq "-key") + { + print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; + $private_key_file = $ARGV[++$i]; + $options |= $axtlsp::SSL_NO_DEFAULT_KEY; + } + elsif ($ARGV[$i] eq "-pass") + { + print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; + $password = $ARGV[++$i]; + } + elsif ($build_mode >= $axtlsp::SSL_BUILD_ENABLE_VERIFICATION) + { + if ($ARGV[$i] eq "-verify") + { + $options |= $axtlsp::SSL_CLIENT_AUTHENTICATION; + } + elsif ($ARGV[$i] eq "-CAfile") + { + print_server_options($build_mode, $ARGV[$i]) + if $i >= $#ARGV || $#ca_cert >= $ca_cert_size-1; + push @ca_cert, $ARGV[++$i]; + } + elsif ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) + { + if ($ARGV[$i] eq "-debug") + { + $options |= $axtlsp::SSL_DISPLAY_BYTES; + } + elsif ($ARGV[$i] eq "-state") + { + $options |= $axtlsp::SSL_DISPLAY_STATES; + } + elsif ($ARGV[$i] eq "-show-rsa") + { + $options |= $axtlsp::SSL_DISPLAY_RSA; + } + else + { + print_server_options($build_mode, $ARGV[$i]); + } + } + else + { + print_server_options($build_mode, $ARGV[$i]); + } + } + else + { + print_server_options($build_mode, $ARGV[$i]); + } + } + else + { + print_server_options($build_mode, $ARGV[$i]); + } + + $i++; + } + + # Create socket for incoming connections + my $server_sock = IO::Socket::INET->new(Proto => 'tcp', + LocalPort => $port, + Listen => 1, + Reuse => 1) or die $!; + + ########################################################################### + # This is where the interesting stuff happens. Up until now we've + # just been setting up sockets etc. Now we do the SSL handshake. + ########################################################################### + my $ssl_ctx = axtlsp::ssl_ctx_new($options, $axtlsp::SSL_DEFAULT_SVR_SESS); + die "Error: Server context is invalid" if not defined $ssl_ctx; + + if (defined $private_key_file) + { + my $obj_type = $axtlsp::SSL_OBJ_RSA_KEY; + + $obj_type = $axtlsp::SSL_OBJ_PKCS8 if $private_key_file =~ /.p8$/; + $obj_type = $axtlsp::SSL_OBJ_PKCS12 if $private_key_file =~ /.p12$/; + + die "Private key '$private_key_file' is undefined." if + axtlsp::ssl_obj_load($ssl_ctx, $obj_type, + $private_key_file, $password); + } + + foreach (@cert) + { + die "Certificate '$_' is undefined." + if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CERT, + $_, undef) != $axtlsp::SSL_OK; + } + + foreach (@ca_cert) + { + die "Certificate '$_' is undefined." + if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CACERT, + $_, undef) != $axtlsp::SSL_OK; + } + + for (;;) + { + printf("ACCEPT\n") if not $quiet; + my $client_sock = $server_sock->accept; + my $native_sock = get_native_sock($client_sock->fileno); + + # This doesn't work in Win32 - need to get file descriptor from socket. + my $ssl = axtlsp::ssl_server_new($ssl_ctx, $native_sock); + + # do the actual SSL handshake + my $res; + my $buf; + my $connected = 0; + + while (1) + { + ($res, $buf) = axtlsp::ssl_read($ssl, undef); + last if $res < $axtlsp::SSL_OK; + + if ($res == $axtlsp::SSL_OK) # connection established and ok + { + if (axtlsp::ssl_handshake_status($ssl) == $axtlsp::SSL_OK) + { + if (!$quiet && !$connected) + { + display_session_id($ssl); + display_cipher($ssl); + } + + $connected = 1; + } + } + + if ($res > $axtlsp::SSL_OK) + { + printf($$buf); + } + elsif ($res < $axtlsp::SSL_OK) + { + axtlsp::ssl_display_error($res) if not $quiet; + last; + } + } + + # client was disconnected or the handshake failed. + printf("CONNECTION CLOSED\n") if not $quiet; + axtlsp::ssl_free($ssl); + $client_sock->close; + } + + axtlsp::ssl_ctx_free($ssl_ctx); +} + +# +# Implement the SSL client logic. +# +sub do_client +{ + my ($build_mode) = @_; + my $i = 1; + my $port = 4433; + my $options = $axtlsp::SSL_SERVER_VERIFY_LATER|$axtlsp::SSL_DISPLAY_CERTS; + my $private_key_file = undef; + my $reconnect = 0; + my $quiet = 0; + my $password = undef; + my @session_id; + my $host = "127.0.0.1"; + my @cert; + my @ca_cert; + my $cert_size = axtlsp::ssl_get_config( + $axtlsp::SSL_MAX_CERT_CFG_OFFSET); + my $ca_cert_size = axtlsp::ssl_get_config( + $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); + + while ($i <= $#ARGV) + { + if ($ARGV[$i] eq "-connect") + { + print_client_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; + ($host, $port) = split(':', $ARGV[++$i]); + } + elsif ($ARGV[$i] eq "-cert") + { + print_client_options($build_mode, $ARGV[$i]) + if $i >= $#ARGV || $#cert >= $cert_size-1; + + push @cert, $ARGV[++$i]; + } + elsif ($ARGV[$i] eq "-key") + { + print_client_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; + $private_key_file = $ARGV[++$i]; + $options |= $axtlsp::SSL_NO_DEFAULT_KEY; + } + elsif ($ARGV[$i] eq "-CAfile") + { + print_client_options($build_mode, $ARGV[$i]) + if $i >= $#ARGV || $#ca_cert >= $ca_cert_size-1; + + push @ca_cert, $ARGV[++$i]; + } + elsif ($ARGV[$i] eq "-verify") + { + $options &= ~$axtlsp::SSL_SERVER_VERIFY_LATER; + } + elsif ($ARGV[$i] eq "-reconnect") + { + $reconnect = 4; + } + elsif ($ARGV[$i] eq "-quiet") + { + $quiet = 1; + $options &= ~$axtlsp::SSL_DISPLAY_CERTS; + } + elsif ($ARGV[$i] eq "-pass") + { + print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; + $password = $ARGV[++$i]; + } + elsif ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) + { + if ($ARGV[$i] eq "-debug") + { + $options |= $axtlsp::SSL_DISPLAY_BYTES; + } + elsif ($ARGV[$i] eq "-state") + { + $options |= $axtlsp::SSL_DISPLAY_STATES; + } + elsif ($ARGV[$i] eq "-show-rsa") + { + $options |= $axtlsp::SSL_DISPLAY_RSA; + } + else # don't know what this is + { + print_client_options($build_mode, $ARGV[$i]); + } + } + else # don't know what this is + { + print_client_options($build_mode, $ARGV[$i]); + } + + $i++; + } + + my $client_sock = new IO::Socket::INET ( + PeerAddr => $host, PeerPort => $port, Proto => 'tcp') + || die ("no socket: $!"); + my $ssl; + my $res; + my $native_sock = get_native_sock($client_sock->fileno); + + printf("CONNECTED\n") if not $quiet; + + ########################################################################### + # This is where the interesting stuff happens. Up until now we've + # just been setting up sockets etc. Now we do the SSL handshake. + ########################################################################### + my $ssl_ctx = axtlsp::ssl_ctx_new($options, $axtlsp::SSL_DEFAULT_CLNT_SESS); + die "Error: Client context is invalid" if not defined $ssl_ctx; + + if (defined $private_key_file) + { + my $obj_type = $axtlsp::SSL_OBJ_RSA_KEY; + + $obj_type = $axtlsp::SSL_OBJ_PKCS8 if $private_key_file =~ /.p8$/; + $obj_type = $axtlsp::SSL_OBJ_PKCS12 if $private_key_file =~ /.p12$/; + + die "Private key '$private_key_file' is undefined." if + axtlsp::ssl_obj_load($ssl_ctx, $obj_type, + $private_key_file, $password); + } + + foreach (@cert) + { + die "Certificate '$_' is undefined." + if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CERT, + $_, undef) != $axtlsp::SSL_OK; + } + + foreach (@ca_cert) + { + die "Certificate '$_' is undefined." + if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CACERT, + $_, undef) != $axtlsp::SSL_OK; + } + + # Try session resumption? + if ($reconnect) + { + my $session_id = undef; + my $sess_id_size = 0; + + while ($reconnect--) + { + $ssl = axtlsp::ssl_client_new($ssl_ctx, $native_sock, + $session_id, $sess_id_size); + + $res = axtlsp::ssl_handshake_status($ssl); + if ($res != $axtlsp::SSL_OK) + { + axtlsp::ssl_display_error($res) if !$quiet; + axtlsp::ssl_free($ssl); + exit 1; + } + + display_session_id($ssl); + $session_id = axtlsp::ssl_get_session_id($ssl); + + if ($reconnect) + { + axtlsp::ssl_free($ssl); + $client_sock->close; + $client_sock = new IO::Socket::INET ( + PeerAddr => $host, PeerPort => $port, Proto => 'tcp') + || die ("no socket: $!"); + + } + } + } + else + { + $ssl = axtlsp::ssl_client_new($ssl_ctx, $native_sock, undef, 0); + } + + # check the return status + $res = axtlsp::ssl_handshake_status($ssl); + if ($res != $axtlsp::SSL_OK) + { + axtlsp::ssl_display_error($res) if not $quiet; + exit 1; + } + + if (!$quiet) + { + my $common_name = axtlsp::ssl_get_cert_dn($ssl, + $axtlsp::SSL_X509_CERT_COMMON_NAME); + + printf("Common Name:\t\t\t%s\n", $common_name) if defined $common_name; + display_session_id($ssl); + display_cipher($ssl); + } + + while () + { + my $cstring = pack("a*x", $_); # add null terminator + $res = axtlsp::ssl_write($ssl, \$cstring, length($cstring)); + if ($res < $axtlsp::SSL_OK) + { + axtlsp::ssl_display_error($res) if not $quiet; + last; + } + } + + axtlsp::ssl_ctx_free($ssl_ctx); + $client_sock->close; +} + +# +# We've had some sort of command-line error. Print out the basic options. +# +sub print_options +{ + my ($option) = @_; + printf("axssl: Error: '%s' is an invalid command.\n", $option); + printf("usage: axssl [s_server|s_client|version] [args ...]\n"); + exit 1; +} + +# +# We've had some sort of command-line error. Print out the server options. +# +sub print_server_options +{ + my ($build_mode, $option) = @_; + my $cert_size = axtlsp::ssl_get_config($axtlsp::SSL_MAX_CERT_CFG_OFFSET); + my $ca_cert_size = axtlsp::ssl_get_config( + $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); + + printf("unknown option %s\n", $option); + printf("usage: s_server [args ...]\n"); + printf(" -accept arg\t- port to accept on (default is 4433)\n"); + printf(" -quiet\t\t- No server output\n"); + + if ($build_mode >= $axtlsp::SSL_BUILD_SERVER_ONLY) + { + printf(" -cert arg\t- certificate file to add (in addition to default)". + " to chain -\n". + "\t\t Can repeat up to %d times\n", $cert_size); + printf(" -key arg\t- Private key file to use - default DER format\n"); + printf(" -pass\t\t- private key file pass phrase source\n"); + } + + if ($build_mode >= $axtlsp::SSL_BUILD_ENABLE_VERIFICATION) + { + printf(" -verify\t- turn on peer certificate verification\n"); + printf(" -CAfile arg\t- Certificate authority - default DER format\n"); + printf("\t\t Can repeat up to %d times\n", $ca_cert_size); + } + + if ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) + { + printf(" -debug\t\t- Print more output\n"); + printf(" -state\t\t- Show state messages\n"); + printf(" -show-rsa\t- Show RSA state\n"); + } + + exit 1; +} + +# +# We've had some sort of command-line error. Print out the client options. +# +sub print_client_options +{ + my ($build_mode, $option) = @_; + my $cert_size = axtlsp::ssl_get_config($axtlsp::SSL_MAX_CERT_CFG_OFFSET); + my $ca_cert_size = axtlsp::ssl_get_config( + $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); + + printf("unknown option %s\n", $option); + + if ($build_mode >= $axtlsp::SSL_BUILD_ENABLE_CLIENT) + { + printf("usage: s_client [args ...]\n"); + printf(" -connect host:port - who to connect to (default ". + "is localhost:4433)\n"); + printf(" -verify\t- turn on peer certificate verification\n"); + printf(" -cert arg\t- certificate file to use - default DER format\n"); + printf(" -key arg\t- Private key file to use - default DER format\n"); + printf("\t\t Can repeat up to %d times\n", $cert_size); + printf(" -CAfile arg\t- Certificate authority - default DER format\n"); + printf("\t\t Can repeat up to %d times\n", $ca_cert_size); + printf(" -quiet\t\t- No client output\n"); + printf(" -pass\t\t- private key file pass phrase source\n"); + printf(" -reconnect\t- Drop and re-make the connection ". + "with the same Session-ID\n"); + + if ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) + { + printf(" -debug\t\t- Print more output\n"); + printf(" -state\t\t- Show state messages\n"); + printf(" -show-rsa\t- Show RSA state\n"); + } + } + else + { + printf("Change configuration to allow this feature\n"); + } + + exit 1; +} + +# +# Display what cipher we are using +# +sub display_cipher +{ + my ($ssl) = @_; + printf("CIPHER is "); + my $cipher_id = axtlsp::ssl_get_cipher_id($ssl); + + if ($cipher_id == $axtlsp::SSL_AES128_SHA) + { + printf("AES128-SHA"); + } + elsif ($cipher_id == $axtlsp::SSL_AES256_SHA) + { + printf("AES256-SHA"); + } + elsif ($axtlsp::SSL_AES128_SHA256) + { + printf("AES128-SHA256"); + } + elsif ($axtlsp::SSL_AES256_SHA256) + { + printf("AES256-SHA256"); + } + else + { + printf("Unknown - %d", $cipher_id); + } + + printf("\n"); +} + +# +# Display what session id we have. +# +sub display_session_id +{ + my ($ssl) = @_; + my $session_id = axtlsp::ssl_get_session_id($ssl); + if (length($$session_id) > 0) + { + printf("-----BEGIN SSL SESSION PARAMETERS-----\n"); + printf(unpack("H*", $$session_id)); + printf("\n-----END SSL SESSION PARAMETERS-----\n"); + } +} diff --git a/user/mpy/lib/axtls/samples/vbnet/Makefile b/user/mpy/lib/axtls/samples/vbnet/Makefile new file mode 100644 index 0000000..0984d4e --- /dev/null +++ b/user/mpy/lib/axtls/samples/vbnet/Makefile @@ -0,0 +1,48 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +include ../../config/.config +include ../../config/makefile.conf +include ../../config/makefile.dotnet.conf + +# only build on Win32 platforms +ifdef GO_DOT_NET +all : sample +TARGET=../../$(STAGE)/axssl.vbnet.exe +sample : $(TARGET) + +$(TARGET): ../../bindings/vbnet/axTLSvb.vb ../../bindings/vbnet/axInterface.vb axssl.vb + vbc.exe /r:"`cygpath -w "$(CONFIG_DOT_NET_FRAMEWORK_BASE)/System.dll"`" /nologo /t:exe /out:"`cygpath -w $@`" $(foreach file, $^, "`cygpath -w $(file)`") + +endif # ARCH + +clean:: + -@rm -f $(TARGET) + diff --git a/user/mpy/lib/axtls/samples/vbnet/axssl.vb b/user/mpy/lib/axtls/samples/vbnet/axssl.vb new file mode 100644 index 0000000..7e5d682 --- /dev/null +++ b/user/mpy/lib/axtls/samples/vbnet/axssl.vb @@ -0,0 +1,702 @@ +' +' Copyright (c) 2007-2016, Cameron Rich +' +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without +' modification, are permitted provided that the following conditions are met: +' +' * Redistributions of source code must retain the above copyright notice, +' this list of conditions and the following disclaimer. +' * Redistributions in binary form must reproduce the above copyright +' notice, this list of conditions and the following disclaimer in the +' documentation and/or other materials provided with the distribution. +' * Neither the name of the axTLS project nor the names of its +' contributors may be used to endorse or promote products derived +' from this software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +' CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +' TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +' OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +' NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +' THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +' + +' +' Demonstrate the use of the axTLS library in VB.NET with a set of +' command-line parameters similar to openssl. In fact, openssl clients +' should be able to communicate with axTLS servers and visa-versa. +' +' This code has various bits enabled depending on the configuration. To enable +' the most interesting version, compile with the 'full mode' enabled. +' +' To see what options you have, run the following: +' > axssl.vbnet.exe s_server -? +' > axssl.vbnet.exe s_client -? +' +' The axtls shared library must be in the same directory or be found +' by the OS. +' + +Imports System +Imports System.Net +Imports System.Net.Sockets +Imports Microsoft.VisualBasic +Imports axTLSvb + +Public Class axssl + ' + ' do_server() + ' + Public Sub do_server(ByVal build_mode As Integer, _ + ByVal args() As String) + Dim i As Integer = 1 + Dim port As Integer = 4433 + Dim options As Integer = axtls.SSL_DISPLAY_CERTS + Dim quiet As Boolean = False + Dim password As String = Nothing + Dim private_key_file As String = Nothing + + ' organise the cert/ca_cert lists + Dim cert_size As Integer = SSLUtil.MaxCerts() + Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() + Dim cert(cert_size) As String + Dim ca_cert(ca_cert_size) As String + Dim cert_index As Integer = 0 + Dim ca_cert_index As Integer = 0 + + While i < args.Length + If args(i) = "-accept" Then + If i >= args.Length-1 + print_server_options(build_mode, args(i)) + End If + + i += 1 + port = Int32.Parse(args(i)) + ElseIf args(i) = "-quiet" + quiet = True + options = options And Not axtls.SSL_DISPLAY_CERTS + ElseIf build_mode >= axtls.SSL_BUILD_SERVER_ONLY + If args(i) = "-cert" + If i >= args.Length-1 Or cert_index >= cert_size + print_server_options(build_mode, args(i)) + End If + + i += 1 + cert(cert_index) = args(i) + cert_index += 1 + ElseIf args(i) = "-key" + If i >= args.Length-1 + print_server_options(build_mode, args(i)) + End If + + i += 1 + private_key_file = args(i) + options = options Or axtls.SSL_NO_DEFAULT_KEY + ElseIf args(i) = "-pass" + If i >= args.Length-1 + print_server_options(build_mode, args(i)) + End If + + i += 1 + password = args(i) + ElseIf build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION + If args(i) = "-verify" Then + options = options Or axtls.SSL_CLIENT_AUTHENTICATION + ElseIf args(i) = "-CAfile" + If i >= args.Length-1 Or _ + ca_cert_index >= ca_cert_size Then + print_server_options(build_mode, args(i)) + End If + + i += 1 + ca_cert(ca_cert_index) = args(i) + ca_cert_index += 1 + ElseIf build_mode = axtls.SSL_BUILD_FULL_MODE + If args(i) = "-debug" Then + options = options Or axtls.SSL_DISPLAY_BYTES + ElseIf args(i) = "-state" + options = options Or axtls.SSL_DISPLAY_STATES + ElseIf args(i) = "-show-rsa" + options = options Or axtls.SSL_DISPLAY_RSA + Else + print_server_options(build_mode, args(i)) + End If + Else + print_server_options(build_mode, args(i)) + End If + Else + print_server_options(build_mode, args(i)) + End If + End If + + i += 1 + End While + + ' Create socket for incoming connections + Dim ep As IPEndPoint = New IPEndPoint(IPAddress.Any, port) + Dim server_sock As TcpListener = New TcpListener(ep) + server_sock.Start() + + '********************************************************************* + ' This is where the interesting stuff happens. Up until now we've + ' just been setting up sockets etc. Now we do the SSL handshake. + '*********************************************************************/ + Dim ssl_ctx As SSLServer = New SSLServer(options, _ + axtls.SSL_DEFAULT_SVR_SESS) + + If ssl_ctx Is Nothing Then + Console.Error.WriteLine("Error: Server context is invalid") + Environment.Exit(1) + End If + + If private_key_file <> Nothing Then + Dim obj_type As Integer = axtls.SSL_OBJ_RSA_KEY + + If private_key_file.EndsWith(".p8") Then + obj_type = axtls.SSL_OBJ_PKCS8 + Else If (private_key_file.EndsWith(".p12")) + obj_type = axtls.SSL_OBJ_PKCS12 + End If + + If ssl_ctx.ObjLoad(obj_type, private_key_file, _ + password) <> axtls.SSL_OK Then + Console.Error.WriteLine("Error: Private key '" & _ + private_key_file & "' is undefined.") + Environment.Exit(1) + End If + End If + + For i = 0 To cert_index-1 + If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, _ + cert(i), Nothing) <> axtls.SSL_OK Then + Console.WriteLine("Certificate '" & cert(i) & _ + "' is undefined.") + Environment.Exit(1) + End If + Next + + For i = 0 To ca_cert_index-1 + If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, _ + ca_cert(i), Nothing) <> axtls.SSL_OK Then + Console.WriteLine("Certificate '" & ca_cert(i) & _ + "' is undefined.") + Environment.Exit(1) + End If + Next + + Dim buf As Byte() = Nothing + Dim res As Integer + Dim ssl As SSL + + While 1 + If Not quiet Then + Console.WriteLine("ACCEPT") + End If + + Dim client_sock As Socket = server_sock.AcceptSocket() + + ssl = ssl_ctx.Connect(client_sock) + + ' do the actual SSL handshake + While 1 + res = ssl_ctx.Read(ssl, buf) + If res <> axtls.SSL_OK Then + Exit While + End If + + ' check when the connection has been established + If ssl.HandshakeStatus() = axtls.SSL_OK + Exit While + End If + + ' could do something else here + End While + + If res = axtls.SSL_OK Then ' connection established and ok + If Not quiet + display_session_id(ssl) + display_cipher(ssl) + End If + + ' now read (and display) whatever the client sends us + While 1 + ' keep reading until we get something interesting + While 1 + res = ssl_ctx.Read(ssl, buf) + If res <> axtls.SSL_OK Then + Exit While + End If + + ' could do something else here + End While + + If res < axtls.SSL_OK + If Not quiet + Console.WriteLine("CONNECTION CLOSED") + End If + + Exit While + End If + + ' convert to String + Dim str(res) As Char + For i = 0 To res-1 + str(i) = Chr(buf(i)) + Next + + Console.Write(str) + End While + ElseIf Not quiet + SSLUtil.DisplayError(res) + End If + + ' client was disconnected or the handshake failed. */ + ssl.Dispose() + client_sock.Close() + End While + + ssl_ctx.Dispose() + End Sub + + ' + ' do_client() + ' + Public Sub do_client(ByVal build_mode As Integer, _ + ByVal args() As String) + + If build_mode < axtls.SSL_BUILD_ENABLE_CLIENT Then + print_client_options(build_mode, args(1)) + End If + + Dim i As Integer = 1 + Dim res As Integer + Dim port As Integer = 4433 + Dim quiet As Boolean = False + Dim password As String = Nothing + Dim reconnect As Integer = 0 + Dim private_key_file As String = Nothing + Dim hostname As String = "127.0.0.1" + + ' organise the cert/ca_cert lists + Dim ssl As SSL = Nothing + Dim cert_size As Integer = SSLUtil.MaxCerts() + Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() + Dim cert(cert_size) As String + Dim ca_cert(ca_cert_size) As String + Dim cert_index As Integer = 0 + Dim ca_cert_index As Integer = 0 + + Dim options As Integer = _ + axtls.SSL_SERVER_VERIFY_LATER Or axtls.SSL_DISPLAY_CERTS + Dim session_id As Byte() = Nothing + + While i < args.Length + If args(i) = "-connect" Then + Dim host_port As String + + If i >= args.Length-1 + print_client_options(build_mode, args(i)) + End If + + i += 1 + host_port = args(i) + + Dim index_colon As Integer = host_port.IndexOf(":"C) + If index_colon < 0 Then + print_client_options(build_mode, args(i)) + End If + + hostname = New String(host_port.ToCharArray(), _ + 0, index_colon) + port = Int32.Parse(New String(host_port.ToCharArray(), _ + index_colon+1, host_port.Length-index_colon-1)) + ElseIf args(i) = "-cert" + If i >= args.Length-1 Or cert_index >= cert_size Then + print_client_options(build_mode, args(i)) + End If + + i += 1 + cert(cert_index) = args(i) + cert_index += 1 + ElseIf args(i) = "-key" + If i >= args.Length-1 + print_client_options(build_mode, args(i)) + End If + + i += 1 + private_key_file = args(i) + options = options Or axtls.SSL_NO_DEFAULT_KEY + ElseIf args(i) = "-CAfile" + If i >= args.Length-1 Or ca_cert_index >= ca_cert_size + print_client_options(build_mode, args(i)) + End If + + i += 1 + ca_cert(ca_cert_index) = args(i) + ca_cert_index += 1 + ElseIf args(i) = "-verify" + options = options And Not axtls.SSL_SERVER_VERIFY_LATER + ElseIf args(i) = "-reconnect" + reconnect = 4 + ElseIf args(i) = "-quiet" + quiet = True + options = options And Not axtls.SSL_DISPLAY_CERTS + ElseIf args(i) = "-pass" + If i >= args.Length-1 + print_client_options(build_mode, args(i)) + End If + + i += 1 + password = args(i) + ElseIf build_mode = axtls.SSL_BUILD_FULL_MODE + If args(i) = "-debug" Then + options = options Or axtls.SSL_DISPLAY_BYTES + ElseIf args(i) = "-state" + options = options Or axtls.SSL_DISPLAY_STATES + ElseIf args(i) = "-show-rsa" + options = options Or axtls.SSL_DISPLAY_RSA + Else + print_client_options(build_mode, args(i)) + End If + Else ' don't know what this is + print_client_options(build_mode, args(i)) + End If + + i += 1 + End While + + 'Dim hostInfo As IPHostEntry = Dns.Resolve(hostname) + Dim hostInfo As IPHostEntry = Dns.GetHostEntry(hostname) + Dim addresses As IPAddress() = hostInfo.AddressList + Dim ep As IPEndPoint = New IPEndPoint(addresses(0), port) + Dim client_sock As Socket = New Socket(AddressFamily.InterNetwork, _ + SocketType.Stream, ProtocolType.Tcp) + client_sock.Connect(ep) + + If Not client_sock.Connected Then + Console.WriteLine("could not connect") + Environment.Exit(1) + End If + + If Not quiet Then + Console.WriteLine("CONNECTED") + End If + + '********************************************************************* + ' This is where the interesting stuff happens. Up until now we've + ' just been setting up sockets etc. Now we do the SSL handshake. + '*********************************************************************/ + Dim ssl_ctx As SSLClient = New SSLClient(options, _ + axtls.SSL_DEFAULT_CLNT_SESS) + + If ssl_ctx Is Nothing Then + Console.Error.WriteLine("Error: Client context is invalid") + Environment.Exit(1) + End If + + If private_key_file <> Nothing Then + Dim obj_type As Integer = axtls.SSL_OBJ_RSA_KEY + + If private_key_file.EndsWith(".p8") Then + obj_type = axtls.SSL_OBJ_PKCS8 + Else If (private_key_file.EndsWith(".p12")) + obj_type = axtls.SSL_OBJ_PKCS12 + End If + + If ssl_ctx.ObjLoad(obj_type, private_key_file, _ + password) <> axtls.SSL_OK Then + Console.Error.WriteLine("Error: Private key '" & _ + private_key_file & "' is undefined.") + Environment.Exit(1) + End If + End If + + For i = 0 To cert_index-1 + If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, _ + cert(i), Nothing) <> axtls.SSL_OK Then + Console.WriteLine("Certificate '" & cert(i) & _ + "' is undefined.") + Environment.Exit(1) + End If + Next + + For i = 0 To ca_cert_index-1 + If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, _ + ca_cert(i), Nothing) <> axtls.SSL_OK Then + Console.WriteLine("Certificate '" & ca_cert(i) & _ + "' is undefined.") + Environment.Exit(1) + End If + Next + + ' Try session resumption? + If reconnect > 0 Then + While reconnect > 0 + reconnect -= 1 + ssl = ssl_ctx.Connect(client_sock, session_id) + + res = ssl.HandshakeStatus() + If res <> axtls.SSL_OK Then + If Not quiet Then + SSLUtil.DisplayError(res) + End If + + ssl.Dispose() + Environment.Exit(1) + End If + + display_session_id(ssl) + session_id = ssl.GetSessionId() + + If reconnect > 0 Then + ssl.Dispose() + client_sock.Close() + + ' and reconnect + client_sock = New Socket(AddressFamily.InterNetwork, _ + SocketType.Stream, ProtocolType.Tcp) + client_sock.Connect(ep) + End If + End While + Else + ssl = ssl_ctx.Connect(client_sock, Nothing) + End If + + ' check the return status + res = ssl.HandshakeStatus() + If res <> axtls.SSL_OK Then + If Not quiet Then + SSLUtil.DisplayError(res) + End If + + Environment.Exit(1) + End If + + If Not quiet Then + Dim common_name As String = _ + ssl.GetCertificateDN(axtls.SSL_X509_CERT_COMMON_NAME) + + If common_name <> Nothing + Console.WriteLine("Common Name:" & _ + ControlChars.Tab & ControlChars.Tab & _ + ControlChars.Tab & common_name) + End If + + display_session_id(ssl) + display_cipher(ssl) + End If + + While (1) + Dim user_input As String = Console.ReadLine() + + If user_input = Nothing Then + Exit While + End If + + Dim buf(user_input.Length+1) As Byte + buf(buf.Length-2) = Asc(ControlChars.Lf) ' add the carriage return + buf(buf.Length-1) = 0 ' null terminate + + For i = 0 To user_input.Length-1 + buf(i) = Asc(user_input.Chars(i)) + Next + + res = ssl_ctx.Write(ssl, buf, buf.Length) + If res < axtls.SSL_OK Then + If Not quiet Then + SSLUtil.DisplayError(res) + End If + + Exit While + End If + End While + + ssl_ctx.Dispose() + End Sub + + ' + ' Display what cipher we are using + ' + Private Sub display_cipher(ByVal ssl As SSL) + Console.Write("CIPHER is ") + + Select ssl.GetCipherId() + Case axtls.SSL_AES128_SHA + Console.WriteLine("AES128-SHA") + + Case axtls.SSL_AES256_SHA + Console.WriteLine("AES256-SHA") + + Case axtls.SSL_AES128_SHA256 + Console.WriteLine("AES128-SHA256") + + Case axtls.SSL_AES256_SHA256 + Console.WriteLine("AES256-SHA256") + + Case Else + Console.WriteLine("Unknown - " & ssl.GetCipherId()) + End Select + End Sub + + ' + ' Display what session id we have. + ' + Private Sub display_session_id(ByVal ssl As SSL) + Dim session_id As Byte() = ssl.GetSessionId() + + If session_id.Length > 0 Then + Console.WriteLine("-----BEGIN SSL SESSION PARAMETERS-----") + Dim b As Byte + For Each b In session_id + Console.Write("{0:x02}", b) + Next + + Console.WriteLine() + Console.WriteLine("-----END SSL SESSION PARAMETERS-----") + End If + End Sub + + ' + ' We've had some sort of command-line error. Print out the basic options. + ' + Public Sub print_options(ByVal options As String) + Console.WriteLine("axssl: Error: '" & options & _ + "' is an invalid command.") + Console.WriteLine("usage: axssl.vbnet [s_server|s_client|" & _ + "version] [args ...]") + Environment.Exit(1) + End Sub + + ' + ' We've had some sort of command-line error. Print out the server options. + ' + Private Sub print_server_options(ByVal build_mode As Integer, _ + ByVal options As String) + Dim cert_size As Integer = SSLUtil.MaxCerts() + Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() + + Console.WriteLine("unknown option " & options) + Console.WriteLine("usage: s_server [args ...]") + Console.WriteLine(" -accept arg" & ControlChars.Tab & _ + "- port to accept on (default is 4433)") + Console.WriteLine(" -quiet" & ControlChars.Tab & ControlChars.Tab & _ + "- No server output") + If build_mode >= axtls.SSL_BUILD_SERVER_ONLY + Console.WriteLine(" -cert arg" & ControlChars.Tab & _ + "- certificate file to add (in addition to default) to chain -") + Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ + " Can repeat up to " & cert_size & " times") + Console.WriteLine(" -key arg" & ControlChars.Tab & _ + "- Private key file to use") + Console.WriteLine(" -pass" & ControlChars.Tab & ControlChars.Tab & _ + "- private key file pass phrase source") + End If + + If build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION + Console.WriteLine(" -verify" & ControlChars.Tab & _ + "- turn on peer certificate verification") + Console.WriteLine(" -CAfile arg" & ControlChars.Tab & _ + "- Certificate authority") + Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ + " Can repeat up to " & ca_cert_size & " times") + End If + + If build_mode = axtls.SSL_BUILD_FULL_MODE + Console.WriteLine(" -debug" & _ + ControlChars.Tab & ControlChars.Tab & _ + "- Print more output") + Console.WriteLine(" -state" & _ + ControlChars.Tab & ControlChars.Tab & _ + "- Show state messages") + Console.WriteLine(" -show-rsa" & _ + ControlChars.Tab & "- Show RSA state") + End If + + Environment.Exit(1) + End Sub + + ' + ' We've had some sort of command-line error. Print out the client options. + ' + Private Sub print_client_options(ByVal build_mode As Integer, _ + ByVal options As String) + Dim cert_size As Integer = SSLUtil.MaxCerts() + Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() + + Console.WriteLine("unknown option " & options) + + If build_mode >= axtls.SSL_BUILD_ENABLE_CLIENT Then + Console.WriteLine("usage: s_client [args ...]") + Console.WriteLine(" -connect host:port - who to connect to " & _ + "(default is localhost:4433)") + Console.WriteLine(" -verify" & ControlChars.Tab & _ + "- turn on peer certificate verification") + Console.WriteLine(" -cert arg" & ControlChars.Tab & _ + "- certificate file to use") + Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ + " Can repeat up to " & cert_size & " times") + Console.WriteLine(" -key arg" & ControlChars.Tab & _ + "- Private key file to use") + Console.WriteLine(" -CAfile arg" & ControlChars.Tab & _ + "- Certificate authority") + Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ + " Can repeat up to " & ca_cert_size & " times") + Console.WriteLine(" -quiet" & _ + ControlChars.Tab & ControlChars.Tab & "- No client output") + Console.WriteLine(" -pass" & ControlChars.Tab & _ + ControlChars.Tab & _ + "- private key file pass phrase source") + Console.WriteLine(" -reconnect" & ControlChars.Tab & _ + "- Drop and re-make the " & _ + "connection with the same Session-ID") + + If build_mode = axtls.SSL_BUILD_FULL_MODE Then + Console.WriteLine(" -debug" & _ + ControlChars.Tab & ControlChars.Tab & _ + "- Print more output") + Console.WriteLine(" -state" & _ + ControlChars.Tab & ControlChars.Tab & _ + "- Show state messages") + Console.WriteLine(" -show-rsa" & ControlChars.Tab & _ + "- Show RSA state") + End If + Else + Console.WriteLine("Change configuration to allow this feature") + End If + + Environment.Exit(1) + End Sub + +End Class + +Public Module MyMain + Function Main(ByVal args() As String) As Integer + Dim runner As axssl = New axssl() + + If args.Length = 1 And args(0) = "version" Then + Console.WriteLine("axssl.vbnet " & SSLUtil.Version()) + Environment.Exit(0) + End If + + If args.Length < 1 + runner.print_options("") + ElseIf args(0) <> "s_server" And args(0) <> "s_client" + runner.print_options(args(0)) + End If + + Dim build_mode As Integer = SSLUtil.BuildMode() + + If args(0) = "s_server" Then + runner.do_server(build_mode, args) + Else + runner.do_client(build_mode, args) + End If + End Function +End Module diff --git a/user/mpy/lib/axtls/ssl/BigIntConfig.in b/user/mpy/lib/axtls/ssl/BigIntConfig.in new file mode 100644 index 0000000..116ce17 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/BigIntConfig.in @@ -0,0 +1,145 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/config/Kconfig-language.txt +# + +menu "BigInt Options" + depends on !CONFIG_SSL_SKELETON_MODE + +choice + prompt "Reduction Algorithm" + default CONFIG_BIGINT_BARRETT + +config CONFIG_BIGINT_CLASSICAL + bool "Classical" + help + Classical uses standard division. It has no limitations and is + theoretically the slowest due to the divisions used. For this particular + implementation it is surprisingly quite fast. + +config CONFIG_BIGINT_MONTGOMERY + bool "Montgomery" + help + Montgomery uses simple addition and multiplication to achieve its + performance. It has the limitation that 0 <= x, y < m, and so is not + used when CRT is active. + + This option will not be normally selected. + +config CONFIG_BIGINT_BARRETT + bool "Barrett" + help + Barrett performs expensive precomputation before reduction and partial + multiplies for computational speed. + + It is about 40% faster than Classical/Montgomery with the expense of + about 2kB, and so this option is normally selected. + +endchoice + +config CONFIG_BIGINT_CRT + bool "Chinese Remainder Theorem (CRT)" + default y + help + Allow the Chinese Remainder Theorem (CRT) to be used. + + Uses a number of extra coefficients from the private key to improve the + performance of a decryption. This feature is one of the most + significant performance improvements (it reduces a decryption time by + over 3 times). + + This option should be selected. + +config CONFIG_BIGINT_KARATSUBA + bool "Karatsuba Multiplication" + default n + help + Allow Karasuba multiplication to be used. + + Uses 3 multiplications (plus a number of additions/subtractions) + instead of 4. Multiplications are O(N^2) but addition/subtraction + is O(N) hence for large numbers is beneficial. For this project, the + effect was only useful for 4096 bit keys (for 32 bit processors). For + 8 bit processors this option might be a possibility. + + It costs about 2kB to enable it. + +config MUL_KARATSUBA_THRESH + int "Karatsuba Multiplication Theshold" + default 20 + depends on CONFIG_BIGINT_KARATSUBA + help + The minimum number of components needed before Karasuba muliplication + is used. + + This is very dependent on the speed/implementation of bi_add()/ + bi_subtract(). There is a bit of trial and error here and will be + at a different point for different architectures. + +config SQU_KARATSUBA_THRESH + int "Karatsuba Square Threshold" + default 40 + depends on CONFIG_BIGINT_KARATSUBA && CONFIG_BIGINT_SQUARE + help + The minimum number of components needed before Karatsuba squaring + is used. + + This is very dependent on the speed/implementation of bi_add()/ + bi_subtract(). There is a bit of trial and error here and will be + at a different point for different architectures. + +config CONFIG_BIGINT_SLIDING_WINDOW + bool "Sliding Window Exponentiation" + default y + help + Allow Sliding-Window Exponentiation to be used. + + Potentially processes more than 1 bit at a time when doing + exponentiation. The sliding-window technique reduces the number of + precomputations compared to other precomputed techniques. + + It results in a considerable performance improvement with it enabled + (it halves the decryption time) and so should be selected. + +config CONFIG_BIGINT_SQUARE + bool "Square Algorithm" + default y + help + Allow squaring to be used instead of a multiplication. It uses + 1/2 of the standard multiplies to obtain its performance. + It gives a 20% speed improvement overall and so should be selected. + +config CONFIG_BIGINT_CHECK_ON + bool "BigInt Integrity Checking" + default n if !CONFIG_DEBUG + default y if CONFIG_DEBUG + help + This is used when developing bigint algorithms. It performs a sanity + check on all operations at the expense of speed. + + This option is only selected when developing and should normally be + turned off. + +choice + prompt "Integer Size" + default CONFIG_INTEGER_32BIT + +config CONFIG_INTEGER_32BIT + bool "32" + help + The native integer size is 32 bits or higher. + + +config CONFIG_INTEGER_16BIT + bool "16" + help + The native integer size is 16 bits. + +config CONFIG_INTEGER_8BIT + bool "8" + help + The native integer size is 8 bits. + +endchoice +endmenu + diff --git a/user/mpy/lib/axtls/ssl/Config.in b/user/mpy/lib/axtls/ssl/Config.in new file mode 100644 index 0000000..aac4144 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/Config.in @@ -0,0 +1,341 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/config/Kconfig-language.txt +# + +menu "SSL Library" + +choice + prompt "Mode" + default CONFIG_SSL_FULL_MODE + +config CONFIG_SSL_SERVER_ONLY + bool "Server only - no verification" + help + Enable server functionality (no client functionality). + This mode still supports sessions and chaining (which can be turned + off in configuration). + + The axssl sample runs with the minimum of features. + + This is the most space efficient of the modes with the library + about 45kB in size. Use this mode if you are doing standard SSL server + work. + +config CONFIG_SSL_CERT_VERIFICATION + bool "Server only - with verification" + help + Enable server functionality with client authentication (no client + functionality). + + The axssl sample runs with the "-verify" and "-CAfile" options. + + This mode produces a library about 49kB in size. Use this mode if you + have an SSL server which requires client authentication (which is + uncommon in browser applications). + + +config CONFIG_SSL_FULL_MODE + bool "Client/Server enabled with diagnostics" + help + Enable client/server functionality including diagnostics. Most of the + extra size in this mode is due to the storage of various strings that + are used. + + The axssl sample has 3 more options, "-debug", "-state" and "-show-rsa" + + This mode produces a library about 58kB in size. It is suggested that + this mode is used only during development, or systems that have more + generous memory limits. + + It is the default to demonstrate the features of axTLS. + +config CONFIG_SSL_SKELETON_MODE + bool "Skeleton mode - the smallest server mode" + help + This is an experiment to build the smallest library at the expense of + features and speed. + + * Server mode only. + * The AES cipher is disabled. + * No session resumption. + * No external keys/certificates are supported. + * The bigint library has most of the performance features disabled. + * Some other features/API calls may not work. + + This mode produces a library about 37kB in size. The main + disadvantage of this mode is speed - it will be much slower than the + other build modes. + +endchoice + +config CONFIG_SSL_ENABLE_SERVER + bool "Server enabled" + help + Enable server functionality. + +config CONFIG_SSL_ENABLE_CLIENT + bool "Client enabled" + help + Enable client functionality. + + The axssl sample runs with the "s_client" option enabled. + + This mode produces a library about 51kB in size. Use this mode if you + require axTLS to use SSL client functionality (the SSL server code + is always enabled). + +config CONFIG_SSL_DIAGNOSTICS + bool "Diagnostic messages" + help + Enable support for diagnostics of connection progress and state. + +choice + prompt "Protocol Preference" +# depends on !CONFIG_SSL_SKELETON_MODE + default CONFIG_SSL_PROT_MEDIUM + +config CONFIG_SSL_PROT_LOW + bool "Low" + help + Chooses the cipher in the order of AES128-SHA, AES128-SHA256, + AES256-SHA256. + + This will use the fastest cipher(s) but at the expense of security. + +config CONFIG_SSL_PROT_MEDIUM + bool "Medium" + help + Chooses the cipher in the order of AES128-SHA256, AES256-SHA256, + AES128-SHA + + This mode is a balance between speed and security and is the default. + +config CONFIG_SSL_PROT_HIGH + bool "High" + help + Chooses the cipher in the order of AES256-SHA256, AES128-SHA256, + AES128-SHA. + + This will use the strongest cipher(s) at the cost of speed. + +endchoice + +config CONFIG_SSL_AES + bool "Enable AES cipher" + default y + help + Enable/disable AES support. + +config CONFIG_SSL_USE_DEFAULT_KEY + bool "Enable default key" +# depends on !CONFIG_SSL_SKELETON_MODE + default y + help + Some applications will not require the default private key/certificate + that is built in. This is one way to save on a couple of kB's if an + external private key/certificate is used. + + The private key is in ssl/private_key.h and the certificate is in + ssl/cert.h. + + The advantage of a built-in private key/certificate is that no file + system is required for access. Both the certificate and the private + key will be automatically loaded on a ssl_ctx_new(). + + However this private key/certificate can never be changed (without a + code update). + + This mode is enabled by default. Disable this mode if the + built-in key/certificate is not used. + +config CONFIG_SSL_PRIVATE_KEY_LOCATION + string "Private key file location" + depends on !CONFIG_SSL_USE_DEFAULT_KEY && !CONFIG_SSL_SKELETON_MODE + help + The file location of the private key which will be automatically + loaded on a ssl_ctx_new(). + +config CONFIG_SSL_PRIVATE_KEY_PASSWORD + string "Private key password" + depends on !CONFIG_SSL_USE_DEFAULT_KEY && CONFIG_SSL_HAS_PEM + help + The password required to decrypt a PEM-encoded password file. + +config CONFIG_SSL_X509_CERT_LOCATION + string "X.509 certificate file location" + depends on !CONFIG_SSL_GENERATE_X509_CERT && !CONFIG_SSL_USE_DEFAULT_KEY && !CONFIG_SSL_SKELETON_MODE + help + The file location of the X.509 certificate which will be automatically + loaded on a ssl_ctx_new(). + +config CONFIG_SSL_GENERATE_X509_CERT + bool "Generate X.509 Certificate" + default n + help + An X.509 certificate can be automatically generated on a + ssl_ctx_new(). A private key still needs to be provided (the private + key in ss/private_key.h will be used unless + CONFIG_SSL_PRIVATE_KEY_LOCATION is set). + + The certificate is generated on the fly, and so a minor start-up time + penalty is to be expected. This feature adds around 5kB to the + library. + + This feature is disabled by default. + +config CONFIG_SSL_X509_COMMON_NAME + string "X.509 Common Name" + depends on CONFIG_SSL_GENERATE_X509_CERT + help + The common name for the X.509 certificate. This should be the fully + qualified domain name (FQDN), e.g. www.foo.com. + + If this is blank, then this will be value from gethostname() and + getdomainname(). + +config CONFIG_SSL_X509_ORGANIZATION_NAME + string "X.509 Organization Name" + depends on CONFIG_SSL_GENERATE_X509_CERT + help + The organization name for the generated X.509 certificate. + + This field is optional. + +config CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME + string "X.509 Organization Unit Name" + depends on CONFIG_SSL_GENERATE_X509_CERT + help + The organization unit name for the generated X.509 certificate. + + This field is optional. + +config CONFIG_SSL_HAS_PEM + bool "Enable PEM" + default n if !CONFIG_SSL_FULL_MODE + default y if CONFIG_SSL_FULL_MODE + depends on !CONFIG_SSL_SKELETON_MODE + help + Enable the use of PEM format for certificates and private keys. + + PEM is not normally needed - PEM files can be converted into DER files + quite easily. However they have the convenience of allowing multiple + certificates/keys in the same file. + + This feature will add a couple of kB to the library. + + Disable if PEM is not used (which will be in most cases). + +config CONFIG_SSL_USE_PKCS12 + bool "Use PKCS8/PKCS12" + default n if !CONFIG_SSL_FULL_MODE + default y if CONFIG_SSL_FULL_MODE + depends on !CONFIG_SSL_SKELETON_MODE + help + PKCS#12 certificates combine private keys and certificates together in + one file. + + PKCS#8 private keys are also suppported (as it is a subset of PKCS#12). + + The decryption of these certificates uses RC4-128 (and these + certificates must be encrypted using this cipher). The actual + algorithm is "PBE-SHA1-RC4-128". + + Disable if PKCS#12 is not used (which will be in most cases). + +config CONFIG_SSL_EXPIRY_TIME + int "Session expiry time (in hours)" + depends on !CONFIG_SSL_SKELETON_MODE + default 24 + help + The time (in hours) before a session expires. + + A longer time means that the expensive parts of a handshake don't + need to be run when a client reconnects later. + + The default is 1 day. + +config CONFIG_X509_MAX_CA_CERTS + int "Maximum number of certificate authorites" + default 150 +# depends on !CONFIG_SSL_SERVER_ONLY && !CONFIG_SSL_SKELETON_MODE + help + Determines the number of CA's allowed. + + Increase this figure if more trusted sites are allowed. Each + certificate adds about 300 bytes (when added). + + The default is to allow the Debian cert bundle to be parsed. + +config CONFIG_SSL_MAX_CERTS + int "Maximum number of chained certificates" + default 3 + help + Determines the number of certificates used in a certificate + chain. The chain length must be at least 1. + + Increase this figure if more certificates are to be added to the + chain. Each certificate adds about 300 bytes (when added). + + The default is to allow one certificate + 2 certificates in the chain. + +config CONFIG_SSL_CTX_MUTEXING + bool "Enable SSL_CTX mutexing" + default n + help + Normally mutexing is not required - each SSL_CTX object can deal with + many SSL objects (as long as each SSL_CTX object is using a single + thread). + + If the SSL_CTX object is not thread safe e.g. the case where a + new thread is created for each SSL object, then mutexing is required. + + Select y when a mutex on the SSL_CTX object is required. + +config CONFIG_USE_DEV_URANDOM + bool "Use /dev/urandom" + default y + depends on !CONFIG_PLATFORM_WIN32 + help + Use /dev/urandom. Otherwise a custom RNG is used. + + This will be the default on most Linux systems. + +config CONFIG_WIN32_USE_CRYPTO_LIB + bool "Use Win32 Crypto Library" + depends on CONFIG_PLATFORM_WIN32 + help + Microsoft produce a Crypto API which requires the Platform SDK to be + installed. It's used for the RNG. + + This will be the default on most Win32 systems. + +config CONFIG_OPENSSL_COMPATIBLE + bool "Enable openssl API compatibility" + default n + help + To ease the porting of openssl applications, a subset of the openssl + API is wrapped around the axTLS API. + + Note: not all the API is implemented, so parts may still break. And + it's definitely not 100% compatible. + +config CONFIG_PERFORMANCE_TESTING + bool "Build the bigint performance test tool" + default n + depends on CONFIG_SSL_CERT_VERIFICATION + help + Used for performance testing of bigint. + + This is a testing tool and is normally disabled. + +config CONFIG_SSL_TEST + bool "Build the SSL testing tool" + default n + depends on CONFIG_SSL_FULL_MODE && !CONFIG_SSL_GENERATE_X509_CERT + help + Used for sanity checking the SSL handshaking. + + This is a testing tool and is normally disabled. + +endmenu diff --git a/user/mpy/lib/axtls/ssl/Makefile b/user/mpy/lib/axtls/ssl/Makefile new file mode 100644 index 0000000..a222884 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/Makefile @@ -0,0 +1,125 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +AXTLS_HOME=.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +all: libs +ifdef CONFIG_PERFORMANCE_TESTING + $(MAKE) -C test +else +ifdef CONFIG_SSL_TEST + $(MAKE) -C test +endif +endif + +ifndef CONFIG_PLATFORM_WIN32 +TARGET1=$(AXTLS_HOME)/$(STAGE)/libaxtls.a +BASETARGET=libaxtls.so +CRYPTO_PATH=$(AXTLS_HOME)/crypto/ +ifdef CONFIG_PLATFORM_CYGWIN +TARGET2=$(AXTLS_HOME)/$(STAGE)/libaxtls.dll.a +else +TARGET2=$(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) +endif + +# shared library major/minor numbers +LIBMAJOR=$(BASETARGET).1 +LIBMINOR=$(BASETARGET).1.2 +else +TARGET1=$(AXTLS_HOME)/$(STAGE)/axtls.lib +TARGET2=$(AXTLS_HOME)/$(STAGE)/axtls.dll +STATIC_LIB=$(AXTLS_HOME)/$(STAGE)/axtls.static.lib +CRYPTO_PATH=$(AXTLS_HOME)\\crypto\\ +endif + +libs: $(TARGET1) #$(TARGET2) + +CRYPTO_OBJ=\ + $(CRYPTO_PATH)aes.o \ + $(CRYPTO_PATH)bigint.o \ + $(CRYPTO_PATH)crypto_misc.o \ + $(CRYPTO_PATH)hmac.o \ + $(CRYPTO_PATH)md5.o \ + $(CRYPTO_PATH)rc4.o \ + $(CRYPTO_PATH)rsa.o \ + $(CRYPTO_PATH)sha1.o \ + $(CRYPTO_PATH)sha256.o \ + $(CRYPTO_PATH)sha384.o \ + $(CRYPTO_PATH)sha512.o + +OBJ=\ + asn1.o \ + gen_cert.o \ + loader.o \ + openssl.o \ + os_port.o \ + p12.o \ + tls1.o \ + tls1_svr.o \ + tls1_clnt.o \ + x509.o + +include $(AXTLS_HOME)/config/makefile.post + +ifndef CONFIG_PLATFORM_WIN32 # Linux/Unix/Cygwin + +$(TARGET1) : $(CRYPTO_OBJ) $(OBJ) + $(AR) -rcs $@ $(CRYPTO_OBJ) $(OBJ) + +$(TARGET2) : $(CRYPTO_OBJ) $(OBJ) +ifndef CONFIG_PLATFORM_CYGWIN + $(LD) $(LDFLAGS) $(LDSHARED) -Wl,-soname,$(LIBMAJOR) -o $(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) $(CRYPTO_OBJ) $(OBJ) + cd $(AXTLS_HOME)/$(STAGE); ln -sf $(LIBMINOR) $(LIBMAJOR); ln -sf $(LIBMAJOR) $(BASETARGET); cd - +else + $(LD) $(LDFLAGS) $(LDSHARED) -o $(AXTLS_HOME)/$(STAGE)/cygaxtls.dll \ + -Wl,--out-implib=$(AXTLS_HOME)/$(STAGE)/libaxtls.dll.a \ + -Wl,--export-all-symbols \ + -Wl,--enable-auto-import $(CRYPTO_OBJ) $(OBJ) +endif + +else # Win32 +CRYPTO_OBJ:=$(CRYPTO_OBJ:.o=.obj) + +$(TARGET1) : $(OBJ) + $(AR) /out:$@ $(CRYPTO_OBJ) $(OBJ) + +$(TARGET2) : $(OBJ) + cp $(TARGET1) $(STATIC_LIB) + $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(CRYPTO_OBJ) $(OBJ) + +endif + +clean:: + $(MAKE) -C test clean + -@rm -f $(AXTLS_HOME)/$(STAGE)/* *.a $(TARGET1) $(TARGET2) + diff --git a/user/mpy/lib/axtls/ssl/asn1.c b/user/mpy/lib/axtls/ssl/asn1.c new file mode 100644 index 0000000..6f85257 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/asn1.c @@ -0,0 +1,776 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Some primitive asn methods for extraction ASN.1 data. + */ + +#include +#include +#include +#include +#include "os_port.h" +#include "crypto.h" +#include "crypto_misc.h" + +/* 1.2.840.113549.1.1 OID prefix - handle the following */ +/* md5WithRSAEncryption(4) */ +/* sha1WithRSAEncryption(5) */ +/* sha256WithRSAEncryption (11) */ +/* sha384WithRSAEncryption (12) */ +/* sha512WithRSAEncryption (13) */ +static const uint8_t sig_oid_prefix[] = +{ + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01 +}; + +/* 1.3.14.3.2.29 SHA1 with RSA signature */ +static const uint8_t sig_sha1WithRSAEncrypt[] = +{ + 0x2b, 0x0e, 0x03, 0x02, 0x1d +}; + +/* 2.16.840.1.101.3.4.2.1 SHA-256 */ +static const uint8_t sig_sha256[] = +{ + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 +}; + +/* 2.16.840.1.101.3.4.2.2 SHA-384 */ +static const uint8_t sig_sha384[] = +{ + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 +}; + +/* 2.16.840.1.101.3.4.2.3 SHA-512 */ +static const uint8_t sig_sha512[] = +{ + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 +}; + +static const uint8_t sig_subject_alt_name[] = +{ + 0x55, 0x1d, 0x11 +}; + +static const uint8_t sig_basic_constraints[] = +{ + 0x55, 0x1d, 0x13 +}; + +static const uint8_t sig_key_usage[] = +{ + 0x55, 0x1d, 0x0f +}; + +/* CN, O, OU, L, C, ST */ +static const uint8_t g_dn_types[] = { 3, 10, 11, 7, 6, 8 }; + +uint32_t get_asn1_length(const uint8_t *buf, int *offset) +{ + int i; + uint32_t len; + + if (!(buf[*offset] & 0x80)) /* short form */ + { + len = buf[(*offset)++]; + } + else /* long form */ + { + int length_bytes = buf[(*offset)++]&0x7f; + if (length_bytes > 4) /* limit number of bytes */ + return 0; + + len = 0; + for (i = 0; i < length_bytes; i++) + { + len <<= 8; + len += buf[(*offset)++]; + } + } + + return len; +} + +/** + * Skip the ASN1.1 object type and its length. Get ready to read the object's + * data. + */ +int asn1_next_obj(const uint8_t *buf, int *offset, int obj_type) +{ + if (buf[*offset] != obj_type) + return X509_NOT_OK; + + (*offset)++; + return get_asn1_length(buf, offset); +} + +/** + * Skip over an ASN.1 object type completely. Get ready to read the next + * object. + */ +int asn1_skip_obj(const uint8_t *buf, int *offset, int obj_type) +{ + int len; + + if (buf[*offset] != obj_type) + return X509_NOT_OK; + (*offset)++; + len = get_asn1_length(buf, offset); + *offset += len; + return 0; +} + +/** + * Read an integer value for ASN.1 data + * Note: This function allocates memory which must be freed by the user. + */ +int asn1_get_big_int(const uint8_t *buf, int *offset, uint8_t **object) +{ + int len; + + if ((len = asn1_next_obj(buf, offset, ASN1_INTEGER)) < 0) + goto end_big_int; + + if (len > 1 && buf[*offset] == 0x00) /* ignore the negative byte */ + { + len--; + (*offset)++; + } + + *object = (uint8_t *)malloc(len); + memcpy(*object, &buf[*offset], len); + *offset += len; + +end_big_int: + return len; +} + +/** + * Read an integer value for ASN.1 data + */ +int asn1_get_int(const uint8_t *buf, int *offset, int32_t *val) +{ + int res = X509_OK; + int len; + int i; + + if ((len = asn1_next_obj(buf, offset, ASN1_INTEGER)) < 0 || + len > sizeof(int32_t)) + { + res = X509_NOT_OK; + goto end_int; + } + + *val = 0; + for (i = 0; i < len; i++) + { + *val <<= 8; + *val |= buf[(*offset)++]; + } + +end_int: + return res; +} + +/** + * Read an boolean value for ASN.1 data + */ +int asn1_get_bool(const uint8_t *buf, int *offset, bool *val) +{ + int res = X509_OK; + + if (asn1_next_obj(buf, offset, ASN1_BOOLEAN) != 1) + { + res = X509_NOT_OK; + goto end_bool; + } + + /* DER demands that "If the encoding represents the boolean value TRUE, + its single contents octet shall have all eight bits set to one." + Thus only 0 and 255 are valid encoded values. */ + *val = buf[(*offset)++] == 0xFF; + +end_bool: + return res; +} + +/** + * Convert an ASN.1 bit string into a 32 bit integer. Used for key usage + */ +int asn1_get_bit_string_as_int(const uint8_t *buf, int *offset, uint32_t *val) +{ + int res = X509_OK; + int len, i; + + if ((len = asn1_next_obj(buf, offset, ASN1_BIT_STRING)) < 0 || len > 5) + { + res = X509_NOT_OK; + goto end_bit_string_as_int; + } + + /* number of bits left unused in the final byte of content */ + (*offset)++; + len--; + *val = 0; + + /* not sure why key usage doesn't used proper DER spec version */ + for (i = len-1; i >= 0; --i) + { + *val <<= 8; + *val |= buf[(*offset) + i]; + } + + *offset += len; + +end_bit_string_as_int: + return res; +} + +/** + * Get all the RSA private key specifics from an ASN.1 encoded file + */ +int asn1_get_private_key(const uint8_t *buf, int len, RSA_CTX **rsa_ctx) +{ + int offset = 7; + uint8_t *modulus = NULL, *priv_exp = NULL, *pub_exp = NULL; + int mod_len, priv_len, pub_len; +#ifdef CONFIG_BIGINT_CRT + uint8_t *p = NULL, *q = NULL, *dP = NULL, *dQ = NULL, *qInv = NULL; + int p_len, q_len, dP_len, dQ_len, qInv_len; +#endif + + /* not in der format */ + if (buf[0] != ASN1_SEQUENCE) /* basic sanity check */ + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: This is not a valid ASN.1 file\n"); +#endif + return X509_INVALID_PRIV_KEY; + } + + /* Use the private key to mix up the RNG if possible. */ + RNG_custom_init(buf, len); + + mod_len = asn1_get_big_int(buf, &offset, &modulus); + pub_len = asn1_get_big_int(buf, &offset, &pub_exp); + priv_len = asn1_get_big_int(buf, &offset, &priv_exp); + + if (mod_len <= 0 || pub_len <= 0 || priv_len <= 0) + return X509_INVALID_PRIV_KEY; + +#ifdef CONFIG_BIGINT_CRT + p_len = asn1_get_big_int(buf, &offset, &p); + q_len = asn1_get_big_int(buf, &offset, &q); + dP_len = asn1_get_big_int(buf, &offset, &dP); + dQ_len = asn1_get_big_int(buf, &offset, &dQ); + qInv_len = asn1_get_big_int(buf, &offset, &qInv); + + if (p_len <= 0 || q_len <= 0 || dP_len <= 0 || dQ_len <= 0 || qInv_len <= 0) + return X509_INVALID_PRIV_KEY; + + RSA_priv_key_new(rsa_ctx, + modulus, mod_len, pub_exp, pub_len, priv_exp, priv_len, + p, p_len, q, p_len, dP, dP_len, dQ, dQ_len, qInv, qInv_len); + + free(p); + free(q); + free(dP); + free(dQ); + free(qInv); +#else + RSA_priv_key_new(rsa_ctx, + modulus, mod_len, pub_exp, pub_len, priv_exp, priv_len); +#endif + + free(modulus); + free(priv_exp); + free(pub_exp); + return X509_OK; +} + +/** + * Get the time of a certificate. Ignore hours/minutes/seconds. + */ +static int asn1_get_utc_time(const uint8_t *buf, int *offset, time_t *t) +{ + int ret = X509_NOT_OK, len, t_offset, abs_year; + struct tm tm; + + /* see http://tools.ietf.org/html/rfc5280#section-4.1.2.5 */ + if (buf[*offset] == ASN1_UTC_TIME) + { + (*offset)++; + + len = get_asn1_length(buf, offset); + t_offset = *offset; + + memset(&tm, 0, sizeof(struct tm)); + tm.tm_year = (buf[t_offset] - '0')*10 + (buf[t_offset+1] - '0'); + + if (tm.tm_year < 50) /* 1951-2050 thing */ + { + tm.tm_year += 100; + } + + tm.tm_mon = (buf[t_offset+2] - '0')*10 + (buf[t_offset+3] - '0') - 1; + tm.tm_mday = (buf[t_offset+4] - '0')*10 + (buf[t_offset+5] - '0'); + tm.tm_hour = (buf[t_offset+6] - '0')*10 + (buf[t_offset+7] - '0'); + tm.tm_min = (buf[t_offset+8] - '0')*10 + (buf[t_offset+9] - '0'); + tm.tm_sec = (buf[t_offset+10] - '0')*10 + (buf[t_offset+11] - '0'); + *t = mktime(&tm); + *offset += len; + ret = X509_OK; + } + else if (buf[*offset] == ASN1_GENERALIZED_TIME) + { + (*offset)++; + + len = get_asn1_length(buf, offset); + t_offset = *offset; + + memset(&tm, 0, sizeof(struct tm)); + abs_year = ((buf[t_offset] - '0')*1000 + + (buf[t_offset+1] - '0')*100 + (buf[t_offset+2] - '0')*10 + + (buf[t_offset+3] - '0')); + + if (abs_year <= 1901) + { + tm.tm_year = 1; + tm.tm_mon = 0; + tm.tm_mday = 1; + } + else + { + tm.tm_year = abs_year - 1900; + tm.tm_mon = (buf[t_offset+4] - '0')*10 + + (buf[t_offset+5] - '0') - 1; + tm.tm_mday = (buf[t_offset+6] - '0')*10 + (buf[t_offset+7] - '0'); + tm.tm_hour = (buf[t_offset+8] - '0')*10 + (buf[t_offset+9] - '0'); + tm.tm_min = (buf[t_offset+10] - '0')*10 + (buf[t_offset+11] - '0'); + tm.tm_sec = (buf[t_offset+12] - '0')*10 + (buf[t_offset+13] - '0'); + *t = mktime(&tm); + } + + *offset += len; + ret = X509_OK; + } + + return ret; +} + +/** + * Get the version type of a certificate + */ +int asn1_version(const uint8_t *cert, int *offset, int *val) +{ + (*offset) += 2; /* get past explicit tag */ + return asn1_get_int(cert, offset, val); +} + +/** + * Retrieve the notbefore and notafter certificate times. + */ +int asn1_validity(const uint8_t *cert, int *offset, X509_CTX *x509_ctx) +{ + return (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0 || + asn1_get_utc_time(cert, offset, &x509_ctx->not_before) || + asn1_get_utc_time(cert, offset, &x509_ctx->not_after)); +} + +/** + * Get the components of a distinguished name + */ +static int asn1_get_oid_x520(const uint8_t *buf, int *offset) +{ + int dn_type = 0; + int len; + + if ((len = asn1_next_obj(buf, offset, ASN1_OID)) < 0) + goto end_oid; + + /* expect a sequence of 2.5.4.[x] where x is a one of distinguished name + components we are interested in. */ + if (len == 3 && buf[(*offset)++] == 0x55 && buf[(*offset)++] == 0x04) + dn_type = buf[(*offset)++]; + else + { + *offset += len; /* skip over it */ + } + +end_oid: + return dn_type; +} + +/** + * Obtain an ASN.1 printable string type. + */ +static int asn1_get_printable_str(const uint8_t *buf, int *offset, char **str) +{ + int len = X509_NOT_OK; + int asn1_type = buf[*offset]; + + /* some certs have this awful crud in them for some reason */ + if (asn1_type != ASN1_PRINTABLE_STR && + asn1_type != ASN1_PRINTABLE_STR2 && + asn1_type != ASN1_TELETEX_STR && + asn1_type != ASN1_IA5_STR && + asn1_type != ASN1_UNICODE_STR) + goto end_pnt_str; + + (*offset)++; + len = get_asn1_length(buf, offset); + + if (asn1_type == ASN1_UNICODE_STR) + { + int i; + *str = (char *)malloc(len/2+1); /* allow for null */ + + for (i = 0; i < len; i += 2) + (*str)[i/2] = buf[*offset + i + 1]; + + (*str)[len/2] = 0; /* null terminate */ + } + else + { + *str = (char *)malloc(len+1); /* allow for null */ + memcpy(*str, &buf[*offset], len); + (*str)[len] = 0; /* null terminate */ + } + + *offset += len; + +end_pnt_str: + return len; +} + +/** + * Get the subject name (or the issuer) of a certificate. + */ +int asn1_name(const uint8_t *cert, int *offset, char *dn[]) +{ + int ret = X509_NOT_OK; + int dn_type; + char *tmp; + + if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0) + goto end_name; + + while (asn1_next_obj(cert, offset, ASN1_SET) >= 0) + { + int i, found = 0; + + if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0 || + (dn_type = asn1_get_oid_x520(cert, offset)) < 0) + goto end_name; + + tmp = NULL; + + if (asn1_get_printable_str(cert, offset, &tmp) < 0) + { + free(tmp); + goto end_name; + } + + /* find the distinguished named type */ + for (i = 0; i < X509_NUM_DN_TYPES; i++) + { + if (dn_type == g_dn_types[i]) + { + if (dn[i] == NULL) + { + dn[i] = tmp; + found = 1; + break; + } + } + } + + if (found == 0) /* not found so get rid of it */ + { + free(tmp); + } + } + + ret = X509_OK; +end_name: + return ret; +} + +/** + * Read the modulus and public exponent of a certificate. + */ +int asn1_public_key(const uint8_t *cert, int *offset, X509_CTX *x509_ctx) +{ + int ret = X509_NOT_OK, mod_len, pub_len; + uint8_t *modulus = NULL, *pub_exp = NULL; + + if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(cert, offset, ASN1_SEQUENCE) || + asn1_next_obj(cert, offset, ASN1_BIT_STRING) < 0) + goto end_pub_key; + + (*offset)++; /* ignore the padding bit field */ + + if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0) + goto end_pub_key; + + mod_len = asn1_get_big_int(cert, offset, &modulus); + pub_len = asn1_get_big_int(cert, offset, &pub_exp); + + RSA_pub_key_new(&x509_ctx->rsa_ctx, modulus, mod_len, pub_exp, pub_len); + + free(modulus); + free(pub_exp); + ret = X509_OK; + +end_pub_key: + return ret; +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION +/** + * Read the signature of the certificate. + */ +int asn1_signature(const uint8_t *cert, int *offset, X509_CTX *x509_ctx) +{ + int ret = X509_NOT_OK; + + if (cert[(*offset)++] != ASN1_BIT_STRING) + goto end_sig; + + x509_ctx->sig_len = get_asn1_length(cert, offset)-1; + (*offset)++; /* ignore bit string padding bits */ + x509_ctx->signature = (uint8_t *)malloc(x509_ctx->sig_len); + memcpy(x509_ctx->signature, &cert[*offset], x509_ctx->sig_len); + *offset += x509_ctx->sig_len; + ret = X509_OK; + +end_sig: + return ret; +} + +/* + * Compare 2 distinguished name components for equality + * @return 0 if a match + */ +static int asn1_compare_dn_comp(const char *dn1, const char *dn2) +{ + int ret; + + if (dn1 == NULL && dn2 == NULL) + ret = 0; + else + ret = (dn1 && dn2) ? strcmp(dn1, dn2) : 1; + + return ret; +} + +/** + * Clean up all of the CA certificates. + */ +void remove_ca_certs(CA_CERT_CTX *ca_cert_ctx) +{ + int i = 0; + + if (ca_cert_ctx == NULL) + return; + + while (i < CONFIG_X509_MAX_CA_CERTS && ca_cert_ctx->cert[i]) + { + x509_free(ca_cert_ctx->cert[i]); + ca_cert_ctx->cert[i++] = NULL; + } + + free(ca_cert_ctx); +} + +/* + * Compare 2 distinguished names for equality + * @return 0 if a match + */ +int asn1_compare_dn(char * const dn1[], char * const dn2[]) +{ + int i; + + for (i = 0; i < X509_NUM_DN_TYPES; i++) + { + if (asn1_compare_dn_comp(dn1[i], dn2[i])) + return 1; + } + + return 0; /* all good */ +} + +int asn1_find_oid(const uint8_t* cert, int* offset, + const uint8_t* oid, int oid_length) +{ + int seqlen; + if ((seqlen = asn1_next_obj(cert, offset, ASN1_SEQUENCE))> 0) + { + int end = *offset + seqlen; + + while (*offset < end) + { + int type = cert[(*offset)++]; + int length = get_asn1_length(cert, offset); + int noffset = *offset + length; + + if (type == ASN1_SEQUENCE) + { + type = cert[(*offset)++]; + length = get_asn1_length(cert, offset); + + if (type == ASN1_OID && length == oid_length && + memcmp(cert + *offset, oid, oid_length) == 0) + { + *offset += oid_length; + return 1; + } + } + + *offset = noffset; + } + } + + return 0; +} + +int asn1_is_subject_alt_name(const uint8_t *cert, int offset) +{ + if (asn1_find_oid(cert, &offset, sig_subject_alt_name, + sizeof(sig_subject_alt_name))) + { + return offset; + } + + return 0; +} + +int asn1_is_basic_constraints(const uint8_t *cert, int offset) +{ + if (asn1_find_oid(cert, &offset, sig_basic_constraints, + sizeof(sig_basic_constraints))) + { + return offset; + } + + return 0; +} + +int asn1_is_key_usage(const uint8_t *cert, int offset) +{ + if (asn1_find_oid(cert, &offset, sig_key_usage, + sizeof(sig_key_usage))) + { + return offset; + } + + return 0; +} + +bool asn1_is_critical_ext(const uint8_t *buf, int *offset) +{ + /* critical is optional */ + bool res = false; + + if (asn1_next_obj(buf, offset, ASN1_BOOLEAN) == 1) + res = buf[(*offset)++] == 0xFF; + + return res; +} + +#endif /* CONFIG_SSL_CERT_VERIFICATION */ + +/** + * Read the signature type of the certificate. We only support RSA-MD5 and + * RSA-SHA1 signature types. + */ +int asn1_signature_type(const uint8_t *cert, + int *offset, X509_CTX *x509_ctx) +{ + int ret = X509_NOT_OK, len; + + if (cert[(*offset)++] != ASN1_OID) + goto end_check_sig; + + len = get_asn1_length(cert, offset); + + if (len == sizeof(sig_sha1WithRSAEncrypt) && + memcmp(sig_sha1WithRSAEncrypt, &cert[*offset], + sizeof(sig_sha1WithRSAEncrypt)) == 0) + { + x509_ctx->sig_type = SIG_TYPE_SHA1; + } + else if (len == sizeof(sig_sha256) && + memcmp(sig_sha256, &cert[*offset], + sizeof(sig_sha256)) == 0) + { + x509_ctx->sig_type = SIG_TYPE_SHA256; + } + else if (len == sizeof(sig_sha384) && + memcmp(sig_sha384, &cert[*offset], + sizeof(sig_sha384)) == 0) + { + x509_ctx->sig_type = SIG_TYPE_SHA384; + } + else if (len == sizeof(sig_sha512) && + memcmp(sig_sha512, &cert[*offset], + sizeof(sig_sha512)) == 0) + { + x509_ctx->sig_type = SIG_TYPE_SHA512; + } + else + { + if (memcmp(sig_oid_prefix, &cert[*offset], sizeof(sig_oid_prefix))) + { +#ifdef CONFIG_SSL_FULL_MODE + int i; + printf("invalid digest: "); + + for (i = 0; i < len; i++) + printf("%02x ", cert[*offset + i]); + + printf("\n"); +#endif + goto end_check_sig; /* unrecognised cert type */ + } + + x509_ctx->sig_type = cert[*offset + sizeof(sig_oid_prefix)]; + } + + *offset += len; + asn1_skip_obj(cert, offset, ASN1_NULL); /* if it's there */ + ret = X509_OK; + +end_check_sig: + return ret; +} + diff --git a/user/mpy/lib/axtls/ssl/cert.h b/user/mpy/lib/axtls/ssl/cert.h new file mode 100644 index 0000000..40234b9 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/cert.h @@ -0,0 +1,54 @@ +unsigned char default_certificate[] = { + 0x30, 0x82, 0x02, 0x58, 0x30, 0x82, 0x01, 0x40, 0x02, 0x09, 0x00, 0xa5, + 0x2a, 0xc8, 0x78, 0x87, 0xf2, 0xe7, 0xc5, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x34, + 0x31, 0x32, 0x30, 0x30, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x29, 0x61, + 0x78, 0x54, 0x4c, 0x53, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x20, 0x44, 0x6f, 0x64, 0x67, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, + 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x31, 0x32, + 0x33, 0x30, 0x32, 0x31, 0x30, 0x34, 0x32, 0x37, 0x5a, 0x17, 0x0d, 0x33, + 0x30, 0x30, 0x39, 0x30, 0x38, 0x32, 0x31, 0x30, 0x34, 0x32, 0x37, 0x5a, + 0x30, 0x2c, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, + 0x0d, 0x61, 0x78, 0x54, 0x4c, 0x53, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, + 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x81, + 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, + 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, + 0x81, 0x81, 0x00, 0xbd, 0x0f, 0xd4, 0x42, 0xa8, 0x74, 0x87, 0x54, 0xaa, + 0xb9, 0x3a, 0x1f, 0x8b, 0xce, 0xbd, 0xb7, 0x65, 0xfb, 0x40, 0x3d, 0xd0, + 0x11, 0x9a, 0x9c, 0xdc, 0x82, 0x7c, 0xea, 0xa8, 0x17, 0xe1, 0x74, 0xf3, + 0x05, 0x0e, 0x61, 0xc1, 0xc1, 0x78, 0x8a, 0xb2, 0xba, 0x15, 0x22, 0x5a, + 0xff, 0x9b, 0xb8, 0x7a, 0x2e, 0x0f, 0x88, 0xb7, 0x74, 0xde, 0x04, 0x99, + 0xa5, 0xa2, 0x99, 0x53, 0x8b, 0xad, 0x78, 0x5a, 0x31, 0xed, 0xbc, 0x01, + 0xe7, 0xdf, 0xe9, 0xec, 0x2f, 0xa0, 0x5d, 0x53, 0xf6, 0xe6, 0x8a, 0xa0, + 0xc8, 0x6d, 0x41, 0x45, 0x63, 0x23, 0xb3, 0xcf, 0x4e, 0x50, 0x1f, 0x28, + 0xdf, 0x36, 0xe2, 0x73, 0xdf, 0xd6, 0xa1, 0xb3, 0x46, 0x4f, 0x6e, 0xbb, + 0x0d, 0x9b, 0xef, 0xa8, 0xf9, 0x4c, 0xa5, 0x71, 0xa1, 0x88, 0xdd, 0x07, + 0xa9, 0x86, 0x0d, 0x3f, 0xcd, 0x99, 0x23, 0xa2, 0x84, 0x77, 0x0f, 0x02, + 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, + 0x32, 0xe0, 0x3c, 0x6e, 0x21, 0xe6, 0xa6, 0xf4, 0xb8, 0x10, 0x9f, 0x8a, + 0xe6, 0x0b, 0x84, 0x4e, 0x2c, 0xe5, 0x14, 0xca, 0x56, 0x81, 0x3f, 0xc0, + 0x2c, 0xa3, 0x39, 0x89, 0x24, 0xce, 0xaf, 0x47, 0x2e, 0x19, 0x62, 0xb2, + 0xe4, 0x76, 0x91, 0x25, 0xbc, 0xe1, 0xa8, 0xee, 0x6a, 0x68, 0x3a, 0x77, + 0xb9, 0xb2, 0x62, 0x97, 0x0c, 0x25, 0x3c, 0x5e, 0x13, 0x48, 0x87, 0x80, + 0xa3, 0x91, 0xd9, 0x2e, 0xe6, 0x92, 0x2b, 0x1c, 0x52, 0x24, 0xb1, 0x77, + 0xc6, 0xf6, 0xde, 0xd8, 0x9b, 0xd9, 0x57, 0x37, 0x56, 0x68, 0x17, 0x32, + 0x66, 0x01, 0x08, 0x38, 0x08, 0x9a, 0xc1, 0x8c, 0x5e, 0x3f, 0xe7, 0xc9, + 0x44, 0xcb, 0x62, 0xb9, 0x48, 0xc7, 0x89, 0xa6, 0xff, 0x8e, 0x7d, 0x3d, + 0xe1, 0x46, 0x32, 0x9c, 0x13, 0x06, 0x9a, 0xd1, 0x17, 0xab, 0x3f, 0xa9, + 0x90, 0x04, 0x33, 0x2d, 0x3f, 0x81, 0x0a, 0xa5, 0x55, 0xce, 0xb6, 0x95, + 0x54, 0xad, 0xf1, 0x4f, 0xa2, 0xca, 0xc3, 0xf6, 0x25, 0x7b, 0x71, 0xd2, + 0x68, 0x85, 0xe9, 0x72, 0xb6, 0x99, 0x34, 0x6d, 0xe5, 0x5f, 0xf6, 0x74, + 0x1c, 0xb9, 0xa2, 0xda, 0x2b, 0x04, 0xff, 0x82, 0xc5, 0x09, 0x04, 0xc4, + 0xba, 0xbc, 0x82, 0x3e, 0xb4, 0x72, 0x18, 0x8e, 0x30, 0x68, 0x48, 0x4a, + 0x0d, 0xa7, 0x3d, 0xb5, 0xf4, 0x42, 0x3a, 0x97, 0x60, 0x7d, 0xa8, 0x61, + 0x8a, 0x9e, 0x98, 0xc4, 0x7e, 0x65, 0x99, 0xea, 0x7e, 0xca, 0x75, 0xe7, + 0xdb, 0x21, 0x5d, 0xce, 0x7c, 0x66, 0x3d, 0x7e, 0xdc, 0x14, 0xfe, 0x55, + 0x04, 0x97, 0xa8, 0x64, 0x12, 0xb4, 0xb5, 0x30, 0x48, 0x72, 0xbc, 0xdb, + 0xeb, 0x5b, 0x4f, 0xa6, 0xfb, 0x87, 0x01, 0x41, 0x91, 0xec, 0x98, 0x98, + 0xf1, 0x4b, 0x38, 0xa2, 0x40, 0xf1, 0x05, 0x90, 0xbb, 0x9b, 0x5d, 0x96, + 0xb1, 0x22, 0x6b, 0x50 +}; +unsigned int default_certificate_len = 604; diff --git a/user/mpy/lib/axtls/ssl/crypto_misc.h b/user/mpy/lib/axtls/ssl/crypto_misc.h new file mode 100644 index 0000000..21b59cb --- /dev/null +++ b/user/mpy/lib/axtls/ssl/crypto_misc.h @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2007-2017, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** + * @file crypto_misc.h + */ + +#ifndef HEADER_CRYPTO_MISC_H +#define HEADER_CRYPTO_MISC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "crypto.h" +#include "bigint.h" + +/************************************************************************** + * X509 declarations + **************************************************************************/ +#define X509_OK 0 +#define X509_NOT_OK -1 +#define X509_VFY_ERROR_NO_TRUSTED_CERT -2 +#define X509_VFY_ERROR_BAD_SIGNATURE -3 +#define X509_VFY_ERROR_NOT_YET_VALID -4 +#define X509_VFY_ERROR_EXPIRED -5 +#define X509_VFY_ERROR_SELF_SIGNED -6 +#define X509_VFY_ERROR_INVALID_CHAIN -7 +#define X509_VFY_ERROR_UNSUPPORTED_DIGEST -8 +#define X509_INVALID_PRIV_KEY -9 +#define X509_MAX_CERTS -10 +#define X509_VFY_ERROR_BASIC_CONSTRAINT -11 + +/* + * The Distinguished Name + */ +#define X509_NUM_DN_TYPES 6 +#define X509_COMMON_NAME 0 +#define X509_ORGANIZATION 1 +#define X509_ORGANIZATIONAL_UNIT 2 +#define X509_LOCATION 3 +#define X509_COUNTRY 4 +#define X509_STATE 5 + +/* + * Key Usage bits + */ +#define IS_SET_KEY_USAGE_FLAG(A, B) (A->key_usage & B) + +#define KEY_USAGE_DIGITAL_SIGNATURE 0x0080 +#define KEY_USAGE_NON_REPUDIATION 0x0040 +#define KEY_USAGE_KEY_ENCIPHERMENT 0x0020 +#define KEY_USAGE_DATA_ENCIPHERMENT 0x0010 +#define KEY_USAGE_KEY_AGREEMENT 0x0008 +#define KEY_USAGE_KEY_CERT_SIGN 0x0004 +#define KEY_USAGE_CRL_SIGN 0x0002 +#define KEY_USAGE_ENCIPHER_ONLY 0x0001 +#define KEY_USAGE_DECIPHER_ONLY 0x8000 + +struct _x509_ctx +{ + char *ca_cert_dn[X509_NUM_DN_TYPES]; + char *cert_dn[X509_NUM_DN_TYPES]; + char **subject_alt_dnsnames; + time_t not_before; + time_t not_after; + uint8_t *signature; + RSA_CTX *rsa_ctx; + bigint *digest; + uint16_t sig_len; + uint8_t sig_type; + bool basic_constraint_present; + bool basic_constraint_is_critical; + bool key_usage_present; + bool key_usage_is_critical; + bool subject_alt_name_present; + bool subject_alt_name_is_critical; + bool basic_constraint_cA; + int basic_constraint_pathLenConstraint; + uint32_t key_usage; + struct _x509_ctx *next; +}; + +typedef struct _x509_ctx X509_CTX; + +//#ifdef CONFIG_SSL_CERT_VERIFICATION +typedef struct +{ + X509_CTX *cert[CONFIG_X509_MAX_CA_CERTS]; +} CA_CERT_CTX; +//#endif + +int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx); +void x509_free(X509_CTX *x509_ctx); +//#ifdef CONFIG_SSL_CERT_VERIFICATION +int x509_verify(const CA_CERT_CTX *ca_cert_ctx, const X509_CTX *cert, + int *pathLenConstraint); +//#endif +//#ifdef CONFIG_SSL_FULL_MODE +void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx); +const char * x509_display_error(int error); +//#endif + +/************************************************************************** + * ASN1 declarations + **************************************************************************/ +#define ASN1_BOOLEAN 0x01 +#define ASN1_INTEGER 0x02 +#define ASN1_BIT_STRING 0x03 +#define ASN1_OCTET_STRING 0x04 +#define ASN1_NULL 0x05 +#define ASN1_PRINTABLE_STR2 0x0C +#define ASN1_OID 0x06 +#define ASN1_PRINTABLE_STR2 0x0C +#define ASN1_PRINTABLE_STR 0x13 +#define ASN1_TELETEX_STR 0x14 +#define ASN1_IA5_STR 0x16 +#define ASN1_UTC_TIME 0x17 +#define ASN1_GENERALIZED_TIME 0x18 +#define ASN1_UNICODE_STR 0x1e +#define ASN1_SEQUENCE 0x30 +#define ASN1_CONTEXT_DNSNAME 0x82 +#define ASN1_SET 0x31 +#define ASN1_V3_DATA 0xa3 +#define ASN1_IMPLICIT_TAG 0x80 +#define ASN1_CONTEXT_DNSNAME 0x82 +#define ASN1_EXPLICIT_TAG 0xa0 +#define ASN1_V3_DATA 0xa3 + +#define SIG_TYPE_MD5 0x04 +#define SIG_TYPE_SHA1 0x05 +#define SIG_TYPE_SHA256 0x0b +#define SIG_TYPE_SHA384 0x0c +#define SIG_TYPE_SHA512 0x0d + +uint32_t get_asn1_length(const uint8_t *buf, int *offset); +int asn1_get_private_key(const uint8_t *buf, int len, RSA_CTX **rsa_ctx); +int asn1_next_obj(const uint8_t *buf, int *offset, int obj_type); +int asn1_skip_obj(const uint8_t *buf, int *offset, int obj_type); +int asn1_get_big_int(const uint8_t *buf, int *offset, uint8_t **object); +int asn1_get_int(const uint8_t *buf, int *offset, int32_t *val); +int asn1_get_bool(const uint8_t *buf, int *offset, bool *val); +int asn1_get_bit_string_as_int(const uint8_t *buf, int *offset, uint32_t *val); +int asn1_version(const uint8_t *cert, int *offset, int *val); +int asn1_validity(const uint8_t *cert, int *offset, X509_CTX *x509_ctx); +int asn1_name(const uint8_t *cert, int *offset, char *dn[]); +int asn1_public_key(const uint8_t *cert, int *offset, X509_CTX *x509_ctx); +#ifdef CONFIG_SSL_CERT_VERIFICATION +int asn1_signature(const uint8_t *cert, int *offset, X509_CTX *x509_ctx); +int asn1_compare_dn(char * const dn1[], char * const dn2[]); +int asn1_is_subject_alt_name(const uint8_t *cert, int offset); +int asn1_is_basic_constraints(const uint8_t *cert, int offset); +int asn1_is_key_usage(const uint8_t *cert, int offset); +bool asn1_is_critical_ext(const uint8_t *buf, int *offset); +#endif /* CONFIG_SSL_CERT_VERIFICATION */ +int asn1_signature_type(const uint8_t *cert, + int *offset, X509_CTX *x509_ctx); + +/************************************************************************** + * MISC declarations + **************************************************************************/ +#define SALT_SIZE 8 + +extern const char * const unsupported_str; + +typedef void (*crypt_func)(void *, const uint8_t *, uint8_t *, int); +typedef void (*hmac_func)(const uint8_t *msg, int length, const uint8_t *key, + int key_len, uint8_t *digest); + +int get_file(const char *filename, uint8_t **buf); + +#if defined(CONFIG_SSL_DIAGNOSTICS) || defined(WIN32) || defined(CONFIG_DEBUG) +EXP_FUNC void STDCALL print_blob(const char *format, const uint8_t *data, int size, ...); +#else + #define print_blob(...) +#endif + +EXP_FUNC int STDCALL base64_decode(const char *in, int len, + uint8_t *out, int *outlen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/axtls/ssl/gen_cert.c b/user/mpy/lib/axtls/ssl/gen_cert.c new file mode 100644 index 0000000..17ad38e --- /dev/null +++ b/user/mpy/lib/axtls/ssl/gen_cert.c @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2007-2014, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#ifdef CONFIG_SSL_GENERATE_X509_CERT +#include +#include +#include "os_port.h" +#include "ssl.h" + +/** + * Generate a basic X.509 certificate + */ + +static uint8_t set_gen_length(int len, uint8_t *buf, int *offset) +{ + if (len < 0x80) /* short form */ + { + buf[(*offset)++] = len; + return 1; + } + else /* long form */ + { + int i, length_bytes = 0; + + if (len & 0x00FF0000) + length_bytes = 3; + else if (len & 0x0000FF00) + length_bytes = 2; + else if (len & 0x000000FF) + length_bytes = 1; + + buf[(*offset)++] = 0x80 + length_bytes; + + for (i = length_bytes-1; i >= 0; i--) + { + buf[*offset+i] = len & 0xFF; + len >>= 8; + } + + *offset += length_bytes; + return length_bytes+1; + } +} + +static int pre_adjust_with_size(uint8_t type, + int *seq_offset, uint8_t *buf, int *offset) +{ + buf[(*offset)++] = type; + *seq_offset = *offset; + *offset += 4; /* fill in later */ + return *offset; +} + +static void adjust_with_size(int seq_size, int seq_start, + uint8_t *buf, int *offset) +{ + uint8_t seq_byte_size; + int orig_seq_size = seq_size; + int orig_seq_start = seq_start; + + seq_size = *offset-seq_size; + seq_byte_size = set_gen_length(seq_size, buf, &seq_start); + + if (seq_byte_size != 4) + { + memmove(&buf[orig_seq_start+seq_byte_size], + &buf[orig_seq_size], seq_size); + *offset -= 4-seq_byte_size; + } +} + +static void gen_serial_number(uint8_t *buf, int *offset) +{ + static const uint8_t ser_oid[] = { ASN1_INTEGER, 1, 0x7F }; + memcpy(&buf[*offset], ser_oid , sizeof(ser_oid)); + *offset += sizeof(ser_oid); +} + +static void gen_signature_alg(uint8_t *buf, int *offset) +{ + /* OBJECT IDENTIFIER sha1withRSAEncryption (1 2 840 113549 1 1 5) */ + static const uint8_t sig_oid[] = + { + ASN1_SEQUENCE, 0x0d, ASN1_OID, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, + ASN1_NULL, 0x00 + }; + + memcpy(&buf[*offset], sig_oid, sizeof(sig_oid)); + *offset += sizeof(sig_oid); +} + +static int gen_dn(const char *name, uint8_t dn_type, + uint8_t *buf, int *offset) +{ + int ret = X509_OK; + int name_size = strlen(name); + + if (name_size > 0x70) /* just too big */ + { + ret = X509_NOT_OK; + goto error; + } + + buf[(*offset)++] = ASN1_SET; + set_gen_length(9+name_size, buf, offset); + buf[(*offset)++] = ASN1_SEQUENCE; + set_gen_length(7+name_size, buf, offset); + buf[(*offset)++] = ASN1_OID; + buf[(*offset)++] = 3; + buf[(*offset)++] = 0x55; + buf[(*offset)++] = 0x04; + buf[(*offset)++] = dn_type; + buf[(*offset)++] = ASN1_PRINTABLE_STR; + buf[(*offset)++] = name_size; + strcpy((char *)&buf[*offset], name); + *offset += name_size; + +error: + return ret; +} + +static int gen_issuer(const char * dn[], uint8_t *buf, int *offset) +{ + int ret = X509_OK; + int seq_offset; + int seq_size = pre_adjust_with_size( + ASN1_SEQUENCE, &seq_offset, buf, offset); + char fqdn[128]; + + /* we need the common name, so if not configured, work out the fully + * qualified domain name */ + if (dn[X509_COMMON_NAME] == NULL || strlen(dn[X509_COMMON_NAME]) == 0) + { + int fqdn_len; + gethostname(fqdn, sizeof(fqdn)); + fqdn_len = strlen(fqdn); + fqdn[fqdn_len++] = '.'; + + if (getdomainname(&fqdn[fqdn_len], sizeof(fqdn)-fqdn_len) < 0) + { + ret = X509_NOT_OK; + goto error; + } + + fqdn_len = strlen(fqdn); + + if (fqdn[fqdn_len-1] == '.') /* ensure '.' is not last char */ + fqdn[fqdn_len-1] = 0; + + dn[X509_COMMON_NAME] = fqdn; + } + + if ((ret = gen_dn(dn[X509_COMMON_NAME], 3, buf, offset))) + goto error; + + if (dn[X509_ORGANIZATION] != NULL && strlen(dn[X509_ORGANIZATION]) > 0) + { + if ((ret = gen_dn(dn[X509_ORGANIZATION], 10, buf, offset))) + goto error; + } + + if (dn[X509_ORGANIZATIONAL_UNIT] != NULL && + strlen(dn[X509_ORGANIZATIONAL_UNIT]) > 0) + { + if ((ret = gen_dn(dn[X509_ORGANIZATIONAL_UNIT], 11, buf, offset))) + goto error; + } + + adjust_with_size(seq_size, seq_offset, buf, offset); + +error: + return ret; +} + +static void gen_utc_time(uint8_t *buf, int *offset) +{ + static const uint8_t time_seq[] = + { + ASN1_SEQUENCE, 30, + ASN1_UTC_TIME, 13, + '0', '7', '0', '1', '0', '1', '0', '0', '0', '0', '0', '0', 'Z', + ASN1_UTC_TIME, 13, /* make it good for 30 or so years */ + '3', '8', '0', '1', '0', '1', '0', '0', '0', '0', '0', '0', 'Z' + }; + + /* fixed time */ + memcpy(&buf[*offset], time_seq, sizeof(time_seq)); + *offset += sizeof(time_seq); +} + +static void gen_pub_key2(const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset) +{ + static const uint8_t pub_key_seq[] = + { + ASN1_INTEGER, 0x03, 0x01, 0x00, 0x01 /* INTEGER 65537 */ + }; + + int seq_offset; + int pub_key_size = rsa_ctx->num_octets; + uint8_t *block = (uint8_t *)alloca(pub_key_size); + int seq_size = pre_adjust_with_size( + ASN1_SEQUENCE, &seq_offset, buf, offset); + buf[(*offset)++] = ASN1_INTEGER; + bi_export(rsa_ctx->bi_ctx, rsa_ctx->m, block, pub_key_size); + + if (*block & 0x80) /* make integer positive */ + { + set_gen_length(pub_key_size+1, buf, offset); + buf[(*offset)++] = 0; + } + else + set_gen_length(pub_key_size, buf, offset); + + memcpy(&buf[*offset], block, pub_key_size); + *offset += pub_key_size; + memcpy(&buf[*offset], pub_key_seq, sizeof(pub_key_seq)); + *offset += sizeof(pub_key_seq); + adjust_with_size(seq_size, seq_offset, buf, offset); +} + +static void gen_pub_key1(const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset) +{ + int seq_offset; + int seq_size = pre_adjust_with_size( + ASN1_BIT_STRING, &seq_offset, buf, offset); + buf[(*offset)++] = 0; /* bit string is multiple of 8 */ + gen_pub_key2(rsa_ctx, buf, offset); + adjust_with_size(seq_size, seq_offset, buf, offset); +} + +static void gen_pub_key(const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset) +{ + /* OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1) */ + static const uint8_t rsa_enc_oid[] = + { + ASN1_SEQUENCE, 0x0d, ASN1_OID, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, + ASN1_NULL, 0x00 + }; + + int seq_offset; + int seq_size = pre_adjust_with_size( + ASN1_SEQUENCE, &seq_offset, buf, offset); + + memcpy(&buf[*offset], rsa_enc_oid, sizeof(rsa_enc_oid)); + *offset += sizeof(rsa_enc_oid); + gen_pub_key1(rsa_ctx, buf, offset); + adjust_with_size(seq_size, seq_offset, buf, offset); +} + +static void gen_signature(const RSA_CTX *rsa_ctx, const uint8_t *sha_dgst, + uint8_t *buf, int *offset) +{ + static const uint8_t asn1_sig[] = + { + ASN1_SEQUENCE, 0x21, ASN1_SEQUENCE, 0x09, ASN1_OID, 0x05, + 0x2b, 0x0e, 0x03, 0x02, 0x1a, /* sha1 (1 3 14 3 2 26) */ + ASN1_NULL, 0x00, ASN1_OCTET_STRING, 0x14 + }; + + uint8_t *enc_block = (uint8_t *)alloca(rsa_ctx->num_octets); + uint8_t *block = (uint8_t *)alloca(sizeof(asn1_sig) + SHA1_SIZE); + int sig_size; + + /* add the digest as an embedded asn.1 sequence */ + memcpy(block, asn1_sig, sizeof(asn1_sig)); + memcpy(&block[sizeof(asn1_sig)], sha_dgst, SHA1_SIZE); + + sig_size = RSA_encrypt(rsa_ctx, block, + sizeof(asn1_sig) + SHA1_SIZE, enc_block, 1); + + buf[(*offset)++] = ASN1_BIT_STRING; + set_gen_length(sig_size+1, buf, offset); + buf[(*offset)++] = 0; /* bit string is multiple of 8 */ + memcpy(&buf[*offset], enc_block, sig_size); + *offset += sig_size; +} + +static int gen_tbs_cert(const char * dn[], + const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset, + uint8_t *sha_dgst) +{ + int ret = X509_OK; + SHA1_CTX sha_ctx; + int seq_offset; + int begin_tbs = *offset; + int seq_size = pre_adjust_with_size( + ASN1_SEQUENCE, &seq_offset, buf, offset); + + gen_serial_number(buf, offset); + gen_signature_alg(buf, offset); + + /* CA certicate issuer */ + if ((ret = gen_issuer(dn, buf, offset))) + goto error; + + gen_utc_time(buf, offset); + + /* certificate issuer */ + if ((ret = gen_issuer(dn, buf, offset))) + goto error; + + gen_pub_key(rsa_ctx, buf, offset); + adjust_with_size(seq_size, seq_offset, buf, offset); + + SHA1_Init(&sha_ctx); + SHA1_Update(&sha_ctx, &buf[begin_tbs], *offset-begin_tbs); + SHA1_Final(sha_dgst, &sha_ctx); + +error: + return ret; +} + +/** + * Create a new certificate. + */ +EXP_FUNC int STDCALL ssl_x509_create(SSL_CTX *ssl_ctx, uint32_t options, const char * dn[], uint8_t **cert_data) +{ + int ret = X509_OK, offset = 0, seq_offset; + /* allocate enough space to load a new certificate */ + uint8_t *buf = (uint8_t *)alloca(ssl_ctx->rsa_ctx->num_octets*2 + 512); + uint8_t sha_dgst[SHA1_SIZE]; + int seq_size = pre_adjust_with_size(ASN1_SEQUENCE, + &seq_offset, buf, &offset); + + if ((ret = gen_tbs_cert(dn, ssl_ctx->rsa_ctx, buf, &offset, sha_dgst)) < 0) + goto error; + + gen_signature_alg(buf, &offset); + gen_signature(ssl_ctx->rsa_ctx, sha_dgst, buf, &offset); + adjust_with_size(seq_size, seq_offset, buf, &offset); + *cert_data = (uint8_t *)malloc(offset); /* create the exact memory for it */ + memcpy(*cert_data, buf, offset); + +error: + return ret < 0 ? ret : offset; +} + +#endif + diff --git a/user/mpy/lib/axtls/ssl/loader.c b/user/mpy/lib/axtls/ssl/loader.c new file mode 100644 index 0000000..38ed0bf --- /dev/null +++ b/user/mpy/lib/axtls/ssl/loader.c @@ -0,0 +1,492 @@ +/* + * Copyright (c) 2007-2014, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Load certificates/keys into memory. These can be in many different formats. + * PEM support and other formats can be processed here. + * + * The PEM private keys may be optionally encrypted with AES128 or AES256. + * The encrypted PEM keys were generated with something like: + * + * openssl genrsa -aes128 -passout pass:abcd -out axTLS.key_aes128.pem 512 + */ + +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +#if CONFIG_SSL_ENABLE_SERVER + +static int do_obj(SSL_CTX *ssl_ctx, int obj_type, + SSLObjLoader *ssl_obj, const char *password); +#ifdef CONFIG_SSL_HAS_PEM +static int ssl_obj_PEM_load(SSL_CTX *ssl_ctx, int obj_type, + SSLObjLoader *ssl_obj, const char *password); +#endif + +/* + * Load a file into memory that is in binary DER (or ascii PEM) format. + */ +EXP_FUNC int STDCALL ssl_obj_load(SSL_CTX *ssl_ctx, int obj_type, + const char *filename, const char *password) +{ +#ifndef CONFIG_SSL_SKELETON_MODE + static const char * const begin = "-----BEGIN"; + int ret = SSL_OK; + SSLObjLoader *ssl_obj = NULL; + + if (filename == NULL) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + + ssl_obj = (SSLObjLoader *)calloc(1, sizeof(SSLObjLoader)); + ssl_obj->len = get_file(filename, &ssl_obj->buf); + if (ssl_obj->len <= 0) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + + /* is the file a PEM file? */ + if (strstr((char *)ssl_obj->buf, begin) != NULL) + { +#ifdef CONFIG_SSL_HAS_PEM + ret = ssl_obj_PEM_load(ssl_ctx, obj_type, ssl_obj, password); +#else +#ifdef CONFIG_SSL_FULL_MODE + printf("%s", unsupported_str); +#endif + ret = SSL_ERROR_NOT_SUPPORTED; +#endif + } + else + ret = do_obj(ssl_ctx, obj_type, ssl_obj, password); + +error: + ssl_obj_free(ssl_obj); + return ret; +#else +#ifdef CONFIG_SSL_FULL_MODE + printf("%s", unsupported_str); +#endif + return SSL_ERROR_NOT_SUPPORTED; +#endif /* CONFIG_SSL_SKELETON_MODE */ +} + +/* + * Transfer binary data into the object loader. + */ +EXP_FUNC int STDCALL ssl_obj_memory_load(SSL_CTX *ssl_ctx, int mem_type, + const uint8_t *data, int len, const char *password) +{ + int ret; + SSLObjLoader *ssl_obj; + + ssl_obj = (SSLObjLoader *)calloc(1, sizeof(SSLObjLoader)); + ssl_obj->buf = (uint8_t *)malloc(len); + memcpy(ssl_obj->buf, data, len); + ssl_obj->len = len; + ret = do_obj(ssl_ctx, mem_type, ssl_obj, password); + ssl_obj_free(ssl_obj); + return ret; +} + +/* + * Actually work out what we are doing + */ +static int do_obj(SSL_CTX *ssl_ctx, int obj_type, + SSLObjLoader *ssl_obj, const char *password) +{ + int ret = SSL_OK; + + switch (obj_type) + { + case SSL_OBJ_RSA_KEY: + ret = add_private_key(ssl_ctx, ssl_obj); + break; + + case SSL_OBJ_X509_CERT: + ret = add_cert(ssl_ctx, ssl_obj->buf, ssl_obj->len); + break; + +#ifdef CONFIG_SSL_CERT_VERIFICATION + case SSL_OBJ_X509_CACERT: + add_cert_auth(ssl_ctx, ssl_obj->buf, ssl_obj->len); + break; +#endif + +#ifdef CONFIG_SSL_USE_PKCS12 + case SSL_OBJ_PKCS8: + ret = pkcs8_decode(ssl_ctx, ssl_obj, password); + break; + + case SSL_OBJ_PKCS12: + ret = pkcs12_decode(ssl_ctx, ssl_obj, password); + break; +#endif + default: +#ifdef CONFIG_SSL_FULL_MODE + printf("%s", unsupported_str); +#endif + ret = SSL_ERROR_NOT_SUPPORTED; + break; + } + + return ret; +} + +/* + * Clean up our mess. + */ +void ssl_obj_free(SSLObjLoader *ssl_obj) +{ + if (ssl_obj) + { + free(ssl_obj->buf); + free(ssl_obj); + } +} + +/* + * Support for PEM encoded keys/certificates. + */ +#ifdef CONFIG_SSL_HAS_PEM + +#define NUM_PEM_TYPES 4 +#define IV_SIZE 16 +#define IS_RSA_PRIVATE_KEY 0 +#define IS_ENCRYPTED_PRIVATE_KEY 1 +#define IS_PRIVATE_KEY 2 +#define IS_CERTIFICATE 3 + +static const char * const begins[NUM_PEM_TYPES] = +{ + "-----BEGIN RSA PRIVATE KEY-----", + "-----BEGIN ENCRYPTED PRIVATE KEY-----", + "-----BEGIN PRIVATE KEY-----", + "-----BEGIN CERTIFICATE-----", +}; + +static const char * const ends[NUM_PEM_TYPES] = +{ + "-----END RSA PRIVATE KEY-----", + "-----END ENCRYPTED PRIVATE KEY-----", + "-----END PRIVATE KEY-----", + "-----END CERTIFICATE-----", +}; + +static const char * const aes_str[2] = +{ + "DEK-Info: AES-128-CBC,", + "DEK-Info: AES-256-CBC," +}; + +/** + * Take a base64 blob of data and decrypt it (using AES) into its + * proper ASN.1 form. + */ +static int pem_decrypt(const char *where, const char *end, + const char *password, SSLObjLoader *ssl_obj) +{ + int ret = -1; + int is_aes_256 = 0; + char *start = NULL; + uint8_t iv[IV_SIZE]; + int i, pem_size; + MD5_CTX md5_ctx; + AES_CTX aes_ctx; + uint8_t key[32]; /* AES256 size */ + + if (password == NULL || strlen(password) == 0) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: Need a password for this PEM file\n"); +#endif + goto error; + } + + if ((start = strstr((const char *)where, aes_str[0]))) /* AES128? */ + { + start += strlen(aes_str[0]); + } + else if ((start = strstr((const char *)where, aes_str[1]))) /* AES256? */ + { + is_aes_256 = 1; + start += strlen(aes_str[1]); + } + else + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: Unsupported password cipher\n"); +#endif + goto error; + } + + /* convert from hex to binary - assumes uppercase hex */ + for (i = 0; i < IV_SIZE; i++) + { + char c = *start++ - '0'; + iv[i] = (c > 9 ? c + '0' - 'A' + 10 : c) << 4; + c = *start++ - '0'; + iv[i] += (c > 9 ? c + '0' - 'A' + 10 : c); + } + + while (*start == '\r' || *start == '\n') + start++; + + /* turn base64 into binary */ + pem_size = (int)(end-start); + if (base64_decode(start, pem_size, ssl_obj->buf, &ssl_obj->len) != 0) + goto error; + + /* work out the key */ + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, (const uint8_t *)password, strlen(password)); + MD5_Update(&md5_ctx, iv, SALT_SIZE); + MD5_Final(key, &md5_ctx); + + if (is_aes_256) + { + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, key, MD5_SIZE); + MD5_Update(&md5_ctx, (const uint8_t *)password, strlen(password)); + MD5_Update(&md5_ctx, iv, SALT_SIZE); + MD5_Final(&key[MD5_SIZE], &md5_ctx); + } + + /* decrypt using the key/iv */ + AES_set_key(&aes_ctx, key, iv, is_aes_256 ? AES_MODE_256 : AES_MODE_128); + AES_convert_key(&aes_ctx); + AES_cbc_decrypt(&aes_ctx, ssl_obj->buf, ssl_obj->buf, ssl_obj->len); + ret = 0; + +error: + return ret; +} + +/** + * Take a base64 blob of data and turn it into its proper ASN.1 form. + */ +static int new_pem_obj(SSL_CTX *ssl_ctx, int is_cacert, char *where, + int remain, const char *password) +{ + int ret = SSL_ERROR_BAD_CERTIFICATE; + SSLObjLoader *ssl_obj = NULL; + + while (remain > 0) + { + int i, pem_size, obj_type; + char *start = NULL, *end = NULL; + + for (i = 0; i < NUM_PEM_TYPES; i++) + { + if ((start = strstr(where, begins[i])) && + (end = strstr(where, ends[i]))) + { + remain -= (int)(end-where); + start += strlen(begins[i]); + pem_size = (int)(end-start); + + ssl_obj = (SSLObjLoader *)calloc(1, sizeof(SSLObjLoader)); + + /* 4/3 bigger than what we need but so what */ + ssl_obj->buf = (uint8_t *)calloc(1, pem_size); + ssl_obj->len = pem_size; + + if (i == IS_RSA_PRIVATE_KEY && + strstr(start, "Proc-Type:") && + strstr(start, "4,ENCRYPTED")) + { + /* check for encrypted PEM file */ + if (pem_decrypt(start, end, password, ssl_obj) < 0) + { + ret = SSL_ERROR_BAD_CERTIFICATE; + goto error; + } + } + else + { + ssl_obj->len = pem_size; + if (base64_decode(start, pem_size, + ssl_obj->buf, &ssl_obj->len) != 0) + { + ret = SSL_ERROR_BAD_CERTIFICATE; + goto error; + } + } + + switch (i) + { + case IS_RSA_PRIVATE_KEY: + obj_type = SSL_OBJ_RSA_KEY; + break; + + case IS_ENCRYPTED_PRIVATE_KEY: + case IS_PRIVATE_KEY: + obj_type = SSL_OBJ_PKCS8; + break; + + case IS_CERTIFICATE: + obj_type = is_cacert ? + SSL_OBJ_X509_CACERT : SSL_OBJ_X509_CERT; + break; + + default: + ret = SSL_ERROR_BAD_CERTIFICATE; + goto error; + } + + /* In a format we can now understand - so process it */ + if ((ret = do_obj(ssl_ctx, obj_type, ssl_obj, password))) + goto error; + + end += strlen(ends[i]); + remain -= strlen(ends[i]); + while (remain > 0 && (*end == '\r' || *end == '\n')) + { + end++; + remain--; + } + + where = end; + break; + } + } + + ssl_obj_free(ssl_obj); + ssl_obj = NULL; + if (start == NULL) + break; + } +error: + ssl_obj_free(ssl_obj); + return ret; +} + +/* + * Load a file into memory that is in ASCII PEM format. + */ +static int ssl_obj_PEM_load(SSL_CTX *ssl_ctx, int obj_type, + SSLObjLoader *ssl_obj, const char *password) +{ + char *start; + + /* add a null terminator */ + ssl_obj->len++; + ssl_obj->buf = (uint8_t *)realloc(ssl_obj->buf, ssl_obj->len); + ssl_obj->buf[ssl_obj->len-1] = 0; + start = (char *)ssl_obj->buf; + return new_pem_obj(ssl_ctx, obj_type == SSL_OBJ_X509_CACERT, + start, ssl_obj->len, password); +} +#endif /* CONFIG_SSL_HAS_PEM */ + +/** + * Load the key/certificates in memory depending on compile-time and user + * options. + */ +int load_key_certs(SSL_CTX *ssl_ctx) +{ + int ret = SSL_OK; + uint32_t options = ssl_ctx->options; +#ifdef CONFIG_SSL_GENERATE_X509_CERT + uint8_t *cert_data = NULL; + int cert_size; + static const char *dn[] = + { + CONFIG_SSL_X509_COMMON_NAME, + CONFIG_SSL_X509_ORGANIZATION_NAME, + CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME + }; +#endif + + /* do the private key first */ + if (strlen(CONFIG_SSL_PRIVATE_KEY_LOCATION) > 0) + { + if ((ret = ssl_obj_load(ssl_ctx, SSL_OBJ_RSA_KEY, + CONFIG_SSL_PRIVATE_KEY_LOCATION, + CONFIG_SSL_PRIVATE_KEY_PASSWORD)) < 0) + goto error; + } + else if (!(options & SSL_NO_DEFAULT_KEY)) + { +#if defined(CONFIG_SSL_USE_DEFAULT_KEY) || defined(CONFIG_SSL_SKELETON_MODE) + static const /* saves a few more bytes */ +#include "private_key.h" + + ssl_obj_memory_load(ssl_ctx, SSL_OBJ_RSA_KEY, default_private_key, + default_private_key_len, NULL); +#endif + } + + /* now load the certificate */ +#ifdef CONFIG_SSL_GENERATE_X509_CERT + if ((cert_size = ssl_x509_create(ssl_ctx, 0, dn, &cert_data)) < 0) + { + ret = cert_size; + goto error; + } + + ssl_obj_memory_load(ssl_ctx, SSL_OBJ_X509_CERT, cert_data, cert_size, NULL); + free(cert_data); +#else + if (strlen(CONFIG_SSL_X509_CERT_LOCATION)) + { + if ((ret = ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, + CONFIG_SSL_X509_CERT_LOCATION, NULL)) < 0) + goto error; + } + else if (!(options & SSL_NO_DEFAULT_KEY)) + { +#if defined(CONFIG_SSL_USE_DEFAULT_KEY) || defined(CONFIG_SSL_SKELETON_MODE) +#include "cert.h" + ssl_obj_memory_load(ssl_ctx, SSL_OBJ_X509_CERT, + default_certificate, default_certificate_len, NULL); +#endif + } +#endif + +error: +#ifdef CONFIG_SSL_FULL_MODE + if (ret) + { + printf("Error: Certificate or key not loaded\n"); + } +#endif + + return ret; + +} + +#endif diff --git a/user/mpy/lib/axtls/ssl/openssl.c b/user/mpy/lib/axtls/ssl/openssl.c new file mode 100644 index 0000000..d0343e5 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/openssl.c @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Enable a subset of openssl compatible functions. We don't aim to be 100% + * compatible - just to be able to do basic ports etc. + * + * Only really tested on mini_httpd, so I'm not too sure how extensive this + * port is. + */ + +#include "config.h" + +#ifdef CONFIG_OPENSSL_COMPATIBLE +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +#define OPENSSL_CTX_ATTR ((OPENSSL_CTX *)ssl_ctx->bonus_attr) + +static char *key_password = NULL; + +void *SSLv3_server_method(void) { return NULL; } +void *TLSv1_server_method(void) { return NULL; } +void *SSLv3_client_method(void) { return NULL; } +void *TLSv1_client_method(void) { return NULL; } + +typedef void * (*ssl_func_type_t)(void); +typedef void * (*bio_func_type_t)(void); + +typedef struct +{ + ssl_func_type_t ssl_func_type; +} OPENSSL_CTX; + +SSL_CTX * SSL_CTX_new(ssl_func_type_t meth) +{ + SSL_CTX *ssl_ctx = ssl_ctx_new(0, 5); + ssl_ctx->bonus_attr = malloc(sizeof(OPENSSL_CTX)); + OPENSSL_CTX_ATTR->ssl_func_type = meth; + return ssl_ctx; +} + +void SSL_CTX_free(SSL_CTX * ssl_ctx) +{ + free(ssl_ctx->bonus_attr); + ssl_ctx_free(ssl_ctx); +} + +SSL * SSL_new(SSL_CTX *ssl_ctx) +{ + SSL *ssl; +#ifdef CONFIG_SSL_ENABLE_CLIENT + ssl_func_type_t ssl_func_type = OPENSSL_CTX_ATTR->ssl_func_type; +#endif + + ssl = ssl_new(ssl_ctx, -1); /* fd is set later */ +#ifdef CONFIG_SSL_ENABLE_CLIENT + if (ssl_func_type == SSLv3_client_method || + ssl_func_type == TLSv1_client_method) + { + SET_SSL_FLAG(SSL_IS_CLIENT); + } + else +#endif + { + ssl->next_state = HS_CLIENT_HELLO; + } + + return ssl; +} + +int SSL_set_fd(SSL *s, int fd) +{ + s->client_fd = fd; + return 1; /* always succeeds */ +} + +int SSL_accept(SSL *ssl) +{ + while (ssl_read(ssl, NULL) == SSL_OK) + { + if (ssl->next_state == HS_CLIENT_HELLO) + return 1; /* we're done */ + } + + return -1; +} + +#ifdef CONFIG_SSL_ENABLE_CLIENT +int SSL_connect(SSL *ssl) +{ + return do_client_connect(ssl) == SSL_OK ? 1 : -1; +} +#endif + +void SSL_free(SSL *ssl) +{ + ssl_free(ssl); +} + +int SSL_read(SSL *ssl, void *buf, int num) +{ + uint8_t *read_buf; + int ret; + + while ((ret = ssl_read(ssl, &read_buf)) == SSL_OK); + + if (ret > SSL_OK) + { + memcpy(buf, read_buf, ret > num ? num : ret); + } + + return ret; +} + +int SSL_write(SSL *ssl, const void *buf, int num) +{ + return ssl_write(ssl, buf, num); +} + +int SSL_CTX_use_certificate_file(SSL_CTX *ssl_ctx, const char *file, int type) +{ + return (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, file, NULL) == SSL_OK); +} + +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ssl_ctx, const char *file, int type) +{ + return (ssl_obj_load(ssl_ctx, SSL_OBJ_RSA_KEY, file, key_password) == SSL_OK); +} + +int SSL_CTX_use_certificate_ASN1(SSL_CTX *ssl_ctx, int len, const uint8_t *d) +{ + return (ssl_obj_memory_load(ssl_ctx, + SSL_OBJ_X509_CERT, d, len, NULL) == SSL_OK); +} + +int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, + unsigned int sid_ctx_len) +{ + return 1; +} + +int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) +{ + return 1; +} + +int SSL_CTX_use_certificate_chain_file(SSL_CTX *ssl_ctx, const char *file) +{ + return (ssl_obj_load(ssl_ctx, + SSL_OBJ_X509_CERT, file, NULL) == SSL_OK); +} + +int SSL_shutdown(SSL *ssl) +{ + return 1; +} + +/*** get/set session ***/ +SSL_SESSION *SSL_get1_session(SSL *ssl) +{ + return (SSL_SESSION *)ssl_get_session_id(ssl); /* note: wrong cast */ +} + +int SSL_set_session(SSL *ssl, SSL_SESSION *session) +{ + memcpy(ssl->session_id, (uint8_t *)session, SSL_SESSION_ID_SIZE); + return 1; +} + +void SSL_SESSION_free(SSL_SESSION *session) { } +/*** end get/set session ***/ + +long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) +{ + return 0; +} + +void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, + int (*verify_callback)(int, void *)) { } + +void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) { } + +int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, + const char *CApath) +{ + return 1; +} + +void *SSL_load_client_CA_file(const char *file) +{ + return (void *)file; +} + +void SSL_CTX_set_client_CA_list(SSL_CTX *ssl_ctx, void *file) +{ + + ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, (const char *)file, NULL); +} + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, void *cb) { } + +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u) +{ + key_password = (char *)u; +} + +int SSL_peek(SSL *ssl, void *buf, int num) +{ + memcpy(buf, ssl->bm_data, num); + return num; +} + +void SSL_set_bio(SSL *ssl, void *rbio, void *wbio) { } + +long SSL_get_verify_result(const SSL *ssl) +{ + return ssl_handshake_status(ssl); +} + +int SSL_state(SSL *ssl) +{ + return 0x03; // ok state +} + +/** end of could do better list */ + +void *SSL_get_peer_certificate(const SSL *ssl) +{ + return &ssl->ssl_ctx->certs[0]; +} + +int SSL_clear(SSL *ssl) +{ + return 1; +} + + +int SSL_CTX_check_private_key(const SSL_CTX *ctx) +{ + return 1; +} + +int SSL_CTX_set_cipher_list(SSL *s, const char *str) +{ + return 1; +} + +int SSL_get_error(const SSL *ssl, int ret) +{ + ssl_display_error(ret); + return 0; /* TODO: return proper return code */ +} + +void SSL_CTX_set_options(SSL_CTX *ssl_ctx, int option) {} +int SSL_library_init(void ) { return 1; } +void SSL_load_error_strings(void ) {} +void ERR_print_errors_fp(FILE *fp) {} + +#ifndef CONFIG_SSL_SKELETON_MODE +long SSL_CTX_get_timeout(const SSL_CTX *ssl_ctx) { + return CONFIG_SSL_EXPIRY_TIME*3600; } +long SSL_CTX_set_timeout(SSL_CTX *ssl_ctx, long t) { + return SSL_CTX_get_timeout(ssl_ctx); } +#endif +void BIO_printf(FILE *f, const char *format, ...) +{ + va_list(ap); + va_start(ap, format); + vfprintf(f, format, ap); + va_end(ap); +} + +void* BIO_s_null(void) { return NULL; } +FILE *BIO_new(bio_func_type_t func) +{ + if (func == BIO_s_null) + return fopen("/dev/null", "r"); + else + return NULL; +} + +FILE *BIO_new_fp(FILE *stream, int close_flag) { return stream; } +int BIO_free(FILE *a) { if (a != stdout && a != stderr) fclose(a); return 1; } + + + +#endif diff --git a/user/mpy/lib/axtls/ssl/os_port.c b/user/mpy/lib/axtls/ssl/os_port.c new file mode 100644 index 0000000..e69de29 diff --git a/user/mpy/lib/axtls/ssl/os_port.h b/user/mpy/lib/axtls/ssl/os_port.h new file mode 120000 index 0000000..76d6248 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/os_port.h @@ -0,0 +1 @@ +os_port_micropython.h \ No newline at end of file diff --git a/user/mpy/lib/axtls/ssl/os_port_micropython.h b/user/mpy/lib/axtls/ssl/os_port_micropython.h new file mode 100644 index 0000000..88697f2 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/os_port_micropython.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2007-2015, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file os_port.h + * + * Some stuff to minimise the differences between windows and linux/unix + */ + +#ifndef HEADER_OS_PORT_H +#define HEADER_OS_PORT_H + +#include "os_int.h" +#include +#include +#ifndef __ets__ +#include +#endif +#include +#include "config.h" + +ssize_t mp_stream_posix_write(void *sock_obj, const void *buf, size_t len); +ssize_t mp_stream_posix_read(void *sock_obj, void *buf, size_t len); +extern int mp_stream_errno; + +#if 1 +#define SOCKET_READ(A,B,C) mp_stream_posix_read((void*)A,B,C) +#define SOCKET_WRITE(A,B,C) mp_stream_posix_write((void*)A,B,C) +#define SOCKET_CLOSE(A) NOT_USED_IN_LIB_CODE +#define SOCKET_ERRNO() mp_stream_errno +#else +#define SOCKET_READ(A,B,C) read(A,B,C) +#define SOCKET_WRITE(A,B,C) write(A,B,C) +#define SOCKET_CLOSE(A) if (A >= 0) close(A) +#define SOCKET_ERRNO() errno +#endif +#define ax_calloc(x, y) calloc(x, y) +#define ax_open(x, y) open(x, y) + +#ifndef be64toh +#define be64toh(x) __be64_to_cpu(x) +#endif + +#define SSL_CTX_MUTEX_INIT(A) +#define SSL_CTX_MUTEX_DESTROY(A) +#define SSL_CTX_LOCK(A) +#define SSL_CTX_UNLOCK(A) + +#define TTY_FLUSH() + +#include "../../../extmod/crypto-algorithms/sha256.h" + +#define SHA256_CTX CRYAL_SHA256_CTX +#define SHA256_Init(a) sha256_init(a) +#define SHA256_Update(a, b, c) sha256_update(a, b, c) +#define SHA256_Final(a, b) sha256_final(b, a) + +#endif diff --git a/user/mpy/lib/axtls/ssl/p12.c b/user/mpy/lib/axtls/ssl/p12.c new file mode 100644 index 0000000..2c16581 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/p12.c @@ -0,0 +1,483 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Process PKCS#8/PKCS#12 keys. + * + * The decoding of a PKCS#12 key is fairly specific - this code was tested on a + * key generated with: + * + * openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem + * -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 + * -name "p12_withoutCA" -out axTLS.withoutCA.p12 -password pass:abcd + * + * or with a certificate chain: + * + * openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem + * -certfile axTLS.ca_x509.pem -keypbe PBE-SHA1-RC4-128 -certpbe + * PBE-SHA1-RC4-128 -name "p12_withCA" -out axTLS.withCA.p12 -password pass:abcd + * + * Note that the PBE has to be specified with PBE-SHA1-RC4-128. The + * private/public keys/certs have to use RSA encryption. Both the integrity + * and privacy passwords are the same. + * + * The PKCS#8 files were generated with something like: + * + * PEM format: + * openssl pkcs8 -in axTLS.key_512.pem -passout pass:abcd -topk8 -v1 + * PBE-SHA1-RC4-128 -out axTLS.encrypted_pem.p8 + * + * DER format: + * openssl pkcs8 -in axTLS.key_512.pem -passout pass:abcd -topk8 -outform DER + * -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted.p8 + */ + +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +/* all commented out if not used */ +#ifdef CONFIG_SSL_USE_PKCS12 + +#define BLOCK_SIZE 64 +#define PKCS12_KEY_ID 1 +#define PKCS12_IV_ID 2 +#define PKCS12_MAC_ID 3 + +static char *make_uni_pass(const char *password, int *uni_pass_len); +static int p8_decrypt(const char *uni_pass, int uni_pass_len, + const uint8_t *salt, int iter, + uint8_t *priv_key, int priv_key_len, int id); +static int p8_add_key(SSL_CTX *ssl_ctx, uint8_t *priv_key); +static int get_pbe_params(uint8_t *buf, int *offset, + const uint8_t **salt, int *iterations); + +/* + * Take a raw pkcs8 block and then decrypt it and turn it into a normal key. + */ +int pkcs8_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password) +{ + uint8_t *buf = ssl_obj->buf; + int len, offset = 0; + int iterations; + int ret = SSL_NOT_OK; + uint8_t *version = NULL; + const uint8_t *salt; + uint8_t *priv_key; + int uni_pass_len; + char *uni_pass = make_uni_pass(password, &uni_pass_len); + + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: Invalid p8 ASN.1 file\n"); +#endif + goto error; + } + + /* unencrypted key? */ + if (asn1_get_big_int(buf, &offset, &version) > 0 && *version == 0) + { + ret = p8_add_key(ssl_ctx, buf); + goto error; + } + + if (get_pbe_params(buf, &offset, &salt, &iterations) < 0) + goto error; + + if ((len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0) + goto error; + + priv_key = &buf[offset]; + + p8_decrypt(uni_pass, uni_pass_len, salt, + iterations, priv_key, len, PKCS12_KEY_ID); + ret = p8_add_key(ssl_ctx, priv_key); + +error: + free(version); + free(uni_pass); + return ret; +} + +/* + * Take the unencrypted pkcs8 and turn it into a private key + */ +static int p8_add_key(SSL_CTX *ssl_ctx, uint8_t *priv_key) +{ + uint8_t *buf = priv_key; + int len, offset = 0; + int ret = SSL_NOT_OK; + + /* Skip the preamble and go straight to the private key. + We only support rsaEncryption (1.2.840.113549.1.1.1) */ + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(buf, &offset, ASN1_INTEGER) < 0 || + asn1_skip_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0) + goto error; + + ret = asn1_get_private_key(&buf[offset], len, &ssl_ctx->rsa_ctx); + +error: + return ret; +} + +/* + * Create the unicode password + */ +static char *make_uni_pass(const char *password, int *uni_pass_len) +{ + int pass_len = 0, i; + char *uni_pass; + + if (password == NULL) + { + password = ""; + } + + uni_pass = (char *)malloc((strlen(password)+1)*2); + + /* modify the password into a unicode version */ + for (i = 0; i < (int)strlen(password); i++) + { + uni_pass[pass_len++] = 0; + uni_pass[pass_len++] = password[i]; + } + + uni_pass[pass_len++] = 0; /* null terminate */ + uni_pass[pass_len++] = 0; + *uni_pass_len = pass_len; + return uni_pass; +} + +/* + * Decrypt a pkcs8 block. + */ +static int p8_decrypt(const char *uni_pass, int uni_pass_len, + const uint8_t *salt, int iter, + uint8_t *priv_key, int priv_key_len, int id) +{ + uint8_t p[BLOCK_SIZE*2]; + uint8_t d[BLOCK_SIZE]; + uint8_t Ai[SHA1_SIZE]; + SHA1_CTX sha_ctx; + RC4_CTX rc4_ctx; + int i; + + for (i = 0; i < BLOCK_SIZE; i++) + { + p[i] = salt[i % SALT_SIZE]; + p[BLOCK_SIZE+i] = uni_pass[i % uni_pass_len]; + d[i] = id; + } + + /* get the key - no IV since we are using RC4 */ + SHA1_Init(&sha_ctx); + SHA1_Update(&sha_ctx, d, sizeof(d)); + SHA1_Update(&sha_ctx, p, sizeof(p)); + SHA1_Final(Ai, &sha_ctx); + + for (i = 1; i < iter; i++) + { + SHA1_Init(&sha_ctx); + SHA1_Update(&sha_ctx, Ai, SHA1_SIZE); + SHA1_Final(Ai, &sha_ctx); + } + + /* do the decryption */ + if (id == PKCS12_KEY_ID) + { + RC4_setup(&rc4_ctx, Ai, 16); + RC4_crypt(&rc4_ctx, priv_key, priv_key, priv_key_len); + } + else /* MAC */ + memcpy(priv_key, Ai, SHA1_SIZE); + + return 0; +} + +/* + * Take a raw pkcs12 block and the decrypt it and turn it into a certificate(s) + * and keys. + */ +int pkcs12_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password) +{ + uint8_t *buf = ssl_obj->buf; + int len, iterations, auth_safes_start, + auth_safes_end, auth_safes_len, key_offset, offset = 0; + int all_certs = 0; + uint8_t *version = NULL, *auth_safes = NULL, *cert, *orig_mac; + uint8_t key[SHA1_SIZE]; + uint8_t mac[SHA1_SIZE]; + const uint8_t *salt; + int uni_pass_len, ret = SSL_OK; + char *uni_pass = make_uni_pass(password, &uni_pass_len); + static const uint8_t pkcs_data[] = /* pkc7 data */ + { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01 }; + static const uint8_t pkcs_encrypted[] = /* pkc7 encrypted */ + { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x06 }; + static const uint8_t pkcs8_key_bag[] = /* 1.2.840.113549.1.12.10.1.2 */ + { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01, 0x02 }; + + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: Invalid p12 ASN.1 file\n"); +#endif + goto error; + } + + if (asn1_get_big_int(buf, &offset, &version) < 0 || *version != 3) + { + ret = SSL_ERROR_INVALID_VERSION; + goto error; + } + + /* remove all the boring pcks7 bits */ + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || + len != sizeof(pkcs_data) || + memcmp(&buf[offset], pkcs_data, sizeof(pkcs_data))) + goto error; + + offset += len; + + if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || + asn1_next_obj(buf, &offset, ASN1_OCTET_STRING) < 0) + goto error; + + /* work out the MAC start/end points (done on AuthSafes) */ + auth_safes_start = offset; + auth_safes_end = offset; + if (asn1_skip_obj(buf, &auth_safes_end, ASN1_SEQUENCE) < 0) + goto error; + + auth_safes_len = auth_safes_end - auth_safes_start; + auth_safes = malloc(auth_safes_len); + + memcpy(auth_safes, &buf[auth_safes_start], auth_safes_len); + + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || + (len != sizeof(pkcs_encrypted) || + memcmp(&buf[offset], pkcs_encrypted, sizeof(pkcs_encrypted)))) + goto error; + + offset += len; + + if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(buf, &offset, ASN1_INTEGER) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || + len != sizeof(pkcs_data) || + memcmp(&buf[offset], pkcs_data, sizeof(pkcs_data))) + goto error; + + offset += len; + + /* work out the salt for the certificate */ + if (get_pbe_params(buf, &offset, &salt, &iterations) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_IMPLICIT_TAG)) < 0) + goto error; + + /* decrypt the certificate */ + cert = &buf[offset]; + if ((ret = p8_decrypt(uni_pass, uni_pass_len, salt, iterations, cert, + len, PKCS12_KEY_ID)) < 0) + goto error; + + offset += len; + + /* load the certificate */ + key_offset = 0; + all_certs = asn1_next_obj(cert, &key_offset, ASN1_SEQUENCE); + + /* keep going until all certs are loaded */ + while (key_offset < all_certs) + { + int cert_offset = key_offset; + + if (asn1_skip_obj(cert, &cert_offset, ASN1_SEQUENCE) < 0 || + asn1_next_obj(cert, &key_offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(cert, &key_offset, ASN1_OID) < 0 || + asn1_next_obj(cert, &key_offset, ASN1_EXPLICIT_TAG) < 0 || + asn1_next_obj(cert, &key_offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(cert, &key_offset, ASN1_OID) < 0 || + asn1_next_obj(cert, &key_offset, ASN1_EXPLICIT_TAG) < 0 || + (len = asn1_next_obj(cert, &key_offset, ASN1_OCTET_STRING)) < 0) + goto error; + + if ((ret = add_cert(ssl_ctx, &cert[key_offset], len)) < 0) + goto error; + + key_offset = cert_offset; + } + + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || + len != sizeof(pkcs_data) || + memcmp(&buf[offset], pkcs_data, sizeof(pkcs_data))) + goto error; + + offset += len; + + if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || + asn1_next_obj(buf, &offset, ASN1_OCTET_STRING) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || + (len != sizeof(pkcs8_key_bag)) || + memcmp(&buf[offset], pkcs8_key_bag, sizeof(pkcs8_key_bag))) + goto error; + + offset += len; + + /* work out the salt for the private key */ + if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + get_pbe_params(buf, &offset, &salt, &iterations) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0) + goto error; + + /* decrypt the private key */ + cert = &buf[offset]; + if ((ret = p8_decrypt(uni_pass, uni_pass_len, salt, iterations, cert, + len, PKCS12_KEY_ID)) < 0) + goto error; + + offset += len; + + /* load the private key */ + if ((ret = p8_add_key(ssl_ctx, cert)) < 0) + goto error; + + /* miss out on friendly name, local key id etc */ + if (asn1_skip_obj(buf, &offset, ASN1_SET) < 0) + goto error; + + /* work out the MAC */ + if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(buf, &offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0 || + len != SHA1_SIZE) + goto error; + + orig_mac = &buf[offset]; + offset += len; + + /* get the salt */ + if ((len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0 || len != 8) + goto error; + + salt = &buf[offset]; + + /* work out what the mac should be */ + if ((ret = p8_decrypt(uni_pass, uni_pass_len, salt, iterations, + key, SHA1_SIZE, PKCS12_MAC_ID)) < 0) + goto error; + + ssl_hmac_sha1(auth_safes, auth_safes_len, key, SHA1_SIZE, mac); + + if (memcmp(mac, orig_mac, SHA1_SIZE)) + { + ret = SSL_ERROR_INVALID_HMAC; + goto error; + } + +error: + free(version); + free(uni_pass); + free(auth_safes); + return ret; +} + +/* + * Retrieve the salt/iteration details from a PBE block. + */ +static int get_pbe_params(uint8_t *buf, int *offset, + const uint8_t **salt, int *iterations) +{ + static const uint8_t pbeSH1RC4[] = /* pbeWithSHAAnd128BitRC4 */ + { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x01 }; + + int i, len; + uint8_t *iter = NULL; + int error_code = SSL_ERROR_NOT_SUPPORTED; + + /* Get the PBE type */ + if (asn1_next_obj(buf, offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, offset, ASN1_OID)) < 0) + goto error; + + /* we expect pbeWithSHAAnd128BitRC4 (1.2.840.113549.1.12.1.1) + which is the only algorithm we support */ + if (len != sizeof(pbeSH1RC4) || + memcmp(&buf[*offset], pbeSH1RC4, sizeof(pbeSH1RC4))) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: pkcs8/pkcs12 must use \"PBE-SHA1-RC4-128\"\n"); +#endif + goto error; + } + + *offset += len; + + if (asn1_next_obj(buf, offset, ASN1_SEQUENCE) < 0 || + (len = asn1_next_obj(buf, offset, ASN1_OCTET_STRING)) < 0 || + len != 8) + goto error; + + *salt = &buf[*offset]; + *offset += len; + + if ((len = asn1_get_big_int(buf, offset, &iter)) < 0) + goto error; + + *iterations = 0; + for (i = 0; i < len; i++) + { + (*iterations) <<= 8; + (*iterations) += iter[i]; + } + + free(iter); + error_code = SSL_OK; /* got here - we are ok */ + +error: + return error_code; +} + +#endif diff --git a/user/mpy/lib/axtls/ssl/private_key.h b/user/mpy/lib/axtls/ssl/private_key.h new file mode 100644 index 0000000..f72bee2 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/private_key.h @@ -0,0 +1,54 @@ +unsigned char default_private_key[] = { + 0x30, 0x82, 0x02, 0x5d, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xbd, + 0x0f, 0xd4, 0x42, 0xa8, 0x74, 0x87, 0x54, 0xaa, 0xb9, 0x3a, 0x1f, 0x8b, + 0xce, 0xbd, 0xb7, 0x65, 0xfb, 0x40, 0x3d, 0xd0, 0x11, 0x9a, 0x9c, 0xdc, + 0x82, 0x7c, 0xea, 0xa8, 0x17, 0xe1, 0x74, 0xf3, 0x05, 0x0e, 0x61, 0xc1, + 0xc1, 0x78, 0x8a, 0xb2, 0xba, 0x15, 0x22, 0x5a, 0xff, 0x9b, 0xb8, 0x7a, + 0x2e, 0x0f, 0x88, 0xb7, 0x74, 0xde, 0x04, 0x99, 0xa5, 0xa2, 0x99, 0x53, + 0x8b, 0xad, 0x78, 0x5a, 0x31, 0xed, 0xbc, 0x01, 0xe7, 0xdf, 0xe9, 0xec, + 0x2f, 0xa0, 0x5d, 0x53, 0xf6, 0xe6, 0x8a, 0xa0, 0xc8, 0x6d, 0x41, 0x45, + 0x63, 0x23, 0xb3, 0xcf, 0x4e, 0x50, 0x1f, 0x28, 0xdf, 0x36, 0xe2, 0x73, + 0xdf, 0xd6, 0xa1, 0xb3, 0x46, 0x4f, 0x6e, 0xbb, 0x0d, 0x9b, 0xef, 0xa8, + 0xf9, 0x4c, 0xa5, 0x71, 0xa1, 0x88, 0xdd, 0x07, 0xa9, 0x86, 0x0d, 0x3f, + 0xcd, 0x99, 0x23, 0xa2, 0x84, 0x77, 0x0f, 0x02, 0x03, 0x01, 0x00, 0x01, + 0x02, 0x81, 0x80, 0x26, 0x3f, 0xec, 0x96, 0xab, 0xd4, 0x1f, 0x89, 0x0e, + 0x9d, 0x38, 0xd8, 0x27, 0x05, 0xe5, 0xb6, 0x14, 0x08, 0xd7, 0xff, 0x69, + 0x78, 0x16, 0x4a, 0xc4, 0x06, 0x16, 0x55, 0xb7, 0x3a, 0x55, 0x9f, 0xbe, + 0x86, 0xf8, 0x58, 0xe8, 0xc5, 0x46, 0xa8, 0xf0, 0xed, 0xda, 0xd6, 0xbf, + 0x88, 0x55, 0x2d, 0xe6, 0x72, 0x29, 0x2c, 0x64, 0xc9, 0x5d, 0x1d, 0x9b, + 0x24, 0x3a, 0x98, 0x40, 0xa1, 0xd2, 0xaf, 0x5c, 0xab, 0x23, 0xe4, 0x33, + 0xd0, 0xea, 0x60, 0x52, 0xe7, 0x7a, 0x9e, 0x73, 0x5f, 0x2e, 0x80, 0xd1, + 0xdc, 0x6f, 0x47, 0x0f, 0x97, 0x80, 0x36, 0xd2, 0x30, 0x07, 0xdd, 0xd6, + 0xd7, 0x15, 0x89, 0x2b, 0x74, 0xd5, 0x7e, 0x8a, 0xbc, 0x63, 0x42, 0x0a, + 0xf2, 0x31, 0x29, 0xbf, 0xf9, 0xf9, 0xf0, 0x88, 0x8f, 0x8a, 0xc2, 0x22, + 0x6e, 0x15, 0x26, 0xb7, 0x5e, 0x5b, 0x58, 0x44, 0x1c, 0x3b, 0x79, 0x02, + 0x41, 0x00, 0xe1, 0xf1, 0xb2, 0xe5, 0xc8, 0x80, 0x93, 0x40, 0x50, 0x74, + 0x14, 0xdd, 0xb2, 0xf2, 0x27, 0x5c, 0x0c, 0x3d, 0xc0, 0x5f, 0xee, 0x9c, + 0x45, 0x6c, 0x13, 0x00, 0xdf, 0xd0, 0xd9, 0x83, 0xfa, 0x90, 0x2c, 0x84, + 0xf2, 0xaa, 0xc2, 0xdd, 0xfb, 0xcf, 0x03, 0x41, 0x88, 0x10, 0xc6, 0xbb, + 0x5e, 0xb7, 0xb6, 0x2e, 0xa6, 0x1d, 0xaa, 0xba, 0xfb, 0x4a, 0x72, 0xd8, + 0x9a, 0xad, 0x88, 0x0d, 0x6a, 0x15, 0x02, 0x41, 0x00, 0xd6, 0x36, 0x23, + 0xf3, 0x5d, 0x77, 0xc8, 0xd3, 0x49, 0xc1, 0x93, 0xfe, 0xca, 0x0d, 0xeb, + 0x9b, 0xda, 0xbd, 0x47, 0x28, 0x73, 0x97, 0xa0, 0x50, 0xd7, 0x4c, 0x24, + 0xdf, 0x9b, 0x0b, 0x37, 0xae, 0xc3, 0x31, 0xb5, 0x4f, 0x62, 0x08, 0xca, + 0xe5, 0xef, 0x97, 0x7b, 0x43, 0xa0, 0xda, 0x2b, 0x1f, 0xbf, 0xa8, 0x08, + 0x93, 0xd2, 0x16, 0x1c, 0x89, 0x99, 0xf1, 0xdf, 0x26, 0xd1, 0x42, 0x99, + 0x93, 0x02, 0x41, 0x00, 0xb1, 0x41, 0xe4, 0x7e, 0xdf, 0x20, 0xf7, 0xe4, + 0xf1, 0xf9, 0x4f, 0xd1, 0x6a, 0x2d, 0x0d, 0xf1, 0xe9, 0xec, 0x9c, 0x3a, + 0xe6, 0xc0, 0x94, 0xba, 0x27, 0xe2, 0x7c, 0xb4, 0xa5, 0xa1, 0x23, 0xf6, + 0xed, 0xe6, 0x53, 0x56, 0xe2, 0x50, 0x32, 0xd8, 0x02, 0x8e, 0xeb, 0xc7, + 0x75, 0x91, 0xd3, 0xca, 0x3e, 0xd4, 0x34, 0x20, 0x7c, 0x2b, 0xfb, 0x2f, + 0x3a, 0x10, 0x72, 0xb1, 0x07, 0x56, 0xb6, 0xcd, 0x02, 0x40, 0x1e, 0x3b, + 0xf2, 0x03, 0x0d, 0x74, 0x34, 0xb2, 0x2d, 0xbc, 0xd6, 0xc8, 0xa5, 0x78, + 0x25, 0x83, 0x0f, 0xf2, 0x9b, 0x32, 0x88, 0x6e, 0x24, 0x40, 0x84, 0xc2, + 0xc8, 0x89, 0x8e, 0xf6, 0x9c, 0x5b, 0x5c, 0x4d, 0x8d, 0xcb, 0xb0, 0x88, + 0x91, 0x2a, 0xb7, 0x10, 0x68, 0x63, 0x79, 0x36, 0x91, 0xd3, 0x9f, 0x57, + 0x76, 0x2e, 0x76, 0xfe, 0x8b, 0xf4, 0x97, 0xf7, 0xdd, 0x89, 0x3b, 0x0b, + 0xed, 0x65, 0x02, 0x41, 0x00, 0xb9, 0xaf, 0xbf, 0x09, 0xc9, 0x90, 0x26, + 0xf3, 0x72, 0x8b, 0xbf, 0xb3, 0x7c, 0xe7, 0x6f, 0x6f, 0x5b, 0xa3, 0x95, + 0xb8, 0x9e, 0x03, 0xb9, 0xcf, 0xa0, 0x53, 0xba, 0x32, 0xc1, 0xd3, 0xad, + 0x85, 0xbb, 0x79, 0x48, 0x09, 0xd6, 0x3f, 0x9c, 0xd9, 0x37, 0x91, 0x11, + 0x0d, 0x04, 0xd5, 0x3b, 0xca, 0x74, 0x5d, 0x1c, 0x91, 0x8d, 0x3d, 0xf1, + 0xf8, 0xf9, 0xbe, 0x35, 0xd7, 0xb2, 0x53, 0x50, 0x1d +}; +unsigned int default_private_key_len = 609; diff --git a/user/mpy/lib/axtls/ssl/ssl.h b/user/mpy/lib/axtls/ssl/ssl.h new file mode 100644 index 0000000..d143fd0 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/ssl.h @@ -0,0 +1,538 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @mainpage axTLS API + * + * @image html axolotl.jpg + * + * The axTLS library has features such as: + * - The TLSv1 SSL client/server protocol + * - No requirement to use any openssl libraries. + * - A choice between AES block (128/256 bit) and RC4 (128 bit) stream ciphers. + * - RSA encryption/decryption with variable sized keys (up to 4096 bits). + * - Certificate chaining and peer authentication. + * - Session resumption, session renegotiation. + * - ASN.1, X.509, PKCS#8, PKCS#12 keys/certificates with DER/PEM encoding. + * - Highly configurable compile time options. + * - Portable across many platforms (written in ANSI C), and has language + * bindings in C, C#, VB.NET, Java, Perl and Lua. + * - Partial openssl API compatibility (via a wrapper). + * - A very small footprint (around 50-60kB for the library in 'server-only' + * mode). + * - No dependencies on sockets - can use serial connections for example. + * - A very simple API - ~ 20 functions/methods. + * + * A list of these functions/methods are described below. + * + * @ref c_api + * + * @ref bigint_api + * + * @ref csharp_api + * + * @ref java_api + */ +#ifndef HEADER_SSL_H +#define HEADER_SSL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* need to predefine before ssl_lib.h gets to it */ +#define SSL_SESSION_ID_SIZE 32 + +#include "tls1.h" + +/* The optional parameters that can be given to the client/server SSL engine */ +#define SSL_CLIENT_AUTHENTICATION 0x00010000 +#define SSL_SERVER_VERIFY_LATER 0x00020000 +#define SSL_NO_DEFAULT_KEY 0x00040000 +#define SSL_DISPLAY_STATES 0x00080000 +#define SSL_DISPLAY_BYTES 0x00100000 +#define SSL_DISPLAY_CERTS 0x00200000 +#define SSL_DISPLAY_RSA 0x00400000 +#define SSL_CONNECT_IN_PARTS 0x00800000 + +/* errors that can be generated */ +#define SSL_OK 0 +#define SSL_NOT_OK -1 +#define SSL_ERROR_DEAD -2 +#define SSL_CLOSE_NOTIFY -3 +#define SSL_ERROR_CONN_LOST -256 +#define SSL_ERROR_RECORD_OVERFLOW -257 +#define SSL_ERROR_SOCK_SETUP_FAILURE -258 +#define SSL_ERROR_INVALID_HANDSHAKE -260 +#define SSL_ERROR_INVALID_PROT_MSG -261 +#define SSL_ERROR_INVALID_HMAC -262 +#define SSL_ERROR_INVALID_VERSION -263 +#define SSL_ERROR_UNSUPPORTED_EXTENSION -264 +#define SSL_ERROR_INVALID_SESSION -265 +#define SSL_ERROR_NO_CIPHER -266 +#define SSL_ERROR_INVALID_CERT_HASH_ALG -267 +#define SSL_ERROR_BAD_CERTIFICATE -268 +#define SSL_ERROR_INVALID_KEY -269 +#define SSL_ERROR_FINISHED_INVALID -271 +#define SSL_ERROR_NO_CERT_DEFINED -272 +#define SSL_ERROR_NO_CLIENT_RENOG -273 +#define SSL_ERROR_NOT_SUPPORTED -274 +#define SSL_X509_OFFSET -512 +#define SSL_X509_ERROR(A) (SSL_X509_OFFSET+A) + +/* alert types that are recognized */ +#define SSL_ALERT_TYPE_WARNING 1 +#define SLL_ALERT_TYPE_FATAL 2 + +/* these are all the alerts that are recognized */ +#define SSL_ALERT_CLOSE_NOTIFY 0 +#define SSL_ALERT_UNEXPECTED_MESSAGE 10 +#define SSL_ALERT_BAD_RECORD_MAC 20 +#define SSL_ALERT_RECORD_OVERFLOW 22 +#define SSL_ALERT_HANDSHAKE_FAILURE 40 +#define SSL_ALERT_BAD_CERTIFICATE 42 +#define SSL_ALERT_UNSUPPORTED_CERTIFICATE 43 +#define SSL_ALERT_CERTIFICATE_EXPIRED 45 +#define SSL_ALERT_CERTIFICATE_UNKNOWN 46 +#define SSL_ALERT_ILLEGAL_PARAMETER 47 +#define SSL_ALERT_UNKNOWN_CA 48 +#define SSL_ALERT_DECODE_ERROR 50 +#define SSL_ALERT_DECRYPT_ERROR 51 +#define SSL_ALERT_INVALID_VERSION 70 +#define SSL_ALERT_NO_RENEGOTIATION 100 +#define SSL_ALERT_UNSUPPORTED_EXTENSION 110 + +/* The ciphers that are supported */ +#define SSL_AES128_SHA 0x2f +#define SSL_AES256_SHA 0x35 +#define SSL_AES128_SHA256 0x3c +#define SSL_AES256_SHA256 0x3d + +/* build mode ids' */ +#define SSL_BUILD_SKELETON_MODE 0x01 +#define SSL_BUILD_SERVER_ONLY 0x02 +#define SSL_BUILD_ENABLE_VERIFICATION 0x03 +#define SSL_BUILD_ENABLE_CLIENT 0x04 +#define SSL_BUILD_FULL_MODE 0x05 + +/* offsets to retrieve configuration information */ +#define SSL_BUILD_MODE 0 +#define SSL_MAX_CERT_CFG_OFFSET 1 +#define SSL_MAX_CA_CERT_CFG_OFFSET 2 +#define SSL_HAS_PEM 3 + +/* default session sizes */ +#define SSL_DEFAULT_SVR_SESS 5 +#define SSL_DEFAULT_CLNT_SESS 1 + +/* X.509/X.520 distinguished name types */ +#define SSL_X509_CERT_COMMON_NAME 0 +#define SSL_X509_CERT_ORGANIZATION 1 +#define SSL_X509_CERT_ORGANIZATIONAL_NAME 2 +#define SSL_X509_CERT_LOCATION 3 +#define SSL_X509_CERT_COUNTRY 4 +#define SSL_X509_CERT_STATE 5 +#define SSL_X509_CA_CERT_COMMON_NAME 6 +#define SSL_X509_CA_CERT_ORGANIZATION 7 +#define SSL_X509_CA_CERT_ORGANIZATIONAL_NAME 8 +#define SSL_X509_CA_CERT_LOCATION 9 +#define SSL_X509_CA_CERT_COUNTRY 10 +#define SSL_X509_CA_CERT_STATE 11 + +/* SSL object loader types */ +#define SSL_OBJ_X509_CERT 1 +#define SSL_OBJ_X509_CACERT 2 +#define SSL_OBJ_RSA_KEY 3 +#define SSL_OBJ_PKCS8 4 +#define SSL_OBJ_PKCS12 5 + +/** + * @defgroup c_api Standard C API + * @brief The standard interface in C. + * @{ + */ + +/** + * @brief Establish a new client/server context. + * + * This function is called before any client/server SSL connections are made. + * + * Each new connection will use the this context's private key and + * certificate chain. If a different certificate chain is required, then a + * different context needs to be be used. + * + * There are two threading models supported - a single thread with one + * SSL_CTX can support any number of SSL connections - and multiple threads can + * support one SSL_CTX object each (the default). But if a single SSL_CTX + * object uses many SSL objects in individual threads, then the + * CONFIG_SSL_CTX_MUTEXING option needs to be configured. + * + * @param options [in] Any particular options. At present the options + * supported are: + * - SSL_SERVER_VERIFY_LATER (client only): Don't stop a handshake if the server + * authentication fails. The certificate can be authenticated later with a + * call to ssl_verify_cert(). + * - SSL_CLIENT_AUTHENTICATION (server only): Enforce client authentication + * i.e. each handshake will include a "certificate request" message from the + * server. Only available if verification has been enabled. + * - SSL_DISPLAY_BYTES (full mode build only): Display the byte sequences + * during the handshake. + * - SSL_DISPLAY_STATES (full mode build only): Display the state changes + * during the handshake. + * - SSL_DISPLAY_CERTS (full mode build only): Display the certificates that + * are passed during a handshake. + * - SSL_DISPLAY_RSA (full mode build only): Display the RSA key details that + * are passed during a handshake. + * - SSL_CONNECT_IN_PARTS (client only): To use a non-blocking version of + * ssl_client_new(). + * @param num_sessions [in] The number of sessions to be used for session + * caching. If this value is 0, then there is no session caching. This option + * is not used in skeleton mode. + * @return A client/server context. + */ +EXP_FUNC SSL_CTX * STDCALL ssl_ctx_new(uint32_t options, int num_sessions); + +/** + * @brief Remove a client/server context. + * + * Frees any used resources used by this context. Each connection will be + * sent a "Close Notify" alert (if possible). + * @param ssl_ctx [in] The client/server context. + */ +EXP_FUNC void STDCALL ssl_ctx_free(SSL_CTX *ssl_ctx); + +/** + * @brief Allocates new SSL extensions structure and returns pointer to it + * + * @return ssl_ext Pointer to SSL_EXTENSIONS structure + * + */ +EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new(void); + +/** + * @brief Frees SSL extensions structure + * + * @param ssl_ext [in] Pointer to SSL_EXTENSION structure + * + */ +EXP_FUNC void STDCALL ssl_ext_free(SSL_EXTENSIONS *ssl_ext); + +/** + * @brief (server only) Establish a new SSL connection to an SSL client. + * + * It is up to the application to establish the logical connection (whether it + * is a socket, serial connection etc). + * @param ssl_ctx [in] The server context. + * @param client_fd [in] The client's file descriptor. + * @return An SSL object reference. + */ +EXP_FUNC SSL * STDCALL ssl_server_new(SSL_CTX *ssl_ctx, long client_fd); + +/** + * @brief (client only) Establish a new SSL connection to an SSL server. + * + * It is up to the application to establish the initial logical connection + * (whether it is a socket, serial connection etc). + * + * This is a normally a blocking call - it will finish when the handshake is + * complete (or has failed). To use in non-blocking mode, set + * SSL_CONNECT_IN_PARTS in ssl_ctx_new(). + * @param ssl_ctx [in] The client context. + * @param client_fd [in] The client's file descriptor. + * @param session_id [in] A 32 byte session id for session resumption. This + * can be null if no session resumption is being used or required. This option + * is not used in skeleton mode. + * @param sess_id_size The size of the session id (max 32) + * @param ssl_ext pointer to a structure with the activated SSL extensions + * and their values + * @return An SSL object reference. Use ssl_handshake_status() to check + * if a handshake succeeded. + */ +EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, long client_fd, const uint8_t *session_id, uint8_t sess_id_size, SSL_EXTENSIONS* ssl_ext); + +/** + * @brief Free any used resources on this connection. + + * A "Close Notify" message is sent on this connection (if possible). It is up + * to the application to close the socket or file descriptor. + * @param ssl [in] The ssl object reference. + */ +EXP_FUNC void STDCALL ssl_free(SSL *ssl); + +/** + * @brief Read the SSL data stream. + * If the socket is non-blocking and data is blocked then SSO_OK will be + * returned. + * @param ssl [in] An SSL object reference. + * @param in_data [out] If the read was successful, a pointer to the read + * buffer will be here. Do NOT ever free this memory as this buffer is used in + * sucessive calls. If the call was unsuccessful, this value will be null. + * @return The number of decrypted bytes: + * - if > 0, then the handshaking is complete and we are returning the number + * of decrypted bytes. + * - SSL_OK if the handshaking stage is successful (but not yet complete). + * - < 0 if an error. + * @see ssl.h for the error code list. + * @note Use in_data before doing any successive ssl calls. + */ +EXP_FUNC int STDCALL ssl_read(SSL *ssl, uint8_t **in_data); + +/** + * @brief Write to the SSL data stream. + * if the socket is non-blocking and data is blocked then a check is made + * to ensure that all data is sent (i.e. blocked mode is forced). + * @param ssl [in] An SSL obect reference. + * @param out_data [in] The data to be written + * @param out_len [in] The number of bytes to be written. + * @return The number of bytes sent, or if < 0 if an error. + * @see ssl.h for the error code list. + */ +EXP_FUNC int STDCALL ssl_write(SSL *ssl, const uint8_t *out_data, int out_len); + +/** + * @brief Find an ssl object based on a file descriptor. + * + * Goes through the list of SSL objects maintained in a client/server context + * to look for a file descriptor match. + * @param ssl_ctx [in] The client/server context. + * @param client_fd [in] The file descriptor. + * @return A reference to the SSL object. Returns null if the object could not + * be found. + */ +EXP_FUNC SSL * STDCALL ssl_find(SSL_CTX *ssl_ctx, long client_fd); + +/** + * @brief Get the session id for a handshake. + * + * This will be a 32 byte sequence and is available after the first + * handshaking messages are sent. + * @param ssl [in] An SSL object reference. + * @return The session id as a 32 byte sequence. + * @note A SSLv23 handshake may have only 16 valid bytes. + */ +EXP_FUNC const uint8_t * STDCALL ssl_get_session_id(const SSL *ssl); + +/** + * @brief Get the session id size for a handshake. + * + * This will normally be 32 but could be 0 (no session id) or something else. + * @param ssl [in] An SSL object reference. + * @return The size of the session id. + */ +EXP_FUNC uint8_t STDCALL ssl_get_session_id_size(const SSL *ssl); + +/** + * @brief Return the cipher id (in the SSL form). + * @param ssl [in] An SSL object reference. + * @return The cipher id. This will be one of the following: + * - SSL_AES128_SHA (0x2f) + * - SSL_AES256_SHA (0x35) + * - SSL_AES128_SHA256 (0x3c) + * - SSL_AES256_SHA256 (0x3d) + */ +EXP_FUNC uint8_t STDCALL ssl_get_cipher_id(const SSL *ssl); + +/** + * @brief Return the status of the handshake. + * @param ssl [in] An SSL object reference. + * @return SSL_OK if the handshake is complete and ok. + * @see ssl.h for the error code list. + */ +EXP_FUNC int STDCALL ssl_handshake_status(const SSL *ssl); + +/** + * @brief Retrieve various parameters about the axTLS engine. + * @param offset [in] The configuration offset. It will be one of the following: + * - SSL_BUILD_MODE The build mode. This will be one of the following: + * - SSL_BUILD_SERVER_ONLY (basic server mode) + * - SSL_BUILD_ENABLE_VERIFICATION (server can do client authentication) + * - SSL_BUILD_ENABLE_CLIENT (client/server capabilties) + * - SSL_BUILD_FULL_MODE (client/server with diagnostics) + * - SSL_BUILD_SKELETON_MODE (skeleton mode) + * - SSL_MAX_CERT_CFG_OFFSET The maximum number of certificates allowed. + * - SSL_MAX_CA_CERT_CFG_OFFSET The maximum number of CA certificates allowed. + * - SSL_HAS_PEM 1 if supported + * @return The value of the requested parameter. + */ +EXP_FUNC int STDCALL ssl_get_config(int offset); + +/** + * @brief Display why the handshake failed. + * + * This call is only useful in a 'full mode' build. The output is to stdout. + * @param error_code [in] An error code. + * @see ssl.h for the error code list. + */ +EXP_FUNC void STDCALL ssl_display_error(int error_code); + +/** + * @brief Authenticate a received certificate. + * + * This call is usually made by a client after a handshake is complete and the + * context is in SSL_SERVER_VERIFY_LATER mode. + * @param ssl [in] An SSL object reference. + * @return SSL_OK if the certificate is verified. + */ +EXP_FUNC int STDCALL ssl_verify_cert(const SSL *ssl); + +/** + * @brief Retrieve an X.509 distinguished name component. + * + * When a handshake is complete and a certificate has been exchanged, then the + * details of the remote certificate can be retrieved. + * + * This will usually be used by a client to check that the server's common + * name matches the URL. + * + * @param ssl [in] An SSL object reference. + * @param component [in] one of: + * - SSL_X509_CERT_COMMON_NAME + * - SSL_X509_CERT_ORGANIZATION + * - SSL_X509_CERT_ORGANIZATIONAL_NAME + * - SSL_X509_CERT_LOCATION + * - SSL_X509_CERT_COUNTRY + * - SSL_X509_CERT_STATE + * - SSL_X509_CA_CERT_COMMON_NAME + * - SSL_X509_CA_CERT_ORGANIZATION + * - SSL_X509_CA_CERT_ORGANIZATIONAL_NAME + * - SSL_X509_CA_CERT_LOCATION + * - SSL_X509_CA_CERT_COUNTRY + * - SSL_X509_CA_CERT_STATE + * @return The appropriate string (or null if not defined) + * @note Verification build mode must be enabled. + */ +EXP_FUNC const char * STDCALL ssl_get_cert_dn(const SSL *ssl, int component); + +/** + * @brief Retrieve a Subject Alternative DNSName + * + * When a handshake is complete and a certificate has been exchanged, then the + * details of the remote certificate can be retrieved. + * + * This will usually be used by a client to check that the server's DNS + * name matches the URL. + * + * @param ssl [in] An SSL object reference. + * @param dnsindex [in] The index of the DNS name to retrieve. + * @return The appropriate string (or null if not defined) + * @note Verification build mode must be enabled. + */ +EXP_FUNC const char * STDCALL ssl_get_cert_subject_alt_dnsname(const SSL *ssl, int dnsindex); + +/** + * @brief Force the client to perform its handshake again. + * + * For a client this involves sending another "client hello" message. + * For the server is means sending a "hello request" message. + * + * This is a blocking call on the client (until the handshake completes). + * + * @param ssl [in] An SSL object reference. + * @return SSL_OK if renegotiation instantiation was ok + */ +EXP_FUNC int STDCALL ssl_renegotiate(SSL *ssl); + +/** + * @brief Process a file that is in binary DER or ASCII PEM format. + * + * These are temporary objects that are used to load private keys, + * certificates etc into memory. + * @param ssl_ctx [in] The client/server context. + * @param obj_type [in] The format of the file. Can be one of: + * - SSL_OBJ_X509_CERT (no password required) + * - SSL_OBJ_X509_CACERT (no password required) + * - SSL_OBJ_RSA_KEY (AES128/AES256 PEM encryption supported) + * - SSL_OBJ_PKCS8 (RC4-128 encrypted data supported) + * - SSL_OBJ_PKCS12 (RC4-128 encrypted data supported) + * + * PEM files are automatically detected (if supported). The object type is + * also detected, and so is not relevant for these types of files. + * @param filename [in] The location of a file in DER/PEM format. + * @param password [in] The password used. Can be null if not required. + * @return SSL_OK if all ok + * @note Not available in skeleton build mode. + */ +EXP_FUNC int STDCALL ssl_obj_load(SSL_CTX *ssl_ctx, int obj_type, const char *filename, const char *password); + +/** + * @brief Process binary data. + * + * These are temporary objects that are used to load private keys, + * certificates etc into memory. + * @param ssl_ctx [in] The client/server context. + * @param obj_type [in] The format of the memory data. + * @param data [in] The binary data to be loaded. + * @param len [in] The amount of data to be loaded. + * @param password [in] The password used. Can be null if not required. + * @return SSL_OK if all ok + * @see ssl_obj_load for more details on obj_type. + */ +EXP_FUNC int STDCALL ssl_obj_memory_load(SSL_CTX *ssl_ctx, int obj_type, const uint8_t *data, int len, const char *password); + +#ifdef CONFIG_SSL_GENERATE_X509_CERT +/** + * @brief Create an X.509 certificate. + * + * This certificate is a self-signed v1 cert with a fixed start/stop validity + * times. It is signed with an internal private key in ssl_ctx. + * + * @param ssl_ctx [in] The client/server context. + * @param options [in] Not used yet. + * @param dn [in] An array of distinguished name strings. The array is defined + * by: + * - SSL_X509_CERT_COMMON_NAME (0) + * - If SSL_X509_CERT_COMMON_NAME is empty or not defined, then the + * hostname will be used. + * - SSL_X509_CERT_ORGANIZATION (1) + * - If SSL_X509_CERT_ORGANIZATION is empty or not defined, then $USERNAME + * will be used. + * - SSL_X509_CERT_ORGANIZATIONAL_NAME (2) + * - SSL_X509_CERT_ORGANIZATIONAL_NAME is optional. + * @param cert_data [out] The certificate as a sequence of bytes. + * @return < 0 if an error, or the size of the certificate in bytes. + * @note cert_data must be freed when there is no more need for it. + */ +EXP_FUNC int STDCALL ssl_x509_create(SSL_CTX *ssl_ctx, uint32_t options, const char * dn[], uint8_t **cert_data); +#endif + +/** + * @brief Return the axTLS library version as a string. + */ +EXP_FUNC const char * STDCALL ssl_version(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/axtls/ssl/test/Makefile b/user/mpy/lib/axtls/ssl/test/Makefile new file mode 100644 index 0000000..b1d7538 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/Makefile @@ -0,0 +1,100 @@ +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +all: + +AXTLS_HOME=../.. + +include $(AXTLS_HOME)/config/.config +include $(AXTLS_HOME)/config/makefile.conf + +ifdef CONFIG_PERFORMANCE_TESTING +all: performance +endif + +ifdef CONFIG_SSL_TEST +all: ssltesting +endif + +include $(AXTLS_HOME)/config/makefile.post + +ifndef CONFIG_PLATFORM_WIN32 +performance: $(AXTLS_HOME)/$(STAGE)/perf_bigint +ssltesting: $(AXTLS_HOME)/$(STAGE)/ssltest +LIBS=$(AXTLS_HOME)/$(STAGE) + +$(AXTLS_HOME)/$(STAGE)/perf_bigint: perf_bigint.o $(LIBS)/libaxtls.a + $(LD) $(LDFLAGS) -o $@ $^ -L $(LIBS) -laxtls + +$(AXTLS_HOME)/$(STAGE)/ssltest: ssltest.o $(LIBS)/libaxtls.a + $(LD) $(LDFLAGS) -o $@ $^ -lpthread -L $(LIBS) -laxtls +else +performance: $(AXTLS_HOME)/$(STAGE)/perf_bigint.exe +ssltesting: $(AXTLS_HOME)/$(STAGE)/ssltest.exe + +CRYPTO_PATH="$(AXTLS_INCLUDE)crypto\\" +AXTLS_SSL_PATH="$(AXTLS_INCLUDE)ssl\\" + +CRYPTO_OBJ=\ + $(CRYPTO_PATH)aes.obj \ + $(CRYPTO_PATH)bigint.obj \ + $(CRYPTO_PATH)crypto_misc.obj \ + $(CRYPTO_PATH)hmac.obj \ + $(CRYPTO_PATH)md2.obj \ + $(CRYPTO_PATH)md5.obj \ + $(CRYPTO_PATH)rc4.obj \ + $(CRYPTO_PATH)rsa.obj \ + $(CRYPTO_PATH)sha1.obj \ + $(CRYPTO_PATH)sha256.obj \ + $(CRYPTO_PATH)sha384.obj \ + $(CRYPTO_PATH)sha512.obj + +OBJ=\ + $(AXTLS_SSL_PATH)asn1.obj \ + $(AXTLS_SSL_PATH)gen_cert.obj \ + $(AXTLS_SSL_PATH)loader.obj \ + $(AXTLS_SSL_PATH)openssl.obj \ + $(AXTLS_SSL_PATH)os_port.obj \ + $(AXTLS_SSL_PATH)p12.obj \ + $(AXTLS_SSL_PATH)x509.obj \ + $(AXTLS_SSL_PATH)tls1.obj \ + $(AXTLS_SSL_PATH)tls1_svr.obj \ + $(AXTLS_SSL_PATH)tls1_clnt.obj + +$(AXTLS_HOME)/$(STAGE)/perf_bigint.exe: perf_bigint.obj + $(LD) $(LDFLAGS) /out:$@ $? $(CRYPTO_OBJ) $(OBJ) + +$(AXTLS_HOME)/$(STAGE)/ssltest.exe: ssltest.obj + $(LD) $(LDFLAGS) /out:$@ $? $(CRYPTO_OBJ) $(OBJ) +endif + +clean:: + -@rm -f $(AXTLS_HOME)/$(STAGE)/perf_bigint* $(AXTLS_HOME)/$(STAGE)/ssltest* + diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem b/user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem new file mode 100644 index 0000000..0c8c19b --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAsSMwkpYHlwIsi1oxllJLjAPjjycx9t6Q3BOzXBSoZHc1wA+r +QVuKHarpe8tYOKlNP8b79ejbCv/1U3NlVkMJJtLZUPtDwTEwUZNEG17ixS438mGI +1AbHXvwhPaoT24UymEOcbJxAZuClDfzKpN7Cl6OzN7Ox44gHmBCBSnUhRAnJYxD6 +x8wBLw8HdH0bMdoc2+H4KyW31uMGva7C9YlUCPVQGPJsTP1DLRskqy+zO1NERUTO +XytHeYLlh/X/o+NYVvUf7WKu6qC3I4HK+OZ5OW3E+EaE73oYRmUVDaVavL7bRKEf +2NSbzowU+VsFEnyXIF7YnRFp0D1yrMzaC49bDQIDAQABAoIBAQCwOrNLUunwKaCJ +b00gIXW5sfDGbhc+ZUU3Pn5V4NN7SEJ4dt5JYrnxNCWgHLkDfiQ1jFEF4QlzUx0O +TiMGhCDpuCGueJx66uYIcnvywx7XT1kn0jNfxfK6JBsqDzg8ULL6W2GXiIhmEZ8E +YHh3OIvec2WMyED1flMXzWvj2M4ksfMgZH290T9BSxzlEj9X7dZu55K4sFtu0XNi +7uJDB0vF8KfW5gLpwj6pd7i32Cm/Pgpl+7lcqMNpDHo0U2dMyWeH1EmWinS4rHxd +mGDm0N0qK4BOYAJdasq7HwRjzDZkAPuNqcH0gOzSq3aYCI2tP2E6IvprM/vbqA4I +ooo+GDJhAoGBAORiphxweuGBRTpSqoi9qEICM2WMC2NZW8bpFyWn79CuALGzvvc+ +Buw8W3LVElByUyTVWBnBQQ1iXZGe9f1x2P9q8R1Bdl0rpePg3J9ff9674VRLrcov +M85/NUHkj1fJ+2CkCx7KG5BFm3GaAb74e+7MceEW/eErMmCqtNgkR2Z5AoGBAMaO +O9SnVNd4wgnJAjVgN4fqaXWNzZz6NYWtnFVIcTTO7vU1P9t5NjgcsdF9+SnLA/jV +Ylo5Pl0fLPKg5QtIvlooZjXB8hgKVjrVGRLFt9TN0tJMeJ//11Bo88MNMOf0OQPg +i2OMWI3w/oRFJthmpeYWOgXNlLOcoSW1LsnWR0Q1AoGBALAXi+KTq3tiM+FzSb/j +E+/JSJ28bC9u/7+Pi2RiZxrsfuaFI/H4ZlgRdaVFujhC3e6hfKtnAWRzepfEDAEd +neXaLAyVo9DUzbS1dQaBGNPA400eiOJCoNxP4t1qgEd9GhB6i4Ry6uvDb8YYq832 +Q4BtLEUUeC38I3y7QnMBDfhpAoGAZ13InA54xqvhKELy2WK7xhAs0rv93MkNcAhP +qL5L4RgRoqoUEmfp6BBYKh2Qx0cfTD2aNCo04znFppJIazV1k24Qt8+9/vHyrjIe +GX3BFBIKvNx+t5zzNLNOo66MVVT5EaGmLy7zMwHRHn75mBLoLv5HOpop3c+evQiz +0POyqjkCgYA2+ql0jS7Qbk7EPyFXftQhHcD/Ld8TKjonShkASoudSEHKwuQGBuit +ftPsg/E5YfhlRpQB6p00kXb4vZsdpFV38eXkyLuLwg0kbpaLedahIujIENNvWP1w +89T/ueiafWPqvwu3M7sAkkd/ReAQ0LcPwrsBHlOk0uujq+WV+b+Xfw== +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer b/user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer new file mode 100644 index 0000000000000000000000000000000000000000..7bde7b0a4231cedc65d7bbdcb877cfc56e79ade4 GIT binary patch literal 786 zcmXqLV&*ewV*Iv%nTe5!iId?;!n6&HOIThQ@Un4gwRyCC=VfGMWo0lhF*GtTU}Fwt z;S$zNtO)T5RtPA{&q_@$QE{YLH8e9c zGBz+WG%ztTj}qrKHZZU>uz+&OG_{FQ3E6p!tPIRejQk8hZ*Va+F)}i2R5qA2jeR@*u=Ewc&hTrZ@xFftdMr1`wx#1%)N_tzJWz*C4um2Z6jtKiI|2Apes|DMY8&Cas zR%w}gn@ECYj)k)bI0{DSQw zUDgwX5*BDDADR7FsNllkf=%5FZn@PP?f(RtulByMW}}Pv#60dy-^<>Hp+`lHzr5f5 zSbNXgyc)$dZf5IERy|Cy{1tTndehcj%{Sjk{F&W!-^1%q=0djB&5aS|=PR5)Ke!UN z-rPTa?>UY`%O>4({MK4!c1u-9;Qgar4KshLPEN`wbu$m_dlmBQY3}EhuPV>_&3b4T zQaNi$vi9a$gJ>lWmd3T5XTCL+-t)BD!|Gnj8x_Q4E%m$Y!U?ezlh^PH%BT6x+S$o_ z*mOzgQU~Ved#nU?A8XF~I+L$(b!5ZmQ+Ji0pdkmlHgD7Vz zCm9>FJDCD@>~r}|@snQhXFpIWl5vk2sM{QxjI_9P)WipyQj*FPWsvp@aSaHp@pMDK z$MZ1uGwhQEoVP#A-kSi+dF@r}0bd6_%=)sMicLuiwtg#<3Y7GXU1(kJizJNz?rB8R{k=4>M8Z{jx$bSb z;tb0$e|023ira) zD>a(ty;nL}MC^RHtzL7Qc>{bsjm=OO9*Eb+*ftfQu80Z%gf49F03=jRv$9vannCiq zf5{60qu}m6-rO}9Z!j6by%67*uwJK$%i(EW%Y3`v zEK6MzCSvG=;jW{#t^^ps&}d7nJ?CA*f8PEzY6f44WRx=aquSW0uMo|h^4N5oU#CUY zzPn(1I=F_2Luh4{P}g>Lw+t71V^!Z#OO^Sepe==Jwey=>11<+a%YiDyyv0>1%F)+lUE`S)`6xBS@V)O-(`jMu^s6c^<#;>i{2IW5?bTxuZ~w%dx787P?vjtU zyeek_O^XX?nEBTi*5i#QQZL#ra;^+llVBeDl_hR{TBlMCL`Xov*IvWw@7Mab>K>qx z91lbWCd`Ij^a&hPw#2c(_^5Pcxmu-5%&Fk~WTNIbGwDg(YP}?j6oq}T(+M_nCrTlQ HUEnaSBD_pH literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 b/user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 new file mode 100644 index 0000000..bc28403 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 @@ -0,0 +1,17 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIICnTAcBgoqhkiG9w0BDAEBMA4ECLZOmsNEeDZnAgIIAASCAnu22JX3BRRr9cTr +j4x62+iDbrqcwmhQkybM1xShFgWObY3/OQf1NJfH4DO4zGQN45ZN0X9zSUVRu8Dd +ycHls5qsROJ96PYQ8d1xnuh1C9TWmFiLieM0qUyn35raHcKPQiBl8PYHtNr3+m0K +bsql6T23hE5ZjVhbRtcRdRd9MsQeTZ6n4mdWPEhzN1+rmSPV8ybCbrtJl3/Dh1v8 +LnswXB92T6WcmHRyRiNsbAXR9SQkOaXFZ/1RUXDNqoRYZjlWPBWdcQf48mzgaDjq +3RXF1mjbOlX2x4/V4qVwH1qZADlT38fSRk/iVdRfureS+wfOuJgJ/g9Riwa0o41K +2q+sOEcTOv4rShXRGp/0ckeuwhARDdSMymlSBhgBWdf14qdgxCx0rAXYlRAc/4Ze +Zl9ErfydwdUfDJoPK+QlGZMF//hFRF+vdO/wJHleLsels4KaqN9v/sB+BrGWaeUC +ScKMISixquCwfWi2qGiqLQGsxHn0d6ejiMblZR4kTf7dcuWVWGXdf5VZqxLNP8Xg +zzjjeP59OxHRVH0ytGBUejTehcxWDKq+6ESAuujzVXa0v1+5QzZXsJ8rPyZOINzj +bdpN4Cr3tZj9ALrNzoC2oG62+OO45U7lg54cV1nyrQ2QiI4XFnt0WA06K1G1JrRW +a/y6nZkntGybbCpuuIBiWl2FfdcTepctiXcJ0vCYqVNOTT4L2Y1RwajDzALhgb7e +wOy0eA8gmOmMLNozSlMV7siL0LeE1WlotLwK+AHMU1lmPMqS7jK9nycXtZyg4IKl +eBAnW052fnKZhT4zNlfJkZqpcp6YWpCU16PWx6L+/FDzFPzswluHyfB72oVqRniI +2A== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_1024 b/user/mpy/lib/axtls/ssl/test/axTLS.key_1024 new file mode 100644 index 0000000000000000000000000000000000000000..e39791ec8b54056d5bc75137a9e8ade3ae6c29c5 GIT binary patch literal 609 zcmV-n0-pUaf&yIv0RRGlfdIV^)Iz9qhg7P$Iv$5h}{RNh7CW>nIocvcMk#s0RRC4fq*7I z?3Sz4ABhf~IM^oz<+cR?jmdY*G%E`ZV8Z$}T8fHu-F2i?}!6^Sc!)qaY+V?qk@ zF)6?K`S6I3iozmp6(+Y{TUbOKJ9z>@0O9en<;Z}OKu~lP-Lmp0Tns(HU+$bmY!d+A z(Ak6fkSv7qs>0p-&jUe-5XQS+x3(^(9jdzfN^;nmt%wb36#_v3);1&aU3bXSNx_r; z$_?wA+Pz08bC;k{*Gween+rFt!!fl_VhGCR@0WW+pxP@Rzo-b4(iR+vnepEy(L$M% z0zm+=LF9hlAot|)`A^YmEe-MM?3_C0z?8Zt;(WBFp(FO~=2KSUP%_v8j_b#Dk<-dP z)HEP`EBh}x5OT2xR<_LoKps2t0}XUEvMs#U$fbBCgAekXGKg*@K!n1`iH`Q1TUgjXm-B`Mx#RvQtnU*ex&x literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem new file mode 100644 index 0000000..fd8226e --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQC9D9RCqHSHVKq5Oh+Lzr23ZftAPdARmpzcgnzqqBfhdPMFDmHB +wXiKsroVIlr/m7h6Lg+It3TeBJmloplTi614WjHtvAHn3+nsL6BdU/bmiqDIbUFF +YyOzz05QHyjfNuJz39ahs0ZPbrsNm++o+UylcaGI3Qephg0/zZkjooR3DwIDAQAB +AoGAJj/slqvUH4kOnTjYJwXlthQI1/9peBZKxAYWVbc6VZ++hvhY6MVGqPDt2ta/ +iFUt5nIpLGTJXR2bJDqYQKHSr1yrI+Qz0OpgUud6nnNfLoDR3G9HD5eANtIwB93W +1xWJK3TVfoq8Y0IK8jEpv/n58IiPisIibhUmt15bWEQcO3kCQQDh8bLlyICTQFB0 +FN2y8idcDD3AX+6cRWwTAN/Q2YP6kCyE8qrC3fvPA0GIEMa7Xre2LqYdqrr7SnLY +mq2IDWoVAkEA1jYj8113yNNJwZP+yg3rm9q9Ryhzl6BQ10wk35sLN67DMbVPYgjK +5e+Xe0Og2isfv6gIk9IWHImZ8d8m0UKZkwJBALFB5H7fIPfk8flP0WotDfHp7Jw6 +5sCUuififLSloSP27eZTVuJQMtgCjuvHdZHTyj7UNCB8K/svOhBysQdWts0CQB47 +8gMNdDSyLbzWyKV4JYMP8psyiG4kQITCyImO9pxbXE2Ny7CIkSq3EGhjeTaR059X +di52/ov0l/fdiTsL7WUCQQC5r78JyZAm83KLv7N8529vW6OVuJ4Duc+gU7oywdOt +hbt5SAnWP5zZN5ERDQTVO8p0XRyRjT3x+Pm+NdeyU1Ad +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_2048 b/user/mpy/lib/axtls/ssl/test/axTLS.key_2048 new file mode 100644 index 0000000000000000000000000000000000000000..00989873bb903c8c1537d4318e535fe068d6aa00 GIT binary patch literal 1192 zcmV;Z1Xueof&`=j0RRGm0RaH{T6R3AC2^VxXLF))22BHn=^2*8_o14xzC`P*=rH@6 z?q9N&et`5QFL)W+(l6XVbV9s-!tGHNzp`upSmteb&<0wmV){%MxUPyI4%}1$so8x0|-eF z53KPPtq)(3fr9U|R-lCkCHu0BSqDwK7RiZF-j+6sH-#U^)dhS-)$f4D)6-0{m`T`G z`Tbwxtpv2E)FiZC|-?&eX=i#pSP=0JEA z`*pDo=d(>5BYeo-P6_TWG5DC>*nJWe!wIXSrR*ifFe{Iz);M+Zz{jwH z7={XO-&;!7t}aIj4&HO+t{m{TDFKj~5b2S1EX8coAi^v#r?)d`*bnMt;~5F4-F`V= zz&>OjFDoICVE7Q<>Kj*Lc*Hb&&PT@(v20NjJ2PKA0?ZuDilWu=VCv63J0Z@{) zDxfm3MqM7$mYQie95%BL9ghXFsRDt40RMqc^_O{AEjs;TcPsrwZTOJlLJg!&wOKcV zlMOBS{g{a*a{(PoDPg2sZ@#fm0b~daQ}Y%}q%zMMBH*+dZZpJxyhL6(mk3~Sc~?Kq z$cT)V=o+qS31(OWJy3cj-}d$ZJydp@hI>ixT8%3rt2m|GMobPtNhKJ0rdNkCLjr+; z0QuG#YJ+OL(ruGCO=l~|qrP%7=d#>GTjwB1A}gENm8)#5_<8v|P1-lqtdd-Y#ds*n z2S&ZNC!G0rx&-y#(u9bIlt>^{*Oia_)?SX0=CwiHxI8suq@@I(Q~I7lNHIRzLTF~~ za~rj{cp7VF%&IkOaNIl`*x#O-v3@jP2LgeC0Nli^1x2fN3o3HyN-%ezUg{&+8)+iF^8WCm-LE4e4f0-pB70*JaNYbk69WV847=TWm`?k zCjxO8j7flrH>@xnRz@w@sxFy3hH%?>FdeE?D02hXZ4*hE{d7(IddsZcxeH zYGjNKF`$KI$aFILIK?}Etd6n~-QuCvT4K!EYn6*K-%YmqdN&s}sLclAM>D8M$)rUa zv8(jlPBY9Nc{`-cUVyD^l>MZ$;cQ-RJoHG}0)c>43rt-w_O7VyNPF?A=_BhSAAW2w z<-kkl4oJV*6MN5+B$ye|7ZdX93W12hQN)$V;;qt2CgO3wyG;p7+x2Swvid>z<3P_D z6FN_Nb}2vnGBE|+R~O;bVM9+hq5>7uyc-!-KN0JNO@!8spNZNsP`HMyT4!Q_(+cBF G5|Pp%l0WbO literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem new file mode 100644 index 0000000..5ef719d --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA+Vp2PKclcZoKZ3OicQZNA4XpGZbD96Gasb5E66voMPub7l+y +ln6A9CYveBna0i/cQHRCwpYuzzbHQgOjAAw7rcveiIqm8nJMxA8BFNMJCHv0knDl +RT3H28xoTt08Z/MCfCYyOXoVsJOS6BSOSdFVyzhfU6nAie5iskYnmKecmhYaFm94 +S8WWJMNgEvwzPyhdmE4rpqUBHRSu3zPgHUnRRIOfui5KdZGzKpaC+i1Gn58MOC4W +L8kguEMDCEkQD6zxFq0PX5GBgu+zVqCFByX7soxZB027FsmJUN6WNoo3hR/H1QV8 +RdXvgMbT00yymEnYVfn9ZL7nXShKI70Pi5Y11QIDAQABAoIBAQDQQBrrgPUmsW3r +BIowNwDu5lHNizrTf+ZAeBX7dbEP57NNHCN8yN5OCe4vMfis/kfGlNKEzQT/DlLP +8VWa3pyhA9kw1AumBIvUWmuexrmOmmeiPiNc9sIJ8edTpjWi4zO6F/RuSGYA+N8C +cNh9EhXDCaujpewlxjArj6fWOHXzwMewghiGCm/fW0rWri5HCQ7ec+WuHPC2KQGQ +mRDpkXUsxWzTIMIsMKe3M2jYD+pk4xkJqN1+OV/APmQfLyshkGD4EN/qG1dieMQ0 +e85HxxCxbFETOzip0+pHXMbtxY/ok25/SCdtBXkBUJK1KqAysEZdHtOWmmk4HDaz +Dx2PBbKpAoGBAP+BT/WXeVgtOv1idyv9RG34kOJCDaROtVk3g5MNLfj9mIklcwEd +SylhpFxvvrFQAWQIDFPzFkukMs8aIuC0Gm4zxH+8RF45lwhgcXlXP87IiIyW6Bqu +aglmWAM9UHol3/b2AD1UdpqGe0nvWo0rIqs4pdtGTA5BSSUYeaZXhzFDAoGBAPnW +GWqDarzSbZM4TWcrx6O+cjLnstxDW+cgSCIrm9iVq2ys+Hn5O03aN9SsklyGxXgo +ygdGvbYnnPl3ugT139KEiIeUSCBU15WP/NZejpHmtUHduDw1Y6SlBJ9T+p5CSDE+ +2kJoZu1zG7W3eBprZsyqNWtw3Dwc2N+emrF+NF8HAoGBANzErAVFq6if9E+KK/SL +cvwegXmun0DwbUu4ZuzBv45b+NfPzu4QlKgd4TmpqDhnK7x2I8jJyuLy7p/6Mla7 +5/Z+rnO8hcpwsmqfgozY8Z5HsYzgu46KU77penTaHtZcMYefCZf0ikJ8nrzEnxZJ +RjxxxwWPWRocGQp/emVbTconAoGAUClmFkr8YIGULvyNuWDOubdNpQ+6z/m87zfo +bS5Y3vGHA2OshlZ1tNEjwNVuUMndamSMDjGghWXIdDL6OMU7f6yOshHd4qHWWmLM +2WuVizLfTbb6ejcXNajNBuJHM6hIyaRFG7Gr9NxOM8weeTukzF6ArWyU/aSz4Wxe +bjz0SNkCgYBVC0xdMPauqO1Ie/Gp6SPrIx9+bDDlwEvnDki/2RN7z5IkmBnRFxPy +6wqBiMFRxJXI4q3SSSbicb+7TQlK2/Vq/bL6QfjjQM8ZEzpPenYpP/wyMQXdVxfh +1GFDTzeiAhXTvBsZVj8R64VNhNaNn4naMlC4hqxaZ2KA0wrjTRKR0g== +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_4096 b/user/mpy/lib/axtls/ssl/test/axTLS.key_4096 new file mode 100644 index 0000000000000000000000000000000000000000..df8a8fde95f87836187040e8746243bebd557e15 GIT binary patch literal 2347 zcmV+`3Dov5f(a)A0RRGm0s#QP3QnWf^s^<%@HvE#|2%kbpk<#0x@QOp%A6JL4$B06 zQpMDD2u!G_%q}k$mC8P>+J$g8>^C4Klpx}(&t0eXjgNSz2~a3rc8R(sQ0dkEQqWOU zMZI#r^XVAit&~0Z$s0Q#j9piF;Ey8_Wo}z)3f1H@Q{hx^U7e4PW=*2$FQ9Q<#l{P_ zwkao$@0gatD@@2~i9#yX@%wF1*1A>luI?)_5iI$Qr6##63}lIV9yz}&8JWgFZWjGn zn_{FYqAgeTszHFOo(QGXj&mfq$5>Ni1FiT|t@2r#IW1%u@|t*BhHvZOg~# z3gv%fj)MK=x8KnU{G-Vg4HL!_8>R!n)TXWMBD$g5GzqV%R1qOUo% z$%26b0|5X50)henB`H~QXEoUT^w(Fa35@!jtKPl~dB#d@$;U-e5a5mU zzH_JursW1el*jZR^pxY^ApYQ2h}zQ#3w@BMjBCP4;Bp{SPOpTmYbr4qu9bDljSSm& z0fEI?Q9sw&l90q<0i~GvW$$^Im9dV&PuIC(FyzozS{5PC|nptna#& zMdhF^A%Vx+RFj}~AI1sc)F{ztqy7nO+*@&nHYJ9*d+K|I)rh`h#248>-wZ=9lmt1t zsQzN6HUZEWcUO%0V?1A+2Y1n2N6mYX7gqf7Qt%Wvwwhh&Lermw^m*rQuDv+mrFw7j z39c=jQ1`8v^)M5N4p&RoN37kd-7O|RFNA*v1XeXgk(>CFuaZpWc^u@pb3(u`k#iV6fhkx0ypxWj72$-jbw#u zNguMfE%9jNL0gpoJZsqDA0)hbn0O73zXm=?(p;NijJdiKV+fi;4)j2T|?I&T+<7kr*2h59B z>1H#x<_M}{7x6ThvP}8b4Y?8>Tg|y5z#E@GUd;+l<-!sLt^lw_wg@-$8qZBXO2c5C zs3-`h9zd)d1^anJd}0Tbhp0LfdpN1h@vVRAUdmMA@mGONU)GhHiM$k|s*RQ$Ikr6L z$O}2MEw`O7(ZZM-16d0#M=piOL}Gs4oT+3*bgLH5w`j%!5h)G-%XNQ5&wvPEt$O{g zK)p%LCR@#SZwo#I!o2dlG93S#?&hKh0RY+9MDO3_$)TR!Txuq4@pQ4bDjIjd2{`>DItc$>l;26> zNIOtbh!ap0v%SYZ30InfvJ+bVgQd0!qfB8MU#Tq|SSsA(fNAw|{Mqy0!i+4B(58%Xu+2L=R++!W1c%WXF1Y9xZDb%Mc7D>_yDs|rPRi*_@>yY0GWKE zmr#8v4<}lQ<4w8bR2@|GF$4UGnq}Acmnb__*Lw>H1xW&?1_bjs&U?%JbkKntIN!cn zA)uCqL(@JDz(PC@_Z=6)17tt3jyEXH%9Ok?Hm;qWF4; zx^5dYje5j|($8)!ETTCNR1Bx5H1pe>7fjq7D&)@gqg_ZV1kb*&d3#T2+2L5xDQd!^ R-KpUHmbT&ib)P%cX;_ZKh7|w+ literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem new file mode 100644 index 0000000..73fb75f --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +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 +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem new file mode 100644 index 0000000..470f29b --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,7BFA0887B7740C1BBA458D0362E75F89 + +aBIhF2zVGRMFZAWg8s11WnxoTQhGabdzchHBxPltnipEgvwOM9FGmYnVIDsFPvyb +hSA2HgmN972SPeRG4hITzrIXiRZMBOd6Lchz9p2Ui/mqkR6RUfnUBkUtkgxGymSa +oD7WAmbpNG73+7KX4gV36tevC1dM9lQzbClhhXQL9FH9LFh11cS7ZFa9L/esWHbb +sxgicR8zG919UEA+XvhLPVXpYD3AVHTcyEHbPWiGY49SIEI+GOcLi6rvxQizcXKY +pFtmlk/jM06OdZWur5/qLg3HqGP/o8GUjjA6KuAe5SIWVrmlkHCYHj6c1KFLVQJZ +7qAUNvjVaELXOc3+SE64Fl4OMP/4MiUA5WJ+gcdIKFtX/qksjywzF7goNTsxB1ZX +8g9JP6m5BF2VS/Woz+9ypekzk7DEKST4Knh8cYBNdz6yYwX73FBb93jk1aPMXv2K +SzhupTSHyAt7ddvXm+QYXBrklpZgUcuvinrkb7TNYEDcc2h3iDkLMHhI2VW0fiSF +JcL2DZWLu1UChg+Nkc43+9f8Ao76tjJHdV+IkWfINlKz8cpKthIfOiUSQWYK4Czr +0E3dyUrljIqFyKmZGokQ2QH+kdMmcm2/R+8NwL4s0Y4k1ylB0mZ5+A55t0ESaUVC +8NJtoIMrLz2pyhf2ohXMVepcjvR/Id8vNxSlLFResmIwSo4orTZOnsHBlQqm5hJl +9dr8G0o7n7WVfGbHLlpuPHoKegn1OK5xLbDbAi14HnZIi7/lUnbQHMbFFBjyS5EE +v+SMbI7JU+5zeJc34WLUTm1zll1ZNpFH/76vlP7tUWxYqVUZfKYHOndqS4b1rAs2 +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem new file mode 100644 index 0000000..5e9c5fd --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,5AA67B48694516B66EECE19E0F3BB048 + +eXbuyN1kJR84JMhFruS9yeJ/WnyD0V6h9w/6fhEcPfxW0HmFqgIk35IE4c4QYazZ +aMC0J1S19Yb4kKnRd7j0+92IDBw3B7zeJKjPDrcRDSo8R8K7O7+6MYwcmJJ/DZlC +yqcaHr3cJEiS4I8NS3EdffffFA37Uf2O4C26b96ewg899YZXmPtai6uOvKbF1A90 +aRV4PdCpJdJq0q69VfoSeQ5p//Wokb4RfDGWTNxpgclYr0SK2F8qfITjCNDbqR+E +r+6tRsy9VcHVRjswuewU19HOQNQzaPlIiNaoGBGvOVRHLdE0s8b1Czyh3oeuRAZi +EK/SPEdZ5JMWbtxpKi+rdqFZhW3sGE5T9QItYqAWezScOCcuZw7ivVITWj0HuAJl +YZnkL4CS2qMKfQ7oz/YBAuShDvfl/W1M2YXt8caoYIox8NWnGaifHbk+eP7sQRE3 +UMA/71gfz4AOUSKOWTNCen+qeAImyRi++6kFOVyAZnmvGAj1INv76xh6tHP9aDN+ +0ROlEMeL+4EyqEeTeRL5+i9xEGtA247hMjtwB6i8SDl2N9RZkIzGOj6GmJpWQhHK +qRSu+PvoDfSHqfHYXof0rtvCuKj6pAhYgKeL5Ycfc0FtJX6gTvErlKWENUrsJxgV +RJNcRbltxcOylmdYP2tUe/PxQCSFcYIzFbQbXJDoZ9hMgJRv086fzn/QWiZEx59o +9r8kKQrYhKjS34Aq13ghFBf/Mr+GKrB8JtO5DnlC4N9AnapVlDgeZn2NmXyVZygA +mcIq5MTJcZzCdX6PdzNVBsttRfYeItN9M8aP5q5YodBfuLXPOvFhV2J7wc5Bgt4i +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem new file mode 100644 index 0000000..5c9a845 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAvV0Pomdmpxx7s19ue0itPlPusWrTSwofoWEU141dp7cS9eXc +SnQV5pfvYvvw21HsZHy+xW2cupjQBzvqPtrrqAz4p2E9VHTMuzvDSScj6GU0BUD+ +GQ3qthLkXMfh7pJZFN5DYtVqzSE+ufZlYlfBqsT1BON9eRs2fTf6OnMFApx0ANjJ +yFElu2cEf3iif/3Z6PF0iUNtKaDNDVvVBoiRa9mUuj4vxnyH4HmyzThp2bXDLMUO +Viz/WWZs9Nl/QoJduyJZGEii1UM5VS81qQnu2dT1g/E0yPXwtOQUnVgjSMPfW+CA +yJ1XTdSwVDSsyXApyxxtSEYbM81t3GGvmmCf+QIDAQABAoIBAFFO4COvmlgu1r6S +P3IYJqsYhukPIWKbGjHE6ZoUTR5ycWW8KPafGbhFjLhHzYeeiY4sMg27nwxQCSLS +CyaqAX3K9AmKqzbUYAQVCSkj8TscGVYYLgK8Awfi3MMp4Ez78dwQA4cwdAdYOwLG +VYoAfFvC7iIHPB0AHklt+7eVI5WWsYlOIf9aS6+PDVii86GVoCpBE0eNZjE3JJo7 +hC0ctcjOqSVZRPC4p5KLFI8QkwyEK3vstyIiQOKSCFbZIn5Wi0+d6A9K96WhwssM +OpmenLv3xgz4zrUkRDbv0cPAU+/e7ZVPCiIbL/Y78qk3lBjUuyztX6fwQ/eDFadw +BS6LcvECgYEA+Nlwgi1Kzcd46xKG7xryI0mYjHO4cbZMsTcB4FQK5xXkGlg6j+WD +NAi/LKDJhaKcBKIYDhYi8tY1ye7JSDmyrPfZ0WvQF8K4yprUAqidNIuwOPMASjTW +CEBgTfMwCATNYNiaQ8eRuTLyknF4I2lrc4Ifby7cYEZrJ6aLGyolvdcCgYEAws4J +rGQS8W1DmzrL9mIDlSUtMFkTWqhx7nvG4lCYWVGpMByiQwf4DRvcqmXhwPr0syaj +qE6nu8G3iuOywSx2qrPX1a6NzeoZZybOSL7poaVmnpxgtS1xXyo1Bdc5ZPPOom1T +apb1QXHIPFVFKsuKsrQvyXfYLFGlQbYh3TGrtq8CgYEAmDqT+95vI0ECNHNp/f0y +4OlVm53y2AUYF1S6Hhvra3/VwVP1xy80uvEa2dcmUEywOplaM8vQ51KpJvWfRkKd +jfg01Eqqys5AsxhR16qEOK+3Rq9InxyBThzrjOPWnyEo7jSy8gG0oGGNSI6HWspT +hB620hINmAub426bLCv1WJMCgYEAkdfBZEAT8o30BH5TfyVIO1v25fB6TfA4Q+yF +LKBcPtqlSPDXBkosClxmq2fVSS5ZDtsJwZMJfsb8C86G4JrSSOCV4VNqtNPjqtdh +rxLHRQ7YsjyvJlVcQHwP8Ex+mrbxZ6djwTQ9b36pA4pvWyfBsiK2eCXyQNPrXjPm +THzIat8CgYAXN7CO+EUKtBil/r3PTj8FpWxvfZiKMbmktiHKD9ntcN3te2hrOWVs +1SmrIzr8/eBIsh7OGS3LUZTb4wKGtY29N6fTHuoA8pYILeRcJALGZnmrsTyFDzGH +iXBSkZ94EXpywxWHAEglow028nQ9UNugKk9SIkpg42u4vrqhRitMqw== +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem new file mode 100644 index 0000000..7c1cb6c --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA7R4S75j5ZfknrzbsAvUnqS997FNk545sGo0YraDQ7CeJXGqe +DyUTpdwtzBt8H8/axNP1BFdgNEWnF1C1HXVbhqWxq16IlakqZYkYldHJMPQgFa3Y +uRN4Y0i8sn8A1Fbe69D//57JZr1wt+qxAJWWn0anPGXmR0HlO0At1ACQkKGSE+aj +TB2TnO7UTsjKRrXPv16FdWTXkJTVHUdVuAs6IfgAKkvQQ5zA8D6IXgjWsToWdFzl +I8eTDHZqZJiw8gPg7xG0jepN9JU05JRc4NduzeVj/0WT0tdilO0jQP/+8FgikdOe +DU6wo4/e0Ta5bdZe7apqOBfdDnq3EUnHO1ZQbQIDAQABAoIBADbu47Yse4L7YQ0/ +rRfWUfTpMsQgYd0far4P+Cqpeh1r32/Qp4OctFuVkeqaZ3w7PFSjQj1aPMh/ZoGJ +ShxkBus/0dSA1yXNBix1wYNcEb9Mn25GU1I1R4vA2y6DK98FrSl2xwgickhiFQ4W +yiD3huiphq8AcIQLqR679KIL63IF+lMnHmYTrm9/rkGvO/wiW55OMhLvhuR4w7/n +5g+PMBLF4vEqtN6wEpb5f3Q8ugNCG35ykpgBMFWI6FGGmcZkYgux+xnTweZ9+Xol +tBQRrq9cY3/ouIrRX4K30e/EcaJN0eA0Cx9WerEHfYO45BWUJGySsxPab9vk6Qep +uxRnHoECgYEA+uv054HQKGQOZPjgZ9lCqfPB4wQ98T4hNSLgNwAkd85D7UtF6Wb9 +GMsEecJ5aPIQjDN6dTT6Nb45AV4e0XWtQFtxHFXP6SKfyIlf0Zcl0cd8Fvt7CX/e +ghZF6ndUxHaWtAltALVwo+Fi6LOgEN7+dsBjkAZf994cZNfqrr6B1s0CgYEA8eqY +u2p/QE7YNfw7naMUKDqgqGzo41IjF915rznYOyuO4hu+zGrL2D+7EeZnLWfSCSxl +t0uowOzDOKkm6XeungMyJFH0DnzhYEgh6K9AXMi3QF0zfgGrh7hhK5wFEt+a4nOY +hIAnqhANqISRhOOd0iT2VIt+igQhEQv8XLjAICECgYAVvkKfmQkfpuP0bfiMJzB2 +p6/Ca0iu0fJwt0/0lCeU1iPeuSoaupjuABGoN2jr5iX28DMJWwjfhVdNPgmvnuHf +dM0NZoY4ro5oAzdxYwac8gtXtn0H6rOuVB3E3ohS6e/PNA3lBNP473vxrDcPnzMv +uSYngdXpFa8iMe+dKtb3dQKBgQCAzse56q+Mvy5yODZJ7f4amXTXmP27pA1ZdKyI +90TB5KR0kg9aanbVUsG5ezNuwrvb9I7INPnKl4Yu0ioM35PTQKJfIl/PowChsmaT +rVSY0qp4E+gJ7Lu3TR44CR/Od87RSnln+5CjBV8wXj3ZQxTSQqoCRDABLseoevhJ +Knnp4QKBgEHHHpegaCXl7+kaPzD/qD38iN6AmoAya9ZUxCUH55bDmkTFu1ZGgA6S +87fuXQ2tzwFyOtaxAftPuOkSKMpZYRPJY92SalHA4WyN1pl0MhWMZQiyKOh0QQ7A +yaHjrLn5wPrhHhkpmYu2L1ZNiN+NIFDuD/j+APCX+wqb9otfbfxk +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem new file mode 100644 index 0000000..57fef36 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAzhdv9CgZ895+JuF4J5ttgKS8HDKL5uCAYOS2B+o1OkGzYRkS +I+vA41BpPfE8D8P9lgjcbzAOrOvgYHPZneE3Ix1mhlyPwbnXesC48AahbWXeHFJL +u3Hr3EfjIVngptIHF0/FXmLtOjcxLpP/mXyUTX7bm0NMhgEvxAX34fPfgM4r6AwP +YLwxJGl0c4rrb9choDmXp7+72NnjiO/pXzrUkI0VL+fV6U/cT9ro6p6wJYewvfXA +zqV01B76xf+QhYGp6h/HSZQntTQfA2KIp3H7jhaVXgC/CyyZ/fvx1QUAVCy8pMck +Fs7YuLtVuhAOZ1KpeZzaQotwRjTEeRkF99iCxwIDAQABAoIBAFNxi+O4hOGHuV42 +tjabKNgIWx2znY+KYJBaqhVET+7ZgS6UPxMKNlwTR7lLvjzH5xnjVpUySQ7cpkmH +Ppo9AN0X31YRjicq/sL12ytcE+o+b5LaA03Oz2euN5leUaZZrYNTyh7wQQrsI96v +D7NujIFgFryjoA0118gvfnEfE+SLW5q4m+n7D4cZ2D1nolDnOo2noLhKhMVWT9jp +UVoa5sO+9/Ap71ElAaet2LawNsKbyjjRuI84544G09zQ+YUfcelADaqtXyYZpSJL +iWrmHasD1w8NfiHB84y2hWHySoiuTBfVBJFfTjg075TaxBwCtDbzzEe0ecDCVGnb +gZfkevECgYEA5+5cUFf9LXt7Cwqc/lnuIUYmX7pvTPVVZbdjEzd1MUvu12p01cRN +QYk4K41LZsQYwDrCk82TFn1+hDbVt27i5r4FPJ9GbkSh4AiqUFDkqpqE/U06ZiUX +JOosU6laI6MmguWbXAAQuv2OwK7xVA0575HdbsEK8LRP2bSTRUYNFjkCgYEA43qb +FaKixVC4KOm8dyNYFHB5oldZW0u4ieemum8B+a9wd2BEG8FdxFw6IuGnKyMQ1BWu +NVwN2wZsHbosmCYxGO7cX4OT37711hdCr4pCGQhQ3gf9eNls4ZjjykZp8EHWQnx8 +SYl7sjQMQUjhfqePKwR396IGx4KSrc/l1rxKYP8CgYEAjYPPJ+bIQFw7s30CVeAh +gIQBHh/vkZGQTcQb27nW9AFU9nOqXlSsnvRPJaPNAiNcxs4Ts4OX3/0qmRmsRYSP +RiNjpp24p8eQzdX7tY3mOIKX6saYf4LaIFgSO+n1ahE+ilf296fCjZXw6HjWH2cC +lr710YJQXpZmsnuP8JDRo2ECgYBrasL+5WydZi+ASldPnuYByNb3HO46GTiMDlKB +6Ndy8zBVfqTKwnWnurFNNWc+DHHu5En+Mnjse0zkgLx8IFTA5FI13Ckg18i4jwVT +ZSMvNOkS340G2wz6PrsaEkQGSuCFRsld5Ej/7mn3DhZFO5R0iMipq94tqe/fmbN7 +wjAROwKBgHLl/XNhPTI/ed76ZjmCpbCvQlKZeYLhNbTS4lHvKCuniHKQsPz4BxjB +fuVCUDH61yQT7WM31zIMfzQZjx9hTgFYYvnptRWj9zIBlIZJEieX3//flvEJ3Qmd +/tbSoADa/1y+Y58biKkgmM4f4qS9h0AkVe88OCbpm14Xs2u7/4Nu +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem new file mode 100644 index 0000000..5a4dbee --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAqhp+ySEP4Oods+29nF39auqEmJ/qTUqQCz+9iWyOhp6NU5pJ +2LZiQNxVWIzasFHp9I1cvmf+4fnstMpaFl/TtdCpQnuV+eFIe7alEP6+Pc3YiFrO +zyO0XnqJcZwmmkpr5omvGcx9FbcrKflzfgmn4ZvGIdgtwkA+ZAj6WkpZHGGpzqLY +yAFz86fwANeT4I3a90aGwOEo/on+jvJA+O8KARsFx+yspxrfSZtNVTNWFfQfkIIt +7vOWnevZNAEkMnHxY8jDFq8EACNGDo3r0j+G5imRl8P0hdklpN261OS1hANVM3l2 +t2INNN/UkZjJe3/T7RW30A0VZ3Wk/nz3IgKlDwIDAQABAoIBACV6FurrPNtZ2Vd2 +DqtvzdCLgNE7klybC+dekLzBTRl9vzdnK9PyQu11XdxXlCr6sSfvKTrOIMrazHr8 +hiKd1EAfi9sY7W8TYmvXTsDSz0lAm+9Wym+6txeFudhtBdhCg0lUll6BviFVrM3f +psFjETjUoC9+uH4ut1BE5huUe9OTmOXxupLWdETcHViMc2VrpnDsNKX/lFIMFSo7 +3JDVojyTA/xdawJgkksCmQyHLICDvqJrIbLaDKxCfEiMKMyjVqgf9qwR33WAJ73e +ES8XMVtgIce2Zpzx6OITf+gNhS0ekqsxZJ56iiacOVHxpphNKk+BwSj1bBxHLRoo +narBebkCgYEA1BuLsbfr5lXAmGxE4JG1XrOZ7YtTqQNMYzy03s6fndoITqS+YpHk +dtPqM/lQ6qByqLbaPZFVEqecIb9EVRoG1m+9rIkAutiWf/vAWwr7w7yIbFID2YBH +50crmdtbK+1eoml/MkNx2grmgelqtMy5iOzwbPcFzmgXaTBzXvJvZEUCgYEAzU3F +f3QP0xgbrT0iK6138waegsuPaLoBdq+arlZ0LMzuN7T3KTKiNfkJKWbxoaECmu1p +PpJsQpG+0cQxyKU1PK9Pz+9qUXaPf/OsRKTcvpiS2kdBFXLPEgGi2JeSoPZxErYM +WuaqLIM8krYrV0JBRgGv38Pd0u0VaSbQvPx5u0MCgYEAidFoIE6IKf64CJH44w3q +EiGSt8Va06u/+48bWtZY4kEkOq1Sw0tWbltdhu3NRNaCCdvdzDldVKSxjz/vD3i8 +zqKGVNAkOEO47mnO35kwY0tiPTfBJpbyoXUeAHeGMvGmFtODgU5PcMS6Z9kZq2aG +e1CxG6waCraZ15BStnPCKx0CgYA2n7Olhp7TPn3WqQZXcq8QdTlleX2tkpfjGTPh +oNUGOnxDTB3a00L/c0QxxNcTdwB3ciVnZZPyXk7UBwxr4zD39XkZzQyPoijqFU5H +cUneWD/yXbT+XO6lTtQiJqn3s7pADTnaUbcDYuOR8XA0pkcxti8yLS3u+e+Ra6ds +MQy+ewKBgDfHrvBhbxyYskxc/xHnSeAZjrKsKoFNmV3/n9XTmms3WAVoCYydIEou +Pm3p5kDiaiTTqLBpxoa4g2tuaEXBJpgLwxq79Jod4PA1bnip45ERRrk4kRROIaFg +eHV6U0+PQTrdFhiJkvK7CgNZVr+NLiS1V1pM3x7xI81nAV9Sv4c5 +-----END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 b/user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 new file mode 100644 index 0000000000000000000000000000000000000000..0383293487b156598a1383a699cb16e6db4a4a1b GIT binary patch literal 1612 zcmZXTdpOez7{|AtZ5mk{T5@nSilMbVGnR6hWS87_s8HAxJMCCtmiqm=Q)48&-*-|@AJNYeZF`;j0S+!@O&5o2DeC} zB`s)y)xr6E=qiK{UB>gF3wS=T{BH!y=L6F!Gy#A?sx|y?0>&G_H2(Uq77WHCAZvD< z6Q_nwKXU|tHK6l+pn~xdJsU6T+gKWOpI|W6#>7-w?*<|El0^O>)P4%m{>@9^{N)e3 z+~A3oA+g`9RLRWTs(#p{*g`%zmOjy6M10R!(o+awd_ zXbx^UyHl2Nl3BkBM2TKRv{Rz`!Q_a*ZeGp%2Sx|Xi3b?YvZR!ipKXA*7FpqKy#bH? zM((ck6e2{Dnw~ng;o!h~Wh}1Oo<8|VUcT96EIxt2X4Wr>IbQA%o2`D+u|Cv5Bz6d1 zx9ox4xxcnZnu<>03|5`=-_s?9@iQ1MP32gz&^7VMH|=rfp>x7pr4+80&y5CxXL9lI zP-uy?I{4I*Wo1hDSv?cn=W*+*3HldB$AOS)WBVn_IPJ4pH_Eg9%2Ua{ z?6q~?9=;}vSn|eAkq@B`^u-UWj$mZp+(B1np z@@FHw8}vC{M49F*U&rDBIPPW|Il>dS+jb-9)2hHN4)X+MxuP%8A8)QQk8dbN zoN~R5kq={L&JCjVO4vhDMv>~W+H2Z{Jp?L?F3`%~T{8Ot|PMdQ#bD=*|CHd$7NUqX<6r%E8g=MPgg=zk+yapIhg?Ci& z_Wzr3>4h@8$KK)E_a>;$<8IzNmXI=x-7l}cPWLTnnY5T{ex$_SJ0r%HQRgM$TvNas z+o~tdFmK89j5l_>Q&-`&_)0$~XwJjNj=kQ|#aj19_!tpf8o5Zmcnb(h<_hNXl6qn? zS%(j|Ni~gT`gH>xDQ5ib_&)@>)ZhmT6-8D*ZO7#GaZ z1kk&6F|nZZls-c}j&TuFZ5?_GC9Sl7qd^Q4U}`P03NwZIJ1?w=xf3I{24SaVae)Ia z4`msZI=iKu>N?{}d~exNn>2i&}aextd7q{jtq(Dd3SH zc{4b7LUhjy4Ge*I<<86<-)zZkba({gWLKk7MM26=-AincOYjjk$bOp zL!vtEH-|YhR5r$x&{&`42K!nUmL^>1z0I?chvAgGz*J}5MZZEv?R3t37u-W$IYy0# zYA!*274meEW?NN4eJf9RZkt*^J9C6)Oev)pAy}yg{jbJ!RGFV9H*Mw-%-tz1wqoL0 zrQW=C@;<+;jvp*xh6}ECCy{DS^-~_M6Yx|yy&YopbM-S<0nx{4>fo6NN^9x>q^SA^ zNC{cY$=hpfyQu{vskmgU(ZExnHrV1|TQ4_h#zvoD*|PQp2~)@W9qC=2i)Vil{f>nX zHeR)#+hdY)sca@}#+&>jG<-b)4bd&kz6Lm1aWbOycP3*VzJ;Iy zCMNI%{3bjc2DL<}0s2r7M0a!g#q{~O5TK6iMN8_B+@Wj3w}PyhVLV64LdIC%#r_j8 CC*Z9B literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted.p8 b/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted.p8 new file mode 100644 index 0000000000000000000000000000000000000000..df7c2e21600e2f296671ecc261f79616e864929e GIT binary patch literal 635 zcmV->0)+iAf&zB}0RS)!1_>&LNQUpVK9OMT>=3B0)c@5y${qvsC0)^ zs<}EJi_X2bW&1!q&=H!P+=6`Ss2AaM^92rJ!NGWnvbq%_TK}84dM*!$w{+eFnWdtc zQ;V&5S~2as0q5W8>@T2QQ}*VHpvY}OMPnng&rVPuDBm{XbKlmXvqn#DyA7M~sQFB# zaiNIa2dRb)Kh2pVqJ(!30s{d60Rn-5CO_njyzJ~Z%=*32;@a@{xzlc>W=5i@4WXW9}nwcGB5oBXw_aOVL>xPL0zm-b z@v`N}fRjK_bQImP@+VvjJ-}b?oJDLC0N>ErgZhvxgz~Dw-TTi2L5L8>yI!}pE~Xu- zy8B9U*qW_~4QdqvK>*e^BlBH%$kR!|lm5yL>zmrWM<{cbpitLLB;T70H?G4mwNGLQ z%H{8udqbewD<8k82$Rwl9Eq9n-zL#QnUexR0I@;je%~PXqCkJMse!bTqOp zyw=F2cqM}m@|!YO^wU2h>)e0zX{2ZCi8NOzq5SjZ*N@ VJIZuj9FdJZ@%Z_^HP^CJP#x3uH1Yrd literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 b/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 new file mode 100644 index 0000000..dee0ed4 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 @@ -0,0 +1,16 @@ +-----BEGIN PRIVATE KEY----- +MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL0P1EKodIdUqrk6 +H4vOvbdl+0A90BGanNyCfOqoF+F08wUOYcHBeIqyuhUiWv+buHouD4i3dN4EmaWi +mVOLrXhaMe28Aeff6ewvoF1T9uaKoMhtQUVjI7PPTlAfKN824nPf1qGzRk9uuw2b +76j5TKVxoYjdB6mGDT/NmSOihHcPAgMBAAECgYAmP+yWq9QfiQ6dONgnBeW2FAjX +/2l4FkrEBhZVtzpVn76G+FjoxUao8O3a1r+IVS3mciksZMldHZskOphAodKvXKsj +5DPQ6mBS53qec18ugNHcb0cPl4A20jAH3dbXFYkrdNV+irxjQgryMSm/+fnwiI+K +wiJuFSa3XltYRBw7eQJBAOHxsuXIgJNAUHQU3bLyJ1wMPcBf7pxFbBMA39DZg/qQ +LITyqsLd+88DQYgQxrtet7Yuph2quvtKctiarYgNahUCQQDWNiPzXXfI00nBk/7K +Deub2r1HKHOXoFDXTCTfmws3rsMxtU9iCMrl75d7Q6DaKx+/qAiT0hYciZnx3ybR +QpmTAkEAsUHkft8g9+Tx+U/Rai0N8ensnDrmwJS6J+J8tKWhI/bt5lNW4lAy2AKO +68d1kdPKPtQ0IHwr+y86EHKxB1a2zQJAHjvyAw10NLItvNbIpXglgw/ymzKIbiRA +hMLIiY72nFtcTY3LsIiRKrcQaGN5NpHTn1d2Lnb+i/SX992JOwvtZQJBALmvvwnJ +kCbzcou/s3znb29bo5W4ngO5z6BTujLB062Fu3lICdY/nNk3kRENBNU7ynRdHJGN +PfH4+b4117JTUB0= +-----END PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 b/user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 new file mode 100644 index 0000000000000000000000000000000000000000..0a89e7358b4104678b647bbd9388f20d8a2593ff GIT binary patch literal 2521 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 literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.cer b/user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.cer new file mode 100644 index 0000000000000000000000000000000000000000..784e26ffb786bd96d7d95ecab3eaca6f55beca66 GIT binary patch literal 604 zcmXqLVu~j5Y@Awc9&O)w85vnw84OGejSLLfm_u2(gf$Z@ zLVSW10*dmpQj<#*T=G-WD;1nmi%K%nGLsWaQWYFaOEU6{GD|8A>-Tv$Sww$6fZ7ZM^npXDTmhDd%TmW@KPQb{;U$ zn41_G8H^s-JZp^+JZXT8)Zj{EzVZkx$U{9R= z^OG*8lXiL>?_Bo3uh#aVo6#I$wpka&SKF_gz+$Xx-^jHz^xU?oA!|SSFFJMjn`(98 zrHs~>McZbYKdkZ!5;0t4Xu1yCd>1lx6yg6rn9!4LpkW+lVPdWiHi15&rcfgvT6)$}FigkQ3)MG&3|ZHZU?Y zFflTZ66ZBGFt9YRfN~9V48;sYAg1!7m})3wAOI3)7Us;!PfpCq$S*Ddx=;z(S&Xa< z%uS5^3_x)%rY1&4hM!SoHp^8DXK|$$FDhj7Wo~^bIqmTGg|jy9b9ue`g~9LH@8UO2 zt84h8re7g>>yrK*hZ3hl)AY`p9d}}0%)n#4_Vm4uu4SK!e2(xlid^R8sQxmk;Hj(a z@!MxI{O;PMe`cytGqS7_-7tC53z0t0i=n42;)7Qn=zN#7$xVI6@;S4_q{Q+oypK*( zIh-K$$JkyYc7~t!vZai&BJ1uOKalmj=+ZoYm!4PY#LZgMnttiJ&7aR>p(mz)QelTP zGl!=D|C*0tYx(0RHa5NA9JZj9UG?{-o=A4z-C`#@1MW>T>oRYZKYo?9#`Ws^hGUm6 z`)r!wc_Z}a-;{mNV>P^#_wsj7Grh{h%*eoq974c|1BMVIgUqU~+buVuH|I+=Db;Li zJ-K89BWu0IgO{B%CwIQR{#3x-y-xq@&x4a^Eoc3AB*p#EjuZAXFAL00%-P=EcwRp1 z!_VB>lTDfR`>&j3eOB{O=*-Ex2kz}T5O?HewR7kFgezwqH9Sv=ELeYC;Lkdn$(I;j zw*(dn|K-gNGPf={Z(tFiwRD2?sq!Uv3-nhr8!u|S5q#c#Yxbq7HA^;bttsMQkvy?H zr#3S&T=jh9-F0j4bJT1Px# literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem new file mode 100644 index 0000000..95bdb5a --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC3DCCAcQCCQClKsh4h/LnyTANBgkqhkiG9w0BAQUFADA0MTIwMAYDVQQKEylh +eFRMUyBQcm9qZWN0IERvZGd5IENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNjEy +MzAyMTA0MjdaFw0zMDA5MDgyMTA0MjdaMCwxFjAUBgNVBAoTDWF4VExTIFByb2pl +Y3QxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAPladjynJXGaCmdzonEGTQOF6RmWw/ehmrG+ROur6DD7m+5fspZ+gPQm +L3gZ2tIv3EB0QsKWLs82x0IDowAMO63L3oiKpvJyTMQPARTTCQh79JJw5UU9x9vM +aE7dPGfzAnwmMjl6FbCTkugUjknRVcs4X1OpwInuYrJGJ5innJoWGhZveEvFliTD +YBL8Mz8oXZhOK6alAR0Urt8z4B1J0USDn7ouSnWRsyqWgvotRp+fDDguFi/JILhD +AwhJEA+s8RatD1+RgYLvs1aghQcl+7KMWQdNuxbJiVDeljaKN4Ufx9UFfEXV74DG +09NMsphJ2FX5/WS+510oSiO9D4uWNdUCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +HKqK24TYW7NvGoIifLaFyaSwAQV/OODpiZmTie3X5RBHR34v9fnBk5qnBf7EZEfC +uMg/mdMQm2Fst4uBzx9q8PltfcmCaX+/1M0F5nzhEszJ3cDevMBexNl7Q4nfYNTN +QShJyhSgr9cQ/K48k9IA64RRcRP9DWtSNzt0zzA4UCqlkBvKd6TdcC+rAzOigdhT +z0e1a9KVfKSxtXxyCAQZyKdsfWlhVyXPWd2urd8IfLfHdiFMKwyyreCCc4tCDjcA +QcJkv2bfL8Cb4cUd2vtI8kic9zUBFaOWyz9tOicGG2k3SBjN99iQfBAsqbHjtGnj ++dKbDCxXy4udsNINgfE3aA== +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.cer b/user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.cer new file mode 100644 index 0000000000000000000000000000000000000000..f90fb1cc28c86af31bb0a93aa18c129d2d3698b6 GIT binary patch literal 992 zcmV<610Vb_f&<(zf&#<>2>_)k$ashH=gKe*1_>&LNQU@ro9v2NUHZd|Y zFfuVPG%`0@7Y#EoFgY+dGBGeTGB;WY-n$DbTEPfA}|dG2`Yw2hW8Bt0RaU71A+n%05F0A3Ic)x0RX@X zPNUcKvn9yzIfRh^Ja}-RWuFDQX9x+(oE7a3%LIK=#ng2OOsJ>KE-x09%08^xg>X0Q zHy|aHAmXdfU8nYqk9emEP$*t@iMl3G>DB#G&{0%Hy>h?v=@{Uxls)*#8#^D2T~~PE zk0TLfZd+;!)#Ni%;Z$#3osW)YO`_>9pmANr#tXN$DJPEan3lpTOvq`8LMqkq`)yFx zx>fS7?kh17EcuP4Cb=sNWQlqnIln6znZ`hF7X4Y9Vx%gfEm!rbL4d2C2&L4Hb0oOO zSW{yIt@u-|@>!ZWEo2z-nt8)5EVM5>$dLQeyDZK*x6SD7Tm@pLZM*nop4GC5=|B~K zA-Bus!~mm)bJqG&l?m=7Pj`KTt&oY=8=F;a%g5*n<$?>b{@*|ZPXV_zDZ7c-Vs^jS zp&;Dkt0ek2p-G<4!Eu?#0eLZ!;Hx1K3 z2=dh45AKOWq?mP9OnIwk+i45Pt5M9N^rjf1uQ|2jj0!531zLzJq>{hgja^fE?MY9a z8b7;g2;-{-fLd5{wIJYn#8Z-fkR-X4U*ZafvR$K2BG~IN;gP4wf`I}90RRCo4F(A+ zhDe6@4FLfK1potr0RaFL@KNiqM#QC5L6G ze>~xk+?vfj)}U+iSBjy`u1Zt8>tH{{n0)wpm#ij<5rH&0c zZtJ76;$u0Laz23cXCmrpx#jBmWM%Zok51H8&SWe=1oB0YF#wZ+kV(ec5HML^OFIr+(nIT`uIB?fZhyoP257KWyV21W*^W>Mn2#s&r^ zMkY|MfwrNhfjY!A1r*a1TvE$2lT#I(Q;SM6(=wA2OHvIQ=Oa6Yk(GhDv6sQ1v6HE> zk>S7|p$yLd2f|Dj=6{NLb1Le)z%wq^#+EJTl9w%E`!60XT(|XFkkJ3no-yAWU3d7; zeH?nIsB2}{pS#Crh(G_JdEYB@+y4H)wg*(R93>BLkn}pu$Na90|Ks|*IoH~ETxV8(yjZKI!|a$yap-3Wlh%B$#z%(6%RbK3{-(O&X4>hayZ<(` zuIxW{ovZZQzus~lv8Pp`EN}Jro;;Y!xz{D`#e=>D6Wj$hS-)^xZIJHu_xsh!Zthza d?&43cZg3RhOG+2|`$Fh=y_^1Dp%9^+ivW7xwDbS~ literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem new file mode 100644 index 0000000..2ecdabe --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem @@ -0,0 +1,34 @@ +-----BEGIN CERTIFICATE----- +MIICUjCCAbsCCQClKsh4h/LnyzANBgkqhkiG9w0BAQUFADAsMRYwFAYDVQQKEw1h +eFRMUyBQcm9qZWN0MRIwEAYDVQQDEwlsb2NhbGhvc3QwHhcNMTYxMjMwMjEwNDI3 +WhcNMzAwOTA4MjEwNDI3WjArMSkwJwYDVQQKEyBheFRMUyBQcm9qZWN0IERldmlj +ZSBDZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL1d +D6JnZqcce7NfbntIrT5T7rFq00sKH6FhFNeNXae3EvXl3Ep0FeaX72L78NtR7GR8 +vsVtnLqY0Ac76j7a66gM+KdhPVR0zLs7w0knI+hlNAVA/hkN6rYS5FzH4e6SWRTe +Q2LVas0hPrn2ZWJXwarE9QTjfXkbNn03+jpzBQKcdADYychRJbtnBH94on/92ejx +dIlDbSmgzQ1b1QaIkWvZlLo+L8Z8h+B5ss04adm1wyzFDlYs/1lmbPTZf0KCXbsi +WRhIotVDOVUvNakJ7tnU9YPxNMj18LTkFJ1YI0jD31vggMidV03UsFQ0rMlwKcsc +bUhGGzPNbdxhr5pgn/kCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBX+beg1jGMSqQd +6Q/d07mQCLuEwmXmmz7hc0lgp6IumjsxulO2xLiotXie7e3GIRAVgJsd6ysRJKim +IioOMxcwUMWw0CcqjcwqorczJjsqzW99dzCd3NcDiDxx+7Pye58D8qOLHGtafC9n +TjQELV6dNIUX5IfH/18jAkPEmFcOUg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDDjCCAfagAwIBAgIJAORglrABpAToMA0GCSqGSIb3DQEBBQUAMDQxMjAwBgNV +BAoTKWF4VExTIFByb2plY3QgRG9kZ3kgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X +DTE2MTIzMDIxMDQyN1oXDTMwMDkwODIxMDQyN1owNDEyMDAGA1UEChMpYXhUTFMg +UHJvamVjdCBEb2RneSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCxIzCSlgeXAiyLWjGWUkuMA+OPJzH23pDcE7Nc +FKhkdzXAD6tBW4odqul7y1g4qU0/xvv16NsK//VTc2VWQwkm0tlQ+0PBMTBRk0Qb +XuLFLjfyYYjUBsde/CE9qhPbhTKYQ5xsnEBm4KUN/Mqk3sKXo7M3s7HjiAeYEIFK +dSFECcljEPrHzAEvDwd0fRsx2hzb4fgrJbfW4wa9rsL1iVQI9VAY8mxM/UMtGySr +L7M7U0RFRM5fK0d5guWH9f+j41hW9R/tYq7qoLcjgcr45nk5bcT4RoTvehhGZRUN +pVq8vttEoR/Y1JvOjBT5WwUSfJcgXtidEWnQPXKszNoLj1sNAgMBAAGjIzAhMA8G +A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IB +AQByY8+gtxSKO5ASYKArY8Sb4xJw0MNwsosARm17sT/8UTerS9CssUQXkW4LaU3T +SzFVxRUz9O+74yu87W58IaxGNq80quFkOfpS39eCtbqD2e4Y/JuC30hK/GmhBquD +gVh3z3hD8+DUXq83T1+9zgjCppLeQfaFejbaJSwQ7+K6gJn5JZNiaHVGN1GO6lT6 +5W3zqep5zU6a4T5UeZqkYyuzfTBbIkgEga0JzPaCdd5JOrwFR3UNWlICOxr7htDI +FqiTrA0RH2ZNmrmJDcM1pFWlQAPnvDoRLeMpmvWZDnGrWYDzyt0j5G0bIPL7214c +b5kxOvfGlM4E6v+lMSw/HDrI +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem new file mode 100644 index 0000000..c0a4eb3 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDJDCCAgygAwIBAgIJAKUqyHiH8ufOMA0GCSqGSIb3DQEBCwUAMCgxJjAkBgNV +BAoTHWF4VExTIFByb2plY3QgSW50ZXJtZWRpYXRlIENBMB4XDTE2MTIzMDIxMDQy +OFoXDTMwMDkwODIxMDQyOFowLDEWMBQGA1UEChMNYXhUTFMgUHJvamVjdDESMBAG +A1UEAxMJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA +7R4S75j5ZfknrzbsAvUnqS997FNk545sGo0YraDQ7CeJXGqeDyUTpdwtzBt8H8/a +xNP1BFdgNEWnF1C1HXVbhqWxq16IlakqZYkYldHJMPQgFa3YuRN4Y0i8sn8A1Fbe +69D//57JZr1wt+qxAJWWn0anPGXmR0HlO0At1ACQkKGSE+ajTB2TnO7UTsjKRrXP +v16FdWTXkJTVHUdVuAs6IfgAKkvQQ5zA8D6IXgjWsToWdFzlI8eTDHZqZJiw8gPg +7xG0jepN9JU05JRc4NduzeVj/0WT0tdilO0jQP/+8FgikdOeDU6wo4/e0Ta5bdZe +7apqOBfdDnq3EUnHO1ZQbQIDAQABo00wSzAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB +/wQEAwIF4DArBgNVHREEJDAigg93d3cuZXhhbXBsZS5uZXSCD3d3dy5leGFtcGxl +Lm9yZzANBgkqhkiG9w0BAQsFAAOCAQEAbPQ1Y205Ricl1K2ByVa2RHJyYGP0Qj+H +5mWj4A92N1vAb6uOrliqFYOClYINGsKKC8YDZdyA4c8ZglCKZ2RePwOSdaWIw7wi +Efhysyq3WLSlo5jEcnkO7o5dV/7V7FX/+65UEXu35ZqaE8ZY++eotmLzccnInYP3 +1e4oaF5hyZIHVNCXnywNvchSkXjN0HhvIpeLTyzC5MQkQMMEOi8EBOgTGAo4UvL9 +eau3YhhpvfnCDlrRB6N79RcTLmJyOj5g1YO/9wn/du+EMwEkKUg5QJHzwUB2+ISp +57JjKh2BQt0g/XJfRugHQcNtjUu73Ziexpl0qaXjNjb8mvsuV9RX0g== +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem new file mode 100644 index 0000000..743dbc0 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDJjCCAg6gAwIBAgIJAKUqyHiH8ufPMA0GCSqGSIb3DQEBCwUAMCoxKDAmBgNV +BAoTH2F4VExTIFByb2plY3QgSW50ZXJtZWRpYXRlIDIgQ0EwHhcNMTYxMjMwMjEw +NDI4WhcNMzAwOTA4MjEwNDI4WjAsMRYwFAYDVQQKEw1heFRMUyBQcm9qZWN0MRIw +EAYDVQQDEwlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQDtHhLvmPll+SevNuwC9SepL33sU2TnjmwajRitoNDsJ4lcap4PJROl3C3MG3wf +z9rE0/UEV2A0RacXULUddVuGpbGrXoiVqSpliRiV0ckw9CAVrdi5E3hjSLyyfwDU +Vt7r0P//nslmvXC36rEAlZafRqc8ZeZHQeU7QC3UAJCQoZIT5qNMHZOc7tROyMpG +tc+/XoV1ZNeQlNUdR1W4Czoh+AAqS9BDnMDwPoheCNaxOhZ0XOUjx5MMdmpkmLDy +A+DvEbSN6k30lTTklFzg127N5WP/RZPS12KU7SNA//7wWCKR054NTrCjj97RNrlt +1l7tqmo4F90OercRScc7VlBtAgMBAAGjTTBLMAwGA1UdEwEB/wQCMAAwDgYDVR0P +AQH/BAQDAgXgMCsGA1UdEQQkMCKCD3d3dy5leGFtcGxlLm5ldIIPd3d3LmV4YW1w +bGUub3JnMA0GCSqGSIb3DQEBCwUAA4IBAQBGJydzARx5fNYprptRG9c3pqecGKlX +ArxbLe+K+83wS427HnWONnuZ5LJKGkuXjIeh1G/2AfKYXJz/SMN0IPYY3ro5Lt1Z +GOPyn01qcj6OkfyiUPCDIsVFS9V0TVLTBLTMZFa1j6nMHs8Ajmm10Fkf/NQP/CVk +zEgoktjb+wLqw1iPUGqkVepVtp3wg7VQY6E07SliNp/06Q3ue6xLJnYlKqFhUQf7 +064JyRIH9W/C2WnxWbKRBjsE4gCRnMvKQrCrfR64VohCr6XvygIIufwCG/CLJogn +4OJMqz1oDkABPgSgjNhOdwnt+3dvxbjQBiRy1ERfNAJLo+V6x6aO1Gqz +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem new file mode 100644 index 0000000..4fbad81 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDAjCCAeqgAwIBAgIJAKUqyHiH8ufMMA0GCSqGSIb3DQEBCwUAMDQxMjAwBgNV +BAoTKWF4VExTIFByb2plY3QgRG9kZ3kgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X +DTE2MTIzMDIxMDQyN1oXDTMwMDkwODIxMDQyN1owKDEmMCQGA1UEChMdYXhUTFMg +UHJvamVjdCBJbnRlcm1lZGlhdGUgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDOF2/0KBnz3n4m4Xgnm22ApLwcMovm4IBg5LYH6jU6QbNhGRIj68Dj +UGk98TwPw/2WCNxvMA6s6+Bgc9md4TcjHWaGXI/Budd6wLjwBqFtZd4cUku7cevc +R+MhWeCm0gcXT8VeYu06NzEuk/+ZfJRNftubQ0yGAS/EBffh89+AzivoDA9gvDEk +aXRziutv1yGgOZenv7vY2eOI7+lfOtSQjRUv59XpT9xP2ujqnrAlh7C99cDOpXTU +HvrF/5CFganqH8dJlCe1NB8DYoincfuOFpVeAL8LLJn9+/HVBQBULLykxyQWzti4 +u1W6EA5nUql5nNpCi3BGNMR5GQX32ILHAgMBAAGjIzAhMBIGA1UdEwEB/wQIMAYB +Af8CAQAwCwYDVR0PBAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAYt1Wq1XsZjOWf +mH9XzI3k8UEtErTkBX5SXH10siY5tYmHzH02jaZVRC1yNrxQevqARhR1yj3daKg3 ++innX8foKlYRCxTfFeE/HELcm7rIt5mrIGdGAFn2fnImO5kpXxbPk6IAXRTp6lN8 +QS08Ah1Aaeh0ae2Ruzx2TOnG/IuB7ChliJxepo0KtRw6RN6ETvC2KS0glSf5fPW7 +c18UPbTesecrki12FlaGbPD/sWHOltBIpPXzgef7G8b6CiYqaX0T3T/47RLRwrMm +SAcbMerJZoyudbLd+OHGtvz5kOmYCoZYkay121MSvtFucHnR3UjEui2lUbL1Qi92 +2L3MUIVn +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem new file mode 100644 index 0000000..ea8ab7d --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem @@ -0,0 +1,37 @@ +-----BEGIN CERTIFICATE----- +MIIC+TCCAeGgAwIBAgIJAKUqyHiH8ufNMA0GCSqGSIb3DQEBCwUAMCgxJjAkBgNV +BAoTHWF4VExTIFByb2plY3QgSW50ZXJtZWRpYXRlIENBMB4XDTE2MTIzMDIxMDQy +N1oXDTMwMDkwODIxMDQyN1owKjEoMCYGA1UEChMfYXhUTFMgUHJvamVjdCBJbnRl +cm1lZGlhdGUgMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoa +fskhD+DqHbPtvZxd/WrqhJif6k1KkAs/vYlsjoaejVOaSdi2YkDcVViM2rBR6fSN +XL5n/uH57LTKWhZf07XQqUJ7lfnhSHu2pRD+vj3N2Ihazs8jtF56iXGcJppKa+aJ +rxnMfRW3Kyn5c34Jp+GbxiHYLcJAPmQI+lpKWRxhqc6i2MgBc/On8ADXk+CN2vdG +hsDhKP6J/o7yQPjvCgEbBcfsrKca30mbTVUzVhX0H5CCLe7zlp3r2TQBJDJx8WPI +wxavBAAjRg6N69I/huYpkZfD9IXZJaTdutTktYQDVTN5drdiDTTf1JGYyXt/0+0V +t9ANFWd1pP589yICpQ8CAwEAAaMkMCIwEgYDVR0TAQH/BAgwBgEB/wIBCjAMBgNV +HQ8EBQMDBwWAMA0GCSqGSIb3DQEBCwUAA4IBAQBNWDjqxlO0BwMdyxfUs1wDsLiq +4hOmUFwCv8TuTFsL9aNe7OIJRT8IF2pHw07qyvAxJVEWUCLK/KLq0HrRTzRZO/tK +eNroHMHS+fBwFuHFp+1RGMK2rHLajxVVB6X0aeLWKrNKrvUQZL+Tx+NZ3dEO62rq +rANnElCrnyI1bIBKwHdUbOMOHeZAECr7H0KfvaX8F67aln4IwPzCauQM3DFf9h9Z +FvmxUdVgjRZK4e5he9k4gT/Faom0z/ApnW4DJRF8rpCPWqN872aNpL8NPZuOFtiD +Gzg5O4wJYx7OWIPa/qcQ0hTbn5waPzC68X448tlJTPiwyeKsYT3JwWqLi6o5 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDAjCCAeqgAwIBAgIJAKUqyHiH8ufMMA0GCSqGSIb3DQEBCwUAMDQxMjAwBgNV +BAoTKWF4VExTIFByb2plY3QgRG9kZ3kgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X +DTE2MTIzMDIxMDQyN1oXDTMwMDkwODIxMDQyN1owKDEmMCQGA1UEChMdYXhUTFMg +UHJvamVjdCBJbnRlcm1lZGlhdGUgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDOF2/0KBnz3n4m4Xgnm22ApLwcMovm4IBg5LYH6jU6QbNhGRIj68Dj +UGk98TwPw/2WCNxvMA6s6+Bgc9md4TcjHWaGXI/Budd6wLjwBqFtZd4cUku7cevc +R+MhWeCm0gcXT8VeYu06NzEuk/+ZfJRNftubQ0yGAS/EBffh89+AzivoDA9gvDEk +aXRziutv1yGgOZenv7vY2eOI7+lfOtSQjRUv59XpT9xP2ujqnrAlh7C99cDOpXTU +HvrF/5CFganqH8dJlCe1NB8DYoincfuOFpVeAL8LLJn9+/HVBQBULLykxyQWzti4 +u1W6EA5nUql5nNpCi3BGNMR5GQX32ILHAgMBAAGjIzAhMBIGA1UdEwEB/wQIMAYB +Af8CAQAwCwYDVR0PBAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAYt1Wq1XsZjOWf +mH9XzI3k8UEtErTkBX5SXH10siY5tYmHzH02jaZVRC1yNrxQevqARhR1yj3daKg3 ++innX8foKlYRCxTfFeE/HELcm7rIt5mrIGdGAFn2fnImO5kpXxbPk6IAXRTp6lN8 +QS08Ah1Aaeh0ae2Ruzx2TOnG/IuB7ChliJxepo0KtRw6RN6ETvC2KS0glSf5fPW7 +c18UPbTesecrki12FlaGbPD/sWHOltBIpPXzgef7G8b6CiYqaX0T3T/47RLRwrMm +SAcbMerJZoyudbLd+OHGtvz5kOmYCoZYkay121MSvtFucHnR3UjEui2lUbL1Qi92 +2L3MUIVn +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/ca-bundle.crt b/user/mpy/lib/axtls/ssl/test/ca-bundle.crt new file mode 100644 index 0000000..0c00239 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/ca-bundle.crt @@ -0,0 +1,3585 @@ +-----BEGIN CERTIFICATE----- +MIIEuDCCA6CgAwIBAgIBBDANBgkqhkiG9w0BAQUFADCBtDELMAkGA1UEBhMCQlIx +EzARBgNVBAoTCklDUC1CcmFzaWwxPTA7BgNVBAsTNEluc3RpdHV0byBOYWNpb25h +bCBkZSBUZWNub2xvZ2lhIGRhIEluZm9ybWFjYW8gLSBJVEkxETAPBgNVBAcTCEJy +YXNpbGlhMQswCQYDVQQIEwJERjExMC8GA1UEAxMoQXV0b3JpZGFkZSBDZXJ0aWZp +Y2Fkb3JhIFJhaXogQnJhc2lsZWlyYTAeFw0wMTExMzAxMjU4MDBaFw0xMTExMzAy +MzU5MDBaMIG0MQswCQYDVQQGEwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDE9MDsG +A1UECxM0SW5zdGl0dXRvIE5hY2lvbmFsIGRlIFRlY25vbG9naWEgZGEgSW5mb3Jt +YWNhbyAtIElUSTERMA8GA1UEBxMIQnJhc2lsaWExCzAJBgNVBAgTAkRGMTEwLwYD +VQQDEyhBdXRvcmlkYWRlIENlcnRpZmljYWRvcmEgUmFpeiBCcmFzaWxlaXJhMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwPMudwX/hvm+Uh2b/lQAcHVA +isamaLkWdkwP9/S/tOKIgRrL6Oy+ZIGlOUdd6uYtk9Ma/3pUpgcfNAj0vYm5gsyj +Qo9emsc+x6m4VWwk9iqMZSCK5EQkAq/Ut4n7KuLE1+gdftwdIgxfUsPt4CyNrY50 +QV57KM2UT8x5rrmzEjr7TICGpSUAl2gVqe6xaii+bmYR1QrmWaBSAG59LrkrjrYt +bRhFboUDe1DK+6T8s5L6k8c8okpbHpa9veMztDVC9sPJ60MWXh6anVKo1UcLcbUR +yEeNvZneVRKAAU6ouwdjDvwlsaKydFKwed0ToQ47bmUKgcm+wV3eTRk36UOnTwID +AQABo4HSMIHPME4GA1UdIARHMEUwQwYFYEwBAQAwOjA4BggrBgEFBQcCARYsaHR0 +cDovL2FjcmFpei5pY3BicmFzaWwuZ292LmJyL0RQQ2FjcmFpei5wZGYwPQYDVR0f +BDYwNDAyoDCgLoYsaHR0cDovL2FjcmFpei5pY3BicmFzaWwuZ292LmJyL0xDUmFj +cmFpei5jcmwwHQYDVR0OBBYEFIr68VeEERM1kEL6V0lUaQ2kxPA3MA8GA1UdEwEB +/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQAZA5c1 +U/hgIh6OcgLAfiJgFWpvmDZWqlV30/bHFpj8iBobJSm5uDpt7TirYh1Uxe3fQaGl +YjJe+9zd+izPRbBqXPVQA34EXcwk4qpWuf1hHriWfdrx8AcqSqr6CuQFwSr75Fos +SzlwDADa70mT7wZjAmQhnZx2xJ6wfWlT9VQfS//JYeIc7Fue2JNLd00UOSMMaiK/ +t79enKNHEA2fupH3vEigf5Eh4bVAN5VohrTm6MY53x7XQZZr1ME7a55lFEnSeT0u +mlOAjR2mAbvSM5X5oSZNrmetdzyTj2flCM8CC7MLab0kkdngRIlUBGHF1/S5nmPb +K+9A46sd33oqK8n8 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIESzCCAzOgAwIBAgIJAJigUTEEXRQpMA0GCSqGSIb3DQEBBQUAMHYxCzAJBgNV +BAYTAkRFMQ8wDQYDVQQIEwZIZXNzZW4xDjAMBgNVBAcTBUZ1bGRhMRAwDgYDVQQK +EwdEZWJjb25mMRMwEQYDVQQDEwpEZWJjb25mIENBMR8wHQYJKoZIhvcNAQkBFhBq +b2VyZ0BkZWJpYW4ub3JnMB4XDTA1MTEwNTE3NTUxNFoXDTE1MTEwMzE3NTUxNFow +djELMAkGA1UEBhMCREUxDzANBgNVBAgTBkhlc3NlbjEOMAwGA1UEBxMFRnVsZGEx +EDAOBgNVBAoTB0RlYmNvbmYxEzARBgNVBAMTCkRlYmNvbmYgQ0ExHzAdBgkqhkiG +9w0BCQEWEGpvZXJnQGRlYmlhbi5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQCvbOo0SrIwI5IMlsshH8WF3dHB9r9JlSKhMPaybawa1EyvZspMQ3wa +F5qxNf3Sj+NElEmjseEqvCZiIIzqwerHu0Qw62cDYCdCd2+Wb5m0bPYB5CGHiyU1 +eNP0je42O0YeXG2BvUujN8AviocVo39X2YwNQ0ryy4OaqYgm2pRlbtT2ESbF+SfV +Y2iqQj/f8ymF+lHo/pz8tbAqxWcqaSiHFAVQJrdqtFhtoodoNiE3q76zJoUkZTXB +k60Yc3MJSnatZCpnsSBr/D7zpntl0THrUjjtdRWCjQVhqfhM1yZJV+ApbLdheFh0 +ZWlSxdnp25p0q0XYw/7G92ELyFDfBUUNAgMBAAGjgdswgdgwHQYDVR0OBBYEFMuV +dFNb4mCWUFbcP5LOtxFLrEVTMIGoBgNVHSMEgaAwgZ2AFMuVdFNb4mCWUFbcP5LO +txFLrEVToXqkeDB2MQswCQYDVQQGEwJERTEPMA0GA1UECBMGSGVzc2VuMQ4wDAYD +VQQHEwVGdWxkYTEQMA4GA1UEChMHRGViY29uZjETMBEGA1UEAxMKRGViY29uZiBD +QTEfMB0GCSqGSIb3DQEJARYQam9lcmdAZGViaWFuLm9yZ4IJAJigUTEEXRQpMAwG +A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAGZXxHg4mnkvilRIM1EQfGdY +S5b/WcyF2MYSTeTvK4aIB6VHwpZoZCnDGj2m2D3CkHT0upAD9o0zM1tdsfncLzV+ +mDT/jNmBtYo4QXx5vEPwvEIcgrWjwk7SyaEUhZjtolTkHB7ACl0oD0r71St4iEPR +qTUCEXk2E47bg1Fz58wNt/yo2+4iqiRjg1XCH4evkQuhpW+dTZnDyFNqwSYZapOE +TBA+9zBb6xD1KM2DdY7r4GiyYItN0BKLfuWbh9LXGbl1C+f4P11g+m2MPiavIeCe +1iazG5pcS3KoTLACsYlEX24TINtg4kcuS81XdllcnsV3Kdts0nIqPj6uhTTZD0k= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDtTCCAp2gAwIBAgIRANAeQJAAAEZSAAAAAQAAAAQwDQYJKoZIhvcNAQEFBQAw +gYkxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJEQzETMBEGA1UEBxMKV2FzaGluZ3Rv +bjEXMBUGA1UEChMOQUJBLkVDT00sIElOQy4xGTAXBgNVBAMTEEFCQS5FQ09NIFJv +b3QgQ0ExJDAiBgkqhkiG9w0BCQEWFWFkbWluQGRpZ3NpZ3RydXN0LmNvbTAeFw05 +OTA3MTIxNzMzNTNaFw0wOTA3MDkxNzMzNTNaMIGJMQswCQYDVQQGEwJVUzELMAkG +A1UECBMCREMxEzARBgNVBAcTCldhc2hpbmd0b24xFzAVBgNVBAoTDkFCQS5FQ09N +LCBJTkMuMRkwFwYDVQQDExBBQkEuRUNPTSBSb290IENBMSQwIgYJKoZIhvcNAQkB +FhVhZG1pbkBkaWdzaWd0cnVzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQCx0xHgeVVDBwhMywVCAOINg0Y95JO6tgbTDVm9PsHOQ2cBiiGo77zM +0KLMsFWWU4RmBQDaREmA2FQKpSWGlO1jVv9wbKOhGdJ4vmgqRF4vz8wYXke8OrFG +PR7wuSw0X4x8TAgpnUBV6zx9g9618PeKgw6hTLQ6pbNfWiKX7BmbwQVo/ea3qZGU +LOR4SCQaJRk665WcOQqKz0Ky8BzVX/tr7WhWezkscjiw7pOp03t3POtxA6k4ShZs +iSrK2jMTecJVjO2cu/LLWxD4LmE1xilMKtAqY9FlWbT4zfn0AIS2V0KFnTKo+SpU ++/94Qby9cSj0u5C8/5Y0BONFnqFGKECBAgMBAAGjFjAUMBIGA1UdEwEB/wQIMAYB +Af8CAQgwDQYJKoZIhvcNAQEFBQADggEBAARvJYbk5pYntNlCwNDJALF/VD6Hsm0k +qS8Kfv2kRLD4VAe9G52dyntQJHsRW0mjpr8SdNWJt7cvmGQlFLdh6X9ggGvTZOir +vRrWUfrAtF13Gn9kCF55xgVM8XrdTX3O5kh7VNJhkoHWG9YA8A6eKHegTYjHInYZ +w8eeG6Z3ePhfm1bR8PIXrI6dWeYf/le22V7hXZ9F7GFoGUHhsiAm/lowdiT/QHI8 +eZ98IkirRs3bs4Ysj78FQdPB4xTjQRcm0HyncUwZ6EoPclgxfexgeqMiKL0ZJGA/ +O4dzwGvky663qyVDslUte6sGDnVdNOVdc22esnVApVnJTzFxiNmIf1Q= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs +IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 +MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux +FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h +bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v +dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt +H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 +uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX +mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX +a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN +E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 +WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD +VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 +Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU +cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx +IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN +AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH +YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 +6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC +Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX +c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a +mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEGDCCAwCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 +b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwHhcNMDAwNTMw +MTAzODMxWhcNMjAwNTMwMTAzODMxWjBlMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYD +VQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUA +A4IBDwAwggEKAoIBAQCWltQhSWDia+hBBwzexODcEyPNwTXH+9ZOEQpnXvUGW2ul +CDtbKRY654eyNAbFvAWlA3yCyykQruGIgb3WntP+LVbBFc7jJp0VLhD7Bo8wBN6n +tGO0/7Gcrjyvd7ZWxbWroulpOj0OM3kyP3CCkplhbY0wCI9xP6ZIVxn4JdxLZlyl +dI+Yrsj5wAYi56xz36Uu+1LcsRVlIPo1Zmne3yzxbrww2ywkEtvrNTVokMsAsJch +PXQhI2U0K7t4WaPW4XY5mqRJjox0r26kmqPZm9I4XJuiGMx1I4S+6+JNM3GOGvDC ++Mcdoq0Dlyz4zyXG9rgkMbFjXZJ/Y/AlyVMuH79NAgMBAAGjgdIwgc8wHQYDVR0O +BBYEFJWxtPCUtr3H2tERCSG+wa9J/RB7MAsGA1UdDwQEAwIBBjAPBgNVHRMBAf8E +BTADAQH/MIGPBgNVHSMEgYcwgYSAFJWxtPCUtr3H2tERCSG+wa9J/RB7oWmkZzBl +MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFk +ZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENB +IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBACxtZBsfzQ3duQH6lmM0MkhHma6X +7f1yFqZzR1r0693p9db7RcwpiURdv0Y5PejuvE1Uhh4dbOMXJ0PhiVYrqW9yTkkz +43J8KiOavD7/KCrto/8cI7pDVwlnTUtiBi34/2ydYB7YHEt9tTEv2dB8Xfjea4MY +eDdXL+gzB2ffHsdrKpV2ro9Xo/D0UrSpUwjP4E/TelOL/bscVjby/rK25Xa71SJl +pz/+0WatC7xrmYbvP33zGDLKe8bjq2RGlfgmadlVg3sslgf/WSxEo8bl6ancoWOA +WiFeIc9TVPC6b4nbqKqVz4vjccweGyBECMB6tkD9xOQ14R0WHNC8K47Wcdk= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEFTCCAv2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 +b3JrMSAwHgYDVQQDExdBZGRUcnVzdCBQdWJsaWMgQ0EgUm9vdDAeFw0wMDA1MzAx +MDQxNTBaFw0yMDA1MzAxMDQxNTBaMGQxCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtB +ZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5ldHdvcmsxIDAeBgNV +BAMTF0FkZFRydXN0IFB1YmxpYyBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA6Rowj4OIFMEg2Dybjxt+A3S72mnTRqX4jsIMEZBRpS9mVEBV +6tsfSlbunyNu9DnLoblv8n75XYcmYZ4c+OLspoH4IcUkzBEMP9smcnrHAZcHF/nX +GCwwfQ56HmIexkvA/X1id9NEHif2P0tEs7c42TkfYNVRknMDtABp4/MUTu7R3AnP +dzRGULD4EfL+OHn3Bzn+UZKXC1sIXzSGAa2Il+tmzV7R/9x98oTaunet3IAIx6eH +1lWfl2royBFkuucZKT8Rs3iQhCBSWxHveNCD9tVIkNAwHM+A+WD+eeSI8t0A65RF +62WUaUC6wNW0uLp9BBGo6zEFlpROWCGOn9Bg/QIDAQABo4HRMIHOMB0GA1UdDgQW +BBSBPjfYkrAfd59ctKtzquf2NGAv+jALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/BAUw +AwEB/zCBjgYDVR0jBIGGMIGDgBSBPjfYkrAfd59ctKtzquf2NGAv+qFopGYwZDEL +MAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRU +cnVzdCBUVFAgTmV0d29yazEgMB4GA1UEAxMXQWRkVHJ1c3QgUHVibGljIENBIFJv +b3SCAQEwDQYJKoZIhvcNAQEFBQADggEBAAP3FUr4JNojVhaTdt02KLmuG7jD8WS6 +IBh4lSknVwW8fCr0uVFV2ocC3g8WFzH4qnkuCRO7r7IgGRLlk/lL+YPoRNWyQSW/ +iHVv/xD8SlTQX/D67zZzfRs2RcYhbbQVuE7PnFylPVoAjgbjPGsye/Kf8Lb93/Ao +GEjwxrzQvzSAlsJKsW2Ox5BF3i9nrEUEo3rcVZLJR2bYGozH7ZxOmuASu7VqTITh +4SINhwBk/ox9Yjllpu9CtoAlEmEBqCQTcAARJl/6NVDFSMwGR+gn2HCNX2TmoUQm +XiLsks3/QppEIW1cxeMiHV9HEufOX1362KqxMy3ZdvJOOjMMK7MtkAY= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 +b3JrMSMwIQYDVQQDExpBZGRUcnVzdCBRdWFsaWZpZWQgQ0EgUm9vdDAeFw0wMDA1 +MzAxMDQ0NTBaFw0yMDA1MzAxMDQ0NTBaMGcxCzAJBgNVBAYTAlNFMRQwEgYDVQQK +EwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5ldHdvcmsxIzAh +BgNVBAMTGkFkZFRydXN0IFF1YWxpZmllZCBDQSBSb290MIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEA5B6a/twJWoekn0e+EV+vhDTbYjx5eLfpMLXsDBwq +xBb/4Oxx64r1EW7tTw2R0hIYLUkVAcKkIhPHEWT/IhKauY5cLwjPcWqzZwFZ8V1G +87B4pfYOQnrjfxvM0PC3KP0q6p6zsLkEqv32x7SxuCqg+1jxGaBvcCV+PmlKfw8i +2O+tCBGaKZnhqkRFmhJePp1tUvznoD1oL/BLcHwTOK28FSXx1s6rosAx1i+f4P8U +WfyEk9mHfExUE+uf0S0R+Bg6Ot4l2ffTQO2kBhLEO+GRwVY18BTcZTYJbqukB8c1 +0cIDMzZbdSZtQvESa0NvS3GU+jQd7RNuyoB/mC9suWXY6QIDAQABo4HUMIHRMB0G +A1UdDgQWBBQ5lYtii1zJ1IC6WA+XPxUIQ8yYpzALBgNVHQ8EBAMCAQYwDwYDVR0T +AQH/BAUwAwEB/zCBkQYDVR0jBIGJMIGGgBQ5lYtii1zJ1IC6WA+XPxUIQ8yYp6Fr +pGkwZzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQL +ExRBZGRUcnVzdCBUVFAgTmV0d29yazEjMCEGA1UEAxMaQWRkVHJ1c3QgUXVhbGlm +aWVkIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBABmrder4i2VhlRO6aQTv +hsoToMeqT2QbPxj2qC0sVY8FtzDqQmodwCVRLae/DLPt7wh/bDxGGuoYQ992zPlm +hpwsaPXpF/gxsxjE1kh9I0xowX67ARRvxdlu3rsEQmr49lx95dr6h+sNNVJn0J6X +dgWTP5XHAeZpVTh/EGGZyeNfpso+gmNIquIISD6q8rKFYqa0p9m9N5xotS1WfbC3 +P6CxB9bpT9zeRXEwMn8bLgn5v1Kh7sKAPgZcLlVAwRv1cEWw3F369nJad9Jjzc9Y +iQBCYz95OdBEsIJuQRno3eDBiFrRHnGTHyQwdOUeqN48Jzd/g66ed8/wMLH/S5no +xqE= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDpDCCAoygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEc +MBoGA1UEChMTQW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBP +bmxpbmUgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyODA2 +MDAwMFoXDTM3MTExOTIwNDMwMFowYzELMAkGA1UEBhMCVVMxHDAaBgNVBAoTE0Ft +ZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2EgT25saW5lIFJvb3Qg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAKgv6KRpBgNHw+kqmP8ZonCaxlCyfqXfaE0bfA+2l2h9LaaLl+lk +hsmj76CGv2BlnEtUiMJIxUo5vxTjWVXlGbR0yLQFOVwWpeKVBeASrlmLojNoWBym +1BW32J/X3HGrfpq/m44zDyL9Hy7nBzbvYjnF3cu6JRQj3gzGPTzOggjmZj7aUTsW +OqMFf6Dch9Wc/HKpoH145LcxVR5lu9RhsCFg7RAycsWSJR74kEoYeEfffjA3PlAb +2xzTa5qGUwew76wGePiEmf4hjUyAtgyC9mZweRrTT6PP8c9GsEsPPt2IYriMqQko +O3rHl+Ee5fSfwMCuJKDIodkP1nsmgmkyPacCAwEAAaNjMGEwDwYDVR0TAQH/BAUw +AwEB/zAdBgNVHQ4EFgQUAK3Zo/Z59m50qX8zPYEX10zPM94wHwYDVR0jBBgwFoAU +AK3Zo/Z59m50qX8zPYEX10zPM94wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB +BQUAA4IBAQB8itEfGDeC4Liwo+1WlchiYZwFos3CYiZhzRAW18y0ZTTQEYqtqKkF +Zu90821fnZmv9ov761KyBZiibyrFVL0lvV+uyIbqRizBs73B6UlwGBaXCBOMIOAb +LjpHyx7kADCVW/RFo8AasAFOq73AI25jP4BKxQft3OJvx8Fi8eNy1gTIdGcL+oir +oQHIb/AUr9KZzVGTfu0uOMe9zkZQPXLjeSWdm4grECDdpbgyn43gKd8hdIaC2y+C +MMbHNYaz+ZZfRtsMRf3zUMNvxsNIrUam4SdHCh0Om7bCd39j8uB9Gr784N/Xx6ds +sPmuujz9dLQR6FgNgLzTqIA6me11zEZ7 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFpDCCA4ygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEc +MBoGA1UEChMTQW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBP +bmxpbmUgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyODA2 +MDAwMFoXDTM3MDkyOTE0MDgwMFowYzELMAkGA1UEBhMCVVMxHDAaBgNVBAoTE0Ft +ZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2EgT25saW5lIFJvb3Qg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAMxBRR3pPU0Q9oyxQcngXssNt79Hc9PwVU3dxgz6sWYFas14tNwC +206B89enfHG8dWOgXeMHDEjsJcQDIPT/DjsS/5uN4cbVG7RtIuOx238hZK+GvFci +KtZHgVdEglZTvYYUAQv8f3SkWq7xuhG1m1hagLQ3eAkzfDJHA1zEpYNI9FdWboE2 +JxhP7JsowtS013wMPgwr38oE18aO6lhOqKSlGBxsRZijQdEt0sdtjRnxrXm3gT+9 +BoInLRBYBbV4Bbkv2wxrkJB+FFk4u5QkE+XRnRTf04JNRvCAOVIyD+OEsnpD8l7e +Xz8d3eOyG6ChKiMDbi4BFYdcpnV1x5dhvt6G3NRI270qv0pV2uh9UPu0gBe4lL8B +PeraunzgWGcXuVjgiIZGZ2ydEEdYMtA1fHkqkKJaEBEjNa0vzORKW6fIJ/KD3l67 +Xnfn6KVuY8INXWHQjNJsWiEOyiijzirplcdIz5ZvHZIlyMbGwcEMBawmxNJ10uEq +Z8A9W6Wa6897GqidFEXlD6CaZd4vKL3Ob5Rmg0gp2OpljK+T2WSfVVcmv2/LNzGZ +o2C7HK2JNDJiuEMhBnIMoVxtRsX6Kc8w3onccVvdtjc+31D1uAclJuW8tf48ArO3 ++L5DwYcRlJ4jbBeKuIonDFRH8KmzwICMoCfrHRnjB453cMor9H124HhnAgMBAAGj +YzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFE1FwWg4u3OpaaEg5+31IqEj +FNeeMB8GA1UdIwQYMBaAFE1FwWg4u3OpaaEg5+31IqEjFNeeMA4GA1UdDwEB/wQE +AwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAZ2sGuV9FOypLM7PmG2tZTiLMubekJcmn +xPBUlgtk87FYT15R/LKXeydlwuXK5w0MJXti4/qftIe3RUavg6WXSIylvfEWK5t2 +LHo1YGwRgJfMqZJS5ivmae2p+DYtLHe/YUjRYwu5W1LtGLBDQiKmsXeu3mnFzccc +obGlHBD7GL4acN3Bkku+KVqdPzW+5X1R+FXgJXUjhx5c3LqdsKyzadsXg8n33gy8 +CNyRnqjQ1xU3c6U1uPx+xURABsPr+CKAXEfOAuMRn0T//ZoyzH1kUQ7rVyZ2OuMe +IjzCpjbdGe+n/BLzJsBZMYVMnNjP36TMzCmT/5RtdlwTCJfy7aULTd3oyWgOZtMA +DjMSW7yV5TKQqLPGbIOtd+6Lfn6xqavT4fG2wLHqiMDn05DpKJKUe2h7lyoKZy2F +AjgQ5ANh1NolNscIWC2hp1GvMApJ9aZphwctREZ2jirlmjvXGKL8nDgQzMY70rUX +Om/9riW99XJZZLF0KjhfGEzfz3EEWjbUvy+ZnOjZurGV5gJLIaFb1cFPj65pbVPb +AZO1XB4Y3WRayhgoPmMEEf0cjQAPuDffZ4qdZqkCapH/E8ovXYO8h5Ns3CRRFgQl +Zvqz2cK6Kb6aSDiCmfS/O0oxGfm/jiEzFMpPVF/7zvuPcX/9XhmgD0uRuMRUvAaw +RY8mkaKO/qk= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID5jCCAs6gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMCVVMx +HTAbBgNVBAoTFEFPTCBUaW1lIFdhcm5lciBJbmMuMRwwGgYDVQQLExNBbWVyaWNh +IE9ubGluZSBJbmMuMTcwNQYDVQQDEy5BT0wgVGltZSBXYXJuZXIgUm9vdCBDZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyOTA2MDAwMFoXDTM3MTEyMDE1 +MDMwMFowgYMxCzAJBgNVBAYTAlVTMR0wGwYDVQQKExRBT0wgVGltZSBXYXJuZXIg +SW5jLjEcMBoGA1UECxMTQW1lcmljYSBPbmxpbmUgSW5jLjE3MDUGA1UEAxMuQU9M +IFRpbWUgV2FybmVyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnej8Mlo2k06AX3dLm/WpcZuS+U +0pPlLYnKhHw/EEMbjIt8hFj4JHxIzyr9wBXZGH6EGhfT257XyuTZ16pYUYfw8ItI +TuLCxFlpMGK2MKKMCxGZYTVtfu/FsRkGIBKOQuHfD5YQUqjPnF+VFNivO3ULMSAf +RC+iYkGzuxgh28pxPIzstrkNn+9R7017EvILDOGsQI93f7DKeHEMXRZxcKLXwjqF +zQ6axOAAsNUl6twr5JQtOJyJQVdkKGUZHLZEtMgxa44Be3ZZJX8VHIQIfHNlIAqh +BC4aMqiaILGcLCFZ5/vP7nAtCMpjPiybkxlqpMKX/7eGV4iFbJ4VFitNLLMCAwEA +AaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUoTYwFsuGkABFgFOxj8jY +PXy+XxIwHwYDVR0jBBgwFoAUoTYwFsuGkABFgFOxj8jYPXy+XxIwDgYDVR0PAQH/ +BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IBAQCKIBilvrMvtKaEAEAwKfq0FHNMeUWn +9nDg6H5kHgqVfGphwu9OH77/yZkfB2FK4V1Mza3u0FIy2VkyvNp5ctZ7CegCgTXT +Ct8RHcl5oIBN/lrXVtbtDyqvpxh1MwzqwWEFT2qaifKNuZ8u77BfWgDrvq2g+EQF +Z7zLBO+eZMXpyD8Fv8YvBxzDNnGGyjhmSs3WuEvGbKeXO/oTLW4jYYehY0KswsuX +n2Fozy1MBJ3XJU8KDk2QixhWqJNIV9xvrr2eZ1d3iVCzvhGbRWeDhhmH05i9CBoW +H1iCC+GWaQVLjuyDUTEH1dSf/1l7qG6Fz9NLqUmwX7A5KGgOc90lmt4S +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIF5jCCA86gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMCVVMx +HTAbBgNVBAoTFEFPTCBUaW1lIFdhcm5lciBJbmMuMRwwGgYDVQQLExNBbWVyaWNh +IE9ubGluZSBJbmMuMTcwNQYDVQQDEy5BT0wgVGltZSBXYXJuZXIgUm9vdCBDZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyOTA2MDAwMFoXDTM3MDkyODIz +NDMwMFowgYMxCzAJBgNVBAYTAlVTMR0wGwYDVQQKExRBT0wgVGltZSBXYXJuZXIg +SW5jLjEcMBoGA1UECxMTQW1lcmljYSBPbmxpbmUgSW5jLjE3MDUGA1UEAxMuQU9M +IFRpbWUgV2FybmVyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALQ3WggWmRToVbEbJGv8x4vmh6mJ +7ouZzU9AhqS2TcnZsdw8TQ2FTBVsRotSeJ/4I/1n9SQ6aF3Q92RhQVSji6UI0ilb +m2BPJoPRYxJWSXakFsKlnUWsi4SVqBax7J/qJBrvuVdcmiQhLE0OcR+mrF1FdAOY +xFSMFkpBd4aVdQxHAWZg/BXxD+r1FHjHDtdugRxev17nOirYlxcwfACtCJ0zr7iZ +YYCLqJV+FNwSbKTQ2O9ASQI2+W6p1h2WVgSysy0WVoaP2SBXgM1nEG2wTPDaRrbq +JS5Gr42whTg0ixQmgiusrpkLjhTXUr2eacOGAgvqdnUxCc4zGSGFQ+aJLZ8lN2fx +I2rSAG2X+Z/nKcrdH9cG6rjJuQkhn8g/BsXS6RJGAE57COtCPStIbp1n3UsC5ETz +kxmlJ85per5n0/xQpCyrw2u544BMzwVhSyvcG7mm0tCq9Stz+86QNZ8MUhy/XCFh +EVsVS6kkUfykXPcXnbDS+gfpj1bkGoxoigTTfFrjnqKhynFbotSg5ymFXQNoKk/S +Btc9+cMDLz9l+WceR0DTYw/j1Y75hauXTLPXJuuWCpTehTacyH+BCQJJKg71ZDIM +gtG6aoIbs0t0EfOMd9afv9w3pKdVBC/UMejTRrkDfNoSTllkt1ExMVCgyhwn2RAu +rda9EGYrw7AiShJbAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FE9pbQN+nZ8HGEO8txBO1b+pxCAoMB8GA1UdIwQYMBaAFE9pbQN+nZ8HGEO8txBO +1b+pxCAoMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAO/Ouyugu +h4X7ZVnnrREUpVe8WJ8kEle7+z802u6teio0cnAxa8cZmIDJgt43d15Ui47y6mdP +yXSEkVYJ1eV6moG2gcKtNuTxVBFT8zRFASbI5Rq8NEQh3q0l/HYWdyGQgJhXnU7q +7C+qPBR7V8F+GBRn7iTGvboVsNIYvbdVgaxTwOjdaRITQrcCtQVBynlQboIOcXKT +RuidDV29rs4prWPVVRaAMCf/drr3uNZK49m1+VLQTkCpx+XCMseqdiThawVQ68W/ +ClTluUI8JPu3B5wwn3la5uBAUhX0/Kr0VvlEl4ftDmVyXr4m+02kLQgH3thcoNyB +M5kYJRF3p+v9WAksmWsbivNSPxpNSGDxoPYzAlOL7SUJuA0t7Zdz7NeWH45gDtoQ +my8YJPamTQr5O8t1wswvziRpyQoijlmn94IM19drNZxDAGrElWe6nEXLuA4399xO +AU++CrYD062KRffaJ00psUjf5BHklka9bAI+1lHIlRcBFanyqqryvy9lG2/QuRqT +9Y41xICHPpQvZuTpqP9BnHAqTyo5GJUefvthATxRCC4oGKQWDzH9OmwjkyB24f0H +hdFbP9IcczLd+rn4jM8Ch3qaluTtT4mNU0OrDhPAARW0eTjb/G49nlG2uBOLZ8/5 +fNkiHfZdxRwBL5joeiQYvITX+txyW/fBOmg= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ +RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD +VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX +DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y +ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy +VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr +mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr +IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK +mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu +XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy +dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye +jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1 +BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3 +DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92 +9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx +jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0 +Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz +ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS +R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFajCCBFKgAwIBAgIEPLU9RjANBgkqhkiG9w0BAQUFADBmMRIwEAYDVQQKEwli +ZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENBczEzMDEGA1UEAxMq +YmVUUlVTVGVkIFJvb3QgQ0EtQmFsdGltb3JlIEltcGxlbWVudGF0aW9uMB4XDTAy +MDQxMTA3Mzg1MVoXDTIyMDQxMTA3Mzg1MVowZjESMBAGA1UEChMJYmVUUlVTVGVk +MRswGQYDVQQLExJiZVRSVVNUZWQgUm9vdCBDQXMxMzAxBgNVBAMTKmJlVFJVU1Rl +ZCBSb290IENBLUJhbHRpbW9yZSBJbXBsZW1lbnRhdGlvbjCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBALx+xDmcjOPWHIb/ymKt4H8wRXqOGrO4x/nRNv8i +805qX4QQ+2aBw5R5MdKR4XeOGCrDFN5R9U+jK7wYFuK13XneIviCfsuBH/0nLI/6 +l2Qijvj/YaOcGx6Sj8CoCd8JEey3fTGaGuqDIQY8n7pc/5TqarjDa1U0Tz0yH92B +FODEPM2dMPgwqZfT7syj0B9fHBOB1BirlNFjw55/NZKeX0Tq7PQiXLfoPX2k+Ymp +kbIq2eszh+6l/ePazIjmiSZuxyuC0F6dWdsU7JGDBcNeDsYq0ATdcT0gTlgn/FP7 +eHgZFLL8kFKJOGJgB7Sg7KxrUNb9uShr71ItOrL/8QFArDcCAwEAAaOCAh4wggIa +MA8GA1UdEwEB/wQFMAMBAf8wggG1BgNVHSAEggGsMIIBqDCCAaQGDysGAQQBsT4A +AAEJKIORMTCCAY8wggFIBggrBgEFBQcCAjCCAToaggE2UmVsaWFuY2Ugb24gb3Ig +dXNlIG9mIHRoaXMgQ2VydGlmaWNhdGUgY3JlYXRlcyBhbiBhY2tub3dsZWRnbWVu +dCBhbmQgYWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJk +IHRlcm1zIGFuZCBjb25kaXRpb25zIG9mIHVzZSwgdGhlIENlcnRpZmljYXRpb24g +UHJhY3RpY2UgU3RhdGVtZW50IGFuZCB0aGUgUmVseWluZyBQYXJ0eSBBZ3JlZW1l +bnQsIHdoaWNoIGNhbiBiZSBmb3VuZCBhdCB0aGUgYmVUUlVTVGVkIHdlYiBzaXRl +LCBodHRwOi8vd3d3LmJldHJ1c3RlZC5jb20vcHJvZHVjdHNfc2VydmljZXMvaW5k +ZXguaHRtbDBBBggrBgEFBQcCARY1aHR0cDovL3d3dy5iZXRydXN0ZWQuY29tL3By +b2R1Y3RzX3NlcnZpY2VzL2luZGV4Lmh0bWwwHQYDVR0OBBYEFEU9w6nR3D8kVpgc +cxiIav+DR+22MB8GA1UdIwQYMBaAFEU9w6nR3D8kVpgccxiIav+DR+22MA4GA1Ud +DwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEASZK8o+6svfoNyYt5hhwjdrCA +WXf82n+0S9/DZEtqTg6t8n1ZdwWtColzsPq8y9yNAIiPpqCy6qxSJ7+hSHyXEHu6 +7RMdmgduyzFiEuhjA6p9beP4G3YheBufS0OM00mG9htc9i5gFdPp43t1P9ACg9AY +gkHNZTfqjjJ+vWuZXTARyNtIVBw74acT02pIk/c9jH8F6M7ziCpjBLjqflh8AXtb +4cV97yHgjQ5dUX2xZ/2jvTg2xvI4hocalmhgRvsoFEdV4aeADGvi6t9NfJBIoDa9 +CReJf8Py05yc493EG931t3GzUwWJBtDLSoDByFOQtTwxiBdQn8nEDovYqAJjDQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFLDCCBBSgAwIBAgIEOU99hzANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJX +VzESMBAGA1UEChMJYmVUUlVTVGVkMRswGQYDVQQDExJiZVRSVVNUZWQgUm9vdCBD +QXMxGjAYBgNVBAMTEWJlVFJVU1RlZCBSb290IENBMB4XDTAwMDYyMDE0MjEwNFoX +DTEwMDYyMDEzMjEwNFowWjELMAkGA1UEBhMCV1cxEjAQBgNVBAoTCWJlVFJVU1Rl +ZDEbMBkGA1UEAxMSYmVUUlVTVGVkIFJvb3QgQ0FzMRowGAYDVQQDExFiZVRSVVNU +ZWQgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANS0c3oT +CjhVAb6JVuGUntS+WutKNHUbYSnE4a0IYCF4SP+00PpeQY1hRIfo7clY+vyTmt9P +6j41ffgzeubx181vSUs9Ty1uDoM6GHh3o8/n9E1z2Jo7Gh2+lVPPIJfCzz4kUmwM +jmVZxXH/YgmPqsWPzGCgc0rXOD8Vcr+il7dw6K/ifhYGTPWqZCZyByWtNfwYsSbX +2P8ZDoMbjNx4RWc0PfSvHI3kbWvtILNnmrRhyxdviTX/507AMhLn7uzf/5cwdO2N +R47rtMNE5qdMf1ZD6Li8tr76g5fmu/vEtpO+GRg+jIG5c4gW9JZDnGdzF5DYCW5j +rEq2I8QBoa2k5MUCAwEAAaOCAfgwggH0MA8GA1UdEwEB/wQFMAMBAf8wggFZBgNV +HSAEggFQMIIBTDCCAUgGCisGAQQBsT4BAAAwggE4MIIBAQYIKwYBBQUHAgIwgfQa +gfFSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBhc3N1 +bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0 +ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGFuZCBjZXJ0aWZpY2F0aW9uIHBy +YWN0aWNlIHN0YXRlbWVudCwgd2hpY2ggY2FuIGJlIGZvdW5kIGF0IGJlVFJVU1Rl +ZCdzIHdlYiBzaXRlLCBodHRwczovL3d3dy5iZVRSVVNUZWQuY29tL3ZhdWx0L3Rl +cm1zMDEGCCsGAQUFBwIBFiVodHRwczovL3d3dy5iZVRSVVNUZWQuY29tL3ZhdWx0 +L3Rlcm1zMDQGA1UdHwQtMCswKaAnoCWkIzAhMRIwEAYDVQQKEwliZVRSVVNUZWQx +CzAJBgNVBAYTAldXMB0GA1UdDgQWBBQquZtpLjub2M3eKjEENGvKBxirZzAfBgNV +HSMEGDAWgBQquZtpLjub2M3eKjEENGvKBxirZzAOBgNVHQ8BAf8EBAMCAf4wDQYJ +KoZIhvcNAQEFBQADggEBAHlh26Nebhax6nZR+csVm8tpvuaBa58oH2U+3RGFktTo +Qb9+M70j5/Egv6S0phkBxoyNNXxlpE8JpNbYIxUFE6dDea/bow6be3ga8wSGWsb2 +jCBHOElQBp1yZzrwmAOtlmdE/D8QDYZN5AA7KXvOOzuZhmElQITcE2K3+spZ1gMe +1lMBzW1MaFVA4e5rxyoAAEiCswoBw2AqDPeCNe5IhpbkdNQ96gFxugR1QKepfzk5 +mlWXKWWuGVUlBXJH0+gY3Ljpr0NzARJ0o+FcXxVdJPP55PS2Z2cS52QiivalQaYc +tmBjRYoQtLpGEK5BV2VsPyMQPyEQWbfkQN0mDCP2qq4= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIGUTCCBTmgAwIBAgIEPLVPQDANBgkqhkiG9w0BAQUFADBmMRIwEAYDVQQKEwli +ZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENBczEzMDEGA1UEAxMq +YmVUUlVTVGVkIFJvb3QgQ0EgLSBFbnRydXN0IEltcGxlbWVudGF0aW9uMB4XDTAy +MDQxMTA4MjQyN1oXDTIyMDQxMTA4NTQyN1owZjESMBAGA1UEChMJYmVUUlVTVGVk +MRswGQYDVQQLExJiZVRSVVNUZWQgUm9vdCBDQXMxMzAxBgNVBAMTKmJlVFJVU1Rl +ZCBSb290IENBIC0gRW50cnVzdCBJbXBsZW1lbnRhdGlvbjCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBALr0RAOqEmq1Q+xVkrYwfTVXDNvzDSduTPdQqJtO +K2/b9a0cS12zqcH+e0TrW6MFDR/FNCswACnxeECypP869AGIF37m1CbTukzqMvtD +d5eHI8XbQ6P1KqNRXuE70mVpflUVm3rnafdE4Fe1FehmYA8NA/uCjqPoEXtsvsdj +DheT389Lrm5zdeDzqrmkwAkbhepxKYhBMvnwKg5sCfJ0a2ZsUhMfGLzUPvfYbiCe +yv78IZTuEyhL11xeDGbu6bsPwTSxfwh28z0mcMmLJR1iJAzqHHVOwBLkuhMdMCkt +VjMFu5dZfsZJT4nXLySotohAtWSSU1Yk5KKghbNekLQSM80CAwEAAaOCAwUwggMB +MIIBtwYDVR0gBIIBrjCCAaowggGmBg8rBgEEAbE+AAACCSiDkTEwggGRMIIBSQYI +KwYBBQUHAgIwggE7GoIBN1JlbGlhbmNlIG9uIG9yIHVzZSBvZiB0aGlzIENlcnRp +ZmljYXRlIGNyZWF0ZXMgYW4gYWNrbm93bGVkZ21lbnQgYW5kIGFjY2VwdGFuY2Ug +b2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0 +aW9ucyBvZiB1c2UsIHRoZSBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVu +dCBhbmQgdGhlIFJlbHlpbmcgUGFydHkgQWdyZWVtZW50LCB3aGljaCBjYW4gYmUg +Zm91bmQgYXQgdGhlIGJlVFJVU1RlZCB3ZWIgc2l0ZSwgaHR0cHM6Ly93d3cuYmV0 +cnVzdGVkLmNvbS9wcm9kdWN0c19zZXJ2aWNlcy9pbmRleC5odG1sMEIGCCsGAQUF +BwIBFjZodHRwczovL3d3dy5iZXRydXN0ZWQuY29tL3Byb2R1Y3RzX3NlcnZpY2Vz +L2luZGV4Lmh0bWwwEQYJYIZIAYb4QgEBBAQDAgAHMIGJBgNVHR8EgYEwfzB9oHug +eaR3MHUxEjAQBgNVBAoTCWJlVFJVU1RlZDEbMBkGA1UECxMSYmVUUlVTVGVkIFJv +b3QgQ0FzMTMwMQYDVQQDEypiZVRSVVNUZWQgUm9vdCBDQSAtIEVudHJ1c3QgSW1w +bGVtZW50YXRpb24xDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMjAwMjA0MTEw +ODI0MjdagQ8yMDIyMDQxMTA4NTQyN1owCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaA +FH1w5a44iwY/qhwaj/nPJDCqhIQWMB0GA1UdDgQWBBR9cOWuOIsGP6ocGo/5zyQw +qoSEFjAMBgNVHRMEBTADAQH/MB0GCSqGSIb2fQdBAAQQMA4bCFY2LjA6NC4wAwIE +kDANBgkqhkiG9w0BAQUFAAOCAQEAKrgXzh8QlOu4mre5X+za95IkrNySO8cgjfKZ +5V04ocI07cUTWVwFtStPYZuR+0H8/NU8TZh2BvWBfevdkObRVlTa4y0MnxEylCIB +evZsLHRnBMylj44ss0O1lKLQfelifwa+JwGDnjr9iu6YQ0pr17WXOzq/T220Y/oz +ADQuLW2WyXvKmWO6vvT2MKAtmJbpVkQFqUSjYRDrgqFnXbxdJ3Wqiig2KjiS2d2k +XgClzMx8KSreKJCrt+G2/30lC0DYqjSjLd4H61/OCt3Kfjp9JsFiaDrmLzfzgYYh +xKlkqu9FNtEaZnz46TfW1mG+oq1I59/mdP7TbX3SJdysYlep9w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFaDCCBFCgAwIBAgIQO1nHe81bV569N1KsdrSqGjANBgkqhkiG9w0BAQUFADBi +MRIwEAYDVQQKEwliZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENB +czEvMC0GA1UEAxMmYmVUUlVTVGVkIFJvb3QgQ0EgLSBSU0EgSW1wbGVtZW50YXRp +b24wHhcNMDIwNDExMTExODEzWhcNMjIwNDEyMTEwNzI1WjBiMRIwEAYDVQQKEwli +ZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENBczEvMC0GA1UEAxMm +YmVUUlVTVGVkIFJvb3QgQ0EgLSBSU0EgSW1wbGVtZW50YXRpb24wggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkujQwCY5X0LkGLG9uJIAiv11DpvpPrILn +HGhwhRujbrWqeNluB0s/6d/16uhUoWGKDi9pdRi3DOUUjXFumLhV/AyV0Jtu4S2I +1DpAa5LxmZZk3tv/ePTulh1HiXzUvrmIdyM6CeYEnm2qXtLIvZpOGd+J6lsOfsPk +tPDgaTuID0GQ+NRxQyTBjyZLO1bp/4xsN+lFrYWMU8NghpBKlsmzVLC7F/AcRdnU +GxlkVgoZ98zh/4avflherHqQH8koOUV7orbHnB/ahdQhhlkwk75TMzf270HPM8er +cmsl9fNTGwxMLvF1S++gh/f+ihXQbNXL+WhTuXAVE8L1LvtDNXUtAgMBAAGjggIY +MIICFDAMBgNVHRMEBTADAQH/MIIBtQYDVR0gBIIBrDCCAagwggGkBg8rBgEEAbE+ +AAADCSiDkTEwggGPMEEGCCsGAQUFBwIBFjVodHRwOi8vd3d3LmJldHJ1c3RlZC5j +b20vcHJvZHVjdHNfc2VydmljZXMvaW5kZXguaHRtbDCCAUgGCCsGAQUFBwICMIIB +OhqCATZSZWxpYW5jZSBvbiBvciB1c2Ugb2YgdGhpcyBDZXJ0aWZpY2F0ZSBjcmVh +dGVzIGFuIGFja25vd2xlZGdtZW50IGFuZCBhY2NlcHRhbmNlIG9mIHRoZSB0aGVu +IGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNl +LCB0aGUgQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1lbnQgYW5kIHRoZSBS +ZWx5aW5nIFBhcnR5IEFncmVlbWVudCwgd2hpY2ggY2FuIGJlIGZvdW5kIGF0IHRo +ZSBiZVRSVVNUZWQgd2ViIHNpdGUsIGh0dHA6Ly93d3cuYmV0cnVzdGVkLmNvbS9w +cm9kdWN0c19zZXJ2aWNlcy9pbmRleC5odG1sMAsGA1UdDwQEAwIBBjAfBgNVHSME +GDAWgBSp7BR++dlDzFMrFK3P9/BZiUHNGTAdBgNVHQ4EFgQUqewUfvnZQ8xTKxSt +z/fwWYlBzRkwDQYJKoZIhvcNAQEFBQADggEBANuXsHXqDMTBmMpWBcCorSZIry0g +6IHHtt9DwSwddUvUQo3neqh03GZCWYez9Wlt2ames30cMcH1VOJZJEnl7r05pmuK +mET7m9cqg5c0Lcd9NUwtNLg+DcTsiCevnpL9UGGCqGAHFFPMZRPB9kdEadIxyKbd +LrML3kqNWz2rDcI1UqJWN8wyiyiFQpyRQHpwKzg21eFzGh/l+n5f3NacOzDq28Bb +J1zTcwfBwvNMm2+fG8oeqqg4MwlYsq78B+g23FW6L09A/nq9BqaBwZMifIYRCgZ3 +SK41ty8ymmFei74pnykkiFY5LKjSq5YDWtRIn7lAhAuYaPsBQ9Yb4gmxlxw= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDDDCCAfSgAwIBAgIDAQAgMA0GCSqGSIb3DQEBBQUAMD4xCzAJBgNVBAYTAlBM +MRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBD +QTAeFw0wMjA2MTExMDQ2MzlaFw0yNzA2MTExMDQ2MzlaMD4xCzAJBgNVBAYTAlBM +MRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBD +QTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM6xwS7TT3zNJc4YPk/E +jG+AanPIW1H4m9LcuwBcsaD8dQPugfCI7iNS6eYVM42sLQnFdvkrOYCJ5JdLkKWo +ePhzQ3ukYbDYWMzhbGZ+nPMJXlVjhNWo7/OxLjBos8Q82KxujZlakE403Daaj4GI +ULdtlkIJ89eVgw1BS7Bqa/j8D35in2fE7SZfECYPCE/wpFcozo+47UX2bu4lXapu +Ob7kky/ZR6By6/qmW6/KUz/iDsaWVhFu9+lmqSbYf5VT7QqFiLpPKaVCjF62/IUg +AKpoC6EahQGcxEZjgoi2IrHu/qpGWX7PNSzVttpd90gzFFS269lvzs2I1qsb2pY7 +HVkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEA +uI3O7+cUus/usESSbLQ5PqKEbq24IXfS1HeCh+YgQYHu4vgRt2PRFze+GXYkHAQa +TOs9qmdvLdTN/mUxcMUbpgIKumB7bVjCmkn+YzILa+M6wKyrO7Do0wlRjBCDxjTg +xSvgGrZgFCdsMneMvLJymM/NzD+5yCRCFNZX/OYmQ6kd5YCQzgNUKD73P9P4Te1q +CjqTE5s7FCMTY5w/0YcneeVMUeMBrYVdGjux1XMQpNPyvG5k9VpWkKjHDkx0Dy5x +O/fIR/RpbxXyEV6DHpx8Uq79AtoSqFlnGNu8cN2bsWntgM6JQEhqDjXKKWYVIZQs +6GAqm4VKQPNriiTsBhYscw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb +MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow +GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj +YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL +MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE +BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM +GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua +BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe +3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4 +YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR +rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm +ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU +oBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF +MAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20v +QUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29t +b2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUF +AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q +GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz +Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2 +G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi +l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3 +smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEPzCCAyegAwIBAgIBATANBgkqhkiG9w0BAQUFADB+MQswCQYDVQQGEwJHQjEb +MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow +GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEkMCIGA1UEAwwbU2VjdXJlIENlcnRp +ZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVow +fjELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G +A1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxJDAiBgNV +BAMMG1NlY3VyZSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAMBxM4KK0HDrc4eCQNUd5MvJDkKQ+d40uaG6EfQlhfPM +cm3ye5drswfxdySRXyWP9nQ95IDC+DwN879A6vfIUtFyb+/Iq0G4bi4XKpVpDM3S +HpR7LZQdqnXXs5jLrLxkU0C8j6ysNstcrbvd4JQX7NFc0L/vpZXJkMWwrPsbQ996 +CF23uPJAGysnnlDOXmWCiIxe004MeuoIkbY2qitC++rCoznl2yY4rYsK7hljxxwk +3wN42ubqwUcaCwtGCd0C/N7Lh1/XMGNooa7cMqG6vv5Eq2i2pRcV/b3Vp6ea5EQz +6YiO/O1R65NxTq0B50SOqy3LqP4BSUjwwN3HaNiS/j0CAwEAAaOBxzCBxDAdBgNV +HQ4EFgQUPNiTiMLAggnMAZkGkyDpnnAJY08wDgYDVR0PAQH/BAQDAgEGMA8GA1Ud +EwEB/wQFMAMBAf8wgYEGA1UdHwR6MHgwO6A5oDeGNWh0dHA6Ly9jcmwuY29tb2Rv +Y2EuY29tL1NlY3VyZUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDmgN6A1hjNodHRw +Oi8vY3JsLmNvbW9kby5uZXQvU2VjdXJlQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmww +DQYJKoZIhvcNAQEFBQADggEBAIcBbSMdflsXfcFhMs+P5/OKlFlm4J4oqF7Tt/Q0 +5qo5spcWxYJvMqTpjOev/e/C6LlLqqP05tqNZSH7uoDrJiiFGv45jN5bBAS0VPmj +Z55B+glSzAVIqMk/IQQezkhr/IXownuvf7fM+F86/TXGDe+X3EyrEeFryzHRbPtI +gKvcnDe4IRRLDXE97IMzbtFuMhbsmMcWi1mmNKsFVy2T96oTy9IT4rcuO81rUBcJ +aD61JlfutuC23bkpgHl9j6PwpCikFcSF9CfUa7/lXORlAnZUtOM3ZiTTGWHIUhDl +izeauan5Hb/qmZJhlv8BzaFfDbxxvA6sCx1HRR3B7Hzs/Sk= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIBATANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJHQjEb +MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow +GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDElMCMGA1UEAwwcVHJ1c3RlZCBDZXJ0 +aWZpY2F0ZSBTZXJ2aWNlczAeFw0wNDAxMDEwMDAwMDBaFw0yODEyMzEyMzU5NTla +MH8xCzAJBgNVBAYTAkdCMRswGQYDVQQIDBJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoMEUNvbW9kbyBDQSBMaW1pdGVkMSUwIwYD +VQQDDBxUcnVzdGVkIENlcnRpZmljYXRlIFNlcnZpY2VzMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEA33FvNlhTWvI2VFeAxHQIIO0Yfyod5jWaHiWsnOWW +fnJSoBVC21ndZHoa0Lh73TkVvFVIxO06AOoxEbrycXQaZ7jPM8yoMa+j49d/vzMt +TGo87IvDktJTdyR0nAducPy9C1t2ul/y/9c3S0pgePfw+spwtOpZqqPOSC+pw7IL +fhdyFgymBwwbOM/JYrc/oJOlh0Hyt3BAd9i+FHzjqMB6juljatEPmsbS9Is6FARW +1O24zG71++IsWL1/T2sr92AkWCTOJu80kTrV44HQsvAEAtdbtz6SrGsSivnkBbA7 +kUlcsutT6vifR4buv5XAwAaf0lteERv0xwQ1KdJVXOTt6wIDAQABo4HJMIHGMB0G +A1UdDgQWBBTFe1i97doladL3WRaoszLAeydb9DAOBgNVHQ8BAf8EBAMCAQYwDwYD +VR0TAQH/BAUwAwEB/zCBgwYDVR0fBHwwejA8oDqgOIY2aHR0cDovL2NybC5jb21v +ZG9jYS5jb20vVHJ1c3RlZENlcnRpZmljYXRlU2VydmljZXMuY3JsMDqgOKA2hjRo +dHRwOi8vY3JsLmNvbW9kby5uZXQvVHJ1c3RlZENlcnRpZmljYXRlU2VydmljZXMu +Y3JsMA0GCSqGSIb3DQEBBQUAA4IBAQDIk4E7ibSvuIQSTI3S8NtwuleGFTQQuS9/ +HrCoiWChisJ3DFBKmwCL2Iv0QeLQg4pKHBQGsKNoBXAxMKdTmw7pSqBYaWcOrp32 +pSxBvzwGa+RZzG0Q8ZZvH9/0BAKkn0U+yNj6NkZEUD+Cl5EfKNsYEYwq5GWDVxIS +jBc/lDb+XbDABHcTuPQV1T84zJQ6VdCsmPW6AF/ghhmBeC8owH7TzEIK9a5QoNE+ +xqFx7D+gIIxmOom0jtTYsU0lR+4viMi14QVFwL4Ucd56/Y57fU0IlqUSc/Atyjcn +dBInTMu2l+nZrghtWjlA3QVHdWpaIbOjGM9O9y5Xt5hwXsjEeLBi +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDKTCCApKgAwIBAgIENnAVljANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJV +UzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMREwDwYDVQQL +EwhEU1RDQSBFMTAeFw05ODEyMTAxODEwMjNaFw0xODEyMTAxODQwMjNaMEYxCzAJ +BgNVBAYTAlVTMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4x +ETAPBgNVBAsTCERTVENBIEUxMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQCg +bIGpzzQeJN3+hijM3oMv+V7UQtLodGBmE5gGHKlREmlvMVW5SXIACH7TpWJENySZ +j9mDSI+ZbZUTu0M7LklOiDfBu1h//uG9+LthzfNHwJmm8fOR6Hh8AMthyUQncWlV +Sn5JTe2io74CTADKAqjuAQIxZA9SLRN0dja1erQtcQIBA6OCASQwggEgMBEGCWCG +SAGG+EIBAQQEAwIABzBoBgNVHR8EYTBfMF2gW6BZpFcwVTELMAkGA1UEBhMCVVMx +JDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UECxMI +RFNUQ0EgRTExDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMTk5ODEyMTAxODEw +MjNagQ8yMDE4MTIxMDE4MTAyM1owCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaAFGp5 +fpFpRhgTCgJ3pVlbYJglDqL4MB0GA1UdDgQWBBRqeX6RaUYYEwoCd6VZW2CYJQ6i ++DAMBgNVHRMEBTADAQH/MBkGCSqGSIb2fQdBAAQMMAobBFY0LjADAgSQMA0GCSqG +SIb3DQEBBQUAA4GBACIS2Hod3IEGtgllsofIH160L+nEHvI8wbsEkBFKg05+k7lN +QseSJqBcNJo4cvj9axY+IO6CizEqkzaFI4iKPANo08kJD038bKTaKHKTDomAsH3+ +gG9lbRgzl4vCa4nuYD3Im+9/KzJic5PLPON74nZ4RbyhkwS7hp86W0N6w4pl +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID2DCCAsACEQDQHkCLAAACfAAAAAIAAAABMA0GCSqGSIb3DQEBBQUAMIGpMQsw +CQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMOU2FsdCBMYWtlIENp +dHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UE +CxMIRFNUQ0EgWDExFjAUBgNVBAMTDURTVCBSb290Q0EgWDExITAfBgkqhkiG9w0B +CQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTAeFw05ODEyMDExODE4NTVaFw0wODExMjgx +ODE4NTVaMIGpMQswCQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMO +U2FsdCBMYWtlIENpdHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0 +IENvLjERMA8GA1UECxMIRFNUQ0EgWDExFjAUBgNVBAMTDURTVCBSb290Q0EgWDEx +ITAfBgkqhkiG9w0BCQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBANLGJrbnpT3BxGjVUG9TxW9JEwm4ryxIjRRqoxdf +WvnTLnUv2Chi0ZMv/E3Uq4flCMeZ55I/db3rJbQVwZsZPdJEjdd0IG03Ao9pk1uK +xBmd9LIO/BZsubEFkoPRhSxglD5FVaDZqwgh5mDoO3TymVBRaNADLbGAvqPYUrBE +zUNKcI5YhZXhTizWLUFv1oTnyJhEykfbLCSlaSbPa7gnYsP0yXqSI+0TZ4KuRS5F +5X5yP4WdlGIQ5jyRoa13AOAV7POEgHJ6jm5gl8ckWRA0g1vhpaRptlc1HHhZxtMv +OnNn7pTKBBMFYgZwI7P0fO5F2WQLW0mqpEPOJsREEmy43XkCAwEAATANBgkqhkiG +9w0BAQUFAAOCAQEAojeyP2n714Z5VEkxlTMr89EJFEliYIalsBHiUMIdBlc+Legz +ZL6bqq1fG03UmZWii5rJYnK1aerZWKs17RWiQ9a2vAd5ZWRzfdd5ynvVWlHG4VME +lo04z6MXrDlxawHDi1M8Y+nuecDkvpIyZHqzH5eUYr3qsiAVlfuX8ngvYzZAOONG +Dx3drJXK50uQe7FLqdTF65raqtWjlBRGjS0f8zrWkzr2Pnn86Oawde3uPclwx12q +gUtGJRzHbBXjlU4PqjI3lAoXJJIThFjSY28r9+ZbYgsTF7ANUkz+/m9c4pFuHf2k +Ytdo+o56T9II2pPc8JIRetDccpMMc5NihWjQ9A== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDKTCCApKgAwIBAgIENm7TzjANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJV +UzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMREwDwYDVQQL +EwhEU1RDQSBFMjAeFw05ODEyMDkxOTE3MjZaFw0xODEyMDkxOTQ3MjZaMEYxCzAJ +BgNVBAYTAlVTMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4x +ETAPBgNVBAsTCERTVENBIEUyMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQC/ +k48Xku8zExjrEH9OFr//Bo8qhbxe+SSmJIi2A7fBw18DW9Fvrn5C6mYjuGODVvso +LeE4i7TuqAHhzhy2iCoiRoX7n6dwqUcUP87eZfCocfdPJmyMvMa1795JJ/9IKn3o +TQPMx7JSxhcxEzu1TdvIxPbDDyQq2gyd55FbgM2UnQIBA6OCASQwggEgMBEGCWCG +SAGG+EIBAQQEAwIABzBoBgNVHR8EYTBfMF2gW6BZpFcwVTELMAkGA1UEBhMCVVMx +JDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UECxMI +RFNUQ0EgRTIxDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMTk5ODEyMDkxOTE3 +MjZagQ8yMDE4MTIwOTE5MTcyNlowCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaAFB6C +TShlgDzJQW6sNS5ay97u+DlbMB0GA1UdDgQWBBQegk0oZYA8yUFurDUuWsve7vg5 +WzAMBgNVHRMEBTADAQH/MBkGCSqGSIb2fQdBAAQMMAobBFY0LjADAgSQMA0GCSqG +SIb3DQEBBQUAA4GBAEeNg61i8tuwnkUiBbmi1gMOOHLnnvx75pO2mqWilMg0HZHR +xdf0CiUPPXiBng+xZ8SQTGPdXqfiup/1902lMXucKS1M/mQ+7LZT/uqb7YLbdHVL +B3luHtgZg3Pe9T7Qtd7nS2h9Qy4qIOF+oHhEngj1mPnHfxsb1gYgAlihw6ID +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID2DCCAsACEQDQHkCLAAB3bQAAAAEAAAAEMA0GCSqGSIb3DQEBBQUAMIGpMQsw +CQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMOU2FsdCBMYWtlIENp +dHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UE +CxMIRFNUQ0EgWDIxFjAUBgNVBAMTDURTVCBSb290Q0EgWDIxITAfBgkqhkiG9w0B +CQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTAeFw05ODExMzAyMjQ2MTZaFw0wODExMjcy +MjQ2MTZaMIGpMQswCQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMO +U2FsdCBMYWtlIENpdHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0 +IENvLjERMA8GA1UECxMIRFNUQ0EgWDIxFjAUBgNVBAMTDURTVCBSb290Q0EgWDIx +ITAfBgkqhkiG9w0BCQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBANx18IzAdZaawGIfJvfE4Zrq4FZzW5nNAUSoCLbV +p9oaBBg5kkp4o4HC9Xd6ULRw/5qrxsfKboNPQpj7Jgva3G3WqZlVUmfpKAOS3OWw +BZoPFflrWXJW8vo5/Kpo7g8fEIMv/J36F5bdguPmRX3AS4BEH+0s4IT9kVySVGkl +5WJp3OXuAFK9MwutdQKFp2RQLcUZGTDAJtvJ0/0uma1ZtQtN1EGuhUhDWdy3qOKi +3sOP17ihYqZoUFLkzzGnlIXan0YyF1bl8utmPRL/Q9uY73fPy4GNNLHGUEom0eQ+ +QVCvbK4iNC7Va26Dunm4dmVI2gkpZGMiuftHdoWMhkTLCdsCAwEAATANBgkqhkiG +9w0BAQUFAAOCAQEAtTYOXeFhKFoRZcA/gwN5Tb4opgsHAlKFzfiR0BBstWogWxyQ +2TA8xkieil5k+aFxd+8EJx8H6+Qm93N0yUQYGmbT4EOvkTvRyyzYdFQ6HE3K1GjN +I3wdEJ5F6fYAbqbNGf9PLCmPV03Ed5K+4EwJ+11EhmYhqLkyolbV6YyDfFk/xPEL +553snr2cGA4+wjl5KLcDDQjLxufZATdQEOzMYRZA1K8xdHv8PzGn0EdzMzkbzE5q +10mDEQb+64JYMzJM8FasHpwvVpp7wUocpf1VNs78lk30sPDst2yC7S8xmUJMqbIN +uBVd8d+6ybVK1GSYsyapMMj9puyrliGtf8J4tg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEgzCCA+ygAwIBAgIEOJ725DANBgkqhkiG9w0BAQQFADCBtDEUMBIGA1UEChML +RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9HQ0NBX0NQUyBp +bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAyMDAw +IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENsaWVu +dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMDAyMDcxNjE2NDBaFw0yMDAy +MDcxNjQ2NDBaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3 +LmVudHJ1c3QubmV0L0dDQ0FfQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp +YWIuKTElMCMGA1UECxMcKGMpIDIwMDAgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG +A1UEAxMqRW50cnVzdC5uZXQgQ2xpZW50IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTdLS25MVL1qFof2LV7PdRV7Ny +Spj10InJrWPNTTVRaoTUrcloeW+46xHbh65cJFET8VQlhK8pK5/jgOLZy93GRUk0 +iJBeAZfv6lOm3fzB3ksqJeTpNfpVBQbliXrqpBFXO/x8PTbNZzVtpKklWb1m9fkn +5JVn1j+SgF7yNH0rhQIDAQABo4IBnjCCAZowEQYJYIZIAYb4QgEBBAQDAgAHMIHd +BgNVHR8EgdUwgdIwgc+ggcyggcmkgcYwgcMxFDASBgNVBAoTC0VudHJ1c3QubmV0 +MUAwPgYDVQQLFDd3d3cuZW50cnVzdC5uZXQvR0NDQV9DUFMgaW5jb3JwLiBieSBy +ZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMjAwMCBFbnRydXN0Lm5l +dCBMaW1pdGVkMTMwMQYDVQQDEypFbnRydXN0Lm5ldCBDbGllbnQgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkxDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMjAwMDAy +MDcxNjE2NDBagQ8yMDIwMDIwNzE2NDY0MFowCwYDVR0PBAQDAgEGMB8GA1UdIwQY +MBaAFISLdP3FjcD/J20gN0V8/i3OutN9MB0GA1UdDgQWBBSEi3T9xY3A/ydtIDdF +fP4tzrrTfTAMBgNVHRMEBTADAQH/MB0GCSqGSIb2fQdBAAQQMA4bCFY1LjA6NC4w +AwIEkDANBgkqhkiG9w0BAQQFAAOBgQBObzWAO9GK9Q6nIMstZVXQkvTnhLUGJoMS +hAusO7JE7r3PQNsgDrpuFOow4DtifH+La3xKp9U1PL6oXOpLu5OOgGarDyn9TS2/ +GpsKkMWr2tGzhtQvJFJcem3G8v7lTRowjJDyutdKPkN+1MhQGof4T4HHdguEOnKd +zmVml64mXg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIElTCCA/6gAwIBAgIEOJsRPDANBgkqhkiG9w0BAQQFADCBujEUMBIGA1UEChML +RW50cnVzdC5uZXQxPzA9BgNVBAsUNnd3dy5lbnRydXN0Lm5ldC9TU0xfQ1BTIGlu +Y29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMcKGMpIDIwMDAg +RW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5uZXQgU2VjdXJl +IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMDAyMDQxNzIwMDBa +Fw0yMDAyMDQxNzUwMDBaMIG6MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDE/MD0GA1UE +CxQ2d3d3LmVudHJ1c3QubmV0L1NTTF9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p +dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMjAwMCBFbnRydXN0Lm5ldCBMaW1pdGVk +MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp +b24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHwV9OcfHO +8GCGD9JYf9Mzly0XonUwtZZkJi9ow0SrqHXmAGc0V55lxyKbc+bT3QgON1WqJUaB +bL3+qPZ1V1eMkGxKwz6LS0MKyRFWmponIpnPVZ5h2QLifLZ8OAfc439PmrkDQYC2 +dWcTC5/oVzbIXQA23mYU2m52H083jIITiQIDAQABo4IBpDCCAaAwEQYJYIZIAYb4 +QgEBBAQDAgAHMIHjBgNVHR8EgdswgdgwgdWggdKggc+kgcwwgckxFDASBgNVBAoT +C0VudHJ1c3QubmV0MT8wPQYDVQQLFDZ3d3cuZW50cnVzdC5uZXQvU1NMX0NQUyBp +bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAyMDAw +IEVudHJ1c3QubmV0IExpbWl0ZWQxOjA4BgNVBAMTMUVudHJ1c3QubmV0IFNlY3Vy +ZSBTZXJ2ZXIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxDTALBgNVBAMTBENSTDEw +KwYDVR0QBCQwIoAPMjAwMDAyMDQxNzIwMDBagQ8yMDIwMDIwNDE3NTAwMFowCwYD +VR0PBAQDAgEGMB8GA1UdIwQYMBaAFMtswGvjuz7L/CKc/vuLkpyw8m4iMB0GA1Ud +DgQWBBTLbMBr47s+y/winP77i5KcsPJuIjAMBgNVHRMEBTADAQH/MB0GCSqGSIb2 +fQdBAAQQMA4bCFY1LjA6NC4wAwIEkDANBgkqhkiG9w0BAQQFAAOBgQBi24GRzsia +d0Iv7L0no1MPUBvqTpLwqa+poLpIYcvvyQbvH9X07t9WLebKahlzqlO+krNQAraF +JnJj2HVQYnUUt7NQGj/KEQALhUVpbbalrlHhStyCP2yMNLJ3a9kC9n8O6mUE8c1U +yrrJzOCE98g+EZfTYAkYvAX/bIkz8OwVDw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEXDCCA0SgAwIBAgIEOGO5ZjANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML +RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp +bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5 +IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0xOTEy +MjQxODIwNTFaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3 +LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp +YWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG +A1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU1LqRKGsuqjIAcVFmQq +K0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOLGp18EzoOH1u3Hs/lJBQe +sYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSrhRSGlVuX +MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT +XTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/ +HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH +4QIDAQABo3QwcjARBglghkgBhvhCAQEEBAMCAAcwHwYDVR0jBBgwFoAUVeSB0RGA +vtiJuQijMfmhJAkWuXAwHQYDVR0OBBYEFFXkgdERgL7YibkIozH5oSQJFrlwMB0G +CSqGSIb2fQdBAAQQMA4bCFY1LjA6NC4wAwIEkDANBgkqhkiG9w0BAQUFAAOCAQEA +WUesIYSKF8mciVMeuoCFGsY8Tj6xnLZ8xpJdGGQC49MGCBFhfGPjK50xA3B20qMo +oPS7mmNz7W3lKtvtFKkrxjYR0CvrB4ul2p5cGZ1WEvVUKcgF7bISKo30Axv/55IQ +h7A6tcOdBTcSo8f0FbnVpDkWm1M6I5HxqIKiaohowXkCIryqptau37AUX7iH0N18 +f3v/rxzP5tsHrV7bhZ3QKw0z2wTR5klAEyt2+z7pnIkPFc4YsIV4IU9rTw76NmfN +B/L/CNDi3tm/Kq+4h4YhPATKt5Rof8886ZjXOP/swNlQ8C5LWK5Gb9Auw2DaclVy +vUxFnmG6v4SBkgPR0ml8xQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIE7TCCBFagAwIBAgIEOAOR7jANBgkqhkiG9w0BAQQFADCByTELMAkGA1UEBhMC +VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MUgwRgYDVQQLFD93d3cuZW50cnVzdC5u +ZXQvQ2xpZW50X0NBX0luZm8vQ1BTIGluY29ycC4gYnkgcmVmLiBsaW1pdHMgbGlh +Yi4xJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV +BAMTKkVudHJ1c3QubmV0IENsaWVudCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe +Fw05OTEwMTIxOTI0MzBaFw0xOTEwMTIxOTU0MzBaMIHJMQswCQYDVQQGEwJVUzEU +MBIGA1UEChMLRW50cnVzdC5uZXQxSDBGBgNVBAsUP3d3dy5lbnRydXN0Lm5ldC9D +bGllbnRfQ0FfSW5mby9DUFMgaW5jb3JwLiBieSByZWYuIGxpbWl0cyBsaWFiLjEl +MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMq +RW50cnVzdC5uZXQgQ2xpZW50IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0G +CSqGSIb3DQEBAQUAA4GLADCBhwKBgQDIOpleMRffrCdvkHvkGf9FozTC28GoT/Bo +6oT9n3V5z8GKUZSvx1cDR2SerYIbWtp/N3hHuzeYEpbOxhN979IMMFGpOZ5V+Pux +5zDeg7K6PvHViTs7hbqqdCz+PzFur5GVbgbUB01LLFZHGARS2g4Qk79jkJvh34zm +AqTmT173iwIBA6OCAeAwggHcMBEGCWCGSAGG+EIBAQQEAwIABzCCASIGA1UdHwSC +ARkwggEVMIHkoIHhoIHepIHbMIHYMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50 +cnVzdC5uZXQxSDBGBgNVBAsUP3d3dy5lbnRydXN0Lm5ldC9DbGllbnRfQ0FfSW5m +by9DUFMgaW5jb3JwLiBieSByZWYuIGxpbWl0cyBsaWFiLjElMCMGA1UECxMcKGMp +IDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5uZXQg +Q2xpZW50IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCyg +KqAohiZodHRwOi8vd3d3LmVudHJ1c3QubmV0L0NSTC9DbGllbnQxLmNybDArBgNV +HRAEJDAigA8xOTk5MTAxMjE5MjQzMFqBDzIwMTkxMDEyMTkyNDMwWjALBgNVHQ8E +BAMCAQYwHwYDVR0jBBgwFoAUxPucKXuXzUyW/O5bs8qZdIuV6kwwHQYDVR0OBBYE +FMT7nCl7l81MlvzuW7PKmXSLlepMMAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EA +BAwwChsEVjQuMAMCBJAwDQYJKoZIhvcNAQEEBQADgYEAP66K8ddmAwWePvrqHEa7 +pFuPeJoSSJn59DXeDDYHAmsQOokUgZwxpnyyQbJq5wcBoUv5nyU7lsqZwz6hURzz +wy5E97BnRqqS5TvaHBkUODDV4qIxJS7x7EU47fgGWANzYrAQMY9Av2TgXD7FTx/a +EkP/TOYGJqibGapEPHayXOw= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC +VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u +ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc +KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u +ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1 +MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE +ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j +b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF +bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg +U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA +A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/ +I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3 +wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC +AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb +oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5 +BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p +dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk +MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp +b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu +dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0 +MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi +E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa +MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI +hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN +95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd +2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV +UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy +dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1 +MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx +dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f +BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A +cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC +AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ +MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm +aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw +ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj +IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF +MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA +A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y +7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh +1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICgjCCAeugAwIBAgIBBDANBgkqhkiG9w0BAQQFADBTMQswCQYDVQQGEwJVUzEc +MBoGA1UEChMTRXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBT +ZWN1cmUgZUJ1c2luZXNzIENBLTEwHhcNOTkwNjIxMDQwMDAwWhcNMjAwNjIxMDQw +MDAwWjBTMQswCQYDVQQGEwJVUzEcMBoGA1UEChMTRXF1aWZheCBTZWN1cmUgSW5j +LjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNzIENBLTEwgZ8wDQYJ +KoZIhvcNAQEBBQADgY0AMIGJAoGBAM4vGbwXt3fek6lfWg0XTzQaDJj0ItlZ1MRo +RvC0NcWFAyDGr0WlIVFFQesWWDYyb+JQYmT5/VGcqiTZ9J2DKocKIdMSODRsjQBu +WqDZQu4aIZX5UkxVWsUPOE9G+m34LjXWHXzr4vCwdYDIqROsvojvOm6rXyo4YgKw +Env+j6YDAgMBAAGjZjBkMBEGCWCGSAGG+EIBAQQEAwIABzAPBgNVHRMBAf8EBTAD +AQH/MB8GA1UdIwQYMBaAFEp4MlIR21kWNl7fwRQ2QGpHfEyhMB0GA1UdDgQWBBRK +eDJSEdtZFjZe38EUNkBqR3xMoTANBgkqhkiG9w0BAQQFAAOBgQB1W6ibAxHm6VZM +zfmpTMANmvPMZWnmJXbMWbfWVMMdzZmsGd20hdXgPfxiIKeES1hl8eL5lSE/9dR+ +WB5Hh1Q+WKG1tfgq73HnvMP2sUlG4tega+VWeponmHxGYhTnyfxuAxJ5gDgdSIKN +/Bf+KpYrtWKmpj29f5JZzVoqgrI3eQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIEN3DPtTANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMORXF1aWZheCBTZWN1cmUxJjAkBgNVBAsTHUVxdWlmYXggU2Vj +dXJlIGVCdXNpbmVzcyBDQS0yMB4XDTk5MDYyMzEyMTQ0NVoXDTE5MDYyMzEyMTQ0 +NVowTjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDkVxdWlmYXggU2VjdXJlMSYwJAYD +VQQLEx1FcXVpZmF4IFNlY3VyZSBlQnVzaW5lc3MgQ0EtMjCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEA5Dk5kx5SBhsoNviyoynF7Y6yEb3+6+e0dMKP/wXn2Z0G +vxLIPw7y1tEkshHe0XMJitSxLJgJDR5QRrKDpkWNYmi7hRsgcDKqQM2mll/EcTc/ +BPO3QSQ5BxoeLmFYoBIL5aXfxavqN3HMHMg3OrmXUqesxWoklE6ce8/AatbfIb0C +AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEX +MBUGA1UEChMORXF1aWZheCBTZWN1cmUxJjAkBgNVBAsTHUVxdWlmYXggU2VjdXJl +IGVCdXNpbmVzcyBDQS0yMQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTkw +NjIzMTIxNDQ1WjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUUJ4L6q9euSBIplBq +y/3YIHqngnYwHQYDVR0OBBYEFFCeC+qvXrkgSKZQasv92CB6p4J2MAwGA1UdEwQF +MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA +A4GBAAyGgq3oThr1jokn4jVYPSm0B482UJW/bsGe68SQsoWou7dC4A8HOd/7npCy +0cE+U58DRLB+S/Rv5Hwf5+Kx5Lia78O9zt4LMjTZ3ijtM2vE1Nc9ElirfQkty3D1 +E4qUoSek1nDFbZS1yX2doNLGCEnZZpum0/QL3MUmV+GRMOrN +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT +MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i +YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG +EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg +R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9 +9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq +fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv +iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU +1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+ +bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW +MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA +ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l +uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn +Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS +tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF +PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un +hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV +5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG +A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv +b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw +MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i +YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT +aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ +jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp +xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp +1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG +snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ +U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 +9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E +BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B +AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz +yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE +38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP +AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad +DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME +HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYD +VQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNv +bHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJv +b3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEzMjM1OTAwWjB1MQswCQYDVQQGEwJV +UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU +cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds +b2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrH +iM3dFw4usJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTS +r41tiGeA5u2ylc9yMcqlHHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X4 +04Wqk2kmhXBIgD8SFcd5tB8FLztimQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAG3r +GwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMWM4ETCJ57NE7fQMh017l9 +3PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P +lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIB+jCCAWMCAgGjMA0GCSqGSIb3DQEBBAUAMEUxCzAJBgNVBAYTAlVTMRgwFgYD +VQQKEw9HVEUgQ29ycG9yYXRpb24xHDAaBgNVBAMTE0dURSBDeWJlclRydXN0IFJv +b3QwHhcNOTYwMjIzMjMwMTAwWhcNMDYwMjIzMjM1OTAwWjBFMQswCQYDVQQGEwJV +UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMRwwGgYDVQQDExNHVEUgQ3liZXJU +cnVzdCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC45k+625h8cXyv +RLfTD0bZZOWTwUKOx7pJjTUteueLveUFMVnGsS8KDPufpz+iCWaEVh43KRuH6X4M +ypqfpX/1FZSj1aJGgthoTNE3FQZor734sLPwKfWVWgkWYXcKIiXUT0Wqx73llt/5 +1KiOQswkwB6RJ0q1bQaAYznEol44AwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABKz +dcZfHeFhVYAA1IFLezEPI2PnPfMD+fQ2qLvZ46WXTeorKeDWanOB5sCJo9Px4KWl +IjeaY8JIILTbcuPI9tl8vrGvU9oUtCG41tWW4/5ODFlitppK+ULdjG+BqXH/9Apy +bW1EDp3zdHSo1TRJ6V6e6bR64eVaH4QwnNOfpSXY +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIH9zCCB2CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARwxCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE +ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE +ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEzMDEGA1UECxMq +SVBTIENBIENoYWluZWQgQ0FzIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MTMwMQYD +VQQDEypJUFMgQ0EgQ2hhaW5lZCBDQXMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx +HjAcBgkqhkiG9w0BCQEWD2lwc0BtYWlsLmlwcy5lczAeFw0wMTEyMjkwMDUzNTha +Fw0yNTEyMjcwMDUzNThaMIIBHDELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUJhcmNl +bG9uYTESMBAGA1UEBxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJUFMgSW50ZXJuZXQg +cHVibGlzaGluZyBTZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJpcHNAbWFpbC5pcHMu +ZXMgQy5JLkYuICBCLTYwOTI5NDUyMTMwMQYDVQQLEypJUFMgQ0EgQ2hhaW5lZCBD +QXMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMzAxBgNVBAMTKklQUyBDQSBDaGFp +bmVkIENBcyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEeMBwGCSqGSIb3DQEJARYP +aXBzQG1haWwuaXBzLmVzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcVpJJ +spQgvJhPUOtopKdJC7/SMejHT8KGC/po/UNaivNgkjWZOLtNA1IhW/A3mTXhQSCB +hYEFcYGdtJUZqV92NC5jNzVXjrQfQj8VXOF6wV8TGDIxya2+o8eDZh65nAQTy2nB +Bt4wBrszo7Uf8I9vzv+W6FS+ZoCua9tBhDaiPQIDAQABo4IEQzCCBD8wHQYDVR0O +BBYEFKGtMbH5PuEXpsirNPxShwkeYlJBMIIBTgYDVR0jBIIBRTCCAUGAFKGtMbH5 +PuEXpsirNPxShwkeYlJBoYIBJKSCASAwggEcMQswCQYDVQQGEwJFUzESMBAGA1UE +CBMJQmFyY2Vsb25hMRIwEAYDVQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJ +bnRlcm5ldCBwdWJsaXNoaW5nIFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0Bt +YWlsLmlwcy5lcyBDLkkuRi4gIEItNjA5Mjk0NTIxMzAxBgNVBAsTKklQUyBDQSBD +aGFpbmVkIENBcyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEzMDEGA1UEAxMqSVBT +IENBIENoYWluZWQgQ0FzIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4wHAYJKoZI +hvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYDVR0TBAUwAwEB/zAMBgNVHQ8E +BQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYBBQUHAwMG +CCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIBFQYKKwYBBAGCNwIBFgYKKwYB +BAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhCAQEEBAMCAAcwGgYDVR0RBBMw +EYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGBD2lwc0BtYWlsLmlwcy5lczBC +BglghkgBhvhCAQ0ENRYzQ2hhaW5lZCBDQSBDZXJ0aWZpY2F0ZSBpc3N1ZWQgYnkg +aHR0cDovL3d3dy5pcHMuZXMvMCkGCWCGSAGG+EIBAgQcFhpodHRwOi8vd3d3Lmlw +cy5lcy9pcHMyMDAyLzA3BglghkgBhvhCAQQEKhYoaHR0cDovL3d3dy5pcHMuZXMv +aXBzMjAwMi9pcHMyMDAyQ0FDLmNybDA8BglghkgBhvhCAQMELxYtaHR0cDovL3d3 +dy5pcHMuZXMvaXBzMjAwMi9yZXZvY2F0aW9uQ0FDLmh0bWw/MDkGCWCGSAGG+EIB +BwQsFipodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3JlbmV3YWxDQUMuaHRtbD8w +NwYJYIZIAYb4QgEIBCoWKGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcG9saWN5 +Q0FDLmh0bWwwbQYDVR0fBGYwZDAuoCygKoYoaHR0cDovL3d3dy5pcHMuZXMvaXBz +MjAwMi9pcHMyMDAyQ0FDLmNybDAyoDCgLoYsaHR0cDovL3d3d2JhY2suaXBzLmVz +L2lwczIwMDIvaXBzMjAwMkNBQy5jcmwwLwYIKwYBBQUHAQEEIzAhMB8GCCsGAQUF +BzABhhNodHRwOi8vb2NzcC5pcHMuZXMvMA0GCSqGSIb3DQEBBQUAA4GBAERyMJ1W +WKJBGyi3leGmGpVfp3hAK+/blkr8THFj2XOVvQLiogbHvpcqk4A0hgP63Ng9HgfN +HnNDJGD1HWHc3JagvPsd4+cSACczAsDAK1M92GsDgaPb1pOVIO/Tln4mkImcJpvN +b2ar7QMiRDjMWb2f2/YHogF/JsRj9SVCXmK9 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIH6jCCB1OgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARIxCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE +ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE +ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEuMCwGA1UECxMl +SVBTIENBIENMQVNFMSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMl +SVBTIENBIENMQVNFMSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEeMBwGCSqGSIb3 +DQEJARYPaXBzQG1haWwuaXBzLmVzMB4XDTAxMTIyOTAwNTkzOFoXDTI1MTIyNzAw +NTkzOFowggESMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQmFyY2Vsb25hMRIwEAYD +VQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJbnRlcm5ldCBwdWJsaXNoaW5n +IFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0BtYWlsLmlwcy5lcyBDLkkuRi4g +IEItNjA5Mjk0NTIxLjAsBgNVBAsTJUlQUyBDQSBDTEFTRTEgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxLjAsBgNVBAMTJUlQUyBDQSBDTEFTRTEgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2lwc0BtYWlsLmlwcy5lczCBnzAN +BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4FEnpwvdr9G5Q1uCN0VWcu+atsIS7ywS +zHb5BlmvXSHU0lq4oNTzav3KaY1mSPd05u42veiWkXWmcSjK5yISMmmwPh5r9FBS +YmL9Yzt9fuzuOOpi9GyocY3h6YvJP8a1zZRCb92CRTzo3wno7wpVqVZHYUxJZHMQ +KD/Kvwn/xi8CAwEAAaOCBEowggRGMB0GA1UdDgQWBBTrsxl588GlHKzcuh9morKb +adB4CDCCAUQGA1UdIwSCATswggE3gBTrsxl588GlHKzcuh9morKbadB4CKGCARqk +ggEWMIIBEjELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUJhcmNlbG9uYTESMBAGA1UE +BxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJUFMgSW50ZXJuZXQgcHVibGlzaGluZyBT +ZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJpcHNAbWFpbC5pcHMuZXMgQy5JLkYuICBC +LTYwOTI5NDUyMS4wLAYDVQQLEyVJUFMgQ0EgQ0xBU0UxIENlcnRpZmljYXRpb24g +QXV0aG9yaXR5MS4wLAYDVQQDEyVJUFMgQ0EgQ0xBU0UxIENlcnRpZmljYXRpb24g +QXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYD +VR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggr +BgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIB +FQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhC +AQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGB +D2lwc0BtYWlsLmlwcy5lczBBBglghkgBhvhCAQ0ENBYyQ0xBU0UxIENBIENlcnRp +ZmljYXRlIGlzc3VlZCBieSBodHRwOi8vd3d3Lmlwcy5lcy8wKQYJYIZIAYb4QgEC +BBwWGmh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvMDoGCWCGSAGG+EIBBAQtFito +dHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTEuY3JsMD8GCWCG +SAGG+EIBAwQyFjBodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3Jldm9jYXRpb25D +TEFTRTEuaHRtbD8wPAYJYIZIAYb4QgEHBC8WLWh0dHA6Ly93d3cuaXBzLmVzL2lw +czIwMDIvcmVuZXdhbENMQVNFMS5odG1sPzA6BglghkgBhvhCAQgELRYraHR0cDov +L3d3dy5pcHMuZXMvaXBzMjAwMi9wb2xpY3lDTEFTRTEuaHRtbDBzBgNVHR8EbDBq +MDGgL6AthitodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTEu +Y3JsMDWgM6Axhi9odHRwOi8vd3d3YmFjay5pcHMuZXMvaXBzMjAwMi9pcHMyMDAy +Q0xBU0UxLmNybDAvBggrBgEFBQcBAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9v +Y3NwLmlwcy5lcy8wDQYJKoZIhvcNAQEFBQADgYEAK9Dr/drIyllq2tPMMi7JVBuK +Yn4VLenZMdMu9Ccj/1urxUq2ckCuU3T0vAW0xtnIyXf7t/k0f3gA+Nak5FI/LEpj +V4F1Wo7ojPsCwJTGKbqz3Bzosq/SLmJbGqmODszFV0VRFOlOHIilkfSj945RyKm+ +hjM+5i9Ibq9UkE6tsSU= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIH6jCCB1OgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARIxCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE +ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE +ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEuMCwGA1UECxMl +SVBTIENBIENMQVNFMyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMl +SVBTIENBIENMQVNFMyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEeMBwGCSqGSIb3 +DQEJARYPaXBzQG1haWwuaXBzLmVzMB4XDTAxMTIyOTAxMDE0NFoXDTI1MTIyNzAx +MDE0NFowggESMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQmFyY2Vsb25hMRIwEAYD +VQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJbnRlcm5ldCBwdWJsaXNoaW5n +IFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0BtYWlsLmlwcy5lcyBDLkkuRi4g +IEItNjA5Mjk0NTIxLjAsBgNVBAsTJUlQUyBDQSBDTEFTRTMgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxLjAsBgNVBAMTJUlQUyBDQSBDTEFTRTMgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2lwc0BtYWlsLmlwcy5lczCBnzAN +BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqxf+DrDGaBtT8FK+n/ra+osTBLsBjzLZ +H49NzjaY2uQARIwo2BNEKqRrThckQpzTiKRBgtYj+4vJhuW5qYIF3PHeH+AMmVWY +8jjsbJ0gA8DvqqPGZARRLXgNo9KoOtYkTOmWehisEyMiG3zoMRGzXwmqMHBxRiVr +SXGAK5UBsh8CAwEAAaOCBEowggRGMB0GA1UdDgQWBBS4k/8uy9wsjqLnev42USGj +mFsMNDCCAUQGA1UdIwSCATswggE3gBS4k/8uy9wsjqLnev42USGjmFsMNKGCARqk +ggEWMIIBEjELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUJhcmNlbG9uYTESMBAGA1UE +BxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJUFMgSW50ZXJuZXQgcHVibGlzaGluZyBT +ZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJpcHNAbWFpbC5pcHMuZXMgQy5JLkYuICBC +LTYwOTI5NDUyMS4wLAYDVQQLEyVJUFMgQ0EgQ0xBU0UzIENlcnRpZmljYXRpb24g +QXV0aG9yaXR5MS4wLAYDVQQDEyVJUFMgQ0EgQ0xBU0UzIENlcnRpZmljYXRpb24g +QXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYD +VR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggr +BgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIB +FQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhC +AQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGB +D2lwc0BtYWlsLmlwcy5lczBBBglghkgBhvhCAQ0ENBYyQ0xBU0UzIENBIENlcnRp +ZmljYXRlIGlzc3VlZCBieSBodHRwOi8vd3d3Lmlwcy5lcy8wKQYJYIZIAYb4QgEC +BBwWGmh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvMDoGCWCGSAGG+EIBBAQtFito +dHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTMuY3JsMD8GCWCG +SAGG+EIBAwQyFjBodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3Jldm9jYXRpb25D +TEFTRTMuaHRtbD8wPAYJYIZIAYb4QgEHBC8WLWh0dHA6Ly93d3cuaXBzLmVzL2lw +czIwMDIvcmVuZXdhbENMQVNFMy5odG1sPzA6BglghkgBhvhCAQgELRYraHR0cDov +L3d3dy5pcHMuZXMvaXBzMjAwMi9wb2xpY3lDTEFTRTMuaHRtbDBzBgNVHR8EbDBq +MDGgL6AthitodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTMu +Y3JsMDWgM6Axhi9odHRwOi8vd3d3YmFjay5pcHMuZXMvaXBzMjAwMi9pcHMyMDAy +Q0xBU0UzLmNybDAvBggrBgEFBQcBAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9v +Y3NwLmlwcy5lcy8wDQYJKoZIhvcNAQEFBQADgYEAF2VcmZVDAyevJuXr0LMXI/dD +qsfwfewPxqmurpYPdikc4gYtfibFPPqhwYHOU7BC0ZdXGhd+pFFhxu7pXu8Fuuu9 +D6eSb9ijBmgpjnn1/7/5p6/ksc7C0YBCJwUENPjDfxZ4IwwHJPJGR607VNCv1TGy +r33I6unUVtkOE7LFRVA= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIH9zCCB2CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARQxCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE +ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE +ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEvMC0GA1UECxMm +SVBTIENBIENMQVNFQTEgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxLzAtBgNVBAMT +JklQUyBDQSBDTEFTRUExIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4wHAYJKoZI +hvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMwHhcNMDExMjI5MDEwNTMyWhcNMjUxMjI3 +MDEwNTMyWjCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ +BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp +bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G +LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTEgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUExIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMw +gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALsw19zQVL01Tp/FTILq0VA8R5j8 +m2mdd81u4D/u6zJfX5/S0HnllXNEITLgCtud186Nq1KLK3jgm1t99P1tCeWu4Wwd +ByOgF9H5fahGRpEiqLJpxq339fWUoTCUvQDMRH/uxJ7JweaPCjbB/SQ9AaD1e+J8 +eGZDi09Z8pvZ+kmzAgMBAAGjggRTMIIETzAdBgNVHQ4EFgQUZyaW56G/2LUDnf47 +3P7yiuYV3TAwggFGBgNVHSMEggE9MIIBOYAUZyaW56G/2LUDnf473P7yiuYV3TCh +ggEcpIIBGDCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ +BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp +bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G +LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTEgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUExIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOC +AQAwDAYDVR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUF +BwMBBggrBgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYB +BAGCNwIBFQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglg +hkgBhvhCAQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1Ud +EgQTMBGBD2lwc0BtYWlsLmlwcy5lczBCBglghkgBhvhCAQ0ENRYzQ0xBU0VBMSBD +QSBDZXJ0aWZpY2F0ZSBpc3N1ZWQgYnkgaHR0cDovL3d3dy5pcHMuZXMvMCkGCWCG +SAGG+EIBAgQcFhpodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyLzA7BglghkgBhvhC +AQQELhYsaHR0cDovL3d3dy5pcHMuZXMvaXBzMjAwMi9pcHMyMDAyQ0xBU0VBMS5j +cmwwQAYJYIZIAYb4QgEDBDMWMWh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcmV2 +b2NhdGlvbkNMQVNFQTEuaHRtbD8wPQYJYIZIAYb4QgEHBDAWLmh0dHA6Ly93d3cu +aXBzLmVzL2lwczIwMDIvcmVuZXdhbENMQVNFQTEuaHRtbD8wOwYJYIZIAYb4QgEI +BC4WLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcG9saWN5Q0xBU0VBMS5odG1s +MHUGA1UdHwRuMGwwMqAwoC6GLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvaXBz +MjAwMkNMQVNFQTEuY3JsMDagNKAyhjBodHRwOi8vd3d3YmFjay5pcHMuZXMvaXBz +MjAwMi9pcHMyMDAyQ0xBU0VBMS5jcmwwLwYIKwYBBQUHAQEEIzAhMB8GCCsGAQUF +BzABhhNodHRwOi8vb2NzcC5pcHMuZXMvMA0GCSqGSIb3DQEBBQUAA4GBAH66iqyA +AIQVCtWYUQxkxZwCWINmyq0eB81+atqAB98DNEock8RLWCA1NnHtogo1EqWmZaeF +aQoO42Hu6r4okzPV7Oi+xNtff6j5YzHIa5biKcJboOeXNp13XjFr/tOn2yrb25aL +H2betgPAK7N41lUH5Y85UN4HI3LmvSAUS7SG +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIH9zCCB2CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARQxCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE +ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE +ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEvMC0GA1UECxMm +SVBTIENBIENMQVNFQTMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxLzAtBgNVBAMT +JklQUyBDQSBDTEFTRUEzIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4wHAYJKoZI +hvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMwHhcNMDExMjI5MDEwNzUwWhcNMjUxMjI3 +MDEwNzUwWjCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ +BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp +bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G +LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTMgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUEzIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMw +gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAO6AAPYaZC6tasiDsYun7o/ZttvN +G7uGBiJ2MwwSbUhWYdLcgiViL5/SaTBlA0IjWLxH3GvWdV0XPOH/8lhneaDBgbHU +VqLyjRGZ/fZ98cfEXgIqmuJKtROKAP2Md4bm15T1IHUuDky/dMQ/gT6DtKM4Ninn +6Cr1jIhBqoCm42zvAgMBAAGjggRTMIIETzAdBgNVHQ4EFgQUHp9XUEe2YZM50yz8 +2l09BXW3mQIwggFGBgNVHSMEggE9MIIBOYAUHp9XUEe2YZM50yz82l09BXW3mQKh +ggEcpIIBGDCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ +BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp +bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G +LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTMgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUEzIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOC +AQAwDAYDVR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUF +BwMBBggrBgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYB +BAGCNwIBFQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglg +hkgBhvhCAQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1Ud +EgQTMBGBD2lwc0BtYWlsLmlwcy5lczBCBglghkgBhvhCAQ0ENRYzQ0xBU0VBMyBD +QSBDZXJ0aWZpY2F0ZSBpc3N1ZWQgYnkgaHR0cDovL3d3dy5pcHMuZXMvMCkGCWCG +SAGG+EIBAgQcFhpodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyLzA7BglghkgBhvhC +AQQELhYsaHR0cDovL3d3dy5pcHMuZXMvaXBzMjAwMi9pcHMyMDAyQ0xBU0VBMy5j +cmwwQAYJYIZIAYb4QgEDBDMWMWh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcmV2 +b2NhdGlvbkNMQVNFQTMuaHRtbD8wPQYJYIZIAYb4QgEHBDAWLmh0dHA6Ly93d3cu +aXBzLmVzL2lwczIwMDIvcmVuZXdhbENMQVNFQTMuaHRtbD8wOwYJYIZIAYb4QgEI +BC4WLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcG9saWN5Q0xBU0VBMy5odG1s +MHUGA1UdHwRuMGwwMqAwoC6GLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvaXBz +MjAwMkNMQVNFQTMuY3JsMDagNKAyhjBodHRwOi8vd3d3YmFjay5pcHMuZXMvaXBz +MjAwMi9pcHMyMDAyQ0xBU0VBMy5jcmwwLwYIKwYBBQUHAQEEIzAhMB8GCCsGAQUF +BzABhhNodHRwOi8vb2NzcC5pcHMuZXMvMA0GCSqGSIb3DQEBBQUAA4GBAEo9IEca +2on0eisxeewBwMwB9dbB/MjD81ACUZBYKp/nNQlbMAqBACVHr9QPDp5gJqiVp4MI +3y2s6Q73nMify5NF8bpqxmdRSmlPa/59Cy9SKcJQrSRE7SOzSMtEQMEDlQwKeAYS +AfWRMS1Jjbs/RU4s4OjNtckUFQzjB4ObJnXv +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICtzCCAiACAQAwDQYJKoZIhvcNAQEEBQAwgaMxCzAJBgNVBAYTAkVTMRIwEAYD +VQQIEwlCQVJDRUxPTkExEjAQBgNVBAcTCUJBUkNFTE9OQTEZMBcGA1UEChMQSVBT +IFNlZ3VyaWRhZCBDQTEYMBYGA1UECxMPQ2VydGlmaWNhY2lvbmVzMRcwFQYDVQQD +Ew5JUFMgU0VSVklET1JFUzEeMBwGCSqGSIb3DQEJARYPaXBzQG1haWwuaXBzLmVz +MB4XDTk4MDEwMTIzMjEwN1oXDTA5MTIyOTIzMjEwN1owgaMxCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCQVJDRUxPTkExEjAQBgNVBAcTCUJBUkNFTE9OQTEZMBcGA1UE +ChMQSVBTIFNlZ3VyaWRhZCBDQTEYMBYGA1UECxMPQ2VydGlmaWNhY2lvbmVzMRcw +FQYDVQQDEw5JUFMgU0VSVklET1JFUzEeMBwGCSqGSIb3DQEJARYPaXBzQG1haWwu +aXBzLmVzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsT1J0nznqjtwlxLyY +XZhkJAk8IbPMGbWOlI6H0fg3PqHILVikgDVboXVsHUUMH2Fjal5vmwpMwci4YSM1 +gf/+rHhwLWjhOgeYlQJU3c0jt4BT18g3RXIGJBK6E2Ehim51KODFDzT9NthFf+G4 +Nu+z4cYgjui0OLzhPvYR3oydAQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBACzzw3lY +JN7GO9HgQmm47mSzPWIBubOE3yN93ZjPEKn+ANgilgUTB1RXxafey9m4iEL2mdsU +dx+2/iU94aI+A6mB0i1sR/WWRowiq8jMDQ6XXotBtDvECgZAHd1G9AHduoIuPD14 +cJ58GNCr+Lh3B0Zx8coLY1xq+XKU1QFPoNtC +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIIODCCB6GgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCAR4xCzAJBgNVBAYTAkVT +MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE +ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE +ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjE0MDIGA1UECxMr +SVBTIENBIFRpbWVzdGFtcGluZyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTE0MDIG +A1UEAxMrSVBTIENBIFRpbWVzdGFtcGluZyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 +eTEeMBwGCSqGSIb3DQEJARYPaXBzQG1haWwuaXBzLmVzMB4XDTAxMTIyOTAxMTAx +OFoXDTI1MTIyNzAxMTAxOFowggEeMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQmFy +Y2Vsb25hMRIwEAYDVQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJbnRlcm5l +dCBwdWJsaXNoaW5nIFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0BtYWlsLmlw +cy5lcyBDLkkuRi4gIEItNjA5Mjk0NTIxNDAyBgNVBAsTK0lQUyBDQSBUaW1lc3Rh +bXBpbmcgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxNDAyBgNVBAMTK0lQUyBDQSBU +aW1lc3RhbXBpbmcgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHjAcBgkqhkiG9w0B +CQEWD2lwc0BtYWlsLmlwcy5lczCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +vLjuVqWajOY2ycJioGaBjRrVetJznw6EZLqVtJCneK/K/lRhW86yIFcBrkSSQxA4 +Efdo/BdApWgnMjvEp+ZCccWZ73b/K5Uk9UmSGGjKALWkWi9uy9YbLA1UZ2t6KaFY +q6JaANZbuxjC3/YeE1Z2m6Vo4pjOxgOKNNtMg0GmqaMCAwEAAaOCBIAwggR8MB0G +A1UdDgQWBBSL0BBQCYHynQnVDmB4AyKiP8jKZjCCAVAGA1UdIwSCAUcwggFDgBSL +0BBQCYHynQnVDmB4AyKiP8jKZqGCASakggEiMIIBHjELMAkGA1UEBhMCRVMxEjAQ +BgNVBAgTCUJhcmNlbG9uYTESMBAGA1UEBxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJ +UFMgSW50ZXJuZXQgcHVibGlzaGluZyBTZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJp +cHNAbWFpbC5pcHMuZXMgQy5JLkYuICBCLTYwOTI5NDUyMTQwMgYDVQQLEytJUFMg +Q0EgVGltZXN0YW1waW5nIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MTQwMgYDVQQD +EytJUFMgQ0EgVGltZXN0YW1waW5nIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4w +HAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYDVR0TBAUwAwEB/zAM +BgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYB +BQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIBFQYKKwYBBAGCNwIB +FgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhCAQEEBAMCAAcwGgYD +VR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGBD2lwc0BtYWlsLmlw +cy5lczBHBglghkgBhvhCAQ0EOhY4VGltZXN0YW1waW5nIENBIENlcnRpZmljYXRl +IGlzc3VlZCBieSBodHRwOi8vd3d3Lmlwcy5lcy8wKQYJYIZIAYb4QgECBBwWGmh0 +dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvMEAGCWCGSAGG+EIBBAQzFjFodHRwOi8v +d3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJUaW1lc3RhbXBpbmcuY3JsMEUGCWCG +SAGG+EIBAwQ4FjZodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3Jldm9jYXRpb25U +aW1lc3RhbXBpbmcuaHRtbD8wQgYJYIZIAYb4QgEHBDUWM2h0dHA6Ly93d3cuaXBz +LmVzL2lwczIwMDIvcmVuZXdhbFRpbWVzdGFtcGluZy5odG1sPzBABglghkgBhvhC +AQgEMxYxaHR0cDovL3d3dy5pcHMuZXMvaXBzMjAwMi9wb2xpY3lUaW1lc3RhbXBp +bmcuaHRtbDB/BgNVHR8EeDB2MDegNaAzhjFodHRwOi8vd3d3Lmlwcy5lcy9pcHMy +MDAyL2lwczIwMDJUaW1lc3RhbXBpbmcuY3JsMDugOaA3hjVodHRwOi8vd3d3YmFj +ay5pcHMuZXMvaXBzMjAwMi9pcHMyMDAyVGltZXN0YW1waW5nLmNybDAvBggrBgEF +BQcBAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9vY3NwLmlwcy5lcy8wDQYJKoZI +hvcNAQEFBQADgYEAZbrBzAAalZHK6Ww6vzoeFAh8+4Pua2JR0zORtWB5fgTYXXk3 +6MNbsMRnLWhasl8OCvrNPzpFoeo2zyYepxEoxZSPhExTCMWTs/zif/WN87GphV+I +3pGW7hdbrqXqcGV4LCFkAZXOzkw+UPS2Wctjjba9GNSHSl/c7+lW8AoM6HU= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC +TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz +MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw +IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR +dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp +li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D +rOpm2RgbaIr1VxqYuvXtdj182d6UajtLF8HVj71lODqV0D1VNk7feVcxKh7YWWVJ +WCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeLYzcS19Dsw3sgQUSj7cug +F+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWenAScOospU +xbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCC +Ak4wPQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVv +dmFkaXNvZmZzaG9yZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREw +ggENMIIBCQYJKwYBBAG+WAABMIH7MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNl +IG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBh +c3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFy +ZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh +Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYI +KwYBBQUHAgEWFmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3T +KbkGGew5Oanwl4Rqy+/fMIGuBgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rq +y+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1p +dGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD +VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL +MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk +fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8 +7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R +cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y +mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW +xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK +SnQ2+Q== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 +IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz +BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDMgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y +aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG +9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMjIzM1oXDTE5MDYy +NjAwMjIzM1owgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y +azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDMgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw +Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl +cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjmFGWHOjVsQaBalfD +cnWTq8+epvzzFlLWLU2fNUSoLgRNB0mKOCn1dzfnt6td3zZxFJmP3MKS8edgkpfs +2Ejcv8ECIMYkpChMMFp2bbFc893enhBxoYjHW5tBbcqwuI4V7q0zK89HBFx1cQqY +JJgpp0lZpd34t0NiYfPT4tBVPwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFa7AliE +Zwgs3x/be0kz9dNnnfS0ChCzycUs4pJqcXgn8nCDQtM+z6lU9PHYkhaM0QTLS6vJ +n0WuPIqpsHEzXcjFV9+vqDWzf4mH6eglkrh/hXqu1rweN1gqZ8mRzyqBPu3GOd/A +PhmcGcwTTYJBtYze4D1gCCAPRX5ron+jjBXu +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICXDCCAcWgAwIBAgIQCgEBAQAAAnwAAAALAAAAAjANBgkqhkiG9w0BAQUFADA6 +MRkwFwYDVQQKExBSU0EgU2VjdXJpdHkgSW5jMR0wGwYDVQQLExRSU0EgU2VjdXJp +dHkgMTAyNCBWMzAeFw0wMTAyMjIyMTAxNDlaFw0yNjAyMjIyMDAxNDlaMDoxGTAX +BgNVBAoTEFJTQSBTZWN1cml0eSBJbmMxHTAbBgNVBAsTFFJTQSBTZWN1cml0eSAx +MDI0IFYzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDV3f5mCc8kPD6ugU5O +isRpgFtZO9+5TUzKtS3DJy08rwBCbbwoppbPf9dYrIMKo1W1exeQFYRMiu4mmdxY +78c4pqqv0I5CyGLXq6yp+0p9v+r+Ek3d/yYtbzZUaMjShFbuklNhCbM/OZuoyZu9 +zp9+1BlqFikYvtc6adwlWzMaUQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4G +A1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBTEwBykB5T9zU0B1FTapQxf3q4FWjAd +BgNVHQ4EFgQUxMAcpAeU/c1NAdRU2qUMX96uBVowDQYJKoZIhvcNAQEFBQADgYEA +Py1q4yZDlX2Jl2X7deRyHUZXxGFraZ8SmyzVWujAovBDleMf6XbN3Ou8k6BlCsdN +T1+nr6JGFLkM88y9am63nd4lQtBU/55oc2PcJOsiv6hy8l4A4Q1OOkNumU4/iXgD +mMrzVcydro7BqkWY+o8aoI2II/EVQQ2lRj6RP4vr93E= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDYTCCAkmgAwIBAgIQCgEBAQAAAnwAAAAKAAAAAjANBgkqhkiG9w0BAQUFADA6 +MRkwFwYDVQQKExBSU0EgU2VjdXJpdHkgSW5jMR0wGwYDVQQLExRSU0EgU2VjdXJp +dHkgMjA0OCBWMzAeFw0wMTAyMjIyMDM5MjNaFw0yNjAyMjIyMDM5MjNaMDoxGTAX +BgNVBAoTEFJTQSBTZWN1cml0eSBJbmMxHTAbBgNVBAsTFFJTQSBTZWN1cml0eSAy +MDQ4IFYzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt49VcdKA3Xtp +eafwGFAyPGJn9gqVB93mG/Oe2dJBVGutn3y+Gc37RqtBaB4Y6lXIL5F4iSj7Jylg +/9+PjDvJSZu1pJTOAeo+tWN7fyb9Gd3AIb2E0S1PRsNO3Ng3OTsor8udGuorryGl +wSMiuLgbWhOHV4PR8CDn6E8jQrAApX2J6elhc5SYcSa8LWrg903w8bYqODGBDSnh +AMFRD0xS+ARaqn1y07iHKrtjEAMqs6FPDVpeRrc9DvV07Jmf+T0kgYim3WBU6JU2 +PcYJk5qjEoAAVZkZR73QpXzDuvsf9/UP+Ky5tfQ3mBMY3oVbtwyCO4dvlTlYMNpu +AWgXIszACwIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB +BjAfBgNVHSMEGDAWgBQHw1EwpKrpRa41JPr/JCwz0LGdjDAdBgNVHQ4EFgQUB8NR +MKSq6UWuNST6/yQsM9CxnYwwDQYJKoZIhvcNAQEFBQADggEBAF8+hnZuuDU8TjYc +HnmYv/3VEhF5Ug7uMYm83X/50cYVIeiKAVQNOvtUudZj1LGqlk2iQk3UUx+LEN5/ +Zb5gEydxiKRz44Rj0aRV4VCT5hsOedBnvEbIvz8XDZXmxpBp3ue0L96VfdASPz0+ +f00/FGj1EVDVwfSQpQgdMWD/YIwjVAqv/qFuxdF6Kmh4zx6CCiC0H63lhbJqaHVO +rSU3lIW+vaHU6rcMSzyd6BIA8F+sDeGscGNz9395nzIlQnQFgCi/vcEkllgVsRch +6YlL2weIZ/QVrXA+L02FO8K32/6YaCOJ4XQP3vTFhGMpG8zLB8kApKnXwiJPZ9d3 +7CAFYd4= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY +MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t +dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5 +WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD +VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8 +9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ +DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9 +Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N +QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ +xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G +A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T +AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG +kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr +Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5 +Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU +JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot +RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDIDCCAgigAwIBAgIBJDANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP +MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MxIENBMB4XDTAx +MDQwNjEwNDkxM1oXDTIxMDQwNjEwNDkxM1owOTELMAkGA1UEBhMCRkkxDzANBgNV +BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMSBDQTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBALWJHytPZwp5/8Ue+H887dF+2rDNbS82rDTG +29lkFwhjMDMiikzujrsPDUJVyZ0upe/3p4zDq7mXy47vPxVnqIJyY1MPQYx9EJUk +oVqlBvqSV536pQHydekfvFYmUk54GWVYVQNYwBSujHxVX3BbdyMGNpfzJLWaRpXk +3w0LBUXl0fIdgrvGE+D+qnr9aTCU89JFhfzyMlsy3uhsXR/LpCJ0sICOXZT3BgBL +qdReLjVQCfOAl/QMF6452F/NM8EcyonCIvdFEu1eEpOdY6uCLrnrQkFEy0oaAIIN +nvmLVz5MxxftLItyM19yejhW1ebZrgUaHXVFsculJRwSVzb9IjcCAwEAAaMzMDEw +DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQIR+IMi/ZTiFIwCwYDVR0PBAQDAgEG +MA0GCSqGSIb3DQEBBQUAA4IBAQCLGrLJXWG04bkruVPRsoWdd44W7hE928Jj2VuX +ZfsSZ9gqXLar5V7DtxYvyOirHYr9qxp81V9jz9yw3Xe5qObSIjiHBxTZ/75Wtf0H +DjxVyhbMp6Z3N/vbXB9OWQaHowND9Rart4S9Tu+fMTfwRvFAttEMpWT4Y14h21VO +TzF2nBBhjrZTOqMRvq9tfB69ri3iDGnHhVNoomG6xT60eVR4ngrHAr5i0RGCS2Uv +kVrCqIexVmiUefkl98HVrhq4uz2PqYo4Ffdz0Fpg0YCw8NzVUM1O7pJIae2yIx4w +zMiUyLb1O4Z/P6Yun/Y+LLWSlj7fLJOK/4GMDw9ZIRlXvVWa +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP +MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx +MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV +BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o +Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt +5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s +3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej +vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu +8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw +DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG +MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil +zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/ +3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD +FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6 +Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2 +ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgIEAJiWijANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJO +TDEeMBwGA1UEChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSYwJAYDVQQDEx1TdGFh +dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQTAeFw0wMjEyMTcwOTIzNDlaFw0xNTEy +MTYwOTE1MzhaMFUxCzAJBgNVBAYTAk5MMR4wHAYDVQQKExVTdGFhdCBkZXIgTmVk +ZXJsYW5kZW4xJjAkBgNVBAMTHVN0YWF0IGRlciBOZWRlcmxhbmRlbiBSb290IENB +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmNK1URF6gaYUmHFtvszn +ExvWJw56s2oYHLZhWtVhCb/ekBPHZ+7d89rFDBKeNVU+LCeIQGv33N0iYfXCxw71 +9tV2U02PjLwYdjeFnejKScfST5gTCaI+Ioicf9byEGW07l8Y1Rfj+MX94p2i71MO +hXeiD+EwR+4A5zN9RGcaC1Hoi6CeUJhoNFIfLm0B8mBF8jHrqTFoKbt6QZ7GGX+U +tFE5A3+y3qcym7RHjm+0Sq7lr7HcsBthvJly3uSJt3omXdozSVtSnA71iq3DuD3o +BmrC1SoLbHuEvVYFy4ZlkuxEK7COudxwC0barbxjiDn622r+I/q85Ej0ZytqERAh +SQIDAQABo4GRMIGOMAwGA1UdEwQFMAMBAf8wTwYDVR0gBEgwRjBEBgRVHSAAMDww +OgYIKwYBBQUHAgEWLmh0dHA6Ly93d3cucGtpb3ZlcmhlaWQubmwvcG9saWNpZXMv +cm9vdC1wb2xpY3kwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSofeu8Y6R0E3QA +7Jbg0zTBLL9s+DANBgkqhkiG9w0BAQUFAAOCAQEABYSHVXQ2YcG70dTGFagTtJ+k +/rvuFbQvBgwp8qiSpGEN/KtcCFtREytNwiphyPgJWPwtArI5fZlmgb9uXJVFIGzm +eafR2Bwp/MIgJ1HI8XxdNGdphREwxgDS1/PTfLbwMVcoEoJz6TMvplW0C5GUR5z6 +u3pCMuiufi3IvKwUv9kP2Vv8wfl6leF9fpb8cbDCTMjfRTTJzg3ynGQI0DvDKcWy +7ZAEwbEpkcUwb8GpcjPM/l0WFywRaed+/sWDCN+83CI6LiBpIzlWYGeQiy52OfsR +iJf2fL1LuCAWZwWN4jvBcj+UlTfHXbme2JOhF4//DGYVwSR8MnwDHTuhWEUykw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDXDCCAsWgAwIBAgICA+owDQYJKoZIhvcNAQEEBQAwgbwxCzAJBgNVBAYTAkRF +MRAwDgYDVQQIEwdIYW1idXJnMRAwDgYDVQQHEwdIYW1idXJnMTowOAYDVQQKEzFU +QyBUcnVzdENlbnRlciBmb3IgU2VjdXJpdHkgaW4gRGF0YSBOZXR3b3JrcyBHbWJI +MSIwIAYDVQQLExlUQyBUcnVzdENlbnRlciBDbGFzcyAyIENBMSkwJwYJKoZIhvcN +AQkBFhpjZXJ0aWZpY2F0ZUB0cnVzdGNlbnRlci5kZTAeFw05ODAzMDkxMTU5NTla +Fw0xMTAxMDExMTU5NTlaMIG8MQswCQYDVQQGEwJERTEQMA4GA1UECBMHSGFtYnVy +ZzEQMA4GA1UEBxMHSGFtYnVyZzE6MDgGA1UEChMxVEMgVHJ1c3RDZW50ZXIgZm9y +IFNlY3VyaXR5IGluIERhdGEgTmV0d29ya3MgR21iSDEiMCAGA1UECxMZVEMgVHJ1 +c3RDZW50ZXIgQ2xhc3MgMiBDQTEpMCcGCSqGSIb3DQEJARYaY2VydGlmaWNhdGVA +dHJ1c3RjZW50ZXIuZGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANo46O0y +AClxgwENv4wB3NrGrTmkqYov1YtcaF9QxmL1Zr3KkSLsqh1R1z2zUbKDTl3LSbDw +TFXlay3HhQswHJJOgtTKAu33b77c4OMUuAVT8pr0VotanoWT0bSCVq5Nu6hLVxa8 +/vhYnvgpjbB7zXjJT6yLZwzxnPv8V5tXXE8NAgMBAAGjazBpMA8GA1UdEwEB/wQF +MAMBAf8wDgYDVR0PAQH/BAQDAgGGMDMGCWCGSAGG+EIBCAQmFiRodHRwOi8vd3d3 +LnRydXN0Y2VudGVyLmRlL2d1aWRlbGluZXMwEQYJYIZIAYb4QgEBBAQDAgAHMA0G +CSqGSIb3DQEBBAUAA4GBAIRS+yjf/x91AbwBvgRWl2p0QiQxg/lGsQaKic+WLDO/ +jLVfenKhhQbOhvgFjuj5Jcrag4wGrOs2bYWRNAQ29ELw+HkuCkhcq8xRT3h2oNms +Gb0q0WkEKJHKNhAngFdb0lz1wlurZIFjdFH0l7/NEij3TWZ/p/AcASZ4smZHcFFk +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDXDCCAsWgAwIBAgICA+swDQYJKoZIhvcNAQEEBQAwgbwxCzAJBgNVBAYTAkRF +MRAwDgYDVQQIEwdIYW1idXJnMRAwDgYDVQQHEwdIYW1idXJnMTowOAYDVQQKEzFU +QyBUcnVzdENlbnRlciBmb3IgU2VjdXJpdHkgaW4gRGF0YSBOZXR3b3JrcyBHbWJI +MSIwIAYDVQQLExlUQyBUcnVzdENlbnRlciBDbGFzcyAzIENBMSkwJwYJKoZIhvcN +AQkBFhpjZXJ0aWZpY2F0ZUB0cnVzdGNlbnRlci5kZTAeFw05ODAzMDkxMTU5NTla +Fw0xMTAxMDExMTU5NTlaMIG8MQswCQYDVQQGEwJERTEQMA4GA1UECBMHSGFtYnVy +ZzEQMA4GA1UEBxMHSGFtYnVyZzE6MDgGA1UEChMxVEMgVHJ1c3RDZW50ZXIgZm9y +IFNlY3VyaXR5IGluIERhdGEgTmV0d29ya3MgR21iSDEiMCAGA1UECxMZVEMgVHJ1 +c3RDZW50ZXIgQ2xhc3MgMyBDQTEpMCcGCSqGSIb3DQEJARYaY2VydGlmaWNhdGVA +dHJ1c3RjZW50ZXIuZGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALa0wTUF +Lg2N7KBAahwOJ6ZQkmtQGwfeLud2zODa/ISoXoxjaitN2U4CdhHBC/KNecoAtvGw +Dtf7pBc9r6tpepYnv68zoZoqWarEtTcI8hKlMbZD9TKWcSgoq40oht+77uMMfTDW +w1Krj10nnGvAo+cFa1dJRLNu6mTP0o56UHd3AgMBAAGjazBpMA8GA1UdEwEB/wQF +MAMBAf8wDgYDVR0PAQH/BAQDAgGGMDMGCWCGSAGG+EIBCAQmFiRodHRwOi8vd3d3 +LnRydXN0Y2VudGVyLmRlL2d1aWRlbGluZXMwEQYJYIZIAYb4QgEBBAQDAgAHMA0G +CSqGSIb3DQEBBAUAA4GBABY9xs3Bu4VxhUafPiCPUSiZ7C1FIWMjWwS7TJC4iJIE +Tb19AaM/9uzO8d7+feXhPrvGq14L3T2WxMup1Pkm5gZOngylerpuw3yCGdHHsbHD +2w2Om0B8NwvxXej9H5CIpQ5ON2QhqE6NtJ/x3kit1VYYUimLRzQSCdS7kjXvD9s0 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEKzCCAxOgAwIBAgIEOsylTDANBgkqhkiG9w0BAQUFADBDMQswCQYDVQQGEwJE +SzEVMBMGA1UEChMMVERDIEludGVybmV0MR0wGwYDVQQLExRUREMgSW50ZXJuZXQg +Um9vdCBDQTAeFw0wMTA0MDUxNjMzMTdaFw0yMTA0MDUxNzAzMTdaMEMxCzAJBgNV +BAYTAkRLMRUwEwYDVQQKEwxUREMgSW50ZXJuZXQxHTAbBgNVBAsTFFREQyBJbnRl +cm5ldCBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxLhA +vJHVYx/XmaCLDEAedLdInUaMArLgJF/wGROnN4NrXceO+YQwzho7+vvOi20jxsNu +Zp+Jpd/gQlBn+h9sHvTQBda/ytZO5GhgbEaqHF1j4QeGDmUApy6mcca8uYGoOn0a +0vnRrEvLznWv3Hv6gXPU/Lq9QYjUdLP5Xjg6PEOo0pVOd20TDJ2PeAG3WiAfAzc1 +4izbSysseLlJ28TQx5yc5IogCSEWVmb/Bexb4/DPqyQkXsN/cHoSxNK1EKC2IeGN +eGlVRGn1ypYcNIUXJXfi9i8nmHj9eQY6otZaQ8H/7AQ77hPv01ha/5Lr7K7a8jcD +R0G2l8ktCkEiu7vmpwIDAQABo4IBJTCCASEwEQYJYIZIAYb4QgEBBAQDAgAHMGUG +A1UdHwReMFwwWqBYoFakVDBSMQswCQYDVQQGEwJESzEVMBMGA1UEChMMVERDIElu +dGVybmV0MR0wGwYDVQQLExRUREMgSW50ZXJuZXQgUm9vdCBDQTENMAsGA1UEAxME +Q1JMMTArBgNVHRAEJDAigA8yMDAxMDQwNTE2MzMxN1qBDzIwMjEwNDA1MTcwMzE3 +WjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUbGQBx/2FbazI2p5QCIUItTxWqFAw +HQYDVR0OBBYEFGxkAcf9hW2syNqeUAiFCLU8VqhQMAwGA1UdEwQFMAMBAf8wHQYJ +KoZIhvZ9B0EABBAwDhsIVjUuMDo0LjADAgSQMA0GCSqGSIb3DQEBBQUAA4IBAQBO +Q8zR3R0QGwZ/t6T609lN+yOfI1Rb5osvBCiLtSdtiaHsmGnc540mgwV5dOy0uaOX +wTUA/RXaOYE6lTGQ3pfphqiZdwzlWqCE/xIWrG64jcN7ksKsLtB9KOy282A4aW8+ +2ARVPp7MVdK6/rtHBNcK2RYKNCn1WBPVT8+PVkuzHu7TmHnaCB4Mb7j4Fifvwm89 +9qNLPg7kbWzbO0ESm70NRyN/PErQr8Cv9u8btRXE64PECV90i9kR+8JWsTz4cMo0 +jUNAE4z9mQNUecYu6oah9jrUCbz0vGbMPVjQV0kK7iXiQe4T+Zs4NNEA9X7nlB38 +aQNiuJkFBT1reBK9sG9l +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFGTCCBAGgAwIBAgIEPki9xDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJE +SzEMMAoGA1UEChMDVERDMRQwEgYDVQQDEwtUREMgT0NFUyBDQTAeFw0wMzAyMTEw +ODM5MzBaFw0zNzAyMTEwOTA5MzBaMDExCzAJBgNVBAYTAkRLMQwwCgYDVQQKEwNU +REMxFDASBgNVBAMTC1REQyBPQ0VTIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEArGL2YSCyz8DGhdfjeebM7fI5kqSXLmSjhFuHnEz9pPPEXyG9VhDr +2y5h7JNp46PMvZnDBfwGuMo2HP6QjklMxFaaL1a8z3sM8W9Hpg1DTeLpHTk0zY0s +2RKY+ePhwUp8hjjEqcRhiNJerxomTdXkoCJHhNlktxmW/OwZ5LKXJk5KTMuPJItU +GBxIYXvViGjaXbXqzRowwYCDdlCqT9HU3Tjw7xb04QxQBr/q+3pJoSgrHPb8FTKj +dGqPqcNiKXEx5TukYBdedObaE+3pHx8b0bJoc8YQNHVGEBDjkAB2QMuLt0MJIf+r +TpPGWOmlgtt3xDqZsXKVSQTwtyv6e1mO3QIDAQABo4ICNzCCAjMwDwYDVR0TAQH/ +BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwgewGA1UdIASB5DCB4TCB3gYIKoFQgSkB +AQEwgdEwLwYIKwYBBQUHAgEWI2h0dHA6Ly93d3cuY2VydGlmaWthdC5kay9yZXBv +c2l0b3J5MIGdBggrBgEFBQcCAjCBkDAKFgNUREMwAwIBARqBgUNlcnRpZmlrYXRl +ciBmcmEgZGVubmUgQ0EgdWRzdGVkZXMgdW5kZXIgT0lEIDEuMi4yMDguMTY5LjEu +MS4xLiBDZXJ0aWZpY2F0ZXMgZnJvbSB0aGlzIENBIGFyZSBpc3N1ZWQgdW5kZXIg +T0lEIDEuMi4yMDguMTY5LjEuMS4xLjARBglghkgBhvhCAQEEBAMCAAcwgYEGA1Ud +HwR6MHgwSKBGoESkQjBAMQswCQYDVQQGEwJESzEMMAoGA1UEChMDVERDMRQwEgYD +VQQDEwtUREMgT0NFUyBDQTENMAsGA1UEAxMEQ1JMMTAsoCqgKIYmaHR0cDovL2Ny +bC5vY2VzLmNlcnRpZmlrYXQuZGsvb2Nlcy5jcmwwKwYDVR0QBCQwIoAPMjAwMzAy +MTEwODM5MzBagQ8yMDM3MDIxMTA5MDkzMFowHwYDVR0jBBgwFoAUYLWF7FZkfhIZ +J2cdUBVLc647+RIwHQYDVR0OBBYEFGC1hexWZH4SGSdnHVAVS3OuO/kSMB0GCSqG +SIb2fQdBAAQQMA4bCFY2LjA6NC4wAwIEkDANBgkqhkiG9w0BAQUFAAOCAQEACrom +JkbTc6gJ82sLMJn9iuFXehHTuJTXCRBuo7E4A9G28kNBKWKnctj7fAXmMXAnVBhO +inxO5dHKjHiIzxvTkIvmI/gLDjNDfZziChmPyQE+dF10yYscA+UYyAFMP8uXBV2Y +caaYb7Z8vTd/vuGTJW1v8AqtFxjhA7wHKcitJuj4YfD9IQl+mo6paH1IYnK9AOoB +mbgGglGBTvH1tJFUuSN6AJqfXY3gPGS5GhKSKseCRHI53OI8xthV9RVOyAUO28bQ +YqbsFbS1AoLbrIyigfCbmTH1ICCoiGEKB5+U/NDXG8wuF/MEJ3Zn61SD/aSQfgY9 +BKNDLdr8C2LqL19iUw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDITCCAoqgAwIBAgIBADANBgkqhkiG9w0BAQQFADCByzELMAkGA1UEBhMCWkEx +FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYD +VQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBT +ZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFBlcnNvbmFsIEJhc2lj +IENBMSgwJgYJKoZIhvcNAQkBFhlwZXJzb25hbC1iYXNpY0B0aGF3dGUuY29tMB4X +DTk2MDEwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgcsxCzAJBgNVBAYTAlpBMRUw +EwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UE +ChMRVGhhd3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2Vy +dmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQZXJzb25hbCBCYXNpYyBD +QTEoMCYGCSqGSIb3DQEJARYZcGVyc29uYWwtYmFzaWNAdGhhd3RlLmNvbTCBnzAN +BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvLyTU23AUE+CFeZIlDWmWr5vQvoPR+53 +dXLdjUmbllegeNTKP1GzaQuRdhciB5dqxFGTS+CN7zeVoQxN2jSQHReJl+A1OFdK +wPQIcOk8RHtQfmGakOMj04gRRif1CwcOu93RfyAKiLlWCy4cgNrx454p7xS9CkT7 +G1sY0b8jkyECAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQQF +AAOBgQAt4plrsD16iddZopQBHyvdEktTwq1/qqcAXJFAVyVKOKqEcLnZgA+le1z7 +c8a914phXAPjLSeoF+CEhULcXpvGt7Jtu3Sv5D/Lp7ew4F2+eIMllNLbgQ95B21P +9DkVWlIBe94y1k049hJcBlDfBVu9FEuh3ym6O0GN92NWod8isQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDLTCCApagAwIBAgIBADANBgkqhkiG9w0BAQQFADCB0TELMAkGA1UEBhMCWkEx +FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYD +VQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBT +ZXJ2aWNlcyBEaXZpc2lvbjEkMCIGA1UEAxMbVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIENBMSswKQYJKoZIhvcNAQkBFhxwZXJzb25hbC1mcmVlbWFpbEB0aGF3dGUu +Y29tMB4XDTk2MDEwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgdExCzAJBgNVBAYT +AlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEa +MBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRp +b24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0ZSBQZXJzb25hbCBG +cmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxAdGhh +d3RlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1GnX1LCUZFtx6UfY +DFG26nKRsIRefS0Nj3sS34UldSh0OkIsYyeflXtL734Zhx2G6qPduc6WZBrCFG5E +rHzmj+hND3EfQDimAKOHePb5lIZererAXnbr2RSjXW56fAylS1V/Bhkpf56aJtVq +uzgkCGqYx7Hao5iR/Xnb5VrEHLkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zAN +BgkqhkiG9w0BAQQFAAOBgQDH7JJ+Tvj1lqVnYiqk8E0RYNBvjWBYYawmu1I1XAjP +MPuoSpaKH2JCI4wXD/S6ZJwXrEcp352YXtJsYHFcoqzceePnbgBHH7UNKOgCneSa +/RP0ptl8sfjcXyMmCZGAc9AUG95DqYMl8uacLxXK/qarigd1iwzdUYRr5PjRznei +gQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDKTCCApKgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBzzELMAkGA1UEBhMCWkEx +FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYD +VQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBT +ZXJ2aWNlcyBEaXZpc2lvbjEjMCEGA1UEAxMaVGhhd3RlIFBlcnNvbmFsIFByZW1p +dW0gQ0ExKjAoBgkqhkiG9w0BCQEWG3BlcnNvbmFsLXByZW1pdW1AdGhhd3RlLmNv +bTAeFw05NjAxMDEwMDAwMDBaFw0yMDEyMzEyMzU5NTlaMIHPMQswCQYDVQQGEwJa +QTEVMBMGA1UECBMMV2VzdGVybiBDYXBlMRIwEAYDVQQHEwlDYXBlIFRvd24xGjAY +BgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9u +IFNlcnZpY2VzIERpdmlzaW9uMSMwIQYDVQQDExpUaGF3dGUgUGVyc29uYWwgUHJl +bWl1bSBDQTEqMCgGCSqGSIb3DQEJARYbcGVyc29uYWwtcHJlbWl1bUB0aGF3dGUu +Y29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJZtn4B0TPuYwu8KHvE0Vs +Bd/eJxZRNkERbGw77f4QfRKe5ZtCmv5gMcNmt3M6SK5O0DI3lIi1DbbZ8/JE2dWI +Et12TfIa/G8jHnrx2JhFTgcQ7xZC0EN1bUre4qrJMf8fAHB8Zs8QJQi6+u4A6UYD +ZicRFTuqW/KY3TZCstqIdQIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MA0GCSqG +SIb3DQEBBAUAA4GBAGk2ifc0KjNyL2071CKyuG+axTZmDhs8obF1Wub9NdP4qPIH +b4Vnjt4rueIXsDqg8A6iAJrf8xQVbrvIhVqYgPn/vnQdPfP+MCXRNzRn+qVxeTBh +KXLA4CxM+1bkOqhv5TJZUtt1KFBZDPgLGeSs2a+WjS9Q2wfD6h+rM+D1KzGJ +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkEx +FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD +VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv +biBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFByZW1pdW0gU2Vy +dmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZlckB0aGF3dGUuY29t +MB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYTAlpB +MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsG +A1UEChMUVGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRp +b24gU2VydmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNl +cnZlciBDQTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNv +bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2aovXwlue2oFBYo847kkE +VdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIhUdib0GfQ +ug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMR +uHM/qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG +9w0BAQQFAAOBgQAmSCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUI +hfzJATj/Tb7yFkJD57taRvvBxhEf8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JM +pAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDEzCCAnygAwIBAgIBATANBgkqhkiG9w0BAQQFADCBxDELMAkGA1UEBhMCWkEx +FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD +VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv +biBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcGA1UEAxMQVGhhd3RlIFNlcnZlciBDQTEm +MCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5jb20wHhcNOTYwODAx +MDAwMDAwWhcNMjAxMjMxMjM1OTU5WjCBxDELMAkGA1UEBhMCWkExFTATBgNVBAgT +DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3 +dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNl +cyBEaXZpc2lvbjEZMBcGA1UEAxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3 +DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD +gY0AMIGJAoGBANOkUG7I/1Zr5s9dtuoMaHVHoqrC2oQl/Kj0R1HahbUgdJSGHg91 +yekIYfUGbTBuFRkC6VLAYttNmZ7iagxEOM3+vuNkCXDF/rFrKbYvScg71CcEJRCX +L+eQbcAoQpnXTEPew/UhbVSfXcNY4cDk2VuwuNy0e982OsK1ZiIS1ocNAgMBAAGj +EzARMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAB/pMaVz7lcxG +7oWDTSEwjsrZqG9JGubaUeNgcGyEYRGhGshIPllDfU+VPaGLtwtimHp1it2ITk6e +QNuozDJ0uW8NxuOzRAvZim+aKZuZGCg70eNAKJpaPNW15yAbi8qkq43pUdniTCxZ +qdq5snUb9kLy78fyGPmJvKP/iiMucEc= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICoTCCAgqgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBizELMAkGA1UEBhMCWkEx +FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTEUMBIGA1UEBxMLRHVyYmFudmlsbGUxDzAN +BgNVBAoTBlRoYXd0ZTEdMBsGA1UECxMUVGhhd3RlIENlcnRpZmljYXRpb24xHzAd +BgNVBAMTFlRoYXd0ZSBUaW1lc3RhbXBpbmcgQ0EwHhcNOTcwMTAxMDAwMDAwWhcN +MjAxMjMxMjM1OTU5WjCBizELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4g +Q2FwZTEUMBIGA1UEBxMLRHVyYmFudmlsbGUxDzANBgNVBAoTBlRoYXd0ZTEdMBsG +A1UECxMUVGhhd3RlIENlcnRpZmljYXRpb24xHzAdBgNVBAMTFlRoYXd0ZSBUaW1l +c3RhbXBpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANYrWHhhRYZT +6jR7UZztsOYuGA7+4F+oJ9O0yeB8WU4WDnNUYMF/9p8u6TqFJBU820cEY8OexJQa +Wt9MevPZQx08EHp5JduQ/vBR5zDWQQD9nyjfeb6Uu522FOMjhdepQeBMpHmwKxqL +8vg7ij5FrHGSALSQQZj7X+36ty6K+Ig3AgMBAAGjEzARMA8GA1UdEwEB/wQFMAMB +Af8wDQYJKoZIhvcNAQEEBQADgYEAZ9viwuaHPUCDhjc1fR/OmsMMZiCouqoEiYbC +9RAIDb/LogWK0E02PvTX72nGXuSwlG9KuefeW4i2e9vjJ+V2w/A1wcu1J5szedyQ +pgCed/r8zSeUQhac0xxo7L9c3eWpexAKMnRUEzGLhQOEkbdYATAUOK8oyvyxUBkZ +CayJSdM= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB +kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug +Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho +dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw +IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG +EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD +VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu +dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6 +E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ +D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK +4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq +lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW +bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB +o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT +MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js +LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr +BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB +AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft +Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj +j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH +KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv +2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3 +mfnGV/TJVTl4uix5yaaIK/QI +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEojCCA4qgAwIBAgIQRL4Mi1AAJLQR0zYlJWfJiTANBgkqhkiG9w0BAQUFADCB +rjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug +Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho +dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xNjA0BgNVBAMTLVVUTi1VU0VSRmlyc3Qt +Q2xpZW50IEF1dGhlbnRpY2F0aW9uIGFuZCBFbWFpbDAeFw05OTA3MDkxNzI4NTBa +Fw0xOTA3MDkxNzM2NThaMIGuMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAV +BgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5l +dHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTE2MDQGA1UE +AxMtVVROLVVTRVJGaXJzdC1DbGllbnQgQXV0aGVudGljYXRpb24gYW5kIEVtYWls +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsjmFpPJ9q0E7YkY3rs3B +YHW8OWX5ShpHornMSMxqmNVNNRm5pELlzkniii8efNIxB8dOtINknS4p1aJkxIW9 +hVE1eaROaJB7HHqkkqgX8pgV8pPMyaQylbsMTzC9mKALi+VuG6JG+ni8om+rWV6l +L8/K2m2qL+usobNqqrcuZzWLeeEeaYji5kbNoKXqvgvOdjp6Dpvq/NonWz1zHyLm +SGHGTPNpsaguG7bUMSAsvIKKjqQOpdeJQ/wWWq8dcdcRWdq6hw2v+vPhwvCkxWeM +1tZUOt4KpLoDd7NlyP0e03RiqhjKaJMeoYV+9Udly/hNVyh00jT/MLbu9mIwFIws +6wIDAQABo4G5MIG2MAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud +DgQWBBSJgmd9xJ0mcABLtFBIfN49rgRufTBYBgNVHR8EUTBPME2gS6BJhkdodHRw +Oi8vY3JsLnVzZXJ0cnVzdC5jb20vVVROLVVTRVJGaXJzdC1DbGllbnRBdXRoZW50 +aWNhdGlvbmFuZEVtYWlsLmNybDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUH +AwQwDQYJKoZIhvcNAQEFBQADggEBALFtYV2mGn98q0rkMPxTbyUkxsrt4jFcKw7u +7mFVbwQ+zznexRtJlOTrIEy05p5QLnLZjfWqo7NK2lYcYJeA3IKirUq9iiv/Cwm0 +xtcgBEXkzYABurorbs6q15L+5K/r9CYdFip/bDCVNy8zEqx/3cfREYxRmLLQo5HQ +rfafnoOTHh1CuEava2bwm3/q4wMC5QJRwarVNZ1yQAOJujEdxRBoUp7fooXFXAim +eOZTT7Hot9MUnpOmw2TjrH5xzbyf6QMbzPvprDHBr3wVdAKZw7JHpsIyYdfHb0gk +USeh1YdV8nuPmD0Wnu51tvjQjvLzxq4oW6fw8zYX/MMF08oDSlQ= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCB +lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug +Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho +dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt +SGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgxOTIyWjCBlzELMAkG +A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEe +MBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8v +d3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdh +cmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn +0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlIwrthdBKWHTxqctU8EGc6Oe0rE81m65UJ +M6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFdtqdt++BxF2uiiPsA3/4a +MXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8i4fDidNd +oI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqI +DsjfPe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9Ksy +oUhbAgMBAAGjgbkwgbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYD +VR0OBBYEFKFyXyYbKJhDlV0HN9WFlp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0 +dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LUhhcmR3YXJlLmNy +bDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEF +BQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM +//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28Gpgoiskli +CE7/yMgUsogWXecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gE +CJChicsZUN/KHAG8HQQZexB2lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t +3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kniCrVWFCVH/A7HFe7fRQ5YiuayZSS +KqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67nfhmqA== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEZDCCA0ygAwIBAgIQRL4Mi1AAJLQR0zYwS8AzdzANBgkqhkiG9w0BAQUFADCB +ozELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug +Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho +dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xKzApBgNVBAMTIlVUTi1VU0VSRmlyc3Qt +TmV0d29yayBBcHBsaWNhdGlvbnMwHhcNOTkwNzA5MTg0ODM5WhcNMTkwNzA5MTg1 +NzQ5WjCBozELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0 +IExha2UgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYD +VQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xKzApBgNVBAMTIlVUTi1VU0VS +Rmlyc3QtTmV0d29yayBBcHBsaWNhdGlvbnMwggEiMA0GCSqGSIb3DQEBAQUAA4IB +DwAwggEKAoIBAQCz+5Gh5DZVhawGNFugmliy+LUPBXeDrjKxdpJo7CNKyXY/45y2 +N3kDuatpjQclthln5LAbGHNhSuh+zdMvZOOmfAz6F4CjDUeJT1FxL+78P/m4FoCH +iZMlIJpDgmkkdihZNaEdwH+DBmQWICzTSaSFtMBhf1EI+GgVkYDLpdXuOzr0hARe +YFmnjDRy7rh4xdE7EkpvfmUnuaRVxblvQ6TFHSyZwFKkeEwVs0CYCGtDxgGwenv1 +axwiP8vv/6jQOkt2FZ7S0cYu49tXGzKiuG/ohqY/cKvlcJKrRB5AUPuco2LkbG6g +yN7igEL66S/ozjIEj3yNtxyjNTwV3Z7DrpelAgMBAAGjgZEwgY4wCwYDVR0PBAQD +AgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFPqGydvguul49Uuo1hXf8NPh +ahQ8ME8GA1UdHwRIMEYwRKBCoECGPmh0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9V +VE4tVVNFUkZpcnN0LU5ldHdvcmtBcHBsaWNhdGlvbnMuY3JsMA0GCSqGSIb3DQEB +BQUAA4IBAQCk8yXM0dSRgyLQzDKrm5ZONJFUICU0YV8qAhXhi6r/fWRRzwr/vH3Y +IWp4yy9Rb/hCHTO967V7lMPDqaAt39EpHx3+jz+7qEUqf9FuVSTiuwL7MT++6Lzs +QCv4AdRWOOTKRIK1YSAhZ2X28AvnNPilwpyjXEAfhZOVBt5P1CeptqX8Fs1zMT+4 +ZSfP1FMa8Kxun08FDAOBp4QpxFq9ZFdyrTvPNximmMatBrTcCKME1SmklpoSZ0qM +YEWd8SOasACcaLWYUNPvji6SZbFIPiG+FTAqDbUMo2s/rn9X9R+WfN9v3YIwLGUb +QErNaLly7HF27FSOH4UMAWr6pjisH8SE +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 +IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz +BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y +aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG +9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNTIyMjM0OFoXDTE5MDYy +NTIyMjM0OFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y +azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw +Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl +cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYWYJ6ibiWuqYvaG9Y +LqdUHAZu9OqNSLwxlBfw8068srg1knaw0KWlAdcAAxIiGQj4/xEjm84H9b9pGib+ +TunRf50sQB1ZaG6m+FiwnRqP0z/x3BkGgagO4DrdyFNFCQbmD3DD+kCmDuJWBQ8Y +TfwggtFzVXSNdnKgHZ0dwN0/cQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFBoPUn0 +LBwGlN+VYH+Wexf+T3GtZMjdd9LvWVXoP+iOBSoh8gfStadS/pyxtuJbdxdA6nLW +I8sogTLDAHkY7FkXicnGah5xyf23dKUlRWnFSKsZ4UWKJWsZ7uW7EvV/96aNUcPw +nXS3qT6gpf+2SQMT2iLM7XGCK5nPOrf1LXLI +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 +IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz +BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y +aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG +9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE5MDYy +NjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y +azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw +Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl +cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5avIWZJV16vY +dA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zfN1SLUzm1NZ9 +WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7RfZHM047QS +v4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9v +UJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTu +IYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwC +W/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICPTCCAaYCEQDNun9W8N/kvFT+IqyzcqpVMA0GCSqGSIb3DQEBAgUAMF8xCzAJ +BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xh +c3MgMSBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05 +NjAxMjkwMDAwMDBaFw0yODA4MDEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYD +VQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgMSBQdWJsaWMgUHJp +bWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOB +jQAwgYkCgYEA5Rm/baNWYS2ZSHH2Z965jeu3noaACpEO+jglr0aIguVzqKCbJF0N +H8xlbgyw0FaEGIeaBpsQoXPftFg5a27B9hXVqKg/qhIGjTGsf7A01480Z4gJzRQR +4k5FVmkfeAKA2txHkSm7NsljXMXg1y2He6G3MrB7MLoqLzGq7qNn2tsCAwEAATAN +BgkqhkiG9w0BAQIFAAOBgQBMP7iLxmjf7kMzDl3ppssHhE16M/+SG/Q2rdiVIjZo +EWx8QszznC7EBz8UsA9P/5CSdvnivErpj82ggAr3xSnxgiJduLHdgSOjeyUVRjB5 +FvjqBUuUfx3CHMjjt/QQQDwTw18fU+hI5Ia0e6E1sHslurjTjqs/OJ0ANACY89Fx +lA== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEEzH6qqYPnHTkxD4PTqJkZIwDQYJKoZIhvcNAQEFBQAwgcExCzAJ +BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh +c3MgMSBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy +MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp +emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X +DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMSBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo +YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 +MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQCq0Lq+Fi24g9TK0g+8djHKlNgdk4xWArzZbxpvUjZudVYK +VdPfQ4chEWWKfo+9Id5rMj8bhDSVBZ1BNeuS65bdqlk/AVNtmU/t5eIqWpDBucSm +Fc/IReumXY6cPvBkJHalzasab7bYe1FhbqZ/h8jit+U03EGI6glAvnOSPWvndQID +AQABMA0GCSqGSIb3DQEBBQUAA4GBAKlPww3HZ74sy9mozS11534Vnjty637rXC0J +h9ZrbWB85a7FkCMMXErQr7Fd88e2CtvgFZMN3QO8x3aKtd1Pw5sTdbgBwObJW2ul +uIncrKTdcu1OofdPvAbT6shkdHvClUGcZXNY8ZCaPGqxmMnEh7zPRW1F4m4iP/68 +DzFc6PLZ +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCLW3VWhFSFCwDPrzhIzrGkMA0GCSqGSIb3DQEBBQUAMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl +cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu +LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT +aWduIENsYXNzIDEgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD +VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT +aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ +bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu +IENsYXNzIDEgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN2E1Lm0+afY8wR4 +nN493GwTFtl63SRRZsDHJlkNrAYIwpTRMx/wgzUfbhvI3qpuFU5UJ+/EbRrsC+MO +8ESlV8dAWB6jRx9x7GD2bZTIGDnt/kIYVt/kTEkQeE4BdjVjEjbdZrwBBDajVWjV +ojYJrKshJlQGrT/KFOCsyq0GHZXi+J3x4GD/wn91K0zM2v6HmSHquv4+VNfSWXjb +PG7PoBMAGrgnoeS+Z5bKoMWznN3JdZ7rMJpfo83ZrngZPyPpXNspva1VyBtUjGP2 +6KbqxzcSXKMpHgLZ2x87tNcPVkeBFQRKr4Mn0cVYiMHd9qqnoxjaaKptEVHhv2Vr +n5Z20T0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAq2aN17O6x5q25lXQBfGfMY1a +qtmqRiYPce2lrVNWYgFHKkTp/j90CxObufRNG7LRX7K20ohcs5/Ny9Sn2WCVhDr4 +wTcdYcrnsMXlkdpUpqwxga6X3s0IrLjAl4B/bnKk52kTlWUfxJM8/XmPBNQ+T+r3 +ns7NZ3xPZQL/kYVUc8f/NveGLezQXk//EZ9yBta4GvFMDSZl4kSAHsef493oCtrs +pSCAaWihT37ha88HQfqDjrw43bAuEbFrskLMmrz5SCJ5ShkPshw+IHTZasO+8ih4 +E1Z5T21Q6huwtVexN2ZYI/PcD98Kh8TvhgXVOBRgmaNL3gaWcSzy27YfpO8/7g== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEC0b/EoXjaOR6+f/9YtFvgswDQYJKoZIhvcNAQECBQAwXzELMAkG +A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz +cyAyIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 +MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV +BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAyIFB1YmxpYyBQcmlt +YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN +ADCBiQKBgQC2WoujDWojg4BrzzmH9CETMwZMJaLtVRKXxaeAufqDwSCg+i8VDXyh +YGt+eSz6Bg86rvYbb7HS/y8oUl+DfUvEerf4Zh+AVPy3wo5ZShRXRtGak75BkQO7 +FYCTXOvnzAhsPz6zSvz/S2wj1VCCJkQZjiPDceoZJEcEnnW/yKYAHwIDAQABMA0G +CSqGSIb3DQEBAgUAA4GBAIobK/o5wXTXXtgZZKJYSi034DNHD6zt96rbHuSLBlxg +J8pFUs4W7z8GZOeUaHxgMxURaa+dYo2jA1Rrpr7l7gUYYAS/QoD90KioHgE796Nc +r6Pc5iaAIzy4RHT3Cq5Ji2F4zCS/iIqnDupzGUH9TQPwiNHleI2lKk/2lw0Xd8rY +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDAzCCAmwCEQC5L2DMiJ+hekYJuFtwbIqvMA0GCSqGSIb3DQEBBQUAMIHBMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0Ns +YXNzIDIgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH +MjE6MDgGA1UECxMxKGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9y +aXplZCB1c2Ugb25seTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazAe +Fw05ODA1MTgwMDAwMDBaFw0yODA4MDEyMzU5NTlaMIHBMQswCQYDVQQGEwJVUzEX +MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0NsYXNzIDIgUHVibGlj +IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjE6MDgGA1UECxMx +KGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s +eTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAp4gBIXQs5xoD8JjhlzwPIQjxnNuX6Zr8wgQGE75fUsjM +HiwSViy4AWkszJkfrbCWrnkE8hM5wXuYuggs6MKEEyyqaekJ9MepAqRCwiNPStjw +DqL7MWzJ5m+ZJwf15vRMeJ5t60aG+rmGyVTyssSv1EYcWskVMP8NbPUtDm3Of3cC +AwEAATANBgkqhkiG9w0BAQUFAAOBgQByLvl/0fFx+8Se9sVeUYpAmLho+Jscg9ji +nb3/7aHmZuovCfTK1+qlK5X2JGCGTUQug6XELaDTrnhpb3LabK4I8GOSN+a7xDAX +rXfMSTWqz9iP0b63GJZHc2pUIjRkLbYWm1lbtFFZOrMLFPQS32eg9K0yZF6xRnIn +jBJ7xUS0rg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEGTCCAwECEGFwy0mMX5hFKeewptlQW3owDQYJKoZIhvcNAQEFBQAwgcoxCzAJ +BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEfMB0GA1UECxMWVmVy +aVNpZ24gVHJ1c3QgTmV0d29yazE6MDgGA1UECxMxKGMpIDE5OTkgVmVyaVNpZ24s +IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTFFMEMGA1UEAxM8VmVyaVNp +Z24gQ2xhc3MgMiBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 +eSAtIEczMB4XDTk5MTAwMTAwMDAwMFoXDTM2MDcxNjIzNTk1OVowgcoxCzAJBgNV +BAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEfMB0GA1UECxMWVmVyaVNp +Z24gVHJ1c3QgTmV0d29yazE6MDgGA1UECxMxKGMpIDE5OTkgVmVyaVNpZ24sIElu +Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTFFMEMGA1UEAxM8VmVyaVNpZ24g +Q2xhc3MgMiBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt +IEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArwoNwtUs22e5LeWU +J92lvuCwTY+zYVY81nzD9M0+hsuiiOLh2KRpxbXiv8GmR1BeRjmL1Za6tW8UvxDO +JxOeBUebMXoT2B/Z0wI3i60sR/COgQanDTAM6/c8DyAd3HJG7qUCyFvDyVZpTMUY +wZF7C9UTAJu878NIPkZgIIUq1ZC2zYugzDLdt/1AVbJQHFauzI13TccgTacxdu9o +koqQHgiBVrKtaaNS0MscxCM9H5n+TOgWY47GCI72MfbS+uV23bUckqNJzc0BzWjN +qWm6o+sdDZykIKbBoMXRRkwXbdKsZj+WjOCE1Db/IlnF+RFgqF8EffIa9iVCYQ/E +Srg+iQIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQA0JhU8wI1NQ0kdvekhktdmnLfe +xbjQ5F1fdiLAJvmEOjr5jLX77GDx6M4EsMjdpwOPMPOY36TmpDHf0xwLRtxyID+u +7gU8pDM/CzmscHhzS5kr3zDCVLCoO1Wh/hYozUK9dG6A2ydEp85EXdQbkJgNHkKU +sQAsBNB0owIFImNjzYO1+8FtYmtpdf1dcEG59b98377BMnMiIYtYgXsVkXq642RI +sH/7NiXaldDxJBQX3RiAa0YjOVT1jmIJBB2UkKab5iXiQkWquJCtvgiPqQtCGJTP +cjnhsUPgKM+351psE2tJs//jGHyJizNdrDPXp/naOlXJWBD5qu9ats9LS98q +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG +A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz +cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 +MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV +BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt +YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN +ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE +BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is +I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G +CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do +lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc +AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJ +BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh +c3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy +MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp +emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X +DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo +YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 +MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4 +pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg0 +13gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwID +AQABMA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSk +U01UbSuvDV1Ai2TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i +F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY +oJ2daZH9 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl +cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu +LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT +aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD +VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT +aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ +bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu +IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b +N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t +KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu +kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm +CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ +Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu +imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te +2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe +DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC +/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p +F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt +TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEDKIjprS9esTR/h/xCA3JfgwDQYJKoZIhvcNAQEFBQAwgcExCzAJ +BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh +c3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy +MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp +emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X +DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgNCBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo +YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 +MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQC68OTP+cSuhVS5B1f5j8V/aBH4xBewRNzjMHPVKmIquNDM +HO0oW369atyzkSTKQWI8/AIBvxwWMZQFl3Zuoq29YRdsTjCG8FE3KlDHqGKB3FtK +qsGgtG7rL+VXxbErQHDbWk2hjh+9Ax/YA9SPTJlxvOKCzFjomDqG04Y48wApHwID +AQABMA0GCSqGSIb3DQEBBQUAA4GBAIWMEsGnuVAVess+rLhDityq3RS6iYF+ATwj +cSGIL4LcY/oCRaxFWdcqWERbt5+BO5JoPeI3JPV7bI92NZYJqFmduc4jq3TWg/0y +cyfYaT5DdPauxYma51N86Xv2S/PBZYPejYqcPIiNOVn8qj8ijaHBZlCBckztImRP +T8qAkbYp +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl +cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu +LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT +aWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD +VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT +aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ +bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu +IENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK3LpRFpxlmr8Y+1 +GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaStBO3IFsJ ++mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0Gbd +U6LM8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLm +NxdLMEYH5IBtptiWLugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XY +ufTsgsbSPZUd5cBPhMnZo0QoBmrXRazwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ +ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAj/ola09b5KROJ1WrIhVZPMq1 +CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXttmhwwjIDLk5Mq +g6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm +fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c +2NU8Qh0XwRJdRTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/ +bLvSHgCwIe34QWKCudiyxLtGUPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICNDCCAaECEAKtZn5ORf5eV288mBle3cAwDQYJKoZIhvcNAQECBQAwXzELMAkG +A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD +VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk0 +MTEwOTAwMDAwMFoXDTEwMDEwNzIzNTk1OVowXzELMAkGA1UEBhMCVVMxIDAeBgNV +BAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYDVQQLEyVTZWN1cmUgU2Vy +dmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGbMA0GCSqGSIb3DQEBAQUAA4GJ +ADCBhQJ+AJLOesGugz5aqomDV6wlAXYMra6OLDfO6zV4ZFQD5YRAUcm/jwjiioII +0haGN1XpsSECrXZogZoFokvJSyVmIlZsiAeP94FZbYQHZXATcXY+m3dM41CJVphI +uR2nKRoTLkoRWZweFdVJVCxzOmmCsZc5nG1wZ0jl3S3WyB57AgMBAAEwDQYJKoZI +hvcNAQECBQADfgBl3X7hsuyw4jrg7HFGmhkRuNPHoLQDQCYCPgmc4RKz0Vr2N6W3 +YQO2WxZpO8ZECAyIUwxrl0nHPjXcbLm7qt9cuzovk2C2qUtN8iD3zV9/ZHuO3ABc +1/p3yjkWWW8O6tO1g39NTUJWdrTJXwT4OPjr0l91X817/OWOgHz8UA== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDzTCCAzagAwIBAgIQU2GyYK7bcY6nlLMTM/QHCTANBgkqhkiG9w0BAQUFADCB +wTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTwwOgYDVQQL +EzNDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +IC0gRzIxOjA4BgNVBAsTMShjKSAxOTk4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1 +dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmswHhcNMDAwOTI2MDAwMDAwWhcNMTAwOTI1MjM1OTU5WjCBpTEXMBUGA1UEChMO +VmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsx +OzA5BgNVBAsTMlRlcm1zIG9mIHVzZSBhdCBodHRwczovL3d3dy52ZXJpc2lnbi5j +b20vcnBhIChjKTAwMSwwKgYDVQQDEyNWZXJpU2lnbiBUaW1lIFN0YW1waW5nIEF1 +dGhvcml0eSBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0hmdZ8IAIVli +zrQJIkRpivglWtvtDbc2fk7gu5Q+kCWHwmFHKdm9VLhjzCx9abQzNvQ3B5rB3UBU +/OB4naCTuQk9I1F/RMIUdNsKvsvJMDRAmD7Q1yUQgZS9B0+c1lQn3y6ov8uQjI11 +S7zi6ESHzeZBCiVu6PQkAsVSD27smHUCAwEAAaOB3zCB3DAPBgNVHRMECDAGAQH/ +AgEAMEUGA1UdIAQ+MDwwOgYMYIZIAYb4RQEHFwEDMCowKAYIKwYBBQUHAgEWHGh0 +dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9ycGEwMQYDVR0fBCowKDAmoCSgIoYgaHR0 +cDovL2NybC52ZXJpc2lnbi5jb20vcGNhMy5jcmwwCwYDVR0PBAQDAgEGMEIGCCsG +AQUFBwEBBDYwNDAyBggrBgEFBQcwAaYmFiRodHRwOi8vb2NzcC52ZXJpc2lnbi5j +b20vb2NzcC9zdGF0dXMwDQYJKoZIhvcNAQEFBQADgYEAgnBold+2DcIBcBlK0lRW +HqzyRUyHuPU163hLBanInTsZIS5wNEqi9YngFXVF5yg3ADQnKeg3S/LvRJdrF1Ea +w1adPBqK9kpGRjeM+sv1ZFo4aC4cw+9wzrhGBha/937ntag+RaypJXUie28/sJyU +58dzq6wf7iWbwBbtt8pb8BQ= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDojCCAoqgAwIBAgIQE4Y1TR0/BvLB+WUF1ZAcYjANBgkqhkiG9w0BAQUFADBr +MQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRl +cm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNv +bW1lcmNlIFJvb3QwHhcNMDIwNjI2MDIxODM2WhcNMjIwNjI0MDAxNjEyWjBrMQsw +CQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRlcm5h +dGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNvbW1l +cmNlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvV95WHm6h +2mCxlCfLF9sHP4CFT8icttD0b0/Pmdjh28JIXDqsOTPHH2qLJj0rNfVIsZHBAk4E +lpF7sDPwsRROEW+1QK8bRaVK7362rPKgH1g/EkZgPI2h4H3PVz4zHvtH8aoVlwdV +ZqW1LS7YgFmypw23RuwhY/81q6UCzyr0TP579ZRdhE2o8mCP2w4lPJ9zcc+U30rq +299yOIzzlr3xF7zSujtFWsan9sYXiwGd/BmoKoMWuDpI/k4+oKsGGelT84ATB+0t +vz8KPFUgOSwsAGl0lUq8ILKpeeUYiZGo3BxN77t+Nwtd/jmliFKMAGzsGHxBvfaL +dXe6YJ2E5/4tAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD +AgEGMB0GA1UdDgQWBBQVOIMPPyw/cDMezUb+B4wg4NfDtzANBgkqhkiG9w0BAQUF +AAOCAQEAX/FBfXxcCLkr4NWSR/pnXKUTwwMhmytMiUbPWU3J/qVAtmPN3XEolWcR +zCSs00Rsca4BIGsDoo8Ytyk6feUWYFN4PMCvFYP3j1IzJL1kk5fui/fbGKhtcbP3 +LBfQdCVp9/5rPJS+TUtBjE7ic9DjkCJzQ83z7+pzzkWKsKZJ/0x9nXGIxHYdkFsd +7v3M9+79YKWxehZx0RbQfBI8bGmX265fOZpwLwU8GUYEmSA20GBuYQa7FkKMcPcw +++DbZqMAAb3mLNqRX6BGi01qnD093QVG/na/oAo85ADmJ7f/hC3euiInlhBx6yLt +398znM/jra6O1I7mT1GvFpLgXPYHDw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDgDCCAmigAwIBAgICAx4wDQYJKoZIhvcNAQEFBQAwYTELMAkGA1UEBhMCVVMx +DTALBgNVBAoTBFZJU0ExLzAtBgNVBAsTJlZpc2EgSW50ZXJuYXRpb25hbCBTZXJ2 +aWNlIEFzc29jaWF0aW9uMRIwEAYDVQQDEwlHUCBSb290IDIwHhcNMDAwODE2MjI1 +MTAwWhcNMjAwODE1MjM1OTAwWjBhMQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklT +QTEvMC0GA1UECxMmVmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRp +b24xEjAQBgNVBAMTCUdQIFJvb3QgMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKkBcLWqxEDwq2omYXkZAPy/mzdZDK9vZBv42pWUJGkzEXDK41Z0ohdX +ZFwgBuHW73G3O/erwWnQSaSxBNf0V2KJXLB1LRckaeNCYOTudNargFbYiCjh+20i +/SN8RnNPflRzHqgsVVh1t0zzWkWlAhr62p3DRcMiXvOL8WAp0sdftAw6UYPvMPjU +58fy+pmjIlC++QU3o63tmsPm7IgbthknGziLgE3sucfFicv8GjLtI/C1AVj59o/g +halMCXI5Etuz9c9OYmTaxhkVOmMd6RdVoUwiPDQyRvhlV7or7zaMavrZ2UT0qt2E +1w0cslSsMoW0ZA3eQbuxNMYBhjJk1Z8CAwEAAaNCMEAwHQYDVR0OBBYEFJ59SzS/ +ca3CBfYDdYDOqU8axCRMMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEG +MA0GCSqGSIb3DQEBBQUAA4IBAQAhpXYUVfmtJ3CPPPTVbMjMCqujmAuKBiPFyWHb +mQdpNSYx/scuhMKZYdQN6X0uEyt8joW2hcdLzzW2LEc9zikv2G+fiRxkk78IvXbQ +kIqUs38oW26sTTMs7WXcFsziza6kPWKSBpUmv9+55CCmc2rBvveURNZNbyoLaxhN +dBA2aGpawWqn3TYpjLgwi08hPwAuVDAHOrqK5MOeyti12HvOdUVmB/RtLdh6yumJ +ivIj2C/LbgA2T/vwLwHMD8AiZfSr4k5hLQOCfZEWtTDVFN5ex5D8ofyrEK9ca3Cn +B+8phuiyJccg/ybdd+95RBTEvd07xQObdyPsoOy7Wjm1zK0G +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIETzCCAzegAwIBAgIEO63vKTANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE +ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg +U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDEwOTIzMTQxODE3WhcNMTEw +OTIzMTMxODE3WjB1MQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v +LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MR8wHQYDVQQDExZDQyBTaWdu +ZXQgLSBDQSBLbGFzYSAxMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4SRW9Q58g5DY1Hw7h +gCRKBEdPdGn0MFHsfw7rlu/oQm7IChI/uWd9q5wwo77YojtTDjRnpgZsjqBeynX8T90vFILqsY2K +5CF1OESalwvVr3sZiQX79lisuFKat92u6hBFikFIVxfHHB67Af+g7u0dEHdDW7lwy81MwFYxBTRy +9wIDAQABo4IBbTCCAWkwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwggEEBgNVHSAE +gfwwgfkwgfYGDSsGAQQBvj8CAQoBAQAwgeQwgZoGCCsGAQUFBwICMIGNGoGKQ2VydHlmaWthdCB3 +eXN0YXdpb255IHpnb2RuaWUgeiBkb2t1bWVudGVtOiAiUG9saXR5a2EgQ2VydHlmaWthY2ppIGRs +YSBSb290Q0EiLiBDZXJ0eWZpa2F0IHd5c3Rhd2lvbnkgcHJ6ZXogUm9vdENBIHcgaGllcmFyY2hp +aSBDQyBTaWduZXQuMEUGCCsGAQUFBwIBFjlodHRwOi8vd3d3LnNpZ25ldC5wbC9yZXBvenl0b3Jp +dW0vZG9rdW1lbnR5L3BjX3Jvb3RjYS50eHQwHwYDVR0jBBgwFoAUwJvFIw0C4aZOSGsfAOnjmhQb +sa8wHQYDVR0OBBYEFMODHtVZd1T7TftXR/nEI1zR54njMA0GCSqGSIb3DQEBBQUAA4IBAQBRIHQB +FIGh8Jpxt87AgSLwIEEk4+oGy769u3NtoaR0R3WNMdmt7fXTi0tyTQ9V4AIszxVjhnUPaKnF1KYy +f8Tl+YTzk9ZfFkZ3kCdSaILZAOIrmqWNLPmjUQ5/JiMGho0e1YmWUcMci84+pIisTsytFzVP32/W ++sz2H4FQAvOIMmxB7EJX9AdbnXn9EXZ+4nCqi0ft5z96ZqOJJiCB3vSaoYg+wdkcvb6souMJzuc2 +uptXtR1Xf3ihlHaGW+hmnpcwFA6AoNrom6Vgzk6U1ienx0Cw28BhRSKqzKkyXkuK8gRflZUx84uf +tXncwKJrMiE3lvgOOBITRzcahirLer4c +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIE9zCCA9+gAwIBAgIEPL/xoTANBgkqhkiG9w0BAQUFADB2MQswCQYDVQQGEwJQTDEfMB0GA1UE +ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg +U2lnbmV0MSAwHgYDVQQDExdDQyBTaWduZXQgLSBQQ0EgS2xhc2EgMjAeFw0wMjA0MTkxMDI5NTNa +Fw0xNzA0MTgxMjUzMDdaMHUxCzAJBgNVBAYTAlBMMR8wHQYDVQQKExZUUCBJbnRlcm5ldCBTcC4g +eiBvLm8uMSQwIgYDVQQLExtDZW50cnVtIENlcnR5ZmlrYWNqaSBTaWduZXQxHzAdBgNVBAMTFkND +IFNpZ25ldCAtIENBIEtsYXNhIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqgLJu +QqY4yavbSgHg8CyfKTx4BokNSDOVz4eD9vptUr11Kqd06ED1hlH7Sg0goBFAfntNU/QTKwSBaNui +me7C4sSEdgsKrPoAhGb4Mq8y7Ty7RqZz7mkzNMqzL2L2U4yQ2QjvpH8MH0IBqOWEcpSkpwnrCDIm +RoTfd+YlZWKi2JceQixUUYIQ45Ox8+x8hHbvvZdgqtcvo8PW27qoHkp/7hMuJ44kDAGrmxffBXl/ +OBRZp0uO1CSLcMcVJzyr2phKhy406MYdWrtNPEluGs0GFDzd0nrIctiWAO4cmct4S72S9Q6e//0G +O9f3/Ca5Kb2I1xYLj/xE+HgjHX9aD2MhAgMBAAGjggGMMIIBiDAPBgNVHRMBAf8EBTADAQH/MA4G +A1UdDwEB/wQEAwIBBjCB4wYDVR0gBIHbMIHYMIHVBg0rBgEEAb4/AhQKAQEAMIHDMHUGCCsGAQUF +BwICMGkaZ0NlcnR5ZmlrYXQgd3lzdGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0 +eWthIENlcnR5ZmlrYWNqaSBQQ0EyIC0gQ2VydHlmaWthdHkgVXJ6ZWRvdyBLbGFzeSAyIi4wSgYI +KwYBBQUHAgEWPmh0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9kb2t1bWVudHkva2xh +c2EyL3BjX3BjYTIudHh0MD8GA1UdHwQ4MDYwNKAyoDCGLmh0dHA6Ly93d3cuc2lnbmV0LnBsL3Jl +cG96eXRvcml1bS9jcmwvcGNhMi5jcmwwHwYDVR0jBBgwFoAUwGxGyl2CfpYHRonE82AVXO08kMIw +HQYDVR0OBBYEFLtFBlILy4HNKVSzvHxBTM0HDowlMA0GCSqGSIb3DQEBBQUAA4IBAQBWTsCbqXrX +hBBev5v5cIuc6gJM8ww7oR0uMQRZoFSqvQUPWBYM2/TLI/f8UM9hSShUVj3zEsSj/vFHagUVmzuV +Xo5u0WK8iaqATSyEVBhADHrPG6wYcLKJlagge/ILA0m+SieyP2sjYD9MUB9KZIEyBKv0429UuDTw +6P7pslxMWJBSNyQxaLIs0SRKsqZZWkc7ZYAj2apSkBMX2Is1oHA+PwkF6jQMwCao/+CndXPUzfCF +6caa9WwW31W26MlXCvSmJgfiTPwGvm4PkPmOnmWZ3CczzhHl4q7ztHFzshJH3sZWDnrWwBFjzz5e +Pr3WHV1wA7EY6oT4zBx+2gT9XBTB +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEUzCCAzugAwIBAgIEPq+qjzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJQTDE3MDUGA1UE +ChMuQ1ppQyBDZW50cmFzdCBTQSB3IGltaWVuaXUgTWluaXN0cmEgR29zcG9kYXJraTEZMBcGA1UE +AxMQQ1ppQyBDZW50cmFzdCBTQTAeFw0wMzA0MzAxMDUwNTVaFw0wODA0MjgxMDUwNTVaMGgxCzAJ +BgNVBAYTAlBMMR8wHQYDVQQKExZUUCBJbnRlcm5ldCBTcC4geiBvLm8uMR8wHQYDVQQDExZDQyBT +aWduZXQgLSBDQSBLbGFzYSAzMRcwFQYDVQQFEw5OdW1lciB3cGlzdTogNDCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBALVdeOM62cPH2NERFxbS5FIp/HSv3fgesdVsTUFxZbGtE+/E0RMl +KZQJHH9emx7vRYubsi4EOLCjYsCOTFvgGRIpZzx7R7T5c0Di5XFkRU4gjBl7aHJoKb5SLzGlWdoX +GsekVtl6keEACrizV2EafqjI8cnBWY7OxQ1ooLQp5AeFjXg+5PT0lO6TUZAubqjFbhVbxSWjqvdj +93RGfyYE76MnNn4c2xWySD07n7uno06TC0IJe6+3WSX1h+76VsIFouWBXOoM7cxxiLjoqdBVu24+ +P8e81SukE7qEvOwDPmk9ZJFtt1nBNg8a1kaixcljrA/43XwOPz6qnJ+cIj/xywECAwEAAaOCAQow +ggEGMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMDMGA1UdIAEB/wQpMCcwJQYEVR0g +ADAdMBsGCCsGAQUFBwIBFg93d3cuY2VudHJhc3QucGwwgY4GA1UdIwSBhjCBg4AU2a7r85Cp1iJN +W0Ca1LR6VG3996ShZaRjMGExCzAJBgNVBAYTAlBMMTcwNQYDVQQKEy5DWmlDIENlbnRyYXN0IFNB +IHcgaW1pZW5pdSBNaW5pc3RyYSBHb3Nwb2RhcmtpMRkwFwYDVQQDExBDWmlDIENlbnRyYXN0IFNB +ggQ9/0sQMB0GA1UdDgQWBBR7Y8wZkHq0zrY7nn1tFSdQ0PlJuTANBgkqhkiG9w0BAQUFAAOCAQEA +ldt/svO5c1MU08FKgrOXCGEbEPbQxhpM0xcd6Iv3dCo6qugEgjEs9Qm5CwUNKMnFsvR27cJWUvZb +MVcvwlwCwclOdwF6u/QRS8bC2HYErhYo9bp9yuxxzuow2A94c5fPqfVrjXy+vDouchAm6+A5Wjzv +J8wxVFDCs+9iGACmyUWr/JGXCYiQIbQkwlkRKHHlan9ymKf1NvIej/3EpeT8fKr6ywxGuhAfqofW +pg3WJY/RCB4lTzD8vZGNwfMFGkWhJkypad3i9w3lGmDVpsHaWtCgGfd0H7tUtWPkP+t7EjIRCD9J +HYnTR+wbbewc5vOI+UobR15ynGfFIaSIiMTVtQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEejCCA2KgAwIBAgIEP4vk6TANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJQ +TDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2Vu +dHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MR8wHQYDVQQDExZDQyBTaWduZXQgLSBD +QSBLbGFzYSAyMB4XDTAzMTAxNDExNTgyMloXDTE3MDQxODEyNTMwN1owdzELMAkG +A1UEBhMCUEwxHzAdBgNVBAoTFlRQIEludGVybmV0IFNwLiB6IG8uby4xJDAiBgNV +BAsTG0NlbnRydW0gQ2VydHlmaWthY2ppIFNpZ25ldDEhMB8GA1UEAxMYQ0MgU2ln +bmV0IC0gT0NTUCBLbGFzYSAyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCo +VCsaBStblXQYVNthe3dvaCrfvKpPXngh4almm988iIlEv9CVTaAdCfaJNihvA+Vs +Qw8++ix1VqteMQE474/MV/YaXigP0Zr0QB+g+/7PWVlv+5U9Gzp9+Xx4DJay8AoI +iB7Iy5Qf9iZiHm5BiPRIuUXT4ZRbZRYPh0/76vgRsQIDAQABo4IBkjCCAY4wDgYD +VR0PAQH/BAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMJMEEGA1UdHwQ6MDgwNqA0 +oDKGMGh0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9jcmwva2xhc2Ey +LmNybDCB2AYDVR0gBIHQMIHNMIHKBg4rBgEEAb4/AoFICgwBADCBtzBsBggrBgEF +BQcCAjBgGl5DZXJ0eWZpa2F0IHd5ZGFueSB6Z29kbmllIHogZG9rdW1lbnRlbSAi +UG9saXR5a2EgQ2VydHlmaWthY2ppIC0gQ2VydHlmaWthdHkgcmVzcG9uZGVyb3cg +T0NTUCIuMEcGCCsGAQUFBwIBFjtodHRwOi8vd3d3LnNpZ25ldC5wbC9yZXBvenl0 +b3JpdW0vZG9rdW1lbnR5L3BjX29jc3BfMV8wLnBkZjAfBgNVHSMEGDAWgBS7RQZS +C8uBzSlUs7x8QUzNBw6MJTAdBgNVHQ4EFgQUKEVrOY7cEHvsVgvoyZdytlbtgwEw +CQYDVR0TBAIwADANBgkqhkiG9w0BAQUFAAOCAQEAQrRg5MV6dxr0HU2IsLInxhvt +iUVmSFkIUsBCjzLoewOXA16d2oDyHhI/eE+VgAsp+2ANjZu4xRteHIHoYMsN218M +eD2MLRsYS0U9xxAFK9gDj/KscPbrrdoqLvtPSMhUb4adJS9HLhvUe6BicvBf3A71 +iCNe431axGNDWKnpuj2KUpj4CFHYsWCXky847YtTXDjri9NIwJJauazsrSjK+oXp +ngRS506mdQ7vWrtApkh8zhhWp7duCkjcCo1O8JxqYr2qEW1fXmgOISe010v2mmuv +hHxPyVwoAU4KkOw0nbXZn53yak0is5+XmAjh0wWue44AssHrjC9nUh3mkLt6eQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEezCCA2OgAwIBAgIEP4vnLzANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJQ +TDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEfMB0GA1UEAxMWQ0Mg +U2lnbmV0IC0gQ0EgS2xhc2EgMzEXMBUGA1UEBRMOTnVtZXIgd3Bpc3U6IDQwHhcN +MDMxMDE0MTIwODAwWhcNMDgwNDI4MTA1MDU1WjB3MQswCQYDVQQGEwJQTDEfMB0G +A1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBD +ZXJ0eWZpa2FjamkgU2lnbmV0MSEwHwYDVQQDExhDQyBTaWduZXQgLSBPQ1NQIEts +YXNhIDMwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM/9GwvARNuCVN+PqZmO +4FqH8vTqhenUyqRkmAVT4YhLu0a9AXeLAYVDu+NTkYzsAUMAfu55rIKHNLlm6WbF +KvLiKKz4p4pbUr+ToPcwl/TDotidloUdBAxDg0SL+PmQqACZDe3seJho2IYf2vDL +/G4TLMbKmNB0mlWFuN0f4fJNAgMBAAGjggGgMIIBnDAOBgNVHQ8BAf8EBAMCB4Aw +EwYDVR0lBAwwCgYIKwYBBQUHAwkwTwYDVR0fBEgwRjBEoEKgQIY+aHR0cDovL3d3 +dy5zaWduZXQucGwva3dhbGlmaWtvd2FuZS9yZXBvenl0b3JpdW0vY3JsL2tsYXNh +My5jcmwwgdgGA1UdIASB0DCBzTCBygYOKwYBBAG+PwKCLAoCAQAwgbcwbAYIKwYB +BQUHAgIwYBpeQ2VydHlmaWthdCB3eWRhbnkgemdvZG5pZSB6IGRva3VtZW50ZW0g +IlBvbGl0eWthIENlcnR5ZmlrYWNqaSAtIENlcnR5ZmlrYXR5IHJlc3BvbmRlcm93 +IE9DU1AiLjBHBggrBgEFBQcCARY7aHR0cDovL3d3dy5zaWduZXQucGwvcmVwb3p5 +dG9yaXVtL2Rva3VtZW50eS9wY19vY3NwXzFfMC5wZGYwHwYDVR0jBBgwFoAUe2PM +GZB6tM62O559bRUnUND5SbkwHQYDVR0OBBYEFG4jnCMvBALRQXtmDn9TyXQ/EKP+ +MAkGA1UdEwQCMAAwDQYJKoZIhvcNAQEFBQADggEBACXrKG5Def5lpRwmZom3UEDq +bl7y4U3qomG4B+ok2FVZGgPZti+ZgvrenPj7PtbYCUBPsCSTNrznKinoT3gD9lQQ +xkEHwdc6VD1GlFp+qI64u0+wS9Epatrdf7aBnizrOIB4LJd4E2TWQ6trspetjMIU +upyWls1BmYUxB91R7QkTiAUSNZ87s3auhZuG4f0V0JLVCcg2rn7AN1rfMkgxCbHk +GxiQbYWFljl6aatxR3odnnzVUe1I8uoY2JXpmmUcOG4dNGuQYziyKG3mtXCQWvug +5qi9Mf3KUh1oSTKx6HfLjjNl1+wMB5Mdb8LF0XyZLdJM9yIZh7SBRsYm9QiXevY= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFGjCCBAKgAwIBAgIEPL7eEDANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE +ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg +U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDIwNDE4MTQ1NDA4WhcNMjYw +OTIxMTU0MjE5WjB2MQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v +LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MSAwHgYDVQQDExdDQyBTaWdu +ZXQgLSBQQ0EgS2xhc2EgMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM7BrBlbN5ma +M5eg0BOTqoZ+9NBDvU8Lm5rTdrMswFTCathzpVVLK/JD4K3+4oCZ9SRAspEXE4gvwb08ASY6w5s+ +HpRkeJw8YzMFR5kDZD5adgnCAy4vDfIXYZgppXPaTQ8wnfUZ7BZ7Zfa7QBemUIcJIzJBB0UqgtxW +Ceol9IekpBRVmuuSA6QG0Jkm+pGDJ05yj2eQG8jTcBENM7sVA8rGRMyFA4skSZ+D0OG6FS2xC1i9 +JyN0ag1yII/LPx8HK5J4W9MaPRNjAEeaa2qI9EpchwrOxnyVbQfSedCG1VRJfAsE/9tT9CMUPZ3x +W20QjQcSZJqVcmGW9gVsXKQOVLsCAwEAAaOCAbMwggGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P +AQH/BAQDAgEGMIIBBAYDVR0gBIH8MIH5MIH2Bg0rBgEEAb4/AgEKAQEBMIHkMIGaBggrBgEFBQcC +AjCBjRqBikNlcnR5ZmlrYXQgd3lzdGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0 +eWthIENlcnR5ZmlrYWNqaSBkbGEgUm9vdENBIi4gQ2VydHlmaWthdCB3eXN0YXdpb255IHByemV6 +IFJvb3RDQSB3IGhpZXJhcmNoaWkgQ0MgU2lnbmV0LjBFBggrBgEFBQcCARY5aHR0cDovL3d3dy5z +aWduZXQucGwvcmVwb3p5dG9yaXVtL2Rva3VtZW50eS9wY19yb290Y2EudHh0MEQGA1UdHwQ9MDsw +OaA3oDWGM2h0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9yb290Y2Evcm9vdGNhLmNy +bDAfBgNVHSMEGDAWgBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAdBgNVHQ4EFgQUwGxGyl2CfpYHRonE +82AVXO08kMIwDQYJKoZIhvcNAQEFBQADggEBABp1TAUsa+BeVWg4cjowc8yTJ5XN3GvN96GObMkx +UGY7U9kVrLI71xBgoNVyzXTiMNDBvjh7vdPWjpl5SDiRpnnKiOFXA43HvNWzUaOkTu1mxjJsZsan +ot1Xt6j0ZDC+03FjLHdYMyM9kSWp6afb4980EPYZCcSzgM5TOGfJmNii5Tq468VFKrX+52Aou1G2 +2Ohu+EEOlOrG7ylKv1hHUJJCjwN0ZVEIn1nDbrU9FeGCz8J9ihVUvnENEBbBkU37PWqWuHitKQDV +tcwTwJJdR8cmKq3NmkwAm9fPacidQLpaw0WkuGrS+fEDhu1Nhy9xELP6NA9GRTCNxm/dXlcwnmY= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFGjCCBAKgAwIBAgIEPV0tNDANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE +ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg +U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDIwODE2MTY0OTU2WhcNMjYw +OTIxMTU0MjE5WjB2MQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v +LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MSAwHgYDVQQDExdDQyBTaWdu +ZXQgLSBQQ0EgS2xhc2EgMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALN3LanJtdue +Ne6geWUTFENa+lEuzqELcoqhYB+a/tJcPEkc6TX/bYPzalRRjqs+quMP6KZTU0DixOrV+K7iWaqA +iQ913HX5IBLmKDCrTVW/ZvSDpiBKbxlHfSNuJxAuVT6HdbzK7yAW38ssX+yS2tZYHZ5FhZcfqzPE +OpO94mAKcBUhk6T/ki0evXX/ZvvktwmF3hKattzwtM4JMLurAEl8SInyEYULw5JdlfcBez2Tg6Db +w34hA1A+ckTwhxzecrB8TUe2BnQKOs9vr2cCACpFFcOmPkM0Drtjctr1QHm1tYSqRFRf9VcV5tfC +3P8QqoK4ONjtLPHc9x5NE1uK/FMCAwEAAaOCAbMwggGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P +AQH/BAQDAgEGMIIBBAYDVR0gBIH8MIH5MIH2Bg0rBgEEAb4/AgEKAQECMIHkMIGaBggrBgEFBQcC +AjCBjRqBikNlcnR5ZmlrYXQgd3lzdGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0 +eWthIENlcnR5ZmlrYWNqaSBkbGEgUm9vdENBIi4gQ2VydHlmaWthdCB3eXN0YXdpb255IHByemV6 +IFJvb3RDQSB3IGhpZXJhcmNoaWkgQ0MgU2lnbmV0LjBFBggrBgEFBQcCARY5aHR0cDovL3d3dy5z +aWduZXQucGwvcmVwb3p5dG9yaXVtL2Rva3VtZW50eS9wY19yb290Y2EudHh0MEQGA1UdHwQ9MDsw +OaA3oDWGM2h0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9yb290Y2Evcm9vdGNhLmNy +bDAfBgNVHSMEGDAWgBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAdBgNVHQ4EFgQUXvthcPHlH5BgGhlM +ErJNXWlhlgAwDQYJKoZIhvcNAQEFBQADggEBACIce95Mvn710KCAISA0CuHD4aznTU6pLoCDShW4 +7OR+GTpJUm1coTcUqlBHV9mra4VFrBcBuOkHZoBLq/jmE0QJWnpSEULDcH9J3mF0nqO9SM+mWyJG +dsJF/XU/7smummgjMNQXwzQTtWORF+6v5KUbWX85anO2wR+M6YTBWC55zWpWi4RG3vkHFs5Ze2oF +JTlpuxw9ZgxTnWlwI9QR2MvEhYIUMKMOWxw1nt0kKj+5TCNQQGh/VJJ1dsiroGh/io1DOcePEhKz +1Ag52y6Wf0nJJB9yk0sFakqZH18F7eQecQImgZyyeRtsG95leNugB3BXWCW+KxwiBrtQTXv4dTE= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEzzCCA7egAwIBAgIEO6ocGTANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE +ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg +U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDEwOTIwMTY0MjE5WhcNMjYw +OTIxMTU0MjE5WjBxMQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v +LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MRswGQYDVQQDExJDQyBTaWdu +ZXQgLSBSb290Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrr2vydnNpELfGW3Ks +ARiDhJvwDtUe4AbWev+OfMc3+vA29nX8ZmIwno3gmItjo5DbUCCRiCMq5c9epcGu+kg4a3BJChVX +REl8gVh0ST15rr3RKrSc4VgsvQzl0ZUraeQLl8JoRT5PLsUj3qwF78jUCQVckiiLVcnGfZtFCm+D +CJXliQBDMB9XFAUEiO/DtEBs0B7wJGx7lgJeJpQUcGiaOPjcJDYOk7rNAYmmD2gWeSlepufO8luU +YG/YDxTC4mqhRqfa4MnVO5dqy+ICj2UvUpHbZDB0KfGRibgBYeQP1kuqgIzJN4UqknVAJb0aMBSP +l+9k2fAUdchx1njlbdcbAgMBAAGjggFtMIIBaTAPBgNVHRMBAf8EBTADAQH/MIIBBAYDVR0gBIH8 +MIH5MIH2Bg0rBgEEAb4/AgEKAQEAMIHkMIGaBggrBgEFBQcCAjCBjRqBikNlcnR5ZmlrYXQgd3lz +dGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0eWthIENlcnR5ZmlrYWNqaSBkbGEg +Um9vdENBIi4gQ2VydHlmaWthdCB3eXN0YXdpb255IHByemV6IFJvb3RDQSB3IGhpZXJhcmNoaWkg +Q0MgU2lnbmV0LjBFBggrBgEFBQcCARY5aHR0cDovL3d3dy5zaWduZXQucGwvcmVwb3p5dG9yaXVt +L2Rva3VtZW50eS9wY19yb290Y2EudHh0MB0GA1UdDgQWBBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAf +BgNVHSMEGDAWgBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcN +AQEFBQADggEBAGnY5QmYqnnO9OqFOWZxxb25UHRnaRF6IV9aaGit5BZufZj2Tq3v8L3SgE34GOoI +cdRMMG5JEpEU4mN/Ef3oY6Eo+7HfqaPHI4KFmbDSPiK5s+wmf+bQSm0Yq5/h4ZOdcAESlLQeLSt1 +CQk2JoKQJ6pyAf6xJBgWEIlm4RXE4J3324PUiOp83kW6MDvaa1xY976WyInr4rwoLgxVl11LZeKW +ha0RJJxJgw/NyWpKG7LWCm1fglF8JH51vZNndGYq1iKtfnrIOvLZq6bzaCiZm1EurD8HE6P7pmAB +KK6o3C2OXlNfNIgwkDN/cDqk5TYsTkrpfriJPdxXBH8hQOkW89g= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID/TCCA2agAwIBAgIEP4/gkTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJQTDEfMB0GA1UE +ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg +U2lnbmV0MR8wHQYDVQQDExZDQyBTaWduZXQgLSBDQSBLbGFzYSAxMB4XDTAzMTAxNzEyMjkwMloX +DTExMDkyMzExMTgxN1owdjELMAkGA1UEBhMCUEwxHzAdBgNVBAoTFlRQIEludGVybmV0IFNwLiB6 +IG8uby4xJDAiBgNVBAsTG0NlbnRydW0gQ2VydHlmaWthY2ppIFNpZ25ldDEgMB4GA1UEAxMXQ0Mg +U2lnbmV0IC0gVFNBIEtsYXNhIDEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOJYrISEtSsd +uHajROh5/n7NGrkpYTT9NEaPe9+ucuQ37KxIbfJwXJjgUc1dw4wCkcQ12FJarD1X6mSQ4cfN/60v +LfKI5ZD4nhJTMKlAj1pX9ScQ/MuyvKStCbn5WTkjPhjRAM0tdwXSnzuTEunfw0Oup559y3Iqxg1c +ExflB6cfAgMBAAGjggGXMIIBkzBBBgNVHR8EOjA4MDagNKAyhjBodHRwOi8vd3d3LnNpZ25ldC5w +bC9yZXBvenl0b3JpdW0vY3JsL2tsYXNhMS5jcmwwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQM +MAoGCCsGAQUFBwMIMIHaBgNVHSAEgdIwgc8wgcwGDSsGAQQBvj8CZAoRAgEwgbowbwYIKwYBBQUH +AgIwYxphQ2VydHlmaWthdCB3eXN0YXdpb255IHpnb2RuaWUgeiBkb2t1bWVudGVtICJQb2xpdHlr +YSBDZXJ0eWZpa2FjamkgQ0MgU2lnbmV0IC0gWm5ha293YW5pZSBjemFzZW0iLjBHBggrBgEFBQcC +ARY7aHR0cDovL3d3dy5zaWduZXQucGwvcmVwb3p5dG9yaXVtL2Rva3VtZW50eS9wY190c2ExXzJf +MS5wZGYwHwYDVR0jBBgwFoAUw4Me1Vl3VPtN+1dH+cQjXNHnieMwHQYDVR0OBBYEFJdDwEqtcavO +Yd9u9tej53vWXwNBMAkGA1UdEwQCMAAwDQYJKoZIhvcNAQEFBQADgYEAnpiQkqLCJQYXUrqMHUEz ++z3rOqS0XzSFnVVLhkVssvXc8S3FkJIiQTUrkScjI4CToCzujj3EyfNxH6yiLlMbskF8I31JxIeB +vueqV+s+o76CZm3ycu9hb0I4lswuxoT+q5ZzPR8Irrb51rZXlolR+7KtwMg4sFDJZ8RNgOf7tbA= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBADANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJFVTEn +MCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQL +ExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEiMCAGA1UEAxMZQ2hhbWJlcnMg +b2YgQ29tbWVyY2UgUm9vdDAeFw0wMzA5MzAxNjEzNDNaFw0zNzA5MzAxNjEzNDRa +MH8xCzAJBgNVBAYTAkVVMScwJQYDVQQKEx5BQyBDYW1lcmZpcm1hIFNBIENJRiBB +ODI3NDMyODcxIzAhBgNVBAsTGmh0dHA6Ly93d3cuY2hhbWJlcnNpZ24ub3JnMSIw +IAYDVQQDExlDaGFtYmVycyBvZiBDb21tZXJjZSBSb290MIIBIDANBgkqhkiG9w0B +AQEFAAOCAQ0AMIIBCAKCAQEAtzZV5aVdGDDg2olUkfzIx1L4L1DZ77F1c2VHfRtb +unXF/KGIJPov7coISjlUxFF6tdpg6jg8gbLL8bvZkSM/SAFwdakFKq0fcfPJVD0d +BmpAPrMMhe5cG3nCYsS4No41XQEMIwRHNaqbYE6gZj3LJgqcQKH0XZi/caulAGgq +7YN6D6IUtdQis4CwPAxaUWktWBiP7Zme8a7ileb2R6jWDA+wWFjbw2Y3npuRVDM3 +0pQcakjJyfKl2qUMI/cjDpwyVV5xnIQFUZot/eZOKjRa3spAN2cMVCFVd9oKDMyX +roDclDZK9D7ONhMeU+SsTjoF7Nuucpw4i9A5O4kKPnf+dQIBA6OCAUQwggFAMBIG +A1UdEwEB/wQIMAYBAf8CAQwwPAYDVR0fBDUwMzAxoC+gLYYraHR0cDovL2NybC5j +aGFtYmVyc2lnbi5vcmcvY2hhbWJlcnNyb290LmNybDAdBgNVHQ4EFgQU45T1sU3p +26EpW1eLTXYGduHRooowDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIA +BzAnBgNVHREEIDAegRxjaGFtYmVyc3Jvb3RAY2hhbWJlcnNpZ24ub3JnMCcGA1Ud +EgQgMB6BHGNoYW1iZXJzcm9vdEBjaGFtYmVyc2lnbi5vcmcwWAYDVR0gBFEwTzBN +BgsrBgEEAYGHLgoDATA+MDwGCCsGAQUFBwIBFjBodHRwOi8vY3BzLmNoYW1iZXJz +aWduLm9yZy9jcHMvY2hhbWJlcnNyb290Lmh0bWwwDQYJKoZIhvcNAQEFBQADggEB +AAxBl8IahsAifJ/7kPMa0QOx7xP5IV8EnNrJpY0nbJaHkb5BkAFyk+cefV/2icZd +p0AJPaxJRUXcLo0waLIJuvvDL8y6C98/d3tGfToSJI6WjzwFCm/SlCgdbQzALogi +1djPHRPH8EjX1wWnz8dHnjs8NMiAT9QUu/wNUPf6s+xCX6ndbcj0dc97wXImsQEc +XCz9ek60AcUFV7nnPKoF2YjpB0ZBzu9Bga5Y34OirsrXdx/nADydb47kMgkdTXg0 +eDQ8lJsm7U9xxhl6vSAiSFr+S30Dt+dYvsYyTnQeaN2oaFuzPu5ifdmA6Ap1erfu +tGWaIZDgqtCYvDi1czyL+Nw= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIExTCCA62gAwIBAgIBADANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJFVTEn +MCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQL +ExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEgMB4GA1UEAxMXR2xvYmFsIENo +YW1iZXJzaWduIFJvb3QwHhcNMDMwOTMwMTYxNDE4WhcNMzcwOTMwMTYxNDE4WjB9 +MQswCQYDVQQGEwJFVTEnMCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgy +NzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEgMB4G +A1UEAxMXR2xvYmFsIENoYW1iZXJzaWduIFJvb3QwggEgMA0GCSqGSIb3DQEBAQUA +A4IBDQAwggEIAoIBAQCicKLQn0KuWxfH2H3PFIP8T8mhtxOviteePgQKkotgVvq0 +Mi+ITaFgCPS3CU6gSS9J1tPfnZdan5QEcOw/Wdm3zGaLmFIoCQLfxS+EjXqXd7/s +QJ0lcqu1PzKY+7e3/HKE5TWH+VX6ox8Oby4o3Wmg2UIQxvi1RMLQQ3/bvOSiPGpV +eAp3qdjqGTK3L/5cPxvusZjsyq16aUXjlg9V9ubtdepl6DJWk0aJqCWKZQbua795 +B9Dxt6/tLE2Su8CoX6dnfQTyFQhwrJLWfQTSM/tMtgsL+xrJxI0DqX5c8lCrEqWh +z0hQpe/SyBoT+rB/sYIcd2oPX9wLlY/vQ37mRQklAgEDo4IBUDCCAUwwEgYDVR0T +AQH/BAgwBgEB/wIBDDA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3JsLmNoYW1i +ZXJzaWduLm9yZy9jaGFtYmVyc2lnbnJvb3QuY3JsMB0GA1UdDgQWBBRDnDafsJ4w +TcbOX60Qq+UDpfqpFDAOBgNVHQ8BAf8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgAH +MCoGA1UdEQQjMCGBH2NoYW1iZXJzaWducm9vdEBjaGFtYmVyc2lnbi5vcmcwKgYD +VR0SBCMwIYEfY2hhbWJlcnNpZ25yb290QGNoYW1iZXJzaWduLm9yZzBbBgNVHSAE +VDBSMFAGCysGAQQBgYcuCgEBMEEwPwYIKwYBBQUHAgEWM2h0dHA6Ly9jcHMuY2hh +bWJlcnNpZ24ub3JnL2Nwcy9jaGFtYmVyc2lnbnJvb3QuaHRtbDANBgkqhkiG9w0B +AQUFAAOCAQEAPDtwkfkEVCeR4e3t/mh/YV3lQWVPMvEYBZRqHN4fcNs+ezICNLUM +bKGKfKX0j//U2K0X1S0E0T9YgOKBWYi+wONGkyT+kL0mojAt6JcmVzWJdJYY9hXi +ryQZVgICsroPFOrGimbBhkVVi76SvpykBMdJPJ7oKXqJ1/6v/2j1pReQvayZzKWG +VwlnRtvWFsJG8eSpUPWP0ZIV018+xgBJOm5YstHRJw0lyDL4IBHNfTIzSJRUTN3c +ecQwn+uOuFW114hcxWokPbLTBQNRxgfvzBRydD1ucs4YKIxKoHflCStFREest2d/ +AYoFWpO+ocH/+OcOZ6RHSXZddZAa9SaP8A== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAw +PTELMAkGA1UEBhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFz +cyAyIFByaW1hcnkgQ0EwHhcNOTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9 +MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2VydHBsdXMxGzAZBgNVBAMTEkNsYXNz +IDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANxQ +ltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR5aiR +VhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyL +kcAbmXuZVg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCd +EgETjdyAYveVqUSISnFOYFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yas +H7WLO7dDWWuwJKZtkIvEcupdM5i3y95ee++U8Rs+yskhwcWYAqqi9lt3m/V+llU0 +HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRMECDAGAQH/AgEKMAsGA1Ud +DwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJYIZIAYb4 +QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMu +Y29tL0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/ +AN9WM2K191EBkOvDP9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8 +yfFC82x/xXp8HVGIutIKPidd3i1RTtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMR +FcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+7UCmnYR0ObncHoUW2ikbhiMA +ybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW//1IMwrh3KWB +kJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7 +l7+ijrRU +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB +gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G +A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV +BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw +MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl +YXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01P +RE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3 +UcEbVASY06m/weaKXTuH+7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI +2GqGd0S7WWaXUF601CxwRM/aN5VCaTwwxHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8 +Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV4EajcNxo2f8ESIl33rXp ++2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA1KGzqSX+ +DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5O +nKVIrLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW +/zAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6g +PKA6hjhodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9u +QXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAPpiem/Yb6dc5t3iuHXIY +SdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CPOGEIqB6BCsAv +IC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/ +RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4 +zJVSk/BwJVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd +BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB +ZQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv +b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl +cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c +JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP +mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+ +wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4 +VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/ +AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB +AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW +BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun +pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC +dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf +fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm +NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx +H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe ++o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD +QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT +MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j +b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB +CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 +nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt +43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P +T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4 +gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO +BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR +TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw +DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr +hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg +06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF +PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls +YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk +CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j +ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL +MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3 +LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug +RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm ++9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW +PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM +xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB +Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3 +hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg +EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA +FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec +nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z +eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF +hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2 +Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe +vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep ++OkuE6N36B9K +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIECTCCAvGgAwIBAgIQDV6ZCtadt3js2AdWO4YV2TANBgkqhkiG9w0BAQUFADBb +MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3Qx +ETAPBgNVBAsTCERTVCBBQ0VTMRcwFQYDVQQDEw5EU1QgQUNFUyBDQSBYNjAeFw0w +MzExMjAyMTE5NThaFw0xNzExMjAyMTE5NThaMFsxCzAJBgNVBAYTAlVTMSAwHgYD +VQQKExdEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdDERMA8GA1UECxMIRFNUIEFDRVMx +FzAVBgNVBAMTDkRTVCBBQ0VTIENBIFg2MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEAuT31LMmU3HWKlV1j6IR3dma5WZFcRt2SPp/5DgO0PWGSvSMmtWPu +ktKe1jzIDZBfZIGxqAgNTNj50wUoUrQBJcWVHAx+PhCEdc/BGZFjz+iokYi5Q1K7 +gLFViYsx+tC3dr5BPTCapCIlF3PoHuLTrCq9Wzgh1SpL11V94zpVvddtawJXa+ZH +fAjIgrrep4c9oW24MFbCswKBXy314powGCi4ZtPLAZZv6opFVdbgnf9nKxcCpk4a +ahELfrd755jWjHZvwTvbUJN+5dCOHze4vbrGn2zpfDPyMjwmR/onJALJfh1biEIT +ajV8fTXpLmaRcpPVMibEdPVTo7NdmvYJywIDAQABo4HIMIHFMA8GA1UdEwEB/wQF +MAMBAf8wDgYDVR0PAQH/BAQDAgHGMB8GA1UdEQQYMBaBFHBraS1vcHNAdHJ1c3Rk +c3QuY29tMGIGA1UdIARbMFkwVwYKYIZIAWUDAgEBATBJMEcGCCsGAQUFBwIBFjto +dHRwOi8vd3d3LnRydXN0ZHN0LmNvbS9jZXJ0aWZpY2F0ZXMvcG9saWN5L0FDRVMt +aW5kZXguaHRtbDAdBgNVHQ4EFgQUCXIGThhDD+XWzMNqizF7eI+og7gwDQYJKoZI +hvcNAQEFBQADggEBAKPYjtay284F5zLNAdMEA+V25FYrnJmQ6AgwbN99Pe7lv7Uk +QIRJ4dEorsTCOlMwiPH1d25Ryvr/ma8kXxug/fKshMrfqfBfBC6tFr8hlxCBPeP/ +h40y3JTlR4peahPJlJU90u7INJXQgNStMgiAVDzgvVJT11J8smk/f3rPanTK+gQq +nExaBqXpIK1FZg9p8d2/6eMyi/rgwYZNcjwu2JN4Cir42NInPRmJX1p7ijvMDNpR +rscL9yuwNwXsvFcj4jjSm2jzVhKIT0J8uDHEtdvkyCE06UgRNe76x5JXxZ805Mf2 +9w4LTJxoeHtxMcfrHuBnQfO3oKfN5XozNmr6mis= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/ +MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT +DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow +PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD +Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O +rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq +OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b +xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw +7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD +aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV +HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG +SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69 +ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr +AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz +R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5 +JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo +Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0 +Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW +KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl +cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw +NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw +NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy +ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV +BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo +Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4 +4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9 +KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI +rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi +94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB +sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi +gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo +kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE +vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA +A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t +O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua +AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP +9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/ +eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m +0vdXcDazv/wor3ElhVsT/h5/WrQ8 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEVzCCAz+gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBnTELMAkGA1UEBhMCRVMx +IjAgBgNVBAcTGUMvIE11bnRhbmVyIDI0NCBCYXJjZWxvbmExQjBABgNVBAMTOUF1 +dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 +MjYzNDA2ODEmMCQGCSqGSIb3DQEJARYXY2FAZmlybWFwcm9mZXNpb25hbC5jb20w +HhcNMDExMDI0MjIwMDAwWhcNMTMxMDI0MjIwMDAwWjCBnTELMAkGA1UEBhMCRVMx +IjAgBgNVBAcTGUMvIE11bnRhbmVyIDI0NCBCYXJjZWxvbmExQjBABgNVBAMTOUF1 +dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 +MjYzNDA2ODEmMCQGCSqGSIb3DQEJARYXY2FAZmlybWFwcm9mZXNpb25hbC5jb20w +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDnIwNvbyOlXnjOlSztlB5u +Cp4Bx+ow0Syd3Tfom5h5VtP8c9/Qit5Vj1H5WuretXDE7aTt/6MNbg9kUDGvASdY +rv5sp0ovFy3Tc9UTHI9ZpTQsHVQERc1ouKDAA6XPhUJHlShbz++AbOCQl4oBPB3z +hxAwJkh91/zpnZFx/0GaqUC1N5wpIE8fUuOgfRNtVLcK3ulqTgesrBlf3H5idPay +BQC6haD9HThuy1q7hryUZzM1gywfI834yJFxzJeL764P3CkDG8A563DtwW4O2GcL +iam8NeTvtjS0pbbELaW+0MOUJEjb35bTALVmGotmBQ/dPz/LP6pemkr4tErvlTcb +AgMBAAGjgZ8wgZwwKgYDVR0RBCMwIYYfaHR0cDovL3d3dy5maXJtYXByb2Zlc2lv +bmFsLmNvbTASBgNVHRMBAf8ECDAGAQH/AgEBMCsGA1UdEAQkMCKADzIwMDExMDI0 +MjIwMDAwWoEPMjAxMzEwMjQyMjAwMDBaMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4E +FgQUMwugZtHq2s7eYpMEKFK1FH84aLcwDQYJKoZIhvcNAQEFBQADggEBAEdz/o0n +VPD11HecJ3lXV7cVVuzH2Fi3AQL0M+2TUIiefEaxvT8Ub/GzR0iLjJcG1+p+o1wq +u00vR+L4OQbJnC4xGgN49Lw4xiKLMzHwFgQEffl25EvXwOaD7FnMP97/T2u3Z36m +hoEyIwOdyPdfwUpgpZKpsaSgYMN4h7Mi8yrrW6ntBas3D7Hi05V2Y1Z0jFhyGzfl +ZKG+TQyTmAyX9odtsz/ny4Cm7YjHX1BiAuiZdBbQ5rQ58SfLyEDW44YQqSMSkuBp +QWOnryULwMWSyx6Yo1q6xTMPoJcB3X/ge9YGVM+h4k0460tQtcsm9MracEpqoeJ5 +quGnM/b9Sh/22WA= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDZjCCAk6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBEMQswCQYDVQQGEwJVUzEW +MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFs +IENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMTkwMzA0MDUwMDAwWjBEMQswCQYDVQQG +EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3Qg +R2xvYmFsIENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDvPE1A +PRDfO1MA4Wf+lGAVPoWI8YkNkMgoI5kF6CsgncbzYEbYwbLVjDHZ3CB5JIG/NTL8 +Y2nbsSpr7iFY8gjpeMtvy/wWUsiRxP89c96xPqfCfWbB9X5SJBri1WeR0IIQ13hL +TytCOb1kLUCgsBDTOEhGiKEMuzozKmKY+wCdE1l/bztyqu6mD4b5BWHqZ38MN5aL +5mkWRxHCJ1kDs6ZgwiFAVvqgx306E+PsV8ez1q6diYD3Aecs9pYrEw15LNnA5IZ7 +S4wMcoKK+xfNAGw6EzywhIdLFnopsk/bHdQL82Y3vdj2V7teJHq4PIu5+pIaGoSe +2HSPqht/XvT+RSIhAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FHE4NvICMVNHK266ZUapEBVYIAUJMB8GA1UdIwQYMBaAFHE4NvICMVNHK266ZUap +EBVYIAUJMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAQEAA/e1K6td +EPx7srJerJsOflN4WT5CBP51o62sgU7XAotexC3IUnbHLB/8gTKY0UvGkpMzNTEv +/NgdRN3ggX+d6YvhZJFiCzkIjKx0nVnZellSlxG5FntvRdOW2TF9AjYPnDtuzywN +A0ZF66D0f0hExghAzN4bcLUprbqLOzRldRtxIR0sFAqwlpW41uryZfspuk/qkZN0 +abby/+Ea0AzRdoXLiiW9l14sbxWZJue2Kf8i7MkCx1YAzUm5s2x7UwQa4qjJqhIF +I8LO57sEAszAR6LkxCkvW0VXiVHuPOtSCP8HNR6fNWpHSlaY0VqFH4z1Ir+rzoPz +4iIprn2DQKi6bA== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY +MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo +R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx +MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK +Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9 +AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA +ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0 +7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W +kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI +mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G +A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ +KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1 +6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl +4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K +oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj +UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU +AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW +MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVy +c2FsIENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYD +VQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1 +c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC +AQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0DE81 +WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUG +FF+3Qs17j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdq +XbboW0W63MOhBW9Wjo8QJqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxL +se4YuU6W3Nx2/zu+z18DwPw76L5GG//aQMJS9/7jOvdqdzXQ2o3rXhhqMcceujwb +KNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2WP0+GfPtDCapkzj4T8Fd +IgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP20gaXT73 +y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRt +hAAnZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgoc +QIgfksILAAX/8sgCSqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4 +Lt1ZrtmhN79UNdxzMk+MBB4zsslG8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAfBgNV +HSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8EBAMCAYYwDQYJ +KoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z +dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQ +L1EuxBRa3ugZ4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgr +Fg5fNuH8KrUwJM/gYwx7WBr+mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSo +ag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpqA1Ihn0CoZ1Dy81of398j9tx4TuaY +T1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz +GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m +1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV +OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH +6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX +QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW +MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy +c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE +BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0 +IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV +VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8 +cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT +QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh +F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v +c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w +mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd +VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX +teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ +f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfRe +Bi9Fi1jUIxaS5BZuKGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+ +nhutxx9z3SxPGWX9f5NAEC7S8O08ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB +/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY +MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG +9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc +aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX +IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn +ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z +uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN +Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja +QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW +koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9 +ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt +DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm +bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G +A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp +Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1 +MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG +A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL +v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8 +eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq +tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd +C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa +zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB +mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH +V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n +bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG +3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs +J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO +291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS +ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd +AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 +TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh +MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE +YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3 +MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo +ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg +MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN +ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA +PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w +wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi +EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY +avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+ +YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE +sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h +/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5 +IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD +ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy +OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P +TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER +dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf +ReYNnyicsbkqWletNw+vHX/bvZ8= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFSzCCBLSgAwIBAgIBaTANBgkqhkiG9w0BAQQFADCBmTELMAkGA1UEBhMCSFUx +ETAPBgNVBAcTCEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0 +b25zYWdpIEtmdC4xGjAYBgNVBAsTEVRhbnVzaXR2YW55a2lhZG9rMTIwMAYDVQQD +EylOZXRMb2NrIFV6bGV0aSAoQ2xhc3MgQikgVGFudXNpdHZhbnlraWFkbzAeFw05 +OTAyMjUxNDEwMjJaFw0xOTAyMjAxNDEwMjJaMIGZMQswCQYDVQQGEwJIVTERMA8G +A1UEBxMIQnVkYXBlc3QxJzAlBgNVBAoTHk5ldExvY2sgSGFsb3phdGJpenRvbnNh +Z2kgS2Z0LjEaMBgGA1UECxMRVGFudXNpdHZhbnlraWFkb2sxMjAwBgNVBAMTKU5l +dExvY2sgVXpsZXRpIChDbGFzcyBCKSBUYW51c2l0dmFueWtpYWRvMIGfMA0GCSqG +SIb3DQEBAQUAA4GNADCBiQKBgQCx6gTsIKAjwo84YM/HRrPVG/77uZmeBNwcf4xK +gZjupNTKihe5In+DCnVMm8Bp2GQ5o+2So/1bXHQawEfKOml2mrriRBf8TKPV/riX +iK+IA4kfpPIEPsgHC+b5sy96YhQJRhTKZPWLgLViqNhr1nGTLbO/CVRY7QbrqHvc +Q7GhaQIDAQABo4ICnzCCApswEgYDVR0TAQH/BAgwBgEB/wIBBDAOBgNVHQ8BAf8E +BAMCAAYwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1G +SUdZRUxFTSEgRXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFu +b3MgU3pvbGdhbHRhdGFzaSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBh +bGFwamFuIGtlc3p1bHQuIEEgaGl0ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExv +Y2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2VnLWJpenRvc2l0YXNhIHZlZGkuIEEgZGln +aXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUgYXogZWxvaXJ0 +IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFzIGxlaXJh +c2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGph +biBhIGh0dHBzOi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJo +ZXRvIGF6IGVsbGVub3J6ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBP +UlRBTlQhIFRoZSBpc3N1YW5jZSBhbmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmlj +YXRlIGlzIHN1YmplY3QgdG8gdGhlIE5ldExvY2sgQ1BTIGF2YWlsYWJsZSBhdCBo +dHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBjcHNA +bmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUAA4GBAATbrowXr/gOkDFOzT4JwG06 +sPgzTEdM43WIEJessDgVkcYplswhwG08pXTP2IKlOcNl40JwuyKQ433bNXbhoLXa +n3BukxowOR0w2y7jfLKRstE3Kfq51hdcR0/jHTjrn9V7lagonhVK0dHQKwCXoOKS +NitjrFgBazMpUIaD8QFI +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFTzCCBLigAwIBAgIBaDANBgkqhkiG9w0BAQQFADCBmzELMAkGA1UEBhMCSFUx +ETAPBgNVBAcTCEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0 +b25zYWdpIEtmdC4xGjAYBgNVBAsTEVRhbnVzaXR2YW55a2lhZG9rMTQwMgYDVQQD +EytOZXRMb2NrIEV4cHJlc3N6IChDbGFzcyBDKSBUYW51c2l0dmFueWtpYWRvMB4X +DTk5MDIyNTE0MDgxMVoXDTE5MDIyMDE0MDgxMVowgZsxCzAJBgNVBAYTAkhVMREw +DwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6dG9u +c2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE0MDIGA1UEAxMr +TmV0TG9jayBFeHByZXNzeiAoQ2xhc3MgQykgVGFudXNpdHZhbnlraWFkbzCBnzAN +BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA6+ywbGGKIyWvYCDj2Z/8kwvbXY2wobNA +OoLO/XXgeDIDhlqGlZHtU/qdQPzm6N3ZW3oDvV3zOwzDUXmbrVWg6dADEK8KuhRC +2VImESLH0iDMgqSaqf64gXadarfSNnU+sYYJ9m5tfk63euyucYT2BDMIJTLrdKwW +RMbkQJMdf60CAwEAAaOCAp8wggKbMBIGA1UdEwEB/wQIMAYBAf8CAQQwDgYDVR0P +AQH/BAQDAgAGMBEGCWCGSAGG+EIBAQQEAwIABzCCAmAGCWCGSAGG+EIBDQSCAlEW +ggJNRklHWUVMRU0hIEV6ZW4gdGFudXNpdHZhbnkgYSBOZXRMb2NrIEtmdC4gQWx0 +YWxhbm9zIFN6b2xnYWx0YXRhc2kgRmVsdGV0ZWxlaWJlbiBsZWlydCBlbGphcmFz +b2sgYWxhcGphbiBrZXN6dWx0LiBBIGhpdGVsZXNpdGVzIGZvbHlhbWF0YXQgYSBO +ZXRMb2NrIEtmdC4gdGVybWVrZmVsZWxvc3NlZy1iaXp0b3NpdGFzYSB2ZWRpLiBB +IGRpZ2l0YWxpcyBhbGFpcmFzIGVsZm9nYWRhc2FuYWsgZmVsdGV0ZWxlIGF6IGVs +b2lydCBlbGxlbm9yemVzaSBlbGphcmFzIG1lZ3RldGVsZS4gQXogZWxqYXJhcyBs +ZWlyYXNhIG1lZ3RhbGFsaGF0byBhIE5ldExvY2sgS2Z0LiBJbnRlcm5ldCBob25s +YXBqYW4gYSBodHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIGNpbWVuIHZhZ3kg +a2VyaGV0byBheiBlbGxlbm9yemVzQG5ldGxvY2submV0IGUtbWFpbCBjaW1lbi4g +SU1QT1JUQU5UISBUaGUgaXNzdWFuY2UgYW5kIHRoZSB1c2Ugb2YgdGhpcyBjZXJ0 +aWZpY2F0ZSBpcyBzdWJqZWN0IHRvIHRoZSBOZXRMb2NrIENQUyBhdmFpbGFibGUg +YXQgaHR0cHM6Ly93d3cubmV0bG9jay5uZXQvZG9jcyBvciBieSBlLW1haWwgYXQg +Y3BzQG5ldGxvY2submV0LjANBgkqhkiG9w0BAQQFAAOBgQAQrX/XDDKACtiG8XmY +ta3UzbM2xJZIwVzNmtkFLp++UOv0JhQQLdRmF/iewSf98e3ke0ugbLWrmldwpu2g +pO0u9f38vf5NNwgMvOOWgyL1SRt/Syu0VMGAfJlOHdCM7tCs5ZL6dVb+ZKATj7i4 +Fp1hBWeAyNDYpQcCNJgEjTME1A== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIGfTCCBWWgAwIBAgICAQMwDQYJKoZIhvcNAQEEBQAwga8xCzAJBgNVBAYTAkhV +MRAwDgYDVQQIEwdIdW5nYXJ5MREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMe +TmV0TG9jayBIYWxvemF0Yml6dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0 +dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9jayBLb3pqZWd5em9pIChDbGFzcyBB +KSBUYW51c2l0dmFueWtpYWRvMB4XDTk5MDIyNDIzMTQ0N1oXDTE5MDIxOTIzMTQ0 +N1owga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQIEwdIdW5nYXJ5MREwDwYDVQQHEwhC +dWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6dG9uc2FnaSBLZnQu +MRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9jayBL +b3pqZWd5em9pIChDbGFzcyBBKSBUYW51c2l0dmFueWtpYWRvMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvHSMD7tM9DceqQWC2ObhbHDqeLVu0ThEDaiD +zl3S1tWBxdRL51uUcCbbO51qTGL3cfNk1mE7PetzozfZz+qMkjvN9wfcZnSX9EUi +3fRc4L9t875lM+QVOr/bmJBVOMTtplVjC7B4BPTjbsE/jvxReB+SnoPC/tmwqcm8 +WgD/qaiYdPv2LD4VOQ22BFWoDpggQrOxJa1+mm9dU7GrDPzr4PN6s6iz/0b2Y6LY +Oph7tqyF/7AlT3Rj5xMHpQqPBffAZG9+pyeAlt7ULoZgx2srXnN7F+eRP2QM2Esi +NCubMvJIH5+hCoR64sKtlz2O1cH5VqNQ6ca0+pii7pXmKgOM3wIDAQABo4ICnzCC +ApswDgYDVR0PAQH/BAQDAgAGMBIGA1UdEwEB/wQIMAYBAf8CAQQwEQYJYIZIAYb4 +QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1GSUdZRUxFTSEgRXplbiB0 +YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pvbGdhbHRhdGFz +aSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQu +IEEgaGl0ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtm +ZWxlbG9zc2VnLWJpenRvc2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMg +ZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUgYXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVs +amFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFzIGxlaXJhc2EgbWVndGFsYWxoYXRv +IGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGphbiBhIGh0dHBzOi8vd3d3 +Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRvIGF6IGVsbGVub3J6 +ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRoZSBpc3N1 +YW5jZSBhbmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3Qg +dG8gdGhlIE5ldExvY2sgQ1BTIGF2YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRs +b2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBjcHNAbmV0bG9jay5uZXQuMA0G +CSqGSIb3DQEBBAUAA4IBAQBIJEb3ulZv+sgoA0BO5TE5ayZrU3/b39/zcT0mwBQO +xmd7I6gMc90Bu8bKbjc5VdXHjFYgDigKDtIqpLBJUsY4B/6+CgmM0ZjPytoUMaFP +0jn8DxEsQ8Pdq5PHVT5HfBgaANzze9jyf1JsIPQLX2lS9O74silg6+NJMSEN1rUQ +QeJBCWziGppWS3cC9qCbmieH6FUpccKQn0V4GuEVZD3QDtigdp+uxdAu6tYPVuxk +f1qbFFgBJ34TUMdrKuZoPL9coAob4Q566eKAw+np9v1sEZ7Q5SgnK1QyQhSCdeZK +8CtmdWOMovsEPoMOmzbwGOQmIMOM8CgHrTwXZoi1/baI +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIG0TCCBbmgAwIBAgIBezANBgkqhkiG9w0BAQUFADCByTELMAkGA1UEBhMCSFUx +ETAPBgNVBAcTCEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0 +b25zYWdpIEtmdC4xGjAYBgNVBAsTEVRhbnVzaXR2YW55a2lhZG9rMUIwQAYDVQQD +EzlOZXRMb2NrIE1pbm9zaXRldHQgS296amVneXpvaSAoQ2xhc3MgUUEpIFRhbnVz +aXR2YW55a2lhZG8xHjAcBgkqhkiG9w0BCQEWD2luZm9AbmV0bG9jay5odTAeFw0w +MzAzMzAwMTQ3MTFaFw0yMjEyMTUwMTQ3MTFaMIHJMQswCQYDVQQGEwJIVTERMA8G +A1UEBxMIQnVkYXBlc3QxJzAlBgNVBAoTHk5ldExvY2sgSGFsb3phdGJpenRvbnNh +Z2kgS2Z0LjEaMBgGA1UECxMRVGFudXNpdHZhbnlraWFkb2sxQjBABgNVBAMTOU5l +dExvY2sgTWlub3NpdGV0dCBLb3pqZWd5em9pIChDbGFzcyBRQSkgVGFudXNpdHZh +bnlraWFkbzEeMBwGCSqGSIb3DQEJARYPaW5mb0BuZXRsb2NrLmh1MIIBIjANBgkq +hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx1Ilstg91IRVCacbvWy5FPSKAtt2/Goq +eKvld/Bu4IwjZ9ulZJm53QE+b+8tmjwi8F3JV6BVQX/yQ15YglMxZc4e8ia6AFQe +r7C8HORSjKAyr7c3sVNnaHRnUPYtLmTeriZ539+Zhqurf4XsoPuAzPS4DB6TRWO5 +3Lhbm+1bOdRfYrCnjnxmOCyqsQhjF2d9zL2z8cM/z1A57dEZgxXbhxInlrfa6uWd +vLrqOU+L73Sa58XQ0uqGURzk/mQIKAR5BevKxXEOC++r6uwSEaEYBTJp0QwsGj0l +mT+1fMptsK6ZmfoIYOcZwvK9UdPM0wKswREMgM6r3JSda6M5UzrWhQIDAMV9o4IC +wDCCArwwEgYDVR0TAQH/BAgwBgEB/wIBBDAOBgNVHQ8BAf8EBAMCAQYwggJ1Bglg +hkgBhvhCAQ0EggJmFoICYkZJR1lFTEVNISBFemVuIHRhbnVzaXR2YW55IGEgTmV0 +TG9jayBLZnQuIE1pbm9zaXRldHQgU3pvbGdhbHRhdGFzaSBTemFiYWx5emF0YWJh +biBsZWlydCBlbGphcmFzb2sgYWxhcGphbiBrZXN6dWx0LiBBIG1pbm9zaXRldHQg +ZWxla3Ryb25pa3VzIGFsYWlyYXMgam9naGF0YXMgZXJ2ZW55ZXN1bGVzZW5laywg +dmFsYW1pbnQgZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUgYSBNaW5vc2l0ZXR0IFN6 +b2xnYWx0YXRhc2kgU3phYmFseXphdGJhbiwgYXogQWx0YWxhbm9zIFN6ZXJ6b2Rl +c2kgRmVsdGV0ZWxla2JlbiBlbG9pcnQgZWxsZW5vcnplc2kgZWxqYXJhcyBtZWd0 +ZXRlbGUuIEEgZG9rdW1lbnR1bW9rIG1lZ3RhbGFsaGF0b2sgYSBodHRwczovL3d3 +dy5uZXRsb2NrLmh1L2RvY3MvIGNpbWVuIHZhZ3kga2VyaGV0b2sgYXogaW5mb0Bu +ZXRsb2NrLm5ldCBlLW1haWwgY2ltZW4uIFdBUk5JTkchIFRoZSBpc3N1YW5jZSBh +bmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGFyZSBzdWJqZWN0IHRvIHRo +ZSBOZXRMb2NrIFF1YWxpZmllZCBDUFMgYXZhaWxhYmxlIGF0IGh0dHBzOi8vd3d3 +Lm5ldGxvY2suaHUvZG9jcy8gb3IgYnkgZS1tYWlsIGF0IGluZm9AbmV0bG9jay5u +ZXQwHQYDVR0OBBYEFAlqYhaSsFq7VQ7LdTI6MuWyIckoMA0GCSqGSIb3DQEBBQUA +A4IBAQCRalCc23iBmz+LQuM7/KbD7kPgz/PigDVJRXYC4uMvBcXxKufAQTPGtpvQ +MznNwNuhrWw3AkxYQTvyl5LGSKjN5Yo5iWH5Upfpvfb5lHTocQ68d4bDBsxafEp+ +NFAwLvt/MpqNPfMgW/hqyobzMUwsWYACff44yTB1HLdV47yfuqhthCgFdbOLDcCR +VCHnpgu0mfVRQdzNo0ci2ccBgcTcR08m6h/t280NmPSjnLRzMkqWmf68f8glWPhY +83ZmiVSkpj7EUFy6iRiCdUgh0k8T6GB+B3bbELVR5qq5aKrN9p2QdRLqOBrKROi3 +macqaJVmlaut74nLYKkGEsaUR+ko +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x +GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv +b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV +BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W +YWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCa +GMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6XJxg +Fyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55J +WpzmM+Yklvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bB +rrcCaoF6qUWD4gXmuVbBlDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp ++ARz8un+XJiM9XOva7R+zdRcAitMOeGylZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1 +ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt66/3FsvbzSUr5R/7mp/i +Ucw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1JdxnwQ5hYIiz +PtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og +/zOhD7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UH +oycR7hYQe7xFSkyyBNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuI +yV77zGHcizN300QyNQliBJIWENieJ0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1Ud +EwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBQahGK8SEwzJQTU7tD2 +A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGUa6FJpEcwRTEL +MAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT +ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2f +BluornFdLwUvZ+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzn +g/iN/Ae42l9NLmeyhP3ZRPx3UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2Bl +fF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodmVjB3pjd4M1IQWK4/YY7yarHvGH5K +WWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK+JDSV6IZUaUtl0Ha +B0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrWIozc +hLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPR +TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD +mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z +ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y +4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza +8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x +GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv +b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV +BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W +YWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM +V0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNggDhoB +4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUr +H556VOijKTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd +8lyyBTNvijbO0BNO/79KDDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9Cabwv +vWhDFlaJKjdhkf2mrk7AyxRllDdLkgbvBNDInIjbC3uBr7E9KsRlOni27tyAsdLT +mZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwpp5ijJUMv7/FfJuGITfhe +btfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8nT8KKdjc +T5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDt +WAEXMJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZ +c6tsgLjoC2SToJyMGf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A +4iLItLRkT9a6fUg+qGkM17uGcclzuD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYD +VR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHTBgkrBgEEAb5YAAMwgcUwgZMG +CCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmljYXRlIGNvbnN0 +aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0 +aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVu +dC4wLQYIKwYBBQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2Nw +czALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4G +A1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4ywLQoUmkRzBFMQswCQYDVQQGEwJC +TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UEAxMSUXVvVmFkaXMg +Um9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZVqyM0 +7ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSem +d1o417+shvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd ++LJ2w/w4E6oM3kJpK27zPOuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B +4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadN +t54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp8kokUvd0/bpO5qgdAm6x +DYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBCbjPsMZ57 +k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6s +zHXug/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0j +Wy10QJLZYxkNc91pvGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeT +mJlglFwjz1onl14LBQaTNx47aTbrqZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK +4SVhM7JZG+Ju1zdXtg2pEto= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBK +MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x +GTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkx +MjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3Qg +Q29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwgQ0EwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jxYDiJ +iQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa +/FHtaMbQbqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJ +jnIFHovdRIWCQtBJwB1g8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnI +HmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYVHDGA76oYa8J719rO+TMg1fW9ajMtgQT7 +sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi0XPnj3pDAgMBAAGjgZ0w +gZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCsw +KaAnoCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsG +AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L +URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO +H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm +I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY +iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc +f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI +MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x +FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz +MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv +cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz +Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO +0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao +wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj +7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS +8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT +BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB +/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg +JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGC +NxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt3 +6Z3q059c4EVlew3KW+JwULKUBRSuSceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/ +3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm +D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS +CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR +3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl +MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp +U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw +NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE +ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp +ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3 +DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf +8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN ++lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0 +X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa +K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA +1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G +A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR +zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0 +YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD +bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w +DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3 +L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D +eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl +xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp +VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY +WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIHyTCCBbGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEW +MBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwg +Q2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0NjM2WhcNMzYwOTE3MTk0NjM2WjB9 +MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMi +U2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3Rh +cnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA +A4ICDwAwggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZk +pMyONvg45iPwbm2xPN1yo4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rf +OQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/C +Ji/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/deMotHweXMAEtcnn6RtYT +Kqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt2PZE4XNi +HzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMM +Av+Z6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w ++2OqqGwaVLRcJXrJosmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+ +Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3 +Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVcUjyJthkqcwEKDwOzEmDyei+B +26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT37uMdBNSSwID +AQABo4ICUjCCAk4wDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAa4wHQYDVR0OBBYE +FE4L7xqkQFulF2mHMMo0aEPQQa7yMGQGA1UdHwRdMFswLKAqoCiGJmh0dHA6Ly9j +ZXJ0LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMCugKaAnhiVodHRwOi8vY3Js +LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMIIBXQYDVR0gBIIBVDCCAVAwggFM +BgsrBgEEAYG1NwEBATCCATswLwYIKwYBBQUHAgEWI2h0dHA6Ly9jZXJ0LnN0YXJ0 +Y29tLm9yZy9wb2xpY3kucGRmMDUGCCsGAQUFBwIBFilodHRwOi8vY2VydC5zdGFy +dGNvbS5vcmcvaW50ZXJtZWRpYXRlLnBkZjCB0AYIKwYBBQUHAgIwgcMwJxYgU3Rh +cnQgQ29tbWVyY2lhbCAoU3RhcnRDb20pIEx0ZC4wAwIBARqBl0xpbWl0ZWQgTGlh +YmlsaXR5LCByZWFkIHRoZSBzZWN0aW9uICpMZWdhbCBMaW1pdGF0aW9ucyogb2Yg +dGhlIFN0YXJ0Q29tIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFBvbGljeSBhdmFp +bGFibGUgYXQgaHR0cDovL2NlcnQuc3RhcnRjb20ub3JnL3BvbGljeS5wZGYwEQYJ +YIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilTdGFydENvbSBGcmVlIFNT +TCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAgEAFmyZ +9GYMNPXQhV59CuzaEE44HF7fpiUFS5Eyweg78T3dRAlbB0mKKctmArexmvclmAk8 +jhvh3TaHK0u7aNM5Zj2gJsfyOZEdUauCe37Vzlrk4gNXcGmXCPleWKYK34wGmkUW +FjgKXlf2Ysd6AgXmvB618p70qSmD+LIU424oh0TDkBreOKk8rENNZEXO3SipXPJz +ewT4F+irsfMuXGRuczE6Eri8sxHkfY+BUZo7jYn0TZNmezwD7dOaHZrzZVD1oNB1 +ny+v8OqCQ5j4aZyJecRDjkZy42Q2Eq/3JR44iZB3fsNrarnDy0RLrHiQi+fHLB5L +EUTINFInzQpdn4XBidUaePKVEFMy3YCEZnXZtWgo+2EuvoSoOMCZEoalHmdkrQYu +L6lwhceWD3yJZfWOQ1QOq92lgDmUYMA0yZZwLKMS9R9Ie70cfmu3nZD0Ijuu+Pwq +yvqCUqDvr0tVk+vBtfAii6w0TiYiBKGHLHVKt+V9E9e4DGTANtLJL4YSjCMJwRuC +O3NJo2pXh5Tl1njFmUNj403gdy3hZZlyaQQaRwnmDwFWJPsfvw55qVguucQJAX6V +um0ABj6y6koQOdjQK/W/7HW/lwLFCRsI3FU34oH7N4RDYiDK51ZLZer+bMEkkySh +NOsF/5oirpt9P/FlUQqmMGqz9IgcgA38corog14= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFFjCCBH+gAwIBAgIBADANBgkqhkiG9w0BAQQFADCBsDELMAkGA1UEBhMCSUwx +DzANBgNVBAgTBklzcmFlbDEOMAwGA1UEBxMFRWlsYXQxFjAUBgNVBAoTDVN0YXJ0 +Q29tIEx0ZC4xGjAYBgNVBAsTEUNBIEF1dGhvcml0eSBEZXAuMSkwJwYDVQQDEyBG +cmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYS +YWRtaW5Ac3RhcnRjb20ub3JnMB4XDTA1MDMxNzE3Mzc0OFoXDTM1MDMxMDE3Mzc0 +OFowgbAxCzAJBgNVBAYTAklMMQ8wDQYDVQQIEwZJc3JhZWwxDjAMBgNVBAcTBUVp +bGF0MRYwFAYDVQQKEw1TdGFydENvbSBMdGQuMRowGAYDVQQLExFDQSBBdXRob3Jp +dHkgRGVwLjEpMCcGA1UEAxMgRnJlZSBTU0wgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkxITAfBgkqhkiG9w0BCQEWEmFkbWluQHN0YXJ0Y29tLm9yZzCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEA7YRgACOeyEpRKSfeOqE5tWmrCbIvNP1h3D3TsM+x +18LEwrHkllbEvqoUDufMOlDIOmKdw6OsWXuO7lUaHEe+o5c5s7XvIywI6Nivcy+5 +yYPo7QAPyHWlLzRMGOh2iCNJitu27Wjaw7ViKUylS7eYtAkUEKD4/mJ2IhULpNYI +LzUCAwEAAaOCAjwwggI4MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgHmMB0G +A1UdDgQWBBQcicOWzL3+MtUNjIExtpidjShkjTCB3QYDVR0jBIHVMIHSgBQcicOW +zL3+MtUNjIExtpidjShkjaGBtqSBszCBsDELMAkGA1UEBhMCSUwxDzANBgNVBAgT +BklzcmFlbDEOMAwGA1UEBxMFRWlsYXQxFjAUBgNVBAoTDVN0YXJ0Q29tIEx0ZC4x +GjAYBgNVBAsTEUNBIEF1dGhvcml0eSBEZXAuMSkwJwYDVQQDEyBGcmVlIFNTTCBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSYWRtaW5Ac3Rh +cnRjb20ub3JnggEAMB0GA1UdEQQWMBSBEmFkbWluQHN0YXJ0Y29tLm9yZzAdBgNV +HRIEFjAUgRJhZG1pbkBzdGFydGNvbS5vcmcwEQYJYIZIAYb4QgEBBAQDAgAHMC8G +CWCGSAGG+EIBDQQiFiBGcmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAy +BglghkgBhvhCAQQEJRYjaHR0cDovL2NlcnQuc3RhcnRjb20ub3JnL2NhLWNybC5j +cmwwKAYJYIZIAYb4QgECBBsWGWh0dHA6Ly9jZXJ0LnN0YXJ0Y29tLm9yZy8wOQYJ +YIZIAYb4QgEIBCwWKmh0dHA6Ly9jZXJ0LnN0YXJ0Y29tLm9yZy9pbmRleC5waHA/ +YXBwPTExMTANBgkqhkiG9w0BAQQFAAOBgQBscSXhnjSRIe/bbL0BCFaPiNhBOlP1 +ct8nV0t2hPdopP7rPwl+KLhX6h/BquL/lp9JmeaylXOWxkjHXo0Hclb4g4+fd68p +00UOpO6wNnQt8M2YI3s3S9r+UZjEHjQ8iP2ZO1CnwYszx8JSFhKVU2Ui77qLzmLb +cCOxgN8aIDjnfg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIF2TCCA8GgAwIBAgIQXAuFXAvnWUHfV8w/f52oNjANBgkqhkiG9w0BAQUFADBk +MQswCQYDVQQGEwJjaDERMA8GA1UEChMIU3dpc3Njb20xJTAjBgNVBAsTHERpZ2l0 +YWwgQ2VydGlmaWNhdGUgU2VydmljZXMxGzAZBgNVBAMTElN3aXNzY29tIFJvb3Qg +Q0EgMTAeFw0wNTA4MTgxMjA2MjBaFw0yNTA4MTgyMjA2MjBaMGQxCzAJBgNVBAYT +AmNoMREwDwYDVQQKEwhTd2lzc2NvbTElMCMGA1UECxMcRGlnaXRhbCBDZXJ0aWZp +Y2F0ZSBTZXJ2aWNlczEbMBkGA1UEAxMSU3dpc3Njb20gUm9vdCBDQSAxMIICIjAN +BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0LmwqAzZuz8h+BvVM5OAFmUgdbI9 +m2BtRsiMMW8Xw/qabFbtPMWRV8PNq5ZJkCoZSx6jbVfd8StiKHVFXqrWW/oLJdih +FvkcxC7mlSpnzNApbjyFNDhhSbEAn9Y6cV9Nbc5fuankiX9qUvrKm/LcqfmdmUc/ +TilftKaNXXsLmREDA/7n29uj/x2lzZAeAR81sH8A25Bvxn570e56eqeqDFdvpG3F +EzuwpdntMhy0XmeLVNxzh+XTF3xmUHJd1BpYwdnP2IkCb6dJtDZd0KTeByy2dbco +kdaXvij1mB7qWybJvbCXc9qukSbraMH5ORXWZ0sKbU/Lz7DkQnGMU3nn7uHbHaBu +HYwadzVcFh4rUx80i9Fs/PJnB3r1re3WmquhsUvhzDdf/X/NTa64H5xD+SpYVUNF +vJbNcA78yeNmuk6NO4HLFWR7uZToXTNShXEuT46iBhFRyePLoW4xCGQMwtI89Tbo +19AOeCMgkckkKmUpWyL3Ic6DXqTz3kvTaI9GdVyDCW4pa8RwjPWd1yAv/0bSKzjC +L3UcPX7ape8eYIVpQtPM+GP+HkM5haa2Y0EQs3MevNP6yn0WR+Kn1dCjigoIlmJW +bjTb2QK5MHXjBNLnj8KwEUAKrNVxAmKLMb7dxiNYMUJDLXT5xp6mig/p/r+D5kNX +JLrvRjSq1xIBOO0CAwEAAaOBhjCBgzAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0hBBYw +FDASBgdghXQBUwABBgdghXQBUwABMBIGA1UdEwEB/wQIMAYBAf8CAQcwHwYDVR0j +BBgwFoAUAyUv3m+CATpcLNwroWm1Z9SM0/0wHQYDVR0OBBYEFAMlL95vggE6XCzc +K6FptWfUjNP9MA0GCSqGSIb3DQEBBQUAA4ICAQA1EMvspgQNDQ/NwNurqPKIlwzf +ky9NfEBWMXrrpA9gzXrzvsMnjgM+pN0S734edAY8PzHyHHuRMSG08NBsl9Tpl7Ik +Vh5WwzW9iAUPWxAaZOHHgjD5Mq2eUCzneAXQMbFamIp1TpBcahQq4FJHgmDmHtqB +sfsUC1rxn9KVuj7QG9YVHaO+htXbD8BJZLsuUBlL0iT43R4HVtA4oJVwIHaM190e +3p9xxCPvgxNcoyQVTSlAPGrEqdi3pkSlDfTgnXceQHAm/NrZNuR55LU/vJtlvrsR +ls/bxig5OgjOR1tTWsWZ/l2p3e9M1MalrQLmjAcSHm8D0W+go/MpvRLHUKKwf4ip +mXeascClOS5cfGniLLDqN2qk4Vrh9VDlg++luyqI54zb/W1elxmofmZ1a3Hqv7HH +b6D0jqTsNFFbjCYDcKF31QESVwA12yPeDooomf2xEG9L/zgtYE4snOtnta1J7ksf +rK/7DZBaZmBwXarNeNQk7shBoJMBkpxqnvy5JMWzFYJ+vq6VK+uxwNrjAWALXmms +hFZhvnEX/h0TD/7Gh0Xp/jKgGg0TpJRVcaUWi7rKibCyx/yP2FS1k2Kdzs9Z+z0Y +zirLNRWCXf9UIltxUvu3yf5gmwBBZPCqKuy2QkPOiWaByIufOVQDJdMWNY6E0F/6 +MBr1mmz0DlP5OlvRHA== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV +BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln +biBHb2xkIENBIC0gRzIwHhcNMDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBF +MQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMR8wHQYDVQQDExZT +d2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC +CgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUqt2/8 +76LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+ +bbqBHH5CjCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c +6bM8K8vzARO/Ws/BtQpgvd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqE +emA8atufK+ze3gE/bk3lUIbLtK/tREDFylqM2tIrfKjuvqblCqoOpd8FUrdVxyJd +MmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvRAiTysybUa9oEVeXBCsdt +MDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuendjIj3o02y +MszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69y +FGkOpeUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPi +aG59je883WX0XaxR7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxM +gI93e2CaHt+28kgeDrpOVG2Y4OGiGqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCB +qTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUWyV7 +lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64OfPAeGZe6Drn +8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov +L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe6 +45R88a7A3hfm5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczO +UYrHUDFu4Up+GC9pWbY9ZIEr44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5 +O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOfMke6UiI0HTJ6CVanfCU2qT1L2sCC +bwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6mGu6uLftIdxf+u+yv +GPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxpmo/a +77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC +hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3 +92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp +Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w +ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt +Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFwTCCA6mgAwIBAgIITrIAZwwDXU8wDQYJKoZIhvcNAQEFBQAwSTELMAkGA1UE +BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEjMCEGA1UEAxMaU3dpc3NTaWdu +IFBsYXRpbnVtIENBIC0gRzIwHhcNMDYxMDI1MDgzNjAwWhcNMzYxMDI1MDgzNjAw +WjBJMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMSMwIQYDVQQD +ExpTd2lzc1NpZ24gUGxhdGludW0gQ0EgLSBHMjCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAMrfogLi2vj8Bxax3mCq3pZcZB/HL37PZ/pEQtZ2Y5Wu669y +IIpFR4ZieIbWIDkm9K6j/SPnpZy1IiEZtzeTIsBQnIJ71NUERFzLtMKfkr4k2Htn +IuJpX+UFeNSH2XFwMyVTtIc7KZAoNppVRDBopIOXfw0enHb/FZ1glwCNioUD7IC+ +6ixuEFGSzH7VozPY1kneWCqv9hbrS3uQMpe5up1Y8fhXSQQeol0GcN1x2/ndi5ob +jM89o03Oy3z2u5yg+gnOI2Ky6Q0f4nIoj5+saCB9bzuohTEJfwvH6GXp43gOCWcw +izSC+13gzJ2BbWLuCB4ELE6b7P6pT1/9aXjvCR+htL/68++QHkwFix7qepF6w9fl ++zC8bBsQWJj3Gl/QKTIDE0ZNYWqFTFJ0LwYfexHihJfGmfNtf9dng34TaNhxKFrY +zt3oEBSa/m0jh26OWnA81Y0JAKeqvLAxN23IhBQeW71FYyBrS3SMvds6DsHPWhaP +pZjydomyExI7C3d3rLvlPClKknLKYRorXkzig3R3+jVIeoVNjZpTxN94ypeRSCtF +KwH3HBqi7Ri6Cr2D+m+8jVeTO9TUps4e8aCxzqv9KyiaTxvXw3LbpMS/XUz13XuW +ae5ogObnmLo2t/5u7Su9IPhlGdpVCX4l3P5hYnL5fhgC72O00Puv5TtjjGePAgMB +AAGjgawwgakwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O +BBYEFFCvzAeHFUdvOMW0ZdHelarp35zMMB8GA1UdIwQYMBaAFFCvzAeHFUdvOMW0 +ZdHelarp35zMMEYGA1UdIAQ/MD0wOwYJYIV0AVkBAQEBMC4wLAYIKwYBBQUHAgEW +IGh0dHA6Ly9yZXBvc2l0b3J5LnN3aXNzc2lnbi5jb20vMA0GCSqGSIb3DQEBBQUA +A4ICAQAIhab1Fgz8RBrBY+D5VUYI/HAcQiiWjrfFwUF1TglxeeVtlspLpYhg0DB0 +uMoI3LQwnkAHFmtllXcBrqS3NQuB2nEVqXQXOHtYyvkv+8Bldo1bAbl93oI9ZLi+ +FHSjClTTLJUYFzX1UWs/j6KWYTl4a0vlpqD4U99REJNi54Av4tHgvI42Rncz7Lj7 +jposiU0xEQ8mngS7twSNC/K5/FqdOxa3L8iYq/6KUFkuozv8KV2LwUvJ4ooTHbG/ +u0IdUt1O2BReEMYxB+9xJ/cbOQncguqLs5WGXv312l0xpuAxtpTmREl0xRbl9x8D +YSjFyMsSoEJL+WuICI20MhjzdZ/EfwBPBZWcoxcCw7NTm6ogOSkrZvqdr16zktK1 +puEa+S1BaYEUtLS17Yk9zvupnTVCRLEcFHOBzyoBNZox1S2PbYTfgE1X4z/FhHXa +icYwu+uPyyIIoK6q8QNsOktNCaUOcsZWayFCTiMlFGiudgp8DAdwZPmaL/YFOSbG +DI8Zf0NebvRbFS/bYV3mZy8/CJT5YLSYMdp08YSTcU1f+2BY0fvEwW2JorsgH51x +kcsymxM9Pn2SUjWskpSi0xjCfMfqr3YFFt1nJ8J+HAciIfNAChs0B0QTwoRqjt8Z +Wr9/6x3iGjjRXK9HkmuAtTClyY3YqzGBH9/CZjfTk6mFhnll0g== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE +BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWdu +IFNpbHZlciBDQSAtIEcyMB4XDTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0Nlow +RzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMY +U3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A +MIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644N0Mv +Fz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7br +YT7QbNHm+/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieF +nbAVlDLaYQ1HTWBCrpJH6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH +6ATK72oxh9TAtvmUcXtnZLi2kUpCe2UuMGoM9ZDulebyzYLs2aFK7PayS+VFheZt +eJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5hqAaEuSh6XzjZG6k4sIN/ +c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5FZGkECwJ +MoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRH +HTBsROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTf +jNFusB3hB48IHpmccelM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb6 +5i/4z3GcRm25xBWNOHkDRUjvxF3XCO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOB +rDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU +F6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRBtjpbO8tFnb0c +wpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0 +cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIB +AHPGgeAn0i0P4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShp +WJHckRE1qTodvBqlYJ7YH39FkWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9 +xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L3XWgwF15kIwb4FDm3jH+mHtwX6WQ +2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx/uNncqCxv1yL5PqZ +IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8 +aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X +em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR +dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/ +OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+ +hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy +tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/ +MQswCQYDVQQGEwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5MB4XDTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1ow +PzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dvdmVybm1lbnQgUm9vdCBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB +AJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qNw8XR +IePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1q +gQdW8or5BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKy +yhwOeYHWtXBiCAEuTk8O1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAts +F/tnyMKtsc2AtJfcdgEWFelq16TheEfOhtX7MfP6Mb40qij7cEwdScevLJ1tZqa2 +jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wovJ5pGfaENda1UhhXcSTvx +ls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7Q3hub/FC +VGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHK +YS1tB6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoH +EgKXTiCQ8P8NHuJBO9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThN +Xo+EHWbNxWCWtFJaBYmOlXqYwZE8lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1Ud +DgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNVHRMEBTADAQH/MDkGBGcqBwAE +MTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg209yewDL7MTqK +UWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ +TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyf +qzvS/3WXy6TjZwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaK +ZEk9GhiHkASfQlK3T8v+R0F2Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFE +JPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlUD7gsL0u8qV1bYH+Mh6XgUmMqvtg7 +hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6QzDxARvBMB1uUO07+1 +EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+HbkZ6Mm +nD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WX +udpVBrkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz +ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe +LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl +pYYsfPQS +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB +qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf +Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw +MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV +BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw +NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j +LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG +A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs +W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta +3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGcq/gcfomk +6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6 +Sk/KaAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J +NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA +MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP +r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU +DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz +YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX +xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2 +/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/ +LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7 +jVaMaA== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID+zCCAuOgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBtzE/MD0GA1UEAww2VMOc +UktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sx +c8SxMQswCQYDVQQGDAJUUjEPMA0GA1UEBwwGQU5LQVJBMVYwVAYDVQQKDE0oYykg +MjAwNSBUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8 +dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjAeFw0wNTA1MTMxMDI3MTdaFw0xNTAz +MjIxMDI3MTdaMIG3MT8wPQYDVQQDDDZUw5xSS1RSVVNUIEVsZWt0cm9uaWsgU2Vy +dGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLExCzAJBgNVBAYMAlRSMQ8wDQYD +VQQHDAZBTktBUkExVjBUBgNVBAoMTShjKSAyMDA1IFTDnFJLVFJVU1QgQmlsZ2kg +xLBsZXRpxZ9pbSB2ZSBCaWxpxZ9pbSBHw7x2ZW5sacSfaSBIaXptZXRsZXJpIEEu +xZ4uMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylIF1mMD2Bxf3dJ7 +XfIMYGFbazt0K3gNfUW9InTojAPBxhEqPZW8qZSwu5GXyGl8hMW0kWxsE2qkVa2k +heiVfrMArwDCBRj1cJ02i67L5BuBf5OI+2pVu32Fks66WJ/bMsW9Xe8iSi9BB35J +YbOG7E6mQW6EvAPs9TscyB/C7qju6hJKjRTP8wrgUDn5CDX4EVmt5yLqS8oUBt5C +urKZ8y1UiBAG6uEaPj1nH/vO+3yC6BFdSsG5FOpU2WabfIl9BJpiyelSPJ6c79L1 +JuTm5Rh8i27fbMx4W09ysstcP4wFjdFMjK2Sx+F4f2VsSQZQLJ4ywtdKxnWKWU51 +b0dewQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAV +9VX/N5aAWSGk/KEVTCD21F/aAyT8z5Aa9CEKmu46sWrv7/hg0Uw2ZkUd82YCdAR7 +kjCo3gp2D++Vbr3JN+YaDayJSFvMgzbC9UZcWYJWtNX+I7TYVBxEq8Sn5RTOPEFh +fEPmzcSBCYsk+1Ql1haolgxnB2+zUEfjHCQo3SqYpGH+2+oSN7wBGjSFvW5P55Fy +B0SFHljKVETd96y5y4khctuPwGkplyqjrhgjlxxBKot8KsF8kOipKMDTkcatKIdA +aLX/7KfS0zgYnNN9aV3wxqUeJBujR/xpB2jn5Jq07Q+hh4cCzofSSE7hvP/L8XKS +RGQDJereW26fyfJOrN3H +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEPDCCAySgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBvjE/MD0GA1UEAww2VMOc +UktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sx +c8SxMQswCQYDVQQGEwJUUjEPMA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xS +S1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kg +SGl6bWV0bGVyaSBBLsWeLiAoYykgS2FzxLFtIDIwMDUwHhcNMDUxMTA3MTAwNzU3 +WhcNMTUwOTE2MTAwNzU3WjCBvjE/MD0GA1UEAww2VMOcUktUUlVTVCBFbGVrdHJv +bmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJU +UjEPMA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSw +bGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWe +LiAoYykgS2FzxLFtIDIwMDUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCpNn7DkUNMwxmYCMjHWHtPFoylzkkBH3MOrHUTpvqeLCDe2JAOCtFp0if7qnef +J1Il4std2NiDUBd9irWCPwSOtNXwSadktx4uXyCcUHVPr+G1QRT0mJKIx+XlZEdh +R3n9wFHxwZnn3M5q+6+1ATDcRhzviuyV79z/rxAc653YsKpqhRgNF8k+v/Gb0AmJ +Qv2gQrSdiVFVKc8bcLyEVK3BEx+Y9C52YItdP5qtygy/p1Zbj3e41Z55SZI/4PGX +JHpsmxcPbe9TmJEr5A++WXkHeLuXlfSfadRYhwqp48y2WBmfJiGxxFmNskF1wK1p +zpwACPI2/z7woQ8arBT9pmAPAgMBAAGjQzBBMB0GA1UdDgQWBBTZN7NOBf3Zz58S +Fq62iS/rJTqIHDAPBgNVHQ8BAf8EBQMDBwYAMA8GA1UdEwEB/wQFMAMBAf8wDQYJ +KoZIhvcNAQEFBQADggEBAHJglrfJ3NgpXiOFX7KzLXb7iNcX/nttRbj2hWyfIvwq +ECLsqrkw9qtY1jkQMZkpAL2JZkH7dN6RwRgLn7Vhy506vvWolKMiVW4XSf/SKfE4 +Jl3vpao6+XF75tpYHdN0wgH6PmlYX63LaL4ULptswLbcoCb6dxriJNoaN+BnrdFz +gw2lGh1uEpJ+hGIAF728JRhX8tepb1mIvDS3LoV4nZbcFMMsilKbloxSZj2GFotH +uFEJjOp9zYhys2AzsfAKRO8P9Qk3iCQOLGsgOqL6EfJANZxEaGM7rDNvY7wsu/LS +y3Z9fYjYHcgFHW68lKlmjHdxx/qR+i9Rnuk5UrbnBEI= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL +ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp +U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW +ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL +MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW +ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp +U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y +aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1 +nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex +t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz +SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG +BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+ +rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/ +NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E +BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH +BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy +aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv +MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE +p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y +5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK +WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ +4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N +hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID5TCCAs2gAwIBAgIEOeSXnjANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UEBhMC +VVMxFDASBgNVBAoTC1dlbGxzIEZhcmdvMSwwKgYDVQQLEyNXZWxscyBGYXJnbyBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEvMC0GA1UEAxMmV2VsbHMgRmFyZ28gUm9v +dCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDAxMDExMTY0MTI4WhcNMjEwMTE0 +MTY0MTI4WjCBgjELMAkGA1UEBhMCVVMxFDASBgNVBAoTC1dlbGxzIEZhcmdvMSww +KgYDVQQLEyNXZWxscyBGYXJnbyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEvMC0G +A1UEAxMmV2VsbHMgRmFyZ28gUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVqDM7Jvk0/82bfuUER84A4n13 +5zHCLielTWi5MbqNQ1mXx3Oqfz1cQJ4F5aHiidlMuD+b+Qy0yGIZLEWukR5zcUHE +SxP9cMIlrCL1dQu3U+SlK93OvRw6esP3E48mVJwWa2uv+9iWsWCaSOAlIiR5NM4O +JgALTqv9i86C1y8IcGjBqAr5dE8Hq6T54oN+J3N0Prj5OEL8pahbSCOz6+MlsoCu +ltQKnMJ4msZoGK43YjdeUXWoWGPAUe5AeH6orxqg4bB4nVCMe+ez/I4jsNtlAHCE +AQgAFG5Uhpq6zPk3EPbg3oQtnaSFN9OH4xXQwReQfhkhahKpdv0SAulPIV4XAgMB +AAGjYTBfMA8GA1UdEwEB/wQFMAMBAf8wTAYDVR0gBEUwQzBBBgtghkgBhvt7hwcB +CzAyMDAGCCsGAQUFBwIBFiRodHRwOi8vd3d3LndlbGxzZmFyZ28uY29tL2NlcnRw +b2xpY3kwDQYJKoZIhvcNAQEFBQADggEBANIn3ZwKdyu7IvICtUpKkfnRLb7kuxpo +7w6kAOnu5+/u9vnldKTC2FJYxHT7zmu1Oyl5GFrvm+0fazbuSCUlFLZWohDo7qd/ +0D+j0MNdJu4HzMPBJCGHHt8qElNvQRbn7a6U+oxy+hNH8Dx+rn0ROhPs7fpvcmR7 +nX1/Jv16+yWt6j4pf0zjAFcysLPp7VMX2YuyFA4w6OXVE8Zkr8QA1dhYJPz1j+zx +x32l2w8n0cbyQIjmH/ZhqPRCyLk306m+LFZ4wnKbWV01QIroTmMatukgalHizqSQ +33ZwmVxwQ023tqcZZE6St8WRPH9IFmV7Fv3L/PvZ1dZPIWU7Sn9Ho/s= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB +gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk +MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY +UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx +NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3 +dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2Vy +dmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS6 +38eMpSe2OAtp87ZOqCwuIR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCP +KZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMxfoArtYzAQDsRhtDLooY2YKTVMIJt2W7Q +DxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FEzG+gSqmUsE3a56k0enI4 +qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqsAxcZZPRa +JSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNVi +PvryxS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0P +BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASs +jVy16bYbMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0 +eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQEwDQYJKoZIhvcNAQEFBQAD +ggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc/Kh4ZzXxHfAR +vbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt +qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLa +IR9NmXmd4c8nnxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSy +i6mx5O+aGtA9aZnuqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ +O+7ETPTsJ3xCwnR8gooJybQDJbw= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEc +MBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2Vj +IFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENB +IDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5MjM1OTAwWjBxMQswCQYDVQQGEwJE +RTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxl +U2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290 +IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEU +ha88EOQ5bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhC +QN/Po7qCWWqSG6wcmtoIKyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1Mjwr +rFDa1sPeg5TKqAyZMg4ISFZbavva4VhYAUlfckE8FQYBjl2tqriTtM2e66foai1S +NNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aKSe5TBY8ZTNXeWHmb0moc +QqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTVjlsB9WoH +txa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAP +BgNVHRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOC +AQEAlGRZrTlk5ynrE/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756Abrsp +tJh6sTtU6zkXR34ajgv8HzFZMQSyzhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpa +IzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8rZ7/gFnkm0W09juwzTkZmDLl +6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4Gdyd1Lx+4ivn+ +xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU +Cm26OWMohpLzGITY+9HPBVZkVw== +-----END CERTIFICATE----- + +-----BEGIN CERTIFICATE----- +MIIEFTCCA36gAwIBAgIBADANBgkqhkiG9w0BAQQFADCBvjELMAkGA1UEBhMCVVMx +EDAOBgNVBAgTB0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UE +ChMfU29mdHdhcmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9z +dG1hc3RlcjEgMB4GA1UEAxMXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxJTAjBgkq +hkiG9w0BCQEWFmhvc3RtYXN0ZXJAc3BpLWluYy5vcmcwHhcNMDMwMTE1MTYyOTE3 +WhcNMDcwMTE0MTYyOTE3WjCBvjELMAkGA1UEBhMCVVMxEDAOBgNVBAgTB0luZGlh +bmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UEChMfU29mdHdhcmUgaW4g +dGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9zdG1hc3RlcjEgMB4GA1UE +AxMXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxJTAjBgkqhkiG9w0BCQEWFmhvc3Rt +YXN0ZXJAc3BpLWluYy5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAPB6 +rdoiLR3RodtM22LMcfwfqb5OrJNl7fwmvskgF7yP6sdD2bOfDIXhg9852jhY8/kL +VOFe1ELAL2OyN4RAxk0rliZQVgeTgqvgkOVIBbNwgnjN6mqtuWzFiPL+NXQExq40 +I3whM+4lEiwSHaV+MYxWanMdhc+kImT50LKfkxcdAgMBAAGjggEfMIIBGzAdBgNV +HQ4EFgQUB63oQR1/vda/G4F6P4xLiN4E0vowgesGA1UdIwSB4zCB4IAUB63oQR1/ +vda/G4F6P4xLiN4E0vqhgcSkgcEwgb4xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdJ +bmRpYW5hMRUwEwYDVQQHEwxJbmRpYW5hcG9saXMxKDAmBgNVBAoTH1NvZnR3YXJl +IGluIHRoZSBQdWJsaWMgSW50ZXJlc3QxEzARBgNVBAsTCmhvc3RtYXN0ZXIxIDAe +BgNVBAMTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MSUwIwYJKoZIhvcNAQkBFhZo +b3N0bWFzdGVyQHNwaS1pbmMub3JnggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN +AQEEBQADgYEAm/Abn8c2y1nO3fgpAIslxvi9iNBZDhQtJ0VQZY6wgSfANyDOR4DW +iexO/AlorB49KnkFS7TjCAoLOZhcg5FaNiKnlstMI5krQmau1Qnb/vGSNsE/UGms +1ts+QYPUs0KmGEAFUri2XzLy+aQo9Kw74VBvqnxvaaMeY5yMcKNOieY= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIIDjCCBfagAwIBAgIJAOiOtsn4KhQoMA0GCSqGSIb3DQEBBQUAMIG8MQswCQYD +VQQGEwJVUzEQMA4GA1UECBMHSW5kaWFuYTEVMBMGA1UEBxMMSW5kaWFuYXBvbGlz +MSgwJgYDVQQKEx9Tb2Z0d2FyZSBpbiB0aGUgUHVibGljIEludGVyZXN0MRMwEQYD +VQQLEwpob3N0bWFzdGVyMR4wHAYDVQQDExVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkx +JTAjBgkqhkiG9w0BCQEWFmhvc3RtYXN0ZXJAc3BpLWluYy5vcmcwHhcNMDgwNTEz +MDgwNzU2WhcNMTgwNTExMDgwNzU2WjCBvDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UEChMfU29mdHdh +cmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9zdG1hc3RlcjEe +MBwGA1UEAxMVQ2VydGlmaWNhdGUgQXV0aG9yaXR5MSUwIwYJKoZIhvcNAQkBFhZo +b3N0bWFzdGVyQHNwaS1pbmMub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC +CgKCAgEA3DbmR0LCxFF1KYdAw9iOIQbSGE7r7yC9kDyFEBOMKVuUY/b0LfEGQpG5 +GcRCaQi/izZF6igFM0lIoCdDkzWKQdh4s/Dvs24t3dHLfer0dSbTPpA67tfnLAS1 +fOH1fMVO73e9XKKTM5LOfYFIz2u1IiwIg/3T1c87Lf21SZBb9q1NE8re06adU1Fx +Y0b4ShZcmO4tbZoWoXaQ4mBDmdaJ1mwuepiyCwMs43pPx93jzONKao15Uvr0wa8u +jyoIyxspgpJyQ7zOiKmqp4pRQ1WFmjcDeJPI8L20QcgHQprLNZd6ioFl3h1UCAHx +ZFy3FxpRvB7DWYd2GBaY7r/2Z4GLBjXFS21ZGcfSxki+bhQog0oQnBv1b7ypjvVp +/rLBVcznFMn5WxRTUQfqzj3kTygfPGEJ1zPSbqdu1McTCW9rXRTunYkbpWry9vjQ +co7qch8vNGopCsUK7BxAhRL3pqXTT63AhYxMfHMgzFMY8bJYTAH1v+pk1Vw5xc5s +zFNaVrpBDyXfa1C2x4qgvQLCxTtVpbJkIoRRKFauMe5e+wsWTUYFkYBE7axt8Feo ++uthSKDLG7Mfjs3FIXcDhB78rKNDCGOM7fkn77SwXWfWT+3Qiz5dW8mRvZYChD3F +TbxCP3T9PF2sXEg2XocxLxhsxGjuoYvJWdAY4wCAs1QnLpnwFVMCAwEAAaOCAg8w +ggILMB0GA1UdDgQWBBQ0cdE41xU2g0dr1zdkQjuOjVKdqzCB8QYDVR0jBIHpMIHm +gBQ0cdE41xU2g0dr1zdkQjuOjVKdq6GBwqSBvzCBvDELMAkGA1UEBhMCVVMxEDAO +BgNVBAgTB0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UEChMf +U29mdHdhcmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9zdG1h +c3RlcjEeMBwGA1UEAxMVQ2VydGlmaWNhdGUgQXV0aG9yaXR5MSUwIwYJKoZIhvcN +AQkBFhZob3N0bWFzdGVyQHNwaS1pbmMub3JnggkA6I62yfgqFCgwDwYDVR0TAQH/ +BAUwAwEB/zARBglghkgBhvhCAQEEBAMCAAcwCQYDVR0SBAIwADAuBglghkgBhvhC +AQ0EIRYfU29mdHdhcmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDAwBglghkgBhvhC +AQQEIxYhaHR0cHM6Ly9jYS5zcGktaW5jLm9yZy9jYS1jcmwucGVtMDIGCWCGSAGG ++EIBAwQlFiNodHRwczovL2NhLnNwaS1pbmMub3JnL2NlcnQtY3JsLnBlbTAhBgNV +HREEGjAYgRZob3N0bWFzdGVyQHNwaS1pbmMub3JnMA4GA1UdDwEB/wQEAwIBBjAN +BgkqhkiG9w0BAQUFAAOCAgEAtM294LnqsgMrfjLp3nI/yUuCXp3ir1UJogxU6M8Y +PCggHam7AwIvUjki+RfPrWeQswN/2BXja367m1YBrzXU2rnHZxeb1NUON7MgQS4M +AcRb+WU+wmHo0vBqlXDDxm/VNaSsWXLhid+hoJ0kvSl56WEq2dMeyUakCHhBknIP +qxR17QnwovBc78MKYiC3wihmrkwvLo9FYyaW8O4x5otVm6o6+YI5HYg84gd1GuEP +sTC8cTLSOv76oYnzQyzWcsR5pxVIBcDYLXIC48s9Fmq6ybgREOJJhcyWR2AFJS7v +dVkz9UcZFu/abF8HyKZQth3LZjQl/GaD68W2MEH4RkRiqMEMVObqTFoo5q7Gt/5/ +O5aoLu7HaD7dAD0prypjq1/uSSotxdz70cbT0ZdWUoa2lOvUYFG3/B6bzAKb1B+P ++UqPti4oOxfMxaYF49LTtcYDyeFIQpvLP+QX4P4NAZUJurgNceQJcHdC2E3hQqlg +g9cXiUPS1N2nGLar1CQlh7XU4vwuImm9rWgs/3K1mKoGnOcqarihk3bOsPN/nOHg +T7jYhkalMwIsJWE3KpLIrIF0aGOHM3a9BX9e1dUCbb2v/ypaqknsmHlHU5H2DjRa +yaXG67Ljxay2oHA1u8hRadDytaIybrw/oDc5fHE2pgXfDBLkFqfF1stjo5VwP+YE +o2A= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDvjCCA3ygAwIBAgIFJQaThoEwCwYHKoZIzjgEAwUAMIGFMQswCQYDVQQGEwJG +UjEPMA0GA1UECBMGRnJhbmNlMQ4wDAYDVQQHEwVQYXJpczEQMA4GA1UEChMHUE0v +U0dETjEOMAwGA1UECxMFRENTU0kxDjAMBgNVBAMTBUlHQy9BMSMwIQYJKoZIhvcN +AQkBFhRpZ2NhQHNnZG4ucG0uZ291di5mcjAeFw0wMjEyMTMxNDM5MTVaFw0yMDEw +MTcxNDM5MTRaMIGFMQswCQYDVQQGEwJGUjEPMA0GA1UECBMGRnJhbmNlMQ4wDAYD +VQQHEwVQYXJpczEQMA4GA1UEChMHUE0vU0dETjEOMAwGA1UECxMFRENTU0kxDjAM +BgNVBAMTBUlHQy9BMSMwIQYJKoZIhvcNAQkBFhRpZ2NhQHNnZG4ucG0uZ291di5m +cjCCAbYwggErBgcqhkjOOAQBMIIBHgKBgQCFkMImdk9zDzJfTO4XPdAAmLbAdWws +ZiEMZh19RyTo3CyhFqO77OIXrwY6vc1pcc3MgWJ0dgQpAgrDMtmFFxpUu4gmjVsx +8GpxQC+4VOgLY8Cvmcd/UDzYg07EIRto8BwCpPJ/JfUxwzV2V3N713aAX+cEoKZ/ +s+kgxC6nZCA7oQIVALME/JYjkdW2uKIGngsEPbXAjdhDAoGADh/uqWJx94UBm31c +9d8ZTBfRGRnmSSRVFDgPWgA69JD4BR5da8tKz+1HjfMhDXljbMH86ixpD5Ka1Z0V +pRYUPbyAoB37tsmXMJY7kjyD19d5VdaZboUjVvhH6UJy5lpNNNGSvFl4fqkxyvw+ +pq1QV0N5RcvK120hlXdfHUX+YKYDgYQAAoGAQGr7IuKJcYIvJRMjxwl43KxXY2xC +aoCiM/bv117MfI94aNf1UusGhp7CbYAY9CXuL60P0oPMAajbaTE5Z34AuITeHq3Y +CNMHwxalip8BHqSSGmGiQsXeK7T+r1rPXsccZ1c5ikGDZ4xn5gUaCyy2rCmb+fOJ +6VAfCbAbAjmNKwejdzB1MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgFGMBUG +A1UdIAQOMAwwCgYIKoF6AXkBAQEwHQYDVR0OBBYEFPkeNRcUf8idzpKblYbLNxs0 +MQhSMB8GA1UdIwQYMBaAFPkeNRcUf8idzpKblYbLNxs0MQhSMAsGByqGSM44BAMF +AAMvADAsAhRVh+CJA5eVyEYU5AO9Tm7GxX0rmQIUBCqsU5u1WxoZ5lEXicDX5/Ob +sRQ= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEAjCCAuqgAwIBAgIFORFFEJQwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYT +AkZSMQ8wDQYDVQQIEwZGcmFuY2UxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQ +TS9TR0ROMQ4wDAYDVQQLEwVEQ1NTSTEOMAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG +9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2LmZyMB4XDTAyMTIxMzE0MjkyM1oXDTIw +MTAxNzE0MjkyMlowgYUxCzAJBgNVBAYTAkZSMQ8wDQYDVQQIEwZGcmFuY2UxDjAM +BgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQTS9TR0ROMQ4wDAYDVQQLEwVEQ1NTSTEO +MAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2 +LmZyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsh/R0GLFMzvABIaI +s9z4iPf930Pfeo2aSVz2TqrMHLmh6yeJ8kbpO0px1R2OLc/mratjUMdUC24SyZA2 +xtgv2pGqaMVy/hcKshd+ebUyiHDKcMCWSo7kVc0dJ5S/znIq7Fz5cyD+vfcuiWe4 +u0dzEvfRNWk68gq5rv9GQkaiv6GFGvm/5P9JhfejcIYyHF2fYPepraX/z9E0+X1b +F8bc1g4oa8Ld8fUzaJ1O/Id8NhLWo4DoQw1VYZTqZDdH6nfK0LJYBcNdfrGoRpAx +Vs5wKpayMLh35nnAvSk7/ZR3TL0gzUEl4C7HG7vupARB0l2tEmqKm0f7yd1GQOGd +PDPQtQIDAQABo3cwdTAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBRjAVBgNV +HSAEDjAMMAoGCCqBegF5AQEBMB0GA1UdDgQWBBSjBS8YYFDCiQrdKyFP/45OqDAx +NjAfBgNVHSMEGDAWgBSjBS8YYFDCiQrdKyFP/45OqDAxNjANBgkqhkiG9w0BAQUF +AAOCAQEABdwm2Pp3FURo/C9mOnTgXeQp/wYHE4RKq89toB9RlPhJy3Q2FLwV3duJ +L92PoF189RLrn544pEfMs5bZvpwlqwN+Mw+VgQ39FuCIvjfwbF3QMZsyK10XZZOY +YLxuj7GoPB7ZHPOpJkL5ZB3C55L29B5aqhlSXa/oovdgoPaN8In1buAKBQGVyYsg +Crpa/JosPL3Dt8ldeCUFP1YUmwza+zpI/pdpXsoQhvdOlgQITeywvl3cO45Pwf2a +NjSaTFR+FwNIlQgRHAdvhQh+XU3Endv7rs6y0bO4g2wdsrN58dhwmX7wEwLOXt1R +0982gaEbeC9xs/FZTEYYKKuF0mBWWg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 +IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB +IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA +Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO +BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi +MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ +ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC +CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ +8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 +zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y +fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 +w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc +G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k +epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q +laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ +QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU +fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 +YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w +ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY +gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe +MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 +IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy +dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw +czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 +dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl +aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC +AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg +b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB +ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc +nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg +18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c +gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl +Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY +sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T +SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF +CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum +GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk +zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW +omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIGCDCCA/CgAwIBAgIBATANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 +IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB +IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA +Y2FjZXJ0Lm9yZzAeFw0wNTEwMTQwNzM2NTVaFw0zMzAzMjgwNzM2NTVaMFQxFDAS +BgNVBAoTC0NBY2VydCBJbmMuMR4wHAYDVQQLExVodHRwOi8vd3d3LkNBY2VydC5v +cmcxHDAaBgNVBAMTE0NBY2VydCBDbGFzcyAzIFJvb3QwggIiMA0GCSqGSIb3DQEB +AQUAA4ICDwAwggIKAoICAQCrSTURSHzSJn5TlM9Dqd0o10Iqi/OHeBlYfA+e2ol9 +4fvrcpANdKGWZKufoCSZc9riVXbHF3v1BKxGuMO+f2SNEGwk82GcwPKQ+lHm9WkB +Y8MPVuJKQs/iRIwlKKjFeQl9RrmK8+nzNCkIReQcn8uUBByBqBSzmGXEQ+xOgo0J +0b2qW42S0OzekMV/CsLj6+YxWl50PpczWejDAz1gM7/30W9HxM3uYoNSbi4ImqTZ +FRiRpoWSR7CuSOtttyHshRpocjWr//AQXcD0lKdq1TuSfkyQBX6TwSyLpI5idBVx +bgtxA+qvFTia1NIFcm+M+SvrWnIl+TlG43IbPgTDZCciECqKT1inA62+tC4T7V2q +SNfVfdQqe1z6RgRQ5MwOQluM7dvyz/yWk+DbETZUYjQ4jwxgmzuXVjit89Jbi6Bb +6k6WuHzX1aCGcEDTkSm3ojyt9Yy7zxqSiuQ0e8DYbF/pCsLDpyCaWt8sXVJcukfV +m+8kKHA4IC/VfynAskEDaJLM4JzMl0tF7zoQCqtwOpiVcK01seqFK6QcgCExqa5g +eoAmSAC4AcCTY1UikTxW56/bOiXzjzFU6iaLgVn5odFTEcV7nQP2dBHgbbEsPyyG +kZlxmqZ3izRg0RS0LKydr4wQ05/EavhvE/xzWfdmQnQeiuP43NJvmJzLR5iVQAX7 +6QIDAQABo4G/MIG8MA8GA1UdEwEB/wQFMAMBAf8wXQYIKwYBBQUHAQEEUTBPMCMG +CCsGAQUFBzABhhdodHRwOi8vb2NzcC5DQWNlcnQub3JnLzAoBggrBgEFBQcwAoYc +aHR0cDovL3d3dy5DQWNlcnQub3JnL2NhLmNydDBKBgNVHSAEQzBBMD8GCCsGAQQB +gZBKMDMwMQYIKwYBBQUHAgEWJWh0dHA6Ly93d3cuQ0FjZXJ0Lm9yZy9pbmRleC5w +aHA/aWQ9MTAwDQYJKoZIhvcNAQEEBQADggIBAH8IiKHaGlBJ2on7oQhy84r3HsQ6 +tHlbIDCxRd7CXdNlafHCXVRUPIVfuXtCkcKZ/RtRm6tGpaEQU55tiKxzbiwzpvD0 +nuB1wT6IRanhZkP+VlrRekF490DaSjrxC1uluxYG5sLnk7mFTZdPsR44Q4Dvmw2M +77inYACHV30eRBzLI++bPJmdr7UpHEV5FpZNJ23xHGzDwlVks7wU4vOkHx4y/CcV +Bc/dLq4+gmF78CEQGPZE6lM5+dzQmiDgxrvgu1pPxJnIB721vaLbLmINQjRBvP+L +ivVRIqqIMADisNS8vmW61QNXeZvo3MhN+FDtkaVSKKKs+zZYPumUK5FQhxvWXtaM +zPcPEAxSTtAWYeXlCmy/F8dyRlecmPVsYGN6b165Ti/Iubm7aoW8mA3t+T6XhDSU +rgCvoeXnkm5OvfPi2RSLXNLrAWygF6UtEOucekq9ve7O/e0iQKtwOIj1CodqwqsF +YMlIBdpTwd5Ed2qz8zw87YC8pjhKKSRf/lk7myV6VmMAZLldpGJ9VzZPrYPvH5JT +oI53V93lYRE9IwCQTDz6o2CTBKOvNfYOao9PSmCnhQVsRqGP9Md246FZV/dxssRu +FFxtbUFm3xuTsdQAw+7Lzzw9IYCpX2Nl/N3gX6T0K/CFcUHUZyX7GrGXrtaZghNB +0m6lG5kngOcLqagA +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL +MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE +BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT +IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw +MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy +ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N +T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR +FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J +cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW +BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm +fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv +GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFijCCA3KgAwIBAgIQDHbanJEMTiye/hXQWJM8TDANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp +Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww +HhcNMDcwNTE2MTcxOTM2WhcNMjUwMzMxMTgxOTIxWjBfMQswCQYDVQQGEwJOTDES +MBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdpTm90YXIgUm9vdCBDQTEg +MB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmwwggIiMA0GCSqGSIb3DQEB +AQUAA4ICDwAwggIKAoICAQCssFjBAL3YIQgLK5r+blYwBZ8bd5AQQVzDDYcRd46B +8cp86Yxq7Th0Nbva3/m7wAk3tJZzgX0zGpg595NvlX89ubF1h7pRSOiLcD6VBMXY +tsMW2YiwsYcdcNqGtA8Ui3rPENF0NqISe3eGSnnme98CEWilToauNFibJBN4ViIl +HgGLS1Fx+4LMWZZpiFpoU8W5DQI3y0u8ZkqQfioLBQftFl9VkHXYRskbg+IIvvEj +zJkd1ioPgyAVWCeCLvriIsJJsbkBgWqdbZ1Ad2h2TiEqbYRAhU52mXyC8/O3AlnU +JgEbjt+tUwbRrhjd4rI6y9eIOI6sWym5GdOY+RgDz0iChmYLG2kPyes4iHomGgVM +ktck1JbyrFIto0fVUvY//s6EBnCmqj6i8rZWNBhXouSBbefK8GrTx5FrAoNBfBXv +a5pkXuPQPOWx63tdhvvL5ndJzaNl3Pe5nLjkC1+Tz8wwGjIczhxjlaX56uF0i57p +K6kwe6AYHw4YC+VbqdPRbB4HZ4+RS6mKvNJmqpMBiLKR+jFc1abBUggJzQpjotMi +puih2TkGl/VujQKQjBR7P4DNG5y6xFhyI6+2Vp/GekIzKQc/gsnmHwUNzUwoNovT +yD4cxojvXu6JZOkd69qJfjKmadHdzIif0dDJZiHcBmfFlHqabWJMfczgZICynkeO +owIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV +HQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wDQYJKoZIhvcNAQEFBQADggIBADsC +jcs8MOhuoK3yc7NfniUTBAXT9uOLuwt5zlPe5JbF0a9zvNXD0EBVfEB/zRtfCdXy +fJ9oHbtdzno5wozWmHvFg1Wo1X1AyuAe94leY12hE8JdiraKfADzI8PthV9xdvBo +Y6pFITlIYXg23PFDk9Qlx/KAZeFTAnVR/Ho67zerhChXDNjU1JlWbOOi/lmEtDHo +M/hklJRRl6s5xUvt2t2AC298KQ3EjopyDedTFLJgQT2EkTFoPSdE2+Xe9PpjRchM +Ppj1P0G6Tss3DbpmmPHdy59c91Q2gmssvBNhl0L4eLvMyKKfyvBovWsdst+Nbwed +2o5nx0ceyrm/KkKRt2NTZvFCo+H0Wk1Ya7XkpDOtXHAd3ODy63MUkZoDweoAZbwH +/M8SESIsrqC9OuCiKthZ6SnTGDWkrBFfGbW1G/8iSlzGeuQX7yCpp/Q/rYqnmgQl +nQ7KN+ZQ/YxCKQSa7LnPS3K94gg2ryMvYuXKAdNw23yCIywWMQzGNgeQerEfZ1jE +O1hZibCMjFCz2IbLaKPECudpSyDOwR5WS5WpI2jYMNjD67BVUc3l/Su49bsRn1NU +9jQZjHkJNsphFyUXC4KYcwx3dMPVDceoEkzHp1RxRy4sGn3J4ys7SN4nhKdjNrN9 +j6BkOSQNPXuHr2ZcdBtLc7LljPCGmbjlxd+Ewbfr +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi +MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu +MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp +dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJV +UzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydO +ZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwz +c7MEL7xxjOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPP +OCwGJgl6cvf6UDL4wpPTaaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rl +mGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXTcrA/vGp97Eh/jcOrqnErU2lBUzS1sLnF +BgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc/Qzpf14Dl847ABSHJ3A4 +qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMBAAGjgZcw +gZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIB +BjAPBgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwu +bmV0c29sc3NsLmNvbS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3Jp +dHkuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc8 +6fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q4LqILPxFzBiwmZVRDuwduIj/ +h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/GGUsyfJj4akH +/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv +wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN +pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCVVMx +IDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxs +cyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9v +dCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDcxMjEzMTcwNzU0WhcNMjIxMjE0 +MDAwNzU0WjCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdl +bGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQD +DC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDub7S9eeKPCCGeOARBJe+r +WxxTkqxtnt3CxC5FlAM1iGd0V+PfjLindo8796jE2yljDpFoNoqXjopxaAkH5OjU +Dk/41itMpBb570OYj7OeUt9tkTmPOL13i0Nj67eT/DBMHAGTthP796EfvyXhdDcs +HqRePGj4S78NuR4uNuip5Kf4D8uCdXw1LSLWwr8L87T8bJVhHlfXBIEyg1J55oNj +z7fLY4sR4r1e6/aN7ZVyKLSsEmLpSjPmgzKuBXWVvYSV2ypcm44uDLiBK0HmOFaf +SZtsdvqKXfcBeYF8wYNABf5x/Qw/zE5gCQ5lRxAvAcAFP4/4s0HvWkJ+We/Slwxl +AgMBAAGjggE0MIIBMDAPBgNVHRMBAf8EBTADAQH/MDkGA1UdHwQyMDAwLqAsoCqG +KGh0dHA6Ly9jcmwucGtpLndlbGxzZmFyZ28uY29tL3dzcHJjYS5jcmwwDgYDVR0P +AQH/BAQDAgHGMB0GA1UdDgQWBBQmlRkQ2eihl5H/3BnZtQQ+0nMKajCBsgYDVR0j +BIGqMIGngBQmlRkQ2eihl5H/3BnZtQQ+0nMKaqGBi6SBiDCBhTELMAkGA1UEBhMC +VVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNX +ZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMg +Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCAQEwDQYJKoZIhvcNAQEFBQADggEB +ALkVsUSRzCPIK0134/iaeycNzXK7mQDKfGYZUMbVmO2rvwNa5U3lHshPcZeG1eMd +/ZDJPHV3V3p9+N701NX3leZ0bh08rnyd2wIDBSxxSyU+B+NemvVmFymIGjifz6pB +A4SXa5M4esowRBskRDPQ5NHcKDj0E0M1NSljqHyita04pO2t/caaH/+Xc/77szWn +k4bGdpEA5qxRFsQnMlzbc9qlk1eOPm01JghZ1edE13YgY+esE2fDbbFwRnzVlhE9 +iW9dqKHrjQrawx0zbKPqZxmamX9LPYNRKh3KL4YMon4QLSvUFpULB6ouFJJJtylv +2G0xffX8oRAHh84vWdw+WNs= +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt b/user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt new file mode 100644 index 0000000..453bafa --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFXTCCBEWgAwIBAgIQRKGXkBbin0Hge3vNu4Z04TANBgkqhkiG9w0BAQsFADCB +kDELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G +A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxNjA0BgNV +BAMTLUNPTU9ETyBSU0EgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD +QTAeFw0xNDExMTIwMDAwMDBaFw0xNzExMTEyMzU5NTlaMFcxITAfBgNVBAsTGERv +bWFpbiBDb250cm9sIFZhbGlkYXRlZDEUMBIGA1UECxMLUG9zaXRpdmVTU0wxHDAa +BgNVBAMTE2NhbXN0ZXIuZHVja2Rucy5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IB +DwAwggEKAoIBAQCvKi9/3GOq1pqgnIQR2hTxr1kv17pUzpQeAVOZVCd/q6KbMrsw +ayPj41hJd+EVtu6DV8Zd/Rxv4P6i2HTRWev9aE2+vFfTmhIZG0HUZqs3Fbq6yONn +ox8d7Dsu/vwIkyaIE9mMAYYr81bX86v8cmvCHatCO/lluwUqjnXUjYpMOpTopHjC +hNzUe63ZtUDVmXfTBHneO5GLZqhQSSX7rd33cJzkojGCoPSFP5TUhN5WGyRi+xa2 +bD+Q5xXlC4f/WVXiZxGiGPrWIpQBO5Y5o33S6Vo2ck9Bvg2g1atsR02m+yARtmH3 ++IDlvg7DeyLL3AXgUwDNHnRb0t9LVDXcYOJnAgMBAAGjggHpMIIB5TAfBgNVHSME +GDAWgBSQr2o6lFoL2JDqElZz30O0Oija5zAdBgNVHQ4EFgQUGNRX8FYKZUYa1F4+ +L7nyHOn3ArcwDgYDVR0PAQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYw +FAYIKwYBBQUHAwEGCCsGAQUFBwMCME8GA1UdIARIMEYwOgYLKwYBBAGyMQECAgcw +KzApBggrBgEFBQcCARYdaHR0cHM6Ly9zZWN1cmUuY29tb2RvLmNvbS9DUFMwCAYG +Z4EMAQIBMFQGA1UdHwRNMEswSaBHoEWGQ2h0dHA6Ly9jcmwuY29tb2RvY2EuY29t +L0NPTU9ET1JTQURvbWFpblZhbGlkYXRpb25TZWN1cmVTZXJ2ZXJDQS5jcmwwgYUG +CCsGAQUFBwEBBHkwdzBPBggrBgEFBQcwAoZDaHR0cDovL2NydC5jb21vZG9jYS5j +b20vQ09NT0RPUlNBRG9tYWluVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAk +BggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMDcGA1UdEQQwMC6C +E2NhbXN0ZXIuZHVja2Rucy5vcmeCF3d3dy5jYW1zdGVyLmR1Y2tkbnMub3JnMA0G +CSqGSIb3DQEBCwUAA4IBAQBpfJIXHPyoxbXlS1Jy5V4oDpDR+vKRIXXUPDp6GlmK +6w8W7M536W7JamLrT8wbA04hKgtjQkXD8pXZPFHBNJ92Lza5fKB/KiIlObz386lK +Z9AVc10TwWlkZlFYhYVhQ+kpTtcUUdj5QI2org81s9XQoSViVOM8cxIuYk/er20g +jY3Nvdbjg4dtakH1nsITGMYLN+wJglSAq1QGSQ76fLyYhMfF25nNjPYP96SFf1Dd +XinknP2tED6ukzIgfkimlyn2/XIbnz4Xry8ouq4x/cPd8MOcffWt1QWlGIel5B8i +I1vtVHceHSsHjnnNPSkXIn0/lpc5vzVZ+bw9yLt+Lvc6 +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/comodo.sha384.cer b/user/mpy/lib/axtls/ssl/test/comodo.sha384.cer new file mode 100644 index 0000000..b52ea61 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/comodo.sha384.cer @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv +MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk +ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF +eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow +gYUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMSswKQYD +VQQDEyJDT01PRE8gUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkq +hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkehUktIKVrGsDSTdxc9EZ3SZKzejfSNw +AHG8U9/E+ioSj0t/EFa9n3Byt2F/yUsPF6c947AEYe7/EZfH9IY+Cvo+XPmT5jR6 +2RRr55yzhaCCenavcZDX7P0N+pxs+t+wgvQUfvm+xKYvT3+Zf7X8Z0NyvQwA1onr +ayzT7Y+YHBSrfuXjbvzYqOSSJNpDa2K4Vf3qwbxstovzDo2a5JtsaZn4eEgwRdWt +4Q08RWD8MpZRJ7xnw8outmvqRsfHIKCxH2XeSAi6pE6p8oNGN4Tr6MyBSENnTnIq +m1y9TBsoilwie7SrmNnu4FGDwwlGTm0+mfqVF9p8M1dBPI1R7Qu2XK8sYxrfV8g/ +vOldxJuvRZnio1oktLqpVj3Pb6r/SVi+8Kj/9Lit6Tf7urj0Czr56ENCHonYhMsT +8dm74YlguIwoVqwUHZwK53Hrzw7dPamWoUi9PPevtQ0iTMARgexWO/bTouJbt7IE +IlKVgJNp6I5MZfGRAy1wdALqi2cVKWlSArvX31BqVUa/oKMoYX9w0MOiqiwhqkfO +KJwGRXa/ghgntNWutMtQ5mv0TIZxMOmm3xaG4Nj/QN370EKIf6MzOi5cHkERgWPO +GHFrK+ymircxXDpqR+DDeVnWIBqv8mqYqnK8V0rSS527EPywTEHl7R09XiidnMy/ +s1Hap0flhFMCAwEAAaOB9DCB8TAfBgNVHSMEGDAWgBStvZh6NLQm9/rEJlTvA73g +JMtUGjAdBgNVHQ4EFgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQD +AgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAGBgRVHSAAMEQGA1UdHwQ9 +MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9BZGRUcnVzdEV4dGVy +bmFsQ0FSb290LmNybDA1BggrBgEFBQcBAQQpMCcwJQYIKwYBBQUHMAGGGWh0dHA6 +Ly9vY3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggEBAGS/g/FfmoXQ +zbihKVcN6Fr30ek+8nYEbvFScLsePP9NDXRqzIGCJdPDoCpdTPW6i6FtxFQJdcfj +Jw5dhHk3QBN39bSsHNA7qxcS1u80GH4r6XnTq1dFDK8o+tDb5VCViLvfhVdpfZLY +Uspzgb8c8+a4bmYRBbMelC1/kZWSWfFMzqORcUx8Rww7Cxn2obFshj5cqsQugsv5 +B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx +PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR +pu/xO28QOG8= +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/deutsche_telecom.x509_ca b/user/mpy/lib/axtls/ssl/test/deutsche_telecom.x509_ca new file mode 100644 index 0000000000000000000000000000000000000000..0f4b96a0d5b66ac34b258e34a8943630d55feacc GIT binary patch literal 670 zcmXqLVwz>p#KgRSnTe5!iBZLXmyJ`a&7xk*W}qnv{YLwX`%aH?TA`G&V6Xh!W>D1apmyO)Y`kfpAje zeB^LpWMyD(>}4=$>||7N?y$<5%!OzF zERzTg``9Ao-X*XBQfdA{s)V1MQHyO zWy#)aHLqswC)*oOrXGIdcj#m4Y98-5?oH8;9tM=&_?EauBId2}0<I-~KIoDw&uW z85kEk890CgUzU$Wj73Dm@KODoQ$kaJe=JbA?W-YN=#+TOfFBt2vcfDJ25gLs|CtzB z4fsF;{6G#13o!QCki7_udS;;C=E@5EntVbwMZq<0PCjey;-LEFE80^xr_VBLt0)o^ z{eRuHSc9>xWA4OP_pWJj^Vlt(S>nKR=8eFEls^UAc3BFke~M!W*vfs)>;B68FPk|v z8vb08JMyN$t<~qA>juWD7Hh=jyLr9SJ-zpI>PD-l%e+~<`HcU|RG(;Raeo+<;^qYa DuXy4z literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/equifax.x509_ca b/user/mpy/lib/axtls/ssl/test/equifax.x509_ca new file mode 100644 index 0000000000000000000000000000000000000000..79b0a3f98764a07fdf6cae1a80eebf704d1f8796 GIT binary patch literal 646 zcmXqLVrnvIVtl=TnTe5!iIK&CmyJ`a&7A-4f18*?ZNn=n&ou%V2B z6o|tmEbLlXnwgeZp%9#!Tw0W>;F*`KXQ*bN0+MAGmPM0Ibt)~+%u6jUR&aLIH8hYD z=e4vnFf%eVFfjmvC~;mR10*hOENz^R>^DYM2Ij_I27|^_GV!Yaq78vdHv|ahSG);D}~qW z>v(UKw>nj0}v6(+pA!1lc$f+B_KBemDWcpM{x;f!%-~7^bqq zjEw(TSPhtglz}`*K$%6tK&(N;tHLNq@OGq_S={}DB4!R*?lnFO4P-$I_*lePuuG#x zF*DHrrO_*9GYdX@8Rm2L=SrUgyt6)^NzHtwT6QLK`?Zk6vS(+mk-WR5_38uLKS>J9 zTf8GuKR)_7Rnh+ImAVKy_x2FGh=p6X{?K|~_^nW3?Pk)dG}kZXa&H83}nHjo5q@oeRF+y~C}AK5 zF_#}?pk8`jX-Q78UVc%!LE{``H!w0c_AnSUb}%(IT;CP5elgDny_M==tAhJhysmF7 z^~s*G&+FB8xgXw#vyR;2W!Uk`M_ArWZ1TOL_s5pRZOYqrimM~Ebi%Z^%fk2YSeNlm zm)raDP5tGSZ+^F?EXZEqajv|sc#fg)f7=u5mL}xg+}0B{D}UR*`B{6He^_9w{&lI0t~bUk(V|yzt>L6d&agTOlQ%<1HtMiK21dqF;?crMuy~AZ)cCC zcar#4F@K*Wyr$(`=edOf)X_qG#W2@k=EugP0m@R{;Q^*WZi) literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/header_issue.dat b/user/mpy/lib/axtls/ssl/test/header_issue.dat new file mode 100755 index 0000000000000000000000000000000000000000..a48d23d2b937820a533bc1394d6c155fd28c1959 GIT binary patch literal 1159 zcmWe*W@Kq%Vqj2XW^_B{aBjXp>E)wm*3`MA7YKbx?VUNb&ow+D@R^CtrU!`(45kd+ z3@iZ*EWQj(j0R1Ne}Q;86SDvVivceir&gOs+jm|@Mpjk^gU02C@&>YO%%Ln?!eYS% znMJ92B?`{@xw)lznaPPInfZCehI|G*AO+mQtO1U?;Q@xK2Fh?lI2pynic1R$@{39w ziXqyQ^K_r&^DUdsvg@wz@%k`ix z(#=UO2Kme&200WNSs9qU84Ns_92wpo`5|5!qql9!X6NU%!l&1>n0uS&D5^(1N_N=q zT3#1Xo$~t3DZM?rcUCRjoTpWPC&fDJUdopHOj#EUEFSSFWs-_7#%qy;W$R;IY>2#oGL(LO(Mop($Bszg1H5j-<7 zYyB}vW~D>tw?BFLXek4en?Vzk6EF?DVd7-C`OWT+eQSgcnmt1@C72qS8d)Mz0)#t+ ze1a<>?d5STc=(BH&V_n5t}ZuuwkKi#Kd5eDJK@OGejq5*ct+H>r89oKDBiP7sKoTQ zuBR~j#nTEypxQCB{fdK$z?p#a& literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/killgnutls.sh b/user/mpy/lib/axtls/ssl/test/killgnutls.sh new file mode 100755 index 0000000..f910f4b --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/killgnutls.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ps -ef|grep gnutls-serv | /usr/bin/awk '{print $2}' |xargs kill -9 diff --git a/user/mpy/lib/axtls/ssl/test/killopenssl.sh b/user/mpy/lib/axtls/ssl/test/killopenssl.sh new file mode 100755 index 0000000..17950fb --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/killopenssl.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ps -ef|grep openssl | /usr/bin/awk '{print $2}' |xargs kill -9 diff --git a/user/mpy/lib/axtls/ssl/test/make_certs.sh b/user/mpy/lib/axtls/ssl/test/make_certs.sh new file mode 100755 index 0000000..f234b3f --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/make_certs.sh @@ -0,0 +1,253 @@ +#!/bin/sh + +# +# Copyright (c) 2007-2016, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# Generate the certificates and keys for testing. +# + +PROJECT_NAME="axTLS Project" + +# Generate the openssl configuration files. +cat > ca_cert.conf << EOF +[ req ] +distinguished_name = req_distinguished_name +prompt = no +req_extensions = v3_ca + +[ req_distinguished_name ] + O = $PROJECT_NAME Dodgy Certificate Authority + +[ v3_ca ] +basicConstraints = critical, CA:true +keyUsage = critical, cRLSign, keyCertSign, digitalSignature +EOF + +cat > certs.conf << EOF +[ req ] +distinguished_name = req_distinguished_name +prompt = no +req_extensions = v3_usr_cert + +[ req_distinguished_name ] + O = $PROJECT_NAME + CN = localhost + +[ v3_usr_cert ] +basicConstraints = critical, CA:false +keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment +subjectAltName = @alt_names + +[alt_names] +DNS.1 = www.example.net +DNS.2 = www.example.org +EOF + +cat > device_cert.conf << EOF +[ req ] +distinguished_name = req_distinguished_name +prompt = no + +[ req_distinguished_name ] + O = $PROJECT_NAME Device Certificate +EOF + +cat > intermediate_ca.conf << EOF +[ req ] +distinguished_name = req_distinguished_name +prompt = no +req_extensions = v3_intermediate_ca + +[ req_distinguished_name ] + O = $PROJECT_NAME Intermediate CA + +[ v3_intermediate_ca ] +basicConstraints = critical, CA:true, pathlen:0 +keyUsage = cRLSign, keyCertSign, digitalSignature +EOF + +cat > intermediate_ca2.conf << EOF +[ req ] +distinguished_name = req_distinguished_name +prompt = no +req_extensions = v3_intermediate_ca2 + +[ req_distinguished_name ] + O = $PROJECT_NAME Intermediate 2 CA + +[ v3_intermediate_ca2 ] +basicConstraints = critical, CA:true, pathlen:10 +keyUsage = encipherOnly, keyCertSign, decipherOnly +EOF + +# private key generation +openssl genrsa -out axTLS.ca_key.pem 2048 +openssl genrsa -out axTLS.key_1024.pem 1024 +openssl genrsa -out axTLS.key_2048.pem 2048 +openssl genrsa -out axTLS.key_4096.pem 4096 +openssl genrsa -out axTLS.key_device.pem 2048 +openssl genrsa -out axTLS.key_intermediate_ca.pem 2048 +openssl genrsa -out axTLS.key_intermediate_ca2.pem 2048 +openssl genrsa -out axTLS.key_end_chain.pem 2048 +openssl genrsa -aes128 -passout pass:abcd -out axTLS.key_aes128.pem 1024 +openssl genrsa -aes256 -passout pass:abcd -out axTLS.key_aes256.pem 1024 + +# convert private keys into DER format +openssl rsa -in axTLS.key_1024.pem -out axTLS.key_1024 -outform DER +openssl rsa -in axTLS.key_2048.pem -out axTLS.key_2048 -outform DER +openssl rsa -in axTLS.key_4096.pem -out axTLS.key_4096 -outform DER + +# cert requests +openssl req -out axTLS.ca_x509.csr -key axTLS.ca_key.pem -new \ + -config ./ca_cert.conf +openssl req -out axTLS.x509_1024.csr -key axTLS.key_1024.pem -new \ + -config ./certs.conf +openssl req -out axTLS.x509_2048.csr -key axTLS.key_2048.pem -new \ + -config ./certs.conf +openssl req -out axTLS.x509_4096.csr -key axTLS.key_4096.pem -new \ + -config ./certs.conf +openssl req -out axTLS.x509_device.csr -key axTLS.key_device.pem -new \ + -config ./device_cert.conf +openssl req -out axTLS.x509_intermediate_ca.csr \ + -key axTLS.key_intermediate_ca.pem -new \ + -config ./intermediate_ca.conf +openssl req -out axTLS.x509_intermediate_ca2.csr \ + -key axTLS.key_intermediate_ca2.pem -new \ + -config ./intermediate_ca2.conf +openssl req -out axTLS.x509_end_chain.csr -key axTLS.key_end_chain.pem -new \ + -config ./certs.conf +openssl req -out axTLS.x509_aes128.csr -key axTLS.key_aes128.pem \ + -new -config ./certs.conf -passin pass:abcd +openssl req -out axTLS.x509_aes256.csr -key axTLS.key_aes256.pem \ + -new -config ./certs.conf -passin pass:abcd + +# generate the actual certs. +openssl x509 -req -in axTLS.ca_x509.csr -out axTLS.ca_x509.pem \ + -sha1 -days 5000 -signkey axTLS.ca_key.pem \ + -CAkey axTLS.ca_key.pem -extfile ./ca_cert.conf -extensions v3_ca +openssl x509 -req -in axTLS.ca_x509.csr -out axTLS.ca_x509_sha256.pem \ + -sha256 -days 5000 -signkey axTLS.ca_key.pem \ + -CAkey axTLS.ca_key.pem -extfile ./ca_cert.conf -extensions v3_ca +openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024.pem \ + -sha1 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024_sha256.pem \ + -sha256 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509_sha256.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024_sha384.pem \ + -sha384 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509_sha256.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024_sha512.pem \ + -sha512 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509_sha256.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_2048.csr -out axTLS.x509_2048.pem \ + -sha1 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_4096.csr -out axTLS.x509_4096.pem \ + -sha1 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_device.csr -out axTLS.x509_device.pem \ + -sha1 -CAcreateserial -days 5000 \ + -CA axTLS.x509_1024.pem -CAkey axTLS.key_1024.pem +openssl x509 -req -in axTLS.x509_intermediate_ca.csr -out axTLS.x509_intermediate_ca.pem \ + -sha256 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem \ + -extfile ./intermediate_ca.conf -extensions v3_intermediate_ca +openssl x509 -req -in axTLS.x509_intermediate_ca2.csr -out axTLS.x509_intermediate_ca2.pem \ + -sha256 -CAcreateserial -days 5000 \ + -CA axTLS.x509_intermediate_ca.pem \ + -CAkey axTLS.key_intermediate_ca.pem \ + -extfile ./intermediate_ca2.conf -extensions v3_intermediate_ca2 +openssl x509 -req -in axTLS.x509_end_chain.csr -out axTLS.x509_end_chain.pem \ + -sha256 -CAcreateserial -days 5000 \ + -CA axTLS.x509_intermediate_ca.pem \ + -CAkey axTLS.key_intermediate_ca.pem \ + -extfile ./certs.conf -extensions v3_usr_cert +# basic constraint path len failure +openssl x509 -req -in axTLS.x509_end_chain.csr \ + -out axTLS.x509_end_chain_bad.pem \ + -sha256 -CAcreateserial -days 5000 \ + -CA axTLS.x509_intermediate_ca2.pem \ + -CAkey axTLS.key_intermediate_ca2.pem \ + -extfile ./certs.conf -extensions v3_usr_cert +cat axTLS.x509_intermediate_ca.pem >> axTLS.x509_intermediate_ca2.pem +openssl x509 -req -in axTLS.x509_aes128.csr \ + -out axTLS.x509_aes128.pem \ + -sha1 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem +openssl x509 -req -in axTLS.x509_aes256.csr \ + -out axTLS.x509_aes256.pem \ + -sha1 -CAcreateserial -days 5000 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem + +# note: must be root to do this +DATE_NOW=`date` +if date -s "Jan 1 2025"; then +openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_bad_before.pem \ + -sha1 -CAcreateserial -days 365 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem +date -s "$DATE_NOW" +touch axTLS.x509_bad_before.pem +fi +openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_bad_after.pem \ + -sha1 -CAcreateserial -days -365 \ + -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem + +# some cleanup +rm axTLS*.csr +rm *.srl +rm *.conf + +# need this for the client tests +openssl x509 -in axTLS.ca_x509.pem -outform DER -out axTLS.ca_x509.cer +openssl x509 -in axTLS.x509_1024.pem -outform DER -out axTLS.x509_1024.cer +openssl x509 -in axTLS.x509_2048.pem -outform DER -out axTLS.x509_2048.cer +openssl x509 -in axTLS.x509_4096.pem -outform DER -out axTLS.x509_4096.cer + +# generate pkcs8 files (use RC4-128 for encryption) +openssl pkcs8 -in axTLS.key_1024.pem -passout pass:abcd -topk8 -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted_pem.p8 +openssl pkcs8 -in axTLS.key_1024.pem -passout pass:abcd -topk8 -outform DER -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted.p8 +openssl pkcs8 -in axTLS.key_1024.pem -nocrypt -topk8 -out axTLS.unencrypted_pem.p8 +openssl pkcs8 -in axTLS.key_1024.pem -nocrypt -topk8 -outform DER -out axTLS.unencrypted.p8 + +# generate pkcs12 files (use RC4-128 for encryption) +openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -certfile axTLS.ca_x509.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -name "p12_with_CA" -out axTLS.withCA.p12 -password pass:abcd +openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -name "p12_without_CA" -out axTLS.withoutCA.p12 -password pass:abcd +openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -out axTLS.noname.p12 -password pass:abcd + +# PEM certificate chain +cat axTLS.ca_x509.pem >> axTLS.x509_device.pem + +# set default key/cert for use in the server +xxd -i axTLS.x509_1024.cer | sed -e \ + "s/axTLS_x509_1024_cer/default_certificate/" > ../../ssl/cert.h +xxd -i axTLS.key_1024 | sed -e \ + "s/axTLS_key_1024/default_private_key/" > ../../ssl/private_key.h diff --git a/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca b/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca new file mode 100644 index 0000000000000000000000000000000000000000..b90803452b6cd92749d3e34c60420fd20e5b1c4f GIT binary patch literal 1046 zcmXqLVi7WEV*0g!nTe5!iJ##hL${4hhu}rKZ^>`&I~ee?acZ@Bw0-AgWMpAwFeot8 zHqc~a4rSpMR&vfSs4U7%&nQvQNY+#^w6ru=@Xbsv$}i4OD^YOHFDlS8lrxZlC>BMP z$uCMQ$;{6)R5XwW$ukQ}AmoGc^Gg&QOG`5Hi!w_p4dldmEzJ!K4Gj#;4S*m@oY%;} z(8$;j${hd~H8Cn72MZ%B19KB2KZ8LNBNtN>BO}8~ro9IXo>_nLlh&9&y&}%w)uNTX zs_{SmP4!v4{omY03U)Pti)JtCPcX{9=#*0VZcW+AkXxT#&uNqCpWl+U`Dk`klJYfK zn|u6>lU__avR^lC)~pP*nHQ{d_Va9wP&?@MoXgH)n$AiM%N1`to1GrF@b8|L6PmcD zsb*n!o!TfGUH;@z+EkjRPZ-kzwi!?gPD_ zr%RZ=-NC4Gqg?QFOoGw;dEBS%SSNP$pR{_W_~}FVWSy-G+)pIE|8xC}wRO}=vyjYx zD!KM2&#bz~T65R1*LJ=@LDuenLjDq&2mV}eek>TJ;QuPAdi^TN6WZpgy8BWW3U#US zColdUBJ)%6pZD?vZDNP*#d?OS@s7n znRPvI6k1`LC7pHK^x+j5mM1G*Sx!V5Tjcr5@Fs2NTGVs-YKXntS((sf1-FH)+9#LJ IUw&x;05YnPSO5S3 literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem b/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem new file mode 100644 index 0000000..478e60b --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEEjCCAvqgAwIBAgIPAMEAizw8iBHRPvZj7N9AMA0GCSqGSIb3DQEBBAUAMHAx +KzApBgNVBAsTIkNvcHlyaWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAc +BgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8GA1UEAxMYTWljcm9zb2Z0 +IFJvb3QgQXV0aG9yaXR5MB4XDTk3MDExMDA3MDAwMFoXDTIwMTIzMTA3MDAwMFow +cDErMCkGA1UECxMiQ29weXJpZ2h0IChjKSAxOTk3IE1pY3Jvc29mdCBDb3JwLjEe +MBwGA1UECxMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSEwHwYDVQQDExhNaWNyb3Nv +ZnQgUm9vdCBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCpAr3BcOY78k4bKJ+XeF4w6qKpjSVf+P6VTKO3/p2iID58UaKboo9gMmvRQmR5 +7qx2yVTa8uuchhyPn4Rms8VremIj1h083g8BkuiWxL8tZpqaaCaZ0Dosvwy1WCbB +RucKPjiWLKkoOajsSYNC44QPu5psVWGsgnyhYC13TOmZtGQ7mlAcMQgkFJ+p55Er +GOY9mGMUYFgFZZ8dN1KH96fvlALGG9O/VUWziYC/OuxUlE6u/ad6bXROrxjMlgko +IQBXkGBpN7tLEgc8Vv9b+6RmCgim0oFWV++2O14WgXcE2va+roCV/rDNf9anGnJc +PMq88AijIjCzBoXJsyB3E4XfAgMBAAGjgagwgaUwgaIGA1UdAQSBmjCBl4AQW9Bw +72lyniNRfhSyTY7/y6FyMHAxKzApBgNVBAsTIkNvcHlyaWdodCAoYykgMTk5NyBN +aWNyb3NvZnQgQ29ycC4xHjAcBgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEh +MB8GA1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5gg8AwQCLPDyIEdE+9mPs +30AwDQYJKoZIhvcNAQEEBQADggEBAJXoC8CN85cYNe24ASTYdxHzXGAyn54Lyz4F +kYiPyTrmIfLwV5MstaBHyGLv/NfMOztaqTZUaf4kbT/JzKreBXzdMY09nxBwarv+ +Ek8YacD80EPjEVogT+pie6+qGcgrNyUtvmWhEoolD2Oj91Qc+SHJ1hXzUqxuQzIH +/YIX+OVnbA1R9r3xUse958Qw/CAxCYgdlSkaTdUdAqXxgOADtFv0sd3IV+5lScdS +VLa0AygS/5DW8AiPfriXxas3LOR65Kh343agANBqP8HSNorgQRKoNWobats14dQc +BOSoRQTIWjM4bk0cDWK3CqKM09VUP0bNHFWmcNsSOoeTdZ+n0qA= +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/ms_iis.cer b/user/mpy/lib/axtls/ssl/test/ms_iis.cer new file mode 100755 index 0000000..250b926 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/ms_iis.cer @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB5jCCAVOgAwIBAgIQWPe7KyA+U7lLUohulwW2HDAJBgUrDgMCHQUAMCExHzAd +BgNVBAMTFmF4dGxzLmNlcm9jY2x1Yi5jb20uYXUwHhcNMDgwMzE3MTAyMTA2WhcN +MDkwMzE3MTAyMTA2WjAhMR8wHQYDVQQDExZheHRscy5jZXJvY2NsdWIuY29tLmF1 +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9JqHlQjrQMt3JW8yxcGhFagDa +D4QiIY8+KItTt13fIBt5g1AG4VXniaylSqKKYNPwVzqSWl7WhxMmoFU73veF8o4M +G0Zc5qbVB6ukrSV4WaTgHrIO6pWkyiaQ4L/eYfCo/2pByhl0IUKkf/TMN346/rFg +JgrElx01l6QHNQrzVQIDAQABoycwJTATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNV +HQ8EBwMFALAAAAAwCQYFKw4DAh0FAAOBgQAbH94H1fryngROJ//Oa0D3vvTO8CJ3 +8VW+3gQEwrPBOWmN6RV8OM0dE6pf8wD3s7PTCcM5+/HI1Qk53nUGrNiOmKM1s0JB +bvsO9RT+UF8mtdbo/n30M0MHMWPCC76baW3R+ANBp/V/z4l1ytpUTt+MHvz0VlUs +J4uJA3s3uh23Tg== +-----END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/perf_bigint.c b/user/mpy/lib/axtls/ssl/test/perf_bigint.c new file mode 100644 index 0000000..6336d1b --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/perf_bigint.c @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2007, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Some performance testing of bigint. + */ + +#include +#include +#include + +#include "os_port.h" +#include "ssl.h" + +/************************************************************************** + * BIGINT tests + * + **************************************************************************/ + +int main(int argc, char *argv[]) +{ +#ifdef CONFIG_SSL_CERT_VERIFICATION + RSA_CTX *rsa_ctx = NULL; + BI_CTX *ctx; + bigint *bi_data, *bi_res; + float diff; + int res = 1; + struct timeval tv_old, tv_new; + const char *plaintext; + uint8_t compare[MAX_KEY_BYTE_SIZE]; + int i, max_biggie = 10; /* really crank performance */ + int len; + uint8_t *buf; + + /** + * 512 bit key + */ + plaintext = /* 64 byte number */ + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; + + len = get_file("../ssl/test/axTLS.key_512", &buf); + asn1_get_private_key(buf, len, &rsa_ctx); + ctx = rsa_ctx->bi_ctx; + bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); + bi_res = RSA_public(rsa_ctx, bi_data); + bi_data = bi_res; /* reuse again */ + + gettimeofday(&tv_old, NULL); + for (i = 0; i < max_biggie; i++) + { + bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); + if (i < max_biggie-1) + { + bi_free(ctx, bi_res); + } + } + + gettimeofday(&tv_new, NULL); + bi_free(ctx, bi_data); + + diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + + (tv_new.tv_usec-tv_old.tv_usec)/1000; + printf("512 bit decrypt time: %.2fms\n", diff/max_biggie); + TTY_FLUSH(); + bi_export(ctx, bi_res, compare, 64); + RSA_free(rsa_ctx); + free(buf); + if (memcmp(plaintext, compare, 64) != 0) + goto end; + + /** + * 1024 bit key + */ + plaintext = /* 128 byte number */ + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; + + len = get_file("../ssl/test/axTLS.key_1024", &buf); + rsa_ctx = NULL; + asn1_get_private_key(buf, len, &rsa_ctx); + ctx = rsa_ctx->bi_ctx; + bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); + bi_res = RSA_public(rsa_ctx, bi_data); + bi_data = bi_res; /* reuse again */ + + gettimeofday(&tv_old, NULL); + for (i = 0; i < max_biggie; i++) + { + bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); + if (i < max_biggie-1) + { + bi_free(ctx, bi_res); + } + } + + gettimeofday(&tv_new, NULL); + bi_free(ctx, bi_data); + + diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + + (tv_new.tv_usec-tv_old.tv_usec)/1000; + printf("1024 bit decrypt time: %.2fms\n", diff/max_biggie); + TTY_FLUSH(); + bi_export(ctx, bi_res, compare, 128); + RSA_free(rsa_ctx); + free(buf); + if (memcmp(plaintext, compare, 128) != 0) + goto end; + + /** + * 2048 bit key + */ + plaintext = /* 256 byte number */ + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; + + len = get_file("../ssl/test/axTLS.key_2048", &buf); + rsa_ctx = NULL; + asn1_get_private_key(buf, len, &rsa_ctx); + ctx = rsa_ctx->bi_ctx; + bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); + bi_res = RSA_public(rsa_ctx, bi_data); + bi_data = bi_res; /* reuse again */ + + gettimeofday(&tv_old, NULL); + for (i = 0; i < max_biggie; i++) + { + bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); + if (i < max_biggie-1) + { + bi_free(ctx, bi_res); + } + } + gettimeofday(&tv_new, NULL); + bi_free(ctx, bi_data); + + diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + + (tv_new.tv_usec-tv_old.tv_usec)/1000; + printf("2048 bit decrypt time: %.2fms\n", diff/max_biggie); + TTY_FLUSH(); + bi_export(ctx, bi_res, compare, 256); + RSA_free(rsa_ctx); + free(buf); + if (memcmp(plaintext, compare, 256) != 0) + goto end; + + /** + * 4096 bit key + */ + plaintext = /* 512 byte number */ + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; + + len = get_file("../ssl/test/axTLS.key_4096", &buf); + rsa_ctx = NULL; + asn1_get_private_key(buf, len, &rsa_ctx); + ctx = rsa_ctx->bi_ctx; + bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); + gettimeofday(&tv_old, NULL); + bi_res = RSA_public(rsa_ctx, bi_data); + gettimeofday(&tv_new, NULL); + diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + + (tv_new.tv_usec-tv_old.tv_usec)/1000; + printf("4096 bit encrypt time: %.2fms\n", diff); + TTY_FLUSH(); + bi_data = bi_res; /* reuse again */ + + gettimeofday(&tv_old, NULL); + for (i = 0; i < max_biggie; i++) + { + bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); + if (i < max_biggie-1) + { + bi_free(ctx, bi_res); + } + } + + gettimeofday(&tv_new, NULL); + bi_free(ctx, bi_data); + + diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + + (tv_new.tv_usec-tv_old.tv_usec)/1000; + printf("4096 bit decrypt time: %.2fms\n", diff/max_biggie); + TTY_FLUSH(); + bi_export(ctx, bi_res, compare, 512); + RSA_free(rsa_ctx); + free(buf); + if (memcmp(plaintext, compare, 512) != 0) + goto end; + + /* done */ + printf("Bigint performance testing complete\n"); + res = 0; + +end: + return res; +#else + return 0; +#endif +} diff --git a/user/mpy/lib/axtls/ssl/test/qualityssl.com.der b/user/mpy/lib/axtls/ssl/test/qualityssl.com.der new file mode 100644 index 0000000000000000000000000000000000000000..c73b246440aed171f9e8baa9f1963c6981945fb3 GIT binary patch literal 1385 zcmXqLVofz@V)0$T%*4pVB*2;)`+UuO=IctEE2C}NI+_i5**LY@JlekVGBUEVG8i;Y zH{>?pWMd9xVH0Kw4TfJijR0P|-jhB+o4@kx^1oV5P5LUS6(OTAW%`QdC-8qL-YX zYbb9Z3sS-?EEXE#rwcN|EwiY&MAsv+D5X5HDAhntoY%k-2#pNDAWEFq&;-OaGB&j| zwTv=oya#hE(B&@PhP(#cAOi)3S&Yn#ObxjVI6zzuVMbj;5d$F*n_ZYYEHNi1HLo}+ zF*Vyz%0L1n$|)@9mztB4nVnjen3|WKTB2ZRWGHMP2$JIx=5op`am`E5%u6kX333Z_ z1(qh}0K*|T*azkhZeg*2qWrSVl++Z3q)G)OT`~qzAfvd2g%P?G!ZUMHl7T)olr#_r z$uf%wXz3L~Of4?X0fmr3<9y`EVq|4tZtMj{SSM3sBg5`nnJKJ07Hqy6pyHLVUvwd3 z@~>YS$_!^sg3J_F?3&asrlD&(tI7XYeTYKsT^^MMlKQI7tC^qLoj7vl|N4rgqv4&7 z!E9wY3_1?GSxhJVyl~7*o=NEU=T)maZ!phzb2CM^&rssSS)ZE2I~F8IsfOBj$6r?{ zF*#=%c9tcsGvH&kULvAAuuVR+&Y@K&(MzVNtxAw8jkQsj=+lS6ipe z^}cl26&%&Fd@N!tBCo_AG)l+3O3gaJFj@ale%`%lX>SbpfI%S3&&c?ng@u`kb%6m7 zh%XG{GZ`>IG^?_R8HliPXtM!REju$KoW*3|22!lRVsBt;V9mw@RKUWx$&itWk(tFn z+dvbhkcm-D7L*o?fr+s=HMz7X6%@w#DfxPNsU`Z(0l@~0?i@dO&psKz$30+6*vsf^EU0uMp-=Mn;xYgJhsjpk6g#YSV|C z2F^Js?r=;=2?1rP;MAhB)FNj`pd(5QRN$H!+h7?mKe@O7>SKs6475T16=YE{P-?$1?wo@z>i|9+~!DQVdb$zhdFPbbjeVz2aw9=Am=6Z-;U6 z|F>9q<}bL2pT$;l&p_UnL$%W88hLxTb-d_1NV7 z5vx7lh|YY~@$^u!tXR95RjB_Ln|2=Syaf4&D?T>;^EGyAxV=4)>HYDKrcYa=n;bdT zD1_gVIX$B?$mr*qC0U=IFPUawmVUQ6EAPkWtjR+Ab~fHD=a}%eSF`D(HiO5};&o+v z&!=k&N1dwdc6(Y{w23{{=0l>Iu~pl_{j_`!T z;QZvw)RI&M_td=9qQsn3Lm2}pu`Kb zlb2eeSDc@mo|>nZoS$pZI3GE97+D#Z8+#dmE@WzKWVoD|Jf%l(uZI1`=4qA=*RJJA z?chpsFj>bp<>2Cnn~pKH_~~}+WSdv5Vp-g~=R*{W@9c}qf6Ug-cl@VZLQQ_OCeH@^h`oXZ!fnJj3XJKJxVqIWh1LDZD zm>L)x7%tFXpxdUMQBqQ1rLUh{l%ofXrp)5Zbg*Cbf$tUR59|fBpSpoj9n0I5NQx@ z5Gux*nVXoNs-K>jW}s*wZ@|vRs?EpDB*h}q|Map{+nV0K?8E09vaWbY=u}JU8K{aW zL+t=2fqWD@^vjCDVjz=Ha|v@D1BdA4&`;!%a z`ZjicJXrPWUp61x_6yT?-1OPGnCp)Bskw&pd3$HgaIL> +#include +#include +#include +#include +#include +#include + +#ifndef WIN32 +#include +#endif + +#include "os_port.h" +#include "ssl.h" + +#define DEFAULT_CERT "../ssl/test/axTLS.x509_1024.cer" +#define DEFAULT_KEY "../ssl/test/axTLS.key_1024" +//#define DEFAULT_SVR_OPTION SSL_DISPLAY_BYTES|SSL_DISPLAY_STATES +#define DEFAULT_SVR_OPTION 0 +//#define DEFAULT_CLNT_OPTION SSL_DISPLAY_BYTES|SSL_DISPLAY_STATES +#define DEFAULT_CLNT_OPTION 0 + +/* hack to remove gcc warning */ +#define SYSTEM(A) if (system(A) < 0) printf("system call error\n"); + +static int g_port = 19001; + +/************************************************************************** + * AES tests + * + * Run through a couple of the RFC3602 tests to verify that AES is correct. + **************************************************************************/ +#define TEST1_SIZE 16 +#define TEST2_SIZE 32 + +static int AES_test(BI_CTX *bi_ctx) +{ + AES_CTX aes_key; + int res = 1; + uint8_t key[TEST1_SIZE]; + uint8_t iv[TEST1_SIZE]; + + { + /* + Case #1: Encrypting 16 bytes (1 block) using AES-CBC + Key : 0x06a9214036b8a15b512e03d534120006 + IV : 0x3dafba429d9eb430b422da802c9fac41 + Plaintext : "Single block msg" + Ciphertext: 0xe353779c1079aeb82708942dbe77181a + + */ + char *in_str = "Single block msg"; + uint8_t ct[TEST1_SIZE]; + uint8_t enc_data[TEST1_SIZE]; + uint8_t dec_data[TEST1_SIZE]; + + bigint *key_bi = bi_str_import( + bi_ctx, "06A9214036B8A15B512E03D534120006"); + bigint *iv_bi = bi_str_import( + bi_ctx, "3DAFBA429D9EB430B422DA802C9FAC41"); + bigint *ct_bi = bi_str_import( + bi_ctx, "E353779C1079AEB82708942DBE77181A"); + bi_export(bi_ctx, key_bi, key, TEST1_SIZE); + bi_export(bi_ctx, iv_bi, iv, TEST1_SIZE); + bi_export(bi_ctx, ct_bi, ct, TEST1_SIZE); + + AES_set_key(&aes_key, key, iv, AES_MODE_128); + AES_cbc_encrypt(&aes_key, (const uint8_t *)in_str, + enc_data, sizeof(enc_data)); + if (memcmp(enc_data, ct, sizeof(ct))) + { + printf("Error: AES ENCRYPT #1 failed\n"); + goto end; + } + + AES_set_key(&aes_key, key, iv, AES_MODE_128); + AES_convert_key(&aes_key); + AES_cbc_decrypt(&aes_key, enc_data, dec_data, sizeof(enc_data)); + + if (memcmp(dec_data, in_str, sizeof(dec_data))) + { + printf("Error: AES DECRYPT #1 failed\n"); + goto end; + } + } + + { + /* + Case #2: Encrypting 32 bytes (2 blocks) using AES-CBC + Key : 0xc286696d887c9aa0611bbb3e2025a45a + IV : 0x562e17996d093d28ddb3ba695a2e6f58 + Plaintext : 0x000102030405060708090a0b0c0d0e0f + 101112131415161718191a1b1c1d1e1f + Ciphertext: 0xd296cd94c2cccf8a3a863028b5e1dc0a + 7586602d253cfff91b8266bea6d61ab1 + */ + uint8_t in_data[TEST2_SIZE]; + uint8_t ct[TEST2_SIZE]; + uint8_t enc_data[TEST2_SIZE]; + uint8_t dec_data[TEST2_SIZE]; + + bigint *in_bi = bi_str_import(bi_ctx, + "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); + bigint *key_bi = bi_str_import( + bi_ctx, "C286696D887C9AA0611BBB3E2025A45A"); + bigint *iv_bi = bi_str_import( + bi_ctx, "562E17996D093D28DDB3BA695A2E6F58"); + bigint *ct_bi = bi_str_import(bi_ctx, + "D296CD94C2CCCF8A3A863028B5E1DC0A7586602D253CFFF91B8266BEA6D61AB1"); + bi_export(bi_ctx, in_bi, in_data, TEST2_SIZE); + bi_export(bi_ctx, key_bi, key, TEST1_SIZE); + bi_export(bi_ctx, iv_bi, iv, TEST1_SIZE); + bi_export(bi_ctx, ct_bi, ct, TEST2_SIZE); + + AES_set_key(&aes_key, key, iv, AES_MODE_128); + AES_cbc_encrypt(&aes_key, (const uint8_t *)in_data, + enc_data, sizeof(enc_data)); + + if (memcmp(enc_data, ct, sizeof(ct))) + { + printf("Error: ENCRYPT #2 failed\n"); + goto end; + } + + AES_set_key(&aes_key, key, iv, AES_MODE_128); + AES_convert_key(&aes_key); + AES_cbc_decrypt(&aes_key, enc_data, dec_data, sizeof(enc_data)); + if (memcmp(dec_data, in_data, sizeof(dec_data))) + { + printf("Error: DECRYPT #2 failed\n"); + goto end; + } + } + + res = 0; + printf("All AES tests passed\n"); + +end: + return res; +} + +/************************************************************************** + * SHA1 tests + * + * Run through a couple of the RFC3174 tests to verify that SHA1 is correct. + **************************************************************************/ +static int SHA1_test(BI_CTX *bi_ctx) +{ + SHA1_CTX ctx; + uint8_t ct[SHA1_SIZE]; + uint8_t digest[SHA1_SIZE]; + int res = 1; + + { + const char *in_str = "abc"; + bigint *ct_bi = bi_str_import(bi_ctx, + "A9993E364706816ABA3E25717850C26C9CD0D89D"); + bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); + + SHA1_Init(&ctx); + SHA1_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA1_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA1 #1 failed\n"); + goto end; + } + } + + { + const char *in_str = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; + bigint *ct_bi = bi_str_import(bi_ctx, + "84983E441C3BD26EBAAE4AA1F95129E5E54670F1"); + bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); + + SHA1_Init(&ctx); + SHA1_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA1_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA1 #2 failed\n"); + goto end; + } + } + + res = 0; + printf("All SHA1 tests passed\n"); + +end: + return res; +} + +/************************************************************************** + * SHA256 tests + * + * Run through a couple of the SHA-2 tests to verify that SHA256 is correct. + **************************************************************************/ +static int SHA256_test(BI_CTX *bi_ctx) +{ + SHA256_CTX ctx; + uint8_t ct[SHA256_SIZE]; + uint8_t digest[SHA256_SIZE]; + int res = 1; + + { + const char *in_str = "abc"; + bigint *ct_bi = bi_str_import(bi_ctx, + "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD"); + bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); + + SHA256_Init(&ctx); + SHA256_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA256_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA256 #1 failed\n"); + goto end; + } + } + + { + const char *in_str = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; + bigint *ct_bi = bi_str_import(bi_ctx, + "248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1"); + bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); + + SHA256_Init(&ctx); + SHA256_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA256_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA256 #2 failed\n"); + goto end; + } + } + + res = 0; + printf("All SHA256 tests passed\n"); + +end: + return res; +} + +/************************************************************************** + * SHA384 tests + * + * Run through a couple of the SHA-2 tests to verify that SHA384 is correct. + **************************************************************************/ +static int SHA384_test(BI_CTX *bi_ctx) +{ + SHA384_CTX ctx; + uint8_t ct[SHA384_SIZE]; + uint8_t digest[SHA384_SIZE]; + int res = 1; + + { + const char *in_str = "abc"; + bigint *ct_bi = bi_str_import(bi_ctx, + "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7"); + bi_export(bi_ctx, ct_bi, ct, SHA384_SIZE); + + SHA384_Init(&ctx); + SHA384_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA384_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA384 #1 failed\n"); + goto end; + } + } + + { + const char *in_str = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; + bigint *ct_bi = bi_str_import(bi_ctx, + "3391FDDDFC8DC7393707A65B1B4709397CF8B1D162AF05ABFE8F450DE5F36BC6B0455A8520BC4E6F5FE95B1FE3C8452B"); + bi_export(bi_ctx, ct_bi, ct, SHA384_SIZE); + + SHA384_Init(&ctx); + SHA384_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA384_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA384 #2 failed\n"); + goto end; + } + } + + res = 0; + printf("All SHA384 tests passed\n"); + +end: + return res; +} +/************************************************************************** + * SHA512 tests + * + * Run through a couple of the SHA-2 tests to verify that SHA512 is correct. + **************************************************************************/ +static int SHA512_test(BI_CTX *bi_ctx) +{ + SHA512_CTX ctx; + uint8_t ct[SHA512_SIZE]; + uint8_t digest[SHA512_SIZE]; + int res = 1; + + { + const char *in_str = "abc"; + bigint *ct_bi = bi_str_import(bi_ctx, + "DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F"); + bi_export(bi_ctx, ct_bi, ct, SHA512_SIZE); + + SHA512_Init(&ctx); + SHA512_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA512_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA512 #1 failed\n"); + goto end; + } + } + + { + const char *in_str = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; + bigint *ct_bi = bi_str_import(bi_ctx, + "204A8FC6DDA82F0A0CED7BEB8E08A41657C16EF468B228A8279BE331A703C33596FD15C13B1B07F9AA1D3BEA57789CA031AD85C7A71DD70354EC631238CA3445"); + bi_export(bi_ctx, ct_bi, ct, SHA512_SIZE); + + SHA512_Init(&ctx); + SHA512_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + SHA512_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: SHA512 #2 failed\n"); + goto end; + } + } + + res = 0; + printf("All SHA512 tests passed\n"); + +end: + return res; +} +/************************************************************************** + * MD5 tests + * + * Run through a couple of the RFC1321 tests to verify that MD5 is correct. + **************************************************************************/ +static int MD5_test(BI_CTX *bi_ctx) +{ + MD5_CTX ctx; + uint8_t ct[MD5_SIZE]; + uint8_t digest[MD5_SIZE]; + int res = 1; + + { + const char *in_str = "abc"; + bigint *ct_bi = bi_str_import(bi_ctx, + "900150983CD24FB0D6963F7D28E17F72"); + bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); + + MD5_Init(&ctx); + MD5_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + MD5_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: MD5 #1 failed\n"); + goto end; + } + } + + { + const char *in_str = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + bigint *ct_bi = bi_str_import( + bi_ctx, "D174AB98D277D9F5A5611C2C9F419D9F"); + bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); + + MD5_Init(&ctx); + MD5_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); + MD5_Final(digest, &ctx); + + if (memcmp(digest, ct, sizeof(ct))) + { + printf("Error: MD5 #2 failed\n"); + goto end; + } + } + res = 0; + printf("All MD5 tests passed\n"); + +end: + return res; +} + +/************************************************************************** + * HMAC tests + * + * Run through a couple of the RFC2202 tests to verify that HMAC is correct. + **************************************************************************/ +static int HMAC_test(BI_CTX *bi_ctx) +{ + uint8_t key[SHA256_SIZE]; + uint8_t ct[SHA256_SIZE]; + uint8_t dgst[SHA256_SIZE]; + int res = 1; + const char *key_str; + + const char *data_str = "Hi There"; + bigint *key_bi = bi_str_import(bi_ctx, "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); + bigint *ct_bi = bi_str_import(bi_ctx, "9294727A3638BB1C13F48EF8158BFC9D"); + bi_export(bi_ctx, key_bi, key, MD5_SIZE); + bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); + hmac_md5((const uint8_t *)data_str, 8, key, MD5_SIZE, dgst); + if (memcmp(dgst, ct, MD5_SIZE)) + { + printf("HMAC MD5 #1 failed\n"); + goto end; + } + + data_str = "what do ya want for nothing?"; + key_str = "Jefe"; + ct_bi = bi_str_import(bi_ctx, "750C783E6AB0B503EAA86E310A5DB738"); + bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); + hmac_md5((const uint8_t *)data_str, 28, (const uint8_t *)key_str, 4, dgst); + if (memcmp(dgst, ct, MD5_SIZE)) + { + printf("HMAC MD5 #2 failed\n"); + goto end; + } + + data_str = "Hi There"; + key_bi = bi_str_import(bi_ctx, "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); + ct_bi = bi_str_import(bi_ctx, "B617318655057264E28BC0B6FB378C8EF146BE00"); + bi_export(bi_ctx, key_bi, key, SHA1_SIZE); + bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); + + hmac_sha1((const uint8_t *)data_str, 8, + (const uint8_t *)key, SHA1_SIZE, dgst); + if (memcmp(dgst, ct, SHA1_SIZE)) + { + printf("HMAC SHA1 #1 failed\n"); + goto end; + } + + data_str = "what do ya want for nothing?"; + key_str = "Jefe"; + ct_bi = bi_str_import(bi_ctx, "EFFCDF6AE5EB2FA2D27416D5F184DF9C259A7C79"); + bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); + + hmac_sha1((const uint8_t *)data_str, 28, (const uint8_t *)key_str, 4, dgst); + if (memcmp(dgst, ct, SHA1_SIZE)) + { + printf("HMAC SHA1 #2 failed\n"); + goto end; + } + + data_str = "Hi There"; + key_bi = bi_str_import(bi_ctx, "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); + ct_bi = bi_str_import(bi_ctx, + "B0344C61D8DB38535CA8AFCEAF0BF12B881DC200C9833DA726E9376C2E32CFF7"); + bi_export(bi_ctx, key_bi, key, 20); + bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); + + hmac_sha256((const uint8_t *)data_str, 8, + (const uint8_t *)key, 20, dgst); + + if (memcmp(dgst, ct, SHA256_SIZE)) + { + printf("HMAC SHA256 #1 failed\n"); + goto end; + } + + data_str = "what do ya want for nothing?"; + key_str = "Jefe"; + ct_bi = bi_str_import(bi_ctx, + "5BDCC146BF60754E6A042426089575C75A003F089D2739839DEC58B964EC3843"); + bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); + + hmac_sha256((const uint8_t *)data_str, 28, + (const uint8_t *)key_str, 4, dgst); + if (memcmp(dgst, ct, SHA256_SIZE)) + { + printf("HMAC SHA256 #2 failed\n"); + goto end; + } + + // other test + /*uint8_t secret[16]; + key_str = "9BBE436BA940F017B17652849A71DB35"; + ct_bi = bi_str_import(bi_ctx, key_str); + bi_export(bi_ctx, ct_bi, secret, 16); + + uint8_t random[26]; + data_str = "74657374206C6162656CA0BA9F936CDA311827A6F796FFD5198C"; + ct_bi = bi_str_import(bi_ctx, data_str); + bi_export(bi_ctx, ct_bi, random, 26); + + uint8_t output[256]; + p_hash_sha256(secret, 16, random, 26, output, 100); + ct_bi = bi_import(bi_ctx, output, 100); + bi_print("RESULT", ct_bi); + */ + + /*uint8_t secret[48]; + uint8_t random[256]; + uint8_t output[256]; + + key_str = + "8C6D256467157DAEC7BAEBC1371E6DABFF1AB686EFA7DCF6B65242AA6EEBFC0A7472A1E583C4F2B23F784F25A6DE05A6"; + ct_bi = bi_str_import(bi_ctx, key_str); + bi_export(bi_ctx, ct_bi, secret, 48); + + data_str = + "636C69656E742066696E697368656475F80B2E4375CFA44105D16694A5E2D232302FF27241BDF52BA681C13E2CDF9F"; + ct_bi = bi_str_import(bi_ctx, data_str); + bi_export(bi_ctx, ct_bi, random, 47); + + p_hash_sha256(secret, 48, random, 47, output, 12); + ct_bi = bi_import(bi_ctx, output, 12); + bi_print("RESULT1", ct_bi);*/ + + res = 0; + printf("All HMAC tests passed\n"); + +end: + return res; +} + +/************************************************************************** + * BIGINT tests + * + **************************************************************************/ +static int BIGINT_test(BI_CTX *ctx) +{ + int res = 1; + +#ifndef CONFIG_INTEGER_8BIT +#ifndef CONFIG_INTEGER_16BIT + bigint *bi_data, *bi_exp, *bi_res; + const char *expnt, *plaintext, *mod; + uint8_t compare[MAX_KEY_BYTE_SIZE]; + /** + * 512 bit key + */ + plaintext = /* 64 byte number */ + "01aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee"; + + mod = "C30773C8ABE09FCC279EE0E5343370DE" + "8B2FFDB6059271E3005A7CEEF0D35E0A" + "1F9915D95E63560836CC2EB2C289270D" + "BCAE8CAF6F5E907FC2759EE220071E1B"; + + expnt = "A1E556CD1738E10DF539E35101334E97" + "BE8D391C57A5C89A7AD9A2EA2ACA1B3D" + "F3140F5091CC535CBAA47CEC4159EE1F" + "B6A3661AFF1AB758426EAB158452A9B9"; + + bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); + bi_exp = int_to_bi(ctx, 0x10001); + bi_set_mod(ctx, bi_str_import(ctx, mod), 0); + bi_res = bi_mod_power(ctx, bi_data, bi_exp); + + bi_data = bi_res; /* resuse again - see if we get the original */ + + bi_exp = bi_str_import(ctx, expnt); + bi_res = bi_mod_power(ctx, bi_data, bi_exp); + bi_free_mod(ctx, 0); + + bi_export(ctx, bi_res, compare, 64); + if (memcmp(plaintext, compare, 64) != 0) + goto end; +#endif +#endif + + /* + * Multiply with psssible carry issue (8 bit) + */ + { + bigint *bi_x = bi_str_import(ctx, + "AFD5060E224B70DA99EFB385BA5C0D2BEA0AD1DAAA52686E1A02D677BC65C1DA7A496BBDCC02999E8814F10AFC4B8E0DD4E6687E0762CE717A5EA1E452B5C56065C8431F0FB9D23CFF3A4B4149798C0670AF7F9565A0EAE5CF1AB16A1F0C3DD5E485DC5ABB96EBE0B6778A15B7302CBCE358E4BF2E2E30932758AC6EFA9F5828"); + bigint *arg2 = bi_clone(ctx, bi_x); + bigint *arg3 = bi_clone(ctx, bi_x); + bigint *sqr_result = bi_square(ctx, bi_x); + bigint *mlt_result = bi_multiply(ctx, arg2, arg3); + + if (bi_compare(sqr_result, mlt_result) != 0) + { + bi_print("SQR_RESULT", sqr_result); + bi_print("MLT_RESULT", mlt_result); + bi_free(ctx, sqr_result); + bi_free(ctx, mlt_result); + goto end; + } + + bi_free(ctx, sqr_result); + bi_free(ctx, mlt_result); + } + + printf("All BIGINT tests passed\n"); + res = 0; + +end: + return res; +} + +/************************************************************************** + * RSA tests + * + * Use the results from openssl to verify PKCS1 etc + **************************************************************************/ +static int RSA_test(void) +{ + int res = 1; + const char *plaintext = /* 128 byte hex number */ + "1aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee2" + "1aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeee2\012"; + uint8_t enc_data[128], dec_data[128]; + RSA_CTX *rsa_ctx = NULL; + BI_CTX *bi_ctx; + bigint *plaintext_bi; + bigint *enc_data_bi, *dec_data_bi; + uint8_t enc_data2[128], dec_data2[128]; + int len; + uint8_t *buf; + + RNG_initialize(); + + /* extract the private key elements */ + len = get_file("../ssl/test/axTLS.key_1024", &buf); + if (asn1_get_private_key(buf, len, &rsa_ctx) < 0) + { + goto end; + } + + free(buf); + bi_ctx = rsa_ctx->bi_ctx; + plaintext_bi = bi_import(bi_ctx, + (const uint8_t *)plaintext, strlen(plaintext)); + + /* basic rsa encrypt */ + enc_data_bi = RSA_public(rsa_ctx, plaintext_bi); + bi_export(bi_ctx, bi_copy(enc_data_bi), enc_data, sizeof(enc_data)); + + /* basic rsa decrypt */ + dec_data_bi = RSA_private(rsa_ctx, enc_data_bi); + bi_export(bi_ctx, dec_data_bi, dec_data, sizeof(dec_data)); + + if (memcmp(dec_data, plaintext, strlen(plaintext))) + { + printf("Error: DECRYPT #1 failed\n"); + goto end; + } + + if (RSA_encrypt(rsa_ctx, (const uint8_t *)"abc", 3, enc_data2, 0) < 0) + { + printf("Error: ENCRYPT #2 failed\n"); + goto end; + } + + RSA_decrypt(rsa_ctx, enc_data2, dec_data2, sizeof(dec_data2), 1); + if (memcmp("abc", dec_data2, 3)) + { + printf("Error: DECRYPT #2 failed\n"); + goto end; + } + + RSA_free(rsa_ctx); + res = 0; + printf("All RSA tests passed\n"); + +end: + RNG_terminate(); + return res; +} + +/************************************************************************** + * Cert Testing + * + **************************************************************************/ +static int cert_tests(void) +{ + int res = -1, len; + X509_CTX *x509_ctx; + SSL_CTX *ssl_ctx; + uint8_t *buf; + + /* check a bunch of 3rd party certificates */ + ssl_ctx = ssl_ctx_new(0, 0); + len = get_file("../ssl/test/microsoft.x509_ca", &buf); + if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) + { + printf("Cert #1\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + free(buf); + + ssl_ctx = ssl_ctx_new(0, 0); + len = get_file("../ssl/test/thawte.x509_ca", &buf); + if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) + { + printf("Cert #2\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + free(buf); + + ssl_ctx = ssl_ctx_new(0, 0); + len = get_file("../ssl/test/deutsche_telecom.x509_ca", &buf); + if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) + { + printf("Cert #3\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + free(buf); + + ssl_ctx = ssl_ctx_new(0, 0); + len = get_file("../ssl/test/equifax.x509_ca", &buf); + if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) + { + printf("Cert #4\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + free(buf); + + ssl_ctx = ssl_ctx_new(0, 0); + len = get_file("../ssl/test/gnutls.cer", &buf); + if ((res = add_cert(ssl_ctx, buf, len)) < 0) + { + printf("Cert #5\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + free(buf); + + ssl_ctx = ssl_ctx_new(0, 0); + len = get_file("../ssl/test/socgen.cer", &buf); + if ((res = add_cert(ssl_ctx, buf, len)) < 0) + { + printf("Cert #6\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + free(buf); + + ssl_ctx = ssl_ctx_new(0, 0); + if ((res = ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, + "../ssl/test/camster_duckdns_org.crt", NULL)) != SSL_OK) + { + printf("Cert #7\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + + ssl_ctx = ssl_ctx_new(0, 0); + if ((res = ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, + "../ssl/test/comodo.sha384.cer", NULL)) != SSL_OK) + { + printf("Cert #8\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + + ssl_ctx = ssl_ctx_new(0, 0); + if ((res = ssl_obj_load(ssl_ctx, + SSL_OBJ_X509_CERT, "../ssl/test/ms_iis.cer", NULL)) != SSL_OK) + { + printf("Cert #9\n"); + ssl_display_error(res); + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + + if (get_file("../ssl/test/qualityssl.com.der", &buf) < 0 || + x509_new(buf, &len, &x509_ctx)) + { + printf("Cert #10\n"); + res = -1; + goto bad_cert; + } + + if (strcmp(x509_ctx->subject_alt_dnsnames[1], "qualityssl.com")) + { + printf("Cert #11\n"); + res = -1; + goto bad_cert; + } + x509_free(x509_ctx); + free(buf); + + // this bundle has two DSA (1.2.840.10040.4.3 invalid) certificates + ssl_ctx = ssl_ctx_new(0, 0); + if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, + "../ssl/test/ca-bundle.crt", NULL)) + { + goto bad_cert; + } + + ssl_ctx_free(ssl_ctx); + res = 0; /* all ok */ + printf("All Certificate tests passed\n"); + +bad_cert: + if (res) + printf("Error: A certificate test failed\n"); + + return res; +} + +/** + * init a server socket. + */ +static int server_socket_init(int *port) +{ + struct sockaddr_in serv_addr; + int server_fd; + char yes = 1; + + /* Create socket for incoming connections */ + if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) + { + return -1; + } + + setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); + +go_again: + /* Construct local address structure */ + memset(&serv_addr, 0, sizeof(serv_addr)); /* Zero out structure */ + serv_addr.sin_family = AF_INET; /* Internet address family */ + serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */ + serv_addr.sin_port = htons(*port); /* Local port */ + + /* Bind to the local address */ + if (bind(server_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) + { + (*port)++; + goto go_again; + } + /* Mark the socket so it will listen for incoming connections */ + if (listen(server_fd, 3000) < 0) + { + return -1; + } + + return server_fd; +} + +/** + * init a client socket. + */ +static int client_socket_init(uint16_t port) +{ + struct sockaddr_in address; + int client_fd; + + address.sin_family = AF_INET; + address.sin_port = htons(port); + address.sin_addr.s_addr = inet_addr("127.0.0.1"); + client_fd = socket(AF_INET, SOCK_STREAM, 0); + if (connect(client_fd, (struct sockaddr *)&address, sizeof(address)) < 0) + { + perror("socket"); + SOCKET_CLOSE(client_fd); + client_fd = -1; + } + + return client_fd; +} + +/************************************************************************** + * SSL Server Testing + * + **************************************************************************/ +typedef struct +{ + /* not used as yet */ + int dummy; +} SVR_CTX; + +typedef struct +{ + const char *testname; + const char *openssl_option; +} client_t; + +static void do_client(client_t *clnt) +{ + char openssl_buf[2048]; + usleep(200000); /* allow server to start */ + + /* show the session ids in the reconnect test */ + if (strcmp(clnt->testname, "Session Reuse") == 0) + { + sprintf(openssl_buf, "echo \"hello client\" | openssl s_client " + "-connect localhost:%d %s 2>&1 | grep \"Session-ID:\"", + g_port, clnt->openssl_option); + } + else if (strstr(clnt->testname, "GNUTLS") == NULL) + { + sprintf(openssl_buf, "echo \"hello client\" | openssl s_client " +#ifdef WIN32 + "-connect localhost:%d -quiet %s", +#else + "-connect localhost:%d -quiet %s > /dev/null 2>&1", +#endif + g_port, clnt->openssl_option); + } + else /* gnutls */ + { + sprintf(openssl_buf, "echo \"hello client\" | gnutls-cli " +#ifdef WIN32 + "-p %d %s localhost", +#else + "-p %d %s localhost > /dev/null 2>&1", +#endif + g_port, clnt->openssl_option); + } + +//printf("CLIENT %s\n", openssl_buf); + SYSTEM(openssl_buf); +} + +static int SSL_server_test( + const char *testname, + const char *openssl_option, + const char *device_cert, + const char *product_cert, + const char *private_key, + const char *ca_cert, + const char *password, + int axtls_option) +{ + int server_fd, ret = 0; + SSL_CTX *ssl_ctx = NULL; + struct sockaddr_in client_addr; + uint8_t *read_buf; + socklen_t clnt_len = sizeof(client_addr); + client_t client_data; +#ifndef WIN32 + pthread_t thread; +#endif + g_port++; + + client_data.testname = testname; + client_data.openssl_option = openssl_option; + + if ((server_fd = server_socket_init(&g_port)) < 0) + goto error; + + if (private_key) + { + axtls_option |= SSL_NO_DEFAULT_KEY; + } + + if ((ssl_ctx = ssl_ctx_new(axtls_option, SSL_DEFAULT_SVR_SESS)) == NULL) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + + if (private_key) + { + int obj_type = SSL_OBJ_RSA_KEY; + + if (strstr(private_key, ".p8")) + obj_type = SSL_OBJ_PKCS8; + else if (strstr(private_key, ".p12")) + obj_type = SSL_OBJ_PKCS12; + + if (ssl_obj_load(ssl_ctx, obj_type, private_key, password)) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + } + + if (device_cert) /* test chaining */ + { + if ((ret = ssl_obj_load(ssl_ctx, + SSL_OBJ_X509_CERT, device_cert, NULL)) != SSL_OK) + goto error; + } + + if (product_cert) /* test chaining */ + { + if ((ret = ssl_obj_load(ssl_ctx, + SSL_OBJ_X509_CERT, product_cert, NULL)) != SSL_OK) + goto error; + } + + if (ca_cert) /* test adding certificate authorities */ + { + if ((ret = ssl_obj_load(ssl_ctx, + SSL_OBJ_X509_CACERT, ca_cert, NULL)) != SSL_OK) + goto error; + } + +#ifndef WIN32 + pthread_create(&thread, NULL, + (void *(*)(void *))do_client, (void *)&client_data); + pthread_detach(thread); +#else + CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_client, + (LPVOID)&client_data, 0, NULL); +#endif + + for (;;) + { + int client_fd, size = 0; + SSL *ssl; + + /* Wait for a client to connect */ + if ((client_fd = accept(server_fd, + (struct sockaddr *)&client_addr, &clnt_len)) < 0) + { + ret = SSL_ERROR_SOCK_SETUP_FAILURE; + goto error; + } + + /* we are ready to go */ + ssl = ssl_server_new(ssl_ctx, client_fd); + while ((size = ssl_read(ssl, &read_buf)) == SSL_OK); + SOCKET_CLOSE(client_fd); + + if (size == SSL_CLOSE_NOTIFY) + { + /* do nothing */ + } + else if (size < SSL_OK) /* got some alert or something nasty */ + { + ret = size; + + if (ret == SSL_ERROR_CONN_LOST) + continue; + + break; /* we've got a problem */ + } + else /* looks more promising */ + { + if (strstr("hello client", (char *)read_buf) == NULL) + { + printf("SSL server test \"%s\" passed\n", testname); + TTY_FLUSH(); + ret = 0; + break; + } + } + + ssl_free(ssl); + } + + SOCKET_CLOSE(server_fd); + +error: + ssl_ctx_free(ssl_ctx); + return ret; +} + +int SSL_server_tests(void) +{ + int ret = -1; + struct stat stat_buf; + SVR_CTX svr_test_ctx; + memset(&svr_test_ctx, 0, sizeof(SVR_CTX)); + + printf("### starting server tests\n"); TTY_FLUSH(); + + /* Go through the algorithms */ + + /* + * TLS client hello + */ + + /* + * AES128-SHA TLS1.2 + */ + if ((ret = SSL_server_test("AES128-SHA TLS1.2", + "-cipher AES128-SHA -tls1_2", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES256-SHA TLS1.2 + */ + if ((ret = SSL_server_test("AES256-SHA TLS1.2", + "-cipher AES256-SHA -tls1_2", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES128-SHA256 TLS1.2 + */ + if ((ret = SSL_server_test("AES128-SHA256 TLS1.2", + "-cipher AES128-SHA256 -tls1_2", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + + /* + * AES256-SHA256 TLS1.2 + */ + if ((ret = SSL_server_test("AES256-SHA256 TLS1.2", + "-cipher AES256-SHA256 -tls1_2", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES128-SHA TLS1.1 + */ + if ((ret = SSL_server_test("AES128-SHA TLS1.1", + "-cipher AES128-SHA -tls1_1", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES128-SHA TLS1.0 + */ + if ((ret = SSL_server_test("AES128-SHA TLS1.0", + "-cipher AES128-SHA -tls1", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * Session Reuse + * all the session id's should match for session resumption. + */ + if ((ret = SSL_server_test("Session Reuse", + "-cipher AES128-SHA -reconnect -tls1_2", + DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, + DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * 1024 bit RSA key (check certificate chaining) + */ + if ((ret = SSL_server_test("1024 bit key", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_1024.cer", NULL, + "../ssl/test/axTLS.key_1024", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * 2048 bit RSA key + */ + if ((ret = SSL_server_test("2048 bit key", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_2048.cer", NULL, + "../ssl/test/axTLS.key_2048", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * 4096 bit RSA key + */ + if ((ret = SSL_server_test("4096 bit key", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_4096.cer", NULL, + "../ssl/test/axTLS.key_4096", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * RSA1024/SHA256 + */ + if ((ret = SSL_server_test("RSA1024/SHA256", + "-tls1_2", + "../ssl/test/axTLS.x509_1024_sha256.pem" , NULL, + "../ssl/test/axTLS.key_1024", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * RSA1024/SHA384 + */ + if ((ret = SSL_server_test("RSA1024/SHA384", + "-tls1_2", + "../ssl/test/axTLS.x509_1024_sha384.pem" , NULL, + "../ssl/test/axTLS.key_1024", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * RSA1024/SHA512 + */ + if ((ret = SSL_server_test("RSA1024/SHA512", + "-tls1_2", + "../ssl/test/axTLS.x509_1024_sha512.pem" , NULL, + "../ssl/test/axTLS.key_1024", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * Client Verification + */ + if ((ret = SSL_server_test("Client Verification TLS1.2", + "-cipher AES128-SHA -tls1_2 " + "-cert ../ssl/test/axTLS.x509_2048.pem " + "-key ../ssl/test/axTLS.key_2048.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + "../ssl/test/axTLS.ca_x509.cer", NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) + goto cleanup; + + if ((ret = SSL_server_test("Client Verification TLS1.1", + "-cipher AES128-SHA -tls1_1 " + "-cert ../ssl/test/axTLS.x509_2048.pem " + "-key ../ssl/test/axTLS.key_2048.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + "../ssl/test/axTLS.ca_x509.cer", NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) + goto cleanup; + + /* this test should fail */ + if (stat("../ssl/test/axTLS.x509_bad_before.pem", &stat_buf) >= 0) + { + if ((ret = SSL_server_test("Error: Bad Before Cert", + "-cipher AES128-SHA -tls1_2 " + "-cert ../ssl/test/axTLS.x509_bad_before.pem " + "-key ../ssl/test/axTLS.key_1024.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + "../ssl/test/axTLS.ca_x509.cer", NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != + SSL_X509_ERROR(X509_VFY_ERROR_NOT_YET_VALID)) + goto cleanup; + + printf("SSL server test \"%s\" passed\n", "Bad Before Cert"); + TTY_FLUSH(); + } + + /* this test should fail */ + if ((ret = SSL_server_test("Error: Bad After Cert", + "-cipher AES128-SHA -tls1_2 " + "-cert ../ssl/test/axTLS.x509_bad_after.pem " + "-key ../ssl/test/axTLS.key_1024.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + "../ssl/test/axTLS.ca_x509.cer", NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != + SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED)) + goto cleanup; + + printf("SSL server test \"%s\" passed\n", "Bad After Cert"); + TTY_FLUSH(); + + /* + * No trusted cert + */ + if ((ret = SSL_server_test("Error: No trusted certificate", + "-cipher AES128-SHA -tls1_2 " + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + NULL, NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != + SSL_X509_ERROR(X509_VFY_ERROR_NO_TRUSTED_CERT)) + goto cleanup; + + printf("SSL server test \"%s\" passed\n", "No trusted certificate"); + TTY_FLUSH(); + + /* + * Self-signed (from the server) + */ + if ((ret = SSL_server_test("Error: Self-signed certificate (from server)", + "-cipher AES128-SHA -tls1_2 " + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem " + "-CAfile ../ssl/test/axTLS.ca_x509.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + NULL, NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != + SSL_X509_ERROR(X509_VFY_ERROR_SELF_SIGNED)) + goto cleanup; + + printf("SSL server test \"%s\" passed\n", + "Self-signed certificate (from server)"); + TTY_FLUSH(); + + /* + * Self-signed (from the client) + */ + if ((ret = SSL_server_test("Self-signed certificate (from client)", + "-cipher AES128-SHA -tls1_2 " + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem ", + NULL, + "../ssl/test/axTLS.x509_1024.pem", + "../ssl/test/axTLS.key_1024.pem", + "../ssl/test/axTLS.ca_x509.cer", + NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) + goto cleanup; + + /* + * Key in PEM format + */ + if ((ret = SSL_server_test("Key in PEM format", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_1024.cer", NULL, + "../ssl/test/axTLS.key_1024.pem", NULL, + NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * Cert in PEM format + */ + if ((ret = SSL_server_test("Cert in PEM format", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_1024.pem", NULL, + "../ssl/test/axTLS.key_1024.pem", NULL, + NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * Cert chain in PEM format + */ + if ((ret = SSL_server_test("Cert chain in PEM format", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_device.pem", + NULL, "../ssl/test/axTLS.key_device.pem", + "../ssl/test/axTLS.ca_x509.pem", NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES128 Encrypted key + */ + if ((ret = SSL_server_test("AES128 encrypted key", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_aes128.pem", NULL, + "../ssl/test/axTLS.key_aes128.pem", + NULL, "abcd", DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES256 Encrypted key + */ + if ((ret = SSL_server_test("AES256 encrypted key", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_aes256.pem", NULL, + "../ssl/test/axTLS.key_aes256.pem", + NULL, "abcd", DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * AES128 Encrypted invalid key + */ + if ((ret = SSL_server_test("AES128 encrypted invalid key", + "-cipher AES128-SHA -tls1_2", + "../ssl/test/axTLS.x509_aes128.pem", NULL, + "../ssl/test/axTLS.key_aes128.pem", + NULL, "xyz", DEFAULT_SVR_OPTION)) != SSL_ERROR_INVALID_KEY) + goto cleanup; + + printf("SSL server test \"%s\" passed\n", "AES128 encrypted invalid key"); + TTY_FLUSH(); + + /* + * PKCS#8 key (encrypted) + */ + if ((ret = SSL_server_test("pkcs#8 encrypted", + "-cipher AES128-SHA -tls1_2", + DEFAULT_CERT, NULL, "../ssl/test/axTLS.encrypted.p8", + NULL, "abcd", DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * PKCS#8 key (unencrypted DER format) + */ + if ((ret = SSL_server_test("pkcs#8 DER unencrypted", + "-cipher AES128-SHA -tls1_2", + DEFAULT_CERT, NULL, "../ssl/test/axTLS.unencrypted.p8", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * PKCS#8 key (unencrypted PEM format) + */ + if ((ret = SSL_server_test("pkcs#8 PEM unencrypted", + "-cipher AES128-SHA -tls1_2", + DEFAULT_CERT, NULL, "../ssl/test/axTLS.unencrypted_pem.p8", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * PKCS#12 key/certificate + */ + if ((ret = SSL_server_test("pkcs#12 with CA", "-cipher AES128-SHA", + NULL, NULL, "../ssl/test/axTLS.withCA.p12", + NULL, "abcd", DEFAULT_SVR_OPTION))) + goto cleanup; + + if ((ret = SSL_server_test("pkcs#12 no CA", "-cipher AES128-SHA", + DEFAULT_CERT, NULL, "../ssl/test/axTLS.withoutCA.p12", + NULL, "abcd", DEFAULT_SVR_OPTION))) + goto cleanup; + + /* + * GNUTLS + */ + if ((ret = SSL_server_test("GNUTLS client", + "", + "../ssl/test/axTLS.x509_1024.cer", NULL, + "../ssl/test/axTLS.key_1024", + NULL, NULL, DEFAULT_SVR_OPTION))) + goto cleanup; + + if ((ret = SSL_server_test("GNUTLS client with verify", + "--x509certfile ../ssl/test/axTLS.x509_1024.pem " + "--x509keyfile ../ssl/test/axTLS.key_1024.pem", + "../ssl/test/axTLS.x509_1024.cer", NULL, + "../ssl/test/axTLS.key_1024", + "../ssl/test/axTLS.ca_x509.cer", NULL, + DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) + goto cleanup; + ret = 0; + +cleanup: + if (ret) + { + printf("Error: A server test failed\n"); + ssl_display_error(ret); + exit(1); + } + else + { + printf("All server tests passed\n"); TTY_FLUSH(); + } + + return ret; +} + +/************************************************************************** + * SSL Client Testing + * + **************************************************************************/ +typedef struct +{ + uint8_t session_id[SSL_SESSION_ID_SIZE]; +#ifndef WIN32 + pthread_t server_thread; +#endif + int start_server; + int stop_server; + int do_reneg; +} CLNT_SESSION_RESUME_CTX; + +typedef struct +{ + const char *testname; + const char *openssl_option; + int do_gnutls; +} server_t; + +static void do_server(server_t *svr) +{ + char openssl_buf[2048]; +#ifndef WIN32 + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); +#endif + if (svr->do_gnutls) + { + sprintf(openssl_buf, "gnutls-serv " + "-p %d --quiet %s ", g_port, svr->openssl_option); + } + else + { + sprintf(openssl_buf, "openssl s_server " +#ifdef WIN32 + "-accept %d -quiet %s", +#else + "-accept %d -quiet %s > /dev/null", +#endif + g_port, svr->openssl_option); + } +//printf("SERVER %s\n", openssl_buf); + SYSTEM(openssl_buf); +} + +static int SSL_client_test( + const char *test, + SSL_CTX **ssl_ctx, + const char *openssl_option, + CLNT_SESSION_RESUME_CTX *sess_resume, + uint32_t client_options, + const char *private_key, + const char *password, + const char *cert) +{ + server_t server_data; + SSL *ssl = NULL; + int client_fd = -1; + uint8_t *session_id = NULL; + int ret = 1; +#ifndef WIN32 + pthread_t thread; +#endif + + server_data.do_gnutls = strstr(test, "GNUTLS") != NULL; + + if (sess_resume == NULL || sess_resume->start_server) + { + g_port++; + server_data.openssl_option = openssl_option; + +#ifndef WIN32 + pthread_create(&thread, NULL, + (void *(*)(void *))do_server, (void *)&server_data); + pthread_detach(thread); +#else + CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_server, + (LPVOID)&server_data, 0, NULL); +#endif + } + + usleep(200000); /* allow server to start */ + + if (*ssl_ctx == NULL) + { + if (private_key) + { + client_options |= SSL_NO_DEFAULT_KEY; + } + + if ((*ssl_ctx = ssl_ctx_new( + client_options, SSL_DEFAULT_CLNT_SESS)) == NULL) + { + ret = SSL_ERROR_INVALID_KEY; + goto client_test_exit; + } + + if (private_key) + { + int obj_type = SSL_OBJ_RSA_KEY; + + if (strstr(private_key, ".p8")) + obj_type = SSL_OBJ_PKCS8; + else if (strstr(private_key, ".p12")) + obj_type = SSL_OBJ_PKCS12; + + if (ssl_obj_load(*ssl_ctx, obj_type, private_key, password)) + { + ret = SSL_ERROR_INVALID_KEY; + goto client_test_exit; + } + } + + if (cert) + { + if ((ret = ssl_obj_load(*ssl_ctx, + SSL_OBJ_X509_CERT, cert, NULL)) != SSL_OK) + { + printf("could not add cert %s (%d)\n", cert, ret); + TTY_FLUSH(); + goto client_test_exit; + } + } + + if (ssl_obj_load(*ssl_ctx, SSL_OBJ_X509_CACERT, + "../ssl/test/axTLS.ca_x509.cer", NULL)) + { + printf("could not add cert auth\n"); TTY_FLUSH(); + goto client_test_exit; + } + } + + if (sess_resume && !sess_resume->start_server) + { + session_id = sess_resume->session_id; + } + + if ((client_fd = client_socket_init(g_port)) < 0) + { + printf("could not start socket on %d\n", g_port); TTY_FLUSH(); + goto client_test_exit; + } + + ssl = ssl_client_new(*ssl_ctx, client_fd, + session_id, sizeof(session_id), NULL); + + /* check the return status */ + if ((ret = ssl_handshake_status(ssl))) + goto client_test_exit; + + /* renegotiate client */ + if (sess_resume && sess_resume->do_reneg) + { + if (ssl_renegotiate(ssl) == -SSL_ALERT_NO_RENEGOTIATION) + ret = 0; + else + ret = -SSL_ALERT_NO_RENEGOTIATION; + + goto client_test_exit; + } + + if (sess_resume) + { + memcpy(sess_resume->session_id, + ssl_get_session_id(ssl), SSL_SESSION_ID_SIZE); + } + + if (IS_SET_SSL_FLAG(SSL_SERVER_VERIFY_LATER) && + (ret = ssl_verify_cert(ssl))) + { + goto client_test_exit; + } + + ssl_write(ssl, (uint8_t *)"hello world\n", 13); + if (sess_resume) + { + const uint8_t *sess_id = ssl_get_session_id(ssl); + int i; + + printf(" Session-ID: "); + for (i = 0; i < SSL_SESSION_ID_SIZE; i++) + { + printf("%02X", sess_id[i]); + } + printf("\n"); + TTY_FLUSH(); + } + + ret = 0; + +client_test_exit: + ssl_free(ssl); + SOCKET_CLOSE(client_fd); + usleep(200000); /* allow openssl to say something */ + + if (sess_resume) + { + if (sess_resume->stop_server) + { + ssl_ctx_free(*ssl_ctx); + *ssl_ctx = NULL; + } + else if (sess_resume->start_server) + { +#ifndef WIN32 + sess_resume->server_thread = thread; +#endif + } + } + else + { + ssl_ctx_free(*ssl_ctx); + *ssl_ctx = NULL; + } + + if (ret == 0) + { + printf("SSL client test \"%s\" passed\n", test); + TTY_FLUSH(); + } + + return ret; +} + +int SSL_client_tests(void) +{ + int ret = -1; + SSL_CTX *ssl_ctx = NULL; + CLNT_SESSION_RESUME_CTX sess_resume; + memset(&sess_resume, 0, sizeof(CLNT_SESSION_RESUME_CTX)); + + sess_resume.start_server = 1; + printf("### starting client tests\n"); + + if ((ret = SSL_client_test("1024 bit key", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem", + &sess_resume, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + /* all the session id's should match for session resumption */ + sess_resume.start_server = 0; + if ((ret = SSL_client_test("Client session resumption #1", + &ssl_ctx, NULL, &sess_resume, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + // no client renegotiation + sess_resume.do_reneg = 1; + // test relies on openssl killing the call + if ((ret = SSL_client_test("Client renegotiation", + &ssl_ctx, NULL, &sess_resume, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + sess_resume.do_reneg = 0; + + sess_resume.stop_server = 1; + if ((ret = SSL_client_test("Client session resumption #2", + &ssl_ctx, NULL, &sess_resume, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("1024 bit key", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("2048 bit key", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_2048.pem " + "-key ../ssl/test/axTLS.key_2048.pem", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("4096 bit key", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_4096.pem " + "-key ../ssl/test/axTLS.key_4096.pem", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("TLS 1.1", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem -tls1_1", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("TLS 1.0", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_1024.pem " + "-key ../ssl/test/axTLS.key_1024.pem -tls1", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("Basic Constraint - len OK", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_end_chain.pem -key " + "../ssl/test/axTLS.key_end_chain.pem -CAfile " + "../ssl/test/axTLS.x509_intermediate_ca.pem", + NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + if ((ret = SSL_client_test("Basic Constraint - len NOT OK", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_end_chain_bad.pem -key " + "../ssl/test/axTLS.key_end_chain.pem -CAfile " + "../ssl/test/axTLS.x509_intermediate_ca2.pem", + NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL)) + != SSL_X509_ERROR(X509_VFY_ERROR_BASIC_CONSTRAINT)) + { + printf("*** Error: %d\n", ret); + if (ret == 0) + ret = SSL_NOT_OK; + + goto cleanup; + } + + printf("SSL server test \"%s\" passed\n", "Basic Constraint - len NOT OK"); + + if ((ret = SSL_client_test("Server cert chaining", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_device.pem " + "-key ../ssl/test/axTLS.key_device.pem " + "-CAfile ../ssl/test/axTLS.x509_1024.pem ", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) + goto cleanup; + + /* Check the server can verify the client */ + if ((ret = SSL_client_test("Client peer authentication", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_2048.pem " + "-key ../ssl/test/axTLS.key_2048.pem " + "-CAfile ../ssl/test/axTLS.ca_x509.pem " + "-verify 1 ", NULL, DEFAULT_CLNT_OPTION, + "../ssl/test/axTLS.key_1024", NULL, + "../ssl/test/axTLS.x509_1024.cer"))) + goto cleanup; + + /* Check the server can verify the client */ + if ((ret = SSL_client_test("Client peer authentication TLS1.1", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_2048.pem " + "-key ../ssl/test/axTLS.key_2048.pem " + "-CAfile ../ssl/test/axTLS.ca_x509.pem " + "-verify 1 -tls1_1", NULL, DEFAULT_CLNT_OPTION, + "../ssl/test/axTLS.key_1024", NULL, + "../ssl/test/axTLS.x509_1024.cer"))) + goto cleanup; + + /* Should get an "ERROR" from openssl (as the handshake fails as soon as + * the certificate verification fails) */ + if ((ret = SSL_client_test("Error: Expired cert (verify now)", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_bad_after.pem " + "-key ../ssl/test/axTLS.key_1024.pem", NULL, + DEFAULT_CLNT_OPTION, NULL, NULL, NULL)) != + SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED)) + { + printf("*** Error: %d\n", ret); + goto cleanup; + } + + printf("SSL client test \"Expired cert (verify now)\" passed\n"); + + /* There is no "ERROR" from openssl */ + if ((ret = SSL_client_test("Error: Expired cert (verify later)", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_bad_after.pem " + "-key ../ssl/test/axTLS.key_1024.pem", NULL, + DEFAULT_CLNT_OPTION|SSL_SERVER_VERIFY_LATER, NULL, + NULL, NULL)) != SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED)) + { + printf("*** Error: %d\n", ret); TTY_FLUSH(); + goto cleanup; + } + + printf("SSL client test \"Expired cert (verify later)\" passed\n"); + + /* invalid cert type */ + /*if ((ret = SSL_client_test("Error: Invalid certificate type", + &ssl_ctx, + "-cert ../ssl/test/axTLS.x509_2048.pem " + "-key ../ssl/test/axTLS.key_2048.pem " + "-CAfile ../ssl/test/axTLS.ca_x509.pem " + "-verify 1 ", NULL, DEFAULT_CLNT_OPTION, + "../ssl/test/axTLS.key_1024.pem", NULL, + "../ssl/test/axTLS.x509_1024.pem")) + != SSL_ERROR_INVALID_KEY) + { + if (ret == 0) + ret = SSL_NOT_OK; + + printf("*** Error: %d\n", ret); TTY_FLUSH(); + goto cleanup; + } + + printf("SSL client test \"Invalid certificate type\" passed\n"); */ + + if ((ret = SSL_client_test("GNUTLS client", + &ssl_ctx, + "--x509certfile ../ssl/test/axTLS.x509_1024.pem " + "--x509keyfile ../ssl/test/axTLS.key_1024.pem -g", NULL, + DEFAULT_CLNT_OPTION, + "../ssl/test/axTLS.key_1024.pem", NULL, + "../ssl/test/axTLS.x509_1024.pem"))) + goto cleanup; + + ret = 0; + + if ((ret = SSL_client_test("GNUTLS client with verify", + &ssl_ctx, + "--x509certfile ../ssl/test/axTLS.x509_1024.pem " + "--x509keyfile ../ssl/test/axTLS.key_1024.pem -r -g", NULL, + DEFAULT_CLNT_OPTION|SSL_SERVER_VERIFY_LATER, + "../ssl/test/axTLS.key_1024.pem", NULL, + "../ssl/test/axTLS.x509_1024.pem"))) + goto cleanup; + + ret = 0; + +cleanup: + if (ret) + { + ssl_display_error(ret); + printf("Error: A client test failed\n"); + SYSTEM("sh ../ssl/test/killopenssl.sh"); + SYSTEM("sh ../ssl/test/killgnutls.sh"); + exit(1); + } + else + { + printf("All client tests passed\n"); TTY_FLUSH(); + } + + ssl_ctx_free(ssl_ctx); + return ret; +} + +/************************************************************************** + * SSL Basic Testing (test a big packet handshake) + * + **************************************************************************/ +static uint8_t basic_buf[256*1024]; + +static void do_basic(void) +{ + int client_fd; + SSL *ssl_clnt; + SSL_CTX *ssl_clnt_ctx = ssl_ctx_new( + DEFAULT_CLNT_OPTION, SSL_DEFAULT_CLNT_SESS); + usleep(200000); /* allow server to start */ + + if ((client_fd = client_socket_init(g_port)) < 0) + goto error; + + if (ssl_obj_load(ssl_clnt_ctx, SSL_OBJ_X509_CACERT, + "../ssl/test/axTLS.ca_x509.cer", NULL)) + goto error; + + ssl_clnt = ssl_client_new(ssl_clnt_ctx, client_fd, NULL, 0, NULL); + + /* check the return status */ + if (ssl_handshake_status(ssl_clnt) < 0) + { + ssl_display_error(ssl_handshake_status(ssl_clnt)); + goto error; + } + + ssl_write(ssl_clnt, basic_buf, sizeof(basic_buf)); + ssl_free(ssl_clnt); + +error: + ssl_ctx_free(ssl_clnt_ctx); + SOCKET_CLOSE(client_fd); + + /* exit this thread */ +} + +static int SSL_basic_test(void) +{ + int server_fd, client_fd, ret = 0, size = 0, offset = 0; + SSL_CTX *ssl_svr_ctx = NULL; + struct sockaddr_in client_addr; + uint8_t *read_buf; + socklen_t clnt_len = sizeof(client_addr); + SSL *ssl_svr; +#ifndef WIN32 + pthread_t thread; +#endif + memset(basic_buf, 0xA5, sizeof(basic_buf)/2); + memset(&basic_buf[sizeof(basic_buf)/2], 0x5A, sizeof(basic_buf)/2); + + if ((server_fd = server_socket_init(&g_port)) < 0) + goto error; + + ssl_svr_ctx = ssl_ctx_new(DEFAULT_SVR_OPTION, SSL_DEFAULT_SVR_SESS); + if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_X509_CERT, + "../ssl/test/axTLS.x509_1024.pem", NULL)) != SSL_OK) + goto error; + + if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_RSA_KEY, + "../ssl/test/axTLS.key_1024.pem", NULL)) != SSL_OK) + goto error; +#ifndef WIN32 + pthread_create(&thread, NULL, + (void *(*)(void *))do_basic, NULL); + pthread_detach(thread); +#else + CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_basic, NULL, 0, NULL); +#endif + + /* Wait for a client to connect */ + if ((client_fd = accept(server_fd, + (struct sockaddr *) &client_addr, &clnt_len)) < 0) + { + ret = SSL_ERROR_SOCK_SETUP_FAILURE; + goto error; + } + + /* we are ready to go */ + ssl_svr = ssl_server_new(ssl_svr_ctx, client_fd); + + do + { + while ((size = ssl_read(ssl_svr, &read_buf)) == SSL_OK); + + if (size < SSL_OK) /* got some alert or something nasty */ + { + ssl_display_error(size); + ret = size; + break; + } + else /* looks more promising */ + { + if (memcmp(read_buf, &basic_buf[offset], size) != 0) + { + ret = SSL_NOT_OK; + break; + } + } + + offset += size; + } while (offset < sizeof(basic_buf)); + + printf(ret == SSL_OK && offset == sizeof(basic_buf) ? + "SSL basic test passed\n" : + "SSL basic test failed\n"); + TTY_FLUSH(); + + ssl_free(ssl_svr); + SOCKET_CLOSE(server_fd); + SOCKET_CLOSE(client_fd); + +error: + ssl_ctx_free(ssl_svr_ctx); + return ret; +} + +/************************************************************************** + * SSL unblocked case + * + **************************************************************************/ +static void do_unblocked(void) +{ + int client_fd; + SSL *ssl_clnt; + SSL_CTX *ssl_clnt_ctx = ssl_ctx_new( + DEFAULT_CLNT_OPTION, + SSL_DEFAULT_CLNT_SESS | + SSL_CONNECT_IN_PARTS); + usleep(200000); /* allow server to start */ + + if ((client_fd = client_socket_init(g_port)) < 0) + goto error; + + { +#ifdef WIN32 + u_long argp = 1; + ioctlsocket(client_fd, FIONBIO, &argp); +#else + int flags = fcntl(client_fd, F_GETFL, NULL); + fcntl(client_fd, F_SETFL, flags | O_NONBLOCK); +#endif + } + + if (ssl_obj_load(ssl_clnt_ctx, SSL_OBJ_X509_CACERT, + "../ssl/test/axTLS.ca_x509.cer", NULL)) + goto error; + + ssl_clnt = ssl_client_new(ssl_clnt_ctx, client_fd, NULL, 0, NULL); + + while (ssl_handshake_status(ssl_clnt) != SSL_OK) + { + if (ssl_read(ssl_clnt, NULL) < 0) + { + ssl_display_error(ssl_handshake_status(ssl_clnt)); + goto error; + } + } + + ssl_write(ssl_clnt, basic_buf, sizeof(basic_buf)); + ssl_free(ssl_clnt); + +error: + ssl_ctx_free(ssl_clnt_ctx); + SOCKET_CLOSE(client_fd); + + /* exit this thread */ +} + +static int SSL_unblocked_test(void) +{ + int server_fd, client_fd, ret = 0, size = 0, offset = 0; + SSL_CTX *ssl_svr_ctx = NULL; + struct sockaddr_in client_addr; + uint8_t *read_buf; + socklen_t clnt_len = sizeof(client_addr); + SSL *ssl_svr; +#ifndef WIN32 + pthread_t thread; +#endif + memset(basic_buf, 0xA5, sizeof(basic_buf)/2); + memset(&basic_buf[sizeof(basic_buf)/2], 0x5A, sizeof(basic_buf)/2); + + if ((server_fd = server_socket_init(&g_port)) < 0) + goto error; + + ssl_svr_ctx = ssl_ctx_new(DEFAULT_SVR_OPTION, SSL_DEFAULT_SVR_SESS); + if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_X509_CERT, + "../ssl/test/axTLS.x509_1024.pem", NULL)) != SSL_OK) + goto error; + + if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_RSA_KEY, + "../ssl/test/axTLS.key_1024.pem", NULL)) != SSL_OK) + goto error; + +#ifndef WIN32 + pthread_create(&thread, NULL, + (void *(*)(void *))do_unblocked, NULL); + pthread_detach(thread); +#else + CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_unblocked, + NULL, 0, NULL); +#endif + + /* Wait for a client to connect */ + if ((client_fd = accept(server_fd, + (struct sockaddr *) &client_addr, &clnt_len)) < 0) + { + ret = SSL_ERROR_SOCK_SETUP_FAILURE; + goto error; + } + + /* we are ready to go */ + ssl_svr = ssl_server_new(ssl_svr_ctx, client_fd); + + do + { + while ((size = ssl_read(ssl_svr, &read_buf)) == SSL_OK); + + if (size < SSL_OK) /* got some alert or something nasty */ + { + ssl_display_error(size); + ret = size; + break; + } + else /* looks more promising */ + { + if (memcmp(read_buf, &basic_buf[offset], size) != 0) + { + ret = SSL_NOT_OK; + break; + } + } + + offset += size; + } while (offset < sizeof(basic_buf)); + + printf(ret == SSL_OK && offset == sizeof(basic_buf) ? + "SSL unblocked test passed\n" : + "SSL unblocked test failed\n"); + TTY_FLUSH(); + + ssl_free(ssl_svr); + SOCKET_CLOSE(server_fd); + SOCKET_CLOSE(client_fd); + +error: + ssl_ctx_free(ssl_svr_ctx); + return ret; +} + +#if !defined(WIN32) && defined(CONFIG_SSL_CTX_MUTEXING) +/************************************************************************** + * Multi-Threading Tests + * + **************************************************************************/ +#define NUM_THREADS 100 + +typedef struct +{ + SSL_CTX *ssl_clnt_ctx; + int port; + int thread_id; +} multi_t; + +void do_multi_clnt(multi_t *multi_data) +{ + int res = 1, client_fd, i; + SSL *ssl = NULL; + char tmp[5]; + + if ((client_fd = client_socket_init(multi_data->port)) < 0) + goto client_test_exit; + + usleep(200000); + ssl = ssl_client_new(multi_data->ssl_clnt_ctx, client_fd, NULL, 0, NULL); + + if ((res = ssl_handshake_status(ssl))) + { + printf("Client "); + ssl_display_error(res); + goto client_test_exit; + } + + sprintf(tmp, "%d\n", multi_data->thread_id); + for (i = 0; i < 10; i++) + ssl_write(ssl, (uint8_t *)tmp, strlen(tmp)+1); + +client_test_exit: + ssl_free(ssl); + SOCKET_CLOSE(client_fd); + free(multi_data); +} + +void do_multi_svr(SSL *ssl) +{ + uint8_t *read_buf; + int *res_ptr = malloc(sizeof(int)); + int res; + + for (;;) + { + res = ssl_read(ssl, &read_buf); + + /* kill the client */ + if (res != SSL_OK) + { + if (res == SSL_ERROR_CONN_LOST) + { + SOCKET_CLOSE(ssl->client_fd); + ssl_free(ssl); + break; + } + else if (res > 0) + { + /* do nothing */ + } + else /* some problem */ + { + printf("Server "); + ssl_display_error(res); + goto error; + } + } + } + + res = SSL_OK; +error: + *res_ptr = res; + pthread_exit(res_ptr); +} + +int multi_thread_test(void) +{ + int server_fd = -1; + SSL_CTX *ssl_server_ctx; + SSL_CTX *ssl_clnt_ctx; + pthread_t clnt_threads[NUM_THREADS]; + pthread_t svr_threads[NUM_THREADS]; + int i, res = 0; + struct sockaddr_in client_addr; + socklen_t clnt_len = sizeof(client_addr); + + printf("Do multi-threading test (takes a minute)\n"); + + ssl_svr_ctx = ssl_ctx_new(DEFAULT_SVR_OPTION, SSL_DEFAULT_SVR_SESS); + if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_X509_CERT, + "../ssl/test/axTLS.x509_1024.pem", NULL)) != SSL_OK) + goto error; + + if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_RSA_KEY, + "../ssl/test/axTLS.key_1024.pem", NULL)) != SSL_OK) + goto error; + ssl_clnt_ctx = ssl_ctx_new(DEFAULT_CLNT_OPTION, SSL_DEFAULT_CLNT_SESS); + + if (ssl_obj_load(ssl_clnt_ctx, SSL_OBJ_X509_CACERT, + "../ssl/test/axTLS.ca_x509.cer", NULL)) + goto error; + + if ((server_fd = server_socket_init(&g_port)) < 0) + goto error; + + for (i = 0; i < NUM_THREADS; i++) + { + multi_t *multi_data = (multi_t *)malloc(sizeof(multi_t)); + multi_data->ssl_clnt_ctx = ssl_clnt_ctx; + multi_data->port = g_port; + multi_data->thread_id = i+1; + pthread_create(&clnt_threads[i], NULL, + (void *(*)(void *))do_multi_clnt, (void *)multi_data); + pthread_detach(clnt_threads[i]); + } + + for (i = 0; i < NUM_THREADS; i++) + { + SSL *ssl_svr; + int client_fd = accept(server_fd, + (struct sockaddr *)&client_addr, &clnt_len); + + if (client_fd < 0) + goto error; + + ssl_svr = ssl_server_new(ssl_server_ctx, client_fd); + + pthread_create(&svr_threads[i], NULL, + (void *(*)(void *))do_multi_svr, (void *)ssl_svr); + } + + /* make sure we've run all of the threads */ + for (i = 0; i < NUM_THREADS; i++) + { + void *thread_res; + pthread_join(svr_threads[i], &thread_res); + + if (*((int *)thread_res) != 0) + res = 1; + + free(thread_res); + } + + if (res) + goto error; + + printf("Multi-thread test passed (%d)\n", NUM_THREADS); +error: + ssl_ctx_free(ssl_svr_ctx); + ssl_ctx_free(ssl_clnt_ctx); + SOCKET_CLOSE(server_fd); + return res; +} +#endif /* !defined(WIN32) && defined(CONFIG_SSL_CTX_MUTEXING) */ + +/************************************************************************** + * Header issue + * + **************************************************************************/ +//static void do_header_issue(void) +//{ +// char axtls_buf[2048]; +//#ifndef WIN32 +// pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); +//#endif +// sprintf(axtls_buf, "./axssl s_client -connect localhost:%d", g_port); +// SYSTEM(axtls_buf); +//} +// +//static int header_issue(void) +//{ +// FILE *f = fopen("../ssl/test/header_issue.dat", "r"); +// int server_fd = -1, client_fd = -1, ret = 1; +// uint8_t buf[2048]; +// int size = 0; +// struct sockaddr_in client_addr; +// socklen_t clnt_len = sizeof(client_addr); +//#ifndef WIN32 +// pthread_t thread; +//#endif +// +// if (f == NULL || (server_fd = server_socket_init(&g_port)) < 0) +// goto error; +// +//#ifndef WIN32 +// pthread_create(&thread, NULL, +// (void *(*)(void *))do_header_issue, NULL); +// pthread_detach(thread); +//#else +// CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_header_issue, +// NULL, 0, NULL); +//#endif +// if ((client_fd = accept(server_fd, +// (struct sockaddr *) &client_addr, &clnt_len)) < 0) +// { +// ret = SSL_ERROR_SOCK_SETUP_FAILURE; +// goto error; +// } +// +// size = fread(buf, 1, sizeof(buf), f); +// if (SOCKET_WRITE(client_fd, buf, size) < 0) +// { +// ret = SSL_ERROR_SOCK_SETUP_FAILURE; +// goto error; +// } +// +// usleep(200000); +// +// ret = 0; +//error: +// fclose(f); +// SOCKET_CLOSE(client_fd); +// SOCKET_CLOSE(server_fd); +// TTY_FLUSH(); +// SYSTEM("killall axssl"); +// return ret; +//} + +/************************************************************************** + * main() + * + **************************************************************************/ +int main(int argc, char *argv[]) +{ + int ret = 1; + BI_CTX *bi_ctx; + int fd; + +#ifdef WIN32 + WSADATA wsaData; + WORD wVersionRequested = MAKEWORD(2, 2); + WSAStartup(wVersionRequested, &wsaData); + fd = _open("test_result.txt", O_WRONLY|O_TEMPORARY|O_CREAT, _S_IWRITE); + dup2(fd, 2); /* write stderr to this file */ +#else + fd = open("/dev/null", O_WRONLY); /* write stderr to /dev/null */ + signal(SIGPIPE, SIG_IGN); /* ignore pipe errors */ + dup2(fd, 2); +#endif + + /* can't do testing in this mode */ +#if defined CONFIG_SSL_GENERATE_X509_CERT + printf("Error: Must compile with default key/certificates\n"); + exit(1); +#endif + + bi_ctx = bi_initialize(); + + if (AES_test(bi_ctx)) + { + printf("AES tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (MD5_test(bi_ctx)) + { + printf("MD5 tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (SHA1_test(bi_ctx)) + { + printf("SHA1 tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (SHA256_test(bi_ctx)) + { + printf("SHA256 tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (SHA384_test(bi_ctx)) + { + printf("SHA384 tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (SHA512_test(bi_ctx)) + { + printf("SHA512 tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (HMAC_test(bi_ctx)) + { + printf("HMAC tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (BIGINT_test(bi_ctx)) + { + printf("BigInt tests failed!\n"); + goto cleanup; + } + TTY_FLUSH(); + + bi_terminate(bi_ctx); + + if (RSA_test()) + { + printf("RSA tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + + if (cert_tests()) + { + printf("CERT tests failed\n"); + goto cleanup; + } + TTY_FLUSH(); + +#if !defined(WIN32) && defined(CONFIG_SSL_CTX_MUTEXING) + if (multi_thread_test()) + goto cleanup; +#endif + + if (SSL_basic_test()) + goto cleanup; + + SYSTEM("sh ../ssl/test/killopenssl.sh"); + + if (SSL_unblocked_test()) + goto cleanup; + + SYSTEM("sh ../ssl/test/killopenssl.sh"); + + if (SSL_client_tests()) + goto cleanup; + + SYSTEM("sh ../ssl/test/killopenssl.sh"); + SYSTEM("sh ../ssl/test/killgnutls.sh"); + + if (SSL_server_tests()) + goto cleanup; + + SYSTEM("sh ../ssl/test/killopenssl.sh"); + +// if (header_issue()) +// { +// printf("Header tests failed\n"); TTY_FLUSH(); +// goto cleanup; +// } + + ret = 0; /* all ok */ + printf("**** ALL TESTS PASSED ****\n"); TTY_FLUSH(); +cleanup: + + if (ret) + printf("Error: Some tests failed!\n"); + + close(fd); + return ret; +} diff --git a/user/mpy/lib/axtls/ssl/test/test_axssl.sh b/user/mpy/lib/axtls/ssl/test/test_axssl.sh new file mode 100755 index 0000000..acf11a6 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/test/test_axssl.sh @@ -0,0 +1,163 @@ +#!/bin/sh + +# +# Copyright (c) 2007, Cameron Rich +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the axTLS project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# Test the various axssl bindings. To run it, got to the _install directory +# and run this script from there. +# + +if grep "CONFIG_PLATFORM_WIN32=y" "../config/.config" > /dev/null; then + JAVA_EXE="$JAVA_HOME/bin/java.exe" + PERL_BIN="/cygdrive/c/Perl/bin/perl" + KILL_AXSSL="kill %1" + KILL_CSHARP="kill %1" + KILL_PERL="kill %1" + KILL_JAVA="kill %1" + KILL_LUA="kill %1" +else + if grep "CONFIG_PLATFORM_CYGWIN=y" "../config/.config" > /dev/null; then + # no .net or java on cygwin + PERL_BIN=/usr/bin/perl + KILL_AXSSL="killall axssl" + KILL_PERL="killall /usr/bin/perl" + KILL_LUA="killall /usr/local/bin/lua" + else # Linux + JAVA_EXE=/usr/java/default/bin/java + PERL_BIN=/usr/bin/perl + KILL_AXSSL="killall axssl" + KILL_CSHARP="killall mono" + KILL_PERL="killall /usr/bin/perl" + RUN_CSHARP="mono" + KILL_JAVA="killall $JAVA_EXE" + KILL_LUA="killall /usr/local/bin/lua" + fi +fi + +BASE=.. +SERVER_ARGS="s_server -accept 15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer" +CLIENT_ARGS="s_client -reconnect -connect localhost:15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer -key $BASE/ssl/test/axTLS.key_1024 -cert $BASE/ssl/test/axTLS.x509_1024.cer" + +# check pem arguments +SERVER_PEM_ARGS="s_server -accept 15001 -pass abcd -key $BASE/ssl/test/axTLS.key_aes128.pem -cert $BASE/ssl/test/axTLS.x509_aes128.pem" +CLIENT_PEM_ARGS="s_client -connect localhost:15001 -CAfile $BASE/ssl/test/axTLS.ca_x509.pem -key $BASE/ssl/test/axTLS.key_1024.pem -cert $BASE/ssl/test/axTLS.x509_1024.pem" + +export LD_LIBRARY_PATH=.:`perl -e 'use Config; print $Config{archlib};'`/CORE + +if [ -x ./axssl ]; then +echo "############################# C SAMPLE ###########################" +./axssl $SERVER_ARGS & +echo "C Test passed" | ./axssl $CLIENT_ARGS +$KILL_AXSSL +sleep 1 + +./axssl $SERVER_PEM_ARGS & +echo "C Test passed" | ./axssl $CLIENT_PEM_ARGS +$KILL_AXSSL +sleep 1 +echo "### C tests complete" +fi + +if [ -f ./axtls.jar ]; then +echo "########################## JAVA SAMPLE ###########################" +"$JAVA_EXE" -jar ./axtls.jar $SERVER_ARGS & +echo "Java Test passed" | "$JAVA_EXE" -jar ./axtls.jar $CLIENT_ARGS +$KILL_JAVA +sleep 1 + +"$JAVA_EXE" -jar ./axtls.jar $SERVER_PEM_ARGS & +echo "Java Test passed" | "$JAVA_EXE" -jar ./axtls.jar $CLIENT_PEM_ARGS +$KILL_JAVA +sleep 1 + +echo "### Java tests complete" +fi + +if [ -x ./axssl.csharp.exe ]; then +echo "############################ C# SAMPLE ###########################" +$RUN_CSHARP ./axssl.csharp.exe $SERVER_ARGS & +echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_ARGS +$KILL_CSHARP +sleep 1 + +$RUN_CSHARP ./axssl.csharp.exe $SERVER_PEM_ARGS & +echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_PEM_ARGS +$KILL_CSHARP +sleep 1 + +echo "### C# tests complete" +fi + +if [ -x ./axssl.vbnet.exe ]; then +echo "######################## VB.NET SAMPLE ###########################" +echo $SERVER_ARGS +echo $CLIENT_ARGS +./axssl.vbnet $SERVER_ARGS & +echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_ARGS +kill %1 +sleep 1 + +./axssl.vbnet $SERVER_PEM_ARGS & +echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_PEM_ARGS +kill %1 +sleep 1 +echo "### VB.NET tests complete" +fi + +if [ -f ./axssl.pl ]; then +echo "########################## PERL SAMPLE ###########################" +"$PERL_BIN" ./axssl.pl $SERVER_ARGS & +echo "Perl Test passed" | "$PERL_BIN" ./axssl.pl $CLIENT_ARGS +$KILL_PERL +sleep 1 + +"$PERL_BIN" ./axssl.pl $SERVER_PEM_ARGS & +echo "Perl Test passed" | "$PERL_BIN" ./axssl.pl $CLIENT_PEM_ARGS +$KILL_PERL +sleep 1 +echo "### Perl tests complete" +fi + +if [ -f ./axssl.lua ]; then +echo "########################## LUA SAMPLE ###########################" +./axssl.lua $SERVER_ARGS & +echo "Lua Test passed" | ./axssl.lua $CLIENT_ARGS +$KILL_LUA +sleep 1 + +./axssl.lua $SERVER_PEM_ARGS & +echo "Lua Test passed" | ./axssl.lua $CLIENT_PEM_ARGS +$KILL_LUA +sleep 1 +echo "### Lua tests complete" +fi + +echo "########################## ALL TESTS COMPLETE ###########################" diff --git a/user/mpy/lib/axtls/ssl/test/thawte.x509_ca b/user/mpy/lib/axtls/ssl/test/thawte.x509_ca new file mode 100644 index 0000000000000000000000000000000000000000..59b1059f84086fa580dc1001303c4db4e070e572 GIT binary patch literal 811 zcmXqLVpcb3Vw$jknTe5!iILHOmyJ`a&71aK>;=YaCsSi1!zDAbtnTZF zqUYUebWG~Ec<0FydhNn{8R@BF?(Zc$Os#^xXlJqYTkF3Hd%V7_cb@q7d0SFTnS9@$ z=3Jy0cw_d3^b5OqC$WhXUzvP*x)#Hn7(bppzeI!nd~(UVCFqsMF<)Qz@y}IOZN=N% zf+J3JvhHmb+)-@5ioN%XlkanfxiaQV%!~|-i-ipY4fugEEGx{&_@9N=wue#B(wSB};{CmAjN`|kTB z=H&c*ca+=jgU1BrKYDG@a65VUh*RyJU#lbYu5J(P5PZC(RWiHDX9 +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +/* The session expiry time */ +#define SSL_EXPIRY_TIME (CONFIG_SSL_EXPIRY_TIME*3600) + +static const uint8_t g_hello_request[] = { HS_HELLO_REQUEST, 0, 0, 0 }; +static const uint8_t g_chg_cipher_spec_pkt[] = { 1 }; +static const char * server_finished = "server finished"; +static const char * client_finished = "client finished"; + +static int do_handshake(SSL *ssl, uint8_t *buf, int read_len); +static int set_key_block(SSL *ssl, int is_write); +static int verify_digest(SSL *ssl, int mode, const uint8_t *buf, int read_len); +static void *crypt_new(SSL *ssl, uint8_t *key, uint8_t *iv, int is_decrypt); +static int send_raw_packet(SSL *ssl, uint8_t protocol); +static int check_certificate_chain(SSL *ssl); + +/** + * The server will pick the cipher based on the order that the order that the + * ciphers are listed. This order is defined at compile time. + */ +#ifndef CONFIG_SSL_SKELETON_MODE +static void session_free(SSL_SESSION *ssl_sessions[], int sess_index); +#endif + +const uint8_t ssl_prot_prefs[NUM_PROTOCOLS] = +#ifdef CONFIG_SSL_PROT_LOW /* low security, fast speed */ +{ SSL_AES128_SHA, SSL_AES128_SHA256, SSL_AES256_SHA, SSL_AES256_SHA256 }; +#elif CONFIG_SSL_PROT_MEDIUM /* medium security, medium speed */ +{ SSL_AES128_SHA256, SSL_AES256_SHA256, SSL_AES256_SHA, SSL_AES128_SHA }; +#else /* CONFIG_SSL_PROT_HIGH */ /* high security, low speed */ +{ SSL_AES256_SHA256, SSL_AES128_SHA256, SSL_AES256_SHA, SSL_AES128_SHA }; +#endif + +/** + * The cipher map containing all the essentials for each cipher. + */ +static const cipher_info_t cipher_info[NUM_PROTOCOLS] = +{ + { /* AES128-SHA */ + SSL_AES128_SHA, /* AES128-SHA */ + 16, /* key size */ + 16, /* iv size */ + 16, /* block padding size */ + SHA1_SIZE, /* digest size */ + 2*(SHA1_SIZE+16+16), /* key block size */ + ssl_hmac_sha1, /* hmac algorithm */ + (crypt_func)AES_cbc_encrypt, /* encrypt */ + (crypt_func)AES_cbc_decrypt /* decrypt */ + }, + { /* AES256-SHA */ + SSL_AES256_SHA, /* AES256-SHA */ + 32, /* key size */ + 16, /* iv size */ + 16, /* block padding size */ + SHA1_SIZE, /* digest size */ + 2*(SHA1_SIZE+32+16), /* key block size */ + ssl_hmac_sha1, /* hmac algorithm */ + (crypt_func)AES_cbc_encrypt, /* encrypt */ + (crypt_func)AES_cbc_decrypt /* decrypt */ + }, + { /* AES128-SHA256 */ + SSL_AES128_SHA256, /* AES128-SHA256 */ + 16, /* key size */ + 16, /* iv size */ + 16, /* block padding size */ + SHA256_SIZE, /* digest size */ + 2*(SHA256_SIZE+32+16), /* key block size */ + hmac_sha256, /* hmac algorithm */ + (crypt_func)AES_cbc_encrypt, /* encrypt */ + (crypt_func)AES_cbc_decrypt /* decrypt */ + }, + { /* AES256-SHA256 */ + SSL_AES256_SHA256, /* AES256-SHA256 */ + 32, /* key size */ + 16, /* iv size */ + 16, /* block padding size */ + SHA256_SIZE, /* digest size */ + 2*(SHA256_SIZE+32+16), /* key block size */ + hmac_sha256, /* hmac algorithm */ + (crypt_func)AES_cbc_encrypt, /* encrypt */ + (crypt_func)AES_cbc_decrypt /* decrypt */ + } +}; + +static void prf(SSL *ssl, const uint8_t *sec, int sec_len, + uint8_t *seed, int seed_len, + uint8_t *out, int olen); +static const cipher_info_t *get_cipher_info(uint8_t cipher); +static void increment_read_sequence(SSL *ssl); +static void increment_write_sequence(SSL *ssl); +static void add_hmac_digest(SSL *ssl, int snd, uint8_t *hmac_header, + const uint8_t *buf, int buf_len, uint8_t *hmac_buf); + +/* win32 VC6.0 doesn't have variadic macros */ +#if defined(WIN32) && !defined(CONFIG_SSL_FULL_MODE) +void DISPLAY_BYTES(SSL *ssl, const char *format, + const uint8_t *data, int size, ...) {} +#endif + +/** + * Allocates new SSL extensions structure and returns pointer to it + * + */ +EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new() +{ + return (SSL_EXTENSIONS *)calloc(1, sizeof(SSL_EXTENSIONS)); +} + +/** + * Allocates new SSL extensions structure and returns pointer to it + * + */ +EXP_FUNC void STDCALL ssl_ext_free(SSL_EXTENSIONS *ssl_ext) +{ + if (ssl_ext == NULL ) + { + return; + } + + free(ssl_ext); +} + +/** + * Establish a new client/server context. + */ +EXP_FUNC SSL_CTX *STDCALL ssl_ctx_new(uint32_t options, int num_sessions) +{ + SSL_CTX *ssl_ctx = (SSL_CTX *)calloc(1, sizeof (SSL_CTX)); + ssl_ctx->options = options; + RNG_initialize(); + +#ifdef CONFIG_SSL_ENABLE_SERVER + if (load_key_certs(ssl_ctx) < 0) + { + free(ssl_ctx); /* can't load our key/certificate pair, so die */ + return NULL; + } +#endif + +#ifndef CONFIG_SSL_SKELETON_MODE + ssl_ctx->num_sessions = num_sessions; +#endif + + SSL_CTX_MUTEX_INIT(ssl_ctx->mutex); + +#ifndef CONFIG_SSL_SKELETON_MODE + if (num_sessions) + { + ssl_ctx->ssl_sessions = (SSL_SESSION **) + calloc(1, num_sessions*sizeof(SSL_SESSION *)); + } +#endif + + return ssl_ctx; +} + +/* + * Remove a client/server context. + */ +EXP_FUNC void STDCALL ssl_ctx_free(SSL_CTX *ssl_ctx) +{ + SSL *ssl; + int i; + + if (ssl_ctx == NULL) + return; + + ssl = ssl_ctx->head; + + /* clear out all the ssl entries */ + while (ssl) + { + SSL *next = ssl->next; + ssl_free(ssl); + ssl = next; + } + +#ifndef CONFIG_SSL_SKELETON_MODE + /* clear out all the sessions */ + for (i = 0; i < ssl_ctx->num_sessions; i++) + session_free(ssl_ctx->ssl_sessions, i); + + free(ssl_ctx->ssl_sessions); +#endif + + i = 0; + while (i < CONFIG_SSL_MAX_CERTS && ssl_ctx->certs[i].buf) + { + free(ssl_ctx->certs[i].buf); + ssl_ctx->certs[i++].buf = NULL; + } + +#ifdef CONFIG_SSL_CERT_VERIFICATION + remove_ca_certs(ssl_ctx->ca_cert_ctx); +#endif + ssl_ctx->chain_length = 0; + SSL_CTX_MUTEX_DESTROY(ssl_ctx->mutex); + RSA_free(ssl_ctx->rsa_ctx); + RNG_terminate(); + free(ssl_ctx); +} + +/* + * Free any used resources used by this connection. + */ +EXP_FUNC void STDCALL ssl_free(SSL *ssl) +{ + SSL_CTX *ssl_ctx; + + if (ssl == NULL) /* just ignore null pointers */ + return; + + /* only notify if we weren't notified first */ + /* spec says we must notify when we are dying */ + if (!IS_SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY)) + send_alert(ssl, SSL_ALERT_CLOSE_NOTIFY); + + ssl_ctx = ssl->ssl_ctx; + + SSL_CTX_LOCK(ssl_ctx->mutex); + + /* adjust the server SSL list */ + if (ssl->prev) + ssl->prev->next = ssl->next; + else + ssl_ctx->head = ssl->next; + + if (ssl->next) + ssl->next->prev = ssl->prev; + else + ssl_ctx->tail = ssl->prev; + + SSL_CTX_UNLOCK(ssl_ctx->mutex); + + /* may already be free - but be sure */ + free(ssl->encrypt_ctx); + ssl->encrypt_ctx = NULL; + free(ssl->decrypt_ctx); + ssl->decrypt_ctx = NULL; + disposable_free(ssl); +#ifdef CONFIG_SSL_CERT_VERIFICATION + x509_free(ssl->x509_ctx); +#endif + + ssl_ext_free(ssl->extensions); + ssl->extensions = NULL; + free(ssl); +} + +/* + * Read the SSL connection and send any alerts for various errors. + */ +EXP_FUNC int STDCALL ssl_read(SSL *ssl, uint8_t **in_data) +{ + int ret = basic_read(ssl, in_data); + + /* check for return code so we can send an alert */ + if (ret < SSL_OK && ret != SSL_CLOSE_NOTIFY) + { + if (ret != SSL_ERROR_CONN_LOST) + { + send_alert(ssl, ret); +#ifndef CONFIG_SSL_SKELETON_MODE + /* something nasty happened, so get rid of this session */ + kill_ssl_session(ssl->ssl_ctx->ssl_sessions, ssl); +#endif + } + } + + return ret; +} + +/* + * Write application data to the client + */ +EXP_FUNC int STDCALL ssl_write(SSL *ssl, const uint8_t *out_data, int out_len) +{ + int n = out_len, nw, i, tot = 0; + + /* maximum size of a TLS packet is around 16kB, so fragment */ + do + { + nw = n; + + if (nw > RT_MAX_PLAIN_LENGTH) /* fragment if necessary */ + nw = RT_MAX_PLAIN_LENGTH; + + if ((i = send_packet(ssl, PT_APP_PROTOCOL_DATA, + &out_data[tot], nw)) <= 0) + { + out_len = i; /* an error */ + break; + } + + tot += i; + n -= i; + } while (n > 0); + + return out_len; +} + +/** + * Add a certificate to the certificate chain. + */ +int add_cert(SSL_CTX *ssl_ctx, const uint8_t *buf, int len) +{ + int ret = SSL_ERROR_NO_CERT_DEFINED, i = 0; + SSL_CERT *ssl_cert; + X509_CTX *cert = NULL; + int offset; + + while (i < CONFIG_SSL_MAX_CERTS && ssl_ctx->certs[i].buf) + i++; + + if (i == CONFIG_SSL_MAX_CERTS) /* too many certs */ + { +#ifdef CONFIG_SSL_DIAGNOSTICS + printf("Error: maximum number of certs added (%d) - change of " + "compile-time configuration required\n", + CONFIG_SSL_MAX_CERTS); +#endif + goto error; + } + + if ((ret = x509_new(buf, &offset, &cert))) + goto error; + +#if defined (CONFIG_SSL_FULL_MODE) + if (ssl_ctx->options & SSL_DISPLAY_CERTS) + x509_print(cert, NULL); +#endif + + ssl_cert = &ssl_ctx->certs[i]; + ssl_cert->size = len; + ssl_cert->buf = (uint8_t *)malloc(len); + + switch (cert->sig_type) + { + case SIG_TYPE_SHA1: + ssl_cert->hash_alg = SIG_ALG_SHA1; + break; + + case SIG_TYPE_SHA256: + ssl_cert->hash_alg = SIG_ALG_SHA256; + break; + + case SIG_TYPE_SHA384: + ssl_cert->hash_alg = SIG_ALG_SHA384; + break; + + case SIG_TYPE_SHA512: + ssl_cert->hash_alg = SIG_ALG_SHA512; + break; + } + + memcpy(ssl_cert->buf, buf, len); + ssl_ctx->chain_length++; + len -= offset; + ret = SSL_OK; /* ok so far */ + + /* recurse? */ + if (len > 0) + { + ret = add_cert(ssl_ctx, &buf[offset], len); + } + +error: + x509_free(cert); /* don't need anymore */ + return ret; +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION +/** + * Add a certificate authority. + */ +int add_cert_auth(SSL_CTX *ssl_ctx, const uint8_t *buf, int len) +{ + int ret = X509_OK; /* ignore errors for now */ + int i = 0; + CA_CERT_CTX *ca_cert_ctx; + + if (ssl_ctx->ca_cert_ctx == NULL) + ssl_ctx->ca_cert_ctx = (CA_CERT_CTX *)calloc(1, sizeof(CA_CERT_CTX)); + + ca_cert_ctx = ssl_ctx->ca_cert_ctx; + + while (i < CONFIG_X509_MAX_CA_CERTS && ca_cert_ctx->cert[i]) + i++; + + while (len > 0) + { + int offset; + if (i >= CONFIG_X509_MAX_CA_CERTS) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: maximum number of CA certs added (%d) - change of " + "compile-time configuration required\n", + CONFIG_X509_MAX_CA_CERTS); +#endif + ret = X509_MAX_CERTS; + break; + } + + /* ignore the return code */ + if (x509_new(buf, &offset, &ca_cert_ctx->cert[i]) == X509_OK) + { +#if defined (CONFIG_SSL_FULL_MODE) + if (ssl_ctx->options & SSL_DISPLAY_CERTS) + x509_print(ca_cert_ctx->cert[i], NULL); +#endif + } + + i++; + len -= offset; + } + + return ret; +} + +/* + * Retrieve an X.509 distinguished name component + */ +EXP_FUNC const char * STDCALL ssl_get_cert_dn(const SSL *ssl, int component) +{ + if (ssl->x509_ctx == NULL) + return NULL; + + switch (component) + { + case SSL_X509_CERT_COMMON_NAME: + return ssl->x509_ctx->cert_dn[X509_COMMON_NAME]; + + case SSL_X509_CERT_ORGANIZATION: + return ssl->x509_ctx->cert_dn[X509_ORGANIZATION]; + + case SSL_X509_CERT_ORGANIZATIONAL_NAME: + return ssl->x509_ctx->cert_dn[X509_ORGANIZATIONAL_UNIT]; + + case SSL_X509_CERT_LOCATION: + return ssl->x509_ctx->cert_dn[X509_LOCATION]; + + case SSL_X509_CERT_COUNTRY: + return ssl->x509_ctx->cert_dn[X509_COUNTRY]; + + case SSL_X509_CERT_STATE: + return ssl->x509_ctx->cert_dn[X509_STATE]; + + case SSL_X509_CA_CERT_COMMON_NAME: + return ssl->x509_ctx->ca_cert_dn[X509_COMMON_NAME]; + + case SSL_X509_CA_CERT_ORGANIZATION: + return ssl->x509_ctx->ca_cert_dn[X509_ORGANIZATION]; + + case SSL_X509_CA_CERT_ORGANIZATIONAL_NAME: + return ssl->x509_ctx->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]; + + case SSL_X509_CA_CERT_LOCATION: + return ssl->x509_ctx->ca_cert_dn[X509_LOCATION]; + + case SSL_X509_CA_CERT_COUNTRY: + return ssl->x509_ctx->ca_cert_dn[X509_COUNTRY]; + + case SSL_X509_CA_CERT_STATE: + return ssl->x509_ctx->ca_cert_dn[X509_STATE]; + + default: + return NULL; + } +} + +/* + * Retrieve a "Subject Alternative Name" from a v3 certificate + */ +EXP_FUNC const char * STDCALL ssl_get_cert_subject_alt_dnsname(const SSL *ssl, + int dnsindex) +{ + int i; + + if (ssl->x509_ctx == NULL || ssl->x509_ctx->subject_alt_dnsnames == NULL) + return NULL; + + for (i = 0; i < dnsindex; ++i) + { + if (ssl->x509_ctx->subject_alt_dnsnames[i] == NULL) + return NULL; + } + + return ssl->x509_ctx->subject_alt_dnsnames[dnsindex]; +} + +#endif /* CONFIG_SSL_CERT_VERIFICATION */ + +/* + * Find an ssl object based on the client's file descriptor. + */ +EXP_FUNC SSL * STDCALL ssl_find(SSL_CTX *ssl_ctx, long client_fd) +{ + SSL *ssl; + + SSL_CTX_LOCK(ssl_ctx->mutex); + ssl = ssl_ctx->head; + + /* search through all the ssl entries */ + while (ssl) + { + if (ssl->client_fd == client_fd) + { + SSL_CTX_UNLOCK(ssl_ctx->mutex); + return ssl; + } + + ssl = ssl->next; + } + + SSL_CTX_UNLOCK(ssl_ctx->mutex); + return NULL; +} + +/* + * Force the client to perform its handshake again. + */ +EXP_FUNC int STDCALL ssl_renegotiate(SSL *ssl) +{ + int ret = SSL_OK; + + disposable_new(ssl); +#ifdef CONFIG_SSL_ENABLE_CLIENT + if (IS_SET_SSL_FLAG(SSL_IS_CLIENT)) + { + ret = do_client_connect(ssl); + } + else +#endif + { + send_packet(ssl, PT_HANDSHAKE_PROTOCOL, + g_hello_request, sizeof(g_hello_request)); + SET_SSL_FLAG(SSL_NEED_RECORD); + } + + return ret; +} + +/** + * @brief Get what we need for key info. + * @param cipher [in] The cipher information we are after + * @param key_size [out] The key size for the cipher + * @param iv_size [out] The iv size for the cipher + * @return The amount of key information we need. + */ +static const cipher_info_t *get_cipher_info(uint8_t cipher) +{ + int i; + + for (i = 0; i < NUM_PROTOCOLS; i++) + { + if (cipher_info[i].cipher == cipher) + { + return &cipher_info[i]; + } + } + + return NULL; /* error */ +} + +/* + * Get a new ssl context for a new connection. + */ +SSL *ssl_new(SSL_CTX *ssl_ctx, long client_fd) +{ + SSL *ssl = (SSL *)calloc(1, sizeof(SSL)); + ssl->ssl_ctx = ssl_ctx; + ssl->need_bytes = SSL_RECORD_SIZE; /* need a record */ + ssl->client_fd = client_fd; + ssl->flag = SSL_NEED_RECORD; + ssl->bm_data = ssl->bm_all_data+BM_RECORD_OFFSET; /* space at the start */ + ssl->hs_status = SSL_NOT_OK; /* not connected */ +#ifdef CONFIG_ENABLE_VERIFICATION + ssl->ca_cert_ctx = ssl_ctx->ca_cert_ctx; +#endif + disposable_new(ssl); + + /* a bit hacky but saves a few bytes of memory */ + ssl->flag |= ssl_ctx->options; + SSL_CTX_LOCK(ssl_ctx->mutex); + + if (ssl_ctx->head == NULL) + { + ssl_ctx->head = ssl; + ssl_ctx->tail = ssl; + } + else + { + ssl->prev = ssl_ctx->tail; + ssl_ctx->tail->next = ssl; + ssl_ctx->tail = ssl; + } + + SSL_CTX_UNLOCK(ssl_ctx->mutex); + return ssl; +} + +/* + * Add a private key to a context. + */ +int add_private_key(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj) +{ + int ret = SSL_OK; + + /* get the private key details */ + if (asn1_get_private_key(ssl_obj->buf, ssl_obj->len, &ssl_ctx->rsa_ctx)) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + +error: + return ret; +} + +/** + * Increment the read sequence number (as a 64 bit endian indepenent #) + */ +static void increment_read_sequence(SSL *ssl) +{ + int i; + + for (i = 7; i >= 0; i--) + { + if (++ssl->read_sequence[i]) + break; + } +} + +/** + * Increment the read sequence number (as a 64 bit endian indepenent #) + */ +static void increment_write_sequence(SSL *ssl) +{ + int i; + + for (i = 7; i >= 0; i--) + { + if (++ssl->write_sequence[i]) + break; + } +} + +/** + * Work out the HMAC digest in a packet. + */ +static void add_hmac_digest(SSL *ssl, int mode, uint8_t *hmac_header, + const uint8_t *buf, int buf_len, uint8_t *hmac_buf) +{ + int hmac_len = buf_len + 8 + SSL_RECORD_SIZE; + uint8_t *t_buf = (uint8_t *)alloca(hmac_len); + + memcpy(t_buf, (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_WRITE) ? + ssl->write_sequence : ssl->read_sequence, 8); + memcpy(&t_buf[8], hmac_header, SSL_RECORD_SIZE); + memcpy(&t_buf[8+SSL_RECORD_SIZE], buf, buf_len); + + ssl->cipher_info->hmac(t_buf, hmac_len, + (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_READ) ? + ssl->server_mac : ssl->client_mac, + ssl->cipher_info->digest_size, hmac_buf); + +#if 0 + print_blob("record", hmac_header, SSL_RECORD_SIZE); + print_blob("buf", buf, buf_len); + if (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_WRITE) + { + print_blob("write seq", ssl->write_sequence, 8); + } + else + { + print_blob("read seq", ssl->read_sequence, 8); + } + + if (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_READ) + { + print_blob("server mac", + ssl->server_mac, ssl->cipher_info->digest_size); + } + else + { + print_blob("client mac", + ssl->client_mac, ssl->cipher_info->digest_size); + } + print_blob("hmac", hmac_buf, ssl->cipher_info->digest_size); +#endif +} + +/** + * Verify that the digest of a packet is correct. + */ +static int verify_digest(SSL *ssl, int mode, const uint8_t *buf, int read_len) +{ + uint8_t hmac_buf[SHA256_SIZE]; // size of largest digest + int hmac_offset; + + int last_blk_size = buf[read_len-1], i; + hmac_offset = read_len-last_blk_size-ssl->cipher_info->digest_size-1; + + /* guard against a timing attack - make sure we do the digest */ + if (hmac_offset < 0) + { + hmac_offset = 0; + } + else + { + /* already looked at last byte */ + for (i = 1; i < last_blk_size; i++) + { + if (buf[read_len-i] != last_blk_size) + { + hmac_offset = 0; + break; + } + } + } + + /* sanity check the offset */ + ssl->hmac_header[3] = hmac_offset >> 8; /* insert size */ + ssl->hmac_header[4] = hmac_offset & 0xff; + add_hmac_digest(ssl, mode, ssl->hmac_header, buf, hmac_offset, hmac_buf); + + if (memcmp(hmac_buf, &buf[hmac_offset], ssl->cipher_info->digest_size)) + { + return SSL_ERROR_INVALID_HMAC; + } + + return hmac_offset; +} + +/** + * Add a packet to the end of our sent and received packets, so that we may use + * it to calculate the hash at the end. + */ +void add_packet(SSL *ssl, const uint8_t *pkt, int len) +{ + // TLS1.2+ + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2 || ssl->version == 0) + { + SHA256_Update(&ssl->dc->sha256_ctx, pkt, len); + } + + if (ssl->version < SSL_PROTOCOL_VERSION_TLS1_2 || + ssl->next_state == HS_SERVER_HELLO || + ssl->next_state == 0) + { + MD5_Update(&ssl->dc->md5_ctx, pkt, len); + SHA1_Update(&ssl->dc->sha1_ctx, pkt, len); + } +} + +/** + * Work out the MD5 PRF. + */ +static void p_hash_md5(const uint8_t *sec, int sec_len, + uint8_t *seed, int seed_len, uint8_t *out, int olen) +{ + uint8_t a1[MD5_SIZE+77]; + + /* A(1) */ + ssl_hmac_md5(seed, seed_len, sec, sec_len, a1); + memcpy(&a1[MD5_SIZE], seed, seed_len); + ssl_hmac_md5(a1, MD5_SIZE+seed_len, sec, sec_len, out); + + while (olen > MD5_SIZE) + { + uint8_t a2[MD5_SIZE]; + out += MD5_SIZE; + olen -= MD5_SIZE; + + /* A(N) */ + ssl_hmac_md5(a1, MD5_SIZE, sec, sec_len, a2); + memcpy(a1, a2, MD5_SIZE); + + /* work out the actual hash */ + ssl_hmac_md5(a1, MD5_SIZE+seed_len, sec, sec_len, out); + } +} + +/** + * Work out the SHA1 PRF. + */ +static void p_hash_sha1(const uint8_t *sec, int sec_len, + uint8_t *seed, int seed_len, uint8_t *out, int olen) +{ + uint8_t a1[SHA1_SIZE+77]; + + /* A(1) */ + ssl_hmac_sha1(seed, seed_len, sec, sec_len, a1); + memcpy(&a1[SHA1_SIZE], seed, seed_len); + ssl_hmac_sha1(a1, SHA1_SIZE+seed_len, sec, sec_len, out); + + while (olen > SHA1_SIZE) + { + uint8_t a2[SHA1_SIZE]; + out += SHA1_SIZE; + olen -= SHA1_SIZE; + + /* A(N) */ + ssl_hmac_sha1(a1, SHA1_SIZE, sec, sec_len, a2); + memcpy(a1, a2, SHA1_SIZE); + + /* work out the actual hash */ + ssl_hmac_sha1(a1, SHA1_SIZE+seed_len, sec, sec_len, out); + } +} + +/** + * Work out the SHA256 PRF. + */ +static void p_hash_sha256(const uint8_t *sec, int sec_len, + uint8_t *seed, int seed_len, uint8_t *out, int olen) +{ + uint8_t a1[SHA256_SIZE+77]; + + /* A(1) */ + hmac_sha256(seed, seed_len, sec, sec_len, a1); + memcpy(&a1[SHA256_SIZE], seed, seed_len); + hmac_sha256(a1, SHA256_SIZE+seed_len, sec, sec_len, out); + + while (olen > SHA256_SIZE) + { + uint8_t a2[SHA256_SIZE]; + out += SHA256_SIZE; + olen -= SHA256_SIZE; + + // A(N) + hmac_sha256(a1, SHA256_SIZE, sec, sec_len, a2); + memcpy(a1, a2, SHA256_SIZE); + + // work out the actual hash + hmac_sha256(a1, SHA256_SIZE+seed_len, sec, sec_len, out); + } +} + +/** + * Work out the PRF. + */ +static void prf(SSL *ssl, const uint8_t *sec, int sec_len, + uint8_t *seed, int seed_len, + uint8_t *out, int olen) +{ + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + p_hash_sha256(sec, sec_len, seed, seed_len, out, olen); + } + else // TLS1.0/1.1 + { + int len, i; + const uint8_t *S1, *S2; + uint8_t xbuf[2*(SHA256_SIZE+32+16) + MD5_SIZE]; /* max keyblock */ + uint8_t ybuf[2*(SHA256_SIZE+32+16) + SHA1_SIZE]; /* max keyblock */ + + len = sec_len/2; + S1 = sec; + S2 = &sec[len]; + len += (sec_len & 1); /* add for odd, make longer */ + + p_hash_md5(S1, len, seed, seed_len, xbuf, olen); + p_hash_sha1(S2, len, seed, seed_len, ybuf, olen); + + for (i = 0; i < olen; i++) + out[i] = xbuf[i] ^ ybuf[i]; + } +} + +/** + * Generate a master secret based on the client/server random data and the + * premaster secret. + */ +void generate_master_secret(SSL *ssl, const uint8_t *premaster_secret) +{ + uint8_t buf[77]; +//print_blob("premaster secret", premaster_secret, 48); + strcpy((char *)buf, "master secret"); + memcpy(&buf[13], ssl->dc->client_random, SSL_RANDOM_SIZE); + memcpy(&buf[45], ssl->dc->server_random, SSL_RANDOM_SIZE); + prf(ssl, premaster_secret, SSL_SECRET_SIZE, buf, 77, ssl->dc->master_secret, + SSL_SECRET_SIZE); +#if 0 + print_blob("client random", ssl->dc->client_random, 32); + print_blob("server random", ssl->dc->server_random, 32); + print_blob("master secret", ssl->dc->master_secret, 48); +#endif +} + +/** + * Generate a 'random' blob of data used for the generation of keys. + */ +static void generate_key_block(SSL *ssl, + uint8_t *client_random, uint8_t *server_random, + uint8_t *master_secret, uint8_t *key_block, int key_block_size) +{ + uint8_t buf[77]; + strcpy((char *)buf, "key expansion"); + memcpy(&buf[13], server_random, SSL_RANDOM_SIZE); + memcpy(&buf[45], client_random, SSL_RANDOM_SIZE); + prf(ssl, master_secret, SSL_SECRET_SIZE, buf, 77, + key_block, key_block_size); +} + +/** + * Calculate the digest used in the finished message. This function also + * doubles up as a certificate verify function. + */ +int finished_digest(SSL *ssl, const char *label, uint8_t *digest) +{ + uint8_t mac_buf[SHA1_SIZE+MD5_SIZE+15]; + uint8_t *q = mac_buf; + int dgst_len; + + if (label) + { + strcpy((char *)q, label); + q += strlen(label); + } + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + SHA256_CTX sha256_ctx = ssl->dc->sha256_ctx; // interim copy + SHA256_Final(q, &sha256_ctx); + q += SHA256_SIZE; + dgst_len = (int)(q-mac_buf); + } + else // TLS1.0/1.1 + { + MD5_CTX md5_ctx = ssl->dc->md5_ctx; // interim copy + SHA1_CTX sha1_ctx = ssl->dc->sha1_ctx; + + MD5_Final(q, &md5_ctx); + q += MD5_SIZE; + + SHA1_Final(q, &sha1_ctx); + q += SHA1_SIZE; + dgst_len = (int)(q-mac_buf); + } + + if (label) + { + prf(ssl, ssl->dc->master_secret, SSL_SECRET_SIZE, + mac_buf, dgst_len, digest, SSL_FINISHED_HASH_SIZE); + } + else /* for use in a certificate verify */ + { + memcpy(digest, mac_buf, dgst_len); + } + +#if 0 + printf("label: %s\n", label); + print_blob("mac_buf", mac_buf, dgst_len); + print_blob("finished digest", digest, SSL_FINISHED_HASH_SIZE); +#endif + + return dgst_len; +} + +/** + * Retrieve (and initialise) the context of a cipher. + */ +static void *crypt_new(SSL *ssl, uint8_t *key, uint8_t *iv, int is_decrypt) +{ + switch (ssl->cipher) + { + case SSL_AES128_SHA: + case SSL_AES128_SHA256: + { + AES_CTX *aes_ctx = (AES_CTX *)malloc(sizeof(AES_CTX)); + AES_set_key(aes_ctx, key, iv, AES_MODE_128); + + if (is_decrypt) + { + AES_convert_key(aes_ctx); + } + + return (void *)aes_ctx; + } + + case SSL_AES256_SHA: + case SSL_AES256_SHA256: + { + AES_CTX *aes_ctx = (AES_CTX *)malloc(sizeof(AES_CTX)); + AES_set_key(aes_ctx, key, iv, AES_MODE_256); + + if (is_decrypt) + { + AES_convert_key(aes_ctx); + } + + return (void *)aes_ctx; + } + + } + + return NULL; /* its all gone wrong */ +} + +/** + * Send a packet over the socket. + */ +static int send_raw_packet(SSL *ssl, uint8_t protocol) +{ + uint8_t *rec_buf = ssl->bm_all_data; + int pkt_size = SSL_RECORD_SIZE+ssl->bm_index; + int sent = 0; + int ret = SSL_OK; + + rec_buf[0] = protocol; + rec_buf[1] = 0x03; /* version = 3.1 or higher */ + rec_buf[2] = ssl->version & 0x0f; + rec_buf[3] = ssl->bm_index >> 8; + rec_buf[4] = ssl->bm_index & 0xff; + + DISPLAY_BYTES(ssl, "sending %d bytes", ssl->bm_all_data, + pkt_size, pkt_size); + + while (sent < pkt_size) + { + ret = SOCKET_WRITE(ssl->client_fd, + &ssl->bm_all_data[sent], pkt_size-sent); + + if (ret >= 0) + sent += ret; + else + { + +#ifdef WIN32 + if (GetLastError() != WSAEWOULDBLOCK) +#else + if (SOCKET_ERRNO() != EAGAIN && SOCKET_ERRNO() != EWOULDBLOCK) +#endif + return SSL_ERROR_CONN_LOST; + } + +#ifdef PORT_USE_SELECT + // TODO: This should be factored into SOCKET_WAIT_WRITABLE(), + // with semantic being waiting until socket can be written + // regardless whether it is in blocking or non-blocking mode. + /* keep going until the write buffer has some space */ + if (sent != pkt_size) + { + fd_set wfds; + FD_ZERO(&wfds); + FD_SET(ssl->client_fd, &wfds); + + /* block and wait for it */ + if (select(ssl->client_fd + 1, NULL, &wfds, NULL, NULL) < 0) + return SSL_ERROR_CONN_LOST; + } +#endif + } + + SET_SSL_FLAG(SSL_NEED_RECORD); /* reset for next time */ + ssl->bm_index = 0; + + if (protocol != PT_APP_PROTOCOL_DATA) + { + /* always return SSL_OK during handshake */ + ret = SSL_OK; + } + + return ret; +} + +/** + * Send an encrypted packet with padding bytes if necessary. + */ +int send_packet(SSL *ssl, uint8_t protocol, const uint8_t *in, int length) +{ + int ret, msg_length = 0; + + /* if our state is bad, don't bother */ + if (ssl->hs_status == SSL_ERROR_DEAD) + return SSL_ERROR_CONN_LOST; + + if (IS_SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY)) + return SSL_CLOSE_NOTIFY; + + if (in) /* has the buffer already been initialised? */ + { + memcpy(ssl->bm_data, in, length); + } + + msg_length += length; + + if (IS_SET_SSL_FLAG(SSL_TX_ENCRYPTED)) + { + int mode = IS_SET_SSL_FLAG(SSL_IS_CLIENT) ? + SSL_CLIENT_WRITE : SSL_SERVER_WRITE; + uint8_t hmac_header[SSL_RECORD_SIZE] = + { + protocol, + 0x03, /* version = 3.1 or higher */ + ssl->version & 0x0f, + msg_length >> 8, + msg_length & 0xff + }; + + if (protocol == PT_HANDSHAKE_PROTOCOL) + { + DISPLAY_STATE(ssl, 1, ssl->bm_data[0], 0); + + if (ssl->bm_data[0] != HS_HELLO_REQUEST) + { + add_packet(ssl, ssl->bm_data, msg_length); + } + } + + /* add the packet digest */ + add_hmac_digest(ssl, mode, hmac_header, ssl->bm_data, msg_length, + &ssl->bm_data[msg_length]); + msg_length += ssl->cipher_info->digest_size; + + /* add padding */ + { + int last_blk_size = msg_length%ssl->cipher_info->padding_size; + int pad_bytes = ssl->cipher_info->padding_size - last_blk_size; + + /* ensure we always have at least 1 padding byte */ + if (pad_bytes == 0) + pad_bytes += ssl->cipher_info->padding_size; + + memset(&ssl->bm_data[msg_length], pad_bytes-1, pad_bytes); + msg_length += pad_bytes; + } + + DISPLAY_BYTES(ssl, "unencrypted write", ssl->bm_data, msg_length); + increment_write_sequence(ssl); + + /* add the explicit IV for TLS1.1 */ + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_1) + { + uint8_t iv_size = ssl->cipher_info->iv_size; + uint8_t *t_buf = alloca(msg_length + iv_size); + memcpy(t_buf + iv_size, ssl->bm_data, msg_length); + if (get_random(iv_size, t_buf) < 0) + return SSL_NOT_OK; + + msg_length += iv_size; + memcpy(ssl->bm_data, t_buf, msg_length); + } + + /* now encrypt the packet */ + ssl->cipher_info->encrypt(ssl->encrypt_ctx, ssl->bm_data, + ssl->bm_data, msg_length); + } + else if (protocol == PT_HANDSHAKE_PROTOCOL) + { + DISPLAY_STATE(ssl, 1, ssl->bm_data[0], 0); + + if (ssl->bm_data[0] != HS_HELLO_REQUEST) + { + add_packet(ssl, ssl->bm_data, length); + } + } + + ssl->bm_index = msg_length; + if ((ret = send_raw_packet(ssl, protocol)) <= 0) + return ret; + + return length; /* just return what we wanted to send */ +} + +/** + * Work out the cipher keys we are going to use for this session based on the + * master secret. + */ +static int set_key_block(SSL *ssl, int is_write) +{ + const cipher_info_t *ciph_info = get_cipher_info(ssl->cipher); + uint8_t *q; + uint8_t client_key[32], server_key[32]; /* big enough for AES256 */ + uint8_t client_iv[16], server_iv[16]; /* big enough for AES128/256 */ + int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); + + if (ciph_info == NULL) + return -1; + + /* only do once in a handshake */ + if (!ssl->dc->key_block_generated) + { + generate_key_block(ssl, ssl->dc->client_random, ssl->dc->server_random, + ssl->dc->master_secret, ssl->dc->key_block, + ciph_info->key_block_size); +#if 0 + print_blob("master", ssl->dc->master_secret, SSL_SECRET_SIZE); + print_blob("keyblock", ssl->dc->key_block, ciph_info->key_block_size); + print_blob("client random", ssl->dc->client_random, 32); + print_blob("server random", ssl->dc->server_random, 32); +#endif + ssl->dc->key_block_generated = 1; + } + + q = ssl->dc->key_block; + + if ((is_client && is_write) || (!is_client && !is_write)) + { + memcpy(ssl->client_mac, q, ciph_info->digest_size); + } + + q += ciph_info->digest_size; + + if ((!is_client && is_write) || (is_client && !is_write)) + { + memcpy(ssl->server_mac, q, ciph_info->digest_size); + } + + q += ciph_info->digest_size; + memcpy(client_key, q, ciph_info->key_size); + q += ciph_info->key_size; + memcpy(server_key, q, ciph_info->key_size); + q += ciph_info->key_size; + + memcpy(client_iv, q, ciph_info->iv_size); + q += ciph_info->iv_size; + memcpy(server_iv, q, ciph_info->iv_size); + q += ciph_info->iv_size; +#if 0 + print_blob("client key", client_key, ciph_info->key_size); + print_blob("server key", server_key, ciph_info->key_size); + print_blob("client iv", client_iv, ciph_info->iv_size); + print_blob("server iv", server_iv, ciph_info->iv_size); +#endif + + free(is_write ? ssl->encrypt_ctx : ssl->decrypt_ctx); + + /* now initialise the ciphers */ + if (is_client) + { + finished_digest(ssl, server_finished, ssl->dc->final_finish_mac); + + if (is_write) + ssl->encrypt_ctx = crypt_new(ssl, client_key, client_iv, 0); + else + ssl->decrypt_ctx = crypt_new(ssl, server_key, server_iv, 1); + } + else + { + finished_digest(ssl, client_finished, ssl->dc->final_finish_mac); + + if (is_write) + ssl->encrypt_ctx = crypt_new(ssl, server_key, server_iv, 0); + else + ssl->decrypt_ctx = crypt_new(ssl, client_key, client_iv, 1); + } + + ssl->cipher_info = ciph_info; + return 0; +} + +/** + * Read the SSL connection. + */ +int basic_read(SSL *ssl, uint8_t **in_data) +{ + int ret = SSL_OK; + int read_len, is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); + uint8_t *buf = ssl->bm_data; + + if (IS_SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY)) + return SSL_CLOSE_NOTIFY; + + read_len = SOCKET_READ(ssl->client_fd, &buf[ssl->bm_read_index], + ssl->need_bytes-ssl->got_bytes); + + if (read_len < 0) + { +#ifdef WIN32 + if (GetLastError() == WSAEWOULDBLOCK) +#else + if (SOCKET_ERRNO() == EAGAIN || SOCKET_ERRNO() == EWOULDBLOCK) +#endif + return 0; + } + + /* connection has gone, so die */ + if (read_len <= 0) + { + ret = SSL_ERROR_CONN_LOST; + ssl->hs_status = SSL_ERROR_DEAD; /* make sure it stays dead */ + goto error; + } + + DISPLAY_BYTES(ssl, "received %d bytes", + &ssl->bm_data[ssl->bm_read_index], read_len, read_len); + + ssl->got_bytes += read_len; + ssl->bm_read_index += read_len; + + /* haven't quite got what we want, so try again later */ + if (ssl->got_bytes < ssl->need_bytes) + return SSL_OK; + + read_len = ssl->got_bytes; + ssl->got_bytes = 0; + + if (IS_SET_SSL_FLAG(SSL_NEED_RECORD)) + { + /* check for sslv2 "client hello" */ + if ((buf[0] & 0x80) && buf[2] == 1) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: no SSLv23 handshaking allowed\n"); +#endif + ret = SSL_ERROR_NOT_SUPPORTED; + goto error; /* not an error - just get out of here */ + } + + ssl->need_bytes = (buf[3] << 8) + buf[4]; + + /* do we violate the spec with the message size? */ + if (ssl->need_bytes > RT_MAX_PLAIN_LENGTH+RT_EXTRA-BM_RECORD_OFFSET) + { + printf("TLS buffer overflow, record size: %u (+5)\n", ssl->need_bytes); + ret = SSL_ERROR_RECORD_OVERFLOW; + goto error; + } + + CLR_SSL_FLAG(SSL_NEED_RECORD); + memcpy(ssl->hmac_header, buf, 3); /* store for hmac */ + ssl->record_type = buf[0]; + goto error; /* no error, we're done */ + } + + /* for next time - just do it now in case of an error */ + SET_SSL_FLAG(SSL_NEED_RECORD); + ssl->need_bytes = SSL_RECORD_SIZE; + + /* decrypt if we need to */ + if (IS_SET_SSL_FLAG(SSL_RX_ENCRYPTED)) + { + ssl->cipher_info->decrypt(ssl->decrypt_ctx, buf, buf, read_len); + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_1) + { + buf += ssl->cipher_info->iv_size; + read_len -= ssl->cipher_info->iv_size; + } + + read_len = verify_digest(ssl, + is_client ? SSL_CLIENT_READ : SSL_SERVER_READ, buf, read_len); + + /* does the hmac work? */ + if (read_len < 0) + { + ret = read_len; + goto error; + } + + DISPLAY_BYTES(ssl, "decrypted", buf, read_len); + increment_read_sequence(ssl); + } + + /* The main part of the SSL packet */ + switch (ssl->record_type) + { + case PT_HANDSHAKE_PROTOCOL: + if (ssl->dc != NULL) + { + ssl->dc->bm_proc_index = 0; + ret = do_handshake(ssl, buf, read_len); + } + else /* no client renegotiation allowed */ + { + ret = SSL_ERROR_NO_CLIENT_RENOG; + goto error; + } + break; + + case PT_CHANGE_CIPHER_SPEC: + if (ssl->next_state != HS_FINISHED) + { + ret = SSL_ERROR_INVALID_HANDSHAKE; + goto error; + } + + if (set_key_block(ssl, 0) < 0) + { + ret = SSL_ERROR_INVALID_HANDSHAKE; + goto error; + } + + /* all encrypted from now on */ + SET_SSL_FLAG(SSL_RX_ENCRYPTED); + memset(ssl->read_sequence, 0, 8); + break; + + case PT_APP_PROTOCOL_DATA: + if (in_data && ssl->hs_status == SSL_OK) + { + *in_data = buf; /* point to the work buffer */ + (*in_data)[read_len] = 0; /* null terminate just in case */ + ret = read_len; + } + else + ret = SSL_ERROR_INVALID_PROT_MSG; + break; + + case PT_ALERT_PROTOCOL: + /* return the alert # with alert bit set */ + if (buf[0] == SSL_ALERT_TYPE_WARNING && + buf[1] == SSL_ALERT_CLOSE_NOTIFY) + { + ret = SSL_CLOSE_NOTIFY; + send_alert(ssl, SSL_ALERT_CLOSE_NOTIFY); + SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY); + } + else + { + ret = -buf[1]; + DISPLAY_ALERT(ssl, buf[1]); + } + + break; + + default: + ret = SSL_ERROR_INVALID_PROT_MSG; + break; + } + +error: + ssl->bm_read_index = 0; /* reset to go again */ + + if (ret < SSL_OK && in_data)/* if all wrong, then clear this buffer ptr */ + *in_data = NULL; + + return ret; +} + +/** + * Do some basic checking of data and then perform the appropriate handshaking. + */ +static int do_handshake(SSL *ssl, uint8_t *buf, int read_len) +{ + int hs_len = (buf[2]<<8) + buf[3]; + uint8_t handshake_type = buf[0]; + int ret = SSL_OK; + int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); + + /* some integrity checking on the handshake */ + PARANOIA_CHECK(read_len-SSL_HS_HDR_SIZE, hs_len); + + if (handshake_type != ssl->next_state) + { + /* handle a special case on the client */ + if (!is_client || handshake_type != HS_CERT_REQ || + ssl->next_state != HS_SERVER_HELLO_DONE) + { + ret = SSL_ERROR_INVALID_HANDSHAKE; + goto error; + } + } + + hs_len += SSL_HS_HDR_SIZE; /* adjust for when adding packets */ + ssl->bm_index = hs_len; /* store the size and check later */ + DISPLAY_STATE(ssl, 0, handshake_type, 0); + + if (handshake_type != HS_CERT_VERIFY && handshake_type != HS_HELLO_REQUEST) + add_packet(ssl, buf, hs_len); + +#if defined(CONFIG_SSL_ENABLE_CLIENT) && defined(CONFIG_SSL_ENABLE_SERVER) + ret = is_client ? + do_clnt_handshake(ssl, handshake_type, buf, hs_len) : + do_svr_handshake(ssl, handshake_type, buf, hs_len); +#elif defined(CONFIG_SSL_ENABLE_CLIENT) + ret = do_clnt_handshake(ssl, handshake_type, buf, hs_len); +#else + ret = do_svr_handshake(ssl, handshake_type, buf, hs_len); +#endif + + /* just use recursion to get the rest */ + if (hs_len < read_len && ret == SSL_OK) + ret = do_handshake(ssl, &buf[hs_len], read_len-hs_len); + +error: + return ret; +} + +/** + * Sends the change cipher spec message. We have just read a finished message + * from the client. + */ +int send_change_cipher_spec(SSL *ssl) +{ + int ret = send_packet(ssl, PT_CHANGE_CIPHER_SPEC, + g_chg_cipher_spec_pkt, sizeof(g_chg_cipher_spec_pkt)); + + if (ret >= 0 && set_key_block(ssl, 1) < 0) + ret = SSL_ERROR_INVALID_HANDSHAKE; + + if (ssl->cipher_info) + SET_SSL_FLAG(SSL_TX_ENCRYPTED); + + memset(ssl->write_sequence, 0, 8); + return ret; +} + +/** + * Send a "finished" message + */ +int send_finished(SSL *ssl) +{ + uint8_t buf[SHA1_SIZE+MD5_SIZE+15+4] = { + HS_FINISHED, 0, 0, SSL_FINISHED_HASH_SIZE }; + + /* now add the finished digest mac (12 bytes) */ + finished_digest(ssl, + IS_SET_SSL_FLAG(SSL_IS_CLIENT) ? + client_finished : server_finished, &buf[4]); + +#ifndef CONFIG_SSL_SKELETON_MODE + /* store in the session cache */ + if (!IS_SET_SSL_FLAG(SSL_SESSION_RESUME) && ssl->ssl_ctx->num_sessions) + { + memcpy(ssl->session->master_secret, + ssl->dc->master_secret, SSL_SECRET_SIZE); + } +#endif + + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, + buf, SSL_FINISHED_HASH_SIZE+4); +} + +/** + * Send an alert message. + * Return 1 if the alert was an "error". + */ +int send_alert(SSL *ssl, int error_code) +{ + int alert_num = 0; + int is_warning = 0; + uint8_t buf[2]; + + /* Don't bother, we're already dead */ + if (ssl->hs_status == SSL_ERROR_DEAD) + { + return SSL_ERROR_CONN_LOST; + } + +#ifdef CONFIG_SSL_DIAGNOSTICS + if (IS_SET_SSL_FLAG(SSL_DISPLAY_STATES)) + ssl_display_error(error_code); +#endif + + switch (error_code) + { + case SSL_ALERT_CLOSE_NOTIFY: + is_warning = 1; + alert_num = SSL_ALERT_CLOSE_NOTIFY; + break; + + case SSL_ERROR_CONN_LOST: /* don't send alert just yet */ + is_warning = 1; + break; + + case SSL_ERROR_NO_CIPHER: + alert_num = SSL_ALERT_HANDSHAKE_FAILURE; + break; + + case SSL_ERROR_INVALID_HMAC: + alert_num = SSL_ALERT_BAD_RECORD_MAC; + break; + + case SSL_ERROR_FINISHED_INVALID: + case SSL_ERROR_INVALID_KEY: + alert_num = SSL_ALERT_DECRYPT_ERROR; + break; + + case SSL_ERROR_INVALID_VERSION: + alert_num = SSL_ALERT_INVALID_VERSION; + break; + + case SSL_ERROR_INVALID_SESSION: + alert_num = SSL_ALERT_ILLEGAL_PARAMETER; + break; + + case SSL_ERROR_NO_CLIENT_RENOG: + alert_num = SSL_ALERT_NO_RENEGOTIATION; + break; + + case SSL_ERROR_RECORD_OVERFLOW: + alert_num = SSL_ALERT_RECORD_OVERFLOW; + break; + + case SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED): + case SSL_X509_ERROR(X509_VFY_ERROR_NOT_YET_VALID): + alert_num = SSL_ALERT_CERTIFICATE_EXPIRED; + break; + + case SSL_X509_ERROR(X509_VFY_ERROR_NO_TRUSTED_CERT): + alert_num = SSL_ALERT_UNKNOWN_CA; + break; + + case SSL_X509_ERROR(X509_VFY_ERROR_UNSUPPORTED_DIGEST): + case SSL_ERROR_INVALID_CERT_HASH_ALG: + alert_num = SSL_ALERT_UNSUPPORTED_CERTIFICATE; + break; + + case SSL_ERROR_BAD_CERTIFICATE: + case SSL_X509_ERROR(X509_VFY_ERROR_BAD_SIGNATURE): + alert_num = SSL_ALERT_BAD_CERTIFICATE; + break; + + case SSL_ERROR_INVALID_HANDSHAKE: + case SSL_ERROR_INVALID_PROT_MSG: + default: + /* a catch-all for anything bad */ + alert_num = (error_code <= SSL_X509_OFFSET) ? + SSL_ALERT_CERTIFICATE_UNKNOWN: SSL_ALERT_UNEXPECTED_MESSAGE; + break; + } + + buf[0] = is_warning ? 1 : 2; + buf[1] = alert_num; + send_packet(ssl, PT_ALERT_PROTOCOL, buf, sizeof(buf)); + DISPLAY_ALERT(ssl, alert_num); + return is_warning ? 0 : 1; +} + +/** + * Process a client finished message. + */ +int process_finished(SSL *ssl, uint8_t *buf, int hs_len) +{ + int ret = SSL_OK; + int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); + int resume = IS_SET_SSL_FLAG(SSL_SESSION_RESUME); + + PARANOIA_CHECK(ssl->bm_index, SSL_FINISHED_HASH_SIZE+4); + + /* check that we all work before we continue */ + if (memcmp(ssl->dc->final_finish_mac, &buf[4], SSL_FINISHED_HASH_SIZE)) + return SSL_ERROR_FINISHED_INVALID; + + if ((!is_client && !resume) || (is_client && resume)) + { + if ((ret = send_change_cipher_spec(ssl)) == SSL_OK) + ret = send_finished(ssl); + } + + /* if we ever renegotiate */ + ssl->next_state = is_client ? HS_HELLO_REQUEST : HS_CLIENT_HELLO; + ssl->hs_status = ret; /* set the final handshake status */ + +error: + return ret; +} + +/** + * Send a certificate. + */ +int send_certificate(SSL *ssl) +{ + int ret = SSL_OK; + int i = 0; + uint8_t *buf = ssl->bm_data; + int offset = 7; + int chain_length; + + buf[0] = HS_CERTIFICATE; + buf[1] = 0; + buf[4] = 0; + + /* spec says we must check if the hash/sig algorithm is OK */ + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2 && + ((ret = check_certificate_chain(ssl)) != SSL_OK)) + { + ret = SSL_ERROR_INVALID_CERT_HASH_ALG; + goto error; + } + + while (i < ssl->ssl_ctx->chain_length) + { + SSL_CERT *cert = &ssl->ssl_ctx->certs[i]; + buf[offset++] = 0; + buf[offset++] = cert->size >> 8; /* cert 1 length */ + buf[offset++] = cert->size & 0xff; + memcpy(&buf[offset], cert->buf, cert->size); + offset += cert->size; + i++; + } + + chain_length = offset - 7; + buf[5] = chain_length >> 8; /* cert chain length */ + buf[6] = chain_length & 0xff; + chain_length += 3; + buf[2] = chain_length >> 8; /* handshake length */ + buf[3] = chain_length & 0xff; + ssl->bm_index = offset; + ret = send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, offset); + +error: + return ret; +} + +/** + * Create a blob of memory that we'll get rid of once the handshake is + * complete. + */ +void disposable_new(SSL *ssl) +{ + if (ssl->dc == NULL) + { + ssl->dc = (DISPOSABLE_CTX *)calloc(1, sizeof(DISPOSABLE_CTX)); + SHA256_Init(&ssl->dc->sha256_ctx); + MD5_Init(&ssl->dc->md5_ctx); + SHA1_Init(&ssl->dc->sha1_ctx); + } +} + +/** + * Remove the temporary blob of memory. + */ +void disposable_free(SSL *ssl) +{ + if (ssl->dc) + { + memset(ssl->dc, 0, sizeof(DISPOSABLE_CTX)); + free(ssl->dc); + ssl->dc = NULL; + } + +} + +#ifndef CONFIG_SSL_SKELETON_MODE /* no session resumption in this mode */ +/** + * Find if an existing session has the same session id. If so, use the + * master secret from this session for session resumption. + */ +SSL_SESSION *ssl_session_update(int max_sessions, SSL_SESSION *ssl_sessions[], + SSL *ssl, const uint8_t *session_id) +{ + time_t tm = time(NULL); + time_t oldest_sess_time = tm; + SSL_SESSION *oldest_sess = NULL; + int i; + + /* no sessions? Then bail */ + if (max_sessions == 0) + return NULL; + + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + if (session_id) + { + for (i = 0; i < max_sessions; i++) + { + if (ssl_sessions[i]) + { + /* kill off any expired sessions (including those in + the future) */ + if ((tm > ssl_sessions[i]->conn_time + SSL_EXPIRY_TIME) || + (tm < ssl_sessions[i]->conn_time)) + { + session_free(ssl_sessions, i); + continue; + } + + /* if the session id matches, it must still be less than + the expiry time */ + if (memcmp(ssl_sessions[i]->session_id, session_id, + SSL_SESSION_ID_SIZE) == 0) + { + ssl->session_index = i; + memcpy(ssl->dc->master_secret, + ssl_sessions[i]->master_secret, SSL_SECRET_SIZE); + SET_SSL_FLAG(SSL_SESSION_RESUME); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + return ssl_sessions[i]; /* a session was found */ + } + } + } + } + + /* If we've got here, no matching session was found - so create one */ + for (i = 0; i < max_sessions; i++) + { + if (ssl_sessions[i] == NULL) + { + /* perfect, this will do */ + ssl_sessions[i] = (SSL_SESSION *)calloc(1, sizeof(SSL_SESSION)); + ssl_sessions[i]->conn_time = tm; + ssl->session_index = i; + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + return ssl_sessions[i]; /* return the session object */ + } + else if (ssl_sessions[i]->conn_time <= oldest_sess_time) + { + /* find the oldest session */ + oldest_sess_time = ssl_sessions[i]->conn_time; + oldest_sess = ssl_sessions[i]; + ssl->session_index = i; + } + } + + /* ok, we've used up all of our sessions. So blow the oldest session away */ + oldest_sess->conn_time = tm; + memset(oldest_sess->session_id, 0, SSL_SESSION_ID_SIZE); + memset(oldest_sess->master_secret, 0, SSL_SECRET_SIZE); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + return oldest_sess; +} + +/** + * Free an existing session. + */ +static void session_free(SSL_SESSION *ssl_sessions[], int sess_index) +{ + if (ssl_sessions[sess_index]) + { + free(ssl_sessions[sess_index]); + ssl_sessions[sess_index] = NULL; + } +} + +/** + * This ssl object doesn't want this session anymore. + */ +void kill_ssl_session(SSL_SESSION **ssl_sessions, SSL *ssl) +{ + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + + if (ssl->ssl_ctx->num_sessions) + { + session_free(ssl_sessions, ssl->session_index); + ssl->session = NULL; + } + + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); +} +#endif /* CONFIG_SSL_SKELETON_MODE */ + +/* + * Get the session id for a handshake. This will be a 32 byte sequence. + */ +EXP_FUNC const uint8_t * STDCALL ssl_get_session_id(const SSL *ssl) +{ + return ssl->session_id; +} + +/* + * Get the session id size for a handshake. + */ +EXP_FUNC uint8_t STDCALL ssl_get_session_id_size(const SSL *ssl) +{ + return ssl->sess_id_size; +} + +/* + * Return the cipher id (in the SSL form). + */ +EXP_FUNC uint8_t STDCALL ssl_get_cipher_id(const SSL *ssl) +{ + return ssl->cipher; +} + +/* + * Return the status of the handshake. + */ +EXP_FUNC int STDCALL ssl_handshake_status(const SSL *ssl) +{ + return ssl->hs_status; +} + +/* + * Retrieve various parameters about the SSL engine. + */ +EXP_FUNC int STDCALL ssl_get_config(int offset) +{ + switch (offset) + { + /* return the appropriate build mode */ + case SSL_BUILD_MODE: +#if defined(CONFIG_SSL_FULL_MODE) + return SSL_BUILD_FULL_MODE; +#elif defined(CONFIG_SSL_ENABLE_CLIENT) + return SSL_BUILD_ENABLE_CLIENT; +#elif defined(CONFIG_ENABLE_VERIFICATION) + return SSL_BUILD_ENABLE_VERIFICATION; +#elif defined(CONFIG_SSL_SERVER_ONLY ) + return SSL_BUILD_SERVER_ONLY; +#else + return SSL_BUILD_SKELETON_MODE; +#endif + + case SSL_MAX_CERT_CFG_OFFSET: + return CONFIG_SSL_MAX_CERTS; + +#ifdef CONFIG_SSL_CERT_VERIFICATION + case SSL_MAX_CA_CERT_CFG_OFFSET: + return CONFIG_X509_MAX_CA_CERTS; +#endif +#ifdef CONFIG_SSL_HAS_PEM + case SSL_HAS_PEM: + return 1; +#endif + default: + return 0; + } +} + +/** + * Check the certificate chain to see if the certs are supported + */ +static int check_certificate_chain(SSL *ssl) +{ + int i = 0; + int ret = SSL_OK; + + while (i < ssl->ssl_ctx->chain_length) + { + int j = 0; + uint8_t found = 0; + SSL_CERT *cert = &ssl->ssl_ctx->certs[i]; + + while (j < ssl->num_sig_algs) + { + if (ssl->sig_algs[j++] == cert->hash_alg) + { + found = 1; + break; + } + } + + if (!found) + { + + ret = SSL_ERROR_INVALID_CERT_HASH_ALG; + goto error; + } + + i++; + } + +error: + return ret; +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION +/** + * Authenticate a received certificate. + */ +EXP_FUNC int STDCALL ssl_verify_cert(const SSL *ssl) +{ + int ret; + int pathLenConstraint = 0; + + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + ret = x509_verify(ssl->ssl_ctx->ca_cert_ctx, ssl->x509_ctx, + &pathLenConstraint); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + + if (ret) /* modify into an SSL error type */ + { + ret = SSL_X509_ERROR(ret); + } + + return ret; +} +#endif /* CONFIG_SSL_CERT_VERIFICATION */ + +/** + * Process a certificate message. + */ +int process_certificate(SSL *ssl, X509_CTX **x509_ctx) +{ + int ret = SSL_OK; + uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; + int pkt_size = ssl->bm_index; + int cert_size, offset = 5, offset_start; + int total_cert_len = (buf[offset]<<8) + buf[offset+1]; + int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); + X509_CTX *chain = 0; + X509_CTX **certs = 0; + int *cert_used = 0; + int num_certs = 0; + int i = 0; + offset += 2; + + PARANOIA_CHECK(pkt_size, total_cert_len + offset); + + // record the start point for the second pass + offset_start = offset; + + // first pass - count the certificates + while (offset < total_cert_len) + { + offset++; /* skip empty char */ + cert_size = (buf[offset]<<8) + buf[offset+1]; + offset += 2; + offset += cert_size; + num_certs++; + } + + PARANOIA_CHECK(pkt_size, offset); + + certs = (X509_CTX**) calloc(num_certs, sizeof(void*)); + cert_used = (int*) calloc(num_certs, sizeof(int)); + num_certs = 0; + + // restore the offset from the saved value + offset = offset_start; + + // second pass - load the certificates + while (offset < total_cert_len) + { + offset++; /* skip empty char */ + cert_size = (buf[offset]<<8) + buf[offset+1]; + offset += 2; + + if (x509_new(&buf[offset], NULL, certs+num_certs)) + { + ret = SSL_ERROR_BAD_CERTIFICATE; + goto error; + } + +#if defined (CONFIG_SSL_FULL_MODE) + if (ssl->ssl_ctx->options & SSL_DISPLAY_CERTS) + x509_print(certs[num_certs], NULL); +#endif + num_certs++; + offset += cert_size; + } + + PARANOIA_CHECK(pkt_size, offset); + + // third pass - link certs together, assume server cert is the first + *x509_ctx = certs[0]; + chain = certs[0]; + cert_used[0] = 1; + +#ifndef CONFIG_SSL_SKELETON_MODE + // repeat until the end of the chain is found + while (1) + { + // look for CA cert + for( i = 1; i < num_certs; i++ ) + { + if (certs[i] == chain) + continue; + + if (cert_used[i]) + continue; // don't allow loops + + if (asn1_compare_dn(chain->ca_cert_dn, certs[i]->cert_dn) == 0) + { + // CA cert found, add it to the chain + cert_used[i] = 1; + chain->next = certs[i]; + chain = certs[i]; + break; + } + } + + // no CA cert found, reached the end of the chain + if (i >= num_certs) + break; + } + + // clean up any certs that aren't part of the chain + for (i = 1; i < num_certs; i++) + { + if (cert_used[i] == 0) + x509_free(certs[i]); + } + + /* if we are client we can do the verify now or later */ + if (is_client && !IS_SET_SSL_FLAG(SSL_SERVER_VERIFY_LATER)) + { + ret = ssl_verify_cert(ssl); + } +#endif + + ssl->next_state = is_client ? HS_SERVER_HELLO_DONE : HS_CLIENT_KEY_XCHG; + ssl->dc->bm_proc_index += offset; +error: + // clean up arrays + if (certs) + free(certs); + + if (cert_used) + free(cert_used); + + return ret; +} + +//#endif /* CONFIG_SSL_CERT_VERIFICATION */ + +/** + * Debugging routine to display SSL handshaking stuff. + */ +#ifdef CONFIG_SSL_DIAGNOSTICS +/** + * Debugging routine to display SSL states. + */ +void DISPLAY_STATE(SSL *ssl, int is_send, uint8_t state, int not_ok) +{ + const char *str; + + if (!IS_SET_SSL_FLAG(SSL_DISPLAY_STATES)) + return; + + printf(not_ok ? "Error - invalid State:\t" : "State:\t"); + printf(is_send ? "sending " : "receiving "); + + switch (state) + { + case HS_HELLO_REQUEST: + str = "Hello Request (0)"; + break; + + case HS_CLIENT_HELLO: + str = "Client Hello (1)"; + break; + + case HS_SERVER_HELLO: + str = "Server Hello (2)"; + break; + + case HS_CERTIFICATE: + str = "Certificate (11)"; + break; + + case HS_SERVER_KEY_XCHG: + str = "Certificate Request (12)"; + break; + + case HS_CERT_REQ: + str = "Certificate Request (13)"; + break; + + case HS_SERVER_HELLO_DONE: + str = "Server Hello Done (14)"; + break; + + case HS_CERT_VERIFY: + str = "Certificate Verify (15)"; + break; + + case HS_CLIENT_KEY_XCHG: + str = "Client Key Exchange (16)"; + break; + + case HS_FINISHED: + str = "Finished (16)"; + break; + + default: + str = "Error (Unknown)"; + + break; + } + + printf("%s\n", str); +} + +/** + * Debugging routine to display RSA objects + */ +void DISPLAY_RSA(SSL *ssl, const RSA_CTX *rsa_ctx) +{ +#ifdef CONFIG_SSL_FULL_MODE + if (!IS_SET_SSL_FLAG(SSL_DISPLAY_RSA)) + return; + + RSA_print(rsa_ctx); + TTY_FLUSH(); +#endif +} + +/** + * Debugging routine to display SSL handshaking bytes. + */ +void DISPLAY_BYTES(SSL *ssl, const char *format, + const uint8_t *data, int size, ...) +{ + va_list(ap); + + if (!IS_SET_SSL_FLAG(SSL_DISPLAY_BYTES)) + return; + + va_start(ap, size); + print_blob(format, data, size, va_arg(ap, char *)); + va_end(ap); + TTY_FLUSH(); +} + +/** + * Debugging routine to display SSL handshaking errors. + */ +EXP_FUNC void STDCALL ssl_display_error(int error_code) +{ + if (error_code == SSL_OK) + return; + + printf("Error: "); + + /* X509 error? */ + if (error_code < SSL_X509_OFFSET) + { + printf("%s\n", x509_display_error(error_code - SSL_X509_OFFSET)); + return; + } + + /* SSL alert error code */ + if (error_code > SSL_ERROR_CONN_LOST) + { + printf("SSL error %d\n", -error_code); + return; + } + + switch (error_code) + { + case SSL_ERROR_DEAD: + printf("connection dead"); + break; + + case SSL_ERROR_RECORD_OVERFLOW: + printf("record overflow"); + break; + + case SSL_ERROR_INVALID_HANDSHAKE: + printf("invalid handshake"); + break; + + case SSL_ERROR_INVALID_PROT_MSG: + printf("invalid protocol message"); + break; + + case SSL_ERROR_INVALID_HMAC: + printf("invalid mac"); + break; + + case SSL_ERROR_INVALID_VERSION: + printf("invalid version"); + break; + + case SSL_ERROR_INVALID_SESSION: + printf("invalid session"); + break; + + case SSL_ERROR_NO_CIPHER: + printf("no cipher"); + break; + + case SSL_ERROR_INVALID_CERT_HASH_ALG: + printf("invalid cert hash algorithm"); + break; + + case SSL_ERROR_CONN_LOST: + printf("connection lost"); + break; + + case SSL_ERROR_BAD_CERTIFICATE: + printf("bad certificate"); + break; + + case SSL_ERROR_INVALID_KEY: + printf("invalid key"); + break; + + case SSL_ERROR_FINISHED_INVALID: + printf("finished invalid"); + break; + + case SSL_ERROR_NO_CERT_DEFINED: + printf("no certificate defined"); + break; + + case SSL_ERROR_NO_CLIENT_RENOG: + printf("client renegotiation not supported"); + break; + + case SSL_ERROR_NOT_SUPPORTED: + printf("Option not supported"); + break; + + default: + printf("undefined as yet - %d", error_code); + break; + } + + printf("\n"); +} + +/** + * Debugging routine to display alerts. + */ + +/** + * Debugging routine to display alerts. + */ +void DISPLAY_ALERT(SSL *ssl, int alert) +{ + if (!IS_SET_SSL_FLAG(SSL_DISPLAY_STATES)) + return; + + printf("Alert: "); + + switch (alert) + { + case SSL_ALERT_CLOSE_NOTIFY: + printf("close notify"); + break; + + case SSL_ALERT_UNEXPECTED_MESSAGE: + printf("unexpected message"); + break; + + case SSL_ALERT_BAD_RECORD_MAC: + printf("bad record mac"); + break; + + case SSL_ALERT_RECORD_OVERFLOW: + printf("record overlow"); + break; + + case SSL_ALERT_HANDSHAKE_FAILURE: + printf("handshake failure"); + break; + + case SSL_ALERT_BAD_CERTIFICATE: + printf("bad certificate"); + break; + + case SSL_ALERT_UNSUPPORTED_CERTIFICATE: + printf("unsupported certificate"); + break; + + case SSL_ALERT_CERTIFICATE_EXPIRED: + printf("certificate expired"); + break; + + case SSL_ALERT_CERTIFICATE_UNKNOWN: + printf("certificate unknown"); + break; + + case SSL_ALERT_ILLEGAL_PARAMETER: + printf("illegal parameter"); + break; + + case SSL_ALERT_UNKNOWN_CA: + printf("unknown ca"); + break; + + case SSL_ALERT_DECODE_ERROR: + printf("decode error"); + break; + + case SSL_ALERT_DECRYPT_ERROR: + printf("decrypt error"); + break; + + case SSL_ALERT_INVALID_VERSION: + printf("invalid version"); + break; + + case SSL_ALERT_NO_RENEGOTIATION: + printf("no renegotiation"); + break; + + default: + printf("alert - (unknown %d)", alert); + break; + } + + printf("\n"); +} + +#endif /* CONFIG_SSL_FULL_MODE */ + +/** + * Return the version of this library. + */ +EXP_FUNC const char * STDCALL ssl_version() +{ + static const char * axtls_version = AXTLS_VERSION; + return axtls_version; +} + +/** + * Enable the various language bindings to work regardless of the + * configuration - they just return an error statement and a bad return code. + */ +#if !defined(CONFIG_SSL_DIAGNOSTICS) +EXP_FUNC void STDCALL ssl_display_error(int error_code) {} +#endif + +#ifdef CONFIG_BINDINGS +#if !defined(CONFIG_SSL_ENABLE_CLIENT) +EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, long client_fd, const + uint8_t *session_id, uint8_t sess_id_size) +{ + printf("%s", unsupported_str); + return NULL; +} +#endif + +#if !defined(CONFIG_SSL_CERT_VERIFICATION) +EXP_FUNC int STDCALL ssl_verify_cert(const SSL *ssl) +{ + printf("%s", unsupported_str); + return -1; +} + + +EXP_FUNC const char * STDCALL ssl_get_cert_dn(const SSL *ssl, int component) +{ + printf("%s", unsupported_str); + return NULL; +} + +EXP_FUNC const char * STDCALL ssl_get_cert_subject_alt_dnsname(const SSL *ssl, int index) +{ + printf("%s", unsupported_str); + return NULL; +} + +#endif /* CONFIG_SSL_CERT_VERIFICATION */ + +#endif /* CONFIG_BINDINGS */ + diff --git a/user/mpy/lib/axtls/ssl/tls1.h b/user/mpy/lib/axtls/ssl/tls1.h new file mode 100755 index 0000000..b656380 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/tls1.h @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file tls1.h + * + * @brief The definitions for the TLS library. + */ +#ifndef HEADER_SSL_LIB_H +#define HEADER_SSL_LIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "version.h" +#include "config.h" +#include "os_int.h" +#include "os_port.h" +#include "crypto.h" +#include "crypto_misc.h" + +#define SSL_PROTOCOL_MIN_VERSION 0x31 /* TLS v1.0 */ +#define SSL_PROTOCOL_VERSION_MAX 0x33 /* TLS v1.3 */ +#define SSL_PROTOCOL_VERSION_TLS1_1 0x32 /* TLS v1.1 */ +#define SSL_PROTOCOL_VERSION_TLS1_2 0x33 /* TLS v1.2 */ +#define SSL_RANDOM_SIZE 32 +#define SSL_SECRET_SIZE 48 +#define SSL_FINISHED_HASH_SIZE 12 +#define SSL_RECORD_SIZE 5 +#define SSL_SERVER_READ 0 +#define SSL_SERVER_WRITE 1 +#define SSL_CLIENT_READ 2 +#define SSL_CLIENT_WRITE 3 +#define SSL_HS_HDR_SIZE 4 + +/* the flags we use while establishing a connection */ +#define SSL_NEED_RECORD 0x0001 +#define SSL_TX_ENCRYPTED 0x0002 +#define SSL_RX_ENCRYPTED 0x0004 +#define SSL_SESSION_RESUME 0x0008 +#define SSL_IS_CLIENT 0x0010 +#define SSL_HAS_CERT_REQ 0x0020 +#define SSL_SENT_CLOSE_NOTIFY 0x0040 + +/* some macros to muck around with flag bits */ +#define SET_SSL_FLAG(A) (ssl->flag |= A) +#define CLR_SSL_FLAG(A) (ssl->flag &= ~A) +#define IS_SET_SSL_FLAG(A) (ssl->flag & A) + +#define MAX_KEY_BYTE_SIZE 512 /* for a 4096 bit key */ +/* On send, will send another SSL fragment if plaintext exceeds RT_MAX_PLAIN_LENGTH */ +#ifndef RT_MAX_PLAIN_LENGTH +#define RT_MAX_PLAIN_LENGTH 16384 +#endif +/* Total receive buffer is RT_MAX_PLAIN_LENGTH + RT_EXTRA */ +#ifndef RT_EXTRA +#define RT_EXTRA 1024 +#endif +#define BM_RECORD_OFFSET 5 + +#define NUM_PROTOCOLS 4 + +#define MAX_SIG_ALGORITHMS 4 +#define SIG_ALG_SHA1 2 +#define SIG_ALG_SHA256 4 +#define SIG_ALG_SHA384 5 +#define SIG_ALG_SHA512 6 +#define SIG_ALG_RSA 1 + +#define PARANOIA_CHECK(A, B) if (A < B) { \ + ret = SSL_ERROR_INVALID_HANDSHAKE; goto error; } + +/* protocol types */ +enum +{ + PT_CHANGE_CIPHER_SPEC = 20, + PT_ALERT_PROTOCOL, + PT_HANDSHAKE_PROTOCOL, + PT_APP_PROTOCOL_DATA +}; + +/* handshaking types */ +enum +{ + HS_HELLO_REQUEST, + HS_CLIENT_HELLO, + HS_SERVER_HELLO, + HS_CERTIFICATE = 11, + HS_SERVER_KEY_XCHG, + HS_CERT_REQ, + HS_SERVER_HELLO_DONE, + HS_CERT_VERIFY, + HS_CLIENT_KEY_XCHG, + HS_FINISHED = 20 +}; + +/* SSL extension types */ +enum +{ + SSL_EXT_SERVER_NAME = 0, + SSL_EXT_MAX_FRAGMENT_SIZE, + SSL_EXT_SIG_ALG = 0x0d, +}; + +typedef struct +{ + uint8_t cipher; + uint8_t key_size; + uint8_t iv_size; + uint8_t padding_size; + uint8_t digest_size; + uint8_t key_block_size; + hmac_func hmac; + crypt_func encrypt; + crypt_func decrypt; +} cipher_info_t; + +struct _SSLObjLoader +{ + uint8_t *buf; + int len; +}; + +typedef struct _SSLObjLoader SSLObjLoader; + +typedef struct +{ + time_t conn_time; + uint8_t session_id[SSL_SESSION_ID_SIZE]; + uint8_t master_secret[SSL_SECRET_SIZE]; +} SSL_SESSION; + +typedef struct +{ + uint8_t *buf; + int size; + uint8_t hash_alg; +} SSL_CERT; + +typedef struct +{ + MD5_CTX md5_ctx; + SHA1_CTX sha1_ctx; + SHA256_CTX sha256_ctx; + uint8_t client_random[SSL_RANDOM_SIZE]; /* client's random sequence */ + uint8_t server_random[SSL_RANDOM_SIZE]; /* server's random sequence */ + uint8_t final_finish_mac[128]; + uint8_t master_secret[SSL_SECRET_SIZE]; + uint8_t key_block[256]; + uint16_t bm_proc_index; + uint8_t key_block_generated; +} DISPOSABLE_CTX; + +typedef struct +{ + char *host_name; /* Needed for the SNI support */ + /* Needed for the Max Fragment Size Extension. + Allowed values: 2^9, 2^10 .. 2^14 */ + uint16_t max_fragment_size; +} SSL_EXTENSIONS; + +struct _SSL +{ + uint32_t flag; + uint16_t need_bytes; + uint16_t got_bytes; + uint8_t record_type; + uint8_t cipher; + uint8_t sess_id_size; + uint8_t version; + uint8_t client_version; + int16_t next_state; + int16_t hs_status; + DISPOSABLE_CTX *dc; /* temporary data which we'll get rid of soon */ + long client_fd; + const cipher_info_t *cipher_info; + void *encrypt_ctx; + void *decrypt_ctx; + uint8_t bm_all_data[RT_MAX_PLAIN_LENGTH+RT_EXTRA]; + uint8_t *bm_data; + uint16_t bm_index; + uint16_t bm_read_index; + uint8_t sig_algs[MAX_SIG_ALGORITHMS]; + uint8_t num_sig_algs; + struct _SSL *next; /* doubly linked list */ + struct _SSL *prev; + struct _SSL_CTX *ssl_ctx; /* back reference to a clnt/svr ctx */ +#ifndef CONFIG_SSL_SKELETON_MODE + uint16_t session_index; + SSL_SESSION *session; +#endif +#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_ENABLE_CLIENT) + X509_CTX *x509_ctx; +#endif + + uint8_t session_id[SSL_SESSION_ID_SIZE]; + uint8_t client_mac[SHA256_SIZE]; /* for HMAC verification */ + uint8_t server_mac[SHA256_SIZE]; /* for HMAC verification */ + uint8_t read_sequence[8]; /* 64 bit sequence number */ + uint8_t write_sequence[8]; /* 64 bit sequence number */ + uint8_t hmac_header[SSL_RECORD_SIZE]; /* rx hmac */ + SSL_EXTENSIONS *extensions; /* Contains the SSL (client) extensions */ +}; + +typedef struct _SSL SSL; + +struct _SSL_CTX +{ + uint32_t options; + uint8_t chain_length; + RSA_CTX *rsa_ctx; +#ifdef CONFIG_SSL_CERT_VERIFICATION + CA_CERT_CTX *ca_cert_ctx; +#endif + SSL *head; + SSL *tail; + SSL_CERT certs[CONFIG_SSL_MAX_CERTS]; +#ifndef CONFIG_SSL_SKELETON_MODE + uint16_t num_sessions; + SSL_SESSION **ssl_sessions; +#endif +#ifdef CONFIG_SSL_CTX_MUTEXING + SSL_CTX_MUTEX_TYPE mutex; +#endif +#ifdef CONFIG_OPENSSL_COMPATIBLE + void *bonus_attr; +#endif +}; + +typedef struct _SSL_CTX SSL_CTX; + +/* backwards compatibility */ +typedef struct _SSL_CTX SSLCTX; + +extern const uint8_t ssl_prot_prefs[NUM_PROTOCOLS]; + +SSL *ssl_new(SSL_CTX *ssl_ctx, long client_fd); +void disposable_new(SSL *ssl); +void disposable_free(SSL *ssl); +int send_packet(SSL *ssl, uint8_t protocol, + const uint8_t *in, int length); +int do_svr_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len); +int do_clnt_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len); +int process_finished(SSL *ssl, uint8_t *buf, int hs_len); +int process_sslv23_client_hello(SSL *ssl); +int send_alert(SSL *ssl, int error_code); +int send_finished(SSL *ssl); +int send_certificate(SSL *ssl); +int basic_read(SSL *ssl, uint8_t **in_data); +int send_change_cipher_spec(SSL *ssl); +int finished_digest(SSL *ssl, const char *label, uint8_t *digest); +void generate_master_secret(SSL *ssl, const uint8_t *premaster_secret); +void add_packet(SSL *ssl, const uint8_t *pkt, int len); +int add_cert(SSL_CTX *ssl_ctx, const uint8_t *buf, int len); +int add_private_key(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj); +void ssl_obj_free(SSLObjLoader *ssl_obj); +int pkcs8_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password); +int pkcs12_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password); +int load_key_certs(SSL_CTX *ssl_ctx); +#ifdef CONFIG_SSL_CERT_VERIFICATION +int add_cert_auth(SSL_CTX *ssl_ctx, const uint8_t *buf, int len); +void remove_ca_certs(CA_CERT_CTX *ca_cert_ctx); +#endif +#ifdef CONFIG_SSL_ENABLE_CLIENT +int do_client_connect(SSL *ssl); +#endif + +#ifdef CONFIG_SSL_DIAGNOSTICS +void DISPLAY_STATE(SSL *ssl, int is_send, uint8_t state, int not_ok); +void DISPLAY_BYTES(SSL *ssl, const char *format, + const uint8_t *data, int size, ...); +void DISPLAY_CERT(SSL *ssl, const X509_CTX *x509_ctx); +void DISPLAY_RSA(SSL *ssl, const RSA_CTX *rsa_ctx); +void DISPLAY_ALERT(SSL *ssl, int alert); +#else +#define DISPLAY_STATE(A,B,C,D) +#define DISPLAY_CERT(A,B) +#define DISPLAY_RSA(A,B) +#define DISPLAY_ALERT(A, B) +#ifdef WIN32 +void DISPLAY_BYTES(SSL *ssl, const char *format,/* win32 has no variadic macros */ + const uint8_t *data, int size, ...); +#else +#define DISPLAY_BYTES(A,B,C,D,...) +#endif +#endif + +//#ifdef CONFIG_SSL_CERT_VERIFICATION +int process_certificate(SSL *ssl, X509_CTX **x509_ctx); +//#endif + +SSL_SESSION *ssl_session_update(int max_sessions, + SSL_SESSION *ssl_sessions[], SSL *ssl, + const uint8_t *session_id); +void kill_ssl_session(SSL_SESSION **ssl_sessions, SSL *ssl); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/axtls/ssl/tls1_clnt.c b/user/mpy/lib/axtls/ssl/tls1_clnt.c new file mode 100644 index 0000000..667825f --- /dev/null +++ b/user/mpy/lib/axtls/ssl/tls1_clnt.c @@ -0,0 +1,546 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +#ifdef CONFIG_SSL_ENABLE_CLIENT /* all commented out if no client */ + +/* support sha512/384/256/1 RSA */ +static const uint8_t g_sig_alg[] = { + 0x00, SSL_EXT_SIG_ALG, + 0x00, 0x0a, 0x00, 0x08, + SIG_ALG_SHA512, SIG_ALG_RSA, + SIG_ALG_SHA384, SIG_ALG_RSA, + SIG_ALG_SHA256, SIG_ALG_RSA, + SIG_ALG_SHA1, SIG_ALG_RSA +}; + +static const uint8_t g_asn1_sha256[] = +{ + 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, + 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 +}; + +static int send_client_hello(SSL *ssl); +static int process_server_hello(SSL *ssl); +static int process_server_hello_done(SSL *ssl); +static int send_client_key_xchg(SSL *ssl); +static int process_cert_req(SSL *ssl); +static int send_cert_verify(SSL *ssl); + +/* + * Establish a new SSL connection to an SSL server. + */ +EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, long client_fd, const + uint8_t *session_id, uint8_t sess_id_size, SSL_EXTENSIONS* ssl_ext) +{ + SSL *ssl = ssl_new(ssl_ctx, client_fd); + ssl->version = SSL_PROTOCOL_VERSION_MAX; /* try top version first */ + +#ifndef CONFIG_SSL_SKELETON_MODE + if (session_id && ssl_ctx->num_sessions) + { + if (sess_id_size > SSL_SESSION_ID_SIZE) /* validity check */ + { + ssl_free(ssl); + return NULL; + } + + memcpy(ssl->session_id, session_id, sess_id_size); + ssl->sess_id_size = sess_id_size; + SET_SSL_FLAG(SSL_SESSION_RESUME); /* just flag for later */ + } +#endif + + ssl->extensions = ssl_ext; + + SET_SSL_FLAG(SSL_IS_CLIENT); + do_client_connect(ssl); + return ssl; +} + +/* + * Process the handshake record. + */ +int do_clnt_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len) +{ + int ret; + + /* To get here the state must be valid */ + switch (handshake_type) + { + case HS_SERVER_HELLO: + ret = process_server_hello(ssl); + break; + + case HS_CERTIFICATE: + ret = process_certificate(ssl, &ssl->x509_ctx); + break; + + case HS_SERVER_HELLO_DONE: + if ((ret = process_server_hello_done(ssl)) == SSL_OK) + { + if (IS_SET_SSL_FLAG(SSL_HAS_CERT_REQ)) + { + if ((ret = send_certificate(ssl)) == SSL_OK && + (ret = send_client_key_xchg(ssl)) == SSL_OK) + { + send_cert_verify(ssl); + } + } + else + { + ret = send_client_key_xchg(ssl); + } + + if (ret == SSL_OK && + (ret = send_change_cipher_spec(ssl)) == SSL_OK) + { + ret = send_finished(ssl); + } + } + break; + + case HS_CERT_REQ: + ret = process_cert_req(ssl); + break; + + case HS_FINISHED: + ret = process_finished(ssl, buf, hs_len); + disposable_free(ssl); /* free up some memory */ + /* note: client renegotiation is not allowed after this */ + break; + + case HS_HELLO_REQUEST: + disposable_new(ssl); + ret = do_client_connect(ssl); + break; + + default: + ret = SSL_ERROR_INVALID_HANDSHAKE; + break; + } + + return ret; +} + +/* + * Do the handshaking from the beginning. + */ +int do_client_connect(SSL *ssl) +{ + int ret = SSL_OK; + + send_client_hello(ssl); /* send the client hello */ + ssl->bm_read_index = 0; + ssl->next_state = HS_SERVER_HELLO; + ssl->hs_status = SSL_NOT_OK; /* not connected */ + + /* sit in a loop until it all looks good */ + if (!IS_SET_SSL_FLAG(SSL_CONNECT_IN_PARTS)) + { + while (ssl->hs_status != SSL_OK) + { + ret = ssl_read(ssl, NULL); + + if (ret < SSL_OK) + break; + } + + ssl->hs_status = ret; /* connected? */ + } + + return ret; +} + +/* + * Send the initial client hello. + */ +static int send_client_hello(SSL *ssl) +{ + uint8_t *buf = ssl->bm_data; + time_t tm = time(NULL); + uint8_t *tm_ptr = &buf[6]; /* time will go here */ + int i, offset, ext_offset; + int ext_len = 0; + + + buf[0] = HS_CLIENT_HELLO; + buf[1] = 0; + buf[2] = 0; + /* byte 3 is calculated later */ + buf[4] = 0x03; + buf[5] = ssl->version & 0x0f; + + /* client random value - spec says that 1st 4 bytes are big endian time */ + *tm_ptr++ = (uint8_t)(((long)tm & 0xff000000) >> 24); + *tm_ptr++ = (uint8_t)(((long)tm & 0x00ff0000) >> 16); + *tm_ptr++ = (uint8_t)(((long)tm & 0x0000ff00) >> 8); + *tm_ptr++ = (uint8_t)(((long)tm & 0x000000ff)); + if (get_random(SSL_RANDOM_SIZE-4, &buf[10]) < 0) + return SSL_NOT_OK; + + memcpy(ssl->dc->client_random, &buf[6], SSL_RANDOM_SIZE); + offset = 6 + SSL_RANDOM_SIZE; + + /* give session resumption a go */ + if (IS_SET_SSL_FLAG(SSL_SESSION_RESUME)) /* set initially by user */ + { + buf[offset++] = ssl->sess_id_size; + memcpy(&buf[offset], ssl->session_id, ssl->sess_id_size); + offset += ssl->sess_id_size; + CLR_SSL_FLAG(SSL_SESSION_RESUME); /* clear so we can set later */ + } + else + { + /* no session id - because no session resumption just yet */ + buf[offset++] = 0; + } + + buf[offset++] = 0; /* number of ciphers */ + buf[offset++] = NUM_PROTOCOLS*2;/* number of ciphers */ + + /* put all our supported protocols in our request */ + for (i = 0; i < NUM_PROTOCOLS; i++) + { + buf[offset++] = 0; /* cipher we are using */ + buf[offset++] = ssl_prot_prefs[i]; + } + + buf[offset++] = 1; /* no compression */ + buf[offset++] = 0; + + ext_offset = offset; + + buf[offset++] = 0; /* total length of extensions */ + buf[offset++] = 0; + + /* send the signature algorithm extension for TLS 1.2+ */ + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) + { + memcpy(&buf[offset], g_sig_alg, sizeof(g_sig_alg)); + offset += sizeof(g_sig_alg); + ext_len += sizeof(g_sig_alg); + } + + if (ssl->extensions != NULL) + { + /* send the host name if specified */ + if (ssl->extensions->host_name != NULL) + { + size_t host_len = strlen(ssl->extensions->host_name); + buf[offset++] = 0; + buf[offset++] = SSL_EXT_SERVER_NAME; /* server_name(0) (65535) */ + buf[offset++] = 0; + buf[offset++] = host_len + 5; /* server_name length */ + buf[offset++] = 0; + buf[offset++] = host_len + 3; /* server_list length */ + buf[offset++] = 0; /* host_name(0) (255) */ + buf[offset++] = 0; + buf[offset++] = host_len; /* host_name length */ + strncpy((char*) &buf[offset], ssl->extensions->host_name, host_len); + offset += host_len; + ext_len += host_len + 9; + } + + if (ssl->extensions->max_fragment_size) + { + buf[offset++] = 0; + buf[offset++] = SSL_EXT_MAX_FRAGMENT_SIZE; + + buf[offset++] = 0; // size of data + buf[offset++] = 2; + + buf[offset++] = (uint8_t) + ((ssl->extensions->max_fragment_size >> 8) & 0xff); + buf[offset++] = (uint8_t) + (ssl->extensions->max_fragment_size & 0xff); + ext_len += 6; + } + } + + if (ext_len > 0) + { + // update the extensions length value + buf[ext_offset] = (uint8_t) ((ext_len >> 8) & 0xff); + buf[ext_offset + 1] = (uint8_t) (ext_len & 0xff); + } + + buf[3] = offset - 4; /* handshake size */ + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, offset); +} + +/* + * Process the server hello. + */ +static int process_server_hello(SSL *ssl) +{ + uint8_t *buf = ssl->bm_data; + int pkt_size = ssl->bm_index; +#ifndef CONFIG_SSL_SKELETON_MODE + int num_sessions = ssl->ssl_ctx->num_sessions; +#endif + uint8_t sess_id_size; + int offset, ret = SSL_OK; + + /* check that we are talking to a TLSv1 server */ + uint8_t version = (buf[4] << 4) + buf[5]; + if (version > SSL_PROTOCOL_VERSION_MAX) + { + version = SSL_PROTOCOL_VERSION_MAX; + } + else if (ssl->version < SSL_PROTOCOL_MIN_VERSION) + { + ret = SSL_ERROR_INVALID_VERSION; +#ifdef CONFIG_SSL_DIAGNOSTICS + ssl_display_error(ret); +#endif + goto error; + } + + ssl->version = version; + + /* get the server random value */ + memcpy(ssl->dc->server_random, &buf[6], SSL_RANDOM_SIZE); + offset = 6 + SSL_RANDOM_SIZE; /* skip of session id size */ + sess_id_size = buf[offset++]; + + if (sess_id_size > SSL_SESSION_ID_SIZE) + { + ret = SSL_ERROR_INVALID_SESSION; + goto error; + } + +#ifndef CONFIG_SSL_SKELETON_MODE + if (num_sessions) + { + ssl->session = ssl_session_update(num_sessions, + ssl->ssl_ctx->ssl_sessions, ssl, &buf[offset]); + memcpy(ssl->session->session_id, &buf[offset], sess_id_size); + + /* pad the rest with 0's */ + if (sess_id_size < SSL_SESSION_ID_SIZE) + { + memset(&ssl->session->session_id[sess_id_size], 0, + SSL_SESSION_ID_SIZE-sess_id_size); + } + } +#endif + + memcpy(ssl->session_id, &buf[offset], sess_id_size); + ssl->sess_id_size = sess_id_size; + offset += sess_id_size; + + /* get the real cipher we are using - ignore MSB */ + ssl->cipher = buf[++offset]; + ssl->next_state = IS_SET_SSL_FLAG(SSL_SESSION_RESUME) ? + HS_FINISHED : HS_CERTIFICATE; + + offset += 2; // ignore compression + PARANOIA_CHECK(pkt_size, offset); + + ssl->dc->bm_proc_index = offset; + PARANOIA_CHECK(pkt_size, offset); + + // no extensions +error: + return ret; +} + +/** + * Process the server hello done message. + */ +static int process_server_hello_done(SSL *ssl) +{ + ssl->next_state = HS_FINISHED; + return SSL_OK; +} + +/* + * Send a client key exchange message. + */ +static int send_client_key_xchg(SSL *ssl) +{ + uint8_t *buf = ssl->bm_data; + uint8_t premaster_secret[SSL_SECRET_SIZE]; + int enc_secret_size = -1; + + buf[0] = HS_CLIENT_KEY_XCHG; + buf[1] = 0; + + // spec says client must use the what is initially negotiated - + // and this is our current version + premaster_secret[0] = 0x03; + premaster_secret[1] = SSL_PROTOCOL_VERSION_MAX & 0x0f; + if (get_random(SSL_SECRET_SIZE-2, &premaster_secret[2]) < 0) + return SSL_NOT_OK; + + DISPLAY_RSA(ssl, ssl->x509_ctx->rsa_ctx); + + /* rsa_ctx->bi_ctx is not thread-safe */ + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + enc_secret_size = RSA_encrypt(ssl->x509_ctx->rsa_ctx, premaster_secret, + SSL_SECRET_SIZE, &buf[6], 0); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + + buf[2] = (enc_secret_size + 2) >> 8; + buf[3] = (enc_secret_size + 2) & 0xff; + buf[4] = enc_secret_size >> 8; + buf[5] = enc_secret_size & 0xff; + + generate_master_secret(ssl, premaster_secret); + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, enc_secret_size+6); +} + +/* + * Process the certificate request. + */ +static int process_cert_req(SSL *ssl) +{ + uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; + int ret = SSL_OK; + int cert_req_size = (buf[2]<<8) + buf[3]; + int offset = 4; + int pkt_size = ssl->bm_index; + uint8_t cert_type_len, sig_alg_len; + + PARANOIA_CHECK(pkt_size, offset + cert_req_size); + ssl->dc->bm_proc_index = cert_req_size; + + /* don't do any processing - we will send back an RSA certificate anyway */ + ssl->next_state = HS_SERVER_HELLO_DONE; + SET_SSL_FLAG(SSL_HAS_CERT_REQ); + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + // supported certificate types + cert_type_len = buf[offset++]; + PARANOIA_CHECK(pkt_size, offset + cert_type_len); + offset += cert_type_len; + + // supported signature algorithms + sig_alg_len = buf[offset++] << 8; + sig_alg_len += buf[offset++]; + PARANOIA_CHECK(pkt_size, offset + sig_alg_len); + + while (sig_alg_len > 0) + { + uint8_t hash_alg = buf[offset++]; + uint8_t sig_alg = buf[offset++]; + sig_alg_len -= 2; + + if (sig_alg == SIG_ALG_RSA && + (hash_alg == SIG_ALG_SHA1 || + hash_alg == SIG_ALG_SHA256 || + hash_alg == SIG_ALG_SHA384 || + hash_alg == SIG_ALG_SHA512)) + { + ssl->sig_algs[ssl->num_sig_algs++] = hash_alg; + } + } + } + +error: + return ret; +} + +/* + * Send a certificate verify message. + */ +static int send_cert_verify(SSL *ssl) +{ + uint8_t *buf = ssl->bm_data; + uint8_t dgst[SHA1_SIZE+MD5_SIZE+15]; + RSA_CTX *rsa_ctx = ssl->ssl_ctx->rsa_ctx; + int n = 0, ret; + int offset = 0; + int dgst_len; + + if (rsa_ctx == NULL) + return SSL_OK; + + DISPLAY_RSA(ssl, rsa_ctx); + + buf[0] = HS_CERT_VERIFY; + buf[1] = 0; + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + buf[4] = SIG_ALG_SHA256; + buf[5] = SIG_ALG_RSA; + offset = 6; + memcpy(dgst, g_asn1_sha256, sizeof(g_asn1_sha256)); + dgst_len = finished_digest(ssl, NULL, &dgst[sizeof(g_asn1_sha256)]) + + sizeof(g_asn1_sha256); + } + else + { + offset = 4; + dgst_len = finished_digest(ssl, NULL, dgst); + } + + /* rsa_ctx->bi_ctx is not thread-safe */ + if (rsa_ctx) + { + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + n = RSA_encrypt(rsa_ctx, dgst, dgst_len, &buf[offset + 2], 1); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + + if (n == 0) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + } + + buf[offset] = n >> 8; /* add the RSA size */ + buf[offset+1] = n & 0xff; + n += 2; + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + n += 2; // sig/alg + offset -= 2; + } + + buf[2] = n >> 8; + buf[3] = n & 0xff; + ret = send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, n + offset); + +error: + return ret; +} + +#endif /* CONFIG_SSL_ENABLE_CLIENT */ diff --git a/user/mpy/lib/axtls/ssl/tls1_svr.c b/user/mpy/lib/axtls/ssl/tls1_svr.c new file mode 100644 index 0000000..f45b0c5 --- /dev/null +++ b/user/mpy/lib/axtls/ssl/tls1_svr.c @@ -0,0 +1,533 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include "os_port.h" +#include "ssl.h" + +#ifdef CONFIG_SSL_ENABLE_SERVER + +static const uint8_t g_hello_done[] = { HS_SERVER_HELLO_DONE, 0, 0, 0 }; +static const uint8_t g_asn1_sha256[] = +{ + 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, + 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 +}; + +static int process_client_hello(SSL *ssl); +static int send_server_hello_sequence(SSL *ssl); +static int send_server_hello(SSL *ssl); +static int send_server_hello_done(SSL *ssl); +static int process_client_key_xchg(SSL *ssl); +#ifdef CONFIG_SSL_CERT_VERIFICATION +static int send_certificate_request(SSL *ssl); +static int process_cert_verify(SSL *ssl); +#endif + +/* + * Establish a new SSL connection to an SSL client. + */ +EXP_FUNC SSL * STDCALL ssl_server_new(SSL_CTX *ssl_ctx, long client_fd) +{ + SSL *ssl; + + ssl = ssl_new(ssl_ctx, client_fd); + ssl->next_state = HS_CLIENT_HELLO; + +#ifdef CONFIG_SSL_DIAGNOSTICS + if (ssl_ctx->chain_length == 0) + printf("Warning - no server certificate defined\n"); TTY_FLUSH(); +#endif + + return ssl; +} + +/* + * Process the handshake record. + */ +int do_svr_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len) +{ + int ret = SSL_OK; + ssl->hs_status = SSL_NOT_OK; /* not connected */ + + /* To get here the state must be valid */ + switch (handshake_type) + { + case HS_CLIENT_HELLO: + if ((ret = process_client_hello(ssl)) == SSL_OK) + ret = send_server_hello_sequence(ssl); + break; + +#ifdef CONFIG_SSL_CERT_VERIFICATION + case HS_CERTIFICATE:/* the client sends its cert */ + ret = process_certificate(ssl, &ssl->x509_ctx); + + if (ret == SSL_OK) /* verify the cert */ + { + int cert_res; + int pathLenConstraint = 0; + + cert_res = x509_verify(ssl->ssl_ctx->ca_cert_ctx, + ssl->x509_ctx, &pathLenConstraint); + ret = (cert_res == 0) ? SSL_OK : SSL_X509_ERROR(cert_res); + } + break; + + case HS_CERT_VERIFY: + ret = process_cert_verify(ssl); + add_packet(ssl, buf, hs_len); /* needs to be done after */ + break; +#endif + case HS_CLIENT_KEY_XCHG: + ret = process_client_key_xchg(ssl); + break; + + case HS_FINISHED: + ret = process_finished(ssl, buf, hs_len); + disposable_free(ssl); /* free up some memory */ + break; + } + + return ret; +} + +/* + * Process a client hello message. + */ +static int process_client_hello(SSL *ssl) +{ + uint8_t *buf = ssl->bm_data; + int pkt_size = ssl->bm_index; + int i, j, cs_len, id_len, offset = 6 + SSL_RANDOM_SIZE; + int ret = SSL_OK; + + uint8_t version = (buf[4] << 4) + buf[5]; + ssl->version = ssl->client_version = version; + + if (version > SSL_PROTOCOL_VERSION_MAX) + { + /* use client's version instead */ + ssl->version = SSL_PROTOCOL_VERSION_MAX; + } + else if (version < SSL_PROTOCOL_MIN_VERSION) /* old version supported? */ + { + ret = SSL_ERROR_INVALID_VERSION; +#ifdef CONFIG_SSL_DIAGNOSTICS + ssl_display_error(ret); +#endif + goto error; + } + + memcpy(ssl->dc->client_random, &buf[6], SSL_RANDOM_SIZE); + + /* process the session id */ + id_len = buf[offset++]; + if (id_len > SSL_SESSION_ID_SIZE) + { + return SSL_ERROR_INVALID_SESSION; + } + +#ifndef CONFIG_SSL_SKELETON_MODE + ssl->session = ssl_session_update(ssl->ssl_ctx->num_sessions, + ssl->ssl_ctx->ssl_sessions, ssl, id_len ? &buf[offset] : NULL); +#endif + + offset += id_len; + cs_len = (buf[offset]<<8) + buf[offset+1]; + offset += 3; /* add 1 due to all cipher suites being 8 bit */ + + PARANOIA_CHECK(pkt_size, offset + cs_len); + + /* work out what cipher suite we are going to use - client defines + the preference */ + for (i = 0; i < cs_len; i += 2) + { + for (j = 0; j < NUM_PROTOCOLS; j++) + { + if (ssl_prot_prefs[j] == buf[offset+i]) /* got a match? */ + { + ssl->cipher = ssl_prot_prefs[j]; + goto do_compression; + } + } + } + + /* ouch! protocol is not supported */ + return SSL_ERROR_NO_CIPHER; + + /* completely ignore compression */ +do_compression: + offset += cs_len; + id_len = buf[offset++]; + offset += id_len; + PARANOIA_CHECK(pkt_size, offset + id_len); + + if (offset == pkt_size) + { + /* no extensions */ + goto error; + } + + /* extension size */ + id_len = buf[offset++] << 8; + id_len += buf[offset++]; + PARANOIA_CHECK(pkt_size, offset + id_len); + + // Check for extensions from the client - only the signature algorithm + // is supported + while (offset < pkt_size) + { + int ext = buf[offset++] << 8; + ext += buf[offset++]; + int ext_len = buf[offset++] << 8; + ext_len += buf[offset++]; + PARANOIA_CHECK(pkt_size, offset + ext_len); + + if (ext == SSL_EXT_SIG_ALG) + { + while (ext_len > 0) + { + uint8_t hash_alg = buf[offset++]; + uint8_t sig_alg = buf[offset++]; + ext_len -= 2; + + if (sig_alg == SIG_ALG_RSA && + (hash_alg == SIG_ALG_SHA1 || + hash_alg == SIG_ALG_SHA256 || + hash_alg == SIG_ALG_SHA384 || + hash_alg == SIG_ALG_SHA512)) + { + ssl->sig_algs[ssl->num_sig_algs++] = hash_alg; + } + } + } + else + { + offset += ext_len; + } + } + + /* default is RSA/SHA1 */ + if (ssl->num_sig_algs == 0) + { + ssl->sig_algs[ssl->num_sig_algs++] = SIG_ALG_SHA1; + } + +error: + return ret; +} + +/* + * Send the entire server hello sequence + */ +#if CONFIG_SSL_ENABLE_SERVER +static int send_server_hello_sequence(SSL *ssl) +{ + int ret; + + if ((ret = send_server_hello(ssl)) == SSL_OK) + { +#ifndef CONFIG_SSL_SKELETON_MODE + /* resume handshake? */ + if (IS_SET_SSL_FLAG(SSL_SESSION_RESUME)) + { + if ((ret = send_change_cipher_spec(ssl)) == SSL_OK) + { + ret = send_finished(ssl); + ssl->next_state = HS_FINISHED; + } + } + else +#endif + if ((ret = send_certificate(ssl)) == SSL_OK) + { +#ifdef CONFIG_SSL_CERT_VERIFICATION + /* ask the client for its certificate */ + if (IS_SET_SSL_FLAG(SSL_CLIENT_AUTHENTICATION)) + { + if ((ret = send_certificate_request(ssl)) == SSL_OK) + { + ret = send_server_hello_done(ssl); + ssl->next_state = HS_CERTIFICATE; + } + } + else +#endif + { + ret = send_server_hello_done(ssl); + ssl->next_state = HS_CLIENT_KEY_XCHG; + } + } + } + + return ret; +} + +/* + * Send a server hello message. + */ +static int send_server_hello(SSL *ssl) +{ + uint8_t *buf = ssl->bm_data; + int offset = 0; + + buf[0] = HS_SERVER_HELLO; + buf[1] = 0; + buf[2] = 0; + /* byte 3 is calculated later */ + buf[4] = 0x03; + buf[5] = ssl->version & 0x0f; + + /* server random value */ + if (get_random(SSL_RANDOM_SIZE, &buf[6]) < 0) + return SSL_NOT_OK; + + memcpy(ssl->dc->server_random, &buf[6], SSL_RANDOM_SIZE); + offset = 6 + SSL_RANDOM_SIZE; + +#ifndef CONFIG_SSL_SKELETON_MODE + if (IS_SET_SSL_FLAG(SSL_SESSION_RESUME)) + { + /* retrieve id from session cache */ + buf[offset++] = SSL_SESSION_ID_SIZE; + memcpy(&buf[offset], ssl->session->session_id, SSL_SESSION_ID_SIZE); + memcpy(ssl->session_id, ssl->session->session_id, SSL_SESSION_ID_SIZE); + ssl->sess_id_size = SSL_SESSION_ID_SIZE; + offset += SSL_SESSION_ID_SIZE; + } + else /* generate our own session id */ +#endif + { +#ifndef CONFIG_SSL_SKELETON_MODE + buf[offset++] = SSL_SESSION_ID_SIZE; + get_random(SSL_SESSION_ID_SIZE, &buf[offset]); + memcpy(ssl->session_id, &buf[offset], SSL_SESSION_ID_SIZE); + ssl->sess_id_size = SSL_SESSION_ID_SIZE; + + /* store id in session cache */ + if (ssl->ssl_ctx->num_sessions) + { + memcpy(ssl->session->session_id, + ssl->session_id, SSL_SESSION_ID_SIZE); + } + + offset += SSL_SESSION_ID_SIZE; +#else + buf[offset++] = 0; /* don't bother with session id in skelton mode */ +#endif + } + + buf[offset++] = 0; /* cipher we are using */ + buf[offset++] = ssl->cipher; + buf[offset++] = 0; /* no compression and no extensions supported */ + buf[3] = offset - 4; /* handshake size */ + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, offset); +} + +/* + * Send the server hello done message. + */ +static int send_server_hello_done(SSL *ssl) +{ + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, + g_hello_done, sizeof(g_hello_done)); +} +#endif + +/* + * Pull apart a client key exchange message. Decrypt the pre-master key (using + * our RSA private key) and then work out the master key. Initialise the + * ciphers. + */ +static int process_client_key_xchg(SSL *ssl) +{ + uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; + int pkt_size = ssl->bm_index; + int premaster_size, secret_length = (buf[2] << 8) + buf[3]; + uint8_t premaster_secret[MAX_KEY_BYTE_SIZE]; + RSA_CTX *rsa_ctx = ssl->ssl_ctx->rsa_ctx; + int offset = 4; + int ret = SSL_OK; + + if (rsa_ctx == NULL) + { + ret = SSL_ERROR_NO_CERT_DEFINED; + goto error; + } + + /* is there an extra size field? */ + if ((secret_length - 2) == rsa_ctx->num_octets) + offset += 2; + + PARANOIA_CHECK(pkt_size, rsa_ctx->num_octets+offset); + + /* rsa_ctx->bi_ctx is not thread-safe */ + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + premaster_size = RSA_decrypt(rsa_ctx, &buf[offset], premaster_secret, + sizeof(premaster_secret), 1); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + + if (premaster_size != SSL_SECRET_SIZE || + premaster_secret[0] != 0x03 || /* must be the same as client + offered version */ + premaster_secret[1] != (ssl->client_version & 0x0f)) + { + /* guard against a Bleichenbacher attack */ + if (get_random(SSL_SECRET_SIZE, premaster_secret) < 0) + return SSL_NOT_OK; + + /* and continue - will die eventually when checking the mac */ + } + + generate_master_secret(ssl, premaster_secret); + +#ifdef CONFIG_SSL_CERT_VERIFICATION + ssl->next_state = IS_SET_SSL_FLAG(SSL_CLIENT_AUTHENTICATION) ? + HS_CERT_VERIFY : HS_FINISHED; +#else + ssl->next_state = HS_FINISHED; +#endif + + ssl->dc->bm_proc_index += rsa_ctx->num_octets+offset; +error: + return ret; +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION +static const uint8_t g_cert_request[] = { HS_CERT_REQ, 0, + 0, 0x0e, + 1, 1, // rsa sign + 0x00, 0x08, + SIG_ALG_SHA256, SIG_ALG_RSA, + SIG_ALG_SHA512, SIG_ALG_RSA, + SIG_ALG_SHA384, SIG_ALG_RSA, + SIG_ALG_SHA1, SIG_ALG_RSA, + 0, 0 +}; + +static const uint8_t g_cert_request_v1[] = { HS_CERT_REQ, 0, 0, 4, 1, 0, 0, 0 }; + +/* + * Send the certificate request message. + */ +static int send_certificate_request(SSL *ssl) +{ + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, + g_cert_request, sizeof(g_cert_request)); + } + else + { + return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, + g_cert_request_v1, sizeof(g_cert_request_v1)); + } +} + +/* + * Ensure the client has the private key by first decrypting the packet and + * then checking the packet digests. + */ +static int process_cert_verify(SSL *ssl) +{ + uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; + int pkt_size = ssl->bm_index; + uint8_t dgst_buf[MAX_KEY_BYTE_SIZE]; + uint8_t dgst[MD5_SIZE + SHA1_SIZE]; + X509_CTX *x509_ctx = ssl->x509_ctx; + int ret = SSL_OK; + int offset = 6; + int rsa_len; + int n; + + DISPLAY_RSA(ssl, x509_ctx->rsa_ctx); + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + // TODO: should really need to be able to handle other algorihms. An + // assumption is made on RSA/SHA256 and appears to be OK. + //uint8_t hash_alg = buf[4]; + //uint8_t sig_alg = buf[5]; + offset = 8; + rsa_len = (buf[6] << 8) + buf[7]; + } + else + { + rsa_len = (buf[4] << 8) + buf[5]; + } + + PARANOIA_CHECK(pkt_size, offset + rsa_len); + + /* rsa_ctx->bi_ctx is not thread-safe */ + SSL_CTX_LOCK(ssl->ssl_ctx->mutex); + n = RSA_decrypt(x509_ctx->rsa_ctx, &buf[offset], dgst_buf, + sizeof(dgst_buf), 0); + SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); + + if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ + { + if (memcmp(dgst_buf, g_asn1_sha256, sizeof(g_asn1_sha256))) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + + finished_digest(ssl, NULL, dgst); /* calculate the digest */ + if (memcmp(&dgst_buf[sizeof(g_asn1_sha256)], dgst, SHA256_SIZE)) + { + ret = SSL_ERROR_INVALID_KEY; + goto error; + } + } + else // TLS1.0/1.1 + { + if (n != SHA1_SIZE + MD5_SIZE) + { + ret = SSL_ERROR_INVALID_KEY; + goto end_cert_vfy; + } + + finished_digest(ssl, NULL, dgst); /* calculate the digest */ + if (memcmp(dgst_buf, dgst, MD5_SIZE + SHA1_SIZE)) + { + ret = SSL_ERROR_INVALID_KEY; + } + } + +end_cert_vfy: + ssl->next_state = HS_FINISHED; +error: + return ret; +} + +#endif + +#endif diff --git a/user/mpy/lib/axtls/ssl/x509.c b/user/mpy/lib/axtls/ssl/x509.c new file mode 100644 index 0000000..abdebdb --- /dev/null +++ b/user/mpy/lib/axtls/ssl/x509.c @@ -0,0 +1,861 @@ +/* + * Copyright (c) 2007-2016, Cameron Rich + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the axTLS project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file x509.c + * + * Certificate processing. + */ + +#include +#include +#include +#include +#include "os_port.h" +#include "crypto_misc.h" + +#ifdef CONFIG_SSL_CERT_VERIFICATION +static int x509_v3_subject_alt_name(const uint8_t *cert, int offset, + X509_CTX *x509_ctx); +static int x509_v3_basic_constraints(const uint8_t *cert, int offset, + X509_CTX *x509_ctx); +static int x509_v3_key_usage(const uint8_t *cert, int offset, + X509_CTX *x509_ctx); + +/** + * Retrieve the signature from a certificate. + */ +static const uint8_t *get_signature(const uint8_t *asn1_sig, int *len) +{ + int offset = 0; + const uint8_t *ptr = NULL; + + if (asn1_next_obj(asn1_sig, &offset, ASN1_SEQUENCE) < 0 || + asn1_skip_obj(asn1_sig, &offset, ASN1_SEQUENCE)) + goto end_get_sig; + + if (asn1_sig[offset++] != ASN1_OCTET_STRING) + goto end_get_sig; + *len = get_asn1_length(asn1_sig, &offset); + ptr = &asn1_sig[offset]; /* all ok */ + +end_get_sig: + return ptr; +} + +#endif + +/** + * Construct a new x509 object. + * @return 0 if ok. < 0 if there was a problem. + */ +int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx) +{ + int begin_tbs, end_tbs; + int ret = X509_NOT_OK, offset = 0, cert_size = 0; + int version = 0; + X509_CTX *x509_ctx; +#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */ + BI_CTX *bi_ctx; +#endif + + *ctx = (X509_CTX *)calloc(1, sizeof(X509_CTX)); + x509_ctx = *ctx; + + /* get the certificate size */ + asn1_skip_obj(cert, &cert_size, ASN1_SEQUENCE); + + if (asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0) + goto end_cert; + + begin_tbs = offset; /* start of the tbs */ + end_tbs = begin_tbs; /* work out the end of the tbs */ + asn1_skip_obj(cert, &end_tbs, ASN1_SEQUENCE); + + if (asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0) + goto end_cert; + + /* optional version */ + if (cert[offset] == ASN1_EXPLICIT_TAG && + asn1_version(cert, &offset, &version) == X509_NOT_OK) + goto end_cert; + + if (asn1_skip_obj(cert, &offset, ASN1_INTEGER) || /* serial number */ + asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0) + goto end_cert; + + /* make sure the signature is ok */ + if (asn1_signature_type(cert, &offset, x509_ctx)) + { + ret = X509_VFY_ERROR_UNSUPPORTED_DIGEST; + goto end_cert; + } + + if (asn1_name(cert, &offset, x509_ctx->ca_cert_dn) || + asn1_validity(cert, &offset, x509_ctx) || + asn1_name(cert, &offset, x509_ctx->cert_dn) || + asn1_public_key(cert, &offset, x509_ctx)) + { + goto end_cert; + } + +#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */ + bi_ctx = x509_ctx->rsa_ctx->bi_ctx; + + /* use the appropriate signature algorithm */ + switch (x509_ctx->sig_type) + { + case SIG_TYPE_MD5: + { + MD5_CTX md5_ctx; + uint8_t md5_dgst[MD5_SIZE]; + MD5_Init(&md5_ctx); + MD5_Update(&md5_ctx, &cert[begin_tbs], end_tbs-begin_tbs); + MD5_Final(md5_dgst, &md5_ctx); + x509_ctx->digest = bi_import(bi_ctx, md5_dgst, MD5_SIZE); + } + break; + + case SIG_TYPE_SHA1: + { + SHA1_CTX sha_ctx; + uint8_t sha_dgst[SHA1_SIZE]; + SHA1_Init(&sha_ctx); + SHA1_Update(&sha_ctx, &cert[begin_tbs], end_tbs-begin_tbs); + SHA1_Final(sha_dgst, &sha_ctx); + x509_ctx->digest = bi_import(bi_ctx, sha_dgst, SHA1_SIZE); + } + break; + + case SIG_TYPE_SHA256: + { + SHA256_CTX sha256_ctx; + uint8_t sha256_dgst[SHA256_SIZE]; + SHA256_Init(&sha256_ctx); + SHA256_Update(&sha256_ctx, &cert[begin_tbs], end_tbs-begin_tbs); + SHA256_Final(sha256_dgst, &sha256_ctx); + x509_ctx->digest = bi_import(bi_ctx, sha256_dgst, SHA256_SIZE); + } + break; + + case SIG_TYPE_SHA384: + { + SHA384_CTX sha384_ctx; + uint8_t sha384_dgst[SHA384_SIZE]; + SHA384_Init(&sha384_ctx); + SHA384_Update(&sha384_ctx, &cert[begin_tbs], end_tbs-begin_tbs); + SHA384_Final(sha384_dgst, &sha384_ctx); + x509_ctx->digest = bi_import(bi_ctx, sha384_dgst, SHA384_SIZE); + } + break; + + case SIG_TYPE_SHA512: + { + SHA512_CTX sha512_ctx; + uint8_t sha512_dgst[SHA512_SIZE]; + SHA512_Init(&sha512_ctx); + SHA512_Update(&sha512_ctx, &cert[begin_tbs], end_tbs-begin_tbs); + SHA512_Final(sha512_dgst, &sha512_ctx); + x509_ctx->digest = bi_import(bi_ctx, sha512_dgst, SHA512_SIZE); + } + break; + } + + if (version == 2 && asn1_next_obj(cert, &offset, ASN1_V3_DATA) > 0) + { + x509_v3_subject_alt_name(cert, offset, x509_ctx); + x509_v3_basic_constraints(cert, offset, x509_ctx); + x509_v3_key_usage(cert, offset, x509_ctx); + } + + offset = end_tbs; /* skip the rest of v3 data */ + if (asn1_skip_obj(cert, &offset, ASN1_SEQUENCE) || + asn1_signature(cert, &offset, x509_ctx)) + goto end_cert; +#endif + ret = X509_OK; +end_cert: + if (len) + { + *len = cert_size; + } + + if (ret) + { +#ifdef CONFIG_SSL_FULL_MODE + printf("Error: Invalid X509 ASN.1 file (%s)\n", + x509_display_error(ret)); +#endif + x509_free(x509_ctx); + *ctx = NULL; + } + + return ret; +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */ +static int x509_v3_subject_alt_name(const uint8_t *cert, int offset, + X509_CTX *x509_ctx) +{ + if ((offset = asn1_is_subject_alt_name(cert, offset)) > 0) + { + x509_ctx->subject_alt_name_present = true; + x509_ctx->subject_alt_name_is_critical = + asn1_is_critical_ext(cert, &offset); + + if (asn1_next_obj(cert, &offset, ASN1_OCTET_STRING) > 0) + { + int altlen; + + if ((altlen = asn1_next_obj(cert, &offset, ASN1_SEQUENCE)) > 0) + { + int endalt = offset + altlen; + int totalnames = 0; + + while (offset < endalt) + { + int type = cert[offset++]; + int dnslen = get_asn1_length(cert, &offset); + + if (type == ASN1_CONTEXT_DNSNAME) + { + x509_ctx->subject_alt_dnsnames = (char**) + realloc(x509_ctx->subject_alt_dnsnames, + (totalnames + 2) * sizeof(char*)); + x509_ctx->subject_alt_dnsnames[totalnames] = + (char*)malloc(dnslen + 1); + x509_ctx->subject_alt_dnsnames[totalnames+1] = NULL; + memcpy(x509_ctx->subject_alt_dnsnames[totalnames], + cert + offset, dnslen); + x509_ctx->subject_alt_dnsnames[totalnames][dnslen] = 0; + totalnames++; + } + + offset += dnslen; + } + } + } + } + + return X509_OK; +} + +/** + * Basic constraints - see https://tools.ietf.org/html/rfc5280#page-39 + */ +static int x509_v3_basic_constraints(const uint8_t *cert, int offset, + X509_CTX *x509_ctx) +{ + int ret = X509_OK; + + if ((offset = asn1_is_basic_constraints(cert, offset)) == 0) + goto end_contraints; + + x509_ctx->basic_constraint_present = true; + x509_ctx->basic_constraint_is_critical = + asn1_is_critical_ext(cert, &offset); + + if (asn1_next_obj(cert, &offset, ASN1_OCTET_STRING) < 0 || + asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0 || + asn1_get_bool(cert, &offset, &x509_ctx->basic_constraint_cA) < 0 || + asn1_get_int(cert, &offset, + &x509_ctx->basic_constraint_pathLenConstraint) < 0) + { + ret = X509_NOT_OK; + } + +end_contraints: + return ret; +} + +/* + * Key usage - see https://tools.ietf.org/html/rfc5280#section-4.2.1.3 + */ +static int x509_v3_key_usage(const uint8_t *cert, int offset, + X509_CTX *x509_ctx) +{ + int ret = X509_OK; + + if ((offset = asn1_is_key_usage(cert, offset)) == 0) + goto end_key_usage; + + x509_ctx->key_usage_present = true; + x509_ctx->key_usage_is_critical = asn1_is_critical_ext(cert, &offset); + + if (asn1_next_obj(cert, &offset, ASN1_OCTET_STRING) < 0 || + asn1_get_bit_string_as_int(cert, &offset, &x509_ctx->key_usage)) + { + ret = X509_NOT_OK; + } + +end_key_usage: + return ret; +} +#endif + +/** + * Free an X.509 object's resources. + */ +void x509_free(X509_CTX *x509_ctx) +{ + X509_CTX *next; + int i; + + if (x509_ctx == NULL) /* if already null, then don't bother */ + return; + + for (i = 0; i < X509_NUM_DN_TYPES; i++) + { + free(x509_ctx->ca_cert_dn[i]); + free(x509_ctx->cert_dn[i]); + } + + free(x509_ctx->signature); + +#ifdef CONFIG_SSL_CERT_VERIFICATION + if (x509_ctx->digest) + { + bi_free(x509_ctx->rsa_ctx->bi_ctx, x509_ctx->digest); + } + + if (x509_ctx->subject_alt_dnsnames) + { + for (i = 0; x509_ctx->subject_alt_dnsnames[i]; ++i) + free(x509_ctx->subject_alt_dnsnames[i]); + + free(x509_ctx->subject_alt_dnsnames); + } +#endif + + RSA_free(x509_ctx->rsa_ctx); + next = x509_ctx->next; + free(x509_ctx); + x509_free(next); /* clear the chain */ +} + +#ifdef CONFIG_SSL_CERT_VERIFICATION +/** + * Take a signature and decrypt it. + */ +static bigint *sig_verify(BI_CTX *ctx, const uint8_t *sig, int sig_len, + bigint *modulus, bigint *pub_exp) +{ + int i, size; + bigint *decrypted_bi, *dat_bi; + bigint *bir = NULL; + uint8_t *block = (uint8_t *)alloca(sig_len); + + /* decrypt */ + dat_bi = bi_import(ctx, sig, sig_len); + ctx->mod_offset = BIGINT_M_OFFSET; + + /* convert to a normal block */ + decrypted_bi = bi_mod_power2(ctx, dat_bi, modulus, pub_exp); + + bi_export(ctx, decrypted_bi, block, sig_len); + ctx->mod_offset = BIGINT_M_OFFSET; + + i = 10; /* start at the first possible non-padded byte */ + while (block[i++] && i < sig_len); + size = sig_len - i; + + /* get only the bit we want */ + if (size > 0) + { + int len; + const uint8_t *sig_ptr = get_signature(&block[i], &len); + + if (sig_ptr) + { + bir = bi_import(ctx, sig_ptr, len); + } + } + + /* save a few bytes of memory */ + bi_clear_cache(ctx); + return bir; +} + +/** + * Do some basic checks on the certificate chain. + * + * Certificate verification consists of a number of checks: + * - The date of the certificate is after the start date. + * - The date of the certificate is before the finish date. + * - A root certificate exists in the certificate store. + * - That the certificate(s) are not self-signed. + * - The certificate chain is valid. + * - The signature of the certificate is valid. + * - Basic constraints + */ +int x509_verify(const CA_CERT_CTX *ca_cert_ctx, const X509_CTX *cert, + int *pathLenConstraint) +{ + int ret = X509_OK, i = 0; + bigint *cert_sig; + X509_CTX *next_cert = NULL; + BI_CTX *ctx = NULL; + bigint *mod = NULL, *expn = NULL; + int match_ca_cert = 0; + struct timeval tv; + uint8_t is_self_signed = 0; + + if (cert == NULL) + { + ret = X509_VFY_ERROR_NO_TRUSTED_CERT; + goto end_verify; + } + + /* a self-signed certificate that is not in the CA store - use this + to check the signature */ + if (asn1_compare_dn(cert->ca_cert_dn, cert->cert_dn) == 0) + { + is_self_signed = 1; + ctx = cert->rsa_ctx->bi_ctx; + mod = cert->rsa_ctx->m; + expn = cert->rsa_ctx->e; + } + + gettimeofday(&tv, NULL); + + /* check the not before date */ + if (tv.tv_sec < cert->not_before) + { + ret = X509_VFY_ERROR_NOT_YET_VALID; + goto end_verify; + } + + /* check the not after date */ + if (tv.tv_sec > cert->not_after) + { + ret = X509_VFY_ERROR_EXPIRED; + goto end_verify; + } + + if (cert->basic_constraint_present) + { + /* If the cA boolean is not asserted, + then the keyCertSign bit in the key usage extension MUST NOT be + asserted. */ + if (!cert->basic_constraint_cA && + IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_CERT_SIGN)) + { + ret = X509_VFY_ERROR_BASIC_CONSTRAINT; + goto end_verify; + } + + /* The pathLenConstraint field is meaningful only if the cA boolean is + asserted and the key usage extension, if present, asserts the + keyCertSign bit. In this case, it gives the maximum number of + non-self-issued intermediate certificates that may follow this + certificate in a valid certification path. */ + if (cert->basic_constraint_cA && + (!cert->key_usage_present || + IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_CERT_SIGN)) && + (cert->basic_constraint_pathLenConstraint+1) < *pathLenConstraint) + { + ret = X509_VFY_ERROR_BASIC_CONSTRAINT; + goto end_verify; + } + } + + next_cert = cert->next; + + /* last cert in the chain - look for a trusted cert */ + if (next_cert == NULL) + { + if (ca_cert_ctx != NULL) + { + /* go thru the CA store */ + while (i < CONFIG_X509_MAX_CA_CERTS && ca_cert_ctx->cert[i]) + { + /* the extension is present but the cA boolean is not + asserted, then the certified public key MUST NOT be used + to verify certificate signatures. */ + if (cert->basic_constraint_present && + !ca_cert_ctx->cert[i]->basic_constraint_cA) + continue; + + if (asn1_compare_dn(cert->ca_cert_dn, + ca_cert_ctx->cert[i]->cert_dn) == 0) + { + /* use this CA certificate for signature verification */ + match_ca_cert = true; + ctx = ca_cert_ctx->cert[i]->rsa_ctx->bi_ctx; + mod = ca_cert_ctx->cert[i]->rsa_ctx->m; + expn = ca_cert_ctx->cert[i]->rsa_ctx->e; + + + break; + } + + i++; + } + } + + /* couldn't find a trusted cert (& let self-signed errors + be returned) */ + if (!match_ca_cert && !is_self_signed) + { + ret = X509_VFY_ERROR_NO_TRUSTED_CERT; + goto end_verify; + } + } + else if (asn1_compare_dn(cert->ca_cert_dn, next_cert->cert_dn) != 0) + { + /* check the chain */ + ret = X509_VFY_ERROR_INVALID_CHAIN; + goto end_verify; + } + else /* use the next certificate in the chain for signature verify */ + { + ctx = next_cert->rsa_ctx->bi_ctx; + mod = next_cert->rsa_ctx->m; + expn = next_cert->rsa_ctx->e; + } + + /* cert is self signed */ + if (!match_ca_cert && is_self_signed) + { + ret = X509_VFY_ERROR_SELF_SIGNED; + goto end_verify; + } + + /* check the signature */ + cert_sig = sig_verify(ctx, cert->signature, cert->sig_len, + bi_clone(ctx, mod), bi_clone(ctx, expn)); + + if (cert_sig && cert->digest) + { + if (bi_compare(cert_sig, cert->digest) != 0) + ret = X509_VFY_ERROR_BAD_SIGNATURE; + + + bi_free(ctx, cert_sig); + } + else + { + ret = X509_VFY_ERROR_BAD_SIGNATURE; + } + + if (ret) + goto end_verify; + + /* go down the certificate chain using recursion. */ + if (next_cert != NULL) + { + (*pathLenConstraint)++; /* don't include last certificate */ + ret = x509_verify(ca_cert_ctx, next_cert, pathLenConstraint); + } + +end_verify: + return ret; +} +#endif + +#if defined (CONFIG_SSL_FULL_MODE) +/** + * Used for diagnostics. + */ +static const char *not_part_of_cert = ""; +void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx) +{ + if (cert == NULL) + return; + + printf("=== CERTIFICATE ISSUED TO ===\n"); + printf("Common Name (CN):\t\t"); + printf("%s\n", cert->cert_dn[X509_COMMON_NAME] ? + cert->cert_dn[X509_COMMON_NAME] : not_part_of_cert); + + printf("Organization (O):\t\t"); + printf("%s\n", cert->cert_dn[X509_ORGANIZATION] ? + cert->cert_dn[X509_ORGANIZATION] : not_part_of_cert); + + if (cert->cert_dn[X509_ORGANIZATIONAL_UNIT]) + { + printf("Organizational Unit (OU):\t"); + printf("%s\n", cert->cert_dn[X509_ORGANIZATIONAL_UNIT]); + } + + if (cert->cert_dn[X509_LOCATION]) + { + printf("Location (L):\t\t\t"); + printf("%s\n", cert->cert_dn[X509_LOCATION]); + } + + if (cert->cert_dn[X509_COUNTRY]) + { + printf("Country (C):\t\t\t"); + printf("%s\n", cert->cert_dn[X509_COUNTRY]); + } + + if (cert->cert_dn[X509_STATE]) + { + printf("State (ST):\t\t\t"); + printf("%s\n", cert->cert_dn[X509_STATE]); + } + + if (cert->basic_constraint_present) + { + printf("Basic Constraints:\t\t%sCA:%s, pathlen:%d\n", + cert->basic_constraint_is_critical ? + "critical, " : "", + cert->basic_constraint_cA? "TRUE" : "FALSE", + cert->basic_constraint_pathLenConstraint); + } + + if (cert->key_usage_present) + { + printf("Key Usage:\t\t\t%s", cert->key_usage_is_critical ? + "critical, " : ""); + bool has_started = false; + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_DIGITAL_SIGNATURE)) + { + printf("Digital Signature"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_NON_REPUDIATION)) + { + if (has_started) + printf(", "); + + printf("Non Repudiation"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_ENCIPHERMENT)) + { + if (has_started) + printf(", "); + + printf("Key Encipherment"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_DATA_ENCIPHERMENT)) + { + if (has_started) + printf(", "); + + printf("Data Encipherment"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_AGREEMENT)) + { + if (has_started) + printf(", "); + + printf("Key Agreement"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_CERT_SIGN)) + { + if (has_started) + printf(", "); + + printf("Key Cert Sign"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_CRL_SIGN)) + { + if (has_started) + printf(", "); + + printf("CRL Sign"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_ENCIPHER_ONLY)) + { + if (has_started) + printf(", "); + + printf("Encipher Only"); + has_started = true; + } + + if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_DECIPHER_ONLY)) + { + if (has_started) + printf(", "); + + printf("Decipher Only"); + has_started = true; + } + + printf("\n"); + } + + if (cert->subject_alt_name_present) + { + printf("Subject Alt Name:\t\t%s", cert->subject_alt_name_is_critical + ? "critical, " : ""); + if (cert->subject_alt_dnsnames) + { + int i = 0; + + while (cert->subject_alt_dnsnames[i]) + printf("%s ", cert->subject_alt_dnsnames[i++]); + } + printf("\n"); + + } + + printf("=== CERTIFICATE ISSUED BY ===\n"); + printf("Common Name (CN):\t\t"); + printf("%s\n", cert->ca_cert_dn[X509_COMMON_NAME] ? + cert->ca_cert_dn[X509_COMMON_NAME] : not_part_of_cert); + + printf("Organization (O):\t\t"); + printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATION] ? + cert->ca_cert_dn[X509_ORGANIZATION] : not_part_of_cert); + + if (cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]) + { + printf("Organizational Unit (OU):\t"); + printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]); + } + + if (cert->ca_cert_dn[X509_LOCATION]) + { + printf("Location (L):\t\t\t"); + printf("%s\n", cert->ca_cert_dn[X509_LOCATION]); + } + + if (cert->ca_cert_dn[X509_COUNTRY]) + { + printf("Country (C):\t\t\t"); + printf("%s\n", cert->ca_cert_dn[X509_COUNTRY]); + } + + if (cert->ca_cert_dn[X509_STATE]) + { + printf("State (ST):\t\t\t"); + printf("%s\n", cert->ca_cert_dn[X509_STATE]); + } + + printf("Not Before:\t\t\t%s", ctime(&cert->not_before)); + printf("Not After:\t\t\t%s", ctime(&cert->not_after)); + printf("RSA bitsize:\t\t\t%d\n", cert->rsa_ctx->num_octets*8); + printf("Sig Type:\t\t\t"); + switch (cert->sig_type) + { + case SIG_TYPE_MD5: + printf("MD5\n"); + break; + case SIG_TYPE_SHA1: + printf("SHA1\n"); + break; + case SIG_TYPE_SHA256: + printf("SHA256\n"); + break; + case SIG_TYPE_SHA384: + printf("SHA384\n"); + break; + case SIG_TYPE_SHA512: + printf("SHA512\n"); + break; + default: + printf("Unrecognized: %d\n", cert->sig_type); + break; + } + + if (ca_cert_ctx) + { + int pathLenConstraint = 0; + printf("Verify:\t\t\t\t%s\n", + x509_display_error(x509_verify(ca_cert_ctx, cert, + &pathLenConstraint))); + } + +#if 0 + print_blob("Signature", cert->signature, cert->sig_len); + bi_print("Modulus", cert->rsa_ctx->m); + bi_print("Pub Exp", cert->rsa_ctx->e); +#endif + + if (ca_cert_ctx) + { + x509_print(cert->next, ca_cert_ctx); + } + + TTY_FLUSH(); +} +#endif + +const char * x509_display_error(int error) +{ + switch (error) + { + case X509_OK: + return "Certificate verify successful"; + + case X509_NOT_OK: + return "X509 not ok"; + + case X509_VFY_ERROR_NO_TRUSTED_CERT: + return "No trusted cert is available"; + + case X509_VFY_ERROR_BAD_SIGNATURE: + return "Bad signature"; + + case X509_VFY_ERROR_NOT_YET_VALID: + return "Cert is not yet valid"; + + case X509_VFY_ERROR_EXPIRED: + return "Cert has expired"; + + case X509_VFY_ERROR_SELF_SIGNED: + return "Cert is self-signed"; + + case X509_VFY_ERROR_INVALID_CHAIN: + return "Chain is invalid (check order of certs)"; + + case X509_VFY_ERROR_UNSUPPORTED_DIGEST: + return "Unsupported digest"; + + case X509_INVALID_PRIV_KEY: + return "Invalid private key"; + + case X509_VFY_ERROR_BASIC_CONSTRAINT: + return "Basic constraint invalid"; + + default: + return "Unknown"; + } +} +//#endif /* CONFIG_SSL_FULL_MODE */ + diff --git a/user/mpy/lib/axtls/www/bin/.htaccess b/user/mpy/lib/axtls/www/bin/.htaccess new file mode 100644 index 0000000..4496fa9 --- /dev/null +++ b/user/mpy/lib/axtls/www/bin/.htaccess @@ -0,0 +1,2 @@ +Deny all + diff --git a/user/mpy/lib/axtls/www/favicon.ico b/user/mpy/lib/axtls/www/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..9f6f30e4c6de09f2e93be5e3cbde8a97850b1989 GIT binary patch literal 22486 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 literal 0 HcmV?d00001 diff --git a/user/mpy/lib/axtls/www/index.html b/user/mpy/lib/axtls/www/index.html new file mode 100755 index 0000000..2b1d8b3 --- /dev/null +++ b/user/mpy/lib/axtls/www/index.html @@ -0,0 +1,7103 @@ + + + + + + + + + + + + axTLS Embedded SSL - changes, notes and errata + + + + + + + + + + + + + +
+
+
+
+
changes, notes and errata
+
Type the text for 'YourName'
+
@@bgcolor(#ff0000):color(#ffffff):Changes for 2.1.2 (2016-12-31)@@\n\n!!__SSL Library__\n* Basic constraint/key usage v3 extensions now supported\n* Test harness must now be run without built-in default cert\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.1.1 (2016-12-20)@@\n\n!!__SSL Library__\n* X509 State, country and location are now used for verification and display.\n* SNI hostname memory is now managed by the calling application\n* X509 version number is checked before processing v3 extensions.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.1.0 (2016-12-13)@@\n\n!!__SSL Library__\n* SNI added\n* Some non-C sample code updated.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.0.1 (2016-08-30)@@\n\n!!__SSL Library__\n* ~RC4 only used if ~PKCS12 is used.\n* Buffer sizes tightned up.\n* Buffer check on client handshake due to some incompatibilities.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.0.0 (2016-08-17)@@\n\n!!__SSL Library__\n* Support for TLS 1.2\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.4 (2016-07-07)@@\n\n!!__SSL Library__\n* Fixed client certificate issue where there is no client certificate and a certificate verify msg was still being sent.\n* Tag 64-bit constants with "LL" (e.g. keep ~AVR32 gcc happy)\n* Removed ~RC4 from the list of ciphers\n* Can handle chains that are out of order (thanks Paul Johnstone)\n* Removed some printfs in skeleton mode\n* Removed endian.h as it was causing some porting issues\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.3 (2015-04-30)@@\n\n!!__SSL Library__\n* Added named unions to ~SHA512 code as some compilers don't support it\n* Some other porting suggesions from Chris Ghormley\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.2 (2015-03-10)@@\n\n!!__SSL Library__\n* ~SHA384/~SHA512 support added\n* Security issue fixed where a plain text could be injected before the handshake was completed\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.1 (2014-11-19)@@\n\n!!__SSL Library__\n* ~SHA256 support added\n* All padding/separator bytes checked in ~RSA_decrypt()\n* Added check to get_asn1_length() to limit the number of octets and to not allow overflow\n* ~MD2 removed\n* Return code checked for get_random()\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.0 (2014-10-31)@@\n\n!!__SSL Library__\n* Fixed array access out of bounds bug in add_cert() (thanks Ole Reinhardt)\n* Fix handling of return values of ~SOCKET_READ in process_sslv23_client_hello() (thanks Ole Reinhardt)\n* added generalized time for certificates\n* added printf changes from Fabian Frank to stop warnings/errors\n* Moved setting encryption flags to after handshake completion (thanks Eric Hu)\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.9@@\n\n!!__SSL Library__\n* Fixed issue where the Chrome browser could not connect. This was due to Chrome sending different version numbers in its record header and client hello. ~AxTLS has been modified to use the client hello version as part of ~RFC5246.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.8@@\n\n!!__SSL Library__\n* Fixed issue where the stdint typedefs were not imported by default (stdint.h had to be included explicity) (thanks Anthony G. Basile)\n\n!!__axhttpd__\n* The password hash broke due to an over zealous buffer overflow check. \n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.6@@\n\n!!__SSL Library__\n* Fixed issue where the stdint typedefs were not imported by default (stdint.h had to be included explicity) (thanks Anthony G. Basile)\n* Fixed RNG initialization issue where client library was performed incorrectly (thanks Gilles Boccon~-Gibod). \n\n!!__axhttpd__\n* Now compiles properly under TCP/IP v6.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.5@@\n\n!!__SSL Library__\n* Fixed possible buffer overflow when doing base64 decoding (thanks Emil Kvarnhammar).\n* Fixed unicode parsing error in certificates (thanks Eric Hu)\n\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.4@@\n\n!!__axhttpd__\n* Allow other CGI applications (such as PHP) to call HTML files from their command line.\n\n!!__SSL Library__\n* Fixed memory leak with invalid certificates (thanks Jon Trauntvein)\n* Fixed issue with non-blocking client connections not working properly (thanks Richard Titmuss).\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.3@@\n\n!!__SSL Library__\n* axtlswrap compilation error fixed.\n\n!!__axhttpd__\n* added '-w' command-line option to set the webroot directory.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.2@@\n\n!!__SSL Library__\n* bi_export could have a buffer overrun with incorrect input (thanks Gilles ~Boccon-Gibod - 3334305)\n\n!!__axhttpd__\n* ~RFC1123 time format used in the headers.\n* Expires heading added (current time + ~CONFIG_HTTP_TIMEOUT)\n* UTC/localtime issue with ~If-Modified-Since header.\n\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.1@@\n\n!!__SSL Library__\n* Allow reading of ~PKCS8/12 unencrypted keys in PEM format and mconf will allow the option in server mode (thanks Steve Bennett).\n* Issue where comparing a null and an empty string could return a false positive for cert check (thanks Gilles ~Boccon-Gibod - 3310885).\n* -fPIC added as a Linux compile option.\n\n!!__axhttpd__\n* Killing connections on session timeout is guaranteed.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.0@@\n\n!!__SSL Library__\n* TLS v1.1 implemented and is enabled by default.\n* Closure alerts implemented correctly.\n* Fixed issue with ~SSLv23 hello versioning. \n \n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.4@@\n\n!!__SSL Library__\n* SSL 2.0 client hello is turned off by default as per RFC 4346 Appendix E.\n* Client determines the cipher suite selected rather than the server as per RFC 4346 7.4.1.2.\n* Guard against timing HMAC timing attacks as per RFC 4346 6.2.3.2.\n* Fixed ~SOCKET_WRITE buffer issue (thanks Hardy Griech - 3177419)\n* Fixed variable length MAC issue as used by gnutls.\n* Fixed version issue when TLS >=1.1 is used.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.2@@\n\n!!__SSL Library__\n* Loading of PEM certificate bundles now loads CA certs properly.\n* ssl_client_new() can now be broken up into an ssl_client_new() and successive ssl_read()'s now by setting the ~SSL_CONNECT_IN_PARTS as an option in ssl_ctx_new().\n* Non-blocked mode is now not a requirement but calls may still be blocked.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.1@@\n\n!!__SSL Library__\n* Certificate bundles which contain "invalid" certificates (i.e. invalid digests types etc) are ignored rather than cause failure.\n\n!!__axhttpd__\n* ~HTTPv1.0 packets close a connection upon completion.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.0@@\n\n!!__SSL Library__\n* Close notify is now sent as an error code from ssl_read(). Server code should be modified to check for ~SSL_CLOSE_NOTIFY (thanks to Eric Hu - 3132700).\n* regular_square() issue fixed (3078672)\n* partial_multiply() removed and merged with regular_multiply() (3078372).\n* Invalid session id size now returns ~SSL_ERROR_INVALID_SESSION (thanks to Hardy Griech - 3072881)\n* q-dash issue with Barrett reduction fixed (thanks to Hardy Griech - 3079291).\n* PEM file detection now looks for "-BEGIN" in any part of the file rather than at the start (3123838).\n* 8/16/32 bit native int sizes can be selected in configuration.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.7@@\n\n!!__SSL Library__\n* A fix to find_max_exp_index() (thanks to Hardy Griech).\n* Check is made to get_cipher_info() if the appropriate cipher is not found (thanks to Hardy Griech).\n* Extra x509_free() removed from do_client_connect().\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.5@@\n\n!!__SSL Library__\n* The custom RNG updated to use an entropy pool (with better hooks to use counters).\n\n!!__axhttpd__\n* Headers are case insensitive (thanks to Joe Pruett for this and the following).\n* Child zombie issue fixed.\n* EOF on ~POSTs fixed.\n* Expect is ignored.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.4@@\n\n!!__SSL Library__\n* Client renegotiation now results in an error. This is the result of a security flaw described in this paper http://extendedsubset.com/Renegotiating_TLS.pdf, and also is explained in detail here http://www.cupfighter.net/index.php/2009/11/tls-renegotiation-attack/.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.3@@\n\n!!__SSL Library__\n* v3 certificates with ~SANs now supports (thanks to Carsten Sørensen).\n* axtlswrap added - a port of sslwrap (thanks to Steve Bennett)\n\n!!__axhttpd__\n* shutdown() called before socket close in CGI (thanks to Tom Brown)\n* command-line parameters to specify the http/https port.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.2@@\n\n!!__axhttpd__\n* File uploads over 1kB (but under MAXPOSTDATASIZE) are now supported.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.1@@\n\n!!__SSL Library__\n* Certificate verification now works for Firefox.\n* Extended the openssl API.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.0@@\n\n!!__SSL Library__\n* A self-signed certificate will be verified as ok provided that that it is on the certificate authority list.\n* Certificates are not verified when added as certificate authorities (since self-signed and expired certificates can be added to browsers etc)\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.9@@\n\n!!__SSL Library__\n* Now support MS IIS resource kit certificates (thanks to Carsten Sørensen).\n* Fixed a memory leak when freeing more than one CA certificate.\n* The bigint library had a problem with squaring which affected classical reduction (thanks to Manuel Klimek).\n\n!!__axhttpd__\n* Brought back setuid()/setgid() as an option.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.8@@\n\n!!__SSL Library__\n* Now using a BSD style license.\n* Self-signed certificates can now be automatically generated (the keys still need to be provided).\n* A new API call //ssl_x509_create()// can be used to programatically create the certificate.\n* Certificate/keys can be loaded automatically given a file location.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.7@@\n\n!!__SSL Library__\n\n* Variable sized session id's is now better handled for session caching. It has meant a new API call //ssl_get_session_id_size()// and a change to //ssl_client_new()// to define the session id size.\n* Muliple records with a single header are now better supported (thanks to Hervé Sibert).\n* ~MD2 added for Verisign root cert verification (thanks to Byron Rakitzis).\n* The ~MD5/~SHA1 digests are calculated incrementally to reduce memory (thanks to Byron Rakitzis).\n* The bigint cache is now cleared regularly to reduce memory.\n\n!!__axhttpd__\n\n* Improved the POST handling (thanks to Christian Melki).\n* CSS files now work properly.\n* Lua's CGI launcher location is configurable.\n* //vfork()// is now used for CGI for performance reasons.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.6@@\n\n!!__SSL Library__\n\n* ~RC4 speed improvements\n* Lua samples/bindings now work properly\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.5@@\n\n!!__SSL Library__\n\n* Session id's can now be variable lengths in server hello messages.\n* 0 length client certificates are now supported.\n* ssl_version() now returns just the version and not the date.\n* ssl_write() was not sending complete packets under load.\n\n!!__axhttpd__\n\n* Completely updated the CGI code.\n* Lua now integrated - Lua scripts and Lua Pages now run.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.4@@\n\n!!__SSL Library__\n\n* Fixed a Win32 crypto library issue with non-Administrator users\n* Removed compiler warnings that showed up in ~FC6.\n* GNU TLS certificates are now accepted.\n* Separated the send/receive headers for HMAC calculations.\n* Fixed a compilation problem with swig/perl/~FC6.\n* Fixed an issue with loading PEM CA certificates.\n\n!!__axhttpd__\n\n* Made //setuid()/setgid()// call an mconf option.\n* Made //chroot()// an mconf option. Default to //chdir()// instead.\n* Removed optional permissions checking.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.1@@\n\n!!__SSL Library__\n\n* AES should now work on 16bit processors (there was an alignment problem).\n* Various freed objects are cleared before freeing.\n* Header files now installed in ///usr/local/include/axTLS//.\n* -DCYGWIN replaced with -~DCONFIG_PLATFORM_CYGWIN (and the same for Solaris).\n* removed "-noextern" option in Swig. Fixed some other warnings in Win32.\n* SSLCTX changed to ~SSL_CTX (to be consistent with openssl). SSLCTX still exists for backwards compatibility.\n* malloc() and friends call abort() on failure.\n* Fixed a memory leak in directory listings.\n* Added openssl() compatibility functions.\n* Fixed Cygwin 'make install' issue.\n\n!!__axhttpd__\n\n* main.c now becomes axhttpd.c.\n* Header file issue fixed (in mime_types.c).\n* //chroot()// now used for better security.\n* Basic authentication implemented (via .htpasswd).\n* SSL access/denial protection implemented (via .htaccess).\n* Directory access protection implemented (via .htaccess).\n* Can now have more than one CGI file extension in mconf.\n* "~If-Modified-Since" request now handled properly.\n* Performance tweaks to remove //ssl_find()//.
[[Read Me]]
axTLS uses a BSD style license:\n\nCopyright (c) 2008, Cameron Rich All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer. Redistributions in binary\nform must reproduce the above copyright notice, this list of conditions and\nthe following disclaimer in the documentation and/or other materials\nprovided with the distribution. Neither the name of the axTLS Project nor\nthe names of its contributors may be used to endorse or promote products\nderived from this software without specific prior written permission. \n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGE.
[[Read Me]] \n[[Changelog]]\n[[axhttpd]]\n[[License]]
+
<div class='header' macro='gradient vert #390108 #900'>\n<div class='headerShadow'>\n<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;\n<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>\n</div>\n<div class='headerForeground'>\n<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;\n<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>\n</div>\n</div>\n<div id='mainMenu'>\n<div refresh='content' tiddler='MainMenu'></div>\n</div>\n<div id='sidebar'>\n<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>\n<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>\n</div>\n<div id='displayArea'>\n<div id='messageArea'></div>\n<div id='tiddlerDisplay'></div>\n</div>
+
!@@bgcolor(#ff0000):color(#ffffff):axTLS Quick Start Guide@@\n\nThis is a guide to get a small SSL web-server up and running quickly.\n\n!!__Introduction__\n\nThe axTLS project is an SSL client/server library using the ~TLSv1 protocol. It is designed to be small and fast, and is suited to embedded projects. A web server is included.\n\nThe basic web server + SSL library is around 60-70kB and is configurable for features or size.\n\n!!__Compilation__\n\nAll platforms require GNU make. This means on Win32 that Cygwin needs to be installed with "make" and various developer options selected.\n\nConfiguration now uses a tool called "mconf" which gives a nice way to configure options (similar to what is used in ~BusyBox and the Linux kernel).\n\nYou should be able to compile axTLS simply by extracting it, change into the extracted directory and typing:\n\n{{indent{{{{> make}}}\n\nSelect your platform type, save the configuration, exit, and then type "make" again.\n\nIf all goes well, you should end up with an executable called "axhttpd" (or axhttpd.exe) in the //_stage// directory.\n\nTo play with all the various axTLS options, type:\n\n{{indent{{{{> make menuconfig}}}\n\nSave the new configuration and rebuild.\n\n!!__Running it__\n\nTo run it, go to the //_stage// directory, and type (as superuser):\n\n{{indent{{{{> axhttpd}}}\n\nNote: you may have to set your ~LD_LIBRARY_PATH - e.g. go to //_stage// and type //export ~LD_LIBRARY_PATH=`pwd`//\n\nAnd then point your browser at https://127.0.0.1 And you should see a this html page with a padlock appearing on your browser. or type http://127.0.0.1 to see the same page unencrypted.\n\n!!__The axssl utilities__\n\nThe axssl suite of tools are the SSL test tools in the various language bindings. They are:\n\n* axssl - C sample\n* axssl.csharp - C# sample\n* axssl.vbnet - VB.NET sample\n* axtls.jar - Java sample\n* axssl.pl - Perl sample\n* axssl.lua - Lua sample\n\nAll the tools have identical command-line parameters. e.g. to run something interesting:\n\n{{indent{{{{> axssl s_server -verify -CAfile ../ssl/test/axTLS.ca_x509}}}\n\nand\n\n{{indent{{{{> axssl s_client -cert ../ssl/test/axTLS.x509_1024 -key ../ssl/test/axTLS.key_1024 -reconnect}}}\n\n!!!!C#\n\nIf building under Linux or other non-Win32 platforms, Mono must be installed and the executable is run as:\n\n{{indent{{{{> mono axssl.csharp.exe ...}}}\n\n!!!!Java\n\nThe java version is run as:\n\n{{indent{{{{> java -jar axtls.jar <options>}}}\n\n!!!!Perl\n\n{{indent{{{{> [perl] ./axssl.pl <options>}}}\n\nIf running under Win32, be sure to use the correct version of Perl (i.e. ~ActiveState's version works ok).\n\n!!!!Lua\n\n{{indent{{{{> [lua] ./axssl.lua <options>}}}\n\n!__Known Issues__\n\n* Firefox doesn't handle legacy ~SSLv2 at all well. Disabling ~SSLv2 still initiates a ~SSLv23 handshake (v1.5). And continuous pressing of the "Reload" page instigates a change to ~SSLv3 for some reason (even though the TLS 1.0 option is selected). This will cause a "Firefox and <server> cannot communicate securely because they have no common encryption algorithms" (v1.5), or "Firefox can't connect to <server> because the site uses a security protocol which isn't enabled" (v2.0). See bugzilla issues 343543 and 359484 (Comment #7). It's all broken (hopefully fixed soon).\n* Perl/Java bindings don't work on 64 bit Linux machines. I can't even compile the latest version of Perl on an ~AMD64 box (using ~FC3).\n* Java 1.4 or better is required for the Java interfaces.\n* Processes that fork can't use session resumption unless some form of IPC is used.\n* Ensure libperl.so and libaxtls.so are in the shared library path when running with the perl bindings. A way to do this is with:\n\n{{indent{{{{> export LD_LIBRARY_PATH=`perl -e 'use Config; print $Config{archlib};'`/CORE:.}}}\n* The lua sample requires the luabit library from http://luaforge.net/projects/bit.\n\n!!!!Win32 issues\n\n* Be careful about doing .NET executions on network drives - .NET complains with security exceptions on the binary. //TODO: Add a manifest file to prevent this.//\n* CGI has been removed from Win32 - it needs a lot more work to get it right.\n* The default Microsoft .NET SDK is v2.0.50727. Download from: http://msdn.microsoft.com/netframework/downloads/updates/default.aspx.\n\n!!!!Solaris issues\n\n* mconf doesn't work well - some manual tweaking is required for string values.\n* GNU make is required and needs to be in $PATH.\n* To get swig's library dependencies to work (and for the C library to be found), I needed to type:\n\n{{indent{{{{> export LD_LIBRARY_PATH=/usr/local/gcc-3.3.1/lib:.}}}\n\n!!!!Cygwin issues\n\n* The bindings all compile but don't run under Cygwin with the exception of Perl. This is due to win32 executables being incompatible with Cygwin libraries.\n\n
+
changes, notes and errata
+
axTLS Embedded SSL
+
http://axtls.cerocclub.com.au
+
/***\nhttp://tiddlystyles.com/#theme:DevFire\nAuthor: Clint Checketts\n***/\n\n/*{{{*/\nbody {\nbackground: #000;\n}\n/*}}}*/\n/***\n!Link styles /% ============================================================= %/\n***/\n/*{{{*/\na,\na.button,\n#mainMenu a.button,\n#sidebarOptions .sliderPanel a{\n color: #ffbf00;\n border: 0;\n background: transparent;\n}\n\na:hover,\na.button:hover,\n#mainMenu a.button:hover,\n#sidebarOptions .sliderPanel a:hover\n#sidebarOptions .sliderPanel a:active{\n color: #ff7f00;\n border: 0;\n border-bottom: #ff7f00 1px dashed;\n background: transparent;\n text-decoration: none;\n}\n\n#displayArea .button.highlight{\n color: #ffbf00;\n background: #4c4c4c;\n}\n/*}}}*/\n/***\n!Header styles /% ============================================================= %/\n***/\n/*{{{*/\n.header{\n border-bottom: 2px solid #ffbf00;\n color: #fff;\n}\n\n.headerForeground a {\n color: #fff;\n}\n\n.header a:hover {\n border-bottom: 1px dashed #fff;\n}\n/*}}}*/\n/***\n!Main menu styles /% ============================================================= %/\n***/\n/*{{{*/\n#mainMenu {color: #fff;}\n#mainMenu h1{\n font-size: 1.1em;\n}\n#mainMenu li,#mainMenu ul{\n list-style: none;\n margin: 0;\n padding: 0;\n}\n/*}}}*/\n/***\n!Sidebar styles /% ============================================================= %/\n***/\n/*{{{*/\n#sidebar {\n right: 0;\n color: #fff;\n border: 2px solid #ffbf00;\n border-width: 0 0 2px 2px;\n}\n#sidebarOptions {\n background-color: #4c4c4c;\n padding: 0;\n}\n\n#sidebarOptions a{\n margin: 0;\n color: #ffbf00;\n border: 0;\n}\n#sidebarOptions a:hover {\n color: #4c4c4c;\n background-color: #ffbf00;\n\n}\n\n#sidebarOptions a:active {\n color: #ffbf00;\n background-color: transparent;\n}\n\n#sidebarOptions .sliderPanel {\n background-color: #333;\n margin: 0;\n}\n\n#sidebarTabs {background-color: #4c4c4c;}\n#sidebarTabs .tabSelected {\n padding: 3px 3px;\n cursor: default;\n color: #ffbf00;\n background-color: #666;\n}\n#sidebarTabs .tabUnselected {\n color: #ffbf00;\n background-color: #5f5f5f;\n padding: 0 4px;\n}\n\n#sidebarTabs .tabUnselected:hover,\n#sidebarTabs .tabContents {\n background-color: #666;\n}\n\n.listTitle{color: #FFF;}\n#sidebarTabs .tabContents a{\n color: #ffbf00;\n}\n\n#sidebarTabs .tabContents a:hover{\n color: #ff7f00;\n background: transparent;\n}\n\n#sidebarTabs .txtMoreTab .tabSelected,\n#sidebarTabs .txtMoreTab .tab:hover,\n#sidebarTabs .txtMoreTab .tabContents{\n color: #ffbf00;\n background: #4c4c4c;\n}\n\n#sidebarTabs .txtMoreTab .tabUnselected {\n color: #ffbf00;\n background: #5f5f5f;\n}\n\n.tab.tabSelected, .tab.tabSelected:hover{color: #ffbf00; border: 0; background-color: #4c4c4c;cursor:default;}\n.tab.tabUnselected {background-color: #666;}\n.tab.tabUnselected:hover{color:#ffbf00; border: 0;background-color: #4c4c4c;}\n.tabContents {\n background-color: #4c4c4c;\n border: 0;\n}\n.tabContents .tabContents{background: #666;}\n.tabContents .tabSelected{background: #666;}\n.tabContents .tabUnselected{background: #5f5f5f;}\n.tabContents .tab:hover{background: #666;}\n/*}}}*/\n/***\n!Message area styles /% ============================================================= %/\n***/\n/*{{{*/\n#messageArea {background-color: #666; color: #fff; border: 2px solid #ffbf00;}\n#messageArea a:link, #messageArea a:visited {color: #ffbf00; text-decoration:none;}\n#messageArea a:hover {color: #ff7f00;}\n#messageArea a:active {color: #ff7f00;}\n#messageArea .messageToolbar a{\n border: 1px solid #ffbf00;\n background: #4c4c4c;\n}\n/*}}}*/\n/***\n!Popup styles /% ============================================================= %/\n***/\n/*{{{*/\n.popup {color: #fff; background-color: #4c4c4c; border: 1px solid #ffbf00;}\n.popup li.disabled{color: #fff;}\n.popup a {color: #ffbf00; }\n.popup a:hover { background: transparent; color: #ff7f00; border: 0;}\n.popup hr {color: #ffbf00; background: #ffbf00;}\n/*}}}*/\n/***\n!Tiddler Display styles /% ============================================================= %/\n***/\n/*{{{*/\n.title{color: #fff;}\nh1, h2, h3, h4, h5 {\n color: #fff;\n background-color: transparent;\n border-bottom: 1px solid #333;\n}\n\n.subtitle{\n color: #666;\n}\n\n.viewer {color: #fff; }\n\n.viewer table{background: #666; color: #fff;}\n\n.viewer th {background-color: #996; color: #fff;}\n\n.viewer pre, .viewer code {color: #ddd; background-color: #4c4c4c; border: 1px solid #ffbf00;}\n\n.viewer hr {color: #666;}\n\n.tiddler .button {color: #4c4c4c;}\n.tiddler .button:hover { color: #ffbf00; background-color: #4c4c4c;}\n.tiddler .button:active {color: #ffbf00; background-color: #4c4c4c;}\n\n.toolbar {\n color: #4c4c4c;\n}\n\n.toolbar a.button,\n.toolbar a.button:hover,\n.toolbar a.button:active,\n.editorFooter a{\n border: 0;\n}\n\n.footer {\n color: #ddd;\n}\n\n.selected .footer {\n color: #888;\n}\n\n.highlight, .marked {\n color: #000;\n background-color: #ffe72f;\n}\n.editorFooter {\n color: #aaa;\n}\n\n.tab{\n-moz-border-radius-topleft: 3px;\n-moz-border-radius-topright: 3px;\n}\n\n.tagging,\n.tagged{\n background: #4c4c4c;\n border: 1px solid #4c4c4c; \n}\n\n.selected .tagging,\n.selected .tagged{\n background-color: #333;\n border: 1px solid #ffbf00;\n}\n\n.tagging .listTitle,\n.tagged .listTitle{\n color: #fff;\n}\n\n.tagging .button,\n.tagged .button{\n color: #ffbf00;\n border: 0;\n padding: 0;\n}\n\n.tagging .button:hover,\n.tagged .button:hover{\nbackground: transparent;\n}\n\n.selected .isTag .tagging.simple,\n.selected .tagged.simple,\n.isTag .tagging.simple,\n.tagged.simple {\n float: none;\n display: inline;\n border: 0;\n background: transparent;\n color: #fff;\n margin: 0;\n}\n\n.cascade {\n background: #4c4c4c;\n color: #ddd;\n border: 1px solid #ffbf00;\n}\n/*}}}*/
+
axhttpd is a small embedded web server using the axTLS library. It is based originally on the web server written by Doug Currie which is at http://www.hcsw.org/awhttpd.\n\n!@@bgcolor(#ff0000):color(#ffffff):axhttpd Features@@ \n\n!!__Basic Authentication__\n\nBasic Authentication uses a password file called ".htpasswd", in the directory to be protected. This file is formatted as the familiar colon-separated username/encrypted-password pair, records delimited by newlines. The protection does not carry over to subdirectories. The utility program htpasswd is included to help manually edit .htpasswd files.\n\nThe encryption of this password uses a proprietary algorithm due to the dependency of many crypt libraries on DES. An example is in [[/test_dir/no_http|https://localhost/test_dir/no_http]] (username 'abcd', password is '1234').\n\n//Note: This is an mconf enabled configuration option.//\n\n!!__SSL Protection__\n\nDirectories/files can be accessed using the 'http' or 'https' uri prefix. If normal http access for a directory needs to be disabled, then put "~SSLRequireSSL" into a '.htaccess' file in the directory to be protected. \n\nConversely, use "~SSLDenySSL" to deny access to directories via SSL.\n\nAn example is in [[/test_dir/no_http|http://localhost/test_dir/no_http]] and [[/test_dir/no_ssl|https://localhost/test_dir/no_ssl]].\n\nEntire directories can be denied access with a "Deny all" directive (regardless of SSL or authentication). An example is in [[/test_dir/bin|http://localhost/test_dir/bin]]\n\n!!__CGI__\n\nMost of the CGI 1.1 variables are now placed into the script environment and should work as normal.\n\n!!__Lua and Lua Pages__\n\nThis is a small scripting language gaining popularity in embedded applications due to its small footprint and fast speed.\n\nLua has been incorporated into the build, so simply select it and it will automatically install. Try pointing your browser at [[test_main.html|http://localhost/lua/test_main.html]] to see an example of Lua Pages.\n\n//Note: This is an mconf enabled configuration option.//\n\nThe readline development library may have to be downloaded: //yum install readline-devel//\n\n!!__Directory Listing__\n\nAn mconf option. Allow the files in directories to be displayed. An example is in [[/test_dir|http://localhost/test_dir]]\n\n!!__Other Features__\n\n* Timeout - HTTP 1.1 allows for persistent connections. This is the time allowed for this connection in seconds.\n* Daemon - Puts the process in daemon mode. \n* SSL session cache size - The size of the session cache (a heavily loaded server should maintain many sessions). A session will save on expensive SSL handshaking.\n\n
+
+ + + + + diff --git a/user/mpy/lib/axtls/www/lua/download.lua b/user/mpy/lib/axtls/www/lua/download.lua new file mode 100644 index 0000000..2ee1a71 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/download.lua @@ -0,0 +1,75 @@ +#!/usr/local/bin/lua + +require"luasocket" + +function receive (connection) + connection:settimeout(0) + local s, status = connection:receive (2^10) + if status == "timeout" then + coroutine.yield (connection) + end + return s, status +end + +function download (host, file, outfile) + --local f = assert (io.open (outfile, "w")) + local c = assert (socket.connect (host, 80)) + c:send ("GET "..file.." HTTP/1.0\r\n\r\n") + while true do + local s, status = receive (c) + --f:write (s) + if status == "closed" then + break + end + end + c:close() + --f:close() +end + +local threads = {} +function get (host, file, outfile) + print (string.format ("Downloading %s from %s to %s", file, host, outfile)) + local co = coroutine.create (function () + return download (host, file, outfile) + end) + table.insert (threads, co) +end + +function dispatcher () + while true do + local n = table.getn (threads) + if n == 0 then + break + end + local connections = {} + for i = 1, n do + local status, res = coroutine.resume (threads[i]) + if not res then + table.remove (threads, i) + break + else + table.insert (connections, res) + end + end + if table.getn (connections) == n then + socket.select (connections) + end + end +end + +local url = arg[1] +if not url then + print (string.format ("usage: %s url [times]", arg[0])) + os.exit() +end +local times = arg[2] or 5 + +url = string.gsub (url, "^http.?://", "") +local _, _, host, file = string.find (url, "^([^/]+)(/.*)") +local _, _, fn = string.find (file, "([^/]+)$") + +for i = 1, times do + get (host, file, fn..i) +end + +dispatcher () diff --git a/user/mpy/lib/axtls/www/lua/env.lua b/user/mpy/lib/axtls/www/lua/env.lua new file mode 100644 index 0000000..c429847 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/env.lua @@ -0,0 +1,26 @@ +-- This file should be executed before any script in this directory +-- according to the configuration (cgilua/conf.lua). + +pcall (cgilua.enablesession) + +local put, mkurlpath = cgilua.put, cgilua.mkurlpath + +cgilua.addclosefunction (function () + put [[ +

+ +Main]] + for _, test in { + { "Get", "test_main.lua", {ab = "cd", ef = "gh"} }, + { "Cookies", "test_cookies.lua", }, + { "FileSystem", "test_fs.lua", }, + { "Libraries", "test_lib.lua", }, + { "Session", "test_session.lua", }, + { "Variables", "test_variables.lp", }, + } do + put (string.format (' · %s', + mkurlpath (test[2], test[3]), test[1])) + end + put [[ +]] +end) diff --git a/user/mpy/lib/axtls/www/lua/overview.lp b/user/mpy/lib/axtls/www/lua/overview.lp new file mode 100644 index 0000000..4d17002 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/overview.lp @@ -0,0 +1,64 @@ + + +CGILua installation overview + + +

CGILua installation overview

+ + + + + + + + + + + + + +
Version + Copyright + Description +
<%= tostring(_G[l[2]]) %> + + +
<%= idx(p,"VERSION") %> + <%= idx(p,"COPYRIGHT") %> + <%= idx(p,"DESCRIPTION") %> +
+ + + diff --git a/user/mpy/lib/axtls/www/lua/prepara_sql2.lua b/user/mpy/lib/axtls/www/lua/prepara_sql2.lua new file mode 100644 index 0000000..6a37c2f --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/prepara_sql2.lua @@ -0,0 +1,31 @@ +#!/usr/local/bin/lua + +MAX_ROWS = arg[1] or 10 + +require"postgres" + +local env = assert (luasql.postgres ()) +local conn = assert (env:connect ("luasql-test", "tomas")) + +-- Apaga restos de outros testes. +conn:execute "drop table t2" +conn:execute "drop table t1" + +-- Criando as tabelas. +assert (conn:execute [[create table t1 ( + a int, + b int +)]]) +assert (conn:execute [[create table t2 ( + c int, + d int +)]]) + +-- Preenchedo as tabelas. +for i = 1, MAX_ROWS do + local ii = 2*i + assert (conn:execute (string.format ([[ +insert into t1 values (%d, %d); +insert into t2 values (%d, %d);]], + ii, i, ii, i))) +end diff --git a/user/mpy/lib/axtls/www/lua/test_conc.lua b/user/mpy/lib/axtls/www/lua/test_conc.lua new file mode 100644 index 0000000..bbb9be7 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_conc.lua @@ -0,0 +1,38 @@ +cgilua.htmlheader() +if ap then + local pid, ppid = ap.pid () + if not ppid then + ppid = "no parent pid" + end + cgilua.put ("pid = "..pid.." ("..ppid..")".."\n") +end + +assert(type(stable.get) == "function") +assert(type(stable.set) == "function") + +cgilua.put"stable.pairs = {
\n" +for i, v in stable.pairs () do + cgilua.put (i.." = "..tostring(v).."
\n") +end +cgilua.put"}
\n" + +local counter = stable.get"counter" or 0 +stable.set ("counter", counter + 1) + +local f = stable.get"f" +if not f then + local d = os.date() + stable.set ("f", function () return d end) +else + cgilua.put ("f() = "..tostring (f ())) +end + +cgilua.put"
\n" +for i = 1,800 do + cgilua.put (i) + for ii = 1,1000 do + cgilua.put ("") + end + cgilua.put ("\n") +end +cgilua.put ("End") diff --git a/user/mpy/lib/axtls/www/lua/test_cookies.lp b/user/mpy/lib/axtls/www/lua/test_cookies.lp new file mode 100644 index 0000000..932b9c5 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_cookies.lp @@ -0,0 +1,13 @@ + + +

Testing Cookies library

+ +<%= CL_COOKIE%> = <%= tostring(test)%>
+Assigning current date to cookie!
+Reload this script to check cookie's value! diff --git a/user/mpy/lib/axtls/www/lua/test_cookies.lua b/user/mpy/lib/axtls/www/lua/test_cookies.lua new file mode 100644 index 0000000..6af935e --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_cookies.lua @@ -0,0 +1,14 @@ +local cookies = require"cgilua.cookies" +CL_COOKIE = "cgilua_cookie" + +local test = cookies.get (CL_COOKIE) +cookies.set (CL_COOKIE, os.date()) + +cgilua.htmlheader () +cgilua.put ([[ +

Testing Cookies library

+ +]]..CL_COOKIE..' = '..tostring(test)..[[
+Assigning current date to cookie!
+Reload this script to check cookie's value! +]]) diff --git a/user/mpy/lib/axtls/www/lua/test_err.lua b/user/mpy/lib/axtls/www/lua/test_err.lua new file mode 100644 index 0000000..4d6ffc9 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_err.lua @@ -0,0 +1,4 @@ +cgilua.htmlheader() +cgilua.put"Oi!" +--io.write"something\n" +cgilua.errorlog ("eca", "emerg") diff --git a/user/mpy/lib/axtls/www/lua/test_fs.lua b/user/mpy/lib/axtls/www/lua/test_fs.lua new file mode 100644 index 0000000..566ed8b --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_fs.lua @@ -0,0 +1,23 @@ +function link_dir (dir, base) + local path = base.."/"..dir + local mode = lfs.attributes (path).mode + if mode == "directory" then + return string.format ('%s', + cgilua.mkurlpath ("test_fs.lua", { dir = path }), + dir) + else + return dir + end +end + +cgilua.htmlheader () +cgilua.put ("

Testing Filesystem library

\n") +cgilua.put ("\n") +cgilua.put ("\n") +local i = 0 +local dir = cgi.dir or "." +for file in lfs.dir (dir) do + i = i+1 + cgilua.put ("\n") +end +cgilua.put ("
Testing dir
"..i..""..link_dir(file, dir).."
\n") diff --git a/user/mpy/lib/axtls/www/lua/test_htk.lua b/user/mpy/lib/axtls/www/lua/test_htk.lua new file mode 100644 index 0000000..ac1de6c --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_htk.lua @@ -0,0 +1,22 @@ +require"htk" + +local a_table = {} +for i = 1, 20 do + local l = {} + for j = 1, 20 do + table.insert (l, HTK.TD { "cell "..i..","..j }) + end + table.insert (a_table, HTK.TR (l)) +end + +cgilua.htmlheader() +cgilua.put (HTK.HTML { + HTK.HEAD { HTK.TITLE { "Titulo da Pagina" } }, + HTK.BODY { + bgcolor = "#FFFFFF", + HTK.H1 { "Titulo da Pagina" }, + HTK.P {}, + "Uma página qualquer", + HTK.TABLE (a_table), + } +}) diff --git a/user/mpy/lib/axtls/www/lua/test_lib.lua b/user/mpy/lib/axtls/www/lua/test_lib.lua new file mode 100644 index 0000000..5041253 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_lib.lua @@ -0,0 +1,31 @@ +local function getfield (t, f) + for w in string.gfind(f, "[%w_]+") do + if not t then return nil end + t = t[w] + end + return t +end + +function test_lib (libname) + local ok, err = pcall (require, libname) + if not ok then + cgilua.put ("Library "..libname.." not found
\n".. + err) + else + cgilua.put ("Library "..libname.."
\n") + local t = getfield (_G, libname) + if type(t) ~= "table" then + cgilua.put (tostring(t)) + else + for i, v in pairs (t) do + cgilua.put ("  "..tostring(i).." = "..tostring(v).."
\n") + end + end + end + cgilua.put ("\n

\n") +end + +cgilua.htmlheader () +for _, lib in ipairs { "lfs", "socket", "luasql.postgres", "luasql", "lxp", "lxp.lom", "lualdap", "htk", "xmlrpc", "xmlrpc.http" } do + test_lib (lib) +end diff --git a/user/mpy/lib/axtls/www/lua/test_main.html b/user/mpy/lib/axtls/www/lua/test_main.html new file mode 100644 index 0000000..a50dd63 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_main.html @@ -0,0 +1,127 @@ + +Test Page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GET: +
Lua scriptmodule
HTML templatemodule
POST: +
+
+ + + + + + + + + + + + +
+ field 1:
+ field 2:
+ field 3: + op 1 + op 2 + op 3 +
Lua script + module +
HTML template + module +
+
+
POST (with upload): +
+
+ + + + + + + + + + + + +
+ field 1:
+ file (binary!):
+
Lua script + module +
HTML template + module +
+
+
Cookies: +
Lua scriptmodule
HTML templatemodule
Filesystem: +
Lua scriptmodule
Session: +
Lua scriptmodule
CGI Variables: +
HTML templatemodule
Library Overview: +
HTML templatemodule
Concurrency +
Lua scriptmodule
+ diff --git a/user/mpy/lib/axtls/www/lua/test_main.lp b/user/mpy/lib/axtls/www/lua/test_main.lp new file mode 100644 index 0000000..917ee1e --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_main.lp @@ -0,0 +1,31 @@ + +Embeded Lua Test + + +cgi = { +\n", vv, a, tostring(b)) + end + v = vv.."}" + end +?> +<%= i %> = <%= tostring(v) %>
+<% +end +%> +} +
+Remote address: <%= cgilua.servervariable"REMOTE_ADDR" %> +
+Is persistent = <%= tostring (SAPI.Info.ispersistent) %> +
+ap =
+lfcgi = <% = tostring(lfcgi) %>
+<%= (ap and ap.handler()) or "" %>
+ + + diff --git a/user/mpy/lib/axtls/www/lua/test_main.lua b/user/mpy/lib/axtls/www/lua/test_main.lua new file mode 100644 index 0000000..0e997a2 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_main.lua @@ -0,0 +1,46 @@ +cgilua.htmlheader() +cgilua.put[[ + +Script Lua Test + + +cgi = { +]] + +for i,v in pairs (cgi) do + if type(v) == "table" then + local vv = "{" + for a,b in pairs(v) do + vv = string.format ("%s%s = %s
\n", vv, a, tostring(b)) + end + v = vv.."}" + end + cgilua.put (string.format ("%s = %s
\n", i, tostring(v))) +end +cgilua.put "}
\n" +cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR") +cgilua.put "
\n" +cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."
\n") +cgilua.put ("ap="..tostring(ap).."
\n") +cgilua.put ("lfcgi="..tostring(lfcgi).."
\n") + +-- Checking Virtual Environment +local my_output = cgilua.put +cgilua.put = nil +local status, err = pcall (function () + assert (cgilua.put == nil, "cannot change cgilua.put value") +end) +cgilua.put = my_output +assert (status == true, err) + +-- Checking require +local status, err = pcall (function () require"unknown_module" end) +assert (status == false, "unknown_module loaded!") +-- assert (package == nil, "Access to package table allowed!") + +cgilua.put[[ +

+ + +]] +cgilua = nil diff --git a/user/mpy/lib/axtls/www/lua/test_session.lua b/user/mpy/lib/axtls/www/lua/test_session.lua new file mode 100644 index 0000000..d97cc45 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_session.lua @@ -0,0 +1,43 @@ +cgilua.enablesession () + +function pt (tab) + for i, v in pairs (tab) do + local vv = v + if type(v) == "table" then + vv = "" + for _i, _v in pairs (v) do + vv = vv..string.format ("%s = %q, ", _i, _v) + end + vv = '{'..vv..'}' + end + cgilua.put (string.format ("%s = %s
\n", tostring (i), tostring (vv))) + end +end + + +if cgi.field then + if not cgilua.session.data.field then + cgilua.session.data.field = {} + end + table.insert (cgilua.session.data.field, cgi.field) +end +cgilua.htmlheader() +if cgilua.session then + cgilua.put "cgi = {
\n" + pt (cgi) + cgilua.put "}
\n" + cgilua.put "cgilua.session.data = {
\n" + pt (cgilua.session.data) + cgilua.put "}
\n" + + cgilua.put [[

+ field:
+
+
]] +else + cgilua.put "Sessions library is not available or not well configured" +end diff --git a/user/mpy/lib/axtls/www/lua/test_sql.lua b/user/mpy/lib/axtls/www/lua/test_sql.lua new file mode 100644 index 0000000..085ce97 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_sql.lua @@ -0,0 +1,13 @@ +local s = require"luasql.postgres" + +local env = assert (luasql.postgres ()) +local conn = assert (env:connect ("luasql-test", "tomas")) +local cur = assert (conn:execute ("select count(*) from fetch_test")) + +cgilua.htmlheader() +cgilua.put ("Total lines at table fetch_test is "..cur:fetch()) +cgilua.put (string.format ("
\n%s == %s
\n", tostring(s), tostring(luasql))) + +cur:close() +conn:close() +env:close() diff --git a/user/mpy/lib/axtls/www/lua/test_sql2.lua b/user/mpy/lib/axtls/www/lua/test_sql2.lua new file mode 100644 index 0000000..a2f6ee1 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_sql2.lua @@ -0,0 +1,24 @@ +require"postgres" + +local env = assert (luasql.postgres ()) +local conn = assert (env:connect ("luasql-test", "tomas")) +local cur = assert (conn:execute ("select count(*) from t1")) +local total = tonumber (cur:fetch()) +cur:close() +local aleatorio = math.random(total) +local cur = assert (conn:execute ("select * from t1, t2 where b = d and a != "..2*aleatorio)) + +cgilua.htmlheader() +cgilua.put ("Aleatorio = "..aleatorio.."
\n") + +local a,b,c,d = cur:fetch() +cgilua.put ("\n") +while a do +-- cgilua.put ("") + a,b,c,d = cur:fetch() +end +cgilua.put ("
",a,"",b,"",c,"",d,"
\n") + +cur:close() +conn:close() +env:close() diff --git a/user/mpy/lib/axtls/www/lua/test_variables.lp b/user/mpy/lib/axtls/www/lua/test_variables.lp new file mode 100644 index 0000000..c1ac332 --- /dev/null +++ b/user/mpy/lib/axtls/www/lua/test_variables.lp @@ -0,0 +1,14 @@ + +<% for _, var in pairs { "SERVER_SOFTWARE", "SERVER_NAME", "GATEWAY_INTERFACE", "SERVER_PROTOCOL", "SERVER_PORT", "REQUEST_METHOD", "PATH_INFO", "PATH_TRANSLATED", "SCRIPT_NAME", "QUERY_STRING", "REMOTE_HOST", "REMOTE_ADDR", "AUTH_TYPE", "REMOTE_USER", "REMOTE_IDENT", "CONTENT_TYPE", "CONTENT_LENGTH", "HTTP_REFERER", "HTTP_COOKIE", "SCRIPT_FILENAME", "DOCUMENT_ROOT", } do %> + +<% end %> +
<%= var %>="<%= cgilua.servervariable(var) or "not defined"%>"
+ +

+ +<% for _, var in ipairs { "script_file", "script_path", "script_pdir", "script_vdir", "script_vpath", "urlpath", } do %> + +<% end %> +
<%= var %>="<%= cgilua[var] %>"
+ +

diff --git a/user/mpy/lib/axtls/www/test_dir/bin/.htaccess b/user/mpy/lib/axtls/www/test_dir/bin/.htaccess new file mode 100644 index 0000000..8fd8c46 --- /dev/null +++ b/user/mpy/lib/axtls/www/test_dir/bin/.htaccess @@ -0,0 +1 @@ +Deny all diff --git a/user/mpy/lib/axtls/www/test_dir/no_http/.htaccess b/user/mpy/lib/axtls/www/test_dir/no_http/.htaccess new file mode 100644 index 0000000..3e20076 --- /dev/null +++ b/user/mpy/lib/axtls/www/test_dir/no_http/.htaccess @@ -0,0 +1 @@ +SSLRequireSSL diff --git a/user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd b/user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd new file mode 100644 index 0000000..0471b01 --- /dev/null +++ b/user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd @@ -0,0 +1,2 @@ +abcd:CQhgDPyy0rvEU8OMxnQIvg==$YdJfIKZimFLYxPf/rbnhtQ== +yaya:Syuss5jE2FNGVdr0kKGoHg==$WLw/SgHZFuAoOuml3GTJVw== diff --git a/user/mpy/lib/axtls/www/test_dir/no_http/index.html b/user/mpy/lib/axtls/www/test_dir/no_http/index.html new file mode 100644 index 0000000..8b86eba --- /dev/null +++ b/user/mpy/lib/axtls/www/test_dir/no_http/index.html @@ -0,0 +1,6 @@ + +axhttpd is running + +Looks like you got to this directory. + + diff --git a/user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess b/user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess new file mode 100644 index 0000000..d980d26 --- /dev/null +++ b/user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess @@ -0,0 +1 @@ +SSLDenySSL diff --git a/user/mpy/lib/axtls/www/test_dir/no_ssl/index.html b/user/mpy/lib/axtls/www/test_dir/no_ssl/index.html new file mode 100644 index 0000000..8b86eba --- /dev/null +++ b/user/mpy/lib/axtls/www/test_dir/no_ssl/index.html @@ -0,0 +1,6 @@ + +axhttpd is running + +Looks like you got to this directory. + + diff --git a/user/mpy/lib/berkeley-db-1.xx/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/Makefile.inc new file mode 100644 index 0000000..77af9c5 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/Makefile.inc @@ -0,0 +1,10 @@ +# @(#)Makefile.inc 8.2 (Berkeley) 2/21/94 +# +CFLAGS+=-D__DBINTERFACE_PRIVATE + +.include "${.CURDIR}/db/btree/Makefile.inc" +.include "${.CURDIR}/db/db/Makefile.inc" +.include "${.CURDIR}/db/hash/Makefile.inc" +.include "${.CURDIR}/db/man/Makefile.inc" +.include "${.CURDIR}/db/mpool/Makefile.inc" +.include "${.CURDIR}/db/recno/Makefile.inc" diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/Makefile new file mode 100644 index 0000000..383b259 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/README b/user/mpy/lib/berkeley-db-1.xx/PORT/README new file mode 100644 index 0000000..6d47281 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/README @@ -0,0 +1,131 @@ +# @(#)README 8.6 (Berkeley) 6/20/94 + +This is the area for building the libdb library. There are a number +of porting directories, for various architecture/OS combinations. Pick +the one that's closest to yours and try "make". For the rest of this +file, I'll use "MACH" as a fake architecture/OS name. + +To PORT to a new system, create the following subdirectories and +symbolic links. + + mkdir MACH (for example: mkdir sunos.4.0) + cd MACH + cp ../Makefile . + chmod 664 Makefile + ln -s ../clib . + mkdir include + ln -s include sys + cd include + ln -s ../../include/*.h . + rm compat.h + cp ../../include/compat.h . + chmod 664 compat.h + cd .. + +The basic idea is that you now have a local area that you can modify. +In particular, you have local copies of the Makefile and the include +file compat.h. Read through the Makefile and compat.h and make whatever +changes are appropriate to your system. If there's an architecture +that's close to yours, you probably should diff the Makefile and +compat.h in that tree against the standard ones and see what changes +were necessary, as they're probably necessary for you as well. Then, +enter "make" and see what happens! + +There are several subroutines that are found in POSIX 1003.2, ANSI +C, or 4.4BSD that you may not have. Once you get libdb.a to compile, +go through the list of undefined routines and add entries to the MISC +line in the Makefile as necessary. + +If you have to add some functions that are missing (and which aren't +in the PORT/clib directory), please don't add them in the PORT/clib +directory. Add them in a MACH/local directory, and add lines of the +form: + + function.o: local/function.o + ${CL} -Ilocal local/function.o + +to your local Makefile. + +Hopefully, over time, we'll develop a set of system directories that +are known to work. If you send me the changes that were necessary to +make your system work, this will happen much more quickly. + +In some of the system directories, you'll see a file named OTHER_PATCHES. +This is a set of patches which you'll have to make from the top-level db +directory to get libdb.a to run on this system: + + cd .. + patch < PORT/MACH/OTHER_PATCHES + +If patch prompts you for the name of the file to modify (some versions +of patch don't figure it out on their own) use the file name which patch +displays. + +Some knobs you may have to turn: + +In include/db.h: + Before attempting to build libdb, you should look through the + db.h file, and adjust it as necessary for your system. The + only adjustments that you should need to make are for the + fixed sized typedef's at the top of the file. Make sure they're + right for your system. + +In include/compat.h: + Before attempting to build libdb, you should look through the + compat.h file, and adjust it as necessary for your system. + It's possible to use the #ifndef construct to figure out if a + #ifdef has been set, but C provides no similar method to figure + out if a typedef has been done. Your compile errors should + give you a good indication of which ones you need. + +You may see warning messages about illegal pointer combinations. You may +also see lots of warning messages about #define's being redefined. These +can mostly be ignored. I usually ignore warning messages until something +doesn't work. Some systems produce thousands of lines of useless warnings, +bless their little hearts. + +The other parts of the PORT directory are as follows: + + The directory PORT/clib is a set of functions that the 4.4BSD + C library had and which your system may not have. They are + added to the MISC line of the Makefile if they aren't defined + when you try and load libdb.a. + + The directory PORT/include is header files that the 4.4BSD + system had which your system may not have. There is also + one really important extra one, named compat.h, which is a + set of compatibility work-arounds that you'll almost certainly + have to copy and modify for a new system. + + The symbolic link PORT/sys points to the PORT/include directory + so that includes of the form work. + +Some of the more common portability problems: + + If you don't have: + + memmove(3): add memmove.o + mkstemp(3): add mktemp.o + + ... to the MISC line in the Makefile. + + If you don't have snprintf/vsnprintf(3), add snprintf.o to the + MISC line in the Makefile. This workaround depends on your + system having vsprintf(3) -- if you don't, there's no workaround + other than changing the source code to not use the snprintf calls. + If you have to make that change, check to see if your vsprintf + returns a length or a char *; if it's the latter, make sure you + set VSPRINTF_CHARSTAR in the MACH/include/compat.h file. + +Installing the DB library: + + The Makefile builds a C library named libdb.a. This file needs + to be installed in a place where the loader will automatically + look for it (or, if you're building it for a single project, + wherever that project's Makefile loads it from). + + In addition, the header file PORT/include/db.h must be copied to + a directory (often /usr/include/) where programs that use the + db package can include it in their source. (If you intend to use + the ndbm interface to libdb, you'll need to copy the header file + PORT/include/ndbm.h as well.) diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile new file mode 100644 index 0000000..85b09a7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h new file mode 100644 index 0000000..2bd360a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h new file mode 120000 index 0000000..c626d51 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h @@ -0,0 +1 @@ +../../include/compat.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h new file mode 100644 index 0000000..cae13f9 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h @@ -0,0 +1,222 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)db.h 8.6 (Berkeley) 6/16/94 + */ + +#ifndef _DB_H_ +#define _DB_H_ + +#include +#include + +#include + +#ifdef __DBINTERFACE_PRIVATE +#include +#endif + +#define RET_ERROR -1 /* Return values. */ +#define RET_SUCCESS 0 +#define RET_SPECIAL 1 + +#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ +typedef u_int32_t pgno_t; +#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ +typedef u_int16_t indx_t; +#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ +typedef u_int32_t recno_t; + +/* Key/data structure -- a Data-Base Thang. */ +typedef struct { + void *data; /* data */ + size_t size; /* data length */ +} DBT; + +/* Routine flags. */ +#define R_CURSOR 1 /* del, put, seq */ +#define __R_UNUSED 2 /* UNUSED */ +#define R_FIRST 3 /* seq */ +#define R_IAFTER 4 /* put (RECNO) */ +#define R_IBEFORE 5 /* put (RECNO) */ +#define R_LAST 6 /* seq (BTREE, RECNO) */ +#define R_NEXT 7 /* seq */ +#define R_NOOVERWRITE 8 /* put */ +#define R_PREV 9 /* seq (BTREE, RECNO) */ +#define R_SETCURSOR 10 /* put (RECNO) */ +#define R_RECNOSYNC 11 /* sync (RECNO) */ + +typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; + +/* + * !!! + * The following flags are included in the dbopen(3) call as part of the + * open(2) flags. In order to avoid conflicts with the open flags, start + * at the top of the 16 or 32-bit number space and work our way down. If + * the open flags were significantly expanded in the future, it could be + * a problem. Wish I'd left another flags word in the dbopen call. + * + * !!! + * None of this stuff is implemented yet. The only reason that it's here + * is so that the access methods can skip copying the key/data pair when + * the DB_LOCK flag isn't set. + */ +#if UINT_MAX > 65535 +#define DB_LOCK 0x20000000 /* Do locking. */ +#define DB_SHMEM 0x40000000 /* Use shared memory. */ +#define DB_TXN 0x80000000 /* Do transactions. */ +#else +#define DB_LOCK 0x2000 /* Do locking. */ +#define DB_SHMEM 0x4000 /* Use shared memory. */ +#define DB_TXN 0x8000 /* Do transactions. */ +#endif + +/* Access method description structure. */ +typedef struct __db { + DBTYPE type; /* Underlying db type. */ + int (*close) __P((struct __db *)); + int (*del) __P((const struct __db *, const DBT *, u_int)); + int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); + int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); + int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); + int (*sync) __P((const struct __db *, u_int)); + void *internal; /* Access method private. */ + int (*fd) __P((const struct __db *)); +} DB; + +#define BTREEMAGIC 0x053162 +#define BTREEVERSION 3 + +/* Structure used to pass parameters to the btree routines. */ +typedef struct { +#define R_DUP 0x01 /* duplicate keys */ + u_long flags; + u_int cachesize; /* bytes to cache */ + int maxkeypage; /* maximum keys per page */ + int minkeypage; /* minimum keys per page */ + u_int psize; /* page size */ + int (*compare) /* comparison function */ + __P((const DBT *, const DBT *)); + size_t (*prefix) /* prefix function */ + __P((const DBT *, const DBT *)); + int lorder; /* byte order */ +} BTREEINFO; + +#define HASHMAGIC 0x061561 +#define HASHVERSION 2 + +/* Structure used to pass parameters to the hashing routines. */ +typedef struct { + u_int bsize; /* bucket size */ + u_int ffactor; /* fill factor */ + u_int nelem; /* number of elements */ + u_int cachesize; /* bytes to cache */ + u_int32_t /* hash function */ + (*hash) __P((const void *, size_t)); + int lorder; /* byte order */ +} HASHINFO; + +/* Structure used to pass parameters to the record routines. */ +typedef struct { +#define R_FIXEDLEN 0x01 /* fixed-length records */ +#define R_NOKEY 0x02 /* key not required */ +#define R_SNAPSHOT 0x04 /* snapshot the input */ + u_long flags; + u_int cachesize; /* bytes to cache */ + u_int psize; /* page size */ + int lorder; /* byte order */ + size_t reclen; /* record length (fixed-length records) */ + u_char bval; /* delimiting byte (variable-length records */ + char *bfname; /* btree file name */ +} RECNOINFO; + +#ifdef __DBINTERFACE_PRIVATE +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + u_int32_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[3]; \ + ((char *)&a)[1] = ((char *)&_tmp)[2]; \ + ((char *)&a)[2] = ((char *)&_tmp)[1]; \ + ((char *)&a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + u_int32_t _tmp = *(u_int32_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[3]; \ + ((char *)a)[1] = ((char *)&_tmp)[2]; \ + ((char *)a)[2] = ((char *)&_tmp)[1]; \ + ((char *)a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[3]; \ + ((char *)&(b))[1] = ((char *)&(a))[2]; \ + ((char *)&(b))[2] = ((char *)&(a))[1]; \ + ((char *)&(b))[3] = ((char *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + u_int16_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[1]; \ + ((char *)&a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + u_int16_t _tmp = *(u_int16_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[1]; \ + ((char *)a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[1]; \ + ((char *)&(b))[1] = ((char *)&(a))[0]; \ +} +#endif + +__BEGIN_DECLS +DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); + +#ifdef __DBINTERFACE_PRIVATE +DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); +DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); +DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); +void __dbpanic __P((DB *dbp)); +#endif +__END_DECLS +#endif /* !_DB_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile new file mode 120000 index 0000000..d0b0e8e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile @@ -0,0 +1 @@ +../Makefile \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES new file mode 100644 index 0000000..85027c9 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES @@ -0,0 +1,19 @@ +*** PORT/db/recno/rec_open.c.orig Mon Aug 16 16:29:18 1993 +--- PORT/db/recno/rec_open.c Mon Aug 16 16:29:35 1993 +*************** +*** 159,165 **** + else { + t->bt_msize = sb.st_size; + if ((t->bt_smap = mmap(NULL, t->bt_msize, +! PROT_READ, MAP_PRIVATE, rfd, + (off_t)0)) == (caddr_t)-1) + goto slow; + t->bt_cmap = t->bt_smap; +--- 159,165 ---- + else { + t->bt_msize = sb.st_size; + if ((t->bt_smap = mmap(NULL, t->bt_msize, +! PROT_READ, MAP_FILE | MAP_PRIVATE, rfd, + (off_t)0)) == (caddr_t)-1) + goto slow; + t->bt_cmap = t->bt_smap; diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h new file mode 100644 index 0000000..f455fe8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)assert.h 4.4 (Berkeley) 4/3/91 + */ + +#ifndef _ASSERT_H_ +#define _ASSERT_H_ + +#ifdef NDEBUG +#define assert(expression) +#define _assert(expression) +#else +#define assert(expression) { \ + if (!(expression)) { \ + (void)fprintf(stderr, \ + "assertion \"%s\" failed: file \"%s\", line %d\n", \ + "expression", __FILE__, __LINE__); \ + exit(2); \ + } \ +} +#define _assert(expression) assert(expression) +#endif + +#endif /* !_ASSERT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h new file mode 100644 index 0000000..ae735ef --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h new file mode 100644 index 0000000..21966d7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h @@ -0,0 +1,87 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)local.h 5.3 (Berkeley) 5/6/93 + */ + +/* + * Information local to this implementation of stdio, + * in particular, macros and private variables. + */ + +int __sflush __P((FILE *)); +FILE *__sfp __P((void)); +int __srefill __P((FILE *)); +int __sread __P((void *, char *, int)); +int __swrite __P((void *, char const *, int)); +fpos_t __sseek __P((void *, fpos_t, int)); +int __sclose __P((void *)); +void __sinit __P((void)); +void _cleanup __P((void)); +void (*__cleanup) __P((void)); +void __smakebuf __P((FILE *)); +int __swhatbuf __P((FILE *, size_t *, int *)); +int _fwalk __P((int (*)(FILE *))); +int __swsetup __P((FILE *)); +int __sflags __P((const char *, int *)); + +extern int __sdidinit; + +/* + * Return true iff the given FILE cannot be written now. + */ +#define cantwrite(fp) \ + ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ + __swsetup(fp)) + +/* + * Test whether the given stdio file has an active ungetc buffer; + * release such a buffer, without restoring ordinary unread data. + */ +#define HASUB(fp) ((fp)->_ub._base != NULL) +#define FREEUB(fp) { \ + if ((fp)->_ub._base != (fp)->_ubuf) \ + free((char *)(fp)->_ub._base); \ + (fp)->_ub._base = NULL; \ +} + +/* + * test for an fgetline() buffer. + */ +#define HASLB(fp) ((fp)->_lb._base != NULL) +#define FREELB(fp) { \ + free((char *)(fp)->_lb._base); \ + (fp)->_lb._base = NULL; \ +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c new file mode 100644 index 0000000..cb87e60 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c @@ -0,0 +1,118 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)makebuf.c 5.3 (Berkeley) 5/6/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include "local.h" + +/* + * Allocate a file buffer, or switch to unbuffered I/O. + * Per the ANSI C standard, ALL tty devices default to line buffered. + * + * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek + * optimisation) right after the fstat() that finds the buffer size. + */ +void +__smakebuf(fp) + register FILE *fp; +{ + register void *p; + register int flags; + size_t size; + int couldbetty; + + if (fp->_flags & __SNBF) { + fp->_bf._base = fp->_p = fp->_nbuf; + fp->_bf._size = 1; + return; + } + flags = __swhatbuf(fp, &size, &couldbetty); + if ((p = malloc(size)) == NULL) { + fp->_flags |= __SNBF; + fp->_bf._base = fp->_p = fp->_nbuf; + fp->_bf._size = 1; + return; + } + __cleanup = _cleanup; + flags |= __SMBF; + fp->_bf._base = fp->_p = p; + fp->_bf._size = size; + if (couldbetty && isatty(fp->_file)) + flags |= __SLBF; + fp->_flags |= flags; +} + +/* + * Internal routine to determine `proper' buffering for a file. + */ +int +__swhatbuf(fp, bufsize, couldbetty) + register FILE *fp; + size_t *bufsize; + int *couldbetty; +{ + struct stat st; + + if (fp->_file < 0 || fstat(fp->_file, &st) < 0) { + *couldbetty = 0; + *bufsize = BUFSIZ; + return (__SNPT); + } + + /* could be a tty iff it is a character device */ + *couldbetty = (st.st_mode & S_IFMT) == S_IFCHR; + if (st.st_blksize <= 0) { + *bufsize = BUFSIZ; + return (__SNPT); + } + + /* + * Optimise fseek() only if it is a regular file. (The test for + * __sseek is mainly paranoia.) It is safe to set _blksize + * unconditionally; it will only be used if __SOPT is also set. + */ + *bufsize = st.st_blksize; + fp->_blksize = st.st_blksize; + return ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ? + __SOPT : __SNPT); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c new file mode 100644 index 0000000..41bb16b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c @@ -0,0 +1,148 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +! static char sccsid[] = "@(#)setvbuf.c 5.5 (Berkeley) 5/6/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include "local.h" + +/* + * Set one of the three kinds of buffering, optionally including + * a buffer. + */ +setvbuf(fp, buf, mode, size) + register FILE *fp; + char *buf; + register int mode; + register size_t size; +{ + register int ret, flags; + size_t iosize; + int ttyflag; + + /* + * Verify arguments. The `int' limit on `size' is due to this + * particular implementation. Note, buf and size are ignored + * when setting _IONBF. + */ + if (mode != _IONBF) + if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0) + return (EOF); + + /* + * Write current buffer, if any. Discard unread input, cancel + * line buffering, and free old buffer if malloc()ed. + */ + ret = 0; + (void)__sflush(fp); + fp->_r = fp->_lbfsize = 0; + flags = fp->_flags; + if (flags & __SMBF) + free((void *)fp->_bf._base); + flags &= ~(__SLBF | __SNBF | __SMBF | __SOPT | __SNPT); + + /* If setting unbuffered mode, skip all the hard work. */ + if (mode == _IONBF) + goto nbf; + + /* + * Find optimal I/O size for seek optimization. This also returns + * a `tty flag' to suggest that we check isatty(fd), but we do not + * care since our caller told us how to buffer. + */ + flags |= __swhatbuf(fp, &iosize, &ttyflag); + if (size == 0) { + buf = NULL; /* force local allocation */ + size = iosize; + } + + /* Allocate buffer if needed. */ + if (buf == NULL) { + if ((buf = malloc(size)) == NULL) { + /* + * Unable to honor user's request. We will return + * failure, but try again with file system size. + */ + ret = EOF; + if (size != iosize) { + size = iosize; + buf = malloc(size); + } + } + if (buf == NULL) { + /* No luck; switch to unbuffered I/O. */ +nbf: + fp->_flags = flags | __SNBF; + fp->_w = 0; + fp->_bf._base = fp->_p = fp->_nbuf; + fp->_bf._size = 1; + return (ret); + } + flags |= __SMBF; + } + + /* + * Kill any seek optimization if the buffer is not the + * right size. + * + * SHOULD WE ALLOW MULTIPLES HERE (i.e., ok iff (size % iosize) == 0)? + */ + if (size != iosize) + flags |= __SNPT; + + /* + * Fix up the FILE fields, and set __cleanup for output flush on + * exit (since we are buffered in some way). If in r/w mode, go + * to the intermediate state, so that everyone has to call + * __srefill or __swsetup on the first operation -- it is more + * trouble than it is worth to set things up correctly here. + */ + if (mode == _IOLBF) + flags |= __SLBF; + if (flags & __SRW) + flags &= ~(__SRD | __SWR); + fp->_w = 0; + fp->_flags = flags; + fp->_bf._base = fp->_p = (unsigned char *)buf; + fp->_bf._size = size; + fp->_lbfsize = 0; + __cleanup = _cleanup; + + return (ret); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c new file mode 100644 index 0000000..f90b09c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c @@ -0,0 +1,139 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +/* + * sizeof(word) MUST BE A POWER OF TWO + * SO THAT wmask BELOW IS ALL ONES + */ +typedef int word; /* "word" used for optimal copy speed */ + +#define wsize sizeof(word) +#define wmask (wsize - 1) + +/* + * Copy a block of memory, handling overlap. + * This is the routine that actually implements + * (the portable versions of) bcopy, memcpy, and memmove. + */ +#ifdef MEMCOPY +void * +memcpy(dst0, src0, length) +#else +#ifdef MEMMOVE +void * +memmove(dst0, src0, length) +#else +void +bcopy(src0, dst0, length) +#endif +#endif + void *dst0; + const void *src0; + register size_t length; +{ + register char *dst = dst0; + register const char *src = src0; + register size_t t; + + if (length == 0 || dst == src) /* nothing to do */ + goto done; + + /* + * Macros: loop-t-times; and loop-t-times, t>0 + */ +#define TLOOP(s) if (t) TLOOP1(s) +#define TLOOP1(s) do { s; } while (--t) + + if ((unsigned long)dst < (unsigned long)src) { + /* + * Copy forward. + */ + t = (int)src; /* only need low bits */ + if ((t | (int)dst) & wmask) { + /* + * Try to align operands. This cannot be done + * unless the low bits match. + */ + if ((t ^ (int)dst) & wmask || length < wsize) + t = length; + else + t = wsize - (t & wmask); + length -= t; + TLOOP1(*dst++ = *src++); + } + /* + * Copy whole words, then mop up any trailing bytes. + */ + t = length / wsize; + TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); + t = length & wmask; + TLOOP(*dst++ = *src++); + } else { + /* + * Copy backwards. Otherwise essentially the same. + * Alignment works as before, except that it takes + * (t&wmask) bytes to align, not wsize-(t&wmask). + */ + src += length; + dst += length; + t = (int)src; + if ((t | (int)dst) & wmask) { + if ((t ^ (int)dst) & wmask || length <= wsize) + t = length; + else + t &= wmask; + length -= t; + TLOOP1(*--dst = *--src); + } + t = length / wsize; + TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); + t = length & wmask; + TLOOP(*--dst = *--src); + } +done: +#if defined(MEMCOPY) || defined(MEMMOVE) + return (dst0); +#else + return; +#endif +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c new file mode 100644 index 0000000..6cedd6a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include + +static int _gettemp(); + +mkstemp(path) + char *path; +{ + int fd; + + return (_gettemp(path, &fd) ? fd : -1); +} + +char * +mktemp(path) + char *path; +{ + return(_gettemp(path, (int *)NULL) ? path : (char *)NULL); +} + +static +_gettemp(path, doopen) + char *path; + register int *doopen; +{ + extern int errno; + register char *start, *trv; + struct stat sbuf; + u_int pid; + + pid = getpid(); + for (trv = path; *trv; ++trv); /* extra X's get set to 0's */ + while (*--trv == 'X') { + *trv = (pid % 10) + '0'; + pid /= 10; + } + + /* + * check the target directory; if you have six X's and it + * doesn't exist this runs for a *very* long time. + */ + for (start = trv + 1;; --trv) { + if (trv <= path) + break; + if (*trv == '/') { + *trv = '\0'; + if (stat(path, &sbuf)) + return(0); + if (!S_ISDIR(sbuf.st_mode)) { + errno = ENOTDIR; + return(0); + } + *trv = '/'; + break; + } + } + + for (;;) { + if (doopen) { + if ((*doopen = + open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + return(1); + if (errno != EEXIST) + return(0); + } + else if (stat(path, &sbuf)) + return(errno == ENOENT ? 1 : 0); + + /* tricky little algorithm for backward compatibility */ + for (trv = start;;) { + if (!*trv) + return(0); + if (*trv == 'z') + *trv++ = 'a'; + else { + if (isdigit(*trv)) + *trv = 'a'; + else + ++*trv; + break; + } + } + } + /*NOTREACHED*/ +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c new file mode 100644 index 0000000..2863fa2 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c @@ -0,0 +1,54 @@ +#include +#include + +#include + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +#ifdef __STDC__ +snprintf(char *str, size_t n, const char *fmt, ...) +#else +snprintf(str, n, fmt, va_alist) + char *str; + size_t n; + const char *fmt; + va_dcl +#endif +{ + va_list ap; + char *rp; + int rval; +#ifdef __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif +#ifdef VSPRINTF_CHARSTAR + rp = vsprintf(str, fmt, ap); + va_end(ap); + return (strlen(rp)); +#else + rval = vsprintf(str, fmt, ap); + va_end(ap); + return (rval); +#endif +} + +int +vsnprintf(str, n, fmt, ap) + char *str; + size_t n; + const char *fmt; + va_list ap; +{ +#ifdef VSPRINTF_CHARSTAR + return (strlen(vsprintf(str, fmt, ap))); +#else + return (vsprintf(str, fmt, ap)); +#endif +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c new file mode 100644 index 0000000..53f374b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include + +char * +strerror(num) + int num; +{ + extern int sys_nerr; + extern char *sys_errlist[]; +#define UPREFIX "Unknown error: " + static char ebuf[40] = UPREFIX; /* 64-bit number + slop */ + register unsigned int errnum; + register char *p, *t; + char tmp[40]; + + errnum = num; /* convert to unsigned */ + if (errnum < sys_nerr) + return(sys_errlist[errnum]); + + /* Do this by hand, so we don't include stdio(3). */ + t = tmp; + do { + *t++ = "0123456789"[errnum % 10]; + } while (errnum /= 10); + for (p = ebuf + sizeof(UPREFIX) - 1;;) { + *p++ = *--t; + if (t <= tmp) + break; + } + return(ebuf); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile new file mode 100644 index 0000000..4053c4b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile @@ -0,0 +1,103 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +CC= gcc +OORG= -O2 +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h new file mode 100644 index 0000000..2bd360a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 new file mode 120000 index 0000000..e634b1f --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 @@ -0,0 +1 @@ +hpux.9.01 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile new file mode 100644 index 0000000..85b09a7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h new file mode 100644 index 0000000..2bd360a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c new file mode 100644 index 0000000..e65083b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c @@ -0,0 +1,75 @@ +/* + * Derived from: + * static char sccsid[] = "@(#)siglist.c 8.1 (Berkeley) 6/4/93"; + */ +#include + +#include + +const char *const sys_signame[NSIG] = { + "Signal 0", + "hup", /* SIGHUP */ + "int", /* SIGINT */ + "quit", /* SIGQUIT */ + "ill", /* SIGILL */ + "trap", /* SIGTRAP */ + "abrt", /* SIGABRT */ + "emt", /* SIGEMT */ + "fpe", /* SIGFPE */ + "kill", /* SIGKILL */ + "bus", /* SIGBUS */ + "segv", /* SIGSEGV */ + "sys", /* SIGSYS */ + "pipe", /* SIGPIPE */ + "alrm", /* SIGALRM */ + "term", /* SIGTERM */ + "usr1", /* SIGUSR1 */ + "usr2", /* SIGUSR2 */ + "chld", /* SIGCHLD */ + "pwr", /* SIGPWR */ + "vtalrm", /* SIGVTALRM */ + "prof", /* SIGPROF */ + "io", /* SIGIO */ + "winch", /* SIGWINCH */ + "stop", /* SIGSTOP */ + "tstp", /* SIGTSTP */ + "cont", /* SIGCONT */ + "ttin", /* SIGTTIN */ + "ttou", /* SIGTTOU */ + "urg", /* SIGURG */ + "lost", /* SIGLOST */ +}; + +const char *const sys_siglist[NSIG] = { + "Signal 0", + "Hangup", /* SIGHUP */ + "Interrupt", /* SIGINT */ + "Quit", /* SIGQUIT */ + "Illegal instruction", /* SIGILL */ + "Trace/BPT trap", /* SIGTRAP */ + "Abort trap", /* SIGABRT */ + "EMT trap", /* SIGEMT */ + "Floating point exception", /* SIGFPE */ + "Killed", /* SIGKILL */ + "Bus error", /* SIGBUS */ + "Segmentation fault", /* SIGSEGV */ + "Bad system call", /* SIGSYS */ + "Broken pipe", /* SIGPIPE */ + "Alarm clock", /* SIGALRM */ + "Terminated", /* SIGTERM */ + "User defined signal 1", /* SIGUSR1 */ + "User defined signal 2" /* SIGUSR2 */ + "Child exited", /* SIGCHLD */ + "Power failure", /* SIGPWR */ + "Virtual timer expired", /* SIGVTALRM */ + "Profiling timer expired", /* SIGPROF */ + "I/O possible", /* SIGIO */ + "Window size changes", /* SIGWINCH */ + "Suspended (signal)", /* SIGSTOP */ + "Suspended", /* SIGTSTP */ + "Continued", /* SIGCONT */ + "Stopped (tty input)", /* SIGTTIN */ + "Stopped (tty output)", /* SIGTTOU */ + "Urgent I/O condition", /* SIGURG */ + "File lock lost", /* SIGLOST */ +}; diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h new file mode 120000 index 0000000..f28ad5d --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h @@ -0,0 +1 @@ +queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h new file mode 100644 index 0000000..c104b9e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.7 (Berkeley) 1/21/94 + */ + +#ifndef _CDEFS_H_ +#define _CDEFS_H_ + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS }; +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ +#if defined(__STDC__) || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) +#define __inline inline /* convert to C++ keyword */ +#else +#ifndef __GNUC__ +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * When using a compiler other than gcc, programs using the ANSI C keywords + * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. + * When using "gcc -traditional", we assume that this is the intent; if + * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. + */ +#ifndef NO_ANSI_KEYWORDS +#define const /* delete ANSI C keywords */ +#define inline +#define signed +#define volatile +#endif +#endif /* !__GNUC__ */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * GCC1 and some versions of GCC2 declare dead (non-returning) and + * pure (no side effects) functions using "volatile" and "const"; + * unfortunately, these then cause warnings under "-ansi -pedantic". + * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of + * these work for GNU C++ (modulo a slight glitch in the C++ grammar + * in the distribution version of 2.5.5). + */ +#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#define __dead __volatile +#define __pure __const +#endif +#endif + +/* Delete pseudo-keywords wherever they are not available or needed. */ +#ifndef __dead +#define __dead +#define __pure +#endif + +#endif /* !_CDEFS_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h new file mode 100644 index 0000000..30cf88d --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h @@ -0,0 +1,233 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#ifndef memmove +#define memmove(a, b, n) bcopy(b, a, n) +#endif +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h new file mode 120000 index 0000000..25306d1 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h @@ -0,0 +1 @@ +../../include/filevtable.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h new file mode 100644 index 0000000..a545bca --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NDBM_H_ +#define _NDBM_H_ + +#include + +/* Map dbm interface onto db(3). */ +#define DBM_RDONLY O_RDONLY + +/* Flags to dbm_store(). */ +#define DBM_INSERT 0 +#define DBM_REPLACE 1 + +/* + * The db(3) support for ndbm(3) always appends this suffix to the + * file name to avoid overwriting the user's original database. + */ +#define DBM_SUFFIX ".db" + +typedef struct { + char *dptr; + int dsize; +} datum; + +typedef DB DBM; +#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE + +__BEGIN_DECLS +void dbm_close __P((DBM *)); +int dbm_delete __P((DBM *, datum)); +datum dbm_fetch __P((DBM *, datum)); +datum dbm_firstkey __P((DBM *)); +long dbm_forder __P((DBM *, datum)); +datum dbm_nextkey __P((DBM *)); +DBM *dbm_open __P((const char *, int, int)); +int dbm_store __P((DBM *, datum, datum, int)); +int dbm_dirfno __P((DBM *)); +__END_DECLS + +#endif /* !_NDBM_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h new file mode 100644 index 0000000..40d32cc --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h @@ -0,0 +1,245 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.3 (Berkeley) 12/13/93 + */ + +#ifndef _QUEUE_H_ +#define _QUEUE_H_ + +/* + * This file defines three types of data structures: lists, tail queues, + * and circular queues. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list after + * an existing element or at the head of the list. A list may only be + * traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A tail queue may only be traversed in the forward direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#define LIST_INIT(head) { \ + (head)->lh_first = NULL; \ +} + +#define LIST_INSERT_AFTER(listelm, elm, field) { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} + +#define LIST_INSERT_HEAD(head, elm, field) { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} + +#define LIST_REMOVE(elm, field) { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ +} + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} + +/* + * Tail queue functions. + */ +#define TAILQ_INIT(head) { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} + +#define TAILQ_INSERT_HEAD(head, elm, field) { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} + +#define TAILQ_INSERT_TAIL(head, elm, field) { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} + +#define TAILQ_REMOVE(head, elm, field) { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} + +/* + * Circular queue definitions. + */ +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) { \ + (head)->cqh_first = (void *)(head); \ + (head)->cqh_last = (void *)(head); \ +} + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) { \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = (void *)(head); \ + if ((head)->cqh_last == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) { \ + (elm)->field.cqe_next = (void *)(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} + +#define CIRCLEQ_REMOVE(head, elm, field) { \ + if ((elm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ +} +#endif /* !_QUEUE_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile new file mode 100644 index 0000000..1775095 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile @@ -0,0 +1,103 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +CC= cc -cckr -D_BSD_COMPAT +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES new file mode 100644 index 0000000..46c624b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES @@ -0,0 +1,32 @@ +*** PORT/db/btree/bt_open.c.dist Thu Sep 16 14:42:22 1993 +--- PORT/db/btree/bt_open.c Mon Nov 8 07:03:40 1993 +*************** +*** 256,262 **** +--- 256,266 ---- + * Don't overflow the page offset type. + */ + if (b.psize == 0) { ++ #ifndef sgi + b.psize = sb.st_blksize; ++ #else ++ b.psize = 4096; ++ #endif /* sgi */ + if (b.psize < MINPSIZE) + b.psize = MINPSIZE; + if (b.psize > MAX_PAGE_OFFSET + 1) +*** PORT/db/hash/hash.c.dist Thu Nov 4 15:32:16 1993 +--- PORT/db/hash/hash.c Mon Nov 8 07:05:12 1993 +*************** +*** 301,307 **** +--- 301,311 ---- + if (file != NULL) { + if (stat(file, &statbuf)) + return (NULL); ++ #ifndef sgi + hashp->BSIZE = statbuf.st_blksize; ++ #else ++ hashp->BSIZE = 4096; ++ #endif /* sgi */ + hashp->BSHIFT = __log2(hashp->BSIZE); + } + diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h new file mode 100644 index 0000000..2bd360a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile new file mode 100644 index 0000000..85b09a7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES new file mode 100644 index 0000000..b0387a5 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES @@ -0,0 +1,29 @@ +*** PORT/db/recno/rec_open.c.orig 1993/10/13 02:01:31 +--- PORT/db/recno/rec_open.c 1993/10/13 02:20:47 +*************** +*** 159,167 **** +--- 159,182 ---- + SET(t, R_EOF); + else { + t->bt_msize = sb.st_size; ++ /* ++ * hack : ++ * ++ * The Linux kernel mmap() semantics are broken : ++ * ++ * Under Linux, read only private mappings cause write only and read/write ++ * opens to fail with errno=ETXTBSY. Shared read only mappings should work ++ * fine though, but I'm not familiar enough with the code to ascertain that ++ * a MAP_SHARED mapping would be safe so I use the non-mmap'd version ++ * instead. ++ * ++ */ ++ ++ #if !defined(linux) + if ((t->bt_smap = mmap(NULL, t->bt_msize, + PROT_READ, MAP_PRIVATE, rfd, + (off_t)0)) == (caddr_t)-1) ++ #endif + goto slow; + t->bt_cmap = t->bt_smap; + t->bt_emap = t->bt_smap + sb.st_size; diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h new file mode 100644 index 0000000..ae735ef --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile new file mode 100644 index 0000000..85b09a7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h new file mode 100644 index 0000000..ae735ef --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 new file mode 120000 index 0000000..1a1d658 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 @@ -0,0 +1 @@ +osf.1.0.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 new file mode 120000 index 0000000..1a1d658 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 @@ -0,0 +1 @@ +osf.1.0.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile new file mode 100644 index 0000000..e852b76 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile @@ -0,0 +1,104 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= mktemp.o snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +CC= gcc +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude \ + -DMMAP_NOT_AVAILABLE -DSTBLKSIZE_NOT_AVAILABLE -DSYS5 + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES new file mode 100644 index 0000000..891cccb --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES @@ -0,0 +1,95 @@ +*** PORT/db/btree/bt_open.c.orig 1993/11/24 11:16:51 +--- PORT/db/btree/bt_open.c 1993/11/24 12:38:12 +*************** +*** 256,262 **** +--- 256,266 ---- + * Don't overflow the page offset type. + */ + if (b.psize == 0) { ++ #ifdef STBLKSIZE_NOT_AVAILABLE ++ b.psize = 4096; ++ #else + b.psize = sb.st_blksize; ++ #endif + if (b.psize < MINPSIZE) + b.psize = MINPSIZE; + if (b.psize > MAX_PAGE_OFFSET + 1) +*** PORT/db/recno/rec_open.c.orig 1993/11/29 18:26:26 +--- PORT/db/recno/rec_open.c 1993/11/30 11:35:21 +*************** +*** 159,164 **** +--- 159,167 ---- + SET(t, R_EOF); + else { + t->bt_msize = sb.st_size; ++ #ifdef MMAP_NOT_AVAILABLE ++ goto slow; ++ #else + if ((t->bt_smap = mmap(NULL, t->bt_msize, + PROT_READ, MAP_PRIVATE, rfd, + (off_t)0)) == (caddr_t)-1) +*************** +*** 168,173 **** +--- 171,177 ---- + t->bt_irec = ISSET(t, R_FIXLEN) ? + __rec_fmap : __rec_vmap; + SET(t, R_MEMMAPPED); ++ #endif + } + } + } +*** PORT/db/hash/hash_log2.c.orig 1993/11/24 11:10:40 +--- PORT/db/hash/hash_log2.c 1993/11/24 12:38:52 +*************** +*** 40,50 **** + + #include + +! u_int + __log2(num) +! u_int num; + { +! register u_int i, limit; + + limit = 1; + for (i = 0; limit < num; limit = limit << 1, i++); +--- 40,50 ---- + + #include + +! unsigned int + __log2(num) +! unsigned int num; + { +! register unsigned int i, limit; + + limit = 1; + for (i = 0; limit < num; limit = limit << 1, i++); +*** PORT/db/hash/hash.c.orig 1993/11/24 11:18:44 +--- PORT/db/hash/hash.c 1993/11/24 12:38:29 +*************** +*** 301,307 **** +--- 301,311 ---- + if (file != NULL) { + if (stat(file, &statbuf)) + return (NULL); ++ #ifdef STBLKSIZE_NOT_AVAILABLE ++ hashp->BSIZE = 4096; ++ #else + hashp->BSIZE = statbuf.st_blksize; ++ #endif + hashp->BSHIFT = __log2(hashp->BSIZE); + } + +*** PORT/db/hash/hash.h.orig 1993/11/24 11:20:03 +--- PORT/db/hash/hash.h 1993/11/24 12:38:38 +*************** +*** 261,266 **** +--- 261,267 ---- + #define REAL_KEY 4 + + /* Short hands for accessing structure */ ++ #undef BSIZE + #define BSIZE hdr.bsize + #define BSHIFT hdr.bshift + #define DSIZE hdr.dsize diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h new file mode 100644 index 0000000..108060d --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h @@ -0,0 +1,232 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include +#include /* For fd_set. */ + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 1 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h new file mode 100644 index 0000000..81b9f32 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)pathnames.h 8.5 (Berkeley) 12/21/93 + */ + +#define _PATH_BSHELL "/bin/sh" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_EXRC ".exrc" +#define _PATH_NEXRC ".nexrc" +#define _PATH_PRESERVE "/usr/tmp/vi.recover" +#define _PATH_SENDMAIL "/usr/lib/sendmail" +#define _PATH_SYSEXRC "/etc/vi.exrc" +#define _PATH_TAGS "tags" +#define _PATH_TMP "/tmp" +#define _PATH_TTY "/dev/tty" diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile new file mode 100644 index 0000000..dd459ad --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= mktemp.o snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h new file mode 100644 index 0000000..2bd360a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 b/user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 new file mode 120000 index 0000000..b9f1ef8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 @@ -0,0 +1 @@ +sunos.5.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile new file mode 100644 index 0000000..aae1a45 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= memmove.o snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h new file mode 100644 index 0000000..62643bd --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 1 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 1 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h new file mode 100644 index 0000000..df94cd0 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)pathnames.h 8.5 (Berkeley) 12/21/93 + */ + +#define _PATH_BSHELL "/bin/sh" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_EXRC ".exrc" +#define _PATH_NEXRC ".nexrc" +#define _PATH_PRESERVE "/var/tmp/vi.recover" +#define _PATH_SENDMAIL "/usr/lib/sendmail" +#define _PATH_SYSEXRC "/etc/vi.exrc" +#define _PATH_TAGS "tags /var/db/libc.tags /sys/kern/tags" +#define _PATH_TMP "/tmp" +#define _PATH_TTY "/dev/tty" diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 new file mode 120000 index 0000000..cf2aa36 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 @@ -0,0 +1 @@ +sunos.4.1.1 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 new file mode 120000 index 0000000..cf2aa36 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 @@ -0,0 +1 @@ +sunos.4.1.1 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile new file mode 100644 index 0000000..85b09a7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h new file mode 100644 index 0000000..b302f19 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h @@ -0,0 +1,236 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +#define NO_ERRLIST + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 0 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + + +#define write _write + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h new file mode 120000 index 0000000..44c1ba4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h @@ -0,0 +1 @@ +../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile new file mode 100644 index 0000000..dd459ad --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile @@ -0,0 +1,102 @@ +# @(#)Makefile 8.9 (Berkeley) 7/14/94 + +LIBDB= libdb.a +OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ + hsearch.o ndbm.o +OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ + bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ + bt_utils.o +OBJ3= db.o +OBJ4= mpool.o +OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ + rec_seq.o rec_utils.o + +MISC= mktemp.o snprintf.o + +${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + rm -f $@ + ar cq $@ \ + `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` + ranlib $@ + +clean: + rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} + +OORG= -O +CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude + +hash.o: ../../hash/hash.c + ${CL} -I../../hash ../../hash/hash.c +hash_bigkey.o: ../../hash/hash_bigkey.c + ${CL} -I../../hash ../../hash/hash_bigkey.c +hash_buf.o: ../../hash/hash_buf.c + ${CL} -I../../hash ../../hash/hash_buf.c +hash_func.o: ../../hash/hash_func.c + ${CL} -I../../hash ../../hash/hash_func.c +hash_log2.o: ../../hash/hash_log2.c + ${CL} -I../../hash ../../hash/hash_log2.c +hash_page.o: ../../hash/hash_page.c + ${CL} -I../../hash ../../hash/hash_page.c +hsearch.o: ../../hash/hsearch.c + ${CL} -I../../hash ../../hash/hsearch.c +ndbm.o: ../../hash/ndbm.c + ${CL} -I../../hash ../../hash/ndbm.c + +bt_close.o: ../../btree/bt_close.c + ${CL} -I../../btree ../../btree/bt_close.c +bt_conv.o: ../../btree/bt_conv.c + ${CL} -I../../btree ../../btree/bt_conv.c +bt_debug.o: ../../btree/bt_debug.c + ${CL} -I../../btree ../../btree/bt_debug.c +bt_delete.o: ../../btree/bt_delete.c + ${CL} -I../../btree ../../btree/bt_delete.c +bt_get.o: ../../btree/bt_get.c + ${CL} -I../../btree ../../btree/bt_get.c +bt_open.o: ../../btree/bt_open.c + ${CL} -I../../btree ../../btree/bt_open.c +bt_overflow.o: ../../btree/bt_overflow.c + ${CL} -I../../btree ../../btree/bt_overflow.c +bt_page.o: ../../btree/bt_page.c + ${CL} -I../../btree ../../btree/bt_page.c +bt_put.o: ../../btree/bt_put.c + ${CL} -I../../btree ../../btree/bt_put.c +bt_search.o: ../../btree/bt_search.c + ${CL} -I../../btree ../../btree/bt_search.c +bt_seq.o: ../../btree/bt_seq.c + ${CL} -I../../btree ../../btree/bt_seq.c +bt_split.o: ../../btree/bt_split.c + ${CL} -I../../btree ../../btree/bt_split.c +bt_stack.o: ../../btree/bt_stack.c + ${CL} -I../../btree ../../btree/bt_stack.c +bt_utils.o: ../../btree/bt_utils.c + ${CL} -I../../btree ../../btree/bt_utils.c + +db.o: ../../db/db.c + ${CL} ../../db/db.c + +mpool.o: ../../mpool/mpool.c + ${CL} -I../../mpool ../../mpool/mpool.c + +rec_close.o: ../../recno/rec_close.c + ${CL} -I../../recno ../../recno/rec_close.c +rec_delete.o: ../../recno/rec_delete.c + ${CL} -I../../recno ../../recno/rec_delete.c +rec_get.o: ../../recno/rec_get.c + ${CL} -I../../recno ../../recno/rec_get.c +rec_open.o: ../../recno/rec_open.c + ${CL} -I../../recno ../../recno/rec_open.c +rec_put.o: ../../recno/rec_put.c + ${CL} -I../../recno ../../recno/rec_put.c +rec_search.o: ../../recno/rec_search.c + ${CL} -I../../recno ../../recno/rec_search.c +rec_seq.o: ../../recno/rec_seq.c + ${CL} -I../../recno ../../recno/rec_seq.c +rec_utils.o: ../../recno/rec_utils.c + ${CL} -I../../recno ../../recno/rec_utils.c + +memmove.o: + ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c +mktemp.o: + ${CC} -c -O -I. -Iinclude clib/mktemp.c +snprintf.o: + ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib new file mode 120000 index 0000000..f0f4f38 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib @@ -0,0 +1 @@ +../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h new file mode 120000 index 0000000..d248490 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h @@ -0,0 +1 @@ +../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h new file mode 100644 index 0000000..46a2964 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h @@ -0,0 +1,231 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)compat.h 8.13 (Berkeley) 2/21/94 + */ + +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +#include + +/* + * If your system doesn't typedef u_long, u_short, or u_char, change + * the 0 to a 1. + */ +#if 0 +typedef unsigned char u_char; /* 4.[34]BSD names. */ +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short u_short; +#endif + +/* If your system doesn't typedef size_t, change the 0 to a 1. */ +#if 0 +typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ +#endif + +/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ +#if 1 +typedef int ssize_t; /* POSIX names. */ +#endif + +/* + * If your system doesn't have the POSIX type for a signal mask, + * change the 0 to a 1. + */ +#if 0 /* POSIX 1003.1 signal mask type. */ +typedef unsigned int sigset_t; +#endif + +/* + * If your system's vsprintf returns a char *, not an int, + * change the 0 to a 1. + */ +#if 0 +#define VSPRINTF_CHARSTAR +#endif + +/* + * If you don't have POSIX 1003.1 signals, the signal code surrounding the + * temporary file creation is intended to block all of the possible signals + * long enough to create the file and unlink it. All of this stuff is + * intended to use old-style BSD calls to fake POSIX 1003.1 calls. + */ +#ifdef NO_POSIX_SIGNALS +#define sigemptyset(set) (*(set) = 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) +#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) +#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +static int __sigtemp; /* For the use of sigprocmask */ + +/* Repeated test of oset != NULL is to avoid "*0". */ +#define sigprocmask(how, set, oset) \ + ((__sigtemp = \ + (((how) == SIG_BLOCK) ? \ + sigblock(0) | *(set) : \ + (((how) == SIG_UNBLOCK) ? \ + sigblock(0) & ~(*(set)) : \ + ((how) == SIG_SETMASK ? \ + *(set) : sigblock(0))))), \ + ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ + sigsetmask(__sigtemp)), 0) +#endif + +/* + * If your system doesn't have an include file with the appropriate + * byte order set, make sure you specify the correct one. + */ +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ +#endif + +#if defined(SYSV) || defined(SYSTEM5) +#define index(a, b) strchr(a, b) +#define rindex(a, b) strrchr(a, b) +#define bzero(a, b) memset(a, 0, b) +#define bcmp(a, b, n) memcmp(a, b, n) +#define bcopy(a, b, n) memmove(b, a, n) +#endif + +#if defined(BSD) || defined(BSD4_3) +#define strchr(a, b) index(a, b) +#define strrchr(a, b) rindex(a, b) +#define memcmp(a, b, n) bcmp(a, b, n) +#define memmove(a, b, n) bcopy(b, a, n) +#endif + +/* + * 32-bit machine. The db routines are theoretically independent of + * the size of u_shorts and u_longs, but I don't know that anyone has + * ever actually tried it. At a minimum, change the following #define's + * if you are trying to compile on a different type of system. + */ +#ifndef USHRT_MAX +#define USHRT_MAX 0xFFFF +#define ULONG_MAX 0xFFFFFFFF +#endif + +#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +/* + * If you can't provide lock values in the open(2) call. Note, this + * allows races to happen. + */ +#ifndef O_EXLOCK /* 4.4BSD extension. */ +#define O_EXLOCK 0 +#endif + +#ifndef O_SHLOCK /* 4.4BSD extension. */ +#define O_SHLOCK 0 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ +#endif + +#ifndef WCOREDUMP /* 4.4BSD extension */ +#define WCOREDUMP(a) 0 +#endif + +#ifndef STDERR_FILENO +#define STDIN_FILENO 0 /* ANSI C #defines */ +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif + +#ifndef SEEK_END +#define SEEK_SET 0 /* POSIX 1003.1 seek values */ +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ +#define _POSIX_VDISABLE 0 /* Some systems used 0. */ +#endif + +#ifndef TCSASOFT /* 4.4BSD extension. */ +#define TCSASOFT 0 +#endif + +#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif + +#ifndef NULL /* ANSI C #defines NULL everywhere. */ +#define NULL 0 +#endif + +#ifndef MAX /* Usually found in . */ +#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) +#endif +#ifndef MIN /* Usually found in . */ +#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) +#endif + +/* Default file permissions. */ +#ifndef DEFFILEMODE /* 4.4BSD extension. */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ +#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ +#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ +#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ +#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ +#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ +#endif +#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ +#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ +#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ +#endif + +/* The type of a va_list. */ +#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ +#define _BSD_VA_LIST_ char * +#endif + +#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h new file mode 100644 index 0000000..55f8c57 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h @@ -0,0 +1,230 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)db.h 8.7 (Berkeley) 6/16/94 + */ + +#ifndef _DB_H_ +#define _DB_H_ + +#include +#include + +#include + +#ifdef __DBINTERFACE_PRIVATE +#include +#endif + +#define RET_ERROR -1 /* Return values. */ +#define RET_SUCCESS 0 +#define RET_SPECIAL 1 + +#ifndef __BIT_TYPES_DEFINED__ +#define __BIT_TYPES_DEFINED__ +typedef __signed char int8_t; +typedef unsigned char u_int8_t; +typedef short int16_t; +typedef unsigned short u_int16_t; +typedef int int32_t; +typedef unsigned int u_int32_t; +#ifdef WE_DONT_NEED_QUADS +typedef long long int64_t; +typedef unsigned long long u_int64_t; +#endif +#endif + +#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ +typedef u_int32_t pgno_t; +#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ +typedef u_int16_t indx_t; +#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ +typedef u_int32_t recno_t; + +/* Key/data structure -- a Data-Base Thang. */ +typedef struct { + void *data; /* data */ + size_t size; /* data length */ +} DBT; + +/* Routine flags. */ +#define R_CURSOR 1 /* del, put, seq */ +#define __R_UNUSED 2 /* UNUSED */ +#define R_FIRST 3 /* seq */ +#define R_IAFTER 4 /* put (RECNO) */ +#define R_IBEFORE 5 /* put (RECNO) */ +#define R_LAST 6 /* seq (BTREE, RECNO) */ +#define R_NEXT 7 /* seq */ +#define R_NOOVERWRITE 8 /* put */ +#define R_PREV 9 /* seq (BTREE, RECNO) */ +#define R_SETCURSOR 10 /* put (RECNO) */ +#define R_RECNOSYNC 11 /* sync (RECNO) */ + +typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; + +/* + * !!! + * The following flags are included in the dbopen(3) call as part of the + * open(2) flags. In order to avoid conflicts with the open flags, start + * at the top of the 16 or 32-bit number space and work our way down. If + * the open flags were significantly expanded in the future, it could be + * a problem. Wish I'd left another flags word in the dbopen call. + * + * !!! + * None of this stuff is implemented yet. The only reason that it's here + * is so that the access methods can skip copying the key/data pair when + * the DB_LOCK flag isn't set. + */ +#define DB_LOCK 0x20000000 /* Do locking. */ +#define DB_SHMEM 0x40000000 /* Use shared memory. */ +#define DB_TXN 0x80000000 /* Do transactions. */ + +/* Access method description structure. */ +typedef struct __db { + DBTYPE type; /* Underlying db type. */ + int (*close) __P((struct __db *)); + int (*del) __P((const struct __db *, const DBT *, u_int)); + int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); + int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); + int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); + int (*sync) __P((const struct __db *, u_int)); + void *internal; /* Access method private. */ + int (*fd) __P((const struct __db *)); +} DB; + +#define BTREEMAGIC 0x053162 +#define BTREEVERSION 3 + +/* Structure used to pass parameters to the btree routines. */ +typedef struct { +#define R_DUP 0x01 /* duplicate keys */ + u_long flags; + u_int cachesize; /* bytes to cache */ + int maxkeypage; /* maximum keys per page */ + int minkeypage; /* minimum keys per page */ + u_int psize; /* page size */ + int (*compare) /* comparison function */ + __P((const DBT *, const DBT *)); + size_t (*prefix) /* prefix function */ + __P((const DBT *, const DBT *)); + int lorder; /* byte order */ +} BTREEINFO; + +#define HASHMAGIC 0x061561 +#define HASHVERSION 2 + +/* Structure used to pass parameters to the hashing routines. */ +typedef struct { + u_int bsize; /* bucket size */ + u_int ffactor; /* fill factor */ + u_int nelem; /* number of elements */ + u_int cachesize; /* bytes to cache */ + u_int32_t /* hash function */ + (*hash) __P((const void *, size_t)); + int lorder; /* byte order */ +} HASHINFO; + +/* Structure used to pass parameters to the record routines. */ +typedef struct { +#define R_FIXEDLEN 0x01 /* fixed-length records */ +#define R_NOKEY 0x02 /* key not required */ +#define R_SNAPSHOT 0x04 /* snapshot the input */ + u_long flags; + u_int cachesize; /* bytes to cache */ + u_int psize; /* page size */ + int lorder; /* byte order */ + size_t reclen; /* record length (fixed-length records) */ + u_char bval; /* delimiting byte (variable-length records */ + char *bfname; /* btree file name */ +} RECNOINFO; + +#ifdef __DBINTERFACE_PRIVATE +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + u_int32_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[3]; \ + ((char *)&a)[1] = ((char *)&_tmp)[2]; \ + ((char *)&a)[2] = ((char *)&_tmp)[1]; \ + ((char *)&a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + u_int32_t _tmp = *(u_int32_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[3]; \ + ((char *)a)[1] = ((char *)&_tmp)[2]; \ + ((char *)a)[2] = ((char *)&_tmp)[1]; \ + ((char *)a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[3]; \ + ((char *)&(b))[1] = ((char *)&(a))[2]; \ + ((char *)&(b))[2] = ((char *)&(a))[1]; \ + ((char *)&(b))[3] = ((char *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + u_int16_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[1]; \ + ((char *)&a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + u_int16_t _tmp = *(u_int16_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[1]; \ + ((char *)a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[1]; \ + ((char *)&(b))[1] = ((char *)&(a))[0]; \ +} +#endif + +__BEGIN_DECLS +DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); + +#ifdef __DBINTERFACE_PRIVATE +DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); +DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); +DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); +void __dbpanic __P((DB *dbp)); +#endif +__END_DECLS +#endif /* !_DB_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h new file mode 120000 index 0000000..03f870c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h @@ -0,0 +1 @@ +../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h new file mode 120000 index 0000000..a1a41a8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h @@ -0,0 +1 @@ +../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h new file mode 120000 index 0000000..e54c7cf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h @@ -0,0 +1 @@ +../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys new file mode 120000 index 0000000..2996fba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 new file mode 120000 index 0000000..283b111 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 @@ -0,0 +1 @@ +ultrix.4.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/README b/user/mpy/lib/berkeley-db-1.xx/README new file mode 100644 index 0000000..bed2c92 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/README @@ -0,0 +1,40 @@ +# @(#)README 8.27 (Berkeley) 9/1/94 + +This is version 1.85 of the Berkeley DB code. + +For information on compiling and installing this software, see the file +PORT/README. + +Newer versions of this software will periodically be made available by +anonymous ftp from ftp.cs.berkeley.edu. An archive in compressed format +is in ucb/4bsd/db.tar.Z, or in gzip format in ucb/4bsd/db.tar.gz. If +you'd like to receive announcements of future releases of this software, +send email to the contact address below. + +Email questions may be addressed to Keith Bostic at bostic@cs.berkeley.edu. + +============================================ +Distribution contents: + +Makefile.inc Ignore this, it's the 4.4BSD subsystem Makefile. +PORT The per OS/architecture directories to use to build + libdb.a, if you're not running 4.4BSD. See the file + PORT/README for more information. +README This file. +btree The B+tree routines. +changelog List of changes, per version. +db The dbopen(3) interface routine. +docs Various USENIX papers, and the formatted manual pages. +hash The extended linear hashing routines. +man The unformatted manual pages. +mpool The memory pool routines. +recno The fixed/variable length record routines. +test Test package. + +============================================ +Debugging: + +If you're running a memory checker (e.g. Purify) on DB, make sure that +you recompile it with "-DPURIFY" in the CFLAGS, first. By default, +allocated pages are not initialized by the DB code, and they will show +up as reads of uninitialized memory in the buffer write routines. diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc new file mode 100644 index 0000000..8ed7649 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc @@ -0,0 +1,7 @@ +# @(#)Makefile.inc 8.2 (Berkeley) 7/14/94 + +.PATH: ${.CURDIR}/db/btree + +SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c \ + bt_overflow.c bt_page.c bt_put.c bt_search.c bt_seq.c bt_split.c \ + bt_utils.c diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c new file mode 100644 index 0000000..523bbdb --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c @@ -0,0 +1,179 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +#include +#include "btree.h" + +static int bt_meta __P((BTREE *)); + +/* + * BT_CLOSE -- Close a btree. + * + * Parameters: + * dbp: pointer to access method + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__bt_close(dbp) + DB *dbp; +{ + BTREE *t; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* Sync the tree. */ + if (__bt_sync(dbp, 0) == RET_ERROR) + return (RET_ERROR); + + /* Close the memory pool. */ + if (mpool_close(t->bt_mp) == RET_ERROR) + return (RET_ERROR); + + /* Free random memory. */ + if (t->bt_cursor.key.data != NULL) { + free(t->bt_cursor.key.data); + t->bt_cursor.key.size = 0; + t->bt_cursor.key.data = NULL; + } + if (t->bt_rkey.data) { + free(t->bt_rkey.data); + t->bt_rkey.size = 0; + t->bt_rkey.data = NULL; + } + if (t->bt_rdata.data) { + free(t->bt_rdata.data); + t->bt_rdata.size = 0; + t->bt_rdata.data = NULL; + } + + free(t); + free(dbp); + return RET_SUCCESS; +} + +/* + * BT_SYNC -- sync the btree to disk. + * + * Parameters: + * dbp: pointer to access method + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +int +__bt_sync(dbp, flags) + const DB *dbp; + u_int flags; +{ + BTREE *t; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* Sync doesn't currently take any flags. */ + if (flags != 0) { + errno = EINVAL; + return (RET_ERROR); + } + + if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED)) + return (RET_SUCCESS); + + if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) + return (RET_ERROR); + + if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS) + F_CLR(t, B_MODIFIED); + + return (status); +} + +/* + * BT_META -- write the tree meta data to disk. + * + * Parameters: + * t: tree + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +static int +bt_meta(t) + BTREE *t; +{ + BTMETA m; + void *p; + + if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL) + return (RET_ERROR); + + /* Fill in metadata. */ + m.magic = BTREEMAGIC; + m.version = BTREEVERSION; + m.psize = t->bt_psize; + m.free = t->bt_free; + m.nrecs = t->bt_nrecs; + m.flags = F_ISSET(t, SAVEMETA); + + memmove(p, &m, sizeof(BTMETA)); + mpool_put(t->bt_mp, p, MPOOL_DIRTY); + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c new file mode 100644 index 0000000..1cb208b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c @@ -0,0 +1,221 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_conv.c 8.5 (Berkeley) 8/17/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include + +#include +#include "btree.h" + +static void mswap __P((PAGE *)); + +/* + * __BT_BPGIN, __BT_BPGOUT -- + * Convert host-specific number layout to/from the host-independent + * format stored on disk. + * + * Parameters: + * t: tree + * pg: page number + * h: page to convert + */ +void +__bt_pgin(t, pg, pp) + void *t; + pgno_t pg; + void *pp; +{ + PAGE *h; + indx_t i, top; + u_char flags; + char *p; + + if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) + return; + if (pg == P_META) { + mswap(pp); + return; + } + + h = pp; + M_32_SWAP(h->pgno); + M_32_SWAP(h->prevpg); + M_32_SWAP(h->nextpg); + M_32_SWAP(h->flags); + M_16_SWAP(h->lower); + M_16_SWAP(h->upper); + + top = NEXTINDEX(h); + if ((h->flags & P_TYPE) == P_BINTERNAL) + for (i = 0; i < top; i++) { + M_16_SWAP(h->linp[i]); + p = (char *)GETBINTERNAL(h, i); + P_32_SWAP(p); + p += sizeof(u_int32_t); + P_32_SWAP(p); + p += sizeof(pgno_t); + if (*(u_char *)p & P_BIGKEY) { + p += sizeof(u_char); + P_32_SWAP(p); + p += sizeof(pgno_t); + P_32_SWAP(p); + } + } + else if ((h->flags & P_TYPE) == P_BLEAF) + for (i = 0; i < top; i++) { + M_16_SWAP(h->linp[i]); + p = (char *)GETBLEAF(h, i); + P_32_SWAP(p); + p += sizeof(u_int32_t); + P_32_SWAP(p); + p += sizeof(u_int32_t); + flags = *(u_char *)p; + if (flags & (P_BIGKEY | P_BIGDATA)) { + p += sizeof(u_char); + if (flags & P_BIGKEY) { + P_32_SWAP(p); + p += sizeof(pgno_t); + P_32_SWAP(p); + } + if (flags & P_BIGDATA) { + p += sizeof(u_int32_t); + P_32_SWAP(p); + p += sizeof(pgno_t); + P_32_SWAP(p); + } + } + } +} + +void +__bt_pgout(t, pg, pp) + void *t; + pgno_t pg; + void *pp; +{ + PAGE *h; + indx_t i, top; + u_char flags; + char *p; + + if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) + return; + if (pg == P_META) { + mswap(pp); + return; + } + + h = pp; + top = NEXTINDEX(h); + if ((h->flags & P_TYPE) == P_BINTERNAL) + for (i = 0; i < top; i++) { + p = (char *)GETBINTERNAL(h, i); + P_32_SWAP(p); + p += sizeof(u_int32_t); + P_32_SWAP(p); + p += sizeof(pgno_t); + if (*(u_char *)p & P_BIGKEY) { + p += sizeof(u_char); + P_32_SWAP(p); + p += sizeof(pgno_t); + P_32_SWAP(p); + } + M_16_SWAP(h->linp[i]); + } + else if ((h->flags & P_TYPE) == P_BLEAF) + for (i = 0; i < top; i++) { + p = (char *)GETBLEAF(h, i); + P_32_SWAP(p); + p += sizeof(u_int32_t); + P_32_SWAP(p); + p += sizeof(u_int32_t); + flags = *(u_char *)p; + if (flags & (P_BIGKEY | P_BIGDATA)) { + p += sizeof(u_char); + if (flags & P_BIGKEY) { + P_32_SWAP(p); + p += sizeof(pgno_t); + P_32_SWAP(p); + } + if (flags & P_BIGDATA) { + p += sizeof(u_int32_t); + P_32_SWAP(p); + p += sizeof(pgno_t); + P_32_SWAP(p); + } + } + M_16_SWAP(h->linp[i]); + } + + M_32_SWAP(h->pgno); + M_32_SWAP(h->prevpg); + M_32_SWAP(h->nextpg); + M_32_SWAP(h->flags); + M_16_SWAP(h->lower); + M_16_SWAP(h->upper); +} + +/* + * MSWAP -- Actually swap the bytes on the meta page. + * + * Parameters: + * p: page to convert + */ +static void +mswap(pg) + PAGE *pg; +{ + char *p; + + p = (char *)pg; + P_32_SWAP(p); /* magic */ + p += sizeof(u_int32_t); + P_32_SWAP(p); /* version */ + p += sizeof(u_int32_t); + P_32_SWAP(p); /* psize */ + p += sizeof(u_int32_t); + P_32_SWAP(p); /* free */ + p += sizeof(u_int32_t); + P_32_SWAP(p); /* nrecs */ + p += sizeof(u_int32_t); + P_32_SWAP(p); /* flags */ + p += sizeof(u_int32_t); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c new file mode 100644 index 0000000..3aefbe7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c @@ -0,0 +1,329 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_debug.c 8.5 (Berkeley) 8/17/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "btree.h" + +#ifdef DEBUG +/* + * BT_DUMP -- Dump the tree + * + * Parameters: + * dbp: pointer to the DB + */ +void +__bt_dump(dbp) + DB *dbp; +{ + BTREE *t; + PAGE *h; + pgno_t i; + char *sep; + + t = dbp->internal; + (void)fprintf(stderr, "%s: pgsz %d", + F_ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize); + if (F_ISSET(t, R_RECNO)) + (void)fprintf(stderr, " keys %lu", t->bt_nrecs); +#undef X +#define X(flag, name) \ + if (F_ISSET(t, flag)) { \ + (void)fprintf(stderr, "%s%s", sep, name); \ + sep = ", "; \ + } + if (t->flags != 0) { + sep = " flags ("; + X(R_FIXLEN, "FIXLEN"); + X(B_INMEM, "INMEM"); + X(B_NODUPS, "NODUPS"); + X(B_RDONLY, "RDONLY"); + X(R_RECNO, "RECNO"); + X(B_METADIRTY,"METADIRTY"); + (void)fprintf(stderr, ")\n"); + } +#undef X + + for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { + __bt_dpage(h); + (void)mpool_put(t->bt_mp, h, 0); + } +} + +/* + * BT_DMPAGE -- Dump the meta page + * + * Parameters: + * h: pointer to the PAGE + */ +void +__bt_dmpage(h) + PAGE *h; +{ + BTMETA *m; + char *sep; + + m = (BTMETA *)h; + (void)fprintf(stderr, "magic %lx\n", m->magic); + (void)fprintf(stderr, "version %lu\n", m->version); + (void)fprintf(stderr, "psize %lu\n", m->psize); + (void)fprintf(stderr, "free %lu\n", m->free); + (void)fprintf(stderr, "nrecs %lu\n", m->nrecs); + (void)fprintf(stderr, "flags %lu", m->flags); +#undef X +#define X(flag, name) \ + if (m->flags & flag) { \ + (void)fprintf(stderr, "%s%s", sep, name); \ + sep = ", "; \ + } + if (m->flags) { + sep = " ("; + X(B_NODUPS, "NODUPS"); + X(R_RECNO, "RECNO"); + (void)fprintf(stderr, ")"); + } +} + +/* + * BT_DNPAGE -- Dump the page + * + * Parameters: + * n: page number to dump. + */ +void +__bt_dnpage(dbp, pgno) + DB *dbp; + pgno_t pgno; +{ + BTREE *t; + PAGE *h; + + t = dbp->internal; + if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) { + __bt_dpage(h); + (void)mpool_put(t->bt_mp, h, 0); + } +} + +/* + * BT_DPAGE -- Dump the page + * + * Parameters: + * h: pointer to the PAGE + */ +void +__bt_dpage(h) + PAGE *h; +{ + BINTERNAL *bi; + BLEAF *bl; + RINTERNAL *ri; + RLEAF *rl; + indx_t cur, top; + char *sep; + + (void)fprintf(stderr, " page %d: (", h->pgno); +#undef X +#define X(flag, name) \ + if (h->flags & flag) { \ + (void)fprintf(stderr, "%s%s", sep, name); \ + sep = ", "; \ + } + sep = ""; + X(P_BINTERNAL, "BINTERNAL") /* types */ + X(P_BLEAF, "BLEAF") + X(P_RINTERNAL, "RINTERNAL") /* types */ + X(P_RLEAF, "RLEAF") + X(P_OVERFLOW, "OVERFLOW") + X(P_PRESERVE, "PRESERVE"); + (void)fprintf(stderr, ")\n"); +#undef X + + (void)fprintf(stderr, "\tprev %2d next %2d", h->prevpg, h->nextpg); + if (h->flags & P_OVERFLOW) + return; + + top = NEXTINDEX(h); + (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n", + h->lower, h->upper, top); + for (cur = 0; cur < top; cur++) { + (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]); + switch (h->flags & P_TYPE) { + case P_BINTERNAL: + bi = GETBINTERNAL(h, cur); + (void)fprintf(stderr, + "size %03d pgno %03d", bi->ksize, bi->pgno); + if (bi->flags & P_BIGKEY) + (void)fprintf(stderr, " (indirect)"); + else if (bi->ksize) + (void)fprintf(stderr, + " {%.*s}", (int)bi->ksize, bi->bytes); + break; + case P_RINTERNAL: + ri = GETRINTERNAL(h, cur); + (void)fprintf(stderr, "entries %03d pgno %03d", + ri->nrecs, ri->pgno); + break; + case P_BLEAF: + bl = GETBLEAF(h, cur); + if (bl->flags & P_BIGKEY) + (void)fprintf(stderr, + "big key page %lu size %u/", + *(pgno_t *)bl->bytes, + *(u_int32_t *)(bl->bytes + sizeof(pgno_t))); + else if (bl->ksize) + (void)fprintf(stderr, "%s/", bl->bytes); + if (bl->flags & P_BIGDATA) + (void)fprintf(stderr, + "big data page %lu size %u", + *(pgno_t *)(bl->bytes + bl->ksize), + *(u_int32_t *)(bl->bytes + bl->ksize + + sizeof(pgno_t))); + else if (bl->dsize) + (void)fprintf(stderr, "%.*s", + (int)bl->dsize, bl->bytes + bl->ksize); + break; + case P_RLEAF: + rl = GETRLEAF(h, cur); + if (rl->flags & P_BIGDATA) + (void)fprintf(stderr, + "big data page %lu size %u", + *(pgno_t *)rl->bytes, + *(u_int32_t *)(rl->bytes + sizeof(pgno_t))); + else if (rl->dsize) + (void)fprintf(stderr, + "%.*s", (int)rl->dsize, rl->bytes); + break; + } + (void)fprintf(stderr, "\n"); + } +} +#endif + +#ifdef STATISTICS +/* + * BT_STAT -- Gather/print the tree statistics + * + * Parameters: + * dbp: pointer to the DB + */ +void +__bt_stat(dbp) + DB *dbp; +{ + extern u_long bt_cache_hit, bt_cache_miss, bt_pfxsaved, bt_rootsplit; + extern u_long bt_sortsplit, bt_split; + BTREE *t; + PAGE *h; + pgno_t i, pcont, pinternal, pleaf; + u_long ifree, lfree, nkeys; + int levels; + + t = dbp->internal; + pcont = pinternal = pleaf = 0; + nkeys = ifree = lfree = 0; + for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { + switch (h->flags & P_TYPE) { + case P_BINTERNAL: + case P_RINTERNAL: + ++pinternal; + ifree += h->upper - h->lower; + break; + case P_BLEAF: + case P_RLEAF: + ++pleaf; + lfree += h->upper - h->lower; + nkeys += NEXTINDEX(h); + break; + case P_OVERFLOW: + ++pcont; + break; + } + (void)mpool_put(t->bt_mp, h, 0); + } + + /* Count the levels of the tree. */ + for (i = P_ROOT, levels = 0 ;; ++levels) { + h = mpool_get(t->bt_mp, i, 0); + if (h->flags & (P_BLEAF|P_RLEAF)) { + if (levels == 0) + levels = 1; + (void)mpool_put(t->bt_mp, h, 0); + break; + } + i = F_ISSET(t, R_RECNO) ? + GETRINTERNAL(h, 0)->pgno : + GETBINTERNAL(h, 0)->pgno; + (void)mpool_put(t->bt_mp, h, 0); + } + + (void)fprintf(stderr, "%d level%s with %ld keys", + levels, levels == 1 ? "" : "s", nkeys); + if (F_ISSET(t, R_RECNO)) + (void)fprintf(stderr, " (%ld header count)", t->bt_nrecs); + (void)fprintf(stderr, + "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n", + pinternal + pleaf + pcont, pleaf, pinternal, pcont); + (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n", + bt_cache_hit, bt_cache_miss); + (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n", + bt_split, bt_rootsplit, bt_sortsplit); + pleaf *= t->bt_psize - BTDATAOFF; + if (pleaf) + (void)fprintf(stderr, + "%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n", + ((double)(pleaf - lfree) / pleaf) * 100, + pleaf - lfree, lfree); + pinternal *= t->bt_psize - BTDATAOFF; + if (pinternal) + (void)fprintf(stderr, + "%.0f%% internal fill (%ld bytes used, %ld bytes free\n", + ((double)(pinternal - ifree) / pinternal) * 100, + pinternal - ifree, ifree); + if (bt_pfxsaved) + (void)fprintf(stderr, "prefix checking removed %lu bytes.\n", + bt_pfxsaved); +} +#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c new file mode 100644 index 0000000..667bff5 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c @@ -0,0 +1,657 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_delete.c 8.13 (Berkeley) 7/28/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "btree.h" + +static int __bt_bdelete __P((BTREE *, const DBT *)); +static int __bt_curdel __P((BTREE *, const DBT *, PAGE *, u_int)); +static int __bt_pdelete __P((BTREE *, PAGE *)); +static int __bt_relink __P((BTREE *, PAGE *)); +static int __bt_stkacq __P((BTREE *, PAGE **, CURSOR *)); + +/* + * __bt_delete + * Delete the item(s) referenced by a key. + * + * Return RET_SPECIAL if the key is not found. + */ +int +__bt_delete(dbp, key, flags) + const DB *dbp; + const DBT *key; + u_int flags; +{ + BTREE *t; + CURSOR *c; + PAGE *h; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* Check for change to a read-only tree. */ + if (F_ISSET(t, B_RDONLY)) { + errno = EPERM; + return (RET_ERROR); + } + + switch (flags) { + case 0: + status = __bt_bdelete(t, key); + break; + case R_CURSOR: + /* + * If flags is R_CURSOR, delete the cursor. Must already + * have started a scan and not have already deleted it. + */ + c = &t->bt_cursor; + if (F_ISSET(c, CURS_INIT)) { + if (F_ISSET(c, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) + return (RET_SPECIAL); + if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) + return (RET_ERROR); + + /* + * If the page is about to be emptied, we'll need to + * delete it, which means we have to acquire a stack. + */ + if (NEXTINDEX(h) == 1) + if (__bt_stkacq(t, &h, &t->bt_cursor)) + return (RET_ERROR); + + status = __bt_dleaf(t, NULL, h, c->pg.index); + + if (NEXTINDEX(h) == 0 && status == RET_SUCCESS) { + if (__bt_pdelete(t, h)) + return (RET_ERROR); + } else + mpool_put(t->bt_mp, + h, status == RET_SUCCESS ? MPOOL_DIRTY : 0); + break; + } + /* FALLTHROUGH */ + default: + errno = EINVAL; + return (RET_ERROR); + } + if (status == RET_SUCCESS) + F_SET(t, B_MODIFIED); + return (status); +} + +/* + * __bt_stkacq -- + * Acquire a stack so we can delete a cursor entry. + * + * Parameters: + * t: tree + * hp: pointer to current, pinned PAGE pointer + * c: pointer to the cursor + * + * Returns: + * 0 on success, 1 on failure + */ +static int +__bt_stkacq(t, hp, c) + BTREE *t; + PAGE **hp; + CURSOR *c; +{ + BINTERNAL *bi; + EPG *e; + EPGNO *parent; + PAGE *h; + indx_t index = 0; + pgno_t pgno; + recno_t nextpg, prevpg; + int exact, level; + + /* + * Find the first occurrence of the key in the tree. Toss the + * currently locked page so we don't hit an already-locked page. + */ + h = *hp; + mpool_put(t->bt_mp, h, 0); + if ((e = __bt_search(t, &c->key, &exact)) == NULL) + return (1); + h = e->page; + + /* See if we got it in one shot. */ + if (h->pgno == c->pg.pgno) + goto ret; + + /* + * Move right, looking for the page. At each move we have to move + * up the stack until we don't have to move to the next page. If + * we have to change pages at an internal level, we have to fix the + * stack back up. + */ + while (h->pgno != c->pg.pgno) { + if ((nextpg = h->nextpg) == P_INVALID) + break; + mpool_put(t->bt_mp, h, 0); + + /* Move up the stack. */ + for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { + /* Get the parent page. */ + if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) + return (1); + + /* Move to the next index. */ + if (parent->index != NEXTINDEX(h) - 1) { + index = parent->index + 1; + BT_PUSH(t, h->pgno, index); + break; + } + mpool_put(t->bt_mp, h, 0); + } + + /* Restore the stack. */ + while (level--) { + /* Push the next level down onto the stack. */ + bi = GETBINTERNAL(h, index); + pgno = bi->pgno; + BT_PUSH(t, pgno, 0); + + /* Lose the currently pinned page. */ + mpool_put(t->bt_mp, h, 0); + + /* Get the next level down. */ + if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) + return (1); + index = 0; + } + mpool_put(t->bt_mp, h, 0); + if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL) + return (1); + } + + if (h->pgno == c->pg.pgno) + goto ret; + + /* Reacquire the original stack. */ + mpool_put(t->bt_mp, h, 0); + if ((e = __bt_search(t, &c->key, &exact)) == NULL) + return (1); + h = e->page; + + /* + * Move left, looking for the page. At each move we have to move + * up the stack until we don't have to change pages to move to the + * next page. If we have to change pages at an internal level, we + * have to fix the stack back up. + */ + while (h->pgno != c->pg.pgno) { + if ((prevpg = h->prevpg) == P_INVALID) + break; + mpool_put(t->bt_mp, h, 0); + + /* Move up the stack. */ + for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { + /* Get the parent page. */ + if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) + return (1); + + /* Move to the next index. */ + if (parent->index != 0) { + index = parent->index - 1; + BT_PUSH(t, h->pgno, index); + break; + } + mpool_put(t->bt_mp, h, 0); + } + + /* Restore the stack. */ + while (level--) { + /* Push the next level down onto the stack. */ + bi = GETBINTERNAL(h, index); + pgno = bi->pgno; + + /* Lose the currently pinned page. */ + mpool_put(t->bt_mp, h, 0); + + /* Get the next level down. */ + if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) + return (1); + + index = NEXTINDEX(h) - 1; + BT_PUSH(t, pgno, index); + } + mpool_put(t->bt_mp, h, 0); + if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL) + return (1); + } + + +ret: mpool_put(t->bt_mp, h, 0); + return ((*hp = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL); +} + +/* + * __bt_bdelete -- + * Delete all key/data pairs matching the specified key. + * + * Parameters: + * t: tree + * key: key to delete + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. + */ +static int +__bt_bdelete(t, key) + BTREE *t; + const DBT *key; +{ + EPG *e; + PAGE *h; + int deleted, exact, redo; + + deleted = 0; + + /* Find any matching record; __bt_search pins the page. */ +loop: if ((e = __bt_search(t, key, &exact)) == NULL) + return (deleted ? RET_SUCCESS : RET_ERROR); + if (!exact) { + mpool_put(t->bt_mp, e->page, 0); + return (deleted ? RET_SUCCESS : RET_SPECIAL); + } + + /* + * Delete forward, then delete backward, from the found key. If + * there are duplicates and we reach either side of the page, do + * the key search again, so that we get them all. + */ + redo = 0; + h = e->page; + do { + if (__bt_dleaf(t, key, h, e->index)) { + mpool_put(t->bt_mp, h, 0); + return (RET_ERROR); + } + if (F_ISSET(t, B_NODUPS)) { + if (NEXTINDEX(h) == 0) { + if (__bt_pdelete(t, h)) + return (RET_ERROR); + } else + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + return (RET_SUCCESS); + } + deleted = 1; + } while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0); + + /* Check for right-hand edge of the page. */ + if (e->index == NEXTINDEX(h)) + redo = 1; + + /* Delete from the key to the beginning of the page. */ + while (e->index-- > 0) { + if (__bt_cmp(t, key, e) != 0) + break; + if (__bt_dleaf(t, key, h, e->index) == RET_ERROR) { + mpool_put(t->bt_mp, h, 0); + return (RET_ERROR); + } + if (e->index == 0) + redo = 1; + } + + /* Check for an empty page. */ + if (NEXTINDEX(h) == 0) { + if (__bt_pdelete(t, h)) + return (RET_ERROR); + goto loop; + } + + /* Put the page. */ + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + + if (redo) + goto loop; + return (RET_SUCCESS); +} + +/* + * __bt_pdelete -- + * Delete a single page from the tree. + * + * Parameters: + * t: tree + * h: leaf page + * + * Returns: + * RET_SUCCESS, RET_ERROR. + * + * Side-effects: + * mpool_put's the page + */ +static int +__bt_pdelete(t, h) + BTREE *t; + PAGE *h; +{ + BINTERNAL *bi; + PAGE *pg; + EPGNO *parent; + indx_t cnt, index, *ip, offset; + u_int32_t nksize; + char *from; + + /* + * Walk the parent page stack -- a LIFO stack of the pages that were + * traversed when we searched for the page where the delete occurred. + * Each stack entry is a page number and a page index offset. The + * offset is for the page traversed on the search. We've just deleted + * a page, so we have to delete the key from the parent page. + * + * If the delete from the parent page makes it empty, this process may + * continue all the way up the tree. We stop if we reach the root page + * (which is never deleted, it's just not worth the effort) or if the + * delete does not empty the page. + */ + while ((parent = BT_POP(t)) != NULL) { + /* Get the parent page. */ + if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) + return (RET_ERROR); + + index = parent->index; + bi = GETBINTERNAL(pg, index); + + /* Free any overflow pages. */ + if (bi->flags & P_BIGKEY && + __ovfl_delete(t, bi->bytes) == RET_ERROR) { + mpool_put(t->bt_mp, pg, 0); + return (RET_ERROR); + } + + /* + * Free the parent if it has only the one key and it's not the + * root page. If it's the rootpage, turn it back into an empty + * leaf page. + */ + if (NEXTINDEX(pg) == 1) + if (pg->pgno == P_ROOT) { + pg->lower = BTDATAOFF; + pg->upper = t->bt_psize; + pg->flags = P_BLEAF; + } else { + if (__bt_relink(t, pg) || __bt_free(t, pg)) + return (RET_ERROR); + continue; + } + else { + /* Pack remaining key items at the end of the page. */ + nksize = NBINTERNAL(bi->ksize); + from = (char *)pg + pg->upper; + memmove(from + nksize, from, (char *)bi - from); + pg->upper += nksize; + + /* Adjust indices' offsets, shift the indices down. */ + offset = pg->linp[index]; + for (cnt = index, ip = &pg->linp[0]; cnt--; ++ip) + if (ip[0] < offset) + ip[0] += nksize; + for (cnt = NEXTINDEX(pg) - index; --cnt; ++ip) + ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1]; + pg->lower -= sizeof(indx_t); + } + + mpool_put(t->bt_mp, pg, MPOOL_DIRTY); + break; + } + + /* Free the leaf page, as long as it wasn't the root. */ + if (h->pgno == P_ROOT) { + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + return (RET_SUCCESS); + } + return (__bt_relink(t, h) || __bt_free(t, h)); +} + +/* + * __bt_dleaf -- + * Delete a single record from a leaf page. + * + * Parameters: + * t: tree + * key: referenced key + * h: page + * index: index on page to delete + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +int +__bt_dleaf(t, key, h, index) + BTREE *t; + const DBT *key; + PAGE *h; + u_int index; +{ + BLEAF *bl; + indx_t cnt, *ip, offset; + u_int32_t nbytes; + void *to; + char *from; + + /* If this record is referenced by the cursor, delete the cursor. */ + if (F_ISSET(&t->bt_cursor, CURS_INIT) && + !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && + t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == index && + __bt_curdel(t, key, h, index)) + return (RET_ERROR); + + /* If the entry uses overflow pages, make them available for reuse. */ + to = bl = GETBLEAF(h, index); + if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) + return (RET_ERROR); + if (bl->flags & P_BIGDATA && + __ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR) + return (RET_ERROR); + + /* Pack the remaining key/data items at the end of the page. */ + nbytes = NBLEAF(bl); + from = (char *)h + h->upper; + memmove(from + nbytes, from, (char *)to - from); + h->upper += nbytes; + + /* Adjust the indices' offsets, shift the indices down. */ + offset = h->linp[index]; + for (cnt = index, ip = &h->linp[0]; cnt--; ++ip) + if (ip[0] < offset) + ip[0] += nbytes; + for (cnt = NEXTINDEX(h) - index; --cnt; ++ip) + ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; + h->lower -= sizeof(indx_t); + + /* If the cursor is on this page, adjust it as necessary. */ + if (F_ISSET(&t->bt_cursor, CURS_INIT) && + !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && + t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > index) + --t->bt_cursor.pg.index; + + return (RET_SUCCESS); +} + +/* + * __bt_curdel -- + * Delete the cursor. + * + * Parameters: + * t: tree + * key: referenced key (or NULL) + * h: page + * index: index on page to delete + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +static int +__bt_curdel(t, key, h, index) + BTREE *t; + const DBT *key; + PAGE *h; + u_int index; +{ + CURSOR *c; + EPG e; + PAGE *pg; + int curcopy, status; + + /* + * If there are duplicates, move forward or backward to one. + * Otherwise, copy the key into the cursor area. + */ + c = &t->bt_cursor; + F_CLR(c, CURS_AFTER | CURS_BEFORE | CURS_ACQUIRE); + + curcopy = 0; + if (!F_ISSET(t, B_NODUPS)) { + /* + * We're going to have to do comparisons. If we weren't + * provided a copy of the key, i.e. the user is deleting + * the current cursor position, get one. + */ + if (key == NULL) { + e.page = h; + e.index = index; + if ((status = __bt_ret(t, &e, + &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS) + return (status); + curcopy = 1; + key = &c->key; + } + /* Check previous key, if not at the beginning of the page. */ + if (index > 0) { + e.page = h; + e.index = index - 1; + if (__bt_cmp(t, key, &e) == 0) { + F_SET(c, CURS_BEFORE); + goto dup2; + } + } + /* Check next key, if not at the end of the page. */ + if (index < NEXTINDEX(h) - 1) { + e.page = h; + e.index = index + 1; + if (__bt_cmp(t, key, &e) == 0) { + F_SET(c, CURS_AFTER); + goto dup2; + } + } + /* Check previous key if at the beginning of the page. */ + if (index == 0 && h->prevpg != P_INVALID) { + if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) + return (RET_ERROR); + e.page = pg; + e.index = NEXTINDEX(pg) - 1; + if (__bt_cmp(t, key, &e) == 0) { + F_SET(c, CURS_BEFORE); + goto dup1; + } + mpool_put(t->bt_mp, pg, 0); + } + /* Check next key if at the end of the page. */ + if (index == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) { + if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) + return (RET_ERROR); + e.page = pg; + e.index = 0; + if (__bt_cmp(t, key, &e) == 0) { + F_SET(c, CURS_AFTER); +dup1: mpool_put(t->bt_mp, pg, 0); +dup2: c->pg.pgno = e.page->pgno; + c->pg.index = e.index; + return (RET_SUCCESS); + } + mpool_put(t->bt_mp, pg, 0); + } + } + e.page = h; + e.index = index; + if (curcopy || (status = + __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) { + F_SET(c, CURS_ACQUIRE); + return (RET_SUCCESS); + } + return (status); +} + +/* + * __bt_relink -- + * Link around a deleted page. + * + * Parameters: + * t: tree + * h: page to be deleted + */ +static int +__bt_relink(t, h) + BTREE *t; + PAGE *h; +{ + PAGE *pg; + + if (h->nextpg != P_INVALID) { + if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) + return (RET_ERROR); + pg->prevpg = h->prevpg; + mpool_put(t->bt_mp, pg, MPOOL_DIRTY); + } + if (h->prevpg != P_INVALID) { + if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) + return (RET_ERROR); + pg->nextpg = h->nextpg; + mpool_put(t->bt_mp, pg, MPOOL_DIRTY); + } + return (0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c new file mode 100644 index 0000000..74824c7 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_get.c 8.6 (Berkeley) 7/20/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "btree.h" + +/* + * __BT_GET -- Get a record from the btree. + * + * Parameters: + * dbp: pointer to access method + * key: key to find + * data: data to return + * flag: currently unused + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. + */ +int +__bt_get(dbp, key, data, flags) + const DB *dbp; + const DBT *key; + DBT *data; + u_int flags; +{ + BTREE *t; + EPG *e; + int exact, status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* Get currently doesn't take any flags. */ + if (flags) { + errno = EINVAL; + return (RET_ERROR); + } + + if ((e = __bt_search(t, key, &exact)) == NULL) + return (RET_ERROR); + if (!exact) { + mpool_put(t->bt_mp, e->page, 0); + return (RET_SPECIAL); + } + + status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0); + + /* + * If the user is doing concurrent access, we copied the + * key/data, toss the page. + */ + if (F_ISSET(t, B_DB_LOCK)) + mpool_put(t->bt_mp, e->page, 0); + else + t->bt_pinned = e->page; + return (status); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c new file mode 100644 index 0000000..7269ef0 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c @@ -0,0 +1,412 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Implementation of btree access method for 4.4BSD. + * + * The design here was originally based on that of the btree access method + * used in the Postgres database system at UC Berkeley. This implementation + * is wholly independent of the Postgres code. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include "btree.h" + +#ifdef DEBUG +#undef MINPSIZE +#define MINPSIZE 128 +#endif + +static int byteorder __P((void)); +static int nroot __P((BTREE *)); + +#ifdef BTREE_POSIX +/* Default vmethods and vtable to work with POSIX fd's. */ +static ssize_t bt_read(void *fd, void *buf, size_t size) +{ +//printf("read: %p(%lx)\n", buf, size); + return read((int)(uintptr_t)fd, buf, size); +} + +static ssize_t bt_write(void *fd, const void *buf, size_t size) +{ +//printf("write: %p(%lx)\n", buf, size); + return write((int)(uintptr_t)fd, buf, size); +} + +static off_t bt_lseek(void *fd, off_t offset, int whence) +{ +//printf("lseek: %lx(%d)\n", offset, whence); + return lseek((int)(uintptr_t)fd, offset, whence); +} + +static int bt_fsync(void *fd) +{ + return fsync((int)(uintptr_t)fd); +} + +static FILEVTABLE bt_fd_fvtable = { + bt_read, + bt_write, + bt_lseek, + bt_fsync +}; +#endif + +/* + * __BT_OPEN -- Open a btree. + * + * Creates and fills a DB struct, and calls the routine that actually + * opens the btree. + * + * Parameters: + * fname: filename (NULL for in-memory trees) + * b: BTREEINFO pointer + * + * Returns: + * NULL on failure, pointer to DB on success. + * + */ +DB * +__bt_open(file, vtable, openinfo, dflags) + virt_fd_t file; + const FILEVTABLE *vtable; + int dflags; + const BTREEINFO *openinfo; +{ + BTMETA m; + BTREE *t; + BTREEINFO b; + DB *dbp; + pgno_t ncache; + ssize_t nr; + int machine_lorder; + + t = NULL; +#ifdef BTREE_POSIX + if (vtable == NULL) + vtable = &bt_fd_fvtable; +#endif + + /* + * Intention is to make sure all of the user's selections are okay + * here and then use them without checking. Can't be complete, since + * we don't know the right page size, lorder or flags until the backing + * file is opened. Also, the file's page size can cause the cachesize + * to change. + */ + machine_lorder = byteorder(); + if (openinfo) { + b = *openinfo; + + /* Flags: R_DUP. */ + if (b.flags & ~(R_DUP)) + goto einval; + + /* + * Page size must be indx_t aligned and >= MINPSIZE. Default + * page size is set farther on, based on the underlying file + * transfer size. + */ + if (b.psize && + (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 || + b.psize & (sizeof(indx_t) - 1))) + goto einval; + + /* Minimum number of keys per page; absolute minimum is 2. */ + if (b.minkeypage) { + if (b.minkeypage < 2) + goto einval; + } else + b.minkeypage = DEFMINKEYPAGE; + + /* If no comparison, use default comparison and prefix. */ + if (b.compare == NULL) { + b.compare = __bt_defcmp; + if (b.prefix == NULL) + b.prefix = __bt_defpfx; + } + + if (b.lorder == 0) + b.lorder = machine_lorder; + } else { + b.compare = __bt_defcmp; + b.cachesize = 0; + b.flags = 0; + b.lorder = machine_lorder; + b.minkeypage = DEFMINKEYPAGE; + b.prefix = __bt_defpfx; + b.psize = 0; + } + + /* Check for the ubiquitous PDP-11. */ + if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN) + goto einval; + + /* Allocate and initialize DB and BTREE structures. */ + if ((t = (BTREE *)malloc(sizeof(BTREE))) == NULL) + goto err; + memset(t, 0, sizeof(BTREE)); + t->bt_fd = file; + t->bt_lorder = b.lorder; + t->bt_order = NOT; + t->bt_cmp = b.compare; + t->bt_pfx = b.prefix; + t->bt_rfd = -1; + + if ((t->bt_dbp = dbp = (DB *)malloc(sizeof(DB))) == NULL) + goto err; + memset(t->bt_dbp, 0, sizeof(DB)); + if (t->bt_lorder != machine_lorder) + F_SET(t, B_NEEDSWAP); + + dbp->type = DB_BTREE; + dbp->internal = t; + dbp->close = __bt_close; + dbp->del = __bt_delete; + dbp->fd = __bt_fd; + dbp->get = __bt_get; + dbp->put = __bt_put; + dbp->seq = __bt_seq; + dbp->sync = __bt_sync; + + if ((nr = vtable->read(t->bt_fd, &m, sizeof(BTMETA))) < 0) + goto err; + if (nr != 0) { + if (nr != sizeof(BTMETA)) + goto eftype; + + /* + * Read in the meta-data. This can change the notion of what + * the lorder, page size and flags are, and, when the page size + * changes, the cachesize value can change too. If the user + * specified the wrong byte order for an existing database, we + * don't bother to return an error, we just clear the NEEDSWAP + * bit. + */ + if (m.magic == BTREEMAGIC) + F_CLR(t, B_NEEDSWAP); + else { + F_SET(t, B_NEEDSWAP); + M_32_SWAP(m.magic); + M_32_SWAP(m.version); + M_32_SWAP(m.psize); + M_32_SWAP(m.free); + M_32_SWAP(m.nrecs); + M_32_SWAP(m.flags); + } + if (m.magic != BTREEMAGIC || m.version != BTREEVERSION) + goto eftype; + if (m.psize < MINPSIZE || m.psize > MAX_PAGE_OFFSET + 1 || + m.psize & (sizeof(indx_t) - 1)) + goto eftype; + if (m.flags & ~SAVEMETA) + goto eftype; + b.psize = m.psize; + F_SET(t, m.flags); + t->bt_free = m.free; + t->bt_nrecs = m.nrecs; + } else { + /* + * Set the page size to the best value for I/O to this file. + * Don't overflow the page offset type. + */ + if (b.psize == 0) { + b.psize = DEFPSIZE; + } + + /* Set flag if duplicates permitted. */ + if (!(b.flags & R_DUP)) + F_SET(t, B_NODUPS); + + t->bt_free = P_INVALID; + t->bt_nrecs = 0; + F_SET(t, B_METADIRTY); + } + + t->bt_psize = b.psize; + + /* Set the cache size; must be a multiple of the page size. */ + if (b.cachesize && b.cachesize & (b.psize - 1)) + b.cachesize += (~b.cachesize & (b.psize - 1)) + 1; + if (b.cachesize < b.psize * MINCACHE) + b.cachesize = b.psize * MINCACHE; + + /* Calculate number of pages to cache. */ + ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; + + /* + * The btree data structure requires that at least two keys can fit on + * a page, but other than that there's no fixed requirement. The user + * specified a minimum number per page, and we translated that into the + * number of bytes a key/data pair can use before being placed on an + * overflow page. This calculation includes the page header, the size + * of the index referencing the leaf item and the size of the leaf item + * structure. Also, don't let the user specify a minkeypage such that + * a key/data pair won't fit even if both key and data are on overflow + * pages. + */ + t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage - + (sizeof(indx_t) + NBLEAFDBT(0, 0)); + if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t)) + t->bt_ovflsize = + NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t); + + /* Initialize the buffer pool. */ + if ((t->bt_mp = + mpool_open(NULL, t->bt_fd, vtable, t->bt_psize, ncache)) == NULL) + goto err; + if (!F_ISSET(t, B_INMEM)) + mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t); + + /* Create a root page if new tree. */ + if (nroot(t) == RET_ERROR) + goto err; + + /* Global flags. */ + if (dflags & DB_LOCK) + F_SET(t, B_DB_LOCK); + if (dflags & DB_SHMEM) + F_SET(t, B_DB_SHMEM); + if (dflags & DB_TXN) + F_SET(t, B_DB_TXN); + + return (dbp); + +einval: errno = EINVAL; + goto err; + +eftype: errno = EFTYPE; + goto err; + +err: if (t) { + if (t->bt_dbp) + free(t->bt_dbp); + free(t); + } + return (NULL); +} + +/* + * NROOT -- Create the root of a new tree. + * + * Parameters: + * t: tree + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +static int +nroot(t) + BTREE *t; +{ + PAGE *meta, *root; + pgno_t npg; + + if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { + mpool_put(t->bt_mp, meta, 0); + return (RET_SUCCESS); + } + if (errno != EINVAL) /* It's OK to not exist. */ + return (RET_ERROR); + errno = 0; + + if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) + return (RET_ERROR); + + if ((root = mpool_new(t->bt_mp, &npg)) == NULL) + return (RET_ERROR); + + if (npg != P_ROOT) + return (RET_ERROR); + root->pgno = npg; + root->prevpg = root->nextpg = P_INVALID; + root->lower = BTDATAOFF; + root->upper = t->bt_psize; + root->flags = P_BLEAF; + memset(meta, 0, t->bt_psize); + mpool_put(t->bt_mp, meta, MPOOL_DIRTY); + mpool_put(t->bt_mp, root, MPOOL_DIRTY); + return (RET_SUCCESS); +} + +static int +byteorder() +{ + u_int32_t x; + u_char *p; + + x = 0x01020304; + p = (u_char *)&x; + switch (*p) { + case 1: + return (BIG_ENDIAN); + case 4: + return (LITTLE_ENDIAN); + default: + return (0); + } +} + +int +__bt_fd(dbp) + const DB *dbp; +{ + BTREE *t; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + return -1; +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c new file mode 100644 index 0000000..b1bd343 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c @@ -0,0 +1,228 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "btree.h" + +/* + * Big key/data code. + * + * Big key and data entries are stored on linked lists of pages. The initial + * reference is byte string stored with the key or data and is the page number + * and size. The actual record is stored in a chain of pages linked by the + * nextpg field of the PAGE header. + * + * The first page of the chain has a special property. If the record is used + * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set + * in the header. + * + * XXX + * A single DBT is written to each chain, so a lot of space on the last page + * is wasted. This is a fairly major bug for some data sets. + */ + +/* + * __OVFL_GET -- Get an overflow key/data item. + * + * Parameters: + * t: tree + * p: pointer to { pgno_t, u_int32_t } + * buf: storage address + * bufsz: storage size + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__ovfl_get(t, p, ssz, buf, bufsz) + BTREE *t; + void *p; + size_t *ssz; + void **buf; + size_t *bufsz; +{ + PAGE *h; + pgno_t pg; + size_t nb, plen; + u_int32_t sz; + + memcpy(&pg, p, sizeof(pgno_t)); + memcpy(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); + *ssz = sz; + +#ifdef DEBUG + if (pg == P_INVALID || sz == 0) + abort(); +#endif + /* Make the buffer bigger as necessary. */ + if (*bufsz < sz) { + *buf = (char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz)); + if (*buf == NULL) + return (RET_ERROR); + *bufsz = sz; + } + + /* + * Step through the linked list of pages, copying the data on each one + * into the buffer. Never copy more than the data's length. + */ + plen = t->bt_psize - BTDATAOFF; + for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) { + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + + nb = MIN(sz, plen); + memmove(p, (char *)h + BTDATAOFF, nb); + mpool_put(t->bt_mp, h, 0); + + if ((sz -= nb) == 0) + break; + } + return (RET_SUCCESS); +} + +/* + * __OVFL_PUT -- Store an overflow key/data item. + * + * Parameters: + * t: tree + * data: DBT to store + * pgno: storage page number + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__ovfl_put(t, dbt, pg) + BTREE *t; + const DBT *dbt; + pgno_t *pg; +{ + PAGE *h, *last; + void *p; + pgno_t npg; + size_t nb, plen; + u_int32_t sz; + + /* + * Allocate pages and copy the key/data record into them. Store the + * number of the first page in the chain. + */ + plen = t->bt_psize - BTDATAOFF; + for (last = NULL, p = dbt->data, sz = dbt->size;; + p = (char *)p + plen, last = h) { + if ((h = __bt_new(t, &npg)) == NULL) + return (RET_ERROR); + + h->pgno = npg; + h->nextpg = h->prevpg = P_INVALID; + h->flags = P_OVERFLOW; + h->lower = h->upper = 0; + + nb = MIN(sz, plen); + memmove((char *)h + BTDATAOFF, p, nb); + + if (last) { + last->nextpg = h->pgno; + mpool_put(t->bt_mp, last, MPOOL_DIRTY); + } else + *pg = h->pgno; + + if ((sz -= nb) == 0) { + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + break; + } + } + return (RET_SUCCESS); +} + +/* + * __OVFL_DELETE -- Delete an overflow chain. + * + * Parameters: + * t: tree + * p: pointer to { pgno_t, u_int32_t } + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__ovfl_delete(t, p) + BTREE *t; + void *p; +{ + PAGE *h; + pgno_t pg; + size_t plen; + u_int32_t sz; + + memmove(&pg, p, sizeof(pgno_t)); + memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); + +#ifdef DEBUG + if (pg == P_INVALID || sz == 0) + abort(); +#endif + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + + /* Don't delete chains used by internal pages. */ + if (h->flags & P_PRESERVE) { + mpool_put(t->bt_mp, h, 0); + return (RET_SUCCESS); + } + + /* Step through the chain, calling the free routine for each page. */ + for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) { + pg = h->nextpg; + __bt_free(t, h); + if (sz <= plen) + break; + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + } + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c new file mode 100644 index 0000000..ce9cbf1 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c @@ -0,0 +1,100 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include + +#include +#include "btree.h" + +/* + * __bt_free -- + * Put a page on the freelist. + * + * Parameters: + * t: tree + * h: page to free + * + * Returns: + * RET_ERROR, RET_SUCCESS + * + * Side-effect: + * mpool_put's the page. + */ +int +__bt_free(t, h) + BTREE *t; + PAGE *h; +{ + /* Insert the page at the head of the free list. */ + h->prevpg = P_INVALID; + h->nextpg = t->bt_free; + t->bt_free = h->pgno; + F_SET(t, B_METADIRTY); + + /* Make sure the page gets written back. */ + return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); +} + +/* + * __bt_new -- + * Get a new page, preferably from the freelist. + * + * Parameters: + * t: tree + * npg: storage for page number. + * + * Returns: + * Pointer to a page, NULL on error. + */ +PAGE * +__bt_new(t, npg) + BTREE *t; + pgno_t *npg; +{ + PAGE *h; + + if (t->bt_free != P_INVALID && + (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { + *npg = t->bt_free; + t->bt_free = h->nextpg; + F_SET(t, B_METADIRTY); + return (h); + } + return (mpool_new(t->bt_mp, npg)); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c new file mode 100644 index 0000000..4f3bd1f --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c @@ -0,0 +1,321 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_put.c 8.8 (Berkeley) 7/26/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +#include +#include "btree.h" + +static EPG *bt_fast __P((BTREE *, const DBT *, const DBT *, int *)); + +/* + * __BT_PUT -- Add a btree item to the tree. + * + * Parameters: + * dbp: pointer to access method + * key: key + * data: data + * flag: R_NOOVERWRITE + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the + * tree and R_NOOVERWRITE specified. + */ +int +__bt_put(dbp, key, data, flags) + const DB *dbp; + DBT *key; + const DBT *data; + u_int flags; +{ + BTREE *t; + DBT tkey, tdata; + EPG *e = NULL; + PAGE *h; + indx_t index, nxtindex; + pgno_t pg; + u_int32_t nbytes; + int dflags, exact, status; + char *dest, db[NOVFLSIZE], kb[NOVFLSIZE]; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* Check for change to a read-only tree. */ + if (F_ISSET(t, B_RDONLY)) { + errno = EPERM; + return (RET_ERROR); + } + + switch (flags) { + case 0: + case R_NOOVERWRITE: + break; + case R_CURSOR: + /* + * If flags is R_CURSOR, put the cursor. Must already + * have started a scan and not have already deleted it. + */ + if (F_ISSET(&t->bt_cursor, CURS_INIT) && + !F_ISSET(&t->bt_cursor, + CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) + break; + /* FALLTHROUGH */ + default: + errno = EINVAL; + return (RET_ERROR); + } + + /* + * If the key/data pair won't fit on a page, store it on overflow + * pages. Only put the key on the overflow page if the pair are + * still too big after moving the data to an overflow page. + * + * XXX + * If the insert fails later on, the overflow pages aren't recovered. + */ + dflags = 0; + if (key->size + data->size > t->bt_ovflsize) { + if (key->size > t->bt_ovflsize) { +storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR) + return (RET_ERROR); + tkey.data = kb; + tkey.size = NOVFLSIZE; + memmove(kb, &pg, sizeof(pgno_t)); + memmove(kb + sizeof(pgno_t), + &key->size, sizeof(u_int32_t)); + dflags |= P_BIGKEY; + key = &tkey; + } + if (key->size + data->size > t->bt_ovflsize) { + if (__ovfl_put(t, data, &pg) == RET_ERROR) + return (RET_ERROR); + tdata.data = db; + tdata.size = NOVFLSIZE; + memmove(db, &pg, sizeof(pgno_t)); + memmove(db + sizeof(pgno_t), + &data->size, sizeof(u_int32_t)); + dflags |= P_BIGDATA; + data = &tdata; + } + if (key->size + data->size > t->bt_ovflsize) + goto storekey; + } + + /* Replace the cursor. */ + if (flags == R_CURSOR) { + if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL) + return (RET_ERROR); + index = t->bt_cursor.pg.index; + goto delete; + } + + /* + * Find the key to delete, or, the location at which to insert. + * Bt_fast and __bt_search both pin the returned page. + */ + if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL) + if ((e = __bt_search(t, key, &exact)) == NULL) + return (RET_ERROR); + h = e->page; + index = e->index; + + /* + * Add the key/data pair to the tree. If an identical key is already + * in the tree, and R_NOOVERWRITE is set, an error is returned. If + * R_NOOVERWRITE is not set, the key is either added (if duplicates are + * permitted) or an error is returned. + */ + switch (flags) { + case R_NOOVERWRITE: + if (!exact) + break; + mpool_put(t->bt_mp, h, 0); + return (RET_SPECIAL); + default: + if (!exact || !F_ISSET(t, B_NODUPS)) + break; + /* + * !!! + * Note, the delete may empty the page, so we need to put a + * new entry into the page immediately. + */ +delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) { + mpool_put(t->bt_mp, h, 0); + return (RET_ERROR); + } + break; + } + + /* + * If not enough room, or the user has put a ceiling on the number of + * keys permitted in the page, split the page. The split code will + * insert the key and data and unpin the current page. If inserting + * into the offset array, shift the pointers up. + */ + nbytes = NBLEAFDBT(key->size, data->size); + if (h->upper - h->lower < nbytes + sizeof(indx_t)) { + if ((status = __bt_split(t, h, key, + data, dflags, nbytes, index)) != RET_SUCCESS) + return (status); + goto success; + } + + if (index < (nxtindex = NEXTINDEX(h))) + memmove(h->linp + index + 1, h->linp + index, + (nxtindex - index) * sizeof(indx_t)); + h->lower += sizeof(indx_t); + + h->linp[index] = h->upper -= nbytes; + dest = (char *)h + h->upper; + WR_BLEAF(dest, key, data, dflags); + + /* If the cursor is on this page, adjust it as necessary. */ + if (F_ISSET(&t->bt_cursor, CURS_INIT) && + !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && + t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= index) + ++t->bt_cursor.pg.index; + + if (t->bt_order == NOT) { + if (h->nextpg == P_INVALID) { + if (index == NEXTINDEX(h) - 1) { + t->bt_order = FORWARD; + t->bt_last.index = index; + t->bt_last.pgno = h->pgno; + } + } else if (h->prevpg == P_INVALID) { + if (index == 0) { + t->bt_order = BACK; + t->bt_last.index = 0; + t->bt_last.pgno = h->pgno; + } + } + } + + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + +success: + if (flags == R_SETCURSOR) + __bt_setcur(t, e->page->pgno, e->index); + + F_SET(t, B_MODIFIED); + return (RET_SUCCESS); +} + +#ifdef STATISTICS +u_long bt_cache_hit, bt_cache_miss; +#endif + +/* + * BT_FAST -- Do a quick check for sorted data. + * + * Parameters: + * t: tree + * key: key to insert + * + * Returns: + * EPG for new record or NULL if not found. + */ +static EPG * +bt_fast(t, key, data, exactp) + BTREE *t; + const DBT *key, *data; + int *exactp; +{ + PAGE *h; + u_int32_t nbytes; + int cmp; + + if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) { + t->bt_order = NOT; + return (NULL); + } + t->bt_cur.page = h; + t->bt_cur.index = t->bt_last.index; + + /* + * If won't fit in this page or have too many keys in this page, + * have to search to get split stack. + */ + nbytes = NBLEAFDBT(key->size, data->size); + if (h->upper - h->lower < nbytes + sizeof(indx_t)) + goto miss; + + if (t->bt_order == FORWARD) { + if (t->bt_cur.page->nextpg != P_INVALID) + goto miss; + if (t->bt_cur.index != NEXTINDEX(h) - 1) + goto miss; + if ((cmp = __bt_cmp(t, key, &t->bt_cur)) < 0) + goto miss; + t->bt_last.index = cmp ? ++t->bt_cur.index : t->bt_cur.index; + } else { + if (t->bt_cur.page->prevpg != P_INVALID) + goto miss; + if (t->bt_cur.index != 0) + goto miss; + if ((cmp = __bt_cmp(t, key, &t->bt_cur)) > 0) + goto miss; + t->bt_last.index = 0; + } + *exactp = cmp == 0; +#ifdef STATISTICS + ++bt_cache_hit; +#endif + return (&t->bt_cur); + +miss: +#ifdef STATISTICS + ++bt_cache_miss; +#endif + t->bt_order = NOT; + mpool_put(t->bt_mp, h, 0); + return (NULL); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c new file mode 100644 index 0000000..485afcb --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c @@ -0,0 +1,213 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_search.c 8.8 (Berkeley) 7/31/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include + +#include +#include "btree.h" + +static int __bt_snext __P((BTREE *, PAGE *, const DBT *, int *)); +static int __bt_sprev __P((BTREE *, PAGE *, const DBT *, int *)); + +/* + * __bt_search -- + * Search a btree for a key. + * + * Parameters: + * t: tree to search + * key: key to find + * exactp: pointer to exact match flag + * + * Returns: + * The EPG for matching record, if any, or the EPG for the location + * of the key, if it were inserted into the tree, is entered into + * the bt_cur field of the tree. A pointer to the field is returned. + */ +EPG * +__bt_search(t, key, exactp) + BTREE *t; + const DBT *key; + int *exactp; +{ + PAGE *h; + indx_t base, index, lim; + pgno_t pg; + int cmp; + + BT_CLR(t); + for (pg = P_ROOT;;) { + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (NULL); + + /* Do a binary search on the current page. */ + t->bt_cur.page = h; + for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { + t->bt_cur.index = index = base + (lim >> 1); + if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) { + if (h->flags & P_BLEAF) { + *exactp = 1; + return (&t->bt_cur); + } + goto next; + } + if (cmp > 0) { + base = index + 1; + --lim; + } + } + + /* + * If it's a leaf page, we're almost done. If no duplicates + * are allowed, or we have an exact match, we're done. Else, + * it's possible that there were matching keys on this page, + * which later deleted, and we're on a page with no matches + * while there are matches on other pages. If at the start or + * end of a page, check the adjacent page. + */ + if (h->flags & P_BLEAF) { + if (!F_ISSET(t, B_NODUPS)) { + if (base == 0 && + h->prevpg != P_INVALID && + __bt_sprev(t, h, key, exactp)) + return (&t->bt_cur); + if (base == NEXTINDEX(h) && + h->nextpg != P_INVALID && + __bt_snext(t, h, key, exactp)) + return (&t->bt_cur); + } + *exactp = 0; + t->bt_cur.index = base; + return (&t->bt_cur); + } + + /* + * No match found. Base is the smallest index greater than + * key and may be zero or a last + 1 index. If it's non-zero, + * decrement by one, and record the internal page which should + * be a parent page for the key. If a split later occurs, the + * inserted page will be to the right of the saved page. + */ + index = base ? base - 1 : base; + +next: BT_PUSH(t, h->pgno, index); + pg = GETBINTERNAL(h, index)->pgno; + mpool_put(t->bt_mp, h, 0); + } +} + +/* + * __bt_snext -- + * Check for an exact match after the key. + * + * Parameters: + * t: tree + * h: current page + * key: key + * exactp: pointer to exact match flag + * + * Returns: + * If an exact match found. + */ +static int +__bt_snext(t, h, key, exactp) + BTREE *t; + PAGE *h; + const DBT *key; + int *exactp; +{ + EPG e; + + /* + * Get the next page. The key is either an exact + * match, or not as good as the one we already have. + */ + if ((e.page = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) + return (0); + e.index = 0; + if (__bt_cmp(t, key, &e) == 0) { + mpool_put(t->bt_mp, h, 0); + t->bt_cur = e; + *exactp = 1; + return (1); + } + mpool_put(t->bt_mp, e.page, 0); + return (0); +} + +/* + * __bt_sprev -- + * Check for an exact match before the key. + * + * Parameters: + * t: tree + * h: current page + * key: key + * exactp: pointer to exact match flag + * + * Returns: + * If an exact match found. + */ +static int +__bt_sprev(t, h, key, exactp) + BTREE *t; + PAGE *h; + const DBT *key; + int *exactp; +{ + EPG e; + + /* + * Get the previous page. The key is either an exact + * match, or not as good as the one we already have. + */ + if ((e.page = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) + return (0); + e.index = NEXTINDEX(e.page) - 1; + if (__bt_cmp(t, key, &e) == 0) { + mpool_put(t->bt_mp, h, 0); + t->bt_cur = e; + *exactp = 1; + return (1); + } + mpool_put(t->bt_mp, e.page, 0); + return (0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c new file mode 100644 index 0000000..d5a700d --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c @@ -0,0 +1,460 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_seq.c 8.7 (Berkeley) 7/20/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +#include +#include "btree.h" + +static int __bt_first __P((BTREE *, const DBT *, EPG *, int *)); +static int __bt_seqadv __P((BTREE *, EPG *, int)); +static int __bt_seqset __P((BTREE *, EPG *, DBT *, int)); + +/* + * Sequential scan support. + * + * The tree can be scanned sequentially, starting from either end of the + * tree or from any specific key. A scan request before any scanning is + * done is initialized as starting from the least node. + */ + +/* + * __bt_seq -- + * Btree sequential scan interface. + * + * Parameters: + * dbp: pointer to access method + * key: key for positioning and return value + * data: data return value + * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. + * + * Returns: + * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. + */ +int +__bt_seq(dbp, key, data, flags) + const DB *dbp; + DBT *key, *data; + u_int flags; +{ + BTREE *t; + EPG e; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* + * If scan unitialized as yet, or starting at a specific record, set + * the scan to a specific key. Both __bt_seqset and __bt_seqadv pin + * the page the cursor references if they're successful. + */ + switch (flags) { + case R_NEXT: + case R_PREV: + if (F_ISSET(&t->bt_cursor, CURS_INIT)) { + status = __bt_seqadv(t, &e, flags); + break; + } + /* FALLTHROUGH */ + case R_FIRST: + case R_LAST: + case R_CURSOR: + status = __bt_seqset(t, &e, key, flags); + break; + default: + errno = EINVAL; + return (RET_ERROR); + } + + if (status == RET_SUCCESS) { + __bt_setcur(t, e.page->pgno, e.index); + + status = + __bt_ret(t, &e, key, &t->bt_rkey, data, &t->bt_rdata, 0); + + /* + * If the user is doing concurrent access, we copied the + * key/data, toss the page. + */ + if (F_ISSET(t, B_DB_LOCK)) + mpool_put(t->bt_mp, e.page, 0); + else + t->bt_pinned = e.page; + } + return (status); +} + +/* + * __bt_seqset -- + * Set the sequential scan to a specific key. + * + * Parameters: + * t: tree + * ep: storage for returned key + * key: key for initial scan position + * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV + * + * Side effects: + * Pins the page the cursor references. + * + * Returns: + * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. + */ +static int +__bt_seqset(t, ep, key, flags) + BTREE *t; + EPG *ep; + DBT *key; + int flags; +{ + PAGE *h; + pgno_t pg; + int exact; + + /* + * Find the first, last or specific key in the tree and point the + * cursor at it. The cursor may not be moved until a new key has + * been found. + */ + switch (flags) { + case R_CURSOR: /* Keyed scan. */ + /* + * Find the first instance of the key or the smallest key + * which is greater than or equal to the specified key. + */ + if (key->data == NULL || key->size == 0) { + errno = EINVAL; + return (RET_ERROR); + } + return (__bt_first(t, key, ep, &exact)); + case R_FIRST: /* First record. */ + case R_NEXT: + /* Walk down the left-hand side of the tree. */ + for (pg = P_ROOT;;) { + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + + /* Check for an empty tree. */ + if (NEXTINDEX(h) == 0) { + mpool_put(t->bt_mp, h, 0); + return (RET_SPECIAL); + } + + if (h->flags & (P_BLEAF | P_RLEAF)) + break; + pg = GETBINTERNAL(h, 0)->pgno; + mpool_put(t->bt_mp, h, 0); + } + ep->page = h; + ep->index = 0; + break; + case R_LAST: /* Last record. */ + case R_PREV: + /* Walk down the right-hand side of the tree. */ + for (pg = P_ROOT;;) { + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + + /* Check for an empty tree. */ + if (NEXTINDEX(h) == 0) { + mpool_put(t->bt_mp, h, 0); + return (RET_SPECIAL); + } + + if (h->flags & (P_BLEAF | P_RLEAF)) + break; + pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno; + mpool_put(t->bt_mp, h, 0); + } + + ep->page = h; + ep->index = NEXTINDEX(h) - 1; + break; + } + return (RET_SUCCESS); +} + +/* + * __bt_seqadvance -- + * Advance the sequential scan. + * + * Parameters: + * t: tree + * flags: R_NEXT, R_PREV + * + * Side effects: + * Pins the page the new key/data record is on. + * + * Returns: + * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. + */ +static int +__bt_seqadv(t, ep, flags) + BTREE *t; + EPG *ep; + int flags; +{ + CURSOR *c; + PAGE *h; + indx_t index = 0; + pgno_t pg; + int exact; + + /* + * There are a couple of states that we can be in. The cursor has + * been initialized by the time we get here, but that's all we know. + */ + c = &t->bt_cursor; + + /* + * The cursor was deleted where there weren't any duplicate records, + * so the key was saved. Find out where that key would go in the + * current tree. It doesn't matter if the returned key is an exact + * match or not -- if it's an exact match, the record was added after + * the delete so we can just return it. If not, as long as there's + * a record there, return it. + */ + if (F_ISSET(c, CURS_ACQUIRE)) + return (__bt_first(t, &c->key, ep, &exact)); + + /* Get the page referenced by the cursor. */ + if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) + return (RET_ERROR); + + /* + * Find the next/previous record in the tree and point the cursor at + * it. The cursor may not be moved until a new key has been found. + */ + switch (flags) { + case R_NEXT: /* Next record. */ + /* + * The cursor was deleted in duplicate records, and moved + * forward to a record that has yet to be returned. Clear + * that flag, and return the record. + */ + if (F_ISSET(c, CURS_AFTER)) + goto usecurrent; + index = c->pg.index; + if (++index == NEXTINDEX(h)) { + pg = h->nextpg; + mpool_put(t->bt_mp, h, 0); + if (pg == P_INVALID) + return (RET_SPECIAL); + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + index = 0; + } + break; + case R_PREV: /* Previous record. */ + /* + * The cursor was deleted in duplicate records, and moved + * backward to a record that has yet to be returned. Clear + * that flag, and return the record. + */ + if (F_ISSET(c, CURS_BEFORE)) { +usecurrent: F_CLR(c, CURS_AFTER | CURS_BEFORE); + ep->page = h; + ep->index = c->pg.index; + return (RET_SUCCESS); + } + index = c->pg.index; + if (index == 0) { + pg = h->prevpg; + mpool_put(t->bt_mp, h, 0); + if (pg == P_INVALID) + return (RET_SPECIAL); + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + index = NEXTINDEX(h) - 1; + } else + --index; + break; + } + + ep->page = h; + ep->index = index; + return (RET_SUCCESS); +} + +/* + * __bt_first -- + * Find the first entry. + * + * Parameters: + * t: the tree + * key: the key + * erval: return EPG + * exactp: pointer to exact match flag + * + * Returns: + * The first entry in the tree greater than or equal to key, + * or RET_SPECIAL if no such key exists. + */ +static int +__bt_first(t, key, erval, exactp) + BTREE *t; + const DBT *key; + EPG *erval; + int *exactp; +{ + PAGE *h; + EPG *ep, save; + pgno_t pg; + + /* + * Find any matching record; __bt_search pins the page. + * + * If it's an exact match and duplicates are possible, walk backwards + * in the tree until we find the first one. Otherwise, make sure it's + * a valid key (__bt_search may return an index just past the end of a + * page) and return it. + */ + if ((ep = __bt_search(t, key, exactp)) == NULL) + return (RET_SPECIAL); + if (*exactp) { + if (F_ISSET(t, B_NODUPS)) { + *erval = *ep; + return (RET_SUCCESS); + } + + /* + * Walk backwards, as long as the entry matches and there are + * keys left in the tree. Save a copy of each match in case + * we go too far. + */ + save = *ep; + h = ep->page; + do { + if (save.page->pgno != ep->page->pgno) { + mpool_put(t->bt_mp, save.page, 0); + save = *ep; + } else + save.index = ep->index; + + /* + * Don't unpin the page the last (or original) match + * was on, but make sure it's unpinned if an error + * occurs. + */ + if (ep->index == 0) { + if (h->prevpg == P_INVALID) + break; + if (h->pgno != save.page->pgno) + mpool_put(t->bt_mp, h, 0); + if ((h = mpool_get(t->bt_mp, + h->prevpg, 0)) == NULL) { + if (h->pgno == save.page->pgno) + mpool_put(t->bt_mp, + save.page, 0); + return (RET_ERROR); + } + ep->page = h; + ep->index = NEXTINDEX(h); + } + --ep->index; + } while (__bt_cmp(t, key, ep) == 0); + + /* + * Reach here with the last page that was looked at pinned, + * which may or may not be the same as the last (or original) + * match page. If it's not useful, release it. + */ + if (h->pgno != save.page->pgno) + mpool_put(t->bt_mp, h, 0); + + *erval = save; + return (RET_SUCCESS); + } + + /* If at the end of a page, find the next entry. */ + if (ep->index == NEXTINDEX(ep->page)) { + h = ep->page; + pg = h->nextpg; + mpool_put(t->bt_mp, h, 0); + if (pg == P_INVALID) + return (RET_SPECIAL); + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + ep->index = 0; + ep->page = h; + } + *erval = *ep; + return (RET_SUCCESS); +} + +/* + * __bt_setcur -- + * Set the cursor to an entry in the tree. + * + * Parameters: + * t: the tree + * pgno: page number + * index: page index + */ +void +__bt_setcur(t, pgno, index) + BTREE *t; + pgno_t pgno; + u_int index; +{ + /* Lose any already deleted key. */ + if (t->bt_cursor.key.data != NULL) { + free(t->bt_cursor.key.data); + t->bt_cursor.key.size = 0; + t->bt_cursor.key.data = NULL; + } + F_CLR(&t->bt_cursor, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE); + + /* Update the cursor. */ + t->bt_cursor.pg.pgno = pgno; + t->bt_cursor.pg.index = index; + F_SET(&t->bt_cursor, CURS_INIT); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c new file mode 100644 index 0000000..e743178 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c @@ -0,0 +1,834 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_split.c 8.9 (Berkeley) 7/26/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +#include +#include "btree.h" + +static int bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *)); +static PAGE *bt_page + __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t)); +static int bt_preserve __P((BTREE *, pgno_t)); +static PAGE *bt_psplit + __P((BTREE *, PAGE *, PAGE *, PAGE *, indx_t *, size_t)); +static PAGE *bt_root + __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t)); +static int bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *)); +static recno_t rec_total __P((PAGE *)); + +#ifdef STATISTICS +u_long bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved; +#endif + +/* + * __BT_SPLIT -- Split the tree. + * + * Parameters: + * t: tree + * sp: page to split + * key: key to insert + * data: data to insert + * flags: BIGKEY/BIGDATA flags + * ilen: insert length + * skip: index to leave open + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__bt_split(t, sp, key, data, flags, ilen, argskip) + BTREE *t; + PAGE *sp; + const DBT *key, *data; + int flags; + size_t ilen; + u_int32_t argskip; +{ + BINTERNAL *bi = NULL; + BLEAF *bl = NULL, *tbl; + DBT a, b; + EPGNO *parent; + PAGE *h, *l, *r, *lchild, *rchild; + indx_t nxtindex; + u_int16_t skip; + u_int32_t n, nbytes, nksize = 0; + int parentsplit; + char *dest; + pgno_t pg_tmp; + + /* + * Split the page into two pages, l and r. The split routines return + * a pointer to the page into which the key should be inserted and with + * skip set to the offset which should be used. Additionally, l and r + * are pinned. + */ + skip = argskip; + h = sp->pgno == P_ROOT ? + bt_root(t, sp, &l, &r, &skip, ilen) : + bt_page(t, sp, &l, &r, &skip, ilen); + if (h == NULL) + return (RET_ERROR); + + /* + * Insert the new key/data pair into the leaf page. (Key inserts + * always cause a leaf page to split first.) + */ + h->linp[skip] = h->upper -= ilen; + dest = (char *)h + h->upper; + if (F_ISSET(t, R_RECNO)) + WR_RLEAF(dest, data, flags) + else + WR_BLEAF(dest, key, data, flags) + + /* If the root page was split, make it look right. */ + if (sp->pgno == P_ROOT && + (F_ISSET(t, R_RECNO) ? + bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) + goto err2; + + /* + * Now we walk the parent page stack -- a LIFO stack of the pages that + * were traversed when we searched for the page that split. Each stack + * entry is a page number and a page index offset. The offset is for + * the page traversed on the search. We've just split a page, so we + * have to insert a new key into the parent page. + * + * If the insert into the parent page causes it to split, may have to + * continue splitting all the way up the tree. We stop if the root + * splits or the page inserted into didn't have to split to hold the + * new key. Some algorithms replace the key for the old page as well + * as the new page. We don't, as there's no reason to believe that the + * first key on the old page is any better than the key we have, and, + * in the case of a key being placed at index 0 causing the split, the + * key is unavailable. + * + * There are a maximum of 5 pages pinned at any time. We keep the left + * and right pages pinned while working on the parent. The 5 are the + * two children, left parent and right parent (when the parent splits) + * and the root page or the overflow key page when calling bt_preserve. + * This code must make sure that all pins are released other than the + * root page or overflow page which is unlocked elsewhere. + */ + while ((parent = BT_POP(t)) != NULL) { + lchild = l; + rchild = r; + + /* Get the parent page. */ + if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) + goto err2; + + /* + * The new key goes ONE AFTER the index, because the split + * was to the right. + */ + skip = parent->index + 1; + + /* + * Calculate the space needed on the parent page. + * + * Prefix trees: space hack when inserting into BINTERNAL + * pages. Retain only what's needed to distinguish between + * the new entry and the LAST entry on the page to its left. + * If the keys compare equal, retain the entire key. Note, + * we don't touch overflow keys, and the entire key must be + * retained for the next-to-left most key on the leftmost + * page of each level, or the search will fail. Applicable + * ONLY to internal pages that have leaf pages as children. + * Further reduction of the key between pairs of internal + * pages loses too much information. + */ + switch (rchild->flags & P_TYPE) { + case P_BINTERNAL: + bi = GETBINTERNAL(rchild, 0); + nbytes = NBINTERNAL(bi->ksize); + break; + case P_BLEAF: + bl = GETBLEAF(rchild, 0); + nbytes = NBINTERNAL(bl->ksize); + if (t->bt_pfx && !(bl->flags & P_BIGKEY) && + (h->prevpg != P_INVALID || skip > 1)) { + tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1); + a.size = tbl->ksize; + a.data = tbl->bytes; + b.size = bl->ksize; + b.data = bl->bytes; + nksize = t->bt_pfx(&a, &b); + n = NBINTERNAL(nksize); + if (n < nbytes) { +#ifdef STATISTICS + bt_pfxsaved += nbytes - n; +#endif + nbytes = n; + } else + nksize = 0; + } else + nksize = 0; + break; + case P_RINTERNAL: + case P_RLEAF: + nbytes = NRINTERNAL; + break; + default: + abort(); + } + + /* Split the parent page if necessary or shift the indices. */ + if (h->upper - h->lower < nbytes + sizeof(indx_t)) { + sp = h; + h = h->pgno == P_ROOT ? + bt_root(t, h, &l, &r, &skip, nbytes) : + bt_page(t, h, &l, &r, &skip, nbytes); + if (h == NULL) + goto err1; + parentsplit = 1; + } else { + if (skip < (nxtindex = NEXTINDEX(h))) + memmove(h->linp + skip + 1, h->linp + skip, + (nxtindex - skip) * sizeof(indx_t)); + h->lower += sizeof(indx_t); + parentsplit = 0; + } + + /* Insert the key into the parent page. */ + switch (rchild->flags & P_TYPE) { + case P_BINTERNAL: + h->linp[skip] = h->upper -= nbytes; + dest = (char *)h + h->linp[skip]; + memmove(dest, bi, nbytes); + ((BINTERNAL *)dest)->pgno = rchild->pgno; + break; + case P_BLEAF: + h->linp[skip] = h->upper -= nbytes; + dest = (char *)h + h->linp[skip]; + WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, + rchild->pgno, bl->flags & P_BIGKEY); + memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); + /* Avoid alignment violation */ + memcpy(&pg_tmp, bl->bytes, sizeof(pgno_t)); + if (bl->flags & P_BIGKEY && + bt_preserve(t, pg_tmp) == RET_ERROR) + goto err1; + break; + case P_RINTERNAL: + /* + * Update the left page count. If split + * added at index 0, fix the correct page. + */ + if (skip > 0) + dest = (char *)h + h->linp[skip - 1]; + else + dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; + ((RINTERNAL *)dest)->nrecs = rec_total(lchild); + ((RINTERNAL *)dest)->pgno = lchild->pgno; + + /* Update the right page count. */ + h->linp[skip] = h->upper -= nbytes; + dest = (char *)h + h->linp[skip]; + ((RINTERNAL *)dest)->nrecs = rec_total(rchild); + ((RINTERNAL *)dest)->pgno = rchild->pgno; + break; + case P_RLEAF: + /* + * Update the left page count. If split + * added at index 0, fix the correct page. + */ + if (skip > 0) + dest = (char *)h + h->linp[skip - 1]; + else + dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; + ((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild); + ((RINTERNAL *)dest)->pgno = lchild->pgno; + + /* Update the right page count. */ + h->linp[skip] = h->upper -= nbytes; + dest = (char *)h + h->linp[skip]; + ((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild); + ((RINTERNAL *)dest)->pgno = rchild->pgno; + break; + default: + abort(); + } + + /* Unpin the held pages. */ + if (!parentsplit) { + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + break; + } + + /* If the root page was split, make it look right. */ + if (sp->pgno == P_ROOT && + (F_ISSET(t, R_RECNO) ? + bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) + goto err1; + + mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); + mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); + } + + /* Unpin the held pages. */ + mpool_put(t->bt_mp, l, MPOOL_DIRTY); + mpool_put(t->bt_mp, r, MPOOL_DIRTY); + + /* Clear any pages left on the stack. */ + return (RET_SUCCESS); + + /* + * If something fails in the above loop we were already walking back + * up the tree and the tree is now inconsistent. Nothing much we can + * do about it but release any memory we're holding. + */ +err1: mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); + mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); + +err2: mpool_put(t->bt_mp, l, 0); + mpool_put(t->bt_mp, r, 0); + __dbpanic(t->bt_dbp); + return (RET_ERROR); +} + +/* + * BT_PAGE -- Split a non-root page of a btree. + * + * Parameters: + * t: tree + * h: root page + * lp: pointer to left page pointer + * rp: pointer to right page pointer + * skip: pointer to index to leave open + * ilen: insert length + * + * Returns: + * Pointer to page in which to insert or NULL on error. + */ +static PAGE * +bt_page(t, h, lp, rp, skip, ilen) + BTREE *t; + PAGE *h, **lp, **rp; + indx_t *skip; + size_t ilen; +{ + PAGE *l, *r, *tp; + pgno_t npg; + +#ifdef STATISTICS + ++bt_split; +#endif + /* Put the new right page for the split into place. */ + if ((r = __bt_new(t, &npg)) == NULL) + return (NULL); + r->pgno = npg; + r->lower = BTDATAOFF; + r->upper = t->bt_psize; + r->nextpg = h->nextpg; + r->prevpg = h->pgno; + r->flags = h->flags & P_TYPE; + + /* + * If we're splitting the last page on a level because we're appending + * a key to it (skip is NEXTINDEX()), it's likely that the data is + * sorted. Adding an empty page on the side of the level is less work + * and can push the fill factor much higher than normal. If we're + * wrong it's no big deal, we'll just do the split the right way next + * time. It may look like it's equally easy to do a similar hack for + * reverse sorted data, that is, split the tree left, but it's not. + * Don't even try. + */ + if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) { +#ifdef STATISTICS + ++bt_sortsplit; +#endif + h->nextpg = r->pgno; + r->lower = BTDATAOFF + sizeof(indx_t); + *skip = 0; + *lp = h; + *rp = r; + return (r); + } + + /* Put the new left page for the split into place. */ + if ((l = (PAGE *)malloc(t->bt_psize)) == NULL) { + mpool_put(t->bt_mp, r, 0); + return (NULL); + } +#ifdef PURIFY + memset(l, 0xff, t->bt_psize); +#endif + l->pgno = h->pgno; + l->nextpg = r->pgno; + l->prevpg = h->prevpg; + l->lower = BTDATAOFF; + l->upper = t->bt_psize; + l->flags = h->flags & P_TYPE; + + /* Fix up the previous pointer of the page after the split page. */ + if (h->nextpg != P_INVALID) { + if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) { + free(l); + /* XXX mpool_free(t->bt_mp, r->pgno); */ + return (NULL); + } + tp->prevpg = r->pgno; + mpool_put(t->bt_mp, tp, MPOOL_DIRTY); + } + + /* + * Split right. The key/data pairs aren't sorted in the btree page so + * it's simpler to copy the data from the split page onto two new pages + * instead of copying half the data to the right page and compacting + * the left page in place. Since the left page can't change, we have + * to swap the original and the allocated left page after the split. + */ + tp = bt_psplit(t, h, l, r, skip, ilen); + + /* Move the new left page onto the old left page. */ + memmove(h, l, t->bt_psize); + if (tp == l) + tp = h; + free(l); + + *lp = h; + *rp = r; + return (tp); +} + +/* + * BT_ROOT -- Split the root page of a btree. + * + * Parameters: + * t: tree + * h: root page + * lp: pointer to left page pointer + * rp: pointer to right page pointer + * skip: pointer to index to leave open + * ilen: insert length + * + * Returns: + * Pointer to page in which to insert or NULL on error. + */ +static PAGE * +bt_root(t, h, lp, rp, skip, ilen) + BTREE *t; + PAGE *h, **lp, **rp; + indx_t *skip; + size_t ilen; +{ + PAGE *l, *r, *tp; + pgno_t lnpg, rnpg; + +#ifdef STATISTICS + ++bt_split; + ++bt_rootsplit; +#endif + /* Put the new left and right pages for the split into place. */ + if ((l = __bt_new(t, &lnpg)) == NULL || + (r = __bt_new(t, &rnpg)) == NULL) + return (NULL); + l->pgno = lnpg; + r->pgno = rnpg; + l->nextpg = r->pgno; + r->prevpg = l->pgno; + l->prevpg = r->nextpg = P_INVALID; + l->lower = r->lower = BTDATAOFF; + l->upper = r->upper = t->bt_psize; + l->flags = r->flags = h->flags & P_TYPE; + + /* Split the root page. */ + tp = bt_psplit(t, h, l, r, skip, ilen); + + *lp = l; + *rp = r; + return (tp); +} + +/* + * BT_RROOT -- Fix up the recno root page after it has been split. + * + * Parameters: + * t: tree + * h: root page + * l: left page + * r: right page + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +static int +bt_rroot(t, h, l, r) + BTREE *t; + PAGE *h, *l, *r; +{ + char *dest; + + /* Insert the left and right keys, set the header information. */ + h->linp[0] = h->upper = t->bt_psize - NRINTERNAL; + dest = (char *)h + h->upper; + WR_RINTERNAL(dest, + l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno); + + h->linp[1] = h->upper -= NRINTERNAL; + dest = (char *)h + h->upper; + WR_RINTERNAL(dest, + r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno); + + h->lower = BTDATAOFF + 2 * sizeof(indx_t); + + /* Unpin the root page, set to recno internal page. */ + h->flags &= ~P_TYPE; + h->flags |= P_RINTERNAL; + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + + return (RET_SUCCESS); +} + +/* + * BT_BROOT -- Fix up the btree root page after it has been split. + * + * Parameters: + * t: tree + * h: root page + * l: left page + * r: right page + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +static int +bt_broot(t, h, l, r) + BTREE *t; + PAGE *h, *l, *r; +{ + BINTERNAL *bi; + BLEAF *bl; + u_int32_t nbytes; + char *dest; + pgno_t pg_tmp; + + /* + * If the root page was a leaf page, change it into an internal page. + * We copy the key we split on (but not the key's data, in the case of + * a leaf page) to the new root page. + * + * The btree comparison code guarantees that the left-most key on any + * level of the tree is never used, so it doesn't need to be filled in. + */ + nbytes = NBINTERNAL(0); + h->linp[0] = h->upper = t->bt_psize - nbytes; + dest = (char *)h + h->upper; + WR_BINTERNAL(dest, 0, l->pgno, 0); + + switch (h->flags & P_TYPE) { + case P_BLEAF: + bl = GETBLEAF(r, 0); + nbytes = NBINTERNAL(bl->ksize); + h->linp[1] = h->upper -= nbytes; + dest = (char *)h + h->upper; + WR_BINTERNAL(dest, bl->ksize, r->pgno, 0); + memmove(dest, bl->bytes, bl->ksize); + + /* + * If the key is on an overflow page, mark the overflow chain + * so it isn't deleted when the leaf copy of the key is deleted. + */ + /* Avoid alignment violation */ + memcpy(&pg_tmp, bl->bytes, sizeof(pgno_t)); + if (bl->flags & P_BIGKEY && + bt_preserve(t, pg_tmp) == RET_ERROR) + return (RET_ERROR); + break; + case P_BINTERNAL: + bi = GETBINTERNAL(r, 0); + nbytes = NBINTERNAL(bi->ksize); + h->linp[1] = h->upper -= nbytes; + dest = (char *)h + h->upper; + memmove(dest, bi, nbytes); + ((BINTERNAL *)dest)->pgno = r->pgno; + break; + default: + abort(); + } + + /* There are two keys on the page. */ + h->lower = BTDATAOFF + 2 * sizeof(indx_t); + + /* Unpin the root page, set to btree internal page. */ + h->flags &= ~P_TYPE; + h->flags |= P_BINTERNAL; + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + + return (RET_SUCCESS); +} + +/* + * BT_PSPLIT -- Do the real work of splitting the page. + * + * Parameters: + * t: tree + * h: page to be split + * l: page to put lower half of data + * r: page to put upper half of data + * pskip: pointer to index to leave open + * ilen: insert length + * + * Returns: + * Pointer to page in which to insert. + */ +static PAGE * +bt_psplit(t, h, l, r, pskip, ilen) + BTREE *t; + PAGE *h, *l, *r; + indx_t *pskip; + size_t ilen; +{ + BINTERNAL *bi; + BLEAF *bl; + CURSOR *c; + RLEAF *rl; + PAGE *rval; + void *src = NULL; + indx_t full, half, nxt, off, skip, top, used; + u_int32_t nbytes; + int bigkeycnt, isbigkey; + + /* + * Split the data to the left and right pages. Leave the skip index + * open. Additionally, make some effort not to split on an overflow + * key. This makes internal page processing faster and can save + * space as overflow keys used by internal pages are never deleted. + */ + bigkeycnt = 0; + skip = *pskip; + full = t->bt_psize - BTDATAOFF; + half = full / 2; + used = 0; + for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { + if (skip == off) { + nbytes = ilen; + isbigkey = 0; /* XXX: not really known. */ + } else + switch (h->flags & P_TYPE) { + case P_BINTERNAL: + src = bi = GETBINTERNAL(h, nxt); + nbytes = NBINTERNAL(bi->ksize); + isbigkey = bi->flags & P_BIGKEY; + break; + case P_BLEAF: + src = bl = GETBLEAF(h, nxt); + nbytes = NBLEAF(bl); + isbigkey = bl->flags & P_BIGKEY; + break; + case P_RINTERNAL: + src = GETRINTERNAL(h, nxt); + nbytes = NRINTERNAL; + isbigkey = 0; + break; + case P_RLEAF: + src = rl = GETRLEAF(h, nxt); + nbytes = NRLEAF(rl); + isbigkey = 0; + break; + default: + abort(); + } + + /* + * If the key/data pairs are substantial fractions of the max + * possible size for the page, it's possible to get situations + * where we decide to try and copy too much onto the left page. + * Make sure that doesn't happen. + */ + if ((skip <= off && + used + nbytes + sizeof(indx_t) >= full) || nxt == top - 1) { + --off; + break; + } + + /* Copy the key/data pair, if not the skipped index. */ + if (skip != off) { + ++nxt; + + l->linp[off] = l->upper -= nbytes; + memmove((char *)l + l->upper, src, nbytes); + } + + used += nbytes + sizeof(indx_t); + if (used >= half) { + if (!isbigkey || bigkeycnt == 3) + break; + else + ++bigkeycnt; + } + } + + /* + * Off is the last offset that's valid for the left page. + * Nxt is the first offset to be placed on the right page. + */ + l->lower += (off + 1) * sizeof(indx_t); + + /* + * If splitting the page that the cursor was on, the cursor has to be + * adjusted to point to the same record as before the split. If the + * cursor is at or past the skipped slot, the cursor is incremented by + * one. If the cursor is on the right page, it is decremented by the + * number of records split to the left page. + */ + c = &t->bt_cursor; + if (F_ISSET(c, CURS_INIT) && c->pg.pgno == h->pgno) { + if (c->pg.index >= skip) + ++c->pg.index; + if (c->pg.index < nxt) /* Left page. */ + c->pg.pgno = l->pgno; + else { /* Right page. */ + c->pg.pgno = r->pgno; + c->pg.index -= nxt; + } + } + + /* + * If the skipped index was on the left page, just return that page. + * Otherwise, adjust the skip index to reflect the new position on + * the right page. + */ + if (skip <= off) { + skip = 0; + rval = l; + } else { + rval = r; + *pskip -= nxt; + } + + for (off = 0; nxt < top; ++off) { + if (skip == nxt) { + ++off; + skip = 0; + } + switch (h->flags & P_TYPE) { + case P_BINTERNAL: + src = bi = GETBINTERNAL(h, nxt); + nbytes = NBINTERNAL(bi->ksize); + break; + case P_BLEAF: + src = bl = GETBLEAF(h, nxt); + nbytes = NBLEAF(bl); + break; + case P_RINTERNAL: + src = GETRINTERNAL(h, nxt); + nbytes = NRINTERNAL; + break; + case P_RLEAF: + src = rl = GETRLEAF(h, nxt); + nbytes = NRLEAF(rl); + break; + default: + abort(); + } + ++nxt; + r->linp[off] = r->upper -= nbytes; + memmove((char *)r + r->upper, src, nbytes); + } + r->lower += off * sizeof(indx_t); + + /* If the key is being appended to the page, adjust the index. */ + if (skip == top) + r->lower += sizeof(indx_t); + + return (rval); +} + +/* + * BT_PRESERVE -- Mark a chain of pages as used by an internal node. + * + * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the + * record that references them gets deleted. Chains pointed to by internal + * pages never get deleted. This routine marks a chain as pointed to by an + * internal page. + * + * Parameters: + * t: tree + * pg: page number of first page in the chain. + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +static int +bt_preserve(t, pg) + BTREE *t; + pgno_t pg; +{ + PAGE *h; + + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + return (RET_ERROR); + h->flags |= P_PRESERVE; + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + return (RET_SUCCESS); +} + +/* + * REC_TOTAL -- Return the number of recno entries below a page. + * + * Parameters: + * h: page + * + * Returns: + * The number of recno entries below a page. + * + * XXX + * These values could be set by the bt_psplit routine. The problem is that the + * entry has to be popped off of the stack etc. or the values have to be passed + * all the way back to bt_split/bt_rroot and it's not very clean. + */ +static recno_t +rec_total(h) + PAGE *h; +{ + recno_t recs; + indx_t nxt, top; + + for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt) + recs += GETRINTERNAL(h, nxt)->nrecs; + return (recs); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c new file mode 100644 index 0000000..9c1438e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c @@ -0,0 +1,260 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bt_utils.c 8.8 (Berkeley) 7/20/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "btree.h" + +/* + * __bt_ret -- + * Build return key/data pair. + * + * Parameters: + * t: tree + * e: key/data pair to be returned + * key: user's key structure (NULL if not to be filled in) + * rkey: memory area to hold key + * data: user's data structure (NULL if not to be filled in) + * rdata: memory area to hold data + * copy: always copy the key/data item + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +int +__bt_ret(t, e, key, rkey, data, rdata, copy) + BTREE *t; + EPG *e; + DBT *key, *rkey, *data, *rdata; + int copy; +{ + BLEAF *bl; + void *p; + + bl = GETBLEAF(e->page, e->index); + + /* + * We must copy big keys/data to make them contigous. Otherwise, + * leave the page pinned and don't copy unless the user specified + * concurrent access. + */ + if (key == NULL) + goto dataonly; + + if (bl->flags & P_BIGKEY) { + if (__ovfl_get(t, bl->bytes, + &key->size, &rkey->data, &rkey->size)) + return (RET_ERROR); + key->data = rkey->data; + } else if (copy || F_ISSET(t, B_DB_LOCK)) { + if (bl->ksize > rkey->size) { + p = (void *)(rkey->data == NULL ? + malloc(bl->ksize) : realloc(rkey->data, bl->ksize)); + if (p == NULL) + return (RET_ERROR); + rkey->data = p; + rkey->size = bl->ksize; + } + memmove(rkey->data, bl->bytes, bl->ksize); + key->size = bl->ksize; + key->data = rkey->data; + } else { + key->size = bl->ksize; + key->data = bl->bytes; + } + +dataonly: + if (data == NULL) + return (RET_SUCCESS); + + if (bl->flags & P_BIGDATA) { + if (__ovfl_get(t, bl->bytes + bl->ksize, + &data->size, &rdata->data, &rdata->size)) + return (RET_ERROR); + data->data = rdata->data; + } else if (copy || F_ISSET(t, B_DB_LOCK)) { + /* Use +1 in case the first record retrieved is 0 length. */ + if (bl->dsize + 1 > rdata->size) { + p = (void *)(rdata->data == NULL ? + malloc(bl->dsize + 1) : + realloc(rdata->data, bl->dsize + 1)); + if (p == NULL) + return (RET_ERROR); + rdata->data = p; + rdata->size = bl->dsize + 1; + } + memmove(rdata->data, bl->bytes + bl->ksize, bl->dsize); + data->size = bl->dsize; + data->data = rdata->data; + } else { + data->size = bl->dsize; + data->data = bl->bytes + bl->ksize; + } + + return (RET_SUCCESS); +} + +/* + * __BT_CMP -- Compare a key to a given record. + * + * Parameters: + * t: tree + * k1: DBT pointer of first arg to comparison + * e: pointer to EPG for comparison + * + * Returns: + * < 0 if k1 is < record + * = 0 if k1 is = record + * > 0 if k1 is > record + */ +int +__bt_cmp(t, k1, e) + BTREE *t; + const DBT *k1; + EPG *e; +{ + BINTERNAL *bi; + BLEAF *bl; + DBT k2; + PAGE *h; + void *bigkey; + + /* + * The left-most key on internal pages, at any level of the tree, is + * guaranteed by the following code to be less than any user key. + * This saves us from having to update the leftmost key on an internal + * page when the user inserts a new key in the tree smaller than + * anything we've yet seen. + */ + h = e->page; + if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF)) + return (1); + + bigkey = NULL; + if (h->flags & P_BLEAF) { + bl = GETBLEAF(h, e->index); + if (bl->flags & P_BIGKEY) + bigkey = bl->bytes; + else { + k2.data = bl->bytes; + k2.size = bl->ksize; + } + } else { + bi = GETBINTERNAL(h, e->index); + if (bi->flags & P_BIGKEY) + bigkey = bi->bytes; + else { + k2.data = bi->bytes; + k2.size = bi->ksize; + } + } + + if (bigkey) { + if (__ovfl_get(t, bigkey, + &k2.size, &t->bt_rdata.data, &t->bt_rdata.size)) + return (RET_ERROR); + k2.data = t->bt_rdata.data; + } + return ((*t->bt_cmp)(k1, &k2)); +} + +/* + * __BT_DEFCMP -- Default comparison routine. + * + * Parameters: + * a: DBT #1 + * b: DBT #2 + * + * Returns: + * < 0 if a is < b + * = 0 if a is = b + * > 0 if a is > b + */ +int +__bt_defcmp(a, b) + const DBT *a, *b; +{ + register size_t len; + register u_char *p1, *p2; + + /* + * XXX + * If a size_t doesn't fit in an int, this routine can lose. + * What we need is a integral type which is guaranteed to be + * larger than a size_t, and there is no such thing. + */ + len = MIN(a->size, b->size); + for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2) + if (*p1 != *p2) + return ((int)*p1 - (int)*p2); + return ((int)a->size - (int)b->size); +} + +/* + * __BT_DEFPFX -- Default prefix routine. + * + * Parameters: + * a: DBT #1 + * b: DBT #2 + * + * Returns: + * Number of bytes needed to distinguish b from a. + */ +size_t +__bt_defpfx(a, b) + const DBT *a, *b; +{ + register u_char *p1, *p2; + register size_t cnt, len; + + cnt = 1; + len = MIN(a->size, b->size); + for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt) + if (*p1 != *p2) + return (cnt); + + /* a->size must be <= b->size, or they wouldn't be in this order. */ + return (a->size < b->size ? a->size + 1 : a->size); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/btree.h b/user/mpy/lib/berkeley-db-1.xx/btree/btree.h new file mode 100644 index 0000000..af94ae6 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/btree.h @@ -0,0 +1,384 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)btree.h 8.11 (Berkeley) 8/17/94 + */ + +/* Macros to set/clear/test flags. */ +#define F_SET(p, f) (p)->flags |= (f) +#define F_CLR(p, f) (p)->flags &= ~(f) +#define F_ISSET(p, f) ((p)->flags & (f)) + +#include + +#define DEFMINKEYPAGE (2) /* Minimum keys per page */ +#define MINCACHE (5) /* Minimum cached pages */ +#define MINPSIZE (512) /* Minimum page size */ +#define DEFPSIZE (4096) /* Default page size */ + +/* + * Page 0 of a btree file contains a copy of the meta-data. This page is also + * used as an out-of-band page, i.e. page pointers that point to nowhere point + * to page 0. Page 1 is the root of the btree. + */ +#define P_INVALID 0 /* Invalid tree page number. */ +#define P_META 0 /* Tree metadata page number. */ +#define P_ROOT 1 /* Tree root page number. */ + +/* + * There are five page layouts in the btree: btree internal pages (BINTERNAL), + * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages + * (RLEAF) and overflow pages. All five page types have a page header (PAGE). + * This implementation requires that values within structures NOT be padded. + * (ANSI C permits random padding.) If your compiler pads randomly you'll have + * to do some work to get this package to run. + */ +typedef struct _page { + pgno_t pgno; /* this page's page number */ + pgno_t prevpg; /* left sibling */ + pgno_t nextpg; /* right sibling */ + +#define P_BINTERNAL 0x01 /* btree internal page */ +#define P_BLEAF 0x02 /* leaf page */ +#define P_OVERFLOW 0x04 /* overflow page */ +#define P_RINTERNAL 0x08 /* recno internal page */ +#define P_RLEAF 0x10 /* leaf page */ +#define P_TYPE 0x1f /* type mask */ +#define P_PRESERVE 0x20 /* never delete this chain of pages */ + u_int32_t flags; + + indx_t lower; /* lower bound of free space on page */ + indx_t upper; /* upper bound of free space on page */ + indx_t linp[1]; /* indx_t-aligned VAR. LENGTH DATA */ +} PAGE; + +/* First and next index. */ +#define BTDATAOFF \ + (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ + sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t)) +#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) + +/* + * For pages other than overflow pages, there is an array of offsets into the + * rest of the page immediately following the page header. Each offset is to + * an item which is unique to the type of page. The h_lower offset is just + * past the last filled-in index. The h_upper offset is the first item on the + * page. Offsets are from the beginning of the page. + * + * If an item is too big to store on a single page, a flag is set and the item + * is a { page, size } pair such that the page is the first page of an overflow + * chain with size bytes of item. Overflow pages are simply bytes without any + * external structure. + * + * The page number and size fields in the items are pgno_t-aligned so they can + * be manipulated without copying. (This presumes that 32 bit items can be + * manipulated on this system.) + */ +#define LALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) +#define NOVFLSIZE (sizeof(pgno_t) + sizeof(u_int32_t)) + +/* + * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} + * pairs, such that the key compares less than or equal to all of the records + * on that page. For a tree without duplicate keys, an internal page with two + * consecutive keys, a and b, will have all records greater than or equal to a + * and less than b stored on the page associated with a. Duplicate keys are + * somewhat special and can cause duplicate internal and leaf page records and + * some minor modifications of the above rule. + */ +typedef struct _binternal { + u_int32_t ksize; /* key size */ + pgno_t pgno; /* page number stored on */ +#define P_BIGDATA 0x01 /* overflow data */ +#define P_BIGKEY 0x02 /* overflow key */ + u_char flags; + char bytes[1]; /* data */ +} BINTERNAL; + +/* Get the page's BINTERNAL structure at index indx. */ +#define GETBINTERNAL(pg, indx) \ + ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx])) + +/* Get the number of bytes in the entry. */ +#define NBINTERNAL(len) \ + LALIGN(sizeof(u_int32_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) + +/* Copy a BINTERNAL entry to the page. */ +#define WR_BINTERNAL(p, size, pgno, flags) { \ + *(u_int32_t *)p = size; \ + p += sizeof(u_int32_t); \ + *(pgno_t *)p = pgno; \ + p += sizeof(pgno_t); \ + *(u_char *)p = flags; \ + p += sizeof(u_char); \ +} + +/* + * For the recno internal pages, the item is a page number with the number of + * keys found on that page and below. + */ +typedef struct _rinternal { + recno_t nrecs; /* number of records */ + pgno_t pgno; /* page number stored below */ +} RINTERNAL; + +/* Get the page's RINTERNAL structure at index indx. */ +#define GETRINTERNAL(pg, indx) \ + ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx])) + +/* Get the number of bytes in the entry. */ +#define NRINTERNAL \ + LALIGN(sizeof(recno_t) + sizeof(pgno_t)) + +/* Copy a RINTERAL entry to the page. */ +#define WR_RINTERNAL(p, nrecs, pgno) { \ + *(recno_t *)p = nrecs; \ + p += sizeof(recno_t); \ + *(pgno_t *)p = pgno; \ +} + +/* For the btree leaf pages, the item is a key and data pair. */ +typedef struct _bleaf { + u_int32_t ksize; /* size of key */ + u_int32_t dsize; /* size of data */ + u_char flags; /* P_BIGDATA, P_BIGKEY */ + char bytes[1]; /* data */ +} BLEAF; + +/* Get the page's BLEAF structure at index indx. */ +#define GETBLEAF(pg, indx) \ + ((BLEAF *)((char *)(pg) + (pg)->linp[indx])) + +/* Get the number of bytes in the entry. */ +#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) + +/* Get the number of bytes in the user's key/data pair. */ +#define NBLEAFDBT(ksize, dsize) \ + LALIGN(sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_char) + \ + (ksize) + (dsize)) + +/* Copy a BLEAF entry to the page. */ +#define WR_BLEAF(p, key, data, flags) { \ + *(u_int32_t *)p = key->size; \ + p += sizeof(u_int32_t); \ + *(u_int32_t *)p = data->size; \ + p += sizeof(u_int32_t); \ + *(u_char *)p = flags; \ + p += sizeof(u_char); \ + memmove(p, key->data, key->size); \ + p += key->size; \ + memmove(p, data->data, data->size); \ +} + +/* For the recno leaf pages, the item is a data entry. */ +typedef struct _rleaf { + u_int32_t dsize; /* size of data */ + u_char flags; /* P_BIGDATA */ + char bytes[1]; +} RLEAF; + +/* Get the page's RLEAF structure at index indx. */ +#define GETRLEAF(pg, indx) \ + ((RLEAF *)((char *)(pg) + (pg)->linp[indx])) + +/* Get the number of bytes in the entry. */ +#define NRLEAF(p) NRLEAFDBT((p)->dsize) + +/* Get the number of bytes from the user's data. */ +#define NRLEAFDBT(dsize) \ + LALIGN(sizeof(u_int32_t) + sizeof(u_char) + (dsize)) + +/* Copy a RLEAF entry to the page. */ +#define WR_RLEAF(p, data, flags) { \ + *(u_int32_t *)p = data->size; \ + p += sizeof(u_int32_t); \ + *(u_char *)p = flags; \ + p += sizeof(u_char); \ + memmove(p, data->data, data->size); \ +} + +/* + * A record in the tree is either a pointer to a page and an index in the page + * or a page number and an index. These structures are used as a cursor, stack + * entry and search returns as well as to pass records to other routines. + * + * One comment about searches. Internal page searches must find the largest + * record less than key in the tree so that descents work. Leaf page searches + * must find the smallest record greater than key so that the returned index + * is the record's correct position for insertion. + */ +typedef struct _epgno { + pgno_t pgno; /* the page number */ + indx_t index; /* the index on the page */ +} EPGNO; + +typedef struct _epg { + PAGE *page; /* the (pinned) page */ + indx_t index; /* the index on the page */ +} EPG; + +/* + * About cursors. The cursor (and the page that contained the key/data pair + * that it referenced) can be deleted, which makes things a bit tricky. If + * there are no duplicates of the cursor key in the tree (i.e. B_NODUPS is set + * or there simply aren't any duplicates of the key) we copy the key that it + * referenced when it's deleted, and reacquire a new cursor key if the cursor + * is used again. If there are duplicates keys, we move to the next/previous + * key, and set a flag so that we know what happened. NOTE: if duplicate (to + * the cursor) keys are added to the tree during this process, it is undefined + * if they will be returned or not in a cursor scan. + * + * The flags determine the possible states of the cursor: + * + * CURS_INIT The cursor references *something*. + * CURS_ACQUIRE The cursor was deleted, and a key has been saved so that + * we can reacquire the right position in the tree. + * CURS_AFTER, CURS_BEFORE + * The cursor was deleted, and now references a key/data pair + * that has not yet been returned, either before or after the + * deleted key/data pair. + * XXX + * This structure is broken out so that we can eventually offer multiple + * cursors as part of the DB interface. + */ +typedef struct _cursor { + EPGNO pg; /* B: Saved tree reference. */ + DBT key; /* B: Saved key, or key.data == NULL. */ + recno_t rcursor; /* R: recno cursor (1-based) */ + +#define CURS_ACQUIRE 0x01 /* B: Cursor needs to be reacquired. */ +#define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ +#define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ +#define CURS_INIT 0x08 /* RB: Cursor initialized. */ + u_int8_t flags; +} CURSOR; + +/* + * The metadata of the tree. The nrecs field is used only by the RECNO code. + * This is because the btree doesn't really need it and it requires that every + * put or delete call modify the metadata. + */ +typedef struct _btmeta { + u_int32_t magic; /* magic number */ + u_int32_t version; /* version */ + u_int32_t psize; /* page size */ + u_int32_t free; /* page number of first free page */ + u_int32_t nrecs; /* R: number of records */ + +#define SAVEMETA (B_NODUPS | R_RECNO) + u_int32_t flags; /* bt_flags & SAVEMETA */ +} BTMETA; + +/* The in-memory btree/recno data structure. */ +typedef struct _btree { + MPOOL *bt_mp; /* memory pool cookie */ + + DB *bt_dbp; /* pointer to enclosing DB */ + + EPG bt_cur; /* current (pinned) page */ + PAGE *bt_pinned; /* page pinned across calls */ + + CURSOR bt_cursor; /* cursor */ + +#define BT_PUSH(t, p, i) { \ + t->bt_sp->pgno = p; \ + t->bt_sp->index = i; \ + ++t->bt_sp; \ +} +#define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL : --t->bt_sp) +#define BT_CLR(t) (t->bt_sp = t->bt_stack) + EPGNO bt_stack[50]; /* stack of parent pages */ + EPGNO *bt_sp; /* current stack pointer */ + + DBT bt_rkey; /* returned key */ + DBT bt_rdata; /* returned data */ + + virt_fd_t bt_fd; /* tree virtual file descriptor */ + + pgno_t bt_free; /* next free page */ + u_int32_t bt_psize; /* page size */ + indx_t bt_ovflsize; /* cut-off for key/data overflow */ + int bt_lorder; /* byte order */ + /* sorted order */ + enum { NOT, BACK, FORWARD } bt_order; + EPGNO bt_last; /* last insert */ + + /* B: key comparison function */ + int (*bt_cmp) __P((const DBT *, const DBT *)); + /* B: prefix comparison function */ + size_t (*bt_pfx) __P((const DBT *, const DBT *)); + /* R: recno input function */ + int (*bt_irec) __P((struct _btree *, recno_t)); + + FILE *bt_rfp; /* R: record FILE pointer */ + int bt_rfd; /* R: record file descriptor */ + + caddr_t bt_cmap; /* R: current point in mapped space */ + caddr_t bt_smap; /* R: start of mapped space */ + caddr_t bt_emap; /* R: end of mapped space */ + size_t bt_msize; /* R: size of mapped region. */ + + recno_t bt_nrecs; /* R: number of records */ + size_t bt_reclen; /* R: fixed record length */ + u_char bt_bval; /* R: delimiting byte/pad character */ + +/* + * NB: + * B_NODUPS and R_RECNO are stored on disk, and may not be changed. + */ +#define B_INMEM 0x00001 /* in-memory tree */ +#define B_METADIRTY 0x00002 /* need to write metadata */ +#define B_MODIFIED 0x00004 /* tree modified */ +#define B_NEEDSWAP 0x00008 /* if byte order requires swapping */ +#define B_RDONLY 0x00010 /* read-only tree */ + +#define B_NODUPS 0x00020 /* no duplicate keys permitted */ +#define R_RECNO 0x00080 /* record oriented tree */ + +#define R_CLOSEFP 0x00040 /* opened a file pointer */ +#define R_EOF 0x00100 /* end of input file reached. */ +#define R_FIXLEN 0x00200 /* fixed length records */ +#define R_MEMMAPPED 0x00400 /* memory mapped file. */ +#define R_INMEM 0x00800 /* in-memory file */ +#define R_MODIFIED 0x01000 /* modified file */ +#define R_RDONLY 0x02000 /* read-only file */ + +#define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ +#define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ +#define B_DB_TXN 0x10000 /* DB_TXN specified. */ + u_int32_t flags; +} BTREE; + +#include "extern.h" diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/extern.h b/user/mpy/lib/berkeley-db-1.xx/btree/extern.h new file mode 100644 index 0000000..ebd9c54 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/extern.h @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)extern.h 8.10 (Berkeley) 7/20/94 + */ + +int __bt_close __P((DB *)); +int __bt_cmp __P((BTREE *, const DBT *, EPG *)); +int __bt_crsrdel __P((BTREE *, EPGNO *)); +int __bt_defcmp __P((const DBT *, const DBT *)); +size_t __bt_defpfx __P((const DBT *, const DBT *)); +int __bt_delete __P((const DB *, const DBT *, u_int)); +int __bt_dleaf __P((BTREE *, const DBT *, PAGE *, u_int)); +int __bt_fd __P((const DB *)); +int __bt_free __P((BTREE *, PAGE *)); +int __bt_get __P((const DB *, const DBT *, DBT *, u_int)); +PAGE *__bt_new __P((BTREE *, pgno_t *)); +void __bt_pgin __P((void *, pgno_t, void *)); +void __bt_pgout __P((void *, pgno_t, void *)); +int __bt_push __P((BTREE *, pgno_t, int)); +int __bt_put __P((const DB *dbp, DBT *, const DBT *, u_int)); +int __bt_ret __P((BTREE *, EPG *, DBT *, DBT *, DBT *, DBT *, int)); +EPG *__bt_search __P((BTREE *, const DBT *, int *)); +int __bt_seq __P((const DB *, DBT *, DBT *, u_int)); +void __bt_setcur __P((BTREE *, pgno_t, u_int)); +int __bt_split __P((BTREE *, PAGE *, + const DBT *, const DBT *, int, size_t, u_int32_t)); +int __bt_sync __P((const DB *, u_int)); + +int __ovfl_delete __P((BTREE *, void *)); +int __ovfl_get __P((BTREE *, void *, size_t *, void **, size_t *)); +int __ovfl_put __P((BTREE *, const DBT *, pgno_t *)); + +#ifdef DEBUG +void __bt_dnpage __P((DB *, pgno_t)); +void __bt_dpage __P((PAGE *)); +void __bt_dump __P((DB *)); +#endif +#ifdef STATISTICS +void __bt_stat __P((DB *)); +#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/tags b/user/mpy/lib/berkeley-db-1.xx/btree/tags new file mode 120000 index 0000000..7ab656b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/btree/tags @@ -0,0 +1 @@ +../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/changelog b/user/mpy/lib/berkeley-db-1.xx/changelog new file mode 100644 index 0000000..1540ca8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/changelog @@ -0,0 +1,103 @@ +1.84 -> 1.85 + recno: #ifdef out use of mmap, it's not portable enough. + +1.83 -> 1.84 Thu Aug 18 15:46:07 EDT 1994 + recno: Rework fixed-length records so that closing and reopening + the file now works. Pad short records on input. Never do + signed comparison in recno input reading functions. + +1.82 -> 1.83 Tue Jul 26 15:33:44 EDT 1994 + btree: Rework cursor deletion code yet again; bugs with + deleting empty pages that only contained the cursor + record. + +1.81 -> 1.82 Sat Jul 16 11:01:50 EDT 1994 + btree: Fix bugs introduced by new cursor/deletion code. + Replace return kbuf/dbuf with real DBT's. + +1.80 -> 1.81 + btree: Fix bugs introduced by new cursor/deletion code. + all: Add #defines for Purify. + +1.79 -> 1.80 Wed Jul 13 22:41:54 EDT 1994 + btree Change deletion to coalesce empty pages. This is a major + change, cursors and duplicate pages all had to be reworked. + Return to a fixed stack. + recno: Affected by cursor changes. New cursor structures should + permit multiple cursors in the future. + +1.78 -> 1.79 Mon Jun 20 17:36:47 EDT 1994 + all: Minor cleanups of 1.78 for porting reasons; only + major change was inlining check of NULL pointer + so that __fix_realloc goes away. + +1.77 -> 1.78 Thu Jun 16 19:06:43 EDT 1994 + all: Move "standard" size typedef's into db.h. + +1.76 -> 1.77 Thu Jun 16 16:48:38 EDT 1994 + hash: Delete __init_ routine, has special meaning to OSF 2.0. + +1.74 -> 1.76 + all: Finish up the port to the Alpha. + +1.73 -> 1.74 + recno: Don't put the record if rec_search fails, in rec_rdelete. + Create fixed-length intermediate records past "end" of DB + correctly. + Realloc bug when reading in fixed records. + all: First cut at port to Alpha (64-bit architecture) using + 4.4BSD basic integral types typedef's. + Cast allocation pointers to shut up old compilers. + Rework PORT directory into OS/machine directories. + +1.72 -> 1.73 + btree: If enough duplicate records were inserted and then deleted + that internal pages had references to empty pages of the + duplicate keys, the search function ended up on the wrong + page. + +1.7 -> 1.72 12 Oct 1993 + hash: Support NET/2 hash formats. + +1.7 -> 1.71 16 Sep 1993 + btree/recno: + Fix bug in internal search routines that caused + return of invalid pointers. + +1.6 -> 1.7 07 Sep 1993 + hash: Fixed big key overflow bugs. + test: Portability hacks, rewrite test script, Makefile. + btree/recno: + Stop copying non-overflow key/data pairs. + PORT: Break PORT directory up into per architecture/OS + subdirectories. + +1.5 -> 1.6 06 Jun 1993 + hash: In PAIRFITS, the first comparison should look at (P)[2]. + The hash_realloc function was walking off the end of memory. + The overflow page number was wrong when bumping splitpoint. + +1.4 -> 1.5 23 May 1993 + hash: Set hash default fill factor dynamically. + recno: Fixed bug in sorted page splits. + Add page size parameter support. + Allow recno to specify the name of the underlying btree; + used for vi recovery. + btree/recno: + Support 64K pages. + btree/hash/recno: + Provide access to an underlying file descriptor. + Change sync routines to take a flag argument, recno + uses this to sync out the underlying btree. + +1.3 -> 1.4 10 May 1993 + recno: Delete the R_CURSORLOG flag from the recno interface. + Zero-length record fix for non-mmap reads. + Try and make SIZE_T_MAX test in open portable. + +1.2 -> 1.3 01 May 1993 + btree: Ignore user byte-order setting when reading already + existing database. Fixes to byte-order conversions. + +1.1 -> 1.2 15 Apr 1993 + No bug fixes, only compatibility hacks. diff --git a/user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc new file mode 100644 index 0000000..59478ba --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc @@ -0,0 +1,5 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 + +.PATH: ${.CURDIR}/db/db + +SRCS+= db.c diff --git a/user/mpy/lib/berkeley-db-1.xx/db/db.c b/user/mpy/lib/berkeley-db-1.xx/db/db.c new file mode 100644 index 0000000..a18f056 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/db/db.c @@ -0,0 +1,99 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +#include + +DB * +dbopen(fname, flags, mode, type, openinfo) + const char *fname; + int flags, mode; + DBTYPE type; + const void *openinfo; +{ + +#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) +#define USE_OPEN_FLAGS \ + (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \ + O_RDWR | O_SHLOCK | O_TRUNC) + + if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) + switch (type) { + case DB_BTREE: + return (__bt_open(fname, flags & USE_OPEN_FLAGS, + mode, openinfo, flags & DB_FLAGS)); + case DB_HASH: + return (__hash_open(fname, flags & USE_OPEN_FLAGS, + mode, openinfo, flags & DB_FLAGS)); + case DB_RECNO: + return (__rec_open(fname, flags & USE_OPEN_FLAGS, + mode, openinfo, flags & DB_FLAGS)); + } + errno = EINVAL; + return (NULL); +} + +static int +__dberr() +{ + return (RET_ERROR); +} + +/* + * __DBPANIC -- Stop. + * + * Parameters: + * dbp: pointer to the DB structure. + */ +void +__dbpanic(dbp) + DB *dbp; +{ + /* The only thing that can succeed is a close. */ + dbp->del = (int (*)())__dberr; + dbp->fd = (int (*)())__dberr; + dbp->get = (int (*)())__dberr; + dbp->put = (int (*)())__dberr; + dbp->seq = (int (*)())__dberr; + dbp->sync = (int (*)())__dberr; +} diff --git a/user/mpy/lib/berkeley-db-1.xx/db/tags b/user/mpy/lib/berkeley-db-1.xx/db/tags new file mode 100644 index 0000000..f9c1143 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/db/tags @@ -0,0 +1,205 @@ +BT_CLR ../btree/btree.h /^#define BT_CLR(t) (t->bt_sp = t->bt_stack)$/ +BT_POP ../btree/btree.h /^#define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL / +BT_PUSH ../btree/btree.h /^#define BT_PUSH(t, p, i) { \\$/ +BUCKET_TO_PAGE ../hash/hash.h /^#define BUCKET_TO_PAGE(B) \\$/ +BUF_INSERT ../hash/hash_buf.c /^#define BUF_INSERT(B, P) { \\$/ +BUF_REMOVE ../hash/hash_buf.c /^#define BUF_REMOVE(B) { \\$/ +CLRBIT ../hash/hash.h /^#define CLRBIT(A, N) ((A)[(N)\/BITS_PER_MAP] &= ~(/ +DODISK ../hash/hash.h /^#define DODISK(X) ((X) = (char *)((ptrdiff_t)(X)|0/ +DOMOD ../hash/hash.h /^#define DOMOD(X) ((X) = (char *)((ptrdiff_t)(X)|0x/ +FREESPACE ../hash/page.h /^#define FREESPACE(P) ((P)[(P)[0]+1])$/ +F_CLR ../btree/btree.h /^#define F_CLR(p, f) (p)->flags &= ~(f)$/ +F_ISSET ../btree/btree.h /^#define F_ISSET(p, f) ((p)->flags & (f))$/ +F_SET ../btree/btree.h /^#define F_SET(p, f) (p)->flags |= (f)$/ +GETBINTERNAL ../btree/btree.h /^#define GETBINTERNAL(pg, indx) \\$/ +GETBLEAF ../btree/btree.h /^#define GETBLEAF(pg, indx) \\$/ +GETRINTERNAL ../btree/btree.h /^#define GETRINTERNAL(pg, indx) \\$/ +GETRLEAF ../btree/btree.h /^#define GETRLEAF(pg, indx) \\$/ +HASHKEY ../include/mpool.h /^#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE)$/ +ISDISK ../hash/hash.h /^#define ISDISK(X) ((u_int32_t)(ptrdiff_t)(X)&0x2)$/ +ISMOD ../hash/hash.h /^#define ISMOD(X) ((u_int32_t)(ptrdiff_t)(X)&0x1)$/ +ISSET ../hash/hash.h /^#define ISSET(A, N) ((A)[(N)\/BITS_PER_MAP] & (1<siz/ +LALIGN ../btree/btree.h /^#define LALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(/ +LRU_INSERT ../hash/hash_buf.c /^#define LRU_INSERT(B) BUF_INSERT((B), LRU)$/ +MOD ../hash/hash.c /^#define MOD(x, y) ((x) & ((y) - 1))$/ +MRU_INSERT ../hash/hash_buf.c /^#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufh/ +M_16_SWAP ../include/db.h /^#define M_16_SWAP(a) { \\$/ +M_32_SWAP ../include/db.h /^#define M_32_SWAP(a) { \\$/ +NBINTERNAL ../btree/btree.h /^#define NBINTERNAL(len) \\$/ +NBLEAF ../btree/btree.h /^#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize/ +NBLEAFDBT ../btree/btree.h /^#define NBLEAFDBT(ksize, dsize) \\$/ +NEXTINDEX ../btree/btree.h /^#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) \/ / +NRLEAF ../btree/btree.h /^#define NRLEAF(p) NRLEAFDBT((p)->dsize)$/ +NRLEAFDBT ../btree/btree.h /^#define NRLEAFDBT(dsize) \\$/ +OADDR_OF ../hash/hash.h /^#define OADDR_OF(S,O) ((u_int32_t)((u_int32_t)(S) / +OADDR_TO_PAGE ../hash/hash.h /^#define OADDR_TO_PAGE(B) \\$/ +OFFSET ../hash/page.h /^#define OFFSET(P) ((P)[(P)[0]+2])$/ +OPAGENUM ../hash/hash.h /^#define OPAGENUM(N) ((N) & SPLITMASK)$/ +PAGE_INIT ../hash/hash_page.c /^#define PAGE_INIT(P) { \\$/ +PAGE_META ../hash/page.h /^#define PAGE_META(N) (((N)+3) * sizeof(u_int16_t))/ +PAIRFITS ../hash/page.h /^#define PAIRFITS(P,K,D) \\$/ +PAIRSIZE ../hash/page.h /^#define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->/ +PTROF ../hash/hash.h /^#define PTROF(X) ((BUFHEAD *)((ptrdiff_t)(X)&~0x3)/ +P_16_COPY ../include/db.h /^#define P_16_COPY(a, b) { \\$/ +P_16_SWAP ../include/db.h /^#define P_16_SWAP(a) { \\$/ +P_32_COPY ../include/db.h /^#define P_32_COPY(a, b) { \\$/ +P_32_SWAP ../include/db.h /^#define P_32_SWAP(a) { \\$/ +RETURN_ERROR ../hash/hash.c /^#define RETURN_ERROR(ERR, LOC) { save_errno = ERR;/ +SETBIT ../hash/hash.h /^#define SETBIT(A, N) ((A)[(N)\/BITS_PER_MAP] |= (1/ +SPLITNUM ../hash/hash.h /^#define SPLITNUM(N) (((u_int32_t)(N)) >> SPLITSHIF/ +WR_BINTERNAL ../btree/btree.h /^#define WR_BINTERNAL(p, size, pgno, flags) { \\/ +WR_BLEAF ../btree/btree.h /^#define WR_BLEAF(p, key, data, flags) { \\$/ +WR_RINTERNAL ../btree/btree.h /^#define WR_RINTERNAL(p, nrecs, pgno) { \\$/ +WR_RLEAF ../btree/btree.h /^#define WR_RLEAF(p, data, flags) { \\$/ +X ../btree/bt_debug.c /^#define X(flag, name) \\$/ +__add_ovflpage ../hash/hash_page.c /^__add_ovflpage(hashp, bufp)$/ +__addel ../hash/hash_page.c /^__addel(hashp, bufp, key, val)$/ +__big_delete ../hash/hash_bigkey.c /^__big_delete(hashp, bufp)$/ +__big_insert ../hash/hash_bigkey.c /^__big_insert(hashp, bufp, key, val)$/ +__big_keydata ../hash/hash_bigkey.c /^__big_keydata(hashp, bufp, key, val, set)$/ +__big_return ../hash/hash_bigkey.c /^__big_return(hashp, bufp, ndx, val, set_current)$/ +__big_split ../hash/hash_bigkey.c /^__big_split(hashp, op, np, big_keyp, addr, obucket/ +__bt_bdelete ../btree/bt_delete.c /^__bt_bdelete(t, key)$/ +__bt_close ../btree/bt_close.c /^__bt_close(dbp)$/ +__bt_cmp ../btree/bt_utils.c /^__bt_cmp(t, k1, e)$/ +__bt_curdel ../btree/bt_delete.c /^__bt_curdel(t, key, h, index)$/ +__bt_defcmp ../btree/bt_utils.c /^__bt_defcmp(a, b)$/ +__bt_defpfx ../btree/bt_utils.c /^__bt_defpfx(a, b)$/ +__bt_delete ../btree/bt_delete.c /^__bt_delete(dbp, key, flags)$/ +__bt_dleaf ../btree/bt_delete.c /^__bt_dleaf(t, key, h, index)$/ +__bt_dmpage ../btree/bt_debug.c /^__bt_dmpage(h)$/ +__bt_dnpage ../btree/bt_debug.c /^__bt_dnpage(dbp, pgno)$/ +__bt_dpage ../btree/bt_debug.c /^__bt_dpage(h)$/ +__bt_dump ../btree/bt_debug.c /^__bt_dump(dbp)$/ +__bt_fd ../btree/bt_open.c /^__bt_fd(dbp)$/ +__bt_first ../btree/bt_seq.c /^__bt_first(t, key, erval, exactp)$/ +__bt_free ../btree/bt_page.c /^__bt_free(t, h)$/ +__bt_get ../btree/bt_get.c /^__bt_get(dbp, key, data, flags)$/ +__bt_new ../btree/bt_page.c /^__bt_new(t, npg)$/ +__bt_open ../btree/bt_open.c /^__bt_open(fname, flags, mode, openinfo, dflags)$/ +__bt_pdelete ../btree/bt_delete.c /^__bt_pdelete(t, h)$/ +__bt_pgin ../btree/bt_conv.c /^__bt_pgin(t, pg, pp)$/ +__bt_pgout ../btree/bt_conv.c /^__bt_pgout(t, pg, pp)$/ +__bt_put ../btree/bt_put.c /^__bt_put(dbp, key, data, flags)$/ +__bt_relink ../btree/bt_delete.c /^__bt_relink(t, h)$/ +__bt_ret ../btree/bt_utils.c /^__bt_ret(t, e, key, rkey, data, rdata, copy)$/ +__bt_search ../btree/bt_search.c /^__bt_search(t, key, exactp)$/ +__bt_seq ../btree/bt_seq.c /^__bt_seq(dbp, key, data, flags)$/ +__bt_seqadv ../btree/bt_seq.c /^__bt_seqadv(t, ep, flags)$/ +__bt_seqset ../btree/bt_seq.c /^__bt_seqset(t, ep, key, flags)$/ +__bt_setcur ../btree/bt_seq.c /^__bt_setcur(t, pgno, index)$/ +__bt_snext ../btree/bt_search.c /^__bt_snext(t, h, key, exactp)$/ +__bt_split ../btree/bt_split.c /^__bt_split(t, sp, key, data, flags, ilen, argskip)/ +__bt_sprev ../btree/bt_search.c /^__bt_sprev(t, h, key, exactp)$/ +__bt_stat ../btree/bt_debug.c /^__bt_stat(dbp)$/ +__bt_stkacq ../btree/bt_delete.c /^__bt_stkacq(t, hp, c)$/ +__bt_sync ../btree/bt_close.c /^__bt_sync(dbp, flags)$/ +__buf_free ../hash/hash_buf.c /^__buf_free(hashp, do_free, to_disk)$/ +__buf_init ../hash/hash_buf.c /^__buf_init(hashp, nbytes)$/ +__call_hash ../hash/hash.c /^__call_hash(hashp, k, len)$/ +__dberr ../db/db.c /^__dberr()$/ +__dbpanic ../db/db.c /^__dbpanic(dbp)$/ +__delpair ../hash/hash_page.c /^__delpair(hashp, bufp, ndx)$/ +__expand_table ../hash/hash.c /^__expand_table(hashp)$/ +__find_bigpair ../hash/hash_bigkey.c /^__find_bigpair(hashp, bufp, ndx, key, size)$/ +__find_last_page ../hash/hash_bigkey.c /^__find_last_page(hashp, bpp)$/ +__free_ovflpage ../hash/hash_page.c /^__free_ovflpage(hashp, obufp)$/ +__get_buf ../hash/hash_buf.c /^__get_buf(hashp, addr, prev_bp, newpage)$/ +__get_page ../hash/hash_page.c /^__get_page(hashp, p, bucket, is_bucket, is_disk, i/ +__hash_open ../hash/hash.c /^__hash_open(file, flags, mode, info, dflags)$/ +__ibitmap ../hash/hash_page.c /^__ibitmap(hashp, pnum, nbits, ndx)$/ +__log2 ../hash/hash_log2.c /^__log2(num)$/ +__ovfl_delete ../btree/bt_overflow.c /^__ovfl_delete(t, p)$/ +__ovfl_get ../btree/bt_overflow.c /^__ovfl_get(t, p, ssz, buf, bufsz)$/ +__ovfl_put ../btree/bt_overflow.c /^__ovfl_put(t, dbt, pg)$/ +__put_page ../hash/hash_page.c /^__put_page(hashp, p, bucket, is_bucket, is_bitmap)/ +__rec_close ../recno/rec_close.c /^__rec_close(dbp)$/ +__rec_delete ../recno/rec_delete.c /^__rec_delete(dbp, key, flags)$/ +__rec_dleaf ../recno/rec_delete.c /^__rec_dleaf(t, h, index)$/ +__rec_fd ../recno/rec_open.c /^__rec_fd(dbp)$/ +__rec_fmap ../recno/rec_get.c /^__rec_fmap(t, top)$/ +__rec_fpipe ../recno/rec_get.c /^__rec_fpipe(t, top)$/ +__rec_get ../recno/rec_get.c /^__rec_get(dbp, key, data, flags)$/ +__rec_iput ../recno/rec_put.c /^__rec_iput(t, nrec, data, flags)$/ +__rec_open ../recno/rec_open.c /^__rec_open(fname, flags, mode, openinfo, dflags)$/ +__rec_put ../recno/rec_put.c /^__rec_put(dbp, key, data, flags)$/ +__rec_ret ../recno/rec_utils.c /^__rec_ret(t, e, nrec, key, data)$/ +__rec_search ../recno/rec_search.c /^__rec_search(t, recno, op)$/ +__rec_seq ../recno/rec_seq.c /^__rec_seq(dbp, key, data, flags)$/ +__rec_sync ../recno/rec_close.c /^__rec_sync(dbp, flags)$/ +__rec_vmap ../recno/rec_get.c /^__rec_vmap(t, top)$/ +__rec_vpipe ../recno/rec_get.c /^__rec_vpipe(t, top)$/ +__reclaim_buf ../hash/hash_buf.c /^__reclaim_buf(hashp, bp)$/ +__split_page ../hash/hash_page.c /^__split_page(hashp, obucket, nbucket)$/ +alloc_segs ../hash/hash.c /^alloc_segs(hashp, nsegs)$/ +bt_broot ../btree/bt_split.c /^bt_broot(t, h, l, r)$/ +bt_fast ../btree/bt_put.c /^bt_fast(t, key, data, exactp)$/ +bt_meta ../btree/bt_close.c /^bt_meta(t)$/ +bt_page ../btree/bt_split.c /^bt_page(t, h, lp, rp, skip, ilen)$/ +bt_preserve ../btree/bt_split.c /^bt_preserve(t, pg)$/ +bt_psplit ../btree/bt_split.c /^bt_psplit(t, h, l, r, pskip, ilen)$/ +bt_root ../btree/bt_split.c /^bt_root(t, h, lp, rp, skip, ilen)$/ +bt_rroot ../btree/bt_split.c /^bt_rroot(t, h, l, r)$/ +byteorder ../btree/bt_open.c /^byteorder()$/ +collect_data ../hash/hash_bigkey.c /^collect_data(hashp, bufp, len, set)$/ +collect_key ../hash/hash_bigkey.c /^collect_key(hashp, bufp, len, val, set)$/ +dbm_clearerr ../hash/ndbm.c /^dbm_clearerr(db)$/ +dbm_close ../hash/ndbm.c /^dbm_close(db)$/ +dbm_delete ../hash/ndbm.c /^dbm_delete(db, key)$/ +dbm_dirfno ../hash/ndbm.c /^dbm_dirfno(db)$/ +dbm_error ../hash/ndbm.c /^dbm_error(db)$/ +dbm_fetch ../hash/ndbm.c /^dbm_fetch(db, key)$/ +dbm_firstkey ../hash/ndbm.c /^dbm_firstkey(db)$/ +dbm_nextkey ../hash/ndbm.c /^dbm_nextkey(db)$/ +dbm_open ../hash/ndbm.c /^dbm_open(file, flags, mode)$/ +dbm_store ../hash/ndbm.c /^dbm_store(db, key, content, flags)$/ +dbopen ../db/db.c /^dbopen(fname, flags, mode, type, openinfo)$/ +dcharhash ../hash/hash_func.c /^#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x/ +fetch_bitmap ../hash/hash_page.c /^fetch_bitmap(hashp, ndx)$/ +first_free ../hash/hash_page.c /^first_free(map)$/ +flush_meta ../hash/hash.c /^flush_meta(hashp)$/ +hash2 ../hash/hash_func.c /^hash2(keyarg, len)$/ +hash3 ../hash/hash_func.c /^hash3(keyarg, len)$/ +hash4 ../hash/hash_func.c /^hash4(keyarg, len)$/ +hash_access ../hash/hash.c /^hash_access(hashp, action, key, val)$/ +hash_close ../hash/hash.c /^hash_close(dbp)$/ +hash_delete ../hash/hash.c /^hash_delete(dbp, key, flag)$/ +hash_fd ../hash/hash.c /^hash_fd(dbp)$/ +hash_get ../hash/hash.c /^hash_get(dbp, key, data, flag)$/ +hash_put ../hash/hash.c /^hash_put(dbp, key, data, flag)$/ +hash_realloc ../hash/hash.c /^hash_realloc(p_ptr, oldsize, newsize)$/ +hash_seq ../hash/hash.c /^hash_seq(dbp, key, data, flag)$/ +hash_sync ../hash/hash.c /^hash_sync(dbp, flags)$/ +hcreate ../hash/hsearch.c /^hcreate(nel)$/ +hdestroy ../hash/hash.c /^hdestroy(hashp)$/ +hsearch ../hash/hsearch.c /^hsearch(item, action)$/ +init_hash ../hash/hash.c /^init_hash(hashp, file, info)$/ +init_htab ../hash/hash.c /^init_htab(hashp, nelem)$/ +mpool_bkt ../mpool/mpool.c /^mpool_bkt(mp)$/ +mpool_close ../mpool/mpool.c /^mpool_close(mp)$/ +mpool_filter ../mpool/mpool.c /^mpool_filter(mp, pgin, pgout, pgcookie)$/ +mpool_get ../mpool/mpool.c /^mpool_get(mp, pgno, flags)$/ +mpool_look ../mpool/mpool.c /^mpool_look(mp, pgno)$/ +mpool_new ../mpool/mpool.c /^mpool_new(mp, pgnoaddr)$/ +mpool_open ../mpool/mpool.c /^mpool_open(key, fd, pagesize, maxcache)$/ +mpool_put ../mpool/mpool.c /^mpool_put(mp, page, flags)$/ +mpool_stat ../mpool/mpool.c /^mpool_stat(mp)$/ +mpool_sync ../mpool/mpool.c /^mpool_sync(mp)$/ +mpool_write ../mpool/mpool.c /^mpool_write(mp, bp)$/ +mswap ../btree/bt_conv.c /^mswap(pg)$/ +newbuf ../hash/hash_buf.c /^newbuf(hashp, addr, prev_bp)$/ +nroot ../btree/bt_open.c /^nroot(t)$/ +open_temp ../hash/hash_page.c /^open_temp(hashp)$/ +overflow_page ../hash/hash_page.c /^overflow_page(hashp)$/ +print_chain ../hash/hash_page.c /^print_chain(addr)$/ +putpair ../hash/hash_page.c /^putpair(p, key, val)$/ +rec_rdelete ../recno/rec_delete.c /^rec_rdelete(t, nrec)$/ +rec_total ../btree/bt_split.c /^rec_total(h)$/ +squeeze_key ../hash/hash_page.c /^squeeze_key(sp, key, val)$/ +swap_header ../hash/hash.c /^swap_header(hashp)$/ +swap_header_copy ../hash/hash.c /^swap_header_copy(srcp, destp)$/ +tmp ../btree/bt_open.c /^tmp()$/ +u_int32_t ../hash/extern.h /^extern u_int32_t (*__default_hash) __P((const void/ +ugly_split ../hash/hash_page.c /^ugly_split(hashp, obucket, old_bufp, new_bufp, cop/ diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps new file mode 100644 index 0000000000000000000000000000000000000000..c79c97232ccc4cf3e96fc896cba56020878922a2 GIT binary patch literal 16754 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 SJdpC|8`K)K%_mo9&i?|$3`J@H literal 0 HcmV?d00001 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps new file mode 100644 index 0000000000000000000000000000000000000000..c621bef97db51a132b8902ceefcf72bb955c8992 GIT binary patch literal 26477 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%0D0u}#;uT9jcxHw_Q*z~&sUkGj1Ijlf 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 literal 0 HcmV?d00001 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps new file mode 100644 index 0000000000000000000000000000000000000000..18303cfb7cd25528580455f93b1c8afed2cb6fee GIT binary patch literal 11349 zcmd5?S##S+l77dpsEvt^1!pA`0p9M3jnzR)nvo@0l&7bs-O*75iX>Vfz{Vko&G3KU zFS80DWV^?Hn1^|=iK8m-{4y({@BZs@@%;jPdYE+ zEET@j9pmkJ7FHXbmN!~QI=a_IR^_2C-iT$Emf|7a=;HW3+o%+4|EK-%G)tmSpIwzI ziNhAvd9~dp@hiI9JPQk5k~G_br4S_Lomvssz+T?wk%q`8MW|C^bDPHyQk9VWjkwG5 zGFNel=hHMg%QmDyfxA<^iqpG1OR`mcS8Mb}e37w)C|eai#_38tuXV2X&NkaRVU_2g zY2P?yUTJYy>3ocrjBApStOZ?%!AW?SI~QL z>Zo9s!KnfQdvto7;} z#JPC2{ELEJe!k=zM7+W-Cie$&{`J%M-yrPYKHu|2iLd`)-8YE+cK-+R-ZU@1LD1XQ z;x9^g_vwOf5bfRm%O1b4pMQg3^TXON%JuNc`)?3yKHED>gg1i<5p{lI(v&nd1nf_$ zS9sF>d7~aRt#)V$Qjf2B6QwNE37=km#y`>IO)G=mwir4;)rsPCk$5)moPQIiL_g^S z5}WkCpU&&cyX*Suy7la0@2m>-q(!Qqx2jx=Fp0N(LH{il*$a?S7XWPSu!#UiLPe3u z6T+sJmZx`nM_K`xC}ECI=1SsJhiZGc`85MFjRHXeM)4EFRS~L0JJ<8QGXYd&fLHB& z+`~u^9RQma2|tOKIw>?r0kX`NmIzabU?r%k6XBBXg9yMn9{E-tMNVTLrzur6Z8^`1bU6Gv#A3u}k z{OlkwqGs3?5F5_Q3Qdk`>-O+gY*d-YFD3-er+WvFYzeV%$Z?HHjTM^+py2Ta`0sNr zpaW+b8f}*MXEFx^#`Z&PxxbdVRp{_={veHZts?aHL0XtNtUJ4wjdrc2Gg!>3vdY!Y z_yaQW%`!#-vo~$=POl}uI#9poR2bWYOkrgdxWUnaCHvr?vV{2_mn^QhqWBV9}!(DNgO#%!z`k* zZ-5Ai1Ee{yYMxrp(^lpKmvDsS$Dbaen%lpG4?b9CEdZITig{6=l1#S}I@(k!mk64HX`uTgkV1jLx&w zj5S-Dx4hoMi6hBoAwZ!d9~C9KIW|mH=$yS~yRsUV_8-Y?EjQf34G8i?tK9j74v_{5 z?ct=4x!$6YHeiPuVlnza#|8&$|Am$k+STnOwU6Ao*3BvIuF^26B3(cEV*mZG*4TFZ zUoElSx#?TkD3asSw+*abibI^rYVUQszSvYrqoRO{k_rgw2y7_tuAR}uT%yDoH_`Ly z%~|&+sfsX;!x%WVG1q0BL|V>6m1n8^r};s2(%tX;5a-C-&EjAz8rr+L6e?L~V>t(ISy)wOP=CY?aCgrva7At;YE) zEv4Gvs!*^v8z7HY>r!qNjwOj+mX5hJPgQ|5jEhIPO{zkMI1eeg-fh=9C2DaNNmTM; zEq~W}CbLw_@;Q^`I@ek*aolqN)=yd%@e30737a(YN&#~qmcTuQ-o)lA(M2KkZM{oFNxr9SNK`!YBzY(!2 zinzY`6}AWb%XO8mR9_P zYPqR6Z4|7xUE9$j0{fnabgviiBO<}gMl%jJLn7gV{z|-6%2#1T>jsk z07sjt!2fRXw&NUogMqlHcdHbIL^L!yy?)p8M@&P`d@*^gI=CKt{@A@aAx7iAm^<#< zX$OzMVAgflz)Wf*=sWt6+{SieJ;u1^-E=S)Hq=YDd7z!vFK3IMWU5G4Ab{#M1i<#q+SywrEL2hH3G`XBF9^_{hgI+s$%6RAD?WeJ{#6BBoE&r5&fLWE@4>rJ^|^S1 z7Z|`yUCIOinH5&-txX0KUPuSIMG^n5zwh|{z6eHs^Egy6O6%2_RD0*rj-^>VVP-%K z-(4!h@4^i+82cV657yN$XiZn*gZpRl(TC0lH_TETHlKKVuR9`wj+@1i`16q?TI&(a=g7*?Rs# zOC;#4go$-{;SfIP;W5}J`&zrw+~<{5*=FQ&r#E5UIx4!4SbCgfar7I1-B;9qM2n0sx}hcNNP1kq8Duyu=x- zMhAZBxK||-ZikN^__U&zNOIzch#b;hN;bq4&ImwY$~sO;;z-zm6KC;wOeehvMiMM6 zB^4r?s1*1rg82`QLq^~6*c&_VT*_+73``w1Mi?N!+e8xQNWV*f`A+maf9ReRyua@g zip+&K96D}=<{N!v1leEWO|`LBKx(j#M>RNY(BT6+nL1!$F!lmeCZ>c891Z}Y4}>{S z9WWd)=HbUx2|g9Yg^5?BW#BUWKpd>$GNq!YxBzLm#ysO+$33DTA5wKBdM?>wtvdt1 z?+pXL=1j=ls%EegCUBT%Wg*UD0utjtBY2J}rOrVEP-QZz9~f9uabi3k2Qm^?<#aJbDeo*Fa65jI=`0S%G*8LFdC;I9PD!60p216agmmGYs?gQ`dk*bB`N z(iNX2GE*Px6$0leDvyQWQ-1=#YJ?n$ILwW~DvqT{SonuEodkWCQk3ekHk=6}m^a0< zLayV*!pJ%y$VDxX z9Bp_`K`Lx{!(IR^e25(_csE6EzzxAWj*>b+1d<$?X=951%TV=+KMY6FW`*h>^#Y%TMyy;Bq<|oSS&xiGXiT@Lr8!9TYM5hTkVjp3 zG|lWP>YD-}JKGR1TVV!w5>NZpK&&%FS+kDZh?HYphkeqO$Xs!c4S8@w_MvB#F{q|0 zK>>~M)usIw(fEQ<2ue0_YVkIx!SFW@{2Du;4Py;vj3^HXBU4#ypEMW^QCYcawJBlz zZoFSIPJ1U@btMkSrfC)76T7@*>wi9*d8O!y#0cDOLQd zwb9{{`9qQQq18x|jzg7~%geykFD&w~OXoVOFa5E*C9B~~8|oznd^^g;N962b&kp1X z1yEG_W5+ENzonvr-KffT%!GC;p+VpZf7>C7ga)lO!YYE_NOy36^(KBG4F7wSkN(I7 zYvdfAoovem)nm*=>Lh$sNrt{TceX1D8VA#vAYH9DVTp+izNYPO;*CIK*rT&4qI86W z-#T!sPB0r6dP(9nV9dI zZm&f9yQOGvdJt%2&grjeT$>9qg=vvML=uIjpzo=OVzM{Jm!{!CH}2?-K&PlpIFU^{hBG1Rwo&{yG928()ora17oUzb~M1{6@QS$ z3o(QIY^7PqkwHgokJl0jbIJyGWUL}W9X%zO5*AYNAGlBU_5!zkH$O62?~=7nb^b^b zo)O5sbAf~`Ek`HX)pNR|umzGsosQqb8FFM6V?O1LK^$WsB>YLWLaRbt!QLMo34b!_ znX#JdcLu$I!yLqvW_M<`7x3TFo$_D9HIuymoY@{tVQ?zs=E$TphIu$Q16@%SkVb?a zt;pcRAX*7yKsW^-QfkDqgQyzQcx?E|$P`nu`E)8yuIINraqD(J8}zj&YKs!5PMY4C zfuQ4RVr&}%8&lk_A<}|+=whav7($wu<8c$e-=KL-jJGI{oA(1w>;PfY8=*e%3Sbyo zjMuCVoX+i3>5^*K1BvL=14ceGLr8p#(L#A7$LyW&(Mqt^TB%g@yR2HlR-*- z&33(j{qrJAj|BZeWtGyo4&i497+Rckf<6lSu%UAH_DG!IV|{{v!~q>dc*2R;1NV~~ zGb{0jWNZ{s{J|sTi+&cDn3tfA!@&IRfom~@MK++p2tkKV^^ZLAfjS6#?4*Ve@Q*8T z2}l?3Z?67g-C251S4 ztV8?>EV^^_RX=ok-7z}ihJ@+kk$7A@%_J9M;jD1_zC(Xj<@2C&?q1A0w2!>t-eT^^ zjVhJQBrfq0ukKk}EjU$!db-NvM+bc5BTHS1Yao8 MU;|R7w=?Je0Rq3mX8-^I literal 0 HcmV?d00001 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/hash.usenix.ps b/user/mpy/lib/berkeley-db-1.xx/docs/hash.usenix.ps new file mode 100644 index 0000000000000000000000000000000000000000..c884778830d2fa8b5f335e527b8430be9cef5b06 GIT binary patch literal 158771 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 SvfOT1TDbPGSX+CzU;7E%nZ#EB literal 0 HcmV?d00001 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/libtp.usenix.ps b/user/mpy/lib/berkeley-db-1.xx/docs/libtp.usenix.ps new file mode 100644 index 0000000000000000000000000000000000000000..ea821a9145e2482e7e17b157cff518aecfaeffc4 GIT binary patch literal 168201 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 literal 0 HcmV?d00001 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps new file mode 100644 index 0000000000000000000000000000000000000000..816c9243c8636087c0c9cb31b2f9354af6ac5fea GIT binary patch literal 13573 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 K=;sTUQ}sW}*6BL{ literal 0 HcmV?d00001 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps new file mode 100644 index 0000000000000000000000000000000000000000..8ffccfca90db10b200826806cb47c3bcc2acc42b GIT binary patch literal 14632 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 +#include + +#include +#include +#include +#include +#include +#include +#ifdef DEBUG +#include +#endif + +#include +#include "hash.h" +#include "page.h" +#include "extern.h" + +static int alloc_segs __P((HTAB *, int)); +static int flush_meta __P((HTAB *)); +static int hash_access __P((HTAB *, ACTION, DBT *, DBT *)); +static int hash_close __P((DB *)); +static int hash_delete __P((const DB *, const DBT *, u_int32_t)); +static int hash_fd __P((const DB *)); +static int hash_get __P((const DB *, const DBT *, DBT *, u_int32_t)); +static int hash_put __P((const DB *, DBT *, const DBT *, u_int32_t)); +static void *hash_realloc __P((SEGMENT **, int, int)); +static int hash_seq __P((const DB *, DBT *, DBT *, u_int32_t)); +static int hash_sync __P((const DB *, u_int32_t)); +static int hdestroy __P((HTAB *)); +static HTAB *init_hash __P((HTAB *, const char *, HASHINFO *)); +static int init_htab __P((HTAB *, int)); +#if BYTE_ORDER == LITTLE_ENDIAN +static void swap_header __P((HTAB *)); +static void swap_header_copy __P((HASHHDR *, HASHHDR *)); +#endif + +/* Fast arithmetic, relying on powers of 2, */ +#define MOD(x, y) ((x) & ((y) - 1)) + +#define RETURN_ERROR(ERR, LOC) { save_errno = ERR; goto LOC; } + +/* Return values */ +#define SUCCESS (0) +#define ERROR (-1) +#define ABNORMAL (1) + +#ifdef HASH_STATISTICS +int hash_accesses, hash_collisions, hash_expansions, hash_overflows; +#endif + +/************************** INTERFACE ROUTINES ***************************/ +/* OPEN/CLOSE */ + +extern DB * +__hash_open(file, flags, mode, info, dflags) + const char *file; + int flags, mode, dflags; + const HASHINFO *info; /* Special directives for create */ +{ + HTAB *hashp; + struct stat statbuf; + DB *dbp; + int bpages, hdrsize, new_table, nsegs, save_errno; + + if ((flags & O_ACCMODE) == O_WRONLY) { + errno = EINVAL; + return (NULL); + } + + if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB)))) + return (NULL); + hashp->fp = -1; + + /* + * Even if user wants write only, we need to be able to read + * the actual file, so we need to open it read/write. But, the + * field in the hashp structure needs to be accurate so that + * we can check accesses. + */ + hashp->flags = flags; + + new_table = 0; + if (!file || (flags & O_TRUNC) || + (stat(file, &statbuf) && (errno == ENOENT))) { + if (errno == ENOENT) + errno = 0; /* Just in case someone looks at errno */ + new_table = 1; + } + if (file) { + if ((hashp->fp = open(file, flags, mode)) == -1) + RETURN_ERROR(errno, error0); + (void)fcntl(hashp->fp, F_SETFD, 1); + } + if (new_table) { + if (!(hashp = init_hash(hashp, file, (HASHINFO *)info))) + RETURN_ERROR(errno, error1); + } else { + /* Table already exists */ + if (info && info->hash) + hashp->hash = info->hash; + else + hashp->hash = __default_hash; + + hdrsize = read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); +#if BYTE_ORDER == LITTLE_ENDIAN + swap_header(hashp); +#endif + if (hdrsize == -1) + RETURN_ERROR(errno, error1); + if (hdrsize != sizeof(HASHHDR)) + RETURN_ERROR(EFTYPE, error1); + /* Verify file type, versions and hash function */ + if (hashp->MAGIC != HASHMAGIC) + RETURN_ERROR(EFTYPE, error1); +#define OLDHASHVERSION 1 + if (hashp->VERSION != HASHVERSION && + hashp->VERSION != OLDHASHVERSION) + RETURN_ERROR(EFTYPE, error1); + if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != hashp->H_CHARKEY) + RETURN_ERROR(EFTYPE, error1); + /* + * Figure out how many segments we need. Max_Bucket is the + * maximum bucket number, so the number of buckets is + * max_bucket + 1. + */ + nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) / + hashp->SGSIZE; + hashp->nsegs = 0; + if (alloc_segs(hashp, nsegs)) + /* + * If alloc_segs fails, table will have been destroyed + * and errno will have been set. + */ + return (NULL); + /* Read in bitmaps */ + bpages = (hashp->SPARES[hashp->OVFL_POINT] + + (hashp->BSIZE << BYTE_SHIFT) - 1) >> + (hashp->BSHIFT + BYTE_SHIFT); + + hashp->nmaps = bpages; + (void)memset(&hashp->mapp[0], 0, bpages * sizeof(u_int32_t *)); + } + + /* Initialize Buffer Manager */ + if (info && info->cachesize) + __buf_init(hashp, info->cachesize); + else + __buf_init(hashp, DEF_BUFSIZE); + + hashp->new_file = new_table; + hashp->save_file = file && (hashp->flags & O_RDWR); + hashp->cbucket = -1; + if (!(dbp = (DB *)malloc(sizeof(DB)))) { + save_errno = errno; + hdestroy(hashp); + errno = save_errno; + return (NULL); + } + dbp->internal = hashp; + dbp->close = hash_close; + dbp->del = hash_delete; + dbp->fd = hash_fd; + dbp->get = hash_get; + dbp->put = hash_put; + dbp->seq = hash_seq; + dbp->sync = hash_sync; + dbp->type = DB_HASH; + +#ifdef DEBUG + (void)fprintf(stderr, +"%s\n%s%x\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%x\n%s%x\n%s%d\n%s%d\n", + "init_htab:", + "TABLE POINTER ", hashp, + "BUCKET SIZE ", hashp->BSIZE, + "BUCKET SHIFT ", hashp->BSHIFT, + "DIRECTORY SIZE ", hashp->DSIZE, + "SEGMENT SIZE ", hashp->SGSIZE, + "SEGMENT SHIFT ", hashp->SSHIFT, + "FILL FACTOR ", hashp->FFACTOR, + "MAX BUCKET ", hashp->MAX_BUCKET, + "OVFL POINT ", hashp->OVFL_POINT, + "LAST FREED ", hashp->LAST_FREED, + "HIGH MASK ", hashp->HIGH_MASK, + "LOW MASK ", hashp->LOW_MASK, + "NSEGS ", hashp->nsegs, + "NKEYS ", hashp->NKEYS); +#endif +#ifdef HASH_STATISTICS + hash_overflows = hash_accesses = hash_collisions = hash_expansions = 0; +#endif + return (dbp); + +error1: + if (hashp != NULL) + (void)close(hashp->fp); + +error0: + free(hashp); + errno = save_errno; + return (NULL); +} + +static int +hash_close(dbp) + DB *dbp; +{ + HTAB *hashp; + int retval; + + if (!dbp) + return (ERROR); + + hashp = (HTAB *)dbp->internal; + retval = hdestroy(hashp); + free(dbp); + return (retval); +} + +static int +hash_fd(dbp) + const DB *dbp; +{ + HTAB *hashp; + + if (!dbp) + return (ERROR); + + hashp = (HTAB *)dbp->internal; + if (hashp->fp == -1) { + errno = ENOENT; + return (-1); + } + return (hashp->fp); +} + +/************************** LOCAL CREATION ROUTINES **********************/ +static HTAB * +init_hash(hashp, file, info) + HTAB *hashp; + const char *file; + HASHINFO *info; +{ + struct stat statbuf; + int nelem; + + nelem = 1; + hashp->NKEYS = 0; + hashp->LORDER = BYTE_ORDER; + hashp->BSIZE = DEF_BUCKET_SIZE; + hashp->BSHIFT = DEF_BUCKET_SHIFT; + hashp->SGSIZE = DEF_SEGSIZE; + hashp->SSHIFT = DEF_SEGSIZE_SHIFT; + hashp->DSIZE = DEF_DIRSIZE; + hashp->FFACTOR = DEF_FFACTOR; + hashp->hash = __default_hash; + memset(hashp->SPARES, 0, sizeof(hashp->SPARES)); + memset(hashp->BITMAPS, 0, sizeof (hashp->BITMAPS)); + + /* Fix bucket size to be optimal for file system */ + if (file != NULL) { + if (stat(file, &statbuf)) + return (NULL); + hashp->BSIZE = statbuf.st_blksize; + hashp->BSHIFT = __log2(hashp->BSIZE); + } + + if (info) { + if (info->bsize) { + /* Round pagesize up to power of 2 */ + hashp->BSHIFT = __log2(info->bsize); + hashp->BSIZE = 1 << hashp->BSHIFT; + if (hashp->BSIZE > MAX_BSIZE) { + errno = EINVAL; + return (NULL); + } + } + if (info->ffactor) + hashp->FFACTOR = info->ffactor; + if (info->hash) + hashp->hash = info->hash; + if (info->nelem) + nelem = info->nelem; + if (info->lorder) { + if (info->lorder != BIG_ENDIAN && + info->lorder != LITTLE_ENDIAN) { + errno = EINVAL; + return (NULL); + } + hashp->LORDER = info->lorder; + } + } + /* init_htab should destroy the table and set errno if it fails */ + if (init_htab(hashp, nelem)) + return (NULL); + else + return (hashp); +} +/* + * This calls alloc_segs which may run out of memory. Alloc_segs will destroy + * the table and set errno, so we just pass the error information along. + * + * Returns 0 on No Error + */ +static int +init_htab(hashp, nelem) + HTAB *hashp; + int nelem; +{ + register int nbuckets, nsegs; + int l2; + + /* + * Divide number of elements by the fill factor and determine a + * desired number of buckets. Allocate space for the next greater + * power of two number of buckets. + */ + nelem = (nelem - 1) / hashp->FFACTOR + 1; + + l2 = __log2(MAX(nelem, 2)); + nbuckets = 1 << l2; + + hashp->SPARES[l2] = l2 + 1; + hashp->SPARES[l2 + 1] = l2 + 1; + hashp->OVFL_POINT = l2; + hashp->LAST_FREED = 2; + + /* First bitmap page is at: splitpoint l2 page offset 1 */ + if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0)) + return (-1); + + hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1; + hashp->HIGH_MASK = (nbuckets << 1) - 1; + hashp->HDRPAGES = ((MAX(sizeof(HASHHDR), MINHDRSIZE) - 1) >> + hashp->BSHIFT) + 1; + + nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; + nsegs = 1 << __log2(nsegs); + + if (nsegs > hashp->DSIZE) + hashp->DSIZE = nsegs; + return (alloc_segs(hashp, nsegs)); +} + +/********************** DESTROY/CLOSE ROUTINES ************************/ + +/* + * Flushes any changes to the file if necessary and destroys the hashp + * structure, freeing all allocated space. + */ +static int +hdestroy(hashp) + HTAB *hashp; +{ + int i, save_errno; + + save_errno = 0; + +#ifdef HASH_STATISTICS + (void)fprintf(stderr, "hdestroy: accesses %ld collisions %ld\n", + hash_accesses, hash_collisions); + (void)fprintf(stderr, "hdestroy: expansions %ld\n", + hash_expansions); + (void)fprintf(stderr, "hdestroy: overflows %ld\n", + hash_overflows); + (void)fprintf(stderr, "keys %ld maxp %d segmentcount %d\n", + hashp->NKEYS, hashp->MAX_BUCKET, hashp->nsegs); + + for (i = 0; i < NCACHED; i++) + (void)fprintf(stderr, + "spares[%d] = %d\n", i, hashp->SPARES[i]); +#endif + /* + * Call on buffer manager to free buffers, and if required, + * write them to disk. + */ + if (__buf_free(hashp, 1, hashp->save_file)) + save_errno = errno; + if (hashp->dir) { + free(*hashp->dir); /* Free initial segments */ + /* Free extra segments */ + while (hashp->exsegs--) + free(hashp->dir[--hashp->nsegs]); + free(hashp->dir); + } + if (flush_meta(hashp) && !save_errno) + save_errno = errno; + /* Free Bigmaps */ + for (i = 0; i < hashp->nmaps; i++) + if (hashp->mapp[i]) + free(hashp->mapp[i]); + + if (hashp->fp != -1) + (void)close(hashp->fp); + + free(hashp); + + if (save_errno) { + errno = save_errno; + return (ERROR); + } + return (SUCCESS); +} +/* + * Write modified pages to disk + * + * Returns: + * 0 == OK + * -1 ERROR + */ +static int +hash_sync(dbp, flags) + const DB *dbp; + u_int32_t flags; +{ + HTAB *hashp; + + if (flags != 0) { + errno = EINVAL; + return (ERROR); + } + + if (!dbp) + return (ERROR); + + hashp = (HTAB *)dbp->internal; + if (!hashp->save_file) + return (0); + if (__buf_free(hashp, 0, 1) || flush_meta(hashp)) + return (ERROR); + hashp->new_file = 0; + return (0); +} + +/* + * Returns: + * 0 == OK + * -1 indicates that errno should be set + */ +static int +flush_meta(hashp) + HTAB *hashp; +{ + HASHHDR *whdrp; +#if BYTE_ORDER == LITTLE_ENDIAN + HASHHDR whdr; +#endif + int fp, i, wsize; + + if (!hashp->save_file) + return (0); + hashp->MAGIC = HASHMAGIC; + hashp->VERSION = HASHVERSION; + hashp->H_CHARKEY = hashp->hash(CHARKEY, sizeof(CHARKEY)); + + fp = hashp->fp; + whdrp = &hashp->hdr; +#if BYTE_ORDER == LITTLE_ENDIAN + whdrp = &whdr; + swap_header_copy(&hashp->hdr, whdrp); +#endif + if ((lseek(fp, (off_t)0, SEEK_SET) == -1) || + ((wsize = write(fp, whdrp, sizeof(HASHHDR))) == -1)) + return (-1); + else + if (wsize != sizeof(HASHHDR)) { + errno = EFTYPE; + hashp->errno = errno; + return (-1); + } + for (i = 0; i < NCACHED; i++) + if (hashp->mapp[i]) + if (__put_page(hashp, (char *)hashp->mapp[i], + hashp->BITMAPS[i], 0, 1)) + return (-1); + return (0); +} + +/*******************************SEARCH ROUTINES *****************************/ +/* + * All the access routines return + * + * Returns: + * 0 on SUCCESS + * 1 to indicate an external ERROR (i.e. key not found, etc) + * -1 to indicate an internal ERROR (i.e. out of memory, etc) + */ +static int +hash_get(dbp, key, data, flag) + const DB *dbp; + const DBT *key; + DBT *data; + u_int32_t flag; +{ + HTAB *hashp; + + hashp = (HTAB *)dbp->internal; + if (flag) { + hashp->errno = errno = EINVAL; + return (ERROR); + } + return (hash_access(hashp, HASH_GET, (DBT *)key, data)); +} + +static int +hash_put(dbp, key, data, flag) + const DB *dbp; + DBT *key; + const DBT *data; + u_int32_t flag; +{ + HTAB *hashp; + + hashp = (HTAB *)dbp->internal; + if (flag && flag != R_NOOVERWRITE) { + hashp->errno = errno = EINVAL; + return (ERROR); + } + if ((hashp->flags & O_ACCMODE) == O_RDONLY) { + hashp->errno = errno = EPERM; + return (ERROR); + } + return (hash_access(hashp, flag == R_NOOVERWRITE ? + HASH_PUTNEW : HASH_PUT, (DBT *)key, (DBT *)data)); +} + +static int +hash_delete(dbp, key, flag) + const DB *dbp; + const DBT *key; + u_int32_t flag; /* Ignored */ +{ + HTAB *hashp; + + hashp = (HTAB *)dbp->internal; + if (flag && flag != R_CURSOR) { + hashp->errno = errno = EINVAL; + return (ERROR); + } + if ((hashp->flags & O_ACCMODE) == O_RDONLY) { + hashp->errno = errno = EPERM; + return (ERROR); + } + return (hash_access(hashp, HASH_DELETE, (DBT *)key, NULL)); +} + +/* + * Assume that hashp has been set in wrapper routine. + */ +static int +hash_access(hashp, action, key, val) + HTAB *hashp; + ACTION action; + DBT *key, *val; +{ + register BUFHEAD *rbufp; + BUFHEAD *bufp, *save_bufp; + register u_int16_t *bp; + register int n, ndx, off, size; + register char *kp; + u_int16_t pageno; + +#ifdef HASH_STATISTICS + hash_accesses++; +#endif + + off = hashp->BSIZE; + size = key->size; + kp = (char *)key->data; + rbufp = __get_buf(hashp, __call_hash(hashp, kp, size), NULL, 0); + if (!rbufp) + return (ERROR); + save_bufp = rbufp; + + /* Pin the bucket chain */ + rbufp->flags |= BUF_PIN; + for (bp = (u_int16_t *)rbufp->page, n = *bp++, ndx = 1; ndx < n;) + if (bp[1] >= REAL_KEY) { + /* Real key/data pair */ + if (size == off - *bp && + memcmp(kp, rbufp->page + *bp, size) == 0) + goto found; + off = bp[1]; +#ifdef HASH_STATISTICS + hash_collisions++; +#endif + bp += 2; + ndx += 2; + } else if (bp[1] == OVFLPAGE) { + rbufp = __get_buf(hashp, *bp, rbufp, 0); + if (!rbufp) { + save_bufp->flags &= ~BUF_PIN; + return (ERROR); + } + /* FOR LOOP INIT */ + bp = (u_int16_t *)rbufp->page; + n = *bp++; + ndx = 1; + off = hashp->BSIZE; + } else if (bp[1] < REAL_KEY) { + if ((ndx = + __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0) + goto found; + if (ndx == -2) { + bufp = rbufp; + if (!(pageno = + __find_last_page(hashp, &bufp))) { + ndx = 0; + rbufp = bufp; + break; /* FOR */ + } + rbufp = __get_buf(hashp, pageno, bufp, 0); + if (!rbufp) { + save_bufp->flags &= ~BUF_PIN; + return (ERROR); + } + /* FOR LOOP INIT */ + bp = (u_int16_t *)rbufp->page; + n = *bp++; + ndx = 1; + off = hashp->BSIZE; + } else { + save_bufp->flags &= ~BUF_PIN; + return (ERROR); + } + } + + /* Not found */ + switch (action) { + case HASH_PUT: + case HASH_PUTNEW: + if (__addel(hashp, rbufp, key, val)) { + save_bufp->flags &= ~BUF_PIN; + return (ERROR); + } else { + save_bufp->flags &= ~BUF_PIN; + return (SUCCESS); + } + case HASH_GET: + case HASH_DELETE: + default: + save_bufp->flags &= ~BUF_PIN; + return (ABNORMAL); + } + +found: + switch (action) { + case HASH_PUTNEW: + save_bufp->flags &= ~BUF_PIN; + return (ABNORMAL); + case HASH_GET: + bp = (u_int16_t *)rbufp->page; + if (bp[ndx + 1] < REAL_KEY) { + if (__big_return(hashp, rbufp, ndx, val, 0)) + return (ERROR); + } else { + val->data = (u_char *)rbufp->page + (int)bp[ndx + 1]; + val->size = bp[ndx] - bp[ndx + 1]; + } + break; + case HASH_PUT: + if ((__delpair(hashp, rbufp, ndx)) || + (__addel(hashp, rbufp, key, val))) { + save_bufp->flags &= ~BUF_PIN; + return (ERROR); + } + break; + case HASH_DELETE: + if (__delpair(hashp, rbufp, ndx)) + return (ERROR); + break; + default: + abort(); + } + save_bufp->flags &= ~BUF_PIN; + return (SUCCESS); +} + +static int +hash_seq(dbp, key, data, flag) + const DB *dbp; + DBT *key, *data; + u_int32_t flag; +{ + register u_int32_t bucket; + register BUFHEAD *bufp; + HTAB *hashp; + u_int16_t *bp, ndx; + + hashp = (HTAB *)dbp->internal; + if (flag && flag != R_FIRST && flag != R_NEXT) { + hashp->errno = errno = EINVAL; + return (ERROR); + } +#ifdef HASH_STATISTICS + hash_accesses++; +#endif + if ((hashp->cbucket < 0) || (flag == R_FIRST)) { + hashp->cbucket = 0; + hashp->cndx = 1; + hashp->cpage = NULL; + } + + for (bp = NULL; !bp || !bp[0]; ) { + if (!(bufp = hashp->cpage)) { + for (bucket = hashp->cbucket; + bucket <= hashp->MAX_BUCKET; + bucket++, hashp->cndx = 1) { + bufp = __get_buf(hashp, bucket, NULL, 0); + if (!bufp) + return (ERROR); + hashp->cpage = bufp; + bp = (u_int16_t *)bufp->page; + if (bp[0]) + break; + } + hashp->cbucket = bucket; + if (hashp->cbucket > hashp->MAX_BUCKET) { + hashp->cbucket = -1; + return (ABNORMAL); + } + } else + bp = (u_int16_t *)hashp->cpage->page; + +#ifdef DEBUG + assert(bp); + assert(bufp); +#endif + while (bp[hashp->cndx + 1] == OVFLPAGE) { + bufp = hashp->cpage = + __get_buf(hashp, bp[hashp->cndx], bufp, 0); + if (!bufp) + return (ERROR); + bp = (u_int16_t *)(bufp->page); + hashp->cndx = 1; + } + if (!bp[0]) { + hashp->cpage = NULL; + ++hashp->cbucket; + } + } + ndx = hashp->cndx; + if (bp[ndx + 1] < REAL_KEY) { + if (__big_keydata(hashp, bufp, key, data, 1)) + return (ERROR); + } else { + key->data = (u_char *)hashp->cpage->page + bp[ndx]; + key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx]; + data->data = (u_char *)hashp->cpage->page + bp[ndx + 1]; + data->size = bp[ndx] - bp[ndx + 1]; + ndx += 2; + if (ndx > bp[0]) { + hashp->cpage = NULL; + hashp->cbucket++; + hashp->cndx = 1; + } else + hashp->cndx = ndx; + } + return (SUCCESS); +} + +/********************************* UTILITIES ************************/ + +/* + * Returns: + * 0 ==> OK + * -1 ==> Error + */ +extern int +__expand_table(hashp) + HTAB *hashp; +{ + u_int32_t old_bucket, new_bucket; + int dirsize, new_segnum, spare_ndx; + +#ifdef HASH_STATISTICS + hash_expansions++; +#endif + new_bucket = ++hashp->MAX_BUCKET; + old_bucket = (hashp->MAX_BUCKET & hashp->LOW_MASK); + + new_segnum = new_bucket >> hashp->SSHIFT; + + /* Check if we need a new segment */ + if (new_segnum >= hashp->nsegs) { + /* Check if we need to expand directory */ + if (new_segnum >= hashp->DSIZE) { + /* Reallocate directory */ + dirsize = hashp->DSIZE * sizeof(SEGMENT *); + if (!hash_realloc(&hashp->dir, dirsize, dirsize << 1)) + return (-1); + hashp->DSIZE = dirsize << 1; + } + if ((hashp->dir[new_segnum] = + (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) + return (-1); + hashp->exsegs++; + hashp->nsegs++; + } + /* + * If the split point is increasing (MAX_BUCKET's log base 2 + * * increases), we need to copy the current contents of the spare + * split bucket to the next bucket. + */ + spare_ndx = __log2(hashp->MAX_BUCKET + 1); + if (spare_ndx > hashp->OVFL_POINT) { + hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT]; + hashp->OVFL_POINT = spare_ndx; + } + + if (new_bucket > hashp->HIGH_MASK) { + /* Starting a new doubling */ + hashp->LOW_MASK = hashp->HIGH_MASK; + hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK; + } + /* Relocate records to the new bucket */ + return (__split_page(hashp, old_bucket, new_bucket)); +} + +/* + * If realloc guarantees that the pointer is not destroyed if the realloc + * fails, then this routine can go away. + */ +static void * +hash_realloc(p_ptr, oldsize, newsize) + SEGMENT **p_ptr; + int oldsize, newsize; +{ + register void *p; + + if (p = malloc(newsize)) { + memmove(p, *p_ptr, oldsize); + memset((char *)p + oldsize, 0, newsize - oldsize); + free(*p_ptr); + *p_ptr = p; + } + return (p); +} + +extern u_int32_t +__call_hash(hashp, k, len) + HTAB *hashp; + char *k; + int len; +{ + int n, bucket; + + n = hashp->hash(k, len); + bucket = n & hashp->HIGH_MASK; + if (bucket > hashp->MAX_BUCKET) + bucket = bucket & hashp->LOW_MASK; + return (bucket); +} + +/* + * Allocate segment table. On error, destroy the table and set errno. + * + * Returns 0 on success + */ +static int +alloc_segs(hashp, nsegs) + HTAB *hashp; + int nsegs; +{ + register int i; + register SEGMENT store; + + int save_errno; + + if ((hashp->dir = + (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { + save_errno = errno; + (void)hdestroy(hashp); + errno = save_errno; + return (-1); + } + /* Allocate segments */ + if ((store = + (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { + save_errno = errno; + (void)hdestroy(hashp); + errno = save_errno; + return (-1); + } + for (i = 0; i < nsegs; i++, hashp->nsegs++) + hashp->dir[i] = &store[i << hashp->SSHIFT]; + return (0); +} + +#if BYTE_ORDER == LITTLE_ENDIAN +/* + * Hashp->hdr needs to be byteswapped. + */ +static void +swap_header_copy(srcp, destp) + HASHHDR *srcp, *destp; +{ + int i; + + P_32_COPY(srcp->magic, destp->magic); + P_32_COPY(srcp->version, destp->version); + P_32_COPY(srcp->lorder, destp->lorder); + P_32_COPY(srcp->bsize, destp->bsize); + P_32_COPY(srcp->bshift, destp->bshift); + P_32_COPY(srcp->dsize, destp->dsize); + P_32_COPY(srcp->ssize, destp->ssize); + P_32_COPY(srcp->sshift, destp->sshift); + P_32_COPY(srcp->ovfl_point, destp->ovfl_point); + P_32_COPY(srcp->last_freed, destp->last_freed); + P_32_COPY(srcp->max_bucket, destp->max_bucket); + P_32_COPY(srcp->high_mask, destp->high_mask); + P_32_COPY(srcp->low_mask, destp->low_mask); + P_32_COPY(srcp->ffactor, destp->ffactor); + P_32_COPY(srcp->nkeys, destp->nkeys); + P_32_COPY(srcp->hdrpages, destp->hdrpages); + P_32_COPY(srcp->h_charkey, destp->h_charkey); + for (i = 0; i < NCACHED; i++) { + P_32_COPY(srcp->spares[i], destp->spares[i]); + P_16_COPY(srcp->bitmaps[i], destp->bitmaps[i]); + } +} + +static void +swap_header(hashp) + HTAB *hashp; +{ + HASHHDR *hdrp; + int i; + + hdrp = &hashp->hdr; + + M_32_SWAP(hdrp->magic); + M_32_SWAP(hdrp->version); + M_32_SWAP(hdrp->lorder); + M_32_SWAP(hdrp->bsize); + M_32_SWAP(hdrp->bshift); + M_32_SWAP(hdrp->dsize); + M_32_SWAP(hdrp->ssize); + M_32_SWAP(hdrp->sshift); + M_32_SWAP(hdrp->ovfl_point); + M_32_SWAP(hdrp->last_freed); + M_32_SWAP(hdrp->max_bucket); + M_32_SWAP(hdrp->high_mask); + M_32_SWAP(hdrp->low_mask); + M_32_SWAP(hdrp->ffactor); + M_32_SWAP(hdrp->nkeys); + M_32_SWAP(hdrp->hdrpages); + M_32_SWAP(hdrp->h_charkey); + for (i = 0; i < NCACHED; i++) { + M_32_SWAP(hdrp->spares[i]); + M_16_SWAP(hdrp->bitmaps[i]); + } +} +#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash.h b/user/mpy/lib/berkeley-db-1.xx/hash/hash.h new file mode 100644 index 0000000..913e82b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hash.h @@ -0,0 +1,293 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)hash.h 8.3 (Berkeley) 5/31/94 + */ + +/* Operations */ +typedef enum { + HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT +} ACTION; + +/* Buffer Management structures */ +typedef struct _bufhead BUFHEAD; + +struct _bufhead { + BUFHEAD *prev; /* LRU links */ + BUFHEAD *next; /* LRU links */ + BUFHEAD *ovfl; /* Overflow page buffer header */ + u_int32_t addr; /* Address of this page */ + char *page; /* Actual page data */ + char flags; +#define BUF_MOD 0x0001 +#define BUF_DISK 0x0002 +#define BUF_BUCKET 0x0004 +#define BUF_PIN 0x0008 +}; + +#define IS_BUCKET(X) ((X) & BUF_BUCKET) + +typedef BUFHEAD **SEGMENT; + +/* Hash Table Information */ +typedef struct hashhdr { /* Disk resident portion */ + int magic; /* Magic NO for hash tables */ + int version; /* Version ID */ + u_int32_t lorder; /* Byte Order */ + int bsize; /* Bucket/Page Size */ + int bshift; /* Bucket shift */ + int dsize; /* Directory Size */ + int ssize; /* Segment Size */ + int sshift; /* Segment shift */ + int ovfl_point; /* Where overflow pages are being + * allocated */ + int last_freed; /* Last overflow page freed */ + int max_bucket; /* ID of Maximum bucket in use */ + int high_mask; /* Mask to modulo into entire table */ + int low_mask; /* Mask to modulo into lower half of + * table */ + int ffactor; /* Fill factor */ + int nkeys; /* Number of keys in hash table */ + int hdrpages; /* Size of table header */ + int h_charkey; /* value of hash(CHARKEY) */ +#define NCACHED 32 /* number of bit maps and spare + * points */ + int spares[NCACHED];/* spare pages for overflow */ + u_int16_t bitmaps[NCACHED]; /* address of overflow page + * bitmaps */ +} HASHHDR; + +typedef struct htab { /* Memory resident data structure */ + HASHHDR hdr; /* Header */ + int nsegs; /* Number of allocated segments */ + int exsegs; /* Number of extra allocated + * segments */ + u_int32_t /* Hash function */ + (*hash)__P((const void *, size_t)); + int flags; /* Flag values */ + int fp; /* File pointer */ + char *tmp_buf; /* Temporary Buffer for BIG data */ + char *tmp_key; /* Temporary Buffer for BIG keys */ + BUFHEAD *cpage; /* Current page */ + int cbucket; /* Current bucket */ + int cndx; /* Index of next item on cpage */ + int errno; /* Error Number -- for DBM + * compatability */ + int new_file; /* Indicates if fd is backing store + * or no */ + int save_file; /* Indicates whether we need to flush + * file at + * exit */ + u_int32_t *mapp[NCACHED]; /* Pointers to page maps */ + int nmaps; /* Initial number of bitmaps */ + int nbufs; /* Number of buffers left to + * allocate */ + BUFHEAD bufhead; /* Header of buffer lru list */ + SEGMENT *dir; /* Hash Bucket directory */ +} HTAB; + +/* + * Constants + */ +#define MAX_BSIZE 65536 /* 2^16 */ +#define MIN_BUFFERS 6 +#define MINHDRSIZE 512 +#define DEF_BUFSIZE 65536 /* 64 K */ +#define DEF_BUCKET_SIZE 4096 +#define DEF_BUCKET_SHIFT 12 /* log2(BUCKET) */ +#define DEF_SEGSIZE 256 +#define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */ +#define DEF_DIRSIZE 256 +#define DEF_FFACTOR 65536 +#define MIN_FFACTOR 4 +#define SPLTMAX 8 +#define CHARKEY "%$sniglet^&" +#define NUMKEY 1038583 +#define BYTE_SHIFT 3 +#define INT_TO_BYTE 2 +#define INT_BYTE_SHIFT 5 +#define ALL_SET ((u_int32_t)0xFFFFFFFF) +#define ALL_CLEAR 0 + +#define PTROF(X) ((BUFHEAD *)((ptrdiff_t)(X)&~0x3)) +#define ISMOD(X) ((u_int32_t)(ptrdiff_t)(X)&0x1) +#define DOMOD(X) ((X) = (char *)((ptrdiff_t)(X)|0x1)) +#define ISDISK(X) ((u_int32_t)(ptrdiff_t)(X)&0x2) +#define DODISK(X) ((X) = (char *)((ptrdiff_t)(X)|0x2)) + +#define BITS_PER_MAP 32 + +/* Given the address of the beginning of a big map, clear/set the nth bit */ +#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) +#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) +#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) + +/* Overflow management */ +/* + * Overflow page numbers are allocated per split point. At each doubling of + * the table, we can allocate extra pages. So, an overflow page number has + * the top 5 bits indicate which split point and the lower 11 bits indicate + * which page at that split point is indicated (pages within split points are + * numberered starting with 1). + */ + +#define SPLITSHIFT 11 +#define SPLITMASK 0x7FF +#define SPLITNUM(N) (((u_int32_t)(N)) >> SPLITSHIFT) +#define OPAGENUM(N) ((N) & SPLITMASK) +#define OADDR_OF(S,O) ((u_int32_t)((u_int32_t)(S) << SPLITSHIFT) + (O)) + +#define BUCKET_TO_PAGE(B) \ + (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((B)+1)-1] : 0) +#define OADDR_TO_PAGE(B) \ + BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)); + +/* + * page.h contains a detailed description of the page format. + * + * Normally, keys and data are accessed from offset tables in the top of + * each page which point to the beginning of the key and data. There are + * four flag values which may be stored in these offset tables which indicate + * the following: + * + * + * OVFLPAGE Rather than a key data pair, this pair contains + * the address of an overflow page. The format of + * the pair is: + * OVERFLOW_PAGE_NUMBER OVFLPAGE + * + * PARTIAL_KEY This must be the first key/data pair on a page + * and implies that page contains only a partial key. + * That is, the key is too big to fit on a single page + * so it starts on this page and continues on the next. + * The format of the page is: + * KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE + * + * KEY_OFF -- offset of the beginning of the key + * PARTIAL_KEY -- 1 + * OVFL_PAGENO - page number of the next overflow page + * OVFLPAGE -- 0 + * + * FULL_KEY This must be the first key/data pair on the page. It + * is used in two cases. + * + * Case 1: + * There is a complete key on the page but no data + * (because it wouldn't fit). The next page contains + * the data. + * + * Page format it: + * KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE + * + * KEY_OFF -- offset of the beginning of the key + * FULL_KEY -- 2 + * OVFL_PAGENO - page number of the next overflow page + * OVFLPAGE -- 0 + * + * Case 2: + * This page contains no key, but part of a large + * data field, which is continued on the next page. + * + * Page format it: + * DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE + * + * KEY_OFF -- offset of the beginning of the data on + * this page + * FULL_KEY -- 2 + * OVFL_PAGENO - page number of the next overflow page + * OVFLPAGE -- 0 + * + * FULL_KEY_DATA + * This must be the first key/data pair on the page. + * There are two cases: + * + * Case 1: + * This page contains a key and the beginning of the + * data field, but the data field is continued on the + * next page. + * + * Page format is: + * KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF + * + * KEY_OFF -- offset of the beginning of the key + * FULL_KEY_DATA -- 3 + * OVFL_PAGENO - page number of the next overflow page + * DATA_OFF -- offset of the beginning of the data + * + * Case 2: + * This page contains the last page of a big data pair. + * There is no key, only the tail end of the data + * on this page. + * + * Page format is: + * DATA_OFF FULL_KEY_DATA + * + * DATA_OFF -- offset of the beginning of the data on + * this page + * FULL_KEY_DATA -- 3 + * OVFL_PAGENO - page number of the next overflow page + * OVFLPAGE -- 0 + * + * OVFL_PAGENO and OVFLPAGE are optional (they are + * not present if there is no next page). + */ + +#define OVFLPAGE 0 +#define PARTIAL_KEY 1 +#define FULL_KEY 2 +#define FULL_KEY_DATA 3 +#define REAL_KEY 4 + +/* Short hands for accessing structure */ +#define BSIZE hdr.bsize +#define BSHIFT hdr.bshift +#define DSIZE hdr.dsize +#define SGSIZE hdr.ssize +#define SSHIFT hdr.sshift +#define LORDER hdr.lorder +#define OVFL_POINT hdr.ovfl_point +#define LAST_FREED hdr.last_freed +#define MAX_BUCKET hdr.max_bucket +#define FFACTOR hdr.ffactor +#define HIGH_MASK hdr.high_mask +#define LOW_MASK hdr.low_mask +#define NKEYS hdr.nkeys +#define HDRPAGES hdr.hdrpages +#define SPARES hdr.spares +#define BITMAPS hdr.bitmaps +#define VERSION hdr.version +#define MAGIC hdr.magic +#define NEXT_FREE hdr.next_free +#define H_CHARKEY hdr.h_charkey diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c new file mode 100644 index 0000000..578314a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c @@ -0,0 +1,667 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * PACKAGE: hash + * DESCRIPTION: + * Big key/data handling for the hashing package. + * + * ROUTINES: + * External + * __big_keydata + * __big_split + * __big_insert + * __big_return + * __big_delete + * __find_last_page + * Internal + * collect_key + * collect_data + */ + +#include + +#include +#include +#include +#include + +#ifdef DEBUG +#include +#endif + +#include +#include "hash.h" +#include "page.h" +#include "extern.h" + +static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int)); +static int collect_data __P((HTAB *, BUFHEAD *, int, int)); + +/* + * Big_insert + * + * You need to do an insert and the key/data pair is too big + * + * Returns: + * 0 ==> OK + *-1 ==> ERROR + */ +extern int +__big_insert(hashp, bufp, key, val) + HTAB *hashp; + BUFHEAD *bufp; + const DBT *key, *val; +{ + register u_int16_t *p; + int key_size, n, val_size; + u_int16_t space, move_bytes, off; + char *cp, *key_data, *val_data; + + cp = bufp->page; /* Character pointer of p. */ + p = (u_int16_t *)cp; + + key_data = (char *)key->data; + key_size = key->size; + val_data = (char *)val->data; + val_size = val->size; + + /* First move the Key */ + for (space = FREESPACE(p) - BIGOVERHEAD; key_size; + space = FREESPACE(p) - BIGOVERHEAD) { + move_bytes = MIN(space, key_size); + off = OFFSET(p) - move_bytes; + memmove(cp + off, key_data, move_bytes); + key_size -= move_bytes; + key_data += move_bytes; + n = p[0]; + p[++n] = off; + p[0] = ++n; + FREESPACE(p) = off - PAGE_META(n); + OFFSET(p) = off; + p[n] = PARTIAL_KEY; + bufp = __add_ovflpage(hashp, bufp); + if (!bufp) + return (-1); + n = p[0]; + if (!key_size) + if (FREESPACE(p)) { + move_bytes = MIN(FREESPACE(p), val_size); + off = OFFSET(p) - move_bytes; + p[n] = off; + memmove(cp + off, val_data, move_bytes); + val_data += move_bytes; + val_size -= move_bytes; + p[n - 2] = FULL_KEY_DATA; + FREESPACE(p) = FREESPACE(p) - move_bytes; + OFFSET(p) = off; + } else + p[n - 2] = FULL_KEY; + p = (u_int16_t *)bufp->page; + cp = bufp->page; + bufp->flags |= BUF_MOD; + } + + /* Now move the data */ + for (space = FREESPACE(p) - BIGOVERHEAD; val_size; + space = FREESPACE(p) - BIGOVERHEAD) { + move_bytes = MIN(space, val_size); + /* + * Here's the hack to make sure that if the data ends on the + * same page as the key ends, FREESPACE is at least one. + */ + if (space == val_size && val_size == val->size) + move_bytes--; + off = OFFSET(p) - move_bytes; + memmove(cp + off, val_data, move_bytes); + val_size -= move_bytes; + val_data += move_bytes; + n = p[0]; + p[++n] = off; + p[0] = ++n; + FREESPACE(p) = off - PAGE_META(n); + OFFSET(p) = off; + if (val_size) { + p[n] = FULL_KEY; + bufp = __add_ovflpage(hashp, bufp); + if (!bufp) + return (-1); + cp = bufp->page; + p = (u_int16_t *)cp; + } else + p[n] = FULL_KEY_DATA; + bufp->flags |= BUF_MOD; + } + return (0); +} + +/* + * Called when bufp's page contains a partial key (index should be 1) + * + * All pages in the big key/data pair except bufp are freed. We cannot + * free bufp because the page pointing to it is lost and we can't get rid + * of its pointer. + * + * Returns: + * 0 => OK + *-1 => ERROR + */ +extern int +__big_delete(hashp, bufp) + HTAB *hashp; + BUFHEAD *bufp; +{ + register BUFHEAD *last_bfp, *rbufp; + u_int16_t *bp, pageno; + int key_done, n; + + rbufp = bufp; + last_bfp = NULL; + bp = (u_int16_t *)bufp->page; + pageno = 0; + key_done = 0; + + while (!key_done || (bp[2] != FULL_KEY_DATA)) { + if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) + key_done = 1; + + /* + * If there is freespace left on a FULL_KEY_DATA page, then + * the data is short and fits entirely on this page, and this + * is the last page. + */ + if (bp[2] == FULL_KEY_DATA && FREESPACE(bp)) + break; + pageno = bp[bp[0] - 1]; + rbufp->flags |= BUF_MOD; + rbufp = __get_buf(hashp, pageno, rbufp, 0); + if (last_bfp) + __free_ovflpage(hashp, last_bfp); + last_bfp = rbufp; + if (!rbufp) + return (-1); /* Error. */ + bp = (u_int16_t *)rbufp->page; + } + + /* + * If we get here then rbufp points to the last page of the big + * key/data pair. Bufp points to the first one -- it should now be + * empty pointing to the next page after this pair. Can't free it + * because we don't have the page pointing to it. + */ + + /* This is information from the last page of the pair. */ + n = bp[0]; + pageno = bp[n - 1]; + + /* Now, bp is the first page of the pair. */ + bp = (u_int16_t *)bufp->page; + if (n > 2) { + /* There is an overflow page. */ + bp[1] = pageno; + bp[2] = OVFLPAGE; + bufp->ovfl = rbufp->ovfl; + } else + /* This is the last page. */ + bufp->ovfl = NULL; + n -= 2; + bp[0] = n; + FREESPACE(bp) = hashp->BSIZE - PAGE_META(n); + OFFSET(bp) = hashp->BSIZE - 1; + + bufp->flags |= BUF_MOD; + if (rbufp) + __free_ovflpage(hashp, rbufp); + if (last_bfp != rbufp) + __free_ovflpage(hashp, last_bfp); + + hashp->NKEYS--; + return (0); +} +/* + * Returns: + * 0 = key not found + * -1 = get next overflow page + * -2 means key not found and this is big key/data + * -3 error + */ +extern int +__find_bigpair(hashp, bufp, ndx, key, size) + HTAB *hashp; + BUFHEAD *bufp; + int ndx; + char *key; + int size; +{ + register u_int16_t *bp; + register char *p; + int ksize; + u_int16_t bytes; + char *kkey; + + bp = (u_int16_t *)bufp->page; + p = bufp->page; + ksize = size; + kkey = key; + + for (bytes = hashp->BSIZE - bp[ndx]; + bytes <= size && bp[ndx + 1] == PARTIAL_KEY; + bytes = hashp->BSIZE - bp[ndx]) { + if (memcmp(p + bp[ndx], kkey, bytes)) + return (-2); + kkey += bytes; + ksize -= bytes; + bufp = __get_buf(hashp, bp[ndx + 2], bufp, 0); + if (!bufp) + return (-3); + p = bufp->page; + bp = (u_int16_t *)p; + ndx = 1; + } + + if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) { +#ifdef HASH_STATISTICS + ++hash_collisions; +#endif + return (-2); + } else + return (ndx); +} + +/* + * Given the buffer pointer of the first overflow page of a big pair, + * find the end of the big pair + * + * This will set bpp to the buffer header of the last page of the big pair. + * It will return the pageno of the overflow page following the last page + * of the pair; 0 if there isn't any (i.e. big pair is the last key in the + * bucket) + */ +extern u_int16_t +__find_last_page(hashp, bpp) + HTAB *hashp; + BUFHEAD **bpp; +{ + BUFHEAD *bufp; + u_int16_t *bp, pageno; + int n; + + bufp = *bpp; + bp = (u_int16_t *)bufp->page; + for (;;) { + n = bp[0]; + + /* + * This is the last page if: the tag is FULL_KEY_DATA and + * either only 2 entries OVFLPAGE marker is explicit there + * is freespace on the page. + */ + if (bp[2] == FULL_KEY_DATA && + ((n == 2) || (bp[n] == OVFLPAGE) || (FREESPACE(bp)))) + break; + + pageno = bp[n - 1]; + bufp = __get_buf(hashp, pageno, bufp, 0); + if (!bufp) + return (0); /* Need to indicate an error! */ + bp = (u_int16_t *)bufp->page; + } + + *bpp = bufp; + if (bp[0] > 2) + return (bp[3]); + else + return (0); +} + +/* + * Return the data for the key/data pair that begins on this page at this + * index (index should always be 1). + */ +extern int +__big_return(hashp, bufp, ndx, val, set_current) + HTAB *hashp; + BUFHEAD *bufp; + int ndx; + DBT *val; + int set_current; +{ + BUFHEAD *save_p; + u_int16_t *bp, len, off, save_addr; + char *tp; + + bp = (u_int16_t *)bufp->page; + while (bp[ndx + 1] == PARTIAL_KEY) { + bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!bufp) + return (-1); + bp = (u_int16_t *)bufp->page; + ndx = 1; + } + + if (bp[ndx + 1] == FULL_KEY) { + bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!bufp) + return (-1); + bp = (u_int16_t *)bufp->page; + save_p = bufp; + save_addr = save_p->addr; + off = bp[1]; + len = 0; + } else + if (!FREESPACE(bp)) { + /* + * This is a hack. We can't distinguish between + * FULL_KEY_DATA that contains complete data or + * incomplete data, so we require that if the data + * is complete, there is at least 1 byte of free + * space left. + */ + off = bp[bp[0]]; + len = bp[1] - off; + save_p = bufp; + save_addr = bufp->addr; + bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!bufp) + return (-1); + bp = (u_int16_t *)bufp->page; + } else { + /* The data is all on one page. */ + tp = (char *)bp; + off = bp[bp[0]]; + val->data = (u_char *)tp + off; + val->size = bp[1] - off; + if (set_current) { + if (bp[0] == 2) { /* No more buckets in + * chain */ + hashp->cpage = NULL; + hashp->cbucket++; + hashp->cndx = 1; + } else { + hashp->cpage = __get_buf(hashp, + bp[bp[0] - 1], bufp, 0); + if (!hashp->cpage) + return (-1); + hashp->cndx = 1; + if (!((u_int16_t *) + hashp->cpage->page)[0]) { + hashp->cbucket++; + hashp->cpage = NULL; + } + } + } + return (0); + } + + val->size = collect_data(hashp, bufp, (int)len, set_current); + if (val->size == -1) + return (-1); + if (save_p->addr != save_addr) { + /* We are pretty short on buffers. */ + errno = EINVAL; /* OUT OF BUFFERS */ + return (-1); + } + memmove(hashp->tmp_buf, (save_p->page) + off, len); + val->data = (u_char *)hashp->tmp_buf; + return (0); +} +/* + * Count how big the total datasize is by recursing through the pages. Then + * allocate a buffer and copy the data as you recurse up. + */ +static int +collect_data(hashp, bufp, len, set) + HTAB *hashp; + BUFHEAD *bufp; + int len, set; +{ + register u_int16_t *bp; + register char *p; + BUFHEAD *xbp; + u_int16_t save_addr; + int mylen, totlen; + + p = bufp->page; + bp = (u_int16_t *)p; + mylen = hashp->BSIZE - bp[1]; + save_addr = bufp->addr; + + if (bp[2] == FULL_KEY_DATA) { /* End of Data */ + totlen = len + mylen; + if (hashp->tmp_buf) + free(hashp->tmp_buf); + if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL) + return (-1); + if (set) { + hashp->cndx = 1; + if (bp[0] == 2) { /* No more buckets in chain */ + hashp->cpage = NULL; + hashp->cbucket++; + } else { + hashp->cpage = + __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!hashp->cpage) + return (-1); + else if (!((u_int16_t *)hashp->cpage->page)[0]) { + hashp->cbucket++; + hashp->cpage = NULL; + } + } + } + } else { + xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!xbp || ((totlen = + collect_data(hashp, xbp, len + mylen, set)) < 1)) + return (-1); + } + if (bufp->addr != save_addr) { + errno = EINVAL; /* Out of buffers. */ + return (-1); + } + memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen); + return (totlen); +} + +/* + * Fill in the key and data for this big pair. + */ +extern int +__big_keydata(hashp, bufp, key, val, set) + HTAB *hashp; + BUFHEAD *bufp; + DBT *key, *val; + int set; +{ + key->size = collect_key(hashp, bufp, 0, val, set); + if (key->size == -1) + return (-1); + key->data = (u_char *)hashp->tmp_key; + return (0); +} + +/* + * Count how big the total key size is by recursing through the pages. Then + * collect the data, allocate a buffer and copy the key as you recurse up. + */ +static int +collect_key(hashp, bufp, len, val, set) + HTAB *hashp; + BUFHEAD *bufp; + int len; + DBT *val; + int set; +{ + BUFHEAD *xbp; + char *p; + int mylen, totlen; + u_int16_t *bp, save_addr; + + p = bufp->page; + bp = (u_int16_t *)p; + mylen = hashp->BSIZE - bp[1]; + + save_addr = bufp->addr; + totlen = len + mylen; + if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ + if (hashp->tmp_key != NULL) + free(hashp->tmp_key); + if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL) + return (-1); + if (__big_return(hashp, bufp, 1, val, set)) + return (-1); + } else { + xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!xbp || ((totlen = + collect_key(hashp, xbp, totlen, val, set)) < 1)) + return (-1); + } + if (bufp->addr != save_addr) { + errno = EINVAL; /* MIS -- OUT OF BUFFERS */ + return (-1); + } + memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen); + return (totlen); +} + +/* + * Returns: + * 0 => OK + * -1 => error + */ +extern int +__big_split(hashp, op, np, big_keyp, addr, obucket, ret) + HTAB *hashp; + BUFHEAD *op; /* Pointer to where to put keys that go in old bucket */ + BUFHEAD *np; /* Pointer to new bucket page */ + /* Pointer to first page containing the big key/data */ + BUFHEAD *big_keyp; + int addr; /* Address of big_keyp */ + u_int32_t obucket;/* Old Bucket */ + SPLIT_RETURN *ret; +{ + register BUFHEAD *tmpp; + register u_int16_t *tp; + BUFHEAD *bp; + DBT key, val; + u_int32_t change; + u_int16_t free_space, n, off; + + bp = big_keyp; + + /* Now figure out where the big key/data goes */ + if (__big_keydata(hashp, big_keyp, &key, &val, 0)) + return (-1); + change = (__call_hash(hashp, key.data, key.size) != obucket); + + if (ret->next_addr = __find_last_page(hashp, &big_keyp)) { + if (!(ret->nextp = + __get_buf(hashp, ret->next_addr, big_keyp, 0))) + return (-1);; + } else + ret->nextp = NULL; + + /* Now make one of np/op point to the big key/data pair */ +#ifdef DEBUG + assert(np->ovfl == NULL); +#endif + if (change) + tmpp = np; + else + tmpp = op; + + tmpp->flags |= BUF_MOD; +#ifdef DEBUG1 + (void)fprintf(stderr, + "BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->addr, + (tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0)); +#endif + tmpp->ovfl = bp; /* one of op/np point to big_keyp */ + tp = (u_int16_t *)tmpp->page; +#ifdef DEBUG + assert(FREESPACE(tp) >= OVFLSIZE); +#endif + n = tp[0]; + off = OFFSET(tp); + free_space = FREESPACE(tp); + tp[++n] = (u_int16_t)addr; + tp[++n] = OVFLPAGE; + tp[0] = n; + OFFSET(tp) = off; + FREESPACE(tp) = free_space - OVFLSIZE; + + /* + * Finally, set the new and old return values. BIG_KEYP contains a + * pointer to the last page of the big key_data pair. Make sure that + * big_keyp has no following page (2 elements) or create an empty + * following page. + */ + + ret->newp = np; + ret->oldp = op; + + tp = (u_int16_t *)big_keyp->page; + big_keyp->flags |= BUF_MOD; + if (tp[0] > 2) { + /* + * There may be either one or two offsets on this page. If + * there is one, then the overflow page is linked on normally + * and tp[4] is OVFLPAGE. If there are two, tp[4] contains + * the second offset and needs to get stuffed in after the + * next overflow page is added. + */ + n = tp[4]; + free_space = FREESPACE(tp); + off = OFFSET(tp); + tp[0] -= 2; + FREESPACE(tp) = free_space + OVFLSIZE; + OFFSET(tp) = off; + tmpp = __add_ovflpage(hashp, big_keyp); + if (!tmpp) + return (-1); + tp[4] = n; + } else + tmpp = big_keyp; + + if (change) + ret->newp = tmpp; + else + ret->oldp = tmpp; + return (0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c new file mode 100644 index 0000000..92e1f93 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c @@ -0,0 +1,355 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * PACKAGE: hash + * + * DESCRIPTION: + * Contains buffer management + * + * ROUTINES: + * External + * __buf_init + * __get_buf + * __buf_free + * __reclaim_buf + * Internal + * newbuf + */ + +#include + +#include +#include +#include +#include + +#ifdef DEBUG +#include +#endif + +#include +#include "hash.h" +#include "page.h" +#include "extern.h" + +static BUFHEAD *newbuf __P((HTAB *, u_int32_t, BUFHEAD *)); + +/* Unlink B from its place in the lru */ +#define BUF_REMOVE(B) { \ + (B)->prev->next = (B)->next; \ + (B)->next->prev = (B)->prev; \ +} + +/* Insert B after P */ +#define BUF_INSERT(B, P) { \ + (B)->next = (P)->next; \ + (B)->prev = (P); \ + (P)->next = (B); \ + (B)->next->prev = (B); \ +} + +#define MRU hashp->bufhead.next +#define LRU hashp->bufhead.prev + +#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead) +#define LRU_INSERT(B) BUF_INSERT((B), LRU) + +/* + * We are looking for a buffer with address "addr". If prev_bp is NULL, then + * address is a bucket index. If prev_bp is not NULL, then it points to the + * page previous to an overflow page that we are trying to find. + * + * CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer + * be valid. Therefore, you must always verify that its address matches the + * address you are seeking. + */ +extern BUFHEAD * +__get_buf(hashp, addr, prev_bp, newpage) + HTAB *hashp; + u_int32_t addr; + BUFHEAD *prev_bp; + int newpage; /* If prev_bp set, indicates a new overflow page. */ +{ + register BUFHEAD *bp; + register u_int32_t is_disk_mask; + register int is_disk, segment_ndx; + SEGMENT segp; + + is_disk = 0; + is_disk_mask = 0; + if (prev_bp) { + bp = prev_bp->ovfl; + if (!bp || (bp->addr != addr)) + bp = NULL; + if (!newpage) + is_disk = BUF_DISK; + } else { + /* Grab buffer out of directory */ + segment_ndx = addr & (hashp->SGSIZE - 1); + + /* valid segment ensured by __call_hash() */ + segp = hashp->dir[addr >> hashp->SSHIFT]; +#ifdef DEBUG + assert(segp != NULL); +#endif + bp = PTROF(segp[segment_ndx]); + is_disk_mask = ISDISK(segp[segment_ndx]); + is_disk = is_disk_mask || !hashp->new_file; + } + + if (!bp) { + bp = newbuf(hashp, addr, prev_bp); + if (!bp || + __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) + return (NULL); + if (!prev_bp) + segp[segment_ndx] = + (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask); + } else { + BUF_REMOVE(bp); + MRU_INSERT(bp); + } + return (bp); +} + +/* + * We need a buffer for this page. Either allocate one, or evict a resident + * one (if we have as many buffers as we're allowed) and put this one in. + * + * If newbuf finds an error (returning NULL), it also sets errno. + */ +static BUFHEAD * +newbuf(hashp, addr, prev_bp) + HTAB *hashp; + u_int32_t addr; + BUFHEAD *prev_bp; +{ + register BUFHEAD *bp; /* The buffer we're going to use */ + register BUFHEAD *xbp; /* Temp pointer */ + register BUFHEAD *next_xbp; + SEGMENT segp; + int segment_ndx; + u_int16_t oaddr, *shortp; + + oaddr = 0; + bp = LRU; + /* + * If LRU buffer is pinned, the buffer pool is too small. We need to + * allocate more buffers. + */ + if (hashp->nbufs || (bp->flags & BUF_PIN)) { + /* Allocate a new one */ + if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL) + return (NULL); +#ifdef PURIFY + memset(bp, 0xff, sizeof(BUFHEAD)); +#endif + if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) { + free(bp); + return (NULL); + } +#ifdef PURIFY + memset(bp->page, 0xff, hashp->BSIZE); +#endif + if (hashp->nbufs) + hashp->nbufs--; + } else { + /* Kick someone out */ + BUF_REMOVE(bp); + /* + * If this is an overflow page with addr 0, it's already been + * flushed back in an overflow chain and initialized. + */ + if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { + /* + * Set oaddr before __put_page so that you get it + * before bytes are swapped. + */ + shortp = (u_int16_t *)bp->page; + if (shortp[0]) + oaddr = shortp[shortp[0] - 1]; + if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, + bp->addr, (int)IS_BUCKET(bp->flags), 0)) + return (NULL); + /* + * Update the pointer to this page (i.e. invalidate it). + * + * If this is a new file (i.e. we created it at open + * time), make sure that we mark pages which have been + * written to disk so we retrieve them from disk later, + * rather than allocating new pages. + */ + if (IS_BUCKET(bp->flags)) { + segment_ndx = bp->addr & (hashp->SGSIZE - 1); + segp = hashp->dir[bp->addr >> hashp->SSHIFT]; +#ifdef DEBUG + assert(segp != NULL); +#endif + + if (hashp->new_file && + ((bp->flags & BUF_MOD) || + ISDISK(segp[segment_ndx]))) + segp[segment_ndx] = (BUFHEAD *)BUF_DISK; + else + segp[segment_ndx] = NULL; + } + /* + * Since overflow pages can only be access by means of + * their bucket, free overflow pages associated with + * this bucket. + */ + for (xbp = bp; xbp->ovfl;) { + next_xbp = xbp->ovfl; + xbp->ovfl = 0; + xbp = next_xbp; + + /* Check that ovfl pointer is up date. */ + if (IS_BUCKET(xbp->flags) || + (oaddr != xbp->addr)) + break; + + shortp = (u_int16_t *)xbp->page; + if (shortp[0]) + /* set before __put_page */ + oaddr = shortp[shortp[0] - 1]; + if ((xbp->flags & BUF_MOD) && __put_page(hashp, + xbp->page, xbp->addr, 0, 0)) + return (NULL); + xbp->addr = 0; + xbp->flags = 0; + BUF_REMOVE(xbp); + LRU_INSERT(xbp); + } + } + } + + /* Now assign this buffer */ + bp->addr = addr; +#ifdef DEBUG1 + (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n", + bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); +#endif + bp->ovfl = NULL; + if (prev_bp) { + /* + * If prev_bp is set, this is an overflow page, hook it in to + * the buffer overflow links. + */ +#ifdef DEBUG1 + (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n", + prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0), + (bp ? bp->addr : 0)); +#endif + prev_bp->ovfl = bp; + bp->flags = 0; + } else + bp->flags = BUF_BUCKET; + MRU_INSERT(bp); + return (bp); +} + +extern void +__buf_init(hashp, nbytes) + HTAB *hashp; + int nbytes; +{ + BUFHEAD *bfp; + int npages; + + bfp = &(hashp->bufhead); + npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT; + npages = MAX(npages, MIN_BUFFERS); + + hashp->nbufs = npages; + bfp->next = bfp; + bfp->prev = bfp; + /* + * This space is calloc'd so these are already null. + * + * bfp->ovfl = NULL; + * bfp->flags = 0; + * bfp->page = NULL; + * bfp->addr = 0; + */ +} + +extern int +__buf_free(hashp, do_free, to_disk) + HTAB *hashp; + int do_free, to_disk; +{ + BUFHEAD *bp; + + /* Need to make sure that buffer manager has been initialized */ + if (!LRU) + return (0); + for (bp = LRU; bp != &hashp->bufhead;) { + /* Check that the buffer is valid */ + if (bp->addr || IS_BUCKET(bp->flags)) { + if (to_disk && (bp->flags & BUF_MOD) && + __put_page(hashp, bp->page, + bp->addr, IS_BUCKET(bp->flags), 0)) + return (-1); + } + /* Check if we are freeing stuff */ + if (do_free) { + if (bp->page) + free(bp->page); + BUF_REMOVE(bp); + free(bp); + bp = LRU; + } else + bp = bp->prev; + } + return (0); +} + +extern void +__reclaim_buf(hashp, bp) + HTAB *hashp; + BUFHEAD *bp; +{ + bp->ovfl = 0; + bp->addr = 0; + bp->flags = 0; + BUF_REMOVE(bp); + LRU_INSERT(bp); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c new file mode 100644 index 0000000..a5ec434 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c @@ -0,0 +1,212 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include "hash.h" +#include "page.h" +#include "extern.h" + +static u_int32_t hash1 __P((const void *, size_t)); +static u_int32_t hash2 __P((const void *, size_t)); +static u_int32_t hash3 __P((const void *, size_t)); +static u_int32_t hash4 __P((const void *, size_t)); + +/* Global default hash function */ +u_int32_t (*__default_hash) __P((const void *, size_t)) = hash4; + +/* + * HASH FUNCTIONS + * + * Assume that we've already split the bucket to which this key hashes, + * calculate that bucket, and check that in fact we did already split it. + * + * This came from ejb's hsearch. + */ + +#define PRIME1 37 +#define PRIME2 1048583 + +static u_int32_t +hash1(keyarg, len) + const void *keyarg; + register size_t len; +{ + register const u_char *key; + register u_int32_t h; + + /* Convert string to integer */ + for (key = keyarg, h = 0; len--;) + h = h * PRIME1 ^ (*key++ - ' '); + h %= PRIME2; + return (h); +} + +/* + * Phong's linear congruential hash + */ +#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) + +static u_int32_t +hash2(keyarg, len) + const void *keyarg; + size_t len; +{ + register const u_char *e, *key; + register u_int32_t h; + register u_char c; + + key = keyarg; + e = key + len; + for (h = 0; key != e;) { + c = *key++; + if (!c && key > e) + break; + dcharhash(h, c); + } + return (h); +} + +/* + * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte + * units. On the first time through the loop we get the "leftover bytes" + * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle + * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If + * this routine is heavily used enough, it's worth the ugly coding. + * + * OZ's original sdbm hash + */ +static u_int32_t +hash3(keyarg, len) + const void *keyarg; + register size_t len; +{ + register const u_char *key; + register size_t loop; + register u_int32_t h; + +#define HASHC h = *key++ + 65599 * h + + h = 0; + key = keyarg; + if (len > 0) { + loop = (len + 8 - 1) >> 3; + + switch (len & (8 - 1)) { + case 0: + do { + HASHC; + /* FALLTHROUGH */ + case 7: + HASHC; + /* FALLTHROUGH */ + case 6: + HASHC; + /* FALLTHROUGH */ + case 5: + HASHC; + /* FALLTHROUGH */ + case 4: + HASHC; + /* FALLTHROUGH */ + case 3: + HASHC; + /* FALLTHROUGH */ + case 2: + HASHC; + /* FALLTHROUGH */ + case 1: + HASHC; + } while (--loop); + } + } + return (h); +} + +/* Hash function from Chris Torek. */ +static u_int32_t +hash4(keyarg, len) + const void *keyarg; + register size_t len; +{ + register const u_char *key; + register size_t loop; + register u_int32_t h; + +#define HASH4a h = (h << 5) - h + *key++; +#define HASH4b h = (h << 5) + h + *key++; +#define HASH4 HASH4b + + h = 0; + key = keyarg; + if (len > 0) { + loop = (len + 8 - 1) >> 3; + + switch (len & (8 - 1)) { + case 0: + do { + HASH4; + /* FALLTHROUGH */ + case 7: + HASH4; + /* FALLTHROUGH */ + case 6: + HASH4; + /* FALLTHROUGH */ + case 5: + HASH4; + /* FALLTHROUGH */ + case 4: + HASH4; + /* FALLTHROUGH */ + case 3: + HASH4; + /* FALLTHROUGH */ + case 2: + HASH4; + /* FALLTHROUGH */ + case 1: + HASH4; + } while (--loop); + } + } + return (h); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c new file mode 100644 index 0000000..c8c56bf --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include + +u_int32_t +__log2(num) + u_int32_t num; +{ + register u_int32_t i, limit; + + limit = 1; + for (i = 0; limit < num; limit = limit << 1, i++); + return (i); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c new file mode 100644 index 0000000..e1dfe6b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c @@ -0,0 +1,944 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * PACKAGE: hashing + * + * DESCRIPTION: + * Page manipulation for hashing package. + * + * ROUTINES: + * + * External + * __get_page + * __add_ovflpage + * Internal + * overflow_page + * open_temp + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#ifdef DEBUG +#include +#endif + +#include +#include "hash.h" +#include "page.h" +#include "extern.h" + +static u_int32_t *fetch_bitmap __P((HTAB *, int)); +static u_int32_t first_free __P((u_int32_t)); +static int open_temp __P((HTAB *)); +static u_int16_t overflow_page __P((HTAB *)); +static void putpair __P((char *, const DBT *, const DBT *)); +static void squeeze_key __P((u_int16_t *, const DBT *, const DBT *)); +static int ugly_split + __P((HTAB *, u_int32_t, BUFHEAD *, BUFHEAD *, int, int)); + +#define PAGE_INIT(P) { \ + ((u_int16_t *)(P))[0] = 0; \ + ((u_int16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_int16_t); \ + ((u_int16_t *)(P))[2] = hashp->BSIZE; \ +} + +/* + * This is called AFTER we have verified that there is room on the page for + * the pair (PAIRFITS has returned true) so we go right ahead and start moving + * stuff on. + */ +static void +putpair(p, key, val) + char *p; + const DBT *key, *val; +{ + register u_int16_t *bp, n, off; + + bp = (u_int16_t *)p; + + /* Enter the key first. */ + n = bp[0]; + + off = OFFSET(bp) - key->size; + memmove(p + off, key->data, key->size); + bp[++n] = off; + + /* Now the data. */ + off -= val->size; + memmove(p + off, val->data, val->size); + bp[++n] = off; + + /* Adjust page info. */ + bp[0] = n; + bp[n + 1] = off - ((n + 3) * sizeof(u_int16_t)); + bp[n + 2] = off; +} + +/* + * Returns: + * 0 OK + * -1 error + */ +extern int +__delpair(hashp, bufp, ndx) + HTAB *hashp; + BUFHEAD *bufp; + register int ndx; +{ + register u_int16_t *bp, newoff; + register int n; + u_int16_t pairlen; + + bp = (u_int16_t *)bufp->page; + n = bp[0]; + + if (bp[ndx + 1] < REAL_KEY) + return (__big_delete(hashp, bufp)); + if (ndx != 1) + newoff = bp[ndx - 1]; + else + newoff = hashp->BSIZE; + pairlen = newoff - bp[ndx + 1]; + + if (ndx != (n - 1)) { + /* Hard Case -- need to shuffle keys */ + register int i; + register char *src = bufp->page + (int)OFFSET(bp); + register char *dst = src + (int)pairlen; + memmove(dst, src, bp[ndx + 1] - OFFSET(bp)); + + /* Now adjust the pointers */ + for (i = ndx + 2; i <= n; i += 2) { + if (bp[i + 1] == OVFLPAGE) { + bp[i - 2] = bp[i]; + bp[i - 1] = bp[i + 1]; + } else { + bp[i - 2] = bp[i] + pairlen; + bp[i - 1] = bp[i + 1] + pairlen; + } + } + } + /* Finally adjust the page data */ + bp[n] = OFFSET(bp) + pairlen; + bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(u_int16_t); + bp[0] = n - 2; + hashp->NKEYS--; + + bufp->flags |= BUF_MOD; + return (0); +} +/* + * Returns: + * 0 ==> OK + * -1 ==> Error + */ +extern int +__split_page(hashp, obucket, nbucket) + HTAB *hashp; + u_int32_t obucket, nbucket; +{ + register BUFHEAD *new_bufp, *old_bufp; + register u_int16_t *ino; + register char *np; + DBT key, val; + int n, ndx, retval; + u_int16_t copyto, diff, off, moved; + char *op; + + copyto = (u_int16_t)hashp->BSIZE; + off = (u_int16_t)hashp->BSIZE; + old_bufp = __get_buf(hashp, obucket, NULL, 0); + if (old_bufp == NULL) + return (-1); + new_bufp = __get_buf(hashp, nbucket, NULL, 0); + if (new_bufp == NULL) + return (-1); + + old_bufp->flags |= (BUF_MOD | BUF_PIN); + new_bufp->flags |= (BUF_MOD | BUF_PIN); + + ino = (u_int16_t *)(op = old_bufp->page); + np = new_bufp->page; + + moved = 0; + + for (n = 1, ndx = 1; n < ino[0]; n += 2) { + if (ino[n + 1] < REAL_KEY) { + retval = ugly_split(hashp, obucket, old_bufp, new_bufp, + (int)copyto, (int)moved); + old_bufp->flags &= ~BUF_PIN; + new_bufp->flags &= ~BUF_PIN; + return (retval); + + } + key.data = (u_char *)op + ino[n]; + key.size = off - ino[n]; + + if (__call_hash(hashp, key.data, key.size) == obucket) { + /* Don't switch page */ + diff = copyto - off; + if (diff) { + copyto = ino[n + 1] + diff; + memmove(op + copyto, op + ino[n + 1], + off - ino[n + 1]); + ino[ndx] = copyto + ino[n] - ino[n + 1]; + ino[ndx + 1] = copyto; + } else + copyto = ino[n + 1]; + ndx += 2; + } else { + /* Switch page */ + val.data = (u_char *)op + ino[n + 1]; + val.size = ino[n] - ino[n + 1]; + putpair(np, &key, &val); + moved += 2; + } + + off = ino[n + 1]; + } + + /* Now clean up the page */ + ino[0] -= moved; + FREESPACE(ino) = copyto - sizeof(u_int16_t) * (ino[0] + 3); + OFFSET(ino) = copyto; + +#ifdef DEBUG3 + (void)fprintf(stderr, "split %d/%d\n", + ((u_int16_t *)np)[0] / 2, + ((u_int16_t *)op)[0] / 2); +#endif + /* unpin both pages */ + old_bufp->flags &= ~BUF_PIN; + new_bufp->flags &= ~BUF_PIN; + return (0); +} + +/* + * Called when we encounter an overflow or big key/data page during split + * handling. This is special cased since we have to begin checking whether + * the key/data pairs fit on their respective pages and because we may need + * overflow pages for both the old and new pages. + * + * The first page might be a page with regular key/data pairs in which case + * we have a regular overflow condition and just need to go on to the next + * page or it might be a big key/data pair in which case we need to fix the + * big key/data pair. + * + * Returns: + * 0 ==> success + * -1 ==> failure + */ +static int +ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) + HTAB *hashp; + u_int32_t obucket; /* Same as __split_page. */ + BUFHEAD *old_bufp, *new_bufp; + int copyto; /* First byte on page which contains key/data values. */ + int moved; /* Number of pairs moved to new page. */ +{ + register BUFHEAD *bufp; /* Buffer header for ino */ + register u_int16_t *ino; /* Page keys come off of */ + register u_int16_t *np; /* New page */ + register u_int16_t *op; /* Page keys go on to if they aren't moving */ + + BUFHEAD *last_bfp; /* Last buf header OVFL needing to be freed */ + DBT key, val; + SPLIT_RETURN ret; + u_int16_t n, off, ov_addr, scopyto; + char *cino; /* Character value of ino */ + + bufp = old_bufp; + ino = (u_int16_t *)old_bufp->page; + np = (u_int16_t *)new_bufp->page; + op = (u_int16_t *)old_bufp->page; + last_bfp = NULL; + scopyto = (u_int16_t)copyto; /* ANSI */ + + n = ino[0] - 1; + while (n < ino[0]) { + if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) { + if (__big_split(hashp, old_bufp, + new_bufp, bufp, bufp->addr, obucket, &ret)) + return (-1); + old_bufp = ret.oldp; + if (!old_bufp) + return (-1); + op = (u_int16_t *)old_bufp->page; + new_bufp = ret.newp; + if (!new_bufp) + return (-1); + np = (u_int16_t *)new_bufp->page; + bufp = ret.nextp; + if (!bufp) + return (0); + cino = (char *)bufp->page; + ino = (u_int16_t *)cino; + last_bfp = ret.nextp; + } else if (ino[n + 1] == OVFLPAGE) { + ov_addr = ino[n]; + /* + * Fix up the old page -- the extra 2 are the fields + * which contained the overflow information. + */ + ino[0] -= (moved + 2); + FREESPACE(ino) = + scopyto - sizeof(u_int16_t) * (ino[0] + 3); + OFFSET(ino) = scopyto; + + bufp = __get_buf(hashp, ov_addr, bufp, 0); + if (!bufp) + return (-1); + + ino = (u_int16_t *)bufp->page; + n = 1; + scopyto = hashp->BSIZE; + moved = 0; + + if (last_bfp) + __free_ovflpage(hashp, last_bfp); + last_bfp = bufp; + } + /* Move regular sized pairs of there are any */ + off = hashp->BSIZE; + for (n = 1; (n < ino[0]) && (ino[n + 1] >= REAL_KEY); n += 2) { + cino = (char *)ino; + key.data = (u_char *)cino + ino[n]; + key.size = off - ino[n]; + val.data = (u_char *)cino + ino[n + 1]; + val.size = ino[n] - ino[n + 1]; + off = ino[n + 1]; + + if (__call_hash(hashp, key.data, key.size) == obucket) { + /* Keep on old page */ + if (PAIRFITS(op, (&key), (&val))) + putpair((char *)op, &key, &val); + else { + old_bufp = + __add_ovflpage(hashp, old_bufp); + if (!old_bufp) + return (-1); + op = (u_int16_t *)old_bufp->page; + putpair((char *)op, &key, &val); + } + old_bufp->flags |= BUF_MOD; + } else { + /* Move to new page */ + if (PAIRFITS(np, (&key), (&val))) + putpair((char *)np, &key, &val); + else { + new_bufp = + __add_ovflpage(hashp, new_bufp); + if (!new_bufp) + return (-1); + np = (u_int16_t *)new_bufp->page; + putpair((char *)np, &key, &val); + } + new_bufp->flags |= BUF_MOD; + } + } + } + if (last_bfp) + __free_ovflpage(hashp, last_bfp); + return (0); +} + +/* + * Add the given pair to the page + * + * Returns: + * 0 ==> OK + * 1 ==> failure + */ +extern int +__addel(hashp, bufp, key, val) + HTAB *hashp; + BUFHEAD *bufp; + const DBT *key, *val; +{ + register u_int16_t *bp, *sop; + int do_expand; + + bp = (u_int16_t *)bufp->page; + do_expand = 0; + while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY)) + /* Exception case */ + if (bp[2] == FULL_KEY_DATA && bp[0] == 2) + /* This is the last page of a big key/data pair + and we need to add another page */ + break; + else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { + bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!bufp) + return (-1); + bp = (u_int16_t *)bufp->page; + } else + /* Try to squeeze key on this page */ + if (FREESPACE(bp) > PAIRSIZE(key, val)) { + squeeze_key(bp, key, val); + return (0); + } else { + bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); + if (!bufp) + return (-1); + bp = (u_int16_t *)bufp->page; + } + + if (PAIRFITS(bp, key, val)) + putpair(bufp->page, key, val); + else { + do_expand = 1; + bufp = __add_ovflpage(hashp, bufp); + if (!bufp) + return (-1); + sop = (u_int16_t *)bufp->page; + + if (PAIRFITS(sop, key, val)) + putpair((char *)sop, key, val); + else + if (__big_insert(hashp, bufp, key, val)) + return (-1); + } + bufp->flags |= BUF_MOD; + /* + * If the average number of keys per bucket exceeds the fill factor, + * expand the table. + */ + hashp->NKEYS++; + if (do_expand || + (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR)) + return (__expand_table(hashp)); + return (0); +} + +/* + * + * Returns: + * pointer on success + * NULL on error + */ +extern BUFHEAD * +__add_ovflpage(hashp, bufp) + HTAB *hashp; + BUFHEAD *bufp; +{ + register u_int16_t *sp; + u_int16_t ndx, ovfl_num; +#ifdef DEBUG1 + int tmp1, tmp2; +#endif + sp = (u_int16_t *)bufp->page; + + /* Check if we are dynamically determining the fill factor */ + if (hashp->FFACTOR == DEF_FFACTOR) { + hashp->FFACTOR = sp[0] >> 1; + if (hashp->FFACTOR < MIN_FFACTOR) + hashp->FFACTOR = MIN_FFACTOR; + } + bufp->flags |= BUF_MOD; + ovfl_num = overflow_page(hashp); +#ifdef DEBUG1 + tmp1 = bufp->addr; + tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0; +#endif + if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1))) + return (NULL); + bufp->ovfl->flags |= BUF_MOD; +#ifdef DEBUG1 + (void)fprintf(stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n", + tmp1, tmp2, bufp->ovfl->addr); +#endif + ndx = sp[0]; + /* + * Since a pair is allocated on a page only if there's room to add + * an overflow page, we know that the OVFL information will fit on + * the page. + */ + sp[ndx + 4] = OFFSET(sp); + sp[ndx + 3] = FREESPACE(sp) - OVFLSIZE; + sp[ndx + 1] = ovfl_num; + sp[ndx + 2] = OVFLPAGE; + sp[0] = ndx + 2; +#ifdef HASH_STATISTICS + hash_overflows++; +#endif + return (bufp->ovfl); +} + +/* + * Returns: + * 0 indicates SUCCESS + * -1 indicates FAILURE + */ +extern int +__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) + HTAB *hashp; + char *p; + u_int32_t bucket; + int is_bucket, is_disk, is_bitmap; +{ + register int fd, page, size; + int rsize; + u_int16_t *bp; + + fd = hashp->fp; + size = hashp->BSIZE; + + if ((fd == -1) || !is_disk) { + PAGE_INIT(p); + return (0); + } + if (is_bucket) + page = BUCKET_TO_PAGE(bucket); + else + page = OADDR_TO_PAGE(bucket); + if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || + ((rsize = read(fd, p, size)) == -1)) + return (-1); + bp = (u_int16_t *)p; + if (!rsize) + bp[0] = 0; /* We hit the EOF, so initialize a new page */ + else + if (rsize != size) { + errno = EFTYPE; + return (-1); + } + if (!is_bitmap && !bp[0]) { + PAGE_INIT(p); + } else + if (hashp->LORDER != BYTE_ORDER) { + register int i, max; + + if (is_bitmap) { + max = hashp->BSIZE >> 2; /* divide by 4 */ + for (i = 0; i < max; i++) + M_32_SWAP(((int *)p)[i]); + } else { + M_16_SWAP(bp[0]); + max = bp[0] + 2; + for (i = 1; i <= max; i++) + M_16_SWAP(bp[i]); + } + } + return (0); +} + +/* + * Write page p to disk + * + * Returns: + * 0 ==> OK + * -1 ==>failure + */ +extern int +__put_page(hashp, p, bucket, is_bucket, is_bitmap) + HTAB *hashp; + char *p; + u_int32_t bucket; + int is_bucket, is_bitmap; +{ + register int fd, page, size; + int wsize; + + size = hashp->BSIZE; + if ((hashp->fp == -1) && open_temp(hashp)) + return (-1); + fd = hashp->fp; + + if (hashp->LORDER != BYTE_ORDER) { + register int i; + register int max; + + if (is_bitmap) { + max = hashp->BSIZE >> 2; /* divide by 4 */ + for (i = 0; i < max; i++) + M_32_SWAP(((int *)p)[i]); + } else { + max = ((u_int16_t *)p)[0] + 2; + for (i = 0; i <= max; i++) + M_16_SWAP(((u_int16_t *)p)[i]); + } + } + if (is_bucket) + page = BUCKET_TO_PAGE(bucket); + else + page = OADDR_TO_PAGE(bucket); + if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || + ((wsize = write(fd, p, size)) == -1)) + /* Errno is set */ + return (-1); + if (wsize != size) { + errno = EFTYPE; + return (-1); + } + return (0); +} + +#define BYTE_MASK ((1 << INT_BYTE_SHIFT) -1) +/* + * Initialize a new bitmap page. Bitmap pages are left in memory + * once they are read in. + */ +extern int +__ibitmap(hashp, pnum, nbits, ndx) + HTAB *hashp; + int pnum, nbits, ndx; +{ + u_int32_t *ip; + int clearbytes, clearints; + + if ((ip = (u_int32_t *)malloc(hashp->BSIZE)) == NULL) + return (1); + hashp->nmaps++; + clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; + clearbytes = clearints << INT_TO_BYTE; + (void)memset((char *)ip, 0, clearbytes); + (void)memset(((char *)ip) + clearbytes, 0xFF, + hashp->BSIZE - clearbytes); + ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK); + SETBIT(ip, 0); + hashp->BITMAPS[ndx] = (u_int16_t)pnum; + hashp->mapp[ndx] = ip; + return (0); +} + +static u_int32_t +first_free(map) + u_int32_t map; +{ + register u_int32_t i, mask; + + mask = 0x1; + for (i = 0; i < BITS_PER_MAP; i++) { + if (!(mask & map)) + return (i); + mask = mask << 1; + } + return (i); +} + +static u_int16_t +overflow_page(hashp) + HTAB *hashp; +{ + register u_int32_t *freep; + register int max_free, offset, splitnum; + u_int16_t addr; + int bit, first_page, free_bit, free_page, i, in_use_bits, j; +#ifdef DEBUG2 + int tmp1, tmp2; +#endif + splitnum = hashp->OVFL_POINT; + max_free = hashp->SPARES[splitnum]; + + free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT); + free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1); + + /* Look through all the free maps to find the first free block */ + first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT); + for ( i = first_page; i <= free_page; i++ ) { + if (!(freep = (u_int32_t *)hashp->mapp[i]) && + !(freep = fetch_bitmap(hashp, i))) + return (0); + if (i == free_page) + in_use_bits = free_bit; + else + in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1; + + if (i == first_page) { + bit = hashp->LAST_FREED & + ((hashp->BSIZE << BYTE_SHIFT) - 1); + j = bit / BITS_PER_MAP; + bit = bit & ~(BITS_PER_MAP - 1); + } else { + bit = 0; + j = 0; + } + for (; bit <= in_use_bits; j++, bit += BITS_PER_MAP) + if (freep[j] != ALL_SET) + goto found; + } + + /* No Free Page Found */ + hashp->LAST_FREED = hashp->SPARES[splitnum]; + hashp->SPARES[splitnum]++; + offset = hashp->SPARES[splitnum] - + (splitnum ? hashp->SPARES[splitnum - 1] : 0); + +#define OVMSG "HASH: Out of overflow pages. Increase page size\n" + if (offset > SPLITMASK) { + if (++splitnum >= NCACHED) { + (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); + return (0); + } + hashp->OVFL_POINT = splitnum; + hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; + hashp->SPARES[splitnum-1]--; + offset = 1; + } + + /* Check if we need to allocate a new bitmap page */ + if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { + free_page++; + if (free_page >= NCACHED) { + (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); + return (0); + } + /* + * This is tricky. The 1 indicates that you want the new page + * allocated with 1 clear bit. Actually, you are going to + * allocate 2 pages from this map. The first is going to be + * the map page, the second is the overflow page we were + * looking for. The init_bitmap routine automatically, sets + * the first bit of itself to indicate that the bitmap itself + * is in use. We would explicitly set the second bit, but + * don't have to if we tell init_bitmap not to leave it clear + * in the first place. + */ + if (__ibitmap(hashp, + (int)OADDR_OF(splitnum, offset), 1, free_page)) + return (0); + hashp->SPARES[splitnum]++; +#ifdef DEBUG2 + free_bit = 2; +#endif + offset++; + if (offset > SPLITMASK) { + if (++splitnum >= NCACHED) { + (void)write(STDERR_FILENO, OVMSG, + sizeof(OVMSG) - 1); + return (0); + } + hashp->OVFL_POINT = splitnum; + hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; + hashp->SPARES[splitnum-1]--; + offset = 0; + } + } else { + /* + * Free_bit addresses the last used bit. Bump it to address + * the first available bit. + */ + free_bit++; + SETBIT(freep, free_bit); + } + + /* Calculate address of the new overflow page */ + addr = OADDR_OF(splitnum, offset); +#ifdef DEBUG2 + (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", + addr, free_bit, free_page); +#endif + return (addr); + +found: + bit = bit + first_free(freep[j]); + SETBIT(freep, bit); +#ifdef DEBUG2 + tmp1 = bit; + tmp2 = i; +#endif + /* + * Bits are addressed starting with 0, but overflow pages are addressed + * beginning at 1. Bit is a bit addressnumber, so we need to increment + * it to convert it to a page number. + */ + bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT)); + if (bit >= hashp->LAST_FREED) + hashp->LAST_FREED = bit - 1; + + /* Calculate the split number for this page */ + for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++); + offset = (i ? bit - hashp->SPARES[i - 1] : bit); + if (offset >= SPLITMASK) + return (0); /* Out of overflow pages */ + addr = OADDR_OF(i, offset); +#ifdef DEBUG2 + (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", + addr, tmp1, tmp2); +#endif + + /* Allocate and return the overflow page */ + return (addr); +} + +/* + * Mark this overflow page as free. + */ +extern void +__free_ovflpage(hashp, obufp) + HTAB *hashp; + BUFHEAD *obufp; +{ + register u_int16_t addr; + u_int32_t *freep; + int bit_address, free_page, free_bit; + u_int16_t ndx; + + addr = obufp->addr; +#ifdef DEBUG1 + (void)fprintf(stderr, "Freeing %d\n", addr); +#endif + ndx = (((u_int16_t)addr) >> SPLITSHIFT); + bit_address = + (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1; + if (bit_address < hashp->LAST_FREED) + hashp->LAST_FREED = bit_address; + free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT)); + free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1); + + if (!(freep = hashp->mapp[free_page])) + freep = fetch_bitmap(hashp, free_page); +#ifdef DEBUG + /* + * This had better never happen. It means we tried to read a bitmap + * that has already had overflow pages allocated off it, and we + * failed to read it from the file. + */ + if (!freep) + assert(0); +#endif + CLRBIT(freep, free_bit); +#ifdef DEBUG2 + (void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", + obufp->addr, free_bit, free_page); +#endif + __reclaim_buf(hashp, obufp); +} + +/* + * Returns: + * 0 success + * -1 failure + */ +static int +open_temp(hashp) + HTAB *hashp; +{ + sigset_t set, oset; + static char namestr[] = "_hashXXXXXX"; + + /* Block signals; make sure file goes away at process exit. */ + (void)sigfillset(&set); + (void)sigprocmask(SIG_BLOCK, &set, &oset); + if ((hashp->fp = mkstemp(namestr)) != -1) { + (void)unlink(namestr); + (void)fcntl(hashp->fp, F_SETFD, 1); + } + (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); + return (hashp->fp != -1 ? 0 : -1); +} + +/* + * We have to know that the key will fit, but the last entry on the page is + * an overflow pair, so we need to shift things. + */ +static void +squeeze_key(sp, key, val) + u_int16_t *sp; + const DBT *key, *val; +{ + register char *p; + u_int16_t free_space, n, off, pageno; + + p = (char *)sp; + n = sp[0]; + free_space = FREESPACE(sp); + off = OFFSET(sp); + + pageno = sp[n - 1]; + off -= key->size; + sp[n - 1] = off; + memmove(p + off, key->data, key->size); + off -= val->size; + sp[n] = off; + memmove(p + off, val->data, val->size); + sp[0] = n + 2; + sp[n + 1] = pageno; + sp[n + 2] = OVFLPAGE; + FREESPACE(sp) = free_space - PAIRSIZE(key, val); + OFFSET(sp) = off; +} + +static u_int32_t * +fetch_bitmap(hashp, ndx) + HTAB *hashp; + int ndx; +{ + if (ndx >= hashp->nmaps) + return (NULL); + if ((hashp->mapp[ndx] = (u_int32_t *)malloc(hashp->BSIZE)) == NULL) + return (NULL); + if (__get_page(hashp, + (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) { + free(hashp->mapp[ndx]); + return (NULL); + } + return (hashp->mapp[ndx]); +} + +#ifdef DEBUG4 +int +print_chain(addr) + int addr; +{ + BUFHEAD *bufp; + short *bp, oaddr; + + (void)fprintf(stderr, "%d ", addr); + bufp = __get_buf(hashp, addr, NULL, 0); + bp = (short *)bufp->page; + while (bp[0] && ((bp[bp[0]] == OVFLPAGE) || + ((bp[0] > 2) && bp[2] < REAL_KEY))) { + oaddr = bp[bp[0] - 1]; + (void)fprintf(stderr, "%d ", (int)oaddr); + bufp = __get_buf(hashp, (int)oaddr, bufp, 0); + bp = (short *)bufp->page; + } + (void)fprintf(stderr, "\n"); +} +#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c b/user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c new file mode 100644 index 0000000..cc8f7a4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c @@ -0,0 +1,107 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)hsearch.c 8.4 (Berkeley) 7/21/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include + +#include +#include "search.h" + +static DB *dbp = NULL; +static ENTRY retval; + +extern int +hcreate(nel) + u_int nel; +{ + HASHINFO info; + + info.nelem = nel; + info.bsize = 256; + info.ffactor = 8; + info.cachesize = 0; + info.hash = NULL; + info.lorder = 0; + dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0); + return ((int)dbp); +} + +extern ENTRY * +hsearch(item, action) + ENTRY item; + ACTION action; +{ + DBT key, val; + int status; + + if (!dbp) + return (NULL); + key.data = (u_char *)item.key; + key.size = strlen(item.key) + 1; + + if (action == ENTER) { + val.data = (u_char *)item.data; + val.size = strlen(item.data) + 1; + status = (dbp->put)(dbp, &key, &val, R_NOOVERWRITE); + if (status) + return (NULL); + } else { + /* FIND */ + status = (dbp->get)(dbp, &key, &val, 0); + if (status) + return (NULL); + else + item.data = (char *)val.data; + } + retval.key = item.key; + retval.data = item.data; + return (&retval); +} + +extern void +hdestroy() +{ + if (dbp) { + (void)(dbp->close)(dbp); + dbp = NULL; + } +} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c b/user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c new file mode 100644 index 0000000..2cbbe91 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c @@ -0,0 +1,202 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * This package provides a dbm compatible interface to the new hashing + * package described in db(3). + */ + +#include + +#include +#include + +#include +#include "hash.h" + +/* + * Returns: + * *DBM on success + * NULL on failure + */ +extern DBM * +dbm_open(file, flags, mode) + const char *file; + int flags, mode; +{ + HASHINFO info; + char path[MAXPATHLEN]; + + info.bsize = 4096; + info.ffactor = 40; + info.nelem = 1; + info.cachesize = 0; + info.hash = NULL; + info.lorder = 0; + (void)strcpy(path, file); + (void)strcat(path, DBM_SUFFIX); + return ((DBM *)__hash_open(path, flags, mode, &info, 0)); +} + +extern void +dbm_close(db) + DBM *db; +{ + (void)(db->close)(db); +} + +/* + * Returns: + * DATUM on success + * NULL on failure + */ +extern datum +dbm_fetch(db, key) + DBM *db; + datum key; +{ + datum retval; + int status; + + status = (db->get)(db, (DBT *)&key, (DBT *)&retval, 0); + if (status) { + retval.dptr = NULL; + retval.dsize = 0; + } + return (retval); +} + +/* + * Returns: + * DATUM on success + * NULL on failure + */ +extern datum +dbm_firstkey(db) + DBM *db; +{ + int status; + datum retdata, retkey; + + status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_FIRST); + if (status) + retkey.dptr = NULL; + return (retkey); +} + +/* + * Returns: + * DATUM on success + * NULL on failure + */ +extern datum +dbm_nextkey(db) + DBM *db; +{ + int status; + datum retdata, retkey; + + status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_NEXT); + if (status) + retkey.dptr = NULL; + return (retkey); +} +/* + * Returns: + * 0 on success + * <0 failure + */ +extern int +dbm_delete(db, key) + DBM *db; + datum key; +{ + int status; + + status = (db->del)(db, (DBT *)&key, 0); + if (status) + return (-1); + else + return (0); +} + +/* + * Returns: + * 0 on success + * <0 failure + * 1 if DBM_INSERT and entry exists + */ +extern int +dbm_store(db, key, content, flags) + DBM *db; + datum key, content; + int flags; +{ + return ((db->put)(db, (DBT *)&key, (DBT *)&content, + (flags == DBM_INSERT) ? R_NOOVERWRITE : 0)); +} + +extern int +dbm_error(db) + DBM *db; +{ + HTAB *hp; + + hp = (HTAB *)db->internal; + return (hp->errno); +} + +extern int +dbm_clearerr(db) + DBM *db; +{ + HTAB *hp; + + hp = (HTAB *)db->internal; + hp->errno = 0; + return (0); +} + +extern int +dbm_dirfno(db) + DBM *db; +{ + return(((HTAB *)db->internal)->fp); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/page.h b/user/mpy/lib/berkeley-db-1.xx/hash/page.h new file mode 100644 index 0000000..0fc0d5a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/page.h @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)page.h 8.2 (Berkeley) 5/31/94 + */ + +/* + * Definitions for hashing page file format. + */ + +/* + * routines dealing with a data page + * + * page format: + * +------------------------------+ + * p | n | keyoff | datoff | keyoff | + * +------------+--------+--------+ + * | datoff | free | ptr | --> | + * +--------+---------------------+ + * | F R E E A R E A | + * +--------------+---------------+ + * | <---- - - - | data | + * +--------+-----+----+----------+ + * | key | data | key | + * +--------+----------+----------+ + * + * Pointer to the free space is always: p[p[0] + 2] + * Amount of free space on the page is: p[p[0] + 1] + */ + +/* + * How many bytes required for this pair? + * 2 shorts in the table at the top of the page + room for the + * key and room for the data + * + * We prohibit entering a pair on a page unless there is also room to append + * an overflow page. The reason for this it that you can get in a situation + * where a single key/data pair fits on a page, but you can't append an + * overflow page and later you'd have to split the key/data and handle like + * a big pair. + * You might as well do this up front. + */ + +#define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->size + (D)->size) +#define BIGOVERHEAD (4*sizeof(u_int16_t)) +#define KEYSIZE(K) (4*sizeof(u_int16_t) + (K)->size); +#define OVFLSIZE (2*sizeof(u_int16_t)) +#define FREESPACE(P) ((P)[(P)[0]+1]) +#define OFFSET(P) ((P)[(P)[0]+2]) +#define PAIRFITS(P,K,D) \ + (((P)[2] >= REAL_KEY) && \ + (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) +#define PAGE_META(N) (((N)+3) * sizeof(u_int16_t)) + +typedef struct { + BUFHEAD *newp; + BUFHEAD *oldp; + BUFHEAD *nextp; + u_int16_t next_addr; +} SPLIT_RETURN; diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/search.h b/user/mpy/lib/berkeley-db-1.xx/hash/search.h new file mode 100644 index 0000000..4d3b914 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/search.h @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)search.h 8.1 (Berkeley) 6/4/93 + */ + +/* Backward compatibility to hsearch interface. */ +typedef struct entry { + char *key; + char *data; +} ENTRY; + +typedef enum { + FIND, ENTER +} ACTION; + +int hcreate __P((unsigned int)); +void hdestroy __P((void)); +ENTRY *hsearch __P((ENTRY, ACTION)); diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/tags b/user/mpy/lib/berkeley-db-1.xx/hash/tags new file mode 120000 index 0000000..7ab656b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/hash/tags @@ -0,0 +1 @@ +../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/include/db.h b/user/mpy/lib/berkeley-db-1.xx/include/db.h new file mode 100644 index 0000000..2029de5 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/include/db.h @@ -0,0 +1,237 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)db.h 8.7 (Berkeley) 6/16/94 + */ + +#ifndef _DB_H_ +#define _DB_H_ + +#include +#include + +#include + +#include +#ifdef __DBINTERFACE_PRIVATE +#include +#endif + +#define RET_ERROR -1 /* Return values. */ +#define RET_SUCCESS 0 +#define RET_SPECIAL 1 + +#ifndef __BIT_TYPES_DEFINED__ +#define __BIT_TYPES_DEFINED__ +typedef __signed char int8_t; +typedef unsigned char u_int8_t; +typedef short int16_t; +typedef unsigned short u_int16_t; +typedef int int32_t; +typedef unsigned int u_int32_t; +#ifdef WE_DONT_NEED_QUADS +typedef long long int64_t; +typedef unsigned long long u_int64_t; +#endif +#endif + +#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ +typedef u_int32_t pgno_t; +#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ +typedef u_int16_t indx_t; +#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ +typedef u_int32_t recno_t; + +/* Key/data structure -- a Data-Base Thang. */ +typedef struct { + void *data; /* data */ + size_t size; /* data length */ +} DBT; + +/* Routine flags. */ +#define R_CURSOR 1 /* del, put, seq */ +#define __R_UNUSED 2 /* UNUSED */ +#define R_FIRST 3 /* seq */ +#define R_IAFTER 4 /* put (RECNO) */ +#define R_IBEFORE 5 /* put (RECNO) */ +#define R_LAST 6 /* seq (BTREE, RECNO) */ +#define R_NEXT 7 /* seq */ +#define R_NOOVERWRITE 8 /* put */ +#define R_PREV 9 /* seq (BTREE, RECNO) */ +#define R_SETCURSOR 10 /* put (RECNO) */ +#define R_RECNOSYNC 11 /* sync (RECNO) */ + +typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; + +/* + * !!! + * The following flags are included in the dbopen(3) call as part of the + * open(2) flags. In order to avoid conflicts with the open flags, start + * at the top of the 16 or 32-bit number space and work our way down. If + * the open flags were significantly expanded in the future, it could be + * a problem. Wish I'd left another flags word in the dbopen call. + * + * !!! + * None of this stuff is implemented yet. The only reason that it's here + * is so that the access methods can skip copying the key/data pair when + * the DB_LOCK flag isn't set. + */ +#if UINT_MAX > 65535 +#define DB_LOCK 0x20000000 /* Do locking. */ +#define DB_SHMEM 0x40000000 /* Use shared memory. */ +#define DB_TXN 0x80000000 /* Do transactions. */ +#else +#define DB_LOCK 0x2000 /* Do locking. */ +#define DB_SHMEM 0x4000 /* Use shared memory. */ +#define DB_TXN 0x8000 /* Do transactions. */ +#endif + +/* Access method description structure. */ +typedef struct __db { + DBTYPE type; /* Underlying db type. */ + int (*close) __P((struct __db *)); + int (*del) __P((const struct __db *, const DBT *, u_int)); + int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); + int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); + int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); + int (*sync) __P((const struct __db *, u_int)); + void *internal; /* Access method private. */ + int (*fd) __P((const struct __db *)); +} DB; + +#define BTREEMAGIC 0x053162 +#define BTREEVERSION 3 + +/* Structure used to pass parameters to the btree routines. */ +typedef struct { +#define R_DUP 0x01 /* duplicate keys */ + u_long flags; + u_int cachesize; /* bytes to cache */ + int maxkeypage; /* maximum keys per page */ + int minkeypage; /* minimum keys per page */ + u_int psize; /* page size */ + int (*compare) /* comparison function */ + __P((const DBT *, const DBT *)); + size_t (*prefix) /* prefix function */ + __P((const DBT *, const DBT *)); + int lorder; /* byte order */ +} BTREEINFO; + +#define HASHMAGIC 0x061561 +#define HASHVERSION 2 + +/* Structure used to pass parameters to the hashing routines. */ +typedef struct { + u_int bsize; /* bucket size */ + u_int ffactor; /* fill factor */ + u_int nelem; /* number of elements */ + u_int cachesize; /* bytes to cache */ + u_int32_t /* hash function */ + (*hash) __P((const void *, size_t)); + int lorder; /* byte order */ +} HASHINFO; + +/* Structure used to pass parameters to the record routines. */ +typedef struct { +#define R_FIXEDLEN 0x01 /* fixed-length records */ +#define R_NOKEY 0x02 /* key not required */ +#define R_SNAPSHOT 0x04 /* snapshot the input */ + u_long flags; + u_int cachesize; /* bytes to cache */ + u_int psize; /* page size */ + int lorder; /* byte order */ + size_t reclen; /* record length (fixed-length records) */ + u_char bval; /* delimiting byte (variable-length records */ + char *bfname; /* btree file name */ +} RECNOINFO; + +#ifdef __DBINTERFACE_PRIVATE +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + u_int32_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[3]; \ + ((char *)&a)[1] = ((char *)&_tmp)[2]; \ + ((char *)&a)[2] = ((char *)&_tmp)[1]; \ + ((char *)&a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + u_int32_t _tmp = *(u_int32_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[3]; \ + ((char *)a)[1] = ((char *)&_tmp)[2]; \ + ((char *)a)[2] = ((char *)&_tmp)[1]; \ + ((char *)a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[3]; \ + ((char *)&(b))[1] = ((char *)&(a))[2]; \ + ((char *)&(b))[2] = ((char *)&(a))[1]; \ + ((char *)&(b))[3] = ((char *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + u_int16_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[1]; \ + ((char *)&a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + u_int16_t _tmp = *(u_int16_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[1]; \ + ((char *)a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[1]; \ + ((char *)&(b))[1] = ((char *)&(a))[0]; \ +} +#endif + +__BEGIN_DECLS +DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); + +#ifdef __DBINTERFACE_PRIVATE +DB *__bt_open __P((virt_fd_t, const FILEVTABLE *, const BTREEINFO *, int)); +DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); +DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); +void __dbpanic __P((DB *dbp)); +#endif +__END_DECLS +#endif /* !_DB_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/include/filevtable.h b/user/mpy/lib/berkeley-db-1.xx/include/filevtable.h new file mode 100644 index 0000000..d1f3dfe --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/include/filevtable.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _BDB_FILEVTABLE_H_ +#define _BDB_FILEVTABLE_H_ + +#ifdef VIRT_FD_T_HEADER +#include VIRT_FD_T_HEADER +#endif +#include +#include + +#ifndef virt_fd_t +#define virt_fd_t int +#endif + +typedef struct FILEVTABLE { + ssize_t (*read) __P((virt_fd_t, void *, size_t)); + ssize_t (*write) __P((virt_fd_t, const void *, size_t)); + off_t (*lseek) __P((virt_fd_t, off_t, int)); + int (*fsync) __P((virt_fd_t)); +} FILEVTABLE; + +#endif /* _BDB_FILEVTABLE_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/include/mpool.h new file mode 100644 index 0000000..5607b49 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/include/mpool.h @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)mpool.h 8.2 (Berkeley) 7/14/94 + */ + +#include +#include + +/* + * The memory pool scheme is a simple one. Each in-memory page is referenced + * by a bucket which is threaded in up to two of three ways. All active pages + * are threaded on a hash chain (hashed by page number) and an lru chain. + * Inactive pages are threaded on a free chain. Each reference to a memory + * pool is handed an opaque MPOOL cookie which stores all of this information. + */ +#define HASHSIZE 128 +#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) + +/* The BKT structures are the elements of the queues. */ +typedef struct _bkt { + CIRCLEQ_ENTRY(_bkt) hq; /* hash queue */ + CIRCLEQ_ENTRY(_bkt) q; /* lru queue */ + void *page; /* page */ + pgno_t pgno; /* page number */ + +#define MPOOL_DIRTY 0x01 /* page needs to be written */ +#define MPOOL_PINNED 0x02 /* page is pinned into memory */ + u_int8_t flags; /* flags */ +} BKT; + +typedef struct MPOOL { + CIRCLEQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */ + /* hash queue array */ + CIRCLEQ_HEAD(_hqh, _bkt) hqh[HASHSIZE]; + pgno_t curcache; /* current number of cached pages */ + pgno_t maxcache; /* max number of cached pages */ + pgno_t npages; /* number of pages in the file */ + u_long pagesize; /* file page size */ + virt_fd_t fd; /* virtual file descriptor */ + /* page in conversion routine */ + const FILEVTABLE *fvtable; + void (*pgin) __P((void *, pgno_t, void *)); + /* page out conversion routine */ + void (*pgout) __P((void *, pgno_t, void *)); + void *pgcookie; /* cookie for page in/out routines */ +#ifdef STATISTICS + u_long cachehit; + u_long cachemiss; + u_long pagealloc; + u_long pageflush; + u_long pageget; + u_long pagenew; + u_long pageput; + u_long pageread; + u_long pagewrite; +#endif +} MPOOL; + +__BEGIN_DECLS +MPOOL *mpool_open __P((void *, virt_fd_t, const FILEVTABLE *, pgno_t, pgno_t)); +void mpool_filter __P((MPOOL *, void (*)(void *, pgno_t, void *), + void (*)(void *, pgno_t, void *), void *)); +void *mpool_new __P((MPOOL *, pgno_t *)); +void *mpool_get __P((MPOOL *, pgno_t, u_int)); +int mpool_put __P((MPOOL *, void *, u_int)); +int mpool_sync __P((MPOOL *)); +int mpool_close __P((MPOOL *)); +#ifdef STATISTICS +void mpool_stat __P((MPOOL *)); +#endif +__END_DECLS diff --git a/user/mpy/lib/berkeley-db-1.xx/include/tags b/user/mpy/lib/berkeley-db-1.xx/include/tags new file mode 120000 index 0000000..7ab656b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/include/tags @@ -0,0 +1 @@ +../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc new file mode 100644 index 0000000..d8d93f9 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc @@ -0,0 +1,7 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 + +.PATH: ${.CURDIR}/db/man + +# mpool.3 +MAN3+= btree.0 dbopen.0 hash.0 recno.0 +MLINKS+= dbopen.3 db.3 diff --git a/user/mpy/lib/berkeley-db-1.xx/man/btree.3 b/user/mpy/lib/berkeley-db-1.xx/man/btree.3 new file mode 100644 index 0000000..8284b21 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/man/btree.3 @@ -0,0 +1,233 @@ +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)btree.3 8.4 (Berkeley) 8/18/94 +.\" +.TH BTREE 3 "August 18, 1994" +.\".UC 7 +.SH NAME +btree \- btree database access method +.SH SYNOPSIS +.nf +.ft B +#include +#include +.ft R +.fi +.SH DESCRIPTION +The routine +.IR dbopen +is the library interface to database files. +One of the supported file formats is btree files. +The general description of the database access methods is in +.IR dbopen (3), +this manual page describes only the btree specific information. +.PP +The btree data structure is a sorted, balanced tree structure storing +associated key/data pairs. +.PP +The btree access method specific data structure provided to +.I dbopen +is defined in the include file as follows: +.PP +typedef struct { +.RS +u_long flags; +.br +u_int cachesize; +.br +int maxkeypage; +.br +int minkeypage; +.br +u_int psize; +.br +int (*compare)(const DBT *key1, const DBT *key2); +.br +size_t (*prefix)(const DBT *key1, const DBT *key2); +.br +int lorder; +.RE +} BTREEINFO; +.PP +The elements of this structure are as follows: +.TP +flags +The flag value is specified by +.IR or 'ing +any of the following values: +.RS +.TP +R_DUP +Permit duplicate keys in the tree, i.e. permit insertion if the key to be +inserted already exists in the tree. +The default behavior, as described in +.IR dbopen (3), +is to overwrite a matching key when inserting a new key or to fail if +the R_NOOVERWRITE flag is specified. +The R_DUP flag is overridden by the R_NOOVERWRITE flag, and if the +R_NOOVERWRITE flag is specified, attempts to insert duplicate keys into +the tree will fail. +.IP +If the database contains duplicate keys, the order of retrieval of +key/data pairs is undefined if the +.I get +routine is used, however, +.I seq +routine calls with the R_CURSOR flag set will always return the logical +``first'' of any group of duplicate keys. +.RE +.TP +cachesize +A suggested maximum size (in bytes) of the memory cache. +This value is +.B only +advisory, and the access method will allocate more memory rather than fail. +Since every search examines the root page of the tree, caching the most +recently used pages substantially improves access time. +In addition, physical writes are delayed as long as possible, so a moderate +cache can reduce the number of I/O operations significantly. +Obviously, using a cache increases (but only increases) the likelihood of +corruption or lost data if the system crashes while a tree is being modified. +If +.I cachesize +is 0 (no size is specified) a default cache is used. +.TP +maxkeypage +The maximum number of keys which will be stored on any single page. +Not currently implemented. +.\" The maximum number of keys which will be stored on any single page. +.\" Because of the way the btree data structure works, +.\" .I maxkeypage +.\" must always be greater than or equal to 2. +.\" If +.\" .I maxkeypage +.\" is 0 (no maximum number of keys is specified) the page fill factor is +.\" made as large as possible (which is almost invariably what is wanted). +.TP +minkeypage +The minimum number of keys which will be stored on any single page. +This value is used to determine which keys will be stored on overflow +pages, i.e. if a key or data item is longer than the pagesize divided +by the minkeypage value, it will be stored on overflow pages instead +of in the page itself. +If +.I minkeypage +is 0 (no minimum number of keys is specified) a value of 2 is used. +.TP +psize +Page size is the size (in bytes) of the pages used for nodes in the tree. +The minimum page size is 512 bytes and the maximum page size is 64K. +If +.I psize +is 0 (no page size is specified) a page size is chosen based on the +underlying file system I/O block size. +.TP +compare +Compare is the key comparison function. +It must return an integer less than, equal to, or greater than zero if the +first key argument is considered to be respectively less than, equal to, +or greater than the second key argument. +The same comparison function must be used on a given tree every time it +is opened. +If +.I compare +is NULL (no comparison function is specified), the keys are compared +lexically, with shorter keys considered less than longer keys. +.TP +prefix +Prefix is the prefix comparison function. +If specified, this routine must return the number of bytes of the second key +argument which are necessary to determine that it is greater than the first +key argument. +If the keys are equal, the key length should be returned. +Note, the usefulness of this routine is very data dependent, but, in some +data sets can produce significantly reduced tree sizes and search times. +If +.I prefix +is NULL (no prefix function is specified), +.B and +no comparison function is specified, a default lexical comparison routine +is used. +If +.I prefix +is NULL and a comparison routine is specified, no prefix comparison is +done. +.TP +lorder +The byte order for integers in the stored database metadata. +The number should represent the order as an integer; for example, +big endian order would be the number 4,321. +If +.I lorder +is 0 (no order is specified) the current host order is used. +.PP +If the file already exists (and the O_TRUNC flag is not specified), the +values specified for the parameters flags, lorder and psize are ignored +in favor of the values used when the tree was created. +.PP +Forward sequential scans of a tree are from the least key to the greatest. +.PP +Space freed up by deleting key/data pairs from the tree is never reclaimed, +although it is normally made available for reuse. +This means that the btree storage structure is grow-only. +The only solutions are to avoid excessive deletions, or to create a fresh +tree periodically from a scan of an existing one. +.PP +Searches, insertions, and deletions in a btree will all complete in +O lg base N where base is the average fill factor. +Often, inserting ordered data into btrees results in a low fill factor. +This implementation has been modified to make ordered insertion the best +case, resulting in a much better than normal page fill factor. +.SH ERRORS +The +.I btree +access method routines may fail and set +.I errno +for any of the errors specified for the library routine +.IR dbopen (3). +.SH "SEE ALSO" +.IR dbopen (3), +.IR hash (3), +.IR mpool (3), +.IR recno (3) +.sp +.IR "The Ubiquitous B-tree" , +Douglas Comer, ACM Comput. Surv. 11, 2 (June 1979), 121-138. +.sp +.IR "Prefix B-trees" , +Bayer and Unterauer, ACM Transactions on Database Systems, Vol. 2, 1 +(March 1977), 11-26. +.sp +.IR "The Art of Computer Programming Vol. 3: Sorting and Searching" , +D.E. Knuth, 1968, pp 471-480. +.SH BUGS +Only big and little endian byte order is supported. diff --git a/user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 b/user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 new file mode 100644 index 0000000..f06a4ef --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 @@ -0,0 +1,476 @@ +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94 +.\" +.TH DBOPEN 3 "January 2, 1994" +.UC 7 +.SH NAME +dbopen \- database access methods +.SH SYNOPSIS +.nf +.ft B +#include +#include +#include + +DB * +dbopen(const char *file, int flags, int mode, DBTYPE type, +.ti +5 +const void *openinfo); +.ft R +.fi +.SH DESCRIPTION +.IR Dbopen +is the library interface to database files. +The supported file formats are btree, hashed and UNIX file oriented. +The btree format is a representation of a sorted, balanced tree structure. +The hashed format is an extensible, dynamic hashing scheme. +The flat-file format is a byte stream file with fixed or variable length +records. +The formats and file format specific information are described in detail +in their respective manual pages +.IR btree (3), +.IR hash (3) +and +.IR recno (3). +.PP +Dbopen opens +.I file +for reading and/or writing. +Files never intended to be preserved on disk may be created by setting +the file parameter to NULL. +.PP +The +.I flags +and +.I mode arguments +are as specified to the +.IR open (2) +routine, however, only the O_CREAT, O_EXCL, O_EXLOCK, O_NONBLOCK, +O_RDONLY, O_RDWR, O_SHLOCK and O_TRUNC flags are meaningful. +(Note, opening a database file O_WRONLY is not possible.) +.\"Three additional options may be specified by +.\".IR or 'ing +.\"them into the +.\".I flags +.\"argument. +.\".TP +.\"DB_LOCK +.\"Do the necessary locking in the database to support concurrent access. +.\"If concurrent access isn't needed or the database is read-only this +.\"flag should not be set, as it tends to have an associated performance +.\"penalty. +.\".TP +.\"DB_SHMEM +.\"Place the underlying memory pool used by the database in shared +.\"memory. +.\"Necessary for concurrent access. +.\".TP +.\"DB_TXN +.\"Support transactions in the database. +.\"The DB_LOCK and DB_SHMEM flags must be set as well. +.PP +The +.I type +argument is of type DBTYPE (as defined in the include file) and +may be set to DB_BTREE, DB_HASH or DB_RECNO. +.PP +The +.I openinfo +argument is a pointer to an access method specific structure described +in the access method's manual page. +If +.I openinfo +is NULL, each access method will use defaults appropriate for the system +and the access method. +.PP +.I Dbopen +returns a pointer to a DB structure on success and NULL on error. +The DB structure is defined in the include file, and contains at +least the following fields: +.sp +.nf +typedef struct { +.RS +DBTYPE type; +int (*close)(const DB *db); +int (*del)(const DB *db, const DBT *key, u_int flags); +int (*fd)(const DB *db); +int (*get)(const DB *db, DBT *key, DBT *data, u_int flags); +int (*put)(const DB *db, DBT *key, const DBT *data, +.ti +5 +u_int flags); +int (*sync)(const DB *db, u_int flags); +int (*seq)(const DB *db, DBT *key, DBT *data, u_int flags); +.RE +} DB; +.fi +.PP +These elements describe a database type and a set of functions performing +various actions. +These functions take a pointer to a structure as returned by +.IR dbopen , +and sometimes one or more pointers to key/data structures and a flag value. +.TP +type +The type of the underlying access method (and file format). +.TP +close +A pointer to a routine to flush any cached information to disk, free any +allocated resources, and close the underlying file(s). +Since key/data pairs may be cached in memory, failing to sync the file +with a +.I close +or +.I sync +function may result in inconsistent or lost information. +.I Close +routines return -1 on error (setting +.IR errno ) +and 0 on success. +.TP +del +A pointer to a routine to remove key/data pairs from the database. +.IP +The parameter +.I flag +may be set to the following value: +.RS +.TP +R_CURSOR +Delete the record referenced by the cursor. +The cursor must have previously been initialized. +.RE +.IP +.I Delete +routines return -1 on error (setting +.IR errno ), +0 on success, and 1 if the specified +.I key +was not in the file. +.TP +fd +A pointer to a routine which returns a file descriptor representative +of the underlying database. +A file descriptor referencing the same file will be returned to all +processes which call +.I dbopen +with the same +.I file +name. +This file descriptor may be safely used as an argument to the +.IR fcntl (2) +and +.IR flock (2) +locking functions. +The file descriptor is not necessarily associated with any of the +underlying files used by the access method. +No file descriptor is available for in memory databases. +.I Fd +routines return -1 on error (setting +.IR errno ), +and the file descriptor on success. +.TP +get +A pointer to a routine which is the interface for keyed retrieval from +the database. +The address and length of the data associated with the specified +.I key +are returned in the structure referenced by +.IR data . +.I Get +routines return -1 on error (setting +.IR errno ), +0 on success, and 1 if the +.I key +was not in the file. +.TP +put +A pointer to a routine to store key/data pairs in the database. +.IP +The parameter +.I flag +may be set to one of the following values: +.RS +.TP +R_CURSOR +Replace the key/data pair referenced by the cursor. +The cursor must have previously been initialized. +.TP +R_IAFTER +Append the data immediately after the data referenced by +.IR key , +creating a new key/data pair. +The record number of the appended key/data pair is returned in the +.I key +structure. +(Applicable only to the DB_RECNO access method.) +.TP +R_IBEFORE +Insert the data immediately before the data referenced by +.IR key , +creating a new key/data pair. +The record number of the inserted key/data pair is returned in the +.I key +structure. +(Applicable only to the DB_RECNO access method.) +.TP +R_NOOVERWRITE +Enter the new key/data pair only if the key does not previously exist. +.TP +R_SETCURSOR +Store the key/data pair, setting or initializing the position of the +cursor to reference it. +(Applicable only to the DB_BTREE and DB_RECNO access methods.) +.RE +.IP +R_SETCURSOR is available only for the DB_BTREE and DB_RECNO access +methods because it implies that the keys have an inherent order +which does not change. +.IP +R_IAFTER and R_IBEFORE are available only for the DB_RECNO +access method because they each imply that the access method is able to +create new keys. +This is only true if the keys are ordered and independent, record numbers +for example. +.IP +The default behavior of the +.I put +routines is to enter the new key/data pair, replacing any previously +existing key. +.IP +.I Put +routines return -1 on error (setting +.IR errno ), +0 on success, and 1 if the R_NOOVERWRITE +.I flag +was set and the key already exists in the file. +.TP +seq +A pointer to a routine which is the interface for sequential +retrieval from the database. +The address and length of the key are returned in the structure +referenced by +.IR key , +and the address and length of the data are returned in the +structure referenced +by +.IR data . +.IP +Sequential key/data pair retrieval may begin at any time, and the +position of the ``cursor'' is not affected by calls to the +.IR del , +.IR get , +.IR put , +or +.I sync +routines. +Modifications to the database during a sequential scan will be reflected +in the scan, i.e. records inserted behind the cursor will not be returned +while records inserted in front of the cursor will be returned. +.IP +The flag value +.B must +be set to one of the following values: +.RS +.TP +R_CURSOR +The data associated with the specified key is returned. +This differs from the +.I get +routines in that it sets or initializes the cursor to the location of +the key as well. +(Note, for the DB_BTREE access method, the returned key is not necessarily an +exact match for the specified key. +The returned key is the smallest key greater than or equal to the specified +key, permitting partial key matches and range searches.) +.TP +R_FIRST +The first key/data pair of the database is returned, and the cursor +is set or initialized to reference it. +.TP +R_LAST +The last key/data pair of the database is returned, and the cursor +is set or initialized to reference it. +(Applicable only to the DB_BTREE and DB_RECNO access methods.) +.TP +R_NEXT +Retrieve the key/data pair immediately after the cursor. +If the cursor is not yet set, this is the same as the R_FIRST flag. +.TP +R_PREV +Retrieve the key/data pair immediately before the cursor. +If the cursor is not yet set, this is the same as the R_LAST flag. +(Applicable only to the DB_BTREE and DB_RECNO access methods.) +.RE +.IP +R_LAST and R_PREV are available only for the DB_BTREE and DB_RECNO +access methods because they each imply that the keys have an inherent +order which does not change. +.IP +.I Seq +routines return -1 on error (setting +.IR errno ), +0 on success and 1 if there are no key/data pairs less than or greater +than the specified or current key. +If the DB_RECNO access method is being used, and if the database file +is a character special file and no complete key/data pairs are currently +available, the +.I seq +routines return 2. +.TP +sync +A pointer to a routine to flush any cached information to disk. +If the database is in memory only, the +.I sync +routine has no effect and will always succeed. +.IP +The flag value may be set to the following value: +.RS +.TP +R_RECNOSYNC +If the DB_RECNO access method is being used, this flag causes +the sync routine to apply to the btree file which underlies the +recno file, not the recno file itself. +(See the +.I bfname +field of the +.IR recno (3) +manual page for more information.) +.RE +.IP +.I Sync +routines return -1 on error (setting +.IR errno ) +and 0 on success. +.SH "KEY/DATA PAIRS" +Access to all file types is based on key/data pairs. +Both keys and data are represented by the following data structure: +.PP +typedef struct { +.RS +void *data; +.br +size_t size; +.RE +} DBT; +.PP +The elements of the DBT structure are defined as follows: +.TP +data +A pointer to a byte string. +.TP +size +The length of the byte string. +.PP +Key and data byte strings may reference strings of essentially unlimited +length although any two of them must fit into available memory at the same +time. +It should be noted that the access methods provide no guarantees about +byte string alignment. +.SH ERRORS +The +.I dbopen +routine may fail and set +.I errno +for any of the errors specified for the library routines +.IR open (2) +and +.IR malloc (3) +or the following: +.TP +[EFTYPE] +A file is incorrectly formatted. +.TP +[EINVAL] +A parameter has been specified (hash function, pad byte etc.) that is +incompatible with the current file specification or which is not +meaningful for the function (for example, use of the cursor without +prior initialization) or there is a mismatch between the version +number of file and the software. +.PP +The +.I close +routines may fail and set +.I errno +for any of the errors specified for the library routines +.IR close (2), +.IR read (2), +.IR write (2), +.IR free (3), +or +.IR fsync (2). +.PP +The +.IR del , +.IR get , +.I put +and +.I seq +routines may fail and set +.I errno +for any of the errors specified for the library routines +.IR read (2), +.IR write (2), +.IR free (3) +or +.IR malloc (3). +.PP +The +.I fd +routines will fail and set +.I errno +to ENOENT for in memory databases. +.PP +The +.I sync +routines may fail and set +.I errno +for any of the errors specified for the library routine +.IR fsync (2). +.SH "SEE ALSO" +.IR btree (3), +.IR hash (3), +.IR mpool (3), +.IR recno (3) +.sp +.IR "LIBTP: Portable, Modular Transactions for UNIX" , +Margo Seltzer, Michael Olson, USENIX proceedings, Winter 1992. +.SH BUGS +The typedef DBT is a mnemonic for ``data base thang'', and was used +because noone could think of a reasonable name that wasn't already used. +.PP +The file descriptor interface is a kluge and will be deleted in a +future version of the interface. +.PP +None of the access methods provide any form of concurrent access, +locking, or transactions. diff --git a/user/mpy/lib/berkeley-db-1.xx/man/hash.3 b/user/mpy/lib/berkeley-db-1.xx/man/hash.3 new file mode 100644 index 0000000..4367031 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/man/hash.3 @@ -0,0 +1,159 @@ +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)hash.3 8.6 (Berkeley) 8/18/94 +.\" +.TH HASH 3 "August 18, 1994" +.UC 7 +.SH NAME +hash \- hash database access method +.SH SYNOPSIS +.nf +.ft B +#include +#include +.ft R +.fi +.SH DESCRIPTION +The routine +.IR dbopen +is the library interface to database files. +One of the supported file formats is hash files. +The general description of the database access methods is in +.IR dbopen (3), +this manual page describes only the hash specific information. +.PP +The hash data structure is an extensible, dynamic hashing scheme. +.PP +The access method specific data structure provided to +.I dbopen +is defined in the include file as follows: +.sp +typedef struct { +.RS +u_int bsize; +.br +u_int ffactor; +.br +u_int nelem; +.br +u_int cachesize; +.br +u_int32_t (*hash)(const void *, size_t); +.br +int lorder; +.RE +} HASHINFO; +.PP +The elements of this structure are as follows: +.TP +bsize +.I Bsize +defines the hash table bucket size, and is, by default, 256 bytes. +It may be preferable to increase the page size for disk-resident tables +and tables with large data items. +.TP +ffactor +.I Ffactor +indicates a desired density within the hash table. +It is an approximation of the number of keys allowed to accumulate in any +one bucket, determining when the hash table grows or shrinks. +The default value is 8. +.TP +nelem +.I Nelem +is an estimate of the final size of the hash table. +If not set or set too low, hash tables will expand gracefully as keys +are entered, although a slight performance degradation may be noticed. +The default value is 1. +.TP +cachesize +A suggested maximum size, in bytes, of the memory cache. +This value is +.B only +advisory, and the access method will allocate more memory rather +than fail. +.TP +hash +.I Hash +is a user defined hash function. +Since no hash function performs equally well on all possible data, the +user may find that the built-in hash function does poorly on a particular +data set. +User specified hash functions must take two arguments (a pointer to a byte +string and a length) and return a 32-bit quantity to be used as the hash +value. +.TP +lorder +The byte order for integers in the stored database metadata. +The number should represent the order as an integer; for example, +big endian order would be the number 4,321. +If +.I lorder +is 0 (no order is specified) the current host order is used. +If the file already exists, the specified value is ignored and the +value specified when the tree was created is used. +.PP +If the file already exists (and the O_TRUNC flag is not specified), the +values specified for the parameters bsize, ffactor, lorder and nelem are +ignored and the values specified when the tree was created are used. +.PP +If a hash function is specified, +.I hash_open +will attempt to determine if the hash function specified is the same as +the one with which the database was created, and will fail if it is not. +.PP +Backward compatible interfaces to the routines described in +.IR dbm (3), +and +.IR ndbm (3) +are provided, however these interfaces are not compatible with +previous file formats. +.SH ERRORS +The +.I hash +access method routines may fail and set +.I errno +for any of the errors specified for the library routine +.IR dbopen (3). +.SH "SEE ALSO" +.IR btree (3), +.IR dbopen (3), +.IR mpool (3), +.IR recno (3) +.sp +.IR "Dynamic Hash Tables" , +Per-Ake Larson, Communications of the ACM, April 1988. +.sp +.IR "A New Hash Package for UNIX" , +Margo Seltzer, USENIX Proceedings, Winter 1991. +.SH BUGS +Only big and little endian byte order is supported. diff --git a/user/mpy/lib/berkeley-db-1.xx/man/mpool.3 b/user/mpy/lib/berkeley-db-1.xx/man/mpool.3 new file mode 100644 index 0000000..c17606e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/man/mpool.3 @@ -0,0 +1,219 @@ +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93 +.\" +.TH MPOOL 3 "June 4, 1993" +.UC 7 +.SH NAME +mpool \- shared memory buffer pool +.SH SYNOPSIS +.nf +.ft B +#include +#include + +MPOOL * +mpool_open (DBT *key, int fd, pgno_t pagesize, pgno_t maxcache); + +void +mpool_filter (MPOOL *mp, void (*pgin)(void *, pgno_t, void *), +.ti +5 +void (*pgout)(void *, pgno_t, void *), void *pgcookie); + +void * +mpool_new (MPOOL *mp, pgno_t *pgnoaddr); + +void * +mpool_get (MPOOL *mp, pgno_t pgno, u_int flags); + +int +mpool_put (MPOOL *mp, void *pgaddr, u_int flags); + +int +mpool_sync (MPOOL *mp); + +int +mpool_close (MPOOL *mp); +.ft R +.fi +.SH DESCRIPTION +.IR Mpool +is the library interface intended to provide page oriented buffer management +of files. +The buffers may be shared between processes. +.PP +The function +.I mpool_open +initializes a memory pool. +The +.I key +argument is the byte string used to negotiate between multiple +processes wishing to share buffers. +If the file buffers are mapped in shared memory, all processes using +the same key will share the buffers. +If +.I key +is NULL, the buffers are mapped into private memory. +The +.I fd +argument is a file descriptor for the underlying file, which must be seekable. +If +.I key +is non-NULL and matches a file already being mapped, the +.I fd +argument is ignored. +.PP +The +.I pagesize +argument is the size, in bytes, of the pages into which the file is broken up. +The +.I maxcache +argument is the maximum number of pages from the underlying file to cache +at any one time. +This value is not relative to the number of processes which share a file's +buffers, but will be the largest value specified by any of the processes +sharing the file. +.PP +The +.I mpool_filter +function is intended to make transparent input and output processing of the +pages possible. +If the +.I pgin +function is specified, it is called each time a buffer is read into the memory +pool from the backing file. +If the +.I pgout +function is specified, it is called each time a buffer is written into the +backing file. +Both functions are are called with the +.I pgcookie +pointer, the page number and a pointer to the page to being read or written. +.PP +The function +.I mpool_new +takes an MPOOL pointer and an address as arguments. +If a new page can be allocated, a pointer to the page is returned and +the page number is stored into the +.I pgnoaddr +address. +Otherwise, NULL is returned and errno is set. +.PP +The function +.I mpool_get +takes a MPOOL pointer and a page number as arguments. +If the page exists, a pointer to the page is returned. +Otherwise, NULL is returned and errno is set. +The flags parameter is not currently used. +.PP +The function +.I mpool_put +unpins the page referenced by +.IR pgaddr . +.I Pgaddr +must be an address previously returned by +.I mpool_get +or +.IR mpool_new . +The flag value is specified by +.IR or 'ing +any of the following values: +.TP +MPOOL_DIRTY +The page has been modified and needs to be written to the backing file. +.PP +.I Mpool_put +returns 0 on success and -1 if an error occurs. +.PP +The function +.I mpool_sync +writes all modified pages associated with the MPOOL pointer to the +backing file. +.I Mpool_sync +returns 0 on success and -1 if an error occurs. +.PP +The +.I mpool_close +function free's up any allocated memory associated with the memory pool +cookie. +Modified pages are +.B not +written to the backing file. +.I Mpool_close +returns 0 on success and -1 if an error occurs. +.SH ERRORS +The +.I mpool_open +function may fail and set +.I errno +for any of the errors specified for the library routine +.IR malloc (3). +.PP +The +.I mpool_get +function may fail and set +.I errno +for the following: +.TP 15 +[EINVAL] +The requested record doesn't exist. +.PP +The +.I mpool_new +and +.I mpool_get +functions may fail and set +.I errno +for any of the errors specified for the library routines +.IR read (2) , +.IR write (2) , +and +.IR malloc (3). +.PP +The +.I mpool_sync +function may fail and set +.I errno +for any of the errors specified for the library routine +.IR write (2). +.PP +The +.I mpool_close +function may fail and set +.I errno +for any of the errors specified for the library routine +.IR free (3). +.SH "SEE ALSO" +.IR dbopen (3), +.IR btree (3), +.IR hash (3), +.IR recno (3) diff --git a/user/mpy/lib/berkeley-db-1.xx/man/recno.3 b/user/mpy/lib/berkeley-db-1.xx/man/recno.3 new file mode 100644 index 0000000..516bef0 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/man/recno.3 @@ -0,0 +1,216 @@ +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)recno.3 8.5 (Berkeley) 8/18/94 +.\" +.TH RECNO 3 "August 18, 1994" +.UC 7 +.SH NAME +recno \- record number database access method +.SH SYNOPSIS +.nf +.ft B +#include +#include +.ft R +.fi +.SH DESCRIPTION +The routine +.IR dbopen +is the library interface to database files. +One of the supported file formats is record number files. +The general description of the database access methods is in +.IR dbopen (3), +this manual page describes only the recno specific information. +.PP +The record number data structure is either variable or fixed-length +records stored in a flat-file format, accessed by the logical record +number. +The existence of record number five implies the existence of records +one through four, and the deletion of record number one causes +record number five to be renumbered to record number four, as well +as the cursor, if positioned after record number one, to shift down +one record. +.PP +The recno access method specific data structure provided to +.I dbopen +is defined in the include file as follows: +.PP +typedef struct { +.RS +u_long flags; +.br +u_int cachesize; +.br +u_int psize; +.br +int lorder; +.br +size_t reclen; +.br +u_char bval; +.br +char *bfname; +.RE +} RECNOINFO; +.PP +The elements of this structure are defined as follows: +.TP +flags +The flag value is specified by +.IR or 'ing +any of the following values: +.RS +.TP +R_FIXEDLEN +The records are fixed-length, not byte delimited. +The structure element +.I reclen +specifies the length of the record, and the structure element +.I bval +is used as the pad character. +Any records, inserted into the database, that are less than +.I reclen +bytes long are automatically padded. +.TP +R_NOKEY +In the interface specified by +.IR dbopen , +the sequential record retrieval fills in both the caller's key and +data structures. +If the R_NOKEY flag is specified, the +.I cursor +routines are not required to fill in the key structure. +This permits applications to retrieve records at the end of files without +reading all of the intervening records. +.TP +R_SNAPSHOT +This flag requires that a snapshot of the file be taken when +.I dbopen +is called, instead of permitting any unmodified records to be read from +the original file. +.RE +.TP +cachesize +A suggested maximum size, in bytes, of the memory cache. +This value is +.B only +advisory, and the access method will allocate more memory rather than fail. +If +.I cachesize +is 0 (no size is specified) a default cache is used. +.TP +psize +The recno access method stores the in-memory copies of its records +in a btree. +This value is the size (in bytes) of the pages used for nodes in that tree. +If +.I psize +is 0 (no page size is specified) a page size is chosen based on the +underlying file system I/O block size. +See +.IR btree (3) +for more information. +.TP +lorder +The byte order for integers in the stored database metadata. +The number should represent the order as an integer; for example, +big endian order would be the number 4,321. +If +.I lorder +is 0 (no order is specified) the current host order is used. +.TP +reclen +The length of a fixed-length record. +.TP +bval +The delimiting byte to be used to mark the end of a record for +variable-length records, and the pad character for fixed-length +records. +If no value is specified, newlines (``\en'') are used to mark the end +of variable-length records and fixed-length records are padded with +spaces. +.TP +bfname +The recno access method stores the in-memory copies of its records +in a btree. +If bfname is non-NULL, it specifies the name of the btree file, +as if specified as the file name for a dbopen of a btree file. +.PP +The data part of the key/data pair used by the recno access method +is the same as other access methods. +The key is different. +The +.I data +field of the key should be a pointer to a memory location of type +.IR recno_t , +as defined in the include file. +This type is normally the largest unsigned integral type available to +the implementation. +The +.I size +field of the key should be the size of that type. +.PP +Because there can be no meta-data associated with the underlying +recno access method files, any changes made to the default values +(e.g. fixed record length or byte separator value) must be explicitly +specified each time the file is opened. +.PP +In the interface specified by +.IR dbopen , +using the +.I put +interface to create a new record will cause the creation of multiple, +empty records if the record number is more than one greater than the +largest record currently in the database. +.SH ERRORS +The +.I recno +access method routines may fail and set +.I errno +for any of the errors specified for the library routine +.IR dbopen (3) +or the following: +.TP +[EINVAL] +An attempt was made to add a record to a fixed-length database that +was too large to fit. +.SH "SEE ALSO" +.IR btree (3) +.IR dbopen (3), +.IR hash (3), +.IR mpool (3), +.sp +.IR "Document Processing in a Relational Database System" , +Michael Stonebraker, Heidi Stettner, Joseph Kalash, Antonin Guttman, +Nadene Lynn, Memorandum No. UCB/ERL M82/32, May 1982. +.SH BUGS +Only big and little endian byte order is supported. diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc new file mode 100644 index 0000000..93210c8 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc @@ -0,0 +1,5 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 + +.PATH: ${.CURDIR}/db/mpool + +SRCS+= mpool.c diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/README b/user/mpy/lib/berkeley-db-1.xx/mpool/README new file mode 100644 index 0000000..0f01fbc --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/mpool/README @@ -0,0 +1,7 @@ +# @(#)README 8.1 (Berkeley) 6/4/93 + +These are the current memory pool routines. +They aren't ready for prime time, yet, and +the interface is expected to change. + +--keith diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c b/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c new file mode 100644 index 0000000..2331259 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c @@ -0,0 +1,452 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +#include +#include +#include +#include + +#include + +#define __MPOOLINTERFACE_PRIVATE +#include + +static BKT *mpool_bkt __P((MPOOL *)); +static BKT *mpool_look __P((MPOOL *, pgno_t)); +static int mpool_write __P((MPOOL *, BKT *)); + +/* + * mpool_open -- + * Initialize a memory pool. + */ +MPOOL * +mpool_open(key, fd, fvtable, pagesize, maxcache) + void *key; + virt_fd_t fd; + const FILEVTABLE * fvtable; + pgno_t pagesize, maxcache; +{ + MPOOL *mp; + int entry; + + /* Allocate and initialize the MPOOL cookie. */ + if ((mp = (MPOOL *)calloc(1, sizeof(MPOOL))) == NULL) + return (NULL); + CIRCLEQ_INIT(&mp->lqh); + for (entry = 0; entry < HASHSIZE; ++entry) + CIRCLEQ_INIT(&mp->hqh[entry]); + mp->maxcache = maxcache; + mp->fvtable = fvtable; + off_t file_size = mp->fvtable->lseek(fd, 0, SEEK_END); + if (file_size == (off_t)-1) + return (NULL); + mp->npages = file_size / pagesize; + mp->pagesize = pagesize; + mp->fd = fd; + return (mp); +} + +/* + * mpool_filter -- + * Initialize input/output filters. + */ +void +mpool_filter(mp, pgin, pgout, pgcookie) + MPOOL *mp; + void (*pgin) __P((void *, pgno_t, void *)); + void (*pgout) __P((void *, pgno_t, void *)); + void *pgcookie; +{ + mp->pgin = pgin; + mp->pgout = pgout; + mp->pgcookie = pgcookie; +} + +/* + * mpool_new -- + * Get a new page of memory. + */ +void * +mpool_new(mp, pgnoaddr) + MPOOL *mp; + pgno_t *pgnoaddr; +{ + struct _hqh *head; + BKT *bp; + + if (mp->npages == MAX_PAGE_NUMBER) { + mpool_error("mpool_new: page allocation overflow.\n"); + abort(); + } +#ifdef STATISTICS + ++mp->pagenew; +#endif + /* + * Get a BKT from the cache. Assign a new page number, attach + * it to the head of the hash chain, the tail of the lru chain, + * and return. + */ + if ((bp = mpool_bkt(mp)) == NULL) + return (NULL); + *pgnoaddr = bp->pgno = mp->npages++; + bp->flags = MPOOL_PINNED; + + head = &mp->hqh[HASHKEY(bp->pgno)]; + CIRCLEQ_INSERT_HEAD(head, bp, hq); + CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); + return (bp->page); +} + +/* + * mpool_get + * Get a page. + */ +void * +mpool_get(mp, pgno, flags) + MPOOL *mp; + pgno_t pgno; + u_int flags; /* XXX not used? */ +{ + struct _hqh *head; + BKT *bp; + off_t off; + int nr; + + /* Check for attempt to retrieve a non-existent page. */ + if (pgno >= mp->npages) { + errno = EINVAL; + return (NULL); + } + +#ifdef STATISTICS + ++mp->pageget; +#endif + + /* Check for a page that is cached. */ + if ((bp = mpool_look(mp, pgno)) != NULL) { +#ifdef DEBUG + if (bp->flags & MPOOL_PINNED) { + mpool_error( + "mpool_get: page %d already pinned\n", bp->pgno); + abort(); + } +#endif + /* + * Move the page to the head of the hash chain and the tail + * of the lru chain. + */ + head = &mp->hqh[HASHKEY(bp->pgno)]; + CIRCLEQ_REMOVE(head, bp, hq); + CIRCLEQ_INSERT_HEAD(head, bp, hq); + CIRCLEQ_REMOVE(&mp->lqh, bp, q); + CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); + + /* Return a pinned page. */ + bp->flags |= MPOOL_PINNED; + return (bp->page); + } + + /* Get a page from the cache. */ + if ((bp = mpool_bkt(mp)) == NULL) + return (NULL); + + /* Read in the contents. */ +#ifdef STATISTICS + ++mp->pageread; +#endif + off = mp->pagesize * pgno; + if (mp->fvtable->lseek(mp->fd, off, SEEK_SET) != off) + return (NULL); + if ((nr = mp->fvtable->read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { + if (nr >= 0) + errno = EFTYPE; + return (NULL); + } + + /* Set the page number, pin the page. */ + bp->pgno = pgno; + bp->flags = MPOOL_PINNED; + + /* + * Add the page to the head of the hash chain and the tail + * of the lru chain. + */ + head = &mp->hqh[HASHKEY(bp->pgno)]; + CIRCLEQ_INSERT_HEAD(head, bp, hq); + CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); + + /* Run through the user's filter. */ + if (mp->pgin != NULL) + (mp->pgin)(mp->pgcookie, bp->pgno, bp->page); + + return (bp->page); +} + +/* + * mpool_put + * Return a page. + */ +int +mpool_put(mp, page, flags) + MPOOL *mp; + void *page; + u_int flags; +{ + BKT *bp; + +#ifdef STATISTICS + ++mp->pageput; +#endif + bp = (BKT *)((char *)page - sizeof(BKT)); +#ifdef DEBUG + if (!(bp->flags & MPOOL_PINNED)) { + mpool_error( + "mpool_put: page %d not pinned\n", bp->pgno); + abort(); + } +#endif + bp->flags &= ~MPOOL_PINNED; + bp->flags |= flags & MPOOL_DIRTY; + return (RET_SUCCESS); +} + +/* + * mpool_close + * Close the buffer pool. + */ +int +mpool_close(mp) + MPOOL *mp; +{ + BKT *bp; + + /* Free up any space allocated to the lru pages. */ + while ((bp = mp->lqh.cqh_first) != (void *)&mp->lqh) { + CIRCLEQ_REMOVE(&mp->lqh, mp->lqh.cqh_first, q); + free(bp); + } + + /* Free the MPOOL cookie. */ + free(mp); + return (RET_SUCCESS); +} + +/* + * mpool_sync + * Sync the pool to disk. + */ +int +mpool_sync(mp) + MPOOL *mp; +{ + BKT *bp; + + /* Walk the lru chain, flushing any dirty pages to disk. */ + for (bp = mp->lqh.cqh_first; + bp != (void *)&mp->lqh; bp = bp->q.cqe_next) + if (bp->flags & MPOOL_DIRTY && + mpool_write(mp, bp) == RET_ERROR) + return (RET_ERROR); + + /* Sync the file descriptor. */ + return (mp->fvtable->fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); +} + +/* + * mpool_bkt + * Get a page from the cache (or create one). + */ +static BKT * +mpool_bkt(mp) + MPOOL *mp; +{ + struct _hqh *head; + BKT *bp; + + /* If under the max cached, always create a new page. */ + if (mp->curcache < mp->maxcache) + goto new; + + /* + * If the cache is max'd out, walk the lru list for a buffer we + * can flush. If we find one, write it (if necessary) and take it + * off any lists. If we don't find anything we grow the cache anyway. + * The cache never shrinks. + */ + for (bp = mp->lqh.cqh_first; + bp != (void *)&mp->lqh; bp = bp->q.cqe_next) + if (!(bp->flags & MPOOL_PINNED)) { + /* Flush if dirty. */ + if (bp->flags & MPOOL_DIRTY && + mpool_write(mp, bp) == RET_ERROR) + return (NULL); +#ifdef STATISTICS + ++mp->pageflush; +#endif + /* Remove from the hash and lru queues. */ + head = &mp->hqh[HASHKEY(bp->pgno)]; + CIRCLEQ_REMOVE(head, bp, hq); + CIRCLEQ_REMOVE(&mp->lqh, bp, q); +#ifdef DEBUG + { void *spage; + spage = bp->page; + memset(bp, 0xff, sizeof(BKT) + mp->pagesize); + bp->page = spage; + } +#endif + return (bp); + } + +new: if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL) + return (NULL); +#ifdef STATISTICS + ++mp->pagealloc; +#endif +#if defined(DEBUG) || defined(PURIFY) + memset(bp, 0xff, sizeof(BKT) + mp->pagesize); +#endif + bp->page = (char *)bp + sizeof(BKT); + ++mp->curcache; + return (bp); +} + +/* + * mpool_write + * Write a page to disk. + */ +static int +mpool_write(mp, bp) + MPOOL *mp; + BKT *bp; +{ + off_t off; + +#ifdef STATISTICS + ++mp->pagewrite; +#endif + + /* Run through the user's filter. */ + if (mp->pgout) + (mp->pgout)(mp->pgcookie, bp->pgno, bp->page); + + off = mp->pagesize * bp->pgno; + if (mp->fvtable->lseek(mp->fd, off, SEEK_SET) != off) + return (RET_ERROR); + if (mp->fvtable->write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) + return (RET_ERROR); + + bp->flags &= ~MPOOL_DIRTY; + return (RET_SUCCESS); +} + +/* + * mpool_look + * Lookup a page in the cache. + */ +static BKT * +mpool_look(mp, pgno) + MPOOL *mp; + pgno_t pgno; +{ + struct _hqh *head; + BKT *bp; + + head = &mp->hqh[HASHKEY(pgno)]; + for (bp = head->cqh_first; bp != (void *)head; bp = bp->hq.cqe_next) + if (bp->pgno == pgno) { +#ifdef STATISTICS + ++mp->cachehit; +#endif + return (bp); + } +#ifdef STATISTICS + ++mp->cachemiss; +#endif + return (NULL); +} + +#ifdef STATISTICS +/* + * mpool_stat + * Print out cache statistics. + */ +void +mpool_stat(mp) + MPOOL *mp; +{ + BKT *bp; + int cnt; + char *sep; + + (void)fprintf(stderr, "%lu pages in the file\n", mp->npages); + (void)fprintf(stderr, + "page size %lu, cacheing %lu pages of %lu page max cache\n", + mp->pagesize, mp->curcache, mp->maxcache); + (void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n", + mp->pageput, mp->pageget, mp->pagenew); + (void)fprintf(stderr, "%lu page allocs, %lu page flushes\n", + mp->pagealloc, mp->pageflush); + if (mp->cachehit + mp->cachemiss) + (void)fprintf(stderr, + "%.0f%% cache hit rate (%lu hits, %lu misses)\n", + ((double)mp->cachehit / (mp->cachehit + mp->cachemiss)) + * 100, mp->cachehit, mp->cachemiss); + (void)fprintf(stderr, "%lu page reads, %lu page writes\n", + mp->pageread, mp->pagewrite); + + sep = ""; + cnt = 0; + for (bp = mp->lqh.cqh_first; + bp != (void *)&mp->lqh; bp = bp->q.cqe_next) { + (void)fprintf(stderr, "%s%d", sep, bp->pgno); + if (bp->flags & MPOOL_DIRTY) + (void)fprintf(stderr, "d"); + if (bp->flags & MPOOL_PINNED) + (void)fprintf(stderr, "P"); + if (++cnt == 10) { + sep = "\n"; + cnt = 0; + } else + sep = ", "; + + } + (void)fprintf(stderr, "\n"); +} +#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp b/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp new file mode 100644 index 0000000..8c0fc27 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp @@ -0,0 +1,746 @@ +/****************************************************************************** + +VERSION $Id: buf.c,v 1.26 92/01/09 09:15:26 margo Exp $ +PACKAGE: User Level Shared Memory Manager + +DESCRIPTION: + This package provides a buffer pool interface implemented as + a collection of file pages mapped into shared memory. + + Based on Mark's buffer manager + +ROUTINES: + External + buf_alloc + buf_flags + buf_get + buf_init + buf_last + buf_open + buf_pin + buf_sync + buf_unpin + Internal + bf_assign_buf + bf_fid_to_fd + bf_newbuf + bf_put_page + + +******************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "list.h" +#include "user.h" +#include "txn_sys.h" +#include "buf.h" +#include "semkeys.h" +#include "error.h" + +/* + we need to translate between some type of file id that the user + process passes and a file descriptor. For now, it's a nop. +*/ +#define GET_MASTER get_sem ( buf_spinlock ) +#define RELEASE_MASTER release_sem ( buf_spinlock ) + +#define LRUID *buf_lru +#define LRUP (bufhdr_table+*buf_lru) +#define MRU bufhdr_table[*buf_lru].lru.prev + +/* Global indicator that you have started reusing buffers */ +int do_statistics = 0; +/* + Process Statics (pointers into shared memory) +*/ +static BUF_T *buf_table = 0; +static BUFHDR_T *bufhdr_table; +static int *buf_hash_table; +static int *buf_lru; /* LRU is the free list */ +static int buf_spinlock; +static FINFO_T *buf_fids; +static int *buf_sp; /* Pointer to string free space */ +static char *buf_strings; + +/* Process Local FID->FD table */ +static int fds[NUM_FILE_ENTRIES]; + +/* Static routines */ +static BUFHDR_T *bf_assign_buf(); +static int bf_fid_to_fd(); +static BUFHDR_T *bf_newbuf(); +static int bf_put_page(); + +/* + Return 0 on success + 1 on failure +*/ +extern int +buf_init ( ) +{ + ADDR_T buf_region; + BUFHDR_T *bhp; + int i; + int ref_count; + int *spinlockp; + + /* + Initialize Process local structures + */ + for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { + fds[i] = -1; + } + + buf_region = attach_region ( BUF_REGION_NAME, BUF_REGION_NUM, + BUF_REGION_SIZE, &ref_count ); + if ( !buf_region ) { + return (1); + } + error_log3 ( "Buf Region: ADDR: %d ID: %d SIZE: %d\n", buf_region, + BUF_REGION_NUM, BUF_REGION_SIZE ); + + buf_table = (BUF_T *)buf_region; + bufhdr_table = (BUFHDR_T *)(buf_table + NUM_BUFS); + buf_hash_table = (int *)(bufhdr_table + NUM_BUFS); + buf_lru = buf_hash_table + NUMTABLE_ENTRIES; + spinlockp = buf_lru + 1; + buf_fids = (FINFO_T *)(spinlockp+1); + buf_sp = (int *)(buf_fids + NUM_FILE_ENTRIES); + buf_strings = (char *)(buf_sp + 1); + + /* Create locking spinlock (gets creating holding the lock) */ + buf_spinlock = create_sem ( BUF_SPIN_NAME, BUF_SPIN_NUM, ref_count <= 1 ); + if ( buf_spinlock < 0 ) { + return(1); + } + if ( ref_count <= 1 ) { + *spinlockp = buf_spinlock; + + /* Now initialize the buffer manager */ + + /* 1. Free list */ + *buf_lru = 0; + + /* 2. Buffer headers */ + for ( i = 0, bhp = bufhdr_table; i < NUM_BUFS; bhp++, i++ ) { + bhp->lru.next = i+1; + bhp->lru.prev = i-1; + bhp->flags = 0; /* All Flags off */ + bhp->refcount = 0; + bhp->wait_proc = -1; /* No sleepers */ + LISTPE_INIT ( hash, bhp, i ); /* Hash chains */ + } + bufhdr_table[0].lru.prev = NUM_BUFS-1; + bufhdr_table[NUM_BUFS-1].lru.next = 0; + + /* 3. Hash Table */ + for ( i = 0; i < NUMTABLE_ENTRIES; i++ ) { + buf_hash_table[i] = NUM_BUFS; + } + + /* 4. File ID Table */ + for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { + buf_fids[i].offset = -1; + buf_fids[i].npages = -1; + buf_fids[i].refcount = 0; + } + + /* 5. Free String Pointer */ + *buf_sp = (FILE_NAME_LEN*NUM_FILE_ENTRIES); + if (RELEASE_MASTER) { + return(1); + } + error_log0 ( "Initialized buffer region\n" ); + } + return (0); +} + +extern void +buf_exit() +{ + int ref; + int i; + + /* Flush Buffer Pool on Exit */ + for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { + if ( fds[i] != -1 ) { + close ( fds[i] ); + } + } + if ( buf_table ) { + detach_region ( buf_table, BUF_REGION_NUM, BUF_REGION_SIZE, &ref ); + } + return; +} + +/* + We need an empty buffer. Find the LRU unpinned NON-Dirty page. +*/ +static BUFHDR_T * +bf_newbuf() +{ + int fd; + int lruid; + int nbytes; + int ndx; + BUFHDR_T *bhp; + + lruid = LRUID; + for ( bhp = LRUP; + bhp->flags & (BUF_PINNED|BUF_IO_IN_PROGRESS); + bhp = LISTP_NEXTP (bufhdr_table, lru, bhp ) ) { + + if ( bhp->lru.next == lruid ) { + /* OUT OF BUFFERS */ + error_log1 ( "All buffers are pinned. %s\n", + "Unable to grant buffer request" ); + return(NULL); + } + } + /* BHP can be used */ + if ( bhp->flags & BUF_DIRTY ) { + do_statistics = 1; + /* + MIS Check for log flushed appropriately + */ + fd = bf_fid_to_fd(bhp->id.file_id); + if ( fd == -1 ) { + error_log1 ("Invalid fid %d\n", bhp->id.file_id); + return(NULL); + } + if ( bf_put_page(fd, bhp) < 0 ) { + return(NULL); + } + } + /* Update Hash Pointers */ + ndx = BUF_HASH ( bhp->id.file_id, bhp->id.obj_id ); + LISTP_REMOVE(bufhdr_table, hash, bhp); + if ( buf_hash_table[ndx] == (bhp-bufhdr_table) ) { + if ( bhp->hash.next != (bhp-bufhdr_table) ) { + buf_hash_table[ndx] = bhp->hash.next; + } else { + buf_hash_table[ndx] = NUM_BUFS; + } + } + INIT_BUF(bhp); + + return(bhp); +} +/* + buf_alloc + + Add a page to a file and return a buffer for it. + +*/ +ADDR_T +buf_alloc ( fid, new_pageno ) +int fid; +int *new_pageno; +{ + BUFHDR_T *bhp; + int fd; + int len; + int ndx; + OBJ_T fobj; + + if (GET_MASTER) { + return(NULL); + } + if ( buf_fids[fid].npages == -1 ) { + /* initialize npages field */ + fd = bf_fid_to_fd ( fid ); + } + assert (fid < NUM_FILE_ENTRIES); + + *new_pageno = buf_fids[fid].npages; + if ( *new_pageno == -1 ) { + RELEASE_MASTER; + return ( NULL ); + } + buf_fids[fid].npages++; + ndx = BUF_HASH ( fid, *new_pageno ); + fobj.file_id = fid; + fobj.obj_id = *new_pageno; + bhp = bf_assign_buf ( ndx, &fobj, BF_PIN|BF_DIRTY|BF_EMPTY, &len ); + if ( RELEASE_MASTER ) { + /* Memory leak */ + return(NULL); + } + if ( bhp ) { + return ((ADDR_T)(buf_table+(bhp-bufhdr_table))); + } else { + return ( NULL ); + } +} + + +/* + Buffer Flags + BF_DIRTY Mark page as dirty + BF_EMPTY Don't initialize page, just get buffer + BF_PIN Retrieve with pin + +MIS +Might want to add a flag that sets an LSN for this buffer is the +DIRTY flag is set + +Eventually, you may want a flag that indicates the I/O and lock +request should be shipped off together, but not for now. +*/ +extern ADDR_T +buf_get ( file_id, page_id, flags, len ) +int file_id; +int page_id; +u_long flags; +int *len; /* Number of bytes read into buffer */ +{ + BUFHDR_T *bhp; + int bufid; + int fd; + int ndx; + int next_bufid; + int stat; + OBJ_T fobj; + + ndx = BUF_HASH ( file_id, page_id ); + fobj.file_id = (long) file_id; + fobj.obj_id = (long) page_id; + if ( GET_MASTER ) { + return(NULL); + } + /* + This could be a for loop, but we lose speed + by making all the cases general purpose so we + optimize for the no-collision case. + */ + bufid = buf_hash_table[ndx]; + if ( bufid < NUM_BUFS ) { + for ( bhp = bufhdr_table+bufid; + !OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID); + bhp = LISTP_NEXTP ( bufhdr_table, hash, bhp ) ) { + + if ( bhp->hash.next == bufid ) { + goto not_found; + } + } +/* found */ + if ( flags & BF_PIN ) { + bhp->flags |= BUF_PINNED; + bhp->refcount++; +#ifdef PIN_DEBUG + fprintf(stderr, "buf_get: %X PINNED (%d)\n", + buf_table + (bhp-bufhdr_table), bhp->refcount); +#endif + } + if ( flags & BF_DIRTY ) { + bhp->flags |= BUF_DIRTY; + } + + while ( bhp->flags & BUF_IO_IN_PROGRESS ) { + /* MIS -- eventually err check here */ +#ifdef DEBUG + printf("About to sleep on %d (me: %d\n)\n", bhp->wait_proc, + my_txnp - txn_table); +#endif +#ifdef WAIT_STATS + buf_waits++; +#endif + stat = proc_sleep_on ( &(bhp->wait_proc), buf_spinlock ); + if ( stat ) { + /* Memory leak */ + return(NULL); + } + if (!( bhp->flags & BUF_IO_IN_PROGRESS) && + (!OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID))) { + if (RELEASE_MASTER) + return(NULL); + return(buf_get ( file_id, page_id, flags, len )); + } + } + MAKE_MRU( bhp ); + *len = BUFSIZE; + } else { +not_found: + /* If you get here, the page isn't in the hash table */ + bhp = bf_assign_buf ( ndx, &fobj, flags, len ); + } + /* Common code between found and not found */ + + if ( bhp && bhp->flags & BUF_NEWPAGE ) { + *len = 0; + } + if (RELEASE_MASTER){ + /* Memory leak */ + return(NULL); + } + if ( bhp ) { + return ((ADDR_T)(buf_table+(bhp-bufhdr_table))); + } else { + return ( NULL ); + } +} + +/* + MIS - do I want to add file links to buffer pool? +*/ +extern int +buf_sync ( fid, close ) +int fid; +int close; /* should we dec refcount and possibly + invalidate all the buffers */ +{ + int i; + int fd; + int invalidate; + BUFHDR_T *bhp; + + if ( (fd = bf_fid_to_fd ( fid )) < 0 ) { + return(1); + } + if (GET_MASTER) { + return(1); + } + invalidate = (buf_fids[fid].refcount == 1 && close); + if ( invalidate ) + for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) { + if (bhp->id.file_id == fid) { + if ((bhp->flags & BF_DIRTY) && (bf_put_page( fd, bhp ) < 0)) { + return(1); + } + bhp->id.file_id = -1; + } + } + if (invalidate || close) + buf_fids[fid].refcount--; + + if (RELEASE_MASTER) { + return(1); + } + return(0); + + +} + +extern int +buf_flags ( addr, set_flags, unset_flags ) +ADDR_T addr; +u_long set_flags; +u_long unset_flags; +{ + int bufid; + BUFHDR_T *bhp; + +#ifdef PIN_DEBUG + fprintf(stderr, "buf_flags: %X setting %s%s%s%s%s releasing %s%s%s%s%s\n", + addr, + set_flags&BUF_DIRTY ? "DIRTY " : "", + set_flags&BUF_VALID ? "VALID " : "", + set_flags&BUF_PINNED ? "PINNED " : "", + set_flags&BUF_IO_ERROR ? "IO_ERROR " : "", + set_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", + set_flags&BUF_NEWPAGE ? "NEWPAGE " : "", + unset_flags&BUF_DIRTY ? "DIRTY " : "", + unset_flags&BUF_VALID ? "VALID " : "", + unset_flags&BUF_PINNED ? "PINNED " : "", + unset_flags&BUF_IO_ERROR ? "IO_ERROR " : "", + unset_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", + unset_flags&BUF_NEWPAGE ? "NEWPAGE " : "" ); +#endif + if (!ADDR_OK(addr)) { + error_log1 ( "buf_pin: Invalid Buffer Address %x\n", addr ); + return(1); + } + bufid = ((BUF_T *)addr) - buf_table; + assert ( bufid < NUM_BUFS); + bhp = &bufhdr_table[bufid]; + if (GET_MASTER) { + return(1); + } + bhp->flags |= set_flags; + if ( set_flags & BUF_PINNED ) { + bhp->refcount++; + } + if ( set_flags & BUF_DIRTY ) { + unset_flags |= BUF_NEWPAGE; + } + + if ( unset_flags & BUF_PINNED ) { + bhp->refcount--; + if ( bhp->refcount ) { + /* Turn off pin bit so it doesn't get unset */ + unset_flags &= ~BUF_PINNED; + } + } + bhp->flags &= ~unset_flags; + MAKE_MRU(bhp); + if (RELEASE_MASTER) { + return(1); + } + return(0); +} + +/* + Take a string name and produce an fid. + + returns -1 on error + + MIS -- this is a potential problem -- you keep actual names + here -- what if people run from different directories? +*/ +extern int +buf_name_lookup ( fname ) +char *fname; +{ + int i; + int fid; + int ndx; + + fid = -1; + if (GET_MASTER) { + return(-1); + } + for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { + if ( buf_fids[i].offset == -1 ) { + fid = i; + } else { + if (!strcmp (fname, buf_strings+buf_fids[i].offset)) { + if (RELEASE_MASTER) { + return(-1); + } + buf_fids[i].refcount++; + return(i); + } + } + } + if ( fid == -1 ) { + error_log0 ( "No more file ID's\n" ); + } else { + ndx = *buf_sp - strlen(fname) - 1; + if ( ndx < 0 ) { + error_log0 ( "Out of string space\n" ); + fid = -1; + } else { + *buf_sp = ndx; + strcpy ( buf_strings+ndx, fname ); + buf_fids[fid].offset = ndx; + } + buf_fids[fid].refcount = 1; + } + if (RELEASE_MASTER) { + return(-1); + } + return(fid); +} + +static int +bf_fid_to_fd ( fid ) +int fid; +{ + struct stat sbuf; + + assert ( (fid < NUM_FILE_ENTRIES) && (buf_fids[fid].offset != -1) ); + if ( fds[fid] != -1 ) { + return(fds[fid]); + + } + fds[fid] = open ( buf_strings+buf_fids[fid].offset, O_RDWR|O_CREAT, + 0666 ); + if ( fds[fid] < 0 ) { + error_log3 ( "Error Opening File %s FID: %d FD: %d. Errno = %d\n", + buf_strings+buf_fids[fid].offset, fid, fds[fid], + errno ); + return(-1); + } + error_log3 ( "Opening File %s FID: %d FD: %d\n", + buf_strings+buf_fids[fid].offset, fid, fds[fid] ); + if ( buf_fids[fid].npages == -1 ) { + /* Initialize the npages field */ + if ( fstat ( fds[fid], &sbuf ) ) { + error_log3 ( "Error Fstating %s FID: %d. Errno = %d\n", + buf_strings+buf_fids[fid].offset, fid, errno ); + } else { + buf_fids[fid].npages = ( sbuf.st_size / BUFSIZE ); + } + } + + return ( fds[fid] ); +} + +static int +bf_put_page ( fd, bhp ) +int fd; +BUFHDR_T *bhp; +{ + int nbytes; + + assert ( (bhp-bufhdr_table) < NUM_BUFS ); + if ( lseek ( fd, bhp->id.obj_id << BUFSHIFT, L_SET ) < 0 ) { + return(-1); + } + bhp->flags |= BUF_IO_IN_PROGRESS; + if (RELEASE_MASTER) { + return(-1); + } + nbytes = write(fd, buf_table[bhp-bufhdr_table], BUFSIZE); + if (GET_MASTER) { + return(-2); + } + if ( nbytes < 0 ) { + error_log1 ("Write failed with error code %d\n", errno); + return(-1); + } else if ( nbytes != BUFSIZE ) { + error_log1 ("Short write: %d bytes of %d\n", nbytes, BUFSIZE ); + } + bhp->flags &= ~(BUF_DIRTY|BUF_IO_IN_PROGRESS); + return (0); +} + +static BUFHDR_T * +bf_assign_buf ( ndx, obj, flags, len ) +int ndx; +OBJ_T *obj; +u_long flags; +int *len; /* Number of bytes read */ +{ + BUFHDR_T *bhp; + int fd; + + assert ( obj->file_id < NUM_FILE_ENTRIES ); + bhp = bf_newbuf(); + if ( !bhp ) { + return(NULL); + } + OBJ_ASSIGN ( (*obj), bhp->id ); + if ( buf_hash_table[ndx] >= NUM_BUFS ) { + buf_hash_table[ndx] = bhp-bufhdr_table; + } else { + LISTPE_INSERT ( bufhdr_table, hash, bhp, buf_hash_table[ndx] ); + } + + bhp->flags |= BUF_VALID; + if ( flags & BF_PIN ) { + bhp->flags |= BUF_PINNED; + bhp->refcount++; +#ifdef PIN_DEBUG + fprintf(stderr, "bf_assign_buf: %X PINNED (%d)\n", + buf_table + (bhp-bufhdr_table), bhp->refcount); +#endif + } + fd = bf_fid_to_fd(obj->file_id); + if ( fd == -1 ) { + error_log1 ("Invalid fid %d\n", obj->file_id); + bhp->flags |= ~BUF_IO_ERROR; + return(NULL); + } + if ( obj->obj_id >= buf_fids[obj->file_id].npages) { + buf_fids[obj->file_id].npages = obj->obj_id+1; + *len = 0; + } else if ( flags & BF_EMPTY ) { + *len = 0; + } else { + bhp->flags |= BUF_IO_IN_PROGRESS; + if (RELEASE_MASTER) { + return(NULL); + } + if ( lseek ( fd, obj->obj_id << BUFSHIFT, L_SET ) < -1 ) { + error_log2 ("Unable to perform seek on file: %d to page %d", + obj->file_id, obj->obj_id ); + bhp->flags &= ~BUF_IO_IN_PROGRESS; + bhp->flags |= ~BUF_IO_ERROR; + return(NULL); + } + *len = read(fd, buf_table[bhp-bufhdr_table], BUFSIZE); + if ( *len < 0 ) { + error_log2 ("Unable to perform read on file: %d to page %d", + obj->file_id, obj->obj_id ); + bhp->flags &= ~BUF_IO_IN_PROGRESS; + bhp->flags |= ~BUF_IO_ERROR; + return(NULL); + } + if (GET_MASTER) { + return(NULL); + } + bhp->flags &= ~BUF_IO_IN_PROGRESS; + if ( bhp->wait_proc != -1 ) { + /* wake up waiter and anyone waiting on it */ +#ifdef DEBUG + printf("Waking transaction %d due to completed I/O\n", + bhp->wait_proc); +#endif + proc_wake_id ( bhp->wait_proc ); + bhp->wait_proc = -1; + } + MAKE_MRU(bhp); + } + + if ( flags & BF_DIRTY ) { + bhp->flags |= BUF_DIRTY; + } else if ( *len < BUFSIZE ) { + bhp->flags |= BUF_NEWPAGE; + } + return ( bhp ); +} + +int +buf_last ( fid ) +int fid; +{ + int val; + + if (GET_MASTER) { + return(-1); + } + assert ( fid < NUM_FILE_ENTRIES ); + if ( buf_fids[fid].npages == -1 ) { + /* initialize npages field */ + (void) bf_fid_to_fd ( fid ); + } + val = buf_fids[fid].npages; + if ( val ) { + val--; /* Convert to page number */ + } + if (RELEASE_MASTER) { + return(-1); + } + return(val); +} + +#ifdef DEBUG +extern void +buf_dump ( id, all ) +int id; +int all; +{ + int i; + BUFHDR_T *bhp; + + printf ( "LRU + %d\n", *buf_lru ); + if ( all ) { + printf("ID\tFID\tPID\tLNEXT\tLPREV\tHNEXT\tHPREV\tSLEEP\tFLAG\tREFS\n"); + for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) { + printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i, + bhp->id.file_id, bhp->id.obj_id, + bhp->lru.next, bhp->lru.prev, + bhp->hash.next, bhp->hash.prev, + bhp->wait_proc, bhp->flags, bhp->refcount ); + } + } else { + if ( id >= NUM_BUFS ) { + printf ( "Buffer ID (%d) too high\n", id ); + return; + } + bhp = bufhdr_table+id; + printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i, + bhp->id.file_id, bhp->id.obj_id, + bhp->lru.next, bhp->lru.prev, + bhp->hash.next, bhp->hash.prev, + bhp->wait_proc, bhp->flags, bhp->refcount ); + } + return; +} +#endif + diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/tags b/user/mpy/lib/berkeley-db-1.xx/mpool/tags new file mode 120000 index 0000000..7ab656b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/mpool/tags @@ -0,0 +1 @@ +../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc new file mode 100644 index 0000000..e49e225 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc @@ -0,0 +1,6 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 + +.PATH: ${.CURDIR}/db/recno + +SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c rec_search.c \ + rec_seq.c rec_utils.c diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/extern.h b/user/mpy/lib/berkeley-db-1.xx/recno/extern.h new file mode 100644 index 0000000..feed434 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/extern.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)extern.h 8.3 (Berkeley) 6/4/94 + */ + +#include "../btree/extern.h" + +int __rec_close __P((DB *)); +int __rec_delete __P((const DB *, const DBT *, u_int)); +int __rec_dleaf __P((BTREE *, PAGE *, u_int32_t)); +int __rec_fd __P((const DB *)); +int __rec_fmap __P((BTREE *, recno_t)); +int __rec_fout __P((BTREE *)); +int __rec_fpipe __P((BTREE *, recno_t)); +int __rec_get __P((const DB *, const DBT *, DBT *, u_int)); +int __rec_iput __P((BTREE *, recno_t, const DBT *, u_int)); +int __rec_put __P((const DB *dbp, DBT *, const DBT *, u_int)); +int __rec_ret __P((BTREE *, EPG *, recno_t, DBT *, DBT *)); +EPG *__rec_search __P((BTREE *, recno_t, enum SRCHOP)); +int __rec_seq __P((const DB *, DBT *, DBT *, u_int)); +int __rec_sync __P((const DB *, u_int)); +int __rec_vmap __P((BTREE *, recno_t)); +int __rec_vout __P((BTREE *)); +int __rec_vpipe __P((BTREE *, recno_t)); diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c new file mode 100644 index 0000000..16fb0b4 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c @@ -0,0 +1,182 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include "recno.h" + +/* + * __REC_CLOSE -- Close a recno tree. + * + * Parameters: + * dbp: pointer to access method + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__rec_close(dbp) + DB *dbp; +{ + BTREE *t; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + if (__rec_sync(dbp, 0) == RET_ERROR) + return (RET_ERROR); + + /* Committed to closing. */ + status = RET_SUCCESS; + if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize)) + status = RET_ERROR; + + if (!F_ISSET(t, R_INMEM)) + if (F_ISSET(t, R_CLOSEFP)) { + if (fclose(t->bt_rfp)) + status = RET_ERROR; + } else + if (close(t->bt_rfd)) + status = RET_ERROR; + + if (__bt_close(dbp) == RET_ERROR) + status = RET_ERROR; + + return (status); +} + +/* + * __REC_SYNC -- sync the recno tree to disk. + * + * Parameters: + * dbp: pointer to access method + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +int +__rec_sync(dbp, flags) + const DB *dbp; + u_int flags; +{ + struct iovec iov[2]; + BTREE *t; + DBT data, key; + off_t off; + recno_t scursor, trec; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + if (flags == R_RECNOSYNC) + return (__bt_sync(dbp, 0)); + + if (F_ISSET(t, R_RDONLY | R_INMEM) || !F_ISSET(t, R_MODIFIED)) + return (RET_SUCCESS); + + /* Read any remaining records into the tree. */ + if (!F_ISSET(t, R_EOF) && t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) + return (RET_ERROR); + + /* Rewind the file descriptor. */ + if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0) + return (RET_ERROR); + + /* Save the cursor. */ + scursor = t->bt_cursor.rcursor; + + key.size = sizeof(recno_t); + key.data = &trec; + + if (F_ISSET(t, R_FIXLEN)) { + /* + * We assume that fixed length records are all fixed length. + * Any that aren't are either EINVAL'd or corrected by the + * record put code. + */ + status = (dbp->seq)(dbp, &key, &data, R_FIRST); + while (status == RET_SUCCESS) { + if (write(t->bt_rfd, data.data, data.size) != data.size) + return (RET_ERROR); + status = (dbp->seq)(dbp, &key, &data, R_NEXT); + } + } else { + iov[1].iov_base = &t->bt_bval; + iov[1].iov_len = 1; + + status = (dbp->seq)(dbp, &key, &data, R_FIRST); + while (status == RET_SUCCESS) { + iov[0].iov_base = data.data; + iov[0].iov_len = data.size; + if (writev(t->bt_rfd, iov, 2) != data.size + 1) + return (RET_ERROR); + status = (dbp->seq)(dbp, &key, &data, R_NEXT); + } + } + + /* Restore the cursor. */ + t->bt_cursor.rcursor = scursor; + + if (status == RET_ERROR) + return (RET_ERROR); + if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1) + return (RET_ERROR); + if (ftruncate(t->bt_rfd, off)) + return (RET_ERROR); + F_CLR(t, R_MODIFIED); + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c new file mode 100644 index 0000000..a16593d --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c @@ -0,0 +1,197 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_delete.c 8.7 (Berkeley) 7/14/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "recno.h" + +static int rec_rdelete __P((BTREE *, recno_t)); + +/* + * __REC_DELETE -- Delete the item(s) referenced by a key. + * + * Parameters: + * dbp: pointer to access method + * key: key to delete + * flags: R_CURSOR if deleting what the cursor references + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. + */ +int +__rec_delete(dbp, key, flags) + const DB *dbp; + const DBT *key; + u_int flags; +{ + BTREE *t; + recno_t nrec; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + switch(flags) { + case 0: + if ((nrec = *(recno_t *)key->data) == 0) + goto einval; + if (nrec > t->bt_nrecs) + return (RET_SPECIAL); + --nrec; + status = rec_rdelete(t, nrec); + break; + case R_CURSOR: + if (!F_ISSET(&t->bt_cursor, CURS_INIT)) + goto einval; + if (t->bt_nrecs == 0) + return (RET_SPECIAL); + status = rec_rdelete(t, t->bt_cursor.rcursor - 1); + if (status == RET_SUCCESS) + --t->bt_cursor.rcursor; + break; + default: +einval: errno = EINVAL; + return (RET_ERROR); + } + + if (status == RET_SUCCESS) + F_SET(t, B_MODIFIED | R_MODIFIED); + return (status); +} + +/* + * REC_RDELETE -- Delete the data matching the specified key. + * + * Parameters: + * tree: tree + * nrec: record to delete + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. + */ +static int +rec_rdelete(t, nrec) + BTREE *t; + recno_t nrec; +{ + EPG *e; + PAGE *h; + int status; + + /* Find the record; __rec_search pins the page. */ + if ((e = __rec_search(t, nrec, SDELETE)) == NULL) + return (RET_ERROR); + + /* Delete the record. */ + h = e->page; + status = __rec_dleaf(t, h, e->index); + if (status != RET_SUCCESS) { + mpool_put(t->bt_mp, h, 0); + return (status); + } + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + return (RET_SUCCESS); +} + +/* + * __REC_DLEAF -- Delete a single record from a recno leaf page. + * + * Parameters: + * t: tree + * index: index on current page to delete + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +int +__rec_dleaf(t, h, index) + BTREE *t; + PAGE *h; + u_int32_t index; +{ + RLEAF *rl; + indx_t *ip, cnt, offset; + u_int32_t nbytes; + char *from; + void *to; + + /* + * Delete a record from a recno leaf page. Internal records are never + * deleted from internal pages, regardless of the records that caused + * them to be added being deleted. Pages made empty by deletion are + * not reclaimed. They are, however, made available for reuse. + * + * Pack the remaining entries at the end of the page, shift the indices + * down, overwriting the deleted record and its index. If the record + * uses overflow pages, make them available for reuse. + */ + to = rl = GETRLEAF(h, index); + if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) + return (RET_ERROR); + nbytes = NRLEAF(rl); + + /* + * Compress the key/data pairs. Compress and adjust the [BR]LEAF + * offsets. Reset the headers. + */ + from = (char *)h + h->upper; + memmove(from + nbytes, from, (char *)to - from); + h->upper += nbytes; + + offset = h->linp[index]; + for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip) + if (ip[0] < offset) + ip[0] += nbytes; + for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip) + ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; + h->lower -= sizeof(indx_t); + --t->bt_nrecs; + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c new file mode 100644 index 0000000..47dd773 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c @@ -0,0 +1,311 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_get.c 8.9 (Berkeley) 8/18/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include "recno.h" + +/* + * __REC_GET -- Get a record from the btree. + * + * Parameters: + * dbp: pointer to access method + * key: key to find + * data: data to return + * flag: currently unused + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. + */ +int +__rec_get(dbp, key, data, flags) + const DB *dbp; + const DBT *key; + DBT *data; + u_int flags; +{ + BTREE *t; + EPG *e; + recno_t nrec; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* Get currently doesn't take any flags, and keys of 0 are illegal. */ + if (flags || (nrec = *(recno_t *)key->data) == 0) { + errno = EINVAL; + return (RET_ERROR); + } + + /* + * If we haven't seen this record yet, try to find it in the + * original file. + */ + if (nrec > t->bt_nrecs) { + if (F_ISSET(t, R_EOF | R_INMEM)) + return (RET_SPECIAL); + if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS) + return (status); + } + + --nrec; + if ((e = __rec_search(t, nrec, SEARCH)) == NULL) + return (RET_ERROR); + + status = __rec_ret(t, e, 0, NULL, data); + if (F_ISSET(t, B_DB_LOCK)) + mpool_put(t->bt_mp, e->page, 0); + else + t->bt_pinned = e->page; + return (status); +} + +/* + * __REC_FPIPE -- Get fixed length records from a pipe. + * + * Parameters: + * t: tree + * cnt: records to read + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__rec_fpipe(t, top) + BTREE *t; + recno_t top; +{ + DBT data; + recno_t nrec; + size_t len; + int ch; + u_char *p; + + if (t->bt_rdata.size < t->bt_reclen) { + t->bt_rdata.data = t->bt_rdata.data == NULL ? + malloc(t->bt_reclen) : + realloc(t->bt_rdata.data, t->bt_reclen); + if (t->bt_rdata.data == NULL) + return (RET_ERROR); + t->bt_rdata.size = t->bt_reclen; + } + data.data = t->bt_rdata.data; + data.size = t->bt_reclen; + + for (nrec = t->bt_nrecs; nrec < top;) { + len = t->bt_reclen; + for (p = t->bt_rdata.data;; *p++ = ch) + if ((ch = getc(t->bt_rfp)) == EOF || !--len) { + if (ch != EOF) + *p = ch; + if (len != 0) + memset(p, t->bt_bval, len); + if (__rec_iput(t, + nrec, &data, 0) != RET_SUCCESS) + return (RET_ERROR); + ++nrec; + break; + } + if (ch == EOF) + break; + } + if (nrec < top) { + F_SET(t, R_EOF); + return (RET_SPECIAL); + } + return (RET_SUCCESS); +} + +/* + * __REC_VPIPE -- Get variable length records from a pipe. + * + * Parameters: + * t: tree + * cnt: records to read + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__rec_vpipe(t, top) + BTREE *t; + recno_t top; +{ + DBT data; + recno_t nrec; + indx_t len; + size_t sz; + int bval, ch; + u_char *p; + + bval = t->bt_bval; + for (nrec = t->bt_nrecs; nrec < top; ++nrec) { + for (p = t->bt_rdata.data, + sz = t->bt_rdata.size;; *p++ = ch, --sz) { + if ((ch = getc(t->bt_rfp)) == EOF || ch == bval) { + data.data = t->bt_rdata.data; + data.size = p - (u_char *)t->bt_rdata.data; + if (ch == EOF && data.size == 0) + break; + if (__rec_iput(t, nrec, &data, 0) + != RET_SUCCESS) + return (RET_ERROR); + break; + } + if (sz == 0) { + len = p - (u_char *)t->bt_rdata.data; + t->bt_rdata.size += (sz = 256); + t->bt_rdata.data = t->bt_rdata.data == NULL ? + malloc(t->bt_rdata.size) : + realloc(t->bt_rdata.data, t->bt_rdata.size); + if (t->bt_rdata.data == NULL) + return (RET_ERROR); + p = (u_char *)t->bt_rdata.data + len; + } + } + if (ch == EOF) + break; + } + if (nrec < top) { + F_SET(t, R_EOF); + return (RET_SPECIAL); + } + return (RET_SUCCESS); +} + +/* + * __REC_FMAP -- Get fixed length records from a file. + * + * Parameters: + * t: tree + * cnt: records to read + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__rec_fmap(t, top) + BTREE *t; + recno_t top; +{ + DBT data; + recno_t nrec; + u_char *sp, *ep, *p; + size_t len; + + if (t->bt_rdata.size < t->bt_reclen) { + t->bt_rdata.data = t->bt_rdata.data == NULL ? + malloc(t->bt_reclen) : + realloc(t->bt_rdata.data, t->bt_reclen); + if (t->bt_rdata.data == NULL) + return (RET_ERROR); + t->bt_rdata.size = t->bt_reclen; + } + data.data = t->bt_rdata.data; + data.size = t->bt_reclen; + + sp = (u_char *)t->bt_cmap; + ep = (u_char *)t->bt_emap; + for (nrec = t->bt_nrecs; nrec < top; ++nrec) { + if (sp >= ep) { + F_SET(t, R_EOF); + return (RET_SPECIAL); + } + len = t->bt_reclen; + for (p = t->bt_rdata.data; + sp < ep && len > 0; *p++ = *sp++, --len); + if (len != 0) + memset(p, t->bt_bval, len); + if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) + return (RET_ERROR); + } + t->bt_cmap = (caddr_t)sp; + return (RET_SUCCESS); +} + +/* + * __REC_VMAP -- Get variable length records from a file. + * + * Parameters: + * t: tree + * cnt: records to read + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__rec_vmap(t, top) + BTREE *t; + recno_t top; +{ + DBT data; + u_char *sp, *ep; + recno_t nrec; + int bval; + + sp = (u_char *)t->bt_cmap; + ep = (u_char *)t->bt_emap; + bval = t->bt_bval; + + for (nrec = t->bt_nrecs; nrec < top; ++nrec) { + if (sp >= ep) { + F_SET(t, R_EOF); + return (RET_SPECIAL); + } + for (data.data = sp; sp < ep && *sp != bval; ++sp); + data.size = sp - (u_char *)data.data; + if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) + return (RET_ERROR); + ++sp; + } + t->bt_cmap = (caddr_t)sp; + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c new file mode 100644 index 0000000..51d8a3c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c @@ -0,0 +1,241 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include "recno.h" + +DB * +__rec_open(fname, flags, mode, openinfo, dflags) + const char *fname; + int flags, mode, dflags; + const RECNOINFO *openinfo; +{ + BTREE *t; + BTREEINFO btopeninfo; + DB *dbp; + PAGE *h; + struct stat sb; + int rfd, sverrno; + + /* Open the user's file -- if this fails, we're done. */ + if (fname != NULL && (rfd = open(fname, flags, mode)) < 0) + return (NULL); + + /* Create a btree in memory (backed by disk). */ + dbp = NULL; + if (openinfo) { + if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT)) + goto einval; + btopeninfo.flags = 0; + btopeninfo.cachesize = openinfo->cachesize; + btopeninfo.maxkeypage = 0; + btopeninfo.minkeypage = 0; + btopeninfo.psize = openinfo->psize; + btopeninfo.compare = NULL; + btopeninfo.prefix = NULL; + btopeninfo.lorder = openinfo->lorder; + dbp = __bt_open(openinfo->bfname, + O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags); + } else + dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags); + if (dbp == NULL) + goto err; + + /* + * Some fields in the tree structure are recno specific. Fill them + * in and make the btree structure look like a recno structure. We + * don't change the bt_ovflsize value, it's close enough and slightly + * bigger. + */ + t = dbp->internal; + if (openinfo) { + if (openinfo->flags & R_FIXEDLEN) { + F_SET(t, R_FIXLEN); + t->bt_reclen = openinfo->reclen; + if (t->bt_reclen == 0) + goto einval; + } + t->bt_bval = openinfo->bval; + } else + t->bt_bval = '\n'; + + F_SET(t, R_RECNO); + if (fname == NULL) + F_SET(t, R_EOF | R_INMEM); + else + t->bt_rfd = rfd; + + if (fname != NULL) { + /* + * In 4.4BSD, stat(2) returns true for ISSOCK on pipes. + * Unfortunately, that's not portable, so we use lseek + * and check the errno values. + */ + errno = 0; + if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) { + switch (flags & O_ACCMODE) { + case O_RDONLY: + F_SET(t, R_RDONLY); + break; + default: + goto einval; + } +slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL) + goto err; + F_SET(t, R_CLOSEFP); + t->bt_irec = + F_ISSET(t, R_FIXLEN) ? __rec_fpipe : __rec_vpipe; + } else { + switch (flags & O_ACCMODE) { + case O_RDONLY: + F_SET(t, R_RDONLY); + break; + case O_RDWR: + break; + default: + goto einval; + } + + if (fstat(rfd, &sb)) + goto err; + /* + * Kluge -- we'd like to test to see if the file is too + * big to mmap. Since, we don't know what size or type + * off_t's or size_t's are, what the largest unsigned + * integral type is, or what random insanity the local + * C compiler will perpetrate, doing the comparison in + * a portable way is flatly impossible. Hope that mmap + * fails if the file is too large. + */ + if (sb.st_size == 0) + F_SET(t, R_EOF); + else { +#ifdef MMAP_NOT_AVAILABLE + /* + * XXX + * Mmap doesn't work correctly on many current + * systems. In particular, it can fail subtly, + * with cache coherency problems. Don't use it + * for now. + */ + t->bt_msize = sb.st_size; + if ((t->bt_smap = mmap(NULL, t->bt_msize, + PROT_READ, MAP_PRIVATE, rfd, + (off_t)0)) == (caddr_t)-1) + goto slow; + t->bt_cmap = t->bt_smap; + t->bt_emap = t->bt_smap + sb.st_size; + t->bt_irec = F_ISSET(t, R_FIXLEN) ? + __rec_fmap : __rec_vmap; + F_SET(t, R_MEMMAPPED); +#else + goto slow; +#endif + } + } + } + + /* Use the recno routines. */ + dbp->close = __rec_close; + dbp->del = __rec_delete; + dbp->fd = __rec_fd; + dbp->get = __rec_get; + dbp->put = __rec_put; + dbp->seq = __rec_seq; + dbp->sync = __rec_sync; + + /* If the root page was created, reset the flags. */ + if ((h = mpool_get(t->bt_mp, P_ROOT, 0)) == NULL) + goto err; + if ((h->flags & P_TYPE) == P_BLEAF) { + F_CLR(h, P_TYPE); + F_SET(h, P_RLEAF); + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + } else + mpool_put(t->bt_mp, h, 0); + + if (openinfo && openinfo->flags & R_SNAPSHOT && + !F_ISSET(t, R_EOF | R_INMEM) && + t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) + goto err; + return (dbp); + +einval: errno = EINVAL; +err: sverrno = errno; + if (dbp != NULL) + (void)__bt_close(dbp); + if (fname != NULL) + (void)close(rfd); + errno = sverrno; + return (NULL); +} + +int +__rec_fd(dbp) + const DB *dbp; +{ + BTREE *t; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* In-memory database can't have a file descriptor. */ + if (F_ISSET(t, R_INMEM)) { + errno = ENOENT; + return (-1); + } + return (t->bt_rfd); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c new file mode 100644 index 0000000..1afae0d --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c @@ -0,0 +1,280 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_put.c 8.7 (Berkeley) 8/18/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +#include +#include "recno.h" + +/* + * __REC_PUT -- Add a recno item to the tree. + * + * Parameters: + * dbp: pointer to access method + * key: key + * data: data + * flag: R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE + * + * Returns: + * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is + * already in the tree and R_NOOVERWRITE specified. + */ +int +__rec_put(dbp, key, data, flags) + const DB *dbp; + DBT *key; + const DBT *data; + u_int flags; +{ + BTREE *t; + DBT fdata, tdata; + recno_t nrec; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + /* + * If using fixed-length records, and the record is long, return + * EINVAL. If it's short, pad it out. Use the record data return + * memory, it's only short-term. + */ + if (F_ISSET(t, R_FIXLEN) && data->size != t->bt_reclen) { + if (data->size > t->bt_reclen) + goto einval; + + if (t->bt_rdata.size < t->bt_reclen) { + t->bt_rdata.data = t->bt_rdata.data == NULL ? + malloc(t->bt_reclen) : + realloc(t->bt_rdata.data, t->bt_reclen); + if (t->bt_rdata.data == NULL) + return (RET_ERROR); + t->bt_rdata.size = t->bt_reclen; + } + memmove(t->bt_rdata.data, data->data, data->size); + memset((char *)t->bt_rdata.data + data->size, + t->bt_bval, t->bt_reclen - data->size); + fdata.data = t->bt_rdata.data; + fdata.size = t->bt_reclen; + } else { + fdata.data = data->data; + fdata.size = data->size; + } + + switch (flags) { + case R_CURSOR: + if (!F_ISSET(&t->bt_cursor, CURS_INIT)) + goto einval; + nrec = t->bt_cursor.rcursor; + break; + case R_SETCURSOR: + if ((nrec = *(recno_t *)key->data) == 0) + goto einval; + break; + case R_IAFTER: + if ((nrec = *(recno_t *)key->data) == 0) { + nrec = 1; + flags = R_IBEFORE; + } + break; + case 0: + case R_IBEFORE: + if ((nrec = *(recno_t *)key->data) == 0) + goto einval; + break; + case R_NOOVERWRITE: + if ((nrec = *(recno_t *)key->data) == 0) + goto einval; + if (nrec <= t->bt_nrecs) + return (RET_SPECIAL); + break; + default: +einval: errno = EINVAL; + return (RET_ERROR); + } + + /* + * Make sure that records up to and including the put record are + * already in the database. If skipping records, create empty ones. + */ + if (nrec > t->bt_nrecs) { + if (!F_ISSET(t, R_EOF | R_INMEM) && + t->bt_irec(t, nrec) == RET_ERROR) + return (RET_ERROR); + if (nrec > t->bt_nrecs + 1) { + if (F_ISSET(t, R_FIXLEN)) { + if ((tdata.data = + (void *)malloc(t->bt_reclen)) == NULL) + return (RET_ERROR); + tdata.size = t->bt_reclen; + memset(tdata.data, t->bt_bval, tdata.size); + } else { + tdata.data = NULL; + tdata.size = 0; + } + while (nrec > t->bt_nrecs + 1) + if (__rec_iput(t, + t->bt_nrecs, &tdata, 0) != RET_SUCCESS) + return (RET_ERROR); + if (F_ISSET(t, R_FIXLEN)) + free(tdata.data); + } + } + + if ((status = __rec_iput(t, nrec - 1, &fdata, flags)) != RET_SUCCESS) + return (status); + + if (flags == R_SETCURSOR) + t->bt_cursor.rcursor = nrec; + + F_SET(t, R_MODIFIED); + return (__rec_ret(t, NULL, nrec, key, NULL)); +} + +/* + * __REC_IPUT -- Add a recno item to the tree. + * + * Parameters: + * t: tree + * nrec: record number + * data: data + * + * Returns: + * RET_ERROR, RET_SUCCESS + */ +int +__rec_iput(t, nrec, data, flags) + BTREE *t; + recno_t nrec; + const DBT *data; + u_int flags; +{ + DBT tdata; + EPG *e; + PAGE *h; + indx_t index, nxtindex; + pgno_t pg; + u_int32_t nbytes; + int dflags, status; + char *dest, db[NOVFLSIZE]; + + /* + * If the data won't fit on a page, store it on indirect pages. + * + * XXX + * If the insert fails later on, these pages aren't recovered. + */ + if (data->size > t->bt_ovflsize) { + if (__ovfl_put(t, data, &pg) == RET_ERROR) + return (RET_ERROR); + tdata.data = db; + tdata.size = NOVFLSIZE; + *(pgno_t *)db = pg; + *(u_int32_t *)(db + sizeof(pgno_t)) = data->size; + dflags = P_BIGDATA; + data = &tdata; + } else + dflags = 0; + + /* __rec_search pins the returned page. */ + if ((e = __rec_search(t, nrec, + nrec > t->bt_nrecs || flags == R_IAFTER || flags == R_IBEFORE ? + SINSERT : SEARCH)) == NULL) + return (RET_ERROR); + + h = e->page; + index = e->index; + + /* + * Add the specified key/data pair to the tree. The R_IAFTER and + * R_IBEFORE flags insert the key after/before the specified key. + * + * Pages are split as required. + */ + switch (flags) { + case R_IAFTER: + ++index; + break; + case R_IBEFORE: + break; + default: + if (nrec < t->bt_nrecs && + __rec_dleaf(t, h, index) == RET_ERROR) { + mpool_put(t->bt_mp, h, 0); + return (RET_ERROR); + } + break; + } + + /* + * If not enough room, split the page. The split code will insert + * the key and data and unpin the current page. If inserting into + * the offset array, shift the pointers up. + */ + nbytes = NRLEAFDBT(data->size); + if (h->upper - h->lower < nbytes + sizeof(indx_t)) { + status = __bt_split(t, h, NULL, data, dflags, nbytes, index); + if (status == RET_SUCCESS) + ++t->bt_nrecs; + return (status); + } + + if (index < (nxtindex = NEXTINDEX(h))) + memmove(h->linp + index + 1, h->linp + index, + (nxtindex - index) * sizeof(indx_t)); + h->lower += sizeof(indx_t); + + h->linp[index] = h->upper -= nbytes; + dest = (char *)h + h->upper; + WR_RLEAF(dest, data, dflags); + + ++t->bt_nrecs; + F_SET(t, B_MODIFIED); + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c new file mode 100644 index 0000000..acc109e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c @@ -0,0 +1,126 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_search.c 8.4 (Berkeley) 7/14/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include + +#include +#include "recno.h" + +/* + * __REC_SEARCH -- Search a btree for a key. + * + * Parameters: + * t: tree to search + * recno: key to find + * op: search operation + * + * Returns: + * EPG for matching record, if any, or the EPG for the location of the + * key, if it were inserted into the tree. + * + * Returns: + * The EPG for matching record, if any, or the EPG for the location + * of the key, if it were inserted into the tree, is entered into + * the bt_cur field of the tree. A pointer to the field is returned. + */ +EPG * +__rec_search(t, recno, op) + BTREE *t; + recno_t recno; + enum SRCHOP op; +{ + register indx_t index; + register PAGE *h; + EPGNO *parent; + RINTERNAL *r; + pgno_t pg; + indx_t top; + recno_t total; + int sverrno; + + BT_CLR(t); + for (pg = P_ROOT, total = 0;;) { + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + goto err; + if (h->flags & P_RLEAF) { + t->bt_cur.page = h; + t->bt_cur.index = recno - total; + return (&t->bt_cur); + } + for (index = 0, top = NEXTINDEX(h);;) { + r = GETRINTERNAL(h, index); + if (++index == top || total + r->nrecs > recno) + break; + total += r->nrecs; + } + + BT_PUSH(t, pg, index - 1); + + pg = r->pgno; + switch (op) { + case SDELETE: + --GETRINTERNAL(h, (index - 1))->nrecs; + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + break; + case SINSERT: + ++GETRINTERNAL(h, (index - 1))->nrecs; + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + break; + case SEARCH: + mpool_put(t->bt_mp, h, 0); + break; + } + + } + /* Try and recover the tree. */ +err: sverrno = errno; + if (op != SEARCH) + while ((parent = BT_POP(t)) != NULL) { + if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) + break; + if (op == SINSERT) + --GETRINTERNAL(h, parent->index)->nrecs; + else + ++GETRINTERNAL(h, parent->index)->nrecs; + mpool_put(t->bt_mp, h, MPOOL_DIRTY); + } + errno = sverrno; + return (NULL); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c new file mode 100644 index 0000000..f80992c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c @@ -0,0 +1,131 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)rec_seq.c 8.3 (Berkeley) 7/14/94"; +#endif /* not lint */ + +#include + +#include +#include +#include +#include + +#include +#include "recno.h" + +/* + * __REC_SEQ -- Recno sequential scan interface. + * + * Parameters: + * dbp: pointer to access method + * key: key for positioning and return value + * data: data return value + * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. + * + * Returns: + * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. + */ +int +__rec_seq(dbp, key, data, flags) + const DB *dbp; + DBT *key, *data; + u_int flags; +{ + BTREE *t; + EPG *e; + recno_t nrec; + int status; + + t = dbp->internal; + + /* Toss any page pinned across calls. */ + if (t->bt_pinned != NULL) { + mpool_put(t->bt_mp, t->bt_pinned, 0); + t->bt_pinned = NULL; + } + + switch(flags) { + case R_CURSOR: + if ((nrec = *(recno_t *)key->data) == 0) + goto einval; + break; + case R_NEXT: + if (F_ISSET(&t->bt_cursor, CURS_INIT)) { + nrec = t->bt_cursor.rcursor + 1; + break; + } + /* FALLTHROUGH */ + case R_FIRST: + nrec = 1; + break; + case R_PREV: + if (F_ISSET(&t->bt_cursor, CURS_INIT)) { + if ((nrec = t->bt_cursor.rcursor - 1) == 0) + return (RET_SPECIAL); + break; + } + /* FALLTHROUGH */ + case R_LAST: + if (!F_ISSET(t, R_EOF | R_INMEM) && + t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) + return (RET_ERROR); + nrec = t->bt_nrecs; + break; + default: +einval: errno = EINVAL; + return (RET_ERROR); + } + + if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { + if (!F_ISSET(t, R_EOF | R_INMEM) && + (status = t->bt_irec(t, nrec)) != RET_SUCCESS) + return (status); + if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) + return (RET_SPECIAL); + } + + if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) + return (RET_ERROR); + + F_SET(&t->bt_cursor, CURS_INIT); + t->bt_cursor.rcursor = nrec; + + status = __rec_ret(t, e, nrec, key, data); + if (F_ISSET(t, B_DB_LOCK)) + mpool_put(t->bt_mp, e->page, 0); + else + t->bt_pinned = e->page; + return (status); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c new file mode 100644 index 0000000..baea3fa --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c @@ -0,0 +1,122 @@ +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rec_utils.c 8.6 (Berkeley) 7/16/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include + +#include +#include "recno.h" + +/* + * __rec_ret -- + * Build return data. + * + * Parameters: + * t: tree + * e: key/data pair to be returned + * nrec: record number + * key: user's key structure + * data: user's data structure + * + * Returns: + * RET_SUCCESS, RET_ERROR. + */ +int +__rec_ret(t, e, nrec, key, data) + BTREE *t; + EPG *e; + recno_t nrec; + DBT *key, *data; +{ + RLEAF *rl; + void *p; + + if (key == NULL) + goto dataonly; + + /* We have to copy the key, it's not on the page. */ + if (sizeof(recno_t) > t->bt_rkey.size) { + p = (void *)(t->bt_rkey.data == NULL ? + malloc(sizeof(recno_t)) : + realloc(t->bt_rkey.data, sizeof(recno_t))); + if (p == NULL) + return (RET_ERROR); + t->bt_rkey.data = p; + t->bt_rkey.size = sizeof(recno_t); + } + memmove(t->bt_rkey.data, &nrec, sizeof(recno_t)); + key->size = sizeof(recno_t); + key->data = t->bt_rkey.data; + +dataonly: + if (data == NULL) + return (RET_SUCCESS); + + /* + * We must copy big keys/data to make them contigous. Otherwise, + * leave the page pinned and don't copy unless the user specified + * concurrent access. + */ + rl = GETRLEAF(e->page, e->index); + if (rl->flags & P_BIGDATA) { + if (__ovfl_get(t, rl->bytes, + &data->size, &t->bt_rdata.data, &t->bt_rdata.size)) + return (RET_ERROR); + data->data = t->bt_rdata.data; + } else if (F_ISSET(t, B_DB_LOCK)) { + /* Use +1 in case the first record retrieved is 0 length. */ + if (rl->dsize + 1 > t->bt_rdata.size) { + p = (void *)(t->bt_rdata.data == NULL ? + malloc(rl->dsize + 1) : + realloc(t->bt_rdata.data, rl->dsize + 1)); + if (p == NULL) + return (RET_ERROR); + t->bt_rdata.data = p; + t->bt_rdata.size = rl->dsize + 1; + } + memmove(t->bt_rdata.data, rl->bytes, rl->dsize); + data->size = rl->dsize; + data->data = t->bt_rdata.data; + } else { + data->size = rl->dsize; + data->data = rl->bytes; + } + return (RET_SUCCESS); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/recno.h b/user/mpy/lib/berkeley-db-1.xx/recno/recno.h new file mode 100644 index 0000000..bec772c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/recno.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)recno.h 8.1 (Berkeley) 6/4/93 + */ + +enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ + +#include "../btree/btree.h" +#include "extern.h" diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/tags b/user/mpy/lib/berkeley-db-1.xx/recno/tags new file mode 120000 index 0000000..7ab656b --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/recno/tags @@ -0,0 +1 @@ +../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/test/Makefile b/user/mpy/lib/berkeley-db-1.xx/test/Makefile new file mode 100644 index 0000000..a5dd08a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/Makefile @@ -0,0 +1,23 @@ +# @(#)Makefile 8.15 (Berkeley) 7/28/94 + +PROG= dbtest +OBJS= dbtest.o strerror.o + +# Uncomment the STAT line get hash and btree statistical use info. This +# also forces ld to load the btree debug functions for use by gdb, which +# is useful. The db library has to be compiled with -DSTATISTICS as well. +INC= -I${PORTDIR}/include -I${PORTDIR} +OORG= -g +#STAT= -DSTATISTICS +CFLAGS= -D__DBINTERFACE_PRIVATE -DDEBUG ${STAT} ${OORG} ${INC} + +dbtest: ${OBJS} ${PORTDIR}/libdb.a + ${CC} -o $@ ${OBJS} ${PORTDIR}/libdb.a + +strerror.o: ${PORTDIR}/clib/strerror.c + ${CC} -c ${PORTDIR}/clib/strerror.c + +clean: + rm -f dbtest.core gmon.out ${OBJS} ${PROG} t1 t2 t3 + +${OBJS}: Makefile diff --git a/user/mpy/lib/berkeley-db-1.xx/test/README b/user/mpy/lib/berkeley-db-1.xx/test/README new file mode 100644 index 0000000..0c0cd13 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/README @@ -0,0 +1,74 @@ +# @(#)README 8.8 (Berkeley) 7/31/94 + +To build this portably, try something like: + + make PORTDIR="../PORT/MACH" + +where MACH is the machine, i.e. "sunos.4.1.1". + +To run the tests, enter "sh run.test". If your system dictionary isn't +in /usr/share/dict/words, edit run.test to reflect the correct place. + +Fairly large files (the command files) are built in this directory during +the test runs, and even larger files (the database files) are created in +"/var/tmp". If the latter directory doesn't exist, set the environmental +variable TMPDIR to a directory where the files can be built. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +The script file consists of lines with an initial character which is +the command for that line, or an initial character indicating a key +or data entry for a previous command. + +Legal command characters are as follows: + +c: compare a record + + must be followed by [kK][dD]; the data value in the database + associated with the specified key is compared to the specified + data value. +e: echo a string + + writes out the rest of the line into the output file; if the + last character is not a carriage-return, a newline is appended. +f: set the flags for the next command + + no value zero's the flags +g: do a get command + + must be followed by [kK] + + writes out the retrieved data DBT. +o [r]: dump [reverse] + + dump the database out, if 'r' is set, in reverse order. +p: do a put command + + must be followed by [kK][dD] +r: do a del command + + must be followed by [kK] unless R_CURSOR flag set. +S: sync the database +s: do a seq command + + must be followed by [kK] if R_CURSOR flag set. + + writes out the retrieved data DBT. + +Legal key/data characters are as follows: + +D [file]: data file + + set the current data value to the contents of the file +d [data]: + + set the current key value to the contents of the line. +K [file]: key file + + set the current key value to the contents of the file +k [data]: + + set the current key value to the contents of the line. + +Blank lines, lines with leading white space, and lines with leading +hash marks (#) are ignored. + +Options to dbtest are as follows: + + -d: Set the DB_LOCK flag. + -f: Use the file argument as the database file. + -i: Use the rest of the argument to set elements in the info + structure. If the type is btree, then "-i cachesize=10240" + will set BTREEINFO.cachesize to 10240. + -o: The rest of the argument is the output file instead of + using stdout. + -s: Don't delete the database file before opening it, i.e. + use the database file from a previous run. + +Dbtest requires two arguments, the type of access "hash", "recno" +or "btree", and the script name or "-" to indicate stdin. diff --git a/user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c b/user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c new file mode 100644 index 0000000..f26e193 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c @@ -0,0 +1,765 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Olson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "btree.h" + +typedef struct cmd_table { + char *cmd; + int nargs; + int rconv; + void (*func) __P((DB *, char **)); + char *usage, *descrip; +} cmd_table; + +int stopstop; +DB *globaldb; + +void append __P((DB *, char **)); +void bstat __P((DB *, char **)); +void cursor __P((DB *, char **)); +void delcur __P((DB *, char **)); +void delete __P((DB *, char **)); +void dump __P((DB *, char **)); +void first __P((DB *, char **)); +void get __P((DB *, char **)); +void help __P((DB *, char **)); +void iafter __P((DB *, char **)); +void ibefore __P((DB *, char **)); +void icursor __P((DB *, char **)); +void insert __P((DB *, char **)); +void keydata __P((DBT *, DBT *)); +void last __P((DB *, char **)); +void list __P((DB *, char **)); +void load __P((DB *, char **)); +void mstat __P((DB *, char **)); +void next __P((DB *, char **)); +int parse __P((char *, char **, int)); +void previous __P((DB *, char **)); +void show __P((DB *, char **)); +void usage __P((void)); +void user __P((DB *)); + +cmd_table commands[] = { + "?", 0, 0, help, "help", NULL, + "a", 2, 1, append, "append key def", "append key with data def", + "b", 0, 0, bstat, "bstat", "stat btree", + "c", 1, 1, cursor, "cursor word", "move cursor to word", + "delc", 0, 0, delcur, "delcur", "delete key the cursor references", + "dele", 1, 1, delete, "delete word", "delete word", + "d", 0, 0, dump, "dump", "dump database", + "f", 0, 0, first, "first", "move cursor to first record", + "g", 1, 1, get, "get key", "locate key", + "h", 0, 0, help, "help", "print command summary", + "ia", 2, 1, iafter, "iafter key data", "insert data after key", + "ib", 2, 1, ibefore, "ibefore key data", "insert data before key", + "ic", 2, 1, icursor, "icursor key data", "replace cursor", + "in", 2, 1, insert, "insert key def", "insert key with data def", + "la", 0, 0, last, "last", "move cursor to last record", + "li", 1, 1, list, "list file", "list to a file", + "loa", 1, 0, load, "load file", NULL, + "loc", 1, 1, get, "get key", NULL, + "m", 0, 0, mstat, "mstat", "stat memory pool", + "n", 0, 0, next, "next", "move cursor forward one record", + "p", 0, 0, previous, "previous", "move cursor back one record", + "q", 0, 0, NULL, "quit", "quit", + "sh", 1, 0, show, "show page", "dump a page", + { NULL }, +}; + +int recno; /* use record numbers */ +char *dict = "words"; /* default dictionary */ +char *progname; + +int +main(argc, argv) + int argc; + char **argv; +{ + int c; + DB *db; + BTREEINFO b; + + progname = *argv; + + b.flags = 0; + b.cachesize = 0; + b.maxkeypage = 0; + b.minkeypage = 0; + b.psize = 0; + b.compare = NULL; + b.prefix = NULL; + b.lorder = 0; + + while ((c = getopt(argc, argv, "bc:di:lp:ru")) != EOF) { + switch (c) { + case 'b': + b.lorder = BIG_ENDIAN; + break; + case 'c': + b.cachesize = atoi(optarg); + break; + case 'd': + b.flags |= R_DUP; + break; + case 'i': + dict = optarg; + break; + case 'l': + b.lorder = LITTLE_ENDIAN; + break; + case 'p': + b.psize = atoi(optarg); + break; + case 'r': + recno = 1; + break; + case 'u': + b.flags = 0; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (recno) + db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR, + 0, DB_RECNO, NULL); + else + db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR, + 0600, DB_BTREE, &b); + + if (db == NULL) { + (void)fprintf(stderr, "dbopen: %s\n", strerror(errno)); + exit(1); + } + globaldb = db; + user(db); + exit(0); + /* NOTREACHED */ +} + +void +user(db) + DB *db; +{ + FILE *ifp; + int argc, i, last; + char *lbuf, *argv[4], buf[512]; + + if ((ifp = fopen("/dev/tty", "r")) == NULL) { + (void)fprintf(stderr, + "/dev/tty: %s\n", strerror(errno)); + exit(1); + } + for (last = 0;;) { + (void)printf("> "); + (void)fflush(stdout); + if ((lbuf = fgets(&buf[0], 512, ifp)) == NULL) + break; + if (lbuf[0] == '\n') { + i = last; + goto uselast; + } + lbuf[strlen(lbuf) - 1] = '\0'; + + if (lbuf[0] == 'q') + break; + + argc = parse(lbuf, &argv[0], 3); + if (argc == 0) + continue; + + for (i = 0; commands[i].cmd != NULL; i++) + if (strncmp(commands[i].cmd, argv[0], + strlen(commands[i].cmd)) == 0) + break; + + if (commands[i].cmd == NULL) { + (void)fprintf(stderr, + "%s: command unknown ('help' for help)\n", lbuf); + continue; + } + + if (commands[i].nargs != argc - 1) { + (void)fprintf(stderr, "usage: %s\n", commands[i].usage); + continue; + } + + if (recno && commands[i].rconv) { + static recno_t nlong; + nlong = atoi(argv[1]); + argv[1] = (char *)&nlong; + } +uselast: last = i; + (*commands[i].func)(db, argv); + } + if ((db->sync)(db) == RET_ERROR) + perror("dbsync"); + else if ((db->close)(db) == RET_ERROR) + perror("dbclose"); +} + +int +parse(lbuf, argv, maxargc) + char *lbuf, **argv; + int maxargc; +{ + int argc = 0; + char *c; + + c = lbuf; + while (isspace(*c)) + c++; + while (*c != '\0' && argc < maxargc) { + *argv++ = c; + argc++; + while (!isspace(*c) && *c != '\0') { + c++; + } + while (isspace(*c)) + *c++ = '\0'; + } + return (argc); +} + +void +append(db, argv) + DB *db; + char **argv; +{ + DBT key, data; + int status; + + if (!recno) { + (void)fprintf(stderr, + "append only available for recno db's.\n"); + return; + } + key.data = argv[1]; + key.size = sizeof(recno_t); + data.data = argv[2]; + data.size = strlen(data.data); + status = (db->put)(db, &key, &data, R_APPEND); + switch (status) { + case RET_ERROR: + perror("append/put"); + break; + case RET_SPECIAL: + (void)printf("%s (duplicate key)\n", argv[1]); + break; + case RET_SUCCESS: + break; + } +} + +void +cursor(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + int status; + + key.data = argv[1]; + if (recno) + key.size = sizeof(recno_t); + else + key.size = strlen(argv[1]) + 1; + status = (*db->seq)(db, &key, &data, R_CURSOR); + switch (status) { + case RET_ERROR: + perror("cursor/seq"); + break; + case RET_SPECIAL: + (void)printf("key not found\n"); + break; + case RET_SUCCESS: + keydata(&key, &data); + break; + } +} + +void +delcur(db, argv) + DB *db; + char **argv; +{ + int status; + + status = (*db->del)(db, NULL, R_CURSOR); + + if (status == RET_ERROR) + perror("delcur/del"); +} + +void +delete(db, argv) + DB *db; + char **argv; +{ + DBT key; + int status; + + key.data = argv[1]; + if (recno) + key.size = sizeof(recno_t); + else + key.size = strlen(argv[1]) + 1; + + status = (*db->del)(db, &key, 0); + switch (status) { + case RET_ERROR: + perror("delete/del"); + break; + case RET_SPECIAL: + (void)printf("key not found\n"); + break; + case RET_SUCCESS: + break; + } +} + +void +dump(db, argv) + DB *db; + char **argv; +{ + __bt_dump(db); +} + +void +first(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + int status; + + status = (*db->seq)(db, &key, &data, R_FIRST); + + switch (status) { + case RET_ERROR: + perror("first/seq"); + break; + case RET_SPECIAL: + (void)printf("no more keys\n"); + break; + case RET_SUCCESS: + keydata(&key, &data); + break; + } +} + +void +get(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + int status; + + key.data = argv[1]; + if (recno) + key.size = sizeof(recno_t); + else + key.size = strlen(argv[1]) + 1; + + status = (*db->get)(db, &key, &data, 0); + + switch (status) { + case RET_ERROR: + perror("get/get"); + break; + case RET_SPECIAL: + (void)printf("key not found\n"); + break; + case RET_SUCCESS: + keydata(&key, &data); + break; + } +} + +void +help(db, argv) + DB *db; + char **argv; +{ + int i; + + for (i = 0; commands[i].cmd; i++) + if (commands[i].descrip) + (void)printf("%s: %s\n", + commands[i].usage, commands[i].descrip); +} + +void +iafter(db, argv) + DB *db; + char **argv; +{ + DBT key, data; + int status; + + if (!recno) { + (void)fprintf(stderr, + "iafter only available for recno db's.\n"); + return; + } + key.data = argv[1]; + key.size = sizeof(recno_t); + data.data = argv[2]; + data.size = strlen(data.data); + status = (db->put)(db, &key, &data, R_IAFTER); + switch (status) { + case RET_ERROR: + perror("iafter/put"); + break; + case RET_SPECIAL: + (void)printf("%s (duplicate key)\n", argv[1]); + break; + case RET_SUCCESS: + break; + } +} + +void +ibefore(db, argv) + DB *db; + char **argv; +{ + DBT key, data; + int status; + + if (!recno) { + (void)fprintf(stderr, + "ibefore only available for recno db's.\n"); + return; + } + key.data = argv[1]; + key.size = sizeof(recno_t); + data.data = argv[2]; + data.size = strlen(data.data); + status = (db->put)(db, &key, &data, R_IBEFORE); + switch (status) { + case RET_ERROR: + perror("ibefore/put"); + break; + case RET_SPECIAL: + (void)printf("%s (duplicate key)\n", argv[1]); + break; + case RET_SUCCESS: + break; + } +} + +void +icursor(db, argv) + DB *db; + char **argv; +{ + int status; + DBT data, key; + + key.data = argv[1]; + if (recno) + key.size = sizeof(recno_t); + else + key.size = strlen(argv[1]) + 1; + data.data = argv[2]; + data.size = strlen(argv[2]) + 1; + + status = (*db->put)(db, &key, &data, R_CURSOR); + switch (status) { + case RET_ERROR: + perror("icursor/put"); + break; + case RET_SPECIAL: + (void)printf("%s (duplicate key)\n", argv[1]); + break; + case RET_SUCCESS: + break; + } +} + +void +insert(db, argv) + DB *db; + char **argv; +{ + int status; + DBT data, key; + + key.data = argv[1]; + if (recno) + key.size = sizeof(recno_t); + else + key.size = strlen(argv[1]) + 1; + data.data = argv[2]; + data.size = strlen(argv[2]) + 1; + + status = (*db->put)(db, &key, &data, R_NOOVERWRITE); + switch (status) { + case RET_ERROR: + perror("insert/put"); + break; + case RET_SPECIAL: + (void)printf("%s (duplicate key)\n", argv[1]); + break; + case RET_SUCCESS: + break; + } +} + +void +last(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + int status; + + status = (*db->seq)(db, &key, &data, R_LAST); + + switch (status) { + case RET_ERROR: + perror("last/seq"); + break; + case RET_SPECIAL: + (void)printf("no more keys\n"); + break; + case RET_SUCCESS: + keydata(&key, &data); + break; + } +} + +void +list(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + FILE *fp; + int status; + + if ((fp = fopen(argv[1], "w")) == NULL) { + (void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); + return; + } + status = (*db->seq)(db, &key, &data, R_FIRST); + while (status == RET_SUCCESS) { + (void)fprintf(fp, "%s\n", key.data); + status = (*db->seq)(db, &key, &data, R_NEXT); + } + if (status == RET_ERROR) + perror("list/seq"); +} + +DB *BUGdb; +void +load(db, argv) + DB *db; + char **argv; +{ + register char *p, *t; + FILE *fp; + DBT data, key; + recno_t cnt; + size_t len; + int status; + char *lp, buf[16 * 1024]; + + BUGdb = db; + if ((fp = fopen(argv[1], "r")) == NULL) { + (void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); + return; + } + (void)printf("loading %s...\n", argv[1]); + + for (cnt = 1; (lp = fgetline(fp, &len)) != NULL; ++cnt) { + if (recno) { + key.data = &cnt; + key.size = sizeof(recno_t); + data.data = lp; + data.size = len + 1; + } else { + key.data = lp; + key.size = len + 1; + for (p = lp + len - 1, t = buf; p >= lp; *t++ = *p--); + *t = '\0'; + data.data = buf; + data.size = len + 1; + } + + status = (*db->put)(db, &key, &data, R_NOOVERWRITE); + switch (status) { + case RET_ERROR: + perror("load/put"); + exit(1); + case RET_SPECIAL: + if (recno) + (void)fprintf(stderr, + "duplicate: %ld {%s}\n", cnt, data.data); + else + (void)fprintf(stderr, + "duplicate: %ld {%s}\n", cnt, key.data); + exit(1); + case RET_SUCCESS: + break; + } + } + (void)fclose(fp); +} + +void +next(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + int status; + + status = (*db->seq)(db, &key, &data, R_NEXT); + + switch (status) { + case RET_ERROR: + perror("next/seq"); + break; + case RET_SPECIAL: + (void)printf("no more keys\n"); + break; + case RET_SUCCESS: + keydata(&key, &data); + break; + } +} + +void +previous(db, argv) + DB *db; + char **argv; +{ + DBT data, key; + int status; + + status = (*db->seq)(db, &key, &data, R_PREV); + + switch (status) { + case RET_ERROR: + perror("previous/seq"); + break; + case RET_SPECIAL: + (void)printf("no more keys\n"); + break; + case RET_SUCCESS: + keydata(&key, &data); + break; + } +} + +void +show(db, argv) + DB *db; + char **argv; +{ + BTREE *t; + PAGE *h; + pgno_t pg; + + pg = atoi(argv[1]); + t = db->internal; + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) { + (void)printf("getpage of %ld failed\n", pg); + return; + } + if (pg == 0) + __bt_dmpage(h); + else + __bt_dpage(h); + mpool_put(t->bt_mp, h, 0); +} + +void +bstat(db, argv) + DB *db; + char **argv; +{ + (void)printf("BTREE\n"); + __bt_stat(db); +} + +void +mstat(db, argv) + DB *db; + char **argv; +{ + (void)printf("MPOOL\n"); + mpool_stat(((BTREE *)db->internal)->bt_mp); +} + +void +keydata(key, data) + DBT *key, *data; +{ + if (!recno && key->size > 0) + (void)printf("%s/", key->data); + if (data->size > 0) + (void)printf("%s", data->data); + (void)printf("\n"); +} + +void +usage() +{ + (void)fprintf(stderr, + "usage: %s [-bdlu] [-c cache] [-i file] [-p page] [file]\n", + progname); + exit (1); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/dbtest.c b/user/mpy/lib/berkeley-db-1.xx/test/dbtest.c new file mode 100644 index 0000000..4341b4c --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/dbtest.c @@ -0,0 +1,753 @@ +/*- + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1992, 1993, 1994\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94"; +#endif /* not lint */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA }; + +void compare __P((DBT *, DBT *)); +DBTYPE dbtype __P((char *)); +void dump __P((DB *, int)); +void err __P((const char *, ...)); +void get __P((DB *, DBT *)); +void getdata __P((DB *, DBT *, DBT *)); +void put __P((DB *, DBT *, DBT *)); +void rem __P((DB *, DBT *)); +char *sflags __P((int)); +void synk __P((DB *)); +void *rfile __P((char *, size_t *)); +void seq __P((DB *, DBT *)); +u_int setflags __P((char *)); +void *setinfo __P((DBTYPE, char *)); +void usage __P((void)); +void *xmalloc __P((char *, size_t)); + +DBTYPE type; /* Database type. */ +void *infop; /* Iflags. */ +u_long lineno; /* Current line in test script. */ +u_int flags; /* Current DB flags. */ +int ofd = STDOUT_FILENO; /* Standard output fd. */ + +DB *XXdbp; /* Global for gdb. */ +int XXlineno; /* Fast breakpoint for gdb. */ + +int +main(argc, argv) + int argc; + char *argv[]; +{ + extern int optind; + extern char *optarg; + enum S command, state; + DB *dbp; + DBT data, key, keydata; + size_t len; + int ch, oflags, sflag; + char *fname, *infoarg, *p, *t, buf[8 * 1024]; + + infoarg = NULL; + fname = NULL; + oflags = O_CREAT | O_RDWR; + sflag = 0; + while ((ch = getopt(argc, argv, "f:i:lo:s")) != EOF) + switch (ch) { + case 'f': + fname = optarg; + break; + case 'i': + infoarg = optarg; + break; + case 'l': + oflags |= DB_LOCK; + break; + case 'o': + if ((ofd = open(optarg, + O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) + err("%s: %s", optarg, strerror(errno)); + break; + case 's': + sflag = 1; + break; + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + if (argc != 2) + usage(); + + /* Set the type. */ + type = dbtype(*argv++); + + /* Open the descriptor file. */ + if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL) + err("%s: %s", *argv, strerror(errno)); + + /* Set up the db structure as necessary. */ + if (infoarg == NULL) + infop = NULL; + else + for (p = strtok(infoarg, ",\t "); p != NULL; + p = strtok(0, ",\t ")) + if (*p != '\0') + infop = setinfo(type, p); + + /* + * Open the DB. Delete any preexisting copy, you almost never + * want it around, and it often screws up tests. + */ + if (fname == NULL) { + p = getenv("TMPDIR"); + if (p == NULL) + p = "/var/tmp"; + (void)sprintf(buf, "%s/__dbtest", p); + fname = buf; + (void)unlink(buf); + } else if (!sflag) + (void)unlink(fname); + + if ((dbp = dbopen(fname, + oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL) + err("dbopen: %s", strerror(errno)); + XXdbp = dbp; + + state = COMMAND; + for (lineno = 1; + (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) { + /* Delete the newline, displaying the key/data is easier. */ + if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL) + *t = '\0'; + if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#') + continue; + + /* Convenient gdb break point. */ + if (XXlineno == lineno) + XXlineno = 1; + switch (*p) { + case 'c': /* compare */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + state = KEY; + command = COMPARE; + break; + case 'e': /* echo */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + /* Don't display the newline, if CR at EOL. */ + if (p[len - 2] == '\r') + --len; + if (write(ofd, p + 1, len - 1) != len - 1 || + write(ofd, "\n", 1) != 1) + err("write: %s", strerror(errno)); + break; + case 'g': /* get */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + state = KEY; + command = GET; + break; + case 'p': /* put */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + state = KEY; + command = PUT; + break; + case 'r': /* remove */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + if (flags == R_CURSOR) { + rem(dbp, &key); + state = COMMAND; + } else { + state = KEY; + command = REMOVE; + } + break; + case 'S': /* sync */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + synk(dbp); + state = COMMAND; + break; + case 's': /* seq */ + if (state != COMMAND) + err("line %lu: not expecting command", lineno); + if (flags == R_CURSOR) { + state = KEY; + command = SEQ; + } else + seq(dbp, &key); + break; + case 'f': + flags = setflags(p + 1); + break; + case 'D': /* data file */ + if (state != DATA) + err("line %lu: not expecting data", lineno); + data.data = rfile(p + 1, &data.size); + goto ldata; + case 'd': /* data */ + if (state != DATA) + err("line %lu: not expecting data", lineno); + data.data = xmalloc(p + 1, len - 1); + data.size = len - 1; +ldata: switch (command) { + case COMPARE: + compare(&keydata, &data); + break; + case PUT: + put(dbp, &key, &data); + break; + default: + err("line %lu: command doesn't take data", + lineno); + } + if (type != DB_RECNO) + free(key.data); + free(data.data); + state = COMMAND; + break; + case 'K': /* key file */ + if (state != KEY) + err("line %lu: not expecting a key", lineno); + if (type == DB_RECNO) + err("line %lu: 'K' not available for recno", + lineno); + key.data = rfile(p + 1, &key.size); + goto lkey; + case 'k': /* key */ + if (state != KEY) + err("line %lu: not expecting a key", lineno); + if (type == DB_RECNO) { + static recno_t recno; + recno = atoi(p + 1); + key.data = &recno; + key.size = sizeof(recno); + } else { + key.data = xmalloc(p + 1, len - 1); + key.size = len - 1; + } +lkey: switch (command) { + case COMPARE: + getdata(dbp, &key, &keydata); + state = DATA; + break; + case GET: + get(dbp, &key); + if (type != DB_RECNO) + free(key.data); + state = COMMAND; + break; + case PUT: + state = DATA; + break; + case REMOVE: + rem(dbp, &key); + if ((type != DB_RECNO) && (flags != R_CURSOR)) + free(key.data); + state = COMMAND; + break; + case SEQ: + seq(dbp, &key); + if ((type != DB_RECNO) && (flags != R_CURSOR)) + free(key.data); + state = COMMAND; + break; + default: + err("line %lu: command doesn't take a key", + lineno); + } + break; + case 'o': + dump(dbp, p[1] == 'r'); + break; + default: + err("line %lu: %s: unknown command character", + lineno, p); + } + } +#ifdef STATISTICS + /* + * -l must be used (DB_LOCK must be set) for this to be + * used, otherwise a page will be locked and it will fail. + */ + if (type == DB_BTREE && oflags & DB_LOCK) + __bt_stat(dbp); +#endif + if (dbp->close(dbp)) + err("db->close: %s", strerror(errno)); + (void)close(ofd); + exit(0); +} + +#define NOOVERWRITE "put failed, would overwrite key\n" + +void +compare(db1, db2) + DBT *db1, *db2; +{ + register size_t len; + register u_char *p1, *p2; + + if (db1->size != db2->size) + printf("compare failed: key->data len %lu != data len %lu\n", + db1->size, db2->size); + + len = MIN(db1->size, db2->size); + for (p1 = db1->data, p2 = db2->data; len--;) + if (*p1++ != *p2++) { + printf("compare failed at offset %d\n", + p1 - (u_char *)db1->data); + break; + } +} + +void +get(dbp, kp) + DB *dbp; + DBT *kp; +{ + DBT data; + + switch (dbp->get(dbp, kp, &data, flags)) { + case 0: + (void)write(ofd, data.data, data.size); + if (ofd == STDOUT_FILENO) + (void)write(ofd, "\n", 1); + break; + case -1: + err("line %lu: get: %s", lineno, strerror(errno)); + /* NOTREACHED */ + case 1: +#define NOSUCHKEY "get failed, no such key\n" + if (ofd != STDOUT_FILENO) + (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); + else + (void)fprintf(stderr, "%d: %.*s: %s", + lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); +#undef NOSUCHKEY + break; + } +} + +void +getdata(dbp, kp, dp) + DB *dbp; + DBT *kp, *dp; +{ + switch (dbp->get(dbp, kp, dp, flags)) { + case 0: + return; + case -1: + err("line %lu: getdata: %s", lineno, strerror(errno)); + /* NOTREACHED */ + case 1: + err("line %lu: getdata failed, no such key", lineno); + /* NOTREACHED */ + } +} + +void +put(dbp, kp, dp) + DB *dbp; + DBT *kp, *dp; +{ + switch (dbp->put(dbp, kp, dp, flags)) { + case 0: + break; + case -1: + err("line %lu: put: %s", lineno, strerror(errno)); + /* NOTREACHED */ + case 1: + (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1); + break; + } +} + +void +rem(dbp, kp) + DB *dbp; + DBT *kp; +{ + switch (dbp->del(dbp, kp, flags)) { + case 0: + break; + case -1: + err("line %lu: rem: %s", lineno, strerror(errno)); + /* NOTREACHED */ + case 1: +#define NOSUCHKEY "rem failed, no such key\n" + if (ofd != STDOUT_FILENO) + (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); + else if (flags != R_CURSOR) + (void)fprintf(stderr, "%d: %.*s: %s", + lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); + else + (void)fprintf(stderr, + "%d: rem of cursor failed\n", lineno); +#undef NOSUCHKEY + break; + } +} + +void +synk(dbp) + DB *dbp; +{ + switch (dbp->sync(dbp, flags)) { + case 0: + break; + case -1: + err("line %lu: synk: %s", lineno, strerror(errno)); + /* NOTREACHED */ + } +} + +void +seq(dbp, kp) + DB *dbp; + DBT *kp; +{ + DBT data; + + switch (dbp->seq(dbp, kp, &data, flags)) { + case 0: + (void)write(ofd, data.data, data.size); + if (ofd == STDOUT_FILENO) + (void)write(ofd, "\n", 1); + break; + case -1: + err("line %lu: seq: %s", lineno, strerror(errno)); + /* NOTREACHED */ + case 1: +#define NOSUCHKEY "seq failed, no such key\n" + if (ofd != STDOUT_FILENO) + (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); + else if (flags == R_CURSOR) + (void)fprintf(stderr, "%d: %.*s: %s", + lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); + else + (void)fprintf(stderr, + "%d: seq (%s) failed\n", lineno, sflags(flags)); +#undef NOSUCHKEY + break; + } +} + +void +dump(dbp, rev) + DB *dbp; + int rev; +{ + DBT key, data; + int flags, nflags; + + if (rev) { + flags = R_LAST; + nflags = R_PREV; + } else { + flags = R_FIRST; + nflags = R_NEXT; + } + for (;; flags = nflags) + switch (dbp->seq(dbp, &key, &data, flags)) { + case 0: + (void)write(ofd, data.data, data.size); + if (ofd == STDOUT_FILENO) + (void)write(ofd, "\n", 1); + break; + case 1: + goto done; + case -1: + err("line %lu: (dump) seq: %s", + lineno, strerror(errno)); + /* NOTREACHED */ + } +done: return; +} + +u_int +setflags(s) + char *s; +{ + char *p, *index(); + + for (; isspace(*s); ++s); + if (*s == '\n' || *s == '\0') + return (0); + if ((p = index(s, '\n')) != NULL) + *p = '\0'; + if (!strcmp(s, "R_CURSOR")) return (R_CURSOR); + if (!strcmp(s, "R_FIRST")) return (R_FIRST); + if (!strcmp(s, "R_IAFTER")) return (R_IAFTER); + if (!strcmp(s, "R_IBEFORE")) return (R_IBEFORE); + if (!strcmp(s, "R_LAST")) return (R_LAST); + if (!strcmp(s, "R_NEXT")) return (R_NEXT); + if (!strcmp(s, "R_NOOVERWRITE")) return (R_NOOVERWRITE); + if (!strcmp(s, "R_PREV")) return (R_PREV); + if (!strcmp(s, "R_SETCURSOR")) return (R_SETCURSOR); + + err("line %lu: %s: unknown flag", lineno, s); + /* NOTREACHED */ +} + +char * +sflags(flags) + int flags; +{ + switch (flags) { + case R_CURSOR: return ("R_CURSOR"); + case R_FIRST: return ("R_FIRST"); + case R_IAFTER: return ("R_IAFTER"); + case R_IBEFORE: return ("R_IBEFORE"); + case R_LAST: return ("R_LAST"); + case R_NEXT: return ("R_NEXT"); + case R_NOOVERWRITE: return ("R_NOOVERWRITE"); + case R_PREV: return ("R_PREV"); + case R_SETCURSOR: return ("R_SETCURSOR"); + } + + return ("UNKNOWN!"); +} + +DBTYPE +dbtype(s) + char *s; +{ + if (!strcmp(s, "btree")) + return (DB_BTREE); + if (!strcmp(s, "hash")) + return (DB_HASH); + if (!strcmp(s, "recno")) + return (DB_RECNO); + err("%s: unknown type (use btree, hash or recno)", s); + /* NOTREACHED */ +} + +void * +setinfo(type, s) + DBTYPE type; + char *s; +{ + static BTREEINFO ib; + static HASHINFO ih; + static RECNOINFO rh; + char *eq, *index(); + + if ((eq = index(s, '=')) == NULL) + err("%s: illegal structure set statement", s); + *eq++ = '\0'; + if (!isdigit(*eq)) + err("%s: structure set statement must be a number", s); + + switch (type) { + case DB_BTREE: + if (!strcmp("flags", s)) { + ib.flags = atoi(eq); + return (&ib); + } + if (!strcmp("cachesize", s)) { + ib.cachesize = atoi(eq); + return (&ib); + } + if (!strcmp("maxkeypage", s)) { + ib.maxkeypage = atoi(eq); + return (&ib); + } + if (!strcmp("minkeypage", s)) { + ib.minkeypage = atoi(eq); + return (&ib); + } + if (!strcmp("lorder", s)) { + ib.lorder = atoi(eq); + return (&ib); + } + if (!strcmp("psize", s)) { + ib.psize = atoi(eq); + return (&ib); + } + break; + case DB_HASH: + if (!strcmp("bsize", s)) { + ih.bsize = atoi(eq); + return (&ih); + } + if (!strcmp("ffactor", s)) { + ih.ffactor = atoi(eq); + return (&ih); + } + if (!strcmp("nelem", s)) { + ih.nelem = atoi(eq); + return (&ih); + } + if (!strcmp("cachesize", s)) { + ih.cachesize = atoi(eq); + return (&ih); + } + if (!strcmp("lorder", s)) { + ih.lorder = atoi(eq); + return (&ih); + } + break; + case DB_RECNO: + if (!strcmp("flags", s)) { + rh.flags = atoi(eq); + return (&rh); + } + if (!strcmp("cachesize", s)) { + rh.cachesize = atoi(eq); + return (&rh); + } + if (!strcmp("lorder", s)) { + rh.lorder = atoi(eq); + return (&rh); + } + if (!strcmp("reclen", s)) { + rh.reclen = atoi(eq); + return (&rh); + } + if (!strcmp("bval", s)) { + rh.bval = atoi(eq); + return (&rh); + } + if (!strcmp("psize", s)) { + rh.psize = atoi(eq); + return (&rh); + } + break; + } + err("%s: unknown structure value", s); + /* NOTREACHED */ +} + +void * +rfile(name, lenp) + char *name; + size_t *lenp; +{ + struct stat sb; + void *p; + int fd; + char *np, *index(); + + for (; isspace(*name); ++name); + if ((np = index(name, '\n')) != NULL) + *np = '\0'; + if ((fd = open(name, O_RDONLY, 0)) < 0 || + fstat(fd, &sb)) + err("%s: %s\n", name, strerror(errno)); +#ifdef NOT_PORTABLE + if (sb.st_size > (off_t)SIZE_T_MAX) + err("%s: %s\n", name, strerror(E2BIG)); +#endif + if ((p = (void *)malloc((u_int)sb.st_size)) == NULL) + err("%s", strerror(errno)); + (void)read(fd, p, (int)sb.st_size); + *lenp = sb.st_size; + (void)close(fd); + return (p); +} + +void * +xmalloc(text, len) + char *text; + size_t len; +{ + void *p; + + if ((p = (void *)malloc(len)) == NULL) + err("%s", strerror(errno)); + memmove(p, text, len); + return (p); +} + +void +usage() +{ + (void)fprintf(stderr, + "usage: dbtest [-l] [-f file] [-i info] [-o file] type script\n"); + exit(1); +} + +#if __STDC__ +#include +#else +#include +#endif + +void +#if __STDC__ +err(const char *fmt, ...) +#else +err(fmt, va_alist) + char *fmt; + va_dcl +#endif +{ + va_list ap; +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + (void)fprintf(stderr, "dbtest: "); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + (void)fprintf(stderr, "\n"); + exit(1); + /* NOTREACHED */ +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c new file mode 100644 index 0000000..2008a28 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c @@ -0,0 +1,114 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)driver2.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +/* + * Test driver, to try to tackle the large ugly-split problem. + */ + +#include +#include +#include "ndbm.h" + +int my_hash(key, len) + char *key; + int len; +{ + return(17); /* So I'm cruel... */ +} + +main(argc, argv) + int argc; +{ + DB *db; + DBT key, content; + char keybuf[2049]; + char contentbuf[2049]; + char buf[256]; + int i; + HASHINFO info; + + info.bsize = 1024; + info.ffactor = 5; + info.nelem = 1; + info.cachesize = NULL; +#ifdef HASH_ID_PROGRAM_SPECIFIED + info.hash_id = HASH_ID_PROGRAM_SPECIFIED; + info.hash_func = my_hash; +#else + info.hash = my_hash; +#endif + info.lorder = 0; + if (!(db = dbopen("bigtest", O_RDWR | O_CREAT, 0644, DB_HASH, &info))) { + sprintf(buf, "dbopen: failed on file bigtest"); + perror(buf); + exit(1); + } + srandom(17); + key.data = keybuf; + content.data = contentbuf; + bzero(keybuf, sizeof(keybuf)); + bzero(contentbuf, sizeof(contentbuf)); + for (i=1; i <= 500; i++) { + key.size = 128 + (random()&1023); + content.size = 128 + (random()&1023); +/* printf("%d: Key size %d, data size %d\n", i, key.size, + content.size); */ + sprintf(keybuf, "Key #%d", i); + sprintf(contentbuf, "Contents #%d", i); + if ((db->put)(db, &key, &content, R_NOOVERWRITE)) { + sprintf(buf, "dbm_store #%d", i); + perror(buf); + } + } + if ((db->close)(db)) { + perror("closing hash file"); + exit(1); + } + exit(0); +} + + + diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh new file mode 100644 index 0000000..f28e281 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# @(#)makedb.sh 8.1 (Berkeley) 6/4/93 + +awk '{i++; print $0; print i;}' /usr/share/dict/words > WORDS +ls /bin /usr/bin /usr/ucb /etc | egrep '^(...|....|.....|......)$' | \ +sort | uniq | \ +awk '{ + printf "%s\n", $0 + for (i = 0; i < 1000; i++) + printf "%s+", $0 + printf "\n" +}' > LONG.DATA diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c new file mode 100644 index 0000000..bd125ac --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)tcreat3.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +#include +#include +#include +#include + +#define INITIAL 25000 +#define MAXWORDS 25000 /* # of elements in search table */ + +char wp1[8192]; +char wp2[8192]; +main(argc, argv) +char **argv; +{ + DBT item, key; + DB *dbp; + HASHINFO ctl; + FILE *fp; + int trash; + + int i = 0; + + argv++; + ctl.hash = NULL; + ctl.bsize = atoi(*argv++); + ctl.ffactor = atoi(*argv++); + ctl.nelem = atoi(*argv++); + ctl.lorder = 0; + if (!(dbp = dbopen( "hashtest", + O_CREAT|O_TRUNC|O_RDWR, 0600, DB_HASH, &ctl))){ + /* create table */ + fprintf(stderr, "cannot create: hash table (size %d)\n", + INITIAL); + exit(1); + } + + key.data = wp1; + item.data = wp2; + while ( fgets(wp1, 8192, stdin) && + fgets(wp2, 8192, stdin) && + i++ < MAXWORDS) { +/* +* put info in structure, and structure in the item +*/ + key.size = strlen(wp1); + item.size = strlen(wp2); + +/* + * enter key/data pair into the table + */ + if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { + fprintf(stderr, "cannot enter: key %s\n", + item.data); + exit(1); + } + } + + (dbp->close)(dbp); + exit(0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c new file mode 100644 index 0000000..ed3f90a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c @@ -0,0 +1,122 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)tdel.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +#include +#include +#include +#include + +#define INITIAL 25000 +#define MAXWORDS 25000 /* # of elements in search table */ + +/* Usage: thash pagesize fillfactor file */ +char wp1[8192]; +char wp2[8192]; +main(argc, argv) +char **argv; +{ + DBT item, key; + DB *dbp; + HASHINFO ctl; + FILE *fp; + int stat; + + int i = 0; + + argv++; + ctl.nelem = INITIAL; + ctl.hash = NULL; + ctl.bsize = atoi(*argv++); + ctl.ffactor = atoi(*argv++); + ctl.cachesize = 1024 * 1024; /* 1 MEG */ + ctl.lorder = 0; + argc -= 2; + if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { + /* create table */ + fprintf(stderr, "cannot create: hash table size %d)\n", + INITIAL); + exit(1); + } + + key.data = wp1; + item.data = wp2; + while ( fgets(wp1, 8192, stdin) && + fgets(wp2, 8192, stdin) && + i++ < MAXWORDS) { +/* +* put info in structure, and structure in the item +*/ + key.size = strlen(wp1); + item.size = strlen(wp2); + +/* + * enter key/data pair into the table + */ + if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { + fprintf(stderr, "cannot enter: key %s\n", + item.data); + exit(1); + } + } + + if ( --argc ) { + fp = fopen ( argv[0], "r"); + i = 0; + while ( fgets(wp1, 8192, fp) && + fgets(wp2, 8192, fp) && + i++ < MAXWORDS) { + key.size = strlen(wp1); + stat = (dbp->del)(dbp, &key, 0); + if (stat) { + fprintf ( stderr, "Error retrieving %s\n", key.data ); + exit(1); + } + } + fclose(fp); + } + (dbp->close)(dbp); + exit(0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit new file mode 100644 index 0000000..039457a --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit @@ -0,0 +1,147 @@ +#!/bin/csh -f +# +# @(#)testit 8.1 (Berkeley) 6/4/93 +# + +echo "" +echo "PAGE FILL " +set name=WORDS + set i = 256 + foreach j ( 11 14 21 ) + thash4 $i $j 25000 65536 $name < $name + end + set i = 512 + foreach j ( 21 28 43 ) + thash4 $i $j 25000 65536 $name < $name + end + set i = 1024 + foreach j ( 43 57 85 ) + thash4 $i $j 25000 65536 $name < $name + end + set i = 2048 + foreach j ( 85 114 171 ) + thash4 $i $j 25000 65536 $name < $name + end + set i = 4096 + foreach j ( 171 228 341 ) + thash4 $i $j 25000 65536 $name < $name + end + set i = 8192 + foreach j ( 341 455 683 ) + thash4 $i $j 25000 65536 $name < $name + end + echo "PAGE FILL " + set i = 256 + foreach j ( 11 14 21 ) + echo "$i"_"$j" + tcreat3 $i $j 25000 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 512 + foreach j ( 21 28 43 ) + echo "$i"_"$j" + tcreat3 $i $j 25000 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 1024 + foreach j ( 43 57 85 ) + echo "$i"_"$j" + tcreat3 $i $j 25000 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 2048 + foreach j ( 85 114 171 ) + echo "$i"_"$j" + tcreat3 $i $j 25000 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 4096 + foreach j ( 171 228 341 ) + echo "$i"_"$j" + tcreat3 $i $j 25000 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 8192 + foreach j ( 341 455 683 ) + echo "$i"_"$j" + tcreat3 $i $j 25000 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end +set name=LONG.DATA + set i = 1024 + foreach j ( 1 2 4 ) + echo thash4 $i $j 600 65536 $name + thash4 $i $j 600 65536 $name < $name + end + + set i = 2048 + foreach j ( 1 2 4 ) + echo thash4 $i $j 600 65536 $name + thash4 $i $j 600 65536 $name < $name + end + set i = 4096 + foreach j ( 1 2 4 ) + echo thash4 $i $j 600 65536 $name + thash4 $i $j 600 65536 $name < $name + end + set i = 8192 + foreach j ( 2 4 8 ) + echo thash4 $i $j 600 65536 $name + thash4 $i $j 600 65536 $name < $name + end + echo "PAGE FILL " + set i = 1024 + foreach j ( 1 2 4 ) + echo "$i"_"$j" + tcreat3 $i $j 600 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 2048 + foreach j ( 1 2 4 ) + echo "$i"_"$j" + tcreat3 $i $j 600 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 4096 + foreach j ( 1 2 4 ) + echo "$i"_"$j" + tcreat3 $i $j 600 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end + set i = 8192 + foreach j ( 2 4 8 ) + echo "$i"_"$j" + tcreat3 $i $j 600 $name < $name + tread2 65536 < $name + tverify $name < $name + tseq > /dev/null + tdel $i $j $name < $name + end +driver2 diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c new file mode 100644 index 0000000..9e344cb --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c @@ -0,0 +1,132 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)thash4.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include + +#define INITIAL 25000 +#define MAXWORDS 25000 /* # of elements in search table */ + +/* Usage: thash pagesize fillfactor file */ +char wp1[8192]; +char wp2[8192]; +main(argc, argv) +char **argv; +{ + DBT item, key, res; + DB *dbp; + HASHINFO ctl; + FILE *fp; + int stat; + time_t t; + + int i = 0; + + argv++; + ctl.hash = NULL; + ctl.bsize = atoi(*argv++); + ctl.ffactor = atoi(*argv++); + ctl.nelem = atoi(*argv++); + ctl.cachesize = atoi(*argv++); + ctl.lorder = 0; + if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { + /* create table */ + fprintf(stderr, "cannot create: hash table size %d)\n", + INITIAL); + fprintf(stderr, "\terrno: %d\n", errno); + exit(1); + } + + key.data = wp1; + item.data = wp2; + while ( fgets(wp1, 8192, stdin) && + fgets(wp2, 8192, stdin) && + i++ < MAXWORDS) { +/* +* put info in structure, and structure in the item +*/ + key.size = strlen(wp1); + item.size = strlen(wp2); + +/* + * enter key/data pair into the table + */ + if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { + fprintf(stderr, "cannot enter: key %s\n", + item.data); + fprintf(stderr, "\terrno: %d\n", errno); + exit(1); + } + } + + if ( --argc ) { + fp = fopen ( argv[0], "r"); + i = 0; + while ( fgets(wp1, 256, fp) && + fgets(wp2, 8192, fp) && + i++ < MAXWORDS) { + + key.size = strlen(wp1); + stat = (dbp->get)(dbp, &key, &res, 0); + if (stat < 0 ) { + fprintf ( stderr, "Error retrieving %s\n", key.data ); + fprintf(stderr, "\terrno: %d\n", errno); + exit(1); + } else if ( stat > 0 ) { + fprintf ( stderr, "%s not found\n", key.data ); + fprintf(stderr, "\terrno: %d\n", errno); + exit(1); + } + } + fclose(fp); + } + dbp->close(dbp); + exit(0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c new file mode 100644 index 0000000..8f01556 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)tread2.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +#include +#include +#include +#include + +#define INITIAL 25000 +#define MAXWORDS 25000 /* # of elements in search table */ + +typedef struct { /* info to be stored */ + int num, siz; +} info; + +char wp1[8192]; +char wp2[8192]; +main(argc, argv) +char **argv; +{ + DBT item, key, res; + DB *dbp; + HASHINFO ctl; + int stat; + + int i = 0; + + ctl.nelem = INITIAL; + ctl.hash = NULL; + ctl.bsize = 64; + ctl.ffactor = 1; + ctl.cachesize = atoi(*argv++); + ctl.lorder = 0; + if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { + /* create table */ + fprintf(stderr, "cannot open: hash table\n" ); + exit(1); + } + + key.data = wp1; + item.data = wp2; + while ( fgets(wp1, 8192, stdin) && + fgets(wp2, 8192, stdin) && + i++ < MAXWORDS) { +/* +* put info in structure, and structure in the item +*/ + key.size = strlen(wp1); + item.size = strlen(wp2); + + stat = (dbp->get)(dbp, &key, &res,0); + if (stat < 0) { + fprintf ( stderr, "Error retrieving %s\n", key.data ); + exit(1); + } else if ( stat > 0 ) { + fprintf ( stderr, "%s not found\n", key.data ); + exit(1); + } + } + (dbp->close)(dbp); + exit(0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c new file mode 100644 index 0000000..f45700e --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)tseq.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +#include +#include +#include +#include + +#define INITIAL 25000 +#define MAXWORDS 25000 /* # of elements in search table */ + + +char wp[8192]; +char cp[8192]; +main(argc, argv) +char **argv; +{ + DBT item, key, res; + DB *dbp; + FILE *fp; + int stat; + + if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) { + /* create table */ + fprintf(stderr, "cannot open: hash table\n" ); + exit(1); + } + +/* +* put info in structure, and structure in the item +*/ + for ( stat = (dbp->seq) (dbp, &res, &item, 1 ); + stat == 0; + stat = (dbp->seq) (dbp, &res, &item, 0 ) ) { + + bcopy ( res.data, wp, res.size ); + wp[res.size] = 0; + bcopy ( item.data, cp, item.size ); + cp[item.size] = 0; + + printf ( "%s %s\n", wp, cp ); + } + (dbp->close)(dbp); + exit(0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c new file mode 100644 index 0000000..ac5d2f9 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c @@ -0,0 +1,107 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)tverify.c 8.1 (Berkeley) 6/4/93"; +#endif /* not lint */ + +#include +#include +#include +#include + +#define INITIAL 25000 +#define MAXWORDS 25000 /* # of elements in search table */ + +typedef struct { /* info to be stored */ + int num, siz; +} info; + +char wp1[8192]; +char wp2[8192]; +main(argc, argv) +char **argv; +{ + DBT key, res; + DB *dbp; + HASHINFO ctl; + int trash; + int stat; + + int i = 0; + + ctl.nelem = INITIAL; + ctl.hash = NULL; + ctl.bsize = 64; + ctl.ffactor = 1; + ctl.cachesize = 1024 * 1024; /* 1 MEG */ + ctl.lorder = 0; + if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { + /* create table */ + fprintf(stderr, "cannot open: hash table\n" ); + exit(1); + } + + key.data = wp1; + while ( fgets(wp1, 8192, stdin) && + fgets(wp2, 8192, stdin) && + i++ < MAXWORDS) { +/* +* put info in structure, and structure in the item +*/ + key.size = strlen(wp1); + + stat = (dbp->get)(dbp, &key, &res,0); + if (stat < 0) { + fprintf ( stderr, "Error retrieving %s\n", key.data ); + exit(1); + } else if ( stat > 0 ) { + fprintf ( stderr, "%s not found\n", key.data ); + exit(1); + } + if ( memcmp ( res.data, wp2, res.size ) ) { + fprintf ( stderr, "data for %s is incorrect. Data was %s. Should have been %s\n", key.data, res.data, wp2 ); + } + } + (dbp->close)(dbp); + exit(0); +} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/run.test b/user/mpy/lib/berkeley-db-1.xx/test/run.test new file mode 100644 index 0000000..52b74c3 --- /dev/null +++ b/user/mpy/lib/berkeley-db-1.xx/test/run.test @@ -0,0 +1,705 @@ +#!/bin/sh - +# +# @(#)run.test 8.10 (Berkeley) 7/26/94 +# + +# db regression tests +main() +{ + + PROG=./dbtest + TMP1=t1 + TMP2=t2 + TMP3=t3 + + if [ -f /usr/share/dict/words ]; then + DICT=/usr/share/dict/words + elif [ -f /usr/dict/words ]; then + DICT=/usr/dict/words + else + echo 'run.test: no dictionary' + exit 1 + fi + + if [ $# -eq 0 ]; then + for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do + test$t + done + else + while [ $# -gt 0 ] + do case "$1" in + test*) + $1;; + [0-9]*) + test$1;; + btree) + for t in 1 2 3 7 8 9 10 12 13; do + test$t + done;; + hash) + for t in 1 2 3 8 13 20; do + test$t + done;; + recno) + for t in 1 2 3 4 5 6 7 10 11; do + test$t + done;; + *) + echo "run.test: unknown test $1" + echo "usage: run.test test# | type" + exit 1 + esac + shift + done + fi + rm -f $TMP1 $TMP2 $TMP3 + exit 0 +} + +# Take the first hundred entries in the dictionary, and make them +# be key/data pairs. +test1() +{ + echo "Test 1: btree, hash: small key, small data pairs" + sed 200q $DICT > $TMP1 + for type in btree hash; do + rm -f $TMP2 $TMP3 + for i in `sed 200q $DICT`; do + echo p + echo k$i + echo d$i + echo g + echo k$i + done > $TMP2 + $PROG -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test1: type $type: failed" + exit 1 + fi + done + echo "Test 1: recno: small key, small data pairs" + rm -f $TMP2 $TMP3 + sed 200q $DICT | + awk '{ + ++i; + printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); + }' > $TMP2 + $PROG -o $TMP3 recno $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test1: type recno: failed" + exit 1 + fi +} + +# Take the first 200 entries in the dictionary, and give them +# each a medium size data entry. +test2() +{ + echo "Test 2: btree, hash: small key, medium data pairs" + mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz + echo $mdata | + awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 + for type in hash btree; do + rm -f $TMP2 $TMP3 + for i in `sed 200q $DICT`; do + echo p + echo k$i + echo d$mdata + echo g + echo k$i + done > $TMP2 + $PROG -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test2: type $type: failed" + exit 1 + fi + done + echo "Test 2: recno: small key, medium data pairs" + rm -f $TMP2 $TMP3 + echo $mdata | + awk '{ for (i = 1; i < 201; ++i) + printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); + }' > $TMP2 + $PROG -o $TMP3 recno $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test2: type recno: failed" + exit 1 + fi +} + +# Insert the programs in /bin with their paths as their keys. +test3() +{ + echo "Test 3: hash: small key, big data pairs" + rm -f $TMP1 + (find /bin -type f -print | xargs cat) > $TMP1 + for type in hash; do + rm -f $TMP2 $TMP3 + for i in `find /bin -type f -print`; do + echo p + echo k$i + echo D$i + echo g + echo k$i + done > $TMP2 + $PROG -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test3: $type: failed" + exit 1 + fi + done + echo "Test 3: btree: small key, big data pairs" + for psize in 512 16384 65536; do + echo " page size $psize" + for type in btree; do + rm -f $TMP2 $TMP3 + for i in `find /bin -type f -print`; do + echo p + echo k$i + echo D$i + echo g + echo k$i + done > $TMP2 + $PROG -i psize=$psize -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test3: $type: page size $psize: failed" + exit 1 + fi + done + done + echo "Test 3: recno: big data pairs" + rm -f $TMP2 $TMP3 + find /bin -type f -print | + awk '{ + ++i; + printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); + }' > $TMP2 + for psize in 512 16384 65536; do + echo " page size $psize" + $PROG -i psize=$psize -o $TMP3 recno $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test3: recno: page size $psize: failed" + exit 1 + fi + done +} + +# Do random recno entries. +test4() +{ + echo "Test 4: recno: random entries" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk '{ + for (i = 37; i <= 37 + 88 * 17; i += 17) { + if (i % 41) + s = substr($0, 1, i % 41); + else + s = substr($0, 1); + printf("input key %d: %s\n", i, s); + } + for (i = 1; i <= 15; ++i) { + if (i % 41) + s = substr($0, 1, i % 41); + else + s = substr($0, 1); + printf("input key %d: %s\n", i, s); + } + for (i = 19234; i <= 19234 + 61 * 27; i += 27) { + if (i % 41) + s = substr($0, 1, i % 41); + else + s = substr($0, 1); + printf("input key %d: %s\n", i, s); + } + exit + }' > $TMP1 + rm -f $TMP2 $TMP3 + cat $TMP1 | + awk 'BEGIN { + i = 37; + incr = 17; + } + { + printf("p\nk%d\nd%s\n", i, $0); + if (i == 19234 + 61 * 27) + exit; + if (i == 37 + 88 * 17) { + i = 1; + incr = 1; + } else if (i == 15) { + i = 19234; + incr = 27; + } else + i += incr; + } + END { + for (i = 37; i <= 37 + 88 * 17; i += 17) + printf("g\nk%d\n", i); + for (i = 1; i <= 15; ++i) + printf("g\nk%d\n", i); + for (i = 19234; i <= 19234 + 61 * 27; i += 27) + printf("g\nk%d\n", i); + }' > $TMP2 + $PROG -o $TMP3 recno $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test4: type recno: failed" + exit 1 + fi +} + +# Do reverse order recno entries. +test5() +{ + echo "Test 5: recno: reverse order entries" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk ' { + for (i = 1500; i; --i) { + if (i % 34) + s = substr($0, 1, i % 34); + else + s = substr($0, 1); + printf("input key %d: %s\n", i, s); + } + exit; + }' > $TMP1 + rm -f $TMP2 $TMP3 + cat $TMP1 | + awk 'BEGIN { + i = 1500; + } + { + printf("p\nk%d\nd%s\n", i, $0); + --i; + } + END { + for (i = 1500; i; --i) + printf("g\nk%d\n", i); + }' > $TMP2 + $PROG -o $TMP3 recno $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test5: type recno: failed" + exit 1 + fi +} + +# Do alternating order recno entries. +test6() +{ + echo "Test 6: recno: alternating order entries" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk ' { + for (i = 1; i < 1200; i += 2) { + if (i % 34) + s = substr($0, 1, i % 34); + else + s = substr($0, 1); + printf("input key %d: %s\n", i, s); + } + for (i = 2; i < 1200; i += 2) { + if (i % 34) + s = substr($0, 1, i % 34); + else + s = substr($0, 1); + printf("input key %d: %s\n", i, s); + } + exit; + }' > $TMP1 + rm -f $TMP2 $TMP3 + cat $TMP1 | + awk 'BEGIN { + i = 1; + even = 0; + } + { + printf("p\nk%d\nd%s\n", i, $0); + i += 2; + if (i >= 1200) { + if (even == 1) + exit; + even = 1; + i = 2; + } + } + END { + for (i = 1; i < 1200; ++i) + printf("g\nk%d\n", i); + }' > $TMP2 + $PROG -o $TMP3 recno $TMP2 + sort -o $TMP1 $TMP1 + sort -o $TMP3 $TMP3 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test6: type recno: failed" + exit 1 + fi +} + +# Delete cursor record +test7() +{ + echo "Test 7: btree, recno: delete cursor record" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk '{ + for (i = 1; i <= 120; ++i) + printf("%05d: input key %d: %s\n", i, i, $0); + printf("%05d: input key %d: %s\n", 120, 120, $0); + printf("seq failed, no such key\n"); + printf("%05d: input key %d: %s\n", 1, 1, $0); + printf("%05d: input key %d: %s\n", 2, 2, $0); + exit; + }' > $TMP1 + rm -f $TMP2 $TMP3 + + for type in btree recno; do + cat $TMP1 | + awk '{ + if (i == 120) + exit; + printf("p\nk%d\nd%s\n", ++i, $0); + } + END { + printf("fR_NEXT\n"); + for (i = 1; i <= 120; ++i) + printf("s\n"); + printf("fR_CURSOR\ns\nk120\n"); + printf("r\n"); + printf("fR_NEXT\ns\n"); + printf("fR_CURSOR\ns\nk1\n"); + printf("r\n"); + printf("fR_FIRST\ns\n"); + }' > $TMP2 + $PROG -o $TMP3 recno $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test7: type $type: failed" + exit 1 + fi + done +} + +# Make sure that overflow pages are reused. +test8() +{ + echo "Test 8: btree, hash: repeated small key, big data pairs" + rm -f $TMP1 + echo "" | + awk 'BEGIN { + for (i = 1; i <= 10; ++i) { + printf("p\nkkey1\nD/bin/sh\n"); + printf("p\nkkey2\nD/bin/csh\n"); + if (i % 8 == 0) { + printf("c\nkkey2\nD/bin/csh\n"); + printf("c\nkkey1\nD/bin/sh\n"); + printf("e\t%d of 10 (comparison)\n", i); + } else + printf("e\t%d of 10 \n", i); + printf("r\nkkey1\nr\nkkey2\n"); + } + }' > $TMP1 + $PROG btree $TMP1 +# $PROG hash $TMP1 + # No explicit test for success. +} + +# Test btree duplicate keys +test9() +{ + echo "Test 9: btree: duplicate keys" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk '{ + for (i = 1; i <= 543; ++i) + printf("%05d: input key %d: %s\n", i, i, $0); + exit; + }' > $TMP1 + rm -f $TMP2 $TMP3 + + for type in btree; do + cat $TMP1 | + awk '{ + if (i++ % 2) + printf("p\nkduplicatekey\nd%s\n", $0); + else + printf("p\nkunique%dkey\nd%s\n", i, $0); + } + END { + printf("o\n"); + }' > $TMP2 + $PROG -iflags=1 -o $TMP3 $type $TMP2 + sort -o $TMP3 $TMP3 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test9: type $type: failed" + exit 1 + fi + done +} + +# Test use of cursor flags without initialization +test10() +{ + echo "Test 10: btree, recno: test cursor flag use" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk '{ + for (i = 1; i <= 20; ++i) + printf("%05d: input key %d: %s\n", i, i, $0); + exit; + }' > $TMP1 + rm -f $TMP2 $TMP3 + + # Test that R_CURSOR doesn't succeed before cursor initialized + for type in btree recno; do + cat $TMP1 | + awk '{ + if (i == 10) + exit; + printf("p\nk%d\nd%s\n", ++i, $0); + } + END { + printf("fR_CURSOR\nr\n"); + printf("eR_CURSOR SHOULD HAVE FAILED\n"); + }' > $TMP2 + $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 + if [ -s $TMP3 ] ; then + echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED" + exit 1 + fi + done + for type in btree recno; do + cat $TMP1 | + awk '{ + if (i == 10) + exit; + printf("p\nk%d\nd%s\n", ++i, $0); + } + END { + printf("fR_CURSOR\np\nk1\ndsome data\n"); + printf("eR_CURSOR SHOULD HAVE FAILED\n"); + }' > $TMP2 + $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 + if [ -s $TMP3 ] ; then + echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED" + exit 1 + fi + done +} + +# Test insert in reverse order. +test11() +{ + echo "Test 11: recno: reverse order insert" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk '{ + for (i = 1; i <= 779; ++i) + printf("%05d: input key %d: %s\n", i, i, $0); + exit; + }' > $TMP1 + rm -f $TMP2 $TMP3 + + for type in recno; do + cat $TMP1 | + awk '{ + if (i == 0) { + i = 1; + printf("p\nk1\nd%s\n", $0); + printf("%s\n", "fR_IBEFORE"); + } else + printf("p\nk1\nd%s\n", $0); + } + END { + printf("or\n"); + }' > $TMP2 + $PROG -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test11: type $type: failed" + exit 1 + fi + done +} + +# Take the first 20000 entries in the dictionary, reverse them, and give +# them each a small size data entry. Use a small page size to make sure +# the btree split code gets hammered. +test12() +{ + echo "Test 12: btree: lots of keys, small page size" + mdata=abcdefghijklmnopqrstuvwxy + echo $mdata | + awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 + for type in btree; do + rm -f $TMP2 $TMP3 + for i in `sed 20000q $DICT | rev`; do + echo p + echo k$i + echo d$mdata + echo g + echo k$i + done > $TMP2 + $PROG -i psize=512 -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test12: type $type: failed" + exit 1 + fi + done +} + +# Test different byte orders. +test13() +{ + echo "Test 13: btree, hash: differing byte orders" + sed 50q $DICT > $TMP1 + for order in 1234 4321; do + for type in btree hash; do + rm -f byte.file $TMP2 $TMP3 + for i in `sed 50q $DICT`; do + echo p + echo k$i + echo d$i + echo g + echo k$i + done > $TMP2 + $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test13: $type/$order put failed" + exit 1 + fi + for i in `sed 50q $DICT`; do + echo g + echo k$i + done > $TMP2 + $PROG -s \ + -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test13: $type/$order get failed" + exit 1 + fi + done + done + rm -f byte.file +} + +# Try a variety of bucketsizes and fill factors for hashing +test20() +{ + echo\ + "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536" + echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | + awk '{ + for (i = 1; i <= 10000; ++i) { + if (i % 34) + s = substr($0, 1, i % 34); + else + s = substr($0, 1); + printf("%s\n", s); + } + exit; + }' > $TMP1 + sed 10000q $DICT | + awk 'BEGIN { + ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" + } + { + if (++i % 34) + s = substr(ds, 1, i % 34); + else + s = substr(ds, 1); + printf("p\nk%s\nd%s\n", $0, s); + }' > $TMP2 + sed 10000q $DICT | + awk '{ + ++i; + printf("g\nk%s\n", $0); + }' >> $TMP2 + bsize=256 + for ffactor in 11 14 21; do + echo " bucketsize $bsize, fill factor $ffactor" + $PROG -o$TMP3 \ + -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ + hash $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test20: type hash:\ +bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" + exit 1 + fi + done + bsize=512 + for ffactor in 21 28 43; do + echo " bucketsize $bsize, fill factor $ffactor" + $PROG -o$TMP3 \ + -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ + hash $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test20: type hash:\ +bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" + exit 1 + fi + done + bsize=1024 + for ffactor in 43 57 85; do + echo " bucketsize $bsize, fill factor $ffactor" + $PROG -o$TMP3 \ + -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ + hash $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test20: type hash:\ +bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" + exit 1 + fi + done + bsize=2048 + for ffactor in 85 114 171; do + echo " bucketsize $bsize, fill factor $ffactor" + $PROG -o$TMP3 \ + -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ + hash $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test20: type hash:\ +bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" + exit 1 + fi + done + bsize=4096 + for ffactor in 171 228 341; do + echo " bucketsize $bsize, fill factor $ffactor" + $PROG -o$TMP3 \ + -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ + hash $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test20: type hash:\ +bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" + exit 1 + fi + done + bsize=8192 + for ffactor in 341 455 683; do + echo " bucketsize $bsize, fill factor $ffactor" + $PROG -o$TMP3 \ + -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ + hash $TMP2 + if (cmp -s $TMP1 $TMP3) ; then : + else + echo "test20: type hash:\ +bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" + exit 1 + fi + done +} + +main $* diff --git a/user/mpy/lib/cmsis/inc/cmsis_armcc.h b/user/mpy/lib/cmsis/inc/cmsis_armcc.h new file mode 100644 index 0000000..74c49c6 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/cmsis_armcc.h @@ -0,0 +1,734 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS Cortex-M Core Function/Instruction Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#ifndef __CMSIS_ARMCC_H +#define __CMSIS_ARMCC_H + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) + #error "Please use ARM Compiler Toolchain V4.0.677 or later!" +#endif + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/* intrinsic void __enable_irq(); */ +/* intrinsic void __disable_irq(); */ + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xFFU); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + register uint32_t __regBasePriMax __ASM("basepri_max"); + __regBasePriMax = (basePri & 0xFFU); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1); +} + +#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + + +#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#endif +} + +#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ + + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() do {\ + __schedule_barrier();\ + __isb(0xF);\ + __schedule_barrier();\ + } while (0U) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() do {\ + __schedule_barrier();\ + __dsb(0xF);\ + __schedule_barrier();\ + } while (0U) + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() do {\ + __schedule_barrier();\ + __dmb(0xF);\ + __schedule_barrier();\ + } while (0U) + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in integer value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in two unsigned short values. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + +/** + \brief Reverse byte order in signed short value + \details Reverses the byte order in a signed short value with sign extension to integer. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] value Value to rotate + \param [in] value Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ + return(result); +} +#endif + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + + +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) +#else + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) +#else + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) +#else + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXB(value, ptr) __strex(value, ptr) +#else + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXH(value, ptr) __strex(value, ptr) +#else + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXW(value, ptr) __strex(value, ptr) +#else + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) +{ + rrx r0, r0 + bx lr +} +#endif + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRBT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRHT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRT(value, ptr) __strt(value, ptr) + +#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ + +#define __SADD8 __sadd8 +#define __QADD8 __qadd8 +#define __SHADD8 __shadd8 +#define __UADD8 __uadd8 +#define __UQADD8 __uqadd8 +#define __UHADD8 __uhadd8 +#define __SSUB8 __ssub8 +#define __QSUB8 __qsub8 +#define __SHSUB8 __shsub8 +#define __USUB8 __usub8 +#define __UQSUB8 __uqsub8 +#define __UHSUB8 __uhsub8 +#define __SADD16 __sadd16 +#define __QADD16 __qadd16 +#define __SHADD16 __shadd16 +#define __UADD16 __uadd16 +#define __UQADD16 __uqadd16 +#define __UHADD16 __uhadd16 +#define __SSUB16 __ssub16 +#define __QSUB16 __qsub16 +#define __SHSUB16 __shsub16 +#define __USUB16 __usub16 +#define __UQSUB16 __uqsub16 +#define __UHSUB16 __uhsub16 +#define __SASX __sasx +#define __QASX __qasx +#define __SHASX __shasx +#define __UASX __uasx +#define __UQASX __uqasx +#define __UHASX __uhasx +#define __SSAX __ssax +#define __QSAX __qsax +#define __SHSAX __shsax +#define __USAX __usax +#define __UQSAX __uqsax +#define __UHSAX __uhsax +#define __USAD8 __usad8 +#define __USADA8 __usada8 +#define __SSAT16 __ssat16 +#define __USAT16 __usat16 +#define __UXTB16 __uxtb16 +#define __UXTAB16 __uxtab16 +#define __SXTB16 __sxtb16 +#define __SXTAB16 __sxtab16 +#define __SMUAD __smuad +#define __SMUADX __smuadx +#define __SMLAD __smlad +#define __SMLADX __smladx +#define __SMLALD __smlald +#define __SMLALDX __smlaldx +#define __SMUSD __smusd +#define __SMUSDX __smusdx +#define __SMLSD __smlsd +#define __SMLSDX __smlsdx +#define __SMLSLD __smlsld +#define __SMLSLDX __smlsldx +#define __SEL __sel +#define __QADD __qadd +#define __QSUB __qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ + ((int64_t)(ARG3) << 32U) ) >> 32U)) + +#endif /* (__CORTEX_M >= 0x04) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h b/user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h new file mode 100644 index 0000000..cd13240 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h @@ -0,0 +1,1800 @@ +/**************************************************************************//** + * @file cmsis_armcc_V6.h + * @brief CMSIS Cortex-M Core Function/Instruction Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#ifndef __CMSIS_ARMCC_V6_H +#define __CMSIS_ARMCC_V6_H + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get IPSR Register (non-secure) + \details Returns the content of the non-secure IPSR Register when in secure state. + \return IPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_IPSR_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get APSR Register (non-secure) + \details Returns the content of the non-secure APSR Register when in secure state. + \return APSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_APSR_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get xPSR Register (non-secure) + \details Returns the content of the non-secure xPSR Register when in secure state. + \return xPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_xPSR_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : "sp"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : "sp"); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : "sp"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : "sp"); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__((always_inline)) __STATIC_INLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__((always_inline)) __STATIC_INLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t value) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t value) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (value) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Base Priority with condition (non_secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_MAX_NS(uint32_t value) +{ + __ASM volatile ("MSR basepri_max_ns, %0" : : "r" (value) : "memory"); +} +#endif + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + + +#endif /* ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ + + +#if (__ARM_ARCH_8M__ == 1U) + +/** + \brief Get Process Stack Pointer Limit + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Get Process Stack Pointer Limit (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Get Main Stack Pointer Limit (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Set Main Stack Pointer Limit (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +} +#endif + +#endif /* (__ARM_ARCH_8M__ == 1U) */ + + +#if ((__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=4 */ + +/** + \brief Get FPSCR + \details eturns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#define __get_FPSCR __builtin_arm_get_fpscr +#if 0 +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + uint32_t result; + + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#endif +} +#endif + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get FPSCR (non-secure) + \details Returns the current value of the non-secure Floating Point Status/Control register when in secure state. + \return Floating Point Status/Control register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FPSCR_NS(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + uint32_t result; + + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMRS %0, fpscr_ns" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#endif +} +#endif + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#define __set_FPSCR __builtin_arm_set_fpscr +#if 0 +__attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} +#endif + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set FPSCR (non-secure) + \details Assigns the given value to the non-secure Floating Point Status/Control register when in secure state. + \param [in] fpscr Floating Point Status/Control value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FPSCR_NS(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMSR fpscr_ns, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} +#endif + +#endif /* ((__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ + + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF); + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF); + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF); + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in integer value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __builtin_bswap32 + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in two unsigned short values. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16 __builtin_bswap16 /* ToDo: ARMCC_V6: check if __builtin_bswap16 could be used */ +#if 0 +__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} +#endif + + +/** + \brief Reverse byte order in signed short value + \details Reverses the byte order in a signed short value with sign extension to integer. + \param [in] value Value to reverse + \return Reversed value + */ + /* ToDo: ARMCC_V6: check if __builtin_bswap16 could be used */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) +{ + int32_t result; + + __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ + /* ToDo: ARMCC_V6: check if __builtin_arm_rbit is supported */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ + __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return(result); +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __builtin_clz + + +#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +/*#define __SSAT __builtin_arm_ssat*/ +#define __SSAT(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat +#if 0 +#define __USAT(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) +#endif + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#endif /* ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ + + +#if (__ARM_ARCH_8M__ == 1U) + +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* (__ARM_ARCH_8M__ == 1U) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (__ARM_FEATURE_DSP == 1U) /* ToDo: ARMCC_V6: This should be ARCH >= ARMv7-M + SIMD */ + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1U) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_V6_H */ diff --git a/user/mpy/lib/cmsis/inc/cmsis_gcc.h b/user/mpy/lib/cmsis/inc/cmsis_gcc.h new file mode 100644 index 0000000..bb89fbb --- /dev/null +++ b/user/mpy/lib/cmsis/inc/cmsis_gcc.h @@ -0,0 +1,1373 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS Cortex-M Core Function/Instruction Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + + \return xPSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (__CORTEX_M >= 0x03U) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + +#endif /* (__CORTEX_M >= 0x03U) */ + + +#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + uint32_t result; + + /* Empty asm statement works as a scheduling barrier */ + __ASM volatile (""); + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + /* Empty asm statement works as a scheduling barrier */ + __ASM volatile (""); + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} + +#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ + + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +__attribute__((always_inline)) __STATIC_INLINE void __NOP(void) +{ + __ASM volatile ("nop"); +} + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +__attribute__((always_inline)) __STATIC_INLINE void __WFI(void) +{ + __ASM volatile ("wfi"); +} + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +__attribute__((always_inline)) __STATIC_INLINE void __WFE(void) +{ + __ASM volatile ("wfe"); +} + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +__attribute__((always_inline)) __STATIC_INLINE void __SEV(void) +{ + __ASM volatile ("sev"); +} + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__attribute__((always_inline)) __STATIC_INLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__attribute__((always_inline)) __STATIC_INLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__attribute__((always_inline)) __STATIC_INLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in integer value. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in two unsigned short values. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief Reverse byte order in signed short value + \details Reverses the byte order in a signed short value with sign extension to integer. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (short)__builtin_bswap16(value); +#else + int32_t result; + + __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +#endif +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] value Value to rotate + \param [in] value Number of Bits to rotate + \return Rotated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return(result); +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __builtin_clz + + +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) ); +} + +#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__CORTEX_M >= 0x04) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +#endif /* __CMSIS_GCC_H */ diff --git a/user/mpy/lib/cmsis/inc/core_cm0.h b/user/mpy/lib/cmsis/inc/core_cm0.h new file mode 100644 index 0000000..711dad5 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cm0.h @@ -0,0 +1,798 @@ +/**************************************************************************//** + * @file core_cm0.h + * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0_H_GENERIC +#define __CORE_CM0_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M0 + @{ + */ + +/* CMSIS CM0 definitions */ +#define __CM0_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM0_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ + __CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x00U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0_H_DEPENDANT +#define __CORE_CM0_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0_REV + #define __CM0_REV 0x0000U + #warning "__CM0_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M0 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M0 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/* Interrupt Priorities are WORD accessible only under ARMv6M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm0plus.h b/user/mpy/lib/cmsis/inc/core_cm0plus.h new file mode 100644 index 0000000..b04aa39 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cm0plus.h @@ -0,0 +1,914 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0PLUS_H_GENERIC +#define __CORE_CM0PLUS_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex-M0+ + @{ + */ + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x00U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0PLUS_H_DEPENDANT +#define __CORE_CM0PLUS_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0PLUS_REV + #define __CM0PLUS_REV 0x0000U + #warning "__CM0PLUS_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex-M0+ */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if (__VTOR_PRESENT == 1U) +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0+ header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M0+ Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/* Interrupt Priorities are WORD accessible only under ARMv6M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm3.h b/user/mpy/lib/cmsis/inc/core_cm3.h new file mode 100644 index 0000000..b4ac4c7 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cm3.h @@ -0,0 +1,1763 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M3 + @{ + */ + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x03U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200U + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if (__CM3_REV < 0x0201U) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if ((defined __CM3_REV) && (__CM3_REV >= 0x200U)) + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1U]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M3 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm4.h b/user/mpy/lib/cmsis/inc/core_cm4.h new file mode 100644 index 0000000..dc840eb --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cm4.h @@ -0,0 +1,1937 @@ +/**************************************************************************//** + * @file core_cm4.h + * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM4_H_GENERIC +#define __CORE_CM4_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M4 + @{ + */ + +/* CMSIS CM4 definitions */ +#define __CM4_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM4_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ + __CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x04U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #if (__FPU_PRESENT == 1) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ +#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM4_H_DEPENDANT +#define __CORE_CM4_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM4_REV + #define __CM4_REV 0x0000U + #warning "__CM4_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M4 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if (__FPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/*@} end of group CMSIS_FPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M4 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#if (__FPU_PRESENT == 1U) + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm7.h b/user/mpy/lib/cmsis/inc/core_cm7.h new file mode 100644 index 0000000..3b7530a --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cm7.h @@ -0,0 +1,2512 @@ +/**************************************************************************//** + * @file core_cm7.h + * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM7_H_GENERIC +#define __CORE_CM7_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M7 + @{ + */ + +/* CMSIS CM7 definitions */ +#define __CM7_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM7_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ + __CM7_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x07U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #if (__FPU_PRESENT == 1) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ +#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM7_H_DEPENDANT +#define __CORE_CM7_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM7_REV + #define __CM7_REV 0x0000U + #warning "__CM7_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M7 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED3[93U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 1 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + uint32_t RESERVED7[6U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ + __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ + __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ + __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ + uint32_t RESERVED8[1U]; + __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ + +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ +#define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ + +#define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ +#define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ +#define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ + +#define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ +#define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* AHBP Control Register Definitions */ +#define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ +#define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ + +#define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ +#define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +#define SCB_CACR_ECCEN_Pos 1U /*!< SCB CACR: ECCEN Position */ +#define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< SCB CACR: ECCEN Mask */ + +#define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ +#define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ + +/* AHBS Control Register Definitions */ +#define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ +#define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBPCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ + +#define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ +#define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBPCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ + +#define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ +#define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBPCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ + +/* Auxiliary Bus Fault Status Register Definitions */ +#define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ +#define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ + +#define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ +#define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ + +#define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ +#define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ + +#define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ +#define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ + +#define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ +#define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ + +#define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ +#define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ +#define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ + +#define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED3[981U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if (__FPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +/*@} end of group CMSIS_FPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M4 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#if (__FPU_PRESENT == 1U) + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHPR[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return(((uint32_t)SCB->SHPR[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = SCB->MVFR0; + if ((mvfr0 & 0x00000FF0UL) == 0x220UL) + { + return 2UL; /* Double + Single precision FPU */ + } + else if ((mvfr0 & 0x00000FF0UL) == 0x020UL) + { + return 1UL; /* Single precision FPU */ + } + else + { + return 0UL; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## Cache functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_INLINE void SCB_EnableICache (void) +{ + #if (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_INLINE void SCB_DisableICache (void) +{ + #if (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_INLINE void SCB_InvalidateICache (void) +{ + #if (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_INLINE void SCB_EnableDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways--); + } while(sets--); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_INLINE void SCB_DisableDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_INLINE void SCB_InvalidateDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_INLINE void SCB_CleanDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_INLINE void SCB_CleanInvalidateDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_INLINE void SCB_InvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if (__DCACHE_PRESENT == 1U) + int32_t op_size = dsize; + uint32_t op_addr = (uint32_t)addr; + int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ + + __DSB(); + + while (op_size > 0) { + SCB->DCIMVAC = op_addr; + op_addr += linesize; + op_size -= linesize; + } + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_INLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if (__DCACHE_PRESENT == 1) + int32_t op_size = dsize; + uint32_t op_addr = (uint32_t) addr; + int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ + + __DSB(); + + while (op_size > 0) { + SCB->DCCMVAC = op_addr; + op_addr += linesize; + op_size -= linesize; + } + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_INLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if (__DCACHE_PRESENT == 1U) + int32_t op_size = dsize; + uint32_t op_addr = (uint32_t) addr; + int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ + + __DSB(); + + while (op_size > 0) { + SCB->DCCIMVAC = op_addr; + op_addr += linesize; + op_size -= linesize; + } + + __DSB(); + __ISB(); + #endif +} + + +/*@} end of CMSIS_Core_CacheFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cmFunc.h b/user/mpy/lib/cmsis/inc/core_cmFunc.h new file mode 100644 index 0000000..652a48a --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cmFunc.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * @file core_cmFunc.h + * @brief CMSIS Cortex-M Core Function Access Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CMFUNC_H +#define __CORE_CMFUNC_H + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ +*/ + +/*------------------ RealView Compiler -----------------*/ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #include "cmsis_armcc_V6.h" + +/*------------------ GNU Compiler ----------------------*/ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + +/*------------------ ICC Compiler ----------------------*/ +#elif defined ( __ICCARM__ ) + #include + +/*------------------ TI CCS Compiler -------------------*/ +#elif defined ( __TMS470__ ) + #include + +/*------------------ TASKING Compiler ------------------*/ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + +/*------------------ COSMIC Compiler -------------------*/ +#elif defined ( __CSMC__ ) + #include + +#endif + +/*@} end of CMSIS_Core_RegAccFunctions */ + +#endif /* __CORE_CMFUNC_H */ diff --git a/user/mpy/lib/cmsis/inc/core_cmInstr.h b/user/mpy/lib/cmsis/inc/core_cmInstr.h new file mode 100644 index 0000000..f474b0e --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cmInstr.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * @file core_cmInstr.h + * @brief CMSIS Cortex-M Core Instruction Access Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CMINSTR_H +#define __CORE_CMINSTR_H + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/*------------------ RealView Compiler -----------------*/ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #include "cmsis_armcc_V6.h" + +/*------------------ GNU Compiler ----------------------*/ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + +/*------------------ ICC Compiler ----------------------*/ +#elif defined ( __ICCARM__ ) + #include + +/*------------------ TI CCS Compiler -------------------*/ +#elif defined ( __TMS470__ ) + #include + +/*------------------ TASKING Compiler ------------------*/ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + +/*------------------ COSMIC Compiler -------------------*/ +#elif defined ( __CSMC__ ) + #include + +#endif + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + +#endif /* __CORE_CMINSTR_H */ diff --git a/user/mpy/lib/cmsis/inc/core_cmSimd.h b/user/mpy/lib/cmsis/inc/core_cmSimd.h new file mode 100644 index 0000000..66bf5c2 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_cmSimd.h @@ -0,0 +1,96 @@ +/**************************************************************************//** + * @file core_cmSimd.h + * @brief CMSIS Cortex-M SIMD Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CMSIMD_H +#define __CORE_CMSIMD_H + +#ifdef __cplusplus + extern "C" { +#endif + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +/*------------------ RealView Compiler -----------------*/ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #include "cmsis_armcc_V6.h" + +/*------------------ GNU Compiler ----------------------*/ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + +/*------------------ ICC Compiler ----------------------*/ +#elif defined ( __ICCARM__ ) + #include + +/*------------------ TI CCS Compiler -------------------*/ +#elif defined ( __TMS470__ ) + #include + +/*------------------ TASKING Compiler ------------------*/ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + +/*------------------ COSMIC Compiler -------------------*/ +#elif defined ( __CSMC__ ) + #include + +#endif + +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CMSIMD_H */ diff --git a/user/mpy/lib/cmsis/inc/core_sc000.h b/user/mpy/lib/cmsis/inc/core_sc000.h new file mode 100644 index 0000000..514dbd8 --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_sc000.h @@ -0,0 +1,926 @@ +/**************************************************************************//** + * @file core_sc000.h + * @brief CMSIS SC000 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC000_H_GENERIC +#define __CORE_SC000_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC000 + @{ + */ + +/* CMSIS SC000 definitions */ +#define __SC000_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __SC000_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \ + __SC000_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_SC (000U) /*!< Cortex secure core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC000_H_DEPENDANT +#define __CORE_SC000_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC000_REV + #define __SC000_REV 0x0000U + #warning "__SC000_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC000 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + uint32_t RESERVED1[154U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the SC000 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of SC000 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/* Interrupt Priorities are WORD accessible only under ARMv6M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_sc300.h b/user/mpy/lib/cmsis/inc/core_sc300.h new file mode 100644 index 0000000..8bd18aa --- /dev/null +++ b/user/mpy/lib/cmsis/inc/core_sc300.h @@ -0,0 +1,1745 @@ +/**************************************************************************//** + * @file core_sc300.h + * @brief CMSIS SC300 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC300_H_GENERIC +#define __CORE_SC300_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC3000 + @{ + */ + +/* CMSIS SC300 definitions */ +#define __SC300_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __SC300_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \ + __SC300_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_SC (300U) /*!< Cortex secure core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_PCS_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC300_H_DEPENDANT +#define __CORE_SC300_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC300_REV + #define __SC300_REV 0x0000U + #warning "__SC300_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC300 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED1[129U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + uint32_t RESERVED1[1U]; +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M3 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) < 0) + { + return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/embed/abort_.c b/user/mpy/lib/embed/abort_.c new file mode 100644 index 0000000..a6df814 --- /dev/null +++ b/user/mpy/lib/embed/abort_.c @@ -0,0 +1,7 @@ +#include + +NORETURN void abort_(void); + +NORETURN void abort_(void) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "abort() called")); +} diff --git a/user/mpy/lib/libc/string0.c b/user/mpy/lib/libc/string0.c new file mode 100644 index 0000000..c2f2abd --- /dev/null +++ b/user/mpy/lib/libc/string0.c @@ -0,0 +1,219 @@ +/* + * 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. + */ + +#include +#include + +#define likely(x) __builtin_expect((x), 1) + +void *memcpy(void *dst, const void *src, size_t n) { + if (likely(!(((uintptr_t)dst) & 3) && !(((uintptr_t)src) & 3))) { + // pointers aligned + uint32_t *d = dst; + const uint32_t *s = src; + + // copy words first + for (size_t i = (n >> 2); i; i--) { + *d++ = *s++; + } + + if (n & 2) { + // copy half-word + *(uint16_t*)d = *(const uint16_t*)s; + d = (uint32_t*)((uint16_t*)d + 1); + s = (const uint32_t*)((const uint16_t*)s + 1); + } + + if (n & 1) { + // copy byte + *((uint8_t*)d) = *((const uint8_t*)s); + } + } else { + // unaligned access, copy bytes + uint8_t *d = dst; + const uint8_t *s = src; + + for (; n; n--) { + *d++ = *s++; + } + } + + return dst; +} + +void *memmove(void *dest, const void *src, size_t n) { + if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) { + // need to copy backwards + uint8_t *d = (uint8_t*)dest + n - 1; + const uint8_t *s = (const uint8_t*)src + n - 1; + for (; n > 0; n--) { + *d-- = *s--; + } + return dest; + } else { + // can use normal memcpy + return memcpy(dest, src, n); + } +} + +void *memset(void *s, int c, size_t n) { + if (c == 0 && ((uintptr_t)s & 3) == 0) { + // aligned store of 0 + uint32_t *s32 = s; + for (size_t i = n >> 2; i > 0; i--) { + *s32++ = 0; + } + if (n & 2) { + *((uint16_t*)s32) = 0; + s32 = (uint32_t*)((uint16_t*)s32 + 1); + } + if (n & 1) { + *((uint8_t*)s32) = 0; + } + } else { + uint8_t *s2 = s; + for (; n > 0; n--) { + *s2++ = c; + } + } + return s; +} + +int memcmp(const void *s1, const void *s2, size_t n) { + const uint8_t *s1_8 = s1; + const uint8_t *s2_8 = s2; + while (n--) { + char c1 = *s1_8++; + char c2 = *s2_8++; + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + } + return 0; +} + +void *memchr(const void *s, int c, size_t n) { + if (n != 0) { + const unsigned char *p = s; + + do { + if (*p++ == c) + return ((void *)(p - 1)); + } while (--n != 0); + } + return 0; +} + +size_t strlen(const char *str) { + int len = 0; + for (const char *s = str; *s; s++) { + len += 1; + } + return len; +} + +int strcmp(const char *s1, const char *s2) { + while (*s1 && *s2) { + char c1 = *s1++; // XXX UTF8 get char, next char + char c2 = *s2++; // XXX UTF8 get char, next char + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + } + if (*s2) return -1; + else if (*s1) return 1; + else return 0; +} + +int strncmp(const char *s1, const char *s2, size_t n) { + while (*s1 && *s2 && n > 0) { + char c1 = *s1++; // XXX UTF8 get char, next char + char c2 = *s2++; // XXX UTF8 get char, next char + n--; + if (c1 < c2) return -1; + else if (c1 > c2) return 1; + } + if (n == 0) return 0; + else if (*s2) return -1; + else if (*s1) return 1; + else return 0; +} + +char *strcpy(char *dest, const char *src) { + char *d = dest; + while (*src) { + *d++ = *src++; + } + *d = '\0'; + return dest; +} + +// needed because gcc optimises strcpy + strcat to this +char *stpcpy(char *dest, const char *src) { + while (*src) { + *dest++ = *src++; + } + *dest = '\0'; + return dest; +} + +char *strcat(char *dest, const char *src) { + char *d = dest; + while (*d) { + d++; + } + while (*src) { + *d++ = *src++; + } + *d = '\0'; + return dest; +} + +// Public Domain implementation of strchr from: +// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strchr_function +char *strchr(const char *s, int c) +{ + /* Scan s for the character. When this loop is finished, + s will either point to the end of the string or the + character we were looking for. */ + while (*s != '\0' && *s != (char)c) + s++; + return ((*s == c) ? (char *) s : 0); +} + + +// Public Domain implementation of strstr from: +// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strstr_function +char *strstr(const char *haystack, const char *needle) +{ + size_t needlelen; + /* Check for the null needle case. */ + if (*needle == '\0') + return (char *) haystack; + needlelen = strlen(needle); + for (; (haystack = strchr(haystack, *needle)) != 0; haystack++) + if (strncmp(haystack, needle, needlelen) == 0) + return (char *) haystack; + return 0; +} diff --git a/user/mpy/lib/libffi/.gitignore b/user/mpy/lib/libffi/.gitignore new file mode 100644 index 0000000..6f89994 --- /dev/null +++ b/user/mpy/lib/libffi/.gitignore @@ -0,0 +1,36 @@ +.libs +.deps +*.o +*.lo +.dirstamp +*.la +Makefile +Makefile.in +aclocal.m4 +compile +config.* +configure +depcomp +doc/libffi.info +*~ +fficonfig.h.in +fficonfig.h +include/ffi.h +include/ffitarget.h +install-sh +libffi.pc +libtool +libtool-ldflags +ltmain.sh +m4/libtool.m4 +m4/lt*.m4 +mdate-sh +missing +stamp-h1 +libffi*gz +autom4te.cache +libffi.xcodeproj/xcuserdata +libffi.xcodeproj/project.xcworkspace +build_*/ +darwin_*/ +src/arm/trampoline.S diff --git a/user/mpy/lib/libffi/.travis.yml b/user/mpy/lib/libffi/.travis.yml new file mode 100644 index 0000000..6c14fcd --- /dev/null +++ b/user/mpy/lib/libffi/.travis.yml @@ -0,0 +1,22 @@ +language: cpp +compiler: + - gcc + - clang +env: + - + - HOST=i386-pc-linux-gnu +matrix: + exclude: + - compiler: clang + env: HOST=i386-pc-linux-gnu + +before_script: + - sudo apt-get install dejagnu texinfo + - if [ "$HOST" = i386-pc-linux-gnu ] ; then sudo apt-get install gcc-multilib g++-multilib && CC="$CC -m32" && CXX="$CXX -m32" ; fi + +script: + - ./autogen.sh + - ./configure ${HOST+--host=$HOST} + - make + - make dist + - make check diff --git a/user/mpy/lib/libffi/ChangeLog.libffi b/user/mpy/lib/libffi/ChangeLog.libffi new file mode 100644 index 0000000..49ba8da --- /dev/null +++ b/user/mpy/lib/libffi/ChangeLog.libffi @@ -0,0 +1,584 @@ +2011-02-08 Andreas Tobler + + * testsuite/lib/libffi.exp: Tweak for stand-alone mode. + +2009-12-25 Samuli Suominen + + * configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64. + * configure: Rebuilt. + * fficonfig.h.in: Rebuilt. + +2009-06-16 Andrew Haley + + * testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_medium2.c: Fix printf format + specifiers. + * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs. + * testsuite/libffi.call/float2.c: Fix dg-excess-errors. + * testsuite/libffi.call/ffitest.h, + testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define. + +2009-06-12 Andrew Haley + + * testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_medium2.c: Fix printf format + specifiers. + testsuite/libffi.special/unwindtest.cc: include stdint.h. + +2009-06-11 Timothy Wall + + * Makefile.am, + configure.ac, + include/ffi.h.in, + include/ffi_common.h, + src/closures.c, + src/dlmalloc.c, + src/x86/ffi.c, + src/x86/ffitarget.h, + src/x86/win64.S (new), + README: Added win64 support (mingw or MSVC) + * Makefile.in, + include/Makefile.in, + man/Makefile.in, + testsuite/Makefile.in, + configure, + aclocal.m4: Regenerated + * ltcf-c.sh: properly escape cygwin/w32 path + * man/ffi_call.3: Clarify size requirements for return value. + * src/x86/ffi64.c: Fix filename in comment. + * src/x86/win32.S: Remove unused extern. + + * testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/cls_12byte.c, + testsuite/libffi.call/cls_16byte.c, + testsuite/libffi.call/cls_18byte.c, + testsuite/libffi.call/cls_19byte.c, + testsuite/libffi.call/cls_1_1byte.c, + testsuite/libffi.call/cls_20byte.c, + testsuite/libffi.call/cls_20byte1.c, + testsuite/libffi.call/cls_24byte.c, + testsuite/libffi.call/cls_2byte.c, + testsuite/libffi.call/cls_3_1byte.c, + testsuite/libffi.call/cls_3byte1.c, + testsuite/libffi.call/cls_3byte2.c, + testsuite/libffi.call/cls_4_1byte.c, + testsuite/libffi.call/cls_4byte.c, + testsuite/libffi.call/cls_5_1_byte.c, + testsuite/libffi.call/cls_5byte.c, + testsuite/libffi.call/cls_64byte.c, + testsuite/libffi.call/cls_6_1_byte.c, + testsuite/libffi.call/cls_6byte.c, + testsuite/libffi.call/cls_7_1_byte.c, + testsuite/libffi.call/cls_7byte.c, + testsuite/libffi.call/cls_8byte.c, + testsuite/libffi.call/cls_9byte1.c, + testsuite/libffi.call/cls_9byte2.c, + testsuite/libffi.call/cls_align_double.c, + testsuite/libffi.call/cls_align_float.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_align_sint16.c, + testsuite/libffi.call/cls_align_sint32.c, + testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint16.c, + testsuite/libffi.call/cls_align_uint32.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_dbls_struct.c, + testsuite/libffi.call/cls_double.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_float.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_multi_schar.c, + testsuite/libffi.call/cls_multi_sshort.c, + testsuite/libffi.call/cls_multi_sshortchar.c, + testsuite/libffi.call/cls_multi_uchar.c, + testsuite/libffi.call/cls_multi_ushort.c, + testsuite/libffi.call/cls_multi_ushortchar.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c, + testsuite/libffi.call/cls_schar.c, + testsuite/libffi.call/cls_sint.c, + testsuite/libffi.call/cls_sshort.c, + testsuite/libffi.call/cls_uchar.c, + testsuite/libffi.call/cls_uint.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/cls_ushort.c, + testsuite/libffi.call/err_bad_abi.c, + testsuite/libffi.call/err_bad_typedef.c, + testsuite/libffi.call/float2.c, + testsuite/libffi.call/huge_struct.c, + testsuite/libffi.call/nested_struct.c, + testsuite/libffi.call/nested_struct1.c, + testsuite/libffi.call/nested_struct10.c, + testsuite/libffi.call/nested_struct2.c, + testsuite/libffi.call/nested_struct3.c, + testsuite/libffi.call/nested_struct4.c, + testsuite/libffi.call/nested_struct5.c, + testsuite/libffi.call/nested_struct6.c, + testsuite/libffi.call/nested_struct7.c, + testsuite/libffi.call/nested_struct8.c, + testsuite/libffi.call/nested_struct9.c, + testsuite/libffi.call/problem1.c, + testsuite/libffi.call/return_ldl.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_large.c, + testsuite/libffi.call/stret_large2.c, + testsuite/libffi.call/stret_medium.c, + testsuite/libffi.call/stret_medium2.c, + testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead + of checking for MMAP. Use intptr_t instead of long casts. + +2009-06-04 Andrew Haley + + * src/powerpc/ffitarget.h: Fix misapplied merge from gcc. + +2009-06-04 Andrew Haley + + * src/mips/o32.S, + src/mips/n32.S: Fix licence formatting. + +2009-06-04 Andrew Haley + + * src/x86/darwin.S: Fix licence formatting. + src/x86/win32.S: Likewise. + src/sh64/sysv.S: Likewise. + src/sh/sysv.S: Likewise. + +2009-06-04 Andrew Haley + + * src/sh64/ffi.c: Remove lint directives. Was missing from merge + of Andreas Tobler's patch from 2006-04-22. + +2009-06-04 Andrew Haley + + * src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of + 2007-03-07. + +2008-12-26 Timothy Wall + + * testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected + failures on x86_64 cygwin/mingw. + +2008-12-22 Timothy Wall + + * testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/closure_loc_fn0.c, + testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c: use portable cast from + pointer to integer (intptr_t). + * testsuite/libffi.call/cls_longdouble.c: disable for win64. + +2008-12-19 Anthony Green + + * configure.ac: Bump version to 3.0.8. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-11-11 Anthony Green + + * configure.ac: Bump version to 3.0.7. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-08-25 Andreas Tobler + + * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and + FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. + Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. + Adjust copyright notice. + * src/powerpc/ffi.c: Add two new flags to indicate if we have one + register or two register to use for FFI_SYSV structs. + (ffi_prep_cif_machdep): Pass the right register flag introduced above. + (ffi_closure_helper_SYSV): Fix the return type for + FFI_SYSV_TYPE_SMALL_STRUCT. Comment. + Adjust copyright notice. + +2008-07-24 Anthony Green + + * testsuite/libffi.call/cls_dbls_struct.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c, + testsuite/libffi.call/err_bad_abi.c: Clean up failures from + compiler warnings. + +2008-07-17 Anthony Green + + * configure.ac: Bump version to 3.0.6. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. Add documentation. + * README: Update for new release. + +2008-07-16 Kaz Kojima + + * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned + int. + +2008-07-16 Kaz Kojima + + * src/sh/sysv.S: Add .note.GNU-stack on Linux. + * src/sh64/sysv.S: Likewise. + +2008-04-03 Anthony Green + + * libffi.pc.in (Libs): Add -L${libdir}. + * configure.ac: Bump version to 3.0.5. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-04-03 Anthony Green + Xerces Ranby + + * include/ffi.h.in: Wrap definition of target architecture to + protect from double definitions. + +2008-03-22 Moriyoshi Koizumi + + * src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in + closure_loc_fn0.c. + * testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0): + New test. + +2008-03-04 Anthony Green + Blake Chaffin + hos@tamanegi.org + + * testsuite/libffi.call/cls_align_longdouble_split2.c + testsuite/libffi.call/cls_align_longdouble_split.c + testsuite/libffi.call/cls_dbls_struct.c + testsuite/libffi.call/cls_double_va.c + testsuite/libffi.call/cls_longdouble.c + testsuite/libffi.call/cls_longdouble_va.c + testsuite/libffi.call/cls_pointer.c + testsuite/libffi.call/cls_pointer_stack.c + testsuite/libffi.call/err_bad_abi.c + testsuite/libffi.call/err_bad_typedef.c + testsuite/libffi.call/huge_struct.c + testsuite/libffi.call/stret_large2.c + testsuite/libffi.call/stret_large.c + testsuite/libffi.call/stret_medium2.c + testsuite/libffi.call/stret_medium.c: New tests from Apple. + +2008-02-26 Jakub Jelinek + Anthony Green + + * src/alpha/osf.S: Add .note.GNU-stack on Linux. + * src/s390/sysv.S: Likewise. + * src/powerpc/linux64.S: Likewise. + * src/powerpc/linux64_closure.S: Likewise. + * src/powerpc/ppc_closure.S: Likewise. + * src/powerpc/sysv.S: Likewise. + * src/x86/unix64.S: Likewise. + * src/x86/sysv.S: Likewise. + * src/sparc/v8.S: Likewise. + * src/sparc/v9.S: Likewise. + * src/m68k/sysv.S: Likewise. + * src/ia64/unix.S: Likewise. + * src/arm/sysv.S: Likewise. + +2008-02-26 Anthony Green + Thomas Heller + + * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C + comment. + +2008-02-26 Anthony Green + Thomas Heller + + * include/ffi.h.in: Change void (*)() to void (*)(void). + +2008-02-26 Anthony Green + Thomas Heller + + * src/alpha/ffi.c: Change void (*)() to void (*)(void). + src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c, + src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c, + src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S, + src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c, + src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c, + src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S, + src/x86/ffi64.c: Ditto. + +2008-02-24 Anthony Green + + * configure.ac: Accept openbsd*, not just openbsd. + Bump version to 3.0.4. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-02-22 Anthony Green + + * README: Clean up list of tested platforms. + +2008-02-22 Anthony Green + + * configure.ac: Bump version to 3.0.3. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. Clean up test docs. + +2008-02-22 Bjoern Koenig + Andreas Tobler + + * configure.ac: Add amd64-*-freebsd* target. + * configure: Regenerate. + +2008-02-22 Thomas Heller + + * configure.ac: Add x86 OpenBSD support. + * configure: Rebuilt. + +2008-02-21 Thomas Heller + + * README: Change "make test" to "make check". + +2008-02-21 Anthony Green + + * configure.ac: Bump version to 3.0.2. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-02-21 Björn König + + * src/x86/freebsd.S: New file. + * configure.ac: Add x86 FreeBSD support. + * Makefile.am: Ditto. + +2008-02-15 Anthony Green + + * configure.ac: Bump version to 3.0.1. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-02-15 David Daney + + * src/mips/ffi.c: Remove extra '>' from include directive. + (ffi_prep_closure_loc): Use clear_location instead of tramp. + +2008-02-15 Anthony Green + + * configure.ac: Bump version to 3.0.0. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + +2008-02-15 David Daney + + * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE): + Define (conditionally), and use it to include cachectl.h. + (ffi_prep_closure_loc): Fix cache flushing. + * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define. + +2008-02-15 Anthony Green + + * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3: + Update dates and remove all references to ffi_prep_closure. + * configure.ac: Bump version to 2.99.9. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + +2008-02-15 Anthony Green + + * man/ffi_prep_closure.3: Delete. + * man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3. + (man_MANS): Ditto. + * man/Makefile.in: Rebuilt. + * configure.ac: Bump version to 2.99.8. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + +2008-02-14 Anthony Green + + * configure.ac: Bump version to 2.99.7. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * include/ffi.h.in LICENSE src/debug.c src/closures.c + src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h + src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c + src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S + src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c + src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c + src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S + src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h + src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c + src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S + src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h + src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h + src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S + src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h + src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S + src/arm/ffitarget.h src/prep_cif.c: Update license text. + +2008-02-14 Anthony Green + + * README: Update tested platforms. + * configure.ac: Bump version to 2.99.6. + * configure: Rebuilt. + +2008-02-14 Anthony Green + + * configure.ac: Bump version to 2.99.5. + * configure: Rebuilt. + * Makefile.am (EXTRA_DIST): Add darwin64.S + * Makefile.in: Rebuilt. + * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree. + * LICENSE: Update WARRANTY. + +2008-02-14 Anthony Green + + * libffi.pc.in (libdir): Fix libdir definition. + * configure.ac: Bump version to 2.99.4. + * configure: Rebuilt. + +2008-02-14 Anthony Green + + * README: Update. + * libffi.info: New file. + * doc/stamp-vti: New file. + * configure.ac: Bump version to 2.99.3. + * configure: Rebuilt. + +2008-02-14 Anthony Green + + * Makefile.am (SUBDIRS): Add man dir. + * Makefile.in: Rebuilt. + * configure.ac: Create Makefile. + * configure: Rebuilt. + * man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3 + man/Makefile.am man/Makefile.in: New files. + +2008-02-14 Tom Tromey + + * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt. + * mdate-sh, texinfo.tex: New files. + * Makefile.am (info_TEXINFOS): New variable. + * doc/libffi.texi: New file. + * doc/version.texi: Likewise. + +2008-02-14 Anthony Green + + * Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET). + (lib_LTLIBRARIES): Define. + (toolexeclib_LIBRARIES): Undefine. + * Makefile.in: Rebuilt. + * configure.ac: Reset version to 2.99.1. + * configure.in: Rebuilt. + +2008-02-14 Anthony Green + + * libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@. + * configure.ac: Reset version to 2.99.1. + * configure.in: Rebuilt. + * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi. + * Makefile.in: Rebuilt. + * LICENSE: Update copyright notice. + +2008-02-14 Anthony Green + + * include/Makefile.am (nodist_includes_HEADERS): Define. Don't + distribute ffitarget.h or ffi.h from the build include dir. + * Makefile.in: Rebuilt. + +2008-02-14 Anthony Green + + * include/Makefile.am (includesdir): Install headers under libdir. + (pkgconfigdir): Define. Install libffi.pc. + * include/Makefile.in: Rebuilt. + * libffi.pc.in: Create. + * libtool-version: Increment CURRENT + * configure.ac: Add libffi.pc.in + * configure: Rebuilt. + +2008-02-03 Anthony Green + + * include/Makefile.am (includesdir): Fix header install with + DESTDIR. + * include/Makefile.in: Rebuilt. + +2008-02-03 Timothy Wall + + * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return + offset based on code pointer, not data pointer. + +2008-02-01 Anthony Green + + * include/Makefile.am: Fix header installs. + * Makefile.am: Ditto. + * include/Makefile.in: Rebuilt. + * Makefile.in: Ditto. + +2008-02-01 Anthony Green + + * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL, + FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last + patch. + +2008-01-31 Anthony Green + + * Makefile.am (EXTRA_DIST): Add missing files. + * testsuite/Makefile.am: Ditto. + * Makefile.in, testsuite/Makefile.in: Rebuilt. + +2008-01-31 Timothy Wall + + * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall + closures. + * src/x86/ffitarget.h: Increase size of trampoline for stdcall + closures. + * src/x86/win32.S: Add assembly for stdcall closure. + * src/x86/ffi.c: Initialize stdcall closure trampoline. + +2008-01-30 H.J. Lu + + PR libffi/34612 + * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when + returning struct. + + * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer" + tests. + +2008-01-30 Anthony Green + + * Makefile.am, include/Makefile.am: Move headers to + libffi_la_SOURCES for new automake. + * Makefile.in, include/Makefile.in: Rebuilt. + + * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for + execution outside of gcc tree. + * testsuite/lib/target-libpath.exp: Ditto. + + * testsuite/lib/libffi-dg.exp: Many changes to allow for execution + outside of gcc tree. + diff --git a/user/mpy/lib/libffi/ChangeLog.libffi-3.1 b/user/mpy/lib/libffi/ChangeLog.libffi-3.1 new file mode 100644 index 0000000..8f7f50d --- /dev/null +++ b/user/mpy/lib/libffi/ChangeLog.libffi-3.1 @@ -0,0 +1,6000 @@ +2014-03-16 Josh Triplett + + * ChangeLog: Archive to ChangeLog.libffi-3.1 and delete. Future + changelogs will come from git, with autogenerated snapshots shipped in + distributed tarballs. + +2014-03-16 Josh Triplett + + Add support for stdcall, thiscall, and fastcall on non-Windows + x86-32. + + Linux supports the stdcall calling convention, either via + functions explicitly declared with the stdcall attribute, or via + code compiled with -mrtd which effectively makes stdcall the + default. + + This introduces FFI_STDCALL, FFI_THISCALL, and FFI_FASTCALL on + non-Windows x86-32 platforms, as non-default calling conventions. + + * Makefile.am: Compile in src/x86/win32.S on non-Windows x86-32. + * src/x86/ffitarget.h: Add FFI_STDCALL, FFI_THISCALL, and + FFI_FASTCALL on non-Windows x86-32. Increase trampoline size to + accomodate these calling conventions, and unify some ifdeffery. + * src/x86/ffi.c: Add support for FFI_STDCALL, FFI_THISCALL, and + FFI_FASTCALL on non-Windows x86-32 platforms; update ifdeffery. + * src/x86/win32.S: Support compiling on non-Windows x86-32 + platforms. On those platforms, avoid redefining the SYSV symbols + already provided by src/x86/sysv.S. + * testsuite/libffi.call/closure_stdcall.c: Run on non-Windows. + #define __stdcall if needed. + * testsuite/libffi.call/closure_thiscall.c: Run on non-Windows. + #define __fastcall if needed. + * testsuite/libffi.call/fastthis1_win32.c: Run on non-Windows. + * testsuite/libffi.call/fastthis2_win32.c: Ditto. + * testsuite/libffi.call/fastthis3_win32.c: Ditto. + * testsuite/libffi.call/many2_win32.c: Ditto. + * testsuite/libffi.call/many_win32.c: Ditto. + * testsuite/libffi.call/strlen2_win32.c: Ditto. + * testsuite/libffi.call/strlen_win32.c: Ditto. + * testsuite/libffi.call/struct1_win32.c: Ditto. + * testsuite/libffi.call/struct2_win32.c: Ditto. + +2014-03-16 Josh Triplett + + * prep_cif.c: Remove unnecessary ifdef for X86_WIN32. + ffi_prep_cif_core had a special case for X86_WIN32, checking for + FFI_THISCALL in addition to the FFI_FIRST_ABI-to-FFI_LAST_ABI + range before returning FFI_BAD_ABI. However, on X86_WIN32, + FFI_THISCALL already falls in that range, making the special case + unnecessary. Remove it. + +2014-03-16 Josh Triplett + + * testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/closure_thiscall.c: Remove fragile stack + pointer checks. These files included inline assembly to save the + stack pointer before and after the call, and compare the values. + However, compilers can and do leave the stack in different states + for these two pieces of inline assembly, such as by saving a + temporary value on the stack across the call; observed with gcc + -Os, and verified as spurious through careful inspection of + disassembly. + +2014-03-16 Josh Triplett + + * testsuite/libffi.call/many.c: Avoid spurious failure due to + excess floating-point precision. + * testsuite/libffi.call/many_win32.c: Ditto. + +2014-03-16 Josh Triplett + + * libtool-ldflags: Re-add. + +2014-03-16 Josh Triplett + + * Makefile.in, aclocal.m4, compile, config.guess, config.sub, + configure, depcomp, include/Makefile.in, install-sh, + libtool-ldflags, ltmain.sh, m4/libtool.m4, m4/ltoptions.m4, + m4/ltsugar.m4, m4/ltversion.m4, m4/lt~obsolete.m4, + man/Makefile.in, mdate-sh, missing, testsuite/Makefile.in: Delete + autogenerated files from version control. + * .gitignore: Add autogenerated files. + * autogen.sh: New script to generate the autogenerated files. + * README: Document requirement to run autogen.sh when building + directly from version control. + * .travis.yml: Run autogen.sh + +2014-03-14 Anthony Green + + * configure, Makefile.in: Rebuilt. + +2014-03-10 Mike Hommey + + * configure.ac: Allow building for mipsel with Android NDK r8. + * Makefile.am (AM_MAKEFLAGS): Replace double quotes with single + quotes. + +2014-03-10 Landry Breuil + + * configure.ac: Ensure the linker supports @unwind sections in libffi. + +2014-03-01 Anthony Green + + * Makefile.am (EXTRA_DIST): Replace old scripts with + generate-darwin-source-and-headers.py. + * Makefile.in: Rebuilt. + +2014-02-28 Anthony Green + + * Makefile.am (AM_CFLAGS): Reintroduce missing -DFFI_DEBUG for + --enable-debug builds. + * Makefile.in: Rebuilt. + +2014-02-28 Makoto Kato + + * src/closures.c: Fix build failure when using clang for Android. + +2014-02-28 Marcin Wojdyr + + * libffi.pc.in (toolexeclibdir): use -L${toolexeclibdir} instead + of -L${libdir}. + +2014-02-28 Paulo Pizarro + + * src/bfin/sysv.S: Calling functions in shared libraries requires + considering the GOT. + +2014-02-28 Josh Triplett + + * src/x86/ffi64.c (classify_argument): Handle case where + FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE. + +2014-02-28 Anthony Green + + * ltmain.sh: Generate with libtool-2.4.2.418. + * m4/libtool.m4, m4/ltoptions.m4, m4/ltversion.m4: Ditto. + * configure: Rebuilt. + +2014-02-28 Dominik Vogt + + * configure.ac (AC_ARG_ENABLE struct): Fix typo in help + message. + (AC_ARG_ENABLE raw_api): Ditto. + * configure, fficonfig.h.in: Rebuilt. + +2014-02-28 Will Newton + + * src/arm/sysv.S: Initialize IP register with FP. + +2014-02-28 Yufeng Zhang + + * src/aarch64/sysv.S (ffi_closure_SYSV): Use x29 as the + main CFA reg; update cfi_rel_offset. + +2014-02-15 Marcus Comstedt + + * src/powerpc/ffi_linux64.c, src/powerpc/linux64_closure.S: Remove + assumption on contents of r11 in closure. + +2014-02-09 Heiher + + * src/mips/n32.S: Fix call floating point va function. + +2014-01-21 Zachary Waldowski + + * src/aarch64/ffi.c: Fix missing semicolons on assertions under + debug mode. + +2013-12-30 Zachary Waldowski + + * .gitignore: Exclude darwin_* generated source and build_* trees. + * src/aarch64/ffi.c, src/arm/ffi.c, src/x86/ffi.c: Inhibit Clang + previous prototype warnings. + * src/arm/ffi.c: Prevent NULL dereference, fix short type warning + * src/dlmalloc.c: Fix warnings from set_segment_flags return type, + and the native use of size_t for malloc on platforms + * src/arm/sysv.S: Use unified syntax. Clang clean-ups for + ARM_FUNC_START. + * generate-osx-source-and-headers.py: Remove. + * build-ios.sh: Remove. + * libffi.xcodeproj/project.pbxproj: Rebuild targets. Include + x86_64+aarch64 pieces in library. Export headers properly. + * src/x86/ffi64.c: More Clang warning clean-ups. + * src/closures.c (open_temp_exec_file_dir): Use size_t. + * src/prep_cif.c (ffi_prep_cif_core): Cast ALIGN result. + * src/aarch64/sysv.S: Use CNAME for global symbols. Only use + .size for ELF targets. + * src/aarch64/ffi.c: Clean up for double == long double. Clean up + from Clang warnings. Use Clang cache invalidation builtin. Use + size_t in place of unsigned in many places. Accommodate for + differences in Apple AArch64 ABI. + +2013-12-02 Daniel Rodríguez Troitiño + + * generate-darwin-source-and-headers.py: Clean up, modernize, + merged version of previous scripts. + +2013-11-21 Anthony Green + + * configure, Makefile.in, include/Makefile.in, include/ffi.h.in, + man/Makefile.in, testsuite/Makefile.in, fficonfig.h.in: Rebuilt. + +2013-11-21 Alan Modra + + * Makefile.am (EXTRA_DIST): Add new src/powerpc files. + (nodist_libffi_la_SOURCES ): Likewise. + * configure.ac (HAVE_LONG_DOUBLE_VARIANT): Define for powerpc. + * include/ffi.h.in (ffi_prep_types): Declare. + * src/prep_cif.c (ffi_prep_cif_core): Call ffi_prep_types. + * src/types.c (FFI_NONCONST_TYPEDEF): Define and use for + HAVE_LONG_DOUBLE_VARIANT. + * src/powerpc/ffi_powerpc.h: New file. + * src/powerpc/ffi.c: Split into.. + * src/powerpc/ffi_sysv.c: ..new file, and.. + * src/powerpc/ffi_linux64.c: ..new file, rewriting parts. + * src/powerpc/ffitarget.h (enum ffi_abi): Rewrite powerpc ABI + selection as bits controlling features. + * src/powerpc/linux64.S: For consistency, use POWERPC64 rather + than __powerpc64__. + * src/powerpc/linux64_closure.S: Likewise. + * src/powerpc/ppc_closure.S: Likewise. Move .note.FNU-stack + inside guard. + * src/powerpc/sysv.S: Likewise. + * configure: Regenerate. + * fficonfig.h.in: Regenerate. + * Makefile.in: Regenerate. + +2013-11-20 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use + NUM_FPR_ARG_REGISTERS64 and NUM_GPR_ARG_REGISTERS64 not their + 32-bit versions for 64-bit code. + * src/powerpc/linux64_closure.S: Don't use the return value area + as a parameter save area on ELFv2. + +2013-11-18 Iain Sandoe + + * src/powerpc/darwin.S (EH): Correct use of pcrel FDE encoding. + * src/powerpc/darwin_closure.S (EH): Likewise. Modernise picbase + labels. + +2013-11-18 Anthony Green + + * src/arm/ffi.c (ffi_call): Hoist declaration of temp to top of + function. + * src/arm/ffi.c (ffi_closure_inner): Moderize function declaration + to appease compiler. + Thanks for Gregory P. Smith . + +2013-11-18 Anthony Green + + * README (tested): Mention PowerPC ELFv2. + +2013-11-16 Alan Modra + + * src/powerpc/ppc_closure.S: Move errant #endif to where it belongs. + Don't bl .Luint128. + +2013-11-16 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use #if _CALL_ELF + test to select parameter save sizing for ELFv2 vs. ELFv1. + * src/powerpc/ffitarget.h (FFI_V2_TYPE_FLOAT_HOMOG, + FFI_V2_TYPE_DOUBLE_HOMOG, FFI_V2_TYPE_SMALL_STRUCT): Define. + (FFI_TRAMPOLINE_SIZE): Define variant for ELFv2. + * src/powerpc/ffi.c (FLAG_ARG_NEEDS_PSAVE): Define. + (discover_homogeneous_aggregate): New function. + (ffi_prep_args64): Adjust start of param save area for ELFv2. + Handle homogenous floating point struct parms. + (ffi_prep_cif_machdep_core): Adjust space calculation for ELFv2. + Handle ELFv2 return values. Set FLAG_ARG_NEEDS_PSAVE. Handle + homogenous floating point structs. + (ffi_call): Increase size of smst_buffer for ELFv2. Handle ELFv2. + (flush_icache): Compile for ELFv2. + (ffi_prep_closure_loc): Set up ELFv2 trampoline. + (ffi_closure_helper_LINUX64): Don't return all structs directly + to caller. Handle homogenous floating point structs. Handle + ELFv2 struct return values. + * src/powerpc/linux64.S (ffi_call_LINUX64): Set up r2 for + ELFv2. Adjust toc save location. Call function pointer using + r12. Handle FLAG_RETURNS_SMST. Don't predict branches. + * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Set up r2 + for ELFv2. Define ELFv2 versions of STACKFRAME, PARMSAVE, and + RETVAL. Handle possibly missing parameter save area. Handle + ELFv2 return values. + (.note.GNU-stack): Move inside outer #ifdef. + +2013-11-16 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_cif_machdep): Revert 2013-02-08 + change. Do not consume an int arg when returning a small struct + for FFI_SYSV ABI. + (ffi_call): Only use bounce buffer when FLAG_RETURNS_SMST. + Properly copy bounce buffer to destination. + * src/powerpc/sysv.S: Revert 2013-02-08 change. + * src/powerpc/ppc_closure.S: Remove stray '+'. + +2013-11-16 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_args64): Align struct parameters + according to __STRUCT_PARM_ALIGN__. + (ffi_prep_cif_machdep_core): Likewise. + (ffi_closure_helper_LINUX64): Likewise. + +2013-11-16 Alan Modra + + * src/powerpc/linux64.S (ffi_call_LINUX64): Tweak restore of r28. + (.note.GNU-stack): Move inside outer #ifdef. + * src/powerpc/linux64_closure.S (STACKFRAME, PARMSAVE, + RETVAL): Define and use throughout. + (ffi_closure_LINUX64): Save fprs before buying stack. + (.note.GNU-stack): Move inside outer #ifdef. + +2013-11-16 Alan Modra + + * src/powerpc/ffitarget.h (FFI_TARGET_SPECIFIC_VARIADIC): Define. + (FFI_EXTRA_CIF_FIELDS): Define. + * src/powerpc/ffi.c (ffi_prep_args64): Save fprs as per the + ABI, not to both fpr and param save area. + (ffi_prep_cif_machdep_core): Renamed from ffi_prep_cif_machdep. + Keep initial flags. Formatting. Remove dead FFI_LINUX_SOFT_FLOAT + code. + (ffi_prep_cif_machdep, ffi_prep_cif_machdep_var): New functions. + (ffi_closure_helper_LINUX64): Pass floating point as per ABI, + not to both fpr and parameter save areas. + + * libffi/testsuite/libffi.call/cls_double_va.c (main): Correct + function cast and don't call ffi_prep_cif. + * libffi/testsuite/libffi.call/cls_longdouble_va.c (main): Likewise. + +2013-11-15 Andrew Haley + + * doc/libffi.texi (Closure Example): Fix the sample code. + * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt. + +2013-11-15 Andrew Haley + + * testsuite/libffi.call/va_struct1.c (main): Fix broken test. + * testsuite/libffi.call/cls_uint_va.c (cls_ret_T_fn): Likewise + * testsuite/libffi.call/cls_struct_va1.c (test_fn): Likewise. + * testsuite/libffi.call/va_1.c (main): Likewise. + +2013-11-14 David Schneider + + * src/arm/ffi.c: Fix register allocation for mixed float and + doubles. + * testsuite/libffi.call/cls_many_mixed_float_double.c: Testcase + for many mixed float and double arguments. + +2013-11-13 Alan Modra + + * doc/libffi.texi (Simple Example): Correct example code. + * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt. + +2013-11-13 Anthony Green + + * include/ffi_common.h: Respect HAVE_ALLOCA_H for GNU compiler + based build. (Thanks to tmr111116 on github) + +2013-11-09 Anthony Green + + * m4/libtool.m4: Refresh. + * configure, Makefile.in: Rebuilt. + * README: Add more notes about next release. + +2013-11-09 Shigeharu TAKENO + + * m4/ax_gcc_archflag.m4 (ax_gcc_arch): Don't recognize + UltraSPARC-IIi as ultrasparc3. + +2013-11-06 Mark Kettenis + + * src/x86/freebsd.S (ffi_call_SYSV): Align the stack pointer to + 16-bytes. + +2013-11-06 Konstantin Belousov + + * src/x86/freebsd.S (ffi_closure_raw_SYSV): Mark the assembler + source as not requiring executable stack. + +2013-11-02 Anthony Green + + * doc/libffi.texi (The Basics): Clarify return value buffer size + requirements. Also, NULL result buffer pointers are no longer + supported. + * doc/libffi.info: Rebuilt. + +2013-11-02 Mischa Jonker + + * Makefile.am (nodist_libffi_la_SOURCES): Fix build error. + * Makefile.in: Rebuilt. + +2013-11-02 David Schneider + + * src/arm/ffi.c: more robust argument handling for closures on arm hardfloat + * testsuite/libffi.call/many_mixed.c: New file. + * testsuite/libffi.call/cls_many_mixed_args.c: More tests. + +2013-11-02 Vitaly Budovski + + * src/x86/ffi.c (ffi_prep_cif_machdep): Don't align stack for win32. + +2013-10-23 Mark H Weaver + + * src/mips/ffi.c: Fix handling of uint32_t arguments on the + MIPS N32 ABI. + +2013-10-13 Sandra Loosemore + + * README: Add Nios II to table of supported platforms. + * Makefile.am (EXTRA_DIST): Add nios2 files. + (nodist_libffi_la_SOURCES): Likewise. + * Makefile.in: Regenerated. + * configure.ac (nios2*-linux*): New host. + (NIOS2): Add AM_CONDITIONAL. + * configure: Regenerated. + * src/nios2/ffi.c: New. + * src/nios2/ffitarget.h: New. + * src/nios2/sysv.S: New. + * src/prep_cif.c (initialize_aggregate): Handle extra structure + alignment via FFI_AGGREGATE_ALIGNMENT. + (ffi_prep_cif_core): Conditionalize structure return for NIOS2. + +2013-10-10 Sandra Loosemore + + * testsuite/libffi.call/cls_many_mixed_args.c (cls_ret_double_fn): + Fix uninitialized variable. + +2013-10-11 Marcus Shawcroft + + * testsuite/libffi.call/many.c (many): Replace * with +. + +2013-10-08 Ondřej Bílka + + * src/aarch64/ffi.c, src/aarch64/sysv.S, src/arm/ffi.c, + src/arm/gentramp.sh, src/bfin/sysv.S, src/closures.c, + src/dlmalloc.c, src/ia64/ffi.c, src/microblaze/ffi.c, + src/microblaze/sysv.S, src/powerpc/darwin_closure.S, + src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/sh/ffi.c, + src/tile/tile.S, testsuite/libffi.call/nested_struct11.c: Fix + spelling errors. + +2013-10-08 Anthony Green + + * aclocal.m4, compile, config.guess, config.sub, depcomp, + install-sh, mdate-sh, missing, texinfo.tex: Update from upstream. + * configure.ac: Update version to 3.0.14-rc0. + * Makefile.in, configure, Makefile.in, include/Makefile.in, + man/Makefile.in, testsuite/Makefile.in: Rebuilt. + * README: Mention M88K and VAX. + +2013-07-15 Miod Vallat + + * Makefile.am, + configure.ac, + src/m88k/ffi.c, + src/m88k/ffitarget.h, + src/m88k/obsd.S, + src/vax/elfbsd.S, + src/vax/ffi.c, + src/vax/ffitarget.h: Add m88k and vax support. + +2013-06-24 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Move var declaration + before statements. + (ffi_prep_args64): Support little-endian. + (ffi_closure_helper_SYSV, ffi_closure_helper_LINUX64): Likewise. + * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise. + * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Likewise. + +2013-06-12 Mischa Jonker + + * configure.ac: Add support for ARC. + * Makefile.am: Likewise. + * README: Add ARC details. + * src/arc/arcompact.S: New. + * src/arc/ffi.c: Likewise. + * src/arc/ffitarget.h: Likewise. + +2013-03-28 David Schneider + + * src/arm/ffi.c: Fix support for ARM hard-float calling convention. + * src/arm/sysv.S: call different methods for SYSV and VFP ABIs. + * testsuite/libffi.call/cls_many_mixed_args.c: testcase for a closure with + mixed arguments, many doubles. + * testsuite/libffi.call/many_double.c: testcase for calling a function using + more than 8 doubles. + * testcase/libffi.call/many.c: use absolute value to check result against an + epsilon + +2013-03-17 Anthony Green + + * README: Update for 3.0.13. + * configure.ac: Ditto. + * configure: Rebuilt. + * doc/*: Update version. + +2013-03-17 Dave Korn + + * src/closures.c (is_emutramp_enabled + [!FFI_MMAP_EXEC_EMUTRAMP_PAX]): Move default definition outside + enclosing #if scope. + +2013-03-17 Anthony Green + + * configure.ac: Only modify toolexecdir in certain cases. + * configure: Rebuilt. + +2013-03-16 Gilles Talis + + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Don't use + fparg_count,etc on __NO_FPRS__ targets. + +2013-03-16 Alan Hourihane + + * src/m68k/sysv.S (epilogue): Don't use extb instruction on + m680000 machines. + +2013-03-16 Alex Gaynor + + * src/x86/ffi.c (ffi_prep_cif_machdep): Always align stack. + +2013-03-13 Markos Chandras + + * configure.ac: Add support for Imagination Technologies Meta. + * Makefile.am: Likewise. + * README: Add Imagination Technologies Meta details. + * src/metag/ffi.c: New. + * src/metag/ffitarget.h: Likewise. + * src/metag/sysv.S: Likewise. + +2013-02-24 Andreas Schwab + + * doc/libffi.texi (Structures): Fix missing category argument of + @deftp. + +2013-02-11 Anthony Green + + * configure.ac: Update release number to 3.0.12. + * configure: Rebuilt. + * README: Update release info. + +2013-02-10 Anthony Green + + * README: Add Moxie. + * src/moxie/ffi.c: Created. + * src/moxie/eabi.S: Created. + * src/moxie/ffitarget.h: Created. + * Makefile.am (nodist_libffi_la_SOURCES): Add Moxie. + * Makefile.in: Rebuilt. + * configure.ac: Add Moxie. + * configure: Rebuilt. + * testsuite/libffi.call/huge_struct.c: Disable format string + warnings for moxie*-*-elf tests. + +2013-02-10 Anthony Green + + * Makefile.am (LTLDFLAGS): Fix reference. + * Makefile.in: Rebuilt. + +2013-02-10 Anthony Green + + * README: Update supported platforms. Update test results link. + +2013-02-09 Anthony Green + + * testsuite/libffi.call/negint.c: Remove forced -O2. + * testsuite/libffi.call/many2.c (foo): Remove GCCism. + * testsuite/libffi.call/ffitest.h: Add default PRIuPTR definition. + + * src/sparc/v8.S (ffi_closure_v8): Import ancient ulonglong + closure return type fix developed by Martin v. Löwis for cpython + fork. + +2013-02-08 Andreas Tobler + + * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix small struct + support. + * src/powerpc/sysv.S: Ditto. + +2013-02-08 Anthony Green + + * testsuite/libffi.call/cls_longdouble.c: Remove xfail for + arm*-*-*. + +2013-02-08 Anthony Green + + * src/sparc/ffi.c (ffi_prep_closure_loc): Fix cache flushing for GCC. + +2013-02-08 Matthias Klose + + * man/ffi_prep_cif.3: Clean up for debian linter. + +2013-02-08 Peter Bergner + + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Account for FP args pushed + on the stack. + +2013-02-08 Anthony Green + + * Makefile.am (EXTRA_DIST): Add missing files. + * testsuite/Makefile.am (EXTRA_DIST): Ditto. + * Makefile.in: Rebuilt. + +2013-02-08 Anthony Green + + * configure.ac: Move sparc asm config checks to within functions + for compatibility with sun tools. + * configure: Rebuilt. + * src/sparc/ffi.c (ffi_prep_closure_loc): Flush cache on v9 + systems. + * src/sparc/v8.S (ffi_flush_icache): Implement a sparc v9 cache + flusher. + +2013-02-08 Nathan Rossi + + * src/microblaze/ffi.c (ffi_closure_call_SYSV): Fix handling of + small big-endian structures. + (ffi_prep_args): Ditto. + +2013-02-07 Anthony Green + + * src/sparc/v8.S (ffi_call_v8): Fix typo from last patch + (effectively hiding ffi_call_v8). + +2013-02-07 Anthony Green + + * configure.ac: Update bug reporting address. + * configure.in: Rebuild. + + * src/sparc/v8.S (ffi_flush_icache): Out-of-line cache flusher for + Sun compiler. + * src/sparc/ffi.c (ffi_call): Remove warning. + Call ffi_flush_icache for non-GCC builds. + (ffi_prep_closure_loc): Use ffi_flush_icache. + + * Makefile.am (EXTRA_DIST): Add libtool-ldflags. + * Makefile.in: Rebuilt. + * libtool-ldflags: New file. + +2013-02-07 Daniel Schepler + + * configure.ac: Correctly identify x32 systems as 64-bit. + * m4/libtool.m4: Remove libtool expr error. + * aclocal.m4, configure: Rebuilt. + +2013-02-07 Anthony Green + + * configure.ac: Fix GCC usage test. + * configure: Rebuilt. + * README: Mention LLVM/GCC x86_64 issue. + * testsuite/Makefile.in: Rebuilt. + +2013-02-07 Anthony Green + + * testsuite/libffi.call/cls_double_va.c (main): Replace // style + comments with /* */ for xlc compiler. + * testsuite/libffi.call/stret_large.c (main): Ditto. + * testsuite/libffi.call/stret_large2.c (main): Ditto. + * testsuite/libffi.call/nested_struct1.c (main): Ditto. + * testsuite/libffi.call/huge_struct.c (main): Ditto. + * testsuite/libffi.call/float_va.c (main): Ditto. + * testsuite/libffi.call/cls_struct_va1.c (main): Ditto. + * testsuite/libffi.call/cls_pointer_stack.c (main): Ditto. + * testsuite/libffi.call/cls_pointer.c (main): Ditto. + * testsuite/libffi.call/cls_longdouble_va.c (main): Ditto. + +2013-02-06 Anthony Green + + * man/ffi_prep_cif.3: Clean up for debian lintian checker. + +2013-02-06 Anthony Green + + * Makefile.am (pkgconfigdir): Add missing pkgconfig install bits. + * Makefile.in: Rebuild. + +2013-02-02 Mark H Weaver + + * src/x86/ffi64.c (ffi_call): Sign-extend integer arguments passed + via general purpose registers. + +2013-01-21 Nathan Rossi + + * README: Add MicroBlaze details. + * Makefile.am: Add MicroBlaze support. + * configure.ac: Likewise. + * src/microblaze/ffi.c: New. + * src/microblaze/ffitarget.h: Likewise. + * src/microblaze/sysv.S: Likewise. + +2013-01-21 Nathan Rossi + * testsuite/libffi.call/return_uc.c: Fixed issue. + +2013-01-21 Chris Zankel + + * README: Add Xtensa support. + * Makefile.am: Likewise. + * configure.ac: Likewise. + * Makefile.in Regenerate. + * configure: Likewise. + * src/prep_cif.c: Handle Xtensa. + * src/xtensa: New directory. + * src/xtensa/ffi.c: New file. + * src/xtensa/ffitarget.h: Ditto. + * src/xtensa/sysv.S: Ditto. + +2013-01-11 Anthony Green + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Replace // style + comments with /* */ for xlc compiler. + * src/powerpc/aix.S (ffi_call_AIX): Ditto. + * testsuite/libffi.call/ffitest.h (allocate_mmap): Delete + deprecated inline function. + * testsuite/libffi.special/ffitestcxx.h: Ditto. + * README: Add update for AIX support. + +2013-01-11 Anthony Green + + * configure.ac: Robustify pc relative reloc check. + * m4/ax_cc_maxopt.m4: Don't -malign-double. This is an ABI + changing option for 32-bit x86. + * aclocal.m4, configure: Rebuilt. + * README: Update supported target list. + +2013-01-10 Anthony Green + + * README (tested): Add Compiler column to table. + +2013-01-10 Anthony Green + + * src/x86/ffi64.c (struct register_args): Make sse array and array + of unions for sunpro compiler compatibility. + +2013-01-10 Anthony Green + + * configure.ac: Test target platform size_t size. Handle both 32 + and 64-bit builds for x86_64-* and i?86-* targets (allowing for + CFLAG option to change default settings). + * configure, aclocal.m4: Rebuilt. + +2013-01-10 Anthony Green + + * testsuite/libffi.special/special.exp: Only run exception + handling tests when using GNU compiler. + + * m4/ax_compiler_vendor.m4: New file. + * configure.ac: Test for compiler vendor and don't use + AX_CFLAGS_WARN_ALL with the sun compiler. + * aclocal.m4, configure: Rebuilt. + +2013-01-10 Anthony Green + + * include/ffi_common.h: Don't use GCCisms to define types when + building with the SUNPRO compiler. + +2013-01-10 Anthony Green + + * configure.ac: Put local.exp in the right place. + * configure: Rebuilt. + + * src/x86/ffi.c: Update comment about regparm function attributes. + * src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires + that all function arguments be passed on the stack (no regparm + support). + +2013-01-08 Anthony Green + + * configure.ac: Generate local.exp. This sets CC_FOR_TARGET + when we are using the vendor compiler. + * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): Point to + ../local.exp. + * configure, testsuite/Makefile.in: Rebuilt. + + * testsuite/libffi.call/call.exp: Run tests with different + options, depending on whether or not we are using gcc or the + vendor compiler. + * testsuite/lib/libffi.exp (libffi-init): Set using_gcc based on + whether or not we are building/testing with gcc. + +2013-01-08 Anthony Green + + * configure.ac: Switch x86 solaris target to X86 by default. + * configure: Rebuilt. + +2013-01-08 Anthony Green + + * configure.ac: Fix test for read-only eh_frame. + * configure: Rebuilt. + +2013-01-08 Anthony Green + + * src/x86/sysv.S, src/x86/unix64.S: Only emit DWARF unwind info + when building with the GNU toolchain. + * testsuite/libffi.call/ffitest.h (CHECK): Fix for Solaris vendor + compiler. + +2013-01-07 Thorsten Glaser + + * testsuite/libffi.call/cls_uchar_va.c, + testsuite/libffi.call/cls_ushort_va.c, + testsuite/libffi.call/va_1.c: Testsuite fixes. + +2013-01-07 Thorsten Glaser + + * src/m68k/ffi.c (CIF_FLAGS_SINT8, CIF_FLAGS_SINT16): Define. + (ffi_prep_cif_machdep): Fix 8-bit and 16-bit signed calls. + * src/m68k/sysv.S (ffi_call_SYSV, ffi_closure_SYSV): Ditto. + +2013-01-04 Anthony Green + + * Makefile.am (AM_CFLAGS): Don't automatically add -fexceptions + and -Wall. This is set in the configure script after testing for + GCC. + * Makefile.in: Rebuilt. + +2013-01-02 rofl0r + + * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix build error on ppc + when long double == double. + +2013-01-02 Reini Urban + + * Makefile.am (libffi_la_LDFLAGS): Add -no-undefined to LDFLAGS + (required for shared libs on cygwin/mingw). + * Makefile.in: Rebuilt. + +2012-10-31 Alan Modra + + * src/powerpc/linux64_closure.S: Add new ABI support. + * src/powerpc/linux64.S: Likewise. + +2012-10-30 Magnus Granberg + Pavel Labushev + + * configure.ac: New options pax_emutramp + * configure, fficonfig.h.in: Regenerated + * src/closures.c: New function emutramp_enabled_check() and + checks. + +2012-10-30 Frederick Cheung + + * configure.ac: Enable FFI_MAP_EXEC_WRIT for Darwin 12 (mountain + lion) and future version. + * configure: Rebuild. + +2012-10-30 James Greenhalgh + Marcus Shawcroft + + * README: Add details of aarch64 port. + * src/aarch64/ffi.c: New. + * src/aarch64/ffitarget.h: Likewise. + * src/aarch64/sysv.S: Likewise. + * Makefile.am: Support aarch64. + * configure.ac: Support aarch64. + * Makefile.in, configure: Rebuilt. + +2012-10-30 James Greenhalgh + Marcus Shawcroft + + * testsuite/lib/libffi.exp: Add support for aarch64. + * testsuite/libffi.call/cls_struct_va1.c: New. + * testsuite/libffi.call/cls_uchar_va.c: Likewise. + * testsuite/libffi.call/cls_uint_va.c: Likewise. + * testsuite/libffi.call/cls_ulong_va.c: Likewise. + * testsuite/libffi.call/cls_ushort_va.c: Likewise. + * testsuite/libffi.call/nested_struct11.c: Likewise. + * testsuite/libffi.call/uninitialized.c: Likewise. + * testsuite/libffi.call/va_1.c: Likewise. + * testsuite/libffi.call/va_struct1.c: Likewise. + * testsuite/libffi.call/va_struct2.c: Likewise. + * testsuite/libffi.call/va_struct3.c: Likewise. + +2012-10-12 Walter Lee + + * Makefile.am: Add TILE-Gx/TILEPro support. + * configure.ac: Likewise. + * Makefile.in: Regenerate. + * configure: Likewise. + * src/prep_cif.c (ffi_prep_cif_core): Handle TILE-Gx/TILEPro. + * src/tile: New directory. + * src/tile/ffi.c: New file. + * src/tile/ffitarget.h: Ditto. + * src/tile/tile.S: Ditto. + +2012-10-12 Matthias Klose + + * generate-osx-source-and-headers.py: Normalize whitespace. + +2012-09-14 David Edelsohn + + * configure: Regenerated. + +2012-08-26 Andrew Pinski + + PR libffi/53014 + * src/mips/ffi.c (ffi_prep_closure_loc): Allow n32 with soft-float and n64 with + soft-float. + +2012-08-08 Uros Bizjak + + * src/s390/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, + just return FFI_BAD_ABI when things are wrong. + +2012-07-18 H.J. Lu + + PR libffi/53982 + PR libffi/53973 + * src/x86/ffitarget.h: Check __ILP32__ instead of __LP64__ for x32. + (FFI_SIZEOF_JAVA_RAW): Defined to 4 for x32. + +2012-05-16 H.J. Lu + + * configure: Regenerated. + +2012-05-05 Nicolas Lelong + + * libffi.xcodeproj/project.pbxproj: Fixes. + * README: Update for iOS builds. + +2012-04-23 Alexandre Keunecke I. de Mendonca + + * configure.ac: Add Blackfin/sysv support + * Makefile.am: Add Blackfin/sysv support + * src/bfin/ffi.c: Add Blackfin/sysv support + * src/bfin/ffitarget.h: Add Blackfin/sysv support + +2012-04-11 Anthony Green + + * Makefile.am (EXTRA_DIST): Add new script. + * Makefile.in: Rebuilt. + +2012-04-11 Zachary Waldowski + + * generate-ios-source-and-headers.py, + libffi.xcodeproj/project.pbxproj: Support a Mac static library via + Xcode. Set iOS compatibility to 4.0. Move iOS trampoline + generation into an Xcode "run script" phase. Include both as + Xcode build scripts. Don't always regenerate config files. + +2012-04-10 Anthony Green + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Add missing semicolon. + +2012-04-06 Anthony Green + + * Makefile.am (EXTRA_DIST): Add new iOS/xcode files. + * Makefile.in: Rebuilt. + +2012-04-06 Mike Lewis + + * generate-ios-source-and-headers.py: New file. + * libffi.xcodeproj/project.pbxproj: New file. + * README: Update instructions on building iOS binary. + * build-ios.sh: Delete. + +2012-04-06 Anthony Green + + * src/x86/ffi64.c (UINT128): Define differently for Intel and GNU + compilers, then use it. + +2012-04-06 H.J. Lu + + * m4/libtool.m4 (_LT_ENABLE_LOCK): Support x32. + +2012-04-06 Anthony Green + + * testsuite/Makefile.am (EXTRA_DIST): Add missing test cases. + * testsuite/Makefile.in: Rebuilt. + +2012-04-05 Zachary Waldowski + + * include/ffi.h.in: Add missing trampoline table fields. + * src/arm/sysv.S: Fix ENTRY definition, and wrap symbol references + in CNAME. + * src/x86/ffi.c: Wrap Windows specific code in ifdefs. + +2012-04-02 Peter Bergner + + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Declare double_tmp. + Silence casting pointer to integer of different size warning. + Delete goto to previously deleted label. + (ffi_call): Silence possibly undefined warning. + (ffi_closure_helper_SYSV): Declare variable type. + +2012-04-02 Peter Rosin + + * src/x86/win32.S (ffi_call_win32): Sign/zero extend the return + value in the Intel version as is already done for the AT&T version. + (ffi_closure_SYSV): Likewise. + (ffi_closure_raw_SYSV): Likewise. + (ffi_closure_STDCALL): Likewise. + +2012-03-29 Peter Rosin + + * src/x86/win32.S (ffi_closure_raw_THISCALL): Unify the frame + generation, fix the ENDP label and remove the surplus third arg + from the 'lea' insn. + +2012-03-29 Peter Rosin + + * src/x86/win32.S (ffi_closure_raw_SYSV): Make the 'stubraw' label + visible outside the PROC, so that ffi_closure_raw_THISCALL can see + it. Also instruct the assembler to add a frame to the function. + +2012-03-23 Peter Rosin + + * Makefile.am (AM_CPPFLAGS): Add -DFFI_BUILDING. + * Makefile.in: Rebuilt. + * include/ffi.h.in [MSVC]: Add __declspec(dllimport) decorations + to all data exports, when compiling libffi clients using MSVC. + +2012-03-29 Peter Rosin + + * src/x86/ffitarget.h (ffi_abi): Add new ABI FFI_MS_CDECL and + make it the default for MSVC. + (FFI_TYPE_MS_STRUCT): New structure return convention. + * src/x86/ffi.c (ffi_prep_cif_machdep): Tweak the structure + return convention for FFI_MS_CDECL to be FFI_TYPE_MS_STRUCT + instead of an ordinary FFI_TYPE_STRUCT. + (ffi_prep_args): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT. + (ffi_call): Likewise. + (ffi_prep_incoming_args_SYSV): Likewise. + (ffi_raw_call): Likewise. + (ffi_prep_closure_loc): Treat FFI_MS_CDECL as FFI_SYSV. + * src/x86/win32.S (ffi_closure_SYSV): For FFI_TYPE_MS_STRUCT, + return a pointer to the result structure in eax and don't pop + that pointer from the stack, the caller takes care of it. + (ffi_call_win32): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT. + (ffi_closure_raw_SYSV): Likewise. + +2012-03-22 Peter Rosin + + * testsuite/libffi.call/closure_stdcall.c [MSVC]: Add inline + assembly version with Intel syntax. + * testsuite/libffi.call/closure_thiscall.c [MSVC]: Likewise. + +2012-03-23 Peter Rosin + + * testsuite/libffi.call/ffitest.h: Provide abstration of + __attribute__((fastcall)) in the form of a __FASTCALL__ + define. Define it to __fastcall for MSVC. + * testsuite/libffi.call/fastthis1_win32.c: Use the above. + * testsuite/libffi.call/fastthis2_win32.c: Likewise. + * testsuite/libffi.call/fastthis3_win32.c: Likewise. + * testsuite/libffi.call/strlen2_win32.c: Likewise. + * testsuite/libffi.call/struct1_win32.c: Likewise. + * testsuite/libffi.call/struct2_win32.c: Likewise. + +2012-03-22 Peter Rosin + + * src/x86/win32.S [MSVC] (ffi_closure_THISCALL): Remove the manual + frame on function entry, MASM adds one automatically. + +2012-03-22 Peter Rosin + + * testsuite/libffi.call/ffitest.h [MSVC]: Add kludge for missing + bits in the MSVC headers. + +2012-03-22 Peter Rosin + + * testsuite/libffi.call/cls_12byte.c: Adjust to the C89 style + with no declarations after statements. + * testsuite/libffi.call/cls_16byte.c: Likewise. + * testsuite/libffi.call/cls_18byte.c: Likewise. + * testsuite/libffi.call/cls_19byte.c: Likewise. + * testsuite/libffi.call/cls_1_1byte.c: Likewise. + * testsuite/libffi.call/cls_20byte.c: Likewise. + * testsuite/libffi.call/cls_20byte1.c: Likewise. + * testsuite/libffi.call/cls_24byte.c: Likewise. + * testsuite/libffi.call/cls_2byte.c: Likewise. + * testsuite/libffi.call/cls_3_1byte.c: Likewise. + * testsuite/libffi.call/cls_3byte1.c: Likewise. + * testsuite/libffi.call/cls_3byte2.c: Likewise. + * testsuite/libffi.call/cls_4_1byte.c: Likewise. + * testsuite/libffi.call/cls_4byte.c: Likewise. + * testsuite/libffi.call/cls_5_1_byte.c: Likewise. + * testsuite/libffi.call/cls_5byte.c: Likewise. + * testsuite/libffi.call/cls_64byte.c: Likewise. + * testsuite/libffi.call/cls_6_1_byte.c: Likewise. + * testsuite/libffi.call/cls_6byte.c: Likewise. + * testsuite/libffi.call/cls_7_1_byte.c: Likewise. + * testsuite/libffi.call/cls_7byte.c: Likewise. + * testsuite/libffi.call/cls_8byte.c: Likewise. + * testsuite/libffi.call/cls_9byte1.c: Likewise. + * testsuite/libffi.call/cls_9byte2.c: Likewise. + * testsuite/libffi.call/cls_align_double.c: Likewise. + * testsuite/libffi.call/cls_align_float.c: Likewise. + * testsuite/libffi.call/cls_align_longdouble.c: Likewise. + * testsuite/libffi.call/cls_align_longdouble_split.c: Likewise. + * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise. + * testsuite/libffi.call/cls_align_pointer.c: Likewise. + * testsuite/libffi.call/cls_align_sint16.c: Likewise. + * testsuite/libffi.call/cls_align_sint32.c: Likewise. + * testsuite/libffi.call/cls_align_sint64.c: Likewise. + * testsuite/libffi.call/cls_align_uint16.c: Likewise. + * testsuite/libffi.call/cls_align_uint32.c: Likewise. + * testsuite/libffi.call/cls_align_uint64.c: Likewise. + * testsuite/libffi.call/cls_dbls_struct.c: Likewise. + * testsuite/libffi.call/cls_pointer_stack.c: Likewise. + * testsuite/libffi.call/err_bad_typedef.c: Likewise. + * testsuite/libffi.call/huge_struct.c: Likewise. + * testsuite/libffi.call/nested_struct.c: Likewise. + * testsuite/libffi.call/nested_struct1.c: Likewise. + * testsuite/libffi.call/nested_struct10.c: Likewise. + * testsuite/libffi.call/nested_struct2.c: Likewise. + * testsuite/libffi.call/nested_struct3.c: Likewise. + * testsuite/libffi.call/nested_struct4.c: Likewise. + * testsuite/libffi.call/nested_struct5.c: Likewise. + * testsuite/libffi.call/nested_struct6.c: Likewise. + * testsuite/libffi.call/nested_struct7.c: Likewise. + * testsuite/libffi.call/nested_struct8.c: Likewise. + * testsuite/libffi.call/nested_struct9.c: Likewise. + * testsuite/libffi.call/stret_large.c: Likewise. + * testsuite/libffi.call/stret_large2.c: Likewise. + * testsuite/libffi.call/stret_medium.c: Likewise. + * testsuite/libffi.call/stret_medium2.c: Likewise. + * testsuite/libffi.call/struct1.c: Likewise. + * testsuite/libffi.call/struct1_win32.c: Likewise. + * testsuite/libffi.call/struct2.c: Likewise. + * testsuite/libffi.call/struct2_win32.c: Likewise. + * testsuite/libffi.call/struct3.c: Likewise. + * testsuite/libffi.call/struct4.c: Likewise. + * testsuite/libffi.call/struct5.c: Likewise. + * testsuite/libffi.call/struct6.c: Likewise. + * testsuite/libffi.call/struct7.c: Likewise. + * testsuite/libffi.call/struct8.c: Likewise. + * testsuite/libffi.call/struct9.c: Likewise. + * testsuite/libffi.call/testclosure.c: Likewise. + +2012-03-21 Peter Rosin + + * testsuite/libffi.call/float_va.c (float_va_fn): Use %f when + printing doubles (%lf is for long doubles). + (main): Likewise. + +2012-03-21 Peter Rosin + + * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*] + (set_ld_library_path_env_vars): Add the library search dir to PATH + (and save PATH for later). + (restore_ld_library_path_env_vars): Restore PATH. + +2012-03-21 Peter Rosin + + * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*] + (set_ld_library_path_env_vars): Add the library search dir to PATH + (and save PATH for later). + (restore_ld_library_path_env_vars): Restore PATH. + +2012-03-20 Peter Rosin + + * testsuite/libffi.call/strlen2_win32.c (main): Remove bug. + * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label + visible outside the PROC, so that ffi_closure_THISCALL can see it. + +2012-03-20 Peter Rosin + + * testsuite/libffi.call/strlen2_win32.c (main): Remove bug. + * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label + visible outside the PROC, so that ffi_closure_THISCALL can see it. + +2012-03-19 Alan Hourihane + + * src/m68k/ffi.c: Add MINT support. + * src/m68k/sysv.S: Ditto. + +2012-03-06 Chung-Lin Tang + + * src/arm/ffi.c (ffi_call): Add __ARM_EABI__ guard around call to + ffi_call_VFP(). + (ffi_prep_closure_loc): Add __ARM_EABI__ guard around use of + ffi_closure_VFP. + * src/arm/sysv.S: Add __ARM_EABI__ guard around VFP code. + +2012-03-19 chennam + + * src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure + support. + +2012-03-13 Kaz Kojima + + * src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, + just return FFI_BAD_ABI when things are wrong. + * src/sh64/ffi.c (ffi_prep_closure_loc): Ditto. + +2012-03-09 David Edelsohn + + * src/powerpc/aix_closure.S (ffi_closure_ASM): Adjust for Darwin64 + change to return value of ffi_closure_helper_DARWIN and load type + from return type. + +2012-03-03 H.J. Lu + + * src/x86/ffi64.c (ffi_call): Cast the return value to unsigned + long. + (ffi_prep_closure_loc): Cast to 64bit address in trampoline. + (ffi_closure_unix64_inner): Cast return pointer to unsigned long + first. + + * src/x86/ffitarget.h (FFI_SIZEOF_ARG): Defined to 8 for x32. + (ffi_arg): Set to unsigned long long for x32. + (ffi_sarg): Set to long long for x32. + +2012-03-03 H.J. Lu + + * src/prep_cif.c (ffi_prep_cif_core): Properly check bad ABI. + +2012-03-03 Andoni Morales Alastruey + + * configure.ac: Add -no-undefined for both 32- and 64-bit x86 + windows-like hosts. + * configure: Rebuilt. + +2012-02-27 Mikael Pettersson + + PR libffi/52223 + * Makefile.am (FLAGS_TO_PASS): Define. + * Makefile.in: Regenerate. + +2012-02-23 Anthony Green + + * src/*/ffitarget.h: Ensure that users never include ffitarget.h + directly. + +2012-02-23 Kai Tietz + + PR libffi/52221 + * src/x86/ffi.c (ffi_closure_raw_THISCALL): New + prototype. + (ffi_prep_raw_closure_loc): Use ffi_closure_raw_THISCALL for + thiscall-convention. + (ffi_raw_call): Use ffi_prep_args_raw. + * src/x86/win32.S (ffi_closure_raw_THISCALL): Add + implementation for stub. + +2012-02-10 Kai Tietz + + * configure.ac (AM_LTLDFLAGS): Add -no-undefine for x64 + windows target. + * configure: Regenerated. + +2012-02-08 Kai Tietz + + * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32 + also FFI_THISCALL. + * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype. + (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code. + (ffi_prep_closure_loc): Add FFI_THISCALL support. + * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size. + * src/x86/win32.S (ffi_closure_THISCALL): New closure code + for thiscall-calling convention. + * testsuite/libffi.call/closure_thiscall.c: New test. + +2012-01-28 Kai Tietz + + * src/libffi/src/x86/ffi.c (ffi_call_win32): Add new + argument to prototype for specify calling-convention. + (ffi_call): Add support for stdcall/thiscall convention. + (ffi_prep_args): Likewise. + (ffi_raw_call): Likewise. + * src/x86/ffitarget.h (ffi_abi): Add FFI_THISCALL and + FFI_FASTCALL. + * src/x86/win32.S (_ffi_call_win32): Add support for + fastcall/thiscall calling-convention calls. + * testsuite/libffi.call/fastthis1_win32.c: New test. + * testsuite/libffi.call/fastthis2_win32.c: New test. + * testsuite/libffi.call/fastthis3_win32.c: New test. + * testsuite/libffi.call/strlen2_win32.c: New test. + * testsuite/libffi.call/many2_win32.c: New test. + * testsuite/libffi.call/struct1_win32.c: New test. + * testsuite/libffi.call/struct2_win32.c: New test. + +2012-01-23 Uros Bizjak + + * src/alpha/ffi.c (ffi_prep_closure_loc): Check for bad ABI. + +2012-01-23 Anthony Green + Chris Young + + * configure.ac: Add Amiga support. + * configure: Rebuilt. + +2012-01-23 Dmitry Nadezhin + + * include/ffi_common.h (LIKELY, UNLIKELY): Fix definitions. + +2012-01-23 Andreas Schwab + + * src/m68k/sysv.S (ffi_call_SYSV): Properly test for plain + mc68000. Test for __HAVE_68881__ in addition to __MC68881__. + +2012-01-19 Jakub Jelinek + + PR rtl-optimization/48496 + * src/ia64/ffi.c (ffi_call): Fix up aliasing violations. + +2012-01-09 Rainer Orth + + * configure.ac (i?86-*-*): Set TARGET to X86_64. + * configure: Regenerate. + +2011-12-07 Andrew Pinski + + PR libffi/50051 + * src/mips/n32.S: Add ".set mips4". + +2011-11-21 Andreas Tobler + + * configure: Regenerate. + +2011-11-12 David Gilbert + + * doc/libffi.texi, include/ffi.h.in, include/ffi_common.h, + man/Makefile.am, man/ffi.3, man/ffi_prep_cif.3, + man/ffi_prep_cif_var.3, src/arm/ffi.c, src/arm/ffitarget.h, + src/cris/ffi.c, src/prep_cif.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/float_va.c: Many changes to support variadic + function calls. + +2011-11-12 Kyle Moffett + + * src/powerpc/ffi.c, src/powerpc/ffitarget.h, + src/powerpc/ppc_closure.S, src/powerpc/sysv.S: Many changes for + softfloat powerpc variants. + +2011-11-12 Petr Salinger + + * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Fix kfreebsd support. + * configure: Rebuilt. + +2011-11-12 Timothy Wall + + * src/arm/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV): Max + alignment of 4 for wince on ARM. + +2011-11-12 Kyle Moffett + Anthony Green + + * src/ppc/sysv.S, src/ppc/ffi.c: Remove use of ppc string + instructions (not available on some cores, like the PPC440). + +2011-11-12 Kimura Wataru + + * m4/ax_enable_builddir: Change from string comparison to numeric + comparison for wc output. + * configure.ac: Enable FFI_MMAP_EXEC_WRIT for darwin11 aka Mac OS + X 10.7. + * configure: Rebuilt. + +2011-11-12 Anthony Green + + * Makefile.am (AM_CCASFLAGS): Add -g option to build assembly + files with debug info. + * Makefile.in: Rebuilt. + +2011-11-12 Jasper Lievisse Adriaanse + + * README: Update list of supported OpenBSD systems. + +2011-11-12 Anthony Green + + * libtool-version: Update. + * Makefile.am (nodist_libffi_la_SOURCES): Add src/debug.c if + FFI_DEBUG. + (libffi_la_SOURCES): Remove src/debug.c + (EXTRA_DIST): Add src/debug.c + * Makefile.in: Rebuilt. + * README: Update for 3.0.11. + +2011-11-10 Richard Henderson + + * configure.ac (GCC_AS_CFI_PSEUDO_OP): Use it instead of inline check. + * configure, aclocal.m4: Rebuild. + +2011-09-04 Iain Sandoe + + PR libffi/49594 + * src/powerpc/darwin_closure.S (stubs): Make the stub binding + helper reference track the architecture pointer size. + +2011-08-25 Andrew Haley + + * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Remove hard-coded assembly + instructions. + * src/arm/sysv.S (ffi_arm_trampoline): Put them here instead. + +2011-07-11 Andrew Haley + + * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Clear icache. + +2011-06-29 Rainer Orth + + * testsuite/libffi.call/cls_double_va.c: Move PR number to comment. + * testsuite/libffi.call/cls_longdouble_va.c: Likewise. + +2011-06-29 Rainer Orth + + PR libffi/46660 + * testsuite/libffi.call/cls_double_va.c: xfail dg-output on + mips-sgi-irix6*. + * testsuite/libffi.call/cls_longdouble_va.c: Likewise. + +2011-06-14 Rainer Orth + + * testsuite/libffi.call/huge_struct.c (test_large_fn): Use PRIu8, + PRId8 instead of %hhu, %hhd. + * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRId8, + PRIu8): Define. + [__sgi__] (PRId8, PRIu8): Define. + +2011-04-29 Rainer Orth + + * src/alpha/osf.S (UA_SI, FDE_ENCODING, FDE_ENCODE, FDE_ARANGE): + Define. + Use them to handle ELF vs. ECOFF differences. + [__osf__] (_GLOBAL__F_ffi_call_osf): Define. + +2011-03-30 Timothy Wall + + * src/powerpc/darwin.S: Fix unknown FDE encoding. + * src/powerpc/darwin_closure.S: ditto. + +2011-02-25 Anthony Green + + * src/powerpc/ffi.c (ffi_prep_closure_loc): Allow for more + 32-bit ABIs. + +2011-02-15 Anthony Green + + * m4/ax_cc_maxopt.m4: Don't -malign-double or use -ffast-math. + * configure: Rebuilt. + +2011-02-13 Ralf Wildenhues + + * configure: Regenerate. + +2011-02-13 Anthony Green + + * include/ffi_common.h (UNLIKELY, LIKELY): Define. + * src/x86/ffi64.c (UNLIKELY, LIKELY): Remove definition. + * src/prep_cif.c (UNLIKELY, LIKELY): Remove definition. + + * src/prep_cif.c (initialize_aggregate): Convert assertion into + FFI_BAD_TYPEDEF return. Initialize arg size and alignment to 0. + + * src/pa/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, + just return FFI_BAD_ABI when things are wrong. + * src/arm/ffi.c (ffi_prep_closure_loc): Ditto. + * src/powerpc/ffi.c (ffi_prep_closure_loc): Ditto. + * src/mips/ffi.c (ffi_prep_closure_loc): Ditto. + * src/ia64/ffi.c (ffi_prep_closure_loc): Ditto. + * src/avr32/ffi.c (ffi_prep_closure_loc): Ditto. + +2011-02-11 Anthony Green + + * src/sparc/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, + just return FFI_BAD_ABI when things are wrong. + +2012-02-11 Eric Botcazou + + * src/sparc/v9.S (STACKFRAME): Bump to 176. + +2011-02-09 Stuart Shelton + + http://bugs.gentoo.org/show_bug.cgi?id=286911 + * src/mips/ffitarget.h: Clean up error messages. + * src/java_raw_api.c (ffi_java_translate_args): Cast raw arg to + ffi_raw*. + * include/ffi.h.in: Add pragma for SGI compiler. + +2011-02-09 Anthony Green + + * configure.ac: Add powerpc64-*-darwin* support. + +2011-02-09 Anthony Green + + * README: Mention Interix. + +2011-02-09 Jonathan Callen + + * configure.ac: Add Interix to win32/cygwin/mingw case. + * configure: Ditto. + * src/closures.c: Treat Interix like Cygwin, instead of as a + generic win32. + +2011-02-09 Anthony Green + + * testsuite/libffi.call/err_bad_typedef.c: Remove xfail. + * testsuite/libffi.call/err_bad_abi.c: Remove xfail. + * src/x86/ffi64.c (UNLIKELY, LIKELY): Define. + (ffi_prep_closure_loc): Check for bad ABI. + * src/prep_cif.c (UNLIKELY, LIKELY): Define. + (initialize_aggregate): Check for bad types. + +2011-02-09 Landon Fuller + + * Makefile.am (EXTRA_DIST): Add build-ios.sh, src/arm/gentramp.sh, + src/arm/trampoline.S. + (nodist_libffi_la_SOURCES): Add src/arc/trampoline.S. + * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Define. + * src/arm/ffi.c (ffi_trampoline_table) + (ffi_closure_trampoline_table_page, ffi_trampoline_table_entry) + (FFI_TRAMPOLINE_CODELOC_CONFIG, FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) + (FFI_TRAMPOLINE_COUNT, ffi_trampoline_lock, ffi_trampoline_tables) + (ffi_trampoline_table_alloc, ffi_closure_alloc, ffi_closure_free): + Define for FFI_EXEC_TRAMPOLINE_TABLE case (iOS). + (ffi_prep_closure_loc): Handl FFI_EXEC_TRAMPOLINE_TABLE case + separately. + * src/arm/sysv.S: Handle Apple iOS host. + * src/closures.c: Handle FFI_EXEC_TRAMPOLINE_TABLE case. + * build-ios.sh: New file. + * fficonfig.h.in, configure, Makefile.in: Rebuilt. + * README: Mention ARM iOS. + +2011-02-08 Oren Held + + * src/dlmalloc.c (_STRUCT_MALLINFO): Define in order to avoid + redefinition of mallinfo on HP-UX. + +2011-02-08 Ginn Chen + + * src/sparc/ffi.c (ffi_call): Make compatible with Solaris Studio + aggregate return ABI. Flush cache. + (ffi_prep_closure_loc): Flush cache. + +2011-02-11 Anthony Green + + From Tom Honermann : + * src/powerpc/aix.S (ffi_call_AIX): Support for xlc toolchain on + AIX. Declare .ffi_prep_args. Insert nops after branch + instructions so that the AIX linker can insert TOC reload + instructions. + * src/powerpc/aix_closure.S: Declare .ffi_closure_helper_DARWIN. + +2011-02-08 Ed + + * src/powerpc/asm.h: Fix grammar nit in comment. + +2011-02-08 Uli Link + + * include/ffi.h.in (FFI_64_BIT_MAX): Define and use. + +2011-02-09 Rainer Orth + + PR libffi/46661 + * testsuite/libffi.call/cls_pointer.c (main): Cast void * to + uintptr_t first. + * testsuite/libffi.call/cls_pointer_stack.c (main): Likewise. + +2011-02-08 Rafael Avila de Espindola + + * configure.ac: Fix x86 test for pc related relocs. + * configure: Rebuilt. + +2011-02-07 Joel Sherrill + + * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing. + Handle case when CPU variant does not have long double support. + * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire, + and cores with soft floating point. + +2011-02-07 Joel Sherrill + + * configure.ac: Add mips*-*-rtems* support. + * configure: Regenerate. + * src/mips/ffitarget.h: Ensure needed constants are available + for targets which do not have sgidefs.h. + +2011-01-26 Dave Korn + + PR target/40125 + * configure.ac (AM_LTLDFLAGS): Add -bindir option for windows DLLs. + * configure: Regenerate. + +2010-12-18 Iain Sandoe + + PR libffi/29152 + PR libffi/42378 + * src/powerpc/darwin_closure.S: Provide Darwin64 implementation, + update comments. + * src/powerpc/ffitarget.h (POWERPC_DARWIN64): New, + (FFI_TRAMPOLINE_SIZE): Update for Darwin64. + * src/powerpc/darwin.S: Provide Darwin64 implementation, + update comments. + * src/powerpc/ffi_darwin.c: Likewise. + +2010-12-06 Rainer Orth + + * configure.ac (libffi_cv_as_ascii_pseudo_op): Use double + backslashes. + (libffi_cv_as_string_pseudo_op): Likewise. + * configure: Regenerate. + +2010-12-03 Chung-Lin Tang + + * src/arm/sysv.S (ffi_closure_SYSV): Add UNWIND to .pad directive. + (ffi_closure_VFP): Same. + (ffi_call_VFP): Move down to before ffi_closure_VFP. Add '.fpu vfp' + directive. + +2010-12-01 Rainer Orth + + * testsuite/libffi.call/ffitest.h [__sgi] (PRId64, PRIu64): Define. + (PRIuPTR): Define. + +2010-11-29 Richard Henderson + Rainer Orth + + * src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define. + (.eh_frame): Use FDE_ENCODING. + (.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE. + +2010-11-22 Jacek Caban + + * configure.ac: Check for symbol underscores on mingw-w64. + * configure: Rebuilt. + * src/x86/win64.S: Correctly access extern symbols in respect to + underscores. + +2010-11-15 Rainer Orth + + * testsuite/lib/libffi-dg.exp: Rename ... + * testsuite/lib/libffi.exp: ... to this. + * libffi/testsuite/libffi.call/call.exp: Don't load libffi-dg.exp. + * libffi/testsuite/libffi.special/special.exp: Likewise. + +2010-10-28 Chung-Lin Tang + + * src/arm/ffi.c (ffi_prep_args): Add VFP register argument handling + code, new parameter, and return value. Update comments. + (ffi_prep_cif_machdep): Add case for VFP struct return values. Add + call to layout_vfp_args(). + (ffi_call_SYSV): Update declaration. + (ffi_call_VFP): New declaration. + (ffi_call): Add VFP struct return conditions. Call ffi_call_VFP() + when ABI is FFI_VFP. + (ffi_closure_VFP): New declaration. + (ffi_closure_SYSV_inner): Add new vfp_args parameter, update call to + ffi_prep_incoming_args_SYSV(). + (ffi_prep_incoming_args_SYSV): Update parameters. Add VFP argument + case handling. + (ffi_prep_closure_loc): Pass ffi_closure_VFP to trampoline + construction under VFP hard-float. + (rec_vfp_type_p): New function. + (vfp_type_p): Same. + (place_vfp_arg): Same. + (layout_vfp_args): Same. + * src/arm/ffitarget.h (ffi_abi): Add FFI_VFP. Define FFI_DEFAULT_ABI + based on __ARM_PCS_VFP. + (FFI_EXTRA_CIF_FIELDS): Define for adding VFP hard-float specific + fields. + (FFI_TYPE_STRUCT_VFP_FLOAT): Define internally used type code. + (FFI_TYPE_STRUCT_VFP_DOUBLE): Same. + * src/arm/sysv.S (ffi_call_SYSV): Change call of ffi_prep_args() to + direct call. Move function pointer load upwards. + (ffi_call_VFP): New function. + (ffi_closure_VFP): Same. + + * testsuite/lib/libffi-dg.exp (check-flags): New function. + (dg-skip-if): New function. + * testsuite/libffi.call/cls_double_va.c: Skip if target is arm*-*-* + and compiler options include -mfloat-abi=hard. + * testsuite/libffi.call/cls_longdouble_va.c: Same. + +2010-10-01 Jakub Jelinek + + PR libffi/45677 + * src/x86/ffi64.c (ffi_prep_cif_machdep): Ensure cif->bytes is + a multiple of 8. + * testsuite/libffi.call/many2.c: New test. + +2010-08-20 Mark Wielaard + + * src/closures.c (open_temp_exec_file_mnt): Check if getmntent_r + returns NULL. + +2010-08-09 Andreas Tobler + + * configure.ac: Add target powerpc64-*-freebsd*. + * configure: Regenerate. + * testsuite/libffi.call/cls_align_longdouble_split.c: Pass + -mlong-double-128 only to linux targets. + * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise. + * testsuite/libffi.call/cls_longdouble.c: Likewise. + * testsuite/libffi.call/huge_struct.c: Likewise. + +2010-08-05 Dan Witte + + * Makefile.am: Pass FFI_DEBUG define to msvcc.sh for linking to the + debug CRT when --enable-debug is given. + * configure.ac: Define it. + * msvcc.sh: Translate -g and -DFFI_DEBUG appropriately. + +2010-08-04 Dan Witte + + * src/x86/ffitarget.h: Add X86_ANY define for all x86/x86_64 + platforms. + * src/x86/ffi.c: Remove redundant ifdef checks. + * src/prep_cif.c: Push stack space computation into src/x86/ffi.c + for X86_ANY so return value space doesn't get added twice. + +2010-08-03 Neil Rashbrooke + + * msvcc.sh: Don't pass -safeseh to ml64 because behavior is buggy. + +2010-07-22 Dan Witte + + * src/*/ffitarget.h: Make FFI_LAST_ABI one past the last valid ABI. + * src/prep_cif.c: Fix ABI assertion. + * src/cris/ffi.c: Ditto. + +2010-07-10 Evan Phoenix + + * src/closures.c (selinux_enabled_check): Fix strncmp usage bug. + +2010-07-07 Dan Horák + + * include/ffi.h.in: Protect #define with #ifndef. + * src/powerpc/ffitarget.h: Ditto. + * src/s390/ffitarget.h: Ditto. + * src/sparc/ffitarget.h: Ditto. + +2010-07-07 Neil Roberts + + * src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to + 16-bytes. + +2010-07-02 Jakub Jelinek + + * Makefile.am (AM_MAKEFLAGS): Pass also mandir to submakes. + * Makefile.in: Regenerated. + +2010-05-19 Rainer Orth + + * configure.ac (libffi_cv_as_x86_pcrel): Check for illegal in as + output, too. + (libffi_cv_as_ascii_pseudo_op): Check for .ascii. + (libffi_cv_as_string_pseudo_op): Check for .string. + * configure: Regenerate. + * fficonfig.h.in: Regenerate. + * src/x86/sysv.S (.eh_frame): Use .ascii, .string or error. + +2010-05-11 Dan Witte + + * doc/libffi.tex: Document previous change. + +2010-05-11 Makoto Kato + + * src/x86/ffi.c (ffi_call): Don't copy structs passed by value. + +2010-05-05 Michael Kohler + + * src/dlmalloc.c (dlfree): Fix spelling. + * src/ia64/ffi.c (ffi_prep_cif_machdep): Ditto. + * configure.ac: Ditto. + * configure: Rebuilt. + +2010-04-13 Dan Witte + + * msvcc.sh: Build with -W3 instead of -Wall. + * src/powerpc/ffi_darwin.c: Remove build warnings. + * src/x86/ffi.c: Ditto. + * src/x86/ffitarget.h: Ditto. + +2010-04-12 Dan Witte + Walter Meinl + + * configure.ac: Add OS/2 support. + * configure: Rebuilt. + * src/closures.c: Ditto. + * src/dlmalloc.c: Ditto. + * src/x86/win32.S: Ditto. + +2010-04-07 Jakub Jelinek + + * testsuite/libffi.call/err_bad_abi.c: Remove unused args variable. + +2010-04-02 Ralf Wildenhues + + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * include/Makefile.in: Regenerate. + * man/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2010-03-30 Dan Witte + + * msvcc.sh: Disable build warnings. + * README (tested): Clarify windows build procedure. + +2010-03-15 Rainer Orth + + * configure.ac (libffi_cv_as_x86_64_unwind_section_type): New test. + * configure: Regenerate. + * fficonfig.h.in: Regenerate. + * libffi/src/x86/unix64.S (.eh_frame) + [HAVE_AS_X86_64_UNWIND_SECTION_TYPE]: Use @unwind section type. + +2010-03-14 Matthias Klose + + * src/x86/ffi64.c: Fix typo in comment. + * src/x86/ffi.c: Use /* ... */ comment style. + +2010-02-24 Rainer Orth + + * doc/libffi.texi (The Closure API): Fix typo. + * doc/libffi.info: Remove. + +2010-02-15 Matthias Klose + + * src/arm/sysv.S (__ARM_ARCH__): Define for processor + __ARM_ARCH_7EM__. + +2010-01-15 Anthony Green + + * README: Add notes on building with Microsoft Visual C++. + +2010-01-15 Daniel Witte + + * msvcc.sh: New file. + + * src/x86/win32.S: Port assembly routines to MSVC and #ifdef. + * src/x86/ffi.c: Tweak function declaration and remove excess + parens. + * include/ffi.h.in: Add __declspec(align(8)) to typedef struct + ffi_closure. + + * src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new + function ffi_call_win32 on X86_WIN32. + * src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32. + (ffi_call_STDCALL): Remove. + + * src/prep_cif.c (ffi_prep_cif): Move stack space allocation code + to ffi_prep_cif_machdep for x86. + * src/x86/ffi.c (ffi_prep_cif_machdep): To here. + +2010-01-15 Oliver Kiddle + + * src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for + Sun Studio compiler compatibility. + +2010-01-12 Conrad Irwin + + * doc/libffi.texi: Add closure example. + +2010-01-07 Rainer Orth + + PR libffi/40701 + * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRIdLL, + PRIuLL, PRId64, PRIu64, PRIuPTR): Define. + * testsuite/libffi.call/cls_align_sint64.c: Add -Wno-format on + alpha*-dec-osf*. + * testsuite/libffi.call/cls_align_uint64.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/return_ll1.c: Likewise. + * testsuite/libffi.call/stret_medium2.c: Likewise. + * testsuite/libffi.special/ffitestcxx.h (allocate_mmap): Cast + MAP_FAILED to char *. + +2010-01-06 Rainer Orth + + * src/mips/n32.S: Use .abicalls and .eh_frame with __GNUC__. + +2009-12-31 Anthony Green + + * README: Update for libffi 3.0.9. + +2009-12-27 Matthias Klose + + * configure.ac (HAVE_LONG_DOUBLE): Define for mips when + appropriate. + * configure: Rebuilt. + +2009-12-26 Anthony Green + + * testsuite/libffi.call/cls_longdouble_va.c: Mark as xfail for + avr32*-*-*. + * testsuite/libffi.call/cls_double_va.c: Ditto. + +2009-12-26 Andreas Tobler + + * testsuite/libffi.call/ffitest.h: Conditionally include stdint.h + and inttypes.h. + * testsuite/libffi.special/unwindtest.cc: Ditto. + +2009-12-26 Andreas Tobler + + * configure.ac: Add amd64-*-openbsd*. + * configure: Rebuilt. + * testsuite/lib/libffi-dg.exp (libffi_target_compile): Link + openbsd programs with -lpthread. + +2009-12-26 Anthony Green + + * testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c: Remove xfail for + mips*-*-* and arm*-*-*. + * testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c, + testsuite/libffi.call/stret_medium2.c, + testsuite/libffi.call/stret_medium.c, + testsuite/libffi.call/stret_large.c, + testsuite/libffi.call/stret_large2.c: Remove xfail for arm*-*-*. + +2009-12-31 Kay Tietz + + * testsuite/libffi.call/ffitest.h, + testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRuLL): Fix + definitions. + +2009-12-31 Carlo Bramini + + * configure.ac (AM_LTLDFLAGS): Define for windows hosts. + * Makefile.am (libffi_la_LDFLAGS): Add AM_LTLDFLAGS. + * configure: Rebuilt. + * Makefile.in: Rebuilt. + +2009-12-31 Anthony Green + Blake Chaffin. + + * testsuite/libffi.call/huge_struct.c: New test case from Blake + Chaffin @ Apple. + +2009-12-28 David Edelsohn + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Copy abi and nargs to + local variables. + (aix_adjust_aggregate_sizes): New function. + (ffi_prep_cif_machdep): Call it. + +2009-12-26 Andreas Tobler + + * configure.ac: Define FFI_MMAP_EXEC_WRIT for the given targets. + * configure: Regenerate. + * fficonfig.h.in: Likewise. + * src/closures.c: Remove the FFI_MMAP_EXEC_WRIT definition for + Solaris/x86. + +2009-12-26 Andreas Schwab + + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Advance intarg_count + when a float arguments is passed in memory. + (ffi_closure_helper_SYSV): Mark general registers as used up when + a 64bit or soft-float long double argument is passed in memory. + +2009-12-25 Matthias Klose + + * man/ffi_call.3: Fix #include in examples. + * doc/libffi.texi: Add dircategory. + +2009-12-25 Frank Everdij + + * include/ffi.h.in: Placed '__GNUC__' ifdef around + '__attribute__((aligned(8)))' in ffi_closure, fixes compile for + IRIX MIPSPro c99. + * include/ffi_common.h: Added '__sgi' define to non + '__attribute__((__mode__()))' integer typedefs. + * src/mips/ffi.c (ffi_call, ffi_closure_mips_inner_O32, + ffi_closure_mips_inner_N32): Added 'defined(_MIPSEB)' to BE check. + (ffi_closure_mips_inner_O32, ffi_closure_mips_inner_N32): Added + FFI_LONGDOUBLE support and alignment(N32 only). + * src/mips/ffitarget.h: Corrected '#include ' for IRIX and + fixed non '__attribute__((__mode__()))' integer typedefs. + * src/mips/n32.S: Put '#ifdef linux' around '.abicalls' and '.eh_frame' + since they are Linux/GNU Assembler specific. + +2009-12-25 Bradley Smith + + * configure.ac, Makefile.am, src/avr32/ffi.c, + src/avr32/ffitarget.h, + src/avr32/sysv.S: Add AVR32 port. + * configure, Makefile.in: Rebuilt. + +2009-12-21 Andreas Tobler + + * configure.ac: Make i?86 build on FreeBSD and OpenBSD. + * configure: Regenerate. + +2009-12-15 John David Anglin + + * testsuite/libffi.call/ffitest.h: Define PRIuPTR on PA HP-UX. + +2009-12-13 John David Anglin + + * src/pa/ffi.c (ffi_closure_inner_pa32): Handle FFI_TYPE_LONGDOUBLE + type on HP-UX. + +2012-02-13 Kai Tietz + + PR libffi/52221 + * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall + support for X86_WIN32. + (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement. + +2009-12-11 Eric Botcazou + + * src/sparc/ffi.c (ffi_closure_sparc_inner_v9): Properly align 'long + double' arguments. + +2009-12-11 Eric Botcazou + + * testsuite/libffi.call/ffitest.h: Define PRIuPTR on Solaris < 10. + +2009-12-10 Rainer Orth + + PR libffi/40700 + * src/closures.c [X86_64 && __sun__ && __svr4__] + (FFI_MMAP_EXEC_WRIT): Define. + +2009-12-08 David Daney + + * testsuite/libffi.call/stret_medium.c: Remove xfail for mips*-*-* + * testsuite/libffi.call/cls_align_longdouble_split2.c: Same. + * testsuite/libffi.call/stret_large.c: Same. + * testsuite/libffi.call/cls_align_longdouble_split.c: Same. + * testsuite/libffi.call/stret_large2.c: Same. + * testsuite/libffi.call/stret_medium2.c: Same. + +2009-12-07 David Edelsohn + + * src/powerpc/aix_closure.S (libffi_closure_ASM): Fix tablejump + typo. + +2009-12-05 David Edelsohn + + * src/powerpc/aix.S: Update AIX32 code to be consistent with AIX64 + code. + * src/powerpc/aix_closure.S: Same. + +2009-12-05 Ralf Wildenhues + + * Makefile.in: Regenerate. + * configure: Regenerate. + * include/Makefile.in: Regenerate. + * man/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2009-12-04 David Edelsohn + + * src/powerpc/aix_closure.S: Reorganize 64-bit code to match + linux64_closure.S. + +2009-12-04 Uros Bizjak + + PR libffi/41908 + * src/x86/ffi64.c (classify_argument): Update from + gcc/config/i386/i386.c. + (ffi_closure_unix64_inner): Do not use the address of two consecutive + SSE registers directly. + * testsuite/libffi.call/cls_dbls_struct.c (main): Remove xfail + for x86_64 linux targets. + +2009-12-04 David Edelsohn + + * src/powerpc/ffi_darwin.c (ffi_closure_helper_DARWIN): Increment + pfr for long double split between fpr13 and stack. + +2009-12-03 David Edelsohn + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Increment next_arg and + fparg_count twice for long double. + +2009-12-03 David Edelsohn + + PR libffi/42243 + * src/powerpc/ffi_darwin.c (ffi_prep_args): Remove extra parentheses. + +2009-12-03 Uros Bizjak + + * testsuite/libffi.call/cls_longdouble_va.c (main): Fix format string. + Remove xfails for x86 linux targets. + +2009-12-02 David Edelsohn + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Fix typo in INT64 + case. + +2009-12-01 David Edelsohn + + * src/powerpc/aix.S (ffi_call_AIX): Convert to more standard + register usage. Call ffi_prep_args directly. Add long double + return value support. + * src/powerpc/ffi_darwin.c (ffi_prep_args): Double arg increment + applies to FFI_TYPE_DOUBLE. Correct fpr_base increment typo. + Separate FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases. + (ffi_prep_cif_machdep): Only 16 byte stack alignment in 64 bit + mode. + (ffi_closure_helper_DARWIN): Remove nf and ng counters. Move temp + into case. + * src/powerpc/aix_closure.S: Maintain 16 byte stack alignment. + Allocate result area between params and FPRs. + +2009-11-30 David Edelsohn + + PR target/35484 + * src/powerpc/ffitarget.h (POWERPC64): Define for PPC64 Linux and + AIX64. + * src/powerpc/aix.S: Implement AIX64 version. + * src/powerpc/aix_closure.S: Implement AIX64 version. + (ffi_closure_ASM): Use extsb, lha and displament addresses. + * src/powerpc/ffi_darwin.c (ffi_prep_args): Implement AIX64 + support. + (ffi_prep_cif_machdep): Same. + (ffi_call): Same. + (ffi_closure_helper_DARWIN): Same. + +2009-11-02 Andreas Tobler + + PR libffi/41908 + * testsuite/libffi.call/testclosure.c: New test. + +2009-09-28 Kai Tietz + + * src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu + assembly version use of ___chkstk. + +2009-09-23 Matthias Klose + + PR libffi/40242, PR libffi/41443 + * src/arm/sysv.S (__ARM_ARCH__): Define for processors + __ARM_ARCH_6T2__, __ARM_ARCH_6M__, __ARM_ARCH_7__, + __ARM_ARCH_7A__, __ARM_ARCH_7R__, __ARM_ARCH_7M__. + Change the conditionals to __SOFTFP__ || __ARM_EABI__ + for -mfloat-abi=softfp to work. + +2009-09-17 Loren J. Rittle + + PR testsuite/32843 (strikes again) + * src/x86/ffi.c (ffi_prep_cif_machdep): Add X86_FREEBSD to + enable proper extension on char and short. + +2009-09-15 David Daney + + * src/java_raw_api.c (ffi_java_raw_to_rvalue): Remove special + handling for FFI_TYPE_POINTER. + * src/mips/ffitarget.h (FFI_TYPE_STRUCT_D_SOFT, + FFI_TYPE_STRUCT_F_SOFT, FFI_TYPE_STRUCT_DD_SOFT, + FFI_TYPE_STRUCT_FF_SOFT, FFI_TYPE_STRUCT_FD_SOFT, + FFI_TYPE_STRUCT_DF_SOFT, FFI_TYPE_STRUCT_SOFT): New defines. + (FFI_N32_SOFT_FLOAT, FFI_N64_SOFT_FLOAT): New ffi_abi enumerations. + (enum ffi_abi): Set FFI_DEFAULT_ABI for soft-float. + * src/mips/n32.S (ffi_call_N32): Add handling for soft-float + structure and pointer returns. + (ffi_closure_N32): Add handling for pointer returns. + * src/mips/ffi.c (ffi_prep_args, calc_n32_struct_flags, + calc_n32_return_struct_flags): Handle soft-float. + (ffi_prep_cif_machdep): Handle soft-float, fix pointer handling. + (ffi_call_N32): Declare proper argument types. + (ffi_call, copy_struct_N32, ffi_closure_mips_inner_N32): Handle + soft-float. + +2009-08-24 Ralf Wildenhues + + * configure.ac (AC_PREREQ): Bump to 2.64. + +2009-08-22 Ralf Wildenhues + + * Makefile.am (install-html, install-pdf): Remove. + * Makefile.in: Regenerate. + + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * configure: Regenerate. + * fficonfig.h.in: Regenerate. + * include/Makefile.in: Regenerate. + * man/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2011-08-22 Jasper Lievisse Adriaanse + + * configure.ac: Add OpenBSD/hppa and OpenBSD/powerpc support. + * configure: Rebuilt. + +2009-07-30 Ralf Wildenhues + + * configure.ac (_AC_ARG_VAR_PRECIOUS): Use m4_rename_force. + +2009-07-24 Dave Korn + + PR libffi/40807 + * src/x86/ffi.c (ffi_prep_cif_machdep): Also use sign/zero-extending + return types for X86_WIN32. + * src/x86/win32.S (_ffi_call_SYSV): Handle omitted return types. + (_ffi_call_STDCALL, _ffi_closure_SYSV, _ffi_closure_raw_SYSV, + _ffi_closure_STDCALL): Likewise. + + * src/closures.c (is_selinux_enabled): Define to const 0 for Cygwin. + (dlmmap, dlmunmap): Also use these functions on Cygwin. + +2009-07-11 Richard Sandiford + + PR testsuite/40699 + PR testsuite/40707 + PR testsuite/40709 + * testsuite/lib/libffi-dg.exp: Revert 2009-07-02, 2009-07-01 and + 2009-06-30 commits. + +2009-07-01 Richard Sandiford + + * testsuite/lib/libffi-dg.exp (libffi-init): Set ld_library_path + to "" before adding paths. (This reinstates an assignment that + was removed by my 2009-06-30 commit, but changes the initial + value from "." to "".) + +2009-07-01 H.J. Lu + + PR testsuite/40601 + * testsuite/lib/libffi-dg.exp (libffi-init): Properly set + gccdir. Adjust ld_library_path for gcc only if gccdir isn't + empty. + +2009-06-30 Richard Sandiford + + * testsuite/lib/libffi-dg.exp (libffi-init): Don't add "." + to ld_library_path. Use add_path. Add just find_libgcc_s + to ld_library_path, not every libgcc multilib directory. + +2009-06-16 Wim Lewis + + * src/powerpc/ffi.c: Avoid clobbering cr3 and cr4, which are + supposed to be callee-saved. + * src/powerpc/sysv.S (small_struct_return_value): Fix overrun of + return buffer for odd-size structs. + +2009-06-16 Andreas Tobler + + PR libffi/40444 + * testsuite/lib/libffi-dg.exp (libffi_target_compile): Add + allow_stack_execute for Darwin. + +2009-06-16 Andrew Haley + + * configure.ac (TARGETDIR): Add missing blank lines. + * configure: Regenerate. + +2009-06-16 Andrew Haley + + * testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_medium2.c: Fix printf format + specifiers. + * testsuite/libffi.call/ffitest.h, + testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define. + +2009-06-15 Andrew Haley + + * testsuite/libffi.call/err_bad_typedef.c: xfail everywhere. + * testsuite/libffi.call/err_bad_abi.c: Likewise. + +2009-06-12 Andrew Haley + + * Makefile.am: Remove info_TEXINFOS. + +2009-06-12 Andrew Haley + + * ChangeLog.libffi: testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_medium2.c: Fix printf format + specifiers. + testsuite/libffi.special/unwindtest.cc: include stdint.h. + +2009-06-11 Timothy Wall + + * Makefile.am, + configure.ac, + include/ffi.h.in, + include/ffi_common.h, + src/closures.c, + src/dlmalloc.c, + src/x86/ffi.c, + src/x86/ffitarget.h, + src/x86/win64.S (new), + README: Added win64 support (mingw or MSVC) + * Makefile.in, + include/Makefile.in, + man/Makefile.in, + testsuite/Makefile.in, + configure, + aclocal.m4: Regenerated + * ltcf-c.sh: properly escape cygwin/w32 path + * man/ffi_call.3: Clarify size requirements for return value. + * src/x86/ffi64.c: Fix filename in comment. + * src/x86/win32.S: Remove unused extern. + + * testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/cls_12byte.c, + testsuite/libffi.call/cls_16byte.c, + testsuite/libffi.call/cls_18byte.c, + testsuite/libffi.call/cls_19byte.c, + testsuite/libffi.call/cls_1_1byte.c, + testsuite/libffi.call/cls_20byte.c, + testsuite/libffi.call/cls_20byte1.c, + testsuite/libffi.call/cls_24byte.c, + testsuite/libffi.call/cls_2byte.c, + testsuite/libffi.call/cls_3_1byte.c, + testsuite/libffi.call/cls_3byte1.c, + testsuite/libffi.call/cls_3byte2.c, + testsuite/libffi.call/cls_4_1byte.c, + testsuite/libffi.call/cls_4byte.c, + testsuite/libffi.call/cls_5_1_byte.c, + testsuite/libffi.call/cls_5byte.c, + testsuite/libffi.call/cls_64byte.c, + testsuite/libffi.call/cls_6_1_byte.c, + testsuite/libffi.call/cls_6byte.c, + testsuite/libffi.call/cls_7_1_byte.c, + testsuite/libffi.call/cls_7byte.c, + testsuite/libffi.call/cls_8byte.c, + testsuite/libffi.call/cls_9byte1.c, + testsuite/libffi.call/cls_9byte2.c, + testsuite/libffi.call/cls_align_double.c, + testsuite/libffi.call/cls_align_float.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_align_sint16.c, + testsuite/libffi.call/cls_align_sint32.c, + testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint16.c, + testsuite/libffi.call/cls_align_uint32.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_dbls_struct.c, + testsuite/libffi.call/cls_double.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_float.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_multi_schar.c, + testsuite/libffi.call/cls_multi_sshort.c, + testsuite/libffi.call/cls_multi_sshortchar.c, + testsuite/libffi.call/cls_multi_uchar.c, + testsuite/libffi.call/cls_multi_ushort.c, + testsuite/libffi.call/cls_multi_ushortchar.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c, + testsuite/libffi.call/cls_schar.c, + testsuite/libffi.call/cls_sint.c, + testsuite/libffi.call/cls_sshort.c, + testsuite/libffi.call/cls_uchar.c, + testsuite/libffi.call/cls_uint.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/cls_ushort.c, + testsuite/libffi.call/err_bad_abi.c, + testsuite/libffi.call/err_bad_typedef.c, + testsuite/libffi.call/float2.c, + testsuite/libffi.call/huge_struct.c, + testsuite/libffi.call/nested_struct.c, + testsuite/libffi.call/nested_struct1.c, + testsuite/libffi.call/nested_struct10.c, + testsuite/libffi.call/nested_struct2.c, + testsuite/libffi.call/nested_struct3.c, + testsuite/libffi.call/nested_struct4.c, + testsuite/libffi.call/nested_struct5.c, + testsuite/libffi.call/nested_struct6.c, + testsuite/libffi.call/nested_struct7.c, + testsuite/libffi.call/nested_struct8.c, + testsuite/libffi.call/nested_struct9.c, + testsuite/libffi.call/problem1.c, + testsuite/libffi.call/return_ldl.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_large.c, + testsuite/libffi.call/stret_large2.c, + testsuite/libffi.call/stret_medium.c, + testsuite/libffi.call/stret_medium2.c, + testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead + of checking for MMAP. Use intptr_t instead of long casts. + +2009-06-11 Kaz Kojima + + * testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*. + * testsuite/libffi.call/err_bad_abi.c: Add xfail sh*-*-*. + * testsuite/libffi.call/err_bad_typedef.c: Likewise. + +2009-06-09 Andrew Haley + + * src/x86/freebsd.S: Add missing file. + +2009-06-08 Andrew Haley + + Import from libffi 3.0.8: + + * doc/libffi.texi: New file. + * doc/libffi.info: Likewise. + * doc/stamp-vti: Likewise. + * man/Makefile.am: New file. + * man/ffi_call.3: New file. + + * Makefile.am (EXTRA_DIST): Add src/x86/darwin64.S, + src/dlmalloc.c. + (nodist_libffi_la_SOURCES): Add X86_FREEBSD. + + * configure.ac: Bump version to 3.0.8. + parisc*-*-linux*: Add. + i386-*-freebsd* | i386-*-openbsd*: Add. + powerpc-*-beos*: Add. + AM_CONDITIONAL X86_FREEBSD: Add. + AC_CONFIG_FILES: Add man/Makefile. + + * include/ffi.h.in (FFI_FN): Change void (*)() to void (*)(void). + +2009-06-08 Andrew Haley + + * README: Import from libffi 3.0.8. + +2009-06-08 Andrew Haley + + * testsuite/libffi.call/err_bad_abi.c: Add xfails. + * testsuite/libffi.call/cls_longdouble_va.c: Add xfails. + * testsuite/libffi.call/cls_dbls_struct.c: Add xfail x86_64-*-linux-*. + * testsuite/libffi.call/err_bad_typedef.c: Add xfails. + + * testsuite/libffi.call/stret_medium2.c: Add __UNUSED__ to args. + * testsuite/libffi.call/stret_medium.c: Likewise. + * testsuite/libffi.call/stret_large2.c: Likewise. + * testsuite/libffi.call/stret_large.c: Likewise. + +2008-12-26 Timothy Wall + + * testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected + failures on x86_64 cygwin/mingw. + +2008-12-22 Timothy Wall + + * testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/closure_loc_fn0.c, + testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c: use portable cast from + pointer to integer (intptr_t). + * testsuite/libffi.call/cls_longdouble.c: disable for win64. + +2008-07-24 Anthony Green + + * testsuite/libffi.call/cls_dbls_struct.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c, + testsuite/libffi.call/err_bad_abi.c: Clean up failures from + compiler warnings. + +2008-03-04 Anthony Green + Blake Chaffin + hos@tamanegi.org + + * testsuite/libffi.call/cls_align_longdouble_split2.c + testsuite/libffi.call/cls_align_longdouble_split.c + testsuite/libffi.call/cls_dbls_struct.c + testsuite/libffi.call/cls_double_va.c + testsuite/libffi.call/cls_longdouble.c + testsuite/libffi.call/cls_longdouble_va.c + testsuite/libffi.call/cls_pointer.c + testsuite/libffi.call/cls_pointer_stack.c + testsuite/libffi.call/err_bad_abi.c + testsuite/libffi.call/err_bad_typedef.c + testsuite/libffi.call/stret_large2.c + testsuite/libffi.call/stret_large.c + testsuite/libffi.call/stret_medium2.c + testsuite/libffi.call/stret_medium.c: New tests from Apple. + +2009-06-05 Andrew Haley + + * src/x86/ffitarget.h, src/x86/ffi.c: Merge stdcall changes from + libffi. + +2009-06-04 Andrew Haley + + * src/x86/ffitarget.h, src/x86/win32.S, src/x86/ffi.c: Back out + stdcall changes. + +2008-02-26 Anthony Green + Thomas Heller + + * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C + comment. + +2008-02-03 Timothy Wall + + * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return + offset based on code pointer, not data pointer. + +2008-01-31 Timothy Wall + + * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall + closures. + * src/x86/ffitarget.h: Increase size of trampoline for stdcall + closures. + * src/x86/win32.S: Add assembly for stdcall closure. + * src/x86/ffi.c: Initialize stdcall closure trampoline. + +2009-06-04 Andrew Haley + + * include/ffi.h.in: Change void (*)() to void (*)(void). + * src/x86/ffi.c: Likewise. + +2009-06-04 Andrew Haley + + * src/powerpc/ppc_closure.S: Insert licence header. + * src/powerpc/linux64_closure.S: Likewise. + * src/m68k/sysv.S: Likewise. + + * src/sh64/ffi.c: Change void (*)() to void (*)(void). + * src/powerpc/ffi.c: Likewise. + * src/powerpc/ffi_darwin.c: Likewise. + * src/m32r/ffi.c: Likewise. + * src/sh64/ffi.c: Likewise. + * src/x86/ffi64.c: Likewise. + * src/alpha/ffi.c: Likewise. + * src/alpha/osf.S: Likewise. + * src/frv/ffi.c: Likewise. + * src/s390/ffi.c: Likewise. + * src/pa/ffi.c: Likewise. + * src/pa/hpux32.S: Likewise. + * src/ia64/unix.S: Likewise. + * src/ia64/ffi.c: Likewise. + * src/sparc/ffi.c: Likewise. + * src/mips/ffi.c: Likewise. + * src/sh/ffi.c: Likewise. + +2008-02-15 David Daney + + * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE): + Define (conditionally), and use it to include cachectl.h. + (ffi_prep_closure_loc): Fix cache flushing. + * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define. + +2009-06-04 Andrew Haley + + include/ffi.h.in, + src/arm/ffitarget.h, + src/arm/ffi.c, + src/arm/sysv.S, + src/powerpc/ffitarget.h, + src/closures.c, + src/sh64/ffitarget.h, + src/sh64/ffi.c, + src/sh64/sysv.S, + src/types.c, + src/x86/ffi64.c, + src/x86/ffitarget.h, + src/x86/win32.S, + src/x86/darwin.S, + src/x86/ffi.c, + src/x86/sysv.S, + src/x86/unix64.S, + src/alpha/ffitarget.h, + src/alpha/ffi.c, + src/alpha/osf.S, + src/m68k/ffitarget.h, + src/frv/ffitarget.h, + src/frv/ffi.c, + src/s390/ffitarget.h, + src/s390/sysv.S, + src/cris/ffitarget.h, + src/pa/linux.S, + src/pa/ffitarget.h, + src/pa/ffi.c, + src/raw_api.c, + src/ia64/ffitarget.h, + src/ia64/unix.S, + src/ia64/ffi.c, + src/ia64/ia64_flags.h, + src/java_raw_api.c, + src/debug.c, + src/sparc/v9.S, + src/sparc/ffitarget.h, + src/sparc/ffi.c, + src/sparc/v8.S, + src/mips/ffitarget.h, + src/mips/n32.S, + src/mips/o32.S, + src/mips/ffi.c, + src/prep_cif.c, + src/sh/ffitarget.h, + src/sh/ffi.c, + src/sh/sysv.S: Update license text. + +2009-05-22 Dave Korn + + * src/x86/win32.S (_ffi_closure_STDCALL): New function. + (.eh_frame): Add FDE for it. + +2009-05-22 Dave Korn + + * configure.ac: Also check if assembler supports pc-relative + relocs on X86_WIN32 targets. + * configure: Regenerate. + * src/x86/win32.S (ffi_prep_args): Declare extern, not global. + (_ffi_call_SYSV): Add missing function type symbol .def and + add EH markup labels. + (_ffi_call_STDCALL): Likewise. + (_ffi_closure_SYSV): Likewise. + (_ffi_closure_raw_SYSV): Likewise. + (.eh_frame): Add hand-crafted EH data. + +2009-04-09 Jakub Jelinek + + * testsuite/lib/libffi-dg.exp: Change copyright header to refer to + version 3 of the GNU General Public License and to point readers + at the COPYING3 file and the FSF's license web page. + * testsuite/libffi.call/call.exp: Likewise. + * testsuite/libffi.special/special.exp: Likewise. + +2009-03-01 Ralf Wildenhues + + * configure: Regenerate. + +2008-12-18 Rainer Orth + + PR libffi/26048 + * configure.ac (HAVE_AS_X86_PCREL): New test. + * configure: Regenerate. + * fficonfig.h.in: Regenerate. + * src/x86/sysv.S [!FFI_NO_RAW_API]: Precalculate + RAW_CLOSURE_CIF_OFFSET, RAW_CLOSURE_FUN_OFFSET, + RAW_CLOSURE_USER_DATA_OFFSET for the Solaris 10/x86 assembler. + (.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL. + * src/x86/unix64.S (.Lstore_table): Move to .text section. + (.Lload_table): Likewise. + (.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL. + +2008-12-18 Ralf Wildenhues + + * configure: Regenerate. + +2008-11-21 Eric Botcazou + + * src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for + signed/unsigned int8/16 return values. + * src/sparc/v8.S (ffi_call_v8): Likewise. + (ffi_closure_v8): Likewise. + +2008-09-26 Peter O'Gorman + Steve Ellcey + + * configure: Regenerate for new libtool. + * Makefile.in: Ditto. + * include/Makefile.in: Ditto. + * aclocal.m4: Ditto. + +2008-08-25 Andreas Tobler + + * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and + FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. + Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. + Adjust copyright notice. + * src/powerpc/ffi.c: Add two new flags to indicate if we have one + register or two register to use for FFI_SYSV structs. + (ffi_prep_cif_machdep): Pass the right register flag introduced above. + (ffi_closure_helper_SYSV): Fix the return type for + FFI_SYSV_TYPE_SMALL_STRUCT. Comment. + Adjust copyright notice. + +2008-07-16 Kaz Kojima + + * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned + int. + +2008-06-17 Ralf Wildenhues + + * configure: Regenerate. + * include/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2008-06-07 Joseph Myers + + * configure.ac (parisc*-*-linux*, powerpc-*-sysv*, + powerpc-*-beos*): Remove. + * configure: Regenerate. + +2008-05-09 Julian Brown + + * Makefile.am (LTLDFLAGS): New. + (libffi_la_LDFLAGS): Use above. + * Makefile.in: Regenerate. + +2008-04-18 Paolo Bonzini + + PR bootstrap/35457 + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2008-03-26 Kaz Kojima + + * src/sh/sysv.S: Add .note.GNU-stack on Linux. + * src/sh64/sysv.S: Likewise. + +2008-03-26 Daniel Jacobowitz + + * src/arm/sysv.S: Fix ARM comment marker. + +2008-03-26 Jakub Jelinek + + * src/alpha/osf.S: Add .note.GNU-stack on Linux. + * src/s390/sysv.S: Likewise. + * src/powerpc/ppc_closure.S: Likewise. + * src/powerpc/sysv.S: Likewise. + * src/x86/unix64.S: Likewise. + * src/x86/sysv.S: Likewise. + * src/sparc/v8.S: Likewise. + * src/sparc/v9.S: Likewise. + * src/m68k/sysv.S: Likewise. + * src/arm/sysv.S: Likewise. + +2008-03-16 Ralf Wildenhues + + * aclocal.m4: Regenerate. + * configure: Likewise. + * Makefile.in: Likewise. + * include/Makefile.in: Likewise. + * testsuite/Makefile.in: Likewise. + +2008-02-12 Bjoern Koenig + Andreas Tobler + + * configure.ac: Add amd64-*-freebsd* target. + * configure: Regenerate. + +2008-01-30 H.J. Lu + + PR libffi/34612 + * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when + returning struct. + + * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer" + tests. + +2008-01-24 David Edelsohn + + * configure: Regenerate. + +2008-01-06 Andreas Tobler + + * src/x86/ffi.c (ffi_prep_cif_machdep): Fix thinko. + +2008-01-05 Andreas Tobler + + PR testsuite/32843 + * src/x86/ffi.c (ffi_prep_cif_machdep): Add code for + signed/unsigned int8/16 for X86_DARWIN. + Updated copyright info. + Handle one and two byte structs with special cif->flags. + * src/x86/ffitarget.h: Add special types for one and two byte structs. + Updated copyright info. + * src/x86/darwin.S (ffi_call_SYSV): Rewrite to use a jump table like + sysv.S + Remove code to pop args from the stack after call. + Special-case signed/unsigned for int8/16, one and two byte structs. + (ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8, + FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32, + FFI_TYPE_SINT32. + Updated copyright info. + +2007-12-08 David Daney + + * src/mips/n32.S (ffi_call_N32): Replace dadd with ADDU, dsub with + SUBU, add with ADDU and use smaller code sequences. + +2007-12-07 David Daney + + * src/mips/ffi.c (ffi_prep_cif_machdep): Handle long double return + type. + +2007-12-06 David Daney + + * include/ffi.h.in (FFI_SIZEOF_JAVA_RAW): Define if not already + defined. + (ffi_java_raw): New typedef. + (ffi_java_raw_call, ffi_java_ptrarray_to_raw, + ffi_java_raw_to_ptrarray): Change parameter types from ffi_raw to + ffi_java_raw. + (ffi_java_raw_closure) : Same. + (ffi_prep_java_raw_closure, ffi_prep_java_raw_closure_loc): Change + parameter types. + * src/java_raw_api.c (ffi_java_raw_size): Replace FFI_SIZEOF_ARG with + FFI_SIZEOF_JAVA_RAW. + (ffi_java_raw_to_ptrarray): Change type of raw to ffi_java_raw. + Replace FFI_SIZEOF_ARG with FFI_SIZEOF_JAVA_RAW. Use + sizeof(ffi_java_raw) for alignment calculations. + (ffi_java_ptrarray_to_raw): Same. + (ffi_java_rvalue_to_raw): Add special handling for FFI_TYPE_POINTER + if FFI_SIZEOF_JAVA_RAW == 4. + (ffi_java_raw_to_rvalue): Same. + (ffi_java_raw_call): Change type of raw to ffi_java_raw. + (ffi_java_translate_args): Same. + (ffi_prep_java_raw_closure_loc, ffi_prep_java_raw_closure): Change + parameter types. + * src/mips/ffitarget.h (FFI_SIZEOF_JAVA_RAW): Define for N32 ABI. + +2007-12-06 David Daney + + * src/mips/n32.S (ffi_closure_N32): Use 64-bit add instruction on + pointer values. + +2007-12-01 Andreas Tobler + + PR libffi/31937 + * src/powerpc/ffitarget.h: Introduce new ABI FFI_LINUX_SOFT_FLOAT. + Add local FFI_TYPE_UINT128 to handle soft-float long-double-128. + * src/powerpc/ffi.c: Distinguish between __NO_FPRS__ and not and + set the NUM_FPR_ARG_REGISTERS according to. + Add support for potential soft-float support under hard-float + architecture. + (ffi_prep_args_SYSV): Set NUM_FPR_ARG_REGISTERS to 0 in case of + FFI_LINUX_SOFT_FLOAT, handle float, doubles and long-doubles according + to the FFI_LINUX_SOFT_FLOAT ABI. + (ffi_prep_cif_machdep): Likewise. + (ffi_closure_helper_SYSV): Likewise. + * src/powerpc/ppc_closure.S: Make sure not to store float/double + on archs where __NO_FPRS__ is true. + Add FFI_TYPE_UINT128 support. + * src/powerpc/sysv.S: Add support for soft-float long-double-128. + Adjust copyright notice. + +2007-11-25 Andreas Tobler + + * src/closures.c: Move defintion of MAYBE_UNUSED from here to ... + * include/ffi_common.h: ... here. + Update copyright. + +2007-11-17 Andreas Tobler + + * src/powerpc/sysv.S: Load correct cr to compare if we have long double. + * src/powerpc/linux64.S: Likewise. + * src/powerpc/ffi.c: Add a comment to show which part goes into cr6. + * testsuite/libffi.call/return_ldl.c: New test. + +2007-09-04 + + * src/arm/sysv.S (UNWIND): New. + (Whole file): Conditionally compile unwinder directives. + * src/arm/sysv.S: Add unwinder directives. + + * src/arm/ffi.c (ffi_prep_args): Align structs by at least 4 bytes. + Only treat r0 as a struct address if we're actually returning a + struct by address. + Only copy the bytes that are actually within a struct. + (ffi_prep_cif_machdep): A Composite Type not larger than 4 bytes + is returned in r0, not passed by address. + (ffi_call): Allocate a word-sized temporary for the case where + a composite is returned in r0. + (ffi_prep_incoming_args_SYSV): Align as necessary. + +2007-08-05 Steven Newbury + + * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Use __clear_cache instead of + directly using the sys_cacheflush syscall. + +2007-07-27 Andrew Haley + + * src/arm/sysv.S (ffi_closure_SYSV): Add soft-float. + +2007-09-03 Maciej W. Rozycki + + * Makefile.am: Unify MIPS_IRIX and MIPS_LINUX into MIPS. + * configure.ac: Likewise. + * Makefile.in: Regenerate. + * include/Makefile.in: Likewise. + * testsuite/Makefile.in: Likewise. + * configure: Likewise. + +2007-08-24 David Daney + + * testsuite/libffi.call/return_sl.c: New test. + +2007-08-10 David Daney + + * testsuite/libffi.call/cls_multi_ushort.c, + testsuite/libffi.call/cls_align_uint16.c, + testsuite/libffi.call/nested_struct1.c, + testsuite/libffi.call/nested_struct3.c, + testsuite/libffi.call/cls_7_1_byte.c, + testsuite/libffi.call/nested_struct5.c, + testsuite/libffi.call/cls_double.c, + testsuite/libffi.call/nested_struct7.c, + testsuite/libffi.call/cls_sint.c, + testsuite/libffi.call/nested_struct9.c, + testsuite/libffi.call/cls_20byte1.c, + testsuite/libffi.call/cls_multi_sshortchar.c, + testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_3byte2.c, + testsuite/libffi.call/cls_multi_schar.c, + testsuite/libffi.call/cls_multi_uchar.c, + testsuite/libffi.call/cls_19byte.c, + testsuite/libffi.call/cls_9byte1.c, + testsuite/libffi.call/cls_align_float.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/problem1.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/cls_sshort.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/cls_align_double.c, + testsuite/libffi.call/nested_struct.c, + testsuite/libffi.call/cls_2byte.c, + testsuite/libffi.call/nested_struct10.c, + testsuite/libffi.call/cls_4byte.c, + testsuite/libffi.call/cls_6byte.c, + testsuite/libffi.call/cls_8byte.c, + testsuite/libffi.call/cls_multi_sshort.c, + testsuite/libffi.call/cls_align_sint16.c, + testsuite/libffi.call/cls_align_uint32.c, + testsuite/libffi.call/cls_20byte.c, + testsuite/libffi.call/cls_float.c, + testsuite/libffi.call/nested_struct2.c, + testsuite/libffi.call/cls_5_1_byte.c, + testsuite/libffi.call/nested_struct4.c, + testsuite/libffi.call/cls_24byte.c, + testsuite/libffi.call/nested_struct6.c, + testsuite/libffi.call/cls_64byte.c, + testsuite/libffi.call/nested_struct8.c, + testsuite/libffi.call/cls_uint.c, + testsuite/libffi.call/cls_multi_ushortchar.c, + testsuite/libffi.call/cls_schar.c, + testsuite/libffi.call/cls_uchar.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_1_1byte.c, + testsuite/libffi.call/cls_12byte.c, + testsuite/libffi.call/cls_3_1byte.c, + testsuite/libffi.call/cls_3byte1.c, + testsuite/libffi.call/cls_4_1byte.c, + testsuite/libffi.call/cls_6_1_byte.c, + testsuite/libffi.call/cls_16byte.c, + testsuite/libffi.call/cls_18byte.c, + testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/cls_9byte2.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/cls_ushort.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/cls_5byte.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_7byte.c, + testsuite/libffi.call/cls_align_sint32.c, + testsuite/libffi.special/unwindtest_ffi_call.cc, + testsuite/libffi.special/unwindtest.cc: Remove xfail for mips64*-*-*. + +2007-08-10 David Daney + + PR libffi/28313 + * configure.ac: Don't treat mips64 as a special case. + * Makefile.am (nodist_libffi_la_SOURCES): Add n32.S. + * configure: Regenerate + * Makefile.in: Ditto. + * fficonfig.h.in: Ditto. + * src/mips/ffitarget.h (REG_L, REG_S, SUBU, ADDU, SRL, LI): Indent. + (LA, EH_FRAME_ALIGN, FDE_ADDR_BYTES): New preprocessor macros. + (FFI_DEFAULT_ABI): Set for n64 case. + (FFI_CLOSURES, FFI_TRAMPOLINE_SIZE): Define for n32 and n64 cases. + * src/mips/n32.S (ffi_call_N32): Add debug macros and labels for FDE. + (ffi_closure_N32): New function. + (.eh_frame): New section + * src/mips/o32.S: Clean up comments. + (ffi_closure_O32): Pass ffi_closure parameter in $12. + * src/mips/ffi.c: Use FFI_MIPS_N32 instead of + _MIPS_SIM == _ABIN32 throughout. + (FFI_MIPS_STOP_HERE): New, use in place of + ffi_stop_here. + (ffi_prep_args): Use unsigned long to hold pointer values. Rewrite + to support n32/n64 ABIs. + (calc_n32_struct_flags): Rewrite. + (calc_n32_return_struct_flags): Remove unused variable. Reverse + position of flag bits. + (ffi_prep_cif_machdep): Rewrite n32 portion. + (ffi_call): Enable for n64. Add special handling for small structure + return values. + (ffi_prep_closure_loc): Add n32 and n64 support. + (ffi_closure_mips_inner_O32): Add cast to silence warning. + (copy_struct_N32, ffi_closure_mips_inner_N32): New functions. + +2007-08-08 David Daney + + * testsuite/libffi.call/ffitest.h (ffi_type_mylong): Remove definition. + * testsuite/libffi.call/cls_align_uint16.c (main): Use correct type + specifiers. + * testsuite/libffi.call/nested_struct1.c (main): Ditto. + * testsuite/libffi.call/cls_sint.c (main): Ditto. + * testsuite/libffi.call/nested_struct9.c (main): Ditto. + * testsuite/libffi.call/cls_20byte1.c (main): Ditto. + * testsuite/libffi.call/cls_9byte1.c (main): Ditto. + * testsuite/libffi.call/closure_fn1.c (main): Ditto. + * testsuite/libffi.call/closure_fn3.c (main): Ditto. + * testsuite/libffi.call/return_dbl2.c (main): Ditto. + * testsuite/libffi.call/cls_sshort.c (main): Ditto. + * testsuite/libffi.call/return_fl3.c (main): Ditto. + * testsuite/libffi.call/closure_fn5.c (main): Ditto. + * testsuite/libffi.call/nested_struct.c (main): Ditto. + * testsuite/libffi.call/nested_struct10.c (main): Ditto. + * testsuite/libffi.call/return_ll1.c (main): Ditto. + * testsuite/libffi.call/cls_8byte.c (main): Ditto. + * testsuite/libffi.call/cls_align_uint32.c (main): Ditto. + * testsuite/libffi.call/cls_align_sint16.c (main): Ditto. + * testsuite/libffi.call/cls_20byte.c (main): Ditto. + * testsuite/libffi.call/nested_struct2.c (main): Ditto. + * testsuite/libffi.call/cls_24byte.c (main): Ditto. + * testsuite/libffi.call/nested_struct6.c (main): Ditto. + * testsuite/libffi.call/cls_uint.c (main): Ditto. + * testsuite/libffi.call/cls_12byte.c (main): Ditto. + * testsuite/libffi.call/cls_16byte.c (main): Ditto. + * testsuite/libffi.call/closure_fn0.c (main): Ditto. + * testsuite/libffi.call/cls_9byte2.c (main): Ditto. + * testsuite/libffi.call/closure_fn2.c (main): Ditto. + * testsuite/libffi.call/return_dbl1.c (main): Ditto. + * testsuite/libffi.call/closure_fn4.c (main): Ditto. + * testsuite/libffi.call/closure_fn6.c (main): Ditto. + * testsuite/libffi.call/cls_align_sint32.c (main): Ditto. + +2007-08-07 Andrew Haley + + * src/x86/sysv.S (ffi_closure_raw_SYSV): Fix typo in previous + checkin. + +2007-08-06 Andrew Haley + + PR testsuite/32843 + * src/x86/sysv.S (ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8, + FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32, + FFI_TYPE_SINT32. + +2007-08-02 David Daney + + * testsuite/libffi.call/return_ul.c (main): Define return type as + ffi_arg. Use proper printf conversion specifier. + +2007-07-30 Andrew Haley + + PR testsuite/32843 + * src/x86/ffi.c (ffi_prep_cif_machdep): in x86 case, add code for + signed/unsigned int8/16. + * src/x86/sysv.S (ffi_call_SYSV): Rewrite to: + Use a jump table. + Remove code to pop args from the stack after call. + Special-case signed/unsigned int8/16. + * testsuite/libffi.call/return_sc.c (main): Revert. + +2007-07-26 Richard Guenther + + PR testsuite/32843 + * testsuite/libffi.call/return_sc.c (main): Verify call + result as signed char, not ffi_arg. + +2007-07-16 Rainer Orth + + * configure.ac (i?86-*-solaris2.1[0-9]): Set TARGET to X86_64. + * configure: Regenerate. + +2007-07-11 David Daney + + * src/mips/ffi.c: Don't include sys/cachectl.h. + (ffi_prep_closure_loc): Use __builtin___clear_cache() instead of + cacheflush(). + +2007-05-18 Aurelien Jarno + + * src/arm/ffi.c (ffi_prep_closure_loc): Renamed and ajusted + from (ffi_prep_closure): ... this. + (FFI_INIT_TRAMPOLINE): Adjust. + +2005-12-31 Phil Blundell + + * src/arm/ffi.c (ffi_prep_incoming_args_SYSV, + ffi_closure_SYSV_inner, ffi_prep_closure): New, add closure support. + * src/arm/sysv.S(ffi_closure_SYSV): Likewise. + * src/arm/ffitarget.h (FFI_TRAMPOLINE_SIZE): Likewise. + (FFI_CLOSURES): Enable closure support. + +2007-07-03 Andrew Haley + + * testsuite/libffi.call/cls_multi_ushort.c, + testsuite/libffi.call/cls_align_uint16.c, + testsuite/libffi.call/nested_struct1.c, + testsuite/libffi.call/nested_struct3.c, + testsuite/libffi.call/cls_7_1_byte.c, + testsuite/libffi.call/cls_double.c, + testsuite/libffi.call/nested_struct5.c, + testsuite/libffi.call/nested_struct7.c, + testsuite/libffi.call/cls_sint.c, + testsuite/libffi.call/nested_struct9.c, + testsuite/libffi.call/cls_20byte1.c, + testsuite/libffi.call/cls_multi_sshortchar.c, + testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_3byte2.c, + testsuite/libffi.call/cls_multi_schar.c, + testsuite/libffi.call/cls_multi_uchar.c, + testsuite/libffi.call/cls_19byte.c, + testsuite/libffi.call/cls_9byte1.c, + testsuite/libffi.call/cls_align_float.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/problem1.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/cls_sshort.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/cls_align_double.c, + testsuite/libffi.call/cls_2byte.c, + testsuite/libffi.call/nested_struct.c, + testsuite/libffi.call/nested_struct10.c, + testsuite/libffi.call/cls_4byte.c, + testsuite/libffi.call/cls_6byte.c, + testsuite/libffi.call/cls_8byte.c, + testsuite/libffi.call/cls_multi_sshort.c, + testsuite/libffi.call/cls_align_uint32.c, + testsuite/libffi.call/cls_align_sint16.c, + testsuite/libffi.call/cls_float.c, + testsuite/libffi.call/cls_20byte.c, + testsuite/libffi.call/cls_5_1_byte.c, + testsuite/libffi.call/nested_struct2.c, + testsuite/libffi.call/cls_24byte.c, + testsuite/libffi.call/nested_struct4.c, + testsuite/libffi.call/nested_struct6.c, + testsuite/libffi.call/cls_64byte.c, + testsuite/libffi.call/nested_struct8.c, + testsuite/libffi.call/cls_uint.c, + testsuite/libffi.call/cls_multi_ushortchar.c, + testsuite/libffi.call/cls_schar.c, + testsuite/libffi.call/cls_uchar.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_1_1byte.c, + testsuite/libffi.call/cls_12byte.c, + testsuite/libffi.call/cls_3_1byte.c, + testsuite/libffi.call/cls_3byte1.c, + testsuite/libffi.call/cls_4_1byte.c, + testsuite/libffi.call/cls_6_1_byte.c, + testsuite/libffi.call/cls_16byte.c, + testsuite/libffi.call/cls_18byte.c, + testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/cls_9byte2.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/cls_ushort.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/cls_5byte.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_7byte.c, + testsuite/libffi.call/cls_align_sint32.c, + testsuite/libffi.special/unwindtest_ffi_call.cc, + testsuite/libffi.special/unwindtest.cc: Enable for ARM. + +2007-07-05 H.J. Lu + + * aclocal.m4: Regenerated. + +2007-06-02 Paolo Bonzini + + * configure: Regenerate. + +2007-05-23 Steve Ellcey + + * Makefile.in: Regenerate. + * configure: Regenerate. + * aclocal.m4: Regenerate. + * include/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2007-05-10 Roman Zippel + + * src/m68k/ffi.c (ffi_prep_incoming_args_SYSV, + ffi_closure_SYSV_inner,ffi_prep_closure): New, add closure support. + * src/m68k/sysv.S(ffi_closure_SYSV,ffi_closure_struct_SYSV): Likewise. + * src/m68k/ffitarget.h (FFI_TRAMPOLINE_SIZE): Likewise. + (FFI_CLOSURES): Enable closure support. + +2007-05-10 Roman Zippel + + * configure.ac (HAVE_AS_CFI_PSEUDO_OP): New test. + * configure: Regenerate. + * fficonfig.h.in: Regenerate. + * src/m68k/sysv.S (CFI_STARTPROC,CFI_ENDPROC, + CFI_OFFSET,CFI_DEF_CFA): New macros. + (ffi_call_SYSV): Add callframe annotation. + +2007-05-10 Roman Zippel + + * src/m68k/ffi.c (ffi_prep_args,ffi_prep_cif_machdep): Fix + numerous test suite failures. + * src/m68k/sysv.S (ffi_call_SYSV): Likewise. + +2007-04-11 Paolo Bonzini + + * Makefile.am (EXTRA_DIST): Bring up to date. + * Makefile.in: Regenerate. + * src/frv/eabi.S: Remove RCS keyword. + +2007-04-06 Richard Henderson + + * configure.ac: Tidy target case. + (HAVE_LONG_DOUBLE): Allow the target to override. + * configure: Regenerate. + * include/ffi.h.in: Don't define ffi_type_foo if + LIBFFI_HIDE_BASIC_TYPES is defined. + (ffi_type_longdouble): If not HAVE_LONG_DOUBLE, define + to ffi_type_double. + * types.c (LIBFFI_HIDE_BASIC_TYPES): Define. + (FFI_TYPEDEF, ffi_type_void): Mark the data const. + (ffi_type_longdouble): Special case for Alpha. Don't define + if long double == double. + + * src/alpha/ffi.c (FFI_TYPE_LONGDOUBLE): Assert unique value. + (ffi_prep_cif_machdep): Handle it as the 128-bit type. + (ffi_call, ffi_closure_osf_inner): Likewise. + (ffi_closure_osf_inner): Likewise. Mark hidden. + (ffi_call_osf, ffi_closure_osf): Mark hidden. + * src/alpha/ffitarget.h (FFI_LAST_ABI): Tidy definition. + * src/alpha/osf.S (ffi_call_osf, ffi_closure_osf): Mark hidden. + (load_table): Handle 128-bit long double. + + * testsuite/libffi.call/float4.c: Add -mieee for alpha. + +2007-04-06 Tom Tromey + + PR libffi/31491: + * README: Fixed bug in example. + +2007-04-03 Jakub Jelinek + + * src/closures.c: Include sys/statfs.h. + (_GNU_SOURCE): Define on Linux. + (FFI_MMAP_EXEC_SELINUX): Define. + (selinux_enabled): New variable. + (selinux_enabled_check): New function. + (is_selinux_enabled): Define. + (dlmmap): Use it. + +2007-03-24 Uros Bizjak + + * testsuite/libffi.call/return_fl2.c (return_fl): Mark as static. + Use 'volatile float sum' to create sum of floats to avoid false + negative due to excess precision on ix86 targets. + (main): Ditto. + +2007-03-08 Alexandre Oliva + + * src/powerpc/ffi.c (flush_icache): Fix left-over from previous + patch. + (ffi_prep_closure_loc): Remove unneeded casts. Add needed ones. + +2007-03-07 Alexandre Oliva + + * include/ffi.h.in (ffi_closure_alloc, ffi_closure_free): New. + (ffi_prep_closure_loc): New. + (ffi_prep_raw_closure_loc): New. + (ffi_prep_java_raw_closure_loc): New. + * src/closures.c: New file. + * src/dlmalloc.c [FFI_MMAP_EXEC_WRIT] (struct malloc_segment): + Replace sflags with exec_offset. + [FFI_MMAP_EXEC_WRIT] (mmap_exec_offset, add_segment_exec_offset, + sub_segment_exec_offset): New macros. + (get_segment_flags, set_segment_flags, check_segment_merge): New + macros. + (is_mmapped_segment, is_extern_segment): Use get_segment_flags. + (add_segment, sys_alloc, create_mspace, create_mspace_with_base, + destroy_mspace): Use new macros. + (sys_alloc): Silence warning. + * Makefile.am (libffi_la_SOURCES): Add src/closures.c. + * Makefile.in: Rebuilt. + * src/prep_cif [FFI_CLOSURES] (ffi_prep_closure): Implement in + terms of ffi_prep_closure_loc. + * src/raw_api.c (ffi_prep_raw_closure_loc): Renamed and adjusted + from... + (ffi_prep_raw_closure): ... this. Re-implement in terms of the + renamed version. + * src/java_raw_api (ffi_prep_java_raw_closure_loc): Renamed and + adjusted from... + (ffi_prep_java_raw_closure): ... this. Re-implement in terms of + the renamed version. + * src/alpha/ffi.c (ffi_prep_closure_loc): Renamed from + (ffi_prep_closure): ... this. + * src/pa/ffi.c: Likewise. + * src/cris/ffi.c: Likewise. Adjust. + * src/frv/ffi.c: Likewise. + * src/ia64/ffi.c: Likewise. + * src/mips/ffi.c: Likewise. + * src/powerpc/ffi_darwin.c: Likewise. + * src/s390/ffi.c: Likewise. + * src/sh/ffi.c: Likewise. + * src/sh64/ffi.c: Likewise. + * src/sparc/ffi.c: Likewise. + * src/x86/ffi64.c: Likewise. + * src/x86/ffi.c: Likewise. + (FFI_INIT_TRAMPOLINE): Adjust. + (ffi_prep_raw_closure_loc): Renamed and adjusted from... + (ffi_prep_raw_closure): ... this. + * src/powerpc/ffi.c (ffi_prep_closure_loc): Renamed from + (ffi_prep_closure): ... this. + (flush_icache): Adjust. + +2007-03-07 Alexandre Oliva + + * src/dlmalloc.c: New file, imported version 2.8.3 of Doug + Lea's malloc. + +2007-03-01 Brooks Moses + + * Makefile.am: Add dummy install-pdf target. + * Makefile.in: Regenerate + +2007-02-13 Andreas Krebbel + + * src/s390/ffi.c (ffi_prep_args, ffi_prep_cif_machdep, + ffi_closure_helper_SYSV): Add long double handling. + +2007-02-02 Jakub Jelinek + + * src/powerpc/linux64.S (ffi_call_LINUX64): Move restore of r2 + immediately after bctrl instruction. + +2007-01-18 Alexandre Oliva + + * Makefile.am (all-recursive, install-recursive, + mostlyclean-recursive, clean-recursive, distclean-recursive, + maintainer-clean-recursive): Add missing targets. + * Makefile.in: Rebuilt. + +2006-12-14 Andreas Tobler + + * configure.ac: Add TARGET for x86_64-*-darwin*. + * Makefile.am (nodist_libffi_la_SOURCES): Add rules for 64-bit sources + for X86_DARWIN. + * src/x86/ffitarget.h: Set trampoline size for x86_64-*-darwin*. + * src/x86/darwin64.S: New file for x86_64-*-darwin* support. + * configure: Regenerate. + * Makefile.in: Regenerate. + * include/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + * testsuite/libffi.special/unwindtest_ffi_call.cc: New test case for + ffi_call only. + +2006-12-13 Andreas Tobler + + * aclocal.m4: Regenerate with aclocal -I .. as written in the + Makefile.am. + +2006-10-31 Geoffrey Keating + + * src/powerpc/ffi_darwin.c (darwin_adjust_aggregate_sizes): New. + (ffi_prep_cif_machdep): Call darwin_adjust_aggregate_sizes for + Darwin. + * testsuite/libffi.call/nested_struct4.c: Remove Darwin XFAIL. + * testsuite/libffi.call/nested_struct6.c: Remove Darwin XFAIL. + +2006-10-10 Paolo Bonzini + Sandro Tolaini + + * configure.ac [i*86-*-darwin*]: Set X86_DARWIN symbol and + conditional. + * configure: Regenerated. + * Makefile.am (nodist_libffi_la_SOURCES) [X86_DARWIN]: New case. + (EXTRA_DIST): Add src/x86/darwin.S. + * Makefile.in: Regenerated. + * include/Makefile.in: Regenerated. + * testsuite/Makefile.in: Regenerated. + + * src/x86/ffi.c (ffi_prep_cif_machdep) [X86_DARWIN]: Treat like + X86_WIN32, and additionally align stack to 16 bytes. + * src/x86/darwin.S: New, based on sysv.S. + * src/prep_cif.c (ffi_prep_cif) [X86_DARWIN]: Align > 8-byte structs. + +2006-09-12 David Daney + + PR libffi/23935 + * include/Makefile.am: Install both ffi.h and ffitarget.h in + $(libdir)/gcc/$(target_alias)/$(gcc_version)/include. + * aclocal.m4: Regenerated for automake 1.9.6. + * Makefile.in: Regenerated. + * include/Makefile.in: Regenerated. + * testsuite/Makefile.in: Regenerated. + +2006-08-17 Andreas Tobler + + * include/ffi_common.h (struct): Revert accidental commit. + +2006-08-15 Andreas Tobler + + * include/ffi_common.h: Remove lint directives. + * include/ffi.h.in: Likewise. + +2006-07-25 Torsten Schoenfeld + + * include/ffi.h.in (ffi_type_ulong, ffi_type_slong): Define correctly + for 32-bit architectures. + * testsuite/libffi.call/return_ul.c: New test case. + +2006-07-19 David Daney + + * testsuite/libffi.call/closure_fn6.c: Remove xfail for mips, + xfail remains for mips64. + +2006-05-23 Carlos O'Donell + + * Makefile.am: Add install-html target. Add install-html to .PHONY + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * include/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2006-05-18 John David Anglin + + * pa/ffi.c (ffi_prep_args_pa32): Load floating point arguments from + stack slot. + +2006-04-22 Andreas Tobler + + * README: Remove notice about 'Crazy Comments'. + * src/debug.c: Remove lint directives. Cleanup white spaces. + * src/java_raw_api.c: Likewise. + * src/prep_cif.c: Likewise. + * src/raw_api.c: Likewise. + * src/ffitest.c: Delete. No longer needed, all test cases migrated + to the testsuite. + * src/arm/ffi.c: Remove lint directives. + * src/m32r/ffi.c: Likewise. + * src/pa/ffi.c: Likewise. + * src/powerpc/ffi.c: Likewise. + * src/powerpc/ffi_darwin.c: Likewise. + * src/sh/ffi.c: Likewise. + * src/sh64/ffi.c: Likewise. + * src/x86/ffi.c: Likewise. + * testsuite/libffi.call/float2.c: Likewise. + * testsuite/libffi.call/promotion.c: Likewise. + * testsuite/libffi.call/struct1.c: Likewise. + +2006-04-13 Andreas Tobler + + * src/pa/hpux32.S: Correct unwind offset calculation for + ffi_closure_pa32. + * src/pa/linux.S: Likewise. + +2006-04-12 James E Wilson + + PR libgcj/26483 + * src/ia64/ffi.c (stf_spill, ldf_fill): Rewrite as macros. + (hfa_type_load): Call stf_spill. + (hfa_type_store): Call ldf_fill. + (ffi_call): Adjust calls to above routines. Add local temps for + macro result. + +2006-04-10 Matthias Klose + + * testsuite/lib/libffi-dg.exp (libffi-init): Recognize multilib + directory names containing underscores. + +2006-04-07 James E Wilson + + * testsuite/libffi.call/float4.c: New testcase. + +2006-04-05 John David Anglin + Andreas Tobler + + * Makefile.am: Add PA_HPUX port. + * Makefile.in: Regenerate. + * include/Makefile.in: Likewise. + * testsuite/Makefile.in: Likewise. + * configure.ac: Add PA_HPUX rules. + * configure: Regenerate. + * src/pa/ffitarget.h: Rename linux target to PA_LINUX. + Add PA_HPUX and PA64_HPUX. + Rename FFI_LINUX ABI to FFI_PA32 ABI. + (FFI_TRAMPOLINE_SIZE): Define for 32-bit HP-UX targets. + (FFI_TYPE_SMALL_STRUCT2): Define. + (FFI_TYPE_SMALL_STRUCT4): Likewise. + (FFI_TYPE_SMALL_STRUCT8): Likewise. + (FFI_TYPE_SMALL_STRUCT3): Redefine. + (FFI_TYPE_SMALL_STRUCT5): Likewise. + (FFI_TYPE_SMALL_STRUCT6): Likewise. + (FFI_TYPE_SMALL_STRUCT7): Likewise. + * src/pa/ffi.c (ROUND_DOWN): Delete. + (fldw, fstw, fldd, fstd): Use '__asm__'. + (ffi_struct_type): Add support for FFI_TYPE_SMALL_STRUCT2, + FFI_TYPE_SMALL_STRUCT4 and FFI_TYPE_SMALL_STRUCT8. + (ffi_prep_args_LINUX): Rename to ffi_prep_args_pa32. Update comment. + Simplify incrementing of stack slot variable. Change type of local + 'n' to unsigned int. + (ffi_size_stack_LINUX): Rename to ffi_size_stack_pa32. Handle long + double on PA_HPUX. + (ffi_prep_cif_machdep): Likewise. + (ffi_call): Likewise. + (ffi_closure_inner_LINUX): Rename to ffi_closure_inner_pa32. Change + return type to ffi_status. Simplify incrementing of stack slot + variable. Only copy floating point argument registers when PA_LINUX + is true. Reformat debug statement. + Add support for FFI_TYPE_SMALL_STRUCT2, FFI_TYPE_SMALL_STRUCT4 and + FFI_TYPE_SMALL_STRUCT8. + (ffi_closure_LINUX): Rename to ffi_closure_pa32. Add 'extern' to + declaration. + (ffi_prep_closure): Make linux trampoline conditional on PA_LINUX. + Add nops to cache flush. Add trampoline for PA_HPUX. + * src/pa/hpux32.S: New file. + * src/pa/linux.S (ffi_call_LINUX): Rename to ffi_call_pa32. Rename + ffi_prep_args_LINUX to ffi_prep_args_pa32. + Localize labels. Add support for 2, 4 and 8-byte small structs. Handle + unaligned destinations in 3, 5, 6 and 7-byte small structs. Order + argument type checks so that common argument types appear first. + (ffi_closure_LINUX): Rename to ffi_closure_pa32. Rename + ffi_closure_inner_LINUX to ffi_closure_inner_pa32. + +2006-03-24 Alan Modra + + * src/powerpc/ffitarget.h (enum ffi_abi): Add FFI_LINUX. Default + for 32-bit using IBM extended double format. Fix FFI_LAST_ABI. + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Handle linux variant of + FFI_TYPE_LONGDOUBLE. + (ffi_prep_args64): Assert using IBM extended double. + (ffi_prep_cif_machdep): Don't munge FFI_TYPE_LONGDOUBLE type. + Handle FFI_LINUX FFI_TYPE_LONGDOUBLE return and args. + (ffi_call): Handle FFI_LINUX. + (ffi_closure_helper_SYSV): Non FFI_LINUX long double return needs + gpr3 return pointer as for struct return. Handle FFI_LINUX + FFI_TYPE_LONGDOUBLE return and args. Don't increment "nf" + unnecessarily. + * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Load both f1 and f2 + for FFI_TYPE_LONGDOUBLE. Move epilogue insns into case table. + Don't use r6 as pointer to results, instead use sp offset. Don't + make a special call to load lr with case table address, instead + use offset from previous call. + * src/powerpc/sysv.S (ffi_call_SYSV): Save long double return. + * src/powerpc/linux64.S (ffi_call_LINUX64): Simplify long double + return. + +2006-03-15 Kaz Kojima + + * src/sh64/ffi.c (ffi_prep_cif_machdep): Handle float arguments + passed with FP registers correctly. + (ffi_closure_helper_SYSV): Likewise. + * src/sh64/sysv.S: Likewise. + +2006-03-01 Andreas Tobler + + * testsuite/libffi.special/unwindtest.cc (closure_test_fn): Mark cif, + args and userdata unused. + (closure_test_fn1): Mark cif and userdata unused. + (main): Remove unused res. + +2006-02-28 Andreas Tobler + + * testsuite/libffi.call/call.exp: Adjust FSF address. Add test runs for + -O2, -O3, -Os and the warning flags -W -Wall. + * testsuite/libffi.special/special.exp: Likewise. + * testsuite/libffi.call/ffitest.h: Add an __UNUSED__ macro to mark + unused parameter unused for gcc or else do nothing. + * testsuite/libffi.special/ffitestcxx.h: Likewise. + * testsuite/libffi.call/cls_12byte.c (cls_struct_12byte_gn): Mark cif + and userdata unused. + * testsuite/libffi.call/cls_16byte.c (cls_struct_16byte_gn): Likewise. + * testsuite/libffi.call/cls_18byte.c (cls_struct_18byte_gn): Likewise. + * testsuite/libffi.call/cls_19byte.c (cls_struct_19byte_gn): Likewise. + * testsuite/libffi.call/cls_1_1byte.c (cls_struct_1_1byte_gn): Likewise. + * testsuite/libffi.call/cls_20byte.c (cls_struct_20byte_gn): Likewise. + * testsuite/libffi.call/cls_20byte1.c (cls_struct_20byte_gn): Likewise. + * testsuite/libffi.call/cls_24byte.c (cls_struct_24byte_gn): Likewise. + * testsuite/libffi.call/cls_2byte.c (cls_struct_2byte_gn): Likewise. + * testsuite/libffi.call/cls_3_1byte.c (cls_struct_3_1byte_gn): Likewise. + * testsuite/libffi.call/cls_3byte1.c (cls_struct_3byte_gn): Likewise. + * testsuite/libffi.call/cls_3byte2.c (cls_struct_3byte_gn1): Likewise. + * testsuite/libffi.call/cls_4_1byte.c (cls_struct_4_1byte_gn): Likewise. + * testsuite/libffi.call/cls_4byte.c (cls_struct_4byte_gn): Likewise. + * testsuite/libffi.call/cls_5_1_byte.c (cls_struct_5byte_gn): Likewise. + * testsuite/libffi.call/cls_5byte.c (cls_struct_5byte_gn): Likewise. + * testsuite/libffi.call/cls_64byte.c (cls_struct_64byte_gn): Likewise. + * testsuite/libffi.call/cls_6_1_byte.c (cls_struct_6byte_gn): Likewise. + * testsuite/libffi.call/cls_6byte.c (cls_struct_6byte_gn): Likewise. + * testsuite/libffi.call/cls_7_1_byte.c (cls_struct_7byte_gn): Likewise. + * testsuite/libffi.call/cls_7byte.c (cls_struct_7byte_gn): Likewise. + * testsuite/libffi.call/cls_8byte.c (cls_struct_8byte_gn): Likewise. + * testsuite/libffi.call/cls_9byte1.c (cls_struct_9byte_gn): Likewise. + * testsuite/libffi.call/cls_9byte2.c (cls_struct_9byte_gn): Likewise. + * testsuite/libffi.call/cls_align_double.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_float.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_longdouble.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_pointer.c (cls_struct_align_fn): Cast + void* to avoid compiler warning. + (main): Likewise. + (cls_struct_align_gn): Mark cif and userdata unused. + * testsuite/libffi.call/cls_align_sint16.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_sint32.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_sint64.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_uint16.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_align_uint32.c (cls_struct_align_gn): + Likewise. + * testsuite/libffi.call/cls_double.c (cls_ret_double_fn): Likewise. + * testsuite/libffi.call/cls_float.c (cls_ret_float_fn): Likewise. + * testsuite/libffi.call/cls_multi_schar.c (test_func_gn): Mark cif and + data unused. + (main): Cast res_call to silence gcc. + * testsuite/libffi.call/cls_multi_sshort.c (test_func_gn): Mark cif and + data unused. + (main): Cast res_call to silence gcc. + * testsuite/libffi.call/cls_multi_sshortchar.c (test_func_gn): Mark cif + and data unused. + (main): Cast res_call to silence gcc. + * testsuite/libffi.call/cls_multi_uchar.c (test_func_gn): Mark cif and + data unused. + (main): Cast res_call to silence gcc. + * testsuite/libffi.call/cls_multi_ushort.c (test_func_gn): Mark cif and + data unused. + (main): Cast res_call to silence gcc. + * testsuite/libffi.call/cls_multi_ushortchar.c (test_func_gn): Mark cif + and data unused. + (main): Cast res_call to silence gcc. + * testsuite/libffi.call/cls_schar.c (cls_ret_schar_fn): Mark cif and + userdata unused. + (cls_ret_schar_fn): Cast printf parameter to silence gcc. + * testsuite/libffi.call/cls_sint.c (cls_ret_sint_fn): Mark cif and + userdata unused. + (cls_ret_sint_fn): Cast printf parameter to silence gcc. + * testsuite/libffi.call/cls_sshort.c (cls_ret_sshort_fn): Mark cif and + userdata unused. + (cls_ret_sshort_fn): Cast printf parameter to silence gcc. + * testsuite/libffi.call/cls_uchar.c (cls_ret_uchar_fn): Mark cif and + userdata unused. + (cls_ret_uchar_fn): Cast printf parameter to silence gcc. + * testsuite/libffi.call/cls_uint.c (cls_ret_uint_fn): Mark cif and + userdata unused. + (cls_ret_uint_fn): Cast printf parameter to silence gcc. + * testsuite/libffi.call/cls_ulonglong.c (cls_ret_ulonglong_fn): Mark cif + and userdata unused. + * testsuite/libffi.call/cls_ushort.c (cls_ret_ushort_fn): Mark cif and + userdata unused. + (cls_ret_ushort_fn): Cast printf parameter to silence gcc. + * testsuite/libffi.call/float.c (floating): Remove unused parameter e. + * testsuite/libffi.call/float1.c (main): Remove unused variable i. + Cleanup white spaces. + * testsuite/libffi.call/negint.c (checking): Remove unused variable i. + * testsuite/libffi.call/nested_struct.c (cls_struct_combined_gn): Mark + cif and userdata unused. + * testsuite/libffi.call/nested_struct1.c (cls_struct_combined_gn): + Likewise. + * testsuite/libffi.call/nested_struct10.c (B_gn): Likewise. + * testsuite/libffi.call/nested_struct2.c (B_fn): Adjust printf + formatters to silence gcc. + (B_gn): Mark cif and userdata unused. + * testsuite/libffi.call/nested_struct3.c (B_gn): Mark cif and userdata + unused. + * testsuite/libffi.call/nested_struct4.c: Mention related PR. + (B_gn): Mark cif and userdata unused. + * testsuite/libffi.call/nested_struct5.c (B_gn): Mark cif and userdata + unused. + * testsuite/libffi.call/nested_struct6.c: Mention related PR. + (B_gn): Mark cif and userdata unused. + * testsuite/libffi.call/nested_struct7.c (B_gn): Mark cif and userdata + unused. + * testsuite/libffi.call/nested_struct8.c (B_gn): Likewise. + * testsuite/libffi.call/nested_struct9.c (B_gn): Likewise. + * testsuite/libffi.call/problem1.c (stub): Likewise. + * testsuite/libffi.call/pyobjc-tc.c (main): Cast the result to silence + gcc. + * testsuite/libffi.call/return_fl2.c (return_fl): Add the note mentioned + in the last commit for this test case in the test case itself. + * testsuite/libffi.call/closure_fn0.c (closure_test_fn0): Mark cif as + unused. + * testsuite/libffi.call/closure_fn1.c (closure_test_fn1): Likewise. + * testsuite/libffi.call/closure_fn2.c (closure_test_fn2): Likewise. + * testsuite/libffi.call/closure_fn3.c (closure_test_fn3): Likewise. + * testsuite/libffi.call/closure_fn4.c (closure_test_fn0): Likewise. + * testsuite/libffi.call/closure_fn5.c (closure_test_fn5): Likewise. + * testsuite/libffi.call/closure_fn6.c (closure_test_fn0): Likewise. + +2006-02-22 Kaz Kojima + + * src/sh/sysv.S: Fix register numbers in the FDE for + ffi_closure_SYSV. + +2006-02-20 Andreas Tobler + + * testsuite/libffi.call/return_fl2.c (return_fl): Remove static + declaration to avoid a false negative on ix86. See PR323. + +2006-02-18 Kaz Kojima + + * src/sh/ffi.c (ffi_closure_helper_SYSV): Remove unused variable + and cast integer to void * if needed. Update the pointer to + the FP register saved area correctly. + +2006-02-17 Andreas Tobler + + * testsuite/libffi.call/nested_struct6.c: XFAIL this test until PR25630 + is fixed. + * testsuite/libffi.call/nested_struct4.c: Likewise. + +2006-02-16 Andreas Tobler + + * testsuite/libffi.call/return_dbl.c: New test case. + * testsuite/libffi.call/return_dbl1.c: Likewise. + * testsuite/libffi.call/return_dbl2.c: Likewise. + * testsuite/libffi.call/return_fl.c: Likewise. + * testsuite/libffi.call/return_fl1.c: Likewise. + * testsuite/libffi.call/return_fl2.c: Likewise. + * testsuite/libffi.call/return_fl3.c: Likewise. + * testsuite/libffi.call/closure_fn6.c: Likewise. + + * testsuite/libffi.call/nested_struct2.c: Remove ffi_type_mylong + definition. + * testsuite/libffi.call/ffitest.h: Add ffi_type_mylong definition + here to be used by other test cases too. + + * testsuite/libffi.call/nested_struct10.c: New test case. + * testsuite/libffi.call/nested_struct9.c: Likewise. + * testsuite/libffi.call/nested_struct8.c: Likewise. + * testsuite/libffi.call/nested_struct7.c: Likewise. + * testsuite/libffi.call/nested_struct6.c: Likewise. + * testsuite/libffi.call/nested_struct5.c: Likewise. + * testsuite/libffi.call/nested_struct4.c: Likewise. + +2006-01-21 Andreas Tobler + + * configure.ac: Enable libffi for sparc64-*-freebsd*. + * configure: Rebuilt. + +2006-01-18 Jakub Jelinek + + * src/powerpc/sysv.S (smst_two_register): Don't call __ashldi3, + instead do the shifting inline. + * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Don't compute %r5 + shift count unconditionally. Simplify load sequences for 1, 2, 3, 4 + and 8 byte structs, for the remaining struct sizes don't call + __lshrdi3, instead do the shifting inline. + +2005-12-07 Thiemo Seufer + + * src/mips/ffitarget.h: Remove obsolete sgidefs.h include. Add + missing parentheses. + * src/mips/o32.S (ffi_call_O32): Code formatting. Define + and use A3_OFF, FP_OFF, RA_OFF. Micro-optimizations. + (ffi_closure_O32): Likewise, but with newly defined A3_OFF2, + A2_OFF2, A1_OFF2, A0_OFF2, RA_OFF2, FP_OFF2, S0_OFF2, GP_OFF2, + V1_OFF2, V0_OFF2, FA_1_1_OFF2, FA_1_0_OFF2, FA_0_1_OFF2, + FA_0_0_OFF2. + * src/mips/ffi.c (ffi_prep_args): Code formatting. Fix + endianness bugs. + (ffi_prep_closure): Improve trampoline instruction scheduling. + (ffi_closure_mips_inner_O32): Fix endianness bugs. + +2005-12-03 Alan Modra + + * src/powerpc/ffi.c: Formatting. + (ffi_prep_args_SYSV): Avoid possible aliasing problems by using unions. + (ffi_prep_args64): Likewise. + +2005-09-30 Geoffrey Keating + + * testsuite/lib/libffi-dg.exp (libffi_target_compile): For + darwin, use -shared-libgcc not -lgcc_s, and explain why. + +2005-09-26 Tom Tromey + + * testsuite/libffi.call/float1.c (value_type): New typedef. + (CANARY): New define. + (main): Check for result buffer overflow. + * src/powerpc/linux64.S: Handle linux64 long double returns. + * src/powerpc/ffi.c (FLAG_RETURNS_128BITS): New constant. + (ffi_prep_cif_machdep): Handle linux64 long double returns. + +2005-08-25 Alan Modra + + PR target/23404 + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Correct placement of stack + homed fp args. + (ffi_status ffi_prep_cif_machdep): Correct stack sizing for same. + +2005-08-11 Jakub Jelinek + + * configure.ac (HAVE_HIDDEN_VISIBILITY_ATTRIBUTE): New test. + (AH_BOTTOM): Add FFI_HIDDEN definition. + * configure: Rebuilt. + * fficonfig.h.in: Rebuilt. + * src/powerpc/ffi.c (hidden): Remove. + (ffi_closure_LINUX64, ffi_prep_args64, ffi_call_LINUX64, + ffi_closure_helper_LINUX64): Use FFI_HIDDEN instead of hidden. + * src/powerpc/linux64_closure.S (ffi_closure_LINUX64, + .ffi_closure_LINUX64): Use FFI_HIDDEN instead of .hidden. + * src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV): Remove, + add FFI_HIDDEN to its prototype. + (ffi_closure_SYSV_inner): New. + * src/x86/sysv.S (ffi_closure_SYSV, ffi_closure_raw_SYSV): New. + * src/x86/win32.S (ffi_closure_SYSV, ffi_closure_raw_SYSV): New. + +2005-08-10 Alfred M. Szmidt + + PR libffi/21819: + * configure: Rebuilt. + * configure.ac: Handle i*86-*-gnu*. + +2005-08-09 Jakub Jelinek + + * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Use + DW_CFA_offset_extended_sf rather than + DW_CFA_GNU_negative_offset_extended. + * src/powerpc/sysv.S (ffi_call_SYSV): Likewise. + +2005-07-22 SUGIOKA Toshinobu + + * src/sh/sysv.S (ffi_call_SYSV): Stop argument popping correctly + on sh3. + (ffi_closure_SYSV): Change the stack layout for sh3 struct argument. + * src/sh/ffi.c (ffi_prep_args): Fix sh3 argument copy, when it is + partially on register. + (ffi_closure_helper_SYSV): Likewise. + (ffi_prep_cif_machdep): Don't set too many cif->flags. + +2005-07-20 Kaz Kojima + + * src/sh/ffi.c (ffi_call): Handle small structures correctly. + Remove empty line. + * src/sh64/ffi.c (simple_type): Remove. + (return_type): Handle small structures correctly. + (ffi_prep_args): Likewise. + (ffi_call): Likewise. + (ffi_closure_helper_SYSV): Likewise. + * src/sh64/sysv.S (ffi_call_SYSV): Handle 1, 2 and 4-byte return. + Emit position independent code if PIC and remove wrong datalabel + prefixes from EH data. + +2005-07-19 Andreas Tobler + + * Makefile.am (nodist_libffi_la_SOURCES): Add POWERPC_FREEBSD. + * Makefile.in: Regenerate. + * include/Makefile.in: Likewise. + * testsuite/Makefile.in: Likewise. + * configure.ac: Add POWERPC_FREEBSD rules. + * configure: Regenerate. + * src/powerpc/ffitarget.h: Add POWERPC_FREEBSD rules. + (FFI_SYSV_TYPE_SMALL_STRUCT): Define. + * src/powerpc/ffi.c: Add flags to handle small structure returns + in ffi_call_SYSV. + (ffi_prep_cif_machdep): Handle small structures for SYSV 4 ABI. + Aka FFI_SYSV. + (ffi_closure_helper_SYSV): Likewise. + * src/powerpc/ppc_closure.S: Add return types for small structures. + * src/powerpc/sysv.S: Add bits to handle small structures for + final SYSV 4 ABI. + +2005-07-10 Andreas Tobler + + * testsuite/libffi.call/cls_5_1_byte.c: New test file. + * testsuite/libffi.call/cls_6_1_byte.c: Likewise. + * testsuite/libffi.call/cls_7_1_byte.c: Likewise. + +2005-07-05 Randolph Chung + + * src/pa/ffi.c (ffi_struct_type): Rename FFI_TYPE_SMALL_STRUCT1 + as FFI_TYPE_SMALL_STRUCT3. Break out handling for 5-7 byte + structures. Kill compilation warnings. + (ffi_closure_inner_LINUX): Print return values as hex in debug + message. Rename FFI_TYPE_SMALL_STRUCT1 as FFI_TYPE_SMALL_STRUCT3. + Properly handle 5-7 byte structure returns. + * src/pa/ffitarget.h (FFI_TYPE_SMALL_STRUCT1) + (FFI_TYPE_SMALL_STRUCT2): Remove. + (FFI_TYPE_SMALL_STRUCT3, FFI_TYPE_SMALL_STRUCT5) + (FFI_TYPE_SMALL_STRUCT6, FFI_TYPE_SMALL_STRUCT7): Define. + * src/pa/linux.S: Mark source file as using PA1.1 assembly. + (checksmst1, checksmst2): Remove. + (checksmst3): Optimize handling of 3-byte struct returns. + (checksmst567): Properly handle 5-7 byte struct returns. + +2005-06-15 Rainer Orth + + PR libgcj/21943 + * src/mips/n32.S: Enforce PIC code. + * src/mips/o32.S: Likewise. + +2005-06-15 Rainer Orth + + * configure.ac: Treat i*86-*-solaris2.10 and up as X86_64. + * configure: Regenerate. + +2005-06-01 Alan Modra + + * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Don't use JUMPTARGET + to call ffi_closure_helper_SYSV. Append @local instead. + * src/powerpc/sysv.S (ffi_call_SYSV): Likewise for ffi_prep_args_SYSV. + +2005-05-17 Kelley Cook + + * configure.ac: Use AC_C_BIGENDIAN instead of AC_C_BIGENDIAN_CROSS. + Use AC_CHECK_SIZEOF instead of AC_COMPILE_CHECK_SIZEOF. + * Makefile.am (ACLOCAL_AMFLAGS): Remove -I ../config. + * aclocal.m4, configure, fficonfig.h.in, Makefile.in, + include/Makefile.in, testsuite/Makefile.in: Regenerate. + +2005-05-09 Mike Stump + + * configure: Regenerate. + +2005-05-08 Richard Henderson + + PR libffi/21285 + * src/alpha/osf.S: Update unwind into to match code. + +2005-05-04 Andreas Degert + Richard Henderson + + * src/x86/ffi64.c (ffi_prep_cif_machdep): Save sse-used flag in + bit 11 of flags. + (ffi_call): Mask return type field. Pass ssecount to ffi_call_unix64. + (ffi_prep_closure): Set carry bit if sse-used flag set. + * src/x86/unix64.S (ffi_call_unix64): Add ssecount argument. + Only load sse registers if ssecount non-zero. + (ffi_closure_unix64): Only save sse registers if carry set on entry. + +2005-04-29 Ralf Corsepius + + * configure.ac: Add i*86-*-rtems*, sparc*-*-rtems*, + powerpc-*rtems*, arm*-*-rtems*, sh-*-rtems*. + * configure: Regenerate. + +2005-04-20 Hans-Peter Nilsson + + * testsuite/lib/libffi-dg.exp (libffi-dg-test-1): In regsub use, + have Tcl8.3-compatible intermediate variable. + +2005-04-18 Simon Posnjak + Hans-Peter Nilsson + + * Makefile.am: Add CRIS support. + * configure.ac: Likewise. + * Makefile.in, configure, testsuite/Makefile.in, + include/Makefile.in: Regenerate. + * src/cris: New directory. + * src/cris/ffi.c, src/cris/sysv.S, src/cris/ffitarget.h: New files. + * src/prep_cif.c (ffi_prep_cif): Wrap in #ifndef __CRIS__. + + * testsuite/lib/libffi-dg.exp (libffi-dg-test-1): Replace \n with + \r?\n in output tests. + +2005-04-12 Mike Stump + + * configure: Regenerate. + +2005-03-30 Hans Boehm + + * src/ia64/ffitarget.h (ffi_arg): Use long long instead of DI. + +2005-03-30 Steve Ellcey + + * src/ia64/ffitarget.h (ffi_arg) ADD DI attribute. + (ffi_sarg) Ditto. + * src/ia64/unix.S (ffi_closure_unix): Extend gp + to 64 bits in ILP32 mode. + Load 64 bits even for short data. + +2005-03-23 Mike Stump + + * src/powerpc/darwin.S: Update for -m64 multilib. + * src/powerpc/darwin_closure.S: Likewise. + +2005-03-21 Zack Weinberg + + * configure.ac: Do not invoke TL_AC_GCC_VERSION. + Do not set tool_include_dir. + * aclocal.m4, configure, Makefile.in, testsuite/Makefile.in: + Regenerate. + * include/Makefile.am: Set gcc_version and toollibffidir. + * include/Makefile.in: Regenerate. + +2005-02-22 Andrew Haley + + * src/powerpc/ffi.c (ffi_prep_cif_machdep): Bump alignment to + odd-numbered register pairs for 64-bit integer types. + +2005-02-23 Andreas Tobler + + PR libffi/20104 + * testsuite/libffi.call/return_ll1.c: New test case. + +2005-02-11 Janis Johnson + + * testsuite/libffi.call/cls_align_longdouble.c: Remove dg-options. + * testsuite/libffi.call/float.c: Ditto. + * testsuite/libffi.call/float2.c: Ditto. + * testsuite/libffi.call/float3.c: Ditto. + +2005-02-08 Andreas Tobler + + * src/frv/ffitarget.h: Remove PPC stuff which does not belong to frv. + +2005-01-12 Eric Botcazou + + * testsuite/libffi.special/special.exp (cxx_options): Add + -shared-libgcc. + +2004-12-31 Richard Henderson + + * src/types.c (FFI_AGGREGATE_TYPEDEF): Remove. + (FFI_TYPEDEF): Rename from FFI_INTEGRAL_TYPEDEF. Replace size and + offset parameters with a type parameter; deduce size and structure + alignment. Update all users. + +2004-12-31 Richard Henderson + + * src/types.c (FFI_TYPE_POINTER): Define with sizeof. + (FFI_TYPE_LONGDOUBLE): Fix for ia64. + * src/ia64/ffitarget.h (struct ffi_ia64_trampoline_struct): Move + into ffi_prep_closure. + * src/ia64/ia64_flags.h, src/ia64/ffi.c, src/ia64/unix.S: Rewrite + from scratch. + +2004-12-27 Richard Henderson + + * src/x86/unix64.S: Fix typo in unwind info. + +2004-12-25 Richard Henderson + + * src/x86/ffi64.c (struct register_args): Rename from stackLayout. + (enum x86_64_reg_class): Add X86_64_COMPLEX_X87_CLASS. + (merge_classes): Check for it. + (SSE_CLASS_P): New. + (classify_argument): Pass byte_offset by value; perform all updates + inside struct case. + (examine_argument): Add classes argument; handle + X86_64_COMPLEX_X87_CLASS. + (ffi_prep_args): Merge into ... + (ffi_call): ... here. Share stack frame with ffi_call_unix64. + (ffi_prep_cif_machdep): Setup cif->flags for proper structure return. + (ffi_fill_return_value): Remove. + (ffi_prep_closure): Remove dead assert. + (ffi_closure_unix64_inner): Rename from ffi_closure_UNIX64_inner. + Rewrite to use struct register_args instead of va_list. Create + flags for handling structure returns. + * src/x86/unix64.S: Remove dead strings. + (ffi_call_unix64): Rename from ffi_call_UNIX64. Rewrite to share + stack frame with ffi_call. Handle structure returns properly. + (float2sse, floatfloat2sse, double2sse): Remove. + (sse2float, sse2double, sse2floatfloat): Remove. + (ffi_closure_unix64): Rename from ffi_closure_UNIX64. Rewrite + to handle structure returns properly. + +2004-12-08 David Edelsohn + + * Makefile.am (AM_MAKEFLAGS): Remove duplicate LIBCFLAGS and + PICFLAG. + * Makefile.in: Regenerated. + +2004-12-02 Richard Sandiford + + * configure.ac: Use TL_AC_GCC_VERSION to set gcc_version. + * configure, aclocal.m4, Makefile.in: Regenerate. + * include/Makefile.in, testsuite/Makefile.in: Regenerate. + +2004-11-29 Kelley Cook + + * configure: Regenerate for libtool change. + +2004-11-25 Kelley Cook + + * configure: Regenerate for libtool reversion. + +2004-11-24 Kelley Cook + + * configure: Regenerate for libtool change. + +2004-11-23 John David Anglin + + * testsuite/lib/libffi-dg.exp: Use new procs in target-libpath.exp. + +2004-11-23 Richard Sandiford + + * src/mips/o32.S (ffi_call_O32, ffi_closure_O32): Use jalr instead + of jal. Use an absolute encoding for the frame information. + +2004-11-23 Kelley Cook + + * Makefile.am: Remove no-dependencies. Add ACLOCAL_AMFLAGS. + * acinclude.m4: Delete logic for sincludes. + * aclocal.m4, Makefile.in, configure: Regenerate. + * include/Makefile: Likewise. + * testsuite/Makefile: Likewise. + +2004-11-22 Eric Botcazou + + * src/sparc/ffi.c (ffi_prep_closure): Align doubles and 64-bit integers + on a 8-byte boundary. + * src/sparc/v8.S (ffi_closure_v8): Reserve frame space for arguments. + +2004-10-27 Richard Earnshaw + + * src/arm/ffi.c (ffi_prep_cif_machdep): Handle functions that return + long long values. Round stack allocation to a multiple of 8 bytes + for ATPCS compatibility. + * src/arm/sysv.S (ffi_call_SYSV): Rework to avoid use of APCS register + names. Handle returning long long types. Add Thumb and interworking + support. Improve soft-float code. + +2004-10-27 Richard Earnshaw + + * testsuite/lib/libffi-db.exp (load_gcc_lib): New function. + (libffi_exit): New function. + (libffi_init): Build the testglue wrapper if needed. + +2004-10-25 Eric Botcazou + + PR other/18138 + * testsuite/lib/libffi-dg.exp: Accept more than one multilib libgcc. + +2004-10-25 Kazuhiro Inaoka + + * src/m32r/libffitarget.h (FFI_CLOSURES): Set to 0. + +2004-10-20 Kaz Kojima + + * src/sh/sysv.S (ffi_call_SYSV): Don't align for double data. + * testsuite/libffi.call/float3.c: New test case. + +2004-10-18 Kaz Kojima + + * src/sh/ffi.c (ffi_prep_closure): Set T bit in trampoline for + the function returning a structure pointed with R2. + * src/sh/sysv.S (ffi_closure_SYSV): Use R2 as the pointer to + the structure return value if T bit set. Emit position + independent code and EH data if PIC. + +2004-10-13 Kazuhiro Inaoka + + * Makefile.am: Add m32r support. + * configure.ac: Likewise. + * Makefile.in: Regenerate. + * confiugre: Regenerate. + * src/types.c: Add m32r port to FFI_INTERNAL_TYPEDEF + (uint64, sint64, double, longdouble) + * src/m32r: New directory. + * src/m32r/ffi.c: New file. + * src/m32r/sysv.S: Likewise. + * src/m32r/ffitarget.h: Likewise. + +2004-10-02 Kaz Kojima + + * testsuite/libffi.call/negint.c: New test case. + +2004-09-14 H.J. Lu + + PR libgcj/17465 + * testsuite/lib/libffi-dg.exp: Don't use global ld_library_path. + Set up LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH, + LD_LIBRARY64_PATH, LD_LIBRARY_PATH_32, LD_LIBRARY_PATH_64 and + DYLD_LIBRARY_PATH. + +2004-09-05 Andreas Tobler + + * testsuite/libffi.call/many_win32.c: Remove whitespaces. + * testsuite/libffi.call/promotion.c: Likewise. + * testsuite/libffi.call/return_ll.c: Remove unused var. Cleanup + whitespaces. + * testsuite/libffi.call/return_sc.c: Likewise. + * testsuite/libffi.call/return_uc.c: Likewise. + +2004-09-05 Andreas Tobler + + * src/powerpc/darwin.S: Fix comments and identation. + * src/powerpc/darwin_closure.S: Likewise. + +2004-09-02 Andreas Tobler + + * src/powerpc/ffi_darwin.c: Add flag for longdouble return values. + (ffi_prep_args): Handle longdouble arguments. + (ffi_prep_cif_machdep): Set flags for longdouble. Calculate space for + longdouble. + (ffi_closure_helper_DARWIN): Add closure handling for longdouble. + * src/powerpc/darwin.S (_ffi_call_DARWIN): Add handling of longdouble + values. + * src/powerpc/darwin_closure.S (_ffi_closure_ASM): Likewise. + * src/types.c: Defined longdouble size and alignment for darwin. + +2004-09-02 Andreas Tobler + + * src/powerpc/aix.S: Remove whitespaces. + * src/powerpc/aix_closure.S: Likewise. + * src/powerpc/asm.h: Likewise. + * src/powerpc/ffi.c: Likewise. + * src/powerpc/ffitarget.h: Likewise. + * src/powerpc/linux64.S: Likewise. + * src/powerpc/linux64_closure.S: Likewise. + * src/powerpc/ppc_closure.S: Likewise. + * src/powerpc/sysv.S: Likewise. + +2004-08-30 Anthony Green + + * Makefile.am: Add frv support. + * Makefile.in, testsuite/Makefile.in: Rebuilt. + * configure.ac: Read configure.host. + * configure.in: Read configure.host. + * configure.host: New file. frv-elf needs libgloss. + * include/ffi.h.in: Force ffi_closure to have a nice big (8) + alignment. This is needed to frv and shouldn't harm the others. + * include/ffi_common.h (ALIGN_DOWN): New macro. + * src/frv/ffi.c, src/frv/ffitarget.h, src/frv/eabi.S: New files. + +2004-08-24 David Daney + + * testsuite/libffi.call/closure_fn0.c: Xfail mips64* instead of mips*. + * testsuite/libffi.call/closure_fn1.c: Likewise. + * testsuite/libffi.call/closure_fn2.c Likewise. + * testsuite/libffi.call/closure_fn3.c: Likewise. + * testsuite/libffi.call/closure_fn4.c: Likewise. + * testsuite/libffi.call/closure_fn5.c: Likewise. + * testsuite/libffi.call/cls_18byte.c: Likewise. + * testsuite/libffi.call/cls_19byte.c: Likewise. + * testsuite/libffi.call/cls_1_1byte.c: Likewise. + * testsuite/libffi.call/cls_20byte.c: Likewise. + * testsuite/libffi.call/cls_20byte1.c: Likewise. + * testsuite/libffi.call/cls_24byte.c: Likewise. + * testsuite/libffi.call/cls_2byte.c: Likewise. + * testsuite/libffi.call/cls_3_1byte.c: Likewise. + * testsuite/libffi.call/cls_3byte1.c: Likewise. + * testsuite/libffi.call/cls_3byte2.c: Likewise. + * testsuite/libffi.call/cls_4_1byte.c: Likewise. + * testsuite/libffi.call/cls_4byte.c: Likewise. + * testsuite/libffi.call/cls_64byte.c: Likewise. + * testsuite/libffi.call/cls_6byte.c: Likewise. + * testsuite/libffi.call/cls_7byte.c: Likewise. + * testsuite/libffi.call/cls_8byte.c: Likewise. + * testsuite/libffi.call/cls_9byte1.c: Likewise. + * testsuite/libffi.call/cls_9byte2.c: Likewise. + * testsuite/libffi.call/cls_align_double.c: Likewise. + * testsuite/libffi.call/cls_align_float.c: Likewise. + * testsuite/libffi.call/cls_align_longdouble.c: Likewise. + * testsuite/libffi.call/cls_align_pointer.c: Likewise. + * testsuite/libffi.call/cls_align_sint16.c: Likewise. + * testsuite/libffi.call/cls_align_sint32.c: Likewise. + * testsuite/libffi.call/cls_align_sint64.c: Likewise. + * testsuite/libffi.call/cls_align_uint16.c: Likewise. + * testsuite/libffi.call/cls_align_uint32.c: Likewise. + * testsuite/libffi.call/cls_align_uint64.c: Likewise. + * testsuite/libffi.call/cls_double.c: Likewise. + * testsuite/libffi.call/cls_float.c: Likewise. + * testsuite/libffi.call/cls_multi_schar.c: Likewise. + * testsuite/libffi.call/cls_multi_sshort.c: Likewise. + * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise. + * testsuite/libffi.call/cls_multi_uchar.c: Likewise. + * testsuite/libffi.call/cls_multi_ushort.c: Likewise. + * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise. + * testsuite/libffi.call/cls_schar.c: Likewise. + * testsuite/libffi.call/cls_sint.c: Likewise. + * testsuite/libffi.call/cls_sshort.c: Likewise. + * testsuite/libffi.call/cls_uchar.c: Likewise. + * testsuite/libffi.call/cls_uint.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/cls_ushort.c: Likewise. + * testsuite/libffi.call/nested_struct.c: Likewise. + * testsuite/libffi.call/nested_struct1.c: Likewise. + * testsuite/libffi.call/nested_struct2.c: Likewise. + * testsuite/libffi.call/nested_struct3.c: Likewise. + * testsuite/libffi.call/problem1.c: Likewise. + * testsuite/libffi.special/unwindtest.cc: Likewise. + * testsuite/libffi.call/cls_12byte.c: Likewise and set return value + to zero. + * testsuite/libffi.call/cls_16byte.c: Likewise. + * testsuite/libffi.call/cls_5byte.c: Likewise. + +2004-08-23 David Daney + + PR libgcj/13141 + * src/mips/ffitarget.h (FFI_O32_SOFT_FLOAT): New ABI. + * src/mips/ffi.c (ffi_prep_args): Fix alignment calculation. + (ffi_prep_cif_machdep): Handle FFI_O32_SOFT_FLOAT floating point + parameters and return types. + (ffi_call): Handle FFI_O32_SOFT_FLOAT ABI. + (ffi_prep_closure): Ditto. + (ffi_closure_mips_inner_O32): Handle FFI_O32_SOFT_FLOAT ABI, fix + alignment calculations. + * src/mips/o32.S (ffi_closure_O32): Don't use floating point + instructions if FFI_O32_SOFT_FLOAT, make stack frame ABI compliant. + +2004-08-14 Casey Marshall + + * src/mips/ffi.c (ffi_pref_cif_machdep): set `cif->flags' to + contain `FFI_TYPE_UINT64' as return type for any 64-bit + integer (O32 ABI only). + (ffi_prep_closure): new function. + (ffi_closure_mips_inner_O32): new function. + * src/mips/ffitarget.h: Define `FFI_CLOSURES' and + `FFI_TRAMPOLINE_SIZE' appropriately if the ABI is o32. + * src/mips/o32.S (ffi_call_O32): add labels for .eh_frame. Return + 64 bit integers correctly. + (ffi_closure_O32): new function. + Added DWARF-2 unwind info for both functions. + +2004-08-10 Andrew Haley + + * src/x86/ffi64.c (ffi_prep_args ): 8-align all stack arguments. + +2004-08-01 Robert Millan + + * configure.ac: Detect knetbsd-gnu and kfreebsd-gnu. + * configure: Regenerate. + +2004-07-30 Maciej W. Rozycki + + * acinclude.m4 (AC_FUNC_MMAP_BLACKLIST): Check for + and mmap() explicitly instead of relying on preset autoconf cache + variables. + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2004-07-11 Ulrich Weigand + + * src/s390/ffi.c (ffi_prep_args): Fix C aliasing violation. + (ffi_check_float_struct): Remove unused prototype. + +2004-06-30 Geoffrey Keating + + * src/powerpc/ffi_darwin.c (flush_icache): ';' is a comment + character on Darwin, use '\n\t' instead. + +2004-06-26 Matthias Klose + + * libtool-version: Fix typo in revision/age. + +2004-06-17 Matthias Klose + + * libtool-version: New. + * Makefile.am (libffi_la_LDFLAGS): Use -version-info for soname. + * Makefile.in: Regenerate. + +2004-06-15 Paolo Bonzini + + * Makefile.am: Remove useless multilib rules. + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate with automake 1.8.5. + * configure.ac: Remove useless multilib configury. + * configure: Regenerate. + +2004-06-15 Paolo Bonzini + + * .cvsignore: New file. + +2004-06-10 Jakub Jelinek + + * src/ia64/unix.S (ffi_call_unix): Insert group barrier break + fp_done. + (ffi_closure_UNIX): Fix f14/f15 adjustment if FLOAT_SZ is ever + changed from 8. + +2004-06-06 Sean McNeil + + * configure.ac: Add x86_64-*-freebsd* support. + * configure: Regenerate. + +2004-04-26 Joe Buck + + Bug 15093 + * configure.ac: Test for existence of mmap and sys/mman.h before + checking blacklist. Fix suggested by Jim Wilson. + * configure: Regenerate. + +2004-04-26 Matt Austern + + * src/powerpc/darwin.S: Go through a non-lazy pointer for initial + FDE location. + * src/powerpc/darwin_closure.S: Likewise. + +2004-04-24 Andreas Tobler + + * testsuite/libffi.call/cls_multi_schar.c (main): Fix initialization + error. Reported by Thomas Heller . + * testsuite/libffi.call/cls_multi_sshort.c (main): Likewise. + * testsuite/libffi.call/cls_multi_ushort.c (main): Likewise. + +2004-03-20 Matthias Klose + + * src/pa/linux.S: Fix typo. + +2004-03-19 Matthias Klose + + * Makefile.am: Update. + * Makefile.in: Regenerate. + * src/pa/ffi.h.in: Remove. + * src/pa/ffitarget.h: New file. + +2004-02-10 Randolph Chung + + * Makefile.am: Add PA support. + * Makefile.in: Regenerate. + * include/Makefile.in: Regenerate. + * configure.ac: Add PA target. + * configure: Regenerate. + * src/pa/ffi.c: New file. + * src/pa/ffi.h.in: Add PA support. + * src/pa/linux.S: New file. + * prep_cif.c: Add PA support. + +2004-03-16 Hosaka Yuji + + * src/types.c: Fix alignment size of X86_WIN32 case int64 and + double. + * src/x86/ffi.c (ffi_prep_args): Replace ecif->cif->rtype->type + with ecif->cif->flags. + (ffi_call, ffi_prep_incoming_args_SYSV): Replace cif->rtype->type + with cif->flags. + (ffi_prep_cif_machdep): Add X86_WIN32 struct case. + (ffi_closure_SYSV): Add 1 or 2-bytes struct case for X86_WIN32. + * src/x86/win32.S (retstruct1b, retstruct2b, sc_retstruct1b, + sc_retstruct2b): Add for 1 or 2-bytes struct case. + +2004-03-15 Kelley Cook + + * configure.in: Rename file to ... + * configure.ac: ... this. + * fficonfig.h.in: Regenerate. + * Makefile.in: Regenerate. + * include/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2004-03-12 Matt Austern + + * src/powerpc/darwin.S: Fix EH information so it corresponds to + changes in EH format resulting from addition of linkonce support. + * src/powerpc/darwin_closure.S: Likewise. + +2004-03-11 Andreas Tobler + Paolo Bonzini + + * Makefile.am (AUTOMAKE_OPTIONS): Set them. + Remove VPATH. Remove rules for object files. Remove multilib support. + (AM_CCASFLAGS): Add. + * configure.in (AC_CONFIG_HEADERS): Relace AM_CONFIG_HEADER. + (AC_PREREQ): Bump version to 2.59. + (AC_INIT): Fill with version info and bug address. + (ORIGINAL_LD_FOR_MULTILIBS): Remove. + (AM_ENABLE_MULTILIB): Use this instead of AC_ARG_ENABLE. + De-precious CC so that the right flags are passed down to multilibs. + (AC_MSG_ERROR): Replace obsolete macro AC_ERROR. + (AC_CONFIG_FILES): Replace obsolete macro AC_LINK_FILES. + (AC_OUTPUT): Reorganize the output with AC_CONFIG_COMMANDS. + * configure: Rebuilt. + * aclocal.m4: Likewise. + * Makefile.in, include/Makefile.in, testsuite/Makefile.in: Likewise. + * fficonfig.h.in: Likewise. + +2004-03-11 Andreas Schwab + + * src/ia64/ffi.c (ffi_prep_incoming_args_UNIX): Get floating point + arguments from fp registers only for the first 8 parameter slots. + Don't convert a float parameter when passed in memory. + +2004-03-09 Hans-Peter Nilsson + + * configure: Regenerate for config/accross.m4 correction. + +2004-02-25 Matt Kraai + + * src/powerpc/ffi.c (ffi_prep_args_SYSV): Change + ecif->cif->bytes to bytes. + (ffi_prep_cif_machdep): Add braces around nested if statement. + +2004-02-09 Alan Modra + + * src/types.c (pointer): POWERPC64 has 8 byte pointers. + + * src/powerpc/ffi.c (ffi_prep_args64): Correct long double handling. + (ffi_closure_helper_LINUX64): Fix typo. + * testsuite/libffi.call/cls_align_longdouble.c: Pass -mlong-double-128 + for powerpc64-*-*. + * testsuite/libffi.call/float.c: Likewise. + * testsuite/libffi.call/float2.c: Likewise. + +2004-02-08 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_cif_machdep ): Correct + long double function return and long double arg handling. + (ffi_closure_helper_LINUX64): Formatting. Delete unused "ng" var. + Use "end_pfr" instead of "nf". Correct long double handling. + Localise "temp". + * src/powerpc/linux64.S (ffi_call_LINUX64): Save f2 long double + return value. + * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Allocate + space for long double return value. Adjust stack frame and offsets. + Load f2 long double return. + +2004-02-07 Alan Modra + + * src/types.c: Use 16 byte long double for POWERPC64. + +2004-01-25 Eric Botcazou + + * src/sparc/ffi.c (ffi_prep_args_v9): Shift the parameter array + when the structure return address is passed in %o0. + (ffi_V9_return_struct): Rename into ffi_v9_layout_struct. + (ffi_v9_layout_struct): Align the field following a nested structure + on a word boundary. Use memmove instead of memcpy. + (ffi_call): Update call to ffi_V9_return_struct. + (ffi_prep_closure): Define 'ctx' only for V8. + (ffi_closure_sparc_inner): Clone into ffi_closure_sparc_inner_v8 + and ffi_closure_sparc_inner_v9. + (ffi_closure_sparc_inner_v8): Return long doubles by reference. + Always skip the structure return address. For structures and long + doubles, copy the argument directly. + (ffi_closure_sparc_inner_v9): Skip the structure return address only + if required. Shift the maximum floating-point slot accordingly. For + big structures, copy the argument directly; otherwise, left-justify the + argument and call ffi_v9_layout_struct to lay out the structure on + the stack. + * src/sparc/v8.S: Undef STACKFRAME before defining it. + (ffi_closure_v8): Pass the structure return address. Update call to + ffi_closure_sparc_inner_v8. Short-circuit FFI_TYPE_INT handling. + Skip the 'unimp' insn when returning long doubles and structures. + * src/sparc/v9.S: Undef STACKFRAME before defining it. + (ffi_closure_v9): Increase the frame size by 2 words. Short-circuit + FFI_TYPE_INT handling. Load structures both in integers and + floating-point registers on return. + * README: Update status of the SPARC port. + +2004-01-24 Andreas Tobler + + * testsuite/libffi.call/pyobjc-tc.c (main): Treat result value + as of type ffi_arg. + * testsuite/libffi.call/struct3.c (main): Fix CHECK. + +2004-01-22 Ulrich Weigand + + * testsuite/libffi.call/cls_uint.c (cls_ret_uint_fn): Treat result + value as of type ffi_arg, not unsigned int. + +2004-01-21 Michael Ritzert + + * ffi64.c (ffi_prep_args): Cast the RHS of an assignment instead + of the LHS. + +2004-01-12 Andreas Tobler + + * testsuite/lib/libffi-dg.exp: Set LD_LIBRARY_PATH_32 for + Solaris. + +2004-01-08 Rainer Orth + + * testsuite/libffi.call/ffitest.h (allocate_mmap): Cast MAP_FAILED + to void *. + +2003-12-10 Richard Henderson + + * testsuite/libffi.call/cls_align_pointer.c: Cast pointers to + size_t instead of int. + +2003-12-04 Hosaka Yuji + + * testsuite/libffi.call/many_win32.c: Include . + * testsuite/libffi.call/many_win32.c (main): Replace variable + int i with unsigned long ul. + + * testsuite/libffi.call/cls_align_uint64.c: New test case. + * testsuite/libffi.call/cls_align_sint64.c: Likewise. + * testsuite/libffi.call/cls_align_uint32.c: Likewise. + * testsuite/libffi.call/cls_align_sint32.c: Likewise. + * testsuite/libffi.call/cls_align_uint16.c: Likewise. + * testsuite/libffi.call/cls_align_sint16.c: Likewise. + * testsuite/libffi.call/cls_align_float.c: Likewise. + * testsuite/libffi.call/cls_align_double.c: Likewise. + * testsuite/libffi.call/cls_align_longdouble.c: Likewise. + * testsuite/libffi.call/cls_align_pointer.c: Likewise. + +2003-12-02 Hosaka Yuji + + PR other/13221 + * src/x86/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV): + Align arguments to 32 bits. + +2003-12-01 Andreas Tobler + + PR other/13221 + * testsuite/libffi.call/cls_multi_sshort.c: New test case. + * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise. + * testsuite/libffi.call/cls_multi_uchar.c: Likewise. + * testsuite/libffi.call/cls_multi_schar.c: Likewise. + * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise. + * testsuite/libffi.call/cls_multi_ushort.c: Likewise. + + * testsuite/libffi.special/unwindtest.cc: Cosmetics. + +2003-11-26 Kaveh R. Ghazi + + * testsuite/libffi.call/ffitest.h: Include . + * testsuite/libffi.special/ffitestcxx.h: Likewise. + +2003-11-22 Andreas Tobler + + * Makefile.in: Rebuilt. + * configure: Likewise. + * testsuite/libffi.special/unwindtest.cc: Convert the mmap to + the right type. + +2003-11-21 Andreas Jaeger + Andreas Tobler + + * acinclude.m4: Add AC_FUNC_MMAP_BLACKLIST. + * configure.in: Call AC_FUNC_MMAP_BLACKLIST. + * Makefile.in: Rebuilt. + * aclocal.m4: Likewise. + * configure: Likewise. + * fficonfig.h.in: Likewise. + * testsuite/lib/libffi-dg.exp: Add include dir. + * testsuite/libffi.call/ffitest.h: Add MMAP definitions. + * testsuite/libffi.special/ffitestcxx.h: Likewise. + * testsuite/libffi.call/closure_fn0.c: Use MMAP functionality + for ffi_closure if available. + * testsuite/libffi.call/closure_fn1.c: Likewise. + * testsuite/libffi.call/closure_fn2.c: Likewise. + * testsuite/libffi.call/closure_fn3.c: Likewise. + * testsuite/libffi.call/closure_fn4.c: Likewise. + * testsuite/libffi.call/closure_fn5.c: Likewise. + * testsuite/libffi.call/cls_12byte.c: Likewise. + * testsuite/libffi.call/cls_16byte.c: Likewise. + * testsuite/libffi.call/cls_18byte.c: Likewise. + * testsuite/libffi.call/cls_19byte.c: Likewise. + * testsuite/libffi.call/cls_1_1byte.c: Likewise. + * testsuite/libffi.call/cls_20byte.c: Likewise. + * testsuite/libffi.call/cls_20byte1.c: Likewise. + * testsuite/libffi.call/cls_24byte.c: Likewise. + * testsuite/libffi.call/cls_2byte.c: Likewise. + * testsuite/libffi.call/cls_3_1byte.c: Likewise. + * testsuite/libffi.call/cls_3byte1.c: Likewise. + * testsuite/libffi.call/cls_3byte2.c: Likewise. + * testsuite/libffi.call/cls_4_1byte.c: Likewise. + * testsuite/libffi.call/cls_4byte.c: Likewise. + * testsuite/libffi.call/cls_5byte.c: Likewise. + * testsuite/libffi.call/cls_64byte.c: Likewise. + * testsuite/libffi.call/cls_6byte.c: Likewise. + * testsuite/libffi.call/cls_7byte.c: Likewise. + * testsuite/libffi.call/cls_8byte.c: Likewise. + * testsuite/libffi.call/cls_9byte1.c: Likewise. + * testsuite/libffi.call/cls_9byte2.c: Likewise. + * testsuite/libffi.call/cls_double.c: Likewise. + * testsuite/libffi.call/cls_float.c: Likewise. + * testsuite/libffi.call/cls_schar.c: Likewise. + * testsuite/libffi.call/cls_sint.c: Likewise. + * testsuite/libffi.call/cls_sshort.c: Likewise. + * testsuite/libffi.call/cls_uchar.c: Likewise. + * testsuite/libffi.call/cls_uint.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/cls_ushort.c: Likewise. + * testsuite/libffi.call/nested_struct.c: Likewise. + * testsuite/libffi.call/nested_struct1.c: Likewise. + * testsuite/libffi.call/nested_struct2.c: Likewise. + * testsuite/libffi.call/nested_struct3.c: Likewise. + * testsuite/libffi.call/problem1.c: Likewise. + * testsuite/libffi.special/unwindtest.cc: Likewise. + +2003-11-20 Andreas Tobler + + * testsuite/lib/libffi-dg.exp: Make the -lgcc_s conditional. + +2003-11-19 Andreas Tobler + + * testsuite/lib/libffi-dg.exp: Add DYLD_LIBRARY_PATH for darwin. + Add -lgcc_s to additional flags. + +2003-11-12 Andreas Tobler + + * configure.in, include/Makefile.am: PR libgcj/11147, install + the ffitarget.h header file in a gcc versioned and target + dependent place. + * configure: Regenerated. + * Makefile.in, include/Makefile.in: Likewise. + * testsuite/Makefile.in: Likewise. + +2003-11-09 Andreas Tobler + + * testsuite/libffi.call/closure_fn0.c: Print result and check + with dg-output to make debugging easier. + * testsuite/libffi.call/closure_fn1.c: Likewise. + * testsuite/libffi.call/closure_fn2.c: Likewise. + * testsuite/libffi.call/closure_fn3.c: Likewise. + * testsuite/libffi.call/closure_fn4.c: Likewise. + * testsuite/libffi.call/closure_fn5.c: Likewise. + * testsuite/libffi.call/cls_12byte.c: Likewise. + * testsuite/libffi.call/cls_16byte.c: Likewise. + * testsuite/libffi.call/cls_18byte.c: Likewise. + * testsuite/libffi.call/cls_19byte.c: Likewise. + * testsuite/libffi.call/cls_1_1byte.c: Likewise. + * testsuite/libffi.call/cls_20byte.c: Likewise. + * testsuite/libffi.call/cls_20byte1.c: Likewise. + * testsuite/libffi.call/cls_24byte.c: Likewise. + * testsuite/libffi.call/cls_2byte.c: Likewise. + * testsuite/libffi.call/cls_3_1byte.c: Likewise. + * testsuite/libffi.call/cls_3byte1.c: Likewise. + * testsuite/libffi.call/cls_3byte2.c: Likewise. + * testsuite/libffi.call/cls_4_1byte.c: Likewise. + * testsuite/libffi.call/cls_4byte.c: Likewise. + * testsuite/libffi.call/cls_5byte.c: Likewise. + * testsuite/libffi.call/cls_64byte.c: Likewise. + * testsuite/libffi.call/cls_6byte.c: Likewise. + * testsuite/libffi.call/cls_7byte.c: Likewise. + * testsuite/libffi.call/cls_8byte.c: Likewise. + * testsuite/libffi.call/cls_9byte1.c: Likewise. + * testsuite/libffi.call/cls_9byte2.c: Likewise. + * testsuite/libffi.call/cls_double.c: Likewise. + * testsuite/libffi.call/cls_float.c: Likewise. + * testsuite/libffi.call/cls_schar.c: Likewise. + * testsuite/libffi.call/cls_sint.c: Likewise. + * testsuite/libffi.call/cls_sshort.c: Likewise. + * testsuite/libffi.call/cls_uchar.c: Likewise. + * testsuite/libffi.call/cls_uint.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/cls_ushort.c: Likewise. + * testsuite/libffi.call/problem1.c: Likewise. + + * testsuite/libffi.special/unwindtest.cc: Make ffi_closure + static. + +2003-11-08 Andreas Tobler + + * testsuite/libffi.call/cls_9byte2.c: New test case. + * testsuite/libffi.call/cls_9byte1.c: Likewise. + * testsuite/libffi.call/cls_64byte.c: Likewise. + * testsuite/libffi.call/cls_20byte1.c: Likewise. + * testsuite/libffi.call/cls_19byte.c: Likewise. + * testsuite/libffi.call/cls_18byte.c: Likewise. + * testsuite/libffi.call/closure_fn4.c: Likewise. + * testsuite/libffi.call/closure_fn5.c: Likewise. + * testsuite/libffi.call/cls_schar.c: Likewise. + * testsuite/libffi.call/cls_sint.c: Likewise. + * testsuite/libffi.call/cls_sshort.c: Likewise. + * testsuite/libffi.call/nested_struct2.c: Likewise. + * testsuite/libffi.call/nested_struct3.c: Likewise. + +2003-11-08 Andreas Tobler + + * testsuite/libffi.call/cls_double.c: Do a check on the result. + * testsuite/libffi.call/cls_uchar.c: Likewise. + * testsuite/libffi.call/cls_uint.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/cls_ushort.c: Likewise. + * testsuite/libffi.call/return_sc.c: Cleanup whitespaces. + +2003-11-06 Andreas Tobler + + * src/prep_cif.c (ffi_prep_cif): Move the validity check after + the initialization. + +2003-10-23 Andreas Tobler + + * src/java_raw_api.c (ffi_java_ptrarray_to_raw): Replace + FFI_ASSERT(FALSE) with FFI_ASSERT(0). + +2003-10-22 David Daney + + * src/mips/ffitarget.h: Replace undefined UINT32 and friends with + __attribute__((__mode__(__SI__))) and friends. + +2003-10-22 Andreas Schwab + + * src/ia64/ffi.c: Replace FALSE/TRUE with false/true. + +2003-10-21 Andreas Tobler + + * configure.in: AC_LINK_FILES(ffitarget.h). + * configure: Regenerate. + * Makefile.in: Likewise. + * include/Makefile.in: Likewise. + * testsuite/Makefile.in: Likewise. + * fficonfig.h.in: Likewise. + +2003-10-21 Paolo Bonzini + Richard Henderson + + Avoid that ffi.h includes fficonfig.h. + + * Makefile.am (EXTRA_DIST): Include ffitarget.h files + (TARGET_SRC_MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX. + (TARGET_SRC_MIPS_SGI): Removed. + (MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX. + (MIPS_SGI): Removed. + (CLEANFILES): Removed. + (mostlyclean-am, clean-am, mostlyclean-sub, clean-sub): New + targets. + * acconfig.h: Removed. + * configure.in: Compute sizeofs only for double and long double. + Use them to define and subst HAVE_LONG_DOUBLE. Include comments + into AC_DEFINE instead of using acconfig.h. Create + include/ffitarget.h instead of include/fficonfig.h. Rename + MIPS_GCC to MIPS_IRIX, drop MIPS_SGI since we are in gcc's tree. + AC_DEFINE EH_FRAME_FLAGS. + * include/Makefile.am (DISTCLEANFILES): New automake macro. + (hack_DATA): Add ffitarget.h. + * include/ffi.h.in: Remove all system specific definitions. + Declare raw API even if it is not installed, why bother? + Use limits.h instead of SIZEOF_* to define ffi_type_*. Do + not define EH_FRAME_FLAGS, it is in fficonfig.h now. Include + ffitarget.h instead of fficonfig.h. Remove ALIGN macro. + (UINT_ARG, INT_ARG): Removed, use ffi_arg and ffi_sarg instead. + * include/ffi_common.h (bool): Do not define. + (ffi_assert): Accept failed assertion. + (ffi_type_test): Return void and accept file/line. + (FFI_ASSERT): Pass stringized failed assertion. + (FFI_ASSERT_AT): New macro. + (FFI_ASSERT_VALID_TYPE): New macro. + (UINT8, SINT8, UINT16, SINT16, UINT32, SINT32, + UINT64, SINT64): Define here with gcc's __attribute__ macro + instead of in ffi.h + (FLOAT32, ALIGN): Define here instead of in ffi.h + * include/ffi-mips.h: Removed. Its content moved to + src/mips/ffitarget.h after separating assembly and C sections. + * src/alpha/ffi.c, src/alpha/ffi.c, src/java_raw_api.c + src/prep_cif.c, src/raw_api.c, src/ia64/ffi.c, + src/mips/ffi.c, src/mips/n32.S, src/mips/o32.S, + src/mips/ffitarget.h, src/sparc/ffi.c, src/x86/ffi64.c: + SIZEOF_ARG -> FFI_SIZEOF_ARG. + * src/ia64/ffi.c: Include stdbool.h (provided by GCC 2.95+). + * src/debug.c (ffi_assert): Accept stringized failed assertion. + (ffi_type_test): Rewritten. + * src/prep-cif.c (initialize_aggregate, ffi_prep_cif): Call + FFI_ASSERT_VALID_TYPE. + * src/alpha/ffitarget.h, src/arm/ffitarget.h, + src/ia64/ffitarget.h, src/m68k/ffitarget.h, + src/mips/ffitarget.h, src/powerpc/ffitarget.h, + src/s390/ffitarget.h, src/sh/ffitarget.h, + src/sh64/ffitarget.h, src/sparc/ffitarget.h, + src/x86/ffitarget.h: New files. + * src/alpha/osf.S, src/arm/sysv.S, src/ia64/unix.S, + src/m68k/sysv.S, src/mips/n32.S, src/mips/o32.S, + src/powerpc/aix.S, src/powerpc/darwin.S, + src/powerpc/ffi_darwin.c, src/powerpc/linux64.S, + src/powerpc/linux64_closure.S, src/powerpc/ppc_closure.S, + src/powerpc/sysv.S, src/s390/sysv.S, src/sh/sysv.S, + src/sh64/sysv.S, src/sparc/v8.S, src/sparc/v9.S, + src/x86/sysv.S, src/x86/unix64.S, src/x86/win32.S: + include fficonfig.h + +2003-10-20 Rainer Orth + + * src/mips/ffi.c: Use _ABIN32, _ABIO32 instead of external + _MIPS_SIM_NABI32, _MIPS_SIM_ABI32. + +2003-10-19 Andreas Tobler + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Declare bytes again. + Used when FFI_DEBUG = 1. + +2003-10-14 Alan Modra + + * src/types.c (double, longdouble): Default POWERPC64 to 8 byte size + and align. + +2003-10-06 Rainer Orth + + * include/ffi_mips.h: Define FFI_MIPS_N32 for N32/N64 ABIs, + FFI_MIPS_O32 for O32 ABI. + +2003-10-01 Andreas Tobler + + * testsuite/lib/libffi-dg.exp: Set LD_LIBRARY_PATH_64 for + SPARC64. Cleanup whitespaces. + +2003-09-19 Andreas Tobler + + * testsuite/libffi.call/closure_fn0.c: Xfail mips, arm, + strongarm, xscale. Cleanup whitespaces. + * testsuite/libffi.call/closure_fn1.c: Likewise. + * testsuite/libffi.call/closure_fn2.c: Likewise. + * testsuite/libffi.call/closure_fn3.c: Likewise. + * testsuite/libffi.call/cls_12byte.c: Likewise. + * testsuite/libffi.call/cls_16byte.c: Likewise. + * testsuite/libffi.call/cls_1_1byte.c: Likewise. + * testsuite/libffi.call/cls_20byte.c: Likewise. + * testsuite/libffi.call/cls_24byte.c: Likewise. + * testsuite/libffi.call/cls_2byte.c: Likewise. + * testsuite/libffi.call/cls_3_1byte.c: Likewise. + * testsuite/libffi.call/cls_3byte1.c: Likewise. + * testsuite/libffi.call/cls_3byte2.c: Likewise. + * testsuite/libffi.call/cls_4_1byte.c: Likewise. + * testsuite/libffi.call/cls_4byte.c: Likewise. + * testsuite/libffi.call/cls_5byte.c: Likewise. + * testsuite/libffi.call/cls_6byte.c: Likewise. + * testsuite/libffi.call/cls_7byte.c: Likewise. + * testsuite/libffi.call/cls_8byte.c: Likewise. + * testsuite/libffi.call/cls_double.c: Likewise. + * testsuite/libffi.call/cls_float.c: Likewise. + * testsuite/libffi.call/cls_uchar.c: Likewise. + * testsuite/libffi.call/cls_uint.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/cls_ushort.c: Likewise. + * testsuite/libffi.call/nested_struct.c: Likewise. + * testsuite/libffi.call/nested_struct1.c: Likewise. + * testsuite/libffi.call/problem1.c: Likewise. + * testsuite/libffi.special/unwindtest.cc: Likewise. + * testsuite/libffi.call/pyobjc-tc.c: Cleanup whitespaces. + +2003-09-18 David Edelsohn + + * src/powerpc/aix.S: Cleanup whitespaces. + * src/powerpc/aix_closure.S: Likewise. + +2003-09-18 Andreas Tobler + + * src/powerpc/darwin.S: Cleanup whitespaces, comment formatting. + * src/powerpc/darwin_closure.S: Likewise. + * src/powerpc/ffi_darwin.c: Likewise. + +2003-09-18 Andreas Tobler + David Edelsohn + + * src/types.c (double): Add AIX and Darwin to the right TYPEDEF. + * src/powerpc/aix_closure.S: Remove the pointer to the outgoing + parameter stack. + * src/powerpc/darwin_closure.S: Likewise. + * src/powerpc/ffi_darwin.c (ffi_prep_args): Handle structures + according to the Darwin/AIX ABI. + (ffi_prep_cif_machdep): Likewise. + (ffi_closure_helper_DARWIN): Likewise. + Remove the outgoing parameter stack logic. Simplify the evaluation + of the different CASE types. + (ffi_prep_clousure): Avoid the casts on lvalues. Change the branch + statement in the trampoline code. + +2003-09-18 Kaz Kojima + + * src/sh/ffi.c (ffi_prep_args): Take account into the alignement + for the register size. + (ffi_closure_helper_SYSV): Handle the structure return value + address correctly. + (ffi_closure_helper_SYSV): Return the appropriate type when + the registers are used for the structure return value. + * src/sh/sysv.S (ffi_closure_SYSV): Fix the stack layout for + the 64-bit return value. Update copyright years. + +2003-09-17 Rainer Orth + + * testsuite/lib/libffi-dg.exp (libffi_target_compile): Search in + srcdir for ffi_mips.h. + +2003-09-12 Alan Modra + + * src/prep_cif.c (initialize_aggregate): Include tail padding in + structure size. + * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Correct + placement of float result. + * testsuite/libffi.special/unwindtest.cc (closure_test_fn1): Correct + cast of "resp" for big-endian 64 bit machines. + +2003-09-11 Alan Modra + + * src/types.c (double, longdouble): Merge identical SH and ARM + typedefs, and add POWERPC64. + * src/powerpc/ffi.c (ffi_prep_args64): Correct next_arg calc for + struct split over gpr and rest. + (ffi_prep_cif_machdep): Correct intarg_count for structures. + * src/powerpc/linux64.S (ffi_call_LINUX64): Fix gpr offsets. + +2003-09-09 Andreas Tobler + + * src/powerpc/ffi.c (ffi_closure_helper_SYSV) Handle struct + passing correctly. + +2003-09-09 Alan Modra + + * configure: Regenerate. + +2003-09-04 Andreas Tobler + + * Makefile.am: Remove build rules for ffitest. + * Makefile.in: Rebuilt. + +2003-09-04 Andreas Tobler + + * src/java_raw_api.c: Include to fix compiler warning + about implicit declaration of abort(). + +2003-09-04 Andreas Tobler + + * Makefile.am: Add dejagnu test framework. Fixes PR other/11411. + * Makefile.in: Rebuilt. + * configure.in: Add dejagnu test framework. + * configure: Rebuilt. + + * testsuite/Makefile.am: New file. + * testsuite/Makefile.in: Built + * testsuite/lib/libffi-dg.exp: New file. + * testsuite/config/default.exp: Likewise. + * testsuite/libffi.call/call.exp: Likewise. + * testsuite/libffi.call/ffitest.h: Likewise. + * testsuite/libffi.call/closure_fn0.c: Likewise. + * testsuite/libffi.call/closure_fn1.c: Likewise. + * testsuite/libffi.call/closure_fn2.c: Likewise. + * testsuite/libffi.call/closure_fn3.c: Likewise. + * testsuite/libffi.call/cls_1_1byte.c: Likewise. + * testsuite/libffi.call/cls_3_1byte.c: Likewise. + * testsuite/libffi.call/cls_4_1byte.c: Likewise. + * testsuite/libffi.call/cls_2byte.c: Likewise. + * testsuite/libffi.call/cls_3byte1.c: Likewise. + * testsuite/libffi.call/cls_3byte2.c: Likewise. + * testsuite/libffi.call/cls_4byte.c: Likewise. + * testsuite/libffi.call/cls_5byte.c: Likewise. + * testsuite/libffi.call/cls_6byte.c: Likewise. + * testsuite/libffi.call/cls_7byte.c: Likewise. + * testsuite/libffi.call/cls_8byte.c: Likewise. + * testsuite/libffi.call/cls_12byte.c: Likewise. + * testsuite/libffi.call/cls_16byte.c: Likewise. + * testsuite/libffi.call/cls_20byte.c: Likewise. + * testsuite/libffi.call/cls_24byte.c: Likewise. + * testsuite/libffi.call/cls_double.c: Likewise. + * testsuite/libffi.call/cls_float.c: Likewise. + * testsuite/libffi.call/cls_uchar.c: Likewise. + * testsuite/libffi.call/cls_uint.c: Likewise. + * testsuite/libffi.call/cls_ulonglong.c: Likewise. + * testsuite/libffi.call/cls_ushort.c: Likewise. + * testsuite/libffi.call/float.c: Likewise. + * testsuite/libffi.call/float1.c: Likewise. + * testsuite/libffi.call/float2.c: Likewise. + * testsuite/libffi.call/many.c: Likewise. + * testsuite/libffi.call/many_win32.c: Likewise. + * testsuite/libffi.call/nested_struct.c: Likewise. + * testsuite/libffi.call/nested_struct1.c: Likewise. + * testsuite/libffi.call/pyobjc-tc.c: Likewise. + * testsuite/libffi.call/problem1.c: Likewise. + * testsuite/libffi.call/promotion.c: Likewise. + * testsuite/libffi.call/return_ll.c: Likewise. + * testsuite/libffi.call/return_sc.c: Likewise. + * testsuite/libffi.call/return_uc.c: Likewise. + * testsuite/libffi.call/strlen.c: Likewise. + * testsuite/libffi.call/strlen_win32.c: Likewise. + * testsuite/libffi.call/struct1.c: Likewise. + * testsuite/libffi.call/struct2.c: Likewise. + * testsuite/libffi.call/struct3.c: Likewise. + * testsuite/libffi.call/struct4.c: Likewise. + * testsuite/libffi.call/struct5.c: Likewise. + * testsuite/libffi.call/struct6.c: Likewise. + * testsuite/libffi.call/struct7.c: Likewise. + * testsuite/libffi.call/struct8.c: Likewise. + * testsuite/libffi.call/struct9.c: Likewise. + * testsuite/libffi.special/special.exp: New file. + * testsuite/libffi.special/ffitestcxx.h: Likewise. + * testsuite/libffi.special/unwindtest.cc: Likewise. + + +2003-08-13 Kaz Kojima + + * src/sh/ffi.c (OFS_INT16): Set 0 for little endian case. Update + copyright years. + +2003-08-02 Alan Modra + + * src/powerpc/ffi.c (ffi_prep_args64): Modify for changed gcc + structure passing. + (ffi_closure_helper_LINUX64): Likewise. + * src/powerpc/linux64.S: Remove code writing to parm save area. + * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Use return + address in lr from ffi_closure_helper_LINUX64 call to calculate + table address. Optimize function tail. + +2003-07-28 Andreas Tobler + + * src/sparc/ffi.c: Handle all floating point registers. + * src/sparc/v9.S: Likewise. Fixes second part of PR target/11410. + +2003-07-11 Gerald Pfeifer + + * README: Note that libffi is not part of GCC. Update the project + URL and status. + +2003-06-19 Franz Sirl + + * src/powerpc/ppc_closure.S: Include ffi.h. + +2003-06-13 Rainer Orth + + * src/x86/sysv.S: Avoid gas-only .uleb128/.sleb128 directives. + Use C style comments. + +2003-06-13 Kaz Kojima + + * Makefile.am: Add SHmedia support. Fix a typo of SH support. + * Makefile.in: Regenerate. + * configure.in (sh64-*-linux*, sh5*-*-linux*): Add target. + * configure: Regenerate. + * include/ffi.h.in: Add SHmedia support. + * src/sh64/ffi.c: New file. + * src/sh64/sysv.S: New file. + +2003-05-16 Jakub Jelinek + + * configure.in (HAVE_RO_EH_FRAME): Check whether .eh_frame section + should be read-only. + * configure: Rebuilt. + * fficonfig.h.in: Rebuilt. + * include/ffi.h.in (EH_FRAME_FLAGS): Define. + * src/alpha/osf.S: Use EH_FRAME_FLAGS. + * src/powerpc/linux64.S: Likewise. + * src/powerpc/linux64_closure.S: Likewise. Include ffi.h. + * src/powerpc/sysv.S: Use EH_FRAME_FLAGS. Use pcrel encoding + if -fpic/-fPIC/-mrelocatable. + * src/powerpc/powerpc_closure.S: Likewise. + * src/sparc/v8.S: If HAVE_RO_EH_FRAME is defined, don't include + #write in .eh_frame flags. + * src/sparc/v9.S: Likewise. + * src/x86/unix64.S: Use EH_FRAME_FLAGS. + * src/x86/sysv.S: Likewise. Use pcrel encoding if -fpic/-fPIC. + * src/s390/sysv.S: Use EH_FRAME_FLAGS. Include ffi.h. + +2003-05-07 Jeff Sturm + + Fixes PR bootstrap/10656 + * configure.in (HAVE_AS_REGISTER_PSEUDO_OP): Test assembler + support for .register pseudo-op. + * src/sparc/v8.S: Use it. + * fficonfig.h.in: Rebuilt. + * configure: Rebuilt. + +2003-04-18 Jakub Jelinek + + * include/ffi.h.in (POWERPC64): Define if 64-bit. + (enum ffi_abi): Add FFI_LINUX64 on POWERPC. + Make it the default on POWERPC64. + (FFI_TRAMPOLINE_SIZE): Define to 24 on POWERPC64. + * configure.in: Change powerpc-*-linux* into powerpc*-*-linux*. + * configure: Rebuilt. + * src/powerpc/ffi.c (hidden): Define. + (ffi_prep_args_SYSV): Renamed from + ffi_prep_args. Cast pointers to unsigned long to shut up warnings. + (NUM_GPR_ARG_REGISTERS64, NUM_FPR_ARG_REGISTERS64, + ASM_NEEDS_REGISTERS64): New. + (ffi_prep_args64): New function. + (ffi_prep_cif_machdep): Handle FFI_LINUX64 ABI. + (ffi_call): Likewise. + (ffi_prep_closure): Likewise. + (flush_icache): Surround by #ifndef POWERPC64. + (ffi_dblfl): New union type. + (ffi_closure_helper_SYSV): Use it to avoid aliasing problems. + (ffi_closure_helper_LINUX64): New function. + * src/powerpc/ppc_closure.S: Surround whole file by #ifndef + __powerpc64__. + * src/powerpc/sysv.S: Likewise. + (ffi_call_SYSV): Rename ffi_prep_args to ffi_prep_args_SYSV. + * src/powerpc/linux64.S: New file. + * src/powerpc/linux64_closure.S: New file. + * Makefile.am (EXTRA_DIST): Add src/powerpc/linux64.S and + src/powerpc/linux64_closure.S. + (TARGET_SRC_POWERPC): Likewise. + + * src/ffitest.c (closure_test_fn, closure_test_fn1, closure_test_fn2, + closure_test_fn3): Fix result printing on big-endian 64-bit + machines. + (main): Print tst2_arg instead of uninitialized tst2_result. + + * src/ffitest.c (main): Hide what closure pointer really points to + from the compiler. + +2003-04-16 Richard Earnshaw + + * configure.in (arm-*-netbsdelf*): Add configuration. + (configure): Regenerated. + +2003-04-04 Loren J. Rittle + + * include/Makefile.in: Regenerate. + +2003-03-21 Zdenek Dvorak + + * libffi/include/ffi.h.in: Define X86 instead of X86_64 in 32 + bit mode. + * libffi/src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV): + Receive closure pointer through parameter, read args using + __builtin_dwarf_cfa. + (FFI_INIT_TRAMPOLINE): Send closure reference through eax. + +2003-03-12 Andreas Schwab + + * configure.in: Avoid trailing /. in toolexeclibdir. + * configure: Rebuilt. + +2003-03-03 Andreas Tobler + + * src/powerpc/darwin_closure.S: Recode to fit dynamic libraries. + +2003-02-06 Andreas Tobler + + * libffi/src/powerpc/darwin_closure.S: + Fix alignement bug, allocate 8 bytes for the result. + * libffi/src/powerpc/aix_closure.S: + Likewise. + * libffi/src/powerpc/ffi_darwin.c: + Update stackframe description for aix/darwin_closure.S. + +2003-02-06 Jakub Jelinek + + * src/s390/ffi.c (ffi_closure_helper_SYSV): Add hidden visibility + attribute. + +2003-01-31 Christian Cornelssen , + Andreas Schwab + + * configure.in: Adjust command to source config-ml.in to account + for changes to the libffi_basedir definition. + (libffi_basedir): Remove ${srcdir} from value and include trailing + slash if nonempty. + + * configure: Regenerate. + +2003-01-29 Franz Sirl + + * src/powerpc/ppc_closure.S: Recode to fit shared libs. + +2003-01-28 Andrew Haley + + * include/ffi.h.in: Enable FFI_CLOSURES for x86_64. + * src/x86/ffi64.c (ffi_prep_closure): New. + (ffi_closure_UNIX64_inner): New. + * src/x86/unix64.S (ffi_closure_UNIX64): New. + +2003-01-27 Alexandre Oliva + + * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST. + Remove USE_LIBDIR conditional. + * Makefile.am (toolexecdir, toolexeclibdir): Don't override. + * Makefile.in, configure: Rebuilt. + +2003-01027 David Edelsohn + + * Makefile.am (TARGET_SRC_POWERPC_AIX): Fix typo. + * Makefile.in: Regenerate. + +2003-01-22 Andrew Haley + + * src/powerpc/darwin.S (_ffi_call_AIX): Add Augmentation size to + unwind info. + +2003-01-21 Andreas Tobler + + * src/powerpc/darwin.S: Add unwind info. + * src/powerpc/darwin_closure.S: Likewise. + +2003-01-14 Andrew Haley + + * src/x86/ffi64.c (ffi_prep_args): Check for void retval. + (ffi_prep_cif_machdep): Likewise. + * src/x86/unix64.S: Add unwind info. + +2003-01-14 Andreas Jaeger + + * src/ffitest.c (main): Only use ffi_closures if those are + supported. + +2003-01-13 Andreas Tobler + + * libffi/src/ffitest.c + add closure testcases + +2003-01-13 Kevin B. Hendricks + + * libffi/src/powerpc/ffi.c + fix alignment bug for float (4 byte aligned iso 8 byte) + +2003-01-09 Geoffrey Keating + + * src/powerpc/ffi_darwin.c: Remove RCS version string. + * src/powerpc/darwin.S: Remove RCS version string. + +2003-01-03 Jeff Sturm + + * include/ffi.h.in: Add closure defines for SPARC, SPARC64. + * src/ffitest.c (main): Use static storage for closure. + * src/sparc/ffi.c (ffi_prep_closure, ffi_closure_sparc_inner): New. + * src/sparc/v8.S (ffi_closure_v8): New. + * src/sparc/v9.S (ffi_closure_v9): New. + +2002-11-10 Ranjit Mathew + + * include/ffi.h.in: Added FFI_STDCALL ffi_type + enumeration for X86_WIN32. + * src/x86/win32.S: Added ffi_call_STDCALL function + definition. + * src/x86/ffi.c (ffi_call/ffi_raw_call): Added + switch cases for recognising FFI_STDCALL and + calling ffi_call_STDCALL if target is X86_WIN32. + * src/ffitest.c (my_stdcall_strlen/stdcall_many): + stdcall versions of the "my_strlen" and "many" + test functions (for X86_WIN32). + Added test cases to test stdcall invocation using + these functions. + +2002-12-02 Kaz Kojima + + * src/sh/sysv.S: Add DWARF2 unwind info. + +2002-11-27 Ulrich Weigand + + * src/s390/sysv.S (.eh_frame section): Make section read-only. + +2002-11-26 Jim Wilson + + * src/types.c (FFI_TYPE_POINTER): Has size 8 on IA64. + +2002-11-23 H.J. Lu + + * acinclude.m4: Add dummy AM_PROG_LIBTOOL. + Include ../config/accross.m4. + * aclocal.m4; Rebuild. + * configure: Likewise. + +2002-11-15 Ulrich Weigand + + * src/s390/sysv.S (.eh_frame section): Adapt to pcrel FDE encoding. + +2002-11-11 DJ Delorie + + * configure.in: Look for common files in the right place. + +2002-10-08 Ulrich Weigand + + * src/java_raw_api.c (ffi_java_raw_to_ptrarray): Interpret + raw data as _Jv_word values, not ffi_raw. + (ffi_java_ptrarray_to_raw): Likewise. + (ffi_java_rvalue_to_raw): New function. + (ffi_java_raw_call): Call it. + (ffi_java_raw_to_rvalue): New function. + (ffi_java_translate_args): Call it. + * src/ffitest.c (closure_test_fn): Interpret return value + as ffi_arg, not int. + * src/s390/ffi.c (ffi_prep_cif_machdep): Add missing + FFI_TYPE_POINTER case. + (ffi_closure_helper_SYSV): Likewise. Also, assume return + values extended to word size. + +2002-10-02 Andreas Jaeger + + * src/x86/ffi64.c (ffi_prep_cif_machdep): Remove debug output. + +2002-10-01 Bo Thorsen + + * include/ffi.h.in: Fix i386 win32 compilation. + +2002-09-30 Ulrich Weigand + + * configure.in: Add s390x-*-linux-* target. + * configure: Regenerate. + * include/ffi.h.in: Define S390X for s390x targets. + (FFI_CLOSURES): Define for s390/s390x. + (FFI_TRAMPOLINE_SIZE): Likewise. + (FFI_NATIVE_RAW_API): Likewise. + * src/prep_cif.c (ffi_prep_cif): Do not compute stack space for s390. + * src/types.c (FFI_TYPE_POINTER): Use 8-byte pointers on s390x. + * src/s390/ffi.c: Major rework of existing code. Add support for + s390x targets. Add closure support. + * src/s390/sysv.S: Likewise. + +2002-09-29 Richard Earnshaw + + * src/arm/sysv.S: Fix typo. + +2002-09-28 Richard Earnshaw + + * src/arm/sysv.S: If we don't have machine/asm.h and the pre-processor + has defined __USER_LABEL_PREFIX__, then use it in CNAME. + (ffi_call_SYSV): Handle soft-float. + +2002-09-27 Bo Thorsen + + * include/ffi.h.in: Fix multilib x86-64 support. + +2002-09-22 Kaveh R. Ghazi + + * Makefile.am (all-multi): Fix multilib parallel build. + +2002-07-19 Kaz Kojima + + * configure.in (sh[34]*-*-linux*): Add brackets. + * configure: Regenerate. + +2002-07-18 Kaz Kojima + + * Makefile.am: Add SH support. + * Makefile.in: Regenerate. + * configure.in (sh-*-linux*, sh[34]*-*-linux*): Add target. + * configure: Regenerate. + * include/ffi.h.in: Add SH support. + * src/sh/ffi.c: New file. + * src/sh/sysv.S: New file. + * src/types.c: Add SH support. + +2002-07-16 Bo Thorsen + + * src/x86/ffi64.c: New file that adds x86-64 support. + * src/x86/unix64.S: New file that handles argument setup for + x86-64. + * src/x86/sysv.S: Don't use this on x86-64. + * src/x86/ffi.c: Don't use this on x86-64. + Remove unused vars. + * src/prep_cif.c (ffi_prep_cif): Don't do stack size calculation + for x86-64. + * src/ffitest.c (struct6): New test that tests a special case in + the x86-64 ABI. + (struct7): Likewise. + (struct8): Likewise. + (struct9): Likewise. + (closure_test_fn): Silence warning about this when it's not used. + (main): Add the new tests. + (main): Fix a couple of wrong casts and silence some compiler warnings. + * include/ffi.h.in: Add x86-64 ABI definition. + * fficonfig.h.in: Regenerate. + * Makefile.am: Add x86-64 support. + * configure.in: Likewise. + * Makefile.in: Regenerate. + * configure: Likewise. + +2002-06-24 Bo Thorsen + + * src/types.c: Merge settings for similar architectures. + Add x86-64 sizes and alignments. + +2002-06-23 Bo Thorsen + + * src/arm/ffi.c (ffi_prep_args): Remove unused vars. + * src/sparc/ffi.c (ffi_prep_args_v8): Likewise. + * src/mips/ffi.c (ffi_prep_args): Likewise. + * src/m68k/ffi.c (ffi_prep_args): Likewise. + +2002-07-18 H.J. Lu (hjl@gnu.org) + + * Makefile.am (TARGET_SRC_MIPS_LINUX): New. + (libffi_la_SOURCES): Support MIPS_LINUX. + (libffi_convenience_la_SOURCES): Likewise. + * Makefile.in: Regenerated. + + * configure.in (mips64*-*): Skip. + (mips*-*-linux*): New. + * configure: Regenerated. + + * src/mips/ffi.c: Include . + +2002-06-06 Ulrich Weigand + + * src/s390/sysv.S: Save/restore %r6. Add DWARF-2 unwind info. + +2002-05-27 Roger Sayle + + * src/x86/ffi.c (ffi_prep_args): Remove reference to avn. + +2002-05-27 Bo Thorsen + + * src/x86/ffi.c (ffi_prep_args): Remove unused variable and + fix formatting. + +2002-05-13 Andreas Tobler + + * src/powerpc/ffi_darwin.c (ffi_prep_closure): Declare fd at + beginning of function (for older apple cc). + +2002-05-08 Alexandre Oliva + + * configure.in (ORIGINAL_LD_FOR_MULTILIBS): Preserve LD at + script entry, and set LD to it when configuring multilibs. + * configure: Rebuilt. + +2002-05-05 Jason Thorpe + + * configure.in (sparc64-*-netbsd*): Add target. + (sparc-*-netbsdelf*): Likewise. + * configure: Regenerate. + +2002-04-28 David S. Miller + + * configure.in, configure: Fix SPARC test in previous change. + +2002-04-29 Gerhard Tonn + + * Makefile.am: Add Linux for S/390 support. + * Makefile.in: Regenerate. + * configure.in: Add Linux for S/390 support. + * configure: Regenerate. + * include/ffi.h.in: Add Linux for S/390 support. + * src/s390/ffi.c: New file from libffi CVS tree. + * src/s390/sysv.S: New file from libffi CVS tree. + +2002-04-28 Jakub Jelinek + + * configure.in (HAVE_AS_SPARC_UA_PCREL): Check for working + %r_disp32(). + * src/sparc/v8.S: Use it. + * src/sparc/v9.S: Likewise. + * fficonfig.h.in: Rebuilt. + * configure: Rebuilt. + +2002-04-08 Hans Boehm + + * src/java_raw_api.c (ffi_java_raw_size): Handle FFI_TYPE_DOUBLE + correctly. + * src/ia64/unix.S: Add unwind information. Fix comments. + Save sp in a way that's compatible with unwind info. + (ffi_call_unix): Correctly restore sp in all cases. + * src/ia64/ffi.c: Add, fix comments. + +2002-04-08 Jakub Jelinek + + * src/sparc/v8.S: Make .eh_frame dependent on target word size. + +2002-04-06 Jason Thorpe + + * configure.in (alpha*-*-netbsd*): Add target. + * configure: Regenerate. + +2002-04-04 Jeff Sturm + + * src/sparc/v8.S: Add unwind info. + * src/sparc/v9.S: Likewise. + +2002-03-30 Krister Walfridsson + + * configure.in: Enable i*86-*-netbsdelf*. + * configure: Rebuilt. + +2002-03-29 David Billinghurst + + PR other/2620 + * src/mips/n32.s: Delete + * src/mips/o32.s: Delete + +2002-03-21 Loren J. Rittle + + * configure.in: Enable alpha*-*-freebsd*. + * configure: Rebuilt. + +2002-03-17 Bryce McKinlay + + * Makefile.am: libfficonvenience -> libffi_convenience. + * Makefile.in: Rebuilt. + + * Makefile.am: Define ffitest_OBJECTS. + * Makefile.in: Rebuilt. + +2002-03-07 Andreas Tobler + David Edelsohn + + * Makefile.am (EXTRA_DIST): Add Darwin and AIX closure files. + (TARGET_SRC_POWERPC_AIX): Add aix_closure.S. + (TARGET_SRC_POWERPC_DARWIN): Add darwin_closure.S. + * Makefile.in: Regenerate. + * include/ffi.h.in: Add AIX and Darwin closure definitions. + * src/powerpc/ffi_darwin.c (ffi_prep_closure): New function. + (flush_icache, flush_range): New functions. + (ffi_closure_helper_DARWIN): New function. + * src/powerpc/aix_closure.S: New file. + * src/powerpc/darwin_closure.S: New file. + +2002-02-24 Jeff Sturm + + * include/ffi.h.in: Add typedef for ffi_arg. + * src/ffitest.c (main): Declare rint with ffi_arg. + +2002-02-21 Andreas Tobler + + * src/powerpc/ffi_darwin.c (ffi_prep_args): Skip appropriate + number of GPRs for floating-point arguments. + +2002-01-31 Anthony Green + + * configure: Rebuilt. + * configure.in: Replace CHECK_SIZEOF and endian tests with + cross-compiler friendly macros. + * aclocal.m4 (AC_COMPILE_CHECK_SIZEOF, AC_C_BIGENDIAN_CROSS): New + macros. + +2002-01-18 David Edelsohn + + * src/powerpc/darwin.S (_ffi_call_AIX): New. + * src/powerpc/aix.S (ffi_call_DARWIN): New. + +2002-01-17 David Edelsohn + + * Makefile.am (EXTRA_DIST): Add Darwin and AIX files. + (TARGET_SRC_POWERPC_AIX): New. + (POWERPC_AIX): New stanza. + * Makefile.in: Regenerate. + * configure.in: Add AIX case. + * configure: Regenerate. + * include/ffi.h.in (ffi_abi): Add FFI_AIX. + * src/powerpc/ffi_darwin.c (ffi_status): Use "long" to scale frame + size. Fix "long double" support. + (ffi_call): Add FFI_AIX case. + * src/powerpc/aix.S: New. + +2001-10-09 John Hornkvist + + Implement Darwin PowerPC ABI. + * configure.in: Handle powerpc-*-darwin*. + * Makefile.am: Set source files for POWERPC_DARWIN. + * configure: Rebuilt. + * Makefile.in: Rebuilt. + * include/ffi.h.in: Define FFI_DARWIN and FFI_DEFAULT_ABI for + POWERPC_DARWIN. + * src/powerpc/darwin.S: New file. + * src/powerpc/ffi_darwin.c: New file. + +2001-10-07 Joseph S. Myers + + * src/x86/ffi.c: Fix spelling error of "separate" as "seperate". + +2001-07-16 Rainer Orth + + * src/x86/sysv.S: Avoid gas-only .balign directive. + Use C style comments. + +2001-07-16 Rainer Orth + + * src/alpha/ffi.c (ffi_prep_closure): Avoid gas-only mnemonic. + Fixes PR bootstrap/3563. + +2001-06-26 Rainer Orth + + * src/alpha/osf.S (ffi_closure_osf): Use .rdata for ECOFF. + +2001-06-25 Rainer Orth + + * configure.in: Recognize sparc*-sun-* host. + * configure: Regenerate. + +2001-06-06 Andrew Haley + + * src/alpha/osf.S (__FRAME_BEGIN__): Conditionalize for ELF. + +2001-06-03 Andrew Haley + + * src/alpha/osf.S: Add unwind info. + * src/powerpc/sysv.S: Add unwind info. + * src/powerpc/ppc_closure.S: Likewise. + +2000-05-31 Jeff Sturm + + * configure.in: Fix AC_ARG_ENABLE usage. + * configure: Rebuilt. + +2001-05-06 Bryce McKinlay + + * configure.in: Remove warning about beta code. + * configure: Rebuilt. + +2001-04-25 Hans Boehm + + * src/ia64/unix.S: Restore stack pointer when returning from + ffi_closure_UNIX. + * src/ia64/ffi.c: Fix typo in comment. + +2001-04-18 Jim Wilson + + * src/ia64/unix.S: Delete unnecessary increment and decrement of loc2 + to eliminate RAW DV. + +2001-04-12 Bryce McKinlay + + * Makefile.am: Make a libtool convenience library. + * Makefile.in: Rebuilt. + +2001-03-29 Bryce McKinlay + + * configure.in: Use different syntax for subdirectory creation. + * configure: Rebuilt. + +2001-03-27 Jon Beniston + + * configure.in: Added X86_WIN32 target (Win32, CygWin, MingW). + * configure: Rebuilt. + * Makefile.am: Added X86_WIN32 target support. + * Makefile.in: Rebuilt. + + * include/ffi.h.in: Added X86_WIN32 target support. + + * src/ffitest.c: Doesn't run structure tests for X86_WIN32 targets. + * src/types.c: Added X86_WIN32 target support. + + * src/x86/win32.S: New file. Based on sysv.S, but with EH + stuff removed and made to work with CygWin's gas. + +2001-03-26 Bryce McKinlay + + * configure.in: Make target subdirectory in build dir. + * Makefile.am: Override suffix based rules to specify correct output + subdirectory. + * Makefile.in: Rebuilt. + * configure: Rebuilt. + +2001-03-23 Kevin B Hendricks + + * src/powerpc/ppc_closure.S: New file. + * src/powerpc/ffi.c (ffi_prep_args): Fixed ABI compatibility bug + involving long long and register pairs. + (ffi_prep_closure): New function. + (flush_icache): Likewise. + (ffi_closure_helper_SYSV): Likewise. + * include/ffi.h.in (FFI_CLOSURES): Define on PPC. + (FFI_TRAMPOLINE_SIZE): Likewise. + (FFI_NATIVE_RAW_API): Likewise. + * Makefile.in: Rebuilt. + * Makefile.am (EXTRA_DIST): Added src/powerpc/ppc_closure.S. + (TARGET_SRC_POWERPC): Likewise. + +2001-03-19 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (ffitest_LDFLAGS): New macro. + +2001-03-02 Nick Clifton + + * include/ffi.h.in: Remove RCS ident string. + * include/ffi_mips.h: Remove RCS ident string. + * src/debug.c: Remove RCS ident string. + * src/ffitest.c: Remove RCS ident string. + * src/prep_cif.c: Remove RCS ident string. + * src/types.c: Remove RCS ident string. + * src/alpha/ffi.c: Remove RCS ident string. + * src/alpha/osf.S: Remove RCS ident string. + * src/arm/ffi.c: Remove RCS ident string. + * src/arm/sysv.S: Remove RCS ident string. + * src/mips/ffi.c: Remove RCS ident string. + * src/mips/n32.S: Remove RCS ident string. + * src/mips/o32.S: Remove RCS ident string. + * src/sparc/ffi.c: Remove RCS ident string. + * src/sparc/v8.S: Remove RCS ident string. + * src/sparc/v9.S: Remove RCS ident string. + * src/x86/ffi.c: Remove RCS ident string. + * src/x86/sysv.S: Remove RCS ident string. + +2001-02-08 Joseph S. Myers + + * include/ffi.h.in: Change sourceware.cygnus.com references to + gcc.gnu.org. + +2000-12-09 Richard Henderson + + * src/alpha/ffi.c (ffi_call): Simplify struct return test. + (ffi_closure_osf_inner): Index rather than increment avalue + and arg_types. Give ffi_closure_osf the raw return value type. + * src/alpha/osf.S (ffi_closure_osf): Handle return value type + promotion. + +2000-12-07 Richard Henderson + + * src/raw_api.c (ffi_translate_args): Fix typo. + (ffi_prep_closure): Likewise. + + * include/ffi.h.in [ALPHA]: Define FFI_CLOSURES and + FFI_TRAMPOLINE_SIZE. + * src/alpha/ffi.c (ffi_prep_cif_machdep): Adjust minimal + cif->bytes for new ffi_call_osf implementation. + (ffi_prep_args): Absorb into ... + (ffi_call): ... here. Do all stack allocation here and + avoid a callback function. + (ffi_prep_closure, ffi_closure_osf_inner): New. + * src/alpha/osf.S (ffi_call_osf): Reimplement with no callback. + (ffi_closure_osf): New. + +2000-09-10 Alexandre Oliva + + * config.guess, config.sub, install-sh: Removed. + * ltconfig, ltmain.sh, missing, mkinstalldirs: Likewise. + * Makefile.in: Rebuilt. + + * acinclude.m4: Include libtool macros from the top level. + * aclocal.m4, configure: Rebuilt. + +2000-08-22 Alexandre Oliva + + * configure.in [i*86-*-freebsd*] (TARGET, TARGETDIR): Set. + * configure: Rebuilt. + +2000-05-11 Scott Bambrough + + * libffi/src/arm/sysv.S (ffi_call_SYSV): Doubles are not saved to + memory correctly. Use conditional instructions, not branches where + possible. + +2000-05-04 Tom Tromey + + * configure: Rebuilt. + * configure.in: Match `arm*-*-linux-*'. + From Chris Dornan . + +2000-04-28 Jakub Jelinek + + * Makefile.am (SUBDIRS): Define. + (AM_MAKEFLAGS): Likewise. + (Multilib support.): Add section. + * Makefile.in: Rebuilt. + * ltconfig (extra_compiler_flags, extra_compiler_flags_value): + New variables. Set for gcc using -print-multi-lib. Export them + to libtool. + (sparc64-*-linux-gnu*): Use libsuff 64 for search paths. + * ltmain.sh (B|b|V): Don't throw away gcc's -B, -b and -V options + for -shared links. + (extra_compiler_flags_value, extra_compiler_flags): Check these + for extra compiler options which need to be passed down in + compiler_flags. + +2000-04-16 Anthony Green + + * configure: Rebuilt. + * configure.in: Change i*86-pc-linux* to i*86-*-linux*. + +2000-04-14 Jakub Jelinek + + * include/ffi.h.in (SPARC64): Define for 64bit SPARC builds. + Set SPARC FFI_DEFAULT_ABI based on SPARC64 define. + * src/sparc/ffi.c (ffi_prep_args_v8): Renamed from ffi_prep_args. + Replace all void * sizeofs with sizeof(int). + Only compare type with FFI_TYPE_LONGDOUBLE if LONGDOUBLE is + different than DOUBLE. + Remove FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases (handled elsewhere). + (ffi_prep_args_v9): New function. + (ffi_prep_cif_machdep): Handle V9 ABI and long long on V8. + (ffi_V9_return_struct): New function. + (ffi_call): Handle FFI_V9 ABI from 64bit code and FFI_V8 ABI from + 32bit code (not yet cross-arch calls). + * src/sparc/v8.S: Add struct return delay nop. + Handle long long. + * src/sparc/v9.S: New file. + * src/prep_cif.c (ffi_prep_cif): Return structure pointer + is used on sparc64 only for structures larger than 32 bytes. + Pass by reference for structures is done for structure arguments + larger than 16 bytes. + * src/ffitest.c (main): Use 64bit rint on sparc64. + Run long long tests on sparc. + * src/types.c (FFI_TYPE_POINTER): Pointer is 64bit on alpha and + sparc64. + (FFI_TYPE_LONGDOUBLE): long double is 128 bit aligned to 128 bits + on sparc64. + * configure.in (sparc-*-linux*): New supported target. + (sparc64-*-linux*): Likewise. + * configure: Rebuilt. + * Makefile.am: Add v9.S to SPARC files. + * Makefile.in: Likewise. + (LINK): Surround $(CCLD) into double quotes, so that multilib + compiles work correctly. + +2000-04-04 Alexandre Petit-Bianco + + * configure: Rebuilt. + * configure.in: (i*86-*-solaris*): New libffi target. Patch + proposed by Bryce McKinlay. + +2000-03-20 Tom Tromey + + * Makefile.in: Hand edit for java_raw_api.lo. + +2000-03-08 Bryce McKinlay + + * config.guess, config.sub: Update from the gcc tree. + Fix for PR libgcj/168. + +2000-03-03 Tom Tromey + + * Makefile.in: Fixed ia64 by hand. + + * configure: Rebuilt. + * configure.in (--enable-multilib): New option. + (libffi_basedir): New subst. + (AC_OUTPUT): Added multilib code. + +2000-03-02 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (TARGET_SRC_IA64): Use `ia64', not `alpha', as + directory name. + +2000-02-25 Hans Boehm + + * src/ia64/ffi.c, src/ia64/ia64_flags.h, src/ia64/unix.S: New + files. + * src/raw_api.c (ffi_translate_args): Fixed typo in argument + list. + (ffi_prep_raw_closure): Use ffi_translate_args, not + ffi_closure_translate. + * src/java_raw_api.c: New file. + * src/ffitest.c (closure_test_fn): New function. + (main): Define `rint' as long long on IA64. Added new test when + FFI_CLOSURES is defined. + * include/ffi.h.in (ALIGN): Use size_t, not unsigned. + (ffi_abi): Recognize IA64. + (ffi_raw): Added `flt' field. + Added "Java raw API" code. + * configure.in: Recognize ia64. + * Makefile.am (TARGET_SRC_IA64): New macro. + (libffi_la_common_SOURCES): Added java_raw_api.c. + (libffi_la_SOURCES): Define in IA64 case. + +2000-01-04 Tom Tromey + + * Makefile.in: Rebuilt with newer automake. + +1999-12-31 Tom Tromey + + * Makefile.am (INCLUDES): Added -I$(top_srcdir)/src. + +1999-09-01 Tom Tromey + + * include/ffi.h.in: Removed PACKAGE and VERSION defines and + undefs. + * fficonfig.h.in: Rebuilt. + * configure: Rebuilt. + * configure.in: Pass 3rd argument to AM_INIT_AUTOMAKE. + Use AM_PROG_LIBTOOL (automake 1.4 compatibility). + * acconfig.h: Don't #undef PACKAGE or VERSION. + +1999-08-09 Anthony Green + + * include/ffi.h.in: Try to work around messy header problem + with PACKAGE and VERSION. + + * configure: Rebuilt. + * configure.in: Change version to 2.00-beta. + + * fficonfig.h.in: Rebuilt. + * acconfig.h (FFI_NO_STRUCTS, FFI_NO_RAW_API): Define. + + * src/x86/ffi.c (ffi_raw_call): Rename. + +1999-08-02 Kresten Krab Thorup + + * src/x86/ffi.c (ffi_closure_SYSV): New function. + (ffi_prep_incoming_args_SYSV): Ditto. + (ffi_prep_closure): Ditto. + (ffi_closure_raw_SYSV): Ditto. + (ffi_prep_raw_closure): More ditto. + (ffi_call_raw): Final ditto. + + * include/ffi.h.in: Add definitions for closure and raw API. + + * src/x86/ffi.c (ffi_prep_cif_machdep): Added case for + FFI_TYPE_UINT64. + + * Makefile.am (libffi_la_common_SOURCES): Added raw_api.c + + * src/raw_api.c: New file. + + * include/ffi.h.in (ffi_raw): New type. + (UINT_ARG, SINT_ARG): New defines. + (ffi_closure, ffi_raw_closure): New types. + (ffi_prep_closure, ffi_prep_raw_closure): New declarations. + + * configure.in: Add check for endianness and sizeof void*. + + * src/x86/sysv.S (ffi_call_SYSV): Call fixup routine via argument, + instead of directly. + + * configure: Rebuilt. + +Thu Jul 8 14:28:42 1999 Anthony Green + + * configure.in: Add x86 and powerpc BeOS configurations. + From Makoto Kato . + +1999-05-09 Anthony Green + + * configure.in: Add warning about this being beta code. + Remove src/Makefile.am from the picture. + * configure: Rebuilt. + + * Makefile.am: Move logic from src/Makefile.am. Add changes + to support libffi as a target library. + * Makefile.in: Rebuilt. + + * aclocal.m4, config.guess, config.sub, ltconfig, ltmain.sh: + Upgraded to new autoconf, automake, libtool. + + * README: Tweaks. + + * LICENSE: Update copyright date. + + * src/Makefile.am, src/Makefile.in: Removed. + +1998-11-29 Anthony Green + + * include/ChangeLog: Removed. + * src/ChangeLog: Removed. + * src/mips/ChangeLog: Removed. + * src/sparc/ChangeLog: Remboved. + * src/x86/ChangeLog: Removed. + + * ChangeLog.v1: Created. diff --git a/user/mpy/lib/libffi/ChangeLog.libgcj b/user/mpy/lib/libffi/ChangeLog.libgcj new file mode 100644 index 0000000..ea5d02f --- /dev/null +++ b/user/mpy/lib/libffi/ChangeLog.libgcj @@ -0,0 +1,40 @@ +2004-01-14 Kelley Cook + + * configure.in: Add in AC_PREREQ(2.13) + +2003-02-20 Alexandre Oliva + + * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to + config.status. + * configure: Rebuilt. + +2002-01-27 Alexandre Oliva + + * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST. + Remove USE_LIBDIR conditional. + * Makefile.am (toolexecdir, toolexeclibdir): Don't override. + * Makefile.in, configure: Rebuilt. + +Mon Aug 9 18:33:38 1999 Rainer Orth + + * include/Makefile.in: Rebuilt. + * Makefile.in: Rebuilt + * Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native + builds. + Use USE_LIBDIR. + + * configure: Rebuilt. + * configure.in (USE_LIBDIR): Define for native builds. + Use lowercase in configure --help explanations. + +1999-08-08 Anthony Green + + * include/ffi.h.in (FFI_FN): Remove `...'. + +1999-08-08 Anthony Green + + * Makefile.in: Rebuilt. + * Makefile.am (AM_CFLAGS): Compile with -fexceptions. + + * src/x86/sysv.S: Add exception handling metadata. + diff --git a/user/mpy/lib/libffi/ChangeLog.v1 b/user/mpy/lib/libffi/ChangeLog.v1 new file mode 100644 index 0000000..af3a377 --- /dev/null +++ b/user/mpy/lib/libffi/ChangeLog.v1 @@ -0,0 +1,764 @@ +The libffi version 1 ChangeLog archive. + +Version 1 of libffi had per-directory ChangeLogs. Current and future +versions have a single ChangeLog file in the root directory. The +version 1 ChangeLogs have all been concatenated into this file for +future reference only. + +--- libffi ---------------------------------------------------------------- + +Mon Oct 5 02:17:50 1998 Anthony Green + + * configure.in: Boosted rev. + * configure, Makefile.in, aclocal.m4: Rebuilt. + * README: Boosted rev and updated release notes. + +Mon Oct 5 01:03:03 1998 Anthony Green + + * configure.in: Boosted rev. + * configure, Makefile.in, aclocal.m4: Rebuilt. + * README: Boosted rev and updated release notes. + +1998-07-25 Andreas Schwab + + * m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags. + Correctly handle small structures. + (ffi_prep_args): Also handle small structures. + (ffi_call): Pass size of return type to ffi_call_SYSV. + * m68k/sysv.S: Adjust for above changes. Correctly align small + structures in the return value. + + * types.c (uint64, sint64) [M68K]: Change alignment to 4. + +Fri Apr 17 17:26:58 1998 Anthony Green + + * configure.in: Boosted rev. + * configure,Makefile.in,aclocal.m4: Rebuilt. + * README: Boosted rev and added release notes. + +Sun Feb 22 00:50:41 1998 Geoff Keating + + * configure.in: Add PowerPC config bits. + +1998-02-14 Andreas Schwab + + * configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM + to AC_CANONICAL_HOST, this is not a compiler. Use $host instead + of $target. Remove AC_CHECK_SIZEOF(char), we already know the + result. Fix argument of AC_ARG_ENABLE. + * configure, fficonfig.h.in: Rebuilt. + +Tue Feb 10 20:53:40 1998 Richard Henderson + + * configure.in: Add Alpha config bits. + +Tue May 13 13:39:20 1997 Anthony Green + + * README: Updated dates and reworded Irix comments. + + * configure.in: Removed AC_PROG_RANLIB. + + * Makefile.in, aclocal.m4, config.guess, config.sub, configure, + ltmain.sh, */Makefile.in: libtoolized again and rebuilt with + automake and autoconf. + +Sat May 10 18:44:50 1997 Tom Tromey + + * configure, aclocal.m4: Rebuilt. + * configure.in: Don't compute EXTRADIST; now handled in + src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE. + Don't run AM_MAINTAINER_MODE. + +Thu May 8 14:34:05 1997 Anthony Green + + * missing, ltmain.sh, ltconfig.sh: Created. These are new files + required by automake and libtool. + + * README: Boosted rev to 1.14. Added notes. + + * acconfig.h: Moved PACKAGE and VERSION for new automake. + + * configure.in: Changes for libtool. + + * Makefile.am (check): make test now make check. Uses libtool now. + + * Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt. + +Thu May 1 16:27:07 1997 Anthony Green + + * missing: Added file required by new automake. + +Tue Nov 26 14:10:42 1996 Anthony Green + + * acconfig.h: Added USING_PURIFY flag. This is defined when + --enable-purify-safety was used at configure time. + + * configure.in (allsources): Added --enable-purify-safety switch. + (VERSION): Boosted rev to 1.13. + * configure: Rebuilt. + +Fri Nov 22 06:46:12 1996 Anthony Green + + * configure.in (VERSION): Boosted rev to 1.12. + Removed special CFLAGS hack for gcc. + * configure: Rebuilt. + + * README: Boosted rev to 1.12. Added notes. + + * Many files: Cygnus Support changed to Cygnus Solutions. + +Wed Oct 30 11:15:25 1996 Anthony Green + + * configure.in (VERSION): Boosted rev to 1.11. + * configure: Rebuilt. + + * README: Boosted rev to 1.11. Added notes about GNU make. + +Tue Oct 29 12:25:12 1996 Anthony Green + + * configure.in: Fixed -Wall trick. + (VERSION): Boosted rev. + * configure: Rebuilt + + * acconfig.h: Needed for --enable-debug configure switch. + + * README: Boosted rev to 1.09. Added more notes on building + libffi, and LCLint. + + * configure.in: Added --enable-debug switch. Boosted rev to + 1.09. + * configure: Rebuilt + +Tue Oct 15 13:11:28 1996 Anthony Green + + * configure.in (VERSION): Boosted rev to 1.08 + * configure: Rebuilt. + + * README: Added n32 bug fix notes. + + * Makefile.am: Added "make lint" production. + * Makefile.in: Rebuilt. + +Mon Oct 14 10:54:46 1996 Anthony Green + + * README: Added web page reference. + + * configure.in, README: Boosted rev to 1.05 + * configure: Rebuilt. + + * README: Fixed n32 sample code. + +Fri Oct 11 17:09:28 1996 Anthony Green + + * README: Added sparc notes. + + * configure.in, README: Boosted rev to 1.04. + * configure: Rebuilt. + +Thu Oct 10 10:31:03 1996 Anthony Green + + * configure.in, README: Boosted rev to 1.03. + * configure: Rebuilt. + + * README: Added struct notes. + + * Makefile.am (EXTRA_DIST): Added LICENSE to distribution. + * Makefile.in: Rebuilt. + + * README: Removed Linux section. No special notes now + because aggregates arg/return types work. + +Wed Oct 9 16:16:42 1996 Anthony Green + + * README, configure.in (VERSION): Boosted rev to 1.02 + * configure: Rebuilt. + +Tue Oct 8 11:56:33 1996 Anthony Green + + * README (NOTE): Added n32 notes. + + * Makefile.am: Added test production. + * Makefile: Rebuilt + + * README: spell checked! + + * configure.in (VERSION): Boosted rev to 1.01 + * configure: Rebuilt. + +Mon Oct 7 15:50:22 1996 Anthony Green + + * configure.in: Added nasty bit to support SGI tools. + * configure: Rebuilt. + + * README: Added SGI notes. Added note about automake bug. + +Mon Oct 7 11:00:28 1996 Anthony Green + + * README: Rewrote intro, and fixed examples. + +Fri Oct 4 10:19:55 1996 Anthony Green + + * configure.in: -D$TARGET is no longer used as a compiler switch. + It is now inserted into ffi.h at configure time. + * configure: Rebuilt. + + * FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status. + +Thu Oct 3 13:47:34 1996 Anthony Green + + * README, LICENSE: Created. Wrote some docs. + + * configure.in: Don't barf on i586-unknown-linuxaout. + Added EXTRADIST code for "make dist". + * configure: Rebuilt. + + * */Makefile.in: Rebuilt with patched automake. + +Tue Oct 1 17:12:25 1996 Anthony Green + + * Makefile.am, aclocal.m4, config.guess, config.sub, + configure.in, fficonfig.h.in, install-sh, mkinstalldirs, + stamp-h.in: Created + * Makefile.in, configure: Generated + +--- libffi/include -------------------------------------------------------- + +Tue Feb 24 13:09:36 1998 Anthony Green + + * ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on + ffi.h.in changes. This is a work-around for SGI's "simple" + assembler. + +Sun Feb 22 00:51:55 1998 Geoff Keating + + * ffi.h.in: PowerPC support. + +1998-02-14 Andreas Schwab + + * ffi.h.in: Add m68k support. + (FFI_TYPE_LONGDOUBLE): Make it a separate value. + +Tue Feb 10 20:55:16 1998 Richard Henderson + + * ffi.h.in (SIZEOF_ARG): Use a pointer type by default. + + * ffi.h.in: Alpha support. + +Fri Nov 22 06:48:45 1996 Anthony Green + + * ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions. + +Wed Nov 20 22:31:01 1996 Anthony Green + + * ffi.h.in: Added ffi_type_void definition. + +Tue Oct 29 12:22:40 1996 Anthony Green + + * Makefile.am (hack_DATA): Always install ffi_mips.h. + + * ffi.h.in: Removed FFI_DEBUG. It's now in the correct + place (acconfig.h). + Added #include for size_t definition. + +Tue Oct 15 17:23:35 1996 Anthony Green + + * ffi.h.in, ffi_common.h, ffi_mips.h: More clean up. + Commented out #define of FFI_DEBUG. + +Tue Oct 15 13:01:06 1996 Anthony Green + + * ffi_common.h: Added bool definition. + + * ffi.h.in, ffi_common.h: Clean up based on LCLint output. + Added funny /*@...@*/ comments to annotate source. + +Mon Oct 14 12:29:23 1996 Anthony Green + + * ffi.h.in: Interface changes based on feedback from Jim + Blandy. + +Fri Oct 11 16:49:35 1996 Anthony Green + + * ffi.h.in: Small change for sparc support. + +Thu Oct 10 14:53:37 1996 Anthony Green + + * ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for + special structure return types. + +Wed Oct 9 13:55:57 1996 Anthony Green + + * ffi.h.in: Added SIZEOF_ARG definition for X86 + +Tue Oct 8 11:40:36 1996 Anthony Green + + * ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings. + Use it to case your function pointers to the proper type. + + * ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug. + + * Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST. + * Makefile: Rebuilt. + + * ffi_mips.h: Created. Moved all common mips definitions here. + +Mon Oct 7 10:58:12 1996 Anthony Green + + * ffi.h.in: The SGI assember is very picky about parens. Redefined + some macros to avoid problems. + + * ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added + externs for pointer, and 64bit integral ffi_types. + +Fri Oct 4 09:51:37 1996 Anthony Green + + * ffi.h.in: Added FFI_ABI member to ffi_cif and changed + function prototypes accordingly. + Added #define @TARGET@. Now programs including ffi.h don't + have to specify this themselves. + +Thu Oct 3 15:36:44 1996 Anthony Green + + * ffi.h.in: Changed ffi_prep_cif's values from void* to void** + + * Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist" + to work. + * Makefile.in: Regenerated. + +Wed Oct 2 10:16:59 1996 Anthony Green + + * Makefile.am: Created + * Makefile.in: Generated + + * ffi_common.h: Added rcsid comment + +Tue Oct 1 17:13:51 1996 Anthony Green + + * ffi.h.in, ffi_common.h: Created + +--- libffi/src ------------------------------------------------------------ + +Mon Oct 5 02:17:50 1998 Anthony Green + + * arm/ffi.c, arm/sysv.S: Created. + + * Makefile.am: Added arm files. + * Makefile.in: Rebuilt. + +Mon Oct 5 01:41:38 1998 Anthony Green + + * Makefile.am (libffi_la_LDFLAGS): Incremented revision. + +Sun Oct 4 16:27:17 1998 Anthony Green + + * alpha/osf.S (ffi_call_osf): Patch for DU assembler. + + * ffitest.c (main): long long and long double return values work + for x86. + +Fri Apr 17 11:50:58 1998 Anthony Green + + * Makefile.in: Rebuilt. + + * ffitest.c (main): Floating point tests not executed for systems + with broken lond double (SunOS 4 w/ GCC). + + * types.c: Fixed x86 alignment info for long long types. + +Thu Apr 16 07:15:28 1998 Anthony Green + + * ffitest.c: Added more notes about GCC bugs under Irix 6. + +Wed Apr 15 08:42:22 1998 Anthony Green + + * ffitest.c (struct5): New test function. + (main): New test with struct5. + +Thu Mar 5 10:48:11 1998 Anthony Green + + * prep_cif.c (initialize_aggregate): Fix assertion for + nested structures. + +Tue Feb 24 16:33:41 1998 Anthony Green + + * prep_cif.c (ffi_prep_cif): Added long double support for sparc. + +Sun Feb 22 00:52:18 1998 Geoff Keating + + * powerpc/asm.h: New file. + * powerpc/ffi.c: New file. + * powerpc/sysv.S: New file. + * Makefile.am: PowerPC port. + * ffitest.c (main): Allow all tests to run even in presence of gcc + bug on PowerPC. + +1998-02-17 Anthony Green + + * mips/ffi.c: Fixed comment typo. + + * x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat): + Fixed x86 long double return handling. + + * types.c: Fixed x86 long double alignment info. + +1998-02-14 Andreas Schwab + + * types.c: Add m68k support. + + * ffitest.c (floating): Add long double parameter. + (return_ll, ldblit): New functions to test long long and long + double return value. + (main): Fix type error in assignment of ts[1-4]_type.elements. + Add tests for long long and long double arguments and return + values. + + * prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for + struct value pointer. + + * m68k/ffi.c, m68k/sysv.S: New files. + * Makefile.am: Add bits for m68k port. Add kludge to work around + automake deficiency. + (test): Don't require "." in $PATH. + * Makefile.in: Rebuilt. + +Wed Feb 11 07:36:50 1998 Anthony Green + + * Makefile.in: Rebuilt. + +Tue Feb 10 20:56:00 1998 Richard Henderson + + * alpha/ffi.c, alpha/osf.S: New files. + * Makefile.am: Alpha port. + +Tue Nov 18 14:12:07 1997 Anthony Green + + * mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag + for n32. + +Tue Jun 3 17:18:20 1997 Anthony Green + + * ffitest.c (main): Added hack to get structure tests working + correctly. + +Sat May 10 19:06:42 1997 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (EXTRA_DIST): Explicitly list all distributable + files in subdirs. + (VERSION, CC): Removed. + +Thu May 8 17:19:01 1997 Anthony Green + + * Makefile.am: Many changes for new automake and libtool. + * Makefile.in: Rebuilt. + +Fri Nov 22 06:57:56 1996 Anthony Green + + * ffitest.c (main): Fixed test case for non mips machines. + +Wed Nov 20 22:31:59 1996 Anthony Green + + * types.c: Added ffi_type_void declaration. + +Tue Oct 29 13:07:19 1996 Anthony Green + + * ffitest.c (main): Fixed character constants. + (main): Emit warning for structure test 3 failure on Sun. + + * Makefile.am (VPATH): Fixed VPATH def'n so automake won't + strip it out. + Moved distdir hack from libffi to automake. + (ffitest): Added missing -c for $(COMPILE) (change in automake). + * Makefile.in: Rebuilt. + +Tue Oct 15 13:08:20 1996 Anthony Green + + * Makefile.am: Added "make lint" production. + * Makefile.in: Rebuilt. + + * prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro. + Clean up based on LCLint output. Added funny /*@...@*/ comments to + annotate source. + + * ffitest.c, debug.c: Cleaned up code. + +Mon Oct 14 12:26:56 1996 Anthony Green + + * ffitest.c: Changes based on interface changes. + + * prep_cif.c (ffi_prep_cif): Cleaned up interface based on + feedback from Jim Blandy. + +Fri Oct 11 15:53:18 1996 Anthony Green + + * ffitest.c: Reordered tests while porting to sparc. + Made changes to handle lame structure passing for sparc. + Removed calls to fflush(). + + * prep_cif.c (ffi_prep_cif): Added special case for sparc + aggregate type arguments. + +Thu Oct 10 09:56:51 1996 Anthony Green + + * ffitest.c (main): Added structure passing/returning tests. + + * prep_cif.c (ffi_prep_cif): Perform proper initialization + of structure return types if needed. + (initialize_aggregate): Bug fix + +Wed Oct 9 16:04:20 1996 Anthony Green + + * types.c: Added special definitions for x86 (double doesn't + need double word alignment). + + * ffitest.c: Added many tests + +Tue Oct 8 09:19:22 1996 Anthony Green + + * prep_cif.c (ffi_prep_cif): Fixed assertion. + + * debug.c (ffi_assert): Must return a non void now. + + * Makefile.am: Added test production. + * Makefile: Rebuilt. + + * ffitest.c (main): Created. + + * types.c: Created. Stripped common code out of */ffi.c. + + * prep_cif.c: Added missing stdlib.h include. + + * debug.c (ffi_type_test): Used "a" to eliminate compiler + warnings in non-debug builds. Included ffi_common.h. + +Mon Oct 7 15:36:42 1996 Anthony Green + + * Makefile.am: Added a rule for .s -> .o + This is required by the SGI compiler. + * Makefile: Rebuilt. + +Fri Oct 4 09:51:08 1996 Anthony Green + + * prep_cif.c (initialize_aggregate): Moved abi specification + to ffi_prep_cif(). + +Thu Oct 3 15:37:37 1996 Anthony Green + + * prep_cif.c (ffi_prep_cif): Changed values from void* to void**. + (initialize_aggregate): Fixed aggregate type initialization. + + * Makefile.am (EXTRA_DIST): Added support code for "make dist". + * Makefile.in: Regenerated. + +Wed Oct 2 11:41:57 1996 Anthony Green + + * debug.c, prep_cif: Created. + + * Makefile.am: Added debug.o and prep_cif.o to OBJ. + * Makefile.in: Regenerated. + + * Makefile.am (INCLUDES): Added missing -I../include + * Makefile.in: Regenerated. + +Tue Oct 1 17:11:51 1996 Anthony Green + + * error.c, Makefile.am: Created. + * Makefile.in: Generated. + +--- libffi/src/x86 -------------------------------------------------------- + +Sun Oct 4 16:27:17 1998 Anthony Green + + * sysv.S (retlongdouble): Fixed long long return value support. + * ffi.c (ffi_prep_cif_machdep): Ditto. + +Wed May 13 04:30:33 1998 Anthony Green + + * ffi.c (ffi_prep_cif_machdep): Fixed long double return value + support. + +Wed Apr 15 08:43:20 1998 Anthony Green + + * ffi.c (ffi_prep_args): small struct support was missing. + +Thu May 8 16:53:58 1997 Anthony Green + + * objects.mak: Removed. + +Mon Dec 2 15:12:58 1996 Tom Tromey + + * sysv.S: Use .balign, for a.out Linux boxes. + +Tue Oct 15 13:06:50 1996 Anthony Green + + * ffi.c: Clean up based on LCLint output. + Added funny /*@...@*/ comments to annotate source. + +Fri Oct 11 16:43:38 1996 Anthony Green + + * ffi.c (ffi_call): Added assertion for bad ABIs. + +Wed Oct 9 13:57:27 1996 Anthony Green + + * sysv.S (retdouble): Fixed double return problems. + + * ffi.c (ffi_call): Corrected fn arg definition. + (ffi_prep_cif_machdep): Fixed double return problems + +Tue Oct 8 12:12:49 1996 Anthony Green + + * ffi.c: Moved ffi_type definitions to types.c. + (ffi_prep_args): Fixed type promotion bug. + +Mon Oct 7 15:53:06 1996 Anthony Green + + * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' + +Fri Oct 4 09:54:53 1996 Anthony Green + + * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped + remaining args. + +Wed Oct 2 10:07:05 1996 Anthony Green + + * ffi.c, sysv.S, objects.mak: Created. + (ffi_prep_cif): cif->rvalue no longer initialized to NULL. + (ffi_prep_cif_machdep): Moved machine independent cif processing + to src/prep_cif.c. Introduced ffi_prep_cif_machdep(). + +--- libffi/src/mips ------------------------------------------------------- + +Tue Feb 17 17:18:07 1998 Anthony Green + + * o32.S: Fixed typo in comment. + + * ffi.c (ffi_prep_cif_machdep): Fixed argument processing. + +Thu May 8 16:53:58 1997 Anthony Green + + * o32.s, n32.s: Wrappers for SGI tool support. + + * objects.mak: Removed. + +Tue Oct 29 14:37:45 1996 Anthony Green + + * ffi.c (ffi_prep_args): Changed int z to size_t z. + +Tue Oct 15 13:17:25 1996 Anthony Green + + * n32.S: Fixed bad stack munging. + + * ffi.c: Moved prototypes for ffi_call_?32() to here from + ffi_mips.h because extended_cif is not defined in ffi_mips.h. + +Mon Oct 14 12:42:02 1996 Anthony Green + + * ffi.c: Interface changes based on feedback from Jim Blandy. + +Thu Oct 10 11:22:16 1996 Anthony Green + + * n32.S, ffi.c: Lots of changes to support passing and + returning structures with the n32 calling convention. + + * n32.S: Fixed fn pointer bug. + + * ffi.c (ffi_prep_cif_machdep): Fix for o32 structure + return values. + (ffi_prep_args): Fixed n32 structure passing when structures + partially fit in registers. + +Wed Oct 9 13:49:25 1996 Anthony Green + + * objects.mak: Added n32.o. + + * n32.S: Created. + + * ffi.c (ffi_prep_args): Added magic to support proper + n32 processing. + +Tue Oct 8 10:37:35 1996 Anthony Green + + * ffi.c: Moved ffi_type definitions to types.c. + (ffi_prep_args): Fixed type promotion bug. + + * o32.S: This code is only built for o32 compiles. + A lot of the #define cruft has moved to ffi_mips.h. + + * ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg + is only processed if the first is either a float or double. + +Mon Oct 7 15:33:59 1996 Anthony Green + + * o32.S: Modified to compile under each of o32, n32 and n64. + + * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' + +Fri Oct 4 09:53:25 1996 Anthony Green + + * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped + remaining args. + +Wed Oct 2 17:41:22 1996 Anthony Green + + * o32.S: Removed crufty definitions. + +Wed Oct 2 12:53:42 1996 Anthony Green + + * ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL. + (ffi_prep_cif_machdep): Moved all machine independent cif processing + to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types + of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT. + +Tue Oct 1 17:11:02 1996 Anthony Green + + * ffi.c, o32.S, object.mak: Created + +--- libffi/src/sparc ------------------------------------------------------ + +Tue Feb 24 16:33:18 1998 Anthony Green + + * ffi.c (ffi_prep_args): Added long double support. + +Thu May 8 16:53:58 1997 Anthony Green + + * objects.mak: Removed. + +Thu May 1 16:07:56 1997 Anthony Green + + * v8.S: Fixed minor portability problem reported by + Russ McManus . + +Tue Nov 26 14:12:43 1996 Anthony Green + + * v8.S: Used STACKFRAME define elsewhere. + + * ffi.c (ffi_prep_args): Zero out space when USING_PURIFY + is set. + (ffi_prep_cif_machdep): Allocate the correct stack frame + space for functions with < 6 args. + +Tue Oct 29 15:08:55 1996 Anthony Green + + * ffi.c (ffi_prep_args): int z is now size_t z. + +Mon Oct 14 13:31:24 1996 Anthony Green + + * v8.S (ffi_call_V8): Gordon rewrites this again. It looks + great now. + + * ffi.c (ffi_call): The comment about hijacked registers + is no longer valid after gordoni hacked v8.S. + + * v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler. + + * v8.S, ffi.c: ffi_call() had changed to accept more than + two args, so v8.S had to change (because it hijacks incoming + arg registers). + + * ffi.c: Interface changes based on feedback from Jim Blandy. + +Thu Oct 10 17:48:16 1996 Anthony Green + + * ffi.c, v8.S, objects.mak: Created. + + diff --git a/user/mpy/lib/libffi/LICENSE b/user/mpy/lib/libffi/LICENSE new file mode 100644 index 0000000..a66fab4 --- /dev/null +++ b/user/mpy/lib/libffi/LICENSE @@ -0,0 +1,21 @@ +libffi - Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others. +See source files for details. + +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. diff --git a/user/mpy/lib/libffi/Makefile.am b/user/mpy/lib/libffi/Makefile.am new file mode 100644 index 0000000..6fb3d47 --- /dev/null +++ b/user/mpy/lib/libffi/Makefile.am @@ -0,0 +1,174 @@ +## Process this with automake to create Makefile.in + +AUTOMAKE_OPTIONS = foreign subdir-objects + +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = include testsuite man + +EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \ + ChangeLog.libffi ChangeLog.libffi-3.1 \ + m4/libtool.m4 m4/lt~obsolete.m4 \ + m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ + m4/ltversion.m4 src/debug.c msvcc.sh \ + generate-darwin-source-and-headers.py \ + libffi.xcodeproj/project.pbxproj \ + libtool-ldflags + +info_TEXINFOS = doc/libffi.texi + +## ################################################################ + +## +## This section is for make and multilib madness. +## + +# Work around what appears to be a GNU make bug handling MAKEFLAGS +# values defined in terms of make variables, as is the case for CC and +# friends when we are called from the top level Makefile. +AM_MAKEFLAGS = \ + 'AR_FLAGS=$(AR_FLAGS)' \ + 'CC_FOR_BUILD=$(CC_FOR_BUILD)' \ + 'CFLAGS=$(CFLAGS)' \ + 'CXXFLAGS=$(CXXFLAGS)' \ + 'CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)' \ + 'CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)' \ + 'INSTALL=$(INSTALL)' \ + 'INSTALL_DATA=$(INSTALL_DATA)' \ + 'INSTALL_PROGRAM=$(INSTALL_PROGRAM)' \ + 'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \ + 'JC1FLAGS=$(JC1FLAGS)' \ + 'LDFLAGS=$(LDFLAGS)' \ + 'LIBCFLAGS=$(LIBCFLAGS)' \ + 'LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)' \ + 'MAKE=$(MAKE)' \ + 'MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)' \ + 'PICFLAG=$(PICFLAG)' \ + 'PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)' \ + 'RUNTESTFLAGS=$(RUNTESTFLAGS)' \ + 'SHELL=$(SHELL)' \ + 'exec_prefix=$(exec_prefix)' \ + 'infodir=$(infodir)' \ + 'libdir=$(libdir)' \ + 'mandir=$(mandir)' \ + 'prefix=$(prefix)' \ + 'AR=$(AR)' \ + 'AS=$(AS)' \ + 'CC=$(CC)' \ + 'CXX=$(CXX)' \ + 'LD=$(LD)' \ + 'NM=$(NM)' \ + 'RANLIB=$(RANLIB)' \ + 'DESTDIR=$(DESTDIR)' + +# Subdir rules rely on $(FLAGS_TO_PASS) +FLAGS_TO_PASS = $(AM_MAKEFLAGS) + +MAKEOVERRIDES= + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libffi.pc + +toolexeclib_LTLIBRARIES = libffi.la +noinst_LTLIBRARIES = libffi_convenience.la + +libffi_la_SOURCES = src/prep_cif.c src/types.c \ + src/raw_api.c src/java_raw_api.c src/closures.c + +if FFI_DEBUG +libffi_la_SOURCES += src/debug.c +endif + +noinst_HEADERS = \ + src/aarch64/ffitarget.h src/aarch64/internal.h \ + src/alpha/ffitarget.h src/alpha/internal.h \ + src/arc/ffitarget.h \ + src/arm/ffitarget.h src/arm/internal.h \ + src/avr32/ffitarget.h \ + src/bfin/ffitarget.h \ + src/cris/ffitarget.h \ + src/frv/ffitarget.h \ + src/ia64/ffitarget.h src/ia64/ia64_flags.h \ + src/m32r/ffitarget.h \ + src/m68k/ffitarget.h \ + src/m88k/ffitarget.h \ + src/metag/ffitarget.h \ + src/microblaze/ffitarget.h \ + src/mips/ffitarget.h \ + src/moxie/ffitarget.h \ + src/nios2/ffitarget.h \ + src/or1k/ffitarget.h \ + src/pa/ffitarget.h \ + src/powerpc/ffitarget.h src/powerpc/asm.h src/powerpc/ffi_powerpc.h \ + src/s390/ffitarget.h \ + src/sh/ffitarget.h \ + src/sh64/ffitarget.h \ + src/sparc/ffitarget.h src/sparc/internal.h \ + src/tile/ffitarget.h \ + src/vax/ffitarget.h \ + src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h \ + src/xtensa/ffitarget.h \ + src/dlmalloc.c + +EXTRA_libffi_la_SOURCES = \ + src/aarch64/ffi.c src/aarch64/sysv.S \ + src/alpha/ffi.c src/alpha/osf.S \ + src/arc/ffi.c src/arc/arcompact.S \ + src/arm/ffi.c src/arm/sysv.S \ + src/avr32/ffi.c src/avr32/sysv.S \ + src/bfin/ffi.c src/bfin/sysv.S \ + src/cris/ffi.c src/cris/sysv.S \ + src/frv/ffi.c src/frv/eabi.S \ + src/ia64/ffi.c src/ia64/unix.S \ + src/m32r/ffi.c src/m32r/sysv.S \ + src/m68k/ffi.c src/m68k/sysv.S \ + src/m88k/ffi.c src/m88k/obsd.S \ + src/metag/ffi.c src/metag/sysv.S \ + src/microblaze/ffi.c src/microblaze/sysv.S \ + src/mips/ffi.c src/mips/o32.S src/mips/n32.S \ + src/moxie/ffi.c src/moxie/eabi.S \ + src/nios2/ffi.c src/nios2/sysv.S \ + src/or1k/ffi.c src/or1k/sysv.S \ + src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ + src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \ + src/powerpc/sysv.S src/powerpc/linux64.S \ + src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ + src/powerpc/aix.S src/powerpc/darwin.S src/powerpc/aix_closure.S \ + src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ + src/s390/ffi.c src/s390/sysv.S \ + src/sh/ffi.c src/sh/sysv.S \ + src/sh64/ffi.c src/sh64/sysv.S \ + src/sparc/ffi.c src/sparc/ffi64.c src/sparc/v8.S src/sparc/v9.S \ + src/tile/ffi.c src/tile/tile.S \ + src/vax/ffi.c src/vax/elfbsd.S \ + src/x86/ffi.c src/x86/sysv.S \ + src/x86/ffiw64.c src/x86/win64.S \ + src/x86/ffi64.c src/x86/unix64.S \ + src/xtensa/ffi.c src/xtensa/sysv.S + +TARGET_OBJ = @TARGET_OBJ@ +libffi_la_LIBADD = $(TARGET_OBJ) +libffi_la_DEPENDENCIES = $(TARGET_OBJ) + +libffi_convenience_la_SOURCES = $(libffi_la_SOURCES) +EXTRA_libffi_convenience_la_SOURCES = $(EXTRA_libffi_la_SOURCES) +libffi_convenience_la_LIBADD = $(libffi_la_LIBADD) +libffi_convenience_la_DEPENDENCIES = $(libffi_la_DEPENDENCIES) +nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) + +LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) + +AM_CFLAGS = +if FFI_DEBUG +# Build debug. Define FFI_DEBUG on the commandline so that, when building with +# MSVC, it can link against the debug CRT. +AM_CFLAGS += -DFFI_DEBUG +endif + +libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) + +AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src +AM_CCASFLAGS = $(AM_CPPFLAGS) + +dist-hook: + if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog diff --git a/user/mpy/lib/libffi/README b/user/mpy/lib/libffi/README new file mode 100644 index 0000000..c072101 --- /dev/null +++ b/user/mpy/lib/libffi/README @@ -0,0 +1,450 @@ +Status +====== + +libffi-4?? was released on TBD. Check the libffi web +page for updates: . + + +What is libffi? +=============== + +Compilers for high level languages generate code that follow certain +conventions. These conventions are necessary, in part, for separate +compilation to work. One such convention is the "calling +convention". The "calling convention" is essentially a set of +assumptions made by the compiler about where function arguments will +be found on entry to a function. A "calling convention" also specifies +where the return value for a function is found. + +Some programs may not know at the time of compilation what arguments +are to be passed to a function. For instance, an interpreter may be +told at run-time about the number and types of arguments used to call +a given function. Libffi can be used in such programs to provide a +bridge from the interpreter program to compiled code. + +The libffi library provides a portable, high level programming +interface to various calling conventions. This allows a programmer to +call any function specified by a call interface description at run +time. + +FFI stands for Foreign Function Interface. A foreign function +interface is the popular name for the interface that allows code +written in one language to call code written in another language. The +libffi library really only provides the lowest, machine dependent +layer of a fully featured foreign function interface. A layer must +exist above libffi that handles type conversions for values passed +between the two languages. + + +Supported Platforms +=================== + +Libffi has been ported to many different platforms. +For specific configuration details and testing status, please +refer to the wiki page here: + + http://www.moxielogic.org/wiki/index.php?title=Libffi_3.2 + +At the time of release, the following basic configurations have been +tested: + +|-----------------+------------------+-------------------------| +| Architecture | Operating System | Compiler | +|-----------------+------------------+-------------------------| +| AArch64 (ARM64) | iOS | Clang | +| AArch64 | Linux | GCC | +| Alpha | Linux | GCC | +| Alpha | Tru64 | GCC | +| ARC | Linux | GCC | +| ARM | Linux | GCC | +| ARM | iOS | GCC | +| AVR32 | Linux | GCC | +| Blackfin | uClinux | GCC | +| HPPA | HPUX | GCC | +| IA-64 | Linux | GCC | +| M68K | FreeMiNT | GCC | +| M68K | Linux | GCC | +| M68K | RTEMS | GCC | +| M88K | OpenBSD/mvme88k | GCC | +| Meta | Linux | GCC | +| MicroBlaze | Linux | GCC | +| MIPS | IRIX | GCC | +| MIPS | Linux | GCC | +| MIPS | RTEMS | GCC | +| MIPS64 | Linux | GCC | +| Moxie | Bare metal | GCC | +| Nios II | Linux | GCC | +| OpenRISC | Linux | GCC | +| PowerPC 32-bit | AIX | IBM XL C | +| PowerPC 64-bit | AIX | IBM XL C | +| PowerPC | AMIGA | GCC | +| PowerPC | Linux | GCC | +| PowerPC | Mac OSX | GCC | +| PowerPC | FreeBSD | GCC | +| PowerPC 64-bit | FreeBSD | GCC | +| PowerPC 64-bit | Linux ELFv1 | GCC | +| PowerPC 64-bit | Linux ELFv2 | GCC | +| S390 | Linux | GCC | +| S390X | Linux | GCC | +| SPARC | Linux | GCC | +| SPARC | Solaris | GCC | +| SPARC | Solaris | Oracle Solaris Studio C | +| SPARC64 | Linux | GCC | +| SPARC64 | FreeBSD | GCC | +| SPARC64 | Solaris | Oracle Solaris Studio C | +| TILE-Gx/TILEPro | Linux | GCC | +| VAX | OpenBSD/vax | GCC | +| X86 | FreeBSD | GCC | +| X86 | GNU HURD | GCC | +| X86 | Interix | GCC | +| X86 | kFreeBSD | GCC | +| X86 | Linux | GCC | +| X86 | Mac OSX | GCC | +| X86 | OpenBSD | GCC | +| X86 | OS/2 | GCC | +| X86 | Solaris | GCC | +| X86 | Solaris | Oracle Solaris Studio C | +| X86 | Windows/Cygwin | GCC | +| X86 | Windows/MingW | GCC | +| X86-64 | FreeBSD | GCC | +| X86-64 | Linux | GCC | +| X86-64 | Linux/x32 | GCC | +| X86-64 | OpenBSD | GCC | +| X86-64 | Solaris | Oracle Solaris Studio C | +| X86-64 | Windows/Cygwin | GCC | +| X86-64 | Windows/MingW | GCC | +| Xtensa | Linux | GCC | +|-----------------+------------------+-------------------------| + +Please send additional platform test results to +libffi-discuss@sourceware.org and feel free to update the wiki page +above. + +Installing libffi +================= + +First you must configure the distribution for your particular +system. Go to the directory you wish to build libffi in and run the +"configure" program found in the root directory of the libffi source +distribution. + +If you're building libffi directly from version control, configure won't +exist yet; run ./autogen.sh first. + +You may want to tell configure where to install the libffi library and +header files. To do that, use the --prefix configure switch. Libffi +will install under /usr/local by default. + +If you want to enable extra run-time debugging checks use the the +--enable-debug configure switch. This is useful when your program dies +mysteriously while using libffi. + +Another useful configure switch is --enable-purify-safety. Using this +will add some extra code which will suppress certain warnings when you +are using Purify with libffi. Only use this switch when using +Purify, as it will slow down the library. + +It's also possible to build libffi on Windows platforms with +Microsoft's Visual C++ compiler. In this case, use the msvcc.sh +wrapper script during configuration like so: + +path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" + +For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and +CXX="path/to/msvcc.sh -m64". You may also need to specify --build +appropriately. + +It is also possible to build libffi on Windows platforms with the LLVM +project's clang-cl compiler, like below: + +path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" + +When building with MSVC under a MingW environment, you may need to +remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath' +command. ('cygpath' is not present in MingW, and is not required when +using MingW-style paths.) + +For iOS builds, the 'libffi.xcodeproj' Xcode project is available. + +Configure has many other options. Use "configure --help" to see them all. + +Once configure has finished, type "make". Note that you must be using +GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make . + +To ensure that libffi is working as advertised, type "make check". +This will require that you have DejaGNU installed. + +To install the library and header files, type "make install". + + +History +======= + +See the git log for details at http://github.com/atgreen/libffi. + +4.0 TBD + New API in support of GO closures. + +3.2.1 Nov-12-14 + Build fix for non-iOS AArch64 targets. + +3.2 Nov-11-14 + Add C99 Complex Type support (currently only supported on + s390). + Add support for PASCAL and REGISTER calling conventions on x86 + Windows/Linux. + Add OpenRISC and Cygwin-64 support. + Bug fixes. + +3.1 May-19-14 + Add AArch64 (ARM64) iOS support. + Add Nios II support. + Add m88k and DEC VAX support. + Add support for stdcall, thiscall, and fastcall on non-Windows + 32-bit x86 targets such as Linux. + Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi + fixes. + Make the testsuite more robust: eliminate several spurious + failures, and respect the $CC and $CXX environment variables. + Archive off the manually maintained ChangeLog in favor of git + log. + +3.0.13 Mar-17-13 + Add Meta support. + Add missing Moxie bits. + Fix stack alignment bug on 32-bit x86. + Build fix for m68000 targets. + Build fix for soft-float Power targets. + Fix the install dir location for some platforms when building + with GCC (OS X, Solaris). + Fix Cygwin regression. + +3.0.12 Feb-11-13 + Add Moxie support. + Add AArch64 support. + Add Blackfin support. + Add TILE-Gx/TILEPro support. + Add MicroBlaze support. + Add Xtensa support. + Add support for PaX enabled kernels with MPROTECT. + Add support for native vendor compilers on + Solaris and AIX. + Work around LLVM/GCC interoperability issue on x86_64. + +3.0.11 Apr-11-12 + Lots of build fixes. + Add support for variadic functions (ffi_prep_cif_var). + Add Linux/x32 support. + Add thiscall, fastcall and MSVC cdecl support on Windows. + Add Amiga and newer MacOS support. + Add m68k FreeMiNT support. + Integration with iOS' xcode build tools. + Fix Octeon and MC68881 support. + Fix code pessimizations. + +3.0.10 Aug-23-11 + Add support for Apple's iOS. + Add support for ARM VFP ABI. + Add RTEMS support for MIPS and M68K. + Fix instruction cache clearing problems on + ARM and SPARC. + Fix the N64 build on mips-sgi-irix6.5. + Enable builds with Microsoft's compiler. + Enable x86 builds with Oracle's Solaris compiler. + Fix support for calling code compiled with Oracle's Sparc + Solaris compiler. + Testsuite fixes for Tru64 Unix. + Additional platform support. + +3.0.9 Dec-31-09 + Add AVR32 and win64 ports. Add ARM softfp support. + Many fixes for AIX, Solaris, HP-UX, *BSD. + Several PowerPC and x86-64 bug fixes. + Build DLL for windows. + +3.0.8 Dec-19-08 + Add *BSD, BeOS, and PA-Linux support. + +3.0.7 Nov-11-08 + Fix for ppc FreeBSD. + (thanks to Andreas Tobler) + +3.0.6 Jul-17-08 + Fix for closures on sh. + Mark the sh/sh64 stack as non-executable. + (both thanks to Kaz Kojima) + +3.0.5 Apr-3-08 + Fix libffi.pc file. + Fix #define ARM for IcedTea users. + Fix x86 closure bug. + +3.0.4 Feb-24-08 + Fix x86 OpenBSD configury. + +3.0.3 Feb-22-08 + Enable x86 OpenBSD thanks to Thomas Heller, and + x86-64 FreeBSD thanks to Björn König and Andreas Tobler. + Clean up test instruction in README. + +3.0.2 Feb-21-08 + Improved x86 FreeBSD support. + Thanks to Björn König. + +3.0.1 Feb-15-08 + Fix instruction cache flushing bug on MIPS. + Thanks to David Daney. + +3.0.0 Feb-15-08 + Many changes, mostly thanks to the GCC project. + Cygnus Solutions is now Red Hat. + + [10 years go by...] + +1.20 Oct-5-98 + Raffaele Sena produces ARM port. + +1.19 Oct-5-98 + Fixed x86 long double and long long return support. + m68k bug fixes from Andreas Schwab. + Patch for DU assembler compatibility for the Alpha from Richard + Henderson. + +1.18 Apr-17-98 + Bug fixes and MIPS configuration changes. + +1.17 Feb-24-98 + Bug fixes and m68k port from Andreas Schwab. PowerPC port from + Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes. + +1.16 Feb-11-98 + Richard Henderson produces Alpha port. + +1.15 Dec-4-97 + Fixed an n32 ABI bug. New libtool, auto* support. + +1.14 May-13-97 + libtool is now used to generate shared and static libraries. + Fixed a minor portability problem reported by Russ McManus + . + +1.13 Dec-2-96 + Added --enable-purify-safety to keep Purify from complaining + about certain low level code. + Sparc fix for calling functions with < 6 args. + Linux x86 a.out fix. + +1.12 Nov-22-96 + Added missing ffi_type_void, needed for supporting void return + types. Fixed test case for non MIPS machines. Cygnus Support + is now Cygnus Solutions. + +1.11 Oct-30-96 + Added notes about GNU make. + +1.10 Oct-29-96 + Added configuration fix for non GNU compilers. + +1.09 Oct-29-96 + Added --enable-debug configure switch. Clean-ups based on LCLint + feedback. ffi_mips.h is always installed. Many configuration + fixes. Fixed ffitest.c for sparc builds. + +1.08 Oct-15-96 + Fixed n32 problem. Many clean-ups. + +1.07 Oct-14-96 + Gordon Irlam rewrites v8.S again. Bug fixes. + +1.06 Oct-14-96 + Gordon Irlam improved the sparc port. + +1.05 Oct-14-96 + Interface changes based on feedback. + +1.04 Oct-11-96 + Sparc port complete (modulo struct passing bug). + +1.03 Oct-10-96 + Passing struct args, and returning struct values works for + all architectures/calling conventions. Expanded tests. + +1.02 Oct-9-96 + Added SGI n32 support. Fixed bugs in both o32 and Linux support. + Added "make test". + +1.01 Oct-8-96 + Fixed float passing bug in mips version. Restructured some + of the code. Builds cleanly with SGI tools. + +1.00 Oct-7-96 + First release. No public announcement. + + +Authors & Credits +================= + +libffi was originally written by Anthony Green . + +The developers of the GNU Compiler Collection project have made +innumerable valuable contributions. See the ChangeLog file for +details. + +Some of the ideas behind libffi were inspired by Gianni Mariani's free +gencall library for Silicon Graphics machines. + +The closure mechanism was designed and implemented by Kresten Krab +Thorup. + +Major processor architecture ports were contributed by the following +developers: + +aarch64 Marcus Shawcroft, James Greenhalgh +alpha Richard Henderson +arm Raffaele Sena +blackfin Alexandre Keunecke I. de Mendonca +cris Simon Posnjak, Hans-Peter Nilsson +frv Anthony Green +ia64 Hans Boehm +m32r Kazuhiro Inaoka +m68k Andreas Schwab +m88k Miod Vallat +microblaze Nathan Rossi +mips Anthony Green, Casey Marshall +mips64 David Daney +moxie Anthony Green +nios ii Sandra Loosemore +openrisc Sebastian Macke +pa Randolph Chung, Dave Anglin, Andreas Tobler +powerpc Geoffrey Keating, Andreas Tobler, + David Edelsohn, John Hornkvist +powerpc64 Jakub Jelinek +s390 Gerhard Tonn, Ulrich Weigand +sh Kaz Kojima +sh64 Kaz Kojima +sparc Anthony Green, Gordon Irlam +tile-gx/tilepro Walter Lee +vax Miod Vallat +x86 Anthony Green, Jon Beniston +x86-64 Bo Thorsen +xtensa Chris Zankel + +Jesper Skov and Andrew Haley both did more than their fair share of +stepping through the code and tracking down bugs. + +Thanks also to Tom Tromey for bug fixes, documentation and +configuration help. + +Thanks to Jim Blandy, who provided some useful feedback on the libffi +interface. + +Andreas Tobler has done a tremendous amount of work on the testsuite. + +Alex Oliva solved the executable page problem for SElinux. + +The list above is almost certainly incomplete and inaccurate. I'm +happy to make corrections or additions upon request. + +If you have a problem, or have found a bug, please send a note to the +author at green@moxielogic.com, or the project mailing list at +libffi-discuss@sourceware.org. diff --git a/user/mpy/lib/libffi/acinclude.m4 b/user/mpy/lib/libffi/acinclude.m4 new file mode 100644 index 0000000..3e8f8ba --- /dev/null +++ b/user/mpy/lib/libffi/acinclude.m4 @@ -0,0 +1,92 @@ +# mmap(2) blacklisting. Some platforms provide the mmap library routine +# but don't support all of the features we need from it. +AC_DEFUN([AC_FUNC_MMAP_BLACKLIST], +[ +AC_CHECK_HEADER([sys/mman.h], + [libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no]) +AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no]) +if test "$libffi_header_sys_mman_h" != yes \ + || test "$libffi_func_mmap" != yes; then + ac_cv_func_mmap_file=no + ac_cv_func_mmap_dev_zero=no + ac_cv_func_mmap_anon=no +else + AC_CACHE_CHECK([whether read-only mmap of a plain file works], + ac_cv_func_mmap_file, + [# Add a system to this blacklist if + # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a + # memory area containing the same data that you'd get if you applied + # read() to the same fd. The only system known to have a problem here + # is VMS, where text files have record structure. + case "$host_os" in + vms* | ultrix*) + ac_cv_func_mmap_file=no ;; + *) + ac_cv_func_mmap_file=yes;; + esac]) + AC_CACHE_CHECK([whether mmap from /dev/zero works], + ac_cv_func_mmap_dev_zero, + [# Add a system to this blacklist if it has mmap() but /dev/zero + # does not exist, or if mmapping /dev/zero does not give anonymous + # zeroed pages with both the following properties: + # 1. If you map N consecutive pages in with one call, and then + # unmap any subset of those pages, the pages that were not + # explicitly unmapped remain accessible. + # 2. If you map two adjacent blocks of memory and then unmap them + # both at once, they must both go away. + # Systems known to be in this category are Windows (all variants), + # VMS, and Darwin. + case "$host_os" in + vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00) + ac_cv_func_mmap_dev_zero=no ;; + *) + ac_cv_func_mmap_dev_zero=yes;; + esac]) + + # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for. + AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon, + [AC_TRY_COMPILE( +[#include +#include +#include + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +], +[int n = MAP_ANONYMOUS;], + ac_cv_decl_map_anon=yes, + ac_cv_decl_map_anon=no)]) + + if test $ac_cv_decl_map_anon = no; then + ac_cv_func_mmap_anon=no + else + AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works], + ac_cv_func_mmap_anon, + [# Add a system to this blacklist if it has mmap() and MAP_ANON or + # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) + # doesn't give anonymous zeroed pages with the same properties listed + # above for use of /dev/zero. + # Systems known to be in this category are Windows, VMS, and SCO Unix. + case "$host_os" in + vms* | cygwin* | pe | mingw* | sco* | udk* ) + ac_cv_func_mmap_anon=no ;; + *) + ac_cv_func_mmap_anon=yes;; + esac]) + fi +fi + +if test $ac_cv_func_mmap_file = yes; then + AC_DEFINE(HAVE_MMAP_FILE, 1, + [Define if read-only mmap of a plain file works.]) +fi +if test $ac_cv_func_mmap_dev_zero = yes; then + AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1, + [Define if mmap of /dev/zero works.]) +fi +if test $ac_cv_func_mmap_anon = yes; then + AC_DEFINE(HAVE_MMAP_ANON, 1, + [Define if mmap with MAP_ANON(YMOUS) works.]) +fi +]) diff --git a/user/mpy/lib/libffi/autogen.sh b/user/mpy/lib/libffi/autogen.sh new file mode 100755 index 0000000..d270b98 --- /dev/null +++ b/user/mpy/lib/libffi/autogen.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec autoreconf -v -f -i diff --git a/user/mpy/lib/libffi/configure.ac b/user/mpy/lib/libffi/configure.ac new file mode 100644 index 0000000..445c589 --- /dev/null +++ b/user/mpy/lib/libffi/configure.ac @@ -0,0 +1,372 @@ +dnl Process this with autoconf to create configure + +AC_PREREQ(2.68) + +AC_INIT([libffi], [3.99999], [http://github.com/atgreen/libffi/issues]) +AC_CONFIG_HEADERS([fficonfig.h]) + +AC_CANONICAL_SYSTEM +target_alias=${target_alias-$host_alias} + +case "${host}" in + frv*-elf) + LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/ + ;; +esac + +AX_ENABLE_BUILDDIR + +AM_INIT_AUTOMAKE + +# The same as in boehm-gc and libstdc++. Have to borrow it from there. +# We must force CC to /not/ be precious variables; otherwise +# the wrong, non-multilib-adjusted value will be used in multilibs. +# As a side effect, we have to subst CFLAGS ourselves. +# Also save and restore CFLAGS, since AC_PROG_CC will come up with +# defaults of its own if none are provided. + +m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) +m4_define([_AC_ARG_VAR_PRECIOUS],[]) +save_CFLAGS=$CFLAGS +AC_PROG_CC +AC_PROG_CXX +CFLAGS=$save_CFLAGS +m4_undefine([_AC_ARG_VAR_PRECIOUS]) +m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) + +AC_SUBST(CFLAGS) + +AM_PROG_AS +AM_PROG_CC_C_O +AC_PROG_LIBTOOL +AC_CONFIG_MACRO_DIR([m4]) + +# Test for 64-bit build. +AC_CHECK_SIZEOF([size_t]) + +AX_COMPILER_VENDOR +AX_CC_MAXOPT +# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro +# compiler. +if test "$ax_cv_c_compiler_vendor" != "sun"; then + AX_CFLAGS_WARN_ALL +fi + +if test "x$GCC" = "xyes"; then + CFLAGS="$CFLAGS -fexceptions" +fi + +cat > local.exp < conftest.s + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes + fi + ]) + if test "x$libffi_cv_as_x86_pcrel" = xyes; then + AC_DEFINE(HAVE_AS_X86_PCREL, 1, + [Define if your assembler supports PC relative relocs.]) + fi + ;; + + S390) + AC_CACHE_CHECK([compiler uses zarch features], + libffi_cv_as_s390_zarch, [ + libffi_cv_as_s390_zarch=no + echo 'void foo(void) { bar(); bar(); }' > conftest.c + if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then + if grep -q brasl conftest.s; then + libffi_cv_as_s390_zarch=yes + fi + fi + ]) + if test "x$libffi_cv_as_s390_zarch" = xyes; then + AC_DEFINE(HAVE_AS_S390_ZARCH, 1, + [Define if the compiler uses zarch features.]) + fi + ;; +esac + +# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. +AC_ARG_ENABLE(pax_emutramp, + [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC], + if test "$enable_pax_emutramp" = "yes"; then + AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1, + [Define this if you want to enable pax emulated trampolines]) + fi) + +LT_SYS_SYMBOL_USCORE +if test "x$sys_symbol_underscore" = xyes; then + AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.]) +fi + +FFI_EXEC_TRAMPOLINE_TABLE=0 +case "$target" in + *arm*-apple-darwin* | aarch64-apple-darwin*) + FFI_EXEC_TRAMPOLINE_TABLE=1 + AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1, + [Cannot use PROT_EXEC on this target, so, we revert to + alternative means]) + ;; + *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*) + AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, + [Cannot use malloc on this target, so, we revert to + alternative means]) + ;; +esac +AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1) +AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE) + +if test x$TARGET = xX86_64; then + AC_CACHE_CHECK([toolchain supports unwind section type], + libffi_cv_as_x86_64_unwind_section_type, [ + cat > conftest1.s << EOF +.text +.globl foo +foo: +jmp bar +.section .eh_frame,"a",@unwind +bar: +EOF + + cat > conftest2.c << EOF +extern void foo(); +int main(){foo();} +EOF + + libffi_cv_as_x86_64_unwind_section_type=no + # we ensure that we can compile _and_ link an assembly file containing an @unwind section + # since the compiler can support it and not the linker (ie old binutils) + if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \ + $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then + libffi_cv_as_x86_64_unwind_section_type=yes + fi + ]) + if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then + AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1, + [Define if your assembler supports unwind section type.]) + fi +fi + +if test "x$GCC" = "xyes"; then + AC_CACHE_CHECK([whether .eh_frame section should be read-only], + libffi_cv_ro_eh_frame, [ + libffi_cv_ro_eh_frame=no + echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c + if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then + objdump -h conftest.o > conftest.dump 2>&1 + libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` + if test "x$libffi_eh_frame_line" != "x"; then + libffi_test_line=`expr $libffi_eh_frame_line + 1`p + sed -n $libffi_test_line conftest.dump > conftest.line + if grep READONLY conftest.line > /dev/null; then + libffi_cv_ro_eh_frame=yes + fi + fi + fi + rm -f conftest.* + ]) + if test "x$libffi_cv_ro_eh_frame" = xyes; then + AC_DEFINE(HAVE_RO_EH_FRAME, 1, + [Define if .eh_frame sections should be read-only.]) + AC_DEFINE(EH_FRAME_FLAGS, "a", + [Define to the flags needed for the .section .eh_frame directive. ]) + else + AC_DEFINE(EH_FRAME_FLAGS, "aw", + [Define to the flags needed for the .section .eh_frame directive. ]) + fi + + AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], + libffi_cv_hidden_visibility_attribute, [ + echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c + libffi_cv_hidden_visibility_attribute=no + if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then + if grep '\.hidden.*foo' conftest.s >/dev/null; then + libffi_cv_hidden_visibility_attribute=yes + fi + fi + rm -f conftest.* + ]) + if test $libffi_cv_hidden_visibility_attribute = yes; then + AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1, + [Define if __attribute__((visibility("hidden"))) is supported.]) + fi +fi + +AH_BOTTOM([ +#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE +#ifdef LIBFFI_ASM +#define FFI_HIDDEN(name) .hidden name +#else +#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) +#endif +#else +#ifdef LIBFFI_ASM +#define FFI_HIDDEN(name) +#else +#define FFI_HIDDEN +#endif +#endif +]) + +AC_SUBST(TARGET) +AC_SUBST(TARGETDIR) + +changequote(<,>) +TARGET_OBJ= +for i in $SOURCES; do + TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'` +done +changequote([,]) +AC_SUBST(TARGET_OBJ) + +AC_SUBST(SHELL) + +AC_ARG_ENABLE(debug, +[ --enable-debug debugging mode], + if test "$enable_debug" = "yes"; then + AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.]) + fi) +AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") + +AC_ARG_ENABLE(structs, +[ --disable-structs omit code for struct support], + if test "$enable_structs" = "no"; then + AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.]) + fi) +AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") + +AC_ARG_ENABLE(raw-api, +[ --disable-raw-api make the raw api unavailable], + if test "$enable_raw_api" = "no"; then + AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.]) + fi) + +AC_ARG_ENABLE(purify-safety, +[ --enable-purify-safety purify-safe mode], + if test "$enable_purify_safety" = "yes"; then + AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) + fi) + +# These variables are only ever used when we cross-build to X86_WIN32. +# And we only support this with GCC, so... +if test "x$GCC" = "xyes"; then + if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + toolexecdir="${exec_prefix}"/'$(target_alias)' + toolexeclibdir="${toolexecdir}"/lib + else + toolexecdir="${libdir}"/gcc-lib/'$(target_alias)' + toolexeclibdir="${libdir}" + fi + multi_os_directory=`$CC $CFLAGS -print-multi-os-directory` + case $multi_os_directory in + .) ;; # Avoid trailing /. + ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; + esac + AC_SUBST(toolexecdir) +else + toolexeclibdir="${libdir}" +fi +AC_SUBST(toolexeclibdir) + +AC_CONFIG_COMMANDS(include, [test -d include || mkdir include]) +AC_CONFIG_COMMANDS(src, [ +test -d src || mkdir src +test -d src/$TARGETDIR || mkdir src/$TARGETDIR +], [TARGETDIR="$TARGETDIR"]) + +AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) + +AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) + +AC_OUTPUT diff --git a/user/mpy/lib/libffi/configure.host b/user/mpy/lib/libffi/configure.host new file mode 100644 index 0000000..c6f6a02 --- /dev/null +++ b/user/mpy/lib/libffi/configure.host @@ -0,0 +1,259 @@ +# configure.host +# +# This shell script handles all host based configuration for libffi. +# + +# THIS TABLE IS SORTED. KEEP IT THAT WAY. +# Most of the time we can define all the variables all at once... +case "${host}" in + aarch64*-*-*) + TARGET=AARCH64; TARGETDIR=aarch64 + SOURCES="ffi.c sysv.S" + ;; + + alpha*-*-*) + TARGET=ALPHA; TARGETDIR=alpha; + # Support 128-bit long double, changeable via command-line switch. + HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' + SOURCES="ffi.c osf.S" + ;; + + arc*-*-*) + TARGET=ARC; TARGETDIR=arc + SOURCES="ffi.c arcompact.S" + ;; + + arm*-*-*) + TARGET=ARM; TARGETDIR=arm + SOURCES="ffi.c sysv.S" + ;; + + avr32*-*-*) + TARGET=AVR32; TARGETDIR=avr32 + SOURCES="ffi.c sysv.S" + ;; + + bfin*) + TARGET=BFIN; TARGETDIR=bfin + SOURCES="ffi.c sysv.S" + ;; + + cris-*-*) + TARGET=LIBFFI_CRIS; TARGETDIR=cris + SOURCES="ffi.c sysv.S" + ;; + + frv-*-*) + TARGET=FRV; TARGETDIR=frv + SOURCES="ffi.c eabi.S" + ;; + + hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*) + TARGET=PA_LINUX; TARGETDIR=pa + SOURCES="ffi.c linux.S" + ;; + hppa*64-*-hpux*) + TARGET=PA64_HPUX; TARGETDIR=pa + ;; + hppa*-*-hpux*) + TARGET=PA_HPUX; TARGETDIR=pa + SOURCES="ffi.c hpux32.S" + ;; + + i?86-*-freebsd* | i?86-*-openbsd*) + TARGET=X86_FREEBSD; TARGETDIR=x86 + ;; + + i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix* \ + | x86_64-*-cygwin* | x86_64-*-mingw*) + TARGETDIR=x86 + if test $ac_cv_sizeof_size_t = 4; then + TARGET=X86_WIN32 + else + TARGET=X86_WIN64 + fi + # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. + # We must also check with_cross_host to decide if this is a native + # or cross-build and select where to install dlls appropriately. + if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; + else + AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; + fi + ;; + + i?86-*-darwin* | x86_64-*-darwin*) + TARGETDIR=x86 + if test $ac_cv_sizeof_size_t = 4; then + TARGET=X86_DARWIN + else + TARGET=X86_64 + fi + ;; + + i?86-*-* | x86_64-*-* | amd64-*) + TARGETDIR=x86 + if test $ac_cv_sizeof_size_t = 4; then + case "$host" in + *-gnux32) + TARGET=X86_64 + ;; + *) + TARGET=X86 + ;; + esac + else + TARGET=X86_64; + fi + ;; + + ia64*-*-*) + TARGET=IA64; TARGETDIR=ia64 + SOURCES="ffi.c unix.S" + ;; + + m32r*-*-*) + TARGET=M32R; TARGETDIR=m32r + SOURCES="ffi.c sysv.S" + ;; + + m68k-*-*) + TARGET=M68K; TARGETDIR=m68k + SOURCES="ffi.c sysv.S" + ;; + + m88k-*-*) + TARGET=M88K; TARGETDIR=m88k + SOURCES="ffi.c obsd.S" + ;; + + microblaze*-*-*) + TARGET=MICROBLAZE; TARGETDIR=microblaze + SOURCES="ffi.c sysv.S" + ;; + + moxie-*-*) + TARGET=MOXIE; TARGETDIR=moxie + SOURCES="ffi.c eabi.S" + ;; + + metag-*-*) + TARGET=METAG; TARGETDIR=metag + SOURCES="ffi.c sysv.S" + ;; + + mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) + TARGET=MIPS; TARGETDIR=mips + ;; + mips*-*linux* | mips*-*-openbsd*) + # Support 128-bit long double for NewABI. + HAVE_LONG_DOUBLE='defined(__mips64)' + TARGET=MIPS; TARGETDIR=mips + ;; + + nios2*-linux*) + TARGET=NIOS2; TARGETDIR=nios2 + SOURCES="ffi.c sysv.S" + ;; + + or1k*-linux*) + TARGET=OR1K; TARGETDIR=or1k + SOURCES="ffi.c sysv.S" + ;; + + powerpc*-*-linux* | powerpc-*-sysv*) + TARGET=POWERPC; TARGETDIR=powerpc + HAVE_LONG_DOUBLE_VARIANT=1 + ;; + powerpc-*-amigaos*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + powerpc-*-beos*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + powerpc-*-darwin* | powerpc64-*-darwin*) + TARGET=POWERPC_DARWIN; TARGETDIR=powerpc + ;; + powerpc-*-aix* | rs6000-*-aix*) + TARGET=POWERPC_AIX; TARGETDIR=powerpc + ;; + powerpc-*-freebsd* | powerpc-*-openbsd* | powerpc-*-netbsd*) + TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc + HAVE_LONG_DOUBLE_VARIANT=1 + ;; + powerpc64-*-freebsd*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + powerpc*-*-rtems*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + + s390-*-* | s390x-*-*) + TARGET=S390; TARGETDIR=s390 + SOURCES="ffi.c sysv.S" + ;; + + sh-*-* | sh[34]*-*-*) + TARGET=SH; TARGETDIR=sh + SOURCES="ffi.c sysv.S" + ;; + sh64-*-* | sh5*-*-*) + TARGET=SH64; TARGETDIR=sh64 + SOURCES="ffi.c sysv.S" + ;; + + sparc*-*-*) + TARGET=SPARC; TARGETDIR=sparc + SOURCES="ffi.c ffi64.c v8.S v9.S" + ;; + + tile*-*) + TARGET=TILE; TARGETDIR=tile + SOURCES="ffi.c tile.S" + ;; + + vax-*-*) + TARGET=VAX; TARGETDIR=vax + SOURCES="ffi.c elfbsd.S" + ;; + + xtensa*-*) + TARGET=XTENSA; TARGETDIR=xtensa + SOURCES="ffi.c sysv.S" + ;; +esac + +# ... but some of the cases above share configury. +case "${TARGET}" in + MIPS) + SOURCES="ffi.c o32.S n32.S" + ;; + POWERPC) + SOURCES="ffi.c ffi_sysv.c ffi_linux64.c sysv.S ppc_closure.S" + SOURCES="${SOURCES} linux64.S linux64_closure.S" + ;; + POWERPC_AIX) + SOURCES="ffi_darwin.c aix.S aix_closure.S" + ;; + POWERPC_DARWIN) + SOURCES="ffi_darwin.c darwin.S darwin_closure.S" + ;; + POWERPC_FREEBSD) + SOURCES="ffi.c ffi_sysv.c sysv.S ppc_closure.S" + ;; + X86 | X86_DARWIN | X86_FREEBSD | X86_WIN32) + SOURCES="ffi.c sysv.S" + ;; + X86_64) + SOURCES="ffi64.c unix64.S" + ;; + X86_WIN64) + SOURCES="ffiw64.c win64.S" + ;; +esac + +# If we failed to configure SOURCES, we can't do anything. +if test -z "${SOURCES}"; then + UNSUPPORTED=1 +fi diff --git a/user/mpy/lib/libffi/doc/libffi.texi b/user/mpy/lib/libffi/doc/libffi.texi new file mode 100644 index 0000000..ff72e58 --- /dev/null +++ b/user/mpy/lib/libffi/doc/libffi.texi @@ -0,0 +1,765 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename libffi.info +@settitle libffi +@setchapternewpage off +@c %**end of header + +@c Merge the standard indexes into a single one. +@syncodeindex fn cp +@syncodeindex vr cp +@syncodeindex ky cp +@syncodeindex pg cp +@syncodeindex tp cp + +@include version.texi + +@copying + +This manual is for Libffi, a portable foreign-function interface +library. + +Copyright @copyright{} 2008, 2010, 2011 Red Hat, Inc. + +@quotation +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. A copy of the license is included in the +section entitled ``GNU General Public License''. + +@end quotation +@end copying + +@dircategory Development +@direntry +* libffi: (libffi). Portable foreign-function interface library. +@end direntry + +@titlepage +@title Libffi +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + + +@ifnottex +@node Top +@top libffi + +@insertcopying + +@menu +* Introduction:: What is libffi? +* Using libffi:: How to use libffi. +* Missing Features:: Things libffi can't do. +* Index:: Index. +@end menu + +@end ifnottex + + +@node Introduction +@chapter What is libffi? + +Compilers for high level languages generate code that follow certain +conventions. These conventions are necessary, in part, for separate +compilation to work. One such convention is the @dfn{calling +convention}. The calling convention is a set of assumptions made by +the compiler about where function arguments will be found on entry to +a function. A calling convention also specifies where the return +value for a function is found. The calling convention is also +sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}. +@cindex calling convention +@cindex ABI +@cindex Application Binary Interface + +Some programs may not know at the time of compilation what arguments +are to be passed to a function. For instance, an interpreter may be +told at run-time about the number and types of arguments used to call +a given function. @samp{Libffi} can be used in such programs to +provide a bridge from the interpreter program to compiled code. + +The @samp{libffi} library provides a portable, high level programming +interface to various calling conventions. This allows a programmer to +call any function specified by a call interface description at run +time. + +@acronym{FFI} stands for Foreign Function Interface. A foreign +function interface is the popular name for the interface that allows +code written in one language to call code written in another language. +The @samp{libffi} library really only provides the lowest, machine +dependent layer of a fully featured foreign function interface. A +layer must exist above @samp{libffi} that handles type conversions for +values passed between the two languages. +@cindex FFI +@cindex Foreign Function Interface + + +@node Using libffi +@chapter Using libffi + +@menu +* The Basics:: The basic libffi API. +* Simple Example:: A simple example. +* Types:: libffi type descriptions. +* Multiple ABIs:: Different passing styles on one platform. +* The Closure API:: Writing a generic function. +* Closure Example:: A closure example. +@end menu + + +@node The Basics +@section The Basics + +@samp{Libffi} assumes that you have a pointer to the function you wish +to call and that you know the number and types of arguments to pass +it, as well as the return type of the function. + +The first thing you must do is create an @code{ffi_cif} object that +matches the signature of the function you wish to call. This is a +separate step because it is common to make multiple calls using a +single @code{ffi_cif}. The @dfn{cif} in @code{ffi_cif} stands for +Call InterFace. To prepare a call interface object, use the function +@code{ffi_prep_cif}. +@cindex cif + +@findex ffi_prep_cif +@defun ffi_status ffi_prep_cif (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes}) +This initializes @var{cif} according to the given parameters. + +@var{abi} is the ABI to use; normally @code{FFI_DEFAULT_ABI} is what +you want. @ref{Multiple ABIs} for more information. + +@var{nargs} is the number of arguments that this function accepts. + +@var{rtype} is a pointer to an @code{ffi_type} structure that +describes the return type of the function. @xref{Types}. + +@var{argtypes} is a vector of @code{ffi_type} pointers. +@var{argtypes} must have @var{nargs} elements. If @var{nargs} is 0, +this argument is ignored. + +@code{ffi_prep_cif} returns a @code{libffi} status code, of type +@code{ffi_status}. This will be either @code{FFI_OK} if everything +worked properly; @code{FFI_BAD_TYPEDEF} if one of the @code{ffi_type} +objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter +is invalid. +@end defun + +If the function being called is variadic (varargs) then +@code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}. + +@findex ffi_prep_cif_var +@defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nfixedargs}, unsigned int @var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes}) +This initializes @var{cif} according to the given parameters for +a call to a variadic function. In general it's operation is the +same as for @code{ffi_prep_cif} except that: + +@var{nfixedargs} is the number of fixed arguments, prior to any +variadic arguments. It must be greater than zero. + +@var{ntotalargs} the total number of arguments, including variadic +and fixed arguments. @var{argtypes} must have this many elements. + +Note that, different cif's must be prepped for calls to the same +function when different numbers of arguments are passed. + +Also note that a call to @code{ffi_prep_cif_var} with +@var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to +@code{ffi_prep_cif}. + +@end defun + + +To call a function using an initialized @code{ffi_cif}, use the +@code{ffi_call} function: + +@findex ffi_call +@defun void ffi_call (ffi_cif *@var{cif}, void *@var{fn}, void *@var{rvalue}, void **@var{avalues}) +This calls the function @var{fn} according to the description given in +@var{cif}. @var{cif} must have already been prepared using +@code{ffi_prep_cif}. + +@var{rvalue} is a pointer to a chunk of memory that will hold the +result of the function call. This must be large enough to hold the +result, no smaller than the system register size (generally 32 or 64 +bits), and must be suitably aligned; it is the caller's responsibility +to ensure this. If @var{cif} declares that the function returns +@code{void} (using @code{ffi_type_void}), then @var{rvalue} is +ignored. + +@var{avalues} is a vector of @code{void *} pointers that point to the +memory locations holding the argument values for a call. If @var{cif} +declares that the function has no arguments (i.e., @var{nargs} was 0), +then @var{avalues} is ignored. Note that argument values may be +modified by the callee (for instance, structs passed by value); the +burden of copying pass-by-value arguments is placed on the caller. +@end defun + + +@node Simple Example +@section Simple Example + +Here is a trivial example that calls @code{puts} a few times. + +@example +#include +#include + +int main() +@{ + ffi_cif cif; + ffi_type *args[1]; + void *values[1]; + char *s; + ffi_arg rc; + + /* Initialize the argument info vectors */ + args[0] = &ffi_type_pointer; + values[0] = &s; + + /* Initialize the cif */ + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_sint, args) == FFI_OK) + @{ + s = "Hello World!"; + ffi_call(&cif, puts, &rc, values); + /* rc now holds the result of the call to puts */ + + /* values holds a pointer to the function's arg, so to + call puts() again all we need to do is change the + value of s */ + s = "This is cool!"; + ffi_call(&cif, puts, &rc, values); + @} + + return 0; +@} +@end example + + +@node Types +@section Types + +@menu +* Primitive Types:: Built-in types. +* Structures:: Structure types. +* Type Example:: Structure type example. +* Complex:: Complex types. +* Complex Type Example:: Complex type example. +@end menu + +@node Primitive Types +@subsection Primitive Types + +@code{Libffi} provides a number of built-in type descriptors that can +be used to describe argument and return types: + +@table @code +@item ffi_type_void +@tindex ffi_type_void +The type @code{void}. This cannot be used for argument types, only +for return values. + +@item ffi_type_uint8 +@tindex ffi_type_uint8 +An unsigned, 8-bit integer type. + +@item ffi_type_sint8 +@tindex ffi_type_sint8 +A signed, 8-bit integer type. + +@item ffi_type_uint16 +@tindex ffi_type_uint16 +An unsigned, 16-bit integer type. + +@item ffi_type_sint16 +@tindex ffi_type_sint16 +A signed, 16-bit integer type. + +@item ffi_type_uint32 +@tindex ffi_type_uint32 +An unsigned, 32-bit integer type. + +@item ffi_type_sint32 +@tindex ffi_type_sint32 +A signed, 32-bit integer type. + +@item ffi_type_uint64 +@tindex ffi_type_uint64 +An unsigned, 64-bit integer type. + +@item ffi_type_sint64 +@tindex ffi_type_sint64 +A signed, 64-bit integer type. + +@item ffi_type_float +@tindex ffi_type_float +The C @code{float} type. + +@item ffi_type_double +@tindex ffi_type_double +The C @code{double} type. + +@item ffi_type_uchar +@tindex ffi_type_uchar +The C @code{unsigned char} type. + +@item ffi_type_schar +@tindex ffi_type_schar +The C @code{signed char} type. (Note that there is not an exact +equivalent to the C @code{char} type in @code{libffi}; ordinarily you +should either use @code{ffi_type_schar} or @code{ffi_type_uchar} +depending on whether @code{char} is signed.) + +@item ffi_type_ushort +@tindex ffi_type_ushort +The C @code{unsigned short} type. + +@item ffi_type_sshort +@tindex ffi_type_sshort +The C @code{short} type. + +@item ffi_type_uint +@tindex ffi_type_uint +The C @code{unsigned int} type. + +@item ffi_type_sint +@tindex ffi_type_sint +The C @code{int} type. + +@item ffi_type_ulong +@tindex ffi_type_ulong +The C @code{unsigned long} type. + +@item ffi_type_slong +@tindex ffi_type_slong +The C @code{long} type. + +@item ffi_type_longdouble +@tindex ffi_type_longdouble +On platforms that have a C @code{long double} type, this is defined. +On other platforms, it is not. + +@item ffi_type_pointer +@tindex ffi_type_pointer +A generic @code{void *} pointer. You should use this for all +pointers, regardless of their real type. + +@item ffi_type_complex_float +@tindex ffi_type_complex_float +The C @code{_Complex float} type. + +@item ffi_type_complex_double +@tindex ffi_type_complex_double +The C @code{_Complex double} type. + +@item ffi_type_complex_longdouble +@tindex ffi_type_complex_longdouble +The C @code{_Complex long double} type. +On platforms that have a C @code{long double} type, this is defined. +On other platforms, it is not. +@end table + +Each of these is of type @code{ffi_type}, so you must take the address +when passing to @code{ffi_prep_cif}. + + +@node Structures +@subsection Structures + +Although @samp{libffi} has no special support for unions or +bit-fields, it is perfectly happy passing structures back and forth. +You must first describe the structure to @samp{libffi} by creating a +new @code{ffi_type} object for it. + +@tindex ffi_type +@deftp {Data type} ffi_type +The @code{ffi_type} has the following members: +@table @code +@item size_t size +This is set by @code{libffi}; you should initialize it to zero. + +@item unsigned short alignment +This is set by @code{libffi}; you should initialize it to zero. + +@item unsigned short type +For a structure, this should be set to @code{FFI_TYPE_STRUCT}. + +@item ffi_type **elements +This is a @samp{NULL}-terminated array of pointers to @code{ffi_type} +objects. There is one element per field of the struct. +@end table +@end deftp + + +@node Type Example +@subsection Type Example + +The following example initializes a @code{ffi_type} object +representing the @code{tm} struct from Linux's @file{time.h}. + +Here is how the struct is defined: + +@example +struct tm @{ + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + /* Those are for future use. */ + long int __tm_gmtoff__; + __const char *__tm_zone__; +@}; +@end example + +Here is the corresponding code to describe this struct to +@code{libffi}: + +@example + @{ + ffi_type tm_type; + ffi_type *tm_type_elements[12]; + int i; + + tm_type.size = tm_type.alignment = 0; + tm_type.type = FFI_TYPE_STRUCT; + tm_type.elements = &tm_type_elements; + + for (i = 0; i < 9; i++) + tm_type_elements[i] = &ffi_type_sint; + + tm_type_elements[9] = &ffi_type_slong; + tm_type_elements[10] = &ffi_type_pointer; + tm_type_elements[11] = NULL; + + /* tm_type can now be used to represent tm argument types and + return types for ffi_prep_cif() */ + @} +@end example + +@node Complex +@subsection Complex Types + +@samp{libffi} supports the complex types defined by the C99 +standard (@code{_Complex float}, @code{_Complex double} and +@code{_Complex long double} with the built-in type descriptors +@code{ffi_type_complex_float}, @code{ffi_type_complex_double} and +@code{ffi_type_complex_longdouble}. + +Custom complex types like @code{_Complex int} can also be used. +An @code{ffi_type} object has to be defined to describe the +complex type to @samp{libffi}. + +@tindex ffi_type +@deftp {Data type} ffi_type +@table @code +@item size_t size +This must be manually set to the size of the complex type. + +@item unsigned short alignment +This must be manually set to the alignment of the complex type. + +@item unsigned short type +For a complex type, this must be set to @code{FFI_TYPE_COMPLEX}. + +@item ffi_type **elements + +This is a @samp{NULL}-terminated array of pointers to +@code{ffi_type} objects. The first element is set to the +@code{ffi_type} of the complex's base type. The second element +must be set to @code{NULL}. +@end table +@end deftp + +The section @ref{Complex Type Example} shows a way to determine +the @code{size} and @code{alignment} members in a platform +independent way. + +For platforms that have no complex support in @code{libffi} yet, +the functions @code{ffi_prep_cif} and @code{ffi_prep_args} abort +the program if they encounter a complex type. + +@node Complex Type Example +@subsection Complex Type Example + +This example demonstrates how to use complex types: + +@example +#include +#include +#include + +void complex_fn(_Complex float cf, + _Complex double cd, + _Complex long double cld) +@{ + printf("cf=%f+%fi\ncd=%f+%fi\ncld=%f+%fi\n", + (float)creal (cf), (float)cimag (cf), + (float)creal (cd), (float)cimag (cd), + (float)creal (cld), (float)cimag (cld)); +@} + +int main() +@{ + ffi_cif cif; + ffi_type *args[3]; + void *values[3]; + _Complex float cf; + _Complex double cd; + _Complex long double cld; + + /* Initialize the argument info vectors */ + args[0] = &ffi_type_complex_float; + args[1] = &ffi_type_complex_double; + args[2] = &ffi_type_complex_longdouble; + values[0] = &cf; + values[1] = &cd; + values[2] = &cld; + + /* Initialize the cif */ + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &ffi_type_void, args) == FFI_OK) + @{ + cf = 1.0 + 20.0 * I; + cd = 300.0 + 4000.0 * I; + cld = 50000.0 + 600000.0 * I; + /* Call the function */ + ffi_call(&cif, (void (*)(void))complex_fn, 0, values); + @} + + return 0; +@} +@end example + +This is an example for defining a custom complex type descriptor +for compilers that support them: + +@example +/* + * This macro can be used to define new complex type descriptors + * in a platform independent way. + * + * name: Name of the new descriptor is ffi_type_complex_. + * type: The C base type of the complex type. + */ +#define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \ + static ffi_type *ffi_elements_complex_##name [2] = @{ \ + (ffi_type *)(&ffitype), NULL \ + @}; \ + struct struct_align_complex_##name @{ \ + char c; \ + _Complex type x; \ + @}; \ + ffi_type ffi_type_complex_##name = @{ \ + sizeof(_Complex type), \ + offsetof(struct struct_align_complex_##name, x), \ + FFI_TYPE_COMPLEX, \ + (ffi_type **)ffi_elements_complex_##name \ + @} + +/* Define new complex type descriptors using the macro: */ +/* ffi_type_complex_sint */ +FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint); +/* ffi_type_complex_uchar */ +FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8); +@end example + +The new type descriptors can then be used like one of the built-in +type descriptors in the previous example. + +@node Multiple ABIs +@section Multiple ABIs + +A given platform may provide multiple different ABIs at once. For +instance, the x86 platform has both @samp{stdcall} and @samp{fastcall} +functions. + +@code{libffi} provides some support for this. However, this is +necessarily platform-specific. + +@c FIXME: document the platforms + +@node The Closure API +@section The Closure API + +@code{libffi} also provides a way to write a generic function -- a +function that can accept and decode any combination of arguments. +This can be useful when writing an interpreter, or to provide wrappers +for arbitrary functions. + +This facility is called the @dfn{closure API}. Closures are not +supported on all platforms; you can check the @code{FFI_CLOSURES} +define to determine whether they are supported on the current +platform. +@cindex closures +@cindex closure API +@findex FFI_CLOSURES + +Because closures work by assembling a tiny function at runtime, they +require special allocation on platforms that have a non-executable +heap. Memory management for closures is handled by a pair of +functions: + +@findex ffi_closure_alloc +@defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code}) +Allocate a chunk of memory holding @var{size} bytes. This returns a +pointer to the writable address, and sets *@var{code} to the +corresponding executable address. + +@var{size} should be sufficient to hold a @code{ffi_closure} object. +@end defun + +@findex ffi_closure_free +@defun void ffi_closure_free (void *@var{writable}) +Free memory allocated using @code{ffi_closure_alloc}. The argument is +the writable address that was returned. +@end defun + + +Once you have allocated the memory for a closure, you must construct a +@code{ffi_cif} describing the function call. Finally you can prepare +the closure function: + +@findex ffi_prep_closure_loc +@defun ffi_status ffi_prep_closure_loc (ffi_closure *@var{closure}, ffi_cif *@var{cif}, void (*@var{fun}) (ffi_cif *@var{cif}, void *@var{ret}, void **@var{args}, void *@var{user_data}), void *@var{user_data}, void *@var{codeloc}) +Prepare a closure function. + +@var{closure} is the address of a @code{ffi_closure} object; this is +the writable address returned by @code{ffi_closure_alloc}. + +@var{cif} is the @code{ffi_cif} describing the function parameters. + +@var{user_data} is an arbitrary datum that is passed, uninterpreted, +to your closure function. + +@var{codeloc} is the executable address returned by +@code{ffi_closure_alloc}. + +@var{fun} is the function which will be called when the closure is +invoked. It is called with the arguments: +@table @var +@item cif +The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}. + +@item ret +A pointer to the memory used for the function's return value. +@var{fun} must fill this, unless the function is declared as returning +@code{void}. +@c FIXME: is this NULL for void-returning functions? + +@item args +A vector of pointers to memory holding the arguments to the function. + +@item user_data +The same @var{user_data} that was passed to +@code{ffi_prep_closure_loc}. +@end table + +@code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything +went ok, and something else on error. +@c FIXME: what? + +After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc} +to the appropriate pointer-to-function type. +@end defun + +You may see old code referring to @code{ffi_prep_closure}. This +function is deprecated, as it cannot handle the need for separate +writable and executable addresses. + +@node Closure Example +@section Closure Example + +A trivial example that creates a new @code{puts} by binding +@code{fputs} with @code{stdout}. + +@example +#include +#include + +/* Acts like puts with the file given at time of enclosure. */ +void puts_binding(ffi_cif *cif, void *ret, void* args[], + void *stream) +@{ + *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream); +@} + +typedef int (*puts_t)(char *); + +int main() +@{ + ffi_cif cif; + ffi_type *args[1]; + ffi_closure *closure; + + void *bound_puts; + int rc; + + /* Allocate closure and bound_puts */ + closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts); + + if (closure) + @{ + /* Initialize the argument info vectors */ + args[0] = &ffi_type_pointer; + + /* Initialize the cif */ + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_sint, args) == FFI_OK) + @{ + /* Initialize the closure, setting stream to stdout */ + if (ffi_prep_closure_loc(closure, &cif, puts_binding, + stdout, bound_puts) == FFI_OK) + @{ + rc = ((puts_t)bound_puts)("Hello World!"); + /* rc now holds the result of the call to fputs */ + @} + @} + @} + + /* Deallocate both closure, and bound_puts */ + ffi_closure_free(closure); + + return 0; +@} + +@end example + + +@node Missing Features +@chapter Missing Features + +@code{libffi} is missing a few features. We welcome patches to add +support for these. + +@itemize @bullet +@item +Variadic closures. + +@item +There is no support for bit fields in structures. + +@item +The ``raw'' API is undocumented. +@c argument promotion? +@c unions? +@c anything else? +@end itemize + +Note that variadic support is very new and tested on a relatively +small number of platforms. + +@node Index +@unnumbered Index + +@printindex cp + +@bye diff --git a/user/mpy/lib/libffi/doc/version.texi b/user/mpy/lib/libffi/doc/version.texi new file mode 100644 index 0000000..ccef70f --- /dev/null +++ b/user/mpy/lib/libffi/doc/version.texi @@ -0,0 +1,4 @@ +@set UPDATED 8 November 2014 +@set UPDATED-MONTH November 2014 +@set EDITION 3.2.1 +@set VERSION 3.2.1 diff --git a/user/mpy/lib/libffi/generate-darwin-source-and-headers.py b/user/mpy/lib/libffi/generate-darwin-source-and-headers.py new file mode 100644 index 0000000..f551c35 --- /dev/null +++ b/user/mpy/lib/libffi/generate-darwin-source-and-headers.py @@ -0,0 +1,209 @@ +#!/usr/bin/env python +import subprocess +import os +import errno +import collections +import glob +import argparse + +class Platform(object): + pass + +class simulator_platform(Platform): + directory = 'darwin_ios' + sdk = 'iphonesimulator' + arch = 'i386' + triple = 'i386-apple-darwin11' + version_min = '-miphoneos-version-min=7.0' + + prefix = "#ifdef __i386__\n\n" + suffix = "\n\n#endif" + src_dir = 'x86' + src_files = ['sysv.S', 'ffi.c'] + + +class simulator64_platform(Platform): + directory = 'darwin_ios' + sdk = 'iphonesimulator' + arch = 'x86_64' + triple = 'x86_64-apple-darwin13' + version_min = '-miphoneos-version-min=7.0' + + prefix = "#ifdef __x86_64__\n\n" + suffix = "\n\n#endif" + src_dir = 'x86' + src_files = ['unix64.S', 'ffi64.c'] + + +class device_platform(Platform): + directory = 'darwin_ios' + sdk = 'iphoneos' + arch = 'armv7' + triple = 'arm-apple-darwin11' + version_min = '-miphoneos-version-min=7.0' + + prefix = "#ifdef __arm__\n\n" + suffix = "\n\n#endif" + src_dir = 'arm' + src_files = ['sysv.S', 'trampoline.S', 'ffi.c'] + + +class device64_platform(Platform): + directory = 'darwin_ios' + sdk = 'iphoneos' + arch = 'arm64' + triple = 'aarch64-apple-darwin13' + version_min = '-miphoneos-version-min=7.0' + + prefix = "#ifdef __arm64__\n\n" + suffix = "\n\n#endif" + src_dir = 'aarch64' + src_files = ['sysv.S', 'ffi.c'] + + +class desktop32_platform(Platform): + directory = 'darwin_osx' + sdk = 'macosx' + arch = 'i386' + triple = 'i386-apple-darwin10' + version_min = '-mmacosx-version-min=10.6' + src_dir = 'x86' + src_files = ['sysv.S', 'ffi.c'] + + prefix = "#ifdef __i386__\n\n" + suffix = "\n\n#endif" + + +class desktop64_platform(Platform): + directory = 'darwin_osx' + sdk = 'macosx' + arch = 'x86_64' + triple = 'x86_64-apple-darwin10' + version_min = '-mmacosx-version-min=10.6' + + prefix = "#ifdef __x86_64__\n\n" + suffix = "\n\n#endif" + src_dir = 'x86' + src_files = ['unix64.S', 'ffi64.c'] + + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST: + pass + else: + raise + + +def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''): + mkdir_p(dst_dir) + out_filename = filename + + if file_suffix: + split_name = os.path.splitext(filename) + out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1]) + + with open(os.path.join(src_dir, filename)) as in_file: + with open(os.path.join(dst_dir, out_filename), 'w') as out_file: + if prefix: + out_file.write(prefix) + + out_file.write(in_file.read()) + + if suffix: + out_file.write(suffix) + + +def list_files(src_dir, pattern=None, filelist=None): + if pattern: filelist = glob.iglob(os.path.join(src_dir, pattern)) + for file in filelist: + yield os.path.basename(file) + + +def copy_files(src_dir, dst_dir, pattern=None, filelist=None, file_suffix=None, prefix=None, suffix=None): + for filename in list_files(src_dir, pattern=pattern, filelist=filelist): + move_file(src_dir, dst_dir, filename, file_suffix=file_suffix, prefix=prefix, suffix=suffix) + + +def copy_src_platform_files(platform): + src_dir = os.path.join('src', platform.src_dir) + dst_dir = os.path.join(platform.directory, 'src', platform.src_dir) + copy_files(src_dir, dst_dir, filelist=platform.src_files, file_suffix=platform.arch, prefix=platform.prefix, suffix=platform.suffix) + + +def build_target(platform, platform_headers): + def xcrun_cmd(cmd): + return 'xcrun -sdk %s %s -arch %s' % (platform.sdk, cmd, platform.arch) + + tag='%s-%s' % (platform.sdk, platform.arch) + build_dir = 'build_%s' % tag + mkdir_p(build_dir) + env = dict(CC=xcrun_cmd('clang'), + LD=xcrun_cmd('ld'), + CFLAGS='%s' % (platform.version_min)) + working_dir = os.getcwd() + try: + os.chdir(build_dir) + subprocess.check_call(['../configure', '-host', platform.triple], env=env) + finally: + os.chdir(working_dir) + + for src_dir in [build_dir, os.path.join(build_dir, 'include')]: + copy_files(src_dir, + os.path.join(platform.directory, 'include'), + pattern='*.h', + file_suffix=platform.arch, + prefix=platform.prefix, + suffix=platform.suffix) + + for filename in list_files(src_dir, pattern='*.h'): + platform_headers[filename].add((platform.prefix, platform.arch, platform.suffix)) + + +def make_tramp(): + with open('src/arm/trampoline.S', 'w') as tramp_out: + p = subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=tramp_out) + p.wait() + + +def generate_source_and_headers(generate_osx=True, generate_ios=True): + copy_files('src', 'darwin_common/src', pattern='*.c') + copy_files('include', 'darwin_common/include', pattern='*.h') + + if generate_ios: + make_tramp() + copy_src_platform_files(simulator_platform) + copy_src_platform_files(simulator64_platform) + copy_src_platform_files(device_platform) + copy_src_platform_files(device64_platform) + if generate_osx: + copy_src_platform_files(desktop32_platform) + copy_src_platform_files(desktop64_platform) + + platform_headers = collections.defaultdict(set) + + if generate_ios: + build_target(simulator_platform, platform_headers) + build_target(simulator64_platform, platform_headers) + build_target(device_platform, platform_headers) + build_target(device64_platform, platform_headers) + if generate_osx: + build_target(desktop32_platform, platform_headers) + build_target(desktop64_platform, platform_headers) + + mkdir_p('darwin_common/include') + for header_name, tag_tuples in platform_headers.iteritems(): + basename, suffix = os.path.splitext(header_name) + with open(os.path.join('darwin_common/include', header_name), 'w') as header: + for tag_tuple in tag_tuples: + header.write('%s#include <%s_%s%s>\n%s\n' % (tag_tuple[0], basename, tag_tuple[1], suffix, tag_tuple[2])) + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--only-ios', action='store_true', default=False) + parser.add_argument('--only-osx', action='store_true', default=False) + args = parser.parse_args() + + generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx) diff --git a/user/mpy/lib/libffi/include/Makefile.am b/user/mpy/lib/libffi/include/Makefile.am new file mode 100644 index 0000000..bb241e8 --- /dev/null +++ b/user/mpy/lib/libffi/include/Makefile.am @@ -0,0 +1,10 @@ +## Process this with automake to create Makefile.in + +AUTOMAKE_OPTIONS=foreign + +DISTCLEANFILES=ffitarget.h +noinst_HEADERS=ffi_common.h ffi_cfi.h +EXTRA_DIST=ffi.h.in + +includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include +nodist_includes_HEADERS = ffi.h ffitarget.h diff --git a/user/mpy/lib/libffi/include/ffi.h.in b/user/mpy/lib/libffi/include/ffi.h.in new file mode 100644 index 0000000..c43d52f --- /dev/null +++ b/user/mpy/lib/libffi/include/ffi.h.in @@ -0,0 +1,503 @@ +/* -----------------------------------------------------------------*-C-*- + libffi @VERSION@ - Copyright (c) 2011, 2014 Anthony Green + - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. + + 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. + + ----------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------- + The basic API is described in the README file. + + The raw API is designed to bypass some of the argument packing + and unpacking on architectures for which it can be avoided. + + The closure API allows interpreted functions to be packaged up + inside a C function pointer, so that they can be called as C functions, + with no understanding on the client side that they are interpreted. + It can also be used in other cases in which it is necessary to package + up a user specified parameter and a function pointer as a single + function pointer. + + The closure API must be implemented in order to get its functionality, + e.g. for use by gij. Routines are provided to emulate the raw API + if the underlying platform doesn't allow faster implementation. + + More details on the raw and cloure API can be found in: + + http://gcc.gnu.org/ml/java/1999-q3/msg00138.html + + and + + http://gcc.gnu.org/ml/java/1999-q3/msg00174.html + -------------------------------------------------------------------- */ + +#ifndef LIBFFI_H +#define LIBFFI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Specify which architecture libffi is configured for. */ +#ifndef @TARGET@ +#define @TARGET@ +#endif + +/* ---- System configuration information --------------------------------- */ + +#include + +#ifndef LIBFFI_ASM + +#if defined(_MSC_VER) && !defined(__clang__) +#define __attribute__(X) +#endif + +#include +#include + +/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). + But we can find it either under the correct ANSI name, or under GNU + C's internal name. */ + +#define FFI_64_BIT_MAX 9223372036854775807 + +#ifdef LONG_LONG_MAX +# define FFI_LONG_LONG_MAX LONG_LONG_MAX +#else +# ifdef LLONG_MAX +# define FFI_LONG_LONG_MAX LLONG_MAX +# ifdef _AIX52 /* or newer has C99 LLONG_MAX */ +# undef FFI_64_BIT_MAX +# define FFI_64_BIT_MAX 9223372036854775807LL +# endif /* _AIX52 or newer */ +# else +# ifdef __GNUC__ +# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ +# endif +# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ +# ifndef __PPC64__ +# if defined (__IBMC__) || defined (__IBMCPP__) +# define FFI_LONG_LONG_MAX LONGLONG_MAX +# endif +# endif /* __PPC64__ */ +# undef FFI_64_BIT_MAX +# define FFI_64_BIT_MAX 9223372036854775807LL +# endif +# endif +#endif + +/* The closure code assumes that this works on pointers, i.e. a size_t */ +/* can hold a pointer. */ + +typedef struct _ffi_type +{ + size_t size; + unsigned short alignment; + unsigned short type; + struct _ffi_type **elements; +} ffi_type; + +#ifndef LIBFFI_HIDE_BASIC_TYPES +#if SCHAR_MAX == 127 +# define ffi_type_uchar ffi_type_uint8 +# define ffi_type_schar ffi_type_sint8 +#else + #error "char size not supported" +#endif + +#if SHRT_MAX == 32767 +# define ffi_type_ushort ffi_type_uint16 +# define ffi_type_sshort ffi_type_sint16 +#elif SHRT_MAX == 2147483647 +# define ffi_type_ushort ffi_type_uint32 +# define ffi_type_sshort ffi_type_sint32 +#else + #error "short size not supported" +#endif + +#if INT_MAX == 32767 +# define ffi_type_uint ffi_type_uint16 +# define ffi_type_sint ffi_type_sint16 +#elif INT_MAX == 2147483647 +# define ffi_type_uint ffi_type_uint32 +# define ffi_type_sint ffi_type_sint32 +#elif INT_MAX == 9223372036854775807 +# define ffi_type_uint ffi_type_uint64 +# define ffi_type_sint ffi_type_sint64 +#else + #error "int size not supported" +#endif + +#if LONG_MAX == 2147483647 +# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX + #error "no 64-bit data type supported" +# endif +#elif LONG_MAX != FFI_64_BIT_MAX + #error "long size not supported" +#endif + +#if LONG_MAX == 2147483647 +# define ffi_type_ulong ffi_type_uint32 +# define ffi_type_slong ffi_type_sint32 +#elif LONG_MAX == FFI_64_BIT_MAX +# define ffi_type_ulong ffi_type_uint64 +# define ffi_type_slong ffi_type_sint64 +#else + #error "long size not supported" +#endif + +/* Need minimal decorations for DLLs to works on Windows. */ +/* GCC has autoimport and autoexport. Rely on Libtool to */ +/* help MSVC export from a DLL, but always declare data */ +/* to be imported for MSVC clients. This costs an extra */ +/* indirection for MSVC clients using the static version */ +/* of the library, but don't worry about that. Besides, */ +/* as a workaround, they can define FFI_BUILDING if they */ +/* *know* they are going to link with the static library. */ +#if defined _MSC_VER && !defined FFI_BUILDING +#define FFI_EXTERN extern __declspec(dllimport) +#else +#define FFI_EXTERN extern +#endif + +/* These are defined in types.c */ +FFI_EXTERN ffi_type ffi_type_void; +FFI_EXTERN ffi_type ffi_type_uint8; +FFI_EXTERN ffi_type ffi_type_sint8; +FFI_EXTERN ffi_type ffi_type_uint16; +FFI_EXTERN ffi_type ffi_type_sint16; +FFI_EXTERN ffi_type ffi_type_uint32; +FFI_EXTERN ffi_type ffi_type_sint32; +FFI_EXTERN ffi_type ffi_type_uint64; +FFI_EXTERN ffi_type ffi_type_sint64; +FFI_EXTERN ffi_type ffi_type_float; +FFI_EXTERN ffi_type ffi_type_double; +FFI_EXTERN ffi_type ffi_type_pointer; + +#if @HAVE_LONG_DOUBLE@ +FFI_EXTERN ffi_type ffi_type_longdouble; +#else +#define ffi_type_longdouble ffi_type_double +#endif + +#ifdef FFI_TARGET_HAS_COMPLEX_TYPE +FFI_EXTERN ffi_type ffi_type_complex_float; +FFI_EXTERN ffi_type ffi_type_complex_double; +#if @HAVE_LONG_DOUBLE@ +FFI_EXTERN ffi_type ffi_type_complex_longdouble; +#else +#define ffi_type_complex_longdouble ffi_type_complex_double +#endif +#endif +#endif /* LIBFFI_HIDE_BASIC_TYPES */ + +typedef enum { + FFI_OK = 0, + FFI_BAD_TYPEDEF, + FFI_BAD_ABI +} ffi_status; + +typedef unsigned FFI_TYPE; + +typedef struct { + ffi_abi abi; + unsigned nargs; + ffi_type **arg_types; + ffi_type *rtype; + unsigned bytes; + unsigned flags; +#ifdef FFI_EXTRA_CIF_FIELDS + FFI_EXTRA_CIF_FIELDS; +#endif +} ffi_cif; + +#if @HAVE_LONG_DOUBLE_VARIANT@ +/* Used to adjust size/alignment of ffi types. */ +void ffi_prep_types (ffi_abi abi); +#endif + +/* Used internally, but overridden by some architectures */ +ffi_status ffi_prep_cif_core(ffi_cif *cif, + ffi_abi abi, + unsigned int isvariadic, + unsigned int nfixedargs, + unsigned int ntotalargs, + ffi_type *rtype, + ffi_type **atypes); + +/* ---- Definitions for the raw API -------------------------------------- */ + +#ifndef FFI_SIZEOF_ARG +# if LONG_MAX == 2147483647 +# define FFI_SIZEOF_ARG 4 +# elif LONG_MAX == FFI_64_BIT_MAX +# define FFI_SIZEOF_ARG 8 +# endif +#endif + +#ifndef FFI_SIZEOF_JAVA_RAW +# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG +#endif + +typedef union { + ffi_sarg sint; + ffi_arg uint; + float flt; + char data[FFI_SIZEOF_ARG]; + void* ptr; +} ffi_raw; + +#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 +/* This is a special case for mips64/n32 ABI (and perhaps others) where + sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ +typedef union { + signed int sint; + unsigned int uint; + float flt; + char data[FFI_SIZEOF_JAVA_RAW]; + void* ptr; +} ffi_java_raw; +#else +typedef ffi_raw ffi_java_raw; +#endif + + +void ffi_raw_call (ffi_cif *cif, + void (*fn)(void), + void *rvalue, + ffi_raw *avalue); + +void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); +void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); +size_t ffi_raw_size (ffi_cif *cif); + +/* This is analogous to the raw API, except it uses Java parameter */ +/* packing, even on 64-bit machines. I.e. on 64-bit machines */ +/* longs and doubles are followed by an empty 64-bit word. */ + +void ffi_java_raw_call (ffi_cif *cif, + void (*fn)(void), + void *rvalue, + ffi_java_raw *avalue); + +void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); +void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); +size_t ffi_java_raw_size (ffi_cif *cif); + +/* ---- Definitions for closures ----------------------------------------- */ + +#if FFI_CLOSURES + +#ifdef _MSC_VER +__declspec(align(8)) +#endif +typedef struct { +#if @FFI_EXEC_TRAMPOLINE_TABLE@ + void *trampoline_table; + void *trampoline_table_entry; +#else + char tramp[FFI_TRAMPOLINE_SIZE]; +#endif + ffi_cif *cif; + void (*fun)(ffi_cif*,void*,void**,void*); + void *user_data; +#ifdef __GNUC__ +} ffi_closure __attribute__((aligned (8))); +#else +} ffi_closure; +# ifdef __sgi +# pragma pack 0 +# endif +#endif + +void *ffi_closure_alloc (size_t size, void **code); +void ffi_closure_free (void *); + +ffi_status +ffi_prep_closure (ffi_closure*, + ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data); + +ffi_status +ffi_prep_closure_loc (ffi_closure*, + ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void*codeloc); + +#ifdef __sgi +# pragma pack 8 +#endif +typedef struct { +#if @FFI_EXEC_TRAMPOLINE_TABLE@ + void *trampoline_table; + void *trampoline_table_entry; +#else + char tramp[FFI_TRAMPOLINE_SIZE]; +#endif + ffi_cif *cif; + +#if !FFI_NATIVE_RAW_API + + /* if this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate + handler to do the transaltion, void** -> ffi_raw*. */ + + void (*translate_args)(ffi_cif*,void*,void**,void*); + void *this_closure; + +#endif + + void (*fun)(ffi_cif*,void*,ffi_raw*,void*); + void *user_data; + +} ffi_raw_closure; + +typedef struct { +#if @FFI_EXEC_TRAMPOLINE_TABLE@ + void *trampoline_table; + void *trampoline_table_entry; +#else + char tramp[FFI_TRAMPOLINE_SIZE]; +#endif + + ffi_cif *cif; + +#if !FFI_NATIVE_RAW_API + + /* if this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate + handler to do the transaltion, void** -> ffi_raw*. */ + + void (*translate_args)(ffi_cif*,void*,void**,void*); + void *this_closure; + +#endif + + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); + void *user_data; + +} ffi_java_raw_closure; + +ffi_status +ffi_prep_raw_closure (ffi_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data); + +ffi_status +ffi_prep_raw_closure_loc (ffi_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data, + void *codeloc); + +ffi_status +ffi_prep_java_raw_closure (ffi_java_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data); + +ffi_status +ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data, + void *codeloc); + +#endif /* FFI_CLOSURES */ + +#if FFI_GO_CLOSURES + +typedef struct { + void *tramp; + ffi_cif *cif; + void (*fun)(ffi_cif*,void*,void**,void*); +} ffi_go_closure; + +ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*)); + +void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure); + +#endif /* FFI_GO_CLOSURES */ + +/* ---- Public interface definition -------------------------------------- */ + +ffi_status ffi_prep_cif(ffi_cif *cif, + ffi_abi abi, + unsigned int nargs, + ffi_type *rtype, + ffi_type **atypes); + +ffi_status ffi_prep_cif_var(ffi_cif *cif, + ffi_abi abi, + unsigned int nfixedargs, + unsigned int ntotalargs, + ffi_type *rtype, + ffi_type **atypes); + +void ffi_call(ffi_cif *cif, + void (*fn)(void), + void *rvalue, + void **avalue); + +/* Useful for eliminating compiler warnings */ +#define FFI_FN(f) ((void (*)(void))f) + +/* ---- Definitions shared with assembly code ---------------------------- */ + +#endif + +/* If these change, update src/mips/ffitarget.h. */ +#define FFI_TYPE_VOID 0 +#define FFI_TYPE_INT 1 +#define FFI_TYPE_FLOAT 2 +#define FFI_TYPE_DOUBLE 3 +#if @HAVE_LONG_DOUBLE@ +#define FFI_TYPE_LONGDOUBLE 4 +#else +#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE +#endif +#define FFI_TYPE_UINT8 5 +#define FFI_TYPE_SINT8 6 +#define FFI_TYPE_UINT16 7 +#define FFI_TYPE_SINT16 8 +#define FFI_TYPE_UINT32 9 +#define FFI_TYPE_SINT32 10 +#define FFI_TYPE_UINT64 11 +#define FFI_TYPE_SINT64 12 +#define FFI_TYPE_STRUCT 13 +#define FFI_TYPE_POINTER 14 +#define FFI_TYPE_COMPLEX 15 + +/* This should always refer to the last type code (for sanity checks) */ +#define FFI_TYPE_LAST FFI_TYPE_COMPLEX + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/libffi/include/ffi_cfi.h b/user/mpy/lib/libffi/include/ffi_cfi.h new file mode 100644 index 0000000..244ce57 --- /dev/null +++ b/user/mpy/lib/libffi/include/ffi_cfi.h @@ -0,0 +1,55 @@ +/* ----------------------------------------------------------------------- + ffi_cfi.h - Copyright (c) 2014 Red Hat, Inc. + + Conditionally assemble cfi directives. Only necessary for building libffi. + ----------------------------------------------------------------------- */ + +#ifndef FFI_CFI_H +#define FFI_CFI_H + +#ifdef HAVE_AS_CFI_PSEUDO_OP + +# define cfi_startproc .cfi_startproc +# define cfi_endproc .cfi_endproc +# define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off +# define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg +# define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off +# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off +# define cfi_offset(reg, off) .cfi_offset reg, off +# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off +# define cfi_register(r1, r2) .cfi_register r1, r2 +# define cfi_return_column(reg) .cfi_return_column reg +# define cfi_restore(reg) .cfi_restore reg +# define cfi_same_value(reg) .cfi_same_value reg +# define cfi_undefined(reg) .cfi_undefined reg +# define cfi_remember_state .cfi_remember_state +# define cfi_restore_state .cfi_restore_state +# define cfi_window_save .cfi_window_save +# define cfi_personality(enc, exp) .cfi_personality enc, exp +# define cfi_lsda(enc, exp) .cfi_lsda enc, exp +# define cfi_escape(...) .cfi_escape __VA_ARGS__ + +#else + +# define cfi_startproc +# define cfi_endproc +# define cfi_def_cfa(reg, off) +# define cfi_def_cfa_register(reg) +# define cfi_def_cfa_offset(off) +# define cfi_adjust_cfa_offset(off) +# define cfi_offset(reg, off) +# define cfi_rel_offset(reg, off) +# define cfi_register(r1, r2) +# define cfi_return_column(reg) +# define cfi_restore(reg) +# define cfi_same_value(reg) +# define cfi_undefined(reg) +# define cfi_remember_state +# define cfi_restore_state +# define cfi_window_save +# define cfi_personality(enc, exp) +# define cfi_lsda(enc, exp) +# define cfi_escape(...) + +#endif /* HAVE_AS_CFI_PSEUDO_OP */ +#endif /* FFI_CFI_H */ diff --git a/user/mpy/lib/libffi/include/ffi_common.h b/user/mpy/lib/libffi/include/ffi_common.h new file mode 100644 index 0000000..37f5a9e --- /dev/null +++ b/user/mpy/lib/libffi/include/ffi_common.h @@ -0,0 +1,132 @@ +/* ----------------------------------------------------------------------- + ffi_common.h - Copyright (C) 2011, 2012, 2013 Anthony Green + Copyright (C) 2007 Free Software Foundation, Inc + Copyright (c) 1996 Red Hat, Inc. + + Common internal definitions and macros. Only necessary for building + libffi. + ----------------------------------------------------------------------- */ + +#ifndef FFI_COMMON_H +#define FFI_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Do not move this. Some versions of AIX are very picky about where + this is positioned. */ +#ifdef __GNUC__ +# if HAVE_ALLOCA_H +# include +# else + /* mingw64 defines this already in malloc.h. */ +# ifndef alloca +# define alloca __builtin_alloca +# endif +# endif +# define MAYBE_UNUSED __attribute__((__unused__)) +#else +# define MAYBE_UNUSED +# if HAVE_ALLOCA_H +# include +# else +# ifdef _AIX +# pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +# ifdef _MSC_VER +# define alloca _alloca +# else +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +/* Check for the existence of memcpy. */ +#if STDC_HEADERS +# include +#else +# ifndef HAVE_MEMCPY +# define memcpy(d, s, n) bcopy ((s), (d), (n)) +# endif +#endif + +#if defined(FFI_DEBUG) +#include +#endif + +#ifdef FFI_DEBUG +void ffi_assert(char *expr, char *file, int line); +void ffi_stop_here(void); +void ffi_type_test(ffi_type *a, char *file, int line); + +#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__)) +#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l))) +#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__) +#else +#define FFI_ASSERT(x) +#define FFI_ASSERT_AT(x, f, l) +#define FFI_ASSERT_VALID_TYPE(x) +#endif + +#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1) +#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a) + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif); +ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, + unsigned int nfixedargs, unsigned int ntotalargs); + +/* Extended cif, used in callback from assembly routine */ +typedef struct +{ + ffi_cif *cif; + void *rvalue; + void **avalue; +} extended_cif; + +/* Terse sized type definitions. */ +#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C) +typedef unsigned char UINT8; +typedef signed char SINT8; +typedef unsigned short UINT16; +typedef signed short SINT16; +typedef unsigned int UINT32; +typedef signed int SINT32; +# ifdef _MSC_VER +typedef unsigned __int64 UINT64; +typedef signed __int64 SINT64; +# else +# include +typedef uint64_t UINT64; +typedef int64_t SINT64; +# endif +#else +typedef unsigned int UINT8 __attribute__((__mode__(__QI__))); +typedef signed int SINT8 __attribute__((__mode__(__QI__))); +typedef unsigned int UINT16 __attribute__((__mode__(__HI__))); +typedef signed int SINT16 __attribute__((__mode__(__HI__))); +typedef unsigned int UINT32 __attribute__((__mode__(__SI__))); +typedef signed int SINT32 __attribute__((__mode__(__SI__))); +typedef unsigned int UINT64 __attribute__((__mode__(__DI__))); +typedef signed int SINT64 __attribute__((__mode__(__DI__))); +#endif + +typedef float FLOAT32; + +#ifndef __GNUC__ +#define __builtin_expect(x, expected_value) (x) +#endif +#define LIKELY(x) __builtin_expect(!!(x),1) +#define UNLIKELY(x) __builtin_expect((x)!=0,0) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/libffi/libffi.pc.in b/user/mpy/lib/libffi/libffi.pc.in new file mode 100644 index 0000000..edf6fde --- /dev/null +++ b/user/mpy/lib/libffi/libffi.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +toolexeclibdir=@toolexeclibdir@ +includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include + +Name: @PACKAGE_NAME@ +Description: Library supporting Foreign Function Interfaces +Version: @PACKAGE_VERSION@ +Libs: -L${toolexeclibdir} -lffi +Cflags: -I${includedir} diff --git a/user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj b/user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj new file mode 100644 index 0000000..1cf396f --- /dev/null +++ b/user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj @@ -0,0 +1,637 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; }; + DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; }; + DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7140187F1D8600A76262 /* fficonfig.h */; }; + DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; }; + DBFA714E187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; + DBFA714F187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; + DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; + DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; + DBFA7158187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; }; + DBFA7159187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; }; + DBFA715A187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; }; + DBFA715B187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; }; + DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716C187F1D9B00A76262 /* ffi_arm64.c */; }; + DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716D187F1D9B00A76262 /* sysv_arm64.S */; }; + DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716F187F1D9B00A76262 /* ffi_armv7.c */; }; + DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7170187F1D9B00A76262 /* sysv_armv7.S */; }; + DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */; }; + DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */; }; + DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7174187F1D9B00A76262 /* darwin_i386.S */; }; + DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; }; + DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; }; + DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; }; + DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; }; + DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; }; + DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; }; + DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; }; + DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; }; + DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */; }; + DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* darwin_i386.S */; }; + DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; }; + DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718D187F1DA100A76262 /* ffi_i386.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + DB13B1641849DF1E0010F42D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + DB13B1661849DF1E0010F42D /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; + DB13B1911849DF510010F42D /* ffi.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = ffi.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + DBFA713E187F1D8600A76262 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = ""; }; + DBFA713F187F1D8600A76262 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = ""; }; + DBFA7140187F1D8600A76262 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = ""; }; + DBFA7141187F1D8600A76262 /* ffitarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget.h; sourceTree = ""; }; + DBFA7143187F1D8600A76262 /* closures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = closures.c; sourceTree = ""; }; + DBFA7145187F1D8600A76262 /* dlmalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dlmalloc.c; sourceTree = ""; }; + DBFA7147187F1D8600A76262 /* prep_cif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = prep_cif.c; sourceTree = ""; }; + DBFA7148187F1D8600A76262 /* raw_api.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raw_api.c; sourceTree = ""; }; + DBFA7149187F1D8600A76262 /* types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = types.c; sourceTree = ""; }; + DBFA715E187F1D9B00A76262 /* ffi_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_arm64.h; sourceTree = ""; }; + DBFA715F187F1D9B00A76262 /* ffi_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_armv7.h; sourceTree = ""; }; + DBFA7160187F1D9B00A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; + DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; + DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_arm64.h; sourceTree = ""; }; + DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_armv7.h; sourceTree = ""; }; + DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; + DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; + DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_arm64.h; sourceTree = ""; }; + DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_armv7.h; sourceTree = ""; }; + DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; + DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; + DBFA716C187F1D9B00A76262 /* ffi_arm64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_arm64.c; sourceTree = ""; }; + DBFA716D187F1D9B00A76262 /* sysv_arm64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_arm64.S; sourceTree = ""; }; + DBFA716F187F1D9B00A76262 /* ffi_armv7.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_armv7.c; sourceTree = ""; }; + DBFA7170187F1D9B00A76262 /* sysv_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_armv7.S; sourceTree = ""; }; + DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = trampoline_armv7.S; sourceTree = ""; }; + DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = ""; }; + DBFA7174187F1D9B00A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = ""; }; + DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = ""; }; + DBFA7176187F1D9B00A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = ""; }; + DBFA7182187F1DA100A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; + DBFA7183187F1DA100A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; + DBFA7184187F1DA100A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; + DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; + DBFA7186187F1DA100A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; + DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; + DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = ""; }; + DBFA718B187F1DA100A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = ""; }; + DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = ""; }; + DBFA718D187F1DA100A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXGroup section */ + DB13B15B1849DEB70010F42D = { + isa = PBXGroup; + children = ( + DBFA713C187F1D8600A76262 /* darwin_common */, + DBFA715C187F1D9B00A76262 /* darwin_ios */, + DBFA7180187F1DA100A76262 /* darwin_osx */, + DB13B1671849DF1E0010F42D /* Products */, + ); + sourceTree = ""; + }; + DB13B1671849DF1E0010F42D /* Products */ = { + isa = PBXGroup; + children = ( + DB13B1661849DF1E0010F42D /* libffi.a */, + DB13B1911849DF510010F42D /* ffi.dylib */, + ); + name = Products; + sourceTree = ""; + }; + DBFA713C187F1D8600A76262 /* darwin_common */ = { + isa = PBXGroup; + children = ( + DBFA713D187F1D8600A76262 /* include */, + DBFA7142187F1D8600A76262 /* src */, + ); + path = "darwin_common"; + sourceTree = ""; + }; + DBFA713D187F1D8600A76262 /* include */ = { + isa = PBXGroup; + children = ( + DBFA713E187F1D8600A76262 /* ffi.h */, + DBFA713F187F1D8600A76262 /* ffi_common.h */, + DBFA7140187F1D8600A76262 /* fficonfig.h */, + DBFA7141187F1D8600A76262 /* ffitarget.h */, + ); + path = include; + sourceTree = ""; + }; + DBFA7142187F1D8600A76262 /* src */ = { + isa = PBXGroup; + children = ( + DBFA7143187F1D8600A76262 /* closures.c */, + DBFA7145187F1D8600A76262 /* dlmalloc.c */, + DBFA7147187F1D8600A76262 /* prep_cif.c */, + DBFA7148187F1D8600A76262 /* raw_api.c */, + DBFA7149187F1D8600A76262 /* types.c */, + ); + path = src; + sourceTree = ""; + }; + DBFA715C187F1D9B00A76262 /* darwin_ios */ = { + isa = PBXGroup; + children = ( + DBFA715D187F1D9B00A76262 /* include */, + DBFA716A187F1D9B00A76262 /* src */, + ); + path = "darwin_ios"; + sourceTree = ""; + }; + DBFA715D187F1D9B00A76262 /* include */ = { + isa = PBXGroup; + children = ( + DBFA715E187F1D9B00A76262 /* ffi_arm64.h */, + DBFA715F187F1D9B00A76262 /* ffi_armv7.h */, + DBFA7160187F1D9B00A76262 /* ffi_i386.h */, + DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */, + DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */, + DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */, + DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */, + DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */, + DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */, + DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */, + DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */, + DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */, + ); + path = include; + sourceTree = ""; + }; + DBFA716A187F1D9B00A76262 /* src */ = { + isa = PBXGroup; + children = ( + DBFA716B187F1D9B00A76262 /* aarch64 */, + DBFA716E187F1D9B00A76262 /* arm */, + DBFA7172187F1D9B00A76262 /* x86 */, + ); + path = src; + sourceTree = ""; + }; + DBFA716B187F1D9B00A76262 /* aarch64 */ = { + isa = PBXGroup; + children = ( + DBFA716C187F1D9B00A76262 /* ffi_arm64.c */, + DBFA716D187F1D9B00A76262 /* sysv_arm64.S */, + ); + path = aarch64; + sourceTree = ""; + }; + DBFA716E187F1D9B00A76262 /* arm */ = { + isa = PBXGroup; + children = ( + DBFA716F187F1D9B00A76262 /* ffi_armv7.c */, + DBFA7170187F1D9B00A76262 /* sysv_armv7.S */, + DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */, + ); + path = arm; + sourceTree = ""; + }; + DBFA7172187F1D9B00A76262 /* x86 */ = { + isa = PBXGroup; + children = ( + DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */, + DBFA7174187F1D9B00A76262 /* darwin_i386.S */, + DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */, + DBFA7176187F1D9B00A76262 /* ffi_i386.c */, + ); + path = x86; + sourceTree = ""; + }; + DBFA7180187F1DA100A76262 /* darwin_osx */ = { + isa = PBXGroup; + children = ( + DBFA7181187F1DA100A76262 /* include */, + DBFA7188187F1DA100A76262 /* src */, + ); + path = "darwin_osx"; + sourceTree = ""; + }; + DBFA7181187F1DA100A76262 /* include */ = { + isa = PBXGroup; + children = ( + DBFA7182187F1DA100A76262 /* ffi_i386.h */, + DBFA7183187F1DA100A76262 /* ffi_x86_64.h */, + DBFA7184187F1DA100A76262 /* fficonfig_i386.h */, + DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */, + DBFA7186187F1DA100A76262 /* ffitarget_i386.h */, + DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */, + ); + path = include; + sourceTree = ""; + }; + DBFA7188187F1DA100A76262 /* src */ = { + isa = PBXGroup; + children = ( + DBFA7189187F1DA100A76262 /* x86 */, + ); + path = src; + sourceTree = ""; + }; + DBFA7189187F1DA100A76262 /* x86 */ = { + isa = PBXGroup; + children = ( + DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */, + DBFA718B187F1DA100A76262 /* darwin_i386.S */, + DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */, + DBFA718D187F1DA100A76262 /* ffi_i386.c */, + ); + path = x86; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + DB13B18F1849DF510010F42D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */, + DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */, + DBFA714A187F1D8600A76262 /* ffi.h in Headers */, + DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */, + DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */, + DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */, + DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */, + DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */, + DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */, + DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + DB13B1651849DF1E0010F42D /* libffi-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */; + buildPhases = ( + DB13B3051849E01C0010F42D /* ShellScript */, + DB13B1621849DF1E0010F42D /* Sources */, + DB13B1641849DF1E0010F42D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "libffi-iOS"; + productName = ffi; + productReference = DB13B1661849DF1E0010F42D /* libffi.a */; + productType = "com.apple.product-type.library.static"; + }; + DB13B1901849DF510010F42D /* libffi-Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */; + buildPhases = ( + DB13B3061849E0490010F42D /* ShellScript */, + DB13B18D1849DF510010F42D /* Sources */, + DB13B18F1849DF510010F42D /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "libffi-Mac"; + productName = ffi; + productReference = DB13B1911849DF510010F42D /* ffi.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + DB13B15C1849DEB70010F42D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + }; + buildConfigurationList = DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = DB13B15B1849DEB70010F42D; + productRefGroup = DB13B1671849DF1E0010F42D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + DB13B1651849DF1E0010F42D /* libffi-iOS */, + DB13B1901849DF510010F42D /* libffi-Mac */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + DB13B3051849E01C0010F42D /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-ios"; + }; + DB13B3061849E0490010F42D /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-osx"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + DB13B1621849DF1E0010F42D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */, + DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */, + DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */, + DBFA714E187F1D8600A76262 /* closures.c in Sources */, + DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */, + DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */, + DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */, + DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */, + DBFA7158187F1D8600A76262 /* raw_api.c in Sources */, + DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */, + DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */, + DBFA715A187F1D8600A76262 /* types.c in Sources */, + DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB13B18D1849DF510010F42D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */, + DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */, + DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */, + DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */, + DBFA715B187F1D8600A76262 /* types.c in Sources */, + DBFA7159187F1D8600A76262 /* raw_api.c in Sources */, + DBFA714F187F1D8600A76262 /* closures.c in Sources */, + DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + DB13B1601849DEB70010F42D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "darwin_common/include", + ); + ONLY_ACTIVE_ARCH = YES; + }; + name = Debug; + }; + DB13B1611849DEB70010F42D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "darwin_common/include", + ); + }; + name = Release; + }; + DB13B1871849DF1E0010F42D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DSTROOT = /tmp/ffi.dst; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "darwin_ios/include", + ); + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = ffi; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + DB13B1881849DF1E0010F42D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DSTROOT = /tmp/ffi.dst; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "darwin_ios/include", + ); + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = ffi; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + DB13B1B11849DF520010F42D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "darwin_osx/include", + ); + MACOSX_DEPLOYMENT_TARGET = 10.6; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; + PRODUCT_NAME = ffi; + SDKROOT = macosx; + }; + name = Debug; + }; + DB13B1B21849DF520010F42D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "darwin_osx/include", + ); + MACOSX_DEPLOYMENT_TARGET = 10.6; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; + PRODUCT_NAME = ffi; + SDKROOT = macosx; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB13B1601849DEB70010F42D /* Debug */, + DB13B1611849DEB70010F42D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB13B1871849DF1E0010F42D /* Debug */, + DB13B1881849DF1E0010F42D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB13B1B11849DF520010F42D /* Debug */, + DB13B1B21849DF520010F42D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = DB13B15C1849DEB70010F42D /* Project object */; +} diff --git a/user/mpy/lib/libffi/libtool-version b/user/mpy/lib/libffi/libtool-version new file mode 100644 index 0000000..149a51a --- /dev/null +++ b/user/mpy/lib/libffi/libtool-version @@ -0,0 +1,29 @@ +# This file is used to maintain libtool version info for libffi. See +# the libtool manual to understand the meaning of the fields. This is +# a separate file so that version updates don't involve re-running +# automake. +# +# Here are a set of rules to help you update your library version +# information: +# +# 1. Start with version information of `0:0:0' for each libtool library. +# +# 2. Update the version information only immediately before a public +# release of your software. More frequent updates are unnecessary, +# and only guarantee that the current interface number gets larger +# faster. +# +# 3. If the library source code has changed at all since the last +# update, then increment revision (`c:r:a' becomes `c:r+1:a'). +# +# 4. If any interfaces have been added, removed, or changed since the +# last update, increment current, and set revision to 0. +# +# 5. If any interfaces have been added since the last public release, +# then increment age. +# +# 6. If any interfaces have been removed since the last public +# release, then set age to 0. +# +# CURRENT:REVISION:AGE +6:4:0 diff --git a/user/mpy/lib/libffi/m4/asmcfi.m4 b/user/mpy/lib/libffi/m4/asmcfi.m4 new file mode 100644 index 0000000..dbf73a0 --- /dev/null +++ b/user/mpy/lib/libffi/m4/asmcfi.m4 @@ -0,0 +1,13 @@ +AC_DEFUN([GCC_AS_CFI_PSEUDO_OP], +[AC_CACHE_CHECK([assembler .cfi pseudo-op support], + gcc_cv_as_cfi_pseudo_op, [ + gcc_cv_as_cfi_pseudo_op=unknown + AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],, + [gcc_cv_as_cfi_pseudo_op=yes], + [gcc_cv_as_cfi_pseudo_op=no]) + ]) + if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then + AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1, + [Define if your assembler supports .cfi_* directives.]) + fi +]) diff --git a/user/mpy/lib/libffi/m4/ax_append_flag.m4 b/user/mpy/lib/libffi/m4/ax_append_flag.m4 new file mode 100644 index 0000000..1d38b76 --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_append_flag.m4 @@ -0,0 +1,69 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) +# +# DESCRIPTION +# +# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space +# added in between. +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains +# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly +# FLAG. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_APPEND_FLAG], +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl +AS_VAR_SET_IF(FLAGS, + [case " AS_VAR_GET(FLAGS) " in + *" $1 "*) + AC_RUN_LOG([: FLAGS already contains $1]) + ;; + *) + AC_RUN_LOG([: FLAGS="$FLAGS $1"]) + AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) + ;; + esac], + [AS_VAR_SET(FLAGS,["$1"])]) +AS_VAR_POPDEF([FLAGS])dnl +])dnl AX_APPEND_FLAG diff --git a/user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 b/user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 new file mode 100644 index 0000000..62e3b53 --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 @@ -0,0 +1,181 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CC_MAXOPT +# +# DESCRIPTION +# +# Try to turn on "good" C optimization flags for various compilers and +# architectures, for some definition of "good". (In our case, good for +# FFTW and hopefully for other scientific codes. Modify as needed.) +# +# The user can override the flags by setting the CFLAGS environment +# variable. The user can also specify --enable-portable-binary in order to +# disable any optimization flags that might result in a binary that only +# runs on the host architecture. +# +# Note also that the flags assume that ANSI C aliasing rules are followed +# by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point +# computations can be re-ordered as needed. +# +# Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR, +# AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 13 + +AC_DEFUN([AX_CC_MAXOPT], +[ +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AX_COMPILER_VENDOR]) +AC_REQUIRE([AC_CANONICAL_HOST]) + +AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])], + acx_maxopt_portable=$enableval, acx_maxopt_portable=no) + +# Try to determine "good" native compiler flags if none specified via CFLAGS +if test "$ac_test_CFLAGS" != "set"; then + CFLAGS="" + case $ax_cv_c_compiler_vendor in + dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" + if test "x$acx_maxopt_portable" = xno; then + CFLAGS="$CFLAGS -arch host" + fi;; + + sun) CFLAGS="-native -fast -xO5 -dalign" + if test "x$acx_maxopt_portable" = xyes; then + CFLAGS="$CFLAGS -xarch=generic" + fi;; + + hp) CFLAGS="+Oall +Optrs_ansi +DSnative" + if test "x$acx_maxopt_portable" = xyes; then + CFLAGS="$CFLAGS +DAportable" + fi;; + + ibm) if test "x$acx_maxopt_portable" = xno; then + xlc_opt="-qarch=auto -qtune=auto" + else + xlc_opt="-qtune=auto" + fi + AX_CHECK_COMPILE_FLAG($xlc_opt, + CFLAGS="-O3 -qansialias -w $xlc_opt", + [CFLAGS="-O3 -qansialias -w" + echo "******************************************************" + echo "* You seem to have the IBM C compiler. It is *" + echo "* recommended for best performance that you use: *" + echo "* *" + echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" + echo "* ^^^ ^^^ *" + echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" + echo "* CPU you have. (Set the CFLAGS environment var. *" + echo "* and re-run configure.) For more info, man cc. *" + echo "******************************************************"]) + ;; + + intel) CFLAGS="-O3 -ansi_alias" + if test "x$acx_maxopt_portable" = xno; then + icc_archflag=unknown + icc_flags="" + case $host_cpu in + i686*|x86_64*) + # icc accepts gcc assembly syntax, so these should work: + AX_GCC_X86_CPUID(0) + AX_GCC_X86_CPUID(1) + case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG + *:756e6547:*:*) # Intel + case $ax_cv_gcc_x86_cpuid_1 in + *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";; + *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";; + *f??:*:*:*) icc_flags="-xN -xW -xK";; + esac ;; + esac ;; + esac + if test "x$icc_flags" != x; then + for flag in $icc_flags; do + AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break]) + done + fi + AC_MSG_CHECKING([for icc architecture flag]) + AC_MSG_RESULT($icc_archflag) + if test "x$icc_archflag" != xunknown; then + CFLAGS="$CFLAGS $icc_archflag" + fi + fi + ;; + + gnu) + # default optimization flags for gcc on all systems + CFLAGS="-O3 -fomit-frame-pointer" + + # -malign-double for x86 systems + # LIBFFI -- DON'T DO THIS - CHANGES ABI + # AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double") + + # -fstrict-aliasing for gcc-2.95+ + AX_CHECK_COMPILE_FLAG(-fstrict-aliasing, + CFLAGS="$CFLAGS -fstrict-aliasing") + + # note that we enable "unsafe" fp optimization with other compilers, too + AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math") + + AX_GCC_ARCHFLAG($acx_maxopt_portable) + ;; + esac + + if test -z "$CFLAGS"; then + echo "" + echo "********************************************************" + echo "* WARNING: Don't know the best CFLAGS for this system *" + echo "* Use ./configure CFLAGS=... to specify your own flags *" + echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" + echo "********************************************************" + echo "" + CFLAGS="-O3" + fi + + AX_CHECK_COMPILE_FLAG($CFLAGS, [], [ + echo "" + echo "********************************************************" + echo "* WARNING: The guessed CFLAGS don't seem to work with *" + echo "* your compiler. *" + echo "* Use ./configure CFLAGS=... to specify your own flags *" + echo "********************************************************" + echo "" + CFLAGS="" + ]) + +fi +]) diff --git a/user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 b/user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 new file mode 100644 index 0000000..0fa3e18 --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 @@ -0,0 +1,122 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] +# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] +# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] +# +# DESCRIPTION +# +# Try to find a compiler option that enables most reasonable warnings. +# +# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result +# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. +# +# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, +# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and +# Intel compilers. For a given compiler, the Fortran flags are much more +# experimental than their C equivalents. +# +# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS +# - $2 add-value-if-not-found : nothing +# - $3 action-if-found : add value to shellvariable +# - $4 action-if-not-found : nothing +# +# NOTE: These macros depend on AX_APPEND_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2010 Rhys Ulerich +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 14 + +AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl +AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl +AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl +AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], +VAR,[VAR="no, unknown" +ac_save_[]FLAGS="$[]FLAGS" +for ac_arg dnl +in "-warn all % -warn all" dnl Intel + "-pedantic % -Wall" dnl GCC + "-xstrconst % -v" dnl Solaris C + "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix + "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX + "-ansi -ansiE % -fullwarn" dnl IRIX + "+ESlit % +w1" dnl HP-UX C + "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) + "-h conform % -h msglevel 2" dnl Cray C (Unicos) + # +do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) +done +FLAGS="$ac_save_[]FLAGS" +]) +AS_VAR_POPDEF([FLAGS])dnl +AC_REQUIRE([AX_APPEND_FLAG]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; + *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +])dnl AX_FLAGS_WARN_ALL +dnl implementation tactics: +dnl the for-argument contains a list of options. The first part of +dnl these does only exist to detect the compiler - usually it is +dnl a global option to enable -ansi or -extrawarnings. All other +dnl compilers will fail about it. That was needed since a lot of +dnl compilers will give false positives for some option-syntax +dnl like -Woption or -Xoption as they think of it is a pass-through +dnl to later compile stages or something. The "%" is used as a +dnl delimiter. A non-option comment can be given after "%%" marks +dnl which will be shown but not added to the respective C/CXXFLAGS. + +AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl +AC_LANG_PUSH([C]) +AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) +AC_LANG_POP([C]) +]) + +AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl +AC_LANG_PUSH([C++]) +AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) +AC_LANG_POP([C++]) +]) + +AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl +AC_LANG_PUSH([Fortran]) +AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) +AC_LANG_POP([Fortran]) +]) diff --git a/user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 b/user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..c3a8d69 --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 b/user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 new file mode 100644 index 0000000..73e32ea --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 @@ -0,0 +1,84 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPILER_VENDOR +# +# DESCRIPTION +# +# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, +# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, +# watcom, etc. The vendor is returned in the cache variable +# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 11 + +AC_DEFUN([AX_COMPILER_VENDOR], +[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, + [# note: don't check for gcc first since some other compilers define __GNUC__ + vendors="intel: __ICC,__ECC,__INTEL_COMPILER + ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ + pathscale: __PATHCC__,__PATHSCALE__ + clang: __clang__ + gnu: __GNUC__ + sun: __SUNPRO_C,__SUNPRO_CC + hp: __HP_cc,__HP_aCC + dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER + borland: __BORLANDC__,__TURBOC__ + comeau: __COMO__ + cray: _CRAYC + kai: __KCC + lcc: __LCC__ + sgi: __sgi,sgi + microsoft: _MSC_VER + metrowerks: __MWERKS__ + watcom: __WATCOMC__ + portland: __PGI + unknown: UNKNOWN" + for ventest in $vendors; do + case $ventest in + *:) vendor=$ventest; continue ;; + *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; + esac + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ + #if !($vencpp) + thisisanerror; + #endif + ])], [break]) + done + ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` + ]) +]) diff --git a/user/mpy/lib/libffi/m4/ax_configure_args.m4 b/user/mpy/lib/libffi/m4/ax_configure_args.m4 new file mode 100644 index 0000000..0726b1b --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_configure_args.m4 @@ -0,0 +1,70 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_configure_args.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CONFIGURE_ARGS +# +# DESCRIPTION +# +# Helper macro for AX_ENABLE_BUILDDIR. +# +# The traditional way of starting a subdir-configure is running the script +# with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have +# to rely on eval'ing $ac_configure_args however some old autoconf +# versions do not provide that. To ensure maximum portability of autoconf +# extension macros this helper can be AC_REQUIRE'd so that +# $ac_configure_args will alsways be present. +# +# Sadly, the traditional "exec $SHELL" of the enable_builddir macros is +# spoiled now and must be replaced by "eval + exit $?". +# +# Example: +# +# AC_DEFUN([AX_ENABLE_SUBDIR],[dnl +# AC_REQUIRE([AX_CONFIGURE_ARGS])dnl +# eval $SHELL $ac_configure_args || exit $? +# ...]) +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AC_DEFUN([AX_CONFIGURE_ARGS],[ + # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args + if test "${ac_configure_args+set}" != "set" ; then + ac_configure_args= + for ac_arg in ${1+"[$]@"}; do + ac_configure_args="$ac_configure_args '$ac_arg'" + done + fi +]) diff --git a/user/mpy/lib/libffi/m4/ax_enable_builddir.m4 b/user/mpy/lib/libffi/m4/ax_enable_builddir.m4 new file mode 100644 index 0000000..3cb2093 --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_enable_builddir.m4 @@ -0,0 +1,301 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])] +# +# DESCRIPTION +# +# If the current configure was run within the srcdir then we move all +# configure-files into a subdir and let the configure steps continue +# there. We provide an option --disable-builddir to suppress the move into +# a separate builddir. +# +# Defaults: +# +# $1 = $host (overridden with $HOST) +# $2 = Makefile.mk +# $3 = -all +# +# This macro must be called before AM_INIT_AUTOMAKE. It creates a default +# toplevel srcdir Makefile from the information found in the created +# toplevel builddir Makefile. It just copies the variables and +# rule-targets, each extended with a default rule-execution that recurses +# into the build directory of the current "HOST". You can override the +# auto-dection through `config.guess` and build-time of course, as in +# +# make HOST=i386-mingw-cross +# +# which can of course set at configure time as well using +# +# configure --host=i386-mingw-cross +# +# After the default has been created, additional rules can be appended +# that will not just recurse into the subdirectories and only ever exist +# in the srcdir toplevel makefile - these parts are read from the $2 = +# Makefile.mk file +# +# The automatic rules are usually scanning the toplevel Makefile for lines +# like '#### $host |$builddir' to recognize the place where to recurse +# into. Usually, the last one is the only one used. However, almost all +# targets have an additional "*-all" rule which makes the script to +# recurse into _all_ variants of the current HOST (!!) setting. The "-all" +# suffix can be overriden for the macro as well. +# +# a special rule is only given for things like "dist" that will copy the +# tarball from the builddir to the sourcedir (or $(PUB)) for reason of +# convenience. +# +# LICENSE +# +# Copyright (c) 2009 Guido U. Draheim +# Copyright (c) 2009 Alan Jenkins +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 23 + +AC_DEFUN([AX_ENABLE_BUILDDIR],[ +AC_REQUIRE([AC_CANONICAL_HOST])[]dnl +AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl +AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl +AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl +AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl +AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl +AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl +SUB="." +AC_ARG_ENABLE([builddir], AS_HELP_STRING( + [--disable-builddir],[disable automatic build in subdir of sources]) + ,[SUB="$enableval"], [SUB="auto"]) +if test ".$ac_srcdir_defaulted" != ".no" ; then +if test ".$srcdir" = ".." ; then + if test -f config.status ; then + AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build) + else + test ".$SUB" = "." && SUB="." + test ".$SUB" = ".no" && SUB="." + test ".$TARGET" = "." && TARGET="$target" + test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])" + if test ".$SUB" != ".." ; then # we know where to go and + AS_MKDIR_P([$SUB]) + echo __.$SUB.__ > $SUB/conftest.tmp + cd $SUB + if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then + rm conftest.tmp + AC_MSG_RESULT([continue configure in default builddir "./$SUB"]) + else + AC_MSG_ERROR([could not change to default builddir "./$SUB"]) + fi + srcdir=`echo "$SUB" | + sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'` + # going to restart from subdirectory location + test -f $srcdir/config.log && mv $srcdir/config.log . + test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h . + test -f $srcdir/conftest.log && mv $srcdir/conftest.log . + test -f $srcdir/$cache_file && mv $srcdir/$cache_file . + AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"}) + case "[$]0" in # restart + [[\\/]]* | ?:[[\\/]]*) # Asbolute name + eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; + *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; + esac ; exit $? + fi + fi +fi fi +test ".$SUB" = ".auto" && SUB="." +dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec" +AC_PATH_PROG(SED,gsed sed, sed) +AUX="$am_aux_dir" +AS_VAR_POPDEF([SED])dnl +AS_VAR_POPDEF([AUX])dnl +AS_VAR_POPDEF([SUB])dnl +AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status .............. +AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl +AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl +AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl +AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl +AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl +pushdef([END],[Makefile.mk])dnl +pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl + SRC="$ax_enable_builddir_srcdir" + if test ".$SUB" = ".." ; then + if test -f "$TOP/Makefile" ; then + AC_MSG_NOTICE([skipping TOP/Makefile - left untouched]) + else + AC_MSG_NOTICE([skipping TOP/Makefile - not created]) + fi + else + if test -f "$SRC/Makefile" ; then + a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile` + test "$a" != "$b" && rm "$SRC/Makefile" + fi + if test -f "$SRC/Makefile" ; then + echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk + echo " []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk + eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null" + if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null + then rm $SRC/Makefile ; fi + cp $tmp/conftemp.mk $SRC/makefiles.mk~ ## DEBUGGING + fi + if test ! -f "$SRC/Makefile" ; then + AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile]) + x='`' ; cat >$tmp/conftemp.sed <<_EOF +/^\$/n +x +/^\$/bS +x +/\\\\\$/{H;d;} +{H;s/.*//;x;} +bM +:S +x +/\\\\\$/{h;d;} +{h;s/.*//;x;} +:M +s/\\(\\n\\) /\\1 /g +/^ /d +/^[[ ]]*[[\\#]]/d +/^VPATH *=/d +s/^srcdir *=.*/srcdir = ./ +s/^top_srcdir *=.*/top_srcdir = ./ +/[[:=]]/!d +/^\\./d +dnl Now handle rules (i.e. lines containing ":" but not " = "). +/ = /b +/ .= /b +/:/!b +s/:.*/:/ +s/ / /g +s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g +s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/ +s/ / /g +/^all all[]_ALL[[ :]]/i\\ +all-configured : all[]_ALL +dnl dist-all exists... and would make for dist-all-all +s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g +/[]_ALL[]_ALL/d +a\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ + ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ + ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ + ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\ + ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\ + ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ + ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ + ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ + ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done +dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree) +/dist[]_ALL *:/a\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ + ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ + ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ + ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ + ; if test "\$\$found" -eq "0" ; then : \\\\\\ + ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ + ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ + ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ + ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done +dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree) +/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\ + ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ + ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ + ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\ + ; if test "\$\$found" -eq "0" ; then : \\\\\\ + ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ + ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ + ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\ + ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done +dnl special rule add-on: "distclean" removes all local builddirs completely +/distclean[]_ALL *:/a\\ + @ HOST="\$(HOST)\" \\\\\\ + ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ + ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\ + ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ + ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\ + ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ + ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ + ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\ + ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ + ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\ + ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\ + ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile +_EOF + cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING + $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile + if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then + AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])]) + cat $SRC/END >>$SRC/Makefile + fi ; xxxx="####" + echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile + # sanity check + if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then + AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts]) + $SED -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $SRC/Makefile \ + >$SRC/Makefile~ + (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null + fi + else + xxxx="\\#\\#\\#\\#" + # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed + echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed + $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp + cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~" ## DEBUGGING + cp "$tmp/mkfile.tmp" "$SRC/makefiles.out~" ## DEBUGGING + if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then + AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure]) + rm "$tmp/mkfile.tmp" + else + AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure]) + mv "$tmp/mkfile.tmp" "$SRC/Makefile" + fi + fi + AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)]) + xxxx="####" + echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile + fi +popdef([END])dnl +AS_VAR_POPDEF([SED])dnl +AS_VAR_POPDEF([AUX])dnl +AS_VAR_POPDEF([SRC])dnl +AS_VAR_POPDEF([TOP])dnl +AS_VAR_POPDEF([SUB])dnl +],[dnl +ax_enable_builddir_srcdir="$srcdir" # $srcdir +ax_enable_builddir_host="$HOST" # $HOST / $host +ax_enable_builddir_version="$VERSION" # $VERSION +ax_enable_builddir_package="$PACKAGE" # $PACKAGE +ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX +ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED +ax_enable_builddir="$ax_enable_builddir" # $SUB +])dnl +]) diff --git a/user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 b/user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 new file mode 100644 index 0000000..aab2661 --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 @@ -0,0 +1,225 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE]) +# +# DESCRIPTION +# +# This macro tries to guess the "native" arch corresponding to the target +# architecture for use with gcc's -march=arch or -mtune=arch flags. If +# found, the cache variable $ax_cv_gcc_archflag is set to this flag and +# ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to +# "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is +# to add $ax_cv_gcc_archflag to the end of $CFLAGS. +# +# PORTABLE? should be either [yes] (default) or [no]. In the former case, +# the flag is set to -mtune (or equivalent) so that the architecture is +# only used for tuning, but the instruction set used is still portable. In +# the latter case, the flag is set to -march (or equivalent) so that +# architecture-specific instructions are enabled. +# +# The user can specify --with-gcc-arch= in order to override the +# macro's choice of architecture, or --without-gcc-arch to disable this. +# +# When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is +# called unless the user specified --with-gcc-arch manually. +# +# Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID +# +# (The main emphasis here is on recent CPUs, on the principle that doing +# high-performance computing on old hardware is uncommon.) +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# Copyright (c) 2012 Tsukasa Oi +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 11 + +AC_DEFUN([AX_GCC_ARCHFLAG], +[AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_CANONICAL_HOST]) + +AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=], [use architecture for gcc -march/-mtune, instead of guessing])], + ax_gcc_arch=$withval, ax_gcc_arch=yes) + +AC_MSG_CHECKING([for gcc architecture flag]) +AC_MSG_RESULT([]) +AC_CACHE_VAL(ax_cv_gcc_archflag, +[ +ax_cv_gcc_archflag="unknown" + +if test "$GCC" = yes; then + +if test "x$ax_gcc_arch" = xyes; then +ax_gcc_arch="" +if test "$cross_compiling" = no; then +case $host_cpu in + i[[3456]]86*|x86_64*) # use cpuid codes + AX_GCC_X86_CPUID(0) + AX_GCC_X86_CPUID(1) + case $ax_cv_gcc_x86_cpuid_0 in + *:756e6547:*:*) # Intel + case $ax_cv_gcc_x86_cpuid_1 in + *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; + *5??:*:*:*) ax_gcc_arch=pentium ;; + *0?6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; + *0?6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; + *0?6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; + *0?6[[9de]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; + *0?6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; + *0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;; + *1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;; + *1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;; + *1?6c?:*:*:*|*[[23]]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;; + *2?6[[ad]]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; + *0?6??:*:*:*) ax_gcc_arch=pentiumpro ;; + *6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;; + ?000?f3[[347]]:*:*:*|?000?f4[1347]:*:*:*|?000?f6?:*:*:*) + case $host_cpu in + x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; + *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; + esac ;; + ?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; + esac ;; + *:68747541:*:*) # AMD + case $ax_cv_gcc_x86_cpuid_1 in + *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;; + *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; + *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; + *60?:*:*:*) ax_gcc_arch=k7 ;; + *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;; + *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; + *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; + *6[[68a]]?:*:*:*) + AX_GCC_X86_CPUID(0x80000006) # L2 cache size + case $ax_cv_gcc_x86_cpuid_0x80000006 in + *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256 + ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; + *) ax_gcc_arch="athlon-4 athlon k7" ;; + esac ;; + ?00??f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; + ?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;; + ?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; + ?00??f??:*:*:*) ax_gcc_arch="k8" ;; + ?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;; + ?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;; + *f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;; + esac ;; + *:746e6543:*:*) # IDT + case $ax_cv_gcc_x86_cpuid_1 in + *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; + *58?:*:*:*) ax_gcc_arch=winchip2 ;; + *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;; + *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; + esac ;; + esac + if test x"$ax_gcc_arch" = x; then # fallback + case $host_cpu in + i586*) ax_gcc_arch=pentium ;; + i686*) ax_gcc_arch=pentiumpro ;; + esac + fi + ;; + + sparc*) + AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/]) + cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` + cputype=`echo "$cputype" | tr -d ' -' | sed 's/SPARCIIi/SPARCII/' | tr $as_cr_LETTERS $as_cr_letters` + case $cputype in + *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; + *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; + *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; + *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;; + *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;; + *cypress*) ax_gcc_arch=cypress ;; + esac ;; + + alphaev5) ax_gcc_arch=ev5 ;; + alphaev56) ax_gcc_arch=ev56 ;; + alphapca56) ax_gcc_arch="pca56 ev56" ;; + alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; + alphaev6) ax_gcc_arch=ev6 ;; + alphaev67) ax_gcc_arch=ev67 ;; + alphaev68) ax_gcc_arch="ev68 ev67" ;; + alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; + alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; + alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; + + powerpc*) + cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` + cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` + case $cputype in + *750*) ax_gcc_arch="750 G3" ;; + *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;; + *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;; + *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;; + *970*) ax_gcc_arch="970 G5 power4";; + *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; + *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; + 603ev|8240) ax_gcc_arch="$cputype 603e 603";; + *) ax_gcc_arch=$cputype ;; + esac + ax_gcc_arch="$ax_gcc_arch powerpc" + ;; +esac +fi # not cross-compiling +fi # guess arch + +if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then +for arch in $ax_gcc_arch; do + if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code + flags="-mtune=$arch" + # -mcpu=$arch and m$arch generate nonportable code on every arch except + # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. + case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac + else + flags="-march=$arch -mcpu=$arch -m$arch" + fi + for flag in $flags; do + AX_CHECK_COMPILE_FLAG($flag, [ax_cv_gcc_archflag=$flag; break]) + done + test "x$ax_cv_gcc_archflag" = xunknown || break +done +fi + +fi # $GCC=yes +]) +AC_MSG_CHECKING([for gcc architecture flag]) +AC_MSG_RESULT($ax_cv_gcc_archflag) +if test "x$ax_cv_gcc_archflag" = xunknown; then + m4_default([$3],:) +else + m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"]) +fi +]) diff --git a/user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 b/user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 new file mode 100644 index 0000000..7d46fee --- /dev/null +++ b/user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 @@ -0,0 +1,79 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_X86_CPUID(OP) +# +# DESCRIPTION +# +# On Pentium and later x86 processors, with gcc or a compiler that has a +# compatible syntax for inline assembly instructions, run a small program +# that executes the cpuid instruction with input OP. This can be used to +# detect the CPU type. +# +# On output, the values of the eax, ebx, ecx, and edx registers are stored +# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable +# ax_cv_gcc_x86_cpuid_OP. +# +# If the cpuid instruction fails (because you are running a +# cross-compiler, or because you are not using gcc, or because you are on +# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP +# is set to the string "unknown". +# +# This macro mainly exists to be used in AX_GCC_ARCHFLAG. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AC_DEFUN([AX_GCC_X86_CPUID], +[AC_REQUIRE([AC_PROG_CC]) +AC_LANG_PUSH([C]) +AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, + [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ + int op = $1, eax, ebx, ecx, edx; + FILE *f; + __asm__("cpuid" + : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) + : "a" (op)); + f = fopen("conftest_cpuid", "w"); if (!f) return 1; + fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); + fclose(f); + return 0; +])], + [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], + [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], + [ax_cv_gcc_x86_cpuid_$1=unknown])]) +AC_LANG_POP([C]) +]) diff --git a/user/mpy/lib/libffi/man/Makefile.am b/user/mpy/lib/libffi/man/Makefile.am new file mode 100644 index 0000000..afcbfb6 --- /dev/null +++ b/user/mpy/lib/libffi/man/Makefile.am @@ -0,0 +1,8 @@ +## Process this with automake to create Makefile.in + +AUTOMAKE_OPTIONS=foreign + +EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 + +man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 + diff --git a/user/mpy/lib/libffi/man/ffi.3 b/user/mpy/lib/libffi/man/ffi.3 new file mode 100644 index 0000000..1f1d303 --- /dev/null +++ b/user/mpy/lib/libffi/man/ffi.3 @@ -0,0 +1,41 @@ +.Dd February 15, 2008 +.Dt FFI 3 +.Sh NAME +.Nm FFI +.Nd Foreign Function Interface +.Sh LIBRARY +libffi, -lffi +.Sh SYNOPSIS +.In ffi.h +.Ft ffi_status +.Fo ffi_prep_cif +.Fa "ffi_cif *cif" +.Fa "ffi_abi abi" +.Fa "unsigned int nargs" +.Fa "ffi_type *rtype" +.Fa "ffi_type **atypes" +.Fc +.Ft void +.Fo ffi_prep_cif_var +.Fa "ffi_cif *cif" +.Fa "ffi_abi abi" +.Fa "unsigned int nfixedargs" +.Fa "unsigned int ntotalargs" +.Fa "ffi_type *rtype" +.Fa "ffi_type **atypes" +.Fc +.Ft void +.Fo ffi_call +.Fa "ffi_cif *cif" +.Fa "void (*fn)(void)" +.Fa "void *rvalue" +.Fa "void **avalue" +.Fc +.Sh DESCRIPTION +The foreign function interface provides a mechanism by which a function can +generate a call to another function at runtime without requiring knowledge of +the called function's interface at compile time. +.Sh SEE ALSO +.Xr ffi_prep_cif 3 , +.Xr ffi_prep_cif_var 3 , +.Xr ffi_call 3 diff --git a/user/mpy/lib/libffi/man/ffi_call.3 b/user/mpy/lib/libffi/man/ffi_call.3 new file mode 100644 index 0000000..5351513 --- /dev/null +++ b/user/mpy/lib/libffi/man/ffi_call.3 @@ -0,0 +1,103 @@ +.Dd February 15, 2008 +.Dt ffi_call 3 +.Sh NAME +.Nm ffi_call +.Nd Invoke a foreign function. +.Sh SYNOPSIS +.In ffi.h +.Ft void +.Fo ffi_call +.Fa "ffi_cif *cif" +.Fa "void (*fn)(void)" +.Fa "void *rvalue" +.Fa "void **avalue" +.Fc +.Sh DESCRIPTION +The +.Nm ffi_call +function provides a simple mechanism for invoking a function without +requiring knowledge of the function's interface at compile time. +.Fa fn +is called with the values retrieved from the pointers in the +.Fa avalue +array. The return value from +.Fa fn +is placed in storage pointed to by +.Fa rvalue . +.Fa cif +contains information describing the data types, sizes and alignments of the +arguments to and return value from +.Fa fn , +and must be initialized with +.Nm ffi_prep_cif +before it is used with +.Nm ffi_call . +.Pp +.Fa rvalue +must point to storage that is sizeof(ffi_arg) or larger for non-floating point +types. For smaller-sized return value types, the +.Nm ffi_arg +or +.Nm ffi_sarg +integral type must be used to hold +the return value. +.Sh EXAMPLES +.Bd -literal +#include +#include + +unsigned char +foo(unsigned int, float); + +int +main(int argc, const char **argv) +{ + ffi_cif cif; + ffi_type *arg_types[2]; + void *arg_values[2]; + ffi_status status; + + // Because the return value from foo() is smaller than sizeof(long), it + // must be passed as ffi_arg or ffi_sarg. + ffi_arg result; + + // Specify the data type of each argument. Available types are defined + // in . + arg_types[0] = &ffi_type_uint; + arg_types[1] = &ffi_type_float; + + // Prepare the ffi_cif structure. + if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, + 2, &ffi_type_uint8, arg_types)) != FFI_OK) + { + // Handle the ffi_status error. + } + + // Specify the values of each argument. + unsigned int arg1 = 42; + float arg2 = 5.1; + + arg_values[0] = &arg1; + arg_values[1] = &arg2; + + // Invoke the function. + ffi_call(&cif, FFI_FN(foo), &result, arg_values); + + // The ffi_arg 'result' now contains the unsigned char returned from foo(), + // which can be accessed by a typecast. + printf("result is %hhu", (unsigned char)result); + + return 0; +} + +// The target function. +unsigned char +foo(unsigned int x, float y) +{ + unsigned char result = x - y; + return result; +} +.Ed +.Sh SEE ALSO +.Xr ffi 3 , +.Xr ffi_prep_cif 3 diff --git a/user/mpy/lib/libffi/man/ffi_prep_cif.3 b/user/mpy/lib/libffi/man/ffi_prep_cif.3 new file mode 100644 index 0000000..ab2be8a --- /dev/null +++ b/user/mpy/lib/libffi/man/ffi_prep_cif.3 @@ -0,0 +1,68 @@ +.Dd February 15, 2008 +.Dt ffi_prep_cif 3 +.Sh NAME +.Nm ffi_prep_cif +.Nd Prepare a +.Nm ffi_cif +structure for use with +.Nm ffi_call +. +.Sh SYNOPSIS +.In ffi.h +.Ft ffi_status +.Fo ffi_prep_cif +.Fa "ffi_cif *cif" +.Fa "ffi_abi abi" +.Fa "unsigned int nargs" +.Fa "ffi_type *rtype" +.Fa "ffi_type **atypes" +.Fc +.Sh DESCRIPTION +The +.Nm ffi_prep_cif +function prepares a +.Nm ffi_cif +structure for use with +.Nm ffi_call +. +.Fa abi +specifies a set of calling conventions to use. +.Fa atypes +is an array of +.Fa nargs +pointers to +.Nm ffi_type +structs that describe the data type, size and alignment of each argument. +.Fa rtype +points to an +.Nm ffi_type +that describes the data type, size and alignment of the +return value. Note that to call a variadic function +.Nm ffi_prep_cif_var +must be used instead. +.Sh RETURN VALUES +Upon successful completion, +.Nm ffi_prep_cif +returns +.Nm FFI_OK . +It will return +.Nm FFI_BAD_TYPEDEF +if +.Fa cif +is +.Nm NULL +or +.Fa atypes +or +.Fa rtype +is malformed. If +.Fa abi +does not refer to a valid ABI, +.Nm FFI_BAD_ABI +will be returned. Available ABIs are +defined in +.Nm . +.Sh SEE ALSO +.Xr ffi 3 , +.Xr ffi_call 3 , +.Xr ffi_prep_cif_var 3 diff --git a/user/mpy/lib/libffi/man/ffi_prep_cif_var.3 b/user/mpy/lib/libffi/man/ffi_prep_cif_var.3 new file mode 100644 index 0000000..7e19d0b --- /dev/null +++ b/user/mpy/lib/libffi/man/ffi_prep_cif_var.3 @@ -0,0 +1,73 @@ +.Dd January 25, 2011 +.Dt ffi_prep_cif_var 3 +.Sh NAME +.Nm ffi_prep_cif_var +.Nd Prepare a +.Nm ffi_cif +structure for use with +.Nm ffi_call +for variadic functions. +.Sh SYNOPSIS +.In ffi.h +.Ft ffi_status +.Fo ffi_prep_cif_var +.Fa "ffi_cif *cif" +.Fa "ffi_abi abi" +.Fa "unsigned int nfixedargs" +.Fa "unsigned int ntotalargs" +.Fa "ffi_type *rtype" +.Fa "ffi_type **atypes" +.Fc +.Sh DESCRIPTION +The +.Nm ffi_prep_cif_var +function prepares a +.Nm ffi_cif +structure for use with +.Nm ffi_call +for variadic functions. +.Fa abi +specifies a set of calling conventions to use. +.Fa atypes +is an array of +.Fa ntotalargs +pointers to +.Nm ffi_type +structs that describe the data type, size and alignment of each argument. +.Fa rtype +points to an +.Nm ffi_type +that describes the data type, size and alignment of the +return value. +.Fa nfixedargs +must contain the number of fixed (non-variadic) arguments. +Note that to call a non-variadic function +.Nm ffi_prep_cif +must be used. +.Sh RETURN VALUES +Upon successful completion, +.Nm ffi_prep_cif_var +returns +.Nm FFI_OK . +It will return +.Nm FFI_BAD_TYPEDEF +if +.Fa cif +is +.Nm NULL +or +.Fa atypes +or +.Fa rtype +is malformed. If +.Fa abi +does not refer to a valid ABI, +.Nm FFI_BAD_ABI +will be returned. Available ABIs are +defined in +.Nm +. +.Sh SEE ALSO +.Xr ffi 3 , +.Xr ffi_call 3 , +.Xr ffi_prep_cif 3 diff --git a/user/mpy/lib/libffi/msvcc.sh b/user/mpy/lib/libffi/msvcc.sh new file mode 100755 index 0000000..65fbfef --- /dev/null +++ b/user/mpy/lib/libffi/msvcc.sh @@ -0,0 +1,257 @@ +#!/bin/sh + +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the MSVC wrappificator. +# +# The Initial Developer of the Original Code is +# Timothy Wall . +# Portions created by the Initial Developer are Copyright (C) 2009 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Daniel Witte +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# +# GCC-compatible wrapper for cl.exe and ml.exe. Arguments are given in GCC +# format and translated into something sensible for cl or ml. +# + +args_orig=$@ +args="-nologo -W3" +static_crt= +debug_crt= +cl="cl" +ml="ml" +safeseh="-safeseh" +output= + +while [ $# -gt 0 ] +do + case $1 + in + -fexceptions) + # Don't enable exceptions for now. + #args="$args -EHac" + shift 1 + ;; + -m32) + shift 1 + ;; + -m64) + ml="ml64" # "$MSVC/x86_amd64/ml64" + safeseh= + shift 1 + ;; + -clang-cl) + cl="clang-cl" + safeseh= + shift 1 + ;; + -O0) + args="$args -Od" + shift 1 + ;; + -O*) + # Runtime error checks (enabled by setting -RTC1 in the -DFFI_DEBUG + # case below) are not compatible with optimization flags and will + # cause the build to fail. Therefore, drop the optimization flag if + # -DFFI_DEBUG is also set. + case $args_orig in + *-DFFI_DEBUG*) + args="$args" + ;; + *) + # The ax_cc_maxopt.m4 macro from the upstream autoconf-archive + # project doesn't support MSVC and therefore ends up trying to + # use -O3. Use the equivalent "max optimization" flag for MSVC + # instead of erroring out. + case $1 in + -O3) + args="$args -O2" + ;; + *) + args="$args $1" + ;; + esac + opt="true" + ;; + esac + shift 1 + ;; + -g) + # Enable debug symbol generation. + args="$args -Zi" + shift 1 + ;; + -DFFI_DEBUG) + # Enable runtime error checks. + args="$args -RTC1" + defines="$defines $1" + shift 1 + ;; + -DUSE_STATIC_RTL) + # Link against static CRT. + static_crt=1 + shift 1 + ;; + -DUSE_DEBUG_RTL) + # Link against debug CRT. + debug_crt=1 + shift 1 + ;; + -c) + args="$args -c" + args="$(echo $args | sed 's%/Fe%/Fo%g')" + single="-c" + shift 1 + ;; + -D*=*) + name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')" + value="$(echo $1|sed 's/-D[^=][^=]*=//g')" + args="$args -D${name}='$value'" + defines="$defines -D${name}='$value'" + shift 1 + ;; + -D*) + args="$args $1" + defines="$defines $1" + shift 1 + ;; + -I) + args="$args -I$2" + includes="$includes -I$2" + shift 2 + ;; + -I*) + args="$args $1" + includes="$includes $1" + shift 1 + ;; + -W|-Wextra) + # TODO map extra warnings + shift 1 + ;; + -Wall) + # -Wall on MSVC is overzealous, and we already build with -W3. Nothing + # to do here. + shift 1 + ;; + -pedantic) + # libffi tests -pedantic with -Wall, so drop it also. + shift 1 + ;; + -Werror) + args="$args -WX" + shift 1 + ;; + -W*) + # TODO map specific warnings + shift 1 + ;; + -S) + args="$args -FAs" + shift 1 + ;; + -o) + outdir="$(dirname $2)" + base="$(basename $2|sed 's/\.[^.]*//g')" + if [ -n "$single" ]; then + output="-Fo$2" + else + output="-Fe$2" + fi + if [ -n "$assembly" ]; then + args="$args $output" + else + args="$args $output -Fd$outdir/$base -Fp$outdir/$base -Fa$outdir/$base" + fi + shift 2 + ;; + *.S) + src=$1 + assembly="true" + shift 1 + ;; + *.c) + args="$args $1" + shift 1 + ;; + *) + # Assume it's an MSVC argument, and pass it through. + args="$args $1" + shift 1 + ;; + esac +done + +# If -Zi is specified, certain optimizations are implicitly disabled +# by MSVC. Add back those optimizations if this is an optimized build. +# NOTE: These arguments must come after all others. +if [ -n "$opt" ]; then + args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO" +fi + +if [ -n "$static_crt" ]; then + md=-MT +else + md=-MD +fi + +if [ -n "$debug_crt" ]; then + md="${md}d" +fi + +if [ -n "$assembly" ]; then + if [ -z "$outdir" ]; then + outdir="." + fi + ppsrc="$outdir/$(basename $src|sed 's/.S$/.asm/g')" + echo "$cl -nologo -EP $includes $defines $src > $ppsrc" + "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $? + output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')" + args="-nologo $safeseh $single $output $ppsrc" + + echo "$ml $args" + eval "\"$ml\" $args" + result=$? + + # required to fix ml64 broken output? + #mv *.obj $outdir +else + args="$md $args" + echo "$cl $args" + # Return an error code of 1 if an invalid command line parameter is passed + # instead of just ignoring it. + eval "(\"$cl\" $args 2>&1 1>&3 | \ + awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1" + result=$? +fi + +exit $result + diff --git a/user/mpy/lib/libffi/src/aarch64/ffi.c b/user/mpy/lib/libffi/src/aarch64/ffi.c new file mode 100644 index 0000000..f79602b --- /dev/null +++ b/user/mpy/lib/libffi/src/aarch64/ffi.c @@ -0,0 +1,1152 @@ +/* Copyright (c) 2009, 2010, 2011, 2012 ARM 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. */ + +#include +#include +#include +#include +#include +#include "internal.h" + +/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; + all further uses in this file will refer to the 128-bit type. */ +#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE +# if FFI_TYPE_LONGDOUBLE != 4 +# error FFI_TYPE_LONGDOUBLE out of date +# endif +#else +# undef FFI_TYPE_LONGDOUBLE +# define FFI_TYPE_LONGDOUBLE 4 +#endif + +union _d +{ + UINT64 d; + UINT32 s[2]; +}; + +struct _v +{ + union _d d[2] __attribute__((aligned(16))); +}; + +struct call_context +{ + struct _v v[N_V_ARG_REG]; + UINT64 x[N_X_ARG_REG]; +}; + +#if defined (__clang__) && defined (__APPLE__) +extern void sys_icache_invalidate (void *start, size_t len); +#endif + +static inline void +ffi_clear_cache (void *start, void *end) +{ +#if defined (__clang__) && defined (__APPLE__) + sys_icache_invalidate (start, (char *)end - (char *)start); +#elif defined (__GNUC__) + __builtin___clear_cache (start, end); +#else +#error "Missing builtin to flush instruction cache" +#endif +} + +/* A subroutine of is_vfp_type. Given a structure type, return the type code + of the first non-structure element. Recurse for structure elements. + Return -1 if the structure is in fact empty, i.e. no nested elements. */ + +static int +is_hfa0 (const ffi_type *ty) +{ + ffi_type **elements = ty->elements; + int i, ret = -1; + + if (elements != NULL) + for (i = 0; elements[i]; ++i) + { + ret = elements[i]->type; + if (ret == FFI_TYPE_STRUCT || ret == FFI_TYPE_COMPLEX) + { + ret = is_hfa0 (elements[i]); + if (ret < 0) + continue; + } + break; + } + + return ret; +} + +/* A subroutine of is_vfp_type. Given a structure type, return true if all + of the non-structure elements are the same as CANDIDATE. */ + +static int +is_hfa1 (const ffi_type *ty, int candidate) +{ + ffi_type **elements = ty->elements; + int i; + + if (elements != NULL) + for (i = 0; elements[i]; ++i) + { + int t = elements[i]->type; + if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) + { + if (!is_hfa1 (elements[i], candidate)) + return 0; + } + else if (t != candidate) + return 0; + } + + return 1; +} + +/* Determine if TY may be allocated to the FP registers. This is both an + fp scalar type as well as an homogenous floating point aggregate (HFA). + That is, a structure consisting of 1 to 4 members of all the same type, + where that type is an fp scalar. + + Returns non-zero iff TY is an HFA. The result is the AARCH64_RET_* + constant for the type. */ + +static int +is_vfp_type (const ffi_type *ty) +{ + ffi_type **elements; + int candidate, i; + size_t size, ele_count; + + /* Quickest tests first. */ + candidate = ty->type; + switch (candidate) + { + default: + return 0; + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + ele_count = 1; + goto done; + case FFI_TYPE_COMPLEX: + candidate = ty->elements[0]->type; + switch (candidate) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + ele_count = 2; + goto done; + } + return 0; + case FFI_TYPE_STRUCT: + break; + } + + /* No HFA types are smaller than 4 bytes, or larger than 64 bytes. */ + size = ty->size; + if (size < 4 || size > 64) + return 0; + + /* Find the type of the first non-structure member. */ + elements = ty->elements; + candidate = elements[0]->type; + if (candidate == FFI_TYPE_STRUCT || candidate == FFI_TYPE_COMPLEX) + { + for (i = 0; ; ++i) + { + candidate = is_hfa0 (elements[i]); + if (candidate >= 0) + break; + } + } + + /* If the first member is not a floating point type, it's not an HFA. + Also quickly re-check the size of the structure. */ + switch (candidate) + { + case FFI_TYPE_FLOAT: + ele_count = size / sizeof(float); + if (size != ele_count * sizeof(float)) + return 0; + break; + case FFI_TYPE_DOUBLE: + ele_count = size / sizeof(double); + if (size != ele_count * sizeof(double)) + return 0; + break; + case FFI_TYPE_LONGDOUBLE: + ele_count = size / sizeof(long double); + if (size != ele_count * sizeof(long double)) + return 0; + break; + default: + return 0; + } + if (ele_count > 4) + return 0; + + /* Finally, make sure that all scalar elements are the same type. */ + for (i = 0; elements[i]; ++i) + { + int t = elements[i]->type; + if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) + { + if (!is_hfa1 (elements[i], candidate)) + return 0; + } + else if (t != candidate) + return 0; + } + + /* All tests succeeded. Encode the result. */ + done: + return candidate * 4 + (4 - ele_count); +} + +/* Representation of the procedure call argument marshalling + state. + + The terse state variable names match the names used in the AARCH64 + PCS. */ + +struct arg_state +{ + unsigned ngrn; /* Next general-purpose register number. */ + unsigned nsrn; /* Next vector register number. */ + size_t nsaa; /* Next stack offset. */ + +#if defined (__APPLE__) + unsigned allocating_variadic; +#endif +}; + +/* Initialize a procedure call argument marshalling state. */ +static void +arg_init (struct arg_state *state) +{ + state->ngrn = 0; + state->nsrn = 0; + state->nsaa = 0; +#if defined (__APPLE__) + state->allocating_variadic = 0; +#endif +} + +/* Allocate an aligned slot on the stack and return a pointer to it. */ +static void * +allocate_to_stack (struct arg_state *state, void *stack, + size_t alignment, size_t size) +{ + size_t nsaa = state->nsaa; + + /* Round up the NSAA to the larger of 8 or the natural + alignment of the argument's type. */ +#if defined (__APPLE__) + if (state->allocating_variadic && alignment < 8) + alignment = 8; +#else + if (alignment < 8) + alignment = 8; +#endif + + nsaa = ALIGN (nsaa, alignment); + state->nsaa = nsaa + size; + + return (char *)stack + nsaa; +} + +static ffi_arg +extend_integer_type (void *source, int type) +{ + switch (type) + { + case FFI_TYPE_UINT8: + return *(UINT8 *) source; + case FFI_TYPE_SINT8: + return *(SINT8 *) source; + case FFI_TYPE_UINT16: + return *(UINT16 *) source; + case FFI_TYPE_SINT16: + return *(SINT16 *) source; + case FFI_TYPE_UINT32: + return *(UINT32 *) source; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + return *(SINT32 *) source; + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + return *(UINT64 *) source; + break; + case FFI_TYPE_POINTER: + return *(uintptr_t *) source; + default: + abort(); + } +} + +static void +extend_hfa_type (void *dest, void *src, int h) +{ + int f = h - AARCH64_RET_S4; + void *x0; + + asm volatile ( + "adr %0, 0f\n" +" add %0, %0, %1\n" +" br %0\n" +"0: ldp s16, s17, [%3]\n" /* S4 */ +" ldp s18, s19, [%3, #8]\n" +" b 4f\n" +" ldp s16, s17, [%3]\n" /* S3 */ +" ldr s18, [%3, #8]\n" +" b 3f\n" +" ldp s16, s17, [%3]\n" /* S2 */ +" b 2f\n" +" nop\n" +" ldr s16, [%3]\n" /* S1 */ +" b 1f\n" +" nop\n" +" ldp d16, d17, [%3]\n" /* D4 */ +" ldp d18, d19, [%3, #16]\n" +" b 4f\n" +" ldp d16, d17, [%3]\n" /* D3 */ +" ldr d18, [%3, #16]\n" +" b 3f\n" +" ldp d16, d17, [%3]\n" /* D2 */ +" b 2f\n" +" nop\n" +" ldr d16, [%3]\n" /* D1 */ +" b 1f\n" +" nop\n" +" ldp q16, q17, [%3]\n" /* Q4 */ +" ldp q18, q19, [%3, #16]\n" +" b 4f\n" +" ldp q16, q17, [%3]\n" /* Q3 */ +" ldr q18, [%3, #16]\n" +" b 3f\n" +" ldp q16, q17, [%3]\n" /* Q2 */ +" b 2f\n" +" nop\n" +" ldr q16, [%3]\n" /* Q1 */ +" b 1f\n" +"4: str q19, [%2, #48]\n" +"3: str q18, [%2, #32]\n" +"2: str q17, [%2, #16]\n" +"1: str q16, [%2]" + : "=&r"(x0) + : "r"(f * 12), "r"(dest), "r"(src) + : "memory", "v16", "v17", "v18", "v19"); +} + +static void * +compress_hfa_type (void *dest, void *reg, int h) +{ + switch (h) + { + case AARCH64_RET_S1: + if (dest == reg) + { +#ifdef __AARCH64EB__ + dest += 12; +#endif + } + else + *(float *)dest = *(float *)reg; + break; + case AARCH64_RET_S2: + asm ("ldp q16, q17, [%1]\n\t" + "st2 { v16.s, v17.s }[0], [%0]" + : : "r"(dest), "r"(reg) : "memory", "v16", "v17"); + break; + case AARCH64_RET_S3: + asm ("ldp q16, q17, [%1]\n\t" + "ldr q18, [%1, #32]\n\t" + "st3 { v16.s, v17.s, v18.s }[0], [%0]" + : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18"); + break; + case AARCH64_RET_S4: + asm ("ldp q16, q17, [%1]\n\t" + "ldp q18, q19, [%1, #32]\n\t" + "st4 { v16.s, v17.s, v18.s, v19.s }[0], [%0]" + : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18", "v19"); + break; + + case AARCH64_RET_D1: + if (dest == reg) + { +#ifdef __AARCH64EB__ + dest += 8; +#endif + } + else + *(double *)dest = *(double *)reg; + break; + case AARCH64_RET_D2: + asm ("ldp q16, q17, [%1]\n\t" + "st2 { v16.d, v17.d }[0], [%0]" + : : "r"(dest), "r"(reg) : "memory", "v16", "v17"); + break; + case AARCH64_RET_D3: + asm ("ldp q16, q17, [%1]\n\t" + "ldr q18, [%1, #32]\n\t" + "st3 { v16.d, v17.d, v18.d }[0], [%0]" + : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18"); + break; + case AARCH64_RET_D4: + asm ("ldp q16, q17, [%1]\n\t" + "ldp q18, q19, [%1, #32]\n\t" + "st4 { v16.d, v17.d, v18.d, v19.d }[0], [%0]" + : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18", "v19"); + break; + + default: + if (dest != reg) + return memcpy (dest, reg, 16 * (4 - (h & 3))); + break; + } + return dest; +} + +/* Either allocate an appropriate register for the argument type, or if + none are available, allocate a stack slot and return a pointer + to the allocated space. */ + +static void * +allocate_int_to_reg_or_stack (struct call_context *context, + struct arg_state *state, + void *stack, size_t size) +{ + if (state->ngrn < N_X_ARG_REG) + return &context->x[state->ngrn++]; + + state->ngrn = N_X_ARG_REG; + return allocate_to_stack (state, stack, size, size); +} + +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + ffi_type *rtype = cif->rtype; + size_t bytes = cif->bytes; + int flags, i, n; + + switch (rtype->type) + { + case FFI_TYPE_VOID: + flags = AARCH64_RET_VOID; + break; + case FFI_TYPE_UINT8: + flags = AARCH64_RET_UINT8; + break; + case FFI_TYPE_UINT16: + flags = AARCH64_RET_UINT16; + break; + case FFI_TYPE_UINT32: + flags = AARCH64_RET_UINT32; + break; + case FFI_TYPE_SINT8: + flags = AARCH64_RET_SINT8; + break; + case FFI_TYPE_SINT16: + flags = AARCH64_RET_SINT16; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + flags = AARCH64_RET_SINT32; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + flags = AARCH64_RET_INT64; + break; + case FFI_TYPE_POINTER: + flags = (sizeof(void *) == 4 ? AARCH64_RET_UINT32 : AARCH64_RET_INT64); + break; + + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: + flags = is_vfp_type (rtype); + if (flags == 0) + { + size_t s = rtype->size; + if (s > 16) + { + flags = AARCH64_RET_VOID | AARCH64_RET_IN_MEM; + bytes += 8; + } + else if (s == 16) + flags = AARCH64_RET_INT128; + else if (s == 8) + flags = AARCH64_RET_INT64; + else + flags = AARCH64_RET_INT128 | AARCH64_RET_NEED_COPY; + } + break; + + default: + abort(); + } + + for (i = 0, n = cif->nargs; i < n; i++) + if (is_vfp_type (cif->arg_types[i])) + { + flags |= AARCH64_FLAG_ARG_V; + break; + } + + /* Round the stack up to a multiple of the stack alignment requirement. */ + cif->bytes = ALIGN(bytes, 16); + cif->flags = flags; +#if defined (__APPLE__) + cif->aarch64_nfixedargs = 0; +#endif + + return FFI_OK; +} + +#if defined (__APPLE__) +/* Perform Apple-specific cif processing for variadic calls */ +ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, + unsigned int nfixedargs, + unsigned int ntotalargs) +{ + ffi_status status = ffi_prep_cif_machdep (cif); + cif->aarch64_nfixedargs = nfixedargs; + return status; +} +#endif /* __APPLE__ */ + +extern void ffi_call_SYSV (struct call_context *context, void *frame, + void (*fn)(void), void *rvalue, int flags, + void *closure) FFI_HIDDEN; + +/* Call a function with the provided arguments and capture the return + value. */ +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, + void **avalue, void *closure) +{ + struct call_context *context; + void *stack, *frame, *rvalue; + struct arg_state state; + size_t stack_bytes, rtype_size, rsize; + int i, nargs, flags; + ffi_type *rtype; + + flags = cif->flags; + rtype = cif->rtype; + rtype_size = rtype->size; + stack_bytes = cif->bytes; + + /* If the target function returns a structure via hidden pointer, + then we cannot allow a null rvalue. Otherwise, mash a null + rvalue to void return type. */ + rsize = 0; + if (flags & AARCH64_RET_IN_MEM) + { + if (orig_rvalue == NULL) + rsize = rtype_size; + } + else if (orig_rvalue == NULL) + flags &= AARCH64_FLAG_ARG_V; + else if (flags & AARCH64_RET_NEED_COPY) + rsize = 16; + + /* Allocate consectutive stack for everything we'll need. */ + context = alloca (sizeof(struct call_context) + stack_bytes + 32 + rsize); + stack = context + 1; + frame = stack + stack_bytes; + rvalue = (rsize ? frame + 32 : orig_rvalue); + + arg_init (&state); + for (i = 0, nargs = cif->nargs; i < nargs; i++) + { + ffi_type *ty = cif->arg_types[i]; + size_t s = ty->size; + void *a = avalue[i]; + int h, t; + + t = ty->type; + switch (t) + { + case FFI_TYPE_VOID: + FFI_ASSERT (0); + break; + + /* If the argument is a basic type the argument is allocated to an + appropriate register, or if none are available, to the stack. */ + case FFI_TYPE_INT: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + do_pointer: + { + ffi_arg ext = extend_integer_type (a, t); + if (state.ngrn < N_X_ARG_REG) + context->x[state.ngrn++] = ext; + else + { + void *d = allocate_to_stack (&state, stack, ty->alignment, s); + state.ngrn = N_X_ARG_REG; + /* Note that the default abi extends each argument + to a full 64-bit slot, while the iOS abi allocates + only enough space. */ +#ifdef __APPLE__ + memcpy(d, a, s); +#else + *(ffi_arg *)d = ext; +#endif + } + } + break; + + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: + { + void *dest; + + h = is_vfp_type (ty); + if (h) + { + int elems = 4 - (h & 3); + if (state.nsrn + elems <= N_V_ARG_REG) + { + dest = &context->v[state.nsrn]; + state.nsrn += elems; + extend_hfa_type (dest, a, h); + break; + } + state.nsrn = N_V_ARG_REG; + dest = allocate_to_stack (&state, stack, ty->alignment, s); + } + else if (s > 16) + { + /* If the argument is a composite type that is larger than 16 + bytes, then the argument has been copied to memory, and + the argument is replaced by a pointer to the copy. */ + a = &avalue[i]; + t = FFI_TYPE_POINTER; + goto do_pointer; + } + else + { + size_t n = (s + 7) / 8; + if (state.ngrn + n <= N_X_ARG_REG) + { + /* If the argument is a composite type and the size in + double-words is not more than the number of available + X registers, then the argument is copied into + consecutive X registers. */ + dest = &context->x[state.ngrn]; + state.ngrn += n; + } + else + { + /* Otherwise, there are insufficient X registers. Further + X register allocations are prevented, the NSAA is + adjusted and the argument is copied to memory at the + adjusted NSAA. */ + state.ngrn = N_X_ARG_REG; + dest = allocate_to_stack (&state, stack, ty->alignment, s); + } + } + memcpy (dest, a, s); + } + break; + + default: + abort(); + } + +#if defined (__APPLE__) + if (i + 1 == cif->aarch64_nfixedargs) + { + state.ngrn = N_X_ARG_REG; + state.nsrn = N_V_ARG_REG; + state.allocating_variadic = 1; + } +#endif + } + + ffi_call_SYSV (context, frame, fn, rvalue, flags, closure); + + if (flags & AARCH64_RET_NEED_COPY) + memcpy (orig_rvalue, rvalue, rtype_size); +} + +void +ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +#ifdef FFI_GO_CLOSURES +void +ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} +#endif /* FFI_GO_CLOSURES */ + +/* Build a trampoline. */ + +extern void ffi_closure_SYSV (void) FFI_HIDDEN; +extern void ffi_closure_SYSV_V (void) FFI_HIDDEN; + +#if FFI_EXEC_TRAMPOLINE_TABLE + +#include +#include +#include +#include + +extern void *ffi_closure_trampoline_table_page; + +typedef struct ffi_trampoline_table ffi_trampoline_table; +typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry; + +struct ffi_trampoline_table +{ + /* contiguous writable and executable pages */ + vm_address_t config_page; + vm_address_t trampoline_page; + + /* free list tracking */ + uint16_t free_count; + ffi_trampoline_table_entry *free_list; + ffi_trampoline_table_entry *free_list_pool; + + ffi_trampoline_table *prev; + ffi_trampoline_table *next; +}; + +struct ffi_trampoline_table_entry +{ + void *(*trampoline) (); + ffi_trampoline_table_entry *next; +}; + +/* The trampoline configuration is placed a page prior to the trampoline's entry point */ +#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - PAGE_SIZE)); + +/* Total number of trampolines that fit in one trampoline table */ +#define FFI_TRAMPOLINE_COUNT (PAGE_SIZE / FFI_TRAMPOLINE_SIZE) + +static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER; +static ffi_trampoline_table *ffi_trampoline_tables = NULL; + +static ffi_trampoline_table * +ffi_trampoline_table_alloc () +{ + ffi_trampoline_table *table = NULL; + + /* Loop until we can allocate two contiguous pages */ + while (table == NULL) + { + vm_address_t config_page = 0x0; + kern_return_t kt; + + /* Try to allocate two pages */ + kt = + vm_allocate (mach_task_self (), &config_page, PAGE_SIZE * 2, + VM_FLAGS_ANYWHERE); + if (kt != KERN_SUCCESS) + { + fprintf (stderr, "vm_allocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + break; + } + + /* Now drop the second half of the allocation to make room for the trampoline table */ + vm_address_t trampoline_page = config_page + PAGE_SIZE; + kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE); + if (kt != KERN_SUCCESS) + { + fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + break; + } + + /* Remap the trampoline table to directly follow the config page */ + vm_prot_t cur_prot; + vm_prot_t max_prot; + + kt = + vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, + mach_task_self (), + (vm_address_t) & ffi_closure_trampoline_table_page, FALSE, + &cur_prot, &max_prot, VM_INHERIT_SHARE); + + /* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */ + if (kt != KERN_SUCCESS) + { + /* Log unexpected failures */ + if (kt != KERN_NO_SPACE) + { + fprintf (stderr, "vm_remap() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + } + + vm_deallocate (mach_task_self (), config_page, PAGE_SIZE); + continue; + } + + /* We have valid trampoline and config pages */ + table = calloc (1, sizeof (ffi_trampoline_table)); + table->free_count = FFI_TRAMPOLINE_COUNT; + table->config_page = config_page; + table->trampoline_page = trampoline_page; + + /* Create and initialize the free list */ + table->free_list_pool = + calloc (FFI_TRAMPOLINE_COUNT, sizeof (ffi_trampoline_table_entry)); + + uint16_t i; + for (i = 0; i < table->free_count; i++) + { + ffi_trampoline_table_entry *entry = &table->free_list_pool[i]; + entry->trampoline = + (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); + + if (i < table->free_count - 1) + entry->next = &table->free_list_pool[i + 1]; + } + + table->free_list = table->free_list_pool; + } + + return table; +} + +void * +ffi_closure_alloc (size_t size, void **code) +{ + /* Create the closure */ + ffi_closure *closure = malloc (size); + if (closure == NULL) + return NULL; + + pthread_mutex_lock (&ffi_trampoline_lock); + + /* Check for an active trampoline table with available entries. */ + ffi_trampoline_table *table = ffi_trampoline_tables; + if (table == NULL || table->free_list == NULL) + { + table = ffi_trampoline_table_alloc (); + if (table == NULL) + { + free (closure); + return NULL; + } + + /* Insert the new table at the top of the list */ + table->next = ffi_trampoline_tables; + if (table->next != NULL) + table->next->prev = table; + + ffi_trampoline_tables = table; + } + + /* Claim the free entry */ + ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list; + ffi_trampoline_tables->free_list = entry->next; + ffi_trampoline_tables->free_count--; + entry->next = NULL; + + pthread_mutex_unlock (&ffi_trampoline_lock); + + /* Initialize the return values */ + *code = entry->trampoline; + closure->trampoline_table = table; + closure->trampoline_table_entry = entry; + + return closure; +} + +void +ffi_closure_free (void *ptr) +{ + ffi_closure *closure = ptr; + + pthread_mutex_lock (&ffi_trampoline_lock); + + /* Fetch the table and entry references */ + ffi_trampoline_table *table = closure->trampoline_table; + ffi_trampoline_table_entry *entry = closure->trampoline_table_entry; + + /* Return the entry to the free list */ + entry->next = table->free_list; + table->free_list = entry; + table->free_count++; + + /* If all trampolines within this table are free, and at least one other table exists, deallocate + * the table */ + if (table->free_count == FFI_TRAMPOLINE_COUNT + && ffi_trampoline_tables != table) + { + /* Remove from the list */ + if (table->prev != NULL) + table->prev->next = table->next; + + if (table->next != NULL) + table->next->prev = table->prev; + + /* Deallocate pages */ + kern_return_t kt; + kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE); + if (kt != KERN_SUCCESS) + fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + + kt = + vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE); + if (kt != KERN_SUCCESS) + fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + + /* Deallocate free list */ + free (table->free_list_pool); + free (table); + } + else if (ffi_trampoline_tables != table) + { + /* Otherwise, bump this table to the top of the list */ + table->prev = NULL; + table->next = ffi_trampoline_tables; + if (ffi_trampoline_tables != NULL) + ffi_trampoline_tables->prev = table; + + ffi_trampoline_tables = table; + } + + pthread_mutex_unlock (&ffi_trampoline_lock); + + /* Free the closure */ + free (closure); +} + +#endif + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + void (*start)(void); + + if (cif->flags & AARCH64_FLAG_ARG_V) + start = ffi_closure_SYSV_V; + else + start = ffi_closure_SYSV; + +#if FFI_EXEC_TRAMPOLINE_TABLE + void **config = FFI_TRAMPOLINE_CODELOC_CONFIG (codeloc); + config[0] = closure; + config[1] = start; +#else + static const unsigned char trampoline[16] = { + 0x90, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */ + 0xf1, 0xff, 0xff, 0x10, /* adr x17, tramp+0 */ + 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ + }; + char *tramp = closure->tramp; + + memcpy (tramp, trampoline, sizeof(trampoline)); + + *(UINT64 *)(tramp + 16) = (uintptr_t)start; + + ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE); +#endif + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +#ifdef FFI_GO_CLOSURES +extern void ffi_go_closure_SYSV (void) FFI_HIDDEN; +extern void ffi_go_closure_SYSV_V (void) FFI_HIDDEN; + +ffi_status +ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*)) +{ + void (*start)(void); + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + if (cif->flags & AARCH64_FLAG_ARG_V) + start = ffi_go_closure_SYSV_V; + else + start = ffi_go_closure_SYSV; + + closure->tramp = start; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} +#endif /* FFI_GO_CLOSURES */ + +/* Primary handler to setup and invoke a function within a closure. + + A closure when invoked enters via the assembler wrapper + ffi_closure_SYSV(). The wrapper allocates a call context on the + stack, saves the interesting registers (from the perspective of + the calling convention) into the context then passes control to + ffi_closure_SYSV_inner() passing the saved context and a pointer to + the stack at the point ffi_closure_SYSV() was invoked. + + On the return path the assembler wrapper will reload call context + registers. + + ffi_closure_SYSV_inner() marshalls the call context into ffi value + descriptors, invokes the wrapped function, then marshalls the return + value back into the call context. */ + +int FFI_HIDDEN +ffi_closure_SYSV_inner (ffi_cif *cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + struct call_context *context, + void *stack, void *rvalue, void *struct_rvalue) +{ + void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); + int i, h, nargs, flags; + struct arg_state state; + + arg_init (&state); + + for (i = 0, nargs = cif->nargs; i < nargs; i++) + { + ffi_type *ty = cif->arg_types[i]; + int t = ty->type; + size_t n, s = ty->size; + + switch (t) + { + case FFI_TYPE_VOID: + FFI_ASSERT (0); + break; + + case FFI_TYPE_INT: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + avalue[i] = allocate_int_to_reg_or_stack (context, &state, stack, s); + break; + + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: + h = is_vfp_type (ty); + if (h) + { + n = 4 - (h & 3); + if (state.nsrn + n <= N_V_ARG_REG) + { + void *reg = &context->v[state.nsrn]; + state.nsrn += n; + + /* Eeek! We need a pointer to the structure, however the + homogeneous float elements are being passed in individual + registers, therefore for float and double the structure + is not represented as a contiguous sequence of bytes in + our saved register context. We don't need the original + contents of the register storage, so we reformat the + structure into the same memory. */ + avalue[i] = compress_hfa_type (reg, reg, h); + } + else + { + state.nsrn = N_V_ARG_REG; + avalue[i] = allocate_to_stack (&state, stack, + ty->alignment, s); + } + } + else if (s > 16) + { + /* Replace Composite type of size greater than 16 with a + pointer. */ + avalue[i] = *(void **) + allocate_int_to_reg_or_stack (context, &state, stack, + sizeof (void *)); + } + else + { + n = (s + 7) / 8; + if (state.ngrn + n <= N_X_ARG_REG) + { + avalue[i] = &context->x[state.ngrn]; + state.ngrn += n; + } + else + { + state.ngrn = N_X_ARG_REG; + avalue[i] = allocate_to_stack (&state, stack, + ty->alignment, s); + } + } + break; + + default: + abort(); + } + } + + flags = cif->flags; + if (flags & AARCH64_RET_IN_MEM) + rvalue = struct_rvalue; + + fun (cif, rvalue, avalue, user_data); + + return flags; +} diff --git a/user/mpy/lib/libffi/src/aarch64/ffitarget.h b/user/mpy/lib/libffi/src/aarch64/ffitarget.h new file mode 100644 index 0000000..2862ec7 --- /dev/null +++ b/user/mpy/lib/libffi/src/aarch64/ffitarget.h @@ -0,0 +1,73 @@ +/* Copyright (c) 2009, 2010, 2011, 2012 ARM 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +#ifdef __ILP32__ +#define FFI_SIZEOF_ARG 8 +typedef unsigned long long ffi_arg; +typedef signed long long ffi_sarg; +#else +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; +#endif + +typedef enum ffi_abi + { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV + } ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#if defined (__APPLE__) +#define FFI_TRAMPOLINE_SIZE 20 +#define FFI_TRAMPOLINE_CLOSURE_OFFSET 16 +#else +#define FFI_TRAMPOLINE_SIZE 24 +#define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE +#endif +#define FFI_NATIVE_RAW_API 0 + +/* ---- Internal ---- */ + +#if defined (__APPLE__) +#define FFI_TARGET_SPECIFIC_VARIADIC +#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs +#else +/* iOS reserves x18 for the system. Disable Go closures until + a new static chain is chosen. */ +#define FFI_GO_CLOSURES 1 +#endif + +#define FFI_TARGET_HAS_COMPLEX_TYPE + +#endif diff --git a/user/mpy/lib/libffi/src/aarch64/internal.h b/user/mpy/lib/libffi/src/aarch64/internal.h new file mode 100644 index 0000000..9c3e077 --- /dev/null +++ b/user/mpy/lib/libffi/src/aarch64/internal.h @@ -0,0 +1,67 @@ +/* +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. */ + +#define AARCH64_RET_VOID 0 +#define AARCH64_RET_INT64 1 +#define AARCH64_RET_INT128 2 + +#define AARCH64_RET_UNUSED3 3 +#define AARCH64_RET_UNUSED4 4 +#define AARCH64_RET_UNUSED5 5 +#define AARCH64_RET_UNUSED6 6 +#define AARCH64_RET_UNUSED7 7 + +/* Note that FFI_TYPE_FLOAT == 2, _DOUBLE == 3, _LONGDOUBLE == 4, + so _S4 through _Q1 are layed out as (TYPE * 4) + (4 - COUNT). */ +#define AARCH64_RET_S4 8 +#define AARCH64_RET_S3 9 +#define AARCH64_RET_S2 10 +#define AARCH64_RET_S1 11 + +#define AARCH64_RET_D4 12 +#define AARCH64_RET_D3 13 +#define AARCH64_RET_D2 14 +#define AARCH64_RET_D1 15 + +#define AARCH64_RET_Q4 16 +#define AARCH64_RET_Q3 17 +#define AARCH64_RET_Q2 18 +#define AARCH64_RET_Q1 19 + +/* Note that each of the sub-64-bit integers gets two entries. */ +#define AARCH64_RET_UINT8 20 +#define AARCH64_RET_UINT16 22 +#define AARCH64_RET_UINT32 24 + +#define AARCH64_RET_SINT8 26 +#define AARCH64_RET_SINT16 28 +#define AARCH64_RET_SINT32 30 + +#define AARCH64_RET_MASK 31 + +#define AARCH64_RET_IN_MEM (1 << 5) +#define AARCH64_RET_NEED_COPY (1 << 6) + +#define AARCH64_FLAG_ARG_V_BIT 7 +#define AARCH64_FLAG_ARG_V (1 << AARCH64_FLAG_ARG_V_BIT) + +#define N_X_ARG_REG 8 +#define N_V_ARG_REG 8 +#define CALL_CONTEXT_SIZE (N_V_ARG_REG * 16 + N_X_ARG_REG * 8) diff --git a/user/mpy/lib/libffi/src/aarch64/sysv.S b/user/mpy/lib/libffi/src/aarch64/sysv.S new file mode 100644 index 0000000..c1bf9b9 --- /dev/null +++ b/user/mpy/lib/libffi/src/aarch64/sysv.S @@ -0,0 +1,434 @@ +/* Copyright (c) 2009, 2010, 2011, 2012 ARM 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. */ + +#define LIBFFI_ASM +#include +#include +#include +#include "internal.h" + +#ifdef HAVE_MACHINE_ASM_H +#include +#else +#ifdef __USER_LABEL_PREFIX__ +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +/* Use the right prefix for global labels. */ +#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x) +#else +#define CNAME(x) x +#endif +#endif + +#ifdef __AARCH64EB__ +# define BE(X) X +#else +# define BE(X) 0 +#endif + +#ifdef __ILP32__ +#define PTR_REG(n) w##n +#else +#define PTR_REG(n) x##n +#endif + +#ifdef __ILP32__ +#define PTR_SIZE 4 +#else +#define PTR_SIZE 8 +#endif + + .text + .align 4 + +/* ffi_call_SYSV + extern void ffi_call_SYSV (void *stack, void *frame, + void (*fn)(void), void *rvalue, + int flags, void *closure); + + Therefore on entry we have: + + x0 stack + x1 frame + x2 fn + x3 rvalue + x4 flags + x5 closure +*/ + + cfi_startproc +CNAME(ffi_call_SYSV): + /* Use a stack frame allocated by our caller. */ + cfi_def_cfa(x1, 32); + stp x29, x30, [x1] + mov x29, x1 + mov sp, x0 + cfi_def_cfa_register(x29) + cfi_rel_offset (x29, 0) + cfi_rel_offset (x30, 8) + + mov x9, x2 /* save fn */ + mov x8, x3 /* install structure return */ +#ifdef FFI_GO_CLOSURES + mov x18, x5 /* install static chain */ +#endif + stp x3, x4, [x29, #16] /* save rvalue and flags */ + + /* Load the vector argument passing registers, if necessary. */ + tbz w4, #AARCH64_FLAG_ARG_V_BIT, 1f + ldp q0, q1, [sp, #0] + ldp q2, q3, [sp, #32] + ldp q4, q5, [sp, #64] + ldp q6, q7, [sp, #96] +1: + /* Load the core argument passing registers, including + the structure return pointer. */ + ldp x0, x1, [sp, #16*N_V_ARG_REG + 0] + ldp x2, x3, [sp, #16*N_V_ARG_REG + 16] + ldp x4, x5, [sp, #16*N_V_ARG_REG + 32] + ldp x6, x7, [sp, #16*N_V_ARG_REG + 48] + + /* Deallocate the context, leaving the stacked arguments. */ + add sp, sp, #CALL_CONTEXT_SIZE + + blr x9 /* call fn */ + + ldp x3, x4, [x29, #16] /* reload rvalue and flags */ + + /* Partially deconstruct the stack frame. */ + mov sp, x29 + cfi_def_cfa_register (sp) + ldp x29, x30, [x29] + + /* Save the return value as directed. */ + adr x5, 0f + and w4, w4, #AARCH64_RET_MASK + add x5, x5, x4, lsl #3 + br x5 + + /* Note that each table entry is 2 insns, and thus 8 bytes. + For integer data, note that we're storing into ffi_arg + and therefore we want to extend to 64 bits; these types + have two consecutive entries allocated for them. */ + .align 4 +0: ret /* VOID */ + nop +1: str x0, [x3] /* INT64 */ + ret +2: stp x0, x1, [x3] /* INT128 */ + ret +3: brk #1000 /* UNUSED */ + ret +4: brk #1000 /* UNUSED */ + ret +5: brk #1000 /* UNUSED */ + ret +6: brk #1000 /* UNUSED */ + ret +7: brk #1000 /* UNUSED */ + ret +8: st4 { v0.s, v1.s, v2.s, v3.s }[0], [x3] /* S4 */ + ret +9: st3 { v0.s, v1.s, v2.s }[0], [x3] /* S3 */ + ret +10: stp s0, s1, [x3] /* S2 */ + ret +11: str s0, [x3] /* S1 */ + ret +12: st4 { v0.d, v1.d, v2.d, v3.d }[0], [x3] /* D4 */ + ret +13: st3 { v0.d, v1.d, v2.d }[0], [x3] /* D3 */ + ret +14: stp d0, d1, [x3] /* D2 */ + ret +15: str d0, [x3] /* D1 */ + ret +16: str q3, [x3, #48] /* Q4 */ + nop +17: str q2, [x3, #32] /* Q3 */ + nop +18: stp q0, q1, [x3] /* Q2 */ + ret +19: str q0, [x3] /* Q1 */ + ret +20: uxtb w0, w0 /* UINT8 */ + str x0, [x3] +21: ret /* reserved */ + nop +22: uxth w0, w0 /* UINT16 */ + str x0, [x3] +23: ret /* reserved */ + nop +24: mov w0, w0 /* UINT32 */ + str x0, [x3] +25: ret /* reserved */ + nop +26: sxtb x0, w0 /* SINT8 */ + str x0, [x3] +27: ret /* reserved */ + nop +28: sxth x0, w0 /* SINT16 */ + str x0, [x3] +29: ret /* reserved */ + nop +30: sxtw x0, w0 /* SINT32 */ + str x0, [x3] +31: ret /* reserved */ + nop + + cfi_endproc + + .globl CNAME(ffi_call_SYSV) +#ifdef __ELF__ + .type CNAME(ffi_call_SYSV), #function + .hidden CNAME(ffi_call_SYSV) + .size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV) +#endif + +/* ffi_closure_SYSV + + Closure invocation glue. This is the low level code invoked directly by + the closure trampoline to setup and call a closure. + + On entry x17 points to a struct ffi_closure, x16 has been clobbered + all other registers are preserved. + + We allocate a call context and save the argument passing registers, + then invoked the generic C ffi_closure_SYSV_inner() function to do all + the real work, on return we load the result passing registers back from + the call context. +*/ + +#define ffi_closure_SYSV_FS (8*2 + CALL_CONTEXT_SIZE + 64) + + .align 4 +CNAME(ffi_closure_SYSV_V): + cfi_startproc + stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! + cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) + cfi_rel_offset (x29, 0) + cfi_rel_offset (x30, 8) + + /* Save the argument passing vector registers. */ + stp q0, q1, [sp, #16 + 0] + stp q2, q3, [sp, #16 + 32] + stp q4, q5, [sp, #16 + 64] + stp q6, q7, [sp, #16 + 96] + b 0f + cfi_endproc + + .globl CNAME(ffi_closure_SYSV_V) +#ifdef __ELF__ + .type CNAME(ffi_closure_SYSV_V), #function + .hidden CNAME(ffi_closure_SYSV_V) + .size CNAME(ffi_closure_SYSV_V), . - CNAME(ffi_closure_SYSV_V) +#endif + + .align 4 + cfi_startproc +CNAME(ffi_closure_SYSV): + stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! + cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) + cfi_rel_offset (x29, 0) + cfi_rel_offset (x30, 8) +0: + mov x29, sp + + /* Save the argument passing core registers. */ + stp x0, x1, [sp, #16 + 16*N_V_ARG_REG + 0] + stp x2, x3, [sp, #16 + 16*N_V_ARG_REG + 16] + stp x4, x5, [sp, #16 + 16*N_V_ARG_REG + 32] + stp x6, x7, [sp, #16 + 16*N_V_ARG_REG + 48] + + /* Load ffi_closure_inner arguments. */ + ldp PTR_REG(0), PTR_REG(1), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET] /* load cif, fn */ + ldr PTR_REG(2), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+PTR_SIZE*2] /* load user_data */ +.Ldo_closure: + add x3, sp, #16 /* load context */ + add x4, sp, #ffi_closure_SYSV_FS /* load stack */ + add x5, sp, #16+CALL_CONTEXT_SIZE /* load rvalue */ + mov x6, x8 /* load struct_rval */ + bl CNAME(ffi_closure_SYSV_inner) + + /* Load the return value as directed. */ + adr x1, 0f + and w0, w0, #AARCH64_RET_MASK + add x1, x1, x0, lsl #3 + add x3, sp, #16+CALL_CONTEXT_SIZE + br x1 + + /* Note that each table entry is 2 insns, and thus 8 bytes. */ + .align 4 +0: b 99f /* VOID */ + nop +1: ldr x0, [x3] /* INT64 */ + b 99f +2: ldp x0, x1, [x3] /* INT128 */ + b 99f +3: brk #1000 /* UNUSED */ + nop +4: brk #1000 /* UNUSED */ + nop +5: brk #1000 /* UNUSED */ + nop +6: brk #1000 /* UNUSED */ + nop +7: brk #1000 /* UNUSED */ + nop +8: ldr s3, [x3, #12] /* S4 */ + nop +9: ldr s2, [x2, #8] /* S3 */ + nop +10: ldp s0, s1, [x3] /* S2 */ + b 99f +11: ldr s0, [x3] /* S1 */ + b 99f +12: ldr d3, [x3, #24] /* D4 */ + nop +13: ldr d2, [x3, #16] /* D3 */ + nop +14: ldp d0, d1, [x3] /* D2 */ + b 99f +15: ldr d0, [x3] /* D1 */ + b 99f +16: ldr q3, [x3, #48] /* Q4 */ + nop +17: ldr q2, [x3, #32] /* Q3 */ + nop +18: ldp q0, q1, [x3] /* Q2 */ + b 99f +19: ldr q0, [x3] /* Q1 */ + b 99f +20: ldrb w0, [x3, #BE(7)] /* UINT8 */ + b 99f +21: brk #1000 /* reserved */ + nop +22: ldrh w0, [x3, #BE(6)] /* UINT16 */ + b 99f +23: brk #1000 /* reserved */ + nop +24: ldr w0, [x3, #BE(4)] /* UINT32 */ + b 99f +25: brk #1000 /* reserved */ + nop +26: ldrsb x0, [x3, #BE(7)] /* SINT8 */ + b 99f +27: brk #1000 /* reserved */ + nop +28: ldrsh x0, [x3, #BE(6)] /* SINT16 */ + b 99f +29: brk #1000 /* reserved */ + nop +30: ldrsw x0, [x3, #BE(4)] /* SINT32 */ + nop +31: /* reserved */ +99: ldp x29, x30, [sp], #ffi_closure_SYSV_FS + cfi_adjust_cfa_offset (-ffi_closure_SYSV_FS) + cfi_restore (x29) + cfi_restore (x30) + ret + cfi_endproc + + .globl CNAME(ffi_closure_SYSV) +#ifdef __ELF__ + .type CNAME(ffi_closure_SYSV), #function + .hidden CNAME(ffi_closure_SYSV) + .size CNAME(ffi_closure_SYSV), . - CNAME(ffi_closure_SYSV) +#endif + +#if FFI_EXEC_TRAMPOLINE_TABLE + .align 12 +CNAME(ffi_closure_trampoline_table_page): + .rept 16384 / FFI_TRAMPOLINE_SIZE + adr x17, -16384 + adr x16, -16380 + ldr x16, [x16] + ldr x17, [x17] + br x16 + .endr + + .globl CNAME(ffi_closure_trampoline_table_page) + #ifdef __ELF__ + .type CNAME(ffi_closure_trampoline_table_page), #function + .hidden CNAME(ffi_closure_trampoline_table_page) + .size CNAME(ffi_closure_trampoline_table_page), . - CNAME(ffi_closure_trampoline_table_page) + #endif +#endif + +#ifdef FFI_GO_CLOSURES + .align 4 +CNAME(ffi_go_closure_SYSV_V): + cfi_startproc + stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! + cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) + cfi_rel_offset (x29, 0) + cfi_rel_offset (x30, 8) + + /* Save the argument passing vector registers. */ + stp q0, q1, [sp, #16 + 0] + stp q2, q3, [sp, #16 + 32] + stp q4, q5, [sp, #16 + 64] + stp q6, q7, [sp, #16 + 96] + b 0f + cfi_endproc + + .globl CNAME(ffi_go_closure_SYSV_V) +#ifdef __ELF__ + .type CNAME(ffi_go_closure_SYSV_V), #function + .hidden CNAME(ffi_go_closure_SYSV_V) + .size CNAME(ffi_go_closure_SYSV_V), . - CNAME(ffi_go_closure_SYSV_V) +#endif + + .align 4 + cfi_startproc +CNAME(ffi_go_closure_SYSV): + stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! + cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) + cfi_rel_offset (x29, 0) + cfi_rel_offset (x30, 8) +0: + mov x29, sp + + /* Save the argument passing core registers. */ + stp x0, x1, [sp, #16 + 16*N_V_ARG_REG + 0] + stp x2, x3, [sp, #16 + 16*N_V_ARG_REG + 16] + stp x4, x5, [sp, #16 + 16*N_V_ARG_REG + 32] + stp x6, x7, [sp, #16 + 16*N_V_ARG_REG + 48] + + /* Load ffi_closure_inner arguments. */ + ldp PTR_REG(0), PTR_REG(1), [x18, #PTR_SIZE]/* load cif, fn */ + mov x2, x18 /* load user_data */ + b .Ldo_closure + cfi_endproc + + .globl CNAME(ffi_go_closure_SYSV) +#ifdef __ELF__ + .type CNAME(ffi_go_closure_SYSV), #function + .hidden CNAME(ffi_go_closure_SYSV) + .size CNAME(ffi_go_closure_SYSV), . - CNAME(ffi_go_closure_SYSV) +#endif +#endif /* FFI_GO_CLOSURES */ + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",%progbits +#endif + diff --git a/user/mpy/lib/libffi/src/alpha/ffi.c b/user/mpy/lib/libffi/src/alpha/ffi.c new file mode 100644 index 0000000..efae4cc --- /dev/null +++ b/user/mpy/lib/libffi/src/alpha/ffi.c @@ -0,0 +1,521 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2012 Anthony Green + Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc. + + Alpha Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include "internal.h" + +/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; + all further uses in this file will refer to the 128-bit type. */ +#if defined(__LONG_DOUBLE_128__) +# if FFI_TYPE_LONGDOUBLE != 4 +# error FFI_TYPE_LONGDOUBLE out of date +# endif +#else +# undef FFI_TYPE_LONGDOUBLE +# define FFI_TYPE_LONGDOUBLE 4 +#endif + +extern void ffi_call_osf(void *stack, void *frame, unsigned flags, + void *raddr, void (*fn)(void), void *closure) + FFI_HIDDEN; +extern void ffi_closure_osf(void) FFI_HIDDEN; +extern void ffi_go_closure_osf(void) FFI_HIDDEN; + +/* Promote a float value to its in-register double representation. + Unlike actually casting to double, this does not trap on NaN. */ +static inline UINT64 lds(void *ptr) +{ + UINT64 ret; + asm("lds %0,%1" : "=f"(ret) : "m"(*(UINT32 *)ptr)); + return ret; +} + +/* And the reverse. */ +static inline void sts(void *ptr, UINT64 val) +{ + asm("sts %1,%0" : "=m"(*(UINT32 *)ptr) : "f"(val)); +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep(ffi_cif *cif) +{ + size_t bytes = 0; + int flags, i, avn; + ffi_type *rtype, *itype; + + if (cif->abi != FFI_OSF) + return FFI_BAD_ABI; + + /* Compute the size of the argument area. */ + for (i = 0, avn = cif->nargs; i < avn; i++) + { + itype = cif->arg_types[i]; + switch (itype->type) + { + case FFI_TYPE_INT: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + /* All take one 8 byte slot. */ + bytes += 8; + break; + + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + /* Passed by value in N slots. */ + bytes += ALIGN(itype->size, FFI_SIZEOF_ARG); + break; + + case FFI_TYPE_COMPLEX: + /* _Complex long double passed by reference; others in 2 slots. */ + if (itype->elements[0]->type == FFI_TYPE_LONGDOUBLE) + bytes += 8; + else + bytes += 16; + break; + + default: + abort(); + } + } + + /* Set the return type flag */ + rtype = cif->rtype; + switch (rtype->type) + { + case FFI_TYPE_VOID: + flags = ALPHA_FLAGS(ALPHA_ST_VOID, ALPHA_LD_VOID); + break; + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT32); + break; + case FFI_TYPE_FLOAT: + flags = ALPHA_FLAGS(ALPHA_ST_FLOAT, ALPHA_LD_FLOAT); + break; + case FFI_TYPE_DOUBLE: + flags = ALPHA_FLAGS(ALPHA_ST_DOUBLE, ALPHA_LD_DOUBLE); + break; + case FFI_TYPE_UINT8: + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_UINT8); + break; + case FFI_TYPE_SINT8: + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_SINT8); + break; + case FFI_TYPE_UINT16: + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_UINT16); + break; + case FFI_TYPE_SINT16: + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_SINT16); + break; + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT64); + break; + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_STRUCT: + /* Passed in memory, with a hidden pointer. */ + flags = ALPHA_RET_IN_MEM; + break; + case FFI_TYPE_COMPLEX: + itype = rtype->elements[0]; + switch (itype->type) + { + case FFI_TYPE_FLOAT: + flags = ALPHA_FLAGS(ALPHA_ST_CPLXF, ALPHA_LD_CPLXF); + break; + case FFI_TYPE_DOUBLE: + flags = ALPHA_FLAGS(ALPHA_ST_CPLXD, ALPHA_LD_CPLXD); + break; + default: + if (rtype->size <= 8) + flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT64); + else + flags = ALPHA_RET_IN_MEM; + break; + } + break; + default: + abort(); + } + cif->flags = flags; + + /* Include the hidden structure pointer in args requirement. */ + if (flags == ALPHA_RET_IN_MEM) + bytes += 8; + /* Minimum size is 6 slots, so that ffi_call_osf can pop them. */ + if (bytes < 6*8) + bytes = 6*8; + cif->bytes = bytes; + + return FFI_OK; +} + +static unsigned long +extend_basic_type(void *valp, int type, int argn) +{ + switch (type) + { + case FFI_TYPE_SINT8: + return *(SINT8 *)valp; + case FFI_TYPE_UINT8: + return *(UINT8 *)valp; + case FFI_TYPE_SINT16: + return *(SINT16 *)valp; + case FFI_TYPE_UINT16: + return *(UINT16 *)valp; + + case FFI_TYPE_FLOAT: + if (argn < 6) + return lds(valp); + /* FALLTHRU */ + + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + /* Note that unsigned 32-bit quantities are sign extended. */ + return *(SINT32 *)valp; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + case FFI_TYPE_DOUBLE: + return *(UINT64 *)valp; + + default: + abort(); + } +} + +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + unsigned long *argp; + long i, avn, argn, flags = cif->flags; + ffi_type **arg_types; + void *frame; + + /* If the return value is a struct and we don't have a return + value address then we need to make one. */ + if (rvalue == NULL && flags == ALPHA_RET_IN_MEM) + rvalue = alloca(cif->rtype->size); + + /* Allocate the space for the arguments, plus 4 words of temp + space for ffi_call_osf. */ + argp = frame = alloca(cif->bytes + 4*FFI_SIZEOF_ARG); + frame += cif->bytes; + + argn = 0; + if (flags == ALPHA_RET_IN_MEM) + argp[argn++] = (unsigned long)rvalue; + + avn = cif->nargs; + arg_types = cif->arg_types; + + for (i = 0, avn = cif->nargs; i < avn; i++) + { + ffi_type *ty = arg_types[i]; + void *valp = avalue[i]; + int type = ty->type; + size_t size; + + switch (type) + { + case FFI_TYPE_INT: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + argp[argn] = extend_basic_type(valp, type, argn); + argn++; + break; + + case FFI_TYPE_LONGDOUBLE: + by_reference: + /* Note that 128-bit long double is passed by reference. */ + argp[argn++] = (unsigned long)valp; + break; + + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + size = ty->size; + memcpy(argp + argn, valp, size); + argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; + break; + + case FFI_TYPE_COMPLEX: + type = ty->elements[0]->type; + if (type == FFI_TYPE_LONGDOUBLE) + goto by_reference; + + /* Most complex types passed as two separate arguments. */ + size = ty->elements[0]->size; + argp[argn] = extend_basic_type(valp, type, argn); + argp[argn + 1] = extend_basic_type(valp + size, type, argn + 1); + argn += 2; + break; + + default: + abort(); + } + } + + flags = (flags >> ALPHA_ST_SHIFT) & 0xff; + ffi_call_osf(argp, frame, flags, rvalue, fn, closure); +} + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int(cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int(cif, fn, rvalue, avalue, closure); +} + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp; + + if (cif->abi != FFI_OSF) + return FFI_BAD_ABI; + + tramp = (unsigned int *) &closure->tramp[0]; + tramp[0] = 0x47fb0401; /* mov $27,$1 */ + tramp[1] = 0xa77b0010; /* ldq $27,16($27) */ + tramp[2] = 0x6bfb0000; /* jmp $31,($27),0 */ + tramp[3] = 0x47ff041f; /* nop */ + *(void **) &tramp[4] = ffi_closure_osf; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + /* Flush the Icache. + + Tru64 UNIX as doesn't understand the imb mnemonic, so use call_pal + instead, since both Compaq as and gas can handle it. + + 0x86 is PAL_imb in Tru64 UNIX . */ + asm volatile ("call_pal 0x86" : : : "memory"); + + return FFI_OK; +} + +ffi_status +ffi_prep_go_closure (ffi_go_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*)) +{ + if (cif->abi != FFI_OSF) + return FFI_BAD_ABI; + + closure->tramp = (void *)ffi_go_closure_osf; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +long FFI_HIDDEN +ffi_closure_osf_inner (ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *rvalue, unsigned long *argp) +{ + void **avalue; + ffi_type **arg_types; + long i, avn, argn, flags; + + avalue = alloca(cif->nargs * sizeof(void *)); + flags = cif->flags; + argn = 0; + + /* Copy the caller's structure return address to that the closure + returns the data directly to the caller. */ + if (flags == ALPHA_RET_IN_MEM) + { + rvalue = (void *) argp[0]; + argn = 1; + } + + arg_types = cif->arg_types; + + /* Grab the addresses of the arguments from the stack frame. */ + for (i = 0, avn = cif->nargs; i < avn; i++) + { + ffi_type *ty = arg_types[i]; + int type = ty->type; + void *valp = &argp[argn]; + size_t size; + + switch (type) + { + case FFI_TYPE_INT: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + argn += 1; + break; + + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + size = ty->size; + argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; + break; + + case FFI_TYPE_FLOAT: + /* Floats coming from registers need conversion from double + back to float format. */ + if (argn < 6) + { + valp = &argp[argn - 6]; + sts(valp, argp[argn - 6]); + } + argn += 1; + break; + + case FFI_TYPE_DOUBLE: + if (argn < 6) + valp = &argp[argn - 6]; + argn += 1; + break; + + case FFI_TYPE_LONGDOUBLE: + by_reference: + /* 128-bit long double is passed by reference. */ + valp = (void *)argp[argn]; + argn += 1; + break; + + case FFI_TYPE_COMPLEX: + type = ty->elements[0]->type; + switch (type) + { + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + /* Passed as separate arguments, but they wind up sequential. */ + break; + + case FFI_TYPE_INT: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + /* Passed as separate arguments. Disjoint, but there's room + enough in one slot to hold the pair. */ + size = ty->elements[0]->size; + memcpy(valp + size, valp + 8, size); + break; + + case FFI_TYPE_FLOAT: + /* Passed as separate arguments. Disjoint, and each piece + may need conversion back to float. */ + if (argn < 6) + { + valp = &argp[argn - 6]; + sts(valp, argp[argn - 6]); + } + if (argn + 1 < 6) + sts(valp + 4, argp[argn + 1 - 6]); + else + *(UINT32 *)(valp + 4) = argp[argn + 1]; + break; + + case FFI_TYPE_DOUBLE: + /* Passed as separate arguments. Only disjoint if one part + is in fp regs and the other is on the stack. */ + if (argn < 5) + valp = &argp[argn - 6]; + else if (argn == 5) + { + valp = alloca(16); + ((UINT64 *)valp)[0] = argp[5 - 6]; + ((UINT64 *)valp)[1] = argp[6]; + } + break; + + case FFI_TYPE_LONGDOUBLE: + goto by_reference; + + default: + abort(); + } + argn += 2; + break; + + default: + abort (); + } + + avalue[i] = valp; + } + + /* Invoke the closure. */ + fun (cif, rvalue, avalue, user_data); + + /* Tell ffi_closure_osf how to perform return type promotions. */ + return (flags >> ALPHA_LD_SHIFT) & 0xff; +} diff --git a/user/mpy/lib/libffi/src/alpha/ffitarget.h b/user/mpy/lib/libffi/src/alpha/ffitarget.h new file mode 100644 index 0000000..a02dbd0 --- /dev/null +++ b/user/mpy/lib/libffi/src/alpha/ffitarget.h @@ -0,0 +1,57 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for Alpha. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_OSF, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_OSF +} ffi_abi; +#endif + +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION +#define FFI_TARGET_HAS_COMPLEX_TYPE + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 24 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/alpha/internal.h b/user/mpy/lib/libffi/src/alpha/internal.h new file mode 100644 index 0000000..44da192 --- /dev/null +++ b/user/mpy/lib/libffi/src/alpha/internal.h @@ -0,0 +1,23 @@ +#define ALPHA_ST_VOID 0 +#define ALPHA_ST_INT 1 +#define ALPHA_ST_FLOAT 2 +#define ALPHA_ST_DOUBLE 3 +#define ALPHA_ST_CPLXF 4 +#define ALPHA_ST_CPLXD 5 + +#define ALPHA_LD_VOID 0 +#define ALPHA_LD_INT64 1 +#define ALPHA_LD_INT32 2 +#define ALPHA_LD_UINT16 3 +#define ALPHA_LD_SINT16 4 +#define ALPHA_LD_UINT8 5 +#define ALPHA_LD_SINT8 6 +#define ALPHA_LD_FLOAT 7 +#define ALPHA_LD_DOUBLE 8 +#define ALPHA_LD_CPLXF 9 +#define ALPHA_LD_CPLXD 10 + +#define ALPHA_ST_SHIFT 0 +#define ALPHA_LD_SHIFT 8 +#define ALPHA_RET_IN_MEM 0x10000 +#define ALPHA_FLAGS(S, L) (((L) << ALPHA_LD_SHIFT) | (S)) diff --git a/user/mpy/lib/libffi/src/alpha/osf.S b/user/mpy/lib/libffi/src/alpha/osf.S new file mode 100644 index 0000000..b031828 --- /dev/null +++ b/user/mpy/lib/libffi/src/alpha/osf.S @@ -0,0 +1,282 @@ +/* ----------------------------------------------------------------------- + osf.S - Copyright (c) 1998, 2001, 2007, 2008, 2011, 2014 Red Hat + + Alpha/OSF Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#include +#include "internal.h" + + .arch ev6 + .text + +/* Aid in building a direct addressed jump table, 4 insns per entry. */ +.macro E index + .align 4 + .org 99b + \index * 16 +.endm + +/* ffi_call_osf (void *stack, void *frame, unsigned flags, + void *raddr, void (*fnaddr)(void), void *closure) + + Bit o trickiness here -- FRAME is the base of the stack frame + for this function. This has been allocated by ffi_call. We also + deallocate some of the stack that has been alloca'd. */ + + .align 4 + .globl ffi_call_osf + .ent ffi_call_osf + FFI_HIDDEN(ffi_call_osf) + +ffi_call_osf: + cfi_startproc + cfi_def_cfa($17, 32) + mov $16, $30 + stq $26, 0($17) + stq $15, 8($17) + mov $17, $15 + .prologue 0 + cfi_def_cfa_register($15) + cfi_rel_offset($26, 0) + cfi_rel_offset($15, 8) + + stq $18, 16($17) # save flags into frame + stq $19, 24($17) # save rvalue into frame + mov $20, $27 # fn into place for call + mov $21, $1 # closure into static chain + + # Load up all of the (potential) argument registers. + ldq $16, 0($30) + ldt $f16, 0($30) + ldt $f17, 8($30) + ldq $17, 8($30) + ldt $f18, 16($30) + ldq $18, 16($30) + ldt $f19, 24($30) + ldq $19, 24($30) + ldt $f20, 32($30) + ldq $20, 32($30) + ldt $f21, 40($30) + ldq $21, 40($30) + + # Deallocate the register argument area. + lda $30, 48($30) + + jsr $26, ($27), 0 +0: + ldah $29, 0($26) !gpdisp!1 + ldq $2, 24($15) # reload rvalue + lda $29, 0($29) !gpdisp!1 + ldq $3, 16($15) # reload flags + lda $1, 99f-0b($26) + ldq $26, 0($15) + ldq $15, 8($15) + cfi_restore($26) + cfi_restore($15) + cfi_def_cfa($sp, 0) + cmoveq $2, ALPHA_ST_VOID, $3 # mash null rvalue to void + addq $3, $3, $3 + s8addq $3, $1, $1 # 99f + stcode * 16 + jmp $31, ($1), $st_int + + .align 4 +99: +E ALPHA_ST_VOID + ret +E ALPHA_ST_INT +$st_int: + stq $0, 0($2) + ret +E ALPHA_ST_FLOAT + sts $f0, 0($2) + ret +E ALPHA_ST_DOUBLE + stt $f0, 0($2) + ret +E ALPHA_ST_CPLXF + sts $f0, 0($2) + sts $f1, 4($2) + ret +E ALPHA_ST_CPLXD + stt $f0, 0($2) + stt $f1, 8($2) + ret + + cfi_endproc + .end ffi_call_osf + +/* ffi_closure_osf(...) + + Receives the closure argument in $1. */ + +#define CLOSURE_FS (16*8) + + .align 4 + .globl ffi_go_closure_osf + .ent ffi_go_closure_osf + FFI_HIDDEN(ffi_go_closure_osf) + +ffi_go_closure_osf: + cfi_startproc + ldgp $29, 0($27) + subq $30, CLOSURE_FS, $30 + cfi_adjust_cfa_offset(CLOSURE_FS) + stq $26, 0($30) + .prologue 1 + cfi_rel_offset($26, 0) + + stq $16, 10*8($30) + stq $17, 11*8($30) + stq $18, 12*8($30) + + ldq $16, 8($1) # load cif + ldq $17, 16($1) # load fun + mov $1, $18 # closure is user_data + br $do_closure + + cfi_endproc + .end ffi_go_closure_osf + + .align 4 + .globl ffi_closure_osf + .ent ffi_closure_osf + FFI_HIDDEN(ffi_closure_osf) + +ffi_closure_osf: + cfi_startproc + ldgp $29, 0($27) + subq $30, CLOSURE_FS, $30 + cfi_adjust_cfa_offset(CLOSURE_FS) + stq $26, 0($30) + .prologue 1 + cfi_rel_offset($26, 0) + + # Store all of the potential argument registers in va_list format. + stq $16, 10*8($30) + stq $17, 11*8($30) + stq $18, 12*8($30) + + ldq $16, 24($1) # load cif + ldq $17, 32($1) # load fun + ldq $18, 40($1) # load user_data + +$do_closure: + stq $19, 13*8($30) + stq $20, 14*8($30) + stq $21, 15*8($30) + stt $f16, 4*8($30) + stt $f17, 5*8($30) + stt $f18, 6*8($30) + stt $f19, 7*8($30) + stt $f20, 8*8($30) + stt $f21, 9*8($30) + + # Call ffi_closure_osf_inner to do the bulk of the work. + lda $19, 2*8($30) + lda $20, 10*8($30) + jsr $26, ffi_closure_osf_inner +0: + ldah $29, 0($26) !gpdisp!2 + lda $2, 99f-0b($26) + s4addq $0, 0, $1 # ldcode * 4 + ldq $0, 16($30) # preload return value + s4addq $1, $2, $1 # 99f + ldcode * 16 + lda $29, 0($29) !gpdisp!2 + ldq $26, 0($30) + cfi_restore($26) + jmp $31, ($1), $load_32 + +.macro epilogue + addq $30, CLOSURE_FS, $30 + cfi_adjust_cfa_offset(-CLOSURE_FS) + ret + .align 4 + cfi_adjust_cfa_offset(CLOSURE_FS) +.endm + + .align 4 +99: +E ALPHA_LD_VOID + epilogue + +E ALPHA_LD_INT64 + epilogue + +E ALPHA_LD_INT32 +$load_32: + sextl $0, $0 + epilogue + +E ALPHA_LD_UINT16 + zapnot $0, 3, $0 + epilogue + +E ALPHA_LD_SINT16 +#ifdef __alpha_bwx__ + sextw $0, $0 +#else + sll $0, 48, $0 + sra $0, 48, $0 +#endif + epilogue + +E ALPHA_LD_UINT8 + and $0, 0xff, $0 + epilogue + +E ALPHA_LD_SINT8 +#ifdef __alpha_bwx__ + sextb $0, $0 +#else + sll $0, 56, $0 + sra $0, 56, $0 +#endif + epilogue + +E ALPHA_LD_FLOAT + lds $f0, 16($sp) + epilogue + +E ALPHA_LD_DOUBLE + ldt $f0, 16($sp) + epilogue + +E ALPHA_LD_CPLXF + lds $f0, 16($sp) + lds $f1, 20($sp) + epilogue + +E ALPHA_LD_CPLXD + ldt $f0, 16($sp) + ldt $f1, 24($sp) + epilogue + + cfi_endproc + .end ffi_closure_osf + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/arc/arcompact.S b/user/mpy/lib/libffi/src/arc/arcompact.S new file mode 100644 index 0000000..03715fd --- /dev/null +++ b/user/mpy/lib/libffi/src/arc/arcompact.S @@ -0,0 +1,135 @@ +/* ----------------------------------------------------------------------- + arcompact.S - Copyright (c) 2013 Synposys, Inc. (www.synopsys.com) + + ARCompact Foreign Function Interface + + 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 RENESAS TECHNOLOGY 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#ifdef HAVE_MACHINE_ASM_H +#include +#else +#define CNAME(x) x +#define ENTRY(x) .globl CNAME(x)` .type CNAME(x),%function` CNAME(x): +#endif + +.text + + /* R0: ffi_prep_args */ + /* R1: &ecif */ + /* R2: cif->bytes */ + /* R3: fig->flags */ + /* R4: ecif.rvalue */ + /* R5: fn */ +ENTRY(ffi_call_ARCompact) + /* Save registers. */ + st.a fp, [sp, -4] /* fp + 20, fp */ + push_s blink /* fp + 16, blink */ + st.a r4, [sp, -4] /* fp + 12, ecif.rvalue */ + push_s r3 /* fp + 8, fig->flags */ + st.a r5, [sp, -4] /* fp + 4, fn */ + push_s r2 /* fp + 0, cif->bytes */ + mov fp, sp + + /* Make room for all of the new args. */ + sub sp, sp, r2 + + /* Place all of the ffi_prep_args in position. */ + /* ffi_prep_args(char *stack, extended_cif *ecif) */ + /* R1 already set. */ + + /* And call. */ + jl_s.d [r0] + mov_s r0, sp + + ld.ab r12, [fp, 4] /* cif->bytes */ + ld.ab r11, [fp, 4] /* fn */ + + /* Move first 8 parameters in registers... */ + ld_s r0, [sp] + ld_s r1, [sp, 4] + ld_s r2, [sp, 8] + ld_s r3, [sp, 12] + ld r4, [sp, 16] + ld r5, [sp, 20] + ld r6, [sp, 24] + ld r7, [sp, 28] + + /* ...and adjust the stack. */ + min r12, r12, 32 + + /* Call the function. */ + jl.d [r11] + add sp, sp, r12 + + mov sp, fp + pop_s r3 /* fig->flags, return type */ + pop_s r2 /* ecif.rvalue, pointer for return value */ + + /* If the return value pointer is NULL, assume no return value. */ + breq.d r2, 0, epilogue + pop_s blink + + /* Return INT. */ + brne r3, FFI_TYPE_INT, return_double + b.d epilogue + st_s r0, [r2] + +return_double: + brne r3, FFI_TYPE_DOUBLE, epilogue + st_s r0, [r2] + st_s r1, [r2,4] + +epilogue: + j_s.d [blink] + ld.ab fp, [sp, 4] + +ENTRY(ffi_closure_ARCompact) + st.a r0, [sp, -32] + st_s r1, [sp, 4] + st_s r2, [sp, 8] + st_s r3, [sp, 12] + st r4, [sp, 16] + st r5, [sp, 20] + st r6, [sp, 24] + st r7, [sp, 28] + + /* pointer to arguments */ + mov_s r2, sp + + /* return value goes here */ + sub sp, sp, 8 + mov_s r1, sp + + push_s blink + + bl.d ffi_closure_inner_ARCompact + mov_s r0, r8 /* codeloc, set by trampoline */ + + pop_s blink + + /* set return value to r1:r0 */ + pop_s r0 + pop_s r1 + j_s.d [blink] + add_s sp, sp, 32 diff --git a/user/mpy/lib/libffi/src/arc/ffi.c b/user/mpy/lib/libffi/src/arc/ffi.c new file mode 100644 index 0000000..32f82a7 --- /dev/null +++ b/user/mpy/lib/libffi/src/arc/ffi.c @@ -0,0 +1,268 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com) + + ARC Foreign Function Interface + + 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 RENESAS TECHNOLOGY 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include +#include + +#include + +/* for little endian ARC, the code is in fact stored as mixed endian for + performance reasons */ +#if __BIG_ENDIAN__ +#define CODE_ENDIAN(x) (x) +#else +#define CODE_ENDIAN(x) ( (((uint32_t) (x)) << 16) | (((uint32_t) (x)) >> 16)) +#endif + +/* ffi_prep_args is called by the assembly routine once stack + space has been allocated for the function's arguments. */ + +void +ffi_prep_args (char *stack, extended_cif * ecif) +{ + unsigned int i; + int tmp; + void **p_argv; + char *argp; + ffi_type **p_arg; + + tmp = 0; + argp = stack; + + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) + { + *(void **) argp = ecif->rvalue; + argp += 4; + } + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); i--, p_arg++) + { + size_t z; + int alignment; + + /* align alignment to 4 */ + alignment = (((*p_arg)->alignment - 1) | 3) + 1; + + /* Align if necessary. */ + if ((alignment - 1) & (unsigned) argp) + argp = (char *) ALIGN (argp, alignment); + + z = (*p_arg)->size; + if (z < sizeof (int)) + { + z = sizeof (int); + + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int) *(UINT8 *) (*p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int) *(UINT16 *) (*p_argv); + break; + + case FFI_TYPE_STRUCT: + memcpy (argp, *p_argv, (*p_arg)->size); + break; + + default: + FFI_ASSERT (0); + } + } + else if (z == sizeof (int)) + { + *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv); + } + else + { + if ((*p_arg)->type == FFI_TYPE_STRUCT) + { + memcpy (argp, *p_argv, z); + } + else + { + /* Double or long long 64bit. */ + memcpy (argp, *p_argv, z); + } + } + p_argv++; + argp += z; + } + + return; +} + +/* Perform machine dependent cif processing. */ +ffi_status +ffi_prep_cif_machdep (ffi_cif * cif) +{ + /* Set the return type flag. */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + cif->flags = (unsigned) cif->rtype->type; + break; + + case FFI_TYPE_STRUCT: + cif->flags = (unsigned) cif->rtype->type; + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: + cif->flags = FFI_TYPE_DOUBLE; + break; + + case FFI_TYPE_FLOAT: + default: + cif->flags = FFI_TYPE_INT; + break; + } + + return FFI_OK; +} + +extern void ffi_call_ARCompact (void (*)(char *, extended_cif *), + extended_cif *, unsigned, unsigned, + unsigned *, void (*fn) (void)); + +void +ffi_call (ffi_cif * cif, void (*fn) (void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have + a return value address then we need to make one. */ + if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca (cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_ARCOMPACT: + ffi_call_ARCompact (ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + break; + + default: + FFI_ASSERT (0); + break; + } +} + +int +ffi_closure_inner_ARCompact (ffi_closure * closure, void *rvalue, + ffi_arg * args) +{ + void **arg_area, **p_argv; + ffi_cif *cif = closure->cif; + char *argp = (char *) args; + ffi_type **p_argt; + int i; + + arg_area = (void **) alloca (cif->nargs * sizeof (void *)); + + /* handle hidden argument */ + if (cif->flags == FFI_TYPE_STRUCT) + { + rvalue = *(void **) argp; + argp += 4; + } + + p_argv = arg_area; + + for (i = 0, p_argt = cif->arg_types; i < cif->nargs; + i++, p_argt++, p_argv++) + { + size_t z; + int alignment; + + /* align alignment to 4 */ + alignment = (((*p_argt)->alignment - 1) | 3) + 1; + + /* Align if necessary. */ + if ((alignment - 1) & (unsigned) argp) + argp = (char *) ALIGN (argp, alignment); + + z = (*p_argt)->size; + *p_argv = (void *) argp; + argp += z; + } + + (closure->fun) (cif, rvalue, arg_area, closure->user_data); + + return cif->flags; +} + +extern void ffi_closure_ARCompact (void); + +ffi_status +ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, void *codeloc) +{ + uint32_t *tramp = (uint32_t *) & (closure->tramp[0]); + + switch (cif->abi) + { + case FFI_ARCOMPACT: + FFI_ASSERT (tramp == codeloc); + tramp[0] = CODE_ENDIAN (0x200a1fc0); /* mov r8, pcl */ + tramp[1] = CODE_ENDIAN (0x20200f80); /* j [long imm] */ + tramp[2] = CODE_ENDIAN (ffi_closure_ARCompact); + break; + + default: + return FFI_BAD_ABI; + } + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + cacheflush (codeloc, FFI_TRAMPOLINE_SIZE, BCACHE); + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/arc/ffitarget.h b/user/mpy/lib/libffi/src/arc/ffitarget.h new file mode 100644 index 0000000..bf8311b --- /dev/null +++ b/user/mpy/lib/libffi/src/arc/ffitarget.h @@ -0,0 +1,53 @@ +/* ----------------------------------------------------------------------- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com) + Target configuration macros for ARC. + + 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 RENESAS TECHNOLOGY 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- Generic type definitions ----------------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi +{ + FFI_FIRST_ABI = 0, + FFI_ARCOMPACT, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_ARCOMPACT +} ffi_abi; +#endif + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 12 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/arm/ffi.c b/user/mpy/lib/libffi/src/arm/ffi.c new file mode 100644 index 0000000..9c8732d --- /dev/null +++ b/user/mpy/lib/libffi/src/arm/ffi.c @@ -0,0 +1,1043 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2011 Timothy Wall + Copyright (c) 2011 Plausible Labs Cooperative, Inc. + Copyright (c) 2011 Anthony Green + Copyright (c) 2011 Free Software Foundation + Copyright (c) 1998, 2008, 2011 Red Hat, Inc. + + ARM Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include "internal.h" + +/* Forward declares. */ +static int vfp_type_p (const ffi_type *); +static void layout_vfp_args (ffi_cif *); + +static void * +ffi_align (ffi_type *ty, void *p) +{ + /* Align if necessary */ + size_t alignment; +#ifdef _WIN32_WCE + alignment = 4; +#else + alignment = ty->alignment; + if (alignment < 4) + alignment = 4; +#endif + return (void *) ALIGN (p, alignment); +} + +static size_t +ffi_put_arg (ffi_type *ty, void *src, void *dst) +{ + size_t z = ty->size; + + switch (ty->type) + { + case FFI_TYPE_SINT8: + *(UINT32 *)dst = *(SINT8 *)src; + break; + case FFI_TYPE_UINT8: + *(UINT32 *)dst = *(UINT8 *)src; + break; + case FFI_TYPE_SINT16: + *(UINT32 *)dst = *(SINT16 *)src; + break; + case FFI_TYPE_UINT16: + *(UINT32 *)dst = *(UINT16 *)src; + break; + + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + case FFI_TYPE_FLOAT: + *(UINT32 *)dst = *(UINT32 *)src; + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: + *(UINT64 *)dst = *(UINT64 *)src; + break; + + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: + memcpy (dst, src, z); + break; + + default: + abort(); + } + + return ALIGN (z, 4); +} + +/* ffi_prep_args is called once stack space has been allocated + for the function's arguments. + + The vfp_space parameter is the load area for VFP regs, the return + value is cif->vfp_used (word bitset of VFP regs used for passing + arguments). These are only used for the VFP hard-float ABI. +*/ +static void +ffi_prep_args_SYSV (ffi_cif *cif, int flags, void *rvalue, + void **avalue, char *argp) +{ + ffi_type **arg_types = cif->arg_types; + int i, n; + + if (flags == ARM_TYPE_STRUCT) + { + *(void **) argp = rvalue; + argp += 4; + } + + for (i = 0, n = cif->nargs; i < n; i++) + { + ffi_type *ty = arg_types[i]; + argp = ffi_align (ty, argp); + argp += ffi_put_arg (ty, avalue[i], argp); + } +} + +static void +ffi_prep_args_VFP (ffi_cif *cif, int flags, void *rvalue, + void **avalue, char *stack, char *vfp_space) +{ + ffi_type **arg_types = cif->arg_types; + int i, n, vi = 0; + char *argp, *regp, *eo_regp; + char stack_used = 0; + char done_with_regs = 0; + + /* The first 4 words on the stack are used for values + passed in core registers. */ + regp = stack; + eo_regp = argp = regp + 16; + + /* If the function returns an FFI_TYPE_STRUCT in memory, + that address is passed in r0 to the function. */ + if (flags == ARM_TYPE_STRUCT) + { + *(void **) regp = rvalue; + regp += 4; + } + + for (i = 0, n = cif->nargs; i < n; i++) + { + ffi_type *ty = arg_types[i]; + void *a = avalue[i]; + int is_vfp_type = vfp_type_p (ty); + + /* Allocated in VFP registers. */ + if (vi < cif->vfp_nargs && is_vfp_type) + { + char *vfp_slot = vfp_space + cif->vfp_args[vi++] * 4; + ffi_put_arg (ty, a, vfp_slot); + continue; + } + /* Try allocating in core registers. */ + else if (!done_with_regs && !is_vfp_type) + { + char *tregp = ffi_align (ty, regp); + size_t size = ty->size; + size = (size < 4) ? 4 : size; // pad + /* Check if there is space left in the aligned register + area to place the argument. */ + if (tregp + size <= eo_regp) + { + regp = tregp + ffi_put_arg (ty, a, tregp); + done_with_regs = (regp == argp); + // ensure we did not write into the stack area + FFI_ASSERT (regp <= argp); + continue; + } + /* In case there are no arguments in the stack area yet, + the argument is passed in the remaining core registers + and on the stack. */ + else if (!stack_used) + { + stack_used = 1; + done_with_regs = 1; + argp = tregp + ffi_put_arg (ty, a, tregp); + FFI_ASSERT (eo_regp < argp); + continue; + } + } + /* Base case, arguments are passed on the stack */ + stack_used = 1; + argp = ffi_align (ty, argp); + argp += ffi_put_arg (ty, a, argp); + } +} + +/* Perform machine dependent cif processing */ +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + int flags = 0, cabi = cif->abi; + size_t bytes = cif->bytes; + + /* Map out the register placements of VFP register args. The VFP + hard-float calling conventions are slightly more sophisticated + than the base calling conventions, so we do it here instead of + in ffi_prep_args(). */ + if (cabi == FFI_VFP) + layout_vfp_args (cif); + + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + flags = ARM_TYPE_VOID; + break; + + case FFI_TYPE_INT: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + flags = ARM_TYPE_INT; + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + flags = ARM_TYPE_INT64; + break; + + case FFI_TYPE_FLOAT: + flags = (cabi == FFI_VFP ? ARM_TYPE_VFP_S : ARM_TYPE_INT); + break; + case FFI_TYPE_DOUBLE: + flags = (cabi == FFI_VFP ? ARM_TYPE_VFP_D : ARM_TYPE_INT64); + break; + + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: + if (cabi == FFI_VFP) + { + int h = vfp_type_p (cif->rtype); + + flags = ARM_TYPE_VFP_N; + if (h == 0x100 + FFI_TYPE_FLOAT) + flags = ARM_TYPE_VFP_S; + if (h == 0x100 + FFI_TYPE_DOUBLE) + flags = ARM_TYPE_VFP_D; + if (h != 0) + break; + } + + /* A Composite Type not larger than 4 bytes is returned in r0. + A Composite Type larger than 4 bytes, or whose size cannot + be determined statically ... is stored in memory at an + address passed [in r0]. */ + if (cif->rtype->size <= 4) + flags = ARM_TYPE_INT; + else + { + flags = ARM_TYPE_STRUCT; + bytes += 4; + } + break; + + default: + abort(); + } + + /* Round the stack up to a multiple of 8 bytes. This isn't needed + everywhere, but it is on some platforms, and it doesn't harm anything + when it isn't needed. */ + bytes = ALIGN (bytes, 8); + + /* Minimum stack space is the 4 register arguments that we pop. */ + if (bytes < 4*4) + bytes = 4*4; + + cif->bytes = bytes; + cif->flags = flags; + + return FFI_OK; +} + +/* Perform machine dependent cif processing for variadic calls */ +ffi_status +ffi_prep_cif_machdep_var (ffi_cif * cif, + unsigned int nfixedargs, unsigned int ntotalargs) +{ + /* VFP variadic calls actually use the SYSV ABI */ + if (cif->abi == FFI_VFP) + cif->abi = FFI_SYSV; + + return ffi_prep_cif_machdep (cif); +} + +/* Prototypes for assembly functions, in sysv.S. */ + +struct call_frame +{ + void *fp; + void *lr; + void *rvalue; + int flags; + void *closure; +}; + +extern void ffi_call_SYSV (void *stack, struct call_frame *, + void (*fn) (void)) FFI_HIDDEN; +extern void ffi_call_VFP (void *vfp_space, struct call_frame *, + void (*fn) (void), unsigned vfp_used) FFI_HIDDEN; + +static void +ffi_call_int (ffi_cif * cif, void (*fn) (void), void *rvalue, + void **avalue, void *closure) +{ + int flags = cif->flags; + ffi_type *rtype = cif->rtype; + size_t bytes, rsize, vfp_size; + char *stack, *vfp_space, *new_rvalue; + struct call_frame *frame; + + rsize = 0; + if (rvalue == NULL) + { + /* If the return value is a struct and we don't have a return + value address then we need to make one. Otherwise the return + value is in registers and we can ignore them. */ + if (flags == ARM_TYPE_STRUCT) + rsize = rtype->size; + else + flags = ARM_TYPE_VOID; + } + else if (flags == ARM_TYPE_VFP_N) + { + /* Largest case is double x 4. */ + rsize = 32; + } + else if (flags == ARM_TYPE_INT && rtype->type == FFI_TYPE_STRUCT) + rsize = 4; + + /* Largest case. */ + vfp_size = (cif->abi == FFI_VFP && cif->vfp_used ? 8*8: 0); + + bytes = cif->bytes; + stack = alloca (vfp_size + bytes + sizeof(struct call_frame) + rsize); + + vfp_space = NULL; + if (vfp_size) + { + vfp_space = stack; + stack += vfp_size; + } + + frame = (struct call_frame *)(stack + bytes); + + new_rvalue = rvalue; + if (rsize) + new_rvalue = (void *)(frame + 1); + + frame->rvalue = new_rvalue; + frame->flags = flags; + frame->closure = closure; + + if (vfp_space) + { + ffi_prep_args_VFP (cif, flags, new_rvalue, avalue, stack, vfp_space); + ffi_call_VFP (vfp_space, frame, fn, cif->vfp_used); + } + else + { + ffi_prep_args_SYSV (cif, flags, new_rvalue, avalue, stack); + ffi_call_SYSV (stack, frame, fn); + } + + if (rvalue && rvalue != new_rvalue) + memcpy (rvalue, new_rvalue, rtype->size); +} + +void +ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + +static void * +ffi_prep_incoming_args_SYSV (ffi_cif *cif, void *rvalue, + char *argp, void **avalue) +{ + ffi_type **arg_types = cif->arg_types; + int i, n; + + if (cif->flags == ARM_TYPE_STRUCT) + { + rvalue = *(void **) argp; + argp += 4; + } + + for (i = 0, n = cif->nargs; i < n; i++) + { + ffi_type *ty = arg_types[i]; + size_t z = ty->size; + + argp = ffi_align (ty, argp); + avalue[i] = (void *) argp; + argp += z; + } + + return rvalue; +} + +static void * +ffi_prep_incoming_args_VFP (ffi_cif *cif, void *rvalue, char *stack, + char *vfp_space, void **avalue) +{ + ffi_type **arg_types = cif->arg_types; + int i, n, vi = 0; + char *argp, *regp, *eo_regp; + char done_with_regs = 0; + char stack_used = 0; + + regp = stack; + eo_regp = argp = regp + 16; + + if (cif->flags == ARM_TYPE_STRUCT) + { + rvalue = *(void **) regp; + regp += 4; + } + + for (i = 0, n = cif->nargs; i < n; i++) + { + ffi_type *ty = arg_types[i]; + int is_vfp_type = vfp_type_p (ty); + size_t z = ty->size; + + if (vi < cif->vfp_nargs && is_vfp_type) + { + avalue[i] = vfp_space + cif->vfp_args[vi++] * 4; + continue; + } + else if (!done_with_regs && !is_vfp_type) + { + char *tregp = ffi_align (ty, regp); + + z = (z < 4) ? 4 : z; // pad + + /* If the arguments either fits into the registers or uses registers + and stack, while we haven't read other things from the stack */ + if (tregp + z <= eo_regp || !stack_used) + { + /* Because we're little endian, this is what it turns into. */ + avalue[i] = (void *) tregp; + regp = tregp + z; + + /* If we read past the last core register, make sure we + have not read from the stack before and continue + reading after regp. */ + if (regp > eo_regp) + { + FFI_ASSERT (!stack_used); + argp = regp; + } + if (regp >= eo_regp) + { + done_with_regs = 1; + stack_used = 1; + } + continue; + } + } + + stack_used = 1; + argp = ffi_align (ty, argp); + avalue[i] = (void *) argp; + argp += z; + } + + return rvalue; +} + +struct closure_frame +{ + char vfp_space[8*8] __attribute__((aligned(8))); + char result[8*4]; + char argp[]; +}; + +int FFI_HIDDEN +ffi_closure_inner_SYSV (ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + struct closure_frame *frame) +{ + void **avalue = (void **) alloca (cif->nargs * sizeof (void *)); + void *rvalue = ffi_prep_incoming_args_SYSV (cif, frame->result, + frame->argp, avalue); + fun (cif, rvalue, avalue, user_data); + return cif->flags; +} + +int FFI_HIDDEN +ffi_closure_inner_VFP (ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + struct closure_frame *frame) +{ + void **avalue = (void **) alloca (cif->nargs * sizeof (void *)); + void *rvalue = ffi_prep_incoming_args_VFP (cif, frame->result, frame->argp, + frame->vfp_space, avalue); + fun (cif, rvalue, avalue, user_data); + return cif->flags; +} + +void ffi_closure_SYSV (void) FFI_HIDDEN; +void ffi_closure_VFP (void) FFI_HIDDEN; +void ffi_go_closure_SYSV (void) FFI_HIDDEN; +void ffi_go_closure_VFP (void) FFI_HIDDEN; + +#if FFI_EXEC_TRAMPOLINE_TABLE + +#include +#include +#include +#include + +extern void *ffi_closure_trampoline_table_page; + +typedef struct ffi_trampoline_table ffi_trampoline_table; +typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry; + +struct ffi_trampoline_table +{ + /* contiguous writable and executable pages */ + vm_address_t config_page; + vm_address_t trampoline_page; + + /* free list tracking */ + uint16_t free_count; + ffi_trampoline_table_entry *free_list; + ffi_trampoline_table_entry *free_list_pool; + + ffi_trampoline_table *prev; + ffi_trampoline_table *next; +}; + +struct ffi_trampoline_table_entry +{ + void *(*trampoline) (); + ffi_trampoline_table_entry *next; +}; + +/* Override the standard architecture trampoline size */ +// XXX TODO - Fix +#undef FFI_TRAMPOLINE_SIZE +#define FFI_TRAMPOLINE_SIZE 12 + +/* The trampoline configuration is placed at 4080 bytes prior to the trampoline's entry point */ +#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - 4080)); + +/* The first 16 bytes of the config page are unused, as they are unaddressable from the trampoline page. */ +#define FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET 16 + +/* Total number of trampolines that fit in one trampoline table */ +#define FFI_TRAMPOLINE_COUNT ((PAGE_SIZE - FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) / FFI_TRAMPOLINE_SIZE) + +static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER; +static ffi_trampoline_table *ffi_trampoline_tables = NULL; + +static ffi_trampoline_table * +ffi_trampoline_table_alloc () +{ + ffi_trampoline_table *table = NULL; + + /* Loop until we can allocate two contiguous pages */ + while (table == NULL) + { + vm_address_t config_page = 0x0; + kern_return_t kt; + + /* Try to allocate two pages */ + kt = + vm_allocate (mach_task_self (), &config_page, PAGE_SIZE * 2, + VM_FLAGS_ANYWHERE); + if (kt != KERN_SUCCESS) + { + fprintf (stderr, "vm_allocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + break; + } + + /* Now drop the second half of the allocation to make room for the trampoline table */ + vm_address_t trampoline_page = config_page + PAGE_SIZE; + kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE); + if (kt != KERN_SUCCESS) + { + fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + break; + } + + /* Remap the trampoline table to directly follow the config page */ + vm_prot_t cur_prot; + vm_prot_t max_prot; + + kt = + vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, + mach_task_self (), + (vm_address_t) & ffi_closure_trampoline_table_page, FALSE, + &cur_prot, &max_prot, VM_INHERIT_SHARE); + + /* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */ + if (kt != KERN_SUCCESS) + { + /* Log unexpected failures */ + if (kt != KERN_NO_SPACE) + { + fprintf (stderr, "vm_remap() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + } + + vm_deallocate (mach_task_self (), config_page, PAGE_SIZE); + continue; + } + + /* We have valid trampoline and config pages */ + table = calloc (1, sizeof (ffi_trampoline_table)); + table->free_count = FFI_TRAMPOLINE_COUNT; + table->config_page = config_page; + table->trampoline_page = trampoline_page; + + /* Create and initialize the free list */ + table->free_list_pool = + calloc (FFI_TRAMPOLINE_COUNT, sizeof (ffi_trampoline_table_entry)); + + uint16_t i; + for (i = 0; i < table->free_count; i++) + { + ffi_trampoline_table_entry *entry = &table->free_list_pool[i]; + entry->trampoline = + (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); + + if (i < table->free_count - 1) + entry->next = &table->free_list_pool[i + 1]; + } + + table->free_list = table->free_list_pool; + } + + return table; +} + +void * +ffi_closure_alloc (size_t size, void **code) +{ + /* Create the closure */ + ffi_closure *closure = malloc (size); + if (closure == NULL) + return NULL; + + pthread_mutex_lock (&ffi_trampoline_lock); + + /* Check for an active trampoline table with available entries. */ + ffi_trampoline_table *table = ffi_trampoline_tables; + if (table == NULL || table->free_list == NULL) + { + table = ffi_trampoline_table_alloc (); + if (table == NULL) + { + free (closure); + return NULL; + } + + /* Insert the new table at the top of the list */ + table->next = ffi_trampoline_tables; + if (table->next != NULL) + table->next->prev = table; + + ffi_trampoline_tables = table; + } + + /* Claim the free entry */ + ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list; + ffi_trampoline_tables->free_list = entry->next; + ffi_trampoline_tables->free_count--; + entry->next = NULL; + + pthread_mutex_unlock (&ffi_trampoline_lock); + + /* Initialize the return values */ + *code = entry->trampoline; + closure->trampoline_table = table; + closure->trampoline_table_entry = entry; + + return closure; +} + +void +ffi_closure_free (void *ptr) +{ + ffi_closure *closure = ptr; + + pthread_mutex_lock (&ffi_trampoline_lock); + + /* Fetch the table and entry references */ + ffi_trampoline_table *table = closure->trampoline_table; + ffi_trampoline_table_entry *entry = closure->trampoline_table_entry; + + /* Return the entry to the free list */ + entry->next = table->free_list; + table->free_list = entry; + table->free_count++; + + /* If all trampolines within this table are free, and at least one other table exists, deallocate + * the table */ + if (table->free_count == FFI_TRAMPOLINE_COUNT + && ffi_trampoline_tables != table) + { + /* Remove from the list */ + if (table->prev != NULL) + table->prev->next = table->next; + + if (table->next != NULL) + table->next->prev = table->prev; + + /* Deallocate pages */ + kern_return_t kt; + kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE); + if (kt != KERN_SUCCESS) + fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + + kt = + vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE); + if (kt != KERN_SUCCESS) + fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, + __FILE__, __LINE__); + + /* Deallocate free list */ + free (table->free_list_pool); + free (table); + } + else if (ffi_trampoline_tables != table) + { + /* Otherwise, bump this table to the top of the list */ + table->prev = NULL; + table->next = ffi_trampoline_tables; + if (ffi_trampoline_tables != NULL) + ffi_trampoline_tables->prev = table; + + ffi_trampoline_tables = table; + } + + pthread_mutex_unlock (&ffi_trampoline_lock); + + /* Free the closure */ + free (closure); +} + +#else + +extern unsigned int ffi_arm_trampoline[2] FFI_HIDDEN; + +#endif + +/* the cif must already be prep'ed */ + +ffi_status +ffi_prep_closure_loc (ffi_closure * closure, + ffi_cif * cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, void *codeloc) +{ + void (*closure_func) (void) = ffi_closure_SYSV; + + if (cif->abi == FFI_VFP) + { + /* We only need take the vfp path if there are vfp arguments. */ + if (cif->vfp_used) + closure_func = ffi_closure_VFP; + } + else if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + +#if FFI_EXEC_TRAMPOLINE_TABLE + void **config = FFI_TRAMPOLINE_CODELOC_CONFIG (codeloc); + config[0] = closure; + config[1] = closure_func; +#else + memcpy (closure->tramp, ffi_arm_trampoline, 8); + __clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */ + __clear_cache(codeloc, codeloc + 8); /* clear insn map */ + *(void (**)(void))(closure->tramp + 8) = closure_func; +#endif + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +ffi_status +ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *)) +{ + void (*closure_func) (void) = ffi_go_closure_SYSV; + + if (cif->abi == FFI_VFP) + { + /* We only need take the vfp path if there are vfp arguments. */ + if (cif->vfp_used) + closure_func = ffi_go_closure_VFP; + } + else if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + closure->tramp = closure_func; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +/* Below are routines for VFP hard-float support. */ + +/* A subroutine of vfp_type_p. Given a structure type, return the type code + of the first non-structure element. Recurse for structure elements. + Return -1 if the structure is in fact empty, i.e. no nested elements. */ + +static int +is_hfa0 (const ffi_type *ty) +{ + ffi_type **elements = ty->elements; + int i, ret = -1; + + if (elements != NULL) + for (i = 0; elements[i]; ++i) + { + ret = elements[i]->type; + if (ret == FFI_TYPE_STRUCT || ret == FFI_TYPE_COMPLEX) + { + ret = is_hfa0 (elements[i]); + if (ret < 0) + continue; + } + break; + } + + return ret; +} + +/* A subroutine of vfp_type_p. Given a structure type, return true if all + of the non-structure elements are the same as CANDIDATE. */ + +static int +is_hfa1 (const ffi_type *ty, int candidate) +{ + ffi_type **elements = ty->elements; + int i; + + if (elements != NULL) + for (i = 0; elements[i]; ++i) + { + int t = elements[i]->type; + if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) + { + if (!is_hfa1 (elements[i], candidate)) + return 0; + } + else if (t != candidate) + return 0; + } + + return 1; +} + +/* Determine if TY is an homogenous floating point aggregate (HFA). + That is, a structure consisting of 1 to 4 members of all the same type, + where that type is a floating point scalar. + + Returns non-zero iff TY is an HFA. The result is an encoded value where + bits 0-7 contain the type code, and bits 8-10 contain the element count. */ + +static int +vfp_type_p (const ffi_type *ty) +{ + ffi_type **elements; + int candidate, i; + size_t size, ele_count; + + /* Quickest tests first. */ + candidate = ty->type; + switch (ty->type) + { + default: + return 0; + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + ele_count = 1; + goto done; + case FFI_TYPE_COMPLEX: + candidate = ty->elements[0]->type; + if (candidate != FFI_TYPE_FLOAT && candidate != FFI_TYPE_DOUBLE) + return 0; + ele_count = 2; + goto done; + case FFI_TYPE_STRUCT: + break; + } + + /* No HFA types are smaller than 4 bytes, or larger than 32 bytes. */ + size = ty->size; + if (size < 4 || size > 32) + return 0; + + /* Find the type of the first non-structure member. */ + elements = ty->elements; + candidate = elements[0]->type; + if (candidate == FFI_TYPE_STRUCT || candidate == FFI_TYPE_COMPLEX) + { + for (i = 0; ; ++i) + { + candidate = is_hfa0 (elements[i]); + if (candidate >= 0) + break; + } + } + + /* If the first member is not a floating point type, it's not an HFA. + Also quickly re-check the size of the structure. */ + switch (candidate) + { + case FFI_TYPE_FLOAT: + ele_count = size / sizeof(float); + if (size != ele_count * sizeof(float)) + return 0; + break; + case FFI_TYPE_DOUBLE: + ele_count = size / sizeof(double); + if (size != ele_count * sizeof(double)) + return 0; + break; + default: + return 0; + } + if (ele_count > 4) + return 0; + + /* Finally, make sure that all scalar elements are the same type. */ + for (i = 0; elements[i]; ++i) + { + int t = elements[i]->type; + if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) + { + if (!is_hfa1 (elements[i], candidate)) + return 0; + } + else if (t != candidate) + return 0; + } + + /* All tests succeeded. Encode the result. */ + done: + return (ele_count << 8) | candidate; +} + +static int +place_vfp_arg (ffi_cif *cif, int h) +{ + unsigned short reg = cif->vfp_reg_free; + int align = 1, nregs = h >> 8; + + if ((h & 0xff) == FFI_TYPE_DOUBLE) + align = 2, nregs *= 2; + + /* Align register number. */ + if ((reg & 1) && align == 2) + reg++; + + while (reg + nregs <= 16) + { + int s, new_used = 0; + for (s = reg; s < reg + nregs; s++) + { + new_used |= (1 << s); + if (cif->vfp_used & (1 << s)) + { + reg += align; + goto next_reg; + } + } + /* Found regs to allocate. */ + cif->vfp_used |= new_used; + cif->vfp_args[cif->vfp_nargs++] = reg; + + /* Update vfp_reg_free. */ + if (cif->vfp_used & (1 << cif->vfp_reg_free)) + { + reg += nregs; + while (cif->vfp_used & (1 << reg)) + reg += 1; + cif->vfp_reg_free = reg; + } + return 0; + next_reg:; + } + // done, mark all regs as used + cif->vfp_reg_free = 16; + cif->vfp_used = 0xFFFF; + return 1; +} + +static void +layout_vfp_args (ffi_cif * cif) +{ + int i; + /* Init VFP fields */ + cif->vfp_used = 0; + cif->vfp_nargs = 0; + cif->vfp_reg_free = 0; + memset (cif->vfp_args, -1, 16); /* Init to -1. */ + + for (i = 0; i < cif->nargs; i++) + { + int h = vfp_type_p (cif->arg_types[i]); + if (h && place_vfp_arg (cif, h) == 1) + break; + } +} diff --git a/user/mpy/lib/libffi/src/arm/ffitarget.h b/user/mpy/lib/libffi/src/arm/ffitarget.h new file mode 100644 index 0000000..4f473f9 --- /dev/null +++ b/user/mpy/lib/libffi/src/arm/ffitarget.h @@ -0,0 +1,69 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 2010 CodeSourcery + Copyright (c) 1996-2003 Red Hat, Inc. + + Target configuration macros for ARM. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_VFP, + FFI_LAST_ABI, +#ifdef __ARM_PCS_VFP + FFI_DEFAULT_ABI = FFI_VFP, +#else + FFI_DEFAULT_ABI = FFI_SYSV, +#endif +} ffi_abi; +#endif + +#define FFI_EXTRA_CIF_FIELDS \ + int vfp_used; \ + unsigned short vfp_reg_free, vfp_nargs; \ + signed char vfp_args[16] \ + +#define FFI_TARGET_SPECIFIC_VARIADIC +#define FFI_TARGET_HAS_COMPLEX_TYPE + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 12 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/arm/internal.h b/user/mpy/lib/libffi/src/arm/internal.h new file mode 100644 index 0000000..6cf0b2a --- /dev/null +++ b/user/mpy/lib/libffi/src/arm/internal.h @@ -0,0 +1,7 @@ +#define ARM_TYPE_VFP_S 0 +#define ARM_TYPE_VFP_D 1 +#define ARM_TYPE_VFP_N 2 +#define ARM_TYPE_INT64 3 +#define ARM_TYPE_INT 4 +#define ARM_TYPE_VOID 5 +#define ARM_TYPE_STRUCT 6 diff --git a/user/mpy/lib/libffi/src/arm/sysv.S b/user/mpy/lib/libffi/src/arm/sysv.S new file mode 100644 index 0000000..fd16589 --- /dev/null +++ b/user/mpy/lib/libffi/src/arm/sysv.S @@ -0,0 +1,335 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 1998, 2008, 2011 Red Hat, Inc. + Copyright (c) 2011 Plausible Labs Cooperative, Inc. + + ARM Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#include +#include "internal.h" + +/* GCC 4.8 provides __ARM_ARCH; construct it otherwise. */ +#ifndef __ARM_ARCH +# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7EM__) +# define __ARM_ARCH 7 +# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ + || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ + || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \ + || defined(__ARM_ARCH_6M__) +# define __ARM_ARCH 6 +# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \ + || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ + || defined(__ARM_ARCH_5TEJ__) +# define __ARM_ARCH 5 +# else +# define __ARM_ARCH 4 +# endif +#endif + +/* Conditionally compile unwinder directives. */ +.macro UNWIND text:vararg +#ifdef __ARM_EABI__ + \text +#endif +.endm +#if defined(HAVE_AS_CFI_PSEUDO_OP) && defined(__ARM_EABI__) + .cfi_sections .debug_frame +#endif + +#define CONCAT(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +#ifdef __USER_LABEL_PREFIX__ +# define CNAME(X) CONCAT (__USER_LABEL_PREFIX__, X) +#else +# define CNAME(X) X +#endif +#ifdef __ELF__ +# define SIZE(X) .size CNAME(X), . - CNAME(X) +# define TYPE(X, Y) .type CNAME(X), Y +#else +# define SIZE(X) +# define TYPE(X, Y) +#endif + +#define ARM_FUNC_START(name, gl) \ + .align 3; \ + .ifne gl; .globl CNAME(name); FFI_HIDDEN(CNAME(name)); .endif; \ + TYPE(name, %function); \ + CNAME(name): + +#define ARM_FUNC_END(name) \ + SIZE(name) + +/* Aid in defining a jump table with 8 bytes between entries. */ +.macro E index + .if . - 0b - 8*\index + .error "type table out of sync" + .endif +.endm + + .text + .syntax unified + .arm + + /* We require interworking on LDM, which implies ARMv5T, + which implies the existance of BLX. */ + .arch armv5t + + /* Note that we use STC and LDC to encode VFP instructions, + so that we do not need ".fpu vfp", nor get that added to + the object file attributes. These will not be executed + unless the FFI_VFP abi is used. */ + + @ r0: stack + @ r1: frame + @ r2: fn + @ r3: vfp_used + +ARM_FUNC_START(ffi_call_VFP, 1) + UNWIND .fnstart + cfi_startproc + + cmp r3, #3 @ load only d0 if possible + ldcle p11, cr0, [r0] @ vldrle d0, [sp] + ldcgt p11, cr0, [r0], {16} @ vldmgt sp, {d0-d7} + add r0, r0, #64 @ discard the vfp register args + /* FALLTHRU */ +ARM_FUNC_END(ffi_call_VFP) + +ARM_FUNC_START(ffi_call_SYSV, 1) + stm r1, {fp, lr} + mov fp, r1 + + @ This is a bit of a lie wrt the origin of the unwind info, but + @ now we've got the usual frame pointer and two saved registers. + UNWIND .save {fp,lr} + UNWIND .setfp fp, sp + cfi_def_cfa(fp, 8) + cfi_rel_offset(fp, 0) + cfi_rel_offset(lr, 4) + + mov sp, r0 @ install the stack pointer + mov lr, r2 @ move the fn pointer out of the way + ldr ip, [fp, #16] @ install the static chain + ldmia sp!, {r0-r3} @ move first 4 parameters in registers. + blx lr @ call fn + + @ Load r2 with the pointer to storage for the return value + @ Load r3 with the return type code + ldr r2, [fp, #8] + ldr r3, [fp, #12] + + @ Deallocate the stack with the arguments. + mov sp, fp + cfi_def_cfa_register(sp) + + @ Store values stored in registers. + .align 3 + add pc, pc, r3, lsl #3 + nop +0: +E ARM_TYPE_VFP_S + stc p10, cr0, [r2] @ vstr s0, [r2] + pop {fp,pc} +E ARM_TYPE_VFP_D + stc p11, cr0, [r2] @ vstr d0, [r2] + pop {fp,pc} +E ARM_TYPE_VFP_N + stc p11, cr0, [r2], {8} @ vstm r2, {d0-d3} + pop {fp,pc} +E ARM_TYPE_INT64 + str r1, [r2, #4] + nop +E ARM_TYPE_INT + str r0, [r2] + pop {fp,pc} +E ARM_TYPE_VOID + pop {fp,pc} + nop +E ARM_TYPE_STRUCT + pop {fp,pc} + + cfi_endproc + UNWIND .fnend +ARM_FUNC_END(ffi_call_SYSV) + + +/* + int ffi_closure_inner_* (cif, fun, user_data, frame) +*/ + +ARM_FUNC_START(ffi_go_closure_SYSV, 1) + cfi_startproc + stmdb sp!, {r0-r3} @ save argument regs + cfi_adjust_cfa_offset(16) + ldr r0, [ip, #4] @ load cif + ldr r1, [ip, #8] @ load fun + mov r2, ip @ load user_data + b 0f + cfi_endproc +ARM_FUNC_END(ffi_go_closure_SYSV) + +ARM_FUNC_START(ffi_closure_SYSV, 1) + UNWIND .fnstart + cfi_startproc + stmdb sp!, {r0-r3} @ save argument regs + cfi_adjust_cfa_offset(16) + ldr r0, [ip, #FFI_TRAMPOLINE_SIZE] @ load cif + ldr r1, [ip, #FFI_TRAMPOLINE_SIZE+4] @ load fun + ldr r2, [ip, #FFI_TRAMPOLINE_SIZE+8] @ load user_data +0: + add ip, sp, #16 @ compute entry sp + sub sp, sp, #64+32 @ allocate frame + cfi_adjust_cfa_offset(64+32) + stmdb sp!, {ip,lr} + + /* Remember that EABI unwind info only applies at call sites. + We need do nothing except note the save of the stack pointer + and the link registers. */ + UNWIND .save {sp,lr} + cfi_adjust_cfa_offset(8) + cfi_rel_offset(lr, 4) + + add r3, sp, #8 @ load frame + bl CNAME(ffi_closure_inner_SYSV) + + @ Load values returned in registers. + add r2, sp, #8+64 @ load result + adr r3, CNAME(ffi_closure_ret) + add pc, r3, r0, lsl #3 + cfi_endproc + UNWIND .fnend +ARM_FUNC_END(ffi_closure_SYSV) + +ARM_FUNC_START(ffi_go_closure_VFP, 1) + cfi_startproc + stmdb sp!, {r0-r3} @ save argument regs + cfi_adjust_cfa_offset(16) + ldr r0, [ip, #4] @ load cif + ldr r1, [ip, #8] @ load fun + mov r2, ip @ load user_data + b 0f + cfi_endproc +ARM_FUNC_END(ffi_go_closure_VFP) + +ARM_FUNC_START(ffi_closure_VFP, 1) + UNWIND .fnstart + cfi_startproc + stmdb sp!, {r0-r3} @ save argument regs + cfi_adjust_cfa_offset(16) + ldr r0, [ip, #FFI_TRAMPOLINE_SIZE] @ load cif + ldr r1, [ip, #FFI_TRAMPOLINE_SIZE+4] @ load fun + ldr r2, [ip, #FFI_TRAMPOLINE_SIZE+8] @ load user_data +0: + add ip, sp, #16 + sub sp, sp, #64+32 @ allocate frame + cfi_adjust_cfa_offset(64+32) + stc p11, cr0, [sp], {16} @ vstm sp, {d0-d7} + stmdb sp!, {ip,lr} + + /* See above. */ + UNWIND .save {sp,lr} + cfi_adjust_cfa_offset(8) + cfi_rel_offset(lr, 4) + + add r3, sp, #8 @ load frame + bl CNAME(ffi_closure_inner_VFP) + + @ Load values returned in registers. + add r2, sp, #8+64 @ load result + adr r3, CNAME(ffi_closure_ret) + add pc, r3, r0, lsl #3 + cfi_endproc + UNWIND .fnend +ARM_FUNC_END(ffi_closure_VFP) + +/* Load values returned in registers for both closure entry points. + Note that we use LDM with SP in the register set. This is deprecated + by ARM, but not yet unpredictable. */ + +ARM_FUNC_START(ffi_closure_ret, 0) + cfi_startproc + cfi_rel_offset(sp, 0) + cfi_rel_offset(lr, 4) +0: +E ARM_TYPE_VFP_S + ldc p10, cr0, [r2] @ vldr s0, [r2] + ldm sp, {sp,pc} +E ARM_TYPE_VFP_D + ldc p11, cr0, [r2] @ vldr d0, [r2] + ldm sp, {sp,pc} +E ARM_TYPE_VFP_N + ldc p11, cr0, [r2], {8} @ vldm r2, {d0-d3} + ldm sp, {sp,pc} +E ARM_TYPE_INT64 + ldr r1, [r2, #4] + nop +E ARM_TYPE_INT + ldr r0, [r2] + ldm sp, {sp,pc} +E ARM_TYPE_VOID + ldm sp, {sp,pc} + nop +E ARM_TYPE_STRUCT + ldm sp, {sp,pc} + cfi_endproc +ARM_FUNC_END(ffi_closure_ret) + +#if FFI_EXEC_TRAMPOLINE_TABLE + +/* ??? The iOS support should be updated. The first insn used to + be STMFD, but that's been moved into ffi_closure_SYSV. If the + writable page is put after this one we can make use of the + pc+8 feature of the architecture. We can also reduce the size + of the thunk to 8 and pack more of these into the page. + + In the meantime, simply replace the STMFD with a NOP so as to + keep all the magic numbers the same within ffi.c. */ + + .align 12 +ARM_FUNC_START(ffi_closure_trampoline_table_page) +.rept 4096 / 12 + nop + ldr ip, [pc, #-4092] + ldr pc, [pc, #-4092] +.endr + +#else + +ARM_FUNC_START(ffi_arm_trampoline, 1) +0: adr ip, 0b + ldr pc, 1f +1: .long 0 +ARM_FUNC_END(ffi_arm_trampoline) + +#endif /* FFI_EXEC_TRAMPOLINE_TABLE */ + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/user/mpy/lib/libffi/src/avr32/ffi.c b/user/mpy/lib/libffi/src/avr32/ffi.c new file mode 100644 index 0000000..3d43397 --- /dev/null +++ b/user/mpy/lib/libffi/src/avr32/ffi.c @@ -0,0 +1,423 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2011 Anthony Green + Copyright (c) 2009 Bradley Smith + + AVR32 Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include +#include +#include +#include + +/* #define DEBUG */ + +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, + unsigned int, unsigned int, unsigned int*, unsigned int, + void (*fn)(void)); +extern void ffi_closure_SYSV (ffi_closure *); + +unsigned int pass_struct_on_stack(ffi_type *type) +{ + if(type->type != FFI_TYPE_STRUCT) + return 0; + + if(type->alignment < type->size && + !(type->size == 4 || type->size == 8) && + !(type->size == 8 && type->alignment >= 4)) + return 1; + + if(type->size == 3 || type->size == 5 || type->size == 6 || + type->size == 7) + return 1; + + return 0; +} + +/* ffi_prep_args is called by the assembly routine once stack space + * has been allocated for the function's arguments + * + * This is annoyingly complex since we need to keep track of used + * registers. + */ + +void ffi_prep_args(char *stack, extended_cif *ecif) +{ + unsigned int i; + void **p_argv; + ffi_type **p_arg; + char *reg_base = stack; + char *stack_base = stack + 20; + unsigned int stack_offset = 0; + unsigned int reg_mask = 0; + + p_argv = ecif->avalue; + + /* If cif->flags is struct then we know it's not passed in registers */ + if(ecif->cif->flags == FFI_TYPE_STRUCT) + { + *(void**)reg_base = ecif->rvalue; + reg_mask |= 1; + } + + for(i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; + i++, p_arg++) + { + size_t z = (*p_arg)->size; + int alignment = (*p_arg)->alignment; + int type = (*p_arg)->type; + char *addr = 0; + + if(z % 4 != 0) + z += (4 - z % 4); + + if(reg_mask != 0x1f) + { + if(pass_struct_on_stack(*p_arg)) + { + addr = stack_base + stack_offset; + stack_offset += z; + } + else if(z == sizeof(int)) + { + char index = 0; + + while((reg_mask >> index) & 1) + index++; + + addr = reg_base + (index * 4); + reg_mask |= (1 << index); + } + else if(z == 2 * sizeof(int)) + { + if(!((reg_mask >> 1) & 1)) + { + addr = reg_base + 4; + reg_mask |= (3 << 1); + } + else if(!((reg_mask >> 3) & 1)) + { + addr = reg_base + 12; + reg_mask |= (3 << 3); + } + } + } + + if(!addr) + { + addr = stack_base + stack_offset; + stack_offset += z; + } + + if(type == FFI_TYPE_STRUCT && (*p_arg)->elements[1] == NULL) + type = (*p_arg)->elements[0]->type; + + switch(type) + { + case FFI_TYPE_UINT8: + *(unsigned int *)addr = (unsigned int)*(UINT8 *)(*p_argv); + break; + case FFI_TYPE_SINT8: + *(signed int *)addr = (signed int)*(SINT8 *)(*p_argv); + break; + case FFI_TYPE_UINT16: + *(unsigned int *)addr = (unsigned int)*(UINT16 *)(*p_argv); + break; + case FFI_TYPE_SINT16: + *(signed int *)addr = (signed int)*(SINT16 *)(*p_argv); + break; + default: + memcpy(addr, *p_argv, z); + } + + p_argv++; + } + +#ifdef DEBUG + /* Debugging */ + for(i = 0; i < 5; i++) + { + if((reg_mask & (1 << i)) == 0) + printf("r%d: (unused)\n", 12 - i); + else + printf("r%d: 0x%08x\n", 12 - i, ((unsigned int*)reg_base)[i]); + } + + for(i = 0; i < stack_offset / 4; i++) + { + printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack_base)[i]); + } +#endif +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* Round the stack up to a multiple of 8 bytes. This isn't needed + * everywhere, but it is on some platforms, and it doesn't harm + * anything when it isn't needed. */ + cif->bytes = (cif->bytes + 7) & ~7; + + /* Flag to indicate that he return value is in fact a struct */ + cif->rstruct_flag = 0; + + /* Set the return type flag */ + switch(cif->rtype->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + cif->flags = (unsigned)FFI_TYPE_UINT8; + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + cif->flags = (unsigned)FFI_TYPE_UINT16; + break; + case FFI_TYPE_FLOAT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + cif->flags = (unsigned)FFI_TYPE_UINT32; + break; + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = (unsigned)FFI_TYPE_UINT64; + break; + case FFI_TYPE_STRUCT: + cif->rstruct_flag = 1; + if(!pass_struct_on_stack(cif->rtype)) + { + if(cif->rtype->size <= 1) + cif->flags = (unsigned)FFI_TYPE_UINT8; + else if(cif->rtype->size <= 2) + cif->flags = (unsigned)FFI_TYPE_UINT16; + else if(cif->rtype->size <= 4) + cif->flags = (unsigned)FFI_TYPE_UINT32; + else if(cif->rtype->size <= 8) + cif->flags = (unsigned)FFI_TYPE_UINT64; + else + cif->flags = (unsigned)cif->rtype->type; + } + else + cif->flags = (unsigned)cif->rtype->type; + break; + default: + cif->flags = (unsigned)cif->rtype->type; + break; + } + + return FFI_OK; +} + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + unsigned int size = 0, i = 0; + ffi_type **p_arg; + + ecif.cif = cif; + ecif.avalue = avalue; + + for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++) + size += (*p_arg)->size + (4 - (*p_arg)->size % 4); + + /* If the return value is a struct and we don't have a return value + * address then we need to make one */ + + /* If cif->flags is struct then it's not suitable for registers */ + if((rvalue == NULL) && (cif->flags == FFI_TYPE_STRUCT)) + ecif.rvalue = alloca(cif->rtype->size); + else + ecif.rvalue = rvalue; + + switch(cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV(ffi_prep_args, &ecif, size, cif->flags, + ecif.rvalue, cif->rstruct_flag, fn); + break; + default: + FFI_ASSERT(0); + break; + } +} + +static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, + void **avalue, ffi_cif *cif) +{ + register unsigned int i, reg_mask = 0; + register void **p_argv; + register ffi_type **p_arg; + register char *reg_base = stack; + register char *stack_base = stack + 20; + register unsigned int stack_offset = 0; + +#ifdef DEBUG + /* Debugging */ + for(i = 0; i < cif->nargs + 7; i++) + { + printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack)[i]); + } +#endif + + /* If cif->flags is struct then we know it's not passed in registers */ + if(cif->flags == FFI_TYPE_STRUCT) + { + *rvalue = *(void **)reg_base; + reg_mask |= 1; + } + + p_argv = avalue; + + for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++) + { + size_t z = (*p_arg)->size; + int alignment = (*p_arg)->alignment; + + *p_argv = 0; + + if(z % 4 != 0) + z += (4 - z % 4); + + if(reg_mask != 0x1f) + { + if(pass_struct_on_stack(*p_arg)) + { + *p_argv = (void*)stack_base + stack_offset; + stack_offset += z; + } + else if(z <= sizeof(int)) + { + char index = 0; + + while((reg_mask >> index) & 1) + index++; + + *p_argv = (void*)reg_base + (index * 4); + reg_mask |= (1 << index); + } + else if(z == 2 * sizeof(int)) + { + if(!((reg_mask >> 1) & 1)) + { + *p_argv = (void*)reg_base + 4; + reg_mask |= (3 << 1); + } + else if(!((reg_mask >> 3) & 1)) + { + *p_argv = (void*)reg_base + 12; + reg_mask |= (3 << 3); + } + } + } + + if(!*p_argv) + { + *p_argv = (void*)stack_base + stack_offset; + stack_offset += z; + } + + if((*p_arg)->type != FFI_TYPE_STRUCT || + (*p_arg)->elements[1] == NULL) + { + if(alignment == 1) + **(unsigned int**)p_argv <<= 24; + else if(alignment == 2) + **(unsigned int**)p_argv <<= 16; + } + + p_argv++; + } + +#ifdef DEBUG + /* Debugging */ + for(i = 0; i < cif->nargs; i++) + { + printf("sp+%d: 0x%08x\n", i*4, *(((unsigned int**)avalue)[i])); + } +#endif +} + +/* This function is jumped to by the trampoline */ + +unsigned int ffi_closure_SYSV_inner(ffi_closure *closure, void **respp, + void *args) +{ + ffi_cif *cif; + void **arg_area; + unsigned int i, size = 0; + ffi_type **p_arg; + + cif = closure->cif; + + for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++) + size += (*p_arg)->size + (4 - (*p_arg)->size % 4); + + arg_area = (void **)alloca(size); + + /* this call will initialize ARG_AREA, such that each element in that + * array points to the corresponding value on the stack; and if the + * function returns a structure, it will re-set RESP to point to the + * structure return address. */ + + ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); + + (closure->fun)(cif, *respp, arg_area, closure->user_data); + + return cif->flags; +} + +ffi_status ffi_prep_closure_loc(ffi_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), void *user_data, + void *codeloc) +{ + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]); + unsigned int __fun = (unsigned int)(&ffi_closure_SYSV); + unsigned int __ctx = (unsigned int)(codeloc); + unsigned int __rstruct_flag = (unsigned int)(cif->rstruct_flag); + unsigned int __inner = (unsigned int)(&ffi_closure_SYSV_inner); + *(unsigned int*) &__tramp[0] = 0xebcd1f00; /* pushm r8-r12 */ + *(unsigned int*) &__tramp[4] = 0xfefc0010; /* ld.w r12, pc[16] */ + *(unsigned int*) &__tramp[8] = 0xfefb0010; /* ld.w r11, pc[16] */ + *(unsigned int*) &__tramp[12] = 0xfefa0010; /* ld.w r10, pc[16] */ + *(unsigned int*) &__tramp[16] = 0xfeff0010; /* ld.w pc, pc[16] */ + *(unsigned int*) &__tramp[20] = __ctx; + *(unsigned int*) &__tramp[24] = __rstruct_flag; + *(unsigned int*) &__tramp[28] = __inner; + *(unsigned int*) &__tramp[32] = __fun; + syscall(__NR_cacheflush, 0, (&__tramp[0]), 36); + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} + diff --git a/user/mpy/lib/libffi/src/avr32/ffitarget.h b/user/mpy/lib/libffi/src/avr32/ffitarget.h new file mode 100644 index 0000000..d0c7586 --- /dev/null +++ b/user/mpy/lib/libffi/src/avr32/ffitarget.h @@ -0,0 +1,55 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 2009 Bradley Smith + Target configuration macros for AVR32. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +#define FFI_EXTRA_CIF_FIELDS unsigned int rstruct_flag + +/* Definitions for closures */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 36 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/avr32/sysv.S b/user/mpy/lib/libffi/src/avr32/sysv.S new file mode 100644 index 0000000..a984b3c --- /dev/null +++ b/user/mpy/lib/libffi/src/avr32/sysv.S @@ -0,0 +1,208 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2009 Bradley Smith + + AVR32 Foreign Function Interface + + 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. + --------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + /* r12: ffi_prep_args + * r11: &ecif + * r10: size + * r9: cif->flags + * r8: ecif.rvalue + * sp+0: cif->rstruct_flag + * sp+4: fn */ + + .text + .align 1 + .globl ffi_call_SYSV + .type ffi_call_SYSV, @function +ffi_call_SYSV: + stm --sp, r0,r1,lr + stm --sp, r8-r12 + mov r0, sp + + /* Make room for all of the new args. */ + sub sp, r10 + /* Pad to make way for potential skipped registers */ + sub sp, 20 + + /* Call ffi_prep_args(stack, &ecif). */ + /* r11 already set */ + mov r1, r12 + mov r12, sp + icall r1 + + /* Save new argument size */ + mov r1, r12 + + /* Move first 5 parameters in registers. */ + ldm sp++, r8-r12 + + /* call (fn) (...). */ + ld.w r1, r0[36] + icall r1 + + /* Remove the space we pushed for the args. */ + mov sp, r0 + + /* Load r1 with the rstruct flag. */ + ld.w r1, sp[32] + + /* Load r9 with the return type code. */ + ld.w r9, sp[12] + + /* Load r8 with the return value pointer. */ + ld.w r8, sp[16] + + /* If the return value pointer is NULL, assume no return value. */ + cp.w r8, 0 + breq .Lend + + /* Check if return type is actually a struct */ + cp.w r1, 0 + breq 1f + + /* Return 8bit */ + cp.w r9, FFI_TYPE_UINT8 + breq .Lstore8 + + /* Return 16bit */ + cp.w r9, FFI_TYPE_UINT16 + breq .Lstore16 + +1: + /* Return 32bit */ + cp.w r9, FFI_TYPE_UINT32 + breq .Lstore32 + cp.w r9, FFI_TYPE_UINT16 + breq .Lstore32 + cp.w r9, FFI_TYPE_UINT8 + breq .Lstore32 + + /* Return 64bit */ + cp.w r9, FFI_TYPE_UINT64 + breq .Lstore64 + + /* Didn't match anything */ + bral .Lend + +.Lstore64: + st.w r8[0], r11 + st.w r8[4], r10 + bral .Lend + +.Lstore32: + st.w r8[0], r12 + bral .Lend + +.Lstore16: + st.h r8[0], r12 + bral .Lend + +.Lstore8: + st.b r8[0], r12 + bral .Lend + +.Lend: + sub sp, -20 + ldm sp++, r0,r1,pc + + .size ffi_call_SYSV, . - ffi_call_SYSV + + + /* r12: __ctx + * r11: __rstruct_flag + * r10: __inner */ + + .align 1 + .globl ffi_closure_SYSV + .type ffi_closure_SYSV, @function +ffi_closure_SYSV: + stm --sp, r0,lr + mov r0, r11 + mov r8, r10 + sub r10, sp, -8 + sub sp, 12 + st.w sp[8], sp + sub r11, sp, -8 + icall r8 + + /* Check if return type is actually a struct */ + cp.w r0, 0 + breq 1f + + /* Return 8bit */ + cp.w r12, FFI_TYPE_UINT8 + breq .Lget8 + + /* Return 16bit */ + cp.w r12, FFI_TYPE_UINT16 + breq .Lget16 + +1: + /* Return 32bit */ + cp.w r12, FFI_TYPE_UINT32 + breq .Lget32 + cp.w r12, FFI_TYPE_UINT16 + breq .Lget32 + cp.w r12, FFI_TYPE_UINT8 + breq .Lget32 + + /* Return 64bit */ + cp.w r12, FFI_TYPE_UINT64 + breq .Lget64 + + /* Didn't match anything */ + bral .Lclend + +.Lget64: + ld.w r11, sp[0] + ld.w r10, sp[4] + bral .Lclend + +.Lget32: + ld.w r12, sp[0] + bral .Lclend + +.Lget16: + ld.uh r12, sp[0] + bral .Lclend + +.Lget8: + ld.ub r12, sp[0] + bral .Lclend + +.Lclend: + sub sp, -12 + ldm sp++, r0,lr + sub sp, -20 + mov pc, lr + + .size ffi_closure_SYSV, . - ffi_closure_SYSV + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/bfin/ffi.c b/user/mpy/lib/libffi/src/bfin/ffi.c new file mode 100644 index 0000000..22a2acd --- /dev/null +++ b/user/mpy/lib/libffi/src/bfin/ffi.c @@ -0,0 +1,196 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2012 Alexandre K. I. de Mendonca , + Paulo Pizarro + + Blackfin Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ +#include +#include + +#include +#include + +/* Maximum number of GPRs available for argument passing. */ +#define MAX_GPRARGS 3 + +/* + * Return types + */ +#define FFIBFIN_RET_VOID 0 +#define FFIBFIN_RET_BYTE 1 +#define FFIBFIN_RET_HALFWORD 2 +#define FFIBFIN_RET_INT64 3 +#define FFIBFIN_RET_INT32 4 + +/*====================================================================*/ +/* PROTOTYPE * + /*====================================================================*/ +void ffi_prep_args(unsigned char *, extended_cif *); + +/*====================================================================*/ +/* Externals */ +/* (Assembly) */ +/*====================================================================*/ + +extern void ffi_call_SYSV(unsigned, extended_cif *, void(*)(unsigned char *, extended_cif *), unsigned, void *, void(*fn)(void)); + +/*====================================================================*/ +/* Implementation */ +/* */ +/*====================================================================*/ + + +/* + * This function calculates the return type (size) based on type. + */ + +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* --------------------------------------* + * Return handling * + * --------------------------------------*/ + switch (cif->rtype->type) { + case FFI_TYPE_VOID: + cif->flags = FFIBFIN_RET_VOID; + break; + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + cif->flags = FFIBFIN_RET_HALFWORD; + break; + case FFI_TYPE_UINT8: + cif->flags = FFIBFIN_RET_BYTE; + break; + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_FLOAT: + case FFI_TYPE_POINTER: + case FFI_TYPE_SINT8: + cif->flags = FFIBFIN_RET_INT32; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: + cif->flags = FFIBFIN_RET_INT64; + break; + case FFI_TYPE_STRUCT: + if (cif->rtype->size <= 4){ + cif->flags = FFIBFIN_RET_INT32; + }else if (cif->rtype->size == 8){ + cif->flags = FFIBFIN_RET_INT64; + }else{ + //it will return via a hidden pointer in P0 + cif->flags = FFIBFIN_RET_VOID; + } + break; + default: + FFI_ASSERT(0); + break; + } + return FFI_OK; +} + +/* + * This will prepare the arguments and will call the assembly routine + * cif = the call interface + * fn = the function to be called + * rvalue = the return value + * avalue = the arguments + */ +void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue) +{ + int ret_type = cif->flags; + extended_cif ecif; + ecif.cif = cif; + ecif.avalue = avalue; + ecif.rvalue = rvalue; + + switch (cif->abi) { + case FFI_SYSV: + ffi_call_SYSV(cif->bytes, &ecif, ffi_prep_args, ret_type, ecif.rvalue, fn); + break; + default: + FFI_ASSERT(0); + break; + } +} + + +/* +* This function prepares the parameters (copies them from the ecif to the stack) +* to call the function (ffi_prep_args is called by the assembly routine in file +* sysv.S, which also calls the actual function) +*/ +void ffi_prep_args(unsigned char *stack, extended_cif *ecif) +{ + register unsigned int i = 0; + void **p_argv; + unsigned char *argp; + ffi_type **p_arg; + argp = stack; + p_argv = ecif->avalue; + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); + i--, p_arg++) { + size_t z; + z = (*p_arg)->size; + if (z < sizeof(int)) { + z = sizeof(int); + switch ((*p_arg)->type) { + case FFI_TYPE_SINT8: { + signed char v = *(SINT8 *)(* p_argv); + signed int t = v; + *(signed int *) argp = t; + } + break; + case FFI_TYPE_UINT8: { + unsigned char v = *(UINT8 *)(* p_argv); + unsigned int t = v; + *(unsigned int *) argp = t; + } + break; + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) * (SINT16 *)(* p_argv); + break; + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int) * (UINT16 *)(* p_argv); + break; + case FFI_TYPE_STRUCT: + memcpy(argp, *p_argv, (*p_arg)->size); + break; + default: + FFI_ASSERT(0); + break; + } + } else if (z == sizeof(int)) { + *(unsigned int *) argp = (unsigned int) * (UINT32 *)(* p_argv); + } else { + memcpy(argp, *p_argv, z); + } + p_argv++; + argp += z; + } +} + + + diff --git a/user/mpy/lib/libffi/src/bfin/ffitarget.h b/user/mpy/lib/libffi/src/bfin/ffitarget.h new file mode 100644 index 0000000..2175c01 --- /dev/null +++ b/user/mpy/lib/libffi/src/bfin/ffitarget.h @@ -0,0 +1,43 @@ +/* ----------------------------------------------------------------------- + ffitarget.h - Copyright (c) 2012 Alexandre K. I. de Mendonca + + Blackfin Foreign Function Interface + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +#endif + diff --git a/user/mpy/lib/libffi/src/bfin/sysv.S b/user/mpy/lib/libffi/src/bfin/sysv.S new file mode 100644 index 0000000..f4278be --- /dev/null +++ b/user/mpy/lib/libffi/src/bfin/sysv.S @@ -0,0 +1,179 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2012 Alexandre K. I. de Mendonca , + Paulo Pizarro + + Blackfin Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +.text +.align 4 + + /* + There is a "feature" in the bfin toolchain that it puts a _ before function names + that's why the function here it's called _ffi_call_SYSV and not ffi_call_SYSV + */ + .global _ffi_call_SYSV; + .type _ffi_call_SYSV, STT_FUNC; + .func ffi_call_SYSV + + /* + cif->bytes = R0 (fp+8) + &ecif = R1 (fp+12) + ffi_prep_args = R2 (fp+16) + ret_type = stack (fp+20) + ecif.rvalue = stack (fp+24) + fn = stack (fp+28) + got (fp+32) + + There is room for improvement here (we can use temporary registers + instead of saving the values in the memory) + REGS: + P5 => Stack pointer (function arguments) + R5 => cif->bytes + R4 => ret->type + + FP-20 = P3 + FP-16 = SP (parameters area) + FP-12 = SP (temp) + FP-08 = function return part 1 [R0] + FP-04 = function return part 2 [R1] + */ + +_ffi_call_SYSV: +.prologue: + LINK 20; + [FP-20] = P3; + [FP+8] = R0; + [FP+12] = R1; + [FP+16] = R2; + +.allocate_stack: + //alocate cif->bytes into the stack + R1 = [FP+8]; + R0 = SP; + R0 = R0 - R1; + R1 = 4; + R0 = R0 - R1; + [FP-12] = SP; + SP = R0; + [FP-16] = SP; + +.call_prep_args: + //get the addr of prep_args + P0 = [P3 + _ffi_prep_args@FUNCDESC_GOT17M4]; + P1 = [P0]; + P3 = [P0+4]; + R0 = [FP-16];//SP (parameter area) + R1 = [FP+12];//ecif + call (P1); + +.call_user_function: + //ajust SP so as to allow the user function access the parameters on the stack + SP = [FP-16]; //point to function parameters + R0 = [SP]; + R1 = [SP+4]; + R2 = [SP+8]; + //load user function address + P0 = FP; + P0 +=28; + P1 = [P0]; + P1 = [P1]; + P3 = [P0+4]; + /* + For functions returning aggregate values (struct) occupying more than 8 bytes, + the caller allocates the return value object on the stack and the address + of this object is passed to the callee as a hidden argument in register P0. + */ + P0 = [FP+24]; + + call (P1); + SP = [FP-12]; +.compute_return: + P2 = [FP-20]; + [FP-8] = R0; + [FP-4] = R1; + + R0 = [FP+20]; + R1 = R0 << 2; + + R0 = [P2+.rettable@GOT17M4]; + R0 = R1 + R0; + P2 = R0; + R1 = [P2]; + + P2 = [FP+-20]; + R0 = [P2+.rettable@GOT17M4]; + R0 = R1 + R0; + P2 = R0; + R0 = [FP-8]; + R1 = [FP-4]; + jump (P2); + +/* +#define FFIBFIN_RET_VOID 0 +#define FFIBFIN_RET_BYTE 1 +#define FFIBFIN_RET_HALFWORD 2 +#define FFIBFIN_RET_INT64 3 +#define FFIBFIN_RET_INT32 4 +*/ +.align 4 +.align 4 +.rettable: + .dd .epilogue - .rettable + .dd .rbyte - .rettable; + .dd .rhalfword - .rettable; + .dd .rint64 - .rettable; + .dd .rint32 - .rettable; + +.rbyte: + P0 = [FP+24]; + R0 = R0.B (Z); + [P0] = R0; + JUMP .epilogue +.rhalfword: + P0 = [FP+24]; + R0 = R0.L; + [P0] = R0; + JUMP .epilogue +.rint64: + P0 = [FP+24];// &rvalue + [P0] = R0; + [P0+4] = R1; + JUMP .epilogue +.rint32: + P0 = [FP+24]; + [P0] = R0; +.epilogue: + R0 = [FP+8]; + R1 = [FP+12]; + R2 = [FP+16]; + P3 = [FP-20]; + UNLINK; + RTS; + +.size _ffi_call_SYSV,.-_ffi_call_SYSV; +.endfunc diff --git a/user/mpy/lib/libffi/src/closures.c b/user/mpy/lib/libffi/src/closures.c new file mode 100644 index 0000000..721ff00 --- /dev/null +++ b/user/mpy/lib/libffi/src/closures.c @@ -0,0 +1,688 @@ +/* ----------------------------------------------------------------------- + closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc + Copyright (c) 2011 Plausible Labs Cooperative, Inc. + + Code to allocate and deallocate memory for closures. + + 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 defined __linux__ && !defined _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include +#include + +#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE +# if __gnu_linux__ && !defined(__ANDROID__) +/* This macro indicates it may be forbidden to map anonymous memory + with both write and execute permission. Code compiled when this + option is defined will attempt to map such pages once, but if it + fails, it falls back to creating a temporary file in a writable and + executable filesystem and mapping pages from it into separate + locations in the virtual memory space, one location writable and + another executable. */ +# define FFI_MMAP_EXEC_WRIT 1 +# define HAVE_MNTENT 1 +# endif +# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__) +/* Windows systems may have Data Execution Protection (DEP) enabled, + which requires the use of VirtualMalloc/VirtualFree to alloc/free + executable memory. */ +# define FFI_MMAP_EXEC_WRIT 1 +# endif +#endif + +#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX +# ifdef __linux__ +/* When defined to 1 check for SELinux and if SELinux is active, + don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that + might cause audit messages. */ +# define FFI_MMAP_EXEC_SELINUX 1 +# endif +#endif + +#if FFI_CLOSURES + +# if FFI_EXEC_TRAMPOLINE_TABLE + +// Per-target implementation; It's unclear what can reasonable be shared between two OS/architecture implementations. + +# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */ + +#define USE_LOCKS 1 +#define USE_DL_PREFIX 1 +#ifdef __GNUC__ +#ifndef USE_BUILTIN_FFS +#define USE_BUILTIN_FFS 1 +#endif +#endif + +/* We need to use mmap, not sbrk. */ +#define HAVE_MORECORE 0 + +/* We could, in theory, support mremap, but it wouldn't buy us anything. */ +#define HAVE_MREMAP 0 + +/* We have no use for this, so save some code and data. */ +#define NO_MALLINFO 1 + +/* We need all allocations to be in regular segments, otherwise we + lose track of the corresponding code address. */ +#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T + +/* Don't allocate more than a page unless needed. */ +#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize) + +#if FFI_CLOSURE_TEST +/* Don't release single pages, to avoid a worst-case scenario of + continuously allocating and releasing single pages, but release + pairs of pages, which should do just as well given that allocations + are likely to be small. */ +#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize) +#endif + +#include +#include +#include +#include +#ifndef _MSC_VER +#include +#endif +#include +#include +#if !defined(X86_WIN32) && !defined(X86_WIN64) +#ifdef HAVE_MNTENT +#include +#endif /* HAVE_MNTENT */ +#include +#include + +/* We don't want sys/mman.h to be included after we redefine mmap and + dlmunmap. */ +#include +#define LACKS_SYS_MMAN_H 1 + +#if FFI_MMAP_EXEC_SELINUX +#include +#include + +static int selinux_enabled = -1; + +static int +selinux_enabled_check (void) +{ + struct statfs sfs; + FILE *f; + char *buf = NULL; + size_t len = 0; + + if (statfs ("/selinux", &sfs) >= 0 + && (unsigned int) sfs.f_type == 0xf97cff8cU) + return 1; + f = fopen ("/proc/mounts", "r"); + if (f == NULL) + return 0; + while (getline (&buf, &len, f) >= 0) + { + char *p = strchr (buf, ' '); + if (p == NULL) + break; + p = strchr (p + 1, ' '); + if (p == NULL) + break; + if (strncmp (p + 1, "selinuxfs ", 10) == 0) + { + free (buf); + fclose (f); + return 1; + } + } + free (buf); + fclose (f); + return 0; +} + +#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \ + : (selinux_enabled = selinux_enabled_check ())) + +#else + +#define is_selinux_enabled() 0 + +#endif /* !FFI_MMAP_EXEC_SELINUX */ + +/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */ +#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX +#include + +static int emutramp_enabled = -1; + +static int +emutramp_enabled_check (void) +{ + char *buf = NULL; + size_t len = 0; + FILE *f; + int ret; + f = fopen ("/proc/self/status", "r"); + if (f == NULL) + return 0; + ret = 0; + + while (getline (&buf, &len, f) != -1) + if (!strncmp (buf, "PaX:", 4)) + { + char emutramp; + if (sscanf (buf, "%*s %*c%c", &emutramp) == 1) + ret = (emutramp == 'E'); + break; + } + free (buf); + fclose (f); + return ret; +} + +#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ + : (emutramp_enabled = emutramp_enabled_check ())) +#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ + +#elif defined (__CYGWIN__) || defined(__INTERIX) + +#include + +/* Cygwin is Linux-like, but not quite that Linux-like. */ +#define is_selinux_enabled() 0 + +#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ + +#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX +#define is_emutramp_enabled() 0 +#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ + +/* Declare all functions defined in dlmalloc.c as static. */ +static void *dlmalloc(size_t); +static void dlfree(void*); +static void *dlcalloc(size_t, size_t) MAYBE_UNUSED; +static void *dlrealloc(void *, size_t) MAYBE_UNUSED; +static void *dlmemalign(size_t, size_t) MAYBE_UNUSED; +static void *dlvalloc(size_t) MAYBE_UNUSED; +static int dlmallopt(int, int) MAYBE_UNUSED; +static size_t dlmalloc_footprint(void) MAYBE_UNUSED; +static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED; +static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED; +static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED; +static void *dlpvalloc(size_t) MAYBE_UNUSED; +static int dlmalloc_trim(size_t) MAYBE_UNUSED; +static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; +static void dlmalloc_stats(void) MAYBE_UNUSED; + +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +/* Use these for mmap and munmap within dlmalloc.c. */ +static void *dlmmap(void *, size_t, int, int, int, off_t); +static int dlmunmap(void *, size_t); +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ + +#define mmap dlmmap +#define munmap dlmunmap + +#include "dlmalloc.c" + +#undef mmap +#undef munmap + +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) + +/* A mutex used to synchronize access to *exec* variables in this file. */ +static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; + +/* A file descriptor of a temporary file from which we'll map + executable pages. */ +static int execfd = -1; + +/* The amount of space already allocated from the temporary file. */ +static size_t execsize = 0; + +/* Open a temporary file name, and immediately unlink it. */ +static int +open_temp_exec_file_name (char *name, int flags) +{ + int fd; + +#ifdef HAVE_MKOSTEMP + fd = mkostemp (name, flags); +#else + fd = mkstemp (name); +#endif + + if (fd != -1) + unlink (name); + + return fd; +} + +/* Open a temporary file in the named directory. */ +static int +open_temp_exec_file_dir (const char *dir) +{ + static const char suffix[] = "/ffiXXXXXX"; + int lendir, flags; + char *tempname; +#ifdef O_TMPFILE + int fd; +#endif + +#ifdef O_CLOEXEC + flags = O_CLOEXEC; +#else + flags = 0; +#endif + +#ifdef O_TMPFILE + fd = open (dir, flags | O_RDWR | O_EXCL | O_TMPFILE, 0700); + /* If the running system does not support the O_TMPFILE flag then retry without it. */ + if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP)) { + return fd; + } else { + errno = 0; + } +#endif + + lendir = strlen (dir); + tempname = __builtin_alloca (lendir + sizeof (suffix)); + + if (!tempname) + return -1; + + memcpy (tempname, dir, lendir); + memcpy (tempname + lendir, suffix, sizeof (suffix)); + + return open_temp_exec_file_name (tempname, flags); +} + +/* Open a temporary file in the directory in the named environment + variable. */ +static int +open_temp_exec_file_env (const char *envvar) +{ + const char *value = getenv (envvar); + + if (!value) + return -1; + + return open_temp_exec_file_dir (value); +} + +#ifdef HAVE_MNTENT +/* Open a temporary file in an executable and writable mount point + listed in the mounts file. Subsequent calls with the same mounts + keep searching for mount points in the same file. Providing NULL + as the mounts file closes the file. */ +static int +open_temp_exec_file_mnt (const char *mounts) +{ + static const char *last_mounts; + static FILE *last_mntent; + + if (mounts != last_mounts) + { + if (last_mntent) + endmntent (last_mntent); + + last_mounts = mounts; + + if (mounts) + last_mntent = setmntent (mounts, "r"); + else + last_mntent = NULL; + } + + if (!last_mntent) + return -1; + + for (;;) + { + int fd; + struct mntent mnt; + char buf[MAXPATHLEN * 3]; + + if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL) + return -1; + + if (hasmntopt (&mnt, "ro") + || hasmntopt (&mnt, "noexec") + || access (mnt.mnt_dir, W_OK)) + continue; + + fd = open_temp_exec_file_dir (mnt.mnt_dir); + + if (fd != -1) + return fd; + } +} +#endif /* HAVE_MNTENT */ + +/* Instructions to look for a location to hold a temporary file that + can be mapped in for execution. */ +static struct +{ + int (*func)(const char *); + const char *arg; + int repeat; +} open_temp_exec_file_opts[] = { + { open_temp_exec_file_env, "TMPDIR", 0 }, + { open_temp_exec_file_dir, "/tmp", 0 }, + { open_temp_exec_file_dir, "/var/tmp", 0 }, + { open_temp_exec_file_dir, "/dev/shm", 0 }, + { open_temp_exec_file_env, "HOME", 0 }, +#ifdef HAVE_MNTENT + { open_temp_exec_file_mnt, "/etc/mtab", 1 }, + { open_temp_exec_file_mnt, "/proc/mounts", 1 }, +#endif /* HAVE_MNTENT */ +}; + +/* Current index into open_temp_exec_file_opts. */ +static int open_temp_exec_file_opts_idx = 0; + +/* Reset a current multi-call func, then advances to the next entry. + If we're at the last, go back to the first and return nonzero, + otherwise return zero. */ +static int +open_temp_exec_file_opts_next (void) +{ + if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat) + open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL); + + open_temp_exec_file_opts_idx++; + if (open_temp_exec_file_opts_idx + == (sizeof (open_temp_exec_file_opts) + / sizeof (*open_temp_exec_file_opts))) + { + open_temp_exec_file_opts_idx = 0; + return 1; + } + + return 0; +} + +/* Return a file descriptor of a temporary zero-sized file in a + writable and executable filesystem. */ +static int +open_temp_exec_file (void) +{ + int fd; + + do + { + fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func + (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg); + + if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat + || fd == -1) + { + if (open_temp_exec_file_opts_next ()) + break; + } + } + while (fd == -1); + + return fd; +} + +/* Map in a chunk of memory from the temporary exec file into separate + locations in the virtual memory address space, one writable and one + executable. Returns the address of the writable portion, after + storing an offset to the corresponding executable portion at the + last word of the requested chunk. */ +static void * +dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset) +{ + void *ptr; + + if (execfd == -1) + { + open_temp_exec_file_opts_idx = 0; + retry_open: + execfd = open_temp_exec_file (); + if (execfd == -1) + return MFAIL; + } + + offset = execsize; + + if (ftruncate (execfd, offset + length)) + return MFAIL; + + flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS); + flags |= MAP_SHARED; + + ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC, + flags, execfd, offset); + if (ptr == MFAIL) + { + if (!offset) + { + close (execfd); + goto retry_open; + } + ftruncate (execfd, offset); + return MFAIL; + } + else if (!offset + && open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat) + open_temp_exec_file_opts_next (); + + start = mmap (start, length, prot, flags, execfd, offset); + + if (start == MFAIL) + { + munmap (ptr, length); + ftruncate (execfd, offset); + return start; + } + + mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start; + + execsize += length; + + return start; +} + +/* Map in a writable and executable chunk of memory if possible. + Failing that, fall back to dlmmap_locked. */ +static void * +dlmmap (void *start, size_t length, int prot, + int flags, int fd, off_t offset) +{ + void *ptr; + + assert (start == NULL && length % malloc_getpagesize == 0 + && prot == (PROT_READ | PROT_WRITE) + && flags == (MAP_PRIVATE | MAP_ANONYMOUS) + && fd == -1 && offset == 0); + +#if FFI_CLOSURE_TEST + printf ("mapping in %zi\n", length); +#endif + + if (execfd == -1 && is_emutramp_enabled ()) + { + ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset); + return ptr; + } + + if (execfd == -1 && !is_selinux_enabled ()) + { + ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset); + + if (ptr != MFAIL || (errno != EPERM && errno != EACCES)) + /* Cool, no need to mess with separate segments. */ + return ptr; + + /* If MREMAP_DUP is ever introduced and implemented, try mmap + with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with + MREMAP_DUP and prot at this point. */ + } + + if (execsize == 0 || execfd == -1) + { + pthread_mutex_lock (&open_temp_exec_file_mutex); + ptr = dlmmap_locked (start, length, prot, flags, offset); + pthread_mutex_unlock (&open_temp_exec_file_mutex); + + return ptr; + } + + return dlmmap_locked (start, length, prot, flags, offset); +} + +/* Release memory at the given address, as well as the corresponding + executable page if it's separate. */ +static int +dlmunmap (void *start, size_t length) +{ + /* We don't bother decreasing execsize or truncating the file, since + we can't quite tell whether we're unmapping the end of the file. + We don't expect frequent deallocation anyway. If we did, we + could locate pages in the file by writing to the pages being + deallocated and checking that the file contents change. + Yuck. */ + msegmentptr seg = segment_holding (gm, start); + void *code; + +#if FFI_CLOSURE_TEST + printf ("unmapping %zi\n", length); +#endif + + if (seg && (code = add_segment_exec_offset (start, seg)) != start) + { + int ret = munmap (code, length); + if (ret) + return ret; + } + + return munmap (start, length); +} + +#if FFI_CLOSURE_FREE_CODE +/* Return segment holding given code address. */ +static msegmentptr +segment_holding_code (mstate m, char* addr) +{ + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= add_segment_exec_offset (sp->base, sp) + && addr < add_segment_exec_offset (sp->base, sp) + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } +} +#endif + +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ + +/* Allocate a chunk of memory with the given size. Returns a pointer + to the writable address, and sets *CODE to the executable + corresponding virtual address. */ +void * +ffi_closure_alloc (size_t size, void **code) +{ + void *ptr; + + if (!code) + return NULL; + + ptr = dlmalloc (size); + + if (ptr) + { + msegmentptr seg = segment_holding (gm, ptr); + + *code = add_segment_exec_offset (ptr, seg); + } + + return ptr; +} + +/* Release a chunk of memory allocated with ffi_closure_alloc. If + FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the + writable or the executable address given. Otherwise, only the + writable address can be provided here. */ +void +ffi_closure_free (void *ptr) +{ +#if FFI_CLOSURE_FREE_CODE + msegmentptr seg = segment_holding_code (gm, ptr); + + if (seg) + ptr = sub_segment_exec_offset (ptr, seg); +#endif + + dlfree (ptr); +} + + +#if FFI_CLOSURE_TEST +/* Do some internal sanity testing to make sure allocation and + deallocation of pages are working as intended. */ +int main () +{ + void *p[3]; +#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0) +#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0) + GET (0, malloc_getpagesize / 2); + GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*)); + PUT (1); + GET (1, 2 * malloc_getpagesize); + GET (2, malloc_getpagesize / 2); + PUT (1); + PUT (0); + PUT (2); + return 0; +} +#endif /* FFI_CLOSURE_TEST */ +# else /* ! FFI_MMAP_EXEC_WRIT */ + +/* On many systems, memory returned by malloc is writable and + executable, so just use it. */ + +#include + +void * +ffi_closure_alloc (size_t size, void **code) +{ + if (!code) + return NULL; + + return *code = malloc (size); +} + +void +ffi_closure_free (void *ptr) +{ + free (ptr); +} + +# endif /* ! FFI_MMAP_EXEC_WRIT */ +#endif /* FFI_CLOSURES */ diff --git a/user/mpy/lib/libffi/src/cris/ffi.c b/user/mpy/lib/libffi/src/cris/ffi.c new file mode 100644 index 0000000..aaca5b1 --- /dev/null +++ b/user/mpy/lib/libffi/src/cris/ffi.c @@ -0,0 +1,386 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 1998 Cygnus Solutions + Copyright (c) 2004 Simon Posnjak + Copyright (c) 2005 Axis Communications AB + Copyright (C) 2007 Free Software Foundation, Inc. + + CRIS Foreign Function Interface + + 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 SIMON POSNJAK 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG) + +static ffi_status +initialize_aggregate_packed_struct (ffi_type * arg) +{ + ffi_type **ptr; + + FFI_ASSERT (arg != NULL); + + FFI_ASSERT (arg->elements != NULL); + FFI_ASSERT (arg->size == 0); + FFI_ASSERT (arg->alignment == 0); + + ptr = &(arg->elements[0]); + + while ((*ptr) != NULL) + { + if (((*ptr)->size == 0) + && (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK)) + return FFI_BAD_TYPEDEF; + + FFI_ASSERT (ffi_type_test ((*ptr))); + + arg->size += (*ptr)->size; + + arg->alignment = (arg->alignment > (*ptr)->alignment) ? + arg->alignment : (*ptr)->alignment; + + ptr++; + } + + if (arg->size == 0) + return FFI_BAD_TYPEDEF; + else + return FFI_OK; +} + +int +ffi_prep_args (char *stack, extended_cif * ecif) +{ + unsigned int i; + unsigned int struct_count = 0; + void **p_argv; + char *argp; + ffi_type **p_arg; + + argp = stack; + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); i--, p_arg++) + { + size_t z; + + switch ((*p_arg)->type) + { + case FFI_TYPE_STRUCT: + { + z = (*p_arg)->size; + if (z <= 4) + { + memcpy (argp, *p_argv, z); + z = 4; + } + else if (z <= 8) + { + memcpy (argp, *p_argv, z); + z = 8; + } + else + { + unsigned int uiLocOnStack; + z = sizeof (void *); + uiLocOnStack = 4 * ecif->cif->nargs + struct_count; + struct_count = struct_count + (*p_arg)->size; + *(unsigned int *) argp = + (unsigned int) (UINT32 *) (stack + uiLocOnStack); + memcpy ((stack + uiLocOnStack), *p_argv, (*p_arg)->size); + } + break; + } + default: + z = (*p_arg)->size; + if (z < sizeof (int)) + { + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = + (unsigned int) *(UINT8 *) (*p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = + (unsigned int) *(UINT16 *) (*p_argv); + break; + + default: + FFI_ASSERT (0); + } + z = sizeof (int); + } + else if (z == sizeof (int)) + *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv); + else + memcpy (argp, *p_argv, z); + break; + } + p_argv++; + argp += z; + } + + return (struct_count); +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_core (ffi_cif * cif, + ffi_abi abi, unsigned int isvariadic, + unsigned int nfixedargs, unsigned int ntotalargs, + ffi_type * rtype, ffi_type ** atypes) +{ + unsigned bytes = 0; + unsigned int i; + ffi_type **ptr; + + FFI_ASSERT (cif != NULL); + FFI_ASSERT((!isvariadic) || (nfixedargs >= 1)); + FFI_ASSERT(nfixedargs <= ntotalargs); + FFI_ASSERT (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI); + + cif->abi = abi; + cif->arg_types = atypes; + cif->nargs = ntotalargs; + cif->rtype = rtype; + + cif->flags = 0; + + if ((cif->rtype->size == 0) + && (initialize_aggregate_packed_struct (cif->rtype) != FFI_OK)) + return FFI_BAD_TYPEDEF; + + FFI_ASSERT_VALID_TYPE (cif->rtype); + + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) + { + if (((*ptr)->size == 0) + && (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK)) + return FFI_BAD_TYPEDEF; + + FFI_ASSERT_VALID_TYPE (*ptr); + + if (((*ptr)->alignment - 1) & bytes) + bytes = ALIGN (bytes, (*ptr)->alignment); + if ((*ptr)->type == FFI_TYPE_STRUCT) + { + if ((*ptr)->size > 8) + { + bytes += (*ptr)->size; + bytes += sizeof (void *); + } + else + { + if ((*ptr)->size > 4) + bytes += 8; + else + bytes += 4; + } + } + else + bytes += STACK_ARG_SIZE ((*ptr)->size); + } + + cif->bytes = bytes; + + return ffi_prep_cif_machdep (cif); +} + +ffi_status +ffi_prep_cif_machdep (ffi_cif * cif) +{ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = (unsigned) cif->rtype->type; + break; + + default: + cif->flags = FFI_TYPE_INT; + break; + } + + return FFI_OK; +} + +extern void ffi_call_SYSV (int (*)(char *, extended_cif *), + extended_cif *, + unsigned, unsigned, unsigned *, void (*fn) ()) + __attribute__ ((__visibility__ ("hidden"))); + +void +ffi_call (ffi_cif * cif, void (*fn) (), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca (cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV (ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + break; + default: + FFI_ASSERT (0); + break; + } +} + +/* Because the following variables are not exported outside libffi, we + mark them hidden. */ + +/* Assembly code for the jump stub. */ +extern const char ffi_cris_trampoline_template[] + __attribute__ ((__visibility__ ("hidden"))); + +/* Offset into ffi_cris_trampoline_template of where to put the + ffi_prep_closure_inner function. */ +extern const int ffi_cris_trampoline_fn_offset + __attribute__ ((__visibility__ ("hidden"))); + +/* Offset into ffi_cris_trampoline_template of where to put the + closure data. */ +extern const int ffi_cris_trampoline_closure_offset + __attribute__ ((__visibility__ ("hidden"))); + +/* This function is sibling-called (jumped to) by the closure + trampoline. We get R10..R13 at PARAMS[0..3] and a copy of [SP] at + PARAMS[4] to simplify handling of a straddling parameter. A copy + of R9 is at PARAMS[5] and SP at PARAMS[6]. These parameters are + put at the appropriate place in CLOSURE which is then executed and + the return value is passed back to the caller. */ + +static unsigned long long +ffi_prep_closure_inner (void **params, ffi_closure* closure) +{ + char *register_args = (char *) params; + void *struct_ret = params[5]; + char *stack_args = params[6]; + char *ptr = register_args; + ffi_cif *cif = closure->cif; + ffi_type **arg_types = cif->arg_types; + + /* Max room needed is number of arguments as 64-bit values. */ + void **avalue = alloca (closure->cif->nargs * sizeof(void *)); + int i; + int doing_regs; + long long llret = 0; + + /* Find the address of each argument. */ + for (i = 0, doing_regs = 1; i < cif->nargs; i++) + { + /* Types up to and including 8 bytes go by-value. */ + if (arg_types[i]->size <= 4) + { + avalue[i] = ptr; + ptr += 4; + } + else if (arg_types[i]->size <= 8) + { + avalue[i] = ptr; + ptr += 8; + } + else + { + FFI_ASSERT (arg_types[i]->type == FFI_TYPE_STRUCT); + + /* Passed by-reference, so copy the pointer. */ + avalue[i] = *(void **) ptr; + ptr += 4; + } + + /* If we've handled more arguments than fit in registers, start + looking at the those passed on the stack. Step over the + first one if we had a straddling parameter. */ + if (doing_regs && ptr >= register_args + 4*4) + { + ptr = stack_args + ((ptr > register_args + 4*4) ? 4 : 0); + doing_regs = 0; + } + } + + /* Invoke the closure. */ + (closure->fun) (cif, + + cif->rtype->type == FFI_TYPE_STRUCT + /* The caller allocated space for the return + structure, and passed a pointer to this space in + R9. */ + ? struct_ret + + /* We take advantage of being able to ignore that + the high part isn't set if the return value is + not in R10:R11, but in R10 only. */ + : (void *) &llret, + + avalue, closure->user_data); + + return llret; +} + +/* API function: Prepare the trampoline. */ + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif *, void *, void **, void*), + void *user_data, + void *codeloc) +{ + void *innerfn = ffi_prep_closure_inner; + FFI_ASSERT (cif->abi == FFI_SYSV); + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + memcpy (closure->tramp, ffi_cris_trampoline_template, + FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE); + memcpy (closure->tramp + ffi_cris_trampoline_fn_offset, + &innerfn, sizeof (void *)); + memcpy (closure->tramp + ffi_cris_trampoline_closure_offset, + &codeloc, sizeof (void *)); + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/cris/ffitarget.h b/user/mpy/lib/libffi/src/cris/ffitarget.h new file mode 100644 index 0000000..b837e97 --- /dev/null +++ b/user/mpy/lib/libffi/src/cris/ffitarget.h @@ -0,0 +1,56 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for CRIS. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE 36 +#define FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE (7*4) +#define FFI_TRAMPOLINE_SIZE \ + (FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE + FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE) +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/cris/sysv.S b/user/mpy/lib/libffi/src/cris/sysv.S new file mode 100644 index 0000000..79abaee --- /dev/null +++ b/user/mpy/lib/libffi/src/cris/sysv.S @@ -0,0 +1,215 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2004 Simon Posnjak + Copyright (c) 2005 Axis Communications AB + + CRIS Foreign Function Interface + + 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 SIMON POSNJAK 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#define CONCAT(x,y) x ## y +#define XCONCAT(x,y) CONCAT (x, y) +#define L(x) XCONCAT (__USER_LABEL_PREFIX__, x) + + .text + + ;; OK, when we get called we should have this (according to + ;; AXIS ETRAX 100LX Programmer's Manual chapter 6.3). + ;; + ;; R10: ffi_prep_args (func. pointer) + ;; R11: &ecif + ;; R12: cif->bytes + ;; R13: fig->flags + ;; sp+0: ecif.rvalue + ;; sp+4: fn (function pointer to the function that we need to call) + + .globl L(ffi_call_SYSV) + .type L(ffi_call_SYSV),@function + .hidden L(ffi_call_SYSV) + +L(ffi_call_SYSV): + ;; Save the regs to the stack. + push $srp + ;; Used for stack pointer saving. + push $r6 + ;; Used for function address pointer. + push $r7 + ;; Used for stack pointer saving. + push $r8 + ;; We save fig->flags to stack we will need them after we + ;; call The Function. + push $r13 + + ;; Saving current stack pointer. + move.d $sp,$r8 + move.d $sp,$r6 + + ;; Move address of ffi_prep_args to r13. + move.d $r10,$r13 + + ;; Make room on the stack for the args of fn. + sub.d $r12,$sp + + ;; Function void ffi_prep_args(char *stack, extended_cif *ecif) parameters are: + ;; r10 <-- stack pointer + ;; r11 <-- &ecif (already there) + move.d $sp,$r10 + + ;; Call the function. + jsr $r13 + + ;; Save the size of the structures which are passed on stack. + move.d $r10,$r7 + + ;; Move first four args in to r10..r13. + move.d [$sp+0],$r10 + move.d [$sp+4],$r11 + move.d [$sp+8],$r12 + move.d [$sp+12],$r13 + + ;; Adjust the stack and check if any parameters are given on stack. + addq 16,$sp + sub.d $r7,$r6 + cmp.d $sp,$r6 + + bpl go_on + nop + +go_on_no_params_on_stack: + move.d $r6,$sp + +go_on: + ;; Discover if we need to put rval address in to r9. + move.d [$r8+0],$r7 + cmpq FFI_TYPE_STRUCT,$r7 + bne call_now + nop + + ;; Move rval address to $r9. + move.d [$r8+20],$r9 + +call_now: + ;; Move address of The Function in to r7. + move.d [$r8+24],$r7 + + ;; Call The Function. + jsr $r7 + + ;; Reset stack. + move.d $r8,$sp + + ;; Load rval type (fig->flags) in to r13. + pop $r13 + + ;; Detect rval type. + cmpq FFI_TYPE_VOID,$r13 + beq epilogue + + cmpq FFI_TYPE_STRUCT,$r13 + beq epilogue + + cmpq FFI_TYPE_DOUBLE,$r13 + beq return_double_or_longlong + + cmpq FFI_TYPE_UINT64,$r13 + beq return_double_or_longlong + + cmpq FFI_TYPE_SINT64,$r13 + beq return_double_or_longlong + nop + + ;; Just return the 32 bit value. + ba return + nop + +return_double_or_longlong: + ;; Load half of the rval to r10 and the other half to r11. + move.d [$sp+16],$r13 + move.d $r10,[$r13] + addq 4,$r13 + move.d $r11,[$r13] + ba epilogue + nop + +return: + ;; Load the rval to r10. + move.d [$sp+16],$r13 + move.d $r10,[$r13] + +epilogue: + pop $r8 + pop $r7 + pop $r6 + Jump [$sp+] + + .size ffi_call_SYSV,.-ffi_call_SYSV + +/* Save R10..R13 into an array, somewhat like varargs. Copy the next + argument too, to simplify handling of any straddling parameter. + Save R9 and SP after those. Jump to function handling the rest. + Since this is a template, copied and the main function filled in by + the user. */ + + .globl L(ffi_cris_trampoline_template) + .type L(ffi_cris_trampoline_template),@function + .hidden L(ffi_cris_trampoline_template) + +L(ffi_cris_trampoline_template): +0: + /* The value we get for "PC" is right after the prefix instruction, + two bytes from the beginning, i.e. 0b+2. */ + move.d $r10,[$pc+2f-(0b+2)] + move.d $pc,$r10 +1: + addq 2f-1b+4,$r10 + move.d $r11,[$r10+] + move.d $r12,[$r10+] + move.d $r13,[$r10+] + move.d [$sp],$r11 + move.d $r11,[$r10+] + move.d $r9,[$r10+] + move.d $sp,[$r10+] + subq FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE,$r10 + move.d 0,$r11 +3: + jump 0 +2: + .size ffi_cris_trampoline_template,.-0b + +/* This macro create a constant usable as "extern const int \name" in + C from within libffi, when \name has no prefix decoration. */ + + .macro const name,value + .globl \name + .type \name,@object + .hidden \name +\name: + .dword \value + .size \name,4 + .endm + +/* Constants for offsets within the trampoline. We could do this with + just symbols, avoiding memory contents and memory accesses, but the + C usage code would look a bit stranger. */ + + const L(ffi_cris_trampoline_fn_offset),2b-4-0b + const L(ffi_cris_trampoline_closure_offset),3b-4-0b diff --git a/user/mpy/lib/libffi/src/debug.c b/user/mpy/lib/libffi/src/debug.c new file mode 100644 index 0000000..f3172b1 --- /dev/null +++ b/user/mpy/lib/libffi/src/debug.c @@ -0,0 +1,64 @@ +/* ----------------------------------------------------------------------- + debug.c - Copyright (c) 1996 Red Hat, Inc. + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include + +/* General debugging routines */ + +void ffi_stop_here(void) +{ + /* This function is only useful for debugging purposes. + Place a breakpoint on ffi_stop_here to be notified of + significant events. */ +} + +/* This function should only be called via the FFI_ASSERT() macro */ + +void ffi_assert(char *expr, char *file, int line) +{ + fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line); + ffi_stop_here(); + abort(); +} + +/* Perform a sanity check on an ffi_type structure */ + +void ffi_type_test(ffi_type *a, char *file, int line) +{ + FFI_ASSERT_AT(a != NULL, file, line); + + FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line); + FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line); + FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line); + FFI_ASSERT_AT((a->type != FFI_TYPE_STRUCT && a->type != FFI_TYPE_COMPLEX) + || a->elements != NULL, file, line); + FFI_ASSERT_AT(a->type != FFI_TYPE_COMPLEX + || (a->elements != NULL + && a->elements[0] != NULL && a->elements[1] == NULL), + file, line); + +} diff --git a/user/mpy/lib/libffi/src/dlmalloc.c b/user/mpy/lib/libffi/src/dlmalloc.c new file mode 100644 index 0000000..7e4ea83 --- /dev/null +++ b/user/mpy/lib/libffi/src/dlmalloc.c @@ -0,0 +1,5161 @@ +/* + This is a version (aka dlmalloc) of malloc/free/realloc written by + Doug Lea and released to the public domain, as explained at + http://creativecommons.org/licenses/publicdomain. Send questions, + comments, complaints, performance data, etc to dl@cs.oswego.edu + +* Version 2.8.3 Thu Sep 22 11:16:15 2005 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at + ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + +* Quickstart + + This library is all in one file to simplify the most common usage: + ftp it, compile it (-O3), and link it into another program. All of + the compile-time options default to reasonable values for use on + most platforms. You might later want to step through various + compile-time and dynamic tuning options. + + For convenience, an include file for code using this malloc is at: + ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.3.h + You don't really need this .h file unless you call functions not + defined in your system include files. The .h file contains only the + excerpts from this file needed for using this malloc on ANSI C/C++ + systems, so long as you haven't changed compile-time options about + naming and tuning parameters. If you do, then you can create your + own malloc.h that does include all settings by cutting at the point + indicated below. Note that you may already by default be using a C + library containing a malloc that is based on some version of this + malloc (for example in linux). You might still want to use the one + in this file to customize settings or to avoid overheads associated + with library versions. + +* Vital statistics: + + Supported pointer/size_t representation: 4 or 8 bytes + size_t MUST be an unsigned type of the same width as + pointers. (If you are using an ancient system that declares + size_t as a signed type, or need it to be a different width + than pointers, you can use a previous release of this malloc + (e.g. 2.7.2) supporting these.) + + Alignment: 8 bytes (default) + This suffices for nearly all current machines and C compilers. + However, you can define MALLOC_ALIGNMENT to be wider than this + if necessary (up to 128bytes), at the expense of using more space. + + Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) + 8 or 16 bytes (if 8byte sizes) + Each malloced chunk has a hidden word of overhead holding size + and status information, and additional cross-check word + if FOOTERS is defined. + + Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) + 8-byte ptrs: 32 bytes (including overhead) + + Even a request for zero bytes (i.e., malloc(0)) returns a + pointer to something of the minimum allocatable size. + The maximum overhead wastage (i.e., number of extra bytes + allocated than were requested in malloc) is less than or equal + to the minimum size, except for requests >= mmap_threshold that + are serviced via mmap(), where the worst case wastage is about + 32 bytes plus the remainder from a system page (the minimal + mmap unit); typically 4096 or 8192 bytes. + + Security: static-safe; optionally more or less + The "security" of malloc refers to the ability of malicious + code to accentuate the effects of errors (for example, freeing + space that is not currently malloc'ed or overwriting past the + ends of chunks) in code that calls malloc. This malloc + guarantees not to modify any memory locations below the base of + heap, i.e., static variables, even in the presence of usage + errors. The routines additionally detect most improper frees + and reallocs. All this holds as long as the static bookkeeping + for malloc itself is not corrupted by some other means. This + is only one aspect of security -- these checks do not, and + cannot, detect all possible programming errors. + + If FOOTERS is defined nonzero, then each allocated chunk + carries an additional check word to verify that it was malloced + from its space. These check words are the same within each + execution of a program using malloc, but differ across + executions, so externally crafted fake chunks cannot be + freed. This improves security by rejecting frees/reallocs that + could corrupt heap memory, in addition to the checks preventing + writes to statics that are always on. This may further improve + security at the expense of time and space overhead. (Note that + FOOTERS may also be worth using with MSPACES.) + + By default detected errors cause the program to abort (calling + "abort()"). You can override this to instead proceed past + errors by defining PROCEED_ON_ERROR. In this case, a bad free + has no effect, and a malloc that encounters a bad address + caused by user overwrites will ignore the bad address by + dropping pointers and indices to all known memory. This may + be appropriate for programs that should continue if at all + possible in the face of programming errors, although they may + run out of memory because dropped memory is never reclaimed. + + If you don't like either of these options, you can define + CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything + else. And if if you are sure that your program using malloc has + no errors or vulnerabilities, you can define INSECURE to 1, + which might (or might not) provide a small performance improvement. + + Thread-safety: NOT thread-safe unless USE_LOCKS defined + When USE_LOCKS is defined, each public call to malloc, free, + etc is surrounded with either a pthread mutex or a win32 + spinlock (depending on WIN32). This is not especially fast, and + can be a major bottleneck. It is designed only to provide + minimal protection in concurrent environments, and to provide a + basis for extensions. If you are using malloc in a concurrent + program, consider instead using ptmalloc, which is derived from + a version of this malloc. (See http://www.malloc.de). + + System requirements: Any combination of MORECORE and/or MMAP/MUNMAP + This malloc can use unix sbrk or any emulation (invoked using + the CALL_MORECORE macro) and/or mmap/munmap or any emulation + (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system + memory. On most unix systems, it tends to work best if both + MORECORE and MMAP are enabled. On Win32, it uses emulations + based on VirtualAlloc. It also uses common C library functions + like memset. + + Compliance: I believe it is compliant with the Single Unix Specification + (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably + others as well. + +* Overview of algorithms + + This is not the fastest, most space-conserving, most portable, or + most tunable malloc ever written. However it is among the fastest + while also being among the most space-conserving, portable and + tunable. Consistent balance across these factors results in a good + general-purpose allocator for malloc-intensive programs. + + In most ways, this malloc is a best-fit allocator. Generally, it + chooses the best-fitting existing chunk for a request, with ties + broken in approximately least-recently-used order. (This strategy + normally maintains low fragmentation.) However, for requests less + than 256bytes, it deviates from best-fit when there is not an + exactly fitting available chunk by preferring to use space adjacent + to that used for the previous small request, as well as by breaking + ties in approximately most-recently-used order. (These enhance + locality of series of small allocations.) And for very large requests + (>= 256Kb by default), it relies on system memory mapping + facilities, if supported. (This helps avoid carrying around and + possibly fragmenting memory used only for large chunks.) + + All operations (except malloc_stats and mallinfo) have execution + times that are bounded by a constant factor of the number of bits in + a size_t, not counting any clearing in calloc or copying in realloc, + or actions surrounding MORECORE and MMAP that have times + proportional to the number of non-contiguous regions returned by + system allocation routines, which is often just 1. + + The implementation is not very modular and seriously overuses + macros. Perhaps someday all C compilers will do as good a job + inlining modular code as can now be done by brute-force expansion, + but now, enough of them seem not to. + + Some compilers issue a lot of warnings about code that is + dead/unreachable only on some platforms, and also about intentional + uses of negation on unsigned types. All known cases of each can be + ignored. + + For a longer but out of date high-level description, see + http://gee.cs.oswego.edu/dl/html/malloc.html + +* MSPACES + If MSPACES is defined, then in addition to malloc, free, etc., + this file also defines mspace_malloc, mspace_free, etc. These + are versions of malloc routines that take an "mspace" argument + obtained using create_mspace, to control all internal bookkeeping. + If ONLY_MSPACES is defined, only these versions are compiled. + So if you would like to use this allocator for only some allocations, + and your system malloc for others, you can compile with + ONLY_MSPACES and then do something like... + static mspace mymspace = create_mspace(0,0); // for example + #define mymalloc(bytes) mspace_malloc(mymspace, bytes) + + (Note: If you only need one instance of an mspace, you can instead + use "USE_DL_PREFIX" to relabel the global malloc.) + + You can similarly create thread-local allocators by storing + mspaces as thread-locals. For example: + static __thread mspace tlms = 0; + void* tlmalloc(size_t bytes) { + if (tlms == 0) tlms = create_mspace(0, 0); + return mspace_malloc(tlms, bytes); + } + void tlfree(void* mem) { mspace_free(tlms, mem); } + + Unless FOOTERS is defined, each mspace is completely independent. + You cannot allocate from one and free to another (although + conformance is only weakly checked, so usage errors are not always + caught). If FOOTERS is defined, then each chunk carries around a tag + indicating its originating mspace, and frees are directed to their + originating spaces. + + ------------------------- Compile-time options --------------------------- + +Be careful in setting #define values for numerical constants of type +size_t. On some systems, literal values are not automatically extended +to size_t precision unless they are explicitly casted. + +WIN32 default: defined if _WIN32 defined + Defining WIN32 sets up defaults for MS environment and compilers. + Otherwise defaults are for unix. + +MALLOC_ALIGNMENT default: (size_t)8 + Controls the minimum alignment for malloc'ed chunks. It must be a + power of two and at least 8, even on machines for which smaller + alignments would suffice. It may be defined as larger than this + though. Note however that code and data structures are optimized for + the case of 8-byte alignment. + +MSPACES default: 0 (false) + If true, compile in support for independent allocation spaces. + This is only supported if HAVE_MMAP is true. + +ONLY_MSPACES default: 0 (false) + If true, only compile in mspace versions, not regular versions. + +USE_LOCKS default: 0 (false) + Causes each call to each public routine to be surrounded with + pthread or WIN32 mutex lock/unlock. (If set true, this can be + overridden on a per-mspace basis for mspace versions.) + +FOOTERS default: 0 + If true, provide extra checking and dispatching by placing + information in the footers of allocated chunks. This adds + space and time overhead. + +INSECURE default: 0 + If true, omit checks for usage errors and heap space overwrites. + +USE_DL_PREFIX default: NOT defined + Causes compiler to prefix all public routines with the string 'dl'. + This can be useful when you only want to use this malloc in one part + of a program, using your regular system malloc elsewhere. + +ABORT default: defined as abort() + Defines how to abort on failed checks. On most systems, a failed + check cannot die with an "assert" or even print an informative + message, because the underlying print routines in turn call malloc, + which will fail again. Generally, the best policy is to simply call + abort(). It's not very useful to do more than this because many + errors due to overwriting will show up as address faults (null, odd + addresses etc) rather than malloc-triggered checks, so will also + abort. Also, most compilers know that abort() does not return, so + can better optimize code conditionally calling it. + +PROCEED_ON_ERROR default: defined as 0 (false) + Controls whether detected bad addresses cause them to bypassed + rather than aborting. If set, detected bad arguments to free and + realloc are ignored. And all bookkeeping information is zeroed out + upon a detected overwrite of freed heap space, thus losing the + ability to ever return it from malloc again, but enabling the + application to proceed. If PROCEED_ON_ERROR is defined, the + static variable malloc_corruption_error_count is compiled in + and can be examined to see if errors have occurred. This option + generates slower code than the default abort policy. + +DEBUG default: NOT defined + The DEBUG setting is mainly intended for people trying to modify + this code or diagnose problems when porting to new platforms. + However, it may also be able to better isolate user errors than just + using runtime checks. The assertions in the check routines spell + out in more detail the assumptions and invariants underlying the + algorithms. The checking is fairly extensive, and will slow down + execution noticeably. Calling malloc_stats or mallinfo with DEBUG + set will attempt to check every non-mmapped allocated and free chunk + in the course of computing the summaries. + +ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) + Debugging assertion failures can be nearly impossible if your + version of the assert macro causes malloc to be called, which will + lead to a cascade of further failures, blowing the runtime stack. + ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), + which will usually make debugging easier. + +MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 + The action to take before "return 0" when malloc fails to be able to + return memory because there is none available. + +HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES + True if this system supports sbrk or an emulation of it. + +MORECORE default: sbrk + The name of the sbrk-style system routine to call to obtain more + memory. See below for guidance on writing custom MORECORE + functions. The type of the argument to sbrk/MORECORE varies across + systems. It cannot be size_t, because it supports negative + arguments, so it is normally the signed type of the same width as + size_t (sometimes declared as "intptr_t"). It doesn't much matter + though. Internally, we only call it with arguments less than half + the max value of a size_t, which should work across all reasonable + possibilities, although sometimes generating compiler warnings. See + near the end of this file for guidelines for creating a custom + version of MORECORE. + +MORECORE_CONTIGUOUS default: 1 (true) + If true, take advantage of fact that consecutive calls to MORECORE + with positive arguments always return contiguous increasing + addresses. This is true of unix sbrk. It does not hurt too much to + set it true anyway, since malloc copes with non-contiguities. + Setting it false when definitely non-contiguous saves time + and possibly wasted space it would take to discover this though. + +MORECORE_CANNOT_TRIM default: NOT defined + True if MORECORE cannot release space back to the system when given + negative arguments. This is generally necessary only if you are + using a hand-crafted MORECORE function that cannot handle negative + arguments. + +HAVE_MMAP default: 1 (true) + True if this system supports mmap or an emulation of it. If so, and + HAVE_MORECORE is not true, MMAP is used for all system + allocation. If set and HAVE_MORECORE is true as well, MMAP is + primarily used to directly allocate very large blocks. It is also + used as a backup strategy in cases where MORECORE fails to provide + space from system. Note: A single call to MUNMAP is assumed to be + able to unmap memory that may have be allocated using multiple calls + to MMAP, so long as they are adjacent. + +HAVE_MREMAP default: 1 on linux, else 0 + If true realloc() uses mremap() to re-allocate large blocks and + extend or shrink allocation spaces. + +MMAP_CLEARS default: 1 on unix + True if mmap clears memory so calloc doesn't need to. This is true + for standard unix mmap using /dev/zero. + +USE_BUILTIN_FFS default: 0 (i.e., not used) + Causes malloc to use the builtin ffs() function to compute indices. + Some compilers may recognize and intrinsify ffs to be faster than the + supplied C version. Also, the case of x86 using gcc is special-cased + to an asm instruction, so is already as fast as it can be, and so + this setting has no effect. (On most x86s, the asm version is only + slightly faster than the C version.) + +malloc_getpagesize default: derive from system includes, or 4096. + The system page size. To the extent possible, this malloc manages + memory from the system in page-size units. This may be (and + usually is) a function rather than a constant. This is ignored + if WIN32, where page size is determined using getSystemInfo during + initialization. + +USE_DEV_RANDOM default: 0 (i.e., not used) + Causes malloc to use /dev/random to initialize secure magic seed for + stamping footers. Otherwise, the current time is used. + +NO_MALLINFO default: 0 + If defined, don't compile "mallinfo". This can be a simple way + of dealing with mismatches between system declarations and + those in this file. + +MALLINFO_FIELD_TYPE default: size_t + The type of the fields in the mallinfo struct. This was originally + defined as "int" in SVID etc, but is more usefully defined as + size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set + +REALLOC_ZERO_BYTES_FREES default: not defined + This should be set if a call to realloc with zero bytes should + be the same as a call to free. Some people think it should. Otherwise, + since this malloc returns a unique pointer for malloc(0), so does + realloc(p, 0). + +LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H +LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H +LACKS_STDLIB_H default: NOT defined unless on WIN32 + Define these if your system does not have these header files. + You might need to manually insert some of the declarations they provide. + +DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, + system_info.dwAllocationGranularity in WIN32, + otherwise 64K. + Also settable using mallopt(M_GRANULARITY, x) + The unit for allocating and deallocating memory from the system. On + most systems with contiguous MORECORE, there is no reason to + make this more than a page. However, systems with MMAP tend to + either require or encourage larger granularities. You can increase + this value to prevent system allocation functions to be called so + often, especially if they are slow. The value must be at least one + page and must be a power of two. Setting to 0 causes initialization + to either page size or win32 region size. (Note: In previous + versions of malloc, the equivalent of this option was called + "TOP_PAD") + +DEFAULT_TRIM_THRESHOLD default: 2MB + Also settable using mallopt(M_TRIM_THRESHOLD, x) + The maximum amount of unused top-most memory to keep before + releasing via malloc_trim in free(). Automatic trimming is mainly + useful in long-lived programs using contiguous MORECORE. Because + trimming via sbrk can be slow on some systems, and can sometimes be + wasteful (in cases where programs immediately afterward allocate + more large chunks) the value should be high enough so that your + overall system performance would improve by releasing this much + memory. As a rough guide, you might set to a value close to the + average size of a process (program) running on your system. + Releasing this much memory would allow such a process to run in + memory. Generally, it is worth tuning trim thresholds when a + program undergoes phases where several large chunks are allocated + and released in ways that can reuse each other's storage, perhaps + mixed with phases where there are no such chunks at all. The trim + value must be greater than page size to have any useful effect. To + disable trimming completely, you can set to MAX_SIZE_T. Note that the trick + some people use of mallocing a huge space and then freeing it at + program startup, in an attempt to reserve system memory, doesn't + have the intended effect under automatic trimming, since that memory + will immediately be returned to the system. + +DEFAULT_MMAP_THRESHOLD default: 256K + Also settable using mallopt(M_MMAP_THRESHOLD, x) + The request size threshold for using MMAP to directly service a + request. Requests of at least this size that cannot be allocated + using already-existing space will be serviced via mmap. (If enough + normal freed space already exists it is used instead.) Using mmap + segregates relatively large chunks of memory so that they can be + individually obtained and released from the host system. A request + serviced through mmap is never reused by any other request (at least + not directly; the system may just so happen to remap successive + requests to the same locations). Segregating space in this way has + the benefits that: Mmapped space can always be individually released + back to the system, which helps keep the system level memory demands + of a long-lived program low. Also, mapped memory doesn't become + `locked' between other chunks, as can happen with normally allocated + chunks, which means that even trimming via malloc_trim would not + release them. However, it has the disadvantage that the space + cannot be reclaimed, consolidated, and then used to service later + requests, as happens with normal chunks. The advantages of mmap + nearly always outweigh disadvantages for "large" chunks, but the + value of "large" may vary across systems. The default is an + empirically derived value that works well in most systems. You can + disable mmap by setting to MAX_SIZE_T. + +*/ + +#ifndef WIN32 +#ifdef _WIN32 +#define WIN32 1 +#endif /* _WIN32 */ +#endif /* WIN32 */ +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#define HAVE_MMAP 1 +#define HAVE_MORECORE 0 +#define LACKS_UNISTD_H +#define LACKS_SYS_PARAM_H +#define LACKS_SYS_MMAN_H +#define LACKS_STRING_H +#define LACKS_STRINGS_H +#define LACKS_SYS_TYPES_H +#define LACKS_ERRNO_H +#define MALLOC_FAILURE_ACTION +#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */ +#endif /* WIN32 */ + +#ifdef __OS2__ +#define INCL_DOS +#include +#define HAVE_MMAP 1 +#define HAVE_MORECORE 0 +#define LACKS_SYS_MMAN_H +#endif /* __OS2__ */ + +#if defined(DARWIN) || defined(_DARWIN) +/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ +#ifndef HAVE_MORECORE +#define HAVE_MORECORE 0 +#define HAVE_MMAP 1 +#endif /* HAVE_MORECORE */ +#endif /* DARWIN */ + +#ifndef LACKS_SYS_TYPES_H +#include /* For size_t */ +#endif /* LACKS_SYS_TYPES_H */ + +/* The maximum possible size_t value has all bits set */ +#define MAX_SIZE_T (~(size_t)0) + +#ifndef ONLY_MSPACES +#define ONLY_MSPACES 0 +#endif /* ONLY_MSPACES */ +#ifndef MSPACES +#if ONLY_MSPACES +#define MSPACES 1 +#else /* ONLY_MSPACES */ +#define MSPACES 0 +#endif /* ONLY_MSPACES */ +#endif /* MSPACES */ +#ifndef MALLOC_ALIGNMENT +#define MALLOC_ALIGNMENT ((size_t)8U) +#endif /* MALLOC_ALIGNMENT */ +#ifndef FOOTERS +#define FOOTERS 0 +#endif /* FOOTERS */ +#ifndef ABORT +#define ABORT abort() +#endif /* ABORT */ +#ifndef ABORT_ON_ASSERT_FAILURE +#define ABORT_ON_ASSERT_FAILURE 1 +#endif /* ABORT_ON_ASSERT_FAILURE */ +#ifndef PROCEED_ON_ERROR +#define PROCEED_ON_ERROR 0 +#endif /* PROCEED_ON_ERROR */ +#ifndef USE_LOCKS +#define USE_LOCKS 0 +#endif /* USE_LOCKS */ +#ifndef INSECURE +#define INSECURE 0 +#endif /* INSECURE */ +#ifndef HAVE_MMAP +#define HAVE_MMAP 1 +#endif /* HAVE_MMAP */ +#ifndef MMAP_CLEARS +#define MMAP_CLEARS 1 +#endif /* MMAP_CLEARS */ +#ifndef HAVE_MREMAP +#ifdef linux +#define HAVE_MREMAP 1 +#else /* linux */ +#define HAVE_MREMAP 0 +#endif /* linux */ +#endif /* HAVE_MREMAP */ +#ifndef MALLOC_FAILURE_ACTION +#define MALLOC_FAILURE_ACTION errno = ENOMEM; +#endif /* MALLOC_FAILURE_ACTION */ +#ifndef HAVE_MORECORE +#if ONLY_MSPACES +#define HAVE_MORECORE 0 +#else /* ONLY_MSPACES */ +#define HAVE_MORECORE 1 +#endif /* ONLY_MSPACES */ +#endif /* HAVE_MORECORE */ +#if !HAVE_MORECORE +#define MORECORE_CONTIGUOUS 0 +#else /* !HAVE_MORECORE */ +#ifndef MORECORE +#define MORECORE sbrk +#endif /* MORECORE */ +#ifndef MORECORE_CONTIGUOUS +#define MORECORE_CONTIGUOUS 1 +#endif /* MORECORE_CONTIGUOUS */ +#endif /* HAVE_MORECORE */ +#ifndef DEFAULT_GRANULARITY +#if MORECORE_CONTIGUOUS +#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ +#else /* MORECORE_CONTIGUOUS */ +#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) +#endif /* MORECORE_CONTIGUOUS */ +#endif /* DEFAULT_GRANULARITY */ +#ifndef DEFAULT_TRIM_THRESHOLD +#ifndef MORECORE_CANNOT_TRIM +#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) +#else /* MORECORE_CANNOT_TRIM */ +#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T +#endif /* MORECORE_CANNOT_TRIM */ +#endif /* DEFAULT_TRIM_THRESHOLD */ +#ifndef DEFAULT_MMAP_THRESHOLD +#if HAVE_MMAP +#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) +#else /* HAVE_MMAP */ +#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* DEFAULT_MMAP_THRESHOLD */ +#ifndef USE_BUILTIN_FFS +#define USE_BUILTIN_FFS 0 +#endif /* USE_BUILTIN_FFS */ +#ifndef USE_DEV_RANDOM +#define USE_DEV_RANDOM 0 +#endif /* USE_DEV_RANDOM */ +#ifndef NO_MALLINFO +#define NO_MALLINFO 0 +#endif /* NO_MALLINFO */ +#ifndef MALLINFO_FIELD_TYPE +#define MALLINFO_FIELD_TYPE size_t +#endif /* MALLINFO_FIELD_TYPE */ + +/* + mallopt tuning options. SVID/XPG defines four standard parameter + numbers for mallopt, normally defined in malloc.h. None of these + are used in this malloc, so setting them has no effect. But this + malloc does support the following options. +*/ + +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) + +/* ------------------------ Mallinfo declarations ------------------------ */ + +#if !NO_MALLINFO +/* + This version of malloc supports the standard SVID/XPG mallinfo + routine that returns a struct containing usage properties and + statistics. It should work on any system that has a + /usr/include/malloc.h defining struct mallinfo. The main + declaration needed is the mallinfo struct that is returned (by-copy) + by mallinfo(). The malloinfo struct contains a bunch of fields that + are not even meaningful in this version of malloc. These fields are + are instead filled by mallinfo() with other numbers that might be of + interest. + + HAVE_USR_INCLUDE_MALLOC_H should be set if you have a + /usr/include/malloc.h file that includes a declaration of struct + mallinfo. If so, it is included; else a compliant version is + declared below. These must be precisely the same for mallinfo() to + work. The original SVID version of this struct, defined on most + systems with mallinfo, declares all fields as ints. But some others + define as unsigned long. If your system defines the fields using a + type of different width than listed here, you MUST #include your + system version and #define HAVE_USR_INCLUDE_MALLOC_H. +*/ + +/* #define HAVE_USR_INCLUDE_MALLOC_H */ + +#ifdef HAVE_USR_INCLUDE_MALLOC_H +#include "/usr/include/malloc.h" +#else /* HAVE_USR_INCLUDE_MALLOC_H */ + +/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */ +#define _STRUCT_MALLINFO + +struct mallinfo { + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ +}; + +#endif /* HAVE_USR_INCLUDE_MALLOC_H */ +#endif /* NO_MALLINFO */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if !ONLY_MSPACES + +/* ------------------- Declarations of public routines ------------------- */ + +#ifndef USE_DL_PREFIX +#define dlcalloc calloc +#define dlfree free +#define dlmalloc malloc +#define dlmemalign memalign +#define dlrealloc realloc +#define dlvalloc valloc +#define dlpvalloc pvalloc +#define dlmallinfo mallinfo +#define dlmallopt mallopt +#define dlmalloc_trim malloc_trim +#define dlmalloc_stats malloc_stats +#define dlmalloc_usable_size malloc_usable_size +#define dlmalloc_footprint malloc_footprint +#define dlmalloc_max_footprint malloc_max_footprint +#define dlindependent_calloc independent_calloc +#define dlindependent_comalloc independent_comalloc +#endif /* USE_DL_PREFIX */ + + +/* + malloc(size_t n) + Returns a pointer to a newly allocated chunk of at least n bytes, or + null if no space is available, in which case errno is set to ENOMEM + on ANSI C systems. + + If n is zero, malloc returns a minimum-sized chunk. (The minimum + size is 16 bytes on most 32bit systems, and 32 bytes on 64bit + systems.) Note that size_t is an unsigned type, so calls with + arguments that would be negative if signed are interpreted as + requests for huge amounts of space, which will often fail. The + maximum supported value of n differs across systems, but is in all + cases less than the maximum representable value of a size_t. +*/ +void* dlmalloc(size_t); + +/* + free(void* p) + Releases the chunk of memory pointed to by p, that had been previously + allocated using malloc or a related routine such as realloc. + It has no effect if p is null. If p was not malloced or already + freed, free(p) will by default cause the current program to abort. +*/ +void dlfree(void*); + +/* + calloc(size_t n_elements, size_t element_size); + Returns a pointer to n_elements * element_size bytes, with all locations + set to zero. +*/ +void* dlcalloc(size_t, size_t); + +/* + realloc(void* p, size_t n) + Returns a pointer to a chunk of size n that contains the same data + as does chunk p up to the minimum of (n, p's size) bytes, or null + if no space is available. + + The returned pointer may or may not be the same as p. The algorithm + prefers extending p in most cases when possible, otherwise it + employs the equivalent of a malloc-copy-free sequence. + + If p is null, realloc is equivalent to malloc. + + If space is not available, realloc returns null, errno is set (if on + ANSI) and p is NOT freed. + + if n is for fewer bytes than already held by p, the newly unused + space is lopped off and freed if possible. realloc with a size + argument of zero (re)allocates a minimum-sized chunk. + + The old unix realloc convention of allowing the last-free'd chunk + to be used as an argument to realloc is not supported. +*/ + +void* dlrealloc(void*, size_t); + +/* + memalign(size_t alignment, size_t n); + Returns a pointer to a newly allocated chunk of n bytes, aligned + in accord with the alignment argument. + + The alignment argument should be a power of two. If the argument is + not a power of two, the nearest greater power is used. + 8-byte alignment is guaranteed by normal malloc calls, so don't + bother calling memalign with an argument of 8 or less. + + Overreliance on memalign is a sure way to fragment space. +*/ +void* dlmemalign(size_t, size_t); + +/* + valloc(size_t n); + Equivalent to memalign(pagesize, n), where pagesize is the page + size of the system. If the pagesize is unknown, 4096 is used. +*/ +void* dlvalloc(size_t); + +/* + mallopt(int parameter_number, int parameter_value) + Sets tunable parameters The format is to provide a + (parameter-number, parameter-value) pair. mallopt then sets the + corresponding parameter to the argument value if it can (i.e., so + long as the value is meaningful), and returns 1 if successful else + 0. SVID/XPG/ANSI defines four standard param numbers for mallopt, + normally defined in malloc.h. None of these are use in this malloc, + so setting them has no effect. But this malloc also supports other + options in mallopt. See below for details. Briefly, supported + parameters are as follows (listed defaults are for "typical" + configurations). + + Symbol param # default allowed param values + M_TRIM_THRESHOLD -1 2*1024*1024 any (MAX_SIZE_T disables) + M_GRANULARITY -2 page size any power of 2 >= page size + M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) +*/ +int dlmallopt(int, int); + +/* + malloc_footprint(); + Returns the number of bytes obtained from the system. The total + number of bytes allocated by malloc, realloc etc., is less than this + value. Unlike mallinfo, this function returns only a precomputed + result, so can be called frequently to monitor memory consumption. + Even if locks are otherwise defined, this function does not use them, + so results might not be up to date. +*/ +size_t dlmalloc_footprint(void); + +/* + malloc_max_footprint(); + Returns the maximum number of bytes obtained from the system. This + value will be greater than current footprint if deallocated space + has been reclaimed by the system. The peak number of bytes allocated + by malloc, realloc etc., is less than this value. Unlike mallinfo, + this function returns only a precomputed result, so can be called + frequently to monitor memory consumption. Even if locks are + otherwise defined, this function does not use them, so results might + not be up to date. +*/ +size_t dlmalloc_max_footprint(void); + +#if !NO_MALLINFO +/* + mallinfo() + Returns (by copy) a struct containing various summary statistics: + + arena: current total non-mmapped bytes allocated from system + ordblks: the number of free chunks + smblks: always zero. + hblks: current number of mmapped regions + hblkhd: total bytes held in mmapped regions + usmblks: the maximum total allocated space. This will be greater + than current total if trimming has occurred. + fsmblks: always zero + uordblks: current total allocated space (normal or mmapped) + fordblks: total free space + keepcost: the maximum number of bytes that could ideally be released + back to system via malloc_trim. ("ideally" means that + it ignores page restrictions etc.) + + Because these fields are ints, but internal bookkeeping may + be kept as longs, the reported values may wrap around zero and + thus be inaccurate. +*/ +struct mallinfo dlmallinfo(void); +#endif /* NO_MALLINFO */ + +/* + independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); + + independent_calloc is similar to calloc, but instead of returning a + single cleared space, it returns an array of pointers to n_elements + independent elements that can hold contents of size elem_size, each + of which starts out cleared, and can be independently freed, + realloc'ed etc. The elements are guaranteed to be adjacently + allocated (this is not guaranteed to occur with multiple callocs or + mallocs), which may also improve cache locality in some + applications. + + The "chunks" argument is optional (i.e., may be null, which is + probably the most typical usage). If it is null, the returned array + is itself dynamically allocated and should also be freed when it is + no longer needed. Otherwise, the chunks array must be of at least + n_elements in length. It is filled in with the pointers to the + chunks. + + In either case, independent_calloc returns this pointer array, or + null if the allocation failed. If n_elements is zero and "chunks" + is null, it returns a chunk representing an array with zero elements + (which should be freed if not wanted). + + Each element must be individually freed when it is no longer + needed. If you'd like to instead be able to free all at once, you + should instead use regular calloc and assign pointers into this + space to represent elements. (In this case though, you cannot + independently free elements.) + + independent_calloc simplifies and speeds up implementations of many + kinds of pools. It may also be useful when constructing large data + structures that initially have a fixed number of fixed-sized nodes, + but the number is not known at compile time, and some of the nodes + may later need to be freed. For example: + + struct Node { int item; struct Node* next; }; + + struct Node* build_list() { + struct Node** pool; + int n = read_number_of_nodes_needed(); + if (n <= 0) return 0; + pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); + if (pool == 0) die(); + // organize into a linked list... + struct Node* first = pool[0]; + for (i = 0; i < n-1; ++i) + pool[i]->next = pool[i+1]; + free(pool); // Can now free the array (or not, if it is needed later) + return first; + } +*/ +void** dlindependent_calloc(size_t, size_t, void**); + +/* + independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); + + independent_comalloc allocates, all at once, a set of n_elements + chunks with sizes indicated in the "sizes" array. It returns + an array of pointers to these elements, each of which can be + independently freed, realloc'ed etc. The elements are guaranteed to + be adjacently allocated (this is not guaranteed to occur with + multiple callocs or mallocs), which may also improve cache locality + in some applications. + + The "chunks" argument is optional (i.e., may be null). If it is null + the returned array is itself dynamically allocated and should also + be freed when it is no longer needed. Otherwise, the chunks array + must be of at least n_elements in length. It is filled in with the + pointers to the chunks. + + In either case, independent_comalloc returns this pointer array, or + null if the allocation failed. If n_elements is zero and chunks is + null, it returns a chunk representing an array with zero elements + (which should be freed if not wanted). + + Each element must be individually freed when it is no longer + needed. If you'd like to instead be able to free all at once, you + should instead use a single regular malloc, and assign pointers at + particular offsets in the aggregate space. (In this case though, you + cannot independently free elements.) + + independent_comallac differs from independent_calloc in that each + element may have a different size, and also that it does not + automatically clear elements. + + independent_comalloc can be used to speed up allocation in cases + where several structs or objects must always be allocated at the + same time. For example: + + struct Head { ... } + struct Foot { ... } + + void send_message(char* msg) { + int msglen = strlen(msg); + size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; + void* chunks[3]; + if (independent_comalloc(3, sizes, chunks) == 0) + die(); + struct Head* head = (struct Head*)(chunks[0]); + char* body = (char*)(chunks[1]); + struct Foot* foot = (struct Foot*)(chunks[2]); + // ... + } + + In general though, independent_comalloc is worth using only for + larger values of n_elements. For small values, you probably won't + detect enough difference from series of malloc calls to bother. + + Overuse of independent_comalloc can increase overall memory usage, + since it cannot reuse existing noncontiguous small chunks that + might be available for some of the elements. +*/ +void** dlindependent_comalloc(size_t, size_t*, void**); + + +/* + pvalloc(size_t n); + Equivalent to valloc(minimum-page-that-holds(n)), that is, + round up n to nearest pagesize. + */ +void* dlpvalloc(size_t); + +/* + malloc_trim(size_t pad); + + If possible, gives memory back to the system (via negative arguments + to sbrk) if there is unused memory at the `high' end of the malloc + pool or in unused MMAP segments. You can call this after freeing + large blocks of memory to potentially reduce the system-level memory + requirements of a program. However, it cannot guarantee to reduce + memory. Under some allocation patterns, some large free blocks of + memory will be locked between two used chunks, so they cannot be + given back to the system. + + The `pad' argument to malloc_trim represents the amount of free + trailing space to leave untrimmed. If this argument is zero, only + the minimum amount of memory to maintain internal data structures + will be left. Non-zero arguments can be supplied to maintain enough + trailing space to service future expected allocations without having + to re-obtain memory from the system. + + Malloc_trim returns 1 if it actually released any memory, else 0. +*/ +int dlmalloc_trim(size_t); + +/* + malloc_usable_size(void* p); + + Returns the number of bytes you can actually use in + an allocated chunk, which may be more than you requested (although + often not) due to alignment and minimum size constraints. + You can use this many bytes without worrying about + overwriting other allocated objects. This is not a particularly great + programming practice. malloc_usable_size can be more useful in + debugging and assertions, for example: + + p = malloc(n); + assert(malloc_usable_size(p) >= 256); +*/ +size_t dlmalloc_usable_size(void*); + +/* + malloc_stats(); + Prints on stderr the amount of space obtained from the system (both + via sbrk and mmap), the maximum amount (which may be more than + current if malloc_trim and/or munmap got called), and the current + number of bytes allocated via malloc (or realloc, etc) but not yet + freed. Note that this is the number of bytes allocated, not the + number requested. It will be larger than the number requested + because of alignment and bookkeeping overhead. Because it includes + alignment wastage as being in use, this figure may be greater than + zero even when no user-level chunks are allocated. + + The reported current and maximum system memory can be inaccurate if + a program makes other calls to system memory allocation functions + (normally sbrk) outside of malloc. + + malloc_stats prints only the most commonly interesting statistics. + More information can be obtained by calling mallinfo. +*/ +void dlmalloc_stats(void); + +#endif /* ONLY_MSPACES */ + +#if MSPACES + +/* + mspace is an opaque type representing an independent + region of space that supports mspace_malloc, etc. +*/ +typedef void* mspace; + +/* + create_mspace creates and returns a new independent space with the + given initial capacity, or, if 0, the default granularity size. It + returns null if there is no system memory available to create the + space. If argument locked is non-zero, the space uses a separate + lock to control access. The capacity of the space will grow + dynamically as needed to service mspace_malloc requests. You can + control the sizes of incremental increases of this space by + compiling with a different DEFAULT_GRANULARITY or dynamically + setting with mallopt(M_GRANULARITY, value). +*/ +mspace create_mspace(size_t capacity, int locked); + +/* + destroy_mspace destroys the given space, and attempts to return all + of its memory back to the system, returning the total number of + bytes freed. After destruction, the results of access to all memory + used by the space become undefined. +*/ +size_t destroy_mspace(mspace msp); + +/* + create_mspace_with_base uses the memory supplied as the initial base + of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this + space is used for bookkeeping, so the capacity must be at least this + large. (Otherwise 0 is returned.) When this initial space is + exhausted, additional memory will be obtained from the system. + Destroying this space will deallocate all additionally allocated + space (if possible) but not the initial base. +*/ +mspace create_mspace_with_base(void* base, size_t capacity, int locked); + +/* + mspace_malloc behaves as malloc, but operates within + the given space. +*/ +void* mspace_malloc(mspace msp, size_t bytes); + +/* + mspace_free behaves as free, but operates within + the given space. + + If compiled with FOOTERS==1, mspace_free is not actually needed. + free may be called instead of mspace_free because freed chunks from + any space are handled by their originating spaces. +*/ +void mspace_free(mspace msp, void* mem); + +/* + mspace_realloc behaves as realloc, but operates within + the given space. + + If compiled with FOOTERS==1, mspace_realloc is not actually + needed. realloc may be called instead of mspace_realloc because + realloced chunks from any space are handled by their originating + spaces. +*/ +void* mspace_realloc(mspace msp, void* mem, size_t newsize); + +/* + mspace_calloc behaves as calloc, but operates within + the given space. +*/ +void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); + +/* + mspace_memalign behaves as memalign, but operates within + the given space. +*/ +void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); + +/* + mspace_independent_calloc behaves as independent_calloc, but + operates within the given space. +*/ +void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]); + +/* + mspace_independent_comalloc behaves as independent_comalloc, but + operates within the given space. +*/ +void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]); + +/* + mspace_footprint() returns the number of bytes obtained from the + system for this space. +*/ +size_t mspace_footprint(mspace msp); + +/* + mspace_max_footprint() returns the peak number of bytes obtained from the + system for this space. +*/ +size_t mspace_max_footprint(mspace msp); + + +#if !NO_MALLINFO +/* + mspace_mallinfo behaves as mallinfo, but reports properties of + the given space. +*/ +struct mallinfo mspace_mallinfo(mspace msp); +#endif /* NO_MALLINFO */ + +/* + mspace_malloc_stats behaves as malloc_stats, but reports + properties of the given space. +*/ +void mspace_malloc_stats(mspace msp); + +/* + mspace_trim behaves as malloc_trim, but + operates within the given space. +*/ +int mspace_trim(mspace msp, size_t pad); + +/* + An alias for mallopt. +*/ +int mspace_mallopt(int, int); + +#endif /* MSPACES */ + +#ifdef __cplusplus +}; /* end of extern "C" */ +#endif /* __cplusplus */ + +/* + ======================================================================== + To make a fully customizable malloc.h header file, cut everything + above this line, put into file malloc.h, edit to suit, and #include it + on the next line, as well as in programs that use this malloc. + ======================================================================== +*/ + +/* #include "malloc.h" */ + +/*------------------------------ internal #includes ---------------------- */ + +#ifdef _MSC_VER +#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ +#endif /* _MSC_VER */ + +#include /* for printing in malloc_stats */ + +#ifndef LACKS_ERRNO_H +#include /* for MALLOC_FAILURE_ACTION */ +#endif /* LACKS_ERRNO_H */ +#if FOOTERS +#include /* for magic initialization */ +#endif /* FOOTERS */ +#ifndef LACKS_STDLIB_H +#include /* for abort() */ +#endif /* LACKS_STDLIB_H */ +#ifdef DEBUG +#if ABORT_ON_ASSERT_FAILURE +#define assert(x) if(!(x)) ABORT +#else /* ABORT_ON_ASSERT_FAILURE */ +#include +#endif /* ABORT_ON_ASSERT_FAILURE */ +#else /* DEBUG */ +#define assert(x) +#endif /* DEBUG */ +#ifndef LACKS_STRING_H +#include /* for memset etc */ +#endif /* LACKS_STRING_H */ +#if USE_BUILTIN_FFS +#ifndef LACKS_STRINGS_H +#include /* for ffs */ +#endif /* LACKS_STRINGS_H */ +#endif /* USE_BUILTIN_FFS */ +#if HAVE_MMAP +#ifndef LACKS_SYS_MMAN_H +#include /* for mmap */ +#endif /* LACKS_SYS_MMAN_H */ +#ifndef LACKS_FCNTL_H +#include +#endif /* LACKS_FCNTL_H */ +#endif /* HAVE_MMAP */ +#if HAVE_MORECORE +#ifndef LACKS_UNISTD_H +#include /* for sbrk */ +#else /* LACKS_UNISTD_H */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +extern void* sbrk(ptrdiff_t); +#endif /* FreeBSD etc */ +#endif /* LACKS_UNISTD_H */ +#endif /* HAVE_MMAP */ + +#ifndef WIN32 +#ifndef malloc_getpagesize +# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ +# ifndef _SC_PAGE_SIZE +# define _SC_PAGE_SIZE _SC_PAGESIZE +# endif +# endif +# ifdef _SC_PAGE_SIZE +# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) +# else +# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) + extern size_t getpagesize(); +# define malloc_getpagesize getpagesize() +# else +# ifdef WIN32 /* use supplied emulation of getpagesize */ +# define malloc_getpagesize getpagesize() +# else +# ifndef LACKS_SYS_PARAM_H +# include +# endif +# ifdef EXEC_PAGESIZE +# define malloc_getpagesize EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define malloc_getpagesize NBPG +# else +# define malloc_getpagesize (NBPG * CLSIZE) +# endif +# else +# ifdef NBPC +# define malloc_getpagesize NBPC +# else +# ifdef PAGESIZE +# define malloc_getpagesize PAGESIZE +# else /* just guess */ +# define malloc_getpagesize ((size_t)4096U) +# endif +# endif +# endif +# endif +# endif +# endif +# endif +#endif +#endif + +/* ------------------- size_t and alignment properties -------------------- */ + +/* The byte and bit size of a size_t */ +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) + +/* Some constants coerced to size_t */ +/* Annoying but necessary to avoid errors on some platforms */ +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) +#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) + +/* The bit mask value corresponding to MALLOC_ALIGNMENT */ +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) + +/* True if address a has acceptable alignment */ +#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) + +/* the number of bytes to offset an address to align it */ +#define align_offset(A)\ + ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ + ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) + +/* -------------------------- MMAP preliminaries ------------------------- */ + +/* + If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and + checks to fail so compiler optimizer can delete code rather than + using so many "#if"s. +*/ + + +/* MORECORE and MMAP must return MFAIL on failure */ +#define MFAIL ((void*)(MAX_SIZE_T)) +#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ + +#if !HAVE_MMAP +#define IS_MMAPPED_BIT (SIZE_T_ZERO) +#define USE_MMAP_BIT (SIZE_T_ZERO) +#define CALL_MMAP(s) MFAIL +#define CALL_MUNMAP(a, s) (-1) +#define DIRECT_MMAP(s) MFAIL + +#else /* HAVE_MMAP */ +#define IS_MMAPPED_BIT (SIZE_T_ONE) +#define USE_MMAP_BIT (SIZE_T_ONE) + +#if !defined(WIN32) && !defined (__OS2__) +#define CALL_MUNMAP(a, s) munmap((a), (s)) +#define MMAP_PROT (PROT_READ|PROT_WRITE) +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif /* MAP_ANON */ +#ifdef MAP_ANONYMOUS +#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) +#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) +#else /* MAP_ANONYMOUS */ +/* + Nearly all versions of mmap support MAP_ANONYMOUS, so the following + is unlikely to be needed, but is supplied just in case. +*/ +#define MMAP_FLAGS (MAP_PRIVATE) +static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ +#define CALL_MMAP(s) ((dev_zero_fd < 0) ? \ + (dev_zero_fd = open("/dev/zero", O_RDWR), \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) +#endif /* MAP_ANONYMOUS */ + +#define DIRECT_MMAP(s) CALL_MMAP(s) + +#elif defined(__OS2__) + +/* OS/2 MMAP via DosAllocMem */ +static void* os2mmap(size_t size) { + void* ptr; + if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) && + DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE)) + return MFAIL; + return ptr; +} + +#define os2direct_mmap(n) os2mmap(n) + +/* This function supports releasing coalesed segments */ +static int os2munmap(void* ptr, size_t size) { + while (size) { + ULONG ulSize = size; + ULONG ulFlags = 0; + if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0) + return -1; + if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 || + ulSize > size) + return -1; + if (DosFreeMem(ptr) != 0) + return -1; + ptr = ( void * ) ( ( char * ) ptr + ulSize ); + size -= ulSize; + } + return 0; +} + +#define CALL_MMAP(s) os2mmap(s) +#define CALL_MUNMAP(a, s) os2munmap((a), (s)) +#define DIRECT_MMAP(s) os2direct_mmap(s) + +#else /* WIN32 */ + +/* Win32 MMAP via VirtualAlloc */ +static void* win32mmap(size_t size) { + void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE); + return (ptr != 0)? ptr: MFAIL; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static void* win32direct_mmap(size_t size) { + void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_EXECUTE_READWRITE); + return (ptr != 0)? ptr: MFAIL; +} + +/* This function supports releasing coalesed segments */ +static int win32munmap(void* ptr, size_t size) { + MEMORY_BASIC_INFORMATION minfo; + char* cptr = ptr; + while (size) { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || + minfo.State != MEM_COMMIT || minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + return 0; +} + +#define CALL_MMAP(s) win32mmap(s) +#define CALL_MUNMAP(a, s) win32munmap((a), (s)) +#define DIRECT_MMAP(s) win32direct_mmap(s) +#endif /* WIN32 */ +#endif /* HAVE_MMAP */ + +#if HAVE_MMAP && HAVE_MREMAP +#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) +#else /* HAVE_MMAP && HAVE_MREMAP */ +#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL +#endif /* HAVE_MMAP && HAVE_MREMAP */ + +#if HAVE_MORECORE +#define CALL_MORECORE(S) MORECORE(S) +#else /* HAVE_MORECORE */ +#define CALL_MORECORE(S) MFAIL +#endif /* HAVE_MORECORE */ + +/* mstate bit set if contiguous morecore disabled or failed */ +#define USE_NONCONTIGUOUS_BIT (4U) + +/* segment bit set in create_mspace_with_base */ +#define EXTERN_BIT (8U) + + +/* --------------------------- Lock preliminaries ------------------------ */ + +#if USE_LOCKS + +/* + When locks are defined, there are up to two global locks: + + * If HAVE_MORECORE, morecore_mutex protects sequences of calls to + MORECORE. In many cases sys_alloc requires two calls, that should + not be interleaved with calls by other threads. This does not + protect against direct calls to MORECORE by other threads not + using this lock, so there is still code to cope the best we can on + interference. + + * magic_init_mutex ensures that mparams.magic and other + unique mparams values are initialized only once. +*/ + +#if !defined(WIN32) && !defined(__OS2__) +/* By default use posix locks */ +#include +#define MLOCK_T pthread_mutex_t +#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL) +#define ACQUIRE_LOCK(l) pthread_mutex_lock(l) +#define RELEASE_LOCK(l) pthread_mutex_unlock(l) + +#if HAVE_MORECORE +static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif /* HAVE_MORECORE */ + +static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; + +#elif defined(__OS2__) +#define MLOCK_T HMTX +#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE) +#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT) +#define RELEASE_LOCK(l) DosReleaseMutexSem(*l) +#if HAVE_MORECORE +static MLOCK_T morecore_mutex; +#endif /* HAVE_MORECORE */ +static MLOCK_T magic_init_mutex; + +#else /* WIN32 */ +/* + Because lock-protected regions have bounded times, and there + are no recursive lock calls, we can use simple spinlocks. +*/ + +#define MLOCK_T long +static int win32_acquire_lock (MLOCK_T *sl) { + for (;;) { +#ifdef InterlockedCompareExchangePointer + if (!InterlockedCompareExchange(sl, 1, 0)) + return 0; +#else /* Use older void* version */ + if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0)) + return 0; +#endif /* InterlockedCompareExchangePointer */ + Sleep (0); + } +} + +static void win32_release_lock (MLOCK_T *sl) { + InterlockedExchange (sl, 0); +} + +#define INITIAL_LOCK(l) *(l)=0 +#define ACQUIRE_LOCK(l) win32_acquire_lock(l) +#define RELEASE_LOCK(l) win32_release_lock(l) +#if HAVE_MORECORE +static MLOCK_T morecore_mutex; +#endif /* HAVE_MORECORE */ +static MLOCK_T magic_init_mutex; +#endif /* WIN32 */ + +#define USE_LOCK_BIT (2U) +#else /* USE_LOCKS */ +#define USE_LOCK_BIT (0U) +#define INITIAL_LOCK(l) +#endif /* USE_LOCKS */ + +#if USE_LOCKS && HAVE_MORECORE +#define ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex); +#define RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex); +#else /* USE_LOCKS && HAVE_MORECORE */ +#define ACQUIRE_MORECORE_LOCK() +#define RELEASE_MORECORE_LOCK() +#endif /* USE_LOCKS && HAVE_MORECORE */ + +#if USE_LOCKS +#define ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex); +#define RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex); +#else /* USE_LOCKS */ +#define ACQUIRE_MAGIC_INIT_LOCK() +#define RELEASE_MAGIC_INIT_LOCK() +#endif /* USE_LOCKS */ + + +/* ----------------------- Chunk representations ------------------------ */ + +/* + (The following includes lightly edited explanations by Colin Plumb.) + + The malloc_chunk declaration below is misleading (but accurate and + necessary). It declares a "view" into memory allowing access to + necessary fields at known offsets from a given base. + + Chunks of memory are maintained using a `boundary tag' method as + originally described by Knuth. (See the paper by Paul Wilson + ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such + techniques.) Sizes of free chunks are stored both in the front of + each chunk and at the end. This makes consolidating fragmented + chunks into bigger chunks fast. The head fields also hold bits + representing whether chunks are free or in use. + + Here are some pictures to make it clearer. They are "exploded" to + show that the state of a chunk can be thought of as extending from + the high 31 bits of the head field of its header through the + prev_foot and PINUSE_BIT bit of the following chunk header. + + A chunk that's in use looks like: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk (if P = 1) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| + | Size of this chunk 1| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + +- -+ + | | + +- -+ + | : + +- size - sizeof(size_t) available payload bytes -+ + : | + chunk-> +- -+ + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| + | Size of next chunk (may or may not be in use) | +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + And if it's free, it looks like this: + + chunk-> +- -+ + | User payload (must be in use, or we would have merged!) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| + | Size of this chunk 0| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Next pointer | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Prev pointer | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | : + +- size - sizeof(struct chunk) unused bytes -+ + : | + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of this chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| + | Size of next chunk (must be in use, or we would have merged)| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | : + +- User payload -+ + : | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |0| + +-+ + Note that since we always merge adjacent free chunks, the chunks + adjacent to a free chunk must be in use. + + Given a pointer to a chunk (which can be derived trivially from the + payload pointer) we can, in O(1) time, find out whether the adjacent + chunks are free, and if so, unlink them from the lists that they + are on and merge them with the current chunk. + + Chunks always begin on even word boundaries, so the mem portion + (which is returned to the user) is also on an even word boundary, and + thus at least double-word aligned. + + The P (PINUSE_BIT) bit, stored in the unused low-order bit of the + chunk size (which is always a multiple of two words), is an in-use + bit for the *previous* chunk. If that bit is *clear*, then the + word before the current chunk size contains the previous chunk + size, and can be used to find the front of the previous chunk. + The very first chunk allocated always has this bit set, preventing + access to non-existent (or non-owned) memory. If pinuse is set for + any given chunk, then you CANNOT determine the size of the + previous chunk, and might even get a memory addressing fault when + trying to do so. + + The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of + the chunk size redundantly records whether the current chunk is + inuse. This redundancy enables usage checks within free and realloc, + and reduces indirection when freeing and consolidating chunks. + + Each freshly allocated chunk must have both cinuse and pinuse set. + That is, each allocated chunk borders either a previously allocated + and still in-use chunk, or the base of its memory arena. This is + ensured by making all allocations from the the `lowest' part of any + found chunk. Further, no free chunk physically borders another one, + so each free chunk is known to be preceded and followed by either + inuse chunks or the ends of memory. + + Note that the `foot' of the current chunk is actually represented + as the prev_foot of the NEXT chunk. This makes it easier to + deal with alignments etc but can be very confusing when trying + to extend or adapt this code. + + The exceptions to all this are + + 1. The special chunk `top' is the top-most available chunk (i.e., + the one bordering the end of available memory). It is treated + specially. Top is never included in any bin, is used only if + no other chunk is available, and is released back to the + system if it is very large (see M_TRIM_THRESHOLD). In effect, + the top chunk is treated as larger (and thus less well + fitting) than any other available chunk. The top chunk + doesn't update its trailing size field since there is no next + contiguous chunk that would have to index off it. However, + space is still allocated for it (TOP_FOOT_SIZE) to enable + separation or merging when space is extended. + + 3. Chunks allocated via mmap, which have the lowest-order bit + (IS_MMAPPED_BIT) set in their prev_foot fields, and do not set + PINUSE_BIT in their head fields. Because they are allocated + one-by-one, each must carry its own prev_foot field, which is + also used to hold the offset this chunk has within its mmapped + region, which is needed to preserve alignment. Each mmapped + chunk is trailed by the first two fields of a fake next-chunk + for sake of usage checks. + +*/ + +struct malloc_chunk { + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; +}; + +typedef struct malloc_chunk mchunk; +typedef struct malloc_chunk* mchunkptr; +typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ +typedef size_t bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ + +/* ------------------- Chunks sizes and alignments ----------------------- */ + +#define MCHUNK_SIZE (sizeof(mchunk)) + +#if FOOTERS +#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +#else /* FOOTERS */ +#define CHUNK_OVERHEAD (SIZE_T_SIZE) +#endif /* FOOTERS */ + +/* MMapped chunks need a second word of overhead ... */ +#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +/* ... and additional padding for fake next-chunk at foot */ +#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) + +/* The smallest size we can malloc is an aligned minimal chunk */ +#define MIN_CHUNK_SIZE\ + ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* conversion from malloc headers to user pointers, and back */ +#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) +/* chunk associated with aligned address A */ +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) + +/* Bounds on request (not chunk) sizes. */ +#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) + +/* pad request bytes into a usable size */ +#define pad_request(req) \ + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* pad request, checking for minimum (but not maximum) */ +#define request2size(req) \ + (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + + +/* ------------------ Operations on head and foot fields ----------------- */ + +/* + The head field of a chunk is or'ed with PINUSE_BIT when previous + adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in + use. If the chunk was obtained with mmap, the prev_foot field has + IS_MMAPPED_BIT set, otherwise holding the offset of the base of the + mmapped region to the base of the chunk. +*/ + +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) + +/* Head value for fenceposts */ +#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) + +/* extraction of fields from head words */ +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define chunksize(p) ((p)->head & ~(INUSE_BITS)) + +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) + +/* Treat space at ptr +/- offset as a chunk */ +#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) + +/* Ptr to next or previous physical malloc_chunk. */ +#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS))) +#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) + +/* extract next chunk's pinuse bit */ +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) + +/* Get/set size at footer */ +#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) + +/* Set size, pinuse bit, and foot */ +#define set_size_and_pinuse_of_free_chunk(p, s)\ + ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) + +/* Set size, pinuse bit, foot, and clear next pinuse */ +#define set_free_with_pinuse(p, s, n)\ + (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) + +#define is_mmapped(p)\ + (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT)) + +/* Get the internal overhead associated with chunk p */ +#define overhead_for(p)\ + (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) + +/* Return true if malloced space is not necessarily cleared */ +#if MMAP_CLEARS +#define calloc_must_clear(p) (!is_mmapped(p)) +#else /* MMAP_CLEARS */ +#define calloc_must_clear(p) (1) +#endif /* MMAP_CLEARS */ + +/* ---------------------- Overlaid data structures ----------------------- */ + +/* + When chunks are not in use, they are treated as nodes of either + lists or trees. + + "Small" chunks are stored in circular doubly-linked lists, and look + like this: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `head:' | Size of chunk, in bytes |P| + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Forward pointer to next chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space (may be 0 bytes long) . + . . + . | +nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `foot:' | Size of chunk, in bytes | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Larger chunks are kept in a form of bitwise digital trees (aka + tries) keyed on chunksizes. Because malloc_tree_chunks are only for + free chunks greater than 256 bytes, their size doesn't impose any + constraints on user chunk sizes. Each node looks like: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `head:' | Size of chunk, in bytes |P| + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Forward pointer to next chunk of same size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk of same size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to left child (child[0]) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to right child (child[1]) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to parent | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | bin index of this chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space . + . | +nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `foot:' | Size of chunk, in bytes | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Each tree holding treenodes is a tree of unique chunk sizes. Chunks + of the same size are arranged in a circularly-linked list, with only + the oldest chunk (the next to be used, in our FIFO ordering) + actually in the tree. (Tree members are distinguished by a non-null + parent pointer.) If a chunk with the same size an an existing node + is inserted, it is linked off the existing node using pointers that + work in the same way as fd/bk pointers of small chunks. + + Each tree contains a power of 2 sized range of chunk sizes (the + smallest is 0x100 <= x < 0x180), which is is divided in half at each + tree level, with the chunks in the smaller half of the range (0x100 + <= x < 0x140 for the top nose) in the left subtree and the larger + half (0x140 <= x < 0x180) in the right subtree. This is, of course, + done by inspecting individual bits. + + Using these rules, each node's left subtree contains all smaller + sizes than its right subtree. However, the node at the root of each + subtree has no particular ordering relationship to either. (The + dividing line between the subtree sizes is based on trie relation.) + If we remove the last chunk of a given size from the interior of the + tree, we need to replace it with a leaf node. The tree ordering + rules permit a node to be replaced by any leaf below it. + + The smallest chunk in a tree (a common operation in a best-fit + allocator) can be found by walking a path to the leftmost leaf in + the tree. Unlike a usual binary tree, where we follow left child + pointers until we reach a null, here we follow the right child + pointer any time the left one is null, until we reach a leaf with + both child pointers null. The smallest chunk in the tree will be + somewhere along that path. + + The worst case number of steps to add, find, or remove a node is + bounded by the number of bits differentiating chunks within + bins. Under current bin calculations, this ranges from 6 up to 21 + (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case + is of course much better. +*/ + +struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk* fd; + struct malloc_tree_chunk* bk; + + struct malloc_tree_chunk* child[2]; + struct malloc_tree_chunk* parent; + bindex_t index; +}; + +typedef struct malloc_tree_chunk tchunk; +typedef struct malloc_tree_chunk* tchunkptr; +typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ + +/* A little helper macro for trees */ +#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) + +/* ----------------------------- Segments -------------------------------- */ + +/* + Each malloc space may include non-contiguous segments, held in a + list headed by an embedded malloc_segment record representing the + top-most space. Segments also include flags holding properties of + the space. Large chunks that are directly allocated by mmap are not + included in this list. They are instead independently created and + destroyed without otherwise keeping track of them. + + Segment management mainly comes into play for spaces allocated by + MMAP. Any call to MMAP might or might not return memory that is + adjacent to an existing segment. MORECORE normally contiguously + extends the current space, so this space is almost always adjacent, + which is simpler and faster to deal with. (This is why MORECORE is + used preferentially to MMAP when both are available -- see + sys_alloc.) When allocating using MMAP, we don't use any of the + hinting mechanisms (inconsistently) supported in various + implementations of unix mmap, or distinguish reserving from + committing memory. Instead, we just ask for space, and exploit + contiguity when we get it. It is probably possible to do + better than this on some systems, but no general scheme seems + to be significantly better. + + Management entails a simpler variant of the consolidation scheme + used for chunks to reduce fragmentation -- new adjacent memory is + normally prepended or appended to an existing segment. However, + there are limitations compared to chunk consolidation that mostly + reflect the fact that segment processing is relatively infrequent + (occurring only when getting memory from system) and that we + don't expect to have huge numbers of segments: + + * Segments are not indexed, so traversal requires linear scans. (It + would be possible to index these, but is not worth the extra + overhead and complexity for most programs on most platforms.) + * New segments are only appended to old ones when holding top-most + memory; if they cannot be prepended to others, they are held in + different segments. + + Except for the top-most segment of an mstate, each segment record + is kept at the tail of its segment. Segments are added by pushing + segment records onto the list headed by &mstate.seg for the + containing mstate. + + Segment flags control allocation/merge/deallocation policies: + * If EXTERN_BIT set, then we did not allocate this segment, + and so should not try to deallocate or merge with others. + (This currently holds only for the initial segment passed + into create_mspace_with_base.) + * If IS_MMAPPED_BIT set, the segment may be merged with + other surrounding mmapped segments and trimmed/de-allocated + using munmap. + * If neither bit is set, then the segment was obtained using + MORECORE so can be merged with surrounding MORECORE'd segments + and deallocated/trimmed using MORECORE with negative arguments. +*/ + +struct malloc_segment { + char* base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment* next; /* ptr to next segment */ +#if FFI_MMAP_EXEC_WRIT + /* The mmap magic is supposed to store the address of the executable + segment at the very end of the requested block. */ + +# define mmap_exec_offset(b,s) (*(ptrdiff_t*)((b)+(s)-sizeof(ptrdiff_t))) + + /* We can only merge segments if their corresponding executable + segments are at identical offsets. */ +# define check_segment_merge(S,b,s) \ + (mmap_exec_offset((b),(s)) == (S)->exec_offset) + +# define add_segment_exec_offset(p,S) ((char*)(p) + (S)->exec_offset) +# define sub_segment_exec_offset(p,S) ((char*)(p) - (S)->exec_offset) + + /* The removal of sflags only works with HAVE_MORECORE == 0. */ + +# define get_segment_flags(S) (IS_MMAPPED_BIT) +# define set_segment_flags(S,v) \ + (((v) != IS_MMAPPED_BIT) ? (ABORT, (v)) : \ + (((S)->exec_offset = \ + mmap_exec_offset((S)->base, (S)->size)), \ + (mmap_exec_offset((S)->base + (S)->exec_offset, (S)->size) != \ + (S)->exec_offset) ? (ABORT, (v)) : \ + (mmap_exec_offset((S)->base, (S)->size) = 0), (v))) + + /* We use an offset here, instead of a pointer, because then, when + base changes, we don't have to modify this. On architectures + with segmented addresses, this might not work. */ + ptrdiff_t exec_offset; +#else + +# define get_segment_flags(S) ((S)->sflags) +# define set_segment_flags(S,v) ((S)->sflags = (v)) +# define check_segment_merge(S,b,s) (1) + + flag_t sflags; /* mmap and extern flag */ +#endif +}; + +#define is_mmapped_segment(S) (get_segment_flags(S) & IS_MMAPPED_BIT) +#define is_extern_segment(S) (get_segment_flags(S) & EXTERN_BIT) + +typedef struct malloc_segment msegment; +typedef struct malloc_segment* msegmentptr; + +/* ---------------------------- malloc_state ----------------------------- */ + +/* + A malloc_state holds all of the bookkeeping for a space. + The main fields are: + + Top + The topmost chunk of the currently active segment. Its size is + cached in topsize. The actual size of topmost space is + topsize+TOP_FOOT_SIZE, which includes space reserved for adding + fenceposts and segment records if necessary when getting more + space from the system. The size at which to autotrim top is + cached from mparams in trim_check, except that it is disabled if + an autotrim fails. + + Designated victim (dv) + This is the preferred chunk for servicing small requests that + don't have exact fits. It is normally the chunk split off most + recently to service another small request. Its size is cached in + dvsize. The link fields of this chunk are not maintained since it + is not kept in a bin. + + SmallBins + An array of bin headers for free chunks. These bins hold chunks + with sizes less than MIN_LARGE_SIZE bytes. Each bin contains + chunks of all the same size, spaced 8 bytes apart. To simplify + use in double-linked lists, each bin header acts as a malloc_chunk + pointing to the real first node, if it exists (else pointing to + itself). This avoids special-casing for headers. But to avoid + waste, we allocate only the fd/bk pointers of bins, and then use + repositioning tricks to treat these as the fields of a chunk. + + TreeBins + Treebins are pointers to the roots of trees holding a range of + sizes. There are 2 equally spaced treebins for each power of two + from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything + larger. + + Bin maps + There is one bit map for small bins ("smallmap") and one for + treebins ("treemap). Each bin sets its bit when non-empty, and + clears the bit when empty. Bit operations are then used to avoid + bin-by-bin searching -- nearly all "search" is done without ever + looking at bins that won't be selected. The bit maps + conservatively use 32 bits per map word, even if on 64bit system. + For a good description of some of the bit-based techniques used + here, see Henry S. Warren Jr's book "Hacker's Delight" (and + supplement at http://hackersdelight.org/). Many of these are + intended to reduce the branchiness of paths through malloc etc, as + well as to reduce the number of memory locations read or written. + + Segments + A list of segments headed by an embedded malloc_segment record + representing the initial space. + + Address check support + The least_addr field is the least address ever obtained from + MORECORE or MMAP. Attempted frees and reallocs of any address less + than this are trapped (unless INSECURE is defined). + + Magic tag + A cross-check field that should always hold same value as mparams.magic. + + Flags + Bits recording whether to use MMAP, locks, or contiguous MORECORE + + Statistics + Each space keeps track of current and maximum system memory + obtained via MORECORE or MMAP. + + Locking + If USE_LOCKS is defined, the "mutex" lock is acquired and released + around every public call using this mspace. +*/ + +/* Bin types, widths and sizes */ +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) + +struct malloc_state { + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char* least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t magic; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + flag_t mflags; +#if USE_LOCKS + MLOCK_T mutex; /* locate lock among fields that rarely change */ +#endif /* USE_LOCKS */ + msegment seg; +}; + +typedef struct malloc_state* mstate; + +/* ------------- Global malloc_state and malloc_params ------------------- */ + +/* + malloc_params holds global properties, including those that can be + dynamically set using mallopt. There is a single instance, mparams, + initialized in init_mparams. +*/ + +struct malloc_params { + size_t magic; + size_t page_size; + size_t granularity; + size_t mmap_threshold; + size_t trim_threshold; + flag_t default_mflags; +}; + +static struct malloc_params mparams; + +/* The global malloc_state used for all non-"mspace" calls */ +static struct malloc_state _gm_; +#define gm (&_gm_) +#define is_global(M) ((M) == &_gm_) +#define is_initialized(M) ((M)->top != 0) + +/* -------------------------- system alloc setup ------------------------- */ + +/* Operations on mflags */ + +#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) +#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) +#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) + +#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) +#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) +#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) + +#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) +#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) + +#define set_lock(M,L)\ + ((M)->mflags = (L)?\ + ((M)->mflags | USE_LOCK_BIT) :\ + ((M)->mflags & ~USE_LOCK_BIT)) + +/* page-align a size */ +#define page_align(S)\ + (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE)) + +/* granularity-align a size */ +#define granularity_align(S)\ + (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE)) + +#define is_page_aligned(S)\ + (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) +#define is_granularity_aligned(S)\ + (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) + +/* True if segment S holds address A */ +#define segment_holds(S, A)\ + ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) + +/* Return segment holding given address */ +static msegmentptr segment_holding(mstate m, char* addr) { + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* Return true if segment contains a segment link */ +static int has_segment_link(mstate m, msegmentptr ss) { + msegmentptr sp = &m->seg; + for (;;) { + if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; + } +} + +#ifndef MORECORE_CANNOT_TRIM +#define should_trim(M,s) ((s) > (M)->trim_check) +#else /* MORECORE_CANNOT_TRIM */ +#define should_trim(M,s) (0) +#endif /* MORECORE_CANNOT_TRIM */ + +/* + TOP_FOOT_SIZE is padding at the end of a segment, including space + that may be needed to place segment records and fenceposts when new + noncontiguous segments are added. +*/ +#define TOP_FOOT_SIZE\ + (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + + +/* ------------------------------- Hooks -------------------------------- */ + +/* + PREACTION should be defined to return 0 on success, and nonzero on + failure. If you are not using locking, you can redefine these to do + anything you like. +*/ + +#if USE_LOCKS + +/* Ensure locks are initialized */ +#define GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams()) + +#define PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) +#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } +#else /* USE_LOCKS */ + +#ifndef PREACTION +#define PREACTION(M) (0) +#endif /* PREACTION */ + +#ifndef POSTACTION +#define POSTACTION(M) +#endif /* POSTACTION */ + +#endif /* USE_LOCKS */ + +/* + CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. + USAGE_ERROR_ACTION is triggered on detected bad frees and + reallocs. The argument p is an address that might have triggered the + fault. It is ignored by the two predefined actions, but might be + useful in custom actions that try to help diagnose errors. +*/ + +#if PROCEED_ON_ERROR + +/* A count of the number of corruption errors causing resets */ +int malloc_corruption_error_count; + +/* default corruption action */ +static void reset_on_error(mstate m); + +#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) +#define USAGE_ERROR_ACTION(m, p) + +#else /* PROCEED_ON_ERROR */ + +#ifndef CORRUPTION_ERROR_ACTION +#define CORRUPTION_ERROR_ACTION(m) ABORT +#endif /* CORRUPTION_ERROR_ACTION */ + +#ifndef USAGE_ERROR_ACTION +#define USAGE_ERROR_ACTION(m,p) ABORT +#endif /* USAGE_ERROR_ACTION */ + +#endif /* PROCEED_ON_ERROR */ + +/* -------------------------- Debugging setup ---------------------------- */ + +#if ! DEBUG + +#define check_free_chunk(M,P) +#define check_inuse_chunk(M,P) +#define check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) +#define check_malloc_state(M) +#define check_top_chunk(M,P) + +#else /* DEBUG */ +#define check_free_chunk(M,P) do_check_free_chunk(M,P) +#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) +#define check_top_chunk(M,P) do_check_top_chunk(M,P) +#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) +#define check_malloc_state(M) do_check_malloc_state(M) + +static void do_check_any_chunk(mstate m, mchunkptr p); +static void do_check_top_chunk(mstate m, mchunkptr p); +static void do_check_mmapped_chunk(mstate m, mchunkptr p); +static void do_check_inuse_chunk(mstate m, mchunkptr p); +static void do_check_free_chunk(mstate m, mchunkptr p); +static void do_check_malloced_chunk(mstate m, void* mem, size_t s); +static void do_check_tree(mstate m, tchunkptr t); +static void do_check_treebin(mstate m, bindex_t i); +static void do_check_smallbin(mstate m, bindex_t i); +static void do_check_malloc_state(mstate m); +static int bin_find(mstate m, mchunkptr x); +static size_t traverse_and_check(mstate m); +#endif /* DEBUG */ + +/* ---------------------------- Indexing Bins ---------------------------- */ + +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) ((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) + +/* addressing by index. See above about smallbin repositioning */ +#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) +#define treebin_at(M,i) (&((M)->treebins[i])) + +/* assign tree index for size S to variable I */ +#if defined(__GNUC__) && defined(__i386__) +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K;\ + __asm__("bsrl %1,%0\n\t" : "=r" (K) : "rm" (X));\ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} +#else /* GNUC */ +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int Y = (unsigned int)X;\ + unsigned int N = ((Y - 0x100) >> 16) & 8;\ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ + N += K;\ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ + K = 14 - N + ((Y <<= K) >> 15);\ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ + }\ +} +#endif /* GNUC */ + +/* Bit representing maximum resolved size in a treebin at i */ +#define bit_for_tree_index(i) \ + (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + +/* Shift placing maximum resolved bit in a treebin at i as sign bit */ +#define leftshift_for_tree_index(i) \ + ((i == NTREEBINS-1)? 0 : \ + ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + +/* The size of the smallest chunk held in bin with index i */ +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + + +/* ------------------------ Operations on bin maps ----------------------- */ + +/* bit corresponding to given index */ +#define idx2bit(i) ((binmap_t)(1) << (i)) + +/* Mark/Clear bits with given index */ +#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) + +#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) + +/* index corresponding to given bit */ + +#if defined(__GNUC__) && defined(__i386__) +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + __asm__("bsfl %1,%0\n\t" : "=r" (J) : "rm" (X));\ + I = (bindex_t)J;\ +} + +#else /* GNUC */ +#if USE_BUILTIN_FFS +#define compute_bit2idx(X, I) I = ffs(X)-1 + +#else /* USE_BUILTIN_FFS */ +#define compute_bit2idx(X, I)\ +{\ + unsigned int Y = X - 1;\ + unsigned int K = Y >> (16-4) & 16;\ + unsigned int N = K; Y >>= K;\ + N += K = Y >> (8-3) & 8; Y >>= K;\ + N += K = Y >> (4-2) & 4; Y >>= K;\ + N += K = Y >> (2-1) & 2; Y >>= K;\ + N += K = Y >> (1-0) & 1; Y >>= K;\ + I = (bindex_t)(N + Y);\ +} +#endif /* USE_BUILTIN_FFS */ +#endif /* GNUC */ + +/* isolate the least set bit of a bitmap */ +#define least_bit(x) ((x) & -(x)) + +/* mask with all bits to left of least bit of x on */ +#define left_bits(x) ((x<<1) | -(x<<1)) + +/* mask with all bits to left of or equal to least bit of x on */ +#define same_or_left_bits(x) ((x) | -(x)) + + +/* ----------------------- Runtime Check Support ------------------------- */ + +/* + For security, the main invariant is that malloc/free/etc never + writes to a static address other than malloc_state, unless static + malloc_state itself has been corrupted, which cannot occur via + malloc (because of these checks). In essence this means that we + believe all pointers, sizes, maps etc held in malloc_state, but + check all of those linked or offsetted from other embedded data + structures. These checks are interspersed with main code in a way + that tends to minimize their run-time cost. + + When FOOTERS is defined, in addition to range checking, we also + verify footer fields of inuse chunks, which can be used guarantee + that the mstate controlling malloc/free is intact. This is a + streamlined version of the approach described by William Robertson + et al in "Run-time Detection of Heap-based Overflows" LISA'03 + http://www.usenix.org/events/lisa03/tech/robertson.html The footer + of an inuse chunk holds the xor of its mstate and a random seed, + that is checked upon calls to free() and realloc(). This is + (probablistically) unguessable from outside the program, but can be + computed by any code successfully malloc'ing any chunk, so does not + itself provide protection against code that has already broken + security through some other means. Unlike Robertson et al, we + always dynamically check addresses of all offset chunks (previous, + next, etc). This turns out to be cheaper than relying on hashes. +*/ + +#if !INSECURE +/* Check if address a is at least as high as any from MORECORE or MMAP */ +#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) +/* Check if address of next chunk n is higher than base chunk p */ +#define ok_next(p, n) ((char*)(p) < (char*)(n)) +/* Check if p has its cinuse bit on */ +#define ok_cinuse(p) cinuse(p) +/* Check if p has its pinuse bit on */ +#define ok_pinuse(p) pinuse(p) + +#else /* !INSECURE */ +#define ok_address(M, a) (1) +#define ok_next(b, n) (1) +#define ok_cinuse(p) (1) +#define ok_pinuse(p) (1) +#endif /* !INSECURE */ + +#if (FOOTERS && !INSECURE) +/* Check if (alleged) mstate m has expected magic field */ +#define ok_magic(M) ((M)->magic == mparams.magic) +#else /* (FOOTERS && !INSECURE) */ +#define ok_magic(M) (1) +#endif /* (FOOTERS && !INSECURE) */ + + +/* In gcc, use __builtin_expect to minimize impact of checks */ +#if !INSECURE +#if defined(__GNUC__) && __GNUC__ >= 3 +#define RTCHECK(e) __builtin_expect(e, 1) +#else /* GNUC */ +#define RTCHECK(e) (e) +#endif /* GNUC */ +#else /* !INSECURE */ +#define RTCHECK(e) (1) +#endif /* !INSECURE */ + +/* macros to set up inuse chunks with or without footers */ + +#if !FOOTERS + +#define mark_inuse_foot(M,p,s) + +/* Set cinuse bit and pinuse bit of next chunk */ +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set size, cinuse and pinuse bit of this chunk */ +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + +#else /* FOOTERS */ + +/* Set foot of inuse chunk to be xor of mstate and seed */ +#define mark_inuse_foot(M,p,s)\ + (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) + +#define get_mstate_for(p)\ + ((mstate)(((mchunkptr)((char*)(p) +\ + (chunksize(p))))->prev_foot ^ mparams.magic)) + +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M,p,s)) + +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ + mark_inuse_foot(M,p,s)) + +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + mark_inuse_foot(M, p, s)) + +#endif /* !FOOTERS */ + +/* ---------------------------- setting mparams -------------------------- */ + +/* Initialize mparams */ +static int init_mparams(void) { + if (mparams.page_size == 0) { + size_t s; + + mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; + mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; +#if MORECORE_CONTIGUOUS + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; +#else /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; +#endif /* MORECORE_CONTIGUOUS */ + +#if (FOOTERS && !INSECURE) + { +#if USE_DEV_RANDOM + int fd; + unsigned char buf[sizeof(size_t)]; + /* Try to use /dev/urandom, else fall back on using time */ + if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && + read(fd, buf, sizeof(buf)) == sizeof(buf)) { + s = *((size_t *) buf); + close(fd); + } + else +#endif /* USE_DEV_RANDOM */ + s = (size_t)(time(0) ^ (size_t)0x55555555U); + + s |= (size_t)8U; /* ensure nonzero */ + s &= ~(size_t)7U; /* improve chances of fault for bad values */ + + } +#else /* (FOOTERS && !INSECURE) */ + s = (size_t)0x58585858U; +#endif /* (FOOTERS && !INSECURE) */ + ACQUIRE_MAGIC_INIT_LOCK(); + if (mparams.magic == 0) { + mparams.magic = s; + /* Set up lock for main malloc area */ + INITIAL_LOCK(&gm->mutex); + gm->mflags = mparams.default_mflags; + } + RELEASE_MAGIC_INIT_LOCK(); + +#if !defined(WIN32) && !defined(__OS2__) + mparams.page_size = malloc_getpagesize; + mparams.granularity = ((DEFAULT_GRANULARITY != 0)? + DEFAULT_GRANULARITY : mparams.page_size); +#elif defined (__OS2__) + /* if low-memory is used, os2munmap() would break + if it were anything other than 64k */ + mparams.page_size = 4096u; + mparams.granularity = 65536u; +#else /* WIN32 */ + { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + mparams.page_size = system_info.dwPageSize; + mparams.granularity = system_info.dwAllocationGranularity; + } +#endif /* WIN32 */ + + /* Sanity-check configuration: + size_t must be unsigned and as wide as pointer type. + ints must be at least 4 bytes. + alignment must be at least 8. + Alignment, min chunk size, and page size must all be powers of 2. + */ + if ((sizeof(size_t) != sizeof(char*)) || + (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || + (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || + ((mparams.granularity & (mparams.granularity-SIZE_T_ONE)) != 0) || + ((mparams.page_size & (mparams.page_size-SIZE_T_ONE)) != 0)) + ABORT; + } + return 0; +} + +/* support for mallopt */ +static int change_mparam(int param_number, int value) { + size_t val = (size_t)value; + init_mparams(); + switch(param_number) { + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; + return 1; + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val-1)) == 0)) { + mparams.granularity = val; + return 1; + } + else + return 0; + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: + return 0; + } +} + +#if DEBUG +/* ------------------------- Debugging Support --------------------------- */ + +/* Check properties of any chunk, whether free, inuse, mmapped etc */ +static void do_check_any_chunk(mstate m, mchunkptr p) { + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); +} + +/* Check properties of top chunk */ +static void do_check_top_chunk(mstate m, mchunkptr p) { + msegmentptr sp = segment_holding(m, (char*)p); + size_t sz = chunksize(p); + assert(sp != 0); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(sz == m->topsize); + assert(sz > 0); + assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(pinuse(p)); + assert(!next_pinuse(p)); +} + +/* Check properties of (inuse) mmapped chunks */ +static void do_check_mmapped_chunk(mstate m, mchunkptr p) { + size_t sz = chunksize(p); + size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD); + assert(is_mmapped(p)); + assert(use_mmap(m)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(!is_small(sz)); + assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); + assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); + assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); +} + +/* Check properties of inuse chunks */ +static void do_check_inuse_chunk(mstate m, mchunkptr p) { + do_check_any_chunk(m, p); + assert(cinuse(p)); + assert(next_pinuse(p)); + /* If not pinuse and not mmapped, previous chunk has OK offset */ + assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); + if (is_mmapped(p)) + do_check_mmapped_chunk(m, p); +} + +/* Check properties of free chunks */ +static void do_check_free_chunk(mstate m, mchunkptr p) { + size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); + mchunkptr next = chunk_plus_offset(p, sz); + do_check_any_chunk(m, p); + assert(!cinuse(p)); + assert(!next_pinuse(p)); + assert (!is_mmapped(p)); + if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(is_aligned(chunk2mem(p))); + assert(next->prev_foot == sz); + assert(pinuse(p)); + assert (next == m->top || cinuse(next)); + assert(p->fd->bk == p); + assert(p->bk->fd == p); + } + else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); + } +} + +/* Check properties of malloced chunks at the point they are malloced */ +static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); + do_check_inuse_chunk(m, p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(sz >= MIN_CHUNK_SIZE); + assert(sz >= s); + /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ + assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } +} + +/* Check a tree and its subtrees. */ +static void do_check_tree(mstate m, tchunkptr t) { + tchunkptr head = 0; + tchunkptr u = t; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; + compute_tree_index(tsize, idx); + assert(tindex == idx); + assert(tsize >= MIN_LARGE_SIZE); + assert(tsize >= minsize_for_tree_index(idx)); + assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); + + do { /* traverse through chain of same-sized nodes */ + do_check_any_chunk(m, ((mchunkptr)u)); + assert(u->index == tindex); + assert(chunksize(u) == tsize); + assert(!cinuse(u)); + assert(!next_pinuse(u)); + assert(u->fd->bk == u); + assert(u->bk->fd == u); + if (u->parent == 0) { + assert(u->child[0] == 0); + assert(u->child[1] == 0); + } + else { + assert(head == 0); /* only one node on chain has parent */ + head = u; + assert(u->parent != u); + assert (u->parent->child[0] == u || + u->parent->child[1] == u || + *((tbinptr*)(u->parent)) == u); + if (u->child[0] != 0) { + assert(u->child[0]->parent == u); + assert(u->child[0] != u); + do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); + assert(u->child[1] != u); + do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); +} + +/* Check all the chunks in a treebin. */ +static void do_check_treebin(mstate m, bindex_t i) { + tbinptr* tb = treebin_at(m, i); + tchunkptr t = *tb; + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) + assert(empty); + if (!empty) + do_check_tree(m, t); +} + +/* Check all the chunks in a smallbin. */ +static void do_check_smallbin(mstate m, bindex_t i) { + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; + unsigned int empty = (m->smallmap & (1U << i)) == 0; + if (p == b) + assert(empty); + if (!empty) { + for (; p != b; p = p->bk) { + size_t size = chunksize(p); + mchunkptr q; + /* each chunk claims to be free */ + do_check_free_chunk(m, p); + /* chunk belongs in bin */ + assert(small_index(size) == i); + assert(p->bk == b || chunksize(p->bk) == chunksize(p)); + /* chunk is followed by an inuse chunk */ + q = next_chunk(p); + if (q->head != FENCEPOST_HEAD) + do_check_inuse_chunk(m, q); + } + } +} + +/* Find x in a bin. Used in other check functions. */ +static int bin_find(mstate m, mchunkptr x) { + size_t size = chunksize(x); + if (is_small(size)) { + bindex_t sidx = small_index(size); + sbinptr b = smallbin_at(m, sidx); + if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; + do { + if (p == x) + return 1; + } while ((p = p->fd) != b); + } + } + else { + bindex_t tidx; + compute_tree_index(size, tidx); + if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); + while (t != 0 && chunksize(t) != size) { + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; + do { + if (u == (tchunkptr)x) + return 1; + } while ((u = u->fd) != t); + } + } + } + return 0; +} + +/* Traverse each chunk and check it; return total */ +static size_t traverse_and_check(mstate m) { + size_t sum = 0; + if (is_initialized(m)) { + msegmentptr s = &m->seg; + sum += m->topsize + TOP_FOOT_SIZE; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + mchunkptr lastq = 0; + assert(pinuse(q)); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + sum += chunksize(q); + if (cinuse(q)) { + assert(!bin_find(m, q)); + do_check_inuse_chunk(m, q); + } + else { + assert(q == m->dv || bin_find(m, q)); + assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */ + do_check_free_chunk(m, q); + } + lastq = q; + q = next_chunk(q); + } + s = s->next; + } + } + return sum; +} + +/* Check all properties of malloc_state. */ +static void do_check_malloc_state(mstate m) { + bindex_t i; + size_t total; + /* check bins */ + for (i = 0; i < NSMALLBINS; ++i) + do_check_smallbin(m, i); + for (i = 0; i < NTREEBINS; ++i) + do_check_treebin(m, i); + + if (m->dvsize != 0) { /* check dv chunk */ + do_check_any_chunk(m, m->dv); + assert(m->dvsize == chunksize(m->dv)); + assert(m->dvsize >= MIN_CHUNK_SIZE); + assert(bin_find(m, m->dv) == 0); + } + + if (m->top != 0) { /* check top chunk */ + do_check_top_chunk(m, m->top); + assert(m->topsize == chunksize(m->top)); + assert(m->topsize > 0); + assert(bin_find(m, m->top) == 0); + } + + total = traverse_and_check(m); + assert(total <= m->footprint); + assert(m->footprint <= m->max_footprint); +} +#endif /* DEBUG */ + +/* ----------------------------- statistics ------------------------------ */ + +#if !NO_MALLINFO +static struct mallinfo internal_mallinfo(mstate m) { + struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + if (!PREACTION(m)) { + check_malloc_state(m); + if (is_initialized(m)) { + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; + msegmentptr s = &m->seg; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + size_t sz = chunksize(q); + sum += sz; + if (!cinuse(q)) { + mfree += sz; + ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } + + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; + nm.uordblks = m->footprint - mfree; + nm.fordblks = mfree; + nm.keepcost = m->topsize; + } + + POSTACTION(m); + } + return nm; +} +#endif /* !NO_MALLINFO */ + +static void internal_malloc_stats(mstate m) { + if (!PREACTION(m)) { + size_t maxfp = 0; + size_t fp = 0; + size_t used = 0; + check_malloc_state(m); + if (is_initialized(m)) { + msegmentptr s = &m->seg; + maxfp = m->max_footprint; + fp = m->footprint; + used = fp - (m->topsize + TOP_FOOT_SIZE); + + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + if (!cinuse(q)) + used -= chunksize(q); + q = next_chunk(q); + } + s = s->next; + } + } + + fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); + fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); + fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); + + POSTACTION(m); + } +} + +/* ----------------------- Operations on smallbins ----------------------- */ + +/* + Various forms of linking and unlinking are defined as macros. Even + the ones for trees, which are very long but have very short typical + paths. This is ugly but reduces reliance on inlining support of + compilers. +*/ + +/* Link a free chunk into a smallbin */ +#define insert_small_chunk(M, P, S) {\ + bindex_t I = small_index(S);\ + mchunkptr B = smallbin_at(M, I);\ + mchunkptr F = B;\ + assert(S >= MIN_CHUNK_SIZE);\ + if (!smallmap_is_marked(M, I))\ + mark_smallmap(M, I);\ + else if (RTCHECK(ok_address(M, B->fd)))\ + F = B->fd;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + B->fd = P;\ + F->bk = P;\ + P->fd = F;\ + P->bk = B;\ +} + +/* Unlink a chunk from a smallbin */ +#define unlink_small_chunk(M, P, S) {\ + mchunkptr F = P->fd;\ + mchunkptr B = P->bk;\ + bindex_t I = small_index(S);\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (F == B)\ + clear_smallmap(M, I);\ + else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ + (B == smallbin_at(M,I) || ok_address(M, B)))) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} + +/* Unlink the first chunk from a smallbin */ +#define unlink_first_small_chunk(M, B, P, I) {\ + mchunkptr F = P->fd;\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (B == F)\ + clear_smallmap(M, I);\ + else if (RTCHECK(ok_address(M, F))) {\ + B->fd = F;\ + F->bk = B;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} + +/* Replace dv node, binning the old one */ +/* Used only when dvsize known to be small */ +#define replace_dv(M, P, S) {\ + size_t DVS = M->dvsize;\ + if (DVS != 0) {\ + mchunkptr DV = M->dv;\ + assert(is_small(DVS));\ + insert_small_chunk(M, DV, DVS);\ + }\ + M->dvsize = S;\ + M->dv = P;\ +} + +/* ------------------------- Operations on trees ------------------------- */ + +/* Insert chunk into tree */ +#define insert_large_chunk(M, X, S) {\ + tbinptr* H;\ + bindex_t I;\ + compute_tree_index(S, I);\ + H = treebin_at(M, I);\ + X->index = I;\ + X->child[0] = X->child[1] = 0;\ + if (!treemap_is_marked(M, I)) {\ + mark_treemap(M, I);\ + *H = X;\ + X->parent = (tchunkptr)H;\ + X->fd = X->bk = X;\ + }\ + else {\ + tchunkptr T = *H;\ + size_t K = S << leftshift_for_tree_index(I);\ + for (;;) {\ + if (chunksize(T) != S) {\ + tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ + K <<= 1;\ + if (*C != 0)\ + T = *C;\ + else if (RTCHECK(ok_address(M, C))) {\ + *C = X;\ + X->parent = T;\ + X->fd = X->bk = X;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + else {\ + tchunkptr F = T->fd;\ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ + T->fd = F->bk = X;\ + X->fd = F;\ + X->bk = T;\ + X->parent = 0;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + }\ + }\ +} + +/* + Unlink steps: + + 1. If x is a chained node, unlink it from its same-sized fd/bk links + and choose its bk node as its replacement. + 2. If x was the last node of its size, but not a leaf node, it must + be replaced with a leaf node (not merely one with an open left or + right), to make sure that lefts and rights of descendants + correspond properly to bit masks. We use the rightmost descendant + of x. We could use any other leaf, but this is easy to locate and + tends to counteract removal of leftmosts elsewhere, and so keeps + paths shorter than minimally guaranteed. This doesn't loop much + because on average a node in a tree is near the bottom. + 3. If x is the base of a chain (i.e., has parent links) relink + x's parent and children to x's replacement (or null if none). +*/ + +#define unlink_large_chunk(M, X) {\ + tchunkptr XP = X->parent;\ + tchunkptr R;\ + if (X->bk != X) {\ + tchunkptr F = X->fd;\ + R = X->bk;\ + if (RTCHECK(ok_address(M, F))) {\ + F->bk = R;\ + R->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + tchunkptr* RP;\ + if (((R = *(RP = &(X->child[1]))) != 0) ||\ + ((R = *(RP = &(X->child[0]))) != 0)) {\ + tchunkptr* CP;\ + while ((*(CP = &(R->child[1])) != 0) ||\ + (*(CP = &(R->child[0])) != 0)) {\ + R = *(RP = CP);\ + }\ + if (RTCHECK(ok_address(M, RP)))\ + *RP = 0;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + }\ + if (XP != 0) {\ + tbinptr* H = treebin_at(M, X->index);\ + if (X == *H) {\ + if ((*H = R) == 0) \ + clear_treemap(M, X->index);\ + }\ + else if (RTCHECK(ok_address(M, XP))) {\ + if (XP->child[0] == X) \ + XP->child[0] = R;\ + else \ + XP->child[1] = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + if (R != 0) {\ + if (RTCHECK(ok_address(M, R))) {\ + tchunkptr C0, C1;\ + R->parent = XP;\ + if ((C0 = X->child[0]) != 0) {\ + if (RTCHECK(ok_address(M, C0))) {\ + R->child[0] = C0;\ + C0->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + if ((C1 = X->child[1]) != 0) {\ + if (RTCHECK(ok_address(M, C1))) {\ + R->child[1] = C1;\ + C1->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ +} + +/* Relays to large vs small bin operations */ + +#define insert_chunk(M, P, S)\ + if (is_small(S)) insert_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } + +#define unlink_chunk(M, P, S)\ + if (is_small(S)) unlink_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } + + +/* Relays to internal calls to malloc/free from realloc, memalign etc */ + +#if ONLY_MSPACES +#define internal_malloc(m, b) mspace_malloc(m, b) +#define internal_free(m, mem) mspace_free(m,mem); +#else /* ONLY_MSPACES */ +#if MSPACES +#define internal_malloc(m, b)\ + (m == gm)? dlmalloc(b) : mspace_malloc(m, b) +#define internal_free(m, mem)\ + if (m == gm) dlfree(mem); else mspace_free(m,mem); +#else /* MSPACES */ +#define internal_malloc(m, b) dlmalloc(b) +#define internal_free(m, mem) dlfree(mem) +#endif /* MSPACES */ +#endif /* ONLY_MSPACES */ + +/* ----------------------- Direct-mmapping chunks ----------------------- */ + +/* + Directly mmapped chunks are set up with an offset to the start of + the mmapped region stored in the prev_foot field of the chunk. This + allows reconstruction of the required argument to MUNMAP when freed, + and also allows adjustment of the returned chunk to meet alignment + requirements (especially in memalign). There is also enough space + allocated to hold a fake next chunk of size SIZE_T_SIZE to maintain + the PINUSE bit so frees can be checked. +*/ + +/* Malloc using mmap */ +static void* mmap_alloc(mstate m, size_t nb) { + size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (mmsize > nb) { /* Check for wrap around 0 */ + char* mm = (char*)(DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset | IS_MMAPPED_BIT; + (p)->head = (psize|CINUSE_BIT); + mark_inuse_foot(m, p, psize); + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + + if (mm < m->least_addr) + m->least_addr = mm; + if ((m->footprint += mmsize) > m->max_footprint) + m->max_footprint = m->footprint; + assert(is_aligned(chunk2mem(p))); + check_mmapped_chunk(m, p); + return chunk2mem(p); + } + } + return 0; +} + +/* Realloc using mmap */ +static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) { + size_t oldsize = chunksize(oldp); + if (is_small(nb)) /* Can't shrink mmap regions below small size */ + return 0; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && + (oldsize - nb) <= (mparams.granularity << 1)) + return oldp; + else { + size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT; + size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; + size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES + + CHUNK_ALIGN_MASK); + char* cp = (char*)CALL_MREMAP((char*)oldp - offset, + oldmmsize, newmmsize, 1); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + newp->head = (psize|CINUSE_BIT); + mark_inuse_foot(m, newp, psize); + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + + if (cp < m->least_addr) + m->least_addr = cp; + if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) + m->max_footprint = m->footprint; + check_mmapped_chunk(m, newp); + return newp; + } + } + return 0; +} + +/* -------------------------- mspace management -------------------------- */ + +/* Initialize top chunk and its size */ +static void init_top(mstate m, mchunkptr p, size_t psize) { + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char*)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = mparams.trim_threshold; /* reset on each update */ +} + +/* Initialize bins for a new mstate that is otherwise zeroed out */ +static void init_bins(mstate m) { + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; ++i) { + sbinptr bin = smallbin_at(m,i); + bin->fd = bin->bk = bin; + } +} + +#if PROCEED_ON_ERROR + +/* default corruption action */ +static void reset_on_error(mstate m) { + int i; + ++malloc_corruption_error_count; + /* Reinitialize fields to forget about all memory */ + m->smallbins = m->treebins = 0; + m->dvsize = m->topsize = 0; + m->seg.base = 0; + m->seg.size = 0; + m->seg.next = 0; + m->top = m->dv = 0; + for (i = 0; i < NTREEBINS; ++i) + *treebin_at(m, i) = 0; + init_bins(m); +} +#endif /* PROCEED_ON_ERROR */ + +/* Allocate chunk and prepend remainder with chunk in successor base. */ +static void* prepend_alloc(mstate m, char* newbase, char* oldbase, + size_t nb) { + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + size_t psize = (char*)oldfirst - (char*)p; + mchunkptr q = chunk_plus_offset(p, nb); + size_t qsize = psize - nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + assert((char*)oldfirst > (char*)q); + assert(pinuse(oldfirst)); + assert(qsize >= MIN_CHUNK_SIZE); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + check_top_chunk(m, q); + } + else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } + else { + if (!cinuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + check_free_chunk(m, q); + } + + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); +} + + +/* Add a segment to hold a new noncontiguous region */ +static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { + /* Determine locations and sizes of segment, fenceposts, old top */ + char* old_top = (char*)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char* old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char* asp = rawsp + offset; + char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + assert(is_aligned(ss)); + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + (void)set_segment_flags(&m->seg, mmapped); + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + ++nfences; + if ((char*)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + assert(nfences >= 2); + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + size_t psize = csp - old_top; + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } + + check_top_chunk(m, m->top); +} + +/* -------------------------- System allocation -------------------------- */ + +/* Get memory from system using MORECORE or MMAP */ +static void* sys_alloc(mstate m, size_t nb) { + char* tbase = CMFAIL; + size_t tsize = 0; + flag_t mmap_flag = 0; + + init_mparams(); + + /* Directly map large chunks */ + if (use_mmap(m) && nb >= mparams.mmap_threshold) { + void* mem = mmap_alloc(m, nb); + if (mem != 0) + return mem; + } + + /* + Try getting memory in any of three ways (in most-preferred to + least-preferred order): + 1. A call to MORECORE that can normally contiguously extend memory. + (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or + or main space is mmapped or a previous contiguous call failed) + 2. A call to MMAP new space (disabled if not HAVE_MMAP). + Note that under the default settings, if MORECORE is unable to + fulfill a request, and HAVE_MMAP is true, then mmap is + used as a noncontiguous system allocator. This is a useful backup + strategy for systems with holes in address spaces -- in this case + sbrk cannot contiguously expand the heap, but mmap may be able to + find space. + 3. A call to MORECORE that cannot usually contiguously extend memory. + (disabled if not HAVE_MORECORE) + */ + + if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { + char* br = CMFAIL; + msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); + size_t asize = 0; + ACQUIRE_MORECORE_LOCK(); + + if (ss == 0) { /* First time through or recovery */ + char* base = (char*)CALL_MORECORE(0); + if (base != CMFAIL) { + asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); + /* Adjust to end on a page boundary */ + if (!is_page_aligned(base)) + asize += (page_align((size_t)base) - (size_t)base); + /* Can't call MORECORE if size is negative when treated as signed */ + if (asize < HALF_MAX_SIZE_T && + (br = (char*)(CALL_MORECORE(asize))) == base) { + tbase = base; + tsize = asize; + } + } + } + else { + /* Subtract out existing available top space from MORECORE request. */ + asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE); + /* Use mem here only if it did continuously extend old space */ + if (asize < HALF_MAX_SIZE_T && + (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) { + tbase = br; + tsize = asize; + } + } + + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (asize < HALF_MAX_SIZE_T && + asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) { + size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize); + if (esize < HALF_MAX_SIZE_T) { + char* end = (char*)CALL_MORECORE(esize); + if (end != CMFAIL) + asize += esize; + else { /* Can't use; try to release */ + (void)CALL_MORECORE(-asize); + br = CMFAIL; + } + } + } + } + if (br != CMFAIL) { /* Use the space we did get */ + tbase = br; + tsize = asize; + } + else + disable_contiguous(m); /* Don't try contiguous path in the future */ + } + + RELEASE_MORECORE_LOCK(); + } + + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; + size_t rsize = granularity_align(req); + if (rsize > nb) { /* Fail if wraps around zero */ + char* mp = (char*)(CALL_MMAP(rsize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = rsize; + mmap_flag = IS_MMAPPED_BIT; + } + } + } + + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); + if (asize < HALF_MAX_SIZE_T) { + char* br = CMFAIL; + char* end = CMFAIL; + ACQUIRE_MORECORE_LOCK(); + br = (char*)(CALL_MORECORE(asize)); + end = (char*)(CALL_MORECORE(0)); + RELEASE_MORECORE_LOCK(); + if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; + if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; + tsize = ssize; + } + } + } + } + + if (tbase != CMFAIL) { + + if ((m->footprint += tsize) > m->max_footprint) + m->max_footprint = m->footprint; + + if (!is_initialized(m)) { /* first-time initialization */ + m->seg.base = m->least_addr = tbase; + m->seg.size = tsize; + (void)set_segment_flags(&m->seg, mmap_flag); + m->magic = mparams.magic; + init_bins(m); + if (is_global(m)) + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + else { + /* Offset top by embedded malloc_state */ + mchunkptr mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); + } + } + + else { + /* Try to merge with an existing segment */ + msegmentptr sp = &m->seg; + while (sp != 0 && tbase != sp->base + sp->size) + sp = sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + check_segment_merge(sp, tbase, tsize) && + (get_segment_flags(sp) & IS_MMAPPED_BIT) == mmap_flag && + segment_holds(sp, m->top)) { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } + else { + if (tbase < m->least_addr) + m->least_addr = tbase; + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + check_segment_merge(sp, tbase, tsize) && + (get_segment_flags(sp) & IS_MMAPPED_BIT) == mmap_flag) { + char* oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } + else + add_segment(m, tbase, tsize, mmap_flag); + } + } + + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + check_top_chunk(m, m->top); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); + } + } + + MALLOC_FAILURE_ACTION; + return 0; +} + +/* ----------------------- system deallocation -------------------------- */ + +/* Unmap and unlink any mmapped segments that don't contain used chunks */ +static size_t release_unused_segments(mstate m) { + size_t released = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + assert(segment_holds(sp, (char*)sp)); + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + m->footprint -= size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } + else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } + pred = sp; + sp = next; + } + return released; +} + +static int sys_trim(mstate m, size_t pad) { + size_t released = 0; + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = mparams.granularity; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char*)m->top); + + if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { + if (HAVE_MMAP && + sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } + } + else if (HAVE_MORECORE) { + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; + ACQUIRE_MORECORE_LOCK(); + { + /* Make sure end of memory is where we last set it. */ + char* old_br = (char*)(CALL_MORECORE(0)); + if (old_br == sp->base + sp->size) { + char* rel_br = (char*)(CALL_MORECORE(-extra)); + char* new_br = (char*)(CALL_MORECORE(0)); + if (rel_br != CMFAIL && new_br < old_br) + released = old_br - new_br; + } + } + RELEASE_MORECORE_LOCK(); + } + } + + if (released != 0) { + sp->size -= released; + m->footprint -= released; + init_top(m, m->top, m->topsize - released); + check_top_chunk(m, m->top); + } + } + + /* Unmap any unused mmapped segments */ + if (HAVE_MMAP) + released += release_unused_segments(m); + + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0) + m->trim_check = MAX_SIZE_T; + } + + return (released != 0)? 1 : 0; +} + +/* ---------------------------- malloc support --------------------------- */ + +/* allocate a large request from the best fitting chunk in a treebin */ +static void* tmalloc_large(mstate m, size_t nb) { + tchunkptr v = 0; + size_t rsize = -nb; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) + break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } + } + + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) { + bindex_t i; + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + t = *treebin_at(m, i); + } + } + + while (t != 0) { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); + } + + /* If dv is a better fit, return 0 so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + if (RTCHECK(ok_address(m, v))) { /* split */ + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + } + CORRUPTION_ERROR_ACTION(m); + } + return 0; +} + +/* allocate a small request from the best fitting chunk in a treebin */ +static void* tmalloc_small(mstate m, size_t nb) { + tchunkptr t, v; + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); + compute_bit2idx(leastbit, i); + + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + } + + if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); + } + } + + CORRUPTION_ERROR_ACTION(m); + return 0; +} + +/* --------------------------- realloc support --------------------------- */ + +static void* internal_realloc(mstate m, void* oldmem, size_t bytes) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + return 0; + } + if (!PREACTION(m)) { + mchunkptr oldp = mem2chunk(oldmem); + size_t oldsize = chunksize(oldp); + mchunkptr next = chunk_plus_offset(oldp, oldsize); + mchunkptr newp = 0; + void* extra = 0; + + /* Try to either shrink or extend into top. Else malloc-copy-free */ + + if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) && + ok_next(oldp, next) && ok_pinuse(next))) { + size_t nb = request2size(bytes); + if (is_mmapped(oldp)) + newp = mmap_resize(m, oldp, nb); + else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; + newp = oldp; + if (rsize >= MIN_CHUNK_SIZE) { + mchunkptr remainder = chunk_plus_offset(newp, nb); + set_inuse(m, newp, nb); + set_inuse(m, remainder, rsize); + extra = chunk2mem(remainder); + } + } + else if (next == m->top && oldsize + m->topsize > nb) { + /* Expand into top */ + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(oldp, nb); + set_inuse(m, oldp, nb); + newtop->head = newtopsize |PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = oldp; + } + } + else { + USAGE_ERROR_ACTION(m, oldmem); + POSTACTION(m); + return 0; + } + + POSTACTION(m); + + if (newp != 0) { + if (extra != 0) { + internal_free(m, extra); + } + check_inuse_chunk(m, newp); + return chunk2mem(newp); + } + else { + void* newmem = internal_malloc(m, bytes); + if (newmem != 0) { + size_t oc = oldsize - overhead_for(oldp); + memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); + internal_free(m, oldmem); + } + return newmem; + } + } + return 0; +} + +/* --------------------------- memalign support -------------------------- */ + +static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { + if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ + return internal_malloc(m, bytes); + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ + alignment = MIN_CHUNK_SIZE; + if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ + size_t a = MALLOC_ALIGNMENT << 1; + while (a < alignment) a <<= 1; + alignment = a; + } + + if (bytes >= MAX_REQUEST - alignment) { + if (m != 0) { /* Test isn't needed but avoids compiler warning */ + MALLOC_FAILURE_ACTION; + } + } + else { + size_t nb = request2size(bytes); + size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; + char* mem = (char*)internal_malloc(m, req); + if (mem != 0) { + void* leader = 0; + void* trailer = 0; + mchunkptr p = mem2chunk(mem); + + if (PREACTION(m)) return 0; + if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ + /* + Find an aligned spot inside chunk. Since we need to give + back leading space in a chunk of at least MIN_CHUNK_SIZE, if + the first calculation places us at a spot with less than + MIN_CHUNK_SIZE leader, we can move to the next aligned spot. + We've allocated enough total room so that this is always + possible. + */ + char* br = (char*)mem2chunk((size_t)(((size_t)(mem + + alignment - + SIZE_T_ONE)) & + -alignment)); + char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? + br : br+alignment; + mchunkptr newp = (mchunkptr)pos; + size_t leadsize = pos - (char*)(p); + size_t newsize = chunksize(p) - leadsize; + + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + newp->prev_foot = p->prev_foot + leadsize; + newp->head = (newsize|CINUSE_BIT); + } + else { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); + set_inuse(m, p, leadsize); + leader = chunk2mem(p); + } + p = newp; + } + + /* Give back spare room at the end */ + if (!is_mmapped(p)) { + size_t size = chunksize(p); + if (size > nb + MIN_CHUNK_SIZE) { + size_t remainder_size = size - nb; + mchunkptr remainder = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, remainder, remainder_size); + trailer = chunk2mem(remainder); + } + } + + assert (chunksize(p) >= nb); + assert((((size_t)(chunk2mem(p))) % alignment) == 0); + check_inuse_chunk(m, p); + POSTACTION(m); + if (leader != 0) { + internal_free(m, leader); + } + if (trailer != 0) { + internal_free(m, trailer); + } + return chunk2mem(p); + } + } + return 0; +} + +/* ------------------------ comalloc/coalloc support --------------------- */ + +static void** ialloc(mstate m, + size_t n_elements, + size_t* sizes, + int opts, + void* chunks[]) { + /* + This provides common support for independent_X routines, handling + all of the combinations that can result. + + The opts arg has: + bit 0 set if all elements are same size (using sizes[0]) + bit 1 set if elements should be zeroed + */ + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void* mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ + size_t size; + size_t i; + + /* compute array length, if needed */ + if (chunks != 0) { + if (n_elements == 0) + return chunks; /* nothing to do */ + marray = chunks; + array_size = 0; + } + else { + /* if empty req, must still return chunk representing empty array */ + if (n_elements == 0) + return (void**)internal_malloc(m, 0); + marray = 0; + array_size = request2size(n_elements * (sizeof(void*))); + } + + /* compute total element size */ + if (opts & 0x1) { /* all-same-size */ + element_size = request2size(*sizes); + contents_size = n_elements * element_size; + } + else { /* add up all the sizes */ + element_size = 0; + contents_size = 0; + for (i = 0; i != n_elements; ++i) + contents_size += request2size(sizes[i]); + } + + size = contents_size + array_size; + + /* + Allocate the aggregate chunk. First disable direct-mmapping so + malloc won't use it, since we would not be able to later + free/realloc space internal to a segregated mmap region. + */ + was_enabled = use_mmap(m); + disable_mmap(m); + mem = internal_malloc(m, size - CHUNK_OVERHEAD); + if (was_enabled) + enable_mmap(m); + if (mem == 0) + return 0; + + if (PREACTION(m)) return 0; + p = mem2chunk(mem); + remainder_size = chunksize(p); + + assert(!is_mmapped(p)); + + if (opts & 0x2) { /* optionally clear the elements */ + memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); + } + + /* If not provided, allocate the pointer array as final part of chunk */ + if (marray == 0) { + size_t array_chunk_size; + array_chunk = chunk_plus_offset(p, contents_size); + array_chunk_size = remainder_size - contents_size; + marray = (void**) (chunk2mem(array_chunk)); + set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); + remainder_size = contents_size; + } + + /* split out elements */ + for (i = 0; ; ++i) { + marray[i] = chunk2mem(p); + if (i != n_elements-1) { + if (element_size != 0) + size = element_size; + else + size = request2size(sizes[i]); + remainder_size -= size; + set_size_and_pinuse_of_inuse_chunk(m, p, size); + p = chunk_plus_offset(p, size); + } + else { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); + break; + } + } + +#if DEBUG + if (marray != chunks) { + /* final element must have exactly exhausted chunk */ + if (element_size != 0) { + assert(remainder_size == element_size); + } + else { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); + } + for (i = 0; i != n_elements; ++i) + check_inuse_chunk(m, mem2chunk(marray[i])); + +#endif /* DEBUG */ + + POSTACTION(m); + return marray; +} + + +/* -------------------------- public routines ---------------------------- */ + +#if !ONLY_MSPACES + +void* dlmalloc(size_t bytes) { + /* + Basic algorithm: + If a small request (< 256 bytes minus per-chunk overhead): + 1. If one exists, use a remainderless chunk in associated smallbin. + (Remainderless means that there are too few excess bytes to + represent as a chunk.) + 2. If it is big enough, use the dv chunk, which is normally the + chunk adjacent to the one used for the most recent small request. + 3. If one exists, split the smallest available chunk in a bin, + saving remainder in dv. + 4. If it is big enough, use the top chunk. + 5. If available, get memory from system and use it + Otherwise, for a large request: + 1. Find the smallest available binned chunk that fits, and use it + if it is better fitting than dv chunk, splitting if necessary. + 2. If better fitting than any binned chunk, use the dv chunk. + 3. If it is big enough, use the top chunk. + 4. If request size >= mmap threshold, try to directly mmap this chunk. + 5. If available, get memory from system and use it + + The ugly goto's here ensure that postaction occurs along all paths. + */ + + if (!PREACTION(gm)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = gm->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(gm, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(gm, b, p, idx); + set_inuse_and_pinuse(gm, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb > gm->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(gm, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(gm, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(gm, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + + if (nb <= gm->dvsize) { + size_t rsize = gm->dvsize - nb; + mchunkptr p = gm->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = gm->dv = chunk_plus_offset(p, nb); + gm->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + } + else { /* exhaust dv */ + size_t dvs = gm->dvsize; + gm->dvsize = 0; + gm->dv = 0; + set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; + mchunkptr p = gm->top; + mchunkptr r = gm->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + mem = chunk2mem(p); + check_top_chunk(gm, gm->top); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + mem = sys_alloc(gm, nb); + + postaction: + POSTACTION(gm); + return mem; + } + + return 0; +} + +void dlfree(void* mem) { + /* + Consolidate freed chunks with preceding or succeeding bordering + free chunks, if they exist, and then place in a bin. Intermixed + with special cases for top, dv, mmapped chunks, and usage errors. + */ + + if (mem != 0) { + mchunkptr p = mem2chunk(mem); +#if FOOTERS + mstate fm = get_mstate_for(p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } +#else /* FOOTERS */ +#define fm gm +#endif /* FOOTERS */ + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if ((prevsize & IS_MMAPPED_BIT) != 0) { + prevsize &= ~IS_MMAPPED_BIT; + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + insert_chunk(fm, p, psize); + check_free_chunk(fm, p); + goto postaction; + } + } + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); + } + } +#if !FOOTERS +#undef fm +#endif /* FOOTERS */ +} + +void* dlcalloc(size_t n_elements, size_t elem_size) { + void* mem; + size_t req = 0; + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); + return mem; +} + +void* dlrealloc(void* oldmem, size_t bytes) { + if (oldmem == 0) + return dlmalloc(bytes); +#ifdef REALLOC_ZERO_BYTES_FREES + if (bytes == 0) { + dlfree(oldmem); + return 0; + } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else { +#if ! FOOTERS + mstate m = gm; +#else /* FOOTERS */ + mstate m = get_mstate_for(mem2chunk(oldmem)); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + return internal_realloc(m, oldmem, bytes); + } +} + +void* dlmemalign(size_t alignment, size_t bytes) { + return internal_memalign(gm, alignment, bytes); +} + +void** dlindependent_calloc(size_t n_elements, size_t elem_size, + void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + return ialloc(gm, n_elements, &sz, 3, chunks); +} + +void** dlindependent_comalloc(size_t n_elements, size_t sizes[], + void* chunks[]) { + return ialloc(gm, n_elements, sizes, 0, chunks); +} + +void* dlvalloc(size_t bytes) { + size_t pagesz; + init_mparams(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, bytes); +} + +void* dlpvalloc(size_t bytes) { + size_t pagesz; + init_mparams(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); +} + +int dlmalloc_trim(size_t pad) { + int result = 0; + if (!PREACTION(gm)) { + result = sys_trim(gm, pad); + POSTACTION(gm); + } + return result; +} + +size_t dlmalloc_footprint(void) { + return gm->footprint; +} + +size_t dlmalloc_max_footprint(void) { + return gm->max_footprint; +} + +#if !NO_MALLINFO +struct mallinfo dlmallinfo(void) { + return internal_mallinfo(gm); +} +#endif /* NO_MALLINFO */ + +void dlmalloc_stats() { + internal_malloc_stats(gm); +} + +size_t dlmalloc_usable_size(void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (cinuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; +} + +int dlmallopt(int param_number, int value) { + return change_mparam(param_number, value); +} + +#endif /* !ONLY_MSPACES */ + +/* ----------------------------- user mspaces ---------------------------- */ + +#if MSPACES + +static mstate init_user_mstate(char* tbase, size_t tsize) { + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + memset(m, 0, msize); + INITIAL_LOCK(&m->mutex); + msp->head = (msize|PINUSE_BIT|CINUSE_BIT); + m->seg.base = m->least_addr = tbase; + m->seg.size = m->footprint = m->max_footprint = tsize; + m->magic = mparams.magic; + m->mflags = mparams.default_mflags; + disable_contiguous(m); + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + check_top_chunk(m, m->top); + return m; +} + +mspace create_mspace(size_t capacity, int locked) { + mstate m = 0; + size_t msize = pad_request(sizeof(struct malloc_state)); + init_mparams(); /* Ensure pagesize etc initialized */ + + if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + size_t rs = ((capacity == 0)? mparams.granularity : + (capacity + TOP_FOOT_SIZE + msize)); + size_t tsize = granularity_align(rs); + char* tbase = (char*)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); + set_segment_flags(&m->seg, IS_MMAPPED_BIT); + set_lock(m, locked); + } + } + return (mspace)m; +} + +mspace create_mspace_with_base(void* base, size_t capacity, int locked) { + mstate m = 0; + size_t msize = pad_request(sizeof(struct malloc_state)); + init_mparams(); /* Ensure pagesize etc initialized */ + + if (capacity > msize + TOP_FOOT_SIZE && + capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + m = init_user_mstate((char*)base, capacity); + set_segment_flags(&m->seg, EXTERN_BIT); + set_lock(m, locked); + } + return (mspace)m; +} + +size_t destroy_mspace(mspace msp) { + size_t freed = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + flag_t flag = get_segment_flags(sp); + sp = sp->next; + if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) && + CALL_MUNMAP(base, size) == 0) + freed += size; + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return freed; +} + +/* + mspace versions of routines are near-clones of the global + versions. This is not so nice but better than the alternatives. +*/ + + +void* mspace_malloc(mspace msp, size_t bytes) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (!PREACTION(ms)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb > ms->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(ms, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(ms, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } + else { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + check_top_chunk(ms, ms->top); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + mem = sys_alloc(ms, nb); + + postaction: + POSTACTION(ms); + return mem; + } + + return 0; +} + +void mspace_free(mspace msp, void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); +#if FOOTERS + mstate fm = get_mstate_for(p); +#else /* FOOTERS */ + mstate fm = (mstate)msp; +#endif /* FOOTERS */ + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if ((prevsize & IS_MMAPPED_BIT) != 0) { + prevsize &= ~IS_MMAPPED_BIT; + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + insert_chunk(fm, p, psize); + check_free_chunk(fm, p); + goto postaction; + } + } + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); + } + } +} + +void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { + void* mem; + size_t req = 0; + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); + return mem; +} + +void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { + if (oldmem == 0) + return mspace_malloc(msp, bytes); +#ifdef REALLOC_ZERO_BYTES_FREES + if (bytes == 0) { + mspace_free(msp, oldmem); + return 0; + } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else { +#if FOOTERS + mchunkptr p = mem2chunk(oldmem); + mstate ms = get_mstate_for(p); +#else /* FOOTERS */ + mstate ms = (mstate)msp; +#endif /* FOOTERS */ + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return internal_realloc(ms, oldmem, bytes); + } +} + +void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return internal_memalign(ms, alignment, bytes); +} + +void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); +} + +void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); +} + +int mspace_trim(mspace msp, size_t pad) { + int result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); + POSTACTION(ms); + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +void mspace_malloc_stats(mspace msp) { + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + internal_malloc_stats(ms); + } + else { + USAGE_ERROR_ACTION(ms,ms); + } +} + +size_t mspace_footprint(mspace msp) { + size_t result; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->footprint; + } + USAGE_ERROR_ACTION(ms,ms); + return result; +} + + +size_t mspace_max_footprint(mspace msp) { + size_t result; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->max_footprint; + } + USAGE_ERROR_ACTION(ms,ms); + return result; +} + + +#if !NO_MALLINFO +struct mallinfo mspace_mallinfo(mspace msp) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + } + return internal_mallinfo(ms); +} +#endif /* NO_MALLINFO */ + +int mspace_mallopt(int param_number, int value) { + return change_mparam(param_number, value); +} + +#endif /* MSPACES */ + +/* -------------------- Alternative MORECORE functions ------------------- */ + +/* + Guidelines for creating a custom version of MORECORE: + + * For best performance, MORECORE should allocate in multiples of pagesize. + * MORECORE may allocate more memory than requested. (Or even less, + but this will usually result in a malloc failure.) + * MORECORE must not allocate memory when given argument zero, but + instead return one past the end address of memory from previous + nonzero call. + * For best performance, consecutive calls to MORECORE with positive + arguments should return increasing addresses, indicating that + space has been contiguously extended. + * Even though consecutive calls to MORECORE need not return contiguous + addresses, it must be OK for malloc'ed chunks to span multiple + regions in those cases where they do happen to be contiguous. + * MORECORE need not handle negative arguments -- it may instead + just return MFAIL when given negative arguments. + Negative arguments are always multiples of pagesize. MORECORE + must not misinterpret negative args as large positive unsigned + args. You can suppress all such calls from even occurring by defining + MORECORE_CANNOT_TRIM, + + As an example alternative MORECORE, here is a custom allocator + kindly contributed for pre-OSX macOS. It uses virtually but not + necessarily physically contiguous non-paged memory (locked in, + present and won't get swapped out). You can use it by uncommenting + this section, adding some #includes, and setting up the appropriate + defines above: + + #define MORECORE osMoreCore + + There is also a shutdown routine that should somehow be called for + cleanup upon program exit. + + #define MAX_POOL_ENTRIES 100 + #define MINIMUM_MORECORE_SIZE (64 * 1024U) + static int next_os_pool; + void *our_os_pools[MAX_POOL_ENTRIES]; + + void *osMoreCore(int size) + { + void *ptr = 0; + static void *sbrk_top = 0; + + if (size > 0) + { + if (size < MINIMUM_MORECORE_SIZE) + size = MINIMUM_MORECORE_SIZE; + if (CurrentExecutionLevel() == kTaskLevel) + ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); + if (ptr == 0) + { + return (void *) MFAIL; + } + // save ptrs so they can be freed during cleanup + our_os_pools[next_os_pool] = ptr; + next_os_pool++; + ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); + sbrk_top = (char *) ptr + size; + return ptr; + } + else if (size < 0) + { + // we don't currently support shrink behavior + return (void *) MFAIL; + } + else + { + return sbrk_top; + } + } + + // cleanup any allocated memory pools + // called as last thing before shutting down driver + + void osCleanupMem(void) + { + void **ptr; + + for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) + if (*ptr) + { + PoolDeallocate(*ptr); + *ptr = 0; + } + } + +*/ + + +/* ----------------------------------------------------------------------- +History: + V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) + * Add max_footprint functions + * Ensure all appropriate literals are size_t + * Fix conditional compilation problem for some #define settings + * Avoid concatenating segments with the one provided + in create_mspace_with_base + * Rename some variables to avoid compiler shadowing warnings + * Use explicit lock initialization. + * Better handling of sbrk interference. + * Simplify and fix segment insertion, trimming and mspace_destroy + * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x + * Thanks especially to Dennis Flanagan for help on these. + + V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) + * Fix memalign brace error. + + V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) + * Fix improper #endif nesting in C++ + * Add explicit casts needed for C++ + + V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) + * Use trees for large bins + * Support mspaces + * Use segments to unify sbrk-based and mmap-based system allocation, + removing need for emulation on most platforms without sbrk. + * Default safety checks + * Optional footer checks. Thanks to William Robertson for the idea. + * Internal code refactoring + * Incorporate suggestions and platform-specific changes. + Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, + Aaron Bachmann, Emery Berger, and others. + * Speed up non-fastbin processing enough to remove fastbins. + * Remove useless cfree() to avoid conflicts with other apps. + * Remove internal memcpy, memset. Compilers handle builtins better. + * Remove some options that no one ever used and rename others. + + V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + * Fix malloc_state bitmap array misdeclaration + + V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) + * Allow tuning of FIRST_SORTED_BIN_SIZE + * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. + * Better detection and support for non-contiguousness of MORECORE. + Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger + * Bypass most of malloc if no frees. Thanks To Emery Berger. + * Fix freeing of old top non-contiguous chunk im sysmalloc. + * Raised default trim and map thresholds to 256K. + * Fix mmap-related #defines. Thanks to Lubos Lunak. + * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. + * Branch-free bin calculation + * Default trim and mmap thresholds now 256K. + + V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) + * Introduce independent_comalloc and independent_calloc. + Thanks to Michael Pachos for motivation and help. + * Make optional .h file available + * Allow > 2GB requests on 32bit systems. + * new WIN32 sbrk, mmap, munmap, lock code from . + Thanks also to Andreas Mueller , + and Anonymous. + * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for + helping test this.) + * memalign: check alignment arg + * realloc: don't try to shift chunks backwards, since this + leads to more fragmentation in some programs and doesn't + seem to help in any others. + * Collect all cases in malloc requiring system memory into sysmalloc + * Use mmap as backup to sbrk + * Place all internal state in malloc_state + * Introduce fastbins (although similar to 2.5.1) + * Many minor tunings and cosmetic improvements + * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK + * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS + Thanks to Tony E. Bennett and others. + * Include errno.h to support default failure action. + + V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) + * return null for negative arguments + * Added Several WIN32 cleanups from Martin C. Fong + * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' + (e.g. WIN32 platforms) + * Cleanup header file inclusion for WIN32 platforms + * Cleanup code to avoid Microsoft Visual C++ compiler complaints + * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing + memory allocation routines + * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) + * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to + usage of 'assert' in non-WIN32 code + * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to + avoid infinite loop + * Always call 'fREe()' rather than 'free()' + + V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) + * Fixed ordering problem with boundary-stamping + + V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) + * Added pvalloc, as recommended by H.J. Liu + * Added 64bit pointer support mainly from Wolfram Gloger + * Added anonymously donated WIN32 sbrk emulation + * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen + * malloc_extend_top: fix mask error that caused wastage after + foreign sbrks + * Add linux mremap support code from HJ Liu + + V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) + * Integrated most documentation with the code. + * Add support for mmap, with help from + Wolfram Gloger (Gloger@lrz.uni-muenchen.de). + * Use last_remainder in more cases. + * Pack bins using idea from colin@nyx10.cs.du.edu + * Use ordered bins instead of best-fit threshold + * Eliminate block-local decls to simplify tracing and debugging. + * Support another case of realloc via move into top + * Fix error occurring when initial sbrk_base not word-aligned. + * Rely on page size for units instead of SBRK_UNIT to + avoid surprises about sbrk alignment conventions. + * Add mallinfo, mallopt. Thanks to Raymond Nijssen + (raymond@es.ele.tue.nl) for the suggestion. + * Add `pad' argument to malloc_trim and top_pad mallopt parameter. + * More precautions for cases where other routines call sbrk, + courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). + * Added macros etc., allowing use in linux libc from + H.J. Lu (hjl@gnu.ai.mit.edu) + * Inverted this history list + + V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) + * Re-tuned and fixed to behave more nicely with V2.6.0 changes. + * Removed all preallocation code since under current scheme + the work required to undo bad preallocations exceeds + the work saved in good cases for most test programs. + * No longer use return list or unconsolidated bins since + no scheme using them consistently outperforms those that don't + given above changes. + * Use best fit for very large chunks to prevent some worst-cases. + * Added some support for debugging + + V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) + * Removed footers when chunks are in use. Thanks to + Paul Wilson (wilson@cs.texas.edu) for the suggestion. + + V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) + * Added malloc_trim, with help from Wolfram Gloger + (wmglo@Dent.MED.Uni-Muenchen.DE). + + V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) + + V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) + * realloc: try to expand in both directions + * malloc: swap order of clean-bin strategy; + * realloc: only conditionally expand backwards + * Try not to scavenge used bins + * Use bin counts as a guide to preallocation + * Occasionally bin return list chunks in first scan + * Add a few optimizations from colin@nyx10.cs.du.edu + + V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) + * faster bin computation & slightly different binning + * merged all consolidations to one part of malloc proper + (eliminating old malloc_find_space & malloc_clean_bin) + * Scan 2 returns chunks (not just 1) + * Propagate failure in realloc if malloc returns 0 + * Add stuff to allow compilation on non-ANSI compilers + from kpv@research.att.com + + V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) + * removed potential for odd address access in prev_chunk + * removed dependency on getpagesize.h + * misc cosmetics and a bit more internal documentation + * anticosmetics: mangled names in macros to evade debugger strangeness + * tested on sparc, hp-700, dec-mips, rs6000 + with gcc & native cc (hp, dec only) allowing + Detlefs & Zorn comparison study (in SIGPLAN Notices.) + + Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) + * Based loosely on libg++-1.2X malloc. (It retains some of the overall + structure of old version, but most details differ.) + +*/ diff --git a/user/mpy/lib/libffi/src/frv/eabi.S b/user/mpy/lib/libffi/src/frv/eabi.S new file mode 100644 index 0000000..379ea4b --- /dev/null +++ b/user/mpy/lib/libffi/src/frv/eabi.S @@ -0,0 +1,128 @@ +/* ----------------------------------------------------------------------- + eabi.S - Copyright (c) 2004 Anthony Green + + FR-V Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + .globl ffi_prep_args_EABI + + .text + .p2align 4 + .globl ffi_call_EABI + .type ffi_call_EABI, @function + + # gr8 : ffi_prep_args + # gr9 : &ecif + # gr10: cif->bytes + # gr11: fig->flags + # gr12: ecif.rvalue + # gr13: fn + +ffi_call_EABI: + addi sp, #-80, sp + sti fp, @(sp, #24) + addi sp, #24, fp + movsg lr, gr5 + + /* Make room for the new arguments. */ + /* subi sp, fp, gr10 */ + + /* Store return address and incoming args on stack. */ + sti gr5, @(fp, #8) + sti gr8, @(fp, #-4) + sti gr9, @(fp, #-8) + sti gr10, @(fp, #-12) + sti gr11, @(fp, #-16) + sti gr12, @(fp, #-20) + sti gr13, @(fp, #-24) + + sub sp, gr10, sp + + /* Call ffi_prep_args. */ + ldi @(fp, #-4), gr4 + addi sp, #0, gr8 + ldi @(fp, #-8), gr9 +#ifdef __FRV_FDPIC__ + ldd @(gr4, gr0), gr14 + calll @(gr14, gr0) +#else + calll @(gr4, gr0) +#endif + + /* ffi_prep_args returns the new stack pointer. */ + mov gr8, gr4 + + ldi @(sp, #0), gr8 + ldi @(sp, #4), gr9 + ldi @(sp, #8), gr10 + ldi @(sp, #12), gr11 + ldi @(sp, #16), gr12 + ldi @(sp, #20), gr13 + + /* Always copy the return value pointer into the hidden + parameter register. This is only strictly necessary + when we're returning an aggregate type, but it doesn't + hurt to do this all the time, and it saves a branch. */ + ldi @(fp, #-20), gr3 + + /* Use the ffi_prep_args return value for the new sp. */ + mov gr4, sp + + /* Call the target function. */ + ldi @(fp, -24), gr4 +#ifdef __FRV_FDPIC__ + ldd @(gr4, gr0), gr14 + calll @(gr14, gr0) +#else + calll @(gr4, gr0) +#endif + + /* Store the result. */ + ldi @(fp, #-16), gr10 /* fig->flags */ + ldi @(fp, #-20), gr4 /* ecif.rvalue */ + + /* Is the return value stored in two registers? */ + cmpi gr10, #8, icc0 + bne icc0, 0, .L2 + /* Yes, save them. */ + sti gr8, @(gr4, #0) + sti gr9, @(gr4, #4) + bra .L3 +.L2: + /* Is the return value a structure? */ + cmpi gr10, #-1, icc0 + beq icc0, 0, .L3 + /* No, save a 4 byte return value. */ + sti gr8, @(gr4, #0) +.L3: + + /* Restore the stack, and return. */ + ldi @(fp, 8), gr5 + ld @(fp, gr0), fp + addi sp,#80,sp + jmpl @(gr5,gr0) + .size ffi_call_EABI, .-ffi_call_EABI + diff --git a/user/mpy/lib/libffi/src/frv/ffi.c b/user/mpy/lib/libffi/src/frv/ffi.c new file mode 100644 index 0000000..5698c89 --- /dev/null +++ b/user/mpy/lib/libffi/src/frv/ffi.c @@ -0,0 +1,292 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (C) 2004 Anthony Green + Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2008 Red Hat, Inc. + + FR-V Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +void *ffi_prep_args(char *stack, extended_cif *ecif) +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + register int count = 0; + + p_argv = ecif->avalue; + argp = stack; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); + i--, p_arg++) + { + size_t z; + + z = (*p_arg)->size; + + if ((*p_arg)->type == FFI_TYPE_STRUCT) + { + z = sizeof(void*); + *(void **) argp = *p_argv; + } + /* if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (count > 24) + { + // This is going on the stack. Turn it into a double. + *(double *) argp = (double) *(float*)(* p_argv); + z = sizeof(double); + } + else + *(void **) argp = *(void **)(* p_argv); + } */ + else if (z < sizeof(int)) + { + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + default: + FFI_ASSERT(0); + } + } + else if (z == sizeof(int)) + { + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + } + else + { + memcpy(argp, *p_argv, z); + } + p_argv++; + argp += z; + count += z; + } + + return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8))); +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + if (cif->rtype->type == FFI_TYPE_STRUCT) + cif->flags = -1; + else + cif->flags = cif->rtype->size; + + cif->bytes = ALIGN (cif->bytes, 8); + + return FFI_OK; +} + +extern void ffi_call_EABI(void *(*)(char *, extended_cif *), + extended_cif *, + unsigned, unsigned, + unsigned *, + void (*fn)(void)); + +void ffi_call(ffi_cif *cif, + void (*fn)(void), + void *rvalue, + void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca(cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + + switch (cif->abi) + { + case FFI_EABI: + ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + break; + default: + FFI_ASSERT(0); + break; + } +} + +void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, + unsigned arg4, unsigned arg5, unsigned arg6) +{ + /* This function is called by a trampoline. The trampoline stows a + pointer to the ffi_closure object in gr7. We must save this + pointer in a place that will persist while we do our work. */ + register ffi_closure *creg __asm__ ("gr7"); + ffi_closure *closure = creg; + + /* Arguments that don't fit in registers are found on the stack + at a fixed offset above the current frame pointer. */ + register char *frame_pointer __asm__ ("fp"); + char *stack_args = frame_pointer + 16; + + /* Lay the register arguments down in a continuous chunk of memory. */ + unsigned register_args[6] = + { arg1, arg2, arg3, arg4, arg5, arg6 }; + + ffi_cif *cif = closure->cif; + ffi_type **arg_types = cif->arg_types; + void **avalue = alloca (cif->nargs * sizeof(void *)); + char *ptr = (char *) register_args; + int i; + + /* Find the address of each argument. */ + for (i = 0; i < cif->nargs; i++) + { + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + avalue[i] = ptr + 3; + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + avalue[i] = ptr + 2; + break; + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + avalue[i] = ptr; + break; + case FFI_TYPE_STRUCT: + avalue[i] = *(void**)ptr; + break; + default: + /* This is an 8-byte value. */ + avalue[i] = ptr; + ptr += 4; + break; + } + ptr += 4; + + /* If we've handled more arguments than fit in registers, + start looking at the those passed on the stack. */ + if (ptr == ((char *)register_args + (6*4))) + ptr = stack_args; + } + + /* Invoke the closure. */ + if (cif->rtype->type == FFI_TYPE_STRUCT) + { + /* The caller allocates space for the return structure, and + passes a pointer to this space in gr3. Use this value directly + as the return value. */ + register void *return_struct_ptr __asm__("gr3"); + (closure->fun) (cif, return_struct_ptr, avalue, closure->user_data); + } + else + { + /* Allocate space for the return value and call the function. */ + long long rvalue; + (closure->fun) (cif, &rvalue, avalue, closure->user_data); + + /* Functions return 4-byte or smaller results in gr8. 8-byte + values also use gr9. We fill the both, even for small return + values, just to avoid a branch. */ + asm ("ldi @(%0, #0), gr8" : : "r" (&rvalue)); + asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1])); + } +} + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; + unsigned long fn = (long) ffi_closure_eabi; + unsigned long cls = (long) codeloc; +#ifdef __FRV_FDPIC__ + register void *got __asm__("gr15"); +#endif + int i; + + fn = (unsigned long) ffi_closure_eabi; + +#ifdef __FRV_FDPIC__ + tramp[0] = &((unsigned int *)codeloc)[2]; + tramp[1] = got; + tramp[2] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */ + tramp[3] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */ + tramp[4] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */ + tramp[5] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */ + tramp[6] = 0x9cc86000; /* ldi @(gr6, #0), gr14 */ + tramp[7] = 0x8030e000; /* jmpl @(gr14, gr0) */ +#else + tramp[0] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */ + tramp[1] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */ + tramp[2] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */ + tramp[3] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */ + tramp[4] = 0x80300006; /* jmpl @(gr0, gr6) */ +#endif + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + /* Cache flushing. */ + for (i = 0; i < FFI_TRAMPOLINE_SIZE; i++) + __asm__ volatile ("dcf @(%0,%1)\n\tici @(%2,%1)" :: "r" (tramp), "r" (i), + "r" (codeloc)); + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/frv/ffitarget.h b/user/mpy/lib/libffi/src/frv/ffitarget.h new file mode 100644 index 0000000..d42540e --- /dev/null +++ b/user/mpy/lib/libffi/src/frv/ffitarget.h @@ -0,0 +1,62 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2004 Red Hat, Inc. + Target configuration macros for FR-V + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_EABI, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_EABI +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 + +#ifdef __FRV_FDPIC__ +/* Trampolines are 8 4-byte instructions long. */ +#define FFI_TRAMPOLINE_SIZE (8*4) +#else +/* Trampolines are 5 4-byte instructions long. */ +#define FFI_TRAMPOLINE_SIZE (5*4) +#endif + +#endif diff --git a/user/mpy/lib/libffi/src/ia64/ffi.c b/user/mpy/lib/libffi/src/ia64/ffi.c new file mode 100644 index 0000000..b77a836 --- /dev/null +++ b/user/mpy/lib/libffi/src/ia64/ffi.c @@ -0,0 +1,586 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 1998, 2007, 2008, 2012 Red Hat, Inc. + Copyright (c) 2000 Hewlett Packard Company + Copyright (c) 2011 Anthony Green + + IA64 Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include +#include +#include + +#include "ia64_flags.h" + +/* A 64-bit pointer value. In LP64 mode, this is effectively a plain + pointer. In ILP32 mode, it's a pointer that's been extended to + 64 bits by "addp4". */ +typedef void *PTR64 __attribute__((mode(DI))); + +/* Memory image of fp register contents. This is the implementation + specific format used by ldf.fill/stf.spill. All we care about is + that it wants a 16 byte aligned slot. */ +typedef struct +{ + UINT64 x[2] __attribute__((aligned(16))); +} fpreg; + + +/* The stack layout given to ffi_call_unix and ffi_closure_unix_inner. */ + +struct ia64_args +{ + fpreg fp_regs[8]; /* Contents of 8 fp arg registers. */ + UINT64 gp_regs[8]; /* Contents of 8 gp arg registers. */ + UINT64 other_args[]; /* Arguments passed on stack, variable size. */ +}; + + +/* Adjust ADDR, a pointer to an 8 byte slot, to point to the low LEN bytes. */ + +static inline void * +endian_adjust (void *addr, size_t len) +{ +#ifdef __BIG_ENDIAN__ + return addr + (8 - len); +#else + return addr; +#endif +} + +/* Store VALUE to ADDR in the current cpu implementation's fp spill format. + This is a macro instead of a function, so that it works for all 3 floating + point types without type conversions. Type conversion to long double breaks + the denorm support. */ + +#define stf_spill(addr, value) \ + asm ("stf.spill %0 = %1%P0" : "=m" (*addr) : "f"(value)); + +/* Load a value from ADDR, which is in the current cpu implementation's + fp spill format. As above, this must also be a macro. */ + +#define ldf_fill(result, addr) \ + asm ("ldf.fill %0 = %1%P1" : "=f"(result) : "m"(*addr)); + +/* Return the size of the C type associated with with TYPE. Which will + be one of the FFI_IA64_TYPE_HFA_* values. */ + +static size_t +hfa_type_size (int type) +{ + switch (type) + { + case FFI_IA64_TYPE_HFA_FLOAT: + return sizeof(float); + case FFI_IA64_TYPE_HFA_DOUBLE: + return sizeof(double); + case FFI_IA64_TYPE_HFA_LDOUBLE: + return sizeof(__float80); + default: + abort (); + } +} + +/* Load from ADDR a value indicated by TYPE. Which will be one of + the FFI_IA64_TYPE_HFA_* values. */ + +static void +hfa_type_load (fpreg *fpaddr, int type, void *addr) +{ + switch (type) + { + case FFI_IA64_TYPE_HFA_FLOAT: + stf_spill (fpaddr, *(float *) addr); + return; + case FFI_IA64_TYPE_HFA_DOUBLE: + stf_spill (fpaddr, *(double *) addr); + return; + case FFI_IA64_TYPE_HFA_LDOUBLE: + stf_spill (fpaddr, *(__float80 *) addr); + return; + default: + abort (); + } +} + +/* Load VALUE into ADDR as indicated by TYPE. Which will be one of + the FFI_IA64_TYPE_HFA_* values. */ + +static void +hfa_type_store (int type, void *addr, fpreg *fpaddr) +{ + switch (type) + { + case FFI_IA64_TYPE_HFA_FLOAT: + { + float result; + ldf_fill (result, fpaddr); + *(float *) addr = result; + break; + } + case FFI_IA64_TYPE_HFA_DOUBLE: + { + double result; + ldf_fill (result, fpaddr); + *(double *) addr = result; + break; + } + case FFI_IA64_TYPE_HFA_LDOUBLE: + { + __float80 result; + ldf_fill (result, fpaddr); + *(__float80 *) addr = result; + break; + } + default: + abort (); + } +} + +/* Is TYPE a struct containing floats, doubles, or extended doubles, + all of the same fp type? If so, return the element type. Return + FFI_TYPE_VOID if not. */ + +static int +hfa_element_type (ffi_type *type, int nested) +{ + int element = FFI_TYPE_VOID; + + switch (type->type) + { + case FFI_TYPE_FLOAT: + /* We want to return VOID for raw floating-point types, but the + synthetic HFA type if we're nested within an aggregate. */ + if (nested) + element = FFI_IA64_TYPE_HFA_FLOAT; + break; + + case FFI_TYPE_DOUBLE: + /* Similarly. */ + if (nested) + element = FFI_IA64_TYPE_HFA_DOUBLE; + break; + + case FFI_TYPE_LONGDOUBLE: + /* Similarly, except that that HFA is true for double extended, + but not quad precision. Both have sizeof == 16, so tell the + difference based on the precision. */ + if (LDBL_MANT_DIG == 64 && nested) + element = FFI_IA64_TYPE_HFA_LDOUBLE; + break; + + case FFI_TYPE_STRUCT: + { + ffi_type **ptr = &type->elements[0]; + + for (ptr = &type->elements[0]; *ptr ; ptr++) + { + int sub_element = hfa_element_type (*ptr, 1); + if (sub_element == FFI_TYPE_VOID) + return FFI_TYPE_VOID; + + if (element == FFI_TYPE_VOID) + element = sub_element; + else if (element != sub_element) + return FFI_TYPE_VOID; + } + } + break; + + default: + return FFI_TYPE_VOID; + } + + return element; +} + + +/* Perform machine dependent cif processing. */ + +ffi_status +ffi_prep_cif_machdep(ffi_cif *cif) +{ + int flags; + + /* Adjust cif->bytes to include space for the bits of the ia64_args frame + that precedes the integer register portion. The estimate that the + generic bits did for the argument space required is good enough for the + integer component. */ + cif->bytes += offsetof(struct ia64_args, gp_regs[0]); + if (cif->bytes < sizeof(struct ia64_args)) + cif->bytes = sizeof(struct ia64_args); + + /* Set the return type flag. */ + flags = cif->rtype->type; + switch (cif->rtype->type) + { + case FFI_TYPE_LONGDOUBLE: + /* Leave FFI_TYPE_LONGDOUBLE as meaning double extended precision, + and encode quad precision as a two-word integer structure. */ + if (LDBL_MANT_DIG != 64) + flags = FFI_IA64_TYPE_SMALL_STRUCT | (16 << 8); + break; + + case FFI_TYPE_STRUCT: + { + size_t size = cif->rtype->size; + int hfa_type = hfa_element_type (cif->rtype, 0); + + if (hfa_type != FFI_TYPE_VOID) + { + size_t nelts = size / hfa_type_size (hfa_type); + if (nelts <= 8) + flags = hfa_type | (size << 8); + } + else + { + if (size <= 32) + flags = FFI_IA64_TYPE_SMALL_STRUCT | (size << 8); + } + } + break; + + default: + break; + } + cif->flags = flags; + + return FFI_OK; +} + +extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(void), UINT64); + +void +ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + struct ia64_args *stack; + long i, avn, gpcount, fpcount; + ffi_type **p_arg; + + FFI_ASSERT (cif->abi == FFI_UNIX); + + /* If we have no spot for a return value, make one. */ + if (rvalue == NULL && cif->rtype->type != FFI_TYPE_VOID) + rvalue = alloca (cif->rtype->size); + + /* Allocate the stack frame. */ + stack = alloca (cif->bytes); + + gpcount = fpcount = 0; + avn = cif->nargs; + for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) + { + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + stack->gp_regs[gpcount++] = *(SINT8 *)avalue[i]; + break; + case FFI_TYPE_UINT8: + stack->gp_regs[gpcount++] = *(UINT8 *)avalue[i]; + break; + case FFI_TYPE_SINT16: + stack->gp_regs[gpcount++] = *(SINT16 *)avalue[i]; + break; + case FFI_TYPE_UINT16: + stack->gp_regs[gpcount++] = *(UINT16 *)avalue[i]; + break; + case FFI_TYPE_SINT32: + stack->gp_regs[gpcount++] = *(SINT32 *)avalue[i]; + break; + case FFI_TYPE_UINT32: + stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i]; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i]; + break; + + case FFI_TYPE_POINTER: + stack->gp_regs[gpcount++] = (UINT64)(PTR64) *(void **)avalue[i]; + break; + + case FFI_TYPE_FLOAT: + if (gpcount < 8 && fpcount < 8) + stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]); + { + UINT32 tmp; + memcpy (&tmp, avalue[i], sizeof (UINT32)); + stack->gp_regs[gpcount++] = tmp; + } + break; + + case FFI_TYPE_DOUBLE: + if (gpcount < 8 && fpcount < 8) + stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]); + memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64)); + break; + + case FFI_TYPE_LONGDOUBLE: + if (gpcount & 1) + gpcount++; + if (LDBL_MANT_DIG == 64 && gpcount < 8 && fpcount < 8) + stf_spill (&stack->fp_regs[fpcount++], *(__float80 *)avalue[i]); + memcpy (&stack->gp_regs[gpcount], avalue[i], 16); + gpcount += 2; + break; + + case FFI_TYPE_STRUCT: + { + size_t size = (*p_arg)->size; + size_t align = (*p_arg)->alignment; + int hfa_type = hfa_element_type (*p_arg, 0); + + FFI_ASSERT (align <= 16); + if (align == 16 && (gpcount & 1)) + gpcount++; + + if (hfa_type != FFI_TYPE_VOID) + { + size_t hfa_size = hfa_type_size (hfa_type); + size_t offset = 0; + size_t gp_offset = gpcount * 8; + + while (fpcount < 8 + && offset < size + && gp_offset < 8 * 8) + { + hfa_type_load (&stack->fp_regs[fpcount], hfa_type, + avalue[i] + offset); + offset += hfa_size; + gp_offset += hfa_size; + fpcount += 1; + } + } + + memcpy (&stack->gp_regs[gpcount], avalue[i], size); + gpcount += (size + 7) / 8; + } + break; + + default: + abort (); + } + } + + ffi_call_unix (stack, rvalue, fn, cif->flags); +} + +/* Closures represent a pair consisting of a function pointer, and + some user data. A closure is invoked by reinterpreting the closure + as a function pointer, and branching to it. Thus we can make an + interpreted function callable as a C function: We turn the + interpreter itself, together with a pointer specifying the + interpreted procedure, into a closure. + + For IA64, function pointer are already pairs consisting of a code + pointer, and a gp pointer. The latter is needed to access global + variables. Here we set up such a pair as the first two words of + the closure (in the "trampoline" area), but we replace the gp + pointer with a pointer to the closure itself. We also add the real + gp pointer to the closure. This allows the function entry code to + both retrieve the user data, and to restore the correct gp pointer. */ + +extern void ffi_closure_unix (); + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + /* The layout of a function descriptor. A C function pointer really + points to one of these. */ + struct ia64_fd + { + UINT64 code_pointer; + UINT64 gp; + }; + + struct ffi_ia64_trampoline_struct + { + UINT64 code_pointer; /* Pointer to ffi_closure_unix. */ + UINT64 fake_gp; /* Pointer to closure, installed as gp. */ + UINT64 real_gp; /* Real gp value. */ + }; + + struct ffi_ia64_trampoline_struct *tramp; + struct ia64_fd *fd; + + if (cif->abi != FFI_UNIX) + return FFI_BAD_ABI; + + tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp; + fd = (struct ia64_fd *)(void *)ffi_closure_unix; + + tramp->code_pointer = fd->code_pointer; + tramp->real_gp = fd->gp; + tramp->fake_gp = (UINT64)(PTR64)codeloc; + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} + + +UINT64 +ffi_closure_unix_inner (ffi_closure *closure, struct ia64_args *stack, + void *rvalue, void *r8) +{ + ffi_cif *cif; + void **avalue; + ffi_type **p_arg; + long i, avn, gpcount, fpcount; + + cif = closure->cif; + avn = cif->nargs; + avalue = alloca (avn * sizeof (void *)); + + /* If the structure return value is passed in memory get that location + from r8 so as to pass the value directly back to the caller. */ + if (cif->flags == FFI_TYPE_STRUCT) + rvalue = r8; + + gpcount = fpcount = 0; + for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) + { + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 1); + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 2); + break; + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 4); + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + avalue[i] = &stack->gp_regs[gpcount++]; + break; + case FFI_TYPE_POINTER: + avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], sizeof(void*)); + break; + + case FFI_TYPE_FLOAT: + if (gpcount < 8 && fpcount < 8) + { + fpreg *addr = &stack->fp_regs[fpcount++]; + float result; + avalue[i] = addr; + ldf_fill (result, addr); + *(float *)addr = result; + } + else + avalue[i] = endian_adjust(&stack->gp_regs[gpcount], 4); + gpcount++; + break; + + case FFI_TYPE_DOUBLE: + if (gpcount < 8 && fpcount < 8) + { + fpreg *addr = &stack->fp_regs[fpcount++]; + double result; + avalue[i] = addr; + ldf_fill (result, addr); + *(double *)addr = result; + } + else + avalue[i] = &stack->gp_regs[gpcount]; + gpcount++; + break; + + case FFI_TYPE_LONGDOUBLE: + if (gpcount & 1) + gpcount++; + if (LDBL_MANT_DIG == 64 && gpcount < 8 && fpcount < 8) + { + fpreg *addr = &stack->fp_regs[fpcount++]; + __float80 result; + avalue[i] = addr; + ldf_fill (result, addr); + *(__float80 *)addr = result; + } + else + avalue[i] = &stack->gp_regs[gpcount]; + gpcount += 2; + break; + + case FFI_TYPE_STRUCT: + { + size_t size = (*p_arg)->size; + size_t align = (*p_arg)->alignment; + int hfa_type = hfa_element_type (*p_arg, 0); + + FFI_ASSERT (align <= 16); + if (align == 16 && (gpcount & 1)) + gpcount++; + + if (hfa_type != FFI_TYPE_VOID) + { + size_t hfa_size = hfa_type_size (hfa_type); + size_t offset = 0; + size_t gp_offset = gpcount * 8; + void *addr = alloca (size); + + avalue[i] = addr; + + while (fpcount < 8 + && offset < size + && gp_offset < 8 * 8) + { + hfa_type_store (hfa_type, addr + offset, + &stack->fp_regs[fpcount]); + offset += hfa_size; + gp_offset += hfa_size; + fpcount += 1; + } + + if (offset < size) + memcpy (addr + offset, (char *)stack->gp_regs + gp_offset, + size - offset); + } + else + avalue[i] = &stack->gp_regs[gpcount]; + + gpcount += (size + 7) / 8; + } + break; + + default: + abort (); + } + } + + closure->fun (cif, rvalue, avalue, closure->user_data); + + return cif->flags; +} diff --git a/user/mpy/lib/libffi/src/ia64/ffitarget.h b/user/mpy/lib/libffi/src/ia64/ffitarget.h new file mode 100644 index 0000000..e68cea6 --- /dev/null +++ b/user/mpy/lib/libffi/src/ia64/ffitarget.h @@ -0,0 +1,55 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for IA-64. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long long ffi_arg; +typedef signed long long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_UNIX, /* Linux and all Unix variants use the same conventions */ + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_UNIX +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 24 /* Really the following struct, which */ + /* can be interpreted as a C function */ + /* descriptor: */ + +#endif + diff --git a/user/mpy/lib/libffi/src/ia64/ia64_flags.h b/user/mpy/lib/libffi/src/ia64/ia64_flags.h new file mode 100644 index 0000000..9d652ce --- /dev/null +++ b/user/mpy/lib/libffi/src/ia64/ia64_flags.h @@ -0,0 +1,40 @@ +/* ----------------------------------------------------------------------- + ia64_flags.h - Copyright (c) 2000 Hewlett Packard Company + + IA64/unix Foreign Function Interface + + Original author: Hans Boehm, HP Labs + + 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. + ----------------------------------------------------------------------- */ + +/* "Type" codes used between assembly and C. When used as a part of + a cfi->flags value, the low byte will be these extra type codes, + and bits 8-31 will be the actual size of the type. */ + +/* Small structures containing N words in integer registers. */ +#define FFI_IA64_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 1) + +/* Homogeneous Floating Point Aggregates (HFAs) which are returned + in FP registers. */ +#define FFI_IA64_TYPE_HFA_FLOAT (FFI_TYPE_LAST + 2) +#define FFI_IA64_TYPE_HFA_DOUBLE (FFI_TYPE_LAST + 3) +#define FFI_IA64_TYPE_HFA_LDOUBLE (FFI_TYPE_LAST + 4) diff --git a/user/mpy/lib/libffi/src/ia64/unix.S b/user/mpy/lib/libffi/src/ia64/unix.S new file mode 100644 index 0000000..4d2a86d --- /dev/null +++ b/user/mpy/lib/libffi/src/ia64/unix.S @@ -0,0 +1,560 @@ +/* ----------------------------------------------------------------------- + unix.S - Copyright (c) 1998, 2008 Red Hat, Inc. + Copyright (c) 2000 Hewlett Packard Company + + IA64/unix Foreign Function Interface + + Primary author: Hans Boehm, HP Labs + + Loosely modeled on Cygnus code for other platforms. + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#include "ia64_flags.h" + + .pred.safe_across_calls p1-p5,p16-p63 +.text + +/* int ffi_call_unix (struct ia64_args *stack, PTR64 rvalue, + void (*fn)(void), int flags); + */ + + .align 16 + .global ffi_call_unix + .proc ffi_call_unix +ffi_call_unix: + .prologue + /* Bit o trickiness. We actually share a stack frame with ffi_call. + Rely on the fact that ffi_call uses a vframe and don't bother + tracking one here at all. */ + .fframe 0 + .save ar.pfs, r36 // loc0 + alloc loc0 = ar.pfs, 4, 3, 8, 0 + .save rp, loc1 + mov loc1 = b0 + .body + add r16 = 16, in0 + mov loc2 = gp + mov r8 = in1 + ;; + + /* Load up all of the argument registers. */ + ldf.fill f8 = [in0], 32 + ldf.fill f9 = [r16], 32 + ;; + ldf.fill f10 = [in0], 32 + ldf.fill f11 = [r16], 32 + ;; + ldf.fill f12 = [in0], 32 + ldf.fill f13 = [r16], 32 + ;; + ldf.fill f14 = [in0], 32 + ldf.fill f15 = [r16], 24 + ;; + ld8 out0 = [in0], 16 + ld8 out1 = [r16], 16 + ;; + ld8 out2 = [in0], 16 + ld8 out3 = [r16], 16 + ;; + ld8 out4 = [in0], 16 + ld8 out5 = [r16], 16 + ;; + ld8 out6 = [in0] + ld8 out7 = [r16] + ;; + + /* Deallocate the register save area from the stack frame. */ + mov sp = in0 + + /* Call the target function. */ + ld8 r16 = [in2], 8 + ;; + ld8 gp = [in2] + mov b6 = r16 + br.call.sptk.many b0 = b6 + ;; + + /* Dispatch to handle return value. */ + mov gp = loc2 + zxt1 r16 = in3 + ;; + mov ar.pfs = loc0 + addl r18 = @ltoffx(.Lst_table), gp + ;; + ld8.mov r18 = [r18], .Lst_table + mov b0 = loc1 + ;; + shladd r18 = r16, 3, r18 + ;; + ld8 r17 = [r18] + shr in3 = in3, 8 + ;; + add r17 = r17, r18 + ;; + mov b6 = r17 + br b6 + ;; + +.Lst_void: + br.ret.sptk.many b0 + ;; +.Lst_uint8: + zxt1 r8 = r8 + ;; + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_sint8: + sxt1 r8 = r8 + ;; + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_uint16: + zxt2 r8 = r8 + ;; + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_sint16: + sxt2 r8 = r8 + ;; + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_uint32: + zxt4 r8 = r8 + ;; + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_sint32: + sxt4 r8 = r8 + ;; + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_int64: + st8 [in1] = r8 + br.ret.sptk.many b0 + ;; +.Lst_float: + stfs [in1] = f8 + br.ret.sptk.many b0 + ;; +.Lst_double: + stfd [in1] = f8 + br.ret.sptk.many b0 + ;; +.Lst_ldouble: + stfe [in1] = f8 + br.ret.sptk.many b0 + ;; + +.Lst_small_struct: + add sp = -16, sp + cmp.lt p6, p0 = 8, in3 + cmp.lt p7, p0 = 16, in3 + cmp.lt p8, p0 = 24, in3 + ;; + add r16 = 8, sp + add r17 = 16, sp + add r18 = 24, sp + ;; + st8 [sp] = r8 +(p6) st8 [r16] = r9 + mov out0 = in1 +(p7) st8 [r17] = r10 +(p8) st8 [r18] = r11 + mov out1 = sp + mov out2 = in3 + br.call.sptk.many b0 = memcpy# + ;; + mov ar.pfs = loc0 + mov b0 = loc1 + mov gp = loc2 + br.ret.sptk.many b0 + +.Lst_hfa_float: + add r16 = 4, in1 + cmp.lt p6, p0 = 4, in3 + ;; + stfs [in1] = f8, 8 +(p6) stfs [r16] = f9, 8 + cmp.lt p7, p0 = 8, in3 + cmp.lt p8, p0 = 12, in3 + ;; +(p7) stfs [in1] = f10, 8 +(p8) stfs [r16] = f11, 8 + cmp.lt p9, p0 = 16, in3 + cmp.lt p10, p0 = 20, in3 + ;; +(p9) stfs [in1] = f12, 8 +(p10) stfs [r16] = f13, 8 + cmp.lt p6, p0 = 24, in3 + cmp.lt p7, p0 = 28, in3 + ;; +(p6) stfs [in1] = f14 +(p7) stfs [r16] = f15 + br.ret.sptk.many b0 + ;; + +.Lst_hfa_double: + add r16 = 8, in1 + cmp.lt p6, p0 = 8, in3 + ;; + stfd [in1] = f8, 16 +(p6) stfd [r16] = f9, 16 + cmp.lt p7, p0 = 16, in3 + cmp.lt p8, p0 = 24, in3 + ;; +(p7) stfd [in1] = f10, 16 +(p8) stfd [r16] = f11, 16 + cmp.lt p9, p0 = 32, in3 + cmp.lt p10, p0 = 40, in3 + ;; +(p9) stfd [in1] = f12, 16 +(p10) stfd [r16] = f13, 16 + cmp.lt p6, p0 = 48, in3 + cmp.lt p7, p0 = 56, in3 + ;; +(p6) stfd [in1] = f14 +(p7) stfd [r16] = f15 + br.ret.sptk.many b0 + ;; + +.Lst_hfa_ldouble: + add r16 = 16, in1 + cmp.lt p6, p0 = 16, in3 + ;; + stfe [in1] = f8, 32 +(p6) stfe [r16] = f9, 32 + cmp.lt p7, p0 = 32, in3 + cmp.lt p8, p0 = 48, in3 + ;; +(p7) stfe [in1] = f10, 32 +(p8) stfe [r16] = f11, 32 + cmp.lt p9, p0 = 64, in3 + cmp.lt p10, p0 = 80, in3 + ;; +(p9) stfe [in1] = f12, 32 +(p10) stfe [r16] = f13, 32 + cmp.lt p6, p0 = 96, in3 + cmp.lt p7, p0 = 112, in3 + ;; +(p6) stfe [in1] = f14 +(p7) stfe [r16] = f15 + br.ret.sptk.many b0 + ;; + + .endp ffi_call_unix + + .align 16 + .global ffi_closure_unix + .proc ffi_closure_unix + +#define FRAME_SIZE (8*16 + 8*8 + 8*16) + +ffi_closure_unix: + .prologue + .save ar.pfs, r40 // loc0 + alloc loc0 = ar.pfs, 8, 4, 4, 0 + .fframe FRAME_SIZE + add r12 = -FRAME_SIZE, r12 + .save rp, loc1 + mov loc1 = b0 + .save ar.unat, loc2 + mov loc2 = ar.unat + .body + + /* Retrieve closure pointer and real gp. */ +#ifdef _ILP32 + addp4 out0 = 0, gp + addp4 gp = 16, gp +#else + mov out0 = gp + add gp = 16, gp +#endif + ;; + ld8 gp = [gp] + + /* Spill all of the possible argument registers. */ + add r16 = 16 + 8*16, sp + add r17 = 16 + 8*16 + 16, sp + ;; + stf.spill [r16] = f8, 32 + stf.spill [r17] = f9, 32 + mov loc3 = gp + ;; + stf.spill [r16] = f10, 32 + stf.spill [r17] = f11, 32 + ;; + stf.spill [r16] = f12, 32 + stf.spill [r17] = f13, 32 + ;; + stf.spill [r16] = f14, 32 + stf.spill [r17] = f15, 24 + ;; + .mem.offset 0, 0 + st8.spill [r16] = in0, 16 + .mem.offset 8, 0 + st8.spill [r17] = in1, 16 + add out1 = 16 + 8*16, sp + ;; + .mem.offset 0, 0 + st8.spill [r16] = in2, 16 + .mem.offset 8, 0 + st8.spill [r17] = in3, 16 + add out2 = 16, sp + ;; + .mem.offset 0, 0 + st8.spill [r16] = in4, 16 + .mem.offset 8, 0 + st8.spill [r17] = in5, 16 + mov out3 = r8 + ;; + .mem.offset 0, 0 + st8.spill [r16] = in6 + .mem.offset 8, 0 + st8.spill [r17] = in7 + + /* Invoke ffi_closure_unix_inner for the hard work. */ + br.call.sptk.many b0 = ffi_closure_unix_inner + ;; + + /* Dispatch to handle return value. */ + mov gp = loc3 + zxt1 r16 = r8 + ;; + addl r18 = @ltoffx(.Lld_table), gp + mov ar.pfs = loc0 + ;; + ld8.mov r18 = [r18], .Lld_table + mov b0 = loc1 + ;; + shladd r18 = r16, 3, r18 + mov ar.unat = loc2 + ;; + ld8 r17 = [r18] + shr r8 = r8, 8 + ;; + add r17 = r17, r18 + add r16 = 16, sp + ;; + mov b6 = r17 + br b6 + ;; + .label_state 1 + +.Lld_void: + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; +.Lld_int: + .body + .copy_state 1 + ld8 r8 = [r16] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; +.Lld_float: + .body + .copy_state 1 + ldfs f8 = [r16] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; +.Lld_double: + .body + .copy_state 1 + ldfd f8 = [r16] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; +.Lld_ldouble: + .body + .copy_state 1 + ldfe f8 = [r16] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; + +.Lld_small_struct: + .body + .copy_state 1 + add r17 = 8, r16 + cmp.lt p6, p0 = 8, r8 + cmp.lt p7, p0 = 16, r8 + cmp.lt p8, p0 = 24, r8 + ;; + ld8 r8 = [r16], 16 +(p6) ld8 r9 = [r17], 16 + ;; +(p7) ld8 r10 = [r16] +(p8) ld8 r11 = [r17] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; + +.Lld_hfa_float: + .body + .copy_state 1 + add r17 = 4, r16 + cmp.lt p6, p0 = 4, r8 + ;; + ldfs f8 = [r16], 8 +(p6) ldfs f9 = [r17], 8 + cmp.lt p7, p0 = 8, r8 + cmp.lt p8, p0 = 12, r8 + ;; +(p7) ldfs f10 = [r16], 8 +(p8) ldfs f11 = [r17], 8 + cmp.lt p9, p0 = 16, r8 + cmp.lt p10, p0 = 20, r8 + ;; +(p9) ldfs f12 = [r16], 8 +(p10) ldfs f13 = [r17], 8 + cmp.lt p6, p0 = 24, r8 + cmp.lt p7, p0 = 28, r8 + ;; +(p6) ldfs f14 = [r16] +(p7) ldfs f15 = [r17] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; + +.Lld_hfa_double: + .body + .copy_state 1 + add r17 = 8, r16 + cmp.lt p6, p0 = 8, r8 + ;; + ldfd f8 = [r16], 16 +(p6) ldfd f9 = [r17], 16 + cmp.lt p7, p0 = 16, r8 + cmp.lt p8, p0 = 24, r8 + ;; +(p7) ldfd f10 = [r16], 16 +(p8) ldfd f11 = [r17], 16 + cmp.lt p9, p0 = 32, r8 + cmp.lt p10, p0 = 40, r8 + ;; +(p9) ldfd f12 = [r16], 16 +(p10) ldfd f13 = [r17], 16 + cmp.lt p6, p0 = 48, r8 + cmp.lt p7, p0 = 56, r8 + ;; +(p6) ldfd f14 = [r16] +(p7) ldfd f15 = [r17] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; + +.Lld_hfa_ldouble: + .body + .copy_state 1 + add r17 = 16, r16 + cmp.lt p6, p0 = 16, r8 + ;; + ldfe f8 = [r16], 32 +(p6) ldfe f9 = [r17], 32 + cmp.lt p7, p0 = 32, r8 + cmp.lt p8, p0 = 48, r8 + ;; +(p7) ldfe f10 = [r16], 32 +(p8) ldfe f11 = [r17], 32 + cmp.lt p9, p0 = 64, r8 + cmp.lt p10, p0 = 80, r8 + ;; +(p9) ldfe f12 = [r16], 32 +(p10) ldfe f13 = [r17], 32 + cmp.lt p6, p0 = 96, r8 + cmp.lt p7, p0 = 112, r8 + ;; +(p6) ldfe f14 = [r16] +(p7) ldfe f15 = [r17] + .restore sp + add sp = FRAME_SIZE, sp + br.ret.sptk.many b0 + ;; + + .endp ffi_closure_unix + + .section .rodata + .align 8 +.Lst_table: + data8 @pcrel(.Lst_void) // FFI_TYPE_VOID + data8 @pcrel(.Lst_sint32) // FFI_TYPE_INT + data8 @pcrel(.Lst_float) // FFI_TYPE_FLOAT + data8 @pcrel(.Lst_double) // FFI_TYPE_DOUBLE + data8 @pcrel(.Lst_ldouble) // FFI_TYPE_LONGDOUBLE + data8 @pcrel(.Lst_uint8) // FFI_TYPE_UINT8 + data8 @pcrel(.Lst_sint8) // FFI_TYPE_SINT8 + data8 @pcrel(.Lst_uint16) // FFI_TYPE_UINT16 + data8 @pcrel(.Lst_sint16) // FFI_TYPE_SINT16 + data8 @pcrel(.Lst_uint32) // FFI_TYPE_UINT32 + data8 @pcrel(.Lst_sint32) // FFI_TYPE_SINT32 + data8 @pcrel(.Lst_int64) // FFI_TYPE_UINT64 + data8 @pcrel(.Lst_int64) // FFI_TYPE_SINT64 + data8 @pcrel(.Lst_void) // FFI_TYPE_STRUCT + data8 @pcrel(.Lst_int64) // FFI_TYPE_POINTER + data8 @pcrel(.Lst_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT + data8 @pcrel(.Lst_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT + data8 @pcrel(.Lst_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE + data8 @pcrel(.Lst_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE + +.Lld_table: + data8 @pcrel(.Lld_void) // FFI_TYPE_VOID + data8 @pcrel(.Lld_int) // FFI_TYPE_INT + data8 @pcrel(.Lld_float) // FFI_TYPE_FLOAT + data8 @pcrel(.Lld_double) // FFI_TYPE_DOUBLE + data8 @pcrel(.Lld_ldouble) // FFI_TYPE_LONGDOUBLE + data8 @pcrel(.Lld_int) // FFI_TYPE_UINT8 + data8 @pcrel(.Lld_int) // FFI_TYPE_SINT8 + data8 @pcrel(.Lld_int) // FFI_TYPE_UINT16 + data8 @pcrel(.Lld_int) // FFI_TYPE_SINT16 + data8 @pcrel(.Lld_int) // FFI_TYPE_UINT32 + data8 @pcrel(.Lld_int) // FFI_TYPE_SINT32 + data8 @pcrel(.Lld_int) // FFI_TYPE_UINT64 + data8 @pcrel(.Lld_int) // FFI_TYPE_SINT64 + data8 @pcrel(.Lld_void) // FFI_TYPE_STRUCT + data8 @pcrel(.Lld_int) // FFI_TYPE_POINTER + data8 @pcrel(.Lld_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT + data8 @pcrel(.Lld_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT + data8 @pcrel(.Lld_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE + data8 @pcrel(.Lld_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/java_raw_api.c b/user/mpy/lib/libffi/src/java_raw_api.c new file mode 100644 index 0000000..127123d --- /dev/null +++ b/user/mpy/lib/libffi/src/java_raw_api.c @@ -0,0 +1,374 @@ +/* ----------------------------------------------------------------------- + java_raw_api.c - Copyright (c) 1999, 2007, 2008 Red Hat, Inc. + + Cloned from raw_api.c + + Raw_api.c author: Kresten Krab Thorup + Java_raw_api.c author: Hans-J. Boehm + + $Id $ + + 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. + ----------------------------------------------------------------------- */ + +/* This defines a Java- and 64-bit specific variant of the raw API. */ +/* It assumes that "raw" argument blocks look like Java stacks on a */ +/* 64-bit machine. Arguments that can be stored in a single stack */ +/* stack slots (longs, doubles) occupy 128 bits, but only the first */ +/* 64 bits are actually used. */ + +#include +#include +#include + +#if !defined(NO_JAVA_RAW_API) + +size_t +ffi_java_raw_size (ffi_cif *cif) +{ + size_t result = 0; + int i; + + ffi_type **at = cif->arg_types; + + for (i = cif->nargs-1; i >= 0; i--, at++) + { + switch((*at) -> type) { + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_DOUBLE: + result += 2 * FFI_SIZEOF_JAVA_RAW; + break; + case FFI_TYPE_STRUCT: + /* No structure parameters in Java. */ + abort(); + case FFI_TYPE_COMPLEX: + /* Not supported yet. */ + abort(); + default: + result += FFI_SIZEOF_JAVA_RAW; + } + } + + return result; +} + + +void +ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) +{ + unsigned i; + ffi_type **tp = cif->arg_types; + +#if WORDS_BIGENDIAN + + for (i = 0; i < cif->nargs; i++, tp++, args++) + { + switch ((*tp)->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + *args = (void*) ((char*)(raw++) + 3); + break; + + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + *args = (void*) ((char*)(raw++) + 2); + break; + +#if FFI_SIZEOF_JAVA_RAW == 8 + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_DOUBLE: + *args = (void *)raw; + raw += 2; + break; +#endif + + case FFI_TYPE_POINTER: + *args = (void*) &(raw++)->ptr; + break; + + case FFI_TYPE_COMPLEX: + /* Not supported yet. */ + abort(); + + default: + *args = raw; + raw += + ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw); + } + } + +#else /* WORDS_BIGENDIAN */ + +#if !PDP + + /* then assume little endian */ + for (i = 0; i < cif->nargs; i++, tp++, args++) + { +#if FFI_SIZEOF_JAVA_RAW == 8 + switch((*tp)->type) { + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_DOUBLE: + *args = (void*) raw; + raw += 2; + break; + case FFI_TYPE_COMPLEX: + /* Not supported yet. */ + abort(); + default: + *args = (void*) raw++; + } +#else /* FFI_SIZEOF_JAVA_RAW != 8 */ + *args = (void*) raw; + raw += + ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw); +#endif /* FFI_SIZEOF_JAVA_RAW == 8 */ + } + +#else +#error "pdp endian not supported" +#endif /* ! PDP */ + +#endif /* WORDS_BIGENDIAN */ +} + +void +ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) +{ + unsigned i; + ffi_type **tp = cif->arg_types; + + for (i = 0; i < cif->nargs; i++, tp++, args++) + { + switch ((*tp)->type) + { + case FFI_TYPE_UINT8: +#if WORDS_BIGENDIAN + *(UINT32*)(raw++) = *(UINT8*) (*args); +#else + (raw++)->uint = *(UINT8*) (*args); +#endif + break; + + case FFI_TYPE_SINT8: +#if WORDS_BIGENDIAN + *(SINT32*)(raw++) = *(SINT8*) (*args); +#else + (raw++)->sint = *(SINT8*) (*args); +#endif + break; + + case FFI_TYPE_UINT16: +#if WORDS_BIGENDIAN + *(UINT32*)(raw++) = *(UINT16*) (*args); +#else + (raw++)->uint = *(UINT16*) (*args); +#endif + break; + + case FFI_TYPE_SINT16: +#if WORDS_BIGENDIAN + *(SINT32*)(raw++) = *(SINT16*) (*args); +#else + (raw++)->sint = *(SINT16*) (*args); +#endif + break; + + case FFI_TYPE_UINT32: +#if WORDS_BIGENDIAN + *(UINT32*)(raw++) = *(UINT32*) (*args); +#else + (raw++)->uint = *(UINT32*) (*args); +#endif + break; + + case FFI_TYPE_SINT32: +#if WORDS_BIGENDIAN + *(SINT32*)(raw++) = *(SINT32*) (*args); +#else + (raw++)->sint = *(SINT32*) (*args); +#endif + break; + + case FFI_TYPE_FLOAT: + (raw++)->flt = *(FLOAT32*) (*args); + break; + +#if FFI_SIZEOF_JAVA_RAW == 8 + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_DOUBLE: + raw->uint = *(UINT64*) (*args); + raw += 2; + break; +#endif + + case FFI_TYPE_POINTER: + (raw++)->ptr = **(void***) args; + break; + + default: +#if FFI_SIZEOF_JAVA_RAW == 8 + FFI_ASSERT(0); /* Should have covered all cases */ +#else + memcpy ((void*) raw->data, (void*)*args, (*tp)->size); + raw += + ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw); +#endif + } + } +} + +#if !FFI_NATIVE_RAW_API + +static void +ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue) +{ +#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8 + switch (cif->rtype->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_UINT32: + *(UINT64 *)rvalue <<= 32; + break; + + case FFI_TYPE_SINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_INT: +#if FFI_SIZEOF_JAVA_RAW == 4 + case FFI_TYPE_POINTER: +#endif + *(SINT64 *)rvalue <<= 32; + break; + + case FFI_TYPE_COMPLEX: + /* Not supported yet. */ + abort(); + + default: + break; + } +#endif +} + +static void +ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue) +{ +#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8 + switch (cif->rtype->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_UINT32: + *(UINT64 *)rvalue >>= 32; + break; + + case FFI_TYPE_SINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_INT: + *(SINT64 *)rvalue >>= 32; + break; + + case FFI_TYPE_COMPLEX: + /* Not supported yet. */ + abort(); + + default: + break; + } +#endif +} + +/* This is a generic definition of ffi_raw_call, to be used if the + * native system does not provide a machine-specific implementation. + * Having this, allows code to be written for the raw API, without + * the need for system-specific code to handle input in that format; + * these following couple of functions will handle the translation forth + * and back automatically. */ + +void ffi_java_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, + ffi_java_raw *raw) +{ + void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); + ffi_java_raw_to_ptrarray (cif, raw, avalue); + ffi_call (cif, fn, rvalue, avalue); + ffi_java_rvalue_to_raw (cif, rvalue); +} + +#if FFI_CLOSURES /* base system provides closures */ + +static void +ffi_java_translate_args (ffi_cif *cif, void *rvalue, + void **avalue, void *user_data) +{ + ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif)); + ffi_raw_closure *cl = (ffi_raw_closure*)user_data; + + ffi_java_ptrarray_to_raw (cif, avalue, raw); + (*cl->fun) (cif, rvalue, (ffi_raw*)raw, cl->user_data); + ffi_java_raw_to_rvalue (cif, rvalue); +} + +ffi_status +ffi_prep_java_raw_closure_loc (ffi_java_raw_closure* cl, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data, + void *codeloc) +{ + ffi_status status; + + status = ffi_prep_closure_loc ((ffi_closure*) cl, + cif, + &ffi_java_translate_args, + codeloc, + codeloc); + if (status == FFI_OK) + { + cl->fun = fun; + cl->user_data = user_data; + } + + return status; +} + +/* Again, here is the generic version of ffi_prep_raw_closure, which + * will install an intermediate "hub" for translation of arguments from + * the pointer-array format, to the raw format */ + +ffi_status +ffi_prep_java_raw_closure (ffi_java_raw_closure* cl, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data) +{ + return ffi_prep_java_raw_closure_loc (cl, cif, fun, user_data, cl); +} + +#endif /* FFI_CLOSURES */ +#endif /* !FFI_NATIVE_RAW_API */ +#endif /* !NO_JAVA_RAW_API */ diff --git a/user/mpy/lib/libffi/src/m32r/ffi.c b/user/mpy/lib/libffi/src/m32r/ffi.c new file mode 100644 index 0000000..3000063 --- /dev/null +++ b/user/mpy/lib/libffi/src/m32r/ffi.c @@ -0,0 +1,232 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2004 Renesas Technology + Copyright (c) 2008 Red Hat, Inc. + + M32R Foreign Function Interface + + 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 RENESAS TECHNOLOGY 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +/* ffi_prep_args is called by the assembly routine once stack + space has been allocated for the function's arguments. */ + +void ffi_prep_args(char *stack, extended_cif *ecif) +{ + unsigned int i; + int tmp; + unsigned int avn; + void **p_argv; + char *argp; + ffi_type **p_arg; + + tmp = 0; + argp = stack; + + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 8) + { + *(void **) argp = ecif->rvalue; + argp += 4; + } + + avn = ecif->cif->nargs; + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0) && (avn != 0); + i--, p_arg++) + { + size_t z; + + /* Align if necessary. */ + if (((*p_arg)->alignment - 1) & (unsigned) argp) + argp = (char *) ALIGN (argp, (*p_arg)->alignment); + + if (avn != 0) + { + avn--; + z = (*p_arg)->size; + if (z < sizeof (int)) + { + z = sizeof (int); + + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + case FFI_TYPE_STRUCT: + z = (*p_arg)->size; + if ((*p_arg)->alignment != 1) + memcpy (argp, *p_argv, z); + else + memcpy (argp + 4 - z, *p_argv, z); + z = sizeof (int); + break; + + default: + FFI_ASSERT(0); + } + } + else if (z == sizeof (int)) + { + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + } + else + { + if ((*p_arg)->type == FFI_TYPE_STRUCT) + { + if (z > 8) + { + *(unsigned int *) argp = (unsigned int)(void *)(* p_argv); + z = sizeof(void *); + } + else + { + memcpy(argp, *p_argv, z); + z = 8; + } + } + else + { + /* Double or long long 64bit. */ + memcpy (argp, *p_argv, z); + } + } + p_argv++; + argp += z; + } + } + + return; +} + +/* Perform machine dependent cif processing. */ +ffi_status +ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* Set the return type flag. */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + cif->flags = (unsigned) cif->rtype->type; + break; + + case FFI_TYPE_STRUCT: + if (cif->rtype->size <= 4) + cif->flags = FFI_TYPE_INT; + + else if (cif->rtype->size <= 8) + cif->flags = FFI_TYPE_DOUBLE; + + else + cif->flags = (unsigned) cif->rtype->type; + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: + cif->flags = FFI_TYPE_DOUBLE; + break; + + case FFI_TYPE_FLOAT: + default: + cif->flags = FFI_TYPE_INT; + break; + } + + return FFI_OK; +} + +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, + unsigned, unsigned, unsigned *, void (*fn)(void)); + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have + a return value address then we need to make one. */ + if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca (cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + if (cif->rtype->type == FFI_TYPE_STRUCT) + { + int size = cif->rtype->size; + int align = cif->rtype->alignment; + + if (size < 4) + { + if (align == 1) + *(unsigned long *)(ecif.rvalue) <<= (4 - size) * 8; + } + else if (4 < size && size < 8) + { + if (align == 1) + { + memcpy (ecif.rvalue, ecif.rvalue + 8-size, size); + } + else if (align == 2) + { + if (size & 1) + size += 1; + + if (size != 8) + memcpy (ecif.rvalue, ecif.rvalue + 8-size, size); + } + } + } + break; + + default: + FFI_ASSERT(0); + break; + } +} diff --git a/user/mpy/lib/libffi/src/m32r/ffitarget.h b/user/mpy/lib/libffi/src/m32r/ffitarget.h new file mode 100644 index 0000000..6c34801 --- /dev/null +++ b/user/mpy/lib/libffi/src/m32r/ffitarget.h @@ -0,0 +1,53 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 2004 Renesas Technology. + Target configuration macros for M32R. + + 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 RENESAS TECHNOLOGY 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- Generic type definitions ----------------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi + { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV + } ffi_abi; +#endif + +#define FFI_CLOSURES 0 +#define FFI_TRAMPOLINE_SIZE 24 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/m32r/sysv.S b/user/mpy/lib/libffi/src/m32r/sysv.S new file mode 100644 index 0000000..06b75c2 --- /dev/null +++ b/user/mpy/lib/libffi/src/m32r/sysv.S @@ -0,0 +1,121 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2004 Renesas Technology + + M32R Foreign Function Interface + + 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 RENESAS TECHNOLOGY 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#ifdef HAVE_MACHINE_ASM_H +#include +#else +/* XXX these lose for some platforms, I'm sure. */ +#define CNAME(x) x +#define ENTRY(x) .globl CNAME(x)! .type CNAME(x),%function! CNAME(x): +#endif + +.text + + /* R0: ffi_prep_args */ + /* R1: &ecif */ + /* R2: cif->bytes */ + /* R3: fig->flags */ + /* sp+0: ecif.rvalue */ + /* sp+4: fn */ + + /* This assumes we are using gas. */ +ENTRY(ffi_call_SYSV) + /* Save registers. */ + push fp + push lr + push r3 + push r2 + push r1 + push r0 + mv fp, sp + + /* Make room for all of the new args. */ + sub sp, r2 + + /* Place all of the ffi_prep_args in position. */ + mv lr, r0 + mv r0, sp + /* R1 already set. */ + + /* And call. */ + jl lr + + /* Move first 4 parameters in registers... */ + ld r0, @(0,sp) + ld r1, @(4,sp) + ld r2, @(8,sp) + ld r3, @(12,sp) + + /* ...and adjust the stack. */ + ld lr, @(8,fp) + cmpi lr, #16 + bc adjust_stack + ldi lr, #16 +adjust_stack: + add sp, lr + + /* Call the function. */ + ld lr, @(28,fp) + jl lr + + /* Remove the space we pushed for the args. */ + mv sp, fp + + /* Load R2 with the pointer to storage for the return value. */ + ld r2, @(24,sp) + + /* Load R3 with the return type code. */ + ld r3, @(12,sp) + + /* If the return value pointer is NULL, assume no return value. */ + beqz r2, epilogue + + /* Return INT. */ + ldi r4, #FFI_TYPE_INT + bne r3, r4, return_double + st r0, @r2 + bra epilogue + +return_double: + /* Return DOUBLE or LONGDOUBLE. */ + ldi r4, #FFI_TYPE_DOUBLE + bne r3, r4, epilogue + st r0, @r2 + st r1, @(4,r2) + +epilogue: + pop r0 + pop r1 + pop r2 + pop r3 + pop lr + pop fp + jmp lr + +.ffi_call_SYSV_end: + .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) diff --git a/user/mpy/lib/libffi/src/m68k/ffi.c b/user/mpy/lib/libffi/src/m68k/ffi.c new file mode 100644 index 0000000..0dee938 --- /dev/null +++ b/user/mpy/lib/libffi/src/m68k/ffi.c @@ -0,0 +1,362 @@ +/* ----------------------------------------------------------------------- + ffi.c + + m68k Foreign Function Interface + ----------------------------------------------------------------------- */ + +#include +#include + +#include +#include +#ifdef __rtems__ +void rtems_cache_flush_multiple_data_lines( const void *, size_t ); +#else +#include +#ifdef __MINT__ +#include +#include +#else +#include +#endif +#endif + +void ffi_call_SYSV (extended_cif *, + unsigned, unsigned, + void *, void (*fn) ()); +void *ffi_prep_args (void *stack, extended_cif *ecif); +void ffi_closure_SYSV (ffi_closure *); +void ffi_closure_struct_SYSV (ffi_closure *); +unsigned int ffi_closure_SYSV_inner (ffi_closure *closure, + void *resp, void *args); + +/* ffi_prep_args is called by the assembly routine once stack space has + been allocated for the function's arguments. */ + +void * +ffi_prep_args (void *stack, extended_cif *ecif) +{ + unsigned int i; + void **p_argv; + char *argp; + ffi_type **p_arg; + void *struct_value_ptr; + + argp = stack; + + if ( +#ifdef __MINT__ + (ecif->cif->rtype->type == FFI_TYPE_LONGDOUBLE) || +#endif + (((ecif->cif->rtype->type == FFI_TYPE_STRUCT) + && !ecif->cif->flags))) + struct_value_ptr = ecif->rvalue; + else + struct_value_ptr = NULL; + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + i != 0; + i--, p_arg++) + { + size_t z = (*p_arg)->size; + int type = (*p_arg)->type; + + if (z < sizeof (int)) + { + switch (type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv; + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) *p_argv; + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv; + break; + + case FFI_TYPE_STRUCT: +#ifdef __MINT__ + if (z == 1 || z == 2) + memcpy (argp + 2, *p_argv, z); + else + memcpy (argp, *p_argv, z); +#else + memcpy (argp + sizeof (int) - z, *p_argv, z); +#endif + break; + + default: + FFI_ASSERT (0); + } + z = sizeof (int); + } + else + { + memcpy (argp, *p_argv, z); + + /* Align if necessary. */ + if ((sizeof(int) - 1) & z) + z = ALIGN(z, sizeof(int)); + } + + p_argv++; + argp += z; + } + + return struct_value_ptr; +} + +#define CIF_FLAGS_INT 1 +#define CIF_FLAGS_DINT 2 +#define CIF_FLAGS_FLOAT 4 +#define CIF_FLAGS_DOUBLE 8 +#define CIF_FLAGS_LDOUBLE 16 +#define CIF_FLAGS_POINTER 32 +#define CIF_FLAGS_STRUCT1 64 +#define CIF_FLAGS_STRUCT2 128 +#define CIF_FLAGS_SINT8 256 +#define CIF_FLAGS_SINT16 512 + +/* Perform machine dependent cif processing */ +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + cif->flags = 0; + break; + + case FFI_TYPE_STRUCT: + if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT && + cif->rtype->elements[1]) + { + cif->flags = 0; + break; + } + + switch (cif->rtype->size) + { + case 1: +#ifdef __MINT__ + cif->flags = CIF_FLAGS_STRUCT2; +#else + cif->flags = CIF_FLAGS_STRUCT1; +#endif + break; + case 2: + cif->flags = CIF_FLAGS_STRUCT2; + break; +#ifdef __MINT__ + case 3: +#endif + case 4: + cif->flags = CIF_FLAGS_INT; + break; +#ifdef __MINT__ + case 7: +#endif + case 8: + cif->flags = CIF_FLAGS_DINT; + break; + default: + cif->flags = 0; + break; + } + break; + + case FFI_TYPE_FLOAT: + cif->flags = CIF_FLAGS_FLOAT; + break; + + case FFI_TYPE_DOUBLE: + cif->flags = CIF_FLAGS_DOUBLE; + break; + +#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE) + case FFI_TYPE_LONGDOUBLE: +#ifdef __MINT__ + cif->flags = 0; +#else + cif->flags = CIF_FLAGS_LDOUBLE; +#endif + break; +#endif + + case FFI_TYPE_POINTER: + cif->flags = CIF_FLAGS_POINTER; + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = CIF_FLAGS_DINT; + break; + + case FFI_TYPE_SINT16: + cif->flags = CIF_FLAGS_SINT16; + break; + + case FFI_TYPE_SINT8: + cif->flags = CIF_FLAGS_SINT8; + break; + + default: + cif->flags = CIF_FLAGS_INT; + break; + } + + return FFI_OK; +} + +void +ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return value + address then we need to make one. */ + + if (rvalue == NULL + && cif->rtype->type == FFI_TYPE_STRUCT + && cif->rtype->size > 8) + ecif.rvalue = alloca (cif->rtype->size); + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV (&ecif, cif->bytes, cif->flags, + ecif.rvalue, fn); + break; + + default: + FFI_ASSERT (0); + break; + } +} + +static void +ffi_prep_incoming_args_SYSV (char *stack, void **avalue, ffi_cif *cif) +{ + unsigned int i; + void **p_argv; + char *argp; + ffi_type **p_arg; + + argp = stack; + p_argv = avalue; + + for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) + { + size_t z; + + z = (*p_arg)->size; +#ifdef __MINT__ + if (cif->flags && + cif->rtype->type == FFI_TYPE_STRUCT && + (z == 1 || z == 2)) + { + *p_argv = (void *) (argp + 2); + + z = 4; + } + else + if (cif->flags && + cif->rtype->type == FFI_TYPE_STRUCT && + (z == 3 || z == 4)) + { + *p_argv = (void *) (argp); + + z = 4; + } + else +#endif + if (z <= 4) + { + *p_argv = (void *) (argp + 4 - z); + + z = 4; + } + else + { + *p_argv = (void *) argp; + + /* Align if necessary */ + if ((sizeof(int) - 1) & z) + z = ALIGN(z, sizeof(int)); + } + + p_argv++; + argp += z; + } +} + +unsigned int +ffi_closure_SYSV_inner (ffi_closure *closure, void *resp, void *args) +{ + ffi_cif *cif; + void **arg_area; + + cif = closure->cif; + arg_area = (void**) alloca (cif->nargs * sizeof (void *)); + + ffi_prep_incoming_args_SYSV(args, arg_area, cif); + + (closure->fun) (cif, resp, arg_area, closure->user_data); + + return cif->flags; +} + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + *(unsigned short *)closure->tramp = 0x207c; + *(void **)(closure->tramp + 2) = codeloc; + *(unsigned short *)(closure->tramp + 6) = 0x4ef9; + + if ( +#ifdef __MINT__ + (cif->rtype->type == FFI_TYPE_LONGDOUBLE) || +#endif + (((cif->rtype->type == FFI_TYPE_STRUCT) + && !cif->flags))) + *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV; + else + *(void **)(closure->tramp + 8) = ffi_closure_SYSV; + +#ifdef __rtems__ + rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE ); +#elif defined(__MINT__) + Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE); +#else + syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE, + FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE); +#endif + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/m68k/ffitarget.h b/user/mpy/lib/libffi/src/m68k/ffitarget.h new file mode 100644 index 0000000..e81dde2 --- /dev/null +++ b/user/mpy/lib/libffi/src/m68k/ffitarget.h @@ -0,0 +1,54 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for Motorola 68K. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 16 +#define FFI_NATIVE_RAW_API 0 + +#endif + diff --git a/user/mpy/lib/libffi/src/m68k/sysv.S b/user/mpy/lib/libffi/src/m68k/sysv.S new file mode 100644 index 0000000..ec2b14f --- /dev/null +++ b/user/mpy/lib/libffi/src/m68k/sysv.S @@ -0,0 +1,330 @@ +/* ----------------------------------------------------------------------- + + sysv.S - Copyright (c) 2012 Alan Hourihane + Copyright (c) 1998, 2012 Andreas Schwab + Copyright (c) 2008 Red Hat, Inc. + Copyright (c) 2012 Thorsten Glaser + + m68k Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +#ifdef HAVE_AS_CFI_PSEUDO_OP +#define CFI_STARTPROC() .cfi_startproc +#define CFI_OFFSET(reg,off) .cfi_offset reg,off +#define CFI_DEF_CFA(reg,off) .cfi_def_cfa reg,off +#define CFI_ENDPROC() .cfi_endproc +#else +#define CFI_STARTPROC() +#define CFI_OFFSET(reg,off) +#define CFI_DEF_CFA(reg,off) +#define CFI_ENDPROC() +#endif + +#ifdef __MINT__ +#define CALLFUNC(funcname) _ ## funcname +#else +#define CALLFUNC(funcname) funcname +#endif + + .text + + .globl CALLFUNC(ffi_call_SYSV) + .type CALLFUNC(ffi_call_SYSV),@function + .align 4 + +CALLFUNC(ffi_call_SYSV): + CFI_STARTPROC() + link %fp,#0 + CFI_OFFSET(14,-8) + CFI_DEF_CFA(14,8) + move.l %d2,-(%sp) + CFI_OFFSET(2,-12) + + | Make room for all of the new args. + sub.l 12(%fp),%sp + + | Call ffi_prep_args + move.l 8(%fp),-(%sp) + pea 4(%sp) +#if !defined __PIC__ + jsr CALLFUNC(ffi_prep_args) +#else + bsr.l CALLFUNC(ffi_prep_args@PLTPC) +#endif + addq.l #8,%sp + + | Pass pointer to struct value, if any +#ifdef __MINT__ + move.l %d0,%a1 +#else + move.l %a0,%a1 +#endif + + | Call the function + move.l 24(%fp),%a0 + jsr (%a0) + + | Remove the space we pushed for the args + add.l 12(%fp),%sp + + | Load the pointer to storage for the return value + move.l 20(%fp),%a1 + + | Load the return type code + move.l 16(%fp),%d2 + + | If the return value pointer is NULL, assume no return value. + | NOTE: On the mc68000, tst on an address register is not supported. +#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) + cmp.w #0, %a1 +#else + tst.l %a1 +#endif + jbeq noretval + + btst #0,%d2 + jbeq retlongint + move.l %d0,(%a1) + jbra epilogue + +retlongint: + btst #1,%d2 + jbeq retfloat + move.l %d0,(%a1) + move.l %d1,4(%a1) + jbra epilogue + +retfloat: + btst #2,%d2 + jbeq retdouble +#if defined(__MC68881__) || defined(__HAVE_68881__) + fmove.s %fp0,(%a1) +#else + move.l %d0,(%a1) +#endif + jbra epilogue + +retdouble: + btst #3,%d2 + jbeq retlongdouble +#if defined(__MC68881__) || defined(__HAVE_68881__) + fmove.d %fp0,(%a1) +#else + move.l %d0,(%a1)+ + move.l %d1,(%a1) +#endif + jbra epilogue + +retlongdouble: + btst #4,%d2 + jbeq retpointer +#if defined(__MC68881__) || defined(__HAVE_68881__) + fmove.x %fp0,(%a1) +#else + move.l %d0,(%a1)+ + move.l %d1,(%a1)+ + move.l %d2,(%a1) +#endif + jbra epilogue + +retpointer: + btst #5,%d2 + jbeq retstruct1 +#ifdef __MINT__ + move.l %d0,(%a1) +#else + move.l %a0,(%a1) +#endif + jbra epilogue + +retstruct1: + btst #6,%d2 + jbeq retstruct2 + move.b %d0,(%a1) + jbra epilogue + +retstruct2: + btst #7,%d2 + jbeq retsint8 + move.w %d0,(%a1) + jbra epilogue + +retsint8: + btst #8,%d2 + jbeq retsint16 + | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32. +#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) + ext.w %d0 + ext.l %d0 +#else + extb.l %d0 +#endif + move.l %d0,(%a1) + jbra epilogue + +retsint16: + btst #9,%d2 + jbeq noretval + ext.l %d0 + move.l %d0,(%a1) + +noretval: +epilogue: + move.l (%sp)+,%d2 + unlk %fp + rts + CFI_ENDPROC() + .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV) + + .globl CALLFUNC(ffi_closure_SYSV) + .type CALLFUNC(ffi_closure_SYSV), @function + .align 4 + +CALLFUNC(ffi_closure_SYSV): + CFI_STARTPROC() + link %fp,#-12 + CFI_OFFSET(14,-8) + CFI_DEF_CFA(14,8) + move.l %sp,-12(%fp) + pea 8(%fp) + pea -12(%fp) + move.l %a0,-(%sp) +#if !defined __PIC__ + jsr CALLFUNC(ffi_closure_SYSV_inner) +#else + bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC) +#endif + + lsr.l #1,%d0 + jne 1f + jcc .Lcls_epilogue + | CIF_FLAGS_INT + move.l -12(%fp),%d0 +.Lcls_epilogue: + | no CIF_FLAGS_* + unlk %fp + rts +1: + lea -12(%fp),%a0 + lsr.l #2,%d0 + jne 1f + jcs .Lcls_ret_float + | CIF_FLAGS_DINT + move.l (%a0)+,%d0 + move.l (%a0),%d1 + jra .Lcls_epilogue +.Lcls_ret_float: +#if defined(__MC68881__) || defined(__HAVE_68881__) + fmove.s (%a0),%fp0 +#else + move.l (%a0),%d0 +#endif + jra .Lcls_epilogue +1: + lsr.l #2,%d0 + jne 1f + jcs .Lcls_ret_ldouble + | CIF_FLAGS_DOUBLE +#if defined(__MC68881__) || defined(__HAVE_68881__) + fmove.d (%a0),%fp0 +#else + move.l (%a0)+,%d0 + move.l (%a0),%d1 +#endif + jra .Lcls_epilogue +.Lcls_ret_ldouble: +#if defined(__MC68881__) || defined(__HAVE_68881__) + fmove.x (%a0),%fp0 +#else + move.l (%a0)+,%d0 + move.l (%a0)+,%d1 + move.l (%a0),%d2 +#endif + jra .Lcls_epilogue +1: + lsr.l #2,%d0 + jne 1f + jcs .Lcls_ret_struct1 + | CIF_FLAGS_POINTER + move.l (%a0),%a0 + move.l %a0,%d0 + jra .Lcls_epilogue +.Lcls_ret_struct1: + move.b (%a0),%d0 + jra .Lcls_epilogue +1: + lsr.l #2,%d0 + jne 1f + jcs .Lcls_ret_sint8 + | CIF_FLAGS_STRUCT2 + move.w (%a0),%d0 + jra .Lcls_epilogue +.Lcls_ret_sint8: + move.l (%a0),%d0 + | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32. +#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) + ext.w %d0 + ext.l %d0 +#else + extb.l %d0 +#endif + jra .Lcls_epilogue +1: + | CIF_FLAGS_SINT16 + move.l (%a0),%d0 + ext.l %d0 + jra .Lcls_epilogue + CFI_ENDPROC() + + .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV) + + .globl CALLFUNC(ffi_closure_struct_SYSV) + .type CALLFUNC(ffi_closure_struct_SYSV), @function + .align 4 + +CALLFUNC(ffi_closure_struct_SYSV): + CFI_STARTPROC() + link %fp,#0 + CFI_OFFSET(14,-8) + CFI_DEF_CFA(14,8) + move.l %sp,-12(%fp) + pea 8(%fp) + move.l %a1,-(%sp) + move.l %a0,-(%sp) +#if !defined __PIC__ + jsr CALLFUNC(ffi_closure_SYSV_inner) +#else + bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC) +#endif + unlk %fp + rts + CFI_ENDPROC() + .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV) + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/m88k/ffi.c b/user/mpy/lib/libffi/src/m88k/ffi.c new file mode 100644 index 0000000..68df494 --- /dev/null +++ b/user/mpy/lib/libffi/src/m88k/ffi.c @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * 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. + */ + +/* + * m88k Foreign Function Interface + * + * This file attempts to provide all the FFI entry points which can reliably + * be implemented in C. + * + * Only OpenBSD/m88k is currently supported; other platforms (such as + * Motorola's SysV/m88k) could be supported with the following tweaks: + * + * - non-OpenBSD systems use an `outgoing parameter area' as part of the + * 88BCS calling convention, which is not supported under OpenBSD from + * release 3.6 onwards. Supporting it should be as easy as taking it + * into account when adjusting the stack, in the assembly code. + * + * - the logic deciding whether a function argument gets passed through + * registers, or on the stack, has changed several times in OpenBSD in + * edge cases (especially for structs larger than 32 bytes being passed + * by value). The code below attemps to match the logic used by the + * system compiler of OpenBSD 5.3, i.e. gcc 3.3.6 with many m88k backend + * fixes. + */ + +#include +#include + +#include +#include + +void ffi_call_OBSD (unsigned int, extended_cif *, unsigned int, void *, + void (*fn) ()); +void *ffi_prep_args (void *, extended_cif *); +void ffi_closure_OBSD (ffi_closure *); +void ffi_closure_struct_OBSD (ffi_closure *); +unsigned int ffi_closure_OBSD_inner (ffi_closure *, void *, unsigned int *, + char *); +void ffi_cacheflush_OBSD (unsigned int, unsigned int); + +#define CIF_FLAGS_INT (1 << 0) +#define CIF_FLAGS_DINT (1 << 1) + +/* + * Foreign Function Interface API + */ + +/* ffi_prep_args is called by the assembly routine once stack space has + been allocated for the function's arguments. */ + +void * +ffi_prep_args (void *stack, extended_cif *ecif) +{ + unsigned int i; + void **p_argv; + char *argp, *stackp; + unsigned int *regp; + unsigned int regused; + ffi_type **p_arg; + void *struct_value_ptr; + + regp = (unsigned int *)stack; + stackp = (char *)(regp + 8); + regused = 0; + + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT + && !ecif->cif->flags) + struct_value_ptr = ecif->rvalue; + else + struct_value_ptr = NULL; + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i != 0; i--, p_arg++) + { + size_t z; + unsigned short t, a; + + z = (*p_arg)->size; + t = (*p_arg)->type; + a = (*p_arg)->alignment; + + /* + * Figure out whether the argument can be passed through registers + * or on the stack. + * The rule is that registers can only receive simple types not larger + * than 64 bits, or structs the exact size of a register and aligned to + * the size of a register. + */ + if (t == FFI_TYPE_STRUCT) + { + if (z == sizeof (int) && a == sizeof (int) && regused < 8) + argp = (char *)regp; + else + argp = stackp; + } + else + { + if (z > sizeof (int) && regused < 8 - 1) + { + /* align to an even register pair */ + if (regused & 1) + { + regp++; + regused++; + } + } + if (regused < 8) + argp = (char *)regp; + else + argp = stackp; + } + + /* Enforce proper stack alignment of 64-bit types */ + if (argp == stackp && a > sizeof (int)) + { + stackp = (char *) ALIGN(stackp, a); + argp = stackp; + } + + switch (t) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv; + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) *p_argv; + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv; + break; + + case FFI_TYPE_INT: + case FFI_TYPE_FLOAT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + *(unsigned int *) argp = *(unsigned int *) *p_argv; + break; + + case FFI_TYPE_DOUBLE: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_STRUCT: + memcpy (argp, *p_argv, z); + break; + + default: + FFI_ASSERT (0); + } + + /* Align if necessary. */ + if ((sizeof (int) - 1) & z) + z = ALIGN(z, sizeof (int)); + + p_argv++; + + /* Be careful, once all registers are filled, and about to continue + on stack, regp == stackp. Therefore the check for regused as well. */ + if (argp == (char *)regp && regused < 8) + { + regp += z / sizeof (int); + regused += z / sizeof (int); + } + else + stackp += z; + } + + return struct_value_ptr; +} + +/* Perform machine dependent cif processing */ +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + cif->flags = 0; + break; + + case FFI_TYPE_STRUCT: + if (cif->rtype->size == sizeof (int) && + cif->rtype->alignment == sizeof (int)) + cif->flags = CIF_FLAGS_INT; + else + cif->flags = 0; + break; + + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = CIF_FLAGS_DINT; + break; + + default: + cif->flags = CIF_FLAGS_INT; + break; + } + + return FFI_OK; +} + +void +ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return value + address then we need to make one. */ + + if (rvalue == NULL + && cif->rtype->type == FFI_TYPE_STRUCT + && (cif->rtype->size != sizeof (int) + || cif->rtype->alignment != sizeof (int))) + ecif.rvalue = alloca (cif->rtype->size); + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_OBSD: + ffi_call_OBSD (cif->bytes, &ecif, cif->flags, ecif.rvalue, fn); + break; + + default: + FFI_ASSERT (0); + break; + } +} + +/* + * Closure API + */ + +static void +ffi_prep_closure_args_OBSD (ffi_cif *cif, void **avalue, unsigned int *regp, + char *stackp) +{ + unsigned int i; + void **p_argv; + char *argp; + unsigned int regused; + ffi_type **p_arg; + + regused = 0; + + p_argv = avalue; + + for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++) + { + size_t z; + unsigned short t, a; + + z = (*p_arg)->size; + t = (*p_arg)->type; + a = (*p_arg)->alignment; + + /* + * Figure out whether the argument has been passed through registers + * or on the stack. + * The rule is that registers can only receive simple types not larger + * than 64 bits, or structs the exact size of a register and aligned to + * the size of a register. + */ + if (t == FFI_TYPE_STRUCT) + { + if (z == sizeof (int) && a == sizeof (int) && regused < 8) + argp = (char *)regp; + else + argp = stackp; + } + else + { + if (z > sizeof (int) && regused < 8 - 1) + { + /* align to an even register pair */ + if (regused & 1) + { + regp++; + regused++; + } + } + if (regused < 8) + argp = (char *)regp; + else + argp = stackp; + } + + /* Enforce proper stack alignment of 64-bit types */ + if (argp == stackp && a > sizeof (int)) + { + stackp = (char *) ALIGN(stackp, a); + argp = stackp; + } + + if (z < sizeof (int) && t != FFI_TYPE_STRUCT) + *p_argv = (void *) (argp + sizeof (int) - z); + else + *p_argv = (void *) argp; + + /* Align if necessary */ + if ((sizeof (int) - 1) & z) + z = ALIGN(z, sizeof (int)); + + p_argv++; + + /* Be careful, once all registers are exhausted, and about to fetch from + stack, regp == stackp. Therefore the check for regused as well. */ + if (argp == (char *)regp && regused < 8) + { + regp += z / sizeof (int); + regused += z / sizeof (int); + } + else + stackp += z; + } +} + +unsigned int +ffi_closure_OBSD_inner (ffi_closure *closure, void *resp, unsigned int *regp, + char *stackp) +{ + ffi_cif *cif; + void **arg_area; + + cif = closure->cif; + arg_area = (void**) alloca (cif->nargs * sizeof (void *)); + + ffi_prep_closure_args_OBSD(cif, arg_area, regp, stackp); + + (closure->fun) (cif, resp, arg_area, closure->user_data); + + return cif->flags; +} + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, void *codeloc) +{ + unsigned int *tramp = (unsigned int *) codeloc; + void *fn; + + FFI_ASSERT (cif->abi == FFI_OBSD); + + if (cif->rtype->type == FFI_TYPE_STRUCT && !cif->flags) + fn = &ffi_closure_struct_OBSD; + else + fn = &ffi_closure_OBSD; + + /* or.u %r10, %r0, %hi16(fn) */ + tramp[0] = 0x5d400000 | (((unsigned int)fn) >> 16); + /* or.u %r13, %r0, %hi16(closure) */ + tramp[1] = 0x5da00000 | ((unsigned int)closure >> 16); + /* or %r10, %r10, %lo16(fn) */ + tramp[2] = 0x594a0000 | (((unsigned int)fn) & 0xffff); + /* jmp.n %r10 */ + tramp[3] = 0xf400c40a; + /* or %r13, %r13, %lo16(closure) */ + tramp[4] = 0x59ad0000 | ((unsigned int)closure & 0xffff); + + ffi_cacheflush_OBSD((unsigned int)codeloc, FFI_TRAMPOLINE_SIZE); + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/m88k/ffitarget.h b/user/mpy/lib/libffi/src/m88k/ffitarget.h new file mode 100644 index 0000000..e52bf9f --- /dev/null +++ b/user/mpy/lib/libffi/src/m88k/ffitarget.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * 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. + */ + +/* + * m88k Foreign Function Interface + */ + +#ifndef LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_OBSD, + FFI_DEFAULT_ABI = FFI_OBSD, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 0x14 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/m88k/obsd.S b/user/mpy/lib/libffi/src/m88k/obsd.S new file mode 100644 index 0000000..1944a23 --- /dev/null +++ b/user/mpy/lib/libffi/src/m88k/obsd.S @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * 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. + */ + +/* + * m88k Foreign Function Interface + */ + +#define LIBFFI_ASM +#include +#include + + .text + +/* + * ffi_cacheflush_OBSD(unsigned int addr, %r2 + * unsigned int size); %r3 + */ + .align 4 + .globl ffi_cacheflush_OBSD + .type ffi_cacheflush_OBSD,@function +ffi_cacheflush_OBSD: + tb0 0, %r0, 451 + or %r0, %r0, %r0 + jmp %r1 + .size ffi_cacheflush_OBSD, . - ffi_cacheflush_OBSD + +/* + * ffi_call_OBSD(unsigned bytes, %r2 + * extended_cif *ecif, %r3 + * unsigned flags, %r4 + * void *rvalue, %r5 + * void (*fn)()); %r6 + */ + .align 4 + .globl ffi_call_OBSD + .type ffi_call_OBSD,@function +ffi_call_OBSD: + subu %r31, %r31, 32 + st %r30, %r31, 4 + st %r1, %r31, 0 + addu %r30, %r31, 32 + + | Save the few arguments we'll need after ffi_prep_args() + st.d %r4, %r31, 8 + st %r6, %r31, 16 + + | Allocate room for the image of r2-r9, and the stack space for + | the args (rounded to a 16-byte boundary) + addu %r2, %r2, (8 * 4) + 15 + clr %r2, %r2, 4<0> + subu %r31, %r31, %r2 + + | Fill register and stack image + or %r2, %r31, %r0 +#ifdef PIC + bsr ffi_prep_args#plt +#else + bsr ffi_prep_args +#endif + + | Save pointer to return struct address, if any + or %r12, %r2, %r0 + + | Get function pointer + subu %r4, %r30, 32 + ld %r1, %r4, 16 + + | Fetch the register arguments + ld.d %r2, %r31, (0 * 4) + ld.d %r4, %r31, (2 * 4) + ld.d %r6, %r31, (4 * 4) + ld.d %r8, %r31, (6 * 4) + addu %r31, %r31, (8 * 4) + + | Invoke the function + jsr %r1 + + | Restore stack now that we don't need the args anymore + subu %r31, %r30, 32 + + | Figure out what to return as the function's return value + ld %r5, %r31, 12 | rvalue + ld %r4, %r31, 8 | flags + + bcnd eq0, %r5, 9f + + bb0 0, %r4, 1f | CIF_FLAGS_INT + st %r2, %r5, 0 + br 9f + +1: + bb0 1, %r4, 1f | CIF_FLAGS_DINT + st.d %r2, %r5, 0 + br 9f + +1: +9: + ld %r1, %r31, 0 + ld %r30, %r31, 4 + jmp.n %r1 + addu %r31, %r31, 32 + .size ffi_call_OBSD, . - ffi_call_OBSD + +/* + * ffi_closure_OBSD(ffi_closure *closure); %r13 + */ + .align 4 + .globl ffi_closure_OBSD + .type ffi_closure_OBSD, @function +ffi_closure_OBSD: + subu %r31, %r31, 16 + st %r30, %r31, 4 + st %r1, %r31, 0 + addu %r30, %r31, 16 + + | Make room on the stack for saved register arguments and return + | value + subu %r31, %r31, (8 * 4) + (2 * 4) + st.d %r2, %r31, (0 * 4) + st.d %r4, %r31, (2 * 4) + st.d %r6, %r31, (4 * 4) + st.d %r8, %r31, (6 * 4) + + | Invoke the closure function + or %r5, %r30, 0 | calling stack + addu %r4, %r31, 0 | saved registers + addu %r3, %r31, (8 * 4) | return value + or %r2, %r13, %r0 | closure +#ifdef PIC + bsr ffi_closure_OBSD_inner#plt +#else + bsr ffi_closure_OBSD_inner +#endif + + | Figure out what to return as the function's return value + bb0 0, %r2, 1f | CIF_FLAGS_INT + ld %r2, %r31, (8 * 4) + br 9f + +1: + bb0 1, %r2, 1f | CIF_FLAGS_DINT + ld.d %r2, %r31, (8 * 4) + br 9f + +1: +9: + subu %r31, %r30, 16 + ld %r1, %r31, 0 + ld %r30, %r31, 4 + jmp.n %r1 + addu %r31, %r31, 16 + .size ffi_closure_OBSD,.-ffi_closure_OBSD + +/* + * ffi_closure_struct_OBSD(ffi_closure *closure); %r13 + */ + .align 4 + .globl ffi_closure_struct_OBSD + .type ffi_closure_struct_OBSD, @function +ffi_closure_struct_OBSD: + subu %r31, %r31, 16 + st %r30, %r31, 4 + st %r1, %r31, 0 + addu %r30, %r31, 16 + + | Make room on the stack for saved register arguments + subu %r31, %r31, (8 * 4) + st.d %r2, %r31, (0 * 4) + st.d %r4, %r31, (2 * 4) + st.d %r6, %r31, (4 * 4) + st.d %r8, %r31, (6 * 4) + + | Invoke the closure function + or %r5, %r30, 0 | calling stack + addu %r4, %r31, 0 | saved registers + or %r3, %r12, 0 | return value + or %r2, %r13, %r0 | closure +#ifdef PIC + bsr ffi_closure_OBSD_inner#plt +#else + bsr ffi_closure_OBSD_inner +#endif + + subu %r31, %r30, 16 + ld %r1, %r31, 0 + ld %r30, %r31, 4 + jmp.n %r1 + addu %r31, %r31, 16 + .size ffi_closure_struct_OBSD,.-ffi_closure_struct_OBSD diff --git a/user/mpy/lib/libffi/src/metag/ffi.c b/user/mpy/lib/libffi/src/metag/ffi.c new file mode 100644 index 0000000..46b383e --- /dev/null +++ b/user/mpy/lib/libffi/src/metag/ffi.c @@ -0,0 +1,330 @@ +/* ---------------------------------------------------------------------- + ffi.c - Copyright (c) 2013 Imagination Technologies + + Meta Foreign Function Interface + 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 SIMON POSNJAK 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. +----------------------------------------------------------------------- */ + +#include +#include + +#include + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +/* + * ffi_prep_args is called by the assembly routine once stack space has been + * allocated for the function's arguments + */ + +unsigned int ffi_prep_args(char *stack, extended_cif *ecif) +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + /* Store return value */ + if ( ecif->cif->flags == FFI_TYPE_STRUCT ) { + argp -= 4; + *(void **) argp = ecif->rvalue; + } + + p_argv = ecif->avalue; + + /* point to next location */ + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; (i != 0); i--, p_arg++, p_argv++) + { + size_t z; + + /* Move argp to address of argument */ + z = (*p_arg)->size; + argp -= z; + + /* Align if necessary */ + argp = (char *) ALIGN_DOWN(ALIGN_DOWN(argp, (*p_arg)->alignment), 4); + + if (z < sizeof(int)) { + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + case FFI_TYPE_STRUCT: + memcpy(argp, *p_argv, (*p_arg)->size); + break; + default: + FFI_ASSERT(0); + } + } else if ( z == sizeof(int)) { + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + } else { + memcpy(argp, *p_argv, z); + } + } + + /* return the size of the arguments to be passed in registers, + padded to an 8 byte boundary to preserve stack alignment */ + return ALIGN(MIN(stack - argp, 6*4), 8); +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + ffi_type **ptr; + unsigned i, bytes = 0; + + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) { + if ((*ptr)->size == 0) + return FFI_BAD_TYPEDEF; + + /* Perform a sanity check on the argument type, do this + check after the initialization. */ + FFI_ASSERT_VALID_TYPE(*ptr); + + /* Add any padding if necessary */ + if (((*ptr)->alignment - 1) & bytes) + bytes = ALIGN(bytes, (*ptr)->alignment); + + bytes += ALIGN((*ptr)->size, 4); + } + + /* Ensure arg space is aligned to an 8-byte boundary */ + bytes = ALIGN(bytes, 8); + + /* Make space for the return structure pointer */ + if (cif->rtype->type == FFI_TYPE_STRUCT) { + bytes += sizeof(void*); + + /* Ensure stack is aligned to an 8-byte boundary */ + bytes = ALIGN(bytes, 8); + } + + cif->bytes = bytes; + + /* Set the return type flag */ + switch (cif->rtype->type) { + case FFI_TYPE_VOID: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + cif->flags = (unsigned) cif->rtype->type; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = (unsigned) FFI_TYPE_SINT64; + break; + case FFI_TYPE_STRUCT: + /* Meta can store return values which are <= 64 bits */ + if (cif->rtype->size <= 4) + /* Returned to D0Re0 as 32-bit value */ + cif->flags = (unsigned)FFI_TYPE_INT; + else if ((cif->rtype->size > 4) && (cif->rtype->size <= 8)) + /* Returned valued is stored to D1Re0|R0Re0 */ + cif->flags = (unsigned)FFI_TYPE_DOUBLE; + else + /* value stored in memory */ + cif->flags = (unsigned)FFI_TYPE_STRUCT; + break; + default: + cif->flags = (unsigned)FFI_TYPE_INT; + break; + } + return FFI_OK; +} + +extern void ffi_call_SYSV(void (*fn)(void), extended_cif *, unsigned, unsigned, double *); + +/* + * Exported in API. Entry point + * cif -> ffi_cif object + * fn -> function pointer + * rvalue -> pointer to return value + * avalue -> vector of void * pointers pointing to memory locations holding the + * arguments + */ +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + int small_struct = (((cif->flags == FFI_TYPE_INT) || (cif->flags == FFI_TYPE_DOUBLE)) && (cif->rtype->type == FFI_TYPE_STRUCT)); + ecif.cif = cif; + ecif.avalue = avalue; + + double temp; + + /* + * If the return value is a struct and we don't have a return value address + * then we need to make one + */ + + if ((rvalue == NULL ) && (cif->flags == FFI_TYPE_STRUCT)) + ecif.rvalue = alloca(cif->rtype->size); + else if (small_struct) + ecif.rvalue = &temp; + else + ecif.rvalue = rvalue; + + switch (cif->abi) { + case FFI_SYSV: + ffi_call_SYSV(fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); + break; + default: + FFI_ASSERT(0); + break; + } + + if (small_struct) + memcpy (rvalue, &temp, cif->rtype->size); +} + +/* private members */ + +static void ffi_prep_incoming_args_SYSV (char *, void **, void **, + ffi_cif*, float *); + +void ffi_closure_SYSV (ffi_closure *); + +/* Do NOT change that without changing the FFI_TRAMPOLINE_SIZE */ +extern unsigned int ffi_metag_trampoline[10]; /* 10 instructions */ + +/* end of private members */ + +/* + * __tramp: trampoline memory location + * __fun: assembly routine + * __ctx: memory location for wrapper + * + * At this point, tramp[0] == __ctx ! + */ +void ffi_init_trampoline(unsigned char *__tramp, unsigned int __fun, unsigned int __ctx) { + memcpy (__tramp, ffi_metag_trampoline, sizeof(ffi_metag_trampoline)); + *(unsigned int*) &__tramp[40] = __ctx; + *(unsigned int*) &__tramp[44] = __fun; + /* This will flush the instruction cache */ + __builtin_meta2_cachewd(&__tramp[0], 1); + __builtin_meta2_cachewd(&__tramp[47], 1); +} + + + +/* the cif must already be prepared */ + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + void (*closure_func)(ffi_closure*) = NULL; + + if (cif->abi == FFI_SYSV) + closure_func = &ffi_closure_SYSV; + else + return FFI_BAD_ABI; + + ffi_init_trampoline( + (unsigned char*)&closure->tramp[0], + (unsigned int)closure_func, + (unsigned int)codeloc); + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} + + +/* This function is jumped to by the trampoline */ +unsigned int ffi_closure_SYSV_inner (closure, respp, args, vfp_args) + ffi_closure *closure; + void **respp; + void *args; + void *vfp_args; +{ + ffi_cif *cif; + void **arg_area; + + cif = closure->cif; + arg_area = (void**) alloca (cif->nargs * sizeof (void*)); + + /* + * This call will initialize ARG_AREA, such that each + * element in that array points to the corresponding + * value on the stack; and if the function returns + * a structure, it will re-set RESP to point to the + * structure return address. + */ + ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args); + + (closure->fun) ( cif, *respp, arg_area, closure->user_data); + + return cif->flags; +} + +static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, + void **avalue, ffi_cif *cif, + float *vfp_stack) +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + /* stack points to original arguments */ + argp = stack; + + /* Store return value */ + if ( cif->flags == FFI_TYPE_STRUCT ) { + argp -= 4; + *rvalue = *(void **) argp; + } + + p_argv = avalue; + + for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) { + size_t z; + size_t alignment; + + alignment = (*p_arg)->alignment; + if (alignment < 4) + alignment = 4; + if ((alignment - 1) & (unsigned)argp) + argp = (char *) ALIGN(argp, alignment); + + z = (*p_arg)->size; + *p_argv = (void*) argp; + p_argv++; + argp -= z; + } + return; +} diff --git a/user/mpy/lib/libffi/src/metag/ffitarget.h b/user/mpy/lib/libffi/src/metag/ffitarget.h new file mode 100644 index 0000000..7b9dbeb --- /dev/null +++ b/user/mpy/lib/libffi/src/metag/ffitarget.h @@ -0,0 +1,53 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2013 Imagination Technologies Ltd. + Target configuration macros for Meta + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1, +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 48 +#define FFI_NATIVE_RAW_API 0 + +#endif + diff --git a/user/mpy/lib/libffi/src/metag/sysv.S b/user/mpy/lib/libffi/src/metag/sysv.S new file mode 100644 index 0000000..b4b2a3b --- /dev/null +++ b/user/mpy/lib/libffi/src/metag/sysv.S @@ -0,0 +1,311 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2013 Imagination Technologies Ltd. + + Meta Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#ifdef HAVE_MACHINE_ASM_H +#include +#else +#ifdef __USER_LABEL_PREFIX__ +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +/* Use the right prefix for global labels. */ +#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x) +#else +#define CNAME(x) x +#endif +#define ENTRY(x) .globl CNAME(x); .type CNAME(x), %function; CNAME(x): +#endif + +#ifdef __ELF__ +#define LSYM(x) .x +#else +#define LSYM(x) x +#endif + +.macro call_reg x= + .text + .balign 4 + mov D1RtP, \x + swap D1RtP, PC +.endm + +! Save register arguments +.macro SAVE_ARGS + .text + .balign 4 + setl [A0StP++], D0Ar6, D1Ar5 + setl [A0StP++], D0Ar4, D1Ar3 + setl [A0StP++], D0Ar2, D1Ar1 +.endm + +! Save retrun, frame pointer and other regs +.macro SAVE_REGS regs= + .text + .balign 4 + setl [A0StP++], D0FrT, D1RtP + ! Needs to be a pair of regs + .ifnc "\regs","" + setl [A0StP++], \regs + .endif +.endm + +! Declare a global function +.macro METAG_FUNC_START name + .text + .balign 4 + ENTRY(\name) +.endm + +! Return registers from the stack. Reverse SAVE_REGS operation +.macro RET_REGS regs=, cond= + .ifnc "\regs", "" + getl \regs, [--A0StP] + .endif + getl D0FrT, D1RtP, [--A0StP] +.endm + +! Return arguments +.macro RET_ARGS + getl D0Ar2, D1Ar1, [--A0StP] + getl D0Ar4, D1Ar3, [--A0StP] + getl D0Ar6, D1Ar5, [--A0StP] +.endm + + + ! D1Ar1: fn + ! D0Ar2: &ecif + ! D1Ar3: cif->bytes + ! D0Ar4: fig->flags + ! D1Ar5: ecif.rvalue + + ! This assumes we are using GNU as +METAG_FUNC_START ffi_call_SYSV + ! Save argument registers + + SAVE_ARGS + + ! new frame + mov D0FrT, A0FrP + add A0FrP, A0StP, #0 + + ! Preserve the old frame pointer + SAVE_REGS "D1.5, D0.5" + + ! Make room for new args. cifs->bytes is the total space for input + ! and return arguments + + add A0StP, A0StP, D1Ar3 + + ! Preserve cifs->bytes & fn + mov D0.5, D1Ar3 + mov D1.5, D1Ar1 + + ! Place all of the ffi_prep_args in position + mov D1Ar1, A0StP + + ! Call ffi_prep_args(stack, &ecif) +#ifdef __PIC__ + callr D1RtP, CNAME(ffi_prep_args@PLT) +#else + callr D1RtP, CNAME(ffi_prep_args) +#endif + + ! Restore fn pointer + + ! The foreign stack should look like this + ! XXXXX XXXXXX <--- stack pointer + ! FnArgN rvalue + ! FnArgN+2 FnArgN+1 + ! FnArgN+4 FnArgN+3 + ! .... + ! + + ! A0StP now points to the first (or return) argument + 4 + + ! Preserve cif->bytes + getl D0Ar2, D1Ar1, [--A0StP] + getl D0Ar4, D1Ar3, [--A0StP] + getl D0Ar6, D1Ar5, [--A0StP] + + ! Place A0StP to the first argument again + add A0StP, A0StP, #24 ! That's because we loaded 6 regs x 4 byte each + + ! A0FrP points to the initial stack without the reserved space for the + ! cifs->bytes, whilst A0StP points to the stack after the space allocation + + ! fn was the first argument of ffi_call_SYSV. + ! The stack at this point looks like this: + ! + ! A0StP(on entry to _SYSV) -> Arg6 Arg5 | low + ! Arg4 Arg3 | + ! Arg2 Arg1 | + ! A0FrP ----> D0FrtP D1RtP | + ! D1.5 D0.5 | + ! A0StP(bf prep_args) -> FnArgn FnArgn-1 | + ! FnArgn-2FnArgn-3 | + ! ................ | <= cifs->bytes + ! FnArg4 FnArg3 | + ! A0StP (prv_A0StP+cifs->bytes) FnArg2 FnArg1 | high + ! + ! fn was in Arg1 so it's located in in A0FrP+#-0xC + ! + + ! D0Re0 contains the size of arguments stored in registers + sub A0StP, A0StP, D0Re0 + + ! Arg1 is the function pointer for the foreign call. This has been + ! preserved in D1.5 + + ! Time to call (fn). Arguments should be like this: + ! Arg1-Arg6 are loaded to regs + ! The rest of the arguments are stored in stack pointed by A0StP + + call_reg D1.5 + + ! Reset stack. + + mov A0StP, A0FrP + + ! Load Arg1 with the pointer to storage for the return type + ! This was stored in Arg5 + + getd D1Ar1, [A0FrP+#-20] + + ! Load D0Ar2 with the return type code. This was stored in Arg4 (flags) + + getd D0Ar2, [A0FrP+#-16] + + ! We are ready to start processing the return value + ! D0Re0 (and D1Re0) hold the return value + + ! If the return value is NULL, assume no return value + cmp D1Ar1, #0 + beq LSYM(Lepilogue) + + ! return INT + cmp D0Ar2, #FFI_TYPE_INT + ! Sadly, there is no setd{cc} instruction so we need to workaround that + bne .INT64 + setd [D1Ar1], D0Re0 + b LSYM(Lepilogue) + + ! return INT64 +.INT64: + cmp D0Ar2, #FFI_TYPE_SINT64 + setleq [D1Ar1], D0Re0, D1Re0 + + ! return DOUBLE + cmp D0Ar2, #FFI_TYPE_DOUBLE + setl [D1AR1++], D0Re0, D1Re0 + +LSYM(Lepilogue): + ! At this point, the stack pointer points right after the argument + ! saved area. We need to restore 4 regs, therefore we need to move + ! 16 bytes ahead. + add A0StP, A0StP, #16 + RET_REGS "D1.5, D0.5" + RET_ARGS + getd D0Re0, [A0StP] + mov A0FrP, D0FrT + swap D1RtP, PC + +.ffi_call_SYSV_end: + .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) + + +/* + (called by ffi_metag_trampoline) + void ffi_closure_SYSV (ffi_closure*) + + (called by ffi_closure_SYSV) + unsigned int FFI_HIDDEN + ffi_closure_SYSV_inner (closure,respp, args) + ffi_closure *closure; + void **respp; + void *args; +*/ + +METAG_FUNC_START ffi_closure_SYSV + ! We assume that D1Ar1 holds the address of the + ! ffi_closure struct. We will use that to fetch the + ! arguments. The stack pointer points to an empty space + ! and it is ready to store more data. + + ! D1Ar1 is ready + ! Allocate stack space for return value + add A0StP, A0StP, #8 + ! Store it to D0Ar2 + sub D0Ar2, A0StP, #8 + + sub D1Ar3, A0FrP, #4 + + ! D1Ar3 contains the address of the original D1Ar1 argument + ! We need to subtract #4 later on + + ! Preverve D0Ar2 + mov D0.5, D0Ar2 + +#ifdef __PIC__ + callr D1RtP, CNAME(ffi_closure_SYSV_inner@PLT) +#else + callr D1RtP, CNAME(ffi_closure_SYSV_inner) +#endif + + ! Check the return value and store it to D0.5 + cmp D0Re0, #FFI_TYPE_INT + beq .Lretint + cmp D0Re0, #FFI_TYPE_DOUBLE + beq .Lretdouble +.Lclosure_epilogue: + sub A0StP, A0StP, #8 + RET_REGS "D1.5, D0.5" + RET_ARGS + swap D1RtP, PC + +.Lretint: + setd [D0.5], D0Re0 + b .Lclosure_epilogue +.Lretdouble: + setl [D0.5++], D0Re0, D1Re0 + b .Lclosure_epilogue +.ffi_closure_SYSV_end: +.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) + + +ENTRY(ffi_metag_trampoline) + SAVE_ARGS + ! New frame + mov A0FrP, A0StP + SAVE_REGS "D1.5, D0.5" + mov D0.5, PC + ! Load D1Ar1 the value of ffi_metag_trampoline + getd D1Ar1, [D0.5 + #8] + ! Jump to ffi_closure_SYSV + getd PC, [D0.5 + #12] diff --git a/user/mpy/lib/libffi/src/microblaze/ffi.c b/user/mpy/lib/libffi/src/microblaze/ffi.c new file mode 100644 index 0000000..ea962ea --- /dev/null +++ b/user/mpy/lib/libffi/src/microblaze/ffi.c @@ -0,0 +1,321 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2012, 2013 Xilinx, Inc + + MicroBlaze Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +extern void ffi_call_SYSV(void (*)(void*, extended_cif*), extended_cif*, + unsigned int, unsigned int, unsigned int*, void (*fn)(void), + unsigned int, unsigned int); + +extern void ffi_closure_SYSV(void); + +#define WORD_SIZE sizeof(unsigned int) +#define ARGS_REGISTER_SIZE (WORD_SIZE * 6) +#define WORD_ALIGN(x) ALIGN(x, WORD_SIZE) + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ +void ffi_prep_args(void* stack, extended_cif* ecif) +{ + unsigned int i; + ffi_type** p_arg; + void** p_argv; + void* stack_args_p = stack; + + p_argv = ecif->avalue; + + if (ecif == NULL || ecif->cif == NULL) { + return; /* no description to prepare */ + } + + if ((ecif->cif->rtype != NULL) && + (ecif->cif->rtype->type == FFI_TYPE_STRUCT)) + { + /* if return type is a struct which is referenced on the stack/reg5, + * by a pointer. Stored the return value pointer in r5. + */ + char* addr = stack_args_p; + memcpy(addr, &(ecif->rvalue), WORD_SIZE); + stack_args_p += WORD_SIZE; + } + + if (ecif->avalue == NULL) { + return; /* no arguments to prepare */ + } + + for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; + i++, p_arg++) + { + size_t size = (*p_arg)->size; + int type = (*p_arg)->type; + void* value = p_argv[i]; + char* addr = stack_args_p; + int aligned_size = WORD_ALIGN(size); + + /* force word alignment on the stack */ + stack_args_p += aligned_size; + + switch (type) + { + case FFI_TYPE_UINT8: + *(unsigned int *)addr = (unsigned int)*(UINT8*)(value); + break; + case FFI_TYPE_SINT8: + *(signed int *)addr = (signed int)*(SINT8*)(value); + break; + case FFI_TYPE_UINT16: + *(unsigned int *)addr = (unsigned int)*(UINT16*)(value); + break; + case FFI_TYPE_SINT16: + *(signed int *)addr = (signed int)*(SINT16*)(value); + break; + case FFI_TYPE_STRUCT: +#if __BIG_ENDIAN__ + /* + * MicroBlaze toolchain appears to emit: + * bsrli r5, r5, 8 (caller) + * ... + * + * ... + * bslli r5, r5, 8 (callee) + * + * For structs like "struct a { uint8_t a[3]; };", when passed + * by value. + * + * Structs like "struct b { uint16_t a; };" are also expected + * to be packed strangely in registers. + * + * This appears to be because the microblaze toolchain expects + * "struct b == uint16_t", which is only any issue for big + * endian. + * + * The following is a work around for big-endian only, for the + * above mentioned case, it will re-align the contents of a + * <= 3-byte struct value. + */ + if (size < WORD_SIZE) + { + memcpy (addr + (WORD_SIZE - size), value, size); + break; + } +#endif + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: + default: + memcpy(addr, value, aligned_size); + } + } +} + +ffi_status ffi_prep_cif_machdep(ffi_cif* cif) +{ + /* check ABI */ + switch (cif->abi) + { + case FFI_SYSV: + break; + default: + return FFI_BAD_ABI; + } + return FFI_OK; +} + +void ffi_call(ffi_cif* cif, void (*fn)(void), void* rvalue, void** avalue) +{ + extended_cif ecif; + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { + ecif.rvalue = alloca(cif->rtype->size); + } else { + ecif.rvalue = rvalue; + } + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, + ecif.rvalue, fn, cif->rtype->type, cif->rtype->size); + break; + default: + FFI_ASSERT(0); + break; + } +} + +void ffi_closure_call_SYSV(void* register_args, void* stack_args, + ffi_closure* closure, void* rvalue, + unsigned int* rtype, unsigned int* rsize) +{ + /* prepare arguments for closure call */ + ffi_cif* cif = closure->cif; + ffi_type** arg_types = cif->arg_types; + + /* re-allocate data for the args. This needs to be done in order to keep + * multi-word objects (e.g. structs) in contiguous memory. Callers are not + * required to store the value of args in the lower 6 words in the stack + * (although they are allocated in the stack). + */ + char* stackclone = alloca(cif->bytes); + void** avalue = alloca(cif->nargs * sizeof(void*)); + void* struct_rvalue = NULL; + char* ptr = stackclone; + int i; + + /* copy registers into stack clone */ + int registers_used = cif->bytes; + if (registers_used > ARGS_REGISTER_SIZE) { + registers_used = ARGS_REGISTER_SIZE; + } + memcpy(stackclone, register_args, registers_used); + + /* copy stack allocated args into stack clone */ + if (cif->bytes > ARGS_REGISTER_SIZE) { + int stack_used = cif->bytes - ARGS_REGISTER_SIZE; + memcpy(stackclone + ARGS_REGISTER_SIZE, stack_args, stack_used); + } + + /* preserve struct type return pointer passing */ + if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { + struct_rvalue = *((void**)ptr); + ptr += WORD_SIZE; + } + + /* populate arg pointer list */ + for (i = 0; i < cif->nargs; i++) + { + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: +#ifdef __BIG_ENDIAN__ + avalue[i] = ptr + 3; +#else + avalue[i] = ptr; +#endif + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: +#ifdef __BIG_ENDIAN__ + avalue[i] = ptr + 2; +#else + avalue[i] = ptr; +#endif + break; + case FFI_TYPE_STRUCT: +#if __BIG_ENDIAN__ + /* + * Work around strange ABI behaviour. + * (see info in ffi_prep_args) + */ + if (arg_types[i]->size < WORD_SIZE) + { + memcpy (ptr, ptr + (WORD_SIZE - arg_types[i]->size), arg_types[i]->size); + } +#endif + avalue[i] = (void*)ptr; + break; + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_DOUBLE: + avalue[i] = ptr; + break; + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + default: + /* default 4-byte argument */ + avalue[i] = ptr; + break; + } + ptr += WORD_ALIGN(arg_types[i]->size); + } + + /* set the return type info passed back to the wrapper */ + *rsize = cif->rtype->size; + *rtype = cif->rtype->type; + if (struct_rvalue != NULL) { + closure->fun(cif, struct_rvalue, avalue, closure->user_data); + /* copy struct return pointer value into function return value */ + *((void**)rvalue) = struct_rvalue; + } else { + closure->fun(cif, rvalue, avalue, closure->user_data); + } +} + +ffi_status ffi_prep_closure_loc( + ffi_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void* user_data, void* codeloc) +{ + unsigned long* tramp = (unsigned long*)&(closure->tramp[0]); + unsigned long cls = (unsigned long)codeloc; + unsigned long fn = 0; + unsigned long fn_closure_call_sysv = (unsigned long)ffi_closure_call_SYSV; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + switch (cif->abi) + { + case FFI_SYSV: + fn = (unsigned long)ffi_closure_SYSV; + + /* load r11 (temp) with fn */ + /* imm fn(upper) */ + tramp[0] = 0xb0000000 | ((fn >> 16) & 0xffff); + /* addik r11, r0, fn(lower) */ + tramp[1] = 0x31600000 | (fn & 0xffff); + + /* load r12 (temp) with cls */ + /* imm cls(upper) */ + tramp[2] = 0xb0000000 | ((cls >> 16) & 0xffff); + /* addik r12, r0, cls(lower) */ + tramp[3] = 0x31800000 | (cls & 0xffff); + + /* load r3 (temp) with ffi_closure_call_SYSV */ + /* imm fn_closure_call_sysv(upper) */ + tramp[4] = 0xb0000000 | ((fn_closure_call_sysv >> 16) & 0xffff); + /* addik r3, r0, fn_closure_call_sysv(lower) */ + tramp[5] = 0x30600000 | (fn_closure_call_sysv & 0xffff); + /* branch/jump to address stored in r11 (fn) */ + tramp[6] = 0x98085800; /* bra r11 */ + + break; + default: + return FFI_BAD_ABI; + } + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/microblaze/ffitarget.h b/user/mpy/lib/libffi/src/microblaze/ffitarget.h new file mode 100644 index 0000000..c6fa5a4 --- /dev/null +++ b/user/mpy/lib/libffi/src/microblaze/ffitarget.h @@ -0,0 +1,53 @@ +/* ----------------------------------------------------------------------- + ffitarget.h - Copyright (c) 2012, 2013 Xilinx, Inc + + Target configuration macros for MicroBlaze. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +/* Definitions for closures */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 + +#define FFI_TRAMPOLINE_SIZE (4*8) + +#endif diff --git a/user/mpy/lib/libffi/src/microblaze/sysv.S b/user/mpy/lib/libffi/src/microblaze/sysv.S new file mode 100644 index 0000000..ea43e9d --- /dev/null +++ b/user/mpy/lib/libffi/src/microblaze/sysv.S @@ -0,0 +1,302 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2012, 2013 Xilinx, Inc + + MicroBlaze Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + /* + * arg[0] (r5) = ffi_prep_args, + * arg[1] (r6) = &ecif, + * arg[2] (r7) = cif->bytes, + * arg[3] (r8) = cif->flags, + * arg[4] (r9) = ecif.rvalue, + * arg[5] (r10) = fn + * arg[6] (sp[0]) = cif->rtype->type + * arg[7] (sp[4]) = cif->rtype->size + */ + .text + .globl ffi_call_SYSV + .type ffi_call_SYSV, @function +ffi_call_SYSV: + /* push callee saves */ + addik r1, r1, -20 + swi r19, r1, 0 /* Frame Pointer */ + swi r20, r1, 4 /* PIC register */ + swi r21, r1, 8 /* PIC register */ + swi r22, r1, 12 /* save for locals */ + swi r23, r1, 16 /* save for locals */ + + /* save the r5-r10 registers in the stack */ + addik r1, r1, -24 /* increment sp to store 6x 32-bit words */ + swi r5, r1, 0 + swi r6, r1, 4 + swi r7, r1, 8 + swi r8, r1, 12 + swi r9, r1, 16 + swi r10, r1, 20 + + /* save function pointer */ + addik r3, r5, 0 /* copy ffi_prep_args into r3 */ + addik r22, r1, 0 /* save sp for unallocated args into r22 (callee-saved) */ + addik r23, r10, 0 /* save function address into r23 (callee-saved) */ + + /* prepare stack with allocation for n (bytes = r7) args */ + rsub r1, r7, r1 /* subtract bytes from sp */ + + /* prep args for ffi_prep_args call */ + addik r5, r1, 0 /* store stack pointer into arg[0] */ + /* r6 still holds ecif for arg[1] */ + + /* Call ffi_prep_args(stack, &ecif). */ + addik r1, r1, -4 + swi r15, r1, 0 /* store the link register in the frame */ + brald r15, r3 + nop /* branch has delay slot */ + lwi r15, r1, 0 + addik r1, r1, 4 /* restore the link register from the frame */ + /* returns calling stack pointer location */ + + /* prepare args for fn call, prep_args populates them onto the stack */ + lwi r5, r1, 0 /* arg[0] */ + lwi r6, r1, 4 /* arg[1] */ + lwi r7, r1, 8 /* arg[2] */ + lwi r8, r1, 12 /* arg[3] */ + lwi r9, r1, 16 /* arg[4] */ + lwi r10, r1, 20 /* arg[5] */ + + /* call (fn) (...). */ + addik r1, r1, -4 + swi r15, r1, 0 /* store the link register in the frame */ + brald r15, r23 + nop /* branch has delay slot */ + lwi r15, r1, 0 + addik r1, r1, 4 /* restore the link register from the frame */ + + /* Remove the space we pushed for the args. */ + addik r1, r22, 0 /* restore old SP */ + + /* restore this functions parameters */ + lwi r5, r1, 0 /* arg[0] */ + lwi r6, r1, 4 /* arg[1] */ + lwi r7, r1, 8 /* arg[2] */ + lwi r8, r1, 12 /* arg[3] */ + lwi r9, r1, 16 /* arg[4] */ + lwi r10, r1, 20 /* arg[5] */ + addik r1, r1, 24 /* decrement sp to de-allocate 6x 32-bit words */ + + /* If the return value pointer is NULL, assume no return value. */ + beqi r9, ffi_call_SYSV_end + + lwi r22, r1, 48 /* get return type (20 for locals + 28 for arg[6]) */ + lwi r23, r1, 52 /* get return size (20 for locals + 32 for arg[7]) */ + + /* Check if return type is actually a struct, do nothing */ + rsubi r11, r22, FFI_TYPE_STRUCT + beqi r11, ffi_call_SYSV_end + + /* Return 8bit */ + rsubi r11, r23, 1 + beqi r11, ffi_call_SYSV_store8 + + /* Return 16bit */ + rsubi r11, r23, 2 + beqi r11, ffi_call_SYSV_store16 + + /* Return 32bit */ + rsubi r11, r23, 4 + beqi r11, ffi_call_SYSV_store32 + + /* Return 64bit */ + rsubi r11, r23, 8 + beqi r11, ffi_call_SYSV_store64 + + /* Didn't match anything */ + bri ffi_call_SYSV_end + +ffi_call_SYSV_store64: + swi r3, r9, 0 /* store word r3 into return value */ + swi r4, r9, 4 /* store word r4 into return value */ + bri ffi_call_SYSV_end + +ffi_call_SYSV_store32: + swi r3, r9, 0 /* store word r3 into return value */ + bri ffi_call_SYSV_end + +ffi_call_SYSV_store16: +#ifdef __BIG_ENDIAN__ + shi r3, r9, 2 /* store half-word r3 into return value */ +#else + shi r3, r9, 0 /* store half-word r3 into return value */ +#endif + bri ffi_call_SYSV_end + +ffi_call_SYSV_store8: +#ifdef __BIG_ENDIAN__ + sbi r3, r9, 3 /* store byte r3 into return value */ +#else + sbi r3, r9, 0 /* store byte r3 into return value */ +#endif + bri ffi_call_SYSV_end + +ffi_call_SYSV_end: + /* callee restores */ + lwi r19, r1, 0 /* frame pointer */ + lwi r20, r1, 4 /* PIC register */ + lwi r21, r1, 8 /* PIC register */ + lwi r22, r1, 12 + lwi r23, r1, 16 + addik r1, r1, 20 + + /* return from sub-routine (with delay slot) */ + rtsd r15, 8 + nop + + .size ffi_call_SYSV, . - ffi_call_SYSV + +/* ------------------------------------------------------------------------- */ + + /* + * args passed into this function, are passed down to the callee. + * this function is the target of the closure trampoline, as such r12 is + * a pointer to the closure object. + */ + .text + .globl ffi_closure_SYSV + .type ffi_closure_SYSV, @function +ffi_closure_SYSV: + /* push callee saves */ + addik r11, r1, 28 /* save stack args start location (excluding regs/link) */ + addik r1, r1, -12 + swi r19, r1, 0 /* Frame Pointer */ + swi r20, r1, 4 /* PIC register */ + swi r21, r1, 8 /* PIC register */ + + /* store register args on stack */ + addik r1, r1, -24 + swi r5, r1, 0 + swi r6, r1, 4 + swi r7, r1, 8 + swi r8, r1, 12 + swi r9, r1, 16 + swi r10, r1, 20 + + /* setup args */ + addik r5, r1, 0 /* register_args */ + addik r6, r11, 0 /* stack_args */ + addik r7, r12, 0 /* closure object */ + addik r1, r1, -8 /* allocate return value */ + addik r8, r1, 0 /* void* rvalue */ + addik r1, r1, -8 /* allocate for return type/size values */ + addik r9, r1, 0 /* void* rtype */ + addik r10, r1, 4 /* void* rsize */ + + /* call the wrap_call function */ + addik r1, r1, -28 /* allocate args + link reg */ + swi r15, r1, 0 /* store the link register in the frame */ + brald r15, r3 + nop /* branch has delay slot */ + lwi r15, r1, 0 + addik r1, r1, 28 /* restore the link register from the frame */ + +ffi_closure_SYSV_prepare_return: + lwi r9, r1, 0 /* rtype */ + lwi r10, r1, 4 /* rsize */ + addik r1, r1, 8 /* de-allocate return info values */ + + /* Check if return type is actually a struct, store 4 bytes */ + rsubi r11, r9, FFI_TYPE_STRUCT + beqi r11, ffi_closure_SYSV_store32 + + /* Return 8bit */ + rsubi r11, r10, 1 + beqi r11, ffi_closure_SYSV_store8 + + /* Return 16bit */ + rsubi r11, r10, 2 + beqi r11, ffi_closure_SYSV_store16 + + /* Return 32bit */ + rsubi r11, r10, 4 + beqi r11, ffi_closure_SYSV_store32 + + /* Return 64bit */ + rsubi r11, r10, 8 + beqi r11, ffi_closure_SYSV_store64 + + /* Didn't match anything */ + bri ffi_closure_SYSV_end + +ffi_closure_SYSV_store64: + lwi r3, r1, 0 /* store word r3 into return value */ + lwi r4, r1, 4 /* store word r4 into return value */ + /* 64 bits == 2 words, no sign extend occurs */ + bri ffi_closure_SYSV_end + +ffi_closure_SYSV_store32: + lwi r3, r1, 0 /* store word r3 into return value */ + /* 32 bits == 1 word, no sign extend occurs */ + bri ffi_closure_SYSV_end + +ffi_closure_SYSV_store16: +#ifdef __BIG_ENDIAN__ + lhui r3, r1, 2 /* store half-word r3 into return value */ +#else + lhui r3, r1, 0 /* store half-word r3 into return value */ +#endif + rsubi r11, r9, FFI_TYPE_SINT16 + bnei r11, ffi_closure_SYSV_end + sext16 r3, r3 /* fix sign extend of sint8 */ + bri ffi_closure_SYSV_end + +ffi_closure_SYSV_store8: +#ifdef __BIG_ENDIAN__ + lbui r3, r1, 3 /* store byte r3 into return value */ +#else + lbui r3, r1, 0 /* store byte r3 into return value */ +#endif + rsubi r11, r9, FFI_TYPE_SINT8 + bnei r11, ffi_closure_SYSV_end + sext8 r3, r3 /* fix sign extend of sint8 */ + bri ffi_closure_SYSV_end + +ffi_closure_SYSV_end: + addik r1, r1, 8 /* de-allocate return value */ + + /* de-allocate stored args */ + addik r1, r1, 24 + + /* callee restores */ + lwi r19, r1, 0 /* frame pointer */ + lwi r20, r1, 4 /* PIC register */ + lwi r21, r1, 8 /* PIC register */ + addik r1, r1, 12 + + /* return from sub-routine (with delay slot) */ + rtsd r15, 8 + nop + + .size ffi_closure_SYSV, . - ffi_closure_SYSV diff --git a/user/mpy/lib/libffi/src/mips/ffi.c b/user/mpy/lib/libffi/src/mips/ffi.c new file mode 100644 index 0000000..5d0dd70 --- /dev/null +++ b/user/mpy/lib/libffi/src/mips/ffi.c @@ -0,0 +1,1050 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2011 Anthony Green + Copyright (c) 2008 David Daney + Copyright (c) 1996, 2007, 2008, 2011 Red Hat, Inc. + + MIPS Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +#ifdef __GNUC__ +# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) +# define USE__BUILTIN___CLEAR_CACHE 1 +# endif +#endif + +#ifndef USE__BUILTIN___CLEAR_CACHE +# if defined(__OpenBSD__) +# include +# else +# include +# endif +#endif + +#ifdef FFI_DEBUG +# define FFI_MIPS_STOP_HERE() ffi_stop_here() +#else +# define FFI_MIPS_STOP_HERE() do {} while(0) +#endif + +#ifdef FFI_MIPS_N32 +#define FIX_ARGP \ +FFI_ASSERT(argp <= &stack[bytes]); \ +if (argp == &stack[bytes]) \ +{ \ + argp = stack; \ + FFI_MIPS_STOP_HERE(); \ +} +#else +#define FIX_ARGP +#endif + + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +static void ffi_prep_args(char *stack, + extended_cif *ecif, + int bytes, + int flags) +{ + int i; + void **p_argv; + char *argp; + ffi_type **p_arg; + +#ifdef FFI_MIPS_N32 + /* If more than 8 double words are used, the remainder go + on the stack. We reorder stuff on the stack here to + support this easily. */ + if (bytes > 8 * sizeof(ffi_arg)) + argp = &stack[bytes - (8 * sizeof(ffi_arg))]; + else + argp = stack; +#else + argp = stack; +#endif + + memset(stack, 0, bytes); + +#ifdef FFI_MIPS_N32 + if ( ecif->cif->rstruct_flag != 0 ) +#else + if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) +#endif + { + *(ffi_arg *) argp = (ffi_arg) ecif->rvalue; + argp += sizeof(ffi_arg); + FIX_ARGP; + } + + p_argv = ecif->avalue; + + for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; i++, p_arg++) + { + size_t z; + unsigned int a; + + /* Align if necessary. */ + a = (*p_arg)->alignment; + if (a < sizeof(ffi_arg)) + a = sizeof(ffi_arg); + + if ((a - 1) & (unsigned long) argp) + { + argp = (char *) ALIGN(argp, a); + FIX_ARGP; + } + + z = (*p_arg)->size; + if (z <= sizeof(ffi_arg)) + { + int type = (*p_arg)->type; + z = sizeof(ffi_arg); + + /* The size of a pointer depends on the ABI */ + if (type == FFI_TYPE_POINTER) + type = (ecif->cif->abi == FFI_N64 + || ecif->cif->abi == FFI_N64_SOFT_FLOAT) + ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32; + + if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT + || ecif->cif->abi == FFI_N64_SOFT_FLOAT)) + { + switch (type) + { + case FFI_TYPE_FLOAT: + type = FFI_TYPE_UINT32; + break; + case FFI_TYPE_DOUBLE: + type = FFI_TYPE_UINT64; + break; + default: + break; + } + } + switch (type) + { + case FFI_TYPE_SINT8: + *(ffi_arg *)argp = *(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(ffi_arg *)argp = *(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(ffi_arg *)argp = *(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(ffi_arg *)argp = *(UINT16 *)(* p_argv); + break; + + case FFI_TYPE_SINT32: + *(ffi_arg *)argp = *(SINT32 *)(* p_argv); + break; + + case FFI_TYPE_UINT32: +#ifdef FFI_MIPS_N32 + /* The N32 ABI requires that 32-bit integers + be sign-extended to 64-bits, regardless of + whether they are signed or unsigned. */ + *(ffi_arg *)argp = *(SINT32 *)(* p_argv); +#else + *(ffi_arg *)argp = *(UINT32 *)(* p_argv); +#endif + break; + + /* This can only happen with 64bit slots. */ + case FFI_TYPE_FLOAT: + *(float *) argp = *(float *)(* p_argv); + break; + + /* Handle structures. */ + default: + memcpy(argp, *p_argv, (*p_arg)->size); + break; + } + } + else + { +#ifdef FFI_MIPS_O32 + memcpy(argp, *p_argv, z); +#else + { + unsigned long end = (unsigned long) argp + z; + unsigned long cap = (unsigned long) stack + bytes; + + /* Check if the data will fit within the register space. + Handle it if it doesn't. */ + + if (end <= cap) + memcpy(argp, *p_argv, z); + else + { + unsigned long portion = cap - (unsigned long)argp; + + memcpy(argp, *p_argv, portion); + argp = stack; + z -= portion; + memcpy(argp, (void*)((unsigned long)(*p_argv) + portion), + z); + } + } +#endif + } + p_argv++; + argp += z; + FIX_ARGP; + } +} + +#ifdef FFI_MIPS_N32 + +/* The n32 spec says that if "a chunk consists solely of a double + float field (but not a double, which is part of a union), it + is passed in a floating point register. Any other chunk is + passed in an integer register". This code traverses structure + definitions and generates the appropriate flags. */ + +static unsigned +calc_n32_struct_flags(int soft_float, ffi_type *arg, + unsigned *loc, unsigned *arg_reg) +{ + unsigned flags = 0; + unsigned index = 0; + + ffi_type *e; + + if (soft_float) + return 0; + + while ((e = arg->elements[index])) + { + /* Align this object. */ + *loc = ALIGN(*loc, e->alignment); + if (e->type == FFI_TYPE_DOUBLE) + { + /* Already aligned to FFI_SIZEOF_ARG. */ + *arg_reg = *loc / FFI_SIZEOF_ARG; + if (*arg_reg > 7) + break; + flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS)); + *loc += e->size; + } + else + *loc += e->size; + index++; + } + /* Next Argument register at alignment of FFI_SIZEOF_ARG. */ + *arg_reg = ALIGN(*loc, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; + + return flags; +} + +static unsigned +calc_n32_return_struct_flags(int soft_float, ffi_type *arg) +{ + unsigned flags = 0; + unsigned small = FFI_TYPE_SMALLSTRUCT; + ffi_type *e; + + /* Returning structures under n32 is a tricky thing. + A struct with only one or two floating point fields + is returned in $f0 (and $f2 if necessary). Any other + struct results at most 128 bits are returned in $2 + (the first 64 bits) and $3 (remainder, if necessary). + Larger structs are handled normally. */ + + if (arg->size > 16) + return 0; + + if (arg->size > 8) + small = FFI_TYPE_SMALLSTRUCT2; + + e = arg->elements[0]; + + if (e->type == FFI_TYPE_DOUBLE) + flags = FFI_TYPE_DOUBLE; + else if (e->type == FFI_TYPE_FLOAT) + flags = FFI_TYPE_FLOAT; + + if (flags && (e = arg->elements[1])) + { + if (e->type == FFI_TYPE_DOUBLE) + flags += FFI_TYPE_DOUBLE << FFI_FLAG_BITS; + else if (e->type == FFI_TYPE_FLOAT) + flags += FFI_TYPE_FLOAT << FFI_FLAG_BITS; + else + return small; + + if (flags && (arg->elements[2])) + { + /* There are three arguments and the first two are + floats! This must be passed the old way. */ + return small; + } + if (soft_float) + flags += FFI_TYPE_STRUCT_SOFT; + } + else + if (!flags) + return small; + + return flags; +} + +#endif + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + cif->flags = 0; + +#ifdef FFI_MIPS_O32 + /* Set the flags necessary for O32 processing. FFI_O32_SOFT_FLOAT + * does not have special handling for floating point args. + */ + + if (cif->rtype->type != FFI_TYPE_STRUCT && cif->abi == FFI_O32) + { + if (cif->nargs > 0) + { + switch ((cif->arg_types)[0]->type) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + cif->flags += (cif->arg_types)[0]->type; + break; + + default: + break; + } + + if (cif->nargs > 1) + { + /* Only handle the second argument if the first + is a float or double. */ + if (cif->flags) + { + switch ((cif->arg_types)[1]->type) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + cif->flags += (cif->arg_types)[1]->type << FFI_FLAG_BITS; + break; + + default: + break; + } + } + } + } + } + + /* Set the return type flag */ + + if (cif->abi == FFI_O32_SOFT_FLOAT) + { + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2); + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: + cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 2); + break; + + case FFI_TYPE_FLOAT: + default: + cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2); + break; + } + } + else + { + /* FFI_O32 */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2); + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 2); + break; + + default: + cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2); + break; + } + } +#endif + +#ifdef FFI_MIPS_N32 + /* Set the flags necessary for N32 processing */ + { + int type; + unsigned arg_reg = 0; + unsigned loc = 0; + unsigned count = (cif->nargs < 8) ? cif->nargs : 8; + unsigned index = 0; + + unsigned struct_flags = 0; + int soft_float = (cif->abi == FFI_N32_SOFT_FLOAT + || cif->abi == FFI_N64_SOFT_FLOAT); + + if (cif->rtype->type == FFI_TYPE_STRUCT) + { + struct_flags = calc_n32_return_struct_flags(soft_float, cif->rtype); + + if (struct_flags == 0) + { + /* This means that the structure is being passed as + a hidden argument */ + + arg_reg = 1; + count = (cif->nargs < 7) ? cif->nargs : 7; + + cif->rstruct_flag = !0; + } + else + cif->rstruct_flag = 0; + } + else + cif->rstruct_flag = 0; + + while (count-- > 0 && arg_reg < 8) + { + type = (cif->arg_types)[index]->type; + if (soft_float) + { + switch (type) + { + case FFI_TYPE_FLOAT: + type = FFI_TYPE_UINT32; + break; + case FFI_TYPE_DOUBLE: + type = FFI_TYPE_UINT64; + break; + default: + break; + } + } + switch (type) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + cif->flags += + ((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS)); + arg_reg++; + break; + case FFI_TYPE_LONGDOUBLE: + /* Align it. */ + arg_reg = ALIGN(arg_reg, 2); + /* Treat it as two adjacent doubles. */ + if (soft_float) + { + arg_reg += 2; + } + else + { + cif->flags += + (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS)); + arg_reg++; + cif->flags += + (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS)); + arg_reg++; + } + break; + + case FFI_TYPE_STRUCT: + loc = arg_reg * FFI_SIZEOF_ARG; + cif->flags += calc_n32_struct_flags(soft_float, + (cif->arg_types)[index], + &loc, &arg_reg); + break; + + default: + arg_reg++; + break; + } + + index++; + } + + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_STRUCT: + { + if (struct_flags == 0) + { + /* The structure is returned through a hidden + first argument. Do nothing, 'cause FFI_TYPE_VOID + is 0 */ + } + else + { + /* The structure is returned via some tricky + mechanism */ + cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8); + cif->flags += struct_flags << (4 + (FFI_FLAG_BITS * 8)); + } + break; + } + + case FFI_TYPE_VOID: + /* Do nothing, 'cause FFI_TYPE_VOID is 0 */ + break; + + case FFI_TYPE_POINTER: + if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32) + cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8); + else + cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8); + break; + + case FFI_TYPE_FLOAT: + if (soft_float) + { + cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8); + break; + } + /* else fall through */ + case FFI_TYPE_DOUBLE: + if (soft_float) + cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8); + else + cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8); + break; + + case FFI_TYPE_LONGDOUBLE: + /* Long double is returned as if it were a struct containing + two doubles. */ + if (soft_float) + { + cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8); + cif->flags += FFI_TYPE_SMALLSTRUCT2 << (4 + (FFI_FLAG_BITS * 8)); + } + else + { + cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8); + cif->flags += (FFI_TYPE_DOUBLE + + (FFI_TYPE_DOUBLE << FFI_FLAG_BITS)) + << (4 + (FFI_FLAG_BITS * 8)); + } + break; + default: + cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8); + break; + } + } +#endif + + return FFI_OK; +} + +/* Low level routine for calling O32 functions */ +extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int), + extended_cif *, unsigned, + unsigned, unsigned *, void (*)(void)); + +/* Low level routine for calling N32 functions */ +extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int), + extended_cif *, unsigned, + unsigned, void *, void (*)(void)); + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + ecif.rvalue = alloca(cif->rtype->size); + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { +#ifdef FFI_MIPS_O32 + case FFI_O32: + case FFI_O32_SOFT_FLOAT: + ffi_call_O32(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + break; +#endif + +#ifdef FFI_MIPS_N32 + case FFI_N32: + case FFI_N32_SOFT_FLOAT: + case FFI_N64: + case FFI_N64_SOFT_FLOAT: + { + int copy_rvalue = 0; + int copy_offset = 0; + char *rvalue_copy = ecif.rvalue; + if (cif->rtype->type == FFI_TYPE_STRUCT && cif->rtype->size < 16) + { + /* For structures smaller than 16 bytes we clobber memory + in 8 byte increments. Make a copy so we don't clobber + the callers memory outside of the struct bounds. */ + rvalue_copy = alloca(16); + copy_rvalue = 1; + } + else if (cif->rtype->type == FFI_TYPE_FLOAT + && (cif->abi == FFI_N64_SOFT_FLOAT + || cif->abi == FFI_N32_SOFT_FLOAT)) + { + rvalue_copy = alloca (8); + copy_rvalue = 1; +#if defined(__MIPSEB__) || defined(_MIPSEB) + copy_offset = 4; +#endif + } + ffi_call_N32(ffi_prep_args, &ecif, cif->bytes, + cif->flags, rvalue_copy, fn); + if (copy_rvalue) + memcpy(ecif.rvalue, rvalue_copy + copy_offset, cif->rtype->size); + } + break; +#endif + + default: + FFI_ASSERT(0); + break; + } +} + +#if FFI_CLOSURES +#if defined(FFI_MIPS_O32) +extern void ffi_closure_O32(void); +#else +extern void ffi_closure_N32(void); +#endif /* FFI_MIPS_O32 */ + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; + void * fn; + char *clear_location = (char *) codeloc; + +#if defined(FFI_MIPS_O32) + if (cif->abi != FFI_O32 && cif->abi != FFI_O32_SOFT_FLOAT) + return FFI_BAD_ABI; + fn = ffi_closure_O32; +#else +#if _MIPS_SIM ==_ABIN32 + if (cif->abi != FFI_N32 + && cif->abi != FFI_N32_SOFT_FLOAT) + return FFI_BAD_ABI; +#else + if (cif->abi != FFI_N64 + && cif->abi != FFI_N64_SOFT_FLOAT) + return FFI_BAD_ABI; +#endif + fn = ffi_closure_N32; +#endif /* FFI_MIPS_O32 */ + +#if defined(FFI_MIPS_O32) || (_MIPS_SIM ==_ABIN32) + /* lui $25,high(fn) */ + tramp[0] = 0x3c190000 | ((unsigned)fn >> 16); + /* ori $25,low(fn) */ + tramp[1] = 0x37390000 | ((unsigned)fn & 0xffff); + /* lui $12,high(codeloc) */ + tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16); + /* jr $25 */ + tramp[3] = 0x03200008; + /* ori $12,low(codeloc) */ + tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff); +#else + /* N64 has a somewhat larger trampoline. */ + /* lui $25,high(fn) */ + tramp[0] = 0x3c190000 | ((unsigned long)fn >> 48); + /* lui $12,high(codeloc) */ + tramp[1] = 0x3c0c0000 | ((unsigned long)codeloc >> 48); + /* ori $25,mid-high(fn) */ + tramp[2] = 0x37390000 | (((unsigned long)fn >> 32 ) & 0xffff); + /* ori $12,mid-high(codeloc) */ + tramp[3] = 0x358c0000 | (((unsigned long)codeloc >> 32) & 0xffff); + /* dsll $25,$25,16 */ + tramp[4] = 0x0019cc38; + /* dsll $12,$12,16 */ + tramp[5] = 0x000c6438; + /* ori $25,mid-low(fn) */ + tramp[6] = 0x37390000 | (((unsigned long)fn >> 16 ) & 0xffff); + /* ori $12,mid-low(codeloc) */ + tramp[7] = 0x358c0000 | (((unsigned long)codeloc >> 16) & 0xffff); + /* dsll $25,$25,16 */ + tramp[8] = 0x0019cc38; + /* dsll $12,$12,16 */ + tramp[9] = 0x000c6438; + /* ori $25,low(fn) */ + tramp[10] = 0x37390000 | ((unsigned long)fn & 0xffff); + /* jr $25 */ + tramp[11] = 0x03200008; + /* ori $12,low(codeloc) */ + tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff); + +#endif + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + +#ifdef USE__BUILTIN___CLEAR_CACHE + __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE); +#else + cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE); +#endif + return FFI_OK; +} + +/* + * Decodes the arguments to a function, which will be stored on the + * stack. AR is the pointer to the beginning of the integer arguments + * (and, depending upon the arguments, some floating-point arguments + * as well). FPR is a pointer to the area where floating point + * registers have been saved, if any. + * + * RVALUE is the location where the function return value will be + * stored. CLOSURE is the prepared closure to invoke. + * + * This function should only be called from assembly, which is in + * turn called from a trampoline. + * + * Returns the function return type. + * + * Based on the similar routine for sparc. + */ +int +ffi_closure_mips_inner_O32 (ffi_closure *closure, + void *rvalue, ffi_arg *ar, + double *fpr) +{ + ffi_cif *cif; + void **avaluep; + ffi_arg *avalue; + ffi_type **arg_types; + int i, avn, argn, seen_int; + + cif = closure->cif; + avalue = alloca (cif->nargs * sizeof (ffi_arg)); + avaluep = alloca (cif->nargs * sizeof (ffi_arg)); + + seen_int = (cif->abi == FFI_O32_SOFT_FLOAT); + argn = 0; + + if ((cif->flags >> (FFI_FLAG_BITS * 2)) == FFI_TYPE_STRUCT) + { + rvalue = (void *)(UINT32)ar[0]; + argn = 1; + } + + i = 0; + avn = cif->nargs; + arg_types = cif->arg_types; + + while (i < avn) + { + if (i < 2 && !seen_int && + (arg_types[i]->type == FFI_TYPE_FLOAT || + arg_types[i]->type == FFI_TYPE_DOUBLE || + arg_types[i]->type == FFI_TYPE_LONGDOUBLE)) + { +#if defined(__MIPSEB__) || defined(_MIPSEB) + if (arg_types[i]->type == FFI_TYPE_FLOAT) + avaluep[i] = ((char *) &fpr[i]) + sizeof (float); + else +#endif + avaluep[i] = (char *) &fpr[i]; + } + else + { + if (arg_types[i]->alignment == 8 && (argn & 0x1)) + argn++; + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + avaluep[i] = &avalue[i]; + *(SINT8 *) &avalue[i] = (SINT8) ar[argn]; + break; + + case FFI_TYPE_UINT8: + avaluep[i] = &avalue[i]; + *(UINT8 *) &avalue[i] = (UINT8) ar[argn]; + break; + + case FFI_TYPE_SINT16: + avaluep[i] = &avalue[i]; + *(SINT16 *) &avalue[i] = (SINT16) ar[argn]; + break; + + case FFI_TYPE_UINT16: + avaluep[i] = &avalue[i]; + *(UINT16 *) &avalue[i] = (UINT16) ar[argn]; + break; + + default: + avaluep[i] = (char *) &ar[argn]; + break; + } + seen_int = 1; + } + argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; + i++; + } + + /* Invoke the closure. */ + (closure->fun) (cif, rvalue, avaluep, closure->user_data); + + if (cif->abi == FFI_O32_SOFT_FLOAT) + { + switch (cif->rtype->type) + { + case FFI_TYPE_FLOAT: + return FFI_TYPE_INT; + case FFI_TYPE_DOUBLE: + return FFI_TYPE_UINT64; + default: + return cif->rtype->type; + } + } + else + { + return cif->rtype->type; + } +} + +#if defined(FFI_MIPS_N32) + +static void +copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type, + int argn, unsigned arg_offset, ffi_arg *ar, + ffi_arg *fpr, int soft_float) +{ + ffi_type **elt_typep = type->elements; + while(*elt_typep) + { + ffi_type *elt_type = *elt_typep; + unsigned o; + char *tp; + char *argp; + char *fpp; + + o = ALIGN(offset, elt_type->alignment); + arg_offset += o - offset; + offset = o; + argn += arg_offset / sizeof(ffi_arg); + arg_offset = arg_offset % sizeof(ffi_arg); + + argp = (char *)(ar + argn); + fpp = (char *)(argn >= 8 ? ar + argn : fpr + argn); + + tp = target + offset; + + if (elt_type->type == FFI_TYPE_DOUBLE && !soft_float) + *(double *)tp = *(double *)fpp; + else + memcpy(tp, argp + arg_offset, elt_type->size); + + offset += elt_type->size; + arg_offset += elt_type->size; + elt_typep++; + argn += arg_offset / sizeof(ffi_arg); + arg_offset = arg_offset % sizeof(ffi_arg); + } +} + +/* + * Decodes the arguments to a function, which will be stored on the + * stack. AR is the pointer to the beginning of the integer + * arguments. FPR is a pointer to the area where floating point + * registers have been saved. + * + * RVALUE is the location where the function return value will be + * stored. CLOSURE is the prepared closure to invoke. + * + * This function should only be called from assembly, which is in + * turn called from a trampoline. + * + * Returns the function return flags. + * + */ +int +ffi_closure_mips_inner_N32 (ffi_closure *closure, + void *rvalue, ffi_arg *ar, + ffi_arg *fpr) +{ + ffi_cif *cif; + void **avaluep; + ffi_arg *avalue; + ffi_type **arg_types; + int i, avn, argn; + int soft_float; + ffi_arg *argp; + + cif = closure->cif; + soft_float = cif->abi == FFI_N64_SOFT_FLOAT + || cif->abi == FFI_N32_SOFT_FLOAT; + avalue = alloca (cif->nargs * sizeof (ffi_arg)); + avaluep = alloca (cif->nargs * sizeof (ffi_arg)); + + argn = 0; + + if (cif->rstruct_flag) + { +#if _MIPS_SIM==_ABIN32 + rvalue = (void *)(UINT32)ar[0]; +#else /* N64 */ + rvalue = (void *)ar[0]; +#endif + argn = 1; + } + + i = 0; + avn = cif->nargs; + arg_types = cif->arg_types; + + while (i < avn) + { + if (arg_types[i]->type == FFI_TYPE_FLOAT + || arg_types[i]->type == FFI_TYPE_DOUBLE + || arg_types[i]->type == FFI_TYPE_LONGDOUBLE) + { + argp = (argn >= 8 || soft_float) ? ar + argn : fpr + argn; + if ((arg_types[i]->type == FFI_TYPE_LONGDOUBLE) && ((unsigned)argp & (arg_types[i]->alignment-1))) + { + argp=(ffi_arg*)ALIGN(argp,arg_types[i]->alignment); + argn++; + } +#if defined(__MIPSEB__) || defined(_MIPSEB) + if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8) + avaluep[i] = ((char *) argp) + sizeof (float); + else +#endif + avaluep[i] = (char *) argp; + } + else + { + unsigned type = arg_types[i]->type; + + if (arg_types[i]->alignment > sizeof(ffi_arg)) + argn = ALIGN(argn, arg_types[i]->alignment / sizeof(ffi_arg)); + + argp = ar + argn; + + /* The size of a pointer depends on the ABI */ + if (type == FFI_TYPE_POINTER) + type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT) + ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32; + + if (soft_float && type == FFI_TYPE_FLOAT) + type = FFI_TYPE_UINT32; + + switch (type) + { + case FFI_TYPE_SINT8: + avaluep[i] = &avalue[i]; + *(SINT8 *) &avalue[i] = (SINT8) *argp; + break; + + case FFI_TYPE_UINT8: + avaluep[i] = &avalue[i]; + *(UINT8 *) &avalue[i] = (UINT8) *argp; + break; + + case FFI_TYPE_SINT16: + avaluep[i] = &avalue[i]; + *(SINT16 *) &avalue[i] = (SINT16) *argp; + break; + + case FFI_TYPE_UINT16: + avaluep[i] = &avalue[i]; + *(UINT16 *) &avalue[i] = (UINT16) *argp; + break; + + case FFI_TYPE_SINT32: + avaluep[i] = &avalue[i]; + *(SINT32 *) &avalue[i] = (SINT32) *argp; + break; + + case FFI_TYPE_UINT32: + avaluep[i] = &avalue[i]; + *(UINT32 *) &avalue[i] = (UINT32) *argp; + break; + + case FFI_TYPE_STRUCT: + if (argn < 8) + { + /* Allocate space for the struct as at least part of + it was passed in registers. */ + avaluep[i] = alloca(arg_types[i]->size); + copy_struct_N32(avaluep[i], 0, cif->abi, arg_types[i], + argn, 0, ar, fpr, soft_float); + + break; + } + /* Else fall through. */ + default: + avaluep[i] = (char *) argp; + break; + } + } + argn += ALIGN(arg_types[i]->size, sizeof(ffi_arg)) / sizeof(ffi_arg); + i++; + } + + /* Invoke the closure. */ + (closure->fun) (cif, rvalue, avaluep, closure->user_data); + + return cif->flags >> (FFI_FLAG_BITS * 8); +} + +#endif /* FFI_MIPS_N32 */ + +#endif /* FFI_CLOSURES */ diff --git a/user/mpy/lib/libffi/src/mips/ffitarget.h b/user/mpy/lib/libffi/src/mips/ffitarget.h new file mode 100644 index 0000000..717d659 --- /dev/null +++ b/user/mpy/lib/libffi/src/mips/ffitarget.h @@ -0,0 +1,247 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for MIPS. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifdef linux +# include +#elif defined(__rtems__) +/* + * Subprogram calling convention - copied from sgidefs.h + */ +#define _MIPS_SIM_ABI32 1 +#define _MIPS_SIM_NABI32 2 +#define _MIPS_SIM_ABI64 3 +#elif !defined(__OpenBSD__) +# include +#endif + +# ifndef _ABIN32 +# define _ABIN32 _MIPS_SIM_NABI32 +# endif +# ifndef _ABI64 +# define _ABI64 _MIPS_SIM_ABI64 +# endif +# ifndef _ABIO32 +# define _ABIO32 _MIPS_SIM_ABI32 +# endif + +#if !defined(_MIPS_SIM) +# error -- something is very wrong -- +#else +# if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64)) +# define FFI_MIPS_N32 +# else +# if (_MIPS_SIM==_ABIO32 && defined(_ABIO32)) +# define FFI_MIPS_O32 +# else +# error -- this is an unsupported platform -- +# endif +# endif +#endif + +#ifdef FFI_MIPS_O32 +/* O32 stack frames have 32bit integer args */ +# define FFI_SIZEOF_ARG 4 +#else +/* N32 and N64 frames have 64bit integer args */ +# define FFI_SIZEOF_ARG 8 +# if _MIPS_SIM == _ABIN32 +# define FFI_SIZEOF_JAVA_RAW 4 +# endif +#endif + +#define FFI_FLAG_BITS 2 + +/* SGI's strange assembler requires that we multiply by 4 rather + than shift left by FFI_FLAG_BITS */ + +#define FFI_ARGS_D FFI_TYPE_DOUBLE +#define FFI_ARGS_F FFI_TYPE_FLOAT +#define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE +#define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT +#define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT +#define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE + +/* Needed for N32 structure returns */ +#define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8 +#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8 + +#if 0 +/* The SGI assembler can't handle this.. */ +#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT +/* (and so on) */ +#else +/* ...so we calculate these by hand! */ +#define FFI_TYPE_STRUCT_D 61 +#define FFI_TYPE_STRUCT_F 45 +#define FFI_TYPE_STRUCT_DD 253 +#define FFI_TYPE_STRUCT_FF 173 +#define FFI_TYPE_STRUCT_FD 237 +#define FFI_TYPE_STRUCT_DF 189 +#define FFI_TYPE_STRUCT_SMALL 93 +#define FFI_TYPE_STRUCT_SMALL2 109 + +/* and for n32 soft float, add 16 * 2^4 */ +#define FFI_TYPE_STRUCT_D_SOFT 317 +#define FFI_TYPE_STRUCT_F_SOFT 301 +#define FFI_TYPE_STRUCT_DD_SOFT 509 +#define FFI_TYPE_STRUCT_FF_SOFT 429 +#define FFI_TYPE_STRUCT_FD_SOFT 493 +#define FFI_TYPE_STRUCT_DF_SOFT 445 +#define FFI_TYPE_STRUCT_SOFT 16 +#endif + +#ifdef LIBFFI_ASM +#define v0 $2 +#define v1 $3 +#define a0 $4 +#define a1 $5 +#define a2 $6 +#define a3 $7 +#define a4 $8 +#define a5 $9 +#define a6 $10 +#define a7 $11 +#define t0 $8 +#define t1 $9 +#define t2 $10 +#define t3 $11 +#define t4 $12 +#define t5 $13 +#define t6 $14 +#define t7 $15 +#define t8 $24 +#define t9 $25 +#define ra $31 + +#ifdef FFI_MIPS_O32 +# define REG_L lw +# define REG_S sw +# define SUBU subu +# define ADDU addu +# define SRL srl +# define LI li +#else /* !FFI_MIPS_O32 */ +# define REG_L ld +# define REG_S sd +# define SUBU dsubu +# define ADDU daddu +# define SRL dsrl +# define LI dli +# if (_MIPS_SIM==_ABI64) +# define LA dla +# define EH_FRAME_ALIGN 3 +# define FDE_ADDR_BYTES .8byte +# else +# define LA la +# define EH_FRAME_ALIGN 2 +# define FDE_ADDR_BYTES .4byte +# endif /* _MIPS_SIM==_ABI64 */ +#endif /* !FFI_MIPS_O32 */ +#else /* !LIBFFI_ASM */ +# ifdef __GNUC__ +# ifdef FFI_MIPS_O32 +/* O32 stack frames have 32bit integer args */ +typedef unsigned int ffi_arg __attribute__((__mode__(__SI__))); +typedef signed int ffi_sarg __attribute__((__mode__(__SI__))); +#else +/* N32 and N64 frames have 64bit integer args */ +typedef unsigned int ffi_arg __attribute__((__mode__(__DI__))); +typedef signed int ffi_sarg __attribute__((__mode__(__DI__))); +# endif +# else +# ifdef FFI_MIPS_O32 +/* O32 stack frames have 32bit integer args */ +typedef __uint32_t ffi_arg; +typedef __int32_t ffi_sarg; +# else +/* N32 and N64 frames have 64bit integer args */ +typedef __uint64_t ffi_arg; +typedef __int64_t ffi_sarg; +# endif +# endif /* __GNUC__ */ + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_O32, + FFI_N32, + FFI_N64, + FFI_O32_SOFT_FLOAT, + FFI_N32_SOFT_FLOAT, + FFI_N64_SOFT_FLOAT, + FFI_LAST_ABI, + +#ifdef FFI_MIPS_O32 +#ifdef __mips_soft_float + FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT +#else + FFI_DEFAULT_ABI = FFI_O32 +#endif +#else +# if _MIPS_SIM==_ABI64 +# ifdef __mips_soft_float + FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT +# else + FFI_DEFAULT_ABI = FFI_N64 +# endif +# else +# ifdef __mips_soft_float + FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT +# else + FFI_DEFAULT_ABI = FFI_N32 +# endif +# endif +#endif +} ffi_abi; + +#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag +#endif /* !LIBFFI_ASM */ + +/* ---- Definitions for closures ----------------------------------------- */ + +#if defined(FFI_MIPS_O32) +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 20 +#else +/* N32/N64. */ +# define FFI_CLOSURES 1 +#if _MIPS_SIM==_ABI64 +#define FFI_TRAMPOLINE_SIZE 52 +#else +#define FFI_TRAMPOLINE_SIZE 20 +#endif +#endif /* FFI_MIPS_O32 */ +#define FFI_NATIVE_RAW_API 0 + +#endif + diff --git a/user/mpy/lib/libffi/src/mips/n32.S b/user/mpy/lib/libffi/src/mips/n32.S new file mode 100644 index 0000000..c6985d3 --- /dev/null +++ b/user/mpy/lib/libffi/src/mips/n32.S @@ -0,0 +1,576 @@ +/* ----------------------------------------------------------------------- + n32.S - Copyright (c) 1996, 1998, 2005, 2007, 2009, 2010 Red Hat, Inc. + + MIPS Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +/* Only build this code if we are compiling for n32 */ + +#if defined(FFI_MIPS_N32) + +#define callback a0 +#define bytes a2 +#define flags a3 +#define raddr a4 +#define fn a5 + +#define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG ) + +#ifdef __GNUC__ + .abicalls +#endif + .set mips4 + .text + .align 2 + .globl ffi_call_N32 + .ent ffi_call_N32 +ffi_call_N32: +.LFB3: + .frame $fp, SIZEOF_FRAME, ra + .mask 0xc0000000,-FFI_SIZEOF_ARG + .fmask 0x00000000,0 + + # Prologue + SUBU $sp, SIZEOF_FRAME # Frame size +.LCFI0: + REG_S $fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp) # Save frame pointer + REG_S ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp) # Save return address +.LCFI1: + move $fp, $sp +.LCFI3: + move t9, callback # callback function pointer + REG_S bytes, 2*FFI_SIZEOF_ARG($fp) # bytes + REG_S flags, 3*FFI_SIZEOF_ARG($fp) # flags + REG_S raddr, 4*FFI_SIZEOF_ARG($fp) # raddr + REG_S fn, 5*FFI_SIZEOF_ARG($fp) # fn + + # Allocate at least 4 words in the argstack + move v0, bytes + bge bytes, 4 * FFI_SIZEOF_ARG, bigger + LI v0, 4 * FFI_SIZEOF_ARG + b sixteen + + bigger: + ADDU t4, v0, 2 * FFI_SIZEOF_ARG -1 # make sure it is aligned + and v0, t4, -2 * FFI_SIZEOF_ARG # to a proper boundry. + +sixteen: + SUBU $sp, $sp, v0 # move the stack pointer to reflect the + # arg space + + move a0, $sp # 4 * FFI_SIZEOF_ARG + ADDU a3, $fp, 3 * FFI_SIZEOF_ARG + + # Call ffi_prep_args + jal t9 + + # Copy the stack pointer to t9 + move t9, $sp + + # Fix the stack if there are more than 8 64bit slots worth + # of arguments. + + # Load the number of bytes + REG_L t6, 2*FFI_SIZEOF_ARG($fp) + + # Is it bigger than 8 * FFI_SIZEOF_ARG? + daddiu t8, t6, -(8 * FFI_SIZEOF_ARG) + bltz t8, loadregs + + ADDU t9, t9, t8 + +loadregs: + + REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6. + + and t4, t6, ((1< +#include + +/* Only build this code if we are compiling for o32 */ + +#if defined(FFI_MIPS_O32) + +#define callback a0 +#define bytes a2 +#define flags a3 + +#define SIZEOF_FRAME (4 * FFI_SIZEOF_ARG + 2 * FFI_SIZEOF_ARG) +#define A3_OFF (SIZEOF_FRAME + 3 * FFI_SIZEOF_ARG) +#define FP_OFF (SIZEOF_FRAME - 2 * FFI_SIZEOF_ARG) +#define RA_OFF (SIZEOF_FRAME - 1 * FFI_SIZEOF_ARG) + + .abicalls + .text + .align 2 + .globl ffi_call_O32 + .ent ffi_call_O32 +ffi_call_O32: +$LFB0: + # Prologue + SUBU $sp, SIZEOF_FRAME # Frame size +$LCFI0: + REG_S $fp, FP_OFF($sp) # Save frame pointer +$LCFI1: + REG_S ra, RA_OFF($sp) # Save return address +$LCFI2: + move $fp, $sp + +$LCFI3: + move t9, callback # callback function pointer + REG_S flags, A3_OFF($fp) # flags + + # Allocate at least 4 words in the argstack + LI v0, 4 * FFI_SIZEOF_ARG + blt bytes, v0, sixteen + + ADDU v0, bytes, 7 # make sure it is aligned + and v0, -8 # to an 8 byte boundry + +sixteen: + SUBU $sp, v0 # move the stack pointer to reflect the + # arg space + + ADDU a0, $sp, 4 * FFI_SIZEOF_ARG + + jalr t9 + + REG_L t0, A3_OFF($fp) # load the flags word + SRL t2, t0, 4 # shift our arg info + and t0, ((1<<4)-1) # mask out the return type + + ADDU $sp, 4 * FFI_SIZEOF_ARG # adjust $sp to new args + + bnez t0, pass_d # make it quick for int + REG_L a0, 0*FFI_SIZEOF_ARG($sp) # just go ahead and load the + REG_L a1, 1*FFI_SIZEOF_ARG($sp) # four regs. + REG_L a2, 2*FFI_SIZEOF_ARG($sp) + REG_L a3, 3*FFI_SIZEOF_ARG($sp) + b call_it + +pass_d: + bne t0, FFI_ARGS_D, pass_f + l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args + REG_L a2, 2*FFI_SIZEOF_ARG($sp) # passing a double + REG_L a3, 3*FFI_SIZEOF_ARG($sp) + b call_it + +pass_f: + bne t0, FFI_ARGS_F, pass_d_d + l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args + REG_L a1, 1*FFI_SIZEOF_ARG($sp) # passing a float + REG_L a2, 2*FFI_SIZEOF_ARG($sp) + REG_L a3, 3*FFI_SIZEOF_ARG($sp) + b call_it + +pass_d_d: + bne t0, FFI_ARGS_DD, pass_f_f + l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args + l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing two doubles + b call_it + +pass_f_f: + bne t0, FFI_ARGS_FF, pass_d_f + l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args + l.s $f14, 1*FFI_SIZEOF_ARG($sp) # passing two floats + REG_L a2, 2*FFI_SIZEOF_ARG($sp) + REG_L a3, 3*FFI_SIZEOF_ARG($sp) + b call_it + +pass_d_f: + bne t0, FFI_ARGS_DF, pass_f_d + l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args + l.s $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float + REG_L a3, 3*FFI_SIZEOF_ARG($sp) + b call_it + +pass_f_d: + # assume that the only other combination must be float then double + # bne t0, FFI_ARGS_F_D, call_it + l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args + l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float + +call_it: + # Load the function pointer + REG_L t9, SIZEOF_FRAME + 5*FFI_SIZEOF_ARG($fp) + + # If the return value pointer is NULL, assume no return value. + REG_L t1, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) + beqz t1, noretval + + bne t2, FFI_TYPE_INT, retlonglong + jalr t9 + REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) + REG_S v0, 0(t0) + b epilogue + +retlonglong: + # Really any 64-bit int, signed or not. + bne t2, FFI_TYPE_UINT64, retfloat + jalr t9 + REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) + REG_S v1, 4(t0) + REG_S v0, 0(t0) + b epilogue + +retfloat: + bne t2, FFI_TYPE_FLOAT, retdouble + jalr t9 + REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) + s.s $f0, 0(t0) + b epilogue + +retdouble: + bne t2, FFI_TYPE_DOUBLE, noretval + jalr t9 + REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) + s.d $f0, 0(t0) + b epilogue + +noretval: + jalr t9 + + # Epilogue +epilogue: + move $sp, $fp + REG_L $fp, FP_OFF($sp) # Restore frame pointer + REG_L ra, RA_OFF($sp) # Restore return address + ADDU $sp, SIZEOF_FRAME # Fix stack pointer + j ra + +$LFE0: + .end ffi_call_O32 + + +/* ffi_closure_O32. Expects address of the passed-in ffi_closure + in t4 ($12). Stores any arguments passed in registers onto the + stack, then calls ffi_closure_mips_inner_O32, which + then decodes them. + + Stack layout: + + 3 - a3 save + 2 - a2 save + 1 - a1 save + 0 - a0 save, original sp + -1 - ra save + -2 - fp save + -3 - $16 (s0) save + -4 - cprestore + -5 - return value high (v1) + -6 - return value low (v0) + -7 - f14 (le high, be low) + -8 - f14 (le low, be high) + -9 - f12 (le high, be low) + -10 - f12 (le low, be high) + -11 - Called function a3 save + -12 - Called function a2 save + -13 - Called function a1 save + -14 - Called function a0 save, our sp and fp point here + */ + +#define SIZEOF_FRAME2 (14 * FFI_SIZEOF_ARG) +#define A3_OFF2 (SIZEOF_FRAME2 + 3 * FFI_SIZEOF_ARG) +#define A2_OFF2 (SIZEOF_FRAME2 + 2 * FFI_SIZEOF_ARG) +#define A1_OFF2 (SIZEOF_FRAME2 + 1 * FFI_SIZEOF_ARG) +#define A0_OFF2 (SIZEOF_FRAME2 + 0 * FFI_SIZEOF_ARG) +#define RA_OFF2 (SIZEOF_FRAME2 - 1 * FFI_SIZEOF_ARG) +#define FP_OFF2 (SIZEOF_FRAME2 - 2 * FFI_SIZEOF_ARG) +#define S0_OFF2 (SIZEOF_FRAME2 - 3 * FFI_SIZEOF_ARG) +#define GP_OFF2 (SIZEOF_FRAME2 - 4 * FFI_SIZEOF_ARG) +#define V1_OFF2 (SIZEOF_FRAME2 - 5 * FFI_SIZEOF_ARG) +#define V0_OFF2 (SIZEOF_FRAME2 - 6 * FFI_SIZEOF_ARG) +#define FA_1_1_OFF2 (SIZEOF_FRAME2 - 7 * FFI_SIZEOF_ARG) +#define FA_1_0_OFF2 (SIZEOF_FRAME2 - 8 * FFI_SIZEOF_ARG) +#define FA_0_1_OFF2 (SIZEOF_FRAME2 - 9 * FFI_SIZEOF_ARG) +#define FA_0_0_OFF2 (SIZEOF_FRAME2 - 10 * FFI_SIZEOF_ARG) + + .text + .align 2 + .globl ffi_closure_O32 + .ent ffi_closure_O32 +ffi_closure_O32: +$LFB1: + # Prologue + .frame $fp, SIZEOF_FRAME2, ra + .set noreorder + .cpload t9 + .set reorder + SUBU $sp, SIZEOF_FRAME2 + .cprestore GP_OFF2 +$LCFI4: + REG_S $16, S0_OFF2($sp) # Save s0 + REG_S $fp, FP_OFF2($sp) # Save frame pointer + REG_S ra, RA_OFF2($sp) # Save return address +$LCFI6: + move $fp, $sp + +$LCFI7: + # Store all possible argument registers. If there are more than + # four arguments, then they are stored above where we put a3. + REG_S a0, A0_OFF2($fp) + REG_S a1, A1_OFF2($fp) + REG_S a2, A2_OFF2($fp) + REG_S a3, A3_OFF2($fp) + + # Load ABI enum to s0 + REG_L $16, 20($12) # cif pointer follows tramp. + REG_L $16, 0($16) # abi is first member. + + li $13, 1 # FFI_O32 + bne $16, $13, 1f # Skip fp save if FFI_O32_SOFT_FLOAT + + # Store all possible float/double registers. + s.d $f12, FA_0_0_OFF2($fp) + s.d $f14, FA_1_0_OFF2($fp) +1: + # Call ffi_closure_mips_inner_O32 to do the work. + la t9, ffi_closure_mips_inner_O32 + move a0, $12 # Pointer to the ffi_closure + addu a1, $fp, V0_OFF2 + addu a2, $fp, A0_OFF2 + addu a3, $fp, FA_0_0_OFF2 + jalr t9 + + # Load the return value into the appropriate register. + move $8, $2 + li $9, FFI_TYPE_VOID + beq $8, $9, closure_done + + li $13, 1 # FFI_O32 + bne $16, $13, 1f # Skip fp restore if FFI_O32_SOFT_FLOAT + + li $9, FFI_TYPE_FLOAT + l.s $f0, V0_OFF2($fp) + beq $8, $9, closure_done + + li $9, FFI_TYPE_DOUBLE + l.d $f0, V0_OFF2($fp) + beq $8, $9, closure_done +1: + REG_L $3, V1_OFF2($fp) + REG_L $2, V0_OFF2($fp) + +closure_done: + # Epilogue + move $sp, $fp + REG_L $16, S0_OFF2($sp) # Restore s0 + REG_L $fp, FP_OFF2($sp) # Restore frame pointer + REG_L ra, RA_OFF2($sp) # Restore return address + ADDU $sp, SIZEOF_FRAME2 + j ra +$LFE1: + .end ffi_closure_O32 + +/* DWARF-2 unwind info. */ + + .section .eh_frame,"a",@progbits +$Lframe0: + .4byte $LECIE0-$LSCIE0 # Length of Common Information Entry +$LSCIE0: + .4byte 0x0 # CIE Identifier Tag + .byte 0x1 # CIE Version + .ascii "zR\0" # CIE Augmentation + .uleb128 0x1 # CIE Code Alignment Factor + .sleb128 4 # CIE Data Alignment Factor + .byte 0x1f # CIE RA Column + .uleb128 0x1 # Augmentation size + .byte 0x00 # FDE Encoding (absptr) + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x1d + .uleb128 0x0 + .align 2 +$LECIE0: +$LSFDE0: + .4byte $LEFDE0-$LASFDE0 # FDE Length +$LASFDE0: + .4byte $LASFDE0-$Lframe0 # FDE CIE offset + .4byte $LFB0 # FDE initial location + .4byte $LFE0-$LFB0 # FDE address range + .uleb128 0x0 # Augmentation size + .byte 0x4 # DW_CFA_advance_loc4 + .4byte $LCFI0-$LFB0 + .byte 0xe # DW_CFA_def_cfa_offset + .uleb128 0x18 + .byte 0x4 # DW_CFA_advance_loc4 + .4byte $LCFI2-$LCFI0 + .byte 0x11 # DW_CFA_offset_extended_sf + .uleb128 0x1e # $fp + .sleb128 -2 # SIZEOF_FRAME2 - 2*FFI_SIZEOF_ARG($sp) + .byte 0x11 # DW_CFA_offset_extended_sf + .uleb128 0x1f # $ra + .sleb128 -1 # SIZEOF_FRAME2 - 1*FFI_SIZEOF_ARG($sp) + .byte 0x4 # DW_CFA_advance_loc4 + .4byte $LCFI3-$LCFI2 + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x1e + .uleb128 0x18 + .align 2 +$LEFDE0: +$LSFDE1: + .4byte $LEFDE1-$LASFDE1 # FDE Length +$LASFDE1: + .4byte $LASFDE1-$Lframe0 # FDE CIE offset + .4byte $LFB1 # FDE initial location + .4byte $LFE1-$LFB1 # FDE address range + .uleb128 0x0 # Augmentation size + .byte 0x4 # DW_CFA_advance_loc4 + .4byte $LCFI4-$LFB1 + .byte 0xe # DW_CFA_def_cfa_offset + .uleb128 0x38 + .byte 0x4 # DW_CFA_advance_loc4 + .4byte $LCFI6-$LCFI4 + .byte 0x11 # DW_CFA_offset_extended_sf + .uleb128 0x10 # $16 + .sleb128 -3 # SIZEOF_FRAME2 - 3*FFI_SIZEOF_ARG($sp) + .byte 0x11 # DW_CFA_offset_extended_sf + .uleb128 0x1e # $fp + .sleb128 -2 # SIZEOF_FRAME2 - 2*FFI_SIZEOF_ARG($sp) + .byte 0x11 # DW_CFA_offset_extended_sf + .uleb128 0x1f # $ra + .sleb128 -1 # SIZEOF_FRAME2 - 1*FFI_SIZEOF_ARG($sp) + .byte 0x4 # DW_CFA_advance_loc4 + .4byte $LCFI7-$LCFI6 + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x1e + .uleb128 0x38 + .align 2 +$LEFDE1: + +#endif diff --git a/user/mpy/lib/libffi/src/moxie/eabi.S b/user/mpy/lib/libffi/src/moxie/eabi.S new file mode 100644 index 0000000..ac7aceb --- /dev/null +++ b/user/mpy/lib/libffi/src/moxie/eabi.S @@ -0,0 +1,101 @@ +/* ----------------------------------------------------------------------- + eabi.S - Copyright (c) 2012, 2013 Anthony Green + + Moxie Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + .globl ffi_prep_args_EABI + + .text + .p2align 4 + .globl ffi_call_EABI + .type ffi_call_EABI, @function + + # $r0 : ffi_prep_args + # $r1 : &ecif + # $r2 : cif->bytes + # $r3 : fig->flags + # $r4 : ecif.rvalue + # $r5 : fn + +ffi_call_EABI: + push $sp, $r6 + push $sp, $r7 + push $sp, $r8 + dec $sp, 24 + + /* Store incoming args on stack. */ + sto.l 0($sp), $r0 /* ffi_prep_args */ + sto.l 4($sp), $r1 /* ecif */ + sto.l 8($sp), $r2 /* bytes */ + sto.l 12($sp), $r3 /* flags */ + sto.l 16($sp), $r4 /* &rvalue */ + sto.l 20($sp), $r5 /* fn */ + + /* Call ffi_prep_args. */ + mov $r6, $r4 /* Save result buffer */ + mov $r7, $r5 /* Save the target fn */ + mov $r8, $r3 /* Save the flags */ + sub.l $sp, $r2 /* Allocate stack space */ + mov $r0, $sp /* We can stomp over $r0 */ + /* $r1 is already set up */ + jsra ffi_prep_args + + /* Load register arguments. */ + ldo.l $r0, 0($sp) + ldo.l $r1, 4($sp) + ldo.l $r2, 8($sp) + ldo.l $r3, 12($sp) + ldo.l $r4, 16($sp) + ldo.l $r5, 20($sp) + + /* Call the target function. */ + jsr $r7 + + ldi.l $r7, 0xffffffff + cmp $r8, $r7 + beq retstruct + + ldi.l $r7, 4 + cmp $r8, $r7 + bgt ret2reg + + st.l ($r6), $r0 + jmpa retdone + +ret2reg: + st.l ($r6), $r0 + sto.l 4($r6), $r1 + +retstruct: +retdone: + /* Return. */ + ldo.l $r6, -4($fp) + ldo.l $r7, -8($fp) + ldo.l $r8, -12($fp) + ret + .size ffi_call_EABI, .-ffi_call_EABI + diff --git a/user/mpy/lib/libffi/src/moxie/ffi.c b/user/mpy/lib/libffi/src/moxie/ffi.c new file mode 100644 index 0000000..540a042 --- /dev/null +++ b/user/mpy/lib/libffi/src/moxie/ffi.c @@ -0,0 +1,272 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (C) 2012, 2013 Anthony Green + + Moxie Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +void *ffi_prep_args(char *stack, extended_cif *ecif) +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + register int count = 0; + + p_argv = ecif->avalue; + argp = stack; + + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) + { + *(void **) argp = ecif->rvalue; + argp += 4; + } + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); + i--, p_arg++) + { + size_t z; + + z = (*p_arg)->size; + + if ((*p_arg)->type == FFI_TYPE_STRUCT) + { + z = sizeof(void*); + *(void **) argp = *p_argv; + } + else if (z < sizeof(int)) + { + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + default: + FFI_ASSERT(0); + } + } + else if (z == sizeof(int)) + { + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + } + else + { + memcpy(argp, *p_argv, z); + } + p_argv++; + argp += z; + count += z; + } + + return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8))); +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + if (cif->rtype->type == FFI_TYPE_STRUCT) + cif->flags = -1; + else + cif->flags = cif->rtype->size; + + cif->bytes = ALIGN (cif->bytes, 8); + + return FFI_OK; +} + +extern void ffi_call_EABI(void *(*)(char *, extended_cif *), + extended_cif *, + unsigned, unsigned, + unsigned *, + void (*fn)(void)); + +void ffi_call(ffi_cif *cif, + void (*fn)(void), + void *rvalue, + void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca(cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_EABI: + ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + break; + default: + FFI_ASSERT(0); + break; + } +} + +void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, + unsigned arg4, unsigned arg5, unsigned arg6) +{ + /* This function is called by a trampoline. The trampoline stows a + pointer to the ffi_closure object in $r7. We must save this + pointer in a place that will persist while we do our work. */ + register ffi_closure *creg __asm__ ("$r12"); + ffi_closure *closure = creg; + + /* Arguments that don't fit in registers are found on the stack + at a fixed offset above the current frame pointer. */ + register char *frame_pointer __asm__ ("$fp"); + + /* Pointer to a struct return value. */ + void *struct_rvalue = (void *) arg1; + + /* 6 words reserved for register args + 3 words from jsr */ + char *stack_args = frame_pointer + 9*4; + + /* Lay the register arguments down in a continuous chunk of memory. */ + unsigned register_args[6] = + { arg1, arg2, arg3, arg4, arg5, arg6 }; + char *register_args_ptr = (char *) register_args; + + ffi_cif *cif = closure->cif; + ffi_type **arg_types = cif->arg_types; + void **avalue = alloca (cif->nargs * sizeof(void *)); + char *ptr = (char *) register_args; + int i; + + /* preserve struct type return pointer passing */ + if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { + ptr += 4; + register_args_ptr = (char *)®ister_args[1]; + } + + /* Find the address of each argument. */ + for (i = 0; i < cif->nargs; i++) + { + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + avalue[i] = ptr + 3; + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + avalue[i] = ptr + 2; + break; + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + case FFI_TYPE_POINTER: + avalue[i] = ptr; + break; + case FFI_TYPE_STRUCT: + avalue[i] = *(void**)ptr; + break; + default: + /* This is an 8-byte value. */ + avalue[i] = ptr; + ptr += 4; + break; + } + ptr += 4; + + /* If we've handled more arguments than fit in registers, + start looking at the those passed on the stack. */ + if (ptr == ®ister_args[6]) + ptr = stack_args; + } + + /* Invoke the closure. */ + if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + (closure->fun) (cif, struct_rvalue, avalue, closure->user_data); + } + else + { + /* Allocate space for the return value and call the function. */ + long long rvalue; + (closure->fun) (cif, &rvalue, avalue, closure->user_data); + asm ("mov $r12, %0\n ld.l $r0, ($r12)\n ldo.l $r1, 4($r12)" : : "r" (&rvalue)); + } +} + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned short *tramp = (unsigned short *) &closure->tramp[0]; + unsigned long fn = (long) ffi_closure_eabi; + unsigned long cls = (long) codeloc; + + if (cif->abi != FFI_EABI) + return FFI_BAD_ABI; + + fn = (unsigned long) ffi_closure_eabi; + + tramp[0] = 0x01e0; /* ldi.l $r7, .... */ + tramp[1] = cls >> 16; + tramp[2] = cls & 0xffff; + tramp[3] = 0x1a00; /* jmpa .... */ + tramp[4] = fn >> 16; + tramp[5] = fn & 0xffff; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/moxie/ffitarget.h b/user/mpy/lib/libffi/src/moxie/ffitarget.h new file mode 100644 index 0000000..623e3ec --- /dev/null +++ b/user/mpy/lib/libffi/src/moxie/ffitarget.h @@ -0,0 +1,52 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012, 2013 Anthony Green + Target configuration macros for Moxie + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +/* ---- System specific configurations ----------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_EABI, + FFI_DEFAULT_ABI = FFI_EABI, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 + +/* Trampolines are 12-bytes long. See ffi_prep_closure_loc. */ +#define FFI_TRAMPOLINE_SIZE (12) + +#endif diff --git a/user/mpy/lib/libffi/src/nios2/ffi.c b/user/mpy/lib/libffi/src/nios2/ffi.c new file mode 100644 index 0000000..2efa033 --- /dev/null +++ b/user/mpy/lib/libffi/src/nios2/ffi.c @@ -0,0 +1,304 @@ +/* libffi support for Altera Nios II. + + Copyright (c) 2013 Mentor Graphics. + + 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. */ + + +#include +#include + +#include + +/* The Nios II Processor Reference Handbook defines the procedure call + ABI as follows. + + Arguments are passed as if a structure containing the types of + the arguments were constructed. The first 16 bytes are passed in r4 + through r7, the remainder on the stack. The first 16 bytes of a function + taking variable arguments are passed in r4-r7 in the same way. + + Return values of types up to 8 bytes are returned in r2 and r3. For + return values greater than 8 bytes, the caller must allocate memory for + the result and pass the address as if it were argument 0. + + While this isn't specified explicitly in the ABI documentation, GCC + promotes integral arguments smaller than int size to 32 bits. + + Also of note, the ABI specifies that all structure objects are + aligned to 32 bits even if all their fields have a smaller natural + alignment. See FFI_AGGREGATE_ALIGNMENT. */ + + +/* Declare the assembly language hooks. */ + +extern UINT64 ffi_call_sysv (void (*) (char *, extended_cif *), + extended_cif *, + unsigned, + void (*fn) (void)); +extern void ffi_closure_sysv (void); + +/* Perform machine-dependent cif processing. */ + +ffi_status ffi_prep_cif_machdep (ffi_cif *cif) +{ + /* We always want at least 16 bytes in the parameter block since it + simplifies the low-level call function. Also round the parameter + block size up to a multiple of 4 bytes to preserve + 32-bit alignment of the stack pointer. */ + if (cif->bytes < 16) + cif->bytes = 16; + else + cif->bytes = (cif->bytes + 3) & ~3; + + return FFI_OK; +} + + +/* ffi_prep_args is called by the assembly routine to transfer arguments + to the stack using the pointers in the ecif array. + Note that the stack buffer is big enough to fit all the arguments, + but the first 16 bytes will be copied to registers for the actual + call. */ + +void ffi_prep_args (char *stack, extended_cif *ecif) +{ + char *argp = stack; + unsigned int i; + + /* The implicit return value pointer is passed as if it were a hidden + first argument. */ + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT + && ecif->cif->rtype->size > 8) + { + (*(void **) argp) = ecif->rvalue; + argp += 4; + } + + for (i = 0; i < ecif->cif->nargs; i++) + { + void *avalue = ecif->avalue[i]; + ffi_type *atype = ecif->cif->arg_types[i]; + size_t size = atype->size; + size_t alignment = atype->alignment; + + /* Align argp as appropriate for the argument type. */ + if ((alignment - 1) & (unsigned) argp) + argp = (char *) ALIGN (argp, alignment); + + /* Copy the argument, promoting integral types smaller than a + word to word size. */ + if (size < sizeof (int)) + { + size = sizeof (int); + switch (atype->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) avalue; + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int) *(UINT8 *) avalue; + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) avalue; + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int) *(UINT16 *) avalue; + break; + + case FFI_TYPE_STRUCT: + memcpy (argp, avalue, atype->size); + break; + + default: + FFI_ASSERT(0); + } + } + else if (size == sizeof (int)) + *(unsigned int *) argp = (unsigned int) *(UINT32 *) avalue; + else + memcpy (argp, avalue, size); + argp += size; + } +} + + +/* Call FN using the prepared CIF. RVALUE points to space allocated by + the caller for the return value, and AVALUE is an array of argument + pointers. */ + +void ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) +{ + + extended_cif ecif; + UINT64 result; + + /* If bigret is true, this is the case where a return value of larger + than 8 bytes is handled by being passed by reference as an implicit + argument. */ + int bigret = (cif->rtype->type == FFI_TYPE_STRUCT + && cif->rtype->size > 8); + + ecif.cif = cif; + ecif.avalue = avalue; + + /* Allocate space for return value if this is the pass-by-reference case + and the caller did not provide a buffer. */ + if (rvalue == NULL && bigret) + ecif.rvalue = alloca (cif->rtype->size); + else + ecif.rvalue = rvalue; + + result = ffi_call_sysv (ffi_prep_args, &ecif, cif->bytes, fn); + + /* Now result contains the 64 bit contents returned from fn in + r2 and r3. Copy the value of the appropriate size to the user-provided + rvalue buffer. */ + if (rvalue && !bigret) + switch (cif->rtype->size) + { + case 1: + *(UINT8 *)rvalue = (UINT8) result; + break; + case 2: + *(UINT16 *)rvalue = (UINT16) result; + break; + case 4: + *(UINT32 *)rvalue = (UINT32) result; + break; + case 8: + *(UINT64 *)rvalue = (UINT64) result; + break; + default: + memcpy (rvalue, (void *)&result, cif->rtype->size); + break; + } +} + +/* This function is invoked from the closure trampoline to invoke + CLOSURE with argument block ARGS. Parse ARGS according to + CLOSURE->cfi and invoke CLOSURE->fun. */ + +static UINT64 +ffi_closure_helper (unsigned char *args, + ffi_closure *closure) +{ + ffi_cif *cif = closure->cif; + unsigned char *argp = args; + void **parsed_args = alloca (cif->nargs * sizeof (void *)); + UINT64 result; + void *retptr; + unsigned int i; + + /* First figure out what to do about the return type. If this is the + big-structure-return case, the first arg is the hidden return buffer + allocated by the caller. */ + if (cif->rtype->type == FFI_TYPE_STRUCT + && cif->rtype->size > 8) + { + retptr = *((void **) argp); + argp += 4; + } + else + retptr = (void *) &result; + + /* Fill in the array of argument pointers. */ + for (i = 0; i < cif->nargs; i++) + { + size_t size = cif->arg_types[i]->size; + size_t alignment = cif->arg_types[i]->alignment; + + /* Align argp as appropriate for the argument type. */ + if ((alignment - 1) & (unsigned) argp) + argp = (char *) ALIGN (argp, alignment); + + /* Arguments smaller than an int are promoted to int. */ + if (size < sizeof (int)) + size = sizeof (int); + + /* Store the pointer. */ + parsed_args[i] = argp; + argp += size; + } + + /* Call the user-supplied function. */ + (closure->fun) (cif, retptr, parsed_args, closure->user_data); + return result; +} + + +/* Initialize CLOSURE with a trampoline to call FUN with + CIF and USER_DATA. */ +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun) (ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; + int i; + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + /* The trampoline looks like: + movhi r8, %hi(ffi_closure_sysv) + ori r8, r8, %lo(ffi_closure_sysv) + movhi r9, %hi(ffi_closure_helper) + ori r0, r9, %lo(ffi_closure_helper) + movhi r10, %hi(closure) + ori r10, r10, %lo(closure) + jmp r8 + and then ffi_closure_sysv retrieves the closure pointer out of r10 + in addition to the arguments passed in the normal way for the call, + and invokes ffi_closure_helper. We encode the pointer to + ffi_closure_helper in the trampoline because making a PIC call + to it in ffi_closure_sysv would be messy (it would have to indirect + through the GOT). */ + +#define HI(x) ((((unsigned int) (x)) >> 16) & 0xffff) +#define LO(x) (((unsigned int) (x)) & 0xffff) + tramp[0] = (0 << 27) | (8 << 22) | (HI (ffi_closure_sysv) << 6) | 0x34; + tramp[1] = (8 << 27) | (8 << 22) | (LO (ffi_closure_sysv) << 6) | 0x14; + tramp[2] = (0 << 27) | (9 << 22) | (HI (ffi_closure_helper) << 6) | 0x34; + tramp[3] = (9 << 27) | (9 << 22) | (LO (ffi_closure_helper) << 6) | 0x14; + tramp[4] = (0 << 27) | (10 << 22) | (HI (closure) << 6) | 0x34; + tramp[5] = (10 << 27) | (10 << 22) | (LO (closure) << 6) | 0x14; + tramp[6] = (8 << 27) | (0x0d << 11) | 0x3a; +#undef HI +#undef LO + + /* Flush the caches. + See Example 9-4 in the Nios II Software Developer's Handbook. */ + for (i = 0; i < 7; i++) + asm volatile ("flushd 0(%0); flushi %0" :: "r"(tramp + i) : "memory"); + asm volatile ("flushp" ::: "memory"); + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + diff --git a/user/mpy/lib/libffi/src/nios2/ffitarget.h b/user/mpy/lib/libffi/src/nios2/ffitarget.h new file mode 100644 index 0000000..134d118 --- /dev/null +++ b/user/mpy/lib/libffi/src/nios2/ffitarget.h @@ -0,0 +1,52 @@ +/* libffi target includes for Altera Nios II. + + Copyright (c) 2013 Mentor Graphics. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +/* Structures have a 4-byte alignment even if all the fields have lesser + alignment requirements. */ +#define FFI_AGGREGATE_ALIGNMENT 4 + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 28 /* 7 instructions */ +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/nios2/sysv.S b/user/mpy/lib/libffi/src/nios2/sysv.S new file mode 100644 index 0000000..75f442b --- /dev/null +++ b/user/mpy/lib/libffi/src/nios2/sysv.S @@ -0,0 +1,136 @@ +/* Low-level libffi support for Altera Nios II. + + Copyright (c) 2013 Mentor Graphics. + + 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. */ + +/* This function is declared on the C side as + + extern UINT64 ffi_call_sysv (void (*arghook) (char *, extended_cif *), + extended_cif *ecif, + unsigned nbytes, + void (*fn) (void)); + + On input, the arguments appear as + r4 = arghook + r5 = ecif + r6 = nbytes + r7 = fn +*/ + + .section .text + .align 2 + .global ffi_call_sysv + .type ffi_call_sysv, @function + +ffi_call_sysv: + .cfi_startproc + + /* Create the stack frame, saving r16 so we can use it locally. */ + addi sp, sp, -12 + .cfi_def_cfa_offset 12 + stw ra, 8(sp) + stw fp, 4(sp) + stw r16, 0(sp) + .cfi_offset 31, -4 + .cfi_offset 28, -8 + .cfi_offset 16, -12 + mov fp, sp + .cfi_def_cfa_register 28 + mov r16, r7 + + /* Adjust the stack pointer to create the argument buffer + nbytes long. */ + sub sp, sp, r6 + + /* Call the arghook function. */ + mov r2, r4 /* fn */ + mov r4, sp /* argbuffer */ + callr r2 /* r5 already contains ecif */ + + /* Pop off the first 16 bytes of the argument buffer on the stack, + transferring the contents to the argument registers. */ + ldw r4, 0(sp) + ldw r5, 4(sp) + ldw r6, 8(sp) + ldw r7, 12(sp) + addi sp, sp, 16 + + /* Call the user function, which leaves its result in r2 and r3. */ + callr r16 + + /* Pop off the stack frame. */ + mov sp, fp + ldw ra, 8(sp) + ldw fp, 4(sp) + ldw r16, 0(sp) + addi sp, sp, 12 + ret + .cfi_endproc + .size ffi_call_sysv, .-ffi_call_sysv + + +/* Closure trampolines jump here after putting the C helper address + in r9 and the closure pointer in r10. The user-supplied arguments + to the closure are in the normal places, in r4-r7 and on the + stack. Push the register arguments on the stack too and then call the + C helper function to deal with them. */ + + .section .text + .align 2 + .global ffi_closure_sysv + .type ffi_closure_sysv, @function + +ffi_closure_sysv: + .cfi_startproc + + /* Create the stack frame, pushing the register args on the stack + just below the stack args. This is the same trick illustrated + in Figure 7-3 in the Nios II Processor Reference Handbook, used + for variable arguments and structures passed by value. */ + addi sp, sp, -20 + .cfi_def_cfa_offset 20 + stw ra, 0(sp) + .cfi_offset 31, -20 + stw r4, 4(sp) + .cfi_offset 4, -16 + stw r5, 8(sp) + .cfi_offset 5, -12 + stw r6, 12(sp) + .cfi_offset 6, -8 + stw r7, 16(sp) + .cfi_offset 7, -4 + + /* Call the helper. + r4 = pointer to arguments on stack + r5 = closure pointer (loaded in r10 by the trampoline) + r9 = address of helper function (loaded by trampoline) */ + addi r4, sp, 4 + mov r5, r10 + callr r9 + + /* Pop the stack and return. */ + ldw ra, 0(sp) + addi sp, sp, 20 + .cfi_def_cfa_offset -20 + ret + .cfi_endproc + .size ffi_closure_sysv, .-ffi_closure_sysv + diff --git a/user/mpy/lib/libffi/src/or1k/ffi.c b/user/mpy/lib/libffi/src/or1k/ffi.c new file mode 100644 index 0000000..2bad938 --- /dev/null +++ b/user/mpy/lib/libffi/src/or1k/ffi.c @@ -0,0 +1,328 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2014 Sebastian Macke + + OpenRISC Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include "ffi_common.h" + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +void* ffi_prep_args(char *stack, extended_cif *ecif) +{ + char *stacktemp = stack; + int i, s; + ffi_type **arg; + int count = 0; + int nfixedargs; + + nfixedargs = ecif->cif->nfixedargs; + arg = ecif->cif->arg_types; + void **argv = ecif->avalue; + + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) + { + *(void **) stack = ecif->rvalue; + stack += 4; + count = 4; + } + for(i=0; icif->nargs; i++) + { + + /* variadic args are saved on stack */ + if ((nfixedargs == 0) && (count < 24)) + { + count = 24; + stack = stacktemp + 24; + } + nfixedargs--; + + s = 4; + switch((*arg)->type) + { + case FFI_TYPE_STRUCT: + *(void **)stack = *argv; + break; + + case FFI_TYPE_SINT8: + *(signed int *) stack = (signed int)*(SINT8 *)(* argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) stack = (unsigned int)*(UINT8 *)(* argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) stack = (signed int)*(SINT16 *)(* argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) stack = (unsigned int)*(UINT16 *)(* argv); + break; + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + case FFI_TYPE_POINTER: + *(int *)stack = *(int*)(*argv); + break; + + default: /* 8 byte types */ + if (count == 20) /* never split arguments */ + { + stack += 4; + count += 4; + } + s = (*arg)->size; + memcpy(stack, *argv, s); + break; + } + + stack += s; + count += s; + argv++; + arg++; + } + return stacktemp + ((count>24)?24:0); +} + +extern void ffi_call_SYSV(unsigned, + extended_cif *, + void *(*)(int *, extended_cif *), + unsigned *, + void (*fn)(void), + unsigned); + + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + int i; + int size; + ffi_type **arg; + + /* Calculate size to allocate on stack */ + + for(i = 0, arg = cif->arg_types, size=0; i < cif->nargs; i++, arg++) + { + if ((*arg)->type == FFI_TYPE_STRUCT) + size += 4; + else + if ((*arg)->size <= 4) + size += 4; + else + size += 8; + } + + /* for variadic functions more space is needed on the stack */ + if (cif->nargs != cif->nfixedargs) + size += 24; + + if (cif->rtype->type == FFI_TYPE_STRUCT) + size += 4; + + + extended_cif ecif; + ecif.cif = cif; + ecif.avalue = avalue; + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV(size, &ecif, ffi_prep_args, rvalue, fn, cif->flags); + break; + default: + FFI_ASSERT(0); + break; + } +} + + +void ffi_closure_SYSV(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7, unsigned long r8) +{ + register int *sp __asm__ ("r17"); + register int *r13 __asm__ ("r13"); + + ffi_closure* closure = (ffi_closure*) r13; + char *stack_args = sp; + + /* Lay the register arguments down in a continuous chunk of memory. */ + unsigned register_args[6] = + { r3, r4, r5, r6, r7, r8 }; + + /* Pointer to a struct return value. */ + void *struct_rvalue = (void *) r3; + + ffi_cif *cif = closure->cif; + ffi_type **arg_types = cif->arg_types; + void **avalue = alloca (cif->nargs * sizeof(void *)); + char *ptr = (char *) register_args; + int count = 0; + int nfixedargs = cif->nfixedargs; + int i; + + /* preserve struct type return pointer passing */ + + if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ptr += 4; + count = 4; + } + + /* Find the address of each argument. */ + for (i = 0; i < cif->nargs; i++) + { + + /* variadic args are saved on stack */ + if ((nfixedargs == 0) && (count < 24)) + { + ptr = stack_args; + count = 24; + } + nfixedargs--; + + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + avalue[i] = ptr + 3; + break; + + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + avalue[i] = ptr + 2; + break; + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + case FFI_TYPE_POINTER: + avalue[i] = ptr; + break; + + case FFI_TYPE_STRUCT: + avalue[i] = *(void**)ptr; + break; + + default: + /* 8-byte values */ + + /* arguments are never splitted */ + if (ptr == ®ister_args[5]) + ptr = stack_args; + avalue[i] = ptr; + ptr += 4; + count += 4; + break; + } + ptr += 4; + count += 4; + + /* If we've handled more arguments than fit in registers, + start looking at the those passed on the stack. */ + + if (count == 24) + ptr = stack_args; + } + + if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + (closure->fun) (cif, struct_rvalue, avalue, closure->user_data); + } else + { + long long rvalue; + (closure->fun) (cif, &rvalue, avalue, closure->user_data); + if (cif->rtype) + asm ("l.ori r12, %0, 0x0\n l.lwz r11, 0(r12)\n l.lwz r12, 4(r12)" : : "r" (&rvalue)); + } +} + + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + unsigned short *tramp = (unsigned short *) closure->tramp; + unsigned long fn = (unsigned long) ffi_closure_SYSV; + unsigned long cls = (unsigned long) codeloc; + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + /* write pointers to temporary registers */ + tramp[0] = (0x6 << 10) | (13 << 5); /* l.movhi r13, ... */ + tramp[1] = cls >> 16; + tramp[2] = (0x2a << 10) | (13 << 5) | 13; /* l.ori r13, r13, ... */ + tramp[3] = cls & 0xFFFF; + + tramp[4] = (0x6 << 10) | (15 << 5); /* l.movhi r15, ... */ + tramp[5] = fn >> 16; + tramp[6] = (0x2a << 10) | (15 << 5) | 15; /* l.ori r15, r15 ... */ + tramp[7] = fn & 0xFFFF; + + tramp[8] = (0x11 << 10); /* l.jr r15 */ + tramp[9] = 15 << 11; + + tramp[10] = (0x2a << 10) | (17 << 5) | 1; /* l.ori r17, r1, ... */ + tramp[11] = 0x0; + + return FFI_OK; +} + + +ffi_status ffi_prep_cif_machdep (ffi_cif *cif) +{ + cif->flags = 0; + + /* structures are returned as pointers */ + if (cif->rtype->type == FFI_TYPE_STRUCT) + cif->flags = FFI_TYPE_STRUCT; + else + if (cif->rtype->size > 4) + cif->flags = FFI_TYPE_UINT64; + + cif->nfixedargs = cif->nargs; + + return FFI_OK; +} + + +ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, + unsigned int nfixedargs, unsigned int ntotalargs) +{ + ffi_status status; + + status = ffi_prep_cif_machdep (cif); + cif->nfixedargs = nfixedargs; + return status; +} diff --git a/user/mpy/lib/libffi/src/or1k/ffitarget.h b/user/mpy/lib/libffi/src/or1k/ffitarget.h new file mode 100644 index 0000000..e55da28 --- /dev/null +++ b/user/mpy/lib/libffi/src/or1k/ffitarget.h @@ -0,0 +1,58 @@ +/* ----------------------------------------------------------------------- + ffitarget.h - Copyright (c) 2014 Sebastian Macke + + OpenRISC Target configuration macros + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 +#define FFI_TRAMPOLINE_SIZE (24) + +#define FFI_TARGET_SPECIFIC_VARIADIC 1 +#define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs; + +#endif + diff --git a/user/mpy/lib/libffi/src/or1k/sysv.S b/user/mpy/lib/libffi/src/or1k/sysv.S new file mode 100644 index 0000000..df6570b --- /dev/null +++ b/user/mpy/lib/libffi/src/or1k/sysv.S @@ -0,0 +1,107 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2014 Sebastian Macke + + OpenRISC Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +.text + .globl ffi_call_SYSV + .type ffi_call_SYSV, @function +/* + r3: size to allocate on stack + r4: extended cif structure + r5: function pointer ffi_prep_args + r6: ret address + r7: function to call + r8: flag for return type +*/ + +ffi_call_SYSV: + /* Store registers used on stack */ + l.sw -4(r1), r9 /* return address */ + l.sw -8(r1), r1 /* stack address */ + l.sw -12(r1), r14 /* callee saved registers */ + l.sw -16(r1), r16 + l.sw -20(r1), r18 + l.sw -24(r1), r20 + + l.ori r14, r1, 0x0 /* save stack pointer */ + l.addi r1, r1, -24 + + l.ori r16, r7, 0x0 /* save function address */ + l.ori r18, r6, 0x0 /* save ret address */ + l.ori r20, r8, 0x0 /* save flag */ + + l.sub r1, r1, r3 /* reserve space on stack */ + + /* Call ffi_prep_args */ + l.ori r3, r1, 0x0 /* first argument stack address, second already ecif */ + l.jalr r5 + l.nop + + /* Load register arguments and call*/ + + l.lwz r3, 0(r1) + l.lwz r4, 4(r1) + l.lwz r5, 8(r1) + l.lwz r6, 12(r1) + l.lwz r7, 16(r1) + l.lwz r8, 20(r1) + l.ori r1, r11, 0x0 /* new stack pointer */ + l.jalr r16 + l.nop + + /* handle return values */ + + l.sfeqi r20, FFI_TYPE_STRUCT + l.bf ret /* structs don't return an rvalue */ + l.nop + + /* copy ret address */ + + l.sfeqi r20, FFI_TYPE_UINT64 + l.bnf four_byte_ret /* 8 byte value is returned */ + l.nop + + l.sw 4(r18), r12 + +four_byte_ret: + l.sw 0(r18), r11 + +ret: + /* return */ + l.ori r1, r14, 0x0 /* reset stack pointer */ + l.lwz r9, -4(r1) + l.lwz r1, -8(r1) + l.lwz r14, -12(r1) + l.lwz r16, -16(r1) + l.lwz r18, -20(r1) + l.lwz r20, -24(r1) + l.jr r9 + l.nop + +.size ffi_call_SYSV, .-ffi_call_SYSV diff --git a/user/mpy/lib/libffi/src/pa/ffi.c b/user/mpy/lib/libffi/src/pa/ffi.c new file mode 100644 index 0000000..4ce2bc6 --- /dev/null +++ b/user/mpy/lib/libffi/src/pa/ffi.c @@ -0,0 +1,719 @@ +/* ----------------------------------------------------------------------- + ffi.c - (c) 2011 Anthony Green + (c) 2008 Red Hat, Inc. + (c) 2006 Free Software Foundation, Inc. + (c) 2003-2004 Randolph Chung + + HPPA Foreign Function Interface + HP-UX PA ABI support + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include +#include + +#define ROUND_UP(v, a) (((size_t)(v) + (a) - 1) & ~((a) - 1)) + +#define MIN_STACK_SIZE 64 +#define FIRST_ARG_SLOT 9 +#define DEBUG_LEVEL 0 + +#define fldw(addr, fpreg) \ + __asm__ volatile ("fldw 0(%0), %%" #fpreg "L" : : "r"(addr) : #fpreg) +#define fstw(fpreg, addr) \ + __asm__ volatile ("fstw %%" #fpreg "L, 0(%0)" : : "r"(addr)) +#define fldd(addr, fpreg) \ + __asm__ volatile ("fldd 0(%0), %%" #fpreg : : "r"(addr) : #fpreg) +#define fstd(fpreg, addr) \ + __asm__ volatile ("fstd %%" #fpreg "L, 0(%0)" : : "r"(addr)) + +#define debug(lvl, x...) do { if (lvl <= DEBUG_LEVEL) { printf(x); } } while (0) + +static inline int ffi_struct_type(ffi_type *t) +{ + size_t sz = t->size; + + /* Small structure results are passed in registers, + larger ones are passed by pointer. Note that + small structures of size 2, 4 and 8 differ from + the corresponding integer types in that they have + different alignment requirements. */ + + if (sz <= 1) + return FFI_TYPE_UINT8; + else if (sz == 2) + return FFI_TYPE_SMALL_STRUCT2; + else if (sz == 3) + return FFI_TYPE_SMALL_STRUCT3; + else if (sz == 4) + return FFI_TYPE_SMALL_STRUCT4; + else if (sz == 5) + return FFI_TYPE_SMALL_STRUCT5; + else if (sz == 6) + return FFI_TYPE_SMALL_STRUCT6; + else if (sz == 7) + return FFI_TYPE_SMALL_STRUCT7; + else if (sz <= 8) + return FFI_TYPE_SMALL_STRUCT8; + else + return FFI_TYPE_STRUCT; /* else, we pass it by pointer. */ +} + +/* PA has a downward growing stack, which looks like this: + + Offset + [ Variable args ] + SP = (4*(n+9)) arg word N + ... + SP-52 arg word 4 + [ Fixed args ] + SP-48 arg word 3 + SP-44 arg word 2 + SP-40 arg word 1 + SP-36 arg word 0 + [ Frame marker ] + ... + SP-20 RP + SP-4 previous SP + + The first four argument words on the stack are reserved for use by + the callee. Instead, the general and floating registers replace + the first four argument slots. Non FP arguments are passed solely + in the general registers. FP arguments are passed in both general + and floating registers when using libffi. + + Non-FP 32-bit args are passed in gr26, gr25, gr24 and gr23. + Non-FP 64-bit args are passed in register pairs, starting + on an odd numbered register (i.e. r25+r26 and r23+r24). + FP 32-bit arguments are passed in fr4L, fr5L, fr6L and fr7L. + FP 64-bit arguments are passed in fr5 and fr7. + + The registers are allocated in the same manner as stack slots. + This allows the callee to save its arguments on the stack if + necessary: + + arg word 3 -> gr23 or fr7L + arg word 2 -> gr24 or fr6L or fr7R + arg word 1 -> gr25 or fr5L + arg word 0 -> gr26 or fr4L or fr5R + + Note that fr4R and fr6R are never used for arguments (i.e., + doubles are not passed in fr4 or fr6). + + The rest of the arguments are passed on the stack starting at SP-52, + but 64-bit arguments need to be aligned to an 8-byte boundary + + This means we can have holes either in the register allocation, + or in the stack. */ + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments + + The following code will put everything into the stack frame + (which was allocated by the asm routine), and on return + the asm routine will load the arguments that should be + passed by register into the appropriate registers + + NOTE: We load floating point args in this function... that means we + assume gcc will not mess with fp regs in here. */ + +void ffi_prep_args_pa32(UINT32 *stack, extended_cif *ecif, unsigned bytes) +{ + register unsigned int i; + register ffi_type **p_arg; + register void **p_argv; + unsigned int slot = FIRST_ARG_SLOT; + char *dest_cpy; + size_t len; + + debug(1, "%s: stack = %p, ecif = %p, bytes = %u\n", __FUNCTION__, stack, + ecif, bytes); + + p_arg = ecif->cif->arg_types; + p_argv = ecif->avalue; + + for (i = 0; i < ecif->cif->nargs; i++) + { + int type = (*p_arg)->type; + + switch (type) + { + case FFI_TYPE_SINT8: + *(SINT32 *)(stack - slot) = *(SINT8 *)(*p_argv); + break; + + case FFI_TYPE_UINT8: + *(UINT32 *)(stack - slot) = *(UINT8 *)(*p_argv); + break; + + case FFI_TYPE_SINT16: + *(SINT32 *)(stack - slot) = *(SINT16 *)(*p_argv); + break; + + case FFI_TYPE_UINT16: + *(UINT32 *)(stack - slot) = *(UINT16 *)(*p_argv); + break; + + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + debug(3, "Storing UINT32 %u in slot %u\n", *(UINT32 *)(*p_argv), + slot); + *(UINT32 *)(stack - slot) = *(UINT32 *)(*p_argv); + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + /* Align slot for 64-bit type. */ + slot += (slot & 1) ? 1 : 2; + *(UINT64 *)(stack - slot) = *(UINT64 *)(*p_argv); + break; + + case FFI_TYPE_FLOAT: + /* First 4 args go in fr4L - fr7L. */ + debug(3, "Storing UINT32(float) in slot %u\n", slot); + *(UINT32 *)(stack - slot) = *(UINT32 *)(*p_argv); + switch (slot - FIRST_ARG_SLOT) + { + /* First 4 args go in fr4L - fr7L. */ + case 0: fldw(stack - slot, fr4); break; + case 1: fldw(stack - slot, fr5); break; + case 2: fldw(stack - slot, fr6); break; + case 3: fldw(stack - slot, fr7); break; + } + break; + + case FFI_TYPE_DOUBLE: + /* Align slot for 64-bit type. */ + slot += (slot & 1) ? 1 : 2; + debug(3, "Storing UINT64(double) at slot %u\n", slot); + *(UINT64 *)(stack - slot) = *(UINT64 *)(*p_argv); + switch (slot - FIRST_ARG_SLOT) + { + /* First 2 args go in fr5, fr7. */ + case 1: fldd(stack - slot, fr5); break; + case 3: fldd(stack - slot, fr7); break; + } + break; + +#ifdef PA_HPUX + case FFI_TYPE_LONGDOUBLE: + /* Long doubles are passed in the same manner as structures + larger than 8 bytes. */ + *(UINT32 *)(stack - slot) = (UINT32)(*p_argv); + break; +#endif + + case FFI_TYPE_STRUCT: + + /* Structs smaller or equal than 4 bytes are passed in one + register. Structs smaller or equal 8 bytes are passed in two + registers. Larger structures are passed by pointer. */ + + len = (*p_arg)->size; + if (len <= 4) + { + dest_cpy = (char *)(stack - slot) + 4 - len; + memcpy(dest_cpy, (char *)*p_argv, len); + } + else if (len <= 8) + { + slot += (slot & 1) ? 1 : 2; + dest_cpy = (char *)(stack - slot) + 8 - len; + memcpy(dest_cpy, (char *)*p_argv, len); + } + else + *(UINT32 *)(stack - slot) = (UINT32)(*p_argv); + break; + + default: + FFI_ASSERT(0); + } + + slot++; + p_arg++; + p_argv++; + } + + /* Make sure we didn't mess up and scribble on the stack. */ + { + unsigned int n; + + debug(5, "Stack setup:\n"); + for (n = 0; n < (bytes + 3) / 4; n++) + { + if ((n%4) == 0) { debug(5, "\n%08x: ", (unsigned int)(stack - n)); } + debug(5, "%08x ", *(stack - n)); + } + debug(5, "\n"); + } + + FFI_ASSERT(slot * 4 <= bytes); + + return; +} + +static void ffi_size_stack_pa32(ffi_cif *cif) +{ + ffi_type **ptr; + int i; + int z = 0; /* # stack slots */ + + for (ptr = cif->arg_types, i = 0; i < cif->nargs; ptr++, i++) + { + int type = (*ptr)->type; + + switch (type) + { + case FFI_TYPE_DOUBLE: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + z += 2 + (z & 1); /* must start on even regs, so we may waste one */ + break; + +#ifdef PA_HPUX + case FFI_TYPE_LONGDOUBLE: +#endif + case FFI_TYPE_STRUCT: + z += 1; /* pass by ptr, callee will copy */ + break; + + default: /* <= 32-bit values */ + z++; + } + } + + /* We can fit up to 6 args in the default 64-byte stack frame, + if we need more, we need more stack. */ + if (z <= 6) + cif->bytes = MIN_STACK_SIZE; /* min stack size */ + else + cif->bytes = 64 + ROUND_UP((z - 6) * sizeof(UINT32), MIN_STACK_SIZE); + + debug(3, "Calculated stack size is %u bytes\n", cif->bytes); +} + +/* Perform machine dependent cif processing. */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + cif->flags = (unsigned) cif->rtype->type; + break; + +#ifdef PA_HPUX + case FFI_TYPE_LONGDOUBLE: + /* Long doubles are treated like a structure. */ + cif->flags = FFI_TYPE_STRUCT; + break; +#endif + + case FFI_TYPE_STRUCT: + /* For the return type we have to check the size of the structures. + If the size is smaller or equal 4 bytes, the result is given back + in one register. If the size is smaller or equal 8 bytes than we + return the result in two registers. But if the size is bigger than + 8 bytes, we work with pointers. */ + cif->flags = ffi_struct_type(cif->rtype); + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + cif->flags = FFI_TYPE_UINT64; + break; + + default: + cif->flags = FFI_TYPE_INT; + break; + } + + /* Lucky us, because of the unique PA ABI we get to do our + own stack sizing. */ + switch (cif->abi) + { + case FFI_PA32: + ffi_size_stack_pa32(cif); + break; + + default: + FFI_ASSERT(0); + break; + } + + return FFI_OK; +} + +extern void ffi_call_pa32(void (*)(UINT32 *, extended_cif *, unsigned), + extended_cif *, unsigned, unsigned, unsigned *, + void (*fn)(void)); + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return + value address then we need to make one. */ + + if (rvalue == NULL +#ifdef PA_HPUX + && (cif->rtype->type == FFI_TYPE_STRUCT + || cif->rtype->type == FFI_TYPE_LONGDOUBLE)) +#else + && cif->rtype->type == FFI_TYPE_STRUCT) +#endif + { + ecif.rvalue = alloca(cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + + switch (cif->abi) + { + case FFI_PA32: + debug(3, "Calling ffi_call_pa32: ecif=%p, bytes=%u, flags=%u, rvalue=%p, fn=%p\n", &ecif, cif->bytes, cif->flags, ecif.rvalue, (void *)fn); + ffi_call_pa32(ffi_prep_args_pa32, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + break; + + default: + FFI_ASSERT(0); + break; + } +} + +#if FFI_CLOSURES +/* This is more-or-less an inverse of ffi_call -- we have arguments on + the stack, and we need to fill them into a cif structure and invoke + the user function. This really ought to be in asm to make sure + the compiler doesn't do things we don't expect. */ +ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) +{ + ffi_cif *cif; + void **avalue; + void *rvalue; + UINT32 ret[2]; /* function can return up to 64-bits in registers */ + ffi_type **p_arg; + char *tmp; + int i, avn; + unsigned int slot = FIRST_ARG_SLOT; + register UINT32 r28 asm("r28"); + + cif = closure->cif; + + /* If returning via structure, callee will write to our pointer. */ + if (cif->flags == FFI_TYPE_STRUCT) + rvalue = (void *)r28; + else + rvalue = &ret[0]; + + avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG); + avn = cif->nargs; + p_arg = cif->arg_types; + + for (i = 0; i < avn; i++) + { + int type = (*p_arg)->type; + + switch (type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + avalue[i] = (char *)(stack - slot) + sizeof(UINT32) - (*p_arg)->size; + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + slot += (slot & 1) ? 1 : 2; + avalue[i] = (void *)(stack - slot); + break; + + case FFI_TYPE_FLOAT: +#ifdef PA_LINUX + /* The closure call is indirect. In Linux, floating point + arguments in indirect calls with a prototype are passed + in the floating point registers instead of the general + registers. So, we need to replace what was previously + stored in the current slot with the value in the + corresponding floating point register. */ + switch (slot - FIRST_ARG_SLOT) + { + case 0: fstw(fr4, (void *)(stack - slot)); break; + case 1: fstw(fr5, (void *)(stack - slot)); break; + case 2: fstw(fr6, (void *)(stack - slot)); break; + case 3: fstw(fr7, (void *)(stack - slot)); break; + } +#endif + avalue[i] = (void *)(stack - slot); + break; + + case FFI_TYPE_DOUBLE: + slot += (slot & 1) ? 1 : 2; +#ifdef PA_LINUX + /* See previous comment for FFI_TYPE_FLOAT. */ + switch (slot - FIRST_ARG_SLOT) + { + case 1: fstd(fr5, (void *)(stack - slot)); break; + case 3: fstd(fr7, (void *)(stack - slot)); break; + } +#endif + avalue[i] = (void *)(stack - slot); + break; + +#ifdef PA_HPUX + case FFI_TYPE_LONGDOUBLE: + /* Long doubles are treated like a big structure. */ + avalue[i] = (void *) *(stack - slot); + break; +#endif + + case FFI_TYPE_STRUCT: + /* Structs smaller or equal than 4 bytes are passed in one + register. Structs smaller or equal 8 bytes are passed in two + registers. Larger structures are passed by pointer. */ + if((*p_arg)->size <= 4) + { + avalue[i] = (void *)(stack - slot) + sizeof(UINT32) - + (*p_arg)->size; + } + else if ((*p_arg)->size <= 8) + { + slot += (slot & 1) ? 1 : 2; + avalue[i] = (void *)(stack - slot) + sizeof(UINT64) - + (*p_arg)->size; + } + else + avalue[i] = (void *) *(stack - slot); + break; + + default: + FFI_ASSERT(0); + } + + slot++; + p_arg++; + } + + /* Invoke the closure. */ + (closure->fun) (cif, rvalue, avalue, closure->user_data); + + debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0], + ret[1]); + + /* Store the result using the lower 2 bytes of the flags. */ + switch (cif->flags) + { + case FFI_TYPE_UINT8: + *(stack - FIRST_ARG_SLOT) = (UINT8)(ret[0] >> 24); + break; + case FFI_TYPE_SINT8: + *(stack - FIRST_ARG_SLOT) = (SINT8)(ret[0] >> 24); + break; + case FFI_TYPE_UINT16: + *(stack - FIRST_ARG_SLOT) = (UINT16)(ret[0] >> 16); + break; + case FFI_TYPE_SINT16: + *(stack - FIRST_ARG_SLOT) = (SINT16)(ret[0] >> 16); + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + *(stack - FIRST_ARG_SLOT) = ret[0]; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + *(stack - FIRST_ARG_SLOT) = ret[0]; + *(stack - FIRST_ARG_SLOT - 1) = ret[1]; + break; + + case FFI_TYPE_DOUBLE: + fldd(rvalue, fr4); + break; + + case FFI_TYPE_FLOAT: + fldw(rvalue, fr4); + break; + + case FFI_TYPE_STRUCT: + /* Don't need a return value, done by caller. */ + break; + + case FFI_TYPE_SMALL_STRUCT2: + case FFI_TYPE_SMALL_STRUCT3: + case FFI_TYPE_SMALL_STRUCT4: + tmp = (void*)(stack - FIRST_ARG_SLOT); + tmp += 4 - cif->rtype->size; + memcpy((void*)tmp, &ret[0], cif->rtype->size); + break; + + case FFI_TYPE_SMALL_STRUCT5: + case FFI_TYPE_SMALL_STRUCT6: + case FFI_TYPE_SMALL_STRUCT7: + case FFI_TYPE_SMALL_STRUCT8: + { + unsigned int ret2[2]; + int off; + + /* Right justify ret[0] and ret[1] */ + switch (cif->flags) + { + case FFI_TYPE_SMALL_STRUCT5: off = 3; break; + case FFI_TYPE_SMALL_STRUCT6: off = 2; break; + case FFI_TYPE_SMALL_STRUCT7: off = 1; break; + default: off = 0; break; + } + + memset (ret2, 0, sizeof (ret2)); + memcpy ((char *)ret2 + off, ret, 8 - off); + + *(stack - FIRST_ARG_SLOT) = ret2[0]; + *(stack - FIRST_ARG_SLOT - 1) = ret2[1]; + } + break; + + case FFI_TYPE_POINTER: + case FFI_TYPE_VOID: + break; + + default: + debug(0, "assert with cif->flags: %d\n",cif->flags); + FFI_ASSERT(0); + break; + } + return FFI_OK; +} + +/* Fill in a closure to refer to the specified fun and user_data. + cif specifies the argument and result types for fun. + The cif must already be prep'ed. */ + +extern void ffi_closure_pa32(void); + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + UINT32 *tramp = (UINT32 *)(closure->tramp); +#ifdef PA_HPUX + UINT32 *tmp; +#endif + + if (cif->abi != FFI_PA32) + return FFI_BAD_ABI; + + /* Make a small trampoline that will branch to our + handler function. Use PC-relative addressing. */ + +#ifdef PA_LINUX + tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */ + tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */ + tramp[2] = 0x4aa10028; /* ldw 20(%r21),%r1 ; load plabel */ + tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */ + tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */ + tramp[5] = 0xeac0c000; /* bv%r0(%r22) ; branch to handler */ + tramp[6] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */ + tramp[7] = ((UINT32)(ffi_closure_pa32) & ~2); + + /* Flush d/icache -- have to flush up 2 two lines because of + alignment. */ + __asm__ volatile( + "fdc 0(%0)\n\t" + "fdc %1(%0)\n\t" + "fic 0(%%sr4, %0)\n\t" + "fic %1(%%sr4, %0)\n\t" + "sync\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + : + : "r"((unsigned long)tramp & ~31), + "r"(32 /* stride */) + : "memory"); +#endif + +#ifdef PA_HPUX + tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */ + tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */ + tramp[2] = 0x4aa10038; /* ldw 28(%r21),%r1 ; load plabel */ + tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */ + tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */ + tramp[5] = 0x02c010b4; /* ldsid (%r22),%r20 ; load space id */ + tramp[6] = 0x00141820; /* mtsp %r20,%sr0 ; into %sr0 */ + tramp[7] = 0xe2c00000; /* be 0(%sr0,%r22) ; branch to handler */ + tramp[8] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */ + tramp[9] = ((UINT32)(ffi_closure_pa32) & ~2); + + /* Flush d/icache -- have to flush three lines because of alignment. */ + __asm__ volatile( + "copy %1,%0\n\t" + "fdc,m %2(%0)\n\t" + "fdc,m %2(%0)\n\t" + "fdc,m %2(%0)\n\t" + "ldsid (%1),%0\n\t" + "mtsp %0,%%sr0\n\t" + "copy %1,%0\n\t" + "fic,m %2(%%sr0,%0)\n\t" + "fic,m %2(%%sr0,%0)\n\t" + "fic,m %2(%%sr0,%0)\n\t" + "sync\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + : "=&r" ((unsigned long)tmp) + : "r" ((unsigned long)tramp & ~31), + "r" (32/* stride */) + : "memory"); +#endif + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} +#endif diff --git a/user/mpy/lib/libffi/src/pa/ffitarget.h b/user/mpy/lib/libffi/src/pa/ffitarget.h new file mode 100644 index 0000000..fff4c6b --- /dev/null +++ b/user/mpy/lib/libffi/src/pa/ffitarget.h @@ -0,0 +1,85 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for hppa. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + +#ifdef PA_LINUX + FFI_PA32, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_PA32 +#endif + +#ifdef PA_HPUX + FFI_PA32, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_PA32 +#endif + +#ifdef PA64_HPUX +#error "PA64_HPUX FFI is not yet implemented" + FFI_PA64, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_PA64 +#endif +} ffi_abi; +#endif + +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 + +#ifdef PA_LINUX +#define FFI_TRAMPOLINE_SIZE 32 +#else +#define FFI_TRAMPOLINE_SIZE 40 +#endif + +#define FFI_TYPE_SMALL_STRUCT2 -1 +#define FFI_TYPE_SMALL_STRUCT3 -2 +#define FFI_TYPE_SMALL_STRUCT4 -3 +#define FFI_TYPE_SMALL_STRUCT5 -4 +#define FFI_TYPE_SMALL_STRUCT6 -5 +#define FFI_TYPE_SMALL_STRUCT7 -6 +#define FFI_TYPE_SMALL_STRUCT8 -7 +#endif diff --git a/user/mpy/lib/libffi/src/pa/hpux32.S b/user/mpy/lib/libffi/src/pa/hpux32.S new file mode 100644 index 0000000..40528ba --- /dev/null +++ b/user/mpy/lib/libffi/src/pa/hpux32.S @@ -0,0 +1,368 @@ +/* ----------------------------------------------------------------------- + hpux32.S - Copyright (c) 2006 Free Software Foundation, Inc. + (c) 2008 Red Hat, Inc. + based on src/pa/linux.S + + HP-UX PA Foreign Function Interface + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + .LEVEL 1.1 + .SPACE $PRIVATE$ + .IMPORT $global$,DATA + .IMPORT $$dyncall,MILLICODE + .SUBSPA $DATA$ + .align 4 + + /* void ffi_call_pa32(void (*)(char *, extended_cif *), + extended_cif *ecif, + unsigned bytes, + unsigned flags, + unsigned *rvalue, + void (*fn)(void)); + */ + + .export ffi_call_pa32,ENTRY,PRIV_LEV=3 + .import ffi_prep_args_pa32,CODE + + .SPACE $TEXT$ + .SUBSPA $CODE$ + .align 4 + +L$FB1 +ffi_call_pa32 + .proc + .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4 + .entry + stw %rp, -20(%sp) + copy %r3, %r1 +L$CFI11 + copy %sp, %r3 +L$CFI12 + + /* Setup the stack for calling prep_args... + We want the stack to look like this: + + [ Previous stack ] <- %r3 + + [ 64-bytes register save area ] <- %r4 + + [ Stack space for actual call, passed as ] <- %arg0 + [ arg0 to ffi_prep_args_pa32 ] + + [ Stack for calling prep_args ] <- %sp + */ + + stwm %r1, 64(%sp) + stw %r4, 12(%r3) +L$CFI13 + copy %sp, %r4 + + addl %arg2, %r4, %arg0 ; arg stack + stw %arg3, -48(%r3) ; save flags we need it later + + /* Call prep_args: + %arg0(stack) -- set up above + %arg1(ecif) -- same as incoming param + %arg2(bytes) -- same as incoming param */ + bl ffi_prep_args_pa32,%r2 + ldo 64(%arg0), %sp + ldo -64(%sp), %sp + + /* now %sp should point where %arg0 was pointing. */ + + /* Load the arguments that should be passed in registers + The fp args are loaded by the prep_args function. */ + ldw -36(%sp), %arg0 + ldw -40(%sp), %arg1 + ldw -44(%sp), %arg2 + ldw -48(%sp), %arg3 + + /* in case the function is going to return a structure + we need to give it a place to put the result. */ + ldw -52(%r3), %ret0 ; %ret0 <- rvalue + ldw -56(%r3), %r22 ; %r22 <- function to call + bl $$dyncall, %r31 ; Call the user function + copy %r31, %rp + + /* Prepare to store the result; we need to recover flags and rvalue. */ + ldw -48(%r3), %r21 ; r21 <- flags + ldw -52(%r3), %r20 ; r20 <- rvalue + + /* Store the result according to the return type. The most + likely types should come first. */ + +L$checkint + comib,<>,n FFI_TYPE_INT, %r21, L$checkint8 + b L$done + stw %ret0, 0(%r20) + +L$checkint8 + comib,<>,n FFI_TYPE_UINT8, %r21, L$checkint16 + b L$done + stb %ret0, 0(%r20) + +L$checkint16 + comib,<>,n FFI_TYPE_UINT16, %r21, L$checkdbl + b L$done + sth %ret0, 0(%r20) + +L$checkdbl + comib,<>,n FFI_TYPE_DOUBLE, %r21, L$checkfloat + b L$done + fstd %fr4,0(%r20) + +L$checkfloat + comib,<>,n FFI_TYPE_FLOAT, %r21, L$checkll + b L$done + fstw %fr4L,0(%r20) + +L$checkll + comib,<>,n FFI_TYPE_UINT64, %r21, L$checksmst2 + stw %ret0, 0(%r20) + b L$done + stw %ret1, 4(%r20) + +L$checksmst2 + comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, L$checksmst3 + /* 2-byte structs are returned in ret0 as ????xxyy. */ + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b L$done + stb %ret0, 0(%r20) + +L$checksmst3 + comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, L$checksmst4 + /* 3-byte structs are returned in ret0 as ??xxyyzz. */ + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b L$done + stb %ret0, 0(%r20) + +L$checksmst4 + comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, L$checksmst5 + /* 4-byte structs are returned in ret0 as wwxxyyzz. */ + extru %ret0, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b L$done + stb %ret0, 0(%r20) + +L$checksmst5 + comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, L$checksmst6 + /* 5 byte values are returned right justified: + ret0 ret1 + 5: ??????aa bbccddee */ + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b L$done + stb %ret1, 0(%r20) + +L$checksmst6 + comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, L$checksmst7 + /* 6 byte values are returned right justified: + ret0 ret1 + 6: ????aabb ccddeeff */ + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b L$done + stb %ret1, 0(%r20) + +L$checksmst7 + comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, L$checksmst8 + /* 7 byte values are returned right justified: + ret0 ret1 + 7: ??aabbcc ddeeffgg */ + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b L$done + stb %ret1, 0(%r20) + +L$checksmst8 + comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, L$done + /* 8 byte values are returned right justified: + ret0 ret1 + 8: aabbccdd eeffgghh */ + extru %ret0, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stb %ret1, 0(%r20) + +L$done + /* all done, return */ + copy %r4, %sp ; pop arg stack + ldw 12(%r3), %r4 + ldwm -64(%sp), %r3 ; .. and pop stack + ldw -20(%sp), %rp + bv %r0(%rp) + nop + .exit + .procend +L$FE1 + + /* void ffi_closure_pa32(void); + Called with closure argument in %r21 */ + + .SPACE $TEXT$ + .SUBSPA $CODE$ + .export ffi_closure_pa32,ENTRY,PRIV_LEV=3,RTNVAL=GR + .import ffi_closure_inner_pa32,CODE + .align 4 +L$FB2 +ffi_closure_pa32 + .proc + .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 + .entry + + stw %rp, -20(%sp) + copy %r3, %r1 +L$CFI21 + copy %sp, %r3 +L$CFI22 + stwm %r1, 64(%sp) + + /* Put arguments onto the stack and call ffi_closure_inner. */ + stw %arg0, -36(%r3) + stw %arg1, -40(%r3) + stw %arg2, -44(%r3) + stw %arg3, -48(%r3) + + copy %r21, %arg0 + bl ffi_closure_inner_pa32, %r2 + copy %r3, %arg1 + ldwm -64(%sp), %r3 + ldw -20(%sp), %rp + ldw -36(%sp), %ret0 + bv %r0(%rp) + ldw -40(%sp), %ret1 + .exit + .procend +L$FE2: + + .SPACE $PRIVATE$ + .SUBSPA $DATA$ + + .align 4 + .EXPORT _GLOBAL__F_ffi_call_pa32,DATA +_GLOBAL__F_ffi_call_pa32 +L$frame1: + .word L$ECIE1-L$SCIE1 ;# Length of Common Information Entry +L$SCIE1: + .word 0x0 ;# CIE Identifier Tag + .byte 0x1 ;# CIE Version + .ascii "\0" ;# CIE Augmentation + .uleb128 0x1 ;# CIE Code Alignment Factor + .sleb128 4 ;# CIE Data Alignment Factor + .byte 0x2 ;# CIE RA Column + .byte 0xc ;# DW_CFA_def_cfa + .uleb128 0x1e + .uleb128 0x0 + .align 4 +L$ECIE1: +L$SFDE1: + .word L$EFDE1-L$ASFDE1 ;# FDE Length +L$ASFDE1: + .word L$ASFDE1-L$frame1 ;# FDE CIE offset + .word L$FB1 ;# FDE initial location + .word L$FE1-L$FB1 ;# FDE address range + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI11-L$FB1 + .byte 0x83 ;# DW_CFA_offset, column 0x3 + .uleb128 0x0 + .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20] + .uleb128 0x2 + .sleb128 -5 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI12-L$CFI11 + .byte 0xd ;# DW_CFA_def_cfa_register = r3 + .uleb128 0x3 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI13-L$CFI12 + .byte 0x84 ;# DW_CFA_offset, column 0x4 + .uleb128 0x3 + + .align 4 +L$EFDE1: + +L$SFDE2: + .word L$EFDE2-L$ASFDE2 ;# FDE Length +L$ASFDE2: + .word L$ASFDE2-L$frame1 ;# FDE CIE offset + .word L$FB2 ;# FDE initial location + .word L$FE2-L$FB2 ;# FDE address range + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI21-L$FB2 + .byte 0x83 ;# DW_CFA_offset, column 0x3 + .uleb128 0x0 + .byte 0x11 ;# DW_CFA_offset_extended_sf + .uleb128 0x2 + .sleb128 -5 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI22-L$CFI21 + .byte 0xd ;# DW_CFA_def_cfa_register = r3 + .uleb128 0x3 + + .align 4 +L$EFDE2: diff --git a/user/mpy/lib/libffi/src/pa/linux.S b/user/mpy/lib/libffi/src/pa/linux.S new file mode 100644 index 0000000..f11ae76 --- /dev/null +++ b/user/mpy/lib/libffi/src/pa/linux.S @@ -0,0 +1,357 @@ +/* ----------------------------------------------------------------------- + linux.S - (c) 2003-2004 Randolph Chung + (c) 2008 Red Hat, Inc. + + HPPA Foreign Function Interface + + 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 RENESAS TECHNOLOGY 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + .text + .level 1.1 + .align 4 + + /* void ffi_call_pa32(void (*)(char *, extended_cif *), + extended_cif *ecif, + unsigned bytes, + unsigned flags, + unsigned *rvalue, + void (*fn)(void)); + */ + + .export ffi_call_pa32,code + .import ffi_prep_args_pa32,code + + .type ffi_call_pa32, @function +.LFB1: +ffi_call_pa32: + .proc + .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4 + .entry + stw %rp, -20(%sp) + copy %r3, %r1 +.LCFI11: + + copy %sp, %r3 +.LCFI12: + + /* Setup the stack for calling prep_args... + We want the stack to look like this: + + [ Previous stack ] <- %r3 + + [ 64-bytes register save area ] <- %r4 + + [ Stack space for actual call, passed as ] <- %arg0 + [ arg0 to ffi_prep_args_pa32 ] + + [ Stack for calling prep_args ] <- %sp + */ + + stwm %r1, 64(%sp) + stw %r4, 12(%r3) +.LCFI13: + copy %sp, %r4 + + addl %arg2, %r4, %arg0 /* arg stack */ + stw %arg3, -48(%r3) /* save flags; we need it later */ + + /* Call prep_args: + %arg0(stack) -- set up above + %arg1(ecif) -- same as incoming param + %arg2(bytes) -- same as incoming param */ + bl ffi_prep_args_pa32,%r2 + ldo 64(%arg0), %sp + ldo -64(%sp), %sp + + /* now %sp should point where %arg0 was pointing. */ + + /* Load the arguments that should be passed in registers + The fp args were loaded by the prep_args function. */ + ldw -36(%sp), %arg0 + ldw -40(%sp), %arg1 + ldw -44(%sp), %arg2 + ldw -48(%sp), %arg3 + + /* in case the function is going to return a structure + we need to give it a place to put the result. */ + ldw -52(%r3), %ret0 /* %ret0 <- rvalue */ + ldw -56(%r3), %r22 /* %r22 <- function to call */ + bl $$dyncall, %r31 /* Call the user function */ + copy %r31, %rp + + /* Prepare to store the result; we need to recover flags and rvalue. */ + ldw -48(%r3), %r21 /* r21 <- flags */ + ldw -52(%r3), %r20 /* r20 <- rvalue */ + + /* Store the result according to the return type. */ + +.Lcheckint: + comib,<>,n FFI_TYPE_INT, %r21, .Lcheckint8 + b .Ldone + stw %ret0, 0(%r20) + +.Lcheckint8: + comib,<>,n FFI_TYPE_UINT8, %r21, .Lcheckint16 + b .Ldone + stb %ret0, 0(%r20) + +.Lcheckint16: + comib,<>,n FFI_TYPE_UINT16, %r21, .Lcheckdbl + b .Ldone + sth %ret0, 0(%r20) + +.Lcheckdbl: + comib,<>,n FFI_TYPE_DOUBLE, %r21, .Lcheckfloat + b .Ldone + fstd %fr4,0(%r20) + +.Lcheckfloat: + comib,<>,n FFI_TYPE_FLOAT, %r21, .Lcheckll + b .Ldone + fstw %fr4L,0(%r20) + +.Lcheckll: + comib,<>,n FFI_TYPE_UINT64, %r21, .Lchecksmst2 + stw %ret0, 0(%r20) + b .Ldone + stw %ret1, 4(%r20) + +.Lchecksmst2: + comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, .Lchecksmst3 + /* 2-byte structs are returned in ret0 as ????xxyy. */ + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b .Ldone + stb %ret0, 0(%r20) + +.Lchecksmst3: + comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, .Lchecksmst4 + /* 3-byte structs are returned in ret0 as ??xxyyzz. */ + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b .Ldone + stb %ret0, 0(%r20) + +.Lchecksmst4: + comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, .Lchecksmst5 + /* 4-byte structs are returned in ret0 as wwxxyyzz. */ + extru %ret0, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b .Ldone + stb %ret0, 0(%r20) + +.Lchecksmst5: + comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, .Lchecksmst6 + /* 5 byte values are returned right justified: + ret0 ret1 + 5: ??????aa bbccddee */ + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b .Ldone + stb %ret1, 0(%r20) + +.Lchecksmst6: + comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, .Lchecksmst7 + /* 6 byte values are returned right justified: + ret0 ret1 + 6: ????aabb ccddeeff */ + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b .Ldone + stb %ret1, 0(%r20) + +.Lchecksmst7: + comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, .Lchecksmst8 + /* 7 byte values are returned right justified: + ret0 ret1 + 7: ??aabbcc ddeeffgg */ + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + b .Ldone + stb %ret1, 0(%r20) + +.Lchecksmst8: + comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, .Ldone + /* 8 byte values are returned right justified: + ret0 ret1 + 8: aabbccdd eeffgghh */ + extru %ret0, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret0, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stbs,ma %ret0, 1(%r20) + extru %ret1, 7, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 15, 8, %r22 + stbs,ma %r22, 1(%r20) + extru %ret1, 23, 8, %r22 + stbs,ma %r22, 1(%r20) + stb %ret1, 0(%r20) + +.Ldone: + /* all done, return */ + copy %r4, %sp /* pop arg stack */ + ldw 12(%r3), %r4 + ldwm -64(%sp), %r3 /* .. and pop stack */ + ldw -20(%sp), %rp + bv %r0(%rp) + nop + .exit + .procend +.LFE1: + + /* void ffi_closure_pa32(void); + Called with closure argument in %r21 */ + .export ffi_closure_pa32,code + .import ffi_closure_inner_pa32,code + + .type ffi_closure_pa32, @function +.LFB2: +ffi_closure_pa32: + .proc + .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 + .entry + + stw %rp, -20(%sp) +.LCFI20: + copy %r3, %r1 +.LCFI21: + copy %sp, %r3 +.LCFI22: + stwm %r1, 64(%sp) + + /* Put arguments onto the stack and call ffi_closure_inner. */ + stw %arg0, -36(%r3) + stw %arg1, -40(%r3) + stw %arg2, -44(%r3) + stw %arg3, -48(%r3) + + copy %r21, %arg0 + bl ffi_closure_inner_pa32, %r2 + copy %r3, %arg1 + + ldwm -64(%sp), %r3 + ldw -20(%sp), %rp + ldw -36(%sp), %ret0 + bv %r0(%r2) + ldw -40(%sp), %ret1 + + .exit + .procend +.LFE2: + + .section ".eh_frame",EH_FRAME_FLAGS,@progbits +.Lframe1: + .word .LECIE1-.LSCIE1 ;# Length of Common Information Entry +.LSCIE1: + .word 0x0 ;# CIE Identifier Tag + .byte 0x1 ;# CIE Version + .ascii "\0" ;# CIE Augmentation + .uleb128 0x1 ;# CIE Code Alignment Factor + .sleb128 4 ;# CIE Data Alignment Factor + .byte 0x2 ;# CIE RA Column + .byte 0xc ;# DW_CFA_def_cfa + .uleb128 0x1e + .uleb128 0x0 + .align 4 +.LECIE1: +.LSFDE1: + .word .LEFDE1-.LASFDE1 ;# FDE Length +.LASFDE1: + .word .LASFDE1-.Lframe1 ;# FDE CIE offset + .word .LFB1 ;# FDE initial location + .word .LFE1-.LFB1 ;# FDE address range + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word .LCFI11-.LFB1 + .byte 0x83 ;# DW_CFA_offset, column 0x3 + .uleb128 0x0 + .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20] + .uleb128 0x2 + .sleb128 -5 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word .LCFI12-.LCFI11 + .byte 0xd ;# DW_CFA_def_cfa_register = r3 + .uleb128 0x3 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word .LCFI13-.LCFI12 + .byte 0x84 ;# DW_CFA_offset, column 0x4 + .uleb128 0x3 + + .align 4 +.LEFDE1: + +.LSFDE2: + .word .LEFDE2-.LASFDE2 ;# FDE Length +.LASFDE2: + .word .LASFDE2-.Lframe1 ;# FDE CIE offset + .word .LFB2 ;# FDE initial location + .word .LFE2-.LFB2 ;# FDE address range + .byte 0x4 ;# DW_CFA_advance_loc4 + .word .LCFI21-.LFB2 + .byte 0x83 ;# DW_CFA_offset, column 0x3 + .uleb128 0x0 + .byte 0x11 ;# DW_CFA_offset_extended_sf + .uleb128 0x2 + .sleb128 -5 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word .LCFI22-.LCFI21 + .byte 0xd ;# DW_CFA_def_cfa_register = r3 + .uleb128 0x3 + + .align 4 +.LEFDE2: diff --git a/user/mpy/lib/libffi/src/powerpc/aix.S b/user/mpy/lib/libffi/src/powerpc/aix.S new file mode 100644 index 0000000..349e78c --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/aix.S @@ -0,0 +1,328 @@ +/* ----------------------------------------------------------------------- + aix.S - Copyright (c) 2002, 2009 Free Software Foundation, Inc. + based on darwin.S by John Hornkvist + + PowerPC Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + + .set r0,0 + .set r1,1 + .set r2,2 + .set r3,3 + .set r4,4 + .set r5,5 + .set r6,6 + .set r7,7 + .set r8,8 + .set r9,9 + .set r10,10 + .set r11,11 + .set r12,12 + .set r13,13 + .set r14,14 + .set r15,15 + .set r16,16 + .set r17,17 + .set r18,18 + .set r19,19 + .set r20,20 + .set r21,21 + .set r22,22 + .set r23,23 + .set r24,24 + .set r25,25 + .set r26,26 + .set r27,27 + .set r28,28 + .set r29,29 + .set r30,30 + .set r31,31 + .set f0,0 + .set f1,1 + .set f2,2 + .set f3,3 + .set f4,4 + .set f5,5 + .set f6,6 + .set f7,7 + .set f8,8 + .set f9,9 + .set f10,10 + .set f11,11 + .set f12,12 + .set f13,13 + .set f14,14 + .set f15,15 + .set f16,16 + .set f17,17 + .set f18,18 + .set f19,19 + .set f20,20 + .set f21,21 + + .extern .ffi_prep_args + +#define LIBFFI_ASM +#include +#include +#define JUMPTARGET(name) name +#define L(x) x + .file "aix.S" + .toc + + /* void ffi_call_AIX(extended_cif *ecif, unsigned long bytes, + * unsigned int flags, unsigned int *rvalue, + * void (*fn)(), + * void (*prep_args)(extended_cif*, unsigned *const)); + * r3=ecif, r4=bytes, r5=flags, r6=rvalue, r7=fn, r8=prep_args + */ + +.csect .text[PR] + .align 2 + .globl ffi_call_AIX + .globl .ffi_call_AIX +.csect ffi_call_AIX[DS] +ffi_call_AIX: +#ifdef __64BIT__ + .llong .ffi_call_AIX, TOC[tc0], 0 + .csect .text[PR] +.ffi_call_AIX: + /* Save registers we use. */ + mflr r0 + + std r28,-32(r1) + std r29,-24(r1) + std r30,-16(r1) + std r31, -8(r1) + + std r0, 16(r1) + mr r28, r1 /* our AP. */ + stdux r1, r1, r4 + + /* Save arguments over call... */ + mr r31, r5 /* flags, */ + mr r30, r6 /* rvalue, */ + mr r29, r7 /* function address. */ + std r2, 40(r1) + + /* Call ffi_prep_args. */ + mr r4, r1 + bl .ffi_prep_args + nop + + /* Now do the call. */ + ld r0, 0(r29) + ld r2, 8(r29) + ld r11, 16(r29) + /* Set up cr1 with bits 4-7 of the flags. */ + mtcrf 0x40, r31 + mtctr r0 + /* Load all those argument registers. */ + /* We have set up a nice stack frame, just load it into registers. */ + ld r3, 40+(1*8)(r1) + ld r4, 40+(2*8)(r1) + ld r5, 40+(3*8)(r1) + ld r6, 40+(4*8)(r1) + nop + ld r7, 40+(5*8)(r1) + ld r8, 40+(6*8)(r1) + ld r9, 40+(7*8)(r1) + ld r10,40+(8*8)(r1) + +L1: + /* Load all the FP registers. */ + bf 6,L2 /* 2f + 0x18 */ + lfd f1,-32-(13*8)(r28) + lfd f2,-32-(12*8)(r28) + lfd f3,-32-(11*8)(r28) + lfd f4,-32-(10*8)(r28) + nop + lfd f5,-32-(9*8)(r28) + lfd f6,-32-(8*8)(r28) + lfd f7,-32-(7*8)(r28) + lfd f8,-32-(6*8)(r28) + nop + lfd f9,-32-(5*8)(r28) + lfd f10,-32-(4*8)(r28) + lfd f11,-32-(3*8)(r28) + lfd f12,-32-(2*8)(r28) + nop + lfd f13,-32-(1*8)(r28) + +L2: + /* Make the call. */ + bctrl + ld r2, 40(r1) + + /* Now, deal with the return value. */ + mtcrf 0x01, r31 + + bt 30, L(done_return_value) + bt 29, L(fp_return_value) + std r3, 0(r30) + + /* Fall through... */ + +L(done_return_value): + /* Restore the registers we used and return. */ + mr r1, r28 + ld r0, 16(r28) + ld r28, -32(r1) + mtlr r0 + ld r29, -24(r1) + ld r30, -16(r1) + ld r31, -8(r1) + blr + +L(fp_return_value): + bf 28, L(float_return_value) + stfd f1, 0(r30) + bf 31, L(done_return_value) + stfd f2, 8(r30) + b L(done_return_value) +L(float_return_value): + stfs f1, 0(r30) + b L(done_return_value) + +#else /* ! __64BIT__ */ + + .long .ffi_call_AIX, TOC[tc0], 0 + .csect .text[PR] +.ffi_call_AIX: + /* Save registers we use. */ + mflr r0 + + stw r28,-16(r1) + stw r29,-12(r1) + stw r30, -8(r1) + stw r31, -4(r1) + + stw r0, 8(r1) + mr r28, r1 /* out AP. */ + stwux r1, r1, r4 + + /* Save arguments over call... */ + mr r31, r5 /* flags, */ + mr r30, r6 /* rvalue, */ + mr r29, r7 /* function address, */ + stw r2, 20(r1) + + /* Call ffi_prep_args. */ + mr r4, r1 + bl .ffi_prep_args + nop + + /* Now do the call. */ + lwz r0, 0(r29) + lwz r2, 4(r29) + lwz r11, 8(r29) + /* Set up cr1 with bits 4-7 of the flags. */ + mtcrf 0x40, r31 + mtctr r0 + /* Load all those argument registers. */ + /* We have set up a nice stack frame, just load it into registers. */ + lwz r3, 20+(1*4)(r1) + lwz r4, 20+(2*4)(r1) + lwz r5, 20+(3*4)(r1) + lwz r6, 20+(4*4)(r1) + nop + lwz r7, 20+(5*4)(r1) + lwz r8, 20+(6*4)(r1) + lwz r9, 20+(7*4)(r1) + lwz r10,20+(8*4)(r1) + +L1: + /* Load all the FP registers. */ + bf 6,L2 /* 2f + 0x18 */ + lfd f1,-16-(13*8)(r28) + lfd f2,-16-(12*8)(r28) + lfd f3,-16-(11*8)(r28) + lfd f4,-16-(10*8)(r28) + nop + lfd f5,-16-(9*8)(r28) + lfd f6,-16-(8*8)(r28) + lfd f7,-16-(7*8)(r28) + lfd f8,-16-(6*8)(r28) + nop + lfd f9,-16-(5*8)(r28) + lfd f10,-16-(4*8)(r28) + lfd f11,-16-(3*8)(r28) + lfd f12,-16-(2*8)(r28) + nop + lfd f13,-16-(1*8)(r28) + +L2: + /* Make the call. */ + bctrl + lwz r2, 20(r1) + + /* Now, deal with the return value. */ + mtcrf 0x01, r31 + + bt 30, L(done_return_value) + bt 29, L(fp_return_value) + stw r3, 0(r30) + bf 28, L(done_return_value) + stw r4, 4(r30) + + /* Fall through... */ + +L(done_return_value): + /* Restore the registers we used and return. */ + mr r1, r28 + lwz r0, 8(r28) + lwz r28,-16(r1) + mtlr r0 + lwz r29,-12(r1) + lwz r30, -8(r1) + lwz r31, -4(r1) + blr + +L(fp_return_value): + bf 28, L(float_return_value) + stfd f1, 0(r30) + b L(done_return_value) +L(float_return_value): + stfs f1, 0(r30) + b L(done_return_value) +#endif + .long 0 + .byte 0,0,0,1,128,4,0,0 +/* END(ffi_call_AIX) */ + +.csect .text[PR] + .align 2 + .globl ffi_call_DARWIN + .globl .ffi_call_DARWIN +.csect ffi_call_DARWIN[DS] +ffi_call_DARWIN: +#ifdef __64BIT__ + .llong .ffi_call_DARWIN, TOC[tc0], 0 +#else + .long .ffi_call_DARWIN, TOC[tc0], 0 +#endif + .csect .text[PR] +.ffi_call_DARWIN: + blr + .long 0 + .byte 0,0,0,0,0,0,0,0 +/* END(ffi_call_DARWIN) */ diff --git a/user/mpy/lib/libffi/src/powerpc/aix_closure.S b/user/mpy/lib/libffi/src/powerpc/aix_closure.S new file mode 100644 index 0000000..aabd3c3 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/aix_closure.S @@ -0,0 +1,447 @@ +/* ----------------------------------------------------------------------- + aix_closure.S - Copyright (c) 2002, 2003, 2009 Free Software Foundation, Inc. + based on darwin_closure.S + + PowerPC Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + + .set r0,0 + .set r1,1 + .set r2,2 + .set r3,3 + .set r4,4 + .set r5,5 + .set r6,6 + .set r7,7 + .set r8,8 + .set r9,9 + .set r10,10 + .set r11,11 + .set r12,12 + .set r13,13 + .set r14,14 + .set r15,15 + .set r16,16 + .set r17,17 + .set r18,18 + .set r19,19 + .set r20,20 + .set r21,21 + .set r22,22 + .set r23,23 + .set r24,24 + .set r25,25 + .set r26,26 + .set r27,27 + .set r28,28 + .set r29,29 + .set r30,30 + .set r31,31 + .set f0,0 + .set f1,1 + .set f2,2 + .set f3,3 + .set f4,4 + .set f5,5 + .set f6,6 + .set f7,7 + .set f8,8 + .set f9,9 + .set f10,10 + .set f11,11 + .set f12,12 + .set f13,13 + .set f14,14 + .set f15,15 + .set f16,16 + .set f17,17 + .set f18,18 + .set f19,19 + .set f20,20 + .set f21,21 + + .extern .ffi_closure_helper_DARWIN + +#define LIBFFI_ASM +#define JUMPTARGET(name) name +#define L(x) x + .file "aix_closure.S" + .toc +LC..60: + .tc L..60[TC],L..60 + .csect .text[PR] + .align 2 + +.csect .text[PR] + .align 2 + .globl ffi_closure_ASM + .globl .ffi_closure_ASM +.csect ffi_closure_ASM[DS] +ffi_closure_ASM: +#ifdef __64BIT__ + .llong .ffi_closure_ASM, TOC[tc0], 0 + .csect .text[PR] +.ffi_closure_ASM: +/* we want to build up an area for the parameters passed */ +/* in registers (both floating point and integer) */ + + /* we store gpr 3 to gpr 10 (aligned to 4) + in the parents outgoing area */ + std r3, 48+(0*8)(r1) + std r4, 48+(1*8)(r1) + std r5, 48+(2*8)(r1) + std r6, 48+(3*8)(r1) + mflr r0 + + std r7, 48+(4*8)(r1) + std r8, 48+(5*8)(r1) + std r9, 48+(6*8)(r1) + std r10, 48+(7*8)(r1) + std r0, 16(r1) /* save the return address */ + + + /* 48 Bytes (Linkage Area) */ + /* 64 Bytes (params) */ + /* 16 Bytes (result) */ + /* 104 Bytes (13*8 from FPR) */ + /* 8 Bytes (alignment) */ + /* 240 Bytes */ + + stdu r1, -240(r1) /* skip over caller save area + keep stack aligned to 16 */ + + /* next save fpr 1 to fpr 13 (aligned to 8) */ + stfd f1, 128+(0*8)(r1) + stfd f2, 128+(1*8)(r1) + stfd f3, 128+(2*8)(r1) + stfd f4, 128+(3*8)(r1) + stfd f5, 128+(4*8)(r1) + stfd f6, 128+(5*8)(r1) + stfd f7, 128+(6*8)(r1) + stfd f8, 128+(7*8)(r1) + stfd f9, 128+(8*8)(r1) + stfd f10, 128+(9*8)(r1) + stfd f11, 128+(10*8)(r1) + stfd f12, 128+(11*8)(r1) + stfd f13, 128+(12*8)(r1) + + /* set up registers for the routine that actually does the work */ + /* get the context pointer from the trampoline */ + mr r3, r11 + + /* now load up the pointer to the result storage */ + addi r4, r1, 112 + + /* now load up the pointer to the saved gpr registers */ + addi r5, r1, 288 + + /* now load up the pointer to the saved fpr registers */ + addi r6, r1, 128 + + /* make the call */ + bl .ffi_closure_helper_DARWIN + nop + + /* now r3 contains the return type */ + /* so use it to look up in a table */ + /* so we know how to deal with each type */ + + /* look up the proper starting point in table */ + /* by using return type as offset */ + lhz r3, 10(r3) /* load type from return type */ + ld r4, LC..60(2) /* get address of jump table */ + sldi r3, r3, 4 /* now multiply return type by 16 */ + ld r0, 240+16(r1) /* load return address */ + add r3, r3, r4 /* add contents of table to table address */ + mtctr r3 + bctr /* jump to it */ + +/* Each fragment must be exactly 16 bytes long (4 instructions). + Align to 16 byte boundary for cache and dispatch efficiency. */ + .align 4 + +L..60: +/* case FFI_TYPE_VOID */ + mtlr r0 + addi r1, r1, 240 + blr + nop + +/* case FFI_TYPE_INT */ + lwa r3, 112+4(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_FLOAT */ + lfs f1, 112+0(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_DOUBLE */ + lfd f1, 112+0(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_LONGDOUBLE */ + lfd f1, 112+0(r1) + mtlr r0 + lfd f2, 112+8(r1) + b L..finish + +/* case FFI_TYPE_UINT8 */ + lbz r3, 112+7(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_SINT8 */ + lbz r3, 112+7(r1) + mtlr r0 + extsb r3, r3 + b L..finish + +/* case FFI_TYPE_UINT16 */ + lhz r3, 112+6(r1) + mtlr r0 +L..finish: + addi r1, r1, 240 + blr + +/* case FFI_TYPE_SINT16 */ + lha r3, 112+6(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_UINT32 */ + lwz r3, 112+4(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_SINT32 */ + lwa r3, 112+4(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_UINT64 */ + ld r3, 112+0(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_SINT64 */ + ld r3, 112+0(r1) + mtlr r0 + addi r1, r1, 240 + blr + +/* case FFI_TYPE_STRUCT */ + mtlr r0 + addi r1, r1, 240 + blr + nop + +/* case FFI_TYPE_POINTER */ + ld r3, 112+0(r1) + mtlr r0 + addi r1, r1, 240 + blr + +#else /* ! __64BIT__ */ + + .long .ffi_closure_ASM, TOC[tc0], 0 + .csect .text[PR] +.ffi_closure_ASM: +/* we want to build up an area for the parameters passed */ +/* in registers (both floating point and integer) */ + + /* we store gpr 3 to gpr 10 (aligned to 4) + in the parents outgoing area */ + stw r3, 24+(0*4)(r1) + stw r4, 24+(1*4)(r1) + stw r5, 24+(2*4)(r1) + stw r6, 24+(3*4)(r1) + mflr r0 + + stw r7, 24+(4*4)(r1) + stw r8, 24+(5*4)(r1) + stw r9, 24+(6*4)(r1) + stw r10, 24+(7*4)(r1) + stw r0, 8(r1) + + /* 24 Bytes (Linkage Area) */ + /* 32 Bytes (params) */ + /* 16 Bytes (result) */ + /* 104 Bytes (13*8 from FPR) */ + /* 176 Bytes */ + + stwu r1, -176(r1) /* skip over caller save area + keep stack aligned to 16 */ + + /* next save fpr 1 to fpr 13 (aligned to 8) */ + stfd f1, 72+(0*8)(r1) + stfd f2, 72+(1*8)(r1) + stfd f3, 72+(2*8)(r1) + stfd f4, 72+(3*8)(r1) + stfd f5, 72+(4*8)(r1) + stfd f6, 72+(5*8)(r1) + stfd f7, 72+(6*8)(r1) + stfd f8, 72+(7*8)(r1) + stfd f9, 72+(8*8)(r1) + stfd f10, 72+(9*8)(r1) + stfd f11, 72+(10*8)(r1) + stfd f12, 72+(11*8)(r1) + stfd f13, 72+(12*8)(r1) + + /* set up registers for the routine that actually does the work */ + /* get the context pointer from the trampoline */ + mr r3, r11 + + /* now load up the pointer to the result storage */ + addi r4, r1, 56 + + /* now load up the pointer to the saved gpr registers */ + addi r5, r1, 200 + + /* now load up the pointer to the saved fpr registers */ + addi r6, r1, 72 + + /* make the call */ + bl .ffi_closure_helper_DARWIN + nop + + /* now r3 contains the return type */ + /* so use it to look up in a table */ + /* so we know how to deal with each type */ + + /* look up the proper starting point in table */ + /* by using return type as offset */ + lhz r3, 6(r3) /* load type from return type */ + lwz r4, LC..60(2) /* get address of jump table */ + slwi r3, r3, 4 /* now multiply return type by 16 */ + lwz r0, 176+8(r1) /* load return address */ + add r3, r3, r4 /* add contents of table to table address */ + mtctr r3 + bctr /* jump to it */ + +/* Each fragment must be exactly 16 bytes long (4 instructions). + Align to 16 byte boundary for cache and dispatch efficiency. */ + .align 4 + +L..60: +/* case FFI_TYPE_VOID */ + mtlr r0 + addi r1, r1, 176 + blr + nop + +/* case FFI_TYPE_INT */ + lwz r3, 56+0(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_FLOAT */ + lfs f1, 56+0(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_DOUBLE */ + lfd f1, 56+0(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_LONGDOUBLE */ + lfd f1, 56+0(r1) + mtlr r0 + lfd f2, 56+8(r1) + b L..finish + +/* case FFI_TYPE_UINT8 */ + lbz r3, 56+3(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_SINT8 */ + lbz r3, 56+3(r1) + mtlr r0 + extsb r3, r3 + b L..finish + +/* case FFI_TYPE_UINT16 */ + lhz r3, 56+2(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_SINT16 */ + lha r3, 56+2(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_UINT32 */ + lwz r3, 56+0(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_SINT32 */ + lwz r3, 56+0(r1) + mtlr r0 + addi r1, r1, 176 + blr + +/* case FFI_TYPE_UINT64 */ + lwz r3, 56+0(r1) + mtlr r0 + lwz r4, 56+4(r1) + b L..finish + +/* case FFI_TYPE_SINT64 */ + lwz r3, 56+0(r1) + mtlr r0 + lwz r4, 56+4(r1) + b L..finish + +/* case FFI_TYPE_STRUCT */ + mtlr r0 + addi r1, r1, 176 + blr + nop + +/* case FFI_TYPE_POINTER */ + lwz r3, 56+0(r1) + mtlr r0 +L..finish: + addi r1, r1, 176 + blr +#endif +/* END(ffi_closure_ASM) */ diff --git a/user/mpy/lib/libffi/src/powerpc/asm.h b/user/mpy/lib/libffi/src/powerpc/asm.h new file mode 100644 index 0000000..994f62d --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/asm.h @@ -0,0 +1,125 @@ +/* ----------------------------------------------------------------------- + asm.h - Copyright (c) 1998 Geoffrey Keating + + PowerPC Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#define ASM_GLOBAL_DIRECTIVE .globl + + +#define C_SYMBOL_NAME(name) name +/* Macro for a label. */ +#ifdef __STDC__ +#define C_LABEL(name) name##: +#else +#define C_LABEL(name) name/**/: +#endif + +/* This seems to always be the case on PPC. */ +#define ALIGNARG(log2) log2 +/* For ELF we need the `.type' directive to make shared libs work right. */ +#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; +#define ASM_SIZE_DIRECTIVE(name) .size name,.-name + +/* If compiled for profiling, call `_mcount' at the start of each function. */ +#ifdef PROF +/* The mcount code relies on the return address being on the stack + to locate our caller and so it can restore it; so store one just + for its benefit. */ +#ifdef PIC +#define CALL_MCOUNT \ + .pushsection; \ + .section ".data"; \ + .align ALIGNARG(2); \ +0:.long 0; \ + .previous; \ + mflr %r0; \ + stw %r0,4(%r1); \ + bl _GLOBAL_OFFSET_TABLE_@local-4; \ + mflr %r11; \ + lwz %r0,0b@got(%r11); \ + bl JUMPTARGET(_mcount); +#else /* PIC */ +#define CALL_MCOUNT \ + .section ".data"; \ + .align ALIGNARG(2); \ +0:.long 0; \ + .previous; \ + mflr %r0; \ + lis %r11,0b@ha; \ + stw %r0,4(%r1); \ + addi %r0,%r11,0b@l; \ + bl JUMPTARGET(_mcount); +#endif /* PIC */ +#else /* PROF */ +#define CALL_MCOUNT /* Do nothing. */ +#endif /* PROF */ + +#define ENTRY(name) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ + .align ALIGNARG(2); \ + C_LABEL(name) \ + CALL_MCOUNT + +#define EALIGN_W_0 /* No words to insert. */ +#define EALIGN_W_1 nop +#define EALIGN_W_2 nop;nop +#define EALIGN_W_3 nop;nop;nop +#define EALIGN_W_4 EALIGN_W_3;nop +#define EALIGN_W_5 EALIGN_W_4;nop +#define EALIGN_W_6 EALIGN_W_5;nop +#define EALIGN_W_7 EALIGN_W_6;nop + +/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes + past a 2^align boundary. */ +#ifdef PROF +#define EALIGN(name, alignt, words) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ + .align ALIGNARG(2); \ + C_LABEL(name) \ + CALL_MCOUNT \ + b 0f; \ + .align ALIGNARG(alignt); \ + EALIGN_W_##words; \ + 0: +#else /* PROF */ +#define EALIGN(name, alignt, words) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ + .align ALIGNARG(alignt); \ + EALIGN_W_##words; \ + C_LABEL(name) +#endif + +#define END(name) \ + ASM_SIZE_DIRECTIVE(name) + +#ifdef PIC +#define JUMPTARGET(name) name##@plt +#else +#define JUMPTARGET(name) name +#endif + +/* Local labels stripped out by the linker. */ +#define L(x) .L##x diff --git a/user/mpy/lib/libffi/src/powerpc/darwin.S b/user/mpy/lib/libffi/src/powerpc/darwin.S new file mode 100644 index 0000000..066eb82 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/darwin.S @@ -0,0 +1,378 @@ +/* ----------------------------------------------------------------------- + darwin.S - Copyright (c) 2000 John Hornkvist + Copyright (c) 2004, 2010 Free Software Foundation, Inc. + + PowerPC Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#if defined(__ppc64__) +#define MODE_CHOICE(x, y) y +#else +#define MODE_CHOICE(x, y) x +#endif + +#define machine_choice MODE_CHOICE(ppc7400,ppc64) + +; Define some pseudo-opcodes for size-independent load & store of GPRs ... +#define lgu MODE_CHOICE(lwzu, ldu) +#define lg MODE_CHOICE(lwz,ld) +#define sg MODE_CHOICE(stw,std) +#define sgu MODE_CHOICE(stwu,stdu) +#define sgux MODE_CHOICE(stwux,stdux) + +; ... and the size of GPRs and their storage indicator. +#define GPR_BYTES MODE_CHOICE(4,8) +#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ +#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ + +; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. +#define LINKAGE_SIZE MODE_CHOICE(24,48) +#define PARAM_AREA MODE_CHOICE(32,64) +#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ + +/* If there is any FP stuff we make space for all of the regs. */ +#define SAVED_FPR_COUNT 13 +#define FPR_SIZE 8 +#define RESULT_BYTES 16 + +/* This should be kept in step with the same value in ffi_darwin.c. */ +#define ASM_NEEDS_REGISTERS 4 +#define SAVE_REGS_SIZE (ASM_NEEDS_REGISTERS * GPR_BYTES) + +#include +#include + +#define JUMPTARGET(name) name +#define L(x) x + + .text + .align 2 + .globl _ffi_prep_args + + .align 2 + .globl _ffi_call_DARWIN + + /* We arrive here with: + r3 = ptr to extended cif. + r4 = -bytes. + r5 = cif flags. + r6 = ptr to return value. + r7 = fn pointer (user func). + r8 = fn pointer (ffi_prep_args). + r9 = ffi_type* for the ret val. */ + +_ffi_call_DARWIN: +Lstartcode: + mr r12,r8 /* We only need r12 until the call, + so it does not have to be saved. */ +LFB1: + /* Save the old stack pointer as AP. */ + mr r8,r1 +LCFI0: + + /* Save the retval type in parents frame. */ + sg r9,(LINKAGE_SIZE+6*GPR_BYTES)(r8) + + /* Allocate the stack space we need. */ + sgux r1,r1,r4 + + /* Save registers we use. */ + mflr r9 + sg r9,SAVED_LR_OFFSET(r8) + + sg r28,-(4 * GPR_BYTES)(r8) + sg r29,-(3 * GPR_BYTES)(r8) + sg r30,-(2 * GPR_BYTES)(r8) + sg r31,-( GPR_BYTES)(r8) + +#if !defined(POWERPC_DARWIN) + /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */ + sg r2,(5 * GPR_BYTES)(r1) +#endif + +LCFI1: + + /* Save arguments over call. */ + mr r31,r5 /* flags, */ + mr r30,r6 /* rvalue, */ + mr r29,r7 /* function address, */ + mr r28,r8 /* our AP. */ +LCFI2: + /* Call ffi_prep_args. r3 = extended cif, r4 = stack ptr copy. */ + mr r4,r1 + li r9,0 + + mtctr r12 /* r12 holds address of _ffi_prep_args. */ + bctrl + +#if !defined(POWERPC_DARWIN) + /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */ + lg r2,(5 * GPR_BYTES)(r1) +#endif + /* Now do the call. + Set up cr1 with bits 4-7 of the flags. */ + mtcrf 0x40,r31 + /* Get the address to call into CTR. */ + mtctr r29 + /* Load all those argument registers. + We have set up a nice stack frame, just load it into registers. */ + lg r3, (LINKAGE_SIZE )(r1) + lg r4, (LINKAGE_SIZE + GPR_BYTES)(r1) + lg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r1) + lg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r1) + nop + lg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r1) + lg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r1) + lg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r1) + lg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r1) + +L1: + /* ... Load all the FP registers. */ + bf 6,L2 /* No floats to load. */ + lfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28) + lfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28) + lfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28) + lfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28) + nop + lfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28) + lfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28) + lfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28) + lfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28) + nop + lfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28) + lfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28) + lfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28) + lfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28) + nop + lfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28) + +L2: + mr r12,r29 /* Put the target address in r12 as specified. */ + mtctr r12 + nop + nop + + /* Make the call. */ + bctrl + + /* Now, deal with the return value. */ + + /* m64 structure returns can occupy the same set of registers as + would be used to pass such a structure as arg0 - so take care + not to step on any possibly hot regs. */ + + /* Get the flags.. */ + mtcrf 0x03,r31 ; we need c6 & cr7 now. + ; FLAG_RETURNS_NOTHING also covers struct ret-by-ref. + bt 30,L(done_return_value) ; FLAG_RETURNS_NOTHING + bf 27,L(scalar_return_value) ; not FLAG_RETURNS_STRUCT + + /* OK, so we have a struct. */ +#if defined(__ppc64__) + bt 31,L(maybe_return_128) ; FLAG_RETURNS_128BITS, special case + + /* OK, we have to map the return back to a mem struct. + We are about to trample the parents param area, so recover the + return type. r29 is free, since the call is done. */ + lg r29,(LINKAGE_SIZE + 6 * GPR_BYTES)(r28) + + sg r3, (LINKAGE_SIZE )(r28) + sg r4, (LINKAGE_SIZE + GPR_BYTES)(r28) + sg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r28) + sg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r28) + nop + sg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r28) + sg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r28) + sg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r28) + sg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28) + /* OK, so do the block move - we trust that memcpy will not trample + the fprs... */ + mr r3,r30 ; dest + addi r4,r28,LINKAGE_SIZE ; source + /* The size is a size_t, should be long. */ + lg r5,0(r29) + /* Figure out small structs */ + cmpi 0,r5,4 + bgt L3 ; 1, 2 and 4 bytes have special rules. + cmpi 0,r5,3 + beq L3 ; not 3 + addi r4,r4,8 + subf r4,r5,r4 +L3: + bl _memcpy + + /* ... do we need the FP registers? - recover the flags.. */ + mtcrf 0x03,r31 ; we need c6 & cr7 now. + bf 29,L(done_return_value) /* No floats in the struct. */ + stfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28) + stfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28) + stfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28) + stfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28) + nop + stfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28) + stfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28) + stfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28) + stfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28) + nop + stfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28) + stfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28) + stfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28) + stfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28) + nop + stfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28) + + mr r3,r29 ; ffi_type * + mr r4,r30 ; dest + addi r5,r28,-SAVE_REGS_SIZE-(13*FPR_SIZE) ; fprs + xor r6,r6,r6 + sg r6,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28) + addi r6,r28,(LINKAGE_SIZE + 7 * GPR_BYTES) ; point to a zeroed counter. + bl _darwin64_struct_floats_to_mem + + b L(done_return_value) +#else + stw r3,0(r30) ; m32 the only struct return in reg is 4 bytes. +#endif + b L(done_return_value) + +L(fp_return_value): + /* Do we have long double to store? */ + bf 31,L(fd_return_value) ; FLAG_RETURNS_128BITS + stfd f1,0(r30) + stfd f2,FPR_SIZE(r30) + b L(done_return_value) + +L(fd_return_value): + /* Do we have double to store? */ + bf 28,L(float_return_value) + stfd f1,0(r30) + b L(done_return_value) + +L(float_return_value): + /* We only have a float to store. */ + stfs f1,0(r30) + b L(done_return_value) + +L(scalar_return_value): + bt 29,L(fp_return_value) ; FLAG_RETURNS_FP + ; ffi_arg is defined as unsigned long. + sg r3,0(r30) ; Save the reg. + bf 28,L(done_return_value) ; not FLAG_RETURNS_64BITS + +#if defined(__ppc64__) +L(maybe_return_128): + std r3,0(r30) + bf 31,L(done_return_value) ; not FLAG_RETURNS_128BITS + std r4,8(r30) +#else + stw r4,4(r30) +#endif + + /* Fall through. */ + /* We want this at the end to simplify eh epilog computation. */ + +L(done_return_value): + /* Restore the registers we used and return. */ + lg r29,SAVED_LR_OFFSET(r28) + ; epilog + lg r31,-(1 * GPR_BYTES)(r28) + mtlr r29 + lg r30,-(2 * GPR_BYTES)(r28) + lg r29,-(3 * GPR_BYTES)(r28) + lg r28,-(4 * GPR_BYTES)(r28) + lg r1,0(r1) + blr +LFE1: + .align 1 +/* END(_ffi_call_DARWIN) */ + +/* Provide a null definition of _ffi_call_AIX. */ + .text + .globl _ffi_call_AIX + .align 2 +_ffi_call_AIX: + blr +/* END(_ffi_call_AIX) */ + +/* EH stuff. */ + +#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) + + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +EH_frame1: + .set L$set$0,LECIE1-LSCIE1 + .long L$set$0 ; Length of Common Information Entry +LSCIE1: + .long 0x0 ; CIE Identifier Tag + .byte 0x1 ; CIE Version + .ascii "zR\0" ; CIE Augmentation + .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor + .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor + .byte 0x41 ; CIE RA Column + .byte 0x1 ; uleb128 0x1; Augmentation size + .byte 0x10 ; FDE Encoding (pcrel) + .byte 0xc ; DW_CFA_def_cfa + .byte 0x1 ; uleb128 0x1 + .byte 0x0 ; uleb128 0x0 + .align LOG2_GPR_BYTES +LECIE1: + + .globl _ffi_call_DARWIN.eh +_ffi_call_DARWIN.eh: +LSFDE1: + .set L$set$1,LEFDE1-LASFDE1 + .long L$set$1 ; FDE Length +LASFDE1: + .long LASFDE1-EH_frame1 ; FDE CIE offset + .g_long Lstartcode-. ; FDE initial location + .set L$set$3,LFE1-Lstartcode + .g_long L$set$3 ; FDE address range + .byte 0x0 ; uleb128 0x0; Augmentation size + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$4,LCFI0-Lstartcode + .long L$set$4 + .byte 0xd ; DW_CFA_def_cfa_register + .byte 0x08 ; uleb128 0x08 + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$5,LCFI1-LCFI0 + .long L$set$5 + .byte 0x11 ; DW_CFA_offset_extended_sf + .byte 0x41 ; uleb128 0x41 + .byte 0x7e ; sleb128 -2 + .byte 0x9f ; DW_CFA_offset, column 0x1f + .byte 0x1 ; uleb128 0x1 + .byte 0x9e ; DW_CFA_offset, column 0x1e + .byte 0x2 ; uleb128 0x2 + .byte 0x9d ; DW_CFA_offset, column 0x1d + .byte 0x3 ; uleb128 0x3 + .byte 0x9c ; DW_CFA_offset, column 0x1c + .byte 0x4 ; uleb128 0x4 + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$6,LCFI2-LCFI1 + .long L$set$6 + .byte 0xd ; DW_CFA_def_cfa_register + .byte 0x1c ; uleb128 0x1c + .align LOG2_GPR_BYTES +LEFDE1: + .align 1 + diff --git a/user/mpy/lib/libffi/src/powerpc/darwin_closure.S b/user/mpy/lib/libffi/src/powerpc/darwin_closure.S new file mode 100644 index 0000000..c7734d4 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/darwin_closure.S @@ -0,0 +1,571 @@ +/* ----------------------------------------------------------------------- + darwin_closure.S - Copyright (c) 2002, 2003, 2004, 2010, + Free Software Foundation, Inc. + based on ppc_closure.S + + PowerPC Assembly glue. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#define L(x) x + +#if defined(__ppc64__) +#define MODE_CHOICE(x, y) y +#else +#define MODE_CHOICE(x, y) x +#endif + +#define machine_choice MODE_CHOICE(ppc7400,ppc64) + +; Define some pseudo-opcodes for size-independent load & store of GPRs ... +#define lgu MODE_CHOICE(lwzu, ldu) +#define lg MODE_CHOICE(lwz,ld) +#define sg MODE_CHOICE(stw,std) +#define sgu MODE_CHOICE(stwu,stdu) + +; ... and the size of GPRs and their storage indicator. +#define GPR_BYTES MODE_CHOICE(4,8) +#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ +#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ + +; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. +#define LINKAGE_SIZE MODE_CHOICE(24,48) +#define PARAM_AREA MODE_CHOICE(32,64) + +#define SAVED_CR_OFFSET MODE_CHOICE(4,8) /* save position for CR */ +#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ + +/* WARNING: if ffi_type is changed... here be monsters. + Offsets of items within the result type. */ +#define FFI_TYPE_TYPE MODE_CHOICE(6,10) +#define FFI_TYPE_ELEM MODE_CHOICE(8,16) + +#define SAVED_FPR_COUNT 13 +#define FPR_SIZE 8 +/* biggest m64 struct ret is 8GPRS + 13FPRS = 168 bytes - rounded to 16bytes = 176. */ +#define RESULT_BYTES MODE_CHOICE(16,176) + +; The whole stack frame **MUST** be 16byte-aligned. +#define SAVE_SIZE (((LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)+15) & -16LL) +#define PAD_SIZE (SAVE_SIZE-(LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)) + +#define PARENT_PARM_BASE (SAVE_SIZE+LINKAGE_SIZE) +#define FP_SAVE_BASE (LINKAGE_SIZE+PARAM_AREA) + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 +; We no longer need the pic symbol stub for Darwin >= 9. +#define BLCLS_HELP _ffi_closure_helper_DARWIN +#define STRUCT_RETVALUE_P _darwin64_struct_ret_by_value_p +#define PASS_STR_FLOATS _darwin64_pass_struct_floats +#undef WANT_STUB +#else +#define BLCLS_HELP L_ffi_closure_helper_DARWIN$stub +#define STRUCT_RETVALUE_P L_darwin64_struct_ret_by_value_p$stub +#define PASS_STR_FLOATS L_darwin64_pass_struct_floats$stub +#define WANT_STUB +#endif + +/* m32/m64 + + The stack layout looks like this: + + | Additional params... | | Higher address + ~ ~ ~ + | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS + |--------------------------------------------| | + | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | + |--------------------------------------------| | + | Reserved 2*4/8 | | + |--------------------------------------------| | + | Space for callee`s LR 4/8 | | + |--------------------------------------------| | + | Saved CR [low word for m64] 4/8 | | + |--------------------------------------------| | + | Current backchain pointer 4/8 |-/ Parent`s frame. + |--------------------------------------------| <+ <<< on entry to + | Result Bytes 16/176 | | + |--------------------------------------------| | + ~ padding to 16-byte alignment ~ ~ + |--------------------------------------------| | + | NUM_FPR_ARG_REGISTERS slots | | + | here fp13 .. fp1 13*8 | | + |--------------------------------------------| | + | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS + |--------------------------------------------| | + | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | + |--------------------------------------------| | stack | + | Reserved [compiler,binder] 2*4/8 | | grows | + |--------------------------------------------| | down V + | Space for callees LR 4/8 | | + |--------------------------------------------| | lower addresses + | Saved CR [low word for m64] 4/8 | | + |--------------------------------------------| | stack pointer here + | Current backchain pointer 4/8 |-/ during + |--------------------------------------------| <<< call. + +*/ + + .file "darwin_closure.S" + + .machine machine_choice + + .text + .globl _ffi_closure_ASM + .align LOG2_GPR_BYTES +_ffi_closure_ASM: +LFB1: +Lstartcode: + mflr r0 /* extract return address */ + sg r0,SAVED_LR_OFFSET(r1) /* save the return address */ +LCFI0: + sgu r1,-SAVE_SIZE(r1) /* skip over caller save area + keep stack aligned to 16. */ +LCFI1: + /* We want to build up an area for the parameters passed + in registers. (both floating point and integer) */ + + /* Put gpr 3 to gpr 10 in the parents outgoing area... + ... the remainder of any params that overflowed the regs will + follow here. */ + sg r3, (PARENT_PARM_BASE )(r1) + sg r4, (PARENT_PARM_BASE + GPR_BYTES )(r1) + sg r5, (PARENT_PARM_BASE + GPR_BYTES * 2)(r1) + sg r6, (PARENT_PARM_BASE + GPR_BYTES * 3)(r1) + sg r7, (PARENT_PARM_BASE + GPR_BYTES * 4)(r1) + sg r8, (PARENT_PARM_BASE + GPR_BYTES * 5)(r1) + sg r9, (PARENT_PARM_BASE + GPR_BYTES * 6)(r1) + sg r10,(PARENT_PARM_BASE + GPR_BYTES * 7)(r1) + + /* We save fpr 1 to fpr 14 in our own save frame. */ + stfd f1, (FP_SAVE_BASE )(r1) + stfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1) + stfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1) + stfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1) + stfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1) + stfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1) + stfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1) + stfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1) + stfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1) + stfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1) + stfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1) + stfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1) + stfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1) + + /* Set up registers for the routine that actually does the work + get the context pointer from the trampoline. */ + mr r3,r11 + + /* Now load up the pointer to the result storage. */ + addi r4,r1,(SAVE_SIZE-RESULT_BYTES) + + /* Now load up the pointer to the saved gpr registers. */ + addi r5,r1,PARENT_PARM_BASE + + /* Now load up the pointer to the saved fpr registers. */ + addi r6,r1,FP_SAVE_BASE + + /* Make the call. */ + bl BLCLS_HELP + + /* r3 contains the rtype pointer... save it since we will need + it later. */ + sg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type + lg r0,0(r3) ; size => r0 + lhz r3,FFI_TYPE_TYPE(r3) ; type => r3 + + /* The helper will have intercepted structure returns and inserted + the caller`s destination address for structs returned by ref. */ + + /* r3 contains the return type so use it to look up in a table + so we know how to deal with each type. */ + + addi r5,r1,(SAVE_SIZE-RESULT_BYTES) /* Otherwise, our return is here. */ + bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */ + mflr r4 /* Move to r4. */ + slwi r3,r3,4 /* Now multiply return type by 16. */ + add r3,r3,r4 /* Add contents of table to table address. */ + mtctr r3 + bctr /* Jump to it. */ +LFE1: +/* Each of the ret_typeX code fragments has to be exactly 16 bytes long + (4 instructions). For cache effectiveness we align to a 16 byte boundary + first. */ + + .align 4 + + nop + nop + nop +Lget_ret_type0_addr: + blrl + +/* case FFI_TYPE_VOID */ +Lret_type0: + b Lfinish + nop + nop + nop + +/* case FFI_TYPE_INT */ +Lret_type1: + lg r3,0(r5) + b Lfinish + nop + nop + +/* case FFI_TYPE_FLOAT */ +Lret_type2: + lfs f1,0(r5) + b Lfinish + nop + nop + +/* case FFI_TYPE_DOUBLE */ +Lret_type3: + lfd f1,0(r5) + b Lfinish + nop + nop + +/* case FFI_TYPE_LONGDOUBLE */ +Lret_type4: + lfd f1,0(r5) + lfd f2,8(r5) + b Lfinish + nop + +/* case FFI_TYPE_UINT8 */ +Lret_type5: +#if defined(__ppc64__) + lbz r3,7(r5) +#else + lbz r3,3(r5) +#endif + b Lfinish + nop + nop + +/* case FFI_TYPE_SINT8 */ +Lret_type6: +#if defined(__ppc64__) + lbz r3,7(r5) +#else + lbz r3,3(r5) +#endif + extsb r3,r3 + b Lfinish + nop + +/* case FFI_TYPE_UINT16 */ +Lret_type7: +#if defined(__ppc64__) + lhz r3,6(r5) +#else + lhz r3,2(r5) +#endif + b Lfinish + nop + nop + +/* case FFI_TYPE_SINT16 */ +Lret_type8: +#if defined(__ppc64__) + lha r3,6(r5) +#else + lha r3,2(r5) +#endif + b Lfinish + nop + nop + +/* case FFI_TYPE_UINT32 */ +Lret_type9: +#if defined(__ppc64__) + lwz r3,4(r5) +#else + lwz r3,0(r5) +#endif + b Lfinish + nop + nop + +/* case FFI_TYPE_SINT32 */ +Lret_type10: +#if defined(__ppc64__) + lwz r3,4(r5) +#else + lwz r3,0(r5) +#endif + b Lfinish + nop + nop + +/* case FFI_TYPE_UINT64 */ +Lret_type11: +#if defined(__ppc64__) + lg r3,0(r5) + b Lfinish + nop +#else + lwz r3,0(r5) + lwz r4,4(r5) + b Lfinish +#endif + nop + +/* case FFI_TYPE_SINT64 */ +Lret_type12: +#if defined(__ppc64__) + lg r3,0(r5) + b Lfinish + nop +#else + lwz r3,0(r5) + lwz r4,4(r5) + b Lfinish +#endif + nop + +/* case FFI_TYPE_STRUCT */ +Lret_type13: +#if defined(__ppc64__) + lg r3,0(r5) ; we need at least this... + cmpi 0,r0,4 + bgt Lstructend ; not a special small case + b Lsmallstruct ; see if we need more. +#else + cmpi 0,r0,4 + bgt Lfinish ; not by value + lg r3,0(r5) + b Lfinish +#endif +/* case FFI_TYPE_POINTER */ +Lret_type14: + lg r3,0(r5) + b Lfinish + nop + nop + +#if defined(__ppc64__) +Lsmallstruct: + beq Lfour ; continuation of Lret13. + cmpi 0,r0,3 + beq Lfinish ; don`t adjust this - can`t be any floats here... + srdi r3,r3,48 + cmpi 0,r0,2 + beq Lfinish ; .. or here .. + srdi r3,r3,8 + b Lfinish ; .. or here. + +Lfour: + lg r6,LINKAGE_SIZE(r1) ; get the result type + lg r6,FFI_TYPE_ELEM(r6) ; elements array pointer + lg r6,0(r6) ; first element + lhz r0,FFI_TYPE_TYPE(r6) ; OK go the type + cmpi 0,r0,2 ; FFI_TYPE_FLOAT + bne Lfourint + lfs f1,0(r5) ; just one float in the struct. + b Lfinish + +Lfourint: + srdi r3,r3,32 ; four bytes. + b Lfinish + +Lstructend: + lg r3,LINKAGE_SIZE(r1) ; get the result type + bl STRUCT_RETVALUE_P + cmpi 0,r3,0 + beq Lfinish ; nope. + /* Recover a pointer to the results. */ + addi r11,r1,(SAVE_SIZE-RESULT_BYTES) + lg r3,0(r11) ; we need at least this... + lg r4,8(r11) + cmpi 0,r0,16 + beq Lfinish ; special case 16 bytes we don't consider floats. + + /* OK, frustratingly, the process of saving the struct to mem might have + messed with the FPRs, so we have to re-load them :(. + We`ll use our FPRs space again - calling: + void darwin64_pass_struct_floats (ffi_type *s, char *src, + unsigned *nfpr, double **fprs) + We`ll temporarily pinch the first two slots of the param area for local + vars used by the routine. */ + xor r6,r6,r6 + addi r5,r1,PARENT_PARM_BASE ; some space + sg r6,0(r5) ; *nfpr zeroed. + addi r6,r5,8 ; **fprs + addi r3,r1,FP_SAVE_BASE ; pointer to FPRs space + sg r3,0(r6) + mr r4,r11 ; the struct is here... + lg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type. + bl PASS_STR_FLOATS ; get struct floats into FPR save space. + /* See if we used any floats */ + lwz r0,(SAVE_SIZE-RESULT_BYTES)(r1) + cmpi 0,r0,0 + beq Lstructints ; nope. + /* OK load `em up... */ + lfd f1, (FP_SAVE_BASE )(r1) + lfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1) + lfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1) + lfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1) + lfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1) + lfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1) + lfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1) + lfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1) + lfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1) + lfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1) + lfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1) + lfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1) + lfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1) + + /* point back at our saved struct. */ +Lstructints: + addi r11,r1,(SAVE_SIZE-RESULT_BYTES) + lg r3,0(r11) ; we end up picking the + lg r4,8(r11) ; first two again. + lg r5,16(r11) + lg r6,24(r11) + lg r7,32(r11) + lg r8,40(r11) + lg r9,48(r11) + lg r10,56(r11) +#endif + +/* case done */ +Lfinish: + addi r1,r1,SAVE_SIZE /* Restore stack pointer. */ + lg r0,SAVED_LR_OFFSET(r1) /* Get return address. */ + mtlr r0 /* Reset link register. */ + blr +Lendcode: + .align 1 + +/* END(ffi_closure_ASM) */ + +/* EH frame stuff. */ +#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) +/* 176, 400 */ +#define EH_FRAME_OFFSETA MODE_CHOICE(176,0x90) +#define EH_FRAME_OFFSETB MODE_CHOICE(1,3) + + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +EH_frame1: + .set L$set$0,LECIE1-LSCIE1 + .long L$set$0 ; Length of Common Information Entry +LSCIE1: + .long 0x0 ; CIE Identifier Tag + .byte 0x1 ; CIE Version + .ascii "zR\0" ; CIE Augmentation + .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor + .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor + .byte 0x41 ; CIE RA Column + .byte 0x1 ; uleb128 0x1; Augmentation size + .byte 0x10 ; FDE Encoding (pcrel) + .byte 0xc ; DW_CFA_def_cfa + .byte 0x1 ; uleb128 0x1 + .byte 0x0 ; uleb128 0x0 + .align LOG2_GPR_BYTES +LECIE1: + .globl _ffi_closure_ASM.eh +_ffi_closure_ASM.eh: +LSFDE1: + .set L$set$1,LEFDE1-LASFDE1 + .long L$set$1 ; FDE Length + +LASFDE1: + .long LASFDE1-EH_frame1 ; FDE CIE offset + .g_long Lstartcode-. ; FDE initial location + .set L$set$3,LFE1-Lstartcode + .g_long L$set$3 ; FDE address range + .byte 0x0 ; uleb128 0x0; Augmentation size + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$3,LCFI1-LCFI0 + .long L$set$3 + .byte 0xe ; DW_CFA_def_cfa_offset + .byte EH_FRAME_OFFSETA,EH_FRAME_OFFSETB ; uleb128 176,1/190,3 + .byte 0x4 ; DW_CFA_advance_loc4 + .set L$set$4,LCFI0-Lstartcode + .long L$set$4 + .byte 0x11 ; DW_CFA_offset_extended_sf + .byte 0x41 ; uleb128 0x41 + .byte 0x7e ; sleb128 -2 + .align LOG2_GPR_BYTES +LEFDE1: + .align 1 + +#ifdef WANT_STUB + .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 + .align 5 +L_ffi_closure_helper_DARWIN$stub: + .indirect_symbol _ffi_closure_helper_DARWIN + mflr r0 + bcl 20,31,"L1$spb" +"L1$spb": + mflr r11 + addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb") + mtlr r0 + lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb")(r11) + mtctr r12 + bctr + .lazy_symbol_pointer +L_ffi_closure_helper_DARWIN$lazy_ptr: + .indirect_symbol _ffi_closure_helper_DARWIN + .g_long dyld_stub_binding_helper + +#if defined(__ppc64__) + .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 + .align 5 +L_darwin64_struct_ret_by_value_p$stub: + .indirect_symbol _darwin64_struct_ret_by_value_p + mflr r0 + bcl 20,31,"L2$spb" +"L2$spb": + mflr r11 + addis r11,r11,ha16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb") + mtlr r0 + lwzu r12,lo16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb")(r11) + mtctr r12 + bctr + .lazy_symbol_pointer +L_darwin64_struct_ret_by_value_p$lazy_ptr: + .indirect_symbol _darwin64_struct_ret_by_value_p + .g_long dyld_stub_binding_helper + + .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 + .align 5 +L_darwin64_pass_struct_floats$stub: + .indirect_symbol _darwin64_pass_struct_floats + mflr r0 + bcl 20,31,"L3$spb" +"L3$spb": + mflr r11 + addis r11,r11,ha16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb") + mtlr r0 + lwzu r12,lo16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb")(r11) + mtctr r12 + bctr + .lazy_symbol_pointer +L_darwin64_pass_struct_floats$lazy_ptr: + .indirect_symbol _darwin64_pass_struct_floats + .g_long dyld_stub_binding_helper +# endif +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ffi.c b/user/mpy/lib/libffi/src/powerpc/ffi.c new file mode 100644 index 0000000..7eb543e --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ffi.c @@ -0,0 +1,173 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (C) 2013 IBM + Copyright (C) 2011 Anthony Green + Copyright (C) 2011 Kyle Moffett + Copyright (C) 2008 Red Hat, Inc + Copyright (C) 2007, 2008 Free Software Foundation, Inc + Copyright (c) 1998 Geoffrey Keating + + PowerPC Foreign Function Interface + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#include "ffi.h" +#include "ffi_common.h" +#include "ffi_powerpc.h" + +#if HAVE_LONG_DOUBLE_VARIANT +/* Adjust ffi_type_longdouble. */ +void FFI_HIDDEN +ffi_prep_types (ffi_abi abi) +{ +# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +# ifdef POWERPC64 + ffi_prep_types_linux64 (abi); +# else + ffi_prep_types_sysv (abi); +# endif +# endif +} +#endif + +/* Perform machine dependent cif processing */ +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep (ffi_cif *cif) +{ +#ifdef POWERPC64 + return ffi_prep_cif_linux64 (cif); +#else + return ffi_prep_cif_sysv (cif); +#endif +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep_var (ffi_cif *cif, + unsigned int nfixedargs MAYBE_UNUSED, + unsigned int ntotalargs MAYBE_UNUSED) +{ +#ifdef POWERPC64 + return ffi_prep_cif_linux64_var (cif, nfixedargs, ntotalargs); +#else + return ffi_prep_cif_sysv (cif); +#endif +} + +static void +ffi_call_int (ffi_cif *cif, + void (*fn) (void), + void *rvalue, + void **avalue, + void *closure) +{ + /* The final SYSV ABI says that structures smaller or equal 8 bytes + are returned in r3/r4. A draft ABI used by linux instead returns + them in memory. + + We bounce-buffer SYSV small struct return values so that sysv.S + can write r3 and r4 to memory without worrying about struct size. + + For ELFv2 ABI, use a bounce buffer for homogeneous structs too, + for similar reasons. */ + unsigned long smst_buffer[8]; + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + ecif.rvalue = rvalue; + if ((cif->flags & FLAG_RETURNS_SMST) != 0) + ecif.rvalue = smst_buffer; + /* Ensure that we have a valid struct return value. + FIXME: Isn't this just papering over a user problem? */ + else if (!rvalue && cif->rtype->type == FFI_TYPE_STRUCT) + ecif.rvalue = alloca (cif->rtype->size); + +#ifdef POWERPC64 + ffi_call_LINUX64 (&ecif, fn, ecif.rvalue, cif->flags, closure, + -(long) cif->bytes); +#else + ffi_call_SYSV (&ecif, fn, ecif.rvalue, cif->flags, closure, -cif->bytes); +#endif + + /* Check for a bounce-buffered return value */ + if (rvalue && ecif.rvalue == smst_buffer) + { + unsigned int rsize = cif->rtype->size; +#ifndef __LITTLE_ENDIAN__ + /* The SYSV ABI returns a structure of up to 4 bytes in size + left-padded in r3. */ +# ifndef POWERPC64 + if (rsize <= 4) + memcpy (rvalue, (char *) smst_buffer + 4 - rsize, rsize); + else +# endif + /* The SYSV ABI returns a structure of up to 8 bytes in size + left-padded in r3/r4, and the ELFv2 ABI similarly returns a + structure of up to 8 bytes in size left-padded in r3. */ + if (rsize <= 8) + memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize); + else +#endif + memcpy (rvalue, smst_buffer, rsize); + } +} + +void +ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue, + void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + void *codeloc) +{ +#ifdef POWERPC64 + return ffi_prep_closure_loc_linux64 (closure, cif, fun, user_data, codeloc); +#else + return ffi_prep_closure_loc_sysv (closure, cif, fun, user_data, codeloc); +#endif +} + +ffi_status +ffi_prep_go_closure (ffi_go_closure *closure, + ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *)) +{ +#ifdef POWERPC64 + closure->tramp = ffi_go_closure_linux64; +#else + closure->tramp = ffi_go_closure_sysv; +#endif + closure->cif = cif; + closure->fun = fun; + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_darwin.c b/user/mpy/lib/libffi/src/powerpc/ffi_darwin.c new file mode 100644 index 0000000..cf6fb6d --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ffi_darwin.c @@ -0,0 +1,1359 @@ +/* ----------------------------------------------------------------------- + ffi_darwin.c + + Copyright (C) 1998 Geoffrey Keating + Copyright (C) 2001 John Hornkvist + Copyright (C) 2002, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + + FFI support for Darwin and AIX. + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +extern void ffi_closure_ASM (void); + +enum { + /* The assembly depends on these exact flags. + For Darwin64 (when FLAG_RETURNS_STRUCT is set): + FLAG_RETURNS_FP indicates that the structure embeds FP data. + FLAG_RETURNS_128BITS signals a special struct size that is not + expanded for float content. */ + FLAG_RETURNS_128BITS = 1 << (31-31), /* These go in cr7 */ + FLAG_RETURNS_NOTHING = 1 << (31-30), + FLAG_RETURNS_FP = 1 << (31-29), + FLAG_RETURNS_64BITS = 1 << (31-28), + + FLAG_RETURNS_STRUCT = 1 << (31-27), /* This goes in cr6 */ + + FLAG_ARG_NEEDS_COPY = 1 << (31- 7), + FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ + FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), + FLAG_RETVAL_REFERENCE = 1 << (31- 4) +}; + +/* About the DARWIN ABI. */ +enum { + NUM_GPR_ARG_REGISTERS = 8, + NUM_FPR_ARG_REGISTERS = 13, + LINKAGE_AREA_GPRS = 6 +}; + +enum { ASM_NEEDS_REGISTERS = 4 }; /* r28-r31 */ + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments. + + m32/m64 + + The stack layout we want looks like this: + + | Return address from ffi_call_DARWIN | higher addresses + |--------------------------------------------| + | Previous backchain pointer 4/8 | stack pointer here + |--------------------------------------------|<+ <<< on entry to + | ASM_NEEDS_REGISTERS=r28-r31 4*(4/8) | | ffi_call_DARWIN + |--------------------------------------------| | + | When we have any FP activity... the | | + | FPRs occupy NUM_FPR_ARG_REGISTERS slots | | + | here fp13 .. fp1 from high to low addr. | | + ~ ~ ~ + | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS + |--------------------------------------------| | + | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | + |--------------------------------------------| | stack | + | Reserved 2*4/8 | | grows | + |--------------------------------------------| | down V + | Space for callee's LR 4/8 | | + |--------------------------------------------| | lower addresses + | Saved CR [low word for m64] 4/8 | | + |--------------------------------------------| | stack pointer here + | Current backchain pointer 4/8 |-/ during + |--------------------------------------------| <<< ffi_call_DARWIN + + */ + +#if defined(POWERPC_DARWIN64) +static void +darwin64_pass_struct_by_value + (ffi_type *, char *, unsigned, unsigned *, double **, unsigned long **); +#endif + +/* This depends on GPR_SIZE = sizeof (unsigned long) */ + +void +ffi_prep_args (extended_cif *ecif, unsigned long *const stack) +{ + const unsigned bytes = ecif->cif->bytes; + const unsigned flags = ecif->cif->flags; + const unsigned nargs = ecif->cif->nargs; +#if !defined(POWERPC_DARWIN64) + const ffi_abi abi = ecif->cif->abi; +#endif + + /* 'stacktop' points at the previous backchain pointer. */ + unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long)); + + /* 'fpr_base' points at the space for fpr1, and grows upwards as + we use FPR registers. */ + double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS; + int gp_count = 0, fparg_count = 0; + + /* 'next_arg' grows up as we put parameters in it. */ + unsigned long *next_arg = stack + LINKAGE_AREA_GPRS; /* 6 reserved positions. */ + + int i; + double double_tmp; + void **p_argv = ecif->avalue; + unsigned long gprvalue; + ffi_type** ptr = ecif->cif->arg_types; +#if !defined(POWERPC_DARWIN64) + char *dest_cpy; +#endif + unsigned size_al = 0; + + /* Check that everything starts aligned properly. */ + FFI_ASSERT(((unsigned) (char *) stack & 0xF) == 0); + FFI_ASSERT(((unsigned) (char *) stacktop & 0xF) == 0); + FFI_ASSERT((bytes & 0xF) == 0); + + /* Deal with return values that are actually pass-by-reference. + Rule: + Return values are referenced by r3, so r4 is the first parameter. */ + + if (flags & FLAG_RETVAL_REFERENCE) + *next_arg++ = (unsigned long) (char *) ecif->rvalue; + + /* Now for the arguments. */ + for (i = nargs; i > 0; i--, ptr++, p_argv++) + { + switch ((*ptr)->type) + { + /* If a floating-point parameter appears before all of the general- + purpose registers are filled, the corresponding GPRs that match + the size of the floating-point parameter are skipped. */ + case FFI_TYPE_FLOAT: + double_tmp = *(float *) *p_argv; + if (fparg_count < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = double_tmp; +#if defined(POWERPC_DARWIN) + *(float *)next_arg = *(float *) *p_argv; +#else + *(double *)next_arg = double_tmp; +#endif + next_arg++; + gp_count++; + fparg_count++; + FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); + break; + + case FFI_TYPE_DOUBLE: + double_tmp = *(double *) *p_argv; + if (fparg_count < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = double_tmp; + *(double *)next_arg = double_tmp; +#ifdef POWERPC64 + next_arg++; + gp_count++; +#else + next_arg += 2; + gp_count += 2; +#endif + fparg_count++; + FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); + break; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + + case FFI_TYPE_LONGDOUBLE: +# if defined(POWERPC64) && !defined(POWERPC_DARWIN64) + /* ??? This will exceed the regs count when the value starts at fp13 + and it will not put the extra bit on the stack. */ + if (fparg_count < NUM_FPR_ARG_REGISTERS) + *(long double *) fpr_base++ = *(long double *) *p_argv; + else + *(long double *) next_arg = *(long double *) *p_argv; + next_arg += 2; + fparg_count += 2; +# else + double_tmp = ((double *) *p_argv)[0]; + if (fparg_count < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = double_tmp; + *(double *) next_arg = double_tmp; +# if defined(POWERPC_DARWIN64) + next_arg++; + gp_count++; +# else + next_arg += 2; + gp_count += 2; +# endif + fparg_count++; + double_tmp = ((double *) *p_argv)[1]; + if (fparg_count < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = double_tmp; + *(double *) next_arg = double_tmp; +# if defined(POWERPC_DARWIN64) + next_arg++; + gp_count++; +# else + next_arg += 2; + gp_count += 2; +# endif + fparg_count++; +# endif + FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); + break; +#endif + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: +#ifdef POWERPC64 + gprvalue = *(long long *) *p_argv; + goto putgpr; +#else + *(long long *) next_arg = *(long long *) *p_argv; + next_arg += 2; + gp_count += 2; +#endif + break; + case FFI_TYPE_POINTER: + gprvalue = *(unsigned long *) *p_argv; + goto putgpr; + case FFI_TYPE_UINT8: + gprvalue = *(unsigned char *) *p_argv; + goto putgpr; + case FFI_TYPE_SINT8: + gprvalue = *(signed char *) *p_argv; + goto putgpr; + case FFI_TYPE_UINT16: + gprvalue = *(unsigned short *) *p_argv; + goto putgpr; + case FFI_TYPE_SINT16: + gprvalue = *(signed short *) *p_argv; + goto putgpr; + + case FFI_TYPE_STRUCT: + size_al = (*ptr)->size; +#if defined(POWERPC_DARWIN64) + next_arg = (unsigned long *)ALIGN((char *)next_arg, (*ptr)->alignment); + darwin64_pass_struct_by_value (*ptr, (char *) *p_argv, + (unsigned) size_al, + (unsigned int *) &fparg_count, + &fpr_base, &next_arg); +#else + dest_cpy = (char *) next_arg; + + /* If the first member of the struct is a double, then include enough + padding in the struct size to align it to double-word. */ + if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) + size_al = ALIGN((*ptr)->size, 8); + +# if defined(POWERPC64) + FFI_ASSERT (abi != FFI_DARWIN); + memcpy ((char *) dest_cpy, (char *) *p_argv, size_al); + next_arg += (size_al + 7) / 8; +# else + /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, + SI 4 bytes) are aligned as if they were those modes. + Structures with 3 byte in size are padded upwards. */ + if (size_al < 3 && abi == FFI_DARWIN) + dest_cpy += 4 - size_al; + + memcpy((char *) dest_cpy, (char *) *p_argv, size_al); + next_arg += (size_al + 3) / 4; +# endif +#endif + break; + + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + gprvalue = *(signed int *) *p_argv; + goto putgpr; + + case FFI_TYPE_UINT32: + gprvalue = *(unsigned int *) *p_argv; + putgpr: + *next_arg++ = gprvalue; + gp_count++; + break; + default: + break; + } + } + + /* Check that we didn't overrun the stack... */ + /* FFI_ASSERT(gpr_base <= stacktop - ASM_NEEDS_REGISTERS); + FFI_ASSERT((unsigned *)fpr_base + <= stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); + FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); */ +} + +#if defined(POWERPC_DARWIN64) + +/* See if we can put some of the struct into fprs. + This should not be called for structures of size 16 bytes, since these are not + broken out this way. */ +static void +darwin64_scan_struct_for_floats (ffi_type *s, unsigned *nfpr) +{ + int i; + + FFI_ASSERT (s->type == FFI_TYPE_STRUCT) + + for (i = 0; s->elements[i] != NULL; i++) + { + ffi_type *p = s->elements[i]; + switch (p->type) + { + case FFI_TYPE_STRUCT: + darwin64_scan_struct_for_floats (p, nfpr); + break; + case FFI_TYPE_LONGDOUBLE: + (*nfpr) += 2; + break; + case FFI_TYPE_DOUBLE: + case FFI_TYPE_FLOAT: + (*nfpr) += 1; + break; + default: + break; + } + } +} + +static int +darwin64_struct_size_exceeds_gprs_p (ffi_type *s, char *src, unsigned *nfpr) +{ + unsigned struct_offset=0, i; + + for (i = 0; s->elements[i] != NULL; i++) + { + char *item_base; + ffi_type *p = s->elements[i]; + /* Find the start of this item (0 for the first one). */ + if (i > 0) + struct_offset = ALIGN(struct_offset, p->alignment); + + item_base = src + struct_offset; + + switch (p->type) + { + case FFI_TYPE_STRUCT: + if (darwin64_struct_size_exceeds_gprs_p (p, item_base, nfpr)) + return 1; + break; + case FFI_TYPE_LONGDOUBLE: + if (*nfpr >= NUM_FPR_ARG_REGISTERS) + return 1; + (*nfpr) += 1; + item_base += 8; + /* FALL THROUGH */ + case FFI_TYPE_DOUBLE: + if (*nfpr >= NUM_FPR_ARG_REGISTERS) + return 1; + (*nfpr) += 1; + break; + case FFI_TYPE_FLOAT: + if (*nfpr >= NUM_FPR_ARG_REGISTERS) + return 1; + (*nfpr) += 1; + break; + default: + /* If we try and place any item, that is non-float, once we've + exceeded the 8 GPR mark, then we can't fit the struct. */ + if ((unsigned long)item_base >= 8*8) + return 1; + break; + } + /* now count the size of what we just used. */ + struct_offset += p->size; + } + return 0; +} + +/* Can this struct be returned by value? */ +int +darwin64_struct_ret_by_value_p (ffi_type *s) +{ + unsigned nfp = 0; + + FFI_ASSERT (s && s->type == FFI_TYPE_STRUCT); + + /* The largest structure we can return is 8long + 13 doubles. */ + if (s->size > 168) + return 0; + + /* We can't pass more than 13 floats. */ + darwin64_scan_struct_for_floats (s, &nfp); + if (nfp > 13) + return 0; + + /* If there are not too many floats, and the struct is + small enough to accommodate in the GPRs, then it must be OK. */ + if (s->size <= 64) + return 1; + + /* Well, we have to look harder. */ + nfp = 0; + if (darwin64_struct_size_exceeds_gprs_p (s, NULL, &nfp)) + return 0; + + return 1; +} + +void +darwin64_pass_struct_floats (ffi_type *s, char *src, + unsigned *nfpr, double **fprs) +{ + int i; + double *fpr_base = *fprs; + unsigned struct_offset = 0; + + /* We don't assume anything about the alignment of the source. */ + for (i = 0; s->elements[i] != NULL; i++) + { + char *item_base; + ffi_type *p = s->elements[i]; + /* Find the start of this item (0 for the first one). */ + if (i > 0) + struct_offset = ALIGN(struct_offset, p->alignment); + item_base = src + struct_offset; + + switch (p->type) + { + case FFI_TYPE_STRUCT: + darwin64_pass_struct_floats (p, item_base, nfpr, + &fpr_base); + break; + case FFI_TYPE_LONGDOUBLE: + if (*nfpr < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = *(double *)item_base; + (*nfpr) += 1; + item_base += 8; + /* FALL THROUGH */ + case FFI_TYPE_DOUBLE: + if (*nfpr < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = *(double *)item_base; + (*nfpr) += 1; + break; + case FFI_TYPE_FLOAT: + if (*nfpr < NUM_FPR_ARG_REGISTERS) + *fpr_base++ = (double) *(float *)item_base; + (*nfpr) += 1; + break; + default: + break; + } + /* now count the size of what we just used. */ + struct_offset += p->size; + } + /* Update the scores. */ + *fprs = fpr_base; +} + +/* Darwin64 special rules. + Break out a struct into params and float registers. */ +static void +darwin64_pass_struct_by_value (ffi_type *s, char *src, unsigned size, + unsigned *nfpr, double **fprs, unsigned long **arg) +{ + unsigned long *next_arg = *arg; + char *dest_cpy = (char *)next_arg; + + FFI_ASSERT (s->type == FFI_TYPE_STRUCT) + + if (!size) + return; + + /* First... special cases. */ + if (size < 3 + || (size == 4 + && s->elements[0] + && s->elements[0]->type != FFI_TYPE_FLOAT)) + { + /* Must be at least one GPR, padding is unspecified in value, + let's make it zero. */ + *next_arg = 0UL; + dest_cpy += 8 - size; + memcpy ((char *) dest_cpy, src, size); + next_arg++; + } + else if (size == 16) + { + memcpy ((char *) dest_cpy, src, size); + next_arg += 2; + } + else + { + /* now the general case, we consider embedded floats. */ + memcpy ((char *) dest_cpy, src, size); + darwin64_pass_struct_floats (s, src, nfpr, fprs); + next_arg += (size+7)/8; + } + + *arg = next_arg; +} + +double * +darwin64_struct_floats_to_mem (ffi_type *s, char *dest, double *fprs, unsigned *nf) +{ + int i; + unsigned struct_offset = 0; + + /* We don't assume anything about the alignment of the source. */ + for (i = 0; s->elements[i] != NULL; i++) + { + char *item_base; + ffi_type *p = s->elements[i]; + /* Find the start of this item (0 for the first one). */ + if (i > 0) + struct_offset = ALIGN(struct_offset, p->alignment); + item_base = dest + struct_offset; + + switch (p->type) + { + case FFI_TYPE_STRUCT: + fprs = darwin64_struct_floats_to_mem (p, item_base, fprs, nf); + break; + case FFI_TYPE_LONGDOUBLE: + if (*nf < NUM_FPR_ARG_REGISTERS) + { + *(double *)item_base = *fprs++ ; + (*nf) += 1; + } + item_base += 8; + /* FALL THROUGH */ + case FFI_TYPE_DOUBLE: + if (*nf < NUM_FPR_ARG_REGISTERS) + { + *(double *)item_base = *fprs++ ; + (*nf) += 1; + } + break; + case FFI_TYPE_FLOAT: + if (*nf < NUM_FPR_ARG_REGISTERS) + { + *(float *)item_base = (float) *fprs++ ; + (*nf) += 1; + } + break; + default: + break; + } + /* now count the size of what we just used. */ + struct_offset += p->size; + } + return fprs; +} + +#endif + +/* Adjust the size of S to be correct for Darwin. + On Darwin m32, the first field of a structure has natural alignment. + On Darwin m64, all fields have natural alignment. */ + +static void +darwin_adjust_aggregate_sizes (ffi_type *s) +{ + int i; + + if (s->type != FFI_TYPE_STRUCT) + return; + + s->size = 0; + for (i = 0; s->elements[i] != NULL; i++) + { + ffi_type *p; + int align; + + p = s->elements[i]; + if (p->type == FFI_TYPE_STRUCT) + darwin_adjust_aggregate_sizes (p); +#if defined(POWERPC_DARWIN64) + /* Natural alignment for all items. */ + align = p->alignment; +#else + /* Natural alignment for the first item... */ + if (i == 0) + align = p->alignment; + else if (p->alignment == 16 || p->alignment < 4) + /* .. subsequent items with vector or align < 4 have natural align. */ + align = p->alignment; + else + /* .. or align is 4. */ + align = 4; +#endif + /* Pad, if necessary, before adding the current item. */ + s->size = ALIGN(s->size, align) + p->size; + } + + s->size = ALIGN(s->size, s->alignment); + + /* This should not be necessary on m64, but harmless. */ + if (s->elements[0]->type == FFI_TYPE_UINT64 + || s->elements[0]->type == FFI_TYPE_SINT64 + || s->elements[0]->type == FFI_TYPE_DOUBLE + || s->elements[0]->alignment == 8) + s->alignment = s->alignment > 8 ? s->alignment : 8; + /* Do not add additional tail padding. */ +} + +/* Adjust the size of S to be correct for AIX. + Word-align double unless it is the first member of a structure. */ + +static void +aix_adjust_aggregate_sizes (ffi_type *s) +{ + int i; + + if (s->type != FFI_TYPE_STRUCT) + return; + + s->size = 0; + for (i = 0; s->elements[i] != NULL; i++) + { + ffi_type *p; + int align; + + p = s->elements[i]; + aix_adjust_aggregate_sizes (p); + align = p->alignment; + if (i != 0 && p->type == FFI_TYPE_DOUBLE) + align = 4; + s->size = ALIGN(s->size, align) + p->size; + } + + s->size = ALIGN(s->size, s->alignment); + + if (s->elements[0]->type == FFI_TYPE_UINT64 + || s->elements[0]->type == FFI_TYPE_SINT64 + || s->elements[0]->type == FFI_TYPE_DOUBLE + || s->elements[0]->alignment == 8) + s->alignment = s->alignment > 8 ? s->alignment : 8; + /* Do not add additional tail padding. */ +} + +/* Perform machine dependent cif processing. */ +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + /* All this is for the DARWIN ABI. */ + unsigned i; + ffi_type **ptr; + unsigned bytes; + unsigned fparg_count = 0, intarg_count = 0; + unsigned flags = 0; + unsigned size_al = 0; + + /* All the machine-independent calculation of cif->bytes will be wrong. + All the calculation of structure sizes will also be wrong. + Redo the calculation for DARWIN. */ + + if (cif->abi == FFI_DARWIN) + { + darwin_adjust_aggregate_sizes (cif->rtype); + for (i = 0; i < cif->nargs; i++) + darwin_adjust_aggregate_sizes (cif->arg_types[i]); + } + + if (cif->abi == FFI_AIX) + { + aix_adjust_aggregate_sizes (cif->rtype); + for (i = 0; i < cif->nargs; i++) + aix_adjust_aggregate_sizes (cif->arg_types[i]); + } + + /* Space for the frame pointer, callee's LR, CR, etc, and for + the asm's temp regs. */ + + bytes = (LINKAGE_AREA_GPRS + ASM_NEEDS_REGISTERS) * sizeof(unsigned long); + + /* Return value handling. + The rules m32 are as follows: + - 32-bit (or less) integer values are returned in gpr3; + - structures of size <= 4 bytes also returned in gpr3; + - 64-bit integer values [??? and structures between 5 and 8 bytes] are + returned in gpr3 and gpr4; + - Single/double FP values are returned in fpr1; + - Long double FP (if not equivalent to double) values are returned in + fpr1 and fpr2; + m64: + - 64-bit or smaller integral values are returned in GPR3 + - Single/double FP values are returned in fpr1; + - Long double FP values are returned in fpr1 and fpr2; + m64 Structures: + - If the structure could be accommodated in registers were it to be the + first argument to a routine, then it is returned in those registers. + m32/m64 structures otherwise: + - Larger structures values are allocated space and a pointer is passed + as the first argument. */ + switch (cif->rtype->type) + { + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + flags |= FLAG_RETURNS_128BITS; + flags |= FLAG_RETURNS_FP; + break; +#endif + + case FFI_TYPE_DOUBLE: + flags |= FLAG_RETURNS_64BITS; + /* Fall through. */ + case FFI_TYPE_FLOAT: + flags |= FLAG_RETURNS_FP; + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: +#ifdef POWERPC64 + case FFI_TYPE_POINTER: +#endif + flags |= FLAG_RETURNS_64BITS; + break; + + case FFI_TYPE_STRUCT: +#if defined(POWERPC_DARWIN64) + { + /* Can we fit the struct into regs? */ + if (darwin64_struct_ret_by_value_p (cif->rtype)) + { + unsigned nfpr = 0; + flags |= FLAG_RETURNS_STRUCT; + if (cif->rtype->size != 16) + darwin64_scan_struct_for_floats (cif->rtype, &nfpr) ; + else + flags |= FLAG_RETURNS_128BITS; + /* Will be 0 for 16byte struct. */ + if (nfpr) + flags |= FLAG_RETURNS_FP; + } + else /* By ref. */ + { + flags |= FLAG_RETVAL_REFERENCE; + flags |= FLAG_RETURNS_NOTHING; + intarg_count++; + } + } +#elif defined(DARWIN_PPC) + if (cif->rtype->size <= 4) + flags |= FLAG_RETURNS_STRUCT; + else /* else by reference. */ + { + flags |= FLAG_RETVAL_REFERENCE; + flags |= FLAG_RETURNS_NOTHING; + intarg_count++; + } +#else /* assume we pass by ref. */ + flags |= FLAG_RETVAL_REFERENCE; + flags |= FLAG_RETURNS_NOTHING; + intarg_count++; +#endif + break; + case FFI_TYPE_VOID: + flags |= FLAG_RETURNS_NOTHING; + break; + + default: + /* Returns 32-bit integer, or similar. Nothing to do here. */ + break; + } + + /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the + first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest + goes on the stack. + ??? Structures are passed as a pointer to a copy of the structure. + Stuff on the stack needs to keep proper alignment. + For m64 the count is effectively of half-GPRs. */ + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) + { + unsigned align_words; + switch ((*ptr)->type) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + fparg_count++; +#if !defined(POWERPC_DARWIN64) + /* If this FP arg is going on the stack, it must be + 8-byte-aligned. */ + if (fparg_count > NUM_FPR_ARG_REGISTERS + && (intarg_count & 0x01) != 0) + intarg_count++; +#endif + break; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + fparg_count += 2; + /* If this FP arg is going on the stack, it must be + 16-byte-aligned. */ + if (fparg_count >= NUM_FPR_ARG_REGISTERS) +#if defined (POWERPC64) + intarg_count = ALIGN(intarg_count, 2); +#else + intarg_count = ALIGN(intarg_count, 4); +#endif + break; +#endif + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: +#if defined(POWERPC64) + intarg_count++; +#else + /* 'long long' arguments are passed as two words, but + either both words must fit in registers or both go + on the stack. If they go on the stack, they must + be 8-byte-aligned. */ + if (intarg_count == NUM_GPR_ARG_REGISTERS-1 + || (intarg_count >= NUM_GPR_ARG_REGISTERS + && (intarg_count & 0x01) != 0)) + intarg_count++; + intarg_count += 2; +#endif + break; + + case FFI_TYPE_STRUCT: + size_al = (*ptr)->size; +#if defined(POWERPC_DARWIN64) + align_words = (*ptr)->alignment >> 3; + if (align_words) + intarg_count = ALIGN(intarg_count, align_words); + /* Base size of the struct. */ + intarg_count += (size_al + 7) / 8; + /* If 16 bytes then don't worry about floats. */ + if (size_al != 16) + /* Scan through for floats to be placed in regs. */ + darwin64_scan_struct_for_floats (*ptr, &fparg_count) ; +#else + align_words = (*ptr)->alignment >> 2; + if (align_words) + intarg_count = ALIGN(intarg_count, align_words); + /* If the first member of the struct is a double, then align + the struct to double-word. + if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) + size_al = ALIGN((*ptr)->size, 8); */ +# ifdef POWERPC64 + intarg_count += (size_al + 7) / 8; +# else + intarg_count += (size_al + 3) / 4; +# endif +#endif + break; + + default: + /* Everything else is passed as a 4-byte word in a GPR, either + the object itself or a pointer to it. */ + intarg_count++; + break; + } + } + + if (fparg_count != 0) + flags |= FLAG_FP_ARGUMENTS; + +#if defined(POWERPC_DARWIN64) + /* Space to image the FPR registers, if needed - which includes when they might be + used in a struct return. */ + if (fparg_count != 0 + || ((flags & FLAG_RETURNS_STRUCT) + && (flags & FLAG_RETURNS_FP))) + bytes += NUM_FPR_ARG_REGISTERS * sizeof(double); +#else + /* Space for the FPR registers, if needed. */ + if (fparg_count != 0) + bytes += NUM_FPR_ARG_REGISTERS * sizeof(double); +#endif + + /* Stack space. */ +#ifdef POWERPC64 + if ((intarg_count + fparg_count) > NUM_GPR_ARG_REGISTERS) + bytes += (intarg_count + fparg_count) * sizeof(long); +#else + if ((intarg_count + 2 * fparg_count) > NUM_GPR_ARG_REGISTERS) + bytes += (intarg_count + 2 * fparg_count) * sizeof(long); +#endif + else + bytes += NUM_GPR_ARG_REGISTERS * sizeof(long); + + /* The stack space allocated needs to be a multiple of 16 bytes. */ + bytes = ALIGN(bytes, 16) ; + + cif->flags = flags; + cif->bytes = bytes; + + return FFI_OK; +} + +extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *, + void (*fn)(void), void (*fn2)(void)); + +extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *, + void (*fn)(void), void (*fn2)(void), ffi_type*); + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return + value address then we need to make one. */ + + if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca (cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_AIX: + ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn, + FFI_FN(ffi_prep_args)); + break; + case FFI_DARWIN: + ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn, + FFI_FN(ffi_prep_args), cif->rtype); + break; + default: + FFI_ASSERT(0); + break; + } +} + +static void flush_icache(char *); +static void flush_range(char *, int); + +/* The layout of a function descriptor. A C function pointer really + points to one of these. */ + +typedef struct aix_fd_struct { + void *code_pointer; + void *toc; +} aix_fd; + +/* here I'd like to add the stack frame layout we use in darwin_closure.S + and aix_closure.S + + m32/m64 + + The stack layout looks like this: + + | Additional params... | | Higher address + ~ ~ ~ + | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS + |--------------------------------------------| | + | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | + |--------------------------------------------| | + | Reserved 2*4/8 | | + |--------------------------------------------| | + | Space for callee's LR 4/8 | | + |--------------------------------------------| | + | Saved CR [low word for m64] 4/8 | | + |--------------------------------------------| | + | Current backchain pointer 4/8 |-/ Parent's frame. + |--------------------------------------------| <+ <<< on entry to ffi_closure_ASM + | Result Bytes 16 | | + |--------------------------------------------| | + ~ padding to 16-byte alignment ~ ~ + |--------------------------------------------| | + | NUM_FPR_ARG_REGISTERS slots | | + | here fp13 .. fp1 13*8 | | + |--------------------------------------------| | + | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS + |--------------------------------------------| | + | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | + |--------------------------------------------| | stack | + | Reserved [compiler,binder] 2*4/8 | | grows | + |--------------------------------------------| | down V + | Space for callee's LR 4/8 | | + |--------------------------------------------| | lower addresses + | Saved CR [low word for m64] 4/8 | | + |--------------------------------------------| | stack pointer here + | Current backchain pointer 4/8 |-/ during + |--------------------------------------------| <<< ffi_closure_ASM. + +*/ + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp; + struct ffi_aix_trampoline_struct *tramp_aix; + aix_fd *fd; + + switch (cif->abi) + { + case FFI_DARWIN: + + FFI_ASSERT (cif->abi == FFI_DARWIN); + + tramp = (unsigned int *) &closure->tramp[0]; +#if defined(POWERPC_DARWIN64) + tramp[0] = 0x7c0802a6; /* mflr r0 */ + tramp[1] = 0x429f0015; /* bcl- 20,4*cr7+so, +0x18 (L1) */ + /* We put the addresses here. */ + tramp[6] = 0x7d6802a6; /*L1: mflr r11 */ + tramp[7] = 0xe98b0000; /* ld r12,0(r11) function address */ + tramp[8] = 0x7c0803a6; /* mtlr r0 */ + tramp[9] = 0x7d8903a6; /* mtctr r12 */ + tramp[10] = 0xe96b0008; /* lwz r11,8(r11) static chain */ + tramp[11] = 0x4e800420; /* bctr */ + + *((unsigned long *)&tramp[2]) = (unsigned long) ffi_closure_ASM; /* function */ + *((unsigned long *)&tramp[4]) = (unsigned long) codeloc; /* context */ +#else + tramp[0] = 0x7c0802a6; /* mflr r0 */ + tramp[1] = 0x429f000d; /* bcl- 20,4*cr7+so,0x10 */ + tramp[4] = 0x7d6802a6; /* mflr r11 */ + tramp[5] = 0x818b0000; /* lwz r12,0(r11) function address */ + tramp[6] = 0x7c0803a6; /* mtlr r0 */ + tramp[7] = 0x7d8903a6; /* mtctr r12 */ + tramp[8] = 0x816b0004; /* lwz r11,4(r11) static chain */ + tramp[9] = 0x4e800420; /* bctr */ + tramp[2] = (unsigned long) ffi_closure_ASM; /* function */ + tramp[3] = (unsigned long) codeloc; /* context */ +#endif + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + /* Flush the icache. Only necessary on Darwin. */ + flush_range(codeloc, FFI_TRAMPOLINE_SIZE); + + break; + + case FFI_AIX: + + tramp_aix = (struct ffi_aix_trampoline_struct *) (closure->tramp); + fd = (aix_fd *)(void *)ffi_closure_ASM; + + FFI_ASSERT (cif->abi == FFI_AIX); + + tramp_aix->code_pointer = fd->code_pointer; + tramp_aix->toc = fd->toc; + tramp_aix->static_chain = codeloc; + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + break; + + default: + return FFI_BAD_ABI; + break; + } + return FFI_OK; +} + +static void +flush_icache(char *addr) +{ +#ifndef _AIX + __asm__ volatile ( + "dcbf 0,%0\n" + "\tsync\n" + "\ticbi 0,%0\n" + "\tsync\n" + "\tisync" + : : "r"(addr) : "memory"); +#endif +} + +static void +flush_range(char * addr1, int size) +{ +#define MIN_LINE_SIZE 32 + int i; + for (i = 0; i < size; i += MIN_LINE_SIZE) + flush_icache(addr1+i); + flush_icache(addr1+size-1); +} + +typedef union +{ + float f; + double d; +} ffi_dblfl; + +ffi_type * +ffi_closure_helper_DARWIN (ffi_closure *, void *, + unsigned long *, ffi_dblfl *); + +/* Basically the trampoline invokes ffi_closure_ASM, and on + entry, r11 holds the address of the closure. + After storing the registers that could possibly contain + parameters to be passed into the stack frame and setting + up space for a return value, ffi_closure_ASM invokes the + following helper function to do most of the work. */ + +ffi_type * +ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue, + unsigned long *pgr, ffi_dblfl *pfr) +{ + /* rvalue is the pointer to space for return value in closure assembly + pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM + pfr is the pointer to where f1-f13 are stored in ffi_closure_ASM. */ + + typedef double ldbits[2]; + + union ldu + { + ldbits lb; + long double ld; + }; + + void ** avalue; + ffi_type ** arg_types; + long i, avn; + ffi_cif * cif; + ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS; + unsigned size_al; +#if defined(POWERPC_DARWIN64) + unsigned fpsused = 0; +#endif + + cif = closure->cif; + avalue = alloca (cif->nargs * sizeof(void *)); + + if (cif->rtype->type == FFI_TYPE_STRUCT) + { +#if defined(POWERPC_DARWIN64) + if (!darwin64_struct_ret_by_value_p (cif->rtype)) + { + /* Won't fit into the regs - return by ref. */ + rvalue = (void *) *pgr; + pgr++; + } +#elif defined(DARWIN_PPC) + if (cif->rtype->size > 4) + { + rvalue = (void *) *pgr; + pgr++; + } +#else /* assume we return by ref. */ + rvalue = (void *) *pgr; + pgr++; +#endif + } + + i = 0; + avn = cif->nargs; + arg_types = cif->arg_types; + + /* Grab the addresses of the arguments from the stack frame. */ + while (i < avn) + { + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: +#if defined(POWERPC64) + avalue[i] = (char *) pgr + 7; +#else + avalue[i] = (char *) pgr + 3; +#endif + pgr++; + break; + + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: +#if defined(POWERPC64) + avalue[i] = (char *) pgr + 6; +#else + avalue[i] = (char *) pgr + 2; +#endif + pgr++; + break; + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: +#if defined(POWERPC64) + avalue[i] = (char *) pgr + 4; +#else + case FFI_TYPE_POINTER: + avalue[i] = pgr; +#endif + pgr++; + break; + + case FFI_TYPE_STRUCT: + size_al = arg_types[i]->size; +#if defined(POWERPC_DARWIN64) + pgr = (unsigned long *)ALIGN((char *)pgr, arg_types[i]->alignment); + if (size_al < 3 || size_al == 4) + { + avalue[i] = ((char *)pgr)+8-size_al; + if (arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT + && fpsused < NUM_FPR_ARG_REGISTERS) + { + *(float *)pgr = (float) *(double *)pfr; + pfr++; + fpsused++; + } + } + else + { + if (size_al != 16) + pfr = (ffi_dblfl *) + darwin64_struct_floats_to_mem (arg_types[i], (char *)pgr, + (double *)pfr, &fpsused); + avalue[i] = pgr; + } + pgr += (size_al + 7) / 8; +#else + /* If the first member of the struct is a double, then align + the struct to double-word. */ + if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE) + size_al = ALIGN(arg_types[i]->size, 8); +# if defined(POWERPC64) + FFI_ASSERT (cif->abi != FFI_DARWIN); + avalue[i] = pgr; + pgr += (size_al + 7) / 8; +# else + /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, + SI 4 bytes) are aligned as if they were those modes. */ + if (size_al < 3 && cif->abi == FFI_DARWIN) + avalue[i] = (char*) pgr + 4 - size_al; + else + avalue[i] = pgr; + pgr += (size_al + 3) / 4; +# endif +#endif + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: +#if defined(POWERPC64) + case FFI_TYPE_POINTER: + avalue[i] = pgr; + pgr++; + break; +#else + /* Long long ints are passed in two gpr's. */ + avalue[i] = pgr; + pgr += 2; + break; +#endif + + case FFI_TYPE_FLOAT: + /* A float value consumes a GPR. + There are 13 64bit floating point registers. */ + if (pfr < end_pfr) + { + double temp = pfr->d; + pfr->f = (float) temp; + avalue[i] = pfr; + pfr++; + } + else + { + avalue[i] = pgr; + } + pgr++; + break; + + case FFI_TYPE_DOUBLE: + /* A double value consumes two GPRs. + There are 13 64bit floating point registers. */ + if (pfr < end_pfr) + { + avalue[i] = pfr; + pfr++; + } + else + { + avalue[i] = pgr; + } +#ifdef POWERPC64 + pgr++; +#else + pgr += 2; +#endif + break; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + + case FFI_TYPE_LONGDOUBLE: +#ifdef POWERPC64 + if (pfr + 1 < end_pfr) + { + avalue[i] = pfr; + pfr += 2; + } + else + { + if (pfr < end_pfr) + { + *pgr = *(unsigned long *) pfr; + pfr++; + } + avalue[i] = pgr; + } + pgr += 2; +#else /* POWERPC64 */ + /* A long double value consumes four GPRs and two FPRs. + There are 13 64bit floating point registers. */ + if (pfr + 1 < end_pfr) + { + avalue[i] = pfr; + pfr += 2; + } + /* Here we have the situation where one part of the long double + is stored in fpr13 and the other part is already on the stack. + We use a union to pass the long double to avalue[i]. */ + else if (pfr + 1 == end_pfr) + { + union ldu temp_ld; + memcpy (&temp_ld.lb[0], pfr, sizeof(ldbits)); + memcpy (&temp_ld.lb[1], pgr + 2, sizeof(ldbits)); + avalue[i] = &temp_ld.ld; + pfr++; + } + else + { + avalue[i] = pgr; + } + pgr += 4; +#endif /* POWERPC64 */ + break; +#endif + default: + FFI_ASSERT(0); + } + i++; + } + + (closure->fun) (cif, rvalue, avalue, closure->user_data); + + /* Tell ffi_closure_ASM to perform return type promotions. */ + return cif->rtype; +} diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_linux64.c b/user/mpy/lib/libffi/src/powerpc/ffi_linux64.c new file mode 100644 index 0000000..b84b91f --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ffi_linux64.c @@ -0,0 +1,945 @@ +/* ----------------------------------------------------------------------- + ffi_linux64.c - Copyright (C) 2013 IBM + Copyright (C) 2011 Anthony Green + Copyright (C) 2011 Kyle Moffett + Copyright (C) 2008 Red Hat, Inc + Copyright (C) 2007, 2008 Free Software Foundation, Inc + Copyright (c) 1998 Geoffrey Keating + + PowerPC Foreign Function Interface + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#include "ffi.h" + +#ifdef POWERPC64 +#include "ffi_common.h" +#include "ffi_powerpc.h" + + +/* About the LINUX64 ABI. */ +enum { + NUM_GPR_ARG_REGISTERS64 = 8, + NUM_FPR_ARG_REGISTERS64 = 13 +}; +enum { ASM_NEEDS_REGISTERS64 = 4 }; + + +#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +/* Adjust size of ffi_type_longdouble. */ +void FFI_HIDDEN +ffi_prep_types_linux64 (ffi_abi abi) +{ + if ((abi & (FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128)) == FFI_LINUX) + { + ffi_type_longdouble.size = 8; + ffi_type_longdouble.alignment = 8; + } + else + { + ffi_type_longdouble.size = 16; + ffi_type_longdouble.alignment = 16; + } +} +#endif + + +#if _CALL_ELF == 2 +static unsigned int +discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum) +{ + switch (t->type) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + *elnum = 1; + return (int) t->type; + + case FFI_TYPE_STRUCT:; + { + unsigned int base_elt = 0, total_elnum = 0; + ffi_type **el = t->elements; + while (*el) + { + unsigned int el_elt, el_elnum = 0; + el_elt = discover_homogeneous_aggregate (*el, &el_elnum); + if (el_elt == 0 + || (base_elt && base_elt != el_elt)) + return 0; + base_elt = el_elt; + total_elnum += el_elnum; + if (total_elnum > 8) + return 0; + el++; + } + *elnum = total_elnum; + return base_elt; + } + + default: + return 0; + } +} +#endif + + +/* Perform machine dependent cif processing */ +static ffi_status +ffi_prep_cif_linux64_core (ffi_cif *cif) +{ + ffi_type **ptr; + unsigned bytes; + unsigned i, fparg_count = 0, intarg_count = 0; + unsigned flags = cif->flags; +#if _CALL_ELF == 2 + unsigned int elt, elnum; +#endif + +#if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE + /* If compiled without long double support.. */ + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + return FFI_BAD_ABI; +#endif + + /* The machine-independent calculation of cif->bytes doesn't work + for us. Redo the calculation. */ +#if _CALL_ELF == 2 + /* Space for backchain, CR, LR, TOC and the asm's temp regs. */ + bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long); + + /* Space for the general registers. */ + bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long); +#else + /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp + regs. */ + bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long); + + /* Space for the mandatory parm save area and general registers. */ + bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long); +#endif + + /* Return value handling. */ + switch (cif->rtype->type) + { +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + flags |= FLAG_RETURNS_128BITS; + /* Fall through. */ +#endif + case FFI_TYPE_DOUBLE: + flags |= FLAG_RETURNS_64BITS; + /* Fall through. */ + case FFI_TYPE_FLOAT: + flags |= FLAG_RETURNS_FP; + break; + + case FFI_TYPE_UINT128: + flags |= FLAG_RETURNS_128BITS; + /* Fall through. */ + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + flags |= FLAG_RETURNS_64BITS; + break; + + case FFI_TYPE_STRUCT: +#if _CALL_ELF == 2 + elt = discover_homogeneous_aggregate (cif->rtype, &elnum); + if (elt) + { + if (elt == FFI_TYPE_DOUBLE) + flags |= FLAG_RETURNS_64BITS; + flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST; + break; + } + if (cif->rtype->size <= 16) + { + flags |= FLAG_RETURNS_SMST; + break; + } +#endif + intarg_count++; + flags |= FLAG_RETVAL_REFERENCE; + /* Fall through. */ + case FFI_TYPE_VOID: + flags |= FLAG_RETURNS_NOTHING; + break; + + default: + /* Returns 32-bit integer, or similar. Nothing to do here. */ + break; + } + + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) + { + unsigned int align; + + switch ((*ptr)->type) + { +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + { + fparg_count++; + intarg_count++; + } + /* Fall through. */ +#endif + case FFI_TYPE_DOUBLE: + case FFI_TYPE_FLOAT: + fparg_count++; + intarg_count++; + if (fparg_count > NUM_FPR_ARG_REGISTERS64) + flags |= FLAG_ARG_NEEDS_PSAVE; + break; + + case FFI_TYPE_STRUCT: + if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0) + { + align = (*ptr)->alignment; + if (align > 16) + align = 16; + align = align / 8; + if (align > 1) + intarg_count = ALIGN (intarg_count, align); + } + intarg_count += ((*ptr)->size + 7) / 8; +#if _CALL_ELF == 2 + elt = discover_homogeneous_aggregate (*ptr, &elnum); + if (elt) + { + fparg_count += elnum; + if (fparg_count > NUM_FPR_ARG_REGISTERS64) + flags |= FLAG_ARG_NEEDS_PSAVE; + } + else +#endif + { + if (intarg_count > NUM_GPR_ARG_REGISTERS64) + flags |= FLAG_ARG_NEEDS_PSAVE; + } + break; + + case FFI_TYPE_POINTER: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + /* Everything else is passed as a 8-byte word in a GPR, either + the object itself or a pointer to it. */ + intarg_count++; + if (intarg_count > NUM_GPR_ARG_REGISTERS64) + flags |= FLAG_ARG_NEEDS_PSAVE; + break; + default: + FFI_ASSERT (0); + } + } + + if (fparg_count != 0) + flags |= FLAG_FP_ARGUMENTS; + if (intarg_count > 4) + flags |= FLAG_4_GPR_ARGUMENTS; + + /* Space for the FPR registers, if needed. */ + if (fparg_count != 0) + bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double); + + /* Stack space. */ +#if _CALL_ELF == 2 + if ((flags & FLAG_ARG_NEEDS_PSAVE) != 0) + bytes += intarg_count * sizeof (long); +#else + if (intarg_count > NUM_GPR_ARG_REGISTERS64) + bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long); +#endif + + /* The stack space allocated needs to be a multiple of 16 bytes. */ + bytes = (bytes + 15) & ~0xF; + + cif->flags = flags; + cif->bytes = bytes; + + return FFI_OK; +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_linux64 (ffi_cif *cif) +{ + if ((cif->abi & FFI_LINUX) != 0) + cif->nfixedargs = cif->nargs; +#if _CALL_ELF != 2 + else if (cif->abi == FFI_COMPAT_LINUX64) + { + /* This call is from old code. Don't touch cif->nfixedargs + since old code will be using a smaller cif. */ + cif->flags |= FLAG_COMPAT; + /* Translate to new abi value. */ + cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128; + } +#endif + else + return FFI_BAD_ABI; + return ffi_prep_cif_linux64_core (cif); +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_linux64_var (ffi_cif *cif, + unsigned int nfixedargs, + unsigned int ntotalargs MAYBE_UNUSED) +{ + if ((cif->abi & FFI_LINUX) != 0) + cif->nfixedargs = nfixedargs; +#if _CALL_ELF != 2 + else if (cif->abi == FFI_COMPAT_LINUX64) + { + /* This call is from old code. Don't touch cif->nfixedargs + since old code will be using a smaller cif. */ + cif->flags |= FLAG_COMPAT; + /* Translate to new abi value. */ + cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128; + } +#endif + else + return FFI_BAD_ABI; +#if _CALL_ELF == 2 + cif->flags |= FLAG_ARG_NEEDS_PSAVE; +#endif + return ffi_prep_cif_linux64_core (cif); +} + + +/* ffi_prep_args64 is called by the assembly routine once stack space + has been allocated for the function's arguments. + + The stack layout we want looks like this: + + | Ret addr from ffi_call_LINUX64 8bytes | higher addresses + |--------------------------------------------| + | CR save area 8bytes | + |--------------------------------------------| + | Previous backchain pointer 8 | stack pointer here + |--------------------------------------------|<+ <<< on entry to + | Saved r28-r31 4*8 | | ffi_call_LINUX64 + |--------------------------------------------| | + | GPR registers r3-r10 8*8 | | + |--------------------------------------------| | + | FPR registers f1-f13 (optional) 13*8 | | + |--------------------------------------------| | + | Parameter save area | | + |--------------------------------------------| | + | TOC save area 8 | | + |--------------------------------------------| | stack | + | Linker doubleword 8 | | grows | + |--------------------------------------------| | down V + | Compiler doubleword 8 | | + |--------------------------------------------| | lower addresses + | Space for callee's LR 8 | | + |--------------------------------------------| | + | CR save area 8 | | + |--------------------------------------------| | stack pointer here + | Current backchain pointer 8 |-/ during + |--------------------------------------------| <<< ffi_call_LINUX64 + +*/ + +void FFI_HIDDEN +ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) +{ + const unsigned long bytes = ecif->cif->bytes; + const unsigned long flags = ecif->cif->flags; + + typedef union + { + char *c; + unsigned long *ul; + float *f; + double *d; + size_t p; + } valp; + + /* 'stacktop' points at the previous backchain pointer. */ + valp stacktop; + + /* 'next_arg' points at the space for gpr3, and grows upwards as + we use GPR registers, then continues at rest. */ + valp gpr_base; + valp gpr_end; + valp rest; + valp next_arg; + + /* 'fpr_base' points at the space for fpr3, and grows upwards as + we use FPR registers. */ + valp fpr_base; + unsigned int fparg_count; + + unsigned int i, words, nargs, nfixedargs; + ffi_type **ptr; + double double_tmp; + union + { + void **v; + char **c; + signed char **sc; + unsigned char **uc; + signed short **ss; + unsigned short **us; + signed int **si; + unsigned int **ui; + unsigned long **ul; + float **f; + double **d; + } p_argv; + unsigned long gprvalue; + unsigned long align; + + stacktop.c = (char *) stack + bytes; + gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64; + gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64; +#if _CALL_ELF == 2 + rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64; +#else + rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64; +#endif + fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64; + fparg_count = 0; + next_arg.ul = gpr_base.ul; + + /* Check that everything starts aligned properly. */ + FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0); + FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0); + FFI_ASSERT ((bytes & 0xF) == 0); + + /* Deal with return values that are actually pass-by-reference. */ + if (flags & FLAG_RETVAL_REFERENCE) + *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue; + + /* Now for the arguments. */ + p_argv.v = ecif->avalue; + nargs = ecif->cif->nargs; +#if _CALL_ELF != 2 + nfixedargs = (unsigned) -1; + if ((flags & FLAG_COMPAT) == 0) +#endif + nfixedargs = ecif->cif->nfixedargs; + for (ptr = ecif->cif->arg_types, i = 0; + i < nargs; + i++, ptr++, p_argv.v++) + { +#if _CALL_ELF == 2 + unsigned int elt, elnum; +#endif + + switch ((*ptr)->type) + { +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + { + double_tmp = (*p_argv.d)[0]; + if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) + { + *fpr_base.d++ = double_tmp; +# if _CALL_ELF != 2 + if ((flags & FLAG_COMPAT) != 0) + *next_arg.d = double_tmp; +# endif + } + else + *next_arg.d = double_tmp; + if (++next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + fparg_count++; + double_tmp = (*p_argv.d)[1]; + if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) + { + *fpr_base.d++ = double_tmp; +# if _CALL_ELF != 2 + if ((flags & FLAG_COMPAT) != 0) + *next_arg.d = double_tmp; +# endif + } + else + *next_arg.d = double_tmp; + if (++next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + fparg_count++; + FFI_ASSERT (__LDBL_MANT_DIG__ == 106); + FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + break; + } + /* Fall through. */ +#endif + case FFI_TYPE_DOUBLE: + double_tmp = **p_argv.d; + if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) + { + *fpr_base.d++ = double_tmp; +#if _CALL_ELF != 2 + if ((flags & FLAG_COMPAT) != 0) + *next_arg.d = double_tmp; +#endif + } + else + *next_arg.d = double_tmp; + if (++next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + fparg_count++; + FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + break; + + case FFI_TYPE_FLOAT: + double_tmp = **p_argv.f; + if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) + { + *fpr_base.d++ = double_tmp; +#if _CALL_ELF != 2 + if ((flags & FLAG_COMPAT) != 0) + *next_arg.f = (float) double_tmp; +#endif + } + else + *next_arg.f = (float) double_tmp; + if (++next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + fparg_count++; + FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + break; + + case FFI_TYPE_STRUCT: + if ((ecif->cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0) + { + align = (*ptr)->alignment; + if (align > 16) + align = 16; + if (align > 1) + next_arg.p = ALIGN (next_arg.p, align); + } +#if _CALL_ELF == 2 + elt = discover_homogeneous_aggregate (*ptr, &elnum); + if (elt) + { + union { + void *v; + float *f; + double *d; + } arg; + + arg.v = *p_argv.v; + if (elt == FFI_TYPE_FLOAT) + { + do + { + double_tmp = *arg.f++; + if (fparg_count < NUM_FPR_ARG_REGISTERS64 + && i < nfixedargs) + *fpr_base.d++ = double_tmp; + else + *next_arg.f = (float) double_tmp; + if (++next_arg.f == gpr_end.f) + next_arg.f = rest.f; + fparg_count++; + } + while (--elnum != 0); + if ((next_arg.p & 3) != 0) + { + if (++next_arg.f == gpr_end.f) + next_arg.f = rest.f; + } + } + else + do + { + double_tmp = *arg.d++; + if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) + *fpr_base.d++ = double_tmp; + else + *next_arg.d = double_tmp; + if (++next_arg.d == gpr_end.d) + next_arg.d = rest.d; + fparg_count++; + } + while (--elnum != 0); + } + else +#endif + { + words = ((*ptr)->size + 7) / 8; + if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul) + { + size_t first = gpr_end.c - next_arg.c; + memcpy (next_arg.c, *p_argv.c, first); + memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first); + next_arg.c = rest.c + words * 8 - first; + } + else + { + char *where = next_arg.c; + +#ifndef __LITTLE_ENDIAN__ + /* Structures with size less than eight bytes are passed + left-padded. */ + if ((*ptr)->size < 8) + where += 8 - (*ptr)->size; +#endif + memcpy (where, *p_argv.c, (*ptr)->size); + next_arg.ul += words; + if (next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + } + } + break; + + case FFI_TYPE_UINT8: + gprvalue = **p_argv.uc; + goto putgpr; + case FFI_TYPE_SINT8: + gprvalue = **p_argv.sc; + goto putgpr; + case FFI_TYPE_UINT16: + gprvalue = **p_argv.us; + goto putgpr; + case FFI_TYPE_SINT16: + gprvalue = **p_argv.ss; + goto putgpr; + case FFI_TYPE_UINT32: + gprvalue = **p_argv.ui; + goto putgpr; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + gprvalue = **p_argv.si; + goto putgpr; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + gprvalue = **p_argv.ul; + putgpr: + *next_arg.ul++ = gprvalue; + if (next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + break; + } + } + + FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS + || (next_arg.ul >= gpr_base.ul + && next_arg.ul <= gpr_base.ul + 4)); +} + + +#if _CALL_ELF == 2 +#define MIN_CACHE_LINE_SIZE 8 + +static void +flush_icache (char *wraddr, char *xaddr, int size) +{ + int i; + for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) + __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" + : : "r" (xaddr + i), "r" (wraddr + i) : "memory"); + __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;" + : : "r"(xaddr + size - 1), "r"(wraddr + size - 1) + : "memory"); +} +#endif + + +ffi_status FFI_HIDDEN +ffi_prep_closure_loc_linux64 (ffi_closure *closure, + ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + void *codeloc) +{ +#if _CALL_ELF == 2 + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; + + if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI) + return FFI_BAD_ABI; + + tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */ + tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */ + tramp[2] = 0x7d8903a6; /* mtctr 12 */ + tramp[3] = 0x4e800420; /* bctr */ + /* 1: .quad function_addr */ + /* 2: .quad context */ + *(void **) &tramp[4] = (void *) ffi_closure_LINUX64; + *(void **) &tramp[6] = codeloc; + flush_icache ((char *) tramp, (char *) codeloc, 4 * 4); +#else + void **tramp = (void **) &closure->tramp[0]; + + if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI) + return FFI_BAD_ABI; + + /* Copy function address and TOC from ffi_closure_LINUX64 OPD. */ + memcpy (&tramp[0], (void **) ffi_closure_LINUX64, sizeof (void *)); + tramp[1] = codeloc; + memcpy (&tramp[2], (void **) ffi_closure_LINUX64 + 1, sizeof (void *)); +#endif + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + + +int FFI_HIDDEN +ffi_closure_helper_LINUX64 (ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + void *rvalue, + unsigned long *pst, + ffi_dblfl *pfr) +{ + /* rvalue is the pointer to space for return value in closure assembly */ + /* pst is the pointer to parameter save area + (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */ + /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */ + + void **avalue; + ffi_type **arg_types; + unsigned long i, avn, nfixedargs; + ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64; + unsigned long align; + + avalue = alloca (cif->nargs * sizeof (void *)); + + /* Copy the caller's structure return value address so that the + closure returns the data directly to the caller. */ + if (cif->rtype->type == FFI_TYPE_STRUCT + && (cif->flags & FLAG_RETURNS_SMST) == 0) + { + rvalue = (void *) *pst; + pst++; + } + + i = 0; + avn = cif->nargs; +#if _CALL_ELF != 2 + nfixedargs = (unsigned) -1; + if ((cif->flags & FLAG_COMPAT) == 0) +#endif + nfixedargs = cif->nfixedargs; + arg_types = cif->arg_types; + + /* Grab the addresses of the arguments from the stack frame. */ + while (i < avn) + { + unsigned int elt, elnum; + + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: +#ifndef __LITTLE_ENDIAN__ + avalue[i] = (char *) pst + 7; + pst++; + break; +#endif + + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: +#ifndef __LITTLE_ENDIAN__ + avalue[i] = (char *) pst + 6; + pst++; + break; +#endif + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: +#ifndef __LITTLE_ENDIAN__ + avalue[i] = (char *) pst + 4; + pst++; + break; +#endif + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + avalue[i] = pst; + pst++; + break; + + case FFI_TYPE_STRUCT: + if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0) + { + align = arg_types[i]->alignment; + if (align > 16) + align = 16; + if (align > 1) + pst = (unsigned long *) ALIGN ((size_t) pst, align); + } + elt = 0; +#if _CALL_ELF == 2 + elt = discover_homogeneous_aggregate (arg_types[i], &elnum); +#endif + if (elt) + { + union { + void *v; + unsigned long *ul; + float *f; + double *d; + size_t p; + } to, from; + + /* Repackage the aggregate from its parts. The + aggregate size is not greater than the space taken by + the registers so store back to the register/parameter + save arrays. */ + if (pfr + elnum <= end_pfr) + to.v = pfr; + else + to.v = pst; + + avalue[i] = to.v; + from.ul = pst; + if (elt == FFI_TYPE_FLOAT) + { + do + { + if (pfr < end_pfr && i < nfixedargs) + { + *to.f = (float) pfr->d; + pfr++; + } + else + *to.f = *from.f; + to.f++; + from.f++; + } + while (--elnum != 0); + } + else + { + do + { + if (pfr < end_pfr && i < nfixedargs) + { + *to.d = pfr->d; + pfr++; + } + else + *to.d = *from.d; + to.d++; + from.d++; + } + while (--elnum != 0); + } + } + else + { +#ifndef __LITTLE_ENDIAN__ + /* Structures with size less than eight bytes are passed + left-padded. */ + if (arg_types[i]->size < 8) + avalue[i] = (char *) pst + 8 - arg_types[i]->size; + else +#endif + avalue[i] = pst; + } + pst += (arg_types[i]->size + 7) / 8; + break; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + { + if (pfr + 1 < end_pfr && i + 1 < nfixedargs) + { + avalue[i] = pfr; + pfr += 2; + } + else + { + if (pfr < end_pfr && i < nfixedargs) + { + /* Passed partly in f13 and partly on the stack. + Move it all to the stack. */ + *pst = *(unsigned long *) pfr; + pfr++; + } + avalue[i] = pst; + } + pst += 2; + break; + } + /* Fall through. */ +#endif + case FFI_TYPE_DOUBLE: + /* On the outgoing stack all values are aligned to 8 */ + /* there are 13 64bit floating point registers */ + + if (pfr < end_pfr && i < nfixedargs) + { + avalue[i] = pfr; + pfr++; + } + else + avalue[i] = pst; + pst++; + break; + + case FFI_TYPE_FLOAT: + if (pfr < end_pfr && i < nfixedargs) + { + /* Float values are stored as doubles in the + ffi_closure_LINUX64 code. Fix them here. */ + pfr->f = (float) pfr->d; + avalue[i] = pfr; + pfr++; + } + else + avalue[i] = pst; + pst++; + break; + + default: + FFI_ASSERT (0); + } + + i++; + } + + (*fun) (cif, rvalue, avalue, user_data); + + /* Tell ffi_closure_LINUX64 how to perform return type promotions. */ + if ((cif->flags & FLAG_RETURNS_SMST) != 0) + { + if ((cif->flags & FLAG_RETURNS_FP) == 0) + return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1; + else if ((cif->flags & FLAG_RETURNS_64BITS) != 0) + return FFI_V2_TYPE_DOUBLE_HOMOG; + else + return FFI_V2_TYPE_FLOAT_HOMOG; + } + return cif->rtype->type; +} +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h b/user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h new file mode 100644 index 0000000..3dcd6b5 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h @@ -0,0 +1,94 @@ +/* ----------------------------------------------------------------------- + ffi_powerpc.h - Copyright (C) 2013 IBM + Copyright (C) 2011 Anthony Green + Copyright (C) 2011 Kyle Moffett + Copyright (C) 2008 Red Hat, Inc + Copyright (C) 2007, 2008 Free Software Foundation, Inc + Copyright (c) 1998 Geoffrey Keating + + PowerPC Foreign Function Interface + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +enum { + /* The assembly depends on these exact flags. */ + /* These go in cr7 */ + FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */ + FLAG_RETURNS_NOTHING = 1 << (31-30), + FLAG_RETURNS_FP = 1 << (31-29), + FLAG_RETURNS_64BITS = 1 << (31-28), + + /* This goes in cr6 */ + FLAG_RETURNS_128BITS = 1 << (31-27), + + FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */ + + /* These go in cr1 */ + FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */ + FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */ + FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ + FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), + FLAG_RETVAL_REFERENCE = 1 << (31- 4) +}; + +typedef union +{ + float f; + double d; +} ffi_dblfl; + +void FFI_HIDDEN ffi_closure_SYSV (void); +void FFI_HIDDEN ffi_go_closure_sysv (void); +void FFI_HIDDEN ffi_call_SYSV(extended_cif *, void (*)(void), void *, + unsigned, void *, int); + +void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi); +ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *); +ffi_status FFI_HIDDEN ffi_prep_closure_loc_sysv (ffi_closure *, + ffi_cif *, + void (*) (ffi_cif *, void *, + void **, void *), + void *, void *); +int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_cif *, + void (*) (ffi_cif *, void *, + void **, void *), + void *, void *, unsigned long *, + ffi_dblfl *, unsigned long *); + +void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, void (*) (void), void *, + unsigned long, void *, long); +void FFI_HIDDEN ffi_closure_LINUX64 (void); +void FFI_HIDDEN ffi_go_closure_linux64 (void); + +void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi); +ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *); +ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int, + unsigned int); +void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const); +ffi_status FFI_HIDDEN ffi_prep_closure_loc_linux64 (ffi_closure *, ffi_cif *, + void (*) (ffi_cif *, void *, + void **, void *), + void *, void *); +int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_cif *, + void (*) (ffi_cif *, void *, + void **, void *), + void *, void *, + unsigned long *, ffi_dblfl *); diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_sysv.c b/user/mpy/lib/libffi/src/powerpc/ffi_sysv.c new file mode 100644 index 0000000..646c340 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ffi_sysv.c @@ -0,0 +1,934 @@ +/* ----------------------------------------------------------------------- + ffi_sysv.c - Copyright (C) 2013 IBM + Copyright (C) 2011 Anthony Green + Copyright (C) 2011 Kyle Moffett + Copyright (C) 2008 Red Hat, Inc + Copyright (C) 2007, 2008 Free Software Foundation, Inc + Copyright (c) 1998 Geoffrey Keating + + PowerPC Foreign Function Interface + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ + +#include "ffi.h" + +#ifndef POWERPC64 +#include "ffi_common.h" +#include "ffi_powerpc.h" + + +/* About the SYSV ABI. */ +#define ASM_NEEDS_REGISTERS 6 +#define NUM_GPR_ARG_REGISTERS 8 +#define NUM_FPR_ARG_REGISTERS 8 + + +#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +/* Adjust size of ffi_type_longdouble. */ +void FFI_HIDDEN +ffi_prep_types_sysv (ffi_abi abi) +{ + if ((abi & (FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128)) == FFI_SYSV) + { + ffi_type_longdouble.size = 8; + ffi_type_longdouble.alignment = 8; + } + else + { + ffi_type_longdouble.size = 16; + ffi_type_longdouble.alignment = 16; + } +} +#endif + +/* Transform long double, double and float to other types as per abi. */ +static int +translate_float (int abi, int type) +{ +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + if (type == FFI_TYPE_LONGDOUBLE + && (abi & FFI_SYSV_LONG_DOUBLE_128) == 0) + type = FFI_TYPE_DOUBLE; +#endif + if ((abi & FFI_SYSV_SOFT_FLOAT) != 0) + { + if (type == FFI_TYPE_FLOAT) + type = FFI_TYPE_UINT32; + else if (type == FFI_TYPE_DOUBLE) + type = FFI_TYPE_UINT64; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + else if (type == FFI_TYPE_LONGDOUBLE) + type = FFI_TYPE_UINT128; + } + else if ((abi & FFI_SYSV_IBM_LONG_DOUBLE) == 0) + { + if (type == FFI_TYPE_LONGDOUBLE) + type = FFI_TYPE_STRUCT; +#endif + } + return type; +} + +/* Perform machine dependent cif processing */ +static ffi_status +ffi_prep_cif_sysv_core (ffi_cif *cif) +{ + ffi_type **ptr; + unsigned bytes; + unsigned i, fparg_count = 0, intarg_count = 0; + unsigned flags = cif->flags; + unsigned struct_copy_size = 0; + unsigned type = cif->rtype->type; + unsigned size = cif->rtype->size; + + /* The machine-independent calculation of cif->bytes doesn't work + for us. Redo the calculation. */ + + /* Space for the frame pointer, callee's LR, and the asm's temp regs. */ + bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int); + + /* Space for the GPR registers. */ + bytes += NUM_GPR_ARG_REGISTERS * sizeof (int); + + /* Return value handling. The rules for SYSV are as follows: + - 32-bit (or less) integer values are returned in gpr3; + - Structures of size <= 4 bytes also returned in gpr3; + - 64-bit integer values and structures between 5 and 8 bytes are returned + in gpr3 and gpr4; + - Larger structures are allocated space and a pointer is passed as + the first argument. + - Single/double FP values are returned in fpr1; + - long doubles (if not equivalent to double) are returned in + fpr1,fpr2 for Linux and as for large structs for SysV. */ + + type = translate_float (cif->abi, type); + + switch (type) + { +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + flags |= FLAG_RETURNS_128BITS; + /* Fall through. */ +#endif + case FFI_TYPE_DOUBLE: + flags |= FLAG_RETURNS_64BITS; + /* Fall through. */ + case FFI_TYPE_FLOAT: + flags |= FLAG_RETURNS_FP; +#ifdef __NO_FPRS__ + return FFI_BAD_ABI; +#endif + break; + + case FFI_TYPE_UINT128: + flags |= FLAG_RETURNS_128BITS; + /* Fall through. */ + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + flags |= FLAG_RETURNS_64BITS; + break; + + case FFI_TYPE_STRUCT: + /* The final SYSV ABI says that structures smaller or equal 8 bytes + are returned in r3/r4. A draft ABI used by linux instead + returns them in memory. */ + if ((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8) + { + flags |= FLAG_RETURNS_SMST; + break; + } + intarg_count++; + flags |= FLAG_RETVAL_REFERENCE; + /* Fall through. */ + case FFI_TYPE_VOID: + flags |= FLAG_RETURNS_NOTHING; + break; + + default: + /* Returns 32-bit integer, or similar. Nothing to do here. */ + break; + } + + /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the + first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest + goes on the stack. Structures and long doubles (if not equivalent + to double) are passed as a pointer to a copy of the structure. + Stuff on the stack needs to keep proper alignment. */ + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) + { + unsigned short typenum = (*ptr)->type; + + typenum = translate_float (cif->abi, typenum); + + switch (typenum) + { +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + fparg_count++; + /* Fall thru */ +#endif + case FFI_TYPE_DOUBLE: + fparg_count++; + /* If this FP arg is going on the stack, it must be + 8-byte-aligned. */ + if (fparg_count > NUM_FPR_ARG_REGISTERS + && intarg_count >= NUM_GPR_ARG_REGISTERS + && intarg_count % 2 != 0) + intarg_count++; +#ifdef __NO_FPRS__ + return FFI_BAD_ABI; +#endif + break; + + case FFI_TYPE_FLOAT: + fparg_count++; +#ifdef __NO_FPRS__ + return FFI_BAD_ABI; +#endif + break; + + case FFI_TYPE_UINT128: + /* A long double in FFI_LINUX_SOFT_FLOAT can use only a set + of four consecutive gprs. If we do not have enough, we + have to adjust the intarg_count value. */ + if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3 + && intarg_count < NUM_GPR_ARG_REGISTERS) + intarg_count = NUM_GPR_ARG_REGISTERS; + intarg_count += 4; + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + /* 'long long' arguments are passed as two words, but + either both words must fit in registers or both go + on the stack. If they go on the stack, they must + be 8-byte-aligned. + + Also, only certain register pairs can be used for + passing long long int -- specifically (r3,r4), (r5,r6), + (r7,r8), (r9,r10). */ + if (intarg_count == NUM_GPR_ARG_REGISTERS-1 + || intarg_count % 2 != 0) + intarg_count++; + intarg_count += 2; + break; + + case FFI_TYPE_STRUCT: + /* We must allocate space for a copy of these to enforce + pass-by-value. Pad the space up to a multiple of 16 + bytes (the maximum alignment required for anything under + the SYSV ABI). */ + struct_copy_size += ((*ptr)->size + 15) & ~0xF; + /* Fall through (allocate space for the pointer). */ + + case FFI_TYPE_POINTER: + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + /* Everything else is passed as a 4-byte word in a GPR, either + the object itself or a pointer to it. */ + intarg_count++; + break; + + default: + FFI_ASSERT (0); + } + } + + if (fparg_count != 0) + flags |= FLAG_FP_ARGUMENTS; + if (intarg_count > 4) + flags |= FLAG_4_GPR_ARGUMENTS; + if (struct_copy_size != 0) + flags |= FLAG_ARG_NEEDS_COPY; + + /* Space for the FPR registers, if needed. */ + if (fparg_count != 0) + bytes += NUM_FPR_ARG_REGISTERS * sizeof (double); + + /* Stack space. */ + if (intarg_count > NUM_GPR_ARG_REGISTERS) + bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int); + if (fparg_count > NUM_FPR_ARG_REGISTERS) + bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double); + + /* The stack space allocated needs to be a multiple of 16 bytes. */ + bytes = (bytes + 15) & ~0xF; + + /* Add in the space for the copied structures. */ + bytes += struct_copy_size; + + cif->flags = flags; + cif->bytes = bytes; + + return FFI_OK; +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_sysv (ffi_cif *cif) +{ + if ((cif->abi & FFI_SYSV) == 0) + { + /* This call is from old code. Translate to new ABI values. */ + cif->flags |= FLAG_COMPAT; + switch (cif->abi) + { + default: + return FFI_BAD_ABI; + + case FFI_COMPAT_SYSV: + cif->abi = FFI_SYSV | FFI_SYSV_STRUCT_RET | FFI_SYSV_LONG_DOUBLE_128; + break; + + case FFI_COMPAT_GCC_SYSV: + cif->abi = FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128; + break; + + case FFI_COMPAT_LINUX: + cif->abi = (FFI_SYSV | FFI_SYSV_IBM_LONG_DOUBLE + | FFI_SYSV_LONG_DOUBLE_128); + break; + + case FFI_COMPAT_LINUX_SOFT_FLOAT: + cif->abi = (FFI_SYSV | FFI_SYSV_SOFT_FLOAT | FFI_SYSV_IBM_LONG_DOUBLE + | FFI_SYSV_LONG_DOUBLE_128); + break; + } + } + return ffi_prep_cif_sysv_core (cif); +} + +/* ffi_prep_args_SYSV is called by the assembly routine once stack space + has been allocated for the function's arguments. + + The stack layout we want looks like this: + + | Return address from ffi_call_SYSV 4bytes | higher addresses + |--------------------------------------------| + | Previous backchain pointer 4 | stack pointer here + |--------------------------------------------|<+ <<< on entry to + | Saved r28-r31 4*4 | | ffi_call_SYSV + |--------------------------------------------| | + | GPR registers r3-r10 8*4 | | ffi_call_SYSV + |--------------------------------------------| | + | FPR registers f1-f8 (optional) 8*8 | | + |--------------------------------------------| | stack | + | Space for copied structures | | grows | + |--------------------------------------------| | down V + | Parameters that didn't fit in registers | | + |--------------------------------------------| | lower addresses + | Space for callee's LR 4 | | + |--------------------------------------------| | stack pointer here + | Current backchain pointer 4 |-/ during + |--------------------------------------------| <<< ffi_call_SYSV + +*/ + +void FFI_HIDDEN +ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack) +{ + const unsigned bytes = ecif->cif->bytes; + const unsigned flags = ecif->cif->flags; + + typedef union + { + char *c; + unsigned *u; + long long *ll; + float *f; + double *d; + } valp; + + /* 'stacktop' points at the previous backchain pointer. */ + valp stacktop; + + /* 'gpr_base' points at the space for gpr3, and grows upwards as + we use GPR registers. */ + valp gpr_base; + int intarg_count; + +#ifndef __NO_FPRS__ + /* 'fpr_base' points at the space for fpr1, and grows upwards as + we use FPR registers. */ + valp fpr_base; + int fparg_count; +#endif + + /* 'copy_space' grows down as we put structures in it. It should + stay 16-byte aligned. */ + valp copy_space; + + /* 'next_arg' grows up as we put parameters in it. */ + valp next_arg; + + int i; + ffi_type **ptr; +#ifndef __NO_FPRS__ + double double_tmp; +#endif + union + { + void **v; + char **c; + signed char **sc; + unsigned char **uc; + signed short **ss; + unsigned short **us; + unsigned int **ui; + long long **ll; + float **f; + double **d; + } p_argv; + size_t struct_copy_size; + unsigned gprvalue; + + stacktop.c = (char *) stack + bytes; + gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS; + intarg_count = 0; +#ifndef __NO_FPRS__ + fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS; + fparg_count = 0; + copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c); +#else + copy_space.c = gpr_base.c; +#endif + next_arg.u = stack + 2; + + /* Check that everything starts aligned properly. */ + FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0); + FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0); + FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0); + FFI_ASSERT ((bytes & 0xF) == 0); + FFI_ASSERT (copy_space.c >= next_arg.c); + + /* Deal with return values that are actually pass-by-reference. */ + if (flags & FLAG_RETVAL_REFERENCE) + { + *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue; + intarg_count++; + } + + /* Now for the arguments. */ + p_argv.v = ecif->avalue; + for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs; + i > 0; + i--, ptr++, p_argv.v++) + { + unsigned int typenum = (*ptr)->type; + + typenum = translate_float (ecif->cif->abi, typenum); + + /* Now test the translated value */ + switch (typenum) + { +#ifndef __NO_FPRS__ +# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + double_tmp = (*p_argv.d)[0]; + + if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1) + { + if (intarg_count >= NUM_GPR_ARG_REGISTERS + && intarg_count % 2 != 0) + { + intarg_count++; + next_arg.u++; + } + *next_arg.d = double_tmp; + next_arg.u += 2; + double_tmp = (*p_argv.d)[1]; + *next_arg.d = double_tmp; + next_arg.u += 2; + } + else + { + *fpr_base.d++ = double_tmp; + double_tmp = (*p_argv.d)[1]; + *fpr_base.d++ = double_tmp; + } + + fparg_count += 2; + FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + break; +# endif + case FFI_TYPE_DOUBLE: + double_tmp = **p_argv.d; + + if (fparg_count >= NUM_FPR_ARG_REGISTERS) + { + if (intarg_count >= NUM_GPR_ARG_REGISTERS + && intarg_count % 2 != 0) + { + intarg_count++; + next_arg.u++; + } + *next_arg.d = double_tmp; + next_arg.u += 2; + } + else + *fpr_base.d++ = double_tmp; + fparg_count++; + FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + break; + + case FFI_TYPE_FLOAT: + double_tmp = **p_argv.f; + if (fparg_count >= NUM_FPR_ARG_REGISTERS) + { + *next_arg.f = (float) double_tmp; + next_arg.u += 1; + intarg_count++; + } + else + *fpr_base.d++ = double_tmp; + fparg_count++; + FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + break; +#endif /* have FPRs */ + + case FFI_TYPE_UINT128: + /* The soft float ABI for long doubles works like this, a long double + is passed in four consecutive GPRs if available. A maximum of 2 + long doubles can be passed in gprs. If we do not have 4 GPRs + left, the long double is passed on the stack, 4-byte aligned. */ + { + unsigned int int_tmp; + unsigned int ii; + if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) + { + if (intarg_count < NUM_GPR_ARG_REGISTERS) + intarg_count = NUM_GPR_ARG_REGISTERS; + for (ii = 0; ii < 4; ii++) + { + int_tmp = (*p_argv.ui)[ii]; + *next_arg.u++ = int_tmp; + } + } + else + { + for (ii = 0; ii < 4; ii++) + { + int_tmp = (*p_argv.ui)[ii]; + *gpr_base.u++ = int_tmp; + } + } + intarg_count += 4; + break; + } + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + if (intarg_count == NUM_GPR_ARG_REGISTERS-1) + intarg_count++; + if (intarg_count >= NUM_GPR_ARG_REGISTERS) + { + if (intarg_count % 2 != 0) + { + intarg_count++; + next_arg.u++; + } + *next_arg.ll = **p_argv.ll; + next_arg.u += 2; + } + else + { + /* The abi states only certain register pairs can be + used for passing long long int specifically (r3,r4), + (r5,r6), (r7,r8), (r9,r10). If next arg is long long + but not correct starting register of pair then skip + until the proper starting register. */ + if (intarg_count % 2 != 0) + { + intarg_count ++; + gpr_base.u++; + } + *gpr_base.ll++ = **p_argv.ll; + } + intarg_count += 2; + break; + + case FFI_TYPE_STRUCT: + struct_copy_size = ((*ptr)->size + 15) & ~0xF; + copy_space.c -= struct_copy_size; + memcpy (copy_space.c, *p_argv.c, (*ptr)->size); + + gprvalue = (unsigned long) copy_space.c; + + FFI_ASSERT (copy_space.c > next_arg.c); + FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY); + goto putgpr; + + case FFI_TYPE_UINT8: + gprvalue = **p_argv.uc; + goto putgpr; + case FFI_TYPE_SINT8: + gprvalue = **p_argv.sc; + goto putgpr; + case FFI_TYPE_UINT16: + gprvalue = **p_argv.us; + goto putgpr; + case FFI_TYPE_SINT16: + gprvalue = **p_argv.ss; + goto putgpr; + + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + + gprvalue = **p_argv.ui; + + putgpr: + if (intarg_count >= NUM_GPR_ARG_REGISTERS) + *next_arg.u++ = gprvalue; + else + *gpr_base.u++ = gprvalue; + intarg_count++; + break; + } + } + + /* Check that we didn't overrun the stack... */ + FFI_ASSERT (copy_space.c >= next_arg.c); + FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS); + /* The assert below is testing that the number of integer arguments agrees + with the number found in ffi_prep_cif_machdep(). However, intarg_count + is incremented whenever we place an FP arg on the stack, so account for + that before our assert test. */ +#ifndef __NO_FPRS__ + if (fparg_count > NUM_FPR_ARG_REGISTERS) + intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS; + FFI_ASSERT (fpr_base.u + <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); +#endif + FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); +} + +#define MIN_CACHE_LINE_SIZE 8 + +static void +flush_icache (char *wraddr, char *xaddr, int size) +{ + int i; + for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) + __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" + : : "r" (xaddr + i), "r" (wraddr + i) : "memory"); + __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;" + : : "r"(xaddr + size - 1), "r"(wraddr + size - 1) + : "memory"); +} + +ffi_status FFI_HIDDEN +ffi_prep_closure_loc_sysv (ffi_closure *closure, + ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + void *codeloc) +{ + unsigned int *tramp; + + if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI) + return FFI_BAD_ABI; + + tramp = (unsigned int *) &closure->tramp[0]; + tramp[0] = 0x7c0802a6; /* mflr r0 */ + tramp[1] = 0x429f0005; /* bcl 20,31,.+4 */ + tramp[2] = 0x7d6802a6; /* mflr r11 */ + tramp[3] = 0x7c0803a6; /* mtlr r0 */ + tramp[4] = 0x800b0018; /* lwz r0,24(r11) */ + tramp[5] = 0x816b001c; /* lwz r11,28(r11) */ + tramp[6] = 0x7c0903a6; /* mtctr r0 */ + tramp[7] = 0x4e800420; /* bctr */ + *(void **) &tramp[8] = (void *) ffi_closure_SYSV; /* function */ + *(void **) &tramp[9] = codeloc; /* context */ + + /* Flush the icache. */ + flush_icache ((char *)tramp, (char *)codeloc, 8 * 4); + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +/* Basically the trampoline invokes ffi_closure_SYSV, and on + entry, r11 holds the address of the closure. + After storing the registers that could possibly contain + parameters to be passed into the stack frame and setting + up space for a return value, ffi_closure_SYSV invokes the + following helper function to do most of the work. */ + +int +ffi_closure_helper_SYSV (ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + void *rvalue, + unsigned long *pgr, + ffi_dblfl *pfr, + unsigned long *pst) +{ + /* rvalue is the pointer to space for return value in closure assembly */ + /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */ + /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */ + /* pst is the pointer to outgoing parameter stack in original caller */ + + void ** avalue; + ffi_type ** arg_types; + long i, avn; +#ifndef __NO_FPRS__ + long nf = 0; /* number of floating registers already used */ +#endif + long ng = 0; /* number of general registers already used */ + + unsigned size = cif->rtype->size; + unsigned short rtypenum = cif->rtype->type; + + avalue = alloca (cif->nargs * sizeof (void *)); + + /* First translate for softfloat/nonlinux */ + rtypenum = translate_float (cif->abi, rtypenum); + + /* Copy the caller's structure return value address so that the closure + returns the data directly to the caller. + For FFI_SYSV the result is passed in r3/r4 if the struct size is less + or equal 8 bytes. */ + if (rtypenum == FFI_TYPE_STRUCT + && !((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)) + { + rvalue = (void *) *pgr; + ng++; + pgr++; + } + + i = 0; + avn = cif->nargs; + arg_types = cif->arg_types; + + /* Grab the addresses of the arguments from the stack frame. */ + while (i < avn) { + unsigned short typenum = arg_types[i]->type; + + /* We may need to handle some values depending on ABI. */ + typenum = translate_float (cif->abi, typenum); + + switch (typenum) + { +#ifndef __NO_FPRS__ + case FFI_TYPE_FLOAT: + /* Unfortunately float values are stored as doubles + in the ffi_closure_SYSV code (since we don't check + the type in that routine). */ + if (nf < NUM_FPR_ARG_REGISTERS) + { + /* FIXME? here we are really changing the values + stored in the original calling routines outgoing + parameter stack. This is probably a really + naughty thing to do but... */ + double temp = pfr->d; + pfr->f = (float) temp; + avalue[i] = pfr; + nf++; + pfr++; + } + else + { + avalue[i] = pst; + pst += 1; + } + break; + + case FFI_TYPE_DOUBLE: + if (nf < NUM_FPR_ARG_REGISTERS) + { + avalue[i] = pfr; + nf++; + pfr++; + } + else + { + if (((long) pst) & 4) + pst++; + avalue[i] = pst; + pst += 2; + } + break; + +# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + if (nf < NUM_FPR_ARG_REGISTERS - 1) + { + avalue[i] = pfr; + pfr += 2; + nf += 2; + } + else + { + if (((long) pst) & 4) + pst++; + avalue[i] = pst; + pst += 4; + nf = 8; + } + break; +# endif +#endif + + case FFI_TYPE_UINT128: + /* Test if for the whole long double, 4 gprs are available. + otherwise the stuff ends up on the stack. */ + if (ng < NUM_GPR_ARG_REGISTERS - 3) + { + avalue[i] = pgr; + pgr += 4; + ng += 4; + } + else + { + avalue[i] = pst; + pst += 4; + ng = 8+4; + } + break; + + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: +#ifndef __LITTLE_ENDIAN__ + if (ng < NUM_GPR_ARG_REGISTERS) + { + avalue[i] = (char *) pgr + 3; + ng++; + pgr++; + } + else + { + avalue[i] = (char *) pst + 3; + pst++; + } + break; +#endif + + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: +#ifndef __LITTLE_ENDIAN__ + if (ng < NUM_GPR_ARG_REGISTERS) + { + avalue[i] = (char *) pgr + 2; + ng++; + pgr++; + } + else + { + avalue[i] = (char *) pst + 2; + pst++; + } + break; +#endif + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + if (ng < NUM_GPR_ARG_REGISTERS) + { + avalue[i] = pgr; + ng++; + pgr++; + } + else + { + avalue[i] = pst; + pst++; + } + break; + + case FFI_TYPE_STRUCT: + /* Structs are passed by reference. The address will appear in a + gpr if it is one of the first 8 arguments. */ + if (ng < NUM_GPR_ARG_REGISTERS) + { + avalue[i] = (void *) *pgr; + ng++; + pgr++; + } + else + { + avalue[i] = (void *) *pst; + pst++; + } + break; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + /* Passing long long ints are complex, they must + be passed in suitable register pairs such as + (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10) + and if the entire pair aren't available then the outgoing + parameter stack is used for both but an alignment of 8 + must will be kept. So we must either look in pgr + or pst to find the correct address for this type + of parameter. */ + if (ng < NUM_GPR_ARG_REGISTERS - 1) + { + if (ng & 1) + { + /* skip r4, r6, r8 as starting points */ + ng++; + pgr++; + } + avalue[i] = pgr; + ng += 2; + pgr += 2; + } + else + { + if (((long) pst) & 4) + pst++; + avalue[i] = pst; + pst += 2; + ng = NUM_GPR_ARG_REGISTERS; + } + break; + + default: + FFI_ASSERT (0); + } + + i++; + } + + (*fun) (cif, rvalue, avalue, user_data); + + /* Tell ffi_closure_SYSV how to perform return type promotions. + Because the FFI_SYSV ABI returns the structures <= 8 bytes in + r3/r4 we have to tell ffi_closure_SYSV how to treat them. We + combine the base type FFI_SYSV_TYPE_SMALL_STRUCT with the size of + the struct less one. We never have a struct with size zero. + See the comment in ffitarget.h about ordering. */ + if (rtypenum == FFI_TYPE_STRUCT + && (cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8) + return FFI_SYSV_TYPE_SMALL_STRUCT - 1 + size; + return rtypenum; +} +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ffitarget.h b/user/mpy/lib/libffi/src/powerpc/ffitarget.h new file mode 100644 index 0000000..0f66d31 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ffitarget.h @@ -0,0 +1,195 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc + Copyright (c) 1996-2003 Red Hat, Inc. + + Target configuration macros for PowerPC. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#if defined (POWERPC) && defined (__powerpc64__) /* linux64 */ +#ifndef POWERPC64 +#define POWERPC64 +#endif +#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */ +#ifndef POWERPC64 +#define POWERPC64 +#endif +#ifndef POWERPC_DARWIN64 +#define POWERPC_DARWIN64 +#endif +#elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */ +#ifndef POWERPC64 +#define POWERPC64 +#endif +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + +#if defined (POWERPC_AIX) + FFI_AIX, + FFI_DARWIN, + FFI_DEFAULT_ABI = FFI_AIX, + FFI_LAST_ABI + +#elif defined (POWERPC_DARWIN) + FFI_AIX, + FFI_DARWIN, + FFI_DEFAULT_ABI = FFI_DARWIN, + FFI_LAST_ABI + +#else + /* The FFI_COMPAT values are used by old code. Since libffi may be + a shared library we have to support old values for backwards + compatibility. */ + FFI_COMPAT_SYSV, + FFI_COMPAT_GCC_SYSV, + FFI_COMPAT_LINUX64, + FFI_COMPAT_LINUX, + FFI_COMPAT_LINUX_SOFT_FLOAT, + +# if defined (POWERPC64) + /* This bit, always set in new code, must not be set in any of the + old FFI_COMPAT values that might be used for 64-bit linux. We + only need worry about FFI_COMPAT_LINUX64, but to be safe avoid + all old values. */ + FFI_LINUX = 8, + /* This and following bits can reuse FFI_COMPAT values. */ + FFI_LINUX_STRUCT_ALIGN = 1, + FFI_LINUX_LONG_DOUBLE_128 = 2, + FFI_DEFAULT_ABI = (FFI_LINUX +# ifdef __STRUCT_PARM_ALIGN__ + | FFI_LINUX_STRUCT_ALIGN +# endif +# ifdef __LONG_DOUBLE_128__ + | FFI_LINUX_LONG_DOUBLE_128 +# endif + ), + FFI_LAST_ABI = 12 + +# else + /* This bit, always set in new code, must not be set in any of the + old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd. */ + FFI_SYSV = 8, + /* This and following bits can reuse FFI_COMPAT values. */ + FFI_SYSV_SOFT_FLOAT = 1, + FFI_SYSV_STRUCT_RET = 2, + FFI_SYSV_IBM_LONG_DOUBLE = 4, + FFI_SYSV_LONG_DOUBLE_128 = 16, + + FFI_DEFAULT_ABI = (FFI_SYSV +# ifdef __NO_FPRS__ + | FFI_SYSV_SOFT_FLOAT +# endif +# if (defined (__SVR4_STRUCT_RETURN) \ + || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN)) + | FFI_SYSV_STRUCT_RET +# endif +# if __LDBL_MANT_DIG__ == 106 + | FFI_SYSV_IBM_LONG_DOUBLE +# endif +# ifdef __LONG_DOUBLE_128__ + | FFI_SYSV_LONG_DOUBLE_128 +# endif + ), + FFI_LAST_ABI = 32 +# endif +#endif + +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 +#if defined (POWERPC) || defined (POWERPC_FREEBSD) +# define FFI_GO_CLOSURES 1 +# define FFI_TARGET_SPECIFIC_VARIADIC 1 +# define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs +#endif + +/* ppc_closure.S and linux64_closure.S expect this. */ +#define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER + +/* We define additional types below. If generic types are added that + must be supported by powerpc libffi then it is likely that + FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in + ppc_closure.S and linux64_closure.S be extended. */ + +#if !(FFI_TYPE_LAST == FFI_PPC_TYPE_LAST \ + || (FFI_TYPE_LAST == FFI_TYPE_COMPLEX \ + && !defined FFI_TARGET_HAS_COMPLEX_TYPE)) +# error "You likely have a broken powerpc libffi" +#endif + +/* Needed for soft-float long-double-128 support. */ +#define FFI_TYPE_UINT128 (FFI_PPC_TYPE_LAST + 1) + +/* Needed for FFI_SYSV small structure returns. */ +#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2) + +/* Used by ELFv2 for homogenous structure returns. */ +#define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 1) +#define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 2) +#define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 3) + +#if _CALL_ELF == 2 +# define FFI_TRAMPOLINE_SIZE 32 +#else +# if defined(POWERPC64) || defined(POWERPC_AIX) +# if defined(POWERPC_DARWIN64) +# define FFI_TRAMPOLINE_SIZE 48 +# else +# define FFI_TRAMPOLINE_SIZE 24 +# endif +# else /* POWERPC || POWERPC_AIX */ +# define FFI_TRAMPOLINE_SIZE 40 +# endif +#endif + +#ifndef LIBFFI_ASM +#if defined(POWERPC_DARWIN) || defined(POWERPC_AIX) +struct ffi_aix_trampoline_struct { + void * code_pointer; /* Pointer to ffi_closure_ASM */ + void * toc; /* TOC */ + void * static_chain; /* Pointer to closure */ +}; +#endif +#endif + +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/linux64.S b/user/mpy/lib/libffi/src/powerpc/linux64.S new file mode 100644 index 0000000..b2ae60e --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/linux64.S @@ -0,0 +1,228 @@ +/* ----------------------------------------------------------------------- + sysv.h - Copyright (c) 2003 Jakub Jelinek + Copyright (c) 2008 Red Hat, Inc. + + PowerPC64 Assembly glue. + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +#ifdef POWERPC64 + .hidden ffi_call_LINUX64 + .globl ffi_call_LINUX64 + .text + .cfi_startproc +# if _CALL_ELF == 2 +ffi_call_LINUX64: + addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha + addi %r2, %r2, .TOC.-ffi_call_LINUX64@l + .localentry ffi_call_LINUX64, . - ffi_call_LINUX64 +# else + .section ".opd","aw" + .align 3 +ffi_call_LINUX64: +# ifdef _CALL_LINUX + .quad .L.ffi_call_LINUX64,.TOC.@tocbase,0 + .type ffi_call_LINUX64,@function + .text +.L.ffi_call_LINUX64: +# else + .hidden .ffi_call_LINUX64 + .globl .ffi_call_LINUX64 + .quad .ffi_call_LINUX64,.TOC.@tocbase,0 + .size ffi_call_LINUX64,24 + .type .ffi_call_LINUX64,@function + .text +.ffi_call_LINUX64: +# endif +# endif + mflr %r0 + std %r28, -32(%r1) + std %r29, -24(%r1) + std %r30, -16(%r1) + std %r31, -8(%r1) + std %r7, 8(%r1) /* closure, saved in cr field. */ + std %r0, 16(%r1) + + mr %r28, %r1 /* our AP. */ + .cfi_def_cfa_register 28 + .cfi_offset 65, 16 + .cfi_offset 31, -8 + .cfi_offset 30, -16 + .cfi_offset 29, -24 + .cfi_offset 28, -32 + + stdux %r1, %r1, %r8 + mr %r31, %r6 /* flags, */ + mr %r30, %r5 /* rvalue, */ + mr %r29, %r4 /* function address. */ +/* Save toc pointer, not for the ffi_prep_args64 call, but for the later + bctrl function call. */ +# if _CALL_ELF == 2 + std %r2, 24(%r1) +# else + std %r2, 40(%r1) +# endif + + /* Call ffi_prep_args64. */ + mr %r4, %r1 +# if defined _CALL_LINUX || _CALL_ELF == 2 + bl ffi_prep_args64 +# else + bl .ffi_prep_args64 +# endif + +# if _CALL_ELF == 2 + mr %r12, %r29 +# else + ld %r12, 0(%r29) + ld %r2, 8(%r29) +# endif + /* Now do the call. */ + /* Set up cr1 with bits 4-7 of the flags. */ + mtcrf 0x40, %r31 + + /* Get the address to call into CTR. */ + mtctr %r12 + /* Load all those argument registers. */ + ld %r3, -32-(8*8)(%r28) + ld %r4, -32-(7*8)(%r28) + ld %r5, -32-(6*8)(%r28) + ld %r6, -32-(5*8)(%r28) + bf- 5, 1f + ld %r7, -32-(4*8)(%r28) + ld %r8, -32-(3*8)(%r28) + ld %r9, -32-(2*8)(%r28) + ld %r10, -32-(1*8)(%r28) +1: + + /* Load all the FP registers. */ + bf- 6, 2f + lfd %f1, -32-(21*8)(%r28) + lfd %f2, -32-(20*8)(%r28) + lfd %f3, -32-(19*8)(%r28) + lfd %f4, -32-(18*8)(%r28) + lfd %f5, -32-(17*8)(%r28) + lfd %f6, -32-(16*8)(%r28) + lfd %f7, -32-(15*8)(%r28) + lfd %f8, -32-(14*8)(%r28) + lfd %f9, -32-(13*8)(%r28) + lfd %f10, -32-(12*8)(%r28) + lfd %f11, -32-(11*8)(%r28) + lfd %f12, -32-(10*8)(%r28) + lfd %f13, -32-(9*8)(%r28) +2: + + /* Make the call. */ + ld %r11, 8(%r28) + bctrl + + /* This must follow the call immediately, the unwinder + uses this to find out if r2 has been saved or not. */ +# if _CALL_ELF == 2 + ld %r2, 24(%r1) +# else + ld %r2, 40(%r1) +# endif + + /* Now, deal with the return value. */ + mtcrf 0x01, %r31 + bt 31, .Lstruct_return_value + bt 30, .Ldone_return_value + bt 29, .Lfp_return_value + std %r3, 0(%r30) + /* Fall through... */ + +.Ldone_return_value: + /* Restore the registers we used and return. */ + mr %r1, %r28 + .cfi_def_cfa_register 1 + ld %r0, 16(%r28) + ld %r28, -32(%r28) + mtlr %r0 + ld %r29, -24(%r1) + ld %r30, -16(%r1) + ld %r31, -8(%r1) + blr + +.Lfp_return_value: + .cfi_def_cfa_register 28 + bf 28, .Lfloat_return_value + stfd %f1, 0(%r30) + mtcrf 0x02, %r31 /* cr6 */ + bf 27, .Ldone_return_value + stfd %f2, 8(%r30) + b .Ldone_return_value +.Lfloat_return_value: + stfs %f1, 0(%r30) + b .Ldone_return_value + +.Lstruct_return_value: + bf 29, .Lsmall_struct + bf 28, .Lfloat_homog_return_value + stfd %f1, 0(%r30) + stfd %f2, 8(%r30) + stfd %f3, 16(%r30) + stfd %f4, 24(%r30) + stfd %f5, 32(%r30) + stfd %f6, 40(%r30) + stfd %f7, 48(%r30) + stfd %f8, 56(%r30) + b .Ldone_return_value + +.Lfloat_homog_return_value: + stfs %f1, 0(%r30) + stfs %f2, 4(%r30) + stfs %f3, 8(%r30) + stfs %f4, 12(%r30) + stfs %f5, 16(%r30) + stfs %f6, 20(%r30) + stfs %f7, 24(%r30) + stfs %f8, 28(%r30) + b .Ldone_return_value + +.Lsmall_struct: + std %r3, 0(%r30) + std %r4, 8(%r30) + b .Ldone_return_value + + .cfi_endproc +# if _CALL_ELF == 2 + .size ffi_call_LINUX64,.-ffi_call_LINUX64 +# else +# ifdef _CALL_LINUX + .size ffi_call_LINUX64,.-.L.ffi_call_LINUX64 +# else + .long 0 + .byte 0,12,0,1,128,4,0,0 + .size .ffi_call_LINUX64,.-.ffi_call_LINUX64 +# endif +# endif + +#endif + +#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2 + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/linux64_closure.S b/user/mpy/lib/libffi/src/powerpc/linux64_closure.S new file mode 100644 index 0000000..6487d2a --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/linux64_closure.S @@ -0,0 +1,488 @@ +/* ----------------------------------------------------------------------- + sysv.h - Copyright (c) 2003 Jakub Jelinek + Copyright (c) 2008 Red Hat, Inc. + + PowerPC64 Assembly glue. + + 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. + ----------------------------------------------------------------------- */ +#define LIBFFI_ASM +#include +#include + + .file "linux64_closure.S" + +#ifdef POWERPC64 + FFI_HIDDEN (ffi_closure_LINUX64) + .globl ffi_closure_LINUX64 + .text + .cfi_startproc +# if _CALL_ELF == 2 +ffi_closure_LINUX64: + addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha + addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l + .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64 +# else + .section ".opd","aw" + .align 3 +ffi_closure_LINUX64: +# ifdef _CALL_LINUX + .quad .L.ffi_closure_LINUX64,.TOC.@tocbase,0 + .type ffi_closure_LINUX64,@function + .text +.L.ffi_closure_LINUX64: +# else + FFI_HIDDEN (.ffi_closure_LINUX64) + .globl .ffi_closure_LINUX64 + .quad .ffi_closure_LINUX64,.TOC.@tocbase,0 + .size ffi_closure_LINUX64,24 + .type .ffi_closure_LINUX64,@function + .text +.ffi_closure_LINUX64: +# endif +# endif + +# if _CALL_ELF == 2 +# 32 byte special reg save area + 64 byte parm save area +# + 64 byte retval area + 13*8 fpr save area + round to 16 +# define STACKFRAME 272 +# define PARMSAVE 32 +# define RETVAL PARMSAVE+64 +# else +# 48 bytes special reg save area + 64 bytes parm save area +# + 16 bytes retval area + 13*8 bytes fpr save area + round to 16 +# define STACKFRAME 240 +# define PARMSAVE 48 +# define RETVAL PARMSAVE+64 +# endif + +# if _CALL_ELF == 2 + ld %r12, FFI_TRAMPOLINE_SIZE(%r11) # closure->cif + mflr %r0 + lwz %r12, 28(%r12) # cif->flags + mtcrf 0x40, %r12 + addi %r12, %r1, PARMSAVE + bt 7, 0f + # Our caller has not allocated a parameter save area. + # We need to allocate one here and use it to pass gprs to + # ffi_closure_helper_LINUX64. + addi %r12, %r1, -STACKFRAME+PARMSAVE +0: + # Save general regs into parm save area + std %r3, 0(%r12) + std %r4, 8(%r12) + std %r5, 16(%r12) + std %r6, 24(%r12) + std %r7, 32(%r12) + std %r8, 40(%r12) + std %r9, 48(%r12) + std %r10, 56(%r12) + + # load up the pointer to the parm save area + mr %r7, %r12 +# else + # copy r2 to r11 and load TOC into r2 + mr %r11, %r2 + ld %r2, 16(%r2) + + mflr %r0 + # Save general regs into parm save area + # This is the parameter save area set up by our caller. + std %r3, PARMSAVE+0(%r1) + std %r4, PARMSAVE+8(%r1) + std %r5, PARMSAVE+16(%r1) + std %r6, PARMSAVE+24(%r1) + std %r7, PARMSAVE+32(%r1) + std %r8, PARMSAVE+40(%r1) + std %r9, PARMSAVE+48(%r1) + std %r10, PARMSAVE+56(%r1) + + # load up the pointer to the parm save area + addi %r7, %r1, PARMSAVE +# endif + std %r0, 16(%r1) + + # closure->cif + ld %r3, FFI_TRAMPOLINE_SIZE(%r11) + # closure->fun + ld %r4, FFI_TRAMPOLINE_SIZE+8(%r11) + # closure->user_data + ld %r5, FFI_TRAMPOLINE_SIZE+16(%r11) + +.Ldoclosure: + # next save fpr 1 to fpr 13 + stfd %f1, -104+(0*8)(%r1) + stfd %f2, -104+(1*8)(%r1) + stfd %f3, -104+(2*8)(%r1) + stfd %f4, -104+(3*8)(%r1) + stfd %f5, -104+(4*8)(%r1) + stfd %f6, -104+(5*8)(%r1) + stfd %f7, -104+(6*8)(%r1) + stfd %f8, -104+(7*8)(%r1) + stfd %f9, -104+(8*8)(%r1) + stfd %f10, -104+(9*8)(%r1) + stfd %f11, -104+(10*8)(%r1) + stfd %f12, -104+(11*8)(%r1) + stfd %f13, -104+(12*8)(%r1) + + # load up the pointer to the saved fpr registers */ + addi %r8, %r1, -104 + + # load up the pointer to the result storage + addi %r6, %r1, -STACKFRAME+RETVAL + + stdu %r1, -STACKFRAME(%r1) + .cfi_def_cfa_offset STACKFRAME + .cfi_offset 65, 16 + + # make the call +# if defined _CALL_LINUX || _CALL_ELF == 2 + bl ffi_closure_helper_LINUX64 +# else + bl .ffi_closure_helper_LINUX64 +# endif +.Lret: + + # now r3 contains the return type + # so use it to look up in a table + # so we know how to deal with each type + + # look up the proper starting point in table + # by using return type as offset + ld %r0, STACKFRAME+16(%r1) + cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT + bge .Lsmall + mflr %r4 # move address of .Lret to r4 + sldi %r3, %r3, 4 # now multiply return type by 16 + addi %r4, %r4, .Lret_type0 - .Lret + add %r3, %r3, %r4 # add contents of table to table address + mtctr %r3 + bctr # jump to it + +# Each of the ret_typeX code fragments has to be exactly 16 bytes long +# (4 instructions). For cache effectiveness we align to a 16 byte boundary +# first. + .align 4 + +.Lret_type0: +# case FFI_TYPE_VOID + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME + nop +# case FFI_TYPE_INT +# ifdef __LITTLE_ENDIAN__ + lwa %r3, RETVAL+0(%r1) +# else + lwa %r3, RETVAL+4(%r1) +# endif + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_FLOAT + lfs %f1, RETVAL+0(%r1) + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_DOUBLE + lfd %f1, RETVAL+0(%r1) + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_LONGDOUBLE + lfd %f1, RETVAL+0(%r1) + mtlr %r0 + lfd %f2, RETVAL+8(%r1) + b .Lfinish +# case FFI_TYPE_UINT8 +# ifdef __LITTLE_ENDIAN__ + lbz %r3, RETVAL+0(%r1) +# else + lbz %r3, RETVAL+7(%r1) +# endif + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_SINT8 +# ifdef __LITTLE_ENDIAN__ + lbz %r3, RETVAL+0(%r1) +# else + lbz %r3, RETVAL+7(%r1) +# endif + extsb %r3,%r3 + mtlr %r0 + b .Lfinish +# case FFI_TYPE_UINT16 +# ifdef __LITTLE_ENDIAN__ + lhz %r3, RETVAL+0(%r1) +# else + lhz %r3, RETVAL+6(%r1) +# endif + mtlr %r0 +.Lfinish: + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_SINT16 +# ifdef __LITTLE_ENDIAN__ + lha %r3, RETVAL+0(%r1) +# else + lha %r3, RETVAL+6(%r1) +# endif + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_UINT32 +# ifdef __LITTLE_ENDIAN__ + lwz %r3, RETVAL+0(%r1) +# else + lwz %r3, RETVAL+4(%r1) +# endif + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_SINT32 +# ifdef __LITTLE_ENDIAN__ + lwa %r3, RETVAL+0(%r1) +# else + lwa %r3, RETVAL+4(%r1) +# endif + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_UINT64 + ld %r3, RETVAL+0(%r1) + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_SINT64 + ld %r3, RETVAL+0(%r1) + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_TYPE_STRUCT + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME + nop +# case FFI_TYPE_POINTER + ld %r3, RETVAL+0(%r1) + mtlr %r0 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +# case FFI_V2_TYPE_FLOAT_HOMOG + lfs %f1, RETVAL+0(%r1) + lfs %f2, RETVAL+4(%r1) + lfs %f3, RETVAL+8(%r1) + b .Lmorefloat +# case FFI_V2_TYPE_DOUBLE_HOMOG + lfd %f1, RETVAL+0(%r1) + lfd %f2, RETVAL+8(%r1) + lfd %f3, RETVAL+16(%r1) + lfd %f4, RETVAL+24(%r1) + mtlr %r0 + lfd %f5, RETVAL+32(%r1) + lfd %f6, RETVAL+40(%r1) + lfd %f7, RETVAL+48(%r1) + lfd %f8, RETVAL+56(%r1) + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +.Lmorefloat: + lfs %f4, RETVAL+12(%r1) + mtlr %r0 + lfs %f5, RETVAL+16(%r1) + lfs %f6, RETVAL+20(%r1) + lfs %f7, RETVAL+24(%r1) + lfs %f8, RETVAL+28(%r1) + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +.Lsmall: +# ifdef __LITTLE_ENDIAN__ + ld %r3,RETVAL+0(%r1) + mtlr %r0 + ld %r4,RETVAL+8(%r1) + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr +# else + # A struct smaller than a dword is returned in the low bits of r3 + # ie. right justified. Larger structs are passed left justified + # in r3 and r4. The return value area on the stack will have + # the structs as they are usually stored in memory. + cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT + 7 # size 8 bytes? + neg %r5, %r3 + ld %r3,RETVAL+0(%r1) + blt .Lsmalldown + mtlr %r0 + ld %r4,RETVAL+8(%r1) + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME +.Lsmalldown: + addi %r5, %r5, FFI_V2_TYPE_SMALL_STRUCT + 7 + mtlr %r0 + sldi %r5, %r5, 3 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + srd %r3, %r3, %r5 + blr +# endif + + .cfi_endproc +# if _CALL_ELF == 2 + .size ffi_closure_LINUX64,.-ffi_closure_LINUX64 +# else +# ifdef _CALL_LINUX + .size ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64 +# else + .long 0 + .byte 0,12,0,1,128,0,0,0 + .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64 +# endif +# endif + + + FFI_HIDDEN (ffi_go_closure_linux64) + .globl ffi_go_closure_linux64 + .text + .cfi_startproc +# if _CALL_ELF == 2 +ffi_go_closure_linux64: + addis %r2, %r12, .TOC.-ffi_go_closure_linux64@ha + addi %r2, %r2, .TOC.-ffi_go_closure_linux64@l + .localentry ffi_go_closure_linux64, . - ffi_go_closure_linux64 +# else + .section ".opd","aw" + .align 3 +ffi_go_closure_linux64: +# ifdef _CALL_LINUX + .quad .L.ffi_go_closure_linux64,.TOC.@tocbase,0 + .type ffi_go_closure_linux64,@function + .text +.L.ffi_go_closure_linux64: +# else + FFI_HIDDEN (.ffi_go_closure_linux64) + .globl .ffi_go_closure_linux64 + .quad .ffi_go_closure_linux64,.TOC.@tocbase,0 + .size ffi_go_closure_linux64,24 + .type .ffi_go_closure_linux64,@function + .text +.ffi_go_closure_linux64: +# endif +# endif + +# if _CALL_ELF == 2 + ld %r12, 8(%r11) # closure->cif + mflr %r0 + lwz %r12, 28(%r12) # cif->flags + mtcrf 0x40, %r12 + addi %r12, %r1, PARMSAVE + bt 7, 0f + # Our caller has not allocated a parameter save area. + # We need to allocate one here and use it to pass gprs to + # ffi_closure_helper_LINUX64. + addi %r12, %r1, -STACKFRAME+PARMSAVE +0: + # Save general regs into parm save area + std %r3, 0(%r12) + std %r4, 8(%r12) + std %r5, 16(%r12) + std %r6, 24(%r12) + std %r7, 32(%r12) + std %r8, 40(%r12) + std %r9, 48(%r12) + std %r10, 56(%r12) + + # load up the pointer to the parm save area + mr %r7, %r12 +# else + mflr %r0 + # Save general regs into parm save area + # This is the parameter save area set up by our caller. + std %r3, PARMSAVE+0(%r1) + std %r4, PARMSAVE+8(%r1) + std %r5, PARMSAVE+16(%r1) + std %r6, PARMSAVE+24(%r1) + std %r7, PARMSAVE+32(%r1) + std %r8, PARMSAVE+40(%r1) + std %r9, PARMSAVE+48(%r1) + std %r10, PARMSAVE+56(%r1) + + # load up the pointer to the parm save area + addi %r7, %r1, PARMSAVE +# endif + std %r0, 16(%r1) + + # closure->cif + ld %r3, 8(%r11) + # closure->fun + ld %r4, 16(%r11) + # user_data + mr %r5, %r11 + b .Ldoclosure + + .cfi_endproc +# if _CALL_ELF == 2 + .size ffi_go_closure_linux64,.-ffi_go_closure_linux64 +# else +# ifdef _CALL_LINUX + .size ffi_go_closure_linux64,.-.L.ffi_go_closure_linux64 +# else + .long 0 + .byte 0,12,0,1,128,0,0,0 + .size .ffi_go_closure_linux64,.-.ffi_go_closure_linux64 +# endif +# endif +#endif + +#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2 + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ppc_closure.S b/user/mpy/lib/libffi/src/powerpc/ppc_closure.S new file mode 100644 index 0000000..b6d209d --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/ppc_closure.S @@ -0,0 +1,397 @@ +/* ----------------------------------------------------------------------- + sysv.h - Copyright (c) 2003 Jakub Jelinek + Copyright (c) 2008 Red Hat, Inc. + + PowerPC Assembly glue. + + 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. + ----------------------------------------------------------------------- */ +#define LIBFFI_ASM +#include +#include +#include + + .file "ppc_closure.S" + +#ifndef POWERPC64 + +FFI_HIDDEN(ffi_closure_SYSV) +ENTRY(ffi_closure_SYSV) + .cfi_startproc + stwu %r1,-144(%r1) + .cfi_def_cfa_offset 144 + mflr %r0 + stw %r0,148(%r1) + .cfi_offset 65, 4 + +# we want to build up an areas for the parameters passed +# in registers (both floating point and integer) + + # so first save gpr 3 to gpr 10 (aligned to 4) + stw %r3, 16(%r1) + stw %r4, 20(%r1) + stw %r5, 24(%r1) + + # set up registers for the routine that does the work + + # closure->cif + lwz %r3,FFI_TRAMPOLINE_SIZE(%r11) + # closure->fun + lwz %r4,FFI_TRAMPOLINE_SIZE+4(%r11) + # closure->user_data + lwz %r5,FFI_TRAMPOLINE_SIZE+8(%r11) + +.Ldoclosure: + stw %r6, 28(%r1) + stw %r7, 32(%r1) + stw %r8, 36(%r1) + stw %r9, 40(%r1) + stw %r10,44(%r1) + +#ifndef __NO_FPRS__ + # next save fpr 1 to fpr 8 (aligned to 8) + stfd %f1, 48(%r1) + stfd %f2, 56(%r1) + stfd %f3, 64(%r1) + stfd %f4, 72(%r1) + stfd %f5, 80(%r1) + stfd %f6, 88(%r1) + stfd %f7, 96(%r1) + stfd %f8, 104(%r1) +#endif + + # pointer to the result storage + addi %r6,%r1,112 + + # pointer to the saved gpr registers + addi %r7,%r1,16 + + # pointer to the saved fpr registers + addi %r8,%r1,48 + + # pointer to the outgoing parameter save area in the previous frame + # i.e. the previous frame pointer + 8 + addi %r9,%r1,152 + + # make the call + bl ffi_closure_helper_SYSV@local +.Lret: + # now r3 contains the return type + # so use it to look up in a table + # so we know how to deal with each type + + # look up the proper starting point in table + # by using return type as offset + + mflr %r4 # move address of .Lret to r4 + slwi %r3,%r3,4 # now multiply return type by 16 + addi %r4, %r4, .Lret_type0 - .Lret + lwz %r0,148(%r1) + add %r3,%r3,%r4 # add contents of table to table address + mtctr %r3 + bctr # jump to it + +# Each of the ret_typeX code fragments has to be exactly 16 bytes long +# (4 instructions). For cache effectiveness we align to a 16 byte boundary +# first. + .align 4 +# case FFI_TYPE_VOID +.Lret_type0: + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + nop + +# case FFI_TYPE_INT + lwz %r3,112+0(%r1) + mtlr %r0 +.Lfinish: + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_FLOAT +#ifndef __NO_FPRS__ + lfs %f1,112+0(%r1) +#else + nop +#endif + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_DOUBLE +#ifndef __NO_FPRS__ + lfd %f1,112+0(%r1) +#else + nop +#endif + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_LONGDOUBLE +#ifndef __NO_FPRS__ + lfd %f1,112+0(%r1) + lfd %f2,112+8(%r1) + mtlr %r0 + b .Lfinish +#else + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + nop +#endif + +# case FFI_TYPE_UINT8 +#ifdef __LITTLE_ENDIAN__ + lbz %r3,112+0(%r1) +#else + lbz %r3,112+3(%r1) +#endif + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_SINT8 +#ifdef __LITTLE_ENDIAN__ + lbz %r3,112+0(%r1) +#else + lbz %r3,112+3(%r1) +#endif + extsb %r3,%r3 + mtlr %r0 + b .Lfinish + +# case FFI_TYPE_UINT16 +#ifdef __LITTLE_ENDIAN__ + lhz %r3,112+0(%r1) +#else + lhz %r3,112+2(%r1) +#endif + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_SINT16 +#ifdef __LITTLE_ENDIAN__ + lha %r3,112+0(%r1) +#else + lha %r3,112+2(%r1) +#endif + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_UINT32 + lwz %r3,112+0(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_SINT32 + lwz %r3,112+0(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_UINT64 + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) + mtlr %r0 + b .Lfinish + +# case FFI_TYPE_SINT64 + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) + mtlr %r0 + b .Lfinish + +# case FFI_TYPE_STRUCT + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + nop + +# case FFI_TYPE_POINTER + lwz %r3,112+0(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_TYPE_UINT128 + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) + lwz %r5,112+8(%r1) + b .Luint128 + +# The return types below are only used when the ABI type is FFI_SYSV. +# case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct. + lbz %r3,112+0(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 2. Two byte struct. + lhz %r3,112+0(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct. + lwz %r3,112+0(%r1) +#ifdef __LITTLE_ENDIAN__ + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 +#else + srwi %r3,%r3,8 + mtlr %r0 + b .Lfinish +#endif + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct. + lwz %r3,112+0(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct. + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) +#ifdef __LITTLE_ENDIAN__ + mtlr %r0 + b .Lfinish +#else + li %r5,24 + b .Lstruct567 +#endif + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct. + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) +#ifdef __LITTLE_ENDIAN__ + mtlr %r0 + b .Lfinish +#else + li %r5,16 + b .Lstruct567 +#endif + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct. + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) +#ifdef __LITTLE_ENDIAN__ + mtlr %r0 + b .Lfinish +#else + li %r5,8 + b .Lstruct567 +#endif + +# case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct. + lwz %r3,112+0(%r1) + lwz %r4,112+4(%r1) + mtlr %r0 + b .Lfinish + +#ifndef __LITTLE_ENDIAN__ +.Lstruct567: + subfic %r6,%r5,32 + srw %r4,%r4,%r5 + slw %r6,%r3,%r6 + srw %r3,%r3,%r5 + or %r4,%r6,%r4 + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset 144 +#endif + +.Luint128: + lwz %r6,112+12(%r1) + mtlr %r0 + addi %r1,%r1,144 + .cfi_def_cfa_offset 0 + blr + .cfi_endproc +END(ffi_closure_SYSV) + + +FFI_HIDDEN(ffi_go_closure_sysv) +ENTRY(ffi_go_closure_sysv) + .cfi_startproc + stwu %r1,-144(%r1) + .cfi_def_cfa_offset 144 + mflr %r0 + stw %r0,148(%r1) + .cfi_offset 65, 4 + + stw %r3, 16(%r1) + stw %r4, 20(%r1) + stw %r5, 24(%r1) + + # closure->cif + lwz %r3,4(%r11) + # closure->fun + lwz %r4,8(%r11) + # user_data + mr %r5,%r11 + b .Ldoclosure + .cfi_endproc +END(ffi_go_closure_sysv) + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif +#endif diff --git a/user/mpy/lib/libffi/src/powerpc/sysv.S b/user/mpy/lib/libffi/src/powerpc/sysv.S new file mode 100644 index 0000000..1474ce7 --- /dev/null +++ b/user/mpy/lib/libffi/src/powerpc/sysv.S @@ -0,0 +1,175 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 1998 Geoffrey Keating + Copyright (C) 2007 Free Software Foundation, Inc + + PowerPC Assembly glue. + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#include + +#ifndef POWERPC64 +FFI_HIDDEN(ffi_call_SYSV) +ENTRY(ffi_call_SYSV) + .cfi_startproc + /* Save the old stack pointer as AP. */ + mr %r10,%r1 + .cfi_def_cfa_register 10 + + /* Allocate the stack space we need. */ + stwux %r1,%r1,%r8 + /* Save registers we use. */ + mflr %r9 + stw %r28,-16(%r10) + stw %r29,-12(%r10) + stw %r30, -8(%r10) + stw %r31, -4(%r10) + stw %r9, 4(%r10) + .cfi_offset 65, 4 + .cfi_offset 31, -4 + .cfi_offset 30, -8 + .cfi_offset 29, -12 + .cfi_offset 28, -16 + + /* Save arguments over call... */ + stw %r7, -20(%r10) /* closure, */ + mr %r31,%r6 /* flags, */ + mr %r30,%r5 /* rvalue, */ + mr %r29,%r4 /* function address, */ + mr %r28,%r10 /* our AP. */ + .cfi_def_cfa_register 28 + + /* Call ffi_prep_args_SYSV. */ + mr %r4,%r1 + bl ffi_prep_args_SYSV@local + + /* Now do the call. */ + /* Set up cr1 with bits 4-7 of the flags. */ + mtcrf 0x40,%r31 + /* Get the address to call into CTR. */ + mtctr %r29 + /* Load all those argument registers. */ + lwz %r3,-24-(8*4)(%r28) + lwz %r4,-24-(7*4)(%r28) + lwz %r5,-24-(6*4)(%r28) + lwz %r6,-24-(5*4)(%r28) + bf- 5,1f + nop + lwz %r7,-24-(4*4)(%r28) + lwz %r8,-24-(3*4)(%r28) + lwz %r9,-24-(2*4)(%r28) + lwz %r10,-24-(1*4)(%r28) + nop +1: + +#ifndef __NO_FPRS__ + /* Load all the FP registers. */ + bf- 6,2f + lfd %f1,-24-(8*4)-(8*8)(%r28) + lfd %f2,-24-(8*4)-(7*8)(%r28) + lfd %f3,-24-(8*4)-(6*8)(%r28) + lfd %f4,-24-(8*4)-(5*8)(%r28) + nop + lfd %f5,-24-(8*4)-(4*8)(%r28) + lfd %f6,-24-(8*4)-(3*8)(%r28) + lfd %f7,-24-(8*4)-(2*8)(%r28) + lfd %f8,-24-(8*4)-(1*8)(%r28) +#endif +2: + + /* Make the call. */ + lwz %r11, -20(%r28) + bctrl + + /* Now, deal with the return value. */ + mtcrf 0x01,%r31 /* cr7 */ + bt- 31,L(small_struct_return_value) + bt- 30,L(done_return_value) +#ifndef __NO_FPRS__ + bt- 29,L(fp_return_value) +#endif + stw %r3,0(%r30) + bf+ 28,L(done_return_value) + stw %r4,4(%r30) + mtcrf 0x02,%r31 /* cr6 */ + bf 27,L(done_return_value) + stw %r5,8(%r30) + stw %r6,12(%r30) + /* Fall through... */ + +L(done_return_value): + /* Restore the registers we used and return. */ + lwz %r9, 4(%r28) + lwz %r31, -4(%r28) + mtlr %r9 + lwz %r30, -8(%r28) + lwz %r29,-12(%r28) + lwz %r28,-16(%r28) + .cfi_remember_state + /* At this point we don't have a cfa register. Say all our + saved regs have been restored. */ + .cfi_same_value 65 + .cfi_same_value 31 + .cfi_same_value 30 + .cfi_same_value 29 + .cfi_same_value 28 + /* Hopefully this works.. */ + .cfi_def_cfa_register 1 + .cfi_offset 1, 0 + lwz %r1,0(%r1) + .cfi_same_value 1 + blr + +#ifndef __NO_FPRS__ +L(fp_return_value): + .cfi_restore_state + bf 28,L(float_return_value) + stfd %f1,0(%r30) + mtcrf 0x02,%r31 /* cr6 */ + bf 27,L(done_return_value) + stfd %f2,8(%r30) + b L(done_return_value) +L(float_return_value): + stfs %f1,0(%r30) + b L(done_return_value) +#endif + +L(small_struct_return_value): + /* + * The C code always allocates a properly-aligned 8-byte bounce + * buffer to make this assembly code very simple. Just write out + * r3 and r4 to the buffer to allow the C code to handle the rest. + */ + stw %r3, 0(%r30) + stw %r4, 4(%r30) + b L(done_return_value) + .cfi_endproc + +END(ffi_call_SYSV) + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif +#endif diff --git a/user/mpy/lib/libffi/src/prep_cif.c b/user/mpy/lib/libffi/src/prep_cif.c new file mode 100644 index 0000000..5881ceb --- /dev/null +++ b/user/mpy/lib/libffi/src/prep_cif.c @@ -0,0 +1,242 @@ +/* ----------------------------------------------------------------------- + prep_cif.c - Copyright (c) 2011, 2012 Anthony Green + Copyright (c) 1996, 1998, 2007 Red Hat, Inc. + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include + +/* Round up to FFI_SIZEOF_ARG. */ + +#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG) + +/* Perform machine independent initialization of aggregate type + specifications. */ + +static ffi_status initialize_aggregate(ffi_type *arg) +{ + ffi_type **ptr; + + if (UNLIKELY(arg == NULL || arg->elements == NULL)) + return FFI_BAD_TYPEDEF; + + arg->size = 0; + arg->alignment = 0; + + ptr = &(arg->elements[0]); + + if (UNLIKELY(ptr == 0)) + return FFI_BAD_TYPEDEF; + + while ((*ptr) != NULL) + { + if (UNLIKELY(((*ptr)->size == 0) + && (initialize_aggregate((*ptr)) != FFI_OK))) + return FFI_BAD_TYPEDEF; + + /* Perform a sanity check on the argument type */ + FFI_ASSERT_VALID_TYPE(*ptr); + + arg->size = ALIGN(arg->size, (*ptr)->alignment); + arg->size += (*ptr)->size; + + arg->alignment = (arg->alignment > (*ptr)->alignment) ? + arg->alignment : (*ptr)->alignment; + + ptr++; + } + + /* Structure size includes tail padding. This is important for + structures that fit in one register on ABIs like the PowerPC64 + Linux ABI that right justify small structs in a register. + It's also needed for nested structure layout, for example + struct A { long a; char b; }; struct B { struct A x; char y; }; + should find y at an offset of 2*sizeof(long) and result in a + total size of 3*sizeof(long). */ + arg->size = ALIGN (arg->size, arg->alignment); + + /* On some targets, the ABI defines that structures have an additional + alignment beyond the "natural" one based on their elements. */ +#ifdef FFI_AGGREGATE_ALIGNMENT + if (FFI_AGGREGATE_ALIGNMENT > arg->alignment) + arg->alignment = FFI_AGGREGATE_ALIGNMENT; +#endif + + if (arg->size == 0) + return FFI_BAD_TYPEDEF; + else + return FFI_OK; +} + +#ifndef __CRIS__ +/* The CRIS ABI specifies structure elements to have byte + alignment only, so it completely overrides this functions, + which assumes "natural" alignment and padding. */ + +/* Perform machine independent ffi_cif preparation, then call + machine dependent routine. */ + +/* For non variadic functions isvariadic should be 0 and + nfixedargs==ntotalargs. + + For variadic calls, isvariadic should be 1 and nfixedargs + and ntotalargs set as appropriate. nfixedargs must always be >=1 */ + + +ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, + unsigned int isvariadic, + unsigned int nfixedargs, + unsigned int ntotalargs, + ffi_type *rtype, ffi_type **atypes) +{ + unsigned bytes = 0; + unsigned int i; + ffi_type **ptr; + + FFI_ASSERT(cif != NULL); + FFI_ASSERT((!isvariadic) || (nfixedargs >= 1)); + FFI_ASSERT(nfixedargs <= ntotalargs); + + if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)) + return FFI_BAD_ABI; + + cif->abi = abi; + cif->arg_types = atypes; + cif->nargs = ntotalargs; + cif->rtype = rtype; + + cif->flags = 0; + +#if HAVE_LONG_DOUBLE_VARIANT + ffi_prep_types (abi); +#endif + + /* Initialize the return type if necessary */ + if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK)) + return FFI_BAD_TYPEDEF; + +#ifndef FFI_TARGET_HAS_COMPLEX_TYPE + if (rtype->type == FFI_TYPE_COMPLEX) + abort(); +#endif + /* Perform a sanity check on the return type */ + FFI_ASSERT_VALID_TYPE(cif->rtype); + + /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */ +#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION + /* Make space for the return structure pointer */ + if (cif->rtype->type == FFI_TYPE_STRUCT +#ifdef TILE + && (cif->rtype->size > 10 * FFI_SIZEOF_ARG) +#endif +#ifdef XTENSA + && (cif->rtype->size > 16) +#endif +#ifdef NIOS2 + && (cif->rtype->size > 8) +#endif + ) + bytes = STACK_ARG_SIZE(sizeof(void*)); +#endif + + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) + { + + /* Initialize any uninitialized aggregate type definitions */ + if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK)) + return FFI_BAD_TYPEDEF; + +#ifndef FFI_TARGET_HAS_COMPLEX_TYPE + if ((*ptr)->type == FFI_TYPE_COMPLEX) + abort(); +#endif + /* Perform a sanity check on the argument type, do this + check after the initialization. */ + FFI_ASSERT_VALID_TYPE(*ptr); + +#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION + { + /* Add any padding if necessary */ + if (((*ptr)->alignment - 1) & bytes) + bytes = (unsigned)ALIGN(bytes, (*ptr)->alignment); + +#ifdef TILE + if (bytes < 10 * FFI_SIZEOF_ARG && + bytes + STACK_ARG_SIZE((*ptr)->size) > 10 * FFI_SIZEOF_ARG) + { + /* An argument is never split between the 10 parameter + registers and the stack. */ + bytes = 10 * FFI_SIZEOF_ARG; + } +#endif +#ifdef XTENSA + if (bytes <= 6*4 && bytes + STACK_ARG_SIZE((*ptr)->size) > 6*4) + bytes = 6*4; +#endif + + bytes += STACK_ARG_SIZE((*ptr)->size); + } +#endif + } + + cif->bytes = bytes; + + /* Perform machine dependent cif processing */ +#ifdef FFI_TARGET_SPECIFIC_VARIADIC + if (isvariadic) + return ffi_prep_cif_machdep_var(cif, nfixedargs, ntotalargs); +#endif + + return ffi_prep_cif_machdep(cif); +} +#endif /* not __CRIS__ */ + +ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, + ffi_type *rtype, ffi_type **atypes) +{ + return ffi_prep_cif_core(cif, abi, 0, nargs, nargs, rtype, atypes); +} + +ffi_status ffi_prep_cif_var(ffi_cif *cif, + ffi_abi abi, + unsigned int nfixedargs, + unsigned int ntotalargs, + ffi_type *rtype, + ffi_type **atypes) +{ + return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes); +} + +#if FFI_CLOSURES + +ffi_status +ffi_prep_closure (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data) +{ + return ffi_prep_closure_loc (closure, cif, fun, user_data, closure); +} + +#endif diff --git a/user/mpy/lib/libffi/src/raw_api.c b/user/mpy/lib/libffi/src/raw_api.c new file mode 100644 index 0000000..276cb22 --- /dev/null +++ b/user/mpy/lib/libffi/src/raw_api.c @@ -0,0 +1,267 @@ +/* ----------------------------------------------------------------------- + raw_api.c - Copyright (c) 1999, 2008 Red Hat, Inc. + + Author: Kresten Krab Thorup + + 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. + ----------------------------------------------------------------------- */ + +/* This file defines generic functions for use with the raw api. */ + +#include +#include + +#if !FFI_NO_RAW_API + +size_t +ffi_raw_size (ffi_cif *cif) +{ + size_t result = 0; + int i; + + ffi_type **at = cif->arg_types; + + for (i = cif->nargs-1; i >= 0; i--, at++) + { +#if !FFI_NO_STRUCTS + if ((*at)->type == FFI_TYPE_STRUCT) + result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG); + else +#endif + result += ALIGN ((*at)->size, FFI_SIZEOF_ARG); + } + + return result; +} + + +void +ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args) +{ + unsigned i; + ffi_type **tp = cif->arg_types; + +#if WORDS_BIGENDIAN + + for (i = 0; i < cif->nargs; i++, tp++, args++) + { + switch ((*tp)->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1); + break; + + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2); + break; + +#if FFI_SIZEOF_ARG >= 4 + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4); + break; +#endif + +#if !FFI_NO_STRUCTS + case FFI_TYPE_STRUCT: + *args = (raw++)->ptr; + break; +#endif + + case FFI_TYPE_COMPLEX: + *args = (raw++)->ptr; + break; + + case FFI_TYPE_POINTER: + *args = (void*) &(raw++)->ptr; + break; + + default: + *args = raw; + raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; + } + } + +#else /* WORDS_BIGENDIAN */ + +#if !PDP + + /* then assume little endian */ + for (i = 0; i < cif->nargs; i++, tp++, args++) + { +#if !FFI_NO_STRUCTS + if ((*tp)->type == FFI_TYPE_STRUCT) + { + *args = (raw++)->ptr; + } + else +#endif + if ((*tp)->type == FFI_TYPE_COMPLEX) + { + *args = (raw++)->ptr; + } + else + { + *args = (void*) raw; + raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*); + } + } + +#else +#error "pdp endian not supported" +#endif /* ! PDP */ + +#endif /* WORDS_BIGENDIAN */ +} + +void +ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw) +{ + unsigned i; + ffi_type **tp = cif->arg_types; + + for (i = 0; i < cif->nargs; i++, tp++, args++) + { + switch ((*tp)->type) + { + case FFI_TYPE_UINT8: + (raw++)->uint = *(UINT8*) (*args); + break; + + case FFI_TYPE_SINT8: + (raw++)->sint = *(SINT8*) (*args); + break; + + case FFI_TYPE_UINT16: + (raw++)->uint = *(UINT16*) (*args); + break; + + case FFI_TYPE_SINT16: + (raw++)->sint = *(SINT16*) (*args); + break; + +#if FFI_SIZEOF_ARG >= 4 + case FFI_TYPE_UINT32: + (raw++)->uint = *(UINT32*) (*args); + break; + + case FFI_TYPE_SINT32: + (raw++)->sint = *(SINT32*) (*args); + break; +#endif + +#if !FFI_NO_STRUCTS + case FFI_TYPE_STRUCT: + (raw++)->ptr = *args; + break; +#endif + + case FFI_TYPE_COMPLEX: + (raw++)->ptr = *args; + break; + + case FFI_TYPE_POINTER: + (raw++)->ptr = **(void***) args; + break; + + default: + memcpy ((void*) raw->data, (void*)*args, (*tp)->size); + raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; + } + } +} + +#if !FFI_NATIVE_RAW_API + + +/* This is a generic definition of ffi_raw_call, to be used if the + * native system does not provide a machine-specific implementation. + * Having this, allows code to be written for the raw API, without + * the need for system-specific code to handle input in that format; + * these following couple of functions will handle the translation forth + * and back automatically. */ + +void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw) +{ + void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); + ffi_raw_to_ptrarray (cif, raw, avalue); + ffi_call (cif, fn, rvalue, avalue); +} + +#if FFI_CLOSURES /* base system provides closures */ + +static void +ffi_translate_args (ffi_cif *cif, void *rvalue, + void **avalue, void *user_data) +{ + ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif)); + ffi_raw_closure *cl = (ffi_raw_closure*)user_data; + + ffi_ptrarray_to_raw (cif, avalue, raw); + (*cl->fun) (cif, rvalue, raw, cl->user_data); +} + +ffi_status +ffi_prep_raw_closure_loc (ffi_raw_closure* cl, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data, + void *codeloc) +{ + ffi_status status; + + status = ffi_prep_closure_loc ((ffi_closure*) cl, + cif, + &ffi_translate_args, + codeloc, + codeloc); + if (status == FFI_OK) + { + cl->fun = fun; + cl->user_data = user_data; + } + + return status; +} + +#endif /* FFI_CLOSURES */ +#endif /* !FFI_NATIVE_RAW_API */ + +#if FFI_CLOSURES + +/* Again, here is the generic version of ffi_prep_raw_closure, which + * will install an intermediate "hub" for translation of arguments from + * the pointer-array format, to the raw format */ + +ffi_status +ffi_prep_raw_closure (ffi_raw_closure* cl, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data) +{ + return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl); +} + +#endif /* FFI_CLOSURES */ + +#endif /* !FFI_NO_RAW_API */ diff --git a/user/mpy/lib/libffi/src/s390/ffi.c b/user/mpy/lib/libffi/src/s390/ffi.c new file mode 100644 index 0000000..4035b6e --- /dev/null +++ b/user/mpy/lib/libffi/src/s390/ffi.c @@ -0,0 +1,756 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2000, 2007 Software AG + Copyright (c) 2008 Red Hat, Inc + + S390 Foreign Function Interface + + 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 AUTHOR 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. + ----------------------------------------------------------------------- */ +/*====================================================================*/ +/* Includes */ +/* -------- */ +/*====================================================================*/ + +#include +#include +#include +#include "internal.h" + +/*====================== End of Includes =============================*/ + +/*====================================================================*/ +/* Defines */ +/* ------- */ +/*====================================================================*/ + +/* Maximum number of GPRs available for argument passing. */ +#define MAX_GPRARGS 5 + +/* Maximum number of FPRs available for argument passing. */ +#ifdef __s390x__ +#define MAX_FPRARGS 4 +#else +#define MAX_FPRARGS 2 +#endif + +/* Round to multiple of 16. */ +#define ROUND_SIZE(size) (((size) + 15) & ~15) + +/*===================== End of Defines ===============================*/ + +/*====================================================================*/ +/* Externals */ +/* --------- */ +/*====================================================================*/ + +struct call_frame +{ + void *back_chain; + void *eos; + unsigned long gpr_args[5]; + unsigned long gpr_save[9]; + unsigned long long fpr_args[4]; +}; + +extern void FFI_HIDDEN ffi_call_SYSV(struct call_frame *, unsigned, void *, + void (*fn)(void), void *); + +extern void ffi_closure_SYSV(void); +extern void ffi_go_closure_SYSV(void); + +/*====================== End of Externals ============================*/ + +/*====================================================================*/ +/* */ +/* Name - ffi_check_struct_type. */ +/* */ +/* Function - Determine if a structure can be passed within a */ +/* general purpose or floating point register. */ +/* */ +/*====================================================================*/ + +static int +ffi_check_struct_type (ffi_type *arg) +{ + size_t size = arg->size; + + /* If the struct has just one element, look at that element + to find out whether to consider the struct as floating point. */ + while (arg->type == FFI_TYPE_STRUCT + && arg->elements[0] && !arg->elements[1]) + arg = arg->elements[0]; + + /* Structs of size 1, 2, 4, and 8 are passed in registers, + just like the corresponding int/float types. */ + switch (size) + { + case 1: + return FFI_TYPE_UINT8; + + case 2: + return FFI_TYPE_UINT16; + + case 4: + if (arg->type == FFI_TYPE_FLOAT) + return FFI_TYPE_FLOAT; + else + return FFI_TYPE_UINT32; + + case 8: + if (arg->type == FFI_TYPE_DOUBLE) + return FFI_TYPE_DOUBLE; + else + return FFI_TYPE_UINT64; + + default: + break; + } + + /* Other structs are passed via a pointer to the data. */ + return FFI_TYPE_POINTER; +} + +/*======================== End of Routine ============================*/ + +/*====================================================================*/ +/* */ +/* Name - ffi_prep_cif_machdep. */ +/* */ +/* Function - Perform machine dependent CIF processing. */ +/* */ +/*====================================================================*/ + +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep(ffi_cif *cif) +{ + size_t struct_size = 0; + int n_gpr = 0; + int n_fpr = 0; + int n_ov = 0; + + ffi_type **ptr; + int i; + + /* Determine return value handling. */ + + switch (cif->rtype->type) + { + /* Void is easy. */ + case FFI_TYPE_VOID: + cif->flags = FFI390_RET_VOID; + break; + + /* Structures and complex are returned via a hidden pointer. */ + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: + cif->flags = FFI390_RET_STRUCT; + n_gpr++; /* We need one GPR to pass the pointer. */ + break; + + /* Floating point values are returned in fpr 0. */ + case FFI_TYPE_FLOAT: + cif->flags = FFI390_RET_FLOAT; + break; + + case FFI_TYPE_DOUBLE: + cif->flags = FFI390_RET_DOUBLE; + break; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + cif->flags = FFI390_RET_STRUCT; + n_gpr++; + break; +#endif + /* Integer values are returned in gpr 2 (and gpr 3 + for 64-bit values on 31-bit machines). */ + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + cif->flags = FFI390_RET_INT64; + break; + + case FFI_TYPE_POINTER: + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + /* These are to be extended to word size. */ +#ifdef __s390x__ + cif->flags = FFI390_RET_INT64; +#else + cif->flags = FFI390_RET_INT32; +#endif + break; + + default: + FFI_ASSERT (0); + break; + } + + /* Now for the arguments. */ + + for (ptr = cif->arg_types, i = cif->nargs; + i > 0; + i--, ptr++) + { + int type = (*ptr)->type; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + /* 16-byte long double is passed like a struct. */ + if (type == FFI_TYPE_LONGDOUBLE) + type = FFI_TYPE_STRUCT; +#endif + + /* Check how a structure type is passed. */ + if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX) + { + if (type == FFI_TYPE_COMPLEX) + type = FFI_TYPE_POINTER; + else + type = ffi_check_struct_type (*ptr); + + /* If we pass the struct via pointer, we must reserve space + to copy its data for proper call-by-value semantics. */ + if (type == FFI_TYPE_POINTER) + struct_size += ROUND_SIZE ((*ptr)->size); + } + + /* Now handle all primitive int/float data types. */ + switch (type) + { + /* The first MAX_FPRARGS floating point arguments + go in FPRs, the rest overflow to the stack. */ + + case FFI_TYPE_DOUBLE: + if (n_fpr < MAX_FPRARGS) + n_fpr++; + else + n_ov += sizeof (double) / sizeof (long); + break; + + case FFI_TYPE_FLOAT: + if (n_fpr < MAX_FPRARGS) + n_fpr++; + else + n_ov++; + break; + + /* On 31-bit machines, 64-bit integers are passed in GPR pairs, + if one is still available, or else on the stack. If only one + register is free, skip the register (it won't be used for any + subsequent argument either). */ + +#ifndef __s390x__ + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + if (n_gpr == MAX_GPRARGS-1) + n_gpr = MAX_GPRARGS; + if (n_gpr < MAX_GPRARGS) + n_gpr += 2; + else + n_ov += 2; + break; +#endif + + /* Everything else is passed in GPRs (until MAX_GPRARGS + have been used) or overflows to the stack. */ + + default: + if (n_gpr < MAX_GPRARGS) + n_gpr++; + else + n_ov++; + break; + } + } + + /* Total stack space as required for overflow arguments + and temporary structure copies. */ + + cif->bytes = ROUND_SIZE (n_ov * sizeof (long)) + struct_size; + + return FFI_OK; +} + +/*======================== End of Routine ============================*/ + +/*====================================================================*/ +/* */ +/* Name - ffi_call. */ +/* */ +/* Function - Call the FFI routine. */ +/* */ +/*====================================================================*/ + +static void +ffi_call_int(ffi_cif *cif, + void (*fn)(void), + void *rvalue, + void **avalue, + void *closure) +{ + int ret_type = cif->flags; + size_t rsize = 0, bytes = cif->bytes; + unsigned char *stack, *p_struct; + struct call_frame *frame; + unsigned long *p_ov, *p_gpr; + unsigned long long *p_fpr; + int n_fpr, n_gpr, n_ov, i, n; + ffi_type **arg_types; + + FFI_ASSERT (cif->abi == FFI_SYSV); + + /* If we don't have a return value, we need to fake one. */ + if (rvalue == NULL) + { + if (ret_type & FFI390_RET_IN_MEM) + rsize = cif->rtype->size; + else + ret_type = FFI390_RET_VOID; + } + + /* The stack space will be filled with those areas: + + dummy structure return (highest addresses) + FPR argument register save area + GPR argument register save area + stack frame for ffi_call_SYSV + temporary struct copies + overflow argument area (lowest addresses) + + We set up the following pointers: + + p_fpr: bottom of the FPR area (growing upwards) + p_gpr: bottom of the GPR area (growing upwards) + p_ov: bottom of the overflow area (growing upwards) + p_struct: top of the struct copy area (growing downwards) + + All areas are kept aligned to twice the word size. + + Note that we're going to create the stack frame for both + ffi_call_SYSV _and_ the target function right here. This + works because we don't make any function calls with more + than 5 arguments (indeed only memcpy and ffi_call_SYSV), + and thus we don't have any stacked outgoing parameters. */ + + stack = alloca (bytes + sizeof(struct call_frame) + rsize); + frame = (struct call_frame *)(stack + bytes); + if (rsize) + rvalue = frame + 1; + + /* Link the new frame back to the one from this function. */ + frame->back_chain = __builtin_frame_address (0); + + /* Fill in all of the argument stuff. */ + p_ov = (unsigned long *)stack; + p_struct = (unsigned char *)frame; + p_gpr = frame->gpr_args; + p_fpr = frame->fpr_args; + n_fpr = n_gpr = n_ov = 0; + + /* If we returning a structure then we set the first parameter register + to the address of where we are returning this structure. */ + if (cif->flags & FFI390_RET_IN_MEM) + p_gpr[n_gpr++] = (uintptr_t) rvalue; + + /* Now for the arguments. */ + arg_types = cif->arg_types; + for (i = 0, n = cif->nargs; i < n; ++i) + { + ffi_type *ty = arg_types[i]; + void *arg = avalue[i]; + int type = ty->type; + ffi_arg val; + + restart: + switch (type) + { + case FFI_TYPE_SINT8: + val = *(SINT8 *)arg; + goto do_int; + case FFI_TYPE_UINT8: + val = *(UINT8 *)arg; + goto do_int; + case FFI_TYPE_SINT16: + val = *(SINT16 *)arg; + goto do_int; + case FFI_TYPE_UINT16: + val = *(UINT16 *)arg; + goto do_int; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + val = *(SINT32 *)arg; + goto do_int; + case FFI_TYPE_UINT32: + val = *(UINT32 *)arg; + goto do_int; + case FFI_TYPE_POINTER: + val = *(uintptr_t *)arg; + do_int: + *(n_gpr < MAX_GPRARGS ? p_gpr + n_gpr++ : p_ov + n_ov++) = val; + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: +#ifdef __s390x__ + val = *(UINT64 *)arg; + goto do_int; +#else + if (n_gpr == MAX_GPRARGS-1) + n_gpr = MAX_GPRARGS; + if (n_gpr < MAX_GPRARGS) + p_gpr[n_gpr++] = ((UINT32 *) arg)[0], + p_gpr[n_gpr++] = ((UINT32 *) arg)[1]; + else + p_ov[n_ov++] = ((UINT32 *) arg)[0], + p_ov[n_ov++] = ((UINT32 *) arg)[1]; +#endif + break; + + case FFI_TYPE_DOUBLE: + if (n_fpr < MAX_FPRARGS) + p_fpr[n_fpr++] = *(UINT64 *) arg; + else + { +#ifdef __s390x__ + p_ov[n_ov++] = *(UINT64 *) arg; +#else + p_ov[n_ov++] = ((UINT32 *) arg)[0], + p_ov[n_ov++] = ((UINT32 *) arg)[1]; +#endif + } + break; + + case FFI_TYPE_FLOAT: + val = *(UINT32 *)arg; + if (n_fpr < MAX_FPRARGS) + p_fpr[n_fpr++] = (UINT64)val << 32; + else + p_ov[n_ov++] = val; + break; + + case FFI_TYPE_STRUCT: + /* Check how a structure type is passed. */ + type = ffi_check_struct_type (ty); + /* Some structures are passed via a type they contain. */ + if (type != FFI_TYPE_POINTER) + goto restart; + /* ... otherwise, passed by reference. fallthru. */ + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + /* 16-byte long double is passed via reference. */ +#endif + case FFI_TYPE_COMPLEX: + /* Complex types are passed via reference. */ + p_struct -= ROUND_SIZE (ty->size); + memcpy (p_struct, arg, ty->size); + val = (uintptr_t)p_struct; + goto do_int; + + default: + FFI_ASSERT (0); + break; + } + } + + ffi_call_SYSV (frame, ret_type & FFI360_RET_MASK, rvalue, fn, closure); +} + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int(cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int(cif, fn, rvalue, avalue, closure); +} + +/*======================== End of Routine ============================*/ + +/*====================================================================*/ +/* */ +/* Name - ffi_closure_helper_SYSV. */ +/* */ +/* Function - Call a FFI closure target function. */ +/* */ +/*====================================================================*/ + +void FFI_HIDDEN +ffi_closure_helper_SYSV (ffi_cif *cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + unsigned long *p_gpr, + unsigned long long *p_fpr, + unsigned long *p_ov) +{ + unsigned long long ret_buffer; + + void *rvalue = &ret_buffer; + void **avalue; + void **p_arg; + + int n_gpr = 0; + int n_fpr = 0; + int n_ov = 0; + + ffi_type **ptr; + int i; + + /* Allocate buffer for argument list pointers. */ + p_arg = avalue = alloca (cif->nargs * sizeof (void *)); + + /* If we returning a structure, pass the structure address + directly to the target function. Otherwise, have the target + function store the return value to the GPR save area. */ + if (cif->flags & FFI390_RET_IN_MEM) + rvalue = (void *) p_gpr[n_gpr++]; + + /* Now for the arguments. */ + for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, p_arg++, ptr++) + { + int deref_struct_pointer = 0; + int type = (*ptr)->type; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + /* 16-byte long double is passed like a struct. */ + if (type == FFI_TYPE_LONGDOUBLE) + type = FFI_TYPE_STRUCT; +#endif + + /* Check how a structure type is passed. */ + if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX) + { + if (type == FFI_TYPE_COMPLEX) + type = FFI_TYPE_POINTER; + else + type = ffi_check_struct_type (*ptr); + + /* If we pass the struct via pointer, remember to + retrieve the pointer later. */ + if (type == FFI_TYPE_POINTER) + deref_struct_pointer = 1; + } + + /* Pointers are passed like UINTs of the same size. */ + if (type == FFI_TYPE_POINTER) + { +#ifdef __s390x__ + type = FFI_TYPE_UINT64; +#else + type = FFI_TYPE_UINT32; +#endif + } + + /* Now handle all primitive int/float data types. */ + switch (type) + { + case FFI_TYPE_DOUBLE: + if (n_fpr < MAX_FPRARGS) + *p_arg = &p_fpr[n_fpr++]; + else + *p_arg = &p_ov[n_ov], + n_ov += sizeof (double) / sizeof (long); + break; + + case FFI_TYPE_FLOAT: + if (n_fpr < MAX_FPRARGS) + *p_arg = &p_fpr[n_fpr++]; + else + *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4; + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: +#ifdef __s390x__ + if (n_gpr < MAX_GPRARGS) + *p_arg = &p_gpr[n_gpr++]; + else + *p_arg = &p_ov[n_ov++]; +#else + if (n_gpr == MAX_GPRARGS-1) + n_gpr = MAX_GPRARGS; + if (n_gpr < MAX_GPRARGS) + *p_arg = &p_gpr[n_gpr], n_gpr += 2; + else + *p_arg = &p_ov[n_ov], n_ov += 2; +#endif + break; + + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + if (n_gpr < MAX_GPRARGS) + *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 4; + else + *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4; + break; + + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + if (n_gpr < MAX_GPRARGS) + *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 2; + else + *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 2; + break; + + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + if (n_gpr < MAX_GPRARGS) + *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 1; + else + *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 1; + break; + + default: + FFI_ASSERT (0); + break; + } + + /* If this is a struct passed via pointer, we need to + actually retrieve that pointer. */ + if (deref_struct_pointer) + *p_arg = *(void **)*p_arg; + } + + + /* Call the target function. */ + (fun) (cif, rvalue, avalue, user_data); + + /* Convert the return value. */ + switch (cif->rtype->type) + { + /* Void is easy, and so is struct. */ + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: +#endif + break; + + /* Floating point values are returned in fpr 0. */ + case FFI_TYPE_FLOAT: + p_fpr[0] = (long long) *(unsigned int *) rvalue << 32; + break; + + case FFI_TYPE_DOUBLE: + p_fpr[0] = *(unsigned long long *) rvalue; + break; + + /* Integer values are returned in gpr 2 (and gpr 3 + for 64-bit values on 31-bit machines). */ + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: +#ifdef __s390x__ + p_gpr[0] = *(unsigned long *) rvalue; +#else + p_gpr[0] = ((unsigned long *) rvalue)[0], + p_gpr[1] = ((unsigned long *) rvalue)[1]; +#endif + break; + + case FFI_TYPE_POINTER: + case FFI_TYPE_UINT32: + case FFI_TYPE_UINT16: + case FFI_TYPE_UINT8: + p_gpr[0] = *(unsigned long *) rvalue; + break; + + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_SINT16: + case FFI_TYPE_SINT8: + p_gpr[0] = *(signed long *) rvalue; + break; + + default: + FFI_ASSERT (0); + break; + } +} + +/*======================== End of Routine ============================*/ + +/*====================================================================*/ +/* */ +/* Name - ffi_prep_closure_loc. */ +/* */ +/* Function - Prepare a FFI closure. */ +/* */ +/*====================================================================*/ + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif *cif, + void (*fun) (ffi_cif *, void *, void **, void *), + void *user_data, + void *codeloc) +{ + static unsigned short const template[] = { + 0x0d10, /* basr %r1,0 */ +#ifndef __s390x__ + 0x9801, 0x1006, /* lm %r0,%r1,6(%r1) */ +#else + 0xeb01, 0x100e, 0x0004, /* lmg %r0,%r1,14(%r1) */ +#endif + 0x07f1 /* br %r1 */ + }; + + unsigned long *tramp = (unsigned long *)&closure->tramp; + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + memcpy (tramp, template, sizeof(template)); + tramp[2] = (unsigned long)codeloc; + tramp[3] = (unsigned long)&ffi_closure_SYSV; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +/*======================== End of Routine ============================*/ + +/* Build a Go language closure. */ + +ffi_status +ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, + void (*fun)(ffi_cif*,void*,void**,void*)) +{ + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + closure->tramp = ffi_go_closure_SYSV; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/s390/ffitarget.h b/user/mpy/lib/libffi/src/s390/ffitarget.h new file mode 100644 index 0000000..d8a4ee4 --- /dev/null +++ b/user/mpy/lib/libffi/src/s390/ffitarget.h @@ -0,0 +1,70 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for S390. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#if defined (__s390x__) +#ifndef S390X +#define S390X +#endif +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION +#define FFI_TARGET_HAS_COMPLEX_TYPE + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 +#ifdef S390X +#define FFI_TRAMPOLINE_SIZE 32 +#else +#define FFI_TRAMPOLINE_SIZE 16 +#endif +#define FFI_NATIVE_RAW_API 0 + +#endif + diff --git a/user/mpy/lib/libffi/src/s390/internal.h b/user/mpy/lib/libffi/src/s390/internal.h new file mode 100644 index 0000000..b875578 --- /dev/null +++ b/user/mpy/lib/libffi/src/s390/internal.h @@ -0,0 +1,11 @@ +/* If these values change, sysv.S must be adapted! */ +#define FFI390_RET_DOUBLE 0 +#define FFI390_RET_FLOAT 1 +#define FFI390_RET_INT64 2 +#define FFI390_RET_INT32 3 +#define FFI390_RET_VOID 4 + +#define FFI360_RET_MASK 7 +#define FFI390_RET_IN_MEM 8 + +#define FFI390_RET_STRUCT (FFI390_RET_VOID | FFI390_RET_IN_MEM) diff --git a/user/mpy/lib/libffi/src/s390/sysv.S b/user/mpy/lib/libffi/src/s390/sysv.S new file mode 100644 index 0000000..c4b5006 --- /dev/null +++ b/user/mpy/lib/libffi/src/s390/sysv.S @@ -0,0 +1,325 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2000 Software AG + Copyright (c) 2008 Red Hat, Inc. + + S390 Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + + .text + +#ifndef __s390x__ + + # r2: frame + # r3: ret_type + # r4: ret_addr + # r5: fun + # r6: closure + + # This assumes we are using gas. + .balign 8 + .globl ffi_call_SYSV + FFI_HIDDEN(ffi_call_SYSV) + .type ffi_call_SYSV,%function +ffi_call_SYSV: + .cfi_startproc + st %r6,44(%r2) # Save registers + stm %r12,%r14,48(%r2) + lr %r13,%r2 # Install frame pointer + .cfi_rel_offset r6, 44 + .cfi_rel_offset r12, 48 + .cfi_rel_offset r13, 52 + .cfi_rel_offset r14, 56 + .cfi_def_cfa_register r13 + st %r2,0(%r15) # Set up back chain + sla %r3,3 # ret_type *= 8 + lr %r12,%r4 # Save ret_addr + lr %r1,%r5 # Save fun + lr %r0,%r6 # Install static chain + + # Set return address, so that there is only one indirect jump. +#ifdef HAVE_AS_S390_ZARCH + larl %r14,.Ltable + ar %r14,%r3 +#else + basr %r14,0 +0: la %r14,.Ltable-0b(%r14,%r3) +#endif + + lm %r2,%r6,8(%r13) # Load arguments + ld %f0,64(%r13) + ld %f2,72(%r13) + br %r1 # ... and call function + + .balign 8 +.Ltable: +# FFI390_RET_DOUBLE + std %f0,0(%r12) + j .Ldone + + .balign 8 +# FFI390_RET_FLOAT + ste %f0,0(%r12) + j .Ldone + + .balign 8 +# FFI390_RET_INT64 + st %r3,4(%r12) + nop + # fallthru + + .balign 8 +# FFI390_RET_INT32 + st %r2,0(%r12) + nop + # fallthru + + .balign 8 +# FFI390_RET_VOID +.Ldone: + l %r14,56(%r13) + l %r12,48(%r13) + l %r6,44(%r13) + l %r13,52(%r13) + .cfi_restore 14 + .cfi_restore 13 + .cfi_restore 12 + .cfi_restore 6 + .cfi_def_cfa r15, 96 + br %r14 + .cfi_endproc + .size ffi_call_SYSV,.-ffi_call_SYSV + + + .balign 8 + .globl ffi_go_closure_SYSV + FFI_HIDDEN(ffi_go_closure_SYSV) + .type ffi_go_closure_SYSV,%function +ffi_go_closure_SYSV: + .cfi_startproc + stm %r2,%r6,8(%r15) # Save arguments + lr %r4,%r0 # Load closure -> user_data + l %r2,4(%r4) # ->cif + l %r3,8(%r4) # ->fun + j .Ldoclosure + .cfi_endproc + + .balign 8 + .globl ffi_closure_SYSV + FFI_HIDDEN(ffi_closure_SYSV) + .type ffi_closure_SYSV,%function +ffi_closure_SYSV: + .cfi_startproc + stm %r2,%r6,8(%r15) # Save arguments + lr %r4,%r0 # Closure + l %r2,16(%r4) # ->cif + l %r3,20(%r4) # ->fun + l %r4,24(%r4) # ->user_data +.Ldoclosure: + stm %r12,%r15,48(%r15) # Save registers + lr %r12,%r15 + .cfi_def_cfa_register r12 + .cfi_rel_offset r6, 24 + .cfi_rel_offset r12, 48 + .cfi_rel_offset r13, 52 + .cfi_rel_offset r14, 56 + .cfi_rel_offset r15, 60 +#ifndef HAVE_AS_S390_ZARCH + basr %r13,0 # Set up base register +.Lcbase: + l %r1,.Lchelper-.Lcbase(%r13) # Get helper function +#endif + ahi %r15,-96-8 # Set up stack frame + st %r12,0(%r15) # Set up back chain + + std %f0,64(%r12) # Save fp arguments + std %f2,72(%r12) + + la %r5,96(%r12) # Overflow + st %r5,96(%r15) + la %r6,64(%r12) # FPRs + la %r5,8(%r12) # GPRs +#ifdef HAVE_AS_S390_ZARCH + brasl %r14,ffi_closure_helper_SYSV +#else + bas %r14,0(%r1,%r13) # Call helper +#endif + + lr %r15,%r12 + .cfi_def_cfa_register r15 + lm %r12,%r14,48(%r12) # Restore saved registers + l %r6,24(%r15) + ld %f0,64(%r15) # Load return registers + lm %r2,%r3,8(%r15) + br %r14 + .cfi_endproc + +#ifndef HAVE_AS_S390_ZARCH + .align 4 +.Lchelper: + .long ffi_closure_helper_SYSV-.Lcbase +#endif + + .size ffi_closure_SYSV,.-ffi_closure_SYSV + +#else + + # r2: frame + # r3: ret_type + # r4: ret_addr + # r5: fun + # r6: closure + + # This assumes we are using gas. + .balign 8 + .globl ffi_call_SYSV + FFI_HIDDEN(ffi_call_SYSV) + .type ffi_call_SYSV,%function +ffi_call_SYSV: + .cfi_startproc + stg %r6,88(%r2) # Save registers + stmg %r12,%r14,96(%r2) + lgr %r13,%r2 # Install frame pointer + .cfi_rel_offset r6, 88 + .cfi_rel_offset r12, 96 + .cfi_rel_offset r13, 104 + .cfi_rel_offset r14, 112 + .cfi_def_cfa_register r13 + stg %r2,0(%r15) # Set up back chain + larl %r14,.Ltable # Set up return address + slag %r3,%r3,3 # ret_type *= 8 + lgr %r12,%r4 # Save ret_addr + lgr %r1,%r5 # Save fun + lgr %r0,%r6 # Install static chain + agr %r14,%r3 + lmg %r2,%r6,16(%r13) # Load arguments + ld %f0,128(%r13) + ld %f2,136(%r13) + ld %f4,144(%r13) + ld %f6,152(%r13) + br %r1 # ... and call function + + .balign 8 +.Ltable: +# FFI390_RET_DOUBLE + std %f0,0(%r12) + j .Ldone + + .balign 8 +# FFI390_RET_DOUBLE + ste %f0,0(%r12) + j .Ldone + + .balign 8 +# FFI390_RET_INT64 + stg %r2,0(%r12) + + .balign 8 +# FFI390_RET_INT32 + # Never used, as we always store type ffi_arg. + # But the stg above is 6 bytes and we cannot + # jump around this case, so fall through. + nop + nop + + .balign 8 +# FFI390_RET_VOID +.Ldone: + lg %r14,112(%r13) + lg %r12,96(%r13) + lg %r6,88(%r13) + lg %r13,104(%r13) + .cfi_restore r14 + .cfi_restore r13 + .cfi_restore r12 + .cfi_restore r6 + .cfi_def_cfa r15, 160 + br %r14 + .cfi_endproc + .size ffi_call_SYSV,.-ffi_call_SYSV + + + .balign 8 + .globl ffi_go_closure_SYSV + FFI_HIDDEN(ffi_go_closure_SYSV) + .type ffi_go_closure_SYSV,%function +ffi_go_closure_SYSV: + .cfi_startproc + stmg %r2,%r6,16(%r15) # Save arguments + lgr %r4,%r0 # Load closure -> user_data + lg %r2,8(%r4) # ->cif + lg %r3,16(%r4) # ->fun + j .Ldoclosure + .cfi_endproc + .size ffi_go_closure_SYSV,.-ffi_go_closure_SYSV + + + .balign 8 + .globl ffi_closure_SYSV + FFI_HIDDEN(ffi_closure_SYSV) + .type ffi_closure_SYSV,%function +ffi_closure_SYSV: + .cfi_startproc + stmg %r2,%r6,16(%r15) # Save arguments + lgr %r4,%r0 # Load closure + lg %r2,32(%r4) # ->cif + lg %r3,40(%r4) # ->fun + lg %r4,48(%r4) # ->user_data +.Ldoclosure: + stmg %r13,%r15,104(%r15) # Save registers + lgr %r13,%r15 + .cfi_def_cfa_register r13 + .cfi_rel_offset r6, 48 + .cfi_rel_offset r13, 104 + .cfi_rel_offset r14, 112 + .cfi_rel_offset r15, 120 + aghi %r15,-160-16 # Set up stack frame + stg %r13,0(%r15) # Set up back chain + + std %f0,128(%r13) # Save fp arguments + std %f2,136(%r13) + std %f4,144(%r13) + std %f6,152(%r13) + la %r5,160(%r13) # Overflow + stg %r5,160(%r15) + la %r6,128(%r13) # FPRs + la %r5,16(%r13) # GPRs + brasl %r14,ffi_closure_helper_SYSV # Call helper + + lgr %r15,%r13 + .cfi_def_cfa_register r15 + lmg %r13,%r14,104(%r13) # Restore saved registers + lg %r6,48(%r15) + ld %f0,128(%r15) # Load return registers + lg %r2,16(%r15) + br %r14 + .cfi_endproc + .size ffi_closure_SYSV,.-ffi_closure_SYSV +#endif /* !s390x */ + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/sh/ffi.c b/user/mpy/lib/libffi/src/sh/ffi.c new file mode 100644 index 0000000..9ec86bf --- /dev/null +++ b/user/mpy/lib/libffi/src/sh/ffi.c @@ -0,0 +1,717 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2002-2008, 2012 Kaz Kojima + Copyright (c) 2008 Red Hat, Inc. + + SuperH Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +#define NGREGARG 4 +#if defined(__SH4__) +#define NFREGARG 8 +#endif + +#if defined(__HITACHI__) +#define STRUCT_VALUE_ADDRESS_WITH_ARG 1 +#else +#define STRUCT_VALUE_ADDRESS_WITH_ARG 0 +#endif + +/* If the structure has essentially an unique element, return its type. */ +static int +simple_type (ffi_type *arg) +{ + if (arg->type != FFI_TYPE_STRUCT) + return arg->type; + else if (arg->elements[1]) + return FFI_TYPE_STRUCT; + + return simple_type (arg->elements[0]); +} + +static int +return_type (ffi_type *arg) +{ + unsigned short type; + + if (arg->type != FFI_TYPE_STRUCT) + return arg->type; + + type = simple_type (arg->elements[0]); + if (! arg->elements[1]) + { + switch (type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + return FFI_TYPE_INT; + + default: + return type; + } + } + + /* gcc uses r0/r1 pair for some kind of structures. */ + if (arg->size <= 2 * sizeof (int)) + { + int i = 0; + ffi_type *e; + + while ((e = arg->elements[i++])) + { + type = simple_type (e); + switch (type) + { + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_INT: + case FFI_TYPE_FLOAT: + return FFI_TYPE_UINT64; + + default: + break; + } + } + } + + return FFI_TYPE_STRUCT; +} + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +void ffi_prep_args(char *stack, extended_cif *ecif) +{ + register unsigned int i; + register int tmp; + register unsigned int avn; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + int greg, ireg; +#if defined(__SH4__) + int freg = 0; +#endif + + tmp = 0; + argp = stack; + + if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT) + { + *(void **) argp = ecif->rvalue; + argp += 4; + ireg = STRUCT_VALUE_ADDRESS_WITH_ARG ? 1 : 0; + } + else + ireg = 0; + + /* Set arguments for registers. */ + greg = ireg; + avn = ecif->cif->nargs; + p_argv = ecif->avalue; + + for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++) + { + size_t z; + + z = (*p_arg)->size; + if (z < sizeof(int)) + { + if (greg++ >= NGREGARG) + continue; + + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + case FFI_TYPE_STRUCT: + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + break; + + default: + FFI_ASSERT(0); + } + argp += z; + } + else if (z == sizeof(int)) + { +#if defined(__SH4__) + if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (freg++ >= NFREGARG) + continue; + } + else +#endif + { + if (greg++ >= NGREGARG) + continue; + } + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + argp += z; + } +#if defined(__SH4__) + else if ((*p_arg)->type == FFI_TYPE_DOUBLE) + { + if (freg + 1 >= NFREGARG) + continue; + freg = (freg + 1) & ~1; + freg += 2; + memcpy (argp, *p_argv, z); + argp += z; + } +#endif + else + { + int n = (z + sizeof (int) - 1) / sizeof (int); +#if defined(__SH4__) + if (greg + n - 1 >= NGREGARG) + continue; +#else + if (greg >= NGREGARG) + continue; +#endif + greg += n; + memcpy (argp, *p_argv, z); + argp += n * sizeof (int); + } + } + + /* Set arguments on stack. */ + greg = ireg; +#if defined(__SH4__) + freg = 0; +#endif + p_argv = ecif->avalue; + + for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++) + { + size_t z; + + z = (*p_arg)->size; + if (z < sizeof(int)) + { + if (greg++ < NGREGARG) + continue; + + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + case FFI_TYPE_STRUCT: + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + break; + + default: + FFI_ASSERT(0); + } + argp += z; + } + else if (z == sizeof(int)) + { +#if defined(__SH4__) + if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (freg++ < NFREGARG) + continue; + } + else +#endif + { + if (greg++ < NGREGARG) + continue; + } + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + argp += z; + } +#if defined(__SH4__) + else if ((*p_arg)->type == FFI_TYPE_DOUBLE) + { + if (freg + 1 < NFREGARG) + { + freg = (freg + 1) & ~1; + freg += 2; + continue; + } + memcpy (argp, *p_argv, z); + argp += z; + } +#endif + else + { + int n = (z + sizeof (int) - 1) / sizeof (int); + if (greg + n - 1 < NGREGARG) + { + greg += n; + continue; + } +#if (! defined(__SH4__)) + else if (greg < NGREGARG) + { + greg = NGREGARG; + continue; + } +#endif + memcpy (argp, *p_argv, z); + argp += n * sizeof (int); + } + } + + return; +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + int i, j; + int size, type; + int n, m; + int greg; +#if defined(__SH4__) + int freg = 0; +#endif + + cif->flags = 0; + + greg = ((return_type (cif->rtype) == FFI_TYPE_STRUCT) && + STRUCT_VALUE_ADDRESS_WITH_ARG) ? 1 : 0; + +#if defined(__SH4__) + for (i = j = 0; i < cif->nargs && j < 12; i++) + { + type = (cif->arg_types)[i]->type; + switch (type) + { + case FFI_TYPE_FLOAT: + if (freg >= NFREGARG) + continue; + freg++; + cif->flags += ((cif->arg_types)[i]->type) << (2 * j); + j++; + break; + + case FFI_TYPE_DOUBLE: + if ((freg + 1) >= NFREGARG) + continue; + freg = (freg + 1) & ~1; + freg += 2; + cif->flags += ((cif->arg_types)[i]->type) << (2 * j); + j++; + break; + + default: + size = (cif->arg_types)[i]->size; + n = (size + sizeof (int) - 1) / sizeof (int); + if (greg + n - 1 >= NGREGARG) + continue; + greg += n; + for (m = 0; m < n; m++) + cif->flags += FFI_TYPE_INT << (2 * j++); + break; + } + } +#else + for (i = j = 0; i < cif->nargs && j < 4; i++) + { + size = (cif->arg_types)[i]->size; + n = (size + sizeof (int) - 1) / sizeof (int); + if (greg >= NGREGARG) + continue; + else if (greg + n - 1 >= NGREGARG) + n = NGREGARG - greg; + greg += n; + for (m = 0; m < n; m++) + cif->flags += FFI_TYPE_INT << (2 * j++); + } +#endif + + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_STRUCT: + cif->flags += (unsigned) (return_type (cif->rtype)) << 24; + break; + + case FFI_TYPE_VOID: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags += (unsigned) cif->rtype->type << 24; + break; + + default: + cif->flags += FFI_TYPE_INT << 24; + break; + } + + return FFI_OK; +} + +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, + unsigned, unsigned, unsigned *, void (*fn)(void)); + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + UINT64 trvalue; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if (cif->rtype->type == FFI_TYPE_STRUCT + && return_type (cif->rtype) != FFI_TYPE_STRUCT) + ecif.rvalue = &trvalue; + else if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca(cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, + fn); + break; + default: + FFI_ASSERT(0); + break; + } + + if (rvalue + && cif->rtype->type == FFI_TYPE_STRUCT + && return_type (cif->rtype) != FFI_TYPE_STRUCT) + memcpy (rvalue, &trvalue, cif->rtype->size); +} + +extern void ffi_closure_SYSV (void); +#if defined(__SH4__) +extern void __ic_invalidate (void *line); +#endif + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp; + unsigned int insn; + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + tramp = (unsigned int *) &closure->tramp[0]; + /* Set T bit if the function returns a struct pointed with R2. */ + insn = (return_type (cif->rtype) == FFI_TYPE_STRUCT + ? 0x0018 /* sett */ + : 0x0008 /* clrt */); + +#ifdef __LITTLE_ENDIAN__ + tramp[0] = 0xd301d102; + tramp[1] = 0x0000412b | (insn << 16); +#else + tramp[0] = 0xd102d301; + tramp[1] = 0x412b0000 | insn; +#endif + *(void **) &tramp[2] = (void *)codeloc; /* ctx */ + *(void **) &tramp[3] = (void *)ffi_closure_SYSV; /* funaddr */ + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + +#if defined(__SH4__) + /* Flush the icache. */ + __ic_invalidate(codeloc); +#endif + + return FFI_OK; +} + +/* Basically the trampoline invokes ffi_closure_SYSV, and on + * entry, r3 holds the address of the closure. + * After storing the registers that could possibly contain + * parameters to be passed into the stack frame and setting + * up space for a return value, ffi_closure_SYSV invokes the + * following helper function to do most of the work. + */ + +#ifdef __LITTLE_ENDIAN__ +#define OFS_INT8 0 +#define OFS_INT16 0 +#else +#define OFS_INT8 3 +#define OFS_INT16 2 +#endif + +int +ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue, + unsigned long *pgr, unsigned long *pfr, + unsigned long *pst) +{ + void **avalue; + ffi_type **p_arg; + int i, avn; + int ireg, greg = 0; +#if defined(__SH4__) + int freg = 0; +#endif + ffi_cif *cif; + + cif = closure->cif; + avalue = alloca(cif->nargs * sizeof(void *)); + + /* Copy the caller's structure return value address so that the closure + returns the data directly to the caller. */ + if (cif->rtype->type == FFI_TYPE_STRUCT && STRUCT_VALUE_ADDRESS_WITH_ARG) + { + rvalue = (void *) *pgr++; + ireg = 1; + } + else + ireg = 0; + + cif = closure->cif; + greg = ireg; + avn = cif->nargs; + + /* Grab the addresses of the arguments from the stack frame. */ + for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) + { + size_t z; + + z = (*p_arg)->size; + if (z < sizeof(int)) + { + if (greg++ >= NGREGARG) + continue; + + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + avalue[i] = (((char *)pgr) + OFS_INT8); + break; + + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + avalue[i] = (((char *)pgr) + OFS_INT16); + break; + + case FFI_TYPE_STRUCT: + avalue[i] = pgr; + break; + + default: + FFI_ASSERT(0); + } + pgr++; + } + else if (z == sizeof(int)) + { +#if defined(__SH4__) + if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (freg++ >= NFREGARG) + continue; + avalue[i] = pfr; + pfr++; + } + else +#endif + { + if (greg++ >= NGREGARG) + continue; + avalue[i] = pgr; + pgr++; + } + } +#if defined(__SH4__) + else if ((*p_arg)->type == FFI_TYPE_DOUBLE) + { + if (freg + 1 >= NFREGARG) + continue; + if (freg & 1) + pfr++; + freg = (freg + 1) & ~1; + freg += 2; + avalue[i] = pfr; + pfr += 2; + } +#endif + else + { + int n = (z + sizeof (int) - 1) / sizeof (int); +#if defined(__SH4__) + if (greg + n - 1 >= NGREGARG) + continue; +#else + if (greg >= NGREGARG) + continue; +#endif + greg += n; + avalue[i] = pgr; + pgr += n; + } + } + + greg = ireg; +#if defined(__SH4__) + freg = 0; +#endif + + for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) + { + size_t z; + + z = (*p_arg)->size; + if (z < sizeof(int)) + { + if (greg++ < NGREGARG) + continue; + + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + avalue[i] = (((char *)pst) + OFS_INT8); + break; + + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + avalue[i] = (((char *)pst) + OFS_INT16); + break; + + case FFI_TYPE_STRUCT: + avalue[i] = pst; + break; + + default: + FFI_ASSERT(0); + } + pst++; + } + else if (z == sizeof(int)) + { +#if defined(__SH4__) + if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (freg++ < NFREGARG) + continue; + } + else +#endif + { + if (greg++ < NGREGARG) + continue; + } + avalue[i] = pst; + pst++; + } +#if defined(__SH4__) + else if ((*p_arg)->type == FFI_TYPE_DOUBLE) + { + if (freg + 1 < NFREGARG) + { + freg = (freg + 1) & ~1; + freg += 2; + continue; + } + avalue[i] = pst; + pst += 2; + } +#endif + else + { + int n = (z + sizeof (int) - 1) / sizeof (int); + if (greg + n - 1 < NGREGARG) + { + greg += n; + continue; + } +#if (! defined(__SH4__)) + else if (greg < NGREGARG) + { + greg += n; + pst += greg - NGREGARG; + continue; + } +#endif + avalue[i] = pst; + pst += n; + } + } + + (closure->fun) (cif, rvalue, avalue, closure->user_data); + + /* Tell ffi_closure_SYSV how to perform return type promotions. */ + return return_type (cif->rtype); +} diff --git a/user/mpy/lib/libffi/src/sh/ffitarget.h b/user/mpy/lib/libffi/src/sh/ffitarget.h new file mode 100644 index 0000000..a36bf42 --- /dev/null +++ b/user/mpy/lib/libffi/src/sh/ffitarget.h @@ -0,0 +1,54 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for SuperH. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- Generic type definitions ----------------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 16 +#define FFI_NATIVE_RAW_API 0 + +#endif + diff --git a/user/mpy/lib/libffi/src/sh/sysv.S b/user/mpy/lib/libffi/src/sh/sysv.S new file mode 100644 index 0000000..5be7516 --- /dev/null +++ b/user/mpy/lib/libffi/src/sh/sysv.S @@ -0,0 +1,850 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2002, 2003, 2004, 2006, 2008 Kaz Kojima + + SuperH Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#ifdef HAVE_MACHINE_ASM_H +#include +#else +/* XXX these lose for some platforms, I'm sure. */ +#define CNAME(x) x +#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): +#endif + +#if defined(__HITACHI__) +#define STRUCT_VALUE_ADDRESS_WITH_ARG 1 +#else +#define STRUCT_VALUE_ADDRESS_WITH_ARG 0 +#endif + +.text + + # r4: ffi_prep_args + # r5: &ecif + # r6: bytes + # r7: flags + # sp+0: rvalue + # sp+4: fn + + # This assumes we are using gas. +ENTRY(ffi_call_SYSV) + # Save registers +.LFB1: + mov.l r8,@-r15 +.LCFI0: + mov.l r9,@-r15 +.LCFI1: + mov.l r10,@-r15 +.LCFI2: + mov.l r12,@-r15 +.LCFI3: + mov.l r14,@-r15 +.LCFI4: + sts.l pr,@-r15 +.LCFI5: + mov r15,r14 +.LCFI6: +#if defined(__SH4__) + mov r6,r8 + mov r7,r9 + + sub r6,r15 + add #-16,r15 + mov #~7,r0 + and r0,r15 + + mov r4,r0 + jsr @r0 + mov r15,r4 + + mov r9,r1 + shlr8 r9 + shlr8 r9 + shlr8 r9 + + mov #FFI_TYPE_STRUCT,r2 + cmp/eq r2,r9 + bf 1f +#if STRUCT_VALUE_ADDRESS_WITH_ARG + mov.l @r15+,r4 + bra 2f + mov #5,r2 +#else + mov.l @r15+,r10 +#endif +1: + mov #4,r2 +2: + mov #4,r3 + +L_pass: + cmp/pl r8 + bf L_call_it + + mov r1,r0 + and #3,r0 + +L_pass_d: + cmp/eq #FFI_TYPE_DOUBLE,r0 + bf L_pass_f + + mov r3,r0 + and #1,r0 + tst r0,r0 + bt 1f + add #1,r3 +1: + mov #12,r0 + cmp/hs r0,r3 + bt/s 3f + shlr2 r1 + bsr L_pop_d + nop +3: + add #2,r3 + bra L_pass + add #-8,r8 + +L_pop_d: + mov r3,r0 + add r0,r0 + add r3,r0 + add #-12,r0 + braf r0 + nop +#ifdef __LITTLE_ENDIAN__ + fmov.s @r15+,fr5 + rts + fmov.s @r15+,fr4 + fmov.s @r15+,fr7 + rts + fmov.s @r15+,fr6 + fmov.s @r15+,fr9 + rts + fmov.s @r15+,fr8 + fmov.s @r15+,fr11 + rts + fmov.s @r15+,fr10 +#else + fmov.s @r15+,fr4 + rts + fmov.s @r15+,fr5 + fmov.s @r15+,fr6 + rts + fmov.s @r15+,fr7 + fmov.s @r15+,fr8 + rts + fmov.s @r15+,fr9 + fmov.s @r15+,fr10 + rts + fmov.s @r15+,fr11 +#endif + +L_pass_f: + cmp/eq #FFI_TYPE_FLOAT,r0 + bf L_pass_i + + mov #12,r0 + cmp/hs r0,r3 + bt/s 2f + shlr2 r1 + bsr L_pop_f + nop +2: + add #1,r3 + bra L_pass + add #-4,r8 + +L_pop_f: + mov r3,r0 + shll2 r0 + add #-16,r0 + braf r0 + nop +#ifdef __LITTLE_ENDIAN__ + rts + fmov.s @r15+,fr5 + rts + fmov.s @r15+,fr4 + rts + fmov.s @r15+,fr7 + rts + fmov.s @r15+,fr6 + rts + fmov.s @r15+,fr9 + rts + fmov.s @r15+,fr8 + rts + fmov.s @r15+,fr11 + rts + fmov.s @r15+,fr10 +#else + rts + fmov.s @r15+,fr4 + rts + fmov.s @r15+,fr5 + rts + fmov.s @r15+,fr6 + rts + fmov.s @r15+,fr7 + rts + fmov.s @r15+,fr8 + rts + fmov.s @r15+,fr9 + rts + fmov.s @r15+,fr10 + rts + fmov.s @r15+,fr11 +#endif + +L_pass_i: + cmp/eq #FFI_TYPE_INT,r0 + bf L_call_it + + mov #8,r0 + cmp/hs r0,r2 + bt/s 2f + shlr2 r1 + bsr L_pop_i + nop +2: + add #1,r2 + bra L_pass + add #-4,r8 + +L_pop_i: + mov r2,r0 + shll2 r0 + add #-16,r0 + braf r0 + nop + rts + mov.l @r15+,r4 + rts + mov.l @r15+,r5 + rts + mov.l @r15+,r6 + rts + mov.l @r15+,r7 + +L_call_it: + # call function +#if (! STRUCT_VALUE_ADDRESS_WITH_ARG) + mov r10, r2 +#endif + mov.l @(28,r14),r1 + jsr @r1 + nop + +L_ret_d: + mov #FFI_TYPE_DOUBLE,r2 + cmp/eq r2,r9 + bf L_ret_ll + + mov.l @(24,r14),r1 +#ifdef __LITTLE_ENDIAN__ + fmov.s fr1,@r1 + add #4,r1 + bra L_epilogue + fmov.s fr0,@r1 +#else + fmov.s fr0,@r1 + add #4,r1 + bra L_epilogue + fmov.s fr1,@r1 +#endif + +L_ret_ll: + mov #FFI_TYPE_SINT64,r2 + cmp/eq r2,r9 + bt/s 1f + mov #FFI_TYPE_UINT64,r2 + cmp/eq r2,r9 + bf L_ret_f + +1: + mov.l @(24,r14),r2 + mov.l r0,@r2 + bra L_epilogue + mov.l r1,@(4,r2) + +L_ret_f: + mov #FFI_TYPE_FLOAT,r2 + cmp/eq r2,r9 + bf L_ret_i + + mov.l @(24,r14),r1 + bra L_epilogue + fmov.s fr0,@r1 + +L_ret_i: + mov #FFI_TYPE_INT,r2 + cmp/eq r2,r9 + bf L_epilogue + + mov.l @(24,r14),r1 + bra L_epilogue + mov.l r0,@r1 + +L_epilogue: + # Remove the space we pushed for the args + mov r14,r15 + + lds.l @r15+,pr + mov.l @r15+,r14 + mov.l @r15+,r12 + mov.l @r15+,r10 + mov.l @r15+,r9 + rts + mov.l @r15+,r8 +#else + mov r6,r8 + mov r7,r9 + + sub r6,r15 + add #-16,r15 + mov #~7,r0 + and r0,r15 + + mov r4,r0 + jsr @r0 + mov r15,r4 + + mov r9,r3 + shlr8 r9 + shlr8 r9 + shlr8 r9 + + mov #FFI_TYPE_STRUCT,r2 + cmp/eq r2,r9 + bf 1f +#if STRUCT_VALUE_ADDRESS_WITH_ARG + mov.l @r15+,r4 + bra 2f + mov #5,r2 +#else + mov.l @r15+,r10 +#endif +1: + mov #4,r2 +2: + +L_pass: + cmp/pl r8 + bf L_call_it + + mov r3,r0 + and #3,r0 + +L_pass_d: + cmp/eq #FFI_TYPE_DOUBLE,r0 + bf L_pass_i + + mov r15,r0 + and #7,r0 + tst r0,r0 + bt 1f + add #4,r15 +1: + mov #8,r0 + cmp/hs r0,r2 + bt/s 2f + shlr2 r3 + bsr L_pop_d + nop +2: + add #2,r2 + bra L_pass + add #-8,r8 + +L_pop_d: + mov r2,r0 + add r0,r0 + add r2,r0 + add #-12,r0 + add r0,r0 + braf r0 + nop + mov.l @r15+,r4 + rts + mov.l @r15+,r5 + mov.l @r15+,r5 + rts + mov.l @r15+,r6 + mov.l @r15+,r6 + rts + mov.l @r15+,r7 + rts + mov.l @r15+,r7 + +L_pass_i: + cmp/eq #FFI_TYPE_INT,r0 + bf L_call_it + + mov #8,r0 + cmp/hs r0,r2 + bt/s 2f + shlr2 r3 + bsr L_pop_i + nop +2: + add #1,r2 + bra L_pass + add #-4,r8 + +L_pop_i: + mov r2,r0 + shll2 r0 + add #-16,r0 + braf r0 + nop + rts + mov.l @r15+,r4 + rts + mov.l @r15+,r5 + rts + mov.l @r15+,r6 + rts + mov.l @r15+,r7 + +L_call_it: + # call function +#if (! STRUCT_VALUE_ADDRESS_WITH_ARG) + mov r10, r2 +#endif + mov.l @(28,r14),r1 + jsr @r1 + nop + +L_ret_d: + mov #FFI_TYPE_DOUBLE,r2 + cmp/eq r2,r9 + bf L_ret_ll + + mov.l @(24,r14),r2 + mov.l r0,@r2 + bra L_epilogue + mov.l r1,@(4,r2) + +L_ret_ll: + mov #FFI_TYPE_SINT64,r2 + cmp/eq r2,r9 + bt/s 1f + mov #FFI_TYPE_UINT64,r2 + cmp/eq r2,r9 + bf L_ret_i + +1: + mov.l @(24,r14),r2 + mov.l r0,@r2 + bra L_epilogue + mov.l r1,@(4,r2) + +L_ret_i: + mov #FFI_TYPE_FLOAT,r2 + cmp/eq r2,r9 + bt 1f + mov #FFI_TYPE_INT,r2 + cmp/eq r2,r9 + bf L_epilogue +1: + mov.l @(24,r14),r1 + bra L_epilogue + mov.l r0,@r1 + +L_epilogue: + # Remove the space we pushed for the args + mov r14,r15 + + lds.l @r15+,pr + mov.l @r15+,r14 + mov.l @r15+,r12 + mov.l @r15+,r10 + mov.l @r15+,r9 + rts + mov.l @r15+,r8 +#endif +.LFE1: +.ffi_call_SYSV_end: + .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) + +.globl ffi_closure_helper_SYSV + +ENTRY(ffi_closure_SYSV) +.LFB2: + mov.l r7,@-r15 +.LCFI7: + mov.l r6,@-r15 +.LCFI8: + mov.l r5,@-r15 +.LCFI9: + mov.l r4,@-r15 +.LCFIA: + mov.l r14,@-r15 +.LCFIB: + sts.l pr,@-r15 + + /* Stack layout: + xx bytes (on stack parameters) + 16 bytes (register parameters) + 4 bytes (saved frame pointer) + 4 bytes (saved return address) + 32 bytes (floating register parameters, SH-4 only) + 8 bytes (result) + 4 bytes (pad) + 4 bytes (5th arg) + <- new stack pointer + */ +.LCFIC: +#if defined(__SH4__) + add #-48,r15 +#else + add #-16,r15 +#endif +.LCFID: + mov r15,r14 +.LCFIE: + +#if defined(__SH4__) + mov r14,r1 + add #48,r1 +#ifdef __LITTLE_ENDIAN__ + fmov.s fr10,@-r1 + fmov.s fr11,@-r1 + fmov.s fr8,@-r1 + fmov.s fr9,@-r1 + fmov.s fr6,@-r1 + fmov.s fr7,@-r1 + fmov.s fr4,@-r1 + fmov.s fr5,@-r1 +#else + fmov.s fr11,@-r1 + fmov.s fr10,@-r1 + fmov.s fr9,@-r1 + fmov.s fr8,@-r1 + fmov.s fr7,@-r1 + fmov.s fr6,@-r1 + fmov.s fr5,@-r1 + fmov.s fr4,@-r1 +#endif + mov r1,r7 + mov r14,r6 + add #56,r6 +#else + mov r14,r6 + add #24,r6 +#endif + + bt/s 10f + mov r2, r5 + mov r14,r1 + add #8,r1 + mov r1,r5 +10: + + mov r14,r1 +#if defined(__SH4__) + add #72,r1 +#else + add #40,r1 +#endif + mov.l r1,@r14 + +#ifdef PIC + mov.l L_got,r1 + mova L_got,r0 + add r0,r1 + mov.l L_helper,r0 + add r1,r0 +#else + mov.l L_helper,r0 +#endif + jsr @r0 + mov r3,r4 + + shll r0 + mov r0,r1 + mova L_table,r0 + add r1,r0 + mov.w @r0,r0 + mov r14,r2 + braf r0 + add #8,r2 +0: + .align 2 +#ifdef PIC +L_got: + .long _GLOBAL_OFFSET_TABLE_ +L_helper: + .long ffi_closure_helper_SYSV@GOTOFF +#else +L_helper: + .long ffi_closure_helper_SYSV +#endif +L_table: + .short L_case_v - 0b /* FFI_TYPE_VOID */ + .short L_case_i - 0b /* FFI_TYPE_INT */ +#if defined(__SH4__) + .short L_case_f - 0b /* FFI_TYPE_FLOAT */ + .short L_case_d - 0b /* FFI_TYPE_DOUBLE */ + .short L_case_d - 0b /* FFI_TYPE_LONGDOUBLE */ +#else + .short L_case_i - 0b /* FFI_TYPE_FLOAT */ + .short L_case_ll - 0b /* FFI_TYPE_DOUBLE */ + .short L_case_ll - 0b /* FFI_TYPE_LONGDOUBLE */ +#endif + .short L_case_uq - 0b /* FFI_TYPE_UINT8 */ + .short L_case_q - 0b /* FFI_TYPE_SINT8 */ + .short L_case_uh - 0b /* FFI_TYPE_UINT16 */ + .short L_case_h - 0b /* FFI_TYPE_SINT16 */ + .short L_case_i - 0b /* FFI_TYPE_UINT32 */ + .short L_case_i - 0b /* FFI_TYPE_SINT32 */ + .short L_case_ll - 0b /* FFI_TYPE_UINT64 */ + .short L_case_ll - 0b /* FFI_TYPE_SINT64 */ + .short L_case_v - 0b /* FFI_TYPE_STRUCT */ + .short L_case_i - 0b /* FFI_TYPE_POINTER */ + +#if defined(__SH4__) +L_case_d: +#ifdef __LITTLE_ENDIAN__ + fmov.s @r2+,fr1 + bra L_case_v + fmov.s @r2,fr0 +#else + fmov.s @r2+,fr0 + bra L_case_v + fmov.s @r2,fr1 +#endif + +L_case_f: + bra L_case_v + fmov.s @r2,fr0 +#endif + +L_case_ll: + mov.l @r2+,r0 + bra L_case_v + mov.l @r2,r1 + +L_case_i: + bra L_case_v + mov.l @r2,r0 + +L_case_q: +#ifdef __LITTLE_ENDIAN__ +#else + add #3,r2 +#endif + bra L_case_v + mov.b @r2,r0 + +L_case_uq: +#ifdef __LITTLE_ENDIAN__ +#else + add #3,r2 +#endif + mov.b @r2,r0 + bra L_case_v + extu.b r0,r0 + +L_case_h: +#ifdef __LITTLE_ENDIAN__ +#else + add #2,r2 +#endif + bra L_case_v + mov.w @r2,r0 + +L_case_uh: +#ifdef __LITTLE_ENDIAN__ +#else + add #2,r2 +#endif + mov.w @r2,r0 + extu.w r0,r0 + /* fall through */ + +L_case_v: +#if defined(__SH4__) + add #48,r15 +#else + add #16,r15 +#endif + lds.l @r15+,pr + mov.l @r15+,r14 + rts + add #16,r15 +.LFE2: +.ffi_closure_SYSV_end: + .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif + + .section ".eh_frame","aw",@progbits +__FRAME_BEGIN__: + .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */ +.LSCIE1: + .4byte 0x0 /* CIE Identifier Tag */ + .byte 0x1 /* CIE Version */ +#ifdef PIC + .ascii "zR\0" /* CIE Augmentation */ +#else + .byte 0x0 /* CIE Augmentation */ +#endif + .byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */ + .byte 0x7c /* sleb128 -4; CIE Data Alignment Factor */ + .byte 0x11 /* CIE RA Column */ +#ifdef PIC + .uleb128 0x1 /* Augmentation size */ + .byte 0x10 /* FDE Encoding (pcrel) */ +#endif + .byte 0xc /* DW_CFA_def_cfa */ + .byte 0xf /* uleb128 0xf */ + .byte 0x0 /* uleb128 0x0 */ + .align 2 +.LECIE1: +.LSFDE1: + .4byte .LEFDE1-.LASFDE1 /* FDE Length */ +.LASFDE1: + .4byte .LASFDE1-__FRAME_BEGIN__ /* FDE CIE offset */ +#ifdef PIC + .4byte .LFB1-. /* FDE initial location */ +#else + .4byte .LFB1 /* FDE initial location */ +#endif + .4byte .LFE1-.LFB1 /* FDE address range */ +#ifdef PIC + .uleb128 0x0 /* Augmentation size */ +#endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI0-.LFB1 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x4 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI1-.LCFI0 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x8 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI2-.LCFI1 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0xc /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI3-.LCFI2 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x10 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI4-.LCFI3 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x14 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI5-.LCFI4 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x18 /* uleb128 0x4 */ + .byte 0x91 /* DW_CFA_offset, column 0x11 */ + .byte 0x6 /* uleb128 0x6 */ + .byte 0x8e /* DW_CFA_offset, column 0xe */ + .byte 0x5 /* uleb128 0x5 */ + .byte 0x8c /* DW_CFA_offset, column 0xc */ + .byte 0x4 /* uleb128 0x4 */ + .byte 0x8a /* DW_CFA_offset, column 0xa */ + .byte 0x3 /* uleb128 0x3 */ + .byte 0x89 /* DW_CFA_offset, column 0x9 */ + .byte 0x2 /* uleb128 0x2 */ + .byte 0x88 /* DW_CFA_offset, column 0x8 */ + .byte 0x1 /* uleb128 0x1 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI6-.LCFI5 + .byte 0xd /* DW_CFA_def_cfa_register */ + .byte 0xe /* uleb128 0xe */ + .align 2 +.LEFDE1: + +.LSFDE3: + .4byte .LEFDE3-.LASFDE3 /* FDE Length */ +.LASFDE3: + .4byte .LASFDE3-__FRAME_BEGIN__ /* FDE CIE offset */ +#ifdef PIC + .4byte .LFB2-. /* FDE initial location */ +#else + .4byte .LFB2 /* FDE initial location */ +#endif + .4byte .LFE2-.LFB2 /* FDE address range */ +#ifdef PIC + .uleb128 0x0 /* Augmentation size */ +#endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI7-.LFB2 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x4 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI8-.LCFI7 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x8 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFI9-.LCFI8 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0xc /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFIA-.LCFI9 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x10 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFIB-.LCFIA + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x14 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFIC-.LCFIB + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x18 /* uleb128 0x4 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFID-.LCFIC + .byte 0xe /* DW_CFA_def_cfa_offset */ +#if defined(__SH4__) + .byte 24+48 /* uleb128 24+48 */ +#else + .byte 24+16 /* uleb128 24+16 */ +#endif + .byte 0x91 /* DW_CFA_offset, column 0x11 */ + .byte 0x6 /* uleb128 0x6 */ + .byte 0x8e /* DW_CFA_offset, column 0xe */ + .byte 0x5 /* uleb128 0x5 */ + .byte 0x84 /* DW_CFA_offset, column 0x4 */ + .byte 0x4 /* uleb128 0x4 */ + .byte 0x85 /* DW_CFA_offset, column 0x5 */ + .byte 0x3 /* uleb128 0x3 */ + .byte 0x86 /* DW_CFA_offset, column 0x6 */ + .byte 0x2 /* uleb128 0x2 */ + .byte 0x87 /* DW_CFA_offset, column 0x7 */ + .byte 0x1 /* uleb128 0x1 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte .LCFIE-.LCFID + .byte 0xd /* DW_CFA_def_cfa_register */ + .byte 0xe /* uleb128 0xe */ + .align 2 +.LEFDE3: diff --git a/user/mpy/lib/libffi/src/sh64/ffi.c b/user/mpy/lib/libffi/src/sh64/ffi.c new file mode 100644 index 0000000..123b87a --- /dev/null +++ b/user/mpy/lib/libffi/src/sh64/ffi.c @@ -0,0 +1,469 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2003, 2004, 2006, 2007, 2012 Kaz Kojima + Copyright (c) 2008 Anthony Green + + SuperH SHmedia Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +#define NGREGARG 8 +#define NFREGARG 12 + +static int +return_type (ffi_type *arg) +{ + + if (arg->type != FFI_TYPE_STRUCT) + return arg->type; + + /* gcc uses r2 if the result can be packed in on register. */ + if (arg->size <= sizeof (UINT8)) + return FFI_TYPE_UINT8; + else if (arg->size <= sizeof (UINT16)) + return FFI_TYPE_UINT16; + else if (arg->size <= sizeof (UINT32)) + return FFI_TYPE_UINT32; + else if (arg->size <= sizeof (UINT64)) + return FFI_TYPE_UINT64; + + return FFI_TYPE_STRUCT; +} + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +void ffi_prep_args(char *stack, extended_cif *ecif) +{ + register unsigned int i; + register unsigned int avn; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT) + { + *(void **) argp = ecif->rvalue; + argp += sizeof (UINT64); + } + + avn = ecif->cif->nargs; + p_argv = ecif->avalue; + + for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++) + { + size_t z; + int align; + + z = (*p_arg)->size; + align = (*p_arg)->alignment; + if (z < sizeof (UINT32)) + { + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(SINT64 *) argp = (SINT64) *(SINT8 *)(*p_argv); + break; + + case FFI_TYPE_UINT8: + *(UINT64 *) argp = (UINT64) *(UINT8 *)(*p_argv); + break; + + case FFI_TYPE_SINT16: + *(SINT64 *) argp = (SINT64) *(SINT16 *)(*p_argv); + break; + + case FFI_TYPE_UINT16: + *(UINT64 *) argp = (UINT64) *(UINT16 *)(*p_argv); + break; + + case FFI_TYPE_STRUCT: + memcpy (argp, *p_argv, z); + break; + + default: + FFI_ASSERT(0); + } + argp += sizeof (UINT64); + } + else if (z == sizeof (UINT32) && align == sizeof (UINT32)) + { + switch ((*p_arg)->type) + { + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + *(SINT64 *) argp = (SINT64) *(SINT32 *) (*p_argv); + break; + + case FFI_TYPE_FLOAT: + case FFI_TYPE_POINTER: + case FFI_TYPE_UINT32: + case FFI_TYPE_STRUCT: + *(UINT64 *) argp = (UINT64) *(UINT32 *) (*p_argv); + break; + + default: + FFI_ASSERT(0); + break; + } + argp += sizeof (UINT64); + } + else if (z == sizeof (UINT64) + && align == sizeof (UINT64) + && ((int) *p_argv & (sizeof (UINT64) - 1)) == 0) + { + *(UINT64 *) argp = *(UINT64 *) (*p_argv); + argp += sizeof (UINT64); + } + else + { + int n = (z + sizeof (UINT64) - 1) / sizeof (UINT64); + + memcpy (argp, *p_argv, z); + argp += n * sizeof (UINT64); + } + } + + return; +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + int i, j; + int size, type; + int n, m; + int greg; + int freg; + int fpair = -1; + + greg = (return_type (cif->rtype) == FFI_TYPE_STRUCT ? 1 : 0); + freg = 0; + cif->flags2 = 0; + + for (i = j = 0; i < cif->nargs; i++) + { + type = (cif->arg_types)[i]->type; + switch (type) + { + case FFI_TYPE_FLOAT: + greg++; + cif->bytes += sizeof (UINT64) - sizeof (float); + if (freg >= NFREGARG - 1) + continue; + if (fpair < 0) + { + fpair = freg; + freg += 2; + } + else + fpair = -1; + cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++); + break; + + case FFI_TYPE_DOUBLE: + if (greg++ >= NGREGARG && (freg + 1) >= NFREGARG) + continue; + if ((freg + 1) < NFREGARG) + { + freg += 2; + cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++); + } + else + cif->flags2 += FFI_TYPE_INT << (2 * j++); + break; + + default: + size = (cif->arg_types)[i]->size; + if (size < sizeof (UINT64)) + cif->bytes += sizeof (UINT64) - size; + n = (size + sizeof (UINT64) - 1) / sizeof (UINT64); + if (greg >= NGREGARG) + continue; + else if (greg + n - 1 >= NGREGARG) + greg = NGREGARG; + else + greg += n; + for (m = 0; m < n; m++) + cif->flags2 += FFI_TYPE_INT << (2 * j++); + break; + } + } + + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_STRUCT: + cif->flags = return_type (cif->rtype); + break; + + case FFI_TYPE_VOID: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = cif->rtype->type; + break; + + default: + cif->flags = FFI_TYPE_INT; + break; + } + + return FFI_OK; +} + +/*@-declundef@*/ +/*@-exportheader@*/ +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, long long, + /*@out@*/ unsigned *, + void (*fn)(void)); +/*@=declundef@*/ +/*@=exportheader@*/ + +void ffi_call(/*@dependent@*/ ffi_cif *cif, + void (*fn)(void), + /*@out@*/ void *rvalue, + /*@dependent@*/ void **avalue) +{ + extended_cif ecif; + UINT64 trvalue; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if (cif->rtype->type == FFI_TYPE_STRUCT + && return_type (cif->rtype) != FFI_TYPE_STRUCT) + ecif.rvalue = &trvalue; + else if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca(cif->rtype->size); + } + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, cif->flags2, + ecif.rvalue, fn); + break; + default: + FFI_ASSERT(0); + break; + } + + if (rvalue + && cif->rtype->type == FFI_TYPE_STRUCT + && return_type (cif->rtype) != FFI_TYPE_STRUCT) + memcpy (rvalue, &trvalue, cif->rtype->size); +} + +extern void ffi_closure_SYSV (void); +extern void __ic_invalidate (void *line); + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp; + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + tramp = (unsigned int *) &closure->tramp[0]; + /* Since ffi_closure is an aligned object, the ffi trampoline is + called as an SHcompact code. Sigh. + SHcompact part: + mova @(1,pc),r0; add #1,r0; jmp @r0; nop; + SHmedia part: + movi fnaddr >> 16,r1; shori fnaddr,r1; ptabs/l r1,tr0 + movi cxt >> 16,r1; shori cxt,r1; blink tr0,r63 */ +#ifdef __LITTLE_ENDIAN__ + tramp[0] = 0x7001c701; + tramp[1] = 0x0009402b; +#else + tramp[0] = 0xc7017001; + tramp[1] = 0x402b0009; +#endif + tramp[2] = 0xcc000010 | (((UINT32) ffi_closure_SYSV) >> 16) << 10; + tramp[3] = 0xc8000010 | (((UINT32) ffi_closure_SYSV) & 0xffff) << 10; + tramp[4] = 0x6bf10600; + tramp[5] = 0xcc000010 | (((UINT32) codeloc) >> 16) << 10; + tramp[6] = 0xc8000010 | (((UINT32) codeloc) & 0xffff) << 10; + tramp[7] = 0x4401fff0; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + /* Flush the icache. */ + asm volatile ("ocbwb %0,0; synco; icbi %1,0; synci" : : "r" (tramp), + "r"(codeloc)); + + return FFI_OK; +} + +/* Basically the trampoline invokes ffi_closure_SYSV, and on + * entry, r3 holds the address of the closure. + * After storing the registers that could possibly contain + * parameters to be passed into the stack frame and setting + * up space for a return value, ffi_closure_SYSV invokes the + * following helper function to do most of the work. + */ + +int +ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue, + UINT64 *pgr, UINT64 *pfr, UINT64 *pst) +{ + void **avalue; + ffi_type **p_arg; + int i, avn; + int greg, freg; + ffi_cif *cif; + int fpair = -1; + + cif = closure->cif; + avalue = alloca (cif->nargs * sizeof (void *)); + + /* Copy the caller's structure return value address so that the closure + returns the data directly to the caller. */ + if (return_type (cif->rtype) == FFI_TYPE_STRUCT) + { + rvalue = (UINT64 *) *pgr; + greg = 1; + } + else + greg = 0; + + freg = 0; + cif = closure->cif; + avn = cif->nargs; + + /* Grab the addresses of the arguments from the stack frame. */ + for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) + { + size_t z; + void *p; + + z = (*p_arg)->size; + if (z < sizeof (UINT32)) + { + p = pgr + greg++; + + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_STRUCT: +#ifdef __LITTLE_ENDIAN__ + avalue[i] = p; +#else + avalue[i] = ((char *) p) + sizeof (UINT32) - z; +#endif + break; + + default: + FFI_ASSERT(0); + } + } + else if (z == sizeof (UINT32)) + { + if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (freg < NFREGARG - 1) + { + if (fpair >= 0) + { + avalue[i] = (UINT32 *) pfr + fpair; + fpair = -1; + } + else + { +#ifdef __LITTLE_ENDIAN__ + fpair = freg; + avalue[i] = (UINT32 *) pfr + (1 ^ freg); +#else + fpair = 1 ^ freg; + avalue[i] = (UINT32 *) pfr + freg; +#endif + freg += 2; + } + } + else +#ifdef __LITTLE_ENDIAN__ + avalue[i] = pgr + greg; +#else + avalue[i] = (UINT32 *) (pgr + greg) + 1; +#endif + } + else +#ifdef __LITTLE_ENDIAN__ + avalue[i] = pgr + greg; +#else + avalue[i] = (UINT32 *) (pgr + greg) + 1; +#endif + greg++; + } + else if ((*p_arg)->type == FFI_TYPE_DOUBLE) + { + if (freg + 1 >= NFREGARG) + avalue[i] = pgr + greg; + else + { + avalue[i] = pfr + (freg >> 1); + freg += 2; + } + greg++; + } + else + { + int n = (z + sizeof (UINT64) - 1) / sizeof (UINT64); + + avalue[i] = pgr + greg; + greg += n; + } + } + + (closure->fun) (cif, rvalue, avalue, closure->user_data); + + /* Tell ffi_closure_SYSV how to perform return type promotions. */ + return return_type (cif->rtype); +} + diff --git a/user/mpy/lib/libffi/src/sh64/ffitarget.h b/user/mpy/lib/libffi/src/sh64/ffitarget.h new file mode 100644 index 0000000..08a6fe9 --- /dev/null +++ b/user/mpy/lib/libffi/src/sh64/ffitarget.h @@ -0,0 +1,58 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for SuperH - SHmedia. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- Generic type definitions ----------------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; + +#define FFI_EXTRA_CIF_FIELDS long long flags2 +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 32 +#define FFI_NATIVE_RAW_API 0 + +#endif + diff --git a/user/mpy/lib/libffi/src/sh64/sysv.S b/user/mpy/lib/libffi/src/sh64/sysv.S new file mode 100644 index 0000000..c4587d5 --- /dev/null +++ b/user/mpy/lib/libffi/src/sh64/sysv.S @@ -0,0 +1,539 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2003, 2004, 2006, 2008 Kaz Kojima + + SuperH SHmedia Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#ifdef HAVE_MACHINE_ASM_H +#include +#else +/* XXX these lose for some platforms, I'm sure. */ +#define CNAME(x) x +#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): +#endif + +#ifdef __LITTLE_ENDIAN__ +#define OFS_FLT 0 +#else +#define OFS_FLT 4 +#endif + + .section .text..SHmedia32,"ax" + + # r2: ffi_prep_args + # r3: &ecif + # r4: bytes + # r5: flags + # r6: flags2 + # r7: rvalue + # r8: fn + + # This assumes we are using gas. + .align 5 +ENTRY(ffi_call_SYSV) + # Save registers +.LFB1: + addi.l r15, -48, r15 +.LCFI0: + st.q r15, 40, r32 + st.q r15, 32, r31 + st.q r15, 24, r30 + st.q r15, 16, r29 + st.q r15, 8, r28 + st.l r15, 4, r18 + st.l r15, 0, r14 +.LCFI1: + add.l r15, r63, r14 +.LCFI2: +# add r4, r63, r28 + add r5, r63, r29 + add r6, r63, r30 + add r7, r63, r31 + add r8, r63, r32 + + addi r4, (64 + 7), r4 + andi r4, ~7, r4 + sub.l r15, r4, r15 + + ptabs/l r2, tr0 + add r15, r63, r2 + blink tr0, r18 + + addi r15, 64, r22 + movi 0, r0 + movi 0, r1 + movi -1, r23 + + pt/l 1f, tr1 + bnei/l r29, FFI_TYPE_STRUCT, tr1 + ld.l r15, 0, r19 + addi r15, 8, r15 + addi r0, 1, r0 +1: + +.L_pass: + andi r30, 3, r20 + shlri r30, 2, r30 + + pt/l .L_call_it, tr0 + pt/l .L_pass_i, tr1 + pt/l .L_pass_f, tr2 + + beqi/l r20, FFI_TYPE_VOID, tr0 + beqi/l r20, FFI_TYPE_INT, tr1 + beqi/l r20, FFI_TYPE_FLOAT, tr2 + +.L_pass_d: + addi r0, 1, r0 + pt/l 3f, tr0 + movi 12, r20 + bge/l r1, r20, tr0 + + pt/l .L_pop_d, tr1 + pt/l 2f, tr0 + blink tr1, r63 +2: + addi.l r15, 8, r15 +3: + pt/l .L_pass, tr0 + addi r1, 2, r1 + blink tr0, r63 + +.L_pop_d: + pt/l .L_pop_d_tbl, tr1 + gettr tr1, r20 + shlli r1, 2, r21 + add r20, r21, r20 + ptabs/l r20, tr1 + blink tr1, r63 + +.L_pop_d_tbl: + fld.d r15, 0, dr0 + blink tr0, r63 + fld.d r15, 0, dr2 + blink tr0, r63 + fld.d r15, 0, dr4 + blink tr0, r63 + fld.d r15, 0, dr6 + blink tr0, r63 + fld.d r15, 0, dr8 + blink tr0, r63 + fld.d r15, 0, dr10 + blink tr0, r63 + +.L_pass_f: + addi r0, 1, r0 + pt/l 3f, tr0 + movi 12, r20 + bge/l r1, r20, tr0 + + pt/l .L_pop_f, tr1 + pt/l 2f, tr0 + blink tr1, r63 +2: + addi.l r15, 8, r15 +3: + pt/l .L_pass, tr0 + blink tr0, r63 + +.L_pop_f: + pt/l .L_pop_f_tbl, tr1 + pt/l 5f, tr2 + gettr tr1, r20 + bge/l r23, r63, tr2 + add r1, r63, r23 + shlli r1, 3, r21 + addi r1, 2, r1 + add r20, r21, r20 + ptabs/l r20, tr1 + blink tr1, r63 +5: + addi r23, 1, r21 + movi -1, r23 + shlli r21, 3, r21 + add r20, r21, r20 + ptabs/l r20, tr1 + blink tr1, r63 + +.L_pop_f_tbl: + fld.s r15, OFS_FLT, fr0 + blink tr0, r63 + fld.s r15, OFS_FLT, fr1 + blink tr0, r63 + fld.s r15, OFS_FLT, fr2 + blink tr0, r63 + fld.s r15, OFS_FLT, fr3 + blink tr0, r63 + fld.s r15, OFS_FLT, fr4 + blink tr0, r63 + fld.s r15, OFS_FLT, fr5 + blink tr0, r63 + fld.s r15, OFS_FLT, fr6 + blink tr0, r63 + fld.s r15, OFS_FLT, fr7 + blink tr0, r63 + fld.s r15, OFS_FLT, fr8 + blink tr0, r63 + fld.s r15, OFS_FLT, fr9 + blink tr0, r63 + fld.s r15, OFS_FLT, fr10 + blink tr0, r63 + fld.s r15, OFS_FLT, fr11 + blink tr0, r63 + +.L_pass_i: + pt/l 3f, tr0 + movi 8, r20 + bge/l r0, r20, tr0 + + pt/l .L_pop_i, tr1 + pt/l 2f, tr0 + blink tr1, r63 +2: + addi.l r15, 8, r15 +3: + pt/l .L_pass, tr0 + addi r0, 1, r0 + blink tr0, r63 + +.L_pop_i: + pt/l .L_pop_i_tbl, tr1 + gettr tr1, r20 + shlli r0, 3, r21 + add r20, r21, r20 + ptabs/l r20, tr1 + blink tr1, r63 + +.L_pop_i_tbl: + ld.q r15, 0, r2 + blink tr0, r63 + ld.q r15, 0, r3 + blink tr0, r63 + ld.q r15, 0, r4 + blink tr0, r63 + ld.q r15, 0, r5 + blink tr0, r63 + ld.q r15, 0, r6 + blink tr0, r63 + ld.q r15, 0, r7 + blink tr0, r63 + ld.q r15, 0, r8 + blink tr0, r63 + ld.q r15, 0, r9 + blink tr0, r63 + +.L_call_it: + # call function + pt/l 1f, tr1 + bnei/l r29, FFI_TYPE_STRUCT, tr1 + add r19, r63, r2 +1: + add r22, r63, r15 + ptabs/l r32, tr0 + blink tr0, r18 + + pt/l .L_ret_i, tr0 + pt/l .L_ret_ll, tr1 + pt/l .L_ret_d, tr2 + pt/l .L_ret_f, tr3 + pt/l .L_epilogue, tr4 + + beqi/l r29, FFI_TYPE_INT, tr0 + beqi/l r29, FFI_TYPE_UINT32, tr0 + beqi/l r29, FFI_TYPE_SINT64, tr1 + beqi/l r29, FFI_TYPE_UINT64, tr1 + beqi/l r29, FFI_TYPE_DOUBLE, tr2 + beqi/l r29, FFI_TYPE_FLOAT, tr3 + + pt/l .L_ret_q, tr0 + pt/l .L_ret_h, tr1 + + beqi/l r29, FFI_TYPE_UINT8, tr0 + beqi/l r29, FFI_TYPE_UINT16, tr1 + blink tr4, r63 + +.L_ret_d: + fst.d r31, 0, dr0 + blink tr4, r63 + +.L_ret_ll: + st.q r31, 0, r2 + blink tr4, r63 + +.L_ret_f: + fst.s r31, OFS_FLT, fr0 + blink tr4, r63 + +.L_ret_q: + st.b r31, 0, r2 + blink tr4, r63 + +.L_ret_h: + st.w r31, 0, r2 + blink tr4, r63 + +.L_ret_i: + st.l r31, 0, r2 + # Fall + +.L_epilogue: + # Remove the space we pushed for the args + add r14, r63, r15 + + ld.l r15, 0, r14 + ld.l r15, 4, r18 + ld.q r15, 8, r28 + ld.q r15, 16, r29 + ld.q r15, 24, r30 + ld.q r15, 32, r31 + ld.q r15, 40, r32 + addi.l r15, 48, r15 + ptabs r18, tr0 + blink tr0, r63 + +.LFE1: +.ffi_call_SYSV_end: + .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) + + .align 5 +ENTRY(ffi_closure_SYSV) +.LFB2: + addi.l r15, -136, r15 +.LCFI3: + st.l r15, 12, r18 + st.l r15, 8, r14 + st.l r15, 4, r12 +.LCFI4: + add r15, r63, r14 +.LCFI5: + /* Stack layout: + ... + 64 bytes (register parameters) + 48 bytes (floating register parameters) + 8 bytes (result) + 4 bytes (r18) + 4 bytes (r14) + 4 bytes (r12) + 4 bytes (for align) + <- new stack pointer + */ + fst.d r14, 24, dr0 + fst.d r14, 32, dr2 + fst.d r14, 40, dr4 + fst.d r14, 48, dr6 + fst.d r14, 56, dr8 + fst.d r14, 64, dr10 + st.q r14, 72, r2 + st.q r14, 80, r3 + st.q r14, 88, r4 + st.q r14, 96, r5 + st.q r14, 104, r6 + st.q r14, 112, r7 + st.q r14, 120, r8 + st.q r14, 128, r9 + + add r1, r63, r2 + addi r14, 16, r3 + addi r14, 72, r4 + addi r14, 24, r5 + addi r14, 136, r6 +#ifdef PIC + movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12 + shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12 +.LPCS0: ptrel/u r12, tr0 + movi ((ffi_closure_helper_SYSV@GOTPLT) & 65535), r1 + gettr tr0, r12 + ldx.l r1, r12, r1 + ptabs r1, tr0 +#else + pt/l ffi_closure_helper_SYSV, tr0 +#endif + blink tr0, r18 + + shlli r2, 1, r1 + movi (((datalabel .L_table) >> 16) & 65535), r2 + shori ((datalabel .L_table) & 65535), r2 + ldx.w r2, r1, r1 + add r1, r2, r1 + pt/l .L_case_v, tr1 + ptabs r1, tr0 + blink tr0, r63 + + .align 2 +.L_table: + .word .L_case_v - datalabel .L_table /* FFI_TYPE_VOID */ + .word .L_case_i - datalabel .L_table /* FFI_TYPE_INT */ + .word .L_case_f - datalabel .L_table /* FFI_TYPE_FLOAT */ + .word .L_case_d - datalabel .L_table /* FFI_TYPE_DOUBLE */ + .word .L_case_d - datalabel .L_table /* FFI_TYPE_LONGDOUBLE */ + .word .L_case_uq - datalabel .L_table /* FFI_TYPE_UINT8 */ + .word .L_case_q - datalabel .L_table /* FFI_TYPE_SINT8 */ + .word .L_case_uh - datalabel .L_table /* FFI_TYPE_UINT16 */ + .word .L_case_h - datalabel .L_table /* FFI_TYPE_SINT16 */ + .word .L_case_i - datalabel .L_table /* FFI_TYPE_UINT32 */ + .word .L_case_i - datalabel .L_table /* FFI_TYPE_SINT32 */ + .word .L_case_ll - datalabel .L_table /* FFI_TYPE_UINT64 */ + .word .L_case_ll - datalabel .L_table /* FFI_TYPE_SINT64 */ + .word .L_case_v - datalabel .L_table /* FFI_TYPE_STRUCT */ + .word .L_case_i - datalabel .L_table /* FFI_TYPE_POINTER */ + + .align 2 +.L_case_d: + fld.d r14, 16, dr0 + blink tr1, r63 +.L_case_f: + fld.s r14, 16, fr0 + blink tr1, r63 +.L_case_ll: + ld.q r14, 16, r2 + blink tr1, r63 +.L_case_i: + ld.l r14, 16, r2 + blink tr1, r63 +.L_case_q: + ld.b r14, 16, r2 + blink tr1, r63 +.L_case_uq: + ld.ub r14, 16, r2 + blink tr1, r63 +.L_case_h: + ld.w r14, 16, r2 + blink tr1, r63 +.L_case_uh: + ld.uw r14, 16, r2 + blink tr1, r63 +.L_case_v: + add.l r14, r63, r15 + ld.l r15, 4, r12 + ld.l r15, 8, r14 + ld.l r15, 12, r18 + addi.l r15, 136, r15 + ptabs r18, tr0 + blink tr0, r63 + +.LFE2: +.ffi_closure_SYSV_end: + .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif + + .section ".eh_frame","aw",@progbits +__FRAME_BEGIN__: + .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */ +.LSCIE1: + .4byte 0x0 /* CIE Identifier Tag */ + .byte 0x1 /* CIE Version */ +#ifdef PIC + .ascii "zR\0" /* CIE Augmentation */ +#else + .byte 0x0 /* CIE Augmentation */ +#endif + .uleb128 0x1 /* CIE Code Alignment Factor */ + .sleb128 -4 /* CIE Data Alignment Factor */ + .byte 0x12 /* CIE RA Column */ +#ifdef PIC + .uleb128 0x1 /* Augmentation size */ + .byte 0x10 /* FDE Encoding (pcrel) */ +#endif + .byte 0xc /* DW_CFA_def_cfa */ + .uleb128 0xf + .uleb128 0x0 + .align 2 +.LECIE1: +.LSFDE1: + .4byte datalabel .LEFDE1-datalabel .LASFDE1 /* FDE Length */ +.LASFDE1: + .4byte datalabel .LASFDE1-datalabel __FRAME_BEGIN__ +#ifdef PIC + .4byte .LFB1-. /* FDE initial location */ +#else + .4byte .LFB1 /* FDE initial location */ +#endif + .4byte datalabel .LFE1-datalabel .LFB1 /* FDE address range */ +#ifdef PIC + .uleb128 0x0 /* Augmentation size */ +#endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte datalabel .LCFI0-datalabel .LFB1 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .uleb128 0x30 + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte datalabel .LCFI1-datalabel .LCFI0 + .byte 0x8e /* DW_CFA_offset, column 0xe */ + .uleb128 0xc + .byte 0x92 /* DW_CFA_offset, column 0x12 */ + .uleb128 0xb + .byte 0x9c /* DW_CFA_offset, column 0x1c */ + .uleb128 0xa + .byte 0x9d /* DW_CFA_offset, column 0x1d */ + .uleb128 0x8 + .byte 0x9e /* DW_CFA_offset, column 0x1e */ + .uleb128 0x6 + .byte 0x9f /* DW_CFA_offset, column 0x1f */ + .uleb128 0x4 + .byte 0xa0 /* DW_CFA_offset, column 0x20 */ + .uleb128 0x2 + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte datalabel .LCFI2-datalabel .LCFI1 + .byte 0xd /* DW_CFA_def_cfa_register */ + .uleb128 0xe + .align 2 +.LEFDE1: + +.LSFDE3: + .4byte datalabel .LEFDE3-datalabel .LASFDE3 /* FDE Length */ +.LASFDE3: + .4byte datalabel .LASFDE3-datalabel __FRAME_BEGIN__ +#ifdef PIC + .4byte .LFB2-. /* FDE initial location */ +#else + .4byte .LFB2 /* FDE initial location */ +#endif + .4byte datalabel .LFE2-datalabel .LFB2 /* FDE address range */ +#ifdef PIC + .uleb128 0x0 /* Augmentation size */ +#endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte datalabel .LCFI3-datalabel .LFB2 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .uleb128 0x88 + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte datalabel .LCFI4-datalabel .LCFI3 + .byte 0x8c /* DW_CFA_offset, column 0xc */ + .uleb128 0x21 + .byte 0x8e /* DW_CFA_offset, column 0xe */ + .uleb128 0x20 + .byte 0x92 /* DW_CFA_offset, column 0x12 */ + .uleb128 0x1f + .byte 0x4 /* DW_CFA_advance_loc4 */ + .4byte datalabel .LCFI5-datalabel .LCFI4 + .byte 0xd /* DW_CFA_def_cfa_register */ + .uleb128 0xe + .align 2 +.LEFDE3: diff --git a/user/mpy/lib/libffi/src/sparc/ffi.c b/user/mpy/lib/libffi/src/sparc/ffi.c new file mode 100644 index 0000000..d5212d8 --- /dev/null +++ b/user/mpy/lib/libffi/src/sparc/ffi.c @@ -0,0 +1,468 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2011, 2013 Anthony Green + Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc. + + SPARC Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include "internal.h" + +#ifndef SPARC64 + +/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; + all further uses in this file will refer to the 128-bit type. */ +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +# if FFI_TYPE_LONGDOUBLE != 4 +# error FFI_TYPE_LONGDOUBLE out of date +# endif +#else +# undef FFI_TYPE_LONGDOUBLE +# define FFI_TYPE_LONGDOUBLE 4 +#endif + +/* Perform machine dependent cif processing */ +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep(ffi_cif *cif) +{ + ffi_type *rtype = cif->rtype; + int rtt = rtype->type; + size_t bytes; + int i, n, flags; + + /* Set the return type flag */ + switch (rtt) + { + case FFI_TYPE_VOID: + flags = SPARC_RET_VOID; + break; + case FFI_TYPE_FLOAT: + flags = SPARC_RET_F_1; + break; + case FFI_TYPE_DOUBLE: + flags = SPARC_RET_F_2; + break; + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_STRUCT: + flags = (rtype->size & 0xfff) << SPARC_SIZEMASK_SHIFT; + flags |= SPARC_RET_STRUCT; + break; + case FFI_TYPE_SINT8: + flags = SPARC_RET_SINT8; + break; + case FFI_TYPE_UINT8: + flags = SPARC_RET_UINT8; + break; + case FFI_TYPE_SINT16: + flags = SPARC_RET_SINT16; + break; + case FFI_TYPE_UINT16: + flags = SPARC_RET_UINT16; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + flags = SPARC_RET_UINT32; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + flags = SPARC_RET_INT64; + break; + case FFI_TYPE_COMPLEX: + rtt = rtype->elements[0]->type; + switch (rtt) + { + case FFI_TYPE_FLOAT: + flags = SPARC_RET_F_2; + break; + case FFI_TYPE_DOUBLE: + flags = SPARC_RET_F_4; + break; + case FFI_TYPE_LONGDOUBLE: + flags = SPARC_RET_F_8; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + flags = SPARC_RET_INT128; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + flags = SPARC_RET_INT64; + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + flags = SP_V8_RET_CPLX16; + break; + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + flags = SP_V8_RET_CPLX8; + break; + default: + abort(); + } + break; + default: + abort(); + } + cif->flags = flags; + + bytes = 0; + for (i = 0, n = cif->nargs; i < n; ++i) + { + ffi_type *ty = cif->arg_types[i]; + size_t z = ty->size; + int tt = ty->type; + + switch (tt) + { + case FFI_TYPE_STRUCT: + case FFI_TYPE_LONGDOUBLE: + by_reference: + /* Passed by reference. */ + z = 4; + break; + + case FFI_TYPE_COMPLEX: + tt = ty->elements[0]->type; + if (tt == FFI_TYPE_FLOAT || z > 8) + goto by_reference; + /* FALLTHRU */ + + default: + z = ALIGN(z, 4); + } + bytes += z; + } + + /* Sparc call frames require that space is allocated for 6 args, + even if they aren't used. Make that space if necessary. */ + if (bytes < 6 * 4) + bytes = 6 * 4; + + /* The ABI always requires space for the struct return pointer. */ + bytes += 4; + + /* The stack must be 2 word aligned, so round bytes up appropriately. */ + bytes = ALIGN(bytes, 2 * 4); + + /* Include the call frame to prep_args. */ + bytes += 4*16 + 4*8; + cif->bytes = bytes; + + return FFI_OK; +} + +extern void ffi_call_v8(ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, size_t bytes, void *closure) FFI_HIDDEN; + +int FFI_HIDDEN +ffi_prep_args_v8(ffi_cif *cif, unsigned long *argp, void *rvalue, void **avalue) +{ + ffi_type **p_arg; + int flags = cif->flags; + int i, nargs; + + if (rvalue == NULL) + { + if ((flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) + { + /* Since we pass the pointer to the callee, we need a value. + We allowed for this space in ffi_call, before ffi_call_v8 + alloca'd the space. */ + rvalue = (char *)argp + cif->bytes; + } + else + { + /* Otherwise, we can ignore the return value. */ + flags = SPARC_RET_VOID; + } + } + + /* This could only really be done when we are returning a structure. + However, the space is reserved so we can do it unconditionally. */ + *argp++ = (unsigned long)rvalue; + +#ifdef USING_PURIFY + /* Purify will probably complain in our assembly routine, + unless we zero out this memory. */ + memset(argp, 0, 6*4); +#endif + + p_arg = cif->arg_types; + for (i = 0, nargs = cif->nargs; i < nargs; i++) + { + ffi_type *ty = p_arg[i]; + void *a = avalue[i]; + int tt = ty->type; + size_t z; + + switch (tt) + { + case FFI_TYPE_STRUCT: + case FFI_TYPE_LONGDOUBLE: + by_reference: + *argp++ = (unsigned long)a; + break; + + case FFI_TYPE_DOUBLE: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + memcpy(argp, a, 8); + argp += 2; + break; + + case FFI_TYPE_INT: + case FFI_TYPE_FLOAT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + *argp++ = *(unsigned *)a; + break; + + case FFI_TYPE_UINT8: + *argp++ = *(UINT8 *)a; + break; + case FFI_TYPE_SINT8: + *argp++ = *(SINT8 *)a; + break; + case FFI_TYPE_UINT16: + *argp++ = *(UINT16 *)a; + break; + case FFI_TYPE_SINT16: + *argp++ = *(SINT16 *)a; + break; + + case FFI_TYPE_COMPLEX: + tt = ty->elements[0]->type; + z = ty->size; + if (tt == FFI_TYPE_FLOAT || z > 8) + goto by_reference; + if (z < 4) + { + memcpy((char *)argp + 4 - z, a, z); + argp++; + } + else + { + memcpy(argp, a, z); + argp += z / 4; + } + break; + + default: + abort(); + } + } + + return flags; +} + +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + size_t bytes = cif->bytes; + + FFI_ASSERT (cif->abi == FFI_V8); + + /* If we've not got a return value, we need to create one if we've + got to pass the return value to the callee. Otherwise ignore it. */ + if (rvalue == NULL + && (cif->flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) + bytes += ALIGN (cif->rtype->size, 8); + + ffi_call_v8(cif, fn, rvalue, avalue, -bytes, closure); +} + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + +#ifdef __GNUC__ +static inline void +ffi_flush_icache (void *p) +{ + /* SPARC v8 requires 5 instructions for flush to be visible */ + asm volatile ("iflush %0; iflush %0+8; nop; nop; nop; nop; nop" + : : "r" (p) : "memory"); +} +#else +extern void ffi_flush_icache (void *) FFI_HIDDEN; +#endif + +extern void ffi_closure_v8(void) FFI_HIDDEN; +extern void ffi_go_closure_v8(void) FFI_HIDDEN; + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; + unsigned long ctx = (unsigned long) closure; + unsigned long fn = (unsigned long) ffi_closure_v8; + + if (cif->abi != FFI_V8) + return FFI_BAD_ABI; + + tramp[0] = 0x03000000 | fn >> 10; /* sethi %hi(fn), %g1 */ + tramp[1] = 0x05000000 | ctx >> 10; /* sethi %hi(ctx), %g2 */ + tramp[2] = 0x81c06000 | (fn & 0x3ff); /* jmp %g1+%lo(fn) */ + tramp[3] = 0x8410a000 | (ctx & 0x3ff);/* or %g2, %lo(ctx) */ + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + ffi_flush_icache (closure); + + return FFI_OK; +} + +ffi_status +ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*)) +{ + if (cif->abi != FFI_V8) + return FFI_BAD_ABI; + + closure->tramp = ffi_go_closure_v8; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +int FFI_HIDDEN +ffi_closure_sparc_inner_v8(ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, void *rvalue, + unsigned long *argp) +{ + ffi_type **arg_types; + void **avalue; + int i, nargs, flags; + + arg_types = cif->arg_types; + nargs = cif->nargs; + flags = cif->flags; + avalue = alloca(nargs * sizeof(void *)); + + /* Copy the caller's structure return address so that the closure + returns the data directly to the caller. Also install it so we + can return the address in %o0. */ + if ((flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) + { + void *new_rvalue = (void *)*argp; + *(void **)rvalue = new_rvalue; + rvalue = new_rvalue; + } + + /* Always skip the structure return address. */ + argp++; + + /* Grab the addresses of the arguments from the stack frame. */ + for (i = 0; i < nargs; i++) + { + ffi_type *ty = arg_types[i]; + int tt = ty->type; + void *a = argp; + size_t z; + + switch (tt) + { + case FFI_TYPE_STRUCT: + case FFI_TYPE_LONGDOUBLE: + by_reference: + /* Straight copy of invisible reference. */ + a = (void *)*argp; + break; + + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + if ((unsigned long)a & 7) + { + /* Align on a 8-byte boundary. */ + UINT64 *tmp = alloca(8); + *tmp = ((UINT64)argp[0] << 32) | argp[1]; + a = tmp; + } + argp++; + break; + + case FFI_TYPE_INT: + case FFI_TYPE_FLOAT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + break; + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + a += 2; + break; + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + a += 3; + break; + + case FFI_TYPE_COMPLEX: + tt = ty->elements[0]->type; + z = ty->size; + if (tt == FFI_TYPE_FLOAT || z > 8) + goto by_reference; + if (z < 4) + a += 4 - z; + else if (z > 4) + argp++; + break; + + default: + abort(); + } + argp++; + avalue[i] = a; + } + + /* Invoke the closure. */ + fun (cif, rvalue, avalue, user_data); + + /* Tell ffi_closure_sparc how to perform return type promotions. */ + return flags; +} +#endif /* !SPARC64 */ diff --git a/user/mpy/lib/libffi/src/sparc/ffi64.c b/user/mpy/lib/libffi/src/sparc/ffi64.c new file mode 100644 index 0000000..340b198 --- /dev/null +++ b/user/mpy/lib/libffi/src/sparc/ffi64.c @@ -0,0 +1,608 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2011, 2013 Anthony Green + Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc. + + SPARC Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include "internal.h" + +/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; + all further uses in this file will refer to the 128-bit type. */ +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +# if FFI_TYPE_LONGDOUBLE != 4 +# error FFI_TYPE_LONGDOUBLE out of date +# endif +#else +# undef FFI_TYPE_LONGDOUBLE +# define FFI_TYPE_LONGDOUBLE 4 +#endif + +#ifdef SPARC64 + +/* Flatten the contents of a structure to the parts that are passed in + floating point registers. The return is a bit mask wherein bit N + set means bytes [4*n, 4*n+3] are passed in %fN. + + We encode both the (running) size (maximum 32) and mask (maxumum 255) + into one integer. The size is placed in the low byte, so that align + and addition work correctly. The mask is placed in the second byte. */ + +static int +ffi_struct_float_mask (ffi_type *outer_type, int size_mask) +{ + ffi_type **elts; + ffi_type *t; + + if (outer_type->type == FFI_TYPE_COMPLEX) + { + int m = 0, tt = outer_type->elements[0]->type; + size_t z = outer_type->size; + + if (tt == FFI_TYPE_FLOAT + || tt == FFI_TYPE_DOUBLE + || tt == FFI_TYPE_LONGDOUBLE) + m = (1 << (z / 4)) - 1; + return (m << 8) | z; + } + FFI_ASSERT (outer_type->type == FFI_TYPE_STRUCT); + + for (elts = outer_type->elements; (t = *elts) != NULL; elts++) + { + size_t z = t->size; + int o, m, tt; + + size_mask = ALIGN(size_mask, t->alignment); + switch (t->type) + { + case FFI_TYPE_STRUCT: + size_mask = ffi_struct_float_mask (t, size_mask); + continue; + case FFI_TYPE_COMPLEX: + tt = t->elements[0]->type; + if (tt != FFI_TYPE_FLOAT + && tt != FFI_TYPE_DOUBLE + && tt != FFI_TYPE_LONGDOUBLE) + break; + /* FALLTHRU */ + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + m = (1 << (z / 4)) - 1; /* compute mask for type */ + o = (size_mask >> 2) & 0x3f; /* extract word offset */ + size_mask |= m << (o + 8); /* insert mask into place */ + break; + } + size_mask += z; + } + + size_mask = ALIGN(size_mask, outer_type->alignment); + FFI_ASSERT ((size_mask & 0xff) == outer_type->size); + + return size_mask; +} + +/* Merge floating point data into integer data. If the structure is + entirely floating point, simply return a pointer to the fp data. */ + +static void * +ffi_struct_float_merge (int size_mask, void *vi, void *vf) +{ + int size = size_mask & 0xff; + int mask = size_mask >> 8; + int n = size >> 2; + + if (mask == 0) + return vi; + else if (mask == (1 << n) - 1) + return vf; + else + { + unsigned int *wi = vi, *wf = vf; + int i; + + for (i = 0; i < n; ++i) + if ((mask >> i) & 1) + wi[i] = wf[i]; + + return vi; + } +} + +/* Similar, but place the data into VD in the end. */ + +void FFI_HIDDEN +ffi_struct_float_copy (int size_mask, void *vd, void *vi, void *vf) +{ + int size = size_mask & 0xff; + int mask = size_mask >> 8; + int n = size >> 2; + + if (mask == 0) + ; + else if (mask == (1 << n) - 1) + vi = vf; + else + { + unsigned int *wd = vd, *wi = vi, *wf = vf; + int i; + + for (i = 0; i < n; ++i) + wd[i] = ((mask >> i) & 1 ? wf : wi)[i]; + return; + } + memcpy (vd, vi, size); +} + +/* Perform machine dependent cif processing */ + +static ffi_status +ffi_prep_cif_machdep_core(ffi_cif *cif) +{ + ffi_type *rtype = cif->rtype; + int rtt = rtype->type; + size_t bytes = 0; + int i, n, flags; + + /* Set the return type flag */ + switch (rtt) + { + case FFI_TYPE_VOID: + flags = SPARC_RET_VOID; + break; + case FFI_TYPE_FLOAT: + flags = SPARC_RET_F_1; + break; + case FFI_TYPE_DOUBLE: + flags = SPARC_RET_F_2; + break; + case FFI_TYPE_LONGDOUBLE: + flags = SPARC_RET_F_4; + break; + + case FFI_TYPE_COMPLEX: + case FFI_TYPE_STRUCT: + if (rtype->size > 32) + { + flags = SPARC_RET_VOID | SPARC_FLAG_RET_IN_MEM; + bytes = 8; + } + else + { + int size_mask = ffi_struct_float_mask (rtype, 0); + int word_size = (size_mask >> 2) & 0x3f; + int all_mask = (1 << word_size) - 1; + int fp_mask = size_mask >> 8; + + flags = (size_mask << SPARC_SIZEMASK_SHIFT) | SPARC_RET_STRUCT; + + /* For special cases of all-int or all-fp, we can return + the value directly without popping through a struct copy. */ + if (fp_mask == 0) + { + if (rtype->alignment >= 8) + { + if (rtype->size == 8) + flags = SPARC_RET_INT64; + else if (rtype->size == 16) + flags = SPARC_RET_INT128; + } + } + else if (fp_mask == all_mask) + switch (word_size) + { + case 1: flags = SPARC_RET_F_1; break; + case 2: flags = SPARC_RET_F_2; break; + case 3: flags = SP_V9_RET_F_3; break; + case 4: flags = SPARC_RET_F_4; break; + /* 5 word structures skipped; handled via RET_STRUCT. */ + case 6: flags = SPARC_RET_F_6; break; + /* 7 word structures skipped; handled via RET_STRUCT. */ + case 8: flags = SPARC_RET_F_8; break; + } + } + break; + + case FFI_TYPE_SINT8: + flags = SPARC_RET_SINT8; + break; + case FFI_TYPE_UINT8: + flags = SPARC_RET_UINT8; + break; + case FFI_TYPE_SINT16: + flags = SPARC_RET_SINT16; + break; + case FFI_TYPE_UINT16: + flags = SPARC_RET_UINT16; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + flags = SP_V9_RET_SINT32; + break; + case FFI_TYPE_UINT32: + flags = SPARC_RET_UINT32; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + flags = SPARC_RET_INT64; + break; + + default: + abort(); + } + + bytes = 0; + for (i = 0, n = cif->nargs; i < n; ++i) + { + ffi_type *ty = cif->arg_types[i]; + size_t z = ty->size; + size_t a = ty->alignment; + + switch (ty->type) + { + case FFI_TYPE_COMPLEX: + case FFI_TYPE_STRUCT: + /* Large structs passed by reference. */ + if (z > 16) + { + a = z = 8; + break; + } + /* Small structs may be passed in integer or fp regs or both. */ + if (bytes >= 16*8) + break; + if ((ffi_struct_float_mask (ty, 0) & 0xff00) == 0) + break; + /* FALLTHRU */ + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + flags |= SPARC_FLAG_FP_ARGS; + break; + } + bytes = ALIGN(bytes, a); + bytes += ALIGN(z, 8); + } + + /* Sparc call frames require that space is allocated for 6 args, + even if they aren't used. Make that space if necessary. */ + if (bytes < 6 * 8) + bytes = 6 * 8; + + /* The stack must be 2 word aligned, so round bytes up appropriately. */ + bytes = ALIGN(bytes, 16); + + /* Include the call frame to prep_args. */ + bytes += 8*16 + 8*8; + + cif->bytes = bytes; + cif->flags = flags; + return FFI_OK; +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep(ffi_cif *cif) +{ + cif->nfixedargs = cif->nargs; + return ffi_prep_cif_machdep_core(cif); +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned nfixedargs, unsigned ntotalargs) +{ + cif->nfixedargs = nfixedargs; + return ffi_prep_cif_machdep_core(cif); +} + +extern void ffi_call_v9(ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, size_t bytes, void *closure) FFI_HIDDEN; + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +int FFI_HIDDEN +ffi_prep_args_v9(ffi_cif *cif, unsigned long *argp, void *rvalue, void **avalue) +{ + ffi_type **p_arg; + int flags = cif->flags; + int i, nargs; + + if (rvalue == NULL) + { + if (flags & SPARC_FLAG_RET_IN_MEM) + { + /* Since we pass the pointer to the callee, we need a value. + We allowed for this space in ffi_call, before ffi_call_v8 + alloca'd the space. */ + rvalue = (char *)argp + cif->bytes; + } + else + { + /* Otherwise, we can ignore the return value. */ + flags = SPARC_RET_VOID; + } + } + +#ifdef USING_PURIFY + /* Purify will probably complain in our assembly routine, + unless we zero out this memory. */ + memset(argp, 0, 6*8); +#endif + + if (flags & SPARC_FLAG_RET_IN_MEM) + *argp++ = (unsigned long)rvalue; + + p_arg = cif->arg_types; + for (i = 0, nargs = cif->nargs; i < nargs; i++) + { + ffi_type *ty = p_arg[i]; + void *a = avalue[i]; + size_t z; + + switch (ty->type) + { + case FFI_TYPE_SINT8: + *argp++ = *(SINT8 *)a; + break; + case FFI_TYPE_UINT8: + *argp++ = *(UINT8 *)a; + break; + case FFI_TYPE_SINT16: + *argp++ = *(SINT16 *)a; + break; + case FFI_TYPE_UINT16: + *argp++ = *(UINT16 *)a; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + *argp++ = *(SINT32 *)a; + break; + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + *argp++ = *(UINT32 *)a; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_POINTER: + case FFI_TYPE_DOUBLE: + *argp++ = *(UINT64 *)a; + break; + + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_COMPLEX: + case FFI_TYPE_STRUCT: + z = ty->size; + if (z > 16) + { + /* For structures larger than 16 bytes we pass reference. */ + *argp++ = (unsigned long)a; + break; + } + if (((unsigned long)argp & 15) && ty->alignment > 8) + argp++; + memcpy(argp, a, z); + argp += ALIGN(z, 8) / 8; + break; + + default: + abort(); + } + } + + return flags; +} + +static void +ffi_call_int(ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + size_t bytes = cif->bytes; + + FFI_ASSERT (cif->abi == FFI_V9); + + if (rvalue == NULL && (cif->flags & SPARC_FLAG_RET_IN_MEM)) + bytes += ALIGN (cif->rtype->size, 16); + + ffi_call_v9(cif, fn, rvalue, avalue, -bytes, closure); +} + +void +ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int(cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go(ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int(cif, fn, rvalue, avalue, closure); +} + +#ifdef __GNUC__ +static inline void +ffi_flush_icache (void *p) +{ + asm volatile ("flush %0; flush %0+8" : : "r" (p) : "memory"); +} +#else +extern void ffi_flush_icache (void *) FFI_HIDDEN; +#endif + +extern void ffi_closure_v9(void) FFI_HIDDEN; +extern void ffi_go_closure_v9(void) FFI_HIDDEN; + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; + unsigned long fn; + + if (cif->abi != FFI_V9) + return FFI_BAD_ABI; + + /* Trampoline address is equal to the closure address. We take advantage + of that to reduce the trampoline size by 8 bytes. */ + fn = (unsigned long) ffi_closure_v9; + tramp[0] = 0x83414000; /* rd %pc, %g1 */ + tramp[1] = 0xca586010; /* ldx [%g1+16], %g5 */ + tramp[2] = 0x81c14000; /* jmp %g5 */ + tramp[3] = 0x01000000; /* nop */ + *((unsigned long *) &tramp[4]) = fn; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + ffi_flush_icache (closure); + + return FFI_OK; +} + +ffi_status +ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*)) +{ + if (cif->abi != FFI_V9) + return FFI_BAD_ABI; + + closure->tramp = ffi_go_closure_v9; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +int FFI_HIDDEN +ffi_closure_sparc_inner_v9(ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, void *rvalue, + unsigned long *gpr, unsigned long *fpr) +{ + ffi_type **arg_types; + void **avalue; + int i, argn, argx, nargs, flags, nfixedargs; + + arg_types = cif->arg_types; + nargs = cif->nargs; + flags = cif->flags; + nfixedargs = cif->nfixedargs; + + avalue = alloca(nargs * sizeof(void *)); + + /* Copy the caller's structure return address so that the closure + returns the data directly to the caller. */ + if (flags & SPARC_FLAG_RET_IN_MEM) + { + rvalue = (void *) gpr[0]; + /* Skip the structure return address. */ + argn = 1; + } + else + argn = 0; + + /* Grab the addresses of the arguments from the stack frame. */ + for (i = 0; i < nargs; i++, argn = argx) + { + int named = i < nfixedargs; + ffi_type *ty = arg_types[i]; + void *a = &gpr[argn]; + size_t z; + + argx = argn + 1; + switch (ty->type) + { + case FFI_TYPE_COMPLEX: + case FFI_TYPE_STRUCT: + z = ty->size; + if (z > 16) + a = *(void **)a; + else + { + argx = argn + ALIGN (z, 8) / 8; + if (named && argn < 16) + { + int size_mask = ffi_struct_float_mask (ty, 0); + int argn_mask = (0xffff00 >> argn) & 0xff00; + + /* Eliminate fp registers off the end. */ + size_mask = (size_mask & 0xff) | (size_mask & argn_mask); + a = ffi_struct_float_merge (size_mask, gpr+argn, fpr+argn); + } + } + break; + + case FFI_TYPE_LONGDOUBLE: + argn = ALIGN (argn, 2); + a = (named && argn < 16 ? fpr : gpr) + argn; + argx = argn + 2; + break; + case FFI_TYPE_DOUBLE: + if (named && argn < 16) + a = fpr + argn; + break; + case FFI_TYPE_FLOAT: + if (named && argn < 16) + a = fpr + argn; + a += 4; + break; + + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + break; + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + a += 4; + break; + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + a += 6; + break; + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + a += 7; + break; + + default: + abort(); + } + avalue[i] = a; + } + + /* Invoke the closure. */ + fun (cif, rvalue, avalue, user_data); + + /* Tell ffi_closure_sparc how to perform return type promotions. */ + return flags; +} +#endif /* SPARC64 */ diff --git a/user/mpy/lib/libffi/src/sparc/ffitarget.h b/user/mpy/lib/libffi/src/sparc/ffitarget.h new file mode 100644 index 0000000..2f4cd9a --- /dev/null +++ b/user/mpy/lib/libffi/src/sparc/ffitarget.h @@ -0,0 +1,81 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 1996-2003 Red Hat, Inc. + Target configuration macros for SPARC. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#if defined(__arch64__) || defined(__sparcv9) +#ifndef SPARC64 +#define SPARC64 +#endif +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, +#ifdef SPARC64 + FFI_V9, + FFI_DEFAULT_ABI = FFI_V9, +#else + FFI_V8, + FFI_DEFAULT_ABI = FFI_V8, +#endif + FFI_LAST_ABI +} ffi_abi; +#endif + +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION 1 +#define FFI_TARGET_HAS_COMPLEX_TYPE 1 + +#ifdef SPARC64 +# define FFI_TARGET_SPECIFIC_VARIADIC 1 +# define FFI_EXTRA_CIF_FIELDS unsigned int nfixedargs +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 + +#ifdef SPARC64 +#define FFI_TRAMPOLINE_SIZE 24 +#else +#define FFI_TRAMPOLINE_SIZE 16 +#endif + +#endif + diff --git a/user/mpy/lib/libffi/src/sparc/internal.h b/user/mpy/lib/libffi/src/sparc/internal.h new file mode 100644 index 0000000..0a66472 --- /dev/null +++ b/user/mpy/lib/libffi/src/sparc/internal.h @@ -0,0 +1,26 @@ +#define SPARC_RET_VOID 0 +#define SPARC_RET_STRUCT 1 +#define SPARC_RET_UINT8 2 +#define SPARC_RET_SINT8 3 +#define SPARC_RET_UINT16 4 +#define SPARC_RET_SINT16 5 +#define SPARC_RET_UINT32 6 +#define SP_V9_RET_SINT32 7 /* v9 only */ +#define SP_V8_RET_CPLX16 7 /* v8 only */ +#define SPARC_RET_INT64 8 +#define SPARC_RET_INT128 9 + +/* Note that F_7 is missing, and is handled by SPARC_RET_STRUCT. */ +#define SPARC_RET_F_8 10 +#define SPARC_RET_F_6 11 +#define SPARC_RET_F_4 12 +#define SPARC_RET_F_2 13 +#define SP_V9_RET_F_3 14 /* v9 only */ +#define SP_V8_RET_CPLX8 14 /* v8 only */ +#define SPARC_RET_F_1 15 + +#define SPARC_FLAG_RET_MASK 15 +#define SPARC_FLAG_RET_IN_MEM 32 +#define SPARC_FLAG_FP_ARGS 64 + +#define SPARC_SIZEMASK_SHIFT 8 diff --git a/user/mpy/lib/libffi/src/sparc/v8.S b/user/mpy/lib/libffi/src/sparc/v8.S new file mode 100644 index 0000000..a2e4908 --- /dev/null +++ b/user/mpy/lib/libffi/src/sparc/v8.S @@ -0,0 +1,443 @@ +/* ----------------------------------------------------------------------- + v8.S - Copyright (c) 2013 The Written Word, Inc. + Copyright (c) 1996, 1997, 2003, 2004, 2008 Red Hat, Inc. + + SPARC Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#include "internal.h" + +#ifndef SPARC64 + +#define C2(X, Y) X ## Y +#define C1(X, Y) C2(X, Y) + +#ifdef __USER_LABEL_PREFIX__ +# define C(Y) C1(__USER_LABEL_PREFIX__, Y) +#else +# define C(Y) Y +#endif +#define L(Y) C1(.L, Y) + + .text + +#ifndef __GNUC__ + .align 8 + .globl C(ffi_flush_icache) + .type C(ffi_flush_icache),#function + FFI_HIDDEN(C(ffi_flush_icache)) + +C(ffi_flush_icache): +1: iflush %o0 + iflush %o+8 + nop + nop + nop + nop + nop + retl + nop + .size C(ffi_flush_icache), . - C(ffi_flush_icache) +#endif + +#if defined(__sun__) && defined(__svr4__) +# define E(INDEX) .align 16 +#else +# define E(INDEX) .align 16; .org 2b + INDEX * 16 +#endif + + .align 8 + .globl C(ffi_call_v8) + .type C(ffi_call_v8),#function + FFI_HIDDEN(C(ffi_call_v8)) + +C(ffi_call_v8): +.LUW0: + ! Allocate a stack frame sized by ffi_call. + save %sp, %o4, %sp +.LUW1: + mov %i0, %o0 ! copy cif + add %sp, 64+32, %o1 ! load args area + mov %i2, %o2 ! copy rvalue + call C(ffi_prep_args_v8) + mov %i3, %o3 ! copy avalue + + add %sp, 32, %sp ! deallocate prep frame + and %o0, SPARC_FLAG_RET_MASK, %l0 ! save return type + srl %o0, SPARC_SIZEMASK_SHIFT, %l1 ! save return size + ld [%sp+64+4], %o0 ! load all argument registers + ld [%sp+64+8], %o1 + ld [%sp+64+12], %o2 + ld [%sp+64+16], %o3 + cmp %l0, SPARC_RET_STRUCT ! struct return needs an unimp 4 + ld [%sp+64+20], %o4 + be 8f + ld [%sp+64+24], %o5 + + ! Call foreign function + call %i1 + mov %i5, %g2 ! load static chain + +0: call 1f ! load pc in %o7 + sll %l0, 4, %l0 +1: add %o7, %l0, %o7 ! o7 = 0b + ret_type*16 + jmp %o7+(2f-0b) + nop + + ! Note that each entry is 4 insns, enforced by the E macro. + .align 16 +2: +E(SPARC_RET_VOID) + ret + restore +E(SPARC_RET_STRUCT) + unimp +E(SPARC_RET_UINT8) + and %o0, 0xff, %o0 + st %o0, [%i2] + ret + restore +E(SPARC_RET_SINT8) + sll %o0, 24, %o0 + b 7f + sra %o0, 24, %o0 +E(SPARC_RET_UINT16) + sll %o0, 16, %o0 + b 7f + srl %o0, 16, %o0 +E(SPARC_RET_SINT16) + sll %o0, 16, %o0 + b 7f + sra %o0, 16, %o0 +E(SPARC_RET_UINT32) +7: st %o0, [%i2] + ret + restore +E(SP_V8_RET_CPLX16) + sth %o0, [%i2+2] + b 9f + srl %o0, 16, %o0 +E(SPARC_RET_INT64) + st %o0, [%i2] + st %o1, [%i2+4] + ret + restore +E(SPARC_RET_INT128) + std %o0, [%i2] + std %o2, [%i2+8] + ret + restore +E(SPARC_RET_F_8) + st %f7, [%i2+7*4] + nop + st %f6, [%i2+6*4] + nop +E(SPARC_RET_F_6) + st %f5, [%i2+5*4] + nop + st %f4, [%i2+4*4] + nop +E(SPARC_RET_F_4) + st %f3, [%i2+3*4] + nop + st %f2, [%i2+2*4] + nop +E(SPARC_RET_F_2) + st %f1, [%i2+4] + st %f0, [%i2] + ret + restore +E(SP_V8_RET_CPLX8) + stb %o0, [%i2+1] + b 0f + srl %o0, 8, %o0 +E(SPARC_RET_F_1) + st %f0, [%i2] + ret + restore + + .align 8 +9: sth %o0, [%i2] + ret + restore + .align 8 +0: stb %o0, [%i2] + ret + restore + + ! Struct returning functions expect and skip the unimp here. + ! To make it worse, conforming callees examine the unimp and + ! make sure the low 12 bits of the unimp match the size of + ! the struct being returned. + .align 8 +8: call 1f ! load pc in %o7 + sll %l1, 2, %l0 ! size * 4 +1: sll %l1, 4, %l1 ! size * 16 + add %l0, %l1, %l0 ! size * 20 + add %o7, %l0, %o7 ! o7 = 8b + size*20 + jmp %o7+(2f-8b) + mov %i5, %g2 ! load static chain +2: + +/* The Sun assembler doesn't understand .rept 0x1000. */ +#define rept1 \ + call %i1; \ + nop; \ + unimp (. - 2b) / 20; \ + ret; \ + restore + +#define rept16 \ + rept1; rept1; rept1; rept1; \ + rept1; rept1; rept1; rept1; \ + rept1; rept1; rept1; rept1; \ + rept1; rept1; rept1; rept1 + +#define rept256 \ + rept16; rept16; rept16; rept16; \ + rept16; rept16; rept16; rept16; \ + rept16; rept16; rept16; rept16; \ + rept16; rept16; rept16; rept16 + + rept256; rept256; rept256; rept256 + rept256; rept256; rept256; rept256 + rept256; rept256; rept256; rept256 + rept256; rept256; rept256; rept256 + +.LUW2: + .size C(ffi_call_v8),. - C(ffi_call_v8) + + +/* 16*4 register window + 1*4 struct return + 6*4 args backing store + + 8*4 return storage + 1*4 alignment. */ +#define STACKFRAME (16*4 + 4 + 6*4 + 8*4 + 4) + +/* ffi_closure_v8(...) + + Receives the closure argument in %g2. */ + +#ifdef HAVE_AS_REGISTER_PSEUDO_OP + .register %g2, #scratch +#endif + + .align 8 + .globl C(ffi_go_closure_v8) + .type C(ffi_go_closure_v8),#function + FFI_HIDDEN(C(ffi_go_closure_v8)) + +C(ffi_go_closure_v8): +.LUW3: + save %sp, -STACKFRAME, %sp +.LUW4: + ld [%g2+4], %o0 ! load cif + ld [%g2+8], %o1 ! load fun + b 0f + mov %g2, %o2 ! load user_data +.LUW5: + .size C(ffi_go_closure_v8), . - C(ffi_go_closure_v8) + + .align 8 + .globl C(ffi_closure_v8) + .type C(ffi_closure_v8),#function + FFI_HIDDEN(C(ffi_closure_v8)) + +C(ffi_closure_v8): +.LUW6: + save %sp, -STACKFRAME, %sp +.LUW7: + ld [%g2+FFI_TRAMPOLINE_SIZE], %o0 ! load cif + ld [%g2+FFI_TRAMPOLINE_SIZE+4], %o1 ! load fun + ld [%g2+FFI_TRAMPOLINE_SIZE+8], %o2 ! load user_data +0: + ! Store all of the potential argument registers in va_list format. + st %i0, [%fp+68+0] + st %i1, [%fp+68+4] + st %i2, [%fp+68+8] + st %i3, [%fp+68+12] + st %i4, [%fp+68+16] + st %i5, [%fp+68+20] + + ! Call ffi_closure_sparc_inner to do the bulk of the work. + add %fp, -8*4, %o3 + call ffi_closure_sparc_inner_v8 + add %fp, 64, %o4 + +0: call 1f + and %o0, SPARC_FLAG_RET_MASK, %o0 +1: sll %o0, 4, %o0 ! o0 = o0 * 16 + add %o7, %o0, %o7 ! o7 = 0b + o0*16 + jmp %o7+(2f-0b) + add %fp, -8*4, %i2 + + ! Note that each entry is 4 insns, enforced by the E macro. + .align 16 +2: +E(SPARC_RET_VOID) + ret + restore +E(SPARC_RET_STRUCT) + ld [%i2], %i0 + jmp %i7+12 + restore +E(SPARC_RET_UINT8) + ldub [%i2+3], %i0 + ret + restore +E(SPARC_RET_SINT8) + ldsb [%i2+3], %i0 + ret + restore +E(SPARC_RET_UINT16) + lduh [%i2+2], %i0 + ret + restore +E(SPARC_RET_SINT16) + ldsh [%i2+2], %i0 + ret + restore +E(SPARC_RET_UINT32) + ld [%i2], %i0 + ret + restore +E(SP_V8_RET_CPLX16) + ld [%i2], %i0 + ret + restore +E(SPARC_RET_INT64) + ldd [%i2], %i0 + ret + restore +E(SPARC_RET_INT128) + ldd [%i2], %i0 + ldd [%i2+8], %i2 + ret + restore +E(SPARC_RET_F_8) + ld [%i2+7*4], %f7 + nop + ld [%i2+6*4], %f6 + nop +E(SPARC_RET_F_6) + ld [%i2+5*4], %f5 + nop + ld [%i2+4*4], %f4 + nop +E(SPARC_RET_F_4) + ld [%i2+3*4], %f3 + nop + ld [%i2+2*4], %f2 + nop +E(SPARC_RET_F_2) + ldd [%i2], %f0 + ret + restore +E(SP_V8_RET_CPLX8) + lduh [%i2], %i0 + ret + restore +E(SPARC_RET_F_1) + ld [%i2], %f0 + ret + restore + +.LUW8: + .size C(ffi_closure_v8), . - C(ffi_closure_v8) + +#ifdef HAVE_RO_EH_FRAME + .section ".eh_frame",#alloc +#else + .section ".eh_frame",#alloc,#write +#endif + +#ifdef HAVE_AS_SPARC_UA_PCREL +# define FDE_ADDR(X) %r_disp32(X) +#else +# define FDE_ADDR(X) X +#endif + + .align 4 +.LCIE: + .long .LECIE - .LSCIE ! CIE Length +.LSCIE: + .long 0 ! CIE Identifier Tag + .byte 1 ! CIE Version + .ascii "zR\0" ! CIE Augmentation + .byte 4 ! CIE Code Alignment Factor + .byte 0x7c ! CIE Data Alignment Factor + .byte 15 ! CIE RA Column + .byte 1 ! Augmentation size +#ifdef HAVE_AS_SPARC_UA_PCREL + .byte 0x1b ! FDE Encoding (pcrel sdata4) +#else + .byte 0x50 ! FDE Encoding (aligned absolute) +#endif + .byte 0xc, 14, 0 ! DW_CFA_def_cfa, %o6, offset 0 + .align 4 +.LECIE: + + .long .LEFDE1 - .LSFDE1 ! FDE Length +.LSFDE1: + .long .LSFDE1 - .LCIE ! FDE CIE offset + .long FDE_ADDR(.LUW0) ! Initial location + .long .LUW2 - .LUW0 ! Address range + .byte 0 ! Augmentation size + .byte 0x40+1 ! DW_CFA_advance_loc 4 + .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 + .byte 0x2d ! DW_CFA_GNU_window_save + .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 + .align 4 +.LEFDE1: + + .long .LEFDE2 - .LSFDE2 ! FDE Length +.LSFDE2: + .long .LSFDE2 - .LCIE ! FDE CIE offset + .long FDE_ADDR(.LUW3) ! Initial location + .long .LUW5 - .LUW3 ! Address range + .byte 0 ! Augmentation size + .byte 0x40+1 ! DW_CFA_advance_loc 4 + .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 + .byte 0x2d ! DW_CFA_GNU_window_save + .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 + .align 4 +.LEFDE2: + + .long .LEFDE3 - .LSFDE3 ! FDE Length +.LSFDE3: + .long .LSFDE3 - .LCIE ! FDE CIE offset + .long FDE_ADDR(.LUW6) ! Initial location + .long .LUW8 - .LUW6 ! Address range + .byte 0 ! Augmentation size + .byte 0x40+1 ! DW_CFA_advance_loc 4 + .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 + .byte 0x2d ! DW_CFA_GNU_window_save + .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 + .align 4 +.LEFDE3: + +#endif /* !SPARC64 */ +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/sparc/v9.S b/user/mpy/lib/libffi/src/sparc/v9.S new file mode 100644 index 0000000..55f8f43 --- /dev/null +++ b/user/mpy/lib/libffi/src/sparc/v9.S @@ -0,0 +1,440 @@ +/* ----------------------------------------------------------------------- + v9.S - Copyright (c) 2000, 2003, 2004, 2008 Red Hat, Inc. + + SPARC 64-bit Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include +#include "internal.h" + +#ifdef SPARC64 + +#define C2(X, Y) X ## Y +#define C1(X, Y) C2(X, Y) + +#ifdef __USER_LABEL_PREFIX__ +# define C(Y) C1(__USER_LABEL_PREFIX__, Y) +#else +# define C(Y) Y +#endif +#define L(Y) C1(.L, Y) + +#if defined(__sun__) && defined(__svr4__) +# define E(INDEX) .align 16 +#else +# define E(INDEX) .align 16; .org 2b + INDEX * 16 +#endif + +#define STACK_BIAS 2047 + + .text + .align 8 + .globl C(ffi_call_v9) + .type C(ffi_call_v9),#function + FFI_HIDDEN(C(ffi_call_v9)) + +C(ffi_call_v9): +.LUW0: + save %sp, %o4, %sp +.LUW1: + mov %i0, %o0 ! copy cif + add %sp, STACK_BIAS+128+48, %o1 ! load args area + mov %i2, %o2 ! copy rvalue + call C(ffi_prep_args_v9) + mov %i3, %o3 ! copy avalue + + andcc %o0, SPARC_FLAG_FP_ARGS, %g0 ! need fp regs? + add %sp, 48, %sp ! deallocate prep frame + be,pt %xcc, 1f + mov %o0, %l0 ! save flags + + ldd [%sp+STACK_BIAS+128], %f0 ! load all fp arg regs + ldd [%sp+STACK_BIAS+128+8], %f2 + ldd [%sp+STACK_BIAS+128+16], %f4 + ldd [%sp+STACK_BIAS+128+24], %f6 + ldd [%sp+STACK_BIAS+128+32], %f8 + ldd [%sp+STACK_BIAS+128+40], %f10 + ldd [%sp+STACK_BIAS+128+48], %f12 + ldd [%sp+STACK_BIAS+128+56], %f14 + ldd [%sp+STACK_BIAS+128+64], %f16 + ldd [%sp+STACK_BIAS+128+72], %f18 + ldd [%sp+STACK_BIAS+128+80], %f20 + ldd [%sp+STACK_BIAS+128+88], %f22 + ldd [%sp+STACK_BIAS+128+96], %f24 + ldd [%sp+STACK_BIAS+128+104], %f26 + ldd [%sp+STACK_BIAS+128+112], %f28 + ldd [%sp+STACK_BIAS+128+120], %f30 + +1: ldx [%sp+STACK_BIAS+128], %o0 ! load all int arg regs + ldx [%sp+STACK_BIAS+128+8], %o1 + ldx [%sp+STACK_BIAS+128+16], %o2 + ldx [%sp+STACK_BIAS+128+24], %o3 + ldx [%sp+STACK_BIAS+128+32], %o4 + ldx [%sp+STACK_BIAS+128+40], %o5 + call %i1 + mov %i5, %g5 ! load static chain + +0: call 1f ! load pc in %o7 + and %l0, SPARC_FLAG_RET_MASK, %l1 +1: sll %l1, 4, %l1 + add %o7, %l1, %o7 ! o7 = 0b + ret_type*16 + jmp %o7+(2f-0b) + nop + + .align 16 +2: +E(SPARC_RET_VOID) + return %i7+8 + nop +E(SPARC_RET_STRUCT) + add %sp, STACK_BIAS-64+128+48, %l2 + sub %sp, 64, %sp + b 8f + stx %o0, [%l2] +E(SPARC_RET_UINT8) + and %o0, 0xff, %i0 + return %i7+8 + stx %o0, [%o2] +E(SPARC_RET_SINT8) + sll %o0, 24, %o0 + sra %o0, 24, %i0 + return %i7+8 + stx %o0, [%o2] +E(SPARC_RET_UINT16) + sll %o0, 16, %o0 + srl %o0, 16, %i0 + return %i7+8 + stx %o0, [%o2] +E(SPARC_RET_SINT16) + sll %o0, 16, %o0 + sra %o0, 16, %i0 + return %i7+8 + stx %o0, [%o2] +E(SPARC_RET_UINT32) + srl %o0, 0, %i0 + return %i7+8 + stx %o0, [%o2] +E(SP_V9_RET_SINT32) + sra %o0, 0, %i0 + return %i7+8 + stx %o0, [%o2] +E(SPARC_RET_INT64) + stx %o0, [%i2] + return %i7+8 + nop +E(SPARC_RET_INT128) + stx %o0, [%i2] + stx %o1, [%i2+8] + return %i7+8 + nop +E(SPARC_RET_F_8) + st %f7, [%i2+7*4] + nop + st %f6, [%i2+6*4] + nop +E(SPARC_RET_F_6) + st %f5, [%i2+5*4] + nop + st %f4, [%i2+4*4] + nop +E(SPARC_RET_F_4) + std %f2, [%i2+2*4] + return %i7+8 + std %f0, [%o2] +E(SPARC_RET_F_2) + return %i7+8 + std %f0, [%o2] +E(SP_V9_RET_F_3) + st %f2, [%i2+2*4] + nop + st %f1, [%i2+1*4] + nop +E(SPARC_RET_F_1) + return %i7+8 + st %f0, [%o2] + + ! Finish the SPARC_RET_STRUCT sequence. + .align 8 +8: stx %o1, [%l2+8] + stx %o2, [%l2+16] + stx %o3, [%l2+24] + std %f0, [%l2+32] + std %f2, [%l2+40] + std %f4, [%l2+48] + std %f6, [%l2+56] + + ! Copy the structure into place. + srl %l0, SPARC_SIZEMASK_SHIFT, %o0 ! load size_mask + mov %i2, %o1 ! load dst + mov %l2, %o2 ! load src_gp + call C(ffi_struct_float_copy) + add %l2, 32, %o3 ! load src_fp + + return %i7+8 + nop + +.LUW2: + .size C(ffi_call_v9), . - C(ffi_call_v9) + + +#undef STACKFRAME +#define STACKFRAME 336 /* 16*8 register window + + 6*8 args backing store + + 20*8 locals */ +#define FP %fp+STACK_BIAS + +/* ffi_closure_v9(...) + + Receives the closure argument in %g1. */ + + .align 8 + .globl C(ffi_go_closure_v9) + .type C(ffi_go_closure_v9),#function + FFI_HIDDEN(C(ffi_go_closure_v9)) + +C(ffi_go_closure_v9): +.LUW3: + save %sp, -STACKFRAME, %sp +.LUW4: + ldx [%g5+8], %o0 + ldx [%g5+16], %o1 + b 0f + mov %g5, %o2 + +.LUW5: + .size C(ffi_go_closure_v9), . - C(ffi_go_closure_v9) + + .align 8 + .globl C(ffi_closure_v9) + .type C(ffi_closure_v9),#function + FFI_HIDDEN(C(ffi_closure_v9)) + +C(ffi_closure_v9): +.LUW6: + save %sp, -STACKFRAME, %sp +.LUW7: + ldx [%g1+FFI_TRAMPOLINE_SIZE], %o0 + ldx [%g1+FFI_TRAMPOLINE_SIZE+8], %o1 + ldx [%g1+FFI_TRAMPOLINE_SIZE+16], %o2 +0: + ! Store all of the potential argument registers in va_list format. + stx %i0, [FP+128+0] + stx %i1, [FP+128+8] + stx %i2, [FP+128+16] + stx %i3, [FP+128+24] + stx %i4, [FP+128+32] + stx %i5, [FP+128+40] + + ! Store possible floating point argument registers too. + std %f0, [FP-128] + std %f2, [FP-120] + std %f4, [FP-112] + std %f6, [FP-104] + std %f8, [FP-96] + std %f10, [FP-88] + std %f12, [FP-80] + std %f14, [FP-72] + std %f16, [FP-64] + std %f18, [FP-56] + std %f20, [FP-48] + std %f22, [FP-40] + std %f24, [FP-32] + std %f26, [FP-24] + std %f28, [FP-16] + std %f30, [FP-8] + + ! Call ffi_closure_sparc_inner to do the bulk of the work. + add %fp, STACK_BIAS-160, %o3 + add %fp, STACK_BIAS+128, %o4 + call C(ffi_closure_sparc_inner_v9) + add %fp, STACK_BIAS-128, %o5 + +0: call 1f ! load pc in %o7 + and %o0, SPARC_FLAG_RET_MASK, %o0 +1: sll %o0, 4, %o0 ! o2 = i2 * 16 + add %o7, %o0, %o7 ! o7 = 0b + i2*16 + jmp %o7+(2f-0b) + nop + + ! Note that we cannot load the data in the delay slot of + ! the return insn because the data is in the stack frame + ! that is deallocated by the return. + .align 16 +2: +E(SPARC_RET_VOID) + return %i7+8 + nop +E(SPARC_RET_STRUCT) + ldx [FP-160], %i0 + ldd [FP-160], %f0 + b 8f + ldx [FP-152], %i1 +E(SPARC_RET_UINT8) + ldub [FP-160+7], %i0 + return %i7+8 + nop +E(SPARC_RET_SINT8) + ldsb [FP-160+7], %i0 + return %i7+8 + nop +E(SPARC_RET_UINT16) + lduh [FP-160+6], %i0 + return %i7+8 + nop +E(SPARC_RET_SINT16) + ldsh [FP-160+6], %i0 + return %i7+8 + nop +E(SPARC_RET_UINT32) + lduw [FP-160+4], %i0 + return %i7+8 + nop +E(SP_V9_RET_SINT32) + ldsw [FP-160+4], %i0 + return %i7+8 + nop +E(SPARC_RET_INT64) + ldx [FP-160], %i0 + return %i7+8 + nop +E(SPARC_RET_INT128) + ldx [FP-160], %i0 + ldx [FP-160+8], %i1 + return %i7+8 + nop +E(SPARC_RET_F_8) + ld [FP-160+7*4], %f7 + nop + ld [FP-160+6*4], %f6 + nop +E(SPARC_RET_F_6) + ld [FP-160+5*4], %f5 + nop + ld [FP-160+4*4], %f4 + nop +E(SPARC_RET_F_4) + ldd [FP-160], %f0 + ldd [FP-160+8], %f2 + return %i7+8 + nop +E(SPARC_RET_F_2) + ldd [FP-160], %f0 + return %i7+8 + nop +E(SP_V9_RET_F_3) + ld [FP-160+2*4], %f2 + nop + ld [FP-160+1*4], %f1 + nop +E(SPARC_RET_F_1) + ld [FP-160], %f0 + return %i7+8 + nop + + ! Finish the SPARC_RET_STRUCT sequence. + .align 8 +8: ldd [FP-152], %f2 + ldx [FP-144], %i2 + ldd [FP-144], %f4 + ldx [FP-136], %i3 + ldd [FP-136], %f6 + return %i7+8 + nop + +.LUW8: + .size C(ffi_closure_v9), . - C(ffi_closure_v9) + +#ifdef HAVE_RO_EH_FRAME + .section ".eh_frame",#alloc +#else + .section ".eh_frame",#alloc,#write +#endif + +#ifdef HAVE_AS_SPARC_UA_PCREL +# define FDE_RANGE(B, E) .long %r_disp32(B), E - B +#else +# define FDE_RANGE(B, E) .align 8; .xword B, E - B +#endif + + .align 8 +.LCIE: + .long .LECIE - .LSCIE ! CIE Length +.LSCIE: + .long 0 ! CIE Identifier Tag + .byte 1 ! CIE Version + .ascii "zR\0" ! CIE Augmentation + .byte 4 ! CIE Code Alignment Factor + .byte 0x78 ! CIE Data Alignment Factor + .byte 15 ! CIE RA Column + .byte 1 ! Augmentation size +#ifdef HAVE_AS_SPARC_UA_PCREL + .byte 0x1b ! FDE Encoding (pcrel sdata4) +#else + .byte 0x50 ! FDE Encoding (aligned absolute) +#endif + .byte 0xc, 14, 0xff, 0xf ! DW_CFA_def_cfa, %o6, offset 0x7ff + .align 8 +.LECIE: + + .long .LEFDE1 - .LSFDE1 ! FDE Length +.LSFDE1: + .long .LSFDE1 - .LCIE ! FDE CIE offset + FDE_RANGE(.LUW0, .LUW2) + .byte 0 ! Augmentation size + .byte 0x40+1 ! DW_CFA_advance_loc 4 + .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 + .byte 0x2d ! DW_CFA_GNU_window_save + .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 + .align 8 +.LEFDE1: + + .long .LEFDE2 - .LSFDE2 ! FDE Length +.LSFDE2: + .long .LSFDE2 - .LCIE ! FDE CIE offset + FDE_RANGE(.LUW3, .LUW5) + .byte 0 ! Augmentation size + .byte 0x40+1 ! DW_CFA_advance_loc 4 + .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 + .byte 0x2d ! DW_CFA_GNU_window_save + .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 + .align 8 +.LEFDE2: + + .long .LEFDE3 - .LSFDE3 ! FDE Length +.LSFDE3: + .long .LSFDE3 - .LCIE ! FDE CIE offset + FDE_RANGE(.LUW6, .LUW8) + .byte 0 ! Augmentation size + .byte 0x40+1 ! DW_CFA_advance_loc 4 + .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 + .byte 0x2d ! DW_CFA_GNU_window_save + .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 + .align 8 +.LEFDE3: + +#endif /* SPARC64 */ +#ifdef __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/tile/ffi.c b/user/mpy/lib/libffi/src/tile/ffi.c new file mode 100644 index 0000000..3a94469 --- /dev/null +++ b/user/mpy/lib/libffi/src/tile/ffi.c @@ -0,0 +1,355 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2012 Tilera Corp. + + TILE Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* The first 10 registers are used to pass arguments and return values. */ +#define NUM_ARG_REGS 10 + +/* Performs a raw function call with the given NUM_ARG_REGS register arguments + and the specified additional stack arguments (if any). */ +extern void ffi_call_tile(ffi_sarg reg_args[NUM_ARG_REGS], + const ffi_sarg *stack_args, + size_t stack_args_bytes, + void (*fnaddr)(void)) + FFI_HIDDEN; + +/* This handles the raw call from the closure stub, cleaning up the + parameters and delegating to ffi_closure_tile_inner. */ +extern void ffi_closure_tile(void) FFI_HIDDEN; + + +ffi_status +ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* We always allocate room for all registers. Even if we don't + use them as parameters, they get returned in the same array + as struct return values so we need to make room. */ + if (cif->bytes < NUM_ARG_REGS * FFI_SIZEOF_ARG) + cif->bytes = NUM_ARG_REGS * FFI_SIZEOF_ARG; + + if (cif->rtype->size > NUM_ARG_REGS * FFI_SIZEOF_ARG) + cif->flags = FFI_TYPE_STRUCT; + else + cif->flags = FFI_TYPE_INT; + + /* Nothing to do. */ + return FFI_OK; +} + + +static long +assign_to_ffi_arg(ffi_sarg *out, void *in, const ffi_type *type, + int write_to_reg) +{ + switch (type->type) + { + case FFI_TYPE_SINT8: + *out = *(SINT8 *)in; + return 1; + + case FFI_TYPE_UINT8: + *out = *(UINT8 *)in; + return 1; + + case FFI_TYPE_SINT16: + *out = *(SINT16 *)in; + return 1; + + case FFI_TYPE_UINT16: + *out = *(UINT16 *)in; + return 1; + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: +#ifndef __LP64__ + case FFI_TYPE_POINTER: +#endif + /* Note that even unsigned 32-bit quantities are sign extended + on tilegx when stored in a register. */ + *out = *(SINT32 *)in; + return 1; + + case FFI_TYPE_FLOAT: +#ifdef __tilegx__ + if (write_to_reg) + { + /* Properly sign extend the value. */ + union { float f; SINT32 s32; } val; + val.f = *(float *)in; + *out = val.s32; + } + else +#endif + { + *(float *)out = *(float *)in; + } + return 1; + + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + case FFI_TYPE_DOUBLE: +#ifdef __LP64__ + case FFI_TYPE_POINTER: +#endif + *(UINT64 *)out = *(UINT64 *)in; + return sizeof(UINT64) / FFI_SIZEOF_ARG; + + case FFI_TYPE_STRUCT: + memcpy(out, in, type->size); + return (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; + + case FFI_TYPE_VOID: + /* Must be a return type. Nothing to do. */ + return 0; + + default: + FFI_ASSERT(0); + return -1; + } +} + + +void +ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_sarg * const arg_mem = alloca(cif->bytes); + ffi_sarg * const reg_args = arg_mem; + ffi_sarg * const stack_args = ®_args[NUM_ARG_REGS]; + ffi_sarg *argp = arg_mem; + ffi_type ** const arg_types = cif->arg_types; + const long num_args = cif->nargs; + long i; + + if (cif->flags == FFI_TYPE_STRUCT) + { + /* Pass a hidden pointer to the return value. We make sure there + is scratch space for the callee to store the return value even if + our caller doesn't care about it. */ + *argp++ = (intptr_t)(rvalue ? rvalue : alloca(cif->rtype->size)); + + /* No more work needed to return anything. */ + rvalue = NULL; + } + + for (i = 0; i < num_args; i++) + { + ffi_type *type = arg_types[i]; + void * const arg_in = avalue[i]; + ptrdiff_t arg_word = argp - arg_mem; + +#ifndef __tilegx__ + /* Doubleword-aligned values are always in an even-number register + pair, or doubleword-aligned stack slot if out of registers. */ + long align = arg_word & (type->alignment > FFI_SIZEOF_ARG); + argp += align; + arg_word += align; +#endif + + if (type->type == FFI_TYPE_STRUCT) + { + const size_t arg_size_in_words = + (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; + + if (arg_word < NUM_ARG_REGS && + arg_word + arg_size_in_words > NUM_ARG_REGS) + { + /* Args are not allowed to span registers and the stack. */ + argp = stack_args; + } + + memcpy(argp, arg_in, type->size); + argp += arg_size_in_words; + } + else + { + argp += assign_to_ffi_arg(argp, arg_in, arg_types[i], 1); + } + } + + /* Actually do the call. */ + ffi_call_tile(reg_args, stack_args, + cif->bytes - (NUM_ARG_REGS * FFI_SIZEOF_ARG), fn); + + if (rvalue != NULL) + assign_to_ffi_arg(rvalue, reg_args, cif->rtype, 0); +} + + +/* Template code for closure. */ +extern const UINT64 ffi_template_tramp_tile[] FFI_HIDDEN; + + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, + ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ +#ifdef __tilegx__ + /* TILE-Gx */ + SINT64 c; + SINT64 h; + int s; + UINT64 *out; + + if (cif->abi != FFI_UNIX) + return FFI_BAD_ABI; + + out = (UINT64 *)closure->tramp; + + c = (intptr_t)closure; + h = (intptr_t)ffi_closure_tile; + s = 0; + + /* Find the smallest shift count that doesn't lose information + (i.e. no need to explicitly insert high bits of the address that + are just the sign extension of the low bits). */ + while ((c >> s) != (SINT16)(c >> s) || (h >> s) != (SINT16)(h >> s)) + s += 16; + +#define OPS(a, b, shift) \ + (create_Imm16_X0((a) >> (shift)) | create_Imm16_X1((b) >> (shift))) + + /* Emit the moveli. */ + *out++ = ffi_template_tramp_tile[0] | OPS(c, h, s); + for (s -= 16; s >= 0; s -= 16) + *out++ = ffi_template_tramp_tile[1] | OPS(c, h, s); + +#undef OPS + + *out++ = ffi_template_tramp_tile[2]; + +#else + /* TILEPro */ + UINT64 *out; + intptr_t delta; + + if (cif->abi != FFI_UNIX) + return FFI_BAD_ABI; + + out = (UINT64 *)closure->tramp; + delta = (intptr_t)ffi_closure_tile - (intptr_t)codeloc; + + *out++ = ffi_template_tramp_tile[0] | create_JOffLong_X1(delta >> 3); +#endif + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + invalidate_icache(closure->tramp, (char *)out - closure->tramp, + getpagesize()); + + return FFI_OK; +} + + +/* This is called by the assembly wrapper for closures. This does + all of the work. On entry reg_args[0] holds the values the registers + had when the closure was invoked. On return reg_args[1] holds the register + values to be returned to the caller (many of which may be garbage). */ +void FFI_HIDDEN +ffi_closure_tile_inner(ffi_closure *closure, + ffi_sarg reg_args[2][NUM_ARG_REGS], + ffi_sarg *stack_args) +{ + ffi_cif * const cif = closure->cif; + void ** const avalue = alloca(cif->nargs * sizeof(void *)); + void *rvalue; + ffi_type ** const arg_types = cif->arg_types; + ffi_sarg * const reg_args_in = reg_args[0]; + ffi_sarg * const reg_args_out = reg_args[1]; + ffi_sarg * argp; + long i, arg_word, nargs = cif->nargs; + /* Use a union to guarantee proper alignment for double. */ + union { ffi_sarg arg[NUM_ARG_REGS]; double d; UINT64 u64; } closure_ret; + + /* Start out reading register arguments. */ + argp = reg_args_in; + + /* Copy the caller's structure return address to that the closure + returns the data directly to the caller. */ + if (cif->flags == FFI_TYPE_STRUCT) + { + /* Return by reference via hidden pointer. */ + rvalue = (void *)(intptr_t)*argp++; + arg_word = 1; + } + else + { + /* Return the value in registers. */ + rvalue = &closure_ret; + arg_word = 0; + } + + /* Grab the addresses of the arguments. */ + for (i = 0; i < nargs; i++) + { + ffi_type * const type = arg_types[i]; + const size_t arg_size_in_words = + (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; + +#ifndef __tilegx__ + /* Doubleword-aligned values are always in an even-number register + pair, or doubleword-aligned stack slot if out of registers. */ + long align = arg_word & (type->alignment > FFI_SIZEOF_ARG); + argp += align; + arg_word += align; +#endif + + if (arg_word == NUM_ARG_REGS || + (arg_word < NUM_ARG_REGS && + arg_word + arg_size_in_words > NUM_ARG_REGS)) + { + /* Switch to reading arguments from the stack. */ + argp = stack_args; + arg_word = NUM_ARG_REGS; + } + + avalue[i] = argp; + argp += arg_size_in_words; + arg_word += arg_size_in_words; + } + + /* Invoke the closure. */ + closure->fun(cif, rvalue, avalue, closure->user_data); + + if (cif->flags != FFI_TYPE_STRUCT) + { + /* Canonicalize for register representation. */ + assign_to_ffi_arg(reg_args_out, &closure_ret, cif->rtype, 1); + } +} diff --git a/user/mpy/lib/libffi/src/tile/ffitarget.h b/user/mpy/lib/libffi/src/tile/ffitarget.h new file mode 100644 index 0000000..679fb5d --- /dev/null +++ b/user/mpy/lib/libffi/src/tile/ffitarget.h @@ -0,0 +1,65 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Tilera Corp. + Target configuration macros for TILE. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM + +#include + +typedef uint_reg_t ffi_arg; +typedef int_reg_t ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_UNIX, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_UNIX +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ +#define FFI_CLOSURES 1 + +#ifdef __tilegx__ +/* We always pass 8-byte values, even in -m32 mode. */ +# define FFI_SIZEOF_ARG 8 +# ifdef __LP64__ +# define FFI_TRAMPOLINE_SIZE (8 * 5) /* 5 bundles */ +# else +# define FFI_TRAMPOLINE_SIZE (8 * 3) /* 3 bundles */ +# endif +#else +# define FFI_SIZEOF_ARG 4 +# define FFI_TRAMPOLINE_SIZE 8 /* 1 bundle */ +#endif +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/tile/tile.S b/user/mpy/lib/libffi/src/tile/tile.S new file mode 100644 index 0000000..d1f82cb --- /dev/null +++ b/user/mpy/lib/libffi/src/tile/tile.S @@ -0,0 +1,360 @@ +/* ----------------------------------------------------------------------- + tile.S - Copyright (c) 2011 Tilera Corp. + + Tilera TILEPro and TILE-Gx Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +/* Number of bytes in a register. */ +#define REG_SIZE FFI_SIZEOF_ARG + +/* Number of bytes in stack linkage area for backtracing. + + A note about the ABI: on entry to a procedure, sp points to a stack + slot where it must spill the return address if it's not a leaf. + REG_SIZE bytes beyond that is a slot owned by the caller which + contains the sp value that the caller had when it was originally + entered (i.e. the caller's frame pointer). */ +#define LINKAGE_SIZE (2 * REG_SIZE) + +/* The first 10 registers are used to pass arguments and return values. */ +#define NUM_ARG_REGS 10 + +#ifdef __tilegx__ +#define SW st +#define LW ld +#define BGZT bgtzt +#else +#define SW sw +#define LW lw +#define BGZT bgzt +#endif + + +/* void ffi_call_tile (int_reg_t reg_args[NUM_ARG_REGS], + const int_reg_t *stack_args, + unsigned long stack_args_bytes, + void (*fnaddr)(void)); + + On entry, REG_ARGS contain the outgoing register values, + and STACK_ARGS contains STACK_ARG_BYTES of additional values + to be passed on the stack. If STACK_ARG_BYTES is zero, then + STACK_ARGS is ignored. + + When the invoked function returns, the values of r0-r9 are + blindly stored back into REG_ARGS for the caller to examine. */ + + .section .text.ffi_call_tile, "ax", @progbits + .align 8 + .globl ffi_call_tile + FFI_HIDDEN(ffi_call_tile) +ffi_call_tile: + +/* Incoming arguments. */ +#define REG_ARGS r0 +#define INCOMING_STACK_ARGS r1 +#define STACK_ARG_BYTES r2 +#define ORIG_FNADDR r3 + +/* Temporary values. */ +#define FRAME_SIZE r10 +#define TMP r11 +#define TMP2 r12 +#define OUTGOING_STACK_ARGS r13 +#define REG_ADDR_PTR r14 +#define RETURN_REG_ADDR r15 +#define FNADDR r16 + + .cfi_startproc + { + /* Save return address. */ + SW sp, lr + .cfi_offset lr, 0 + /* Prepare to spill incoming r52. */ + addi TMP, sp, -REG_SIZE + /* Increase frame size to have room to spill r52 and REG_ARGS. + The +7 is to round up mod 8. */ + addi FRAME_SIZE, STACK_ARG_BYTES, \ + REG_SIZE + REG_SIZE + LINKAGE_SIZE + 7 + } + { + /* Round stack frame size to a multiple of 8 to satisfy ABI. */ + andi FRAME_SIZE, FRAME_SIZE, -8 + /* Compute where to spill REG_ARGS value. */ + addi TMP2, sp, -(REG_SIZE * 2) + } + { + /* Spill incoming r52. */ + SW TMP, r52 + .cfi_offset r52, -REG_SIZE + /* Set up our frame pointer. */ + move r52, sp + .cfi_def_cfa_register r52 + /* Push stack frame. */ + sub sp, sp, FRAME_SIZE + } + { + /* Prepare to set up stack linkage. */ + addi TMP, sp, REG_SIZE + /* Prepare to memcpy stack args. */ + addi OUTGOING_STACK_ARGS, sp, LINKAGE_SIZE + /* Save REG_ARGS which we will need after we call the subroutine. */ + SW TMP2, REG_ARGS + } + { + /* Set up linkage info to hold incoming stack pointer. */ + SW TMP, r52 + } + { + /* Skip stack args memcpy if we don't have any stack args (common). */ + blezt STACK_ARG_BYTES, .Ldone_stack_args_memcpy + } + +.Lmemcpy_stack_args: + { + /* Load incoming argument from stack_args. */ + LW TMP, INCOMING_STACK_ARGS + addi INCOMING_STACK_ARGS, INCOMING_STACK_ARGS, REG_SIZE + } + { + /* Store stack argument into outgoing stack argument area. */ + SW OUTGOING_STACK_ARGS, TMP + addi OUTGOING_STACK_ARGS, OUTGOING_STACK_ARGS, REG_SIZE + addi STACK_ARG_BYTES, STACK_ARG_BYTES, -REG_SIZE + } + { + BGZT STACK_ARG_BYTES, .Lmemcpy_stack_args + } +.Ldone_stack_args_memcpy: + + { + /* Copy aside ORIG_FNADDR so we can overwrite its register. */ + move FNADDR, ORIG_FNADDR + /* Prepare to load argument registers. */ + addi REG_ADDR_PTR, r0, REG_SIZE + /* Load outgoing r0. */ + LW r0, r0 + } + + /* Load up argument registers from the REG_ARGS array. */ +#define LOAD_REG(REG, PTR) \ + { \ + LW REG, PTR ; \ + addi PTR, PTR, REG_SIZE \ + } + + LOAD_REG(r1, REG_ADDR_PTR) + LOAD_REG(r2, REG_ADDR_PTR) + LOAD_REG(r3, REG_ADDR_PTR) + LOAD_REG(r4, REG_ADDR_PTR) + LOAD_REG(r5, REG_ADDR_PTR) + LOAD_REG(r6, REG_ADDR_PTR) + LOAD_REG(r7, REG_ADDR_PTR) + LOAD_REG(r8, REG_ADDR_PTR) + LOAD_REG(r9, REG_ADDR_PTR) + + { + /* Call the subroutine. */ + jalr FNADDR + } + + { + /* Restore original lr. */ + LW lr, r52 + /* Prepare to recover ARGS, which we spilled earlier. */ + addi TMP, r52, -(2 * REG_SIZE) + } + { + /* Restore ARGS, so we can fill it in with the return regs r0-r9. */ + LW RETURN_REG_ADDR, TMP + /* Prepare to restore original r52. */ + addi TMP, r52, -REG_SIZE + } + + { + /* Pop stack frame. */ + move sp, r52 + /* Restore original r52. */ + LW r52, TMP + } + +#define STORE_REG(REG, PTR) \ + { \ + SW PTR, REG ; \ + addi PTR, PTR, REG_SIZE \ + } + + /* Return all register values by reference. */ + STORE_REG(r0, RETURN_REG_ADDR) + STORE_REG(r1, RETURN_REG_ADDR) + STORE_REG(r2, RETURN_REG_ADDR) + STORE_REG(r3, RETURN_REG_ADDR) + STORE_REG(r4, RETURN_REG_ADDR) + STORE_REG(r5, RETURN_REG_ADDR) + STORE_REG(r6, RETURN_REG_ADDR) + STORE_REG(r7, RETURN_REG_ADDR) + STORE_REG(r8, RETURN_REG_ADDR) + STORE_REG(r9, RETURN_REG_ADDR) + + { + jrp lr + } + + .cfi_endproc + .size ffi_call_tile, .-ffi_call_tile + +/* ffi_closure_tile(...) + + On entry, lr points to the closure plus 8 bytes, and r10 + contains the actual return address. + + This function simply dumps all register parameters into a stack array + and passes the closure, the registers array, and the stack arguments + to C code that does all of the actual closure processing. */ + + .section .text.ffi_closure_tile, "ax", @progbits + .align 8 + .globl ffi_closure_tile + FFI_HIDDEN(ffi_closure_tile) + + .cfi_startproc +/* Room to spill all NUM_ARG_REGS incoming registers, plus frame linkage. */ +#define CLOSURE_FRAME_SIZE (((NUM_ARG_REGS * REG_SIZE * 2 + LINKAGE_SIZE) + 7) & -8) +ffi_closure_tile: + { +#ifdef __tilegx__ + st sp, lr + .cfi_offset lr, 0 +#else + /* Save return address (in r10 due to closure stub wrapper). */ + SW sp, r10 + .cfi_return_column r10 + .cfi_offset r10, 0 +#endif + /* Compute address for stack frame linkage. */ + addli r10, sp, -(CLOSURE_FRAME_SIZE - REG_SIZE) + } + { + /* Save incoming stack pointer in linkage area. */ + SW r10, sp + .cfi_offset sp, -(CLOSURE_FRAME_SIZE - REG_SIZE) + /* Push a new stack frame. */ + addli sp, sp, -CLOSURE_FRAME_SIZE + .cfi_adjust_cfa_offset CLOSURE_FRAME_SIZE + } + + { + /* Create pointer to where to start spilling registers. */ + addi r10, sp, LINKAGE_SIZE + } + + /* Spill all the incoming registers. */ + STORE_REG(r0, r10) + STORE_REG(r1, r10) + STORE_REG(r2, r10) + STORE_REG(r3, r10) + STORE_REG(r4, r10) + STORE_REG(r5, r10) + STORE_REG(r6, r10) + STORE_REG(r7, r10) + STORE_REG(r8, r10) + { + /* Save r9. */ + SW r10, r9 +#ifdef __tilegx__ + /* Pointer to closure is passed in r11. */ + move r0, r11 +#else + /* Compute pointer to the closure object. Because the closure + starts with a "jal ffi_closure_tile", we can just take the + value of lr (a phony return address pointing into the closure) + and subtract 8. */ + addi r0, lr, -8 +#endif + /* Compute a pointer to the register arguments we just spilled. */ + addi r1, sp, LINKAGE_SIZE + } + { + /* Compute a pointer to the extra stack arguments (if any). */ + addli r2, sp, CLOSURE_FRAME_SIZE + LINKAGE_SIZE + /* Call C code to deal with all of the grotty details. */ + jal ffi_closure_tile_inner + } + { + addli r10, sp, CLOSURE_FRAME_SIZE + } + { + /* Restore the return address. */ + LW lr, r10 + /* Compute pointer to registers array. */ + addli r10, sp, LINKAGE_SIZE + (NUM_ARG_REGS * REG_SIZE) + } + /* Return all the register values, which C code may have set. */ + LOAD_REG(r0, r10) + LOAD_REG(r1, r10) + LOAD_REG(r2, r10) + LOAD_REG(r3, r10) + LOAD_REG(r4, r10) + LOAD_REG(r5, r10) + LOAD_REG(r6, r10) + LOAD_REG(r7, r10) + LOAD_REG(r8, r10) + LOAD_REG(r9, r10) + { + /* Pop the frame. */ + addli sp, sp, CLOSURE_FRAME_SIZE + jrp lr + } + + .cfi_endproc + .size ffi_closure_tile, . - ffi_closure_tile + + +/* What follows are code template instructions that get copied to the + closure trampoline by ffi_prep_closure_loc. The zeroed operands + get replaced by their proper values at runtime. */ + + .section .text.ffi_template_tramp_tile, "ax", @progbits + .align 8 + .globl ffi_template_tramp_tile + FFI_HIDDEN(ffi_template_tramp_tile) +ffi_template_tramp_tile: +#ifdef __tilegx__ + { + moveli r11, 0 /* backpatched to address of containing closure. */ + moveli r10, 0 /* backpatched to ffi_closure_tile. */ + } + /* Note: the following bundle gets generated multiple times + depending on the pointer value (esp. useful for -m32 mode). */ + { shl16insli r11, r11, 0 ; shl16insli r10, r10, 0 } + { info 2+8 /* for backtracer: -> pc in lr, frame size 0 */ ; jr r10 } +#else + /* 'jal .' yields a PC-relative offset of zero so we can OR in the + right offset at runtime. */ + { move r10, lr ; jal . /* ffi_closure_tile */ } +#endif + + .size ffi_template_tramp_tile, . - ffi_template_tramp_tile diff --git a/user/mpy/lib/libffi/src/types.c b/user/mpy/lib/libffi/src/types.c new file mode 100644 index 0000000..7e80aec --- /dev/null +++ b/user/mpy/lib/libffi/src/types.c @@ -0,0 +1,106 @@ +/* ----------------------------------------------------------------------- + types.c - Copyright (c) 1996, 1998 Red Hat, Inc. + + Predefined ffi_types needed by libffi. + + 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. + ----------------------------------------------------------------------- */ + +/* Hide the basic type definitions from the header file, so that we + can redefine them here as "const". */ +#define LIBFFI_HIDE_BASIC_TYPES + +#include +#include + +/* Type definitions */ + +#define FFI_TYPEDEF(name, type, id, maybe_const)\ +struct struct_align_##name { \ + char c; \ + type x; \ +}; \ +maybe_const ffi_type ffi_type_##name = { \ + sizeof(type), \ + offsetof(struct struct_align_##name, x), \ + id, NULL \ +} + +#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \ +static ffi_type *ffi_elements_complex_##name [2] = { \ + (ffi_type *)(&ffi_type_##name), NULL \ +}; \ +struct struct_align_complex_##name { \ + char c; \ + _Complex type x; \ +}; \ +maybe_const ffi_type ffi_type_complex_##name = { \ + sizeof(_Complex type), \ + offsetof(struct struct_align_complex_##name, x), \ + FFI_TYPE_COMPLEX, \ + (ffi_type **)ffi_elements_complex_##name \ +} + +/* Size and alignment are fake here. They must not be 0. */ +const ffi_type ffi_type_void = { + 1, 1, FFI_TYPE_VOID, NULL +}; + +FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8, const); +FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8, const); +FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16, const); +FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16, const); +FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32, const); +FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32, const); +FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64, const); +FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64, const); + +FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER, const); + +FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT, const); +FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE, const); + +#if !defined HAVE_LONG_DOUBLE_VARIANT || defined __alpha__ +#define FFI_LDBL_CONST const +#else +#define FFI_LDBL_CONST +#endif + +#ifdef __alpha__ +/* Even if we're not configured to default to 128-bit long double, + maintain binary compatibility, as -mlong-double-128 can be used + at any time. */ +/* Validate the hard-coded number below. */ +# if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4 +# error FFI_TYPE_LONGDOUBLE out of date +# endif +const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL }; +#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST); +#endif + +#ifdef FFI_TARGET_HAS_COMPLEX_TYPE +FFI_COMPLEX_TYPEDEF(float, float, const); +FFI_COMPLEX_TYPEDEF(double, double, const); +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST); +#endif +#endif diff --git a/user/mpy/lib/libffi/src/vax/elfbsd.S b/user/mpy/lib/libffi/src/vax/elfbsd.S new file mode 100644 index 0000000..01ca313 --- /dev/null +++ b/user/mpy/lib/libffi/src/vax/elfbsd.S @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * 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. + */ + +/* + * vax Foreign Function Interface + */ + +#define LIBFFI_ASM +#include +#include + + .text + +/* + * void * %r0 + * ffi_call_elfbsd(extended_cif *ecif, 4(%ap) + * unsigned bytes, 8(%ap) + * unsigned flags, 12(%ap) + * void *rvalue, 16(%ap) + * void (*fn)()); 20(%ap) + */ + .globl ffi_call_elfbsd + .type ffi_call_elfbsd,@function + .align 2 +ffi_call_elfbsd: + .word 0x00c # save R2 and R3 + + # Allocate stack space for the args + subl2 8(%ap), %sp + + # Call ffi_prep_args + pushl %sp + pushl 4(%ap) + calls $2, ffi_prep_args + + # Get function pointer + movl 20(%ap), %r1 + + # Build a CALLS frame + ashl $-2, 8(%ap), %r0 + pushl %r0 # argument stack usage + movl %sp, %r0 # future %ap + # saved registers + bbc $11, 0(%r1), 1f + pushl %r11 +1: bbc $10, 0(%r1), 1f + pushl %r10 +1: bbc $9, 0(%r1), 1f + pushl %r9 +1: bbc $8, 0(%r1), 1f + pushl %r8 +1: bbc $7, 0(%r1), 1f + pushl %r7 +1: bbc $6, 0(%r1), 1f + pushl %r6 +1: bbc $5, 0(%r1), 1f + pushl %r5 +1: bbc $4, 0(%r1), 1f + pushl %r4 +1: bbc $3, 0(%r1), 1f + pushl %r3 +1: bbc $2, 0(%r1), 1f + pushl %r2 +1: + pushal 9f + pushl %fp + pushl %ap + movl 16(%ap), %r3 # struct return address, if needed + movl %r0, %ap + movzwl 4(%fp), %r0 # previous PSW, without the saved registers mask + bisl2 $0x20000000, %r0 # calls frame + movzwl 0(%r1), %r2 + bicw2 $0xf003, %r2 # only keep R11-R2 + ashl $16, %r2, %r2 + bisl2 %r2, %r0 # saved register mask of the called function + pushl %r0 + pushl $0 + movl %sp, %fp + + # Invoke the function + pushal 2(%r1) # skip procedure entry mask + movl %r3, %r1 + bicpsw $0x000f + rsb + +9: + # Copy return value if necessary + tstl 16(%ap) + jeql 9f + movl 16(%ap), %r2 + + bbc $0, 12(%ap), 1f # CIF_FLAGS_CHAR + movb %r0, 0(%r2) + brb 9f +1: + bbc $1, 12(%ap), 1f # CIF_FLAGS_SHORT + movw %r0, 0(%r2) + brb 9f +1: + bbc $2, 12(%ap), 1f # CIF_FLAGS_INT + movl %r0, 0(%r2) + brb 9f +1: + bbc $3, 12(%ap), 1f # CIF_FLAGS_DINT + movq %r0, 0(%r2) + brb 9f +1: + movl %r1, %r0 # might have been a struct + #brb 9f + +9: + ret + +/* + * ffi_closure_elfbsd(void); + * invoked with %r0: ffi_closure *closure + */ + .globl ffi_closure_elfbsd + .type ffi_closure_elfbsd, @function + .align 2 +ffi_closure_elfbsd: + .word 0 + + # Allocate room on stack for return value + subl2 $8, %sp + + # Invoke the closure function + pushal 4(%ap) # calling stack + pushal 4(%sp) # return value + pushl %r0 # closure + calls $3, ffi_closure_elfbsd_inner + + # Copy return value if necessary + bitb $1, %r0 # CIF_FLAGS_CHAR + beql 1f + movb 0(%sp), %r0 + brb 9f +1: + bitb $2, %r0 # CIF_FLAGS_SHORT + beql 1f + movw 0(%sp), %r0 + brb 9f +1: + bitb $4, %r0 # CIF_FLAGS_INT + beql 1f + movl 0(%sp), %r0 + brb 9f +1: + bitb $8, %r0 # CIF_FLAGS_DINT + beql 1f + movq 0(%sp), %r0 + #brb 9f +1: + +9: + ret + +/* + * ffi_closure_struct_elfbsd(void); + * invoked with %r0: ffi_closure *closure + * %r1: struct return address + */ + .globl ffi_closure_struct_elfbsd + .type ffi_closure_struct_elfbsd, @function + .align 2 +ffi_closure_struct_elfbsd: + .word 0 + + # Invoke the closure function + pushal 4(%ap) # calling stack + pushl %r1 # return value + pushl %r0 # closure + calls $3, ffi_closure_elfbsd_inner + + ret diff --git a/user/mpy/lib/libffi/src/vax/ffi.c b/user/mpy/lib/libffi/src/vax/ffi.c new file mode 100644 index 0000000..f4d6bbb --- /dev/null +++ b/user/mpy/lib/libffi/src/vax/ffi.c @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * 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. + */ + +/* + * vax Foreign Function Interface + * + * This file attempts to provide all the FFI entry points which can reliably + * be implemented in C. + */ + +#include +#include + +#include +#include + +#define CIF_FLAGS_CHAR 1 /* for struct only */ +#define CIF_FLAGS_SHORT 2 /* for struct only */ +#define CIF_FLAGS_INT 4 +#define CIF_FLAGS_DINT 8 + +/* + * Foreign Function Interface API + */ + +void ffi_call_elfbsd (extended_cif *, unsigned, unsigned, void *, + void (*) ()); +void *ffi_prep_args (extended_cif *ecif, void *stack); + +void * +ffi_prep_args (extended_cif *ecif, void *stack) +{ + unsigned int i; + void **p_argv; + char *argp; + ffi_type **p_arg; + void *struct_value_ptr; + + argp = stack; + + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT + && !ecif->cif->flags) + struct_value_ptr = ecif->rvalue; + else + struct_value_ptr = NULL; + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + i != 0; + i--, p_arg++) + { + size_t z; + + z = (*p_arg)->size; + if (z < sizeof (int)) + { + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv; + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) *p_argv; + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv; + break; + + case FFI_TYPE_STRUCT: + memcpy (argp, *p_argv, z); + break; + + default: + FFI_ASSERT (0); + } + z = sizeof (int); + } + else + { + memcpy (argp, *p_argv, z); + + /* Align if necessary. */ + if ((sizeof(int) - 1) & z) + z = ALIGN(z, sizeof(int)); + } + + p_argv++; + argp += z; + } + + return struct_value_ptr; +} + +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + cif->flags = 0; + break; + + case FFI_TYPE_STRUCT: + if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT && + cif->rtype->elements[1]) + { + cif->flags = 0; + break; + } + + if (cif->rtype->size == sizeof (char)) + cif->flags = CIF_FLAGS_CHAR; + else if (cif->rtype->size == sizeof (short)) + cif->flags = CIF_FLAGS_SHORT; + else if (cif->rtype->size == sizeof (int)) + cif->flags = CIF_FLAGS_INT; + else if (cif->rtype->size == 2 * sizeof (int)) + cif->flags = CIF_FLAGS_DINT; + else + cif->flags = 0; + break; + + default: + if (cif->rtype->size <= sizeof (int)) + cif->flags = CIF_FLAGS_INT; + else + cif->flags = CIF_FLAGS_DINT; + break; + } + + return FFI_OK; +} + +void +ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return value + address then we need to make one. */ + + if (rvalue == NULL + && cif->rtype->type == FFI_TYPE_STRUCT + && cif->flags == 0) + ecif.rvalue = alloca (cif->rtype->size); + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_ELFBSD: + ffi_call_elfbsd (&ecif, cif->bytes, cif->flags, ecif.rvalue, fn); + break; + + default: + FFI_ASSERT (0); + break; + } +} + +/* + * Closure API + */ + +void ffi_closure_elfbsd (void); +void ffi_closure_struct_elfbsd (void); +unsigned int ffi_closure_elfbsd_inner (ffi_closure *, void *, char *); + +static void +ffi_prep_closure_elfbsd (ffi_cif *cif, void **avalue, char *stackp) +{ + unsigned int i; + void **p_argv; + ffi_type **p_arg; + + p_argv = avalue; + + for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++) + { + size_t z; + + z = (*p_arg)->size; + *p_argv = stackp; + + /* Align if necessary */ + if ((sizeof (int) - 1) & z) + z = ALIGN(z, sizeof (int)); + + p_argv++; + stackp += z; + } +} + +unsigned int +ffi_closure_elfbsd_inner (ffi_closure *closure, void *resp, char *stack) +{ + ffi_cif *cif; + void **arg_area; + + cif = closure->cif; + arg_area = (void **) alloca (cif->nargs * sizeof (void *)); + + ffi_prep_closure_elfbsd (cif, arg_area, stack); + + (closure->fun) (cif, resp, arg_area, closure->user_data); + + return cif->flags; +} + +ffi_status +ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif, + void (*fun)(ffi_cif *, void *, void **, void *), + void *user_data, void *codeloc) +{ + char *tramp = (char *) codeloc; + void *fn; + + FFI_ASSERT (cif->abi == FFI_ELFBSD); + + /* entry mask */ + *(unsigned short *)(tramp + 0) = 0x0000; + /* movl #closure, r0 */ + tramp[2] = 0xd0; + tramp[3] = 0x8f; + *(unsigned int *)(tramp + 4) = (unsigned int) closure; + tramp[8] = 0x50; + + if (cif->rtype->type == FFI_TYPE_STRUCT + && !cif->flags) + fn = &ffi_closure_struct_elfbsd; + else + fn = &ffi_closure_elfbsd; + + /* jmpl #fn */ + tramp[9] = 0x17; + tramp[10] = 0xef; + *(unsigned int *)(tramp + 11) = (unsigned int)fn + 2 - + (unsigned int)tramp - 9 - 6; + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} diff --git a/user/mpy/lib/libffi/src/vax/ffitarget.h b/user/mpy/lib/libffi/src/vax/ffitarget.h new file mode 100644 index 0000000..2fc9488 --- /dev/null +++ b/user/mpy/lib/libffi/src/vax/ffitarget.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * 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. + */ + +/* + * vax Foreign Function Interface + */ + +#ifndef LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_ELFBSD, + FFI_DEFAULT_ABI = FFI_ELFBSD, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 15 +#define FFI_NATIVE_RAW_API 0 + +#endif diff --git a/user/mpy/lib/libffi/src/x86/ffi.c b/user/mpy/lib/libffi/src/x86/ffi.c new file mode 100644 index 0000000..feb5cbb --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/ffi.c @@ -0,0 +1,729 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc. + Copyright (c) 2002 Ranjit Mathew + Copyright (c) 2002 Bo Thorsen + Copyright (c) 2002 Roger Sayle + Copyright (C) 2008, 2010 Free Software Foundation, Inc. + + x86 Foreign Function Interface + + 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 __x86_64__ +#include +#include +#include +#include "internal.h" + +/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; + all further uses in this file will refer to the 80-bit type. */ +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE +# if FFI_TYPE_LONGDOUBLE != 4 +# error FFI_TYPE_LONGDOUBLE out of date +# endif +#else +# undef FFI_TYPE_LONGDOUBLE +# define FFI_TYPE_LONGDOUBLE 4 +#endif + +#if defined(__GNUC__) && !defined(__declspec) +# define __declspec(x) __attribute__((x)) +#endif + +/* Perform machine dependent cif processing. */ +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep(ffi_cif *cif) +{ + size_t bytes = 0; + int i, n, flags, cabi = cif->abi; + + switch (cabi) + { + case FFI_SYSV: + case FFI_STDCALL: + case FFI_THISCALL: + case FFI_FASTCALL: + case FFI_MS_CDECL: + case FFI_PASCAL: + case FFI_REGISTER: + break; + default: + return FFI_BAD_ABI; + } + + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + flags = X86_RET_VOID; + break; + case FFI_TYPE_FLOAT: + flags = X86_RET_FLOAT; + break; + case FFI_TYPE_DOUBLE: + flags = X86_RET_DOUBLE; + break; + case FFI_TYPE_LONGDOUBLE: + flags = X86_RET_LDOUBLE; + break; + case FFI_TYPE_UINT8: + flags = X86_RET_UINT8; + break; + case FFI_TYPE_UINT16: + flags = X86_RET_UINT16; + break; + case FFI_TYPE_SINT8: + flags = X86_RET_SINT8; + break; + case FFI_TYPE_SINT16: + flags = X86_RET_SINT16; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + flags = X86_RET_INT32; + break; + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + flags = X86_RET_INT64; + break; + case FFI_TYPE_STRUCT: +#ifndef X86 + /* ??? This should be a different ABI rather than an ifdef. */ + if (cif->rtype->size == 1) + flags = X86_RET_STRUCT_1B; + else if (cif->rtype->size == 2) + flags = X86_RET_STRUCT_2B; + else if (cif->rtype->size == 4) + flags = X86_RET_INT32; + else if (cif->rtype->size == 8) + flags = X86_RET_INT64; + else +#endif + { + do_struct: + switch (cabi) + { + case FFI_THISCALL: + case FFI_FASTCALL: + case FFI_STDCALL: + case FFI_MS_CDECL: + flags = X86_RET_STRUCTARG; + break; + default: + flags = X86_RET_STRUCTPOP; + break; + } + /* Allocate space for return value pointer. */ + bytes += ALIGN (sizeof(void*), FFI_SIZEOF_ARG); + } + break; + case FFI_TYPE_COMPLEX: + switch (cif->rtype->elements[0]->type) + { + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + goto do_struct; + case FFI_TYPE_FLOAT: + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + flags = X86_RET_INT64; + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + flags = X86_RET_INT32; + break; + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + flags = X86_RET_STRUCT_2B; + break; + default: + return FFI_BAD_TYPEDEF; + } + break; + default: + return FFI_BAD_TYPEDEF; + } + cif->flags = flags; + + for (i = 0, n = cif->nargs; i < n; i++) + { + ffi_type *t = cif->arg_types[i]; + + bytes = ALIGN (bytes, t->alignment); + bytes += ALIGN (t->size, FFI_SIZEOF_ARG); + } + cif->bytes = ALIGN (bytes, 16); + + return FFI_OK; +} + +static ffi_arg +extend_basic_type(void *arg, int type) +{ + switch (type) + { + case FFI_TYPE_SINT8: + return *(SINT8 *)arg; + case FFI_TYPE_UINT8: + return *(UINT8 *)arg; + case FFI_TYPE_SINT16: + return *(SINT16 *)arg; + case FFI_TYPE_UINT16: + return *(UINT16 *)arg; + + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_POINTER: + case FFI_TYPE_FLOAT: + return *(UINT32 *)arg; + + default: + abort(); + } +} + +struct call_frame +{ + void *ebp; /* 0 */ + void *retaddr; /* 4 */ + void (*fn)(void); /* 8 */ + int flags; /* 12 */ + void *rvalue; /* 16 */ + unsigned regs[3]; /* 20-28 */ +}; + +struct abi_params +{ + int dir; /* parameter growth direction */ + int static_chain; /* the static chain register used by gcc */ + int nregs; /* number of register parameters */ + int regs[3]; +}; + +static const struct abi_params abi_params[FFI_LAST_ABI] = { + [FFI_SYSV] = { 1, R_ECX, 0 }, + [FFI_THISCALL] = { 1, R_EAX, 1, { R_ECX } }, + [FFI_FASTCALL] = { 1, R_EAX, 2, { R_ECX, R_EDX } }, + [FFI_STDCALL] = { 1, R_ECX, 0 }, + [FFI_PASCAL] = { -1, R_ECX, 0 }, + /* ??? No defined static chain; gcc does not support REGISTER. */ + [FFI_REGISTER] = { -1, R_ECX, 3, { R_EAX, R_EDX, R_ECX } }, + [FFI_MS_CDECL] = { 1, R_ECX, 0 } +}; + +extern void ffi_call_i386(struct call_frame *, char *) +#if HAVE_FASTCALL + __declspec(fastcall) +#endif + FFI_HIDDEN; + +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + size_t rsize, bytes; + struct call_frame *frame; + char *stack, *argp; + ffi_type **arg_types; + int flags, cabi, i, n, dir, narg_reg; + const struct abi_params *pabi; + + flags = cif->flags; + cabi = cif->abi; + pabi = &abi_params[cabi]; + dir = pabi->dir; + + rsize = 0; + if (rvalue == NULL) + { + switch (flags) + { + case X86_RET_FLOAT: + case X86_RET_DOUBLE: + case X86_RET_LDOUBLE: + case X86_RET_STRUCTPOP: + case X86_RET_STRUCTARG: + /* The float cases need to pop the 387 stack. + The struct cases need to pass a valid pointer to the callee. */ + rsize = cif->rtype->size; + break; + default: + /* We can pretend that the callee returns nothing. */ + flags = X86_RET_VOID; + break; + } + } + + bytes = cif->bytes; + stack = alloca(bytes + sizeof(*frame) + rsize); + argp = (dir < 0 ? stack + bytes : stack); + frame = (struct call_frame *)(stack + bytes); + if (rsize) + rvalue = frame + 1; + + frame->fn = fn; + frame->flags = flags; + frame->rvalue = rvalue; + frame->regs[pabi->static_chain] = (unsigned)closure; + + narg_reg = 0; + switch (flags) + { + case X86_RET_STRUCTARG: + /* The pointer is passed as the first argument. */ + if (pabi->nregs > 0) + { + frame->regs[pabi->regs[0]] = (unsigned)rvalue; + narg_reg = 1; + break; + } + /* fallthru */ + case X86_RET_STRUCTPOP: + *(void **)argp = rvalue; + argp += sizeof(void *); + break; + } + + arg_types = cif->arg_types; + for (i = 0, n = cif->nargs; i < n; i++) + { + ffi_type *ty = arg_types[i]; + void *valp = avalue[i]; + size_t z = ty->size; + int t = ty->type; + + if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT) + { + ffi_arg val = extend_basic_type (valp, t); + + if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs) + frame->regs[pabi->regs[narg_reg++]] = val; + else if (dir < 0) + { + argp -= 4; + *(ffi_arg *)argp = val; + } + else + { + *(ffi_arg *)argp = val; + argp += 4; + } + } + else + { + size_t za = ALIGN (z, FFI_SIZEOF_ARG); + size_t align = FFI_SIZEOF_ARG; + + /* Alignment rules for arguments are quite complex. Vectors and + structures with 16 byte alignment get it. Note that long double + on Darwin does have 16 byte alignment, and does not get this + alignment if passed directly; a structure with a long double + inside, however, would get 16 byte alignment. Since libffi does + not support vectors, we need non concern ourselves with other + cases. */ + if (t == FFI_TYPE_STRUCT && ty->alignment >= 16) + align = 16; + + if (dir < 0) + { + /* ??? These reverse argument ABIs are probably too old + to have cared about alignment. Someone should check. */ + argp -= za; + memcpy (argp, valp, z); + } + else + { + argp = (char *)ALIGN (argp, align); + memcpy (argp, valp, z); + argp += za; + } + } + } + FFI_ASSERT (dir > 0 || argp == stack); + + ffi_call_i386 (frame, stack); +} + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + +/** private members **/ + +void FFI_HIDDEN ffi_closure_i386(void); +void FFI_HIDDEN ffi_closure_STDCALL(void); +void FFI_HIDDEN ffi_closure_REGISTER(void); + +struct closure_frame +{ + unsigned rettemp[4]; /* 0 */ + unsigned regs[3]; /* 16-24 */ + ffi_cif *cif; /* 28 */ + void (*fun)(ffi_cif*,void*,void**,void*); /* 32 */ + void *user_data; /* 36 */ +}; + +int FFI_HIDDEN +#if HAVE_FASTCALL +__declspec(fastcall) +#endif +ffi_closure_inner (struct closure_frame *frame, char *stack) +{ + ffi_cif *cif = frame->cif; + int cabi, i, n, flags, dir, narg_reg; + const struct abi_params *pabi; + ffi_type **arg_types; + char *argp; + void *rvalue; + void **avalue; + + cabi = cif->abi; + flags = cif->flags; + narg_reg = 0; + rvalue = frame->rettemp; + pabi = &abi_params[cabi]; + dir = pabi->dir; + argp = (dir < 0 ? stack + cif->bytes : stack); + + switch (flags) + { + case X86_RET_STRUCTARG: + if (pabi->nregs > 0) + { + rvalue = (void *)frame->regs[pabi->regs[0]]; + narg_reg = 1; + frame->rettemp[0] = (unsigned)rvalue; + break; + } + /* fallthru */ + case X86_RET_STRUCTPOP: + rvalue = *(void **)argp; + argp += sizeof(void *); + frame->rettemp[0] = (unsigned)rvalue; + break; + } + + n = cif->nargs; + avalue = alloca(sizeof(void *) * n); + + arg_types = cif->arg_types; + for (i = 0; i < n; ++i) + { + ffi_type *ty = arg_types[i]; + size_t z = ty->size; + int t = ty->type; + void *valp; + + if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT) + { + if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs) + valp = &frame->regs[pabi->regs[narg_reg++]]; + else if (dir < 0) + { + argp -= 4; + valp = argp; + } + else + { + valp = argp; + argp += 4; + } + } + else + { + size_t za = ALIGN (z, FFI_SIZEOF_ARG); + size_t align = FFI_SIZEOF_ARG; + + /* See the comment in ffi_call_int. */ + if (t == FFI_TYPE_STRUCT && ty->alignment >= 16) + align = 16; + + if (dir < 0) + { + /* ??? These reverse argument ABIs are probably too old + to have cared about alignment. Someone should check. */ + argp -= za; + valp = argp; + } + else + { + argp = (char *)ALIGN (argp, align); + valp = argp; + argp += za; + } + } + + avalue[i] = valp; + } + + frame->fun (cif, rvalue, avalue, frame->user_data); + + if (cabi == FFI_STDCALL) + return flags + (cif->bytes << X86_RET_POP_SHIFT); + else + return flags; +} + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + char *tramp = closure->tramp; + void (*dest)(void); + int op = 0xb8; /* movl imm, %eax */ + + switch (cif->abi) + { + case FFI_SYSV: + case FFI_THISCALL: + case FFI_FASTCALL: + case FFI_MS_CDECL: + dest = ffi_closure_i386; + break; + case FFI_STDCALL: + case FFI_PASCAL: + dest = ffi_closure_STDCALL; + break; + case FFI_REGISTER: + dest = ffi_closure_REGISTER; + op = 0x68; /* pushl imm */ + default: + return FFI_BAD_ABI; + } + + /* movl or pushl immediate. */ + tramp[0] = op; + *(void **)(tramp + 1) = codeloc; + + /* jmp dest */ + tramp[5] = 0xe9; + *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10); + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +void FFI_HIDDEN ffi_go_closure_EAX(void); +void FFI_HIDDEN ffi_go_closure_ECX(void); +void FFI_HIDDEN ffi_go_closure_STDCALL(void); + +ffi_status +ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*)) +{ + void (*dest)(void); + + switch (cif->abi) + { + case FFI_SYSV: + case FFI_MS_CDECL: + dest = ffi_go_closure_ECX; + break; + case FFI_THISCALL: + case FFI_FASTCALL: + dest = ffi_go_closure_EAX; + break; + case FFI_STDCALL: + case FFI_PASCAL: + dest = ffi_go_closure_STDCALL; + break; + case FFI_REGISTER: + default: + return FFI_BAD_ABI; + } + + closure->tramp = dest; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +/* ------- Native raw API support -------------------------------- */ + +#if !FFI_NO_RAW_API + +void FFI_HIDDEN ffi_closure_raw_SYSV(void); +void FFI_HIDDEN ffi_closure_raw_THISCALL(void); + +ffi_status +ffi_prep_raw_closure_loc (ffi_raw_closure *closure, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data, + void *codeloc) +{ + char *tramp = closure->tramp; + void (*dest)(void); + int i; + + /* We currently don't support certain kinds of arguments for raw + closures. This should be implemented by a separate assembly + language routine, since it would require argument processing, + something we don't do now for performance. */ + for (i = cif->nargs-1; i >= 0; i--) + switch (cif->arg_types[i]->type) + { + case FFI_TYPE_STRUCT: + case FFI_TYPE_LONGDOUBLE: + return FFI_BAD_TYPEDEF; + } + + switch (cif->abi) + { + case FFI_THISCALL: + dest = ffi_closure_raw_THISCALL; + break; + case FFI_SYSV: + dest = ffi_closure_raw_SYSV; + break; + default: + return FFI_BAD_ABI; + } + + /* movl imm, %eax. */ + tramp[0] = 0xb8; + *(void **)(tramp + 1) = codeloc; + + /* jmp dest */ + tramp[5] = 0xe9; + *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10); + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +void +ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue) +{ + size_t rsize, bytes; + struct call_frame *frame; + char *stack, *argp; + ffi_type **arg_types; + int flags, cabi, i, n, narg_reg; + const struct abi_params *pabi; + + flags = cif->flags; + cabi = cif->abi; + pabi = &abi_params[cabi]; + + rsize = 0; + if (rvalue == NULL) + { + switch (flags) + { + case X86_RET_FLOAT: + case X86_RET_DOUBLE: + case X86_RET_LDOUBLE: + case X86_RET_STRUCTPOP: + case X86_RET_STRUCTARG: + /* The float cases need to pop the 387 stack. + The struct cases need to pass a valid pointer to the callee. */ + rsize = cif->rtype->size; + break; + default: + /* We can pretend that the callee returns nothing. */ + flags = X86_RET_VOID; + break; + } + } + + bytes = cif->bytes; + argp = stack = alloca(bytes + sizeof(*frame) + rsize); + frame = (struct call_frame *)(stack + bytes); + if (rsize) + rvalue = frame + 1; + + frame->fn = fn; + frame->flags = flags; + frame->rvalue = rvalue; + + narg_reg = 0; + switch (flags) + { + case X86_RET_STRUCTARG: + /* The pointer is passed as the first argument. */ + if (pabi->nregs > 0) + { + frame->regs[pabi->regs[0]] = (unsigned)rvalue; + narg_reg = 1; + break; + } + /* fallthru */ + case X86_RET_STRUCTPOP: + *(void **)argp = rvalue; + argp += sizeof(void *); + bytes -= sizeof(void *); + break; + } + + arg_types = cif->arg_types; + for (i = 0, n = cif->nargs; narg_reg < pabi->nregs && i < n; i++) + { + ffi_type *ty = arg_types[i]; + size_t z = ty->size; + int t = ty->type; + + if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT && t != FFI_TYPE_FLOAT) + { + ffi_arg val = extend_basic_type (avalue, t); + frame->regs[pabi->regs[narg_reg++]] = val; + z = FFI_SIZEOF_ARG; + } + else + { + memcpy (argp, avalue, z); + z = ALIGN (z, FFI_SIZEOF_ARG); + argp += z; + } + avalue += z; + bytes -= z; + } + if (i < n) + memcpy (argp, avalue, bytes); + + ffi_call_i386 (frame, stack); +} +#endif /* !FFI_NO_RAW_API */ +#endif /* !__x86_64__ */ diff --git a/user/mpy/lib/libffi/src/x86/ffi64.c b/user/mpy/lib/libffi/src/x86/ffi64.c new file mode 100644 index 0000000..131b5e3 --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/ffi64.c @@ -0,0 +1,824 @@ +/* ----------------------------------------------------------------------- + ffi64.c - Copyright (c) 2013 The Written Word, Inc. + Copyright (c) 2011 Anthony Green + Copyright (c) 2008, 2010 Red Hat, Inc. + Copyright (c) 2002, 2007 Bo Thorsen + + x86-64 Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +#include +#include +#include +#include "internal64.h" + +#ifdef __x86_64__ + +#define MAX_GPR_REGS 6 +#define MAX_SSE_REGS 8 + +#if defined(__INTEL_COMPILER) +#include "xmmintrin.h" +#define UINT128 __m128 +#else +#if defined(__SUNPRO_C) +#include +#define UINT128 __m128i +#else +#define UINT128 __int128_t +#endif +#endif + +union big_int_union +{ + UINT32 i32; + UINT64 i64; + UINT128 i128; +}; + +struct register_args +{ + /* Registers for argument passing. */ + UINT64 gpr[MAX_GPR_REGS]; + union big_int_union sse[MAX_SSE_REGS]; + UINT64 rax; /* ssecount */ + UINT64 r10; /* static chain */ +}; + +extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, + void *raddr, void (*fnaddr)(void)) FFI_HIDDEN; + +/* All reference to register classes here is identical to the code in + gcc/config/i386/i386.c. Do *not* change one without the other. */ + +/* Register class used for passing given 64bit part of the argument. + These represent classes as documented by the PS ABI, with the + exception of SSESF, SSEDF classes, that are basically SSE class, + just gcc will use SF or DFmode move instead of DImode to avoid + reformatting penalties. + + Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves + whenever possible (upper half does contain padding). */ +enum x86_64_reg_class + { + X86_64_NO_CLASS, + X86_64_INTEGER_CLASS, + X86_64_INTEGERSI_CLASS, + X86_64_SSE_CLASS, + X86_64_SSESF_CLASS, + X86_64_SSEDF_CLASS, + X86_64_SSEUP_CLASS, + X86_64_X87_CLASS, + X86_64_X87UP_CLASS, + X86_64_COMPLEX_X87_CLASS, + X86_64_MEMORY_CLASS + }; + +#define MAX_CLASSES 4 + +#define SSE_CLASS_P(X) ((X) >= X86_64_SSE_CLASS && X <= X86_64_SSEUP_CLASS) + +/* x86-64 register passing implementation. See x86-64 ABI for details. Goal + of this code is to classify each 8bytes of incoming argument by the register + class and assign registers accordingly. */ + +/* Return the union class of CLASS1 and CLASS2. + See the x86-64 PS ABI for details. */ + +static enum x86_64_reg_class +merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2) +{ + /* Rule #1: If both classes are equal, this is the resulting class. */ + if (class1 == class2) + return class1; + + /* Rule #2: If one of the classes is NO_CLASS, the resulting class is + the other class. */ + if (class1 == X86_64_NO_CLASS) + return class2; + if (class2 == X86_64_NO_CLASS) + return class1; + + /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */ + if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS) + return X86_64_MEMORY_CLASS; + + /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */ + if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS) + || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS)) + return X86_64_INTEGERSI_CLASS; + if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS + || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS) + return X86_64_INTEGER_CLASS; + + /* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class, + MEMORY is used. */ + if (class1 == X86_64_X87_CLASS + || class1 == X86_64_X87UP_CLASS + || class1 == X86_64_COMPLEX_X87_CLASS + || class2 == X86_64_X87_CLASS + || class2 == X86_64_X87UP_CLASS + || class2 == X86_64_COMPLEX_X87_CLASS) + return X86_64_MEMORY_CLASS; + + /* Rule #6: Otherwise class SSE is used. */ + return X86_64_SSE_CLASS; +} + +/* Classify the argument of type TYPE and mode MODE. + CLASSES will be filled by the register class used to pass each word + of the operand. The number of words is returned. In case the parameter + should be passed in memory, 0 is returned. As a special case for zero + sized containers, classes[0] will be NO_CLASS and 1 is returned. + + See the x86-64 PS ABI for details. +*/ +static size_t +classify_argument (ffi_type *type, enum x86_64_reg_class classes[], + size_t byte_offset) +{ + switch (type->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + do_integer: + { + size_t size = byte_offset + type->size; + + if (size <= 4) + { + classes[0] = X86_64_INTEGERSI_CLASS; + return 1; + } + else if (size <= 8) + { + classes[0] = X86_64_INTEGER_CLASS; + return 1; + } + else if (size <= 12) + { + classes[0] = X86_64_INTEGER_CLASS; + classes[1] = X86_64_INTEGERSI_CLASS; + return 2; + } + else if (size <= 16) + { + classes[0] = classes[1] = X86_64_INTEGER_CLASS; + return 2; + } + else + FFI_ASSERT (0); + } + case FFI_TYPE_FLOAT: + if (!(byte_offset % 8)) + classes[0] = X86_64_SSESF_CLASS; + else + classes[0] = X86_64_SSE_CLASS; + return 1; + case FFI_TYPE_DOUBLE: + classes[0] = X86_64_SSEDF_CLASS; + return 1; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + classes[0] = X86_64_X87_CLASS; + classes[1] = X86_64_X87UP_CLASS; + return 2; +#endif + case FFI_TYPE_STRUCT: + { + const size_t UNITS_PER_WORD = 8; + size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + ffi_type **ptr; + int i; + enum x86_64_reg_class subclasses[MAX_CLASSES]; + + /* If the struct is larger than 32 bytes, pass it on the stack. */ + if (type->size > 32) + return 0; + + for (i = 0; i < words; i++) + classes[i] = X86_64_NO_CLASS; + + /* Zero sized arrays or structures are NO_CLASS. We return 0 to + signalize memory class, so handle it as special case. */ + if (!words) + { + case FFI_TYPE_VOID: + classes[0] = X86_64_NO_CLASS; + return 1; + } + + /* Merge the fields of structure. */ + for (ptr = type->elements; *ptr != NULL; ptr++) + { + size_t num; + + byte_offset = ALIGN (byte_offset, (*ptr)->alignment); + + num = classify_argument (*ptr, subclasses, byte_offset % 8); + if (num == 0) + return 0; + for (i = 0; i < num; i++) + { + size_t pos = byte_offset / 8; + classes[i + pos] = + merge_classes (subclasses[i], classes[i + pos]); + } + + byte_offset += (*ptr)->size; + } + + if (words > 2) + { + /* When size > 16 bytes, if the first one isn't + X86_64_SSE_CLASS or any other ones aren't + X86_64_SSEUP_CLASS, everything should be passed in + memory. */ + if (classes[0] != X86_64_SSE_CLASS) + return 0; + + for (i = 1; i < words; i++) + if (classes[i] != X86_64_SSEUP_CLASS) + return 0; + } + + /* Final merger cleanup. */ + for (i = 0; i < words; i++) + { + /* If one class is MEMORY, everything should be passed in + memory. */ + if (classes[i] == X86_64_MEMORY_CLASS) + return 0; + + /* The X86_64_SSEUP_CLASS should be always preceded by + X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */ + if (classes[i] == X86_64_SSEUP_CLASS + && classes[i - 1] != X86_64_SSE_CLASS + && classes[i - 1] != X86_64_SSEUP_CLASS) + { + /* The first one should never be X86_64_SSEUP_CLASS. */ + FFI_ASSERT (i != 0); + classes[i] = X86_64_SSE_CLASS; + } + + /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS, + everything should be passed in memory. */ + if (classes[i] == X86_64_X87UP_CLASS + && (classes[i - 1] != X86_64_X87_CLASS)) + { + /* The first one should never be X86_64_X87UP_CLASS. */ + FFI_ASSERT (i != 0); + return 0; + } + } + return words; + } + case FFI_TYPE_COMPLEX: + { + ffi_type *inner = type->elements[0]; + switch (inner->type) + { + case FFI_TYPE_INT: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + goto do_integer; + + case FFI_TYPE_FLOAT: + classes[0] = X86_64_SSE_CLASS; + if (byte_offset % 8) + { + classes[1] = X86_64_SSESF_CLASS; + return 2; + } + return 1; + case FFI_TYPE_DOUBLE: + classes[0] = classes[1] = X86_64_SSEDF_CLASS; + return 2; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + classes[0] = X86_64_COMPLEX_X87_CLASS; + return 1; +#endif + } + } + } + abort(); +} + +/* Examine the argument and return set number of register required in each + class. Return zero iff parameter should be passed in memory, otherwise + the number of registers. */ + +static size_t +examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES], + _Bool in_return, int *pngpr, int *pnsse) +{ + size_t n; + int i, ngpr, nsse; + + n = classify_argument (type, classes, 0); + if (n == 0) + return 0; + + ngpr = nsse = 0; + for (i = 0; i < n; ++i) + switch (classes[i]) + { + case X86_64_INTEGER_CLASS: + case X86_64_INTEGERSI_CLASS: + ngpr++; + break; + case X86_64_SSE_CLASS: + case X86_64_SSESF_CLASS: + case X86_64_SSEDF_CLASS: + nsse++; + break; + case X86_64_NO_CLASS: + case X86_64_SSEUP_CLASS: + break; + case X86_64_X87_CLASS: + case X86_64_X87UP_CLASS: + case X86_64_COMPLEX_X87_CLASS: + return in_return != 0; + default: + abort (); + } + + *pngpr = ngpr; + *pnsse = nsse; + + return n; +} + +/* Perform machine dependent cif processing. */ + +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + int gprcount, ssecount, i, avn, ngpr, nsse, flags; + enum x86_64_reg_class classes[MAX_CLASSES]; + size_t bytes, n, rtype_size; + ffi_type *rtype; + + if (cif->abi != FFI_UNIX64) + return FFI_BAD_ABI; + + gprcount = ssecount = 0; + + rtype = cif->rtype; + rtype_size = rtype->size; + switch (rtype->type) + { + case FFI_TYPE_VOID: + flags = UNIX64_RET_VOID; + break; + case FFI_TYPE_UINT8: + flags = UNIX64_RET_UINT8; + break; + case FFI_TYPE_SINT8: + flags = UNIX64_RET_SINT8; + break; + case FFI_TYPE_UINT16: + flags = UNIX64_RET_UINT16; + break; + case FFI_TYPE_SINT16: + flags = UNIX64_RET_SINT16; + break; + case FFI_TYPE_UINT32: + flags = UNIX64_RET_UINT32; + break; + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + flags = UNIX64_RET_SINT32; + break; + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + flags = UNIX64_RET_INT64; + break; + case FFI_TYPE_POINTER: + flags = (sizeof(void *) == 4 ? UNIX64_RET_UINT32 : UNIX64_RET_INT64); + break; + case FFI_TYPE_FLOAT: + flags = UNIX64_RET_XMM32; + break; + case FFI_TYPE_DOUBLE: + flags = UNIX64_RET_XMM64; + break; + case FFI_TYPE_LONGDOUBLE: + flags = UNIX64_RET_X87; + break; + case FFI_TYPE_STRUCT: + n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse); + if (n == 0) + { + /* The return value is passed in memory. A pointer to that + memory is the first argument. Allocate a register for it. */ + gprcount++; + /* We don't have to do anything in asm for the return. */ + flags = UNIX64_RET_VOID | UNIX64_FLAG_RET_IN_MEM; + } + else + { + _Bool sse0 = SSE_CLASS_P (classes[0]); + + if (rtype_size == 4 && sse0) + flags = UNIX64_RET_XMM32; + else if (rtype_size == 8) + flags = sse0 ? UNIX64_RET_XMM64 : UNIX64_RET_INT64; + else + { + _Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]); + if (sse0 && sse1) + flags = UNIX64_RET_ST_XMM0_XMM1; + else if (sse0) + flags = UNIX64_RET_ST_XMM0_RAX; + else if (sse1) + flags = UNIX64_RET_ST_RAX_XMM0; + else + flags = UNIX64_RET_ST_RAX_RDX; + flags |= rtype_size << UNIX64_SIZE_SHIFT; + } + } + break; + case FFI_TYPE_COMPLEX: + switch (rtype->elements[0]->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT16: + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + flags = UNIX64_RET_ST_RAX_RDX | (rtype_size << UNIX64_SIZE_SHIFT); + break; + case FFI_TYPE_FLOAT: + flags = UNIX64_RET_XMM64; + break; + case FFI_TYPE_DOUBLE: + flags = UNIX64_RET_ST_XMM0_XMM1 | (16 << UNIX64_SIZE_SHIFT); + break; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + flags = UNIX64_RET_X87_2; + break; +#endif + default: + return FFI_BAD_TYPEDEF; + } + break; + default: + return FFI_BAD_TYPEDEF; + } + + /* Go over all arguments and determine the way they should be passed. + If it's in a register and there is space for it, let that be so. If + not, add it's size to the stack byte count. */ + for (bytes = 0, i = 0, avn = cif->nargs; i < avn; i++) + { + if (examine_argument (cif->arg_types[i], classes, 0, &ngpr, &nsse) == 0 + || gprcount + ngpr > MAX_GPR_REGS + || ssecount + nsse > MAX_SSE_REGS) + { + long align = cif->arg_types[i]->alignment; + + if (align < 8) + align = 8; + + bytes = ALIGN (bytes, align); + bytes += cif->arg_types[i]->size; + } + else + { + gprcount += ngpr; + ssecount += nsse; + } + } + if (ssecount) + flags |= UNIX64_FLAG_XMM_ARGS; + + cif->flags = flags; + cif->bytes = ALIGN (bytes, 8); + + return FFI_OK; +} + +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + enum x86_64_reg_class classes[MAX_CLASSES]; + char *stack, *argp; + ffi_type **arg_types; + int gprcount, ssecount, ngpr, nsse, i, avn, flags; + struct register_args *reg_args; + + /* Can't call 32-bit mode from 64-bit mode. */ + FFI_ASSERT (cif->abi == FFI_UNIX64); + + /* If the return value is a struct and we don't have a return value + address then we need to make one. Otherwise we can ignore it. */ + flags = cif->flags; + if (rvalue == NULL) + { + if (flags & UNIX64_FLAG_RET_IN_MEM) + rvalue = alloca (cif->rtype->size); + else + flags = UNIX64_RET_VOID; + } + + /* Allocate the space for the arguments, plus 4 words of temp space. */ + stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8); + reg_args = (struct register_args *) stack; + argp = stack + sizeof (struct register_args); + + reg_args->r10 = (uintptr_t) closure; + + gprcount = ssecount = 0; + + /* If the return value is passed in memory, add the pointer as the + first integer argument. */ + if (flags & UNIX64_FLAG_RET_IN_MEM) + reg_args->gpr[gprcount++] = (unsigned long) rvalue; + + avn = cif->nargs; + arg_types = cif->arg_types; + + for (i = 0; i < avn; ++i) + { + size_t n, size = arg_types[i]->size; + + n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse); + if (n == 0 + || gprcount + ngpr > MAX_GPR_REGS + || ssecount + nsse > MAX_SSE_REGS) + { + long align = arg_types[i]->alignment; + + /* Stack arguments are *always* at least 8 byte aligned. */ + if (align < 8) + align = 8; + + /* Pass this argument in memory. */ + argp = (void *) ALIGN (argp, align); + memcpy (argp, avalue[i], size); + argp += size; + } + else + { + /* The argument is passed entirely in registers. */ + char *a = (char *) avalue[i]; + int j; + + for (j = 0; j < n; j++, a += 8, size -= 8) + { + switch (classes[j]) + { + case X86_64_NO_CLASS: + case X86_64_SSEUP_CLASS: + break; + case X86_64_INTEGER_CLASS: + case X86_64_INTEGERSI_CLASS: + /* Sign-extend integer arguments passed in general + purpose registers, to cope with the fact that + LLVM incorrectly assumes that this will be done + (the x86-64 PS ABI does not specify this). */ + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + reg_args->gpr[gprcount] = (SINT64) *((SINT8 *) a); + break; + case FFI_TYPE_SINT16: + reg_args->gpr[gprcount] = (SINT64) *((SINT16 *) a); + break; + case FFI_TYPE_SINT32: + reg_args->gpr[gprcount] = (SINT64) *((SINT32 *) a); + break; + default: + reg_args->gpr[gprcount] = 0; + memcpy (®_args->gpr[gprcount], a, size); + } + gprcount++; + break; + case X86_64_SSE_CLASS: + case X86_64_SSEDF_CLASS: + reg_args->sse[ssecount++].i64 = *(UINT64 *) a; + break; + case X86_64_SSESF_CLASS: + reg_args->sse[ssecount++].i32 = *(UINT32 *) a; + break; + default: + abort(); + } + } + } + } + reg_args->rax = ssecount; + + ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args), + flags, rvalue, fn); +} + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + +extern void ffi_closure_unix64(void) FFI_HIDDEN; +extern void ffi_closure_unix64_sse(void) FFI_HIDDEN; + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + static const unsigned char trampoline[16] = { + /* leaq -0x7(%rip),%r10 # 0x0 */ + 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff, + /* jmpq *0x3(%rip) # 0x10 */ + 0xff, 0x25, 0x03, 0x00, 0x00, 0x00, + /* nopl (%rax) */ + 0x0f, 0x1f, 0x00 + }; + void (*dest)(void); + char *tramp = closure->tramp; + + if (cif->abi != FFI_UNIX64) + return FFI_BAD_ABI; + + if (cif->flags & UNIX64_FLAG_XMM_ARGS) + dest = ffi_closure_unix64_sse; + else + dest = ffi_closure_unix64; + + memcpy (tramp, trampoline, sizeof(trampoline)); + *(UINT64 *)(tramp + 16) = (uintptr_t)dest; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +int FFI_HIDDEN +ffi_closure_unix64_inner(ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *rvalue, + struct register_args *reg_args, + char *argp) +{ + void **avalue; + ffi_type **arg_types; + long i, avn; + int gprcount, ssecount, ngpr, nsse; + int flags; + + avn = cif->nargs; + flags = cif->flags; + avalue = alloca(avn * sizeof(void *)); + gprcount = ssecount = 0; + + if (flags & UNIX64_FLAG_RET_IN_MEM) + { + /* On return, %rax will contain the address that was passed + by the caller in %rdi. */ + void *r = (void *)(uintptr_t)reg_args->gpr[gprcount++]; + *(void **)rvalue = r; + rvalue = r; + flags = (sizeof(void *) == 4 ? UNIX64_RET_UINT32 : UNIX64_RET_INT64); + } + + arg_types = cif->arg_types; + for (i = 0; i < avn; ++i) + { + enum x86_64_reg_class classes[MAX_CLASSES]; + size_t n; + + n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse); + if (n == 0 + || gprcount + ngpr > MAX_GPR_REGS + || ssecount + nsse > MAX_SSE_REGS) + { + long align = arg_types[i]->alignment; + + /* Stack arguments are *always* at least 8 byte aligned. */ + if (align < 8) + align = 8; + + /* Pass this argument in memory. */ + argp = (void *) ALIGN (argp, align); + avalue[i] = argp; + argp += arg_types[i]->size; + } + /* If the argument is in a single register, or two consecutive + integer registers, then we can use that address directly. */ + else if (n == 1 + || (n == 2 && !(SSE_CLASS_P (classes[0]) + || SSE_CLASS_P (classes[1])))) + { + /* The argument is in a single register. */ + if (SSE_CLASS_P (classes[0])) + { + avalue[i] = ®_args->sse[ssecount]; + ssecount += n; + } + else + { + avalue[i] = ®_args->gpr[gprcount]; + gprcount += n; + } + } + /* Otherwise, allocate space to make them consecutive. */ + else + { + char *a = alloca (16); + int j; + + avalue[i] = a; + for (j = 0; j < n; j++, a += 8) + { + if (SSE_CLASS_P (classes[j])) + memcpy (a, ®_args->sse[ssecount++], 8); + else + memcpy (a, ®_args->gpr[gprcount++], 8); + } + } + } + + /* Invoke the closure. */ + fun (cif, rvalue, avalue, user_data); + + /* Tell assembly how to perform return type promotions. */ + return flags; +} + +extern void ffi_go_closure_unix64(void) FFI_HIDDEN; +extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN; + +ffi_status +ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*)) +{ + if (cif->abi != FFI_UNIX64) + return FFI_BAD_ABI; + + closure->tramp = (cif->flags & UNIX64_FLAG_XMM_ARGS + ? ffi_go_closure_unix64_sse + : ffi_go_closure_unix64); + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +#endif /* __x86_64__ */ diff --git a/user/mpy/lib/libffi/src/x86/ffitarget.h b/user/mpy/lib/libffi/src/x86/ffitarget.h new file mode 100644 index 0000000..8c1dcac --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/ffitarget.h @@ -0,0 +1,139 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012, 2014 Anthony Green + Copyright (c) 1996-2003, 2010 Red Hat, Inc. + Copyright (C) 2008 Free Software Foundation, Inc. + + Target configuration macros for x86 and x86-64. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +/* For code common to all platforms on x86 and x86_64. */ +#define X86_ANY + +#if defined (X86_64) && defined (__i386__) +#undef X86_64 +#define X86 +#endif + +#ifdef X86_WIN64 +#define FFI_SIZEOF_ARG 8 +#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ +#endif + +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION +#ifndef _MSC_VER +#define FFI_TARGET_HAS_COMPLEX_TYPE +#endif + +/* ---- Generic type definitions ----------------------------------------- */ + +#ifndef LIBFFI_ASM +#ifdef X86_WIN64 +#ifdef _MSC_VER +typedef unsigned __int64 ffi_arg; +typedef __int64 ffi_sarg; +#else +typedef unsigned long long ffi_arg; +typedef long long ffi_sarg; +#endif +#else +#if defined __x86_64__ && defined __ILP32__ +#define FFI_SIZEOF_ARG 8 +#define FFI_SIZEOF_JAVA_RAW 4 +typedef unsigned long long ffi_arg; +typedef long long ffi_sarg; +#else +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; +#endif +#endif + +typedef enum ffi_abi { +#if defined(X86_WIN64) + FFI_FIRST_ABI = 0, + FFI_WIN64, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_WIN64 + +#elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) + FFI_FIRST_ABI = 1, + FFI_UNIX64, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_UNIX64 + +#elif defined(X86_WIN32) + FFI_FIRST_ABI = 0, + FFI_SYSV = 1, + FFI_STDCALL = 2, + FFI_THISCALL = 3, + FFI_FASTCALL = 4, + FFI_MS_CDECL = 5, + FFI_PASCAL = 6, + FFI_REGISTER = 7, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_MS_CDECL +#else + FFI_FIRST_ABI = 0, + FFI_SYSV = 1, + FFI_THISCALL = 3, + FFI_FASTCALL = 4, + FFI_STDCALL = 5, + FFI_PASCAL = 6, + FFI_REGISTER = 7, + FFI_MS_CDECL = 8, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +#endif +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 + +#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) +#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) +#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) +#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) + +#if defined (X86_64) || defined(X86_WIN64) \ + || (defined (__x86_64__) && defined (X86_DARWIN)) +# define FFI_TRAMPOLINE_SIZE 24 +# define FFI_NATIVE_RAW_API 0 +#else +# define FFI_TRAMPOLINE_SIZE 12 +# define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ +#endif + +#endif + diff --git a/user/mpy/lib/libffi/src/x86/ffiw64.c b/user/mpy/lib/libffi/src/x86/ffiw64.c new file mode 100644 index 0000000..8a33a6c --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/ffiw64.c @@ -0,0 +1,281 @@ +/* ----------------------------------------------------------------------- + ffiw64.c - Copyright (c) 2014 Red Hat, Inc. + + x86 win64 Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include +#include +#include + +#ifdef X86_WIN64 + +struct win64_call_frame +{ + UINT64 rbp; /* 0 */ + UINT64 retaddr; /* 8 */ + UINT64 fn; /* 16 */ + UINT64 flags; /* 24 */ + UINT64 rvalue; /* 32 */ +}; + +extern void ffi_call_win64 (void *stack, struct win64_call_frame *, + void *closure) FFI_HIDDEN; + +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) +{ + int flags, n; + + if (cif->abi != FFI_WIN64) + return FFI_BAD_ABI; + + flags = cif->rtype->type; + switch (flags) + { + default: + break; + case FFI_TYPE_LONGDOUBLE: + flags = FFI_TYPE_STRUCT; + break; + case FFI_TYPE_COMPLEX: + flags = FFI_TYPE_STRUCT; + /* FALLTHRU */ + case FFI_TYPE_STRUCT: + switch (cif->rtype->size) + { + case 8: + flags = FFI_TYPE_UINT64; + break; + case 4: + flags = FFI_TYPE_SMALL_STRUCT_4B; + break; + case 2: + flags = FFI_TYPE_SMALL_STRUCT_2B; + break; + case 1: + flags = FFI_TYPE_SMALL_STRUCT_1B; + break; + } + break; + } + cif->flags = flags; + + /* Each argument either fits in a register, an 8 byte slot, or is + passed by reference with the pointer in the 8 byte slot. */ + n = cif->nargs; + n += (flags == FFI_TYPE_STRUCT); + if (n < 4) + n = 4; + cif->bytes = n * 8; + + return FFI_OK; +} + +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + int i, j, n, flags; + UINT64 *stack; + size_t rsize; + struct win64_call_frame *frame; + + FFI_ASSERT(cif->abi == FFI_WIN64); + + flags = cif->flags; + rsize = 0; + + /* If we have no return value for a structure, we need to create one. + Otherwise we can ignore the return type entirely. */ + if (rvalue == NULL) + { + if (flags == FFI_TYPE_STRUCT) + rsize = cif->rtype->size; + else + flags = FFI_TYPE_VOID; + } + + stack = alloca(cif->bytes + sizeof(struct win64_call_frame) + rsize); + frame = (struct win64_call_frame *)((char *)stack + cif->bytes); + if (rsize) + rvalue = frame + 1; + + frame->fn = (uintptr_t)fn; + frame->flags = flags; + frame->rvalue = (uintptr_t)rvalue; + + j = 0; + if (flags == FFI_TYPE_STRUCT) + { + stack[0] = (uintptr_t)rvalue; + j = 1; + } + + for (i = 0, n = cif->nargs; i < n; ++i, ++j) + { + switch (cif->arg_types[i]->size) + { + case 8: + stack[j] = *(UINT64 *)avalue[i]; + break; + case 4: + stack[j] = *(UINT32 *)avalue[i]; + break; + case 2: + stack[j] = *(UINT16 *)avalue[i]; + break; + case 1: + stack[j] = *(UINT8 *)avalue[i]; + break; + default: + stack[j] = (uintptr_t)avalue[i]; + break; + } + } + + ffi_call_win64 (stack, frame, closure); +} + +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + + +extern void ffi_closure_win64(void) FFI_HIDDEN; +extern void ffi_go_closure_win64(void) FFI_HIDDEN; + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + static const unsigned char trampoline[16] = { + /* leaq -0x7(%rip),%r10 # 0x0 */ + 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff, + /* jmpq *0x3(%rip) # 0x10 */ + 0xff, 0x25, 0x03, 0x00, 0x00, 0x00, + /* nopl (%rax) */ + 0x0f, 0x1f, 0x00 + }; + unsigned char *tramp = closure->tramp; + + if (cif->abi != FFI_WIN64) + return FFI_BAD_ABI; + + memcpy (tramp, trampoline, sizeof(trampoline)); + *(UINT64 *)(tramp + 16) = (uintptr_t)ffi_closure_win64; + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + + return FFI_OK; +} + +ffi_status +ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*)) +{ + if (cif->abi != FFI_WIN64) + return FFI_BAD_ABI; + + closure->tramp = ffi_go_closure_win64; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} + +struct win64_closure_frame +{ + UINT64 rvalue[2]; + UINT64 fargs[4]; + UINT64 retaddr; + UINT64 args[]; +}; + +int FFI_HIDDEN +ffi_closure_win64_inner(ffi_cif *cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + struct win64_closure_frame *frame) +{ + void **avalue; + void *rvalue; + int i, n, nreg, flags; + + avalue = alloca(cif->nargs * sizeof(void *)); + rvalue = frame->rvalue; + nreg = 0; + + /* When returning a structure, the address is in the first argument. + We must also be prepared to return the same address in eax, so + install that address in the frame and pretend we return a pointer. */ + flags = cif->flags; + if (flags == FFI_TYPE_STRUCT) + { + rvalue = (void *)(uintptr_t)frame->args[0]; + frame->rvalue[0] = frame->args[0]; + nreg = 1; + } + + for (i = 0, n = cif->nargs; i < n; ++i, ++nreg) + { + size_t size = cif->arg_types[i]->size; + size_t type = cif->arg_types[i]->type; + void *a; + + if (type == FFI_TYPE_DOUBLE || type == FFI_TYPE_FLOAT) + { + if (nreg < 4) + a = &frame->fargs[nreg]; + else + a = &frame->args[nreg]; + } + else if (size == 1 || size == 2 || size == 4 || size == 8) + a = &frame->args[nreg]; + else + a = (void *)(uintptr_t)frame->args[nreg]; + + avalue[i] = a; + } + + /* Invoke the closure. */ + fun (cif, rvalue, avalue, user_data); + return flags; +} + +#endif /* X86_WIN64 */ diff --git a/user/mpy/lib/libffi/src/x86/internal.h b/user/mpy/lib/libffi/src/x86/internal.h new file mode 100644 index 0000000..09771ba --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/internal.h @@ -0,0 +1,29 @@ +#define X86_RET_FLOAT 0 +#define X86_RET_DOUBLE 1 +#define X86_RET_LDOUBLE 2 +#define X86_RET_SINT8 3 +#define X86_RET_SINT16 4 +#define X86_RET_UINT8 5 +#define X86_RET_UINT16 6 +#define X86_RET_INT64 7 +#define X86_RET_INT32 8 +#define X86_RET_VOID 9 +#define X86_RET_STRUCTPOP 10 +#define X86_RET_STRUCTARG 11 +#define X86_RET_STRUCT_1B 12 +#define X86_RET_STRUCT_2B 13 +#define X86_RET_UNUSED14 14 +#define X86_RET_UNUSED15 15 + +#define X86_RET_TYPE_MASK 15 +#define X86_RET_POP_SHIFT 4 + +#define R_EAX 0 +#define R_EDX 1 +#define R_ECX 2 + +#ifdef __PCC__ +# define HAVE_FASTCALL 0 +#else +# define HAVE_FASTCALL 1 +#endif diff --git a/user/mpy/lib/libffi/src/x86/internal64.h b/user/mpy/lib/libffi/src/x86/internal64.h new file mode 100644 index 0000000..512e955 --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/internal64.h @@ -0,0 +1,22 @@ +#define UNIX64_RET_VOID 0 +#define UNIX64_RET_UINT8 1 +#define UNIX64_RET_UINT16 2 +#define UNIX64_RET_UINT32 3 +#define UNIX64_RET_SINT8 4 +#define UNIX64_RET_SINT16 5 +#define UNIX64_RET_SINT32 6 +#define UNIX64_RET_INT64 7 +#define UNIX64_RET_XMM32 8 +#define UNIX64_RET_XMM64 9 +#define UNIX64_RET_X87 10 +#define UNIX64_RET_X87_2 11 +#define UNIX64_RET_ST_XMM0_RAX 12 +#define UNIX64_RET_ST_RAX_XMM0 13 +#define UNIX64_RET_ST_XMM0_XMM1 14 +#define UNIX64_RET_ST_RAX_RDX 15 + +#define UNIX64_RET_LAST 15 + +#define UNIX64_FLAG_RET_IN_MEM (1 << 10) +#define UNIX64_FLAG_XMM_ARGS (1 << 11) +#define UNIX64_SIZE_SHIFT 12 diff --git a/user/mpy/lib/libffi/src/x86/sysv.S b/user/mpy/lib/libffi/src/x86/sysv.S new file mode 100644 index 0000000..78f245b --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/sysv.S @@ -0,0 +1,1040 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2013 The Written Word, Inc. + - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc. + + X86 Foreign Function Interface + + 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 __x86_64__ + +#define LIBFFI_ASM +#include +#include +#include "internal.h" + +#define C2(X, Y) X ## Y +#define C1(X, Y) C2(X, Y) +#ifdef __USER_LABEL_PREFIX__ +# define C(X) C1(__USER_LABEL_PREFIX__, X) +#else +# define C(X) X +#endif + +#ifdef X86_DARWIN +# define L(X) C1(L, X) +#else +# define L(X) C1(.L, X) +#endif + +#ifdef __ELF__ +# define ENDF(X) .type X,@function; .size X, . - X +#else +# define ENDF(X) +#endif + +/* Handle win32 fastcall name mangling. */ +#ifdef X86_WIN32 +# define ffi_call_i386 @ffi_call_i386@8 +# define ffi_closure_inner @ffi_closure_inner@8 +#else +# define ffi_call_i386 C(ffi_call_i386) +# define ffi_closure_inner C(ffi_closure_inner) +#endif + +/* This macro allows the safe creation of jump tables without an + actual table. The entry points into the table are all 8 bytes. + The use of ORG asserts that we're at the correct location. */ +/* ??? The clang assembler doesn't handle .org with symbolic expressions. */ +#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) +# define E(BASE, X) .balign 8 +#else +# define E(BASE, X) .balign 8; .org BASE + X * 8 +#endif + + .text + .balign 16 + .globl ffi_call_i386 + FFI_HIDDEN(ffi_call_i386) + +/* This is declared as + + void ffi_call_i386(struct call_frame *frame, char *argp) + __attribute__((fastcall)); + + Thus the arguments are present in + + ecx: frame + edx: argp +*/ + +ffi_call_i386: +L(UW0): + # cfi_startproc +#if !HAVE_FASTCALL + movl 4(%esp), %ecx + movl 8(%esp), %edx +#endif + movl (%esp), %eax /* move the return address */ + movl %ebp, (%ecx) /* store %ebp into local frame */ + movl %eax, 4(%ecx) /* store retaddr into local frame */ + + /* New stack frame based off ebp. This is a itty bit of unwind + trickery in that the CFA *has* changed. There is no easy way + to describe it correctly on entry to the function. Fortunately, + it doesn't matter too much since at all points we can correctly + unwind back to ffi_call. Note that the location to which we + moved the return address is (the new) CFA-4, so from the + perspective of the unwind info, it hasn't moved. */ + movl %ecx, %ebp +L(UW1): + # cfi_def_cfa(%ebp, 8) + # cfi_rel_offset(%ebp, 0) + + movl %edx, %esp /* set outgoing argument stack */ + movl 20+R_EAX*4(%ebp), %eax /* set register arguments */ + movl 20+R_EDX*4(%ebp), %edx + movl 20+R_ECX*4(%ebp), %ecx + + call *8(%ebp) + + movl 12(%ebp), %ecx /* load return type code */ + movl %ebx, 8(%ebp) /* preserve %ebx */ +L(UW2): + # cfi_rel_offset(%ebx, 8) + + andl $X86_RET_TYPE_MASK, %ecx +#ifdef __PIC__ + call C(__x86.get_pc_thunk.bx) +L(pc1): + leal L(store_table)-L(pc1)(%ebx, %ecx, 8), %ebx +#else + leal L(store_table)(,%ecx, 8), %ebx +#endif + movl 16(%ebp), %ecx /* load result address */ + jmp *%ebx + + .balign 8 +L(store_table): +E(L(store_table), X86_RET_FLOAT) + fstps (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_DOUBLE) + fstpl (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_LDOUBLE) + fstpt (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_SINT8) + movsbl %al, %eax + mov %eax, (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_SINT16) + movswl %ax, %eax + mov %eax, (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_UINT8) + movzbl %al, %eax + mov %eax, (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_UINT16) + movzwl %ax, %eax + mov %eax, (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_INT64) + movl %edx, 4(%ecx) + /* fallthru */ +E(L(store_table), X86_RET_INT32) + movl %eax, (%ecx) + /* fallthru */ +E(L(store_table), X86_RET_VOID) +L(e1): + movl 8(%ebp), %ebx + movl %ebp, %esp + popl %ebp +L(UW3): + # cfi_remember_state + # cfi_def_cfa(%esp, 4) + # cfi_restore(%ebx) + # cfi_restore(%ebp) + ret +L(UW4): + # cfi_restore_state + +E(L(store_table), X86_RET_STRUCTPOP) + jmp L(e1) +E(L(store_table), X86_RET_STRUCTARG) + jmp L(e1) +E(L(store_table), X86_RET_STRUCT_1B) + movb %al, (%ecx) + jmp L(e1) +E(L(store_table), X86_RET_STRUCT_2B) + movw %ax, (%ecx) + jmp L(e1) + + /* Fill out the table so that bad values are predictable. */ +E(L(store_table), X86_RET_UNUSED14) + ud2 +E(L(store_table), X86_RET_UNUSED15) + ud2 + +L(UW5): + # cfi_endproc +ENDF(ffi_call_i386) + +/* The inner helper is declared as + + void ffi_closure_inner(struct closure_frame *frame, char *argp) + __attribute_((fastcall)) + + Thus the arguments are placed in + + ecx: frame + edx: argp +*/ + +/* Macros to help setting up the closure_data structure. */ + +#if HAVE_FASTCALL +# define closure_FS (40 + 4) +# define closure_CF 0 +#else +# define closure_FS (8 + 40 + 12) +# define closure_CF 8 +#endif + +#define FFI_CLOSURE_SAVE_REGS \ + movl %eax, closure_CF+16+R_EAX*4(%esp); \ + movl %edx, closure_CF+16+R_EDX*4(%esp); \ + movl %ecx, closure_CF+16+R_ECX*4(%esp) + +#define FFI_CLOSURE_COPY_TRAMP_DATA \ + movl FFI_TRAMPOLINE_SIZE(%eax), %edx; /* copy cif */ \ + movl FFI_TRAMPOLINE_SIZE+4(%eax), %ecx; /* copy fun */ \ + movl FFI_TRAMPOLINE_SIZE+8(%eax), %eax; /* copy user_data */ \ + movl %edx, closure_CF+28(%esp); \ + movl %ecx, closure_CF+32(%esp); \ + movl %eax, closure_CF+36(%esp) + +#if HAVE_FASTCALL +# define FFI_CLOSURE_PREP_CALL \ + movl %esp, %ecx; /* load closure_data */ \ + leal closure_FS+4(%esp), %edx; /* load incoming stack */ +#else +# define FFI_CLOSURE_PREP_CALL \ + leal closure_CF(%esp), %ecx; /* load closure_data */ \ + leal closure_FS+4(%esp), %edx; /* load incoming stack */ \ + movl %ecx, (%esp); \ + movl %edx, 4(%esp) +#endif + +#define FFI_CLOSURE_CALL_INNER(UWN) \ + call ffi_closure_inner + +#define FFI_CLOSURE_MASK_AND_JUMP(N, UW) \ + andl $X86_RET_TYPE_MASK, %eax; \ + leal L(C1(load_table,N))(, %eax, 8), %edx; \ + movl closure_CF(%esp), %eax; /* optimiztic load */ \ + jmp *%edx + +#ifdef __PIC__ +# if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE +# undef FFI_CLOSURE_MASK_AND_JUMP +# define FFI_CLOSURE_MASK_AND_JUMP(N, UW) \ + andl $X86_RET_TYPE_MASK, %eax; \ + call C(__x86.get_pc_thunk.dx); \ +L(C1(pc,N)): \ + leal L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %edx; \ + movl closure_CF(%esp), %eax; /* optimiztic load */ \ + jmp *%edx +# else +# define FFI_CLOSURE_CALL_INNER_SAVE_EBX +# undef FFI_CLOSURE_CALL_INNER +# define FFI_CLOSURE_CALL_INNER(UWN) \ + movl %ebx, 40(%esp); /* save ebx */ \ +L(C1(UW,UWN)): \ + # cfi_rel_offset(%ebx, 40); \ + call C(__x86.get_pc_thunk.bx); /* load got register */ \ + addl $C(_GLOBAL_OFFSET_TABLE_), %ebx; \ + call ffi_closure_inner@PLT +# undef FFI_CLOSURE_MASK_AND_JUMP +# define FFI_CLOSURE_MASK_AND_JUMP(N, UWN) \ + andl $X86_RET_TYPE_MASK, %eax; \ + leal L(C1(load_table,N))@GOTOFF(%ebx, %eax, 8), %edx; \ + movl 40(%esp), %ebx; /* restore ebx */ \ +L(C1(UW,UWN)): \ + # cfi_restore(%ebx); \ + movl closure_CF(%esp), %eax; /* optimiztic load */ \ + jmp *%edx +# endif /* DARWIN || HIDDEN */ +#endif /* __PIC__ */ + + .balign 16 + .globl C(ffi_go_closure_EAX) + FFI_HIDDEN(C(ffi_go_closure_EAX)) +C(ffi_go_closure_EAX): +L(UW6): + # cfi_startproc + subl $closure_FS, %esp +L(UW7): + # cfi_def_cfa_offset(closure_FS + 4) + FFI_CLOSURE_SAVE_REGS + movl 4(%eax), %edx /* copy cif */ + movl 8(%eax), %ecx /* copy fun */ + movl %edx, closure_CF+28(%esp) + movl %ecx, closure_CF+32(%esp) + movl %eax, closure_CF+36(%esp) /* closure is user_data */ + jmp L(do_closure_i386) +L(UW8): + # cfi_endproc +ENDF(C(ffi_go_closure_EAX)) + + .balign 16 + .globl C(ffi_go_closure_ECX) + FFI_HIDDEN(C(ffi_go_closure_ECX)) +C(ffi_go_closure_ECX): +L(UW9): + # cfi_startproc + subl $closure_FS, %esp +L(UW10): + # cfi_def_cfa_offset(closure_FS + 4) + FFI_CLOSURE_SAVE_REGS + movl 4(%ecx), %edx /* copy cif */ + movl 8(%ecx), %eax /* copy fun */ + movl %edx, closure_CF+28(%esp) + movl %eax, closure_CF+32(%esp) + movl %ecx, closure_CF+36(%esp) /* closure is user_data */ + jmp L(do_closure_i386) +L(UW11): + # cfi_endproc +ENDF(C(ffi_go_closure_ECX)) + +/* The closure entry points are reached from the ffi_closure trampoline. + On entry, %eax contains the address of the ffi_closure. */ + + .balign 16 + .globl C(ffi_closure_i386) + FFI_HIDDEN(C(ffi_closure_i386)) + +C(ffi_closure_i386): +L(UW12): + # cfi_startproc + subl $closure_FS, %esp +L(UW13): + # cfi_def_cfa_offset(closure_FS + 4) + + FFI_CLOSURE_SAVE_REGS + FFI_CLOSURE_COPY_TRAMP_DATA + + /* Entry point from preceeding Go closures. */ +L(do_closure_i386): + + FFI_CLOSURE_PREP_CALL + FFI_CLOSURE_CALL_INNER(14) + FFI_CLOSURE_MASK_AND_JUMP(2, 15) + + .balign 8 +L(load_table2): +E(L(load_table2), X86_RET_FLOAT) + flds closure_CF(%esp) + jmp L(e2) +E(L(load_table2), X86_RET_DOUBLE) + fldl closure_CF(%esp) + jmp L(e2) +E(L(load_table2), X86_RET_LDOUBLE) + fldt closure_CF(%esp) + jmp L(e2) +E(L(load_table2), X86_RET_SINT8) + movsbl %al, %eax + jmp L(e2) +E(L(load_table2), X86_RET_SINT16) + movswl %ax, %eax + jmp L(e2) +E(L(load_table2), X86_RET_UINT8) + movzbl %al, %eax + jmp L(e2) +E(L(load_table2), X86_RET_UINT16) + movzwl %ax, %eax + jmp L(e2) +E(L(load_table2), X86_RET_INT64) + movl closure_CF+4(%esp), %edx + jmp L(e2) +E(L(load_table2), X86_RET_INT32) + nop + /* fallthru */ +E(L(load_table2), X86_RET_VOID) +L(e2): + addl $closure_FS, %esp +L(UW16): + # cfi_adjust_cfa_offset(-closure_FS) + ret +L(UW17): + # cfi_adjust_cfa_offset(closure_FS) +E(L(load_table2), X86_RET_STRUCTPOP) + addl $closure_FS, %esp +L(UW18): + # cfi_adjust_cfa_offset(-closure_FS) + ret $4 +L(UW19): + # cfi_adjust_cfa_offset(closure_FS) +E(L(load_table2), X86_RET_STRUCTARG) + jmp L(e2) +E(L(load_table2), X86_RET_STRUCT_1B) + movzbl %al, %eax + jmp L(e2) +E(L(load_table2), X86_RET_STRUCT_2B) + movzwl %ax, %eax + jmp L(e2) + + /* Fill out the table so that bad values are predictable. */ +E(L(load_table2), X86_RET_UNUSED14) + ud2 +E(L(load_table2), X86_RET_UNUSED15) + ud2 + +L(UW20): + # cfi_endproc +ENDF(C(ffi_closure_i386)) + + .balign 16 + .globl C(ffi_go_closure_STDCALL) + FFI_HIDDEN(C(ffi_go_closure_STDCALL)) +C(ffi_go_closure_STDCALL): +L(UW21): + # cfi_startproc + subl $closure_FS, %esp +L(UW22): + # cfi_def_cfa_offset(closure_FS + 4) + FFI_CLOSURE_SAVE_REGS + movl 4(%ecx), %edx /* copy cif */ + movl 8(%ecx), %eax /* copy fun */ + movl %edx, closure_CF+28(%esp) + movl %eax, closure_CF+32(%esp) + movl %ecx, closure_CF+36(%esp) /* closure is user_data */ + jmp L(do_closure_STDCALL) +L(UW23): + # cfi_endproc +ENDF(C(ffi_go_closure_STDCALL)) + +/* For REGISTER, we have no available parameter registers, and so we + enter here having pushed the closure onto the stack. */ + + .balign 16 + .globl C(ffi_closure_REGISTER) + FFI_HIDDEN(C(ffi_closure_REGISTER)) +C(ffi_closure_REGISTER): +L(UW24): + # cfi_startproc + # cfi_def_cfa(%esp, 8) + # cfi_offset(%eip, -8) + subl $closure_FS-4, %esp +L(UW25): + # cfi_def_cfa_offset(closure_FS + 4) + FFI_CLOSURE_SAVE_REGS + movl closure_FS-4(%esp), %ecx /* load retaddr */ + movl closure_FS(%esp), %eax /* load closure */ + movl %ecx, closure_FS(%esp) /* move retaddr */ + jmp L(do_closure_REGISTER) +L(UW26): + # cfi_endproc +ENDF(C(ffi_closure_REGISTER)) + +/* For STDCALL (and others), we need to pop N bytes of arguments off + the stack following the closure. The amount needing to be popped + is returned to us from ffi_closure_inner. */ + + .balign 16 + .globl C(ffi_closure_STDCALL) + FFI_HIDDEN(C(ffi_closure_STDCALL)) +C(ffi_closure_STDCALL): +L(UW27): + # cfi_startproc + subl $closure_FS, %esp +L(UW28): + # cfi_def_cfa_offset(closure_FS + 4) + + FFI_CLOSURE_SAVE_REGS + + /* Entry point from ffi_closure_REGISTER. */ +L(do_closure_REGISTER): + + FFI_CLOSURE_COPY_TRAMP_DATA + + /* Entry point from preceeding Go closure. */ +L(do_closure_STDCALL): + + FFI_CLOSURE_PREP_CALL + FFI_CLOSURE_CALL_INNER(29) + + movl %eax, %ecx + shrl $X86_RET_POP_SHIFT, %ecx /* isolate pop count */ + leal closure_FS(%esp, %ecx), %ecx /* compute popped esp */ + movl closure_FS(%esp), %edx /* move return address */ + movl %edx, (%ecx) + + /* From this point on, the value of %esp upon return is %ecx+4, + and we've copied the return address to %ecx to make return easy. + There's no point in representing this in the unwind info, as + there is always a window between the mov and the ret which + will be wrong from one point of view or another. */ + + FFI_CLOSURE_MASK_AND_JUMP(3, 30) + + .balign 8 +L(load_table3): +E(L(load_table3), X86_RET_FLOAT) + flds closure_CF(%esp) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_DOUBLE) + fldl closure_CF(%esp) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_LDOUBLE) + fldt closure_CF(%esp) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_SINT8) + movsbl %al, %eax + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_SINT16) + movswl %ax, %eax + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_UINT8) + movzbl %al, %eax + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_UINT16) + movzwl %ax, %eax + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_INT64) + movl closure_CF+4(%esp), %edx + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_INT32) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_VOID) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_STRUCTPOP) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_STRUCTARG) + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_STRUCT_1B) + movzbl %al, %eax + movl %ecx, %esp + ret +E(L(load_table3), X86_RET_STRUCT_2B) + movzwl %ax, %eax + movl %ecx, %esp + ret + + /* Fill out the table so that bad values are predictable. */ +E(L(load_table3), X86_RET_UNUSED14) + ud2 +E(L(load_table3), X86_RET_UNUSED15) + ud2 + +L(UW31): + # cfi_endproc +ENDF(C(ffi_closure_STDCALL)) + +#if !FFI_NO_RAW_API + +#define raw_closure_S_FS (16+16+12) + + .balign 16 + .globl C(ffi_closure_raw_SYSV) + FFI_HIDDEN(C(ffi_closure_raw_SYSV)) +C(ffi_closure_raw_SYSV): +L(UW32): + # cfi_startproc + subl $raw_closure_S_FS, %esp +L(UW33): + # cfi_def_cfa_offset(raw_closure_S_FS + 4) + movl %ebx, raw_closure_S_FS-4(%esp) +L(UW34): + # cfi_rel_offset(%ebx, raw_closure_S_FS-4) + + movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */ + movl %edx, 12(%esp) + leal raw_closure_S_FS+4(%esp), %edx /* load raw_args */ + movl %edx, 8(%esp) + leal 16(%esp), %edx /* load &res */ + movl %edx, 4(%esp) + movl FFI_TRAMPOLINE_SIZE(%eax), %ebx /* load cl->cif */ + movl %ebx, (%esp) + call *FFI_TRAMPOLINE_SIZE+4(%eax) /* call cl->fun */ + + movl 20(%ebx), %eax /* load cif->flags */ + andl $X86_RET_TYPE_MASK, %eax +#ifdef __PIC__ + call C(__x86.get_pc_thunk.bx) +L(pc4): + leal L(load_table4)-L(pc4)(%ebx, %eax, 8), %ecx +#else + leal L(load_table4)(,%eax, 8), %ecx +#endif + movl raw_closure_S_FS-4(%esp), %ebx +L(UW35): + # cfi_restore(%ebx) + movl 16(%esp), %eax /* Optimistic load */ + jmp *%ecx + + .balign 8 +L(load_table4): +E(L(load_table4), X86_RET_FLOAT) + flds 16(%esp) + jmp L(e4) +E(L(load_table4), X86_RET_DOUBLE) + fldl 16(%esp) + jmp L(e4) +E(L(load_table4), X86_RET_LDOUBLE) + fldt 16(%esp) + jmp L(e4) +E(L(load_table4), X86_RET_SINT8) + movsbl %al, %eax + jmp L(e4) +E(L(load_table4), X86_RET_SINT16) + movswl %ax, %eax + jmp L(e4) +E(L(load_table4), X86_RET_UINT8) + movzbl %al, %eax + jmp L(e4) +E(L(load_table4), X86_RET_UINT16) + movzwl %ax, %eax + jmp L(e4) +E(L(load_table4), X86_RET_INT64) + movl 16+4(%esp), %edx + jmp L(e4) +E(L(load_table4), X86_RET_INT32) + nop + /* fallthru */ +E(L(load_table4), X86_RET_VOID) +L(e4): + addl $raw_closure_S_FS, %esp +L(UW36): + # cfi_adjust_cfa_offset(-raw_closure_S_FS) + ret +L(UW37): + # cfi_adjust_cfa_offset(raw_closure_S_FS) +E(L(load_table4), X86_RET_STRUCTPOP) + addl $raw_closure_S_FS, %esp +L(UW38): + # cfi_adjust_cfa_offset(-raw_closure_S_FS) + ret $4 +L(UW39): + # cfi_adjust_cfa_offset(raw_closure_S_FS) +E(L(load_table4), X86_RET_STRUCTARG) + jmp L(e4) +E(L(load_table4), X86_RET_STRUCT_1B) + movzbl %al, %eax + jmp L(e4) +E(L(load_table4), X86_RET_STRUCT_2B) + movzwl %ax, %eax + jmp L(e4) + + /* Fill out the table so that bad values are predictable. */ +E(L(load_table4), X86_RET_UNUSED14) + ud2 +E(L(load_table4), X86_RET_UNUSED15) + ud2 + +L(UW40): + # cfi_endproc +ENDF(C(ffi_closure_raw_SYSV)) + +#define raw_closure_T_FS (16+16+8) + + .balign 16 + .globl C(ffi_closure_raw_THISCALL) + FFI_HIDDEN(C(ffi_closure_raw_THISCALL)) +C(ffi_closure_raw_THISCALL): +L(UW41): + # cfi_startproc + /* Rearrange the stack such that %ecx is the first argument. + This means moving the return address. */ + popl %edx +L(UW42): + # cfi_def_cfa_offset(0) + # cfi_register(%eip, %edx) + pushl %ecx +L(UW43): + # cfi_adjust_cfa_offset(4) + pushl %edx +L(UW44): + # cfi_adjust_cfa_offset(4) + # cfi_rel_offset(%eip, 0) + subl $raw_closure_T_FS, %esp +L(UW45): + # cfi_adjust_cfa_offset(raw_closure_T_FS) + movl %ebx, raw_closure_T_FS-4(%esp) +L(UW46): + # cfi_rel_offset(%ebx, raw_closure_T_FS-4) + + movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */ + movl %edx, 12(%esp) + leal raw_closure_T_FS+4(%esp), %edx /* load raw_args */ + movl %edx, 8(%esp) + leal 16(%esp), %edx /* load &res */ + movl %edx, 4(%esp) + movl FFI_TRAMPOLINE_SIZE(%eax), %ebx /* load cl->cif */ + movl %ebx, (%esp) + call *FFI_TRAMPOLINE_SIZE+4(%eax) /* call cl->fun */ + + movl 20(%ebx), %eax /* load cif->flags */ + andl $X86_RET_TYPE_MASK, %eax +#ifdef __PIC__ + call C(__x86.get_pc_thunk.bx) +L(pc5): + leal L(load_table5)-L(pc5)(%ebx, %eax, 8), %ecx +#else + leal L(load_table5)(,%eax, 8), %ecx +#endif + movl raw_closure_T_FS-4(%esp), %ebx +L(UW47): + # cfi_restore(%ebx) + movl 16(%esp), %eax /* Optimistic load */ + jmp *%ecx + + .balign 8 +L(load_table5): +E(L(load_table5), X86_RET_FLOAT) + flds 16(%esp) + jmp L(e5) +E(L(load_table5), X86_RET_DOUBLE) + fldl 16(%esp) + jmp L(e5) +E(L(load_table5), X86_RET_LDOUBLE) + fldt 16(%esp) + jmp L(e5) +E(L(load_table5), X86_RET_SINT8) + movsbl %al, %eax + jmp L(e5) +E(L(load_table5), X86_RET_SINT16) + movswl %ax, %eax + jmp L(e5) +E(L(load_table5), X86_RET_UINT8) + movzbl %al, %eax + jmp L(e5) +E(L(load_table5), X86_RET_UINT16) + movzwl %ax, %eax + jmp L(e5) +E(L(load_table5), X86_RET_INT64) + movl 16+4(%esp), %edx + jmp L(e5) +E(L(load_table5), X86_RET_INT32) + nop + /* fallthru */ +E(L(load_table5), X86_RET_VOID) +L(e5): + addl $raw_closure_T_FS, %esp +L(UW48): + # cfi_adjust_cfa_offset(-raw_closure_T_FS) + /* Remove the extra %ecx argument we pushed. */ + ret $4 +L(UW49): + # cfi_adjust_cfa_offset(raw_closure_T_FS) +E(L(load_table5), X86_RET_STRUCTPOP) + addl $raw_closure_T_FS, %esp +L(UW50): + # cfi_adjust_cfa_offset(-raw_closure_T_FS) + ret $8 +L(UW51): + # cfi_adjust_cfa_offset(raw_closure_T_FS) +E(L(load_table5), X86_RET_STRUCTARG) + jmp L(e5) +E(L(load_table5), X86_RET_STRUCT_1B) + movzbl %al, %eax + jmp L(e5) +E(L(load_table5), X86_RET_STRUCT_2B) + movzwl %ax, %eax + jmp L(e5) + + /* Fill out the table so that bad values are predictable. */ +E(L(load_table5), X86_RET_UNUSED14) + ud2 +E(L(load_table5), X86_RET_UNUSED15) + ud2 + +L(UW52): + # cfi_endproc +ENDF(C(ffi_closure_raw_THISCALL)) + +#endif /* !FFI_NO_RAW_API */ + +#ifdef X86_DARWIN +# define COMDAT(X) \ + .section __TEXT,__textcoal_nt,coalesced,pure_instructions; \ + .weak_definition X; \ + .private_extern X +#elif defined __ELF__ && !(defined(__sun__) && defined(__svr4__)) +# define COMDAT(X) \ + .section .text.X,"axG",@progbits,X,comdat; \ + .globl X; \ + FFI_HIDDEN(X) +#else +# define COMDAT(X) +#endif + +#if defined(__PIC__) + COMDAT(C(__x86.get_pc_thunk.bx)) +C(__x86.get_pc_thunk.bx): + movl (%esp), %ebx + ret +ENDF(C(__x86.get_pc_thunk.bx)) +# if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE + COMDAT(C(__x86.get_pc_thunk.dx)) +C(__x86.get_pc_thunk.dx): + movl (%esp), %edx + ret +ENDF(C(__x86.get_pc_thunk.dx)) +#endif /* DARWIN || HIDDEN */ +#endif /* __PIC__ */ + +/* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */ + +#ifdef __APPLE__ +.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +EHFrame0: +#elif defined(X86_WIN32) +.section .eh_frame,"r" +#elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) +.section .eh_frame,EH_FRAME_FLAGS,@unwind +#else +.section .eh_frame,EH_FRAME_FLAGS,@progbits +#endif + +#ifdef HAVE_AS_X86_PCREL +# define PCREL(X) X - . +#else +# define PCREL(X) X@rel +#endif + +/* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */ +#define ADV(N, P) .byte 2, L(N)-L(P) + + .balign 4 +L(CIE): + .set L(set0),L(ECIE)-L(SCIE) + .long L(set0) /* CIE Length */ +L(SCIE): + .long 0 /* CIE Identifier Tag */ + .byte 1 /* CIE Version */ + .ascii "zR\0" /* CIE Augmentation */ + .byte 1 /* CIE Code Alignment Factor */ + .byte 0x7c /* CIE Data Alignment Factor */ + .byte 0x8 /* CIE RA Column */ + .byte 1 /* Augmentation size */ + .byte 0x1b /* FDE Encoding (pcrel sdata4) */ + .byte 0xc, 4, 4 /* DW_CFA_def_cfa, %esp offset 4 */ + .byte 0x80+8, 1 /* DW_CFA_offset, %eip offset 1*-4 */ + .balign 4 +L(ECIE): + + .set L(set1),L(EFDE1)-L(SFDE1) + .long L(set1) /* FDE Length */ +L(SFDE1): + .long L(SFDE1)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW0)) /* Initial location */ + .long L(UW5)-L(UW0) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW1, UW0) + .byte 0xc, 5, 8 /* DW_CFA_def_cfa, %ebp 8 */ + .byte 0x80+5, 2 /* DW_CFA_offset, %ebp 2*-4 */ + ADV(UW2, UW1) + .byte 0x80+3, 0 /* DW_CFA_offset, %ebx 0*-4 */ + ADV(UW3, UW2) + .byte 0xa /* DW_CFA_remember_state */ + .byte 0xc, 4, 4 /* DW_CFA_def_cfa, %esp 4 */ + .byte 0xc0+3 /* DW_CFA_restore, %ebx */ + .byte 0xc0+5 /* DW_CFA_restore, %ebp */ + ADV(UW4, UW3) + .byte 0xb /* DW_CFA_restore_state */ + .balign 4 +L(EFDE1): + + .set L(set2),L(EFDE2)-L(SFDE2) + .long L(set2) /* FDE Length */ +L(SFDE2): + .long L(SFDE2)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW6)) /* Initial location */ + .long L(UW8)-L(UW6) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW7, UW6) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE2): + + .set L(set3),L(EFDE3)-L(SFDE3) + .long L(set3) /* FDE Length */ +L(SFDE3): + .long L(SFDE3)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW9)) /* Initial location */ + .long L(UW11)-L(UW9) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW10, UW9) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE3): + + .set L(set4),L(EFDE4)-L(SFDE4) + .long L(set4) /* FDE Length */ +L(SFDE4): + .long L(SFDE4)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW12)) /* Initial location */ + .long L(UW20)-L(UW12) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW13, UW12) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ +#ifdef FFI_CLOSURE_CALL_INNER_SAVE_EBX + ADV(UW14, UW13) + .byte 0x80+3, (40-(closure_FS+4))/-4 /* DW_CFA_offset %ebx */ + ADV(UW15, UW14) + .byte 0xc0+3 /* DW_CFA_restore %ebx */ + ADV(UW16, UW15) +#else + ADV(UW16, UW13) +#endif + .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ + ADV(UW17, UW16) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ + ADV(UW18, UW17) + .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ + ADV(UW19, UW18) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE4): + + .set L(set5),L(EFDE5)-L(SFDE5) + .long L(set5) /* FDE Length */ +L(SFDE5): + .long L(SFDE5)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW21)) /* Initial location */ + .long L(UW23)-L(UW21) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW22, UW21) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE5): + + .set L(set6),L(EFDE6)-L(SFDE6) + .long L(set6) /* FDE Length */ +L(SFDE6): + .long L(SFDE6)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW24)) /* Initial location */ + .long L(UW26)-L(UW24) /* Address range */ + .byte 0 /* Augmentation size */ + .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ + .byte 0x80+8, 2 /* DW_CFA_offset %eip, 2*-4 */ + ADV(UW25, UW24) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE6): + + .set L(set7),L(EFDE7)-L(SFDE7) + .long L(set7) /* FDE Length */ +L(SFDE7): + .long L(SFDE7)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW27)) /* Initial location */ + .long L(UW31)-L(UW27) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW28, UW27) + .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ +#ifdef FFI_CLOSURE_CALL_INNER_SAVE_EBX + ADV(UW29, UW28) + .byte 0x80+3, (40-(closure_FS+4))/-4 /* DW_CFA_offset %ebx */ + ADV(UW30, UW29) + .byte 0xc0+3 /* DW_CFA_restore %ebx */ +#endif + .balign 4 +L(EFDE7): + +#if !FFI_NO_RAW_API + .set L(set8),L(EFDE8)-L(SFDE8) + .long L(set8) /* FDE Length */ +L(SFDE8): + .long L(SFDE8)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW32)) /* Initial location */ + .long L(UW40)-L(UW32) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW33, UW32) + .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */ + ADV(UW34, UW33) + .byte 0x80+3, 2 /* DW_CFA_offset %ebx 2*-4 */ + ADV(UW35, UW34) + .byte 0xc0+3 /* DW_CFA_restore %ebx */ + ADV(UW36, UW35) + .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ + ADV(UW37, UW36) + .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */ + ADV(UW38, UW37) + .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ + ADV(UW39, UW38) + .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE8): + + .set L(set9),L(EFDE9)-L(SFDE9) + .long L(set9) /* FDE Length */ +L(SFDE9): + .long L(SFDE9)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW41)) /* Initial location */ + .long L(UW52)-L(UW41) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW42, UW41) + .byte 0xe, 0 /* DW_CFA_def_cfa_offset */ + .byte 0x9, 8, 2 /* DW_CFA_register %eip, %edx */ + ADV(UW43, UW42) + .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ + ADV(UW44, UW43) + .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ + .byte 0x80+8, 2 /* DW_CFA_offset %eip 2*-4 */ + ADV(UW45, UW44) + .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */ + ADV(UW46, UW45) + .byte 0x80+3, 3 /* DW_CFA_offset %ebx 3*-4 */ + ADV(UW47, UW46) + .byte 0xc0+3 /* DW_CFA_restore %ebx */ + ADV(UW48, UW47) + .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ + ADV(UW49, UW48) + .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */ + ADV(UW50, UW49) + .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ + ADV(UW51, UW50) + .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */ + .balign 4 +L(EFDE9): +#endif /* !FFI_NO_RAW_API */ + +#endif /* ifndef __x86_64__ */ + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/x86/unix64.S b/user/mpy/lib/libffi/src/x86/unix64.S new file mode 100644 index 0000000..c83010c --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/unix64.S @@ -0,0 +1,546 @@ +/* ----------------------------------------------------------------------- + unix64.S - Copyright (c) 2013 The Written Word, Inc. + - Copyright (c) 2008 Red Hat, Inc + - Copyright (c) 2002 Bo Thorsen + + x86-64 Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#ifdef __x86_64__ +#define LIBFFI_ASM +#include +#include +#include "internal64.h" + + .text + +#define C2(X, Y) X ## Y +#define C1(X, Y) C2(X, Y) +#ifdef __USER_LABEL_PREFIX__ +# define C(X) C1(__USER_LABEL_PREFIX__, X) +#else +# define C(X) X +#endif + +#ifdef __APPLE__ +# define L(X) C1(L, X) +#else +# define L(X) C1(.L, X) +#endif + +#ifdef __ELF__ +# define PLT(X) X@PLT +# define ENDF(X) .type X,@function; .size X, . - X +#else +# define PLT(X) X +# define ENDF(X) +#endif + +/* This macro allows the safe creation of jump tables without an + actual table. The entry points into the table are all 8 bytes. + The use of ORG asserts that we're at the correct location. */ +/* ??? The clang assembler doesn't handle .org with symbolic expressions. */ +#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) +# define E(BASE, X) .balign 8 +#else +# define E(BASE, X) .balign 8; .org BASE + X * 8 +#endif + +/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, + void *raddr, void (*fnaddr)(void)); + + Bit o trickiness here -- ARGS+BYTES is the base of the stack frame + for this function. This has been allocated by ffi_call. We also + deallocate some of the stack that has been alloca'd. */ + + .balign 8 + .globl C(ffi_call_unix64) + FFI_HIDDEN(C(ffi_call_unix64)) + +C(ffi_call_unix64): +L(UW0): + movq (%rsp), %r10 /* Load return address. */ + leaq (%rdi, %rsi), %rax /* Find local stack base. */ + movq %rdx, (%rax) /* Save flags. */ + movq %rcx, 8(%rax) /* Save raddr. */ + movq %rbp, 16(%rax) /* Save old frame pointer. */ + movq %r10, 24(%rax) /* Relocate return address. */ + movq %rax, %rbp /* Finalize local stack frame. */ + + /* New stack frame based off rbp. This is a itty bit of unwind + trickery in that the CFA *has* changed. There is no easy way + to describe it correctly on entry to the function. Fortunately, + it doesn't matter too much since at all points we can correctly + unwind back to ffi_call. Note that the location to which we + moved the return address is (the new) CFA-8, so from the + perspective of the unwind info, it hasn't moved. */ +L(UW1): + /* cfi_def_cfa(%rbp, 32) */ + /* cfi_rel_offset(%rbp, 16) */ + + movq %rdi, %r10 /* Save a copy of the register area. */ + movq %r8, %r11 /* Save a copy of the target fn. */ + movl %r9d, %eax /* Set number of SSE registers. */ + + /* Load up all argument registers. */ + movq (%r10), %rdi + movq 0x08(%r10), %rsi + movq 0x10(%r10), %rdx + movq 0x18(%r10), %rcx + movq 0x20(%r10), %r8 + movq 0x28(%r10), %r9 + movl 0xb0(%r10), %eax + testl %eax, %eax + jnz L(load_sse) +L(ret_from_load_sse): + + /* Deallocate the reg arg area, except for r10, then load via pop. */ + leaq 0xb8(%r10), %rsp + popq %r10 + + /* Call the user function. */ + call *%r11 + + /* Deallocate stack arg area; local stack frame in redzone. */ + leaq 24(%rbp), %rsp + + movq 0(%rbp), %rcx /* Reload flags. */ + movq 8(%rbp), %rdi /* Reload raddr. */ + movq 16(%rbp), %rbp /* Reload old frame pointer. */ +L(UW2): + /* cfi_remember_state */ + /* cfi_def_cfa(%rsp, 8) */ + /* cfi_restore(%rbp) */ + + /* The first byte of the flags contains the FFI_TYPE. */ + cmpb $UNIX64_RET_LAST, %cl + movzbl %cl, %r10d + leaq L(store_table)(%rip), %r11 + ja L(sa) + leaq (%r11, %r10, 8), %r10 + + /* Prep for the structure cases: scratch area in redzone. */ + leaq -20(%rsp), %rsi + jmp *%r10 + + .balign 8 +L(store_table): +E(L(store_table), UNIX64_RET_VOID) + ret +E(L(store_table), UNIX64_RET_UINT8) + movzbl %al, %eax + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_UINT16) + movzwl %ax, %eax + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_UINT32) + movl %eax, %eax + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_SINT8) + movsbq %al, %rax + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_SINT16) + movswq %ax, %rax + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_SINT32) + cltq + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_INT64) + movq %rax, (%rdi) + ret +E(L(store_table), UNIX64_RET_XMM32) + movd %xmm0, (%rdi) + ret +E(L(store_table), UNIX64_RET_XMM64) + movq %xmm0, (%rdi) + ret +E(L(store_table), UNIX64_RET_X87) + fstpt (%rdi) + ret +E(L(store_table), UNIX64_RET_X87_2) + fstpt (%rdi) + fstpt 16(%rdi) + ret +E(L(store_table), UNIX64_RET_ST_XMM0_RAX) + movq %rax, 8(%rsi) + jmp L(s3) +E(L(store_table), UNIX64_RET_ST_RAX_XMM0) + movq %xmm0, 8(%rsi) + jmp L(s2) +E(L(store_table), UNIX64_RET_ST_XMM0_XMM1) + movq %xmm1, 8(%rsi) + jmp L(s3) +E(L(store_table), UNIX64_RET_ST_RAX_RDX) + movq %rdx, 8(%rsi) +L(s2): + movq %rax, (%rsi) + shrl $UNIX64_SIZE_SHIFT, %ecx + rep movsb + ret + .balign 8 +L(s3): + movq %xmm0, (%rsi) + shrl $UNIX64_SIZE_SHIFT, %ecx + rep movsb + ret + +L(sa): call PLT(C(abort)) + + /* Many times we can avoid loading any SSE registers at all. + It's not worth an indirect jump to load the exact set of + SSE registers needed; zero or all is a good compromise. */ + .balign 2 +L(UW3): + /* cfi_restore_state */ +L(load_sse): + movdqa 0x30(%r10), %xmm0 + movdqa 0x40(%r10), %xmm1 + movdqa 0x50(%r10), %xmm2 + movdqa 0x60(%r10), %xmm3 + movdqa 0x70(%r10), %xmm4 + movdqa 0x80(%r10), %xmm5 + movdqa 0x90(%r10), %xmm6 + movdqa 0xa0(%r10), %xmm7 + jmp L(ret_from_load_sse) + +L(UW4): +ENDF(C(ffi_call_unix64)) + +/* 6 general registers, 8 vector registers, + 32 bytes of rvalue, 8 bytes of alignment. */ +#define ffi_closure_OFS_G 0 +#define ffi_closure_OFS_V (6*8) +#define ffi_closure_OFS_RVALUE (ffi_closure_OFS_V + 8*16) +#define ffi_closure_FS (ffi_closure_OFS_RVALUE + 32 + 8) + +/* The location of rvalue within the red zone after deallocating the frame. */ +#define ffi_closure_RED_RVALUE (ffi_closure_OFS_RVALUE - ffi_closure_FS) + + .balign 2 + .globl C(ffi_closure_unix64_sse) + FFI_HIDDEN(C(ffi_closure_unix64_sse)) + +C(ffi_closure_unix64_sse): +L(UW5): + subq $ffi_closure_FS, %rsp +L(UW6): + /* cfi_adjust_cfa_offset(ffi_closure_FS) */ + + movdqa %xmm0, ffi_closure_OFS_V+0x00(%rsp) + movdqa %xmm1, ffi_closure_OFS_V+0x10(%rsp) + movdqa %xmm2, ffi_closure_OFS_V+0x20(%rsp) + movdqa %xmm3, ffi_closure_OFS_V+0x30(%rsp) + movdqa %xmm4, ffi_closure_OFS_V+0x40(%rsp) + movdqa %xmm5, ffi_closure_OFS_V+0x50(%rsp) + movdqa %xmm6, ffi_closure_OFS_V+0x60(%rsp) + movdqa %xmm7, ffi_closure_OFS_V+0x70(%rsp) + jmp L(sse_entry1) + +L(UW7): +ENDF(C(ffi_closure_unix64_sse)) + + .balign 2 + .globl C(ffi_closure_unix64) + FFI_HIDDEN(C(ffi_closure_unix64)) + +C(ffi_closure_unix64): +L(UW8): + subq $ffi_closure_FS, %rsp +L(UW9): + /* cfi_adjust_cfa_offset(ffi_closure_FS) */ +L(sse_entry1): + movq %rdi, ffi_closure_OFS_G+0x00(%rsp) + movq %rsi, ffi_closure_OFS_G+0x08(%rsp) + movq %rdx, ffi_closure_OFS_G+0x10(%rsp) + movq %rcx, ffi_closure_OFS_G+0x18(%rsp) + movq %r8, ffi_closure_OFS_G+0x20(%rsp) + movq %r9, ffi_closure_OFS_G+0x28(%rsp) + +#ifdef __ILP32__ + movl FFI_TRAMPOLINE_SIZE(%r10), %edi /* Load cif */ + movl FFI_TRAMPOLINE_SIZE+4(%r10), %esi /* Load fun */ + movl FFI_TRAMPOLINE_SIZE+8(%r10), %edx /* Load user_data */ +#else + movq FFI_TRAMPOLINE_SIZE(%r10), %rdi /* Load cif */ + movq FFI_TRAMPOLINE_SIZE+8(%r10), %rsi /* Load fun */ + movq FFI_TRAMPOLINE_SIZE+16(%r10), %rdx /* Load user_data */ +#endif +L(do_closure): + leaq ffi_closure_OFS_RVALUE(%rsp), %rcx /* Load rvalue */ + movq %rsp, %r8 /* Load reg_args */ + leaq ffi_closure_FS+8(%rsp), %r9 /* Load argp */ + call C(ffi_closure_unix64_inner) + + /* Deallocate stack frame early; return value is now in redzone. */ + addq $ffi_closure_FS, %rsp +L(UW10): + /* cfi_adjust_cfa_offset(-ffi_closure_FS) */ + + /* The first byte of the return value contains the FFI_TYPE. */ + cmpb $UNIX64_RET_LAST, %al + movzbl %al, %r10d + leaq L(load_table)(%rip), %r11 + ja L(la) + leaq (%r11, %r10, 8), %r10 + leaq ffi_closure_RED_RVALUE(%rsp), %rsi + jmp *%r10 + + .balign 8 +L(load_table): +E(L(load_table), UNIX64_RET_VOID) + ret +E(L(load_table), UNIX64_RET_UINT8) + movzbl (%rsi), %eax + ret +E(L(load_table), UNIX64_RET_UINT16) + movzwl (%rsi), %eax + ret +E(L(load_table), UNIX64_RET_UINT32) + movl (%rsi), %eax + ret +E(L(load_table), UNIX64_RET_SINT8) + movsbl (%rsi), %eax + ret +E(L(load_table), UNIX64_RET_SINT16) + movswl (%rsi), %eax + ret +E(L(load_table), UNIX64_RET_SINT32) + movl (%rsi), %eax + ret +E(L(load_table), UNIX64_RET_INT64) + movq (%rsi), %rax + ret +E(L(load_table), UNIX64_RET_XMM32) + movd (%rsi), %xmm0 + ret +E(L(load_table), UNIX64_RET_XMM64) + movq (%rsi), %xmm0 + ret +E(L(load_table), UNIX64_RET_X87) + fldt (%rsi) + ret +E(L(load_table), UNIX64_RET_X87_2) + fldt 16(%rsi) + fldt (%rsi) + ret +E(L(load_table), UNIX64_RET_ST_XMM0_RAX) + movq 8(%rsi), %rax + jmp L(l3) +E(L(load_table), UNIX64_RET_ST_RAX_XMM0) + movq 8(%rsi), %xmm0 + jmp L(l2) +E(L(load_table), UNIX64_RET_ST_XMM0_XMM1) + movq 8(%rsi), %xmm1 + jmp L(l3) +E(L(load_table), UNIX64_RET_ST_RAX_RDX) + movq 8(%rsi), %rdx +L(l2): + movq (%rsi), %rax + ret + .balign 8 +L(l3): + movq (%rsi), %xmm0 + ret + +L(la): call PLT(C(abort)) + +L(UW11): +ENDF(C(ffi_closure_unix64)) + + .balign 2 + .globl C(ffi_go_closure_unix64_sse) + FFI_HIDDEN(C(ffi_go_closure_unix64_sse)) + +C(ffi_go_closure_unix64_sse): +L(UW12): + subq $ffi_closure_FS, %rsp +L(UW13): + /* cfi_adjust_cfa_offset(ffi_closure_FS) */ + + movdqa %xmm0, ffi_closure_OFS_V+0x00(%rsp) + movdqa %xmm1, ffi_closure_OFS_V+0x10(%rsp) + movdqa %xmm2, ffi_closure_OFS_V+0x20(%rsp) + movdqa %xmm3, ffi_closure_OFS_V+0x30(%rsp) + movdqa %xmm4, ffi_closure_OFS_V+0x40(%rsp) + movdqa %xmm5, ffi_closure_OFS_V+0x50(%rsp) + movdqa %xmm6, ffi_closure_OFS_V+0x60(%rsp) + movdqa %xmm7, ffi_closure_OFS_V+0x70(%rsp) + jmp L(sse_entry2) + +L(UW14): +ENDF(C(ffi_go_closure_unix64_sse)) + + .balign 2 + .globl C(ffi_go_closure_unix64) + FFI_HIDDEN(C(ffi_go_closure_unix64)) + +C(ffi_go_closure_unix64): +L(UW15): + subq $ffi_closure_FS, %rsp +L(UW16): + /* cfi_adjust_cfa_offset(ffi_closure_FS) */ +L(sse_entry2): + movq %rdi, ffi_closure_OFS_G+0x00(%rsp) + movq %rsi, ffi_closure_OFS_G+0x08(%rsp) + movq %rdx, ffi_closure_OFS_G+0x10(%rsp) + movq %rcx, ffi_closure_OFS_G+0x18(%rsp) + movq %r8, ffi_closure_OFS_G+0x20(%rsp) + movq %r9, ffi_closure_OFS_G+0x28(%rsp) + +#ifdef __ILP32__ + movl 4(%r10), %edi /* Load cif */ + movl 8(%r10), %esi /* Load fun */ + movl %r10d, %edx /* Load closure (user_data) */ +#else + movq 8(%r10), %rdi /* Load cif */ + movq 16(%r10), %rsi /* Load fun */ + movq %r10, %rdx /* Load closure (user_data) */ +#endif + jmp L(do_closure) + +L(UW17): +ENDF(C(ffi_go_closure_unix64)) + +/* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */ + +#ifdef __APPLE__ +.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +EHFrame0: +#elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) +.section .eh_frame,"a",@unwind +#else +.section .eh_frame,"a",@progbits +#endif + +#ifdef HAVE_AS_X86_PCREL +# define PCREL(X) X - . +#else +# define PCREL(X) X@rel +#endif + +/* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */ +#define ADV(N, P) .byte 2, L(N)-L(P) + + .balign 8 +L(CIE): + .set L(set0),L(ECIE)-L(SCIE) + .long L(set0) /* CIE Length */ +L(SCIE): + .long 0 /* CIE Identifier Tag */ + .byte 1 /* CIE Version */ + .ascii "zR\0" /* CIE Augmentation */ + .byte 1 /* CIE Code Alignment Factor */ + .byte 0x78 /* CIE Data Alignment Factor */ + .byte 0x10 /* CIE RA Column */ + .byte 1 /* Augmentation size */ + .byte 0x1b /* FDE Encoding (pcrel sdata4) */ + .byte 0xc, 7, 8 /* DW_CFA_def_cfa, %rsp offset 8 */ + .byte 0x80+16, 1 /* DW_CFA_offset, %rip offset 1*-8 */ + .balign 8 +L(ECIE): + + .set L(set1),L(EFDE1)-L(SFDE1) + .long L(set1) /* FDE Length */ +L(SFDE1): + .long L(SFDE1)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW0)) /* Initial location */ + .long L(UW4)-L(UW0) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW1, UW0) + .byte 0xc, 6, 32 /* DW_CFA_def_cfa, %rbp 32 */ + .byte 0x80+6, 2 /* DW_CFA_offset, %rbp 2*-8 */ + ADV(UW2, UW1) + .byte 0xa /* DW_CFA_remember_state */ + .byte 0xc, 7, 8 /* DW_CFA_def_cfa, %rsp 8 */ + .byte 0xc0+6 /* DW_CFA_restore, %rbp */ + ADV(UW3, UW2) + .byte 0xb /* DW_CFA_restore_state */ + .balign 8 +L(EFDE1): + + .set L(set2),L(EFDE2)-L(SFDE2) + .long L(set2) /* FDE Length */ +L(SFDE2): + .long L(SFDE2)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW5)) /* Initial location */ + .long L(UW7)-L(UW5) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW6, UW5) + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ + .balign 8 +L(EFDE2): + + .set L(set3),L(EFDE3)-L(SFDE3) + .long L(set3) /* FDE Length */ +L(SFDE3): + .long L(SFDE3)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW8)) /* Initial location */ + .long L(UW11)-L(UW8) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW9, UW8) + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ + ADV(UW10, UW9) + .byte 0xe, 8 /* DW_CFA_def_cfa_offset 8 */ +L(EFDE3): + + .set L(set4),L(EFDE4)-L(SFDE4) + .long L(set4) /* FDE Length */ +L(SFDE4): + .long L(SFDE4)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW12)) /* Initial location */ + .long L(UW14)-L(UW12) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW13, UW12) + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ + .balign 8 +L(EFDE4): + + .set L(set5),L(EFDE5)-L(SFDE5) + .long L(set5) /* FDE Length */ +L(SFDE5): + .long L(SFDE5)-L(CIE) /* FDE CIE offset */ + .long PCREL(L(UW15)) /* Initial location */ + .long L(UW17)-L(UW15) /* Address range */ + .byte 0 /* Augmentation size */ + ADV(UW16, UW15) + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ + .balign 8 +L(EFDE5): +#ifdef __APPLE__ + .subsections_via_symbols +#endif + +#endif /* __x86_64__ */ +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/user/mpy/lib/libffi/src/x86/win64.S b/user/mpy/lib/libffi/src/x86/win64.S new file mode 100644 index 0000000..a5a20b6 --- /dev/null +++ b/user/mpy/lib/libffi/src/x86/win64.S @@ -0,0 +1,219 @@ +#define LIBFFI_ASM +#include +#include +#include + +#if defined(HAVE_AS_CFI_PSEUDO_OP) + .cfi_sections .debug_frame +#endif + +#define arg0 %rcx +#define arg1 %rdx +#define arg2 %r8 +#define arg3 %r9 + +#ifdef SYMBOL_UNDERSCORE +#define SYMBOL_NAME(name) _##name +#else +#define SYMBOL_NAME(name) name +#endif + +.macro E which + .align 8 + .org 0b + \which * 8 +.endm + + .text + +/* ffi_call_win64 (void *stack, struct win64_call_frame *frame, void *r10) + + Bit o trickiness here -- FRAME is the base of the stack frame + for this function. This has been allocated by ffi_call. We also + deallocate some of the stack that has been alloca'd. */ + + .align 8 + .globl ffi_call_win64 + + .seh_proc ffi_call_win64 +ffi_call_win64: + cfi_startproc + /* Set up the local stack frame and install it in rbp/rsp. */ + movq (%rsp), %rax + movq %rbp, (arg1) + movq %rax, 8(arg1) + movq arg1, %rbp + cfi_def_cfa(%rbp, 16) + cfi_rel_offset(%rbp, 0) + .seh_pushreg %rbp + .seh_setframe %rbp, 0 + .seh_endprologue + movq arg0, %rsp + + movq arg2, %r10 + + /* Load all slots into both general and xmm registers. */ + movq (%rsp), %rcx + movsd (%rsp), %xmm0 + movq 8(%rsp), %rdx + movsd 8(%rsp), %xmm1 + movq 16(%rsp), %r8 + movsd 16(%rsp), %xmm2 + movq 24(%rsp), %r9 + movsd 24(%rsp), %xmm3 + + call *16(%rbp) + + movl 24(%rbp), %ecx + movq 32(%rbp), %r8 + leaq 0f(%rip), %r10 + cmpl $FFI_TYPE_SMALL_STRUCT_4B, %ecx + leaq (%r10, %rcx, 8), %r10 + ja 99f + jmp *%r10 + +/* Below, we're space constrained most of the time. Thus we eschew the + modern "mov, pop, ret" sequence (5 bytes) for "leave, ret" (2 bytes). */ +.macro epilogue + leaveq + cfi_remember_state + cfi_def_cfa(%rsp, 8) + cfi_restore(%rbp) + ret + cfi_restore_state +.endm + + .align 8 +0: +E FFI_TYPE_VOID + epilogue +E FFI_TYPE_INT + movslq %eax, %rax + movq %rax, (%r8) + epilogue +E FFI_TYPE_FLOAT + movss %xmm0, (%r8) + epilogue +E FFI_TYPE_DOUBLE + movsd %xmm0, (%r8) + epilogue +E FFI_TYPE_LONGDOUBLE + call abort +E FFI_TYPE_UINT8 + movzbl %al, %eax + movq %rax, (%r8) + epilogue +E FFI_TYPE_SINT8 + movsbq %al, %rax + jmp 98f +E FFI_TYPE_UINT16 + movzwl %ax, %eax + movq %rax, (%r8) + epilogue +E FFI_TYPE_SINT16 + movswq %ax, %rax + jmp 98f +E FFI_TYPE_UINT32 + movl %eax, %eax + movq %rax, (%r8) + epilogue +E FFI_TYPE_SINT32 + movslq %eax, %rax + movq %rax, (%r8) + epilogue +E FFI_TYPE_UINT64 +98: movq %rax, (%r8) + epilogue +E FFI_TYPE_SINT64 + movq %rax, (%r8) + epilogue +E FFI_TYPE_STRUCT + epilogue +E FFI_TYPE_POINTER + movq %rax, (%r8) + epilogue +E FFI_TYPE_COMPLEX + call abort +E FFI_TYPE_SMALL_STRUCT_1B + movb %al, (%r8) + epilogue +E FFI_TYPE_SMALL_STRUCT_2B + movw %ax, (%r8) + epilogue +E FFI_TYPE_SMALL_STRUCT_4B + movl %eax, (%r8) + epilogue + + .align 8 +99: call abort + +.purgem epilogue + + cfi_endproc + .seh_endproc + + +/* 32 bytes of outgoing register stack space, 8 bytes of alignment, + 16 bytes of result, 32 bytes of xmm registers. */ +#define ffi_clo_FS (32+8+16+32) +#define ffi_clo_OFF_R (32+8) +#define ffi_clo_OFF_X (32+8+16) + + .align 8 + .globl ffi_go_closure_win64 + + .seh_proc ffi_go_closure_win64 +ffi_go_closure_win64: + cfi_startproc + /* Save all integer arguments into the incoming reg stack space. */ + movq arg0, 8(%rsp) + movq arg1, 16(%rsp) + movq arg2, 24(%rsp) + movq arg3, 32(%rsp) + + movq 8(%r10), arg0 /* load cif */ + movq 16(%r10), arg1 /* load fun */ + movq %r10, arg2 /* closure is user_data */ + jmp 0f + cfi_endproc + .seh_endproc + + .align 8 + .globl ffi_closure_win64 + + .seh_proc ffi_closure_win64 +ffi_closure_win64: + cfi_startproc + /* Save all integer arguments into the incoming reg stack space. */ + movq arg0, 8(%rsp) + movq arg1, 16(%rsp) + movq arg2, 24(%rsp) + movq arg3, 32(%rsp) + + movq FFI_TRAMPOLINE_SIZE(%r10), arg0 /* load cif */ + movq FFI_TRAMPOLINE_SIZE+8(%r10), arg1 /* load fun */ + movq FFI_TRAMPOLINE_SIZE+16(%r10), arg2 /* load user_data */ +0: + subq $ffi_clo_FS, %rsp + cfi_adjust_cfa_offset(ffi_clo_FS) + .seh_stackalloc ffi_clo_FS + .seh_endprologue + + /* Save all sse arguments into the stack frame. */ + movsd %xmm0, ffi_clo_OFF_X(%rsp) + movsd %xmm1, ffi_clo_OFF_X+8(%rsp) + movsd %xmm2, ffi_clo_OFF_X+16(%rsp) + movsd %xmm3, ffi_clo_OFF_X+24(%rsp) + + leaq ffi_clo_OFF_R(%rsp), arg3 + call ffi_closure_win64_inner + + /* Load the result into both possible result registers. */ + movq ffi_clo_OFF_R(%rsp), %rax + movsd ffi_clo_OFF_R(%rsp), %xmm0 + + addq $ffi_clo_FS, %rsp + cfi_adjust_cfa_offset(-ffi_clo_FS) + ret + + cfi_endproc + .seh_endproc diff --git a/user/mpy/lib/libffi/src/xtensa/ffi.c b/user/mpy/lib/libffi/src/xtensa/ffi.c new file mode 100644 index 0000000..fd94daf --- /dev/null +++ b/user/mpy/lib/libffi/src/xtensa/ffi.c @@ -0,0 +1,298 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 2013 Tensilica, Inc. + + XTENSA Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#include +#include + +/* + |----------------------------------------| + | | + on entry to ffi_call ----> |----------------------------------------| + | caller stack frame for registers a0-a3 | + |----------------------------------------| + | | + | additional arguments | + entry of the function ---> |----------------------------------------| + | copy of function arguments a2-a7 | + | - - - - - - - - - - - - - | + | | + + The area below the entry line becomes the new stack frame for the function. + +*/ + + +#define FFI_TYPE_STRUCT_REGS FFI_TYPE_LAST + + +extern void ffi_call_SYSV(void *rvalue, unsigned rsize, unsigned flags, + void(*fn)(void), unsigned nbytes, extended_cif*); +extern void ffi_closure_SYSV(void) FFI_HIDDEN; + +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + switch(cif->rtype->type) { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + cif->flags = cif->rtype->type; + break; + case FFI_TYPE_VOID: + case FFI_TYPE_FLOAT: + cif->flags = FFI_TYPE_UINT32; + break; + case FFI_TYPE_DOUBLE: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + cif->flags = FFI_TYPE_UINT64; // cif->rtype->type; + break; + case FFI_TYPE_STRUCT: + cif->flags = FFI_TYPE_STRUCT; //_REGS; + /* Up to 16 bytes are returned in registers */ + if (cif->rtype->size > 4 * 4) { + /* returned structure is referenced by a register; use 8 bytes + (including 4 bytes for potential additional alignment) */ + cif->flags = FFI_TYPE_STRUCT; + cif->bytes += 8; + } + break; + + default: + cif->flags = FFI_TYPE_UINT32; + break; + } + + /* Round the stack up to a full 4 register frame, just in case + (we use this size in movsp). This way, it's also a multiple of + 8 bytes for 64-bit arguments. */ + cif->bytes = ALIGN(cif->bytes, 16); + + return FFI_OK; +} + +void ffi_prep_args(extended_cif *ecif, unsigned char* stack) +{ + unsigned int i; + unsigned long *addr; + ffi_type **ptr; + + union { + void **v; + char **c; + signed char **sc; + unsigned char **uc; + signed short **ss; + unsigned short **us; + unsigned int **i; + long long **ll; + float **f; + double **d; + } p_argv; + + /* Verify that everything is aligned up properly */ + FFI_ASSERT (((unsigned long) stack & 0x7) == 0); + + p_argv.v = ecif->avalue; + addr = (unsigned long*)stack; + + /* structures with a size greater than 16 bytes are passed in memory */ + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 16) + { + *addr++ = (unsigned long)ecif->rvalue; + } + + for (i = ecif->cif->nargs, ptr = ecif->cif->arg_types; + i > 0; + i--, ptr++, p_argv.v++) + { + switch ((*ptr)->type) + { + case FFI_TYPE_SINT8: + *addr++ = **p_argv.sc; + break; + case FFI_TYPE_UINT8: + *addr++ = **p_argv.uc; + break; + case FFI_TYPE_SINT16: + *addr++ = **p_argv.ss; + break; + case FFI_TYPE_UINT16: + *addr++ = **p_argv.us; + break; + case FFI_TYPE_FLOAT: + case FFI_TYPE_INT: + case FFI_TYPE_UINT32: + case FFI_TYPE_SINT32: + case FFI_TYPE_POINTER: + *addr++ = **p_argv.i; + break; + case FFI_TYPE_DOUBLE: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + if (((unsigned long)addr & 4) != 0) + addr++; + *(unsigned long long*)addr = **p_argv.ll; + addr += sizeof(unsigned long long) / sizeof (addr); + break; + + case FFI_TYPE_STRUCT: + { + unsigned long offs; + unsigned long size; + + if (((unsigned long)addr & 4) != 0 && (*ptr)->alignment > 4) + addr++; + + offs = (unsigned long) addr - (unsigned long) stack; + size = (*ptr)->size; + + /* Entire structure must fit the argument registers or referenced */ + if (offs < FFI_REGISTER_NARGS * 4 + && offs + size > FFI_REGISTER_NARGS * 4) + addr = (unsigned long*) (stack + FFI_REGISTER_NARGS * 4); + + memcpy((char*) addr, *p_argv.c, size); + addr += (size + 3) / 4; + break; + } + + default: + FFI_ASSERT(0); + } + } +} + + +void ffi_call(ffi_cif* cif, void(*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + unsigned long rsize = cif->rtype->size; + int flags = cif->flags; + void *alloc = NULL; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* Note that for structures that are returned in registers (size <= 16 bytes) + we allocate a temporary buffer and use memcpy to copy it to the final + destination. The reason is that the target address might be misaligned or + the length not a multiple of 4 bytes. Handling all those cases would be + very complex. */ + + if (flags == FFI_TYPE_STRUCT && (rsize <= 16 || rvalue == NULL)) + { + alloc = alloca(ALIGN(rsize, 4)); + ecif.rvalue = alloc; + } + else + { + ecif.rvalue = rvalue; + } + + if (cif->abi != FFI_SYSV) + FFI_ASSERT(0); + + ffi_call_SYSV (ecif.rvalue, rsize, cif->flags, fn, cif->bytes, &ecif); + + if (alloc != NULL && rvalue != NULL) + memcpy(rvalue, alloc, rsize); +} + +extern void ffi_trampoline(); +extern void ffi_cacheflush(void* start, void* end); + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*, void*, void**, void*), + void *user_data, + void *codeloc) +{ + /* copye trampoline to stack and patch 'ffi_closure_SYSV' pointer */ + memcpy(closure->tramp, ffi_trampoline, FFI_TRAMPOLINE_SIZE); + *(unsigned int*)(&closure->tramp[8]) = (unsigned int)ffi_closure_SYSV; + + // Do we have this function? + // __builtin___clear_cache(closer->tramp, closer->tramp + FFI_TRAMPOLINE_SIZE) + ffi_cacheflush(closure->tramp, closure->tramp + FFI_TRAMPOLINE_SIZE); + + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; + return FFI_OK; +} + + +long FFI_HIDDEN +ffi_closure_SYSV_inner(ffi_closure *closure, void **values, void *rvalue) +{ + ffi_cif *cif; + ffi_type **arg_types; + void **avalue; + int i, areg; + + cif = closure->cif; + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + areg = 0; + + int rtype = cif->rtype->type; + if (rtype == FFI_TYPE_STRUCT && cif->rtype->size > 4 * 4) + { + rvalue = *values; + areg++; + } + + cif = closure->cif; + arg_types = cif->arg_types; + avalue = alloca(cif->nargs * sizeof(void *)); + + for (i = 0; i < cif->nargs; i++) + { + if (arg_types[i]->alignment == 8 && (areg & 1) != 0) + areg++; + + // skip the entry 16,a1 framework, add 16 bytes (4 registers) + if (areg == FFI_REGISTER_NARGS) + areg += 4; + + if (arg_types[i]->type == FFI_TYPE_STRUCT) + { + int numregs = ((arg_types[i]->size + 3) & ~3) / 4; + if (areg < FFI_REGISTER_NARGS && areg + numregs > FFI_REGISTER_NARGS) + areg = FFI_REGISTER_NARGS + 4; + } + + avalue[i] = &values[areg]; + areg += (arg_types[i]->size + 3) / 4; + } + + (closure->fun)(cif, rvalue, avalue, closure->user_data); + + return rtype; +} diff --git a/user/mpy/lib/libffi/src/xtensa/ffitarget.h b/user/mpy/lib/libffi/src/xtensa/ffitarget.h new file mode 100644 index 0000000..0ba728b --- /dev/null +++ b/user/mpy/lib/libffi/src/xtensa/ffitarget.h @@ -0,0 +1,53 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2013 Tensilica, Inc. + Target configuration macros for XTENSA. + + 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 LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; +#endif + +#define FFI_REGISTER_NARGS 6 + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 +#define FFI_TRAMPOLINE_SIZE 24 + +#endif diff --git a/user/mpy/lib/libffi/src/xtensa/sysv.S b/user/mpy/lib/libffi/src/xtensa/sysv.S new file mode 100644 index 0000000..64e6a09 --- /dev/null +++ b/user/mpy/lib/libffi/src/xtensa/sysv.S @@ -0,0 +1,253 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2013 Tensilica, Inc. + + XTENSA Foreign Function Interface + + 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. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +#define ENTRY(name) .text; .globl name; .type name,@function; .align 4; name: +#define END(name) .size name , . - name + +/* Assert that the table below is in sync with ffi.h. */ + +#if FFI_TYPE_UINT8 != 5 \ + || FFI_TYPE_SINT8 != 6 \ + || FFI_TYPE_UINT16 != 7 \ + || FFI_TYPE_SINT16 != 8 \ + || FFI_TYPE_UINT32 != 9 \ + || FFI_TYPE_SINT32 != 10 \ + || FFI_TYPE_UINT64 != 11 +#error "xtensa/sysv.S out of sync with ffi.h" +#endif + + +/* ffi_call_SYSV (rvalue, rbytes, flags, (*fnaddr)(), bytes, ecif) + void *rvalue; a2 + unsigned long rbytes; a3 + unsigned flags; a4 + void (*fnaddr)(); a5 + unsigned long bytes; a6 + extended_cif* ecif) a7 +*/ + +ENTRY(ffi_call_SYSV) + + entry a1, 32 # 32 byte frame for using call8 below + + mov a10, a7 # a10(->arg0): ecif + sub a11, a1, a6 # a11(->arg1): stack pointer + mov a7, a1 # fp + movsp a1, a11 # set new sp = old_sp - bytes + + movi a8, ffi_prep_args + callx8 a8 # ffi_prep_args(ecif, stack) + + # prepare to move stack pointer back up to 6 arguments + # note that 'bytes' is already aligned + + movi a10, 6*4 + sub a11, a6, a10 + movgez a6, a10, a11 + add a6, a1, a6 + + + # we can pass up to 6 arguments in registers + # for simplicity, just load 6 arguments + # (the stack size is at least 32 bytes, so no risk to cross boundaries) + + l32i a10, a1, 0 + l32i a11, a1, 4 + l32i a12, a1, 8 + l32i a13, a1, 12 + l32i a14, a1, 16 + l32i a15, a1, 20 + + # move stack pointer + + movsp a1, a6 + + callx8 a5 # (*fn)(args...) + + # Handle return value(s) + + beqz a2, .Lexit + + movi a5, FFI_TYPE_STRUCT + bne a4, a5, .Lstore + movi a5, 16 + blt a5, a3, .Lexit + + s32i a10, a2, 0 + blti a3, 5, .Lexit + addi a3, a3, -1 + s32i a11, a2, 4 + blti a3, 8, .Lexit + s32i a12, a2, 8 + blti a3, 12, .Lexit + s32i a13, a2, 12 + +.Lexit: retw + +.Lstore: + addi a4, a4, -FFI_TYPE_UINT8 + bgei a4, 7, .Lexit # should never happen + movi a6, store_calls + add a4, a4, a4 + addx4 a6, a4, a6 # store_table + idx * 8 + jx a6 + + .align 8 +store_calls: + # UINT8 + s8i a10, a2, 0 + retw + + # SINT8 + .align 8 + s8i a10, a2, 0 + retw + + # UINT16 + .align 8 + s16i a10, a2, 0 + retw + + # SINT16 + .align 8 + s16i a10, a2, 0 + retw + + # UINT32 + .align 8 + s32i a10, a2, 0 + retw + + # SINT32 + .align 8 + s32i a10, a2, 0 + retw + + # UINT64 + .align 8 + s32i a10, a2, 0 + s32i a11, a2, 4 + retw + +END(ffi_call_SYSV) + + +/* + * void ffi_cacheflush (unsigned long start, unsigned long end) + */ + +#define EXTRA_ARGS_SIZE 24 + +ENTRY(ffi_cacheflush) + + entry a1, 16 + +1: dhwbi a2, 0 + ihi a2, 0 + addi a2, a2, 4 + blt a2, a3, 1b + + retw + +END(ffi_cacheflush) + +/* ffi_trampoline is copied to the stack */ + +ENTRY(ffi_trampoline) + + entry a1, 16 + (FFI_REGISTER_NARGS * 4) + (4 * 4) # [ 0] + j 2f # [ 3] + .align 4 # [ 6] +1: .long 0 # [ 8] +2: l32r a15, 1b # [12] + _mov a14, a0 # [15] + callx0 a15 # [18] + # [21] +END(ffi_trampoline) + +/* + * ffi_closure() + * + * a0: closure + 21 + * a14: return address (a0) + */ + +ENTRY(ffi_closure_SYSV) + + /* intentionally omitting entry here */ + + # restore return address (a0) and move pointer to closure to a10 + addi a10, a0, -21 + mov a0, a14 + + # allow up to 4 arguments as return values + addi a11, a1, 4 * 4 + + # save up to 6 arguments to stack (allocated by entry below) + s32i a2, a11, 0 + s32i a3, a11, 4 + s32i a4, a11, 8 + s32i a5, a11, 12 + s32i a6, a11, 16 + s32i a7, a11, 20 + + movi a8, ffi_closure_SYSV_inner + mov a12, a1 + callx8 a8 # .._inner(*closure, **avalue, *rvalue) + + # load up to four return arguments + l32i a2, a1, 0 + l32i a3, a1, 4 + l32i a4, a1, 8 + l32i a5, a1, 12 + + # (sign-)extend return value + movi a11, FFI_TYPE_UINT8 + bne a10, a11, 1f + extui a2, a2, 0, 8 + retw + +1: movi a11, FFI_TYPE_SINT8 + bne a10, a11, 1f + sext a2, a2, 7 + retw + +1: movi a11, FFI_TYPE_UINT16 + bne a10, a11, 1f + extui a2, a2, 0, 16 + retw + +1: movi a11, FFI_TYPE_SINT16 + bne a10, a11, 1f + sext a2, a2, 15 + +1: retw + +END(ffi_closure_SYSV) diff --git a/user/mpy/lib/libffi/stamp-h.in b/user/mpy/lib/libffi/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/user/mpy/lib/libffi/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/user/mpy/lib/libffi/testsuite/Makefile.am b/user/mpy/lib/libffi/testsuite/Makefile.am new file mode 100644 index 0000000..da10465 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/Makefile.am @@ -0,0 +1,85 @@ +## Process this file with automake to produce Makefile.in. + +AUTOMAKE_OPTIONS = foreign dejagnu + +EXTRA_DEJAGNU_SITE_CONFIG=../local.exp + +CLEANFILES = *.exe core* *.log *.sum + +EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \ +libffi.call/cls_align_longdouble_split.c \ +libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \ +libffi.call/closure_fn1.c \ +libffi.call/return_ul.c libffi.call/cls_align_double.c \ +libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \ +libffi.call/cls_64byte.c libffi.call/nested_struct7.c \ +libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \ +libffi.call/ffitest.h libffi.call/nested_struct4.c \ +libffi.call/cls_multi_ushort.c libffi.call/struct3.c \ +libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \ +libffi.call/struct8.c libffi.call/nested_struct8.c \ +libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \ +libffi.call/cls_pointer.c \ +libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ +libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \ +libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \ +libffi.call/call.exp libffi.call/cls_double.c \ +libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \ +libffi.call/return_ll1.c libffi.call/nested_struct3.c \ +libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \ +libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \ +libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \ +libffi.call/return_fl.c libffi.call/struct5.c \ +libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \ +libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \ +libffi.call/return_fl3.c libffi.call/stret_medium.c \ +libffi.call/nested_struct6.c libffi.call/closure_fn3.c \ +libffi.call/float3.c libffi.call/many2.c \ +libffi.call/closure_simple.c libffi.call/cls_align_uint16.c \ +libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \ +libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \ +libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \ +libffi.call/cls_sshort.c \ +libffi.call/nested_struct.c libffi.call/cls_20byte.c \ +libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \ +libffi.call/return_uc.c \ +libffi.call/cls_18byte.c libffi.call/cls_8byte.c \ +libffi.call/promotion.c \ +libffi.call/return_dbl.c libffi.call/cls_24byte.c \ +libffi.call/struct4.c libffi.call/cls_6byte.c \ +libffi.call/cls_align_uint32.c libffi.call/float.c \ +libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \ +libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \ +libffi.call/cls_align_float.c libffi.call/return_fl1.c \ +libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ +libffi.call/cls_align_sint64.c \ +libffi.call/stret_large2.c libffi.call/return_sl.c \ +libffi.call/closure_fn0.c libffi.call/cls_5byte.c \ +libffi.call/cls_2byte.c libffi.call/float2.c \ +libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \ +libffi.call/stret_large.c libffi.call/cls_ulonglong.c \ +libffi.call/cls_ushort.c libffi.call/nested_struct1.c \ +libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \ +libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \ +libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \ +libffi.call/struct1.c libffi.call/nested_struct9.c \ +libffi.call/huge_struct.c libffi.call/problem1.c \ +libffi.call/float4.c \ +libffi.call/return_ldl.c \ +libffi.call/closure_fn5.c \ +libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \ +libffi.call/return_sc.c libffi.call/struct7.c \ +libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ +libffi.call/cls_6_1_byte.c \ +libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \ +libffi.call/unwindtest_ffi_call.cc \ +lib/wrapper.exp lib/target-libpath.exp \ +lib/libffi.exp libffi.call/cls_struct_va1.c \ +libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ +libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ +libffi.call/nested_struct11.c libffi.call/uninitialized.c \ +libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \ +libffi.call/va_struct3.c \ +libffi.call/strlen2.c \ +libffi.call/strlen3.c \ +libffi.call/strlen4.c diff --git a/user/mpy/lib/libffi/testsuite/config/default.exp b/user/mpy/lib/libffi/testsuite/config/default.exp new file mode 100644 index 0000000..90967cc --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/config/default.exp @@ -0,0 +1 @@ +load_lib "standard.exp" diff --git a/user/mpy/lib/libffi/testsuite/lib/libffi.exp b/user/mpy/lib/libffi/testsuite/lib/libffi.exp new file mode 100644 index 0000000..1b8b008 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/lib/libffi.exp @@ -0,0 +1,431 @@ +# Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011, 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +proc load_gcc_lib { filename } { + global srcdir + load_file $srcdir/lib/$filename +} + +load_lib dg.exp +load_lib libgloss.exp +load_gcc_lib target-libpath.exp +load_gcc_lib wrapper.exp + + +# Define libffi callbacks for dg.exp. + +proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } { + + # To get all \n in dg-output test strings to match printf output + # in a system that outputs it as \015\012 (i.e. not just \012), we + # need to change all \n into \r?\n. As there is no dejagnu flag + # or hook to do that, we simply change the text being tested. + # Unfortunately, we have to know that the variable is called + # dg-output-text and lives in the caller of libffi-dg-test, which + # is two calls up. Overriding proc dg-output would be longer and + # would necessarily have the same assumption. + upvar 2 dg-output-text output_match + + if { [llength $output_match] > 1 } { + regsub -all "\n" [lindex $output_match 1] "\r?\n" x + set output_match [lreplace $output_match 1 1 $x] + } + + # Set up the compiler flags, based on what we're going to do. + + set options [list] + switch $do_what { + "compile" { + set compile_type "assembly" + set output_file "[file rootname [file tail $prog]].s" + } + "link" { + set compile_type "executable" + set output_file "[file rootname [file tail $prog]].exe" + # The following line is needed for targets like the i960 where + # the default output file is b.out. Sigh. + } + "run" { + set compile_type "executable" + # FIXME: "./" is to cope with "." not being in $PATH. + # Should this be handled elsewhere? + # YES. + set output_file "./[file rootname [file tail $prog]].exe" + # This is the only place where we care if an executable was + # created or not. If it was, dg.exp will try to run it. + remote_file build delete $output_file; + } + default { + perror "$do_what: not a valid dg-do keyword" + return "" + } + } + + if { $extra_tool_flags != "" } { + lappend options "additional_flags=$extra_tool_flags" + } + + set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options]; + + + return [list $comp_output $output_file] +} + + +proc libffi-dg-test { prog do_what extra_tool_flags } { + return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags] +} + +proc libffi-init { args } { + global gluefile wrap_flags; + global srcdir + global blddirffi + global objdir + global TOOL_OPTIONS + global tool + global libffi_include + global libffi_link_flags + global tool_root_dir + global ld_library_path + global compiler_vendor + + set blddirffi [pwd]/.. + verbose "libffi $blddirffi" + + # Which compiler are we building with? + set tmp [grep ../config.log "^ax_cv_c_compiler_vendor.*$"] + regexp -- {^[^=]*=(.*)$} $tmp nil compiler_vendor + + if { [string match $compiler_vendor "gnu"] } { + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + verbose "gccdir $gccdir" + + set ld_library_path "." + append ld_library_path ":${gccdir}" + + set compiler "${gccdir}/xgcc" + if { [is_remote host] == 0 && [which $compiler] != 0 } { + foreach i "[exec $compiler --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append ld_library_path ":${gccdir}/${mldir}" + } + } + } + } + + # add the library path for libffi. + append ld_library_path ":${blddirffi}/.libs" + + verbose "ld_library_path: $ld_library_path" + + # Point to the Libffi headers in libffi. + set libffi_include "${blddirffi}/include" + verbose "libffi_include $libffi_include" + + set libffi_dir "${blddirffi}/.libs" + verbose "libffi_dir $libffi_dir" + if { $libffi_dir != "" } { + set libffi_dir [file dirname ${libffi_dir}] + set libffi_link_flags "-L${libffi_dir}/.libs" + } + + set_ld_library_path_env_vars + libffi_maybe_build_wrapper "${objdir}/testglue.o" +} + +proc libffi_exit { } { + global gluefile; + + if [info exists gluefile] { + file_on_build delete $gluefile; + unset gluefile; + } +} + +proc libffi_target_compile { source dest type options } { + global gluefile wrap_flags; + global srcdir + global blddirffi + global TOOL_OPTIONS + global libffi_link_flags + global libffi_include + global target_triplet + + + if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=$wrap_flags" + } + + # TOOL_OPTIONS must come first, so that it doesn't override testcase + # specific options. + if [info exists TOOL_OPTIONS] { + lappend options [concat "additional_flags=$TOOL_OPTIONS" $options]; + } + + # search for ffi_mips.h in srcdir, too + lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.." + lappend options "additional_flags=${libffi_link_flags}" + + # Darwin needs a stack execution allowed flag. + + if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"] + || [istarget "*-*-darwin2*"] } { + lappend options "additional_flags=-Wl,-allow_stack_execute" + } + + # If you're building the compiler with --prefix set to a place + # where it's not yet installed, then the linker won't be able to + # find the libgcc used by libffi.dylib. We could pass the + # -dylib_file option, but that's complicated, and it's much easier + # to just make the linker find libgcc using -L options. + if { [string match "*-*-darwin*" $target_triplet] } { + lappend options "libs= -shared-libgcc" + } + + if { [string match "*-*-openbsd*" $target_triplet] } { + lappend options "libs= -lpthread" + } + + lappend options "libs= -lffi" + + if { [string match "aarch64*-*-linux*" $target_triplet] } { + lappend options "libs= -lpthread" + } + + if { [string match "*.cc" $source] } { + lappend options "c++" + } + + verbose "options: $options" + return [target_compile $source $dest $type $options] +} + +# TEST should be a preprocessor condition. Returns true if it holds. +proc libffi_feature_test { test } { + set src "ffitest.c" + + set f [open $src "w"] + puts $f "#include " + puts $f $test + puts $f "xyzzy" + puts $f "#endif" + close $f + + set lines [libffi_target_compile $src "" "preprocess" ""] + file delete $src + + set last [lindex $lines end] + return [regexp -- "xyzzy" $last] +} + +# Utility routines. + +# +# search_for -- looks for a string match in a file +# +proc search_for { file pattern } { + set fd [open $file r] + while { [gets $fd cur_line]>=0 } { + if [string match "*$pattern*" $cur_line] then { + close $fd + return 1 + } + } + close $fd + return 0 +} + +# Modified dg-runtest that can cycle through a list of optimization options +# as c-torture does. +proc libffi-dg-runtest { testcases default-extra-flags } { + global runtests + + foreach test $testcases { + # If we're only testing specific files and this isn't one of + # them, skip it. + if ![runtest_file_p $runtests $test] { + continue + } + + # Look for a loop within the source code - if we don't find one, + # don't pass -funroll[-all]-loops. + global torture_with_loops torture_without_loops + if [expr [search_for $test "for*("]+[search_for $test "while*("]] { + set option_list $torture_with_loops + } else { + set option_list $torture_without_loops + } + + set nshort [file tail [file dirname $test]]/[file tail $test] + + foreach flags $option_list { + verbose "Testing $nshort, $flags" 1 + dg-test $test $flags ${default-extra-flags} + } + } +} + +proc run-many-tests { testcases extra_flags } { + global compiler_vendor + switch $compiler_vendor { + "clang" { + set common "-W -Wall" + set optimizations { "-O0" "-O1" "-O2" "-O3" "-Os" } + } + "gnu" { + set common "-W -Wall -Wno-psabi" + set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" } + } + default { + # Assume we are using the vendor compiler. + set common "" + set optimizations { "" } + } + } + + set targetabis { "" } + if [string match $compiler_vendor "gnu"] { + if [istarget "i?86-*-*"] { + set targetabis { + "" + "-DABI_NUM=FFI_STDCALL -DABI_ATTR=__STDCALL__" + "-DABI_NUM=FFI_THISCALL -DABI_ATTR=__THISCALL__" + "-DABI_NUM=FFI_FASTCALL -DABI_ATTR=__FASTCALL__" + } + } + } + + set common [ concat $common $extra_flags ] + foreach test $testcases { + set testname [file tail $test] + if [search_for $test "ABI_NUM"] { + set abis $targetabis + } else { + set abis { "" } + } + foreach opt $optimizations { + foreach abi $abis { + set options [concat $common $opt $abi] + verbose "Testing $testname, $options" 1 + dg-test $test $options "" + } + } + } +} + +# Like check_conditional_xfail, but callable from a dg test. + +proc dg-xfail-if { args } { + set args [lreplace $args 0 0] + set selector "target [join [lindex $args 1]]" + if { [dg-process-target $selector] == "S" } { + global compiler_conditional_xfail_data + set compiler_conditional_xfail_data $args + } +} + +proc check-flags { args } { + + # The args are within another list; pull them out. + set args [lindex $args 0] + + # The next two arguments are optional. If they were not specified, + # use the defaults. + if { [llength $args] == 2 } { + lappend $args [list "*"] + } + if { [llength $args] == 3 } { + lappend $args [list ""] + } + + # If the option strings are the defaults, or the same as the + # defaults, there is no need to call check_conditional_xfail to + # compare them to the actual options. + if { [string compare [lindex $args 2] "*"] == 0 + && [string compare [lindex $args 3] "" ] == 0 } { + set result 1 + } else { + # The target list might be an effective-target keyword, so replace + # the original list with "*-*-*", since we already know it matches. + set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]] + } + + return $result +} + +proc dg-skip-if { args } { + # Verify the number of arguments. The last two are optional. + set args [lreplace $args 0 0] + if { [llength $args] < 2 || [llength $args] > 4 } { + error "dg-skip-if 2: need 2, 3, or 4 arguments" + } + + # Don't bother if we're already skipping the test. + upvar dg-do-what dg-do-what + if { [lindex ${dg-do-what} 1] == "N" } { + return + } + + set selector [list target [lindex $args 1]] + if { [dg-process-target $selector] == "S" } { + if [check-flags $args] { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + } + } +} + +# We need to make sure that additional_files and additional_sources +# are both cleared out after every test. It is not enough to clear +# them out *before* the next test run because gcc-target-compile gets +# run directly from some .exp files (outside of any test). (Those +# uses should eventually be eliminated.) + +# Because the DG framework doesn't provide a hook that is run at the +# end of a test, we must replace dg-test with a wrapper. + +if { [info procs saved-dg-test] == [list] } { + rename dg-test saved-dg-test + + proc dg-test { args } { + global additional_files + global additional_sources + global errorInfo + + if { [ catch { eval saved-dg-test $args } errmsg ] } { + set saved_info $errorInfo + set additional_files "" + set additional_sources "" + error $errmsg $saved_info + } + set additional_files "" + set additional_sources "" + } +} + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/user/mpy/lib/libffi/testsuite/lib/target-libpath.exp b/user/mpy/lib/libffi/testsuite/lib/target-libpath.exp new file mode 100644 index 0000000..6b7beba --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/lib/target-libpath.exp @@ -0,0 +1,283 @@ +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca) + +set orig_environment_saved 0 +set orig_ld_library_path_saved 0 +set orig_ld_run_path_saved 0 +set orig_shlib_path_saved 0 +set orig_ld_libraryn32_path_saved 0 +set orig_ld_library64_path_saved 0 +set orig_ld_library_path_32_saved 0 +set orig_ld_library_path_64_saved 0 +set orig_dyld_library_path_saved 0 +set orig_path_saved 0 + +####################################### +# proc set_ld_library_path_env_vars { } +####################################### + +proc set_ld_library_path_env_vars { } { + global ld_library_path + global orig_environment_saved + global orig_ld_library_path_saved + global orig_ld_run_path_saved + global orig_shlib_path_saved + global orig_ld_libraryn32_path_saved + global orig_ld_library64_path_saved + global orig_ld_library_path_32_saved + global orig_ld_library_path_64_saved + global orig_dyld_library_path_saved + global orig_path_saved + global orig_ld_library_path + global orig_ld_run_path + global orig_shlib_path + global orig_ld_libraryn32_path + global orig_ld_library64_path + global orig_ld_library_path_32 + global orig_ld_library_path_64 + global orig_dyld_library_path + global orig_path + global GCC_EXEC_PREFIX + + # Set the relocated compiler prefix, but only if the user hasn't specified one. + if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } { + setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX" + } + + # Setting the ld library path causes trouble when testing cross-compilers. + if { [is_remote target] } { + return + } + + if { $orig_environment_saved == 0 } { + global env + + set orig_environment_saved 1 + + # Save the original environment. + if [info exists env(LD_LIBRARY_PATH)] { + set orig_ld_library_path "$env(LD_LIBRARY_PATH)" + set orig_ld_library_path_saved 1 + } + if [info exists env(LD_RUN_PATH)] { + set orig_ld_run_path "$env(LD_RUN_PATH)" + set orig_ld_run_path_saved 1 + } + if [info exists env(SHLIB_PATH)] { + set orig_shlib_path "$env(SHLIB_PATH)" + set orig_shlib_path_saved 1 + } + if [info exists env(LD_LIBRARYN32_PATH)] { + set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)" + set orig_ld_libraryn32_path_saved 1 + } + if [info exists env(LD_LIBRARY64_PATH)] { + set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)" + set orig_ld_library64_path_saved 1 + } + if [info exists env(LD_LIBRARY_PATH_32)] { + set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)" + set orig_ld_library_path_32_saved 1 + } + if [info exists env(LD_LIBRARY_PATH_64)] { + set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)" + set orig_ld_library_path_64_saved 1 + } + if [info exists env(DYLD_LIBRARY_PATH)] { + set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)" + set orig_dyld_library_path_saved 1 + } + if [info exists env(PATH)] { + set orig_path "$env(PATH)" + set orig_path_saved 1 + } + } + + # We need to set ld library path in the environment. Currently, + # unix.exp doesn't set the environment correctly for all systems. + # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a + # program. We also need the environment set for compilations, etc. + # + # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but + # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH + # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH), + # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64), + # and HP-UX (SHLIB_PATH). In some cases, the variables are independent + # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the + # variable is not defined. + # + # Doing this is somewhat of a hack as ld_library_path gets repeated in + # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables. + if { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY_PATH "$ld_library_path" + } + if { $orig_ld_run_path_saved } { + setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path" + } else { + setenv LD_RUN_PATH "$ld_library_path" + } + # The default shared library dynamic path search for 64-bit + # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH. + # LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we + # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent. + if { $orig_shlib_path_saved } { + setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path" + } else { + setenv SHLIB_PATH "$ld_library_path" + } + if { $orig_ld_libraryn32_path_saved } { + setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARYN32_PATH "$ld_library_path" + } + if { $orig_ld_library64_path_saved } { + setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY64_PATH "$ld_library_path" + } + if { $orig_ld_library_path_32_saved } { + setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY_PATH_32 "$ld_library_path" + } + if { $orig_ld_library_path_64_saved } { + setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY_PATH_64 "$ld_library_path" + } + if { $orig_dyld_library_path_saved } { + setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path" + } else { + setenv DYLD_LIBRARY_PATH "$ld_library_path" + } + if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } { + if { $orig_path_saved } { + setenv PATH "$ld_library_path:$orig_path" + } else { + setenv PATH "$ld_library_path" + } + } + + verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path" +} + +####################################### +# proc restore_ld_library_path_env_vars { } +####################################### + +proc restore_ld_library_path_env_vars { } { + global orig_environment_saved + global orig_ld_library_path_saved + global orig_ld_run_path_saved + global orig_shlib_path_saved + global orig_ld_libraryn32_path_saved + global orig_ld_library64_path_saved + global orig_ld_library_path_32_saved + global orig_ld_library_path_64_saved + global orig_dyld_library_path_saved + global orig_path_saved + global orig_ld_library_path + global orig_ld_run_path + global orig_shlib_path + global orig_ld_libraryn32_path + global orig_ld_library64_path + global orig_ld_library_path_32 + global orig_ld_library_path_64 + global orig_dyld_library_path + global orig_path + + if { $orig_environment_saved == 0 } { + return + } + + if { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH "$orig_ld_library_path" + } elseif [info exists env(LD_LIBRARY_PATH)] { + unsetenv LD_LIBRARY_PATH + } + if { $orig_ld_run_path_saved } { + setenv LD_RUN_PATH "$orig_ld_run_path" + } elseif [info exists env(LD_RUN_PATH)] { + unsetenv LD_RUN_PATH + } + if { $orig_shlib_path_saved } { + setenv SHLIB_PATH "$orig_shlib_path" + } elseif [info exists env(SHLIB_PATH)] { + unsetenv SHLIB_PATH + } + if { $orig_ld_libraryn32_path_saved } { + setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path" + } elseif [info exists env(LD_LIBRARYN32_PATH)] { + unsetenv LD_LIBRARYN32_PATH + } + if { $orig_ld_library64_path_saved } { + setenv LD_LIBRARY64_PATH "$orig_ld_library64_path" + } elseif [info exists env(LD_LIBRARY64_PATH)] { + unsetenv LD_LIBRARY64_PATH + } + if { $orig_ld_library_path_32_saved } { + setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32" + } elseif [info exists env(LD_LIBRARY_PATH_32)] { + unsetenv LD_LIBRARY_PATH_32 + } + if { $orig_ld_library_path_64_saved } { + setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64" + } elseif [info exists env(LD_LIBRARY_PATH_64)] { + unsetenv LD_LIBRARY_PATH_64 + } + if { $orig_dyld_library_path_saved } { + setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path" + } elseif [info exists env(DYLD_LIBRARY_PATH)] { + unsetenv DYLD_LIBRARY_PATH + } + if { $orig_path_saved } { + setenv PATH "$orig_path" + } elseif [info exists env(PATH)] { + unsetenv PATH + } +} + +####################################### +# proc get_shlib_extension { } +####################################### + +proc get_shlib_extension { } { + global shlib_ext + + if { [ istarget *-*-darwin* ] } { + set shlib_ext "dylib" + } elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } { + set shlib_ext "dll" + } elseif { [ istarget hppa*-*-hpux* ] } { + set shlib_ext "sl" + } else { + set shlib_ext "so" + } + return $shlib_ext +} + diff --git a/user/mpy/lib/libffi/testsuite/lib/wrapper.exp b/user/mpy/lib/libffi/testsuite/lib/wrapper.exp new file mode 100644 index 0000000..4e5ae43 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/lib/wrapper.exp @@ -0,0 +1,45 @@ +# Copyright (C) 2004, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# This file contains GCC-specifics for status wrappers for test programs. + +# ${tool}_maybe_build_wrapper -- Build wrapper object if the target +# needs it. FILENAME is the path to the wrapper file. If there are +# additional arguments, they are command-line options to provide to +# the compiler when compiling FILENAME. + +proc ${tool}_maybe_build_wrapper { filename args } { + global gluefile wrap_flags + + if { [target_info needs_status_wrapper] != "" \ + && [target_info needs_status_wrapper] != "0" \ + && ![info exists gluefile] } { + set saved_wrap_compile_flags [target_info wrap_compile_flags] + set flags [join $args " "] + # The wrapper code may contain code that gcc objects on. This + # became true for dejagnu-1.4.4. The set of warnings and code + # that gcc objects on may change, so just make sure -w is always + # passed to turn off all warnings. + set_currtarget_info wrap_compile_flags \ + "$saved_wrap_compile_flags -w $flags" + set result [build_wrapper $filename] + set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags" + if { $result != "" } { + set gluefile [lindex $result 0] + set wrap_flags [lindex $result 1] + } + } +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/call.exp b/user/mpy/lib/libffi/testsuite/libffi.call/call.exp new file mode 100644 index 0000000..46fb1eb --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/call.exp @@ -0,0 +1,30 @@ +# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +dg-init +libffi-init + +global srcdir subdir + +set tlist [lsearch -inline -all -not -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*] + +run-many-tests $tlist "" + +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c new file mode 100644 index 0000000..a579ff6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c @@ -0,0 +1,89 @@ +/* Area: closure_call + Purpose: Check multiple values passing from different type. + Also, exceed the limit of gpr and fpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20030828 */ + + + + +/* { dg-do run } */ +#include "ffitest.h" + +static void +closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) + + (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] + + (int)(*(signed short *)args[4]) + + (int)(*(unsigned long long *)args[5]) + + (int)*(int *)args[6] + (int)(*(int *)args[7]) + + (int)(*(double *)args[8]) + (int)*(int *)args[9] + + (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(int *)args[13]) + + (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]), + (int)(*(unsigned long long *)args[2]), + (int)*(int *)args[3], (int)(*(signed short *)args[4]), + (int)(*(unsigned long long *)args[5]), + (int)*(int *)args[6], (int)(*(int *)args[7]), + (int)(*(double *)args[8]), (int)*(int *)args[9], + (int)(*(int *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(int *)args[13]), + (int)(*(int *)args[14]),*(int *)args[15], + (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + +} + +typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long, + int, signed short, unsigned long long, int, + int, double, int, int, float, int, int, + int, int); + +int main (void) +{ + ffi_cif cif; + void * code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int res; + + cl_arg_types[0] = &ffi_type_uint64; + cl_arg_types[1] = &ffi_type_sint; + cl_arg_types[2] = &ffi_type_uint64; + cl_arg_types[3] = &ffi_type_sint; + cl_arg_types[4] = &ffi_type_sshort; + cl_arg_types[5] = &ffi_type_uint64; + cl_arg_types[6] = &ffi_type_sint; + cl_arg_types[7] = &ffi_type_sint; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_sint; + cl_arg_types[10] = &ffi_type_sint; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_sint; + cl_arg_types[13] = &ffi_type_sint; + cl_arg_types[14] = &ffi_type_sint; + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type0)code)) + (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, + 19, 21, 1); + /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 680" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c new file mode 100644 index 0000000..9123173 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c @@ -0,0 +1,81 @@ +/* Area: closure_call. + Purpose: Check multiple values passing from different type. + Also, exceed the limit of gpr and fpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + + +static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(float *)args[0] +(int)(*(float *)args[1]) + + (int)(*(float *)args[2]) + (int)*(float *)args[3] + + (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) + + (int)*(float *)args[6] + (int)(*(int *)args[7]) + + (int)(*(double*)args[8]) + (int)*(int *)args[9] + + (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(int *)args[13]) + + (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(float *)args[0], (int)(*(float *)args[1]), + (int)(*(float *)args[2]), (int)*(float *)args[3], + (int)(*(signed short *)args[4]), (int)(*(float *)args[5]), + (int)*(float *)args[6], (int)(*(int *)args[7]), + (int)(*(double *)args[8]), (int)*(int *)args[9], + (int)(*(int *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(int *)args[13]), + (int)(*(int *)args[14]), *(int *)args[15], + (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); +} + +typedef int (*closure_test_type1)(float, float, float, float, signed short, + float, float, int, double, int, int, float, + int, int, int, int); +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int res; + + cl_arg_types[0] = &ffi_type_float; + cl_arg_types[1] = &ffi_type_float; + cl_arg_types[2] = &ffi_type_float; + cl_arg_types[3] = &ffi_type_float; + cl_arg_types[4] = &ffi_type_sshort; + cl_arg_types[5] = &ffi_type_float; + cl_arg_types[6] = &ffi_type_float; + cl_arg_types[7] = &ffi_type_sint; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_sint; + cl_arg_types[10] = &ffi_type_sint; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_sint; + cl_arg_types[13] = &ffi_type_sint; + cl_arg_types[14] = &ffi_type_sint; + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type1)code)) + (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13, + 19, 21, 1); + /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 255" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c new file mode 100644 index 0000000..08ff9d9 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c @@ -0,0 +1,81 @@ +/* Area: closure_call + Purpose: Check multiple values passing from different type. + Also, exceed the limit of gpr and fpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(double *)args[0] +(int)(*(double *)args[1]) + + (int)(*(double *)args[2]) + (int)*(double *)args[3] + + (int)(*(signed short *)args[4]) + (int)(*(double *)args[5]) + + (int)*(double *)args[6] + (int)(*(int *)args[7]) + + (int)(*(double *)args[8]) + (int)*(int *)args[9] + + (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(float *)args[13]) + + (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(double *)args[0], (int)(*(double *)args[1]), + (int)(*(double *)args[2]), (int)*(double *)args[3], + (int)(*(signed short *)args[4]), (int)(*(double *)args[5]), + (int)*(double *)args[6], (int)(*(int *)args[7]), + (int)(*(double*)args[8]), (int)*(int *)args[9], + (int)(*(int *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(float *)args[13]), + (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, + (int)*(ffi_arg *)resp); +} + +typedef int (*closure_test_type2)(double, double, double, double, signed short, + double, double, int, double, int, int, float, + int, float, int, int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int res; + + cl_arg_types[0] = &ffi_type_double; + cl_arg_types[1] = &ffi_type_double; + cl_arg_types[2] = &ffi_type_double; + cl_arg_types[3] = &ffi_type_double; + cl_arg_types[4] = &ffi_type_sshort; + cl_arg_types[5] = &ffi_type_double; + cl_arg_types[6] = &ffi_type_double; + cl_arg_types[7] = &ffi_type_sint; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_sint; + cl_arg_types[10] = &ffi_type_sint; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_sint; + cl_arg_types[13] = &ffi_type_float; + cl_arg_types[14] = &ffi_type_sint; + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn2, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type2)code)) + (1, 2, 3, 4, 127, 5, 6, 8, 9, 10, 11, 12.0, 13, + 19.0, 21, 1); + /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 255" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c new file mode 100644 index 0000000..9b54d80 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c @@ -0,0 +1,82 @@ +/* Area: closure_call + Purpose: Check multiple values passing from different type. + Also, exceed the limit of gpr and fpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) + { + *(ffi_arg*)resp = + (int)*(float *)args[0] +(int)(*(float *)args[1]) + + (int)(*(float *)args[2]) + (int)*(float *)args[3] + + (int)(*(float *)args[4]) + (int)(*(float *)args[5]) + + (int)*(float *)args[6] + (int)(*(float *)args[7]) + + (int)(*(double *)args[8]) + (int)*(int *)args[9] + + (int)(*(float *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(float *)args[13]) + + (int)(*(float *)args[14]) + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(float *)args[0], (int)(*(float *)args[1]), + (int)(*(float *)args[2]), (int)*(float *)args[3], + (int)(*(float *)args[4]), (int)(*(float *)args[5]), + (int)*(float *)args[6], (int)(*(float *)args[7]), + (int)(*(double *)args[8]), (int)*(int *)args[9], + (int)(*(float *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(float *)args[13]), + (int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, + (int)*(ffi_arg *)resp); + + } + +typedef int (*closure_test_type3)(float, float, float, float, float, float, + float, float, double, int, float, float, int, + float, float, int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int res; + + cl_arg_types[0] = &ffi_type_float; + cl_arg_types[1] = &ffi_type_float; + cl_arg_types[2] = &ffi_type_float; + cl_arg_types[3] = &ffi_type_float; + cl_arg_types[4] = &ffi_type_float; + cl_arg_types[5] = &ffi_type_float; + cl_arg_types[6] = &ffi_type_float; + cl_arg_types[7] = &ffi_type_float; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_sint; + cl_arg_types[10] = &ffi_type_float; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_sint; + cl_arg_types[13] = &ffi_type_float; + cl_arg_types[14] = &ffi_type_float; + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn3, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type3)code)) + (1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13, + 19.19, 21.21, 1); + /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 135" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c new file mode 100644 index 0000000..d4a1530 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c @@ -0,0 +1,89 @@ +/* Area: closure_call + Purpose: Check multiple long long values passing. + Also, exceed the limit of gpr and fpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20031026 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static void +closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] + + (int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] + + (int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] + + (int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] + + (int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] + + (int)*(unsigned long long *)args[10] + + (int)*(unsigned long long *)args[11] + + (int)*(unsigned long long *)args[12] + + (int)*(unsigned long long *)args[13] + + (int)*(unsigned long long *)args[14] + + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(unsigned long long *)args[0], + (int)*(unsigned long long *)args[1], + (int)*(unsigned long long *)args[2], + (int)*(unsigned long long *)args[3], + (int)*(unsigned long long *)args[4], + (int)*(unsigned long long *)args[5], + (int)*(unsigned long long *)args[6], + (int)*(unsigned long long *)args[7], + (int)*(unsigned long long *)args[8], + (int)*(unsigned long long *)args[9], + (int)*(unsigned long long *)args[10], + (int)*(unsigned long long *)args[11], + (int)*(unsigned long long *)args[12], + (int)*(unsigned long long *)args[13], + (int)*(unsigned long long *)args[14], + *(int *)args[15], + (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + +} + +typedef int (*closure_test_type0)(unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int i, res; + + for (i = 0; i < 15; i++) { + cl_arg_types[i] = &ffi_type_uint64; + } + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type0)code)) + (1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11LL, 12LL, + 13LL, 19LL, 21LL, 1); + /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 680" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c new file mode 100644 index 0000000..9907442 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c @@ -0,0 +1,92 @@ +/* Area: closure_call + Purpose: Check multiple long long values passing. + Exceed the limit of gpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20031026 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void +closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] + + (int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] + + (int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] + + (int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] + + (int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] + + (int)*(int *)args[10] + + (int)*(unsigned long long *)args[11] + + (int)*(unsigned long long *)args[12] + + (int)*(unsigned long long *)args[13] + + (int)*(unsigned long long *)args[14] + + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(unsigned long long *)args[0], + (int)*(unsigned long long *)args[1], + (int)*(unsigned long long *)args[2], + (int)*(unsigned long long *)args[3], + (int)*(unsigned long long *)args[4], + (int)*(unsigned long long *)args[5], + (int)*(unsigned long long *)args[6], + (int)*(unsigned long long *)args[7], + (int)*(unsigned long long *)args[8], + (int)*(unsigned long long *)args[9], + (int)*(int *)args[10], + (int)*(unsigned long long *)args[11], + (int)*(unsigned long long *)args[12], + (int)*(unsigned long long *)args[13], + (int)*(unsigned long long *)args[14], + *(int *)args[15], + (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + +} + +typedef int (*closure_test_type0)(unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, unsigned long long, + int, unsigned long long, + unsigned long long, unsigned long long, + unsigned long long, int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int i, res; + + for (i = 0; i < 10; i++) { + cl_arg_types[i] = &ffi_type_uint64; + } + cl_arg_types[10] = &ffi_type_sint; + for (i = 11; i < 15; i++) { + cl_arg_types[i] = &ffi_type_uint64; + } + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn5, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type0)code)) + (1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11, 12LL, + 13LL, 19LL, 21LL, 1); + /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 680" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c new file mode 100644 index 0000000..73c54fd --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c @@ -0,0 +1,90 @@ +/* Area: closure_call + Purpose: Check multiple values passing from different type. + Also, exceed the limit of gpr and fpr registers on PowerPC. + Limitations: none. + PR: PR23404 + Originator: 20050830 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void +closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(unsigned long long *)args[0] + + (int)(*(unsigned long long *)args[1]) + + (int)(*(unsigned long long *)args[2]) + + (int)*(unsigned long long *)args[3] + + (int)(*(int *)args[4]) + (int)(*(double *)args[5]) + + (int)*(double *)args[6] + (int)(*(float *)args[7]) + + (int)(*(double *)args[8]) + (int)*(double *)args[9] + + (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(int *)args[13]) + + (int)(*(double *)args[14]) + (int)*(double *)args[15] + + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(unsigned long long *)args[0], + (int)(*(unsigned long long *)args[1]), + (int)(*(unsigned long long *)args[2]), + (int)*(unsigned long long *)args[3], + (int)(*(int *)args[4]), (int)(*(double *)args[5]), + (int)*(double *)args[6], (int)(*(float *)args[7]), + (int)(*(double *)args[8]), (int)*(double *)args[9], + (int)(*(int *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(int *)args[13]), + (int)(*(double *)args[14]), (int)(*(double *)args[15]), + (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + +} + +typedef int (*closure_test_type0)(unsigned long long, + unsigned long long, + unsigned long long, + unsigned long long, + int, double, double, float, double, double, + int, float, int, int, double, double); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int res; + + cl_arg_types[0] = &ffi_type_uint64; + cl_arg_types[1] = &ffi_type_uint64; + cl_arg_types[2] = &ffi_type_uint64; + cl_arg_types[3] = &ffi_type_uint64; + cl_arg_types[4] = &ffi_type_sint; + cl_arg_types[5] = &ffi_type_double; + cl_arg_types[6] = &ffi_type_double; + cl_arg_types[7] = &ffi_type_float; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_double; + cl_arg_types[10] = &ffi_type_sint; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_sint; + cl_arg_types[13] = &ffi_type_sint; + cl_arg_types[14] = &ffi_type_double; + cl_arg_types[15] = &ffi_type_double; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*((closure_test_type0)code)) + (1, 2, 3, 4, 127, 429., 7., 8., 9.5, 10., 11, 12., 13, + 19, 21., 1.); + /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 680" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c new file mode 100644 index 0000000..b3afa0b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c @@ -0,0 +1,95 @@ +/* Area: closure_call + Purpose: Check multiple values passing from different type. + Also, exceed the limit of gpr and fpr registers on PowerPC + Darwin. + Limitations: none. + PR: none. + Originator: 20030828 */ + + + + +/* { dg-do run } */ +#include "ffitest.h" + +static void +closure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata) +{ + *(ffi_arg*)resp = + (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) + + (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] + + (int)(*(signed short *)args[4]) + + (int)(*(unsigned long long *)args[5]) + + (int)*(int *)args[6] + (int)(*(int *)args[7]) + + (int)(*(double *)args[8]) + (int)*(int *)args[9] + + (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(int *)args[13]) + + (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]), + (int)(*(unsigned long long *)args[2]), + (int)*(int *)args[3], (int)(*(signed short *)args[4]), + (int)(*(unsigned long long *)args[5]), + (int)*(int *)args[6], (int)(*(int *)args[7]), + (int)(*(double *)args[8]), (int)*(int *)args[9], + (int)(*(int *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(int *)args[13]), + (int)(*(int *)args[14]),*(int *)args[15], + (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + +} + +typedef int (*closure_loc_test_type0)(unsigned long long, int, unsigned long long, + int, signed short, unsigned long long, int, + int, double, int, int, float, int, int, + int, int); + +int main (void) +{ + ffi_cif cif; + ffi_closure *pcl; + ffi_type * cl_arg_types[17]; + int res; + void *codeloc; + + cl_arg_types[0] = &ffi_type_uint64; + cl_arg_types[1] = &ffi_type_sint; + cl_arg_types[2] = &ffi_type_uint64; + cl_arg_types[3] = &ffi_type_sint; + cl_arg_types[4] = &ffi_type_sshort; + cl_arg_types[5] = &ffi_type_uint64; + cl_arg_types[6] = &ffi_type_sint; + cl_arg_types[7] = &ffi_type_sint; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_sint; + cl_arg_types[10] = &ffi_type_sint; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_sint; + cl_arg_types[13] = &ffi_type_sint; + cl_arg_types[14] = &ffi_type_sint; + cl_arg_types[15] = &ffi_type_sint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + pcl = ffi_closure_alloc(sizeof(ffi_closure), &codeloc); + CHECK(pcl != NULL); + CHECK(codeloc != NULL); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0, + (void *) 3 /* userdata */, codeloc) == FFI_OK); + + CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0); + + res = (*((closure_loc_test_type0)codeloc)) + (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, + 19, 21, 1); + /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 680" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c new file mode 100644 index 0000000..5a4e728 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c @@ -0,0 +1,55 @@ +/* Area: closure_call + Purpose: Check simple closure handling with all ABIs + Limitations: none. + PR: none. + Originator: */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void +closure_test(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata) +{ + *(ffi_arg*)resp = + (int)*(int *)args[0] + (int)(*(int *)args[1]) + + (int)(*(int *)args[2]) + (int)(*(int *)args[3]) + + (int)(intptr_t)userdata; + + printf("%d %d %d %d: %d\n", + (int)*(int *)args[0], (int)(*(int *)args[1]), + (int)(*(int *)args[2]), (int)(*(int *)args[3]), + (int)*(ffi_arg *)resp); + +} + +typedef int (ABI_ATTR *closure_test_type0)(int, int, int, int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + int res; + + cl_arg_types[0] = &ffi_type_uint; + cl_arg_types[1] = &ffi_type_uint; + cl_arg_types[2] = &ffi_type_uint; + cl_arg_types[3] = &ffi_type_uint; + cl_arg_types[4] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 4, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test, + (void *) 3 /* userdata */, code) == FFI_OK); + + res = (*(closure_test_type0)code)(0, 1, 2, 3); + /* { dg-output "0 1 2 3: 9" } */ + + printf("res: %d\n",res); + /* { dg-output "\nres: 9" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c new file mode 100644 index 0000000..ea0825d --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c @@ -0,0 +1,94 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_12byte { + int a; + int b; + int c; +} cls_struct_12byte; + +cls_struct_12byte cls_struct_12byte_fn(struct cls_struct_12byte b1, + struct cls_struct_12byte b2) +{ + struct cls_struct_12byte result; + + result.a = b1.a + b2.a; + result.b = b1.b + b2.b; + result.c = b1.c + b2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, + result.a, result.b, result.c); + + return result; +} + +static void cls_struct_12byte_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args , void* userdata __UNUSED__) +{ + struct cls_struct_12byte b1, b2; + + b1 = *(struct cls_struct_12byte*)(args[0]); + b2 = *(struct cls_struct_12byte*)(args[1]); + + *(cls_struct_12byte*)resp = cls_struct_12byte_fn(b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_12byte h_dbl = { 7, 4, 9 }; + struct cls_struct_12byte j_dbl = { 1, 5, 3 }; + struct cls_struct_12byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = &ffi_type_sint; + cls_struct_fields[2] = &ffi_type_sint; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &h_dbl; + args_dbl[1] = &j_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_12byte_fn), &res_dbl, args_dbl); + /* { dg-output "7 4 9 1 5 3: 8 9 12" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 8 9 12" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_12byte_gn, NULL, code) == FFI_OK); + + res_dbl.a = 0; + res_dbl.b = 0; + res_dbl.c = 0; + + res_dbl = ((cls_struct_12byte(*)(cls_struct_12byte, cls_struct_12byte))(code))(h_dbl, j_dbl); + /* { dg-output "\n7 4 9 1 5 3: 8 9 12" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 8 9 12" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c new file mode 100644 index 0000000..89a08a2 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c @@ -0,0 +1,95 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_16byte { + int a; + double b; + int c; +} cls_struct_16byte; + +cls_struct_16byte cls_struct_16byte_fn(struct cls_struct_16byte b1, + struct cls_struct_16byte b2) +{ + struct cls_struct_16byte result; + + result.a = b1.a + b2.a; + result.b = b1.b + b2.b; + result.c = b1.c + b2.c; + + printf("%d %g %d %d %g %d: %d %g %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, + result.a, result.b, result.c); + + return result; +} + +static void cls_struct_16byte_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + struct cls_struct_16byte b1, b2; + + b1 = *(struct cls_struct_16byte*)(args[0]); + b2 = *(struct cls_struct_16byte*)(args[1]); + + *(cls_struct_16byte*)resp = cls_struct_16byte_fn(b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_16byte h_dbl = { 7, 8.0, 9 }; + struct cls_struct_16byte j_dbl = { 1, 9.0, 3 }; + struct cls_struct_16byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_sint; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &h_dbl; + args_dbl[1] = &j_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_16byte_fn), &res_dbl, args_dbl); + /* { dg-output "7 8 9 1 9 3: 8 17 12" } */ + printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 8 17 12" } */ + + res_dbl.a = 0; + res_dbl.b = 0.0; + res_dbl.c = 0; + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_16byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_16byte(*)(cls_struct_16byte, cls_struct_16byte))(code))(h_dbl, j_dbl); + /* { dg-output "\n7 8 9 1 9 3: 8 17 12" } */ + printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 8 17 12" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c new file mode 100644 index 0000000..9f75da8 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c @@ -0,0 +1,96 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Double alignment check on darwin. + Limitations: none. + PR: none. + Originator: 20030915 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_18byte { + double a; + unsigned char b; + unsigned char c; + double d; +} cls_struct_18byte; + +cls_struct_18byte cls_struct_18byte_fn(struct cls_struct_18byte a1, + struct cls_struct_18byte a2) +{ + struct cls_struct_18byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + + + printf("%g %d %d %g %g %d %d %g: %g %d %d %g\n", a1.a, a1.b, a1.c, a1.d, + a2.a, a2.b, a2.c, a2.d, + result.a, result.b, result.c, result.d); + return result; +} + +static void +cls_struct_18byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_18byte a1, a2; + + a1 = *(struct cls_struct_18byte*)(args[0]); + a2 = *(struct cls_struct_18byte*)(args[1]); + + *(cls_struct_18byte*)resp = cls_struct_18byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[5]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 }; + struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 }; + struct cls_struct_18byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_18byte_fn), &res_dbl, args_dbl); + /* { dg-output "1 127 126 3 4 125 124 5: 5 252 250 8" } */ + printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 5 252 250 8" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_18byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_18byte(*)(cls_struct_18byte, cls_struct_18byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 127 126 3 4 125 124 5: 5 252 250 8" } */ + printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 5 252 250 8" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c new file mode 100644 index 0000000..278794b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c @@ -0,0 +1,102 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Double alignment check on darwin. + Limitations: none. + PR: none. + Originator: 20030915 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_19byte { + double a; + unsigned char b; + unsigned char c; + double d; + unsigned char e; +} cls_struct_19byte; + +cls_struct_19byte cls_struct_19byte_fn(struct cls_struct_19byte a1, + struct cls_struct_19byte a2) +{ + struct cls_struct_19byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + result.e = a1.e + a2.e; + + + printf("%g %d %d %g %d %g %d %d %g %d: %g %d %d %g %d\n", + a1.a, a1.b, a1.c, a1.d, a1.e, + a2.a, a2.b, a2.c, a2.d, a2.e, + result.a, result.b, result.c, result.d, result.e); + return result; +} + +static void +cls_struct_19byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_19byte a1, a2; + + a1 = *(struct cls_struct_19byte*)(args[0]); + a2 = *(struct cls_struct_19byte*)(args[1]); + + *(cls_struct_19byte*)resp = cls_struct_19byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[6]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 }; + struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 }; + struct cls_struct_19byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = &ffi_type_uchar; + cls_struct_fields[5] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_19byte_fn), &res_dbl, args_dbl); + /* { dg-output "1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */ + printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e); + /* { dg-output "\nres: 5 252 250 8 239" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_19byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_19byte(*)(cls_struct_19byte, cls_struct_19byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */ + printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e); + /* { dg-output "\nres: 5 252 250 8 239" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c new file mode 100644 index 0000000..82492c0 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c @@ -0,0 +1,89 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Especially with small structures which may fit in one + register. Depending on the ABI. + Limitations: none. + PR: none. + Originator: 20030902 */ + + + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_1_1byte { + unsigned char a; +} cls_struct_1_1byte; + +cls_struct_1_1byte cls_struct_1_1byte_fn(struct cls_struct_1_1byte a1, + struct cls_struct_1_1byte a2) +{ + struct cls_struct_1_1byte result; + + result.a = a1.a + a2.a; + + printf("%d %d: %d\n", a1.a, a2.a, result.a); + + return result; +} + +static void +cls_struct_1_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_1_1byte a1, a2; + + a1 = *(struct cls_struct_1_1byte*)(args[0]); + a2 = *(struct cls_struct_1_1byte*)(args[1]); + + *(cls_struct_1_1byte*)resp = cls_struct_1_1byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[2]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_1_1byte g_dbl = { 12 }; + struct cls_struct_1_1byte f_dbl = { 178 }; + struct cls_struct_1_1byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_1_1byte_fn), &res_dbl, args_dbl); + /* { dg-output "12 178: 190" } */ + printf("res: %d\n", res_dbl.a); + /* { dg-output "\nres: 190" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_1_1byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_1_1byte(*)(cls_struct_1_1byte, cls_struct_1_1byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 178: 190" } */ + printf("res: %d\n", res_dbl.a); + /* { dg-output "\nres: 190" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c new file mode 100644 index 0000000..3f8bb28 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_20byte { + double a; + double b; + int c; +} cls_struct_20byte; + +cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, + struct cls_struct_20byte a2) +{ + struct cls_struct_20byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%g %g %d %g %g %d: %g %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, + result.a, result.b, result.c); + return result; +} + +static void +cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_20byte a1, a2; + + a1 = *(struct cls_struct_20byte*)(args[0]); + a2 = *(struct cls_struct_20byte*)(args[1]); + + *(cls_struct_20byte*)resp = cls_struct_20byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 }; + struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 }; + struct cls_struct_20byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_sint; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_20byte_fn), &res_dbl, args_dbl); + /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ + printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 5 7 10" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */ + printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 5 7 10" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c new file mode 100644 index 0000000..6562727 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c @@ -0,0 +1,93 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + + + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_20byte { + int a; + double b; + double c; +} cls_struct_20byte; + +cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, + struct cls_struct_20byte a2) +{ + struct cls_struct_20byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %g %g %d %g %g: %d %g %g\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, + result.a, result.b, result.c); + return result; +} + +static void +cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_20byte a1, a2; + + a1 = *(struct cls_struct_20byte*)(args[0]); + a2 = *(struct cls_struct_20byte*)(args[1]); + + *(cls_struct_20byte*)resp = cls_struct_20byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 }; + struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 }; + struct cls_struct_20byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_double; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_20byte_fn), &res_dbl, args_dbl); + /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ + printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 5 7 10" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */ + printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 5 7 10" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c new file mode 100644 index 0000000..1d82f6e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c @@ -0,0 +1,113 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_24byte { + double a; + double b; + int c; + float d; +} cls_struct_24byte; + +cls_struct_24byte cls_struct_24byte_fn(struct cls_struct_24byte b0, + struct cls_struct_24byte b1, + struct cls_struct_24byte b2, + struct cls_struct_24byte b3) +{ + struct cls_struct_24byte result; + + result.a = b0.a + b1.a + b2.a + b3.a; + result.b = b0.b + b1.b + b2.b + b3.b; + result.c = b0.c + b1.c + b2.c + b3.c; + result.d = b0.d + b1.d + b2.d + b3.d; + + printf("%g %g %d %g %g %g %d %g %g %g %d %g %g %g %d %g: %g %g %d %g\n", + b0.a, b0.b, b0.c, b0.d, + b1.a, b1.b, b1.c, b1.d, + b2.a, b2.b, b2.c, b2.d, + b3.a, b3.b, b3.c, b2.d, + result.a, result.b, result.c, result.d); + + return result; +} + +static void +cls_struct_24byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_24byte b0, b1, b2, b3; + + b0 = *(struct cls_struct_24byte*)(args[0]); + b1 = *(struct cls_struct_24byte*)(args[1]); + b2 = *(struct cls_struct_24byte*)(args[2]); + b3 = *(struct cls_struct_24byte*)(args[3]); + + *(cls_struct_24byte*)resp = cls_struct_24byte_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[5]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_24byte e_dbl = { 9.0, 2.0, 6, 5.0 }; + struct cls_struct_24byte f_dbl = { 1.0, 2.0, 3, 7.0 }; + struct cls_struct_24byte g_dbl = { 4.0, 5.0, 7, 9.0 }; + struct cls_struct_24byte h_dbl = { 8.0, 6.0, 1, 4.0 }; + struct cls_struct_24byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_sint; + cls_struct_fields[3] = &ffi_type_float; + cls_struct_fields[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = &cls_struct_type; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_24byte_fn), &res_dbl, args_dbl); + /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */ + printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 22 15 17 25" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_24byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_24byte(*)(cls_struct_24byte, + cls_struct_24byte, + cls_struct_24byte, + cls_struct_24byte)) + (code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */ + printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 22 15 17 25" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c new file mode 100644 index 0000000..81bb0a6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c @@ -0,0 +1,90 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Especially with small structures which may fit in one + register. Depending on the ABI. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_2byte { + unsigned char a; + unsigned char b; +} cls_struct_2byte; + +cls_struct_2byte cls_struct_2byte_fn(struct cls_struct_2byte a1, + struct cls_struct_2byte a2) +{ + struct cls_struct_2byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + + printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + + return result; +} + +static void +cls_struct_2byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_2byte a1, a2; + + a1 = *(struct cls_struct_2byte*)(args[0]); + a2 = *(struct cls_struct_2byte*)(args[1]); + + *(cls_struct_2byte*)resp = cls_struct_2byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_2byte g_dbl = { 12, 127 }; + struct cls_struct_2byte f_dbl = { 1, 13 }; + struct cls_struct_2byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_2byte_fn), &res_dbl, args_dbl); + /* { dg-output "12 127 1 13: 13 140" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 13 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_2byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_2byte(*)(cls_struct_2byte, cls_struct_2byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 127 1 13: 13 140" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 13 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c new file mode 100644 index 0000000..b782746 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c @@ -0,0 +1,95 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Especially with small structures which may fit in one + register. Depending on the ABI. + Limitations: none. + PR: none. + Originator: 20030902 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_3_1byte { + unsigned char a; + unsigned char b; + unsigned char c; +} cls_struct_3_1byte; + +cls_struct_3_1byte cls_struct_3_1byte_fn(struct cls_struct_3_1byte a1, + struct cls_struct_3_1byte a2) +{ + struct cls_struct_3_1byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, + a2.a, a2.b, a2.c, + result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_3_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_3_1byte a1, a2; + + a1 = *(struct cls_struct_3_1byte*)(args[0]); + a2 = *(struct cls_struct_3_1byte*)(args[1]); + + *(cls_struct_3_1byte*)resp = cls_struct_3_1byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_3_1byte g_dbl = { 12, 13, 14 }; + struct cls_struct_3_1byte f_dbl = { 178, 179, 180 }; + struct cls_struct_3_1byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_3_1byte_fn), &res_dbl, args_dbl); + /* { dg-output "12 13 14 178 179 180: 190 192 194" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 190 192 194" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3_1byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_3_1byte(*)(cls_struct_3_1byte, cls_struct_3_1byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 13 14 178 179 180: 190 192 194" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 190 192 194" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c new file mode 100644 index 0000000..a02c463 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c @@ -0,0 +1,90 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Especially with small structures which may fit in one + register. Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_3byte { + unsigned short a; + unsigned char b; +} cls_struct_3byte; + +cls_struct_3byte cls_struct_3byte_fn(struct cls_struct_3byte a1, + struct cls_struct_3byte a2) +{ + struct cls_struct_3byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + + printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + + return result; +} + +static void +cls_struct_3byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_3byte a1, a2; + + a1 = *(struct cls_struct_3byte*)(args[0]); + a2 = *(struct cls_struct_3byte*)(args[1]); + + *(cls_struct_3byte*)resp = cls_struct_3byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_3byte g_dbl = { 12, 119 }; + struct cls_struct_3byte f_dbl = { 1, 15 }; + struct cls_struct_3byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_ushort; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_3byte_fn), &res_dbl, args_dbl); + /* { dg-output "12 119 1 15: 13 134" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 13 134" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_3byte(*)(cls_struct_3byte, cls_struct_3byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 119 1 15: 13 134" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 13 134" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c new file mode 100644 index 0000000..c7251ce --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c @@ -0,0 +1,90 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Especially with small structures which may fit in one + register. Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_3byte_1 { + unsigned char a; + unsigned short b; +} cls_struct_3byte_1; + +cls_struct_3byte_1 cls_struct_3byte_fn1(struct cls_struct_3byte_1 a1, + struct cls_struct_3byte_1 a2) +{ + struct cls_struct_3byte_1 result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + + printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + + return result; +} + +static void +cls_struct_3byte_gn1(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_3byte_1 a1, a2; + + a1 = *(struct cls_struct_3byte_1*)(args[0]); + a2 = *(struct cls_struct_3byte_1*)(args[1]); + + *(cls_struct_3byte_1*)resp = cls_struct_3byte_fn1(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_3byte_1 g_dbl = { 15, 125 }; + struct cls_struct_3byte_1 f_dbl = { 9, 19 }; + struct cls_struct_3byte_1 res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_ushort; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_3byte_fn1), &res_dbl, args_dbl); + /* { dg-output "15 125 9 19: 24 144" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 24 144" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn1, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_3byte_1(*)(cls_struct_3byte_1, cls_struct_3byte_1))(code))(g_dbl, f_dbl); + /* { dg-output "\n15 125 9 19: 24 144" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 24 144" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c new file mode 100644 index 0000000..2d6d8b6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c @@ -0,0 +1,98 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Especially with small structures which may fit in one + register. Depending on the ABI. + Limitations: none. + PR: none. + Originator: 20030902 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_4_1byte { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; +} cls_struct_4_1byte; + +cls_struct_4_1byte cls_struct_4_1byte_fn(struct cls_struct_4_1byte a1, + struct cls_struct_4_1byte a2) +{ + struct cls_struct_4_1byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + + printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, + a2.a, a2.b, a2.c, a2.d, + result.a, result.b, result.c, result.d); + + return result; +} + +static void +cls_struct_4_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_4_1byte a1, a2; + + a1 = *(struct cls_struct_4_1byte*)(args[0]); + a2 = *(struct cls_struct_4_1byte*)(args[1]); + + *(cls_struct_4_1byte*)resp = cls_struct_4_1byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[5]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 }; + struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 }; + struct cls_struct_4_1byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_uchar; + cls_struct_fields[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_4_1byte_fn), &res_dbl, args_dbl); + /* { dg-output "12 13 14 15 178 179 180 181: 190 192 194 196" } */ + printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 190 192 194 196" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4_1byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_4_1byte(*)(cls_struct_4_1byte, cls_struct_4_1byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 13 14 15 178 179 180 181: 190 192 194 196" } */ + printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 190 192 194 196" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c new file mode 100644 index 0000000..4ac3787 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c @@ -0,0 +1,90 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef struct cls_struct_4byte { + unsigned short a; + unsigned short b; +} cls_struct_4byte; + +cls_struct_4byte cls_struct_4byte_fn(struct cls_struct_4byte a1, + struct cls_struct_4byte a2) +{ + struct cls_struct_4byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + + printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + + return result; +} + +static void +cls_struct_4byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_4byte a1, a2; + + a1 = *(struct cls_struct_4byte*)(args[0]); + a2 = *(struct cls_struct_4byte*)(args[1]); + + *(cls_struct_4byte*)resp = cls_struct_4byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_4byte g_dbl = { 127, 120 }; + struct cls_struct_4byte f_dbl = { 12, 128 }; + struct cls_struct_4byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_ushort; + cls_struct_fields[1] = &ffi_type_ushort; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_4byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 12 128: 139 248" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 139 248" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_4byte(*)(cls_struct_4byte, cls_struct_4byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 12 128: 139 248" } */ + printf("res: %d %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 139 248" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c new file mode 100644 index 0000000..ad9d51c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c @@ -0,0 +1,109 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20050708 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_5byte { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; +} cls_struct_5byte; + +cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, + struct cls_struct_5byte a2) +{ + struct cls_struct_5byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + result.e = a1.e + a2.e; + + printf("%d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d\n", + a1.a, a1.b, a1.c, a1.d, a1.e, + a2.a, a2.b, a2.c, a2.d, a2.e, + result.a, result.b, result.c, result.d, result.e); + + return result; +} + +static void +cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_5byte a1, a2; + + a1 = *(struct cls_struct_5byte*)(args[0]); + a2 = *(struct cls_struct_5byte*)(args[1]); + + *(cls_struct_5byte*)resp = cls_struct_5byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[6]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 }; + struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 }; + struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 }; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_uchar; + cls_struct_fields[4] = &ffi_type_uchar; + cls_struct_fields[5] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_5byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */ + printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e); + /* { dg-output "\nres: 139 248 10 6 8" } */ + + res_dbl.a = 0; + res_dbl.b = 0; + res_dbl.c = 0; + res_dbl.d = 0; + res_dbl.e = 0; + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */ + printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e); + /* { dg-output "\nres: 139 248 10 6 8" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c new file mode 100644 index 0000000..4e0c000 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c @@ -0,0 +1,98 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_5byte { + unsigned short a; + unsigned short b; + unsigned char c; +} cls_struct_5byte; + +cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, + struct cls_struct_5byte a2) +{ + struct cls_struct_5byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, + a2.a, a2.b, a2.c, + result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_5byte a1, a2; + + a1 = *(struct cls_struct_5byte*)(args[0]); + a2 = *(struct cls_struct_5byte*)(args[1]); + + *(cls_struct_5byte*)resp = cls_struct_5byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_5byte g_dbl = { 127, 120, 1 }; + struct cls_struct_5byte f_dbl = { 12, 128, 9 }; + struct cls_struct_5byte res_dbl = { 0, 0, 0 }; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_ushort; + cls_struct_fields[1] = &ffi_type_ushort; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_5byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 1 12 128 9: 139 248 10" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 139 248 10" } */ + + res_dbl.a = 0; + res_dbl.b = 0; + res_dbl.c = 0; + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 1 12 128 9: 139 248 10" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 139 248 10" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c new file mode 100644 index 0000000..a55edc2 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c @@ -0,0 +1,124 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check bigger struct which overlaps + the gp and fp register count on Darwin/AIX/ppc64. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_64byte { + double a; + double b; + double c; + double d; + double e; + double f; + double g; + double h; +} cls_struct_64byte; + +cls_struct_64byte cls_struct_64byte_fn(struct cls_struct_64byte b0, + struct cls_struct_64byte b1, + struct cls_struct_64byte b2, + struct cls_struct_64byte b3) +{ + struct cls_struct_64byte result; + + result.a = b0.a + b1.a + b2.a + b3.a; + result.b = b0.b + b1.b + b2.b + b3.b; + result.c = b0.c + b1.c + b2.c + b3.c; + result.d = b0.d + b1.d + b2.d + b3.d; + result.e = b0.e + b1.e + b2.e + b3.e; + result.f = b0.f + b1.f + b2.f + b3.f; + result.g = b0.g + b1.g + b2.g + b3.g; + result.h = b0.h + b1.h + b2.h + b3.h; + + printf("%g %g %g %g %g %g %g %g\n", result.a, result.b, result.c, + result.d, result.e, result.f, result.g, result.h); + + return result; +} + +static void +cls_struct_64byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_64byte b0, b1, b2, b3; + + b0 = *(struct cls_struct_64byte*)(args[0]); + b1 = *(struct cls_struct_64byte*)(args[1]); + b2 = *(struct cls_struct_64byte*)(args[2]); + b3 = *(struct cls_struct_64byte*)(args[3]); + + *(cls_struct_64byte*)resp = cls_struct_64byte_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[9]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_64byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0 }; + struct cls_struct_64byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0 }; + struct cls_struct_64byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0 }; + struct cls_struct_64byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0 }; + struct cls_struct_64byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_double; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = &ffi_type_double; + cls_struct_fields[5] = &ffi_type_double; + cls_struct_fields[6] = &ffi_type_double; + cls_struct_fields[7] = &ffi_type_double; + cls_struct_fields[8] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = &cls_struct_type; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_64byte_fn), &res_dbl, args_dbl); + /* { dg-output "22 15 17 25 6 13 19 18" } */ + printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_64byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_64byte(*)(cls_struct_64byte, + cls_struct_64byte, + cls_struct_64byte, + cls_struct_64byte)) + (code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n22 15 17 25 6 13 19 18" } */ + printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c new file mode 100644 index 0000000..b4dcdba --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c @@ -0,0 +1,113 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20050708 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_6byte { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; +} cls_struct_6byte; + +cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, + struct cls_struct_6byte a2) +{ + struct cls_struct_6byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + result.e = a1.e + a2.e; + result.f = a1.f + a2.f; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d %d\n", + a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, + a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, + result.a, result.b, result.c, result.d, result.e, result.f); + + return result; +} + +static void +cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_6byte a1, a2; + + a1 = *(struct cls_struct_6byte*)(args[0]); + a2 = *(struct cls_struct_6byte*)(args[1]); + + *(cls_struct_6byte*)resp = cls_struct_6byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[7]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 }; + struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 }; + struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 }; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_uchar; + cls_struct_fields[4] = &ffi_type_uchar; + cls_struct_fields[5] = &ffi_type_uchar; + cls_struct_fields[6] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_6byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */ + printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f); + /* { dg-output "\nres: 139 248 10 6 8 10" } */ + + res_dbl.a = 0; + res_dbl.b = 0; + res_dbl.c = 0; + res_dbl.d = 0; + res_dbl.e = 0; + res_dbl.f = 0; + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */ + printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f); + /* { dg-output "\nres: 139 248 10 6 8 10" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c new file mode 100644 index 0000000..7406780 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c @@ -0,0 +1,99 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_6byte { + unsigned short a; + unsigned short b; + unsigned char c; + unsigned char d; +} cls_struct_6byte; + +cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, + struct cls_struct_6byte a2) +{ + struct cls_struct_6byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + + printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, + a2.a, a2.b, a2.c, a2.d, + result.a, result.b, result.c, result.d); + + return result; +} + +static void +cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_6byte a1, a2; + + a1 = *(struct cls_struct_6byte*)(args[0]); + a2 = *(struct cls_struct_6byte*)(args[1]); + + *(cls_struct_6byte*)resp = cls_struct_6byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[5]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 }; + struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 }; + struct cls_struct_6byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_ushort; + cls_struct_fields[1] = &ffi_type_ushort; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_uchar; + cls_struct_fields[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_6byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 1 128 12 128 9 127: 139 248 10 255" } */ + printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 139 248 10 255" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 1 128 12 128 9 127: 139 248 10 255" } */ + printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 139 248 10 255" } */ + + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c new file mode 100644 index 0000000..14a7e96 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c @@ -0,0 +1,117 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20050708 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_7byte { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; +} cls_struct_7byte; + +cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, + struct cls_struct_7byte a2) +{ + struct cls_struct_7byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + result.e = a1.e + a2.e; + result.f = a1.f + a2.f; + result.g = a1.g + a2.g; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d %d %d\n", + a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, + a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, + result.a, result.b, result.c, result.d, result.e, result.f, result.g); + + return result; +} + +static void +cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_7byte a1, a2; + + a1 = *(struct cls_struct_7byte*)(args[0]); + a2 = *(struct cls_struct_7byte*)(args[1]); + + *(cls_struct_7byte*)resp = cls_struct_7byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[8]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 }; + struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 }; + struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 }; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_uchar; + cls_struct_fields[4] = &ffi_type_uchar; + cls_struct_fields[5] = &ffi_type_uchar; + cls_struct_fields[6] = &ffi_type_uchar; + cls_struct_fields[7] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_7byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */ + printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); + /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ + + res_dbl.a = 0; + res_dbl.b = 0; + res_dbl.c = 0; + res_dbl.d = 0; + res_dbl.e = 0; + res_dbl.f = 0; + res_dbl.g = 0; + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */ + printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); + /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c new file mode 100644 index 0000000..1645cc6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c @@ -0,0 +1,97 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_7byte { + unsigned short a; + unsigned short b; + unsigned char c; + unsigned short d; +} cls_struct_7byte; + +cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, + struct cls_struct_7byte a2) +{ + struct cls_struct_7byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + result.d = a1.d + a2.d; + + printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, + a2.a, a2.b, a2.c, a2.d, + result.a, result.b, result.c, result.d); + + return result; +} + +static void +cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_7byte a1, a2; + + a1 = *(struct cls_struct_7byte*)(args[0]); + a2 = *(struct cls_struct_7byte*)(args[1]); + + *(cls_struct_7byte*)resp = cls_struct_7byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[5]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 }; + struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 }; + struct cls_struct_7byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_ushort; + cls_struct_fields[1] = &ffi_type_ushort; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = &ffi_type_ushort; + cls_struct_fields[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_7byte_fn), &res_dbl, args_dbl); + /* { dg-output "127 120 1 254 12 128 9 255: 139 248 10 509" } */ + printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 139 248 10 509" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n127 120 1 254 12 128 9 255: 139 248 10 509" } */ + printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); + /* { dg-output "\nres: 139 248 10 509" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c new file mode 100644 index 0000000..f6c1ea5 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c @@ -0,0 +1,88 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Check overlapping. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_8byte { + int a; + float b; +} cls_struct_8byte; + +cls_struct_8byte cls_struct_8byte_fn(struct cls_struct_8byte a1, + struct cls_struct_8byte a2) +{ + struct cls_struct_8byte result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + + printf("%d %g %d %g: %d %g\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + + return result; +} + +static void +cls_struct_8byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_8byte a1, a2; + + a1 = *(struct cls_struct_8byte*)(args[0]); + a2 = *(struct cls_struct_8byte*)(args[1]); + + *(cls_struct_8byte*)resp = cls_struct_8byte_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_8byte g_dbl = { 1, 2.0 }; + struct cls_struct_8byte f_dbl = { 4, 5.0 }; + struct cls_struct_8byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = &ffi_type_float; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_8byte_fn), &res_dbl, args_dbl); + /* { dg-output "1 2 4 5: 5 7" } */ + printf("res: %d %g\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 5 7" } */ + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_8byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_8byte(*)(cls_struct_8byte, cls_struct_8byte))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 2 4 5: 5 7" } */ + printf("res: %d %g\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 5 7" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c new file mode 100644 index 0000000..0b85722 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c @@ -0,0 +1,90 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Darwin/AIX do double-word + alignment of the struct if the first element is a double. + Check that it does not here. + Limitations: none. + PR: none. + Originator: 20030914 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_9byte { + int a; + double b; +} cls_struct_9byte; + +cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, + struct cls_struct_9byte b2) +{ + struct cls_struct_9byte result; + + result.a = b1.a + b2.a; + result.b = b1.b + b2.b; + + printf("%d %g %d %g: %d %g\n", b1.a, b1.b, b2.a, b2.b, + result.a, result.b); + + return result; +} + +static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + struct cls_struct_9byte b1, b2; + + b1 = *(struct cls_struct_9byte*)(args[0]); + b2 = *(struct cls_struct_9byte*)(args[1]); + + *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_9byte h_dbl = { 7, 8.0}; + struct cls_struct_9byte j_dbl = { 1, 9.0}; + struct cls_struct_9byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &h_dbl; + args_dbl[1] = &j_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl); + /* { dg-output "7 8 1 9: 8 17" } */ + printf("res: %d %g\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 8 17" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl); + /* { dg-output "\n7 8 1 9: 8 17" } */ + printf("res: %d %g\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 8 17" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c new file mode 100644 index 0000000..edf991d --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Depending on the ABI. Darwin/AIX do double-word + alignment of the struct if the first element is a double. + Check that it does here. + Limitations: none. + PR: none. + Originator: 20030914 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_9byte { + double a; + int b; +} cls_struct_9byte; + +cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, + struct cls_struct_9byte b2) +{ + struct cls_struct_9byte result; + + result.a = b1.a + b2.a; + result.b = b1.b + b2.b; + + printf("%g %d %g %d: %g %d\n", b1.a, b1.b, b2.a, b2.b, + result.a, result.b); + + return result; +} + +static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + struct cls_struct_9byte b1, b2; + + b1 = *(struct cls_struct_9byte*)(args[0]); + b2 = *(struct cls_struct_9byte*)(args[1]); + + *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_9byte h_dbl = { 7.0, 8}; + struct cls_struct_9byte j_dbl = { 1.0, 9}; + struct cls_struct_9byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_sint; + cls_struct_fields[2] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &h_dbl; + args_dbl[1] = &j_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl); + /* { dg-output "7 8 1 9: 8 17" } */ + printf("res: %g %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 8 17" } */ + + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl); + /* { dg-output "\n7 8 1 9: 8 17" } */ + printf("res: %g %d\n", res_dbl.a, res_dbl.b); + /* { dg-output "\nres: 8 17" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c new file mode 100644 index 0000000..aad5f3c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c @@ -0,0 +1,93 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of double. + Limitations: none. + PR: none. + Originator: 20031203 */ + + + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + double b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c new file mode 100644 index 0000000..37e0855 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of float. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + float b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_float; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c new file mode 100644 index 0000000..b3322d8 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c @@ -0,0 +1,92 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of long double. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + long double b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_longdouble; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c new file mode 100644 index 0000000..cc1c43b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c @@ -0,0 +1,132 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of long double. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ + +#include "ffitest.h" + +typedef struct cls_struct_align { + long double a; + long double b; + long double c; + long double d; + long double e; + long double f; + long double g; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn( + cls_struct_align a1, + cls_struct_align a2) +{ + struct cls_struct_align r; + + r.a = a1.a + a2.a; + r.b = a1.b + a2.b; + r.c = a1.c + a2.c; + r.d = a1.d + a2.d; + r.e = a1.e + a2.e; + r.f = a1.f + a2.f; + r.g = a1.g + a2.g; + + printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: " + "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", + a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, + a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, + r.a, r.b, r.c, r.d, r.e, r.f, r.g); + + return r; +} + +cls_struct_align cls_struct_align_fn2( + cls_struct_align a1) +{ + struct cls_struct_align r; + + r.a = a1.a + 1; + r.b = a1.b + 1; + r.c = a1.c + 1; + r.d = a1.d + 1; + r.e = a1.e + 1; + r.f = a1.f + 1; + r.g = a1.g + 1; + + printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg: " + "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", + a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, + r.a, r.b, r.c, r.d, r.e, r.f, r.g); + + return r; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[8]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; + struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_longdouble; + cls_struct_fields[1] = &ffi_type_longdouble; + cls_struct_fields[2] = &ffi_type_longdouble; + cls_struct_fields[3] = &ffi_type_longdouble; + cls_struct_fields[4] = &ffi_type_longdouble; + cls_struct_fields[5] = &ffi_type_longdouble; + cls_struct_fields[6] = &ffi_type_longdouble; + cls_struct_fields[7] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ + printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); + /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ + printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); + /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c new file mode 100644 index 0000000..5d3bec0 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c @@ -0,0 +1,115 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of long double. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/18/2007 +*/ + +/* { dg-do run { xfail strongarm*-*-* } } */ +/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ + +#include "ffitest.h" + +typedef struct cls_struct_align { + long double a; + long double b; + long double c; + long double d; + long double e; + double f; + long double g; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn( + cls_struct_align a1, + cls_struct_align a2) +{ + struct cls_struct_align r; + + r.a = a1.a + a2.a; + r.b = a1.b + a2.b; + r.c = a1.c + a2.c; + r.d = a1.d + a2.d; + r.e = a1.e + a2.e; + r.f = a1.f + a2.f; + r.g = a1.g + a2.g; + + printf("%Lg %Lg %Lg %Lg %Lg %g %Lg %Lg %Lg %Lg %Lg %Lg %g %Lg: " + "%Lg %Lg %Lg %Lg %Lg %g %Lg\n", + a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, + a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, + r.a, r.b, r.c, r.d, r.e, r.f, r.g); + + return r; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[8]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[3]; + + struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; + struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_longdouble; + cls_struct_fields[1] = &ffi_type_longdouble; + cls_struct_fields[2] = &ffi_type_longdouble; + cls_struct_fields[3] = &ffi_type_longdouble; + cls_struct_fields[4] = &ffi_type_longdouble; + cls_struct_fields[5] = &ffi_type_double; + cls_struct_fields[6] = &ffi_type_longdouble; + cls_struct_fields[7] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ + printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); + /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ + printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); + /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + + exit(0); +} + + + diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c new file mode 100644 index 0000000..8fbf36a --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c @@ -0,0 +1,95 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of pointer. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + void *b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = (void *)((uintptr_t)a1.b + (uintptr_t)a2.b); + result.c = a1.c + a2.c; + + printf("%d %" PRIuPTR " %d %d %" PRIuPTR " %d: %d %" PRIuPTR " %d\n", + a1.a, (uintptr_t)a1.b, a1.c, + a2.a, (uintptr_t)a2.b, a2.c, + result.a, (uintptr_t)result.b, + result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, (void *)4951, 127 }; + struct cls_struct_align f_dbl = { 1, (void *)9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_pointer; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c new file mode 100644 index 0000000..039b874 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of sint16. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + signed short b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_sshort; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c new file mode 100644 index 0000000..c96c6d1 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of sint32. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + signed int b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_sint; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c new file mode 100644 index 0000000..9aa7bdd --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c @@ -0,0 +1,92 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of sint64. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + signed long long b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_sint64; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c new file mode 100644 index 0000000..97620b7 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of uint16. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + unsigned short b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_ushort; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c new file mode 100644 index 0000000..5766fad --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of uint32. + Limitations: none. + PR: none. + Originator: 20031203 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + unsigned int b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uint; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c new file mode 100644 index 0000000..a52cb89 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c @@ -0,0 +1,93 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of uint64. + Limitations: none. + PR: none. + Originator: 20031203 */ + + +/* { dg-do run } */ +/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ +#include "ffitest.h" + +typedef struct cls_struct_align { + unsigned char a; + unsigned long long b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, + struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uint64; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &g_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); + /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); + /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ + printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); + /* { dg-output "\nres: 13 14271 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c new file mode 100644 index 0000000..d663791 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c @@ -0,0 +1,66 @@ +/* Area: ffi_call, closure_call + Purpose: Check double arguments in structs. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/23/2007 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef struct Dbls { + double x; + double y; +} Dbls; + +void +closure_test_fn(Dbls p) +{ + printf("%.1f %.1f\n", p.x, p.y); +} + +void +closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, + void** args, void* userdata __UNUSED__) +{ + closure_test_fn(*(Dbls*)args[0]); +} + +int main(int argc __UNUSED__, char** argv __UNUSED__) +{ + ffi_cif cif; + + void *code; + ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type* cl_arg_types[1]; + + ffi_type ts1_type; + ffi_type* ts1_type_elements[4]; + + Dbls arg = { 1.0, 2.0 }; + + ts1_type.size = 0; + ts1_type.alignment = 0; + ts1_type.type = FFI_TYPE_STRUCT; + ts1_type.elements = ts1_type_elements; + + ts1_type_elements[0] = &ffi_type_double; + ts1_type_elements[1] = &ffi_type_double; + ts1_type_elements[2] = NULL; + + cl_arg_types[0] = &ts1_type; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_void, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK); + + ((void*(*)(Dbls))(code))(arg); + /* { dg-output "1.0 2.0\n" } */ + + closure_test_fn(arg); + /* { dg-output "1.0 2.0\n" } */ + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c new file mode 100644 index 0000000..84ad4cb --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c @@ -0,0 +1,43 @@ +/* Area: closure_call + Purpose: Check return value double. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(double *)resp = *(double *)args[0]; + + printf("%f: %f\n",*(double *)args[0], + *(double *)resp); + } +typedef double (*cls_ret_double)(double); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + double res; + + cl_arg_types[0] = &ffi_type_double; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_double, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_double)code))(21474.789); + /* { dg-output "21474.789000: 21474.789000" } */ + printf("res: %.6f\n", res); + /* { dg-output "\nres: 21474.789000" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c new file mode 100644 index 0000000..e077f92 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c @@ -0,0 +1,61 @@ +/* Area: ffi_call, closure_call + Purpose: Test doubles passed in variable argument lists. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-output "" { xfail avr32*-*-* } } */ +/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ + +#include "ffitest.h" + +static void +cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + char* format = *(char**)args[0]; + double doubleValue = *(double*)args[1]; + + *(ffi_arg*)resp = printf(format, doubleValue); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[3]; + ffi_type* arg_types[3]; + + char* format = "%.1f\n"; + double doubleArg = 7; + ffi_arg res = 0; + + arg_types[0] = &ffi_type_pointer; + arg_types[1] = &ffi_type_double; + arg_types[2] = NULL; + + /* This printf call is variadic */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint, + arg_types) == FFI_OK); + + args[0] = &format; + args[1] = &doubleArg; + args[2] = NULL; + + ffi_call(&cif, FFI_FN(printf), &res, args); + /* { dg-output "7.0" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 4" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, + code) == FFI_OK); + + res = ((int(*)(char*, ...))(code))(format, doubleArg); + /* { dg-output "\n7.0" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 4" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c new file mode 100644 index 0000000..0090fed --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c @@ -0,0 +1,42 @@ +/* Area: closure_call + Purpose: Check return value float. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_float_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(float *)resp = *(float *)args[0]; + + printf("%g: %g\n",*(float *)args[0], + *(float *)resp); + } + +typedef float (*cls_ret_float)(float); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + float res; + + cl_arg_types[0] = &ffi_type_float; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_float, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_float_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_float)code)(-2122.12))); + /* { dg-output "\\-2122.12: \\-2122.12" } */ + printf("res: %.6f\n", res); + /* { dg-output "\nres: \-2122.120117" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c new file mode 100644 index 0000000..d24e72e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c @@ -0,0 +1,105 @@ +/* Area: ffi_call, closure_call + Purpose: Check long double arguments. + Limitations: none. + PR: none. + Originator: Blake Chaffin */ + +/* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have + remove the xfail for arm*-*-* below, until we know more. */ +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ + +#include "ffitest.h" + +long double cls_ldouble_fn( + long double a1, + long double a2, + long double a3, + long double a4, + long double a5, + long double a6, + long double a7, + long double a8) +{ + long double r = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; + + printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: %Lg\n", + a1, a2, a3, a4, a5, a6, a7, a8, r); + + return r; +} + +static void +cls_ldouble_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + long double a1 = *(long double*)args[0]; + long double a2 = *(long double*)args[1]; + long double a3 = *(long double*)args[2]; + long double a4 = *(long double*)args[3]; + long double a5 = *(long double*)args[4]; + long double a6 = *(long double*)args[5]; + long double a7 = *(long double*)args[6]; + long double a8 = *(long double*)args[7]; + + *(long double*)resp = cls_ldouble_fn( + a1, a2, a3, a4, a5, a6, a7, a8); +} + +int main(void) +{ + ffi_cif cif; + void* code; + ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[9]; + ffi_type* arg_types[9]; + long double res = 0; + + long double arg1 = 1; + long double arg2 = 2; + long double arg3 = 3; + long double arg4 = 4; + long double arg5 = 5; + long double arg6 = 6; + long double arg7 = 7; + long double arg8 = 8; + + arg_types[0] = &ffi_type_longdouble; + arg_types[1] = &ffi_type_longdouble; + arg_types[2] = &ffi_type_longdouble; + arg_types[3] = &ffi_type_longdouble; + arg_types[4] = &ffi_type_longdouble; + arg_types[5] = &ffi_type_longdouble; + arg_types[6] = &ffi_type_longdouble; + arg_types[7] = &ffi_type_longdouble; + arg_types[8] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 8, &ffi_type_longdouble, + arg_types) == FFI_OK); + + args[0] = &arg1; + args[1] = &arg2; + args[2] = &arg3; + args[3] = &arg4; + args[4] = &arg5; + args[5] = &arg6; + args[6] = &arg7; + args[7] = &arg8; + args[8] = NULL; + + ffi_call(&cif, FFI_FN(cls_ldouble_fn), &res, args); + /* { dg-output "1 2 3 4 5 6 7 8: 36" } */ + printf("res: %Lg\n", res); + /* { dg-output "\nres: 36" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ldouble_gn, NULL, code) == FFI_OK); + + res = ((long double(*)(long double, long double, long double, long double, + long double, long double, long double, long double))(code))(arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8); + /* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */ + printf("res: %Lg\n", res); + /* { dg-output "\nres: 36" } */ + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c new file mode 100644 index 0000000..39b438b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c @@ -0,0 +1,61 @@ +/* Area: ffi_call, closure_call + Purpose: Test long doubles passed in variable argument lists. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */ +/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ + +#include "ffitest.h" + +static void +cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + char* format = *(char**)args[0]; + long double ldValue = *(long double*)args[1]; + + *(ffi_arg*)resp = printf(format, ldValue); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[3]; + ffi_type* arg_types[3]; + + char* format = "%.1Lf\n"; + long double ldArg = 7; + ffi_arg res = 0; + + arg_types[0] = &ffi_type_pointer; + arg_types[1] = &ffi_type_longdouble; + arg_types[2] = NULL; + + /* This printf call is variadic */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint, + arg_types) == FFI_OK); + + args[0] = &format; + args[1] = &ldArg; + args[2] = NULL; + + ffi_call(&cif, FFI_FN(printf), &res, args); + /* { dg-output "7.0" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 4" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, + code) == FFI_OK); + + res = ((int(*)(char*, ...))(code))(format, ldArg); + /* { dg-output "\n7.0" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 4" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c new file mode 100644 index 0000000..7fd6c82 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c @@ -0,0 +1,70 @@ +/* Area: closure_call + Purpose: Check closures called with many args of mixed types + Limitations: none. + PR: none. + Originator: */ + +/* { dg-do run } */ +#include "ffitest.h" +#include +#include + +#define NARGS 16 + +static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + int i; + double r = 0; + double t; + for(i = 0; i < NARGS; i++) + { + if(i == 4 || i == 9 || i == 11 || i == 13 || i == 15) + { + t = *(long int *)args[i]; + CHECK(t == i+1); + } + else + { + t = *(double *)args[i]; + CHECK(fabs(t - ((i+1) * 0.1)) < FLT_EPSILON); + } + r += t; + } + *(double *)resp = r; +} +typedef double (*cls_ret_double)(double, double, double, double, long int, +double, double, double, double, long int, double, long int, double, long int, +double, long int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[NARGS]; + double res; + int i; + double expected = 64.9; + + for(i = 0; i < NARGS; i++) + { + if(i == 4 || i == 9 || i == 11 || i == 13 || i == 15) + cl_arg_types[i] = &ffi_type_slong; + else + cl_arg_types[i] = &ffi_type_double; + } + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NARGS, + &ffi_type_double, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK); + + res = (((cls_ret_double)code))(0.1, 0.2, 0.3, 0.4, 5, 0.6, 0.7, 0.8, 0.9, 10, + 1.1, 12, 1.3, 14, 1.5, 16); + if (fabs(res - expected) < FLT_EPSILON) + exit(0); + else + abort(); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c new file mode 100644 index 0000000..62b0697 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c @@ -0,0 +1,55 @@ +/* Area: closure_call + Purpose: Check register allocation for closure calls with many float and double arguments + Limitations: none. + PR: none. + Originator: */ + +/* { dg-do run } */ +#include "ffitest.h" +#include +#include + +#define NARGS 16 + +static void cls_mixed_float_double_fn(ffi_cif* cif , void* ret, void** args, + void* userdata __UNUSED__) +{ + double r = 0; + unsigned int i; + double t; + for(i=0; i < cif->nargs; i++) + { + if(cif->arg_types[i] == &ffi_type_double) { + t = *(((double**)(args))[i]); + } else { + t = *(((float**)(args))[i]); + } + r += t; + } + *((double*)ret) = r; +} +typedef double (*cls_mixed)(double, float, double, double, double, double, double, float, float, double, float, float); + +int main (void) +{ + ffi_cif cif; + ffi_closure *closure; + void* code; + ffi_type *argtypes[12] = {&ffi_type_double, &ffi_type_float, &ffi_type_double, + &ffi_type_double, &ffi_type_double, &ffi_type_double, + &ffi_type_double, &ffi_type_float, &ffi_type_float, + &ffi_type_double, &ffi_type_float, &ffi_type_float}; + + + closure = ffi_closure_alloc(sizeof(ffi_closure), (void**)&code); + if(closure ==NULL) + abort(); + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 12, &ffi_type_double, argtypes) == FFI_OK); + CHECK(ffi_prep_closure_loc(closure, &cif, cls_mixed_float_double_fn, NULL, code) == FFI_OK); + double ret = ((cls_mixed)code)(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2); + ffi_closure_free(closure); + if(fabs(ret - 7.8) < FLT_EPSILON) + exit(0); + else + abort(); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c new file mode 100644 index 0000000..71df7b6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c @@ -0,0 +1,74 @@ +/* Area: ffi_call, closure_call + Purpose: Check passing of multiple signed char values. + Limitations: none. + PR: PR13221. + Originator: 20031129 */ + +/* { dg-do run } */ +#include "ffitest.h" + +signed char test_func_fn(signed char a1, signed char a2) +{ + signed char result; + + result = a1 + a2; + + printf("%d %d: %d\n", a1, a2, result); + + return result; + +} + +static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, + void *data __UNUSED__) +{ + signed char a1, a2; + + a1 = *(signed char *)avals[0]; + a2 = *(signed char *)avals[1]; + + *(ffi_arg *)rval = test_func_fn(a1, a2); + +} + +typedef signed char (*test_type)(signed char, signed char); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void * args_dbl[3]; + ffi_type * cl_arg_types[3]; + ffi_arg res_call; + signed char a, b, res_closure; + + a = 2; + b = 125; + + args_dbl[0] = &a; + args_dbl[1] = &b; + args_dbl[2] = NULL; + + cl_arg_types[0] = &ffi_type_schar; + cl_arg_types[1] = &ffi_type_schar; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_schar, cl_arg_types) == FFI_OK); + + ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); + /* { dg-output "2 125: 127" } */ + printf("res: %d\n", (signed char)res_call); + /* { dg-output "\nres: 127" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); + + res_closure = (*((test_type)code))(2, 125); + /* { dg-output "\n2 125: 127" } */ + printf("res: %d\n", res_closure); + /* { dg-output "\nres: 127" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c new file mode 100644 index 0000000..4c39153 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c @@ -0,0 +1,74 @@ +/* Area: ffi_call, closure_call + Purpose: Check passing of multiple signed short values. + Limitations: none. + PR: PR13221. + Originator: 20031129 */ + +/* { dg-do run } */ +#include "ffitest.h" + +signed short test_func_fn(signed short a1, signed short a2) +{ + signed short result; + + result = a1 + a2; + + printf("%d %d: %d\n", a1, a2, result); + + return result; + +} + +static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, + void *data __UNUSED__) +{ + signed short a1, a2; + + a1 = *(signed short *)avals[0]; + a2 = *(signed short *)avals[1]; + + *(ffi_arg *)rval = test_func_fn(a1, a2); + +} + +typedef signed short (*test_type)(signed short, signed short); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void * args_dbl[3]; + ffi_type * cl_arg_types[3]; + ffi_arg res_call; + unsigned short a, b, res_closure; + + a = 2; + b = 32765; + + args_dbl[0] = &a; + args_dbl[1] = &b; + args_dbl[2] = NULL; + + cl_arg_types[0] = &ffi_type_sshort; + cl_arg_types[1] = &ffi_type_sshort; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_sshort, cl_arg_types) == FFI_OK); + + ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); + /* { dg-output "2 32765: 32767" } */ + printf("res: %d\n", (unsigned short)res_call); + /* { dg-output "\nres: 32767" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); + + res_closure = (*((test_type)code))(2, 32765); + /* { dg-output "\n2 32765: 32767" } */ + printf("res: %d\n", res_closure); + /* { dg-output "\nres: 32767" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c new file mode 100644 index 0000000..1c3aeb5 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c @@ -0,0 +1,86 @@ +/* Area: ffi_call, closure_call + Purpose: Check passing of multiple signed short/char values. + Limitations: none. + PR: PR13221. + Originator: 20031129 */ + +/* { dg-do run } */ +#include "ffitest.h" + +signed short test_func_fn(signed char a1, signed short a2, + signed char a3, signed short a4) +{ + signed short result; + + result = a1 + a2 + a3 + a4; + + printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + + return result; + +} + +static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, + void *data __UNUSED__) +{ + signed char a1, a3; + signed short a2, a4; + + a1 = *(signed char *)avals[0]; + a2 = *(signed short *)avals[1]; + a3 = *(signed char *)avals[2]; + a4 = *(signed short *)avals[3]; + + *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4); + +} + +typedef signed short (*test_type)(signed char, signed short, + signed char, signed short); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void * args_dbl[5]; + ffi_type * cl_arg_types[5]; + ffi_arg res_call; + signed char a, c; + signed short b, d, res_closure; + + a = 1; + b = 32765; + c = 127; + d = -128; + + args_dbl[0] = &a; + args_dbl[1] = &b; + args_dbl[2] = &c; + args_dbl[3] = &d; + args_dbl[4] = NULL; + + cl_arg_types[0] = &ffi_type_schar; + cl_arg_types[1] = &ffi_type_sshort; + cl_arg_types[2] = &ffi_type_schar; + cl_arg_types[3] = &ffi_type_sshort; + cl_arg_types[4] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_sshort, cl_arg_types) == FFI_OK); + + ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); + /* { dg-output "1 32765 127 -128: 32765" } */ + printf("res: %d\n", (signed short)res_call); + /* { dg-output "\nres: 32765" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); + + res_closure = (*((test_type)code))(1, 32765, 127, -128); + /* { dg-output "\n1 32765 127 -128: 32765" } */ + printf("res: %d\n", res_closure); + /* { dg-output "\nres: 32765" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c new file mode 100644 index 0000000..009c02c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c @@ -0,0 +1,91 @@ +/* Area: ffi_call, closure_call + Purpose: Check passing of multiple unsigned char values. + Limitations: none. + PR: PR13221. + Originator: 20031129 */ + +/* { dg-do run } */ +#include "ffitest.h" + +unsigned char test_func_fn(unsigned char a1, unsigned char a2, + unsigned char a3, unsigned char a4) +{ + unsigned char result; + + result = a1 + a2 + a3 + a4; + + printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + + return result; + +} + +static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, + void *data __UNUSED__) +{ + unsigned char a1, a2, a3, a4; + + a1 = *(unsigned char *)avals[0]; + a2 = *(unsigned char *)avals[1]; + a3 = *(unsigned char *)avals[2]; + a4 = *(unsigned char *)avals[3]; + + *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4); + +} + +typedef unsigned char (*test_type)(unsigned char, unsigned char, + unsigned char, unsigned char); + +void test_func(ffi_cif *cif __UNUSED__, void *rval __UNUSED__, void **avals, + void *data __UNUSED__) +{ + printf("%d %d %d %d\n", *(unsigned char *)avals[0], + *(unsigned char *)avals[1], *(unsigned char *)avals[2], + *(unsigned char *)avals[3]); +} +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void * args_dbl[5]; + ffi_type * cl_arg_types[5]; + ffi_arg res_call; + unsigned char a, b, c, d, res_closure; + + a = 1; + b = 2; + c = 127; + d = 125; + + args_dbl[0] = &a; + args_dbl[1] = &b; + args_dbl[2] = &c; + args_dbl[3] = &d; + args_dbl[4] = NULL; + + cl_arg_types[0] = &ffi_type_uchar; + cl_arg_types[1] = &ffi_type_uchar; + cl_arg_types[2] = &ffi_type_uchar; + cl_arg_types[3] = &ffi_type_uchar; + cl_arg_types[4] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_uchar, cl_arg_types) == FFI_OK); + + ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); + /* { dg-output "1 2 127 125: 255" } */ + printf("res: %d\n", (unsigned char)res_call); + /* { dg-output "\nres: 255" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); + + res_closure = (*((test_type)code))(1, 2, 127, 125); + /* { dg-output "\n1 2 127 125: 255" } */ + printf("res: %d\n", res_closure); + /* { dg-output "\nres: 255" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c new file mode 100644 index 0000000..dd10ca7 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c @@ -0,0 +1,74 @@ +/* Area: ffi_call, closure_call + Purpose: Check passing of multiple unsigned short values. + Limitations: none. + PR: PR13221. + Originator: 20031129 */ + +/* { dg-do run } */ +#include "ffitest.h" + +unsigned short test_func_fn(unsigned short a1, unsigned short a2) +{ + unsigned short result; + + result = a1 + a2; + + printf("%d %d: %d\n", a1, a2, result); + + return result; + +} + +static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, + void *data __UNUSED__) +{ + unsigned short a1, a2; + + a1 = *(unsigned short *)avals[0]; + a2 = *(unsigned short *)avals[1]; + + *(ffi_arg *)rval = test_func_fn(a1, a2); + +} + +typedef unsigned short (*test_type)(unsigned short, unsigned short); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void * args_dbl[3]; + ffi_type * cl_arg_types[3]; + ffi_arg res_call; + unsigned short a, b, res_closure; + + a = 2; + b = 32765; + + args_dbl[0] = &a; + args_dbl[1] = &b; + args_dbl[2] = NULL; + + cl_arg_types[0] = &ffi_type_ushort; + cl_arg_types[1] = &ffi_type_ushort; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_ushort, cl_arg_types) == FFI_OK); + + ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); + /* { dg-output "2 32765: 32767" } */ + printf("res: %d\n", (unsigned short)res_call); + /* { dg-output "\nres: 32767" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); + + res_closure = (*((test_type)code))(2, 32765); + /* { dg-output "\n2 32765: 32767" } */ + printf("res: %d\n", res_closure); + /* { dg-output "\nres: 32767" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c new file mode 100644 index 0000000..2588e97 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c @@ -0,0 +1,86 @@ +/* Area: ffi_call, closure_call + Purpose: Check passing of multiple unsigned short/char values. + Limitations: none. + PR: PR13221. + Originator: 20031129 */ + +/* { dg-do run } */ +#include "ffitest.h" + +unsigned short test_func_fn(unsigned char a1, unsigned short a2, + unsigned char a3, unsigned short a4) +{ + unsigned short result; + + result = a1 + a2 + a3 + a4; + + printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + + return result; + +} + +static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, + void *data __UNUSED__) +{ + unsigned char a1, a3; + unsigned short a2, a4; + + a1 = *(unsigned char *)avals[0]; + a2 = *(unsigned short *)avals[1]; + a3 = *(unsigned char *)avals[2]; + a4 = *(unsigned short *)avals[3]; + + *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4); + +} + +typedef unsigned short (*test_type)(unsigned char, unsigned short, + unsigned char, unsigned short); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void * args_dbl[5]; + ffi_type * cl_arg_types[5]; + ffi_arg res_call; + unsigned char a, c; + unsigned short b, d, res_closure; + + a = 1; + b = 2; + c = 127; + d = 128; + + args_dbl[0] = &a; + args_dbl[1] = &b; + args_dbl[2] = &c; + args_dbl[3] = &d; + args_dbl[4] = NULL; + + cl_arg_types[0] = &ffi_type_uchar; + cl_arg_types[1] = &ffi_type_ushort; + cl_arg_types[2] = &ffi_type_uchar; + cl_arg_types[3] = &ffi_type_ushort; + cl_arg_types[4] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_ushort, cl_arg_types) == FFI_OK); + + ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); + /* { dg-output "1 2 127 128: 258" } */ + printf("res: %d\n", (unsigned short)res_call); + /* { dg-output "\nres: 258" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); + + res_closure = (*((test_type)code))(1, 2, 127, 128); + /* { dg-output "\n1 2 127 128: 258" } */ + printf("res: %d\n", res_closure); + /* { dg-output "\nres: 258" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c new file mode 100644 index 0000000..d82a87a --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c @@ -0,0 +1,74 @@ +/* Area: ffi_call, closure_call + Purpose: Check pointer arguments. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +#include "ffitest.h" + +void* cls_pointer_fn(void* a1, void* a2) +{ + void* result = (void*)((intptr_t)a1 + (intptr_t)a2); + + printf("0x%08x 0x%08x: 0x%08x\n", + (unsigned int)(uintptr_t) a1, + (unsigned int)(uintptr_t) a2, + (unsigned int)(uintptr_t) result); + + return result; +} + +static void +cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + void* a1 = *(void**)(args[0]); + void* a2 = *(void**)(args[1]); + + *(void**)resp = cls_pointer_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[3]; + /* ffi_type cls_pointer_type; */ + ffi_type* arg_types[3]; + +/* cls_pointer_type.size = sizeof(void*); + cls_pointer_type.alignment = 0; + cls_pointer_type.type = FFI_TYPE_POINTER; + cls_pointer_type.elements = NULL;*/ + + void* arg1 = (void*)0x12345678; + void* arg2 = (void*)0x89abcdef; + ffi_arg res = 0; + + arg_types[0] = &ffi_type_pointer; + arg_types[1] = &ffi_type_pointer; + arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer, + arg_types) == FFI_OK); + + args[0] = &arg1; + args[1] = &arg2; + args[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_pointer_fn), &res, args); + /* { dg-output "0x12345678 0x89abcdef: 0x9be02467" } */ + printf("res: 0x%08x\n", (unsigned int) res); + /* { dg-output "\nres: 0x9be02467" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); + + res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2); + /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */ + printf("res: 0x%08x\n", (unsigned int) res); + /* { dg-output "\nres: 0x9be02467" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c new file mode 100644 index 0000000..1f1d915 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c @@ -0,0 +1,142 @@ +/* Area: ffi_call, closure_call + Purpose: Check pointer arguments across multiple hideous stack frames. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/7/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +#include "ffitest.h" + +static long dummyVar; + +long dummy_func( + long double a1, char b1, + long double a2, char b2, + long double a3, char b3, + long double a4, char b4) +{ + return a1 + b1 + a2 + b2 + a3 + b3 + a4 + b4; +} + +void* cls_pointer_fn2(void* a1, void* a2) +{ + long double trample1 = (intptr_t)a1 + (intptr_t)a2; + char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0]; + long double trample3 = (intptr_t)trample1 + (intptr_t)a1; + char trample4 = trample2 + ((char*)&a1)[1]; + long double trample5 = (intptr_t)trample3 + (intptr_t)a2; + char trample6 = trample4 + ((char*)&a2)[1]; + long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; + char trample8 = trample6 + trample2; + void* result; + + dummyVar = dummy_func(trample1, trample2, trample3, trample4, + trample5, trample6, trample7, trample8); + + result = (void*)((intptr_t)a1 + (intptr_t)a2); + + printf("0x%08x 0x%08x: 0x%08x\n", + (unsigned int)(uintptr_t) a1, + (unsigned int)(uintptr_t) a2, + (unsigned int)(uintptr_t) result); + + return result; +} + +void* cls_pointer_fn1(void* a1, void* a2) +{ + long double trample1 = (intptr_t)a1 + (intptr_t)a2; + char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0]; + long double trample3 = (intptr_t)trample1 + (intptr_t)a1; + char trample4 = trample2 + ((char*)&a1)[1]; + long double trample5 = (intptr_t)trample3 + (intptr_t)a2; + char trample6 = trample4 + ((char*)&a2)[1]; + long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; + char trample8 = trample6 + trample2; + void* result; + + dummyVar = dummy_func(trample1, trample2, trample3, trample4, + trample5, trample6, trample7, trample8); + + result = (void*)((intptr_t)a1 + (intptr_t)a2); + + printf("0x%08x 0x%08x: 0x%08x\n", + (unsigned int)(intptr_t) a1, + (unsigned int)(intptr_t) a2, + (unsigned int)(intptr_t) result); + + result = cls_pointer_fn2(result, a1); + + return result; +} + +static void +cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + void* a1 = *(void**)(args[0]); + void* a2 = *(void**)(args[1]); + + long double trample1 = (intptr_t)a1 + (intptr_t)a2; + char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0]; + long double trample3 = (intptr_t)trample1 + (intptr_t)a1; + char trample4 = trample2 + ((char*)&a1)[1]; + long double trample5 = (intptr_t)trample3 + (intptr_t)a2; + char trample6 = trample4 + ((char*)&a2)[1]; + long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; + char trample8 = trample6 + trample2; + + dummyVar = dummy_func(trample1, trample2, trample3, trample4, + trample5, trample6, trample7, trample8); + + *(void**)resp = cls_pointer_fn1(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[3]; + /* ffi_type cls_pointer_type; */ + ffi_type* arg_types[3]; + +/* cls_pointer_type.size = sizeof(void*); + cls_pointer_type.alignment = 0; + cls_pointer_type.type = FFI_TYPE_POINTER; + cls_pointer_type.elements = NULL;*/ + + void* arg1 = (void*)0x01234567; + void* arg2 = (void*)0x89abcdef; + ffi_arg res = 0; + + arg_types[0] = &ffi_type_pointer; + arg_types[1] = &ffi_type_pointer; + arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer, + arg_types) == FFI_OK); + + args[0] = &arg1; + args[1] = &arg2; + args[2] = NULL; + + printf("\n"); + ffi_call(&cif, FFI_FN(cls_pointer_fn1), &res, args); + + printf("res: 0x%08x\n", (unsigned int) res); + /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ + /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ + /* { dg-output "\nres: 0x8bf258bd" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); + + res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2); + + printf("res: 0x%08x\n", (unsigned int) res); + /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ + /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ + /* { dg-output "\nres: 0x8bf258bd" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c new file mode 100644 index 0000000..82986b1 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c @@ -0,0 +1,44 @@ +/* Area: closure_call + Purpose: Check return value schar. + Limitations: none. + PR: none. + Originator: 20031108 */ + + + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + *(ffi_arg*)resp = *(signed char *)args[0]; + printf("%d: %d\n",*(signed char *)args[0], + (int)*(ffi_arg *)(resp)); +} +typedef signed char (*cls_ret_schar)(signed char); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + signed char res; + + cl_arg_types[0] = &ffi_type_schar; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_schar, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_schar_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_schar)code))(127); + /* { dg-output "127: 127" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 127" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c new file mode 100644 index 0000000..c7e13b7 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c @@ -0,0 +1,42 @@ +/* Area: closure_call + Purpose: Check return value sint32. + Limitations: none. + PR: none. + Originator: 20031108 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + *(ffi_arg*)resp = *(signed int *)args[0]; + printf("%d: %d\n",*(signed int *)args[0], + (int)*(ffi_arg *)(resp)); +} +typedef signed int (*cls_ret_sint)(signed int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + signed int res; + + cl_arg_types[0] = &ffi_type_sint; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sint_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_sint)code))(65534); + /* { dg-output "65534: 65534" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 65534" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c new file mode 100644 index 0000000..846d57e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c @@ -0,0 +1,42 @@ +/* Area: closure_call + Purpose: Check return value sshort. + Limitations: none. + PR: none. + Originator: 20031108 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + *(ffi_arg*)resp = *(signed short *)args[0]; + printf("%d: %d\n",*(signed short *)args[0], + (int)*(ffi_arg *)(resp)); +} +typedef signed short (*cls_ret_sshort)(signed short); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + signed short res; + + cl_arg_types[0] = &ffi_type_sshort; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_sshort, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sshort_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_sshort)code))(255); + /* { dg-output "255: 255" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 255" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c new file mode 100644 index 0000000..6d1fdae --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c @@ -0,0 +1,114 @@ +/* Area: ffi_call, closure_call + Purpose: Test doubles passed in variable argument lists. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ +#include "ffitest.h" + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static void +test_fn (ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + int n = *(int*)args[0]; + struct small_tag s1 = * (struct small_tag *) args[1]; + struct large_tag l1 = * (struct large_tag *) args[2]; + struct small_tag s2 = * (struct small_tag *) args[3]; + + printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b, + l1.a, l1.b, l1.c, l1.d, l1.e, + s2.a, s2.b); + * (ffi_arg*) resp = 42; +} + +int +main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc (sizeof (ffi_closure), &code); + ffi_type* arg_types[5]; + + ffi_arg res = 0; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int si; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, + arg_types) == FFI_OK); + + si = 4; + s1.a = 5; + s1.b = 6; + + s2.a = 20; + s2.b = 21; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_fn, NULL, code) == FFI_OK); + + res = ((int (*)(int, ...))(code))(si, s1, l1, s2); + /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 42" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c new file mode 100644 index 0000000..c1317e7 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c @@ -0,0 +1,42 @@ +/* Area: closure_call + Purpose: Check return value uchar. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + *(ffi_arg*)resp = *(unsigned char *)args[0]; + printf("%d: %d\n",*(unsigned char *)args[0], + (int)*(ffi_arg *)(resp)); +} +typedef unsigned char (*cls_ret_uchar)(unsigned char); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + unsigned char res; + + cl_arg_types[0] = &ffi_type_uchar; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_uchar, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uchar_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_uchar)code))(127); + /* { dg-output "127: 127" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 127" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c new file mode 100644 index 0000000..6491c5b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c @@ -0,0 +1,44 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned char argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef unsigned char T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(ffi_arg *)resp = *(T *)args[0]; + + printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_uchar; + cl_arg_types[1] = &ffi_type_uchar; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_uchar, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c new file mode 100644 index 0000000..885cff5 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c @@ -0,0 +1,43 @@ +/* Area: closure_call + Purpose: Check return value uint. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + *(ffi_arg *)resp = *(unsigned int *)args[0]; + + printf("%d: %d\n",*(unsigned int *)args[0], + (int)*(ffi_arg *)(resp)); +} +typedef unsigned int (*cls_ret_uint)(unsigned int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + unsigned int res; + + cl_arg_types[0] = &ffi_type_uint; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_uint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uint_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_uint)code))(2147483647); + /* { dg-output "2147483647: 2147483647" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 2147483647" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c new file mode 100644 index 0000000..b04cfd1 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c @@ -0,0 +1,45 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned int argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef unsigned int T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(ffi_arg *)resp = *(T *)args[0]; + + printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_uint; + cl_arg_types[1] = &ffi_type_uint; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_uint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c new file mode 100644 index 0000000..0315082 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c @@ -0,0 +1,45 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned long argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef unsigned long T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(T *)resp = *(T *)args[0]; + + printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_ulong; + cl_arg_types[1] = &ffi_type_ulong; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_ulong, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %ld\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c new file mode 100644 index 0000000..62f2cae --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c @@ -0,0 +1,47 @@ +/* Area: closure_call + Purpose: Check return value long long. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ +#include "ffitest.h" + +static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + *(unsigned long long *)resp= 0xfffffffffffffffLL ^ *(unsigned long long *)args[0]; + + printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0], + *(unsigned long long *)(resp)); +} +typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + unsigned long long res; + + cl_arg_types[0] = &ffi_type_uint64; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_uint64, cl_arg_types) == FFI_OK); + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK); + res = (*((cls_ret_ulonglong)code))(214LL); + /* { dg-output "214: 1152921504606846761" } */ + printf("res: %" PRIdLL "\n", res); + /* { dg-output "\nres: 1152921504606846761" } */ + + res = (*((cls_ret_ulonglong)code))(9223372035854775808LL); + /* { dg-output "\n9223372035854775808: 8070450533247928831" } */ + printf("res: %" PRIdLL "\n", res); + /* { dg-output "\nres: 8070450533247928831" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c new file mode 100644 index 0000000..a00100e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c @@ -0,0 +1,43 @@ +/* Area: closure_call + Purpose: Check return value ushort. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + *(ffi_arg*)resp = *(unsigned short *)args[0]; + + printf("%d: %d\n",*(unsigned short *)args[0], + (int)*(ffi_arg *)(resp)); +} +typedef unsigned short (*cls_ret_ushort)(unsigned short); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + unsigned short res; + + cl_arg_types[0] = &ffi_type_ushort; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_ushort, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ushort_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_ushort)code))(65535); + /* { dg-output "65535: 65535" } */ + printf("res: %d\n",res); + /* { dg-output "\nres: 65535" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c new file mode 100644 index 0000000..37aa106 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c @@ -0,0 +1,44 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned short argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef unsigned short T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(ffi_arg *)resp = *(T *)args[0]; + + printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_ushort; + cl_arg_types[1] = &ffi_type_ushort; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_ushort, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c b/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c new file mode 100644 index 0000000..f5a7317 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c @@ -0,0 +1,36 @@ +/* Area: ffi_prep_cif, ffi_prep_closure + Purpose: Test error return for bad ABIs. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static void +dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, + void** args __UNUSED__, void* userdata __UNUSED__) +{} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type* arg_types[1]; + + arg_types[0] = NULL; + + CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void, + arg_types) == FFI_BAD_ABI); + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void, + arg_types) == FFI_OK); + + cif.abi= 255; + + CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c b/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c new file mode 100644 index 0000000..bf60161 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c @@ -0,0 +1,26 @@ +/* Area: ffi_prep_cif + Purpose: Test error return for bad typedefs. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +int main (void) +{ + ffi_cif cif; + ffi_type* arg_types[1]; + + ffi_type badType = ffi_type_void; + + arg_types[0] = NULL; + + badType.size = 0; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType, + arg_types) == FFI_BAD_TYPEDEF); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h b/user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h new file mode 100644 index 0000000..15d5e44 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h @@ -0,0 +1,135 @@ +#include +#include +#include +#include +#include +#include "fficonfig.h" + +#if defined HAVE_STDINT_H +#include +#endif + +#if defined HAVE_INTTYPES_H +#include +#endif + +#define MAX_ARGS 256 + +#define CHECK(x) (void)(!(x) ? (abort(), 1) : 0) + +/* Define macros so that compilers other than gcc can run the tests. */ +#undef __UNUSED__ +#if defined(__GNUC__) +#define __UNUSED__ __attribute__((__unused__)) +#define __STDCALL__ __attribute__((stdcall)) +#define __THISCALL__ __attribute__((thiscall)) +#define __FASTCALL__ __attribute__((fastcall)) +#else +#define __UNUSED__ +#define __STDCALL__ __stdcall +#define __THISCALL__ __thiscall +#define __FASTCALL__ __fastcall +#endif + +#ifndef ABI_NUM +#define ABI_NUM FFI_DEFAULT_ABI +#define ABI_ATTR +#endif + +/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a + file open. */ +#ifdef HAVE_MMAP_ANON +# undef HAVE_MMAP_DEV_ZERO + +# include +# ifndef MAP_FAILED +# define MAP_FAILED -1 +# endif +# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) +# define MAP_ANONYMOUS MAP_ANON +# endif +# define USING_MMAP + +#endif + +#ifdef HAVE_MMAP_DEV_ZERO + +# include +# ifndef MAP_FAILED +# define MAP_FAILED -1 +# endif +# define USING_MMAP + +#endif + +/* MinGW kludge. */ +#ifdef _WIN64 +#define PRIdLL "I64d" +#define PRIuLL "I64u" +#else +#define PRIdLL "lld" +#define PRIuLL "llu" +#endif + +/* Tru64 UNIX kludge. */ +#if defined(__alpha__) && defined(__osf__) +/* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit. */ +#undef PRIdLL +#define PRIdLL "ld" +#undef PRIuLL +#define PRIuLL "lu" +#define PRId8 "hd" +#define PRIu8 "hu" +#define PRId64 "ld" +#define PRIu64 "lu" +#define PRIuPTR "lu" +#endif + +/* PA HP-UX kludge. */ +#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR) +#define PRIuPTR "lu" +#endif + +/* IRIX kludge. */ +#if defined(__sgi) +/* IRIX 6.5 provides all definitions, but only for C99 + compilations. */ +#define PRId8 "hhd" +#define PRIu8 "hhu" +#if (_MIPS_SZLONG == 32) +#define PRId64 "lld" +#define PRIu64 "llu" +#endif +/* This doesn't match , which always has "lld" here, but the + arguments are uint64_t, int64_t, which are unsigned long, long for + 64-bit in . */ +#if (_MIPS_SZLONG == 64) +#define PRId64 "ld" +#define PRIu64 "lu" +#endif +/* This doesn't match , which has "u" here, but the arguments + are uintptr_t, which is always unsigned long. */ +#define PRIuPTR "lu" +#endif + +/* Solaris < 10 kludge. */ +#if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR) +#if defined(__arch64__) || defined (__x86_64__) +#define PRIuPTR "lu" +#else +#define PRIuPTR "u" +#endif +#endif + +/* MSVC kludge. */ +#if defined _MSC_VER +#define PRIuPTR "lu" +#define PRIu8 "u" +#define PRId8 "d" +#define PRIu64 "I64u" +#define PRId64 "I64d" +#endif + +#ifndef PRIuPTR +#define PRIuPTR "u" +#endif diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float.c b/user/mpy/lib/libffi/testsuite/libffi.call/float.c new file mode 100644 index 0000000..fbc272d --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/float.c @@ -0,0 +1,59 @@ +/* Area: ffi_call + Purpose: Check return value float. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static int floating(int a, float b, double c, long double d) +{ + int i; + + i = (int) ((float)a/b + ((float)c/(float)d)); + + return i; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + + float f; + signed int si1; + double d; + long double ld; + + args[0] = &ffi_type_sint; + values[0] = &si1; + args[1] = &ffi_type_float; + values[1] = &f; + args[2] = &ffi_type_double; + values[2] = &d; + args[3] = &ffi_type_longdouble; + values[3] = &ld; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_sint, args) == FFI_OK); + + si1 = 6; + f = 3.14159; + d = (double)1.0/(double)3.0; + ld = 2.71828182846L; + + floating (si1, f, d, ld); + + ffi_call(&cif, FFI_FN(floating), &rint, values); + + printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld)); + + CHECK((int)rint == floating(si1, f, d, ld)); + + exit (0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float1.c b/user/mpy/lib/libffi/testsuite/libffi.call/float1.c new file mode 100644 index 0000000..c48493c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/float1.c @@ -0,0 +1,60 @@ +/* Area: ffi_call + Purpose: Check return value double. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +#include "float.h" + +#include + +typedef union +{ + double d; + unsigned char c[sizeof (double)]; +} value_type; + +#define CANARY 0xba + +static double dblit(float f) +{ + return f/3.0; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + float f; + value_type result[2]; + unsigned int i; + + args[0] = &ffi_type_float; + values[0] = &f; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_double, args) == FFI_OK); + + f = 3.14159; + + /* Put a canary in the return array. This is a regression test for + a buffer overrun. */ + memset(result[1].c, CANARY, sizeof (double)); + + ffi_call(&cif, FFI_FN(dblit), &result[0].d, values); + + /* These are not always the same!! Check for a reasonable delta */ + + CHECK(fabs(result[0].d - dblit(f)) < DBL_EPSILON); + + /* Check the canary. */ + for (i = 0; i < sizeof (double); ++i) + CHECK(result[1].c[i] == CANARY); + + exit(0); + +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float2.c b/user/mpy/lib/libffi/testsuite/libffi.call/float2.c new file mode 100644 index 0000000..20a8c40 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/float2.c @@ -0,0 +1,58 @@ +/* Area: ffi_call + Purpose: Check return value long double. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ +/* { dg-do run } */ + +#include "ffitest.h" +#include "float.h" + +#include + +static long double ldblit(float f) +{ + return (long double) (((long double) f)/ (long double) 3.0); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + float f; + long double ld; + + args[0] = &ffi_type_float; + values[0] = &f; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_longdouble, args) == FFI_OK); + + f = 3.14159; + +#if 1 + /* This is ifdef'd out for now. long double support under SunOS/gcc + is pretty much non-existent. You'll get the odd bus error in library + routines like printf(). */ + printf ("%Lf\n", ldblit(f)); +#endif + ld = 666; + ffi_call(&cif, FFI_FN(ldblit), &ld, values); + +#if 1 + /* This is ifdef'd out for now. long double support under SunOS/gcc + is pretty much non-existent. You'll get the odd bus error in library + routines like printf(). */ + printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON); +#endif + + /* These are not always the same!! Check for a reasonable delta */ + if (fabsl(ld - ldblit(f)) < LDBL_EPSILON) + puts("long double return value tests ok!"); + else + CHECK(0); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float3.c b/user/mpy/lib/libffi/testsuite/libffi.call/float3.c new file mode 100644 index 0000000..bab3206 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/float3.c @@ -0,0 +1,74 @@ +/* Area: ffi_call + Purpose: Check float arguments with different orders. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ + +#include "ffitest.h" +#include "float.h" + +#include + +static double floating_1(float a, double b, long double c) +{ + return (double) a + b + (double) c; +} + +static double floating_2(long double a, double b, float c) +{ + return (double) a + b + (double) c; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + double rd; + + float f; + double d; + long double ld; + + args[0] = &ffi_type_float; + values[0] = &f; + args[1] = &ffi_type_double; + values[1] = &d; + args[2] = &ffi_type_longdouble; + values[2] = &ld; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &ffi_type_double, args) == FFI_OK); + + f = 3.14159; + d = (double)1.0/(double)3.0; + ld = 2.71828182846L; + + floating_1 (f, d, ld); + + ffi_call(&cif, FFI_FN(floating_1), &rd, values); + + CHECK(fabs(rd - floating_1(f, d, ld)) < DBL_EPSILON); + + args[0] = &ffi_type_longdouble; + values[0] = &ld; + args[1] = &ffi_type_double; + values[1] = &d; + args[2] = &ffi_type_float; + values[2] = &f; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &ffi_type_double, args) == FFI_OK); + + floating_2 (ld, d, f); + + ffi_call(&cif, FFI_FN(floating_2), &rd, values); + + CHECK(fabs(rd - floating_2(ld, d, f)) < DBL_EPSILON); + + exit (0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float4.c b/user/mpy/lib/libffi/testsuite/libffi.call/float4.c new file mode 100644 index 0000000..0dd6d85 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/float4.c @@ -0,0 +1,62 @@ +/* Area: ffi_call + Purpose: Check denorm double value. + Limitations: none. + PR: PR26483. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +/* { dg-options "-mieee" { target alpha*-*-* } } */ + +#include "ffitest.h" +#include "float.h" + +typedef union +{ + double d; + unsigned char c[sizeof (double)]; +} value_type; + +#define CANARY 0xba + +static double dblit(double d) +{ + return d; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + double d; + value_type result[2]; + unsigned int i; + + args[0] = &ffi_type_double; + values[0] = &d; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_double, args) == FFI_OK); + + d = DBL_MIN / 2; + + /* Put a canary in the return array. This is a regression test for + a buffer overrun. */ + memset(result[1].c, CANARY, sizeof (double)); + + ffi_call(&cif, FFI_FN(dblit), &result[0].d, values); + + /* The standard delta check doesn't work for denorms. Since we didn't do + any arithmetic, we should get the original result back, and hence an + exact check should be OK here. */ + + CHECK(result[0].d == dblit(d)); + + /* Check the canary. */ + for (i = 0; i < sizeof (double); ++i) + CHECK(result[1].c[i] == CANARY); + + exit(0); + +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/float_va.c new file mode 100644 index 0000000..5acff91 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/float_va.c @@ -0,0 +1,107 @@ +/* Area: fp and variadics + Purpose: check fp inputs and returns work on variadics, even the fixed params + Limitations: None + PR: none + Originator: 2011-01-25 + + Intended to stress the difference in ABI on ARM vfp +*/ + +/* { dg-do run } */ + +#include + +#include "ffitest.h" + +/* prints out all the parameters, and returns the sum of them all. + * 'x' is the number of variadic parameters all of which are double in this test + */ +double float_va_fn(unsigned int x, double y,...) +{ + double total=0.0; + va_list ap; + unsigned int i; + + total+=(double)x; + total+=y; + + printf("%u: %.1f :", x, y); + + va_start(ap, y); + for(i=0;i +#include +#include + +static float ABI_ATTR many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13) +{ +#if 0 + printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n", + (double) f1, (double) f2, (double) f3, (double) f4, (double) f5, + (double) f6, (double) f7, (double) f8, (double) f9, (double) f10, + (double) f11, (double) f12, (double) f13); +#endif + + return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[13]; + void *values[13]; + float fa[13]; + float f, ff; + int i; + + for (i = 0; i < 13; i++) + { + args[i] = &ffi_type_float; + values[i] = &fa[i]; + fa[i] = (float) i; + } + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 13, + &ffi_type_float, args) == FFI_OK); + + ffi_call(&cif, FFI_FN(many), &f, values); + + ff = many(fa[0], fa[1], + fa[2], fa[3], + fa[4], fa[5], + fa[6], fa[7], + fa[8], fa[9], + fa[10],fa[11],fa[12]); + + if (fabs(f - ff) < FLT_EPSILON) + exit(0); + else + abort(); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/many2.c b/user/mpy/lib/libffi/testsuite/libffi.call/many2.c new file mode 100644 index 0000000..1c85746 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/many2.c @@ -0,0 +1,57 @@ +/* Area: ffi_call + Purpose: Check uint8_t arguments. + Limitations: none. + PR: PR45677. + Originator: Dan Witte 20100916 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +#define NARGS 7 + +typedef unsigned char u8; + +#ifdef __GNUC__ +__attribute__((noinline)) +#endif +uint8_t +foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d, + uint8_t e, uint8_t f, uint8_t g) +{ + return a + b + c + d + e + f + g; +} + +uint8_t ABI_ATTR +bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d, + uint8_t e, uint8_t f, uint8_t g) +{ + return foo (a, b, c, d, e, f, g); +} + +int +main (void) +{ + ffi_type *ffitypes[NARGS]; + int i; + ffi_cif cif; + ffi_arg result = 0; + uint8_t args[NARGS]; + void *argptrs[NARGS]; + + for (i = 0; i < NARGS; ++i) + ffitypes[i] = &ffi_type_uint8; + + CHECK (ffi_prep_cif (&cif, ABI_NUM, NARGS, + &ffi_type_uint8, ffitypes) == FFI_OK); + + for (i = 0; i < NARGS; ++i) + { + args[i] = i; + argptrs[i] = &args[i]; + } + ffi_call (&cif, FFI_FN (bar), &result, argptrs); + + CHECK (result == 21); + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/many_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/many_double.c new file mode 100644 index 0000000..4ef8c8a --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/many_double.c @@ -0,0 +1,70 @@ +/* Area: ffi_call + Purpose: Check return value double, with many arguments + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +#include +#include +#include + +static double many(double f1, + double f2, + double f3, + double f4, + double f5, + double f6, + double f7, + double f8, + double f9, + double f10, + double f11, + double f12, + double f13) +{ +#if 0 + printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n", + (double) f1, (double) f2, (double) f3, (double) f4, (double) f5, + (double) f6, (double) f7, (double) f8, (double) f9, (double) f10, + (double) f11, (double) f12, (double) f13); +#endif + + return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[13]; + void *values[13]; + double fa[13]; + double f, ff; + int i; + + for (i = 0; i < 13; i++) + { + args[i] = &ffi_type_double; + values[i] = &fa[i]; + fa[i] = (double) i; + } + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, + &ffi_type_double, args) == FFI_OK); + + ffi_call(&cif, FFI_FN(many), &f, values); + + ff = many(fa[0], fa[1], + fa[2], fa[3], + fa[4], fa[5], + fa[6], fa[7], + fa[8], fa[9], + fa[10],fa[11],fa[12]); + if (fabs(f - ff) < FLT_EPSILON) + exit(0); + else + abort(); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c b/user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c new file mode 100644 index 0000000..85ec36e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c @@ -0,0 +1,78 @@ +/* Area: ffi_call + Purpose: Check return value double, with many arguments + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +#include +#include +#include + +static double many(double f1, + double f2, + long int i1, + double f3, + double f4, + long int i2, + double f5, + double f6, + long int i3, + double f7, + double f8, + long int i4, + double f9, + double f10, + long int i5, + double f11, + double f12, + long int i6, + double f13) +{ + return ((double) (i1 + i2 + i3 + i4 + i5 + i6) + (f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[19]; + void *values[19]; + double fa[19]; + long int la[19]; + double f, ff; + int i; + + for (i = 0; i < 19; i++) + { + if( (i - 2) % 3 == 0) { + args[i] = &ffi_type_slong; + la[i] = (long int) i; + values[i] = &la[i]; + } + else { + args[i] = &ffi_type_double; + fa[i] = (double) i; + values[i] = &fa[i]; + } + } + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 19, + &ffi_type_double, args) == FFI_OK); + + ffi_call(&cif, FFI_FN(many), &f, values); + + ff = many(fa[0], fa[1], la[2], + fa[3], fa[4], la[5], + fa[6], fa[7], la[8], + fa[9], fa[10], la[11], + fa[12], fa[13], la[14], + fa[15], fa[16], la[17], + fa[18]); + if (fabs(f - ff) < FLT_EPSILON) + exit(0); + else + abort(); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/negint.c b/user/mpy/lib/libffi/testsuite/libffi.call/negint.c new file mode 100644 index 0000000..6e2f26f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/negint.c @@ -0,0 +1,52 @@ +/* Area: ffi_call + Purpose: Check that negative integers are passed correctly. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static int checking(int a, short b, signed char c) +{ + + return (a < 0 && b < 0 && c < 0); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + + signed int si; + signed short ss; + signed char sc; + + args[0] = &ffi_type_sint; + values[0] = &si; + args[1] = &ffi_type_sshort; + values[1] = &ss; + args[2] = &ffi_type_schar; + values[2] = ≻ + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &ffi_type_sint, args) == FFI_OK); + + si = -6; + ss = -12; + sc = -1; + + checking (si, ss, sc); + + ffi_call(&cif, FFI_FN(checking), &rint, values); + + printf ("%d vs %d\n", (int)rint, checking (si, ss, sc)); + + CHECK(rint != 0); + + exit (0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c new file mode 100644 index 0000000..c15e3a0 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c @@ -0,0 +1,152 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_16byte1 { + double a; + float b; + int c; +} cls_struct_16byte1; + +typedef struct cls_struct_16byte2 { + int ii; + double dd; + float ff; +} cls_struct_16byte2; + +typedef struct cls_struct_combined { + cls_struct_16byte1 d; + cls_struct_16byte2 e; +} cls_struct_combined; + +cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, + struct cls_struct_16byte2 b1, + struct cls_struct_combined b2) +{ + struct cls_struct_combined result; + + result.d.a = b0.a + b1.dd + b2.d.a; + result.d.b = b0.b + b1.ff + b2.d.b; + result.d.c = b0.c + b1.ii + b2.d.c; + result.e.ii = b0.c + b1.ii + b2.e.ii; + result.e.dd = b0.a + b1.dd + b2.e.dd; + result.e.ff = b0.b + b1.ff + b2.e.ff; + + printf("%g %g %d %d %g %g %g %g %d %d %g %g: %g %g %d %d %g %g\n", + b0.a, b0.b, b0.c, + b1.ii, b1.dd, b1.ff, + b2.d.a, b2.d.b, b2.d.c, + b2.e.ii, b2.e.dd, b2.e.ff, + result.d.a, result.d.b, result.d.c, + result.e.ii, result.e.dd, result.e.ff); + + return result; +} + +static void +cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_16byte1 b0; + struct cls_struct_16byte2 b1; + struct cls_struct_combined b2; + + b0 = *(struct cls_struct_16byte1*)(args[0]); + b1 = *(struct cls_struct_16byte2*)(args[1]); + b2 = *(struct cls_struct_combined*)(args[2]); + + + *(cls_struct_combined*)resp = cls_struct_combined_fn(b0, b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[5]; + ffi_type* cls_struct_fields1[5]; + ffi_type* cls_struct_fields2[5]; + ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; + struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; + struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, + {3, 1.0, 8.0}}; + struct cls_struct_combined res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_type2.size = 0; + cls_struct_type2.alignment = 0; + cls_struct_type2.type = FFI_TYPE_STRUCT; + cls_struct_type2.elements = cls_struct_fields2; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_float; + cls_struct_fields[2] = &ffi_type_sint; + cls_struct_fields[3] = NULL; + + cls_struct_fields1[0] = &ffi_type_sint; + cls_struct_fields1[1] = &ffi_type_double; + cls_struct_fields1[2] = &ffi_type_float; + cls_struct_fields1[3] = NULL; + + cls_struct_fields2[0] = &cls_struct_type; + cls_struct_fields2[1] = &cls_struct_type1; + cls_struct_fields2[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = &cls_struct_type2; + dbl_arg_types[3] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type2, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl); + /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ + CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); + CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); + CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1, + cls_struct_16byte2, + cls_struct_combined)) + (code))(e_dbl, f_dbl, g_dbl); + /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ + CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); + CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); + CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c new file mode 100644 index 0000000..477a6b9 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c @@ -0,0 +1,161 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_16byte1 { + double a; + float b; + int c; +} cls_struct_16byte1; + +typedef struct cls_struct_16byte2 { + int ii; + double dd; + float ff; +} cls_struct_16byte2; + +typedef struct cls_struct_combined { + cls_struct_16byte1 d; + cls_struct_16byte2 e; +} cls_struct_combined; + +cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, + struct cls_struct_16byte2 b1, + struct cls_struct_combined b2, + struct cls_struct_16byte1 b3) +{ + struct cls_struct_combined result; + + result.d.a = b0.a + b1.dd + b2.d.a; + result.d.b = b0.b + b1.ff + b2.d.b; + result.d.c = b0.c + b1.ii + b2.d.c; + result.e.ii = b0.c + b1.ii + b2.e.ii; + result.e.dd = b0.a + b1.dd + b2.e.dd; + result.e.ff = b0.b + b1.ff + b2.e.ff; + + printf("%g %g %d %d %g %g %g %g %d %d %g %g %g %g %d: %g %g %d %d %g %g\n", + b0.a, b0.b, b0.c, + b1.ii, b1.dd, b1.ff, + b2.d.a, b2.d.b, b2.d.c, + b2.e.ii, b2.e.dd, b2.e.ff, + b3.a, b3.b, b3.c, + result.d.a, result.d.b, result.d.c, + result.e.ii, result.e.dd, result.e.ff); + + return result; +} + +static void +cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct cls_struct_16byte1 b0; + struct cls_struct_16byte2 b1; + struct cls_struct_combined b2; + struct cls_struct_16byte1 b3; + + b0 = *(struct cls_struct_16byte1*)(args[0]); + b1 = *(struct cls_struct_16byte2*)(args[1]); + b2 = *(struct cls_struct_combined*)(args[2]); + b3 = *(struct cls_struct_16byte1*)(args[3]); + + + *(cls_struct_combined*)resp = cls_struct_combined_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[5]; + ffi_type* cls_struct_fields1[5]; + ffi_type* cls_struct_fields2[5]; + ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; + struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; + struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, + {3, 1.0, 8.0}}; + struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4}; + struct cls_struct_combined res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_type2.size = 0; + cls_struct_type2.alignment = 0; + cls_struct_type2.type = FFI_TYPE_STRUCT; + cls_struct_type2.elements = cls_struct_fields2; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_float; + cls_struct_fields[2] = &ffi_type_sint; + cls_struct_fields[3] = NULL; + + cls_struct_fields1[0] = &ffi_type_sint; + cls_struct_fields1[1] = &ffi_type_double; + cls_struct_fields1[2] = &ffi_type_float; + cls_struct_fields1[3] = NULL; + + cls_struct_fields2[0] = &cls_struct_type; + cls_struct_fields2[1] = &cls_struct_type1; + cls_struct_fields2[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = &cls_struct_type2; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type2, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl); + /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */ + CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); + CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); + CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); + + res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1, + cls_struct_16byte2, + cls_struct_combined, + cls_struct_16byte1)) + (code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */ + CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); + CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); + CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + /* CHECK( 1 == 0); */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c new file mode 100644 index 0000000..34a74e7 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c @@ -0,0 +1,133 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + unsigned long long a; + unsigned char b; +} A; + +typedef struct B { + unsigned char y; + struct A x; + unsigned int z; +} B; + +typedef struct C { + unsigned long long d; + unsigned char e; +} C; + +static B B_fn(struct A b2, struct B b3, struct C b4) +{ + struct B result; + + result.x.a = b2.a + b3.x.a + b3.z + b4.d; + result.x.b = b2.b + b3.x.b + b3.y + b4.e; + result.y = b2.b + b3.x.b + b4.e; + + printf("%d %d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, + (int)b3.x.a, b3.x.b, b3.y, b3.z, (int)b4.d, b4.e, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + struct C b2; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + b2 = *(struct C*)(args[2]); + + *(B*)resp = B_fn(b0, b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[4]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[4]; + ffi_type* cls_struct_fields2[3]; + ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; + ffi_type* dbl_arg_types[4]; + + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = { 99, {12LL , 127}, 255}; + struct C g_dbl = { 2LL, 9}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_type2.size = 0; + cls_struct_type2.alignment = 0; + cls_struct_type2.type = FFI_TYPE_STRUCT; + cls_struct_type2.elements = cls_struct_fields2; + + cls_struct_fields[0] = &ffi_type_uint64; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &ffi_type_uchar; + cls_struct_fields1[1] = &cls_struct_type; + cls_struct_fields1[2] = &ffi_type_uint; + cls_struct_fields1[3] = NULL; + + cls_struct_fields2[0] = &ffi_type_uint64; + cls_struct_fields2[1] = &ffi_type_uchar; + cls_struct_fields2[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = &cls_struct_type2; + dbl_arg_types[3] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99 255 2 9: 270 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); + /* { dg-output "\n1 7 12 127 99 255 2 9: 270 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c new file mode 100644 index 0000000..3510493 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c @@ -0,0 +1,121 @@ +/* Area: ffi_call, closure_call + Purpose: Check parameter passing with nested structs + of a single type. This tests the special cases + for homogeneous floating-point aggregates in the + AArch64 PCS. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + float a_x; + float a_y; +} A; + +typedef struct B { + float b_x; + float b_y; +} B; + +typedef struct C { + A a; + B b; +} C; + +static C C_fn (int x, int y, int z, C source, int i, int j, int k) +{ + C result; + result.a.a_x = source.a.a_x; + result.a.a_y = source.a.a_y; + result.b.b_x = source.b.b_x; + result.b.b_y = source.b.b_y; + + printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k); + + printf ("%.1f, %.1f, %.1f, %.1f, " + "%.1f, %.1f, %.1f, %.1f\n", + source.a.a_x, source.a.a_y, + source.b.b_x, source.b.b_y, + result.a.a_x, result.a.a_y, + result.b.b_x, result.b.b_y); + + return result; +} + +int main (void) +{ + ffi_cif cif; + + ffi_type* struct_fields_source_a[3]; + ffi_type* struct_fields_source_b[3]; + ffi_type* struct_fields_source_c[3]; + ffi_type* arg_types[8]; + + ffi_type struct_type_a, struct_type_b, struct_type_c; + + struct A source_fld_a = {1.0, 2.0}; + struct B source_fld_b = {4.0, 8.0}; + int k = 1; + + struct C result; + struct C source = {source_fld_a, source_fld_b}; + + struct_type_a.size = 0; + struct_type_a.alignment = 0; + struct_type_a.type = FFI_TYPE_STRUCT; + struct_type_a.elements = struct_fields_source_a; + + struct_type_b.size = 0; + struct_type_b.alignment = 0; + struct_type_b.type = FFI_TYPE_STRUCT; + struct_type_b.elements = struct_fields_source_b; + + struct_type_c.size = 0; + struct_type_c.alignment = 0; + struct_type_c.type = FFI_TYPE_STRUCT; + struct_type_c.elements = struct_fields_source_c; + + struct_fields_source_a[0] = &ffi_type_float; + struct_fields_source_a[1] = &ffi_type_float; + struct_fields_source_a[2] = NULL; + + struct_fields_source_b[0] = &ffi_type_float; + struct_fields_source_b[1] = &ffi_type_float; + struct_fields_source_b[2] = NULL; + + struct_fields_source_c[0] = &struct_type_a; + struct_fields_source_c[1] = &struct_type_b; + struct_fields_source_c[2] = NULL; + + arg_types[0] = &ffi_type_sint32; + arg_types[1] = &ffi_type_sint32; + arg_types[2] = &ffi_type_sint32; + arg_types[3] = &struct_type_c; + arg_types[4] = &ffi_type_sint32; + arg_types[5] = &ffi_type_sint32; + arg_types[6] = &ffi_type_sint32; + arg_types[7] = NULL; + + void *args[7]; + args[0] = &k; + args[1] = &k; + args[2] = &k; + args[3] = &source; + args[4] = &k; + args[5] = &k; + args[6] = &k; + CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, 7, &struct_type_c, + arg_types) == FFI_OK); + + ffi_call (&cif, FFI_FN (C_fn), &result, args); + /* { dg-output "1, 1, 1, 1, 1, 1\n" } */ + /* { dg-output "1.0, 2.0, 4.0, 8.0, 1.0, 2.0, 4.0, 8.0" } */ + CHECK (result.a.a_x == source.a.a_x); + CHECK (result.a.a_y == source.a.a_y); + CHECK (result.b.b_x == source.b.b_x); + CHECK (result.b.b_y == source.b.b_y); + exit (0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c new file mode 100644 index 0000000..69268cd --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c @@ -0,0 +1,110 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20030911 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + unsigned long a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +B B_fn(struct A b0, struct B b1) +{ + struct B result; + + result.x.a = b0.a + b1.x.a; + result.x.b = b0.b + b1.x.b + b1.y; + result.y = b0.b + b1.x.b; + + printf("%lu %d %lu %d %d: %lu %d %d\n", b0.a, b0.b, b1.x.a, b1.x.b, b1.y, + result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + struct A e_dbl = { 1, 7}; + struct B f_dbl = {{12 , 127}, 99}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_ulong; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c new file mode 100644 index 0000000..ab18cad --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c @@ -0,0 +1,111 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20030911 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + unsigned long long a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +B B_fn(struct A b0, struct B b1) +{ + struct B result; + + result.x.a = b0.a + b1.x.a; + result.x.b = b0.b + b1.x.b + b1.y; + result.y = b0.b + b1.x.b; + + printf("%d %d %d %d %d: %d %d %d\n", (int)b0.a, b0.b, + (int)b1.x.a, b1.x.b, b1.y, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12LL , 127}, 99}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_uint64; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c new file mode 100644 index 0000000..2ffb4d6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c @@ -0,0 +1,111 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: PR 25630. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + double a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +static B B_fn(struct A b2, struct B b3) +{ + struct B result; + + result.x.a = b2.a + b3.x.a; + result.x.b = b2.b + b3.x.b + b3.y; + result.y = b2.b + b3.x.b; + + printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, + (int)b3.x.a, b3.x.b, b3.y, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c new file mode 100644 index 0000000..6c79845 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c @@ -0,0 +1,112 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + long double a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +static B B_fn(struct A b2, struct B b3) +{ + struct B result; + + result.x.a = b2.a + b3.x.a; + result.x.b = b2.b + b3.x.b + b3.y; + result.y = b2.b + b3.x.b; + + printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, + (int)b3.x.a, b3.x.b, b3.y, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_longdouble; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c new file mode 100644 index 0000000..59d3579 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c @@ -0,0 +1,131 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: PR 25630. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + double a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +typedef struct C { + long d; + unsigned char e; +} C; + +static B B_fn(struct A b2, struct B b3, struct C b4) +{ + struct B result; + + result.x.a = b2.a + b3.x.a + b4.d; + result.x.b = b2.b + b3.x.b + b3.y + b4.e; + result.y = b2.b + b3.x.b + b4.e; + + printf("%d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, + (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + struct C b2; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + b2 = *(struct C*)(args[2]); + + *(B*)resp = B_fn(b0, b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[4]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type* cls_struct_fields2[3]; + ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; + ffi_type* dbl_arg_types[4]; + + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + struct C g_dbl = { 2, 9}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_type2.size = 0; + cls_struct_type2.alignment = 0; + cls_struct_type2.type = FFI_TYPE_STRUCT; + cls_struct_type2.elements = cls_struct_fields2; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + cls_struct_fields2[0] = &ffi_type_slong; + cls_struct_fields2[1] = &ffi_type_uchar; + cls_struct_fields2[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = &cls_struct_type2; + dbl_arg_types[3] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); + /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c new file mode 100644 index 0000000..27595e6 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c @@ -0,0 +1,111 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + unsigned long long a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +static B B_fn(struct A b2, struct B b3) +{ + struct B result; + + result.x.a = b2.a + b3.x.a; + result.x.b = b2.b + b3.x.b + b3.y; + result.y = b2.b + b3.x.b; + + printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, + (int)b3.x.a, b3.x.b, b3.y, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_uint64; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c new file mode 100644 index 0000000..0e6c682 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c @@ -0,0 +1,131 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + unsigned long long a; + unsigned char b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +typedef struct C { + unsigned long long d; + unsigned char e; +} C; + +static B B_fn(struct A b2, struct B b3, struct C b4) +{ + struct B result; + + result.x.a = b2.a + b3.x.a + b4.d; + result.x.b = b2.b + b3.x.b + b3.y + b4.e; + result.y = b2.b + b3.x.b + b4.e; + + printf("%d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, + (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, + (int)result.x.a, result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + struct C b2; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + b2 = *(struct C*)(args[2]); + + *(B*)resp = B_fn(b0, b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[4]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type* cls_struct_fields2[3]; + ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; + ffi_type* dbl_arg_types[4]; + + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12LL , 127}, 99}; + struct C g_dbl = { 2LL, 9}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_type2.size = 0; + cls_struct_type2.alignment = 0; + cls_struct_type2.type = FFI_TYPE_STRUCT; + cls_struct_type2.elements = cls_struct_fields2; + + cls_struct_fields[0] = &ffi_type_uint64; + cls_struct_fields[1] = &ffi_type_uchar; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + cls_struct_fields2[0] = &ffi_type_uint64; + cls_struct_fields2[1] = &ffi_type_uchar; + cls_struct_fields2[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = &cls_struct_type2; + dbl_arg_types[3] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); + /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c new file mode 100644 index 0000000..5f7ac67 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c @@ -0,0 +1,131 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Contains structs as parameter of the struct itself. + Sample taken from Alan Modras patch to src/prep_cif.c. + Limitations: none. + PR: none. + Originator: 20051010 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + unsigned char a; + unsigned long long b; +} A; + +typedef struct B { + struct A x; + unsigned char y; +} B; + +typedef struct C { + unsigned long d; + unsigned char e; +} C; + +static B B_fn(struct A b2, struct B b3, struct C b4) +{ + struct B result; + + result.x.a = b2.a + b3.x.a + b4.d; + result.x.b = b2.b + b3.x.b + b3.y + b4.e; + result.y = b2.b + b3.x.b + b4.e; + + printf("%d %d %d %d %d %d %d: %d %d %d\n", b2.a, (int)b2.b, + b3.x.a, (int)b3.x.b, b3.y, (int)b4.d, b4.e, + result.x.a, (int)result.x.b, result.y); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct A b0; + struct B b1; + struct C b2; + + b0 = *(struct A*)(args[0]); + b1 = *(struct B*)(args[1]); + b2 = *(struct C*)(args[2]); + + *(B*)resp = B_fn(b0, b1, b2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[4]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type* cls_struct_fields2[3]; + ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; + ffi_type* dbl_arg_types[4]; + + struct A e_dbl = { 1, 7LL}; + struct B f_dbl = {{12.0 , 127}, 99}; + struct C g_dbl = { 2, 9}; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_type2.size = 0; + cls_struct_type2.alignment = 0; + cls_struct_type2.type = FFI_TYPE_STRUCT; + cls_struct_type2.elements = cls_struct_fields2; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &ffi_type_uint64; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = &ffi_type_uchar; + cls_struct_fields1[2] = NULL; + + cls_struct_fields2[0] = &ffi_type_ulong; + cls_struct_fields2[1] = &ffi_type_uchar; + cls_struct_fields2[2] = NULL; + + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = &cls_struct_type2; + dbl_arg_types[3] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); + /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */ + CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); + CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); + CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c b/user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c new file mode 100644 index 0000000..7da1621 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c @@ -0,0 +1,127 @@ +/* Area: ffi_call + Purpose: Reproduce bug found in python ctypes + Limitations: none. + PR: Fedora 1174037 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct { + long x; + long y; +} POINT; + +typedef struct { + long left; + long top; + long right; + long bottom; +} RECT; + +static RECT ABI_ATTR pr_test(int i __UNUSED__, RECT ar __UNUSED__, + RECT* br __UNUSED__, POINT cp __UNUSED__, + RECT dr __UNUSED__, RECT *er __UNUSED__, + POINT fp, RECT gr __UNUSED__) +{ + RECT result; + + result.left = fp.x; + result.right = fp.y; + result.top = fp.x; + result.bottom = fp.y; + + return result; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type point_type, rect_type; + ffi_type *point_type_elements[3]; + ffi_type *rect_type_elements[5]; + + int i; + POINT cp, fp; + RECT ar, br, dr, er, gr; + RECT *p1, *p2; + + /* This is a hack to get a properly aligned result buffer */ + RECT *rect_result = + (RECT *) malloc (sizeof(RECT)); + + point_type.size = 0; + point_type.alignment = 0; + point_type.type = FFI_TYPE_STRUCT; + point_type.elements = point_type_elements; + point_type_elements[0] = &ffi_type_slong; + point_type_elements[1] = &ffi_type_slong; + point_type_elements[2] = NULL; + + rect_type.size = 0; + rect_type.alignment = 0; + rect_type.type = FFI_TYPE_STRUCT; + rect_type.elements = rect_type_elements; + rect_type_elements[0] = &ffi_type_slong; + rect_type_elements[1] = &ffi_type_slong; + rect_type_elements[2] = &ffi_type_slong; + rect_type_elements[3] = &ffi_type_slong; + rect_type_elements[4] = NULL; + + args[0] = &ffi_type_sint; + args[1] = &rect_type; + args[2] = &ffi_type_pointer; + args[3] = &point_type; + args[4] = &rect_type; + args[5] = &ffi_type_pointer; + args[6] = &point_type; + args[7] = &rect_type; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 8, &rect_type, args) == FFI_OK); + + i = 1; + ar.left = 2; + ar.right = 3; + ar.top = 4; + ar.bottom = 5; + br.left = 6; + br.right = 7; + br.top = 8; + br.bottom = 9; + cp.x = 10; + cp.y = 11; + dr.left = 12; + dr.right = 13; + dr.top = 14; + dr.bottom = 15; + er.left = 16; + er.right = 17; + er.top = 18; + er.bottom = 19; + fp.x = 20; + fp.y = 21; + gr.left = 22; + gr.right = 23; + gr.top = 24; + gr.bottom = 25; + + values[0] = &i; + values[1] = &ar; + p1 = &br; + values[2] = &p1; + values[3] = &cp; + values[4] = &dr; + p2 = &er; + values[5] = &p2; + values[6] = &fp; + values[7] = &gr; + + ffi_call (&cif, FFI_FN(pr_test), rect_result, values); + + CHECK(rect_result->top == 20); + + free (rect_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/problem1.c b/user/mpy/lib/libffi/testsuite/libffi.call/problem1.c new file mode 100644 index 0000000..6a91555 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/problem1.c @@ -0,0 +1,90 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing with different structure size. + Limitations: none. + PR: none. + Originator: 20030828 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct my_ffi_struct { + double a; + double b; + double c; +} my_ffi_struct; + +my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2) +{ + struct my_ffi_struct result; + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + + printf("%g %g %g %g %g %g: %g %g %g\n", a1.a, a1.b, a1.c, + a2.a, a2.b, a2.c, result.a, result.b, result.c); + + return result; +} + +void stub(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + struct my_ffi_struct a1; + struct my_ffi_struct a2; + + a1 = *(struct my_ffi_struct*)(args[0]); + a2 = *(struct my_ffi_struct*)(args[1]); + + *(my_ffi_struct *)resp = callee(a1, a2); +} + + +int main(void) +{ + ffi_type* my_ffi_struct_fields[4]; + ffi_type my_ffi_struct_type; + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[4]; + ffi_type* arg_types[3]; + + struct my_ffi_struct g = { 1.0, 2.0, 3.0 }; + struct my_ffi_struct f = { 1.0, 2.0, 3.0 }; + struct my_ffi_struct res; + + my_ffi_struct_type.size = 0; + my_ffi_struct_type.alignment = 0; + my_ffi_struct_type.type = FFI_TYPE_STRUCT; + my_ffi_struct_type.elements = my_ffi_struct_fields; + + my_ffi_struct_fields[0] = &ffi_type_double; + my_ffi_struct_fields[1] = &ffi_type_double; + my_ffi_struct_fields[2] = &ffi_type_double; + my_ffi_struct_fields[3] = NULL; + + arg_types[0] = &my_ffi_struct_type; + arg_types[1] = &my_ffi_struct_type; + arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type, + arg_types) == FFI_OK); + + args[0] = &g; + args[1] = &f; + args[2] = NULL; + ffi_call(&cif, FFI_FN(callee), &res, args); + /* { dg-output "1 2 3 1 2 3: 2 4 6" } */ + printf("res: %g %g %g\n", res.a, res.b, res.c); + /* { dg-output "\nres: 2 4 6" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, stub, NULL, code) == FFI_OK); + + res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(code))(g, f); + /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ + printf("res: %g %g %g\n", res.a, res.b, res.c); + /* { dg-output "\nres: 2 4 6" } */ + + exit(0);; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/promotion.c b/user/mpy/lib/libffi/testsuite/libffi.call/promotion.c new file mode 100644 index 0000000..4456161 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/promotion.c @@ -0,0 +1,59 @@ +/* Area: ffi_call + Purpose: Promotion test. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +static int promotion(signed char sc, signed short ss, + unsigned char uc, unsigned short us) +{ + int r = (int) sc + (int) ss + (int) uc + (int) us; + + return r; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + signed char sc; + unsigned char uc; + signed short ss; + unsigned short us; + unsigned long ul; + + args[0] = &ffi_type_schar; + args[1] = &ffi_type_sshort; + args[2] = &ffi_type_uchar; + args[3] = &ffi_type_ushort; + values[0] = ≻ + values[1] = &ss; + values[2] = &uc; + values[3] = &us; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_sint, args) == FFI_OK); + + us = 0; + ul = 0; + + for (sc = (signed char) -127; + sc <= (signed char) 120; sc += 1) + for (ss = -30000; ss <= 30000; ss += 10000) + for (uc = (unsigned char) 0; + uc <= (unsigned char) 200; uc += 20) + for (us = 0; us <= 60000; us += 10000) + { + ul++; + ffi_call(&cif, FFI_FN(promotion), &rint, values); + CHECK((int)rint == (signed char) sc + (signed short) ss + + (unsigned char) uc + (unsigned short) us); + } + printf("%lu promotion tests run\n", ul); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c b/user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c new file mode 100644 index 0000000..e29bd6c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c @@ -0,0 +1,114 @@ +/* Area: ffi_call + Purpose: Check different structures. + Limitations: none. + PR: none. + Originator: Ronald Oussoren 20030824 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct Point { + float x; + float y; +} Point; + +typedef struct Size { + float h; + float w; +} Size; + +typedef struct Rect { + Point o; + Size s; +} Rect; + +int doit(int o, char* s, Point p, Rect r, int last) +{ + printf("CALLED WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", + o, s, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, last); + return 42; +} + + +int main(void) +{ + ffi_type point_type; + ffi_type size_type; + ffi_type rect_type; + ffi_cif cif; + ffi_type* arglist[6]; + void* values[6]; + int r; + + /* + * First set up FFI types for the 3 struct types + */ + + point_type.size = 0; /*sizeof(Point);*/ + point_type.alignment = 0; /*__alignof__(Point);*/ + point_type.type = FFI_TYPE_STRUCT; + point_type.elements = malloc(3 * sizeof(ffi_type*)); + point_type.elements[0] = &ffi_type_float; + point_type.elements[1] = &ffi_type_float; + point_type.elements[2] = NULL; + + size_type.size = 0;/* sizeof(Size);*/ + size_type.alignment = 0;/* __alignof__(Size);*/ + size_type.type = FFI_TYPE_STRUCT; + size_type.elements = malloc(3 * sizeof(ffi_type*)); + size_type.elements[0] = &ffi_type_float; + size_type.elements[1] = &ffi_type_float; + size_type.elements[2] = NULL; + + rect_type.size = 0;/*sizeof(Rect);*/ + rect_type.alignment =0;/* __alignof__(Rect);*/ + rect_type.type = FFI_TYPE_STRUCT; + rect_type.elements = malloc(3 * sizeof(ffi_type*)); + rect_type.elements[0] = &point_type; + rect_type.elements[1] = &size_type; + rect_type.elements[2] = NULL; + + /* + * Create a CIF + */ + arglist[0] = &ffi_type_sint; + arglist[1] = &ffi_type_pointer; + arglist[2] = &point_type; + arglist[3] = &rect_type; + arglist[4] = &ffi_type_sint; + arglist[5] = NULL; + + r = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, + 5, &ffi_type_sint, arglist); + if (r != FFI_OK) { + abort(); + } + + + /* And call the function through the CIF */ + + { + Point p = { 1.0, 2.0 }; + Rect r = { { 9.0, 10.0}, { -1.0, -2.0 } }; + int o = 0; + int l = 42; + char* m = "myMethod"; + ffi_arg result; + + values[0] = &o; + values[1] = &m; + values[2] = &p; + values[3] = &r; + values[4] = &l; + values[5] = NULL; + + printf("CALLING WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", + o, m, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, l); + + ffi_call(&cif, FFI_FN(doit), &result, values); + + printf ("The result is %d\n", (int)result); + + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c new file mode 100644 index 0000000..fd07e50 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c @@ -0,0 +1,36 @@ +/* Area: ffi_call + Purpose: Check return value double. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static double return_dbl(double dbl) +{ + printf ("%f\n", dbl); + return 2 * dbl; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + double dbl, rdbl; + + args[0] = &ffi_type_double; + values[0] = &dbl; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_double, args) == FFI_OK); + + for (dbl = -127.3; dbl < 127; dbl++) + { + ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values); + printf ("%f vs %f\n", rdbl, return_dbl(dbl)); + CHECK(rdbl == 2 * dbl); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c new file mode 100644 index 0000000..0ea5d50 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c @@ -0,0 +1,43 @@ +/* Area: ffi_call + Purpose: Check return value double. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static double return_dbl(double dbl1, float fl2, unsigned int in3, double dbl4) +{ + return dbl1 + fl2 + in3 + dbl4; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + double dbl1, dbl4, rdbl; + float fl2; + unsigned int in3; + args[0] = &ffi_type_double; + args[1] = &ffi_type_float; + args[2] = &ffi_type_uint; + args[3] = &ffi_type_double; + values[0] = &dbl1; + values[1] = &fl2; + values[2] = &in3; + values[3] = &dbl4; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_double, args) == FFI_OK); + dbl1 = 127.0; + fl2 = 128.0; + in3 = 255; + dbl4 = 512.7; + + ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values); + printf ("%f vs %f\n", rdbl, return_dbl(dbl1, fl2, in3, dbl4)); + CHECK(rdbl == dbl1 + fl2 + in3 + dbl4); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c new file mode 100644 index 0000000..b3818f8 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c @@ -0,0 +1,42 @@ +/* Area: ffi_call + Purpose: Check return value double. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static double return_dbl(double dbl1, double dbl2, unsigned int in3, double dbl4) +{ + return dbl1 + dbl2 + in3 + dbl4; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + double dbl1, dbl2, dbl4, rdbl; + unsigned int in3; + args[0] = &ffi_type_double; + args[1] = &ffi_type_double; + args[2] = &ffi_type_uint; + args[3] = &ffi_type_double; + values[0] = &dbl1; + values[1] = &dbl2; + values[2] = &in3; + values[3] = &dbl4; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_double, args) == FFI_OK); + dbl1 = 127.0; + dbl2 = 128.0; + in3 = 255; + dbl4 = 512.7; + + ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values); + printf ("%f vs %f\n", rdbl, return_dbl(dbl1, dbl2, in3, dbl4)); + CHECK(rdbl == dbl1 + dbl2 + in3 + dbl4); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c new file mode 100644 index 0000000..fb8a09e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c @@ -0,0 +1,35 @@ +/* Area: ffi_call + Purpose: Check return value float. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static float return_fl(float fl) +{ + return 2 * fl; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + float fl, rfl; + + args[0] = &ffi_type_float; + values[0] = &fl; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_float, args) == FFI_OK); + + for (fl = -127.0; fl < 127; fl++) + { + ffi_call(&cif, FFI_FN(return_fl), &rfl, values); + printf ("%f vs %f\n", rfl, return_fl(fl)); + CHECK(rfl == 2 * fl); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c new file mode 100644 index 0000000..c3d92c2 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c @@ -0,0 +1,36 @@ +/* Area: ffi_call + Purpose: Check return value float. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static float return_fl(float fl1, float fl2) +{ + return fl1 + fl2; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + float fl1, fl2, rfl; + + args[0] = &ffi_type_float; + args[1] = &ffi_type_float; + values[0] = &fl1; + values[1] = &fl2; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_float, args) == FFI_OK); + fl1 = 127.0; + fl2 = 128.0; + + ffi_call(&cif, FFI_FN(return_fl), &rfl, values); + printf ("%f vs %f\n", rfl, return_fl(fl1, fl2)); + CHECK(rfl == fl1 + fl2); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c new file mode 100644 index 0000000..ddb976c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c @@ -0,0 +1,49 @@ +/* Area: ffi_call + Purpose: Check return value float. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +/* Use volatile float to avoid false negative on ix86. See PR target/323. */ +static float return_fl(float fl1, float fl2, float fl3, float fl4) +{ + volatile float sum; + + sum = fl1 + fl2 + fl3 + fl4; + return sum; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + float fl1, fl2, fl3, fl4, rfl; + volatile float sum; + + args[0] = &ffi_type_float; + args[1] = &ffi_type_float; + args[2] = &ffi_type_float; + args[3] = &ffi_type_float; + values[0] = &fl1; + values[1] = &fl2; + values[2] = &fl3; + values[3] = &fl4; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_float, args) == FFI_OK); + fl1 = 127.0; + fl2 = 128.0; + fl3 = 255.1; + fl4 = 512.7; + + ffi_call(&cif, FFI_FN(return_fl), &rfl, values); + printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, fl3, fl4)); + + sum = fl1 + fl2 + fl3 + fl4; + CHECK(rfl == sum); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c new file mode 100644 index 0000000..c37877b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c @@ -0,0 +1,42 @@ +/* Area: ffi_call + Purpose: Check return value float. + Limitations: none. + PR: none. + Originator: 20050212 */ + +/* { dg-do run } */ +#include "ffitest.h" + +static float return_fl(float fl1, float fl2, unsigned int in3, float fl4) +{ + return fl1 + fl2 + in3 + fl4; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + float fl1, fl2, fl4, rfl; + unsigned int in3; + args[0] = &ffi_type_float; + args[1] = &ffi_type_float; + args[2] = &ffi_type_uint; + args[3] = &ffi_type_float; + values[0] = &fl1; + values[1] = &fl2; + values[2] = &in3; + values[3] = &fl4; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &ffi_type_float, args) == FFI_OK); + fl1 = 127.0; + fl2 = 128.0; + in3 = 255; + fl4 = 512.7; + + ffi_call(&cif, FFI_FN(return_fl), &rfl, values); + printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, in3, fl4)); + CHECK(rfl == fl1 + fl2 + in3 + fl4); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c new file mode 100644 index 0000000..52a92fe --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c @@ -0,0 +1,34 @@ +/* Area: ffi_call + Purpose: Check return value long double. + Limitations: none. + PR: none. + Originator: 20071113 */ +/* { dg-do run } */ + +#include "ffitest.h" + +static long double return_ldl(long double ldl) +{ + return 2*ldl; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + long double ldl, rldl; + + args[0] = &ffi_type_longdouble; + values[0] = &ldl; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_longdouble, args) == FFI_OK); + + for (ldl = -127.0; ldl < 127.0; ldl++) + { + ffi_call(&cif, FFI_FN(return_ldl), &rldl, values); + CHECK(rldl == 2 * ldl); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c new file mode 100644 index 0000000..ea4a1e4 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c @@ -0,0 +1,41 @@ +/* Area: ffi_call + Purpose: Check return value long long. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +static long long return_ll(long long ll) +{ + return ll; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + long long rlonglong; + long long ll; + + args[0] = &ffi_type_sint64; + values[0] = ≪ + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_sint64, args) == FFI_OK); + + for (ll = 0LL; ll < 100LL; ll++) + { + ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); + CHECK(rlonglong == ll); + } + + for (ll = 55555555555000LL; ll < 55555555555100LL; ll++) + { + ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); + CHECK(rlonglong == ll); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c new file mode 100644 index 0000000..593e8a3 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c @@ -0,0 +1,43 @@ +/* Area: ffi_call + Purpose: Check if long long are passed in the corresponding regs on ppc. + Limitations: none. + PR: 20104. + Originator: 20050222 */ + +/* { dg-do run } */ +/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ +#include "ffitest.h" +static long long return_ll(int ll0, long long ll1, int ll2) +{ + return ll0 + ll1 + ll2; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + long long rlonglong; + long long ll1; + unsigned ll0, ll2; + + args[0] = &ffi_type_sint; + args[1] = &ffi_type_sint64; + args[2] = &ffi_type_sint; + values[0] = &ll0; + values[1] = &ll1; + values[2] = &ll2; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &ffi_type_sint64, args) == FFI_OK); + + ll0 = 11111111; + ll1 = 11111111111000LL; + ll2 = 11111111; + + ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); + printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2); + /* { dg-output "res: 11111133333222, 11111133333222" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c new file mode 100644 index 0000000..a36cf3e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c @@ -0,0 +1,36 @@ +/* Area: ffi_call + Purpose: Check return value signed char. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +static signed char return_sc(signed char sc) +{ + return sc; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + signed char sc; + + args[0] = &ffi_type_schar; + values[0] = ≻ + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_schar, args) == FFI_OK); + + for (sc = (signed char) -127; + sc < (signed char) 127; sc++) + { + ffi_call(&cif, FFI_FN(return_sc), &rint, values); + CHECK((signed char)rint == sc); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c new file mode 100644 index 0000000..f0fd345 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c @@ -0,0 +1,38 @@ +/* Area: ffi_call + Purpose: Check if long as return type is handled correctly. + Limitations: none. + PR: none. + */ + +/* { dg-do run } */ +#include "ffitest.h" +static long return_sl(long l1, long l2) +{ + return l1 - l2; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg res; + unsigned long l1, l2; + + args[0] = &ffi_type_slong; + args[1] = &ffi_type_slong; + values[0] = &l1; + values[1] = &l2; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_slong, args) == FFI_OK); + + l1 = 1073741823L; + l2 = 1073741824L; + + ffi_call(&cif, FFI_FN(return_sl), &res, values); + printf("res: %ld, %ld\n", (long)res, l1 - l2); + /* { dg-output "res: -1, -1" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c new file mode 100644 index 0000000..6fe5546 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c @@ -0,0 +1,38 @@ +/* Area: ffi_call + Purpose: Check return value unsigned char. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +static unsigned char return_uc(unsigned char uc) +{ + return uc; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + + unsigned char uc; + + args[0] = &ffi_type_uchar; + values[0] = &uc; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_uchar, args) == FFI_OK); + + for (uc = (unsigned char) '\x00'; + uc < (unsigned char) '\xff'; uc++) + { + ffi_call(&cif, FFI_FN(return_uc), &rint, values); + CHECK((unsigned char)rint == uc); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c new file mode 100644 index 0000000..12b266f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c @@ -0,0 +1,38 @@ +/* Area: ffi_call + Purpose: Check if unsigned long as return type is handled correctly. + Limitations: none. + PR: none. + Originator: 20060724 */ + +/* { dg-do run } */ +#include "ffitest.h" +static unsigned long return_ul(unsigned long ul1, unsigned long ul2) +{ + return ul1 + ul2; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg res; + unsigned long ul1, ul2; + + args[0] = &ffi_type_ulong; + args[1] = &ffi_type_ulong; + values[0] = &ul1; + values[1] = &ul2; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_ulong, args) == FFI_OK); + + ul1 = 1073741823L; + ul2 = 1073741824L; + + ffi_call(&cif, FFI_FN(return_ul), &res, values); + printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2); + /* { dg-output "res: 2147483647, 2147483647" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c new file mode 100644 index 0000000..71c2469 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c @@ -0,0 +1,145 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure returning with different structure size. + Depending on the ABI. Check bigger struct which overlaps + the gp and fp register count on Darwin/AIX/ppc64. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/21/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +#include "ffitest.h" + +/* 13 FPRs: 104 bytes */ +/* 14 FPRs: 112 bytes */ + +typedef struct struct_108byte { + double a; + double b; + double c; + double d; + double e; + double f; + double g; + double h; + double i; + double j; + double k; + double l; + double m; + int n; +} struct_108byte; + +struct_108byte cls_struct_108byte_fn( + struct_108byte b0, + struct_108byte b1, + struct_108byte b2, + struct_108byte b3) +{ + struct_108byte result; + + result.a = b0.a + b1.a + b2.a + b3.a; + result.b = b0.b + b1.b + b2.b + b3.b; + result.c = b0.c + b1.c + b2.c + b3.c; + result.d = b0.d + b1.d + b2.d + b3.d; + result.e = b0.e + b1.e + b2.e + b3.e; + result.f = b0.f + b1.f + b2.f + b3.f; + result.g = b0.g + b1.g + b2.g + b3.g; + result.h = b0.h + b1.h + b2.h + b3.h; + result.i = b0.i + b1.i + b2.i + b3.i; + result.j = b0.j + b1.j + b2.j + b3.j; + result.k = b0.k + b1.k + b2.k + b3.k; + result.l = b0.l + b1.l + b2.l + b3.l; + result.m = b0.m + b1.m + b2.m + b3.m; + result.n = b0.n + b1.n + b2.n + b3.n; + + printf("%g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", result.a, result.b, result.c, + result.d, result.e, result.f, result.g, result.h, result.i, + result.j, result.k, result.l, result.m, result.n); + + return result; +} + +static void +cls_struct_108byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) +{ + struct_108byte b0, b1, b2, b3; + + b0 = *(struct_108byte*)(args[0]); + b1 = *(struct_108byte*)(args[1]); + b2 = *(struct_108byte*)(args[2]); + b3 = *(struct_108byte*)(args[3]); + + *(struct_108byte*)resp = cls_struct_108byte_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[15]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct_108byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 7 }; + struct_108byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 4 }; + struct_108byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 3 }; + struct_108byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 2 }; + struct_108byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_double; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = &ffi_type_double; + cls_struct_fields[5] = &ffi_type_double; + cls_struct_fields[6] = &ffi_type_double; + cls_struct_fields[7] = &ffi_type_double; + cls_struct_fields[8] = &ffi_type_double; + cls_struct_fields[9] = &ffi_type_double; + cls_struct_fields[10] = &ffi_type_double; + cls_struct_fields[11] = &ffi_type_double; + cls_struct_fields[12] = &ffi_type_double; + cls_struct_fields[13] = &ffi_type_sint32; + cls_struct_fields[14] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = &cls_struct_type; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_108byte_fn), &res_dbl, args_dbl); + /* { dg-output "22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ + printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, + res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_108byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((struct_108byte(*)(struct_108byte, struct_108byte, + struct_108byte, struct_108byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ + printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, + res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c new file mode 100644 index 0000000..d9c750e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c @@ -0,0 +1,148 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure returning with different structure size. + Depending on the ABI. Check bigger struct which overlaps + the gp and fp register count on Darwin/AIX/ppc64. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/21/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +#include "ffitest.h" + +/* 13 FPRs: 104 bytes */ +/* 14 FPRs: 112 bytes */ + +typedef struct struct_116byte { + double a; + double b; + double c; + double d; + double e; + double f; + double g; + double h; + double i; + double j; + double k; + double l; + double m; + double n; + int o; +} struct_116byte; + +struct_116byte cls_struct_116byte_fn( + struct_116byte b0, + struct_116byte b1, + struct_116byte b2, + struct_116byte b3) +{ + struct_116byte result; + + result.a = b0.a + b1.a + b2.a + b3.a; + result.b = b0.b + b1.b + b2.b + b3.b; + result.c = b0.c + b1.c + b2.c + b3.c; + result.d = b0.d + b1.d + b2.d + b3.d; + result.e = b0.e + b1.e + b2.e + b3.e; + result.f = b0.f + b1.f + b2.f + b3.f; + result.g = b0.g + b1.g + b2.g + b3.g; + result.h = b0.h + b1.h + b2.h + b3.h; + result.i = b0.i + b1.i + b2.i + b3.i; + result.j = b0.j + b1.j + b2.j + b3.j; + result.k = b0.k + b1.k + b2.k + b3.k; + result.l = b0.l + b1.l + b2.l + b3.l; + result.m = b0.m + b1.m + b2.m + b3.m; + result.n = b0.n + b1.n + b2.n + b3.n; + result.o = b0.o + b1.o + b2.o + b3.o; + + printf("%g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", result.a, result.b, result.c, + result.d, result.e, result.f, result.g, result.h, result.i, + result.j, result.k, result.l, result.m, result.n, result.o); + + return result; +} + +static void +cls_struct_116byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) +{ + struct_116byte b0, b1, b2, b3; + + b0 = *(struct_116byte*)(args[0]); + b1 = *(struct_116byte*)(args[1]); + b2 = *(struct_116byte*)(args[2]); + b3 = *(struct_116byte*)(args[3]); + + *(struct_116byte*)resp = cls_struct_116byte_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[16]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct_116byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 7 }; + struct_116byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 6.0, 4 }; + struct_116byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 7.0, 3 }; + struct_116byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 8.0, 2 }; + struct_116byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_double; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = &ffi_type_double; + cls_struct_fields[5] = &ffi_type_double; + cls_struct_fields[6] = &ffi_type_double; + cls_struct_fields[7] = &ffi_type_double; + cls_struct_fields[8] = &ffi_type_double; + cls_struct_fields[9] = &ffi_type_double; + cls_struct_fields[10] = &ffi_type_double; + cls_struct_fields[11] = &ffi_type_double; + cls_struct_fields[12] = &ffi_type_double; + cls_struct_fields[13] = &ffi_type_double; + cls_struct_fields[14] = &ffi_type_sint32; + cls_struct_fields[15] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = &cls_struct_type; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_116byte_fn), &res_dbl, args_dbl); + /* { dg-output "22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ + printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, + res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_116byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((struct_116byte(*)(struct_116byte, struct_116byte, + struct_116byte, struct_116byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ + printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, + res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, + res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c new file mode 100644 index 0000000..973ee02 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c @@ -0,0 +1,124 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure returning with different structure size. + Depending on the ABI. Check bigger struct which overlaps + the gp and fp register count on Darwin/AIX/ppc64. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/21/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +#include "ffitest.h" + +typedef struct struct_72byte { + double a; + double b; + double c; + double d; + double e; + double f; + double g; + double h; + double i; +} struct_72byte; + +struct_72byte cls_struct_72byte_fn( + struct_72byte b0, + struct_72byte b1, + struct_72byte b2, + struct_72byte b3) +{ + struct_72byte result; + + result.a = b0.a + b1.a + b2.a + b3.a; + result.b = b0.b + b1.b + b2.b + b3.b; + result.c = b0.c + b1.c + b2.c + b3.c; + result.d = b0.d + b1.d + b2.d + b3.d; + result.e = b0.e + b1.e + b2.e + b3.e; + result.f = b0.f + b1.f + b2.f + b3.f; + result.g = b0.g + b1.g + b2.g + b3.g; + result.h = b0.h + b1.h + b2.h + b3.h; + result.i = b0.i + b1.i + b2.i + b3.i; + + printf("%g %g %g %g %g %g %g %g %g\n", result.a, result.b, result.c, + result.d, result.e, result.f, result.g, result.h, result.i); + + return result; +} + +static void +cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) +{ + struct_72byte b0, b1, b2, b3; + + b0 = *(struct_72byte*)(args[0]); + b1 = *(struct_72byte*)(args[1]); + b2 = *(struct_72byte*)(args[2]); + b3 = *(struct_72byte*)(args[3]); + + *(struct_72byte*)resp = cls_struct_72byte_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[10]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7.0 }; + struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0 }; + struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3.0 }; + struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2.0 }; + struct_72byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_double; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = &ffi_type_double; + cls_struct_fields[5] = &ffi_type_double; + cls_struct_fields[6] = &ffi_type_double; + cls_struct_fields[7] = &ffi_type_double; + cls_struct_fields[8] = &ffi_type_double; + cls_struct_fields[9] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = &cls_struct_type; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_72byte_fn), &res_dbl, args_dbl); + /* { dg-output "22 15 17 25 6 13 19 18 16" } */ + printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte, + struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n22 15 17 25 6 13 19 18 16" } */ + printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c new file mode 100644 index 0000000..84323d1 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c @@ -0,0 +1,125 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure returning with different structure size. + Depending on the ABI. Check bigger struct which overlaps + the gp and fp register count on Darwin/AIX/ppc64. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/21/2007 */ + +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ +#include "ffitest.h" + +typedef struct struct_72byte { + double a; + double b; + double c; + double d; + double e; + double f; + double g; + double h; + long long i; +} struct_72byte; + +struct_72byte cls_struct_72byte_fn( + struct_72byte b0, + struct_72byte b1, + struct_72byte b2, + struct_72byte b3) +{ + struct_72byte result; + + result.a = b0.a + b1.a + b2.a + b3.a; + result.b = b0.b + b1.b + b2.b + b3.b; + result.c = b0.c + b1.c + b2.c + b3.c; + result.d = b0.d + b1.d + b2.d + b3.d; + result.e = b0.e + b1.e + b2.e + b3.e; + result.f = b0.f + b1.f + b2.f + b3.f; + result.g = b0.g + b1.g + b2.g + b3.g; + result.h = b0.h + b1.h + b2.h + b3.h; + result.i = b0.i + b1.i + b2.i + b3.i; + + printf("%g %g %g %g %g %g %g %g %" PRIdLL "\n", result.a, result.b, result.c, + result.d, result.e, result.f, result.g, result.h, result.i); + + return result; +} + +static void +cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) +{ + struct_72byte b0, b1, b2, b3; + + b0 = *(struct_72byte*)(args[0]); + b1 = *(struct_72byte*)(args[1]); + b2 = *(struct_72byte*)(args[2]); + b3 = *(struct_72byte*)(args[3]); + + *(struct_72byte*)resp = cls_struct_72byte_fn(b0, b1, b2, b3); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[5]; + ffi_type* cls_struct_fields[10]; + ffi_type cls_struct_type; + ffi_type* dbl_arg_types[5]; + + struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7 }; + struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4 }; + struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3 }; + struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2 }; + struct_72byte res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_double; + cls_struct_fields[1] = &ffi_type_double; + cls_struct_fields[2] = &ffi_type_double; + cls_struct_fields[3] = &ffi_type_double; + cls_struct_fields[4] = &ffi_type_double; + cls_struct_fields[5] = &ffi_type_double; + cls_struct_fields[6] = &ffi_type_double; + cls_struct_fields[7] = &ffi_type_double; + cls_struct_fields[8] = &ffi_type_sint64; + cls_struct_fields[9] = NULL; + + dbl_arg_types[0] = &cls_struct_type; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = &cls_struct_type; + dbl_arg_types[3] = &cls_struct_type; + dbl_arg_types[4] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = &g_dbl; + args_dbl[3] = &h_dbl; + args_dbl[4] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_72byte_fn), &res_dbl, args_dbl); + /* { dg-output "22 15 17 25 6 13 19 18 16" } */ + printf("res: %g %g %g %g %g %g %g %g %" PRIdLL "\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK); + + res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte, + struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); + /* { dg-output "\n22 15 17 25 6 13 19 18 16" } */ + printf("res: %g %g %g %g %g %g %g %g %" PRIdLL "\n", res_dbl.a, res_dbl.b, res_dbl.c, + res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); + /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen.c new file mode 100644 index 0000000..35b70ea --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/strlen.c @@ -0,0 +1,44 @@ +/* Area: ffi_call + Purpose: Check strlen function call. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +static size_t ABI_ATTR my_strlen(char *s) +{ + return (strlen(s)); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + char *s; + + args[0] = &ffi_type_pointer; + values[0] = (void*) &s; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, + &ffi_type_sint, args) == FFI_OK); + + s = "a"; + ffi_call(&cif, FFI_FN(my_strlen), &rint, values); + CHECK(rint == 1); + + s = "1234567"; + ffi_call(&cif, FFI_FN(my_strlen), &rint, values); + CHECK(rint == 7); + + s = "1234567890123456789012345"; + ffi_call(&cif, FFI_FN(my_strlen), &rint, values); + CHECK(rint == 25); + + exit (0); +} + diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c new file mode 100644 index 0000000..96282bc --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c @@ -0,0 +1,49 @@ +/* Area: ffi_call + Purpose: Check strlen function call with additional arguments. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static size_t ABI_ATTR my_f(char *s, float a) +{ + return (size_t) ((int) strlen(s) + (int) a); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + char *s; + float v2; + args[0] = &ffi_type_pointer; + args[1] = &ffi_type_float; + values[0] = (void*) &s; + values[1] = (void*) &v2; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, + &ffi_type_sint, args) == FFI_OK); + + s = "a"; + v2 = 0.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 1); + + s = "1234567"; + v2 = -1.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 6); + + s = "1234567890123456789012345"; + v2 = 1.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 26); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c new file mode 100644 index 0000000..beba86e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c @@ -0,0 +1,49 @@ +/* Area: ffi_call + Purpose: Check strlen function call with additional arguments. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static size_t ABI_ATTR my_f(float a, char *s) +{ + return (size_t) ((int) strlen(s) + (int) a); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + char *s; + float v2; + args[1] = &ffi_type_pointer; + args[0] = &ffi_type_float; + values[1] = (void*) &s; + values[0] = (void*) &v2; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, + &ffi_type_sint, args) == FFI_OK); + + s = "a"; + v2 = 0.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 1); + + s = "1234567"; + v2 = -1.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 6); + + s = "1234567890123456789012345"; + v2 = 1.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 26); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c new file mode 100644 index 0000000..d5d42b4 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c @@ -0,0 +1,55 @@ +/* Area: ffi_call + Purpose: Check strlen function call with additional arguments. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static size_t ABI_ATTR my_f(float a, char *s, int i) +{ + return (size_t) ((int) strlen(s) + (int) a + i); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + char *s; + int v1; + float v2; + args[2] = &ffi_type_sint; + args[1] = &ffi_type_pointer; + args[0] = &ffi_type_float; + values[2] = (void*) &v1; + values[1] = (void*) &s; + values[0] = (void*) &v2; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 3, + &ffi_type_sint, args) == FFI_OK); + + s = "a"; + v1 = 1; + v2 = 0.0; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 2); + + s = "1234567"; + v2 = -1.0; + v1 = -2; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 4); + + s = "1234567890123456789012345"; + v2 = 1.0; + v1 = 2; + ffi_call(&cif, FFI_FN(my_f), &rint, values); + CHECK(rint == 28); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct1.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct1.c new file mode 100644 index 0000000..c13e23f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct1.c @@ -0,0 +1,67 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + unsigned char uc; + double d; + unsigned int ui; +} test_structure_1; + +static test_structure_1 ABI_ATTR struct1(test_structure_1 ts) +{ + ts.uc++; + ts.d--; + ts.ui++; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts1_type; + ffi_type *ts1_type_elements[4]; + + test_structure_1 ts1_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_1 *ts1_result = + (test_structure_1 *) malloc (sizeof(test_structure_1)); + + ts1_type.size = 0; + ts1_type.alignment = 0; + ts1_type.type = FFI_TYPE_STRUCT; + ts1_type.elements = ts1_type_elements; + ts1_type_elements[0] = &ffi_type_uchar; + ts1_type_elements[1] = &ffi_type_double; + ts1_type_elements[2] = &ffi_type_uint; + ts1_type_elements[3] = NULL; + + args[0] = &ts1_type; + values[0] = &ts1_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, + &ts1_type, args) == FFI_OK); + + ts1_arg.uc = '\x01'; + ts1_arg.d = 3.14159; + ts1_arg.ui = 555; + + ffi_call(&cif, FFI_FN(struct1), ts1_result, values); + + CHECK(ts1_result->ui == 556); + CHECK(ts1_result->d == 3.14159 - 1); + + free (ts1_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct2.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct2.c new file mode 100644 index 0000000..5077a5e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct2.c @@ -0,0 +1,67 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + double d1; + double d2; +} test_structure_2; + +static test_structure_2 ABI_ATTR struct2(test_structure_2 ts) +{ + ts.d1--; + ts.d2--; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + test_structure_2 ts2_arg; + ffi_type ts2_type; + ffi_type *ts2_type_elements[3]; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_2 *ts2_result = + (test_structure_2 *) malloc (sizeof(test_structure_2)); + + ts2_type.size = 0; + ts2_type.alignment = 0; + ts2_type.type = FFI_TYPE_STRUCT; + ts2_type.elements = ts2_type_elements; + ts2_type_elements[0] = &ffi_type_double; + ts2_type_elements[1] = &ffi_type_double; + ts2_type_elements[2] = NULL; + + args[0] = &ts2_type; + values[0] = &ts2_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts2_type, args) == FFI_OK); + + ts2_arg.d1 = 5.55; + ts2_arg.d2 = 6.66; + + printf ("%g\n", ts2_arg.d1); + printf ("%g\n", ts2_arg.d2); + + ffi_call(&cif, FFI_FN(struct2), ts2_result, values); + + printf ("%g\n", ts2_result->d1); + printf ("%g\n", ts2_result->d2); + + CHECK(ts2_result->d1 == 5.55 - 1); + CHECK(ts2_result->d2 == 6.66 - 1); + + free (ts2_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct3.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct3.c new file mode 100644 index 0000000..7eba0ea --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct3.c @@ -0,0 +1,60 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + int si; +} test_structure_3; + +static test_structure_3 ABI_ATTR struct3(test_structure_3 ts) +{ + ts.si = -(ts.si*2); + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + int compare_value; + ffi_type ts3_type; + ffi_type *ts3_type_elements[2]; + + test_structure_3 ts3_arg; + test_structure_3 *ts3_result = + (test_structure_3 *) malloc (sizeof(test_structure_3)); + + ts3_type.size = 0; + ts3_type.alignment = 0; + ts3_type.type = FFI_TYPE_STRUCT; + ts3_type.elements = ts3_type_elements; + ts3_type_elements[0] = &ffi_type_sint; + ts3_type_elements[1] = NULL; + + args[0] = &ts3_type; + values[0] = &ts3_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, + &ts3_type, args) == FFI_OK); + + ts3_arg.si = -123; + compare_value = ts3_arg.si; + + ffi_call(&cif, FFI_FN(struct3), ts3_result, values); + + printf ("%d %d\n", ts3_result->si, -(compare_value*2)); + + CHECK(ts3_result->si == -(compare_value*2)); + + free (ts3_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct4.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct4.c new file mode 100644 index 0000000..66a9551 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct4.c @@ -0,0 +1,64 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + unsigned ui1; + unsigned ui2; + unsigned ui3; +} test_structure_4; + +static test_structure_4 ABI_ATTR struct4(test_structure_4 ts) +{ + ts.ui3 = ts.ui1 * ts.ui2 * ts.ui3; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts4_type; + ffi_type *ts4_type_elements[4]; + + test_structure_4 ts4_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_4 *ts4_result = + (test_structure_4 *) malloc (sizeof(test_structure_4)); + + ts4_type.size = 0; + ts4_type.alignment = 0; + ts4_type.type = FFI_TYPE_STRUCT; + ts4_type.elements = ts4_type_elements; + ts4_type_elements[0] = &ffi_type_uint; + ts4_type_elements[1] = &ffi_type_uint; + ts4_type_elements[2] = &ffi_type_uint; + ts4_type_elements[3] = NULL; + + args[0] = &ts4_type; + values[0] = &ts4_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts4_type, args) == FFI_OK); + + ts4_arg.ui1 = 2; + ts4_arg.ui2 = 3; + ts4_arg.ui3 = 4; + + ffi_call (&cif, FFI_FN(struct4), ts4_result, values); + + CHECK(ts4_result->ui3 == 2U * 3U * 4U); + + + free (ts4_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct5.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct5.c new file mode 100644 index 0000000..23e2a3f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct5.c @@ -0,0 +1,66 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +typedef struct +{ + char c1; + char c2; +} test_structure_5; + +static test_structure_5 ABI_ATTR struct5(test_structure_5 ts1, test_structure_5 ts2) +{ + ts1.c1 += ts2.c1; + ts1.c2 -= ts2.c2; + + return ts1; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts5_type; + ffi_type *ts5_type_elements[3]; + + test_structure_5 ts5_arg1, ts5_arg2; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_5 *ts5_result = + (test_structure_5 *) malloc (sizeof(test_structure_5)); + + ts5_type.size = 0; + ts5_type.alignment = 0; + ts5_type.type = FFI_TYPE_STRUCT; + ts5_type.elements = ts5_type_elements; + ts5_type_elements[0] = &ffi_type_schar; + ts5_type_elements[1] = &ffi_type_schar; + ts5_type_elements[2] = NULL; + + args[0] = &ts5_type; + args[1] = &ts5_type; + values[0] = &ts5_arg1; + values[1] = &ts5_arg2; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &ts5_type, args) == FFI_OK); + + ts5_arg1.c1 = 2; + ts5_arg1.c2 = 6; + ts5_arg2.c1 = 5; + ts5_arg2.c2 = 3; + + ffi_call (&cif, FFI_FN(struct5), ts5_result, values); + + CHECK(ts5_result->c1 == 7); + CHECK(ts5_result->c2 == 3); + + + free (ts5_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct6.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct6.c new file mode 100644 index 0000000..173c66e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct6.c @@ -0,0 +1,64 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +typedef struct +{ + float f; + double d; +} test_structure_6; + +static test_structure_6 ABI_ATTR struct6 (test_structure_6 ts) +{ + ts.f += 1; + ts.d += 1; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts6_type; + ffi_type *ts6_type_elements[3]; + + test_structure_6 ts6_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_6 *ts6_result = + (test_structure_6 *) malloc (sizeof(test_structure_6)); + + ts6_type.size = 0; + ts6_type.alignment = 0; + ts6_type.type = FFI_TYPE_STRUCT; + ts6_type.elements = ts6_type_elements; + ts6_type_elements[0] = &ffi_type_float; + ts6_type_elements[1] = &ffi_type_double; + ts6_type_elements[2] = NULL; + + args[0] = &ts6_type; + values[0] = &ts6_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts6_type, args) == FFI_OK); + + ts6_arg.f = 5.55f; + ts6_arg.d = 6.66; + + printf ("%g\n", ts6_arg.f); + printf ("%g\n", ts6_arg.d); + + ffi_call(&cif, FFI_FN(struct6), ts6_result, values); + + CHECK(ts6_result->f == 5.55f + 1); + CHECK(ts6_result->d == 6.66 + 1); + + free (ts6_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct7.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct7.c new file mode 100644 index 0000000..badc7e0 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct7.c @@ -0,0 +1,74 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +typedef struct +{ + float f1; + float f2; + double d; +} test_structure_7; + +static test_structure_7 ABI_ATTR struct7 (test_structure_7 ts) +{ + ts.f1 += 1; + ts.f2 += 1; + ts.d += 1; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts7_type; + ffi_type *ts7_type_elements[4]; + + test_structure_7 ts7_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_7 *ts7_result = + (test_structure_7 *) malloc (sizeof(test_structure_7)); + + ts7_type.size = 0; + ts7_type.alignment = 0; + ts7_type.type = FFI_TYPE_STRUCT; + ts7_type.elements = ts7_type_elements; + ts7_type_elements[0] = &ffi_type_float; + ts7_type_elements[1] = &ffi_type_float; + ts7_type_elements[2] = &ffi_type_double; + ts7_type_elements[3] = NULL; + + args[0] = &ts7_type; + values[0] = &ts7_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts7_type, args) == FFI_OK); + + ts7_arg.f1 = 5.55f; + ts7_arg.f2 = 55.5f; + ts7_arg.d = 6.66; + + printf ("%g\n", ts7_arg.f1); + printf ("%g\n", ts7_arg.f2); + printf ("%g\n", ts7_arg.d); + + ffi_call(&cif, FFI_FN(struct7), ts7_result, values); + + printf ("%g\n", ts7_result->f1); + printf ("%g\n", ts7_result->f2); + printf ("%g\n", ts7_result->d); + + CHECK(ts7_result->f1 == 5.55f + 1); + CHECK(ts7_result->f2 == 55.5f + 1); + CHECK(ts7_result->d == 6.66 + 1); + + free (ts7_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct8.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct8.c new file mode 100644 index 0000000..ef204ec --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct8.c @@ -0,0 +1,81 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" +typedef struct +{ + float f1; + float f2; + float f3; + float f4; +} test_structure_8; + +static test_structure_8 ABI_ATTR struct8 (test_structure_8 ts) +{ + ts.f1 += 1; + ts.f2 += 1; + ts.f3 += 1; + ts.f4 += 1; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts8_type; + ffi_type *ts8_type_elements[5]; + + test_structure_8 ts8_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_8 *ts8_result = + (test_structure_8 *) malloc (sizeof(test_structure_8)); + + ts8_type.size = 0; + ts8_type.alignment = 0; + ts8_type.type = FFI_TYPE_STRUCT; + ts8_type.elements = ts8_type_elements; + ts8_type_elements[0] = &ffi_type_float; + ts8_type_elements[1] = &ffi_type_float; + ts8_type_elements[2] = &ffi_type_float; + ts8_type_elements[3] = &ffi_type_float; + ts8_type_elements[4] = NULL; + + args[0] = &ts8_type; + values[0] = &ts8_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts8_type, args) == FFI_OK); + + ts8_arg.f1 = 5.55f; + ts8_arg.f2 = 55.5f; + ts8_arg.f3 = -5.55f; + ts8_arg.f4 = -55.5f; + + printf ("%g\n", ts8_arg.f1); + printf ("%g\n", ts8_arg.f2); + printf ("%g\n", ts8_arg.f3); + printf ("%g\n", ts8_arg.f4); + + ffi_call(&cif, FFI_FN(struct8), ts8_result, values); + + printf ("%g\n", ts8_result->f1); + printf ("%g\n", ts8_result->f2); + printf ("%g\n", ts8_result->f3); + printf ("%g\n", ts8_result->f4); + + CHECK(ts8_result->f1 == 5.55f + 1); + CHECK(ts8_result->f2 == 55.5f + 1); + CHECK(ts8_result->f3 == -5.55f + 1); + CHECK(ts8_result->f4 == -55.5f + 1); + + free (ts8_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct9.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct9.c new file mode 100644 index 0000000..4a13b81 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/struct9.c @@ -0,0 +1,68 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + float f; + int i; +} test_structure_9; + +static test_structure_9 ABI_ATTR struct9 (test_structure_9 ts) +{ + ts.f += 1; + ts.i += 1; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts9_type; + ffi_type *ts9_type_elements[3]; + + test_structure_9 ts9_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_9 *ts9_result = + (test_structure_9 *) malloc (sizeof(test_structure_9)); + + ts9_type.size = 0; + ts9_type.alignment = 0; + ts9_type.type = FFI_TYPE_STRUCT; + ts9_type.elements = ts9_type_elements; + ts9_type_elements[0] = &ffi_type_float; + ts9_type_elements[1] = &ffi_type_sint; + ts9_type_elements[2] = NULL; + + args[0] = &ts9_type; + values[0] = &ts9_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts9_type, args) == FFI_OK); + + ts9_arg.f = 5.55f; + ts9_arg.i = 5; + + printf ("%g\n", ts9_arg.f); + printf ("%d\n", ts9_arg.i); + + ffi_call(&cif, FFI_FN(struct9), ts9_result, values); + + printf ("%g\n", ts9_result->f); + printf ("%d\n", ts9_result->i); + + CHECK(ts9_result->f == 5.55f + 1); + CHECK(ts9_result->i == 5 + 1); + + free (ts9_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c b/user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c new file mode 100644 index 0000000..ca31056 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c @@ -0,0 +1,70 @@ +/* Area: closure_call + Purpose: Check return value float. + Limitations: none. + PR: 41908. + Originator: 20091102 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_combined { + float a; + float b; + float c; + float d; +} cls_struct_combined; + +void cls_struct_combined_fn(struct cls_struct_combined arg) +{ + printf("%g %g %g %g\n", + arg.a, arg.b, + arg.c, arg.d); + fflush(stdout); +} + +static void +cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, + void** args, void* userdata __UNUSED__) +{ + struct cls_struct_combined a0; + + a0 = *(struct cls_struct_combined*)(args[0]); + + cls_struct_combined_fn(a0); +} + + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type* cls_struct_fields0[5]; + ffi_type cls_struct_type0; + ffi_type* dbl_arg_types[5]; + + struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; + + cls_struct_type0.size = 0; + cls_struct_type0.alignment = 0; + cls_struct_type0.type = FFI_TYPE_STRUCT; + cls_struct_type0.elements = cls_struct_fields0; + + cls_struct_fields0[0] = &ffi_type_float; + cls_struct_fields0[1] = &ffi_type_float; + cls_struct_fields0[2] = &ffi_type_float; + cls_struct_fields0[3] = &ffi_type_float; + cls_struct_fields0[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type0; + dbl_arg_types[1] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void, + dbl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); + + ((void(*)(cls_struct_combined)) (code))(g_dbl); + /* { dg-output "4 5 1 8" } */ + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c b/user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c new file mode 100644 index 0000000..f00d830 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + unsigned char uc; + double d; + unsigned int ui; +} test_structure_1; + +static test_structure_1 struct1(test_structure_1 ts) +{ + ts.uc++; + ts.d--; + ts.ui++; + + return ts; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_type ts1_type; + ffi_type *ts1_type_elements[4]; + + memset(&cif, 1, sizeof(cif)); + ts1_type.size = 0; + ts1_type.alignment = 0; + ts1_type.type = FFI_TYPE_STRUCT; + ts1_type.elements = ts1_type_elements; + ts1_type_elements[0] = &ffi_type_uchar; + ts1_type_elements[1] = &ffi_type_double; + ts1_type_elements[2] = &ffi_type_uint; + ts1_type_elements[3] = NULL; + + test_structure_1 ts1_arg; + /* This is a hack to get a properly aligned result buffer */ + test_structure_1 *ts1_result = + (test_structure_1 *) malloc (sizeof(test_structure_1)); + + args[0] = &ts1_type; + values[0] = &ts1_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ts1_type, args) == FFI_OK); + + ts1_arg.uc = '\x01'; + ts1_arg.d = 3.14159; + ts1_arg.ui = 555; + + ffi_call(&cif, FFI_FN(struct1), ts1_result, values); + + CHECK(ts1_result->ui == 556); + CHECK(ts1_result->d == 3.14159 - 1); + + free (ts1_result); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc b/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc new file mode 100644 index 0000000..67cfefe --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc @@ -0,0 +1,117 @@ +/* Area: ffi_closure, unwind info + Purpose: Check if the unwind information is passed correctly. + Limitations: none. + PR: none. + Originator: Jeff Sturm */ + +/* { dg-do run } */ + +#include "ffitest.h" + +void ABI_ATTR +closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, + void** args __UNUSED__, void* userdata __UNUSED__) +{ + throw 9; +} + +typedef void (*closure_test_type)(); + +void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) + { + *(ffi_arg*)resp = + (int)*(float *)args[0] +(int)(*(float *)args[1]) + + (int)(*(float *)args[2]) + (int)*(float *)args[3] + + (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) + + (int)*(float *)args[6] + (int)(*(int *)args[7]) + + (int)(*(double*)args[8]) + (int)*(int *)args[9] + + (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + + (int)*(int *)args[12] + (int)(*(int *)args[13]) + + (int)(*(int *)args[14]) + *(int *)args[15] + (int)(intptr_t)userdata; + + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", + (int)*(float *)args[0], (int)(*(float *)args[1]), + (int)(*(float *)args[2]), (int)*(float *)args[3], + (int)(*(signed short *)args[4]), (int)(*(float *)args[5]), + (int)*(float *)args[6], (int)(*(int *)args[7]), + (int)(*(double *)args[8]), (int)*(int *)args[9], + (int)(*(int *)args[10]), (int)(*(float *)args[11]), + (int)*(int *)args[12], (int)(*(int *)args[13]), + (int)(*(int *)args[14]), *(int *)args[15], + (int)(intptr_t)userdata, (int)*(ffi_arg*)resp); + + throw (int)*(ffi_arg*)resp; +} + +typedef int (*closure_test_type1)(float, float, float, float, signed short, + float, float, int, double, int, int, float, + int, int, int, int); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = (ffi_closure *)ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[17]; + + { + cl_arg_types[1] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, + &ffi_type_void, cl_arg_types) == FFI_OK); + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn, NULL, code) == FFI_OK); + + try + { + (*((closure_test_type)(code)))(); + } catch (int exception_code) + { + CHECK(exception_code == 9); + } + + printf("part one OK\n"); + /* { dg-output "part one OK" } */ + } + + { + + cl_arg_types[0] = &ffi_type_float; + cl_arg_types[1] = &ffi_type_float; + cl_arg_types[2] = &ffi_type_float; + cl_arg_types[3] = &ffi_type_float; + cl_arg_types[4] = &ffi_type_sshort; + cl_arg_types[5] = &ffi_type_float; + cl_arg_types[6] = &ffi_type_float; + cl_arg_types[7] = &ffi_type_uint; + cl_arg_types[8] = &ffi_type_double; + cl_arg_types[9] = &ffi_type_uint; + cl_arg_types[10] = &ffi_type_uint; + cl_arg_types[11] = &ffi_type_float; + cl_arg_types[12] = &ffi_type_uint; + cl_arg_types[13] = &ffi_type_uint; + cl_arg_types[14] = &ffi_type_uint; + cl_arg_types[15] = &ffi_type_uint; + cl_arg_types[16] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1, + (void *) 3 /* userdata */, code) == FFI_OK); + try + { + (*((closure_test_type1)code)) + (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13, + 19, 21, 1); + /* { dg-output "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ + } catch (int exception_code) + { + CHECK(exception_code == 255); + } + printf("part two OK\n"); + /* { dg-output "\npart two OK" } */ + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc b/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc new file mode 100644 index 0000000..ec61164 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc @@ -0,0 +1,54 @@ +/* Area: ffi_call, unwind info + Purpose: Check if the unwind information is passed correctly. + Limitations: none. + PR: none. + Originator: Andreas Tobler 20061213 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +static int checking(int a __UNUSED__, short b __UNUSED__, + signed char c __UNUSED__) +{ + throw 9; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + ffi_arg rint; + + signed int si; + signed short ss; + signed char sc; + + args[0] = &ffi_type_sint; + values[0] = &si; + args[1] = &ffi_type_sshort; + values[1] = &ss; + args[2] = &ffi_type_schar; + values[2] = ≻ + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &ffi_type_sint, args) == FFI_OK); + + si = -6; + ss = -12; + sc = -1; + { + try + { + ffi_call(&cif, FFI_FN(checking), &rint, values); + } catch (int exception_code) + { + CHECK(exception_code == 9); + } + printf("part one OK\n"); + /* { dg-output "part one OK" } */ + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_1.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_1.c new file mode 100644 index 0000000..7f96809 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/va_1.c @@ -0,0 +1,196 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static int +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + unsigned char uc; + signed char sc; + unsigned short us; + signed short ss; + unsigned int ui; + signed int si; + unsigned long ul; + signed long sl; + float f; + double d; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + + uc = va_arg (ap, unsigned); + sc = va_arg (ap, signed); + + us = va_arg (ap, unsigned); + ss = va_arg (ap, signed); + + ui = va_arg (ap, unsigned int); + si = va_arg (ap, signed int); + + ul = va_arg (ap, unsigned long); + sl = va_arg (ap, signed long); + + f = va_arg (ap, double); /* C standard promotes float->double + when anonymous */ + d = va_arg (ap, double); + + printf ("%u %u %u %u %u %u %u %u %u uc=%u sc=%d %u %d %u %d %lu %ld %f %f\n", + s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b, + uc, sc, + us, ss, + ui, si, + ul, sl, + f, d); + va_end (ap); + return n + 1; +} + +int +main (void) +{ + ffi_cif cif; + void* args[15]; + ffi_type* arg_types[15]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + ffi_arg res; + + unsigned char uc; + signed char sc; + unsigned short us; + signed short ss; + unsigned int ui; + signed int si; + unsigned long ul; + signed long sl; + double d1; + double f1; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = &ffi_type_uchar; + arg_types[5] = &ffi_type_schar; + arg_types[6] = &ffi_type_ushort; + arg_types[7] = &ffi_type_sshort; + arg_types[8] = &ffi_type_uint; + arg_types[9] = &ffi_type_sint; + arg_types[10] = &ffi_type_ulong; + arg_types[11] = &ffi_type_slong; + arg_types[12] = &ffi_type_double; + arg_types[13] = &ffi_type_double; + arg_types[14] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + uc = 9; + sc = 10; + us = 11; + ss = 12; + ui = 13; + si = 14; + ul = 15; + sl = 16; + f1 = 2.12; + d1 = 3.13; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = &uc; + args[5] = ≻ + args[6] = &us; + args[7] = &ss; + args[8] = &ui; + args[9] = &si; + args[10] = &ul; + args[11] = &sl; + args[12] = &f1; + args[13] = &d1; + args[14] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 42" } */ + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c new file mode 100644 index 0000000..e645206 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c @@ -0,0 +1,121 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static int +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b); + va_end (ap); + return n + 1; +} + +int +main (void) +{ + ffi_cif cif; + void* args[5]; + ffi_type* arg_types[5]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + ffi_arg res; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 42" } */ + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c new file mode 100644 index 0000000..56f5b9c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c @@ -0,0 +1,123 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static struct small_tag +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b); + va_end (ap); + s1.a += s2.a; + s1.b += s2.b; + return s1; +} + +int +main (void) +{ + ffi_cif cif; + void* args[5]; + ffi_type* arg_types[5]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + struct small_tag res; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &s_type, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8" } */ + printf("res: %d %d\n", res.a, res.b); + /* { dg-output "\nres: 12 14" } */ + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c new file mode 100644 index 0000000..9a27e7f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c @@ -0,0 +1,125 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static struct large_tag +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b); + va_end (ap); + l.a += s1.a; + l.b += s1.b; + l.c += s2.a; + l.d += s2.b; + return l; +} + +int +main (void) +{ + ffi_cif cif; + void* args[5]; + ffi_type* arg_types[5]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + struct large_tag res; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &l_type, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8" } */ + printf("res: %d %d %d %d %d\n", res.a, res.b, res.c, res.d, res.e); + /* { dg-output "\nres: 15 17 19 21 14" } */ + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc new file mode 100644 index 0000000..4a812ed --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc @@ -0,0 +1,91 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include + +typedef struct cls_struct_align { + unsigned char a; + _Complex T_C_TYPE b; + unsigned char c; +} cls_struct_align; + +cls_struct_align cls_struct_align_fn( + struct cls_struct_align a1, struct cls_struct_align a2) +{ + struct cls_struct_align result; + + result.a = a1.a + a2.a; + result.b = a1.b + a2.b; + result.c = a1.c + a2.c; + + printf("%d %f,%fi %d %d %f,%fi %d: %d %f,%fi %d\n", + a1.a, T_CONV creal (a1.b), T_CONV cimag (a1.b), a1.c, + a2.a, T_CONV creal (a2.b), T_CONV cimag (a2.b), a2.c, + result.a, T_CONV creal (result.b), T_CONV cimag (result.b), result.c); + + return result; +} + +static void +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + + struct cls_struct_align a1, a2; + + a1 = *(struct cls_struct_align*)(args[0]); + a2 = *(struct cls_struct_align*)(args[1]); + + *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_c[5]; + ffi_type* cls_struct_fields[4]; + ffi_type cls_struct_type; + ffi_type* c_arg_types[5]; + + struct cls_struct_align g_c = { 12, 4951 + 7 * I, 127 }; + struct cls_struct_align f_c = { 1, 9320 + 1 * I, 13 }; + struct cls_struct_align res_c; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_fields[0] = &ffi_type_uchar; + cls_struct_fields[1] = &T_FFI_TYPE; + cls_struct_fields[2] = &ffi_type_uchar; + cls_struct_fields[3] = NULL; + + c_arg_types[0] = &cls_struct_type; + c_arg_types[1] = &cls_struct_type; + c_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + c_arg_types) == FFI_OK); + + args_c[0] = &g_c; + args_c[1] = &f_c; + args_c[2] = NULL; + + ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_c, args_c); + /* { dg-output "12 4951,7i 127 1 9320,1i 13: 13 14271,8i 140" } */ + printf("res: %d %f,%fi %d\n", + res_c.a, T_CONV creal (res_c.b), T_CONV cimag (res_c.b), res_c.c); + /* { dg-output "\nres: 13 14271,8i 140" } */ + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); + + res_c = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_c, f_c); + /* { dg-output "\n12 4951,7i 127 1 9320,1i 13: 13 14271,8i 140" } */ + printf("res: %d %f,%fi %d\n", + res_c.a, T_CONV creal (res_c.b), T_CONV cimag (res_c.b), res_c.c); + /* { dg-output "\nres: 13 14271,8i 140" } */ + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c new file mode 100644 index 0000000..0dff23a --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "cls_align_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c new file mode 100644 index 0000000..0affbd0 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "cls_align_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c new file mode 100644 index 0000000..7889ba8 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure alignment of complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "cls_align_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc new file mode 100644 index 0000000..f937404 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc @@ -0,0 +1,42 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include + +static void cls_ret_complex_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + _Complex T_C_TYPE *pa; + _Complex T_C_TYPE *pr; + pa = (_Complex T_C_TYPE *)args[0]; + pr = (_Complex T_C_TYPE *)resp; + *pr = *pa; + + printf("%.6f,%.6fi: %.6f,%.6fi\n", + T_CONV creal (*pa), T_CONV cimag (*pa), + T_CONV creal (*pr), T_CONV cimag (*pr)); + } +typedef _Complex T_C_TYPE (*cls_ret_complex)(_Complex T_C_TYPE); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[2]; + _Complex T_C_TYPE res; + + cl_arg_types[0] = &T_FFI_TYPE; + cl_arg_types[1] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &T_FFI_TYPE, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_complex_fn, NULL, code) == FFI_OK); + + res = (*((cls_ret_complex)code))(0.125 + 128.0 * I); + printf("res: %.6f,%.6fi\n", T_CONV creal (res), T_CONV cimag (res)); + CHECK (res == (0.125 + 128.0 * I)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c new file mode 100644 index 0000000..05e3534 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c @@ -0,0 +1,10 @@ +/* Area: closure_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "cls_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c new file mode 100644 index 0000000..5df7849 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c @@ -0,0 +1,10 @@ +/* Area: closure_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "cls_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c new file mode 100644 index 0000000..2b1c320 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c @@ -0,0 +1,10 @@ +/* Area: closure_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "cls_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc new file mode 100644 index 0000000..df8708d --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc @@ -0,0 +1,71 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include + +typedef struct Cs { + _Complex T_C_TYPE x; + _Complex T_C_TYPE y; +} Cs; + +Cs gc; + +void +closure_test_fn(Cs p) +{ + printf("%.1f,%.1fi %.1f,%.1fi\n", + T_CONV creal (p.x), T_CONV cimag (p.x), + T_CONV creal (p.y), T_CONV cimag (p.y)); + gc = p; +} + +void +closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, + void** args, void* userdata __UNUSED__) +{ + closure_test_fn(*(Cs*)args[0]); +} + +int main(int argc __UNUSED__, char** argv __UNUSED__) +{ + ffi_cif cif; + + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type *cl_arg_types[1]; + + ffi_type ts1_type; + ffi_type* ts1_type_elements[4]; + + Cs arg = { 1.0 + 11.0 * I, 2.0 + 22.0 * I}; + + ts1_type.size = 0; + ts1_type.alignment = 0; + ts1_type.type = FFI_TYPE_STRUCT; + ts1_type.elements = ts1_type_elements; + + ts1_type_elements[0] = &T_FFI_TYPE; + ts1_type_elements[1] = &T_FFI_TYPE; + ts1_type_elements[2] = NULL; + + cl_arg_types[0] = &ts1_type; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &ffi_type_void, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK); + + gc.x = 0.0 + 0.0 * I; + gc.y = 0.0 + 0.0 * I; + ((void*(*)(Cs))(code))(arg); + /* { dg-output "1.0,11.0i 2.0,22.0i\n" } */ + CHECK (gc.x == arg.x && gc.y == arg.y); + + gc.x = 0.0 + 0.0 * I; + gc.y = 0.0 + 0.0 * I; + closure_test_fn(arg); + /* { dg-output "1.0,11.0i 2.0,22.0i\n" } */ + CHECK (gc.x == arg.x && gc.y == arg.y); + + return 0; +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c new file mode 100644 index 0000000..ec71346 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Check complex arguments in structs. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "cls_complex_struct.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c new file mode 100644 index 0000000..96fdf75 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Check complex arguments in structs. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "cls_complex_struct.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c new file mode 100644 index 0000000..005b467 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Check complex arguments in structs. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "cls_complex_struct.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc new file mode 100644 index 0000000..8a3e15f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc @@ -0,0 +1,80 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include +#include +#include +#include + +static _Complex T_C_TYPE gComplexValue1 = 1 + 2 * I; +static _Complex T_C_TYPE gComplexValue2 = 3 + 4 * I; + +static int cls_variadic(const char *format, ...) +{ + va_list ap; + _Complex T_C_TYPE p1, p2; + + va_start (ap, format); + p1 = va_arg (ap, _Complex T_C_TYPE); + p2 = va_arg (ap, _Complex T_C_TYPE); + va_end (ap); + + return printf(format, T_CONV creal (p1), T_CONV cimag (p1), + T_CONV creal (p2), T_CONV cimag (p2)); +} + +static void +cls_complex_va_fn(ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + char* format = *(char**)args[0]; + gComplexValue1 = *(_Complex T_C_TYPE*)args[1]; + gComplexValue2 = *(_Complex T_C_TYPE*)args[2]; + + *(ffi_arg*)resp = + printf(format, + T_CONV creal (gComplexValue1), T_CONV cimag (gComplexValue1), + T_CONV creal (gComplexValue2), T_CONV cimag (gComplexValue2)); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[4]; + ffi_type* arg_types[4]; + char *format = "%.1f,%.1fi %.1f,%.1fi\n"; + + _Complex T_C_TYPE complexArg1 = 1.0 + 22.0 *I; + _Complex T_C_TYPE complexArg2 = 333.0 + 4444.0 *I; + ffi_arg res = 0; + + arg_types[0] = &ffi_type_pointer; + arg_types[1] = &T_FFI_TYPE; + arg_types[2] = &T_FFI_TYPE; + arg_types[3] = NULL; + + /* This printf call is variadic */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 3, &ffi_type_sint, + arg_types) == FFI_OK); + + args[0] = &format; + args[1] = &complexArg1; + args[2] = &complexArg2; + args[3] = NULL; + + ffi_call(&cif, FFI_FN(cls_variadic), &res, args); + printf("res: %d\n", (int) res); + CHECK (res == 24); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_complex_va_fn, NULL, code) + == FFI_OK); + + res = ((int(*)(char *, ...))(code))(format, complexArg1, complexArg2); + CHECK (gComplexValue1 == complexArg1); + CHECK (gComplexValue2 == complexArg2); + printf("res: %d\n", (int) res); + CHECK (res == 24); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c new file mode 100644 index 0000000..879ccf3 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Test complex' passed in variable argument lists. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "cls_complex_va.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c new file mode 100644 index 0000000..2b17826 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c @@ -0,0 +1,16 @@ +/* Area: ffi_call, closure_call + Purpose: Test complex' passed in variable argument lists. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +/* Alpha splits _Complex into two arguments. It's illegal to pass + float through varargs, so _Complex float goes badly. In sort of + gets passed as _Complex double, but the compiler doesn't agree + with itself on this issue. */ +/* { dg-do run { xfail alpha*-*-* } } */ + +#include "complex_defs_float.inc" +#include "cls_complex_va.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c new file mode 100644 index 0000000..6eca965 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call, closure_call + Purpose: Test complex' passed in variable argument lists. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "cls_complex_va.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp b/user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp new file mode 100644 index 0000000..4631db2 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp @@ -0,0 +1,36 @@ +# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +dg-init +libffi-init + +global srcdir subdir + +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] + +if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } { + run-many-tests $tlist "" +} else { + foreach test $tlist { + unsupported "$test" + } +} + +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc new file mode 100644 index 0000000..515ae3e --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc @@ -0,0 +1,51 @@ +/* -*-c-*-*/ +#include "ffitest.h" +#include + +static _Complex T_C_TYPE f_complex(_Complex T_C_TYPE c, int x, int *py) +{ + c = -(2 * creal (c)) + (cimag (c) + 1)* I; + *py += x; + + return c; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + + _Complex T_C_TYPE tc_arg; + _Complex T_C_TYPE tc_result; + int tc_int_arg_x; + int tc_y; + int *tc_ptr_arg_y = &tc_y; + + args[0] = &T_FFI_TYPE; + args[1] = &ffi_type_sint; + args[2] = &ffi_type_pointer; + values[0] = &tc_arg; + values[1] = &tc_int_arg_x; + values[2] = &tc_ptr_arg_y; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &T_FFI_TYPE, args) == FFI_OK); + + tc_arg = 1 + 7 * I; + tc_int_arg_x = 1234; + tc_y = 9876; + ffi_call(&cif, FFI_FN(f_complex), &tc_result, values); + + printf ("%f,%fi %f,%fi, x %d 1234, y %d 11110\n", + T_CONV creal (tc_result), T_CONV cimag (tc_result), + T_CONV creal (2.0), T_CONV creal (8.0), tc_int_arg_x, tc_y); + + CHECK (creal (tc_result) == -2); + CHECK (cimag (tc_result) == 8); + CHECK (tc_int_arg_x == 1234); + CHECK (*tc_ptr_arg_y == 11110); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc new file mode 100644 index 0000000..3583e16 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc @@ -0,0 +1,7 @@ +/* -*-c-*- */ +/* Complex base type. */ +#define T_FFI_TYPE ffi_type_complex_double +/* C type corresponding to the base type. */ +#define T_C_TYPE double +/* C cast for a value of type T_C_TYPE that is passed to printf. */ +#define T_CONV diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc new file mode 100644 index 0000000..bbd9375 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc @@ -0,0 +1,7 @@ +/* -*-c-*- */ +/* Complex base type. */ +#define T_FFI_TYPE ffi_type_complex_float +/* C type corresponding to the base type. */ +#define T_C_TYPE float +/* C cast for a value of type T_C_TYPE that is passed to printf. */ +#define T_CONV (double) diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc new file mode 100644 index 0000000..14b9f24 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc @@ -0,0 +1,7 @@ +/* -*-c-*- */ +/* Complex base type. */ +#define T_FFI_TYPE ffi_type_complex_longdouble +/* C type corresponding to the base type. */ +#define T_C_TYPE long double +/* C cast for a value of type T_C_TYPE that is passed to printf. */ +#define T_CONV diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c new file mode 100644 index 0000000..8a3297b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check complex types. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c new file mode 100644 index 0000000..5044ebb --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check complex types. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c new file mode 100644 index 0000000..bac3190 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c @@ -0,0 +1,86 @@ +/* Area: ffi_call + Purpose: Check non-standard complex types. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "ffitest.h" +#include "ffi.h" +#include + +_Complex int f_complex(_Complex int c, int x, int *py) +{ + __real__ c = -2 * __real__ c; + __imag__ c = __imag__ c + 1; + *py += x; + return c; +} + +/* + * This macro can be used to define new complex type descriptors + * in a platform independent way. + * + * name: Name of the new descriptor is ffi_type_complex_. + * type: The C base type of the complex type. + */ +#define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \ + static ffi_type *ffi_elements_complex_##name [2] = { \ + (ffi_type *)(&ffitype), NULL \ + }; \ + struct struct_align_complex_##name { \ + char c; \ + _Complex type x; \ + }; \ + ffi_type ffi_type_complex_##name = { \ + sizeof(_Complex type), \ + offsetof(struct struct_align_complex_##name, x), \ + FFI_TYPE_COMPLEX, \ + (ffi_type **)ffi_elements_complex_##name \ + } + +/* Define new complex type descriptors using the macro: */ +/* ffi_type_complex_sint */ +FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint); +/* ffi_type_complex_uchar */ +FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8); + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + + _Complex int tc_arg; + _Complex int tc_result; + int tc_int_arg_x; + int tc_y; + int *tc_ptr_arg_y = &tc_y; + + args[0] = &ffi_type_complex_sint; + args[1] = &ffi_type_sint; + args[2] = &ffi_type_pointer; + values[0] = &tc_arg; + values[1] = &tc_int_arg_x; + values[2] = &tc_ptr_arg_y; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &ffi_type_complex_sint, args) + == FFI_OK); + + tc_arg = 1 + 7 * I; + tc_int_arg_x = 1234; + tc_y = 9876; + ffi_call(&cif, FFI_FN(f_complex), &tc_result, values); + + printf ("%d,%di %d,%di, x %d 1234, y %d 11110\n", + (int)tc_result, (int)(tc_result * -I), 2, 8, tc_int_arg_x, tc_y); + /* dg-output "-2,8i 2,8i, x 1234 1234, y 11110 11110" */ + CHECK (creal (tc_result) == -2); + CHECK (cimag (tc_result) == 8); + CHECK (tc_int_arg_x == 1234); + CHECK (*tc_ptr_arg_y == 11110); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c new file mode 100644 index 0000000..7e78366 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check complex types. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h b/user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h new file mode 100644 index 0000000..d27d362 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h @@ -0,0 +1 @@ +#include "../libffi.call/ffitest.h" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc new file mode 100644 index 0000000..e37a774 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc @@ -0,0 +1,78 @@ +/* -*-c-*- */ +#include "ffitest.h" + +#include +#include + +static _Complex T_C_TYPE many(_Complex T_C_TYPE c1, + _Complex T_C_TYPE c2, + _Complex T_C_TYPE c3, + _Complex T_C_TYPE c4, + _Complex T_C_TYPE c5, + _Complex T_C_TYPE c6, + _Complex T_C_TYPE c7, + _Complex T_C_TYPE c8, + _Complex T_C_TYPE c9, + _Complex T_C_TYPE c10, + _Complex T_C_TYPE c11, + _Complex T_C_TYPE c12, + _Complex T_C_TYPE c13) +{ + printf("0 :%f,%fi\n" + "1 :%f,%fi\n" + "2 :%f,%fi\n" + "3 :%f,%fi\n" + "4 :%f,%fi\n" + "5 :%f,%fi\n" + "6 :%f,%fi\n" + "7 :%f,%fi\n" + "8 :%f,%fi\n" + "9 :%f,%fi\n" + "10:%f,%fi\n" + "11:%f,%fi\n" + "12:%f,%fi\n", + T_CONV creal (c1), T_CONV cimag (c1), + T_CONV creal (c2), T_CONV cimag (c2), + T_CONV creal (c3), T_CONV cimag (c3), + T_CONV creal (c4), T_CONV cimag (c4), + T_CONV creal (c5), T_CONV cimag (c5), + T_CONV creal (c6), T_CONV cimag (c6), + T_CONV creal (c7), T_CONV cimag (c7), + T_CONV creal (c8), T_CONV cimag (c8), + T_CONV creal (c9), T_CONV cimag (c9), + T_CONV creal (c10), T_CONV cimag (c10), + T_CONV creal (c11), T_CONV cimag (c11), + T_CONV creal (c12), T_CONV cimag (c12), + T_CONV creal (c13), T_CONV cimag (c13)); + + return (c1+c2-c3-c4+c5+c6+c7-c8-c9-c10-c11+c12+c13); +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[13]; + void *values[13]; + _Complex T_C_TYPE ca[13]; + _Complex T_C_TYPE c, cc; + int i; + + for (i = 0; i < 13; i++) + { + args[i] = &T_FFI_TYPE; + values[i] = &ca[i]; + ca[i] = i + (-20 - i) * I; + } + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, &T_FFI_TYPE, args) == FFI_OK); + + ffi_call(&cif, FFI_FN(many), &c, values); + + cc = many(ca[0], ca[1], ca[2], ca[3], ca[4], ca[5], ca[6], ca[7], ca[8], + ca[9], ca[10], ca[11], ca[12]); + CHECK(creal (cc) == creal (c)); + CHECK(cimag (cc) == cimag (c)); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c new file mode 100644 index 0000000..3fd53c3 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex, with many arguments + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "many_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c new file mode 100644 index 0000000..c43d21c --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex, with many arguments + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "many_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c new file mode 100644 index 0000000..dbab723 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex, with many arguments + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "many_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc new file mode 100644 index 0000000..8bf0c1f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc @@ -0,0 +1,37 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include + +static _Complex T_C_TYPE return_c(_Complex T_C_TYPE c) +{ + printf ("%f,%fi\n", T_CONV creal (c), T_CONV cimag (c)); + return 2 * c; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + _Complex T_C_TYPE c, rc, rc2; + T_C_TYPE cr, ci; + + args[0] = &T_FFI_TYPE; + values[0] = &c; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &T_FFI_TYPE, args) == FFI_OK); + + for (cr = -127.0; cr < 127; cr++) + { + ci = 1000.0 - cr; + c = cr + ci * I; + ffi_call(&cif, FFI_FN(return_c), &rc, values); + rc2 = return_c(c); + printf ("%f,%fi vs %f,%fi\n", + T_CONV creal (rc), T_CONV cimag (rc), + T_CONV creal (rc2), T_CONV cimag (rc2)); + CHECK(rc == 2 * c); + } + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc new file mode 100644 index 0000000..7cecc0f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc @@ -0,0 +1,41 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include + +static _Complex T_C_TYPE return_c(_Complex T_C_TYPE c1, float fl2, unsigned int in3, _Complex T_C_TYPE c4) +{ + return c1 + fl2 + in3 + c4; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + _Complex T_C_TYPE c1, c4, rc, rc2; + float fl2; + unsigned int in3; + args[0] = &T_FFI_TYPE; + args[1] = &ffi_type_float; + args[2] = &ffi_type_uint; + args[3] = &T_FFI_TYPE; + values[0] = &c1; + values[1] = &fl2; + values[2] = &in3; + values[3] = &c4; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &T_FFI_TYPE, args) == FFI_OK); + c1 = 127.0 + 255.0 * I; + fl2 = 128.0; + in3 = 255; + c4 = 512.7 + 1024.1 * I; + + ffi_call(&cif, FFI_FN(return_c), &rc, values); + rc2 = return_c(c1, fl2, in3, c4); + printf ("%f,%fi vs %f,%fi\n", + T_CONV creal (rc), T_CONV cimag (rc), + T_CONV creal (rc2), T_CONV cimag (rc2)); + CHECK(rc == rc2); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c new file mode 100644 index 0000000..727410d --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "return_complex1.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c new file mode 100644 index 0000000..a2aeada --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "return_complex1.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c new file mode 100644 index 0000000..103504b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "return_complex1.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc new file mode 100644 index 0000000..265170b --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc @@ -0,0 +1,44 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include + +_Complex T_C_TYPE +return_c(_Complex T_C_TYPE c1, _Complex T_C_TYPE c2, + unsigned int in3, _Complex T_C_TYPE c4) +{ + volatile _Complex T_C_TYPE r = c1 + c2 + in3 + c4; + return r; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + _Complex T_C_TYPE c1, c2, c4, rc, rc2; + unsigned int in3; + args[0] = &T_FFI_TYPE; + args[1] = &T_FFI_TYPE; + args[2] = &ffi_type_uint; + args[3] = &T_FFI_TYPE; + values[0] = &c1; + values[1] = &c2; + values[2] = &in3; + values[3] = &c4; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, + &T_FFI_TYPE, args) == FFI_OK); + c1 = 127.0 + 255.0 * I; + c2 = 128.0 + 256.0; + in3 = 255; + c4 = 512.7 + 1024.1 * I; + + ffi_call(&cif, FFI_FN(return_c), &rc, values); + rc2 = return_c(c1, c2, in3, c4); + printf ("%f,%fi vs %f,%fi\n", + T_CONV creal (rc), T_CONV cimag (rc), + T_CONV creal (rc2), T_CONV cimag (rc2)); + CHECK(rc == rc2); + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c new file mode 100644 index 0000000..ab9efac --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "return_complex2.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c new file mode 100644 index 0000000..d7f22c2 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "return_complex2.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c new file mode 100644 index 0000000..3edea62 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "return_complex2.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c new file mode 100644 index 0000000..e2497cc --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_double.inc" +#include "return_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c new file mode 100644 index 0000000..a35528f --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_float.inc" +#include "return_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c new file mode 100644 index 0000000..142d7be --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c @@ -0,0 +1,10 @@ +/* Area: ffi_call + Purpose: Check return value complex. + Limitations: none. + PR: none. + Originator: . */ + +/* { dg-do run } */ + +#include "complex_defs_longdouble.inc" +#include "return_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c b/user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c new file mode 100644 index 0000000..b00c404 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +#include "static-chain.h" + +#if defined(__GNUC__) && !defined(__clang__) && defined(STATIC_CHAIN_REG) + +#include "ffitest.h" + +/* Blatent assumption here that the prologue doesn't clobber the + static chain for trivial functions. If this is not true, don't + define STATIC_CHAIN_REG, and we'll test what we can via other tests. */ +void *doit(void) +{ + register void *chain __asm__(STATIC_CHAIN_REG); + return chain; +} + +int main() +{ + ffi_cif cif; + void *result; + + CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK); + + ffi_call_go(&cif, FFI_FN(doit), &result, NULL, &result); + + CHECK(result == &result); + + return 0; +} + +#else /* UNSUPPORTED */ +int main() { return 0; } +#endif diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/closure1.c b/user/mpy/lib/libffi/testsuite/libffi.go/closure1.c new file mode 100644 index 0000000..7b34afc --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.go/closure1.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +#include "ffitest.h" + +void doit(ffi_cif *cif, void *rvalue, void **avalue, void *closure) +{ + (void)cif; + (void)avalue; + *(void **)rvalue = closure; +} + +typedef void * (*FN)(void); + +int main() +{ + ffi_cif cif; + ffi_go_closure cl; + void *result; + + CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK); + CHECK(ffi_prep_go_closure(&cl, &cif, doit) == FFI_OK); + + ffi_call_go(&cif, FFI_FN(*(FN *)&cl), &result, NULL, &cl); + + CHECK(result == &cl); + + exit(0); +} diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h b/user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h new file mode 100644 index 0000000..d27d362 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h @@ -0,0 +1 @@ +#include "../libffi.call/ffitest.h" diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/go.exp b/user/mpy/lib/libffi/testsuite/libffi.go/go.exp new file mode 100644 index 0000000..100c5e7 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.go/go.exp @@ -0,0 +1,36 @@ +# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +dg-init +libffi-init + +global srcdir subdir + +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] + +if { [libffi_feature_test "#ifdef FFI_GO_CLOSURES"] } { + run-many-tests $tlist "" +} else { + foreach test $tlist { + unsupported "$test" + } +} + +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h b/user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h new file mode 100644 index 0000000..3675b40 --- /dev/null +++ b/user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h @@ -0,0 +1,19 @@ +#ifdef __aarch64__ +# define STATIC_CHAIN_REG "x18" +#elif defined(__alpha__) +# define STATIC_CHAIN_REG "$1" +#elif defined(__arm__) +# define STATIC_CHAIN_REG "ip" +#elif defined(__sparc__) +# if defined(__arch64__) || defined(__sparcv9) +# define STATIC_CHAIN_REG "g5" +# else +# define STATIC_CHAIN_REG "g2" +# endif +#elif defined(__x86_64__) +# define STATIC_CHAIN_REG "r10" +#elif defined(__i386__) +# ifndef ABI_NUM +# define STATIC_CHAIN_REG "ecx" /* FFI_DEFAULT_ABI only */ +# endif +#endif diff --git a/user/mpy/lib/libffi/texinfo.tex b/user/mpy/lib/libffi/texinfo.tex new file mode 100644 index 0000000..85f184c --- /dev/null +++ b/user/mpy/lib/libffi/texinfo.tex @@ -0,0 +1,10079 @@ +% texinfo.tex -- TeX macros to handle Texinfo files. +% +% Load plain if necessary, i.e., if running under initex. +\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi +% +\def\texinfoversion{2013-02-01.11} +% +% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, +% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +% 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +% +% This texinfo.tex file is free software: you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation, either version 3 of the +% License, or (at your option) any later version. +% +% This texinfo.tex file is distributed in the hope that it will be +% useful, but WITHOUT ANY WARRANTY; without even the implied warranty +% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +% General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% As a special exception, when this file is read by TeX when processing +% a Texinfo source document, you may use the result without +% restriction. This Exception is an additional permission under section 7 +% of the GNU General Public License, version 3 ("GPLv3"). +% +% Please try the latest version of texinfo.tex before submitting bug +% reports; you can get the latest version from: +% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or +% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or +% http://www.gnu.org/software/texinfo/ (the Texinfo home page) +% The texinfo.tex in any given distribution could well be out +% of date, so if that's what you're using, please check. +% +% Send bug reports to bug-texinfo@gnu.org. Please include including a +% complete document in each bug report with which we can reproduce the +% problem. Patches are, of course, greatly appreciated. +% +% To process a Texinfo manual with TeX, it's most reliable to use the +% texi2dvi shell script that comes with the distribution. For a simple +% manual foo.texi, however, you can get away with this: +% tex foo.texi +% texindex foo.?? +% tex foo.texi +% tex foo.texi +% dvips foo.dvi -o # or whatever; this makes foo.ps. +% The extra TeX runs get the cross-reference information correct. +% Sometimes one run after texindex suffices, and sometimes you need more +% than two; texi2dvi does it as many times as necessary. +% +% It is possible to adapt texinfo.tex for other languages, to some +% extent. You can get the existing language-specific files from the +% full Texinfo distribution. +% +% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. + + +\message{Loading texinfo [version \texinfoversion]:} + +% If in a .fmt file, print the version number +% and turn on active characters that we couldn't do earlier because +% they might have appeared in the input file name. +\everyjob{\message{[Texinfo version \texinfoversion]}% + \catcode`+=\active \catcode`\_=\active} + +\chardef\other=12 + +% We never want plain's \outer definition of \+ in Texinfo. +% For @tex, we can use \tabalign. +\let\+ = \relax + +% Save some plain tex macros whose names we will redefine. +\let\ptexb=\b +\let\ptexbullet=\bullet +\let\ptexc=\c +\let\ptexcomma=\, +\let\ptexdot=\. +\let\ptexdots=\dots +\let\ptexend=\end +\let\ptexequiv=\equiv +\let\ptexexclam=\! +\let\ptexfootnote=\footnote +\let\ptexgtr=> +\let\ptexhat=^ +\let\ptexi=\i +\let\ptexindent=\indent +\let\ptexinsert=\insert +\let\ptexlbrace=\{ +\let\ptexless=< +\let\ptexnewwrite\newwrite +\let\ptexnoindent=\noindent +\let\ptexplus=+ +\let\ptexraggedright=\raggedright +\let\ptexrbrace=\} +\let\ptexslash=\/ +\let\ptexstar=\* +\let\ptext=\t +\let\ptextop=\top +{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Pre-3.0. +\else + \def\linenumber{l.\the\inputlineno:\space} +\fi + +% Set up fixed words for English if not already set. +\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi +\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi +\ifx\putworderror\undefined \gdef\putworderror{error}\fi +\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi +\ifx\putwordin\undefined \gdef\putwordin{in}\fi +\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi +\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi +\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi +\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi +\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi +\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi +\ifx\putwordof\undefined \gdef\putwordof{of}\fi +\ifx\putwordon\undefined \gdef\putwordon{on}\fi +\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi +\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi +\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi +\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi +\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi +\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi +\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi +% +\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi +\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi +\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi +\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi +\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi +\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi +\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi +\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi +\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi +\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi +\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi +\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi +% +\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi +\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi +\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi +\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi +\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi + +% Since the category of space is not known, we have to be careful. +\chardef\spacecat = 10 +\def\spaceisspace{\catcode`\ =\spacecat} + +% sometimes characters are active, so we need control sequences. +\chardef\ampChar = `\& +\chardef\colonChar = `\: +\chardef\commaChar = `\, +\chardef\dashChar = `\- +\chardef\dotChar = `\. +\chardef\exclamChar= `\! +\chardef\hashChar = `\# +\chardef\lquoteChar= `\` +\chardef\questChar = `\? +\chardef\rquoteChar= `\' +\chardef\semiChar = `\; +\chardef\slashChar = `\/ +\chardef\underChar = `\_ + +% Ignore a token. +% +\def\gobble#1{} + +% The following is used inside several \edef's. +\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} + +% Hyphenation fixes. +\hyphenation{ + Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script + ap-pen-dix bit-map bit-maps + data-base data-bases eshell fall-ing half-way long-est man-u-script + man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm + par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces + spell-ing spell-ings + stand-alone strong-est time-stamp time-stamps which-ever white-space + wide-spread wrap-around +} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen\bindingoffset +\newdimen\normaloffset +\newdimen\pagewidth \newdimen\pageheight + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt } + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. We also make +% some effort to order the tracing commands to reduce output in the log +% file; cf. trace.sty in LaTeX. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\def\loggingall{% + \tracingstats2 + \tracingpages1 + \tracinglostchars2 % 2 gives us more in etex + \tracingparagraphs1 + \tracingoutput1 + \tracingmacros2 + \tracingrestores1 + \showboxbreadth\maxdimen \showboxdepth\maxdimen + \ifx\eTeXversion\thisisundefined\else % etex gives us more logging + \tracingscantokens1 + \tracingifs1 + \tracinggroups1 + \tracingnesting2 + \tracingassigns1 + \fi + \tracingcommands3 % 3 gives us more in etex + \errorcontextlines16 +}% + +% @errormsg{MSG}. Do the index-like expansions on MSG, but if things +% aren't perfect, it's not the end of the world, being an error message, +% after all. +% +\def\errormsg{\begingroup \indexnofonts \doerrormsg} +\def\doerrormsg#1{\errmessage{#1}} + +% add check for \lastpenalty to plain's definitions. If the last thing +% we did was a \nobreak, we don't want to insert more space. +% +\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount + \removelastskip\penalty-50\smallskip\fi\fi} +\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount + \removelastskip\penalty-100\medskip\fi\fi} +\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount + \removelastskip\penalty-200\bigskip\fi\fi} + +% Do @cropmarks to get crop marks. +% +\newif\ifcropmarks +\let\cropmarks = \cropmarkstrue +% +% Dimensions to add cropmarks at corners. +% Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines +\newdimen\cornerlong \cornerlong=1pc +\newdimen\cornerthick \cornerthick=.3pt +\newdimen\topandbottommargin \topandbottommargin=.75in + +% Output a mark which sets \thischapter, \thissection and \thiscolor. +% We dump everything together because we only have one kind of mark. +% This works because we only use \botmark / \topmark, not \firstmark. +% +% A mark contains a subexpression of the \ifcase ... \fi construct. +% \get*marks macros below extract the needed part using \ifcase. +% +% Another complication is to let the user choose whether \thischapter +% (\thissection) refers to the chapter (section) in effect at the top +% of a page, or that at the bottom of a page. The solution is +% described on page 260 of The TeXbook. It involves outputting two +% marks for the sectioning macros, one before the section break, and +% one after. I won't pretend I can describe this better than DEK... +\def\domark{% + \toks0=\expandafter{\lastchapterdefs}% + \toks2=\expandafter{\lastsectiondefs}% + \toks4=\expandafter{\prevchapterdefs}% + \toks6=\expandafter{\prevsectiondefs}% + \toks8=\expandafter{\lastcolordefs}% + \mark{% + \the\toks0 \the\toks2 + \noexpand\or \the\toks4 \the\toks6 + \noexpand\else \the\toks8 + }% +} +% \topmark doesn't work for the very first chapter (after the title +% page or the contents), so we use \firstmark there -- this gets us +% the mark with the chapter defs, unless the user sneaks in, e.g., +% @setcolor (or @url, or @link, etc.) between @contents and the very +% first @chapter. +\def\gettopheadingmarks{% + \ifcase0\topmark\fi + \ifx\thischapter\empty \ifcase0\firstmark\fi \fi +} +\def\getbottomheadingmarks{\ifcase1\botmark\fi} +\def\getcolormarks{\ifcase2\topmark\fi} + +% Avoid "undefined control sequence" errors. +\def\lastchapterdefs{} +\def\lastsectiondefs{} +\def\prevchapterdefs{} +\def\prevsectiondefs{} +\def\lastcolordefs{} + +% Main output routine. +\chardef\PAGE = 255 +\output = {\onepageout{\pagecontents\PAGE}} + +\newbox\headlinebox +\newbox\footlinebox + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions, but you have to call it yourself. +\def\onepageout#1{% + \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi + % + \ifodd\pageno \advance\hoffset by \bindingoffset + \else \advance\hoffset by -\bindingoffset\fi + % + % Do this outside of the \shipout so @code etc. will be expanded in + % the headline as they should be, not taken literally (outputting ''code). + \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi + \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% + \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi + \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% + % + {% + % Have to do this stuff outside the \shipout because we want it to + % take effect in \write's, yet the group defined by the \vbox ends + % before the \shipout runs. + % + \indexdummies % don't expand commands in the output. + \normalturnoffactive % \ in index entries must not stay \, e.g., if + % the page break happens to be in the middle of an example. + % We don't want .vr (or whatever) entries like this: + % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} + % "\acronym" won't work when it's read back in; + % it needs to be + % {\code {{\tt \backslashcurfont }acronym} + \shipout\vbox{% + % Do this early so pdf references go to the beginning of the page. + \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi + % + \ifcropmarks \vbox to \outervsize\bgroup + \hsize = \outerhsize + \vskip-\topandbottommargin + \vtop to0pt{% + \line{\ewtop\hfil\ewtop}% + \nointerlineskip + \line{% + \vbox{\moveleft\cornerthick\nstop}% + \hfill + \vbox{\moveright\cornerthick\nstop}% + }% + \vss}% + \vskip\topandbottommargin + \line\bgroup + \hfil % center the page within the outer (page) hsize. + \ifodd\pageno\hskip\bindingoffset\fi + \vbox\bgroup + \fi + % + \unvbox\headlinebox + \pagebody{#1}% + \ifdim\ht\footlinebox > 0pt + % Only leave this space if the footline is nonempty. + % (We lessened \vsize for it in \oddfootingyyy.) + % The \baselineskip=24pt in plain's \makefootline has no effect. + \vskip 24pt + \unvbox\footlinebox + \fi + % + \ifcropmarks + \egroup % end of \vbox\bgroup + \hfil\egroup % end of (centering) \line\bgroup + \vskip\topandbottommargin plus1fill minus1fill + \boxmaxdepth = \cornerthick + \vbox to0pt{\vss + \line{% + \vbox{\moveleft\cornerthick\nsbot}% + \hfill + \vbox{\moveright\cornerthick\nsbot}% + }% + \nointerlineskip + \line{\ewbot\hfil\ewbot}% + }% + \egroup % \vbox from first cropmarks clause + \fi + }% end of \shipout\vbox + }% end of group with \indexdummies + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi +} + +\newinsert\margin \dimen\margin=\maxdimen + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +% marginal hacks, juha@viisa.uucp (Juha Takala) +\ifvoid\margin\else % marginal info is present + \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi +\dimen@=\dp#1\relax \unvbox#1\relax +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. The argument is the rest of +% the input line (except we remove a trailing comment). #1 should be a +% macro which expects an ordinary undelimited TeX argument. +% +\def\parsearg{\parseargusing{}} +\def\parseargusing#1#2{% + \def\argtorun{#2}% + \begingroup + \obeylines + \spaceisspace + #1% + \parseargline\empty% Insert the \empty token, see \finishparsearg below. +} + +{\obeylines % + \gdef\parseargline#1^^M{% + \endgroup % End of the group started in \parsearg. + \argremovecomment #1\comment\ArgTerm% + }% +} + +% First remove any @comment, then any @c comment. +\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} +\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} + +% Each occurrence of `\^^M' or `\^^M' is replaced by a single space. +% +% \argremovec might leave us with trailing space, e.g., +% @end itemize @c foo +% This space token undergoes the same procedure and is eventually removed +% by \finishparsearg. +% +\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} +\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} +\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% + \def\temp{#3}% + \ifx\temp\empty + % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: + \let\temp\finishparsearg + \else + \let\temp\argcheckspaces + \fi + % Put the space token in: + \temp#1 #3\ArgTerm +} + +% If a _delimited_ argument is enclosed in braces, they get stripped; so +% to get _exactly_ the rest of the line, we had to prevent such situation. +% We prepended an \empty token at the very beginning and we expand it now, +% just before passing the control to \argtorun. +% (Similarly, we have to think about #3 of \argcheckspacesY above: it is +% either the null string, or it ends with \^^M---thus there is no danger +% that a pair of braces would be stripped. +% +% But first, we have to remove the trailing space token. +% +\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} + +% \parseargdef\foo{...} +% is roughly equivalent to +% \def\foo{\parsearg\Xfoo} +% \def\Xfoo#1{...} +% +% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my +% favourite TeX trick. --kasal, 16nov03 + +\def\parseargdef#1{% + \expandafter \doparseargdef \csname\string#1\endcsname #1% +} +\def\doparseargdef#1#2{% + \def#2{\parsearg#1}% + \def#1##1% +} + +% Several utility definitions with active space: +{ + \obeyspaces + \gdef\obeyedspace{ } + + % Make each space character in the input produce a normal interword + % space in the output. Don't allow a line break at this space, as this + % is used only in environments like @example, where each line of input + % should produce a line of output anyway. + % + \gdef\sepspaces{\obeyspaces\let =\tie} + + % If an index command is used in an @example environment, any spaces + % therein should become regular spaces in the raw index file, not the + % expansion of \tie (\leavevmode \penalty \@M \ ). + \gdef\unsepspaces{\let =\space} +} + + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +% Define the framework for environments in texinfo.tex. It's used like this: +% +% \envdef\foo{...} +% \def\Efoo{...} +% +% It's the responsibility of \envdef to insert \begingroup before the +% actual body; @end closes the group after calling \Efoo. \envdef also +% defines \thisenv, so the current environment is known; @end checks +% whether the environment name matches. The \checkenv macro can also be +% used to check whether the current environment is the one expected. +% +% Non-false conditionals (@iftex, @ifset) don't fit into this, so they +% are not treated as environments; they don't open a group. (The +% implementation of @end takes care not to call \endgroup in this +% special case.) + + +% At run-time, environments start with this: +\def\startenvironment#1{\begingroup\def\thisenv{#1}} +% initialize +\let\thisenv\empty + +% ... but they get defined via ``\envdef\foo{...}'': +\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} +\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} + +% Check whether we're in the right environment: +\def\checkenv#1{% + \def\temp{#1}% + \ifx\thisenv\temp + \else + \badenverr + \fi +} + +% Environment mismatch, #1 expected: +\def\badenverr{% + \errhelp = \EMsimple + \errmessage{This command can appear only \inenvironment\temp, + not \inenvironment\thisenv}% +} +\def\inenvironment#1{% + \ifx#1\empty + outside of any environment% + \else + in environment \expandafter\string#1% + \fi +} + +% @end foo executes the definition of \Efoo. +% But first, it executes a specialized version of \checkenv +% +\parseargdef\end{% + \if 1\csname iscond.#1\endcsname + \else + % The general wording of \badenverr may not be ideal. + \expandafter\checkenv\csname#1\endcsname + \csname E#1\endcsname + \endgroup + \fi +} + +\newhelp\EMsimple{Press RETURN to continue.} + + +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + % Avoid using \@M directly, because that causes trouble + % if the definition is written into an index file. + \global\let\tiepenalty = \@M + \gdef\tie{\leavevmode\penalty\tiepenalty\ } +} + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\unskip\hfil\break\hbox{}\ignorespaces} + +% @/ allows a line break. +\let\/=\allowbreak + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=\endofsentencespacefactor\space} + +% @! is an end-of-sentence bang. +\def\!{!\spacefactor=\endofsentencespacefactor\space} + +% @? is an end-of-sentence query. +\def\?{?\spacefactor=\endofsentencespacefactor\space} + +% @frenchspacing on|off says whether to put extra space after punctuation. +% +\def\onword{on} +\def\offword{off} +% +\parseargdef\frenchspacing{% + \def\temp{#1}% + \ifx\temp\onword \plainfrenchspacing + \else\ifx\temp\offword \plainnonfrenchspacing + \else + \errhelp = \EMsimple + \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% + \fi\fi +} + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +% Another complication is that the group might be very large. This can +% cause the glue on the previous page to be unduly stretched, because it +% does not have much material. In this case, it's better to add an +% explicit \vfill so that the extra space is at the bottom. The +% threshold for doing this is if the group is more than \vfilllimit +% percent of a page (\vfilllimit can be changed inside of @tex). +% +\newbox\groupbox +\def\vfilllimit{0.7} +% +\envdef\group{% + \ifnum\catcode`\^^M=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + \startsavinginserts + % + \setbox\groupbox = \vtop\bgroup + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an + % end-of-line in the output. We don't want the end-of-line after + % the `@group' to put extra space in the output. Since @group + % should appear on a line by itself (according to the Texinfo + % manual), we don't worry about eating any user text. + \comment +} +% +% The \vtop produces a box with normal height and large depth; thus, TeX puts +% \baselineskip glue before it, and (when the next line of text is done) +% \lineskip glue after it. Thus, space below is not quite equal to space +% above. But it's pretty close. +\def\Egroup{% + % To get correct interline space between the last line of the group + % and the first line afterwards, we have to propagate \prevdepth. + \endgraf % Not \par, as it may have been set to \lisppar. + \global\dimen1 = \prevdepth + \egroup % End the \vtop. + % \dimen0 is the vertical size of the group's box. + \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox + % \dimen2 is how much space is left on the page (more or less). + \dimen2 = \pageheight \advance\dimen2 by -\pagetotal + % if the group doesn't fit on the current page, and it's a big big + % group, force a page break. + \ifdim \dimen0 > \dimen2 + \ifdim \pagetotal < \vfilllimit\pageheight + \page + \fi + \fi + \box\groupbox + \prevdepth = \dimen1 + \checkinserts +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\parseargdef\need{% + % Ensure vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % If the @need value is less than one line space, it's useless. + \dimen0 = #1\mil + \dimen2 = \ht\strutbox + \advance\dimen2 by \dp\strutbox + \ifdim\dimen0 > \dimen2 + % + % Do a \strut just to make the height of this box be normal, so the + % normal leading is inserted relative to the preceding line. + % And a page break here is fine. + \vtop to #1\mil{\strut\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak + \fi +} + +% @br forces paragraph break (and is undocumented). + +\let\br = \par + +% @page forces the start of a new page. +% +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} + +% This defn is used inside nofill environments such as @example. +\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount + \leftline{\hskip\leftskip{\rm#1}}}} + +% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current +% paragraph. For more general purposes, use the \margin insertion +% class. WHICH is `l' or `r'. Not documented, written for gawk manual. +% +\newskip\inmarginspacing \inmarginspacing=1cm +\def\strutdepth{\dp\strutbox} +% +\def\doinmargin#1#2{\strut\vadjust{% + \nobreak + \kern-\strutdepth + \vtop to \strutdepth{% + \baselineskip=\strutdepth + \vss + % if you have multiple lines of stuff to put here, you'll need to + % make the vbox yourself of the appropriate size. + \ifx#1l% + \llap{\ignorespaces #2\hskip\inmarginspacing}% + \else + \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% + \fi + \null + }% +}} +\def\inleftmargin{\doinmargin l} +\def\inrightmargin{\doinmargin r} +% +% @inmargin{TEXT [, RIGHT-TEXT]} +% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; +% else use TEXT for both). +% +\def\inmargin#1{\parseinmargin #1,,\finish} +\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \def\lefttext{#1}% have both texts + \def\righttext{#2}% + \else + \def\lefttext{#1}% have only one text + \def\righttext{#1}% + \fi + % + \ifodd\pageno + \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin + \else + \def\temp{\inleftmargin\lefttext}% + \fi + \temp +} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). This command +% is not documented, not supported, and doesn't work. +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + +% @include FILE -- \input text of FILE. +% +\def\include{\parseargusing\filenamecatcodes\includezzz} +\def\includezzz#1{% + \pushthisfilestack + \def\thisfile{#1}% + {% + \makevalueexpandable % we want to expand any @value in FILE. + \turnoffactive % and allow special characters in the expansion + \indexnofonts % Allow `@@' and other weird things in file names. + \wlog{texinfo.tex: doing @include of #1^^J}% + \edef\temp{\noexpand\input #1 }% + % + % This trickery is to read FILE outside of a group, in case it makes + % definitions, etc. + \expandafter + }\temp + \popthisfilestack +} +\def\filenamecatcodes{% + \catcode`\\=\other + \catcode`~=\other + \catcode`^=\other + \catcode`_=\other + \catcode`|=\other + \catcode`<=\other + \catcode`>=\other + \catcode`+=\other + \catcode`-=\other + \catcode`\`=\other + \catcode`\'=\other +} + +\def\pushthisfilestack{% + \expandafter\pushthisfilestackX\popthisfilestack\StackTerm +} +\def\pushthisfilestackX{% + \expandafter\pushthisfilestackY\thisfile\StackTerm +} +\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% + \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% +} + +\def\popthisfilestack{\errthisfilestackempty} +\def\errthisfilestackempty{\errmessage{Internal error: + the stack of filenames is empty.}} +% +\def\thisfile{} + +% @center line +% outputs that line, centered. +% +\parseargdef\center{% + \ifhmode + \let\centersub\centerH + \else + \let\centersub\centerV + \fi + \centersub{\hfil \ignorespaces#1\unskip \hfil}% + \let\centersub\relax % don't let the definition persist, just in case +} +\def\centerH#1{{% + \hfil\break + \advance\hsize by -\leftskip + \advance\hsize by -\rightskip + \line{#1}% + \break +}} +% +\newcount\centerpenalty +\def\centerV#1{% + % The idea here is the same as in \startdefun, \cartouche, etc.: if + % @center is the first thing after a section heading, we need to wipe + % out the negative parskip inserted by \sectionheading, but still + % prevent a page break here. + \centerpenalty = \lastpenalty + \ifnum\centerpenalty>10000 \vskip\parskip \fi + \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi + \line{\kern\leftskip #1\kern\rightskip}% +} + +% @sp n outputs n lines of vertical space +% +\parseargdef\sp{\vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment +% +\def\comment{\begingroup \catcode`\^^M=\other% +\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% +\commentxxx} +{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} +% +\let\c=\comment + +% @paragraphindent NCHARS +% We'll use ems for NCHARS, close enough. +% NCHARS can also be the word `asis' or `none'. +% We cannot feasibly implement @paragraphindent asis, though. +% +\def\asisword{asis} % no translation, these are keywords +\def\noneword{none} +% +\parseargdef\paragraphindent{% + \def\temp{#1}% + \ifx\temp\asisword + \else + \ifx\temp\noneword + \defaultparindent = 0pt + \else + \defaultparindent = #1em + \fi + \fi + \parindent = \defaultparindent +} + +% @exampleindent NCHARS +% We'll use ems for NCHARS like @paragraphindent. +% It seems @exampleindent asis isn't necessary, but +% I preserve it to make it similar to @paragraphindent. +\parseargdef\exampleindent{% + \def\temp{#1}% + \ifx\temp\asisword + \else + \ifx\temp\noneword + \lispnarrowing = 0pt + \else + \lispnarrowing = #1em + \fi + \fi +} + +% @firstparagraphindent WORD +% If WORD is `none', then suppress indentation of the first paragraph +% after a section heading. If WORD is `insert', then do indent at such +% paragraphs. +% +% The paragraph indentation is suppressed or not by calling +% \suppressfirstparagraphindent, which the sectioning commands do. +% We switch the definition of this back and forth according to WORD. +% By default, we suppress indentation. +% +\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} +\def\insertword{insert} +% +\parseargdef\firstparagraphindent{% + \def\temp{#1}% + \ifx\temp\noneword + \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent + \else\ifx\temp\insertword + \let\suppressfirstparagraphindent = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @firstparagraphindent option `\temp'}% + \fi\fi +} + +% Here is how we actually suppress indentation. Redefine \everypar to +% \kern backwards by \parindent, and then reset itself to empty. +% +% We also make \indent itself not actually do anything until the next +% paragraph. +% +\gdef\dosuppressfirstparagraphindent{% + \gdef\indent{% + \restorefirstparagraphindent + \indent + }% + \gdef\noindent{% + \restorefirstparagraphindent + \noindent + }% + \global\everypar = {% + \kern -\parindent + \restorefirstparagraphindent + }% +} + +\gdef\restorefirstparagraphindent{% + \global \let \indent = \ptexindent + \global \let \noindent = \ptexnoindent + \global \everypar = {}% +} + + +% @refill is a no-op. +\let\refill=\relax + +% If working on a large document in chapters, it is convenient to +% be able to disable indexing, cross-referencing, and contents, for test runs. +% This is done with @novalidate (before @setfilename). +% +\newif\iflinks \linkstrue % by default we want the aux files. +\let\novalidate = \linksfalse + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \iflinks + \tryauxfile + % Open the new aux file. TeX will close it automatically at exit. + \immediate\openout\auxfile=\jobname.aux + \fi % \openindices needs to do some work in any case. + \openindices + \let\setfilename=\comment % Ignore extra @setfilename cmds. + % + % If texinfo.cnf is present on the system, read it. + % Useful for site-wide @afourpaper, etc. + \openin 1 texinfo.cnf + \ifeof 1 \else \input texinfo.cnf \fi + \closein 1 + % + \comment % Ignore the actual filename. +} + +% Called from \setfilename. +% +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% @bye. +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + + +\message{pdf,} +% adobe `portable' document format +\newcount\tempnum +\newcount\lnkcount +\newtoks\filename +\newcount\filenamelength +\newcount\pgn +\newtoks\toksA +\newtoks\toksB +\newtoks\toksC +\newtoks\toksD +\newbox\boxA +\newcount\countA +\newif\ifpdf +\newif\ifpdfmakepagedest + +% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 +% can be set). So we test for \relax and 0 as well as being undefined. +\ifx\pdfoutput\thisisundefined +\else + \ifx\pdfoutput\relax + \else + \ifcase\pdfoutput + \else + \pdftrue + \fi + \fi +\fi + +% PDF uses PostScript string constants for the names of xref targets, +% for display in the outlines, and in other places. Thus, we have to +% double any backslashes. Otherwise, a name like "\node" will be +% interpreted as a newline (\n), followed by o, d, e. Not good. +% +% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and +% related messages. The final outcome is that it is up to the TeX user +% to double the backslashes and otherwise make the string valid, so +% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to +% do this reliably, so we use it. + +% #1 is a control sequence in which to do the replacements, +% which we \xdef. +\def\txiescapepdf#1{% + \ifx\pdfescapestring\thisisundefined + % No primitive available; should we give a warning or log? + % Many times it won't matter. + \else + % The expandable \pdfescapestring primitive escapes parentheses, + % backslashes, and other special chars. + \xdef#1{\pdfescapestring{#1}}% + \fi +} + +\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images +with PDF output, and none of those formats could be found. (.eps cannot +be supported due to the design of the PDF format; use regular TeX (DVI +output) for that.)} + +\ifpdf + % + % Color manipulation macros based on pdfcolor.tex, + % except using rgb instead of cmyk; the latter is said to render as a + % very dark gray on-screen and a very dark halftone in print, instead + % of actual black. + \def\rgbDarkRed{0.50 0.09 0.12} + \def\rgbBlack{0 0 0} + % + % k sets the color for filling (usual text, etc.); + % K sets the color for stroking (thin rules, e.g., normal _'s). + \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} + % + % Set color, and create a mark which defines \thiscolor accordingly, + % so that \makeheadline knows which color to restore. + \def\setcolor#1{% + \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% + \domark + \pdfsetcolor{#1}% + } + % + \def\maincolor{\rgbBlack} + \pdfsetcolor{\maincolor} + \edef\thiscolor{\maincolor} + \def\lastcolordefs{} + % + \def\makefootline{% + \baselineskip24pt + \line{\pdfsetcolor{\maincolor}\the\footline}% + } + % + \def\makeheadline{% + \vbox to 0pt{% + \vskip-22.5pt + \line{% + \vbox to8.5pt{}% + % Extract \thiscolor definition from the marks. + \getcolormarks + % Typeset the headline with \maincolor, then restore the color. + \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% + }% + \vss + }% + \nointerlineskip + } + % + % + \pdfcatalog{/PageMode /UseOutlines} + % + % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). + \def\dopdfimage#1#2#3{% + \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% + \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% + % + % pdftex (and the PDF format) support .pdf, .png, .jpg (among + % others). Let's try in that order, PDF first since if + % someone has a scalable image, presumably better to use that than a + % bitmap. + \let\pdfimgext=\empty + \begingroup + \openin 1 #1.pdf \ifeof 1 + \openin 1 #1.PDF \ifeof 1 + \openin 1 #1.png \ifeof 1 + \openin 1 #1.jpg \ifeof 1 + \openin 1 #1.jpeg \ifeof 1 + \openin 1 #1.JPG \ifeof 1 + \errhelp = \nopdfimagehelp + \errmessage{Could not find image file #1 for pdf}% + \else \gdef\pdfimgext{JPG}% + \fi + \else \gdef\pdfimgext{jpeg}% + \fi + \else \gdef\pdfimgext{jpg}% + \fi + \else \gdef\pdfimgext{png}% + \fi + \else \gdef\pdfimgext{PDF}% + \fi + \else \gdef\pdfimgext{pdf}% + \fi + \closein 1 + \endgroup + % + % without \immediate, ancient pdftex seg faults when the same image is + % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) + \ifnum\pdftexversion < 14 + \immediate\pdfimage + \else + \immediate\pdfximage + \fi + \ifdim \wd0 >0pt width \pdfimagewidth \fi + \ifdim \wd2 >0pt height \pdfimageheight \fi + \ifnum\pdftexversion<13 + #1.\pdfimgext + \else + {#1.\pdfimgext}% + \fi + \ifnum\pdftexversion < 14 \else + \pdfrefximage \pdflastximage + \fi} + % + \def\pdfmkdest#1{{% + % We have to set dummies so commands such as @code, and characters + % such as \, aren't expanded when present in a section title. + \indexnofonts + \turnoffactive + \makevalueexpandable + \def\pdfdestname{#1}% + \txiescapepdf\pdfdestname + \safewhatsit{\pdfdest name{\pdfdestname} xyz}% + }} + % + % used to mark target names; must be expandable. + \def\pdfmkpgn#1{#1} + % + % by default, use a color that is dark enough to print on paper as + % nearly black, but still distinguishable for online viewing. + \def\urlcolor{\rgbDarkRed} + \def\linkcolor{\rgbDarkRed} + \def\endlink{\setcolor{\maincolor}\pdfendlink} + % + % Adding outlines to PDF; macros for calculating structure of outlines + % come from Petr Olsak + \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% + \else \csname#1\endcsname \fi} + \def\advancenumber#1{\tempnum=\expnumber{#1}\relax + \advance\tempnum by 1 + \expandafter\xdef\csname#1\endcsname{\the\tempnum}} + % + % #1 is the section text, which is what will be displayed in the + % outline by the pdf viewer. #2 is the pdf expression for the number + % of subentries (or empty, for subsubsections). #3 is the node text, + % which might be empty if this toc entry had no corresponding node. + % #4 is the page number + % + \def\dopdfoutline#1#2#3#4{% + % Generate a link to the node text if that exists; else, use the + % page number. We could generate a destination for the section + % text in the case where a section has no node, but it doesn't + % seem worth the trouble, since most documents are normally structured. + \edef\pdfoutlinedest{#3}% + \ifx\pdfoutlinedest\empty + \def\pdfoutlinedest{#4}% + \else + \txiescapepdf\pdfoutlinedest + \fi + % + % Also escape PDF chars in the display string. + \edef\pdfoutlinetext{#1}% + \txiescapepdf\pdfoutlinetext + % + \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% + } + % + \def\pdfmakeoutlines{% + \begingroup + % Read toc silently, to get counts of subentries for \pdfoutline. + \def\partentry##1##2##3##4{}% ignore parts in the outlines + \def\numchapentry##1##2##3##4{% + \def\thischapnum{##2}% + \def\thissecnum{0}% + \def\thissubsecnum{0}% + }% + \def\numsecentry##1##2##3##4{% + \advancenumber{chap\thischapnum}% + \def\thissecnum{##2}% + \def\thissubsecnum{0}% + }% + \def\numsubsecentry##1##2##3##4{% + \advancenumber{sec\thissecnum}% + \def\thissubsecnum{##2}% + }% + \def\numsubsubsecentry##1##2##3##4{% + \advancenumber{subsec\thissubsecnum}% + }% + \def\thischapnum{0}% + \def\thissecnum{0}% + \def\thissubsecnum{0}% + % + % use \def rather than \let here because we redefine \chapentry et + % al. a second time, below. + \def\appentry{\numchapentry}% + \def\appsecentry{\numsecentry}% + \def\appsubsecentry{\numsubsecentry}% + \def\appsubsubsecentry{\numsubsubsecentry}% + \def\unnchapentry{\numchapentry}% + \def\unnsecentry{\numsecentry}% + \def\unnsubsecentry{\numsubsecentry}% + \def\unnsubsubsecentry{\numsubsubsecentry}% + \readdatafile{toc}% + % + % Read toc second time, this time actually producing the outlines. + % The `-' means take the \expnumber as the absolute number of + % subentries, which we calculated on our first read of the .toc above. + % + % We use the node names as the destinations. + \def\numchapentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% + \def\numsecentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% + \def\numsubsecentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% + \def\numsubsubsecentry##1##2##3##4{% count is always zero + \dopdfoutline{##1}{}{##3}{##4}}% + % + % PDF outlines are displayed using system fonts, instead of + % document fonts. Therefore we cannot use special characters, + % since the encoding is unknown. For example, the eogonek from + % Latin 2 (0xea) gets translated to a | character. Info from + % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. + % + % TODO this right, we have to translate 8-bit characters to + % their "best" equivalent, based on the @documentencoding. Too + % much work for too little return. Just use the ASCII equivalents + % we use for the index sort strings. + % + \indexnofonts + \setupdatafile + % We can have normal brace characters in the PDF outlines, unlike + % Texinfo index files. So set that up. + \def\{{\lbracecharliteral}% + \def\}{\rbracecharliteral}% + \catcode`\\=\active \otherbackslash + \input \tocreadfilename + \endgroup + } + {\catcode`[=1 \catcode`]=2 + \catcode`{=\other \catcode`}=\other + \gdef\lbracecharliteral[{]% + \gdef\rbracecharliteral[}]% + ] + % + \def\skipspaces#1{\def\PP{#1}\def\D{|}% + \ifx\PP\D\let\nextsp\relax + \else\let\nextsp\skipspaces + \addtokens{\filename}{\PP}% + \advance\filenamelength by 1 + \fi + \nextsp} + \def\getfilename#1{% + \filenamelength=0 + % If we don't expand the argument now, \skipspaces will get + % snagged on things like "@value{foo}". + \edef\temp{#1}% + \expandafter\skipspaces\temp|\relax + } + \ifnum\pdftexversion < 14 + \let \startlink \pdfannotlink + \else + \let \startlink \pdfstartlink + \fi + % make a live url in pdf output. + \def\pdfurl#1{% + \begingroup + % it seems we really need yet another set of dummies; have not + % tried to figure out what each command should do in the context + % of @url. for now, just make @/ a no-op, that's the only one + % people have actually reported a problem with. + % + \normalturnoffactive + \def\@{@}% + \let\/=\empty + \makevalueexpandable + % do we want to go so far as to use \indexnofonts instead of just + % special-casing \var here? + \def\var##1{##1}% + % + \leavevmode\setcolor{\urlcolor}% + \startlink attr{/Border [0 0 0]}% + user{/Subtype /Link /A << /S /URI /URI (#1) >>}% + \endgroup} + \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} + \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} + \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} + \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} + \def\maketoks{% + \expandafter\poptoks\the\toksA|ENDTOKS|\relax + \ifx\first0\adn0 + \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 + \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 + \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 + \else + \ifnum0=\countA\else\makelink\fi + \ifx\first.\let\next=\done\else + \let\next=\maketoks + \addtokens{\toksB}{\the\toksD} + \ifx\first,\addtokens{\toksB}{\space}\fi + \fi + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \next} + \def\makelink{\addtokens{\toksB}% + {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} + \def\pdflink#1{% + \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} + \setcolor{\linkcolor}#1\endlink} + \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} +\else + % non-pdf mode + \let\pdfmkdest = \gobble + \let\pdfurl = \gobble + \let\endlink = \relax + \let\setcolor = \gobble + \let\pdfsetcolor = \gobble + \let\pdfmakeoutlines = \relax +\fi % \ifx\pdfoutput + + +\message{fonts,} + +% Change the current font style to #1, remembering it in \curfontstyle. +% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in +% italics, not bold italics. +% +\def\setfontstyle#1{% + \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. + \csname ten#1\endcsname % change the current font +} + +% Select #1 fonts with the current style. +% +\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} + +\def\rm{\fam=0 \setfontstyle{rm}} +\def\it{\fam=\itfam \setfontstyle{it}} +\def\sl{\fam=\slfam \setfontstyle{sl}} +\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} +\def\tt{\fam=\ttfam \setfontstyle{tt}} + +% Unfortunately, we have to override this for titles and the like, since +% in those cases "rm" is bold. Sigh. +\def\rmisbold{\rm\def\curfontstyle{bf}} + +% Texinfo sort of supports the sans serif font style, which plain TeX does not. +% So we set up a \sf. +\newfam\sffam +\def\sf{\fam=\sffam \setfontstyle{sf}} +\let\li = \sf % Sometimes we call it \li, not \sf. + +% We don't need math for this font style. +\def\ttsl{\setfontstyle{ttsl}} + + +% Set the baselineskip to #1, and the lineskip and strut size +% correspondingly. There is no deep meaning behind these magic numbers +% used as factors; they just match (closely enough) what Knuth defined. +% +\def\lineskipfactor{.08333} +\def\strutheightpercent{.70833} +\def\strutdepthpercent {.29167} +% +% can get a sort of poor man's double spacing by redefining this. +\def\baselinefactor{1} +% +\newdimen\textleading +\def\setleading#1{% + \dimen0 = #1\relax + \normalbaselineskip = \baselinefactor\dimen0 + \normallineskip = \lineskipfactor\normalbaselineskip + \normalbaselines + \setbox\strutbox =\hbox{% + \vrule width0pt height\strutheightpercent\baselineskip + depth \strutdepthpercent \baselineskip + }% +} + +% PDF CMaps. See also LaTeX's t1.cmap. +% +% do nothing with this by default. +\expandafter\let\csname cmapOT1\endcsname\gobble +\expandafter\let\csname cmapOT1IT\endcsname\gobble +\expandafter\let\csname cmapOT1TT\endcsname\gobble + +% if we are producing pdf, and we have \pdffontattr, then define cmaps. +% (\pdffontattr was introduced many years ago, but people still run +% older pdftex's; it's easy to conditionalize, so we do.) +\ifpdf \ifx\pdffontattr\thisisundefined \else + \begingroup + \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. + \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap +%%DocumentNeededResources: ProcSet (CIDInit) +%%IncludeResource: ProcSet (CIDInit) +%%BeginResource: CMap (TeX-OT1-0) +%%Title: (TeX-OT1-0 TeX OT1 0) +%%Version: 1.000 +%%EndComments +/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (TeX) +/Ordering (OT1) +/Supplement 0 +>> def +/CMapName /TeX-OT1-0 def +/CMapType 2 def +1 begincodespacerange +<00> <7F> +endcodespacerange +8 beginbfrange +<00> <01> <0393> +<09> <0A> <03A8> +<23> <26> <0023> +<28> <3B> <0028> +<3F> <5B> <003F> +<5D> <5E> <005D> +<61> <7A> <0061> +<7B> <7C> <2013> +endbfrange +40 beginbfchar +<02> <0398> +<03> <039B> +<04> <039E> +<05> <03A0> +<06> <03A3> +<07> <03D2> +<08> <03A6> +<0B> <00660066> +<0C> <00660069> +<0D> <0066006C> +<0E> <006600660069> +<0F> <00660066006C> +<10> <0131> +<11> <0237> +<12> <0060> +<13> <00B4> +<14> <02C7> +<15> <02D8> +<16> <00AF> +<17> <02DA> +<18> <00B8> +<19> <00DF> +<1A> <00E6> +<1B> <0153> +<1C> <00F8> +<1D> <00C6> +<1E> <0152> +<1F> <00D8> +<21> <0021> +<22> <201D> +<27> <2019> +<3C> <00A1> +<3D> <003D> +<3E> <00BF> +<5C> <201C> +<5F> <02D9> +<60> <2018> +<7D> <02DD> +<7E> <007E> +<7F> <00A8> +endbfchar +endcmap +CMapName currentdict /CMap defineresource pop +end +end +%%EndResource +%%EOF + }\endgroup + \expandafter\edef\csname cmapOT1\endcsname#1{% + \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% + }% +% +% \cmapOT1IT + \begingroup + \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. + \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap +%%DocumentNeededResources: ProcSet (CIDInit) +%%IncludeResource: ProcSet (CIDInit) +%%BeginResource: CMap (TeX-OT1IT-0) +%%Title: (TeX-OT1IT-0 TeX OT1IT 0) +%%Version: 1.000 +%%EndComments +/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (TeX) +/Ordering (OT1IT) +/Supplement 0 +>> def +/CMapName /TeX-OT1IT-0 def +/CMapType 2 def +1 begincodespacerange +<00> <7F> +endcodespacerange +8 beginbfrange +<00> <01> <0393> +<09> <0A> <03A8> +<25> <26> <0025> +<28> <3B> <0028> +<3F> <5B> <003F> +<5D> <5E> <005D> +<61> <7A> <0061> +<7B> <7C> <2013> +endbfrange +42 beginbfchar +<02> <0398> +<03> <039B> +<04> <039E> +<05> <03A0> +<06> <03A3> +<07> <03D2> +<08> <03A6> +<0B> <00660066> +<0C> <00660069> +<0D> <0066006C> +<0E> <006600660069> +<0F> <00660066006C> +<10> <0131> +<11> <0237> +<12> <0060> +<13> <00B4> +<14> <02C7> +<15> <02D8> +<16> <00AF> +<17> <02DA> +<18> <00B8> +<19> <00DF> +<1A> <00E6> +<1B> <0153> +<1C> <00F8> +<1D> <00C6> +<1E> <0152> +<1F> <00D8> +<21> <0021> +<22> <201D> +<23> <0023> +<24> <00A3> +<27> <2019> +<3C> <00A1> +<3D> <003D> +<3E> <00BF> +<5C> <201C> +<5F> <02D9> +<60> <2018> +<7D> <02DD> +<7E> <007E> +<7F> <00A8> +endbfchar +endcmap +CMapName currentdict /CMap defineresource pop +end +end +%%EndResource +%%EOF + }\endgroup + \expandafter\edef\csname cmapOT1IT\endcsname#1{% + \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% + }% +% +% \cmapOT1TT + \begingroup + \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. + \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap +%%DocumentNeededResources: ProcSet (CIDInit) +%%IncludeResource: ProcSet (CIDInit) +%%BeginResource: CMap (TeX-OT1TT-0) +%%Title: (TeX-OT1TT-0 TeX OT1TT 0) +%%Version: 1.000 +%%EndComments +/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (TeX) +/Ordering (OT1TT) +/Supplement 0 +>> def +/CMapName /TeX-OT1TT-0 def +/CMapType 2 def +1 begincodespacerange +<00> <7F> +endcodespacerange +5 beginbfrange +<00> <01> <0393> +<09> <0A> <03A8> +<21> <26> <0021> +<28> <5F> <0028> +<61> <7E> <0061> +endbfrange +32 beginbfchar +<02> <0398> +<03> <039B> +<04> <039E> +<05> <03A0> +<06> <03A3> +<07> <03D2> +<08> <03A6> +<0B> <2191> +<0C> <2193> +<0D> <0027> +<0E> <00A1> +<0F> <00BF> +<10> <0131> +<11> <0237> +<12> <0060> +<13> <00B4> +<14> <02C7> +<15> <02D8> +<16> <00AF> +<17> <02DA> +<18> <00B8> +<19> <00DF> +<1A> <00E6> +<1B> <0153> +<1C> <00F8> +<1D> <00C6> +<1E> <0152> +<1F> <00D8> +<20> <2423> +<27> <2019> +<60> <2018> +<7F> <00A8> +endbfchar +endcmap +CMapName currentdict /CMap defineresource pop +end +end +%%EndResource +%%EOF + }\endgroup + \expandafter\edef\csname cmapOT1TT\endcsname#1{% + \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% + }% +\fi\fi + + +% Set the font macro #1 to the font named \fontprefix#2. +% #3 is the font's design size, #4 is a scale factor, #5 is the CMap +% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). +% Example: +% #1 = \textrm +% #2 = \rmshape +% #3 = 10 +% #4 = \mainmagstep +% #5 = OT1 +% +\def\setfont#1#2#3#4#5{% + \font#1=\fontprefix#2#3 scaled #4 + \csname cmap#5\endcsname#1% +} +% This is what gets called when #5 of \setfont is empty. +\let\cmap\gobble +% +% (end of cmaps) + +% Use cm as the default font prefix. +% To specify the font prefix, you must define \fontprefix +% before you read in texinfo.tex. +\ifx\fontprefix\thisisundefined +\def\fontprefix{cm} +\fi +% Support font families that don't use the same naming scheme as CM. +\def\rmshape{r} +\def\rmbshape{bx} % where the normal face is bold +\def\bfshape{b} +\def\bxshape{bx} +\def\ttshape{tt} +\def\ttbshape{tt} +\def\ttslshape{sltt} +\def\itshape{ti} +\def\itbshape{bxti} +\def\slshape{sl} +\def\slbshape{bxsl} +\def\sfshape{ss} +\def\sfbshape{ss} +\def\scshape{csc} +\def\scbshape{csc} + +% Definitions for a main text size of 11pt. (The default in Texinfo.) +% +\def\definetextfontsizexi{% +% Text fonts (11.2pt, magstep1). +\def\textnominalsize{11pt} +\edef\mainmagstep{\magstephalf} +\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} +\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} +\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} +\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} +\setfont\textsl\slshape{10}{\mainmagstep}{OT1} +\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} +\setfont\textsc\scshape{10}{\mainmagstep}{OT1} +\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep +\def\textecsize{1095} + +% A few fonts for @defun names and args. +\setfont\defbf\bfshape{10}{\magstep1}{OT1} +\setfont\deftt\ttshape{10}{\magstep1}{OT1TT} +\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} + +% Fonts for indices, footnotes, small examples (9pt). +\def\smallnominalsize{9pt} +\setfont\smallrm\rmshape{9}{1000}{OT1} +\setfont\smalltt\ttshape{9}{1000}{OT1TT} +\setfont\smallbf\bfshape{10}{900}{OT1} +\setfont\smallit\itshape{9}{1000}{OT1IT} +\setfont\smallsl\slshape{9}{1000}{OT1} +\setfont\smallsf\sfshape{9}{1000}{OT1} +\setfont\smallsc\scshape{10}{900}{OT1} +\setfont\smallttsl\ttslshape{10}{900}{OT1TT} +\font\smalli=cmmi9 +\font\smallsy=cmsy9 +\def\smallecsize{0900} + +% Fonts for small examples (8pt). +\def\smallernominalsize{8pt} +\setfont\smallerrm\rmshape{8}{1000}{OT1} +\setfont\smallertt\ttshape{8}{1000}{OT1TT} +\setfont\smallerbf\bfshape{10}{800}{OT1} +\setfont\smallerit\itshape{8}{1000}{OT1IT} +\setfont\smallersl\slshape{8}{1000}{OT1} +\setfont\smallersf\sfshape{8}{1000}{OT1} +\setfont\smallersc\scshape{10}{800}{OT1} +\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} +\font\smalleri=cmmi8 +\font\smallersy=cmsy8 +\def\smallerecsize{0800} + +% Fonts for title page (20.4pt): +\def\titlenominalsize{20pt} +\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} +\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} +\setfont\titlesl\slbshape{10}{\magstep4}{OT1} +\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} +\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} +\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} +\let\titlebf=\titlerm +\setfont\titlesc\scbshape{10}{\magstep4}{OT1} +\font\titlei=cmmi12 scaled \magstep3 +\font\titlesy=cmsy10 scaled \magstep4 +\def\titleecsize{2074} + +% Chapter (and unnumbered) fonts (17.28pt). +\def\chapnominalsize{17pt} +\setfont\chaprm\rmbshape{12}{\magstep2}{OT1} +\setfont\chapit\itbshape{10}{\magstep3}{OT1IT} +\setfont\chapsl\slbshape{10}{\magstep3}{OT1} +\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} +\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} +\setfont\chapsf\sfbshape{17}{1000}{OT1} +\let\chapbf=\chaprm +\setfont\chapsc\scbshape{10}{\magstep3}{OT1} +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 +\def\chapecsize{1728} + +% Section fonts (14.4pt). +\def\secnominalsize{14pt} +\setfont\secrm\rmbshape{12}{\magstep1}{OT1} +\setfont\secit\itbshape{10}{\magstep2}{OT1IT} +\setfont\secsl\slbshape{10}{\magstep2}{OT1} +\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} +\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} +\setfont\secsf\sfbshape{12}{\magstep1}{OT1} +\let\secbf\secrm +\setfont\secsc\scbshape{10}{\magstep2}{OT1} +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 +\def\sececsize{1440} + +% Subsection fonts (13.15pt). +\def\ssecnominalsize{13pt} +\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} +\setfont\ssecit\itbshape{10}{1315}{OT1IT} +\setfont\ssecsl\slbshape{10}{1315}{OT1} +\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} +\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} +\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} +\let\ssecbf\ssecrm +\setfont\ssecsc\scbshape{10}{1315}{OT1} +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled 1315 +\def\ssececsize{1200} + +% Reduced fonts for @acro in text (10pt). +\def\reducednominalsize{10pt} +\setfont\reducedrm\rmshape{10}{1000}{OT1} +\setfont\reducedtt\ttshape{10}{1000}{OT1TT} +\setfont\reducedbf\bfshape{10}{1000}{OT1} +\setfont\reducedit\itshape{10}{1000}{OT1IT} +\setfont\reducedsl\slshape{10}{1000}{OT1} +\setfont\reducedsf\sfshape{10}{1000}{OT1} +\setfont\reducedsc\scshape{10}{1000}{OT1} +\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} +\font\reducedi=cmmi10 +\font\reducedsy=cmsy10 +\def\reducedecsize{1000} + +\textleading = 13.2pt % line spacing for 11pt CM +\textfonts % reset the current fonts +\rm +} % end of 11pt text font size definitions, \definetextfontsizexi + + +% Definitions to make the main text be 10pt Computer Modern, with +% section, chapter, etc., sizes following suit. This is for the GNU +% Press printing of the Emacs 22 manual. Maybe other manuals in the +% future. Used with @smallbook, which sets the leading to 12pt. +% +\def\definetextfontsizex{% +% Text fonts (10pt). +\def\textnominalsize{10pt} +\edef\mainmagstep{1000} +\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} +\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} +\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} +\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} +\setfont\textsl\slshape{10}{\mainmagstep}{OT1} +\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} +\setfont\textsc\scshape{10}{\mainmagstep}{OT1} +\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep +\def\textecsize{1000} + +% A few fonts for @defun names and args. +\setfont\defbf\bfshape{10}{\magstephalf}{OT1} +\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} +\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} + +% Fonts for indices, footnotes, small examples (9pt). +\def\smallnominalsize{9pt} +\setfont\smallrm\rmshape{9}{1000}{OT1} +\setfont\smalltt\ttshape{9}{1000}{OT1TT} +\setfont\smallbf\bfshape{10}{900}{OT1} +\setfont\smallit\itshape{9}{1000}{OT1IT} +\setfont\smallsl\slshape{9}{1000}{OT1} +\setfont\smallsf\sfshape{9}{1000}{OT1} +\setfont\smallsc\scshape{10}{900}{OT1} +\setfont\smallttsl\ttslshape{10}{900}{OT1TT} +\font\smalli=cmmi9 +\font\smallsy=cmsy9 +\def\smallecsize{0900} + +% Fonts for small examples (8pt). +\def\smallernominalsize{8pt} +\setfont\smallerrm\rmshape{8}{1000}{OT1} +\setfont\smallertt\ttshape{8}{1000}{OT1TT} +\setfont\smallerbf\bfshape{10}{800}{OT1} +\setfont\smallerit\itshape{8}{1000}{OT1IT} +\setfont\smallersl\slshape{8}{1000}{OT1} +\setfont\smallersf\sfshape{8}{1000}{OT1} +\setfont\smallersc\scshape{10}{800}{OT1} +\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} +\font\smalleri=cmmi8 +\font\smallersy=cmsy8 +\def\smallerecsize{0800} + +% Fonts for title page (20.4pt): +\def\titlenominalsize{20pt} +\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} +\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} +\setfont\titlesl\slbshape{10}{\magstep4}{OT1} +\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} +\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} +\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} +\let\titlebf=\titlerm +\setfont\titlesc\scbshape{10}{\magstep4}{OT1} +\font\titlei=cmmi12 scaled \magstep3 +\font\titlesy=cmsy10 scaled \magstep4 +\def\titleecsize{2074} + +% Chapter fonts (14.4pt). +\def\chapnominalsize{14pt} +\setfont\chaprm\rmbshape{12}{\magstep1}{OT1} +\setfont\chapit\itbshape{10}{\magstep2}{OT1IT} +\setfont\chapsl\slbshape{10}{\magstep2}{OT1} +\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} +\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} +\setfont\chapsf\sfbshape{12}{\magstep1}{OT1} +\let\chapbf\chaprm +\setfont\chapsc\scbshape{10}{\magstep2}{OT1} +\font\chapi=cmmi12 scaled \magstep1 +\font\chapsy=cmsy10 scaled \magstep2 +\def\chapecsize{1440} + +% Section fonts (12pt). +\def\secnominalsize{12pt} +\setfont\secrm\rmbshape{12}{1000}{OT1} +\setfont\secit\itbshape{10}{\magstep1}{OT1IT} +\setfont\secsl\slbshape{10}{\magstep1}{OT1} +\setfont\sectt\ttbshape{12}{1000}{OT1TT} +\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} +\setfont\secsf\sfbshape{12}{1000}{OT1} +\let\secbf\secrm +\setfont\secsc\scbshape{10}{\magstep1}{OT1} +\font\seci=cmmi12 +\font\secsy=cmsy10 scaled \magstep1 +\def\sececsize{1200} + +% Subsection fonts (10pt). +\def\ssecnominalsize{10pt} +\setfont\ssecrm\rmbshape{10}{1000}{OT1} +\setfont\ssecit\itbshape{10}{1000}{OT1IT} +\setfont\ssecsl\slbshape{10}{1000}{OT1} +\setfont\ssectt\ttbshape{10}{1000}{OT1TT} +\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} +\setfont\ssecsf\sfbshape{10}{1000}{OT1} +\let\ssecbf\ssecrm +\setfont\ssecsc\scbshape{10}{1000}{OT1} +\font\sseci=cmmi10 +\font\ssecsy=cmsy10 +\def\ssececsize{1000} + +% Reduced fonts for @acro in text (9pt). +\def\reducednominalsize{9pt} +\setfont\reducedrm\rmshape{9}{1000}{OT1} +\setfont\reducedtt\ttshape{9}{1000}{OT1TT} +\setfont\reducedbf\bfshape{10}{900}{OT1} +\setfont\reducedit\itshape{9}{1000}{OT1IT} +\setfont\reducedsl\slshape{9}{1000}{OT1} +\setfont\reducedsf\sfshape{9}{1000}{OT1} +\setfont\reducedsc\scshape{10}{900}{OT1} +\setfont\reducedttsl\ttslshape{10}{900}{OT1TT} +\font\reducedi=cmmi9 +\font\reducedsy=cmsy9 +\def\reducedecsize{0900} + +\divide\parskip by 2 % reduce space between paragraphs +\textleading = 12pt % line spacing for 10pt CM +\textfonts % reset the current fonts +\rm +} % end of 10pt text font size definitions, \definetextfontsizex + + +% We provide the user-level command +% @fonttextsize 10 +% (or 11) to redefine the text font size. pt is assumed. +% +\def\xiword{11} +\def\xword{10} +\def\xwordpt{10pt} +% +\parseargdef\fonttextsize{% + \def\textsizearg{#1}% + %\wlog{doing @fonttextsize \textsizearg}% + % + % Set \globaldefs so that documents can use this inside @tex, since + % makeinfo 4.8 does not support it, but we need it nonetheless. + % + \begingroup \globaldefs=1 + \ifx\textsizearg\xword \definetextfontsizex + \else \ifx\textsizearg\xiword \definetextfontsizexi + \else + \errhelp=\EMsimple + \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} + \fi\fi + \endgroup +} + + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts except +% in the main text, we don't bother to reset \scriptfont and +% \scriptscriptfont (which would also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy + \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf + \textfont\ttfam=\tentt \textfont\sffam=\tensf +} + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this because \STYLE needs to also set the +% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire +% \tenSTYLE to set the current font. +% +% Each font-changing command also sets the names \lsize (one size lower) +% and \lllsize (three sizes lower). These relative commands are used in +% the LaTeX logo and acronyms. +% +% This all needs generalizing, badly. +% +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \let\tenttsl=\textttsl + \def\curfontsize{text}% + \def\lsize{reduced}\def\lllsize{smaller}% + \resetmathfonts \setleading{\textleading}} +\def\titlefonts{% + \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl + \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc + \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy + \let\tenttsl=\titlettsl + \def\curfontsize{title}% + \def\lsize{chap}\def\lllsize{subsec}% + \resetmathfonts \setleading{27pt}} +\def\titlefont#1{{\titlefonts\rmisbold #1}} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy + \let\tenttsl=\chapttsl + \def\curfontsize{chap}% + \def\lsize{sec}\def\lllsize{text}% + \resetmathfonts \setleading{19pt}} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \let\tenttsl=\secttsl + \def\curfontsize{sec}% + \def\lsize{subsec}\def\lllsize{reduced}% + \resetmathfonts \setleading{16pt}} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \let\tenttsl=\ssecttsl + \def\curfontsize{ssec}% + \def\lsize{text}\def\lllsize{small}% + \resetmathfonts \setleading{15pt}} +\let\subsubsecfonts = \subsecfonts +\def\reducedfonts{% + \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl + \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc + \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy + \let\tenttsl=\reducedttsl + \def\curfontsize{reduced}% + \def\lsize{small}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\def\smallfonts{% + \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl + \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc + \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy + \let\tenttsl=\smallttsl + \def\curfontsize{small}% + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\def\smallerfonts{% + \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl + \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc + \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy + \let\tenttsl=\smallerttsl + \def\curfontsize{smaller}% + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{9.5pt}} + +% Fonts for short table of contents. +\setfont\shortcontrm\rmshape{12}{1000}{OT1} +\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 +\setfont\shortcontsl\slshape{12}{1000}{OT1} +\setfont\shortconttt\ttshape{12}{1000}{OT1TT} + +% Define these just so they can be easily changed for other fonts. +\def\angleleft{$\langle$} +\def\angleright{$\rangle$} + +% Set the fonts to use with the @small... environments. +\let\smallexamplefonts = \smallfonts + +% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample +% can fit this many characters: +% 8.5x11=86 smallbook=72 a4=90 a5=69 +% If we use \scriptfonts (8pt), then we can fit this many characters: +% 8.5x11=90+ smallbook=80 a4=90+ a5=77 +% For me, subjectively, the few extra characters that fit aren't worth +% the additional smallness of 8pt. So I'm making the default 9pt. +% +% By the way, for comparison, here's what fits with @example (10pt): +% 8.5x11=71 smallbook=60 a4=75 a5=58 +% --karl, 24jan03. + +% Set up the default fonts, so we can use them for creating boxes. +% +\definetextfontsizexi + + +\message{markup,} + +% Check if we are currently using a typewriter font. Since all the +% Computer Modern typewriter fonts have zero interword stretch (and +% shrink), and it is reasonable to expect all typewriter fonts to have +% this property, we can check that font parameter. +% +\def\ifmonospace{\ifdim\fontdimen3\font=0pt } + +% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will +% define and register \INITMACRO to be called on markup style changes. +% \INITMACRO can check \currentmarkupstyle for the innermost +% style and the set of \ifmarkupSTYLE switches for all styles +% currently in effect. +\newif\ifmarkupvar +\newif\ifmarkupsamp +\newif\ifmarkupkey +%\newif\ifmarkupfile % @file == @samp. +%\newif\ifmarkupoption % @option == @samp. +\newif\ifmarkupcode +\newif\ifmarkupkbd +%\newif\ifmarkupenv % @env == @code. +%\newif\ifmarkupcommand % @command == @code. +\newif\ifmarkuptex % @tex (and part of @math, for now). +\newif\ifmarkupexample +\newif\ifmarkupverb +\newif\ifmarkupverbatim + +\let\currentmarkupstyle\empty + +\def\setupmarkupstyle#1{% + \csname markup#1true\endcsname + \def\currentmarkupstyle{#1}% + \markupstylesetup +} + +\let\markupstylesetup\empty + +\def\defmarkupstylesetup#1{% + \expandafter\def\expandafter\markupstylesetup + \expandafter{\markupstylesetup #1}% + \def#1% +} + +% Markup style setup for left and right quotes. +\defmarkupstylesetup\markupsetuplq{% + \expandafter\let\expandafter \temp + \csname markupsetuplq\currentmarkupstyle\endcsname + \ifx\temp\relax \markupsetuplqdefault \else \temp \fi +} + +\defmarkupstylesetup\markupsetuprq{% + \expandafter\let\expandafter \temp + \csname markupsetuprq\currentmarkupstyle\endcsname + \ifx\temp\relax \markupsetuprqdefault \else \temp \fi +} + +{ +\catcode`\'=\active +\catcode`\`=\active + +\gdef\markupsetuplqdefault{\let`\lq} +\gdef\markupsetuprqdefault{\let'\rq} + +\gdef\markupsetcodequoteleft{\let`\codequoteleft} +\gdef\markupsetcodequoteright{\let'\codequoteright} +} + +\let\markupsetuplqcode \markupsetcodequoteleft +\let\markupsetuprqcode \markupsetcodequoteright +% +\let\markupsetuplqexample \markupsetcodequoteleft +\let\markupsetuprqexample \markupsetcodequoteright +% +\let\markupsetuplqkbd \markupsetcodequoteleft +\let\markupsetuprqkbd \markupsetcodequoteright +% +\let\markupsetuplqsamp \markupsetcodequoteleft +\let\markupsetuprqsamp \markupsetcodequoteright +% +\let\markupsetuplqverb \markupsetcodequoteleft +\let\markupsetuprqverb \markupsetcodequoteright +% +\let\markupsetuplqverbatim \markupsetcodequoteleft +\let\markupsetuprqverbatim \markupsetcodequoteright + +% Allow an option to not use regular directed right quote/apostrophe +% (char 0x27), but instead the undirected quote from cmtt (char 0x0d). +% The undirected quote is ugly, so don't make it the default, but it +% works for pasting with more pdf viewers (at least evince), the +% lilypond developers report. xpdf does work with the regular 0x27. +% +\def\codequoteright{% + \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax + \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax + '% + \else \char'15 \fi + \else \char'15 \fi +} +% +% and a similar option for the left quote char vs. a grave accent. +% Modern fonts display ASCII 0x60 as a grave accent, so some people like +% the code environments to do likewise. +% +\def\codequoteleft{% + \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax + \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax + % [Knuth] pp. 380,381,391 + % \relax disables Spanish ligatures ?` and !` of \tt font. + \relax`% + \else \char'22 \fi + \else \char'22 \fi +} + +% Commands to set the quote options. +% +\parseargdef\codequoteundirected{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETtxicodequoteundirected\endcsname + = t% + \else\ifx\temp\offword + \expandafter\let\csname SETtxicodequoteundirected\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% + \fi\fi +} +% +\parseargdef\codequotebacktick{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETtxicodequotebacktick\endcsname + = t% + \else\ifx\temp\offword + \expandafter\let\csname SETtxicodequotebacktick\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% + \fi\fi +} + +% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. +\def\noligaturesquoteleft{\relax\lq} + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Font commands. + +% #1 is the font command (\sl or \it), #2 is the text to slant. +% If we are in a monospaced environment, however, 1) always use \ttsl, +% and 2) do not add an italic correction. +\def\dosmartslant#1#2{% + \ifusingtt + {{\ttsl #2}\let\next=\relax}% + {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% + \next +} +\def\smartslanted{\dosmartslant\sl} +\def\smartitalic{\dosmartslant\it} + +% Output an italic correction unless \next (presumed to be the following +% character) is such as not to need one. +\def\smartitaliccorrection{% + \ifx\next,% + \else\ifx\next-% + \else\ifx\next.% + \else\ptexslash + \fi\fi\fi + \aftersmartic +} + +% Unconditional use \ttsl, and no ic. @var is set to this for defuns. +\def\ttslanted#1{{\ttsl #1}} + +% @cite is like \smartslanted except unconditionally use \sl. We never want +% ttsl for book titles, do we? +\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} + +\def\aftersmartic{} +\def\var#1{% + \let\saveaftersmartic = \aftersmartic + \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% + \smartslanted{#1}% +} + +\let\i=\smartitalic +\let\slanted=\smartslanted +\let\dfn=\smartslanted +\let\emph=\smartitalic + +% Explicit font changes: @r, @sc, undocumented @ii. +\def\r#1{{\rm #1}} % roman font +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +% @b, explicit bold. Also @strong. +\def\b#1{{\bf #1}} +\let\strong=\b + +% @sansserif, explicit sans. +\def\sansserif#1{{\sf #1}} + +% We can't just use \exhyphenpenalty, because that only has effect at +% the end of a paragraph. Restore normal hyphenation at the end of the +% group within which \nohyphenation is presumably called. +% +\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} +\def\restorehyphenation{\hyphenchar\font = `- } + +% Set sfcode to normal for the chars that usually have another value. +% Can't use plain's \frenchspacing because it uses the `\x notation, and +% sometimes \x has an active definition that messes things up. +% +\catcode`@=11 + \def\plainfrenchspacing{% + \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m + \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m + \def\endofsentencespacefactor{1000}% for @. and friends + } + \def\plainnonfrenchspacing{% + \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 + \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 + \def\endofsentencespacefactor{3000}% for @. and friends + } +\catcode`@=\other +\def\endofsentencespacefactor{3000}% default + +% @t, explicit typewriter. +\def\t#1{% + {\tt \rawbackslash \plainfrenchspacing #1}% + \null +} + +% @samp. +\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} + +% @indicateurl is \samp, that is, with quotes. +\let\indicateurl=\samp + +% @code (and similar) prints in typewriter, but with spaces the same +% size as normal in the surrounding text, without hyphenation, etc. +% This is a subroutine for that. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \plainfrenchspacing + #1% + }% + \null % reset spacefactor to 1000 +} + +% We *must* turn on hyphenation at `-' and `_' in @code. +% Otherwise, it is too hard to avoid overfull hboxes +% in the Emacs manual, the Library manual, etc. +% +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate at a dash. +% -- rms. +{ + \catcode`\-=\active \catcode`\_=\active + \catcode`\'=\active \catcode`\`=\active + \global\let'=\rq \global\let`=\lq % default definitions + % + \global\def\code{\begingroup + \setupmarkupstyle{code}% + % The following should really be moved into \setupmarkupstyle handlers. + \catcode\dashChar=\active \catcode\underChar=\active + \ifallowcodebreaks + \let-\codedash + \let_\codeunder + \else + \let-\normaldash + \let_\realunder + \fi + \codex + } +} + +\def\codex #1{\tclose{#1}\endgroup} + +\def\normaldash{-} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{% + % this is all so @math{@code{var_name}+1} can work. In math mode, _ + % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) + % will therefore expand the active definition of _, which is us + % (inside @code that is), therefore an endless loop. + \ifusingtt{\ifmmode + \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. + \else\normalunderscore \fi + \discretionary{}{}{}}% + {\_}% +} + +% An additional complication: the above will allow breaks after, e.g., +% each of the four underscores in __typeof__. This is bad. +% @allowcodebreaks provides a document-level way to turn breaking at - +% and _ on and off. +% +\newif\ifallowcodebreaks \allowcodebreakstrue + +\def\keywordtrue{true} +\def\keywordfalse{false} + +\parseargdef\allowcodebreaks{% + \def\txiarg{#1}% + \ifx\txiarg\keywordtrue + \allowcodebreakstrue + \else\ifx\txiarg\keywordfalse + \allowcodebreaksfalse + \else + \errhelp = \EMsimple + \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% + \fi\fi +} + +% For @command, @env, @file, @option quotes seem unnecessary, +% so use \code rather than \samp. +\let\command=\code +\let\env=\code +\let\file=\code +\let\option=\code + +% @uref (abbreviation for `urlref') takes an optional (comma-separated) +% second argument specifying the text to display and an optional third +% arg as text to display instead of (rather than in addition to) the url +% itself. First (mandatory) arg is the url. +% (This \urefnobreak definition isn't used now, leaving it for a while +% for comparison.) +\def\urefnobreak#1{\dourefnobreak #1,,,\finish} +\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup + \unsepspaces + \pdfurl{#1}% + \setbox0 = \hbox{\ignorespaces #3}% + \ifdim\wd0 > 0pt + \unhbox0 % third arg given, show only that + \else + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \ifpdf + \unhbox0 % PDF: 2nd arg given, show only it + \else + \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url + \fi + \else + \code{#1}% only url given, so show it + \fi + \fi + \endlink +\endgroup} + +% This \urefbreak definition is the active one. +\def\urefbreak{\begingroup \urefcatcodes \dourefbreak} +\let\uref=\urefbreak +\def\dourefbreak#1{\urefbreakfinish #1,,,\finish} +\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example + \unsepspaces + \pdfurl{#1}% + \setbox0 = \hbox{\ignorespaces #3}% + \ifdim\wd0 > 0pt + \unhbox0 % third arg given, show only that + \else + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \ifpdf + \unhbox0 % PDF: 2nd arg given, show only it + \else + \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url + \fi + \else + \urefcode{#1}% only url given, so show it + \fi + \fi + \endlink +\endgroup} + +% Allow line breaks around only a few characters (only). +\def\urefcatcodes{% + \catcode\ampChar=\active \catcode\dotChar=\active + \catcode\hashChar=\active \catcode\questChar=\active + \catcode\slashChar=\active +} +{ + \urefcatcodes + % + \global\def\urefcode{\begingroup + \setupmarkupstyle{code}% + \urefcatcodes + \let&\urefcodeamp + \let.\urefcodedot + \let#\urefcodehash + \let?\urefcodequest + \let/\urefcodeslash + \codex + } + % + % By default, they are just regular characters. + \global\def&{\normalamp} + \global\def.{\normaldot} + \global\def#{\normalhash} + \global\def?{\normalquest} + \global\def/{\normalslash} +} + +% we put a little stretch before and after the breakable chars, to help +% line breaking of long url's. The unequal skips make look better in +% cmtt at least, especially for dots. +\def\urefprestretch{\urefprebreak \hskip0pt plus.13em } +\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em } +% +\def\urefcodeamp{\urefprestretch \&\urefpoststretch} +\def\urefcodedot{\urefprestretch .\urefpoststretch} +\def\urefcodehash{\urefprestretch \#\urefpoststretch} +\def\urefcodequest{\urefprestretch ?\urefpoststretch} +\def\urefcodeslash{\futurelet\next\urefcodeslashfinish} +{ + \catcode`\/=\active + \global\def\urefcodeslashfinish{% + \urefprestretch \slashChar + % Allow line break only after the final / in a sequence of + % slashes, to avoid line break between the slashes in http://. + \ifx\next/\else \urefpoststretch \fi + } +} + +% One more complication: by default we'll break after the special +% characters, but some people like to break before the special chars, so +% allow that. Also allow no breaking at all, for manual control. +% +\parseargdef\urefbreakstyle{% + \def\txiarg{#1}% + \ifx\txiarg\wordnone + \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} + \else\ifx\txiarg\wordbefore + \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} + \else\ifx\txiarg\wordafter + \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} + \else + \errhelp = \EMsimple + \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% + \fi\fi\fi +} +\def\wordafter{after} +\def\wordbefore{before} +\def\wordnone{none} + +\urefbreakstyle after + +% @url synonym for @uref, since that's how everyone uses it. +% +\let\url=\uref + +% rms does not like angle brackets --karl, 17may97. +% So now @email is just like @uref, unless we are pdf. +% +%\def\email#1{\angleleft{\tt #1}\angleright} +\ifpdf + \def\email#1{\doemail#1,,\finish} + \def\doemail#1,#2,#3\finish{\begingroup + \unsepspaces + \pdfurl{mailto:#1}% + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi + \endlink + \endgroup} +\else + \let\email=\uref +\fi + +% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), +% `example' (@kbd uses ttsl only inside of @example and friends), +% or `code' (@kbd uses normal tty font always). +\parseargdef\kbdinputstyle{% + \def\txiarg{#1}% + \ifx\txiarg\worddistinct + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% + \else\ifx\txiarg\wordexample + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% + \else\ifx\txiarg\wordcode + \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% + \else + \errhelp = \EMsimple + \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% + \fi\fi\fi +} +\def\worddistinct{distinct} +\def\wordexample{example} +\def\wordcode{code} + +% Default is `distinct'. +\kbdinputstyle distinct + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. +\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} + +\def\xkey{\key} +\def\kbdsub#1#2#3\par{% + \def\one{#1}\def\three{#3}\def\threex{??}% + \ifx\one\xkey\ifx\threex\three \key{#2}% + \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi + \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi +} + +% definition of @key that produces a lozenge. Doesn't adjust to text size. +%\setfont\keyrm\rmshape{8}{1000}{OT1} +%\font\keysy=cmsy9 +%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% +% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% +% \vbox{\hrule\kern-0.4pt +% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% +% \kern-0.4pt\hrule}% +% \kern-.06em\raise0.4pt\hbox{\angleright}}}} + +% definition of @key with no lozenge. If the current font is already +% monospace, don't change it; that way, we respect @kbdinputstyle. But +% if it isn't monospace, then use \tt. +% +\def\key#1{{\setupmarkupstyle{key}% + \nohyphenation + \ifmonospace\else\tt\fi + #1}\null} + +% @clicksequence{File @click{} Open ...} +\def\clicksequence#1{\begingroup #1\endgroup} + +% @clickstyle @arrow (by default) +\parseargdef\clickstyle{\def\click{#1}} +\def\click{\arrow} + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +% @l was never documented to mean ``switch to the Lisp font'', +% and it is not used as such in any manual I can find. We need it for +% Polish suppressed-l. --karl, 22sep96. +%\def\l#1{{\li #1}\null} + +% @acronym for "FBI", "NATO", and the like. +% We print this one point size smaller, since it's intended for +% all-uppercase. +% +\def\acronym#1{\doacronym #1,,\finish} +\def\doacronym#1,#2,#3\finish{% + {\selectfonts\lsize #1}% + \def\temp{#2}% + \ifx\temp\empty \else + \space ({\unsepspaces \ignorespaces \temp \unskip})% + \fi + \null % reset \spacefactor=1000 +} + +% @abbr for "Comput. J." and the like. +% No font change, but don't do end-of-sentence spacing. +% +\def\abbr#1{\doabbr #1,,\finish} +\def\doabbr#1,#2,#3\finish{% + {\plainfrenchspacing #1}% + \def\temp{#2}% + \ifx\temp\empty \else + \space ({\unsepspaces \ignorespaces \temp \unskip})% + \fi + \null % reset \spacefactor=1000 +} + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math outputs its argument in math mode. +% +% One complication: _ usually means subscripts, but it could also mean +% an actual _ character, as in @math{@var{some_variable} + 1}. So make +% _ active, and distinguish by seeing if the current family is \slfam, +% which is what @var uses. +{ + \catcode`\_ = \active + \gdef\mathunderscore{% + \catcode`\_=\active + \def_{\ifnum\fam=\slfam \_\else\sb\fi}% + } +} +% Another complication: we want \\ (and @\) to output a math (or tt) \. +% FYI, plain.tex uses \\ as a temporary control sequence (for no +% particular reason), but this is not advertised and we don't care. +% +% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. +\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} +% +\def\math{% + \tex + \mathunderscore + \let\\ = \mathbackslash + \mathactive + % make the texinfo accent commands work in math mode + \let\"=\ddot + \let\'=\acute + \let\==\bar + \let\^=\hat + \let\`=\grave + \let\u=\breve + \let\v=\check + \let\~=\tilde + \let\dotaccent=\dot + $\finishmath +} +\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. + +% Some active characters (such as <) are spaced differently in math. +% We have to reset their definitions in case the @math was an argument +% to a command which sets the catcodes (such as @item or @section). +% +{ + \catcode`^ = \active + \catcode`< = \active + \catcode`> = \active + \catcode`+ = \active + \catcode`' = \active + \gdef\mathactive{% + \let^ = \ptexhat + \let< = \ptexless + \let> = \ptexgtr + \let+ = \ptexplus + \let' = \ptexquoteright + } +} + +% ctrl is no longer a Texinfo command, but leave this definition for fun. +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. +% Ignore unless FMTNAME == tex; then it is like @iftex and @tex, +% except specified as a normal braced arg, so no newlines to worry about. +% +\def\outfmtnametex{tex} +% +\long\def\inlinefmt#1{\doinlinefmt #1,\finish} +\long\def\doinlinefmt#1,#2,\finish{% + \def\inlinefmtname{#1}% + \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi +} +% For raw, must switch into @tex before parsing the argument, to avoid +% setting catcodes prematurely. Doing it this way means that, for +% example, @inlineraw{html, foo{bar} gets a parse error instead of being +% ignored. But this isn't important because if people want a literal +% *right* brace they would have to use a command anyway, so they may as +% well use a command to get a left brace too. We could re-use the +% delimiter character idea from \verb, but it seems like overkill. +% +\long\def\inlineraw{\tex \doinlineraw} +\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} +\def\doinlinerawtwo#1,#2,\finish{% + \def\inlinerawname{#1}% + \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi + \endgroup % close group opened by \tex. +} + + +\message{glyphs,} +% and logos. + +% @@ prints an @, as does @atchar{}. +\def\@{\char64 } +\let\atchar=\@ + +% @{ @} @lbracechar{} @rbracechar{} all generate brace characters. +% Unless we're in typewriter, use \ecfont because the CM text fonts do +% not have braces, and we don't want to switch into math. +\def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}} +\def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}} +\let\{=\mylbrace \let\lbracechar=\{ +\let\}=\myrbrace \let\rbracechar=\} +\begingroup + % Definitions to produce \{ and \} commands for indices, + % and @{ and @} for the aux/toc files. + \catcode`\{ = \other \catcode`\} = \other + \catcode`\[ = 1 \catcode`\] = 2 + \catcode`\! = 0 \catcode`\\ = \other + !gdef!lbracecmd[\{]% + !gdef!rbracecmd[\}]% + !gdef!lbraceatcmd[@{]% + !gdef!rbraceatcmd[@}]% +!endgroup + +% @comma{} to avoid , parsing problems. +\let\comma = , + +% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent +% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. +\let\, = \ptexc +\let\dotaccent = \ptexdot +\def\ringaccent#1{{\accent23 #1}} +\let\tieaccent = \ptext +\let\ubaraccent = \ptexb +\let\udotaccent = \d + +% Other special characters: @questiondown @exclamdown @ordf @ordm +% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. +\def\questiondown{?`} +\def\exclamdown{!`} +\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} +\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} + +% Dotless i and dotless j, used for accents. +\def\imacro{i} +\def\jmacro{j} +\def\dotless#1{% + \def\temp{#1}% + \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi + \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi + \else \errmessage{@dotless can be used only with i or j}% + \fi\fi +} + +% The \TeX{} logo, as in plain, but resetting the spacing so that a +% period following counts as ending a sentence. (Idea found in latex.) +% +\edef\TeX{\TeX \spacefactor=1000 } + +% @LaTeX{} logo. Not quite the same results as the definition in +% latex.ltx, since we use a different font for the raised A; it's most +% convenient for us to use an explicitly smaller font, rather than using +% the \scriptstyle font (since we don't reset \scriptstyle and +% \scriptscriptstyle). +% +\def\LaTeX{% + L\kern-.36em + {\setbox0=\hbox{T}% + \vbox to \ht0{\hbox{% + \ifx\textnominalsize\xwordpt + % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX. + % Revert to plain's \scriptsize, which is 7pt. + \count255=\the\fam $\fam\count255 \scriptstyle A$% + \else + % For 11pt, we can use our lllsize. + \selectfonts\lllsize A% + \fi + }% + \vss + }}% + \kern-.15em + \TeX +} + +% Some math mode symbols. +\def\bullet{$\ptexbullet$} +\def\geq{\ifmmode \ge\else $\ge$\fi} +\def\leq{\ifmmode \le\else $\le$\fi} +\def\minus{\ifmmode -\else $-$\fi} + +% @dots{} outputs an ellipsis using the current font. +% We do .5em per period so that it has the same spacing in the cm +% typewriter fonts as three actual period characters; on the other hand, +% in other typewriter fonts three periods are wider than 1.5em. So do +% whichever is larger. +% +\def\dots{% + \leavevmode + \setbox0=\hbox{...}% get width of three periods + \ifdim\wd0 > 1.5em + \dimen0 = \wd0 + \else + \dimen0 = 1.5em + \fi + \hbox to \dimen0{% + \hskip 0pt plus.25fil + .\hskip 0pt plus1fil + .\hskip 0pt plus1fil + .\hskip 0pt plus.5fil + }% +} + +% @enddots{} is an end-of-sentence ellipsis. +% +\def\enddots{% + \dots + \spacefactor=\endofsentencespacefactor +} + +% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. +% +% Since these characters are used in examples, they should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% +\def\point{$\star$} +\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} +\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} +\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% The @error{} command. +% Adapted from the TeXbook's \boxit. +% +\newbox\errorbox +% +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} +% +\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{% + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} +% +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @pounds{} is a sterling sign, which Knuth put in the CM italic font. +% +\def\pounds{{\it\$}} + +% @euro{} comes from a separate font, depending on the current style. +% We use the free feym* fonts from the eurosym package by Henrik +% Theiling, which support regular, slanted, bold and bold slanted (and +% "outlined" (blackboard board, sort of) versions, which we don't need). +% It is available from http://www.ctan.org/tex-archive/fonts/eurosym. +% +% Although only regular is the truly official Euro symbol, we ignore +% that. The Euro is designed to be slightly taller than the regular +% font height. +% +% feymr - regular +% feymo - slanted +% feybr - bold +% feybo - bold slanted +% +% There is no good (free) typewriter version, to my knowledge. +% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. +% Hmm. +% +% Also doesn't work in math. Do we need to do math with euro symbols? +% Hope not. +% +% +\def\euro{{\eurofont e}} +\def\eurofont{% + % We set the font at each command, rather than predefining it in + % \textfonts and the other font-switching commands, so that + % installations which never need the symbol don't have to have the + % font installed. + % + % There is only one designed size (nominal 10pt), so we always scale + % that to the current nominal size. + % + % By the way, simply using "at 1em" works for cmr10 and the like, but + % does not work for cmbx10 and other extended/shrunken fonts. + % + \def\eurosize{\csname\curfontsize nominalsize\endcsname}% + % + \ifx\curfontstyle\bfstylename + % bold: + \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize + \else + % regular: + \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize + \fi + \thiseurofont +} + +% Glyphs from the EC fonts. We don't use \let for the aliases, because +% sometimes we redefine the original macro, and the alias should reflect +% the redefinition. +% +% Use LaTeX names for the Icelandic letters. +\def\DH{{\ecfont \char"D0}} % Eth +\def\dh{{\ecfont \char"F0}} % eth +\def\TH{{\ecfont \char"DE}} % Thorn +\def\th{{\ecfont \char"FE}} % thorn +% +\def\guillemetleft{{\ecfont \char"13}} +\def\guillemotleft{\guillemetleft} +\def\guillemetright{{\ecfont \char"14}} +\def\guillemotright{\guillemetright} +\def\guilsinglleft{{\ecfont \char"0E}} +\def\guilsinglright{{\ecfont \char"0F}} +\def\quotedblbase{{\ecfont \char"12}} +\def\quotesinglbase{{\ecfont \char"0D}} +% +% This positioning is not perfect (see the ogonek LaTeX package), but +% we have the precomposed glyphs for the most common cases. We put the +% tests to use those glyphs in the single \ogonek macro so we have fewer +% dummy definitions to worry about for index entries, etc. +% +% ogonek is also used with other letters in Lithuanian (IOU), but using +% the precomposed glyphs for those is not so easy since they aren't in +% the same EC font. +\def\ogonek#1{{% + \def\temp{#1}% + \ifx\temp\macrocharA\Aogonek + \else\ifx\temp\macrochara\aogonek + \else\ifx\temp\macrocharE\Eogonek + \else\ifx\temp\macrochare\eogonek + \else + \ecfont \setbox0=\hbox{#1}% + \ifdim\ht0=1ex\accent"0C #1% + \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% + \fi + \fi\fi\fi\fi + }% +} +\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} +\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} +\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} +\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} +% +% Use the ec* fonts (cm-super in outline format) for non-CM glyphs. +\def\ecfont{% + % We can't distinguish serif/sans and italic/slanted, but this + % is used for crude hacks anyway (like adding French and German + % quotes to documents typeset with CM, where we lose kerning), so + % hopefully nobody will notice/care. + \edef\ecsize{\csname\curfontsize ecsize\endcsname}% + \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% + \ifmonospace + % typewriter: + \font\thisecfont = ectt\ecsize \space at \nominalsize + \else + \ifx\curfontstyle\bfstylename + % bold: + \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize + \else + % regular: + \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize + \fi + \fi + \thisecfont +} + +% @registeredsymbol - R in a circle. The font for the R should really +% be smaller yet, but lllsize is the best we can do for now. +% Adapted from the plain.tex definition of \copyright. +% +\def\registeredsymbol{% + $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% + \hfil\crcr\Orb}}% + }$% +} + +% @textdegree - the normal degrees sign. +% +\def\textdegree{$^\circ$} + +% Laurent Siebenmann reports \Orb undefined with: +% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 +% so we'll define it if necessary. +% +\ifx\Orb\thisisundefined +\def\Orb{\mathhexbox20D} +\fi + +% Quotes. +\chardef\quotedblleft="5C +\chardef\quotedblright=`\" +\chardef\quoteleft=`\` +\chardef\quoteright=`\' + + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\newif\ifseenauthor +\newif\iffinishedtitlepage + +% Do an implicit @contents or @shortcontents after @end titlepage if the +% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. +% +\newif\ifsetcontentsaftertitlepage + \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue +\newif\ifsetshortcontentsaftertitlepage + \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue + +\parseargdef\shorttitlepage{% + \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} + +\envdef\titlepage{% + % Open one extra group, as we want to close it in the middle of \Etitlepage. + \begingroup + \parindent=0pt \textfonts + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \let\page = \oldpage + \page + \null + }% +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + % + % Need this before the \...aftertitlepage checks so that if they are + % in effect the toc pages will come out with page numbers. + \HEADINGSon + % + % If they want short, they certainly want long too. + \ifsetshortcontentsaftertitlepage + \shortcontents + \contents + \global\let\shortcontents = \relax + \global\let\contents = \relax + \fi + % + \ifsetcontentsaftertitlepage + \contents + \global\let\contents = \relax + \global\let\shortcontents = \relax + \fi +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +% Settings used for typesetting titles: no hyphenation, no indentation, +% don't worry much about spacing, ragged right. This should be used +% inside a \vbox, and fonts need to be set appropriately first. Because +% it is always used for titles, nothing else, we call \rmisbold. \par +% should be specified before the end of the \vbox, since a vbox is a group. +% +\def\raggedtitlesettings{% + \rmisbold + \hyphenpenalty=10000 + \parindent=0pt + \tolerance=5000 + \ptexraggedright +} + +% Macros to be used within @titlepage: + +\let\subtitlerm=\tenrm +\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} + +\parseargdef\title{% + \checkenv\titlepage + \vbox{\titlefonts \raggedtitlesettings #1\par}% + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt +} + +\parseargdef\subtitle{% + \checkenv\titlepage + {\subtitlefont \rightline{#1}}% +} + +% @author should come last, but may come many times. +% It can also be used inside @quotation. +% +\parseargdef\author{% + \def\temp{\quotation}% + \ifx\thisenv\temp + \def\quotationauthor{#1}% printed in \Equotation. + \else + \checkenv\titlepage + \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi + {\secfonts\rmisbold \leftline{#1}}% + \fi +} + + +% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks\evenheadline % headline on even pages +\newtoks\oddheadline % headline on odd pages +\newtoks\evenfootline % footline on even pages +\newtoks\oddfootline % footline on odd pages + +% Now make TeX use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + + +\def\evenheading{\parsearg\evenheadingxxx} +\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} +\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\def\oddheading{\parsearg\oddheadingxxx} +\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} +\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} +\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\def\oddfooting{\parsearg\oddfootingxxx} +\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} +\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% + \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% + % + % Leave some space for the footline. Hopefully ok to assume + % @evenfooting will not be used by itself. + \global\advance\pageheight by -12pt + \global\advance\vsize by -12pt +} + +\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} + +% @evenheadingmarks top \thischapter <- chapter at the top of a page +% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page +% +% The same set of arguments for: +% +% @oddheadingmarks +% @evenfootingmarks +% @oddfootingmarks +% @everyheadingmarks +% @everyfootingmarks + +\def\evenheadingmarks{\headingmarks{even}{heading}} +\def\oddheadingmarks{\headingmarks{odd}{heading}} +\def\evenfootingmarks{\headingmarks{even}{footing}} +\def\oddfootingmarks{\headingmarks{odd}{footing}} +\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} + \headingmarks{odd}{heading}{#1} } +\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} + \headingmarks{odd}{footing}{#1} } +% #1 = even/odd, #2 = heading/footing, #3 = top/bottom. +\def\headingmarks#1#2#3 {% + \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname + \global\expandafter\let\csname get#1#2marks\endcsname \temp +} + +\everyheadingmarks bottom +\everyfootingmarks bottom + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off at the start of a document, +% and turned `on' after @end titlepage. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\headingsoff{% non-global headings elimination + \evenheadline={\hfil}\evenfootline={\hfil}% + \oddheadline={\hfil}\oddfootline={\hfil}% +} + +\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting +\HEADINGSoff % it's the default + +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{% +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} +\let\contentsalignmacro = \chappager + +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{% +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} + +% Subroutines used in generating headings +% This produces Day Month Year style of output. +% Only define if not already defined, in case a txi-??.tex file has set +% up a different format (e.g., txi-cs.tex does this). +\ifx\today\thisisundefined +\def\today{% + \number\day\space + \ifcase\month + \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr + \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug + \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec + \fi + \space\number\year} +\fi + +% @settitle line... specifies the title of the document, for headings. +% It generates no output of its own. +\def\thistitle{\putwordNoTitle} +\def\settitle{\parsearg{\gdef\thistitle}} + + +\message{tables,} +% Tables -- @table, @ftable, @vtable, @item(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @ftable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\newif\ifitemxneedsnegativevskip + +\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\itemxpar \parsearg\itemzzz} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemindicate{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + % + % Make this a paragraph so we get the \parskip glue and wrapping, + % but leave it ragged-right. + \begingroup + \advance\leftskip by-\tableindent + \advance\hsize by\tableindent + \advance\rightskip by0pt plus1fil\relax + \leavevmode\unhbox0\par + \endgroup + % + % We're going to be starting a paragraph, but we don't want the + % \parskip glue -- logically it's part of the @item we just started. + \nobreak \vskip-\parskip + % + % Stop a page break at the \parskip glue coming up. However, if + % what follows is an environment such as @example, there will be no + % \parskip glue; then the negative vskip we just inserted would + % cause the example and the item to crash together. So we use this + % bizarre value of 10001 as a signal to \aboveenvbreak to insert + % \parskip glue after all. Section titles are handled this way also. + % + \penalty 10001 + \endgroup + \itemxneedsnegativevskipfalse + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. + \noindent + % Do this with kerns and \unhbox so that if there is a footnote in + % the item text, it can migrate to the main vertical list and + % eventually be printed. + \nobreak\kern-\tableindent + \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 + \unhbox0 + \nobreak\kern\dimen0 + \endgroup + \itemxneedsnegativevskiptrue + \fi +} + +\def\item{\errmessage{@item while not in a list environment}} +\def\itemx{\errmessage{@itemx while not in a list environment}} + +% @table, @ftable, @vtable. +\envdef\table{% + \let\itemindex\gobble + \tablecheck{table}% +} +\envdef\ftable{% + \def\itemindex ##1{\doind {fn}{\code{##1}}}% + \tablecheck{ftable}% +} +\envdef\vtable{% + \def\itemindex ##1{\doind {vr}{\code{##1}}}% + \tablecheck{vtable}% +} +\def\tablecheck#1{% + \ifnum \the\catcode`\^^M=\active + \endgroup + \errmessage{This command won't work in this context; perhaps the problem is + that we are \inenvironment\thisenv}% + \def\next{\doignore{#1}}% + \else + \let\next\tablex + \fi + \next +} +\def\tablex#1{% + \def\itemindicate{#1}% + \parsearg\tabley +} +\def\tabley#1{% + {% + \makevalueexpandable + \edef\temp{\noexpand\tablez #1\space\space\space}% + \expandafter + }\temp \endtablez +} +\def\tablez #1 #2 #3 #4\endtablez{% + \aboveenvbreak + \ifnum 0#1>0 \advance \leftskip by #1\mil \fi + \ifnum 0#2>0 \tableindent=#2\mil \fi + \ifnum 0#3>0 \advance \rightskip by #3\mil \fi + \itemmax=\tableindent + \advance \itemmax by -\itemmargin + \advance \leftskip by \tableindent + \exdentamount=\tableindent + \parindent = 0pt + \parskip = \smallskipamount + \ifdim \parskip=0pt \parskip=2pt \fi + \let\item = \internalBitem + \let\itemx = \internalBitemx +} +\def\Etable{\endgraf\afterenvbreak} +\let\Eftable\Etable +\let\Evtable\Etable +\let\Eitemize\Etable +\let\Eenumerate\Etable + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\envdef\itemize{\parsearg\doitemize} + +\def\doitemize#1{% + \aboveenvbreak + \itemmax=\itemindent + \advance\itemmax by -\itemmargin + \advance\leftskip by \itemindent + \exdentamount=\itemindent + \parindent=0pt + \parskip=\smallskipamount + \ifdim\parskip=0pt \parskip=2pt \fi + % + % Try typesetting the item mark that if the document erroneously says + % something like @itemize @samp (intending @table), there's an error + % right away at the @itemize. It's not the best error message in the + % world, but it's better than leaving it to the @item. This means if + % the user wants an empty mark, they have to say @w{} not just @w. + \def\itemcontents{#1}% + \setbox0 = \hbox{\itemcontents}% + % + % @itemize with no arg is equivalent to @itemize @bullet. + \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi + % + \let\item=\itemizeitem +} + +% Definition of @item while inside @itemize and @enumerate. +% +\def\itemizeitem{% + \advance\itemno by 1 % for enumerations + {\let\par=\endgraf \smallbreak}% reasonable place to break + {% + % If the document has an @itemize directly after a section title, a + % \nobreak will be last on the list, and \sectionheading will have + % done a \vskip-\parskip. In that case, we don't want to zero + % parskip, or the item text will crash with the heading. On the + % other hand, when there is normal text preceding the item (as there + % usually is), we do want to zero parskip, or there would be too much + % space. In that case, we won't have a \nobreak before. At least + % that's the theory. + \ifnum\lastpenalty<10000 \parskip=0in \fi + \noindent + \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% + % + \vadjust{\penalty 1200}}% not good to break after first line of item. + \flushcr +} + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a . + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call \doitemize, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \doitemize{#1.}\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + + +% @multitable macros +% Amy Hendrickson, 8/18/94, 3/6/96 +% +% @multitable ... @end multitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @columnfractions .25 .3 .45 +% @item ... +% +% Numbers following @columnfractions are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab do not need to be on their own lines, but it will not hurt +% if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @end multitable + +% Default dimensions may be reset by user. +% @multitableparskip is vertical space between paragraphs in table. +% @multitableparindent is paragraph indent in table. +% @multitablecolmargin is horizontal space to be left between columns. +% @multitablelinespace is space to leave between table items, baseline +% to baseline. +% 0pt means it depends on current normal line spacing. +% +\newskip\multitableparskip +\newskip\multitableparindent +\newdimen\multitablecolspace +\newskip\multitablelinespace +\multitableparskip=0pt +\multitableparindent=6pt +\multitablecolspace=12pt +\multitablelinespace=0pt + +% Macros used to set up halign preamble: +% +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\columnfractions\relax +\def\xcolumnfractions{\columnfractions} +\newif\ifsetpercent + +% #1 is the @columnfraction, usually a decimal number like .5, but might +% be just 1. We just use it, whatever it is. +% +\def\pickupwholefraction#1 {% + \global\advance\colcount by 1 + \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% + \setuptable +} + +\newcount\colcount +\def\setuptable#1{% + \def\firstarg{#1}% + \ifx\firstarg\xendsetuptable + \let\go = \relax + \else + \ifx\firstarg\xcolumnfractions + \global\setpercenttrue + \else + \ifsetpercent + \let\go\pickupwholefraction + \else + \global\advance\colcount by 1 + \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a + % separator; typically that is always in the input, anyway. + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi + \fi + \ifx\go\pickupwholefraction + % Put the argument back for the \pickupwholefraction call, so + % we'll always have a period there to be parsed. + \def\go{\pickupwholefraction#1}% + \else + \let\go = \setuptable + \fi% + \fi + \go +} + +% multitable-only commands. +% +% @headitem starts a heading row, which we typeset in bold. +% Assignments have to be global since we are inside the implicit group +% of an alignment entry. \everycr resets \everytab so we don't have to +% undo it ourselves. +\def\headitemfont{\b}% for people to use in the template row; not changeable +\def\headitem{% + \checkenv\multitable + \crcr + \global\everytab={\bf}% can't use \headitemfont since the parsing differs + \the\everytab % for the first item +}% +% +% A \tab used to include \hskip1sp. But then the space in a template +% line is not enough. That is bad. So let's go back to just `&' until +% we again encounter the problem the 1sp was intended to solve. +% --karl, nathan@acm.org, 20apr99. +\def\tab{\checkenv\multitable &\the\everytab}% + +% @multitable ... @end multitable definitions: +% +\newtoks\everytab % insert after every tab. +% +\envdef\multitable{% + \vskip\parskip + \startsavinginserts + % + % @item within a multitable starts a normal row. + % We use \def instead of \let so that if one of the multitable entries + % contains an @itemize, we don't choke on the \item (seen as \crcr aka + % \endtemplate) expanding \doitemize. + \def\item{\crcr}% + % + \tolerance=9500 + \hbadness=9500 + \setmultitablespacing + \parskip=\multitableparskip + \parindent=\multitableparindent + \overfullrule=0pt + \global\colcount=0 + % + \everycr = {% + \noalign{% + \global\everytab={}% + \global\colcount=0 % Reset the column counter. + % Check for saved footnotes, etc. + \checkinserts + % Keeps underfull box messages off when table breaks over pages. + %\filbreak + % Maybe so, but it also creates really weird page breaks when the + % table breaks over pages. Wouldn't \vfil be better? Wait until the + % problem manifests itself, so it can be fixed for real --karl. + }% + }% + % + \parsearg\domultitable +} +\def\domultitable#1{% + % To parse everything between @multitable and @item: + \setuptable#1 \endsetuptable + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. + \halign\bgroup &% + \global\advance\colcount by 1 + \multistrut + \vtop{% + % Use the current \colcount to find the correct column width: + \hsize=\expandafter\csname col\the\colcount\endcsname + % + % In order to keep entries from bumping into each other + % we will add a \leftskip of \multitablecolspace to all columns after + % the first one. + % + % If a template has been used, we will add \multitablecolspace + % to the width of each template entry. + % + % If the user has set preamble in terms of percent of \hsize we will + % use that dimension as the width of the column, and the \leftskip + % will keep entries from bumping into each other. Table will start at + % left margin and final column will justify at right margin. + % + % Make sure we don't inherit \rightskip from the outer environment. + \rightskip=0pt + \ifnum\colcount=1 + % The first column will be indented with the surrounding text. + \advance\hsize by\leftskip + \else + \ifsetpercent \else + % If user has not set preamble in terms of percent of \hsize + % we will advance \hsize by \multitablecolspace. + \advance\hsize by \multitablecolspace + \fi + % In either case we will make \leftskip=\multitablecolspace: + \leftskip=\multitablecolspace + \fi + % Ignoring space at the beginning and end avoids an occasional spurious + % blank line, when TeX decides to break the line at the space before the + % box from the multistrut, so the strut ends up on a line by itself. + % For example: + % @multitable @columnfractions .11 .89 + % @item @code{#} + % @tab Legal holiday which is valid in major parts of the whole country. + % Is automatically provided with highlighting sequences respectively + % marking characters. + \noindent\ignorespaces##\unskip\multistrut + }\cr +} +\def\Emultitable{% + \crcr + \egroup % end the \halign + \global\setpercentfalse +} + +\def\setmultitablespacing{% + \def\multistrut{\strut}% just use the standard line spacing + % + % Compute \multitablelinespace (if not defined by user) for use in + % \multitableparskip calculation. We used define \multistrut based on + % this, but (ironically) that caused the spacing to be off. + % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. +\ifdim\multitablelinespace=0pt +\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip +\global\advance\multitablelinespace by-\ht0 +\fi +% Test to see if parskip is larger than space between lines of +% table. If not, do nothing. +% If so, set to same dimension as multitablelinespace. +\ifdim\multitableparskip>\multitablelinespace +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller + % than skip between lines in the table. +\fi% +\ifdim\multitableparskip=0pt +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller + % than skip between lines in the table. +\fi} + + +\message{conditionals,} + +% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, +% @ifnotxml always succeed. They currently do nothing; we don't +% attempt to check whether the conditionals are properly nested. But we +% have to remember that they are conditionals, so that @end doesn't +% attempt to close an environment group. +% +\def\makecond#1{% + \expandafter\let\csname #1\endcsname = \relax + \expandafter\let\csname iscond.#1\endcsname = 1 +} +\makecond{iftex} +\makecond{ifnotdocbook} +\makecond{ifnothtml} +\makecond{ifnotinfo} +\makecond{ifnotplaintext} +\makecond{ifnotxml} + +% Ignore @ignore, @ifhtml, @ifinfo, and the like. +% +\def\direntry{\doignore{direntry}} +\def\documentdescription{\doignore{documentdescription}} +\def\docbook{\doignore{docbook}} +\def\html{\doignore{html}} +\def\ifdocbook{\doignore{ifdocbook}} +\def\ifhtml{\doignore{ifhtml}} +\def\ifinfo{\doignore{ifinfo}} +\def\ifnottex{\doignore{ifnottex}} +\def\ifplaintext{\doignore{ifplaintext}} +\def\ifxml{\doignore{ifxml}} +\def\ignore{\doignore{ignore}} +\def\menu{\doignore{menu}} +\def\xml{\doignore{xml}} + +% Ignore text until a line `@end #1', keeping track of nested conditionals. +% +% A count to remember the depth of nesting. +\newcount\doignorecount + +\def\doignore#1{\begingroup + % Scan in ``verbatim'' mode: + \obeylines + \catcode`\@ = \other + \catcode`\{ = \other + \catcode`\} = \other + % + % Make sure that spaces turn into tokens that match what \doignoretext wants. + \spaceisspace + % + % Count number of #1's that we've seen. + \doignorecount = 0 + % + % Swallow text until we reach the matching `@end #1'. + \dodoignore{#1}% +} + +{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. + \obeylines % + % + \gdef\dodoignore#1{% + % #1 contains the command name as a string, e.g., `ifinfo'. + % + % Define a command to find the next `@end #1'. + \long\def\doignoretext##1^^M@end #1{% + \doignoretextyyy##1^^M@#1\_STOP_}% + % + % And this command to find another #1 command, at the beginning of a + % line. (Otherwise, we would consider a line `@c @ifset', for + % example, to count as an @ifset for nesting.) + \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% + % + % And now expand that command. + \doignoretext ^^M% + }% +} + +\def\doignoreyyy#1{% + \def\temp{#1}% + \ifx\temp\empty % Nothing found. + \let\next\doignoretextzzz + \else % Found a nested condition, ... + \advance\doignorecount by 1 + \let\next\doignoretextyyy % ..., look for another. + % If we're here, #1 ends with ^^M\ifinfo (for example). + \fi + \next #1% the token \_STOP_ is present just after this macro. +} + +% We have to swallow the remaining "\_STOP_". +% +\def\doignoretextzzz#1{% + \ifnum\doignorecount = 0 % We have just found the outermost @end. + \let\next\enddoignore + \else % Still inside a nested condition. + \advance\doignorecount by -1 + \let\next\doignoretext % Look for the next @end. + \fi + \next +} + +% Finish off ignored text. +{ \obeylines% + % Ignore anything after the last `@end #1'; this matters in verbatim + % environments, where otherwise the newline after an ignored conditional + % would result in a blank line in the output. + \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% +} + + +% @set VAR sets the variable VAR to an empty value. +% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. +% +% Since we want to separate VAR from REST-OF-LINE (which might be +% empty), we can't just use \parsearg; we have to insert a space of our +% own to delimit the rest of the line, and then take it out again if we +% didn't need it. +% We rely on the fact that \parsearg sets \catcode`\ =10. +% +\parseargdef\set{\setyyy#1 \endsetyyy} +\def\setyyy#1 #2\endsetyyy{% + {% + \makevalueexpandable + \def\temp{#2}% + \edef\next{\gdef\makecsname{SET#1}}% + \ifx\temp\empty + \next{}% + \else + \setzzz#2\endsetzzz + \fi + }% +} +% Remove the trailing space \setxxx inserted. +\def\setzzz#1 \endsetzzz{\next{#1}} + +% @clear VAR clears (i.e., unsets) the variable VAR. +% +\parseargdef\clear{% + {% + \makevalueexpandable + \global\expandafter\let\csname SET#1\endcsname=\relax + }% +} + +% @value{foo} gets the text saved in variable foo. +\def\value{\begingroup\makevalueexpandable\valuexxx} +\def\valuexxx#1{\expandablevalue{#1}\endgroup} +{ + \catcode`\- = \active \catcode`\_ = \active + % + \gdef\makevalueexpandable{% + \let\value = \expandablevalue + % We don't want these characters active, ... + \catcode`\-=\other \catcode`\_=\other + % ..., but we might end up with active ones in the argument if + % we're called from @code, as @code{@value{foo-bar_}}, though. + % So \let them to their normal equivalents. + \let-\normaldash \let_\normalunderscore + } +} + +% We have this subroutine so that we can handle at least some @value's +% properly in indexes (we call \makevalueexpandable in \indexdummies). +% The command has to be fully expandable (if the variable is set), since +% the result winds up in the index file. This means that if the +% variable's value contains other Texinfo commands, it's almost certain +% it will fail (although perhaps we could fix that with sufficient work +% to do a one-level expansion on the result, instead of complete). +% +\def\expandablevalue#1{% + \expandafter\ifx\csname SET#1\endcsname\relax + {[No value for ``#1'']}% + \message{Variable `#1', used in @value, is not set.}% + \else + \csname SET#1\endcsname + \fi +} + +% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined +% with @set. +% +% To get special treatment of `@end ifset,' call \makeond and the redefine. +% +\makecond{ifset} +\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} +\def\doifset#1#2{% + {% + \makevalueexpandable + \let\next=\empty + \expandafter\ifx\csname SET#2\endcsname\relax + #1% If not set, redefine \next. + \fi + \expandafter + }\next +} +\def\ifsetfail{\doignore{ifset}} + +% @ifclear VAR ... @end executes the `...' iff VAR has never been +% defined with @set, or has been undefined with @clear. +% +% The `\else' inside the `\doifset' parameter is a trick to reuse the +% above code: if the variable is not set, do nothing, if it is set, +% then redefine \next to \ifclearfail. +% +\makecond{ifclear} +\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} +\def\ifclearfail{\doignore{ifclear}} + +% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written +% without the @) is in fact defined. We can only feasibly check at the +% TeX level, so something like `mathcode' is going to considered +% defined even though it is not a Texinfo command. +% +\makecond{ifcommanddefined} +\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} +% +\def\doifcmddefined#1#2{{% + \makevalueexpandable + \let\next=\empty + \expandafter\ifx\csname #2\endcsname\relax + #1% If not defined, \let\next as above. + \fi + \expandafter + }\next +} +\def\ifcmddefinedfail{\doignore{ifcommanddefined}} + +% @ifcommandnotdefined CMD ... handled similar to @ifclear above. +\makecond{ifcommandnotdefined} +\def\ifcommandnotdefined{% + \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} +\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} + +% Set the `txicommandconditionals' variable, so documents have a way to +% test if the @ifcommand...defined conditionals are available. +\set txicommandconditionals + +% @dircategory CATEGORY -- specify a category of the dir file +% which this file should belong to. Ignore this in TeX. +\let\dircategory=\comment + +% @defininfoenclose. +\let\definfoenclose=\comment + + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within macros and \if's. +\edef\newwrite{\makecsname{ptexnewwrite}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. +% +\def\newindex#1{% + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 % Open the file + \fi + \expandafter\xdef\csname#1index\endcsname{% % Define @#1index + \noexpand\doindex{#1}} +} + +% @defindex foo == \newindex{foo} +% +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. +% +\def\defcodeindex{\parsearg\newcodeindex} +% +\def\newcodeindex#1{% + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 + \fi + \expandafter\xdef\csname#1index\endcsname{% + \noexpand\docodeindex{#1}}% +} + + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +% +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +% +\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} +\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} + +% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), +% #3 the target index (bar). +\def\dosynindex#1#2#3{% + % Only do \closeout if we haven't already done it, else we'll end up + % closing the target index. + \expandafter \ifx\csname donesynindex#2\endcsname \relax + % The \closeout helps reduce unnecessary open files; the limit on the + % Acorn RISC OS is a mere 16 files. + \expandafter\closeout\csname#2indfile\endcsname + \expandafter\let\csname donesynindex#2\endcsname = 1 + \fi + % redefine \fooindfile: + \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname + \expandafter\let\csname#2indfile\endcsname=\temp + % redefine \fooindex: + \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +% Take care of Texinfo commands that can appear in an index entry. +% Since there are some commands we want to expand, and others we don't, +% we have to laboriously prevent expansion for those that we don't. +% +\def\indexdummies{% + \escapechar = `\\ % use backslash in output files. + \def\@{@}% change to @@ when we switch to @ as escape char in index files. + \def\ {\realbackslash\space }% + % + % Need these unexpandable (because we define \tt as a dummy) + % definitions when @{ or @} appear in index entry text. Also, more + % complicated, when \tex is in effect and \{ is a \delimiter again. + % We can't use \lbracecmd and \rbracecmd because texindex assumes + % braces and backslashes are used only as delimiters. Perhaps we + % should define @lbrace and @rbrace commands a la @comma. + \def\{{{\tt\char123}}% + \def\}{{\tt\char125}}% + % + % I don't entirely understand this, but when an index entry is + % generated from a macro call, the \endinput which \scanmacro inserts + % causes processing to be prematurely terminated. This is, + % apparently, because \indexsorttmp is fully expanded, and \endinput + % is an expandable command. The redefinition below makes \endinput + % disappear altogether for that purpose -- although logging shows that + % processing continues to some further point. On the other hand, it + % seems \endinput does not hurt in the printed index arg, since that + % is still getting written without apparent harm. + % + % Sample source (mac-idx3.tex, reported by Graham Percival to + % help-texinfo, 22may06): + % @macro funindex {WORD} + % @findex xyz + % @end macro + % ... + % @funindex commtest + % + % The above is not enough to reproduce the bug, but it gives the flavor. + % + % Sample whatsit resulting: + % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} + % + % So: + \let\endinput = \empty + % + % Do the redefinitions. + \commondummies +} + +% For the aux and toc files, @ is the escape character. So we want to +% redefine everything using @ as the escape character (instead of +% \realbackslash, still used for index files). When everything uses @, +% this will be simpler. +% +\def\atdummies{% + \def\@{@@}% + \def\ {@ }% + \let\{ = \lbraceatcmd + \let\} = \rbraceatcmd + % + % Do the redefinitions. + \commondummies + \otherbackslash +} + +% Called from \indexdummies and \atdummies. +% +\def\commondummies{% + % + % \definedummyword defines \#1 as \string\#1\space, thus effectively + % preventing its expansion. This is used only for control words, + % not control letters, because the \space would be incorrect for + % control characters, but is needed to separate the control word + % from whatever follows. + % + % For control letters, we have \definedummyletter, which omits the + % space. + % + % These can be used both for control words that take an argument and + % those that do not. If it is followed by {arg} in the input, then + % that will dutifully get written to the index (or wherever). + % + \def\definedummyword ##1{\def##1{\string##1\space}}% + \def\definedummyletter##1{\def##1{\string##1}}% + \let\definedummyaccent\definedummyletter + % + \commondummiesnofonts + % + \definedummyletter\_% + \definedummyletter\-% + % + % Non-English letters. + \definedummyword\AA + \definedummyword\AE + \definedummyword\DH + \definedummyword\L + \definedummyword\O + \definedummyword\OE + \definedummyword\TH + \definedummyword\aa + \definedummyword\ae + \definedummyword\dh + \definedummyword\exclamdown + \definedummyword\l + \definedummyword\o + \definedummyword\oe + \definedummyword\ordf + \definedummyword\ordm + \definedummyword\questiondown + \definedummyword\ss + \definedummyword\th + % + % Although these internal commands shouldn't show up, sometimes they do. + \definedummyword\bf + \definedummyword\gtr + \definedummyword\hat + \definedummyword\less + \definedummyword\sf + \definedummyword\sl + \definedummyword\tclose + \definedummyword\tt + % + \definedummyword\LaTeX + \definedummyword\TeX + % + % Assorted special characters. + \definedummyword\arrow + \definedummyword\bullet + \definedummyword\comma + \definedummyword\copyright + \definedummyword\registeredsymbol + \definedummyword\dots + \definedummyword\enddots + \definedummyword\entrybreak + \definedummyword\equiv + \definedummyword\error + \definedummyword\euro + \definedummyword\expansion + \definedummyword\geq + \definedummyword\guillemetleft + \definedummyword\guillemetright + \definedummyword\guilsinglleft + \definedummyword\guilsinglright + \definedummyword\lbracechar + \definedummyword\leq + \definedummyword\minus + \definedummyword\ogonek + \definedummyword\pounds + \definedummyword\point + \definedummyword\print + \definedummyword\quotedblbase + \definedummyword\quotedblleft + \definedummyword\quotedblright + \definedummyword\quoteleft + \definedummyword\quoteright + \definedummyword\quotesinglbase + \definedummyword\rbracechar + \definedummyword\result + \definedummyword\textdegree + % + % We want to disable all macros so that they are not expanded by \write. + \macrolist + % + \normalturnoffactive + % + % Handle some cases of @value -- where it does not contain any + % (non-fully-expandable) commands. + \makevalueexpandable +} + +% \commondummiesnofonts: common to \commondummies and \indexnofonts. +% +\def\commondummiesnofonts{% + % Control letters and accents. + \definedummyletter\!% + \definedummyaccent\"% + \definedummyaccent\'% + \definedummyletter\*% + \definedummyaccent\,% + \definedummyletter\.% + \definedummyletter\/% + \definedummyletter\:% + \definedummyaccent\=% + \definedummyletter\?% + \definedummyaccent\^% + \definedummyaccent\`% + \definedummyaccent\~% + \definedummyword\u + \definedummyword\v + \definedummyword\H + \definedummyword\dotaccent + \definedummyword\ogonek + \definedummyword\ringaccent + \definedummyword\tieaccent + \definedummyword\ubaraccent + \definedummyword\udotaccent + \definedummyword\dotless + % + % Texinfo font commands. + \definedummyword\b + \definedummyword\i + \definedummyword\r + \definedummyword\sansserif + \definedummyword\sc + \definedummyword\slanted + \definedummyword\t + % + % Commands that take arguments. + \definedummyword\abbr + \definedummyword\acronym + \definedummyword\anchor + \definedummyword\cite + \definedummyword\code + \definedummyword\command + \definedummyword\dfn + \definedummyword\dmn + \definedummyword\email + \definedummyword\emph + \definedummyword\env + \definedummyword\file + \definedummyword\image + \definedummyword\indicateurl + \definedummyword\inforef + \definedummyword\kbd + \definedummyword\key + \definedummyword\math + \definedummyword\option + \definedummyword\pxref + \definedummyword\ref + \definedummyword\samp + \definedummyword\strong + \definedummyword\tie + \definedummyword\uref + \definedummyword\url + \definedummyword\var + \definedummyword\verb + \definedummyword\w + \definedummyword\xref +} + +% \indexnofonts is used when outputting the strings to sort the index +% by, and when constructing control sequence names. It eliminates all +% control sequences and just writes whatever the best ASCII sort string +% would be for a given command (usually its argument). +% +\def\indexnofonts{% + % Accent commands should become @asis. + \def\definedummyaccent##1{\let##1\asis}% + % We can just ignore other control letters. + \def\definedummyletter##1{\let##1\empty}% + % All control words become @asis by default; overrides below. + \let\definedummyword\definedummyaccent + % + \commondummiesnofonts + % + % Don't no-op \tt, since it isn't a user-level command + % and is used in the definitions of the active chars like <, >, |, etc. + % Likewise with the other plain tex font commands. + %\let\tt=\asis + % + \def\ { }% + \def\@{@}% + \def\_{\normalunderscore}% + \def\-{}% @- shouldn't affect sorting + % + % Unfortunately, texindex is not prepared to handle braces in the + % content at all. So for index sorting, we map @{ and @} to strings + % starting with |, since that ASCII character is between ASCII { and }. + \def\{{|a}% + \def\lbracechar{|a}% + % + \def\}{|b}% + \def\rbracechar{|b}% + % + % Non-English letters. + \def\AA{AA}% + \def\AE{AE}% + \def\DH{DZZ}% + \def\L{L}% + \def\OE{OE}% + \def\O{O}% + \def\TH{ZZZ}% + \def\aa{aa}% + \def\ae{ae}% + \def\dh{dzz}% + \def\exclamdown{!}% + \def\l{l}% + \def\oe{oe}% + \def\ordf{a}% + \def\ordm{o}% + \def\o{o}% + \def\questiondown{?}% + \def\ss{ss}% + \def\th{zzz}% + % + \def\LaTeX{LaTeX}% + \def\TeX{TeX}% + % + % Assorted special characters. + % (The following {} will end up in the sort string, but that's ok.) + \def\arrow{->}% + \def\bullet{bullet}% + \def\comma{,}% + \def\copyright{copyright}% + \def\dots{...}% + \def\enddots{...}% + \def\equiv{==}% + \def\error{error}% + \def\euro{euro}% + \def\expansion{==>}% + \def\geq{>=}% + \def\guillemetleft{<<}% + \def\guillemetright{>>}% + \def\guilsinglleft{<}% + \def\guilsinglright{>}% + \def\leq{<=}% + \def\minus{-}% + \def\point{.}% + \def\pounds{pounds}% + \def\print{-|}% + \def\quotedblbase{"}% + \def\quotedblleft{"}% + \def\quotedblright{"}% + \def\quoteleft{`}% + \def\quoteright{'}% + \def\quotesinglbase{,}% + \def\registeredsymbol{R}% + \def\result{=>}% + \def\textdegree{o}% + % + \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax + \else \indexlquoteignore \fi + % + % We need to get rid of all macros, leaving only the arguments (if present). + % Of course this is not nearly correct, but it is the best we can do for now. + % makeinfo does not expand macros in the argument to @deffn, which ends up + % writing an index entry, and texindex isn't prepared for an index sort entry + % that starts with \. + % + % Since macro invocations are followed by braces, we can just redefine them + % to take a single TeX argument. The case of a macro invocation that + % goes to end-of-line is not handled. + % + \macrolist +} + +% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us +% ignore left quotes in the sort term. +{\catcode`\`=\active + \gdef\indexlquoteignore{\let`=\empty}} + +\let\indexbackslash=0 %overridden during \printindex. +\let\SETmarginindex=\relax % put index entries in margin (undocumented)? + +% Most index entries go through here, but \dosubind is the general case. +% #1 is the index name, #2 is the entry text. +\def\doind#1#2{\dosubind{#1}{#2}{}} + +% Workhorse for all \fooindexes. +% #1 is name of index, #2 is stuff to put there, #3 is subentry -- +% empty if called from \doind, as we usually are (the main exception +% is with most defuns, which call us directly). +% +\def\dosubind#1#2#3{% + \iflinks + {% + % Store the main index entry text (including the third arg). + \toks0 = {#2}% + % If third arg is present, precede it with a space. + \def\thirdarg{#3}% + \ifx\thirdarg\empty \else + \toks0 = \expandafter{\the\toks0 \space #3}% + \fi + % + \edef\writeto{\csname#1indfile\endcsname}% + % + \safewhatsit\dosubindwrite + }% + \fi +} + +% Write the entry in \toks0 to the index file: +% +\def\dosubindwrite{% + % Put the index entry in the margin if desired. + \ifx\SETmarginindex\relax\else + \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% + \fi + % + % Remember, we are within a group. + \indexdummies % Must do this here, since \bf, etc expand at this stage + \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now + % so it will be output as is; and it will print as backslash. + % + % Process the index entry with all font commands turned off, to + % get the string to sort by. + {\indexnofonts + \edef\temp{\the\toks0}% need full expansion + \xdef\indexsorttmp{\temp}% + }% + % + % Set up the complete index entry, with both the sort key and + % the original text, including any font commands. We write + % three arguments to \entry to the .?? file (four in the + % subentry case), texindex reduces to two when writing the .??s + % sorted result. + \edef\temp{% + \write\writeto{% + \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% + }% + \temp +} + +% Take care of unwanted page breaks/skips around a whatsit: +% +% If a skip is the last thing on the list now, preserve it +% by backing up by \lastskip, doing the \write, then inserting +% the skip again. Otherwise, the whatsit generated by the +% \write or \pdfdest will make \lastskip zero. The result is that +% sequences like this: +% @end defun +% @tindex whatever +% @defun ... +% will have extra space inserted, because the \medbreak in the +% start of the @defun won't see the skip inserted by the @end of +% the previous defun. +% +% But don't do any of this if we're not in vertical mode. We +% don't want to do a \vskip and prematurely end a paragraph. +% +% Avoid page breaks due to these extra skips, too. +% +% But wait, there is a catch there: +% We'll have to check whether \lastskip is zero skip. \ifdim is not +% sufficient for this purpose, as it ignores stretch and shrink parts +% of the skip. The only way seems to be to check the textual +% representation of the skip. +% +% The following is almost like \def\zeroskipmacro{0.0pt} except that +% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). +% +\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} +% +\newskip\whatsitskip +\newcount\whatsitpenalty +% +% ..., ready, GO: +% +\def\safewhatsit#1{\ifhmode + #1% + \else + % \lastskip and \lastpenalty cannot both be nonzero simultaneously. + \whatsitskip = \lastskip + \edef\lastskipmacro{\the\lastskip}% + \whatsitpenalty = \lastpenalty + % + % If \lastskip is nonzero, that means the last item was a + % skip. And since a skip is discardable, that means this + % -\whatsitskip glue we're inserting is preceded by a + % non-discardable item, therefore it is not a potential + % breakpoint, therefore no \nobreak needed. + \ifx\lastskipmacro\zeroskipmacro + \else + \vskip-\whatsitskip + \fi + % + #1% + % + \ifx\lastskipmacro\zeroskipmacro + % If \lastskip was zero, perhaps the last item was a penalty, and + % perhaps it was >=10000, e.g., a \nobreak. In that case, we want + % to re-insert the same penalty (values >10000 are used for various + % signals); since we just inserted a non-discardable item, any + % following glue (such as a \parskip) would be a breakpoint. For example: + % @deffn deffn-whatever + % @vindex index-whatever + % Description. + % would allow a break between the index-whatever whatsit + % and the "Description." paragraph. + \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi + \else + % On the other hand, if we had a nonzero \lastskip, + % this make-up glue would be preceded by a non-discardable item + % (the whatsit from the \write), so we must insert a \nobreak. + \nobreak\vskip\whatsitskip + \fi +\fi} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% @printindex causes a particular index (the ??s file) to get printed. +% It does not print any chapter heading (usually an @unnumbered). +% +\parseargdef\printindex{\begingroup + \dobreak \chapheadingskip{10000}% + % + \smallfonts \rm + \tolerance = 9500 + \plainfrenchspacing + \everypar = {}% don't want the \kern\-parindent from indentation suppression. + % + % See if the index file exists and is nonempty. + % Change catcode of @ here so that if the index file contains + % \initial {@} + % as its first line, TeX doesn't complain about mismatched braces + % (because it thinks @} is a control sequence). + \catcode`\@ = 11 + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + \putwordIndexNonexistent + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + \putwordIndexIsEmpty + \else + % Index files are almost Texinfo source, but we use \ as the escape + % character. It would be better to use @, but that's too big a change + % to make right now. + \def\indexbackslash{\backslashcurfont}% + \catcode`\\ = 0 + \escapechar = `\\ + \begindoublecolumns + \input \jobname.#1s + \enddoublecolumns + \fi + \fi + \closein 1 +\endgroup} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +\def\initial#1{{% + % Some minor font changes for the special characters. + \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt + % + % Remove any glue we may have, we'll be inserting our own. + \removelastskip + % + % We like breaks before the index initials, so insert a bonus. + \nobreak + \vskip 0pt plus 3\baselineskip + \penalty 0 + \vskip 0pt plus -3\baselineskip + % + % Typeset the initial. Making this add up to a whole number of + % baselineskips increases the chance of the dots lining up from column + % to column. It still won't often be perfect, because of the stretch + % we need before each entry, but it's better. + % + % No shrink because it confuses \balancecolumns. + \vskip 1.67\baselineskip plus .5\baselineskip + \leftline{\secbf #1}% + % Do our best not to break after the initial. + \nobreak + \vskip .33\baselineskip plus .1\baselineskip +}} + +% \entry typesets a paragraph consisting of the text (#1), dot leaders, and +% then page number (#2) flushed to the right margin. It is used for index +% and table of contents entries. The paragraph is indented by \leftskip. +% +% A straightforward implementation would start like this: +% \def\entry#1#2{... +% But this freezes the catcodes in the argument, and can cause problems to +% @code, which sets - active. This problem was fixed by a kludge--- +% ``-'' was active throughout whole index, but this isn't really right. +% The right solution is to prevent \entry from swallowing the whole text. +% --kasal, 21nov03 +\def\entry{% + \begingroup + % + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par + % + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent = 2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % A bit of stretch before each entry for the benefit of balancing + % columns. + \vskip 0pt plus1pt + % + % When reading the text of entry, convert explicit line breaks + % from @* into spaces. The user might give these in long section + % titles, for instance. + \def\*{\unskip\space\ignorespaces}% + \def\entrybreak{\hfil\break}% + % + % Swallow the left brace of the text (first parameter): + \afterassignment\doentry + \let\temp = +} +\def\entrybreak{\unskip\space\ignorespaces}% +\def\doentry{% + \bgroup % Instead of the swallowed brace. + \noindent + \aftergroup\finishentry + % And now comes the text of the entry. +} +\def\finishentry#1{% + % #1 is the page number. + % + % The following is kludged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \setbox\boxA = \hbox{#1}% + \ifdim\wd\boxA = 0pt + \ % + \else + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ifpdf + \pdfgettoks#1.% + \ \the\toksA + \else + \ #1% + \fi + \fi + \par + \endgroup +} + +% Like plain.tex's \dotfill, except uses up at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm +\def\secondary#1#2{{% + \parfillskip=0in + \parskip=0in + \hangindent=1in + \hangafter=1 + \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill + \ifpdf + \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. + \else + #2 + \fi + \par +}} + +% Define two-column mode, which we use to typeset indexes. +% Adapted from the TeXbook, page 416, which is to say, +% the manmac.tex format used to print the TeXbook itself. +\catcode`\@=11 + +\newbox\partialpage +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns + % Grab any single-column material above us. + \output = {% + % + % Here is a possibility not foreseen in manmac: if we accumulate a + % whole lot of material, we might end up calling this \output + % routine twice in a row (see the doublecol-lose test, which is + % essentially a couple of indexes with @setchapternewpage off). In + % that case we just ship out what is in \partialpage with the normal + % output routine. Generally, \partialpage will be empty when this + % runs and this will be a no-op. See the indexspread.tex test case. + \ifvoid\partialpage \else + \onepageout{\pagecontents\partialpage}% + \fi + % + \global\setbox\partialpage = \vbox{% + % Unvbox the main output page. + \unvbox\PAGE + \kern-\topskip \kern\baselineskip + }% + }% + \eject % run that output routine to set \partialpage + % + % Use the double-column output routine for subsequent pages. + \output = {\doublecolumnout}% + % + % Change the page size parameters. We could do this once outside this + % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 + % format, but then we repeat the same computation. Repeating a couple + % of assignments once per index is clearly meaningless for the + % execution time, so we may as well do it in one place. + % + % First we halve the line length, less a little for the gutter between + % the columns. We compute the gutter based on the line length, so it + % changes automatically with the paper format. The magic constant + % below is chosen so that the gutter has the same value (well, +-<1pt) + % as it did when we hard-coded it. + % + % We put the result in a separate register, \doublecolumhsize, so we + % can restore it in \pagesofar, after \hsize itself has (potentially) + % been clobbered. + % + \doublecolumnhsize = \hsize + \advance\doublecolumnhsize by -.04154\hsize + \divide\doublecolumnhsize by 2 + \hsize = \doublecolumnhsize + % + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) + \vsize = 2\vsize +} + +% The double-column output routine for all double-column pages except +% the last. +% +\def\doublecolumnout{% + \splittopskip=\topskip \splitmaxdepth=\maxdepth + % Get the available space for the double columns -- the normal + % (undoubled) page height minus any material left over from the + % previous page. + \dimen@ = \vsize + \divide\dimen@ by 2 + \advance\dimen@ by -\ht\partialpage + % + % box0 will be the left-hand column, box2 the right. + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ + \onepageout\pagesofar + \unvbox255 + \penalty\outputpenalty +} +% +% Re-output the contents of the output page -- any previous material, +% followed by the two boxes we just split, in box0 and box2. +\def\pagesofar{% + \unvbox\partialpage + % + \hsize = \doublecolumnhsize + \wd0=\hsize \wd2=\hsize + \hbox to\pagewidth{\box0\hfil\box2}% +} +% +% All done with double columns. +\def\enddoublecolumns{% + % The following penalty ensures that the page builder is exercised + % _before_ we change the output routine. This is necessary in the + % following situation: + % + % The last section of the index consists only of a single entry. + % Before this section, \pagetotal is less than \pagegoal, so no + % break occurs before the last section starts. However, the last + % section, consisting of \initial and the single \entry, does not + % fit on the page and has to be broken off. Without the following + % penalty the page builder will not be exercised until \eject + % below, and by that time we'll already have changed the output + % routine to the \balancecolumns version, so the next-to-last + % double-column page will be processed with \balancecolumns, which + % is wrong: The two columns will go to the main vertical list, with + % the broken-off section in the recent contributions. As soon as + % the output routine finishes, TeX starts reconsidering the page + % break. The two columns and the broken-off section both fit on the + % page, because the two columns now take up only half of the page + % goal. When TeX sees \eject from below which follows the final + % section, it invokes the new output routine that we've set after + % \balancecolumns below; \onepageout will try to fit the two columns + % and the final section into the vbox of \pageheight (see + % \pagebody), causing an overfull box. + % + % Note that glue won't work here, because glue does not exercise the + % page builder, unlike penalties (see The TeXbook, pp. 280-281). + \penalty0 + % + \output = {% + % Split the last of the double-column material. Leave it on the + % current page, no automatic page break. + \balancecolumns + % + % If we end up splitting too much material for the current page, + % though, there will be another page break right after this \output + % invocation ends. Having called \balancecolumns once, we do not + % want to call it again. Therefore, reset \output to its normal + % definition right away. (We hope \balancecolumns will never be + % called on to balance too much material, but if it is, this makes + % the output somewhat more palatable.) + \global\output = {\onepageout{\pagecontents\PAGE}}% + }% + \eject + \endgroup % started in \begindoublecolumns + % + % \pagegoal was set to the doubled \vsize above, since we restarted + % the current page. We're now back to normal single-column + % typesetting, so reset \pagegoal to the normal \vsize (after the + % \endgroup where \vsize got restored). + \pagegoal = \vsize +} +% +% Called at the end of the double column material. +\def\balancecolumns{% + \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. + \dimen@ = \ht0 + \advance\dimen@ by \topskip + \advance\dimen@ by-\baselineskip + \divide\dimen@ by 2 % target to split to + %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% + \splittopskip = \topskip + % Loop until we get a decent breakpoint. + {% + \vbadness = 10000 + \loop + \global\setbox3 = \copy0 + \global\setbox1 = \vsplit3 to \dimen@ + \ifdim\ht3>\dimen@ + \global\advance\dimen@ by 1pt + \repeat + }% + %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% + \setbox0=\vbox to\dimen@{\unvbox1}% + \setbox2=\vbox to\dimen@{\unvbox3}% + % + \pagesofar +} +\catcode`\@ = \other + + +\message{sectioning,} +% Chapters, sections, etc. + +% Let's start with @part. +\outer\parseargdef\part{\partzzz{#1}} +\def\partzzz#1{% + \chapoddpage + \null + \vskip.3\vsize % move it down on the page a bit + \begingroup + \noindent \titlefonts\rmisbold #1\par % the text + \let\lastnode=\empty % no node to associate with + \writetocentry{part}{#1}{}% but put it in the toc + \headingsoff % no headline or footline on the part page + \chapoddpage + \endgroup +} + +% \unnumberedno is an oxymoron. But we count the unnumbered +% sections so that we can refer to them unambiguously in the pdf +% outlines by their "section number". We avoid collisions with chapter +% numbers by starting them at 10000. (If a document ever has 10000 +% chapters, we're in trouble anyway, I'm sure.) +\newcount\unnumberedno \unnumberedno = 10000 +\newcount\chapno +\newcount\secno \secno=0 +\newcount\subsecno \subsecno=0 +\newcount\subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +\newcount\appendixno \appendixno = `\@ +% +% \def\appendixletter{\char\the\appendixno} +% We do the following ugly conditional instead of the above simple +% construct for the sake of pdftex, which needs the actual +% letter in the expansion, not just typeset. +% +\def\appendixletter{% + \ifnum\appendixno=`A A% + \else\ifnum\appendixno=`B B% + \else\ifnum\appendixno=`C C% + \else\ifnum\appendixno=`D D% + \else\ifnum\appendixno=`E E% + \else\ifnum\appendixno=`F F% + \else\ifnum\appendixno=`G G% + \else\ifnum\appendixno=`H H% + \else\ifnum\appendixno=`I I% + \else\ifnum\appendixno=`J J% + \else\ifnum\appendixno=`K K% + \else\ifnum\appendixno=`L L% + \else\ifnum\appendixno=`M M% + \else\ifnum\appendixno=`N N% + \else\ifnum\appendixno=`O O% + \else\ifnum\appendixno=`P P% + \else\ifnum\appendixno=`Q Q% + \else\ifnum\appendixno=`R R% + \else\ifnum\appendixno=`S S% + \else\ifnum\appendixno=`T T% + \else\ifnum\appendixno=`U U% + \else\ifnum\appendixno=`V V% + \else\ifnum\appendixno=`W W% + \else\ifnum\appendixno=`X X% + \else\ifnum\appendixno=`Y Y% + \else\ifnum\appendixno=`Z Z% + % The \the is necessary, despite appearances, because \appendixletter is + % expanded while writing the .toc file. \char\appendixno is not + % expandable, thus it is written literally, thus all appendixes come out + % with the same letter (or @) in the toc without it. + \else\char\the\appendixno + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} + +% Each @chapter defines these (using marks) as the number+name, number +% and name of the chapter. Page headings and footings can use +% these. @section does likewise. +\def\thischapter{} +\def\thischapternum{} +\def\thischaptername{} +\def\thissection{} +\def\thissectionnum{} +\def\thissectionname{} + +\newcount\absseclevel % used to calculate proper heading level +\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count + +% @raisesections: treat @section as chapter, @subsection as section, etc. +\def\raisesections{\global\advance\secbase by -1} +\let\up=\raisesections % original BFox name + +% @lowersections: treat @chapter as section, @section as subsection, etc. +\def\lowersections{\global\advance\secbase by 1} +\let\down=\lowersections % original BFox name + +% we only have subsub. +\chardef\maxseclevel = 3 +% +% A numbered section within an unnumbered changes to unnumbered too. +% To achieve this, remember the "biggest" unnum. sec. we are currently in: +\chardef\unnlevel = \maxseclevel +% +% Trace whether the current chapter is an appendix or not: +% \chapheadtype is "N" or "A", unnumbered chapters are ignored. +\def\chapheadtype{N} + +% Choose a heading macro +% #1 is heading type +% #2 is heading level +% #3 is text for heading +\def\genhead#1#2#3{% + % Compute the abs. sec. level: + \absseclevel=#2 + \advance\absseclevel by \secbase + % Make sure \absseclevel doesn't fall outside the range: + \ifnum \absseclevel < 0 + \absseclevel = 0 + \else + \ifnum \absseclevel > 3 + \absseclevel = 3 + \fi + \fi + % The heading type: + \def\headtype{#1}% + \if \headtype U% + \ifnum \absseclevel < \unnlevel + \chardef\unnlevel = \absseclevel + \fi + \else + % Check for appendix sections: + \ifnum \absseclevel = 0 + \edef\chapheadtype{\headtype}% + \else + \if \headtype A\if \chapheadtype N% + \errmessage{@appendix... within a non-appendix chapter}% + \fi\fi + \fi + % Check for numbered within unnumbered: + \ifnum \absseclevel > \unnlevel + \def\headtype{U}% + \else + \chardef\unnlevel = 3 + \fi + \fi + % Now print the heading: + \if \headtype U% + \ifcase\absseclevel + \unnumberedzzz{#3}% + \or \unnumberedseczzz{#3}% + \or \unnumberedsubseczzz{#3}% + \or \unnumberedsubsubseczzz{#3}% + \fi + \else + \if \headtype A% + \ifcase\absseclevel + \appendixzzz{#3}% + \or \appendixsectionzzz{#3}% + \or \appendixsubseczzz{#3}% + \or \appendixsubsubseczzz{#3}% + \fi + \else + \ifcase\absseclevel + \chapterzzz{#3}% + \or \seczzz{#3}% + \or \numberedsubseczzz{#3}% + \or \numberedsubsubseczzz{#3}% + \fi + \fi + \fi + \suppressfirstparagraphindent +} + +% an interface: +\def\numhead{\genhead N} +\def\apphead{\genhead A} +\def\unnmhead{\genhead U} + +% @chapter, @appendix, @unnumbered. Increment top-level counter, reset +% all lower-level sectioning counters to zero. +% +% Also set \chaplevelprefix, which we prepend to @float sequence numbers +% (e.g., figures), q.v. By default (before any chapter), that is empty. +\let\chaplevelprefix = \empty +% +\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz#1{% + % section resetting is \global in case the chapter is in a group, such + % as an @include file. + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\chapno by 1 + % + % Used for \float. + \gdef\chaplevelprefix{\the\chapno.}% + \resetallfloatnos + % + % \putwordChapter can contain complex things in translations. + \toks0=\expandafter{\putwordChapter}% + \message{\the\toks0 \space \the\chapno}% + % + % Write the actual heading. + \chapmacro{#1}{Ynumbered}{\the\chapno}% + % + % So @section and the like are numbered underneath this chapter. + \global\let\section = \numberedsec + \global\let\subsection = \numberedsubsec + \global\let\subsubsection = \numberedsubsubsec +} + +\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz +% +\def\appendixzzz#1{% + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\appendixno by 1 + \gdef\chaplevelprefix{\appendixletter.}% + \resetallfloatnos + % + % \putwordAppendix can contain complex things in translations. + \toks0=\expandafter{\putwordAppendix}% + \message{\the\toks0 \space \appendixletter}% + % + \chapmacro{#1}{Yappendix}{\appendixletter}% + % + \global\let\section = \appendixsec + \global\let\subsection = \appendixsubsec + \global\let\subsubsection = \appendixsubsubsec +} + +% normally unnmhead0 calls unnumberedzzz: +\outer\parseargdef\unnumbered{\unnmhead0{#1}} +\def\unnumberedzzz#1{% + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\unnumberedno by 1 + % + % Since an unnumbered has no number, no prefix for figures. + \global\let\chaplevelprefix = \empty + \resetallfloatnos + % + % This used to be simply \message{#1}, but TeX fully expands the + % argument to \message. Therefore, if #1 contained @-commands, TeX + % expanded them. For example, in `@unnumbered The @cite{Book}', TeX + % expanded @cite (which turns out to cause errors because \cite is meant + % to be executed, not expanded). + % + % Anyway, we don't want the fully-expanded definition of @cite to appear + % as a result of the \message, we just want `@cite' itself. We use + % \the to achieve this: TeX expands \the only once, + % simply yielding the contents of . (We also do this for + % the toc entries.) + \toks0 = {#1}% + \message{(\the\toks0)}% + % + \chapmacro{#1}{Ynothing}{\the\unnumberedno}% + % + \global\let\section = \unnumberedsec + \global\let\subsection = \unnumberedsubsec + \global\let\subsubsection = \unnumberedsubsubsec +} + +% @centerchap is like @unnumbered, but the heading is centered. +\outer\parseargdef\centerchap{% + % Well, we could do the following in a group, but that would break + % an assumption that \chapmacro is called at the outermost level. + % Thus we are safer this way: --kasal, 24feb04 + \let\centerparametersmaybe = \centerparameters + \unnmhead0{#1}% + \let\centerparametersmaybe = \relax +} + +% @top is like @unnumbered. +\let\top\unnumbered + +% Sections. +% +\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz +\def\seczzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% +} + +% normally calls appendixsectionzzz: +\outer\parseargdef\appendixsection{\apphead1{#1}} +\def\appendixsectionzzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% +} +\let\appendixsec\appendixsection + +% normally calls unnumberedseczzz: +\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} +\def\unnumberedseczzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% +} + +% Subsections. +% +% normally calls numberedsubseczzz: +\outer\parseargdef\numberedsubsec{\numhead2{#1}} +\def\numberedsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% +} + +% normally calls appendixsubseczzz: +\outer\parseargdef\appendixsubsec{\apphead2{#1}} +\def\appendixsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Yappendix}% + {\appendixletter.\the\secno.\the\subsecno}% +} + +% normally calls unnumberedsubseczzz: +\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} +\def\unnumberedsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Ynothing}% + {\the\unnumberedno.\the\secno.\the\subsecno}% +} + +% Subsubsections. +% +% normally numberedsubsubseczzz: +\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} +\def\numberedsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Ynumbered}% + {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% +} + +% normally appendixsubsubseczzz: +\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} +\def\appendixsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Yappendix}% + {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% +} + +% normally unnumberedsubsubseczzz: +\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} +\def\unnumberedsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Ynothing}% + {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% +} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\let\section = \numberedsec +\let\subsection = \numberedsubsec +\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +\def\majorheading{% + {\advance\chapheadingskip by 10pt \chapbreak }% + \parsearg\chapheadingzzz +} + +\def\chapheading{\chapbreak \parsearg\chapheadingzzz} +\def\chapheadingzzz#1{% + \vbox{\chapfonts \raggedtitlesettings #1\par}% + \nobreak\bigskip \nobreak + \suppressfirstparagraphindent +} + +% @heading, @subheading, @subsubheading. +\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} +\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} +\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +% Parameter controlling skip before chapter headings (if needed) +\newskip\chapheadingskip + +% Define plain chapter starts, and page on/off switching for it. +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +% Because \domark is called before \chapoddpage, the filler page will +% get the headings for the next chapter, which is wrong. But we don't +% care -- we just disable all headings on the filler page. +\def\chapoddpage{% + \chappager + \ifodd\pageno \else + \begingroup + \headingsoff + \null + \chappager + \endgroup + \fi +} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{% +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{% +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{% +\global\let\contentsalignmacro = \chapoddpage +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +% Chapter opening. +% +% #1 is the text, #2 is the section type (Ynumbered, Ynothing, +% Yappendix, Yomitfromtoc), #3 the chapter number. +% +% To test against our argument. +\def\Ynothingkeyword{Ynothing} +\def\Yomitfromtockeyword{Yomitfromtoc} +\def\Yappendixkeyword{Yappendix} +% +\def\chapmacro#1#2#3{% + % Insert the first mark before the heading break (see notes for \domark). + \let\prevchapterdefs=\lastchapterdefs + \let\prevsectiondefs=\lastsectiondefs + \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% + \gdef\thissection{}}% + % + \def\temptype{#2}% + \ifx\temptype\Ynothingkeyword + \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% + \gdef\thischapter{\thischaptername}}% + \else\ifx\temptype\Yomitfromtockeyword + \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% + \gdef\thischapter{}}% + \else\ifx\temptype\Yappendixkeyword + \toks0={#1}% + \xdef\lastchapterdefs{% + \gdef\noexpand\thischaptername{\the\toks0}% + \gdef\noexpand\thischapternum{\appendixletter}% + % \noexpand\putwordAppendix avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} + \noexpand\thischapternum: + \noexpand\thischaptername}% + }% + \else + \toks0={#1}% + \xdef\lastchapterdefs{% + \gdef\noexpand\thischaptername{\the\toks0}% + \gdef\noexpand\thischapternum{\the\chapno}% + % \noexpand\putwordChapter avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thischapter{\noexpand\putwordChapter{} + \noexpand\thischapternum: + \noexpand\thischaptername}% + }% + \fi\fi\fi + % + % Output the mark. Pass it through \safewhatsit, to take care of + % the preceding space. + \safewhatsit\domark + % + % Insert the chapter heading break. + \pchapsepmacro + % + % Now the second mark, after the heading break. No break points + % between here and the heading. + \let\prevchapterdefs=\lastchapterdefs + \let\prevsectiondefs=\lastsectiondefs + \domark + % + {% + \chapfonts \rmisbold + % + % Have to define \lastsection before calling \donoderef, because the + % xref code eventually uses it. On the other hand, it has to be called + % after \pchapsepmacro, or the headline will change too soon. + \gdef\lastsection{#1}% + % + % Only insert the separating space if we have a chapter/appendix + % number, and don't print the unnumbered ``number''. + \ifx\temptype\Ynothingkeyword + \setbox0 = \hbox{}% + \def\toctype{unnchap}% + \else\ifx\temptype\Yomitfromtockeyword + \setbox0 = \hbox{}% contents like unnumbered, but no toc entry + \def\toctype{omit}% + \else\ifx\temptype\Yappendixkeyword + \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% + \def\toctype{app}% + \else + \setbox0 = \hbox{#3\enspace}% + \def\toctype{numchap}% + \fi\fi\fi + % + % Write the toc entry for this chapter. Must come before the + % \donoderef, because we include the current node name in the toc + % entry, and \donoderef resets it to empty. + \writetocentry{\toctype}{#1}{#3}% + % + % For pdftex, we have to write out the node definition (aka, make + % the pdfdest) after any page break, but before the actual text has + % been typeset. If the destination for the pdf outline is after the + % text, then jumping from the outline may wind up with the text not + % being visible, for instance under high magnification. + \donoderef{#2}% + % + % Typeset the actual heading. + \nobreak % Avoid page breaks at the interline glue. + \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe + \unhbox0 #1\par}% + }% + \nobreak\bigskip % no page break after a chapter title + \nobreak +} + +% @centerchap -- centered and unnumbered. +\let\centerparametersmaybe = \relax +\def\centerparameters{% + \advance\rightskip by 3\rightskip + \leftskip = \rightskip + \parfillskip = 0pt +} + + +% I don't think this chapter style is supported any more, so I'm not +% updating it with the new noderef stuff. We'll see. --karl, 11aug03. +% +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} +% +\def\unnchfopen #1{% + \chapoddpage + \vbox{\chapfonts \raggedtitlesettings #1\par}% + \nobreak\bigskip\nobreak +} +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} +\def\centerchfopen #1{% + \chapoddpage + \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}% + \nobreak\bigskip \nobreak +} +\def\CHAPFopen{% + \global\let\chapmacro=\chfopen + \global\let\centerchapmacro=\centerchfopen} + + +% Section titles. These macros combine the section number parts and +% call the generic \sectionheading to do the printing. +% +\newskip\secheadingskip +\def\secheadingbreak{\dobreak \secheadingskip{-1000}} + +% Subsection titles. +\newskip\subsecheadingskip +\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} + +% Subsubsection titles. +\def\subsubsecheadingskip{\subsecheadingskip} +\def\subsubsecheadingbreak{\subsecheadingbreak} + + +% Print any size, any type, section title. +% +% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is +% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the +% section number. +% +\def\seckeyword{sec} +% +\def\sectionheading#1#2#3#4{% + {% + \checkenv{}% should not be in an environment. + % + % Switch to the right set of fonts. + \csname #2fonts\endcsname \rmisbold + % + \def\sectionlevel{#2}% + \def\temptype{#3}% + % + % Insert first mark before the heading break (see notes for \domark). + \let\prevsectiondefs=\lastsectiondefs + \ifx\temptype\Ynothingkeyword + \ifx\sectionlevel\seckeyword + \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% + \gdef\thissection{\thissectionname}}% + \fi + \else\ifx\temptype\Yomitfromtockeyword + % Don't redefine \thissection. + \else\ifx\temptype\Yappendixkeyword + \ifx\sectionlevel\seckeyword + \toks0={#1}% + \xdef\lastsectiondefs{% + \gdef\noexpand\thissectionname{\the\toks0}% + \gdef\noexpand\thissectionnum{#4}% + % \noexpand\putwordSection avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thissection{\noexpand\putwordSection{} + \noexpand\thissectionnum: + \noexpand\thissectionname}% + }% + \fi + \else + \ifx\sectionlevel\seckeyword + \toks0={#1}% + \xdef\lastsectiondefs{% + \gdef\noexpand\thissectionname{\the\toks0}% + \gdef\noexpand\thissectionnum{#4}% + % \noexpand\putwordSection avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thissection{\noexpand\putwordSection{} + \noexpand\thissectionnum: + \noexpand\thissectionname}% + }% + \fi + \fi\fi\fi + % + % Go into vertical mode. Usually we'll already be there, but we + % don't want the following whatsit to end up in a preceding paragraph + % if the document didn't happen to have a blank line. + \par + % + % Output the mark. Pass it through \safewhatsit, to take care of + % the preceding space. + \safewhatsit\domark + % + % Insert space above the heading. + \csname #2headingbreak\endcsname + % + % Now the second mark, after the heading break. No break points + % between here and the heading. + \let\prevsectiondefs=\lastsectiondefs + \domark + % + % Only insert the space after the number if we have a section number. + \ifx\temptype\Ynothingkeyword + \setbox0 = \hbox{}% + \def\toctype{unn}% + \gdef\lastsection{#1}% + \else\ifx\temptype\Yomitfromtockeyword + % for @headings -- no section number, don't include in toc, + % and don't redefine \lastsection. + \setbox0 = \hbox{}% + \def\toctype{omit}% + \let\sectionlevel=\empty + \else\ifx\temptype\Yappendixkeyword + \setbox0 = \hbox{#4\enspace}% + \def\toctype{app}% + \gdef\lastsection{#1}% + \else + \setbox0 = \hbox{#4\enspace}% + \def\toctype{num}% + \gdef\lastsection{#1}% + \fi\fi\fi + % + % Write the toc entry (before \donoderef). See comments in \chapmacro. + \writetocentry{\toctype\sectionlevel}{#1}{#4}% + % + % Write the node reference (= pdf destination for pdftex). + % Again, see comments in \chapmacro. + \donoderef{#3}% + % + % Interline glue will be inserted when the vbox is completed. + % That glue will be a valid breakpoint for the page, since it'll be + % preceded by a whatsit (usually from the \donoderef, or from the + % \writetocentry if there was no node). We don't want to allow that + % break, since then the whatsits could end up on page n while the + % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. + \nobreak + % + % Output the actual section heading. + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright + \hangindent=\wd0 % zero if no section number + \unhbox0 #1}% + }% + % Add extra space after the heading -- half of whatever came above it. + % Don't allow stretch, though. + \kern .5 \csname #2headingskip\endcsname + % + % Do not let the kern be a potential breakpoint, as it would be if it + % was followed by glue. + \nobreak + % + % We'll almost certainly start a paragraph next, so don't let that + % glue accumulate. (Not a breakpoint because it's preceded by a + % discardable item.) However, when a paragraph is not started next + % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out + % or the negative glue will cause weirdly wrong output, typically + % obscuring the section heading with something else. + \vskip-\parskip + % + % This is so the last item on the main vertical list is a known + % \penalty > 10000, so \startdefun, etc., can recognize the situation + % and do the needful. + \penalty 10001 +} + + +\message{toc,} +% Table of contents. +\newwrite\tocfile + +% Write an entry to the toc file, opening it if necessary. +% Called from @chapter, etc. +% +% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} +% We append the current node name (if any) and page number as additional +% arguments for the \{chap,sec,...}entry macros which will eventually +% read this. The node name is used in the pdf outlines as the +% destination to jump to. +% +% We open the .toc file for writing here instead of at @setfilename (or +% any other fixed time) so that @contents can be anywhere in the document. +% But if #1 is `omit', then we don't do anything. This is used for the +% table of contents chapter openings themselves. +% +\newif\iftocfileopened +\def\omitkeyword{omit}% +% +\def\writetocentry#1#2#3{% + \edef\writetoctype{#1}% + \ifx\writetoctype\omitkeyword \else + \iftocfileopened\else + \immediate\openout\tocfile = \jobname.toc + \global\tocfileopenedtrue + \fi + % + \iflinks + {\atdummies + \edef\temp{% + \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% + \temp + }% + \fi + \fi + % + % Tell \shipout to create a pdf destination on each page, if we're + % writing pdf. These are used in the table of contents. We can't + % just write one on every page because the title pages are numbered + % 1 and 2 (the page numbers aren't printed), and so are the first + % two pages of the document. Thus, we'd have two destinations named + % `1', and two named `2'. + \ifpdf \global\pdfmakepagedesttrue \fi +} + + +% These characters do not print properly in the Computer Modern roman +% fonts, so we must take special care. This is more or less redundant +% with the Texinfo input format setup at the end of this file. +% +\def\activecatcodes{% + \catcode`\"=\active + \catcode`\$=\active + \catcode`\<=\active + \catcode`\>=\active + \catcode`\\=\active + \catcode`\^=\active + \catcode`\_=\active + \catcode`\|=\active + \catcode`\~=\active +} + + +% Read the toc file, which is essentially Texinfo input. +\def\readtocfile{% + \setupdatafile + \activecatcodes + \input \tocreadfilename +} + +\newskip\contentsrightmargin \contentsrightmargin=1in +\newcount\savepageno +\newcount\lastnegativepageno \lastnegativepageno = -1 + +% Prepare to read what we've written to \tocfile. +% +\def\startcontents#1{% + % If @setchapternewpage on, and @headings double, the contents should + % start on an odd page, unlike chapters. Thus, we maintain + % \contentsalignmacro in parallel with \pagealignmacro. + % From: Torbjorn Granlund + \contentsalignmacro + \immediate\closeout\tocfile + % + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \chapmacro{#1}{Yomitfromtoc}{}% + % + \savepageno = \pageno + \begingroup % Set up to handle contents files properly. + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. + % + % Roman numerals for page numbers. + \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi +} + +% redefined for the two-volume lispref. We always output on +% \jobname.toc even if this is redefined. +% +\def\tocreadfilename{\jobname.toc} + +% Normal (long) toc. +% +\def\contents{% + \startcontents{\putwordTOC}% + \openin 1 \tocreadfilename\space + \ifeof 1 \else + \readtocfile + \fi + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \ifeof 1 \else + \pdfmakeoutlines + \fi + \closein 1 + \endgroup + \lastnegativepageno = \pageno + \global\pageno = \savepageno +} + +% And just the chapters. +\def\summarycontents{% + \startcontents{\putwordShortTOC}% + % + \let\partentry = \shortpartentry + \let\numchapentry = \shortchapentry + \let\appentry = \shortchapentry + \let\unnchapentry = \shortunnchapentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf + \let\sl=\shortcontsl \let\tt=\shortconttt + \rm + \hyphenpenalty = 10000 + \advance\baselineskip by 1pt % Open it up a little. + \def\numsecentry##1##2##3##4{} + \let\appsecentry = \numsecentry + \let\unnsecentry = \numsecentry + \let\numsubsecentry = \numsecentry + \let\appsubsecentry = \numsecentry + \let\unnsubsecentry = \numsecentry + \let\numsubsubsecentry = \numsecentry + \let\appsubsubsecentry = \numsecentry + \let\unnsubsubsecentry = \numsecentry + \openin 1 \tocreadfilename\space + \ifeof 1 \else + \readtocfile + \fi + \closein 1 + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \endgroup + \lastnegativepageno = \pageno + \global\pageno = \savepageno +} +\let\shortcontents = \summarycontents + +% Typeset the label for a chapter or appendix for the short contents. +% The arg is, e.g., `A' for an appendix, or `3' for a chapter. +% +\def\shortchaplabel#1{% + % This space should be enough, since a single number is .5em, and the + % widest letter (M) is 1em, at least in the Computer Modern fonts. + % But use \hss just in case. + % (This space doesn't include the extra space that gets added after + % the label; that gets put in by \shortchapentry above.) + % + % We'd like to right-justify chapter numbers, but that looks strange + % with appendix letters. And right-justifying numbers and + % left-justifying letters looks strange when there is less than 10 + % chapters. Have to read the whole toc once to know how many chapters + % there are before deciding ... + \hbox to 1em{#1\hss}% +} + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Parts, in the main contents. Replace the part number, which doesn't +% exist, with an empty box. Let's hope all the numbers have the same width. +% Also ignore the page number, which is conventionally not printed. +\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} +\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} +% +% Parts, in the short toc. +\def\shortpartentry#1#2#3#4{% + \penalty-300 + \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip + \shortchapentry{{\bf #1}}{\numeralbox}{}{}% +} + +% Chapters, in the main contents. +\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} +% +% Chapters, in the short toc. +% See comments in \dochapentry re vbox and related settings. +\def\shortchapentry#1#2#3#4{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% +} + +% Appendices, in the main contents. +% Need the word Appendix, and a fixed-size box. +% +\def\appendixbox#1{% + % We use M since it's probably the widest letter. + \setbox0 = \hbox{\putwordAppendix{} M}% + \hbox to \wd0{\putwordAppendix{} #1\hss}} +% +\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} + +% Unnumbered chapters. +\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} +\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} + +% Sections. +\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} +\let\appsecentry=\numsecentry +\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} + +% Subsections. +\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} +\let\appsubsecentry=\numsubsecentry +\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} + +% And subsubsections. +\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} +\let\appsubsubsecentry=\numsubsubsecentry +\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} + +% This parameter controls the indentation of the various levels. +% Same as \defaultparindent. +\newdimen\tocindent \tocindent = 15pt + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we want it to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno\bgroup#2\egroup}% + \endgroup + \nobreak\vskip .25\baselineskip plus.1\baselineskip +} + +\def\dosecentry#1#2{\begingroup + \secentryfonts \leftskip=\tocindent + \tocentry{#1}{\dopageno\bgroup#2\egroup}% +\endgroup} + +\def\dosubsecentry#1#2{\begingroup + \subsecentryfonts \leftskip=2\tocindent + \tocentry{#1}{\dopageno\bgroup#2\egroup}% +\endgroup} + +\def\dosubsubsecentry#1#2{\begingroup + \subsubsecentryfonts \leftskip=3\tocindent + \tocentry{#1}{\dopageno\bgroup#2\egroup}% +\endgroup} + +% We use the same \entry macro as for the index entries. +\let\tocentry = \entry + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\def\subsecentryfonts{\textfonts} +\def\subsubsecentryfonts{\textfonts} + + +\message{environments,} +% @foo ... @end foo. + +% @tex ... @end tex escapes into raw TeX temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain @ character. + +\envdef\tex{% + \setupmarkupstyle{tex}% + \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 + \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 + \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie + \catcode `\%=14 + \catcode `\+=\other + \catcode `\"=\other + \catcode `\|=\other + \catcode `\<=\other + \catcode `\>=\other + \catcode`\`=\other + \catcode`\'=\other + \escapechar=`\\ + % + % ' is active in math mode (mathcode"8000). So reset it, and all our + % other math active characters (just in case), to plain's definitions. + \mathactive + % + \let\b=\ptexb + \let\bullet=\ptexbullet + \let\c=\ptexc + \let\,=\ptexcomma + \let\.=\ptexdot + \let\dots=\ptexdots + \let\equiv=\ptexequiv + \let\!=\ptexexclam + \let\i=\ptexi + \let\indent=\ptexindent + \let\noindent=\ptexnoindent + \let\{=\ptexlbrace + \let\+=\tabalign + \let\}=\ptexrbrace + \let\/=\ptexslash + \let\*=\ptexstar + \let\t=\ptext + \expandafter \let\csname top\endcsname=\ptextop % outer + \let\frenchspacing=\plainfrenchspacing + % + \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% + \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% + \def\@{@}% +} +% There is no need to define \Etex. + +% Define @lisp ... @end lisp. +% @lisp environment forms a group so it can rebind things, +% including the definition of @end lisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^^M gets inside @lisp, @example, and other +% such environments. \null is better than a space, since it doesn't +% have any width. +\def\lisppar{\null\endgraf} + +% This space is always present above and below environments. +\newskip\envskipamount \envskipamount = 0pt + +% Make spacing and below environment symmetrical. We use \parskip here +% to help in doing that, since in @example-like environments \parskip +% is reset to zero; thus the \afterenvbreak inserts no space -- but the +% start of the next paragraph will insert \parskip. +% +\def\aboveenvbreak{{% + % =10000 instead of <10000 because of a special case in \itemzzz and + % \sectionheading, q.v. + \ifnum \lastpenalty=10000 \else + \advance\envskipamount by \parskip + \endgraf + \ifdim\lastskip<\envskipamount + \removelastskip + % it's not a good place to break if the last penalty was \nobreak + % or better ... + \ifnum\lastpenalty<10000 \penalty-50 \fi + \vskip\envskipamount + \fi + \fi +}} + +\let\afterenvbreak = \aboveenvbreak + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will +% also clear it, so that its embedded environments do the narrowing again. +\let\nonarrowing=\relax + +% @cartouche ... @end cartouche: draw rectangle w/rounded corners around +% environment contents. +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\envdef\cartouche{% + \ifhmode\par\fi % can't be in the midst of a paragraph. + \startsavinginserts + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt % we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18.4pt % allow for 3pt kerns on either + % side, and for 6pt waste from + % each corner char, and rule thickness + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing = t% + % + % If this cartouche directly follows a sectioning command, we need the + % \parskip glue (backspaced over by default) or the cartouche can + % collide with the section heading. + \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi + % + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \kern3pt + \hsize=\cartinner + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip + \comment % For explanation, see the end of def\group. +} +\def\Ecartouche{% + \ifhmode\par\fi + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup + \checkinserts +} + + +% This macro is called at the beginning of all the @example variants, +% inside a group. +\newdimen\nonfillparindent +\def\nonfillstart{% + \aboveenvbreak + \hfuzz = 12pt % Don't be fussy + \sepspaces % Make spaces be word-separators rather than space tokens. + \let\par = \lisppar % don't ignore blank lines + \obeylines % each line of input is a line of output + \parskip = 0pt + % Turn off paragraph indentation but redefine \indent to emulate + % the normal \indent. + \nonfillparindent=\parindent + \parindent = 0pt + \let\indent\nonfillindent + % + \emergencystretch = 0pt % don't try to avoid overfull boxes + \ifx\nonarrowing\relax + \advance \leftskip by \lispnarrowing + \exdentamount=\lispnarrowing + \else + \let\nonarrowing = \relax + \fi + \let\exdent=\nofillexdent +} + +\begingroup +\obeyspaces +% We want to swallow spaces (but not other tokens) after the fake +% @indent in our nonfill-environments, where spaces are normally +% active and set to @tie, resulting in them not being ignored after +% @indent. +\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% +\gdef\nonfillindentcheck{% +\ifx\temp % +\expandafter\nonfillindentgobble% +\else% +\leavevmode\nonfillindentbox% +\fi% +}% +\endgroup +\def\nonfillindentgobble#1{\nonfillindent} +\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} + +% If you want all examples etc. small: @set dispenvsize small. +% If you want even small examples the full size: @set dispenvsize nosmall. +% This affects the following displayed environments: +% @example, @display, @format, @lisp +% +\def\smallword{small} +\def\nosmallword{nosmall} +\let\SETdispenvsize\relax +\def\setnormaldispenv{% + \ifx\SETdispenvsize\smallword + % end paragraph for sake of leading, in case document has no blank + % line. This is redundant with what happens in \aboveenvbreak, but + % we need to do it before changing the fonts, and it's inconvenient + % to change the fonts afterward. + \ifnum \lastpenalty=10000 \else \endgraf \fi + \smallexamplefonts \rm + \fi +} +\def\setsmalldispenv{% + \ifx\SETdispenvsize\nosmallword + \else + \ifnum \lastpenalty=10000 \else \endgraf \fi + \smallexamplefonts \rm + \fi +} + +% We often define two environments, @foo and @smallfoo. +% Let's do it in one command. #1 is the env name, #2 the definition. +\def\makedispenvdef#1#2{% + \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% + \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% + \expandafter\let\csname E#1\endcsname \afterenvbreak + \expandafter\let\csname Esmall#1\endcsname \afterenvbreak +} + +% Define two environment synonyms (#1 and #2) for an environment. +\def\maketwodispenvdef#1#2#3{% + \makedispenvdef{#1}{#3}% + \makedispenvdef{#2}{#3}% +} +% +% @lisp: indented, narrowed, typewriter font; +% @example: same as @lisp. +% +% @smallexample and @smalllisp: use smaller fonts. +% Originally contributed by Pavel@xerox. +% +\maketwodispenvdef{lisp}{example}{% + \nonfillstart + \tt\setupmarkupstyle{example}% + \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. + \gobble % eat return +} +% @display/@smalldisplay: same as @lisp except keep current font. +% +\makedispenvdef{display}{% + \nonfillstart + \gobble +} + +% @format/@smallformat: same as @display except don't narrow margins. +% +\makedispenvdef{format}{% + \let\nonarrowing = t% + \nonfillstart + \gobble +} + +% @flushleft: same as @format, but doesn't obey \SETdispenvsize. +\envdef\flushleft{% + \let\nonarrowing = t% + \nonfillstart + \gobble +} +\let\Eflushleft = \afterenvbreak + +% @flushright. +% +\envdef\flushright{% + \let\nonarrowing = t% + \nonfillstart + \advance\leftskip by 0pt plus 1fill\relax + \gobble +} +\let\Eflushright = \afterenvbreak + + +% @raggedright does more-or-less normal line breaking but no right +% justification. From plain.tex. +\envdef\raggedright{% + \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax +} +\let\Eraggedright\par + +\envdef\raggedleft{% + \parindent=0pt \leftskip0pt plus2em + \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt + \hbadness=10000 % Last line will usually be underfull, so turn off + % badness reporting. +} +\let\Eraggedleft\par + +\envdef\raggedcenter{% + \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em + \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt + \hbadness=10000 % Last line will usually be underfull, so turn off + % badness reporting. +} +\let\Eraggedcenter\par + + +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. We keep \parskip nonzero in general, since +% we're doing normal filling. So, when using \aboveenvbreak and +% \afterenvbreak, temporarily make \parskip 0. +% +\makedispenvdef{quotation}{\quotationstart} +% +\def\quotationstart{% + \indentedblockstart % same as \indentedblock, but increase right margin too. + \ifx\nonarrowing\relax + \advance\rightskip by \lispnarrowing + \fi + \parsearg\quotationlabel +} + +% We have retained a nonzero parskip for the environment, since we're +% doing normal filling. +% +\def\Equotation{% + \par + \ifx\quotationauthor\thisisundefined\else + % indent a bit. + \leftline{\kern 2\leftskip \sl ---\quotationauthor}% + \fi + {\parskip=0pt \afterenvbreak}% +} +\def\Esmallquotation{\Equotation} + +% If we're given an argument, typeset it in bold with a colon after. +\def\quotationlabel#1{% + \def\temp{#1}% + \ifx\temp\empty \else + {\bf #1: }% + \fi +} + +% @indentedblock is like @quotation, but indents only on the left and +% has no optional argument. +% +\makedispenvdef{indentedblock}{\indentedblockstart} +% +\def\indentedblockstart{% + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \parindent=0pt + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \exdentamount = \lispnarrowing + \else + \let\nonarrowing = \relax + \fi +} + +% Keep a nonzero parskip for the environment, since we're doing normal filling. +% +\def\Eindentedblock{% + \par + {\parskip=0pt \afterenvbreak}% +} +\def\Esmallindentedblock{\Eindentedblock} + + +% LaTeX-like @verbatim...@end verbatim and @verb{...} +% If we want to allow any as delimiter, +% we need the curly braces so that makeinfo sees the @verb command, eg: +% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org +% +% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. +% +% [Knuth] p.344; only we need to do the other characters Texinfo sets +% active too. Otherwise, they get lost as the first character on a +% verbatim line. +\def\dospecials{% + \do\ \do\\\do\{\do\}\do\$\do\&% + \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% + \do\<\do\>\do\|\do\@\do+\do\"% + % Don't do the quotes -- if we do, @set txicodequoteundirected and + % @set txicodequotebacktick will not have effect on @verb and + % @verbatim, and ?` and !` ligatures won't get disabled. + %\do\`\do\'% +} +% +% [Knuth] p. 380 +\def\uncatcodespecials{% + \def\do##1{\catcode`##1=\other}\dospecials} +% +% Setup for the @verb command. +% +% Eight spaces for a tab +\begingroup + \catcode`\^^I=\active + \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} +\endgroup +% +\def\setupverb{% + \tt % easiest (and conventionally used) font for verbatim + \def\par{\leavevmode\endgraf}% + \setupmarkupstyle{verb}% + \tabeightspaces + % Respect line breaks, + % print special symbols as themselves, and + % make each space count + % must do in this order: + \obeylines \uncatcodespecials \sepspaces +} + +% Setup for the @verbatim environment +% +% Real tab expansion. +\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount +% +% We typeset each line of the verbatim in an \hbox, so we can handle +% tabs. The \global is in case the verbatim line starts with an accent, +% or some other command that starts with a begin-group. Otherwise, the +% entire \verbbox would disappear at the corresponding end-group, before +% it is typeset. Meanwhile, we can't have nested verbatim commands +% (can we?), so the \global won't be overwriting itself. +\newbox\verbbox +\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} +% +\begingroup + \catcode`\^^I=\active + \gdef\tabexpand{% + \catcode`\^^I=\active + \def^^I{\leavevmode\egroup + \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab + \divide\dimen\verbbox by\tabw + \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw + \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw + \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox + }% + } +\endgroup + +% start the verbatim environment. +\def\setupverbatim{% + \let\nonarrowing = t% + \nonfillstart + \tt % easiest (and conventionally used) font for verbatim + % The \leavevmode here is for blank lines. Otherwise, we would + % never \starttabox and the \egroup would end verbatim mode. + \def\par{\leavevmode\egroup\box\verbbox\endgraf}% + \tabexpand + \setupmarkupstyle{verbatim}% + % Respect line breaks, + % print special symbols as themselves, and + % make each space count. + % Must do in this order: + \obeylines \uncatcodespecials \sepspaces + \everypar{\starttabbox}% +} + +% Do the @verb magic: verbatim text is quoted by unique +% delimiter characters. Before first delimiter expect a +% right brace, after last delimiter expect closing brace: +% +% \def\doverb'{'#1'}'{#1} +% +% [Knuth] p. 382; only eat outer {} +\begingroup + \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other + \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] +\endgroup +% +\def\verb{\begingroup\setupverb\doverb} +% +% +% Do the @verbatim magic: define the macro \doverbatim so that +% the (first) argument ends when '@end verbatim' is reached, ie: +% +% \def\doverbatim#1@end verbatim{#1} +% +% For Texinfo it's a lot easier than for LaTeX, +% because texinfo's \verbatim doesn't stop at '\end{verbatim}': +% we need not redefine '\', '{' and '}'. +% +% Inspired by LaTeX's verbatim command set [latex.ltx] +% +\begingroup + \catcode`\ =\active + \obeylines % + % ignore everything up to the first ^^M, that's the newline at the end + % of the @verbatim input line itself. Otherwise we get an extra blank + % line in the output. + \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% + % We really want {...\end verbatim} in the body of the macro, but + % without the active space; thus we have to use \xdef and \gobble. +\endgroup +% +\envdef\verbatim{% + \setupverbatim\doverbatim +} +\let\Everbatim = \afterenvbreak + + +% @verbatiminclude FILE - insert text of file in verbatim environment. +% +\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} +% +\def\doverbatiminclude#1{% + {% + \makevalueexpandable + \setupverbatim + \indexnofonts % Allow `@@' and other weird things in file names. + \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% + \input #1 + \afterenvbreak + }% +} + +% @copying ... @end copying. +% Save the text away for @insertcopying later. +% +% We save the uninterpreted tokens, rather than creating a box. +% Saving the text in a box would be much easier, but then all the +% typesetting commands (@smallbook, font changes, etc.) have to be done +% beforehand -- and a) we want @copying to be done first in the source +% file; b) letting users define the frontmatter in as flexible order as +% possible is very desirable. +% +\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} +\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} +% +\def\insertcopying{% + \begingroup + \parindent = 0pt % paragraph indentation looks wrong on title page + \scanexp\copyingtext + \endgroup +} + + +\message{defuns,} +% @defun etc. + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deflastargmargin \deflastargmargin=18pt +\newcount\defunpenalty + +% Start the processing of @deffn: +\def\startdefun{% + \ifnum\lastpenalty<10000 + \medbreak + \defunpenalty=10003 % Will keep this @deffn together with the + % following @def command, see below. + \else + % If there are two @def commands in a row, we'll have a \nobreak, + % which is there to keep the function description together with its + % header. But if there's nothing but headers, we need to allow a + % break somewhere. Check specifically for penalty 10002, inserted + % by \printdefunline, instead of 10000, since the sectioning + % commands also insert a nobreak penalty, and we don't want to allow + % a break between a section heading and a defun. + % + % As a further refinement, we avoid "club" headers by signalling + % with penalty of 10003 after the very first @deffn in the + % sequence (see above), and penalty of 10002 after any following + % @def command. + \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi + % + % Similarly, after a section heading, do not allow a break. + % But do insert the glue. + \medskip % preceded by discardable penalty, so not a breakpoint + \fi + % + \parindent=0in + \advance\leftskip by \defbodyindent + \exdentamount=\defbodyindent +} + +\def\dodefunx#1{% + % First, check whether we are in the right environment: + \checkenv#1% + % + % As above, allow line break if we have multiple x headers in a row. + % It's not a great place, though. + \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi + % + % And now, it's time to reuse the body of the original defun: + \expandafter\gobbledefun#1% +} +\def\gobbledefun#1\startdefun{} + +% \printdefunline \deffnheader{text} +% +\def\printdefunline#1#2{% + \begingroup + % call \deffnheader: + #1#2 \endheader + % common ending: + \interlinepenalty = 10000 + \advance\rightskip by 0pt plus 1fil\relax + \endgraf + \nobreak\vskip -\parskip + \penalty\defunpenalty % signal to \startdefun and \dodefunx + % Some of the @defun-type tags do not enable magic parentheses, + % rendering the following check redundant. But we don't optimize. + \checkparencounts + \endgroup +} + +\def\Edefun{\endgraf\medbreak} + +% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; +% the only thing remaining is to define \deffnheader. +% +\def\makedefun#1{% + \expandafter\let\csname E#1\endcsname = \Edefun + \edef\temp{\noexpand\domakedefun + \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% + \temp +} + +% \domakedefun \deffn \deffnx \deffnheader +% +% Define \deffn and \deffnx, without parameters. +% \deffnheader has to be defined explicitly. +% +\def\domakedefun#1#2#3{% + \envdef#1{% + \startdefun + \doingtypefnfalse % distinguish typed functions from all else + \parseargusing\activeparens{\printdefunline#3}% + }% + \def#2{\dodefunx#1}% + \def#3% +} + +\newif\ifdoingtypefn % doing typed function? +\newif\ifrettypeownline % typeset return type on its own line? + +% @deftypefnnewline on|off says whether the return type of typed functions +% are printed on their own line. This affects @deftypefn, @deftypefun, +% @deftypeop, and @deftypemethod. +% +\parseargdef\deftypefnnewline{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETtxideftypefnnl\endcsname + = \empty + \else\ifx\temp\offword + \expandafter\let\csname SETtxideftypefnnl\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @txideftypefnnl value `\temp', + must be on|off}% + \fi\fi +} + +% Untyped functions: + +% @deffn category name args +\makedefun{deffn}{\deffngeneral{}} + +% @deffn category class name args +\makedefun{defop}#1 {\defopon{#1\ \putwordon}} + +% \defopon {category on}class name args +\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } + +% \deffngeneral {subind}category name args +% +\def\deffngeneral#1#2 #3 #4\endheader{% + % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. + \dosubind{fn}{\code{#3}}{#1}% + \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% +} + +% Typed functions: + +% @deftypefn category type name args +\makedefun{deftypefn}{\deftypefngeneral{}} + +% @deftypeop category class type name args +\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} + +% \deftypeopon {category on}class type name args +\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } + +% \deftypefngeneral {subind}category type name args +% +\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% + \dosubind{fn}{\code{#4}}{#1}% + \doingtypefntrue + \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +} + +% Typed variables: + +% @deftypevr category type var args +\makedefun{deftypevr}{\deftypecvgeneral{}} + +% @deftypecv category class type var args +\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} + +% \deftypecvof {category of}class type var args +\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } + +% \deftypecvgeneral {subind}category type var args +% +\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% + \dosubind{vr}{\code{#4}}{#1}% + \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +} + +% Untyped variables: + +% @defvr category var args +\makedefun{defvr}#1 {\deftypevrheader{#1} {} } + +% @defcv category class var args +\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} + +% \defcvof {category of}class var args +\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } + +% Types: + +% @deftp category name args +\makedefun{deftp}#1 #2 #3\endheader{% + \doind{tp}{\code{#2}}% + \defname{#1}{}{#2}\defunargs{#3\unskip}% +} + +% Remaining @defun-like shortcuts: +\makedefun{defun}{\deffnheader{\putwordDeffunc} } +\makedefun{defmac}{\deffnheader{\putwordDefmac} } +\makedefun{defspec}{\deffnheader{\putwordDefspec} } +\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } +\makedefun{defvar}{\defvrheader{\putwordDefvar} } +\makedefun{defopt}{\defvrheader{\putwordDefopt} } +\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } +\makedefun{defmethod}{\defopon\putwordMethodon} +\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} +\makedefun{defivar}{\defcvof\putwordInstanceVariableof} +\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} + +% \defname, which formats the name of the @def (not the args). +% #1 is the category, such as "Function". +% #2 is the return type, if any. +% #3 is the function name. +% +% We are followed by (but not passed) the arguments, if any. +% +\def\defname#1#2#3{% + \par + % Get the values of \leftskip and \rightskip as they were outside the @def... + \advance\leftskip by -\defbodyindent + % + % Determine if we are typesetting the return type of a typed function + % on a line by itself. + \rettypeownlinefalse + \ifdoingtypefn % doing a typed function specifically? + % then check user option for putting return type on its own line: + \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else + \rettypeownlinetrue + \fi + \fi + % + % How we'll format the category name. Putting it in brackets helps + % distinguish it from the body text that may end up on the next line + % just below it. + \def\temp{#1}% + \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} + % + % Figure out line sizes for the paragraph shape. We'll always have at + % least two. + \tempnum = 2 + % + % The first line needs space for \box0; but if \rightskip is nonzero, + % we need only space for the part of \box0 which exceeds it: + \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip + % + % If doing a return type on its own line, we'll have another line. + \ifrettypeownline + \advance\tempnum by 1 + \def\maybeshapeline{0in \hsize}% + \else + \def\maybeshapeline{}% + \fi + % + % The continuations: + \dimen2=\hsize \advance\dimen2 by -\defargsindent + % + % The final paragraph shape: + \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 + % + % Put the category name at the right margin. + \noindent + \hbox to 0pt{% + \hfil\box0 \kern-\hsize + % \hsize has to be shortened this way: + \kern\leftskip + % Intentionally do not respect \rightskip, since we need the space. + }% + % + % Allow all lines to be underfull without complaint: + \tolerance=10000 \hbadness=10000 + \exdentamount=\defbodyindent + {% + % defun fonts. We use typewriter by default (used to be bold) because: + % . we're printing identifiers, they should be in tt in principle. + % . in languages with many accents, such as Czech or French, it's + % common to leave accents off identifiers. The result looks ok in + % tt, but exceedingly strange in rm. + % . we don't want -- and --- to be treated as ligatures. + % . this still does not fix the ?` and !` ligatures, but so far no + % one has made identifiers using them :). + \df \tt + \def\temp{#2}% text of the return type + \ifx\temp\empty\else + \tclose{\temp}% typeset the return type + \ifrettypeownline + % put return type on its own line; prohibit line break following: + \hfil\vadjust{\nobreak}\break + \else + \space % type on same line, so just followed by a space + \fi + \fi % no return type + #3% output function name + }% + {\rm\enskip}% hskip 0.5 em of \tenrm + % + \boldbrax + % arguments will be output next, if any. +} + +% Print arguments in slanted roman (not ttsl), inconsistently with using +% tt for the name. This is because literal text is sometimes needed in +% the argument list (groff manual), and ttsl and tt are not very +% distinguishable. Prevent hyphenation at `-' chars. +% +\def\defunargs#1{% + % use sl by default (not ttsl), + % tt for the names. + \df \sl \hyphenchar\font=0 + % + % On the other hand, if an argument has two dashes (for instance), we + % want a way to get ttsl. We used to recommend @var for that, so + % leave the code in, but it's strange for @var to lead to typewriter. + % Nowadays we recommend @code, since the difference between a ttsl hyphen + % and a tt hyphen is pretty tiny. @code also disables ?` !`. + \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% + #1% + \sl\hyphenchar\font=45 +} + +% We want ()&[] to print specially on the defun line. +% +\def\activeparens{% + \catcode`\(=\active \catcode`\)=\active + \catcode`\[=\active \catcode`\]=\active + \catcode`\&=\active +} + +% Make control sequences which act like normal parenthesis chars. +\let\lparen = ( \let\rparen = ) + +% Be sure that we always have a definition for `(', etc. For example, +% if the fn name has parens in it, \boldbrax will not be in effect yet, +% so TeX would otherwise complain about undefined control sequence. +{ + \activeparens + \global\let(=\lparen \global\let)=\rparen + \global\let[=\lbrack \global\let]=\rbrack + \global\let& = \& + + \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} + \gdef\magicamp{\let&=\amprm} +} + +\newcount\parencount + +% If we encounter &foo, then turn on ()-hacking afterwards +\newif\ifampseen +\def\amprm#1 {\ampseentrue{\bf\ }} + +\def\parenfont{% + \ifampseen + % At the first level, print parens in roman, + % otherwise use the default font. + \ifnum \parencount=1 \rm \fi + \else + % The \sf parens (in \boldbrax) actually are a little bolder than + % the contained text. This is especially needed for [ and ] . + \sf + \fi +} +\def\infirstlevel#1{% + \ifampseen + \ifnum\parencount=1 + #1% + \fi + \fi +} +\def\bfafterword#1 {#1 \bf} + +\def\opnr{% + \global\advance\parencount by 1 + {\parenfont(}% + \infirstlevel \bfafterword +} +\def\clnr{% + {\parenfont)}% + \infirstlevel \sl + \global\advance\parencount by -1 +} + +\newcount\brackcount +\def\lbrb{% + \global\advance\brackcount by 1 + {\bf[}% +} +\def\rbrb{% + {\bf]}% + \global\advance\brackcount by -1 +} + +\def\checkparencounts{% + \ifnum\parencount=0 \else \badparencount \fi + \ifnum\brackcount=0 \else \badbrackcount \fi +} +% these should not use \errmessage; the glibc manual, at least, actually +% has such constructs (when documenting function pointers). +\def\badparencount{% + \message{Warning: unbalanced parentheses in @def...}% + \global\parencount=0 +} +\def\badbrackcount{% + \message{Warning: unbalanced square brackets in @def...}% + \global\brackcount=0 +} + + +\message{macros,} +% @macro. + +% To do this right we need a feature of e-TeX, \scantokens, +% which we arrange to emulate with a temporary file in ordinary TeX. +\ifx\eTeXversion\thisisundefined + \newwrite\macscribble + \def\scantokens#1{% + \toks0={#1}% + \immediate\openout\macscribble=\jobname.tmp + \immediate\write\macscribble{\the\toks0}% + \immediate\closeout\macscribble + \input \jobname.tmp + } +\fi + +\def\scanmacro#1{\begingroup + \newlinechar`\^^M + \let\xeatspaces\eatspaces + % + % Undo catcode changes of \startcontents and \doprintindex + % When called from @insertcopying or (short)caption, we need active + % backslash to get it printed correctly. Previously, we had + % \catcode`\\=\other instead. We'll see whether a problem appears + % with macro expansion. --kasal, 19aug04 + \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ + % + % ... and for \example: + \spaceisspace + % + % The \empty here causes a following catcode 5 newline to be eaten as + % part of reading whitespace after a control sequence. It does not + % eat a catcode 13 newline. There's no good way to handle the two + % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX + % would then have different behavior). See the Macro Details node in + % the manual for the workaround we recommend for macros and + % line-oriented commands. + % + \scantokens{#1\empty}% +\endgroup} + +\def\scanexp#1{% + \edef\temp{\noexpand\scanmacro{#1}}% + \temp +} + +\newcount\paramno % Count of parameters +\newtoks\macname % Macro name +\newif\ifrecursive % Is it recursive? + +% List of all defined macros in the form +% \definedummyword\macro1\definedummyword\macro2... +% Currently is also contains all @aliases; the list can be split +% if there is a need. +\def\macrolist{} + +% Add the macro to \macrolist +\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} +\def\addtomacrolistxxx#1{% + \toks0 = \expandafter{\macrolist\definedummyword#1}% + \xdef\macrolist{\the\toks0}% +} + +% Utility routines. +% This does \let #1 = #2, with \csnames; that is, +% \let \csname#1\endcsname = \csname#2\endcsname +% (except of course we have to play expansion games). +% +\def\cslet#1#2{% + \expandafter\let + \csname#1\expandafter\endcsname + \csname#2\endcsname +} + +% Trim leading and trailing spaces off a string. +% Concepts from aro-bend problem 15 (see CTAN). +{\catcode`\@=11 +\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} +\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} +\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} +\def\unbrace#1{#1} +\unbrace{\gdef\trim@@@ #1 } #2@{#1} +} + +% Trim a single trailing ^^M off a string. +{\catcode`\^^M=\other \catcode`\Q=3% +\gdef\eatcr #1{\eatcra #1Q^^MQ}% +\gdef\eatcra#1^^MQ{\eatcrb#1Q}% +\gdef\eatcrb#1Q#2Q{#1}% +} + +% Macro bodies are absorbed as an argument in a context where +% all characters are catcode 10, 11 or 12, except \ which is active +% (as in normal texinfo). It is necessary to change the definition of \ +% to recognize macro arguments; this is the job of \mbodybackslash. +% +% Non-ASCII encodings make 8-bit characters active, so un-activate +% them to avoid their expansion. Must do this non-globally, to +% confine the change to the current group. +% +% It's necessary to have hard CRs when the macro is executed. This is +% done by making ^^M (\endlinechar) catcode 12 when reading the macro +% body, and then making it the \newlinechar in \scanmacro. +% +\def\scanctxt{% used as subroutine + \catcode`\"=\other + \catcode`\+=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\@=\other + \catcode`\^=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\~=\other + \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi +} + +\def\scanargctxt{% used for copying and captions, not macros. + \scanctxt + \catcode`\\=\other + \catcode`\^^M=\other +} + +\def\macrobodyctxt{% used for @macro definitions + \scanctxt + \catcode`\{=\other + \catcode`\}=\other + \catcode`\^^M=\other + \usembodybackslash +} + +\def\macroargctxt{% used when scanning invocations + \scanctxt + \catcode`\\=0 +} +% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes" +% for the single characters \ { }. Thus, we end up with the "commands" +% that would be written @\ @{ @} in a Texinfo document. +% +% We already have @{ and @}. For @\, we define it here, and only for +% this purpose, to produce a typewriter backslash (so, the @\ that we +% define for @math can't be used with @macro calls): +% +\def\\{\normalbackslash}% +% +% We would like to do this for \, too, since that is what makeinfo does. +% But it is not possible, because Texinfo already has a command @, for a +% cedilla accent. Documents must use @comma{} instead. +% +% \anythingelse will almost certainly be an error of some kind. + + +% \mbodybackslash is the definition of \ in @macro bodies. +% It maps \foo\ => \csname macarg.foo\endcsname => #N +% where N is the macro parameter number. +% We define \csname macarg.\endcsname to be \realbackslash, so +% \\ in macro replacement text gets you a backslash. +% +{\catcode`@=0 @catcode`@\=@active + @gdef@usembodybackslash{@let\=@mbodybackslash} + @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} +} +\expandafter\def\csname macarg.\endcsname{\realbackslash} + +\def\margbackslash#1{\char`\#1 } + +\def\macro{\recursivefalse\parsearg\macroxxx} +\def\rmacro{\recursivetrue\parsearg\macroxxx} + +\def\macroxxx#1{% + \getargs{#1}% now \macname is the macname and \argl the arglist + \ifx\argl\empty % no arguments + \paramno=0\relax + \else + \expandafter\parsemargdef \argl;% + \if\paramno>256\relax + \ifx\eTeXversion\thisisundefined + \errhelp = \EMsimple + \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} + \fi + \fi + \fi + \if1\csname ismacro.\the\macname\endcsname + \message{Warning: redefining \the\macname}% + \else + \expandafter\ifx\csname \the\macname\endcsname \relax + \else \errmessage{Macro name \the\macname\space already defined}\fi + \global\cslet{macsave.\the\macname}{\the\macname}% + \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% + \addtomacrolist{\the\macname}% + \fi + \begingroup \macrobodyctxt + \ifrecursive \expandafter\parsermacbody + \else \expandafter\parsemacbody + \fi} + +\parseargdef\unmacro{% + \if1\csname ismacro.#1\endcsname + \global\cslet{#1}{macsave.#1}% + \global\expandafter\let \csname ismacro.#1\endcsname=0% + % Remove the macro name from \macrolist: + \begingroup + \expandafter\let\csname#1\endcsname \relax + \let\definedummyword\unmacrodo + \xdef\macrolist{\macrolist}% + \endgroup + \else + \errmessage{Macro #1 not defined}% + \fi +} + +% Called by \do from \dounmacro on each macro. The idea is to omit any +% macro definitions that have been changed to \relax. +% +\def\unmacrodo#1{% + \ifx #1\relax + % remove this + \else + \noexpand\definedummyword \noexpand#1% + \fi +} + +% This makes use of the obscure feature that if the last token of a +% is #, then the preceding argument is delimited by +% an opening brace, and that opening brace is not consumed. +\def\getargs#1{\getargsxxx#1{}} +\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} +\def\getmacname#1 #2\relax{\macname={#1}} +\def\getmacargs#1{\def\argl{#1}} + +% For macro processing make @ a letter so that we can make Texinfo private macro names. +\edef\texiatcatcode{\the\catcode`\@} +\catcode `@=11\relax + +% Parse the optional {params} list. Set up \paramno and \paramlist +% so \defmacro knows what to do. Define \macarg.BLAH for each BLAH +% in the params list to some hook where the argument si to be expanded. If +% there are less than 10 arguments that hook is to be replaced by ##N where N +% is the position in that list, that is to say the macro arguments are to be +% defined `a la TeX in the macro body. +% +% That gets used by \mbodybackslash (above). +% +% We need to get `macro parameter char #' into several definitions. +% The technique used is stolen from LaTeX: let \hash be something +% unexpandable, insert that wherever you need a #, and then redefine +% it to # just before using the token list produced. +% +% The same technique is used to protect \eatspaces till just before +% the macro is used. +% +% If there are 10 or more arguments, a different technique is used, where the +% hook remains in the body, and when macro is to be expanded the body is +% processed again to replace the arguments. +% +% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the +% argument N value and then \edef the body (nothing else will expand because of +% the catcode regime underwhich the body was input). +% +% If you compile with TeX (not eTeX), and you have macros with 10 or more +% arguments, you need that no macro has more than 256 arguments, otherwise an +% error is produced. +\def\parsemargdef#1;{% + \paramno=0\def\paramlist{}% + \let\hash\relax + \let\xeatspaces\relax + \parsemargdefxxx#1,;,% + % In case that there are 10 or more arguments we parse again the arguments + % list to set new definitions for the \macarg.BLAH macros corresponding to + % each BLAH argument. It was anyhow needed to parse already once this list + % in order to count the arguments, and as macros with at most 9 arguments + % are by far more frequent than macro with 10 or more arguments, defining + % twice the \macarg.BLAH macros does not cost too much processing power. + \ifnum\paramno<10\relax\else + \paramno0\relax + \parsemmanyargdef@@#1,;,% 10 or more arguments + \fi +} +\def\parsemargdefxxx#1,{% + \if#1;\let\next=\relax + \else \let\next=\parsemargdefxxx + \advance\paramno by 1 + \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname + {\xeatspaces{\hash\the\paramno}}% + \edef\paramlist{\paramlist\hash\the\paramno,}% + \fi\next} + +\def\parsemmanyargdef@@#1,{% + \if#1;\let\next=\relax + \else + \let\next=\parsemmanyargdef@@ + \edef\tempb{\eatspaces{#1}}% + \expandafter\def\expandafter\tempa + \expandafter{\csname macarg.\tempb\endcsname}% + % Note that we need some extra \noexpand\noexpand, this is because we + % don't want \the to be expanded in the \parsermacbody as it uses an + % \xdef . + \expandafter\edef\tempa + {\noexpand\noexpand\noexpand\the\toks\the\paramno}% + \advance\paramno by 1\relax + \fi\next} + +% These two commands read recursive and nonrecursive macro bodies. +% (They're different since rec and nonrec macros end differently.) +% + +\catcode `\@\texiatcatcode +\long\def\parsemacbody#1@end macro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% +\long\def\parsermacbody#1@end rmacro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% +\catcode `\@=11\relax + +\let\endargs@\relax +\let\nil@\relax +\def\nilm@{\nil@}% +\long\def\nillm@{\nil@}% + +% This macro is expanded during the Texinfo macro expansion, not during its +% definition. It gets all the arguments values and assigns them to macros +% macarg.ARGNAME +% +% #1 is the macro name +% #2 is the list of argument names +% #3 is the list of argument values +\def\getargvals@#1#2#3{% + \def\macargdeflist@{}% + \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. + \def\paramlist{#2,\nil@}% + \def\macroname{#1}% + \begingroup + \macroargctxt + \def\argvaluelist{#3,\nil@}% + \def\@tempa{#3}% + \ifx\@tempa\empty + \setemptyargvalues@ + \else + \getargvals@@ + \fi +} + +% +\def\getargvals@@{% + \ifx\paramlist\nilm@ + % Some sanity check needed here that \argvaluelist is also empty. + \ifx\argvaluelist\nillm@ + \else + \errhelp = \EMsimple + \errmessage{Too many arguments in macro `\macroname'!}% + \fi + \let\next\macargexpandinbody@ + \else + \ifx\argvaluelist\nillm@ + % No more arguments values passed to macro. Set remaining named-arg + % macros to empty. + \let\next\setemptyargvalues@ + \else + % pop current arg name into \@tempb + \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% + \expandafter\@tempa\expandafter{\paramlist}% + % pop current argument value into \@tempc + \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% + \expandafter\@tempa\expandafter{\argvaluelist}% + % Here \@tempb is the current arg name and \@tempc is the current arg value. + % First place the new argument macro definition into \@tempd + \expandafter\macname\expandafter{\@tempc}% + \expandafter\let\csname macarg.\@tempb\endcsname\relax + \expandafter\def\expandafter\@tempe\expandafter{% + \csname macarg.\@tempb\endcsname}% + \edef\@tempd{\long\def\@tempe{\the\macname}}% + \push@\@tempd\macargdeflist@ + \let\next\getargvals@@ + \fi + \fi + \next +} + +\def\push@#1#2{% + \expandafter\expandafter\expandafter\def + \expandafter\expandafter\expandafter#2% + \expandafter\expandafter\expandafter{% + \expandafter#1#2}% +} + +% Replace arguments by their values in the macro body, and place the result +% in macro \@tempa +\def\macvalstoargs@{% + % To do this we use the property that token registers that are \the'ed + % within an \edef expand only once. So we are going to place all argument + % values into respective token registers. + % + % First we save the token context, and initialize argument numbering. + \begingroup + \paramno0\relax + % Then, for each argument number #N, we place the corresponding argument + % value into a new token list register \toks#N + \expandafter\putargsintokens@\saveparamlist@,;,% + % Then, we expand the body so that argument are replaced by their + % values. The trick for values not to be expanded themselves is that they + % are within tokens and that tokens expand only once in an \edef . + \edef\@tempc{\csname mac.\macroname .body\endcsname}% + % Now we restore the token stack pointer to free the token list registers + % which we have used, but we make sure that expanded body is saved after + % group. + \expandafter + \endgroup + \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% + } + +\def\macargexpandinbody@{% + %% Define the named-macro outside of this group and then close this group. + \expandafter + \endgroup + \macargdeflist@ + % First the replace in body the macro arguments by their values, the result + % is in \@tempa . + \macvalstoargs@ + % Then we point at the \norecurse or \gobble (for recursive) macro value + % with \@tempb . + \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname + % Depending on whether it is recursive or not, we need some tailing + % \egroup . + \ifx\@tempb\gobble + \let\@tempc\relax + \else + \let\@tempc\egroup + \fi + % And now we do the real job: + \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% + \@tempd +} + +\def\putargsintokens@#1,{% + \if#1;\let\next\relax + \else + \let\next\putargsintokens@ + % First we allocate the new token list register, and give it a temporary + % alias \@tempb . + \toksdef\@tempb\the\paramno + % Then we place the argument value into that token list register. + \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname + \expandafter\@tempb\expandafter{\@tempa}% + \advance\paramno by 1\relax + \fi + \next +} + +% Save the token stack pointer into macro #1 +\def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}} +% Restore the token stack pointer from number in macro #1 +\def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax} +% newtoks that can be used non \outer . +\def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi} + +% Tailing missing arguments are set to empty +\def\setemptyargvalues@{% + \ifx\paramlist\nilm@ + \let\next\macargexpandinbody@ + \else + \expandafter\setemptyargvaluesparser@\paramlist\endargs@ + \let\next\setemptyargvalues@ + \fi + \next +} + +\def\setemptyargvaluesparser@#1,#2\endargs@{% + \expandafter\def\expandafter\@tempa\expandafter{% + \expandafter\def\csname macarg.#1\endcsname{}}% + \push@\@tempa\macargdeflist@ + \def\paramlist{#2}% +} + +% #1 is the element target macro +% #2 is the list macro +% #3,#4\endargs@ is the list value +\def\pop@#1#2#3,#4\endargs@{% + \def#1{#3}% + \def#2{#4}% +} +\long\def\longpop@#1#2#3,#4\endargs@{% + \long\def#1{#3}% + \long\def#2{#4}% +} + +% This defines a Texinfo @macro. There are eight cases: recursive and +% nonrecursive macros of zero, one, up to nine, and many arguments. +% Much magic with \expandafter here. +% \xdef is used so that macro definitions will survive the file +% they're defined in; @include reads the file inside a group. +% +\def\defmacro{% + \let\hash=##% convert placeholders to macro parameter chars + \ifrecursive + \ifcase\paramno + % 0 + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\scanmacro{\temp}}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup\noexpand\scanmacro{\temp}}% + \else + \ifnum\paramno<10\relax % at most 9 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{\egroup\noexpand\scanmacro{\temp}}% + \else % 10 or more + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\getargvals@{\the\macname}{\argl}% + }% + \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp + \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble + \fi + \fi + \else + \ifcase\paramno + % 0 + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \else % at most 9 + \ifnum\paramno<10\relax + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \expandafter\noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \else % 10 or more: + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\getargvals@{\the\macname}{\argl}% + }% + \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp + \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse + \fi + \fi + \fi} + +\catcode `\@\texiatcatcode\relax + +\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} + +% \braceorline decides whether the next nonwhitespace character is a +% {. If so it reads up to the closing }, if not, it reads the whole +% line. Whatever was read is then fed to the next control sequence +% as an argument (by \parsebrace or \parsearg). +% +\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} +\def\braceorlinexxx{% + \ifx\nchar\bgroup\else + \expandafter\parsearg + \fi \macnamexxx} + + +% @alias. +% We need some trickery to remove the optional spaces around the equal +% sign. Make them active and then expand them all to nothing. +% +\def\alias{\parseargusing\obeyspaces\aliasxxx} +\def\aliasxxx #1{\aliasyyy#1\relax} +\def\aliasyyy #1=#2\relax{% + {% + \expandafter\let\obeyedspace=\empty + \addtomacrolist{#1}% + \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% + }% + \next +} + + +\message{cross references,} + +\newwrite\auxfile +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% @inforef is relatively simple. +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{% + \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#1{}}} + +% @node's only job in TeX is to define \lastnode, which is used in +% cross-references. The @node line might or might not have commas, and +% might or might not have spaces before the first comma, like: +% @node foo , bar , ... +% We don't want such trailing spaces in the node name. +% +\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} +% +% also remove a trailing comma, in case of something like this: +% @node Help-Cross, , , Cross-refs +\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} +\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} + +\let\nwnode=\node +\let\lastnode=\empty + +% Write a cross-reference definition for the current node. #1 is the +% type (Ynumbered, Yappendix, Ynothing). +% +\def\donoderef#1{% + \ifx\lastnode\empty\else + \setref{\lastnode}{#1}% + \global\let\lastnode=\empty + \fi +} + +% @anchor{NAME} -- define xref target at arbitrary point. +% +\newcount\savesfregister +% +\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} +\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} +\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} + +% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an +% anchor), which consists of three parts: +% 1) NAME-title - the current sectioning name taken from \lastsection, +% or the anchor name. +% 2) NAME-snt - section number and type, passed as the SNT arg, or +% empty for anchors. +% 3) NAME-pg - the page number. +% +% This is called from \donoderef, \anchor, and \dofloat. In the case of +% floats, there is an additional part, which is not written here: +% 4) NAME-lof - the text as it should appear in a @listoffloats. +% +\def\setref#1#2{% + \pdfmkdest{#1}% + \iflinks + {% + \atdummies % preserve commands, but don't expand them + \edef\writexrdef##1##2{% + \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef + ##1}{##2}}% these are parameters of \writexrdef + }% + \toks0 = \expandafter{\lastsection}% + \immediate \writexrdef{title}{\the\toks0 }% + \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. + \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout + }% + \fi +} + +% @xrefautosectiontitle on|off says whether @section(ing) names are used +% automatically in xrefs, if the third arg is not explicitly specified. +% This was provided as a "secret" @set xref-automatic-section-title +% variable, now it's official. +% +\parseargdef\xrefautomaticsectiontitle{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETxref-automatic-section-title\endcsname + = \empty + \else\ifx\temp\offword + \expandafter\let\csname SETxref-automatic-section-title\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', + must be on|off}% + \fi\fi +} + +% +% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is +% the node name, #2 the name of the Info cross-reference, #3 the printed +% node name, #4 the name of the Info file, #5 the name of the printed +% manual. All but the node name can be omitted. +% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +% +\newbox\toprefbox +\newbox\printedrefnamebox +\newbox\infofilenamebox +\newbox\printedmanualbox +% +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \unsepspaces + % + % Get args without leading/trailing spaces. + \def\printedrefname{\ignorespaces #3}% + \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% + % + \def\infofilename{\ignorespaces #4}% + \setbox\infofilenamebox = \hbox{\infofilename\unskip}% + % + \def\printedmanual{\ignorespaces #5}% + \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% + % + % If the printed reference name (arg #3) was not explicitly given in + % the @xref, figure out what we want to use. + \ifdim \wd\printedrefnamebox = 0pt + % No printed node name was explicitly given. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax + % Not auto section-title: use node name inside the square brackets. + \def\printedrefname{\ignorespaces #1}% + \else + % Auto section-title: use chapter/section title inside + % the square brackets if we have it. + \ifdim \wd\printedmanualbox > 0pt + % It is in another manual, so we don't have it; use node name. + \def\printedrefname{\ignorespaces #1}% + \else + \ifhavexrefs + % We (should) know the real title if we have the xref values. + \def\printedrefname{\refx{#1-title}{}}% + \else + % Otherwise just copy the Info node name. + \def\printedrefname{\ignorespaces #1}% + \fi% + \fi + \fi + \fi + % + % Make link in pdf output. + \ifpdf + {\indexnofonts + \turnoffactive + \makevalueexpandable + % This expands tokens, so do it after making catcode changes, so _ + % etc. don't get their TeX definitions. This ignores all spaces in + % #4, including (wrongly) those in the middle of the filename. + \getfilename{#4}% + % + % This (wrongly) does not take account of leading or trailing + % spaces in #1, which should be ignored. + \edef\pdfxrefdest{#1}% + \ifx\pdfxrefdest\empty + \def\pdfxrefdest{Top}% no empty targets + \else + \txiescapepdf\pdfxrefdest % escape PDF special chars + \fi + % + \leavevmode + \startlink attr{/Border [0 0 0]}% + \ifnum\filenamelength>0 + goto file{\the\filename.pdf} name{\pdfxrefdest}% + \else + goto name{\pdfmkpgn{\pdfxrefdest}}% + \fi + }% + \setcolor{\linkcolor}% + \fi + % + % Float references are printed completely differently: "Figure 1.2" + % instead of "[somenode], p.3". We distinguish them by the + % LABEL-title being set to a magic string. + {% + % Have to otherify everything special to allow the \csname to + % include an _ in the xref name, etc. + \indexnofonts + \turnoffactive + \expandafter\global\expandafter\let\expandafter\Xthisreftitle + \csname XR#1-title\endcsname + }% + \iffloat\Xthisreftitle + % If the user specified the print name (third arg) to the ref, + % print it instead of our usual "Figure 1.2". + \ifdim\wd\printedrefnamebox = 0pt + \refx{#1-snt}{}% + \else + \printedrefname + \fi + % + % If the user also gave the printed manual name (fifth arg), append + % "in MANUALNAME". + \ifdim \wd\printedmanualbox > 0pt + \space \putwordin{} \cite{\printedmanual}% + \fi + \else + % node/anchor (non-float) references. + % + % If we use \unhbox to print the node names, TeX does not insert + % empty discretionaries after hyphens, which means that it will not + % find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, + % this is a loss. Therefore, we give the text of the node name + % again, so it is as if TeX is seeing it for the first time. + % + \ifdim \wd\printedmanualbox > 0pt + % Cross-manual reference with a printed manual name. + % + \crossmanualxref{\cite{\printedmanual\unskip}}% + % + \else\ifdim \wd\infofilenamebox > 0pt + % Cross-manual reference with only an info filename (arg 4), no + % printed manual name (arg 5). This is essentially the same as + % the case above; we output the filename, since we have nothing else. + % + \crossmanualxref{\code{\infofilename\unskip}}% + % + \else + % Reference within this manual. + % + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive + % Only output a following space if the -snt ref is nonempty; for + % @unnumbered and @anchor, it won't be. + \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% + \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi + }% + % output the `[mynode]' via the macro below so it can be overridden. + \xrefprintnodename\printedrefname + % + % But we always want a comma and a space: + ,\space + % + % output the `page 3'. + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi\fi + \fi + \endlink +\endgroup} + +% Output a cross-manual xref to #1. Used just above (twice). +% +% Only include the text "Section ``foo'' in" if the foo is neither +% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply +% "see The Foo Manual", the idea being to refer to the whole manual. +% +% But, this being TeX, we can't easily compare our node name against the +% string "Top" while ignoring the possible spaces before and after in +% the input. By adding the arbitrary 7sp below, we make it much less +% likely that a real node name would have the same width as "Top" (e.g., +% in a monospaced font). Hopefully it will never happen in practice. +% +% For the same basic reason, we retypeset the "Top" at every +% reference, since the current font is indeterminate. +% +\def\crossmanualxref#1{% + \setbox\toprefbox = \hbox{Top\kern7sp}% + \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% + \ifdim \wd2 > 7sp % nonempty? + \ifdim \wd2 = \wd\toprefbox \else % same as Top? + \putwordSection{} ``\printedrefname'' \putwordin{}\space + \fi + \fi + #1% +} + +% This macro is called from \xrefX for the `[nodename]' part of xref +% output. It's a separate macro only so it can be changed more easily, +% since square brackets don't work well in some documents. Particularly +% one that Bob is working on :). +% +\def\xrefprintnodename#1{[#1]} + +% Things referred to by \setref. +% +\def\Ynothing{} +\def\Yomitfromtoc{} +\def\Ynumbered{% + \ifnum\secno=0 + \putwordChapter@tie \the\chapno + \else \ifnum\subsecno=0 + \putwordSection@tie \the\chapno.\the\secno + \else \ifnum\subsubsecno=0 + \putwordSection@tie \the\chapno.\the\secno.\the\subsecno + \else + \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno + \fi\fi\fi +} +\def\Yappendix{% + \ifnum\secno=0 + \putwordAppendix@tie @char\the\appendixno{}% + \else \ifnum\subsecno=0 + \putwordSection@tie @char\the\appendixno.\the\secno + \else \ifnum\subsubsecno=0 + \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno + \else + \putwordSection@tie + @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno + \fi\fi\fi +} + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. +% +\def\refx#1#2{% + {% + \indexnofonts + \otherbackslash + \expandafter\global\expandafter\let\expandafter\thisrefX + \csname XR#1\endcsname + }% + \ifx\thisrefX\relax + % If not defined, say something at least. + \angleleft un\-de\-fined\angleright + \iflinks + \ifhavexrefs + {\toks0 = {#1}% avoid expansion of possibly-complex value + \message{\linenumber Undefined cross reference `\the\toks0'.}}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \fi + \else + % It's defined, so just use it. + \thisrefX + \fi + #2% Output the suffix in any case. +} + +% This is the macro invoked by entries in the aux file. Usually it's +% just a \def (we prepend XR to the control sequence name to avoid +% collisions). But if this is a float type, we have more work to do. +% +\def\xrdef#1#2{% + {% The node name might contain 8-bit characters, which in our current + % implementation are changed to commands like @'e. Don't let these + % mess up the control sequence name. + \indexnofonts + \turnoffactive + \xdef\safexrefname{#1}% + }% + % + \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref + % + % Was that xref control sequence that we just defined for a float? + \expandafter\iffloat\csname XR\safexrefname\endcsname + % it was a float, and we have the (safe) float type in \iffloattype. + \expandafter\let\expandafter\floatlist + \csname floatlist\iffloattype\endcsname + % + % Is this the first time we've seen this float type? + \expandafter\ifx\floatlist\relax + \toks0 = {\do}% yes, so just \do + \else + % had it before, so preserve previous elements in list. + \toks0 = \expandafter{\floatlist\do}% + \fi + % + % Remember this xref in the control sequence \floatlistFLOATTYPE, + % for later use in \listoffloats. + \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 + {\safexrefname}}% + \fi +} + +% Read the last existing aux file, if any. No error if none exists. +% +\def\tryauxfile{% + \openin 1 \jobname.aux + \ifeof 1 \else + \readdatafile{aux}% + \global\havexrefstrue + \fi + \closein 1 +} + +\def\setupdatafile{% + \catcode`\^^@=\other + \catcode`\^^A=\other + \catcode`\^^B=\other + \catcode`\^^C=\other + \catcode`\^^D=\other + \catcode`\^^E=\other + \catcode`\^^F=\other + \catcode`\^^G=\other + \catcode`\^^H=\other + \catcode`\^^K=\other + \catcode`\^^L=\other + \catcode`\^^N=\other + \catcode`\^^P=\other + \catcode`\^^Q=\other + \catcode`\^^R=\other + \catcode`\^^S=\other + \catcode`\^^T=\other + \catcode`\^^U=\other + \catcode`\^^V=\other + \catcode`\^^W=\other + \catcode`\^^X=\other + \catcode`\^^Z=\other + \catcode`\^^[=\other + \catcode`\^^\=\other + \catcode`\^^]=\other + \catcode`\^^^=\other + \catcode`\^^_=\other + % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. + % in xref tags, i.e., node names. But since ^^e4 notation isn't + % supported in the main text, it doesn't seem desirable. Furthermore, + % that is not enough: for node names that actually contain a ^ + % character, we would end up writing a line like this: 'xrdef {'hat + % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first + % argument, and \hat is not an expandable control sequence. It could + % all be worked out, but why? Either we support ^^ or we don't. + % + % The other change necessary for this was to define \auxhat: + % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter + % and then to call \auxhat in \setq. + % + \catcode`\^=\other + % + % Special characters. Should be turned off anyway, but... + \catcode`\~=\other + \catcode`\[=\other + \catcode`\]=\other + \catcode`\"=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\$=\other + \catcode`\#=\other + \catcode`\&=\other + \catcode`\%=\other + \catcode`+=\other % avoid \+ for paranoia even though we've turned it off + % + % This is to support \ in node names and titles, since the \ + % characters end up in a \csname. It's easier than + % leaving it active and making its active definition an actual \ + % character. What I don't understand is why it works in the *value* + % of the xrdef. Seems like it should be a catcode12 \, and that + % should not typeset properly. But it works, so I'm moving on for + % now. --karl, 15jan04. + \catcode`\\=\other + % + % Make the characters 128-255 be printing characters. + {% + \count1=128 + \def\loop{% + \catcode\count1=\other + \advance\count1 by 1 + \ifnum \count1<256 \loop \fi + }% + }% + % + % @ is our escape character in .aux files, and we need braces. + \catcode`\{=1 + \catcode`\}=2 + \catcode`\@=0 +} + +\def\readdatafile#1{% +\begingroup + \setupdatafile + \input\jobname.#1 +\endgroup} + + +\message{insertions,} +% including footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. (Generally, numeric constants should always be followed by a +% space to prevent strange expansion errors.) +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for Info output only. +\let\footnotestyle=\comment + +{\catcode `\@=11 +% +% Auto-number footnotes. Otherwise like plain. +\gdef\footnote{% + \let\indent=\ptexindent + \let\noindent=\ptexnoindent + \global\advance\footnoteno by \@ne + \edef\thisfootno{$^{\the\footnoteno}$}% + % + % In case the footnote comes at the end of a sentence, preserve the + % extra spacing after we do the footnote number. + \let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi + % + % Remove inadvertent blank space before typesetting the footnote number. + \unskip + \thisfootno\@sf + \dofootnote +}% + +% Don't bother with the trickery in plain.tex to not require the +% footnote text as a parameter. Our footnotes don't need to be so general. +% +% Oh yes, they do; otherwise, @ifset (and anything else that uses +% \parseargline) fails inside footnotes because the tokens are fixed when +% the footnote is read. --karl, 16nov96. +% +\gdef\dofootnote{% + \insert\footins\bgroup + % We want to typeset this text as a normal paragraph, even if the + % footnote reference occurs in (for example) a display environment. + % So reset some parameters. + \hsize=\pagewidth + \interlinepenalty\interfootnotelinepenalty + \splittopskip\ht\strutbox % top baseline for broken footnotes + \splitmaxdepth\dp\strutbox + \floatingpenalty\@MM + \leftskip\z@skip + \rightskip\z@skip + \spaceskip\z@skip + \xspaceskip\z@skip + \parindent\defaultparindent + % + \smallfonts \rm + % + % Because we use hanging indentation in footnotes, a @noindent appears + % to exdent this text, so make it be a no-op. makeinfo does not use + % hanging indentation so @noindent can still be needed within footnote + % text after an @example or the like (not that this is good style). + \let\noindent = \relax + % + % Hang the footnote text off the number. Use \everypar in case the + % footnote extends for more than one paragraph. + \everypar = {\hang}% + \textindent{\thisfootno}% + % + % Don't crash into the line above the footnote text. Since this + % expands into a box, it must come within the paragraph, lest it + % provide a place where TeX can split the footnote. + \footstrut + % + % Invoke rest of plain TeX footnote routine. + \futurelet\next\fo@t +} +}%end \catcode `\@=11 + +% In case a @footnote appears in a vbox, save the footnote text and create +% the real \insert just after the vbox finished. Otherwise, the insertion +% would be lost. +% Similarly, if a @footnote appears inside an alignment, save the footnote +% text to a box and make the \insert when a row of the table is finished. +% And the same can be done for other insert classes. --kasal, 16nov03. + +% Replace the \insert primitive by a cheating macro. +% Deeper inside, just make sure that the saved insertions are not spilled +% out prematurely. +% +\def\startsavinginserts{% + \ifx \insert\ptexinsert + \let\insert\saveinsert + \else + \let\checkinserts\relax + \fi +} + +% This \insert replacement works for both \insert\footins{foo} and +% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. +% +\def\saveinsert#1{% + \edef\next{\noexpand\savetobox \makeSAVEname#1}% + \afterassignment\next + % swallow the left brace + \let\temp = +} +\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} +\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} + +\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} + +\def\placesaveins#1{% + \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname + {\box#1}% +} + +% eat @SAVE -- beware, all of them have catcode \other: +{ + \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) + \gdef\gobblesave @SAVE{} +} + +% initialization: +\def\newsaveins #1{% + \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% + \next +} +\def\newsaveinsX #1{% + \csname newbox\endcsname #1% + \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts + \checksaveins #1}% +} + +% initialize: +\let\checkinserts\empty +\newsaveins\footins +\newsaveins\margin + + +% @image. We use the macros from epsf.tex to support this. +% If epsf.tex is not installed and @image is used, we complain. +% +% Check for and read epsf.tex up front. If we read it only at @image +% time, we might be inside a group, and then its definitions would get +% undone and the next image would fail. +\openin 1 = epsf.tex +\ifeof 1 \else + % Do not bother showing banner with epsf.tex v2.7k (available in + % doc/epsf.tex and on ctan). + \def\epsfannounce{\toks0 = }% + \input epsf.tex +\fi +\closein 1 +% +% We will only complain once about lack of epsf.tex. +\newif\ifwarnednoepsf +\newhelp\noepsfhelp{epsf.tex must be installed for images to + work. It is also included in the Texinfo distribution, or you can get + it from ftp://tug.org/tex/epsf.tex.} +% +\def\image#1{% + \ifx\epsfbox\thisisundefined + \ifwarnednoepsf \else + \errhelp = \noepsfhelp + \errmessage{epsf.tex not found, images will be ignored}% + \global\warnednoepsftrue + \fi + \else + \imagexxx #1,,,,,\finish + \fi +} +% +% Arguments to @image: +% #1 is (mandatory) image filename; we tack on .eps extension. +% #2 is (optional) width, #3 is (optional) height. +% #4 is (ignored optional) html alt text. +% #5 is (ignored optional) extension. +% #6 is just the usual extra ignored arg for parsing stuff. +\newif\ifimagevmode +\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup + \catcode`\^^M = 5 % in case we're inside an example + \normalturnoffactive % allow _ et al. in names + % If the image is by itself, center it. + \ifvmode + \imagevmodetrue + \else \ifx\centersub\centerV + % for @center @image, we need a vbox so we can have our vertical space + \imagevmodetrue + \vbox\bgroup % vbox has better behavior than vtop herev + \fi\fi + % + \ifimagevmode + \nobreak\medskip + % Usually we'll have text after the image which will insert + % \parskip glue, so insert it here too to equalize the space + % above and below. + \nobreak\vskip\parskip + \nobreak + \fi + % + % Leave vertical mode so that indentation from an enclosing + % environment such as @quotation is respected. + % However, if we're at the top level, we don't want the + % normal paragraph indentation. + % On the other hand, if we are in the case of @center @image, we don't + % want to start a paragraph, which will create a hsize-width box and + % eradicate the centering. + \ifx\centersub\centerV\else \noindent \fi + % + % Output the image. + \ifpdf + \dopdfimage{#1}{#2}{#3}% + \else + % \epsfbox itself resets \epsf?size at each figure. + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi + \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi + \epsfbox{#1.eps}% + \fi + % + \ifimagevmode + \medskip % space after a standalone image + \fi + \ifx\centersub\centerV \egroup \fi +\endgroup} + + +% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, +% etc. We don't actually implement floating yet, we always include the +% float "here". But it seemed the best name for the future. +% +\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} + +% There may be a space before second and/or third parameter; delete it. +\def\eatcommaspace#1, {#1,} + +% #1 is the optional FLOATTYPE, the text label for this float, typically +% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, +% this float will not be numbered and cannot be referred to. +% +% #2 is the optional xref label. Also must be present for the float to +% be referable. +% +% #3 is the optional positioning argument; for now, it is ignored. It +% will somehow specify the positions allowed to float to (here, top, bottom). +% +% We keep a separate counter for each FLOATTYPE, which we reset at each +% chapter-level command. +\let\resetallfloatnos=\empty +% +\def\dofloat#1,#2,#3,#4\finish{% + \let\thiscaption=\empty + \let\thisshortcaption=\empty + % + % don't lose footnotes inside @float. + % + % BEWARE: when the floats start float, we have to issue warning whenever an + % insert appears inside a float which could possibly float. --kasal, 26may04 + % + \startsavinginserts + % + % We can't be used inside a paragraph. + \par + % + \vtop\bgroup + \def\floattype{#1}% + \def\floatlabel{#2}% + \def\floatloc{#3}% we do nothing with this yet. + % + \ifx\floattype\empty + \let\safefloattype=\empty + \else + {% + % the floattype might have accents or other special characters, + % but we need to use it in a control sequence name. + \indexnofonts + \turnoffactive + \xdef\safefloattype{\floattype}% + }% + \fi + % + % If label is given but no type, we handle that as the empty type. + \ifx\floatlabel\empty \else + % We want each FLOATTYPE to be numbered separately (Figure 1, + % Table 1, Figure 2, ...). (And if no label, no number.) + % + \expandafter\getfloatno\csname\safefloattype floatno\endcsname + \global\advance\floatno by 1 + % + {% + % This magic value for \lastsection is output by \setref as the + % XREFLABEL-title value. \xrefX uses it to distinguish float + % labels (which have a completely different output format) from + % node and anchor labels. And \xrdef uses it to construct the + % lists of floats. + % + \edef\lastsection{\floatmagic=\safefloattype}% + \setref{\floatlabel}{Yfloat}% + }% + \fi + % + % start with \parskip glue, I guess. + \vskip\parskip + % + % Don't suppress indentation if a float happens to start a section. + \restorefirstparagraphindent +} + +% we have these possibilities: +% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap +% @float Foo,lbl & no caption: Foo 1.1 +% @float Foo & @caption{Cap}: Foo: Cap +% @float Foo & no caption: Foo +% @float ,lbl & Caption{Cap}: 1.1: Cap +% @float ,lbl & no caption: 1.1 +% @float & @caption{Cap}: Cap +% @float & no caption: +% +\def\Efloat{% + \let\floatident = \empty + % + % In all cases, if we have a float type, it comes first. + \ifx\floattype\empty \else \def\floatident{\floattype}\fi + % + % If we have an xref label, the number comes next. + \ifx\floatlabel\empty \else + \ifx\floattype\empty \else % if also had float type, need tie first. + \appendtomacro\floatident{\tie}% + \fi + % the number. + \appendtomacro\floatident{\chaplevelprefix\the\floatno}% + \fi + % + % Start the printed caption with what we've constructed in + % \floatident, but keep it separate; we need \floatident again. + \let\captionline = \floatident + % + \ifx\thiscaption\empty \else + \ifx\floatident\empty \else + \appendtomacro\captionline{: }% had ident, so need a colon between + \fi + % + % caption text. + \appendtomacro\captionline{\scanexp\thiscaption}% + \fi + % + % If we have anything to print, print it, with space before. + % Eventually this needs to become an \insert. + \ifx\captionline\empty \else + \vskip.5\parskip + \captionline + % + % Space below caption. + \vskip\parskip + \fi + % + % If have an xref label, write the list of floats info. Do this + % after the caption, to avoid chance of it being a breakpoint. + \ifx\floatlabel\empty \else + % Write the text that goes in the lof to the aux file as + % \floatlabel-lof. Besides \floatident, we include the short + % caption if specified, else the full caption if specified, else nothing. + {% + \atdummies + % + % since we read the caption text in the macro world, where ^^M + % is turned into a normal character, we have to scan it back, so + % we don't write the literal three characters "^^M" into the aux file. + \scanexp{% + \xdef\noexpand\gtemp{% + \ifx\thisshortcaption\empty + \thiscaption + \else + \thisshortcaption + \fi + }% + }% + \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident + \ifx\gtemp\empty \else : \gtemp \fi}}% + }% + \fi + \egroup % end of \vtop + % + % place the captured inserts + % + % BEWARE: when the floats start floating, we have to issue warning + % whenever an insert appears inside a float which could possibly + % float. --kasal, 26may04 + % + \checkinserts +} + +% Append the tokens #2 to the definition of macro #1, not expanding either. +% +\def\appendtomacro#1#2{% + \expandafter\def\expandafter#1\expandafter{#1#2}% +} + +% @caption, @shortcaption +% +\def\caption{\docaption\thiscaption} +\def\shortcaption{\docaption\thisshortcaption} +\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} +\def\defcaption#1#2{\egroup \def#1{#2}} + +% The parameter is the control sequence identifying the counter we are +% going to use. Create it if it doesn't exist and assign it to \floatno. +\def\getfloatno#1{% + \ifx#1\relax + % Haven't seen this figure type before. + \csname newcount\endcsname #1% + % + % Remember to reset this floatno at the next chap. + \expandafter\gdef\expandafter\resetallfloatnos + \expandafter{\resetallfloatnos #1=0 }% + \fi + \let\floatno#1% +} + +% \setref calls this to get the XREFLABEL-snt value. We want an @xref +% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we +% first read the @float command. +% +\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% + +% Magic string used for the XREFLABEL-title value, so \xrefX can +% distinguish floats from other xref types. +\def\floatmagic{!!float!!} + +% #1 is the control sequence we are passed; we expand into a conditional +% which is true if #1 represents a float ref. That is, the magic +% \lastsection value which we \setref above. +% +\def\iffloat#1{\expandafter\doiffloat#1==\finish} +% +% #1 is (maybe) the \floatmagic string. If so, #2 will be the +% (safe) float type for this float. We set \iffloattype to #2. +% +\def\doiffloat#1=#2=#3\finish{% + \def\temp{#1}% + \def\iffloattype{#2}% + \ifx\temp\floatmagic +} + +% @listoffloats FLOATTYPE - print a list of floats like a table of contents. +% +\parseargdef\listoffloats{% + \def\floattype{#1}% floattype + {% + % the floattype might have accents or other special characters, + % but we need to use it in a control sequence name. + \indexnofonts + \turnoffactive + \xdef\safefloattype{\floattype}% + }% + % + % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. + \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax + \ifhavexrefs + % if the user said @listoffloats foo but never @float foo. + \message{\linenumber No `\safefloattype' floats to list.}% + \fi + \else + \begingroup + \leftskip=\tocindent % indent these entries like a toc + \let\do=\listoffloatsdo + \csname floatlist\safefloattype\endcsname + \endgroup + \fi +} + +% This is called on each entry in a list of floats. We're passed the +% xref label, in the form LABEL-title, which is how we save it in the +% aux file. We strip off the -title and look up \XRLABEL-lof, which +% has the text we're supposed to typeset here. +% +% Figures without xref labels will not be included in the list (since +% they won't appear in the aux file). +% +\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} +\def\listoffloatsdoentry#1-title\finish{{% + % Can't fully expand XR#1-lof because it can contain anything. Just + % pass the control sequence. On the other hand, XR#1-pg is just the + % page number, and we want to fully expand that so we can get a link + % in pdf output. + \toksA = \expandafter{\csname XR#1-lof\endcsname}% + % + % use the same \entry macro we use to generate the TOC and index. + \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% + \writeentry +}} + + +\message{localization,} + +% For single-language documents, @documentlanguage is usually given very +% early, just after @documentencoding. Single argument is the language +% (de) or locale (de_DE) abbreviation. +% +{ + \catcode`\_ = \active + \globaldefs=1 +\parseargdef\documentlanguage{\begingroup + \let_=\normalunderscore % normal _ character for filenames + \tex % read txi-??.tex file in plain TeX. + % Read the file by the name they passed if it exists. + \openin 1 txi-#1.tex + \ifeof 1 + \documentlanguagetrywithoutunderscore{#1_\finish}% + \else + \globaldefs = 1 % everything in the txi-LL files needs to persist + \input txi-#1.tex + \fi + \closein 1 + \endgroup % end raw TeX +\endgroup} +% +% If they passed de_DE, and txi-de_DE.tex doesn't exist, +% try txi-de.tex. +% +\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% + \openin 1 txi-#1.tex + \ifeof 1 + \errhelp = \nolanghelp + \errmessage{Cannot read language file txi-#1.tex}% + \else + \globaldefs = 1 % everything in the txi-LL files needs to persist + \input txi-#1.tex + \fi + \closein 1 +} +}% end of special _ catcode +% +\newhelp\nolanghelp{The given language definition file cannot be found or +is empty. Maybe you need to install it? Putting it in the current +directory should work if nowhere else does.} + +% This macro is called from txi-??.tex files; the first argument is the +% \language name to set (without the "\lang@" prefix), the second and +% third args are \{left,right}hyphenmin. +% +% The language names to pass are determined when the format is built. +% See the etex.log file created at that time, e.g., +% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. +% +% With TeX Live 2008, etex now includes hyphenation patterns for all +% available languages. This means we can support hyphenation in +% Texinfo, at least to some extent. (This still doesn't solve the +% accented characters problem.) +% +\catcode`@=11 +\def\txisetlanguage#1#2#3{% + % do not set the language if the name is undefined in the current TeX. + \expandafter\ifx\csname lang@#1\endcsname \relax + \message{no patterns for #1}% + \else + \global\language = \csname lang@#1\endcsname + \fi + % but there is no harm in adjusting the hyphenmin values regardless. + \global\lefthyphenmin = #2\relax + \global\righthyphenmin = #3\relax +} + +% Helpers for encodings. +% Set the catcode of characters 128 through 255 to the specified number. +% +\def\setnonasciicharscatcode#1{% + \count255=128 + \loop\ifnum\count255<256 + \global\catcode\count255=#1\relax + \advance\count255 by 1 + \repeat +} + +\def\setnonasciicharscatcodenonglobal#1{% + \count255=128 + \loop\ifnum\count255<256 + \catcode\count255=#1\relax + \advance\count255 by 1 + \repeat +} + +% @documentencoding sets the definition of non-ASCII characters +% according to the specified encoding. +% +\parseargdef\documentencoding{% + % Encoding being declared for the document. + \def\declaredencoding{\csname #1.enc\endcsname}% + % + % Supported encodings: names converted to tokens in order to be able + % to compare them with \ifx. + \def\ascii{\csname US-ASCII.enc\endcsname}% + \def\latnine{\csname ISO-8859-15.enc\endcsname}% + \def\latone{\csname ISO-8859-1.enc\endcsname}% + \def\lattwo{\csname ISO-8859-2.enc\endcsname}% + \def\utfeight{\csname UTF-8.enc\endcsname}% + % + \ifx \declaredencoding \ascii + \asciichardefs + % + \else \ifx \declaredencoding \lattwo + \setnonasciicharscatcode\active + \lattwochardefs + % + \else \ifx \declaredencoding \latone + \setnonasciicharscatcode\active + \latonechardefs + % + \else \ifx \declaredencoding \latnine + \setnonasciicharscatcode\active + \latninechardefs + % + \else \ifx \declaredencoding \utfeight + \setnonasciicharscatcode\active + \utfeightchardefs + % + \else + \message{Unknown document encoding #1, ignoring.}% + % + \fi % utfeight + \fi % latnine + \fi % latone + \fi % lattwo + \fi % ascii +} + +% A message to be logged when using a character that isn't available +% the default font encoding (OT1). +% +\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} + +% Take account of \c (plain) vs. \, (Texinfo) difference. +\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} + +% First, make active non-ASCII characters in order for them to be +% correctly categorized when TeX reads the replacement text of +% macros containing the character definitions. +\setnonasciicharscatcode\active +% +% Latin1 (ISO-8859-1) character definitions. +\def\latonechardefs{% + \gdef^^a0{\tie} + \gdef^^a1{\exclamdown} + \gdef^^a2{\missingcharmsg{CENT SIGN}} + \gdef^^a3{{\pounds}} + \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} + \gdef^^a5{\missingcharmsg{YEN SIGN}} + \gdef^^a6{\missingcharmsg{BROKEN BAR}} + \gdef^^a7{\S} + \gdef^^a8{\"{}} + \gdef^^a9{\copyright} + \gdef^^aa{\ordf} + \gdef^^ab{\guillemetleft} + \gdef^^ac{$\lnot$} + \gdef^^ad{\-} + \gdef^^ae{\registeredsymbol} + \gdef^^af{\={}} + % + \gdef^^b0{\textdegree} + \gdef^^b1{$\pm$} + \gdef^^b2{$^2$} + \gdef^^b3{$^3$} + \gdef^^b4{\'{}} + \gdef^^b5{$\mu$} + \gdef^^b6{\P} + % + \gdef^^b7{$^.$} + \gdef^^b8{\cedilla\ } + \gdef^^b9{$^1$} + \gdef^^ba{\ordm} + % + \gdef^^bb{\guillemetright} + \gdef^^bc{$1\over4$} + \gdef^^bd{$1\over2$} + \gdef^^be{$3\over4$} + \gdef^^bf{\questiondown} + % + \gdef^^c0{\`A} + \gdef^^c1{\'A} + \gdef^^c2{\^A} + \gdef^^c3{\~A} + \gdef^^c4{\"A} + \gdef^^c5{\ringaccent A} + \gdef^^c6{\AE} + \gdef^^c7{\cedilla C} + \gdef^^c8{\`E} + \gdef^^c9{\'E} + \gdef^^ca{\^E} + \gdef^^cb{\"E} + \gdef^^cc{\`I} + \gdef^^cd{\'I} + \gdef^^ce{\^I} + \gdef^^cf{\"I} + % + \gdef^^d0{\DH} + \gdef^^d1{\~N} + \gdef^^d2{\`O} + \gdef^^d3{\'O} + \gdef^^d4{\^O} + \gdef^^d5{\~O} + \gdef^^d6{\"O} + \gdef^^d7{$\times$} + \gdef^^d8{\O} + \gdef^^d9{\`U} + \gdef^^da{\'U} + \gdef^^db{\^U} + \gdef^^dc{\"U} + \gdef^^dd{\'Y} + \gdef^^de{\TH} + \gdef^^df{\ss} + % + \gdef^^e0{\`a} + \gdef^^e1{\'a} + \gdef^^e2{\^a} + \gdef^^e3{\~a} + \gdef^^e4{\"a} + \gdef^^e5{\ringaccent a} + \gdef^^e6{\ae} + \gdef^^e7{\cedilla c} + \gdef^^e8{\`e} + \gdef^^e9{\'e} + \gdef^^ea{\^e} + \gdef^^eb{\"e} + \gdef^^ec{\`{\dotless i}} + \gdef^^ed{\'{\dotless i}} + \gdef^^ee{\^{\dotless i}} + \gdef^^ef{\"{\dotless i}} + % + \gdef^^f0{\dh} + \gdef^^f1{\~n} + \gdef^^f2{\`o} + \gdef^^f3{\'o} + \gdef^^f4{\^o} + \gdef^^f5{\~o} + \gdef^^f6{\"o} + \gdef^^f7{$\div$} + \gdef^^f8{\o} + \gdef^^f9{\`u} + \gdef^^fa{\'u} + \gdef^^fb{\^u} + \gdef^^fc{\"u} + \gdef^^fd{\'y} + \gdef^^fe{\th} + \gdef^^ff{\"y} +} + +% Latin9 (ISO-8859-15) encoding character definitions. +\def\latninechardefs{% + % Encoding is almost identical to Latin1. + \latonechardefs + % + \gdef^^a4{\euro} + \gdef^^a6{\v S} + \gdef^^a8{\v s} + \gdef^^b4{\v Z} + \gdef^^b8{\v z} + \gdef^^bc{\OE} + \gdef^^bd{\oe} + \gdef^^be{\"Y} +} + +% Latin2 (ISO-8859-2) character definitions. +\def\lattwochardefs{% + \gdef^^a0{\tie} + \gdef^^a1{\ogonek{A}} + \gdef^^a2{\u{}} + \gdef^^a3{\L} + \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} + \gdef^^a5{\v L} + \gdef^^a6{\'S} + \gdef^^a7{\S} + \gdef^^a8{\"{}} + \gdef^^a9{\v S} + \gdef^^aa{\cedilla S} + \gdef^^ab{\v T} + \gdef^^ac{\'Z} + \gdef^^ad{\-} + \gdef^^ae{\v Z} + \gdef^^af{\dotaccent Z} + % + \gdef^^b0{\textdegree} + \gdef^^b1{\ogonek{a}} + \gdef^^b2{\ogonek{ }} + \gdef^^b3{\l} + \gdef^^b4{\'{}} + \gdef^^b5{\v l} + \gdef^^b6{\'s} + \gdef^^b7{\v{}} + \gdef^^b8{\cedilla\ } + \gdef^^b9{\v s} + \gdef^^ba{\cedilla s} + \gdef^^bb{\v t} + \gdef^^bc{\'z} + \gdef^^bd{\H{}} + \gdef^^be{\v z} + \gdef^^bf{\dotaccent z} + % + \gdef^^c0{\'R} + \gdef^^c1{\'A} + \gdef^^c2{\^A} + \gdef^^c3{\u A} + \gdef^^c4{\"A} + \gdef^^c5{\'L} + \gdef^^c6{\'C} + \gdef^^c7{\cedilla C} + \gdef^^c8{\v C} + \gdef^^c9{\'E} + \gdef^^ca{\ogonek{E}} + \gdef^^cb{\"E} + \gdef^^cc{\v E} + \gdef^^cd{\'I} + \gdef^^ce{\^I} + \gdef^^cf{\v D} + % + \gdef^^d0{\DH} + \gdef^^d1{\'N} + \gdef^^d2{\v N} + \gdef^^d3{\'O} + \gdef^^d4{\^O} + \gdef^^d5{\H O} + \gdef^^d6{\"O} + \gdef^^d7{$\times$} + \gdef^^d8{\v R} + \gdef^^d9{\ringaccent U} + \gdef^^da{\'U} + \gdef^^db{\H U} + \gdef^^dc{\"U} + \gdef^^dd{\'Y} + \gdef^^de{\cedilla T} + \gdef^^df{\ss} + % + \gdef^^e0{\'r} + \gdef^^e1{\'a} + \gdef^^e2{\^a} + \gdef^^e3{\u a} + \gdef^^e4{\"a} + \gdef^^e5{\'l} + \gdef^^e6{\'c} + \gdef^^e7{\cedilla c} + \gdef^^e8{\v c} + \gdef^^e9{\'e} + \gdef^^ea{\ogonek{e}} + \gdef^^eb{\"e} + \gdef^^ec{\v e} + \gdef^^ed{\'{\dotless{i}}} + \gdef^^ee{\^{\dotless{i}}} + \gdef^^ef{\v d} + % + \gdef^^f0{\dh} + \gdef^^f1{\'n} + \gdef^^f2{\v n} + \gdef^^f3{\'o} + \gdef^^f4{\^o} + \gdef^^f5{\H o} + \gdef^^f6{\"o} + \gdef^^f7{$\div$} + \gdef^^f8{\v r} + \gdef^^f9{\ringaccent u} + \gdef^^fa{\'u} + \gdef^^fb{\H u} + \gdef^^fc{\"u} + \gdef^^fd{\'y} + \gdef^^fe{\cedilla t} + \gdef^^ff{\dotaccent{}} +} + +% UTF-8 character definitions. +% +% This code to support UTF-8 is based on LaTeX's utf8.def, with some +% changes for Texinfo conventions. It is included here under the GPL by +% permission from Frank Mittelbach and the LaTeX team. +% +\newcount\countUTFx +\newcount\countUTFy +\newcount\countUTFz + +\gdef\UTFviiiTwoOctets#1#2{\expandafter + \UTFviiiDefined\csname u8:#1\string #2\endcsname} +% +\gdef\UTFviiiThreeOctets#1#2#3{\expandafter + \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} +% +\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter + \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} + +\gdef\UTFviiiDefined#1{% + \ifx #1\relax + \message{\linenumber Unicode char \string #1 not defined for Texinfo}% + \else + \expandafter #1% + \fi +} + +\begingroup + \catcode`\~13 + \catcode`\"12 + + \def\UTFviiiLoop{% + \global\catcode\countUTFx\active + \uccode`\~\countUTFx + \uppercase\expandafter{\UTFviiiTmp}% + \advance\countUTFx by 1 + \ifnum\countUTFx < \countUTFy + \expandafter\UTFviiiLoop + \fi} + + \countUTFx = "C2 + \countUTFy = "E0 + \def\UTFviiiTmp{% + \xdef~{\noexpand\UTFviiiTwoOctets\string~}} + \UTFviiiLoop + + \countUTFx = "E0 + \countUTFy = "F0 + \def\UTFviiiTmp{% + \xdef~{\noexpand\UTFviiiThreeOctets\string~}} + \UTFviiiLoop + + \countUTFx = "F0 + \countUTFy = "F4 + \def\UTFviiiTmp{% + \xdef~{\noexpand\UTFviiiFourOctets\string~}} + \UTFviiiLoop +\endgroup + +\begingroup + \catcode`\"=12 + \catcode`\<=12 + \catcode`\.=12 + \catcode`\,=12 + \catcode`\;=12 + \catcode`\!=12 + \catcode`\~=13 + + \gdef\DeclareUnicodeCharacter#1#2{% + \countUTFz = "#1\relax + %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% + \begingroup + \parseXMLCharref + \def\UTFviiiTwoOctets##1##2{% + \csname u8:##1\string ##2\endcsname}% + \def\UTFviiiThreeOctets##1##2##3{% + \csname u8:##1\string ##2\string ##3\endcsname}% + \def\UTFviiiFourOctets##1##2##3##4{% + \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \gdef\UTFviiiTmp{#2}% + \endgroup} + + \gdef\parseXMLCharref{% + \ifnum\countUTFz < "A0\relax + \errhelp = \EMsimple + \errmessage{Cannot define Unicode char value < 00A0}% + \else\ifnum\countUTFz < "800\relax + \parseUTFviiiA,% + \parseUTFviiiB C\UTFviiiTwoOctets.,% + \else\ifnum\countUTFz < "10000\relax + \parseUTFviiiA;% + \parseUTFviiiA,% + \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% + \else + \parseUTFviiiA;% + \parseUTFviiiA,% + \parseUTFviiiA!% + \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% + \fi\fi\fi + } + + \gdef\parseUTFviiiA#1{% + \countUTFx = \countUTFz + \divide\countUTFz by 64 + \countUTFy = \countUTFz + \multiply\countUTFz by 64 + \advance\countUTFx by -\countUTFz + \advance\countUTFx by 128 + \uccode `#1\countUTFx + \countUTFz = \countUTFy} + + \gdef\parseUTFviiiB#1#2#3#4{% + \advance\countUTFz by "#10\relax + \uccode `#3\countUTFz + \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} +\endgroup + +\def\utfeightchardefs{% + \DeclareUnicodeCharacter{00A0}{\tie} + \DeclareUnicodeCharacter{00A1}{\exclamdown} + \DeclareUnicodeCharacter{00A3}{\pounds} + \DeclareUnicodeCharacter{00A8}{\"{ }} + \DeclareUnicodeCharacter{00A9}{\copyright} + \DeclareUnicodeCharacter{00AA}{\ordf} + \DeclareUnicodeCharacter{00AB}{\guillemetleft} + \DeclareUnicodeCharacter{00AD}{\-} + \DeclareUnicodeCharacter{00AE}{\registeredsymbol} + \DeclareUnicodeCharacter{00AF}{\={ }} + + \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} + \DeclareUnicodeCharacter{00B4}{\'{ }} + \DeclareUnicodeCharacter{00B8}{\cedilla{ }} + \DeclareUnicodeCharacter{00BA}{\ordm} + \DeclareUnicodeCharacter{00BB}{\guillemetright} + \DeclareUnicodeCharacter{00BF}{\questiondown} + + \DeclareUnicodeCharacter{00C0}{\`A} + \DeclareUnicodeCharacter{00C1}{\'A} + \DeclareUnicodeCharacter{00C2}{\^A} + \DeclareUnicodeCharacter{00C3}{\~A} + \DeclareUnicodeCharacter{00C4}{\"A} + \DeclareUnicodeCharacter{00C5}{\AA} + \DeclareUnicodeCharacter{00C6}{\AE} + \DeclareUnicodeCharacter{00C7}{\cedilla{C}} + \DeclareUnicodeCharacter{00C8}{\`E} + \DeclareUnicodeCharacter{00C9}{\'E} + \DeclareUnicodeCharacter{00CA}{\^E} + \DeclareUnicodeCharacter{00CB}{\"E} + \DeclareUnicodeCharacter{00CC}{\`I} + \DeclareUnicodeCharacter{00CD}{\'I} + \DeclareUnicodeCharacter{00CE}{\^I} + \DeclareUnicodeCharacter{00CF}{\"I} + + \DeclareUnicodeCharacter{00D0}{\DH} + \DeclareUnicodeCharacter{00D1}{\~N} + \DeclareUnicodeCharacter{00D2}{\`O} + \DeclareUnicodeCharacter{00D3}{\'O} + \DeclareUnicodeCharacter{00D4}{\^O} + \DeclareUnicodeCharacter{00D5}{\~O} + \DeclareUnicodeCharacter{00D6}{\"O} + \DeclareUnicodeCharacter{00D8}{\O} + \DeclareUnicodeCharacter{00D9}{\`U} + \DeclareUnicodeCharacter{00DA}{\'U} + \DeclareUnicodeCharacter{00DB}{\^U} + \DeclareUnicodeCharacter{00DC}{\"U} + \DeclareUnicodeCharacter{00DD}{\'Y} + \DeclareUnicodeCharacter{00DE}{\TH} + \DeclareUnicodeCharacter{00DF}{\ss} + + \DeclareUnicodeCharacter{00E0}{\`a} + \DeclareUnicodeCharacter{00E1}{\'a} + \DeclareUnicodeCharacter{00E2}{\^a} + \DeclareUnicodeCharacter{00E3}{\~a} + \DeclareUnicodeCharacter{00E4}{\"a} + \DeclareUnicodeCharacter{00E5}{\aa} + \DeclareUnicodeCharacter{00E6}{\ae} + \DeclareUnicodeCharacter{00E7}{\cedilla{c}} + \DeclareUnicodeCharacter{00E8}{\`e} + \DeclareUnicodeCharacter{00E9}{\'e} + \DeclareUnicodeCharacter{00EA}{\^e} + \DeclareUnicodeCharacter{00EB}{\"e} + \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} + \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} + \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} + \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} + + \DeclareUnicodeCharacter{00F0}{\dh} + \DeclareUnicodeCharacter{00F1}{\~n} + \DeclareUnicodeCharacter{00F2}{\`o} + \DeclareUnicodeCharacter{00F3}{\'o} + \DeclareUnicodeCharacter{00F4}{\^o} + \DeclareUnicodeCharacter{00F5}{\~o} + \DeclareUnicodeCharacter{00F6}{\"o} + \DeclareUnicodeCharacter{00F8}{\o} + \DeclareUnicodeCharacter{00F9}{\`u} + \DeclareUnicodeCharacter{00FA}{\'u} + \DeclareUnicodeCharacter{00FB}{\^u} + \DeclareUnicodeCharacter{00FC}{\"u} + \DeclareUnicodeCharacter{00FD}{\'y} + \DeclareUnicodeCharacter{00FE}{\th} + \DeclareUnicodeCharacter{00FF}{\"y} + + \DeclareUnicodeCharacter{0100}{\=A} + \DeclareUnicodeCharacter{0101}{\=a} + \DeclareUnicodeCharacter{0102}{\u{A}} + \DeclareUnicodeCharacter{0103}{\u{a}} + \DeclareUnicodeCharacter{0104}{\ogonek{A}} + \DeclareUnicodeCharacter{0105}{\ogonek{a}} + \DeclareUnicodeCharacter{0106}{\'C} + \DeclareUnicodeCharacter{0107}{\'c} + \DeclareUnicodeCharacter{0108}{\^C} + \DeclareUnicodeCharacter{0109}{\^c} + \DeclareUnicodeCharacter{0118}{\ogonek{E}} + \DeclareUnicodeCharacter{0119}{\ogonek{e}} + \DeclareUnicodeCharacter{010A}{\dotaccent{C}} + \DeclareUnicodeCharacter{010B}{\dotaccent{c}} + \DeclareUnicodeCharacter{010C}{\v{C}} + \DeclareUnicodeCharacter{010D}{\v{c}} + \DeclareUnicodeCharacter{010E}{\v{D}} + + \DeclareUnicodeCharacter{0112}{\=E} + \DeclareUnicodeCharacter{0113}{\=e} + \DeclareUnicodeCharacter{0114}{\u{E}} + \DeclareUnicodeCharacter{0115}{\u{e}} + \DeclareUnicodeCharacter{0116}{\dotaccent{E}} + \DeclareUnicodeCharacter{0117}{\dotaccent{e}} + \DeclareUnicodeCharacter{011A}{\v{E}} + \DeclareUnicodeCharacter{011B}{\v{e}} + \DeclareUnicodeCharacter{011C}{\^G} + \DeclareUnicodeCharacter{011D}{\^g} + \DeclareUnicodeCharacter{011E}{\u{G}} + \DeclareUnicodeCharacter{011F}{\u{g}} + + \DeclareUnicodeCharacter{0120}{\dotaccent{G}} + \DeclareUnicodeCharacter{0121}{\dotaccent{g}} + \DeclareUnicodeCharacter{0124}{\^H} + \DeclareUnicodeCharacter{0125}{\^h} + \DeclareUnicodeCharacter{0128}{\~I} + \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} + \DeclareUnicodeCharacter{012A}{\=I} + \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} + \DeclareUnicodeCharacter{012C}{\u{I}} + \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} + + \DeclareUnicodeCharacter{0130}{\dotaccent{I}} + \DeclareUnicodeCharacter{0131}{\dotless{i}} + \DeclareUnicodeCharacter{0132}{IJ} + \DeclareUnicodeCharacter{0133}{ij} + \DeclareUnicodeCharacter{0134}{\^J} + \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} + \DeclareUnicodeCharacter{0139}{\'L} + \DeclareUnicodeCharacter{013A}{\'l} + + \DeclareUnicodeCharacter{0141}{\L} + \DeclareUnicodeCharacter{0142}{\l} + \DeclareUnicodeCharacter{0143}{\'N} + \DeclareUnicodeCharacter{0144}{\'n} + \DeclareUnicodeCharacter{0147}{\v{N}} + \DeclareUnicodeCharacter{0148}{\v{n}} + \DeclareUnicodeCharacter{014C}{\=O} + \DeclareUnicodeCharacter{014D}{\=o} + \DeclareUnicodeCharacter{014E}{\u{O}} + \DeclareUnicodeCharacter{014F}{\u{o}} + + \DeclareUnicodeCharacter{0150}{\H{O}} + \DeclareUnicodeCharacter{0151}{\H{o}} + \DeclareUnicodeCharacter{0152}{\OE} + \DeclareUnicodeCharacter{0153}{\oe} + \DeclareUnicodeCharacter{0154}{\'R} + \DeclareUnicodeCharacter{0155}{\'r} + \DeclareUnicodeCharacter{0158}{\v{R}} + \DeclareUnicodeCharacter{0159}{\v{r}} + \DeclareUnicodeCharacter{015A}{\'S} + \DeclareUnicodeCharacter{015B}{\'s} + \DeclareUnicodeCharacter{015C}{\^S} + \DeclareUnicodeCharacter{015D}{\^s} + \DeclareUnicodeCharacter{015E}{\cedilla{S}} + \DeclareUnicodeCharacter{015F}{\cedilla{s}} + + \DeclareUnicodeCharacter{0160}{\v{S}} + \DeclareUnicodeCharacter{0161}{\v{s}} + \DeclareUnicodeCharacter{0162}{\cedilla{t}} + \DeclareUnicodeCharacter{0163}{\cedilla{T}} + \DeclareUnicodeCharacter{0164}{\v{T}} + + \DeclareUnicodeCharacter{0168}{\~U} + \DeclareUnicodeCharacter{0169}{\~u} + \DeclareUnicodeCharacter{016A}{\=U} + \DeclareUnicodeCharacter{016B}{\=u} + \DeclareUnicodeCharacter{016C}{\u{U}} + \DeclareUnicodeCharacter{016D}{\u{u}} + \DeclareUnicodeCharacter{016E}{\ringaccent{U}} + \DeclareUnicodeCharacter{016F}{\ringaccent{u}} + + \DeclareUnicodeCharacter{0170}{\H{U}} + \DeclareUnicodeCharacter{0171}{\H{u}} + \DeclareUnicodeCharacter{0174}{\^W} + \DeclareUnicodeCharacter{0175}{\^w} + \DeclareUnicodeCharacter{0176}{\^Y} + \DeclareUnicodeCharacter{0177}{\^y} + \DeclareUnicodeCharacter{0178}{\"Y} + \DeclareUnicodeCharacter{0179}{\'Z} + \DeclareUnicodeCharacter{017A}{\'z} + \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} + \DeclareUnicodeCharacter{017C}{\dotaccent{z}} + \DeclareUnicodeCharacter{017D}{\v{Z}} + \DeclareUnicodeCharacter{017E}{\v{z}} + + \DeclareUnicodeCharacter{01C4}{D\v{Z}} + \DeclareUnicodeCharacter{01C5}{D\v{z}} + \DeclareUnicodeCharacter{01C6}{d\v{z}} + \DeclareUnicodeCharacter{01C7}{LJ} + \DeclareUnicodeCharacter{01C8}{Lj} + \DeclareUnicodeCharacter{01C9}{lj} + \DeclareUnicodeCharacter{01CA}{NJ} + \DeclareUnicodeCharacter{01CB}{Nj} + \DeclareUnicodeCharacter{01CC}{nj} + \DeclareUnicodeCharacter{01CD}{\v{A}} + \DeclareUnicodeCharacter{01CE}{\v{a}} + \DeclareUnicodeCharacter{01CF}{\v{I}} + + \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} + \DeclareUnicodeCharacter{01D1}{\v{O}} + \DeclareUnicodeCharacter{01D2}{\v{o}} + \DeclareUnicodeCharacter{01D3}{\v{U}} + \DeclareUnicodeCharacter{01D4}{\v{u}} + + \DeclareUnicodeCharacter{01E2}{\={\AE}} + \DeclareUnicodeCharacter{01E3}{\={\ae}} + \DeclareUnicodeCharacter{01E6}{\v{G}} + \DeclareUnicodeCharacter{01E7}{\v{g}} + \DeclareUnicodeCharacter{01E8}{\v{K}} + \DeclareUnicodeCharacter{01E9}{\v{k}} + + \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} + \DeclareUnicodeCharacter{01F1}{DZ} + \DeclareUnicodeCharacter{01F2}{Dz} + \DeclareUnicodeCharacter{01F3}{dz} + \DeclareUnicodeCharacter{01F4}{\'G} + \DeclareUnicodeCharacter{01F5}{\'g} + \DeclareUnicodeCharacter{01F8}{\`N} + \DeclareUnicodeCharacter{01F9}{\`n} + \DeclareUnicodeCharacter{01FC}{\'{\AE}} + \DeclareUnicodeCharacter{01FD}{\'{\ae}} + \DeclareUnicodeCharacter{01FE}{\'{\O}} + \DeclareUnicodeCharacter{01FF}{\'{\o}} + + \DeclareUnicodeCharacter{021E}{\v{H}} + \DeclareUnicodeCharacter{021F}{\v{h}} + + \DeclareUnicodeCharacter{0226}{\dotaccent{A}} + \DeclareUnicodeCharacter{0227}{\dotaccent{a}} + \DeclareUnicodeCharacter{0228}{\cedilla{E}} + \DeclareUnicodeCharacter{0229}{\cedilla{e}} + \DeclareUnicodeCharacter{022E}{\dotaccent{O}} + \DeclareUnicodeCharacter{022F}{\dotaccent{o}} + + \DeclareUnicodeCharacter{0232}{\=Y} + \DeclareUnicodeCharacter{0233}{\=y} + \DeclareUnicodeCharacter{0237}{\dotless{j}} + + \DeclareUnicodeCharacter{02DB}{\ogonek{ }} + + \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} + \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} + \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} + \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} + \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} + \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} + \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} + \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} + \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} + \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} + \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} + \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} + + \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} + \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} + + \DeclareUnicodeCharacter{1E20}{\=G} + \DeclareUnicodeCharacter{1E21}{\=g} + \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} + \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} + \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} + \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} + \DeclareUnicodeCharacter{1E26}{\"H} + \DeclareUnicodeCharacter{1E27}{\"h} + + \DeclareUnicodeCharacter{1E30}{\'K} + \DeclareUnicodeCharacter{1E31}{\'k} + \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} + \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} + \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} + \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} + \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} + \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} + \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} + \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} + \DeclareUnicodeCharacter{1E3E}{\'M} + \DeclareUnicodeCharacter{1E3F}{\'m} + + \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} + \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} + \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} + \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} + \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} + \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} + \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} + \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} + \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} + \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} + + \DeclareUnicodeCharacter{1E54}{\'P} + \DeclareUnicodeCharacter{1E55}{\'p} + \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} + \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} + \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} + \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} + \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} + \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} + \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} + \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} + + \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} + \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} + \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} + \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} + \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} + \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} + \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} + \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} + \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} + \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} + + \DeclareUnicodeCharacter{1E7C}{\~V} + \DeclareUnicodeCharacter{1E7D}{\~v} + \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} + \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} + + \DeclareUnicodeCharacter{1E80}{\`W} + \DeclareUnicodeCharacter{1E81}{\`w} + \DeclareUnicodeCharacter{1E82}{\'W} + \DeclareUnicodeCharacter{1E83}{\'w} + \DeclareUnicodeCharacter{1E84}{\"W} + \DeclareUnicodeCharacter{1E85}{\"w} + \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} + \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} + \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} + \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} + \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} + \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} + \DeclareUnicodeCharacter{1E8C}{\"X} + \DeclareUnicodeCharacter{1E8D}{\"x} + \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} + \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} + + \DeclareUnicodeCharacter{1E90}{\^Z} + \DeclareUnicodeCharacter{1E91}{\^z} + \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} + \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} + \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} + \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} + \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} + \DeclareUnicodeCharacter{1E97}{\"t} + \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} + \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} + + \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} + \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} + + \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} + \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} + \DeclareUnicodeCharacter{1EBC}{\~E} + \DeclareUnicodeCharacter{1EBD}{\~e} + + \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} + \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} + \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} + \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} + + \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} + \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} + + \DeclareUnicodeCharacter{1EF2}{\`Y} + \DeclareUnicodeCharacter{1EF3}{\`y} + \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} + + \DeclareUnicodeCharacter{1EF8}{\~Y} + \DeclareUnicodeCharacter{1EF9}{\~y} + + \DeclareUnicodeCharacter{2013}{--} + \DeclareUnicodeCharacter{2014}{---} + \DeclareUnicodeCharacter{2018}{\quoteleft} + \DeclareUnicodeCharacter{2019}{\quoteright} + \DeclareUnicodeCharacter{201A}{\quotesinglbase} + \DeclareUnicodeCharacter{201C}{\quotedblleft} + \DeclareUnicodeCharacter{201D}{\quotedblright} + \DeclareUnicodeCharacter{201E}{\quotedblbase} + \DeclareUnicodeCharacter{2022}{\bullet} + \DeclareUnicodeCharacter{2026}{\dots} + \DeclareUnicodeCharacter{2039}{\guilsinglleft} + \DeclareUnicodeCharacter{203A}{\guilsinglright} + \DeclareUnicodeCharacter{20AC}{\euro} + + \DeclareUnicodeCharacter{2192}{\expansion} + \DeclareUnicodeCharacter{21D2}{\result} + + \DeclareUnicodeCharacter{2212}{\minus} + \DeclareUnicodeCharacter{2217}{\point} + \DeclareUnicodeCharacter{2261}{\equiv} +}% end of \utfeightchardefs + + +% US-ASCII character definitions. +\def\asciichardefs{% nothing need be done + \relax +} + +% Make non-ASCII characters printable again for compatibility with +% existing Texinfo documents that may use them, even without declaring a +% document encoding. +% +\setnonasciicharscatcode \other + + +\message{formatting,} + +\newdimen\defaultparindent \defaultparindent = 15pt + +\chapheadingskip = 15pt plus 4pt minus 2pt +\secheadingskip = 12pt plus 3pt minus 2pt +\subsecheadingskip = 9pt plus 2pt minus 2pt + +% Prevent underfull vbox error messages. +\vbadness = 10000 + +% Don't be very finicky about underfull hboxes, either. +\hbadness = 6666 + +% Following George Bush, get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. We call this whenever the paper size is set. +% +\def\setemergencystretch{% + \ifx\emergencystretch\thisisundefined + % Allow us to assign to \emergencystretch anyway. + \def\emergencystretch{\dimen0}% + \else + \emergencystretch = .15\hsize + \fi +} + +% Parameters in order: 1) textheight; 2) textwidth; +% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; +% 7) physical page height; 8) physical page width. +% +% We also call \setleading{\textleading}, so the caller should define +% \textleading. The caller should also set \parskip. +% +\def\internalpagesizes#1#2#3#4#5#6#7#8{% + \voffset = #3\relax + \topskip = #6\relax + \splittopskip = \topskip + % + \vsize = #1\relax + \advance\vsize by \topskip + \outervsize = \vsize + \advance\outervsize by 2\topandbottommargin + \pageheight = \vsize + % + \hsize = #2\relax + \outerhsize = \hsize + \advance\outerhsize by 0.5in + \pagewidth = \hsize + % + \normaloffset = #4\relax + \bindingoffset = #5\relax + % + \ifpdf + \pdfpageheight #7\relax + \pdfpagewidth #8\relax + % if we don't reset these, they will remain at "1 true in" of + % whatever layout pdftex was dumped with. + \pdfhorigin = 1 true in + \pdfvorigin = 1 true in + \fi + % + \setleading{\textleading} + % + \parindent = \defaultparindent + \setemergencystretch +} + +% @letterpaper (the default). +\def\letterpaper{{\globaldefs = 1 + \parskip = 3pt plus 2pt minus 1pt + \textleading = 13.2pt + % + % If page is nothing but text, make it come out even. + \internalpagesizes{607.2pt}{6in}% that's 46 lines + {\voffset}{.25in}% + {\bindingoffset}{36pt}% + {11in}{8.5in}% +}} + +% Use @smallbook to reset parameters for 7x9.25 trim size. +\def\smallbook{{\globaldefs = 1 + \parskip = 2pt plus 1pt + \textleading = 12pt + % + \internalpagesizes{7.5in}{5in}% + {-.2in}{0in}% + {\bindingoffset}{16pt}% + {9.25in}{7in}% + % + \lispnarrowing = 0.3in + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = .5cm +}} + +% Use @smallerbook to reset parameters for 6x9 trim size. +% (Just testing, parameters still in flux.) +\def\smallerbook{{\globaldefs = 1 + \parskip = 1.5pt plus 1pt + \textleading = 12pt + % + \internalpagesizes{7.4in}{4.8in}% + {-.2in}{-.4in}% + {0pt}{14pt}% + {9in}{6in}% + % + \lispnarrowing = 0.25in + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = .4cm +}} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{{\globaldefs = 1 + \parskip = 3pt plus 2pt minus 1pt + \textleading = 13.2pt + % + % Double-side printing via postscript on Laserjet 4050 + % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. + % To change the settings for a different printer or situation, adjust + % \normaloffset until the front-side and back-side texts align. Then + % do the same for \bindingoffset. You can set these for testing in + % your texinfo source file like this: + % @tex + % \global\normaloffset = -6mm + % \global\bindingoffset = 10mm + % @end tex + \internalpagesizes{673.2pt}{160mm}% that's 51 lines + {\voffset}{\hoffset}% + {\bindingoffset}{44pt}% + {297mm}{210mm}% + % + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = 5mm +}} + +% Use @afivepaper to print on European A5 paper. +% From romildo@urano.iceb.ufop.br, 2 July 2000. +% He also recommends making @example and @lisp be small. +\def\afivepaper{{\globaldefs = 1 + \parskip = 2pt plus 1pt minus 0.1pt + \textleading = 12.5pt + % + \internalpagesizes{160mm}{120mm}% + {\voffset}{\hoffset}% + {\bindingoffset}{8pt}% + {210mm}{148mm}% + % + \lispnarrowing = 0.2in + \tolerance = 800 + \hfuzz = 1.2pt + \contentsrightmargin = 0pt + \defbodyindent = 2mm + \tableindent = 12mm +}} + +% A specific text layout, 24x15cm overall, intended for A4 paper. +\def\afourlatex{{\globaldefs = 1 + \afourpaper + \internalpagesizes{237mm}{150mm}% + {\voffset}{4.6mm}% + {\bindingoffset}{7mm}% + {297mm}{210mm}% + % + % Must explicitly reset to 0 because we call \afourpaper. + \globaldefs = 0 +}} + +% Use @afourwide to print on A4 paper in landscape format. +\def\afourwide{{\globaldefs = 1 + \afourpaper + \internalpagesizes{241mm}{165mm}% + {\voffset}{-2.95mm}% + {\bindingoffset}{7mm}% + {297mm}{210mm}% + \globaldefs = 0 +}} + +% @pagesizes TEXTHEIGHT[,TEXTWIDTH] +% Perhaps we should allow setting the margins, \topskip, \parskip, +% and/or leading, also. Or perhaps we should compute them somehow. +% +\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} +\def\pagesizesyyy#1,#2,#3\finish{{% + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi + \globaldefs = 1 + % + \parskip = 3pt plus 2pt minus 1pt + \setleading{\textleading}% + % + \dimen0 = #1\relax + \advance\dimen0 by \voffset + % + \dimen2 = \hsize + \advance\dimen2 by \normaloffset + % + \internalpagesizes{#1}{\hsize}% + {\voffset}{\normaloffset}% + {\bindingoffset}{44pt}% + {\dimen0}{\dimen2}% +}} + +% Set default to letter. +% +\letterpaper + + +\message{and turning on texinfo input format.} + +\def^^L{\par} % remove \outer, so ^L can appear in an @comment + +% DEL is a comment character, in case @c does not suffice. +\catcode`\^^? = 14 + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other \def\normaldoublequote{"} +\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix +\catcode`\+=\other \def\normalplus{+} +\catcode`\<=\other \def\normalless{<} +\catcode`\>=\other \def\normalgreater{>} +\catcode`\^=\other \def\normalcaret{^} +\catcode`\_=\other \def\normalunderscore{_} +\catcode`\|=\other \def\normalverticalbar{|} +\catcode`\~=\other \def\normaltilde{~} + +% This macro is used to make a character print one way in \tt +% (where it can probably be output as-is), and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} + +% Same as above, but check for italic font. Actually this also catches +% non-italic slanted fonts since it is impossible to distinguish them from +% italic fonts. But since this is only used by $ and it uses \sl anyway +% this is not a problem. +\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt\char34}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt\char126}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +\let\realunder=_ +% Subroutine for the previous macro. +\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } + +\catcode`\|=\active +\def|{{\tt\char124}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +\catcode`\$=\active +\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix + +% If a .fmt file is being used, characters that might appear in a file +% name cannot be active until we have parsed the command line. +% So turn them off again, and have \everyjob (or @setfilename) turn them on. +% \otherifyactive is called near the end of this file. +\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} + +% Used sometimes to turn off (effectively) the active characters even after +% parsing them. +\def\turnoffactive{% + \normalturnoffactive + \otherbackslash +} + +\catcode`\@=0 + +% \backslashcurfont outputs one backslash character in current font, +% as in \char`\\. +\global\chardef\backslashcurfont=`\\ +\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work + +% \realbackslash is an actual character `\' with catcode other, and +% \doublebackslash is two of them (for the pdf outlines). +{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} + +% In texinfo, backslash is an active character; it prints the backslash +% in fixed width font. +\catcode`\\=\active % @ for escape char from now on. + +% The story here is that in math mode, the \char of \backslashcurfont +% ends up printing the roman \ from the math symbol font (because \char +% in math mode uses the \mathcode, and plain.tex sets +% \mathcode`\\="026E). It seems better for @backslashchar{} to always +% print a typewriter backslash, hence we use an explicit \mathchar, +% which is the decimal equivalent of "715c (class 7, e.g., use \fam; +% ignored family value; char position "5C). We can't use " for the +% usual hex value because it has already been made active. +@def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} +@let@backslashchar = @normalbackslash % @backslashchar{} is for user documents. + +% On startup, @fixbackslash assigns: +% @let \ = @normalbackslash +% \rawbackslash defines an active \ to do \backslashcurfont. +% \otherbackslash defines an active \ to be a literal `\' character with +% catcode other. We switch back and forth between these. +@gdef@rawbackslash{@let\=@backslashcurfont} +@gdef@otherbackslash{@let\=@realbackslash} + +% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of +% the literal character `\'. Also revert - to its normal character, in +% case the active - from code has slipped in. +% +{@catcode`- = @active + @gdef@normalturnoffactive{% + @let-=@normaldash + @let"=@normaldoublequote + @let$=@normaldollar %$ font-lock fix + @let+=@normalplus + @let<=@normalless + @let>=@normalgreater + @let\=@normalbackslash + @let^=@normalcaret + @let_=@normalunderscore + @let|=@normalverticalbar + @let~=@normaltilde + @markupsetuplqdefault + @markupsetuprqdefault + @unsepspaces + } +} + +% Make _ and + \other characters, temporarily. +% This is canceled by @fixbackslash. +@otherifyactive + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\' in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% Also turn back on active characters that might appear in the input +% file name, in case not using a pre-dumped format. +% +@gdef@fixbackslash{% + @ifx\@eatinput @let\ = @normalbackslash @fi + @catcode`+=@active + @catcode`@_=@active +} + +% Say @foo, not \foo, in error messages. +@escapechar = `@@ + +% These (along with & and #) are made active for url-breaking, so need +% active definitions as the normal characters. +@def@normaldot{.} +@def@normalquest{?} +@def@normalslash{/} + +% These look ok in all fonts, so just make them not special. +% @hashchar{} gets its own user-level command, because of #line. +@catcode`@& = @other @def@normalamp{&} +@catcode`@# = @other @def@normalhash{#} +@catcode`@% = @other @def@normalpercent{%} + +@let @hashchar = @normalhash + +@c Finally, make ` and ' active, so that txicodequoteundirected and +@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we +@c don't make ` and ' active, @code will not get them as active chars. +@c Do this last of all since we use ` in the previous @catcode assignments. +@catcode`@'=@active +@catcode`@`=@active +@markupsetuplqdefault +@markupsetuprqdefault + +@c Local variables: +@c eval: (add-hook 'write-file-hooks 'time-stamp) +@c page-delimiter: "^\\\\message" +@c time-stamp-start: "def\\\\texinfoversion{" +@c time-stamp-format: "%:y-%02m-%02d.%02H" +@c time-stamp-end: "}" +@c End: + +@c vim:sw=2: + +@ignore + arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 +@end ignore diff --git a/user/mpy/lib/libm/acoshf.c b/user/mpy/lib/libm/acoshf.c new file mode 100644 index 0000000..8a8409f --- /dev/null +++ b/user/mpy/lib/libm/acoshf.c @@ -0,0 +1,32 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// acoshf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +#include "libm.h" + +#if FLT_EVAL_METHOD==2 +#undef sqrtf +#define sqrtf sqrtl +#elif FLT_EVAL_METHOD==1 +#undef sqrtf +#define sqrtf sqrt +#endif + +/* acosh(x) = log(x + sqrt(x*x-1)) */ +float acoshf(float x) +{ + union {float f; uint32_t i;} u = {x}; + uint32_t a = u.i & 0x7fffffff; + + if (a < 0x3f800000+(1<<23)) + /* |x| < 2, invalid if x < 1 or nan */ + /* up to 2ulp error in [1,1.125] */ + return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1))); + if (a < 0x3f800000+(12<<23)) + /* |x| < 0x1p12 */ + return logf(2*x - 1/(x+sqrtf(x*x-1))); + /* x >= 0x1p12 */ + return logf(x) + 0.693147180559945309417232121458176568f; +} diff --git a/user/mpy/lib/libm/asinfacosf.c b/user/mpy/lib/libm/asinfacosf.c new file mode 100644 index 0000000..07ecad3 --- /dev/null +++ b/user/mpy/lib/libm/asinfacosf.c @@ -0,0 +1,130 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// asinf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/e_asinf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "libm.h" + +// dpgeorge: pio2 was double in original implementation of asinf +static const float +pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ +pio2_lo = 7.5497894159e-08; /* 0x33a22168 */ + +static const float +/* coefficients for R(x^2) */ +pS0 = 1.6666586697e-01, +pS1 = -4.2743422091e-02, +pS2 = -8.6563630030e-03, +qS1 = -7.0662963390e-01; + +static float R(float z) +{ + float_t p, q; + p = z*(pS0+z*(pS1+z*pS2)); + q = 1.0f+z*qS1; + return p/q; +} + +float asinf(float x) +{ + // dpgeorge: s was double in original implementation + float s,z; + uint32_t hx,ix; + + GET_FLOAT_WORD(hx, x); + ix = hx & 0x7fffffff; + if (ix >= 0x3f800000) { /* |x| >= 1 */ + if (ix == 0x3f800000) /* |x| == 1 */ + return x*pio2_hi + 0x1p-120f; /* asin(+-1) = +-pi/2 with inexact */ + return 0/(x-x); /* asin(|x|>1) is NaN */ + } + if (ix < 0x3f000000) { /* |x| < 0.5 */ + /* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */ + if (ix < 0x39800000 && ix >= 0x00800000) + return x; + return x + x*R(x*x); + } + /* 1 > |x| >= 0.5 */ + z = (1 - fabsf(x))*0.5f; + s = sqrtf(z); + x = pio2_hi - (2*(s+s*R(z)) - pio2_lo); // dpgeorge: use pio2_hi and pio2_lo + if (hx >> 31) + return -x; + return x; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// acosf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/e_acosf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +float acosf(float x) +{ + float z,w,s,c,df; + uint32_t hx,ix; + + GET_FLOAT_WORD(hx, x); + ix = hx & 0x7fffffff; + /* |x| >= 1 or nan */ + if (ix >= 0x3f800000) { + if (ix == 0x3f800000) { + if (hx >> 31) + return 2*pio2_hi + 0x1p-120f; + return 0; + } + return 0/(x-x); + } + /* |x| < 0.5 */ + if (ix < 0x3f000000) { + if (ix <= 0x32800000) /* |x| < 2**-26 */ + return pio2_hi + 0x1p-120f; + return pio2_hi - (x - (pio2_lo-x*R(x*x))); + } + /* x < -0.5 */ + if (hx >> 31) { + z = (1+x)*0.5f; + s = sqrtf(z); + w = R(z)*s-pio2_lo; + return 2*(pio2_hi - (s+w)); + } + /* x > 0.5 */ + z = (1-x)*0.5f; + s = sqrtf(z); + GET_FLOAT_WORD(hx,s); + SET_FLOAT_WORD(df,hx&0xfffff000); + c = (z-df*df)/(s+df); + w = R(z)*s+c; + return 2*(df+w); +} diff --git a/user/mpy/lib/libm/asinhf.c b/user/mpy/lib/libm/asinhf.c new file mode 100644 index 0000000..4bcb3f9 --- /dev/null +++ b/user/mpy/lib/libm/asinhf.c @@ -0,0 +1,34 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// asinhf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +#include "libm.h" + +/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ +float asinhf(float x) +{ + union {float f; uint32_t i;} u = {.f = x}; + uint32_t i = u.i & 0x7fffffff; + unsigned s = u.i >> 31; + + /* |x| */ + u.i = i; + x = u.f; + + if (i >= 0x3f800000 + (12<<23)) { + /* |x| >= 0x1p12 or inf or nan */ + x = logf(x) + 0.693147180559945309417232121458176568f; + } else if (i >= 0x3f800000 + (1<<23)) { + /* |x| >= 2 */ + x = logf(2*x + 1/(sqrtf(x*x+1)+x)); + } else if (i >= 0x3f800000 - (12<<23)) { + /* |x| >= 0x1p-12, up to 1.6ulp error in [0.125,0.5] */ + x = log1pf(x + x*x/(sqrtf(x*x+1)+1)); + } else { + /* |x| < 0x1p-12, raise inexact if x!=0 */ + FORCE_EVAL(x + 0x1p120f); + } + return s ? -x : x; +} diff --git a/user/mpy/lib/libm/atan2f.c b/user/mpy/lib/libm/atan2f.c new file mode 100644 index 0000000..03d000c --- /dev/null +++ b/user/mpy/lib/libm/atan2f.c @@ -0,0 +1,89 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// atan2f from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2f.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "libm.h" + +static const float +pi = 3.1415927410e+00, /* 0x40490fdb */ +pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */ + +float atan2f(float y, float x) +{ + float z; + uint32_t m,ix,iy; + + if (isnan(x) || isnan(y)) + return x+y; + GET_FLOAT_WORD(ix, x); + GET_FLOAT_WORD(iy, y); + if (ix == 0x3f800000) /* x=1.0 */ + return atanf(y); + m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ + ix &= 0x7fffffff; + iy &= 0x7fffffff; + + /* when y = 0 */ + if (iy == 0) { + switch (m) { + case 0: + case 1: return y; /* atan(+-0,+anything)=+-0 */ + case 2: return pi; /* atan(+0,-anything) = pi */ + case 3: return -pi; /* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if (ix == 0) + return m&1 ? -pi/2 : pi/2; + /* when x is INF */ + if (ix == 0x7f800000) { + if (iy == 0x7f800000) { + switch (m) { + case 0: return pi/4; /* atan(+INF,+INF) */ + case 1: return -pi/4; /* atan(-INF,+INF) */ + case 2: return 3*pi/4; /*atan(+INF,-INF)*/ + case 3: return -3*pi/4; /*atan(-INF,-INF)*/ + } + } else { + switch (m) { + case 0: return 0.0f; /* atan(+...,+INF) */ + case 1: return -0.0f; /* atan(-...,+INF) */ + case 2: return pi; /* atan(+...,-INF) */ + case 3: return -pi; /* atan(-...,-INF) */ + } + } + } + /* |y/x| > 0x1p26 */ + if (ix+(26<<23) < iy || iy == 0x7f800000) + return m&1 ? -pi/2 : pi/2; + + /* z = atan(|y/x|) with correct underflow */ + if ((m&2) && iy+(26<<23) < ix) /*|y/x| < 0x1p-26, x < 0 */ + z = 0.0; + else + z = atanf(fabsf(y/x)); + switch (m) { + case 0: return z; /* atan(+,+) */ + case 1: return -z; /* atan(-,+) */ + case 2: return pi - (z-pi_lo); /* atan(+,-) */ + default: /* case 3 */ + return (z-pi_lo) - pi; /* atan(-,-) */ + } +} diff --git a/user/mpy/lib/libm/atanf.c b/user/mpy/lib/libm/atanf.c new file mode 100644 index 0000000..053fc1b --- /dev/null +++ b/user/mpy/lib/libm/atanf.c @@ -0,0 +1,100 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// atanf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/s_atanf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#include "libm.h" + +static const float atanhi[] = { + 4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */ + 7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */ + 9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */ + 1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */ +}; + +static const float atanlo[] = { + 5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */ + 3.7748947079e-08, /* atan(1.0)lo 0x33222168 */ + 3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */ + 7.5497894159e-08, /* atan(inf)lo 0x33a22168 */ +}; + +static const float aT[] = { + 3.3333328366e-01, + -1.9999158382e-01, + 1.4253635705e-01, + -1.0648017377e-01, + 6.1687607318e-02, +}; + +float atanf(float x) +{ + float_t w,s1,s2,z; + uint32_t ix,sign; + int id; + + GET_FLOAT_WORD(ix, x); + sign = ix>>31; + ix &= 0x7fffffff; + if (ix >= 0x4c800000) { /* if |x| >= 2**26 */ + if (isnan(x)) + return x; + z = atanhi[3] + 0x1p-120f; + return sign ? -z : z; + } + if (ix < 0x3ee00000) { /* |x| < 0.4375 */ + if (ix < 0x39800000) { /* |x| < 2**-12 */ + if (ix < 0x00800000) + /* raise underflow for subnormal x */ + FORCE_EVAL(x*x); + return x; + } + id = -1; + } else { + x = fabsf(x); + if (ix < 0x3f980000) { /* |x| < 1.1875 */ + if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */ + id = 0; + x = (2.0f*x - 1.0f)/(2.0f + x); + } else { /* 11/16 <= |x| < 19/16 */ + id = 1; + x = (x - 1.0f)/(x + 1.0f); + } + } else { + if (ix < 0x401c0000) { /* |x| < 2.4375 */ + id = 2; + x = (x - 1.5f)/(1.0f + 1.5f*x); + } else { /* 2.4375 <= |x| < 2**26 */ + id = 3; + x = -1.0f/x; + } + } + } + /* end of argument reduction */ + z = x*x; + w = z*z; + /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ + s1 = z*(aT[0]+w*(aT[2]+w*aT[4])); + s2 = w*(aT[1]+w*aT[3]); + if (id < 0) + return x - x*(s1+s2); + z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); + return sign ? -z : z; +} diff --git a/user/mpy/lib/libm/atanhf.c b/user/mpy/lib/libm/atanhf.c new file mode 100644 index 0000000..6f95f49 --- /dev/null +++ b/user/mpy/lib/libm/atanhf.c @@ -0,0 +1,34 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// atanhf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +#include "libm.h" + +/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ +float atanhf(float x) +{ + union {float f; uint32_t i;} u = {.f = x}; + unsigned s = u.i >> 31; + float_t y; + + /* |x| */ + u.i &= 0x7fffffff; + y = u.f; + + if (u.i < 0x3f800000 - (1<<23)) { + if (u.i < 0x3f800000 - (32<<23)) { + /* handle underflow */ + if (u.i < (1<<23)) + FORCE_EVAL((float)(y*y)); + } else { + /* |x| < 0.5, up to 1.7ulp error */ + y = 0.5f*log1pf(2*y + 2*y*y/(1-y)); + } + } else { + /* avoid overflow */ + y = 0.5f*log1pf(2*(y/(1-y))); + } + return s ? -y : y; +} diff --git a/user/mpy/lib/libm/ef_rem_pio2.c b/user/mpy/lib/libm/ef_rem_pio2.c new file mode 100644 index 0000000..ca55243 --- /dev/null +++ b/user/mpy/lib/libm/ef_rem_pio2.c @@ -0,0 +1,202 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* ef_rem_pio2.c -- float version of e_rem_pio2.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* __ieee754_rem_pio2f(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] + * use __kernel_rem_pio2f() + */ + +#include "fdlibm.h" + +/* + * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi + */ +#ifdef __STDC__ +static const __int32_t two_over_pi[] = { +#else +static __int32_t two_over_pi[] = { +#endif +0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC, +0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62, +0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63, +0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A, +0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09, +0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29, +0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44, +0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41, +0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C, +0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8, +0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11, +0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF, +0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E, +0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5, +0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92, +0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08, +0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0, +0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3, +0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85, +0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80, +0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA, +0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B, +}; + +/* This array is like the one in e_rem_pio2.c, but the numbers are + single precision and the last 8 bits are forced to 0. */ +#ifdef __STDC__ +static const __int32_t npio2_hw[] = { +#else +static __int32_t npio2_hw[] = { +#endif +0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00, +0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00, +0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100, +0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00, +0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00, +0x4242c700, 0x42490f00 +}; + +/* + * invpio2: 24 bits of 2/pi + * pio2_1: first 17 bit of pi/2 + * pio2_1t: pi/2 - pio2_1 + * pio2_2: second 17 bit of pi/2 + * pio2_2t: pi/2 - (pio2_1+pio2_2) + * pio2_3: third 17 bit of pi/2 + * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) + */ + +#ifdef __STDC__ +static const float +#else +static float +#endif +zero = 0.0000000000e+00, /* 0x00000000 */ +half = 5.0000000000e-01, /* 0x3f000000 */ +two8 = 2.5600000000e+02, /* 0x43800000 */ +invpio2 = 6.3661980629e-01, /* 0x3f22f984 */ +pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */ +pio2_1t = 1.0804334124e-05, /* 0x37354443 */ +pio2_2 = 1.0804273188e-05, /* 0x37354400 */ +pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */ +pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */ +pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ + +#ifdef __STDC__ + __int32_t __ieee754_rem_pio2f(float x, float *y) +#else + __int32_t __ieee754_rem_pio2f(x,y) + float x,y[]; +#endif +{ + float z,w,t,r,fn; + float tx[3]; + __int32_t i,j,n,ix,hx; + int e0,nx; + + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */ + {y[0] = x; y[1] = 0; return 0;} + if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */ + if(hx>0) { + z = x - pio2_1; + if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ + y[0] = z - pio2_1t; + y[1] = (z-y[0])-pio2_1t; + } else { /* near pi/2, use 24+24+24 bit pi */ + z -= pio2_2; + y[0] = z - pio2_2t; + y[1] = (z-y[0])-pio2_2t; + } + return 1; + } else { /* negative x */ + z = x + pio2_1; + if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ + y[0] = z + pio2_1t; + y[1] = (z-y[0])+pio2_1t; + } else { /* near pi/2, use 24+24+24 bit pi */ + z += pio2_2; + y[0] = z + pio2_2t; + y[1] = (z-y[0])+pio2_2t; + } + return -1; + } + } + if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */ + t = fabsf(x); + n = (__int32_t) (t*invpio2+half); + fn = (float)n; + r = t-fn*pio2_1; + w = fn*pio2_1t; /* 1st round good to 40 bit */ + if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) { + y[0] = r-w; /* quick check no cancellation */ + } else { + __uint32_t high; + j = ix>>23; + y[0] = r-w; + GET_FLOAT_WORD(high,y[0]); + i = j-((high>>23)&0xff); + if(i>8) { /* 2nd iteration needed, good to 57 */ + t = r; + w = fn*pio2_2; + r = t-w; + w = fn*pio2_2t-((t-r)-w); + y[0] = r-w; + GET_FLOAT_WORD(high,y[0]); + i = j-((high>>23)&0xff); + if(i>25) { /* 3rd iteration need, 74 bits acc */ + t = r; /* will cover all possible cases */ + w = fn*pio2_3; + r = t-w; + w = fn*pio2_3t-((t-r)-w); + y[0] = r-w; + } + } + } + y[1] = (r-y[0])-w; + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + else return n; + } + /* + * all other (large) arguments + */ + if(!FLT_UWORD_IS_FINITE(ix)) { + y[0]=y[1]=x-x; return 0; + } + /* set z = scalbn(|x|,ilogb(x)-7) */ + e0 = (int)((ix>>23)-134); /* e0 = ilogb(z)-7; */ + SET_FLOAT_WORD(z, ix - ((__int32_t)e0<<23)); + for(i=0;i<2;i++) { + tx[i] = (float)((__int32_t)(z)); + z = (z-tx[i])*two8; + } + tx[2] = z; + nx = 3; + while(tx[nx-1]==zero) nx--; /* skip zero term */ + n = __kernel_rem_pio2f(tx,y,e0,nx,2,two_over_pi); + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + return n; +} diff --git a/user/mpy/lib/libm/ef_sqrt.c b/user/mpy/lib/libm/ef_sqrt.c new file mode 100644 index 0000000..87484d0 --- /dev/null +++ b/user/mpy/lib/libm/ef_sqrt.c @@ -0,0 +1,102 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* ef_sqrtf.c -- float version of e_sqrt.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0, tiny=1.0e-30; +#else +static float one = 1.0, tiny=1.0e-30; +#endif + +// sqrtf is exactly __ieee754_sqrtf when _IEEE_LIBM defined +float sqrtf(float x) +/* +#ifdef __STDC__ + float __ieee754_sqrtf(float x) +#else + float __ieee754_sqrtf(x) + float x; +#endif +*/ +{ + float z; + __uint32_t r,hx; + __int32_t ix,s,q,m,t,i; + + GET_FLOAT_WORD(ix,x); + hx = ix&0x7fffffff; + + /* take care of Inf and NaN */ + if(!FLT_UWORD_IS_FINITE(hx)) + return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf + sqrt(-inf)=sNaN */ + /* take care of zero and -ves */ + if(FLT_UWORD_IS_ZERO(hx)) return x;/* sqrt(+-0) = +-0 */ + if(ix<0) return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ + + /* normalize x */ + m = (ix>>23); + if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ + for(i=0;(ix&0x00800000L)==0;i++) ix<<=1; + m -= i-1; + } + m -= 127; /* unbias exponent */ + ix = (ix&0x007fffffL)|0x00800000L; + if(m&1) /* odd m, double x to make it even */ + ix += ix; + m >>= 1; /* m = [m/2] */ + + /* generate sqrt(x) bit by bit */ + ix += ix; + q = s = 0; /* q = sqrt(x) */ + r = 0x01000000L; /* r = moving bit from right to left */ + + while(r!=0) { + t = s+r; + if(t<=ix) { + s = t+r; + ix -= t; + q += r; + } + ix += ix; + r>>=1; + } + + /* use floating add to find out rounding direction */ + if(ix!=0) { + z = one-tiny; /* trigger inexact flag */ + if (z>=one) { + z = one+tiny; + if (z>one) + q += 2; + else + q += (q&1); + } + } + ix = (q>>1)+0x3f000000L; + ix += (m <<23); + SET_FLOAT_WORD(z,ix); + return z; +} diff --git a/user/mpy/lib/libm/erf_lgamma.c b/user/mpy/lib/libm/erf_lgamma.c new file mode 100644 index 0000000..877816a --- /dev/null +++ b/user/mpy/lib/libm/erf_lgamma.c @@ -0,0 +1,255 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* erf_lgamma.c -- float version of er_lgamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#include "fdlibm.h" + +#define __ieee754_logf logf + +#ifdef __STDC__ +static const float +#else +static float +#endif +two23= 8.3886080000e+06, /* 0x4b000000 */ +half= 5.0000000000e-01, /* 0x3f000000 */ +one = 1.0000000000e+00, /* 0x3f800000 */ +pi = 3.1415927410e+00, /* 0x40490fdb */ +a0 = 7.7215664089e-02, /* 0x3d9e233f */ +a1 = 3.2246702909e-01, /* 0x3ea51a66 */ +a2 = 6.7352302372e-02, /* 0x3d89f001 */ +a3 = 2.0580807701e-02, /* 0x3ca89915 */ +a4 = 7.3855509982e-03, /* 0x3bf2027e */ +a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */ +a6 = 1.1927076848e-03, /* 0x3a9c54a1 */ +a7 = 5.1006977446e-04, /* 0x3a05b634 */ +a8 = 2.2086278477e-04, /* 0x39679767 */ +a9 = 1.0801156895e-04, /* 0x38e28445 */ +a10 = 2.5214456400e-05, /* 0x37d383a2 */ +a11 = 4.4864096708e-05, /* 0x383c2c75 */ +tc = 1.4616321325e+00, /* 0x3fbb16c3 */ +tf = -1.2148628384e-01, /* 0xbdf8cdcd */ +/* tt = -(tail of tf) */ +tt = 6.6971006518e-09, /* 0x31e61c52 */ +t0 = 4.8383611441e-01, /* 0x3ef7b95e */ +t1 = -1.4758771658e-01, /* 0xbe17213c */ +t2 = 6.4624942839e-02, /* 0x3d845a15 */ +t3 = -3.2788541168e-02, /* 0xbd064d47 */ +t4 = 1.7970675603e-02, /* 0x3c93373d */ +t5 = -1.0314224288e-02, /* 0xbc28fcfe */ +t6 = 6.1005386524e-03, /* 0x3bc7e707 */ +t7 = -3.6845202558e-03, /* 0xbb7177fe */ +t8 = 2.2596477065e-03, /* 0x3b141699 */ +t9 = -1.4034647029e-03, /* 0xbab7f476 */ +t10 = 8.8108185446e-04, /* 0x3a66f867 */ +t11 = -5.3859531181e-04, /* 0xba0d3085 */ +t12 = 3.1563205994e-04, /* 0x39a57b6b */ +t13 = -3.1275415677e-04, /* 0xb9a3f927 */ +t14 = 3.3552918467e-04, /* 0x39afe9f7 */ +u0 = -7.7215664089e-02, /* 0xbd9e233f */ +u1 = 6.3282704353e-01, /* 0x3f2200f4 */ +u2 = 1.4549225569e+00, /* 0x3fba3ae7 */ +u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */ +u4 = 2.2896373272e-01, /* 0x3e6a7578 */ +u5 = 1.3381091878e-02, /* 0x3c5b3c5e */ +v1 = 2.4559779167e+00, /* 0x401d2ebe */ +v2 = 2.1284897327e+00, /* 0x4008392d */ +v3 = 7.6928514242e-01, /* 0x3f44efdf */ +v4 = 1.0422264785e-01, /* 0x3dd572af */ +v5 = 3.2170924824e-03, /* 0x3b52d5db */ +s0 = -7.7215664089e-02, /* 0xbd9e233f */ +s1 = 2.1498242021e-01, /* 0x3e5c245a */ +s2 = 3.2577878237e-01, /* 0x3ea6cc7a */ +s3 = 1.4635047317e-01, /* 0x3e15dce6 */ +s4 = 2.6642270386e-02, /* 0x3cda40e4 */ +s5 = 1.8402845599e-03, /* 0x3af135b4 */ +s6 = 3.1947532989e-05, /* 0x3805ff67 */ +r1 = 1.3920053244e+00, /* 0x3fb22d3b */ +r2 = 7.2193557024e-01, /* 0x3f38d0c5 */ +r3 = 1.7193385959e-01, /* 0x3e300f6e */ +r4 = 1.8645919859e-02, /* 0x3c98bf54 */ +r5 = 7.7794247773e-04, /* 0x3a4beed6 */ +r6 = 7.3266842264e-06, /* 0x36f5d7bd */ +w0 = 4.1893854737e-01, /* 0x3ed67f1d */ +w1 = 8.3333335817e-02, /* 0x3daaaaab */ +w2 = -2.7777778450e-03, /* 0xbb360b61 */ +w3 = 7.9365057172e-04, /* 0x3a500cfd */ +w4 = -5.9518753551e-04, /* 0xba1c065c */ +w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */ +w6 = -1.6309292987e-03; /* 0xbad5c4e8 */ + +#ifdef __STDC__ +static const float zero= 0.0000000000e+00; +#else +static float zero= 0.0000000000e+00; +#endif + +#ifdef __STDC__ + static float sin_pif(float x) +#else + static float sin_pif(x) + float x; +#endif +{ + float y,z; + __int32_t n,ix; + + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + + if(ix<0x3e800000) return __kernel_sinf(pi*x,zero,0); + y = -x; /* x is assume negative */ + + /* + * argument reduction, make sure inexact flag not raised if input + * is an integer + */ + z = floorf(y); + if(z!=y) { /* inexact anyway */ + y *= (float)0.5; + y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */ + n = (__int32_t) (y*(float)4.0); + } else { + if(ix>=0x4b800000) { + y = zero; n = 0; /* y must be even */ + } else { + if(ix<0x4b000000) z = y+two23; /* exact */ + GET_FLOAT_WORD(n,z); + n &= 1; + y = n; + n<<= 2; + } + } + switch (n) { + case 0: y = __kernel_sinf(pi*y,zero,0); break; + case 1: + case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break; + case 3: + case 4: y = __kernel_sinf(pi*(one-y),zero,0); break; + case 5: + case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break; + default: y = __kernel_sinf(pi*(y-(float)2.0),zero,0); break; + } + return -y; +} + + +#ifdef __STDC__ + float __ieee754_lgammaf_r(float x, int *signgamp) +#else + float __ieee754_lgammaf_r(x,signgamp) + float x; int *signgamp; +#endif +{ + float t,y,z,nadj = 0.0,p,p1,p2,p3,q,r,w; + __int32_t i,hx,ix; + + GET_FLOAT_WORD(hx,x); + + /* purge off +-inf, NaN, +-0, and negative arguments */ + *signgamp = 1; + ix = hx&0x7fffffff; + if(ix>=0x7f800000) return x*x; + if(ix==0) return one/zero; + if(ix<0x1c800000) { /* |x|<2**-70, return -log(|x|) */ + if(hx<0) { + *signgamp = -1; + return -__ieee754_logf(-x); + } else return -__ieee754_logf(x); + } + if(hx<0) { + if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */ + return one/zero; + t = sin_pif(x); + if(t==zero) return one/zero; /* -integer */ + nadj = __ieee754_logf(pi/fabsf(t*x)); + if(t=0x3f3b4a20) {y = one-x; i= 0;} + else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;} + else {y = x; i=2;} + } else { + r = zero; + if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */ + else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */ + else {y=x-one;i=2;} + } + switch(i) { + case 0: + z = y*y; + p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); + p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); + p = y*p1+p2; + r += (p-(float)0.5*y); break; + case 1: + z = y*y; + w = z*y; + p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ + p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); + p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); + p = z*p1-(tt-w*(p2+y*p3)); + r += (tf + p); break; + case 2: + p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); + p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); + r += (-(float)0.5*y + p1/p2); + } + } + else if(ix<0x41000000) { /* x < 8.0 */ + i = (__int32_t)x; + t = zero; + y = x-(float)i; + p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); + q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); + r = half*y+p/q; + z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ + switch(i) { + case 7: z *= (y+(float)6.0); /* FALLTHRU */ + case 6: z *= (y+(float)5.0); /* FALLTHRU */ + case 5: z *= (y+(float)4.0); /* FALLTHRU */ + case 4: z *= (y+(float)3.0); /* FALLTHRU */ + case 3: z *= (y+(float)2.0); /* FALLTHRU */ + r += __ieee754_logf(z); break; + } + /* 8.0 <= x < 2**58 */ + } else if (ix < 0x5c800000) { + t = __ieee754_logf(x); + z = one/x; + y = z*z; + w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); + r = (x-half)*(t-one)+w; + } else + /* 2**58 <= x <= inf */ + r = x*(__ieee754_logf(x)-one); + if(hx<0) r = nadj - r; + return r; +} diff --git a/user/mpy/lib/libm/fdlibm.h b/user/mpy/lib/libm/fdlibm.h new file mode 100644 index 0000000..ace3b2d --- /dev/null +++ b/user/mpy/lib/libm/fdlibm.h @@ -0,0 +1,227 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * This file is adapted from from newlib-nano-2, the newlib/libm/common/fdlib.h, + * available from https://github.com/32bitmicro/newlib-nano-2. The main change + * is removal of anything to do with double precision. + * + * Appropriate copyright headers are reproduced below. + */ + +/* @(#)fdlibm.h 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include + +/* Default to XOPEN_MODE. */ +#define _XOPEN_MODE + +/* Most routines need to check whether a float is finite, infinite, or not a + number, and many need to know whether the result of an operation will + overflow. These conditions depend on whether the largest exponent is + used for NaNs & infinities, or whether it's used for finite numbers. The + macros below wrap up that kind of information: + + FLT_UWORD_IS_FINITE(X) + True if a positive float with bitmask X is finite. + + FLT_UWORD_IS_NAN(X) + True if a positive float with bitmask X is not a number. + + FLT_UWORD_IS_INFINITE(X) + True if a positive float with bitmask X is +infinity. + + FLT_UWORD_MAX + The bitmask of FLT_MAX. + + FLT_UWORD_HALF_MAX + The bitmask of FLT_MAX/2. + + FLT_UWORD_EXP_MAX + The bitmask of the largest finite exponent (129 if the largest + exponent is used for finite numbers, 128 otherwise). + + FLT_UWORD_LOG_MAX + The bitmask of log(FLT_MAX), rounded down. This value is the largest + input that can be passed to exp() without producing overflow. + + FLT_UWORD_LOG_2MAX + The bitmask of log(2*FLT_MAX), rounded down. This value is the + largest input than can be passed to cosh() without producing + overflow. + + FLT_LARGEST_EXP + The largest biased exponent that can be used for finite numbers + (255 if the largest exponent is used for finite numbers, 254 + otherwise) */ + +#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL +#define FLT_UWORD_IS_FINITE(x) 1 +#define FLT_UWORD_IS_NAN(x) 0 +#define FLT_UWORD_IS_INFINITE(x) 0 +#define FLT_UWORD_MAX 0x7fffffff +#define FLT_UWORD_EXP_MAX 0x43010000 +#define FLT_UWORD_LOG_MAX 0x42b2d4fc +#define FLT_UWORD_LOG_2MAX 0x42b437e0 +#define HUGE ((float)0X1.FFFFFEP128) +#else +#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L) +#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L) +#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L) +#define FLT_UWORD_MAX 0x7f7fffffL +#define FLT_UWORD_EXP_MAX 0x43000000 +#define FLT_UWORD_LOG_MAX 0x42b17217 +#define FLT_UWORD_LOG_2MAX 0x42b2d4fc +#define HUGE ((float)3.40282346638528860e+38) +#endif +#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23)) +#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23) + +/* Many routines check for zero and subnormal numbers. Such things depend + on whether the target supports denormals or not: + + FLT_UWORD_IS_ZERO(X) + True if a positive float with bitmask X is +0. Without denormals, + any float with a zero exponent is a +0 representation. With + denormals, the only +0 representation is a 0 bitmask. + + FLT_UWORD_IS_SUBNORMAL(X) + True if a non-zero positive float with bitmask X is subnormal. + (Routines should check for zeros first.) + + FLT_UWORD_MIN + The bitmask of the smallest float above +0. Call this number + REAL_FLT_MIN... + + FLT_UWORD_EXP_MIN + The bitmask of the float representation of REAL_FLT_MIN's exponent. + + FLT_UWORD_LOG_MIN + The bitmask of |log(REAL_FLT_MIN)|, rounding down. + + FLT_SMALLEST_EXP + REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported, + -22 if they are). +*/ + +#ifdef _FLT_NO_DENORMALS +#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L) +#define FLT_UWORD_IS_SUBNORMAL(x) 0 +#define FLT_UWORD_MIN 0x00800000 +#define FLT_UWORD_EXP_MIN 0x42fc0000 +#define FLT_UWORD_LOG_MIN 0x42aeac50 +#define FLT_SMALLEST_EXP 1 +#else +#define FLT_UWORD_IS_ZERO(x) ((x)==0) +#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L) +#define FLT_UWORD_MIN 0x00000001 +#define FLT_UWORD_EXP_MIN 0x43160000 +#define FLT_UWORD_LOG_MIN 0x42cff1b5 +#define FLT_SMALLEST_EXP -22 +#endif + +#ifdef __STDC__ +#undef __P +#define __P(p) p +#else +#define __P(p) () +#endif + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in + * (one may replace the following line by "#include ") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +/* Functions that are not documented, and are not in . */ + +/* Undocumented float functions. */ +#ifdef _SCALB_INT +extern float scalbf __P((float, int)); +#else +extern float scalbf __P((float, float)); +#endif +extern float significandf __P((float)); + +/* ieee style elementary float functions */ +extern float __ieee754_sqrtf __P((float)); +extern float __ieee754_acosf __P((float)); +extern float __ieee754_acoshf __P((float)); +extern float __ieee754_logf __P((float)); +extern float __ieee754_atanhf __P((float)); +extern float __ieee754_asinf __P((float)); +extern float __ieee754_atan2f __P((float,float)); +extern float __ieee754_expf __P((float)); +extern float __ieee754_coshf __P((float)); +extern float __ieee754_fmodf __P((float,float)); +extern float __ieee754_powf __P((float,float)); +extern float __ieee754_lgammaf_r __P((float,int *)); +extern float __ieee754_gammaf_r __P((float,int *)); +extern float __ieee754_log10f __P((float)); +extern float __ieee754_sinhf __P((float)); +extern float __ieee754_hypotf __P((float,float)); +extern float __ieee754_j0f __P((float)); +extern float __ieee754_j1f __P((float)); +extern float __ieee754_y0f __P((float)); +extern float __ieee754_y1f __P((float)); +extern float __ieee754_jnf __P((int,float)); +extern float __ieee754_ynf __P((int,float)); +extern float __ieee754_remainderf __P((float,float)); +extern __int32_t __ieee754_rem_pio2f __P((float,float*)); +#ifdef _SCALB_INT +extern float __ieee754_scalbf __P((float,int)); +#else +extern float __ieee754_scalbf __P((float,float)); +#endif + +/* float versions of fdlibm kernel functions */ +extern float __kernel_sinf __P((float,float,int)); +extern float __kernel_cosf __P((float,float)); +extern float __kernel_tanf __P((float,float,int)); +extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*)); + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + __uint32_t word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +/* Macros to avoid undefined behaviour that can arise if the amount + of a shift is exactly equal to the size of the shifted operand. */ + +#define SAFE_LEFT_SHIFT(op,amt) \ + (((amt) < 8 * sizeof(op)) ? ((op) << (amt)) : 0) + +#define SAFE_RIGHT_SHIFT(op,amt) \ + (((amt) < 8 * sizeof(op)) ? ((op) >> (amt)) : 0) diff --git a/user/mpy/lib/libm/fmodf.c b/user/mpy/lib/libm/fmodf.c new file mode 100644 index 0000000..69a9ad9 --- /dev/null +++ b/user/mpy/lib/libm/fmodf.c @@ -0,0 +1,70 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// fmodf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +#include "libm.h" + +float fmodf(float x, float y) +{ + union {float f; uint32_t i;} ux = {x}, uy = {y}; + int ex = ux.i>>23 & 0xff; + int ey = uy.i>>23 & 0xff; + uint32_t sx = ux.i & 0x80000000; + uint32_t i; + uint32_t uxi = ux.i; + + if (uy.i<<1 == 0 || isnan(y) || ex == 0xff) + return (x*y)/(x*y); + if (uxi<<1 <= uy.i<<1) { + if (uxi<<1 == uy.i<<1) + return 0*x; + return x; + } + + /* normalize x and y */ + if (!ex) { + for (i = uxi<<9; i>>31 == 0; ex--, i <<= 1); + uxi <<= -ex + 1; + } else { + uxi &= -1U >> 9; + uxi |= 1U << 23; + } + if (!ey) { + for (i = uy.i<<9; i>>31 == 0; ey--, i <<= 1); + uy.i <<= -ey + 1; + } else { + uy.i &= -1U >> 9; + uy.i |= 1U << 23; + } + + /* x mod y */ + for (; ex > ey; ex--) { + i = uxi - uy.i; + if (i >> 31 == 0) { + if (i == 0) + return 0*x; + uxi = i; + } + uxi <<= 1; + } + i = uxi - uy.i; + if (i >> 31 == 0) { + if (i == 0) + return 0*x; + uxi = i; + } + for (; uxi>>23 == 0; uxi <<= 1, ex--); + + /* scale result up */ + if (ex > 0) { + uxi -= 1U << 23; + uxi |= (uint32_t)ex << 23; + } else { + uxi >>= -ex + 1; + } + uxi |= sx; + ux.i = uxi; + return ux.f; +} diff --git a/user/mpy/lib/libm/kf_cos.c b/user/mpy/lib/libm/kf_cos.c new file mode 100644 index 0000000..691f984 --- /dev/null +++ b/user/mpy/lib/libm/kf_cos.c @@ -0,0 +1,68 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* kf_cos.c -- float version of k_cos.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3f800000 */ +C1 = 4.1666667908e-02, /* 0x3d2aaaab */ +C2 = -1.3888889225e-03, /* 0xbab60b61 */ +C3 = 2.4801587642e-05, /* 0x37d00d01 */ +C4 = -2.7557314297e-07, /* 0xb493f27c */ +C5 = 2.0875723372e-09, /* 0x310f74f6 */ +C6 = -1.1359647598e-11; /* 0xad47d74e */ + +#ifdef __STDC__ + float __kernel_cosf(float x, float y) +#else + float __kernel_cosf(x, y) + float x,y; +#endif +{ + float a,hz,z,r,qx; + __int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; /* ix = |x|'s high word*/ + if(ix<0x32000000) { /* if x < 2**27 */ + if(((int)x)==0) return one; /* generate inexact */ + } + z = x*x; + r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); + if(ix < 0x3e99999a) /* if |x| < 0.3 */ + return one - ((float)0.5*z - (z*r - x*y)); + else { + if(ix > 0x3f480000) { /* x > 0.78125 */ + qx = (float)0.28125; + } else { + SET_FLOAT_WORD(qx,ix-0x01000000); /* x/4 */ + } + hz = (float)0.5*z-qx; + a = one-qx; + return a - (hz - (z*r-x*y)); + } +} diff --git a/user/mpy/lib/libm/kf_rem_pio2.c b/user/mpy/lib/libm/kf_rem_pio2.c new file mode 100644 index 0000000..c7e9479 --- /dev/null +++ b/user/mpy/lib/libm/kf_rem_pio2.c @@ -0,0 +1,218 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* kf_rem_pio2.c -- float version of k_rem_pio2.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +/* In the float version, the input parameter x contains 8 bit + integers, not 24 bit integers. 113 bit precision is not supported. */ + +#ifdef __STDC__ +static const int init_jk[] = {4,7,9}; /* initial value for jk */ +#else +static int init_jk[] = {4,7,9}; +#endif + +#ifdef __STDC__ +static const float PIo2[] = { +#else +static float PIo2[] = { +#endif + 1.5703125000e+00, /* 0x3fc90000 */ + 4.5776367188e-04, /* 0x39f00000 */ + 2.5987625122e-05, /* 0x37da0000 */ + 7.5437128544e-08, /* 0x33a20000 */ + 6.0026650317e-11, /* 0x2e840000 */ + 7.3896444519e-13, /* 0x2b500000 */ + 5.3845816694e-15, /* 0x27c20000 */ + 5.6378512969e-18, /* 0x22d00000 */ + 8.3009228831e-20, /* 0x1fc40000 */ + 3.2756352257e-22, /* 0x1bc60000 */ + 6.3331015649e-25, /* 0x17440000 */ +}; + +#ifdef __STDC__ +static const float +#else +static float +#endif +zero = 0.0, +one = 1.0, +two8 = 2.5600000000e+02, /* 0x43800000 */ +twon8 = 3.9062500000e-03; /* 0x3b800000 */ + +#ifdef __STDC__ + int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2) +#else + int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2) + float x[], y[]; int e0,nx,prec; __int32_t ipio2[]; +#endif +{ + __int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; + float z,fw,f[20],fq[20],q[20]; + + /* initialize jk*/ + jk = init_jk[prec]; + jp = jk; + + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx-1; + jv = (e0-3)/8; if(jv<0) jv=0; + q0 = e0-8*(jv+1); + + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv-jx; m = jx+jk; + for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j]; + + /* compute q[0],q[1],...q[jk] */ + for (i=0;i<=jk;i++) { + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + + jz = jk; +recompute: + /* distill q[] into iq[] reversingly */ + for(i=0,j=jz,z=q[jz];j>0;i++,j--) { + fw = (float)((__int32_t)(twon8* z)); + iq[i] = (__int32_t)(z-two8*fw); + z = q[j-1]+fw; + } + + /* compute n */ + z = scalbnf(z,(int)q0); /* actual value of z */ + z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */ + n = (__int32_t) z; + z -= (float)n; + ih = 0; + if(q0>0) { /* need iq[jz-1] to determine n */ + i = (iq[jz-1]>>(8-q0)); n += i; + iq[jz-1] -= i<<(8-q0); + ih = iq[jz-1]>>(7-q0); + } + else if(q0==0) ih = iq[jz-1]>>8; + else if(z>=(float)0.5) ih=2; + + if(ih>0) { /* q > 0.5 */ + n += 1; carry = 0; + for(i=0;i0) { /* rare case: chance is 1 in 12 */ + switch(q0) { + case 1: + iq[jz-1] &= 0x7f; break; + case 2: + iq[jz-1] &= 0x3f; break; + } + } + if(ih==2) { + z = one - z; + if(carry!=0) z -= scalbnf(one,(int)q0); + } + } + + /* check if recomputation is needed */ + if(z==zero) { + j = 0; + for (i=jz-1;i>=jk;i--) j |= iq[i]; + if(j==0) { /* need recomputation */ + for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ + + for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ + f[jx+i] = (float) ipio2[jv+i]; + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + jz += k; + goto recompute; + } + } + + /* chop off zero terms */ + if(z==(float)0.0) { + jz -= 1; q0 -= 8; + while(iq[jz]==0) { jz--; q0-=8;} + } else { /* break z into 8-bit if necessary */ + z = scalbnf(z,-(int)q0); + if(z>=two8) { + fw = (float)((__int32_t)(twon8*z)); + iq[jz] = (__int32_t)(z-two8*fw); + jz += 1; q0 += 8; + iq[jz] = (__int32_t) fw; + } else iq[jz] = (__int32_t) z ; + } + + /* convert integer "bit" chunk to floating-point value */ + fw = scalbnf(one,(int)q0); + for(i=jz;i>=0;i--) { + q[i] = fw*(float)iq[i]; fw*=twon8; + } + + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + for(i=jz;i>=0;i--) { + for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; + fq[jz-i] = fw; + } + + /* compress fq[] into y[] */ + switch(prec) { + case 0: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + break; + case 1: + case 2: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + fw = fq[0]-fw; + for (i=1;i<=jz;i++) fw += fq[i]; + y[1] = (ih==0)? fw: -fw; + break; + case 3: /* painful */ + for (i=jz;i>0;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (i=jz;i>1;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; + if(ih==0) { + y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; + } else { + y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; + } + } + return n&7; +} diff --git a/user/mpy/lib/libm/kf_sin.c b/user/mpy/lib/libm/kf_sin.c new file mode 100644 index 0000000..07ea993 --- /dev/null +++ b/user/mpy/lib/libm/kf_sin.c @@ -0,0 +1,58 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* kf_sin.c -- float version of k_sin.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +half = 5.0000000000e-01,/* 0x3f000000 */ +S1 = -1.6666667163e-01, /* 0xbe2aaaab */ +S2 = 8.3333337680e-03, /* 0x3c088889 */ +S3 = -1.9841270114e-04, /* 0xb9500d01 */ +S4 = 2.7557314297e-06, /* 0x3638ef1b */ +S5 = -2.5050759689e-08, /* 0xb2d72f34 */ +S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */ + +#ifdef __STDC__ + float __kernel_sinf(float x, float y, int iy) +#else + float __kernel_sinf(x, y, iy) + float x,y; int iy; /* iy=0 if y is zero */ +#endif +{ + float z,r,v; + __int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; /* high word of x */ + if(ix<0x32000000) /* |x| < 2**-27 */ + {if((int)x==0) return x;} /* generate inexact */ + z = x*x; + v = z*x; + r = S2+z*(S3+z*(S4+z*(S5+z*S6))); + if(iy==0) return x+v*(S1+z*r); + else return x-((z*(half*y-v*r)-y)-v*S1); +} diff --git a/user/mpy/lib/libm/kf_tan.c b/user/mpy/lib/libm/kf_tan.c new file mode 100644 index 0000000..6da9bd8 --- /dev/null +++ b/user/mpy/lib/libm/kf_tan.c @@ -0,0 +1,105 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* kf_tan.c -- float version of k_tan.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "libm.h" +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3f800000 */ +pio4 = 7.8539812565e-01, /* 0x3f490fda */ +pio4lo= 3.7748947079e-08, /* 0x33222168 */ +T[] = { + 3.3333334327e-01, /* 0x3eaaaaab */ + 1.3333334029e-01, /* 0x3e088889 */ + 5.3968254477e-02, /* 0x3d5d0dd1 */ + 2.1869488060e-02, /* 0x3cb327a4 */ + 8.8632395491e-03, /* 0x3c11371f */ + 3.5920790397e-03, /* 0x3b6b6916 */ + 1.4562094584e-03, /* 0x3abede48 */ + 5.8804126456e-04, /* 0x3a1a26c8 */ + 2.4646313977e-04, /* 0x398137b9 */ + 7.8179444245e-05, /* 0x38a3f445 */ + 7.1407252108e-05, /* 0x3895c07a */ + -1.8558637748e-05, /* 0xb79bae5f */ + 2.5907305826e-05, /* 0x37d95384 */ +}; + +#ifdef __STDC__ + float __kernel_tanf(float x, float y, int iy) +#else + float __kernel_tanf(x, y, iy) + float x,y; int iy; +#endif +{ + float z,r,v,w,s; + __int32_t ix,hx; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; /* high word of |x| */ + if(ix<0x31800000) /* x < 2**-28 */ + {if((int)x==0) { /* generate inexact */ + if((ix|(iy+1))==0) return one/fabsf(x); + else return (iy==1)? x: -one/x; + } + } + if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ + if(hx<0) {x = -x; y = -y;} + z = pio4-x; + w = pio4lo-y; + x = z+w; y = 0.0; + } + z = x*x; + w = z*z; + /* Break x^5*(T[1]+x^2*T[2]+...) into + * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) + */ + r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); + v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); + s = z*x; + r = y + z*(s*(r+v)+y); + r += T[0]*s; + w = x+r; + if(ix>=0x3f2ca140) { + v = (float)iy; + return (float)(1-((hx>>30)&2))*(v-(float)2.0*(x-(w*w/(w+v)-r))); + } + if(iy==1) return w; + else { /* if allow error up to 2 ulp, + simply return -1.0/(x+r) here */ + /* compute -1.0/(x+r) accurately */ + float a,t; + __int32_t i; + z = w; + GET_FLOAT_WORD(i,z); + SET_FLOAT_WORD(z,i&0xfffff000); + v = r-(z - x); /* z+v = r+x */ + t = a = -(float)1.0/w; /* a = -1.0/w */ + GET_FLOAT_WORD(i,t); + SET_FLOAT_WORD(t,i&0xfffff000); + s = (float)1.0+t*z; + return t+a*(s+t*v); + } +} diff --git a/user/mpy/lib/libm/libm.h b/user/mpy/lib/libm/libm.h new file mode 100644 index 0000000..f782249 --- /dev/null +++ b/user/mpy/lib/libm/libm.h @@ -0,0 +1,54 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// portions extracted from musl-0.9.15 libm.h +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include +#include + +#define FLT_EVAL_METHOD 0 + +#define FORCE_EVAL(x) do { \ + if (sizeof(x) == sizeof(float)) { \ + volatile float __x; \ + __x = (x); \ + (void)__x; \ + } else if (sizeof(x) == sizeof(double)) { \ + volatile double __x; \ + __x = (x); \ + (void)__x; \ + } else { \ + volatile long double __x; \ + __x = (x); \ + (void)__x; \ + } \ +} while(0) + +/* Get a 32 bit int from a float. */ +#define GET_FLOAT_WORD(w,d) \ +do { \ + union {float f; uint32_t i;} __u; \ + __u.f = (d); \ + (w) = __u.i; \ +} while (0) + +/* Set a float from a 32 bit int. */ +#define SET_FLOAT_WORD(d,w) \ +do { \ + union {float f; uint32_t i;} __u; \ + __u.i = (w); \ + (d) = __u.f; \ +} while (0) diff --git a/user/mpy/lib/libm/log1pf.c b/user/mpy/lib/libm/log1pf.c new file mode 100644 index 0000000..0d32b0a --- /dev/null +++ b/user/mpy/lib/libm/log1pf.c @@ -0,0 +1,83 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// log1pf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/s_log1pf.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "libm.h" + +static const float +ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ +ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ +/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ +Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ +Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ +Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ +Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ + +float log1pf(float x) +{ + union {float f; uint32_t i;} u = {x}; + float_t hfsq,f,c,s,z,R,w,t1,t2,dk; + uint32_t ix,iu; + int k; + + ix = u.i; + k = 1; + if (ix < 0x3ed413d0 || ix>>31) { /* 1+x < sqrt(2)+ */ + if (ix >= 0xbf800000) { /* x <= -1.0 */ + if (x == -1) + return x/0.0f; /* log1p(-1)=+inf */ + return (x-x)/0.0f; /* log1p(x<-1)=NaN */ + } + if (ix<<1 < 0x33800000<<1) { /* |x| < 2**-24 */ + /* underflow if subnormal */ + if ((ix&0x7f800000) == 0) + FORCE_EVAL(x*x); + return x; + } + if (ix <= 0xbe95f619) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */ + k = 0; + c = 0; + f = x; + } + } else if (ix >= 0x7f800000) + return x; + if (k) { + u.f = 1 + x; + iu = u.i; + iu += 0x3f800000 - 0x3f3504f3; + k = (int)(iu>>23) - 0x7f; + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if (k < 25) { + c = k >= 2 ? 1-(u.f-x) : x-(u.f-1); + c /= u.f; + } else + c = 0; + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + iu = (iu&0x007fffff) + 0x3f3504f3; + u.i = iu; + f = u.f - 1; + } + s = f/(2.0f + f); + z = s*s; + w = z*z; + t1= w*(Lg2+w*Lg4); + t2= z*(Lg1+w*Lg3); + R = t2 + t1; + hfsq = 0.5f*f*f; + dk = k; + return s*(hfsq+R) + (dk*ln2_lo+c) - hfsq + f + dk*ln2_hi; +} diff --git a/user/mpy/lib/libm/math.c b/user/mpy/lib/libm/math.c new file mode 100644 index 0000000..9846366 --- /dev/null +++ b/user/mpy/lib/libm/math.c @@ -0,0 +1,822 @@ +/* + * 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. + */ + +#include "libm.h" + +typedef float float_t; +typedef union { + float f; + struct { + uint64_t m : 23; + uint64_t e : 8; + uint64_t s : 1; + }; +} float_s_t; + +#ifndef NDEBUG +float copysignf(float x, float y) { + float_s_t fx={.f = x}; + float_s_t fy={.f = y}; + + // copy sign bit; + fx.s = fy.s; + + return fx.f; +} +#endif + +// some compilers define log2f in terms of logf +#ifdef log2f +#undef log2f +#endif +// some compilers have _M_LN2 defined in math.h, some don't +#ifndef _M_LN2 +#define _M_LN2 (0.69314718055994530942) +#endif +float log2f(float x) { return logf(x) / (float)_M_LN2; } + +static const float _M_LN10 = 2.30258509299404; // 0x40135d8e +float log10f(float x) { return logf(x) / (float)_M_LN10; } + +float tanhf(float x) { return sinhf(x) / coshf(x); } + +/*****************************************************************************/ +/*****************************************************************************/ +// __fpclassifyf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +int __fpclassifyf(float x) +{ + union {float f; uint32_t i;} u = {x}; + int e = u.i>>23 & 0xff; + if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; + if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE; + return FP_NORMAL; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// scalbnf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +float scalbnf(float x, int n) +{ + union {float f; uint32_t i;} u; + float_t y = x; + + if (n > 127) { + y *= 0x1p127f; + n -= 127; + if (n > 127) { + y *= 0x1p127f; + n -= 127; + if (n > 127) + n = 127; + } + } else if (n < -126) { + y *= 0x1p-126f; + n += 126; + if (n < -126) { + y *= 0x1p-126f; + n += 126; + if (n < -126) + n = -126; + } + } + u.i = (uint32_t)(0x7f+n)<<23; + x = y * u.f; + return x; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// powf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/e_powf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +static const float +bp[] = {1.0, 1.5,}, +dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ +dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ +two24 = 16777216.0, /* 0x4b800000 */ +huge = 1.0e30, +tiny = 1.0e-30, +/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ +L1 = 6.0000002384e-01, /* 0x3f19999a */ +L2 = 4.2857143283e-01, /* 0x3edb6db7 */ +L3 = 3.3333334327e-01, /* 0x3eaaaaab */ +L4 = 2.7272811532e-01, /* 0x3e8ba305 */ +L5 = 2.3066075146e-01, /* 0x3e6c3255 */ +L6 = 2.0697501302e-01, /* 0x3e53f142 */ +P1 = 1.6666667163e-01, /* 0x3e2aaaab */ +P2 = -2.7777778450e-03, /* 0xbb360b61 */ +P3 = 6.6137559770e-05, /* 0x388ab355 */ +P4 = -1.6533901999e-06, /* 0xb5ddea0e */ +P5 = 4.1381369442e-08, /* 0x3331bb4c */ +lg2 = 6.9314718246e-01, /* 0x3f317218 */ +lg2_h = 6.93145752e-01, /* 0x3f317200 */ +lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ +ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ +cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ +cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */ +cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */ +ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ +ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ +ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ + +float powf(float x, float y) +{ + float z,ax,z_h,z_l,p_h,p_l; + float y1,t1,t2,r,s,sn,t,u,v,w; + int32_t i,j,k,yisint,n; + int32_t hx,hy,ix,iy,is; + + GET_FLOAT_WORD(hx, x); + GET_FLOAT_WORD(hy, y); + ix = hx & 0x7fffffff; + iy = hy & 0x7fffffff; + + /* x**0 = 1, even if x is NaN */ + if (iy == 0) + return 1.0f; + /* 1**y = 1, even if y is NaN */ + if (hx == 0x3f800000) + return 1.0f; + /* NaN if either arg is NaN */ + if (ix > 0x7f800000 || iy > 0x7f800000) + return x + y; + + /* determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if (hx < 0) { + if (iy >= 0x4b800000) + yisint = 2; /* even integer y */ + else if (iy >= 0x3f800000) { + k = (iy>>23) - 0x7f; /* exponent */ + j = iy>>(23-k); + if ((j<<(23-k)) == iy) + yisint = 2 - (j & 1); + } + } + + /* special value of y */ + if (iy == 0x7f800000) { /* y is +-inf */ + if (ix == 0x3f800000) /* (-1)**+-inf is 1 */ + return 1.0f; + else if (ix > 0x3f800000) /* (|x|>1)**+-inf = inf,0 */ + return hy >= 0 ? y : 0.0f; + else if (ix != 0) /* (|x|<1)**+-inf = 0,inf if x!=0 */ + return hy >= 0 ? 0.0f: -y; + } + if (iy == 0x3f800000) /* y is +-1 */ + return hy >= 0 ? x : 1.0f/x; + if (hy == 0x40000000) /* y is 2 */ + return x*x; + if (hy == 0x3f000000) { /* y is 0.5 */ + if (hx >= 0) /* x >= +0 */ + return sqrtf(x); + } + + ax = fabsf(x); + /* special value of x */ + if (ix == 0x7f800000 || ix == 0 || ix == 0x3f800000) { /* x is +-0,+-inf,+-1 */ + z = ax; + if (hy < 0) /* z = (1/|x|) */ + z = 1.0f/z; + if (hx < 0) { + if (((ix-0x3f800000)|yisint) == 0) { + z = (z-z)/(z-z); /* (-1)**non-int is NaN */ + } else if (yisint == 1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + + sn = 1.0f; /* sign of result */ + if (hx < 0) { + if (yisint == 0) /* (x<0)**(non-int) is NaN */ + return (x-x)/(x-x); + if (yisint == 1) /* (x<0)**(odd int) */ + sn = -1.0f; + } + + /* |y| is huge */ + if (iy > 0x4d000000) { /* if |y| > 2**27 */ + /* over/underflow if x is not close to one */ + if (ix < 0x3f7ffff8) + return hy < 0 ? sn*huge*huge : sn*tiny*tiny; + if (ix > 0x3f800007) + return hy > 0 ? sn*huge*huge : sn*tiny*tiny; + /* now |1-x| is tiny <= 2**-20, suffice to compute + log(x) by x-x^2/2+x^3/3-x^4/4 */ + t = ax - 1; /* t has 20 trailing zeros */ + w = (t*t)*(0.5f - t*(0.333333333333f - t*0.25f)); + u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ + v = t*ivln2_l - w*ivln2; + t1 = u + v; + GET_FLOAT_WORD(is, t1); + SET_FLOAT_WORD(t1, is & 0xfffff000); + t2 = v - (t1-u); + } else { + float s2,s_h,s_l,t_h,t_l; + n = 0; + /* take care subnormal number */ + if (ix < 0x00800000) { + ax *= two24; + n -= 24; + GET_FLOAT_WORD(ix, ax); + } + n += ((ix)>>23) - 0x7f; + j = ix & 0x007fffff; + /* determine interval */ + ix = j | 0x3f800000; /* normalize ix */ + if (j <= 0x1cc471) /* |x|>1) & 0xfffff000) | 0x20000000; + SET_FLOAT_WORD(t_h, is + 0x00400000 + (k<<21)); + t_l = ax - (t_h - bp[k]); + s_l = v*((u - s_h*t_h) - s_h*t_l); + /* compute log(ax) */ + s2 = s*s; + r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); + r += s_l*(s_h+s); + s2 = s_h*s_h; + t_h = 3.0f + s2 + r; + GET_FLOAT_WORD(is, t_h); + SET_FLOAT_WORD(t_h, is & 0xfffff000); + t_l = r - ((t_h - 3.0f) - s2); + /* u+v = s*(1+...) */ + u = s_h*t_h; + v = s_l*t_h + t_l*s; + /* 2/(3log2)*(s+...) */ + p_h = u + v; + GET_FLOAT_WORD(is, p_h); + SET_FLOAT_WORD(p_h, is & 0xfffff000); + p_l = v - (p_h - u); + z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l*p_h + p_l*cp+dp_l[k]; + /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (float)n; + t1 = (((z_h + z_l) + dp_h[k]) + t); + GET_FLOAT_WORD(is, t1); + SET_FLOAT_WORD(t1, is & 0xfffff000); + t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); + } + + /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ + GET_FLOAT_WORD(is, y); + SET_FLOAT_WORD(y1, is & 0xfffff000); + p_l = (y-y1)*t1 + y*t2; + p_h = y1*t1; + z = p_l + p_h; + GET_FLOAT_WORD(j, z); + if (j > 0x43000000) /* if z > 128 */ + return sn*huge*huge; /* overflow */ + else if (j == 0x43000000) { /* if z == 128 */ + if (p_l + ovt > z - p_h) + return sn*huge*huge; /* overflow */ + } else if ((j&0x7fffffff) > 0x43160000) /* z < -150 */ // FIXME: check should be (uint32_t)j > 0xc3160000 + return sn*tiny*tiny; /* underflow */ + else if (j == 0xc3160000) { /* z == -150 */ + if (p_l <= z-p_h) + return sn*tiny*tiny; /* underflow */ + } + /* + * compute 2**(p_h+p_l) + */ + i = j & 0x7fffffff; + k = (i>>23) - 0x7f; + n = 0; + if (i > 0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */ + n = j + (0x00800000>>(k+1)); + k = ((n&0x7fffffff)>>23) - 0x7f; /* new k for n */ + SET_FLOAT_WORD(t, n & ~(0x007fffff>>k)); + n = ((n&0x007fffff)|0x00800000)>>(23-k); + if (j < 0) + n = -n; + p_h -= t; + } + t = p_l + p_h; + GET_FLOAT_WORD(is, t); + SET_FLOAT_WORD(t, is & 0xffff8000); + u = t*lg2_h; + v = (p_l-(t-p_h))*lg2 + t*lg2_l; + z = u + v; + w = v - (z - u); + t = z*z; + t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + r = (z*t1)/(t1-2.0f) - (w+z*w); + z = 1.0f - (r - z); + GET_FLOAT_WORD(j, z); + j += n<<23; + if ((j>>23) <= 0) /* subnormal output */ + z = scalbnf(z, n); + else + SET_FLOAT_WORD(z, j); + return sn*z; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// expf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/e_expf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +static const float +half[2] = {0.5,-0.5}, +ln2hi = 6.9314575195e-1f, /* 0x3f317200 */ +ln2lo = 1.4286067653e-6f, /* 0x35bfbe8e */ +invln2 = 1.4426950216e+0f, /* 0x3fb8aa3b */ +/* + * Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]: + * |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74 + */ +expf_P1 = 1.6666625440e-1f, /* 0xaaaa8f.0p-26 */ +expf_P2 = -2.7667332906e-3f; /* -0xb55215.0p-32 */ + +float expf(float x) +{ + float_t hi, lo, c, xx, y; + int k, sign; + uint32_t hx; + + GET_FLOAT_WORD(hx, x); + sign = hx >> 31; /* sign bit of x */ + hx &= 0x7fffffff; /* high word of |x| */ + + /* special cases */ + if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */ + if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */ + /* overflow */ + x *= 0x1p127f; + return x; + } + if (sign) { + /* underflow */ + FORCE_EVAL(-0x1p-149f/x); + if (hx >= 0x42cff1b5) /* x <= -103.972084f */ + return 0; + } + } + + /* argument reduction */ + if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ + if (hx > 0x3f851592) /* if |x| > 1.5 ln2 */ + k = invln2*x + half[sign]; + else + k = 1 - sign - sign; + hi = x - k*ln2hi; /* k*ln2hi is exact here */ + lo = k*ln2lo; + x = hi - lo; + } else if (hx > 0x39000000) { /* |x| > 2**-14 */ + k = 0; + hi = x; + lo = 0; + } else { + /* raise inexact */ + FORCE_EVAL(0x1p127f + x); + return 1 + x; + } + + /* x is now in primary range */ + xx = x*x; + c = x - xx*(expf_P1+xx*expf_P2); + y = 1 + (x*c/(2-c) - lo + hi); + if (k == 0) + return y; + return scalbnf(y, k); +} + +/*****************************************************************************/ +/*****************************************************************************/ +// expm1f from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/s_expm1f.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +static const float +o_threshold = 8.8721679688e+01, /* 0x42b17180 */ +ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ +ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ +//invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */ +/* + * Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]: + * |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04 + * Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c): + */ +Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */ +Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */ + +float expm1f(float x) +{ + float_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk; + union {float f; uint32_t i;} u = {x}; + uint32_t hx = u.i & 0x7fffffff; + int k, sign = u.i >> 31; + + /* filter out huge and non-finite argument */ + if (hx >= 0x4195b844) { /* if |x|>=27*ln2 */ + if (hx > 0x7f800000) /* NaN */ + return x; + if (sign) + return -1; + if (x > o_threshold) { + x *= 0x1p127f; + return x; + } + } + + /* argument reduction */ + if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ + if (hx < 0x3F851592) { /* and |x| < 1.5 ln2 */ + if (!sign) { + hi = x - ln2_hi; + lo = ln2_lo; + k = 1; + } else { + hi = x + ln2_hi; + lo = -ln2_lo; + k = -1; + } + } else { + k = invln2*x + (sign ? -0.5f : 0.5f); + t = k; + hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ + lo = t*ln2_lo; + } + x = hi-lo; + c = (hi-x)-lo; + } else if (hx < 0x33000000) { /* when |x|<2**-25, return x */ + if (hx < 0x00800000) + FORCE_EVAL(x*x); + return x; + } else + k = 0; + + /* x is now in primary range */ + hfx = 0.5f*x; + hxs = x*hfx; + r1 = 1.0f+hxs*(Q1+hxs*Q2); + t = 3.0f - r1*hfx; + e = hxs*((r1-t)/(6.0f - x*t)); + if (k == 0) /* c is 0 */ + return x - (x*e-hxs); + e = x*(e-c) - c; + e -= hxs; + /* exp(x) ~ 2^k (x_reduced - e + 1) */ + if (k == -1) + return 0.5f*(x-e) - 0.5f; + if (k == 1) { + if (x < -0.25f) + return -2.0f*(e-(x+0.5f)); + return 1.0f + 2.0f*(x-e); + } + u.i = (0x7f+k)<<23; /* 2^k */ + twopk = u.f; + if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */ + y = x - e + 1.0f; + if (k == 128) + y = y*2.0f*0x1p127f; + else + y = y*twopk; + return y - 1.0f; + } + u.i = (0x7f-k)<<23; /* 2^-k */ + if (k < 23) + y = (x-e+(1-u.f))*twopk; + else + y = (x-(e+u.f)+1)*twopk; + return y; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// __expo2f from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN) */ +static const int k = 235; +static const float kln2 = 0x1.45c778p+7f; + +/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ +float __expo2f(float x) +{ + float scale; + + /* note that k is odd and scale*scale overflows */ + SET_FLOAT_WORD(scale, (uint32_t)(0x7f + k/2) << 23); + /* exp(x - k ln2) * 2**(k-1) */ + return expf(x - kln2) * scale * scale; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// logf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +/* origin: FreeBSD /usr/src/lib/msun/src/e_logf.c */ +/* + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +static const float +/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ +Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ +Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ +Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ +Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ + +float logf(float x) +{ + union {float f; uint32_t i;} u = {x}; + float_t hfsq,f,s,z,R,w,t1,t2,dk; + uint32_t ix; + int k; + + ix = u.i; + k = 0; + if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */ + if (ix<<1 == 0) + return -1/(x*x); /* log(+-0)=-inf */ + if (ix>>31) + return (x-x)/0.0f; /* log(-#) = NaN */ + /* subnormal number, scale up x */ + k -= 25; + x *= 0x1p25f; + u.f = x; + ix = u.i; + } else if (ix >= 0x7f800000) { + return x; + } else if (ix == 0x3f800000) + return 0; + + /* reduce x into [sqrt(2)/2, sqrt(2)] */ + ix += 0x3f800000 - 0x3f3504f3; + k += (int)(ix>>23) - 0x7f; + ix = (ix&0x007fffff) + 0x3f3504f3; + u.i = ix; + x = u.f; + + f = x - 1.0f; + s = f/(2.0f + f); + z = s*s; + w = z*z; + t1= w*(Lg2+w*Lg4); + t2= z*(Lg1+w*Lg3); + R = t2 + t1; + hfsq = 0.5f*f*f; + dk = k; + return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// coshf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +float coshf(float x) +{ + union {float f; uint32_t i;} u = {.f = x}; + uint32_t w; + float t; + + /* |x| */ + u.i &= 0x7fffffff; + x = u.f; + w = u.i; + + /* |x| < log(2) */ + if (w < 0x3f317217) { + if (w < 0x3f800000 - (12<<23)) { + FORCE_EVAL(x + 0x1p120f); + return 1; + } + t = expm1f(x); + return 1 + t*t/(2*(1+t)); + } + + /* |x| < log(FLT_MAX) */ + if (w < 0x42b17217) { + t = expf(x); + return 0.5f*(t + 1/t); + } + + /* |x| > log(FLT_MAX) or nan */ + t = __expo2f(x); + return t; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// sinhf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +float sinhf(float x) +{ + union {float f; uint32_t i;} u = {.f = x}; + uint32_t w; + float t, h, absx; + + h = 0.5; + if (u.i >> 31) + h = -h; + /* |x| */ + u.i &= 0x7fffffff; + absx = u.f; + w = u.i; + + /* |x| < log(FLT_MAX) */ + if (w < 0x42b17217) { + t = expm1f(absx); + if (w < 0x3f800000) { + if (w < 0x3f800000 - (12<<23)) + return x; + return h*(2*t - t*t/(t+1)); + } + return h*(t + t/(t+1)); + } + + /* |x| > logf(FLT_MAX) or nan */ + t = 2*h*__expo2f(absx); + return t; +} + +/*****************************************************************************/ +/*****************************************************************************/ +// ceilf, floorf and truncf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +float ceilf(float x) +{ + union {float f; uint32_t i;} u = {x}; + int e = (int)(u.i >> 23 & 0xff) - 0x7f; + uint32_t m; + + if (e >= 23) + return x; + if (e >= 0) { + m = 0x007fffff >> e; + if ((u.i & m) == 0) + return x; + FORCE_EVAL(x + 0x1p120f); + if (u.i >> 31 == 0) + u.i += m; + u.i &= ~m; + } else { + FORCE_EVAL(x + 0x1p120f); + if (u.i >> 31) + u.f = -0.0; + else if (u.i << 1) + u.f = 1.0; + } + return u.f; +} + +float floorf(float x) +{ + union {float f; uint32_t i;} u = {x}; + int e = (int)(u.i >> 23 & 0xff) - 0x7f; + uint32_t m; + + if (e >= 23) + return x; + if (e >= 0) { + m = 0x007fffff >> e; + if ((u.i & m) == 0) + return x; + FORCE_EVAL(x + 0x1p120f); + if (u.i >> 31) + u.i += m; + u.i &= ~m; + } else { + FORCE_EVAL(x + 0x1p120f); + if (u.i >> 31 == 0) + u.i = 0; + else if (u.i << 1) + u.f = -1.0; + } + return u.f; +} + +float truncf(float x) +{ + union {float f; uint32_t i;} u = {x}; + int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9; + uint32_t m; + + if (e >= 23 + 9) + return x; + if (e < 9) + e = 1; + m = -1U >> e; + if ((u.i & m) == 0) + return x; + FORCE_EVAL(x + 0x1p120f); + u.i &= ~m; + return u.f; +} diff --git a/user/mpy/lib/libm/nearbyintf.c b/user/mpy/lib/libm/nearbyintf.c new file mode 100644 index 0000000..1c35459 --- /dev/null +++ b/user/mpy/lib/libm/nearbyintf.c @@ -0,0 +1,21 @@ +// adapted from the rintf() function from musl-1.1.16 + +#include "libm.h" + +float nearbyintf(float x) +{ + union {float f; uint32_t i;} u = {x}; + int e = u.i>>23 & 0xff; + int s = u.i>>31; + float_t y; + + if (e >= 0x7f+23) + return x; + if (s) + y = x - 0x1p23f + 0x1p23f; + else + y = x + 0x1p23f - 0x1p23f; + if (y == 0) + return s ? -0.0f : 0.0f; + return y; +} diff --git a/user/mpy/lib/libm/roundf.c b/user/mpy/lib/libm/roundf.c new file mode 100644 index 0000000..3da1f05 --- /dev/null +++ b/user/mpy/lib/libm/roundf.c @@ -0,0 +1,33 @@ +/*****************************************************************************/ +/*****************************************************************************/ +// roundf from musl-0.9.15 +/*****************************************************************************/ +/*****************************************************************************/ + +#include "libm.h" + +float roundf(float x) +{ + union {float f; uint32_t i;} u = {x}; + int e = u.i >> 23 & 0xff; + float_t y; + + if (e >= 0x7f+23) + return x; + if (u.i >> 31) + x = -x; + if (e < 0x7f-1) { + FORCE_EVAL(x + 0x1p23f); + return 0*u.f; + } + y = (float)(x + 0x1p23f) - 0x1p23f - x; + if (y > 0.5f) + y = y + x - 1; + else if (y <= -0.5f) + y = y + x + 1; + else + y = y + x; + if (u.i >> 31) + y = -y; + return y; +} diff --git a/user/mpy/lib/libm/sf_cos.c b/user/mpy/lib/libm/sf_cos.c new file mode 100644 index 0000000..fabb129 --- /dev/null +++ b/user/mpy/lib/libm/sf_cos.c @@ -0,0 +1,71 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_cos.c -- float version of s_cos.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ + float cosf(float x) +#else + float cosf(x) + float x; +#endif +{ + float y[2],z=0.0; + __int32_t n,ix; + + GET_FLOAT_WORD(ix,x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3f490fd8) return __kernel_cosf(x,z); + + /* cos(Inf or NaN) is NaN */ + else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2f(x,y); + switch(n&3) { + case 0: return __kernel_cosf(y[0],y[1]); + case 1: return -__kernel_sinf(y[0],y[1],1); + case 2: return -__kernel_cosf(y[0],y[1]); + default: + return __kernel_sinf(y[0],y[1],1); + } + } +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double cos(double x) +#else + double cos(x) + double x; +#endif +{ + return (double) cosf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_erf.c b/user/mpy/lib/libm/sf_erf.c new file mode 100644 index 0000000..3f0172c --- /dev/null +++ b/user/mpy/lib/libm/sf_erf.c @@ -0,0 +1,257 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_erf.c -- float version of s_erf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#define __ieee754_expf expf + +#ifdef __v810__ +#define const +#endif + +#ifdef __STDC__ +static const float +#else +static float +#endif +tiny = 1e-30, +half= 5.0000000000e-01, /* 0x3F000000 */ +one = 1.0000000000e+00, /* 0x3F800000 */ +two = 2.0000000000e+00, /* 0x40000000 */ + /* c = (subfloat)0.84506291151 */ +erx = 8.4506291151e-01, /* 0x3f58560b */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +efx = 1.2837916613e-01, /* 0x3e0375d4 */ +efx8= 1.0270333290e+00, /* 0x3f8375d4 */ +pp0 = 1.2837916613e-01, /* 0x3e0375d4 */ +pp1 = -3.2504209876e-01, /* 0xbea66beb */ +pp2 = -2.8481749818e-02, /* 0xbce9528f */ +pp3 = -5.7702702470e-03, /* 0xbbbd1489 */ +pp4 = -2.3763017452e-05, /* 0xb7c756b1 */ +qq1 = 3.9791721106e-01, /* 0x3ecbbbce */ +qq2 = 6.5022252500e-02, /* 0x3d852a63 */ +qq3 = 5.0813062117e-03, /* 0x3ba68116 */ +qq4 = 1.3249473704e-04, /* 0x390aee49 */ +qq5 = -3.9602282413e-06, /* 0xb684e21a */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */ +pa1 = 4.1485610604e-01, /* 0x3ed46805 */ +pa2 = -3.7220788002e-01, /* 0xbebe9208 */ +pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */ +pa4 = -1.1089469492e-01, /* 0xbde31cc2 */ +pa5 = 3.5478305072e-02, /* 0x3d1151b3 */ +pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */ +qa1 = 1.0642088205e-01, /* 0x3dd9f331 */ +qa2 = 5.4039794207e-01, /* 0x3f0a5785 */ +qa3 = 7.1828655899e-02, /* 0x3d931ae7 */ +qa4 = 1.2617121637e-01, /* 0x3e013307 */ +qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */ +qa6 = 1.1984500103e-02, /* 0x3c445aa3 */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +ra0 = -9.8649440333e-03, /* 0xbc21a093 */ +ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */ +ra2 = -1.0558626175e+01, /* 0xc128f022 */ +ra3 = -6.2375331879e+01, /* 0xc2798057 */ +ra4 = -1.6239666748e+02, /* 0xc322658c */ +ra5 = -1.8460508728e+02, /* 0xc3389ae7 */ +ra6 = -8.1287437439e+01, /* 0xc2a2932b */ +ra7 = -9.8143291473e+00, /* 0xc11d077e */ +sa1 = 1.9651271820e+01, /* 0x419d35ce */ +sa2 = 1.3765776062e+02, /* 0x4309a863 */ +sa3 = 4.3456588745e+02, /* 0x43d9486f */ +sa4 = 6.4538726807e+02, /* 0x442158c9 */ +sa5 = 4.2900814819e+02, /* 0x43d6810b */ +sa6 = 1.0863500214e+02, /* 0x42d9451f */ +sa7 = 6.5702495575e+00, /* 0x40d23f7c */ +sa8 = -6.0424413532e-02, /* 0xbd777f97 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +rb0 = -9.8649431020e-03, /* 0xbc21a092 */ +rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */ +rb2 = -1.7757955551e+01, /* 0xc18e104b */ +rb3 = -1.6063638306e+02, /* 0xc320a2ea */ +rb4 = -6.3756646729e+02, /* 0xc41f6441 */ +rb5 = -1.0250950928e+03, /* 0xc480230b */ +rb6 = -4.8351919556e+02, /* 0xc3f1c275 */ +sb1 = 3.0338060379e+01, /* 0x41f2b459 */ +sb2 = 3.2579251099e+02, /* 0x43a2e571 */ +sb3 = 1.5367296143e+03, /* 0x44c01759 */ +sb4 = 3.1998581543e+03, /* 0x4547fdbb */ +sb5 = 2.5530502930e+03, /* 0x451f90ce */ +sb6 = 4.7452853394e+02, /* 0x43ed43a7 */ +sb7 = -2.2440952301e+01; /* 0xc1b38712 */ + +#ifdef __STDC__ + float erff(float x) +#else + float erff(x) + float x; +#endif +{ + __int32_t hx,ix,i; + float R,S,P,Q,s,y,z,r; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) { /* erf(nan)=nan */ + i = ((__uint32_t)hx>>31)<<1; + return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */ + } + + if(ix < 0x3f580000) { /* |x|<0.84375 */ + if(ix < 0x31800000) { /* |x|<2**-28 */ + if (ix < 0x04000000) + /*avoid underflow */ + return (float)0.125*((float)8.0*x+efx8*x); + return x + efx*x; + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + return x + x*y; + } + if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ + s = fabsf(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) return erx + P/Q; else return -erx - P/Q; + } + if (ix >= 0x40c00000) { /* inf>|x|>=6 */ + if(hx>=0) return one-tiny; else return tiny-one; + } + x = fabsf(x); + s = one/(x*x); + if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/0.35 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(z,ix&0xfffff000); + r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S); + if(hx>=0) return one-r/x; else return r/x-one; +} + +#ifdef __STDC__ + float erfcf(float x) +#else + float erfcf(x) + float x; +#endif +{ + __int32_t hx,ix; + float R,S,P,Q,s,y,z,r; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(!FLT_UWORD_IS_FINITE(ix)) { /* erfc(nan)=nan */ + /* erfc(+-inf)=0,2 */ + return (float)(((__uint32_t)hx>>31)<<1)+one/x; + } + + if(ix < 0x3f580000) { /* |x|<0.84375 */ + if(ix < 0x23800000) /* |x|<2**-56 */ + return one-x; + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + if(hx < 0x3e800000) { /* x<1/4 */ + return one-(x+x*y); + } else { + r = x*y; + r += (x-half); + return half - r ; + } + } + if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ + s = fabsf(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) { + z = one-erx; return z - P/Q; + } else { + z = erx+P/Q; return one+z; + } + } + if (ix < 0x41e00000) { /* |x|<28 */ + x = fabsf(x); + s = one/(x*x); + if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/.35 ~ 2.857143 */ + if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(z,ix&0xfffff000); + r = __ieee754_expf(-z*z-(float)0.5625)* + __ieee754_expf((z-x)*(z+x)+R/S); + if(hx>0) return r/x; else return two-r/x; + } else { + if(hx>0) return tiny*tiny; else return two-tiny; + } +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double erf(double x) +#else + double erf(x) + double x; +#endif +{ + return (double) erff((float) x); +} + +#ifdef __STDC__ + double erfc(double x) +#else + double erfc(x) + double x; +#endif +{ + return (double) erfcf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_frexp.c b/user/mpy/lib/libm/sf_frexp.c new file mode 100644 index 0000000..df50fb7 --- /dev/null +++ b/user/mpy/lib/libm/sf_frexp.c @@ -0,0 +1,70 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_frexp.c -- float version of s_frexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +two25 = 3.3554432000e+07; /* 0x4c000000 */ + +#ifdef __STDC__ + float frexpf(float x, int *eptr) +#else + float frexpf(x, eptr) + float x; int *eptr; +#endif +{ + __int32_t hx, ix; + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + *eptr = 0; + if(!FLT_UWORD_IS_FINITE(ix)||FLT_UWORD_IS_ZERO(ix)) return x; /* 0,inf,nan */ + if (FLT_UWORD_IS_SUBNORMAL(ix)) { /* subnormal */ + x *= two25; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + *eptr = -25; + } + *eptr += (ix>>23)-126; + hx = (hx&0x807fffff)|0x3f000000; + SET_FLOAT_WORD(x,hx); + return x; +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double frexp(double x, int *eptr) +#else + double frexp(x, eptr) + double x; int *eptr; +#endif +{ + return (double) frexpf((float) x, eptr); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_ldexp.c b/user/mpy/lib/libm/sf_ldexp.c new file mode 100644 index 0000000..37968d4 --- /dev/null +++ b/user/mpy/lib/libm/sf_ldexp.c @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_ldexp.c -- float version of s_ldexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" +//#include + +#ifdef __STDC__ + float ldexpf(float value, int exp) +#else + float ldexpf(value, exp) + float value; int exp; +#endif +{ + if(!isfinite(value)||value==(float)0.0) return value; + value = scalbnf(value,exp); + //if(!finitef(value)||value==(float)0.0) errno = ERANGE; + return value; +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double ldexp(double value, int exp) +#else + double ldexp(value, exp) + double value; int exp; +#endif +{ + return (double) ldexpf((float) value, exp); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_modf.c b/user/mpy/lib/libm/sf_modf.c new file mode 100644 index 0000000..410db2a --- /dev/null +++ b/user/mpy/lib/libm/sf_modf.c @@ -0,0 +1,82 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/common + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_modf.c -- float version of s_modf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const float one = 1.0; +#else +static float one = 1.0; +#endif + +#ifdef __STDC__ + float modff(float x, float *iptr) +#else + float modff(x, iptr) + float x,*iptr; +#endif +{ + __int32_t i0,j0; + __uint32_t i; + GET_FLOAT_WORD(i0,x); + j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ + if(j0<23) { /* integer part in x */ + if(j0<0) { /* |x|<1 */ + SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ + return x; + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) { /* x is integral */ + __uint32_t ix; + *iptr = x; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } else { + SET_FLOAT_WORD(*iptr,i0&(~i)); + return x - *iptr; + } + } + } else { /* no fraction part */ + __uint32_t ix; + *iptr = x*one; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double modf(double x, double *iptr) +#else + double modf(x, iptr) + double x,*iptr; +#endif +{ + return (double) modff((float) x, (float *) iptr); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_sin.c b/user/mpy/lib/libm/sf_sin.c new file mode 100644 index 0000000..d270507 --- /dev/null +++ b/user/mpy/lib/libm/sf_sin.c @@ -0,0 +1,71 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_sin.c -- float version of s_sin.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ + float sinf(float x) +#else + float sinf(x) + float x; +#endif +{ + float y[2],z=0.0; + __int32_t n,ix; + + GET_FLOAT_WORD(ix,x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0); + + /* sin(Inf or NaN) is NaN */ + else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2f(x,y); + switch(n&3) { + case 0: return __kernel_sinf(y[0],y[1],1); + case 1: return __kernel_cosf(y[0],y[1]); + case 2: return -__kernel_sinf(y[0],y[1],1); + default: + return -__kernel_cosf(y[0],y[1]); + } + } +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double sin(double x) +#else + double sin(x) + double x; +#endif +{ + return (double) sinf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_tan.c b/user/mpy/lib/libm/sf_tan.c new file mode 100644 index 0000000..148b16d --- /dev/null +++ b/user/mpy/lib/libm/sf_tan.c @@ -0,0 +1,66 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* sf_tan.c -- float version of s_tan.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ + float tanf(float x) +#else + float tanf(x) + float x; +#endif +{ + float y[2],z=0.0; + __int32_t n,ix; + + GET_FLOAT_WORD(ix,x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1); + + /* tan(Inf or NaN) is NaN */ + else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; /* NaN */ + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2f(x,y); + return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even + -1 -- n odd */ + } +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double tan(double x) +#else + double tan(x) + double x; +#endif +{ + return (double) tanf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/thumb_vfp_sqrtf.c b/user/mpy/lib/libm/thumb_vfp_sqrtf.c new file mode 100644 index 0000000..12ffebf --- /dev/null +++ b/user/mpy/lib/libm/thumb_vfp_sqrtf.c @@ -0,0 +1,11 @@ +// an implementation of sqrtf for Thumb using hardware VFP instructions + +#include + +float sqrtf(float x) { + asm volatile ( + "vsqrt.f32 %[r], %[x]\n" + : [r] "=t" (x) + : [x] "t" (x)); + return x; +} diff --git a/user/mpy/lib/libm/wf_lgamma.c b/user/mpy/lib/libm/wf_lgamma.c new file mode 100644 index 0000000..d86ede7 --- /dev/null +++ b/user/mpy/lib/libm/wf_lgamma.c @@ -0,0 +1,98 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* wf_lgamma.c -- float version of w_lgamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#include "fdlibm.h" +#define _IEEE_LIBM 1 +//#include +//#include + +#ifdef __STDC__ + float lgammaf(float x) +#else + float lgammaf(x) + float x; +#endif +{ +#ifdef _IEEE_LIBM + int sign; + return __ieee754_lgammaf_r(x,&sign); +#else + float y; + struct exception exc; + y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT))); + if(_LIB_VERSION == _IEEE_) return y; + if(!finitef(y)&&finitef(x)) { +#ifndef HUGE_VAL +#define HUGE_VAL inf + double inf = 0.0; + + SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ +#endif + exc.name = "lgammaf"; + exc.err = 0; + exc.arg1 = exc.arg2 = (double)x; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE; + else + exc.retval = HUGE_VAL; + if(floorf(x)==x&&x<=(float)0.0) { + /* lgammaf(-integer) */ + exc.type = SING; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + errno = EDOM; + } + + } else { + /* lgammaf(finite) overflow */ + exc.type = OVERFLOW; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + } + if (exc.err != 0) + errno = exc.err; + return (float)exc.retval; + } else + return y; +#endif +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double lgamma(double x) +#else + double lgamma(x) + double x; +#endif +{ + return (double) lgammaf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/wf_tgamma.c b/user/mpy/lib/libm/wf_tgamma.c new file mode 100644 index 0000000..64b2488 --- /dev/null +++ b/user/mpy/lib/libm/wf_tgamma.c @@ -0,0 +1,69 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * These math functions are taken from newlib-nano-2, the newlib/libm/math + * directory, available from https://github.com/32bitmicro/newlib-nano-2. + * + * Appropriate copyright headers are reproduced below. + */ + +/* w_gammaf.c -- float version of w_gamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "math.h" +#include "fdlibm.h" +#define _IEEE_LIBM 1 + +#ifdef __STDC__ + float tgammaf(float x) +#else + float tgammaf(x) + float x; +#endif +{ + float y; + int local_signgam; + y = expf(__ieee754_lgammaf_r(x,&local_signgam)); + if (local_signgam < 0) y = -y; +#ifdef _IEEE_LIBM + return y; +#else + if(_LIB_VERSION == _IEEE_) return y; + + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=(float)0.0) + /* tgammaf pole */ + return (float)__kernel_standard((double)x,(double)x,141); + else + /* tgammaf overflow */ + return (float)__kernel_standard((double)x,(double)x,140); + } + return y; +#endif +} + +#ifdef _DOUBLE_IS_32BITS + +#ifdef __STDC__ + double tgamma(double x) +#else + double tgamma(x) + double x; +#endif +{ + return (double) tgammaf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm_dbl/README b/user/mpy/lib/libm_dbl/README new file mode 100644 index 0000000..512b328 --- /dev/null +++ b/user/mpy/lib/libm_dbl/README @@ -0,0 +1,32 @@ +This directory contains source code for the standard double-precision math +functions. + +The files lgamma.c, log10.c and tanh.c are too small to have a meaningful +copyright or license. + +The rest of the files in this directory are copied from the musl library, +v1.1.16, and, unless otherwise stated in the individual file, have the +following copyright and MIT license: + +---------------------------------------------------------------------- +Copyright © 2005-2014 Rich Felker, et al. + +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. +---------------------------------------------------------------------- diff --git a/user/mpy/lib/libm_dbl/__cos.c b/user/mpy/lib/libm_dbl/__cos.c new file mode 100644 index 0000000..46cefb3 --- /dev/null +++ b/user/mpy/lib/libm_dbl/__cos.c @@ -0,0 +1,71 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/k_cos.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* + * __cos( x, y ) + * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * + * Algorithm + * 1. Since cos(-x) = cos(x), we need only to consider positive x. + * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0. + * 3. cos(x) is approximated by a polynomial of degree 14 on + * [0,pi/4] + * 4 14 + * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x + * where the remez error is + * + * | 2 4 6 8 10 12 14 | -58 + * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 + * | | + * + * 4 6 8 10 12 14 + * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then + * cos(x) ~ 1 - x*x/2 + r + * since cos(x+y) ~ cos(x) - sin(x)*y + * ~ cos(x) - x*y, + * a correction term is necessary in cos(x) and hence + * cos(x+y) = 1 - (x*x/2 - (r - x*y)) + * For better accuracy, rearrange to + * cos(x+y) ~ w + (tmp + (r-x*y)) + * where w = 1 - x*x/2 and tmp is a tiny correction term + * (1 - x*x/2 == w + tmp exactly in infinite precision). + * The exactness of w + tmp in infinite precision depends on w + * and tmp having the same precision as x. If they have extra + * precision due to compiler bugs, then the extra precision is + * only good provided it is retained in all terms of the final + * expression for cos(). Retention happens in all cases tested + * under FreeBSD, so don't pessimize things by forcibly clipping + * any extra precision in w. + */ + +#include "libm.h" + +static const double +C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ +C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ +C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ +C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ +C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ +C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ + +double __cos(double x, double y) +{ + double_t hz,z,r,w; + + z = x*x; + w = z*z; + r = z*(C1+z*(C2+z*C3)) + w*w*(C4+z*(C5+z*C6)); + hz = 0.5*z; + w = 1.0-hz; + return w + (((1.0-w)-hz) + (z*r-x*y)); +} diff --git a/user/mpy/lib/libm_dbl/__expo2.c b/user/mpy/lib/libm_dbl/__expo2.c new file mode 100644 index 0000000..740ac68 --- /dev/null +++ b/user/mpy/lib/libm_dbl/__expo2.c @@ -0,0 +1,16 @@ +#include "libm.h" + +/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ +static const int k = 2043; +static const double kln2 = 0x1.62066151add8bp+10; + +/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ +double __expo2(double x) +{ + double scale; + + /* note that k is odd and scale*scale overflows */ + INSERT_WORDS(scale, (uint32_t)(0x3ff + k/2) << 20, 0); + /* exp(x - k ln2) * 2**(k-1) */ + return exp(x - kln2) * scale * scale; +} diff --git a/user/mpy/lib/libm_dbl/__fpclassify.c b/user/mpy/lib/libm_dbl/__fpclassify.c new file mode 100644 index 0000000..5c908ba --- /dev/null +++ b/user/mpy/lib/libm_dbl/__fpclassify.c @@ -0,0 +1,11 @@ +#include +#include + +int __fpclassifyd(double x) +{ + union {double f; uint64_t i;} u = {x}; + int e = u.i>>52 & 0x7ff; + if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; + if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE; + return FP_NORMAL; +} diff --git a/user/mpy/lib/libm_dbl/__rem_pio2.c b/user/mpy/lib/libm_dbl/__rem_pio2.c new file mode 100644 index 0000000..d403f81 --- /dev/null +++ b/user/mpy/lib/libm_dbl/__rem_pio2.c @@ -0,0 +1,177 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + * Optimized by Bruce D. Evans. + */ +/* __rem_pio2(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] + * use __rem_pio2_large() for large x + */ + +#include "libm.h" + +#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 +#define EPS DBL_EPSILON +#elif FLT_EVAL_METHOD==2 +#define EPS LDBL_EPSILON +#endif + +/* + * invpio2: 53 bits of 2/pi + * pio2_1: first 33 bit of pi/2 + * pio2_1t: pi/2 - pio2_1 + * pio2_2: second 33 bit of pi/2 + * pio2_2t: pi/2 - (pio2_1+pio2_2) + * pio2_3: third 33 bit of pi/2 + * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) + */ +static const double +toint = 1.5/EPS, +invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ +pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */ +pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */ +pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */ +pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ +pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ +pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ + +/* caller must handle the case when reduction is not needed: |x| ~<= pi/4 */ +int __rem_pio2(double x, double *y) +{ + union {double f; uint64_t i;} u = {x}; + double_t z,w,t,r,fn; + double tx[3],ty[2]; + uint32_t ix; + int sign, n, ex, ey, i; + + sign = u.i>>63; + ix = u.i>>32 & 0x7fffffff; + if (ix <= 0x400f6a7a) { /* |x| ~<= 5pi/4 */ + if ((ix & 0xfffff) == 0x921fb) /* |x| ~= pi/2 or 2pi/2 */ + goto medium; /* cancellation -- use medium case */ + if (ix <= 0x4002d97c) { /* |x| ~<= 3pi/4 */ + if (!sign) { + z = x - pio2_1; /* one round good to 85 bits */ + y[0] = z - pio2_1t; + y[1] = (z-y[0]) - pio2_1t; + return 1; + } else { + z = x + pio2_1; + y[0] = z + pio2_1t; + y[1] = (z-y[0]) + pio2_1t; + return -1; + } + } else { + if (!sign) { + z = x - 2*pio2_1; + y[0] = z - 2*pio2_1t; + y[1] = (z-y[0]) - 2*pio2_1t; + return 2; + } else { + z = x + 2*pio2_1; + y[0] = z + 2*pio2_1t; + y[1] = (z-y[0]) + 2*pio2_1t; + return -2; + } + } + } + if (ix <= 0x401c463b) { /* |x| ~<= 9pi/4 */ + if (ix <= 0x4015fdbc) { /* |x| ~<= 7pi/4 */ + if (ix == 0x4012d97c) /* |x| ~= 3pi/2 */ + goto medium; + if (!sign) { + z = x - 3*pio2_1; + y[0] = z - 3*pio2_1t; + y[1] = (z-y[0]) - 3*pio2_1t; + return 3; + } else { + z = x + 3*pio2_1; + y[0] = z + 3*pio2_1t; + y[1] = (z-y[0]) + 3*pio2_1t; + return -3; + } + } else { + if (ix == 0x401921fb) /* |x| ~= 4pi/2 */ + goto medium; + if (!sign) { + z = x - 4*pio2_1; + y[0] = z - 4*pio2_1t; + y[1] = (z-y[0]) - 4*pio2_1t; + return 4; + } else { + z = x + 4*pio2_1; + y[0] = z + 4*pio2_1t; + y[1] = (z-y[0]) + 4*pio2_1t; + return -4; + } + } + } + if (ix < 0x413921fb) { /* |x| ~< 2^20*(pi/2), medium size */ +medium: + /* rint(x/(pi/2)), Assume round-to-nearest. */ + fn = (double_t)x*invpio2 + toint - toint; + n = (int32_t)fn; + r = x - fn*pio2_1; + w = fn*pio2_1t; /* 1st round, good to 85 bits */ + y[0] = r - w; + u.f = y[0]; + ey = u.i>>52 & 0x7ff; + ex = ix>>20; + if (ex - ey > 16) { /* 2nd round, good to 118 bits */ + t = r; + w = fn*pio2_2; + r = t - w; + w = fn*pio2_2t - ((t-r)-w); + y[0] = r - w; + u.f = y[0]; + ey = u.i>>52 & 0x7ff; + if (ex - ey > 49) { /* 3rd round, good to 151 bits, covers all cases */ + t = r; + w = fn*pio2_3; + r = t - w; + w = fn*pio2_3t - ((t-r)-w); + y[0] = r - w; + } + } + y[1] = (r - y[0]) - w; + return n; + } + /* + * all other (large) arguments + */ + if (ix >= 0x7ff00000) { /* x is inf or NaN */ + y[0] = y[1] = x - x; + return 0; + } + /* set z = scalbn(|x|,-ilogb(x)+23) */ + u.f = x; + u.i &= (uint64_t)-1>>12; + u.i |= (uint64_t)(0x3ff + 23)<<52; + z = u.f; + for (i=0; i < 2; i++) { + tx[i] = (double)(int32_t)z; + z = (z-tx[i])*0x1p24; + } + tx[i] = z; + /* skip zero terms, first term is non-zero */ + while (tx[i] == 0.0) + i--; + n = __rem_pio2_large(tx,ty,(int)(ix>>20)-(0x3ff+23),i+1,1); + if (sign) { + y[0] = -ty[0]; + y[1] = -ty[1]; + return -n; + } + y[0] = ty[0]; + y[1] = ty[1]; + return n; +} diff --git a/user/mpy/lib/libm_dbl/__rem_pio2_large.c b/user/mpy/lib/libm_dbl/__rem_pio2_large.c new file mode 100644 index 0000000..958f28c --- /dev/null +++ b/user/mpy/lib/libm_dbl/__rem_pio2_large.c @@ -0,0 +1,442 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/k_rem_pio2.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* + * __rem_pio2_large(x,y,e0,nx,prec) + * double x[],y[]; int e0,nx,prec; + * + * __rem_pio2_large return the last three digits of N with + * y = x - N*pi/2 + * so that |y| < pi/2. + * + * The method is to compute the integer (mod 8) and fraction parts of + * (2/pi)*x without doing the full multiplication. In general we + * skip the part of the product that are known to be a huge integer ( + * more accurately, = 0 mod 8 ). Thus the number of operations are + * independent of the exponent of the input. + * + * (2/pi) is represented by an array of 24-bit integers in ipio2[]. + * + * Input parameters: + * x[] The input value (must be positive) is broken into nx + * pieces of 24-bit integers in double precision format. + * x[i] will be the i-th 24 bit of x. The scaled exponent + * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 + * match x's up to 24 bits. + * + * Example of breaking a double positive z into x[0]+x[1]+x[2]: + * e0 = ilogb(z)-23 + * z = scalbn(z,-e0) + * for i = 0,1,2 + * x[i] = floor(z) + * z = (z-x[i])*2**24 + * + * + * y[] ouput result in an array of double precision numbers. + * The dimension of y[] is: + * 24-bit precision 1 + * 53-bit precision 2 + * 64-bit precision 2 + * 113-bit precision 3 + * The actual value is the sum of them. Thus for 113-bit + * precison, one may have to do something like: + * + * long double t,w,r_head, r_tail; + * t = (long double)y[2] + (long double)y[1]; + * w = (long double)y[0]; + * r_head = t+w; + * r_tail = w - (r_head - t); + * + * e0 The exponent of x[0]. Must be <= 16360 or you need to + * expand the ipio2 table. + * + * nx dimension of x[] + * + * prec an integer indicating the precision: + * 0 24 bits (single) + * 1 53 bits (double) + * 2 64 bits (extended) + * 3 113 bits (quad) + * + * External function: + * double scalbn(), floor(); + * + * + * Here is the description of some local variables: + * + * jk jk+1 is the initial number of terms of ipio2[] needed + * in the computation. The minimum and recommended value + * for jk is 3,4,4,6 for single, double, extended, and quad. + * jk+1 must be 2 larger than you might expect so that our + * recomputation test works. (Up to 24 bits in the integer + * part (the 24 bits of it that we compute) and 23 bits in + * the fraction part may be lost to cancelation before we + * recompute.) + * + * jz local integer variable indicating the number of + * terms of ipio2[] used. + * + * jx nx - 1 + * + * jv index for pointing to the suitable ipio2[] for the + * computation. In general, we want + * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8 + * is an integer. Thus + * e0-3-24*jv >= 0 or (e0-3)/24 >= jv + * Hence jv = max(0,(e0-3)/24). + * + * jp jp+1 is the number of terms in PIo2[] needed, jp = jk. + * + * q[] double array with integral value, representing the + * 24-bits chunk of the product of x and 2/pi. + * + * q0 the corresponding exponent of q[0]. Note that the + * exponent for q[i] would be q0-24*i. + * + * PIo2[] double precision array, obtained by cutting pi/2 + * into 24 bits chunks. + * + * f[] ipio2[] in floating point + * + * iq[] integer array by breaking up q[] in 24-bits chunk. + * + * fq[] final product of x*(2/pi) in fq[0],..,fq[jk] + * + * ih integer. If >0 it indicates q[] is >= 0.5, hence + * it also indicates the *sign* of the result. + * + */ +/* + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "libm.h" + +static const int init_jk[] = {3,4,4,6}; /* initial value for jk */ + +/* + * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi + * + * integer array, contains the (24*i)-th to (24*i+23)-th + * bit of 2/pi after binary point. The corresponding + * floating value is + * + * ipio2[i] * 2^(-24(i+1)). + * + * NB: This table must have at least (e0-3)/24 + jk terms. + * For quad precision (e0 <= 16360, jk = 6), this is 686. + */ +static const int32_t ipio2[] = { +0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, +0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, +0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, +0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, +0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, +0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, +0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, +0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, +0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, +0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, +0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, + +#if LDBL_MAX_EXP > 1024 +0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6, +0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2, +0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35, +0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30, +0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C, +0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4, +0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770, +0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7, +0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19, +0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522, +0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16, +0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6, +0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E, +0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48, +0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3, +0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF, +0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55, +0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612, +0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929, +0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC, +0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B, +0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C, +0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4, +0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB, +0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC, +0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C, +0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F, +0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5, +0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437, +0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B, +0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA, +0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD, +0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3, +0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3, +0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717, +0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F, +0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61, +0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB, +0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51, +0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0, +0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C, +0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6, +0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC, +0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED, +0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328, +0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D, +0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0, +0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B, +0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4, +0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3, +0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F, +0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD, +0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B, +0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4, +0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761, +0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31, +0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30, +0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262, +0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E, +0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1, +0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C, +0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4, +0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08, +0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196, +0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9, +0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4, +0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC, +0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C, +0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0, +0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C, +0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0, +0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC, +0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22, +0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893, +0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7, +0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5, +0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F, +0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4, +0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF, +0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B, +0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2, +0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138, +0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E, +0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569, +0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34, +0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9, +0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D, +0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F, +0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855, +0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569, +0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B, +0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE, +0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41, +0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49, +0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F, +0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110, +0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8, +0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365, +0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A, +0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270, +0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5, +0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616, +0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B, +0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0, +#endif +}; + +static const double PIo2[] = { + 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ + 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ + 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ + 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */ + 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */ + 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */ + 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */ + 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ +}; + +int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec) +{ + int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; + double z,fw,f[20],fq[20],q[20]; + + /* initialize jk*/ + jk = init_jk[prec]; + jp = jk; + + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx-1; + jv = (e0-3)/24; if(jv<0) jv=0; + q0 = e0-24*(jv+1); + + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv-jx; m = jx+jk; + for (i=0; i<=m; i++,j++) + f[i] = j<0 ? 0.0 : (double)ipio2[j]; + + /* compute q[0],q[1],...q[jk] */ + for (i=0; i<=jk; i++) { + for (j=0,fw=0.0; j<=jx; j++) + fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + + jz = jk; +recompute: + /* distill q[] into iq[] reversingly */ + for (i=0,j=jz,z=q[jz]; j>0; i++,j--) { + fw = (double)(int32_t)(0x1p-24*z); + iq[i] = (int32_t)(z - 0x1p24*fw); + z = q[j-1]+fw; + } + + /* compute n */ + z = scalbn(z,q0); /* actual value of z */ + z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */ + n = (int32_t)z; + z -= (double)n; + ih = 0; + if (q0 > 0) { /* need iq[jz-1] to determine n */ + i = iq[jz-1]>>(24-q0); n += i; + iq[jz-1] -= i<<(24-q0); + ih = iq[jz-1]>>(23-q0); + } + else if (q0 == 0) ih = iq[jz-1]>>23; + else if (z >= 0.5) ih = 2; + + if (ih > 0) { /* q > 0.5 */ + n += 1; carry = 0; + for (i=0; i 0) { /* rare case: chance is 1 in 12 */ + switch(q0) { + case 1: + iq[jz-1] &= 0x7fffff; break; + case 2: + iq[jz-1] &= 0x3fffff; break; + } + } + if (ih == 2) { + z = 1.0 - z; + if (carry != 0) + z -= scalbn(1.0,q0); + } + } + + /* check if recomputation is needed */ + if (z == 0.0) { + j = 0; + for (i=jz-1; i>=jk; i--) j |= iq[i]; + if (j == 0) { /* need recomputation */ + for (k=1; iq[jk-k]==0; k++); /* k = no. of terms needed */ + + for (i=jz+1; i<=jz+k; i++) { /* add q[jz+1] to q[jz+k] */ + f[jx+i] = (double)ipio2[jv+i]; + for (j=0,fw=0.0; j<=jx; j++) + fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + jz += k; + goto recompute; + } + } + + /* chop off zero terms */ + if (z == 0.0) { + jz -= 1; + q0 -= 24; + while (iq[jz] == 0) { + jz--; + q0 -= 24; + } + } else { /* break z into 24-bit if necessary */ + z = scalbn(z,-q0); + if (z >= 0x1p24) { + fw = (double)(int32_t)(0x1p-24*z); + iq[jz] = (int32_t)(z - 0x1p24*fw); + jz += 1; + q0 += 24; + iq[jz] = (int32_t)fw; + } else + iq[jz] = (int32_t)z; + } + + /* convert integer "bit" chunk to floating-point value */ + fw = scalbn(1.0,q0); + for (i=jz; i>=0; i--) { + q[i] = fw*(double)iq[i]; + fw *= 0x1p-24; + } + + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + for(i=jz; i>=0; i--) { + for (fw=0.0,k=0; k<=jp && k<=jz-i; k++) + fw += PIo2[k]*q[i+k]; + fq[jz-i] = fw; + } + + /* compress fq[] into y[] */ + switch(prec) { + case 0: + fw = 0.0; + for (i=jz; i>=0; i--) + fw += fq[i]; + y[0] = ih==0 ? fw : -fw; + break; + case 1: + case 2: + fw = 0.0; + for (i=jz; i>=0; i--) + fw += fq[i]; + // TODO: drop excess precision here once double_t is used + fw = (double)fw; + y[0] = ih==0 ? fw : -fw; + fw = fq[0]-fw; + for (i=1; i<=jz; i++) + fw += fq[i]; + y[1] = ih==0 ? fw : -fw; + break; + case 3: /* painful */ + for (i=jz; i>0; i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (i=jz; i>1; i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (fw=0.0,i=jz; i>=2; i--) + fw += fq[i]; + if (ih==0) { + y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; + } else { + y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; + } + } + return n&7; +} diff --git a/user/mpy/lib/libm_dbl/__signbit.c b/user/mpy/lib/libm_dbl/__signbit.c new file mode 100644 index 0000000..18c6728 --- /dev/null +++ b/user/mpy/lib/libm_dbl/__signbit.c @@ -0,0 +1,12 @@ +#include "libm.h" + +int __signbitd(double x) +{ + union { + double d; + uint64_t i; + } y = { x }; + return y.i>>63; +} + + diff --git a/user/mpy/lib/libm_dbl/__sin.c b/user/mpy/lib/libm_dbl/__sin.c new file mode 100644 index 0000000..4030949 --- /dev/null +++ b/user/mpy/lib/libm_dbl/__sin.c @@ -0,0 +1,64 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/k_sin.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* __sin( x, y, iy) + * kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). + * + * Algorithm + * 1. Since sin(-x) = -sin(x), we need only to consider positive x. + * 2. Callers must return sin(-0) = -0 without calling here since our + * odd polynomial is not evaluated in a way that preserves -0. + * Callers may do the optimization sin(x) ~ x for tiny x. + * 3. sin(x) is approximated by a polynomial of degree 13 on + * [0,pi/4] + * 3 13 + * sin(x) ~ x + S1*x + ... + S6*x + * where + * + * |sin(x) 2 4 6 8 10 12 | -58 + * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 + * | x | + * + * 4. sin(x+y) = sin(x) + sin'(x')*y + * ~ sin(x) + (1-x*x/2)*y + * For better accuracy, let + * 3 2 2 2 2 + * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) + * then 3 2 + * sin(x) = x + (S1*x + (x *(r-y/2)+y)) + */ + +#include "libm.h" + +static const double +S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ +S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ +S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ +S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ +S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ +S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ + +double __sin(double x, double y, int iy) +{ + double_t z,r,v,w; + + z = x*x; + w = z*z; + r = S2 + z*(S3 + z*S4) + z*w*(S5 + z*S6); + v = z*x; + if (iy == 0) + return x + v*(S1 + z*r); + else + return x - ((z*(0.5*y - v*r) - y) - v*S1); +} diff --git a/user/mpy/lib/libm_dbl/__tan.c b/user/mpy/lib/libm_dbl/__tan.c new file mode 100644 index 0000000..8019844 --- /dev/null +++ b/user/mpy/lib/libm_dbl/__tan.c @@ -0,0 +1,110 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/k_tan.c */ +/* + * ==================================================== + * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* __tan( x, y, k ) + * kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input odd indicates whether tan (if odd = 0) or -1/tan (if odd = 1) is returned. + * + * Algorithm + * 1. Since tan(-x) = -tan(x), we need only to consider positive x. + * 2. Callers must return tan(-0) = -0 without calling here since our + * odd polynomial is not evaluated in a way that preserves -0. + * Callers may do the optimization tan(x) ~ x for tiny x. + * 3. tan(x) is approximated by a odd polynomial of degree 27 on + * [0,0.67434] + * 3 27 + * tan(x) ~ x + T1*x + ... + T13*x + * where + * + * |tan(x) 2 4 26 | -59.2 + * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 + * | x | + * + * Note: tan(x+y) = tan(x) + tan'(x)*y + * ~ tan(x) + (1+x*x)*y + * Therefore, for better accuracy in computing tan(x+y), let + * 3 2 2 2 2 + * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) + * then + * 3 2 + * tan(x+y) = x + (T1*x + (x *(r+y)+y)) + * + * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then + * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) + * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) + */ + +#include "libm.h" + +static const double T[] = { + 3.33333333333334091986e-01, /* 3FD55555, 55555563 */ + 1.33333333333201242699e-01, /* 3FC11111, 1110FE7A */ + 5.39682539762260521377e-02, /* 3FABA1BA, 1BB341FE */ + 2.18694882948595424599e-02, /* 3F9664F4, 8406D637 */ + 8.86323982359930005737e-03, /* 3F8226E3, E96E8493 */ + 3.59207910759131235356e-03, /* 3F6D6D22, C9560328 */ + 1.45620945432529025516e-03, /* 3F57DBC8, FEE08315 */ + 5.88041240820264096874e-04, /* 3F4344D8, F2F26501 */ + 2.46463134818469906812e-04, /* 3F3026F7, 1A8D1068 */ + 7.81794442939557092300e-05, /* 3F147E88, A03792A6 */ + 7.14072491382608190305e-05, /* 3F12B80F, 32F0A7E9 */ + -1.85586374855275456654e-05, /* BEF375CB, DB605373 */ + 2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */ +}, +pio4 = 7.85398163397448278999e-01, /* 3FE921FB, 54442D18 */ +pio4lo = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */ + +double __tan(double x, double y, int odd) +{ + double_t z, r, v, w, s, a; + double w0, a0; + uint32_t hx; + int big, sign; + + GET_HIGH_WORD(hx,x); + big = (hx&0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */ + if (big) { + sign = hx>>31; + if (sign) { + x = -x; + y = -y; + } + x = (pio4 - x) + (pio4lo - y); + y = 0.0; + } + z = x * x; + w = z * z; + /* + * Break x^5*(T[1]+x^2*T[2]+...) into + * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) + */ + r = T[1] + w*(T[3] + w*(T[5] + w*(T[7] + w*(T[9] + w*T[11])))); + v = z*(T[2] + w*(T[4] + w*(T[6] + w*(T[8] + w*(T[10] + w*T[12]))))); + s = z * x; + r = y + z*(s*(r + v) + y) + s*T[0]; + w = x + r; + if (big) { + s = 1 - 2*odd; + v = s - 2.0 * (x + (r - w*w/(w + s))); + return sign ? -v : v; + } + if (!odd) + return w; + /* -1.0/(x+r) has up to 2ulp error, so compute it accurately */ + w0 = w; + SET_LOW_WORD(w0, 0); + v = r - (w0 - x); /* w0+v = r+x */ + a0 = a = -1.0 / w; + SET_LOW_WORD(a0, 0); + return a0 + a*(1.0 + a0*w0 + a0*v); +} diff --git a/user/mpy/lib/libm_dbl/acos.c b/user/mpy/lib/libm_dbl/acos.c new file mode 100644 index 0000000..6104a32 --- /dev/null +++ b/user/mpy/lib/libm_dbl/acos.c @@ -0,0 +1,101 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_acos.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* acos(x) + * Method : + * acos(x) = pi/2 - asin(x) + * acos(-x) = pi/2 + asin(x) + * For |x|<=0.5 + * acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c) + * For x>0.5 + * acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2))) + * = 2asin(sqrt((1-x)/2)) + * = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z) + * = 2f + (2c + 2s*z*R(z)) + * where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term + * for f so that f+c ~ sqrt(z). + * For x<-0.5 + * acos(x) = pi - 2asin(sqrt((1-|x|)/2)) + * = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z) + * + * Special cases: + * if x is NaN, return x itself; + * if |x|>1, return NaN with invalid signal. + * + * Function needed: sqrt + */ + +#include "libm.h" + +static const double +pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ +pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ +pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ +pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ +pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ +pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ +pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ +pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ +qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ +qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ +qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ +qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ + +static double R(double z) +{ + double_t p, q; + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + return p/q; +} + +double acos(double x) +{ + double z,w,s,c,df; + uint32_t hx,ix; + + GET_HIGH_WORD(hx, x); + ix = hx & 0x7fffffff; + /* |x| >= 1 or nan */ + if (ix >= 0x3ff00000) { + uint32_t lx; + + GET_LOW_WORD(lx,x); + if (((ix-0x3ff00000) | lx) == 0) { + /* acos(1)=0, acos(-1)=pi */ + if (hx >> 31) + return 2*pio2_hi + 0x1p-120f; + return 0; + } + return 0/(x-x); + } + /* |x| < 0.5 */ + if (ix < 0x3fe00000) { + if (ix <= 0x3c600000) /* |x| < 2**-57 */ + return pio2_hi + 0x1p-120f; + return pio2_hi - (x - (pio2_lo-x*R(x*x))); + } + /* x < -0.5 */ + if (hx >> 31) { + z = (1.0+x)*0.5; + s = sqrt(z); + w = R(z)*s-pio2_lo; + return 2*(pio2_hi - (s+w)); + } + /* x > 0.5 */ + z = (1.0-x)*0.5; + s = sqrt(z); + df = s; + SET_LOW_WORD(df,0); + c = (z-df*df)/(s+df); + w = R(z)*s+c; + return 2*(df+w); +} diff --git a/user/mpy/lib/libm_dbl/acosh.c b/user/mpy/lib/libm_dbl/acosh.c new file mode 100644 index 0000000..badbf90 --- /dev/null +++ b/user/mpy/lib/libm_dbl/acosh.c @@ -0,0 +1,24 @@ +#include "libm.h" + +#if FLT_EVAL_METHOD==2 +#undef sqrt +#define sqrt sqrtl +#endif + +/* acosh(x) = log(x + sqrt(x*x-1)) */ +double acosh(double x) +{ + union {double f; uint64_t i;} u = {.f = x}; + unsigned e = u.i >> 52 & 0x7ff; + + /* x < 1 domain error is handled in the called functions */ + + if (e < 0x3ff + 1) + /* |x| < 2, up to 2ulp error in [1,1.125] */ + return log1p(x-1 + sqrt((x-1)*(x-1)+2*(x-1))); + if (e < 0x3ff + 26) + /* |x| < 0x1p26 */ + return log(2*x - 1/(x+sqrt(x*x-1))); + /* |x| >= 0x1p26 or nan */ + return log(x) + 0.693147180559945309417232121458176568; +} diff --git a/user/mpy/lib/libm_dbl/asin.c b/user/mpy/lib/libm_dbl/asin.c new file mode 100644 index 0000000..96b4cdf --- /dev/null +++ b/user/mpy/lib/libm_dbl/asin.c @@ -0,0 +1,107 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_asin.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* asin(x) + * Method : + * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... + * we approximate asin(x) on [0,0.5] by + * asin(x) = x + x*x^2*R(x^2) + * where + * R(x^2) is a rational approximation of (asin(x)-x)/x^3 + * and its remez error is bounded by + * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75) + * + * For x in [0.5,1] + * asin(x) = pi/2-2*asin(sqrt((1-x)/2)) + * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; + * then for x>0.98 + * asin(x) = pi/2 - 2*(s+s*z*R(z)) + * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) + * For x<=0.98, let pio4_hi = pio2_hi/2, then + * f = hi part of s; + * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) + * and + * asin(x) = pi/2 - 2*(s+s*z*R(z)) + * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) + * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) + * + * Special cases: + * if x is NaN, return x itself; + * if |x|>1, return NaN with invalid signal. + * + */ + +#include "libm.h" + +static const double +pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ +pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ +/* coefficients for R(x^2) */ +pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ +pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ +pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ +pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ +pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ +pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ +qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ +qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ +qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ +qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ + +static double R(double z) +{ + double_t p, q; + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + return p/q; +} + +double asin(double x) +{ + double z,r,s; + uint32_t hx,ix; + + GET_HIGH_WORD(hx, x); + ix = hx & 0x7fffffff; + /* |x| >= 1 or nan */ + if (ix >= 0x3ff00000) { + uint32_t lx; + GET_LOW_WORD(lx, x); + if (((ix-0x3ff00000) | lx) == 0) + /* asin(1) = +-pi/2 with inexact */ + return x*pio2_hi + 0x1p-120f; + return 0/(x-x); + } + /* |x| < 0.5 */ + if (ix < 0x3fe00000) { + /* if 0x1p-1022 <= |x| < 0x1p-26, avoid raising underflow */ + if (ix < 0x3e500000 && ix >= 0x00100000) + return x; + return x + x*R(x*x); + } + /* 1 > |x| >= 0.5 */ + z = (1 - fabs(x))*0.5; + s = sqrt(z); + r = R(z); + if (ix >= 0x3fef3333) { /* if |x| > 0.975 */ + x = pio2_hi-(2*(s+s*r)-pio2_lo); + } else { + double f,c; + /* f+c = sqrt(z) */ + f = s; + SET_LOW_WORD(f,0); + c = (z-f*f)/(s+f); + x = 0.5*pio2_hi - (2*s*r - (pio2_lo-2*c) - (0.5*pio2_hi-2*f)); + } + if (hx >> 31) + return -x; + return x; +} diff --git a/user/mpy/lib/libm_dbl/asinh.c b/user/mpy/lib/libm_dbl/asinh.c new file mode 100644 index 0000000..0829f22 --- /dev/null +++ b/user/mpy/lib/libm_dbl/asinh.c @@ -0,0 +1,28 @@ +#include "libm.h" + +/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ +double asinh(double x) +{ + union {double f; uint64_t i;} u = {.f = x}; + unsigned e = u.i >> 52 & 0x7ff; + unsigned s = u.i >> 63; + + /* |x| */ + u.i &= (uint64_t)-1/2; + x = u.f; + + if (e >= 0x3ff + 26) { + /* |x| >= 0x1p26 or inf or nan */ + x = log(x) + 0.693147180559945309417232121458176568; + } else if (e >= 0x3ff + 1) { + /* |x| >= 2 */ + x = log(2*x + 1/(sqrt(x*x+1)+x)); + } else if (e >= 0x3ff - 26) { + /* |x| >= 0x1p-26, up to 1.6ulp error in [0.125,0.5] */ + x = log1p(x + x*x/(sqrt(x*x+1)+1)); + } else { + /* |x| < 0x1p-26, raise inexact if x != 0 */ + FORCE_EVAL(x + 0x1p120f); + } + return s ? -x : x; +} diff --git a/user/mpy/lib/libm_dbl/atan.c b/user/mpy/lib/libm_dbl/atan.c new file mode 100644 index 0000000..63b0ab2 --- /dev/null +++ b/user/mpy/lib/libm_dbl/atan.c @@ -0,0 +1,116 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_atan.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* atan(x) + * Method + * 1. Reduce x to positive by atan(x) = -atan(-x). + * 2. According to the integer k=4t+0.25 chopped, t=x, the argument + * is further reduced to one of the following intervals and the + * arctangent of t is evaluated by the corresponding formula: + * + * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...) + * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) ) + * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) ) + * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) ) + * [39/16,INF] atan(x) = atan(INF) + atan( -1/t ) + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + + +#include "libm.h" + +static const double atanhi[] = { + 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ + 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */ + 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */ + 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */ +}; + +static const double atanlo[] = { + 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */ + 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */ + 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */ + 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ +}; + +static const double aT[] = { + 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ + -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ + 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ + -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */ + 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */ + -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */ + 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */ + -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */ + 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */ + -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */ + 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ +}; + +double atan(double x) +{ + double_t w,s1,s2,z; + uint32_t ix,sign; + int id; + + GET_HIGH_WORD(ix, x); + sign = ix >> 31; + ix &= 0x7fffffff; + if (ix >= 0x44100000) { /* if |x| >= 2^66 */ + if (isnan(x)) + return x; + z = atanhi[3] + 0x1p-120f; + return sign ? -z : z; + } + if (ix < 0x3fdc0000) { /* |x| < 0.4375 */ + if (ix < 0x3e400000) { /* |x| < 2^-27 */ + if (ix < 0x00100000) + /* raise underflow for subnormal x */ + FORCE_EVAL((float)x); + return x; + } + id = -1; + } else { + x = fabs(x); + if (ix < 0x3ff30000) { /* |x| < 1.1875 */ + if (ix < 0x3fe60000) { /* 7/16 <= |x| < 11/16 */ + id = 0; + x = (2.0*x-1.0)/(2.0+x); + } else { /* 11/16 <= |x| < 19/16 */ + id = 1; + x = (x-1.0)/(x+1.0); + } + } else { + if (ix < 0x40038000) { /* |x| < 2.4375 */ + id = 2; + x = (x-1.5)/(1.0+1.5*x); + } else { /* 2.4375 <= |x| < 2^66 */ + id = 3; + x = -1.0/x; + } + } + } + /* end of argument reduction */ + z = x*x; + w = z*z; + /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ + s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); + s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); + if (id < 0) + return x - x*(s1+s2); + z = atanhi[id] - (x*(s1+s2) - atanlo[id] - x); + return sign ? -z : z; +} diff --git a/user/mpy/lib/libm_dbl/atan2.c b/user/mpy/lib/libm_dbl/atan2.c new file mode 100644 index 0000000..91378b9 --- /dev/null +++ b/user/mpy/lib/libm_dbl/atan2.c @@ -0,0 +1,107 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ +/* atan2(y,x) + * Method : + * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). + * 2. Reduce x to positive by (if x and y are unexceptional): + * ARG (x+iy) = arctan(y/x) ... if x > 0, + * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, + * + * Special cases: + * + * ATAN2((anything), NaN ) is NaN; + * ATAN2(NAN , (anything) ) is NaN; + * ATAN2(+-0, +(anything but NaN)) is +-0 ; + * ATAN2(+-0, -(anything but NaN)) is +-pi ; + * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; + * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; + * ATAN2(+-(anything but INF and NaN), -INF) is +-pi; + * ATAN2(+-INF,+INF ) is +-pi/4 ; + * ATAN2(+-INF,-INF ) is +-3pi/4; + * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "libm.h" + +static const double +pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ +pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ + +double atan2(double y, double x) +{ + double z; + uint32_t m,lx,ly,ix,iy; + + if (isnan(x) || isnan(y)) + return x+y; + EXTRACT_WORDS(ix, lx, x); + EXTRACT_WORDS(iy, ly, y); + if (((ix-0x3ff00000) | lx) == 0) /* x = 1.0 */ + return atan(y); + m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ + ix = ix & 0x7fffffff; + iy = iy & 0x7fffffff; + + /* when y = 0 */ + if ((iy|ly) == 0) { + switch(m) { + case 0: + case 1: return y; /* atan(+-0,+anything)=+-0 */ + case 2: return pi; /* atan(+0,-anything) = pi */ + case 3: return -pi; /* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if ((ix|lx) == 0) + return m&1 ? -pi/2 : pi/2; + /* when x is INF */ + if (ix == 0x7ff00000) { + if (iy == 0x7ff00000) { + switch(m) { + case 0: return pi/4; /* atan(+INF,+INF) */ + case 1: return -pi/4; /* atan(-INF,+INF) */ + case 2: return 3*pi/4; /* atan(+INF,-INF) */ + case 3: return -3*pi/4; /* atan(-INF,-INF) */ + } + } else { + switch(m) { + case 0: return 0.0; /* atan(+...,+INF) */ + case 1: return -0.0; /* atan(-...,+INF) */ + case 2: return pi; /* atan(+...,-INF) */ + case 3: return -pi; /* atan(-...,-INF) */ + } + } + } + /* |y/x| > 0x1p64 */ + if (ix+(64<<20) < iy || iy == 0x7ff00000) + return m&1 ? -pi/2 : pi/2; + + /* z = atan(|y/x|) without spurious underflow */ + if ((m&2) && iy+(64<<20) < ix) /* |y/x| < 0x1p-64, x<0 */ + z = 0; + else + z = atan(fabs(y/x)); + switch (m) { + case 0: return z; /* atan(+,+) */ + case 1: return -z; /* atan(-,+) */ + case 2: return pi - (z-pi_lo); /* atan(+,-) */ + default: /* case 3 */ + return (z-pi_lo) - pi; /* atan(-,-) */ + } +} diff --git a/user/mpy/lib/libm_dbl/atanh.c b/user/mpy/lib/libm_dbl/atanh.c new file mode 100644 index 0000000..63a035d --- /dev/null +++ b/user/mpy/lib/libm_dbl/atanh.c @@ -0,0 +1,29 @@ +#include "libm.h" + +/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ +double atanh(double x) +{ + union {double f; uint64_t i;} u = {.f = x}; + unsigned e = u.i >> 52 & 0x7ff; + unsigned s = u.i >> 63; + double_t y; + + /* |x| */ + u.i &= (uint64_t)-1/2; + y = u.f; + + if (e < 0x3ff - 1) { + if (e < 0x3ff - 32) { + /* handle underflow */ + if (e == 0) + FORCE_EVAL((float)y); + } else { + /* |x| < 0.5, up to 1.7ulp error */ + y = 0.5*log1p(2*y + 2*y*y/(1-y)); + } + } else { + /* avoid overflow */ + y = 0.5*log1p(2*(y/(1-y))); + } + return s ? -y : y; +} diff --git a/user/mpy/lib/libm_dbl/ceil.c b/user/mpy/lib/libm_dbl/ceil.c new file mode 100644 index 0000000..b13e6f2 --- /dev/null +++ b/user/mpy/lib/libm_dbl/ceil.c @@ -0,0 +1,31 @@ +#include "libm.h" + +#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 +#define EPS DBL_EPSILON +#elif FLT_EVAL_METHOD==2 +#define EPS LDBL_EPSILON +#endif +static const double_t toint = 1/EPS; + +double ceil(double x) +{ + union {double f; uint64_t i;} u = {x}; + int e = u.i >> 52 & 0x7ff; + double_t y; + + if (e >= 0x3ff+52 || x == 0) + return x; + /* y = int(x) - x, where int(x) is an integer neighbor of x */ + if (u.i >> 63) + y = x - toint + toint - x; + else + y = x + toint - toint - x; + /* special case because of non-nearest rounding modes */ + if (e <= 0x3ff-1) { + FORCE_EVAL(y); + return u.i >> 63 ? -0.0 : 1; + } + if (y < 0) + return x + y + 1; + return x + y; +} diff --git a/user/mpy/lib/libm_dbl/cos.c b/user/mpy/lib/libm_dbl/cos.c new file mode 100644 index 0000000..ee97f68 --- /dev/null +++ b/user/mpy/lib/libm_dbl/cos.c @@ -0,0 +1,77 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* cos(x) + * Return cosine function of x. + * + * kernel function: + * __sin ... sine function on [-pi/4,pi/4] + * __cos ... cosine function on [-pi/4,pi/4] + * __rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "libm.h" + +double cos(double x) +{ + double y[2]; + uint32_t ix; + unsigned n; + + GET_HIGH_WORD(ix, x); + ix &= 0x7fffffff; + + /* |x| ~< pi/4 */ + if (ix <= 0x3fe921fb) { + if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */ + /* raise inexact if x!=0 */ + FORCE_EVAL(x + 0x1p120f); + return 1.0; + } + return __cos(x, 0); + } + + /* cos(Inf or NaN) is NaN */ + if (ix >= 0x7ff00000) + return x-x; + + /* argument reduction */ + n = __rem_pio2(x, y); + switch (n&3) { + case 0: return __cos(y[0], y[1]); + case 1: return -__sin(y[0], y[1], 1); + case 2: return -__cos(y[0], y[1]); + default: + return __sin(y[0], y[1], 1); + } +} diff --git a/user/mpy/lib/libm_dbl/cosh.c b/user/mpy/lib/libm_dbl/cosh.c new file mode 100644 index 0000000..100f823 --- /dev/null +++ b/user/mpy/lib/libm_dbl/cosh.c @@ -0,0 +1,40 @@ +#include "libm.h" + +/* cosh(x) = (exp(x) + 1/exp(x))/2 + * = 1 + 0.5*(exp(x)-1)*(exp(x)-1)/exp(x) + * = 1 + x*x/2 + o(x^4) + */ +double cosh(double x) +{ + union {double f; uint64_t i;} u = {.f = x}; + uint32_t w; + double t; + + /* |x| */ + u.i &= (uint64_t)-1/2; + x = u.f; + w = u.i >> 32; + + /* |x| < log(2) */ + if (w < 0x3fe62e42) { + if (w < 0x3ff00000 - (26<<20)) { + /* raise inexact if x!=0 */ + FORCE_EVAL(x + 0x1p120f); + return 1; + } + t = expm1(x); + return 1 + t*t/(2*(1+t)); + } + + /* |x| < log(DBL_MAX) */ + if (w < 0x40862e42) { + t = exp(x); + /* note: if x>log(0x1p26) then the 1/t is not needed */ + return 0.5*(t + 1/t); + } + + /* |x| > log(DBL_MAX) or nan */ + /* note: the result is stored to handle overflow */ + t = __expo2(x); + return t; +} diff --git a/user/mpy/lib/libm_dbl/erf.c b/user/mpy/lib/libm_dbl/erf.c new file mode 100644 index 0000000..2f30a29 --- /dev/null +++ b/user/mpy/lib/libm_dbl/erf.c @@ -0,0 +1,273 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_erf.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* double erf(double x) + * double erfc(double x) + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * Note that + * erf(-x) = -erf(x) + * erfc(-x) = 2 - erfc(x) + * + * Method: + * 1. For |x| in [0, 0.84375] + * erf(x) = x + x*R(x^2) + * erfc(x) = 1 - erf(x) if x in [-.84375,0.25] + * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] + * where R = P/Q where P is an odd poly of degree 8 and + * Q is an odd poly of degree 10. + * -57.90 + * | R - (erf(x)-x)/x | <= 2 + * + * + * Remark. The formula is derived by noting + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) + * and that + * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 + * is close to one. The interval is chosen because the fix + * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is + * near 0.6174), and by some experiment, 0.84375 is chosen to + * guarantee the error is less than one ulp for erf. + * + * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(x) = sign(x) * (c + P1(s)/Q1(s)) + * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0 + * 1+(c+P1(s)/Q1(s)) if x < 0 + * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06 + * Remark: here we use the taylor series expansion at x=1. + * erf(1+s) = erf(1) + s*Poly(s) + * = 0.845.. + P1(s)/Q1(s) + * That is, we use rational approximation to approximate + * erf(1+s) - (c = (single)0.84506291151) + * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] + * where + * P1(s) = degree 6 poly in s + * Q1(s) = degree 6 poly in s + * + * 3. For x in [1.25,1/0.35(~2.857143)], + * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1) + * erf(x) = 1 - erfc(x) + * where + * R1(z) = degree 7 poly in z, (z=1/x^2) + * S1(z) = degree 8 poly in z + * + * 4. For x in [1/0.35,28] + * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0 + * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6 x >= 28 + * erf(x) = sign(x) *(1 - tiny) (raise inexact) + * erfc(x) = tiny*tiny (raise underflow) if x > 0 + * = 2 - tiny if x<0 + * + * 7. Special case: + * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, + * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, + * erfc/erf(NaN) is NaN + */ + +#include "libm.h" + +static const double +erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +efx8 = 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ +pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */ +pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */ +pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */ +pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */ +pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */ +qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */ +qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */ +qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */ +qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */ +qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */ +pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */ +pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */ +pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */ +pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */ +pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */ +pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */ +qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */ +qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */ +qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */ +qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */ +qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */ +qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */ +ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */ +ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */ +ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */ +ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */ +ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */ +ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */ +ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */ +sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */ +sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */ +sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */ +sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */ +sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */ +sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */ +sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */ +sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */ +rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */ +rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */ +rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */ +rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */ +rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */ +rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */ +sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ +sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */ +sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */ +sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */ +sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */ +sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ +sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ + +static double erfc1(double x) +{ + double_t s,P,Q; + + s = fabs(x) - 1; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = 1+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + return 1 - erx - P/Q; +} + +static double erfc2(uint32_t ix, double x) +{ + double_t s,R,S; + double z; + + if (ix < 0x3ff40000) /* |x| < 1.25 */ + return erfc1(x); + + x = fabs(x); + s = 1/(x*x); + if (ix < 0x4006db6d) { /* |x| < 1/.35 ~ 2.85714 */ + R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S = 1.0+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| > 1/.35 */ + R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S = 1.0+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + z = x; + SET_LOW_WORD(z,0); + return exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S)/x; +} + +double erf(double x) +{ + double r,s,z,y; + uint32_t ix; + int sign; + + GET_HIGH_WORD(ix, x); + sign = ix>>31; + ix &= 0x7fffffff; + if (ix >= 0x7ff00000) { + /* erf(nan)=nan, erf(+-inf)=+-1 */ + return 1-2*sign + 1/x; + } + if (ix < 0x3feb0000) { /* |x| < 0.84375 */ + if (ix < 0x3e300000) { /* |x| < 2**-28 */ + /* avoid underflow */ + return 0.125*(8*x + efx8*x); + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = 1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + return x + x*y; + } + if (ix < 0x40180000) /* 0.84375 <= |x| < 6 */ + y = 1 - erfc2(ix,x); + else + y = 1 - 0x1p-1022; + return sign ? -y : y; +} + +double erfc(double x) +{ + double r,s,z,y; + uint32_t ix; + int sign; + + GET_HIGH_WORD(ix, x); + sign = ix>>31; + ix &= 0x7fffffff; + if (ix >= 0x7ff00000) { + /* erfc(nan)=nan, erfc(+-inf)=0,2 */ + return 2*sign + 1/x; + } + if (ix < 0x3feb0000) { /* |x| < 0.84375 */ + if (ix < 0x3c700000) /* |x| < 2**-56 */ + return 1.0 - x; + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = 1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + if (sign || ix < 0x3fd00000) { /* x < 1/4 */ + return 1.0 - (x+x*y); + } + return 0.5 - (x - 0.5 + x*y); + } + if (ix < 0x403c0000) { /* 0.84375 <= |x| < 28 */ + return sign ? 2 - erfc2(ix,x) : erfc2(ix,x); + } + return sign ? 2 - 0x1p-1022 : 0x1p-1022*0x1p-1022; +} diff --git a/user/mpy/lib/libm_dbl/exp.c b/user/mpy/lib/libm_dbl/exp.c new file mode 100644 index 0000000..9ea672f --- /dev/null +++ b/user/mpy/lib/libm_dbl/exp.c @@ -0,0 +1,134 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_exp.c */ +/* + * ==================================================== + * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* exp(x) + * Returns the exponential of x. + * + * Method + * 1. Argument reduction: + * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. + * Given x, find r and integer k such that + * + * x = k*ln2 + r, |r| <= 0.5*ln2. + * + * Here r will be represented as r = hi-lo for better + * accuracy. + * + * 2. Approximation of exp(r) by a special rational function on + * the interval [0,0.34658]: + * Write + * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ... + * We use a special Remez algorithm on [0,0.34658] to generate + * a polynomial of degree 5 to approximate R. The maximum error + * of this polynomial approximation is bounded by 2**-59. In + * other words, + * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5 + * (where z=r*r, and the values of P1 to P5 are listed below) + * and + * | 5 | -59 + * | 2.0+P1*z+...+P5*z - R(z) | <= 2 + * | | + * The computation of exp(r) thus becomes + * 2*r + * exp(r) = 1 + ---------- + * R(r) - r + * r*c(r) + * = 1 + r + ----------- (for better accuracy) + * 2 - c(r) + * where + * 2 4 10 + * c(r) = r - (P1*r + P2*r + ... + P5*r ). + * + * 3. Scale back to obtain exp(x): + * From step 1, we have + * exp(x) = 2^k * exp(r) + * + * Special cases: + * exp(INF) is INF, exp(NaN) is NaN; + * exp(-INF) is 0, and + * for finite argument, only exp(0)=1 is exact. + * + * Accuracy: + * according to an error analysis, the error is always less than + * 1 ulp (unit in the last place). + * + * Misc. info. + * For IEEE double + * if x > 709.782712893383973096 then exp(x) overflows + * if x < -745.133219101941108420 then exp(x) underflows + */ + +#include "libm.h" + +static const double +half[2] = {0.5,-0.5}, +ln2hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ +ln2lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ +invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ +P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ +P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ +P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ +P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ +P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ + +double exp(double x) +{ + double_t hi, lo, c, xx, y; + int k, sign; + uint32_t hx; + + GET_HIGH_WORD(hx, x); + sign = hx>>31; + hx &= 0x7fffffff; /* high word of |x| */ + + /* special cases */ + if (hx >= 0x4086232b) { /* if |x| >= 708.39... */ + if (isnan(x)) + return x; + if (x > 709.782712893383973096) { + /* overflow if x!=inf */ + x *= 0x1p1023; + return x; + } + if (x < -708.39641853226410622) { + /* underflow if x!=-inf */ + FORCE_EVAL((float)(-0x1p-149/x)); + if (x < -745.13321910194110842) + return 0; + } + } + + /* argument reduction */ + if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if (hx >= 0x3ff0a2b2) /* if |x| >= 1.5 ln2 */ + k = (int)(invln2*x + half[sign]); + else + k = 1 - sign - sign; + hi = x - k*ln2hi; /* k*ln2hi is exact here */ + lo = k*ln2lo; + x = hi - lo; + } else if (hx > 0x3e300000) { /* if |x| > 2**-28 */ + k = 0; + hi = x; + lo = 0; + } else { + /* inexact if x!=0 */ + FORCE_EVAL(0x1p1023 + x); + return 1 + x; + } + + /* x is now in primary range */ + xx = x*x; + c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5)))); + y = 1 + (x*c/(2-c) - lo + hi); + if (k == 0) + return y; + return scalbn(y, k); +} diff --git a/user/mpy/lib/libm_dbl/expm1.c b/user/mpy/lib/libm_dbl/expm1.c new file mode 100644 index 0000000..ac1e61e --- /dev/null +++ b/user/mpy/lib/libm_dbl/expm1.c @@ -0,0 +1,201 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_expm1.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* expm1(x) + * Returns exp(x)-1, the exponential of x minus 1. + * + * Method + * 1. Argument reduction: + * Given x, find r and integer k such that + * + * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658 + * + * Here a correction term c will be computed to compensate + * the error in r when rounded to a floating-point number. + * + * 2. Approximating expm1(r) by a special rational function on + * the interval [0,0.34658]: + * Since + * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... + * we define R1(r*r) by + * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) + * That is, + * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r) + * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) + * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ... + * We use a special Remez algorithm on [0,0.347] to generate + * a polynomial of degree 5 in r*r to approximate R1. The + * maximum error of this polynomial approximation is bounded + * by 2**-61. In other words, + * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5 + * where Q1 = -1.6666666666666567384E-2, + * Q2 = 3.9682539681370365873E-4, + * Q3 = -9.9206344733435987357E-6, + * Q4 = 2.5051361420808517002E-7, + * Q5 = -6.2843505682382617102E-9; + * z = r*r, + * with error bounded by + * | 5 | -61 + * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 + * | | + * + * expm1(r) = exp(r)-1 is then computed by the following + * specific way which minimize the accumulation rounding error: + * 2 3 + * r r [ 3 - (R1 + R1*r/2) ] + * expm1(r) = r + --- + --- * [--------------------] + * 2 2 [ 6 - r*(3 - R1*r/2) ] + * + * To compensate the error in the argument reduction, we use + * expm1(r+c) = expm1(r) + c + expm1(r)*c + * ~ expm1(r) + c + r*c + * Thus c+r*c will be added in as the correction terms for + * expm1(r+c). Now rearrange the term to avoid optimization + * screw up: + * ( 2 2 ) + * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r ) + * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) + * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) + * ( ) + * + * = r - E + * 3. Scale back to obtain expm1(x): + * From step 1, we have + * expm1(x) = either 2^k*[expm1(r)+1] - 1 + * = or 2^k*[expm1(r) + (1-2^-k)] + * 4. Implementation notes: + * (A). To save one multiplication, we scale the coefficient Qi + * to Qi*2^i, and replace z by (x^2)/2. + * (B). To achieve maximum accuracy, we compute expm1(x) by + * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf) + * (ii) if k=0, return r-E + * (iii) if k=-1, return 0.5*(r-E)-0.5 + * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) + * else return 1.0+2.0*(r-E); + * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) + * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else + * (vii) return 2^k(1-((E+2^-k)-r)) + * + * Special cases: + * expm1(INF) is INF, expm1(NaN) is NaN; + * expm1(-INF) is -1, and + * for finite argument, only expm1(0)=0 is exact. + * + * Accuracy: + * according to an error analysis, the error is always less than + * 1 ulp (unit in the last place). + * + * Misc. info. + * For IEEE double + * if x > 7.09782712893383973096e+02 then expm1(x) overflow + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "libm.h" + +static const double +o_threshold = 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ +ln2_hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ +ln2_lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ +invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ +/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */ +Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */ +Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */ +Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */ +Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */ +Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */ + +double expm1(double x) +{ + double_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk; + union {double f; uint64_t i;} u = {x}; + uint32_t hx = u.i>>32 & 0x7fffffff; + int k, sign = u.i>>63; + + /* filter out huge and non-finite argument */ + if (hx >= 0x4043687A) { /* if |x|>=56*ln2 */ + if (isnan(x)) + return x; + if (sign) + return -1; + if (x > o_threshold) { + x *= 0x1p1023; + return x; + } + } + + /* argument reduction */ + if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ + if (!sign) { + hi = x - ln2_hi; + lo = ln2_lo; + k = 1; + } else { + hi = x + ln2_hi; + lo = -ln2_lo; + k = -1; + } + } else { + k = invln2*x + (sign ? -0.5 : 0.5); + t = k; + hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ + lo = t*ln2_lo; + } + x = hi-lo; + c = (hi-x)-lo; + } else if (hx < 0x3c900000) { /* |x| < 2**-54, return x */ + if (hx < 0x00100000) + FORCE_EVAL((float)x); + return x; + } else + k = 0; + + /* x is now in primary range */ + hfx = 0.5*x; + hxs = x*hfx; + r1 = 1.0+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); + t = 3.0-r1*hfx; + e = hxs*((r1-t)/(6.0 - x*t)); + if (k == 0) /* c is 0 */ + return x - (x*e-hxs); + e = x*(e-c) - c; + e -= hxs; + /* exp(x) ~ 2^k (x_reduced - e + 1) */ + if (k == -1) + return 0.5*(x-e) - 0.5; + if (k == 1) { + if (x < -0.25) + return -2.0*(e-(x+0.5)); + return 1.0+2.0*(x-e); + } + u.i = (uint64_t)(0x3ff + k)<<52; /* 2^k */ + twopk = u.f; + if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */ + y = x - e + 1.0; + if (k == 1024) + y = y*2.0*0x1p1023; + else + y = y*twopk; + return y - 1.0; + } + u.i = (uint64_t)(0x3ff - k)<<52; /* 2^-k */ + if (k < 20) + y = (x-e+(1-u.f))*twopk; + else + y = (x-(e+u.f)+1)*twopk; + return y; +} diff --git a/user/mpy/lib/libm_dbl/floor.c b/user/mpy/lib/libm_dbl/floor.c new file mode 100644 index 0000000..14a31cd --- /dev/null +++ b/user/mpy/lib/libm_dbl/floor.c @@ -0,0 +1,31 @@ +#include "libm.h" + +#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 +#define EPS DBL_EPSILON +#elif FLT_EVAL_METHOD==2 +#define EPS LDBL_EPSILON +#endif +static const double_t toint = 1/EPS; + +double floor(double x) +{ + union {double f; uint64_t i;} u = {x}; + int e = u.i >> 52 & 0x7ff; + double_t y; + + if (e >= 0x3ff+52 || x == 0) + return x; + /* y = int(x) - x, where int(x) is an integer neighbor of x */ + if (u.i >> 63) + y = x - toint + toint - x; + else + y = x + toint - toint - x; + /* special case because of non-nearest rounding modes */ + if (e <= 0x3ff-1) { + FORCE_EVAL(y); + return u.i >> 63 ? -1 : 0; + } + if (y > 0) + return x + y - 1; + return x + y; +} diff --git a/user/mpy/lib/libm_dbl/fmod.c b/user/mpy/lib/libm_dbl/fmod.c new file mode 100644 index 0000000..6849722 --- /dev/null +++ b/user/mpy/lib/libm_dbl/fmod.c @@ -0,0 +1,68 @@ +#include +#include + +double fmod(double x, double y) +{ + union {double f; uint64_t i;} ux = {x}, uy = {y}; + int ex = ux.i>>52 & 0x7ff; + int ey = uy.i>>52 & 0x7ff; + int sx = ux.i>>63; + uint64_t i; + + /* in the followings uxi should be ux.i, but then gcc wrongly adds */ + /* float load/store to inner loops ruining performance and code size */ + uint64_t uxi = ux.i; + + if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff) + return (x*y)/(x*y); + if (uxi<<1 <= uy.i<<1) { + if (uxi<<1 == uy.i<<1) + return 0*x; + return x; + } + + /* normalize x and y */ + if (!ex) { + for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1); + uxi <<= -ex + 1; + } else { + uxi &= -1ULL >> 12; + uxi |= 1ULL << 52; + } + if (!ey) { + for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1); + uy.i <<= -ey + 1; + } else { + uy.i &= -1ULL >> 12; + uy.i |= 1ULL << 52; + } + + /* x mod y */ + for (; ex > ey; ex--) { + i = uxi - uy.i; + if (i >> 63 == 0) { + if (i == 0) + return 0*x; + uxi = i; + } + uxi <<= 1; + } + i = uxi - uy.i; + if (i >> 63 == 0) { + if (i == 0) + return 0*x; + uxi = i; + } + for (; uxi>>52 == 0; uxi <<= 1, ex--); + + /* scale result */ + if (ex > 0) { + uxi -= 1ULL << 52; + uxi |= (uint64_t)ex << 52; + } else { + uxi >>= -ex + 1; + } + uxi |= (uint64_t)sx << 63; + ux.i = uxi; + return ux.f; +} diff --git a/user/mpy/lib/libm_dbl/frexp.c b/user/mpy/lib/libm_dbl/frexp.c new file mode 100644 index 0000000..27b6266 --- /dev/null +++ b/user/mpy/lib/libm_dbl/frexp.c @@ -0,0 +1,23 @@ +#include +#include + +double frexp(double x, int *e) +{ + union { double d; uint64_t i; } y = { x }; + int ee = y.i>>52 & 0x7ff; + + if (!ee) { + if (x) { + x = frexp(x*0x1p64, e); + *e -= 64; + } else *e = 0; + return x; + } else if (ee == 0x7ff) { + return x; + } + + *e = ee - 0x3fe; + y.i &= 0x800fffffffffffffull; + y.i |= 0x3fe0000000000000ull; + return y.d; +} diff --git a/user/mpy/lib/libm_dbl/ldexp.c b/user/mpy/lib/libm_dbl/ldexp.c new file mode 100644 index 0000000..f4d1cd6 --- /dev/null +++ b/user/mpy/lib/libm_dbl/ldexp.c @@ -0,0 +1,6 @@ +#include + +double ldexp(double x, int n) +{ + return scalbn(x, n); +} diff --git a/user/mpy/lib/libm_dbl/lgamma.c b/user/mpy/lib/libm_dbl/lgamma.c new file mode 100644 index 0000000..ed193da --- /dev/null +++ b/user/mpy/lib/libm_dbl/lgamma.c @@ -0,0 +1,8 @@ +#include + +double __lgamma_r(double, int*); + +double lgamma(double x) { + int sign; + return __lgamma_r(x, &sign); +} diff --git a/user/mpy/lib/libm_dbl/libm.h b/user/mpy/lib/libm_dbl/libm.h new file mode 100644 index 0000000..dc0b431 --- /dev/null +++ b/user/mpy/lib/libm_dbl/libm.h @@ -0,0 +1,96 @@ +// Portions of this file are extracted from musl-1.1.16 src/internal/libm.h + +/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include +#include + +#define FLT_EVAL_METHOD 0 + +#define FORCE_EVAL(x) do { \ + if (sizeof(x) == sizeof(float)) { \ + volatile float __x; \ + __x = (x); \ + (void)__x; \ + } else if (sizeof(x) == sizeof(double)) { \ + volatile double __x; \ + __x = (x); \ + (void)__x; \ + } else { \ + volatile long double __x; \ + __x = (x); \ + (void)__x; \ + } \ +} while(0) + +/* Get two 32 bit ints from a double. */ +#define EXTRACT_WORDS(hi,lo,d) \ +do { \ + union {double f; uint64_t i;} __u; \ + __u.f = (d); \ + (hi) = __u.i >> 32; \ + (lo) = (uint32_t)__u.i; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ +#define GET_HIGH_WORD(hi,d) \ +do { \ + union {double f; uint64_t i;} __u; \ + __u.f = (d); \ + (hi) = __u.i >> 32; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ +#define GET_LOW_WORD(lo,d) \ +do { \ + union {double f; uint64_t i;} __u; \ + __u.f = (d); \ + (lo) = (uint32_t)__u.i; \ +} while (0) + +/* Set a double from two 32 bit ints. */ +#define INSERT_WORDS(d,hi,lo) \ +do { \ + union {double f; uint64_t i;} __u; \ + __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \ + (d) = __u.f; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ +#define SET_HIGH_WORD(d,hi) \ +do { \ + union {double f; uint64_t i;} __u; \ + __u.f = (d); \ + __u.i &= 0xffffffff; \ + __u.i |= (uint64_t)(hi) << 32; \ + (d) = __u.f; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ +#define SET_LOW_WORD(d,lo) \ +do { \ + union {double f; uint64_t i;} __u; \ + __u.f = (d); \ + __u.i &= 0xffffffff00000000ull; \ + __u.i |= (uint32_t)(lo); \ + (d) = __u.f; \ +} while (0) + +#define DBL_EPSILON 2.22044604925031308085e-16 + +int __rem_pio2(double, double*); +int __rem_pio2_large(double*, double*, int, int, int); +double __sin(double, double, int); +double __cos(double, double); +double __tan(double, double, int); +double __expo2(double); diff --git a/user/mpy/lib/libm_dbl/log.c b/user/mpy/lib/libm_dbl/log.c new file mode 100644 index 0000000..e61e113 --- /dev/null +++ b/user/mpy/lib/libm_dbl/log.c @@ -0,0 +1,118 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_log.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* log(x) + * Return the logarithm of x + * + * Method : + * 1. Argument Reduction: find k and f such that + * x = 2^k * (1+f), + * where sqrt(2)/2 < 1+f < sqrt(2) . + * + * 2. Approximation of log(1+f). + * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) + * = 2s + 2/3 s**3 + 2/5 s**5 + ....., + * = 2s + s*R + * We use a special Remez algorithm on [0,0.1716] to generate + * a polynomial of degree 14 to approximate R The maximum error + * of this polynomial approximation is bounded by 2**-58.45. In + * other words, + * 2 4 6 8 10 12 14 + * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s + * (the values of Lg1 to Lg7 are listed in the program) + * and + * | 2 14 | -58.45 + * | Lg1*s +...+Lg7*s - R(z) | <= 2 + * | | + * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. + * In order to guarantee error in log below 1ulp, we compute log + * by + * log(1+f) = f - s*(f - R) (if f is not too large) + * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) + * + * 3. Finally, log(x) = k*ln2 + log(1+f). + * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) + * Here ln2 is split into two floating point number: + * ln2_hi + ln2_lo, + * where n*ln2_hi is always exact for |n| < 2000. + * + * Special cases: + * log(x) is NaN with signal if x < 0 (including -INF) ; + * log(+INF) is +INF; log(0) is -INF with signal; + * log(NaN) is that NaN with no signal. + * + * Accuracy: + * according to an error analysis, the error is always less than + * 1 ulp (unit in the last place). + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include +#include + +static const double +ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ +ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ +Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ +Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ +Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ +Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ +Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ +Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ +Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ + +double log(double x) +{ + union {double f; uint64_t i;} u = {x}; + double_t hfsq,f,s,z,R,w,t1,t2,dk; + uint32_t hx; + int k; + + hx = u.i>>32; + k = 0; + if (hx < 0x00100000 || hx>>31) { + if (u.i<<1 == 0) + return -1/(x*x); /* log(+-0)=-inf */ + if (hx>>31) + return (x-x)/0.0; /* log(-#) = NaN */ + /* subnormal number, scale x up */ + k -= 54; + x *= 0x1p54; + u.f = x; + hx = u.i>>32; + } else if (hx >= 0x7ff00000) { + return x; + } else if (hx == 0x3ff00000 && u.i<<32 == 0) + return 0; + + /* reduce x into [sqrt(2)/2, sqrt(2)] */ + hx += 0x3ff00000 - 0x3fe6a09e; + k += (int)(hx>>20) - 0x3ff; + hx = (hx&0x000fffff) + 0x3fe6a09e; + u.i = (uint64_t)hx<<32 | (u.i&0xffffffff); + x = u.f; + + f = x - 1.0; + hfsq = 0.5*f*f; + s = f/(2.0+f); + z = s*s; + w = z*z; + t1 = w*(Lg2+w*(Lg4+w*Lg6)); + t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + R = t2 + t1; + dk = k; + return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi; +} diff --git a/user/mpy/lib/libm_dbl/log10.c b/user/mpy/lib/libm_dbl/log10.c new file mode 100644 index 0000000..bddedd6 --- /dev/null +++ b/user/mpy/lib/libm_dbl/log10.c @@ -0,0 +1,7 @@ +#include + +static const double _M_LN10 = 2.302585092994046; + +double log10(double x) { + return log(x) / (double)_M_LN10; +} diff --git a/user/mpy/lib/libm_dbl/log1p.c b/user/mpy/lib/libm_dbl/log1p.c new file mode 100644 index 0000000..0097134 --- /dev/null +++ b/user/mpy/lib/libm_dbl/log1p.c @@ -0,0 +1,122 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_log1p.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* double log1p(double x) + * Return the natural logarithm of 1+x. + * + * Method : + * 1. Argument Reduction: find k and f such that + * 1+x = 2^k * (1+f), + * where sqrt(2)/2 < 1+f < sqrt(2) . + * + * Note. If k=0, then f=x is exact. However, if k!=0, then f + * may not be representable exactly. In that case, a correction + * term is need. Let u=1+x rounded. Let c = (1+x)-u, then + * log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u), + * and add back the correction term c/u. + * (Note: when x > 2**53, one can simply return log(x)) + * + * 2. Approximation of log(1+f): See log.c + * + * 3. Finally, log1p(x) = k*ln2 + log(1+f) + c/u. See log.c + * + * Special cases: + * log1p(x) is NaN with signal if x < -1 (including -INF) ; + * log1p(+INF) is +INF; log1p(-1) is -INF with signal; + * log1p(NaN) is that NaN with no signal. + * + * Accuracy: + * according to an error analysis, the error is always less than + * 1 ulp (unit in the last place). + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + * + * Note: Assuming log() return accurate answer, the following + * algorithm can be used to compute log1p(x) to within a few ULP: + * + * u = 1+x; + * if(u==1.0) return x ; else + * return log(u)*(x/(u-1.0)); + * + * See HP-15C Advanced Functions Handbook, p.193. + */ + +#include "libm.h" + +static const double +ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ +ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ +Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ +Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ +Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ +Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ +Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ +Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ +Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ + +double log1p(double x) +{ + union {double f; uint64_t i;} u = {x}; + double_t hfsq,f,c,s,z,R,w,t1,t2,dk; + uint32_t hx,hu; + int k; + + hx = u.i>>32; + k = 1; + if (hx < 0x3fda827a || hx>>31) { /* 1+x < sqrt(2)+ */ + if (hx >= 0xbff00000) { /* x <= -1.0 */ + if (x == -1) + return x/0.0; /* log1p(-1) = -inf */ + return (x-x)/0.0; /* log1p(x<-1) = NaN */ + } + if (hx<<1 < 0x3ca00000<<1) { /* |x| < 2**-53 */ + /* underflow if subnormal */ + if ((hx&0x7ff00000) == 0) + FORCE_EVAL((float)x); + return x; + } + if (hx <= 0xbfd2bec4) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */ + k = 0; + c = 0; + f = x; + } + } else if (hx >= 0x7ff00000) + return x; + if (k) { + u.f = 1 + x; + hu = u.i>>32; + hu += 0x3ff00000 - 0x3fe6a09e; + k = (int)(hu>>20) - 0x3ff; + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if (k < 54) { + c = k >= 2 ? 1-(u.f-x) : x-(u.f-1); + c /= u.f; + } else + c = 0; + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + hu = (hu&0x000fffff) + 0x3fe6a09e; + u.i = (uint64_t)hu<<32 | (u.i&0xffffffff); + f = u.f - 1; + } + hfsq = 0.5*f*f; + s = f/(2.0+f); + z = s*s; + w = z*z; + t1 = w*(Lg2+w*(Lg4+w*Lg6)); + t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + R = t2 + t1; + dk = k; + return s*(hfsq+R) + (dk*ln2_lo+c) - hfsq + f + dk*ln2_hi; +} diff --git a/user/mpy/lib/libm_dbl/modf.c b/user/mpy/lib/libm_dbl/modf.c new file mode 100644 index 0000000..1c8a1db --- /dev/null +++ b/user/mpy/lib/libm_dbl/modf.c @@ -0,0 +1,34 @@ +#include "libm.h" + +double modf(double x, double *iptr) +{ + union {double f; uint64_t i;} u = {x}; + uint64_t mask; + int e = (int)(u.i>>52 & 0x7ff) - 0x3ff; + + /* no fractional part */ + if (e >= 52) { + *iptr = x; + if (e == 0x400 && u.i<<12 != 0) /* nan */ + return x; + u.i &= 1ULL<<63; + return u.f; + } + + /* no integral part*/ + if (e < 0) { + u.i &= 1ULL<<63; + *iptr = u.f; + return x; + } + + mask = -1ULL>>12>>e; + if ((u.i & mask) == 0) { + *iptr = x; + u.i &= 1ULL<<63; + return u.f; + } + u.i &= ~mask; + *iptr = u.f; + return x - u.f; +} diff --git a/user/mpy/lib/libm_dbl/nearbyint.c b/user/mpy/lib/libm_dbl/nearbyint.c new file mode 100644 index 0000000..6e9b0c1 --- /dev/null +++ b/user/mpy/lib/libm_dbl/nearbyint.c @@ -0,0 +1,20 @@ +//#include +#include + +/* nearbyint is the same as rint, but it must not raise the inexact exception */ + +double nearbyint(double x) +{ +#ifdef FE_INEXACT + #pragma STDC FENV_ACCESS ON + int e; + + e = fetestexcept(FE_INEXACT); +#endif + x = rint(x); +#ifdef FE_INEXACT + if (!e) + feclearexcept(FE_INEXACT); +#endif + return x; +} diff --git a/user/mpy/lib/libm_dbl/pow.c b/user/mpy/lib/libm_dbl/pow.c new file mode 100644 index 0000000..3ddc1b6 --- /dev/null +++ b/user/mpy/lib/libm_dbl/pow.c @@ -0,0 +1,328 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_pow.c */ +/* + * ==================================================== + * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* pow(x,y) return x**y + * + * n + * Method: Let x = 2 * (1+f) + * 1. Compute and return log2(x) in two pieces: + * log2(x) = w1 + w2, + * where w1 has 53-24 = 29 bit trailing zeros. + * 2. Perform y*log2(x) = n+y' by simulating muti-precision + * arithmetic, where |y'|<=0.5. + * 3. Return x**y = 2**n*exp(y'*log2) + * + * Special cases: + * 1. (anything) ** 0 is 1 + * 2. 1 ** (anything) is 1 + * 3. (anything except 1) ** NAN is NAN + * 4. NAN ** (anything except 0) is NAN + * 5. +-(|x| > 1) ** +INF is +INF + * 6. +-(|x| > 1) ** -INF is +0 + * 7. +-(|x| < 1) ** +INF is +0 + * 8. +-(|x| < 1) ** -INF is +INF + * 9. -1 ** +-INF is 1 + * 10. +0 ** (+anything except 0, NAN) is +0 + * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 + * 12. +0 ** (-anything except 0, NAN) is +INF, raise divbyzero + * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF, raise divbyzero + * 14. -0 ** (+odd integer) is -0 + * 15. -0 ** (-odd integer) is -INF, raise divbyzero + * 16. +INF ** (+anything except 0,NAN) is +INF + * 17. +INF ** (-anything except 0,NAN) is +0 + * 18. -INF ** (+odd integer) is -INF + * 19. -INF ** (anything) = -0 ** (-anything), (anything except odd integer) + * 20. (anything) ** 1 is (anything) + * 21. (anything) ** -1 is 1/(anything) + * 22. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) + * 23. (-anything except 0 and inf) ** (non-integer) is NAN + * + * Accuracy: + * pow(x,y) returns x**y nearly rounded. In particular + * pow(integer,integer) + * always returns the correct integer provided it is + * representable. + * + * Constants : + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "libm.h" + +static const double +bp[] = {1.0, 1.5,}, +dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ +dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ +two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ +huge = 1.0e300, +tiny = 1.0e-300, +/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ +L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ +L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ +L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ +L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ +L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ +L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ +P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ +P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ +P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ +P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ +P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ +lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ +lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ +lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ +ovt = 8.0085662595372944372e-017, /* -(1024-log2(ovfl+.5ulp)) */ +cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ +cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ +cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ +ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ +ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ +ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ + +double pow(double x, double y) +{ + double z,ax,z_h,z_l,p_h,p_l; + double y1,t1,t2,r,s,t,u,v,w; + int32_t i,j,k,yisint,n; + int32_t hx,hy,ix,iy; + uint32_t lx,ly; + + EXTRACT_WORDS(hx, lx, x); + EXTRACT_WORDS(hy, ly, y); + ix = hx & 0x7fffffff; + iy = hy & 0x7fffffff; + + /* x**0 = 1, even if x is NaN */ + if ((iy|ly) == 0) + return 1.0; + /* 1**y = 1, even if y is NaN */ + if (hx == 0x3ff00000 && lx == 0) + return 1.0; + /* NaN if either arg is NaN */ + if (ix > 0x7ff00000 || (ix == 0x7ff00000 && lx != 0) || + iy > 0x7ff00000 || (iy == 0x7ff00000 && ly != 0)) + return x + y; + + /* determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if (hx < 0) { + if (iy >= 0x43400000) + yisint = 2; /* even integer y */ + else if (iy >= 0x3ff00000) { + k = (iy>>20) - 0x3ff; /* exponent */ + if (k > 20) { + uint32_t j = ly>>(52-k); + if ((j<<(52-k)) == ly) + yisint = 2 - (j&1); + } else if (ly == 0) { + uint32_t j = iy>>(20-k); + if ((j<<(20-k)) == iy) + yisint = 2 - (j&1); + } + } + } + + /* special value of y */ + if (ly == 0) { + if (iy == 0x7ff00000) { /* y is +-inf */ + if (((ix-0x3ff00000)|lx) == 0) /* (-1)**+-inf is 1 */ + return 1.0; + else if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */ + return hy >= 0 ? y : 0.0; + else /* (|x|<1)**+-inf = 0,inf */ + return hy >= 0 ? 0.0 : -y; + } + if (iy == 0x3ff00000) { /* y is +-1 */ + if (hy >= 0) + return x; + y = 1/x; +#if FLT_EVAL_METHOD!=0 + { + union {double f; uint64_t i;} u = {y}; + uint64_t i = u.i & -1ULL/2; + if (i>>52 == 0 && (i&(i-1))) + FORCE_EVAL((float)y); + } +#endif + return y; + } + if (hy == 0x40000000) /* y is 2 */ + return x*x; + if (hy == 0x3fe00000) { /* y is 0.5 */ + if (hx >= 0) /* x >= +0 */ + return sqrt(x); + } + } + + ax = fabs(x); + /* special value of x */ + if (lx == 0) { + if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) { /* x is +-0,+-inf,+-1 */ + z = ax; + if (hy < 0) /* z = (1/|x|) */ + z = 1.0/z; + if (hx < 0) { + if (((ix-0x3ff00000)|yisint) == 0) { + z = (z-z)/(z-z); /* (-1)**non-int is NaN */ + } else if (yisint == 1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + } + + s = 1.0; /* sign of result */ + if (hx < 0) { + if (yisint == 0) /* (x<0)**(non-int) is NaN */ + return (x-x)/(x-x); + if (yisint == 1) /* (x<0)**(odd int) */ + s = -1.0; + } + + /* |y| is huge */ + if (iy > 0x41e00000) { /* if |y| > 2**31 */ + if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */ + if (ix <= 0x3fefffff) + return hy < 0 ? huge*huge : tiny*tiny; + if (ix >= 0x3ff00000) + return hy > 0 ? huge*huge : tiny*tiny; + } + /* over/underflow if x is not close to one */ + if (ix < 0x3fefffff) + return hy < 0 ? s*huge*huge : s*tiny*tiny; + if (ix > 0x3ff00000) + return hy > 0 ? s*huge*huge : s*tiny*tiny; + /* now |1-x| is tiny <= 2**-20, suffice to compute + log(x) by x-x^2/2+x^3/3-x^4/4 */ + t = ax - 1.0; /* t has 20 trailing zeros */ + w = (t*t)*(0.5 - t*(0.3333333333333333333333-t*0.25)); + u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ + v = t*ivln2_l - w*ivln2; + t1 = u + v; + SET_LOW_WORD(t1, 0); + t2 = v - (t1-u); + } else { + double ss,s2,s_h,s_l,t_h,t_l; + n = 0; + /* take care subnormal number */ + if (ix < 0x00100000) { + ax *= two53; + n -= 53; + GET_HIGH_WORD(ix,ax); + } + n += ((ix)>>20) - 0x3ff; + j = ix & 0x000fffff; + /* determine interval */ + ix = j | 0x3ff00000; /* normalize ix */ + if (j <= 0x3988E) /* |x|>1)|0x20000000) + 0x00080000 + (k<<18)); + t_l = ax - (t_h-bp[k]); + s_l = v*((u-s_h*t_h)-s_h*t_l); + /* compute log(ax) */ + s2 = ss*ss; + r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); + r += s_l*(s_h+ss); + s2 = s_h*s_h; + t_h = 3.0 + s2 + r; + SET_LOW_WORD(t_h, 0); + t_l = r - ((t_h-3.0)-s2); + /* u+v = ss*(1+...) */ + u = s_h*t_h; + v = s_l*t_h + t_l*ss; + /* 2/(3log2)*(ss+...) */ + p_h = u + v; + SET_LOW_WORD(p_h, 0); + p_l = v - (p_h-u); + z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l*p_h+p_l*cp + dp_l[k]; + /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (double)n; + t1 = ((z_h + z_l) + dp_h[k]) + t; + SET_LOW_WORD(t1, 0); + t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); + } + + /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ + y1 = y; + SET_LOW_WORD(y1, 0); + p_l = (y-y1)*t1 + y*t2; + p_h = y1*t1; + z = p_l + p_h; + EXTRACT_WORDS(j, i, z); + if (j >= 0x40900000) { /* z >= 1024 */ + if (((j-0x40900000)|i) != 0) /* if z > 1024 */ + return s*huge*huge; /* overflow */ + if (p_l + ovt > z - p_h) + return s*huge*huge; /* overflow */ + } else if ((j&0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */ // FIXME: instead of abs(j) use unsigned j + if (((j-0xc090cc00)|i) != 0) /* z < -1075 */ + return s*tiny*tiny; /* underflow */ + if (p_l <= z - p_h) + return s*tiny*tiny; /* underflow */ + } + /* + * compute 2**(p_h+p_l) + */ + i = j & 0x7fffffff; + k = (i>>20) - 0x3ff; + n = 0; + if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ + n = j + (0x00100000>>(k+1)); + k = ((n&0x7fffffff)>>20) - 0x3ff; /* new k for n */ + t = 0.0; + SET_HIGH_WORD(t, n & ~(0x000fffff>>k)); + n = ((n&0x000fffff)|0x00100000)>>(20-k); + if (j < 0) + n = -n; + p_h -= t; + } + t = p_l + p_h; + SET_LOW_WORD(t, 0); + u = t*lg2_h; + v = (p_l-(t-p_h))*lg2 + t*lg2_l; + z = u + v; + w = v - (z-u); + t = z*z; + t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + r = (z*t1)/(t1-2.0) - (w + z*w); + z = 1.0 - (r-z); + GET_HIGH_WORD(j, z); + j += n<<20; + if ((j>>20) <= 0) /* subnormal output */ + z = scalbn(z,n); + else + SET_HIGH_WORD(z, j); + return s*z; +} diff --git a/user/mpy/lib/libm_dbl/rint.c b/user/mpy/lib/libm_dbl/rint.c new file mode 100644 index 0000000..fbba390 --- /dev/null +++ b/user/mpy/lib/libm_dbl/rint.c @@ -0,0 +1,28 @@ +#include +#include +#include + +#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 +#define EPS DBL_EPSILON +#elif FLT_EVAL_METHOD==2 +#define EPS LDBL_EPSILON +#endif +static const double_t toint = 1/EPS; + +double rint(double x) +{ + union {double f; uint64_t i;} u = {x}; + int e = u.i>>52 & 0x7ff; + int s = u.i>>63; + double_t y; + + if (e >= 0x3ff+52) + return x; + if (s) + y = x - toint + toint; + else + y = x + toint - toint; + if (y == 0) + return s ? -0.0 : 0; + return y; +} diff --git a/user/mpy/lib/libm_dbl/scalbn.c b/user/mpy/lib/libm_dbl/scalbn.c new file mode 100644 index 0000000..182f561 --- /dev/null +++ b/user/mpy/lib/libm_dbl/scalbn.c @@ -0,0 +1,33 @@ +#include +#include + +double scalbn(double x, int n) +{ + union {double f; uint64_t i;} u; + double_t y = x; + + if (n > 1023) { + y *= 0x1p1023; + n -= 1023; + if (n > 1023) { + y *= 0x1p1023; + n -= 1023; + if (n > 1023) + n = 1023; + } + } else if (n < -1022) { + /* make sure final n < -53 to avoid double + rounding in the subnormal range */ + y *= 0x1p-1022 * 0x1p53; + n += 1022 - 53; + if (n < -1022) { + y *= 0x1p-1022 * 0x1p53; + n += 1022 - 53; + if (n < -1022) + n = -1022; + } + } + u.i = (uint64_t)(0x3ff+n)<<52; + x = y * u.f; + return x; +} diff --git a/user/mpy/lib/libm_dbl/sin.c b/user/mpy/lib/libm_dbl/sin.c new file mode 100644 index 0000000..055e215 --- /dev/null +++ b/user/mpy/lib/libm_dbl/sin.c @@ -0,0 +1,78 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* sin(x) + * Return sine function of x. + * + * kernel function: + * __sin ... sine function on [-pi/4,pi/4] + * __cos ... cose function on [-pi/4,pi/4] + * __rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "libm.h" + +double sin(double x) +{ + double y[2]; + uint32_t ix; + unsigned n; + + /* High word of x. */ + GET_HIGH_WORD(ix, x); + ix &= 0x7fffffff; + + /* |x| ~< pi/4 */ + if (ix <= 0x3fe921fb) { + if (ix < 0x3e500000) { /* |x| < 2**-26 */ + /* raise inexact if x != 0 and underflow if subnormal*/ + FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); + return x; + } + return __sin(x, 0.0, 0); + } + + /* sin(Inf or NaN) is NaN */ + if (ix >= 0x7ff00000) + return x - x; + + /* argument reduction needed */ + n = __rem_pio2(x, y); + switch (n&3) { + case 0: return __sin(y[0], y[1], 1); + case 1: return __cos(y[0], y[1]); + case 2: return -__sin(y[0], y[1], 1); + default: + return -__cos(y[0], y[1]); + } +} diff --git a/user/mpy/lib/libm_dbl/sinh.c b/user/mpy/lib/libm_dbl/sinh.c new file mode 100644 index 0000000..00022c4 --- /dev/null +++ b/user/mpy/lib/libm_dbl/sinh.c @@ -0,0 +1,39 @@ +#include "libm.h" + +/* sinh(x) = (exp(x) - 1/exp(x))/2 + * = (exp(x)-1 + (exp(x)-1)/exp(x))/2 + * = x + x^3/6 + o(x^5) + */ +double sinh(double x) +{ + union {double f; uint64_t i;} u = {.f = x}; + uint32_t w; + double t, h, absx; + + h = 0.5; + if (u.i >> 63) + h = -h; + /* |x| */ + u.i &= (uint64_t)-1/2; + absx = u.f; + w = u.i >> 32; + + /* |x| < log(DBL_MAX) */ + if (w < 0x40862e42) { + t = expm1(absx); + if (w < 0x3ff00000) { + if (w < 0x3ff00000 - (26<<20)) + /* note: inexact and underflow are raised by expm1 */ + /* note: this branch avoids spurious underflow */ + return x; + return h*(2*t - t*t/(t+1)); + } + /* note: |x|>log(0x1p26)+eps could be just h*exp(x) */ + return h*(t + t/(t+1)); + } + + /* |x| > log(DBL_MAX) or nan */ + /* note: the result is stored to handle overflow */ + t = 2*h*__expo2(absx); + return t; +} diff --git a/user/mpy/lib/libm_dbl/sqrt.c b/user/mpy/lib/libm_dbl/sqrt.c new file mode 100644 index 0000000..b277567 --- /dev/null +++ b/user/mpy/lib/libm_dbl/sqrt.c @@ -0,0 +1,185 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrt.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* sqrt(x) + * Return correctly rounded sqrt. + * ------------------------------------------ + * | Use the hardware sqrt if you have one | + * ------------------------------------------ + * Method: + * Bit by bit method using integer arithmetic. (Slow, but portable) + * 1. Normalization + * Scale x to y in [1,4) with even powers of 2: + * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then + * sqrt(x) = 2^k * sqrt(y) + * 2. Bit by bit computation + * Let q = sqrt(y) truncated to i bit after binary point (q = 1), + * i 0 + * i+1 2 + * s = 2*q , and y = 2 * ( y - q ). (1) + * i i i i + * + * To compute q from q , one checks whether + * i+1 i + * + * -(i+1) 2 + * (q + 2 ) <= y. (2) + * i + * -(i+1) + * If (2) is false, then q = q ; otherwise q = q + 2 . + * i+1 i i+1 i + * + * With some algebric manipulation, it is not difficult to see + * that (2) is equivalent to + * -(i+1) + * s + 2 <= y (3) + * i i + * + * The advantage of (3) is that s and y can be computed by + * i i + * the following recurrence formula: + * if (3) is false + * + * s = s , y = y ; (4) + * i+1 i i+1 i + * + * otherwise, + * -i -(i+1) + * s = s + 2 , y = y - s - 2 (5) + * i+1 i i+1 i i + * + * One may easily use induction to prove (4) and (5). + * Note. Since the left hand side of (3) contain only i+2 bits, + * it does not necessary to do a full (53-bit) comparison + * in (3). + * 3. Final rounding + * After generating the 53 bits result, we compute one more bit. + * Together with the remainder, we can decide whether the + * result is exact, bigger than 1/2ulp, or less than 1/2ulp + * (it will never equal to 1/2ulp). + * The rounding mode can be detected by checking whether + * huge + tiny is equal to huge, and whether huge - tiny is + * equal to huge for some floating point number "huge" and "tiny". + * + * Special cases: + * sqrt(+-0) = +-0 ... exact + * sqrt(inf) = inf + * sqrt(-ve) = NaN ... with invalid signal + * sqrt(NaN) = NaN ... with invalid signal for signaling NaN + */ + +#include "libm.h" + +static const double tiny = 1.0e-300; + +double sqrt(double x) +{ + double z; + int32_t sign = (int)0x80000000; + int32_t ix0,s0,q,m,t,i; + uint32_t r,t1,s1,ix1,q1; + + EXTRACT_WORDS(ix0, ix1, x); + + /* take care of Inf and NaN */ + if ((ix0&0x7ff00000) == 0x7ff00000) { + return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */ + } + /* take care of zero */ + if (ix0 <= 0) { + if (((ix0&~sign)|ix1) == 0) + return x; /* sqrt(+-0) = +-0 */ + if (ix0 < 0) + return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ + } + /* normalize x */ + m = ix0>>20; + if (m == 0) { /* subnormal x */ + while (ix0 == 0) { + m -= 21; + ix0 |= (ix1>>11); + ix1 <<= 21; + } + for (i=0; (ix0&0x00100000) == 0; i++) + ix0<<=1; + m -= i - 1; + ix0 |= ix1>>(32-i); + ix1 <<= i; + } + m -= 1023; /* unbias exponent */ + ix0 = (ix0&0x000fffff)|0x00100000; + if (m & 1) { /* odd m, double x to make it even */ + ix0 += ix0 + ((ix1&sign)>>31); + ix1 += ix1; + } + m >>= 1; /* m = [m/2] */ + + /* generate sqrt(x) bit by bit */ + ix0 += ix0 + ((ix1&sign)>>31); + ix1 += ix1; + q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ + r = 0x00200000; /* r = moving bit from right to left */ + + while (r != 0) { + t = s0 + r; + if (t <= ix0) { + s0 = t + r; + ix0 -= t; + q += r; + } + ix0 += ix0 + ((ix1&sign)>>31); + ix1 += ix1; + r >>= 1; + } + + r = sign; + while (r != 0) { + t1 = s1 + r; + t = s0; + if (t < ix0 || (t == ix0 && t1 <= ix1)) { + s1 = t1 + r; + if ((t1&sign) == sign && (s1&sign) == 0) + s0++; + ix0 -= t; + if (ix1 < t1) + ix0--; + ix1 -= t1; + q1 += r; + } + ix0 += ix0 + ((ix1&sign)>>31); + ix1 += ix1; + r >>= 1; + } + + /* use floating add to find out rounding direction */ + if ((ix0|ix1) != 0) { + z = 1.0 - tiny; /* raise inexact flag */ + if (z >= 1.0) { + z = 1.0 + tiny; + if (q1 == (uint32_t)0xffffffff) { + q1 = 0; + q++; + } else if (z > 1.0) { + if (q1 == (uint32_t)0xfffffffe) + q++; + q1 += 2; + } else + q1 += q1 & 1; + } + } + ix0 = (q>>1) + 0x3fe00000; + ix1 = q1>>1; + if (q&1) + ix1 |= sign; + ix0 += m << 20; + INSERT_WORDS(z, ix0, ix1); + return z; +} diff --git a/user/mpy/lib/libm_dbl/tan.c b/user/mpy/lib/libm_dbl/tan.c new file mode 100644 index 0000000..9c724a4 --- /dev/null +++ b/user/mpy/lib/libm_dbl/tan.c @@ -0,0 +1,70 @@ +/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ +/* tan(x) + * Return tangent function of x. + * + * kernel function: + * __tan ... tangent function on [-pi/4,pi/4] + * __rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "libm.h" + +double tan(double x) +{ + double y[2]; + uint32_t ix; + unsigned n; + + GET_HIGH_WORD(ix, x); + ix &= 0x7fffffff; + + /* |x| ~< pi/4 */ + if (ix <= 0x3fe921fb) { + if (ix < 0x3e400000) { /* |x| < 2**-27 */ + /* raise inexact if x!=0 and underflow if subnormal */ + FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); + return x; + } + return __tan(x, 0.0, 0); + } + + /* tan(Inf or NaN) is NaN */ + if (ix >= 0x7ff00000) + return x - x; + + /* argument reduction */ + n = __rem_pio2(x, y); + return __tan(y[0], y[1], n&1); +} diff --git a/user/mpy/lib/libm_dbl/tanh.c b/user/mpy/lib/libm_dbl/tanh.c new file mode 100644 index 0000000..89743ba --- /dev/null +++ b/user/mpy/lib/libm_dbl/tanh.c @@ -0,0 +1,5 @@ +#include + +double tanh(double x) { + return sinh(x) / cosh(x); +} diff --git a/user/mpy/lib/libm_dbl/tgamma.c b/user/mpy/lib/libm_dbl/tgamma.c new file mode 100644 index 0000000..d1d0a04 --- /dev/null +++ b/user/mpy/lib/libm_dbl/tgamma.c @@ -0,0 +1,222 @@ +/* +"A Precision Approximation of the Gamma Function" - Cornelius Lanczos (1964) +"Lanczos Implementation of the Gamma Function" - Paul Godfrey (2001) +"An Analysis of the Lanczos Gamma Approximation" - Glendon Ralph Pugh (2004) + +approximation method: + + (x - 0.5) S(x) +Gamma(x) = (x + g - 0.5) * ---------------- + exp(x + g - 0.5) + +with + a1 a2 a3 aN +S(x) ~= [ a0 + ----- + ----- + ----- + ... + ----- ] + x + 1 x + 2 x + 3 x + N + +with a0, a1, a2, a3,.. aN constants which depend on g. + +for x < 0 the following reflection formula is used: + +Gamma(x)*Gamma(-x) = -pi/(x sin(pi x)) + +most ideas and constants are from boost and python +*/ +#include "libm.h" + +static const double pi = 3.141592653589793238462643383279502884; + +/* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */ +static double sinpi(double x) +{ + int n; + + /* argument reduction: x = |x| mod 2 */ + /* spurious inexact when x is odd int */ + x = x * 0.5; + x = 2 * (x - floor(x)); + + /* reduce x into [-.25,.25] */ + n = 4 * x; + n = (n+1)/2; + x -= n * 0.5; + + x *= pi; + switch (n) { + default: /* case 4 */ + case 0: + return __sin(x, 0, 0); + case 1: + return __cos(x, 0); + case 2: + return __sin(-x, 0, 0); + case 3: + return -__cos(x, 0); + } +} + +#define N 12 +//static const double g = 6.024680040776729583740234375; +static const double gmhalf = 5.524680040776729583740234375; +static const double Snum[N+1] = { + 23531376880.410759688572007674451636754734846804940, + 42919803642.649098768957899047001988850926355848959, + 35711959237.355668049440185451547166705960488635843, + 17921034426.037209699919755754458931112671403265390, + 6039542586.3520280050642916443072979210699388420708, + 1439720407.3117216736632230727949123939715485786772, + 248874557.86205415651146038641322942321632125127801, + 31426415.585400194380614231628318205362874684987640, + 2876370.6289353724412254090516208496135991145378768, + 186056.26539522349504029498971604569928220784236328, + 8071.6720023658162106380029022722506138218516325024, + 210.82427775157934587250973392071336271166969580291, + 2.5066282746310002701649081771338373386264310793408, +}; +static const double Sden[N+1] = { + 0, 39916800, 120543840, 150917976, 105258076, 45995730, 13339535, + 2637558, 357423, 32670, 1925, 66, 1, +}; +/* n! for small integer n */ +static const double fact[] = { + 1, 1, 2, 6, 24, 120, 720, 5040.0, 40320.0, 362880.0, 3628800.0, 39916800.0, + 479001600.0, 6227020800.0, 87178291200.0, 1307674368000.0, 20922789888000.0, + 355687428096000.0, 6402373705728000.0, 121645100408832000.0, + 2432902008176640000.0, 51090942171709440000.0, 1124000727777607680000.0, +}; + +/* S(x) rational function for positive x */ +static double S(double x) +{ + double_t num = 0, den = 0; + int i; + + /* to avoid overflow handle large x differently */ + if (x < 8) + for (i = N; i >= 0; i--) { + num = num * x + Snum[i]; + den = den * x + Sden[i]; + } + else + for (i = 0; i <= N; i++) { + num = num / x + Snum[i]; + den = den / x + Sden[i]; + } + return num/den; +} + +double tgamma(double x) +{ + union {double f; uint64_t i;} u = {x}; + double absx, y; + double_t dy, z, r; + uint32_t ix = u.i>>32 & 0x7fffffff; + int sign = u.i>>63; + + /* special cases */ + if (ix >= 0x7ff00000) + /* tgamma(nan)=nan, tgamma(inf)=inf, tgamma(-inf)=nan with invalid */ + return x + INFINITY; + if (ix < (0x3ff-54)<<20) + /* |x| < 2^-54: tgamma(x) ~ 1/x, +-0 raises div-by-zero */ + return 1/x; + + /* integer arguments */ + /* raise inexact when non-integer */ + if (x == floor(x)) { + if (sign) + return 0/0.0; + if (x <= sizeof fact/sizeof *fact) + return fact[(int)x - 1]; + } + + /* x >= 172: tgamma(x)=inf with overflow */ + /* x =< -184: tgamma(x)=+-0 with underflow */ + if (ix >= 0x40670000) { /* |x| >= 184 */ + if (sign) { + FORCE_EVAL((float)(0x1p-126/x)); + if (floor(x) * 0.5 == floor(x * 0.5)) + return 0; + return -0.0; + } + x *= 0x1p1023; + return x; + } + + absx = sign ? -x : x; + + /* handle the error of x + g - 0.5 */ + y = absx + gmhalf; + if (absx > gmhalf) { + dy = y - absx; + dy -= gmhalf; + } else { + dy = y - gmhalf; + dy -= absx; + } + + z = absx - 0.5; + r = S(absx) * exp(-y); + if (x < 0) { + /* reflection formula for negative x */ + /* sinpi(absx) is not 0, integers are already handled */ + r = -pi / (sinpi(absx) * absx * r); + dy = -dy; + z = -z; + } + r += dy * (gmhalf+0.5) * r / y; + z = pow(y, 0.5*z); + y = r * z * z; + return y; +} + +#if 1 +double __lgamma_r(double x, int *sign) +{ + double r, absx; + + *sign = 1; + + /* special cases */ + if (!isfinite(x)) + /* lgamma(nan)=nan, lgamma(+-inf)=inf */ + return x*x; + + /* integer arguments */ + if (x == floor(x) && x <= 2) { + /* n <= 0: lgamma(n)=inf with divbyzero */ + /* n == 1,2: lgamma(n)=0 */ + if (x <= 0) + return 1/0.0; + return 0; + } + + absx = fabs(x); + + /* lgamma(x) ~ -log(|x|) for tiny |x| */ + if (absx < 0x1p-54) { + *sign = 1 - 2*!!signbit(x); + return -log(absx); + } + + /* use tgamma for smaller |x| */ + if (absx < 128) { + x = tgamma(x); + *sign = 1 - 2*!!signbit(x); + return log(fabs(x)); + } + + /* second term (log(S)-g) could be more precise here.. */ + /* or with stirling: (|x|-0.5)*(log(|x|)-1) + poly(1/|x|) */ + r = (absx-0.5)*(log(absx+gmhalf)-1) + (log(S(absx)) - (gmhalf+0.5)); + if (x < 0) { + /* reflection formula for negative x */ + x = sinpi(absx); + *sign = 2*!!signbit(x) - 1; + r = log(pi/(fabs(x)*absx)) - r; + } + return r; +} + +//weak_alias(__lgamma_r, lgamma_r); +#endif diff --git a/user/mpy/lib/libm_dbl/trunc.c b/user/mpy/lib/libm_dbl/trunc.c new file mode 100644 index 0000000..d13711b --- /dev/null +++ b/user/mpy/lib/libm_dbl/trunc.c @@ -0,0 +1,19 @@ +#include "libm.h" + +double trunc(double x) +{ + union {double f; uint64_t i;} u = {x}; + int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12; + uint64_t m; + + if (e >= 52 + 12) + return x; + if (e < 12) + e = 1; + m = -1ULL >> e; + if ((u.i & m) == 0) + return x; + FORCE_EVAL(x + 0x1p120f); + u.i &= ~m; + return u.f; +} diff --git a/user/mpy/lib/lwip/CHANGELOG b/user/mpy/lib/lwip/CHANGELOG new file mode 100644 index 0000000..c502b00 --- /dev/null +++ b/user/mpy/lib/lwip/CHANGELOG @@ -0,0 +1,3339 @@ +HISTORY + +(CVS HEAD) + + * [Enter new changes just after this line - do not remove this line] + + ++ New features: + + 2012-03-25: Simon Goldschmidt (idea by Mason) + * posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h + which are a simple wrapper to the correct lwIP include files. + + 2012-01-16: Simon Goldschmidt + * opt.h, icmp.c: Added option CHECKSUM_GEN_ICMP + + 2011-12-17: Simon Goldschmidt + * ip.h: implemented API functions to access so_options of IP pcbs (UDP, TCP, RAW) + (fixes bug #35061) + + 2011-09-27: Simon Goldschmidt + * opt.h, tcp.c, tcp_in.c: Implemented limiting data on ooseq queue (task #9989) + (define TCP_OOSEQ_MAX_BYTES / TCP_OOSEQ_MAX_PBUFS in lwipopts.h) + + 2011-09-21: Simon Goldschmidt + * opt.h, api.h, api_lib.c, api_msg.h/.c, sockets.c: Implemented timeout on + send (TCP only, bug #33820) + + 2011-09-21: Simon Goldschmidt + * init.c: Converted runtime-sanity-checks into compile-time checks that can + be disabled (since runtime checks can often not be seen on embedded targets) + + 2011-09-11: Simon Goldschmidt + * ppp.h, ppp_impl.h: splitted ppp.h to an internal and external header file + to get a clear separation of which functions an application or port may use + (task #11281) + + 2011-09-11: Simon Goldschmidt + * opt.h, tcp_impl.h, tcp.c, udp.h/.c: Added a config option to randomize + initial local TCP/UDP ports (so that different port ranges are used after + a reboot; bug #33818; this one added tcp_init/udp_init functions again) + + 2011-09-03: Simon Goldschmidt + * dhcp.c: DHCP uses LWIP_RAND() for xid's (bug #30302) + + 2011-08-24: Simon Goldschmidt + * opt.h, netif.h/.c: added netif remove callback (bug #32397) + + 2011-07-26: Simon Goldschmidt + * etharp.c: ETHARP_SUPPORT_VLAN: add support for an external VLAN filter + function instead of only checking for one VLAN (define ETHARP_VLAN_CHECK_FN) + + 2011-07-21: Simon Goldschmidt (patch by hanhui) + * ip4.c, etharp.c, pbuf.h: bug #33634 ip_forward() have a faulty behaviour: + Added pbuf flags to mark incoming packets as link-layer broadcast/multicast. + Also added code to allow ip_forward() to forward non-broadcast packets to + the input netif (set IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1). + + 2011-06-26: Simon Goldschmidt (patch by Cameron Gutman) + * tcp.c, tcp_out.c: bug #33604: added some more asserts to check that + pcb->state != LISTEN + + 2011-05-14: Simon Goldschmidt (patch by Stéphane Lesage) + * tcpip.c/.h: patch #7449 allow tcpip callback from interrupt with static + memory message + + + ++ Bugfixes: + + 2012-09-26: Simon Goldschmidt + * api_msg.c: fixed bug #37405 'err_tcp()' uses already freed 'netconn' object + + 2012-09-26: patch by Henrik Persson + * dhcp.c: patch #7843 Fix corner case with dhcp timeouts + + 2012-09-26: patch by Henrik Persson + * dhcp.c: patch #7840 Segfault in dhcp_parse_reply if no end marker in dhcp packet + + 2012-08-22: Simon Goldschmidt + * memp.c: fixed bug #37166: memp_sanity check loops itself + + 2012-05-08: Simon Goldschmidt + * tcp_out.c: fixed bug: #36380 unsent_oversize mismatch in 1.4.1RC1 (this was + a debug-check issue only) + + 2012-03-27: Simon Goldschmidt + * vj.c: fixed bug #35756 header length calculation problem in ppp/vj.c + + 2012-03-27: Simon Goldschmidt (patch by Mason) + * tcp_out.c: fixed bug #35945: SYN packet should provide the recv MSS not the + send MSS + + 2012-03-22: Simon Goldschmidt + * ip4.c: fixed bug #35927: missing refragmentaion in ip_forward + + 2012-03-20: Simon Goldschmidt (patch by Mason) + * netdb.c: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list + + 2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic) + * ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian, + possible bug on little endian system + + 2012-02-23: Simon Goldschmidt + * etharp.c: fixed bug #35595: Impossible to send broadcast without a gateway + (introduced when fixing bug# 33551) + + 2012-02-16: Simon Goldschmidt + * ppp.c: fixed pbuf leak when PPP session is aborted through pppSigHUP() + (bug #35541: PPP Memory Leak) + + 2012-02-16: Simon Goldschmidt + * etharp.c: fixed bug #35531: Impossible to send multicast without a gateway + (introduced when fixing bug# 33551) + + 2012-02-16: Simon Goldschmidt (patch by Stéphane Lesage) + * msg_in.c, msg_out.c: fixed bug #35536 SNMP: error too big response is malformed + + 2012-02-15: Simon Goldschmidt + * init.c: fixed bug #35537: MEMP_NUM_* sanity checks should be disabled with + MEMP_MEM_MALLOC==1 + + 2012-02-12: Simon Goldschmidt + * tcp.h, tcp_in.c, tcp_out.c: partly fixed bug #25882: TCP hangs on + MSS > pcb->snd_wnd (by not creating segments bigger than half the window) + + 2012-02-11: Simon Goldschmidt + * tcp.c: fixed bug #35435: No pcb state check before adding it to time-wait + queue while closing + + 2012-01-22: Simon Goldschmidt + * tcp.c, tcp_in.c: fixed bug #35305: pcb may be freed too early on shutdown(WR) + + 2012-01-21: Simon Goldschmidt + * tcp.c: fixed bug #34636: FIN_WAIT_2 - Incorrect shutdown of TCP pcb + + 2012-01-20: Simon Goldschmidt + * dhcp.c: fixed bug #35151: DHCP asserts on incoming option lengths + + 2012-01-20: Simon Goldschmidt + * pbuf.c: fixed bug #35291: NULL pointer in pbuf_copy + + 2011-11-25: Simon Goldschmidt + * tcp.h/.c, tcp_impl.h, tcp_in.c: fixed bug #31177: tcp timers can corrupt + tcp_active_pcbs in some cases + + 2011-11-23: Simon Goldschmidt + * sys.c: fixed bug #34884: sys_msleep() body needs to be surrounded with + '#ifndef sys_msleep' + + 2011-11-22: Simon Goldschmidt + * netif.c, etharp.h/.c: fixed bug #34684: Clear the arp table cache when + netif is brought down + + 2011-10-28: Simon Goldschmidt + * tcp_in.c: fixed bug #34638: Dead code in tcp_receive - pcb->dupacks + + 2011-10-23: Simon Goldschmidt + * mem.c: fixed bug #34429: possible memory corruption with + LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT set to 1 + + 2011-10-18: Simon Goldschmidt + * arch.h, netdb.c: fixed bug #34592: lwip_gethostbyname_r uses nonstandard + error value + + 2011-10-18: Simon Goldschmidt + * opt.h: fixed default values of TCP_SNDLOWAT and TCP_SNDQUEUELOWAT for small + windows (bug #34176 select after non-blocking send times out) + + 2011-10-18: Simon Goldschmidt + * tcp_impl.h, tcp_out.c: fixed bug #34587: TCP_BUILD_MSS_OPTION doesn't + consider netif->mtu, causes slow network + + 2011-10-18: Simon Goldschmidt + * sockets.c: fixed bug #34581 missing parentheses in udplite sockets code + + 2011-10-18: Simon Goldschmidt + * sockets.h: fixed bug #34580 fcntl() is missing in LWIP_COMPAT_SOCKETS + + 2011-10-17: Simon Goldschmidt + * api_msg.c: fixed bug #34569: shutdown(SHUT_WR) crashes netconn/socket api + + 2011-10-13: Simon Goldschmidt + * tcp_in.c, tcp_out.c: fixed bug #34517 (persist timer is started although no + zero window is received) by starting the persist timer when a zero window is + received, not when we have more data queued for sending than fits into the + window + + 2011-10-13: Simon Goldschmidt + * def.h, timers.c: fixed bug #34541: LWIP_U32_DIFF is unnecessarily complex + + 2011-10-13: Simon Goldschmidt + * sockets.c, api_lib.c: fixed bug #34540: compiler error when CORE_LOCKING is + used and not all protocols are enabled + + 2011-10-12: Simon Goldschmidt + * pbuf.c: fixed bug #34534: Error in sending fragmented IP if MEM_ALIGNMENT > 4 + + 2011-10-09: Simon Goldschmidt + * tcp_out.c: fixed bug #34426: tcp_zero_window_probe() transmits incorrect + byte value when pcb->unacked != NULL + + 2011-10-09: Simon Goldschmidt + * ip4.c: fixed bug #34447 LWIP_IP_ACCEPT_UDP_PORT(dst_port) wrong + + 2011-09-27: Simon Goldschmidt + * tcp_in.c, tcp_out.c: Reset pcb->unsent_oversize in 2 more places... + + 2011-09-27: Simon Goldschmidt + * tcp_in.c: fixed bug #28288: Data after FIN in oos queue + + 2011-09-27: Simon Goldschmidt + * dhcp.c: fixed bug #34406 dhcp_option_hostname() can overflow the pbuf + + 2011-09-24: Simon Goldschmidt + * mem.h: fixed bug #34377 MEM_SIZE_F is not defined if MEM_LIBC_MALLOC==1 + + 2011-09-23: Simon Goldschmidt + * pbuf.h, tcp.c, tcp_in.c: fixed bug #33871: rejecting TCP_EVENT_RECV() for + the last packet including FIN can lose data + + 2011-09-22: Simon Goldschmidt + * tcp_impl.h: fixed bug #34355: nagle does not take snd_buf/snd_queuelen into + account + + 2011-09-21: Simon Goldschmidt + * opt.h: fixed default value of TCP_SND_BUF to not violate the sanity checks + in init.c + + 2011-09-20: Simon Goldschmidt + * timers.c: fixed bug #34337 (possible NULL pointer in sys_check_timeouts) + + 2011-09-11: Simon Goldschmidt + * tcp_out.c: use pcb->mss instead of TCP_MSS for preallocate mss-sized pbufs + (bug #34019) + + 2011-09-09: Simon Goldschmidt + * udp.c: fixed bug #34072: UDP broadcast is received from wrong UDP pcb if + udp port matches + + 2011-09-03: Simon Goldschmidt + * tcp_in.c: fixed bug #33952 PUSH flag in incoming packet is lost when packet + is aggregated and sent to application + + 2011-09-01: Simon Goldschmidt + * opt.h: fixed bug #31809 LWIP_EVENT_API in opts.h is inconsistent compared + to other options + + 2011-09-01: Simon Goldschmidt + * tcp_in.c: fixed bug #34111 RST for ACK to listening pcb has wrong seqno + + 2011-08-24: Simon Goldschmidt + * api_msg.c, sockets.c: fixed bug #33956 Wrong error returned when calling + accept() on UDP connections + + 2011-08-24: Simon Goldschmidt + * sockets.h: fixed bug #34057 socklen_t should be a typedef + + 2011-08-24: Simon Goldschmidt + * pbuf.c: fixed bug #34112 Odd check in pbuf_alloced_custom (typo) + + 2011-08-24: Simon Goldschmidt + * dhcp.c: fixed bug #34122 dhcp: hostname can overflow + + 2011-08-24: Simon Goldschmidt + * netif.c: fixed bug #34121 netif_add/netif_set_ipaddr fail on NULL ipaddr + + 2011-08-22: Simon Goldschmidt + * tcp_out.c: fixed bug #33962 TF_FIN not always set after FIN is sent. (This + merely prevents nagle from not transmitting fast after closing.) + + 2011-07-22: Simon Goldschmidt + * api_lib.c, api_msg.c, sockets.c, api.h: fixed bug #31084 (socket API returns + always EMSGSIZE on non-blocking sockets if data size > send buffers) -> now + lwip_send() sends as much as possible for non-blocking sockets + + 2011-07-22: Simon Goldschmidt + * pbuf.c/.h, timers.c: freeing ooseq pbufs when the pbuf pool is empty implemented + for NO_SYS==1: when not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() + at regular intervals from main level. + + 2011-07-21: Simon Goldschmidt + * etharp.c: fixed bug #33551 (ARP entries may time out although in use) by + sending an ARP request when an ARP entry is used in the last minute before + it would time out. + + 2011-07-04: Simon Goldschmidt + * sys_arch.txt: Fixed documentation after changing sys arch prototypes for 1.4.0. + + 2011-06-26: Simon Goldschmidt + * tcp.c: fixed bug #31723 (tcp_kill_prio() kills pcbs with the same prio) by + updating its documentation only. + + 2011-06-26: Simon Goldschmidt + * mem.c: fixed bug #33545: With MEM_USE_POOLS==1, mem_malloc can return an + unaligned pointer. + + 2011-06-26: Simon Goldschmidt + * mem.c: fixed bug #33544 "warning in mem.c in lwip 1.4.0 with NO_SYS=1" + + 2011-05-25: Simon Goldschmidt + * tcp.c: fixed bug #33398 (pointless conversion when checking TCP port range) + + + +(STABLE-1.4.0) + + ++ New features: + + 2011-03-27: Simon Goldschmidt + * tcp_impl.h, tcp_in.c, tcp_out.c: Removed 'dataptr' from 'struct tcp_seg' and + calculate it in tcp_zero_window_probe (the only place where it was used). + + 2010-11-21: Simon Goldschmidt + * dhcp.c/.h: Added a function to deallocate the struct dhcp from a netif + (fixes bug #31525). + + 2010-07-12: Simon Goldschmidt (patch by Stephane Lesage) + * ip.c, udp.c/.h, pbuf.h, sockets.c: task #10495: Added support for + IP_MULTICAST_LOOP at socket- and raw-API level. + + 2010-06-16: Simon Goldschmidt + * ip.c: Added an optional define (LWIP_IP_ACCEPT_UDP_PORT) that can allow + link-layer-addressed UDP traffic to be received while a netif is down (just + like DHCP during configuration) + + 2010-05-22: Simon Goldschmidt + * many many files: bug #27352: removed packing from ip_addr_t, the packed + version is now only used in protocol headers. Added global storage for + current src/dest IP address while in input functions. + + 2010-05-16: Simon Goldschmidt + * def.h: task #10391: Add preprocessor-macros for compile-time htonl + calculation (and use them throughout the stack where applicable) + + 2010-05-16: Simon Goldschmidt + * opt.h, memp_std.h, memp.c, ppp_oe.h/.c: PPPoE now uses its own MEMP pool + instead of the heap (moved struct pppoe_softc from ppp_oe.c to ppp_oe.h) + + 2010-05-16: Simon Goldschmidt + * opt.h, memp_std.h, dns.h/.c: DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses its own + MEMP pool instead of the heap + + 2010-05-13: Simon Goldschmidt + * tcp.c, udp.c: task #6995: Implement SO_REUSEADDR (correctly), added + new option SO_REUSE_RXTOALL to pass received UDP broadcast/multicast + packets to more than one pcb. + + 2010-05-02: Simon Goldschmidt + * netbuf.h/.c, sockets.c, api_msg.c: use checksum-on-copy for sending + UDP data for LWIP_NETIF_TX_SINGLE_PBUF==1 + + 2010-04-30: Simon Goldschmidt + * udp.h/.c, pbuf.h/.c: task #6849: added udp_send(_to/_if) functions that + take a precalculated checksum, added pbuf_fill_chksum() to copy data + into a pbuf and at the same time calculating the checksum for that data + + 2010-04-29: Simon Goldschmidt + * ip_addr.h, etharp.h/.c, autoip.c: Create overridable macros for copying + 2-byte-aligned IP addresses and MAC addresses + + 2010-04-28: Patch by Bill Auerbach + * ip.c: Inline generating IP checksum to save a function call + + 2010-04-14: Simon Goldschmidt + * tcpip.h/.c, timers.c: Added an overridable define to get informed when the + tcpip_thread processes messages or timeouts to implement a watchdog. + + 2010-03-28: Simon Goldschmidt + * ip_frag.c: create a new (contiguous) PBUF_RAM for every outgoing + fragment if LWIP_NETIF_TX_SINGLE_PBUF==1 + + 2010-03-27: Simon Goldschmidt + * etharp.c: Speedup TX by moving code from find_entry to etharp_output/ + etharp_query to prevent unnecessary function calls (inspired by + patch #7135). + + 2010-03-20: Simon Goldschmidt + * opt.h, tcpip.c/.h: Added an option to disable tcpip_(un)timeout code + since the linker cannot do this automatically to save space. + + 2010-03-20: Simon Goldschmidt + * opt.h, etharp.c/.h: Added support for static ARP table entries + + 2010-03-14: Simon Goldschmidt + * tcp_impl.h, tcp_out.c, inet_chksum.h/.c: task #6849: Calculate checksum + when creating TCP segments, not when (re-)transmitting them. + + 2010-03-07: Simon Goldschmidt + * sockets.c: bug #28775 (select/event_callback: only check select_cb_list + on change) plus use SYS_LIGHTWEIGHT_PROT to protect the select code. + This should speed up receiving data on sockets as the select code in + event_callback is only executed when select is waiting. + + 2010-03-06: Simon Goldschmidt + * tcp_out.c: task #7013 (Create option to have all packets delivered to + netif->output in one piece): Always copy to try to create single pbufs + in tcp_write. + + 2010-03-06: Simon Goldschmidt + * api.h, api_lib.c, sockets.c: task #10167 (sockets: speed up TCP recv + by not allocating a netbuf): added function netconn_recv_tcp_pbuf() + for tcp netconns to receive pbufs, not netbufs; use that function + for tcp sockets. + + 2010-03-05: Jakob Ole Stoklundsen / Simon Goldschmidt + * opt.h, tcp.h, tcp_impl.h, tcp.c, tcp_in.c, tcp_out.c: task #7040: + Work on tcp_enqueue: Don't waste memory when chaining segments, + added option TCP_OVERSIZE to prevent creating many small pbufs when + calling tcp_write with many small blocks of data. Instead, pbufs are + allocated larger than needed and the space is used for later calls to + tcp_write. + + 2010-02-21: Simon Goldschmidt + * stats.c/.h: Added const char* name to mem- and memp-stats for easier + debugging. + + 2010-02-21: Simon Goldschmidt + * tcp.h (and usages), added tcp_impl.h: Splitted API and internal + implementation of tcp to make API usage cleare to application programmers + + 2010-02-14: Simon Goldschmidt/Stephane Lesage + * ip_addr.h: Improved some defines working on ip addresses, added faster + macro to copy addresses that cannot be NULL + + 2010-02-13: Simon Goldschmidt + * api.h, api_lib.c, api_msg.c, sockets.c: task #7865 (implement non- + blocking send operation) + + 2010-02-12: Simon Goldschmidt + * sockets.c/.h: Added a minimal version of posix fctl() to have a + standardised way to set O_NONBLOCK for nonblocking sockets. + + 2010-02-12: Simon Goldschmidt + * dhcp.c/.h, autoip.c/.h: task #10139 (Prefer statically allocated + memory): added autoip_set_struct() and dhcp_set_struct() to let autoip + and dhcp work with user-allocated structs instead of callin mem_malloc + + 2010-02-12: Simon Goldschmidt/Jeff Barber + * tcp.c/h: patch #6865 (SO_REUSEADDR for TCP): if pcb.so_options has + SOF_REUSEADDR set, allow binding to endpoint in TIME_WAIT + + 2010-02-12: Simon Goldschmidt + * sys layer: task #10139 (Prefer statically allocated memory): converted + mbox and semaphore functions to take pointers to sys_mbox_t/sys_sem_t; + converted sys_mbox_new/sys_sem_new to take pointers and return err_t; + task #7212: Add Mutex concept in sys_arch (define LWIP_COMPAT_MUTEX + to let sys.h use binary semaphores instead of mutexes - as before) + + 2010-02-09: Simon Goldschmidt (Simon Kallweit) + * timers.c/.h: Added function sys_restart_timeouts() from patch #7085 + (Restart system timeout handling) + + 2010-02-09: Simon Goldschmidt + * netif.c/.h, removed loopif.c/.h: task #10153 (Integrate loopif into + netif.c) - loopif does not have to be created by the port any more, + just define LWIP_HAVE_LOOPIF to 1. + + 2010-02-08: Simon Goldschmidt + * inet.h, ip_addr.c/.h: Added reentrant versions of inet_ntoa/ipaddr_ntoa + inet_ntoa_r/ipaddr_ntoa_r + + 2010-02-08: Simon Goldschmidt + * netif.h: Added netif_s/get_igmp_mac_filter() macros + + 2010-02-05: Simon Goldschmidt + * netif.h: Added function-like macros to get/set the hostname on a netif + + 2010-02-04: Simon Goldschmidt + * nearly every file: Replaced struct ip_addr by typedef ip_addr_t to + make changing the actual implementation behind the typedef easier. + + 2010-02-01: Simon Goldschmidt + * opt.h, memp_std.h, dns.h, netdb.c, memp.c: Let netdb use a memp pool + for allocating memory when getaddrinfo() is called. + + 2010-01-31: Simon Goldschmidt + * dhcp.h, dhcp.c: Reworked the code that parses DHCP options: parse + them once instead of parsing for every option. This also removes + the need for mem_malloc from dhcp_recv and makes it possible to + correctly retrieve the BOOTP file. + + 2010-01-30: simon Goldschmidt + * sockets.c: Use SYS_LIGHTWEIGHT_PROT instead of a semaphore to protect + the sockets array. + + 2010-01-29: Simon Goldschmidt (patch by Laura Garrett) + * api.h, api_msg.c, sockets.c: Added except set support in select + (patch #6860) + + 2010-01-29: Simon Goldschmidt (patch by Laura Garrett) + * api.h, sockets.h, err.h, api_lib.c, api_msg.c, sockets.c, err.c: + Add non-blocking support for connect (partly from patch #6860), + plus many cleanups in socket & netconn API. + + 2010-01-27: Simon Goldschmidt + * opt.h, tcp.h, init.c, api_msg.c: Added TCP_SNDQUEUELOWAT corresponding + to TCP_SNDLOWAT and added tcp_sndqueuelen() - this fixes bug #28605 + + 2010-01-26: Simon Goldschmidt + * snmp: Use memp pools for snmp instead of the heap; added 4 new pools. + + 2010-01-14: Simon Goldschmidt + * ppp.c/.h: Fixed bug #27856: PPP: Set netif link- and status-callback + by adding ppp_set_netif_statuscallback()/ppp_set_netif_linkcallback() + + 2010-01-13: Simon Goldschmidt + * mem.c: The heap now may be moved to user-defined memory by defining + LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address + (patch #6966 and bug #26133) + + 2010-01-10: Simon Goldschmidt (Bill Auerbach) + * opt.h, memp.c: patch #6822 (Add option to place memory pools in + separate arrays) + + 2010-01-10: Simon Goldschmidt + * init.c, igmp.c: patch #6463 (IGMP - Adding Random Delay): added define + LWIP_RAND() for lwip-wide randomization (to be defined in cc.h) + + 2009-12-31: Simon Goldschmidt + * tcpip.c, init.c, memp.c, sys.c, memp_std.h, sys.h, tcpip.h + added timers.c/.h: Separated timer implementation from semaphore/mbox + implementation, moved timer implementation to timers.c/.h, timers are + now only called from tcpip_thread or by explicitly checking them. + (TASK#7235) + + 2009-12-27: Simon Goldschmidt + * opt.h, etharp.h/.c, init.c, tcpip.c: Added an additional option + LWIP_ETHERNET to support ethernet without ARP (necessary for pure PPPoE) + + + ++ Bugfixes: + + 2011-04-20: Simon Goldschmidt + * sys_arch.txt: sys_arch_timeouts() is not needed any more. + + 2011-04-13: Simon Goldschmidt + * tcp.c, udp.c: Fixed bug #33048 (Bad range for IP source port numbers) by + using ports in the IANA private/dynamic range (49152 through 65535). + + 2011-03-29: Simon Goldschmidt, patch by Emil Lhungdahl: + * etharp.h/.c: Fixed broken VLAN support. + + 2011-03-27: Simon Goldschmidt + * tcp.c: Fixed bug #32926 (TCP_RMV(&tcp_bound_pcbs) is called on unbound tcp + pcbs) by checking if the pcb was bound (local_port != 0). + + 2011-03-27: Simon Goldschmidt + * ppp.c: Fixed bug #32280 (ppp: a pbuf is freed twice) + + 2011-03-27: Simon Goldschmidt + * sockets.c: Fixed bug #32906: lwip_connect+lwip_send did not work for udp and + raw pcbs with LWIP_TCPIP_CORE_LOCKING==1. + + 2011-03-27: Simon Goldschmidt + * tcp_out.c: Fixed bug #32820 (Outgoing TCP connections created before route + is present never times out) by starting retransmission timer before checking + route. + + 2011-03-22: Simon Goldschmidt + * ppp.c: Fixed bug #32648 (PPP code crashes when terminating a link) by only + calling sio_read_abort() if the file descriptor is valid. + + 2011-03-14: Simon Goldschmidt + * err.h/.c, sockets.c, api_msg.c: fixed bug #31748 (Calling non-blocking connect + more than once can render a socket useless) since it mainly involves changing + "FATAL" classification of error codes: ERR_USE and ERR_ISCONN just aren't fatal. + + 2011-03-13: Simon Goldschmidt + * sockets.c: fixed bug #32769 (ESHUTDOWN is linux-specific) by fixing + err_to_errno_table (ERR_CLSD: ENOTCONN instead of ESHUTDOWN), ERR_ISCONN: + use EALRADY instead of -1 + + 2011-03-13: Simon Goldschmidt + * api_lib.c: netconn_accept: return ERR_ABRT instead of ERR_CLSD if the + connection has been aborted by err_tcp (since this is not a normal closing + procedure). + + 2011-03-13: Simon Goldschmidt + * tcp.c: tcp_bind: return ERR_VAL instead of ERR_ISCONN when trying to bind + with pcb->state != CLOSED + + 2011-02-17: Simon Goldschmidt + * rawapi.txt: Fixed bug #32561 tcp_poll argument definition out-of-order in + documentation + + 2011-02-17: Simon Goldschmidt + * many files: Added missing U/UL modifiers to fix 16-bit-arch portability. + + 2011-01-24: Simon Goldschmidt + * sockets.c: Fixed bug #31741: lwip_select seems to have threading problems + + 2010-12-02: Simon Goldschmidt + * err.h: Fixed ERR_IS_FATAL so that ERR_WOULDBLOCK is not fatal. + + 2010-11-23: Simon Goldschmidt + * api.h, api_lib.c, api_msg.c, sockets.c: netconn.recv_avail is only used for + LWIP_SO_RCVBUF and ioctl/FIONREAD. + + 2010-11-23: Simon Goldschmidt + * etharp.c: Fixed bug #31720: ARP-queueing: RFC 1122 recommends to queue at + least 1 packet -> ARP_QUEUEING==0 now queues the most recent packet. + + 2010-11-23: Simon Goldschmidt + * tcp_in.c: Fixed bug #30577: tcp_input: don't discard ACK-only packets after + refusing 'refused_data' again. + + 2010-11-22: Simon Goldschmidt + * sockets.c: Fixed bug #31590: getsockopt(... SO_ERROR ...) gives EINPROGRESS + after a successful nonblocking connection. + + 2010-11-22: Simon Goldschmidt + * etharp.c: Fixed bug #31722: IP packets sent with an AutoIP source addr + must be sent link-local + + 2010-11-22: Simon Goldschmidt + * timers.c: patch #7329: tcp_timer_needed prototype was ifdef'ed out for + LWIP_TIMERS==0 + + 2010-11-20: Simon Goldschmidt + * sockets.c: Fixed bug #31170: lwip_setsockopt() does not set socket number + + 2010-11-20: Simon Goldschmidt + * sockets.h: Fixed bug #31304: Changed SHUT_RD, SHUT_WR and SHUT_RDWR to + resemble other stacks. + + 2010-11-20: Simon Goldschmidt + * dns.c: Fixed bug #31535: TCP_SND_QUEUELEN must be at least 2 or else + no-copy TCP writes will never succeed. + + 2010-11-20: Simon Goldschmidt + * dns.c: Fixed bug #31701: Error return value from dns_gethostbyname() does + not match documentation: return ERR_ARG instead of ERR_VAL if not + initialized or wrong argument. + + 2010-10-20: Simon Goldschmidt + * sockets.h: Fixed bug #31385: sizeof(struct sockaddr) is 30 but should be 16 + + 2010-10-05: Simon Goldschmidt + * dhcp.c: Once again fixed #30038: DHCP/AutoIP cooperation failed when + replugging the network cable after an AutoIP address was assigned. + + 2010-08-10: Simon Goldschmidt + * tcp.c: Fixed bug #30728: tcp_new_port() did not check listen pcbs + + 2010-08-03: Simon Goldschmidt + * udp.c, raw.c: Don't chain empty pbufs when sending them (fixes bug #30625) + + 2010-08-01: Simon Goldschmidt (patch by Greg Renda) + * ppp.c: Applied patch #7264 (PPP protocols are rejected incorrectly on big + endian architectures) + + 2010-07-28: Simon Goldschmidt + * api_lib.c, api_msg.c, sockets.c, mib2.c: Fixed compilation with TCP or UDP + disabled. + + 2010-07-27: Simon Goldschmidt + * tcp.c: Fixed bug #30565 (tcp_connect() check bound list): that check did no + harm but never did anything + + 2010-07-21: Simon Goldschmidt + * ip.c: Fixed invalid fix for bug #30402 (CHECKSUM_GEN_IP_INLINE does not + add IP options) + + 2010-07-16: Kieran Mansley + * msg_in.c: Fixed SNMP ASN constant defines to not use ! operator + + 2010-07-10: Simon Goldschmidt + * ip.c: Fixed bug #30402: CHECKSUM_GEN_IP_INLINE does not add IP options + + 2010-06-30: Simon Goldschmidt + * api_msg.c: fixed bug #30300 (shutdown parameter was not initialized in + netconn_delete) + + 2010-06-28: Kieran Mansley + * timers.c remove unportable printing of C function pointers + + 2010-06-24: Simon Goldschmidt + * init.c, timers.c/.h, opt.h, memp_std.h: From patch #7221: added flag + NO_SYS_NO_TIMERS to drop timer support for NO_SYS==1 for easier upgrading + + 2010-06-24: Simon Goldschmidt + * api(_lib).c/.h, api_msg.c/.h, sockets.c/.h: Fixed bug #10088: Correctly + implemented shutdown at socket level. + + 2010-06-21: Simon Goldschmidt + * pbuf.c/.h, ip_frag.c/.h, opt.h, memp_std.h: Fixed bug #29361 (ip_frag has + problems with zero-copy DMA MACs) by adding custom pbufs and implementing + custom pbufs that reference other (original) pbufs. Additionally set + IP_FRAG_USES_STATIC_BUF=0 as default to be on the safe side. + + 2010-06-15: Simon Goldschmidt + * dhcp.c: Fixed bug #29970: DHCP endian issue parsing option responses + + 2010-06-14: Simon Goldschmidt + * autoip.c: Fixed bug #30039: AutoIP does not reuse previous addresses + + 2010-06-12: Simon Goldschmidt + * dhcp.c: Fixed bug #30038: dhcp_network_changed doesn't reset AUTOIP coop + state + + 2010-05-17: Simon Goldschmidt + * netdb.c: Correctly NULL-terminate h_addr_list + + 2010-05-16: Simon Goldschmidt + * def.h/.c: changed the semantics of LWIP_PREFIX_BYTEORDER_FUNCS to prevent + "symbol already defined" i.e. when linking to winsock + + 2010-05-05: Simon Goldschmidt + * def.h, timers.c: Fixed bug #29769 (sys_check_timeouts: sys_now() may + overflow) + + 2010-04-21: Simon Goldschmidt + * api_msg.c: Fixed bug #29617 (sometime cause stall on delete listening + connection) + + 2010-03-28: Luca Ceresoli + * ip_addr.c/.h: patch #7143: Add a few missing const qualifiers + + 2010-03-27: Luca Ceresoli + * mib2.c: patch #7130: remove meaningless const qualifiers + + 2010-03-26: Simon Goldschmidt + * tcp_out.c: Make LWIP_NETIF_TX_SINGLE_PBUF work for TCP, too + + 2010-03-26: Simon Goldschmidt + * various files: Fixed compiling with different options disabled (TCP/UDP), + triggered by bug #29345; don't allocate acceptmbox if LWIP_TCP is disabled + + 2010-03-25: Simon Goldschmidt + * sockets.c: Fixed bug #29332: lwip_select() processes readset incorrectly + + 2010-03-25: Simon Goldschmidt + * tcp_in.c, test_tcp_oos.c: Fixed bug #29080: Correctly handle remote side + overrunning our rcv_wnd in ooseq case. + + 2010-03-22: Simon Goldschmidt + * tcp.c: tcp_listen() did not copy the pcb's prio. + + 2010-03-19: Simon Goldschmidt + * snmp_msg.c: Fixed bug #29256: SNMP Trap address was not correctly set + + 2010-03-14: Simon Goldschmidt + * opt.h, etharp.h: Fixed bug #29148 (Incorrect PBUF_POOL_BUFSIZE for ports + where ETH_PAD_SIZE > 0) by moving definition of ETH_PAD_SIZE to opt.h + and basing PBUF_LINK_HLEN on it. + + 2010-03-08: Simon Goldschmidt + * netif.c, ipv4/ip.c: task #10241 (AutoIP: don't break existing connections + when assiging routable address): when checking incoming packets and + aborting existing connection on address change, filter out link-local + addresses. + + 2010-03-06: Simon Goldschmidt + * sockets.c: Fixed LWIP_NETIF_TX_SINGLE_PBUF for LWIP_TCPIP_CORE_LOCKING + + 2010-03-06: Simon Goldschmidt + * ipv4/ip.c: Don't try to forward link-local addresses + + 2010-03-06: Simon Goldschmidt + * etharp.c: Fixed bug #29087: etharp: don't send packets for LinkLocal- + addresses to gw + + 2010-03-05: Simon Goldschmidt + * dhcp.c: Fixed bug #29072: Correctly set ciaddr based on message-type + and state. + + 2010-03-05: Simon Goldschmidt + * api_msg.c: Correctly set TCP_WRITE_FLAG_MORE when netconn_write is split + into multiple calls to tcp_write. + + 2010-02-21: Simon Goldschmidt + * opt.h, mem.h, dns.c: task #10140: Remove DNS_USES_STATIC_BUF (keep + the implementation of DNS_USES_STATIC_BUF==1) + + 2010-02-20: Simon Goldschmidt + * tcp.h, tcp.c, tcp_in.c, tcp_out.c: Task #10088: Correctly implement + close() vs. shutdown(). Now the application does not get any more + recv callbacks after calling tcp_close(). Added tcp_shutdown(). + + 2010-02-19: Simon Goldschmidt + * mem.c/.h, pbuf.c: Renamed mem_realloc() to mem_trim() to prevent + confusion with realloc() + + 2010-02-15: Simon Goldschmidt/Stephane Lesage + * netif.c/.h: Link status does not depend on LWIP_NETIF_LINK_CALLBACK + (fixes bug #28899) + + 2010-02-14: Simon Goldschmidt + * netif.c: Fixed bug #28877 (Duplicate ARP gratuitous packet with + LWIP_NETIF_LINK_CALLBACK set on) by only sending if both link- and + admin-status of a netif are up + + 2010-02-14: Simon Goldschmidt + * opt.h: Disable ETHARP_TRUST_IP_MAC by default since it slows down packet + reception and is not really necessary + + 2010-02-14: Simon Goldschmidt + * etharp.c/.h: Fixed ARP input processing: only add a new entry if a + request was directed as us (RFC 826, Packet Reception), otherwise + only update existing entries; internalized some functions + + 2010-02-14: Simon Goldschmidt + * netif.h, etharp.c, tcpip.c: Fixed bug #28183 (ARP and TCP/IP cannot be + disabled on netif used for PPPoE) by adding a new netif flag + (NETIF_FLAG_ETHERNET) that tells the stack the device is an ethernet + device but prevents usage of ARP (so that ethernet_input can be used + for PPPoE). + + 2010-02-12: Simon Goldschmidt + * netif.c: netif_set_link_up/down: only do something if the link state + actually changes + + 2010-02-12: Simon Goldschmidt/Stephane Lesage + * api_msg.c: Fixed bug #28865 (Cannot close socket/netconn in non-blocking + connect) + + 2010-02-12: Simon Goldschmidt + * mem.h: Fixed bug #28866 (mem_realloc function defined in mem.h) + + 2010-02-09: Simon Goldschmidt + * api_lib.c, api_msg.c, sockets.c, api.h, api_msg.h: Fixed bug #22110 + (recv() makes receive window update for data that wasn't received by + application) + + 2010-02-09: Simon Goldschmidt/Stephane Lesage + * sockets.c: Fixed bug #28853 (lwip_recvfrom() returns 0 on receive time-out + or any netconn_recv() error) + + 2010-02-09: Simon Goldschmidt + * ppp.c: task #10154 (PPP: Update snmp in/out counters for tx/rx packets) + + 2010-02-09: Simon Goldschmidt + * netif.c: For loopback packets, adjust the stats- and snmp-counters + for the loopback netif. + + 2010-02-08: Simon Goldschmidt + * igmp.c/.h, ip.h: Moved most defines from igmp.h to igmp.c for clarity + since they are not used anywhere else. + + 2010-02-08: Simon Goldschmidt (Stéphane Lesage) + * igmp.c, igmp.h, stats.c, stats.h: Improved IGMP stats + (patch from bug #28798) + + 2010-02-08: Simon Goldschmidt (Stéphane Lesage) + * igmp.c: Fixed bug #28798 (Error in "Max Response Time" processing) and + another bug when LWIP_RAND() returns zero. + + 2010-02-04: Simon Goldschmidt + * nearly every file: Use macros defined in ip_addr.h (some of them new) + to work with IP addresses (preparation for bug #27352 - Change ip_addr + from struct to typedef (u32_t) - and better code). + + 2010-01-31: Simon Goldschmidt + * netif.c: Don't call the link-callback from netif_set_up/down() since + this invalidly retriggers DHCP. + + 2010-01-29: Simon Goldschmidt + * ip_addr.h, inet.h, def.h, inet.c, def.c, more: Cleanly separate the + portability file inet.h and its contents from the stack: moved htonX- + functions to def.h (and the new def.c - they are not ipv4 dependent), + let inet.h depend on ip_addr.h and not the other way round. + This fixes bug #28732. + + 2010-01-28: Kieran Mansley + * tcp.c: Ensure ssthresh >= 2*MSS + + 2010-01-27: Simon Goldschmidt + * tcp.h, tcp.c, tcp_in.c: Fixed bug #27871: Calling tcp_abort() in recv + callback can lead to accessing unallocated memory. As a consequence, + ERR_ABRT means the application has called tcp_abort()! + + 2010-01-25: Simon Goldschmidt + * snmp_structs.h, msg_in.c: Partly fixed bug #22070 (MIB_OBJECT_WRITE_ONLY + not implemented in SNMP): write-only or not-accessible are still + returned by getnext (though not by get) + + 2010-01-24: Simon Goldschmidt + * snmp: Renamed the private mib node from 'private' to 'mib_private' to + not use reserved C/C++ keywords + + 2010-01-23: Simon Goldschmidt + * sockets.c: Fixed bug #28716: select() returns 0 after waiting for less + than 1 ms + + 2010-01-21: Simon Goldschmidt + * tcp.c, api_msg.c: Fixed bug #28651 (tcp_connect: no callbacks called + if tcp_enqueue fails) both in raw- and netconn-API + + 2010-01-19: Simon Goldschmidt + * api_msg.c: Fixed bug #27316: netconn: Possible deadlock in err_tcp + + 2010-01-18: Iordan Neshev/Simon Goldschmidt + * src/netif/ppp: reorganised PPP sourcecode to 2.3.11 including some + bugfix backports from 2.4.x. + + 2010-01-18: Simon Goldschmidt + * mem.c: Fixed bug #28679: mem_realloc calculates mem_stats wrong + + 2010-01-17: Simon Goldschmidt + * api_lib.c, api_msg.c, (api_msg.h, api.h, sockets.c, tcpip.c): + task #10102: "netconn: clean up conn->err threading issues" by adding + error return value to struct api_msg_msg + + 2010-01-17: Simon Goldschmidt + * api.h, api_lib.c, sockets.c: Changed netconn_recv() and netconn_accept() + to return err_t (bugs #27709 and #28087) + + 2010-01-14: Simon Goldschmidt + * ...: Use typedef for function prototypes throughout the stack. + + 2010-01-13: Simon Goldschmidt + * api_msg.h/.c, api_lib.c: Fixed bug #26672 (close connection when receive + window = 0) by correctly draining recvmbox/acceptmbox + + 2010-01-11: Simon Goldschmidt + * pap.c: Fixed bug #13315 (PPP PAP authentication can result in + erroneous callbacks) by copying the code from recent pppd + + 2010-01-10: Simon Goldschmidt + * raw.c: Fixed bug #28506 (raw_bind should filter received packets) + + 2010-01-10: Simon Goldschmidt + * tcp.h/.c: bug #28127 (remove call to tcp_output() from tcp_ack(_now)()) + + 2010-01-08: Simon Goldschmidt + * sockets.c: Fixed bug #28519 (lwip_recvfrom bug with len > 65535) + + 2010-01-08: Simon Goldschmidt + * dns.c: Copy hostname for DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1 since string + passed to dns_local_addhost() might be volatile + + 2010-01-07: Simon Goldschmidt + * timers.c, tcp.h: Call tcp_timer_needed() with NO_SYS==1, too + + 2010-01-06: Simon Goldschmidt + * netdb.h: Fixed bug #28496: missing include guards in netdb.h + + 2009-12-31: Simon Goldschmidt + * many ppp files: Reorganised PPP source code from ucip structure to pppd + structure to easily compare our code against the pppd code (around v2.3.1) + + 2009-12-27: Simon Goldschmidt + * tcp_in.c: Another fix for bug #28241 (ooseq processing) and adapted + unit test + + +(STABLE-1.3.2) + + ++ New features: + + 2009-10-27 Simon Goldschmidt/Stephan Lesage + * netifapi.c/.h: Added netifapi_netif_set_addr() + + 2009-10-07 Simon Goldschmidt/Fabian Koch + * api_msg.c, netbuf.c/.h, opt.h: patch #6888: Patch for UDP Netbufs to + support dest-addr and dest-port (optional: LWIP_NETBUF_RECVINFO) + + 2009-08-26 Simon Goldschmidt/Simon Kallweit + * slipif.c/.h: bug #26397: SLIP polling support + + 2009-08-25 Simon Goldschmidt + * opt.h, etharp.h/.c: task #9033: Support IEEE 802.1q tagged frame (VLAN), + New configuration options ETHARP_SUPPORT_VLAN and ETHARP_VLAN_CHECK. + + 2009-08-25 Simon Goldschmidt + * ip_addr.h, netdb.c: patch #6900: added define ip_ntoa(struct ip_addr*) + + 2009-08-24 Jakob Stoklund Olesen + * autoip.c, dhcp.c, netif.c: patch #6725: Teach AutoIP and DHCP to respond + to netif_set_link_up(). + + 2009-08-23 Simon Goldschmidt + * tcp.h/.c: Added function tcp_debug_state_str() to convert a tcp state + to a human-readable string. + + ++ Bugfixes: + + 2009-12-24: Kieran Mansley + * tcp_in.c Apply patches from Oleg Tyshev to improve OOS processing + (BUG#28241) + + 2009-12-06: Simon Goldschmidt + * ppp.h/.c: Fixed bug #27079 (Yet another leak in PPP): outpacket_buf can + be statically allocated (like in ucip) + + 2009-12-04: Simon Goldschmidt (patch by Ioardan Neshev) + * pap.c: patch #6969: PPP: missing PAP authentication UNTIMEOUT + + 2009-12-03: Simon Goldschmidt + * tcp.h, tcp_in.c, tcp_out.c: Fixed bug #28106: dup ack for fast retransmit + could have non-zero length + + 2009-12-02: Simon Goldschmidt + * tcp_in.c: Fixed bug #27904: TCP sends too many ACKs: delay resetting + tcp_input_pcb until after calling the pcb's callbacks + + 2009-11-29: Simon Goldschmidt + * tcp_in.c: Fixed bug #28054: Two segments with FIN flag on the out-of- + sequence queue, also fixed PBUF_POOL leak in the out-of-sequence code + + 2009-11-29: Simon Goldschmidt + * pbuf.c: Fixed bug #28064: pbuf_alloc(PBUF_POOL) is not thread-safe by + queueing a call into tcpip_thread to free ooseq-bufs if the pool is empty + + 2009-11-26: Simon Goldschmidt + * tcp.h: Fixed bug #28098: Nagle can prevent fast retransmit from sending + segment + + 2009-11-26: Simon Goldschmidt + * tcp.h, sockets.c: Fixed bug #28099: API required to disable Nagle + algorithm at PCB level + + 2009-11-22: Simon Goldschmidt + * tcp_out.c: Fixed bug #27905: FIN isn't combined with data on unsent + + 2009-11-22: Simon Goldschmidt (suggested by Bill Auerbach) + * tcp.c: tcp_alloc: prevent increasing stats.err for MEMP_TCP_PCB when + reusing time-wait pcb + + 2009-11-20: Simon Goldschmidt (patch by Albert Bartel) + * sockets.c: Fixed bug #28062: Data received directly after accepting + does not wake up select + + 2009-11-11: Simon Goldschmidt + * netdb.h: Fixed bug #27994: incorrect define for freeaddrinfo(addrinfo) + + 2009-10-30: Simon Goldschmidt + * opt.h: Increased default value for TCP_MSS to 536, updated default + value for TCP_WND to 4*TCP_MSS to keep delayed ACK working. + + 2009-10-28: Kieran Mansley + * tcp_in.c, tcp_out.c, tcp.h: re-work the fast retransmission code + to follow algorithm from TCP/IP Illustrated + + 2009-10-27: Kieran Mansley + * tcp_in.c: fix BUG#27445: grow cwnd with every duplicate ACK + + 2009-10-25: Simon Goldschmidt + * tcp.h: bug-fix in the TCP_EVENT_RECV macro (has to call tcp_recved if + pcb->recv is NULL to keep rcv_wnd correct) + + 2009-10-25: Simon Goldschmidt + * tcp_in.c: Fixed bug #26251: RST process in TIME_WAIT TCP state + + 2009-10-23: Simon Goldschmidt (David Empson) + * tcp.c: Fixed bug #27783: Silly window avoidance for small window sizes + + 2009-10-21: Simon Goldschmidt + * tcp_in.c: Fixed bug #27215: TCP sent() callback gives leading and + trailing 1 byte len (SYN/FIN) + + 2009-10-21: Simon Goldschmidt + * tcp_out.c: Fixed bug #27315: zero window probe and FIN + + 2009-10-19: Simon Goldschmidt + * dhcp.c/.h: Minor code simplification (don't store received pbuf, change + conditional code to assert where applicable), check pbuf length before + testing for valid reply + + 2009-10-19: Simon Goldschmidt + * dhcp.c: Removed most calls to udp_connect since they aren't necessary + when using udp_sendto_if() - always stay connected to IP_ADDR_ANY. + + 2009-10-16: Simon Goldschmidt + * ip.c: Fixed bug #27390: Source IP check in ip_input() causes it to drop + valid DHCP packets -> allow 0.0.0.0 as source address when LWIP_DHCP is + enabled + + 2009-10-15: Simon Goldschmidt (Oleg Tyshev) + * tcp_in.c: Fixed bug #27329: dupacks by unidirectional data transmit + + 2009-10-15: Simon Goldschmidt + * api_lib.c: Fixed bug #27709: conn->err race condition on netconn_recv() + timeout + + 2009-10-15: Simon Goldschmidt + * autoip.c: Fixed bug #27704: autoip starts with wrong address + LWIP_AUTOIP_CREATE_SEED_ADDR() returned address in host byte order instead + of network byte order + + 2009-10-11 Simon Goldschmidt (Jörg Kesten) + * tcp_out.c: Fixed bug #27504: tcp_enqueue wrongly concatenates segments + which are not consecutive when retransmitting unacked segments + + 2009-10-09 Simon Goldschmidt + * opt.h: Fixed default values of some stats to only be enabled if used + Fixes bug #27338: sys_stats is defined when NO_SYS = 1 + + 2009-08-30 Simon Goldschmidt + * ip.c: Fixed bug bug #27345: "ip_frag() does not use the LWIP_NETIF_LOOPBACK + function" by checking for loopback before calling ip_frag + + 2009-08-25 Simon Goldschmidt + * dhcp.c: fixed invalid dependency to etharp_query if DHCP_DOES_ARP_CHECK==0 + + 2009-08-23 Simon Goldschmidt + * ppp.c: bug #27078: Possible memory leak in pppInit() + + 2009-08-23 Simon Goldschmidt + * netdb.c, dns.c: bug #26657: DNS, if host name is "localhost", result + is error. + + 2009-08-23 Simon Goldschmidt + * opt.h, init.c: bug #26649: TCP fails when TCP_MSS > TCP_SND_BUF + Fixed wrong parenthesis, added check in init.c + + 2009-08-23 Simon Goldschmidt + * ppp.c: bug #27266: wait-state debug message in pppMain occurs every ms + + 2009-08-23 Simon Goldschmidt + * many ppp files: bug #27267: Added include to string.h where needed + + 2009-08-23 Simon Goldschmidt + * tcp.h: patch #6843: tcp.h macro optimization patch (for little endian) + + +(STABLE-1.3.1) + + ++ New features: + + 2009-05-10 Simon Goldschmidt + * opt.h, sockets.c, pbuf.c, netbuf.h, pbuf.h: task #7013: Added option + LWIP_NETIF_TX_SINGLE_PBUF to try to create transmit packets from only + one pbuf to help MACs that don't support scatter-gather DMA. + + 2009-05-09 Simon Goldschmidt + * icmp.h, icmp.c: Shrinked ICMP code, added option to NOT check icoming + ECHO pbuf for size (just use it): LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN + + 2009-05-05 Simon Goldschmidt, Jakob Stoklund Olesen + * ip.h, ip.c: Added ip_current_netif() & ip_current_header() to receive + extended info about the currently received packet. + + 2009-04-27 Simon Goldschmidt + * sys.h: Made SYS_LIGHTWEIGHT_PROT and sys_now() work with NO_SYS=1 + + 2009-04-25 Simon Goldschmidt + * mem.c, opt.h: Added option MEM_USE_POOLS_TRY_BIGGER_POOL to try the next + bigger malloc pool if one is empty (only usable with MEM_USE_POOLS). + + 2009-04-21 Simon Goldschmidt + * dns.c, init.c, dns.h, opt.h: task #7507, patch #6786: DNS supports static + hosts table. New configuration options DNS_LOCAL_HOSTLIST and + DNS_LOCAL_HOSTLIST_IS_DYNAMIC. Also, DNS_LOOKUP_LOCAL_EXTERN() can be defined + as an external function for lookup. + + 2009-04-15 Simon Goldschmidt + * dhcp.c: patch #6763: Global DHCP XID can be redefined to something more unique + + 2009-03-31 Kieran Mansley + * tcp.c, tcp_out.c, tcp_in.c, sys.h, tcp.h, opts.h: add support for + TCP timestamp options, off by default. Rework tcp_enqueue() to + take option flags rather than specified option data + + 2009-02-18 Simon Goldschmidt + * cc.h: Added printf formatter for size_t: SZT_F + + 2009-02-16 Simon Goldschmidt (patch by Rishi Khan) + * icmp.c, opt.h: patch #6539: (configurable) response to broadcast- and multicast + pings + + 2009-02-12 Simon Goldschmidt + * init.h: Added LWIP_VERSION to get the current version of the stack + + 2009-02-11 Simon Goldschmidt (suggested by Gottfried Spitaler) + * opt.h, memp.h/.c: added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead + of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc + is otherwise used) + + 2009-01-28 Jonathan Larmour (suggested by Bill Bauerbach) + * ipv4/inet_chksum.c, ipv4/lwip/inet_chksum.h: inet_chksum_pseudo_partial() + is only used by UDPLITE at present, so conditionalise it. + + 2008-12-03 Simon Goldschmidt (base on patch from Luca Ceresoli) + * autoip.c: checked in (slightly modified) patch #6683: Customizable AUTOIP + "seed" address. This should reduce AUTOIP conflicts if + LWIP_AUTOIP_CREATE_SEED_ADDR is overridden. + + 2008-10-02 Jonathan Larmour and Rishi Khan + * sockets.c (lwip_accept): Return EWOULDBLOCK if would block on non-blocking + socket. + + 2008-06-30 Simon Goldschmidt + * mem.c, opt.h, stats.h: fixed bug #21433: Calling mem_free/pbuf_free from + interrupt context isn't safe: LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT allows + mem_free to run between mem_malloc iterations. Added illegal counter for + mem stats. + + 2008-06-27 Simon Goldschmidt + * stats.h/.c, some other files: patch #6483: stats module improvement: + Added defines to display each module's statistic individually, added stats + defines for MEM, MEMP and SYS modules, removed (unused) rexmit counter. + + 2008-06-17 Simon Goldschmidt + * err.h: patch #6459: Made err_t overridable to use a more efficient type + (define LWIP_ERR_T in cc.h) + + 2008-06-17 Simon Goldschmidt + * slipif.c: patch #6480: Added a configuration option for slipif for symmetry + to loopif + + 2008-06-17 Simon Goldschmidt (patch by Luca Ceresoli) + * netif.c, loopif.c, ip.c, netif.h, loopif.h, opt.h: Checked in slightly + modified version of patch # 6370: Moved loopif code to netif.c so that + loopback traffic is supported on all netifs (all local IPs). + Added option to limit loopback packets for each netifs. + + + ++ Bugfixes: + 2009-08-12 Kieran Mansley + * tcp_in.c, tcp.c: Fix bug #27209: handle trimming of segments when + out of window or out of order properly + + 2009-08-12 Kieran Mansley + * tcp_in.c: Fix bug #27199: use snd_wl2 instead of snd_wl1 + + 2009-07-28 Simon Goldschmidt + * mem.h: Fixed bug #27105: "realloc() cannot replace mem_realloc()"s + + 2009-07-27 Kieran Mansley + * api.h api_msg.h netdb.h sockets.h: add missing #include directives + + 2009-07-09 Kieran Mansley + * api_msg.c, sockets.c, api.h: BUG23240 use signed counters for + recv_avail and don't increment counters until message successfully + sent to mbox + + 2009-06-25 Kieran Mansley + * api_msg.c api.h: BUG26722: initialise netconn write variables + in netconn_alloc + + 2009-06-25 Kieran Mansley + * tcp.h: BUG26879: set ret value in TCP_EVENT macros when function is not set + + 2009-06-25 Kieran Mansley + * tcp.c, tcp_in.c, tcp_out.c, tcp.h: BUG26301 and BUG26267: correct + simultaneous close behaviour, and make snd_nxt have the same meaning + as in the RFCs. + + 2009-05-12 Simon Goldschmidt + * etharp.h, etharp.c, netif.c: fixed bug #26507: "Gratuitous ARP depends on + arp_table / uses etharp_query" by adding etharp_gratuitous() + + 2009-05-12 Simon Goldschmidt + * ip.h, ip.c, igmp.c: bug #26487: Added ip_output_if_opt that can add IP options + to the IP header (used by igmp_ip_output_if) + + 2009-05-06 Simon Goldschmidt + * inet_chksum.c: On little endian architectures, use LWIP_PLATFORM_HTONS (if + defined) for SWAP_BYTES_IN_WORD to speed up checksumming. + + 2009-05-05 Simon Goldschmidt + * sockets.c: bug #26405: Prematurely released semaphore causes lwip_select() + to crash + + 2009-05-04 Simon Goldschmidt + * init.c: snmp was not initialized in lwip_init() + + 2009-05-04 Frédéric Bernon + * dhcp.c, netbios.c: Changes if IP_SOF_BROADCAST is enabled. + + 2009-05-03 Simon Goldschmidt + * tcp.h: bug #26349: Nagle algorithm doesn't send although segment is full + (and unsent->next == NULL) + + 2009-05-02 Simon Goldschmidt + * tcpip.h, tcpip.c: fixed tcpip_untimeout (does not need the time, broken after + 1.3.0 in CVS only) - fixes compilation of ppp_oe.c + + 2009-05-02 Simon Goldschmidt + * msg_in.c: fixed bug #25636: SNMPSET value is ignored for integer fields + + 2009-05-01 Simon Goldschmidt + * pap.c: bug #21680: PPP upap_rauthnak() drops legal NAK packets + + 2009-05-01 Simon Goldschmidt + * ppp.c: bug #24228: Memory corruption with PPP and DHCP + + 2009-04-29 Frédéric Bernon + * raw.c, udp.c, init.c, opt.h, ip.h, sockets.h: bug #26309: Implement the + SO(F)_BROADCAST filter for all API layers. Avoid the unindented reception + of broadcast packets even when this option wasn't set. Port maintainers + which want to enable this filter have to set IP_SOF_BROADCAST=1 in opt.h. + If you want this option also filter broadcast on recv operations, you also + have to set IP_SOF_BROADCAST_RECV=1 in opt.h. + + 2009-04-28 Simon Goldschmidt, Jakob Stoklund Olesen + * dhcp.c: patch #6721, bugs #25575, #25576: Some small fixes to DHCP and + DHCP/AUTOIP cooperation + + 2009-04-25 Simon Goldschmidt, Oleg Tyshev + * tcp_out.c: bug #24212: Deadlocked tcp_retransmit due to exceeded pcb->cwnd + Fixed by sorting the unsent and unacked queues (segments are inserted at the + right place in tcp_output and tcp_rexmit). + + 2009-04-25 Simon Goldschmidt + * memp.c, mem.c, memp.h, mem_std.h: bug #26213 "Problem with memory allocation + when debugging": memp_sizes contained the wrong sizes (including sanity + regions); memp pools for MEM_USE_POOLS were too small + + 2009-04-24 Simon Goldschmidt, Frédéric Bernon + * inet.c: patch #6765: Fix a small problem with the last changes (incorrect + behavior, with with ip address string not ended by a '\0', a space or a + end of line) + + 2009-04-19 Simon Goldschmidt + * rawapi.txt: Fixed bug #26069: Corrected documentation: if tcp_connect fails, + pcb->err is called, not pcb->connected (with an error code). + + 2009-04-19 Simon Goldschmidt + * tcp_out.c: Fixed bug #26236: "TCP options (timestamp) don't work with + no-copy-tcpwrite": deallocate option data, only concat segments with same flags + + 2009-04-19 Simon Goldschmidt + * tcp_out.c: Fixed bug #25094: "Zero-length pbuf" (options are now allocated + in the header pbuf, not the data pbuf) + + 2009-04-18 Simon Goldschmidt + * api_msg.c: fixed bug #25695: Segmentation fault in do_writemore() + + 2009-04-15 Simon Goldschmidt + * sockets.c: tried to fix bug #23559: lwip_recvfrom problem with tcp + + 2009-04-15 Simon Goldschmidt + * dhcp.c: task #9192: mem_free of dhcp->options_in and dhcp->msg_in + + 2009-04-15 Simon Goldschmidt + * ip.c, ip6.c, tcp_out.c, ip.h: patch #6808: Add a utility function + ip_hinted_output() (for smaller code mainly) + + 2009-04-15 Simon Goldschmidt + * inet.c: patch #6765: Supporting new line characters in inet_aton() + + 2009-04-15 Simon Goldschmidt + * dhcp.c: patch #6764: DHCP rebind and renew did not send hostnam option; + Converted constant OPTION_MAX_MSG_SIZE to netif->mtu, check if netif->mtu + is big enough in dhcp_start + + 2009-04-15 Simon Goldschmidt + * netbuf.c: bug #26027: netbuf_chain resulted in pbuf memory leak + + 2009-04-15 Simon Goldschmidt + * sockets.c, ppp.c: bug #25763: corrected 4 occurrences of SMEMCPY to MEMCPY + + 2009-04-15 Simon Goldschmidt + * sockets.c: bug #26121: set_errno can be overridden + + 2009-04-09 Kieran Mansley (patch from Luca Ceresoli ) + * init.c, opt.h: Patch#6774 TCP_QUEUE_OOSEQ breaks compilation when + LWIP_TCP==0 + + 2009-04-09 Kieran Mansley (patch from Roy Lee ) + * tcp.h: Patch#6802 Add do-while-clauses to those function like + macros in tcp.h + + 2009-03-31 Kieran Mansley + * tcp.c, tcp_in.c, tcp_out.c, tcp.h, opt.h: Rework the way window + updates are calculated and sent (BUG20515) + + * tcp_in.c: cope with SYN packets received during established states, + and retransmission of initial SYN. + + * tcp_out.c: set push bit correctly when tcp segments are merged + + 2009-03-27 Kieran Mansley + * tcp_out.c set window correctly on probes (correcting change made + yesterday) + + 2009-03-26 Kieran Mansley + * tcp.c, tcp_in.c, tcp.h: add tcp_abandon() to cope with dropping + connections where no reset required (bug #25622) + + * tcp_out.c: set TCP_ACK flag on keepalive and zero window probes + (bug #20779) + + 2009-02-18 Simon Goldschmidt (Jonathan Larmour and Bill Auerbach) + * ip_frag.c: patch #6528: the buffer used for IP_FRAG_USES_STATIC_BUF could be + too small depending on MEM_ALIGNMENT + + 2009-02-16 Simon Goldschmidt + * sockets.h/.c, api_*.h/.c: fixed arguments of socket functions to match the standard; + converted size argument of netconn_write to 'size_t' + + 2009-02-16 Simon Goldschmidt + * tcp.h, tcp.c: fixed bug #24440: TCP connection close problem on 64-bit host + by moving accept callback function pointer to TCP_PCB_COMMON + + 2009-02-12 Simon Goldschmidt + * dhcp.c: fixed bug #25345 (DHCPDECLINE is sent with "Maximum message size" + option) + + 2009-02-11 Simon Goldschmidt + * dhcp.c: fixed bug #24480 (releasing old udp_pdb and pbuf in dhcp_start) + + 2009-02-11 Simon Goldschmidt + * opt.h, api_msg.c: added configurable default valud for netconn->recv_bufsize: + RECV_BUFSIZE_DEFAULT (fixes bug #23726: pbuf pool exhaustion on slow recv()) + + 2009-02-10 Simon Goldschmidt + * tcp.c: fixed bug #25467: Listen backlog is not reset on timeout in SYN_RCVD: + Accepts_pending is decrease on a corresponding listen pcb when a connection + in state SYN_RCVD is close. + + 2009-01-28 Jonathan Larmour + * pbuf.c: reclaim pbufs from TCP out-of-sequence segments if we run + out of pool pbufs. + + 2008-12-19 Simon Goldschmidt + * many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2 + + 2008-12-10 Tamas Somogyi, Frédéric Bernon + * sockets.c: fixed bug #25051: lwip_recvfrom problem with udp: fromaddr and + port uses deleted netbuf. + + 2008-10-18 Simon Goldschmidt + * tcp_in.c: fixed bug ##24596: Vulnerability on faulty TCP options length + in tcp_parseopt + + 2008-10-15 Simon Goldschmidt + * ip_frag.c: fixed bug #24517: IP reassembly crashes on unaligned IP headers + by packing the struct ip_reass_helper. + + 2008-10-03 David Woodhouse, Jonathan Larmour + * etharp.c (etharp_arp_input): Fix type aliasing problem copying ip address. + + 2008-10-02 Jonathan Larmour + * dns.c: Hard-code structure sizes, to avoid issues on some compilers where + padding is included. + + 2008-09-30 Jonathan Larmour + * sockets.c (lwip_accept): check addr isn't NULL. If it's valid, do an + assertion check that addrlen isn't NULL. + + 2008-09-30 Jonathan Larmour + * tcp.c: Fix bug #24227, wrong error message in tcp_bind. + + 2008-08-26 Simon Goldschmidt + * inet.h, ip_addr.h: fixed bug #24132: Cross-dependency between ip_addr.h and + inet.h -> moved declaration of struct in_addr from ip_addr.h to inet.h + + 2008-08-14 Simon Goldschmidt + * api_msg.c: fixed bug #23847: do_close_internal references freed memory (when + tcp_close returns != ERR_OK) + + 2008-07-08 Frédéric Bernon + * stats.h: Fix some build bugs introduced with patch #6483 (missing some parameters + in macros, mainly if MEM_STATS=0 and MEMP_STATS=0). + + 2008-06-24 Jonathan Larmour + * tcp_in.c: Fix for bug #23693 as suggested by Art R. Ensure cseg is unused + if tcp_seg_copy fails. + + 2008-06-17 Simon Goldschmidt + * inet_chksum.c: Checked in some ideas of patch #6460 (loop optimizations) + and created defines for swapping bytes and folding u32 to u16. + + 2008-05-30 Kieran Mansley + * tcp_in.c Remove redundant "if" statement, and use real rcv_wnd + rather than rcv_ann_wnd when deciding if packets are in-window. + Contributed by + + 2008-05-30 Kieran Mansley + * mem.h: Fix BUG#23254. Change macro definition of mem_* to allow + passing as function pointers when MEM_LIBC_MALLOC is defined. + + 2008-05-09 Jonathan Larmour + * err.h, err.c, sockets.c: Fix bug #23119: Reorder timeout error code to + stop it being treated as a fatal error. + + 2008-04-15 Simon Goldschmidt + * dhcp.c: fixed bug #22804: dhcp_stop doesn't clear NETIF_FLAG_DHCP + (flag now cleared) + + 2008-03-27 Simon Goldschmidt + * mem.c, tcpip.c, tcpip.h, opt.h: fixed bug #21433 (Calling mem_free/pbuf_free + from interrupt context isn't safe): set LWIP_USE_HEAP_FROM_INTERRUPT to 1 + in lwipopts.h or use pbuf_free_callback(p)/mem_free_callback(m) to free pbufs + or heap memory from interrupt context + + 2008-03-26 Simon Goldschmidt + * tcp_in.c, tcp.c: fixed bug #22249: division by zero could occur if a remote + host sent a zero mss as TCP option. + + +(STABLE-1.3.0) + + ++ New features: + + 2008-03-10 Jonathan Larmour + * inet_chksum.c: Allow choice of one of the sample algorithms to be + made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM. + + 2008-01-22 Frédéric Bernon + * tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in + TCP_CALCULATE_EFF_SEND_MSS to have coherent TCP options names. + + 2008-01-14 Frédéric Bernon + * rawapi.txt, api_msg.c, tcp.c, tcp_in.c, tcp.h: changes for task #7675 "Enable + to refuse data on a TCP_EVENT_RECV call". Important, behavior changes for the + tcp_recv callback (see rawapi.txt). + + 2008-01-14 Frédéric Bernon, Marc Chaland + * ip.c: Integrate patch #6369" ip_input : checking before realloc". + + 2008-01-12 Frédéric Bernon + * tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field + netconn::sem per netconn::op_completed like suggested for the task #7490 + "Add return value to sys_mbox_post". + + 2008-01-12 Frédéric Bernon + * api_msg.c, opt.h: replace DEFAULT_RECVMBOX_SIZE per DEFAULT_TCP_RECVMBOX_SIZE, + DEFAULT_UDP_RECVMBOX_SIZE and DEFAULT_RAW_RECVMBOX_SIZE (to optimize queues + sizes), like suggested for the task #7490 "Add return value to sys_mbox_post". + + 2008-01-10 Frédéric Bernon + * tcpip.h, tcpip.c: add tcpip_callback_with_block function for the task #7490 + "Add return value to sys_mbox_post". tcpip_callback is always defined as + "blocking" ("block" parameter = 1). + + 2008-01-10 Frédéric Bernon + * tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field + netconn::mbox (sys_mbox_t) per netconn::sem (sys_sem_t) for the task #7490 + "Add return value to sys_mbox_post". + + 2008-01-05 Frédéric Bernon + * sys_arch.txt, api.h, api_lib.c, api_msg.h, api_msg.c, tcpip.c, sys.h, opt.h: + Introduce changes for task #7490 "Add return value to sys_mbox_post" with some + modifications in the sys_mbox api: sys_mbox_new take a "size" parameters which + indicate the number of pointers query by the mailbox. There is three defines + in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the + netconn::acceptmbox. Port maintainers, you can decide to just add this new + parameter in your implementation, but to ignore it to keep the previous behavior. + The new sys_mbox_trypost function return a value to know if the mailbox is + full or if the message is posted. Take a look to sys_arch.txt for more details. + This new function is used in tcpip_input (so, can be called in an interrupt + context since the function is not blocking), and in recv_udp and recv_raw. + + 2008-01-04 Frédéric Bernon, Simon Goldschmidt, Jonathan Larmour + * rawapi.txt, api.h, api_lib.c, api_msg.h, api_msg.c, sockets.c, tcp.h, tcp.c, + tcp_in.c, init.c, opt.h: rename backlog options with TCP_ prefix, limit the + "backlog" parameter in an u8_t, 0 is interpreted as "smallest queue", add + documentation in the rawapi.txt file. + + 2007-12-31 Kieran Mansley (based on patch from Per-Henrik Lundbolm) + * tcp.c, tcp_in.c, tcp_out.c, tcp.h: Add TCP persist timer + + 2007-12-31 Frédéric Bernon, Luca Ceresoli + * autoip.c, etharp.c: ip_addr.h: Integrate patch #6348: "Broadcast ARP packets + in autoip". The change in etharp_raw could be removed, since all calls to + etharp_raw use ethbroadcast for the "ethdst_addr" parameter. But it could be + wrong in the future. + + 2007-12-30 Frédéric Bernon, Tom Evans + * ip.c: Fix bug #21846 "LwIP doesn't appear to perform any IP Source Address + Filtering" reported by Tom Evans. + + 2007-12-21 Frédéric Bernon, Simon Goldschmidt, Jonathan Larmour + * tcp.h, opt.h, api.h, api_msg.h, tcp.c, tcp_in.c, api_lib.c, api_msg.c, + sockets.c, init.c: task #7252: Implement TCP listen backlog: Warning: raw API + applications have to call 'tcp_accepted(pcb)' in their accept callback to + keep accepting new connections. + + 2007-12-13 Frédéric Bernon + * api_msg.c, err.h, err.c, sockets.c, dns.c, dns.h: replace "enum dns_result" + by err_t type. Add a new err_t code "ERR_INPROGRESS". + + 2007-12-12 Frédéric Bernon + * dns.h, dns.c, opt.h: move DNS options to the "right" place. Most visibles + are the one which have ram usage. + + 2007-12-05 Frédéric Bernon + * netdb.c: add a LWIP_DNS_API_HOSTENT_STORAGE option to decide to use a static + set of variables (=0) or a local one (=1). In this last case, your port should + provide a function "struct hostent* sys_thread_hostent( struct hostent* h)" + which have to do a copy of "h" and return a pointer ont the "per-thread" copy. + + 2007-12-03 Simon Goldschmidt + * ip.c: ip_input: check if a packet is for inp first before checking all other + netifs on netif_list (speeds up packet receiving in most cases) + + 2007-11-30 Simon Goldschmidt + * udp.c, raw.c: task #7497: Sort lists (pcb, netif, ...) for faster access + UDP: move a (connected) pcb selected for input to the front of the list of + pcbs so that it is found faster next time. Same for RAW pcbs that have eaten + a packet. + + 2007-11-28 Simon Goldschmidt + * etharp.c, stats.c, stats.h, opt.h: Introduced ETHARP_STATS + + 2007-11-25 Simon Goldschmidt + * dhcp.c: dhcp_unfold_reply() uses pbuf_copy_partial instead of its own copy + algorithm. + + 2007-11-24 Simon Goldschmidt + * netdb.h, netdb.c, sockets.h/.c: Moved lwip_gethostbyname from sockets.c + to the new file netdb.c; included lwip_getaddrinfo. + + 2007-11-21 Simon Goldschmidt + * tcp.h, opt.h, tcp.c, tcp_in.c: implemented calculating the effective send-mss + based on the MTU of the netif used to send. Enabled by default. Disable by + setting LWIP_CALCULATE_EFF_SEND_MSS to 0. This fixes bug #21492. + + 2007-11-19 Frédéric Bernon + * api_msg.c, dns.h, dns.c: Implement DNS_DOES_NAME_CHECK option (check if name + received match the name query), implement DNS_USES_STATIC_BUF (the place where + copy dns payload to parse the response), return an error if there is no place + for a new query, and fix some minor problems. + + 2007-11-16 Simon Goldschmidt + * new files: ipv4/inet.c, ipv4/inet_chksum.c, ipv6/inet6.c + removed files: core/inet.c, core/inet6.c + Moved inet files into ipv4/ipv6 directory; splitted inet.c/inet.h into + inet and chksum part; changed includes in all lwIP files as appropriate + + 2007-11-16 Simon Goldschmidt + * api.h, api_msg.h, api_lib.c, api_msg.c, socket.h, socket.c: Added sequential + dns resolver function for netconn api (netconn_gethostbyname) and socket api + (gethostbyname/gethostbyname_r). + + 2007-11-15 Jim Pettinato, Frédéric Bernon + * opt.h, init.c, tcpip.c, dhcp.c, dns.h, dns.c: add DNS client for simple name + requests with RAW api interface. Initialization is done in lwip_init() with + build time options. DNS timer is added in tcpip_thread context. DHCP can set + DNS server ip addresses when options are received. You need to set LWIP_DNS=1 + in your lwipopts.h file (LWIP_DNS=0 in opt.h). DNS_DEBUG can be set to get + some traces with LWIP_DEBUGF. Sanity check have been added. There is a "todo" + list with points to improve. + + 2007-11-06 Simon Goldschmidt + * opt.h, mib2.c: Patch #6215: added ifAdminStatus write support (if explicitly + enabled by defining SNMP_SAFE_REQUESTS to 0); added code to check link status + for ifOperStatus if LWIP_NETIF_LINK_CALLBACK is defined. + + 2007-11-06 Simon Goldschmidt + * api.h, api_msg.h and dependent files: Task #7410: Removed the need to include + core header files in api.h (ip/tcp/udp/raw.h) to hide the internal + implementation from netconn api applications. + + 2007-11-03 Frédéric Bernon + * api.h, api_lib.c, api_msg.c, sockets.c, opt.h: add SO_RCVBUF option for UDP & + RAW netconn. You need to set LWIP_SO_RCVBUF=1 in your lwipopts.h (it's disabled + by default). Netconn API users can use the netconn_recv_bufsize macro to access + it. This is a first release which have to be improve for TCP. Note it used the + netconn::recv_avail which need to be more "thread-safe" (note there is already + the problem for FIONREAD with lwip_ioctl/ioctlsocket). + + 2007-11-01 Frédéric Bernon, Marc Chaland + * sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, tcp.h, tcp_out.c: + Integrate "patch #6250 : MSG_MORE flag for send". MSG_MORE is used at socket api + layer, NETCONN_MORE at netconn api layer, and TCP_WRITE_FLAG_MORE at raw api + layer. This option enable to delayed TCP PUSH flag on multiple "write" calls. + Note that previous "copy" parameter for "write" APIs is now called "apiflags". + + 2007-10-24 Frédéric Bernon + * api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than + TCP_EVENT_xxx macros to get a code more readable. It could also help to remove + some code (like we have talk in "patch #5919 : Create compile switch to remove + select code"), but it could be done later. + + 2007-10-08 Simon Goldschmidt + * many files: Changed initialization: many init functions are not needed any + more since we now rely on the compiler initializing global and static + variables to zero! + + 2007-10-06 Simon Goldschmidt + * ip_frag.c, memp.c, mib2.c, ip_frag.h, memp_std.h, opt.h: Changed IP_REASSEMBLY + to enqueue the received pbufs so that multiple packets can be reassembled + simultaneously and no static reassembly buffer is needed. + + 2007-10-05 Simon Goldschmidt + * tcpip.c, etharp.h, etharp.c: moved ethernet_input from tcpip.c to etharp.c so + all netifs (or ports) can use it. + + 2007-10-05 Frédéric Bernon + * netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the + common function to reduce a little bit the footprint (for all functions using + only the "netif" parameter). + + 2007-10-03 Frédéric Bernon + * netifapi.h, netifapi.c: add functions netifapi_netif_set_up, netifapi_netif_set_down, + netifapi_autoip_start and netifapi_autoip_stop. Use a common function to reduce + a little bit the footprint (for all functions using only the "netif" parameter). + + 2007-09-15 Frédéric Bernon + * udp.h, udp.c, sockets.c: Changes for "#20503 IGMP Improvement". Add IP_MULTICAST_IF + option in socket API, and a new field "multicast_ip" in "struct udp_pcb" (for + netconn and raw API users), only if LWIP_IGMP=1. Add getsockopt processing for + IP_MULTICAST_TTL and IP_MULTICAST_IF. + + 2007-09-10 Frédéric Bernon + * snmp.h, mib2.c: enable to remove SNMP timer (which consumne several cycles + even when it's not necessary). snmp_agent.txt tell to call snmp_inc_sysuptime() + each 10ms (but, it's intrusive if you use sys_timeout feature). Now, you can + decide to call snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but + call to a lower frequency). Or, you can decide to not call snmp_inc_sysuptime() + or snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro. + This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside + snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only + when it's queried (any direct call to "sysuptime" is changed by a call to + snmp_get_sysuptime). + + 2007-09-09 Frédéric Bernon, Bill Florac + * igmp.h, igmp.c, netif.h, netif.c, ip.c: To enable to have interfaces with IGMP, + and others without it, there is a new NETIF_FLAG_IGMP flag to set in netif->flags + if you want IGMP on an interface. igmp_stop() is now called inside netif_remove(). + igmp_report_groups() is now called inside netif_set_link_up() (need to have + LWIP_NETIF_LINK_CALLBACK=1) to resend reports once the link is up (avoid to wait + the next query message to receive the matching multicast streams). + + 2007-09-08 Frédéric Bernon + * sockets.c, ip.h, api.h, tcp.h: declare a "struct ip_pcb" which only contains + IP_PCB. Add in the netconn's "pcb" union a "struct ip_pcb *ip;" (no size change). + Use this new field to access to common pcb fields (ttl, tos, so_options, etc...). + Enable to access to these fields with LWIP_TCP=0. + + 2007-09-05 Frédéric Bernon + * udp.c, ipv4/icmp.c, ipv4/ip.c, ipv6/icmp.c, ipv6/ip6.c, ipv4/icmp.h, + ipv6/icmp.h, opt.h: Integrate "task #7272 : LWIP_ICMP option". The new option + LWIP_ICMP enable/disable ICMP module inside the IP stack (enable per default). + Be careful, disabling ICMP make your product non-compliant to RFC1122, but + help to reduce footprint, and to reduce "visibility" on the Internet. + + 2007-09-05 Frédéric Bernon, Bill Florac + * opt.h, sys.h, tcpip.c, slipif.c, ppp.c, sys_arch.txt: Change parameters list + for sys_thread_new (see "task #7252 : Create sys_thread_new_ex()"). Two new + parameters have to be provided: a task name, and a task stack size. For this + one, since it's platform dependant, you could define the best one for you in + your lwipopts.h. For port maintainers, you can just add these new parameters + in your sys_arch.c file, and but it's not mandatory, use them in your OS + specific functions. + + 2007-09-05 Frédéric Bernon + * inet.c, autoip.c, msg_in.c, msg_out.c, init.c: Move some build time checkings + inside init.c for task #7142 "Sanity check user-configurable values". + + 2007-09-04 Frédéric Bernon, Bill Florac + * igmp.h, igmp.c, memp_std.h, memp.c, init.c, opt.h: Replace mem_malloc call by + memp_malloc, and use a new MEMP_NUM_IGMP_GROUP option (see opt.h to define the + value). It will avoid potential fragmentation problems, use a counter to know + how many times a group is used on an netif, and free it when all applications + leave it. MEMP_NUM_IGMP_GROUP got 8 as default value (and init.c got a sanity + check if LWIP_IGMP!=0). + + 2007-09-03 Frédéric Bernon + * igmp.h, igmp.c, sockets.c, api_msg.c: Changes for "#20503 IGMP Improvement". + Initialize igmp_mac_filter to NULL in netif_add (this field should be set in + the netif's "init" function). Use the "imr_interface" field (for socket layer) + and/or the "interface" field (for netconn layer), for join/leave operations. + The igmp_join/leavegroup first parameter change from a netif to an ipaddr. + This field could be a netif's ipaddr, or "any" (same meaning than ip_addr_isany). + + 2007-08-30 Frédéric Bernon + * Add netbuf.h, netbuf.c, Change api.h, api_lib.c: #7249 "Split netbuf functions + from api/api_lib". Now netbuf API is independant of netconn, and can be used + with other API (application based on raw API, or future "socket2" API). Ports + maintainers just have to add src/api/netbuf.c in their makefile/projects. + + 2007-08-30 Frédéric Bernon, Jonathan Larmour + * init.c: Add first version of lwip_sanity_check for task #7142 "Sanity check + user-configurable values". + + 2007-08-29 Frédéric Bernon + * igmp.h, igmp.c, tcpip.c, init.c, netif.c: change igmp_init and add igmp_start. + igmp_start is call inside netif_add. Now, igmp initialization is in the same + spirit than the others modules. Modify some IGMP debug traces. + + 2007-08-29 Frédéric Bernon + * Add init.h, init.c, Change opt.h, tcpip.c: Task #7213 "Add a lwip_init function" + Add lwip_init function to regroup all modules initializations, and to provide + a place to add code for task #7142 "Sanity check user-configurable values". + Ports maintainers should remove direct initializations calls from their code, + and add init.c in their makefiles. Note that lwip_init() function is called + inside tcpip_init, but can also be used by raw api users since all calls are + disabled when matching options are disabled. Also note that their is new options + in opt.h, you should configure in your lwipopts.h (they are enabled per default). + + 2007-08-26 Marc Boucher + * api_msg.c: do_close_internal(): Reset the callbacks and arg (conn) to NULL + since they can under certain circumstances be called with an invalid conn + pointer after the connection has been closed (and conn has been freed). + + 2007-08-25 Frédéric Bernon (Artem Migaev's Patch) + * netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up". + Add a netif_is_link_up() function if LWIP_NETIF_LINK_CALLBACK option is set. + + 2007-08-22 Frédéric Bernon + * netif.h, netif.c, opt.h: Rename LWIP_NETIF_CALLBACK in LWIP_NETIF_STATUS_CALLBACK + to be coherent with new LWIP_NETIF_LINK_CALLBACK option before next release. + + 2007-08-22 Frédéric Bernon + * tcpip.h, tcpip.c, ethernetif.c, opt.h: remove options ETHARP_TCPIP_INPUT & + ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the + name is tcpip_input (we keep the name of 1.2.0 function). + + 2007-08-17 Jared Grubb + * memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool + settings into new memp_std.h and optional user file lwippools.h. This adds + more dynamic mempools, and allows the user to create an arbitrary number of + mempools for mem_malloc. + + 2007-08-16 Marc Boucher + * api_msg.c: Initialize newconn->state to NETCONN_NONE in accept_function; + otherwise it was left to NETCONN_CLOSE and sent_tcp() could prematurely + close the connection. + + 2007-08-16 Marc Boucher + * sockets.c: lwip_accept(): check netconn_peer() error return. + + 2007-08-16 Marc Boucher + * mem.c, mem.h: Added mem_calloc(). + + 2007-08-16 Marc Boucher + * tcpip.c, tcpip.h memp.c, memp.h: Added distinct memp (MEMP_TCPIP_MSG_INPKT) + for input packets to prevent floods from consuming all of MEMP_TCPIP_MSG + and starving other message types. + Renamed MEMP_TCPIP_MSG to MEMP_TCPIP_MSG_API + + 2007-08-16 Marc Boucher + * pbuf.c, pbuf.h, etharp.c, tcp_in.c, sockets.c: Split pbuf flags in pbuf + type and flgs (later renamed to flags). + Use enum pbuf_flag as pbuf_type. Renumber PBUF_FLAG_*. + Improved lwip_recvfrom(). TCP push now propagated. + + 2007-08-16 Marc Boucher + * ethernetif.c, contrib/ports/various: ethbroadcast now a shared global + provided by etharp. + + 2007-08-16 Marc Boucher + * ppp_oe.c ppp_oe.h, auth.c chap.c fsm.c lcp.c ppp.c ppp.h, + etharp.c ethernetif.c, etharp.h, opt.h tcpip.h, tcpip.c: + Added PPPoE support and various PPP improvements. + + 2007-07-25 Simon Goldschmidt + * api_lib.c, ip_frag.c, pbuf.c, api.h, pbuf.h: Introduced pbuf_copy_partial, + making netbuf_copy_partial use this function. + + 2007-07-25 Simon Goldschmidt + * tcp_in.c: Fix bug #20506: Slow start / initial congestion window starts with + 2 * mss (instead of 1 * mss previously) to comply with some newer RFCs and + other stacks. + + 2007-07-13 Jared Grubb (integrated by Frédéric Bernon) + * opt.h, netif.h, netif.c, ethernetif.c: Add new configuration option to add + a link callback in the netif struct, and functions to handle it. Be carefull + for port maintainers to add the NETIF_FLAG_LINK_UP flag (like in ethernetif.c) + if you want to be sure to be compatible with future changes... + + 2007-06-30 Frédéric Bernon + * sockets.h, sockets.c: Implement MSG_PEEK flag for recv/recvfrom functions. + + 2007-06-21 Simon Goldschmidt + * etharp.h, etharp.c: Combined etharp_request with etharp_raw for both + LWIP_AUTOIP =0 and =1 to remove redundant code. + + 2007-06-21 Simon Goldschmidt + * mem.c, memp.c, mem.h, memp.h, opt.h: task #6863: Introduced the option + MEM_USE_POOLS to use 4 pools with different sized elements instead of a + heap. This both prevents memory fragmentation and gives a higher speed + at the cost of more memory consumption. Turned off by default. + + 2007-06-21 Simon Goldschmidt + * api_lib.c, api_msg.c, api.h, api_msg.h: Converted the length argument of + netconn_write (and therefore also api_msg_msg.msg.w.len) from u16_t into + int to be able to send a bigger buffer than 64K with one time (mainly + used from lwip_send). + + 2007-06-21 Simon Goldschmidt + * tcp.h, api_msg.c: Moved the nagle algorithm from netconn_write/do_write + into a define (tcp_output_nagle) in tcp.h to provide it to raw api users, too. + + 2007-06-21 Simon Goldschmidt + * api.h, api_lib.c, api_msg.c: Fixed bug #20021: Moved sendbuf-processing in + netconn_write from api_lib.c to api_msg.c to also prevent multiple context- + changes on low memory or empty send-buffer. + + 2007-06-18 Simon Goldschmidt + * etharp.c, etharp.h: Changed etharp to use a defined hardware address length + of 6 to avoid loading netif->hwaddr_len every time (since this file is only + used for ethernet and struct eth_addr already had a defined length of 6). + + 2007-06-17 Simon Goldschmidt + * sockets.c, sockets.h: Implemented socket options SO_NO_CHECK for UDP sockets + to disable UDP checksum generation on transmit. + + 2007-06-13 Frédéric Bernon, Simon Goldschmidt + * debug.h, api_msg.c: change LWIP_ERROR to use it to check errors like invalid + pointers or parameters, and let the possibility to redefined it in cc.h. Use + this macro to check "conn" parameter in api_msg.c functions. + + 2007-06-11 Simon Goldschmidt + * sockets.c, sockets.h: Added UDP lite support for sockets + + 2007-06-10 Simon Goldschmidt + * udp.h, opt.h, api_msg.c, ip.c, udp.c: Included switch LWIP_UDPLITE (enabled + by default) to switch off UDP-Lite support if not needed (reduces udp.c code + size) + + 2007-06-09 Dominik Spies (integrated by Frédéric Bernon) + * autoip.h, autoip.c, dhcp.h, dhcp.c, netif.h, netif.c, etharp.h, etharp.c, opt.h: + AutoIP implementation available for IPv4, with new options LWIP_AUTOIP and + LWIP_DHCP_AUTOIP_COOP if you want to cooperate with DHCP. Some tips to adapt + (see TODO mark in the source code). + + 2007-06-09 Simon Goldschmidt + * etharp.h, etharp.c, ethernetif.c: Modified order of parameters for + etharp_output() to match netif->output so etharp_output() can be used + directly as netif->output to save one function call. + + 2007-06-08 Simon Goldschmidt + * netif.h, ethernetif.c, slipif.c, loopif.c: Added define + NETIF_INIT_SNMP(netif, type, speed) to initialize per-netif snmp variables, + added initialization of those to ethernetif, slipif and loopif. + + 2007-05-18 Simon Goldschmidt + * opt.h, ip_frag.c, ip_frag.h, ip.c: Added option IP_FRAG_USES_STATIC_BUF + (defaulting to off for now) that can be set to 0 to send fragmented + packets by passing PBUF_REFs down the stack. + + 2007-05-23 Frédéric Bernon + * api_lib.c: Implement SO_RCVTIMEO for accept and recv on TCP + connections, such present in patch #5959. + + 2007-05-23 Frédéric Bernon + * api.h, api_lib.c, api_msg.c, sockets.c: group the different NETCONN_UDPxxx + code in only one part... + + 2007-05-18 Simon Goldschmidt + * opt.h, memp.h, memp.c: Added option MEMP_OVERFLOW_CHECK to check for memp + elements to overflow. This is achieved by adding some bytes before and after + each pool element (increasing their size, of course), filling them with a + prominent value and checking them on freeing the element. + Set it to 2 to also check every element in every pool each time memp_malloc() + or memp_free() is called (slower but more helpful). + + 2007-05-10 Simon Goldschmidt + * opt.h, memp.h, memp.c, pbuf.c (see task #6831): use a new memp pool for + PBUF_POOL pbufs instead of the old pool implementation in pbuf.c to reduce + code size. + + 2007-05-11 Frédéric Bernon + * sockets.c, api_lib.c, api_msg.h, api_msg.c, netifapi.h, netifapi.c, tcpip.c: + Include a function pointer instead of a table index in the message to reduce + footprint. Disable some part of lwip_send and lwip_sendto if some options are + not set (LWIP_TCP, LWIP_UDP, LWIP_RAW). + + 2007-05-10 Simon Goldschmidt + * *.h (except netif/ppp/*.h): Included patch #5448: include '#ifdef __cplusplus + \ extern "C" {' in all header files. Now you can write your application using + the lwIP stack in C++ and simply #include the core files. Note I have left + out the netif/ppp/*h header files for now, since I don't know which files are + included by applications and which are for internal use only. + + 2007-05-09 Simon Goldschmidt + * opt.h, *.c/*.h: Included patch #5920: Create define to override C-library + memcpy. 2 Defines are created: MEMCPY() for normal memcpy, SMEMCPY() for + situations where some compilers might inline the copy and save a function + call. Also replaced all calls to memcpy() with calls to (S)MEMCPY(). + + 2007-05-08 Simon Goldschmidt + * mem.h: If MEM_LIBC_MALLOC==1, allow the defines (e.g. mem_malloc() -> malloc()) + to be overriden in case the C-library malloc implementation is not protected + against concurrent access. + + 2007-05-04 Simon Goldschmidt (Atte Kojo) + * etharp.c: Introduced fast one-entry-cache to speed up ARP lookup when sending + multiple packets to the same host. + + 2007-05-04 Frédéric Bernon, Jonathan Larmour + * sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fix bug #19162 "lwip_sento: a possible + to corrupt remote addr/port connection state". Reduce problems "not enought memory" with + netbuf (if we receive lot of datagrams). Improve lwip_sendto (only one exchange between + sockets api and api_msg which run in tcpip_thread context). Add netconn_sento function. + Warning, if you directly access to "fromaddr" & "fromport" field from netbuf struct, + these fields are now renamed "addr" & "port". + + 2007-04-11 Jonathan Larmour + * sys.h, api_lib.c: Provide new sys_mbox_tryfetch function. Require ports to provide new + sys_arch_mbox_tryfetch function to get a message if one is there, otherwise return + with SYS_MBOX_EMPTY. sys_arch_mbox_tryfetch can be implemented as a function-like macro + by the port in sys_arch.h if desired. + + 2007-04-06 Frédéric Bernon, Simon Goldschmidt + * opt.h, tcpip.h, tcpip.c, netifapi.h, netifapi.c: New configuration option LWIP_NETIF_API + allow to use thread-safe functions to add/remove netif in list, and to start/stop dhcp + clients, using new functions from netifapi.h. Disable as default (no port change to do). + + 2007-04-05 Frédéric Bernon + * sockets.c: remplace ENOBUFS errors on alloc_socket by ENFILE to be more BSD compliant. + + 2007-04-04 Simon Goldschmidt + * arch.h, api_msg.c, dhcp.c, msg_in.c, sockets.c: Introduced #define LWIP_UNUSED_ARG(x) + use this for and architecture-independent form to tell the compiler you intentionally + are not using this variable. Can be overriden in cc.h. + + 2007-03-28 Frédéric Bernon + * opt.h, netif.h, dhcp.h, dhcp.c: New configuration option LWIP_NETIF_HOSTNAME allow to + define a hostname in netif struct (this is just a pointer, so, you can use a hardcoded + string, point on one of your's ethernetif field, or alloc a string you will free yourself). + It will be used by DHCP to register a client hostname, but can also be use when you call + snmp_set_sysname. + + 2007-03-28 Frédéric Bernon + * netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to + initialize a network interface's flag with. It tell this interface is an ethernet + device, and we can use ARP with it to do a "gratuitous ARP" (RFC 3220 "IP Mobility + Support for IPv4" section 4.6) when interface is "up" with netif_set_up(). + + 2007-03-26 Frédéric Bernon, Jonathan Larmour + * opt.h, tcpip.c: New configuration option LWIP_ARP allow to disable ARP init at build + time if you only use PPP or SLIP. The default is enable. Note we don't have to call + etharp_init in your port's initilization sequence if you use tcpip.c, because this call + is done in tcpip_init function. + + 2007-03-22 Frédéric Bernon + * stats.h, stats.c, msg_in.c: Stats counters can be change to u32_t if necessary with the + new option LWIP_STATS_LARGE. If you need this option, define LWIP_STATS_LARGE to 1 in + your lwipopts.h. More, unused counters are not defined in the stats structs, and not + display by stats_display(). Note that some options (SYS_STATS and RAW_STATS) are defined + but never used. Fix msg_in.c with the correct #if test for a stat display. + + 2007-03-21 Kieran Mansley + * netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com). + Provides callback on netif up/down state change. + + 2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds + * sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c, + ip.c, netif.h, tcpip.c, opt.h: + New configuration option LWIP_IGMP to enable IGMP processing. Based on only one + filter per all network interfaces. Declare a new function in netif to enable to + control the MAC filter (to reduce lwIP traffic processing). + + 2007-03-11 Frédéric Bernon + * tcp.h, tcp.c, sockets.c, tcp_out.c, tcp_in.c, opt.h: Keepalive values can + be configured at run time with LWIP_TCP_KEEPALIVE, but don't change this + unless you know what you're doing (default are RFC1122 compliant). Note + that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set in seconds. + + 2007-03-08 Frédéric Bernon + * tcp.h: Keepalive values can be configured at compile time, but don't change + this unless you know what you're doing (default are RFC1122 compliant). + + 2007-03-08 Frédéric Bernon + * sockets.c, api.h, api_lib.c, tcpip.c, sys.h, sys.c, err.c, opt.h: + Implement LWIP_SO_RCVTIMEO configuration option to enable/disable SO_RCVTIMEO + on UDP sockets/netconn. + + 2007-03-08 Simon Goldschmidt + * snmp_msg.h, msg_in.c: SNMP UDP ports can be configured at compile time. + + 2007-03-06 Frédéric Bernon + * api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h: + Implement SO_RCVTIMEO on UDP sockets/netconn. + + 2007-02-28 Kieran Mansley (based on patch from Simon Goldschmidt) + * api_lib.c, tcpip.c, memp.c, memp.h: make API msg structs allocated + on the stack and remove the API msg type from memp + + 2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt) + * sockets.h, sockets.c: Move socket initialization to new + lwip_socket_init() function. + NOTE: this changes the API with ports. Ports will have to be + updated to call lwip_socket_init() now. + + 2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt) + * api_lib.c: Use memcpy in netbuf_copy_partial. + + + ++ Bug fixes: + + 2008-03-17 Frédéric Bernon, Ed Kerekes + * igmp.h, igmp.c: Fix bug #22613 "IGMP iphdr problem" (could have + some problems to fill the IP header on some targets, use now the + ip.h macros to do it). + + 2008-03-13 Frédéric Bernon + * sockets.c: Fix bug #22435 "lwip_recvfrom with TCP break;". Using + (lwip_)recvfrom with valid "from" and "fromlen" parameters, on a + TCP connection caused a crash. Note that using (lwip_)recvfrom + like this is a bit slow and that using (lwip)getpeername is the + good lwip way to do it (so, using recv is faster on tcp sockets). + + 2008-03-12 Frédéric Bernon, Jonathan Larmour + * api_msg.c, contrib/apps/ping.c: Fix bug #22530 "api_msg.c's + recv_raw() does not consume data", and the ping sample (with + LWIP_SOCKET=1, the code did the wrong supposition that lwip_recvfrom + returned the IP payload, without the IP header). + + 2008-03-04 Jonathan Larmour + * mem.c, stats.c, mem.h: apply patch #6414 to avoid compiler errors + and/or warnings on some systems where mem_size_t and size_t differ. + * pbuf.c, ppp.c: Fix warnings on some systems with mem_malloc. + + 2008-03-04 Kieran Mansley (contributions by others) + * Numerous small compiler error/warning fixes from contributions to + mailing list after 1.3.0 release candidate made. + + 2008-01-25 Cui hengbin (integrated by Frédéric Bernon) + * dns.c: Fix bug #22108 "DNS problem" caused by unaligned structures. + + 2008-01-15 Kieran Mansley + * tcp_out.c: BUG20511. Modify persist timer to start when we are + prevented from sending by a small send window, not just a zero + send window. + + 2008-01-09 Jonathan Larmour + * opt.h, ip.c: Rename IP_OPTIONS define to IP_OPTIONS_ALLOWED to avoid + conflict with Linux system headers. + + 2008-01-06 Jonathan Larmour + * dhcp.c: fix bug #19927: "DHCP NACK problem" by clearing any existing set IP + address entirely on receiving a DHCPNAK, and restarting discovery. + + 2007-12-21 Simon Goldschmidt + * sys.h, api_lib.c, api_msg.c, sockets.c: fix bug #21698: "netconn->recv_avail + is not protected" by using new macros for interlocked access to modify/test + netconn->recv_avail. + + 2007-12-20 Kieran Mansley (based on patch from Oleg Tyshev) + * tcp_in.c: fix bug# 21535 (nrtx not reset correctly in SYN_SENT state) + + 2007-12-20 Kieran Mansley (based on patch from Per-Henrik Lundbolm) + * tcp.c, tcp_in.c, tcp_out.c, tcp.h: fix bug #20199 (better handling + of silly window avoidance and prevent lwIP from shrinking the window) + + 2007-12-04 Simon Goldschmidt + * tcp.c, tcp_in.c: fix bug #21699 (segment leak in ooseq processing when last + data packet was lost): add assert that all segment lists are empty in + tcp_pcb_remove before setting pcb to CLOSED state; don't directly set CLOSED + state from LAST_ACK in tcp_process + + 2007-12-02 Simon Goldschmidt + * sockets.h: fix bug #21654: exclude definition of struct timeval from #ifndef FD_SET + If including for system-struct timeval, LWIP_TIMEVAL_PRIVATE now + has to be set to 0 in lwipopts.h + + 2007-12-02 Simon Goldschmidt + * api_msg.c, api_lib.c: fix bug #21656 (recvmbox problem in netconn API): always + allocate a recvmbox in netconn_new_with_proto_and_callback. For a tcp-listen + netconn, this recvmbox is later freed and a new mbox is allocated for acceptmbox. + This is a fix for thread-safety and allocates all items needed for a netconn + when the netconn is created. + + 2007-11-30 Simon Goldschmidt + * udp.c: first attempt to fix bug #21655 (DHCP doesn't work reliably with multiple + netifs): if LWIP_DHCP is enabled, UDP packets to DHCP_CLIENT_PORT are passed + to netif->dhcp->pcb only (if that exists) and not to any other pcb for the same + port (only solution to let UDP pcbs 'bind' to a netif instead of an IP address) + + 2007-11-27 Simon Goldschmidt + * ip.c: fixed bug #21643 (udp_send/raw_send don't fail if netif is down) by + letting ip_route only use netifs that are up. + + 2007-11-27 Simon Goldschmidt + * err.h, api_lib.c, api_msg.c, sockets.c: Changed error handling: ERR_MEM, ERR_BUF + and ERR_RTE are seen as non-fatal, all other errors are fatal. netconns and + sockets block most operations once they have seen a fatal error. + + 2007-11-27 Simon Goldschmidt + * udp.h, udp.c, dhcp.c: Implemented new function udp_sendto_if which takes the + netif to send as an argument (to be able to send on netifs that are down). + + 2007-11-26 Simon Goldschmidt + * tcp_in.c: Fixed bug #21582: pcb->acked accounting can be wrong when ACKs + arrive out-of-order + + 2007-11-21 Simon Goldschmidt + * tcp.h, tcp_out.c, api_msg.c: Fixed bug #20287: tcp_output_nagle sends too early + Fixed the nagle algorithm; nagle now also works for all raw API applications + and has to be explicitly disabled with 'tcp_pcb->flags |= TF_NODELAY' + + 2007-11-12 Frédéric Bernon + * sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fixed bug #20900. Now, most + of the netconn_peer and netconn_addr processing is done inside tcpip_thread + context in do_getaddr. + + 2007-11-10 Simon Goldschmidt + * etharp.c: Fixed bug: assert fired when MEMP_ARP_QUEUE was empty (which can + happen any time). Now the packet simply isn't enqueued when out of memory. + + 2007-11-01 Simon Goldschmidt + * tcp.c, tcp_in.c: Fixed bug #21494: The send mss (pcb->mss) is set to 536 (or + TCP_MSS if that is smaller) as long as no MSS option is received from the + remote host. + + 2007-11-01 Simon Goldschmidt + * tcp.h, tcp.c, tcp_in.c: Fixed bug #21491: The MSS option sent (with SYN) + is now based on TCP_MSS instead of pcb->mss (on passive open now effectively + sending our configured TCP_MSS instead of the one received). + + 2007-11-01 Simon Goldschmidt + * tcp_in.c: Fixed bug #21181: On active open, the initial congestion window was + calculated based on the configured TCP_MSS, not on the MSS option received + with SYN+ACK. + + 2007-10-09 Simon Goldschmidt + * udp.c, inet.c, inet.h: Fixed UDPLite: send: Checksum was always generated too + short and also was generated wrong if checksum coverage != tot_len; + receive: checksum was calculated wrong if checksum coverage != tot_len + + 2007-10-08 Simon Goldschmidt + * mem.c: lfree was not updated in mem_realloc! + + 2007-10-07 Frédéric Bernon + * sockets.c, api.h, api_lib.c: First step to fix "bug #20900 : Potential + crash error problem with netconn_peer & netconn_addr". VERY IMPORTANT: + this change cause an API breakage for netconn_addr, since a parameter + type change. Any compiler should cause an error without any changes in + yours netconn_peer calls (so, it can't be a "silent change"). It also + reduce a little bit the footprint for socket layer (lwip_getpeername & + lwip_getsockname use now a common lwip_getaddrname function since + netconn_peer & netconn_addr have the same parameters). + + 2007-09-20 Simon Goldschmidt + * tcp.c: Fixed bug #21080 (tcp_bind without check pcbs in TIME_WAIT state) + by checking tcp_tw_pcbs also + + 2007-09-19 Simon Goldschmidt + * icmp.c: Fixed bug #21107 (didn't reset IP TTL in ICMP echo replies) + + 2007-09-15 Mike Kleshov + * mem.c: Fixed bug #21077 (inaccuracy in calculation of lwip_stat.mem.used) + + 2007-09-06 Frédéric Bernon + * several-files: replace some #include "arch/cc.h" by "lwip/arch.h", or simply remove + it as long as "lwip/opt.h" is included before (this one include "lwip/debug.h" which + already include "lwip/arch.h"). Like that, default defines are provided by "lwip/arch.h" + if they are not defined in cc.h, in the same spirit than "lwip/opt.h" for lwipopts.h. + + 2007-08-30 Frédéric Bernon + * igmp.h, igmp.c: Some changes to remove some redundant code, add some traces, + and fix some coding style. + + 2007-08-28 Frédéric Bernon + * tcpip.c: Fix TCPIP_MSG_INPKT processing: now, tcpip_input can be used for any + kind of packets. These packets are considered like Ethernet packets (payload + pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets + are considered like IP packets (payload pointing to iphdr). + + 2007-08-27 Frédéric Bernon + * api.h, api_lib.c, api_msg.c: First fix for "bug #20900 : Potential crash error + problem with netconn_peer & netconn_addr". Introduce NETCONN_LISTEN netconn_state + and remove obsolete ones (NETCONN_RECV & NETCONN_ACCEPT). + + 2007-08-24 Kieran Mansley + * inet.c Modify (acc >> 16) test to ((acc >> 16) != 0) to help buggy + compiler (Paradigm C++) + + 2007-08-09 Frédéric Bernon, Bill Florac + * stats.h, stats.c, igmp.h, igmp.c, opt.h: Fix for bug #20503 : IGMP Improvement. + Introduce IGMP_STATS to centralize statistics management. + + 2007-08-09 Frédéric Bernon, Bill Florac + * udp.c: Fix for bug #20503 : IGMP Improvement. Enable to receive a multicast + packet on a udp pcb binded on an netif's IP address, and not on "any". + + 2007-08-09 Frédéric Bernon, Bill Florac + * igmp.h, igmp.c, ip.c: Fix minor changes from bug #20503 : IGMP Improvement. + This is mainly on using lookup/lookfor, and some coding styles... + + 2007-07-26 Frédéric Bernon (and "thedoctor") + * igmp.c: Fix bug #20595 to accept IGMPv3 "Query" messages. + + 2007-07-25 Simon Goldschmidt + * api_msg.c, tcp.c: Another fix for bug #20021: by not returning an error if + tcp_output fails in tcp_close, the code in do_close_internal gets simpler + (tcp_output is called again later from tcp timers). + + 2007-07-25 Simon Goldschmidt + * ip_frag.c: Fixed bug #20429: use the new pbuf_copy_partial instead of the old + copy_from_pbuf, which illegally modified the given pbuf. + + 2007-07-25 Simon Goldschmidt + * tcp_out.c: tcp_enqueue: pcb->snd_queuelen didn't work for chaine PBUF_RAMs: + changed snd_queuelen++ to snd_queuelen += pbuf_clen(p). + + 2007-07-24 Simon Goldschmidt + * api_msg.c, tcp.c: Fix bug #20480: Check the pcb passed to tcp_listen() for the + correct state (must be CLOSED). + + 2007-07-13 Thomas Taranowski (commited by Jared Grubb) + * memp.c: Fix bug #20478: memp_malloc returned NULL+MEMP_SIZE on failed + allocation. It now returns NULL. + + 2007-07-13 Frédéric Bernon + * api_msg.c: Fix bug #20318: api_msg "recv" callbacks don't call pbuf_free in + all error cases. + + 2007-07-13 Frédéric Bernon + * api_msg.c: Fix bug #20315: possible memory leak problem if tcp_listen failed, + because current code doesn't follow rawapi.txt documentation. + + 2007-07-13 Kieran Mansley + * src/core/tcp_in.c Apply patch#5741 from Oleg Tyshev to fix bug in + out of sequence processing of received packets + + 2007-07-03 Simon Goldschmidt + * nearly-all-files: Added assertions where PBUF_RAM pbufs are used and an + assumption is made that this pbuf is in one piece (i.e. not chained). These + assumptions clash with the possibility of converting to fully pool-based + pbuf implementations, where PBUF_RAM pbufs might be chained. + + 2007-07-03 Simon Goldschmidt + * api.h, api_lib.c, api_msg.c: Final fix for bug #20021 and some other problems + when closing tcp netconns: removed conn->sem, less context switches when + closing, both netconn_close and netconn_delete should safely close tcp + connections. + + 2007-07-02 Simon Goldschmidt + * ipv4/ip.h, ipv6/ip.h, opt.h, netif.h, etharp.h, ipv4/ip.c, netif.c, raw.c, + tcp_out.c, udp.c, etharp.c: Added option LWIP_NETIF_HWADDRHINT (default=off) + to cache ARP table indices with each pcb instead of single-entry cache for + the complete stack. + + 2007-07-02 Simon Goldschmidt + * tcp.h, tcp.c, tcp_in.c, tcp_out.c: Added some ASSERTS and casts to prevent + warnings when assigning to smaller types. + + 2007-06-28 Simon Goldschmidt + * tcp_out.c: Added check to prevent tcp_pcb->snd_queuelen from overflowing. + + 2007-06-28 Simon Goldschmidt + * tcp.h: Fixed bug #20287: Fixed nagle algorithm (sending was done too early if + a segment contained chained pbufs) + + 2007-06-28 Frédéric Bernon + * autoip.c: replace most of rand() calls by a macro LWIP_AUTOIP_RAND which compute + a "pseudo-random" value based on netif's MAC and some autoip fields. It's always + possible to define this macro in your own lwipopts.h to always use C library's + rand(). Note that autoip_create_rand_addr doesn't use this macro. + + 2007-06-28 Frédéric Bernon + * netifapi.h, netifapi.c, tcpip.h, tcpip.c: Update code to handle the option + LWIP_TCPIP_CORE_LOCKING, and do some changes to be coherent with last modifications + in api_lib/api_msg (use pointers and not type with table, etc...) + + 2007-06-26 Simon Goldschmidt + * udp.h: Fixed bug #20259: struct udp_hdr was lacking the packin defines. + + 2007-06-25 Simon Goldschmidt + * udp.c: Fixed bug #20253: icmp_dest_unreach was called with a wrong p->payload + for udp packets with no matching pcb. + + 2007-06-25 Simon Goldschmidt + * udp.c: Fixed bug #20220: UDP PCB search in udp_input(): a non-local match + could get udp input packets if the remote side matched. + + 2007-06-13 Simon Goldschmidt + * netif.c: Fixed bug #20180 (TCP pcbs listening on IP_ADDR_ANY could get + changed in netif_set_ipaddr if previous netif->ip_addr.addr was 0. + + 2007-06-13 Simon Goldschmidt + * api_msg.c: pcb_new sets conn->err if protocol is not implemented + -> netconn_new_..() does not allocate a new connection for unsupported + protocols. + + 2007-06-13 Frédéric Bernon, Simon Goldschmidt + * api_lib.c: change return expression in netconn_addr and netconn_peer, because + conn->err was reset to ERR_OK without any reasons (and error was lost)... + + 2007-06-13 Frédéric Bernon, Matthias Weisser + * opt.h, mem.h, mem.c, memp.c, pbuf.c, ip_frag.c, vj.c: Fix bug #20162. Rename + MEM_ALIGN in LWIP_MEM_ALIGN and MEM_ALIGN_SIZE in LWIP_MEM_ALIGN_SIZE to avoid + some macro names collision with some OS macros. + + 2007-06-11 Simon Goldschmidt + * udp.c: UDP Lite: corrected the use of chksum_len (based on RFC3828: if it's 0, + create checksum over the complete packet. On RX, if it's < 8 (and not 0), + discard the packet. Also removed the duplicate 'udphdr->chksum = 0' for both + UDP & UDP Lite. + + 2007-06-11 Srinivas Gollakota & Oleg Tyshev + * tcp_out.c: Fix for bug #20075 : "A problem with keep-alive timer and TCP flags" + where TCP flags wasn't initialized in tcp_keepalive. + + 2007-06-03 Simon Goldschmidt + * udp.c: udp_input(): Input pbuf was not freed if pcb had no recv function + registered, p->payload was modified without modifying p->len if sending + icmp_dest_unreach() (had no negative effect but was definitively wrong). + + 2007-06-03 Simon Goldschmidt + * icmp.c: Corrected bug #19937: For responding to an icmp echo request, icmp + re-used the input pbuf even if that didn't have enough space to include the + link headers. Now the space is tested and a new pbuf is allocated for the + echo response packet if the echo request pbuf isn't big enough. + + 2007-06-01 Simon Goldschmidt + * sockets.c: Checked in patch #5914: Moved sockopt processing into tcpip_thread. + + 2007-05-23 Frédéric Bernon + * api_lib.c, sockets.c: Fixed bug #5958 for netconn_listen (acceptmbox only + allocated by do_listen if success) and netconn_accept errors handling. In + most of api_lib functions, we replace some errors checkings like "if (conn==NULL)" + by ASSERT, except for netconn_delete. + + 2007-05-23 Frédéric Bernon + * api_lib.c: Fixed bug #5957 "Safe-thread problem inside netconn_recv" to return + an error code if it's impossible to fetch a pbuf on a TCP connection (and not + directly close the recvmbox). + + 2007-05-22 Simon Goldschmidt + * tcp.c: Fixed bug #1895 (tcp_bind not correct) by introducing a list of + bound but unconnected (and non-listening) tcp_pcbs. + + 2007-05-22 Frédéric Bernon + * sys.h, sys.c, api_lib.c, tcpip.c: remove sys_mbox_fetch_timeout() (was only + used for LWIP_SO_RCVTIMEO option) and use sys_arch_mbox_fetch() instead of + sys_mbox_fetch() in api files. Now, users SHOULD NOT use internal lwIP features + like "sys_timeout" in their application threads. + + 2007-05-22 Frédéric Bernon + * api.h, api_lib.c, api_msg.h, api_msg.c: change the struct api_msg_msg to see + which parameters are used by which do_xxx function, and to avoid "misusing" + parameters (patch #5938). + + 2007-05-22 Simon Goldschmidt + * api_lib.c, api_msg.c, raw.c, api.h, api_msg.h, raw.h: Included patch #5938: + changed raw_pcb.protocol from u16_t to u8_t since for IPv4 and IPv6, proto + is only 8 bits wide. This affects the api, as there, the protocol was + u16_t, too. + + 2007-05-18 Simon Goldschmidt + * memp.c: addition to patch #5913: smaller pointer was returned but + memp_memory was the same size -> did not save memory. + + 2007-05-16 Simon Goldschmidt + * loopif.c, slipif.c: Fix bug #19729: free pbuf if netif->input() returns + != ERR_OK. + + 2007-05-16 Simon Goldschmidt + * api_msg.c, udp.c: If a udp_pcb has a local_ip set, check if it is the same + as the one of the netif used for sending to prevent sending from old + addresses after a netif address gets changed (partly fixes bug #3168). + + 2007-05-16 Frédéric Bernon + * tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work + with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in + tcpip_init) because we have to be sure that network interfaces are already + added (mac filter is updated only in igmp_init for the moment). + + 2007-05-16 Simon Goldschmidt + * mem.c, memp.c: Removed semaphores from memp, changed sys_sem_wait calls + into sys_arch_sem_wait calls to prevent timers from running while waiting + for the heap. This fixes bug #19167. + + 2007-05-13 Simon Goldschmidt + * tcp.h, sockets.h, sockets.c: Fixed bug from patch #5865 by moving the defines + for socket options (lwip_set/-getsockopt) used with level IPPROTO_TCP from + tcp.h to sockets.h. + + 2007-05-07 Simon Goldschmidt + * mem.c: Another attempt to fix bug #17922. + + 2007-05-04 Simon Goldschmidt + * pbuf.c, pbuf.h, etharp.c: Further update to ARP queueing: Changed pbuf_copy() + implementation so that it can be reused (don't allocate the target + pbuf inside pbuf_copy()). + + 2007-05-04 Simon Goldschmidt + * memp.c: checked in patch #5913: in memp_malloc() we can return memp as mem + to save a little RAM (next pointer of memp is not used while not in pool). + + 2007-05-03 "maq" + * sockets.c: Fix ioctl FIONREAD when some data remains from last recv. + (patch #3574). + + 2007-04-23 Simon Goldschmidt + * loopif.c, loopif.h, opt.h, src/netif/FILES: fix bug #2595: "loopif results + in NULL reference for incoming TCP packets". Loopif has to be configured + (using LWIP_LOOPIF_MULTITHREADING) to directly call netif->input() + (multithreading environments, e.g. netif->input() = tcpip_input()) or + putting packets on a list that is fed to the stack by calling loopif_poll() + (single-thread / NO_SYS / polling environment where e.g. + netif->input() = ip_input). + + 2007-04-17 Jonathan Larmour + * pbuf.c: Use s32_t in pbuf_realloc(), as an s16_t can't reliably hold + the difference between two u16_t's. + * sockets.h: FD_SETSIZE needs to match number of sockets, which is + MEMP_NUM_NETCONN in sockets.c right now. + + 2007-04-12 Jonathan Larmour + * icmp.c: Reset IP header TTL in ICMP ECHO responses (bug #19580). + + 2007-04-12 Kieran Mansley + * tcp.c, tcp_in.c, tcp_out.c, tcp.h: Modify way the retransmission + timer is reset to fix bug#19434, with help from Oleg Tyshev. + + 2007-04-11 Simon Goldschmidt + * etharp.c, pbuf.c, pbuf.h: 3rd fix for bug #11400 (arp-queuing): More pbufs than + previously thought need to be copied (everything but PBUF_ROM!). Cleaned up + pbuf.c: removed functions no needed any more (by etharp). + + 2007-04-11 Kieran Mansley + * inet.c, ip_addr.h, sockets.h, sys.h, tcp.h: Apply patch #5745: Fix + "Constant is long" warnings with 16bit compilers. Contributed by + avatar@mmlab.cse.yzu.edu.tw + + 2007-04-05 Frédéric Bernon, Jonathan Larmour + * api_msg.c: Fix bug #16830: "err_tcp() posts to connection mailbox when no pend on + the mailbox is active". Now, the post is only done during a connect, and do_send, + do_write and do_join_leave_group don't do anything if a previous error was signaled. + + 2007-04-03 Frédéric Bernon + * ip.c: Don't set the IP_DF ("Don't fragment") flag in the IP header in IP output + packets. See patch #5834. + + 2007-03-30 Frédéric Bernon + * api_msg.c: add a "pcb_new" helper function to avoid redundant code, and to add + missing pcb allocations checking (in do_bind, and for each raw_new). Fix style. + + 2007-03-30 Frédéric Bernon + * most of files: prefix all debug.h define with "LWIP_" to avoid any conflict with + others environment defines (these were too "generic"). + + 2007-03-28 Frédéric Bernon + * api.h, api_lib.c, sockets.c: netbuf_ref doesn't check its internal pbuf_alloc call + result and can cause a crash. lwip_send now check netbuf_ref result. + + 2007-03-28 Simon Goldschmidt + * sockets.c Remove "#include " from sockets.c to avoid multiple + definition of macros (in errno.h and lwip/arch.h) if LWIP_PROVIDE_ERRNO is + defined. This is the way it should have been already (looking at + doc/sys_arch.txt) + + 2007-03-28 Kieran Mansley + * opt.h Change default PBUF_POOL_BUFSIZE (again) to accomodate default MSS + + IP and TCP headers *and* physical link headers + + 2007-03-26 Frédéric Bernon (based on patch from Dmitry Potapov) + * api_lib.c: patch for netconn_write(), fixes a possible race condition which cause + to send some garbage. It is not a definitive solution, but the patch does solve + the problem for most cases. + + 2007-03-22 Frédéric Bernon + * api_msg.h, api_msg.c: Remove obsolete API_MSG_ACCEPT and do_accept (never used). + + 2007-03-22 Frédéric Bernon + * api_lib.c: somes resources couldn't be freed if there was errors during + netconn_new_with_proto_and_callback. + + 2007-03-22 Frédéric Bernon + * ethernetif.c: update netif->input calls to check return value. In older ports, + it's a good idea to upgrade them, even if before, there could be another problem + (access to an uninitialized mailbox). + + 2007-03-21 Simon Goldschmidt + * sockets.c: fixed bug #5067 (essentialy a signed/unsigned warning fixed + by casting to unsigned). + + 2007-03-21 Frédéric Bernon + * api_lib.c, api_msg.c, tcpip.c: integrate sys_mbox_fetch(conn->mbox, NULL) calls from + api_lib.c to tcpip.c's tcpip_apimsg(). Now, use a local variable and not a + dynamic one from memp to send tcpip_msg to tcpip_thread in a synchrone call. + Free tcpip_msg from tcpip_apimsg is not done in tcpip_thread. This give a + faster and more reliable communication between api_lib and tcpip. + + 2007-03-21 Frédéric Bernon + * opt.h: Add LWIP_NETIF_CALLBACK (to avoid compiler warning) and set it to 0. + + 2007-03-21 Frédéric Bernon + * api_msg.c, igmp.c, igmp.h: Fix C++ style comments + + 2007-03-21 Kieran Mansley + * opt.h Change default PBUF_POOL_BUFSIZE to accomodate default MSS + + IP and TCP headers + + 2007-03-21 Kieran Mansley + * Fix all uses of pbuf_header to check the return value. In some + cases just assert if it fails as I'm not sure how to fix them, but + this is no worse than before when they would carry on regardless + of the failure. + + 2007-03-21 Kieran Mansley + * sockets.c, igmp.c, igmp.h, memp.h: Fix C++ style comments and + comment out missing header include in icmp.c + + 2007-03-20 Frédéric Bernon + * memp.h, stats.c: Fix stats_display function where memp_names table wasn't + synchronized with memp.h. + + 2007-03-20 Frédéric Bernon + * tcpip.c: Initialize tcpip's mbox, and verify if initialized in tcpip_input, + tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with + network interfaces. Also fix a compiler warning. + + 2007-03-20 Kieran Mansley + * udp.c: Only try and use pbuf_header() to make space for headers if + not a ROM or REF pbuf. + + 2007-03-19 Frédéric Bernon + * api_msg.h, api_msg.c, tcpip.h, tcpip.c: Add return types to tcpip_apimsg() + and api_msg_post(). + + 2007-03-19 Frédéric Bernon + * Remove unimplemented "memp_realloc" function from memp.h. + + 2007-03-11 Simon Goldschmidt + * pbuf.c: checked in patch #5796: pbuf_alloc: len field claculation caused + memory corruption. + + 2007-03-11 Simon Goldschmidt (based on patch from Dmitry Potapov) + * api_lib.c, sockets.c, api.h, api_msg.h, sockets.h: Fixed bug #19251 + (missing `const' qualifier in socket functions), to get more compatible to + standard POSIX sockets. + + 2007-03-11 Frédéric Bernon (based on patch from Dmitry Potapov) + * sockets.c: Add asserts inside bind, connect and sendto to check input + parameters. Remove excessive set_errno() calls after get_socket(), because + errno is set inside of get_socket(). Move last sock_set_errno() inside + lwip_close. + + 2007-03-09 Simon Goldschmidt + * memp.c: Fixed bug #11400: New etharp queueing introduced bug: memp_memory + was allocated too small. + + 2007-03-06 Simon Goldschmidt + * tcpip.c: Initialize dhcp timers in tcpip_thread (if LWIP_DHCP) to protect + the stack from concurrent access. + + 2007-03-06 Frédéric Bernon, Dmitry Potapov + * tcpip.c, ip_frag.c, ethernetif.c: Fix some build problems, and a redundancy + call to "lwip_stats.link.recv++;" in low_level_input() & ethernetif_input(). + + 2007-03-06 Simon Goldschmidt + * ip_frag.c, ip_frag.h: Reduce code size: don't include code in those files + if IP_FRAG == 0 and IP_REASSEMBLY == 0 + + 2007-03-06 Frédéric Bernon, Simon Goldschmidt + * opt.h, ip_frag.h, tcpip.h, tcpip.c, ethernetif.c: add new configuration + option named ETHARP_TCPIP_ETHINPUT, which enable the new tcpip_ethinput. + Allow to do ARP processing for incoming packets inside tcpip_thread + (protecting ARP layer against concurrent access). You can also disable + old code using tcp_input with new define ETHARP_TCPIP_INPUT set to 0. + Older ports have to use tcpip_ethinput. + + 2007-03-06 Simon Goldschmidt (based on patch from Dmitry Potapov) + * err.h, err.c: fixed compiler warning "initialization dircards qualifiers + from pointer target type" + + 2007-03-05 Frédéric Bernon + * opt.h, sockets.h: add new configuration options (LWIP_POSIX_SOCKETS_IO_NAMES, + ETHARP_TRUST_IP_MAC, review SO_REUSE) + + 2007-03-04 Frédéric Bernon + * api_msg.c: Remove some compiler warnings : parameter "pcb" was never + referenced. + + 2007-03-04 Frédéric Bernon + * api_lib.c: Fix "[patch #5764] api_lib.c cleanup: after patch #5687" (from + Dmitry Potapov). + The api_msg struct stay on the stack (not moved to netconn struct). + + 2007-03-04 Simon Goldschmidt (based on patch from Dmitry Potapov) + * pbuf.c: Fix BUG#19168 - pbuf_free can cause deadlock (if + SYS_LIGHTWEIGHT_PROT=1 & freeing PBUF_RAM when mem_sem is not available) + Also fixed cast warning in pbuf_alloc() + + 2007-03-04 Simon Goldschmidt + * etharp.c, etharp.h, memp.c, memp.h, opt.h: Fix BUG#11400 - don't corrupt + existing pbuf chain when enqueuing multiple pbufs to a pending ARP request + + 2007-03-03 Frédéric Bernon + * udp.c: remove obsolete line "static struct udp_pcb *pcb_cache = NULL;" + It is static, and never used in udp.c except udp_init(). + + 2007-03-02 Simon Goldschmidt + * tcpip.c: Moved call to ip_init(), udp_init() and tcp_init() from + tcpip_thread() to tcpip_init(). This way, raw API connections can be + initialized before tcpip_thread is running (e.g. before OS is started) + + 2007-03-02 Frédéric Bernon + * rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call + interval. + + 2007-02-28 Kieran Mansley + * pbuf.c: Fix BUG#17645 - ensure pbuf payload pointer is not moved + outside the region of the pbuf by pbuf_header() + + 2007-02-28 Kieran Mansley + * sockets.c: Fix BUG#19161 - ensure milliseconds timeout is non-zero + when supplied timeout is also non-zero + +(STABLE-1.2.0) + + 2006-12-05 Leon Woestenberg + * CHANGELOG: Mention STABLE-1.2.0 release. + + ++ New features: + + 2006-12-01 Christiaan Simons + * mem.h, opt.h: Added MEM_LIBC_MALLOC option. + Note this is a workaround. Currently I have no other options left. + + 2006-10-26 Christiaan Simons (accepted patch by Jonathan Larmour) + * ipv4/ip_frag.c: rename MAX_MTU to IP_FRAG_MAX_MTU and move define + to include/lwip/opt.h. + * ipv4/lwip/ip_frag.h: Remove unused IP_REASS_INTERVAL. + Move IP_REASS_MAXAGE and IP_REASS_BUFSIZE to include/lwip/opt.h. + * opt.h: Add above new options. + + 2006-08-18 Christiaan Simons + * tcp_{in,out}.c: added SNMP counters. + * ipv4/ip.c: added SNMP counters. + * ipv4/ip_frag.c: added SNMP counters. + + 2006-08-08 Christiaan Simons + * etharp.{c,h}: added etharp_find_addr() to read + (stable) ethernet/IP address pair from ARP table + + 2006-07-14 Christiaan Simons + * mib_structs.c: added + * include/lwip/snmp_structs.h: added + * netif.{c,h}, netif/ethernetif.c: added SNMP statistics to netif struct + + 2006-07-06 Christiaan Simons + * snmp/asn1_{enc,dec}.c added + * snmp/mib2.c added + * snmp/msg_{in,out}.c added + * include/lwip/snmp_asn1.h added + * include/lwip/snmp_msg.h added + * doc/snmp_agent.txt added + + 2006-03-29 Christiaan Simons + * inet.c, inet.h: Added platform byteswap support. + Added LWIP_PLATFORM_BYTESWAP define (defaults to 0) and + optional LWIP_PLATFORM_HTONS(), LWIP_PLATFORM_HTONL() macros. + + ++ Bug fixes: + + 2006-11-30 Christiaan Simons + * dhcp.c: Fixed false triggers of request_timeout. + + 2006-11-28 Christiaan Simons + * netif.c: In netif_add() fixed missing clear of ip_addr, netmask, gw and flags. + + 2006-10-11 Christiaan Simons + * api_lib.c etharp.c, ip.c, memp.c, stats.c, sys.{c,h} tcp.h: + Partially accepted patch #5449 for ANSI C compatibility / build fixes. + * ipv4/lwip/ip.h ipv6/lwip/ip.h: Corrected UDP-Lite protocol + identifier from 170 to 136 (bug #17574). + + 2006-10-10 Christiaan Simons + * api_msg.c: Fixed Nagle algorithm as reported by Bob Grice. + + 2006-08-17 Christiaan Simons + * udp.c: Fixed bug #17200, added check for broadcast + destinations for PCBs bound to a unicast address. + + 2006-08-07 Christiaan Simons + * api_msg.c: Flushing TCP output in do_close() (bug #15926). + + 2006-06-27 Christiaan Simons + * api_msg.c: Applied patch for cold case (bug #11135). + In accept_function() ensure newconn->callback is always initialized. + + 2006-06-15 Christiaan Simons + * mem.h: added MEM_SIZE_F alias to fix an ancient cold case (bug #1748), + facilitate printing of mem_size_t and u16_t statistics. + + 2006-06-14 Christiaan Simons + * api_msg.c: Applied patch #5146 to handle allocation failures + in accept() by Kevin Lawson. + + 2006-05-26 Christiaan Simons + * api_lib.c: Removed conn->sem creation and destruction + from netconn_write() and added sys_sem_new to netconn_new_*. + +(STABLE-1_1_1) + + 2006-03-03 Christiaan Simons + * ipv4/ip_frag.c: Added bound-checking assertions on ip_reassbitmap + access and added pbuf_alloc() return value checks. + + 2006-01-01 Leon Woestenberg + * tcp_{in,out}.c, tcp_out.c: Removed 'even sndbuf' fix in TCP, which is + now handled by the checksum routine properly. + + 2006-02-27 Leon Woestenberg + * pbuf.c: Fix alignment; pbuf_init() would not work unless + pbuf_pool_memory[] was properly aligned. (Patch by Curt McDowell.) + + 2005-12-20 Leon Woestenberg + * tcp.c: Remove PCBs which stay in LAST_ACK state too long. Patch + submitted by Mitrani Hiroshi. + + 2005-12-15 Christiaan Simons + * inet.c: Disabled the added summing routine to preserve code space. + + 2005-12-14 Leon Woestenberg + * tcp_in.c: Duplicate FIN ACK race condition fix by Kelvin Lawson. + Added Curt McDowell's optimized checksumming routine for future + inclusion. Need to create test case for unaliged, aligned, odd, + even length combination of cases on various endianess machines. + + 2005-12-09 Christiaan Simons + * inet.c: Rewrote standard checksum routine in proper portable C. + + 2005-11-25 Christiaan Simons + * udp.c tcp.c: Removed SO_REUSE hack. Should reside in socket code only. + * *.c: introduced cc.h LWIP_DEBUG formatters matching the u16_t, s16_t, + u32_t, s32_t typedefs. This solves most debug word-length assumes. + + 2005-07-17 Leon Woestenberg + * inet.c: Fixed unaligned 16-bit access in the standard checksum + routine by Peter Jolasson. + * slipif.c: Fixed implementation assumption of single-pbuf datagrams. + + 2005-02-04 Leon Woestenberg + * tcp_out.c: Fixed uninitialized 'queue' referenced in memerr branch. + * tcp_{out|in}.c: Applied patch fixing unaligned access. + + 2005-01-04 Leon Woestenberg + * pbuf.c: Fixed missing semicolon after LWIP_DEBUG statement. + + 2005-01-03 Leon Woestenberg + * udp.c: UDP pcb->recv() was called even when it was NULL. + +(STABLE-1_1_0) + + 2004-12-28 Leon Woestenberg + * etharp.*: Disabled multiple packets on the ARP queue. + This clashes with TCP queueing. + + 2004-11-28 Leon Woestenberg + * etharp.*: Fixed race condition from ARP request to ARP timeout. + Halved the ARP period, doubled the period counts. + ETHARP_MAX_PENDING now should be at least 2. This prevents + the counter from reaching 0 right away (which would allow + too little time for ARP responses to be received). + + 2004-11-25 Leon Woestenberg + * dhcp.c: Decline messages were not multicast but unicast. + * etharp.c: ETHARP_CREATE is renamed to ETHARP_TRY_HARD. + Do not try hard to insert arbitrary packet's source address, + etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD. + etharp_query() now always DOES call ETHARP_TRY_HARD so that users + querying an address will see it appear in the cache (DHCP could + suffer from this when a server invalidly gave an in-use address.) + * ipv4/ip_addr.h: Renamed ip_addr_maskcmp() to _netcmp() as we are + comparing network addresses (identifiers), not the network masks + themselves. + * ipv4/ip_addr.c: ip_addr_isbroadcast() now checks that the given + IP address actually belongs to the network of the given interface. + + 2004-11-24 Kieran Mansley + * tcp.c: Increment pcb->snd_buf when ACK is received in SYN_SENT state. + +(STABLE-1_1_0-RC1) + + 2004-10-16 Kieran Mansley + * tcp.c: Add code to tcp_recved() to send an ACK (window update) immediately, + even if one is already pending, if the rcv_wnd is above a threshold + (currently TCP_WND/2). This avoids waiting for a timer to expire to send a + delayed ACK in order to open the window if the stack is only receiving data. + + 2004-09-12 Kieran Mansley + * tcp*.*: Retransmit time-out handling improvement by Sam Jansen. + + 2004-08-20 Tony Mountifield + * etharp.c: Make sure the first pbuf queued on an ARP entry + is properly ref counted. + + 2004-07-27 Tony Mountifield + * debug.h: Added (int) cast in LWIP_DEBUGF() to avoid compiler + warnings about comparison. + * pbuf.c: Stopped compiler complaining of empty if statement + when LWIP_DEBUGF() empty. Closed an unclosed comment. + * tcp.c: Stopped compiler complaining of empty if statement + when LWIP_DEBUGF() empty. + * ip.h Corrected IPH_TOS() macro: returns a byte, so doesn't need htons(). + * inet.c: Added a couple of casts to quiet the compiler. + No need to test isascii(c) before isdigit(c) or isxdigit(c). + + 2004-07-22 Tony Mountifield + * inet.c: Made data types consistent in inet_ntoa(). + Added casts for return values of checksum routines, to pacify compiler. + * ip_frag.c, tcp_out.c, sockets.c, pbuf.c + Small corrections to some debugging statements, to pacify compiler. + + 2004-07-21 Tony Mountifield + * etharp.c: Removed spurious semicolon and added missing end-of-comment. + * ethernetif.c Updated low_level_output() to match prototype for + netif->linkoutput and changed low_level_input() similarly for consistency. + * api_msg.c: Changed recv_raw() from int to u8_t, to match prototype + of raw_recv() in raw.h and so avoid compiler error. + * sockets.c: Added trivial (int) cast to keep compiler happier. + * ip.c, netif.c Changed debug statements to use the tidier ip4_addrN() macros. + +(STABLE-1_0_0) + + ++ Changes: + + 2004-07-05 Leon Woestenberg + * sockets.*: Restructured LWIP_PRIVATE_TIMEVAL. Make sure + your cc.h file defines this either 1 or 0. If non-defined, + defaults to 1. + * .c: Added and includes where used. + * etharp.c: Made some array indices unsigned. + + 2004-06-27 Leon Woestenberg + * netif.*: Added netif_set_up()/down(). + * dhcp.c: Changes to restart program flow. + + 2004-05-07 Leon Woestenberg + * etharp.c: In find_entry(), instead of a list traversal per candidate, do a + single-pass lookup for different candidates. Should exploit locality. + + 2004-04-29 Leon Woestenberg + * tcp*.c: Cleaned up source comment documentation for Doxygen processing. + * opt.h: ETHARP_ALWAYS_INSERT option removed to comply with ARP RFC. + * etharp.c: update_arp_entry() only adds new ARP entries when adviced to by + the caller. This deprecates the ETHARP_ALWAYS_INSERT overrule option. + + ++ Bug fixes: + + 2004-04-27 Leon Woestenberg + * etharp.c: Applied patch of bug #8708 by Toni Mountifield with a solution + suggested by Timmy Brolin. Fix for 32-bit processors that cannot access + non-aligned 32-bit words, such as soms 32-bit TCP/IP header fields. Fix + is to prefix the 14-bit Ethernet headers with two padding bytes. + + 2004-04-23 Leon Woestenberg + * ip_addr.c: Fix in the ip_addr_isbroadcast() check. + * etharp.c: Fixed the case where the packet that initiates the ARP request + is not queued, and gets lost. Fixed the case where the packets destination + address is already known; we now always queue the packet and perform an ARP + request. + +(STABLE-0_7_0) + + ++ Bug fixes: + + * Fixed TCP bug for SYN_SENT to ESTABLISHED state transition. + * Fixed TCP bug in dequeueing of FIN from out of order segment queue. + * Fixed two possible NULL references in rare cases. + +(STABLE-0_6_6) + + ++ Bug fixes: + + * Fixed DHCP which did not include the IP address in DECLINE messages. + + ++ Changes: + + * etharp.c has been hauled over a bit. + +(STABLE-0_6_5) + + ++ Bug fixes: + + * Fixed TCP bug induced by bad window resizing with unidirectional TCP traffic. + * Packets sent from ARP queue had invalid source hardware address. + + ++ Changes: + + * Pass-by ARP requests do now update the cache. + + ++ New features: + + * No longer dependent on ctype.h. + * New socket options. + * Raw IP pcb support. + +(STABLE-0_6_4) + + ++ Bug fixes: + + * Some debug formatters and casts fixed. + * Numereous fixes in PPP. + + ++ Changes: + + * DEBUGF now is LWIP_DEBUGF + * pbuf_dechain() has been re-enabled. + * Mentioned the changed use of CVS branches in README. + +(STABLE-0_6_3) + + ++ Bug fixes: + + * Fixed pool pbuf memory leak in pbuf_alloc(). + Occured if not enough PBUF_POOL pbufs for a packet pbuf chain. + Reported by Savin Zlobec. + + * PBUF_POOL chains had their tot_len field not set for non-first + pbufs. Fixed in pbuf_alloc(). + + ++ New features: + + * Added PPP stack contributed by Marc Boucher + + ++ Changes: + + * Now drops short packets for ICMP/UDP/TCP protocols. More robust. + + * ARP queueuing now queues the latest packet instead of the first. + This is the RFC recommended behaviour, but can be overridden in + lwipopts.h. + +(0.6.2) + + ++ Bugfixes: + + * TCP has been fixed to deal with the new use of the pbuf->ref + counter. + + * DHCP dhcp_inform() crash bug fixed. + + ++ Changes: + + * Removed pbuf_pool_free_cache and pbuf_pool_alloc_cache. Also removed + pbuf_refresh(). This has sped up pbuf pool operations considerably. + Implemented by David Haas. + +(0.6.1) + + ++ New features: + + * The packet buffer implementation has been enhanced to support + zero-copy and copy-on-demand for packet buffers which have their + payloads in application-managed memory. + Implemented by David Haas. + + Use PBUF_REF to make a pbuf refer to RAM. lwIP will use zero-copy + if an outgoing packet can be directly sent on the link, or perform + a copy-on-demand when necessary. + + The application can safely assume the packet is sent, and the RAM + is available to the application directly after calling udp_send() + or similar function. + + ++ Bugfixes: + + * ARP_QUEUEING should now correctly work for all cases, including + PBUF_REF. + Implemented by Leon Woestenberg. + + ++ Changes: + + * IP_ADDR_ANY is no longer a NULL pointer. Instead, it is a pointer + to a '0.0.0.0' IP address. + + * The packet buffer implementation is changed. The pbuf->ref counter + meaning has changed, and several pbuf functions have been + adapted accordingly. + + * netif drivers have to be changed to set the hardware address length field + that must be initialized correctly by the driver (hint: 6 for Ethernet MAC). + See the contrib/ports/c16x cs8900 driver as a driver example. + + * netif's have a dhcp field that must be initialized to NULL by the driver. + See the contrib/ports/c16x cs8900 driver as a driver example. + +(0.5.x) This file has been unmaintained up to 0.6.1. All changes are + logged in CVS but have not been explained here. + +(0.5.3) Changes since version 0.5.2 + + ++ Bugfixes: + + * memp_malloc(MEMP_API_MSG) could fail with multiple application + threads because it wasn't protected by semaphores. + + ++ Other changes: + + * struct ip_addr now packed. + + * The name of the time variable in arp.c has been changed to ctime + to avoid conflicts with the time() function. + +(0.5.2) Changes since version 0.5.1 + + ++ New features: + + * A new TCP function, tcp_tmr(), now handles both TCP timers. + + ++ Bugfixes: + + * A bug in tcp_parseopt() could cause the stack to hang because of a + malformed TCP option. + + * The address of new connections in the accept() function in the BSD + socket library was not handled correctly. + + * pbuf_dechain() did not update the ->tot_len field of the tail. + + * Aborted TCP connections were not handled correctly in all + situations. + + ++ Other changes: + + * All protocol header structs are now packed. + + * The ->len field in the tcp_seg structure now counts the actual + amount of data, and does not add one for SYN and FIN segments. + +(0.5.1) Changes since version 0.5.0 + + ++ New features: + + * Possible to run as a user process under Linux. + + * Preliminary support for cross platform packed structs. + + * ARP timer now implemented. + + ++ Bugfixes: + + * TCP output queue length was badly initialized when opening + connections. + + * TCP delayed ACKs were not sent correctly. + + * Explicit initialization of BSS segment variables. + + * read() in BSD socket library could drop data. + + * Problems with memory alignment. + + * Situations when all TCP buffers were used could lead to + starvation. + + * TCP MSS option wasn't parsed correctly. + + * Problems with UDP checksum calculation. + + * IP multicast address tests had endianess problems. + + * ARP requests had wrong destination hardware address. + + ++ Other changes: + + * struct eth_addr changed from u16_t[3] array to u8_t[6]. + + * A ->linkoutput() member was added to struct netif. + + * TCP and UDP ->dest_* struct members where changed to ->remote_*. + + * ntoh* macros are now null definitions for big endian CPUs. + +(0.5.0) Changes since version 0.4.2 + + ++ New features: + + * Redesigned operating system emulation layer to make porting easier. + + * Better control over TCP output buffers. + + * Documenation added. + + ++ Bugfixes: + + * Locking issues in buffer management. + + * Bugfixes in the sequential API. + + * IP forwarding could cause memory leakage. This has been fixed. + + ++ Other changes: + + * Directory structure somewhat changed; the core/ tree has been + collapsed. + +(0.4.2) Changes since version 0.4.1 + + ++ New features: + + * Experimental ARP implementation added. + + * Skeleton Ethernet driver added. + + * Experimental BSD socket API library added. + + ++ Bugfixes: + + * In very intense situations, memory leakage could occur. This has + been fixed. + + ++ Other changes: + + * Variables named "data" and "code" have been renamed in order to + avoid name conflicts in certain compilers. + + * Variable++ have in appliciable cases been translated to ++variable + since some compilers generate better code in the latter case. + +(0.4.1) Changes since version 0.4 + + ++ New features: + + * TCP: Connection attempts time out earlier than data + transmissions. Nagle algorithm implemented. Push flag set on the + last segment in a burst. + + * UDP: experimental support for UDP-Lite extensions. + + ++ Bugfixes: + + * TCP: out of order segments were in some cases handled incorrectly, + and this has now been fixed. Delayed acknowledgements was broken + in 0.4, has now been fixed. Binding to an address that is in use + now results in an error. Reset connections sometimes hung an + application; this has been fixed. + + * Checksum calculation sometimes failed for chained pbufs with odd + lengths. This has been fixed. + + * API: a lot of bug fixes in the API. The UDP API has been improved + and tested. Error reporting and handling has been + improved. Logical flaws and race conditions for incoming TCP + connections has been found and removed. + + * Memory manager: alignment issues. Reallocating memory sometimes + failed, this has been fixed. + + * Generic library: bcopy was flawed and has been fixed. + + ++ Other changes: + + * API: all datatypes has been changed from generic ones such as + ints, to specified ones such as u16_t. Functions that return + errors now have the correct type (err_t). + + * General: A lot of code cleaned up and debugging code removed. Many + portability issues have been fixed. + + * The license was changed; the advertising clause was removed. + + * C64 port added. + + * Thanks: Huge thanks go to Dagan Galarneau, Horst Garnetzke, Petri + Kosunen, Mikael Caleres, and Frits Wilmink for reporting and + fixing bugs! + +(0.4) Changes since version 0.3.1 + + * Memory management has been radically changed; instead of + allocating memory from a shared heap, memory for objects that are + rapidly allocated and deallocated is now kept in pools. Allocation + and deallocation from those memory pools is very fast. The shared + heap is still present but is used less frequently. + + * The memory, memory pool, and packet buffer subsystems now support + 4-, 2-, or 1-byte alignment. + + * "Out of memory" situations are handled in a more robust way. + + * Stack usage has been reduced. + + * Easier configuration of lwIP parameters such as memory usage, + TTLs, statistics gathering, etc. All configuration parameters are + now kept in a single header file "lwipopts.h". + + * The directory structure has been changed slightly so that all + architecture specific files are kept under the src/arch + hierarchy. + + * Error propagation has been improved, both in the protocol modules + and in the API. + + * The code for the RTXC architecture has been implemented, tested + and put to use. + + * Bugs have been found and corrected in the TCP, UDP, IP, API, and + the Internet checksum modules. + + * Bugs related to porting between a 32-bit and a 16-bit architecture + have been found and corrected. + + * The license has been changed slightly to conform more with the + original BSD license, including the advertisement clause. + +(0.3.1) Changes since version 0.3 + + * Fix of a fatal bug in the buffer management. Pbufs with allocated + RAM never returned the RAM when the pbuf was deallocated. + + * TCP congestion control, window updates and retransmissions did not + work correctly. This has now been fixed. + + * Bugfixes in the API. + +(0.3) Changes since version 0.2 + + * New and improved directory structure. All include files are now + kept in a dedicated include/ directory. + + * The API now has proper error handling. A new function, + netconn_err(), now returns an error code for the connection in + case of errors. + + * Improvements in the memory management subsystem. The system now + keeps a pointer to the lowest free memory block. A new function, + mem_malloc2() tries to allocate memory once, and if it fails tries + to free some memory and retry the allocation. + + * Much testing has been done with limited memory + configurations. lwIP now does a better job when overloaded. + + * Some bugfixes and improvements to the buffer (pbuf) subsystem. + + * Many bugfixes in the TCP code: + + - Fixed a bug in tcp_close(). + + - The TCP receive window was incorrectly closed when out of + sequence segments was received. This has been fixed. + + - Connections are now timed-out of the FIN-WAIT-2 state. + + - The initial congestion window could in some cases be too + large. This has been fixed. + + - The retransmission queue could in some cases be screwed up. This + has been fixed. + + - TCP RST flag now handled correctly. + + - Out of sequence data was in some cases never delivered to the + application. This has been fixed. + + - Retransmitted segments now contain the correct acknowledgment + number and advertised window. + + - TCP retransmission timeout backoffs are not correctly computed + (ala BSD). After a number of retransmissions, TCP now gives up + the connection. + + * TCP connections now are kept on three lists, one for active + connections, one for listening connections, and one for + connections that are in TIME-WAIT. This greatly speeds up the fast + timeout processing for sending delayed ACKs. + + * TCP now provides proper feedback to the application when a + connection has been successfully set up. + + * More comments have been added to the code. The code has also been + somewhat cleaned up. + +(0.2) Initial public release. diff --git a/user/mpy/lib/lwip/COPYING b/user/mpy/lib/lwip/COPYING new file mode 100644 index 0000000..e23898b --- /dev/null +++ b/user/mpy/lib/lwip/COPYING @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + + diff --git a/user/mpy/lib/lwip/FILES b/user/mpy/lib/lwip/FILES new file mode 100644 index 0000000..6625319 --- /dev/null +++ b/user/mpy/lib/lwip/FILES @@ -0,0 +1,4 @@ +src/ - The source code for the lwIP TCP/IP stack. +doc/ - The documentation for lwIP. + +See also the FILES file in each subdirectory. diff --git a/user/mpy/lib/lwip/README b/user/mpy/lib/lwip/README new file mode 100644 index 0000000..a62cc4f --- /dev/null +++ b/user/mpy/lib/lwip/README @@ -0,0 +1,89 @@ +INTRODUCTION + +lwIP is a small independent implementation of the TCP/IP protocol +suite that has been developed by Adam Dunkels at the Computer and +Networks Architectures (CNA) lab at the Swedish Institute of Computer +Science (SICS). + +The focus of the lwIP TCP/IP implementation is to reduce the RAM usage +while still having a full scale TCP. This making lwIP suitable for use +in embedded systems with tens of kilobytes of free RAM and room for +around 40 kilobytes of code ROM. + +FEATURES + + * IP (Internet Protocol) including packet forwarding over multiple network + interfaces + * ICMP (Internet Control Message Protocol) for network maintenance and debugging + * IGMP (Internet Group Management Protocol) for multicast traffic management + * UDP (User Datagram Protocol) including experimental UDP-lite extensions + * TCP (Transmission Control Protocol) with congestion control, RTT estimation + and fast recovery/fast retransmit + * Specialized raw/native API for enhanced performance + * Optional Berkeley-like socket API + * DNS (Domain names resolver) + * SNMP (Simple Network Management Protocol) + * DHCP (Dynamic Host Configuration Protocol) + * AUTOIP (for IPv4, conform with RFC 3927) + * PPP (Point-to-Point Protocol) + * ARP (Address Resolution Protocol) for Ethernet + +LICENSE + +lwIP is freely available under a BSD license. + +DEVELOPMENT + +lwIP has grown into an excellent TCP/IP stack for embedded devices, +and developers using the stack often submit bug fixes, improvements, +and additions to the stack to further increase its usefulness. + +Development of lwIP is hosted on Savannah, a central point for +software development, maintenance and distribution. Everyone can +help improve lwIP by use of Savannah's interface, CVS and the +mailing list. A core team of developers will commit changes to the +CVS source tree. + +The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and +contributions (such as platform ports) are in the 'contrib' module. + +See doc/savannah.txt for details on CVS server access for users and +developers. + +Last night's CVS tar ball can be downloaded from: + http://savannah.gnu.org/cvs.backups/lwip.tar.gz [CHANGED - NEEDS FIXING] + +The current CVS trees are web-browsable: + http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/lwip/ + http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/ + +Submit patches and bugs via the lwIP project page: + http://savannah.nongnu.org/projects/lwip/ + + +DOCUMENTATION + +The original out-dated homepage of lwIP and Adam Dunkels' papers on +lwIP are at the official lwIP home page: + http://www.sics.se/~adam/lwip/ + +Self documentation of the source code is regularly extracted from the +current CVS sources and is available from this web page: + http://www.nongnu.org/lwip/ + +There is now a constantly growin wiki about lwIP at + http://lwip.wikia.com/wiki/LwIP_Wiki + +Also, there are mailing lists you can subscribe at + http://savannah.nongnu.org/mail/?group=lwip +plus searchable archives: + http://lists.nongnu.org/archive/html/lwip-users/ + http://lists.nongnu.org/archive/html/lwip-devel/ + +Reading Adam's papers, the files in docs/, browsing the source code +documentation and browsing the mailing list archives is a good way to +become familiar with the design of lwIP. + +Adam Dunkels +Leon Woestenberg + diff --git a/user/mpy/lib/lwip/UPGRADING b/user/mpy/lib/lwip/UPGRADING new file mode 100644 index 0000000..6501107 --- /dev/null +++ b/user/mpy/lib/lwip/UPGRADING @@ -0,0 +1,144 @@ +This file lists major changes between release versions that require +ports or applications to be changed. Use it to update a port or an +application written for an older version of lwIP to correctly work +with newer versions. + + +(CVS HEAD) + + * [Enter new changes just after this line - do not remove this line] + + ++ Application changes: + + * Replaced struct ip_addr by typedef ip_addr_t (struct ip_addr is kept for + compatibility to old applications, but will be removed in the future). + + * Renamed mem_realloc() to mem_trim() to prevent confusion with realloc() + + +++ Raw API: + * Changed the semantics of tcp_close() (since it was rather a + shutdown before): Now the application does *NOT* get any calls to the recv + callback (aside from NULL/closed) after calling tcp_close() + + * When calling tcp_abort() from a raw API TCP callback function, + make sure you return ERR_ABRT to prevent accessing unallocated memory. + (ERR_ABRT now means the applicaiton has called tcp_abort!) + + +++ Netconn API: + * Changed netconn_receive() and netconn_accept() to return + err_t, not a pointer to new data/netconn. + + +++ Socket API: + * LWIP_SO_RCVTIMEO: when accept() or recv() time out, they + now set errno to EWOULDBLOCK/EAGAIN, not ETIMEDOUT. + + * Added a minimal version of posix fctl() to have a + standardised way to set O_NONBLOCK for nonblocking sockets. + + +++ all APIs: + * correctly implemented SO(F)_REUSEADDR + + ++ Port changes + + +++ new files: + + * Added 4 new files: def.c, timers.c, timers.h, tcp_impl.h: + + * Moved stack-internal parts of tcp.h to tcp_impl.h, tcp.h now only contains + the actual application programmer's API + + * Separated timer implementation from sys.h/.c, moved to timers.h/.c; + Added timer implementation for NO_SYS==1, set NO_SYS_NO_TIMERS==1 if you + still want to use your own timer implementation for NO_SYS==0 (as before). + + +++ sys layer: + + * Converted mbox- and semaphore-functions to take pointers to sys_mbox_t/ + sys_sem_t; + + * Converted sys_mbox_new/sys_sem_new to take pointers and return err_t; + + * Added Mutex concept in sys_arch (define LWIP_COMPAT_MUTEX to let sys.h use + binary semaphores instead of mutexes - as before) + + +++ new options: + + * Don't waste memory when chaining segments, added option TCP_OVERSIZE to + prevent creating many small pbufs when calling tcp_write with many small + blocks of data. Instead, pbufs are allocated larger than needed and the + space is used for later calls to tcp_write. + + * Added LWIP_NETIF_TX_SINGLE_PBUF to always copy to try to create single pbufs + in tcp_write/udp_send. + + * Added an additional option LWIP_ETHERNET to support ethernet without ARP + (necessary for pure PPPoE) + + * Add MEMP_SEPARATE_POOLS to place memory pools in separate arrays. This may + be used to place these pools into user-defined memory by using external + declaration. + + * Added TCP_SNDQUEUELOWAT corresponding to TCP_SNDLOWAT + + +++ new pools: + + * Netdb uses a memp pool for allocating memory when getaddrinfo() is called, + so MEMP_NUM_NETDB has to be set accordingly. + + * DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses a memp pool instead of the heap, so + MEMP_NUM_LOCALHOSTLIST has to be set accordingly. + + * Snmp-agent uses a memp pools instead of the heap, so MEMP_NUM_SNMP_* have + to be set accordingly. + + * PPPoE uses a MEMP pool instead of the heap, so MEMP_NUM_PPPOE_INTERFACES + has to be set accordingly + + * Integrated loopif into netif.c - loopif does not have to be created by the + port any more, just define LWIP_HAVE_LOOPIF to 1. + + * Added define LWIP_RAND() for lwip-wide randomization (needs to be defined + in cc.h, e.g. used by igmp) + + * Added printf-formatter X8_F to printf u8_t as hex + + * The heap now may be moved to user-defined memory by defining + LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address + + * added autoip_set_struct() and dhcp_set_struct() to let autoip and dhcp work + with user-allocated structs instead of calling mem_malloc + + * Added const char* name to mem- and memp-stats for easier debugging. + + * Calculate the TCP/UDP checksum while copying to only fetch data once: + Define LWIP_CHKSUM_COPY to a memcpy-like function that returns the checksum + + * Added SO_REUSE_RXTOALL to pass received UDP broadcast/multicast packets to + more than one pcb. + + * Changed the semantics of ARP_QUEUEING==0: ARP_QUEUEING now cannot be turned + off any more, if this is set to 0, only one packet (the most recent one) is + queued (like demanded by RFC 1122). + + + ++ Major bugfixes/improvements + + * Implemented tcp_shutdown() to only shut down one end of a connection + * Implemented shutdown() at socket- and netconn-level + * Added errorset support to select() + improved select speed overhead + * Merged pppd to v2.3.11 (including some backported bugfixes from 2.4.x) + * Added timer implementation for NO_SYS==1 (may be disabled with NO_SYS_NO_TIMERS==1 + * Use macros defined in ip_addr.h to work with IP addresses + * Implemented many nonblocking socket/netconn functions + * Fixed ARP input processing: only add a new entry if a request was directed as us + * mem_realloc() to mem_trim() to prevent confusion with realloc() + * Some improvements for AutoIP (don't route/forward link-local addresses, don't break + existing connections when assigning a routable address) + * Correctly handle remote side overrunning our rcv_wnd in ooseq case + * Removed packing from ip_addr_t, the packed version is now only used in protocol headers + * Corrected PBUF_POOL_BUFSIZE for ports where ETH_PAD_SIZE > 0 + * Added support for static ARP table entries + +(STABLE-1.3.2) + + * initial version of this file diff --git a/user/mpy/lib/lwip/doc/FILES b/user/mpy/lib/lwip/doc/FILES new file mode 100644 index 0000000..05d356f --- /dev/null +++ b/user/mpy/lib/lwip/doc/FILES @@ -0,0 +1,6 @@ +savannah.txt - How to obtain the current development source code. +contrib.txt - How to contribute to lwIP as a developer. +rawapi.txt - The documentation for the core API of lwIP. + Also provides an overview about the other APIs and multithreading. +snmp_agent.txt - The documentation for the lwIP SNMP agent. +sys_arch.txt - The documentation for a system abstraction layer of lwIP. diff --git a/user/mpy/lib/lwip/doc/contrib.txt b/user/mpy/lib/lwip/doc/contrib.txt new file mode 100644 index 0000000..39596fc --- /dev/null +++ b/user/mpy/lib/lwip/doc/contrib.txt @@ -0,0 +1,63 @@ +1 Introduction + +This document describes some guidelines for people participating +in lwIP development. + +2 How to contribute to lwIP + +Here is a short list of suggestions to anybody working with lwIP and +trying to contribute bug reports, fixes, enhancements, platform ports etc. +First of all as you may already know lwIP is a volunteer project so feedback +to fixes or questions might often come late. Hopefully the bug and patch tracking +features of Savannah help us not lose users' input. + +2.1 Source code style: + +1. do not use tabs. +2. indentation is two spaces per level (i.e. per tab). +3. end debug messages with a trailing newline (\n). +4. one space between keyword and opening bracket. +5. no space between function and opening bracket. +6. one space and no newline before opening curly braces of a block. +7. closing curly brace on a single line. +8. spaces surrounding assignment and comparisons. +9. don't initialize static and/or global variables to zero, the compiler takes care of that. +10. use current source code style as further reference. + +2.2 Source code documentation style: + +1. JavaDoc compliant and Doxygen compatible. +2. Function documentation above functions in .c files, not .h files. + (This forces you to synchronize documentation and implementation.) +3. Use current documentation style as further reference. + +2.3 Bug reports and patches: + +1. Make sure you are reporting bugs or send patches against the latest + sources. (From the latest release and/or the current CVS sources.) +2. If you think you found a bug make sure it's not already filed in the + bugtracker at Savannah. +3. If you have a fix put the patch on Savannah. If it is a patch that affects + both core and arch specific stuff please separate them so that the core can + be applied separately while leaving the other patch 'open'. The prefered way + is to NOT touch archs you can't test and let maintainers take care of them. + This is a good way to see if they are used at all - the same goes for unix + netifs except tapif. +4. Do not file a bug and post a fix to it to the patch area. Either a bug report + or a patch will be enough. + If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area. +5. Trivial patches (compiler warning, indentation and spelling fixes or anything obvious which takes a line or two) + can go to the lwip-users list. This is still the fastest way of interaction and the list is not so crowded + as to allow for loss of fixes. Putting bugs on Savannah and subsequently closing them is too much an overhead + for reporting a compiler warning fix. +6. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other + trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you + change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than + if it's not to the point and long :) so the chances for it to be applied are greater. + +2.4 Platform porters: + +1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and + you think it could benefit others[1] you might want discuss this on the mailing list. You + can also ask for CVS access to submit and maintain your port in the contrib CVS module. + \ No newline at end of file diff --git a/user/mpy/lib/lwip/doc/rawapi.txt b/user/mpy/lib/lwip/doc/rawapi.txt new file mode 100644 index 0000000..8c19030 --- /dev/null +++ b/user/mpy/lib/lwip/doc/rawapi.txt @@ -0,0 +1,511 @@ +Raw TCP/IP interface for lwIP + +Authors: Adam Dunkels, Leon Woestenberg, Christiaan Simons + +lwIP provides three Application Program's Interfaces (APIs) for programs +to use for communication with the TCP/IP code: +* low-level "core" / "callback" or "raw" API. +* higher-level "sequential" API. +* BSD-style socket API. + +The sequential API provides a way for ordinary, sequential, programs +to use the lwIP stack. It is quite similar to the BSD socket API. The +model of execution is based on the blocking open-read-write-close +paradigm. Since the TCP/IP stack is event based by nature, the TCP/IP +code and the application program must reside in different execution +contexts (threads). + +The socket API is a compatibility API for existing applications, +currently it is built on top of the sequential API. It is meant to +provide all functions needed to run socket API applications running +on other platforms (e.g. unix / windows etc.). However, due to limitations +in the specification of this API, there might be incompatibilities +that require small modifications of existing programs. + +** Threading + +lwIP started targeting single-threaded environments. When adding multi- +threading support, instead of making the core thread-safe, another +approach was chosen: there is one main thread running the lwIP core +(also known as the "tcpip_thread"). The raw API may only be used from +this thread! Application threads using the sequential- or socket API +communicate with this main thread through message passing. + + As such, the list of functions that may be called from + other threads or an ISR is very limited! Only functions + from these API header files are thread-safe: + - api.h + - netbuf.h + - netdb.h + - netifapi.h + - sockets.h + - sys.h + + Additionaly, memory (de-)allocation functions may be + called from multiple threads (not ISR!) with NO_SYS=0 + since they are protected by SYS_LIGHTWEIGHT_PROT and/or + semaphores. + + Only since 1.3.0, if SYS_LIGHTWEIGHT_PROT is set to 1 + and LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT is set to 1, + pbuf_free() may also be called from another thread or + an ISR (since only then, mem_free - for PBUF_RAM - may + be called from an ISR: otherwise, the HEAP is only + protected by semaphores). + + +** The remainder of this document discusses the "raw" API. ** + +The raw TCP/IP interface allows the application program to integrate +better with the TCP/IP code. Program execution is event based by +having callback functions being called from within the TCP/IP +code. The TCP/IP code and the application program both run in the same +thread. The sequential API has a much higher overhead and is not very +well suited for small systems since it forces a multithreaded paradigm +on the application. + +The raw TCP/IP interface is not only faster in terms of code execution +time but is also less memory intensive. The drawback is that program +development is somewhat harder and application programs written for +the raw TCP/IP interface are more difficult to understand. Still, this +is the preferred way of writing applications that should be small in +code size and memory usage. + +Both APIs can be used simultaneously by different application +programs. In fact, the sequential API is implemented as an application +program using the raw TCP/IP interface. + +--- Callbacks + +Program execution is driven by callbacks. Each callback is an ordinary +C function that is called from within the TCP/IP code. Every callback +function is passed the current TCP or UDP connection state as an +argument. Also, in order to be able to keep program specific state, +the callback functions are called with a program specified argument +that is independent of the TCP/IP state. + +The function for setting the application connection state is: + +- void tcp_arg(struct tcp_pcb *pcb, void *arg) + + Specifies the program specific state that should be passed to all + other callback functions. The "pcb" argument is the current TCP + connection control block, and the "arg" argument is the argument + that will be passed to the callbacks. + + +--- TCP connection setup + +The functions used for setting up connections is similar to that of +the sequential API and of the BSD socket API. A new TCP connection +identifier (i.e., a protocol control block - PCB) is created with the +tcp_new() function. This PCB can then be either set to listen for new +incoming connections or be explicitly connected to another host. + +- struct tcp_pcb *tcp_new(void) + + Creates a new connection identifier (PCB). If memory is not + available for creating the new pcb, NULL is returned. + +- err_t tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port) + + Binds the pcb to a local IP address and port number. The IP address + can be specified as IP_ADDR_ANY in order to bind the connection to + all local IP addresses. + + If another connection is bound to the same port, the function will + return ERR_USE, otherwise ERR_OK is returned. + +- struct tcp_pcb *tcp_listen(struct tcp_pcb *pcb) + + Commands a pcb to start listening for incoming connections. When an + incoming connection is accepted, the function specified with the + tcp_accept() function will be called. The pcb will have to be bound + to a local port with the tcp_bind() function. + + The tcp_listen() function returns a new connection identifier, and + the one passed as an argument to the function will be + deallocated. The reason for this behavior is that less memory is + needed for a connection that is listening, so tcp_listen() will + reclaim the memory needed for the original connection and allocate a + new smaller memory block for the listening connection. + + tcp_listen() may return NULL if no memory was available for the + listening connection. If so, the memory associated with the pcb + passed as an argument to tcp_listen() will not be deallocated. + +- struct tcp_pcb *tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) + + Same as tcp_listen, but limits the number of outstanding connections + in the listen queue to the value specified by the backlog argument. + To use it, your need to set TCP_LISTEN_BACKLOG=1 in your lwipopts.h. + +- void tcp_accepted(struct tcp_pcb *pcb) + + Inform lwIP that an incoming connection has been accepted. This would + usually be called from the accept callback. This allows lwIP to perform + housekeeping tasks, such as allowing further incoming connections to be + queued in the listen backlog. + ATTENTION: the PCB passed in must be the listening pcb, not the pcb passed + into the accept callback! + +- void tcp_accept(struct tcp_pcb *pcb, + err_t (* accept)(void *arg, struct tcp_pcb *newpcb, + err_t err)) + + Specified the callback function that should be called when a new + connection arrives on a listening connection. + +- err_t tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port, err_t (* connected)(void *arg, + struct tcp_pcb *tpcb, + err_t err)); + + Sets up the pcb to connect to the remote host and sends the + initial SYN segment which opens the connection. + + The tcp_connect() function returns immediately; it does not wait for + the connection to be properly setup. Instead, it will call the + function specified as the fourth argument (the "connected" argument) + when the connection is established. If the connection could not be + properly established, either because the other host refused the + connection or because the other host didn't answer, the "err" + callback function of this pcb (registered with tcp_err, see below) + will be called. + + The tcp_connect() function can return ERR_MEM if no memory is + available for enqueueing the SYN segment. If the SYN indeed was + enqueued successfully, the tcp_connect() function returns ERR_OK. + + +--- Sending TCP data + +TCP data is sent by enqueueing the data with a call to +tcp_write(). When the data is successfully transmitted to the remote +host, the application will be notified with a call to a specified +callback function. + +- err_t tcp_write(struct tcp_pcb *pcb, const void *dataptr, u16_t len, + u8_t apiflags) + + Enqueues the data pointed to by the argument dataptr. The length of + the data is passed as the len parameter. The apiflags can be one or more of: + - TCP_WRITE_FLAG_COPY: indicates whether the new memory should be allocated + for the data to be copied into. If this flag is not given, no new memory + should be allocated and the data should only be referenced by pointer. This + also means that the memory behind dataptr must not change until the data is + ACKed by the remote host + - TCP_WRITE_FLAG_MORE: indicates that more data follows. If this is given, + the PSH flag is set in the last segment created by this call to tcp_write. + If this flag is given, the PSH flag is not set. + + The tcp_write() function will fail and return ERR_MEM if the length + of the data exceeds the current send buffer size or if the length of + the queue of outgoing segment is larger than the upper limit defined + in lwipopts.h. The number of bytes available in the output queue can + be retrieved with the tcp_sndbuf() function. + + The proper way to use this function is to call the function with at + most tcp_sndbuf() bytes of data. If the function returns ERR_MEM, + the application should wait until some of the currently enqueued + data has been successfully received by the other host and try again. + +- void tcp_sent(struct tcp_pcb *pcb, + err_t (* sent)(void *arg, struct tcp_pcb *tpcb, + u16_t len)) + + Specifies the callback function that should be called when data has + successfully been received (i.e., acknowledged) by the remote + host. The len argument passed to the callback function gives the + amount bytes that was acknowledged by the last acknowledgment. + + +--- Receiving TCP data + +TCP data reception is callback based - an application specified +callback function is called when new data arrives. When the +application has taken the data, it has to call the tcp_recved() +function to indicate that TCP can advertise increase the receive +window. + +- void tcp_recv(struct tcp_pcb *pcb, + err_t (* recv)(void *arg, struct tcp_pcb *tpcb, + struct pbuf *p, err_t err)) + + Sets the callback function that will be called when new data + arrives. The callback function will be passed a NULL pbuf to + indicate that the remote host has closed the connection. If + there are no errors and the callback function is to return + ERR_OK, then it must free the pbuf. Otherwise, it must not + free the pbuf so that lwIP core code can store it. + +- void tcp_recved(struct tcp_pcb *pcb, u16_t len) + + Must be called when the application has received the data. The len + argument indicates the length of the received data. + + +--- Application polling + +When a connection is idle (i.e., no data is either transmitted or +received), lwIP will repeatedly poll the application by calling a +specified callback function. This can be used either as a watchdog +timer for killing connections that have stayed idle for too long, or +as a method of waiting for memory to become available. For instance, +if a call to tcp_write() has failed because memory wasn't available, +the application may use the polling functionality to call tcp_write() +again when the connection has been idle for a while. + +- void tcp_poll(struct tcp_pcb *pcb, + err_t (* poll)(void *arg, struct tcp_pcb *tpcb), + u8_t interval) + + Specifies the polling interval and the callback function that should + be called to poll the application. The interval is specified in + number of TCP coarse grained timer shots, which typically occurs + twice a second. An interval of 10 means that the application would + be polled every 5 seconds. + + +--- Closing and aborting connections + +- err_t tcp_close(struct tcp_pcb *pcb) + + Closes the connection. The function may return ERR_MEM if no memory + was available for closing the connection. If so, the application + should wait and try again either by using the acknowledgment + callback or the polling functionality. If the close succeeds, the + function returns ERR_OK. + + The pcb is deallocated by the TCP code after a call to tcp_close(). + +- void tcp_abort(struct tcp_pcb *pcb) + + Aborts the connection by sending a RST (reset) segment to the remote + host. The pcb is deallocated. This function never fails. + + ATTENTION: When calling this from one of the TCP callbacks, make + sure you always return ERR_ABRT (and never return ERR_ABRT otherwise + or you will risk accessing deallocated memory or memory leaks! + + +If a connection is aborted because of an error, the application is +alerted of this event by the err callback. Errors that might abort a +connection are when there is a shortage of memory. The callback +function to be called is set using the tcp_err() function. + +- void tcp_err(struct tcp_pcb *pcb, void (* err)(void *arg, + err_t err)) + + The error callback function does not get the pcb passed to it as a + parameter since the pcb may already have been deallocated. + + +--- Lower layer TCP interface + +TCP provides a simple interface to the lower layers of the +system. During system initialization, the function tcp_init() has +to be called before any other TCP function is called. When the system +is running, the two timer functions tcp_fasttmr() and tcp_slowtmr() +must be called with regular intervals. The tcp_fasttmr() should be +called every TCP_FAST_INTERVAL milliseconds (defined in tcp.h) and +tcp_slowtmr() should be called every TCP_SLOW_INTERVAL milliseconds. + + +--- UDP interface + +The UDP interface is similar to that of TCP, but due to the lower +level of complexity of UDP, the interface is significantly simpler. + +- struct udp_pcb *udp_new(void) + + Creates a new UDP pcb which can be used for UDP communication. The + pcb is not active until it has either been bound to a local address + or connected to a remote address. + +- void udp_remove(struct udp_pcb *pcb) + + Removes and deallocates the pcb. + +- err_t udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port) + + Binds the pcb to a local address. The IP-address argument "ipaddr" + can be IP_ADDR_ANY to indicate that it should listen to any local IP + address. The function currently always return ERR_OK. + +- err_t udp_connect(struct udp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port) + + Sets the remote end of the pcb. This function does not generate any + network traffic, but only set the remote address of the pcb. + +- err_t udp_disconnect(struct udp_pcb *pcb) + + Remove the remote end of the pcb. This function does not generate + any network traffic, but only removes the remote address of the pcb. + +- err_t udp_send(struct udp_pcb *pcb, struct pbuf *p) + + Sends the pbuf p. The pbuf is not deallocated. + +- void udp_recv(struct udp_pcb *pcb, + void (* recv)(void *arg, struct udp_pcb *upcb, + struct pbuf *p, + ip_addr_t *addr, + u16_t port), + void *recv_arg) + + Specifies a callback function that should be called when a UDP + datagram is received. + + +--- System initalization + +A truly complete and generic sequence for initializing the lwip stack +cannot be given because it depends on the build configuration (lwipopts.h) +and additional initializations for your runtime environment (e.g. timers). + +We can give you some idea on how to proceed when using the raw API. +We assume a configuration using a single Ethernet netif and the +UDP and TCP transport layers, IPv4 and the DHCP client. + +Call these functions in the order of appearance: + +- stats_init() + + Clears the structure where runtime statistics are gathered. + +- sys_init() + + Not of much use since we set the NO_SYS 1 option in lwipopts.h, + to be called for easy configuration changes. + +- mem_init() + + Initializes the dynamic memory heap defined by MEM_SIZE. + +- memp_init() + + Initializes the memory pools defined by MEMP_NUM_x. + +- pbuf_init() + + Initializes the pbuf memory pool defined by PBUF_POOL_SIZE. + +- etharp_init() + + Initializes the ARP table and queue. + Note: you must call etharp_tmr at a ARP_TMR_INTERVAL (5 seconds) regular interval + after this initialization. + +- ip_init() + + Doesn't do much, it should be called to handle future changes. + +- udp_init() + + Clears the UDP PCB list. + +- tcp_init() + + Clears the TCP PCB list and clears some internal TCP timers. + Note: you must call tcp_fasttmr() and tcp_slowtmr() at the + predefined regular intervals after this initialization. + +- netif_add(struct netif *netif, ip_addr_t *ipaddr, + ip_addr_t *netmask, ip_addr_t *gw, + void *state, err_t (* init)(struct netif *netif), + err_t (* input)(struct pbuf *p, struct netif *netif)) + + Adds your network interface to the netif_list. Allocate a struct + netif and pass a pointer to this structure as the first argument. + Give pointers to cleared ip_addr structures when using DHCP, + or fill them with sane numbers otherwise. The state pointer may be NULL. + + The init function pointer must point to a initialization function for + your ethernet netif interface. The following code illustrates it's use. + + err_t netif_if_init(struct netif *netif) + { + u8_t i; + + for(i = 0; i < ETHARP_HWADDR_LEN; i++) netif->hwaddr[i] = some_eth_addr[i]; + init_my_eth_device(); + return ERR_OK; + } + + For ethernet drivers, the input function pointer must point to the lwip + function ethernet_input() declared in "netif/etharp.h". Other drivers + must use ip_input() declared in "lwip/ip.h". + +- netif_set_default(struct netif *netif) + + Registers the default network interface. + +- netif_set_up(struct netif *netif) + + When the netif is fully configured this function must be called. + +- dhcp_start(struct netif *netif) + + Creates a new DHCP client for this interface on the first call. + Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at + the predefined regular intervals after starting the client. + + You can peek in the netif->dhcp struct for the actual DHCP status. + + +--- Optimalization hints + +The first thing you want to optimize is the lwip_standard_checksum() +routine from src/core/inet.c. You can override this standard +function with the #define LWIP_CHKSUM . + +There are C examples given in inet.c or you might want to +craft an assembly function for this. RFC1071 is a good +introduction to this subject. + +Other significant improvements can be made by supplying +assembly or inline replacements for htons() and htonl() +if you're using a little-endian architecture. +#define LWIP_PLATFORM_BYTESWAP 1 +#define LWIP_PLATFORM_HTONS(x) +#define LWIP_PLATFORM_HTONL(x) + +Check your network interface driver if it reads at +a higher speed than the maximum wire-speed. If the +hardware isn't serviced frequently and fast enough +buffer overflows are likely to occur. + +E.g. when using the cs8900 driver, call cs8900if_service(ethif) +as frequently as possible. When using an RTOS let the cs8900 interrupt +wake a high priority task that services your driver using a binary +semaphore or event flag. Some drivers might allow additional tuning +to match your application and network. + +For a production release it is recommended to set LWIP_STATS to 0. +Note that speed performance isn't influenced much by simply setting +high values to the memory options. + +For more optimization hints take a look at the lwIP wiki. + +--- Zero-copy MACs + +To achieve zero-copy on transmit, the data passed to the raw API must +remain unchanged until sent. Because the send- (or write-)functions return +when the packets have been enqueued for sending, data must be kept stable +after that, too. + +This implies that PBUF_RAM/PBUF_POOL pbufs passed to raw-API send functions +must *not* be reused by the application unless their ref-count is 1. + +For no-copy pbufs (PBUF_ROM/PBUF_REF), data must be kept unchanged, too, +but the stack/driver will/must copy PBUF_REF'ed data when enqueueing, while +PBUF_ROM-pbufs are just enqueued (as ROM-data is expected to never change). + +Also, data passed to tcp_write without the copy-flag must not be changed! + +Therefore, be careful which type of PBUF you use and if you copy TCP data +or not! diff --git a/user/mpy/lib/lwip/doc/savannah.txt b/user/mpy/lib/lwip/doc/savannah.txt new file mode 100644 index 0000000..409905b --- /dev/null +++ b/user/mpy/lib/lwip/doc/savannah.txt @@ -0,0 +1,135 @@ +Daily Use Guide for using Savannah for lwIP + +Table of Contents: + +1 - Obtaining lwIP from the CVS repository +2 - Committers/developers CVS access using SSH (to be written) +3 - Merging from DEVEL branch to main trunk (stable branch) +4 - How to release lwIP + + + +1 Obtaining lwIP from the CVS repository +---------------------------------------- + +To perform an anonymous CVS checkout of the main trunk (this is where +bug fixes and incremental enhancements occur), do this: + +cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout lwip + +Or, obtain a stable branch (updated with bug fixes only) as follows: +cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ + -r STABLE-0_7 -d lwip-0.7 lwip + +Or, obtain a specific (fixed) release as follows: +cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ + -r STABLE-0_7_0 -d lwip-0.7.0 lwip + +3 Committers/developers CVS access using SSH +-------------------------------------------- + +The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption. +As such, CVS commits to the server occur through a SSH tunnel for project members. +To create a SSH2 key pair in UNIX-like environments, do this: + +ssh-keygen -t dsa + +Under Windows, a recommended SSH client is "PuTTY", freely available with good +documentation and a graphic user interface. Use its key generator. + +Now paste the id_dsa.pub contents into your Savannah account public key list. Wait +a while so that Savannah can update its configuration (This can take minutes). + +Try to login using SSH: + +ssh -v your_login@cvs.sv.gnu.org + +If it tells you: + +Authenticating with public key "your_key_name"... +Server refused to allocate pty + +then you could login; Savannah refuses to give you a shell - which is OK, as we +are allowed to use SSH for CVS only. Now, you should be able to do this: + +export CVS_RSH=ssh +cvs -z3 -d:ext:your_login@cvs.sv.gnu.org:/sources/lwip co lwip + +after which you can edit your local files with bug fixes or new features and +commit them. Make sure you know what you are doing when using CVS to make +changes on the repository. If in doubt, ask on the lwip-members mailing list. + +(If SSH asks about authenticity of the host, you can check the key + fingerprint against http://savannah.nongnu.org/cvs/?group=lwip) + + +3 Merging from DEVEL branch to main trunk (stable) +-------------------------------------------------- + +Merging is a delicate process in CVS and requires the +following disciplined steps in order to prevent conflicts +in the future. Conflicts can be hard to solve! + +Merging from branch A to branch B requires that the A branch +has a tag indicating the previous merger. This tag is called +'merged_from_A_to_B'. After merging, the tag is moved in the +A branch to remember this merger for future merge actions. + +IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE +REPOSITORY, THE TAG MUST BE SET ON THE SOURCE BRANCH OF THE +MERGE ACTION (REPLACING EXISTING TAGS WITH THE SAME NAME). + +Merge all changes in DEVEL since our last merge to main: + +In the working copy of the main trunk: +cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL + +(This will apply the changes between 'merged_from_DEVEL_to_main' +and 'DEVEL' to your work set of files) + +We can now commit the merge result. +cvs commit -R -m "Merged from DEVEL to main." + +If this worked out OK, we now move the tag in the DEVEL branch +to this merge point, so we can use this point for future merges: + +cvs rtag -F -r DEVEL merged_from_DEVEL_to_main lwip + +4 How to release lwIP +--------------------- + +First, checkout a clean copy of the branch to be released. Tag this set with +tag name "STABLE-0_6_3". (I use release number 0.6.3 throughout this example). + +Login CVS using pserver authentication, then export a clean copy of the +tagged tree. Export is similar to a checkout, except that the CVS metadata +is not created locally. + +export CVS_RSH=ssh +cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ + -r STABLE-0_6_3 -d lwip-0.6.3 lwip + +Archive this directory using tar, gzip'd, bzip2'd and zip'd. + +tar czvf lwip-0.6.3.tar.gz lwip-0.6.3 +tar cjvf lwip-0.6.3.tar.bz2 lwip-0.6.3 +zip -r lwip-0.6.3.zip lwip-0.6.3 + +Now, sign the archives with a detached GPG binary signature as follows: + +gpg -b lwip-0.6.3.tar.gz +gpg -b lwip-0.6.3.tar.bz2 +gpg -b lwip-0.6.3.zip + +Upload these files using anonymous FTP: +ncftp ftp://savannah.gnu.org/incoming/savannah/lwip + +ncftp>mput *0.6.3.* + +Additionally, you may post a news item on Savannah, like this: + +A new 0.6.3 release is now available here: +http://savannah.nongnu.org/files/?group=lwip&highlight=0.6.3 + +You will have to submit this via the user News interface, then approve +this via the Administrator News interface. \ No newline at end of file diff --git a/user/mpy/lib/lwip/doc/snmp_agent.txt b/user/mpy/lib/lwip/doc/snmp_agent.txt new file mode 100644 index 0000000..2653230 --- /dev/null +++ b/user/mpy/lib/lwip/doc/snmp_agent.txt @@ -0,0 +1,181 @@ +SNMPv1 agent for lwIP + +Author: Christiaan Simons + +This is a brief introduction how to use and configure the SNMP agent. +Note the agent uses the raw-API UDP interface so you may also want to +read rawapi.txt to gain a better understanding of the SNMP message handling. + +0 Agent Capabilities +==================== + +SNMPv1 per RFC1157 + This is an old(er) standard but is still widely supported. + For SNMPv2c and v3 have a greater complexity and need many + more lines of code. IMHO this breaks the idea of "lightweight IP". + + Note the S in SNMP stands for "Simple". Note that "Simple" is + relative. SNMP is simple compared to the complex ISO network + management protocols CMIP (Common Management Information Protocol) + and CMOT (CMip Over Tcp). + +MIB II per RFC1213 + The standard lwIP stack management information base. + This is a required MIB, so this is always enabled. + When builing lwIP without TCP, the mib-2.tcp group is omitted. + The groups EGP, CMOT and transmission are disabled by default. + + Most mib-2 objects are not writable except: + sysName, sysLocation, sysContact, snmpEnableAuthenTraps. + Writing to or changing the ARP and IP address and route + tables is not possible. + + Note lwIP has a very limited notion of IP routing. It currently + doen't have a route table and doesn't have a notion of the U,G,H flags. + Instead lwIP uses the interface list with only one default interface + acting as a single gateway interface (G) for the default route. + + The agent returns a "virtual table" with the default route 0.0.0.0 + for the default interface and network routes (no H) for each + network interface in the netif_list. + All routes are considered to be up (U). + +Loading additional MIBs + MIBs can only be added in compile-time, not in run-time. + There is no MIB compiler thus additional MIBs must be hand coded. + +Large SNMP message support + The packet decoding and encoding routines are designed + to use pbuf-chains. Larger payloads than the minimum + SNMP requirement of 484 octets are supported if the + PBUF_POOL_SIZE and IP_REASS_BUFSIZE are set to match your + local requirement. + +1 Building the Agent +==================== + +First of all you'll need to add the following define +to your local lwipopts.h: + +#define LWIP_SNMP 1 + +and add the source files in lwip/src/core/snmp +and some snmp headers in lwip/src/include/lwip to your makefile. + +Note you'll might need to adapt you network driver to update +the mib2 variables for your interface. + +2 Running the Agent +=================== + +The following function calls must be made in your program to +actually get the SNMP agent running. + +Before starting the agent you should supply pointers +to non-volatile memory for sysContact, sysLocation, +and snmpEnableAuthenTraps. You can do this by calling + +snmp_set_syscontact() +snmp_set_syslocation() +snmp_set_snmpenableauthentraps() + +Additionally you may want to set + +snmp_set_sysdescr() +snmp_set_sysobjid() (if you have a private MIB) +snmp_set_sysname() + +Also before starting the agent you need to setup +one or more trap destinations using these calls: + +snmp_trap_dst_enable(); +snmp_trap_dst_ip_set(); + +In the lwIP initialisation sequence call snmp_init() just after +the call to udp_init(). + +Exactly every 10 msec the SNMP uptime timestamp must be updated with +snmp_inc_sysuptime(). You should call this from a timer interrupt +or a timer signal handler depending on your runtime environment. + +An alternative way to update the SNMP uptime timestamp is to do a call like +snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but call to +a lower frequency). Another one is to not call snmp_inc_sysuptime() or +snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro. +This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside +snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only +when it's queried (any function which need "sysuptime" have to call +snmp_get_sysuptime). + + +3 Private MIBs +============== + +If want to extend the agent with your own private MIB you'll need to +add the following define to your local lwipopts.h: + +#define SNMP_PRIVATE_MIB 1 + +You must provide the private_mib.h and associated files yourself. +Note we don't have a "MIB compiler" that generates C source from a MIB, +so you're required to do some serious coding if you enable this! + +Note the lwIP enterprise ID (26381) is assigned to the lwIP project, +ALL OBJECT IDENTIFIERS LIVING UNDER THIS ID ARE ASSIGNED BY THE lwIP +MAINTAINERS! + +If you need to create your own private MIB you'll need +to apply for your own enterprise ID with IANA: http://www.iana.org/numbers.html + +You can set it by passing a struct snmp_obj_id to the agent +using snmp_set_sysobjid(&my_object_id), just before snmp_init(). + +Note the object identifiers for thes MIB-2 and your private MIB +tree must be kept in sorted ascending (lexicographical) order. +This to ensure correct getnext operation. + +An example for a private MIB is part of the "minimal Unix" project: +contrib/ports/unix/proj/minimal/lwip_prvmib.c + +The next chapter gives a more detailed description of the +MIB-2 tree and the optional private MIB. + +4 The Gory Details +================== + +4.0 Object identifiers and the MIB tree. + +We have three distinct parts for all object identifiers: + +The prefix + .iso.org.dod.internet + +the middle part + .mgmt.mib-2.ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress + +and the index part + .1.192.168.0.1 + +Objects located above the .internet hierarchy aren't supported. +Currently only the .mgmt sub-tree is available and +when the SNMP_PRIVATE_MIB is enabled the .private tree +becomes available too. + +Object identifiers from incoming requests are checked +for a matching prefix, middle part and index part +or are expanded(*) for GetNext requests with short +or inexisting names in the request. +(* we call this "expansion" but this also +resembles the "auto-completion" operation) + +The middle part is usually located in ROM (const) +to preserve precious RAM on small microcontrollers. +However RAM location is possible for a dynamically +changing private tree. + +The index part is handled by functions which in +turn use dynamically allocated index trees from RAM. +These trees are updated by e.g. the etharp code +when new entries are made or removed form the ARP cache. + +/** @todo more gory details */ diff --git a/user/mpy/lib/lwip/doc/sys_arch.txt b/user/mpy/lib/lwip/doc/sys_arch.txt new file mode 100644 index 0000000..847cd77 --- /dev/null +++ b/user/mpy/lib/lwip/doc/sys_arch.txt @@ -0,0 +1,267 @@ +sys_arch interface for lwIP 0.6++ + +Author: Adam Dunkels + +The operating system emulation layer provides a common interface +between the lwIP code and the underlying operating system kernel. The +general idea is that porting lwIP to new architectures requires only +small changes to a few header files and a new sys_arch +implementation. It is also possible to do a sys_arch implementation +that does not rely on any underlying operating system. + +The sys_arch provides semaphores and mailboxes to lwIP. For the full +lwIP functionality, multiple threads support can be implemented in the +sys_arch, but this is not required for the basic lwIP +functionality. Previous versions of lwIP required the sys_arch to +implement timer scheduling as well but as of lwIP 0.5 this is +implemented in a higher layer. + +In addition to the source file providing the functionality of sys_arch, +the OS emulation layer must provide several header files defining +macros used throughout lwip. The files required and the macros they +must define are listed below the sys_arch description. + +Semaphores can be either counting or binary - lwIP works with both +kinds. Mailboxes are used for message passing and can be implemented +either as a queue which allows multiple messages to be posted to a +mailbox, or as a rendez-vous point where only one message can be +posted at a time. lwIP works with both kinds, but the former type will +be more efficient. A message in a mailbox is just a pointer, nothing +more. + +Semaphores are represented by the type "sys_sem_t" which is typedef'd +in the sys_arch.h file. Mailboxes are equivalently represented by the +type "sys_mbox_t". lwIP does not place any restrictions on how +sys_sem_t or sys_mbox_t are represented internally. + +Since lwIP 1.4.0, semaphore and mailbox functions are prototyped in a way that +allows both using pointers or actual OS structures to be used. This way, memory +required for such types can be either allocated in place (globally or on the +stack) or on the heap (allocated internally in the "*_new()" functions). + +The following functions must be implemented by the sys_arch: + +- void sys_init(void) + + Is called to initialize the sys_arch layer. + +- err_t sys_sem_new(sys_sem_t *sem, u8_t count) + + Creates a new semaphore. The semaphore is allocated to the memory that 'sem' + points to (which can be both a pointer or the actual OS structure). + The "count" argument specifies the initial state of the semaphore (which is + either 0 or 1). + If the semaphore has been created, ERR_OK should be returned. Returning any + other error will provide a hint what went wrong, but except for assertions, + no real error handling is implemented. + +- void sys_sem_free(sys_sem_t *sem) + + Deallocates a semaphore. + +- void sys_sem_signal(sys_sem_t *sem) + + Signals a semaphore. + +- u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) + + Blocks the thread while waiting for the semaphore to be + signaled. If the "timeout" argument is non-zero, the thread should + only be blocked for the specified time (measured in + milliseconds). If the "timeout" argument is zero, the thread should be + blocked until the semaphore is signalled. + + If the timeout argument is non-zero, the return value is the number of + milliseconds spent waiting for the semaphore to be signaled. If the + semaphore wasn't signaled within the specified time, the return value is + SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore + (i.e., it was already signaled), the function may return zero. + + Notice that lwIP implements a function with a similar name, + sys_sem_wait(), that uses the sys_arch_sem_wait() function. + +- int sys_sem_valid(sys_sem_t *sem) + + Returns 1 if the semaphore is valid, 0 if it is not valid. + When using pointers, a simple way is to check the pointer for != NULL. + When directly using OS structures, implementing this may be more complex. + This may also be a define, in which case the function is not prototyped. + +- void sys_sem_set_invalid(sys_sem_t *sem) + + Invalidate a semaphore so that sys_sem_valid() returns 0. + ATTENTION: This does NOT mean that the semaphore shall be deallocated: + sys_sem_free() is always called before calling this function! + This may also be a define, in which case the function is not prototyped. + +- err_t sys_mbox_new(sys_mbox_t *mbox, int size) + + Creates an empty mailbox for maximum "size" elements. Elements stored + in mailboxes are pointers. You have to define macros "_MBOX_SIZE" + in your lwipopts.h, or ignore this parameter in your implementation + and use a default size. + If the mailbox has been created, ERR_OK should be returned. Returning any + other error will provide a hint what went wrong, but except for assertions, + no real error handling is implemented. + +- void sys_mbox_free(sys_mbox_t *mbox) + + Deallocates a mailbox. If there are messages still present in the + mailbox when the mailbox is deallocated, it is an indication of a + programming error in lwIP and the developer should be notified. + +- void sys_mbox_post(sys_mbox_t *mbox, void *msg) + + Posts the "msg" to the mailbox. This function have to block until + the "msg" is really posted. + +- err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) + + Try to post the "msg" to the mailbox. Returns ERR_MEM if this one + is full, else, ERR_OK if the "msg" is posted. + +- u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) + + Blocks the thread until a message arrives in the mailbox, but does + not block the thread longer than "timeout" milliseconds (similar to + the sys_arch_sem_wait() function). If "timeout" is 0, the thread should + be blocked until a message arrives. The "msg" argument is a result + parameter that is set by the function (i.e., by doing "*msg = + ptr"). The "msg" parameter maybe NULL to indicate that the message + should be dropped. + + The return values are the same as for the sys_arch_sem_wait() function: + Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a + timeout. + + Note that a function with a similar name, sys_mbox_fetch(), is + implemented by lwIP. + +- u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) + + This is similar to sys_arch_mbox_fetch, however if a message is not + present in the mailbox, it immediately returns with the code + SYS_MBOX_EMPTY. On success 0 is returned. + + To allow for efficient implementations, this can be defined as a + function-like macro in sys_arch.h instead of a normal function. For + example, a naive implementation could be: + #define sys_arch_mbox_tryfetch(mbox,msg) \ + sys_arch_mbox_fetch(mbox,msg,1) + although this would introduce unnecessary delays. + +- int sys_mbox_valid(sys_mbox_t *mbox) + + Returns 1 if the mailbox is valid, 0 if it is not valid. + When using pointers, a simple way is to check the pointer for != NULL. + When directly using OS structures, implementing this may be more complex. + This may also be a define, in which case the function is not prototyped. + +- void sys_mbox_set_invalid(sys_mbox_t *mbox) + + Invalidate a mailbox so that sys_mbox_valid() returns 0. + ATTENTION: This does NOT mean that the mailbox shall be deallocated: + sys_mbox_free() is always called before calling this function! + This may also be a define, in which case the function is not prototyped. + +If threads are supported by the underlying operating system and if +such functionality is needed in lwIP, the following function will have +to be implemented as well: + +- sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio) + + Starts a new thread named "name" with priority "prio" that will begin its + execution in the function "thread()". The "arg" argument will be passed as an + argument to the thread() function. The stack size to used for this thread is + the "stacksize" parameter. The id of the new thread is returned. Both the id + and the priority are system dependent. + +- sys_prot_t sys_arch_protect(void) + + This optional function does a "fast" critical region protection and returns + the previous protection level. This function is only called during very short + critical regions. An embedded system which supports ISR-based drivers might + want to implement this function by disabling interrupts. Task-based systems + might want to implement this by using a mutex or disabling tasking. This + function should support recursive calls from the same task or interrupt. In + other words, sys_arch_protect() could be called while already protected. In + that case the return value indicates that it is already protected. + + sys_arch_protect() is only required if your port is supporting an operating + system. + +- void sys_arch_unprotect(sys_prot_t pval) + + This optional function does a "fast" set of critical region protection to the + value specified by pval. See the documentation for sys_arch_protect() for + more information. This function is only required if your port is supporting + an operating system. + +For some configurations, you also need: + +- u32_t sys_now(void) + + This optional function returns the current time in milliseconds (don't care + for wraparound, this is only used for time diffs). + Not implementing this function means you cannot use some modules (e.g. TCP + timestamps, internal timeouts for NO_SYS==1). + + +Note: + +Be carefull with using mem_malloc() in sys_arch. When malloc() refers to +mem_malloc() you can run into a circular function call problem. In mem.c +mem_init() tries to allcate a semaphore using mem_malloc, which of course +can't be performed when sys_arch uses mem_malloc. + +------------------------------------------------------------------------------- +Additional files required for the "OS support" emulation layer: +------------------------------------------------------------------------------- + +cc.h - Architecture environment, some compiler specific, some + environment specific (probably should move env stuff + to sys_arch.h.) + + Typedefs for the types used by lwip - + u8_t, s8_t, u16_t, s16_t, u32_t, s32_t, mem_ptr_t + + Compiler hints for packing lwip's structures - + PACK_STRUCT_FIELD(x) + PACK_STRUCT_STRUCT + PACK_STRUCT_BEGIN + PACK_STRUCT_END + + Platform specific diagnostic output - + LWIP_PLATFORM_DIAG(x) - non-fatal, print a message. + LWIP_PLATFORM_ASSERT(x) - fatal, print message and abandon execution. + Portability defines for printf formatters: + U16_F, S16_F, X16_F, U32_F, S32_F, X32_F, SZT_F + + "lightweight" synchronization mechanisms - + SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable. + SYS_ARCH_PROTECT(x) - enter protection mode. + SYS_ARCH_UNPROTECT(x) - leave protection mode. + + If the compiler does not provide memset() this file must include a + definition of it, or include a file which defines it. + + This file must either include a system-local which defines + the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO + to make lwip/arch.h define the codes which are used throughout. + + +perf.h - Architecture specific performance measurement. + Measurement calls made throughout lwip, these can be defined to nothing. + PERF_START - start measuring something. + PERF_STOP(x) - stop measuring something, and record the result. + +sys_arch.h - Tied to sys_arch.c + + Arch dependent types for the following objects: + sys_sem_t, sys_mbox_t, sys_thread_t, + And, optionally: + sys_prot_t + + Defines to set vars of sys_mbox_t and sys_sem_t to NULL. + SYS_MBOX_NULL NULL + SYS_SEM_NULL NULL diff --git a/user/mpy/lib/lwip/src/FILES b/user/mpy/lib/lwip/src/FILES new file mode 100644 index 0000000..952aeab --- /dev/null +++ b/user/mpy/lib/lwip/src/FILES @@ -0,0 +1,13 @@ +api/ - The code for the high-level wrapper API. Not needed if + you use the lowel-level call-back/raw API. + +core/ - The core of the TPC/IP stack; protocol implementations, + memory and buffer management, and the low-level raw API. + +include/ - lwIP include files. + +netif/ - Generic network interface device drivers are kept here, + as well as the ARP module. + +For more information on the various subdirectories, check the FILES +file in each directory. diff --git a/user/mpy/lib/lwip/src/api/api_lib.c b/user/mpy/lib/lwip/src/api/api_lib.c new file mode 100644 index 0000000..4bdf08e --- /dev/null +++ b/user/mpy/lib/lwip/src/api/api_lib.c @@ -0,0 +1,780 @@ +/** + * @file + * Sequential API External module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +/* This is the part of the API that is linked with + the application */ + +#include "lwip/opt.h" + +#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/api.h" +#include "lwip/tcpip.h" +#include "lwip/memp.h" + +#include "lwip/ip.h" +#include "lwip/raw.h" +#include "lwip/udp.h" +#include "lwip/tcp.h" + +#include + +/** + * Create a new netconn (of a specific type) that has a callback function. + * The corresponding pcb is also created. + * + * @param t the type of 'connection' to create (@see enum netconn_type) + * @param proto the IP protocol for RAW IP pcbs + * @param callback a function to call on status changes (RX available, TX'ed) + * @return a newly allocated struct netconn or + * NULL on memory error + */ +struct netconn* +netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_callback callback) +{ + struct netconn *conn; + struct api_msg msg; + + conn = netconn_alloc(t, callback); + if (conn != NULL) { + msg.function = do_newconn; + msg.msg.msg.n.proto = proto; + msg.msg.conn = conn; + if (TCPIP_APIMSG(&msg) != ERR_OK) { + LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL); + LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed)); + LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox)); +#if LWIP_TCP + LWIP_ASSERT("conn->acceptmbox shouldn't exist", !sys_mbox_valid(&conn->acceptmbox)); +#endif /* LWIP_TCP */ + sys_sem_free(&conn->op_completed); + sys_mbox_free(&conn->recvmbox); + memp_free(MEMP_NETCONN, conn); + return NULL; + } + } + return conn; +} + +/** + * Close a netconn 'connection' and free its resources. + * UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate + * after this returns. + * + * @param conn the netconn to delete + * @return ERR_OK if the connection was deleted + */ +err_t +netconn_delete(struct netconn *conn) +{ + struct api_msg msg; + + /* No ASSERT here because possible to get a (conn == NULL) if we got an accept error */ + if (conn == NULL) { + return ERR_OK; + } + + msg.function = do_delconn; + msg.msg.conn = conn; + tcpip_apimsg(&msg); + + netconn_free(conn); + + /* don't care for return value of do_delconn since it only calls void functions */ + + return ERR_OK; +} + +/** + * Get the local or remote IP address and port of a netconn. + * For RAW netconns, this returns the protocol instead of a port! + * + * @param conn the netconn to query + * @param addr a pointer to which to save the IP address + * @param port a pointer to which to save the port (or protocol for RAW) + * @param local 1 to get the local IP address, 0 to get the remote one + * @return ERR_CONN for invalid connections + * ERR_OK if the information was retrieved + */ +err_t +netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_getaddr: invalid conn", (conn != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_getaddr: invalid addr", (addr != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_getaddr: invalid port", (port != NULL), return ERR_ARG;); + + msg.function = do_getaddr; + msg.msg.conn = conn; + msg.msg.msg.ad.ipaddr = addr; + msg.msg.msg.ad.port = port; + msg.msg.msg.ad.local = local; + err = TCPIP_APIMSG(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Bind a netconn to a specific local IP address and port. + * Binding one netconn twice might not always be checked correctly! + * + * @param conn the netconn to bind + * @param addr the local IP address to bind the netconn to (use IP_ADDR_ANY + * to bind to all addresses) + * @param port the local port to bind the netconn to (not used for RAW) + * @return ERR_OK if bound, any other err_t on failure + */ +err_t +netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_bind: invalid conn", (conn != NULL), return ERR_ARG;); + + msg.function = do_bind; + msg.msg.conn = conn; + msg.msg.msg.bc.ipaddr = addr; + msg.msg.msg.bc.port = port; + err = TCPIP_APIMSG(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Connect a netconn to a specific remote IP address and port. + * + * @param conn the netconn to connect + * @param addr the remote IP address to connect to + * @param port the remote port to connect to (no used for RAW) + * @return ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise + */ +err_t +netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_connect: invalid conn", (conn != NULL), return ERR_ARG;); + + msg.function = do_connect; + msg.msg.conn = conn; + msg.msg.msg.bc.ipaddr = addr; + msg.msg.msg.bc.port = port; + /* This is the only function which need to not block tcpip_thread */ + err = tcpip_apimsg(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Disconnect a netconn from its current peer (only valid for UDP netconns). + * + * @param conn the netconn to disconnect + * @return TODO: return value is not set here... + */ +err_t +netconn_disconnect(struct netconn *conn) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;); + + msg.function = do_disconnect; + msg.msg.conn = conn; + err = TCPIP_APIMSG(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Set a TCP netconn into listen mode + * + * @param conn the tcp netconn to set to listen mode + * @param backlog the listen backlog, only used if TCP_LISTEN_BACKLOG==1 + * @return ERR_OK if the netconn was set to listen (UDP and RAW netconns + * don't return any error (yet?)) + */ +err_t +netconn_listen_with_backlog(struct netconn *conn, u8_t backlog) +{ +#if LWIP_TCP + struct api_msg msg; + err_t err; + + /* This does no harm. If TCP_LISTEN_BACKLOG is off, backlog is unused. */ + LWIP_UNUSED_ARG(backlog); + + LWIP_ERROR("netconn_listen: invalid conn", (conn != NULL), return ERR_ARG;); + + msg.function = do_listen; + msg.msg.conn = conn; +#if TCP_LISTEN_BACKLOG + msg.msg.msg.lb.backlog = backlog; +#endif /* TCP_LISTEN_BACKLOG */ + err = TCPIP_APIMSG(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +#else /* LWIP_TCP */ + LWIP_UNUSED_ARG(conn); + LWIP_UNUSED_ARG(backlog); + return ERR_ARG; +#endif /* LWIP_TCP */ +} + +/** + * Accept a new connection on a TCP listening netconn. + * + * @param conn the TCP listen netconn + * @param new_conn pointer where the new connection is stored + * @return ERR_OK if a new connection has been received or an error + * code otherwise + */ +err_t +netconn_accept(struct netconn *conn, struct netconn **new_conn) +{ +#if LWIP_TCP + struct netconn *newconn; + err_t err; +#if TCP_LISTEN_BACKLOG + struct api_msg msg; +#endif /* TCP_LISTEN_BACKLOG */ + + LWIP_ERROR("netconn_accept: invalid pointer", (new_conn != NULL), return ERR_ARG;); + *new_conn = NULL; + LWIP_ERROR("netconn_accept: invalid conn", (conn != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_accept: invalid acceptmbox", sys_mbox_valid(&conn->acceptmbox), return ERR_ARG;); + + err = conn->last_err; + if (ERR_IS_FATAL(err)) { + /* don't recv on fatal errors: this might block the application task + waiting on acceptmbox forever! */ + return err; + } + +#if LWIP_SO_RCVTIMEO + if (sys_arch_mbox_fetch(&conn->acceptmbox, (void **)&newconn, conn->recv_timeout) == SYS_ARCH_TIMEOUT) { + NETCONN_SET_SAFE_ERR(conn, ERR_TIMEOUT); + return ERR_TIMEOUT; + } +#else + sys_arch_mbox_fetch(&conn->acceptmbox, (void **)&newconn, 0); +#endif /* LWIP_SO_RCVTIMEO*/ + /* Register event with callback */ + API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0); + + if (newconn == NULL) { + /* connection has been aborted */ + NETCONN_SET_SAFE_ERR(conn, ERR_ABRT); + return ERR_ABRT; + } +#if TCP_LISTEN_BACKLOG + /* Let the stack know that we have accepted the connection. */ + msg.function = do_recv; + msg.msg.conn = conn; + /* don't care for the return value of do_recv */ + TCPIP_APIMSG(&msg); +#endif /* TCP_LISTEN_BACKLOG */ + + *new_conn = newconn; + /* don't set conn->last_err: it's only ERR_OK, anyway */ + return ERR_OK; +#else /* LWIP_TCP */ + LWIP_UNUSED_ARG(conn); + LWIP_UNUSED_ARG(new_conn); + return ERR_ARG; +#endif /* LWIP_TCP */ +} + +/** + * Receive data: actual implementation that doesn't care whether pbuf or netbuf + * is received + * + * @param conn the netconn from which to receive data + * @param new_buf pointer where a new pbuf/netbuf is stored when received data + * @return ERR_OK if data has been received, an error code otherwise (timeout, + * memory error or another error) + */ +static err_t +netconn_recv_data(struct netconn *conn, void **new_buf) +{ + void *buf = NULL; + u16_t len; + err_t err; +#if LWIP_TCP + struct api_msg msg; +#endif /* LWIP_TCP */ + + LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;); + *new_buf = NULL; + LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;); + + err = conn->last_err; + if (ERR_IS_FATAL(err)) { + /* don't recv on fatal errors: this might block the application task + waiting on recvmbox forever! */ + /* @todo: this does not allow us to fetch data that has been put into recvmbox + before the fatal error occurred - is that a problem? */ + return err; + } + +#if LWIP_SO_RCVTIMEO + if (sys_arch_mbox_fetch(&conn->recvmbox, &buf, conn->recv_timeout) == SYS_ARCH_TIMEOUT) { + NETCONN_SET_SAFE_ERR(conn, ERR_TIMEOUT); + return ERR_TIMEOUT; + } +#else + sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); +#endif /* LWIP_SO_RCVTIMEO*/ + +#if LWIP_TCP +#if (LWIP_UDP || LWIP_RAW) + if (conn->type == NETCONN_TCP) +#endif /* (LWIP_UDP || LWIP_RAW) */ + { + if (!netconn_get_noautorecved(conn) || (buf == NULL)) { + /* Let the stack know that we have taken the data. */ + /* TODO: Speedup: Don't block and wait for the answer here + (to prevent multiple thread-switches). */ + msg.function = do_recv; + msg.msg.conn = conn; + if (buf != NULL) { + msg.msg.msg.r.len = ((struct pbuf *)buf)->tot_len; + } else { + msg.msg.msg.r.len = 1; + } + /* don't care for the return value of do_recv */ + TCPIP_APIMSG(&msg); + } + + /* If we are closed, we indicate that we no longer wish to use the socket */ + if (buf == NULL) { + API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0); + /* Avoid to lose any previous error code */ + NETCONN_SET_SAFE_ERR(conn, ERR_CLSD); + return ERR_CLSD; + } + len = ((struct pbuf *)buf)->tot_len; + } +#endif /* LWIP_TCP */ +#if LWIP_TCP && (LWIP_UDP || LWIP_RAW) + else +#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */ +#if (LWIP_UDP || LWIP_RAW) + { + LWIP_ASSERT("buf != NULL", buf != NULL); + len = netbuf_len((struct netbuf *)buf); + } +#endif /* (LWIP_UDP || LWIP_RAW) */ + +#if LWIP_SO_RCVBUF + SYS_ARCH_DEC(conn->recv_avail, len); +#endif /* LWIP_SO_RCVBUF */ + /* Register event with callback */ + API_EVENT(conn, NETCONN_EVT_RCVMINUS, len); + + LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_recv_data: received %p, len=%"U16_F"\n", buf, len)); + + *new_buf = buf; + /* don't set conn->last_err: it's only ERR_OK, anyway */ + return ERR_OK; +} + +/** + * Receive data (in form of a pbuf) from a TCP netconn + * + * @param conn the netconn from which to receive data + * @param new_buf pointer where a new pbuf is stored when received data + * @return ERR_OK if data has been received, an error code otherwise (timeout, + * memory error or another error) + * ERR_ARG if conn is not a TCP netconn + */ +err_t +netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf) +{ + LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL) && + netconn_type(conn) == NETCONN_TCP, return ERR_ARG;); + + return netconn_recv_data(conn, (void **)new_buf); +} + +/** + * Receive data (in form of a netbuf containing a packet buffer) from a netconn + * + * @param conn the netconn from which to receive data + * @param new_buf pointer where a new netbuf is stored when received data + * @return ERR_OK if data has been received, an error code otherwise (timeout, + * memory error or another error) + */ +err_t +netconn_recv(struct netconn *conn, struct netbuf **new_buf) +{ +#if LWIP_TCP + struct netbuf *buf = NULL; + err_t err; +#endif /* LWIP_TCP */ + + LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;); + *new_buf = NULL; + LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;); + +#if LWIP_TCP +#if (LWIP_UDP || LWIP_RAW) + if (conn->type == NETCONN_TCP) +#endif /* (LWIP_UDP || LWIP_RAW) */ + { + struct pbuf *p = NULL; + /* This is not a listening netconn, since recvmbox is set */ + + buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); + if (buf == NULL) { + NETCONN_SET_SAFE_ERR(conn, ERR_MEM); + return ERR_MEM; + } + + err = netconn_recv_data(conn, (void **)&p); + if (err != ERR_OK) { + memp_free(MEMP_NETBUF, buf); + return err; + } + LWIP_ASSERT("p != NULL", p != NULL); + + buf->p = p; + buf->ptr = p; + buf->port = 0; + ip_addr_set_any(&buf->addr); + *new_buf = buf; + /* don't set conn->last_err: it's only ERR_OK, anyway */ + return ERR_OK; + } +#endif /* LWIP_TCP */ +#if LWIP_TCP && (LWIP_UDP || LWIP_RAW) + else +#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */ + { +#if (LWIP_UDP || LWIP_RAW) + return netconn_recv_data(conn, (void **)new_buf); +#endif /* (LWIP_UDP || LWIP_RAW) */ + } +} + +/** + * TCP: update the receive window: by calling this, the application + * tells the stack that it has processed data and is able to accept + * new data. + * ATTENTION: use with care, this is mainly used for sockets! + * Can only be used when calling netconn_set_noautorecved(conn, 1) before. + * + * @param conn the netconn for which to update the receive window + * @param length amount of data processed (ATTENTION: this must be accurate!) + */ +void +netconn_recved(struct netconn *conn, u32_t length) +{ +#if LWIP_TCP + if ((conn != NULL) && (conn->type == NETCONN_TCP) && + (netconn_get_noautorecved(conn))) { + struct api_msg msg; + /* Let the stack know that we have taken the data. */ + /* TODO: Speedup: Don't block and wait for the answer here + (to prevent multiple thread-switches). */ + msg.function = do_recv; + msg.msg.conn = conn; + msg.msg.msg.r.len = length; + /* don't care for the return value of do_recv */ + TCPIP_APIMSG(&msg); + } +#else /* LWIP_TCP */ + LWIP_UNUSED_ARG(conn); + LWIP_UNUSED_ARG(length); +#endif /* LWIP_TCP */ +} + +/** + * Send data (in form of a netbuf) to a specific remote IP address and port. + * Only to be used for UDP and RAW netconns (not TCP). + * + * @param conn the netconn over which to send data + * @param buf a netbuf containing the data to send + * @param addr the remote IP address to which to send the data + * @param port the remote port to which to send the data + * @return ERR_OK if data was sent, any other err_t on error + */ +err_t +netconn_sendto(struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port) +{ + if (buf != NULL) { + ip_addr_set(&buf->addr, addr); + buf->port = port; + return netconn_send(conn, buf); + } + return ERR_VAL; +} + +/** + * Send data over a UDP or RAW netconn (that is already connected). + * + * @param conn the UDP or RAW netconn over which to send data + * @param buf a netbuf containing the data to send + * @return ERR_OK if data was sent, any other err_t on error + */ +err_t +netconn_send(struct netconn *conn, struct netbuf *buf) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_send: invalid conn", (conn != NULL), return ERR_ARG;); + + LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %"U16_F" bytes\n", buf->p->tot_len)); + msg.function = do_send; + msg.msg.conn = conn; + msg.msg.msg.b = buf; + err = TCPIP_APIMSG(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Send data over a TCP netconn. + * + * @param conn the TCP netconn over which to send data + * @param dataptr pointer to the application buffer that contains the data to send + * @param size size of the application data to send + * @param apiflags combination of following flags : + * - NETCONN_COPY: data will be copied into memory belonging to the stack + * - NETCONN_MORE: for TCP connection, PSH flag will be set on last segment sent + * - NETCONN_DONTBLOCK: only write the data if all dat can be written at once + * @param bytes_written pointer to a location that receives the number of written bytes + * @return ERR_OK if data was sent, any other err_t on error + */ +err_t +netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, + u8_t apiflags, size_t *bytes_written) +{ + struct api_msg msg; + err_t err; + u8_t dontblock; + + LWIP_ERROR("netconn_write: invalid conn", (conn != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_write: invalid conn->type", (conn->type == NETCONN_TCP), return ERR_VAL;); + if (size == 0) { + return ERR_OK; + } + dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK); + if (dontblock && !bytes_written) { + /* This implies netconn_write() cannot be used for non-blocking send, since + it has no way to return the number of bytes written. */ + return ERR_VAL; + } + + /* non-blocking write sends as much */ + msg.function = do_write; + msg.msg.conn = conn; + msg.msg.msg.w.dataptr = dataptr; + msg.msg.msg.w.apiflags = apiflags; + msg.msg.msg.w.len = size; +#if LWIP_SO_SNDTIMEO + if (conn->send_timeout != 0) { + /* get the time we started, which is later compared to + sys_now() + conn->send_timeout */ + msg.msg.msg.w.time_started = sys_now(); + } else { + msg.msg.msg.w.time_started = 0; + } +#endif /* LWIP_SO_SNDTIMEO */ + + /* For locking the core: this _can_ be delayed on low memory/low send buffer, + but if it is, this is done inside api_msg.c:do_write(), so we can use the + non-blocking version here. */ + err = TCPIP_APIMSG(&msg); + if ((err == ERR_OK) && (bytes_written != NULL)) { + if (dontblock +#if LWIP_SO_SNDTIMEO + || (conn->send_timeout != 0) +#endif /* LWIP_SO_SNDTIMEO */ + ) { + /* nonblocking write: maybe the data has been sent partly */ + *bytes_written = msg.msg.msg.w.len; + } else { + /* blocking call succeeded: all data has been sent if it */ + *bytes_written = size; + } + } + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Close ot shutdown a TCP netconn (doesn't delete it). + * + * @param conn the TCP netconn to close or shutdown + * @param how fully close or only shutdown one side? + * @return ERR_OK if the netconn was closed, any other err_t on error + */ +static err_t +netconn_close_shutdown(struct netconn *conn, u8_t how) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_close: invalid conn", (conn != NULL), return ERR_ARG;); + + msg.function = do_close; + msg.msg.conn = conn; + /* shutting down both ends is the same as closing */ + msg.msg.msg.sd.shut = how; + /* because of the LWIP_TCPIP_CORE_LOCKING implementation of do_close, + don't use TCPIP_APIMSG here */ + err = tcpip_apimsg(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} + +/** + * Close a TCP netconn (doesn't delete it). + * + * @param conn the TCP netconn to close + * @return ERR_OK if the netconn was closed, any other err_t on error + */ +err_t +netconn_close(struct netconn *conn) +{ + /* shutting down both ends is the same as closing */ + return netconn_close_shutdown(conn, NETCONN_SHUT_RDWR); +} + +/** + * Shut down one or both sides of a TCP netconn (doesn't delete it). + * + * @param conn the TCP netconn to shut down + * @return ERR_OK if the netconn was closed, any other err_t on error + */ +err_t +netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx) +{ + return netconn_close_shutdown(conn, (shut_rx ? NETCONN_SHUT_RD : 0) | (shut_tx ? NETCONN_SHUT_WR : 0)); +} + +#if LWIP_IGMP +/** + * Join multicast groups for UDP netconns. + * + * @param conn the UDP netconn for which to change multicast addresses + * @param multiaddr IP address of the multicast group to join or leave + * @param netif_addr the IP address of the network interface on which to send + * the igmp message + * @param join_or_leave flag whether to send a join- or leave-message + * @return ERR_OK if the action was taken, any err_t on error + */ +err_t +netconn_join_leave_group(struct netconn *conn, + ip_addr_t *multiaddr, + ip_addr_t *netif_addr, + enum netconn_igmp join_or_leave) +{ + struct api_msg msg; + err_t err; + + LWIP_ERROR("netconn_join_leave_group: invalid conn", (conn != NULL), return ERR_ARG;); + + msg.function = do_join_leave_group; + msg.msg.conn = conn; + msg.msg.msg.jl.multiaddr = multiaddr; + msg.msg.msg.jl.netif_addr = netif_addr; + msg.msg.msg.jl.join_or_leave = join_or_leave; + err = TCPIP_APIMSG(&msg); + + NETCONN_SET_SAFE_ERR(conn, err); + return err; +} +#endif /* LWIP_IGMP */ + +#if LWIP_DNS +/** + * Execute a DNS query, only one IP address is returned + * + * @param name a string representation of the DNS host name to query + * @param addr a preallocated ip_addr_t where to store the resolved IP address + * @return ERR_OK: resolving succeeded + * ERR_MEM: memory error, try again later + * ERR_ARG: dns client not initialized or invalid hostname + * ERR_VAL: dns server response was invalid + */ +err_t +netconn_gethostbyname(const char *name, ip_addr_t *addr) +{ + struct dns_api_msg msg; + err_t err; + sys_sem_t sem; + + LWIP_ERROR("netconn_gethostbyname: invalid name", (name != NULL), return ERR_ARG;); + LWIP_ERROR("netconn_gethostbyname: invalid addr", (addr != NULL), return ERR_ARG;); + + err = sys_sem_new(&sem, 0); + if (err != ERR_OK) { + return err; + } + + msg.name = name; + msg.addr = addr; + msg.err = &err; + msg.sem = &sem; + + tcpip_callback(do_gethostbyname, &msg); + sys_sem_wait(&sem); + sys_sem_free(&sem); + + return err; +} +#endif /* LWIP_DNS*/ + +#endif /* LWIP_NETCONN */ diff --git a/user/mpy/lib/lwip/src/api/api_msg.c b/user/mpy/lib/lwip/src/api/api_msg.c new file mode 100644 index 0000000..d4e44b9 --- /dev/null +++ b/user/mpy/lib/lwip/src/api/api_msg.c @@ -0,0 +1,1565 @@ +/** + * @file + * Sequential API Internal module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/api_msg.h" + +#include "lwip/ip.h" +#include "lwip/udp.h" +#include "lwip/tcp.h" +#include "lwip/raw.h" + +#include "lwip/memp.h" +#include "lwip/tcpip.h" +#include "lwip/igmp.h" +#include "lwip/dns.h" + +#include + +#define SET_NONBLOCKING_CONNECT(conn, val) do { if(val) { \ + (conn)->flags |= NETCONN_FLAG_IN_NONBLOCKING_CONNECT; \ +} else { \ + (conn)->flags &= ~ NETCONN_FLAG_IN_NONBLOCKING_CONNECT; }} while(0) +#define IN_NONBLOCKING_CONNECT(conn) (((conn)->flags & NETCONN_FLAG_IN_NONBLOCKING_CONNECT) != 0) + +/* forward declarations */ +#if LWIP_TCP +static err_t do_writemore(struct netconn *conn); +static void do_close_internal(struct netconn *conn); +#endif + +#if LWIP_RAW +/** + * Receive callback function for RAW netconns. + * Doesn't 'eat' the packet, only references it and sends it to + * conn->recvmbox + * + * @see raw.h (struct raw_pcb.recv) for parameters and return value + */ +static u8_t +recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, + ip_addr_t *addr) +{ + struct pbuf *q; + struct netbuf *buf; + struct netconn *conn; + + LWIP_UNUSED_ARG(addr); + conn = (struct netconn *)arg; + + if ((conn != NULL) && sys_mbox_valid(&conn->recvmbox)) { +#if LWIP_SO_RCVBUF + int recv_avail; + SYS_ARCH_GET(conn->recv_avail, recv_avail); + if ((recv_avail + (int)(p->tot_len)) > conn->recv_bufsize) { + return 0; + } +#endif /* LWIP_SO_RCVBUF */ + /* copy the whole packet into new pbufs */ + q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); + if(q != NULL) { + if (pbuf_copy(q, p) != ERR_OK) { + pbuf_free(q); + q = NULL; + } + } + + if (q != NULL) { + u16_t len; + buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); + if (buf == NULL) { + pbuf_free(q); + return 0; + } + + buf->p = q; + buf->ptr = q; + ip_addr_copy(buf->addr, *ip_current_src_addr()); + buf->port = pcb->protocol; + + len = q->tot_len; + if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) { + netbuf_delete(buf); + return 0; + } else { +#if LWIP_SO_RCVBUF + SYS_ARCH_INC(conn->recv_avail, len); +#endif /* LWIP_SO_RCVBUF */ + /* Register event with callback */ + API_EVENT(conn, NETCONN_EVT_RCVPLUS, len); + } + } + } + + return 0; /* do not eat the packet */ +} +#endif /* LWIP_RAW*/ + +#if LWIP_UDP +/** + * Receive callback function for UDP netconns. + * Posts the packet to conn->recvmbox or deletes it on memory error. + * + * @see udp.h (struct udp_pcb.recv) for parameters + */ +static void +recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *addr, u16_t port) +{ + struct netbuf *buf; + struct netconn *conn; + u16_t len; +#if LWIP_SO_RCVBUF + int recv_avail; +#endif /* LWIP_SO_RCVBUF */ + + LWIP_UNUSED_ARG(pcb); /* only used for asserts... */ + LWIP_ASSERT("recv_udp must have a pcb argument", pcb != NULL); + LWIP_ASSERT("recv_udp must have an argument", arg != NULL); + conn = (struct netconn *)arg; + LWIP_ASSERT("recv_udp: recv for wrong pcb!", conn->pcb.udp == pcb); + +#if LWIP_SO_RCVBUF + SYS_ARCH_GET(conn->recv_avail, recv_avail); + if ((conn == NULL) || !sys_mbox_valid(&conn->recvmbox) || + ((recv_avail + (int)(p->tot_len)) > conn->recv_bufsize)) { +#else /* LWIP_SO_RCVBUF */ + if ((conn == NULL) || !sys_mbox_valid(&conn->recvmbox)) { +#endif /* LWIP_SO_RCVBUF */ + pbuf_free(p); + return; + } + + buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); + if (buf == NULL) { + pbuf_free(p); + return; + } else { + buf->p = p; + buf->ptr = p; + ip_addr_set(&buf->addr, addr); + buf->port = port; +#if LWIP_NETBUF_RECVINFO + { + const struct ip_hdr* iphdr = ip_current_header(); + /* get the UDP header - always in the first pbuf, ensured by udp_input */ + const struct udp_hdr* udphdr = (void*)(((char*)iphdr) + IPH_LEN(iphdr)); +#if LWIP_CHECKSUM_ON_COPY + buf->flags = NETBUF_FLAG_DESTADDR; +#endif /* LWIP_CHECKSUM_ON_COPY */ + ip_addr_set(&buf->toaddr, ip_current_dest_addr()); + buf->toport_chksum = udphdr->dest; + } +#endif /* LWIP_NETBUF_RECVINFO */ + } + + len = p->tot_len; + if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) { + netbuf_delete(buf); + return; + } else { +#if LWIP_SO_RCVBUF + SYS_ARCH_INC(conn->recv_avail, len); +#endif /* LWIP_SO_RCVBUF */ + /* Register event with callback */ + API_EVENT(conn, NETCONN_EVT_RCVPLUS, len); + } +} +#endif /* LWIP_UDP */ + +#if LWIP_TCP +/** + * Receive callback function for TCP netconns. + * Posts the packet to conn->recvmbox, but doesn't delete it on errors. + * + * @see tcp.h (struct tcp_pcb.recv) for parameters and return value + */ +static err_t +recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) +{ + struct netconn *conn; + u16_t len; + + LWIP_UNUSED_ARG(pcb); + LWIP_ASSERT("recv_tcp must have a pcb argument", pcb != NULL); + LWIP_ASSERT("recv_tcp must have an argument", arg != NULL); + conn = (struct netconn *)arg; + LWIP_ASSERT("recv_tcp: recv for wrong pcb!", conn->pcb.tcp == pcb); + + if (conn == NULL) { + return ERR_VAL; + } + if (!sys_mbox_valid(&conn->recvmbox)) { + /* recvmbox already deleted */ + if (p != NULL) { + tcp_recved(pcb, p->tot_len); + pbuf_free(p); + } + return ERR_OK; + } + /* Unlike for UDP or RAW pcbs, don't check for available space + using recv_avail since that could break the connection + (data is already ACKed) */ + + /* don't overwrite fatal errors! */ + NETCONN_SET_SAFE_ERR(conn, err); + + if (p != NULL) { + len = p->tot_len; + } else { + len = 0; + } + + if (sys_mbox_trypost(&conn->recvmbox, p) != ERR_OK) { + /* don't deallocate p: it is presented to us later again from tcp_fasttmr! */ + return ERR_MEM; + } else { +#if LWIP_SO_RCVBUF + SYS_ARCH_INC(conn->recv_avail, len); +#endif /* LWIP_SO_RCVBUF */ + /* Register event with callback */ + API_EVENT(conn, NETCONN_EVT_RCVPLUS, len); + } + + return ERR_OK; +} + +/** + * Poll callback function for TCP netconns. + * Wakes up an application thread that waits for a connection to close + * or data to be sent. The application thread then takes the + * appropriate action to go on. + * + * Signals the conn->sem. + * netconn_close waits for conn->sem if closing failed. + * + * @see tcp.h (struct tcp_pcb.poll) for parameters and return value + */ +static err_t +poll_tcp(void *arg, struct tcp_pcb *pcb) +{ + struct netconn *conn = (struct netconn *)arg; + + LWIP_UNUSED_ARG(pcb); + LWIP_ASSERT("conn != NULL", (conn != NULL)); + + if (conn->state == NETCONN_WRITE) { + do_writemore(conn); + } else if (conn->state == NETCONN_CLOSE) { + do_close_internal(conn); + } + /* @todo: implement connect timeout here? */ + + /* Did a nonblocking write fail before? Then check available write-space. */ + if (conn->flags & NETCONN_FLAG_CHECK_WRITESPACE) { + /* If the queued byte- or pbuf-count drops below the configured low-water limit, + let select mark this pcb as writable again. */ + if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) && + (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) { + conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE; + API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); + } + } + + return ERR_OK; +} + +/** + * Sent callback function for TCP netconns. + * Signals the conn->sem and calls API_EVENT. + * netconn_write waits for conn->sem if send buffer is low. + * + * @see tcp.h (struct tcp_pcb.sent) for parameters and return value + */ +static err_t +sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len) +{ + struct netconn *conn = (struct netconn *)arg; + + LWIP_UNUSED_ARG(pcb); + LWIP_ASSERT("conn != NULL", (conn != NULL)); + + if (conn->state == NETCONN_WRITE) { + do_writemore(conn); + } else if (conn->state == NETCONN_CLOSE) { + do_close_internal(conn); + } + + if (conn) { + /* If the queued byte- or pbuf-count drops below the configured low-water limit, + let select mark this pcb as writable again. */ + if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) && + (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) { + conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE; + API_EVENT(conn, NETCONN_EVT_SENDPLUS, len); + } + } + + return ERR_OK; +} + +/** + * Error callback function for TCP netconns. + * Signals conn->sem, posts to all conn mboxes and calls API_EVENT. + * The application thread has then to decide what to do. + * + * @see tcp.h (struct tcp_pcb.err) for parameters + */ +static void +err_tcp(void *arg, err_t err) +{ + struct netconn *conn; + enum netconn_state old_state; + SYS_ARCH_DECL_PROTECT(lev); + + conn = (struct netconn *)arg; + LWIP_ASSERT("conn != NULL", (conn != NULL)); + + conn->pcb.tcp = NULL; + + /* no check since this is always fatal! */ + SYS_ARCH_PROTECT(lev); + conn->last_err = err; + SYS_ARCH_UNPROTECT(lev); + + /* reset conn->state now before waking up other threads */ + old_state = conn->state; + conn->state = NETCONN_NONE; + + /* Notify the user layer about a connection error. Used to signal + select. */ + API_EVENT(conn, NETCONN_EVT_ERROR, 0); + /* Try to release selects pending on 'read' or 'write', too. + They will get an error if they actually try to read or write. */ + API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0); + API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); + + /* pass NULL-message to recvmbox to wake up pending recv */ + if (sys_mbox_valid(&conn->recvmbox)) { + /* use trypost to prevent deadlock */ + sys_mbox_trypost(&conn->recvmbox, NULL); + } + /* pass NULL-message to acceptmbox to wake up pending accept */ + if (sys_mbox_valid(&conn->acceptmbox)) { + /* use trypost to preven deadlock */ + sys_mbox_trypost(&conn->acceptmbox, NULL); + } + + if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) || + (old_state == NETCONN_CONNECT)) { + /* calling do_writemore/do_close_internal is not necessary + since the pcb has already been deleted! */ + int was_nonblocking_connect = IN_NONBLOCKING_CONNECT(conn); + SET_NONBLOCKING_CONNECT(conn, 0); + + if (!was_nonblocking_connect) { + /* set error return code */ + LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL); + conn->current_msg->err = err; + conn->current_msg = NULL; + /* wake up the waiting task */ + sys_sem_signal(&conn->op_completed); + } + } else { + LWIP_ASSERT("conn->current_msg == NULL", conn->current_msg == NULL); + } +} + +/** + * Setup a tcp_pcb with the correct callback function pointers + * and their arguments. + * + * @param conn the TCP netconn to setup + */ +static void +setup_tcp(struct netconn *conn) +{ + struct tcp_pcb *pcb; + + pcb = conn->pcb.tcp; + tcp_arg(pcb, conn); + tcp_recv(pcb, recv_tcp); + tcp_sent(pcb, sent_tcp); + tcp_poll(pcb, poll_tcp, 4); + tcp_err(pcb, err_tcp); +} + +/** + * Accept callback function for TCP netconns. + * Allocates a new netconn and posts that to conn->acceptmbox. + * + * @see tcp.h (struct tcp_pcb_listen.accept) for parameters and return value + */ +static err_t +accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) +{ + struct netconn *newconn; + struct netconn *conn = (struct netconn *)arg; + + LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: newpcb->tate: %s\n", tcp_debug_state_str(newpcb->state))); + + if (!sys_mbox_valid(&conn->acceptmbox)) { + LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: acceptmbox already deleted\n")); + return ERR_VAL; + } + + /* We have to set the callback here even though + * the new socket is unknown. conn->socket is marked as -1. */ + newconn = netconn_alloc(conn->type, conn->callback); + if (newconn == NULL) { + return ERR_MEM; + } + newconn->pcb.tcp = newpcb; + setup_tcp(newconn); + /* no protection: when creating the pcb, the netconn is not yet known + to the application thread */ + newconn->last_err = err; + + if (sys_mbox_trypost(&conn->acceptmbox, newconn) != ERR_OK) { + /* When returning != ERR_OK, the pcb is aborted in tcp_process(), + so do nothing here! */ + /* remove all references to this netconn from the pcb */ + struct tcp_pcb* pcb = newconn->pcb.tcp; + tcp_arg(pcb, NULL); + tcp_recv(pcb, NULL); + tcp_sent(pcb, NULL); + tcp_poll(pcb, NULL, 4); + tcp_err(pcb, NULL); + /* remove reference from to the pcb from this netconn */ + newconn->pcb.tcp = NULL; + /* no need to drain since we know the recvmbox is empty. */ + sys_mbox_free(&newconn->recvmbox); + sys_mbox_set_invalid(&newconn->recvmbox); + netconn_free(newconn); + return ERR_MEM; + } else { + /* Register event with callback */ + API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0); + } + + return ERR_OK; +} +#endif /* LWIP_TCP */ + +/** + * Create a new pcb of a specific type. + * Called from do_newconn(). + * + * @param msg the api_msg_msg describing the connection type + * @return msg->conn->err, but the return value is currently ignored + */ +static void +pcb_new(struct api_msg_msg *msg) +{ + LWIP_ASSERT("pcb_new: pcb already allocated", msg->conn->pcb.tcp == NULL); + + /* Allocate a PCB for this connection */ + switch(NETCONNTYPE_GROUP(msg->conn->type)) { +#if LWIP_RAW + case NETCONN_RAW: + msg->conn->pcb.raw = raw_new(msg->msg.n.proto); + if(msg->conn->pcb.raw == NULL) { + msg->err = ERR_MEM; + break; + } + raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn); + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + msg->conn->pcb.udp = udp_new(); + if(msg->conn->pcb.udp == NULL) { + msg->err = ERR_MEM; + break; + } +#if LWIP_UDPLITE + if (msg->conn->type==NETCONN_UDPLITE) { + udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); + } +#endif /* LWIP_UDPLITE */ + if (msg->conn->type==NETCONN_UDPNOCHKSUM) { + udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); + } + udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + msg->conn->pcb.tcp = tcp_new(); + if(msg->conn->pcb.tcp == NULL) { + msg->err = ERR_MEM; + break; + } + setup_tcp(msg->conn); + break; +#endif /* LWIP_TCP */ + default: + /* Unsupported netconn type, e.g. protocol disabled */ + msg->err = ERR_VAL; + break; + } +} + +/** + * Create a new pcb of a specific type inside a netconn. + * Called from netconn_new_with_proto_and_callback. + * + * @param msg the api_msg_msg describing the connection type + */ +void +do_newconn(struct api_msg_msg *msg) +{ + msg->err = ERR_OK; + if(msg->conn->pcb.tcp == NULL) { + pcb_new(msg); + } + /* Else? This "new" connection already has a PCB allocated. */ + /* Is this an error condition? Should it be deleted? */ + /* We currently just are happy and return. */ + + TCPIP_APIMSG_ACK(msg); +} + +/** + * Create a new netconn (of a specific type) that has a callback function. + * The corresponding pcb is NOT created! + * + * @param t the type of 'connection' to create (@see enum netconn_type) + * @param proto the IP protocol for RAW IP pcbs + * @param callback a function to call on status changes (RX available, TX'ed) + * @return a newly allocated struct netconn or + * NULL on memory error + */ +struct netconn* +netconn_alloc(enum netconn_type t, netconn_callback callback) +{ + struct netconn *conn; + int size; + + conn = (struct netconn *)memp_malloc(MEMP_NETCONN); + if (conn == NULL) { + return NULL; + } + + conn->last_err = ERR_OK; + conn->type = t; + conn->pcb.tcp = NULL; + +#if (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_UDP_RECVMBOX_SIZE) && \ + (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_TCP_RECVMBOX_SIZE) + size = DEFAULT_RAW_RECVMBOX_SIZE; +#else + switch(NETCONNTYPE_GROUP(t)) { +#if LWIP_RAW + case NETCONN_RAW: + size = DEFAULT_RAW_RECVMBOX_SIZE; + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + size = DEFAULT_UDP_RECVMBOX_SIZE; + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + size = DEFAULT_TCP_RECVMBOX_SIZE; + break; +#endif /* LWIP_TCP */ + default: + LWIP_ASSERT("netconn_alloc: undefined netconn_type", 0); + goto free_and_return; + } +#endif + + if (sys_sem_new(&conn->op_completed, 0) != ERR_OK) { + goto free_and_return; + } + if (sys_mbox_new(&conn->recvmbox, size) != ERR_OK) { + sys_sem_free(&conn->op_completed); + goto free_and_return; + } + +#if LWIP_TCP + sys_mbox_set_invalid(&conn->acceptmbox); +#endif + conn->state = NETCONN_NONE; +#if LWIP_SOCKET + /* initialize socket to -1 since 0 is a valid socket */ + conn->socket = -1; +#endif /* LWIP_SOCKET */ + conn->callback = callback; +#if LWIP_TCP + conn->current_msg = NULL; + conn->write_offset = 0; +#endif /* LWIP_TCP */ +#if LWIP_SO_SNDTIMEO + conn->send_timeout = 0; +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO + conn->recv_timeout = 0; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + conn->recv_bufsize = RECV_BUFSIZE_DEFAULT; + conn->recv_avail = 0; +#endif /* LWIP_SO_RCVBUF */ + conn->flags = 0; + return conn; +free_and_return: + memp_free(MEMP_NETCONN, conn); + return NULL; +} + +/** + * Delete a netconn and all its resources. + * The pcb is NOT freed (since we might not be in the right thread context do this). + * + * @param conn the netconn to free + */ +void +netconn_free(struct netconn *conn) +{ + LWIP_ASSERT("PCB must be deallocated outside this function", conn->pcb.tcp == NULL); + LWIP_ASSERT("recvmbox must be deallocated before calling this function", + !sys_mbox_valid(&conn->recvmbox)); +#if LWIP_TCP + LWIP_ASSERT("acceptmbox must be deallocated before calling this function", + !sys_mbox_valid(&conn->acceptmbox)); +#endif /* LWIP_TCP */ + + sys_sem_free(&conn->op_completed); + sys_sem_set_invalid(&conn->op_completed); + + memp_free(MEMP_NETCONN, conn); +} + +/** + * Delete rcvmbox and acceptmbox of a netconn and free the left-over data in + * these mboxes + * + * @param conn the netconn to free + * @bytes_drained bytes drained from recvmbox + * @accepts_drained pending connections drained from acceptmbox + */ +static void +netconn_drain(struct netconn *conn) +{ + void *mem; +#if LWIP_TCP + struct pbuf *p; +#endif /* LWIP_TCP */ + + /* This runs in tcpip_thread, so we don't need to lock against rx packets */ + + /* Delete and drain the recvmbox. */ + if (sys_mbox_valid(&conn->recvmbox)) { + while (sys_mbox_tryfetch(&conn->recvmbox, &mem) != SYS_MBOX_EMPTY) { +#if LWIP_TCP + if (conn->type == NETCONN_TCP) { + if(mem != NULL) { + p = (struct pbuf*)mem; + /* pcb might be set to NULL already by err_tcp() */ + if (conn->pcb.tcp != NULL) { + tcp_recved(conn->pcb.tcp, p->tot_len); + } + pbuf_free(p); + } + } else +#endif /* LWIP_TCP */ + { + netbuf_delete((struct netbuf *)mem); + } + } + sys_mbox_free(&conn->recvmbox); + sys_mbox_set_invalid(&conn->recvmbox); + } + + /* Delete and drain the acceptmbox. */ +#if LWIP_TCP + if (sys_mbox_valid(&conn->acceptmbox)) { + while (sys_mbox_tryfetch(&conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) { + struct netconn *newconn = (struct netconn *)mem; + /* Only tcp pcbs have an acceptmbox, so no need to check conn->type */ + /* pcb might be set to NULL already by err_tcp() */ + if (conn->pcb.tcp != NULL) { + tcp_accepted(conn->pcb.tcp); + } + /* drain recvmbox */ + netconn_drain(newconn); + if (newconn->pcb.tcp != NULL) { + tcp_abort(newconn->pcb.tcp); + newconn->pcb.tcp = NULL; + } + netconn_free(newconn); + } + sys_mbox_free(&conn->acceptmbox); + sys_mbox_set_invalid(&conn->acceptmbox); + } +#endif /* LWIP_TCP */ +} + +#if LWIP_TCP +/** + * Internal helper function to close a TCP netconn: since this sometimes + * doesn't work at the first attempt, this function is called from multiple + * places. + * + * @param conn the TCP netconn to close + */ +static void +do_close_internal(struct netconn *conn) +{ + err_t err; + u8_t shut, shut_rx, shut_tx, close; + + LWIP_ASSERT("invalid conn", (conn != NULL)); + LWIP_ASSERT("this is for tcp netconns only", (conn->type == NETCONN_TCP)); + LWIP_ASSERT("conn must be in state NETCONN_CLOSE", (conn->state == NETCONN_CLOSE)); + LWIP_ASSERT("pcb already closed", (conn->pcb.tcp != NULL)); + LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL); + + shut = conn->current_msg->msg.sd.shut; + shut_rx = shut & NETCONN_SHUT_RD; + shut_tx = shut & NETCONN_SHUT_WR; + /* shutting down both ends is the same as closing */ + close = shut == NETCONN_SHUT_RDWR; + + /* Set back some callback pointers */ + if (close) { + tcp_arg(conn->pcb.tcp, NULL); + } + if (conn->pcb.tcp->state == LISTEN) { + tcp_accept(conn->pcb.tcp, NULL); + } else { + /* some callbacks have to be reset if tcp_close is not successful */ + if (shut_rx) { + tcp_recv(conn->pcb.tcp, NULL); + tcp_accept(conn->pcb.tcp, NULL); + } + if (shut_tx) { + tcp_sent(conn->pcb.tcp, NULL); + } + if (close) { + tcp_poll(conn->pcb.tcp, NULL, 4); + tcp_err(conn->pcb.tcp, NULL); + } + } + /* Try to close the connection */ + if (close) { + err = tcp_close(conn->pcb.tcp); + } else { + err = tcp_shutdown(conn->pcb.tcp, shut_rx, shut_tx); + } + if (err == ERR_OK) { + /* Closing succeeded */ + conn->current_msg->err = ERR_OK; + conn->current_msg = NULL; + conn->state = NETCONN_NONE; + if (close) { + /* Set back some callback pointers as conn is going away */ + conn->pcb.tcp = NULL; + /* Trigger select() in socket layer. Make sure everybody notices activity + on the connection, error first! */ + API_EVENT(conn, NETCONN_EVT_ERROR, 0); + } + if (shut_rx) { + API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0); + } + if (shut_tx) { + API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); + } + /* wake up the application task */ + sys_sem_signal(&conn->op_completed); + } else { + /* Closing failed, restore some of the callbacks */ + /* Closing of listen pcb will never fail! */ + LWIP_ASSERT("Closing a listen pcb may not fail!", (conn->pcb.tcp->state != LISTEN)); + tcp_sent(conn->pcb.tcp, sent_tcp); + tcp_poll(conn->pcb.tcp, poll_tcp, 4); + tcp_err(conn->pcb.tcp, err_tcp); + tcp_arg(conn->pcb.tcp, conn); + /* don't restore recv callback: we don't want to receive any more data */ + } + /* If closing didn't succeed, we get called again either + from poll_tcp or from sent_tcp */ +} +#endif /* LWIP_TCP */ + +/** + * Delete the pcb inside a netconn. + * Called from netconn_delete. + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_delconn(struct api_msg_msg *msg) +{ + /* @todo TCP: abort running write/connect? */ + if ((msg->conn->state != NETCONN_NONE) && + (msg->conn->state != NETCONN_LISTEN) && + (msg->conn->state != NETCONN_CONNECT)) { + /* this only happens for TCP netconns */ + LWIP_ASSERT("msg->conn->type == NETCONN_TCP", msg->conn->type == NETCONN_TCP); + msg->err = ERR_INPROGRESS; + } else { + LWIP_ASSERT("blocking connect in progress", + (msg->conn->state != NETCONN_CONNECT) || IN_NONBLOCKING_CONNECT(msg->conn)); + /* Drain and delete mboxes */ + netconn_drain(msg->conn); + + if (msg->conn->pcb.tcp != NULL) { + + switch (NETCONNTYPE_GROUP(msg->conn->type)) { +#if LWIP_RAW + case NETCONN_RAW: + raw_remove(msg->conn->pcb.raw); + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + msg->conn->pcb.udp->recv_arg = NULL; + udp_remove(msg->conn->pcb.udp); + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && + msg->conn->write_offset == 0); + msg->conn->state = NETCONN_CLOSE; + msg->msg.sd.shut = NETCONN_SHUT_RDWR; + msg->conn->current_msg = msg; + do_close_internal(msg->conn); + /* API_EVENT is called inside do_close_internal, before releasing + the application thread, so we can return at this point! */ + return; +#endif /* LWIP_TCP */ + default: + break; + } + msg->conn->pcb.tcp = NULL; + } + /* tcp netconns don't come here! */ + + /* @todo: this lets select make the socket readable and writable, + which is wrong! errfd instead? */ + API_EVENT(msg->conn, NETCONN_EVT_RCVPLUS, 0); + API_EVENT(msg->conn, NETCONN_EVT_SENDPLUS, 0); + } + if (sys_sem_valid(&msg->conn->op_completed)) { + sys_sem_signal(&msg->conn->op_completed); + } +} + +/** + * Bind a pcb contained in a netconn + * Called from netconn_bind. + * + * @param msg the api_msg_msg pointing to the connection and containing + * the IP address and port to bind to + */ +void +do_bind(struct api_msg_msg *msg) +{ + if (ERR_IS_FATAL(msg->conn->last_err)) { + msg->err = msg->conn->last_err; + } else { + msg->err = ERR_VAL; + if (msg->conn->pcb.tcp != NULL) { + switch (NETCONNTYPE_GROUP(msg->conn->type)) { +#if LWIP_RAW + case NETCONN_RAW: + msg->err = raw_bind(msg->conn->pcb.raw, msg->msg.bc.ipaddr); + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + msg->err = udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port); + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + msg->err = tcp_bind(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port); + break; +#endif /* LWIP_TCP */ + default: + break; + } + } + } + TCPIP_APIMSG_ACK(msg); +} + +#if LWIP_TCP +/** + * TCP callback function if a connection (opened by tcp_connect/do_connect) has + * been established (or reset by the remote host). + * + * @see tcp.h (struct tcp_pcb.connected) for parameters and return values + */ +static err_t +do_connected(void *arg, struct tcp_pcb *pcb, err_t err) +{ + struct netconn *conn; + int was_blocking; + + LWIP_UNUSED_ARG(pcb); + + conn = (struct netconn *)arg; + + if (conn == NULL) { + return ERR_VAL; + } + + LWIP_ASSERT("conn->state == NETCONN_CONNECT", conn->state == NETCONN_CONNECT); + LWIP_ASSERT("(conn->current_msg != NULL) || conn->in_non_blocking_connect", + (conn->current_msg != NULL) || IN_NONBLOCKING_CONNECT(conn)); + + if (conn->current_msg != NULL) { + conn->current_msg->err = err; + } + if ((conn->type == NETCONN_TCP) && (err == ERR_OK)) { + setup_tcp(conn); + } + was_blocking = !IN_NONBLOCKING_CONNECT(conn); + SET_NONBLOCKING_CONNECT(conn, 0); + conn->current_msg = NULL; + conn->state = NETCONN_NONE; + if (!was_blocking) { + NETCONN_SET_SAFE_ERR(conn, ERR_OK); + } + API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); + + if (was_blocking) { + sys_sem_signal(&conn->op_completed); + } + return ERR_OK; +} +#endif /* LWIP_TCP */ + +/** + * Connect a pcb contained inside a netconn + * Called from netconn_connect. + * + * @param msg the api_msg_msg pointing to the connection and containing + * the IP address and port to connect to + */ +void +do_connect(struct api_msg_msg *msg) +{ + if (msg->conn->pcb.tcp == NULL) { + /* This may happen when calling netconn_connect() a second time */ + msg->err = ERR_CLSD; + } else { + switch (NETCONNTYPE_GROUP(msg->conn->type)) { +#if LWIP_RAW + case NETCONN_RAW: + msg->err = raw_connect(msg->conn->pcb.raw, msg->msg.bc.ipaddr); + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + msg->err = udp_connect(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port); + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + /* Prevent connect while doing any other action. */ + if (msg->conn->state != NETCONN_NONE) { + msg->err = ERR_ISCONN; + } else { + setup_tcp(msg->conn); + msg->err = tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, + msg->msg.bc.port, do_connected); + if (msg->err == ERR_OK) { + u8_t non_blocking = netconn_is_nonblocking(msg->conn); + msg->conn->state = NETCONN_CONNECT; + SET_NONBLOCKING_CONNECT(msg->conn, non_blocking); + if (non_blocking) { + msg->err = ERR_INPROGRESS; + } else { + msg->conn->current_msg = msg; + /* sys_sem_signal() is called from do_connected (or err_tcp()), + * when the connection is established! */ + return; + } + } + } + break; +#endif /* LWIP_TCP */ + default: + LWIP_ERROR("Invalid netconn type", 0, do{ msg->err = ERR_VAL; }while(0)); + break; + } + } + sys_sem_signal(&msg->conn->op_completed); +} + +/** + * Connect a pcb contained inside a netconn + * Only used for UDP netconns. + * Called from netconn_disconnect. + * + * @param msg the api_msg_msg pointing to the connection to disconnect + */ +void +do_disconnect(struct api_msg_msg *msg) +{ +#if LWIP_UDP + if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) { + udp_disconnect(msg->conn->pcb.udp); + msg->err = ERR_OK; + } else +#endif /* LWIP_UDP */ + { + msg->err = ERR_VAL; + } + TCPIP_APIMSG_ACK(msg); +} + +#if LWIP_TCP +/** + * Set a TCP pcb contained in a netconn into listen mode + * Called from netconn_listen. + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_listen(struct api_msg_msg *msg) +{ + if (ERR_IS_FATAL(msg->conn->last_err)) { + msg->err = msg->conn->last_err; + } else { + msg->err = ERR_CONN; + if (msg->conn->pcb.tcp != NULL) { + if (msg->conn->type == NETCONN_TCP) { + if (msg->conn->state == NETCONN_NONE) { +#if TCP_LISTEN_BACKLOG + struct tcp_pcb* lpcb = tcp_listen_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog); +#else /* TCP_LISTEN_BACKLOG */ + struct tcp_pcb* lpcb = tcp_listen(msg->conn->pcb.tcp); +#endif /* TCP_LISTEN_BACKLOG */ + if (lpcb == NULL) { + /* in this case, the old pcb is still allocated */ + msg->err = ERR_MEM; + } else { + /* delete the recvmbox and allocate the acceptmbox */ + if (sys_mbox_valid(&msg->conn->recvmbox)) { + /** @todo: should we drain the recvmbox here? */ + sys_mbox_free(&msg->conn->recvmbox); + sys_mbox_set_invalid(&msg->conn->recvmbox); + } + msg->err = ERR_OK; + if (!sys_mbox_valid(&msg->conn->acceptmbox)) { + msg->err = sys_mbox_new(&msg->conn->acceptmbox, DEFAULT_ACCEPTMBOX_SIZE); + } + if (msg->err == ERR_OK) { + msg->conn->state = NETCONN_LISTEN; + msg->conn->pcb.tcp = lpcb; + tcp_arg(msg->conn->pcb.tcp, msg->conn); + tcp_accept(msg->conn->pcb.tcp, accept_function); + } else { + /* since the old pcb is already deallocated, free lpcb now */ + tcp_close(lpcb); + msg->conn->pcb.tcp = NULL; + } + } + } + } else { + msg->err = ERR_ARG; + } + } + } + TCPIP_APIMSG_ACK(msg); +} +#endif /* LWIP_TCP */ + +/** + * Send some data on a RAW or UDP pcb contained in a netconn + * Called from netconn_send + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_send(struct api_msg_msg *msg) +{ + if (ERR_IS_FATAL(msg->conn->last_err)) { + msg->err = msg->conn->last_err; + } else { + msg->err = ERR_CONN; + if (msg->conn->pcb.tcp != NULL) { + switch (NETCONNTYPE_GROUP(msg->conn->type)) { +#if LWIP_RAW + case NETCONN_RAW: + if (ip_addr_isany(&msg->msg.b->addr)) { + msg->err = raw_send(msg->conn->pcb.raw, msg->msg.b->p); + } else { + msg->err = raw_sendto(msg->conn->pcb.raw, msg->msg.b->p, &msg->msg.b->addr); + } + break; +#endif +#if LWIP_UDP + case NETCONN_UDP: +#if LWIP_CHECKSUM_ON_COPY + if (ip_addr_isany(&msg->msg.b->addr)) { + msg->err = udp_send_chksum(msg->conn->pcb.udp, msg->msg.b->p, + msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum); + } else { + msg->err = udp_sendto_chksum(msg->conn->pcb.udp, msg->msg.b->p, + &msg->msg.b->addr, msg->msg.b->port, + msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum); + } +#else /* LWIP_CHECKSUM_ON_COPY */ + if (ip_addr_isany(&msg->msg.b->addr)) { + msg->err = udp_send(msg->conn->pcb.udp, msg->msg.b->p); + } else { + msg->err = udp_sendto(msg->conn->pcb.udp, msg->msg.b->p, &msg->msg.b->addr, msg->msg.b->port); + } +#endif /* LWIP_CHECKSUM_ON_COPY */ + break; +#endif /* LWIP_UDP */ + default: + break; + } + } + } + TCPIP_APIMSG_ACK(msg); +} + +#if LWIP_TCP +/** + * Indicate data has been received from a TCP pcb contained in a netconn + * Called from netconn_recv + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_recv(struct api_msg_msg *msg) +{ + msg->err = ERR_OK; + if (msg->conn->pcb.tcp != NULL) { + if (msg->conn->type == NETCONN_TCP) { +#if TCP_LISTEN_BACKLOG + if (msg->conn->pcb.tcp->state == LISTEN) { + tcp_accepted(msg->conn->pcb.tcp); + } else +#endif /* TCP_LISTEN_BACKLOG */ + { + u32_t remaining = msg->msg.r.len; + do { + u16_t recved = (remaining > 0xffff) ? 0xffff : (u16_t)remaining; + tcp_recved(msg->conn->pcb.tcp, recved); + remaining -= recved; + }while(remaining != 0); + } + } + } + TCPIP_APIMSG_ACK(msg); +} + +/** + * See if more data needs to be written from a previous call to netconn_write. + * Called initially from do_write. If the first call can't send all data + * (because of low memory or empty send-buffer), this function is called again + * from sent_tcp() or poll_tcp() to send more data. If all data is sent, the + * blocking application thread (waiting in netconn_write) is released. + * + * @param conn netconn (that is currently in state NETCONN_WRITE) to process + * @return ERR_OK + * ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished + */ +static err_t +do_writemore(struct netconn *conn) +{ + err_t err; + void *dataptr; + u16_t len, available; + u8_t write_finished = 0; + size_t diff; + u8_t dontblock = netconn_is_nonblocking(conn) || + (conn->current_msg->msg.w.apiflags & NETCONN_DONTBLOCK); + u8_t apiflags = conn->current_msg->msg.w.apiflags; + + LWIP_ASSERT("conn != NULL", conn != NULL); + LWIP_ASSERT("conn->state == NETCONN_WRITE", (conn->state == NETCONN_WRITE)); + LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL); + LWIP_ASSERT("conn->pcb.tcp != NULL", conn->pcb.tcp != NULL); + LWIP_ASSERT("conn->write_offset < conn->current_msg->msg.w.len", + conn->write_offset < conn->current_msg->msg.w.len); + +#if LWIP_SO_SNDTIMEO + if ((conn->send_timeout != 0) && + ((s32_t)(sys_now() - conn->current_msg->msg.w.time_started) >= conn->send_timeout)) { + write_finished = 1; + if (conn->write_offset == 0) { + /* nothing has been written */ + err = ERR_WOULDBLOCK; + conn->current_msg->msg.w.len = 0; + } else { + /* partial write */ + err = ERR_OK; + conn->current_msg->msg.w.len = conn->write_offset; + } + } else +#endif /* LWIP_SO_SNDTIMEO */ + { + dataptr = (u8_t*)conn->current_msg->msg.w.dataptr + conn->write_offset; + diff = conn->current_msg->msg.w.len - conn->write_offset; + if (diff > 0xffffUL) { /* max_u16_t */ + len = 0xffff; +#if LWIP_TCPIP_CORE_LOCKING + conn->flags |= NETCONN_FLAG_WRITE_DELAYED; +#endif + apiflags |= TCP_WRITE_FLAG_MORE; + } else { + len = (u16_t)diff; + } + available = tcp_sndbuf(conn->pcb.tcp); + if (available < len) { + /* don't try to write more than sendbuf */ + len = available; + if (dontblock){ + if (!len) { + err = ERR_WOULDBLOCK; + goto err_mem; + } + } else { +#if LWIP_TCPIP_CORE_LOCKING + conn->flags |= NETCONN_FLAG_WRITE_DELAYED; +#endif + apiflags |= TCP_WRITE_FLAG_MORE; + } + } + LWIP_ASSERT("do_writemore: invalid length!", ((conn->write_offset + len) <= conn->current_msg->msg.w.len)); + err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags); + /* if OK or memory error, check available space */ + if ((err == ERR_OK) || (err == ERR_MEM)) { +err_mem: + if (dontblock && (len < conn->current_msg->msg.w.len)) { + /* non-blocking write did not write everything: mark the pcb non-writable + and let poll_tcp check writable space to mark the pcb writable again */ + API_EVENT(conn, NETCONN_EVT_SENDMINUS, len); + conn->flags |= NETCONN_FLAG_CHECK_WRITESPACE; + } else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT) || + (tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT)) { + /* The queued byte- or pbuf-count exceeds the configured low-water limit, + let select mark this pcb as non-writable. */ + API_EVENT(conn, NETCONN_EVT_SENDMINUS, len); + } + } + + if (err == ERR_OK) { + conn->write_offset += len; + if ((conn->write_offset == conn->current_msg->msg.w.len) || dontblock) { + /* return sent length */ + conn->current_msg->msg.w.len = conn->write_offset; + /* everything was written */ + write_finished = 1; + conn->write_offset = 0; + } + tcp_output(conn->pcb.tcp); + } else if ((err == ERR_MEM) && !dontblock) { + /* If ERR_MEM, we wait for sent_tcp or poll_tcp to be called + we do NOT return to the application thread, since ERR_MEM is + only a temporary error! */ + + /* tcp_write returned ERR_MEM, try tcp_output anyway */ + tcp_output(conn->pcb.tcp); + +#if LWIP_TCPIP_CORE_LOCKING + conn->flags |= NETCONN_FLAG_WRITE_DELAYED; +#endif + } else { + /* On errors != ERR_MEM, we don't try writing any more but return + the error to the application thread. */ + write_finished = 1; + conn->current_msg->msg.w.len = 0; + } + } + if (write_finished) { + /* everything was written: set back connection state + and back to application task */ + conn->current_msg->err = err; + conn->current_msg = NULL; + conn->state = NETCONN_NONE; +#if LWIP_TCPIP_CORE_LOCKING + if ((conn->flags & NETCONN_FLAG_WRITE_DELAYED) != 0) +#endif + { + sys_sem_signal(&conn->op_completed); + } + } +#if LWIP_TCPIP_CORE_LOCKING + else + return ERR_MEM; +#endif + return ERR_OK; +} +#endif /* LWIP_TCP */ + +/** + * Send some data on a TCP pcb contained in a netconn + * Called from netconn_write + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_write(struct api_msg_msg *msg) +{ + if (ERR_IS_FATAL(msg->conn->last_err)) { + msg->err = msg->conn->last_err; + } else { + if (msg->conn->type == NETCONN_TCP) { +#if LWIP_TCP + if (msg->conn->state != NETCONN_NONE) { + /* netconn is connecting, closing or in blocking write */ + msg->err = ERR_INPROGRESS; + } else if (msg->conn->pcb.tcp != NULL) { + msg->conn->state = NETCONN_WRITE; + /* set all the variables used by do_writemore */ + LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && + msg->conn->write_offset == 0); + LWIP_ASSERT("msg->msg.w.len != 0", msg->msg.w.len != 0); + msg->conn->current_msg = msg; + msg->conn->write_offset = 0; +#if LWIP_TCPIP_CORE_LOCKING + msg->conn->flags &= ~NETCONN_FLAG_WRITE_DELAYED; + if (do_writemore(msg->conn) != ERR_OK) { + LWIP_ASSERT("state!", msg->conn->state == NETCONN_WRITE); + UNLOCK_TCPIP_CORE(); + sys_arch_sem_wait(&msg->conn->op_completed, 0); + LOCK_TCPIP_CORE(); + LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE); + } +#else /* LWIP_TCPIP_CORE_LOCKING */ + do_writemore(msg->conn); +#endif /* LWIP_TCPIP_CORE_LOCKING */ + /* for both cases: if do_writemore was called, don't ACK the APIMSG + since do_writemore ACKs it! */ + return; + } else { + msg->err = ERR_CONN; + } +#else /* LWIP_TCP */ + msg->err = ERR_VAL; +#endif /* LWIP_TCP */ +#if (LWIP_UDP || LWIP_RAW) + } else { + msg->err = ERR_VAL; +#endif /* (LWIP_UDP || LWIP_RAW) */ + } + } + TCPIP_APIMSG_ACK(msg); +} + +/** + * Return a connection's local or remote address + * Called from netconn_getaddr + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_getaddr(struct api_msg_msg *msg) +{ + if (msg->conn->pcb.ip != NULL) { + *(msg->msg.ad.ipaddr) = (msg->msg.ad.local ? msg->conn->pcb.ip->local_ip : + msg->conn->pcb.ip->remote_ip); + + msg->err = ERR_OK; + switch (NETCONNTYPE_GROUP(msg->conn->type)) { +#if LWIP_RAW + case NETCONN_RAW: + if (msg->msg.ad.local) { + *(msg->msg.ad.port) = msg->conn->pcb.raw->protocol; + } else { + /* return an error as connecting is only a helper for upper layers */ + msg->err = ERR_CONN; + } + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + if (msg->msg.ad.local) { + *(msg->msg.ad.port) = msg->conn->pcb.udp->local_port; + } else { + if ((msg->conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0) { + msg->err = ERR_CONN; + } else { + *(msg->msg.ad.port) = msg->conn->pcb.udp->remote_port; + } + } + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + *(msg->msg.ad.port) = (msg->msg.ad.local?msg->conn->pcb.tcp->local_port:msg->conn->pcb.tcp->remote_port); + break; +#endif /* LWIP_TCP */ + default: + LWIP_ASSERT("invalid netconn_type", 0); + break; + } + } else { + msg->err = ERR_CONN; + } + TCPIP_APIMSG_ACK(msg); +} + +/** + * Close a TCP pcb contained in a netconn + * Called from netconn_close + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_close(struct api_msg_msg *msg) +{ +#if LWIP_TCP + /* @todo: abort running write/connect? */ + if ((msg->conn->state != NETCONN_NONE) && (msg->conn->state != NETCONN_LISTEN)) { + /* this only happens for TCP netconns */ + LWIP_ASSERT("msg->conn->type == NETCONN_TCP", msg->conn->type == NETCONN_TCP); + msg->err = ERR_INPROGRESS; + } else if ((msg->conn->pcb.tcp != NULL) && (msg->conn->type == NETCONN_TCP)) { + if ((msg->msg.sd.shut != NETCONN_SHUT_RDWR) && (msg->conn->state == NETCONN_LISTEN)) { + /* LISTEN doesn't support half shutdown */ + msg->err = ERR_CONN; + } else { + if (msg->msg.sd.shut & NETCONN_SHUT_RD) { + /* Drain and delete mboxes */ + netconn_drain(msg->conn); + } + LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && + msg->conn->write_offset == 0); + msg->conn->state = NETCONN_CLOSE; + msg->conn->current_msg = msg; + do_close_internal(msg->conn); + /* for tcp netconns, do_close_internal ACKs the message */ + return; + } + } else +#endif /* LWIP_TCP */ + { + msg->err = ERR_VAL; + } + sys_sem_signal(&msg->conn->op_completed); +} + +#if LWIP_IGMP +/** + * Join multicast groups for UDP netconns. + * Called from netconn_join_leave_group + * + * @param msg the api_msg_msg pointing to the connection + */ +void +do_join_leave_group(struct api_msg_msg *msg) +{ + if (ERR_IS_FATAL(msg->conn->last_err)) { + msg->err = msg->conn->last_err; + } else { + if (msg->conn->pcb.tcp != NULL) { + if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) { +#if LWIP_UDP + if (msg->msg.jl.join_or_leave == NETCONN_JOIN) { + msg->err = igmp_joingroup(msg->msg.jl.netif_addr, msg->msg.jl.multiaddr); + } else { + msg->err = igmp_leavegroup(msg->msg.jl.netif_addr, msg->msg.jl.multiaddr); + } +#endif /* LWIP_UDP */ +#if (LWIP_TCP || LWIP_RAW) + } else { + msg->err = ERR_VAL; +#endif /* (LWIP_TCP || LWIP_RAW) */ + } + } else { + msg->err = ERR_CONN; + } + } + TCPIP_APIMSG_ACK(msg); +} +#endif /* LWIP_IGMP */ + +#if LWIP_DNS +/** + * Callback function that is called when DNS name is resolved + * (or on timeout). A waiting application thread is waked up by + * signaling the semaphore. + */ +static void +do_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) +{ + struct dns_api_msg *msg = (struct dns_api_msg*)arg; + + LWIP_ASSERT("DNS response for wrong host name", strcmp(msg->name, name) == 0); + LWIP_UNUSED_ARG(name); + + if (ipaddr == NULL) { + /* timeout or memory error */ + *msg->err = ERR_VAL; + } else { + /* address was resolved */ + *msg->err = ERR_OK; + *msg->addr = *ipaddr; + } + /* wake up the application task waiting in netconn_gethostbyname */ + sys_sem_signal(msg->sem); +} + +/** + * Execute a DNS query + * Called from netconn_gethostbyname + * + * @param arg the dns_api_msg pointing to the query + */ +void +do_gethostbyname(void *arg) +{ + struct dns_api_msg *msg = (struct dns_api_msg*)arg; + + *msg->err = dns_gethostbyname(msg->name, msg->addr, do_dns_found, msg); + if (*msg->err != ERR_INPROGRESS) { + /* on error or immediate success, wake up the application + * task waiting in netconn_gethostbyname */ + sys_sem_signal(msg->sem); + } +} +#endif /* LWIP_DNS */ + +#endif /* LWIP_NETCONN */ diff --git a/user/mpy/lib/lwip/src/api/err.c b/user/mpy/lib/lwip/src/api/err.c new file mode 100644 index 0000000..92fa8b7 --- /dev/null +++ b/user/mpy/lib/lwip/src/api/err.c @@ -0,0 +1,75 @@ +/** + * @file + * Error Management module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/err.h" + +#ifdef LWIP_DEBUG + +static const char *err_strerr[] = { + "Ok.", /* ERR_OK 0 */ + "Out of memory error.", /* ERR_MEM -1 */ + "Buffer error.", /* ERR_BUF -2 */ + "Timeout.", /* ERR_TIMEOUT -3 */ + "Routing problem.", /* ERR_RTE -4 */ + "Operation in progress.", /* ERR_INPROGRESS -5 */ + "Illegal value.", /* ERR_VAL -6 */ + "Operation would block.", /* ERR_WOULDBLOCK -7 */ + "Address in use.", /* ERR_USE -8 */ + "Already connected.", /* ERR_ISCONN -9 */ + "Connection aborted.", /* ERR_ABRT -10 */ + "Connection reset.", /* ERR_RST -11 */ + "Connection closed.", /* ERR_CLSD -12 */ + "Not connected.", /* ERR_CONN -13 */ + "Illegal argument.", /* ERR_ARG -14 */ + "Low-level netif error.", /* ERR_IF -15 */ +}; + +/** + * Convert an lwip internal error to a string representation. + * + * @param err an lwip internal err_t + * @return a string representation for err + */ +const char * +lwip_strerr(err_t err) +{ + return err_strerr[-err]; + +} + +#endif /* LWIP_DEBUG */ diff --git a/user/mpy/lib/lwip/src/api/netbuf.c b/user/mpy/lib/lwip/src/api/netbuf.c new file mode 100644 index 0000000..9390c9e --- /dev/null +++ b/user/mpy/lib/lwip/src/api/netbuf.c @@ -0,0 +1,245 @@ +/** + * @file + * Network buffer management + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/netbuf.h" +#include "lwip/memp.h" + +#include + +/** + * Create (allocate) and initialize a new netbuf. + * The netbuf doesn't yet contain a packet buffer! + * + * @return a pointer to a new netbuf + * NULL on lack of memory + */ +struct +netbuf *netbuf_new(void) +{ + struct netbuf *buf; + + buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); + if (buf != NULL) { + buf->p = NULL; + buf->ptr = NULL; + ip_addr_set_any(&buf->addr); + buf->port = 0; +#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY +#if LWIP_CHECKSUM_ON_COPY + buf->flags = 0; +#endif /* LWIP_CHECKSUM_ON_COPY */ + buf->toport_chksum = 0; +#if LWIP_NETBUF_RECVINFO + ip_addr_set_any(&buf->toaddr); +#endif /* LWIP_NETBUF_RECVINFO */ +#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ + return buf; + } else { + return NULL; + } +} + +/** + * Deallocate a netbuf allocated by netbuf_new(). + * + * @param buf pointer to a netbuf allocated by netbuf_new() + */ +void +netbuf_delete(struct netbuf *buf) +{ + if (buf != NULL) { + if (buf->p != NULL) { + pbuf_free(buf->p); + buf->p = buf->ptr = NULL; + } + memp_free(MEMP_NETBUF, buf); + } +} + +/** + * Allocate memory for a packet buffer for a given netbuf. + * + * @param buf the netbuf for which to allocate a packet buffer + * @param size the size of the packet buffer to allocate + * @return pointer to the allocated memory + * NULL if no memory could be allocated + */ +void * +netbuf_alloc(struct netbuf *buf, u16_t size) +{ + LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;); + + /* Deallocate any previously allocated memory. */ + if (buf->p != NULL) { + pbuf_free(buf->p); + } + buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM); + if (buf->p == NULL) { + return NULL; + } + LWIP_ASSERT("check that first pbuf can hold size", + (buf->p->len >= size)); + buf->ptr = buf->p; + return buf->p->payload; +} + +/** + * Free the packet buffer included in a netbuf + * + * @param buf pointer to the netbuf which contains the packet buffer to free + */ +void +netbuf_free(struct netbuf *buf) +{ + LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); + if (buf->p != NULL) { + pbuf_free(buf->p); + } + buf->p = buf->ptr = NULL; +} + +/** + * Let a netbuf reference existing (non-volatile) data. + * + * @param buf netbuf which should reference the data + * @param dataptr pointer to the data to reference + * @param size size of the data + * @return ERR_OK if data is referenced + * ERR_MEM if data couldn't be referenced due to lack of memory + */ +err_t +netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size) +{ + LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;); + if (buf->p != NULL) { + pbuf_free(buf->p); + } + buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF); + if (buf->p == NULL) { + buf->ptr = NULL; + return ERR_MEM; + } + buf->p->payload = (void*)dataptr; + buf->p->len = buf->p->tot_len = size; + buf->ptr = buf->p; + return ERR_OK; +} + +/** + * Chain one netbuf to another (@see pbuf_chain) + * + * @param head the first netbuf + * @param tail netbuf to chain after head, freed by this function, may not be reference after returning + */ +void +netbuf_chain(struct netbuf *head, struct netbuf *tail) +{ + LWIP_ERROR("netbuf_ref: invalid head", (head != NULL), return;); + LWIP_ERROR("netbuf_chain: invalid tail", (tail != NULL), return;); + pbuf_cat(head->p, tail->p); + head->ptr = head->p; + memp_free(MEMP_NETBUF, tail); +} + +/** + * Get the data pointer and length of the data inside a netbuf. + * + * @param buf netbuf to get the data from + * @param dataptr pointer to a void pointer where to store the data pointer + * @param len pointer to an u16_t where the length of the data is stored + * @return ERR_OK if the information was retreived, + * ERR_BUF on error. + */ +err_t +netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len) +{ + LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;); + LWIP_ERROR("netbuf_data: invalid dataptr", (dataptr != NULL), return ERR_ARG;); + LWIP_ERROR("netbuf_data: invalid len", (len != NULL), return ERR_ARG;); + + if (buf->ptr == NULL) { + return ERR_BUF; + } + *dataptr = buf->ptr->payload; + *len = buf->ptr->len; + return ERR_OK; +} + +/** + * Move the current data pointer of a packet buffer contained in a netbuf + * to the next part. + * The packet buffer itself is not modified. + * + * @param buf the netbuf to modify + * @return -1 if there is no next part + * 1 if moved to the next part but now there is no next part + * 0 if moved to the next part and there are still more parts + */ +s8_t +netbuf_next(struct netbuf *buf) +{ + LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return -1;); + if (buf->ptr->next == NULL) { + return -1; + } + buf->ptr = buf->ptr->next; + if (buf->ptr->next == NULL) { + return 1; + } + return 0; +} + +/** + * Move the current data pointer of a packet buffer contained in a netbuf + * to the beginning of the packet. + * The packet buffer itself is not modified. + * + * @param buf the netbuf to modify + */ +void +netbuf_first(struct netbuf *buf) +{ + LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); + buf->ptr = buf->p; +} + +#endif /* LWIP_NETCONN */ diff --git a/user/mpy/lib/lwip/src/api/netdb.c b/user/mpy/lib/lwip/src/api/netdb.c new file mode 100644 index 0000000..6a4bac5 --- /dev/null +++ b/user/mpy/lib/lwip/src/api/netdb.c @@ -0,0 +1,353 @@ +/** + * @file + * API functions for name resolving + * + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ + +#include "lwip/netdb.h" + +#if LWIP_DNS && LWIP_SOCKET + +#include "lwip/err.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/ip_addr.h" +#include "lwip/api.h" +#include "lwip/dns.h" + +#include +#include + +/** helper struct for gethostbyname_r to access the char* buffer */ +struct gethostbyname_r_helper { + ip_addr_t *addr_list[2]; + ip_addr_t addr; + char *aliases; +}; + +/** h_errno is exported in netdb.h for access by applications. */ +#if LWIP_DNS_API_DECLARE_H_ERRNO +int h_errno; +#endif /* LWIP_DNS_API_DECLARE_H_ERRNO */ + +/** define "hostent" variables storage: 0 if we use a static (but unprotected) + * set of variables for lwip_gethostbyname, 1 if we use a local storage */ +#ifndef LWIP_DNS_API_HOSTENT_STORAGE +#define LWIP_DNS_API_HOSTENT_STORAGE 0 +#endif + +/** define "hostent" variables storage */ +#if LWIP_DNS_API_HOSTENT_STORAGE +#define HOSTENT_STORAGE +#else +#define HOSTENT_STORAGE static +#endif /* LWIP_DNS_API_STATIC_HOSTENT */ + +/** + * Returns an entry containing addresses of address family AF_INET + * for the host with name name. + * Due to dns_gethostbyname limitations, only one address is returned. + * + * @param name the hostname to resolve + * @return an entry containing addresses of address family AF_INET + * for the host with name name + */ +struct hostent* +lwip_gethostbyname(const char *name) +{ + err_t err; + ip_addr_t addr; + + /* buffer variables for lwip_gethostbyname() */ + HOSTENT_STORAGE struct hostent s_hostent; + HOSTENT_STORAGE char *s_aliases; + HOSTENT_STORAGE ip_addr_t s_hostent_addr; + HOSTENT_STORAGE ip_addr_t *s_phostent_addr[2]; + + /* query host IP address */ + err = netconn_gethostbyname(name, &addr); + if (err != ERR_OK) { + LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err)); + h_errno = HOST_NOT_FOUND; + return NULL; + } + + /* fill hostent */ + s_hostent_addr = addr; + s_phostent_addr[0] = &s_hostent_addr; + s_phostent_addr[1] = NULL; + s_hostent.h_name = (char*)name; + s_hostent.h_aliases = &s_aliases; + s_hostent.h_addrtype = AF_INET; + s_hostent.h_length = sizeof(ip_addr_t); + s_hostent.h_addr_list = (char**)&s_phostent_addr; + +#if DNS_DEBUG + /* dump hostent */ + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_name == %s\n", s_hostent.h_name)); + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases == %p\n", s_hostent.h_aliases)); + if (s_hostent.h_aliases != NULL) { + u8_t idx; + for ( idx=0; s_hostent.h_aliases[idx]; idx++) { + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]-> == %p\n", idx, s_hostent.h_aliases[idx])); + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]-> == %s\n", idx, s_hostent.h_aliases[idx])); + } + } + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addrtype == %d\n", s_hostent.h_addrtype)); + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_length == %d\n", s_hostent.h_length)); + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list == %p\n", s_hostent.h_addr_list)); + if (s_hostent.h_addr_list != NULL) { + u8_t idx; + for ( idx=0; s_hostent.h_addr_list[idx]; idx++) { + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i] == %p\n", idx, s_hostent.h_addr_list[idx])); + LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ip_ntoa((ip_addr_t*)s_hostent.h_addr_list[idx]))); + } + } +#endif /* DNS_DEBUG */ + +#if LWIP_DNS_API_HOSTENT_STORAGE + /* this function should return the "per-thread" hostent after copy from s_hostent */ + return sys_thread_hostent(&s_hostent); +#else + return &s_hostent; +#endif /* LWIP_DNS_API_HOSTENT_STORAGE */ +} + +/** + * Thread-safe variant of lwip_gethostbyname: instead of using a static + * buffer, this function takes buffer and errno pointers as arguments + * and uses these for the result. + * + * @param name the hostname to resolve + * @param ret pre-allocated struct where to store the result + * @param buf pre-allocated buffer where to store additional data + * @param buflen the size of buf + * @param result pointer to a hostent pointer that is set to ret on success + * and set to zero on error + * @param h_errnop pointer to an int where to store errors (instead of modifying + * the global h_errno) + * @return 0 on success, non-zero on error, additional error information + * is stored in *h_errnop instead of h_errno to be thread-safe + */ +int +lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, + size_t buflen, struct hostent **result, int *h_errnop) +{ + err_t err; + struct gethostbyname_r_helper *h; + char *hostname; + size_t namelen; + int lh_errno; + + if (h_errnop == NULL) { + /* ensure h_errnop is never NULL */ + h_errnop = &lh_errno; + } + + if (result == NULL) { + /* not all arguments given */ + *h_errnop = EINVAL; + return -1; + } + /* first thing to do: set *result to nothing */ + *result = NULL; + if ((name == NULL) || (ret == NULL) || (buf == NULL)) { + /* not all arguments given */ + *h_errnop = EINVAL; + return -1; + } + + namelen = strlen(name); + if (buflen < (sizeof(struct gethostbyname_r_helper) + namelen + 1 + (MEM_ALIGNMENT - 1))) { + /* buf can't hold the data needed + a copy of name */ + *h_errnop = ERANGE; + return -1; + } + + h = (struct gethostbyname_r_helper*)LWIP_MEM_ALIGN(buf); + hostname = ((char*)h) + sizeof(struct gethostbyname_r_helper); + + /* query host IP address */ + err = netconn_gethostbyname(name, &h->addr); + if (err != ERR_OK) { + LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err)); + *h_errnop = HOST_NOT_FOUND; + return -1; + } + + /* copy the hostname into buf */ + MEMCPY(hostname, name, namelen); + hostname[namelen] = 0; + + /* fill hostent */ + h->addr_list[0] = &h->addr; + h->addr_list[1] = NULL; + h->aliases = NULL; + ret->h_name = hostname; + ret->h_aliases = &h->aliases; + ret->h_addrtype = AF_INET; + ret->h_length = sizeof(ip_addr_t); + ret->h_addr_list = (char**)&h->addr_list; + + /* set result != NULL */ + *result = ret; + + /* return success */ + return 0; +} + +/** + * Frees one or more addrinfo structures returned by getaddrinfo(), along with + * any additional storage associated with those structures. If the ai_next field + * of the structure is not null, the entire list of structures is freed. + * + * @param ai struct addrinfo to free + */ +void +lwip_freeaddrinfo(struct addrinfo *ai) +{ + struct addrinfo *next; + + while (ai != NULL) { + next = ai->ai_next; + memp_free(MEMP_NETDB, ai); + ai = next; + } +} + +/** + * Translates the name of a service location (for example, a host name) and/or + * a service name and returns a set of socket addresses and associated + * information to be used in creating a socket with which to address the + * specified service. + * Memory for the result is allocated internally and must be freed by calling + * lwip_freeaddrinfo()! + * + * Due to a limitation in dns_gethostbyname, only the first address of a + * host is returned. + * Also, service names are not supported (only port numbers)! + * + * @param nodename descriptive name or address string of the host + * (may be NULL -> local address) + * @param servname port number as string of NULL + * @param hints structure containing input values that set socktype and protocol + * @param res pointer to a pointer where to store the result (set to NULL on failure) + * @return 0 on success, non-zero on failure + */ +int +lwip_getaddrinfo(const char *nodename, const char *servname, + const struct addrinfo *hints, struct addrinfo **res) +{ + err_t err; + ip_addr_t addr; + struct addrinfo *ai; + struct sockaddr_in *sa = NULL; + int port_nr = 0; + size_t total_size; + size_t namelen = 0; + + if (res == NULL) { + return EAI_FAIL; + } + *res = NULL; + if ((nodename == NULL) && (servname == NULL)) { + return EAI_NONAME; + } + + if (servname != NULL) { + /* service name specified: convert to port number + * @todo?: currently, only ASCII integers (port numbers) are supported! */ + port_nr = atoi(servname); + if ((port_nr <= 0) || (port_nr > 0xffff)) { + return EAI_SERVICE; + } + } + + if (nodename != NULL) { + /* service location specified, try to resolve */ + err = netconn_gethostbyname(nodename, &addr); + if (err != ERR_OK) { + return EAI_FAIL; + } + } else { + /* service location specified, use loopback address */ + ip_addr_set_loopback(&addr); + } + + total_size = sizeof(struct addrinfo) + sizeof(struct sockaddr_in); + if (nodename != NULL) { + namelen = strlen(nodename); + LWIP_ASSERT("namelen is too long", (namelen + 1) <= (mem_size_t)-1); + total_size += namelen + 1; + } + /* If this fails, please report to lwip-devel! :-) */ + LWIP_ASSERT("total_size <= NETDB_ELEM_SIZE: please report this!", + total_size <= NETDB_ELEM_SIZE); + ai = (struct addrinfo *)memp_malloc(MEMP_NETDB); + if (ai == NULL) { + goto memerr; + } + memset(ai, 0, total_size); + sa = (struct sockaddr_in*)((u8_t*)ai + sizeof(struct addrinfo)); + /* set up sockaddr */ + inet_addr_from_ipaddr(&sa->sin_addr, &addr); + sa->sin_family = AF_INET; + sa->sin_len = sizeof(struct sockaddr_in); + sa->sin_port = htons((u16_t)port_nr); + + /* set up addrinfo */ + ai->ai_family = AF_INET; + if (hints != NULL) { + /* copy socktype & protocol from hints if specified */ + ai->ai_socktype = hints->ai_socktype; + ai->ai_protocol = hints->ai_protocol; + } + if (nodename != NULL) { + /* copy nodename to canonname if specified */ + ai->ai_canonname = ((char*)ai + sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); + MEMCPY(ai->ai_canonname, nodename, namelen); + ai->ai_canonname[namelen] = 0; + } + ai->ai_addrlen = sizeof(struct sockaddr_in); + ai->ai_addr = (struct sockaddr*)sa; + + *res = ai; + + return 0; +memerr: + if (ai != NULL) { + memp_free(MEMP_NETDB, ai); + } + return EAI_MEMORY; +} + +#endif /* LWIP_DNS && LWIP_SOCKET */ diff --git a/user/mpy/lib/lwip/src/api/netifapi.c b/user/mpy/lib/lwip/src/api/netifapi.c new file mode 100644 index 0000000..43e4720 --- /dev/null +++ b/user/mpy/lib/lwip/src/api/netifapi.c @@ -0,0 +1,160 @@ +/** + * @file + * Network Interface Sequential API module + * + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#include "lwip/opt.h" + +#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/netifapi.h" +#include "lwip/tcpip.h" + +/** + * Call netif_add() inside the tcpip_thread context. + */ +void +do_netifapi_netif_add(struct netifapi_msg_msg *msg) +{ + if (!netif_add( msg->netif, + msg->msg.add.ipaddr, + msg->msg.add.netmask, + msg->msg.add.gw, + msg->msg.add.state, + msg->msg.add.init, + msg->msg.add.input)) { + msg->err = ERR_IF; + } else { + msg->err = ERR_OK; + } + TCPIP_NETIFAPI_ACK(msg); +} + +/** + * Call netif_set_addr() inside the tcpip_thread context. + */ +void +do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg) +{ + netif_set_addr( msg->netif, + msg->msg.add.ipaddr, + msg->msg.add.netmask, + msg->msg.add.gw); + msg->err = ERR_OK; + TCPIP_NETIFAPI_ACK(msg); +} + +/** + * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the + * tcpip_thread context. + */ +void +do_netifapi_netif_common(struct netifapi_msg_msg *msg) +{ + if (msg->msg.common.errtfunc != NULL) { + msg->err = msg->msg.common.errtfunc(msg->netif); + } else { + msg->err = ERR_OK; + msg->msg.common.voidfunc(msg->netif); + } + TCPIP_NETIFAPI_ACK(msg); +} + +/** + * Call netif_add() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see netif_add() + */ +err_t +netifapi_netif_add(struct netif *netif, + ip_addr_t *ipaddr, + ip_addr_t *netmask, + ip_addr_t *gw, + void *state, + netif_init_fn init, + netif_input_fn input) +{ + struct netifapi_msg msg; + msg.function = do_netifapi_netif_add; + msg.msg.netif = netif; + msg.msg.msg.add.ipaddr = ipaddr; + msg.msg.msg.add.netmask = netmask; + msg.msg.msg.add.gw = gw; + msg.msg.msg.add.state = state; + msg.msg.msg.add.init = init; + msg.msg.msg.add.input = input; + TCPIP_NETIFAPI(&msg); + return msg.msg.err; +} + +/** + * Call netif_set_addr() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see netif_set_addr() + */ +err_t +netifapi_netif_set_addr(struct netif *netif, + ip_addr_t *ipaddr, + ip_addr_t *netmask, + ip_addr_t *gw) +{ + struct netifapi_msg msg; + msg.function = do_netifapi_netif_set_addr; + msg.msg.netif = netif; + msg.msg.msg.add.ipaddr = ipaddr; + msg.msg.msg.add.netmask = netmask; + msg.msg.msg.add.gw = gw; + TCPIP_NETIFAPI(&msg); + return msg.msg.err; +} + +/** + * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe + * way by running that function inside the tcpip_thread context. + * + * @note use only for functions where there is only "netif" parameter. + */ +err_t +netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc, + netifapi_errt_fn errtfunc) +{ + struct netifapi_msg msg; + msg.function = do_netifapi_netif_common; + msg.msg.netif = netif; + msg.msg.msg.common.voidfunc = voidfunc; + msg.msg.msg.common.errtfunc = errtfunc; + TCPIP_NETIFAPI(&msg); + return msg.msg.err; +} + +#endif /* LWIP_NETIF_API */ diff --git a/user/mpy/lib/lwip/src/api/sockets.c b/user/mpy/lib/lwip/src/api/sockets.c new file mode 100644 index 0000000..359919e --- /dev/null +++ b/user/mpy/lib/lwip/src/api/sockets.c @@ -0,0 +1,2374 @@ +/** + * @file + * Sockets BSD-Like API module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * Improved by Marc Boucher and David Haas + * + */ + +#include "lwip/opt.h" + +#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/sockets.h" +#include "lwip/api.h" +#include "lwip/sys.h" +#include "lwip/igmp.h" +#include "lwip/inet.h" +#include "lwip/tcp.h" +#include "lwip/raw.h" +#include "lwip/udp.h" +#include "lwip/tcpip.h" +#include "lwip/pbuf.h" +#if LWIP_CHECKSUM_ON_COPY +#include "lwip/inet_chksum.h" +#endif + +#include + +#define NUM_SOCKETS MEMP_NUM_NETCONN + +/** Contains all internal pointers and states used for a socket */ +struct lwip_sock { + /** sockets currently are built on netconns, each socket has one netconn */ + struct netconn *conn; + /** data that was left from the previous read */ + void *lastdata; + /** offset in the data that was left from the previous read */ + u16_t lastoffset; + /** number of times data was received, set by event_callback(), + tested by the receive and select functions */ + s16_t rcvevent; + /** number of times data was ACKed (free send buffer), set by event_callback(), + tested by select */ + u16_t sendevent; + /** error happened for this socket, set by event_callback(), tested by select */ + u16_t errevent; + /** last error that occurred on this socket */ + int err; + /** counter of how many threads are waiting for this socket using select */ + int select_waiting; +}; + +/** Description for a task waiting in select */ +struct lwip_select_cb { + /** Pointer to the next waiting task */ + struct lwip_select_cb *next; + /** Pointer to the previous waiting task */ + struct lwip_select_cb *prev; + /** readset passed to select */ + fd_set *readset; + /** writeset passed to select */ + fd_set *writeset; + /** unimplemented: exceptset passed to select */ + fd_set *exceptset; + /** don't signal the same semaphore twice: set to 1 when signalled */ + int sem_signalled; + /** semaphore to wake up a task waiting for select */ + sys_sem_t sem; +}; + +/** This struct is used to pass data to the set/getsockopt_internal + * functions running in tcpip_thread context (only a void* is allowed) */ +struct lwip_setgetsockopt_data { + /** socket struct for which to change options */ + struct lwip_sock *sock; +#ifdef LWIP_DEBUG + /** socket index for which to change options */ + int s; +#endif /* LWIP_DEBUG */ + /** level of the option to process */ + int level; + /** name of the option to process */ + int optname; + /** set: value to set the option to + * get: value of the option is stored here */ + void *optval; + /** size of *optval */ + socklen_t *optlen; + /** if an error occures, it is temporarily stored here */ + err_t err; +}; + +/** The global array of available sockets */ +static struct lwip_sock sockets[NUM_SOCKETS]; +/** The global list of tasks waiting for select */ +static struct lwip_select_cb *select_cb_list; +/** This counter is increased from lwip_select when the list is chagned + and checked in event_callback to see if it has changed. */ +static volatile int select_cb_ctr; + +/** Table to quickly map an lwIP error (err_t) to a socket error + * by using -err as an index */ +static const int err_to_errno_table[] = { + 0, /* ERR_OK 0 No error, everything OK. */ + ENOMEM, /* ERR_MEM -1 Out of memory error. */ + ENOBUFS, /* ERR_BUF -2 Buffer error. */ + EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */ + EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ + EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ + EINVAL, /* ERR_VAL -6 Illegal value. */ + EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ + EADDRINUSE, /* ERR_USE -8 Address in use. */ + EALREADY, /* ERR_ISCONN -9 Already connected. */ + ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */ + ECONNRESET, /* ERR_RST -11 Connection reset. */ + ENOTCONN, /* ERR_CLSD -12 Connection closed. */ + ENOTCONN, /* ERR_CONN -13 Not connected. */ + EIO, /* ERR_ARG -14 Illegal argument. */ + -1, /* ERR_IF -15 Low-level netif error */ +}; + +#define ERR_TO_ERRNO_TABLE_SIZE \ + (sizeof(err_to_errno_table)/sizeof(err_to_errno_table[0])) + +#define err_to_errno(err) \ + ((unsigned)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ? \ + err_to_errno_table[-(err)] : EIO) + +#ifdef ERRNO +#ifndef set_errno +#define set_errno(err) errno = (err) +#endif +#else /* ERRNO */ +#define set_errno(err) +#endif /* ERRNO */ + +#define sock_set_errno(sk, e) do { \ + sk->err = (e); \ + set_errno(sk->err); \ +} while (0) + +/* Forward delcaration of some functions */ +static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len); +static void lwip_getsockopt_internal(void *arg); +static void lwip_setsockopt_internal(void *arg); + +/** + * Initialize this module. This function has to be called before any other + * functions in this module! + */ +void +lwip_socket_init(void) +{ +} + +/** + * Map a externally used socket index to the internal socket representation. + * + * @param s externally used socket index + * @return struct lwip_sock for the socket or NULL if not found + */ +static struct lwip_sock * +get_socket(int s) +{ + struct lwip_sock *sock; + + if ((s < 0) || (s >= NUM_SOCKETS)) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s)); + set_errno(EBADF); + return NULL; + } + + sock = &sockets[s]; + + if (!sock->conn) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s)); + set_errno(EBADF); + return NULL; + } + + return sock; +} + +/** + * Same as get_socket but doesn't set errno + * + * @param s externally used socket index + * @return struct lwip_sock for the socket or NULL if not found + */ +static struct lwip_sock * +tryget_socket(int s) +{ + if ((s < 0) || (s >= NUM_SOCKETS)) { + return NULL; + } + if (!sockets[s].conn) { + return NULL; + } + return &sockets[s]; +} + +/** + * Allocate a new socket for a given netconn. + * + * @param newconn the netconn for which to allocate a socket + * @param accepted 1 if socket has been created by accept(), + * 0 if socket has been created by socket() + * @return the index of the new socket; -1 on error + */ +static int +alloc_socket(struct netconn *newconn, int accepted) +{ + int i; + SYS_ARCH_DECL_PROTECT(lev); + + /* allocate a new socket identifier */ + for (i = 0; i < NUM_SOCKETS; ++i) { + /* Protect socket array */ + SYS_ARCH_PROTECT(lev); + if (!sockets[i].conn) { + sockets[i].conn = newconn; + /* The socket is not yet known to anyone, so no need to protect + after having marked it as used. */ + SYS_ARCH_UNPROTECT(lev); + sockets[i].lastdata = NULL; + sockets[i].lastoffset = 0; + sockets[i].rcvevent = 0; + /* TCP sendbuf is empty, but the socket is not yet writable until connected + * (unless it has been created by accept()). */ + sockets[i].sendevent = (newconn->type == NETCONN_TCP ? (accepted != 0) : 1); + sockets[i].errevent = 0; + sockets[i].err = 0; + sockets[i].select_waiting = 0; + return i; + } + SYS_ARCH_UNPROTECT(lev); + } + return -1; +} + +/** Free a socket. The socket's netconn must have been + * delete before! + * + * @param sock the socket to free + * @param is_tcp != 0 for TCP sockets, used to free lastdata + */ +static void +free_socket(struct lwip_sock *sock, int is_tcp) +{ + void *lastdata; + SYS_ARCH_DECL_PROTECT(lev); + + lastdata = sock->lastdata; + sock->lastdata = NULL; + sock->lastoffset = 0; + sock->err = 0; + + /* Protect socket array */ + SYS_ARCH_PROTECT(lev); + sock->conn = NULL; + SYS_ARCH_UNPROTECT(lev); + /* don't use 'sock' after this line, as another task might have allocated it */ + + if (lastdata != NULL) { + if (is_tcp) { + pbuf_free((struct pbuf *)lastdata); + } else { + netbuf_delete((struct netbuf *)lastdata); + } + } +} + +/* Below this, the well-known socket functions are implemented. + * Use google.com or opengroup.org to get a good description :-) + * + * Exceptions are documented! + */ + +int +lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) +{ + struct lwip_sock *sock, *nsock; + struct netconn *newconn; + ip_addr_t naddr; + u16_t port; + int newsock; + struct sockaddr_in sin; + err_t err; + SYS_ARCH_DECL_PROTECT(lev); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s)); + sock = get_socket(s); + if (!sock) { + return -1; + } + + if (netconn_is_nonblocking(sock->conn) && (sock->rcvevent <= 0)) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): returning EWOULDBLOCK\n", s)); + sock_set_errno(sock, EWOULDBLOCK); + return -1; + } + + /* wait for a new connection */ + err = netconn_accept(sock->conn, &newconn); + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_acept failed, err=%d\n", s, err)); + if (netconn_type(sock->conn) != NETCONN_TCP) { + sock_set_errno(sock, EOPNOTSUPP); + return EOPNOTSUPP; + } + sock_set_errno(sock, err_to_errno(err)); + return -1; + } + LWIP_ASSERT("newconn != NULL", newconn != NULL); + /* Prevent automatic window updates, we do this on our own! */ + netconn_set_noautorecved(newconn, 1); + + /* get the IP address and port of the remote host */ + err = netconn_peer(newconn, &naddr, &port); + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err)); + netconn_delete(newconn); + sock_set_errno(sock, err_to_errno(err)); + return -1; + } + + /* Note that POSIX only requires us to check addr is non-NULL. addrlen must + * not be NULL if addr is valid. + */ + if (NULL != addr) { + LWIP_ASSERT("addr valid but addrlen NULL", addrlen != NULL); + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + inet_addr_from_ipaddr(&sin.sin_addr, &naddr); + + if (*addrlen > sizeof(sin)) + *addrlen = sizeof(sin); + + MEMCPY(addr, &sin, *addrlen); + } + + newsock = alloc_socket(newconn, 1); + if (newsock == -1) { + netconn_delete(newconn); + sock_set_errno(sock, ENFILE); + return -1; + } + LWIP_ASSERT("invalid socket index", (newsock >= 0) && (newsock < NUM_SOCKETS)); + LWIP_ASSERT("newconn->callback == event_callback", newconn->callback == event_callback); + nsock = &sockets[newsock]; + + /* See event_callback: If data comes in right away after an accept, even + * though the server task might not have created a new socket yet. + * In that case, newconn->socket is counted down (newconn->socket--), + * so nsock->rcvevent is >= 1 here! + */ + SYS_ARCH_PROTECT(lev); + nsock->rcvevent += (s16_t)(-1 - newconn->socket); + newconn->socket = newsock; + SYS_ARCH_UNPROTECT(lev); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); + ip_addr_debug_print(SOCKETS_DEBUG, &naddr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", port)); + + sock_set_errno(sock, 0); + return newsock; +} + +int +lwip_bind(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct lwip_sock *sock; + ip_addr_t local_addr; + u16_t local_port; + err_t err; + const struct sockaddr_in *name_in; + + sock = get_socket(s); + if (!sock) { + return -1; + } + + /* check size, familiy and alignment of 'name' */ + LWIP_ERROR("lwip_bind: invalid address", ((namelen == sizeof(struct sockaddr_in)) && + ((name->sa_family) == AF_INET) && ((((mem_ptr_t)name) % 4) == 0)), + sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); + name_in = (const struct sockaddr_in *)(void*)name; + + inet_addr_to_ipaddr(&local_addr, &name_in->sin_addr); + local_port = name_in->sin_port; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s)); + ip_addr_debug_print(SOCKETS_DEBUG, &local_addr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", ntohs(local_port))); + + err = netconn_bind(sock->conn, &local_addr, ntohs(local_port)); + + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err)); + sock_set_errno(sock, err_to_errno(err)); + return -1; + } + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s)); + sock_set_errno(sock, 0); + return 0; +} + +int +lwip_close(int s) +{ + struct lwip_sock *sock; + int is_tcp = 0; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s)); + + sock = get_socket(s); + if (!sock) { + return -1; + } + + if(sock->conn != NULL) { + is_tcp = netconn_type(sock->conn) == NETCONN_TCP; + } else { + LWIP_ASSERT("sock->lastdata == NULL", sock->lastdata == NULL); + } + + netconn_delete(sock->conn); + + free_socket(sock, is_tcp); + set_errno(0); + return 0; +} + +int +lwip_connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct lwip_sock *sock; + err_t err; + const struct sockaddr_in *name_in; + + sock = get_socket(s); + if (!sock) { + return -1; + } + + /* check size, familiy and alignment of 'name' */ + LWIP_ERROR("lwip_connect: invalid address", ((namelen == sizeof(struct sockaddr_in)) && + ((name->sa_family) == AF_INET) && ((((mem_ptr_t)name) % 4) == 0)), + sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); + name_in = (const struct sockaddr_in *)(void*)name; + + if (name_in->sin_family == AF_UNSPEC) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); + err = netconn_disconnect(sock->conn); + } else { + ip_addr_t remote_addr; + u16_t remote_port; + + inet_addr_to_ipaddr(&remote_addr, &name_in->sin_addr); + remote_port = name_in->sin_port; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); + ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", ntohs(remote_port))); + + err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); + } + + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err)); + sock_set_errno(sock, err_to_errno(err)); + return -1; + } + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s)); + sock_set_errno(sock, 0); + return 0; +} + +/** + * Set a socket into listen mode. + * The socket may not have been used for another connection previously. + * + * @param s the socket to set to listening mode + * @param backlog (ATTENTION: needs TCP_LISTEN_BACKLOG=1) + * @return 0 on success, non-zero on failure + */ +int +lwip_listen(int s, int backlog) +{ + struct lwip_sock *sock; + err_t err; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog)); + + sock = get_socket(s); + if (!sock) { + return -1; + } + + /* limit the "backlog" parameter to fit in an u8_t */ + backlog = LWIP_MIN(LWIP_MAX(backlog, 0), 0xff); + + err = netconn_listen_with_backlog(sock->conn, (u8_t)backlog); + + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); + if (netconn_type(sock->conn) != NETCONN_TCP) { + sock_set_errno(sock, EOPNOTSUPP); + return EOPNOTSUPP; + } + sock_set_errno(sock, err_to_errno(err)); + return -1; + } + + sock_set_errno(sock, 0); + return 0; +} + +int +lwip_recvfrom(int s, void *mem, size_t len, int flags, + struct sockaddr *from, socklen_t *fromlen) +{ + struct lwip_sock *sock; + void *buf = NULL; + struct pbuf *p; + u16_t buflen, copylen; + int off = 0; + ip_addr_t *addr; + u16_t port; + u8_t done = 0; + err_t err; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %"SZT_F", 0x%x, ..)\n", s, mem, len, flags)); + sock = get_socket(s); + if (!sock) { + return -1; + } + + do { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: top while sock->lastdata=%p\n", sock->lastdata)); + /* Check if there is data left from the last recv operation. */ + if (sock->lastdata) { + buf = sock->lastdata; + } else { + /* If this is non-blocking call, then check first */ + if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) && + (sock->rcvevent <= 0)) { + if (off > 0) { + /* update receive window */ + netconn_recved(sock->conn, (u32_t)off); + /* already received data, return that */ + sock_set_errno(sock, 0); + return off; + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s)); + sock_set_errno(sock, EWOULDBLOCK); + return -1; + } + + /* No data was left from the previous operation, so we try to get + some from the network. */ + if (netconn_type(sock->conn) == NETCONN_TCP) { + err = netconn_recv_tcp_pbuf(sock->conn, (struct pbuf **)&buf); + } else { + err = netconn_recv(sock->conn, (struct netbuf **)&buf); + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: netconn_recv err=%d, netbuf=%p\n", + err, buf)); + + if (err != ERR_OK) { + if (off > 0) { + /* update receive window */ + netconn_recved(sock->conn, (u32_t)off); + /* already received data, return that */ + sock_set_errno(sock, 0); + return off; + } + /* We should really do some error checking here. */ + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL, error is \"%s\"!\n", + s, lwip_strerr(err))); + sock_set_errno(sock, err_to_errno(err)); + if (err == ERR_CLSD) { + return 0; + } else { + return -1; + } + } + LWIP_ASSERT("buf != NULL", buf != NULL); + sock->lastdata = buf; + } + + if (netconn_type(sock->conn) == NETCONN_TCP) { + p = (struct pbuf *)buf; + } else { + p = ((struct netbuf *)buf)->p; + } + buflen = p->tot_len; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: buflen=%"U16_F" len=%"SZT_F" off=%d sock->lastoffset=%"U16_F"\n", + buflen, len, off, sock->lastoffset)); + + buflen -= sock->lastoffset; + + if (len > buflen) { + copylen = buflen; + } else { + copylen = (u16_t)len; + } + + /* copy the contents of the received buffer into + the supplied memory pointer mem */ + pbuf_copy_partial(p, (u8_t*)mem + off, copylen, sock->lastoffset); + + off += copylen; + + if (netconn_type(sock->conn) == NETCONN_TCP) { + LWIP_ASSERT("invalid copylen, len would underflow", len >= copylen); + len -= copylen; + if ( (len <= 0) || + (p->flags & PBUF_FLAG_PUSH) || + (sock->rcvevent <= 0) || + ((flags & MSG_PEEK)!=0)) { + done = 1; + } + } else { + done = 1; + } + + /* Check to see from where the data was.*/ + if (done) { + ip_addr_t fromaddr; + if (from && fromlen) { + struct sockaddr_in sin; + + if (netconn_type(sock->conn) == NETCONN_TCP) { + addr = &fromaddr; + netconn_getaddr(sock->conn, addr, &port, 0); + } else { + addr = netbuf_fromaddr((struct netbuf *)buf); + port = netbuf_fromport((struct netbuf *)buf); + } + + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_port = htons(port); + inet_addr_from_ipaddr(&sin.sin_addr, addr); + + if (*fromlen > sizeof(sin)) { + *fromlen = sizeof(sin); + } + + MEMCPY(from, &sin, *fromlen); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); + ip_addr_debug_print(SOCKETS_DEBUG, addr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off)); + } else { +#if SOCKETS_DEBUG + if (netconn_type(sock->conn) == NETCONN_TCP) { + addr = &fromaddr; + netconn_getaddr(sock->conn, addr, &port, 0); + } else { + addr = netbuf_fromaddr((struct netbuf *)buf); + port = netbuf_fromport((struct netbuf *)buf); + } + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); + ip_addr_debug_print(SOCKETS_DEBUG, addr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off)); +#endif /* SOCKETS_DEBUG */ + } + } + + /* If we don't peek the incoming message... */ + if ((flags & MSG_PEEK) == 0) { + /* If this is a TCP socket, check if there is data left in the + buffer. If so, it should be saved in the sock structure for next + time around. */ + if ((netconn_type(sock->conn) == NETCONN_TCP) && (buflen - copylen > 0)) { + sock->lastdata = buf; + sock->lastoffset += copylen; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: lastdata now netbuf=%p\n", buf)); + } else { + sock->lastdata = NULL; + sock->lastoffset = 0; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: deleting netbuf=%p\n", buf)); + if (netconn_type(sock->conn) == NETCONN_TCP) { + pbuf_free((struct pbuf *)buf); + } else { + netbuf_delete((struct netbuf *)buf); + } + } + } + } while (!done); + + if (off > 0) { + /* update receive window */ + netconn_recved(sock->conn, (u32_t)off); + } + sock_set_errno(sock, 0); + return off; +} + +int +lwip_read(int s, void *mem, size_t len) +{ + return lwip_recvfrom(s, mem, len, 0, NULL, NULL); +} + +int +lwip_recv(int s, void *mem, size_t len, int flags) +{ + return lwip_recvfrom(s, mem, len, flags, NULL, NULL); +} + +int +lwip_send(int s, const void *data, size_t size, int flags) +{ + struct lwip_sock *sock; + err_t err; + u8_t write_flags; + size_t written; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%"SZT_F", flags=0x%x)\n", + s, data, size, flags)); + + sock = get_socket(s); + if (!sock) { + return -1; + } + + if (sock->conn->type != NETCONN_TCP) { +#if (LWIP_UDP || LWIP_RAW) + return lwip_sendto(s, data, size, flags, NULL, 0); +#else /* (LWIP_UDP || LWIP_RAW) */ + sock_set_errno(sock, err_to_errno(ERR_ARG)); + return -1; +#endif /* (LWIP_UDP || LWIP_RAW) */ + } + + write_flags = NETCONN_COPY | + ((flags & MSG_MORE) ? NETCONN_MORE : 0) | + ((flags & MSG_DONTWAIT) ? NETCONN_DONTBLOCK : 0); + written = 0; + err = netconn_write_partly(sock->conn, data, size, write_flags, &written); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d written=%"SZT_F"\n", s, err, written)); + sock_set_errno(sock, err_to_errno(err)); + return (err == ERR_OK ? (int)written : -1); +} + +int +lwip_sendto(int s, const void *data, size_t size, int flags, + const struct sockaddr *to, socklen_t tolen) +{ + struct lwip_sock *sock; + err_t err; + u16_t short_size; + const struct sockaddr_in *to_in; + u16_t remote_port; +#if !LWIP_TCPIP_CORE_LOCKING + struct netbuf buf; +#endif + + sock = get_socket(s); + if (!sock) { + return -1; + } + + if (sock->conn->type == NETCONN_TCP) { +#if LWIP_TCP + return lwip_send(s, data, size, flags); +#else /* LWIP_TCP */ + LWIP_UNUSED_ARG(flags); + sock_set_errno(sock, err_to_errno(ERR_ARG)); + return -1; +#endif /* LWIP_TCP */ + } + + /* @todo: split into multiple sendto's? */ + LWIP_ASSERT("lwip_sendto: size must fit in u16_t", size <= 0xffff); + short_size = (u16_t)size; + LWIP_ERROR("lwip_sendto: invalid address", (((to == NULL) && (tolen == 0)) || + ((tolen == sizeof(struct sockaddr_in)) && + ((to->sa_family) == AF_INET) && ((((mem_ptr_t)to) % 4) == 0))), + sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); + to_in = (const struct sockaddr_in *)(void*)to; + +#if LWIP_TCPIP_CORE_LOCKING + /* Should only be consider like a sample or a simple way to experiment this option (no check of "to" field...) */ + { + struct pbuf* p; + ip_addr_t *remote_addr; + +#if LWIP_NETIF_TX_SINGLE_PBUF + p = pbuf_alloc(PBUF_TRANSPORT, short_size, PBUF_RAM); + if (p != NULL) { +#if LWIP_CHECKSUM_ON_COPY + u16_t chksum = 0; + if (sock->conn->type != NETCONN_RAW) { + chksum = LWIP_CHKSUM_COPY(p->payload, data, short_size); + } else +#endif /* LWIP_CHECKSUM_ON_COPY */ + MEMCPY(p->payload, data, size); +#else /* LWIP_NETIF_TX_SINGLE_PBUF */ + p = pbuf_alloc(PBUF_TRANSPORT, short_size, PBUF_REF); + if (p != NULL) { + p->payload = (void*)data; +#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ + + if (to_in != NULL) { + inet_addr_to_ipaddr_p(remote_addr, &to_in->sin_addr); + remote_port = ntohs(to_in->sin_port); + } else { + remote_addr = &sock->conn->pcb.ip->remote_ip; +#if LWIP_UDP + if (NETCONNTYPE_GROUP(sock->conn->type) == NETCONN_UDP) { + remote_port = sock->conn->pcb.udp->remote_port; + } else +#endif /* LWIP_UDP */ + { + remote_port = 0; + } + } + + LOCK_TCPIP_CORE(); + if (netconn_type(sock->conn) == NETCONN_RAW) { +#if LWIP_RAW + err = sock->conn->last_err = raw_sendto(sock->conn->pcb.raw, p, remote_addr); +#else /* LWIP_RAW */ + err = ERR_ARG; +#endif /* LWIP_RAW */ + } +#if LWIP_UDP && LWIP_RAW + else +#endif /* LWIP_UDP && LWIP_RAW */ + { +#if LWIP_UDP +#if LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF + err = sock->conn->last_err = udp_sendto_chksum(sock->conn->pcb.udp, p, + remote_addr, remote_port, 1, chksum); +#else /* LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF */ + err = sock->conn->last_err = udp_sendto(sock->conn->pcb.udp, p, + remote_addr, remote_port); +#endif /* LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF */ +#else /* LWIP_UDP */ + err = ERR_ARG; +#endif /* LWIP_UDP */ + } + UNLOCK_TCPIP_CORE(); + + pbuf_free(p); + } else { + err = ERR_MEM; + } + } +#else /* LWIP_TCPIP_CORE_LOCKING */ + /* initialize a buffer */ + buf.p = buf.ptr = NULL; +#if LWIP_CHECKSUM_ON_COPY + buf.flags = 0; +#endif /* LWIP_CHECKSUM_ON_COPY */ + if (to) { + inet_addr_to_ipaddr(&buf.addr, &to_in->sin_addr); + remote_port = ntohs(to_in->sin_port); + netbuf_fromport(&buf) = remote_port; + } else { + remote_port = 0; + ip_addr_set_any(&buf.addr); + netbuf_fromport(&buf) = 0; + } + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, short_size=%"U16_F", flags=0x%x to=", + s, data, short_size, flags)); + ip_addr_debug_print(SOCKETS_DEBUG, &buf.addr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", remote_port)); + + /* make the buffer point to the data that should be sent */ +#if LWIP_NETIF_TX_SINGLE_PBUF + /* Allocate a new netbuf and copy the data into it. */ + if (netbuf_alloc(&buf, short_size) == NULL) { + err = ERR_MEM; + } else { +#if LWIP_CHECKSUM_ON_COPY + if (sock->conn->type != NETCONN_RAW) { + u16_t chksum = LWIP_CHKSUM_COPY(buf.p->payload, data, short_size); + netbuf_set_chksum(&buf, chksum); + err = ERR_OK; + } else +#endif /* LWIP_CHECKSUM_ON_COPY */ + { + err = netbuf_take(&buf, data, short_size); + } + } +#else /* LWIP_NETIF_TX_SINGLE_PBUF */ + err = netbuf_ref(&buf, data, short_size); +#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ + if (err == ERR_OK) { + /* send the data */ + err = netconn_send(sock->conn, &buf); + } + + /* deallocated the buffer */ + netbuf_free(&buf); +#endif /* LWIP_TCPIP_CORE_LOCKING */ + sock_set_errno(sock, err_to_errno(err)); + return (err == ERR_OK ? short_size : -1); +} + +int +lwip_socket(int domain, int type, int protocol) +{ + struct netconn *conn; + int i; + + LWIP_UNUSED_ARG(domain); + + /* create a netconn */ + switch (type) { + case SOCK_RAW: + conn = netconn_new_with_proto_and_callback(NETCONN_RAW, (u8_t)protocol, event_callback); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %d) = ", + domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); + break; + case SOCK_DGRAM: + conn = netconn_new_with_callback( (protocol == IPPROTO_UDPLITE) ? + NETCONN_UDPLITE : NETCONN_UDP, event_callback); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", + domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); + break; + case SOCK_STREAM: + conn = netconn_new_with_callback(NETCONN_TCP, event_callback); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", + domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); + if (conn != NULL) { + /* Prevent automatic window updates, we do this on our own! */ + netconn_set_noautorecved(conn, 1); + } + break; + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", + domain, type, protocol)); + set_errno(EINVAL); + return -1; + } + + if (!conn) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n")); + set_errno(ENOBUFS); + return -1; + } + + i = alloc_socket(conn, 0); + + if (i == -1) { + netconn_delete(conn); + set_errno(ENFILE); + return -1; + } + conn->socket = i; + LWIP_DEBUGF(SOCKETS_DEBUG, ("%d\n", i)); + set_errno(0); + return i; +} + +int +lwip_write(int s, const void *data, size_t size) +{ + return lwip_send(s, data, size, 0); +} + +/** + * Go through the readset and writeset lists and see which socket of the sockets + * set in the sets has events. On return, readset, writeset and exceptset have + * the sockets enabled that had events. + * + * exceptset is not used for now!!! + * + * @param maxfdp1 the highest socket index in the sets + * @param readset_in: set of sockets to check for read events + * @param writeset_in: set of sockets to check for write events + * @param exceptset_in: set of sockets to check for error events + * @param readset_out: set of sockets that had read events + * @param writeset_out: set of sockets that had write events + * @param exceptset_out: set os sockets that had error events + * @return number of sockets that had events (read/write/exception) (>= 0) + */ +static int +lwip_selscan(int maxfdp1, fd_set *readset_in, fd_set *writeset_in, fd_set *exceptset_in, + fd_set *readset_out, fd_set *writeset_out, fd_set *exceptset_out) +{ + int i, nready = 0; + fd_set lreadset, lwriteset, lexceptset; + struct lwip_sock *sock; + SYS_ARCH_DECL_PROTECT(lev); + + FD_ZERO(&lreadset); + FD_ZERO(&lwriteset); + FD_ZERO(&lexceptset); + + /* Go through each socket in each list to count number of sockets which + currently match */ + for(i = 0; i < maxfdp1; i++) { + void* lastdata = NULL; + s16_t rcvevent = 0; + u16_t sendevent = 0; + u16_t errevent = 0; + /* First get the socket's status (protected)... */ + SYS_ARCH_PROTECT(lev); + sock = tryget_socket(i); + if (sock != NULL) { + lastdata = sock->lastdata; + rcvevent = sock->rcvevent; + sendevent = sock->sendevent; + errevent = sock->errevent; + } + SYS_ARCH_UNPROTECT(lev); + /* ... then examine it: */ + /* See if netconn of this socket is ready for read */ + if (readset_in && FD_ISSET(i, readset_in) && ((lastdata != NULL) || (rcvevent > 0))) { + FD_SET(i, &lreadset); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i)); + nready++; + } + /* See if netconn of this socket is ready for write */ + if (writeset_in && FD_ISSET(i, writeset_in) && (sendevent != 0)) { + FD_SET(i, &lwriteset); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i)); + nready++; + } + /* See if netconn of this socket had an error */ + if (exceptset_in && FD_ISSET(i, exceptset_in) && (errevent != 0)) { + FD_SET(i, &lexceptset); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for exception\n", i)); + nready++; + } + } + /* copy local sets to the ones provided as arguments */ + *readset_out = lreadset; + *writeset_out = lwriteset; + *exceptset_out = lexceptset; + + LWIP_ASSERT("nready >= 0", nready >= 0); + return nready; +} + +/** + * Processing exceptset is not yet implemented. + */ +int +lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, + struct timeval *timeout) +{ + u32_t waitres = 0; + int nready; + fd_set lreadset, lwriteset, lexceptset; + u32_t msectimeout; + struct lwip_select_cb select_cb; + err_t err; + int i; + SYS_ARCH_DECL_PROTECT(lev); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%"S32_F" tvusec=%"S32_F")\n", + maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, + timeout ? (s32_t)timeout->tv_sec : (s32_t)-1, + timeout ? (s32_t)timeout->tv_usec : (s32_t)-1)); + + /* Go through each socket in each list to count number of sockets which + currently match */ + nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); + + /* If we don't have any current events, then suspend if we are supposed to */ + if (!nready) { + if (timeout && timeout->tv_sec == 0 && timeout->tv_usec == 0) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n")); + /* This is OK as the local fdsets are empty and nready is zero, + or we would have returned earlier. */ + goto return_copy_fdsets; + } + + /* None ready: add our semaphore to list: + We don't actually need any dynamic memory. Our entry on the + list is only valid while we are in this function, so it's ok + to use local variables. */ + + select_cb.next = NULL; + select_cb.prev = NULL; + select_cb.readset = readset; + select_cb.writeset = writeset; + select_cb.exceptset = exceptset; + select_cb.sem_signalled = 0; + err = sys_sem_new(&select_cb.sem, 0); + if (err != ERR_OK) { + /* failed to create semaphore */ + set_errno(ENOMEM); + return -1; + } + + /* Protect the select_cb_list */ + SYS_ARCH_PROTECT(lev); + + /* Put this select_cb on top of list */ + select_cb.next = select_cb_list; + if (select_cb_list != NULL) { + select_cb_list->prev = &select_cb; + } + select_cb_list = &select_cb; + /* Increasing this counter tells even_callback that the list has changed. */ + select_cb_ctr++; + + /* Now we can safely unprotect */ + SYS_ARCH_UNPROTECT(lev); + + /* Increase select_waiting for each socket we are interested in */ + for(i = 0; i < maxfdp1; i++) { + if ((readset && FD_ISSET(i, readset)) || + (writeset && FD_ISSET(i, writeset)) || + (exceptset && FD_ISSET(i, exceptset))) { + struct lwip_sock *sock = tryget_socket(i); + LWIP_ASSERT("sock != NULL", sock != NULL); + SYS_ARCH_PROTECT(lev); + sock->select_waiting++; + LWIP_ASSERT("sock->select_waiting > 0", sock->select_waiting > 0); + SYS_ARCH_UNPROTECT(lev); + } + } + + /* Call lwip_selscan again: there could have been events between + the last scan (whithout us on the list) and putting us on the list! */ + nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); + if (!nready) { + /* Still none ready, just wait to be woken */ + if (timeout == 0) { + /* Wait forever */ + msectimeout = 0; + } else { + msectimeout = ((timeout->tv_sec * 1000) + ((timeout->tv_usec + 500)/1000)); + if (msectimeout == 0) { + /* Wait 1ms at least (0 means wait forever) */ + msectimeout = 1; + } + } + + waitres = sys_arch_sem_wait(&select_cb.sem, msectimeout); + } + /* Increase select_waiting for each socket we are interested in */ + for(i = 0; i < maxfdp1; i++) { + if ((readset && FD_ISSET(i, readset)) || + (writeset && FD_ISSET(i, writeset)) || + (exceptset && FD_ISSET(i, exceptset))) { + struct lwip_sock *sock = tryget_socket(i); + LWIP_ASSERT("sock != NULL", sock != NULL); + SYS_ARCH_PROTECT(lev); + sock->select_waiting--; + LWIP_ASSERT("sock->select_waiting >= 0", sock->select_waiting >= 0); + SYS_ARCH_UNPROTECT(lev); + } + } + /* Take us off the list */ + SYS_ARCH_PROTECT(lev); + if (select_cb.next != NULL) { + select_cb.next->prev = select_cb.prev; + } + if (select_cb_list == &select_cb) { + LWIP_ASSERT("select_cb.prev == NULL", select_cb.prev == NULL); + select_cb_list = select_cb.next; + } else { + LWIP_ASSERT("select_cb.prev != NULL", select_cb.prev != NULL); + select_cb.prev->next = select_cb.next; + } + /* Increasing this counter tells even_callback that the list has changed. */ + select_cb_ctr++; + SYS_ARCH_UNPROTECT(lev); + + sys_sem_free(&select_cb.sem); + if (waitres == SYS_ARCH_TIMEOUT) { + /* Timeout */ + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n")); + /* This is OK as the local fdsets are empty and nready is zero, + or we would have returned earlier. */ + goto return_copy_fdsets; + } + + /* See what's set */ + nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); + } + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready)); +return_copy_fdsets: + set_errno(0); + if (readset) { + *readset = lreadset; + } + if (writeset) { + *writeset = lwriteset; + } + if (exceptset) { + *exceptset = lexceptset; + } + + + return nready; +} + +/** + * Callback registered in the netconn layer for each socket-netconn. + * Processes recvevent (data available) and wakes up tasks waiting for select. + */ +static void +event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) +{ + int s; + struct lwip_sock *sock; + struct lwip_select_cb *scb; + int last_select_cb_ctr; + SYS_ARCH_DECL_PROTECT(lev); + + LWIP_UNUSED_ARG(len); + + /* Get socket */ + if (conn) { + s = conn->socket; + if (s < 0) { + /* Data comes in right away after an accept, even though + * the server task might not have created a new socket yet. + * Just count down (or up) if that's the case and we + * will use the data later. Note that only receive events + * can happen before the new socket is set up. */ + SYS_ARCH_PROTECT(lev); + if (conn->socket < 0) { + if (evt == NETCONN_EVT_RCVPLUS) { + conn->socket--; + } + SYS_ARCH_UNPROTECT(lev); + return; + } + s = conn->socket; + SYS_ARCH_UNPROTECT(lev); + } + + sock = get_socket(s); + if (!sock) { + return; + } + } else { + return; + } + + SYS_ARCH_PROTECT(lev); + /* Set event as required */ + switch (evt) { + case NETCONN_EVT_RCVPLUS: + sock->rcvevent++; + break; + case NETCONN_EVT_RCVMINUS: + sock->rcvevent--; + break; + case NETCONN_EVT_SENDPLUS: + sock->sendevent = 1; + break; + case NETCONN_EVT_SENDMINUS: + sock->sendevent = 0; + break; + case NETCONN_EVT_ERROR: + sock->errevent = 1; + break; + default: + LWIP_ASSERT("unknown event", 0); + break; + } + + if (sock->select_waiting == 0) { + /* noone is waiting for this socket, no need to check select_cb_list */ + SYS_ARCH_UNPROTECT(lev); + return; + } + + /* Now decide if anyone is waiting for this socket */ + /* NOTE: This code goes through the select_cb_list list multiple times + ONLY IF a select was actually waiting. We go through the list the number + of waiting select calls + 1. This list is expected to be small. */ + + /* At this point, SYS_ARCH is still protected! */ +again: + for (scb = select_cb_list; scb != NULL; scb = scb->next) { + if (scb->sem_signalled == 0) { + /* semaphore not signalled yet */ + int do_signal = 0; + /* Test this select call for our socket */ + if (sock->rcvevent > 0) { + if (scb->readset && FD_ISSET(s, scb->readset)) { + do_signal = 1; + } + } + if (sock->sendevent != 0) { + if (!do_signal && scb->writeset && FD_ISSET(s, scb->writeset)) { + do_signal = 1; + } + } + if (sock->errevent != 0) { + if (!do_signal && scb->exceptset && FD_ISSET(s, scb->exceptset)) { + do_signal = 1; + } + } + if (do_signal) { + scb->sem_signalled = 1; + /* Don't call SYS_ARCH_UNPROTECT() before signaling the semaphore, as this might + lead to the select thread taking itself off the list, invalidagin the semaphore. */ + sys_sem_signal(&scb->sem); + } + } + /* unlock interrupts with each step */ + last_select_cb_ctr = select_cb_ctr; + SYS_ARCH_UNPROTECT(lev); + /* this makes sure interrupt protection time is short */ + SYS_ARCH_PROTECT(lev); + if (last_select_cb_ctr != select_cb_ctr) { + /* someone has changed select_cb_list, restart at the beginning */ + goto again; + } + } + SYS_ARCH_UNPROTECT(lev); +} + +/** + * Unimplemented: Close one end of a full-duplex connection. + * Currently, the full connection is closed. + */ +int +lwip_shutdown(int s, int how) +{ + struct lwip_sock *sock; + err_t err; + u8_t shut_rx = 0, shut_tx = 0; + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how)); + + sock = get_socket(s); + if (!sock) { + return -1; + } + + if (sock->conn != NULL) { + if (netconn_type(sock->conn) != NETCONN_TCP) { + sock_set_errno(sock, EOPNOTSUPP); + return EOPNOTSUPP; + } + } else { + sock_set_errno(sock, ENOTCONN); + return ENOTCONN; + } + + if (how == SHUT_RD) { + shut_rx = 1; + } else if (how == SHUT_WR) { + shut_tx = 1; + } else if(how == SHUT_RDWR) { + shut_rx = 1; + shut_tx = 1; + } else { + sock_set_errno(sock, EINVAL); + return EINVAL; + } + err = netconn_shutdown(sock->conn, shut_rx, shut_tx); + + sock_set_errno(sock, err_to_errno(err)); + return (err == ERR_OK ? 0 : -1); +} + +static int +lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local) +{ + struct lwip_sock *sock; + struct sockaddr_in sin; + ip_addr_t naddr; + + sock = get_socket(s); + if (!sock) { + return -1; + } + + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + + /* get the IP address and port */ + netconn_getaddr(sock->conn, &naddr, &sin.sin_port, local); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s)); + ip_addr_debug_print(SOCKETS_DEBUG, &naddr); + LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", sin.sin_port)); + + sin.sin_port = htons(sin.sin_port); + inet_addr_from_ipaddr(&sin.sin_addr, &naddr); + + if (*namelen > sizeof(sin)) { + *namelen = sizeof(sin); + } + + MEMCPY(name, &sin, *namelen); + sock_set_errno(sock, 0); + return 0; +} + +int +lwip_getpeername(int s, struct sockaddr *name, socklen_t *namelen) +{ + return lwip_getaddrname(s, name, namelen, 0); +} + +int +lwip_getsockname(int s, struct sockaddr *name, socklen_t *namelen) +{ + return lwip_getaddrname(s, name, namelen, 1); +} + +int +lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) +{ + err_t err = ERR_OK; + struct lwip_sock *sock = get_socket(s); + struct lwip_setgetsockopt_data data; + + if (!sock) { + return -1; + } + + if ((NULL == optval) || (NULL == optlen)) { + sock_set_errno(sock, EFAULT); + return -1; + } + + /* Do length and type checks for the various options first, to keep it readable. */ + switch (level) { + +/* Level: SOL_SOCKET */ + case SOL_SOCKET: + switch (optname) { + + case SO_ACCEPTCONN: + case SO_BROADCAST: + /* UNIMPL case SO_DEBUG: */ + /* UNIMPL case SO_DONTROUTE: */ + case SO_ERROR: + case SO_KEEPALIVE: + /* UNIMPL case SO_CONTIMEO: */ +#if LWIP_SO_SNDTIMEO + case SO_SNDTIMEO: +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO + case SO_RCVTIMEO: +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + case SO_RCVBUF: +#endif /* LWIP_SO_RCVBUF */ + /* UNIMPL case SO_OOBINLINE: */ + /* UNIMPL case SO_SNDBUF: */ + /* UNIMPL case SO_RCVLOWAT: */ + /* UNIMPL case SO_SNDLOWAT: */ +#if SO_REUSE + case SO_REUSEADDR: + case SO_REUSEPORT: +#endif /* SO_REUSE */ + case SO_TYPE: + /* UNIMPL case SO_USELOOPBACK: */ + if (*optlen < sizeof(int)) { + err = EINVAL; + } + break; + + case SO_NO_CHECK: + if (*optlen < sizeof(int)) { + err = EINVAL; + } +#if LWIP_UDP + if ((sock->conn->type != NETCONN_UDP) || + ((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_UDPLITE) != 0)) { + /* this flag is only available for UDP, not for UDP lite */ + err = EAFNOSUPPORT; + } +#endif /* LWIP_UDP */ + break; + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; + +/* Level: IPPROTO_IP */ + case IPPROTO_IP: + switch (optname) { + /* UNIMPL case IP_HDRINCL: */ + /* UNIMPL case IP_RCVDSTADDR: */ + /* UNIMPL case IP_RCVIF: */ + case IP_TTL: + case IP_TOS: + if (*optlen < sizeof(int)) { + err = EINVAL; + } + break; +#if LWIP_IGMP + case IP_MULTICAST_TTL: + if (*optlen < sizeof(u8_t)) { + err = EINVAL; + } + break; + case IP_MULTICAST_IF: + if (*optlen < sizeof(struct in_addr)) { + err = EINVAL; + } + break; + case IP_MULTICAST_LOOP: + if (*optlen < sizeof(u8_t)) { + err = EINVAL; + } + if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { + err = EAFNOSUPPORT; + } + break; +#endif /* LWIP_IGMP */ + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; + +#if LWIP_TCP +/* Level: IPPROTO_TCP */ + case IPPROTO_TCP: + if (*optlen < sizeof(int)) { + err = EINVAL; + break; + } + + /* If this is no TCP socket, ignore any options. */ + if (sock->conn->type != NETCONN_TCP) + return 0; + + switch (optname) { + case TCP_NODELAY: + case TCP_KEEPALIVE: +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPIDLE: + case TCP_KEEPINTVL: + case TCP_KEEPCNT: +#endif /* LWIP_TCP_KEEPALIVE */ + break; + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; +#endif /* LWIP_TCP */ +#if LWIP_UDP && LWIP_UDPLITE +/* Level: IPPROTO_UDPLITE */ + case IPPROTO_UDPLITE: + if (*optlen < sizeof(int)) { + err = EINVAL; + break; + } + + /* If this is no UDP lite socket, ignore any options. */ + if (sock->conn->type != NETCONN_UDPLITE) { + return 0; + } + + switch (optname) { + case UDPLITE_SEND_CSCOV: + case UDPLITE_RECV_CSCOV: + break; + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; +#endif /* LWIP_UDP && LWIP_UDPLITE*/ +/* UNDEFINED LEVEL */ + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", + s, level, optname)); + err = ENOPROTOOPT; + } /* switch */ + + + if (err != ERR_OK) { + sock_set_errno(sock, err); + return -1; + } + + /* Now do the actual option processing */ + data.sock = sock; +#ifdef LWIP_DEBUG + data.s = s; +#endif /* LWIP_DEBUG */ + data.level = level; + data.optname = optname; + data.optval = optval; + data.optlen = optlen; + data.err = err; + tcpip_callback(lwip_getsockopt_internal, &data); + sys_arch_sem_wait(&sock->conn->op_completed, 0); + /* maybe lwip_getsockopt_internal has changed err */ + err = data.err; + + sock_set_errno(sock, err); + return err ? -1 : 0; +} + +static void +lwip_getsockopt_internal(void *arg) +{ + struct lwip_sock *sock; +#ifdef LWIP_DEBUG + int s; +#endif /* LWIP_DEBUG */ + int level, optname; + void *optval; + struct lwip_setgetsockopt_data *data; + + LWIP_ASSERT("arg != NULL", arg != NULL); + + data = (struct lwip_setgetsockopt_data*)arg; + sock = data->sock; +#ifdef LWIP_DEBUG + s = data->s; +#endif /* LWIP_DEBUG */ + level = data->level; + optname = data->optname; + optval = data->optval; + + switch (level) { + +/* Level: SOL_SOCKET */ + case SOL_SOCKET: + switch (optname) { + + /* The option flags */ + case SO_ACCEPTCONN: + case SO_BROADCAST: + /* UNIMPL case SO_DEBUG: */ + /* UNIMPL case SO_DONTROUTE: */ + case SO_KEEPALIVE: + /* UNIMPL case SO_OOBINCLUDE: */ +#if SO_REUSE + case SO_REUSEADDR: + case SO_REUSEPORT: +#endif /* SO_REUSE */ + /*case SO_USELOOPBACK: UNIMPL */ + *(int*)optval = ip_get_option(sock->conn->pcb.ip, optname); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, optname=0x%x, ..) = %s\n", + s, optname, (*(int*)optval?"on":"off"))); + break; + + case SO_TYPE: + switch (NETCONNTYPE_GROUP(sock->conn->type)) { + case NETCONN_RAW: + *(int*)optval = SOCK_RAW; + break; + case NETCONN_TCP: + *(int*)optval = SOCK_STREAM; + break; + case NETCONN_UDP: + *(int*)optval = SOCK_DGRAM; + break; + default: /* unrecognized socket type */ + *(int*)optval = sock->conn->type; + LWIP_DEBUGF(SOCKETS_DEBUG, + ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE): unrecognized socket type %d\n", + s, *(int *)optval)); + } /* switch (sock->conn->type) */ + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE) = %d\n", + s, *(int *)optval)); + break; + + case SO_ERROR: + /* only overwrite ERR_OK or tempoary errors */ + if ((sock->err == 0) || (sock->err == EINPROGRESS)) { + sock_set_errno(sock, err_to_errno(sock->conn->last_err)); + } + *(int *)optval = sock->err; + sock->err = 0; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", + s, *(int *)optval)); + break; + +#if LWIP_SO_SNDTIMEO + case SO_SNDTIMEO: + *(int *)optval = netconn_get_sendtimeout(sock->conn); + break; +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO + case SO_RCVTIMEO: + *(int *)optval = netconn_get_recvtimeout(sock->conn); + break; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + case SO_RCVBUF: + *(int *)optval = netconn_get_recvbufsize(sock->conn); + break; +#endif /* LWIP_SO_RCVBUF */ +#if LWIP_UDP + case SO_NO_CHECK: + *(int*)optval = (udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_NOCHKSUM) ? 1 : 0; + break; +#endif /* LWIP_UDP*/ + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; + +/* Level: IPPROTO_IP */ + case IPPROTO_IP: + switch (optname) { + case IP_TTL: + *(int*)optval = sock->conn->pcb.ip->ttl; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TTL) = %d\n", + s, *(int *)optval)); + break; + case IP_TOS: + *(int*)optval = sock->conn->pcb.ip->tos; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TOS) = %d\n", + s, *(int *)optval)); + break; +#if LWIP_IGMP + case IP_MULTICAST_TTL: + *(u8_t*)optval = sock->conn->pcb.ip->ttl; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_TTL) = %d\n", + s, *(int *)optval)); + break; + case IP_MULTICAST_IF: + inet_addr_from_ipaddr((struct in_addr*)optval, &sock->conn->pcb.udp->multicast_ip); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_IF) = 0x%"X32_F"\n", + s, *(u32_t *)optval)); + break; + case IP_MULTICAST_LOOP: + if ((sock->conn->pcb.udp->flags & UDP_FLAGS_MULTICAST_LOOP) != 0) { + *(u8_t*)optval = 1; + } else { + *(u8_t*)optval = 0; + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_LOOP) = %d\n", + s, *(int *)optval)); + break; +#endif /* LWIP_IGMP */ + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; + +#if LWIP_TCP +/* Level: IPPROTO_TCP */ + case IPPROTO_TCP: + switch (optname) { + case TCP_NODELAY: + *(int*)optval = tcp_nagle_disabled(sock->conn->pcb.tcp); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, TCP_NODELAY) = %s\n", + s, (*(int*)optval)?"on":"off") ); + break; + case TCP_KEEPALIVE: + *(int*)optval = (int)sock->conn->pcb.tcp->keep_idle; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPALIVE) = %d\n", + s, *(int *)optval)); + break; + +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPIDLE: + *(int*)optval = (int)(sock->conn->pcb.tcp->keep_idle/1000); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPIDLE) = %d\n", + s, *(int *)optval)); + break; + case TCP_KEEPINTVL: + *(int*)optval = (int)(sock->conn->pcb.tcp->keep_intvl/1000); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPINTVL) = %d\n", + s, *(int *)optval)); + break; + case TCP_KEEPCNT: + *(int*)optval = (int)sock->conn->pcb.tcp->keep_cnt; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPCNT) = %d\n", + s, *(int *)optval)); + break; +#endif /* LWIP_TCP_KEEPALIVE */ + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; +#endif /* LWIP_TCP */ +#if LWIP_UDP && LWIP_UDPLITE + /* Level: IPPROTO_UDPLITE */ + case IPPROTO_UDPLITE: + switch (optname) { + case UDPLITE_SEND_CSCOV: + *(int*)optval = sock->conn->pcb.udp->chksum_len_tx; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) = %d\n", + s, (*(int*)optval)) ); + break; + case UDPLITE_RECV_CSCOV: + *(int*)optval = sock->conn->pcb.udp->chksum_len_rx; + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) = %d\n", + s, (*(int*)optval)) ); + break; + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; +#endif /* LWIP_UDP */ + default: + LWIP_ASSERT("unhandled level", 0); + break; + } /* switch (level) */ + sys_sem_signal(&sock->conn->op_completed); +} + +int +lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) +{ + struct lwip_sock *sock = get_socket(s); + err_t err = ERR_OK; + struct lwip_setgetsockopt_data data; + + if (!sock) { + return -1; + } + + if (NULL == optval) { + sock_set_errno(sock, EFAULT); + return -1; + } + + /* Do length and type checks for the various options first, to keep it readable. */ + switch (level) { + +/* Level: SOL_SOCKET */ + case SOL_SOCKET: + switch (optname) { + + case SO_BROADCAST: + /* UNIMPL case SO_DEBUG: */ + /* UNIMPL case SO_DONTROUTE: */ + case SO_KEEPALIVE: + /* UNIMPL case case SO_CONTIMEO: */ +#if LWIP_SO_SNDTIMEO + case SO_SNDTIMEO: +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO + case SO_RCVTIMEO: +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + case SO_RCVBUF: +#endif /* LWIP_SO_RCVBUF */ + /* UNIMPL case SO_OOBINLINE: */ + /* UNIMPL case SO_SNDBUF: */ + /* UNIMPL case SO_RCVLOWAT: */ + /* UNIMPL case SO_SNDLOWAT: */ +#if SO_REUSE + case SO_REUSEADDR: + case SO_REUSEPORT: +#endif /* SO_REUSE */ + /* UNIMPL case SO_USELOOPBACK: */ + if (optlen < sizeof(int)) { + err = EINVAL; + } + break; + case SO_NO_CHECK: + if (optlen < sizeof(int)) { + err = EINVAL; + } +#if LWIP_UDP + if ((sock->conn->type != NETCONN_UDP) || + ((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_UDPLITE) != 0)) { + /* this flag is only available for UDP, not for UDP lite */ + err = EAFNOSUPPORT; + } +#endif /* LWIP_UDP */ + break; + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; + +/* Level: IPPROTO_IP */ + case IPPROTO_IP: + switch (optname) { + /* UNIMPL case IP_HDRINCL: */ + /* UNIMPL case IP_RCVDSTADDR: */ + /* UNIMPL case IP_RCVIF: */ + case IP_TTL: + case IP_TOS: + if (optlen < sizeof(int)) { + err = EINVAL; + } + break; +#if LWIP_IGMP + case IP_MULTICAST_TTL: + if (optlen < sizeof(u8_t)) { + err = EINVAL; + } + if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { + err = EAFNOSUPPORT; + } + break; + case IP_MULTICAST_IF: + if (optlen < sizeof(struct in_addr)) { + err = EINVAL; + } + if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { + err = EAFNOSUPPORT; + } + break; + case IP_MULTICAST_LOOP: + if (optlen < sizeof(u8_t)) { + err = EINVAL; + } + if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { + err = EAFNOSUPPORT; + } + break; + case IP_ADD_MEMBERSHIP: + case IP_DROP_MEMBERSHIP: + if (optlen < sizeof(struct ip_mreq)) { + err = EINVAL; + } + if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { + err = EAFNOSUPPORT; + } + break; +#endif /* LWIP_IGMP */ + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; + +#if LWIP_TCP +/* Level: IPPROTO_TCP */ + case IPPROTO_TCP: + if (optlen < sizeof(int)) { + err = EINVAL; + break; + } + + /* If this is no TCP socket, ignore any options. */ + if (sock->conn->type != NETCONN_TCP) + return 0; + + switch (optname) { + case TCP_NODELAY: + case TCP_KEEPALIVE: +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPIDLE: + case TCP_KEEPINTVL: + case TCP_KEEPCNT: +#endif /* LWIP_TCP_KEEPALIVE */ + break; + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; +#endif /* LWIP_TCP */ +#if LWIP_UDP && LWIP_UDPLITE +/* Level: IPPROTO_UDPLITE */ + case IPPROTO_UDPLITE: + if (optlen < sizeof(int)) { + err = EINVAL; + break; + } + + /* If this is no UDP lite socket, ignore any options. */ + if (sock->conn->type != NETCONN_UDPLITE) + return 0; + + switch (optname) { + case UDPLITE_SEND_CSCOV: + case UDPLITE_RECV_CSCOV: + break; + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n", + s, optname)); + err = ENOPROTOOPT; + } /* switch (optname) */ + break; +#endif /* LWIP_UDP && LWIP_UDPLITE */ +/* UNDEFINED LEVEL */ + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", + s, level, optname)); + err = ENOPROTOOPT; + } /* switch (level) */ + + + if (err != ERR_OK) { + sock_set_errno(sock, err); + return -1; + } + + + /* Now do the actual option processing */ + data.sock = sock; +#ifdef LWIP_DEBUG + data.s = s; +#endif /* LWIP_DEBUG */ + data.level = level; + data.optname = optname; + data.optval = (void*)optval; + data.optlen = &optlen; + data.err = err; + tcpip_callback(lwip_setsockopt_internal, &data); + sys_arch_sem_wait(&sock->conn->op_completed, 0); + /* maybe lwip_setsockopt_internal has changed err */ + err = data.err; + + sock_set_errno(sock, err); + return err ? -1 : 0; +} + +static void +lwip_setsockopt_internal(void *arg) +{ + struct lwip_sock *sock; +#ifdef LWIP_DEBUG + int s; +#endif /* LWIP_DEBUG */ + int level, optname; + const void *optval; + struct lwip_setgetsockopt_data *data; + + LWIP_ASSERT("arg != NULL", arg != NULL); + + data = (struct lwip_setgetsockopt_data*)arg; + sock = data->sock; +#ifdef LWIP_DEBUG + s = data->s; +#endif /* LWIP_DEBUG */ + level = data->level; + optname = data->optname; + optval = data->optval; + + switch (level) { + +/* Level: SOL_SOCKET */ + case SOL_SOCKET: + switch (optname) { + + /* The option flags */ + case SO_BROADCAST: + /* UNIMPL case SO_DEBUG: */ + /* UNIMPL case SO_DONTROUTE: */ + case SO_KEEPALIVE: + /* UNIMPL case SO_OOBINCLUDE: */ +#if SO_REUSE + case SO_REUSEADDR: + case SO_REUSEPORT: +#endif /* SO_REUSE */ + /* UNIMPL case SO_USELOOPBACK: */ + if (*(int*)optval) { + ip_set_option(sock->conn->pcb.ip, optname); + } else { + ip_reset_option(sock->conn->pcb.ip, optname); + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n", + s, optname, (*(int*)optval?"on":"off"))); + break; +#if LWIP_SO_SNDTIMEO + case SO_SNDTIMEO: + netconn_set_sendtimeout(sock->conn, (s32_t)*(int*)optval); + break; +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO + case SO_RCVTIMEO: + netconn_set_recvtimeout(sock->conn, *(int*)optval); + break; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + case SO_RCVBUF: + netconn_set_recvbufsize(sock->conn, *(int*)optval); + break; +#endif /* LWIP_SO_RCVBUF */ +#if LWIP_UDP + case SO_NO_CHECK: + if (*(int*)optval) { + udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_NOCHKSUM); + } else { + udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_NOCHKSUM); + } + break; +#endif /* LWIP_UDP */ + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; + +/* Level: IPPROTO_IP */ + case IPPROTO_IP: + switch (optname) { + case IP_TTL: + sock->conn->pcb.ip->ttl = (u8_t)(*(int*)optval); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %d\n", + s, sock->conn->pcb.ip->ttl)); + break; + case IP_TOS: + sock->conn->pcb.ip->tos = (u8_t)(*(int*)optval); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %d\n", + s, sock->conn->pcb.ip->tos)); + break; +#if LWIP_IGMP + case IP_MULTICAST_TTL: + sock->conn->pcb.udp->ttl = (u8_t)(*(u8_t*)optval); + break; + case IP_MULTICAST_IF: + inet_addr_to_ipaddr(&sock->conn->pcb.udp->multicast_ip, (struct in_addr*)optval); + break; + case IP_MULTICAST_LOOP: + if (*(u8_t*)optval) { + udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_MULTICAST_LOOP); + } else { + udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_MULTICAST_LOOP); + } + break; + case IP_ADD_MEMBERSHIP: + case IP_DROP_MEMBERSHIP: + { + /* If this is a TCP or a RAW socket, ignore these options. */ + struct ip_mreq *imr = (struct ip_mreq *)optval; + ip_addr_t if_addr; + ip_addr_t multi_addr; + inet_addr_to_ipaddr(&if_addr, &imr->imr_interface); + inet_addr_to_ipaddr(&multi_addr, &imr->imr_multiaddr); + if(optname == IP_ADD_MEMBERSHIP){ + data->err = igmp_joingroup(&if_addr, &multi_addr); + } else { + data->err = igmp_leavegroup(&if_addr, &multi_addr); + } + if(data->err != ERR_OK) { + data->err = EADDRNOTAVAIL; + } + } + break; +#endif /* LWIP_IGMP */ + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; + +#if LWIP_TCP +/* Level: IPPROTO_TCP */ + case IPPROTO_TCP: + switch (optname) { + case TCP_NODELAY: + if (*(int*)optval) { + tcp_nagle_disable(sock->conn->pcb.tcp); + } else { + tcp_nagle_enable(sock->conn->pcb.tcp); + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n", + s, (*(int *)optval)?"on":"off") ); + break; + case TCP_KEEPALIVE: + sock->conn->pcb.tcp->keep_idle = (u32_t)(*(int*)optval); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %"U32_F"\n", + s, sock->conn->pcb.tcp->keep_idle)); + break; + +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPIDLE: + sock->conn->pcb.tcp->keep_idle = 1000*(u32_t)(*(int*)optval); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPIDLE) -> %"U32_F"\n", + s, sock->conn->pcb.tcp->keep_idle)); + break; + case TCP_KEEPINTVL: + sock->conn->pcb.tcp->keep_intvl = 1000*(u32_t)(*(int*)optval); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPINTVL) -> %"U32_F"\n", + s, sock->conn->pcb.tcp->keep_intvl)); + break; + case TCP_KEEPCNT: + sock->conn->pcb.tcp->keep_cnt = (u32_t)(*(int*)optval); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPCNT) -> %"U32_F"\n", + s, sock->conn->pcb.tcp->keep_cnt)); + break; +#endif /* LWIP_TCP_KEEPALIVE */ + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; +#endif /* LWIP_TCP*/ +#if LWIP_UDP && LWIP_UDPLITE + /* Level: IPPROTO_UDPLITE */ + case IPPROTO_UDPLITE: + switch (optname) { + case UDPLITE_SEND_CSCOV: + if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) { + /* don't allow illegal values! */ + sock->conn->pcb.udp->chksum_len_tx = 8; + } else { + sock->conn->pcb.udp->chksum_len_tx = (u16_t)*(int*)optval; + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n", + s, (*(int*)optval)) ); + break; + case UDPLITE_RECV_CSCOV: + if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) { + /* don't allow illegal values! */ + sock->conn->pcb.udp->chksum_len_rx = 8; + } else { + sock->conn->pcb.udp->chksum_len_rx = (u16_t)*(int*)optval; + } + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n", + s, (*(int*)optval)) ); + break; + default: + LWIP_ASSERT("unhandled optname", 0); + break; + } /* switch (optname) */ + break; +#endif /* LWIP_UDP */ + default: + LWIP_ASSERT("unhandled level", 0); + break; + } /* switch (level) */ + sys_sem_signal(&sock->conn->op_completed); +} + +int +lwip_ioctl(int s, long cmd, void *argp) +{ + struct lwip_sock *sock = get_socket(s); + u8_t val; +#if LWIP_SO_RCVBUF + u16_t buflen = 0; + s16_t recv_avail; +#endif /* LWIP_SO_RCVBUF */ + + if (!sock) { + return -1; + } + + switch (cmd) { +#if LWIP_SO_RCVBUF + case FIONREAD: + if (!argp) { + sock_set_errno(sock, EINVAL); + return -1; + } + + SYS_ARCH_GET(sock->conn->recv_avail, recv_avail); + if (recv_avail < 0) { + recv_avail = 0; + } + *((u16_t*)argp) = (u16_t)recv_avail; + + /* Check if there is data left from the last recv operation. /maq 041215 */ + if (sock->lastdata) { + struct pbuf *p = (struct pbuf *)sock->lastdata; + if (netconn_type(sock->conn) != NETCONN_TCP) { + p = ((struct netbuf *)p)->p; + } + buflen = p->tot_len; + buflen -= sock->lastoffset; + + *((u16_t*)argp) += buflen; + } + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %"U16_F"\n", s, argp, *((u16_t*)argp))); + sock_set_errno(sock, 0); + return 0; +#endif /* LWIP_SO_RCVBUF */ + + case FIONBIO: + val = 0; + if (argp && *(u32_t*)argp) { + val = 1; + } + netconn_set_nonblocking(sock->conn, val); + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, val)); + sock_set_errno(sock, 0); + return 0; + + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp)); + sock_set_errno(sock, ENOSYS); /* not yet implemented */ + return -1; + } /* switch (cmd) */ +} + +/** A minimal implementation of fcntl. + * Currently only the commands F_GETFL and F_SETFL are implemented. + * Only the flag O_NONBLOCK is implemented. + */ +int +lwip_fcntl(int s, int cmd, int val) +{ + struct lwip_sock *sock = get_socket(s); + int ret = -1; + + if (!sock || !sock->conn) { + return -1; + } + + switch (cmd) { + case F_GETFL: + ret = netconn_is_nonblocking(sock->conn) ? O_NONBLOCK : 0; + break; + case F_SETFL: + if ((val & ~O_NONBLOCK) == 0) { + /* only O_NONBLOCK, all other bits are zero */ + netconn_set_nonblocking(sock->conn, val & O_NONBLOCK); + ret = 0; + } + break; + default: + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_fcntl(%d, UNIMPL: %d, %d)\n", s, cmd, val)); + break; + } + return ret; +} + +#endif /* LWIP_SOCKET */ diff --git a/user/mpy/lib/lwip/src/api/tcpip.c b/user/mpy/lib/lwip/src/api/tcpip.c new file mode 100644 index 0000000..18d5f67 --- /dev/null +++ b/user/mpy/lib/lwip/src/api/tcpip.c @@ -0,0 +1,511 @@ +/** + * @file + * Sequential API Main thread module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/sys.h" +#include "lwip/memp.h" +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include "lwip/tcpip.h" +#include "lwip/init.h" +#include "netif/etharp.h" +#include "netif/ppp_oe.h" + +/* global variables */ +static tcpip_init_done_fn tcpip_init_done; +static void *tcpip_init_done_arg; +static sys_mbox_t mbox; + +#if LWIP_TCPIP_CORE_LOCKING +/** The global semaphore to lock the stack. */ +sys_mutex_t lock_tcpip_core; +#endif /* LWIP_TCPIP_CORE_LOCKING */ + + +/** + * The main lwIP thread. This thread has exclusive access to lwIP core functions + * (unless access to them is not locked). Other threads communicate with this + * thread using message boxes. + * + * It also starts all the timers to make sure they are running in the right + * thread context. + * + * @param arg unused argument + */ +static void +tcpip_thread(void *arg) +{ + struct tcpip_msg *msg; + LWIP_UNUSED_ARG(arg); + + if (tcpip_init_done != NULL) { + tcpip_init_done(tcpip_init_done_arg); + } + + LOCK_TCPIP_CORE(); + while (1) { /* MAIN Loop */ + UNLOCK_TCPIP_CORE(); + LWIP_TCPIP_THREAD_ALIVE(); + /* wait for a message, timeouts are processed while waiting */ + sys_timeouts_mbox_fetch(&mbox, (void **)&msg); + LOCK_TCPIP_CORE(); + switch (msg->type) { +#if LWIP_NETCONN + case TCPIP_MSG_API: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg)); + msg->msg.apimsg->function(&(msg->msg.apimsg->msg)); + break; +#endif /* LWIP_NETCONN */ + +#if !LWIP_TCPIP_CORE_LOCKING_INPUT + case TCPIP_MSG_INPKT: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg)); +#if LWIP_ETHERNET + if (msg->msg.inp.netif->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) { + ethernet_input(msg->msg.inp.p, msg->msg.inp.netif); + } else +#endif /* LWIP_ETHERNET */ + { + ip_input(msg->msg.inp.p, msg->msg.inp.netif); + } + memp_free(MEMP_TCPIP_MSG_INPKT, msg); + break; +#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */ + +#if LWIP_NETIF_API + case TCPIP_MSG_NETIFAPI: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: Netif API message %p\n", (void *)msg)); + msg->msg.netifapimsg->function(&(msg->msg.netifapimsg->msg)); + break; +#endif /* LWIP_NETIF_API */ + +#if LWIP_TCPIP_TIMEOUT + case TCPIP_MSG_TIMEOUT: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg)); + sys_timeout(msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg); + memp_free(MEMP_TCPIP_MSG_API, msg); + break; + case TCPIP_MSG_UNTIMEOUT: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: UNTIMEOUT %p\n", (void *)msg)); + sys_untimeout(msg->msg.tmo.h, msg->msg.tmo.arg); + memp_free(MEMP_TCPIP_MSG_API, msg); + break; +#endif /* LWIP_TCPIP_TIMEOUT */ + + case TCPIP_MSG_CALLBACK: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); + msg->msg.cb.function(msg->msg.cb.ctx); + memp_free(MEMP_TCPIP_MSG_API, msg); + break; + + case TCPIP_MSG_CALLBACK_STATIC: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK_STATIC %p\n", (void *)msg)); + msg->msg.cb.function(msg->msg.cb.ctx); + break; + + default: + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: %d\n", msg->type)); + LWIP_ASSERT("tcpip_thread: invalid message", 0); + break; + } + } +} + +/** + * Pass a received packet to tcpip_thread for input processing + * + * @param p the received packet, p->payload pointing to the Ethernet header or + * to an IP header (if inp doesn't have NETIF_FLAG_ETHARP or + * NETIF_FLAG_ETHERNET flags) + * @param inp the network interface on which the packet was received + */ +err_t +tcpip_input(struct pbuf *p, struct netif *inp) +{ +#if LWIP_TCPIP_CORE_LOCKING_INPUT + err_t ret; + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_input: PACKET %p/%p\n", (void *)p, (void *)inp)); + LOCK_TCPIP_CORE(); +#if LWIP_ETHERNET + if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) { + ret = ethernet_input(p, inp); + } else +#endif /* LWIP_ETHERNET */ + { + ret = ip_input(p, inp); + } + UNLOCK_TCPIP_CORE(); + return ret; +#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */ + struct tcpip_msg *msg; + + if (!sys_mbox_valid(&mbox)) { + return ERR_VAL; + } + msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT); + if (msg == NULL) { + return ERR_MEM; + } + + msg->type = TCPIP_MSG_INPKT; + msg->msg.inp.p = p; + msg->msg.inp.netif = inp; + if (sys_mbox_trypost(&mbox, msg) != ERR_OK) { + memp_free(MEMP_TCPIP_MSG_INPKT, msg); + return ERR_MEM; + } + return ERR_OK; +#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */ +} + +/** + * Call a specific function in the thread context of + * tcpip_thread for easy access synchronization. + * A function called in that way may access lwIP core code + * without fearing concurrent access. + * + * @param f the function to call + * @param ctx parameter passed to f + * @param block 1 to block until the request is posted, 0 to non-blocking mode + * @return ERR_OK if the function was called, another err_t if not + */ +err_t +tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block) +{ + struct tcpip_msg *msg; + + if (sys_mbox_valid(&mbox)) { + msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg == NULL) { + return ERR_MEM; + } + + msg->type = TCPIP_MSG_CALLBACK; + msg->msg.cb.function = function; + msg->msg.cb.ctx = ctx; + if (block) { + sys_mbox_post(&mbox, msg); + } else { + if (sys_mbox_trypost(&mbox, msg) != ERR_OK) { + memp_free(MEMP_TCPIP_MSG_API, msg); + return ERR_MEM; + } + } + return ERR_OK; + } + return ERR_VAL; +} + +#if LWIP_TCPIP_TIMEOUT +/** + * call sys_timeout in tcpip_thread + * + * @param msec time in milliseconds for timeout + * @param h function to be called on timeout + * @param arg argument to pass to timeout function h + * @return ERR_MEM on memory error, ERR_OK otherwise + */ +err_t +tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg) +{ + struct tcpip_msg *msg; + + if (sys_mbox_valid(&mbox)) { + msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg == NULL) { + return ERR_MEM; + } + + msg->type = TCPIP_MSG_TIMEOUT; + msg->msg.tmo.msecs = msecs; + msg->msg.tmo.h = h; + msg->msg.tmo.arg = arg; + sys_mbox_post(&mbox, msg); + return ERR_OK; + } + return ERR_VAL; +} + +/** + * call sys_untimeout in tcpip_thread + * + * @param msec time in milliseconds for timeout + * @param h function to be called on timeout + * @param arg argument to pass to timeout function h + * @return ERR_MEM on memory error, ERR_OK otherwise + */ +err_t +tcpip_untimeout(sys_timeout_handler h, void *arg) +{ + struct tcpip_msg *msg; + + if (sys_mbox_valid(&mbox)) { + msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg == NULL) { + return ERR_MEM; + } + + msg->type = TCPIP_MSG_UNTIMEOUT; + msg->msg.tmo.h = h; + msg->msg.tmo.arg = arg; + sys_mbox_post(&mbox, msg); + return ERR_OK; + } + return ERR_VAL; +} +#endif /* LWIP_TCPIP_TIMEOUT */ + +#if LWIP_NETCONN +/** + * Call the lower part of a netconn_* function + * This function is then running in the thread context + * of tcpip_thread and has exclusive access to lwIP core code. + * + * @param apimsg a struct containing the function to call and its parameters + * @return ERR_OK if the function was called, another err_t if not + */ +err_t +tcpip_apimsg(struct api_msg *apimsg) +{ + struct tcpip_msg msg; +#ifdef LWIP_DEBUG + /* catch functions that don't set err */ + apimsg->msg.err = ERR_VAL; +#endif + + if (sys_mbox_valid(&mbox)) { + msg.type = TCPIP_MSG_API; + msg.msg.apimsg = apimsg; + sys_mbox_post(&mbox, &msg); + sys_arch_sem_wait(&apimsg->msg.conn->op_completed, 0); + return apimsg->msg.err; + } + return ERR_VAL; +} + +#if LWIP_TCPIP_CORE_LOCKING +/** + * Call the lower part of a netconn_* function + * This function has exclusive access to lwIP core code by locking it + * before the function is called. + * + * @param apimsg a struct containing the function to call and its parameters + * @return ERR_OK (only for compatibility fo tcpip_apimsg()) + */ +err_t +tcpip_apimsg_lock(struct api_msg *apimsg) +{ +#ifdef LWIP_DEBUG + /* catch functions that don't set err */ + apimsg->msg.err = ERR_VAL; +#endif + + LOCK_TCPIP_CORE(); + apimsg->function(&(apimsg->msg)); + UNLOCK_TCPIP_CORE(); + return apimsg->msg.err; + +} +#endif /* LWIP_TCPIP_CORE_LOCKING */ +#endif /* LWIP_NETCONN */ + +#if LWIP_NETIF_API +#if !LWIP_TCPIP_CORE_LOCKING +/** + * Much like tcpip_apimsg, but calls the lower part of a netifapi_* + * function. + * + * @param netifapimsg a struct containing the function to call and its parameters + * @return error code given back by the function that was called + */ +err_t +tcpip_netifapi(struct netifapi_msg* netifapimsg) +{ + struct tcpip_msg msg; + + if (sys_mbox_valid(&mbox)) { + err_t err = sys_sem_new(&netifapimsg->msg.sem, 0); + if (err != ERR_OK) { + netifapimsg->msg.err = err; + return err; + } + + msg.type = TCPIP_MSG_NETIFAPI; + msg.msg.netifapimsg = netifapimsg; + sys_mbox_post(&mbox, &msg); + sys_sem_wait(&netifapimsg->msg.sem); + sys_sem_free(&netifapimsg->msg.sem); + return netifapimsg->msg.err; + } + return ERR_VAL; +} +#else /* !LWIP_TCPIP_CORE_LOCKING */ +/** + * Call the lower part of a netifapi_* function + * This function has exclusive access to lwIP core code by locking it + * before the function is called. + * + * @param netifapimsg a struct containing the function to call and its parameters + * @return ERR_OK (only for compatibility fo tcpip_netifapi()) + */ +err_t +tcpip_netifapi_lock(struct netifapi_msg* netifapimsg) +{ + LOCK_TCPIP_CORE(); + netifapimsg->function(&(netifapimsg->msg)); + UNLOCK_TCPIP_CORE(); + return netifapimsg->msg.err; +} +#endif /* !LWIP_TCPIP_CORE_LOCKING */ +#endif /* LWIP_NETIF_API */ + +/** + * Allocate a structure for a static callback message and initialize it. + * This is intended to be used to send "static" messages from interrupt context. + * + * @param function the function to call + * @param ctx parameter passed to function + * @return a struct pointer to pass to tcpip_trycallback(). + */ +struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx) +{ + struct tcpip_msg *msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg == NULL) { + return NULL; + } + msg->type = TCPIP_MSG_CALLBACK_STATIC; + msg->msg.cb.function = function; + msg->msg.cb.ctx = ctx; + return (struct tcpip_callback_msg*)msg; +} + +/** + * Free a callback message allocated by tcpip_callbackmsg_new(). + * + * @param msg the message to free + */ +void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg) +{ + memp_free(MEMP_TCPIP_MSG_API, msg); +} + +/** + * Try to post a callback-message to the tcpip_thread mbox + * This is intended to be used to send "static" messages from interrupt context. + * + * @param msg pointer to the message to post + * @return sys_mbox_trypost() return code + */ +err_t +tcpip_trycallback(struct tcpip_callback_msg* msg) +{ + if (!sys_mbox_valid(&mbox)) { + return ERR_VAL; + } + return sys_mbox_trypost(&mbox, msg); +} + +/** + * Initialize this module: + * - initialize all sub modules + * - start the tcpip_thread + * + * @param initfunc a function to call when tcpip_thread is running and finished initializing + * @param arg argument to pass to initfunc + */ +void +tcpip_init(tcpip_init_done_fn initfunc, void *arg) +{ + lwip_init(); + + tcpip_init_done = initfunc; + tcpip_init_done_arg = arg; + if(sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) { + LWIP_ASSERT("failed to create tcpip_thread mbox", 0); + } +#if LWIP_TCPIP_CORE_LOCKING + if(sys_mutex_new(&lock_tcpip_core) != ERR_OK) { + LWIP_ASSERT("failed to create lock_tcpip_core", 0); + } +#endif /* LWIP_TCPIP_CORE_LOCKING */ + + sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); +} + +/** + * Simple callback function used with tcpip_callback to free a pbuf + * (pbuf_free has a wrong signature for tcpip_callback) + * + * @param p The pbuf (chain) to be dereferenced. + */ +static void +pbuf_free_int(void *p) +{ + struct pbuf *q = (struct pbuf *)p; + pbuf_free(q); +} + +/** + * A simple wrapper function that allows you to free a pbuf from interrupt context. + * + * @param p The pbuf (chain) to be dereferenced. + * @return ERR_OK if callback could be enqueued, an err_t if not + */ +err_t +pbuf_free_callback(struct pbuf *p) +{ + return tcpip_callback_with_block(pbuf_free_int, p, 0); +} + +/** + * A simple wrapper function that allows you to free heap memory from + * interrupt context. + * + * @param m the heap memory to free + * @return ERR_OK if callback could be enqueued, an err_t if not + */ +err_t +mem_free_callback(void *m) +{ + return tcpip_callback_with_block(mem_free, m, 0); +} + +#endif /* !NO_SYS */ diff --git a/user/mpy/lib/lwip/src/core/def.c b/user/mpy/lib/lwip/src/core/def.c new file mode 100644 index 0000000..352b552 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/def.c @@ -0,0 +1,108 @@ +/** + * @file + * Common functions used throughout the stack. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ + +#include "lwip/opt.h" +#include "lwip/def.h" + +/** + * These are reference implementations of the byte swapping functions. + * Again with the aim of being simple, correct and fully portable. + * Byte swapping is the second thing you would want to optimize. You will + * need to port it to your architecture and in your cc.h: + * + * #define LWIP_PLATFORM_BYTESWAP 1 + * #define LWIP_PLATFORM_HTONS(x) + * #define LWIP_PLATFORM_HTONL(x) + * + * Note ntohs() and ntohl() are merely references to the htonx counterparts. + */ + +#if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) + +/** + * Convert an u16_t from host- to network byte order. + * + * @param n u16_t in host byte order + * @return n in network byte order + */ +u16_t +lwip_htons(u16_t n) +{ + return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); +} + +/** + * Convert an u16_t from network- to host byte order. + * + * @param n u16_t in network byte order + * @return n in host byte order + */ +u16_t +lwip_ntohs(u16_t n) +{ + return lwip_htons(n); +} + +/** + * Convert an u32_t from host- to network byte order. + * + * @param n u32_t in host byte order + * @return n in network byte order + */ +u32_t +lwip_htonl(u32_t n) +{ + return ((n & 0xff) << 24) | + ((n & 0xff00) << 8) | + ((n & 0xff0000UL) >> 8) | + ((n & 0xff000000UL) >> 24); +} + +/** + * Convert an u32_t from network- to host byte order. + * + * @param n u32_t in network byte order + * @return n in host byte order + */ +u32_t +lwip_ntohl(u32_t n) +{ + return lwip_htonl(n); +} + +#endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ diff --git a/user/mpy/lib/lwip/src/core/dhcp.c b/user/mpy/lib/lwip/src/core/dhcp.c new file mode 100644 index 0000000..eb12c55 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/dhcp.c @@ -0,0 +1,1770 @@ +/** + * @file + * Dynamic Host Configuration Protocol client + * + */ + +/* + * + * Copyright (c) 2001-2004 Leon Woestenberg + * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is a contribution to the lwIP TCP/IP stack. + * The Swedish Institute of Computer Science and Adam Dunkels + * are specifically granted permission to redistribute this + * source code. + * + * Author: Leon Woestenberg + * + * This is a DHCP client for the lwIP TCP/IP stack. It aims to conform + * with RFC 2131 and RFC 2132. + * + * TODO: + * - Support for interfaces other than Ethernet (SLIP, PPP, ...) + * + * Please coordinate changes and requests with Leon Woestenberg + * + * + * Integration with your code: + * + * In lwip/dhcp.h + * #define DHCP_COARSE_TIMER_SECS (recommended 60 which is a minute) + * #define DHCP_FINE_TIMER_MSECS (recommended 500 which equals TCP coarse timer) + * + * Then have your application call dhcp_coarse_tmr() and + * dhcp_fine_tmr() on the defined intervals. + * + * dhcp_start(struct netif *netif); + * starts a DHCP client instance which configures the interface by + * obtaining an IP address lease and maintaining it. + * + * Use dhcp_release(netif) to end the lease and use dhcp_stop(netif) + * to remove the DHCP client. + * + */ + +#include "lwip/opt.h" + +#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/stats.h" +#include "lwip/mem.h" +#include "lwip/udp.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/def.h" +#include "lwip/dhcp.h" +#include "lwip/autoip.h" +#include "lwip/dns.h" +#include "netif/etharp.h" + +#include + +/** DHCP_CREATE_RAND_XID: if this is set to 1, the xid is created using + * LWIP_RAND() (this overrides DHCP_GLOBAL_XID) + */ +#ifndef DHCP_CREATE_RAND_XID +#define DHCP_CREATE_RAND_XID 1 +#endif + +/** Default for DHCP_GLOBAL_XID is 0xABCD0000 + * This can be changed by defining DHCP_GLOBAL_XID and DHCP_GLOBAL_XID_HEADER, e.g. + * #define DHCP_GLOBAL_XID_HEADER "stdlib.h" + * #define DHCP_GLOBAL_XID rand() + */ +#ifdef DHCP_GLOBAL_XID_HEADER +#include DHCP_GLOBAL_XID_HEADER /* include optional starting XID generation prototypes */ +#endif + +/** DHCP_OPTION_MAX_MSG_SIZE is set to the MTU + * MTU is checked to be big enough in dhcp_start */ +#define DHCP_MAX_MSG_LEN(netif) (netif->mtu) +#define DHCP_MAX_MSG_LEN_MIN_REQUIRED 576 +/** Minimum length for reply before packet is parsed */ +#define DHCP_MIN_REPLY_LEN 44 + +#define REBOOT_TRIES 2 + +/** Option handling: options are parsed in dhcp_parse_reply + * and saved in an array where other functions can load them from. + * This might be moved into the struct dhcp (not necessarily since + * lwIP is single-threaded and the array is only used while in recv + * callback). */ +#define DHCP_OPTION_IDX_OVERLOAD 0 +#define DHCP_OPTION_IDX_MSG_TYPE 1 +#define DHCP_OPTION_IDX_SERVER_ID 2 +#define DHCP_OPTION_IDX_LEASE_TIME 3 +#define DHCP_OPTION_IDX_T1 4 +#define DHCP_OPTION_IDX_T2 5 +#define DHCP_OPTION_IDX_SUBNET_MASK 6 +#define DHCP_OPTION_IDX_ROUTER 7 +#define DHCP_OPTION_IDX_DNS_SERVER 8 +#define DHCP_OPTION_IDX_MAX (DHCP_OPTION_IDX_DNS_SERVER + DNS_MAX_SERVERS) + +/** Holds the decoded option values, only valid while in dhcp_recv. + @todo: move this into struct dhcp? */ +u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX]; +/** Holds a flag which option was received and is contained in dhcp_rx_options_val, + only valid while in dhcp_recv. + @todo: move this into struct dhcp? */ +u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX]; + +#ifdef DHCP_GLOBAL_XID +static u32_t xid; +static u8_t xid_initialised; +#endif /* DHCP_GLOBAL_XID */ + +#define dhcp_option_given(dhcp, idx) (dhcp_rx_options_given[idx] != 0) +#define dhcp_got_option(dhcp, idx) (dhcp_rx_options_given[idx] = 1) +#define dhcp_clear_option(dhcp, idx) (dhcp_rx_options_given[idx] = 0) +#define dhcp_clear_all_options(dhcp) (memset(dhcp_rx_options_given, 0, sizeof(dhcp_rx_options_given))) +#define dhcp_get_option_value(dhcp, idx) (dhcp_rx_options_val[idx]) +#define dhcp_set_option_value(dhcp, idx, val) (dhcp_rx_options_val[idx] = (val)) + + +/* DHCP client state machine functions */ +static err_t dhcp_discover(struct netif *netif); +static err_t dhcp_select(struct netif *netif); +static void dhcp_bind(struct netif *netif); +#if DHCP_DOES_ARP_CHECK +static err_t dhcp_decline(struct netif *netif); +#endif /* DHCP_DOES_ARP_CHECK */ +static err_t dhcp_rebind(struct netif *netif); +static err_t dhcp_reboot(struct netif *netif); +static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state); + +/* receive, unfold, parse and free incoming messages */ +static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); + +/* set the DHCP timers */ +static void dhcp_timeout(struct netif *netif); +static void dhcp_t1_timeout(struct netif *netif); +static void dhcp_t2_timeout(struct netif *netif); + +/* build outgoing messages */ +/* create a DHCP message, fill in common headers */ +static err_t dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type); +/* free a DHCP request */ +static void dhcp_delete_msg(struct dhcp *dhcp); +/* add a DHCP option (type, then length in bytes) */ +static void dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len); +/* add option values */ +static void dhcp_option_byte(struct dhcp *dhcp, u8_t value); +static void dhcp_option_short(struct dhcp *dhcp, u16_t value); +static void dhcp_option_long(struct dhcp *dhcp, u32_t value); +#if LWIP_NETIF_HOSTNAME +static void dhcp_option_hostname(struct dhcp *dhcp, struct netif *netif); +#endif /* LWIP_NETIF_HOSTNAME */ +/* always add the DHCP options trailer to end and pad */ +static void dhcp_option_trailer(struct dhcp *dhcp); + +/** + * Back-off the DHCP client (because of a received NAK response). + * + * Back-off the DHCP client because of a received NAK. Receiving a + * NAK means the client asked for something non-sensible, for + * example when it tries to renew a lease obtained on another network. + * + * We clear any existing set IP address and restart DHCP negotiation + * afresh (as per RFC2131 3.2.3). + * + * @param netif the netif under DHCP control + */ +static void +dhcp_handle_nak(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", + (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); + /* Set the interface down since the address must no longer be used, as per RFC2131 */ + netif_set_down(netif); + /* remove IP address from interface */ + netif_set_ipaddr(netif, IP_ADDR_ANY); + netif_set_gw(netif, IP_ADDR_ANY); + netif_set_netmask(netif, IP_ADDR_ANY); + /* Change to a defined state */ + dhcp_set_state(dhcp, DHCP_BACKING_OFF); + /* We can immediately restart discovery */ + dhcp_discover(netif); +} + +#if DHCP_DOES_ARP_CHECK +/** + * Checks if the offered IP address is already in use. + * + * It does so by sending an ARP request for the offered address and + * entering CHECKING state. If no ARP reply is received within a small + * interval, the address is assumed to be free for use by us. + * + * @param netif the netif under DHCP control + */ +static void +dhcp_check(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0], + (s16_t)netif->name[1])); + dhcp_set_state(dhcp, DHCP_CHECKING); + /* create an ARP query for the offered IP address, expecting that no host + responds, as the IP address should not be in use. */ + result = etharp_query(netif, &dhcp->offered_ip_addr, NULL); + if (result != ERR_OK) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("dhcp_check: could not perform ARP query\n")); + } + dhcp->tries++; + msecs = 500; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_check(): set request timeout %"U16_F" msecs\n", msecs)); +} +#endif /* DHCP_DOES_ARP_CHECK */ + +/** + * Remember the configuration offered by a DHCP server. + * + * @param netif the netif under DHCP control + */ +static void +dhcp_handle_offer(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n", + (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); + /* obtain the server address */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) { + ip4_addr_set_u32(&dhcp->server_ip_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", + ip4_addr_get_u32(&dhcp->server_ip_addr))); + /* remember offered address */ + ip_addr_copy(dhcp->offered_ip_addr, dhcp->msg_in->yiaddr); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n", + ip4_addr_get_u32(&dhcp->offered_ip_addr))); + + dhcp_select(netif); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, + ("dhcp_handle_offer(netif=%p) did not get server ID!\n", (void*)netif)); + } +} + +/** + * Select a DHCP server offer out of all offers. + * + * Simply select the first offer received. + * + * @param netif the netif under DHCP control + * @return lwIP specific error (see error.h) + */ +static err_t +dhcp_select(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result; + u16_t msecs; + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); + dhcp_set_state(dhcp, DHCP_REQUESTING); + + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); + if (result == ERR_OK) { + dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); + dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); + + /* MUST request the offered IP address */ + dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); + dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); + + dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); + dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->server_ip_addr))); + + dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/); + dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK); + dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER); + dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST); + dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER); + +#if LWIP_NETIF_HOSTNAME + dhcp_option_hostname(dhcp, netif); +#endif /* LWIP_NETIF_HOSTNAME */ + + dhcp_option_trailer(dhcp); + /* shrink the pbuf to the actual content length */ + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + /* send broadcast to any DHCP server */ + udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(dhcp); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_select: REQUESTING\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("dhcp_select: could not allocate DHCP request\n")); + } + dhcp->tries++; + msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * 1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_select(): set request timeout %"U16_F" msecs\n", msecs)); + return result; +} + +/** + * The DHCP timer that checks for lease renewal/rebind timeouts. + */ +void +dhcp_coarse_tmr() +{ + struct netif *netif = netif_list; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_coarse_tmr()\n")); + /* iterate through all network interfaces */ + while (netif != NULL) { + /* only act on DHCP configured interfaces */ + if (netif->dhcp != NULL) { + /* timer is active (non zero), and triggers (zeroes) now? */ + if (netif->dhcp->t2_timeout-- == 1) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n")); + /* this clients' rebind timeout triggered */ + dhcp_t2_timeout(netif); + /* timer is active (non zero), and triggers (zeroes) now */ + } else if (netif->dhcp->t1_timeout-- == 1) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n")); + /* this clients' renewal timeout triggered */ + dhcp_t1_timeout(netif); + } + } + /* proceed to next netif */ + netif = netif->next; + } +} + +/** + * DHCP transaction timeout handling + * + * A DHCP server is expected to respond within a short period of time. + * This timer checks whether an outstanding DHCP request is timed out. + */ +void +dhcp_fine_tmr() +{ + struct netif *netif = netif_list; + /* loop through netif's */ + while (netif != NULL) { + /* only act on DHCP configured interfaces */ + if (netif->dhcp != NULL) { + /* timer is active (non zero), and is about to trigger now */ + if (netif->dhcp->request_timeout > 1) { + netif->dhcp->request_timeout--; + } + else if (netif->dhcp->request_timeout == 1) { + netif->dhcp->request_timeout--; + /* { netif->dhcp->request_timeout == 0 } */ + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_fine_tmr(): request timeout\n")); + /* this client's request timeout triggered */ + dhcp_timeout(netif); + } + } + /* proceed to next network interface */ + netif = netif->next; + } +} + +/** + * A DHCP negotiation transaction, or ARP request, has timed out. + * + * The timer that was started with the DHCP or ARP request has + * timed out, indicating no response was received in time. + * + * @param netif the netif under DHCP control + */ +static void +dhcp_timeout(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_timeout()\n")); + /* back-off period has passed, or server selection timed out */ + if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_timeout(): restarting discovery\n")); + dhcp_discover(netif); + /* receiving the requested lease timed out */ + } else if (dhcp->state == DHCP_REQUESTING) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n")); + if (dhcp->tries <= 5) { + dhcp_select(netif); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n")); + dhcp_release(netif); + dhcp_discover(netif); + } +#if DHCP_DOES_ARP_CHECK + /* received no ARP reply for the offered address (which is good) */ + } else if (dhcp->state == DHCP_CHECKING) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n")); + if (dhcp->tries <= 1) { + dhcp_check(netif); + /* no ARP replies on the offered address, + looks like the IP address is indeed free */ + } else { + /* bind the interface to the offered address */ + dhcp_bind(netif); + } +#endif /* DHCP_DOES_ARP_CHECK */ + } + /* did not get response to renew request? */ + else if (dhcp->state == DHCP_RENEWING) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n")); + /* just retry renewal */ + /* note that the rebind timer will eventually time-out if renew does not work */ + dhcp_renew(netif); + /* did not get response to rebind request? */ + } else if (dhcp->state == DHCP_REBINDING) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n")); + if (dhcp->tries <= 8) { + dhcp_rebind(netif); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n")); + dhcp_release(netif); + dhcp_discover(netif); + } + } else if (dhcp->state == DHCP_REBOOTING) { + if (dhcp->tries < REBOOT_TRIES) { + dhcp_reboot(netif); + } else { + dhcp_discover(netif); + } + } +} + +/** + * The renewal period has timed out. + * + * @param netif the netif under DHCP control + */ +static void +dhcp_t1_timeout(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_t1_timeout()\n")); + if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || + (dhcp->state == DHCP_RENEWING)) { + /* just retry to renew - note that the rebind timer (t2) will + * eventually time-out if renew tries fail. */ + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("dhcp_t1_timeout(): must renew\n")); + /* This slightly different to RFC2131: DHCPREQUEST will be sent from state + DHCP_RENEWING, not DHCP_BOUND */ + dhcp_renew(netif); + } +} + +/** + * The rebind period has timed out. + * + * @param netif the netif under DHCP control + */ +static void +dhcp_t2_timeout(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t2_timeout()\n")); + if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || + (dhcp->state == DHCP_RENEWING)) { + /* just retry to rebind */ + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("dhcp_t2_timeout(): must rebind\n")); + /* This slightly different to RFC2131: DHCPREQUEST will be sent from state + DHCP_REBINDING, not DHCP_BOUND */ + dhcp_rebind(netif); + } +} + +/** + * Handle a DHCP ACK packet + * + * @param netif the netif under DHCP control + */ +static void +dhcp_handle_ack(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; +#if LWIP_DNS + u8_t n; +#endif /* LWIP_DNS */ + + /* clear options we might not get from the ACK */ + ip_addr_set_zero(&dhcp->offered_sn_mask); + ip_addr_set_zero(&dhcp->offered_gw_addr); +#if LWIP_DHCP_BOOTP_FILE + ip_addr_set_zero(&dhcp->offered_si_addr); +#endif /* LWIP_DHCP_BOOTP_FILE */ + + /* lease time given? */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_LEASE_TIME)) { + /* remember offered lease time */ + dhcp->offered_t0_lease = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_LEASE_TIME); + } + /* renewal period given? */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_T1)) { + /* remember given renewal period */ + dhcp->offered_t1_renew = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_T1); + } else { + /* calculate safe periods for renewal */ + dhcp->offered_t1_renew = dhcp->offered_t0_lease / 2; + } + + /* renewal period given? */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_T2)) { + /* remember given rebind period */ + dhcp->offered_t2_rebind = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_T2); + } else { + /* calculate safe periods for rebinding */ + dhcp->offered_t2_rebind = dhcp->offered_t0_lease; + } + + /* (y)our internet address */ + ip_addr_copy(dhcp->offered_ip_addr, dhcp->msg_in->yiaddr); + +#if LWIP_DHCP_BOOTP_FILE + /* copy boot server address, + boot file name copied in dhcp_parse_reply if not overloaded */ + ip_addr_copy(dhcp->offered_si_addr, dhcp->msg_in->siaddr); +#endif /* LWIP_DHCP_BOOTP_FILE */ + + /* subnet mask given? */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SUBNET_MASK)) { + /* remember given subnet mask */ + ip4_addr_set_u32(&dhcp->offered_sn_mask, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SUBNET_MASK))); + dhcp->subnet_mask_given = 1; + } else { + dhcp->subnet_mask_given = 0; + } + + /* gateway router */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_ROUTER)) { + ip4_addr_set_u32(&dhcp->offered_gw_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_ROUTER))); + } + +#if LWIP_DNS + /* DNS servers */ + n = 0; + while(dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n) && (n < DNS_MAX_SERVERS)) { + ip_addr_t dns_addr; + ip4_addr_set_u32(&dns_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n))); + dns_setserver(n, &dns_addr); + n++; + } +#endif /* LWIP_DNS */ +} + +/** Set a statically allocated struct dhcp to work with. + * Using this prevents dhcp_start to allocate it using mem_malloc. + * + * @param netif the netif for which to set the struct dhcp + * @param dhcp (uninitialised) dhcp struct allocated by the application + */ +void +dhcp_set_struct(struct netif *netif, struct dhcp *dhcp) +{ + LWIP_ASSERT("netif != NULL", netif != NULL); + LWIP_ASSERT("dhcp != NULL", dhcp != NULL); + LWIP_ASSERT("netif already has a struct dhcp set", netif->dhcp == NULL); + + /* clear data structure */ + memset(dhcp, 0, sizeof(struct dhcp)); + /* dhcp_set_state(&dhcp, DHCP_OFF); */ + netif->dhcp = dhcp; +} + +/** Removes a struct dhcp from a netif. + * + * ATTENTION: Only use this when not using dhcp_set_struct() to allocate the + * struct dhcp since the memory is passed back to the heap. + * + * @param netif the netif from which to remove the struct dhcp + */ +void dhcp_cleanup(struct netif *netif) +{ + LWIP_ASSERT("netif != NULL", netif != NULL); + + if (netif->dhcp != NULL) { + mem_free(netif->dhcp); + netif->dhcp = NULL; + } +} + +/** + * Start DHCP negotiation for a network interface. + * + * If no DHCP client instance was attached to this interface, + * a new client is created first. If a DHCP client instance + * was already present, it restarts negotiation. + * + * @param netif The lwIP network interface + * @return lwIP error code + * - ERR_OK - No error + * - ERR_MEM - Out of memory + */ +err_t +dhcp_start(struct netif *netif) +{ + struct dhcp *dhcp; + err_t result = ERR_OK; + + LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;); + dhcp = netif->dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); + /* Remove the flag that says this netif is handled by DHCP, + it is set when we succeeded starting. */ + netif->flags &= ~NETIF_FLAG_DHCP; + + /* check hwtype of the netif */ + if ((netif->flags & NETIF_FLAG_ETHARP) == 0) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): No ETHARP netif\n")); + return ERR_ARG; + } + + /* check MTU of the netif */ + if (netif->mtu < DHCP_MAX_MSG_LEN_MIN_REQUIRED) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): Cannot use this netif with DHCP: MTU is too small\n")); + return ERR_MEM; + } + + /* no DHCP client attached yet? */ + if (dhcp == NULL) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting new DHCP client\n")); + dhcp = (struct dhcp *)mem_malloc(sizeof(struct dhcp)); + if (dhcp == NULL) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n")); + return ERR_MEM; + } + /* store this dhcp client in the netif */ + netif->dhcp = dhcp; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): allocated dhcp")); + /* already has DHCP client attached */ + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(): restarting DHCP configuration\n")); + if (dhcp->pcb != NULL) { + udp_remove(dhcp->pcb); + } + LWIP_ASSERT("pbuf p_out wasn't freed", dhcp->p_out == NULL); + LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL ); + } + + /* clear data structure */ + memset(dhcp, 0, sizeof(struct dhcp)); + /* dhcp_set_state(&dhcp, DHCP_OFF); */ + /* allocate UDP PCB */ + dhcp->pcb = udp_new(); + if (dhcp->pcb == NULL) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not obtain pcb\n")); + return ERR_MEM; + } + ip_set_option(dhcp->pcb, SOF_BROADCAST); + /* set up local and remote port for the pcb */ + udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); + udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); + /* set up the recv callback and argument */ + udp_recv(dhcp->pcb, dhcp_recv, netif); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n")); + /* (re)start the DHCP negotiation */ + result = dhcp_discover(netif); + if (result != ERR_OK) { + /* free resources allocated above */ + dhcp_stop(netif); + return ERR_MEM; + } + /* Set the flag that says this netif is handled by DHCP. */ + netif->flags |= NETIF_FLAG_DHCP; + return result; +} + +/** + * Inform a DHCP server of our manual configuration. + * + * This informs DHCP servers of our fixed IP address configuration + * by sending an INFORM message. It does not involve DHCP address + * configuration, it is just here to be nice to the network. + * + * @param netif The lwIP network interface + */ +void +dhcp_inform(struct netif *netif) +{ + struct dhcp dhcp; + err_t result = ERR_OK; + struct udp_pcb *pcb; + + LWIP_ERROR("netif != NULL", (netif != NULL), return;); + + memset(&dhcp, 0, sizeof(struct dhcp)); + dhcp_set_state(&dhcp, DHCP_INFORM); + + if ((netif->dhcp != NULL) && (netif->dhcp->pcb != NULL)) { + /* re-use existing pcb */ + pcb = netif->dhcp->pcb; + } else { + pcb = udp_new(); + if (pcb == NULL) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_inform(): could not obtain pcb")); + return; + } + dhcp.pcb = pcb; + ip_set_option(dhcp.pcb, SOF_BROADCAST); + udp_bind(dhcp.pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_inform(): created new udp pcb\n")); + } + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, &dhcp, DHCP_INFORM); + if (result == ERR_OK) { + dhcp_option(&dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); + dhcp_option_short(&dhcp, DHCP_MAX_MSG_LEN(netif)); + + dhcp_option_trailer(&dhcp); + + pbuf_realloc(dhcp.p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp.options_out_len); + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_inform: INFORMING\n")); + udp_sendto_if(pcb, dhcp.p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(&dhcp); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_inform: could not allocate DHCP request\n")); + } + + if (dhcp.pcb != NULL) { + /* otherwise, the existing pcb was used */ + udp_remove(dhcp.pcb); + } +} + +/** Handle a possible change in the network configuration. + * + * This enters the REBOOTING state to verify that the currently bound + * address is still valid. + */ +void +dhcp_network_changed(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + if (!dhcp) + return; + switch (dhcp->state) { + case DHCP_REBINDING: + case DHCP_RENEWING: + case DHCP_BOUND: + case DHCP_REBOOTING: + netif_set_down(netif); + dhcp->tries = 0; + dhcp_reboot(netif); + break; + case DHCP_OFF: + /* stay off */ + break; + default: + dhcp->tries = 0; +#if LWIP_DHCP_AUTOIP_COOP + if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { + autoip_stop(netif); + dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; + } +#endif /* LWIP_DHCP_AUTOIP_COOP */ + dhcp_discover(netif); + break; + } +} + +#if DHCP_DOES_ARP_CHECK +/** + * Match an ARP reply with the offered IP address. + * + * @param netif the network interface on which the reply was received + * @param addr The IP address we received a reply from + */ +void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr) +{ + LWIP_ERROR("netif != NULL", (netif != NULL), return;); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_arp_reply()\n")); + /* is a DHCP client doing an ARP check? */ + if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08"X32_F"\n", + ip4_addr_get_u32(addr))); + /* did a host respond with the address we + were offered by the DHCP server? */ + if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) { + /* we will not accept the offered address */ + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, + ("dhcp_arp_reply(): arp reply matched with offered address, declining\n")); + dhcp_decline(netif); + } + } +} + +/** + * Decline an offered lease. + * + * Tell the DHCP server we do not accept the offered address. + * One reason to decline the lease is when we find out the address + * is already in use by another host (through ARP). + * + * @param netif the netif under DHCP control + */ +static err_t +dhcp_decline(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result = ERR_OK; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline()\n")); + dhcp_set_state(dhcp, DHCP_BACKING_OFF); + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_DECLINE); + if (result == ERR_OK) { + dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); + dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); + + dhcp_option_trailer(dhcp); + /* resize pbuf to reflect true size of options */ + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + /* per section 4.4.4, broadcast DECLINE messages */ + udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(dhcp); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_decline: BACKING OFF\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, + ("dhcp_decline: could not allocate DHCP request\n")); + } + dhcp->tries++; + msecs = 10*1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs)); + return result; +} +#endif /* DHCP_DOES_ARP_CHECK */ + + +/** + * Start the DHCP process, discover a DHCP server. + * + * @param netif the netif under DHCP control + */ +static err_t +dhcp_discover(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result = ERR_OK; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover()\n")); + ip_addr_set_any(&dhcp->offered_ip_addr); + dhcp_set_state(dhcp, DHCP_SELECTING); + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_DISCOVER); + if (result == ERR_OK) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: making request\n")); + + dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); + dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); + + dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/); + dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK); + dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER); + dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST); + dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER); + + dhcp_option_trailer(dhcp); + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: realloc()ing\n")); + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)\n")); + udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: deleting()ing\n")); + dhcp_delete_msg(dhcp); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover: SELECTING\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_discover: could not allocate DHCP request\n")); + } + dhcp->tries++; +#if LWIP_DHCP_AUTOIP_COOP + if(dhcp->tries >= LWIP_DHCP_AUTOIP_COOP_TRIES && dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_OFF) { + dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_ON; + autoip_start(netif); + } +#endif /* LWIP_DHCP_AUTOIP_COOP */ + msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * 1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs)); + return result; +} + + +/** + * Bind the interface to the offered IP address. + * + * @param netif network interface to bind to the offered address + */ +static void +dhcp_bind(struct netif *netif) +{ + u32_t timeout; + struct dhcp *dhcp; + ip_addr_t sn_mask, gw_addr; + LWIP_ERROR("dhcp_bind: netif != NULL", (netif != NULL), return;); + dhcp = netif->dhcp; + LWIP_ERROR("dhcp_bind: dhcp != NULL", (dhcp != NULL), return;); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); + + /* temporary DHCP lease? */ + if (dhcp->offered_t1_renew != 0xffffffffUL) { + /* set renewal period timer */ + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew)); + timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; + if(timeout > 0xffff) { + timeout = 0xffff; + } + dhcp->t1_timeout = (u16_t)timeout; + if (dhcp->t1_timeout == 0) { + dhcp->t1_timeout = 1; + } + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000)); + } + /* set renewal period timer */ + if (dhcp->offered_t2_rebind != 0xffffffffUL) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind)); + timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; + if(timeout > 0xffff) { + timeout = 0xffff; + } + dhcp->t2_timeout = (u16_t)timeout; + if (dhcp->t2_timeout == 0) { + dhcp->t2_timeout = 1; + } + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000)); + } + + /* If we have sub 1 minute lease, t2 and t1 will kick in at the same time. */ + if ((dhcp->t1_timeout >= dhcp->t2_timeout) && (dhcp->t2_timeout > 0)) { + dhcp->t1_timeout = 0; + } + + if (dhcp->subnet_mask_given) { + /* copy offered network mask */ + ip_addr_copy(sn_mask, dhcp->offered_sn_mask); + } else { + /* subnet mask not given, choose a safe subnet mask given the network class */ + u8_t first_octet = ip4_addr1(&dhcp->offered_ip_addr); + if (first_octet <= 127) { + ip4_addr_set_u32(&sn_mask, PP_HTONL(0xff000000UL)); + } else if (first_octet >= 192) { + ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffffff00UL)); + } else { + ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffff0000UL)); + } + } + + ip_addr_copy(gw_addr, dhcp->offered_gw_addr); + /* gateway address not given? */ + if (ip_addr_isany(&gw_addr)) { + /* copy network address */ + ip_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask); + /* use first host address on network as gateway */ + ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001UL)); + } + +#if LWIP_DHCP_AUTOIP_COOP + if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { + autoip_stop(netif); + dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; + } +#endif /* LWIP_DHCP_AUTOIP_COOP */ + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", + ip4_addr_get_u32(&dhcp->offered_ip_addr))); + netif_set_ipaddr(netif, &dhcp->offered_ip_addr); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", + ip4_addr_get_u32(&sn_mask))); + netif_set_netmask(netif, &sn_mask); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): GW: 0x%08"X32_F"\n", + ip4_addr_get_u32(&gw_addr))); + netif_set_gw(netif, &gw_addr); + /* bring the interface up */ + netif_set_up(netif); + /* netif is now bound to DHCP leased address */ + dhcp_set_state(dhcp, DHCP_BOUND); +} + +/** + * Renew an existing DHCP lease at the involved DHCP server. + * + * @param netif network interface which must renew its lease + */ +err_t +dhcp_renew(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_renew()\n")); + dhcp_set_state(dhcp, DHCP_RENEWING); + + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); + if (result == ERR_OK) { + dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); + dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); + +#if 0 + dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); + dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); +#endif + +#if 0 + dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); + dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); +#endif + +#if LWIP_NETIF_HOSTNAME + dhcp_option_hostname(dhcp, netif); +#endif /* LWIP_NETIF_HOSTNAME */ + + /* append DHCP message trailer */ + dhcp_option_trailer(dhcp); + + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + udp_sendto_if(dhcp->pcb, dhcp->p_out, &dhcp->server_ip_addr, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(dhcp); + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew: RENEWING\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_renew: could not allocate DHCP request\n")); + } + dhcp->tries++; + /* back-off on retries, but to a maximum of 20 seconds */ + msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew(): set request timeout %"U16_F" msecs\n", msecs)); + return result; +} + +/** + * Rebind with a DHCP server for an existing DHCP lease. + * + * @param netif network interface which must rebind with a DHCP server + */ +static err_t +dhcp_rebind(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n")); + dhcp_set_state(dhcp, DHCP_REBINDING); + + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); + if (result == ERR_OK) { + dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); + dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); + +#if LWIP_NETIF_HOSTNAME + dhcp_option_hostname(dhcp, netif); +#endif /* LWIP_NETIF_HOSTNAME */ + +#if 0 + dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); + dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); + + dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); + dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); +#endif + + dhcp_option_trailer(dhcp); + + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + /* broadcast to server */ + udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(dhcp); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind: REBINDING\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_rebind: could not allocate DHCP request\n")); + } + dhcp->tries++; + msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind(): set request timeout %"U16_F" msecs\n", msecs)); + return result; +} + +/** + * Enter REBOOTING state to verify an existing lease + * + * @param netif network interface which must reboot + */ +static err_t +dhcp_reboot(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot()\n")); + dhcp_set_state(dhcp, DHCP_REBOOTING); + + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); + if (result == ERR_OK) { + dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); + dhcp_option_short(dhcp, 576); + + dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); + dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); + + dhcp_option_trailer(dhcp); + + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + /* broadcast to server */ + udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(dhcp); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot: REBOOTING\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_reboot: could not allocate DHCP request\n")); + } + dhcp->tries++; + msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot(): set request timeout %"U16_F" msecs\n", msecs)); + return result; +} + + +/** + * Release a DHCP lease. + * + * @param netif network interface which must release its lease + */ +err_t +dhcp_release(struct netif *netif) +{ + struct dhcp *dhcp = netif->dhcp; + err_t result; + u16_t msecs; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_release()\n")); + + /* idle DHCP client */ + dhcp_set_state(dhcp, DHCP_OFF); + /* clean old DHCP offer */ + ip_addr_set_zero(&dhcp->server_ip_addr); + ip_addr_set_zero(&dhcp->offered_ip_addr); + ip_addr_set_zero(&dhcp->offered_sn_mask); + ip_addr_set_zero(&dhcp->offered_gw_addr); +#if LWIP_DHCP_BOOTP_FILE + ip_addr_set_zero(&dhcp->offered_si_addr); +#endif /* LWIP_DHCP_BOOTP_FILE */ + dhcp->offered_t0_lease = dhcp->offered_t1_renew = dhcp->offered_t2_rebind = 0; + + /* create and initialize the DHCP message header */ + result = dhcp_create_msg(netif, dhcp, DHCP_RELEASE); + if (result == ERR_OK) { + dhcp_option_trailer(dhcp); + + pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); + + udp_sendto_if(dhcp->pcb, dhcp->p_out, &dhcp->server_ip_addr, DHCP_SERVER_PORT, netif); + dhcp_delete_msg(dhcp); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_release: could not allocate DHCP request\n")); + } + dhcp->tries++; + msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; + dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs)); + /* bring the interface down */ + netif_set_down(netif); + /* remove IP address from interface */ + netif_set_ipaddr(netif, IP_ADDR_ANY); + netif_set_gw(netif, IP_ADDR_ANY); + netif_set_netmask(netif, IP_ADDR_ANY); + + return result; +} + +/** + * Remove the DHCP client from the interface. + * + * @param netif The network interface to stop DHCP on + */ +void +dhcp_stop(struct netif *netif) +{ + struct dhcp *dhcp; + LWIP_ERROR("dhcp_stop: netif != NULL", (netif != NULL), return;); + dhcp = netif->dhcp; + /* Remove the flag that says this netif is handled by DHCP. */ + netif->flags &= ~NETIF_FLAG_DHCP; + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_stop()\n")); + /* netif is DHCP configured? */ + if (dhcp != NULL) { +#if LWIP_DHCP_AUTOIP_COOP + if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { + autoip_stop(netif); + dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; + } +#endif /* LWIP_DHCP_AUTOIP_COOP */ + + if (dhcp->pcb != NULL) { + udp_remove(dhcp->pcb); + dhcp->pcb = NULL; + } + LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL); + dhcp_set_state(dhcp, DHCP_OFF); + } +} + +/* + * Set the DHCP state of a DHCP client. + * + * If the state changed, reset the number of tries. + */ +static void +dhcp_set_state(struct dhcp *dhcp, u8_t new_state) +{ + if (new_state != dhcp->state) { + dhcp->state = new_state; + dhcp->tries = 0; + dhcp->request_timeout = 0; + } +} + +/* + * Concatenate an option type and length field to the outgoing + * DHCP message. + * + */ +static void +dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len) +{ + LWIP_ASSERT("dhcp_option: dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2U + option_len <= DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = option_type; + dhcp->msg_out->options[dhcp->options_out_len++] = option_len; +} +/* + * Concatenate a single byte to the outgoing DHCP message. + * + */ +static void +dhcp_option_byte(struct dhcp *dhcp, u8_t value) +{ + LWIP_ASSERT("dhcp_option_byte: dhcp->options_out_len < DHCP_OPTIONS_LEN", dhcp->options_out_len < DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = value; +} + +static void +dhcp_option_short(struct dhcp *dhcp, u16_t value) +{ + LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2U <= DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0xff00U) >> 8); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t) (value & 0x00ffU); +} + +static void +dhcp_option_long(struct dhcp *dhcp, u32_t value) +{ + LWIP_ASSERT("dhcp_option_long: dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 4U <= DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0xff000000UL) >> 24); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x00ff0000UL) >> 16); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x0000ff00UL) >> 8); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x000000ffUL)); +} + +#if LWIP_NETIF_HOSTNAME +static void +dhcp_option_hostname(struct dhcp *dhcp, struct netif *netif) +{ + if (netif->hostname != NULL) { + size_t namelen = strlen(netif->hostname); + if (namelen > 0) { + u8_t len; + const char *p = netif->hostname; + /* Shrink len to available bytes (need 2 bytes for OPTION_HOSTNAME + and 1 byte for trailer) */ + size_t available = DHCP_OPTIONS_LEN - dhcp->options_out_len - 3; + LWIP_ASSERT("DHCP: hostname is too long!", namelen <= available); + len = LWIP_MIN(namelen, available); + dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, len); + while (len--) { + dhcp_option_byte(dhcp, *p++); + } + } + } +} +#endif /* LWIP_NETIF_HOSTNAME */ + +/** + * Extract the DHCP message and the DHCP options. + * + * Extract the DHCP message and the DHCP options, each into a contiguous + * piece of memory. As a DHCP message is variable sized by its options, + * and also allows overriding some fields for options, the easy approach + * is to first unfold the options into a conitguous piece of memory, and + * use that further on. + * + */ +static err_t +dhcp_parse_reply(struct dhcp *dhcp, struct pbuf *p) +{ + u8_t *options; + u16_t offset; + u16_t offset_max; + u16_t options_idx; + u16_t options_idx_max; + struct pbuf *q; + int parse_file_as_options = 0; + int parse_sname_as_options = 0; + + /* clear received options */ + dhcp_clear_all_options(dhcp); + /* check that beginning of dhcp_msg (up to and including chaddr) is in first pbuf */ + if (p->len < DHCP_SNAME_OFS) { + return ERR_BUF; + } + dhcp->msg_in = (struct dhcp_msg *)p->payload; +#if LWIP_DHCP_BOOTP_FILE + /* clear boot file name */ + dhcp->boot_file_name[0] = 0; +#endif /* LWIP_DHCP_BOOTP_FILE */ + + /* parse options */ + + /* start with options field */ + options_idx = DHCP_OPTIONS_OFS; + /* parse options to the end of the received packet */ + options_idx_max = p->tot_len; +again: + q = p; + while((q != NULL) && (options_idx >= q->len)) { + options_idx -= q->len; + options_idx_max -= q->len; + q = q->next; + } + if (q == NULL) { + return ERR_BUF; + } + offset = options_idx; + offset_max = options_idx_max; + options = (u8_t*)q->payload; + /* at least 1 byte to read and no end marker, then at least 3 bytes to read? */ + while((q != NULL) && (options[offset] != DHCP_OPTION_END) && (offset < offset_max)) { + u8_t op = options[offset]; + u8_t len; + u8_t decode_len = 0; + int decode_idx = -1; + u16_t val_offset = offset + 2; + /* len byte might be in the next pbuf */ + if (offset + 1 < q->len) { + len = options[offset + 1]; + } else { + len = (q->next != NULL ? ((u8_t*)q->next->payload)[0] : 0); + } + /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */ + decode_len = len; + switch(op) { + /* case(DHCP_OPTION_END): handled above */ + case(DHCP_OPTION_PAD): + /* special option: no len encoded */ + decode_len = len = 0; + /* will be increased below */ + offset--; + break; + case(DHCP_OPTION_SUBNET_MASK): + LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_SUBNET_MASK; + break; + case(DHCP_OPTION_ROUTER): + decode_len = 4; /* only copy the first given router */ + LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_ROUTER; + break; + case(DHCP_OPTION_DNS_SERVER): + /* special case: there might be more than one server */ + LWIP_ERROR("len % 4 == 0", len % 4 == 0, return ERR_VAL;); + /* limit number of DNS servers */ + decode_len = LWIP_MIN(len, 4 * DNS_MAX_SERVERS); + LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_DNS_SERVER; + break; + case(DHCP_OPTION_LEASE_TIME): + LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_LEASE_TIME; + break; + case(DHCP_OPTION_OVERLOAD): + LWIP_ERROR("len == 1", len == 1, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_OVERLOAD; + break; + case(DHCP_OPTION_MESSAGE_TYPE): + LWIP_ERROR("len == 1", len == 1, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_MSG_TYPE; + break; + case(DHCP_OPTION_SERVER_ID): + LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_SERVER_ID; + break; + case(DHCP_OPTION_T1): + LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_T1; + break; + case(DHCP_OPTION_T2): + LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); + decode_idx = DHCP_OPTION_IDX_T2; + break; + default: + decode_len = 0; + LWIP_DEBUGF(DHCP_DEBUG, ("skipping option %"U16_F" in options\n", op)); + break; + } + offset += len + 2; + if (decode_len > 0) { + u32_t value = 0; + u16_t copy_len; +decode_next: + LWIP_ASSERT("check decode_idx", decode_idx >= 0 && decode_idx < DHCP_OPTION_IDX_MAX); + if (!dhcp_option_given(dhcp, decode_idx)) { + copy_len = LWIP_MIN(decode_len, 4); + pbuf_copy_partial(q, &value, copy_len, val_offset); + if (decode_len > 4) { + /* decode more than one u32_t */ + LWIP_ERROR("decode_len % 4 == 0", decode_len % 4 == 0, return ERR_VAL;); + dhcp_got_option(dhcp, decode_idx); + dhcp_set_option_value(dhcp, decode_idx, htonl(value)); + decode_len -= 4; + val_offset += 4; + decode_idx++; + goto decode_next; + } else if (decode_len == 4) { + value = ntohl(value); + } else { + LWIP_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;); + value = ((u8_t*)&value)[0]; + } + dhcp_got_option(dhcp, decode_idx); + dhcp_set_option_value(dhcp, decode_idx, value); + } + } + if (offset >= q->len) { + offset -= q->len; + offset_max -= q->len; + if ((offset < offset_max) && offset_max) { + q = q->next; + LWIP_ASSERT("next pbuf was null", q); + options = (u8_t*)q->payload; + } else { + // We've run out of bytes, probably no end marker. Don't proceed. + break; + } + } + } + /* is this an overloaded message? */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_OVERLOAD)) { + u32_t overload = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_OVERLOAD); + dhcp_clear_option(dhcp, DHCP_OPTION_IDX_OVERLOAD); + if (overload == DHCP_OVERLOAD_FILE) { + parse_file_as_options = 1; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("overloaded file field\n")); + } else if (overload == DHCP_OVERLOAD_SNAME) { + parse_sname_as_options = 1; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("overloaded sname field\n")); + } else if (overload == DHCP_OVERLOAD_SNAME_FILE) { + parse_sname_as_options = 1; + parse_file_as_options = 1; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("overloaded sname and file field\n")); + } else { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("invalid overload option: %d\n", (int)overload)); + } +#if LWIP_DHCP_BOOTP_FILE + if (!parse_file_as_options) { + /* only do this for ACK messages */ + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE) && + (dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE) == DHCP_ACK)) + /* copy bootp file name, don't care for sname (server hostname) */ + pbuf_copy_partial(p, dhcp->boot_file_name, DHCP_FILE_LEN-1, DHCP_FILE_OFS); + /* make sure the string is really NULL-terminated */ + dhcp->boot_file_name[DHCP_FILE_LEN-1] = 0; + } +#endif /* LWIP_DHCP_BOOTP_FILE */ + } + if (parse_file_as_options) { + /* if both are overloaded, parse file first and then sname (RFC 2131 ch. 4.1) */ + parse_file_as_options = 0; + options_idx = DHCP_FILE_OFS; + options_idx_max = DHCP_FILE_OFS + DHCP_FILE_LEN; + goto again; + } else if (parse_sname_as_options) { + parse_sname_as_options = 0; + options_idx = DHCP_SNAME_OFS; + options_idx_max = DHCP_SNAME_OFS + DHCP_SNAME_LEN; + goto again; + } + return ERR_OK; +} + +/** + * If an incoming DHCP message is in response to us, then trigger the state machine + */ +static void +dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) +{ + struct netif *netif = (struct netif *)arg; + struct dhcp *dhcp = netif->dhcp; + struct dhcp_msg *reply_msg = (struct dhcp_msg *)p->payload; + u8_t msg_type; + u8_t i; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p, + ip4_addr1_16(addr), ip4_addr2_16(addr), ip4_addr3_16(addr), ip4_addr4_16(addr), port)); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len)); + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len)); + /* prevent warnings about unused arguments */ + LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(addr); + LWIP_UNUSED_ARG(port); + + LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL); + + if (p->len < DHCP_MIN_REPLY_LEN) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("DHCP reply message or pbuf too short\n")); + goto free_pbuf_and_return; + } + + if (reply_msg->op != DHCP_BOOTREPLY) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("not a DHCP reply message, but type %"U16_F"\n", (u16_t)reply_msg->op)); + goto free_pbuf_and_return; + } + /* iterate through hardware address and match against DHCP message */ + for (i = 0; i < netif->hwaddr_len; i++) { + if (netif->hwaddr[i] != reply_msg->chaddr[i]) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, + ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n", + (u16_t)i, (u16_t)netif->hwaddr[i], (u16_t)i, (u16_t)reply_msg->chaddr[i])); + goto free_pbuf_and_return; + } + } + /* match transaction ID against what we expected */ + if (ntohl(reply_msg->xid) != dhcp->xid) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, + ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",ntohl(reply_msg->xid),dhcp->xid)); + goto free_pbuf_and_return; + } + /* option fields could be unfold? */ + if (dhcp_parse_reply(dhcp, p) != ERR_OK) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, + ("problem unfolding DHCP message - too short on memory?\n")); + goto free_pbuf_and_return; + } + + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n")); + /* obtain pointer to DHCP message type */ + if (!dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE)) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("DHCP_OPTION_MESSAGE_TYPE option not found\n")); + goto free_pbuf_and_return; + } + + /* read DHCP message type */ + msg_type = (u8_t)dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE); + /* message type is DHCP ACK? */ + if (msg_type == DHCP_ACK) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_ACK received\n")); + /* in requesting state? */ + if (dhcp->state == DHCP_REQUESTING) { + dhcp_handle_ack(netif); +#if DHCP_DOES_ARP_CHECK + /* check if the acknowledged lease address is already in use */ + dhcp_check(netif); +#else + /* bind interface to the acknowledged lease address */ + dhcp_bind(netif); +#endif + } + /* already bound to the given lease address? */ + else if ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING)) { + dhcp_bind(netif); + } + } + /* received a DHCP_NAK in appropriate state? */ + else if ((msg_type == DHCP_NAK) && + ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) || + (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_NAK received\n")); + dhcp_handle_nak(netif); + } + /* received a DHCP_OFFER in DHCP_SELECTING state? */ + else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_OFFER received in DHCP_SELECTING state\n")); + dhcp->request_timeout = 0; + /* remember offered lease */ + dhcp_handle_offer(netif); + } +free_pbuf_and_return: + dhcp->msg_in = NULL; + pbuf_free(p); +} + +/** + * Create a DHCP request, fill in common headers + * + * @param netif the netif under DHCP control + * @param dhcp dhcp control struct + * @param message_type message type of the request + */ +static err_t +dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type) +{ + u16_t i; +#ifndef DHCP_GLOBAL_XID + /** default global transaction identifier starting value (easy to match + * with a packet analyser). We simply increment for each new request. + * Predefine DHCP_GLOBAL_XID to a better value or a function call to generate one + * at runtime, any supporting function prototypes can be defined in DHCP_GLOBAL_XID_HEADER */ +#if DHCP_CREATE_RAND_XID && defined(LWIP_RAND) + static u32_t xid; +#else /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ + static u32_t xid = 0xABCD0000; +#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ +#else + if (!xid_initialised) { + xid = DHCP_GLOBAL_XID; + xid_initialised = !xid_initialised; + } +#endif + LWIP_ERROR("dhcp_create_msg: netif != NULL", (netif != NULL), return ERR_ARG;); + LWIP_ERROR("dhcp_create_msg: dhcp != NULL", (dhcp != NULL), return ERR_VAL;); + LWIP_ASSERT("dhcp_create_msg: dhcp->p_out == NULL", dhcp->p_out == NULL); + LWIP_ASSERT("dhcp_create_msg: dhcp->msg_out == NULL", dhcp->msg_out == NULL); + dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM); + if (dhcp->p_out == NULL) { + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, + ("dhcp_create_msg(): could not allocate pbuf\n")); + return ERR_MEM; + } + LWIP_ASSERT("dhcp_create_msg: check that first pbuf can hold struct dhcp_msg", + (dhcp->p_out->len >= sizeof(struct dhcp_msg))); + + /* reuse transaction identifier in retransmissions */ + if (dhcp->tries == 0) { +#if DHCP_CREATE_RAND_XID && defined(LWIP_RAND) + xid = LWIP_RAND(); +#else /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ + xid++; +#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ + } + dhcp->xid = xid; + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, + ("transaction id xid(%"X32_F")\n", xid)); + + dhcp->msg_out = (struct dhcp_msg *)dhcp->p_out->payload; + + dhcp->msg_out->op = DHCP_BOOTREQUEST; + /* TODO: make link layer independent */ + dhcp->msg_out->htype = DHCP_HTYPE_ETH; + dhcp->msg_out->hlen = netif->hwaddr_len; + dhcp->msg_out->hops = 0; + dhcp->msg_out->xid = htonl(dhcp->xid); + dhcp->msg_out->secs = 0; + /* we don't need the broadcast flag since we can receive unicast traffic + before being fully configured! */ + dhcp->msg_out->flags = 0; + ip_addr_set_zero(&dhcp->msg_out->ciaddr); + /* set ciaddr to netif->ip_addr based on message_type and state */ + if ((message_type == DHCP_INFORM) || (message_type == DHCP_DECLINE) || + ((message_type == DHCP_REQUEST) && /* DHCP_BOUND not used for sending! */ + ((dhcp->state==DHCP_RENEWING) || dhcp->state==DHCP_REBINDING))) { + ip_addr_copy(dhcp->msg_out->ciaddr, netif->ip_addr); + } + ip_addr_set_zero(&dhcp->msg_out->yiaddr); + ip_addr_set_zero(&dhcp->msg_out->siaddr); + ip_addr_set_zero(&dhcp->msg_out->giaddr); + for (i = 0; i < DHCP_CHADDR_LEN; i++) { + /* copy netif hardware address, pad with zeroes */ + dhcp->msg_out->chaddr[i] = (i < netif->hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/; + } + for (i = 0; i < DHCP_SNAME_LEN; i++) { + dhcp->msg_out->sname[i] = 0; + } + for (i = 0; i < DHCP_FILE_LEN; i++) { + dhcp->msg_out->file[i] = 0; + } + dhcp->msg_out->cookie = PP_HTONL(DHCP_MAGIC_COOKIE); + dhcp->options_out_len = 0; + /* fill options field with an incrementing array (for debugging purposes) */ + for (i = 0; i < DHCP_OPTIONS_LEN; i++) { + dhcp->msg_out->options[i] = (u8_t)i; /* for debugging only, no matter if truncated */ + } + /* Add option MESSAGE_TYPE */ + dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); + dhcp_option_byte(dhcp, message_type); + return ERR_OK; +} + +/** + * Free previously allocated memory used to send a DHCP request. + * + * @param dhcp the dhcp struct to free the request from + */ +static void +dhcp_delete_msg(struct dhcp *dhcp) +{ + LWIP_ERROR("dhcp_delete_msg: dhcp != NULL", (dhcp != NULL), return;); + LWIP_ASSERT("dhcp_delete_msg: dhcp->p_out != NULL", dhcp->p_out != NULL); + LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL); + if (dhcp->p_out != NULL) { + pbuf_free(dhcp->p_out); + } + dhcp->p_out = NULL; + dhcp->msg_out = NULL; +} + +/** + * Add a DHCP message trailer + * + * Adds the END option to the DHCP message, and if + * necessary, up to three padding bytes. + * + * @param dhcp DHCP state structure + */ +static void +dhcp_option_trailer(struct dhcp *dhcp) +{ + LWIP_ERROR("dhcp_option_trailer: dhcp != NULL", (dhcp != NULL), return;); + LWIP_ASSERT("dhcp_option_trailer: dhcp->msg_out != NULL\n", dhcp->msg_out != NULL); + LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END; + /* packet is too small, or not 4 byte aligned? */ + while (((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) && + (dhcp->options_out_len < DHCP_OPTIONS_LEN)) { + /* add a fill/padding byte */ + dhcp->msg_out->options[dhcp->options_out_len++] = 0; + } +} + +#endif /* LWIP_DHCP */ diff --git a/user/mpy/lib/lwip/src/core/dns.c b/user/mpy/lib/lwip/src/core/dns.c new file mode 100644 index 0000000..d633612 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/dns.c @@ -0,0 +1,970 @@ +/** + * @file + * DNS - host name to IP address resolver. + * + */ + +/** + + * This file implements a DNS host name to IP address resolver. + + * Port to lwIP from uIP + * by Jim Pettinato April 2007 + + * uIP version Copyright (c) 2002-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * DNS.C + * + * The lwIP DNS resolver functions are used to lookup a host name and + * map it to a numerical IP address. It maintains a list of resolved + * hostnames that can be queried with the dns_lookup() function. + * New hostnames can be resolved using the dns_query() function. + * + * The lwIP version of the resolver also adds a non-blocking version of + * gethostbyname() that will work with a raw API application. This function + * checks for an IP address string first and converts it if it is valid. + * gethostbyname() then does a dns_lookup() to see if the name is + * already in the table. If so, the IP is returned. If not, a query is + * issued and the function returns with a ERR_INPROGRESS status. The app + * using the dns client must then go into a waiting state. + * + * Once a hostname has been resolved (or found to be non-existent), + * the resolver code calls a specified callback function (which + * must be implemented by the module that uses the resolver). + */ + +/*----------------------------------------------------------------------------- + * RFC 1035 - Domain names - implementation and specification + * RFC 2181 - Clarifications to the DNS Specification + *----------------------------------------------------------------------------*/ + +/** @todo: define good default values (rfc compliance) */ +/** @todo: improve answer parsing, more checkings... */ +/** @todo: check RFC1035 - 7.3. Processing responses */ + +/*----------------------------------------------------------------------------- + * Includes + *----------------------------------------------------------------------------*/ + +#include "lwip/opt.h" + +#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/udp.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/dns.h" + +#include + +/** DNS server IP address */ +#ifndef DNS_SERVER_ADDRESS +#define DNS_SERVER_ADDRESS(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("208.67.222.222"))) /* resolver1.opendns.com */ +#endif + +/** DNS server port address */ +#ifndef DNS_SERVER_PORT +#define DNS_SERVER_PORT 53 +#endif + +/** DNS maximum number of retries when asking for a name, before "timeout". */ +#ifndef DNS_MAX_RETRIES +#define DNS_MAX_RETRIES 4 +#endif + +/** DNS resource record max. TTL (one week as default) */ +#ifndef DNS_MAX_TTL +#define DNS_MAX_TTL 604800 +#endif + +/* DNS protocol flags */ +#define DNS_FLAG1_RESPONSE 0x80 +#define DNS_FLAG1_OPCODE_STATUS 0x10 +#define DNS_FLAG1_OPCODE_INVERSE 0x08 +#define DNS_FLAG1_OPCODE_STANDARD 0x00 +#define DNS_FLAG1_AUTHORATIVE 0x04 +#define DNS_FLAG1_TRUNC 0x02 +#define DNS_FLAG1_RD 0x01 +#define DNS_FLAG2_RA 0x80 +#define DNS_FLAG2_ERR_MASK 0x0f +#define DNS_FLAG2_ERR_NONE 0x00 +#define DNS_FLAG2_ERR_NAME 0x03 + +/* DNS protocol states */ +#define DNS_STATE_UNUSED 0 +#define DNS_STATE_NEW 1 +#define DNS_STATE_ASKING 2 +#define DNS_STATE_DONE 3 + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** DNS message header */ +struct dns_hdr { + PACK_STRUCT_FIELD(u16_t id); + PACK_STRUCT_FIELD(u8_t flags1); + PACK_STRUCT_FIELD(u8_t flags2); + PACK_STRUCT_FIELD(u16_t numquestions); + PACK_STRUCT_FIELD(u16_t numanswers); + PACK_STRUCT_FIELD(u16_t numauthrr); + PACK_STRUCT_FIELD(u16_t numextrarr); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif +#define SIZEOF_DNS_HDR 12 + +/** DNS query message structure. + No packing needed: only used locally on the stack. */ +struct dns_query { + /* DNS query record starts with either a domain name or a pointer + to a name already present somewhere in the packet. */ + u16_t type; + u16_t cls; +}; +#define SIZEOF_DNS_QUERY 4 + +/** DNS answer message structure. + No packing needed: only used locally on the stack. */ +struct dns_answer { + /* DNS answer record starts with either a domain name or a pointer + to a name already present somewhere in the packet. */ + u16_t type; + u16_t cls; + u32_t ttl; + u16_t len; +}; +#define SIZEOF_DNS_ANSWER 10 + +/** DNS table entry */ +struct dns_table_entry { + u8_t state; + u8_t numdns; + u8_t tmr; + u8_t retries; + u8_t seqno; + u8_t err; + u32_t ttl; + char name[DNS_MAX_NAME_LENGTH]; + ip_addr_t ipaddr; + /* pointer to callback on DNS query done */ + dns_found_callback found; + void *arg; +}; + +#if DNS_LOCAL_HOSTLIST + +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC +/** Local host-list. For hostnames in this list, no + * external name resolution is performed */ +static struct local_hostlist_entry *local_hostlist_dynamic; +#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + +/** Defining this allows the local_hostlist_static to be placed in a different + * linker section (e.g. FLASH) */ +#ifndef DNS_LOCAL_HOSTLIST_STORAGE_PRE +#define DNS_LOCAL_HOSTLIST_STORAGE_PRE static +#endif /* DNS_LOCAL_HOSTLIST_STORAGE_PRE */ +/** Defining this allows the local_hostlist_static to be placed in a different + * linker section (e.g. FLASH) */ +#ifndef DNS_LOCAL_HOSTLIST_STORAGE_POST +#define DNS_LOCAL_HOSTLIST_STORAGE_POST +#endif /* DNS_LOCAL_HOSTLIST_STORAGE_POST */ +DNS_LOCAL_HOSTLIST_STORAGE_PRE struct local_hostlist_entry local_hostlist_static[] + DNS_LOCAL_HOSTLIST_STORAGE_POST = DNS_LOCAL_HOSTLIST_INIT; + +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + +static void dns_init_local(); +#endif /* DNS_LOCAL_HOSTLIST */ + + +/* forward declarations */ +static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); +static void dns_check_entries(void); + +/*----------------------------------------------------------------------------- + * Globales + *----------------------------------------------------------------------------*/ + +/* DNS variables */ +static struct udp_pcb *dns_pcb; +static u8_t dns_seqno; +static struct dns_table_entry dns_table[DNS_TABLE_SIZE]; +static ip_addr_t dns_servers[DNS_MAX_SERVERS]; +/** Contiguous buffer for processing responses */ +static u8_t dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)]; +static u8_t* dns_payload; + +/** + * Initialize the resolver: set up the UDP pcb and configure the default server + * (DNS_SERVER_ADDRESS). + */ +void +dns_init() +{ + ip_addr_t dnsserver; + + dns_payload = (u8_t *)LWIP_MEM_ALIGN(dns_payload_buffer); + + /* initialize default DNS server address */ + DNS_SERVER_ADDRESS(&dnsserver); + + LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n")); + + /* if dns client not yet initialized... */ + if (dns_pcb == NULL) { + dns_pcb = udp_new(); + + if (dns_pcb != NULL) { + /* initialize DNS table not needed (initialized to zero since it is a + * global variable) */ + LWIP_ASSERT("For implicit initialization to work, DNS_STATE_UNUSED needs to be 0", + DNS_STATE_UNUSED == 0); + + /* initialize DNS client */ + udp_bind(dns_pcb, IP_ADDR_ANY, 0); + udp_recv(dns_pcb, dns_recv, NULL); + + /* initialize default DNS primary server */ + dns_setserver(0, &dnsserver); + } + } +#if DNS_LOCAL_HOSTLIST + dns_init_local(); +#endif +} + +/** + * Initialize one of the DNS servers. + * + * @param numdns the index of the DNS server to set must be < DNS_MAX_SERVERS + * @param dnsserver IP address of the DNS server to set + */ +void +dns_setserver(u8_t numdns, ip_addr_t *dnsserver) +{ + if ((numdns < DNS_MAX_SERVERS) && (dns_pcb != NULL) && + (dnsserver != NULL) && !ip_addr_isany(dnsserver)) { + dns_servers[numdns] = (*dnsserver); + } +} + +/** + * Obtain one of the currently configured DNS server. + * + * @param numdns the index of the DNS server + * @return IP address of the indexed DNS server or "ip_addr_any" if the DNS + * server has not been configured. + */ +ip_addr_t +dns_getserver(u8_t numdns) +{ + if (numdns < DNS_MAX_SERVERS) { + return dns_servers[numdns]; + } else { + return *IP_ADDR_ANY; + } +} + +/** + * The DNS resolver client timer - handle retries and timeouts and should + * be called every DNS_TMR_INTERVAL milliseconds (every second by default). + */ +void +dns_tmr(void) +{ + if (dns_pcb != NULL) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_tmr: dns_check_entries\n")); + dns_check_entries(); + } +} + +#if DNS_LOCAL_HOSTLIST +static void +dns_init_local() +{ +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) + int i; + struct local_hostlist_entry *entry; + /* Dynamic: copy entries from DNS_LOCAL_HOSTLIST_INIT to list */ + struct local_hostlist_entry local_hostlist_init[] = DNS_LOCAL_HOSTLIST_INIT; + size_t namelen; + for (i = 0; i < sizeof(local_hostlist_init) / sizeof(struct local_hostlist_entry); i++) { + struct local_hostlist_entry *init_entry = &local_hostlist_init[i]; + LWIP_ASSERT("invalid host name (NULL)", init_entry->name != NULL); + namelen = strlen(init_entry->name); + LWIP_ASSERT("namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN", namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN); + entry = (struct local_hostlist_entry *)memp_malloc(MEMP_LOCALHOSTLIST); + LWIP_ASSERT("mem-error in dns_init_local", entry != NULL); + if (entry != NULL) { + entry->name = (char*)entry + sizeof(struct local_hostlist_entry); + MEMCPY((char*)entry->name, init_entry->name, namelen); + ((char*)entry->name)[namelen] = 0; + entry->addr = init_entry->addr; + entry->next = local_hostlist_dynamic; + local_hostlist_dynamic = entry; + } + } +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) */ +} + +/** + * Scans the local host-list for a hostname. + * + * @param hostname Hostname to look for in the local host-list + * @return The first IP address for the hostname in the local host-list or + * IPADDR_NONE if not found. + */ +static u32_t +dns_lookup_local(const char *hostname) +{ +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC + struct local_hostlist_entry *entry = local_hostlist_dynamic; + while(entry != NULL) { + if(strcmp(entry->name, hostname) == 0) { + return ip4_addr_get_u32(&entry->addr); + } + entry = entry->next; + } +#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + int i; + for (i = 0; i < sizeof(local_hostlist_static) / sizeof(struct local_hostlist_entry); i++) { + if(strcmp(local_hostlist_static[i].name, hostname) == 0) { + return ip4_addr_get_u32(&local_hostlist_static[i].addr); + } + } +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + return IPADDR_NONE; +} + +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC +/** Remove all entries from the local host-list for a specific hostname + * and/or IP addess + * + * @param hostname hostname for which entries shall be removed from the local + * host-list + * @param addr address for which entries shall be removed from the local host-list + * @return the number of removed entries + */ +int +dns_local_removehost(const char *hostname, const ip_addr_t *addr) +{ + int removed = 0; + struct local_hostlist_entry *entry = local_hostlist_dynamic; + struct local_hostlist_entry *last_entry = NULL; + while (entry != NULL) { + if (((hostname == NULL) || !strcmp(entry->name, hostname)) && + ((addr == NULL) || ip_addr_cmp(&entry->addr, addr))) { + struct local_hostlist_entry *free_entry; + if (last_entry != NULL) { + last_entry->next = entry->next; + } else { + local_hostlist_dynamic = entry->next; + } + free_entry = entry; + entry = entry->next; + memp_free(MEMP_LOCALHOSTLIST, free_entry); + removed++; + } else { + last_entry = entry; + entry = entry->next; + } + } + return removed; +} + +/** + * Add a hostname/IP address pair to the local host-list. + * Duplicates are not checked. + * + * @param hostname hostname of the new entry + * @param addr IP address of the new entry + * @return ERR_OK if succeeded or ERR_MEM on memory error + */ +err_t +dns_local_addhost(const char *hostname, const ip_addr_t *addr) +{ + struct local_hostlist_entry *entry; + size_t namelen; + LWIP_ASSERT("invalid host name (NULL)", hostname != NULL); + namelen = strlen(hostname); + LWIP_ASSERT("namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN", namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN); + entry = (struct local_hostlist_entry *)memp_malloc(MEMP_LOCALHOSTLIST); + if (entry == NULL) { + return ERR_MEM; + } + entry->name = (char*)entry + sizeof(struct local_hostlist_entry); + MEMCPY((char*)entry->name, hostname, namelen); + ((char*)entry->name)[namelen] = 0; + ip_addr_copy(entry->addr, *addr); + entry->next = local_hostlist_dynamic; + local_hostlist_dynamic = entry; + return ERR_OK; +} +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC*/ +#endif /* DNS_LOCAL_HOSTLIST */ + +/** + * Look up a hostname in the array of known hostnames. + * + * @note This function only looks in the internal array of known + * hostnames, it does not send out a query for the hostname if none + * was found. The function dns_enqueue() can be used to send a query + * for a hostname. + * + * @param name the hostname to look up + * @return the hostname's IP address, as u32_t (instead of ip_addr_t to + * better check for failure: != IPADDR_NONE) or IPADDR_NONE if the hostname + * was not found in the cached dns_table. + */ +static u32_t +dns_lookup(const char *name) +{ + u8_t i; +#if DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) + u32_t addr; +#endif /* DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) */ +#if DNS_LOCAL_HOSTLIST + if ((addr = dns_lookup_local(name)) != IPADDR_NONE) { + return addr; + } +#endif /* DNS_LOCAL_HOSTLIST */ +#ifdef DNS_LOOKUP_LOCAL_EXTERN + if((addr = DNS_LOOKUP_LOCAL_EXTERN(name)) != IPADDR_NONE) { + return addr; + } +#endif /* DNS_LOOKUP_LOCAL_EXTERN */ + + /* Walk through name list, return entry if found. If not, return NULL. */ + for (i = 0; i < DNS_TABLE_SIZE; ++i) { + if ((dns_table[i].state == DNS_STATE_DONE) && + (strcmp(name, dns_table[i].name) == 0)) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_lookup: \"%s\": found = ", name)); + ip_addr_debug_print(DNS_DEBUG, &(dns_table[i].ipaddr)); + LWIP_DEBUGF(DNS_DEBUG, ("\n")); + return ip4_addr_get_u32(&dns_table[i].ipaddr); + } + } + + return IPADDR_NONE; +} + +#if DNS_DOES_NAME_CHECK +/** + * Compare the "dotted" name "query" with the encoded name "response" + * to make sure an answer from the DNS server matches the current dns_table + * entry (otherwise, answers might arrive late for hostname not on the list + * any more). + * + * @param query hostname (not encoded) from the dns_table + * @param response encoded hostname in the DNS response + * @return 0: names equal; 1: names differ + */ +static u8_t +dns_compare_name(unsigned char *query, unsigned char *response) +{ + unsigned char n; + + do { + n = *response++; + /** @see RFC 1035 - 4.1.4. Message compression */ + if ((n & 0xc0) == 0xc0) { + /* Compressed name */ + break; + } else { + /* Not compressed name */ + while (n > 0) { + if ((*query) != (*response)) { + return 1; + } + ++response; + ++query; + --n; + }; + ++query; + } + } while (*response != 0); + + return 0; +} +#endif /* DNS_DOES_NAME_CHECK */ + +/** + * Walk through a compact encoded DNS name and return the end of the name. + * + * @param query encoded DNS name in the DNS server response + * @return end of the name + */ +static unsigned char * +dns_parse_name(unsigned char *query) +{ + unsigned char n; + + do { + n = *query++; + /** @see RFC 1035 - 4.1.4. Message compression */ + if ((n & 0xc0) == 0xc0) { + /* Compressed name */ + break; + } else { + /* Not compressed name */ + while (n > 0) { + ++query; + --n; + }; + } + } while (*query != 0); + + return query + 1; +} + +/** + * Send a DNS query packet. + * + * @param numdns index of the DNS server in the dns_servers table + * @param name hostname to query + * @param id index of the hostname in dns_table, used as transaction ID in the + * DNS query packet + * @return ERR_OK if packet is sent; an err_t indicating the problem otherwise + */ +static err_t +dns_send(u8_t numdns, const char* name, u8_t id) +{ + err_t err; + struct dns_hdr *hdr; + struct dns_query qry; + struct pbuf *p; + char *query, *nptr; + const char *pHostname; + u8_t n; + + LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n", + (u16_t)(numdns), name)); + LWIP_ASSERT("dns server out of array", numdns < DNS_MAX_SERVERS); + LWIP_ASSERT("dns server has no IP address set", !ip_addr_isany(&dns_servers[numdns])); + + /* if here, we have either a new query or a retry on a previous query to process */ + p = pbuf_alloc(PBUF_TRANSPORT, SIZEOF_DNS_HDR + DNS_MAX_NAME_LENGTH + + SIZEOF_DNS_QUERY, PBUF_RAM); + if (p != NULL) { + LWIP_ASSERT("pbuf must be in one piece", p->next == NULL); + /* fill dns header */ + hdr = (struct dns_hdr*)p->payload; + memset(hdr, 0, SIZEOF_DNS_HDR); + hdr->id = htons(id); + hdr->flags1 = DNS_FLAG1_RD; + hdr->numquestions = PP_HTONS(1); + query = (char*)hdr + SIZEOF_DNS_HDR; + pHostname = name; + --pHostname; + + /* convert hostname into suitable query format. */ + do { + ++pHostname; + nptr = query; + ++query; + for(n = 0; *pHostname != '.' && *pHostname != 0; ++pHostname) { + *query = *pHostname; + ++query; + ++n; + } + *nptr = n; + } while(*pHostname != 0); + *query++='\0'; + + /* fill dns query */ + qry.type = PP_HTONS(DNS_RRTYPE_A); + qry.cls = PP_HTONS(DNS_RRCLASS_IN); + SMEMCPY(query, &qry, SIZEOF_DNS_QUERY); + + /* resize pbuf to the exact dns query */ + pbuf_realloc(p, (u16_t)((query + SIZEOF_DNS_QUERY) - ((char*)(p->payload)))); + + /* connect to the server for faster receiving */ + udp_connect(dns_pcb, &dns_servers[numdns], DNS_SERVER_PORT); + /* send dns packet */ + err = udp_sendto(dns_pcb, p, &dns_servers[numdns], DNS_SERVER_PORT); + + /* free pbuf */ + pbuf_free(p); + } else { + err = ERR_MEM; + } + + return err; +} + +/** + * dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query. + * Check an entry in the dns_table: + * - send out query for new entries + * - retry old pending entries on timeout (also with different servers) + * - remove completed entries from the table if their TTL has expired + * + * @param i index of the dns_table entry to check + */ +static void +dns_check_entry(u8_t i) +{ + err_t err; + struct dns_table_entry *pEntry = &dns_table[i]; + + LWIP_ASSERT("array index out of bounds", i < DNS_TABLE_SIZE); + + switch(pEntry->state) { + + case DNS_STATE_NEW: { + /* initialize new entry */ + pEntry->state = DNS_STATE_ASKING; + pEntry->numdns = 0; + pEntry->tmr = 1; + pEntry->retries = 0; + + /* send DNS packet for this entry */ + err = dns_send(pEntry->numdns, pEntry->name, i); + if (err != ERR_OK) { + LWIP_DEBUGF(DNS_DEBUG | LWIP_DBG_LEVEL_WARNING, + ("dns_send returned error: %s\n", lwip_strerr(err))); + } + break; + } + + case DNS_STATE_ASKING: { + if (--pEntry->tmr == 0) { + if (++pEntry->retries == DNS_MAX_RETRIES) { + if ((pEntry->numdns+1numdns+1])) { + /* change of server */ + pEntry->numdns++; + pEntry->tmr = 1; + pEntry->retries = 0; + break; + } else { + LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n", pEntry->name)); + /* call specified callback function if provided */ + if (pEntry->found) + (*pEntry->found)(pEntry->name, NULL, pEntry->arg); + /* flush this entry */ + pEntry->state = DNS_STATE_UNUSED; + pEntry->found = NULL; + break; + } + } + + /* wait longer for the next retry */ + pEntry->tmr = pEntry->retries; + + /* send DNS packet for this entry */ + err = dns_send(pEntry->numdns, pEntry->name, i); + if (err != ERR_OK) { + LWIP_DEBUGF(DNS_DEBUG | LWIP_DBG_LEVEL_WARNING, + ("dns_send returned error: %s\n", lwip_strerr(err))); + } + } + break; + } + + case DNS_STATE_DONE: { + /* if the time to live is nul */ + if (--pEntry->ttl == 0) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name)); + /* flush this entry */ + pEntry->state = DNS_STATE_UNUSED; + pEntry->found = NULL; + } + break; + } + case DNS_STATE_UNUSED: + /* nothing to do */ + break; + default: + LWIP_ASSERT("unknown dns_table entry state:", 0); + break; + } +} + +/** + * Call dns_check_entry for each entry in dns_table - check all entries. + */ +static void +dns_check_entries(void) +{ + u8_t i; + + for (i = 0; i < DNS_TABLE_SIZE; ++i) { + dns_check_entry(i); + } +} + +/** + * Receive input function for DNS response packets arriving for the dns UDP pcb. + * + * @params see udp.h + */ +static void +dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) +{ + u16_t i; + char *pHostname; + struct dns_hdr *hdr; + struct dns_answer ans; + struct dns_table_entry *pEntry; + u16_t nquestions, nanswers; + + LWIP_UNUSED_ARG(arg); + LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(addr); + LWIP_UNUSED_ARG(port); + + /* is the dns message too big ? */ + if (p->tot_len > DNS_MSG_SIZE) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too big\n")); + /* free pbuf and return */ + goto memerr; + } + + /* is the dns message big enough ? */ + if (p->tot_len < (SIZEOF_DNS_HDR + SIZEOF_DNS_QUERY + SIZEOF_DNS_ANSWER)) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too small\n")); + /* free pbuf and return */ + goto memerr; + } + + /* copy dns payload inside static buffer for processing */ + if (pbuf_copy_partial(p, dns_payload, p->tot_len, 0) == p->tot_len) { + /* The ID in the DNS header should be our entry into the name table. */ + hdr = (struct dns_hdr*)dns_payload; + i = htons(hdr->id); + if (i < DNS_TABLE_SIZE) { + pEntry = &dns_table[i]; + if(pEntry->state == DNS_STATE_ASKING) { + /* This entry is now completed. */ + pEntry->state = DNS_STATE_DONE; + pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK; + + /* We only care about the question(s) and the answers. The authrr + and the extrarr are simply discarded. */ + nquestions = htons(hdr->numquestions); + nanswers = htons(hdr->numanswers); + + /* Check for error. If so, call callback to inform. */ + if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (pEntry->err != 0) || (nquestions != 1)) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", pEntry->name)); + /* call callback to indicate error, clean up memory and return */ + goto responseerr; + } + +#if DNS_DOES_NAME_CHECK + /* Check if the name in the "question" part match with the name in the entry. */ + if (dns_compare_name((unsigned char *)(pEntry->name), (unsigned char *)dns_payload + SIZEOF_DNS_HDR) != 0) { + LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", pEntry->name)); + /* call callback to indicate error, clean up memory and return */ + goto responseerr; + } +#endif /* DNS_DOES_NAME_CHECK */ + + /* Skip the name in the "question" part */ + pHostname = (char *) dns_parse_name((unsigned char *)dns_payload + SIZEOF_DNS_HDR) + SIZEOF_DNS_QUERY; + + while (nanswers > 0) { + /* skip answer resource record's host name */ + pHostname = (char *) dns_parse_name((unsigned char *)pHostname); + + /* Check for IP address type and Internet class. Others are discarded. */ + SMEMCPY(&ans, pHostname, SIZEOF_DNS_ANSWER); + if((ans.type == PP_HTONS(DNS_RRTYPE_A)) && (ans.cls == PP_HTONS(DNS_RRCLASS_IN)) && + (ans.len == PP_HTONS(sizeof(ip_addr_t))) ) { + /* read the answer resource record's TTL, and maximize it if needed */ + pEntry->ttl = ntohl(ans.ttl); + if (pEntry->ttl > DNS_MAX_TTL) { + pEntry->ttl = DNS_MAX_TTL; + } + /* read the IP address after answer resource record's header */ + SMEMCPY(&(pEntry->ipaddr), (pHostname+SIZEOF_DNS_ANSWER), sizeof(ip_addr_t)); + LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", pEntry->name)); + ip_addr_debug_print(DNS_DEBUG, (&(pEntry->ipaddr))); + LWIP_DEBUGF(DNS_DEBUG, ("\n")); + /* call specified callback function if provided */ + if (pEntry->found) { + (*pEntry->found)(pEntry->name, &pEntry->ipaddr, pEntry->arg); + } + /* deallocate memory and return */ + goto memerr; + } else { + pHostname = pHostname + SIZEOF_DNS_ANSWER + htons(ans.len); + } + --nanswers; + } + LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", pEntry->name)); + /* call callback to indicate error, clean up memory and return */ + goto responseerr; + } + } + } + + /* deallocate memory and return */ + goto memerr; + +responseerr: + /* ERROR: call specified callback function with NULL as name to indicate an error */ + if (pEntry->found) { + (*pEntry->found)(pEntry->name, NULL, pEntry->arg); + } + /* flush this entry */ + pEntry->state = DNS_STATE_UNUSED; + pEntry->found = NULL; + +memerr: + /* free pbuf */ + pbuf_free(p); + return; +} + +/** + * Queues a new hostname to resolve and sends out a DNS query for that hostname + * + * @param name the hostname that is to be queried + * @param found a callback founction to be called on success, failure or timeout + * @param callback_arg argument to pass to the callback function + * @return @return a err_t return code. + */ +static err_t +dns_enqueue(const char *name, dns_found_callback found, void *callback_arg) +{ + u8_t i; + u8_t lseq, lseqi; + struct dns_table_entry *pEntry = NULL; + size_t namelen; + + /* search an unused entry, or the oldest one */ + lseq = lseqi = 0; + for (i = 0; i < DNS_TABLE_SIZE; ++i) { + pEntry = &dns_table[i]; + /* is it an unused entry ? */ + if (pEntry->state == DNS_STATE_UNUSED) + break; + + /* check if this is the oldest completed entry */ + if (pEntry->state == DNS_STATE_DONE) { + if ((dns_seqno - pEntry->seqno) > lseq) { + lseq = dns_seqno - pEntry->seqno; + lseqi = i; + } + } + } + + /* if we don't have found an unused entry, use the oldest completed one */ + if (i == DNS_TABLE_SIZE) { + if ((lseqi >= DNS_TABLE_SIZE) || (dns_table[lseqi].state != DNS_STATE_DONE)) { + /* no entry can't be used now, table is full */ + LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": DNS entries table is full\n", name)); + return ERR_MEM; + } else { + /* use the oldest completed one */ + i = lseqi; + pEntry = &dns_table[i]; + } + } + + /* use this entry */ + LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": use DNS entry %"U16_F"\n", name, (u16_t)(i))); + + /* fill the entry */ + pEntry->state = DNS_STATE_NEW; + pEntry->seqno = dns_seqno++; + pEntry->found = found; + pEntry->arg = callback_arg; + namelen = LWIP_MIN(strlen(name), DNS_MAX_NAME_LENGTH-1); + MEMCPY(pEntry->name, name, namelen); + pEntry->name[namelen] = 0; + + /* force to send query without waiting timer */ + dns_check_entry(i); + + /* dns query is enqueued */ + return ERR_INPROGRESS; +} + +/** + * Resolve a hostname (string) into an IP address. + * NON-BLOCKING callback version for use with raw API!!! + * + * Returns immediately with one of err_t return codes: + * - ERR_OK if hostname is a valid IP address string or the host + * name is already in the local names table. + * - ERR_INPROGRESS enqueue a request to be sent to the DNS server + * for resolution if no errors are present. + * - ERR_ARG: dns client not initialized or invalid hostname + * + * @param hostname the hostname that is to be queried + * @param addr pointer to a ip_addr_t where to store the address if it is already + * cached in the dns_table (only valid if ERR_OK is returned!) + * @param found a callback function to be called on success, failure or timeout (only if + * ERR_INPROGRESS is returned!) + * @param callback_arg argument to pass to the callback function + * @return a err_t return code. + */ +err_t +dns_gethostbyname(const char *hostname, ip_addr_t *addr, dns_found_callback found, + void *callback_arg) +{ + u32_t ipaddr; + /* not initialized or no valid server yet, or invalid addr pointer + * or invalid hostname or invalid hostname length */ + if ((dns_pcb == NULL) || (addr == NULL) || + (!hostname) || (!hostname[0]) || + (strlen(hostname) >= DNS_MAX_NAME_LENGTH)) { + return ERR_ARG; + } + +#if LWIP_HAVE_LOOPIF + if (strcmp(hostname, "localhost")==0) { + ip_addr_set_loopback(addr); + return ERR_OK; + } +#endif /* LWIP_HAVE_LOOPIF */ + + /* host name already in octet notation? set ip addr and return ERR_OK */ + ipaddr = ipaddr_addr(hostname); + if (ipaddr == IPADDR_NONE) { + /* already have this address cached? */ + ipaddr = dns_lookup(hostname); + } + if (ipaddr != IPADDR_NONE) { + ip4_addr_set_u32(addr, ipaddr); + return ERR_OK; + } + + /* queue query with specified callback */ + return dns_enqueue(hostname, found, callback_arg); +} + +#endif /* LWIP_DNS */ diff --git a/user/mpy/lib/lwip/src/core/init.c b/user/mpy/lib/lwip/src/core/init.c new file mode 100644 index 0000000..a7b15a7 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/init.c @@ -0,0 +1,332 @@ +/** + * @file + * Modules initialization + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/init.h" +#include "lwip/stats.h" +#include "lwip/sys.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/pbuf.h" +#include "lwip/netif.h" +#include "lwip/sockets.h" +#include "lwip/ip.h" +#include "lwip/raw.h" +#include "lwip/udp.h" +#include "lwip/tcp_impl.h" +#include "lwip/snmp_msg.h" +#include "lwip/autoip.h" +#include "lwip/igmp.h" +#include "lwip/dns.h" +#include "lwip/timers.h" +#include "netif/etharp.h" +#include "lwip/api.h" + +/* Compile-time sanity checks for configuration errors. + * These can be done independently of LWIP_DEBUG, without penalty. + */ +#ifndef BYTE_ORDER + #error "BYTE_ORDER is not defined, you have to define it in your cc.h" +#endif +#if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV) + #error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h" +#endif +#if (!LWIP_UDP && LWIP_UDPLITE) + #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif +#if (!LWIP_UDP && LWIP_SNMP) + #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif +#if (!LWIP_UDP && LWIP_DHCP) + #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif +#if (!LWIP_UDP && LWIP_IGMP) + #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif +#if (!LWIP_UDP && LWIP_SNMP) + #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif +#if (!LWIP_UDP && LWIP_DNS) + #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" +#endif +#if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */ +#if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0)) + #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h" +#endif +#if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0)) + #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h" +#endif +#if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0)) + #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h" +#endif +#if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0)) + #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h" +#endif +#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1)) + #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h" +#endif +#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0)) + #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" +#endif +/* There must be sufficient timeouts, taking into account requirements of the subsystems. */ +#if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT)) + #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" +#endif +#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) + #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!" +#endif +#endif /* !MEMP_MEM_MALLOC */ +#if (LWIP_TCP && (TCP_WND > 0xffff)) + #error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h" +#endif +#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff)) + #error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h" +#endif +#if (LWIP_TCP && (TCP_SND_QUEUELEN < 2)) + #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work" +#endif +#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) + #error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h" +#endif +#if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)) + #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" +#endif +#if (LWIP_NETIF_API && (NO_SYS==1)) + #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h" +#endif +#if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1)) + #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h" +#endif +#if (!LWIP_NETCONN && LWIP_SOCKET) + #error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h" +#endif +#if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP) + #error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h" +#endif +#if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK) + #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h" +#endif +#if (!LWIP_ARP && LWIP_AUTOIP) + #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h" +#endif +#if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0)) + #error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h" +#endif +#if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0)) + #error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h" +#endif +#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API))) + #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h" +#endif +#if (MEM_LIBC_MALLOC && MEM_USE_POOLS) + #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h" +#endif +#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) + #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" +#endif +#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) + #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf" +#endif +#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT))) + #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST" +#endif +#if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT + #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on" +#endif +#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) + #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" +#endif +#if LWIP_IGMP && !defined(LWIP_RAND) + #error "When using IGMP, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value" +#endif +#if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING + #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too" +#endif +#if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE + #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets" +#endif +#if IP_FRAG && IP_FRAG_USES_STATIC_BUF && LWIP_NETIF_TX_SINGLE_PBUF + #error "LWIP_NETIF_TX_SINGLE_PBUF does not work with IP_FRAG_USES_STATIC_BUF==1 as that creates pbuf queues" +#endif +#if LWIP_NETCONN && LWIP_TCP +#if NETCONN_COPY != TCP_WRITE_FLAG_COPY + #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY" +#endif +#if NETCONN_MORE != TCP_WRITE_FLAG_MORE + #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" +#endif +#endif /* LWIP_NETCONN && LWIP_TCP */ +#if LWIP_SOCKET +/* Check that the SO_* socket options and SOF_* lwIP-internal flags match */ +#if SO_ACCEPTCONN != SOF_ACCEPTCONN + #error "SO_ACCEPTCONN != SOF_ACCEPTCONN" +#endif +#if SO_REUSEADDR != SOF_REUSEADDR + #error "WARNING: SO_REUSEADDR != SOF_REUSEADDR" +#endif +#if SO_KEEPALIVE != SOF_KEEPALIVE + #error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE" +#endif +#if SO_BROADCAST != SOF_BROADCAST + #error "WARNING: SO_BROADCAST != SOF_BROADCAST" +#endif +#if SO_LINGER != SOF_LINGER + #error "WARNING: SO_LINGER != SOF_LINGER" +#endif +#endif /* LWIP_SOCKET */ + + +/* Compile-time checks for deprecated options. + */ +#ifdef MEMP_NUM_TCPIP_MSG + #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h." +#endif +#ifdef MEMP_NUM_API_MSG + #error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h." +#endif +#ifdef TCP_REXMIT_DEBUG + #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h." +#endif +#ifdef RAW_STATS + #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h." +#endif +#ifdef ETHARP_QUEUE_FIRST + #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h." +#endif +#ifdef ETHARP_ALWAYS_INSERT + #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h." +#endif + +#ifndef LWIP_DISABLE_TCP_SANITY_CHECKS +#define LWIP_DISABLE_TCP_SANITY_CHECKS 0 +#endif +#ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS +#define LWIP_DISABLE_MEMP_SANITY_CHECKS 0 +#endif + +/* MEMP sanity checks */ +#if !LWIP_DISABLE_MEMP_SANITY_CHECKS +#if LWIP_NETCONN +#if MEMP_MEM_MALLOC +#if !MEMP_NUM_NETCONN && LWIP_SOCKET +#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!" +#endif +#else /* MEMP_MEM_MALLOC */ +#if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB) +#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN should be less than the sum of MEMP_NUM_{TCP,RAW,UDP}_PCB+MEMP_NUM_TCP_PCB_LISTEN. If you know what you are doing, define LWIP_DISABLE_MEMP_SANITY_CHECKS to 1 to disable this error." +#endif +#endif /* MEMP_MEM_MALLOC */ +#endif /* LWIP_NETCONN */ +#endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */ + +/* TCP sanity checks */ +#if !LWIP_DISABLE_TCP_SANITY_CHECKS +#if LWIP_TCP +#if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN) + #error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#if TCP_SND_BUF < (2 * TCP_MSS) + #error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS)) + #error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#if TCP_SNDLOWAT >= TCP_SND_BUF + #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN + #error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#if !MEMP_MEM_MALLOC && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)))) + #error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#if TCP_WND < TCP_MSS + #error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." +#endif +#endif /* LWIP_TCP */ +#endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */ + +/** + * Perform Sanity check of user-configurable values, and initialize all modules. + */ +void +lwip_init(void) +{ + /* Modules initialization */ + stats_init(); +#if !NO_SYS + sys_init(); +#endif /* !NO_SYS */ + mem_init(); + memp_init(); + pbuf_init(); + netif_init(); +#if LWIP_SOCKET + lwip_socket_init(); +#endif /* LWIP_SOCKET */ + ip_init(); +#if LWIP_ARP + etharp_init(); +#endif /* LWIP_ARP */ +#if LWIP_RAW + raw_init(); +#endif /* LWIP_RAW */ +#if LWIP_UDP + udp_init(); +#endif /* LWIP_UDP */ +#if LWIP_TCP + tcp_init(); +#endif /* LWIP_TCP */ +#if LWIP_SNMP + snmp_init(); +#endif /* LWIP_SNMP */ +#if LWIP_AUTOIP + autoip_init(); +#endif /* LWIP_AUTOIP */ +#if LWIP_IGMP + igmp_init(); +#endif /* LWIP_IGMP */ +#if LWIP_DNS + dns_init(); +#endif /* LWIP_DNS */ + +#if LWIP_TIMERS + sys_timeouts_init(); +#endif /* LWIP_TIMERS */ +} diff --git a/user/mpy/lib/lwip/src/core/ipv4/autoip.c b/user/mpy/lib/lwip/src/core/ipv4/autoip.c new file mode 100644 index 0000000..b122da2 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/autoip.c @@ -0,0 +1,528 @@ +/** + * @file + * AutoIP Automatic LinkLocal IP Configuration + * + */ + +/* + * + * Copyright (c) 2007 Dominik Spies + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Dominik Spies + * + * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform + * with RFC 3927. + * + * + * Please coordinate changes and requests with Dominik Spies + * + */ + +/******************************************************************************* + * USAGE: + * + * define LWIP_AUTOIP 1 in your lwipopts.h + * + * If you don't use tcpip.c (so, don't call, you don't call tcpip_init): + * - First, call autoip_init(). + * - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces, + * that should be defined in autoip.h. + * I recommend a value of 100. The value must divide 1000 with a remainder almost 0. + * Possible values are 1000, 500, 333, 250, 200, 166, 142, 125, 111, 100 .... + * + * Without DHCP: + * - Call autoip_start() after netif_add(). + * + * With DHCP: + * - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h. + * - Configure your DHCP Client. + * + */ + +#include "lwip/opt.h" + +#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/mem.h" +#include "lwip/udp.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/autoip.h" +#include "netif/etharp.h" + +#include +#include + +/* 169.254.0.0 */ +#define AUTOIP_NET 0xA9FE0000 +/* 169.254.1.0 */ +#define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) +/* 169.254.254.255 */ +#define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) + + +/** Pseudo random macro based on netif informations. + * You could use "rand()" from the C Library if you define LWIP_AUTOIP_RAND in lwipopts.h */ +#ifndef LWIP_AUTOIP_RAND +#define LWIP_AUTOIP_RAND(netif) ( (((u32_t)((netif->hwaddr[5]) & 0xff) << 24) | \ + ((u32_t)((netif->hwaddr[3]) & 0xff) << 16) | \ + ((u32_t)((netif->hwaddr[2]) & 0xff) << 8) | \ + ((u32_t)((netif->hwaddr[4]) & 0xff))) + \ + (netif->autoip?netif->autoip->tried_llipaddr:0)) +#endif /* LWIP_AUTOIP_RAND */ + +/** + * Macro that generates the initial IP address to be tried by AUTOIP. + * If you want to override this, define it to something else in lwipopts.h. + */ +#ifndef LWIP_AUTOIP_CREATE_SEED_ADDR +#define LWIP_AUTOIP_CREATE_SEED_ADDR(netif) \ + htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \ + ((u32_t)((u8_t)(netif->hwaddr[5]))) << 8))) +#endif /* LWIP_AUTOIP_CREATE_SEED_ADDR */ + +/* static functions */ +static void autoip_handle_arp_conflict(struct netif *netif); + +/* creates a pseudo random LL IP-Address for a network interface */ +static void autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr); + +/* sends an ARP probe */ +static err_t autoip_arp_probe(struct netif *netif); + +/* sends an ARP announce */ +static err_t autoip_arp_announce(struct netif *netif); + +/* configure interface for use with current LL IP-Address */ +static err_t autoip_bind(struct netif *netif); + +/* start sending probes for llipaddr */ +static void autoip_start_probing(struct netif *netif); + + +/** Set a statically allocated struct autoip to work with. + * Using this prevents autoip_start to allocate it using mem_malloc. + * + * @param netif the netif for which to set the struct autoip + * @param dhcp (uninitialised) dhcp struct allocated by the application + */ +void +autoip_set_struct(struct netif *netif, struct autoip *autoip) +{ + LWIP_ASSERT("netif != NULL", netif != NULL); + LWIP_ASSERT("autoip != NULL", autoip != NULL); + LWIP_ASSERT("netif already has a struct autoip set", netif->autoip == NULL); + + /* clear data structure */ + memset(autoip, 0, sizeof(struct autoip)); + /* autoip->state = AUTOIP_STATE_OFF; */ + netif->autoip = autoip; +} + +/** Restart AutoIP client and check the next address (conflict detected) + * + * @param netif The netif under AutoIP control + */ +static void +autoip_restart(struct netif *netif) +{ + netif->autoip->tried_llipaddr++; + autoip_start(netif); +} + +/** + * Handle a IP address conflict after an ARP conflict detection + */ +static void +autoip_handle_arp_conflict(struct netif *netif) +{ + /* Somehow detect if we are defending or retreating */ + unsigned char defend = 1; /* tbd */ + + if (defend) { + if (netif->autoip->lastconflict > 0) { + /* retreat, there was a conflicting ARP in the last + * DEFEND_INTERVAL seconds + */ + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_handle_arp_conflict(): we are defending, but in DEFEND_INTERVAL, retreating\n")); + + /* TODO: close all TCP sessions */ + autoip_restart(netif); + } else { + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_handle_arp_conflict(): we are defend, send ARP Announce\n")); + autoip_arp_announce(netif); + netif->autoip->lastconflict = DEFEND_INTERVAL * AUTOIP_TICKS_PER_SECOND; + } + } else { + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_handle_arp_conflict(): we do not defend, retreating\n")); + /* TODO: close all TCP sessions */ + autoip_restart(netif); + } +} + +/** + * Create an IP-Address out of range 169.254.1.0 to 169.254.254.255 + * + * @param netif network interface on which create the IP-Address + * @param ipaddr ip address to initialize + */ +static void +autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr) +{ + /* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255 + * compliant to RFC 3927 Section 2.1 + * We have 254 * 256 possibilities */ + + u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif)); + addr += netif->autoip->tried_llipaddr; + addr = AUTOIP_NET | (addr & 0xffff); + /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */ + + if (addr < AUTOIP_RANGE_START) { + addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1; + } + if (addr > AUTOIP_RANGE_END) { + addr -= AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1; + } + LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) && + (addr <= AUTOIP_RANGE_END)); + ip4_addr_set_u32(ipaddr, htonl(addr)); + + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + (u16_t)(netif->autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), + ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr))); +} + +/** + * Sends an ARP probe from a network interface + * + * @param netif network interface used to send the probe + */ +static err_t +autoip_arp_probe(struct netif *netif) +{ + return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast, + (struct eth_addr *)netif->hwaddr, IP_ADDR_ANY, ðzero, + &netif->autoip->llipaddr, ARP_REQUEST); +} + +/** + * Sends an ARP announce from a network interface + * + * @param netif network interface used to send the announce + */ +static err_t +autoip_arp_announce(struct netif *netif) +{ + return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast, + (struct eth_addr *)netif->hwaddr, &netif->autoip->llipaddr, ðzero, + &netif->autoip->llipaddr, ARP_REQUEST); +} + +/** + * Configure interface for use with current LL IP-Address + * + * @param netif network interface to configure with current LL IP-Address + */ +static err_t +autoip_bind(struct netif *netif) +{ + struct autoip *autoip = netif->autoip; + ip_addr_t sn_mask, gw_addr; + + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, + ("autoip_bind(netif=%p) %c%c%"U16_F" %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num, + ip4_addr1_16(&autoip->llipaddr), ip4_addr2_16(&autoip->llipaddr), + ip4_addr3_16(&autoip->llipaddr), ip4_addr4_16(&autoip->llipaddr))); + + IP4_ADDR(&sn_mask, 255, 255, 0, 0); + IP4_ADDR(&gw_addr, 0, 0, 0, 0); + + netif_set_ipaddr(netif, &autoip->llipaddr); + netif_set_netmask(netif, &sn_mask); + netif_set_gw(netif, &gw_addr); + + /* bring the interface up */ + netif_set_up(netif); + + return ERR_OK; +} + +/** + * Start AutoIP client + * + * @param netif network interface on which start the AutoIP client + */ +err_t +autoip_start(struct netif *netif) +{ + struct autoip *autoip = netif->autoip; + err_t result = ERR_OK; + + if (netif_is_up(netif)) { + netif_set_down(netif); + } + + /* Set IP-Address, Netmask and Gateway to 0 to make sure that + * ARP Packets are formed correctly + */ + ip_addr_set_zero(&netif->ip_addr); + ip_addr_set_zero(&netif->netmask); + ip_addr_set_zero(&netif->gw); + + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], + netif->name[1], (u16_t)netif->num)); + if (autoip == NULL) { + /* no AutoIP client attached yet? */ + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, + ("autoip_start(): starting new AUTOIP client\n")); + autoip = (struct autoip *)mem_malloc(sizeof(struct autoip)); + if (autoip == NULL) { + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, + ("autoip_start(): could not allocate autoip\n")); + return ERR_MEM; + } + memset(autoip, 0, sizeof(struct autoip)); + /* store this AutoIP client in the netif */ + netif->autoip = autoip; + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip")); + } else { + autoip->state = AUTOIP_STATE_OFF; + autoip->ttw = 0; + autoip->sent_num = 0; + ip_addr_set_zero(&autoip->llipaddr); + autoip->lastconflict = 0; + } + + autoip_create_addr(netif, &(autoip->llipaddr)); + autoip_start_probing(netif); + + return result; +} + +static void +autoip_start_probing(struct netif *netif) +{ + struct autoip *autoip = netif->autoip; + + autoip->state = AUTOIP_STATE_PROBING; + autoip->sent_num = 0; + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_start_probing(): changing state to PROBING: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr), + ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr))); + + /* time to wait to first probe, this is randomly + * choosen out of 0 to PROBE_WAIT seconds. + * compliant to RFC 3927 Section 2.2.1 + */ + autoip->ttw = (u16_t)(LWIP_AUTOIP_RAND(netif) % (PROBE_WAIT * AUTOIP_TICKS_PER_SECOND)); + + /* + * if we tried more then MAX_CONFLICTS we must limit our rate for + * accquiring and probing address + * compliant to RFC 3927 Section 2.2.1 + */ + if (autoip->tried_llipaddr > MAX_CONFLICTS) { + autoip->ttw = RATE_LIMIT_INTERVAL * AUTOIP_TICKS_PER_SECOND; + } +} + +/** + * Handle a possible change in the network configuration. + * + * If there is an AutoIP address configured, take the interface down + * and begin probing with the same address. + */ +void +autoip_network_changed(struct netif *netif) +{ + if (netif->autoip && netif->autoip->state != AUTOIP_STATE_OFF) { + netif_set_down(netif); + autoip_start_probing(netif); + } +} + +/** + * Stop AutoIP client + * + * @param netif network interface on which stop the AutoIP client + */ +err_t +autoip_stop(struct netif *netif) +{ + netif->autoip->state = AUTOIP_STATE_OFF; + netif_set_down(netif); + return ERR_OK; +} + +/** + * Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds + */ +void +autoip_tmr() +{ + struct netif *netif = netif_list; + /* loop through netif's */ + while (netif != NULL) { + /* only act on AutoIP configured interfaces */ + if (netif->autoip != NULL) { + if (netif->autoip->lastconflict > 0) { + netif->autoip->lastconflict--; + } + + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, + ("autoip_tmr() AutoIP-State: %"U16_F", ttw=%"U16_F"\n", + (u16_t)(netif->autoip->state), netif->autoip->ttw)); + + switch(netif->autoip->state) { + case AUTOIP_STATE_PROBING: + if (netif->autoip->ttw > 0) { + netif->autoip->ttw--; + } else { + if (netif->autoip->sent_num >= PROBE_NUM) { + netif->autoip->state = AUTOIP_STATE_ANNOUNCING; + netif->autoip->sent_num = 0; + netif->autoip->ttw = ANNOUNCE_WAIT * AUTOIP_TICKS_PER_SECOND; + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_tmr(): changing state to ANNOUNCING: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr), + ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr))); + } else { + autoip_arp_probe(netif); + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, + ("autoip_tmr() PROBING Sent Probe\n")); + netif->autoip->sent_num++; + /* calculate time to wait to next probe */ + netif->autoip->ttw = (u16_t)((LWIP_AUTOIP_RAND(netif) % + ((PROBE_MAX - PROBE_MIN) * AUTOIP_TICKS_PER_SECOND) ) + + PROBE_MIN * AUTOIP_TICKS_PER_SECOND); + } + } + break; + + case AUTOIP_STATE_ANNOUNCING: + if (netif->autoip->ttw > 0) { + netif->autoip->ttw--; + } else { + if (netif->autoip->sent_num == 0) { + /* We are here the first time, so we waited ANNOUNCE_WAIT seconds + * Now we can bind to an IP address and use it. + * + * autoip_bind calls netif_set_up. This triggers a gratuitous ARP + * which counts as an announcement. + */ + autoip_bind(netif); + } else { + autoip_arp_announce(netif); + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, + ("autoip_tmr() ANNOUNCING Sent Announce\n")); + } + netif->autoip->ttw = ANNOUNCE_INTERVAL * AUTOIP_TICKS_PER_SECOND; + netif->autoip->sent_num++; + + if (netif->autoip->sent_num >= ANNOUNCE_NUM) { + netif->autoip->state = AUTOIP_STATE_BOUND; + netif->autoip->sent_num = 0; + netif->autoip->ttw = 0; + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("autoip_tmr(): changing state to BOUND: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr), + ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr))); + } + } + break; + } + } + /* proceed to next network interface */ + netif = netif->next; + } +} + +/** + * Handles every incoming ARP Packet, called by etharp_arp_input. + * + * @param netif network interface to use for autoip processing + * @param hdr Incoming ARP packet + */ +void +autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr) +{ + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_arp_reply()\n")); + if ((netif->autoip != NULL) && (netif->autoip->state != AUTOIP_STATE_OFF)) { + /* when ip.src == llipaddr && hw.src != netif->hwaddr + * + * when probing ip.dst == llipaddr && hw.src != netif->hwaddr + * we have a conflict and must solve it + */ + ip_addr_t sipaddr, dipaddr; + struct eth_addr netifaddr; + ETHADDR16_COPY(netifaddr.addr, netif->hwaddr); + + /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without + * structure packing (not using structure copy which breaks strict-aliasing rules). + */ + IPADDR2_COPY(&sipaddr, &hdr->sipaddr); + IPADDR2_COPY(&dipaddr, &hdr->dipaddr); + + if ((netif->autoip->state == AUTOIP_STATE_PROBING) || + ((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) && + (netif->autoip->sent_num == 0))) { + /* RFC 3927 Section 2.2.1: + * from beginning to after ANNOUNCE_WAIT + * seconds we have a conflict if + * ip.src == llipaddr OR + * ip.dst == llipaddr && hw.src != own hwaddr + */ + if ((ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr)) || + (ip_addr_cmp(&dipaddr, &netif->autoip->llipaddr) && + !eth_addr_cmp(&netifaddr, &hdr->shwaddr))) { + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, + ("autoip_arp_reply(): Probe Conflict detected\n")); + autoip_restart(netif); + } + } else { + /* RFC 3927 Section 2.5: + * in any state we have a conflict if + * ip.src == llipaddr && hw.src != own hwaddr + */ + if (ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr) && + !eth_addr_cmp(&netifaddr, &hdr->shwaddr)) { + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, + ("autoip_arp_reply(): Conflicting ARP-Packet detected\n")); + autoip_handle_arp_conflict(netif); + } + } + } +} + +#endif /* LWIP_AUTOIP */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/icmp.c b/user/mpy/lib/lwip/src/core/ipv4/icmp.c new file mode 100644 index 0000000..47ba857 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/icmp.c @@ -0,0 +1,339 @@ +/** + * @file + * ICMP - Internet Control Message Protocol + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +/* Some ICMP messages should be passed to the transport protocols. This + is not implemented. */ + +#include "lwip/opt.h" + +#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/icmp.h" +#include "lwip/inet_chksum.h" +#include "lwip/ip.h" +#include "lwip/def.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" + +#include + +/** Small optimization: set to 0 if incoming PBUF_POOL pbuf always can be + * used to modify and send a response packet (and to 1 if this is not the case, + * e.g. when link header is stripped of when receiving) */ +#ifndef LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN +#define LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN 1 +#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ + +/* The amount of data from the original packet to return in a dest-unreachable */ +#define ICMP_DEST_UNREACH_DATASIZE 8 + +static void icmp_send_response(struct pbuf *p, u8_t type, u8_t code); + +/** + * Processes ICMP input packets, called from ip_input(). + * + * Currently only processes icmp echo requests and sends + * out the echo response. + * + * @param p the icmp echo request packet, p->payload pointing to the ip header + * @param inp the netif on which this packet was received + */ +void +icmp_input(struct pbuf *p, struct netif *inp) +{ + u8_t type; +#ifdef LWIP_DEBUG + u8_t code; +#endif /* LWIP_DEBUG */ + struct icmp_echo_hdr *iecho; + struct ip_hdr *iphdr; + s16_t hlen; + + ICMP_STATS_INC(icmp.recv); + snmp_inc_icmpinmsgs(); + + + iphdr = (struct ip_hdr *)p->payload; + hlen = IPH_HL(iphdr) * 4; + if (pbuf_header(p, -hlen) || (p->tot_len < sizeof(u16_t)*2)) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len)); + goto lenerr; + } + + type = *((u8_t *)p->payload); +#ifdef LWIP_DEBUG + code = *(((u8_t *)p->payload)+1); +#endif /* LWIP_DEBUG */ + switch (type) { + case ICMP_ER: + /* This is OK, echo reply might have been parsed by a raw PCB + (as obviously, an echo request has been sent, too). */ + break; + case ICMP_ECHO: +#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING + { + int accepted = 1; +#if !LWIP_MULTICAST_PING + /* multicast destination address? */ + if (ip_addr_ismulticast(¤t_iphdr_dest)) { + accepted = 0; + } +#endif /* LWIP_MULTICAST_PING */ +#if !LWIP_BROADCAST_PING + /* broadcast destination address? */ + if (ip_addr_isbroadcast(¤t_iphdr_dest, inp)) { + accepted = 0; + } +#endif /* LWIP_BROADCAST_PING */ + /* broadcast or multicast destination address not acceptd? */ + if (!accepted) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n")); + ICMP_STATS_INC(icmp.err); + pbuf_free(p); + return; + } + } +#endif /* !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */ + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); + if (p->tot_len < sizeof(struct icmp_echo_hdr)) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); + goto lenerr; + } + if (inet_chksum_pbuf(p) != 0) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); + pbuf_free(p); + ICMP_STATS_INC(icmp.chkerr); + snmp_inc_icmpinerrors(); + return; + } +#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN + if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) { + /* p is not big enough to contain link headers + * allocate a new one and copy p into it + */ + struct pbuf *r; + /* switch p->payload to ip header */ + if (pbuf_header(p, hlen)) { + LWIP_ASSERT("icmp_input: moving p->payload to ip header failed\n", 0); + goto memerr; + } + /* allocate new packet buffer with space for link headers */ + r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); + if (r == NULL) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: allocating new pbuf failed\n")); + goto memerr; + } + LWIP_ASSERT("check that first pbuf can hold struct the ICMP header", + (r->len >= hlen + sizeof(struct icmp_echo_hdr))); + /* copy the whole packet including ip header */ + if (pbuf_copy(r, p) != ERR_OK) { + LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0); + goto memerr; + } + iphdr = (struct ip_hdr *)r->payload; + /* switch r->payload back to icmp header */ + if (pbuf_header(r, -hlen)) { + LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0); + goto memerr; + } + /* free the original p */ + pbuf_free(p); + /* we now have an identical copy of p that has room for link headers */ + p = r; + } else { + /* restore p->payload to point to icmp header */ + if (pbuf_header(p, -(s16_t)(PBUF_IP_HLEN + PBUF_LINK_HLEN))) { + LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0); + goto memerr; + } + } +#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ + /* At this point, all checks are OK. */ + /* We generate an answer by switching the dest and src ip addresses, + * setting the icmp type to ECHO_RESPONSE and updating the checksum. */ + iecho = (struct icmp_echo_hdr *)p->payload; + ip_addr_copy(iphdr->src, *ip_current_dest_addr()); + ip_addr_copy(iphdr->dest, *ip_current_src_addr()); + ICMPH_TYPE_SET(iecho, ICMP_ER); +#if CHECKSUM_GEN_ICMP + /* adjust the checksum */ + if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) { + iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1; + } else { + iecho->chksum += PP_HTONS(ICMP_ECHO << 8); + } +#else /* CHECKSUM_GEN_ICMP */ + iecho->chksum = 0; +#endif /* CHECKSUM_GEN_ICMP */ + + /* Set the correct TTL and recalculate the header checksum. */ + IPH_TTL_SET(iphdr, ICMP_TTL); + IPH_CHKSUM_SET(iphdr, 0); +#if CHECKSUM_GEN_IP + IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); +#endif /* CHECKSUM_GEN_IP */ + + ICMP_STATS_INC(icmp.xmit); + /* increase number of messages attempted to send */ + snmp_inc_icmpoutmsgs(); + /* increase number of echo replies attempted to send */ + snmp_inc_icmpoutechoreps(); + + if(pbuf_header(p, hlen)) { + LWIP_ASSERT("Can't move over header in packet", 0); + } else { + err_t ret; + /* send an ICMP packet, src addr is the dest addr of the curren packet */ + ret = ip_output_if(p, ip_current_dest_addr(), IP_HDRINCL, + ICMP_TTL, 0, IP_PROTO_ICMP, inp); + if (ret != ERR_OK) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret)); + } + } + break; + default: + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", + (s16_t)type, (s16_t)code)); + ICMP_STATS_INC(icmp.proterr); + ICMP_STATS_INC(icmp.drop); + } + pbuf_free(p); + return; +lenerr: + pbuf_free(p); + ICMP_STATS_INC(icmp.lenerr); + snmp_inc_icmpinerrors(); + return; +#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN +memerr: + pbuf_free(p); + ICMP_STATS_INC(icmp.err); + snmp_inc_icmpinerrors(); + return; +#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ +} + +/** + * Send an icmp 'destination unreachable' packet, called from ip_input() if + * the transport layer protocol is unknown and from udp_input() if the local + * port is not bound. + * + * @param p the input packet for which the 'unreachable' should be sent, + * p->payload pointing to the IP header + * @param t type of the 'unreachable' packet + */ +void +icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) +{ + icmp_send_response(p, ICMP_DUR, t); +} + +#if IP_FORWARD || IP_REASSEMBLY +/** + * Send a 'time exceeded' packet, called from ip_forward() if TTL is 0. + * + * @param p the input packet for which the 'time exceeded' should be sent, + * p->payload pointing to the IP header + * @param t type of the 'time exceeded' packet + */ +void +icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) +{ + icmp_send_response(p, ICMP_TE, t); +} + +#endif /* IP_FORWARD || IP_REASSEMBLY */ + +/** + * Send an icmp packet in response to an incoming packet. + * + * @param p the input packet for which the 'unreachable' should be sent, + * p->payload pointing to the IP header + * @param type Type of the ICMP header + * @param code Code of the ICMP header + */ +static void +icmp_send_response(struct pbuf *p, u8_t type, u8_t code) +{ + struct pbuf *q; + struct ip_hdr *iphdr; + /* we can use the echo header here */ + struct icmp_echo_hdr *icmphdr; + ip_addr_t iphdr_src; + + /* ICMP header + IP header + 8 bytes of data */ + q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE, + PBUF_RAM); + if (q == NULL) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n")); + return; + } + LWIP_ASSERT("check that first pbuf can hold icmp message", + (q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE))); + + iphdr = (struct ip_hdr *)p->payload; + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); + ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); + LWIP_DEBUGF(ICMP_DEBUG, (" to ")); + ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); + LWIP_DEBUGF(ICMP_DEBUG, ("\n")); + + icmphdr = (struct icmp_echo_hdr *)q->payload; + icmphdr->type = type; + icmphdr->code = code; + icmphdr->id = 0; + icmphdr->seqno = 0; + + /* copy fields from original packet */ + SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); + + /* calculate checksum */ + icmphdr->chksum = 0; + icmphdr->chksum = inet_chksum(icmphdr, q->len); + ICMP_STATS_INC(icmp.xmit); + /* increase number of messages attempted to send */ + snmp_inc_icmpoutmsgs(); + /* increase number of destination unreachable messages attempted to send */ + snmp_inc_icmpouttimeexcds(); + ip_addr_copy(iphdr_src, iphdr->src); + ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP); + pbuf_free(q); +} + +#endif /* LWIP_ICMP */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/igmp.c b/user/mpy/lib/lwip/src/core/ipv4/igmp.c new file mode 100644 index 0000000..45bb5d9 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/igmp.c @@ -0,0 +1,805 @@ +/** + * @file + * IGMP - Internet Group Management Protocol + * + */ + +/* + * Copyright (c) 2002 CITEL Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is a contribution to the lwIP TCP/IP stack. + * The Swedish Institute of Computer Science and Adam Dunkels + * are specifically granted permission to redistribute this + * source code. +*/ + +/*------------------------------------------------------------- +Note 1) +Although the rfc requires V1 AND V2 capability +we will only support v2 since now V1 is very old (August 1989) +V1 can be added if required + +a debug print and statistic have been implemented to +show this up. +------------------------------------------------------------- +------------------------------------------------------------- +Note 2) +A query for a specific group address (as opposed to ALLHOSTS) +has now been implemented as I am unsure if it is required + +a debug print and statistic have been implemented to +show this up. +------------------------------------------------------------- +------------------------------------------------------------- +Note 3) +The router alert rfc 2113 is implemented in outgoing packets +but not checked rigorously incoming +------------------------------------------------------------- +Steve Reynolds +------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------- + * RFC 988 - Host extensions for IP multicasting - V0 + * RFC 1054 - Host extensions for IP multicasting - + * RFC 1112 - Host extensions for IP multicasting - V1 + * RFC 2236 - Internet Group Management Protocol, Version 2 - V2 <- this code is based on this RFC (it's the "de facto" standard) + * RFC 3376 - Internet Group Management Protocol, Version 3 - V3 + * RFC 4604 - Using Internet Group Management Protocol Version 3... - V3+ + * RFC 2113 - IP Router Alert Option - + *----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------- + * Includes + *----------------------------------------------------------------------------*/ + +#include "lwip/opt.h" + +#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/igmp.h" +#include "lwip/debug.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/ip.h" +#include "lwip/inet_chksum.h" +#include "lwip/netif.h" +#include "lwip/icmp.h" +#include "lwip/udp.h" +#include "lwip/tcp.h" +#include "lwip/stats.h" + +#include "string.h" + +/* + * IGMP constants + */ +#define IGMP_TTL 1 +#define IGMP_MINLEN 8 +#define ROUTER_ALERT 0x9404U +#define ROUTER_ALERTLEN 4 + +/* + * IGMP message types, including version number. + */ +#define IGMP_MEMB_QUERY 0x11 /* Membership query */ +#define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */ +#define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */ +#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ + +/* Group membership states */ +#define IGMP_GROUP_NON_MEMBER 0 +#define IGMP_GROUP_DELAYING_MEMBER 1 +#define IGMP_GROUP_IDLE_MEMBER 2 + +/** + * IGMP packet format. + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct igmp_msg { + PACK_STRUCT_FIELD(u8_t igmp_msgtype); + PACK_STRUCT_FIELD(u8_t igmp_maxresp); + PACK_STRUCT_FIELD(u16_t igmp_checksum); + PACK_STRUCT_FIELD(ip_addr_p_t igmp_group_address); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + + +static struct igmp_group *igmp_lookup_group(struct netif *ifp, ip_addr_t *addr); +static err_t igmp_remove_group(struct igmp_group *group); +static void igmp_timeout( struct igmp_group *group); +static void igmp_start_timer(struct igmp_group *group, u8_t max_time); +static void igmp_delaying_member(struct igmp_group *group, u8_t maxresp); +static err_t igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif); +static void igmp_send(struct igmp_group *group, u8_t type); + + +static struct igmp_group* igmp_group_list; +static ip_addr_t allsystems; +static ip_addr_t allrouters; + + +/** + * Initialize the IGMP module + */ +void +igmp_init(void) +{ + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_init: initializing\n")); + + IP4_ADDR(&allsystems, 224, 0, 0, 1); + IP4_ADDR(&allrouters, 224, 0, 0, 2); +} + +#ifdef LWIP_DEBUG +/** + * Dump global IGMP groups list + */ +void +igmp_dump_group_list() +{ + struct igmp_group *group = igmp_group_list; + + while (group != NULL) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_dump_group_list: [%"U32_F"] ", (u32_t)(group->group_state))); + ip_addr_debug_print(IGMP_DEBUG, &group->group_address); + LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif)); + group = group->next; + } + LWIP_DEBUGF(IGMP_DEBUG, ("\n")); +} +#else +#define igmp_dump_group_list() +#endif /* LWIP_DEBUG */ + +/** + * Start IGMP processing on interface + * + * @param netif network interface on which start IGMP processing + */ +err_t +igmp_start(struct netif *netif) +{ + struct igmp_group* group; + + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %p\n", netif)); + + group = igmp_lookup_group(netif, &allsystems); + + if (group != NULL) { + group->group_state = IGMP_GROUP_IDLE_MEMBER; + group->use++; + + /* Allow the igmp messages at the MAC level */ + if (netif->igmp_mac_filter != NULL) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD ")); + ip_addr_debug_print(IGMP_DEBUG, &allsystems); + LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); + netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER); + } + + return ERR_OK; + } + + return ERR_MEM; +} + +/** + * Stop IGMP processing on interface + * + * @param netif network interface on which stop IGMP processing + */ +err_t +igmp_stop(struct netif *netif) +{ + struct igmp_group *group = igmp_group_list; + struct igmp_group *prev = NULL; + struct igmp_group *next; + + /* look for groups joined on this interface further down the list */ + while (group != NULL) { + next = group->next; + /* is it a group joined on this interface? */ + if (group->netif == netif) { + /* is it the first group of the list? */ + if (group == igmp_group_list) { + igmp_group_list = next; + } + /* is there a "previous" group defined? */ + if (prev != NULL) { + prev->next = next; + } + /* disable the group at the MAC level */ + if (netif->igmp_mac_filter != NULL) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL ")); + ip_addr_debug_print(IGMP_DEBUG, &group->group_address); + LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); + netif->igmp_mac_filter(netif, &(group->group_address), IGMP_DEL_MAC_FILTER); + } + /* free group */ + memp_free(MEMP_IGMP_GROUP, group); + } else { + /* change the "previous" */ + prev = group; + } + /* move to "next" */ + group = next; + } + return ERR_OK; +} + +/** + * Report IGMP memberships for this interface + * + * @param netif network interface on which report IGMP memberships + */ +void +igmp_report_groups(struct netif *netif) +{ + struct igmp_group *group = igmp_group_list; + + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", netif)); + + while (group != NULL) { + if (group->netif == netif) { + igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR); + } + group = group->next; + } +} + +/** + * Search for a group in the global igmp_group_list + * + * @param ifp the network interface for which to look + * @param addr the group ip address to search for + * @return a struct igmp_group* if the group has been found, + * NULL if the group wasn't found. + */ +struct igmp_group * +igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr) +{ + struct igmp_group *group = igmp_group_list; + + while (group != NULL) { + if ((group->netif == ifp) && (ip_addr_cmp(&(group->group_address), addr))) { + return group; + } + group = group->next; + } + + /* to be clearer, we return NULL here instead of + * 'group' (which is also NULL at this point). + */ + return NULL; +} + +/** + * Search for a specific igmp group and create a new one if not found- + * + * @param ifp the network interface for which to look + * @param addr the group ip address to search + * @return a struct igmp_group*, + * NULL on memory error. + */ +struct igmp_group * +igmp_lookup_group(struct netif *ifp, ip_addr_t *addr) +{ + struct igmp_group *group = igmp_group_list; + + /* Search if the group already exists */ + group = igmp_lookfor_group(ifp, addr); + if (group != NULL) { + /* Group already exists. */ + return group; + } + + /* Group doesn't exist yet, create a new one */ + group = (struct igmp_group *)memp_malloc(MEMP_IGMP_GROUP); + if (group != NULL) { + group->netif = ifp; + ip_addr_set(&(group->group_address), addr); + group->timer = 0; /* Not running */ + group->group_state = IGMP_GROUP_NON_MEMBER; + group->last_reporter_flag = 0; + group->use = 0; + group->next = igmp_group_list; + + igmp_group_list = group; + } + + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: %sallocated a new group with address ", (group?"":"impossible to "))); + ip_addr_debug_print(IGMP_DEBUG, addr); + LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", ifp)); + + return group; +} + +/** + * Remove a group in the global igmp_group_list + * + * @param group the group to remove from the global igmp_group_list + * @return ERR_OK if group was removed from the list, an err_t otherwise + */ +static err_t +igmp_remove_group(struct igmp_group *group) +{ + err_t err = ERR_OK; + + /* Is it the first group? */ + if (igmp_group_list == group) { + igmp_group_list = group->next; + } else { + /* look for group further down the list */ + struct igmp_group *tmpGroup; + for (tmpGroup = igmp_group_list; tmpGroup != NULL; tmpGroup = tmpGroup->next) { + if (tmpGroup->next == group) { + tmpGroup->next = group->next; + break; + } + } + /* Group not found in the global igmp_group_list */ + if (tmpGroup == NULL) + err = ERR_ARG; + } + /* free group */ + memp_free(MEMP_IGMP_GROUP, group); + + return err; +} + +/** + * Called from ip_input() if a new IGMP packet is received. + * + * @param p received igmp packet, p->payload pointing to the ip header + * @param inp network interface on which the packet was received + * @param dest destination ip address of the igmp packet + */ +void +igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) +{ + struct ip_hdr * iphdr; + struct igmp_msg* igmp; + struct igmp_group* group; + struct igmp_group* groupref; + + IGMP_STATS_INC(igmp.recv); + + /* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */ + iphdr = (struct ip_hdr *)p->payload; + if (pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4)) || (p->len < IGMP_MINLEN)) { + pbuf_free(p); + IGMP_STATS_INC(igmp.lenerr); + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: length error\n")); + return; + } + + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: message from ")); + ip_addr_debug_print(IGMP_DEBUG, &(iphdr->src)); + LWIP_DEBUGF(IGMP_DEBUG, (" to address ")); + ip_addr_debug_print(IGMP_DEBUG, &(iphdr->dest)); + LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", inp)); + + /* Now calculate and check the checksum */ + igmp = (struct igmp_msg *)p->payload; + if (inet_chksum(igmp, p->len)) { + pbuf_free(p); + IGMP_STATS_INC(igmp.chkerr); + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: checksum error\n")); + return; + } + + /* Packet is ok so find an existing group */ + group = igmp_lookfor_group(inp, dest); /* use the destination IP address of incoming packet */ + + /* If group can be found or create... */ + if (!group) { + pbuf_free(p); + IGMP_STATS_INC(igmp.drop); + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP frame not for us\n")); + return; + } + + /* NOW ACT ON THE INCOMING MESSAGE TYPE... */ + switch (igmp->igmp_msgtype) { + case IGMP_MEMB_QUERY: { + /* IGMP_MEMB_QUERY to the "all systems" address ? */ + if ((ip_addr_cmp(dest, &allsystems)) && ip_addr_isany(&igmp->igmp_group_address)) { + /* THIS IS THE GENERAL QUERY */ + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: General IGMP_MEMB_QUERY on \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); + + if (igmp->igmp_maxresp == 0) { + IGMP_STATS_INC(igmp.rx_v1); + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: got an all hosts query with time== 0 - this is V1 and not implemented - treat as v2\n")); + igmp->igmp_maxresp = IGMP_V1_DELAYING_MEMBER_TMR; + } else { + IGMP_STATS_INC(igmp.rx_general); + } + + groupref = igmp_group_list; + while (groupref) { + /* Do not send messages on the all systems group address! */ + if ((groupref->netif == inp) && (!(ip_addr_cmp(&(groupref->group_address), &allsystems)))) { + igmp_delaying_member(groupref, igmp->igmp_maxresp); + } + groupref = groupref->next; + } + } else { + /* IGMP_MEMB_QUERY to a specific group ? */ + if (!ip_addr_isany(&igmp->igmp_group_address)) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group ")); + ip_addr_debug_print(IGMP_DEBUG, &igmp->igmp_group_address); + if (ip_addr_cmp(dest, &allsystems)) { + ip_addr_t groupaddr; + LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); + /* we first need to re-look for the group since we used dest last time */ + ip_addr_copy(groupaddr, igmp->igmp_group_address); + group = igmp_lookfor_group(inp, &groupaddr); + } else { + LWIP_DEBUGF(IGMP_DEBUG, (" with the group address as destination [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); + } + + if (group != NULL) { + IGMP_STATS_INC(igmp.rx_group); + igmp_delaying_member(group, igmp->igmp_maxresp); + } else { + IGMP_STATS_INC(igmp.drop); + } + } else { + IGMP_STATS_INC(igmp.proterr); + } + } + break; + } + case IGMP_V2_MEMB_REPORT: { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_V2_MEMB_REPORT\n")); + IGMP_STATS_INC(igmp.rx_report); + if (group->group_state == IGMP_GROUP_DELAYING_MEMBER) { + /* This is on a specific group we have already looked up */ + group->timer = 0; /* stopped */ + group->group_state = IGMP_GROUP_IDLE_MEMBER; + group->last_reporter_flag = 0; + } + break; + } + default: { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: unexpected msg %d in state %d on group %p on if %p\n", + igmp->igmp_msgtype, group->group_state, &group, group->netif)); + IGMP_STATS_INC(igmp.proterr); + break; + } + } + + pbuf_free(p); + return; +} + +/** + * Join a group on one network interface. + * + * @param ifaddr ip address of the network interface which should join a new group + * @param groupaddr the ip address of the group which to join + * @return ERR_OK if group was joined on the netif(s), an err_t otherwise + */ +err_t +igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) +{ + err_t err = ERR_VAL; /* no matching interface */ + struct igmp_group *group; + struct netif *netif; + + /* make sure it is multicast address */ + LWIP_ERROR("igmp_joingroup: attempt to join non-multicast address", ip_addr_ismulticast(groupaddr), return ERR_VAL;); + LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); + + /* loop through netif's */ + netif = netif_list; + while (netif != NULL) { + /* Should we join this interface ? */ + if ((netif->flags & NETIF_FLAG_IGMP) && ((ip_addr_isany(ifaddr) || ip_addr_cmp(&(netif->ip_addr), ifaddr)))) { + /* find group or create a new one if not found */ + group = igmp_lookup_group(netif, groupaddr); + + if (group != NULL) { + /* This should create a new group, check the state to make sure */ + if (group->group_state != IGMP_GROUP_NON_MEMBER) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: join to group not in state IGMP_GROUP_NON_MEMBER\n")); + } else { + /* OK - it was new group */ + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: join to new group: ")); + ip_addr_debug_print(IGMP_DEBUG, groupaddr); + LWIP_DEBUGF(IGMP_DEBUG, ("\n")); + + /* If first use of the group, allow the group at the MAC level */ + if ((group->use==0) && (netif->igmp_mac_filter != NULL)) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: igmp_mac_filter(ADD ")); + ip_addr_debug_print(IGMP_DEBUG, groupaddr); + LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); + netif->igmp_mac_filter(netif, groupaddr, IGMP_ADD_MAC_FILTER); + } + + IGMP_STATS_INC(igmp.tx_join); + igmp_send(group, IGMP_V2_MEMB_REPORT); + + igmp_start_timer(group, IGMP_JOIN_DELAYING_MEMBER_TMR); + + /* Need to work out where this timer comes from */ + group->group_state = IGMP_GROUP_DELAYING_MEMBER; + } + /* Increment group use */ + group->use++; + /* Join on this interface */ + err = ERR_OK; + } else { + /* Return an error even if some network interfaces are joined */ + /** @todo undo any other netif already joined */ + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: Not enought memory to join to group\n")); + return ERR_MEM; + } + } + /* proceed to next network interface */ + netif = netif->next; + } + + return err; +} + +/** + * Leave a group on one network interface. + * + * @param ifaddr ip address of the network interface which should leave a group + * @param groupaddr the ip address of the group which to leave + * @return ERR_OK if group was left on the netif(s), an err_t otherwise + */ +err_t +igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) +{ + err_t err = ERR_VAL; /* no matching interface */ + struct igmp_group *group; + struct netif *netif; + + /* make sure it is multicast address */ + LWIP_ERROR("igmp_leavegroup: attempt to leave non-multicast address", ip_addr_ismulticast(groupaddr), return ERR_VAL;); + LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); + + /* loop through netif's */ + netif = netif_list; + while (netif != NULL) { + /* Should we leave this interface ? */ + if ((netif->flags & NETIF_FLAG_IGMP) && ((ip_addr_isany(ifaddr) || ip_addr_cmp(&(netif->ip_addr), ifaddr)))) { + /* find group */ + group = igmp_lookfor_group(netif, groupaddr); + + if (group != NULL) { + /* Only send a leave if the flag is set according to the state diagram */ + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: Leaving group: ")); + ip_addr_debug_print(IGMP_DEBUG, groupaddr); + LWIP_DEBUGF(IGMP_DEBUG, ("\n")); + + /* If there is no other use of the group */ + if (group->use <= 1) { + /* If we are the last reporter for this group */ + if (group->last_reporter_flag) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: sending leaving group\n")); + IGMP_STATS_INC(igmp.tx_leave); + igmp_send(group, IGMP_LEAVE_GROUP); + } + + /* Disable the group at the MAC level */ + if (netif->igmp_mac_filter != NULL) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL ")); + ip_addr_debug_print(IGMP_DEBUG, groupaddr); + LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); + netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER); + } + + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: remove group: ")); + ip_addr_debug_print(IGMP_DEBUG, groupaddr); + LWIP_DEBUGF(IGMP_DEBUG, ("\n")); + + /* Free the group */ + igmp_remove_group(group); + } else { + /* Decrement group use */ + group->use--; + } + /* Leave on this interface */ + err = ERR_OK; + } else { + /* It's not a fatal error on "leavegroup" */ + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: not member of group\n")); + } + } + /* proceed to next network interface */ + netif = netif->next; + } + + return err; +} + +/** + * The igmp timer function (both for NO_SYS=1 and =0) + * Should be called every IGMP_TMR_INTERVAL milliseconds (100 ms is default). + */ +void +igmp_tmr(void) +{ + struct igmp_group *group = igmp_group_list; + + while (group != NULL) { + if (group->timer > 0) { + group->timer--; + if (group->timer == 0) { + igmp_timeout(group); + } + } + group = group->next; + } +} + +/** + * Called if a timeout for one group is reached. + * Sends a report for this group. + * + * @param group an igmp_group for which a timeout is reached + */ +static void +igmp_timeout(struct igmp_group *group) +{ + /* If the state is IGMP_GROUP_DELAYING_MEMBER then we send a report for this group */ + if (group->group_state == IGMP_GROUP_DELAYING_MEMBER) { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address ")); + ip_addr_debug_print(IGMP_DEBUG, &(group->group_address)); + LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif)); + + IGMP_STATS_INC(igmp.tx_report); + igmp_send(group, IGMP_V2_MEMB_REPORT); + } +} + +/** + * Start a timer for an igmp group + * + * @param group the igmp_group for which to start a timer + * @param max_time the time in multiples of IGMP_TMR_INTERVAL (decrease with + * every call to igmp_tmr()) + */ +static void +igmp_start_timer(struct igmp_group *group, u8_t max_time) +{ + /* ensure the input value is > 0 */ + if (max_time == 0) { + max_time = 1; + } + /* ensure the random value is > 0 */ + group->timer = (LWIP_RAND() % (max_time - 1)) + 1; +} + +/** + * Delaying membership report for a group if necessary + * + * @param group the igmp_group for which "delaying" membership report + * @param maxresp query delay + */ +static void +igmp_delaying_member(struct igmp_group *group, u8_t maxresp) +{ + if ((group->group_state == IGMP_GROUP_IDLE_MEMBER) || + ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) && + ((group->timer == 0) || (maxresp < group->timer)))) { + igmp_start_timer(group, maxresp); + group->group_state = IGMP_GROUP_DELAYING_MEMBER; + } +} + + +/** + * Sends an IP packet on a network interface. This function constructs the IP header + * and calculates the IP header checksum. If the source IP address is NULL, + * the IP address of the outgoing network interface is filled in as source address. + * + * @param p the packet to send (p->payload points to the data, e.g. next + protocol header; if dest == IP_HDRINCL, p already includes an IP + header and p->payload points to that IP header) + * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * IP address of the netif used to send is used as source address) + * @param dest the destination IP address to send the packet to + * @param ttl the TTL value to be set in the IP header + * @param proto the PROTOCOL to be set in the IP header + * @param netif the netif on which to send this packet + * @return ERR_OK if the packet was sent OK + * ERR_BUF if p doesn't have enough space for IP/LINK headers + * returns errors returned by netif->output + */ +static err_t +igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif) +{ + /* This is the "router alert" option */ + u16_t ra[2]; + ra[0] = PP_HTONS(ROUTER_ALERT); + ra[1] = 0x0000; /* Router shall examine packet */ + IGMP_STATS_INC(igmp.xmit); + return ip_output_if_opt(p, src, dest, IGMP_TTL, 0, IP_PROTO_IGMP, netif, ra, ROUTER_ALERTLEN); +} + +/** + * Send an igmp packet to a specific group. + * + * @param group the group to which to send the packet + * @param type the type of igmp packet to send + */ +static void +igmp_send(struct igmp_group *group, u8_t type) +{ + struct pbuf* p = NULL; + struct igmp_msg* igmp = NULL; + ip_addr_t src = *IP_ADDR_ANY; + ip_addr_t* dest = NULL; + + /* IP header + "router alert" option + IGMP header */ + p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM); + + if (p) { + igmp = (struct igmp_msg *)p->payload; + LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg", + (p->len >= sizeof(struct igmp_msg))); + ip_addr_copy(src, group->netif->ip_addr); + + if (type == IGMP_V2_MEMB_REPORT) { + dest = &(group->group_address); + ip_addr_copy(igmp->igmp_group_address, group->group_address); + group->last_reporter_flag = 1; /* Remember we were the last to report */ + } else { + if (type == IGMP_LEAVE_GROUP) { + dest = &allrouters; + ip_addr_copy(igmp->igmp_group_address, group->group_address); + } + } + + if ((type == IGMP_V2_MEMB_REPORT) || (type == IGMP_LEAVE_GROUP)) { + igmp->igmp_msgtype = type; + igmp->igmp_maxresp = 0; + igmp->igmp_checksum = 0; + igmp->igmp_checksum = inet_chksum(igmp, IGMP_MINLEN); + + igmp_ip_output_if(p, &src, dest, group->netif); + } + + pbuf_free(p); + } else { + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_send: not enough memory for igmp_send\n")); + IGMP_STATS_INC(igmp.memerr); + } +} + +#endif /* LWIP_IGMP */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/inet.c b/user/mpy/lib/lwip/src/core/ipv4/inet.c new file mode 100644 index 0000000..e283a57 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/inet.c @@ -0,0 +1,42 @@ +/** + * @file + * Functions common to all TCP/IPv4 modules, such as the byte order functions. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/inet.h" + diff --git a/user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c b/user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c new file mode 100644 index 0000000..960252f --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c @@ -0,0 +1,450 @@ +/** + * @file + * Incluse internet checksum functions. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/inet_chksum.h" +#include "lwip/def.h" + +#include +#include + +/* These are some reference implementations of the checksum algorithm, with the + * aim of being simple, correct and fully portable. Checksumming is the + * first thing you would want to optimize for your platform. If you create + * your own version, link it in and in your cc.h put: + * + * #define LWIP_CHKSUM + * + * Or you can select from the implementations below by defining + * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. + */ + +#ifndef LWIP_CHKSUM +# define LWIP_CHKSUM lwip_standard_chksum +# ifndef LWIP_CHKSUM_ALGORITHM +# define LWIP_CHKSUM_ALGORITHM 2 +# endif +#endif +/* If none set: */ +#ifndef LWIP_CHKSUM_ALGORITHM +# define LWIP_CHKSUM_ALGORITHM 0 +#endif + +#if (LWIP_CHKSUM_ALGORITHM == 1) /* Version #1 */ +/** + * lwip checksum + * + * @param dataptr points to start of data to be summed at any boundary + * @param len length of data to be summed + * @return host order (!) lwip checksum (non-inverted Internet sum) + * + * @note accumulator size limits summable length to 64k + * @note host endianess is irrelevant (p3 RFC1071) + */ +static u16_t +lwip_standard_chksum(void *dataptr, u16_t len) +{ + u32_t acc; + u16_t src; + u8_t *octetptr; + + acc = 0; + /* dataptr may be at odd or even addresses */ + octetptr = (u8_t*)dataptr; + while (len > 1) { + /* declare first octet as most significant + thus assume network order, ignoring host order */ + src = (*octetptr) << 8; + octetptr++; + /* declare second octet as least significant */ + src |= (*octetptr); + octetptr++; + acc += src; + len -= 2; + } + if (len > 0) { + /* accumulate remaining octet */ + src = (*octetptr) << 8; + acc += src; + } + /* add deferred carry bits */ + acc = (acc >> 16) + (acc & 0x0000ffffUL); + if ((acc & 0xffff0000UL) != 0) { + acc = (acc >> 16) + (acc & 0x0000ffffUL); + } + /* This maybe a little confusing: reorder sum using htons() + instead of ntohs() since it has a little less call overhead. + The caller must invert bits for Internet sum ! */ + return htons((u16_t)acc); +} +#endif + +#if (LWIP_CHKSUM_ALGORITHM == 2) /* Alternative version #2 */ +/* + * Curt McDowell + * Broadcom Corp. + * csm@broadcom.com + * + * IP checksum two bytes at a time with support for + * unaligned buffer. + * Works for len up to and including 0x20000. + * by Curt McDowell, Broadcom Corp. 12/08/2005 + * + * @param dataptr points to start of data to be summed at any boundary + * @param len length of data to be summed + * @return host order (!) lwip checksum (non-inverted Internet sum) + */ + +static u16_t +lwip_standard_chksum(void *dataptr, int len) +{ + u8_t *pb = (u8_t *)dataptr; + u16_t *ps, t = 0; + u32_t sum = 0; + int odd = ((mem_ptr_t)pb & 1); + + /* Get aligned to u16_t */ + if (odd && len > 0) { + ((u8_t *)&t)[1] = *pb++; + len--; + } + + /* Add the bulk of the data */ + ps = (u16_t *)(void *)pb; + while (len > 1) { + sum += *ps++; + len -= 2; + } + + /* Consume left-over byte, if any */ + if (len > 0) { + ((u8_t *)&t)[0] = *(u8_t *)ps; + } + + /* Add end bytes */ + sum += t; + + /* Fold 32-bit sum to 16 bits + calling this twice is propably faster than if statements... */ + sum = FOLD_U32T(sum); + sum = FOLD_U32T(sum); + + /* Swap if alignment was odd */ + if (odd) { + sum = SWAP_BYTES_IN_WORD(sum); + } + + return (u16_t)sum; +} +#endif + +#if (LWIP_CHKSUM_ALGORITHM == 3) /* Alternative version #3 */ +/** + * An optimized checksum routine. Basically, it uses loop-unrolling on + * the checksum loop, treating the head and tail bytes specially, whereas + * the inner loop acts on 8 bytes at a time. + * + * @arg start of buffer to be checksummed. May be an odd byte address. + * @len number of bytes in the buffer to be checksummed. + * @return host order (!) lwip checksum (non-inverted Internet sum) + * + * by Curt McDowell, Broadcom Corp. December 8th, 2005 + */ + +static u16_t +lwip_standard_chksum(void *dataptr, int len) +{ + u8_t *pb = (u8_t *)dataptr; + u16_t *ps, t = 0; + u32_t *pl; + u32_t sum = 0, tmp; + /* starts at odd byte address? */ + int odd = ((mem_ptr_t)pb & 1); + + if (odd && len > 0) { + ((u8_t *)&t)[1] = *pb++; + len--; + } + + ps = (u16_t *)pb; + + if (((mem_ptr_t)ps & 3) && len > 1) { + sum += *ps++; + len -= 2; + } + + pl = (u32_t *)ps; + + while (len > 7) { + tmp = sum + *pl++; /* ping */ + if (tmp < sum) { + tmp++; /* add back carry */ + } + + sum = tmp + *pl++; /* pong */ + if (sum < tmp) { + sum++; /* add back carry */ + } + + len -= 8; + } + + /* make room in upper bits */ + sum = FOLD_U32T(sum); + + ps = (u16_t *)pl; + + /* 16-bit aligned word remaining? */ + while (len > 1) { + sum += *ps++; + len -= 2; + } + + /* dangling tail byte remaining? */ + if (len > 0) { /* include odd byte */ + ((u8_t *)&t)[0] = *(u8_t *)ps; + } + + sum += t; /* add end bytes */ + + /* Fold 32-bit sum to 16 bits + calling this twice is propably faster than if statements... */ + sum = FOLD_U32T(sum); + sum = FOLD_U32T(sum); + + if (odd) { + sum = SWAP_BYTES_IN_WORD(sum); + } + + return (u16_t)sum; +} +#endif + +/* inet_chksum_pseudo: + * + * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. + * IP addresses are expected to be in network byte order. + * + * @param p chain of pbufs over that a checksum should be calculated (ip data part) + * @param src source ip address (used for checksum of pseudo header) + * @param dst destination ip address (used for checksum of pseudo header) + * @param proto ip protocol (used for checksum of pseudo header) + * @param proto_len length of the ip data part (used for checksum of pseudo header) + * @return checksum (as u16_t) to be saved directly in the protocol header + */ +u16_t +inet_chksum_pseudo(struct pbuf *p, + ip_addr_t *src, ip_addr_t *dest, + u8_t proto, u16_t proto_len) +{ + u32_t acc; + u32_t addr; + struct pbuf *q; + u8_t swapped; + + acc = 0; + swapped = 0; + /* iterate through all pbuf in chain */ + for(q = p; q != NULL; q = q->next) { + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", + (void *)q, (void *)q->next)); + acc += LWIP_CHKSUM(q->payload, q->len); + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ + /* just executing this next line is probably faster that the if statement needed + to check whether we really need to execute it, and does no harm */ + acc = FOLD_U32T(acc); + if (q->len % 2 != 0) { + swapped = 1 - swapped; + acc = SWAP_BYTES_IN_WORD(acc); + } + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ + } + + if (swapped) { + acc = SWAP_BYTES_IN_WORD(acc); + } + addr = ip4_addr_get_u32(src); + acc += (addr & 0xffffUL); + acc += ((addr >> 16) & 0xffffUL); + addr = ip4_addr_get_u32(dest); + acc += (addr & 0xffffUL); + acc += ((addr >> 16) & 0xffffUL); + acc += (u32_t)htons((u16_t)proto); + acc += (u32_t)htons(proto_len); + + /* Fold 32-bit sum to 16 bits + calling this twice is propably faster than if statements... */ + acc = FOLD_U32T(acc); + acc = FOLD_U32T(acc); + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); + return (u16_t)~(acc & 0xffffUL); +} + +/* inet_chksum_pseudo: + * + * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. + * IP addresses are expected to be in network byte order. + * + * @param p chain of pbufs over that a checksum should be calculated (ip data part) + * @param src source ip address (used for checksum of pseudo header) + * @param dst destination ip address (used for checksum of pseudo header) + * @param proto ip protocol (used for checksum of pseudo header) + * @param proto_len length of the ip data part (used for checksum of pseudo header) + * @return checksum (as u16_t) to be saved directly in the protocol header + */ +u16_t +inet_chksum_pseudo_partial(struct pbuf *p, + ip_addr_t *src, ip_addr_t *dest, + u8_t proto, u16_t proto_len, u16_t chksum_len) +{ + u32_t acc; + u32_t addr; + struct pbuf *q; + u8_t swapped; + u16_t chklen; + + acc = 0; + swapped = 0; + /* iterate through all pbuf in chain */ + for(q = p; (q != NULL) && (chksum_len > 0); q = q->next) { + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", + (void *)q, (void *)q->next)); + chklen = q->len; + if (chklen > chksum_len) { + chklen = chksum_len; + } + acc += LWIP_CHKSUM(q->payload, chklen); + chksum_len -= chklen; + LWIP_ASSERT("delete me", chksum_len < 0x7fff); + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ + /* fold the upper bit down */ + acc = FOLD_U32T(acc); + if (q->len % 2 != 0) { + swapped = 1 - swapped; + acc = SWAP_BYTES_IN_WORD(acc); + } + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ + } + + if (swapped) { + acc = SWAP_BYTES_IN_WORD(acc); + } + addr = ip4_addr_get_u32(src); + acc += (addr & 0xffffUL); + acc += ((addr >> 16) & 0xffffUL); + addr = ip4_addr_get_u32(dest); + acc += (addr & 0xffffUL); + acc += ((addr >> 16) & 0xffffUL); + acc += (u32_t)htons((u16_t)proto); + acc += (u32_t)htons(proto_len); + + /* Fold 32-bit sum to 16 bits + calling this twice is propably faster than if statements... */ + acc = FOLD_U32T(acc); + acc = FOLD_U32T(acc); + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); + return (u16_t)~(acc & 0xffffUL); +} + +/* inet_chksum: + * + * Calculates the Internet checksum over a portion of memory. Used primarily for IP + * and ICMP. + * + * @param dataptr start of the buffer to calculate the checksum (no alignment needed) + * @param len length of the buffer to calculate the checksum + * @return checksum (as u16_t) to be saved directly in the protocol header + */ + +u16_t +inet_chksum(void *dataptr, u16_t len) +{ + return ~LWIP_CHKSUM(dataptr, len); +} + +/** + * Calculate a checksum over a chain of pbufs (without pseudo-header, much like + * inet_chksum only pbufs are used). + * + * @param p pbuf chain over that the checksum should be calculated + * @return checksum (as u16_t) to be saved directly in the protocol header + */ +u16_t +inet_chksum_pbuf(struct pbuf *p) +{ + u32_t acc; + struct pbuf *q; + u8_t swapped; + + acc = 0; + swapped = 0; + for(q = p; q != NULL; q = q->next) { + acc += LWIP_CHKSUM(q->payload, q->len); + acc = FOLD_U32T(acc); + if (q->len % 2 != 0) { + swapped = 1 - swapped; + acc = SWAP_BYTES_IN_WORD(acc); + } + } + + if (swapped) { + acc = SWAP_BYTES_IN_WORD(acc); + } + return (u16_t)~(acc & 0xffffUL); +} + +/* These are some implementations for LWIP_CHKSUM_COPY, which copies data + * like MEMCPY but generates a checksum at the same time. Since this is a + * performance-sensitive function, you might want to create your own version + * in assembly targeted at your hardware by defining it in lwipopts.h: + * #define LWIP_CHKSUM_COPY(dst, src, len) your_chksum_copy(dst, src, len) + */ + +#if (LWIP_CHKSUM_COPY_ALGORITHM == 1) /* Version #1 */ +/** Safe but slow: first call MEMCPY, then call LWIP_CHKSUM. + * For architectures with big caches, data might still be in cache when + * generating the checksum after copying. + */ +u16_t +lwip_chksum_copy(void *dst, const void *src, u16_t len) +{ + MEMCPY(dst, src, len); + return LWIP_CHKSUM(dst, len); +} +#endif /* (LWIP_CHKSUM_COPY_ALGORITHM == 1) */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/ip.c b/user/mpy/lib/lwip/src/core/ipv4/ip.c new file mode 100644 index 0000000..95d2db4 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/ip.c @@ -0,0 +1,924 @@ +/** + * @file + * This is the IPv4 layer implementation for incoming and outgoing IP traffic. + * + * @see ip_frag.c + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" +#include "lwip/ip.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/ip_frag.h" +#include "lwip/inet_chksum.h" +#include "lwip/netif.h" +#include "lwip/icmp.h" +#include "lwip/igmp.h" +#include "lwip/raw.h" +#include "lwip/udp.h" +#include "lwip/tcp_impl.h" +#include "lwip/snmp.h" +#include "lwip/dhcp.h" +#include "lwip/autoip.h" +#include "lwip/stats.h" +#include "arch/perf.h" + +#include + +/** Set this to 0 in the rare case of wanting to call an extra function to + * generate the IP checksum (in contrast to calculating it on-the-fly). */ +#ifndef LWIP_INLINE_IP_CHKSUM +#define LWIP_INLINE_IP_CHKSUM 1 +#endif +#if LWIP_INLINE_IP_CHKSUM && CHECKSUM_GEN_IP +#define CHECKSUM_GEN_IP_INLINE 1 +#else +#define CHECKSUM_GEN_IP_INLINE 0 +#endif + +#if LWIP_DHCP || defined(LWIP_IP_ACCEPT_UDP_PORT) +#define IP_ACCEPT_LINK_LAYER_ADDRESSING 1 + +/** Some defines for DHCP to let link-layer-addressed packets through while the + * netif is down. + * To use this in your own application/protocol, define LWIP_IP_ACCEPT_UDP_PORT + * to return 1 if the port is accepted and 0 if the port is not accepted. + */ +#if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) +/* accept DHCP client port and custom port */ +#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (((port) == PP_NTOHS(DHCP_CLIENT_PORT)) \ + || (LWIP_IP_ACCEPT_UDP_PORT(port))) +#elif defined(LWIP_IP_ACCEPT_UDP_PORT) /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ +/* accept custom port only */ +#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (LWIP_IP_ACCEPT_UDP_PORT(port)) +#else /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ +/* accept DHCP client port only */ +#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) ((port) == PP_NTOHS(DHCP_CLIENT_PORT)) +#endif /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ + +#else /* LWIP_DHCP */ +#define IP_ACCEPT_LINK_LAYER_ADDRESSING 0 +#endif /* LWIP_DHCP */ + +/** + * The interface that provided the packet for the current callback + * invocation. + */ +struct netif *current_netif; + +/** + * Header of the input packet currently being processed. + */ +const struct ip_hdr *current_header; +/** Source IP address of current_header */ +ip_addr_t current_iphdr_src; +/** Destination IP address of current_header */ +ip_addr_t current_iphdr_dest; + +/** The IP header ID of the next outgoing IP packet */ +static u16_t ip_id; + +/** + * Finds the appropriate network interface for a given IP address. It + * searches the list of network interfaces linearly. A match is found + * if the masked IP address of the network interface equals the masked + * IP address given to the function. + * + * @param dest the destination IP address for which to find the route + * @return the netif on which to send to reach dest + */ +struct netif * +ip_route(ip_addr_t *dest) +{ + struct netif *netif; + +#ifdef LWIP_HOOK_IP4_ROUTE + netif = LWIP_HOOK_IP4_ROUTE(dest); + if (netif != NULL) { + return netif; + } +#endif + + /* iterate through netifs */ + for (netif = netif_list; netif != NULL; netif = netif->next) { + /* network mask matches? */ + if (netif_is_up(netif)) { + if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { + /* return netif on which to forward IP packet */ + return netif; + } + } + } + if ((netif_default == NULL) || (!netif_is_up(netif_default))) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); + IP_STATS_INC(ip.rterr); + snmp_inc_ipoutnoroutes(); + return NULL; + } + /* no matching netif found, use default netif */ + return netif_default; +} + +#if IP_FORWARD +/** + * Determine whether an IP address is in a reserved set of addresses + * that may not be forwarded, or whether datagrams to that destination + * may be forwarded. + * @param p the packet to forward + * @param dest the destination IP address + * @return 1: can forward 0: discard + */ +static int +ip_canforward(struct pbuf *p) +{ + u32_t addr = ip4_addr_get_u32(ip_current_dest_addr()); + + if (p->flags & PBUF_FLAG_LLBCAST) { + /* don't route link-layer broadcasts */ + return 0; + } + if ((p->flags & PBUF_FLAG_LLMCAST) && !IP_MULTICAST(addr)) { + /* don't route link-layer multicasts unless the destination address is an IP + multicast address */ + return 0; + } + if (IP_EXPERIMENTAL(addr)) { + return 0; + } + if (IP_CLASSA(addr)) { + u32_t net = addr & IP_CLASSA_NET; + if ((net == 0) || (net == (IP_LOOPBACKNET << IP_CLASSA_NSHIFT))) { + /* don't route loopback packets */ + return 0; + } + } + return 1; +} + +/** + * Forwards an IP packet. It finds an appropriate route for the + * packet, decrements the TTL value of the packet, adjusts the + * checksum and outputs the packet on the appropriate interface. + * + * @param p the packet to forward (p->payload points to IP header) + * @param iphdr the IP header of the input packet + * @param inp the netif on which this packet was received + */ +static void +ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) +{ + struct netif *netif; + + PERF_START; + + if (!ip_canforward(p)) { + goto return_noroute; + } + + /* RFC3927 2.7: do not forward link-local addresses */ + if (ip_addr_islinklocal(¤t_iphdr_dest)) { + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not forwarding LLA %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(¤t_iphdr_dest), ip4_addr2_16(¤t_iphdr_dest), + ip4_addr3_16(¤t_iphdr_dest), ip4_addr4_16(¤t_iphdr_dest))); + goto return_noroute; + } + + /* Find network interface where to forward this IP packet to. */ + netif = ip_route(¤t_iphdr_dest); + if (netif == NULL) { + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for %"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n", + ip4_addr1_16(¤t_iphdr_dest), ip4_addr2_16(¤t_iphdr_dest), + ip4_addr3_16(¤t_iphdr_dest), ip4_addr4_16(¤t_iphdr_dest))); + /* @todo: send ICMP_DUR_NET? */ + goto return_noroute; + } +#if !IP_FORWARD_ALLOW_TX_ON_RX_NETIF + /* Do not forward packets onto the same network interface on which + * they arrived. */ + if (netif == inp) { + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n")); + goto return_noroute; + } +#endif /* IP_FORWARD_ALLOW_TX_ON_RX_NETIF */ + + /* decrement TTL */ + IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1); + /* send ICMP if TTL == 0 */ + if (IPH_TTL(iphdr) == 0) { + snmp_inc_ipinhdrerrors(); +#if LWIP_ICMP + /* Don't send ICMP messages in response to ICMP messages */ + if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) { + icmp_time_exceeded(p, ICMP_TE_TTL); + } +#endif /* LWIP_ICMP */ + return; + } + + /* Incrementally update the IP checksum. */ + if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffffU - 0x100)) { + IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100) + 1); + } else { + IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100)); + } + + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(¤t_iphdr_dest), ip4_addr2_16(¤t_iphdr_dest), + ip4_addr3_16(¤t_iphdr_dest), ip4_addr4_16(¤t_iphdr_dest))); + + IP_STATS_INC(ip.fw); + IP_STATS_INC(ip.xmit); + snmp_inc_ipforwdatagrams(); + + PERF_STOP("ip_forward"); + /* don't fragment if interface has mtu set to 0 [loopif] */ + if (netif->mtu && (p->tot_len > netif->mtu)) { + if ((IPH_OFFSET(iphdr) & PP_NTOHS(IP_DF)) == 0) { +#if IP_FRAG + ip_frag(p, netif, ip_current_dest_addr()); +#else /* IP_FRAG */ + /* @todo: send ICMP Destination Unreacheable code 13 "Communication administratively prohibited"? */ +#endif /* IP_FRAG */ + } else { + /* send ICMP Destination Unreacheable code 4: "Fragmentation Needed and DF Set" */ + icmp_dest_unreach(p, ICMP_DUR_FRAG); + } + return; + } + /* transmit pbuf on chosen interface */ + netif->output(netif, p, ¤t_iphdr_dest); + return; +return_noroute: + snmp_inc_ipoutnoroutes(); +} +#endif /* IP_FORWARD */ + +/** + * This function is called by the network interface device driver when + * an IP packet is received. The function does the basic checks of the + * IP header such as packet size being at least larger than the header + * size etc. If the packet was not destined for us, the packet is + * forwarded (using ip_forward). The IP checksum is always checked. + * + * Finally, the packet is sent to the upper layer protocol input function. + * + * @param p the received IP packet (p->payload points to IP header) + * @param inp the netif on which this packet was received + * @return ERR_OK if the packet was processed (could return ERR_* if it wasn't + * processed, but currently always returns ERR_OK) + */ +err_t +ip_input(struct pbuf *p, struct netif *inp) +{ + struct ip_hdr *iphdr; + struct netif *netif; + u16_t iphdr_hlen; + u16_t iphdr_len; +#if IP_ACCEPT_LINK_LAYER_ADDRESSING + int check_ip_src=1; +#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ + + IP_STATS_INC(ip.recv); + snmp_inc_ipinreceives(); + + /* identify the IP header */ + iphdr = (struct ip_hdr *)p->payload; + if (IPH_V(iphdr) != 4) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr))); + ip_debug_print(p); + pbuf_free(p); + IP_STATS_INC(ip.err); + IP_STATS_INC(ip.drop); + snmp_inc_ipinhdrerrors(); + return ERR_OK; + } + +#ifdef LWIP_HOOK_IP4_INPUT + if (LWIP_HOOK_IP4_INPUT(p, inp)) { + /* the packet has been eaten */ + return ERR_OK; + } +#endif + + /* obtain IP header length in number of 32-bit words */ + iphdr_hlen = IPH_HL(iphdr); + /* calculate IP header length in bytes */ + iphdr_hlen *= 4; + /* obtain ip length in bytes */ + iphdr_len = ntohs(IPH_LEN(iphdr)); + + /* header length exceeds first pbuf length, or ip length exceeds total pbuf length? */ + if ((iphdr_hlen > p->len) || (iphdr_len > p->tot_len)) { + if (iphdr_hlen > p->len) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("IP header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n", + iphdr_hlen, p->len)); + } + if (iphdr_len > p->tot_len) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("IP (len %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n", + iphdr_len, p->tot_len)); + } + /* free (drop) packet pbufs */ + pbuf_free(p); + IP_STATS_INC(ip.lenerr); + IP_STATS_INC(ip.drop); + snmp_inc_ipindiscards(); + return ERR_OK; + } + + /* verify checksum */ +#if CHECKSUM_CHECK_IP + if (inet_chksum(iphdr, iphdr_hlen) != 0) { + + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdr_hlen))); + ip_debug_print(p); + pbuf_free(p); + IP_STATS_INC(ip.chkerr); + IP_STATS_INC(ip.drop); + snmp_inc_ipinhdrerrors(); + return ERR_OK; + } +#endif + + /* Trim pbuf. This should have been done at the netif layer, + * but we'll do it anyway just to be sure that its done. */ + pbuf_realloc(p, iphdr_len); + + /* copy IP addresses to aligned ip_addr_t */ + ip_addr_copy(current_iphdr_dest, iphdr->dest); + ip_addr_copy(current_iphdr_src, iphdr->src); + + /* match packet against an interface, i.e. is this packet for us? */ +#if LWIP_IGMP + if (ip_addr_ismulticast(¤t_iphdr_dest)) { + if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ¤t_iphdr_dest))) { + netif = inp; + } else { + netif = NULL; + } + } else +#endif /* LWIP_IGMP */ + { + /* start trying with inp. if that's not acceptable, start walking the + list of configured netifs. + 'first' is used as a boolean to mark whether we started walking the list */ + int first = 1; + netif = inp; + do { + LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n", + ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(&netif->ip_addr), + ip4_addr_get_u32(&iphdr->dest) & ip4_addr_get_u32(&netif->netmask), + ip4_addr_get_u32(&netif->ip_addr) & ip4_addr_get_u32(&netif->netmask), + ip4_addr_get_u32(&iphdr->dest) & ~ip4_addr_get_u32(&netif->netmask))); + + /* interface is up and configured? */ + if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr)))) { + /* unicast to this interface address? */ + if (ip_addr_cmp(¤t_iphdr_dest, &(netif->ip_addr)) || + /* or broadcast on this interface network address? */ + ip_addr_isbroadcast(¤t_iphdr_dest, netif)) { + LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n", + netif->name[0], netif->name[1])); + /* break out of for loop */ + break; + } +#if LWIP_AUTOIP + /* connections to link-local addresses must persist after changing + the netif's address (RFC3927 ch. 1.9) */ + if ((netif->autoip != NULL) && + ip_addr_cmp(¤t_iphdr_dest, &(netif->autoip->llipaddr))) { + LWIP_DEBUGF(IP_DEBUG, ("ip_input: LLA packet accepted on interface %c%c\n", + netif->name[0], netif->name[1])); + /* break out of for loop */ + break; + } +#endif /* LWIP_AUTOIP */ + } + if (first) { + first = 0; + netif = netif_list; + } else { + netif = netif->next; + } + if (netif == inp) { + netif = netif->next; + } + } while(netif != NULL); + } + +#if IP_ACCEPT_LINK_LAYER_ADDRESSING + /* Pass DHCP messages regardless of destination address. DHCP traffic is addressed + * using link layer addressing (such as Ethernet MAC) so we must not filter on IP. + * According to RFC 1542 section 3.1.1, referred by RFC 2131). + * + * If you want to accept private broadcast communication while a netif is down, + * define LWIP_IP_ACCEPT_UDP_PORT(dst_port), e.g.: + * + * #define LWIP_IP_ACCEPT_UDP_PORT(dst_port) ((dst_port) == PP_NTOHS(12345)) + */ + if (netif == NULL) { + /* remote port is DHCP server? */ + if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { + struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)iphdr + iphdr_hlen); + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: UDP packet to DHCP client port %"U16_F"\n", + ntohs(udphdr->dest))); + if (IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(udphdr->dest)) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: DHCP packet accepted.\n")); + netif = inp; + check_ip_src = 0; + } + } + } +#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ + + /* broadcast or multicast packet source address? Compliant with RFC 1122: 3.2.1.3 */ +#if IP_ACCEPT_LINK_LAYER_ADDRESSING + /* DHCP servers need 0.0.0.0 to be allowed as source address (RFC 1.1.2.2: 3.2.1.3/a) */ + if (check_ip_src && !ip_addr_isany(¤t_iphdr_src)) +#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ + { if ((ip_addr_isbroadcast(¤t_iphdr_src, inp)) || + (ip_addr_ismulticast(¤t_iphdr_src))) { + /* packet source is not valid */ + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("ip_input: packet source is not valid.\n")); + /* free (drop) packet pbufs */ + pbuf_free(p); + IP_STATS_INC(ip.drop); + snmp_inc_ipinaddrerrors(); + snmp_inc_ipindiscards(); + return ERR_OK; + } + } + + /* packet not for us? */ + if (netif == NULL) { + /* packet not for us, route or discard */ + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: packet not for us.\n")); +#if IP_FORWARD + /* non-broadcast packet? */ + if (!ip_addr_isbroadcast(¤t_iphdr_dest, inp)) { + /* try to forward IP packet on (other) interfaces */ + ip_forward(p, iphdr, inp); + } else +#endif /* IP_FORWARD */ + { + snmp_inc_ipinaddrerrors(); + snmp_inc_ipindiscards(); + } + pbuf_free(p); + return ERR_OK; + } + /* packet consists of multiple fragments? */ + if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) { +#if IP_REASSEMBLY /* packet fragment reassembly code present? */ + LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip_reass()\n", + ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8)); + /* reassemble the packet*/ + p = ip_reass(p); + /* packet not fully reassembled yet? */ + if (p == NULL) { + return ERR_OK; + } + iphdr = (struct ip_hdr *)p->payload; +#else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */ + pbuf_free(p); + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n", + ntohs(IPH_OFFSET(iphdr)))); + IP_STATS_INC(ip.opterr); + IP_STATS_INC(ip.drop); + /* unsupported protocol feature */ + snmp_inc_ipinunknownprotos(); + return ERR_OK; +#endif /* IP_REASSEMBLY */ + } + +#if IP_OPTIONS_ALLOWED == 0 /* no support for IP options in the IP header? */ + +#if LWIP_IGMP + /* there is an extra "router alert" option in IGMP messages which we allow for but do not police */ + if((iphdr_hlen > IP_HLEN) && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) { +#else + if (iphdr_hlen > IP_HLEN) { +#endif /* LWIP_IGMP */ + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since there were IP options (while IP_OPTIONS_ALLOWED == 0).\n")); + pbuf_free(p); + IP_STATS_INC(ip.opterr); + IP_STATS_INC(ip.drop); + /* unsupported protocol feature */ + snmp_inc_ipinunknownprotos(); + return ERR_OK; + } +#endif /* IP_OPTIONS_ALLOWED == 0 */ + + /* send to upper layers */ + LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n")); + ip_debug_print(p); + LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len)); + + current_netif = inp; + current_header = iphdr; + +#if LWIP_RAW + /* raw input did not eat the packet? */ + if (raw_input(p, inp) == 0) +#endif /* LWIP_RAW */ + { + switch (IPH_PROTO(iphdr)) { +#if LWIP_UDP + case IP_PROTO_UDP: +#if LWIP_UDPLITE + case IP_PROTO_UDPLITE: +#endif /* LWIP_UDPLITE */ + snmp_inc_ipindelivers(); + udp_input(p, inp); + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case IP_PROTO_TCP: + snmp_inc_ipindelivers(); + tcp_input(p, inp); + break; +#endif /* LWIP_TCP */ +#if LWIP_ICMP + case IP_PROTO_ICMP: + snmp_inc_ipindelivers(); + icmp_input(p, inp); + break; +#endif /* LWIP_ICMP */ +#if LWIP_IGMP + case IP_PROTO_IGMP: + igmp_input(p, inp, ¤t_iphdr_dest); + break; +#endif /* LWIP_IGMP */ + default: +#if LWIP_ICMP + /* send ICMP destination protocol unreachable unless is was a broadcast */ + if (!ip_addr_isbroadcast(¤t_iphdr_dest, inp) && + !ip_addr_ismulticast(¤t_iphdr_dest)) { + p->payload = iphdr; + icmp_dest_unreach(p, ICMP_DUR_PROTO); + } +#endif /* LWIP_ICMP */ + pbuf_free(p); + + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr))); + + IP_STATS_INC(ip.proterr); + IP_STATS_INC(ip.drop); + snmp_inc_ipinunknownprotos(); + } + } + + current_netif = NULL; + current_header = NULL; + ip_addr_set_any(¤t_iphdr_src); + ip_addr_set_any(¤t_iphdr_dest); + + return ERR_OK; +} + +/** + * Sends an IP packet on a network interface. This function constructs + * the IP header and calculates the IP header checksum. If the source + * IP address is NULL, the IP address of the outgoing network + * interface is filled in as source address. + * If the destination IP address is IP_HDRINCL, p is assumed to already + * include an IP header and p->payload points to it instead of the data. + * + * @param p the packet to send (p->payload points to the data, e.g. next + protocol header; if dest == IP_HDRINCL, p already includes an IP + header and p->payload points to that IP header) + * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * IP address of the netif used to send is used as source address) + * @param dest the destination IP address to send the packet to + * @param ttl the TTL value to be set in the IP header + * @param tos the TOS value to be set in the IP header + * @param proto the PROTOCOL to be set in the IP header + * @param netif the netif on which to send this packet + * @return ERR_OK if the packet was sent OK + * ERR_BUF if p doesn't have enough space for IP/LINK headers + * returns errors returned by netif->output + * + * @note ip_id: RFC791 "some host may be able to simply use + * unique identifiers independent of destination" + */ +err_t +ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, + u8_t proto, struct netif *netif) +{ +#if IP_OPTIONS_SEND + return ip_output_if_opt(p, src, dest, ttl, tos, proto, netif, NULL, 0); +} + +/** + * Same as ip_output_if() but with the possibility to include IP options: + * + * @ param ip_options pointer to the IP options, copied into the IP header + * @ param optlen length of ip_options + */ +err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, + u16_t optlen) +{ +#endif /* IP_OPTIONS_SEND */ + struct ip_hdr *iphdr; + ip_addr_t dest_addr; +#if CHECKSUM_GEN_IP_INLINE + u32_t chk_sum = 0; +#endif /* CHECKSUM_GEN_IP_INLINE */ + + /* pbufs passed to IP must have a ref-count of 1 as their payload pointer + gets altered as the packet is passed down the stack */ + LWIP_ASSERT("p->ref == 1", p->ref == 1); + + snmp_inc_ipoutrequests(); + + /* Should the IP header be generated or is it already included in p? */ + if (dest != IP_HDRINCL) { + u16_t ip_hlen = IP_HLEN; +#if IP_OPTIONS_SEND + u16_t optlen_aligned = 0; + if (optlen != 0) { +#if CHECKSUM_GEN_IP_INLINE + int i; +#endif /* CHECKSUM_GEN_IP_INLINE */ + /* round up to a multiple of 4 */ + optlen_aligned = ((optlen + 3) & ~3); + ip_hlen += optlen_aligned; + /* First write in the IP options */ + if (pbuf_header(p, optlen_aligned)) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output_if_opt: not enough room for IP options in pbuf\n")); + IP_STATS_INC(ip.err); + snmp_inc_ipoutdiscards(); + return ERR_BUF; + } + MEMCPY(p->payload, ip_options, optlen); + if (optlen < optlen_aligned) { + /* zero the remaining bytes */ + memset(((char*)p->payload) + optlen, 0, optlen_aligned - optlen); + } +#if CHECKSUM_GEN_IP_INLINE + for (i = 0; i < optlen_aligned/2; i++) { + chk_sum += ((u16_t*)p->payload)[i]; + } +#endif /* CHECKSUM_GEN_IP_INLINE */ + } +#endif /* IP_OPTIONS_SEND */ + /* generate IP header */ + if (pbuf_header(p, IP_HLEN)) { + LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output: not enough room for IP header in pbuf\n")); + + IP_STATS_INC(ip.err); + snmp_inc_ipoutdiscards(); + return ERR_BUF; + } + + iphdr = (struct ip_hdr *)p->payload; + LWIP_ASSERT("check that first pbuf can hold struct ip_hdr", + (p->len >= sizeof(struct ip_hdr))); + + IPH_TTL_SET(iphdr, ttl); + IPH_PROTO_SET(iphdr, proto); +#if CHECKSUM_GEN_IP_INLINE + chk_sum += LWIP_MAKE_U16(proto, ttl); +#endif /* CHECKSUM_GEN_IP_INLINE */ + + /* dest cannot be NULL here */ + ip_addr_copy(iphdr->dest, *dest); +#if CHECKSUM_GEN_IP_INLINE + chk_sum += ip4_addr_get_u32(&iphdr->dest) & 0xFFFF; + chk_sum += ip4_addr_get_u32(&iphdr->dest) >> 16; +#endif /* CHECKSUM_GEN_IP_INLINE */ + + IPH_VHL_SET(iphdr, 4, ip_hlen / 4); + IPH_TOS_SET(iphdr, tos); +#if CHECKSUM_GEN_IP_INLINE + chk_sum += LWIP_MAKE_U16(tos, iphdr->_v_hl); +#endif /* CHECKSUM_GEN_IP_INLINE */ + IPH_LEN_SET(iphdr, htons(p->tot_len)); +#if CHECKSUM_GEN_IP_INLINE + chk_sum += iphdr->_len; +#endif /* CHECKSUM_GEN_IP_INLINE */ + IPH_OFFSET_SET(iphdr, 0); + IPH_ID_SET(iphdr, htons(ip_id)); +#if CHECKSUM_GEN_IP_INLINE + chk_sum += iphdr->_id; +#endif /* CHECKSUM_GEN_IP_INLINE */ + ++ip_id; + + if (ip_addr_isany(src)) { + ip_addr_copy(iphdr->src, netif->ip_addr); + } else { + /* src cannot be NULL here */ + ip_addr_copy(iphdr->src, *src); + } + +#if CHECKSUM_GEN_IP_INLINE + chk_sum += ip4_addr_get_u32(&iphdr->src) & 0xFFFF; + chk_sum += ip4_addr_get_u32(&iphdr->src) >> 16; + chk_sum = (chk_sum >> 16) + (chk_sum & 0xFFFF); + chk_sum = (chk_sum >> 16) + chk_sum; + chk_sum = ~chk_sum; + iphdr->_chksum = chk_sum; /* network order */ +#else /* CHECKSUM_GEN_IP_INLINE */ + IPH_CHKSUM_SET(iphdr, 0); +#if CHECKSUM_GEN_IP + IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen)); +#endif +#endif /* CHECKSUM_GEN_IP_INLINE */ + } else { + /* IP header already included in p */ + iphdr = (struct ip_hdr *)p->payload; + ip_addr_copy(dest_addr, iphdr->dest); + dest = &dest_addr; + } + + IP_STATS_INC(ip.xmit); + + LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num)); + ip_debug_print(p); + +#if ENABLE_LOOPBACK + if (ip_addr_cmp(dest, &netif->ip_addr)) { + /* Packet to self, enqueue it for loopback */ + LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()")); + return netif_loop_output(netif, p, dest); + } +#if LWIP_IGMP + if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) { + netif_loop_output(netif, p, dest); + } +#endif /* LWIP_IGMP */ +#endif /* ENABLE_LOOPBACK */ +#if IP_FRAG + /* don't fragment if interface has mtu set to 0 [loopif] */ + if (netif->mtu && (p->tot_len > netif->mtu)) { + return ip_frag(p, netif, dest); + } +#endif /* IP_FRAG */ + + LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); + return netif->output(netif, p, dest); +} + +/** + * Simple interface to ip_output_if. It finds the outgoing network + * interface and calls upon ip_output_if to do the actual work. + * + * @param p the packet to send (p->payload points to the data, e.g. next + protocol header; if dest == IP_HDRINCL, p already includes an IP + header and p->payload points to that IP header) + * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * IP address of the netif used to send is used as source address) + * @param dest the destination IP address to send the packet to + * @param ttl the TTL value to be set in the IP header + * @param tos the TOS value to be set in the IP header + * @param proto the PROTOCOL to be set in the IP header + * + * @return ERR_RTE if no route is found + * see ip_output_if() for more return values + */ +err_t +ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto) +{ + struct netif *netif; + + /* pbufs passed to IP must have a ref-count of 1 as their payload pointer + gets altered as the packet is passed down the stack */ + LWIP_ASSERT("p->ref == 1", p->ref == 1); + + if ((netif = ip_route(dest)) == NULL) { + LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); + IP_STATS_INC(ip.rterr); + return ERR_RTE; + } + + return ip_output_if(p, src, dest, ttl, tos, proto, netif); +} + +#if LWIP_NETIF_HWADDRHINT +/** Like ip_output, but takes and addr_hint pointer that is passed on to netif->addr_hint + * before calling ip_output_if. + * + * @param p the packet to send (p->payload points to the data, e.g. next + protocol header; if dest == IP_HDRINCL, p already includes an IP + header and p->payload points to that IP header) + * @param src the source IP address to send from (if src == IP_ADDR_ANY, the + * IP address of the netif used to send is used as source address) + * @param dest the destination IP address to send the packet to + * @param ttl the TTL value to be set in the IP header + * @param tos the TOS value to be set in the IP header + * @param proto the PROTOCOL to be set in the IP header + * @param addr_hint address hint pointer set to netif->addr_hint before + * calling ip_output_if() + * + * @return ERR_RTE if no route is found + * see ip_output_if() for more return values + */ +err_t +ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint) +{ + struct netif *netif; + err_t err; + + /* pbufs passed to IP must have a ref-count of 1 as their payload pointer + gets altered as the packet is passed down the stack */ + LWIP_ASSERT("p->ref == 1", p->ref == 1); + + if ((netif = ip_route(dest)) == NULL) { + LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); + IP_STATS_INC(ip.rterr); + return ERR_RTE; + } + + NETIF_SET_HWADDRHINT(netif, addr_hint); + err = ip_output_if(p, src, dest, ttl, tos, proto, netif); + NETIF_SET_HWADDRHINT(netif, NULL); + + return err; +} +#endif /* LWIP_NETIF_HWADDRHINT*/ + +#if IP_DEBUG +/* Print an IP header by using LWIP_DEBUGF + * @param p an IP packet, p->payload pointing to the IP header + */ +void +ip_debug_print(struct pbuf *p) +{ + struct ip_hdr *iphdr = (struct ip_hdr *)p->payload; + + LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" | 0x%02"X16_F" | %5"U16_F" | (v, hl, tos, len)\n", + IPH_V(iphdr), + IPH_HL(iphdr), + IPH_TOS(iphdr), + ntohs(IPH_LEN(iphdr)))); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" |%"U16_F"%"U16_F"%"U16_F"| %4"U16_F" | (id, flags, offset)\n", + ntohs(IPH_ID(iphdr)), + ntohs(IPH_OFFSET(iphdr)) >> 15 & 1, + ntohs(IPH_OFFSET(iphdr)) >> 14 & 1, + ntohs(IPH_OFFSET(iphdr)) >> 13 & 1, + ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%04"X16_F" | (ttl, proto, chksum)\n", + IPH_TTL(iphdr), + IPH_PROTO(iphdr), + ntohs(IPH_CHKSUM(iphdr)))); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (src)\n", + ip4_addr1_16(&iphdr->src), + ip4_addr2_16(&iphdr->src), + ip4_addr3_16(&iphdr->src), + ip4_addr4_16(&iphdr->src))); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (dest)\n", + ip4_addr1_16(&iphdr->dest), + ip4_addr2_16(&iphdr->dest), + ip4_addr3_16(&iphdr->dest), + ip4_addr4_16(&iphdr->dest))); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); +} +#endif /* IP_DEBUG */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/ip_addr.c b/user/mpy/lib/lwip/src/core/ipv4/ip_addr.c new file mode 100644 index 0000000..8f633ff --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/ip_addr.c @@ -0,0 +1,312 @@ +/** + * @file + * This is the IPv4 address tools implementation. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" + +/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ +const ip_addr_t ip_addr_any = { IPADDR_ANY }; +const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST }; + +/** + * Determine if an address is a broadcast address on a network interface + * + * @param addr address to be checked + * @param netif the network interface against which the address is checked + * @return returns non-zero if the address is a broadcast address + */ +u8_t +ip4_addr_isbroadcast(u32_t addr, const struct netif *netif) +{ + ip_addr_t ipaddr; + ip4_addr_set_u32(&ipaddr, addr); + + /* all ones (broadcast) or all zeroes (old skool broadcast) */ + if ((~addr == IPADDR_ANY) || + (addr == IPADDR_ANY)) { + return 1; + /* no broadcast support on this network interface? */ + } else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) { + /* the given address cannot be a broadcast address + * nor can we check against any broadcast addresses */ + return 0; + /* address matches network interface address exactly? => no broadcast */ + } else if (addr == ip4_addr_get_u32(&netif->ip_addr)) { + return 0; + /* on the same (sub) network... */ + } else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask)) + /* ...and host identifier bits are all ones? =>... */ + && ((addr & ~ip4_addr_get_u32(&netif->netmask)) == + (IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) { + /* => network broadcast address */ + return 1; + } else { + return 0; + } +} + +/** Checks if a netmask is valid (starting with ones, then only zeros) + * + * @param netmask the IPv4 netmask to check (in network byte order!) + * @return 1 if the netmask is valid, 0 if it is not + */ +u8_t +ip4_addr_netmask_valid(u32_t netmask) +{ + u32_t mask; + u32_t nm_hostorder = lwip_htonl(netmask); + + /* first, check for the first zero */ + for (mask = 1UL << 31 ; mask != 0; mask >>= 1) { + if ((nm_hostorder & mask) == 0) { + break; + } + } + /* then check that there is no one */ + for (; mask != 0; mask >>= 1) { + if ((nm_hostorder & mask) != 0) { + /* there is a one after the first zero -> invalid */ + return 0; + } + } + /* no one after the first zero -> valid */ + return 1; +} + +/* Here for now until needed in other places in lwIP */ +#ifndef isprint +#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) +#define isprint(c) in_range(c, 0x20, 0x7f) +#define isdigit(c) in_range(c, '0', '9') +#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) +#define islower(c) in_range(c, 'a', 'z') +#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') +#endif + +/** + * Ascii internet address interpretation routine. + * The value returned is in network order. + * + * @param cp IP address in ascii represenation (e.g. "127.0.0.1") + * @return ip address in network order + */ +u32_t +ipaddr_addr(const char *cp) +{ + ip_addr_t val; + + if (ipaddr_aton(cp, &val)) { + return ip4_addr_get_u32(&val); + } + return (IPADDR_NONE); +} + +/** + * Check whether "cp" is a valid ascii representation + * of an Internet address and convert to a binary address. + * Returns 1 if the address is valid, 0 if not. + * This replaces inet_addr, the return value from which + * cannot distinguish between failure and a local broadcast address. + * + * @param cp IP address in ascii represenation (e.g. "127.0.0.1") + * @param addr pointer to which to save the ip address in network order + * @return 1 if cp could be converted to addr, 0 on failure + */ +int +ipaddr_aton(const char *cp, ip_addr_t *addr) +{ + u32_t val; + u8_t base; + char c; + u32_t parts[4]; + u32_t *pp = parts; + + c = *cp; + for (;;) { + /* + * Collect number up to ``.''. + * Values are specified as for C: + * 0x=hex, 0=octal, 1-9=decimal. + */ + if (!isdigit(c)) + return (0); + val = 0; + base = 10; + if (c == '0') { + c = *++cp; + if (c == 'x' || c == 'X') { + base = 16; + c = *++cp; + } else + base = 8; + } + for (;;) { + if (isdigit(c)) { + val = (val * base) + (int)(c - '0'); + c = *++cp; + } else if (base == 16 && isxdigit(c)) { + val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A')); + c = *++cp; + } else + break; + } + if (c == '.') { + /* + * Internet format: + * a.b.c.d + * a.b.c (with c treated as 16 bits) + * a.b (with b treated as 24 bits) + */ + if (pp >= parts + 3) { + return (0); + } + *pp++ = val; + c = *++cp; + } else + break; + } + /* + * Check for trailing characters. + */ + if (c != '\0' && !isspace(c)) { + return (0); + } + /* + * Concoct the address according to + * the number of parts specified. + */ + switch (pp - parts + 1) { + + case 0: + return (0); /* initial nondigit */ + + case 1: /* a -- 32 bits */ + break; + + case 2: /* a.b -- 8.24 bits */ + if (val > 0xffffffUL) { + return (0); + } + val |= parts[0] << 24; + break; + + case 3: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff) { + return (0); + } + val |= (parts[0] << 24) | (parts[1] << 16); + break; + + case 4: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff) { + return (0); + } + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + default: + LWIP_ASSERT("unhandled", 0); + break; + } + if (addr) { + ip4_addr_set_u32(addr, htonl(val)); + } + return (1); +} + +/** + * Convert numeric IP address into decimal dotted ASCII representation. + * returns ptr to static buffer; not reentrant! + * + * @param addr ip address in network order to convert + * @return pointer to a global static (!) buffer that holds the ASCII + * represenation of addr + */ +char * +ipaddr_ntoa(const ip_addr_t *addr) +{ + static char str[16]; + return ipaddr_ntoa_r(addr, str, 16); +} + +/** + * Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used. + * + * @param addr ip address in network order to convert + * @param buf target buffer where the string is stored + * @param buflen length of buf + * @return either pointer to buf which now holds the ASCII + * representation of addr or NULL if buf was too small + */ +char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen) +{ + u32_t s_addr; + char inv[3]; + char *rp; + u8_t *ap; + u8_t rem; + u8_t n; + u8_t i; + int len = 0; + + s_addr = ip4_addr_get_u32(addr); + + rp = buf; + ap = (u8_t *)&s_addr; + for(n = 0; n < 4; n++) { + i = 0; + do { + rem = *ap % (u8_t)10; + *ap /= (u8_t)10; + inv[i++] = '0' + rem; + } while(*ap); + while(i--) { + if (len++ >= buflen) { + return NULL; + } + *rp++ = inv[i]; + } + if (len++ >= buflen) { + return NULL; + } + *rp++ = '.'; + ap++; + } + *--rp = 0; + return buf; +} diff --git a/user/mpy/lib/lwip/src/core/ipv4/ip_frag.c b/user/mpy/lib/lwip/src/core/ipv4/ip_frag.c new file mode 100644 index 0000000..8d18434 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv4/ip_frag.c @@ -0,0 +1,863 @@ +/** + * @file + * This is the IPv4 packet segmentation and reassembly implementation. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Jani Monoses + * Simon Goldschmidt + * original reassembly code by Adam Dunkels + * + */ + +#include "lwip/opt.h" +#include "lwip/ip_frag.h" +#include "lwip/def.h" +#include "lwip/inet_chksum.h" +#include "lwip/netif.h" +#include "lwip/snmp.h" +#include "lwip/stats.h" +#include "lwip/icmp.h" + +#include + +#if IP_REASSEMBLY +/** + * The IP reassembly code currently has the following limitations: + * - IP header options are not supported + * - fragments must not overlap (e.g. due to different routes), + * currently, overlapping or duplicate fragments are thrown away + * if IP_REASS_CHECK_OVERLAP=1 (the default)! + * + * @todo: work with IP header options + */ + +/** Setting this to 0, you can turn off checking the fragments for overlapping + * regions. The code gets a little smaller. Only use this if you know that + * overlapping won't occur on your network! */ +#ifndef IP_REASS_CHECK_OVERLAP +#define IP_REASS_CHECK_OVERLAP 1 +#endif /* IP_REASS_CHECK_OVERLAP */ + +/** Set to 0 to prevent freeing the oldest datagram when the reassembly buffer is + * full (IP_REASS_MAX_PBUFS pbufs are enqueued). The code gets a little smaller. + * Datagrams will be freed by timeout only. Especially useful when MEMP_NUM_REASSDATA + * is set to 1, so one datagram can be reassembled at a time, only. */ +#ifndef IP_REASS_FREE_OLDEST +#define IP_REASS_FREE_OLDEST 1 +#endif /* IP_REASS_FREE_OLDEST */ + +#define IP_REASS_FLAG_LASTFRAG 0x01 + +/** This is a helper struct which holds the starting + * offset and the ending offset of this fragment to + * easily chain the fragments. + * It has the same packing requirements as the IP header, since it replaces + * the IP header in memory in incoming fragments (after copying it) to keep + * track of the various fragments. (-> If the IP header doesn't need packing, + * this struct doesn't need packing, too.) + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip_reass_helper { + PACK_STRUCT_FIELD(struct pbuf *next_pbuf); + PACK_STRUCT_FIELD(u16_t start); + PACK_STRUCT_FIELD(u16_t end); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define IP_ADDRESSES_AND_ID_MATCH(iphdrA, iphdrB) \ + (ip_addr_cmp(&(iphdrA)->src, &(iphdrB)->src) && \ + ip_addr_cmp(&(iphdrA)->dest, &(iphdrB)->dest) && \ + IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0 + +/* global variables */ +static struct ip_reassdata *reassdatagrams; +static u16_t ip_reass_pbufcount; + +/* function prototypes */ +static void ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev); +static int ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev); + +/** + * Reassembly timer base function + * for both NO_SYS == 0 and 1 (!). + * + * Should be called every 1000 msec (defined by IP_TMR_INTERVAL). + */ +void +ip_reass_tmr(void) +{ + struct ip_reassdata *r, *prev = NULL; + + r = reassdatagrams; + while (r != NULL) { + /* Decrement the timer. Once it reaches 0, + * clean up the incomplete fragment assembly */ + if (r->timer > 0) { + r->timer--; + LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n",(u16_t)r->timer)); + prev = r; + r = r->next; + } else { + /* reassembly timed out */ + struct ip_reassdata *tmp; + LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer timed out\n")); + tmp = r; + /* get the next pointer before freeing */ + r = r->next; + /* free the helper struct and all enqueued pbufs */ + ip_reass_free_complete_datagram(tmp, prev); + } + } +} + +/** + * Free a datagram (struct ip_reassdata) and all its pbufs. + * Updates the total count of enqueued pbufs (ip_reass_pbufcount), + * SNMP counters and sends an ICMP time exceeded packet. + * + * @param ipr datagram to free + * @param prev the previous datagram in the linked list + * @return the number of pbufs freed + */ +static int +ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) +{ + u16_t pbufs_freed = 0; + u8_t clen; + struct pbuf *p; + struct ip_reass_helper *iprh; + + LWIP_ASSERT("prev != ipr", prev != ipr); + if (prev != NULL) { + LWIP_ASSERT("prev->next == ipr", prev->next == ipr); + } + + snmp_inc_ipreasmfails(); +#if LWIP_ICMP + iprh = (struct ip_reass_helper *)ipr->p->payload; + if (iprh->start == 0) { + /* The first fragment was received, send ICMP time exceeded. */ + /* First, de-queue the first pbuf from r->p. */ + p = ipr->p; + ipr->p = iprh->next_pbuf; + /* Then, copy the original header into it. */ + SMEMCPY(p->payload, &ipr->iphdr, IP_HLEN); + icmp_time_exceeded(p, ICMP_TE_FRAG); + clen = pbuf_clen(p); + LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); + pbufs_freed += clen; + pbuf_free(p); + } +#endif /* LWIP_ICMP */ + + /* First, free all received pbufs. The individual pbufs need to be released + separately as they have not yet been chained */ + p = ipr->p; + while (p != NULL) { + struct pbuf *pcur; + iprh = (struct ip_reass_helper *)p->payload; + pcur = p; + /* get the next pointer before freeing */ + p = iprh->next_pbuf; + clen = pbuf_clen(pcur); + LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); + pbufs_freed += clen; + pbuf_free(pcur); + } + /* Then, unchain the struct ip_reassdata from the list and free it. */ + ip_reass_dequeue_datagram(ipr, prev); + LWIP_ASSERT("ip_reass_pbufcount >= clen", ip_reass_pbufcount >= pbufs_freed); + ip_reass_pbufcount -= pbufs_freed; + + return pbufs_freed; +} + +#if IP_REASS_FREE_OLDEST +/** + * Free the oldest datagram to make room for enqueueing new fragments. + * The datagram 'fraghdr' belongs to is not freed! + * + * @param fraghdr IP header of the current fragment + * @param pbufs_needed number of pbufs needed to enqueue + * (used for freeing other datagrams if not enough space) + * @return the number of pbufs freed + */ +static int +ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed) +{ + /* @todo Can't we simply remove the last datagram in the + * linked list behind reassdatagrams? + */ + struct ip_reassdata *r, *oldest, *prev; + int pbufs_freed = 0, pbufs_freed_current; + int other_datagrams; + + /* Free datagrams until being allowed to enqueue 'pbufs_needed' pbufs, + * but don't free the datagram that 'fraghdr' belongs to! */ + do { + oldest = NULL; + prev = NULL; + other_datagrams = 0; + r = reassdatagrams; + while (r != NULL) { + if (!IP_ADDRESSES_AND_ID_MATCH(&r->iphdr, fraghdr)) { + /* Not the same datagram as fraghdr */ + other_datagrams++; + if (oldest == NULL) { + oldest = r; + } else if (r->timer <= oldest->timer) { + /* older than the previous oldest */ + oldest = r; + } + } + if (r->next != NULL) { + prev = r; + } + r = r->next; + } + if (oldest != NULL) { + pbufs_freed_current = ip_reass_free_complete_datagram(oldest, prev); + pbufs_freed += pbufs_freed_current; + } + } while ((pbufs_freed < pbufs_needed) && (other_datagrams > 1)); + return pbufs_freed; +} +#endif /* IP_REASS_FREE_OLDEST */ + +/** + * Enqueues a new fragment into the fragment queue + * @param fraghdr points to the new fragments IP hdr + * @param clen number of pbufs needed to enqueue (used for freeing other datagrams if not enough space) + * @return A pointer to the queue location into which the fragment was enqueued + */ +static struct ip_reassdata* +ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen) +{ + struct ip_reassdata* ipr; + /* No matching previous fragment found, allocate a new reassdata struct */ + ipr = (struct ip_reassdata *)memp_malloc(MEMP_REASSDATA); + if (ipr == NULL) { +#if IP_REASS_FREE_OLDEST + if (ip_reass_remove_oldest_datagram(fraghdr, clen) >= clen) { + ipr = (struct ip_reassdata *)memp_malloc(MEMP_REASSDATA); + } + if (ipr == NULL) +#endif /* IP_REASS_FREE_OLDEST */ + { + IPFRAG_STATS_INC(ip_frag.memerr); + LWIP_DEBUGF(IP_REASS_DEBUG,("Failed to alloc reassdata struct\n")); + return NULL; + } + } + memset(ipr, 0, sizeof(struct ip_reassdata)); + ipr->timer = IP_REASS_MAXAGE; + + /* enqueue the new structure to the front of the list */ + ipr->next = reassdatagrams; + reassdatagrams = ipr; + /* copy the ip header for later tests and input */ + /* @todo: no ip options supported? */ + SMEMCPY(&(ipr->iphdr), fraghdr, IP_HLEN); + return ipr; +} + +/** + * Dequeues a datagram from the datagram queue. Doesn't deallocate the pbufs. + * @param ipr points to the queue entry to dequeue + */ +static void +ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) +{ + + /* dequeue the reass struct */ + if (reassdatagrams == ipr) { + /* it was the first in the list */ + reassdatagrams = ipr->next; + } else { + /* it wasn't the first, so it must have a valid 'prev' */ + LWIP_ASSERT("sanity check linked list", prev != NULL); + prev->next = ipr->next; + } + + /* now we can free the ip_reass struct */ + memp_free(MEMP_REASSDATA, ipr); +} + +/** + * Chain a new pbuf into the pbuf list that composes the datagram. The pbuf list + * will grow over time as new pbufs are rx. + * Also checks that the datagram passes basic continuity checks (if the last + * fragment was received at least once). + * @param root_p points to the 'root' pbuf for the current datagram being assembled. + * @param new_p points to the pbuf for the current fragment + * @return 0 if invalid, >0 otherwise + */ +static int +ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct pbuf *new_p) +{ + struct ip_reass_helper *iprh, *iprh_tmp, *iprh_prev=NULL; + struct pbuf *q; + u16_t offset,len; + struct ip_hdr *fraghdr; + int valid = 1; + + /* Extract length and fragment offset from current fragment */ + fraghdr = (struct ip_hdr*)new_p->payload; + len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; + offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; + + /* overwrite the fragment's ip header from the pbuf with our helper struct, + * and setup the embedded helper structure. */ + /* make sure the struct ip_reass_helper fits into the IP header */ + LWIP_ASSERT("sizeof(struct ip_reass_helper) <= IP_HLEN", + sizeof(struct ip_reass_helper) <= IP_HLEN); + iprh = (struct ip_reass_helper*)new_p->payload; + iprh->next_pbuf = NULL; + iprh->start = offset; + iprh->end = offset + len; + + /* Iterate through until we either get to the end of the list (append), + * or we find on with a larger offset (insert). */ + for (q = ipr->p; q != NULL;) { + iprh_tmp = (struct ip_reass_helper*)q->payload; + if (iprh->start < iprh_tmp->start) { + /* the new pbuf should be inserted before this */ + iprh->next_pbuf = q; + if (iprh_prev != NULL) { + /* not the fragment with the lowest offset */ +#if IP_REASS_CHECK_OVERLAP + if ((iprh->start < iprh_prev->end) || (iprh->end > iprh_tmp->start)) { + /* fragment overlaps with previous or following, throw away */ + goto freepbuf; + } +#endif /* IP_REASS_CHECK_OVERLAP */ + iprh_prev->next_pbuf = new_p; + } else { + /* fragment with the lowest offset */ + ipr->p = new_p; + } + break; + } else if(iprh->start == iprh_tmp->start) { + /* received the same datagram twice: no need to keep the datagram */ + goto freepbuf; +#if IP_REASS_CHECK_OVERLAP + } else if(iprh->start < iprh_tmp->end) { + /* overlap: no need to keep the new datagram */ + goto freepbuf; +#endif /* IP_REASS_CHECK_OVERLAP */ + } else { + /* Check if the fragments received so far have no wholes. */ + if (iprh_prev != NULL) { + if (iprh_prev->end != iprh_tmp->start) { + /* There is a fragment missing between the current + * and the previous fragment */ + valid = 0; + } + } + } + q = iprh_tmp->next_pbuf; + iprh_prev = iprh_tmp; + } + + /* If q is NULL, then we made it to the end of the list. Determine what to do now */ + if (q == NULL) { + if (iprh_prev != NULL) { + /* this is (for now), the fragment with the highest offset: + * chain it to the last fragment */ +#if IP_REASS_CHECK_OVERLAP + LWIP_ASSERT("check fragments don't overlap", iprh_prev->end <= iprh->start); +#endif /* IP_REASS_CHECK_OVERLAP */ + iprh_prev->next_pbuf = new_p; + if (iprh_prev->end != iprh->start) { + valid = 0; + } + } else { +#if IP_REASS_CHECK_OVERLAP + LWIP_ASSERT("no previous fragment, this must be the first fragment!", + ipr->p == NULL); +#endif /* IP_REASS_CHECK_OVERLAP */ + /* this is the first fragment we ever received for this ip datagram */ + ipr->p = new_p; + } + } + + /* At this point, the validation part begins: */ + /* If we already received the last fragment */ + if ((ipr->flags & IP_REASS_FLAG_LASTFRAG) != 0) { + /* and had no wholes so far */ + if (valid) { + /* then check if the rest of the fragments is here */ + /* Check if the queue starts with the first datagram */ + if (((struct ip_reass_helper*)ipr->p->payload)->start != 0) { + valid = 0; + } else { + /* and check that there are no wholes after this datagram */ + iprh_prev = iprh; + q = iprh->next_pbuf; + while (q != NULL) { + iprh = (struct ip_reass_helper*)q->payload; + if (iprh_prev->end != iprh->start) { + valid = 0; + break; + } + iprh_prev = iprh; + q = iprh->next_pbuf; + } + /* if still valid, all fragments are received + * (because to the MF==0 already arrived */ + if (valid) { + LWIP_ASSERT("sanity check", ipr->p != NULL); + LWIP_ASSERT("sanity check", + ((struct ip_reass_helper*)ipr->p->payload) != iprh); + LWIP_ASSERT("validate_datagram:next_pbuf!=NULL", + iprh->next_pbuf == NULL); + LWIP_ASSERT("validate_datagram:datagram end!=datagram len", + iprh->end == ipr->datagram_len); + } + } + } + /* If valid is 0 here, there are some fragments missing in the middle + * (since MF == 0 has already arrived). Such datagrams simply time out if + * no more fragments are received... */ + return valid; + } + /* If we come here, not all fragments were received, yet! */ + return 0; /* not yet valid! */ +#if IP_REASS_CHECK_OVERLAP +freepbuf: + ip_reass_pbufcount -= pbuf_clen(new_p); + pbuf_free(new_p); + return 0; +#endif /* IP_REASS_CHECK_OVERLAP */ +} + +/** + * Reassembles incoming IP fragments into an IP datagram. + * + * @param p points to a pbuf chain of the fragment + * @return NULL if reassembly is incomplete, ? otherwise + */ +struct pbuf * +ip_reass(struct pbuf *p) +{ + struct pbuf *r; + struct ip_hdr *fraghdr; + struct ip_reassdata *ipr; + struct ip_reass_helper *iprh; + u16_t offset, len; + u8_t clen; + struct ip_reassdata *ipr_prev = NULL; + + IPFRAG_STATS_INC(ip_frag.recv); + snmp_inc_ipreasmreqds(); + + fraghdr = (struct ip_hdr*)p->payload; + + if ((IPH_HL(fraghdr) * 4) != IP_HLEN) { + LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: IP options currently not supported!\n")); + IPFRAG_STATS_INC(ip_frag.err); + goto nullreturn; + } + + offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; + len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; + + /* Check if we are allowed to enqueue more datagrams. */ + clen = pbuf_clen(p); + if ((ip_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS) { +#if IP_REASS_FREE_OLDEST + if (!ip_reass_remove_oldest_datagram(fraghdr, clen) || + ((ip_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS)) +#endif /* IP_REASS_FREE_OLDEST */ + { + /* No datagram could be freed and still too many pbufs enqueued */ + LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: Overflow condition: pbufct=%d, clen=%d, MAX=%d\n", + ip_reass_pbufcount, clen, IP_REASS_MAX_PBUFS)); + IPFRAG_STATS_INC(ip_frag.memerr); + /* @todo: send ICMP time exceeded here? */ + /* drop this pbuf */ + goto nullreturn; + } + } + + /* Look for the datagram the fragment belongs to in the current datagram queue, + * remembering the previous in the queue for later dequeueing. */ + for (ipr = reassdatagrams; ipr != NULL; ipr = ipr->next) { + /* Check if the incoming fragment matches the one currently present + in the reassembly buffer. If so, we proceed with copying the + fragment into the buffer. */ + if (IP_ADDRESSES_AND_ID_MATCH(&ipr->iphdr, fraghdr)) { + LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching previous fragment ID=%"X16_F"\n", + ntohs(IPH_ID(fraghdr)))); + IPFRAG_STATS_INC(ip_frag.cachehit); + break; + } + ipr_prev = ipr; + } + + if (ipr == NULL) { + /* Enqueue a new datagram into the datagram queue */ + ipr = ip_reass_enqueue_new_datagram(fraghdr, clen); + /* Bail if unable to enqueue */ + if(ipr == NULL) { + goto nullreturn; + } + } else { + if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && + ((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { + /* ipr->iphdr is not the header from the first fragment, but fraghdr is + * -> copy fraghdr into ipr->iphdr since we want to have the header + * of the first fragment (for ICMP time exceeded and later, for copying + * all options, if supported)*/ + SMEMCPY(&ipr->iphdr, fraghdr, IP_HLEN); + } + } + /* Track the current number of pbufs current 'in-flight', in order to limit + the number of fragments that may be enqueued at any one time */ + ip_reass_pbufcount += clen; + + /* At this point, we have either created a new entry or pointing + * to an existing one */ + + /* check for 'no more fragments', and update queue entry*/ + if ((IPH_OFFSET(fraghdr) & PP_NTOHS(IP_MF)) == 0) { + ipr->flags |= IP_REASS_FLAG_LASTFRAG; + ipr->datagram_len = offset + len; + LWIP_DEBUGF(IP_REASS_DEBUG, + ("ip_reass: last fragment seen, total len %"S16_F"\n", + ipr->datagram_len)); + } + /* find the right place to insert this pbuf */ + /* @todo: trim pbufs if fragments are overlapping */ + if (ip_reass_chain_frag_into_datagram_and_validate(ipr, p)) { + /* the totally last fragment (flag more fragments = 0) was received at least + * once AND all fragments are received */ + ipr->datagram_len += IP_HLEN; + + /* save the second pbuf before copying the header over the pointer */ + r = ((struct ip_reass_helper*)ipr->p->payload)->next_pbuf; + + /* copy the original ip header back to the first pbuf */ + fraghdr = (struct ip_hdr*)(ipr->p->payload); + SMEMCPY(fraghdr, &ipr->iphdr, IP_HLEN); + IPH_LEN_SET(fraghdr, htons(ipr->datagram_len)); + IPH_OFFSET_SET(fraghdr, 0); + IPH_CHKSUM_SET(fraghdr, 0); + /* @todo: do we need to set calculate the correct checksum? */ + IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN)); + + p = ipr->p; + + /* chain together the pbufs contained within the reass_data list. */ + while(r != NULL) { + iprh = (struct ip_reass_helper*)r->payload; + + /* hide the ip header for every succeding fragment */ + pbuf_header(r, -IP_HLEN); + pbuf_cat(p, r); + r = iprh->next_pbuf; + } + /* release the sources allocate for the fragment queue entry */ + ip_reass_dequeue_datagram(ipr, ipr_prev); + + /* and adjust the number of pbufs currently queued for reassembly. */ + ip_reass_pbufcount -= pbuf_clen(p); + + /* Return the pbuf chain */ + return p; + } + /* the datagram is not (yet?) reassembled completely */ + LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass_pbufcount: %d out\n", ip_reass_pbufcount)); + return NULL; + +nullreturn: + LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: nullreturn\n")); + IPFRAG_STATS_INC(ip_frag.drop); + pbuf_free(p); + return NULL; +} +#endif /* IP_REASSEMBLY */ + +#if IP_FRAG +#if IP_FRAG_USES_STATIC_BUF +static u8_t buf[LWIP_MEM_ALIGN_SIZE(IP_FRAG_MAX_MTU + MEM_ALIGNMENT - 1)]; +#else /* IP_FRAG_USES_STATIC_BUF */ + +#if !LWIP_NETIF_TX_SINGLE_PBUF +/** Allocate a new struct pbuf_custom_ref */ +static struct pbuf_custom_ref* +ip_frag_alloc_pbuf_custom_ref(void) +{ + return (struct pbuf_custom_ref*)memp_malloc(MEMP_FRAG_PBUF); +} + +/** Free a struct pbuf_custom_ref */ +static void +ip_frag_free_pbuf_custom_ref(struct pbuf_custom_ref* p) +{ + LWIP_ASSERT("p != NULL", p != NULL); + memp_free(MEMP_FRAG_PBUF, p); +} + +/** Free-callback function to free a 'struct pbuf_custom_ref', called by + * pbuf_free. */ +static void +ipfrag_free_pbuf_custom(struct pbuf *p) +{ + struct pbuf_custom_ref *pcr = (struct pbuf_custom_ref*)p; + LWIP_ASSERT("pcr != NULL", pcr != NULL); + LWIP_ASSERT("pcr == p", (void*)pcr == (void*)p); + if (pcr->original != NULL) { + pbuf_free(pcr->original); + } + ip_frag_free_pbuf_custom_ref(pcr); +} +#endif /* !LWIP_NETIF_TX_SINGLE_PBUF */ +#endif /* IP_FRAG_USES_STATIC_BUF */ + +/** + * Fragment an IP datagram if too large for the netif. + * + * Chop the datagram in MTU sized chunks and send them in order + * by using a fixed size static memory buffer (PBUF_REF) or + * point PBUF_REFs into p (depending on IP_FRAG_USES_STATIC_BUF). + * + * @param p ip packet to send + * @param netif the netif on which to send + * @param dest destination ip address to which to send + * + * @return ERR_OK if sent successfully, err_t otherwise + */ +err_t +ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) +{ + struct pbuf *rambuf; +#if IP_FRAG_USES_STATIC_BUF + struct pbuf *header; +#else +#if !LWIP_NETIF_TX_SINGLE_PBUF + struct pbuf *newpbuf; +#endif + struct ip_hdr *original_iphdr; +#endif + struct ip_hdr *iphdr; + u16_t nfb; + u16_t left, cop; + u16_t mtu = netif->mtu; + u16_t ofo, omf; + u16_t last; + u16_t poff = IP_HLEN; + u16_t tmp; +#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF + u16_t newpbuflen = 0; + u16_t left_to_copy; +#endif + + /* Get a RAM based MTU sized pbuf */ +#if IP_FRAG_USES_STATIC_BUF + /* When using a static buffer, we use a PBUF_REF, which we will + * use to reference the packet (without link header). + * Layer and length is irrelevant. + */ + rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF); + if (rambuf == NULL) { + LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc(PBUF_LINK, 0, PBUF_REF) failed\n")); + return ERR_MEM; + } + rambuf->tot_len = rambuf->len = mtu; + rambuf->payload = LWIP_MEM_ALIGN((void *)buf); + + /* Copy the IP header in it */ + iphdr = (struct ip_hdr *)rambuf->payload; + SMEMCPY(iphdr, p->payload, IP_HLEN); +#else /* IP_FRAG_USES_STATIC_BUF */ + original_iphdr = (struct ip_hdr *)p->payload; + iphdr = original_iphdr; +#endif /* IP_FRAG_USES_STATIC_BUF */ + + /* Save original offset */ + tmp = ntohs(IPH_OFFSET(iphdr)); + ofo = tmp & IP_OFFMASK; + omf = tmp & IP_MF; + + left = p->tot_len - IP_HLEN; + + nfb = (mtu - IP_HLEN) / 8; + + while (left) { + last = (left <= mtu - IP_HLEN); + + /* Set new offset and MF flag */ + tmp = omf | (IP_OFFMASK & (ofo)); + if (!last) { + tmp = tmp | IP_MF; + } + + /* Fill this fragment */ + cop = last ? left : nfb * 8; + +#if IP_FRAG_USES_STATIC_BUF + poff += pbuf_copy_partial(p, (u8_t*)iphdr + IP_HLEN, cop, poff); +#else /* IP_FRAG_USES_STATIC_BUF */ +#if LWIP_NETIF_TX_SINGLE_PBUF + rambuf = pbuf_alloc(PBUF_IP, cop, PBUF_RAM); + if (rambuf == NULL) { + return ERR_MEM; + } + LWIP_ASSERT("this needs a pbuf in one piece!", + (rambuf->len == rambuf->tot_len) && (rambuf->next == NULL)); + poff += pbuf_copy_partial(p, rambuf->payload, cop, poff); + /* make room for the IP header */ + if(pbuf_header(rambuf, IP_HLEN)) { + pbuf_free(rambuf); + return ERR_MEM; + } + /* fill in the IP header */ + SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); + iphdr = rambuf->payload; +#else /* LWIP_NETIF_TX_SINGLE_PBUF */ + /* When not using a static buffer, create a chain of pbufs. + * The first will be a PBUF_RAM holding the link and IP header. + * The rest will be PBUF_REFs mirroring the pbuf chain to be fragged, + * but limited to the size of an mtu. + */ + rambuf = pbuf_alloc(PBUF_LINK, IP_HLEN, PBUF_RAM); + if (rambuf == NULL) { + return ERR_MEM; + } + LWIP_ASSERT("this needs a pbuf in one piece!", + (p->len >= (IP_HLEN))); + SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); + iphdr = (struct ip_hdr *)rambuf->payload; + + /* Can just adjust p directly for needed offset. */ + p->payload = (u8_t *)p->payload + poff; + p->len -= poff; + + left_to_copy = cop; + while (left_to_copy) { + struct pbuf_custom_ref *pcr; + newpbuflen = (left_to_copy < p->len) ? left_to_copy : p->len; + /* Is this pbuf already empty? */ + if (!newpbuflen) { + p = p->next; + continue; + } + pcr = ip_frag_alloc_pbuf_custom_ref(); + if (pcr == NULL) { + pbuf_free(rambuf); + return ERR_MEM; + } + /* Mirror this pbuf, although we might not need all of it. */ + newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc, p->payload, newpbuflen); + if (newpbuf == NULL) { + ip_frag_free_pbuf_custom_ref(pcr); + pbuf_free(rambuf); + return ERR_MEM; + } + pbuf_ref(p); + pcr->original = p; + pcr->pc.custom_free_function = ipfrag_free_pbuf_custom; + + /* Add it to end of rambuf's chain, but using pbuf_cat, not pbuf_chain + * so that it is removed when pbuf_dechain is later called on rambuf. + */ + pbuf_cat(rambuf, newpbuf); + left_to_copy -= newpbuflen; + if (left_to_copy) { + p = p->next; + } + } + poff = newpbuflen; +#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ +#endif /* IP_FRAG_USES_STATIC_BUF */ + + /* Correct header */ + IPH_OFFSET_SET(iphdr, htons(tmp)); + IPH_LEN_SET(iphdr, htons(cop + IP_HLEN)); + IPH_CHKSUM_SET(iphdr, 0); + IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); + +#if IP_FRAG_USES_STATIC_BUF + if (last) { + pbuf_realloc(rambuf, left + IP_HLEN); + } + + /* This part is ugly: we alloc a RAM based pbuf for + * the link level header for each chunk and then + * free it.A PBUF_ROM style pbuf for which pbuf_header + * worked would make things simpler. + */ + header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); + if (header != NULL) { + pbuf_chain(header, rambuf); + netif->output(netif, header, dest); + IPFRAG_STATS_INC(ip_frag.xmit); + snmp_inc_ipfragcreates(); + pbuf_free(header); + } else { + LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc() for header failed\n")); + pbuf_free(rambuf); + return ERR_MEM; + } +#else /* IP_FRAG_USES_STATIC_BUF */ + /* No need for separate header pbuf - we allowed room for it in rambuf + * when allocated. + */ + netif->output(netif, rambuf, dest); + IPFRAG_STATS_INC(ip_frag.xmit); + + /* Unfortunately we can't reuse rambuf - the hardware may still be + * using the buffer. Instead we free it (and the ensuing chain) and + * recreate it next time round the loop. If we're lucky the hardware + * will have already sent the packet, the free will really free, and + * there will be zero memory penalty. + */ + + pbuf_free(rambuf); +#endif /* IP_FRAG_USES_STATIC_BUF */ + left -= cop; + ofo += nfb; + } +#if IP_FRAG_USES_STATIC_BUF + pbuf_free(rambuf); +#endif /* IP_FRAG_USES_STATIC_BUF */ + snmp_inc_ipfragoks(); + return ERR_OK; +} +#endif /* IP_FRAG */ diff --git a/user/mpy/lib/lwip/src/core/ipv6/README b/user/mpy/lib/lwip/src/core/ipv6/README new file mode 100644 index 0000000..3620004 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv6/README @@ -0,0 +1 @@ +IPv6 support in lwIP is very experimental. diff --git a/user/mpy/lib/lwip/src/core/ipv6/icmp6.c b/user/mpy/lib/lwip/src/core/ipv6/icmp6.c new file mode 100644 index 0000000..4fcc895 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv6/icmp6.c @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +/* Some ICMP messages should be passed to the transport protocols. This + is not implemented. */ + +#include "lwip/opt.h" + +#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/icmp.h" +#include "lwip/inet.h" +#include "lwip/ip.h" +#include "lwip/def.h" +#include "lwip/stats.h" + +void +icmp_input(struct pbuf *p, struct netif *inp) +{ + u8_t type; + struct icmp_echo_hdr *iecho; + struct ip_hdr *iphdr; + struct ip_addr tmpaddr; + + ICMP_STATS_INC(icmp.recv); + + /* TODO: check length before accessing payload! */ + + type = ((u8_t *)p->payload)[0]; + + switch (type) { + case ICMP6_ECHO: + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); + + if (p->tot_len < sizeof(struct icmp_echo_hdr)) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); + + pbuf_free(p); + ICMP_STATS_INC(icmp.lenerr); + return; + } + iecho = p->payload; + iphdr = (struct ip_hdr *)((u8_t *)p->payload - IP_HLEN); + if (inet_chksum_pbuf(p) != 0) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); + ICMP_STATS_INC(icmp.chkerr); + /* return;*/ + } + LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %"S16_F" p->tot_len %"S16_F"\n", p->len, p->tot_len)); + ip_addr_set(&tmpaddr, &(iphdr->src)); + ip_addr_set(&(iphdr->src), &(iphdr->dest)); + ip_addr_set(&(iphdr->dest), &tmpaddr); + iecho->type = ICMP6_ER; + /* adjust the checksum */ + if (iecho->chksum >= htons(0xffff - (ICMP6_ECHO << 8))) { + iecho->chksum += htons(ICMP6_ECHO << 8) + 1; + } else { + iecho->chksum += htons(ICMP6_ECHO << 8); + } + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); + ICMP_STATS_INC(icmp.xmit); + + /* LWIP_DEBUGF("icmp: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/ + ip_output_if (p, &(iphdr->src), IP_HDRINCL, + iphdr->hoplim, IP_PROTO_ICMP, inp); + break; + default: + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" not supported.\n", (s16_t)type)); + ICMP_STATS_INC(icmp.proterr); + ICMP_STATS_INC(icmp.drop); + } + + pbuf_free(p); +} + +void +icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) +{ + struct pbuf *q; + struct ip_hdr *iphdr; + struct icmp_dur_hdr *idur; + + /* @todo: can this be PBUF_LINK instead of PBUF_IP? */ + q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); + /* ICMP header + IP header + 8 bytes of data */ + if (q == NULL) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_dest_unreach: failed to allocate pbuf for ICMP packet.\n")); + pbuf_free(p); + return; + } + LWIP_ASSERT("check that first pbuf can hold icmp message", + (q->len >= (8 + IP_HLEN + 8))); + + iphdr = p->payload; + + idur = q->payload; + idur->type = (u8_t)ICMP6_DUR; + idur->icode = (u8_t)t; + + SMEMCPY((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8); + + /* calculate checksum */ + idur->chksum = 0; + idur->chksum = inet_chksum(idur, q->len); + ICMP_STATS_INC(icmp.xmit); + + ip_output(q, NULL, + (struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP); + pbuf_free(q); +} + +void +icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) +{ + struct pbuf *q; + struct ip_hdr *iphdr; + struct icmp_te_hdr *tehdr; + + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded\n")); + + /* @todo: can this be PBUF_LINK instead of PBUF_IP? */ + q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); + /* ICMP header + IP header + 8 bytes of data */ + if (q == NULL) { + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_dest_unreach: failed to allocate pbuf for ICMP packet.\n")); + pbuf_free(p); + return; + } + LWIP_ASSERT("check that first pbuf can hold icmp message", + (q->len >= (8 + IP_HLEN + 8))); + + iphdr = p->payload; + + tehdr = q->payload; + tehdr->type = (u8_t)ICMP6_TE; + tehdr->icode = (u8_t)t; + + /* copy fields from original packet */ + SMEMCPY((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8); + + /* calculate checksum */ + tehdr->chksum = 0; + tehdr->chksum = inet_chksum(tehdr, q->len); + ICMP_STATS_INC(icmp.xmit); + ip_output(q, NULL, + (struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP); + pbuf_free(q); +} + +#endif /* LWIP_ICMP */ diff --git a/user/mpy/lib/lwip/src/core/ipv6/inet6.c b/user/mpy/lib/lwip/src/core/ipv6/inet6.c new file mode 100644 index 0000000..c3de85c --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv6/inet6.c @@ -0,0 +1,163 @@ +/** + * @file + * Functions common to all TCP/IPv6 modules, such as the Internet checksum and the + * byte order functions. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/def.h" +#include "lwip/inet.h" + +/* chksum: + * + * Sums up all 16 bit words in a memory portion. Also includes any odd byte. + * This function is used by the other checksum functions. + * + * For now, this is not optimized. Must be optimized for the particular processor + * arcitecture on which it is to run. Preferebly coded in assembler. + */ + +static u32_t +chksum(void *dataptr, u16_t len) +{ + u16_t *sdataptr = dataptr; + u32_t acc; + + + for(acc = 0; len > 1; len -= 2) { + acc += *sdataptr++; + } + + /* add up any odd byte */ + if (len == 1) { + acc += htons((u16_t)(*(u8_t *)dataptr) << 8); + } + + return acc; + +} + +/* inet_chksum_pseudo: + * + * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. + */ + +u16_t +inet_chksum_pseudo(struct pbuf *p, + struct ip_addr *src, struct ip_addr *dest, + u8_t proto, u32_t proto_len) +{ + u32_t acc; + struct pbuf *q; + u8_t swapped, i; + + acc = 0; + swapped = 0; + for(q = p; q != NULL; q = q->next) { + acc += chksum(q->payload, q->len); + while (acc >> 16) { + acc = (acc & 0xffff) + (acc >> 16); + } + if (q->len % 2 != 0) { + swapped = 1 - swapped; + acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); + } + } + + if (swapped) { + acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); + } + + for(i = 0; i < 8; i++) { + acc += ((u16_t *)src->addr)[i] & 0xffff; + acc += ((u16_t *)dest->addr)[i] & 0xffff; + while (acc >> 16) { + acc = (acc & 0xffff) + (acc >> 16); + } + } + acc += (u16_t)htons((u16_t)proto); + acc += ((u16_t *)&proto_len)[0] & 0xffff; + acc += ((u16_t *)&proto_len)[1] & 0xffff; + + while (acc >> 16) { + acc = (acc & 0xffff) + (acc >> 16); + } + return ~(acc & 0xffff); +} + +/* inet_chksum: + * + * Calculates the Internet checksum over a portion of memory. Used primarely for IP + * and ICMP. + */ + +u16_t +inet_chksum(void *dataptr, u16_t len) +{ + u32_t acc, sum; + + acc = chksum(dataptr, len); + sum = (acc & 0xffff) + (acc >> 16); + sum += (sum >> 16); + return ~(sum & 0xffff); +} + +u16_t +inet_chksum_pbuf(struct pbuf *p) +{ + u32_t acc; + struct pbuf *q; + u8_t swapped; + + acc = 0; + swapped = 0; + for(q = p; q != NULL; q = q->next) { + acc += chksum(q->payload, q->len); + while (acc >> 16) { + acc = (acc & 0xffff) + (acc >> 16); + } + if (q->len % 2 != 0) { + swapped = 1 - swapped; + acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8); + } + } + + if (swapped) { + acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); + } + return ~(acc & 0xffff); +} diff --git a/user/mpy/lib/lwip/src/core/ipv6/ip6.c b/user/mpy/lib/lwip/src/core/ipv6/ip6.c new file mode 100644 index 0000000..ad59b72 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv6/ip6.c @@ -0,0 +1,397 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + + + +/* ip.c + * + * This is the code for the IP layer for IPv6. + * + */ + + +#include "lwip/opt.h" + +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/ip.h" +#include "lwip/inet.h" +#include "lwip/netif.h" +#include "lwip/icmp.h" +#include "lwip/udp.h" +#include "lwip/tcp_impl.h" + +#include "lwip/stats.h" + +#include "arch/perf.h" + +/* ip_init: + * + * Initializes the IP layer. + */ + +void +ip_init(void) +{ +} + +/* ip_route: + * + * Finds the appropriate network interface for a given IP address. It searches the + * list of network interfaces linearly. A match is found if the masked IP address of + * the network interface equals the masked IP address given to the function. + */ + +struct netif * +ip_route(struct ip_addr *dest) +{ + struct netif *netif; + + for(netif = netif_list; netif != NULL; netif = netif->next) { + if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { + return netif; + } + } + + return netif_default; +} + +/* ip_forward: + * + * Forwards an IP packet. It finds an appropriate route for the packet, decrements + * the TTL value of the packet, adjusts the checksum and outputs the packet on the + * appropriate interface. + */ + +static void +ip_forward(struct pbuf *p, struct ip_hdr *iphdr) +{ + struct netif *netif; + + PERF_START; + + if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) { + + LWIP_DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for ")); +#if IP_DEBUG + ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); +#endif /* IP_DEBUG */ + LWIP_DEBUGF(IP_DEBUG, ("\n")); + pbuf_free(p); + return; + } + /* Decrement TTL and send ICMP if ttl == 0. */ + if (--iphdr->hoplim == 0) { +#if LWIP_ICMP + /* Don't send ICMP messages in response to ICMP messages */ + if (iphdr->nexthdr != IP_PROTO_ICMP) { + icmp_time_exceeded(p, ICMP_TE_TTL); + } +#endif /* LWIP_ICMP */ + pbuf_free(p); + return; + } + + /* Incremental update of the IP checksum. */ + /* if (iphdr->chksum >= htons(0xffff - 0x100)) { + iphdr->chksum += htons(0x100) + 1; + } else { + iphdr->chksum += htons(0x100); + }*/ + + + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to ")); +#if IP_DEBUG + ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); +#endif /* IP_DEBUG */ + LWIP_DEBUGF(IP_DEBUG, ("\n")); + + IP_STATS_INC(ip.fw); + IP_STATS_INC(ip.xmit); + + PERF_STOP("ip_forward"); + + netif->output(netif, p, (struct ip_addr *)&(iphdr->dest)); +} + +/* ip_input: + * + * This function is called by the network interface device driver when an IP packet is + * received. The function does the basic checks of the IP header such as packet size + * being at least larger than the header size etc. If the packet was not destined for + * us, the packet is forwarded (using ip_forward). The IP checksum is always checked. + * + * Finally, the packet is sent to the upper layer protocol input function. + */ + +void +ip_input(struct pbuf *p, struct netif *inp) { + struct ip_hdr *iphdr; + struct netif *netif; + + + PERF_START; + +#if IP_DEBUG + ip_debug_print(p); +#endif /* IP_DEBUG */ + + + IP_STATS_INC(ip.recv); + + /* identify the IP header */ + iphdr = p->payload; + + + if (iphdr->v != 6) { + LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); +#if IP_DEBUG + ip_debug_print(p); +#endif /* IP_DEBUG */ + pbuf_free(p); + IP_STATS_INC(ip.err); + IP_STATS_INC(ip.drop); + return; + } + + /* is this packet for us? */ + for(netif = netif_list; netif != NULL; netif = netif->next) { +#if IP_DEBUG + LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest ")); + ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); + LWIP_DEBUGF(IP_DEBUG, ("netif->ip_addr ")); + ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); + LWIP_DEBUGF(IP_DEBUG, ("\n")); +#endif /* IP_DEBUG */ + if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) { + break; + } + } + + + if (netif == NULL) { + /* packet not for us, route or discard */ +#if IP_FORWARD + ip_forward(p, iphdr); +#endif + pbuf_free(p); + return; + } + + pbuf_realloc(p, IP_HLEN + ntohs(iphdr->len)); + + /* send to upper layers */ +#if IP_DEBUG + /* LWIP_DEBUGF("ip_input: \n"); + ip_debug_print(p); + LWIP_DEBUGF("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/ +#endif /* IP_DEBUG */ + + if(pbuf_header(p, -IP_HLEN)) { + LWIP_ASSERT("Can't move over header in packet", 0); + return; + } + + switch (iphdr->nexthdr) { + case IP_PROTO_UDP: + udp_input(p, inp); + break; + case IP_PROTO_TCP: + tcp_input(p, inp); + break; +#if LWIP_ICMP + case IP_PROTO_ICMP: + icmp_input(p, inp); + break; +#endif /* LWIP_ICMP */ + default: +#if LWIP_ICMP + /* send ICMP destination protocol unreachable */ + icmp_dest_unreach(p, ICMP_DUR_PROTO); +#endif /* LWIP_ICMP */ + pbuf_free(p); + LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n", + iphdr->nexthdr)); + + IP_STATS_INC(ip.proterr); + IP_STATS_INC(ip.drop); + } + PERF_STOP("ip_input"); +} + + +/* ip_output_if: + * + * Sends an IP packet on a network interface. This function constructs the IP header + * and calculates the IP header checksum. If the source IP address is NULL, + * the IP address of the outgoing network interface is filled in as source address. + */ + +err_t +ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, + u8_t ttl, + u8_t proto, struct netif *netif) +{ + struct ip_hdr *iphdr; + + PERF_START; + + LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len)); + if (pbuf_header(p, IP_HLEN)) { + LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); + IP_STATS_INC(ip.err); + + return ERR_BUF; + } + LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len)); + + iphdr = p->payload; + + + if (dest != IP_HDRINCL) { + LWIP_DEBUGF(IP_DEBUG, ("!IP_HDRLINCL\n")); + iphdr->hoplim = ttl; + iphdr->nexthdr = proto; + iphdr->len = htons(p->tot_len - IP_HLEN); + ip_addr_set(&(iphdr->dest), dest); + + iphdr->v = 6; + + if (ip_addr_isany(src)) { + ip_addr_set(&(iphdr->src), &(netif->ip_addr)); + } else { + ip_addr_set(&(iphdr->src), src); + } + + } else { + dest = &(iphdr->dest); + } + + IP_STATS_INC(ip.xmit); + + LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %"U16_F")\n", netif->name[0], netif->name[1], p->tot_len)); +#if IP_DEBUG + ip_debug_print(p); +#endif /* IP_DEBUG */ + + PERF_STOP("ip_output_if"); + return netif->output(netif, p, dest); +} + +/* ip_output: + * + * Simple interface to ip_output_if. It finds the outgoing network interface and + * calls upon ip_output_if to do the actual work. + */ + +err_t +ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, + u8_t ttl, u8_t proto) +{ + struct netif *netif; + if ((netif = ip_route(dest)) == NULL) { + LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr)); + IP_STATS_INC(ip.rterr); + return ERR_RTE; + } + + return ip_output_if (p, src, dest, ttl, proto, netif); +} + +#if LWIP_NETIF_HWADDRHINT +err_t +ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, + u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint) +{ + struct netif *netif; + err_t err; + + if ((netif = ip_route(dest)) == NULL) { + LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr)); + IP_STATS_INC(ip.rterr); + return ERR_RTE; + } + + LWIP_NETIF_HWADDRHINT(netif, addr_hint); + err = ip_output_if(p, src, dest, ttl, tos, proto, netif); + LWIP_NETIF_HWADDRHINT(netif, NULL); + + return err; +} +#endif /* LWIP_NETIF_HWADDRHINT*/ + +#if IP_DEBUG +void +ip_debug_print(struct pbuf *p) +{ + struct ip_hdr *iphdr = p->payload; + + LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" | %"X16_F"%"X16_F" | %"X16_F"%"X16_F" | (v, traffic class, flow label)\n", + iphdr->v, + iphdr->tclass1, iphdr->tclass2, + iphdr->flow1, iphdr->flow2)); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" | %2"U16_F" | %2"U16_F" | (len, nexthdr, hoplim)\n", + ntohs(iphdr->len), + iphdr->nexthdr, + iphdr->hoplim)); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", + (ntohl(iphdr->src.addr[0]) >> 16) & 0xffff, + ntohl(iphdr->src.addr[0]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", + (ntohl(iphdr->src.addr[1]) >> 16) & 0xffff, + ntohl(iphdr->src.addr[1]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", + (ntohl(iphdr->src.addr[2]) >> 16) & 0xffff, + ntohl(iphdr->src.addr[2]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", + (ntohl(iphdr->src.addr[3]) >> 16) & 0xffff, + ntohl(iphdr->src.addr[3]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", + (ntohl(iphdr->dest.addr[0]) >> 16) & 0xffff, + ntohl(iphdr->dest.addr[0]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", + (ntohl(iphdr->dest.addr[1]) >> 16) & 0xffff, + ntohl(iphdr->dest.addr[1]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", + (ntohl(iphdr->dest.addr[2]) >> 16) & 0xffff, + ntohl(iphdr->dest.addr[2]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", + (ntohl(iphdr->dest.addr[3]) >> 16) & 0xffff, + ntohl(iphdr->dest.addr[3]) & 0xffff)); + LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); +} +#endif /* IP_DEBUG */ diff --git a/user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c b/user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c new file mode 100644 index 0000000..2da6cea --- /dev/null +++ b/user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/inet.h" + +u8_t +ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, + struct ip_addr *mask) +{ + return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) && + (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) && + (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) && + (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3])); + +} + +u8_t +ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2) +{ + return(addr1->addr[0] == addr2->addr[0] && + addr1->addr[1] == addr2->addr[1] && + addr1->addr[2] == addr2->addr[2] && + addr1->addr[3] == addr2->addr[3]); +} + +void +ip_addr_set(struct ip_addr *dest, struct ip_addr *src) +{ + SMEMCPY(dest, src, sizeof(struct ip_addr)); + /* dest->addr[0] = src->addr[0]; + dest->addr[1] = src->addr[1]; + dest->addr[2] = src->addr[2]; + dest->addr[3] = src->addr[3];*/ +} + +u8_t +ip_addr_isany(struct ip_addr *addr) +{ + if (addr == NULL) return 1; + return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0); +} diff --git a/user/mpy/lib/lwip/src/core/mem.c b/user/mpy/lib/lwip/src/core/mem.c new file mode 100644 index 0000000..1659a2c --- /dev/null +++ b/user/mpy/lib/lwip/src/core/mem.c @@ -0,0 +1,659 @@ +/** + * @file + * Dynamic memory manager + * + * This is a lightweight replacement for the standard C library malloc(). + * + * If you want to use the standard C library malloc() instead, define + * MEM_LIBC_MALLOC to 1 in your lwipopts.h + * + * To let mem_malloc() use pools (prevents fragmentation and is much faster than + * a heap but might waste some memory), define MEM_USE_POOLS to 1, define + * MEM_USE_CUSTOM_POOLS to 1 and create a file "lwippools.h" that includes a list + * of pools like this (more pools can be added between _START and _END): + * + * Define three pools with sizes 256, 512, and 1512 bytes + * LWIP_MALLOC_MEMPOOL_START + * LWIP_MALLOC_MEMPOOL(20, 256) + * LWIP_MALLOC_MEMPOOL(10, 512) + * LWIP_MALLOC_MEMPOOL(5, 1512) + * LWIP_MALLOC_MEMPOOL_END + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * Simon Goldschmidt + * + */ + +#include "lwip/opt.h" + +#if !MEM_LIBC_MALLOC /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/sys.h" +#include "lwip/stats.h" +#include "lwip/err.h" + +#include + +#if MEM_USE_POOLS +/* lwIP head implemented with different sized pools */ + +/** + * Allocate memory: determine the smallest pool that is big enough + * to contain an element of 'size' and get an element from that pool. + * + * @param size the size in bytes of the memory needed + * @return a pointer to the allocated memory or NULL if the pool is empty + */ +void * +mem_malloc(mem_size_t size) +{ + void *ret; + struct memp_malloc_helper *element; + memp_t poolnr; + mem_size_t required_size = size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); + + for (poolnr = MEMP_POOL_FIRST; poolnr <= MEMP_POOL_LAST; poolnr = (memp_t)(poolnr + 1)) { +#if MEM_USE_POOLS_TRY_BIGGER_POOL +again: +#endif /* MEM_USE_POOLS_TRY_BIGGER_POOL */ + /* is this pool big enough to hold an element of the required size + plus a struct memp_malloc_helper that saves the pool this element came from? */ + if (required_size <= memp_sizes[poolnr]) { + break; + } + } + if (poolnr > MEMP_POOL_LAST) { + LWIP_ASSERT("mem_malloc(): no pool is that big!", 0); + return NULL; + } + element = (struct memp_malloc_helper*)memp_malloc(poolnr); + if (element == NULL) { + /* No need to DEBUGF or ASSERT: This error is already + taken care of in memp.c */ +#if MEM_USE_POOLS_TRY_BIGGER_POOL + /** Try a bigger pool if this one is empty! */ + if (poolnr < MEMP_POOL_LAST) { + poolnr++; + goto again; + } +#endif /* MEM_USE_POOLS_TRY_BIGGER_POOL */ + return NULL; + } + + /* save the pool number this element came from */ + element->poolnr = poolnr; + /* and return a pointer to the memory directly after the struct memp_malloc_helper */ + ret = (u8_t*)element + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); + + return ret; +} + +/** + * Free memory previously allocated by mem_malloc. Loads the pool number + * and calls memp_free with that pool number to put the element back into + * its pool + * + * @param rmem the memory element to free + */ +void +mem_free(void *rmem) +{ + struct memp_malloc_helper *hmem; + + LWIP_ASSERT("rmem != NULL", (rmem != NULL)); + LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem))); + + /* get the original struct memp_malloc_helper */ + hmem = (struct memp_malloc_helper*)(void*)((u8_t*)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))); + + LWIP_ASSERT("hmem != NULL", (hmem != NULL)); + LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem))); + LWIP_ASSERT("hmem->poolnr < MEMP_MAX", (hmem->poolnr < MEMP_MAX)); + + /* and put it in the pool we saved earlier */ + memp_free(hmem->poolnr, hmem); +} + +#else /* MEM_USE_POOLS */ +/* lwIP replacement for your libc malloc() */ + +/** + * The heap is made up as a list of structs of this type. + * This does not have to be aligned since for getting its size, + * we only use the macro SIZEOF_STRUCT_MEM, which automatically alignes. + */ +struct mem { + /** index (-> ram[next]) of the next struct */ + mem_size_t next; + /** index (-> ram[prev]) of the previous struct */ + mem_size_t prev; + /** 1: this area is used; 0: this area is unused */ + u8_t used; +}; + +/** All allocated blocks will be MIN_SIZE bytes big, at least! + * MIN_SIZE can be overridden to suit your needs. Smaller values save space, + * larger values could prevent too small blocks to fragment the RAM too much. */ +#ifndef MIN_SIZE +#define MIN_SIZE 12 +#endif /* MIN_SIZE */ +/* some alignment macros: we define them here for better source code layout */ +#define MIN_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MIN_SIZE) +#define SIZEOF_STRUCT_MEM LWIP_MEM_ALIGN_SIZE(sizeof(struct mem)) +#define MEM_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEM_SIZE) + +/** If you want to relocate the heap to external memory, simply define + * LWIP_RAM_HEAP_POINTER as a void-pointer to that location. + * If so, make sure the memory at that location is big enough (see below on + * how that space is calculated). */ +#ifndef LWIP_RAM_HEAP_POINTER +/** the heap. we need one struct mem at the end and some room for alignment */ +u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT]; +#define LWIP_RAM_HEAP_POINTER ram_heap +#endif /* LWIP_RAM_HEAP_POINTER */ + +/** pointer to the heap (ram_heap): for alignment, ram is now a pointer instead of an array */ +static u8_t *ram; +/** the last entry, always unused! */ +static struct mem *ram_end; +/** pointer to the lowest free block, this is used for faster search */ +static struct mem *lfree; + +/** concurrent access protection */ +#if !NO_SYS +static sys_mutex_t mem_mutex; +#endif + +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + +static volatile u8_t mem_free_count; + +/* Allow mem_free from other (e.g. interrupt) context */ +#define LWIP_MEM_FREE_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_free) +#define LWIP_MEM_FREE_PROTECT() SYS_ARCH_PROTECT(lev_free) +#define LWIP_MEM_FREE_UNPROTECT() SYS_ARCH_UNPROTECT(lev_free) +#define LWIP_MEM_ALLOC_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_alloc) +#define LWIP_MEM_ALLOC_PROTECT() SYS_ARCH_PROTECT(lev_alloc) +#define LWIP_MEM_ALLOC_UNPROTECT() SYS_ARCH_UNPROTECT(lev_alloc) + +#else /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + +/* Protect the heap only by using a semaphore */ +#define LWIP_MEM_FREE_DECL_PROTECT() +#define LWIP_MEM_FREE_PROTECT() sys_mutex_lock(&mem_mutex) +#define LWIP_MEM_FREE_UNPROTECT() sys_mutex_unlock(&mem_mutex) +/* mem_malloc is protected using semaphore AND LWIP_MEM_ALLOC_PROTECT */ +#define LWIP_MEM_ALLOC_DECL_PROTECT() +#define LWIP_MEM_ALLOC_PROTECT() +#define LWIP_MEM_ALLOC_UNPROTECT() + +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + + +/** + * "Plug holes" by combining adjacent empty struct mems. + * After this function is through, there should not exist + * one empty struct mem pointing to another empty struct mem. + * + * @param mem this points to a struct mem which just has been freed + * @internal this function is only called by mem_free() and mem_trim() + * + * This assumes access to the heap is protected by the calling function + * already. + */ +static void +plug_holes(struct mem *mem) +{ + struct mem *nmem; + struct mem *pmem; + + LWIP_ASSERT("plug_holes: mem >= ram", (u8_t *)mem >= ram); + LWIP_ASSERT("plug_holes: mem < ram_end", (u8_t *)mem < (u8_t *)ram_end); + LWIP_ASSERT("plug_holes: mem->used == 0", mem->used == 0); + + /* plug hole forward */ + LWIP_ASSERT("plug_holes: mem->next <= MEM_SIZE_ALIGNED", mem->next <= MEM_SIZE_ALIGNED); + + nmem = (struct mem *)(void *)&ram[mem->next]; + if (mem != nmem && nmem->used == 0 && (u8_t *)nmem != (u8_t *)ram_end) { + /* if mem->next is unused and not end of ram, combine mem and mem->next */ + if (lfree == nmem) { + lfree = mem; + } + mem->next = nmem->next; + ((struct mem *)(void *)&ram[nmem->next])->prev = (mem_size_t)((u8_t *)mem - ram); + } + + /* plug hole backward */ + pmem = (struct mem *)(void *)&ram[mem->prev]; + if (pmem != mem && pmem->used == 0) { + /* if mem->prev is unused, combine mem and mem->prev */ + if (lfree == mem) { + lfree = pmem; + } + pmem->next = mem->next; + ((struct mem *)(void *)&ram[mem->next])->prev = (mem_size_t)((u8_t *)pmem - ram); + } +} + +/** + * Zero the heap and initialize start, end and lowest-free + */ +void +mem_init(void) +{ + struct mem *mem; + + LWIP_ASSERT("Sanity check alignment", + (SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0); + + /* align the heap */ + ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER); + /* initialize the start of the heap */ + mem = (struct mem *)(void *)ram; + mem->next = MEM_SIZE_ALIGNED; + mem->prev = 0; + mem->used = 0; + /* initialize the end of the heap */ + ram_end = (struct mem *)(void *)&ram[MEM_SIZE_ALIGNED]; + ram_end->used = 1; + ram_end->next = MEM_SIZE_ALIGNED; + ram_end->prev = MEM_SIZE_ALIGNED; + + /* initialize the lowest-free pointer to the start of the heap */ + lfree = (struct mem *)(void *)ram; + + MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED); + + if(sys_mutex_new(&mem_mutex) != ERR_OK) { + LWIP_ASSERT("failed to create mem_mutex", 0); + } +} + +/** + * Put a struct mem back on the heap + * + * @param rmem is the data portion of a struct mem as returned by a previous + * call to mem_malloc() + */ +void +mem_free(void *rmem) +{ + struct mem *mem; + LWIP_MEM_FREE_DECL_PROTECT(); + + if (rmem == NULL) { + LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("mem_free(p == NULL) was called.\n")); + return; + } + LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0); + + LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram && + (u8_t *)rmem < (u8_t *)ram_end); + + if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { + SYS_ARCH_DECL_PROTECT(lev); + LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("mem_free: illegal memory\n")); + /* protect mem stats from concurrent access */ + SYS_ARCH_PROTECT(lev); + MEM_STATS_INC(illegal); + SYS_ARCH_UNPROTECT(lev); + return; + } + /* protect the heap from concurrent access */ + LWIP_MEM_FREE_PROTECT(); + /* Get the corresponding struct mem ... */ + mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); + /* ... which has to be in a used state ... */ + LWIP_ASSERT("mem_free: mem->used", mem->used); + /* ... and is now unused. */ + mem->used = 0; + + if (mem < lfree) { + /* the newly freed struct is now the lowest */ + lfree = mem; + } + + MEM_STATS_DEC_USED(used, mem->next - (mem_size_t)(((u8_t *)mem - ram))); + + /* finally, see if prev or next are free also */ + plug_holes(mem); +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + mem_free_count = 1; +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + LWIP_MEM_FREE_UNPROTECT(); +} + +/** + * Shrink memory returned by mem_malloc(). + * + * @param rmem pointer to memory allocated by mem_malloc the is to be shrinked + * @param newsize required size after shrinking (needs to be smaller than or + * equal to the previous size) + * @return for compatibility reasons: is always == rmem, at the moment + * or NULL if newsize is > old size, in which case rmem is NOT touched + * or freed! + */ +void * +mem_trim(void *rmem, mem_size_t newsize) +{ + mem_size_t size; + mem_size_t ptr, ptr2; + struct mem *mem, *mem2; + /* use the FREE_PROTECT here: it protects with sem OR SYS_ARCH_PROTECT */ + LWIP_MEM_FREE_DECL_PROTECT(); + + /* Expand the size of the allocated memory region so that we can + adjust for alignment. */ + newsize = LWIP_MEM_ALIGN_SIZE(newsize); + + if(newsize < MIN_SIZE_ALIGNED) { + /* every data block must be at least MIN_SIZE_ALIGNED long */ + newsize = MIN_SIZE_ALIGNED; + } + + if (newsize > MEM_SIZE_ALIGNED) { + return NULL; + } + + LWIP_ASSERT("mem_trim: legal memory", (u8_t *)rmem >= (u8_t *)ram && + (u8_t *)rmem < (u8_t *)ram_end); + + if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { + SYS_ARCH_DECL_PROTECT(lev); + LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("mem_trim: illegal memory\n")); + /* protect mem stats from concurrent access */ + SYS_ARCH_PROTECT(lev); + MEM_STATS_INC(illegal); + SYS_ARCH_UNPROTECT(lev); + return rmem; + } + /* Get the corresponding struct mem ... */ + mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); + /* ... and its offset pointer */ + ptr = (mem_size_t)((u8_t *)mem - ram); + + size = mem->next - ptr - SIZEOF_STRUCT_MEM; + LWIP_ASSERT("mem_trim can only shrink memory", newsize <= size); + if (newsize > size) { + /* not supported */ + return NULL; + } + if (newsize == size) { + /* No change in size, simply return */ + return rmem; + } + + /* protect the heap from concurrent access */ + LWIP_MEM_FREE_PROTECT(); + + mem2 = (struct mem *)(void *)&ram[mem->next]; + if(mem2->used == 0) { + /* The next struct is unused, we can simply move it at little */ + mem_size_t next; + /* remember the old next pointer */ + next = mem2->next; + /* create new struct mem which is moved directly after the shrinked mem */ + ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; + if (lfree == mem2) { + lfree = (struct mem *)(void *)&ram[ptr2]; + } + mem2 = (struct mem *)(void *)&ram[ptr2]; + mem2->used = 0; + /* restore the next pointer */ + mem2->next = next; + /* link it back to mem */ + mem2->prev = ptr; + /* link mem to it */ + mem->next = ptr2; + /* last thing to restore linked list: as we have moved mem2, + * let 'mem2->next->prev' point to mem2 again. but only if mem2->next is not + * the end of the heap */ + if (mem2->next != MEM_SIZE_ALIGNED) { + ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; + } + MEM_STATS_DEC_USED(used, (size - newsize)); + /* no need to plug holes, we've already done that */ + } else if (newsize + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED <= size) { + /* Next struct is used but there's room for another struct mem with + * at least MIN_SIZE_ALIGNED of data. + * Old size ('size') must be big enough to contain at least 'newsize' plus a struct mem + * ('SIZEOF_STRUCT_MEM') with some data ('MIN_SIZE_ALIGNED'). + * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty + * region that couldn't hold data, but when mem->next gets freed, + * the 2 regions would be combined, resulting in more free memory */ + ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; + mem2 = (struct mem *)(void *)&ram[ptr2]; + if (mem2 < lfree) { + lfree = mem2; + } + mem2->used = 0; + mem2->next = mem->next; + mem2->prev = ptr; + mem->next = ptr2; + if (mem2->next != MEM_SIZE_ALIGNED) { + ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; + } + MEM_STATS_DEC_USED(used, (size - newsize)); + /* the original mem->next is used, so no need to plug holes! */ + } + /* else { + next struct mem is used but size between mem and mem2 is not big enough + to create another struct mem + -> don't do anyhting. + -> the remaining space stays unused since it is too small + } */ +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + mem_free_count = 1; +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + LWIP_MEM_FREE_UNPROTECT(); + return rmem; +} + +/** + * Adam's mem_malloc() plus solution for bug #17922 + * Allocate a block of memory with a minimum of 'size' bytes. + * + * @param size is the minimum size of the requested block in bytes. + * @return pointer to allocated memory or NULL if no free memory was found. + * + * Note that the returned value will always be aligned (as defined by MEM_ALIGNMENT). + */ +void * +mem_malloc(mem_size_t size) +{ + mem_size_t ptr, ptr2; + struct mem *mem, *mem2; +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + u8_t local_mem_free_count = 0; +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + LWIP_MEM_ALLOC_DECL_PROTECT(); + + if (size == 0) { + return NULL; + } + + /* Expand the size of the allocated memory region so that we can + adjust for alignment. */ + size = LWIP_MEM_ALIGN_SIZE(size); + + if(size < MIN_SIZE_ALIGNED) { + /* every data block must be at least MIN_SIZE_ALIGNED long */ + size = MIN_SIZE_ALIGNED; + } + + if (size > MEM_SIZE_ALIGNED) { + return NULL; + } + + /* protect the heap from concurrent access */ + sys_mutex_lock(&mem_mutex); + LWIP_MEM_ALLOC_PROTECT(); +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + /* run as long as a mem_free disturbed mem_malloc or mem_trim */ + do { + local_mem_free_count = 0; +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + + /* Scan through the heap searching for a free block that is big enough, + * beginning with the lowest free block. + */ + for (ptr = (mem_size_t)((u8_t *)lfree - ram); ptr < MEM_SIZE_ALIGNED - size; + ptr = ((struct mem *)(void *)&ram[ptr])->next) { + mem = (struct mem *)(void *)&ram[ptr]; +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + mem_free_count = 0; + LWIP_MEM_ALLOC_UNPROTECT(); + /* allow mem_free or mem_trim to run */ + LWIP_MEM_ALLOC_PROTECT(); + if (mem_free_count != 0) { + /* If mem_free or mem_trim have run, we have to restart since they + could have altered our current struct mem. */ + local_mem_free_count = 1; + break; + } +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + + if ((!mem->used) && + (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) { + /* mem is not used and at least perfect fit is possible: + * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ + + if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) { + /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing + * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem') + * -> split large block, create empty remainder, + * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if + * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size, + * struct mem would fit in but no data between mem2 and mem2->next + * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty + * region that couldn't hold data, but when mem->next gets freed, + * the 2 regions would be combined, resulting in more free memory + */ + ptr2 = ptr + SIZEOF_STRUCT_MEM + size; + /* create mem2 struct */ + mem2 = (struct mem *)(void *)&ram[ptr2]; + mem2->used = 0; + mem2->next = mem->next; + mem2->prev = ptr; + /* and insert it between mem and mem->next */ + mem->next = ptr2; + mem->used = 1; + + if (mem2->next != MEM_SIZE_ALIGNED) { + ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; + } + MEM_STATS_INC_USED(used, (size + SIZEOF_STRUCT_MEM)); + } else { + /* (a mem2 struct does no fit into the user data space of mem and mem->next will always + * be used at this point: if not we have 2 unused structs in a row, plug_holes should have + * take care of this). + * -> near fit or excact fit: do not split, no mem2 creation + * also can't move mem->next directly behind mem, since mem->next + * will always be used at this point! + */ + mem->used = 1; + MEM_STATS_INC_USED(used, mem->next - (mem_size_t)((u8_t *)mem - ram)); + } +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT +mem_malloc_adjust_lfree: +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + if (mem == lfree) { + struct mem *cur = lfree; + /* Find next free block after mem and update lowest free pointer */ + while (cur->used && cur != ram_end) { +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + mem_free_count = 0; + LWIP_MEM_ALLOC_UNPROTECT(); + /* prevent high interrupt latency... */ + LWIP_MEM_ALLOC_PROTECT(); + if (mem_free_count != 0) { + /* If mem_free or mem_trim have run, we have to restart since they + could have altered our current struct mem or lfree. */ + goto mem_malloc_adjust_lfree; + } +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + cur = (struct mem *)(void *)&ram[cur->next]; + } + lfree = cur; + LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); + } + LWIP_MEM_ALLOC_UNPROTECT(); + sys_mutex_unlock(&mem_mutex); + LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", + (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); + LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", + ((mem_ptr_t)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); + LWIP_ASSERT("mem_malloc: sanity check alignment", + (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); + + return (u8_t *)mem + SIZEOF_STRUCT_MEM; + } + } +#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT + /* if we got interrupted by a mem_free, try again */ + } while(local_mem_free_count != 0); +#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ + LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size)); + MEM_STATS_INC(err); + LWIP_MEM_ALLOC_UNPROTECT(); + sys_mutex_unlock(&mem_mutex); + return NULL; +} + +#endif /* MEM_USE_POOLS */ +/** + * Contiguously allocates enough space for count objects that are size bytes + * of memory each and returns a pointer to the allocated memory. + * + * The allocated memory is filled with bytes of value zero. + * + * @param count number of objects to allocate + * @param size size of the objects to allocate + * @return pointer to allocated memory / NULL pointer if there is an error + */ +void *mem_calloc(mem_size_t count, mem_size_t size) +{ + void *p; + + /* allocate 'count' objects of size 'size' */ + p = mem_malloc(count * size); + if (p) { + /* zero the memory */ + memset(p, 0, count * size); + } + return p; +} + +#endif /* !MEM_LIBC_MALLOC */ diff --git a/user/mpy/lib/lwip/src/core/memp.c b/user/mpy/lib/lwip/src/core/memp.c new file mode 100644 index 0000000..9f680e2 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/memp.c @@ -0,0 +1,470 @@ +/** + * @file + * Dynamic pool memory manager + * + * lwIP has dedicated pools for many structures (netconn, protocol control blocks, + * packet buffers, ...). All these pools are managed here. + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/memp.h" +#include "lwip/pbuf.h" +#include "lwip/udp.h" +#include "lwip/raw.h" +#include "lwip/tcp_impl.h" +#include "lwip/igmp.h" +#include "lwip/api.h" +#include "lwip/api_msg.h" +#include "lwip/tcpip.h" +#include "lwip/sys.h" +#include "lwip/timers.h" +#include "lwip/stats.h" +#include "netif/etharp.h" +#include "lwip/ip_frag.h" +#include "lwip/snmp_structs.h" +#include "lwip/snmp_msg.h" +#include "lwip/dns.h" +#include "netif/ppp_oe.h" + +#include + +#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */ + +struct memp { + struct memp *next; +#if MEMP_OVERFLOW_CHECK + const char *file; + int line; +#endif /* MEMP_OVERFLOW_CHECK */ +}; + +#if MEMP_OVERFLOW_CHECK +/* if MEMP_OVERFLOW_CHECK is turned on, we reserve some bytes at the beginning + * and at the end of each element, initialize them as 0xcd and check + * them later. */ +/* If MEMP_OVERFLOW_CHECK is >= 2, on every call to memp_malloc or memp_free, + * every single element in each pool is checked! + * This is VERY SLOW but also very helpful. */ +/* MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in + * lwipopts.h to change the amount reserved for checking. */ +#ifndef MEMP_SANITY_REGION_BEFORE +#define MEMP_SANITY_REGION_BEFORE 16 +#endif /* MEMP_SANITY_REGION_BEFORE*/ +#if MEMP_SANITY_REGION_BEFORE > 0 +#define MEMP_SANITY_REGION_BEFORE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_BEFORE) +#else +#define MEMP_SANITY_REGION_BEFORE_ALIGNED 0 +#endif /* MEMP_SANITY_REGION_BEFORE*/ +#ifndef MEMP_SANITY_REGION_AFTER +#define MEMP_SANITY_REGION_AFTER 16 +#endif /* MEMP_SANITY_REGION_AFTER*/ +#if MEMP_SANITY_REGION_AFTER > 0 +#define MEMP_SANITY_REGION_AFTER_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_AFTER) +#else +#define MEMP_SANITY_REGION_AFTER_ALIGNED 0 +#endif /* MEMP_SANITY_REGION_AFTER*/ + +/* MEMP_SIZE: save space for struct memp and for sanity check */ +#define MEMP_SIZE (LWIP_MEM_ALIGN_SIZE(sizeof(struct memp)) + MEMP_SANITY_REGION_BEFORE_ALIGNED) +#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x) + MEMP_SANITY_REGION_AFTER_ALIGNED) + +#else /* MEMP_OVERFLOW_CHECK */ + +/* No sanity checks + * We don't need to preserve the struct memp while not allocated, so we + * can save a little space and set MEMP_SIZE to 0. + */ +#define MEMP_SIZE 0 +#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) + +#endif /* MEMP_OVERFLOW_CHECK */ + +/** This array holds the first free element of each pool. + * Elements form a linked list. */ +static struct memp *memp_tab[MEMP_MAX]; + +#else /* MEMP_MEM_MALLOC */ + +#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) + +#endif /* MEMP_MEM_MALLOC */ + +/** This array holds the element sizes of each pool. */ +#if !MEM_USE_POOLS && !MEMP_MEM_MALLOC +static +#endif +const u16_t memp_sizes[MEMP_MAX] = { +#define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEM_ALIGN_SIZE(size), +#include "lwip/memp_std.h" +}; + +#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */ + +/** This array holds the number of elements in each pool. */ +static const u16_t memp_num[MEMP_MAX] = { +#define LWIP_MEMPOOL(name,num,size,desc) (num), +#include "lwip/memp_std.h" +}; + +/** This array holds a textual description of each pool. */ +#ifdef LWIP_DEBUG +static const char *memp_desc[MEMP_MAX] = { +#define LWIP_MEMPOOL(name,num,size,desc) (desc), +#include "lwip/memp_std.h" +}; +#endif /* LWIP_DEBUG */ + +#if MEMP_SEPARATE_POOLS + +/** This creates each memory pool. These are named memp_memory_XXX_base (where + * XXX is the name of the pool defined in memp_std.h). + * To relocate a pool, declare it as extern in cc.h. Example for GCC: + * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; + */ +#define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ + [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; +#include "lwip/memp_std.h" + +/** This array holds the base of each memory pool. */ +static u8_t *const memp_bases[] = { +#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, +#include "lwip/memp_std.h" +}; + +#else /* MEMP_SEPARATE_POOLS */ + +/** This is the actual memory used by the pools (all pools in one big block). */ +static u8_t memp_memory[MEM_ALIGNMENT - 1 +#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) +#include "lwip/memp_std.h" +]; + +#endif /* MEMP_SEPARATE_POOLS */ + +#if MEMP_SANITY_CHECK +/** + * Check that memp-lists don't form a circle, using "Floyd's cycle-finding algorithm". + */ +static int +memp_sanity(void) +{ + s16_t i; + struct memp *t, *h; + + for (i = 0; i < MEMP_MAX; i++) { + t = memp_tab[i]; + if(t != NULL) { + for (h = t->next; (t != NULL) && (h != NULL); t = t->next, + h = (((h->next != NULL) && (h->next->next != NULL)) ? h->next->next : NULL)) { + if (t == h) { + return 0; + } + } + } + } + return 1; +} +#endif /* MEMP_SANITY_CHECK*/ +#if MEMP_OVERFLOW_CHECK +#if defined(LWIP_DEBUG) && MEMP_STATS +static const char * memp_overflow_names[] = { +#define LWIP_MEMPOOL(name,num,size,desc) "/"desc, +#include "lwip/memp_std.h" + }; +#endif + +/** + * Check if a memp element was victim of an overflow + * (e.g. the restricted area after it has been altered) + * + * @param p the memp element to check + * @param memp_type the pool p comes from + */ +static void +memp_overflow_check_element_overflow(struct memp *p, u16_t memp_type) +{ + u16_t k; + u8_t *m; +#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 + m = (u8_t*)p + MEMP_SIZE + memp_sizes[memp_type]; + for (k = 0; k < MEMP_SANITY_REGION_AFTER_ALIGNED; k++) { + if (m[k] != 0xcd) { + char errstr[128] = "detected memp overflow in pool "; + char digit[] = "0"; + if(memp_type >= 10) { + digit[0] = '0' + (memp_type/10); + strcat(errstr, digit); + } + digit[0] = '0' + (memp_type%10); + strcat(errstr, digit); +#if defined(LWIP_DEBUG) && MEMP_STATS + strcat(errstr, memp_overflow_names[memp_type]); +#endif + LWIP_ASSERT(errstr, 0); + } + } +#endif +} + +/** + * Check if a memp element was victim of an underflow + * (e.g. the restricted area before it has been altered) + * + * @param p the memp element to check + * @param memp_type the pool p comes from + */ +static void +memp_overflow_check_element_underflow(struct memp *p, u16_t memp_type) +{ + u16_t k; + u8_t *m; +#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 + m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; + for (k = 0; k < MEMP_SANITY_REGION_BEFORE_ALIGNED; k++) { + if (m[k] != 0xcd) { + char errstr[128] = "detected memp underflow in pool "; + char digit[] = "0"; + if(memp_type >= 10) { + digit[0] = '0' + (memp_type/10); + strcat(errstr, digit); + } + digit[0] = '0' + (memp_type%10); + strcat(errstr, digit); +#if defined(LWIP_DEBUG) && MEMP_STATS + strcat(errstr, memp_overflow_names[memp_type]); +#endif + LWIP_ASSERT(errstr, 0); + } + } +#endif +} + +/** + * Do an overflow check for all elements in every pool. + * + * @see memp_overflow_check_element for a description of the check + */ +static void +memp_overflow_check_all(void) +{ + u16_t i, j; + struct memp *p; + + p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); + for (i = 0; i < MEMP_MAX; ++i) { + p = p; + for (j = 0; j < memp_num[i]; ++j) { + memp_overflow_check_element_overflow(p, i); + p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); + } + } + p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); + for (i = 0; i < MEMP_MAX; ++i) { + p = p; + for (j = 0; j < memp_num[i]; ++j) { + memp_overflow_check_element_underflow(p, i); + p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); + } + } +} + +/** + * Initialize the restricted areas of all memp elements in every pool. + */ +static void +memp_overflow_init(void) +{ + u16_t i, j; + struct memp *p; + u8_t *m; + + p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); + for (i = 0; i < MEMP_MAX; ++i) { + p = p; + for (j = 0; j < memp_num[i]; ++j) { +#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 + m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; + memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED); +#endif +#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 + m = (u8_t*)p + MEMP_SIZE + memp_sizes[i]; + memset(m, 0xcd, MEMP_SANITY_REGION_AFTER_ALIGNED); +#endif + p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); + } + } +} +#endif /* MEMP_OVERFLOW_CHECK */ + +/** + * Initialize this module. + * + * Carves out memp_memory into linked lists for each pool-type. + */ +void +memp_init(void) +{ + struct memp *memp; + u16_t i, j; + + for (i = 0; i < MEMP_MAX; ++i) { + MEMP_STATS_AVAIL(used, i, 0); + MEMP_STATS_AVAIL(max, i, 0); + MEMP_STATS_AVAIL(err, i, 0); + MEMP_STATS_AVAIL(avail, i, memp_num[i]); + } + +#if !MEMP_SEPARATE_POOLS + memp = (struct memp *)LWIP_MEM_ALIGN(memp_memory); +#endif /* !MEMP_SEPARATE_POOLS */ + /* for every pool: */ + for (i = 0; i < MEMP_MAX; ++i) { + memp_tab[i] = NULL; +#if MEMP_SEPARATE_POOLS + memp = (struct memp*)memp_bases[i]; +#endif /* MEMP_SEPARATE_POOLS */ + /* create a linked list of memp elements */ + for (j = 0; j < memp_num[i]; ++j) { + memp->next = memp_tab[i]; + memp_tab[i] = memp; + memp = (struct memp *)(void *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i] +#if MEMP_OVERFLOW_CHECK + + MEMP_SANITY_REGION_AFTER_ALIGNED +#endif + ); + } + } +#if MEMP_OVERFLOW_CHECK + memp_overflow_init(); + /* check everything a first time to see if it worked */ + memp_overflow_check_all(); +#endif /* MEMP_OVERFLOW_CHECK */ +} + +/** + * Get an element from a specific pool. + * + * @param type the pool to get an element from + * + * the debug version has two more parameters: + * @param file file name calling this function + * @param line number of line where this function is called + * + * @return a pointer to the allocated memory or a NULL pointer on error + */ +void * +#if !MEMP_OVERFLOW_CHECK +memp_malloc(memp_t type) +#else +memp_malloc_fn(memp_t type, const char* file, const int line) +#endif +{ + struct memp *memp; + SYS_ARCH_DECL_PROTECT(old_level); + + LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); + + SYS_ARCH_PROTECT(old_level); +#if MEMP_OVERFLOW_CHECK >= 2 + memp_overflow_check_all(); +#endif /* MEMP_OVERFLOW_CHECK >= 2 */ + + memp = memp_tab[type]; + + if (memp != NULL) { + memp_tab[type] = memp->next; +#if MEMP_OVERFLOW_CHECK + memp->next = NULL; + memp->file = file; + memp->line = line; +#endif /* MEMP_OVERFLOW_CHECK */ + MEMP_STATS_INC_USED(used, type); + LWIP_ASSERT("memp_malloc: memp properly aligned", + ((mem_ptr_t)memp % MEM_ALIGNMENT) == 0); + memp = (struct memp*)(void *)((u8_t*)memp + MEMP_SIZE); + } else { + LWIP_DEBUGF(MEMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("memp_malloc: out of memory in pool %s\n", memp_desc[type])); + MEMP_STATS_INC(err, type); + } + + SYS_ARCH_UNPROTECT(old_level); + + return memp; +} + +/** + * Put an element back into its pool. + * + * @param type the pool where to put mem + * @param mem the memp element to free + */ +void +memp_free(memp_t type, void *mem) +{ + struct memp *memp; + SYS_ARCH_DECL_PROTECT(old_level); + + if (mem == NULL) { + return; + } + LWIP_ASSERT("memp_free: mem properly aligned", + ((mem_ptr_t)mem % MEM_ALIGNMENT) == 0); + + memp = (struct memp *)(void *)((u8_t*)mem - MEMP_SIZE); + + SYS_ARCH_PROTECT(old_level); +#if MEMP_OVERFLOW_CHECK +#if MEMP_OVERFLOW_CHECK >= 2 + memp_overflow_check_all(); +#else + memp_overflow_check_element_overflow(memp, type); + memp_overflow_check_element_underflow(memp, type); +#endif /* MEMP_OVERFLOW_CHECK >= 2 */ +#endif /* MEMP_OVERFLOW_CHECK */ + + MEMP_STATS_DEC(used, type); + + memp->next = memp_tab[type]; + memp_tab[type] = memp; + +#if MEMP_SANITY_CHECK + LWIP_ASSERT("memp sanity", memp_sanity()); +#endif /* MEMP_SANITY_CHECK */ + + SYS_ARCH_UNPROTECT(old_level); +} + +#endif /* MEMP_MEM_MALLOC */ diff --git a/user/mpy/lib/lwip/src/core/netif.c b/user/mpy/lib/lwip/src/core/netif.c new file mode 100644 index 0000000..4a02e77 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/netif.c @@ -0,0 +1,774 @@ +/** + * @file + * lwIP network interface abstraction + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/def.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/tcp_impl.h" +#include "lwip/snmp.h" +#include "lwip/igmp.h" +#include "netif/etharp.h" +#include "lwip/stats.h" +#if ENABLE_LOOPBACK +#include "lwip/sys.h" +#if LWIP_NETIF_LOOPBACK_MULTITHREADING +#include "lwip/tcpip.h" +#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ +#endif /* ENABLE_LOOPBACK */ + +#if LWIP_AUTOIP +#include "lwip/autoip.h" +#endif /* LWIP_AUTOIP */ +#if LWIP_DHCP +#include "lwip/dhcp.h" +#endif /* LWIP_DHCP */ + +#if LWIP_NETIF_STATUS_CALLBACK +#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) +#else +#define NETIF_STATUS_CALLBACK(n) +#endif /* LWIP_NETIF_STATUS_CALLBACK */ + +#if LWIP_NETIF_LINK_CALLBACK +#define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0) +#else +#define NETIF_LINK_CALLBACK(n) +#endif /* LWIP_NETIF_LINK_CALLBACK */ + +struct netif *netif_list; +struct netif *netif_default; + +static u8_t netif_num; + +#if LWIP_HAVE_LOOPIF +static struct netif loop_netif; + +/** + * Initialize a lwip network interface structure for a loopback interface + * + * @param netif the lwip network interface structure for this loopif + * @return ERR_OK if the loopif is initialized + * ERR_MEM if private data couldn't be allocated + */ +static err_t +netif_loopif_init(struct netif *netif) +{ + /* initialize the snmp variables and counters inside the struct netif + * ifSpeed: no assumption can be made! + */ + NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0); + + netif->name[0] = 'l'; + netif->name[1] = 'o'; + netif->output = netif_loop_output; + return ERR_OK; +} +#endif /* LWIP_HAVE_LOOPIF */ + +void +netif_init(void) +{ +#if LWIP_HAVE_LOOPIF + ip_addr_t loop_ipaddr, loop_netmask, loop_gw; + IP4_ADDR(&loop_gw, 127,0,0,1); + IP4_ADDR(&loop_ipaddr, 127,0,0,1); + IP4_ADDR(&loop_netmask, 255,0,0,0); + +#if NO_SYS + netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, ip_input); +#else /* NO_SYS */ + netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input); +#endif /* NO_SYS */ + netif_set_up(&loop_netif); + +#endif /* LWIP_HAVE_LOOPIF */ +} + +/** + * Add a network interface to the list of lwIP netifs. + * + * @param netif a pre-allocated netif structure + * @param ipaddr IP address for the new netif + * @param netmask network mask for the new netif + * @param gw default gateway IP address for the new netif + * @param state opaque data passed to the new netif + * @param init callback function that initializes the interface + * @param input callback function that is called to pass + * ingress packets up in the protocol layer stack. + * + * @return netif, or NULL if failed. + */ +struct netif * +netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, + ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input) +{ + + LWIP_ASSERT("No init function given", init != NULL); + + /* reset new interface configuration state */ + ip_addr_set_zero(&netif->ip_addr); + ip_addr_set_zero(&netif->netmask); + ip_addr_set_zero(&netif->gw); + netif->flags = 0; +#if LWIP_DHCP + /* netif not under DHCP control by default */ + netif->dhcp = NULL; +#endif /* LWIP_DHCP */ +#if LWIP_AUTOIP + /* netif not under AutoIP control by default */ + netif->autoip = NULL; +#endif /* LWIP_AUTOIP */ +#if LWIP_NETIF_STATUS_CALLBACK + netif->status_callback = NULL; +#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#if LWIP_NETIF_LINK_CALLBACK + netif->link_callback = NULL; +#endif /* LWIP_NETIF_LINK_CALLBACK */ +#if LWIP_IGMP + netif->igmp_mac_filter = NULL; +#endif /* LWIP_IGMP */ +#if ENABLE_LOOPBACK + netif->loop_first = NULL; + netif->loop_last = NULL; +#endif /* ENABLE_LOOPBACK */ + + /* remember netif specific state information data */ + netif->state = state; + netif->num = netif_num++; + netif->input = input; + NETIF_SET_HWADDRHINT(netif, NULL); +#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS + netif->loop_cnt_current = 0; +#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */ + + netif_set_addr(netif, ipaddr, netmask, gw); + + /* call user specified initialization function for netif */ + if (init(netif) != ERR_OK) { + return NULL; + } + + /* add this netif to the list */ + netif->next = netif_list; + netif_list = netif; + snmp_inc_iflist(); + +#if LWIP_IGMP + /* start IGMP processing */ + if (netif->flags & NETIF_FLAG_IGMP) { + igmp_start(netif); + } +#endif /* LWIP_IGMP */ + + LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ", + netif->name[0], netif->name[1])); + ip_addr_debug_print(NETIF_DEBUG, ipaddr); + LWIP_DEBUGF(NETIF_DEBUG, (" netmask ")); + ip_addr_debug_print(NETIF_DEBUG, netmask); + LWIP_DEBUGF(NETIF_DEBUG, (" gw ")); + ip_addr_debug_print(NETIF_DEBUG, gw); + LWIP_DEBUGF(NETIF_DEBUG, ("\n")); + return netif; +} + +/** + * Change IP address configuration for a network interface (including netmask + * and default gateway). + * + * @param netif the network interface to change + * @param ipaddr the new IP address + * @param netmask the new netmask + * @param gw the new default gateway + */ +void +netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, + ip_addr_t *gw) +{ + netif_set_ipaddr(netif, ipaddr); + netif_set_netmask(netif, netmask); + netif_set_gw(netif, gw); +} + +/** + * Remove a network interface from the list of lwIP netifs. + * + * @param netif the network interface to remove + */ +void +netif_remove(struct netif *netif) +{ + if (netif == NULL) { + return; + } + +#if LWIP_IGMP + /* stop IGMP processing */ + if (netif->flags & NETIF_FLAG_IGMP) { + igmp_stop(netif); + } +#endif /* LWIP_IGMP */ + if (netif_is_up(netif)) { + /* set netif down before removing (call callback function) */ + netif_set_down(netif); + } + + snmp_delete_ipaddridx_tree(netif); + + /* is it the first netif? */ + if (netif_list == netif) { + netif_list = netif->next; + } else { + /* look for netif further down the list */ + struct netif * tmpNetif; + for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { + if (tmpNetif->next == netif) { + tmpNetif->next = netif->next; + break; + } + } + if (tmpNetif == NULL) + return; /* we didn't find any netif today */ + } + snmp_dec_iflist(); + /* this netif is default? */ + if (netif_default == netif) { + /* reset default netif */ + netif_set_default(NULL); + } +#if LWIP_NETIF_REMOVE_CALLBACK + if (netif->remove_callback) { + netif->remove_callback(netif); + } +#endif /* LWIP_NETIF_REMOVE_CALLBACK */ + LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); +} + +/** + * Find a network interface by searching for its name + * + * @param name the name of the netif (like netif->name) plus concatenated number + * in ascii representation (e.g. 'en0') + */ +struct netif * +netif_find(char *name) +{ + struct netif *netif; + u8_t num; + + if (name == NULL) { + return NULL; + } + + num = name[2] - '0'; + + for(netif = netif_list; netif != NULL; netif = netif->next) { + if (num == netif->num && + name[0] == netif->name[0] && + name[1] == netif->name[1]) { + LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); + return netif; + } + } + LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); + return NULL; +} + +/** + * Change the IP address of a network interface + * + * @param netif the network interface to change + * @param ipaddr the new IP address + * + * @note call netif_set_addr() if you also want to change netmask and + * default gateway + */ +void +netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr) +{ + /* TODO: Handling of obsolete pcbs */ + /* See: http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */ +#if LWIP_TCP + struct tcp_pcb *pcb; + struct tcp_pcb_listen *lpcb; + + /* address is actually being changed? */ + if (ipaddr && (ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) { + /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */ + LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n")); + pcb = tcp_active_pcbs; + while (pcb != NULL) { + /* PCB bound to current local interface address? */ + if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr)) +#if LWIP_AUTOIP + /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */ + && !ip_addr_islinklocal(&(pcb->local_ip)) +#endif /* LWIP_AUTOIP */ + ) { + /* this connection must be aborted */ + struct tcp_pcb *next = pcb->next; + LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb)); + tcp_abort(pcb); + pcb = next; + } else { + pcb = pcb->next; + } + } + for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { + /* PCB bound to current local interface address? */ + if ((!(ip_addr_isany(&(lpcb->local_ip)))) && + (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr)))) { + /* The PCB is listening to the old ipaddr and + * is set to listen to the new one instead */ + ip_addr_set(&(lpcb->local_ip), ipaddr); + } + } + } +#endif + snmp_delete_ipaddridx_tree(netif); + snmp_delete_iprteidx_tree(0,netif); + /* set new IP address to netif */ + ip_addr_set(&(netif->ip_addr), ipaddr); + snmp_insert_ipaddridx_tree(netif); + snmp_insert_iprteidx_tree(0,netif); + + LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + netif->name[0], netif->name[1], + ip4_addr1_16(&netif->ip_addr), + ip4_addr2_16(&netif->ip_addr), + ip4_addr3_16(&netif->ip_addr), + ip4_addr4_16(&netif->ip_addr))); +} + +/** + * Change the default gateway for a network interface + * + * @param netif the network interface to change + * @param gw the new default gateway + * + * @note call netif_set_addr() if you also want to change ip address and netmask + */ +void +netif_set_gw(struct netif *netif, ip_addr_t *gw) +{ + ip_addr_set(&(netif->gw), gw); + LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + netif->name[0], netif->name[1], + ip4_addr1_16(&netif->gw), + ip4_addr2_16(&netif->gw), + ip4_addr3_16(&netif->gw), + ip4_addr4_16(&netif->gw))); +} + +/** + * Change the netmask of a network interface + * + * @param netif the network interface to change + * @param netmask the new netmask + * + * @note call netif_set_addr() if you also want to change ip address and + * default gateway + */ +void +netif_set_netmask(struct netif *netif, ip_addr_t *netmask) +{ + snmp_delete_iprteidx_tree(0, netif); + /* set new netmask to netif */ + ip_addr_set(&(netif->netmask), netmask); + snmp_insert_iprteidx_tree(0, netif); + LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + netif->name[0], netif->name[1], + ip4_addr1_16(&netif->netmask), + ip4_addr2_16(&netif->netmask), + ip4_addr3_16(&netif->netmask), + ip4_addr4_16(&netif->netmask))); +} + +/** + * Set a network interface as the default network interface + * (used to output all packets for which no specific route is found) + * + * @param netif the default network interface + */ +void +netif_set_default(struct netif *netif) +{ + if (netif == NULL) { + /* remove default route */ + snmp_delete_iprteidx_tree(1, netif); + } else { + /* install default route */ + snmp_insert_iprteidx_tree(1, netif); + } + netif_default = netif; + LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n", + netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); +} + +/** + * Bring an interface up, available for processing + * traffic. + * + * @note: Enabling DHCP on a down interface will make it come + * up once configured. + * + * @see dhcp_start() + */ +void netif_set_up(struct netif *netif) +{ + if (!(netif->flags & NETIF_FLAG_UP)) { + netif->flags |= NETIF_FLAG_UP; + +#if LWIP_SNMP + snmp_get_sysuptime(&netif->ts); +#endif /* LWIP_SNMP */ + + NETIF_STATUS_CALLBACK(netif); + + if (netif->flags & NETIF_FLAG_LINK_UP) { +#if LWIP_ARP + /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ + if (netif->flags & (NETIF_FLAG_ETHARP)) { + etharp_gratuitous(netif); + } +#endif /* LWIP_ARP */ + +#if LWIP_IGMP + /* resend IGMP memberships */ + if (netif->flags & NETIF_FLAG_IGMP) { + igmp_report_groups( netif); + } +#endif /* LWIP_IGMP */ + } + } +} + +/** + * Bring an interface down, disabling any traffic processing. + * + * @note: Enabling DHCP on a down interface will make it come + * up once configured. + * + * @see dhcp_start() + */ +void netif_set_down(struct netif *netif) +{ + if (netif->flags & NETIF_FLAG_UP) { + netif->flags &= ~NETIF_FLAG_UP; +#if LWIP_SNMP + snmp_get_sysuptime(&netif->ts); +#endif + +#if LWIP_ARP + if (netif->flags & NETIF_FLAG_ETHARP) { + etharp_cleanup_netif(netif); + } +#endif /* LWIP_ARP */ + NETIF_STATUS_CALLBACK(netif); + } +} + +#if LWIP_NETIF_STATUS_CALLBACK +/** + * Set callback to be called when interface is brought up/down + */ +void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback) +{ + if (netif) { + netif->status_callback = status_callback; + } +} +#endif /* LWIP_NETIF_STATUS_CALLBACK */ + +#if LWIP_NETIF_REMOVE_CALLBACK +/** + * Set callback to be called when the interface has been removed + */ +void +netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback) +{ + if (netif) { + netif->remove_callback = remove_callback; + } +} +#endif /* LWIP_NETIF_REMOVE_CALLBACK */ + +/** + * Called by a driver when its link goes up + */ +void netif_set_link_up(struct netif *netif ) +{ + if (!(netif->flags & NETIF_FLAG_LINK_UP)) { + netif->flags |= NETIF_FLAG_LINK_UP; + +#if LWIP_DHCP + if (netif->dhcp) { + dhcp_network_changed(netif); + } +#endif /* LWIP_DHCP */ + +#if LWIP_AUTOIP + if (netif->autoip) { + autoip_network_changed(netif); + } +#endif /* LWIP_AUTOIP */ + + if (netif->flags & NETIF_FLAG_UP) { +#if LWIP_ARP + /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ + if (netif->flags & NETIF_FLAG_ETHARP) { + etharp_gratuitous(netif); + } +#endif /* LWIP_ARP */ + +#if LWIP_IGMP + /* resend IGMP memberships */ + if (netif->flags & NETIF_FLAG_IGMP) { + igmp_report_groups( netif); + } +#endif /* LWIP_IGMP */ + } + NETIF_LINK_CALLBACK(netif); + } +} + +/** + * Called by a driver when its link goes down + */ +void netif_set_link_down(struct netif *netif ) +{ + if (netif->flags & NETIF_FLAG_LINK_UP) { + netif->flags &= ~NETIF_FLAG_LINK_UP; + NETIF_LINK_CALLBACK(netif); + } +} + +#if LWIP_NETIF_LINK_CALLBACK +/** + * Set callback to be called when link is brought up/down + */ +void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback) +{ + if (netif) { + netif->link_callback = link_callback; + } +} +#endif /* LWIP_NETIF_LINK_CALLBACK */ + +#if ENABLE_LOOPBACK +/** + * Send an IP packet to be received on the same netif (loopif-like). + * The pbuf is simply copied and handed back to netif->input. + * In multithreaded mode, this is done directly since netif->input must put + * the packet on a queue. + * In callback mode, the packet is put on an internal queue and is fed to + * netif->input by netif_poll(). + * + * @param netif the lwip network interface structure + * @param p the (IP) packet to 'send' + * @param ipaddr the ip address to send the packet to (not used) + * @return ERR_OK if the packet has been sent + * ERR_MEM if the pbuf used to copy the packet couldn't be allocated + */ +err_t +netif_loop_output(struct netif *netif, struct pbuf *p, + ip_addr_t *ipaddr) +{ + struct pbuf *r; + err_t err; + struct pbuf *last; +#if LWIP_LOOPBACK_MAX_PBUFS + u8_t clen = 0; +#endif /* LWIP_LOOPBACK_MAX_PBUFS */ + /* If we have a loopif, SNMP counters are adjusted for it, + * if not they are adjusted for 'netif'. */ +#if LWIP_SNMP +#if LWIP_HAVE_LOOPIF + struct netif *stats_if = &loop_netif; +#else /* LWIP_HAVE_LOOPIF */ + struct netif *stats_if = netif; +#endif /* LWIP_HAVE_LOOPIF */ +#endif /* LWIP_SNMP */ + SYS_ARCH_DECL_PROTECT(lev); + LWIP_UNUSED_ARG(ipaddr); + + /* Allocate a new pbuf */ + r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); + if (r == NULL) { + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(stats_if); + return ERR_MEM; + } +#if LWIP_LOOPBACK_MAX_PBUFS + clen = pbuf_clen(r); + /* check for overflow or too many pbuf on queue */ + if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) || + ((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) { + pbuf_free(r); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(stats_if); + return ERR_MEM; + } + netif->loop_cnt_current += clen; +#endif /* LWIP_LOOPBACK_MAX_PBUFS */ + + /* Copy the whole pbuf queue p into the single pbuf r */ + if ((err = pbuf_copy(r, p)) != ERR_OK) { + pbuf_free(r); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(stats_if); + return err; + } + + /* Put the packet on a linked list which gets emptied through calling + netif_poll(). */ + + /* let last point to the last pbuf in chain r */ + for (last = r; last->next != NULL; last = last->next); + + SYS_ARCH_PROTECT(lev); + if(netif->loop_first != NULL) { + LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL); + netif->loop_last->next = r; + netif->loop_last = last; + } else { + netif->loop_first = r; + netif->loop_last = last; + } + SYS_ARCH_UNPROTECT(lev); + + LINK_STATS_INC(link.xmit); + snmp_add_ifoutoctets(stats_if, p->tot_len); + snmp_inc_ifoutucastpkts(stats_if); + +#if LWIP_NETIF_LOOPBACK_MULTITHREADING + /* For multithreading environment, schedule a call to netif_poll */ + tcpip_callback((tcpip_callback_fn)netif_poll, netif); +#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ + + return ERR_OK; +} + +/** + * Call netif_poll() in the main loop of your application. This is to prevent + * reentering non-reentrant functions like tcp_input(). Packets passed to + * netif_loop_output() are put on a list that is passed to netif->input() by + * netif_poll(). + */ +void +netif_poll(struct netif *netif) +{ + struct pbuf *in; + /* If we have a loopif, SNMP counters are adjusted for it, + * if not they are adjusted for 'netif'. */ +#if LWIP_SNMP +#if LWIP_HAVE_LOOPIF + struct netif *stats_if = &loop_netif; +#else /* LWIP_HAVE_LOOPIF */ + struct netif *stats_if = netif; +#endif /* LWIP_HAVE_LOOPIF */ +#endif /* LWIP_SNMP */ + SYS_ARCH_DECL_PROTECT(lev); + + do { + /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */ + SYS_ARCH_PROTECT(lev); + in = netif->loop_first; + if (in != NULL) { + struct pbuf *in_end = in; +#if LWIP_LOOPBACK_MAX_PBUFS + u8_t clen = pbuf_clen(in); + /* adjust the number of pbufs on queue */ + LWIP_ASSERT("netif->loop_cnt_current underflow", + ((netif->loop_cnt_current - clen) < netif->loop_cnt_current)); + netif->loop_cnt_current -= clen; +#endif /* LWIP_LOOPBACK_MAX_PBUFS */ + while (in_end->len != in_end->tot_len) { + LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL); + in_end = in_end->next; + } + /* 'in_end' now points to the last pbuf from 'in' */ + if (in_end == netif->loop_last) { + /* this was the last pbuf in the list */ + netif->loop_first = netif->loop_last = NULL; + } else { + /* pop the pbuf off the list */ + netif->loop_first = in_end->next; + LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL); + } + /* De-queue the pbuf from its successors on the 'loop_' list. */ + in_end->next = NULL; + } + SYS_ARCH_UNPROTECT(lev); + + if (in != NULL) { + LINK_STATS_INC(link.recv); + snmp_add_ifinoctets(stats_if, in->tot_len); + snmp_inc_ifinucastpkts(stats_if); + /* loopback packets are always IP packets! */ + if (ip_input(in, netif) != ERR_OK) { + pbuf_free(in); + } + /* Don't reference the packet any more! */ + in = NULL; + } + /* go on while there is a packet on the list */ + } while (netif->loop_first != NULL); +} + +#if !LWIP_NETIF_LOOPBACK_MULTITHREADING +/** + * Calls netif_poll() for every netif on the netif_list. + */ +void +netif_poll_all(void) +{ + struct netif *netif = netif_list; + /* loop through netifs */ + while (netif != NULL) { + netif_poll(netif); + /* proceed to next network interface */ + netif = netif->next; + } +} +#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ +#endif /* ENABLE_LOOPBACK */ diff --git a/user/mpy/lib/lwip/src/core/pbuf.c b/user/mpy/lib/lwip/src/core/pbuf.c new file mode 100644 index 0000000..1e5e53b --- /dev/null +++ b/user/mpy/lib/lwip/src/core/pbuf.c @@ -0,0 +1,1179 @@ +/** + * @file + * Packet buffer management + * + * Packets are built from the pbuf data structure. It supports dynamic + * memory allocation for packet contents or can reference externally + * managed packet contents both in RAM and ROM. Quick allocation for + * incoming packets is provided through pools with fixed sized pbufs. + * + * A packet may span over multiple pbufs, chained as a singly linked + * list. This is called a "pbuf chain". + * + * Multiple packets may be queued, also using this singly linked list. + * This is called a "packet queue". + * + * So, a packet queue consists of one or more pbuf chains, each of + * which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE + * NOT SUPPORTED!!! Use helper structs to queue multiple packets. + * + * The differences between a pbuf chain and a packet queue are very + * precise but subtle. + * + * The last pbuf of a packet has a ->tot_len field that equals the + * ->len field. It can be found by traversing the list. If the last + * pbuf of a packet has a ->next field other than NULL, more packets + * are on the queue. + * + * Therefore, looping through a pbuf of a single packet, has an + * loop end condition (tot_len == p->len), NOT (next == NULL). + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/stats.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/pbuf.h" +#include "lwip/sys.h" +#include "arch/perf.h" +#if LWIP_TCP && TCP_QUEUE_OOSEQ +#include "lwip/tcp_impl.h" +#endif +#if LWIP_CHECKSUM_ON_COPY +#include "lwip/inet_chksum.h" +#endif + +#include + +#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) +/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically + aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */ +#define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) + +#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ +#define PBUF_POOL_IS_EMPTY() +#else /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ */ + +#if !NO_SYS +#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL +#include "lwip/tcpip.h" +#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \ + if(tcpip_callback_with_block(pbuf_free_ooseq_callback, NULL, 0) != ERR_OK) { \ + SYS_ARCH_PROTECT(old_level); \ + pbuf_free_ooseq_pending = 0; \ + SYS_ARCH_UNPROTECT(old_level); \ + } } while(0) +#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ +#endif /* !NO_SYS */ + +volatile u8_t pbuf_free_ooseq_pending; +#define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty() + +/** + * Attempt to reclaim some memory from queued out-of-sequence TCP segments + * if we run out of pool pbufs. It's better to give priority to new packets + * if we're running out. + * + * This must be done in the correct thread context therefore this function + * can only be used with NO_SYS=0 and through tcpip_callback. + */ +#if !NO_SYS +static +#endif /* !NO_SYS */ +void +pbuf_free_ooseq(void) +{ + struct tcp_pcb* pcb; + SYS_ARCH_DECL_PROTECT(old_level); + + SYS_ARCH_PROTECT(old_level); + pbuf_free_ooseq_pending = 0; + SYS_ARCH_UNPROTECT(old_level); + + for (pcb = tcp_active_pcbs; NULL != pcb; pcb = pcb->next) { + if (NULL != pcb->ooseq) { + /** Free the ooseq pbufs of one PCB only */ + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free_ooseq: freeing out-of-sequence pbufs\n")); + tcp_segs_free(pcb->ooseq); + pcb->ooseq = NULL; + return; + } + } +} + +#if !NO_SYS +/** + * Just a callback function for tcpip_timeout() that calls pbuf_free_ooseq(). + */ +static void +pbuf_free_ooseq_callback(void *arg) +{ + LWIP_UNUSED_ARG(arg); + pbuf_free_ooseq(); +} +#endif /* !NO_SYS */ + +/** Queue a call to pbuf_free_ooseq if not already queued. */ +static void +pbuf_pool_is_empty(void) +{ +#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL + SYS_ARCH_DECL_PROTECT(old_level); + SYS_ARCH_PROTECT(old_level); + pbuf_free_ooseq_pending = 1; + SYS_ARCH_UNPROTECT(old_level); +#else /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ + u8_t queued; + SYS_ARCH_DECL_PROTECT(old_level); + SYS_ARCH_PROTECT(old_level); + queued = pbuf_free_ooseq_pending; + pbuf_free_ooseq_pending = 1; + SYS_ARCH_UNPROTECT(old_level); + + if(!queued) { + /* queue a call to pbuf_free_ooseq if not already queued */ + PBUF_POOL_FREE_OOSEQ_QUEUE_CALL(); + } +#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ +} +#endif /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ */ + +/** + * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). + * + * The actual memory allocated for the pbuf is determined by the + * layer at which the pbuf is allocated and the requested size + * (from the size parameter). + * + * @param layer flag to define header size + * @param length size of the pbuf's payload + * @param type this parameter decides how and where the pbuf + * should be allocated as follows: + * + * - PBUF_RAM: buffer memory for pbuf is allocated as one large + * chunk. This includes protocol headers as well. + * - PBUF_ROM: no buffer memory is allocated for the pbuf, even for + * protocol headers. Additional headers must be prepended + * by allocating another pbuf and chain in to the front of + * the ROM pbuf. It is assumed that the memory used is really + * similar to ROM in that it is immutable and will not be + * changed. Memory which is dynamic should generally not + * be attached to PBUF_ROM pbufs. Use PBUF_REF instead. + * - PBUF_REF: no buffer memory is allocated for the pbuf, even for + * protocol headers. It is assumed that the pbuf is only + * being used in a single thread. If the pbuf gets queued, + * then pbuf_take should be called to copy the buffer. + * - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from + * the pbuf pool that is allocated during pbuf_init(). + * + * @return the allocated pbuf. If multiple pbufs where allocated, this + * is the first pbuf of a pbuf chain. + */ +struct pbuf * +pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) +{ + struct pbuf *p, *q, *r; + u16_t offset; + s32_t rem_len; /* remaining length */ + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F")\n", length)); + + /* determine header offset */ + switch (layer) { + case PBUF_TRANSPORT: + /* add room for transport (often TCP) layer header */ + offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; + break; + case PBUF_IP: + /* add room for IP layer header */ + offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; + break; + case PBUF_LINK: + /* add room for link layer header */ + offset = PBUF_LINK_HLEN; + break; + case PBUF_RAW: + offset = 0; + break; + default: + LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0); + return NULL; + } + + switch (type) { + case PBUF_POOL: + /* allocate head of pbuf chain into p */ + p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); + if (p == NULL) { + PBUF_POOL_IS_EMPTY(); + return NULL; + } + p->type = type; + p->next = NULL; + + /* make the payload pointer point 'offset' bytes into pbuf data memory */ + p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + (SIZEOF_STRUCT_PBUF + offset))); + LWIP_ASSERT("pbuf_alloc: pbuf p->payload properly aligned", + ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); + /* the total length of the pbuf chain is the requested size */ + p->tot_len = length; + /* set the length of the first pbuf in the chain */ + p->len = LWIP_MIN(length, PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)); + LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", + ((u8_t*)p->payload + p->len <= + (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); + LWIP_ASSERT("PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT", + (PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)) > 0 ); + /* set reference count (needed here in case we fail) */ + p->ref = 1; + + /* now allocate the tail of the pbuf chain */ + + /* remember first pbuf for linkage in next iteration */ + r = p; + /* remaining length to be allocated */ + rem_len = length - p->len; + /* any remaining pbufs to be allocated? */ + while (rem_len > 0) { + q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); + if (q == NULL) { + PBUF_POOL_IS_EMPTY(); + /* free chain so far allocated */ + pbuf_free(p); + /* bail out unsuccesfully */ + return NULL; + } + q->type = type; + q->flags = 0; + q->next = NULL; + /* make previous pbuf point to this pbuf */ + r->next = q; + /* set total length of this pbuf and next in chain */ + LWIP_ASSERT("rem_len < max_u16_t", rem_len < 0xffff); + q->tot_len = (u16_t)rem_len; + /* this pbuf length is pool size, unless smaller sized tail */ + q->len = LWIP_MIN((u16_t)rem_len, PBUF_POOL_BUFSIZE_ALIGNED); + q->payload = (void *)((u8_t *)q + SIZEOF_STRUCT_PBUF); + LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", + ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0); + LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", + ((u8_t*)p->payload + p->len <= + (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); + q->ref = 1; + /* calculate remaining length to be allocated */ + rem_len -= q->len; + /* remember this pbuf for linkage in next iteration */ + r = q; + } + /* end of chain */ + /*r->next = NULL;*/ + + break; + case PBUF_RAM: + /* If pbuf is to be allocated in RAM, allocate memory for it. */ + p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length)); + if (p == NULL) { + return NULL; + } + /* Set up internal structure of the pbuf. */ + p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)); + p->len = p->tot_len = length; + p->next = NULL; + p->type = type; + + LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", + ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); + break; + /* pbuf references existing (non-volatile static constant) ROM payload? */ + case PBUF_ROM: + /* pbuf references existing (externally allocated) RAM payload? */ + case PBUF_REF: + /* only allocate memory for the pbuf structure */ + p = (struct pbuf *)memp_malloc(MEMP_PBUF); + if (p == NULL) { + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", + (type == PBUF_ROM) ? "ROM" : "REF")); + return NULL; + } + /* caller must set this field properly, afterwards */ + p->payload = NULL; + p->len = p->tot_len = length; + p->next = NULL; + p->type = type; + break; + default: + LWIP_ASSERT("pbuf_alloc: erroneous type", 0); + return NULL; + } + /* set reference count */ + p->ref = 1; + /* set flags */ + p->flags = 0; + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); + return p; +} + +#if LWIP_SUPPORT_CUSTOM_PBUF +/** Initialize a custom pbuf (already allocated). + * + * @param layer flag to define header size + * @param length size of the pbuf's payload + * @param type type of the pbuf (only used to treat the pbuf accordingly, as + * this function allocates no memory) + * @param p pointer to the custom pbuf to initialize (already allocated) + * @param payload_mem pointer to the buffer that is used for payload and headers, + * must be at least big enough to hold 'length' plus the header size, + * may be NULL if set later. + * ATTENTION: The caller is responsible for correct alignment of this buffer!! + * @param payload_mem_len the size of the 'payload_mem' buffer, must be at least + * big enough to hold 'length' plus the header size + */ +struct pbuf* +pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, + void *payload_mem, u16_t payload_mem_len) +{ + u16_t offset; + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloced_custom(length=%"U16_F")\n", length)); + + /* determine header offset */ + switch (l) { + case PBUF_TRANSPORT: + /* add room for transport (often TCP) layer header */ + offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; + break; + case PBUF_IP: + /* add room for IP layer header */ + offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; + break; + case PBUF_LINK: + /* add room for link layer header */ + offset = PBUF_LINK_HLEN; + break; + case PBUF_RAW: + offset = 0; + break; + default: + LWIP_ASSERT("pbuf_alloced_custom: bad pbuf layer", 0); + return NULL; + } + + if (LWIP_MEM_ALIGN_SIZE(offset) + length > payload_mem_len) { + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_WARNING, ("pbuf_alloced_custom(length=%"U16_F") buffer too short\n", length)); + return NULL; + } + + p->pbuf.next = NULL; + if (payload_mem != NULL) { + p->pbuf.payload = (u8_t *)payload_mem + LWIP_MEM_ALIGN_SIZE(offset); + } else { + p->pbuf.payload = NULL; + } + p->pbuf.flags = PBUF_FLAG_IS_CUSTOM; + p->pbuf.len = p->pbuf.tot_len = length; + p->pbuf.type = type; + p->pbuf.ref = 1; + return &p->pbuf; +} +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ + +/** + * Shrink a pbuf chain to a desired length. + * + * @param p pbuf to shrink. + * @param new_len desired new length of pbuf chain + * + * Depending on the desired length, the first few pbufs in a chain might + * be skipped and left unchanged. The new last pbuf in the chain will be + * resized, and any remaining pbufs will be freed. + * + * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted. + * @note May not be called on a packet queue. + * + * @note Despite its name, pbuf_realloc cannot grow the size of a pbuf (chain). + */ +void +pbuf_realloc(struct pbuf *p, u16_t new_len) +{ + struct pbuf *q; + u16_t rem_len; /* remaining length */ + s32_t grow; + + LWIP_ASSERT("pbuf_realloc: p != NULL", p != NULL); + LWIP_ASSERT("pbuf_realloc: sane p->type", p->type == PBUF_POOL || + p->type == PBUF_ROM || + p->type == PBUF_RAM || + p->type == PBUF_REF); + + /* desired length larger than current length? */ + if (new_len >= p->tot_len) { + /* enlarging not yet supported */ + return; + } + + /* the pbuf chain grows by (new_len - p->tot_len) bytes + * (which may be negative in case of shrinking) */ + grow = new_len - p->tot_len; + + /* first, step over any pbufs that should remain in the chain */ + rem_len = new_len; + q = p; + /* should this pbuf be kept? */ + while (rem_len > q->len) { + /* decrease remaining length by pbuf length */ + rem_len -= q->len; + /* decrease total length indicator */ + LWIP_ASSERT("grow < max_u16_t", grow < 0xffff); + q->tot_len += (u16_t)grow; + /* proceed to next pbuf in chain */ + q = q->next; + LWIP_ASSERT("pbuf_realloc: q != NULL", q != NULL); + } + /* we have now reached the new last pbuf (in q) */ + /* rem_len == desired length for pbuf q */ + + /* shrink allocated memory for PBUF_RAM */ + /* (other types merely adjust their length fields */ + if ((q->type == PBUF_RAM) && (rem_len != q->len)) { + /* reallocate and adjust the length of the pbuf that will be split */ + q = (struct pbuf *)mem_trim(q, (u16_t)((u8_t *)q->payload - (u8_t *)q) + rem_len); + LWIP_ASSERT("mem_trim returned q == NULL", q != NULL); + } + /* adjust length fields for new last pbuf */ + q->len = rem_len; + q->tot_len = q->len; + + /* any remaining pbufs in chain? */ + if (q->next != NULL) { + /* free remaining pbufs in chain */ + pbuf_free(q->next); + } + /* q is last packet in chain */ + q->next = NULL; + +} + +/** + * Adjusts the payload pointer to hide or reveal headers in the payload. + * + * Adjusts the ->payload pointer so that space for a header + * (dis)appears in the pbuf payload. + * + * The ->payload, ->tot_len and ->len fields are adjusted. + * + * @param p pbuf to change the header size. + * @param header_size_increment Number of bytes to increment header size which + * increases the size of the pbuf. New space is on the front. + * (Using a negative value decreases the header size.) + * If hdr_size_inc is 0, this function does nothing and returns succesful. + * + * PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so + * the call will fail. A check is made that the increase in header size does + * not move the payload pointer in front of the start of the buffer. + * @return non-zero on failure, zero on success. + * + */ +u8_t +pbuf_header(struct pbuf *p, s16_t header_size_increment) +{ + u16_t type; + void *payload; + u16_t increment_magnitude; + + LWIP_ASSERT("p != NULL", p != NULL); + if ((header_size_increment == 0) || (p == NULL)) { + return 0; + } + + if (header_size_increment < 0){ + increment_magnitude = -header_size_increment; + /* Check that we aren't going to move off the end of the pbuf */ + LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;); + } else { + increment_magnitude = header_size_increment; +#if 0 + /* Can't assert these as some callers speculatively call + pbuf_header() to see if it's OK. Will return 1 below instead. */ + /* Check that we've got the correct type of pbuf to work with */ + LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL", + p->type == PBUF_RAM || p->type == PBUF_POOL); + /* Check that we aren't going to move off the beginning of the pbuf */ + LWIP_ASSERT("p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF", + (u8_t *)p->payload - increment_magnitude >= (u8_t *)p + SIZEOF_STRUCT_PBUF); +#endif + } + + type = p->type; + /* remember current payload pointer */ + payload = p->payload; + + /* pbuf types containing payloads? */ + if (type == PBUF_RAM || type == PBUF_POOL) { + /* set new payload pointer */ + p->payload = (u8_t *)p->payload - header_size_increment; + /* boundary check fails? */ + if ((u8_t *)p->payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) { + LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("pbuf_header: failed as %p < %p (not enough space for new header size)\n", + (void *)p->payload, (void *)(p + 1))); + /* restore old payload pointer */ + p->payload = payload; + /* bail out unsuccesfully */ + return 1; + } + /* pbuf types refering to external payloads? */ + } else if (type == PBUF_REF || type == PBUF_ROM) { + /* hide a header in the payload? */ + if ((header_size_increment < 0) && (increment_magnitude <= p->len)) { + /* increase payload pointer */ + p->payload = (u8_t *)p->payload - header_size_increment; + } else { + /* cannot expand payload to front (yet!) + * bail out unsuccesfully */ + return 1; + } + } else { + /* Unknown type */ + LWIP_ASSERT("bad pbuf type", 0); + return 1; + } + /* modify pbuf length fields */ + p->len += header_size_increment; + p->tot_len += header_size_increment; + + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"S16_F")\n", + (void *)payload, (void *)p->payload, header_size_increment)); + + return 0; +} + +/** + * Dereference a pbuf chain or queue and deallocate any no-longer-used + * pbufs at the head of this chain or queue. + * + * Decrements the pbuf reference count. If it reaches zero, the pbuf is + * deallocated. + * + * For a pbuf chain, this is repeated for each pbuf in the chain, + * up to the first pbuf which has a non-zero reference count after + * decrementing. So, when all reference counts are one, the whole + * chain is free'd. + * + * @param p The pbuf (chain) to be dereferenced. + * + * @return the number of pbufs that were de-allocated + * from the head of the chain. + * + * @note MUST NOT be called on a packet queue (Not verified to work yet). + * @note the reference counter of a pbuf equals the number of pointers + * that refer to the pbuf (or into the pbuf). + * + * @internal examples: + * + * Assuming existing chains a->b->c with the following reference + * counts, calling pbuf_free(a) results in: + * + * 1->2->3 becomes ...1->3 + * 3->3->3 becomes 2->3->3 + * 1->1->2 becomes ......1 + * 2->1->1 becomes 1->1->1 + * 1->1->1 becomes ....... + * + */ +u8_t +pbuf_free(struct pbuf *p) +{ + u16_t type; + struct pbuf *q; + u8_t count; + + if (p == NULL) { + LWIP_ASSERT("p != NULL", p != NULL); + /* if assertions are disabled, proceed with debug output */ + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("pbuf_free(p == NULL) was called.\n")); + return 0; + } + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); + + PERF_START; + + LWIP_ASSERT("pbuf_free: sane type", + p->type == PBUF_RAM || p->type == PBUF_ROM || + p->type == PBUF_REF || p->type == PBUF_POOL); + + count = 0; + /* de-allocate all consecutive pbufs from the head of the chain that + * obtain a zero reference count after decrementing*/ + while (p != NULL) { + u16_t ref; + SYS_ARCH_DECL_PROTECT(old_level); + /* Since decrementing ref cannot be guaranteed to be a single machine operation + * we must protect it. We put the new ref into a local variable to prevent + * further protection. */ + SYS_ARCH_PROTECT(old_level); + /* all pbufs in a chain are referenced at least once */ + LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); + /* decrease reference count (number of pointers to pbuf) */ + ref = --(p->ref); + SYS_ARCH_UNPROTECT(old_level); + /* this pbuf is no longer referenced to? */ + if (ref == 0) { + /* remember next pbuf in chain for next iteration */ + q = p->next; + LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: deallocating %p\n", (void *)p)); + type = p->type; +#if LWIP_SUPPORT_CUSTOM_PBUF + /* is this a custom pbuf? */ + if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { + struct pbuf_custom *pc = (struct pbuf_custom*)p; + LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL); + pc->custom_free_function(p); + } else +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ + { + /* is this a pbuf from the pool? */ + if (type == PBUF_POOL) { + memp_free(MEMP_PBUF_POOL, p); + /* is this a ROM or RAM referencing pbuf? */ + } else if (type == PBUF_ROM || type == PBUF_REF) { + memp_free(MEMP_PBUF, p); + /* type == PBUF_RAM */ + } else { + mem_free(p); + } + } + count++; + /* proceed to next pbuf */ + p = q; + /* p->ref > 0, this pbuf is still referenced to */ + /* (and so the remaining pbufs in chain as well) */ + } else { + LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref)); + /* stop walking through the chain */ + p = NULL; + } + } + PERF_STOP("pbuf_free"); + /* return number of de-allocated pbufs */ + return count; +} + +/** + * Count number of pbufs in a chain + * + * @param p first pbuf of chain + * @return the number of pbufs in a chain + */ + +u8_t +pbuf_clen(struct pbuf *p) +{ + u8_t len; + + len = 0; + while (p != NULL) { + ++len; + p = p->next; + } + return len; +} + +/** + * Increment the reference count of the pbuf. + * + * @param p pbuf to increase reference counter of + * + */ +void +pbuf_ref(struct pbuf *p) +{ + SYS_ARCH_DECL_PROTECT(old_level); + /* pbuf given? */ + if (p != NULL) { + SYS_ARCH_PROTECT(old_level); + ++(p->ref); + SYS_ARCH_UNPROTECT(old_level); + } +} + +/** + * Concatenate two pbufs (each may be a pbuf chain) and take over + * the caller's reference of the tail pbuf. + * + * @note The caller MAY NOT reference the tail pbuf afterwards. + * Use pbuf_chain() for that purpose. + * + * @see pbuf_chain() + */ + +void +pbuf_cat(struct pbuf *h, struct pbuf *t) +{ + struct pbuf *p; + + LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)", + ((h != NULL) && (t != NULL)), return;); + + /* proceed to last pbuf of chain */ + for (p = h; p->next != NULL; p = p->next) { + /* add total length of second chain to all totals of first chain */ + p->tot_len += t->tot_len; + } + /* { p is last pbuf of first h chain, p->next == NULL } */ + LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); + LWIP_ASSERT("p->next == NULL", p->next == NULL); + /* add total length of second chain to last pbuf total of first chain */ + p->tot_len += t->tot_len; + /* chain last pbuf of head (p) with first of tail (t) */ + p->next = t; + /* p->next now references t, but the caller will drop its reference to t, + * so netto there is no change to the reference count of t. + */ +} + +/** + * Chain two pbufs (or pbuf chains) together. + * + * The caller MUST call pbuf_free(t) once it has stopped + * using it. Use pbuf_cat() instead if you no longer use t. + * + * @param h head pbuf (chain) + * @param t tail pbuf (chain) + * @note The pbufs MUST belong to the same packet. + * @note MAY NOT be called on a packet queue. + * + * The ->tot_len fields of all pbufs of the head chain are adjusted. + * The ->next field of the last pbuf of the head chain is adjusted. + * The ->ref field of the first pbuf of the tail chain is adjusted. + * + */ +void +pbuf_chain(struct pbuf *h, struct pbuf *t) +{ + pbuf_cat(h, t); + /* t is now referenced by h */ + pbuf_ref(t); + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t)); +} + +/** + * Dechains the first pbuf from its succeeding pbufs in the chain. + * + * Makes p->tot_len field equal to p->len. + * @param p pbuf to dechain + * @return remainder of the pbuf chain, or NULL if it was de-allocated. + * @note May not be called on a packet queue. + */ +struct pbuf * +pbuf_dechain(struct pbuf *p) +{ + struct pbuf *q; + u8_t tail_gone = 1; + /* tail */ + q = p->next; + /* pbuf has successor in chain? */ + if (q != NULL) { + /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ + LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); + /* enforce invariant if assertion is disabled */ + q->tot_len = p->tot_len - p->len; + /* decouple pbuf from remainder */ + p->next = NULL; + /* total length of pbuf p is its own length only */ + p->tot_len = p->len; + /* q is no longer referenced by p, free it */ + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_dechain: unreferencing %p\n", (void *)q)); + tail_gone = pbuf_free(q); + if (tail_gone > 0) { + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, + ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q)); + } + /* return remaining tail or NULL if deallocated */ + } + /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ + LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); + return ((tail_gone > 0) ? NULL : q); +} + +/** + * + * Create PBUF_RAM copies of pbufs. + * + * Used to queue packets on behalf of the lwIP stack, such as + * ARP based queueing. + * + * @note You MUST explicitly use p = pbuf_take(p); + * + * @note Only one packet is copied, no packet queue! + * + * @param p_to pbuf destination of the copy + * @param p_from pbuf source of the copy + * + * @return ERR_OK if pbuf was copied + * ERR_ARG if one of the pbufs is NULL or p_to is not big + * enough to hold p_from + */ +err_t +pbuf_copy(struct pbuf *p_to, struct pbuf *p_from) +{ + u16_t offset_to=0, offset_from=0, len; + + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n", + (void*)p_to, (void*)p_from)); + + /* is the target big enough to hold the source? */ + LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) && + (p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;); + + /* iterate through pbuf chain */ + do + { + /* copy one part of the original chain */ + if ((p_to->len - offset_to) >= (p_from->len - offset_from)) { + /* complete current p_from fits into current p_to */ + len = p_from->len - offset_from; + } else { + /* current p_from does not fit into current p_to */ + len = p_to->len - offset_to; + } + MEMCPY((u8_t*)p_to->payload + offset_to, (u8_t*)p_from->payload + offset_from, len); + offset_to += len; + offset_from += len; + LWIP_ASSERT("offset_to <= p_to->len", offset_to <= p_to->len); + LWIP_ASSERT("offset_from <= p_from->len", offset_from <= p_from->len); + if (offset_from >= p_from->len) { + /* on to next p_from (if any) */ + offset_from = 0; + p_from = p_from->next; + } + if (offset_to == p_to->len) { + /* on to next p_to (if any) */ + offset_to = 0; + p_to = p_to->next; + LWIP_ERROR("p_to != NULL", (p_to != NULL) || (p_from == NULL) , return ERR_ARG;); + } + + if((p_from != NULL) && (p_from->len == p_from->tot_len)) { + /* don't copy more than one packet! */ + LWIP_ERROR("pbuf_copy() does not allow packet queues!\n", + (p_from->next == NULL), return ERR_VAL;); + } + if((p_to != NULL) && (p_to->len == p_to->tot_len)) { + /* don't copy more than one packet! */ + LWIP_ERROR("pbuf_copy() does not allow packet queues!\n", + (p_to->next == NULL), return ERR_VAL;); + } + } while (p_from); + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy: end of chain reached.\n")); + return ERR_OK; +} + +/** + * Copy (part of) the contents of a packet buffer + * to an application supplied buffer. + * + * @param buf the pbuf from which to copy data + * @param dataptr the application supplied buffer + * @param len length of data to copy (dataptr must be big enough). No more + * than buf->tot_len will be copied, irrespective of len + * @param offset offset into the packet buffer from where to begin copying len bytes + * @return the number of bytes copied, or 0 on failure + */ +u16_t +pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset) +{ + struct pbuf *p; + u16_t left; + u16_t buf_copy_len; + u16_t copied_total = 0; + + LWIP_ERROR("pbuf_copy_partial: invalid buf", (buf != NULL), return 0;); + LWIP_ERROR("pbuf_copy_partial: invalid dataptr", (dataptr != NULL), return 0;); + + left = 0; + + if((buf == NULL) || (dataptr == NULL)) { + return 0; + } + + /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */ + for(p = buf; len != 0 && p != NULL; p = p->next) { + if ((offset != 0) && (offset >= p->len)) { + /* don't copy from this buffer -> on to the next */ + offset -= p->len; + } else { + /* copy from this buffer. maybe only partially. */ + buf_copy_len = p->len - offset; + if (buf_copy_len > len) + buf_copy_len = len; + /* copy the necessary parts of the buffer */ + MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len); + copied_total += buf_copy_len; + left += buf_copy_len; + len -= buf_copy_len; + offset = 0; + } + } + return copied_total; +} + +/** + * Copy application supplied data into a pbuf. + * This function can only be used to copy the equivalent of buf->tot_len data. + * + * @param buf pbuf to fill with data + * @param dataptr application supplied data buffer + * @param len length of the application supplied data buffer + * + * @return ERR_OK if successful, ERR_MEM if the pbuf is not big enough + */ +err_t +pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len) +{ + struct pbuf *p; + u16_t buf_copy_len; + u16_t total_copy_len = len; + u16_t copied_total = 0; + + LWIP_ERROR("pbuf_take: invalid buf", (buf != NULL), return 0;); + LWIP_ERROR("pbuf_take: invalid dataptr", (dataptr != NULL), return 0;); + + if ((buf == NULL) || (dataptr == NULL) || (buf->tot_len < len)) { + return ERR_ARG; + } + + /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */ + for(p = buf; total_copy_len != 0; p = p->next) { + LWIP_ASSERT("pbuf_take: invalid pbuf", p != NULL); + buf_copy_len = total_copy_len; + if (buf_copy_len > p->len) { + /* this pbuf cannot hold all remaining data */ + buf_copy_len = p->len; + } + /* copy the necessary parts of the buffer */ + MEMCPY(p->payload, &((char*)dataptr)[copied_total], buf_copy_len); + total_copy_len -= buf_copy_len; + copied_total += buf_copy_len; + } + LWIP_ASSERT("did not copy all data", total_copy_len == 0 && copied_total == len); + return ERR_OK; +} + +/** + * Creates a single pbuf out of a queue of pbufs. + * + * @remark: Either the source pbuf 'p' is freed by this function or the original + * pbuf 'p' is returned, therefore the caller has to check the result! + * + * @param p the source pbuf + * @param layer pbuf_layer of the new pbuf + * + * @return a new, single pbuf (p->next is NULL) + * or the old pbuf if allocation fails + */ +struct pbuf* +pbuf_coalesce(struct pbuf *p, pbuf_layer layer) +{ + struct pbuf *q; + err_t err; + if (p->next == NULL) { + return p; + } + q = pbuf_alloc(layer, p->tot_len, PBUF_RAM); + if (q == NULL) { + /* @todo: what do we do now? */ + return p; + } + err = pbuf_copy(q, p); + LWIP_ASSERT("pbuf_copy failed", err == ERR_OK); + pbuf_free(p); + return q; +} + +#if LWIP_CHECKSUM_ON_COPY +/** + * Copies data into a single pbuf (*not* into a pbuf queue!) and updates + * the checksum while copying + * + * @param p the pbuf to copy data into + * @param start_offset offset of p->payload where to copy the data to + * @param dataptr data to copy into the pbuf + * @param len length of data to copy into the pbuf + * @param chksum pointer to the checksum which is updated + * @return ERR_OK if successful, another error if the data does not fit + * within the (first) pbuf (no pbuf queues!) + */ +err_t +pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, + u16_t len, u16_t *chksum) +{ + u32_t acc; + u16_t copy_chksum; + char *dst_ptr; + LWIP_ASSERT("p != NULL", p != NULL); + LWIP_ASSERT("dataptr != NULL", dataptr != NULL); + LWIP_ASSERT("chksum != NULL", chksum != NULL); + LWIP_ASSERT("len != 0", len != 0); + + if ((start_offset >= p->len) || (start_offset + len > p->len)) { + return ERR_ARG; + } + + dst_ptr = ((char*)p->payload) + start_offset; + copy_chksum = LWIP_CHKSUM_COPY(dst_ptr, dataptr, len); + if ((start_offset & 1) != 0) { + copy_chksum = SWAP_BYTES_IN_WORD(copy_chksum); + } + acc = *chksum; + acc += copy_chksum; + *chksum = FOLD_U32T(acc); + return ERR_OK; +} +#endif /* LWIP_CHECKSUM_ON_COPY */ + + /** Get one byte from the specified position in a pbuf + * WARNING: returns zero for offset >= p->tot_len + * + * @param p pbuf to parse + * @param offset offset into p of the byte to return + * @return byte at an offset into p OR ZERO IF 'offset' >= p->tot_len + */ +u8_t +pbuf_get_at(struct pbuf* p, u16_t offset) +{ + u16_t copy_from = offset; + struct pbuf* q = p; + + /* get the correct pbuf */ + while ((q != NULL) && (q->len <= copy_from)) { + copy_from -= q->len; + q = q->next; + } + /* return requested data if pbuf is OK */ + if ((q != NULL) && (q->len > copy_from)) { + return ((u8_t*)q->payload)[copy_from]; + } + return 0; +} + +/** Compare pbuf contents at specified offset with memory s2, both of length n + * + * @param p pbuf to compare + * @param offset offset into p at wich to start comparing + * @param s2 buffer to compare + * @param n length of buffer to compare + * @return zero if equal, nonzero otherwise + * (0xffff if p is too short, diffoffset+1 otherwise) + */ +u16_t +pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n) +{ + u16_t start = offset; + struct pbuf* q = p; + + /* get the correct pbuf */ + while ((q != NULL) && (q->len <= start)) { + start -= q->len; + q = q->next; + } + /* return requested data if pbuf is OK */ + if ((q != NULL) && (q->len > start)) { + u16_t i; + for(i = 0; i < n; i++) { + u8_t a = pbuf_get_at(q, start + i); + u8_t b = ((u8_t*)s2)[i]; + if (a != b) { + return i+1; + } + } + return 0; + } + return 0xffff; +} + +/** Find occurrence of mem (with length mem_len) in pbuf p, starting at offset + * start_offset. + * + * @param p pbuf to search, maximum length is 0xFFFE since 0xFFFF is used as + * return value 'not found' + * @param mem search for the contents of this buffer + * @param mem_len length of 'mem' + * @param start_offset offset into p at which to start searching + * @return 0xFFFF if substr was not found in p or the index where it was found + */ +u16_t +pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset) +{ + u16_t i; + u16_t max = p->tot_len - mem_len; + if (p->tot_len >= mem_len + start_offset) { + for(i = start_offset; i <= max; ) { + u16_t plus = pbuf_memcmp(p, i, mem, mem_len); + if (plus == 0) { + return i; + } else { + i += plus; + } + } + } + return 0xFFFF; +} + +/** Find occurrence of substr with length substr_len in pbuf p, start at offset + * start_offset + * WARNING: in contrast to strstr(), this one does not stop at the first \0 in + * the pbuf/source string! + * + * @param p pbuf to search, maximum length is 0xFFFE since 0xFFFF is used as + * return value 'not found' + * @param substr string to search for in p, maximum length is 0xFFFE + * @return 0xFFFF if substr was not found in p or the index where it was found + */ +u16_t +pbuf_strstr(struct pbuf* p, const char* substr) +{ + size_t substr_len; + if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { + return 0xFFFF; + } + substr_len = strlen(substr); + if (substr_len >= 0xFFFF) { + return 0xFFFF; + } + return pbuf_memfind(p, substr, (u16_t)substr_len, 0); +} diff --git a/user/mpy/lib/lwip/src/core/raw.c b/user/mpy/lib/lwip/src/core/raw.c new file mode 100644 index 0000000..7160c0f --- /dev/null +++ b/user/mpy/lib/lwip/src/core/raw.c @@ -0,0 +1,350 @@ +/** + * @file + * Implementation of raw protocol PCBs for low-level handling of + * different types of protocols besides (or overriding) those + * already available in lwIP. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/def.h" +#include "lwip/memp.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/raw.h" +#include "lwip/stats.h" +#include "arch/perf.h" + +#include + +/** The list of RAW PCBs */ +static struct raw_pcb *raw_pcbs; + +/** + * Determine if in incoming IP packet is covered by a RAW PCB + * and if so, pass it to a user-provided receive callback function. + * + * Given an incoming IP datagram (as a chain of pbufs) this function + * finds a corresponding RAW PCB and calls the corresponding receive + * callback function. + * + * @param p pbuf to be demultiplexed to a RAW PCB. + * @param inp network interface on which the datagram was received. + * @return - 1 if the packet has been eaten by a RAW PCB receive + * callback function. The caller MAY NOT not reference the + * packet any longer, and MAY NOT call pbuf_free(). + * @return - 0 if packet is not eaten (pbuf is still referenced by the + * caller). + * + */ +u8_t +raw_input(struct pbuf *p, struct netif *inp) +{ + struct raw_pcb *pcb, *prev; + struct ip_hdr *iphdr; + s16_t proto; + u8_t eaten = 0; + + LWIP_UNUSED_ARG(inp); + + iphdr = (struct ip_hdr *)p->payload; + proto = IPH_PROTO(iphdr); + + prev = NULL; + pcb = raw_pcbs; + /* loop through all raw pcbs until the packet is eaten by one */ + /* this allows multiple pcbs to match against the packet by design */ + while ((eaten == 0) && (pcb != NULL)) { + if ((pcb->protocol == proto) && + (ip_addr_isany(&pcb->local_ip) || + ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest))) { +#if IP_SOF_BROADCAST_RECV + /* broadcast filter? */ + if (ip_get_option(pcb, SOF_BROADCAST) || !ip_addr_isbroadcast(¤t_iphdr_dest, inp)) +#endif /* IP_SOF_BROADCAST_RECV */ + { + /* receive callback function available? */ + if (pcb->recv != NULL) { + /* the receive callback function did not eat the packet? */ + if (pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr()) != 0) { + /* receive function ate the packet */ + p = NULL; + eaten = 1; + if (prev != NULL) { + /* move the pcb to the front of raw_pcbs so that is + found faster next time */ + prev->next = pcb->next; + pcb->next = raw_pcbs; + raw_pcbs = pcb; + } + } + } + /* no receive callback function was set for this raw PCB */ + } + /* drop the packet */ + } + prev = pcb; + pcb = pcb->next; + } + return eaten; +} + +/** + * Bind a RAW PCB. + * + * @param pcb RAW PCB to be bound with a local address ipaddr. + * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to + * bind to all local interfaces. + * + * @return lwIP error code. + * - ERR_OK. Successful. No error occured. + * - ERR_USE. The specified IP address is already bound to by + * another RAW PCB. + * + * @see raw_disconnect() + */ +err_t +raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr) +{ + ip_addr_set(&pcb->local_ip, ipaddr); + return ERR_OK; +} + +/** + * Connect an RAW PCB. This function is required by upper layers + * of lwip. Using the raw api you could use raw_sendto() instead + * + * This will associate the RAW PCB with the remote address. + * + * @param pcb RAW PCB to be connected with remote address ipaddr and port. + * @param ipaddr remote IP address to connect with. + * + * @return lwIP error code + * + * @see raw_disconnect() and raw_sendto() + */ +err_t +raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr) +{ + ip_addr_set(&pcb->remote_ip, ipaddr); + return ERR_OK; +} + + +/** + * Set the callback function for received packets that match the + * raw PCB's protocol and binding. + * + * The callback function MUST either + * - eat the packet by calling pbuf_free() and returning non-zero. The + * packet will not be passed to other raw PCBs or other protocol layers. + * - not free the packet, and return zero. The packet will be matched + * against further PCBs and/or forwarded to another protocol layers. + * + * @return non-zero if the packet was free()d, zero if the packet remains + * available for others. + */ +void +raw_recv(struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg) +{ + /* remember recv() callback and user data */ + pcb->recv = recv; + pcb->recv_arg = recv_arg; +} + +/** + * Send the raw IP packet to the given address. Note that actually you cannot + * modify the IP headers (this is inconsistent with the receive callback where + * you actually get the IP headers), you can only specify the IP payload here. + * It requires some more changes in lwIP. (there will be a raw_send() function + * then.) + * + * @param pcb the raw pcb which to send + * @param p the IP payload to send + * @param ipaddr the destination address of the IP packet + * + */ +err_t +raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr) +{ + err_t err; + struct netif *netif; + ip_addr_t *src_ip; + struct pbuf *q; /* q will be sent down the stack */ + + LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n")); + + /* not enough space to add an IP header to first pbuf in given p chain? */ + if (pbuf_header(p, IP_HLEN)) { + /* allocate header in new pbuf */ + q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM); + /* new header pbuf could not be allocated? */ + if (q == NULL) { + LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("raw_sendto: could not allocate header\n")); + return ERR_MEM; + } + if (p->tot_len != 0) { + /* chain header q in front of given pbuf p */ + pbuf_chain(q, p); + } + /* { first pbuf q points to header pbuf } */ + LWIP_DEBUGF(RAW_DEBUG, ("raw_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); + } else { + /* first pbuf q equals given pbuf */ + q = p; + if(pbuf_header(q, -IP_HLEN)) { + LWIP_ASSERT("Can't restore header we just removed!", 0); + return ERR_MEM; + } + } + + if ((netif = ip_route(ipaddr)) == NULL) { + LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr))); + /* free any temporary header pbuf allocated by pbuf_header() */ + if (q != p) { + pbuf_free(q); + } + return ERR_RTE; + } + +#if IP_SOF_BROADCAST + /* broadcast filter? */ + if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(ipaddr, netif)) { + LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); + /* free any temporary header pbuf allocated by pbuf_header() */ + if (q != p) { + pbuf_free(q); + } + return ERR_VAL; + } +#endif /* IP_SOF_BROADCAST */ + + if (ip_addr_isany(&pcb->local_ip)) { + /* use outgoing network interface IP address as source address */ + src_ip = &(netif->ip_addr); + } else { + /* use RAW PCB local IP address as source address */ + src_ip = &(pcb->local_ip); + } + + NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint); + err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif); + NETIF_SET_HWADDRHINT(netif, NULL); + + /* did we chain a header earlier? */ + if (q != p) { + /* free the header */ + pbuf_free(q); + } + return err; +} + +/** + * Send the raw IP packet to the address given by raw_connect() + * + * @param pcb the raw pcb which to send + * @param p the IP payload to send + * + */ +err_t +raw_send(struct raw_pcb *pcb, struct pbuf *p) +{ + return raw_sendto(pcb, p, &pcb->remote_ip); +} + +/** + * Remove an RAW PCB. + * + * @param pcb RAW PCB to be removed. The PCB is removed from the list of + * RAW PCB's and the data structure is freed from memory. + * + * @see raw_new() + */ +void +raw_remove(struct raw_pcb *pcb) +{ + struct raw_pcb *pcb2; + /* pcb to be removed is first in list? */ + if (raw_pcbs == pcb) { + /* make list start at 2nd pcb */ + raw_pcbs = raw_pcbs->next; + /* pcb not 1st in list */ + } else { + for(pcb2 = raw_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { + /* find pcb in raw_pcbs list */ + if (pcb2->next != NULL && pcb2->next == pcb) { + /* remove pcb from list */ + pcb2->next = pcb->next; + } + } + } + memp_free(MEMP_RAW_PCB, pcb); +} + +/** + * Create a RAW PCB. + * + * @return The RAW PCB which was created. NULL if the PCB data structure + * could not be allocated. + * + * @param proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP) + * + * @see raw_remove() + */ +struct raw_pcb * +raw_new(u8_t proto) +{ + struct raw_pcb *pcb; + + LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_new\n")); + + pcb = (struct raw_pcb *)memp_malloc(MEMP_RAW_PCB); + /* could allocate RAW PCB? */ + if (pcb != NULL) { + /* initialize PCB to all zeroes */ + memset(pcb, 0, sizeof(struct raw_pcb)); + pcb->protocol = proto; + pcb->ttl = RAW_TTL; + pcb->next = raw_pcbs; + raw_pcbs = pcb; + } + return pcb; +} + +#endif /* LWIP_RAW */ diff --git a/user/mpy/lib/lwip/src/core/snmp/asn1_dec.c b/user/mpy/lib/lwip/src/core/snmp/asn1_dec.c new file mode 100644 index 0000000..1d56582 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/snmp/asn1_dec.c @@ -0,0 +1,657 @@ +/** + * @file + * Abstract Syntax Notation One (ISO 8824, 8825) decoding + * + * @todo not optimised (yet), favor correctness over speed, favor speed over size + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/snmp_asn1.h" + +/** + * Retrieves type field from incoming pbuf chain. + * + * @param p points to a pbuf holding an ASN1 coded type field + * @param ofs points to the offset within the pbuf chain of the ASN1 coded type field + * @param type return ASN1 type + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode + */ +err_t +snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + *type = *msg_ptr; + return ERR_OK; + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Decodes length field from incoming pbuf chain into host length. + * + * @param p points to a pbuf holding an ASN1 coded length + * @param ofs points to the offset within the pbuf chain of the ASN1 coded length + * @param octets_used returns number of octets used by the length code + * @param length return host order length, upto 64k + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode + */ +err_t +snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + if (*msg_ptr < 0x80) + { + /* primitive definite length format */ + *octets_used = 1; + *length = *msg_ptr; + return ERR_OK; + } + else if (*msg_ptr == 0x80) + { + /* constructed indefinite length format, termination with two zero octets */ + u8_t zeros; + u8_t i; + + *length = 0; + zeros = 0; + while (zeros != 2) + { + i = 2; + while (i > 0) + { + i--; + (*length) += 1; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + if (*msg_ptr == 0) + { + zeros++; + if (zeros == 2) + { + /* stop while (i > 0) */ + i = 0; + } + } + else + { + zeros = 0; + } + } + } + *octets_used = 1; + return ERR_OK; + } + else if (*msg_ptr == 0x81) + { + /* constructed definite length format, one octet */ + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + *length = *msg_ptr; + *octets_used = 2; + return ERR_OK; + } + else if (*msg_ptr == 0x82) + { + u8_t i; + + /* constructed definite length format, two octets */ + i = 2; + while (i > 0) + { + i--; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + if (i == 0) + { + /* least significant length octet */ + *length |= *msg_ptr; + } + else + { + /* most significant length octet */ + *length = (*msg_ptr) << 8; + } + } + *octets_used = 3; + return ERR_OK; + } + else + { + /* constructed definite length format 3..127 octets, this is too big (>64k) */ + /** @todo: do we need to accept inefficient codings with many leading zero's? */ + *octets_used = 1 + ((*msg_ptr) & 0x7f); + return ERR_ARG; + } + } + p = p->next; + } + + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Decodes positive integer (counter, gauge, timeticks) into u32_t. + * + * @param p points to a pbuf holding an ASN1 coded integer + * @param ofs points to the offset within the pbuf chain of the ASN1 coded integer + * @param len length of the coded integer field + * @param value return host order integer + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode + * + * @note ASN coded integers are _always_ signed. E.g. +0xFFFF is coded + * as 0x00,0xFF,0xFF. Note the leading sign octet. A positive value + * of 0xFFFFFFFF is preceded with 0x00 and the length is 5 octets!! + */ +err_t +snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + if ((len > 0) && (len < 6)) + { + /* start from zero */ + *value = 0; + if (*msg_ptr & 0x80) + { + /* negative, expecting zero sign bit! */ + return ERR_ARG; + } + else + { + /* positive */ + if ((len > 1) && (*msg_ptr == 0)) + { + /* skip leading "sign byte" octet 0x00 */ + len--; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + } + /* OR octets with value */ + while (len > 1) + { + len--; + *value |= *msg_ptr; + *value <<= 8; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + *value |= *msg_ptr; + return ERR_OK; + } + else + { + return ERR_ARG; + } + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Decodes integer into s32_t. + * + * @param p points to a pbuf holding an ASN1 coded integer + * @param ofs points to the offset within the pbuf chain of the ASN1 coded integer + * @param len length of the coded integer field + * @param value return host order integer + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode + * + * @note ASN coded integers are _always_ signed! + */ +err_t +snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value) +{ + u16_t plen, base; + u8_t *msg_ptr; +#if BYTE_ORDER == LITTLE_ENDIAN + u8_t *lsb_ptr = (u8_t*)value; +#endif +#if BYTE_ORDER == BIG_ENDIAN + u8_t *lsb_ptr = (u8_t*)value + sizeof(s32_t) - 1; +#endif + u8_t sign; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + if ((len > 0) && (len < 5)) + { + if (*msg_ptr & 0x80) + { + /* negative, start from -1 */ + *value = -1; + sign = 1; + } + else + { + /* positive, start from 0 */ + *value = 0; + sign = 0; + } + /* OR/AND octets with value */ + while (len > 1) + { + len--; + if (sign) + { + *lsb_ptr &= *msg_ptr; + *value <<= 8; + *lsb_ptr |= 255; + } + else + { + *lsb_ptr |= *msg_ptr; + *value <<= 8; + } + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + if (sign) + { + *lsb_ptr &= *msg_ptr; + } + else + { + *lsb_ptr |= *msg_ptr; + } + return ERR_OK; + } + else + { + return ERR_ARG; + } + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Decodes object identifier from incoming message into array of s32_t. + * + * @param p points to a pbuf holding an ASN1 coded object identifier + * @param ofs points to the offset within the pbuf chain of the ASN1 coded object identifier + * @param len length of the coded object identifier + * @param oid return object identifier struct + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode + */ +err_t +snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid) +{ + u16_t plen, base; + u8_t *msg_ptr; + s32_t *oid_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + oid->len = 0; + oid_ptr = &oid->id[0]; + if (len > 0) + { + /* first compressed octet */ + if (*msg_ptr == 0x2B) + { + /* (most) common case 1.3 (iso.org) */ + *oid_ptr = 1; + oid_ptr++; + *oid_ptr = 3; + oid_ptr++; + } + else if (*msg_ptr < 40) + { + *oid_ptr = 0; + oid_ptr++; + *oid_ptr = *msg_ptr; + oid_ptr++; + } + else if (*msg_ptr < 80) + { + *oid_ptr = 1; + oid_ptr++; + *oid_ptr = (*msg_ptr) - 40; + oid_ptr++; + } + else + { + *oid_ptr = 2; + oid_ptr++; + *oid_ptr = (*msg_ptr) - 80; + oid_ptr++; + } + oid->len = 2; + } + else + { + /* accepting zero length identifiers e.g. for + getnext operation. uncommon but valid */ + return ERR_OK; + } + len--; + if (len > 0) + { + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + while ((len > 0) && (oid->len < LWIP_SNMP_OBJ_ID_LEN)) + { + /* sub-identifier uses multiple octets */ + if (*msg_ptr & 0x80) + { + s32_t sub_id = 0; + + while ((*msg_ptr & 0x80) && (len > 1)) + { + len--; + sub_id = (sub_id << 7) + (*msg_ptr & ~0x80); + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + if (!(*msg_ptr & 0x80) && (len > 0)) + { + /* last octet sub-identifier */ + len--; + sub_id = (sub_id << 7) + *msg_ptr; + *oid_ptr = sub_id; + } + } + else + { + /* !(*msg_ptr & 0x80) sub-identifier uses single octet */ + len--; + *oid_ptr = *msg_ptr; + } + if (len > 0) + { + /* remaining oid bytes available ... */ + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + oid_ptr++; + oid->len++; + } + if (len == 0) + { + /* len == 0, end of oid */ + return ERR_OK; + } + else + { + /* len > 0, oid->len == LWIP_SNMP_OBJ_ID_LEN or malformed encoding */ + return ERR_ARG; + } + + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Decodes (copies) raw data (ip-addresses, octet strings, opaque encoding) + * from incoming message into array. + * + * @param p points to a pbuf holding an ASN1 coded raw data + * @param ofs points to the offset within the pbuf chain of the ASN1 coded raw data + * @param len length of the coded raw data (zero is valid, e.g. empty string!) + * @param raw_len length of the raw return value + * @param raw return raw bytes + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode + */ +err_t +snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw) +{ + u16_t plen, base; + u8_t *msg_ptr; + + if (len > 0) + { + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + if (raw_len >= len) + { + while (len > 1) + { + /* copy len - 1 octets */ + len--; + *raw = *msg_ptr; + raw++; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + /* copy last octet */ + *raw = *msg_ptr; + return ERR_OK; + } + else + { + /* raw_len < len, not enough dst space */ + return ERR_ARG; + } + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; + } + else + { + /* len == 0, empty string */ + return ERR_OK; + } +} + +#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/asn1_enc.c b/user/mpy/lib/lwip/src/core/snmp/asn1_enc.c new file mode 100644 index 0000000..64dfc5f --- /dev/null +++ b/user/mpy/lib/lwip/src/core/snmp/asn1_enc.c @@ -0,0 +1,611 @@ +/** + * @file + * Abstract Syntax Notation One (ISO 8824, 8825) encoding + * + * @todo not optimised (yet), favor correctness over speed, favor speed over size + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/snmp_asn1.h" + +/** + * Returns octet count for length. + * + * @param length + * @param octets_needed points to the return value + */ +void +snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed) +{ + if (length < 0x80U) + { + *octets_needed = 1; + } + else if (length < 0x100U) + { + *octets_needed = 2; + } + else + { + *octets_needed = 3; + } +} + +/** + * Returns octet count for an u32_t. + * + * @param value + * @param octets_needed points to the return value + * + * @note ASN coded integers are _always_ signed. E.g. +0xFFFF is coded + * as 0x00,0xFF,0xFF. Note the leading sign octet. A positive value + * of 0xFFFFFFFF is preceded with 0x00 and the length is 5 octets!! + */ +void +snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed) +{ + if (value < 0x80UL) + { + *octets_needed = 1; + } + else if (value < 0x8000UL) + { + *octets_needed = 2; + } + else if (value < 0x800000UL) + { + *octets_needed = 3; + } + else if (value < 0x80000000UL) + { + *octets_needed = 4; + } + else + { + *octets_needed = 5; + } +} + +/** + * Returns octet count for an s32_t. + * + * @param value + * @param octets_needed points to the return value + * + * @note ASN coded integers are _always_ signed. + */ +void +snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed) +{ + if (value < 0) + { + value = ~value; + } + if (value < 0x80L) + { + *octets_needed = 1; + } + else if (value < 0x8000L) + { + *octets_needed = 2; + } + else if (value < 0x800000L) + { + *octets_needed = 3; + } + else + { + *octets_needed = 4; + } +} + +/** + * Returns octet count for an object identifier. + * + * @param ident_len object identifier array length + * @param ident points to object identifier array + * @param octets_needed points to the return value + */ +void +snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed) +{ + s32_t sub_id; + u8_t cnt; + + cnt = 0; + if (ident_len > 1) + { + /* compressed prefix in one octet */ + cnt++; + ident_len -= 2; + ident += 2; + } + while(ident_len > 0) + { + ident_len--; + sub_id = *ident; + + sub_id >>= 7; + cnt++; + while(sub_id > 0) + { + sub_id >>= 7; + cnt++; + } + ident++; + } + *octets_needed = cnt; +} + +/** + * Encodes ASN type field into a pbuf chained ASN1 msg. + * + * @param p points to output pbuf to encode value into + * @param ofs points to the offset within the pbuf chain + * @param type input ASN1 type + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode + */ +err_t +snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + *msg_ptr = type; + return ERR_OK; + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Encodes host order length field into a pbuf chained ASN1 msg. + * + * @param p points to output pbuf to encode length into + * @param ofs points to the offset within the pbuf chain + * @param length is the host order length to be encoded + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode + */ +err_t +snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + if (length < 0x80) + { + *msg_ptr = (u8_t)length; + return ERR_OK; + } + else if (length < 0x100) + { + *msg_ptr = 0x81; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + *msg_ptr = (u8_t)length; + return ERR_OK; + } + else + { + u8_t i; + + /* length >= 0x100 && length <= 0xFFFF */ + *msg_ptr = 0x82; + i = 2; + while (i > 0) + { + i--; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + if (i == 0) + { + /* least significant length octet */ + *msg_ptr = (u8_t)length; + } + else + { + /* most significant length octet */ + *msg_ptr = (u8_t)(length >> 8); + } + } + return ERR_OK; + } + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Encodes u32_t (counter, gauge, timeticks) into a pbuf chained ASN1 msg. + * + * @param p points to output pbuf to encode value into + * @param ofs points to the offset within the pbuf chain + * @param octets_needed encoding length (from snmp_asn1_enc_u32t_cnt()) + * @param value is the host order u32_t value to be encoded + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode + * + * @see snmp_asn1_enc_u32t_cnt() + */ +err_t +snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + if (octets_needed == 5) + { + /* not enough bits in 'value' add leading 0x00 */ + octets_needed--; + *msg_ptr = 0x00; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + while (octets_needed > 1) + { + octets_needed--; + *msg_ptr = (u8_t)(value >> (octets_needed << 3)); + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + /* (only) one least significant octet */ + *msg_ptr = (u8_t)value; + return ERR_OK; + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Encodes s32_t integer into a pbuf chained ASN1 msg. + * + * @param p points to output pbuf to encode value into + * @param ofs points to the offset within the pbuf chain + * @param octets_needed encoding length (from snmp_asn1_enc_s32t_cnt()) + * @param value is the host order s32_t value to be encoded + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode + * + * @see snmp_asn1_enc_s32t_cnt() + */ +err_t +snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + while (octets_needed > 1) + { + octets_needed--; + *msg_ptr = (u8_t)(value >> (octets_needed << 3)); + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + /* (only) one least significant octet */ + *msg_ptr = (u8_t)value; + return ERR_OK; + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Encodes object identifier into a pbuf chained ASN1 msg. + * + * @param p points to output pbuf to encode oid into + * @param ofs points to the offset within the pbuf chain + * @param ident_len object identifier array length + * @param ident points to object identifier array + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode + */ +err_t +snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + if (ident_len > 1) + { + if ((ident[0] == 1) && (ident[1] == 3)) + { + /* compressed (most common) prefix .iso.org */ + *msg_ptr = 0x2b; + } + else + { + /* calculate prefix */ + *msg_ptr = (u8_t)((ident[0] * 40) + ident[1]); + } + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + ident_len -= 2; + ident += 2; + } + else + { +/* @bug: allow empty varbinds for symmetry (we must decode them for getnext), allow partial compression?? */ + /* ident_len <= 1, at least we need zeroDotZero (0.0) (ident_len == 2) */ + return ERR_ARG; + } + while (ident_len > 0) + { + s32_t sub_id; + u8_t shift, tail; + + ident_len--; + sub_id = *ident; + tail = 0; + shift = 28; + while(shift > 0) + { + u8_t code; + + code = (u8_t)(sub_id >> shift); + if ((code != 0) || (tail != 0)) + { + tail = 1; + *msg_ptr = code | 0x80; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + shift -= 7; + } + *msg_ptr = (u8_t)sub_id & 0x7F; + if (ident_len > 0) + { + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + /* proceed to next sub-identifier */ + ident++; + } + return ERR_OK; + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +/** + * Encodes raw data (octet string, opaque) into a pbuf chained ASN1 msg. + * + * @param p points to output pbuf to encode raw data into + * @param ofs points to the offset within the pbuf chain + * @param raw_len raw data length + * @param raw points raw data + * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode + */ +err_t +snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw) +{ + u16_t plen, base; + u8_t *msg_ptr; + + plen = 0; + while (p != NULL) + { + base = plen; + plen += p->len; + if (ofs < plen) + { + msg_ptr = (u8_t*)p->payload; + msg_ptr += ofs - base; + + while (raw_len > 1) + { + /* copy raw_len - 1 octets */ + raw_len--; + *msg_ptr = *raw; + raw++; + ofs += 1; + if (ofs >= plen) + { + /* next octet in next pbuf */ + p = p->next; + if (p == NULL) { return ERR_ARG; } + msg_ptr = (u8_t*)p->payload; + plen += p->len; + } + else + { + /* next octet in same pbuf */ + msg_ptr++; + } + } + if (raw_len > 0) + { + /* copy last or single octet */ + *msg_ptr = *raw; + } + return ERR_OK; + } + p = p->next; + } + /* p == NULL, ofs >= plen */ + return ERR_ARG; +} + +#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/mib2.c b/user/mpy/lib/lwip/src/core/snmp/mib2.c new file mode 100644 index 0000000..4775ba9 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/snmp/mib2.c @@ -0,0 +1,4146 @@ +/** + * @file + * Management Information Base II (RFC1213) objects and functions. + * + * @note the object identifiers for this MIB-2 and private MIB tree + * must be kept in sorted ascending order. This to ensure correct getnext operation. + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/snmp.h" +#include "lwip/netif.h" +#include "lwip/ip.h" +#include "lwip/ip_frag.h" +#include "lwip/mem.h" +#include "lwip/tcp_impl.h" +#include "lwip/udp.h" +#include "lwip/snmp_asn1.h" +#include "lwip/snmp_structs.h" +#include "lwip/sys.h" +#include "netif/etharp.h" + +/** + * IANA assigned enterprise ID for lwIP is 26381 + * @see http://www.iana.org/assignments/enterprise-numbers + * + * @note this enterprise ID is assigned to the lwIP project, + * all object identifiers living under this ID are assigned + * by the lwIP maintainers (contact Christiaan Simons)! + * @note don't change this define, use snmp_set_sysobjid() + * + * If you need to create your own private MIB you'll need + * to apply for your own enterprise ID with IANA: + * http://www.iana.org/numbers.html + */ +#define SNMP_ENTERPRISE_ID 26381 +#define SNMP_SYSOBJID_LEN 7 +#define SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, SNMP_ENTERPRISE_ID} + +#ifndef SNMP_SYSSERVICES +#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) +#endif + +#ifndef SNMP_GET_SYSUPTIME +#define SNMP_GET_SYSUPTIME(sysuptime) (sysuptime = (sys_now() / 10)) +#endif + +static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void system_get_value(struct obj_def *od, u16_t len, void *value); +static u8_t system_set_test(struct obj_def *od, u16_t len, void *value); +static void system_set_value(struct obj_def *od, u16_t len, void *value); +static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void interfaces_get_value(struct obj_def *od, u16_t len, void *value); +static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void ifentry_get_value(struct obj_def *od, u16_t len, void *value); +#if !SNMP_SAFE_REQUESTS +static u8_t ifentry_set_test (struct obj_def *od, u16_t len, void *value); +static void ifentry_set_value (struct obj_def *od, u16_t len, void *value); +#endif /* SNMP_SAFE_REQUESTS */ +static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void atentry_get_value(struct obj_def *od, u16_t len, void *value); +static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void ip_get_value(struct obj_def *od, u16_t len, void *value); +static u8_t ip_set_test(struct obj_def *od, u16_t len, void *value); +static void ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value); +static void ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value); +static void ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value); +static void icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void icmp_get_value(struct obj_def *od, u16_t len, void *value); +#if LWIP_TCP +static void tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void tcp_get_value(struct obj_def *od, u16_t len, void *value); +#ifdef THIS_SEEMS_UNUSED +static void tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value); +#endif +#endif +static void udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void udp_get_value(struct obj_def *od, u16_t len, void *value); +static void udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void udpentry_get_value(struct obj_def *od, u16_t len, void *value); +static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +static void snmp_get_value(struct obj_def *od, u16_t len, void *value); +static u8_t snmp_set_test(struct obj_def *od, u16_t len, void *value); +static void snmp_set_value(struct obj_def *od, u16_t len, void *value); + + +/* snmp .1.3.6.1.2.1.11 */ +const mib_scalar_node snmp_scalar = { + &snmp_get_object_def, + &snmp_get_value, + &snmp_set_test, + &snmp_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t snmp_ids[28] = { + 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30 +}; +struct mib_node* const snmp_nodes[28] = { + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, + (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar +}; +const struct mib_array_node snmp = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 28, + snmp_ids, + snmp_nodes +}; + +/* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */ +/* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */ +/* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */ + +/* udp .1.3.6.1.2.1.7 */ +/** index root node for udpTable */ +struct mib_list_rootnode udp_root = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t udpentry_ids[2] = { 1, 2 }; +struct mib_node* const udpentry_nodes[2] = { + (struct mib_node*)&udp_root, (struct mib_node*)&udp_root, +}; +const struct mib_array_node udpentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 2, + udpentry_ids, + udpentry_nodes +}; + +s32_t udptable_id = 1; +struct mib_node* udptable_node = (struct mib_node*)&udpentry; +struct mib_ram_array_node udptable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, + 0, + &udptable_id, + &udptable_node +}; + +const mib_scalar_node udp_scalar = { + &udp_get_object_def, + &udp_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 }; +struct mib_node* const udp_nodes[5] = { + (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar, + (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar, + (struct mib_node*)&udptable +}; +const struct mib_array_node udp = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 5, + udp_ids, + udp_nodes +}; + +/* tcp .1.3.6.1.2.1.6 */ +#if LWIP_TCP +/* only if the TCP protocol is available may implement this group */ +/** index root node for tcpConnTable */ +struct mib_list_rootnode tcpconntree_root = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 }; +struct mib_node* const tcpconnentry_nodes[5] = { + (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root, + (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root, + (struct mib_node*)&tcpconntree_root +}; +const struct mib_array_node tcpconnentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 5, + tcpconnentry_ids, + tcpconnentry_nodes +}; + +s32_t tcpconntable_id = 1; +struct mib_node* tcpconntable_node = (struct mib_node*)&tcpconnentry; +struct mib_ram_array_node tcpconntable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, +/** @todo update maxlength when inserting / deleting from table + 0 when table is empty, 1 when more than one entry */ + 0, + &tcpconntable_id, + &tcpconntable_node +}; + +const mib_scalar_node tcp_scalar = { + &tcp_get_object_def, + &tcp_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; +struct mib_node* const tcp_nodes[15] = { + (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcpconntable, (struct mib_node*)&tcp_scalar, + (struct mib_node*)&tcp_scalar +}; +const struct mib_array_node tcp = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 15, + tcp_ids, + tcp_nodes +}; +#endif + +/* icmp .1.3.6.1.2.1.5 */ +const mib_scalar_node icmp_scalar = { + &icmp_get_object_def, + &icmp_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }; +struct mib_node* const icmp_nodes[26] = { + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, + (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar +}; +const struct mib_array_node icmp = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 26, + icmp_ids, + icmp_nodes +}; + +/** index root node for ipNetToMediaTable */ +struct mib_list_rootnode ipntomtree_root = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 }; +struct mib_node* const ipntomentry_nodes[4] = { + (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root, + (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root +}; +const struct mib_array_node ipntomentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 4, + ipntomentry_ids, + ipntomentry_nodes +}; + +s32_t ipntomtable_id = 1; +struct mib_node* ipntomtable_node = (struct mib_node*)&ipntomentry; +struct mib_ram_array_node ipntomtable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, + 0, + &ipntomtable_id, + &ipntomtable_node +}; + +/** index root node for ipRouteTable */ +struct mib_list_rootnode iprtetree_root = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; +struct mib_node* const iprteentry_nodes[13] = { + (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, + (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, + (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, + (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, + (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, + (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, + (struct mib_node*)&iprtetree_root +}; +const struct mib_array_node iprteentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 13, + iprteentry_ids, + iprteentry_nodes +}; + +s32_t iprtetable_id = 1; +struct mib_node* iprtetable_node = (struct mib_node*)&iprteentry; +struct mib_ram_array_node iprtetable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, + 0, + &iprtetable_id, + &iprtetable_node +}; + +/** index root node for ipAddrTable */ +struct mib_list_rootnode ipaddrtree_root = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 }; +struct mib_node* const ipaddrentry_nodes[5] = { + (struct mib_node*)&ipaddrtree_root, + (struct mib_node*)&ipaddrtree_root, + (struct mib_node*)&ipaddrtree_root, + (struct mib_node*)&ipaddrtree_root, + (struct mib_node*)&ipaddrtree_root +}; +const struct mib_array_node ipaddrentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 5, + ipaddrentry_ids, + ipaddrentry_nodes +}; + +s32_t ipaddrtable_id = 1; +struct mib_node* ipaddrtable_node = (struct mib_node*)&ipaddrentry; +struct mib_ram_array_node ipaddrtable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, + 0, + &ipaddrtable_id, + &ipaddrtable_node +}; + +/* ip .1.3.6.1.2.1.4 */ +const mib_scalar_node ip_scalar = { + &ip_get_object_def, + &ip_get_value, + &ip_set_test, + &noleafs_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; +struct mib_node* const ip_nodes[23] = { + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, + (struct mib_node*)&ip_scalar, (struct mib_node*)&ipaddrtable, + (struct mib_node*)&iprtetable, (struct mib_node*)&ipntomtable, + (struct mib_node*)&ip_scalar +}; +const struct mib_array_node mib2_ip = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 23, + ip_ids, + ip_nodes +}; + +/** index root node for atTable */ +struct mib_list_rootnode arptree_root = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t atentry_ids[3] = { 1, 2, 3 }; +struct mib_node* const atentry_nodes[3] = { + (struct mib_node*)&arptree_root, + (struct mib_node*)&arptree_root, + (struct mib_node*)&arptree_root +}; +const struct mib_array_node atentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 3, + atentry_ids, + atentry_nodes +}; + +const s32_t attable_id = 1; +struct mib_node* const attable_node = (struct mib_node*)&atentry; +const struct mib_array_node attable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 1, + &attable_id, + &attable_node +}; + +/* at .1.3.6.1.2.1.3 */ +s32_t at_id = 1; +struct mib_node* mib2_at_node = (struct mib_node*)&attable; +struct mib_ram_array_node at = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, + 0, + &at_id, + &mib2_at_node +}; + +/** index root node for ifTable */ +struct mib_list_rootnode iflist_root = { + &ifentry_get_object_def, + &ifentry_get_value, +#if SNMP_SAFE_REQUESTS + &noleafs_set_test, + &noleafs_set_value, +#else /* SNMP_SAFE_REQUESTS */ + &ifentry_set_test, + &ifentry_set_value, +#endif /* SNMP_SAFE_REQUESTS */ + MIB_NODE_LR, + 0, + NULL, + NULL, + 0 +}; +const s32_t ifentry_ids[22] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 }; +struct mib_node* const ifentry_nodes[22] = { + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, + (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root +}; +const struct mib_array_node ifentry = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 22, + ifentry_ids, + ifentry_nodes +}; + +s32_t iftable_id = 1; +struct mib_node* iftable_node = (struct mib_node*)&ifentry; +struct mib_ram_array_node iftable = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_RA, + 0, + &iftable_id, + &iftable_node +}; + +/* interfaces .1.3.6.1.2.1.2 */ +const mib_scalar_node interfaces_scalar = { + &interfaces_get_object_def, + &interfaces_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t interfaces_ids[2] = { 1, 2 }; +struct mib_node* const interfaces_nodes[2] = { + (struct mib_node*)&interfaces_scalar, (struct mib_node*)&iftable +}; +const struct mib_array_node interfaces = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 2, + interfaces_ids, + interfaces_nodes +}; + + +/* 0 1 2 3 4 5 6 */ +/* system .1.3.6.1.2.1.1 */ +const mib_scalar_node sys_tem_scalar = { + &system_get_object_def, + &system_get_value, + &system_set_test, + &system_set_value, + MIB_NODE_SC, + 0 +}; +const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 }; +struct mib_node* const sys_tem_nodes[7] = { + (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar, + (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar, + (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar, + (struct mib_node*)&sys_tem_scalar +}; +/* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */ +const struct mib_array_node sys_tem = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 7, + sys_tem_ids, + sys_tem_nodes +}; + +/* mib-2 .1.3.6.1.2.1 */ +#if LWIP_TCP +#define MIB2_GROUPS 8 +#else +#define MIB2_GROUPS 7 +#endif +const s32_t mib2_ids[MIB2_GROUPS] = +{ + 1, + 2, + 3, + 4, + 5, +#if LWIP_TCP + 6, +#endif + 7, + 11 +}; +struct mib_node* const mib2_nodes[MIB2_GROUPS] = { + (struct mib_node*)&sys_tem, + (struct mib_node*)&interfaces, + (struct mib_node*)&at, + (struct mib_node*)&mib2_ip, + (struct mib_node*)&icmp, +#if LWIP_TCP + (struct mib_node*)&tcp, +#endif + (struct mib_node*)&udp, + (struct mib_node*)&snmp +}; + +const struct mib_array_node mib2 = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + MIB2_GROUPS, + mib2_ids, + mib2_nodes +}; + +/* mgmt .1.3.6.1.2 */ +const s32_t mgmt_ids[1] = { 1 }; +struct mib_node* const mgmt_nodes[1] = { (struct mib_node*)&mib2 }; +const struct mib_array_node mgmt = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 1, + mgmt_ids, + mgmt_nodes +}; + +/* internet .1.3.6.1 */ +#if SNMP_PRIVATE_MIB +/* When using a private MIB, you have to create a file 'private_mib.h' that contains + * a 'struct mib_array_node mib_private' which contains your MIB. */ +s32_t internet_ids[2] = { 2, 4 }; +struct mib_node* const internet_nodes[2] = { (struct mib_node*)&mgmt, (struct mib_node*)&mib_private }; +const struct mib_array_node internet = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 2, + internet_ids, + internet_nodes +}; +#else +const s32_t internet_ids[1] = { 2 }; +struct mib_node* const internet_nodes[1] = { (struct mib_node*)&mgmt }; +const struct mib_array_node internet = { + &noleafs_get_object_def, + &noleafs_get_value, + &noleafs_set_test, + &noleafs_set_value, + MIB_NODE_AR, + 1, + internet_ids, + internet_nodes +}; +#endif + +/** mib-2.system.sysObjectID */ +static struct snmp_obj_id sysobjid = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID}; +/** enterprise ID for generic TRAPs, .iso.org.dod.internet.mgmt.mib-2.snmp */ +static struct snmp_obj_id snmpgrp_id = {7,{1,3,6,1,2,1,11}}; +/** mib-2.system.sysServices */ +static const s32_t sysservices = SNMP_SYSSERVICES; + +/** mib-2.system.sysDescr */ +static const u8_t sysdescr_len_default = 4; +static const u8_t sysdescr_default[] = "lwIP"; +static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default; +static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0]; +/** mib-2.system.sysContact */ +static const u8_t syscontact_len_default = 0; +static const u8_t syscontact_default[] = ""; +static u8_t* syscontact_len_ptr = (u8_t*)&syscontact_len_default; +static u8_t* syscontact_ptr = (u8_t*)&syscontact_default[0]; +/** mib-2.system.sysName */ +static const u8_t sysname_len_default = 8; +static const u8_t sysname_default[] = "FQDN-unk"; +static u8_t* sysname_len_ptr = (u8_t*)&sysname_len_default; +static u8_t* sysname_ptr = (u8_t*)&sysname_default[0]; +/** mib-2.system.sysLocation */ +static const u8_t syslocation_len_default = 0; +static const u8_t syslocation_default[] = ""; +static u8_t* syslocation_len_ptr = (u8_t*)&syslocation_len_default; +static u8_t* syslocation_ptr = (u8_t*)&syslocation_default[0]; +/** mib-2.snmp.snmpEnableAuthenTraps */ +static const u8_t snmpenableauthentraps_default = 2; /* disabled */ +static u8_t* snmpenableauthentraps_ptr = (u8_t*)&snmpenableauthentraps_default; + +/** mib-2.interfaces.ifTable.ifEntry.ifSpecific (zeroDotZero) */ +static const struct snmp_obj_id ifspecific = {2, {0, 0}}; +/** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */ +static const struct snmp_obj_id iprouteinfo = {2, {0, 0}}; + + + +/* mib-2.system counter(s) */ +static u32_t sysuptime = 0; + +/* mib-2.ip counter(s) */ +static u32_t ipinreceives = 0, + ipinhdrerrors = 0, + ipinaddrerrors = 0, + ipforwdatagrams = 0, + ipinunknownprotos = 0, + ipindiscards = 0, + ipindelivers = 0, + ipoutrequests = 0, + ipoutdiscards = 0, + ipoutnoroutes = 0, + ipreasmreqds = 0, + ipreasmoks = 0, + ipreasmfails = 0, + ipfragoks = 0, + ipfragfails = 0, + ipfragcreates = 0, + iproutingdiscards = 0; +/* mib-2.icmp counter(s) */ +static u32_t icmpinmsgs = 0, + icmpinerrors = 0, + icmpindestunreachs = 0, + icmpintimeexcds = 0, + icmpinparmprobs = 0, + icmpinsrcquenchs = 0, + icmpinredirects = 0, + icmpinechos = 0, + icmpinechoreps = 0, + icmpintimestamps = 0, + icmpintimestampreps = 0, + icmpinaddrmasks = 0, + icmpinaddrmaskreps = 0, + icmpoutmsgs = 0, + icmpouterrors = 0, + icmpoutdestunreachs = 0, + icmpouttimeexcds = 0, + icmpoutparmprobs = 0, + icmpoutsrcquenchs = 0, + icmpoutredirects = 0, + icmpoutechos = 0, + icmpoutechoreps = 0, + icmpouttimestamps = 0, + icmpouttimestampreps = 0, + icmpoutaddrmasks = 0, + icmpoutaddrmaskreps = 0; +/* mib-2.tcp counter(s) */ +static u32_t tcpactiveopens = 0, + tcppassiveopens = 0, + tcpattemptfails = 0, + tcpestabresets = 0, + tcpinsegs = 0, + tcpoutsegs = 0, + tcpretranssegs = 0, + tcpinerrs = 0, + tcpoutrsts = 0; +/* mib-2.udp counter(s) */ +static u32_t udpindatagrams = 0, + udpnoports = 0, + udpinerrors = 0, + udpoutdatagrams = 0; +/* mib-2.snmp counter(s) */ +static u32_t snmpinpkts = 0, + snmpoutpkts = 0, + snmpinbadversions = 0, + snmpinbadcommunitynames = 0, + snmpinbadcommunityuses = 0, + snmpinasnparseerrs = 0, + snmpintoobigs = 0, + snmpinnosuchnames = 0, + snmpinbadvalues = 0, + snmpinreadonlys = 0, + snmpingenerrs = 0, + snmpintotalreqvars = 0, + snmpintotalsetvars = 0, + snmpingetrequests = 0, + snmpingetnexts = 0, + snmpinsetrequests = 0, + snmpingetresponses = 0, + snmpintraps = 0, + snmpouttoobigs = 0, + snmpoutnosuchnames = 0, + snmpoutbadvalues = 0, + snmpoutgenerrs = 0, + snmpoutgetrequests = 0, + snmpoutgetnexts = 0, + snmpoutsetrequests = 0, + snmpoutgetresponses = 0, + snmpouttraps = 0; + + + +/* prototypes of the following functions are in lwip/src/include/lwip/snmp.h */ +/** + * Copy octet string. + * + * @param dst points to destination + * @param src points to source + * @param n number of octets to copy. + */ +static void ocstrncpy(u8_t *dst, u8_t *src, u16_t n) +{ + u16_t i = n; + while (i > 0) { + i--; + *dst++ = *src++; + } +} + +/** + * Copy object identifier (s32_t) array. + * + * @param dst points to destination + * @param src points to source + * @param n number of sub identifiers to copy. + */ +void objectidncpy(s32_t *dst, s32_t *src, u8_t n) +{ + u8_t i = n; + while(i > 0) { + i--; + *dst++ = *src++; + } +} + +/** + * Initializes sysDescr pointers. + * + * @param str if non-NULL then copy str pointer + * @param len points to string length, excluding zero terminator + */ +void snmp_set_sysdesr(u8_t *str, u8_t *len) +{ + if (str != NULL) + { + sysdescr_ptr = str; + sysdescr_len_ptr = len; + } +} + +void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid) +{ + *oid = &sysobjid; +} + +/** + * Initializes sysObjectID value. + * + * @param oid points to stuct snmp_obj_id to copy + */ +void snmp_set_sysobjid(struct snmp_obj_id *oid) +{ + sysobjid = *oid; +} + +/** + * Must be called at regular 10 msec interval from a timer interrupt + * or signal handler depending on your runtime environment. + */ +void snmp_inc_sysuptime(void) +{ + sysuptime++; +} + +void snmp_add_sysuptime(u32_t value) +{ + sysuptime+=value; +} + +void snmp_get_sysuptime(u32_t *value) +{ + SNMP_GET_SYSUPTIME(sysuptime); + *value = sysuptime; +} + +/** + * Initializes sysContact pointers, + * e.g. ptrs to non-volatile memory external to lwIP. + * + * @param ocstr if non-NULL then copy str pointer + * @param ocstrlen points to string length, excluding zero terminator + */ +void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen) +{ + if (ocstr != NULL) + { + syscontact_ptr = ocstr; + syscontact_len_ptr = ocstrlen; + } +} + +/** + * Initializes sysName pointers, + * e.g. ptrs to non-volatile memory external to lwIP. + * + * @param ocstr if non-NULL then copy str pointer + * @param ocstrlen points to string length, excluding zero terminator + */ +void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen) +{ + if (ocstr != NULL) + { + sysname_ptr = ocstr; + sysname_len_ptr = ocstrlen; + } +} + +/** + * Initializes sysLocation pointers, + * e.g. ptrs to non-volatile memory external to lwIP. + * + * @param ocstr if non-NULL then copy str pointer + * @param ocstrlen points to string length, excluding zero terminator + */ +void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen) +{ + if (ocstr != NULL) + { + syslocation_ptr = ocstr; + syslocation_len_ptr = ocstrlen; + } +} + + +void snmp_add_ifinoctets(struct netif *ni, u32_t value) +{ + ni->ifinoctets += value; +} + +void snmp_inc_ifinucastpkts(struct netif *ni) +{ + (ni->ifinucastpkts)++; +} + +void snmp_inc_ifinnucastpkts(struct netif *ni) +{ + (ni->ifinnucastpkts)++; +} + +void snmp_inc_ifindiscards(struct netif *ni) +{ + (ni->ifindiscards)++; +} + +void snmp_add_ifoutoctets(struct netif *ni, u32_t value) +{ + ni->ifoutoctets += value; +} + +void snmp_inc_ifoutucastpkts(struct netif *ni) +{ + (ni->ifoutucastpkts)++; +} + +void snmp_inc_ifoutnucastpkts(struct netif *ni) +{ + (ni->ifoutnucastpkts)++; +} + +void snmp_inc_ifoutdiscards(struct netif *ni) +{ + (ni->ifoutdiscards)++; +} + +void snmp_inc_iflist(void) +{ + struct mib_list_node *if_node = NULL; + + snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node); + /* enable getnext traversal on filled table */ + iftable.maxlength = 1; +} + +void snmp_dec_iflist(void) +{ + snmp_mib_node_delete(&iflist_root, iflist_root.tail); + /* disable getnext traversal on empty table */ + if(iflist_root.count == 0) iftable.maxlength = 0; +} + +/** + * Inserts ARP table indexes (.xIfIndex.xNetAddress) + * into arp table index trees (both atTable and ipNetToMediaTable). + */ +void snmp_insert_arpidx_tree(struct netif *ni, ip_addr_t *ip) +{ + struct mib_list_rootnode *at_rn; + struct mib_list_node *at_node; + s32_t arpidx[5]; + u8_t level, tree; + + LWIP_ASSERT("ni != NULL", ni != NULL); + snmp_netiftoifindex(ni, &arpidx[0]); + snmp_iptooid(ip, &arpidx[1]); + + for (tree = 0; tree < 2; tree++) + { + if (tree == 0) + { + at_rn = &arptree_root; + } + else + { + at_rn = &ipntomtree_root; + } + for (level = 0; level < 5; level++) + { + at_node = NULL; + snmp_mib_node_insert(at_rn, arpidx[level], &at_node); + if ((level != 4) && (at_node != NULL)) + { + if (at_node->nptr == NULL) + { + at_rn = snmp_mib_lrn_alloc(); + at_node->nptr = (struct mib_node*)at_rn; + if (at_rn != NULL) + { + if (level == 3) + { + if (tree == 0) + { + at_rn->get_object_def = atentry_get_object_def; + at_rn->get_value = atentry_get_value; + } + else + { + at_rn->get_object_def = ip_ntomentry_get_object_def; + at_rn->get_value = ip_ntomentry_get_value; + } + at_rn->set_test = noleafs_set_test; + at_rn->set_value = noleafs_set_value; + } + } + else + { + /* at_rn == NULL, malloc failure */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_arpidx_tree() insert failed, mem full")); + break; + } + } + else + { + at_rn = (struct mib_list_rootnode*)at_node->nptr; + } + } + } + } + /* enable getnext traversal on filled tables */ + at.maxlength = 1; + ipntomtable.maxlength = 1; +} + +/** + * Removes ARP table indexes (.xIfIndex.xNetAddress) + * from arp table index trees. + */ +void snmp_delete_arpidx_tree(struct netif *ni, ip_addr_t *ip) +{ + struct mib_list_rootnode *at_rn, *next, *del_rn[5]; + struct mib_list_node *at_n, *del_n[5]; + s32_t arpidx[5]; + u8_t fc, tree, level, del_cnt; + + snmp_netiftoifindex(ni, &arpidx[0]); + snmp_iptooid(ip, &arpidx[1]); + + for (tree = 0; tree < 2; tree++) + { + /* mark nodes for deletion */ + if (tree == 0) + { + at_rn = &arptree_root; + } + else + { + at_rn = &ipntomtree_root; + } + level = 0; + del_cnt = 0; + while ((level < 5) && (at_rn != NULL)) + { + fc = snmp_mib_node_find(at_rn, arpidx[level], &at_n); + if (fc == 0) + { + /* arpidx[level] does not exist */ + del_cnt = 0; + at_rn = NULL; + } + else if (fc == 1) + { + del_rn[del_cnt] = at_rn; + del_n[del_cnt] = at_n; + del_cnt++; + at_rn = (struct mib_list_rootnode*)(at_n->nptr); + } + else if (fc == 2) + { + /* reset delete (2 or more childs) */ + del_cnt = 0; + at_rn = (struct mib_list_rootnode*)(at_n->nptr); + } + level++; + } + /* delete marked index nodes */ + while (del_cnt > 0) + { + del_cnt--; + + at_rn = del_rn[del_cnt]; + at_n = del_n[del_cnt]; + + next = snmp_mib_node_delete(at_rn, at_n); + if (next != NULL) + { + LWIP_ASSERT("next_count == 0",next->count == 0); + snmp_mib_lrn_free(next); + } + } + } + /* disable getnext traversal on empty tables */ + if(arptree_root.count == 0) at.maxlength = 0; + if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0; +} + +void snmp_inc_ipinreceives(void) +{ + ipinreceives++; +} + +void snmp_inc_ipinhdrerrors(void) +{ + ipinhdrerrors++; +} + +void snmp_inc_ipinaddrerrors(void) +{ + ipinaddrerrors++; +} + +void snmp_inc_ipforwdatagrams(void) +{ + ipforwdatagrams++; +} + +void snmp_inc_ipinunknownprotos(void) +{ + ipinunknownprotos++; +} + +void snmp_inc_ipindiscards(void) +{ + ipindiscards++; +} + +void snmp_inc_ipindelivers(void) +{ + ipindelivers++; +} + +void snmp_inc_ipoutrequests(void) +{ + ipoutrequests++; +} + +void snmp_inc_ipoutdiscards(void) +{ + ipoutdiscards++; +} + +void snmp_inc_ipoutnoroutes(void) +{ + ipoutnoroutes++; +} + +void snmp_inc_ipreasmreqds(void) +{ + ipreasmreqds++; +} + +void snmp_inc_ipreasmoks(void) +{ + ipreasmoks++; +} + +void snmp_inc_ipreasmfails(void) +{ + ipreasmfails++; +} + +void snmp_inc_ipfragoks(void) +{ + ipfragoks++; +} + +void snmp_inc_ipfragfails(void) +{ + ipfragfails++; +} + +void snmp_inc_ipfragcreates(void) +{ + ipfragcreates++; +} + +void snmp_inc_iproutingdiscards(void) +{ + iproutingdiscards++; +} + +/** + * Inserts ipAddrTable indexes (.ipAdEntAddr) + * into index tree. + */ +void snmp_insert_ipaddridx_tree(struct netif *ni) +{ + struct mib_list_rootnode *ipa_rn; + struct mib_list_node *ipa_node; + s32_t ipaddridx[4]; + u8_t level; + + LWIP_ASSERT("ni != NULL", ni != NULL); + snmp_iptooid(&ni->ip_addr, &ipaddridx[0]); + + level = 0; + ipa_rn = &ipaddrtree_root; + while (level < 4) + { + ipa_node = NULL; + snmp_mib_node_insert(ipa_rn, ipaddridx[level], &ipa_node); + if ((level != 3) && (ipa_node != NULL)) + { + if (ipa_node->nptr == NULL) + { + ipa_rn = snmp_mib_lrn_alloc(); + ipa_node->nptr = (struct mib_node*)ipa_rn; + if (ipa_rn != NULL) + { + if (level == 2) + { + ipa_rn->get_object_def = ip_addrentry_get_object_def; + ipa_rn->get_value = ip_addrentry_get_value; + ipa_rn->set_test = noleafs_set_test; + ipa_rn->set_value = noleafs_set_value; + } + } + else + { + /* ipa_rn == NULL, malloc failure */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_ipaddridx_tree() insert failed, mem full")); + break; + } + } + else + { + ipa_rn = (struct mib_list_rootnode*)ipa_node->nptr; + } + } + level++; + } + /* enable getnext traversal on filled table */ + ipaddrtable.maxlength = 1; +} + +/** + * Removes ipAddrTable indexes (.ipAdEntAddr) + * from index tree. + */ +void snmp_delete_ipaddridx_tree(struct netif *ni) +{ + struct mib_list_rootnode *ipa_rn, *next, *del_rn[4]; + struct mib_list_node *ipa_n, *del_n[4]; + s32_t ipaddridx[4]; + u8_t fc, level, del_cnt; + + LWIP_ASSERT("ni != NULL", ni != NULL); + snmp_iptooid(&ni->ip_addr, &ipaddridx[0]); + + /* mark nodes for deletion */ + level = 0; + del_cnt = 0; + ipa_rn = &ipaddrtree_root; + while ((level < 4) && (ipa_rn != NULL)) + { + fc = snmp_mib_node_find(ipa_rn, ipaddridx[level], &ipa_n); + if (fc == 0) + { + /* ipaddridx[level] does not exist */ + del_cnt = 0; + ipa_rn = NULL; + } + else if (fc == 1) + { + del_rn[del_cnt] = ipa_rn; + del_n[del_cnt] = ipa_n; + del_cnt++; + ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr); + } + else if (fc == 2) + { + /* reset delete (2 or more childs) */ + del_cnt = 0; + ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr); + } + level++; + } + /* delete marked index nodes */ + while (del_cnt > 0) + { + del_cnt--; + + ipa_rn = del_rn[del_cnt]; + ipa_n = del_n[del_cnt]; + + next = snmp_mib_node_delete(ipa_rn, ipa_n); + if (next != NULL) + { + LWIP_ASSERT("next_count == 0",next->count == 0); + snmp_mib_lrn_free(next); + } + } + /* disable getnext traversal on empty table */ + if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0; +} + +/** + * Inserts ipRouteTable indexes (.ipRouteDest) + * into index tree. + * + * @param dflt non-zero for the default rte, zero for network rte + * @param ni points to network interface for this rte + * + * @todo record sysuptime for _this_ route when it is installed + * (needed for ipRouteAge) in the netif. + */ +void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni) +{ + u8_t insert = 0; + ip_addr_t dst; + + if (dflt != 0) + { + /* the default route 0.0.0.0 */ + ip_addr_set_any(&dst); + insert = 1; + } + else + { + /* route to the network address */ + ip_addr_get_network(&dst, &ni->ip_addr, &ni->netmask); + /* exclude 0.0.0.0 network (reserved for default rte) */ + if (!ip_addr_isany(&dst)) { + insert = 1; + } + } + if (insert) + { + struct mib_list_rootnode *iprte_rn; + struct mib_list_node *iprte_node; + s32_t iprteidx[4]; + u8_t level; + + snmp_iptooid(&dst, &iprteidx[0]); + level = 0; + iprte_rn = &iprtetree_root; + while (level < 4) + { + iprte_node = NULL; + snmp_mib_node_insert(iprte_rn, iprteidx[level], &iprte_node); + if ((level != 3) && (iprte_node != NULL)) + { + if (iprte_node->nptr == NULL) + { + iprte_rn = snmp_mib_lrn_alloc(); + iprte_node->nptr = (struct mib_node*)iprte_rn; + if (iprte_rn != NULL) + { + if (level == 2) + { + iprte_rn->get_object_def = ip_rteentry_get_object_def; + iprte_rn->get_value = ip_rteentry_get_value; + iprte_rn->set_test = noleafs_set_test; + iprte_rn->set_value = noleafs_set_value; + } + } + else + { + /* iprte_rn == NULL, malloc failure */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_iprteidx_tree() insert failed, mem full")); + break; + } + } + else + { + iprte_rn = (struct mib_list_rootnode*)iprte_node->nptr; + } + } + level++; + } + } + /* enable getnext traversal on filled table */ + iprtetable.maxlength = 1; +} + +/** + * Removes ipRouteTable indexes (.ipRouteDest) + * from index tree. + * + * @param dflt non-zero for the default rte, zero for network rte + * @param ni points to network interface for this rte or NULL + * for default route to be removed. + */ +void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni) +{ + u8_t del = 0; + ip_addr_t dst; + + if (dflt != 0) + { + /* the default route 0.0.0.0 */ + ip_addr_set_any(&dst); + del = 1; + } + else + { + /* route to the network address */ + ip_addr_get_network(&dst, &ni->ip_addr, &ni->netmask); + /* exclude 0.0.0.0 network (reserved for default rte) */ + if (!ip_addr_isany(&dst)) { + del = 1; + } + } + if (del) + { + struct mib_list_rootnode *iprte_rn, *next, *del_rn[4]; + struct mib_list_node *iprte_n, *del_n[4]; + s32_t iprteidx[4]; + u8_t fc, level, del_cnt; + + snmp_iptooid(&dst, &iprteidx[0]); + /* mark nodes for deletion */ + level = 0; + del_cnt = 0; + iprte_rn = &iprtetree_root; + while ((level < 4) && (iprte_rn != NULL)) + { + fc = snmp_mib_node_find(iprte_rn, iprteidx[level], &iprte_n); + if (fc == 0) + { + /* iprteidx[level] does not exist */ + del_cnt = 0; + iprte_rn = NULL; + } + else if (fc == 1) + { + del_rn[del_cnt] = iprte_rn; + del_n[del_cnt] = iprte_n; + del_cnt++; + iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr); + } + else if (fc == 2) + { + /* reset delete (2 or more childs) */ + del_cnt = 0; + iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr); + } + level++; + } + /* delete marked index nodes */ + while (del_cnt > 0) + { + del_cnt--; + + iprte_rn = del_rn[del_cnt]; + iprte_n = del_n[del_cnt]; + + next = snmp_mib_node_delete(iprte_rn, iprte_n); + if (next != NULL) + { + LWIP_ASSERT("next_count == 0",next->count == 0); + snmp_mib_lrn_free(next); + } + } + } + /* disable getnext traversal on empty table */ + if (iprtetree_root.count == 0) iprtetable.maxlength = 0; +} + + +void snmp_inc_icmpinmsgs(void) +{ + icmpinmsgs++; +} + +void snmp_inc_icmpinerrors(void) +{ + icmpinerrors++; +} + +void snmp_inc_icmpindestunreachs(void) +{ + icmpindestunreachs++; +} + +void snmp_inc_icmpintimeexcds(void) +{ + icmpintimeexcds++; +} + +void snmp_inc_icmpinparmprobs(void) +{ + icmpinparmprobs++; +} + +void snmp_inc_icmpinsrcquenchs(void) +{ + icmpinsrcquenchs++; +} + +void snmp_inc_icmpinredirects(void) +{ + icmpinredirects++; +} + +void snmp_inc_icmpinechos(void) +{ + icmpinechos++; +} + +void snmp_inc_icmpinechoreps(void) +{ + icmpinechoreps++; +} + +void snmp_inc_icmpintimestamps(void) +{ + icmpintimestamps++; +} + +void snmp_inc_icmpintimestampreps(void) +{ + icmpintimestampreps++; +} + +void snmp_inc_icmpinaddrmasks(void) +{ + icmpinaddrmasks++; +} + +void snmp_inc_icmpinaddrmaskreps(void) +{ + icmpinaddrmaskreps++; +} + +void snmp_inc_icmpoutmsgs(void) +{ + icmpoutmsgs++; +} + +void snmp_inc_icmpouterrors(void) +{ + icmpouterrors++; +} + +void snmp_inc_icmpoutdestunreachs(void) +{ + icmpoutdestunreachs++; +} + +void snmp_inc_icmpouttimeexcds(void) +{ + icmpouttimeexcds++; +} + +void snmp_inc_icmpoutparmprobs(void) +{ + icmpoutparmprobs++; +} + +void snmp_inc_icmpoutsrcquenchs(void) +{ + icmpoutsrcquenchs++; +} + +void snmp_inc_icmpoutredirects(void) +{ + icmpoutredirects++; +} + +void snmp_inc_icmpoutechos(void) +{ + icmpoutechos++; +} + +void snmp_inc_icmpoutechoreps(void) +{ + icmpoutechoreps++; +} + +void snmp_inc_icmpouttimestamps(void) +{ + icmpouttimestamps++; +} + +void snmp_inc_icmpouttimestampreps(void) +{ + icmpouttimestampreps++; +} + +void snmp_inc_icmpoutaddrmasks(void) +{ + icmpoutaddrmasks++; +} + +void snmp_inc_icmpoutaddrmaskreps(void) +{ + icmpoutaddrmaskreps++; +} + +void snmp_inc_tcpactiveopens(void) +{ + tcpactiveopens++; +} + +void snmp_inc_tcppassiveopens(void) +{ + tcppassiveopens++; +} + +void snmp_inc_tcpattemptfails(void) +{ + tcpattemptfails++; +} + +void snmp_inc_tcpestabresets(void) +{ + tcpestabresets++; +} + +void snmp_inc_tcpinsegs(void) +{ + tcpinsegs++; +} + +void snmp_inc_tcpoutsegs(void) +{ + tcpoutsegs++; +} + +void snmp_inc_tcpretranssegs(void) +{ + tcpretranssegs++; +} + +void snmp_inc_tcpinerrs(void) +{ + tcpinerrs++; +} + +void snmp_inc_tcpoutrsts(void) +{ + tcpoutrsts++; +} + +void snmp_inc_udpindatagrams(void) +{ + udpindatagrams++; +} + +void snmp_inc_udpnoports(void) +{ + udpnoports++; +} + +void snmp_inc_udpinerrors(void) +{ + udpinerrors++; +} + +void snmp_inc_udpoutdatagrams(void) +{ + udpoutdatagrams++; +} + +/** + * Inserts udpTable indexes (.udpLocalAddress.udpLocalPort) + * into index tree. + */ +void snmp_insert_udpidx_tree(struct udp_pcb *pcb) +{ + struct mib_list_rootnode *udp_rn; + struct mib_list_node *udp_node; + s32_t udpidx[5]; + u8_t level; + + LWIP_ASSERT("pcb != NULL", pcb != NULL); + snmp_iptooid(&pcb->local_ip, &udpidx[0]); + udpidx[4] = pcb->local_port; + + udp_rn = &udp_root; + for (level = 0; level < 5; level++) + { + udp_node = NULL; + snmp_mib_node_insert(udp_rn, udpidx[level], &udp_node); + if ((level != 4) && (udp_node != NULL)) + { + if (udp_node->nptr == NULL) + { + udp_rn = snmp_mib_lrn_alloc(); + udp_node->nptr = (struct mib_node*)udp_rn; + if (udp_rn != NULL) + { + if (level == 3) + { + udp_rn->get_object_def = udpentry_get_object_def; + udp_rn->get_value = udpentry_get_value; + udp_rn->set_test = noleafs_set_test; + udp_rn->set_value = noleafs_set_value; + } + } + else + { + /* udp_rn == NULL, malloc failure */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_udpidx_tree() insert failed, mem full")); + break; + } + } + else + { + udp_rn = (struct mib_list_rootnode*)udp_node->nptr; + } + } + } + udptable.maxlength = 1; +} + +/** + * Removes udpTable indexes (.udpLocalAddress.udpLocalPort) + * from index tree. + */ +void snmp_delete_udpidx_tree(struct udp_pcb *pcb) +{ + struct udp_pcb *npcb; + struct mib_list_rootnode *udp_rn, *next, *del_rn[5]; + struct mib_list_node *udp_n, *del_n[5]; + s32_t udpidx[5]; + u8_t bindings, fc, level, del_cnt; + + LWIP_ASSERT("pcb != NULL", pcb != NULL); + snmp_iptooid(&pcb->local_ip, &udpidx[0]); + udpidx[4] = pcb->local_port; + + /* count PCBs for a given binding + (e.g. when reusing ports or for temp output PCBs) */ + bindings = 0; + npcb = udp_pcbs; + while ((npcb != NULL)) + { + if (ip_addr_cmp(&npcb->local_ip, &pcb->local_ip) && + (npcb->local_port == udpidx[4])) + { + bindings++; + } + npcb = npcb->next; + } + if (bindings == 1) + { + /* selectively remove */ + /* mark nodes for deletion */ + level = 0; + del_cnt = 0; + udp_rn = &udp_root; + while ((level < 5) && (udp_rn != NULL)) + { + fc = snmp_mib_node_find(udp_rn, udpidx[level], &udp_n); + if (fc == 0) + { + /* udpidx[level] does not exist */ + del_cnt = 0; + udp_rn = NULL; + } + else if (fc == 1) + { + del_rn[del_cnt] = udp_rn; + del_n[del_cnt] = udp_n; + del_cnt++; + udp_rn = (struct mib_list_rootnode*)(udp_n->nptr); + } + else if (fc == 2) + { + /* reset delete (2 or more childs) */ + del_cnt = 0; + udp_rn = (struct mib_list_rootnode*)(udp_n->nptr); + } + level++; + } + /* delete marked index nodes */ + while (del_cnt > 0) + { + del_cnt--; + + udp_rn = del_rn[del_cnt]; + udp_n = del_n[del_cnt]; + + next = snmp_mib_node_delete(udp_rn, udp_n); + if (next != NULL) + { + LWIP_ASSERT("next_count == 0",next->count == 0); + snmp_mib_lrn_free(next); + } + } + } + /* disable getnext traversal on empty table */ + if (udp_root.count == 0) udptable.maxlength = 0; +} + + +void snmp_inc_snmpinpkts(void) +{ + snmpinpkts++; +} + +void snmp_inc_snmpoutpkts(void) +{ + snmpoutpkts++; +} + +void snmp_inc_snmpinbadversions(void) +{ + snmpinbadversions++; +} + +void snmp_inc_snmpinbadcommunitynames(void) +{ + snmpinbadcommunitynames++; +} + +void snmp_inc_snmpinbadcommunityuses(void) +{ + snmpinbadcommunityuses++; +} + +void snmp_inc_snmpinasnparseerrs(void) +{ + snmpinasnparseerrs++; +} + +void snmp_inc_snmpintoobigs(void) +{ + snmpintoobigs++; +} + +void snmp_inc_snmpinnosuchnames(void) +{ + snmpinnosuchnames++; +} + +void snmp_inc_snmpinbadvalues(void) +{ + snmpinbadvalues++; +} + +void snmp_inc_snmpinreadonlys(void) +{ + snmpinreadonlys++; +} + +void snmp_inc_snmpingenerrs(void) +{ + snmpingenerrs++; +} + +void snmp_add_snmpintotalreqvars(u8_t value) +{ + snmpintotalreqvars += value; +} + +void snmp_add_snmpintotalsetvars(u8_t value) +{ + snmpintotalsetvars += value; +} + +void snmp_inc_snmpingetrequests(void) +{ + snmpingetrequests++; +} + +void snmp_inc_snmpingetnexts(void) +{ + snmpingetnexts++; +} + +void snmp_inc_snmpinsetrequests(void) +{ + snmpinsetrequests++; +} + +void snmp_inc_snmpingetresponses(void) +{ + snmpingetresponses++; +} + +void snmp_inc_snmpintraps(void) +{ + snmpintraps++; +} + +void snmp_inc_snmpouttoobigs(void) +{ + snmpouttoobigs++; +} + +void snmp_inc_snmpoutnosuchnames(void) +{ + snmpoutnosuchnames++; +} + +void snmp_inc_snmpoutbadvalues(void) +{ + snmpoutbadvalues++; +} + +void snmp_inc_snmpoutgenerrs(void) +{ + snmpoutgenerrs++; +} + +void snmp_inc_snmpoutgetrequests(void) +{ + snmpoutgetrequests++; +} + +void snmp_inc_snmpoutgetnexts(void) +{ + snmpoutgetnexts++; +} + +void snmp_inc_snmpoutsetrequests(void) +{ + snmpoutsetrequests++; +} + +void snmp_inc_snmpoutgetresponses(void) +{ + snmpoutgetresponses++; +} + +void snmp_inc_snmpouttraps(void) +{ + snmpouttraps++; +} + +void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid) +{ + *oid = &snmpgrp_id; +} + +void snmp_set_snmpenableauthentraps(u8_t *value) +{ + if (value != NULL) + { + snmpenableauthentraps_ptr = value; + } +} + +void snmp_get_snmpenableauthentraps(u8_t *value) +{ + *value = *snmpenableauthentraps_ptr; +} + +void +noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + LWIP_UNUSED_ARG(ident_len); + LWIP_UNUSED_ARG(ident); + od->instance = MIB_OBJECT_NONE; +} + +void +noleafs_get_value(struct obj_def *od, u16_t len, void *value) +{ + LWIP_UNUSED_ARG(od); + LWIP_UNUSED_ARG(len); + LWIP_UNUSED_ARG(value); +} + +u8_t +noleafs_set_test(struct obj_def *od, u16_t len, void *value) +{ + LWIP_UNUSED_ARG(od); + LWIP_UNUSED_ARG(len); + LWIP_UNUSED_ARG(value); + /* can't set */ + return 0; +} + +void +noleafs_set_value(struct obj_def *od, u16_t len, void *value) +{ + LWIP_UNUSED_ARG(od); + LWIP_UNUSED_ARG(len); + LWIP_UNUSED_ARG(value); +} + + +/** + * Returns systems object definitions. + * + * @param ident_len the address length (2) + * @param ident points to objectname.0 (object id trailer) + * @param od points to object definition. + */ +static void +system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + u8_t id; + + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if (ident_len == 2) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def system.%"U16_F".0\n",(u16_t)id)); + switch (id) + { + case 1: /* sysDescr */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = *sysdescr_len_ptr; + break; + case 2: /* sysObjectID */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID); + od->v_len = sysobjid.len * sizeof(s32_t); + break; + case 3: /* sysUpTime */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS); + od->v_len = sizeof(u32_t); + break; + case 4: /* sysContact */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = *syscontact_len_ptr; + break; + case 5: /* sysName */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = *sysname_len_ptr; + break; + case 6: /* sysLocation */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = *syslocation_len_ptr; + break; + case 7: /* sysServices */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + }; + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +/** + * Returns system object value. + * + * @param ident_len the address length (2) + * @param ident points to objectname.0 (object id trailer) + * @param len return value space (in bytes) + * @param value points to (varbind) space to copy value into. + */ +static void +system_get_value(struct obj_def *od, u16_t len, void *value) +{ + u8_t id; + + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* sysDescr */ + ocstrncpy((u8_t*)value, sysdescr_ptr, len); + break; + case 2: /* sysObjectID */ + objectidncpy((s32_t*)value, (s32_t*)sysobjid.id, (u8_t)(len / sizeof(s32_t))); + break; + case 3: /* sysUpTime */ + { + snmp_get_sysuptime((u32_t*)value); + } + break; + case 4: /* sysContact */ + ocstrncpy((u8_t*)value, syscontact_ptr, len); + break; + case 5: /* sysName */ + ocstrncpy((u8_t*)value, sysname_ptr, len); + break; + case 6: /* sysLocation */ + ocstrncpy((u8_t*)value, syslocation_ptr, len); + break; + case 7: /* sysServices */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = sysservices; + } + break; + }; +} + +static u8_t +system_set_test(struct obj_def *od, u16_t len, void *value) +{ + u8_t id, set_ok; + + LWIP_UNUSED_ARG(value); + set_ok = 0; + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 4: /* sysContact */ + if ((syscontact_ptr != syscontact_default) && + (len <= 255)) + { + set_ok = 1; + } + break; + case 5: /* sysName */ + if ((sysname_ptr != sysname_default) && + (len <= 255)) + { + set_ok = 1; + } + break; + case 6: /* sysLocation */ + if ((syslocation_ptr != syslocation_default) && + (len <= 255)) + { + set_ok = 1; + } + break; + }; + return set_ok; +} + +static void +system_set_value(struct obj_def *od, u16_t len, void *value) +{ + u8_t id; + + LWIP_ASSERT("invalid len", len <= 0xff); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 4: /* sysContact */ + ocstrncpy(syscontact_ptr, (u8_t*)value, len); + *syscontact_len_ptr = (u8_t)len; + break; + case 5: /* sysName */ + ocstrncpy(sysname_ptr, (u8_t*)value, len); + *sysname_len_ptr = (u8_t)len; + break; + case 6: /* sysLocation */ + ocstrncpy(syslocation_ptr, (u8_t*)value, len); + *syslocation_len_ptr = (u8_t)len; + break; + }; +} + +/** + * Returns interfaces.ifnumber object definition. + * + * @param ident_len the address length (2) + * @param ident points to objectname.index + * @param od points to object definition. + */ +static void +interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if (ident_len == 2) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("interfaces_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +/** + * Returns interfaces.ifnumber object value. + * + * @param ident_len the address length (2) + * @param ident points to objectname.0 (object id trailer) + * @param len return value space (in bytes) + * @param value points to (varbind) space to copy value into. + */ +static void +interfaces_get_value(struct obj_def *od, u16_t len, void *value) +{ + LWIP_UNUSED_ARG(len); + if (od->id_inst_ptr[0] == 1) + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = iflist_root.count; + } +} + +/** + * Returns ifentry object definitions. + * + * @param ident_len the address length (2) + * @param ident points to objectname.index + * @param od points to object definition. + */ +static void +ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + u8_t id; + + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if (ident_len == 2) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ifentry.%"U16_F"\n",(u16_t)id)); + switch (id) + { + case 1: /* ifIndex */ + case 3: /* ifType */ + case 4: /* ifMtu */ + case 8: /* ifOperStatus */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 2: /* ifDescr */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + /** @todo this should be some sort of sizeof(struct netif.name) */ + od->v_len = 2; + break; + case 5: /* ifSpeed */ + case 21: /* ifOutQLen */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE); + od->v_len = sizeof(u32_t); + break; + case 6: /* ifPhysAddress */ + { + struct netif *netif; + + snmp_ifindextonetif(ident[1], &netif); + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = netif->hwaddr_len; + } + break; + case 7: /* ifAdminStatus */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 9: /* ifLastChange */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS); + od->v_len = sizeof(u32_t); + break; + case 10: /* ifInOctets */ + case 11: /* ifInUcastPkts */ + case 12: /* ifInNUcastPkts */ + case 13: /* ifInDiscarts */ + case 14: /* ifInErrors */ + case 15: /* ifInUnkownProtos */ + case 16: /* ifOutOctets */ + case 17: /* ifOutUcastPkts */ + case 18: /* ifOutNUcastPkts */ + case 19: /* ifOutDiscarts */ + case 20: /* ifOutErrors */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); + od->v_len = sizeof(u32_t); + break; + case 22: /* ifSpecific */ + /** @note returning zeroDotZero (0.0) no media specific MIB support */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID); + od->v_len = ifspecific.len * sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + }; + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +/** + * Returns ifentry object value. + * + * @param ident_len the address length (2) + * @param ident points to objectname.0 (object id trailer) + * @param len return value space (in bytes) + * @param value points to (varbind) space to copy value into. + */ +static void +ifentry_get_value(struct obj_def *od, u16_t len, void *value) +{ + struct netif *netif; + u8_t id; + + snmp_ifindextonetif(od->id_inst_ptr[1], &netif); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* ifIndex */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = od->id_inst_ptr[1]; + } + break; + case 2: /* ifDescr */ + ocstrncpy((u8_t*)value, (u8_t*)netif->name, len); + break; + case 3: /* ifType */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = netif->link_type; + } + break; + case 4: /* ifMtu */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = netif->mtu; + } + break; + case 5: /* ifSpeed */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->link_speed; + } + break; + case 6: /* ifPhysAddress */ + ocstrncpy((u8_t*)value, netif->hwaddr, len); + break; + case 7: /* ifAdminStatus */ + { + s32_t *sint_ptr = (s32_t*)value; + if (netif_is_up(netif)) + { + if (netif_is_link_up(netif)) + { + *sint_ptr = 1; /* up */ + } + else + { + *sint_ptr = 7; /* lowerLayerDown */ + } + } + else + { + *sint_ptr = 2; /* down */ + } + } + break; + case 8: /* ifOperStatus */ + { + s32_t *sint_ptr = (s32_t*)value; + if (netif_is_up(netif)) + { + *sint_ptr = 1; + } + else + { + *sint_ptr = 2; + } + } + break; + case 9: /* ifLastChange */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ts; + } + break; + case 10: /* ifInOctets */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifinoctets; + } + break; + case 11: /* ifInUcastPkts */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifinucastpkts; + } + break; + case 12: /* ifInNUcastPkts */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifinnucastpkts; + } + break; + case 13: /* ifInDiscarts */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifindiscards; + } + break; + case 14: /* ifInErrors */ + case 15: /* ifInUnkownProtos */ + /** @todo add these counters! */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = 0; + } + break; + case 16: /* ifOutOctets */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifoutoctets; + } + break; + case 17: /* ifOutUcastPkts */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifoutucastpkts; + } + break; + case 18: /* ifOutNUcastPkts */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifoutnucastpkts; + } + break; + case 19: /* ifOutDiscarts */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = netif->ifoutdiscards; + } + break; + case 20: /* ifOutErrors */ + /** @todo add this counter! */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = 0; + } + break; + case 21: /* ifOutQLen */ + /** @todo figure out if this must be 0 (no queue) or 1? */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = 0; + } + break; + case 22: /* ifSpecific */ + objectidncpy((s32_t*)value, (s32_t*)ifspecific.id, (u8_t)(len / sizeof(s32_t))); + break; + }; +} + +#if !SNMP_SAFE_REQUESTS +static u8_t +ifentry_set_test(struct obj_def *od, u16_t len, void *value) +{ + struct netif *netif; + u8_t id, set_ok; + LWIP_UNUSED_ARG(len); + + set_ok = 0; + snmp_ifindextonetif(od->id_inst_ptr[1], &netif); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 7: /* ifAdminStatus */ + { + s32_t *sint_ptr = (s32_t*)value; + if (*sint_ptr == 1 || *sint_ptr == 2) + set_ok = 1; + } + break; + } + return set_ok; +} + +static void +ifentry_set_value(struct obj_def *od, u16_t len, void *value) +{ + struct netif *netif; + u8_t id; + LWIP_UNUSED_ARG(len); + + snmp_ifindextonetif(od->id_inst_ptr[1], &netif); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 7: /* ifAdminStatus */ + { + s32_t *sint_ptr = (s32_t*)value; + if (*sint_ptr == 1) + { + netif_set_up(netif); + } + else if (*sint_ptr == 2) + { + netif_set_down(netif); + } + } + break; + } +} +#endif /* SNMP_SAFE_REQUESTS */ + +/** + * Returns atentry object definitions. + * + * @param ident_len the address length (6) + * @param ident points to objectname.atifindex.atnetaddress + * @param od points to object definition. + */ +static void +atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (5) */ + ident_len += 5; + ident -= 5; + + if (ident_len == 6) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + switch (ident[0]) + { + case 1: /* atIfIndex */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 2: /* atPhysAddress */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = 6; /** @todo try to use netif::hwaddr_len */ + break; + case 3: /* atNetAddress */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); + od->v_len = 4; + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + } + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +atentry_get_value(struct obj_def *od, u16_t len, void *value) +{ +#if LWIP_ARP + u8_t id; + struct eth_addr* ethaddr_ret; + ip_addr_t* ipaddr_ret; +#endif /* LWIP_ARP */ + ip_addr_t ip; + struct netif *netif; + + LWIP_UNUSED_ARG(len); + LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */ + + snmp_ifindextonetif(od->id_inst_ptr[1], &netif); + snmp_oidtoip(&od->id_inst_ptr[2], &ip); + +#if LWIP_ARP /** @todo implement a netif_find_addr */ + if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1) + { + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* atIfIndex */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = od->id_inst_ptr[1]; + } + break; + case 2: /* atPhysAddress */ + { + struct eth_addr *dst = (struct eth_addr*)value; + + *dst = *ethaddr_ret; + } + break; + case 3: /* atNetAddress */ + { + ip_addr_t *dst = (ip_addr_t*)value; + + *dst = *ipaddr_ret; + } + break; + } + } +#endif /* LWIP_ARP */ +} + +static void +ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + u8_t id; + + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if (ident_len == 2) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ip.%"U16_F".0\n",(u16_t)id)); + switch (id) + { + case 1: /* ipForwarding */ + case 2: /* ipDefaultTTL */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 3: /* ipInReceives */ + case 4: /* ipInHdrErrors */ + case 5: /* ipInAddrErrors */ + case 6: /* ipForwDatagrams */ + case 7: /* ipInUnknownProtos */ + case 8: /* ipInDiscards */ + case 9: /* ipInDelivers */ + case 10: /* ipOutRequests */ + case 11: /* ipOutDiscards */ + case 12: /* ipOutNoRoutes */ + case 14: /* ipReasmReqds */ + case 15: /* ipReasmOKs */ + case 16: /* ipReasmFails */ + case 17: /* ipFragOKs */ + case 18: /* ipFragFails */ + case 19: /* ipFragCreates */ + case 23: /* ipRoutingDiscards */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); + od->v_len = sizeof(u32_t); + break; + case 13: /* ipReasmTimeout */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + }; + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +ip_get_value(struct obj_def *od, u16_t len, void *value) +{ + u8_t id; + + LWIP_UNUSED_ARG(len); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* ipForwarding */ + { + s32_t *sint_ptr = (s32_t*)value; +#if IP_FORWARD + /* forwarding */ + *sint_ptr = 1; +#else + /* not-forwarding */ + *sint_ptr = 2; +#endif + } + break; + case 2: /* ipDefaultTTL */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = IP_DEFAULT_TTL; + } + break; + case 3: /* ipInReceives */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipinreceives; + } + break; + case 4: /* ipInHdrErrors */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipinhdrerrors; + } + break; + case 5: /* ipInAddrErrors */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipinaddrerrors; + } + break; + case 6: /* ipForwDatagrams */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipforwdatagrams; + } + break; + case 7: /* ipInUnknownProtos */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipinunknownprotos; + } + break; + case 8: /* ipInDiscards */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipindiscards; + } + break; + case 9: /* ipInDelivers */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipindelivers; + } + break; + case 10: /* ipOutRequests */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipoutrequests; + } + break; + case 11: /* ipOutDiscards */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipoutdiscards; + } + break; + case 12: /* ipOutNoRoutes */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipoutnoroutes; + } + break; + case 13: /* ipReasmTimeout */ + { + s32_t *sint_ptr = (s32_t*)value; +#if IP_REASSEMBLY + *sint_ptr = IP_REASS_MAXAGE; +#else + *sint_ptr = 0; +#endif + } + break; + case 14: /* ipReasmReqds */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipreasmreqds; + } + break; + case 15: /* ipReasmOKs */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipreasmoks; + } + break; + case 16: /* ipReasmFails */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipreasmfails; + } + break; + case 17: /* ipFragOKs */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipfragoks; + } + break; + case 18: /* ipFragFails */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipfragfails; + } + break; + case 19: /* ipFragCreates */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = ipfragcreates; + } + break; + case 23: /* ipRoutingDiscards */ + /** @todo can lwIP discard routes at all?? hardwire this to 0?? */ + { + u32_t *uint_ptr = (u32_t*)value; + *uint_ptr = iproutingdiscards; + } + break; + }; +} + +/** + * Test ip object value before setting. + * + * @param od is the object definition + * @param len return value space (in bytes) + * @param value points to (varbind) space to copy value from. + * + * @note we allow set if the value matches the hardwired value, + * otherwise return badvalue. + */ +static u8_t +ip_set_test(struct obj_def *od, u16_t len, void *value) +{ + u8_t id, set_ok; + s32_t *sint_ptr = (s32_t*)value; + + LWIP_UNUSED_ARG(len); + set_ok = 0; + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* ipForwarding */ +#if IP_FORWARD + /* forwarding */ + if (*sint_ptr == 1) +#else + /* not-forwarding */ + if (*sint_ptr == 2) +#endif + { + set_ok = 1; + } + break; + case 2: /* ipDefaultTTL */ + if (*sint_ptr == IP_DEFAULT_TTL) + { + set_ok = 1; + } + break; + }; + return set_ok; +} + +static void +ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (4) */ + ident_len += 4; + ident -= 4; + + if (ident_len == 5) + { + u8_t id; + + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + switch (id) + { + case 1: /* ipAdEntAddr */ + case 3: /* ipAdEntNetMask */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); + od->v_len = 4; + break; + case 2: /* ipAdEntIfIndex */ + case 4: /* ipAdEntBcastAddr */ + case 5: /* ipAdEntReasmMaxSize */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + } + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value) +{ + u8_t id; + u16_t ifidx; + ip_addr_t ip; + struct netif *netif = netif_list; + + LWIP_UNUSED_ARG(len); + snmp_oidtoip(&od->id_inst_ptr[1], &ip); + ifidx = 0; + while ((netif != NULL) && !ip_addr_cmp(&ip, &netif->ip_addr)) + { + netif = netif->next; + ifidx++; + } + + if (netif != NULL) + { + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* ipAdEntAddr */ + { + ip_addr_t *dst = (ip_addr_t*)value; + *dst = netif->ip_addr; + } + break; + case 2: /* ipAdEntIfIndex */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = ifidx + 1; + } + break; + case 3: /* ipAdEntNetMask */ + { + ip_addr_t *dst = (ip_addr_t*)value; + *dst = netif->netmask; + } + break; + case 4: /* ipAdEntBcastAddr */ + { + s32_t *sint_ptr = (s32_t*)value; + + /* lwIP oddity, there's no broadcast + address in the netif we can rely on */ + *sint_ptr = IPADDR_BROADCAST & 1; + } + break; + case 5: /* ipAdEntReasmMaxSize */ + { + s32_t *sint_ptr = (s32_t*)value; +#if IP_REASSEMBLY + /* @todo The theoretical maximum is IP_REASS_MAX_PBUFS * size of the pbufs, + * but only if receiving one fragmented packet at a time. + * The current solution is to calculate for 2 simultaneous packets... + */ + *sint_ptr = (IP_HLEN + ((IP_REASS_MAX_PBUFS/2) * + (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN - IP_HLEN))); +#else + /** @todo returning MTU would be a bad thing and + returning a wild guess like '576' isn't good either */ + *sint_ptr = 0; +#endif + } + break; + } + } +} + +/** + * @note + * lwIP IP routing is currently using the network addresses in netif_list. + * if no suitable network IP is found in netif_list, the default_netif is used. + */ +static void +ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + u8_t id; + + /* return to object name, adding index depth (4) */ + ident_len += 4; + ident -= 4; + + if (ident_len == 5) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + switch (id) + { + case 1: /* ipRouteDest */ + case 7: /* ipRouteNextHop */ + case 11: /* ipRouteMask */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); + od->v_len = 4; + break; + case 2: /* ipRouteIfIndex */ + case 3: /* ipRouteMetric1 */ + case 4: /* ipRouteMetric2 */ + case 5: /* ipRouteMetric3 */ + case 6: /* ipRouteMetric4 */ + case 8: /* ipRouteType */ + case 10: /* ipRouteAge */ + case 12: /* ipRouteMetric5 */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 9: /* ipRouteProto */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 13: /* ipRouteInfo */ + /** @note returning zeroDotZero (0.0) no routing protocol specific MIB */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID); + od->v_len = iprouteinfo.len * sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + } + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value) +{ + struct netif *netif; + ip_addr_t dest; + s32_t *ident; + u8_t id; + + ident = od->id_inst_ptr; + snmp_oidtoip(&ident[1], &dest); + + if (ip_addr_isany(&dest)) + { + /* ip_route() uses default netif for default route */ + netif = netif_default; + } + else + { + /* not using ip_route(), need exact match! */ + netif = netif_list; + while ((netif != NULL) && + !ip_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) ) + { + netif = netif->next; + } + } + if (netif != NULL) + { + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + switch (id) + { + case 1: /* ipRouteDest */ + { + ip_addr_t *dst = (ip_addr_t*)value; + + if (ip_addr_isany(&dest)) + { + /* default rte has 0.0.0.0 dest */ + ip_addr_set_zero(dst); + } + else + { + /* netifs have netaddress dest */ + ip_addr_get_network(dst, &netif->ip_addr, &netif->netmask); + } + } + break; + case 2: /* ipRouteIfIndex */ + { + s32_t *sint_ptr = (s32_t*)value; + + snmp_netiftoifindex(netif, sint_ptr); + } + break; + case 3: /* ipRouteMetric1 */ + { + s32_t *sint_ptr = (s32_t*)value; + + if (ip_addr_isany(&dest)) + { + /* default rte has metric 1 */ + *sint_ptr = 1; + } + else + { + /* other rtes have metric 0 */ + *sint_ptr = 0; + } + } + break; + case 4: /* ipRouteMetric2 */ + case 5: /* ipRouteMetric3 */ + case 6: /* ipRouteMetric4 */ + case 12: /* ipRouteMetric5 */ + { + s32_t *sint_ptr = (s32_t*)value; + /* not used */ + *sint_ptr = -1; + } + break; + case 7: /* ipRouteNextHop */ + { + ip_addr_t *dst = (ip_addr_t*)value; + + if (ip_addr_isany(&dest)) + { + /* default rte: gateway */ + *dst = netif->gw; + } + else + { + /* other rtes: netif ip_addr */ + *dst = netif->ip_addr; + } + } + break; + case 8: /* ipRouteType */ + { + s32_t *sint_ptr = (s32_t*)value; + + if (ip_addr_isany(&dest)) + { + /* default rte is indirect */ + *sint_ptr = 4; + } + else + { + /* other rtes are direct */ + *sint_ptr = 3; + } + } + break; + case 9: /* ipRouteProto */ + { + s32_t *sint_ptr = (s32_t*)value; + /* locally defined routes */ + *sint_ptr = 2; + } + break; + case 10: /* ipRouteAge */ + { + s32_t *sint_ptr = (s32_t*)value; + /** @todo (sysuptime - timestamp last change) / 100 + @see snmp_insert_iprteidx_tree() */ + *sint_ptr = 0; + } + break; + case 11: /* ipRouteMask */ + { + ip_addr_t *dst = (ip_addr_t*)value; + + if (ip_addr_isany(&dest)) + { + /* default rte use 0.0.0.0 mask */ + ip_addr_set_zero(dst); + } + else + { + /* other rtes use netmask */ + *dst = netif->netmask; + } + } + break; + case 13: /* ipRouteInfo */ + objectidncpy((s32_t*)value, (s32_t*)iprouteinfo.id, (u8_t)(len / sizeof(s32_t))); + break; + } + } +} + +static void +ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (5) */ + ident_len += 5; + ident -= 5; + + if (ident_len == 6) + { + u8_t id; + + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + switch (id) + { + case 1: /* ipNetToMediaIfIndex */ + case 4: /* ipNetToMediaType */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 2: /* ipNetToMediaPhysAddress */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); + od->v_len = 6; /** @todo try to use netif::hwaddr_len */ + break; + case 3: /* ipNetToMediaNetAddress */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); + od->v_len = 4; + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + } + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value) +{ +#if LWIP_ARP + u8_t id; + struct eth_addr* ethaddr_ret; + ip_addr_t* ipaddr_ret; +#endif /* LWIP_ARP */ + ip_addr_t ip; + struct netif *netif; + + LWIP_UNUSED_ARG(len); + LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */ + + snmp_ifindextonetif(od->id_inst_ptr[1], &netif); + snmp_oidtoip(&od->id_inst_ptr[2], &ip); + +#if LWIP_ARP /** @todo implement a netif_find_addr */ + if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1) + { + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* ipNetToMediaIfIndex */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = od->id_inst_ptr[1]; + } + break; + case 2: /* ipNetToMediaPhysAddress */ + { + struct eth_addr *dst = (struct eth_addr*)value; + + *dst = *ethaddr_ret; + } + break; + case 3: /* ipNetToMediaNetAddress */ + { + ip_addr_t *dst = (ip_addr_t*)value; + + *dst = *ipaddr_ret; + } + break; + case 4: /* ipNetToMediaType */ + { + s32_t *sint_ptr = (s32_t*)value; + /* dynamic (?) */ + *sint_ptr = 3; + } + break; + } + } +#endif /* LWIP_ARP */ +} + +static void +icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if ((ident_len == 2) && + (ident[0] > 0) && (ident[0] < 27)) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); + od->v_len = sizeof(u32_t); + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +icmp_get_value(struct obj_def *od, u16_t len, void *value) +{ + u32_t *uint_ptr = (u32_t*)value; + u8_t id; + + LWIP_UNUSED_ARG(len); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* icmpInMsgs */ + *uint_ptr = icmpinmsgs; + break; + case 2: /* icmpInErrors */ + *uint_ptr = icmpinerrors; + break; + case 3: /* icmpInDestUnreachs */ + *uint_ptr = icmpindestunreachs; + break; + case 4: /* icmpInTimeExcds */ + *uint_ptr = icmpintimeexcds; + break; + case 5: /* icmpInParmProbs */ + *uint_ptr = icmpinparmprobs; + break; + case 6: /* icmpInSrcQuenchs */ + *uint_ptr = icmpinsrcquenchs; + break; + case 7: /* icmpInRedirects */ + *uint_ptr = icmpinredirects; + break; + case 8: /* icmpInEchos */ + *uint_ptr = icmpinechos; + break; + case 9: /* icmpInEchoReps */ + *uint_ptr = icmpinechoreps; + break; + case 10: /* icmpInTimestamps */ + *uint_ptr = icmpintimestamps; + break; + case 11: /* icmpInTimestampReps */ + *uint_ptr = icmpintimestampreps; + break; + case 12: /* icmpInAddrMasks */ + *uint_ptr = icmpinaddrmasks; + break; + case 13: /* icmpInAddrMaskReps */ + *uint_ptr = icmpinaddrmaskreps; + break; + case 14: /* icmpOutMsgs */ + *uint_ptr = icmpoutmsgs; + break; + case 15: /* icmpOutErrors */ + *uint_ptr = icmpouterrors; + break; + case 16: /* icmpOutDestUnreachs */ + *uint_ptr = icmpoutdestunreachs; + break; + case 17: /* icmpOutTimeExcds */ + *uint_ptr = icmpouttimeexcds; + break; + case 18: /* icmpOutParmProbs */ + *uint_ptr = icmpoutparmprobs; + break; + case 19: /* icmpOutSrcQuenchs */ + *uint_ptr = icmpoutsrcquenchs; + break; + case 20: /* icmpOutRedirects */ + *uint_ptr = icmpoutredirects; + break; + case 21: /* icmpOutEchos */ + *uint_ptr = icmpoutechos; + break; + case 22: /* icmpOutEchoReps */ + *uint_ptr = icmpoutechoreps; + break; + case 23: /* icmpOutTimestamps */ + *uint_ptr = icmpouttimestamps; + break; + case 24: /* icmpOutTimestampReps */ + *uint_ptr = icmpouttimestampreps; + break; + case 25: /* icmpOutAddrMasks */ + *uint_ptr = icmpoutaddrmasks; + break; + case 26: /* icmpOutAddrMaskReps */ + *uint_ptr = icmpoutaddrmaskreps; + break; + } +} + +#if LWIP_TCP +/** @todo tcp grp */ +static void +tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + u8_t id; + + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if (ident_len == 2) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id)); + + switch (id) + { + case 1: /* tcpRtoAlgorithm */ + case 2: /* tcpRtoMin */ + case 3: /* tcpRtoMax */ + case 4: /* tcpMaxConn */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 5: /* tcpActiveOpens */ + case 6: /* tcpPassiveOpens */ + case 7: /* tcpAttemptFails */ + case 8: /* tcpEstabResets */ + case 10: /* tcpInSegs */ + case 11: /* tcpOutSegs */ + case 12: /* tcpRetransSegs */ + case 14: /* tcpInErrs */ + case 15: /* tcpOutRsts */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); + od->v_len = sizeof(u32_t); + break; + case 9: /* tcpCurrEstab */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE); + od->v_len = sizeof(u32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + }; + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +tcp_get_value(struct obj_def *od, u16_t len, void *value) +{ + u32_t *uint_ptr = (u32_t*)value; + s32_t *sint_ptr = (s32_t*)value; + u8_t id; + + LWIP_UNUSED_ARG(len); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* tcpRtoAlgorithm, vanj(4) */ + *sint_ptr = 4; + break; + case 2: /* tcpRtoMin */ + /* @todo not the actual value, a guess, + needs to be calculated */ + *sint_ptr = 1000; + break; + case 3: /* tcpRtoMax */ + /* @todo not the actual value, a guess, + needs to be calculated */ + *sint_ptr = 60000; + break; + case 4: /* tcpMaxConn */ + *sint_ptr = MEMP_NUM_TCP_PCB; + break; + case 5: /* tcpActiveOpens */ + *uint_ptr = tcpactiveopens; + break; + case 6: /* tcpPassiveOpens */ + *uint_ptr = tcppassiveopens; + break; + case 7: /* tcpAttemptFails */ + *uint_ptr = tcpattemptfails; + break; + case 8: /* tcpEstabResets */ + *uint_ptr = tcpestabresets; + break; + case 9: /* tcpCurrEstab */ + { + u16_t tcpcurrestab = 0; + struct tcp_pcb *pcb = tcp_active_pcbs; + while (pcb != NULL) + { + if ((pcb->state == ESTABLISHED) || + (pcb->state == CLOSE_WAIT)) + { + tcpcurrestab++; + } + pcb = pcb->next; + } + *uint_ptr = tcpcurrestab; + } + break; + case 10: /* tcpInSegs */ + *uint_ptr = tcpinsegs; + break; + case 11: /* tcpOutSegs */ + *uint_ptr = tcpoutsegs; + break; + case 12: /* tcpRetransSegs */ + *uint_ptr = tcpretranssegs; + break; + case 14: /* tcpInErrs */ + *uint_ptr = tcpinerrs; + break; + case 15: /* tcpOutRsts */ + *uint_ptr = tcpoutrsts; + break; + } +} +#ifdef THIS_SEEMS_UNUSED +static void +tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (10) */ + ident_len += 10; + ident -= 10; + + if (ident_len == 11) + { + u8_t id; + + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + id = ident[0]; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id)); + + switch (id) + { + case 1: /* tcpConnState */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + case 2: /* tcpConnLocalAddress */ + case 4: /* tcpConnRemAddress */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); + od->v_len = 4; + break; + case 3: /* tcpConnLocalPort */ + case 5: /* tcpConnRemPort */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + }; + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value) +{ + ip_addr_t lip, rip; + u16_t lport, rport; + s32_t *ident; + + ident = od->id_inst_ptr; + snmp_oidtoip(&ident[1], &lip); + lport = ident[5]; + snmp_oidtoip(&ident[6], &rip); + rport = ident[10]; + + /** @todo find matching PCB */ +} +#endif /* if 0 */ +#endif + +static void +udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if ((ident_len == 2) && + (ident[0] > 0) && (ident[0] < 6)) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); + od->v_len = sizeof(u32_t); + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +udp_get_value(struct obj_def *od, u16_t len, void *value) +{ + u32_t *uint_ptr = (u32_t*)value; + u8_t id; + + LWIP_UNUSED_ARG(len); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* udpInDatagrams */ + *uint_ptr = udpindatagrams; + break; + case 2: /* udpNoPorts */ + *uint_ptr = udpnoports; + break; + case 3: /* udpInErrors */ + *uint_ptr = udpinerrors; + break; + case 4: /* udpOutDatagrams */ + *uint_ptr = udpoutdatagrams; + break; + } +} + +static void +udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (5) */ + ident_len += 5; + ident -= 5; + + if (ident_len == 6) + { + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + switch (ident[0]) + { + case 1: /* udpLocalAddress */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); + od->v_len = 4; + break; + case 2: /* udpLocalPort */ + od->instance = MIB_OBJECT_TAB; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + } + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +udpentry_get_value(struct obj_def *od, u16_t len, void *value) +{ + u8_t id; + struct udp_pcb *pcb; + ip_addr_t ip; + u16_t port; + + LWIP_UNUSED_ARG(len); + snmp_oidtoip(&od->id_inst_ptr[1], &ip); + LWIP_ASSERT("invalid port", (od->id_inst_ptr[5] >= 0) && (od->id_inst_ptr[5] <= 0xffff)); + port = (u16_t)od->id_inst_ptr[5]; + + pcb = udp_pcbs; + while ((pcb != NULL) && + !(ip_addr_cmp(&pcb->local_ip, &ip) && + (pcb->local_port == port))) + { + pcb = pcb->next; + } + + if (pcb != NULL) + { + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* udpLocalAddress */ + { + ip_addr_t *dst = (ip_addr_t*)value; + *dst = pcb->local_ip; + } + break; + case 2: /* udpLocalPort */ + { + s32_t *sint_ptr = (s32_t*)value; + *sint_ptr = pcb->local_port; + } + break; + } + } +} + +static void +snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) +{ + /* return to object name, adding index depth (1) */ + ident_len += 1; + ident -= 1; + if (ident_len == 2) + { + u8_t id; + + od->id_inst_len = ident_len; + od->id_inst_ptr = ident; + + LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); + id = (u8_t)ident[0]; + switch (id) + { + case 1: /* snmpInPkts */ + case 2: /* snmpOutPkts */ + case 3: /* snmpInBadVersions */ + case 4: /* snmpInBadCommunityNames */ + case 5: /* snmpInBadCommunityUses */ + case 6: /* snmpInASNParseErrs */ + case 8: /* snmpInTooBigs */ + case 9: /* snmpInNoSuchNames */ + case 10: /* snmpInBadValues */ + case 11: /* snmpInReadOnlys */ + case 12: /* snmpInGenErrs */ + case 13: /* snmpInTotalReqVars */ + case 14: /* snmpInTotalSetVars */ + case 15: /* snmpInGetRequests */ + case 16: /* snmpInGetNexts */ + case 17: /* snmpInSetRequests */ + case 18: /* snmpInGetResponses */ + case 19: /* snmpInTraps */ + case 20: /* snmpOutTooBigs */ + case 21: /* snmpOutNoSuchNames */ + case 22: /* snmpOutBadValues */ + case 24: /* snmpOutGenErrs */ + case 25: /* snmpOutGetRequests */ + case 26: /* snmpOutGetNexts */ + case 27: /* snmpOutSetRequests */ + case 28: /* snmpOutGetResponses */ + case 29: /* snmpOutTraps */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_ONLY; + od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); + od->v_len = sizeof(u32_t); + break; + case 30: /* snmpEnableAuthenTraps */ + od->instance = MIB_OBJECT_SCALAR; + od->access = MIB_OBJECT_READ_WRITE; + od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); + od->v_len = sizeof(s32_t); + break; + default: + LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no such object\n")); + od->instance = MIB_OBJECT_NONE; + break; + }; + } + else + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no scalar\n")); + od->instance = MIB_OBJECT_NONE; + } +} + +static void +snmp_get_value(struct obj_def *od, u16_t len, void *value) +{ + u32_t *uint_ptr = (u32_t*)value; + u8_t id; + + LWIP_UNUSED_ARG(len); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + switch (id) + { + case 1: /* snmpInPkts */ + *uint_ptr = snmpinpkts; + break; + case 2: /* snmpOutPkts */ + *uint_ptr = snmpoutpkts; + break; + case 3: /* snmpInBadVersions */ + *uint_ptr = snmpinbadversions; + break; + case 4: /* snmpInBadCommunityNames */ + *uint_ptr = snmpinbadcommunitynames; + break; + case 5: /* snmpInBadCommunityUses */ + *uint_ptr = snmpinbadcommunityuses; + break; + case 6: /* snmpInASNParseErrs */ + *uint_ptr = snmpinasnparseerrs; + break; + case 8: /* snmpInTooBigs */ + *uint_ptr = snmpintoobigs; + break; + case 9: /* snmpInNoSuchNames */ + *uint_ptr = snmpinnosuchnames; + break; + case 10: /* snmpInBadValues */ + *uint_ptr = snmpinbadvalues; + break; + case 11: /* snmpInReadOnlys */ + *uint_ptr = snmpinreadonlys; + break; + case 12: /* snmpInGenErrs */ + *uint_ptr = snmpingenerrs; + break; + case 13: /* snmpInTotalReqVars */ + *uint_ptr = snmpintotalreqvars; + break; + case 14: /* snmpInTotalSetVars */ + *uint_ptr = snmpintotalsetvars; + break; + case 15: /* snmpInGetRequests */ + *uint_ptr = snmpingetrequests; + break; + case 16: /* snmpInGetNexts */ + *uint_ptr = snmpingetnexts; + break; + case 17: /* snmpInSetRequests */ + *uint_ptr = snmpinsetrequests; + break; + case 18: /* snmpInGetResponses */ + *uint_ptr = snmpingetresponses; + break; + case 19: /* snmpInTraps */ + *uint_ptr = snmpintraps; + break; + case 20: /* snmpOutTooBigs */ + *uint_ptr = snmpouttoobigs; + break; + case 21: /* snmpOutNoSuchNames */ + *uint_ptr = snmpoutnosuchnames; + break; + case 22: /* snmpOutBadValues */ + *uint_ptr = snmpoutbadvalues; + break; + case 24: /* snmpOutGenErrs */ + *uint_ptr = snmpoutgenerrs; + break; + case 25: /* snmpOutGetRequests */ + *uint_ptr = snmpoutgetrequests; + break; + case 26: /* snmpOutGetNexts */ + *uint_ptr = snmpoutgetnexts; + break; + case 27: /* snmpOutSetRequests */ + *uint_ptr = snmpoutsetrequests; + break; + case 28: /* snmpOutGetResponses */ + *uint_ptr = snmpoutgetresponses; + break; + case 29: /* snmpOutTraps */ + *uint_ptr = snmpouttraps; + break; + case 30: /* snmpEnableAuthenTraps */ + *uint_ptr = *snmpenableauthentraps_ptr; + break; + }; +} + +/** + * Test snmp object value before setting. + * + * @param od is the object definition + * @param len return value space (in bytes) + * @param value points to (varbind) space to copy value from. + */ +static u8_t +snmp_set_test(struct obj_def *od, u16_t len, void *value) +{ + u8_t id, set_ok; + + LWIP_UNUSED_ARG(len); + set_ok = 0; + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + if (id == 30) + { + /* snmpEnableAuthenTraps */ + s32_t *sint_ptr = (s32_t*)value; + + if (snmpenableauthentraps_ptr != &snmpenableauthentraps_default) + { + /* we should have writable non-volatile mem here */ + if ((*sint_ptr == 1) || (*sint_ptr == 2)) + { + set_ok = 1; + } + } + else + { + /* const or hardwired value */ + if (*sint_ptr == snmpenableauthentraps_default) + { + set_ok = 1; + } + } + } + return set_ok; +} + +static void +snmp_set_value(struct obj_def *od, u16_t len, void *value) +{ + u8_t id; + + LWIP_UNUSED_ARG(len); + LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); + id = (u8_t)od->id_inst_ptr[0]; + if (id == 30) + { + /* snmpEnableAuthenTraps */ + /* @todo @fixme: which kind of pointer is 'value'? s32_t or u8_t??? */ + u8_t *ptr = (u8_t*)value; + *snmpenableauthentraps_ptr = *ptr; + } +} + +#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/mib_structs.c b/user/mpy/lib/lwip/src/core/snmp/mib_structs.c new file mode 100644 index 0000000..2f185cb --- /dev/null +++ b/user/mpy/lib/lwip/src/core/snmp/mib_structs.c @@ -0,0 +1,1174 @@ +/** + * @file + * MIB tree access/construction functions. + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/snmp_structs.h" +#include "lwip/memp.h" +#include "lwip/netif.h" + +/** .iso.org.dod.internet address prefix, @see snmp_iso_*() */ +const s32_t prefix[4] = {1, 3, 6, 1}; + +#define NODE_STACK_SIZE (LWIP_SNMP_OBJ_ID_LEN) +/** node stack entry (old news?) */ +struct nse +{ + /** right child */ + struct mib_node* r_ptr; + /** right child identifier */ + s32_t r_id; + /** right child next level */ + u8_t r_nl; +}; +static u8_t node_stack_cnt; +static struct nse node_stack[NODE_STACK_SIZE]; + +/** + * Pushes nse struct onto stack. + */ +static void +push_node(struct nse* node) +{ + LWIP_ASSERT("node_stack_cnt < NODE_STACK_SIZE",node_stack_cnt < NODE_STACK_SIZE); + LWIP_DEBUGF(SNMP_MIB_DEBUG,("push_node() node=%p id=%"S32_F"\n",(void*)(node->r_ptr),node->r_id)); + if (node_stack_cnt < NODE_STACK_SIZE) + { + node_stack[node_stack_cnt] = *node; + node_stack_cnt++; + } +} + +/** + * Pops nse struct from stack. + */ +static void +pop_node(struct nse* node) +{ + if (node_stack_cnt > 0) + { + node_stack_cnt--; + *node = node_stack[node_stack_cnt]; + } + LWIP_DEBUGF(SNMP_MIB_DEBUG,("pop_node() node=%p id=%"S32_F"\n",(void *)(node->r_ptr),node->r_id)); +} + +/** + * Conversion from ifIndex to lwIP netif + * @param ifindex is a s32_t object sub-identifier + * @param netif points to returned netif struct pointer + */ +void +snmp_ifindextonetif(s32_t ifindex, struct netif **netif) +{ + struct netif *nif = netif_list; + s32_t i, ifidx; + + ifidx = ifindex - 1; + i = 0; + while ((nif != NULL) && (i < ifidx)) + { + nif = nif->next; + i++; + } + *netif = nif; +} + +/** + * Conversion from lwIP netif to ifIndex + * @param netif points to a netif struct + * @param ifidx points to s32_t object sub-identifier + */ +void +snmp_netiftoifindex(struct netif *netif, s32_t *ifidx) +{ + struct netif *nif = netif_list; + u16_t i; + + i = 0; + while ((nif != NULL) && (nif != netif)) + { + nif = nif->next; + i++; + } + *ifidx = i+1; +} + +/** + * Conversion from oid to lwIP ip_addr + * @param ident points to s32_t ident[4] input + * @param ip points to output struct + */ +void +snmp_oidtoip(s32_t *ident, ip_addr_t *ip) +{ + IP4_ADDR(ip, ident[0], ident[1], ident[2], ident[3]); +} + +/** + * Conversion from lwIP ip_addr to oid + * @param ip points to input struct + * @param ident points to s32_t ident[4] output + */ +void +snmp_iptooid(ip_addr_t *ip, s32_t *ident) +{ + ident[0] = ip4_addr1(ip); + ident[1] = ip4_addr2(ip); + ident[2] = ip4_addr3(ip); + ident[3] = ip4_addr4(ip); +} + +struct mib_list_node * +snmp_mib_ln_alloc(s32_t id) +{ + struct mib_list_node *ln; + + ln = (struct mib_list_node *)memp_malloc(MEMP_SNMP_NODE); + if (ln != NULL) + { + ln->prev = NULL; + ln->next = NULL; + ln->objid = id; + ln->nptr = NULL; + } + return ln; +} + +void +snmp_mib_ln_free(struct mib_list_node *ln) +{ + memp_free(MEMP_SNMP_NODE, ln); +} + +struct mib_list_rootnode * +snmp_mib_lrn_alloc(void) +{ + struct mib_list_rootnode *lrn; + + lrn = (struct mib_list_rootnode*)memp_malloc(MEMP_SNMP_ROOTNODE); + if (lrn != NULL) + { + lrn->get_object_def = noleafs_get_object_def; + lrn->get_value = noleafs_get_value; + lrn->set_test = noleafs_set_test; + lrn->set_value = noleafs_set_value; + lrn->node_type = MIB_NODE_LR; + lrn->maxlength = 0; + lrn->head = NULL; + lrn->tail = NULL; + lrn->count = 0; + } + return lrn; +} + +void +snmp_mib_lrn_free(struct mib_list_rootnode *lrn) +{ + memp_free(MEMP_SNMP_ROOTNODE, lrn); +} + +/** + * Inserts node in idx list in a sorted + * (ascending order) fashion and + * allocates the node if needed. + * + * @param rn points to the root node + * @param objid is the object sub identifier + * @param insn points to a pointer to the inserted node + * used for constructing the tree. + * @return -1 if failed, 1 if inserted, 2 if present. + */ +s8_t +snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn) +{ + struct mib_list_node *nn; + s8_t insert; + + LWIP_ASSERT("rn != NULL",rn != NULL); + + /* -1 = malloc failure, 0 = not inserted, 1 = inserted, 2 = was present */ + insert = 0; + if (rn->head == NULL) + { + /* empty list, add first node */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc empty list objid==%"S32_F"\n",objid)); + nn = snmp_mib_ln_alloc(objid); + if (nn != NULL) + { + rn->head = nn; + rn->tail = nn; + *insn = nn; + insert = 1; + } + else + { + insert = -1; + } + } + else + { + struct mib_list_node *n; + /* at least one node is present */ + n = rn->head; + while ((n != NULL) && (insert == 0)) + { + if (n->objid == objid) + { + /* node is already there */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("node already there objid==%"S32_F"\n",objid)); + *insn = n; + insert = 2; + } + else if (n->objid < objid) + { + if (n->next == NULL) + { + /* alloc and insert at the tail */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc ins tail objid==%"S32_F"\n",objid)); + nn = snmp_mib_ln_alloc(objid); + if (nn != NULL) + { + nn->next = NULL; + nn->prev = n; + n->next = nn; + rn->tail = nn; + *insn = nn; + insert = 1; + } + else + { + /* insertion failure */ + insert = -1; + } + } + else + { + /* there's more to explore: traverse list */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("traverse list\n")); + n = n->next; + } + } + else + { + /* n->objid > objid */ + /* alloc and insert between n->prev and n */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc ins n->prev, objid==%"S32_F", n\n",objid)); + nn = snmp_mib_ln_alloc(objid); + if (nn != NULL) + { + if (n->prev == NULL) + { + /* insert at the head */ + nn->next = n; + nn->prev = NULL; + rn->head = nn; + n->prev = nn; + } + else + { + /* insert in the middle */ + nn->next = n; + nn->prev = n->prev; + n->prev->next = nn; + n->prev = nn; + } + *insn = nn; + insert = 1; + } + else + { + /* insertion failure */ + insert = -1; + } + } + } + } + if (insert == 1) + { + rn->count += 1; + } + LWIP_ASSERT("insert != 0",insert != 0); + return insert; +} + +/** + * Finds node in idx list and returns deletion mark. + * + * @param rn points to the root node + * @param objid is the object sub identifier + * @param fn returns pointer to found node + * @return 0 if not found, 1 if deletable, + * 2 can't delete (2 or more children), 3 not a list_node + */ +s8_t +snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn) +{ + s8_t fc; + struct mib_list_node *n; + + LWIP_ASSERT("rn != NULL",rn != NULL); + n = rn->head; + while ((n != NULL) && (n->objid != objid)) + { + n = n->next; + } + if (n == NULL) + { + fc = 0; + } + else if (n->nptr == NULL) + { + /* leaf, can delete node */ + fc = 1; + } + else + { + struct mib_list_rootnode *r; + + if (n->nptr->node_type == MIB_NODE_LR) + { + r = (struct mib_list_rootnode *)n->nptr; + if (r->count > 1) + { + /* can't delete node */ + fc = 2; + } + else + { + /* count <= 1, can delete node */ + fc = 1; + } + } + else + { + /* other node type */ + fc = 3; + } + } + *fn = n; + return fc; +} + +/** + * Removes node from idx list + * if it has a single child left. + * + * @param rn points to the root node + * @param n points to the node to delete + * @return the nptr to be freed by caller + */ +struct mib_list_rootnode * +snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n) +{ + struct mib_list_rootnode *next; + + LWIP_ASSERT("rn != NULL",rn != NULL); + LWIP_ASSERT("n != NULL",n != NULL); + + /* caller must remove this sub-tree */ + next = (struct mib_list_rootnode*)(n->nptr); + rn->count -= 1; + + if (n == rn->head) + { + rn->head = n->next; + if (n->next != NULL) + { + /* not last node, new list begin */ + n->next->prev = NULL; + } + } + else if (n == rn->tail) + { + rn->tail = n->prev; + if (n->prev != NULL) + { + /* not last node, new list end */ + n->prev->next = NULL; + } + } + else + { + /* node must be in the middle */ + n->prev->next = n->next; + n->next->prev = n->prev; + } + LWIP_DEBUGF(SNMP_MIB_DEBUG,("free list objid==%"S32_F"\n",n->objid)); + snmp_mib_ln_free(n); + if (rn->count == 0) + { + rn->head = NULL; + rn->tail = NULL; + } + return next; +} + + + +/** + * Searches tree for the supplied (scalar?) object identifier. + * + * @param node points to the root of the tree ('.internet') + * @param ident_len the length of the supplied object identifier + * @param ident points to the array of sub identifiers + * @param np points to the found object instance (return) + * @return pointer to the requested parent (!) node if success, NULL otherwise + */ +struct mib_node * +snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np) +{ + u8_t node_type, ext_level; + + ext_level = 0; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("node==%p *ident==%"S32_F"\n",(void*)node,*ident)); + while (node != NULL) + { + node_type = node->node_type; + if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA)) + { + struct mib_array_node *an; + u16_t i; + + if (ident_len > 0) + { + /* array node (internal ROM or RAM, fixed length) */ + an = (struct mib_array_node *)node; + i = 0; + while ((i < an->maxlength) && (an->objid[i] != *ident)) + { + i++; + } + if (i < an->maxlength) + { + /* found it, if available proceed to child, otherwise inspect leaf */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->objid[i],*ident)); + if (an->nptr[i] == NULL) + { + /* a scalar leaf OR table, + inspect remaining instance number / table index */ + np->ident_len = ident_len; + np->ident = ident; + return (struct mib_node*)an; + } + else + { + /* follow next child pointer */ + ident++; + ident_len--; + node = an->nptr[i]; + } + } + else + { + /* search failed, identifier mismatch (nosuchname) */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("an search failed *ident==%"S32_F"\n",*ident)); + return NULL; + } + } + else + { + /* search failed, short object identifier (nosuchname) */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("an search failed, short object identifier\n")); + return NULL; + } + } + else if(node_type == MIB_NODE_LR) + { + struct mib_list_rootnode *lrn; + struct mib_list_node *ln; + + if (ident_len > 0) + { + /* list root node (internal 'RAM', variable length) */ + lrn = (struct mib_list_rootnode *)node; + ln = lrn->head; + /* iterate over list, head to tail */ + while ((ln != NULL) && (ln->objid != *ident)) + { + ln = ln->next; + } + if (ln != NULL) + { + /* found it, proceed to child */; + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln->objid==%"S32_F" *ident==%"S32_F"\n",ln->objid,*ident)); + if (ln->nptr == NULL) + { + np->ident_len = ident_len; + np->ident = ident; + return (struct mib_node*)lrn; + } + else + { + /* follow next child pointer */ + ident_len--; + ident++; + node = ln->nptr; + } + } + else + { + /* search failed */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln search failed *ident==%"S32_F"\n",*ident)); + return NULL; + } + } + else + { + /* search failed, short object identifier (nosuchname) */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln search failed, short object identifier\n")); + return NULL; + } + } + else if(node_type == MIB_NODE_EX) + { + struct mib_external_node *en; + u16_t i, len; + + if (ident_len > 0) + { + /* external node (addressing and access via functions) */ + en = (struct mib_external_node *)node; + + i = 0; + len = en->level_length(en->addr_inf,ext_level); + while ((i < len) && (en->ident_cmp(en->addr_inf,ext_level,i,*ident) != 0)) + { + i++; + } + if (i < len) + { + s32_t debug_id; + + en->get_objid(en->addr_inf,ext_level,i,&debug_id); + LWIP_DEBUGF(SNMP_MIB_DEBUG,("en->objid==%"S32_F" *ident==%"S32_F"\n",debug_id,*ident)); + if ((ext_level + 1) == en->tree_levels) + { + np->ident_len = ident_len; + np->ident = ident; + return (struct mib_node*)en; + } + else + { + /* found it, proceed to child */ + ident_len--; + ident++; + ext_level++; + } + } + else + { + /* search failed */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("en search failed *ident==%"S32_F"\n",*ident)); + return NULL; + } + } + else + { + /* search failed, short object identifier (nosuchname) */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("en search failed, short object identifier\n")); + return NULL; + } + } + else if (node_type == MIB_NODE_SC) + { + mib_scalar_node *sn; + + sn = (mib_scalar_node *)node; + if ((ident_len == 1) && (*ident == 0)) + { + np->ident_len = ident_len; + np->ident = ident; + return (struct mib_node*)sn; + } + else + { + /* search failed, short object identifier (nosuchname) */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed, invalid object identifier length\n")); + return NULL; + } + } + else + { + /* unknown node_type */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed node_type %"U16_F" unkown\n",(u16_t)node_type)); + return NULL; + } + } + /* done, found nothing */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed node==%p\n",(void*)node)); + return NULL; +} + +/** + * Test table for presence of at least one table entry. + */ +static u8_t +empty_table(struct mib_node *node) +{ + u8_t node_type; + u8_t empty = 0; + + if (node != NULL) + { + node_type = node->node_type; + if (node_type == MIB_NODE_LR) + { + struct mib_list_rootnode *lrn; + lrn = (struct mib_list_rootnode *)node; + if ((lrn->count == 0) || (lrn->head == NULL)) + { + empty = 1; + } + } + else if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA)) + { + struct mib_array_node *an; + an = (struct mib_array_node *)node; + if ((an->maxlength == 0) || (an->nptr == NULL)) + { + empty = 1; + } + } + else if (node_type == MIB_NODE_EX) + { + struct mib_external_node *en; + en = (struct mib_external_node *)node; + if (en->tree_levels == 0) + { + empty = 1; + } + } + } + return empty; +} + +/** + * Tree expansion. + */ +struct mib_node * +snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret) +{ + u8_t node_type, ext_level, climb_tree; + + ext_level = 0; + /* reset node stack */ + node_stack_cnt = 0; + while (node != NULL) + { + climb_tree = 0; + node_type = node->node_type; + if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA)) + { + struct mib_array_node *an; + u16_t i; + + /* array node (internal ROM or RAM, fixed length) */ + an = (struct mib_array_node *)node; + if (ident_len > 0) + { + i = 0; + while ((i < an->maxlength) && (an->objid[i] < *ident)) + { + i++; + } + if (i < an->maxlength) + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->objid[i],*ident)); + /* add identifier to oidret */ + oidret->id[oidret->len] = an->objid[i]; + (oidret->len)++; + + if (an->nptr[i] == NULL) + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n")); + /* leaf node (e.g. in a fixed size table) */ + if (an->objid[i] > *ident) + { + return (struct mib_node*)an; + } + else if ((i + 1) < an->maxlength) + { + /* an->objid[i] == *ident */ + (oidret->len)--; + oidret->id[oidret->len] = an->objid[i + 1]; + (oidret->len)++; + return (struct mib_node*)an; + } + else + { + /* (i + 1) == an->maxlength */ + (oidret->len)--; + climb_tree = 1; + } + } + else + { + u8_t j; + struct nse cur_node; + + LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n")); + /* non-leaf, store right child ptr and id */ + LWIP_ASSERT("i < 0xff", i < 0xff); + j = (u8_t)i + 1; + while ((j < an->maxlength) && (empty_table(an->nptr[j]))) + { + j++; + } + if (j < an->maxlength) + { + cur_node.r_ptr = an->nptr[j]; + cur_node.r_id = an->objid[j]; + cur_node.r_nl = 0; + } + else + { + cur_node.r_ptr = NULL; + } + push_node(&cur_node); + if (an->objid[i] == *ident) + { + ident_len--; + ident++; + } + else + { + /* an->objid[i] < *ident */ + ident_len = 0; + } + /* follow next child pointer */ + node = an->nptr[i]; + } + } + else + { + /* i == an->maxlength */ + climb_tree = 1; + } + } + else + { + u8_t j; + /* ident_len == 0, complete with leftmost '.thing' */ + j = 0; + while ((j < an->maxlength) && empty_table(an->nptr[j])) + { + j++; + } + if (j < an->maxlength) + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("left an->objid[j]==%"S32_F"\n",an->objid[j])); + oidret->id[oidret->len] = an->objid[j]; + (oidret->len)++; + if (an->nptr[j] == NULL) + { + /* leaf node */ + return (struct mib_node*)an; + } + else + { + /* no leaf, continue */ + node = an->nptr[j]; + } + } + else + { + /* j == an->maxlength */ + climb_tree = 1; + } + } + } + else if(node_type == MIB_NODE_LR) + { + struct mib_list_rootnode *lrn; + struct mib_list_node *ln; + + /* list root node (internal 'RAM', variable length) */ + lrn = (struct mib_list_rootnode *)node; + if (ident_len > 0) + { + ln = lrn->head; + /* iterate over list, head to tail */ + while ((ln != NULL) && (ln->objid < *ident)) + { + ln = ln->next; + } + if (ln != NULL) + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln->objid==%"S32_F" *ident==%"S32_F"\n",ln->objid,*ident)); + oidret->id[oidret->len] = ln->objid; + (oidret->len)++; + if (ln->nptr == NULL) + { + /* leaf node */ + if (ln->objid > *ident) + { + return (struct mib_node*)lrn; + } + else if (ln->next != NULL) + { + /* ln->objid == *ident */ + (oidret->len)--; + oidret->id[oidret->len] = ln->next->objid; + (oidret->len)++; + return (struct mib_node*)lrn; + } + else + { + /* ln->next == NULL */ + (oidret->len)--; + climb_tree = 1; + } + } + else + { + struct mib_list_node *jn; + struct nse cur_node; + + /* non-leaf, store right child ptr and id */ + jn = ln->next; + while ((jn != NULL) && empty_table(jn->nptr)) + { + jn = jn->next; + } + if (jn != NULL) + { + cur_node.r_ptr = jn->nptr; + cur_node.r_id = jn->objid; + cur_node.r_nl = 0; + } + else + { + cur_node.r_ptr = NULL; + } + push_node(&cur_node); + if (ln->objid == *ident) + { + ident_len--; + ident++; + } + else + { + /* ln->objid < *ident */ + ident_len = 0; + } + /* follow next child pointer */ + node = ln->nptr; + } + + } + else + { + /* ln == NULL */ + climb_tree = 1; + } + } + else + { + struct mib_list_node *jn; + /* ident_len == 0, complete with leftmost '.thing' */ + jn = lrn->head; + while ((jn != NULL) && empty_table(jn->nptr)) + { + jn = jn->next; + } + if (jn != NULL) + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("left jn->objid==%"S32_F"\n",jn->objid)); + oidret->id[oidret->len] = jn->objid; + (oidret->len)++; + if (jn->nptr == NULL) + { + /* leaf node */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("jn->nptr == NULL\n")); + return (struct mib_node*)lrn; + } + else + { + /* no leaf, continue */ + node = jn->nptr; + } + } + else + { + /* jn == NULL */ + climb_tree = 1; + } + } + } + else if(node_type == MIB_NODE_EX) + { + struct mib_external_node *en; + s32_t ex_id; + + /* external node (addressing and access via functions) */ + en = (struct mib_external_node *)node; + if (ident_len > 0) + { + u16_t i, len; + + i = 0; + len = en->level_length(en->addr_inf,ext_level); + while ((i < len) && (en->ident_cmp(en->addr_inf,ext_level,i,*ident) < 0)) + { + i++; + } + if (i < len) + { + /* add identifier to oidret */ + en->get_objid(en->addr_inf,ext_level,i,&ex_id); + LWIP_DEBUGF(SNMP_MIB_DEBUG,("en->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,ex_id,*ident)); + oidret->id[oidret->len] = ex_id; + (oidret->len)++; + + if ((ext_level + 1) == en->tree_levels) + { + LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n")); + /* leaf node */ + if (ex_id > *ident) + { + return (struct mib_node*)en; + } + else if ((i + 1) < len) + { + /* ex_id == *ident */ + en->get_objid(en->addr_inf,ext_level,i + 1,&ex_id); + (oidret->len)--; + oidret->id[oidret->len] = ex_id; + (oidret->len)++; + return (struct mib_node*)en; + } + else + { + /* (i + 1) == len */ + (oidret->len)--; + climb_tree = 1; + } + } + else + { + u8_t j; + struct nse cur_node; + + LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n")); + /* non-leaf, store right child ptr and id */ + LWIP_ASSERT("i < 0xff", i < 0xff); + j = (u8_t)i + 1; + if (j < len) + { + /* right node is the current external node */ + cur_node.r_ptr = node; + en->get_objid(en->addr_inf,ext_level,j,&cur_node.r_id); + cur_node.r_nl = ext_level + 1; + } + else + { + cur_node.r_ptr = NULL; + } + push_node(&cur_node); + if (en->ident_cmp(en->addr_inf,ext_level,i,*ident) == 0) + { + ident_len--; + ident++; + } + else + { + /* external id < *ident */ + ident_len = 0; + } + /* proceed to child */ + ext_level++; + } + } + else + { + /* i == len (en->level_len()) */ + climb_tree = 1; + } + } + else + { + /* ident_len == 0, complete with leftmost '.thing' */ + en->get_objid(en->addr_inf,ext_level,0,&ex_id); + LWIP_DEBUGF(SNMP_MIB_DEBUG,("left en->objid==%"S32_F"\n",ex_id)); + oidret->id[oidret->len] = ex_id; + (oidret->len)++; + if ((ext_level + 1) == en->tree_levels) + { + /* leaf node */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("(ext_level + 1) == en->tree_levels\n")); + return (struct mib_node*)en; + } + else + { + /* no leaf, proceed to child */ + ext_level++; + } + } + } + else if(node_type == MIB_NODE_SC) + { + mib_scalar_node *sn; + + /* scalar node */ + sn = (mib_scalar_node *)node; + if (ident_len > 0) + { + /* at .0 */ + climb_tree = 1; + } + else + { + /* ident_len == 0, complete object identifier */ + oidret->id[oidret->len] = 0; + (oidret->len)++; + /* leaf node */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("completed scalar leaf\n")); + return (struct mib_node*)sn; + } + } + else + { + /* unknown/unhandled node_type */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand failed node_type %"U16_F" unkown\n",(u16_t)node_type)); + return NULL; + } + + if (climb_tree) + { + struct nse child; + + /* find right child ptr */ + child.r_ptr = NULL; + child.r_id = 0; + child.r_nl = 0; + while ((node_stack_cnt > 0) && (child.r_ptr == NULL)) + { + pop_node(&child); + /* trim returned oid */ + (oidret->len)--; + } + if (child.r_ptr != NULL) + { + /* incoming ident is useless beyond this point */ + ident_len = 0; + oidret->id[oidret->len] = child.r_id; + oidret->len++; + node = child.r_ptr; + ext_level = child.r_nl; + } + else + { + /* tree ends here ... */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand failed, tree ends here\n")); + return NULL; + } + } + } + /* done, found nothing */ + LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand failed node==%p\n",(void*)node)); + return NULL; +} + +/** + * Test object identifier for the iso.org.dod.internet prefix. + * + * @param ident_len the length of the supplied object identifier + * @param ident points to the array of sub identifiers + * @return 1 if it matches, 0 otherwise + */ +u8_t +snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident) +{ + if ((ident_len > 3) && + (ident[0] == 1) && (ident[1] == 3) && + (ident[2] == 6) && (ident[3] == 1)) + { + return 1; + } + else + { + return 0; + } +} + +/** + * Expands object identifier to the iso.org.dod.internet + * prefix for use in getnext operation. + * + * @param ident_len the length of the supplied object identifier + * @param ident points to the array of sub identifiers + * @param oidret points to returned expanded object identifier + * @return 1 if it matches, 0 otherwise + * + * @note ident_len 0 is allowed, expanding to the first known object id!! + */ +u8_t +snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret) +{ + const s32_t *prefix_ptr; + s32_t *ret_ptr; + u8_t i; + + i = 0; + prefix_ptr = &prefix[0]; + ret_ptr = &oidret->id[0]; + ident_len = ((ident_len < 4)?ident_len:4); + while ((i < ident_len) && ((*ident) <= (*prefix_ptr))) + { + *ret_ptr++ = *prefix_ptr++; + ident++; + i++; + } + if (i == ident_len) + { + /* match, complete missing bits */ + while (i < 4) + { + *ret_ptr++ = *prefix_ptr++; + i++; + } + oidret->len = i; + return 1; + } + else + { + /* i != ident_len */ + return 0; + } +} + +#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/msg_in.c b/user/mpy/lib/lwip/src/core/snmp/msg_in.c new file mode 100644 index 0000000..be940c6 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/snmp/msg_in.c @@ -0,0 +1,1453 @@ +/** + * @file + * SNMP input message processing (RFC1157). + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/snmp.h" +#include "lwip/snmp_asn1.h" +#include "lwip/snmp_msg.h" +#include "lwip/snmp_structs.h" +#include "lwip/ip_addr.h" +#include "lwip/memp.h" +#include "lwip/udp.h" +#include "lwip/stats.h" + +#include + +/* public (non-static) constants */ +/** SNMP v1 == 0 */ +const s32_t snmp_version = 0; +/** default SNMP community string */ +const char snmp_publiccommunity[7] = "public"; + +/* statically allocated buffers for SNMP_CONCURRENT_REQUESTS */ +struct snmp_msg_pstat msg_input_list[SNMP_CONCURRENT_REQUESTS]; +/* UDP Protocol Control Block */ +struct udp_pcb *snmp1_pcb; + +static void snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); +static err_t snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat); +static err_t snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat); + + +/** + * Starts SNMP Agent. + * Allocates UDP pcb and binds it to IP_ADDR_ANY port 161. + */ +void +snmp_init(void) +{ + struct snmp_msg_pstat *msg_ps; + u8_t i; + + snmp1_pcb = udp_new(); + if (snmp1_pcb != NULL) + { + udp_recv(snmp1_pcb, snmp_recv, (void *)SNMP_IN_PORT); + udp_bind(snmp1_pcb, IP_ADDR_ANY, SNMP_IN_PORT); + } + msg_ps = &msg_input_list[0]; + for (i=0; istate = SNMP_MSG_EMPTY; + msg_ps->error_index = 0; + msg_ps->error_status = SNMP_ES_NOERROR; + msg_ps++; + } + trap_msg.pcb = snmp1_pcb; + +#ifdef SNMP_PRIVATE_MIB_INIT + /* If defined, this must be a function-like define to initialize the + * private MIB after the stack has been initialized. + * The private MIB can also be initialized in tcpip_callback (or after + * the stack is initialized), this define is only for convenience. */ + SNMP_PRIVATE_MIB_INIT(); +#endif /* SNMP_PRIVATE_MIB_INIT */ + + /* The coldstart trap will only be output + if our outgoing interface is up & configured */ + snmp_coldstart_trap(); +} + +static void +snmp_error_response(struct snmp_msg_pstat *msg_ps, u8_t error) +{ + /* move names back from outvb to invb */ + int v; + struct snmp_varbind *vbi = msg_ps->invb.head; + struct snmp_varbind *vbo = msg_ps->outvb.head; + for (v=0; vvb_idx; v++) { + vbi->ident_len = vbo->ident_len; + vbo->ident_len = 0; + vbi->ident = vbo->ident; + vbo->ident = NULL; + vbi = vbi->next; + vbo = vbo->next; + } + /* free outvb */ + snmp_varbind_list_free(&msg_ps->outvb); + /* we send invb back */ + msg_ps->outvb = msg_ps->invb; + msg_ps->invb.head = NULL; + msg_ps->invb.tail = NULL; + msg_ps->invb.count = 0; + msg_ps->error_status = error; + /* error index must be 0 for error too big */ + msg_ps->error_index = (error != SNMP_ES_TOOBIG) ? (1 + msg_ps->vb_idx) : 0; + snmp_send_response(msg_ps); + snmp_varbind_list_free(&msg_ps->outvb); + msg_ps->state = SNMP_MSG_EMPTY; +} + +static void +snmp_ok_response(struct snmp_msg_pstat *msg_ps) +{ + err_t err_ret; + + err_ret = snmp_send_response(msg_ps); + if (err_ret == ERR_MEM) + { + /* serious memory problem, can't return tooBig */ + } + else + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event = %"S32_F"\n",msg_ps->error_status)); + } + /* free varbinds (if available) */ + snmp_varbind_list_free(&msg_ps->invb); + snmp_varbind_list_free(&msg_ps->outvb); + msg_ps->state = SNMP_MSG_EMPTY; +} + +/** + * Service an internal or external event for SNMP GET. + * + * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) + * @param msg_ps points to the assosicated message process state + */ +static void +snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps) +{ + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_get_event: msg_ps->state==%"U16_F"\n",(u16_t)msg_ps->state)); + + if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF) + { + struct mib_external_node *en; + struct snmp_name_ptr np; + + /* get_object_def() answer*/ + en = msg_ps->ext_mib_node; + np = msg_ps->ext_name_ptr; + + /* translate answer into a known lifeform */ + en->get_object_def_a(request_id, np.ident_len, np.ident, &msg_ps->ext_object_def); + if ((msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) && + (msg_ps->ext_object_def.access & MIB_ACCESS_READ)) + { + msg_ps->state = SNMP_MSG_EXTERNAL_GET_VALUE; + en->get_value_q(request_id, &msg_ps->ext_object_def); + } + else + { + en->get_object_def_pc(request_id, np.ident_len, np.ident); + /* search failed, object id points to unknown object (nosuchname) */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + else if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_VALUE) + { + struct mib_external_node *en; + struct snmp_varbind *vb; + + /* get_value() answer */ + en = msg_ps->ext_mib_node; + + /* allocate output varbind */ + vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND); + if (vb != NULL) + { + vb->next = NULL; + vb->prev = NULL; + + /* move name from invb to outvb */ + vb->ident = msg_ps->vb_ptr->ident; + vb->ident_len = msg_ps->vb_ptr->ident_len; + /* ensure this memory is refereced once only */ + msg_ps->vb_ptr->ident = NULL; + msg_ps->vb_ptr->ident_len = 0; + + vb->value_type = msg_ps->ext_object_def.asn_type; + LWIP_ASSERT("invalid length", msg_ps->ext_object_def.v_len <= 0xff); + vb->value_len = (u8_t)msg_ps->ext_object_def.v_len; + if (vb->value_len > 0) + { + LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE); + vb->value = memp_malloc(MEMP_SNMP_VALUE); + if (vb->value != NULL) + { + en->get_value_a(request_id, &msg_ps->ext_object_def, vb->value_len, vb->value); + snmp_varbind_tail_add(&msg_ps->outvb, vb); + /* search again (if vb_idx < msg_ps->invb.count) */ + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + else + { + en->get_value_pc(request_id, &msg_ps->ext_object_def); + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: no variable space\n")); + msg_ps->vb_ptr->ident = vb->ident; + msg_ps->vb_ptr->ident_len = vb->ident_len; + memp_free(MEMP_SNMP_VARBIND, vb); + snmp_error_response(msg_ps,SNMP_ES_TOOBIG); + } + } + else + { + /* vb->value_len == 0, empty value (e.g. empty string) */ + en->get_value_a(request_id, &msg_ps->ext_object_def, 0, NULL); + vb->value = NULL; + snmp_varbind_tail_add(&msg_ps->outvb, vb); + /* search again (if vb_idx < msg_ps->invb.count) */ + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + } + else + { + en->get_value_pc(request_id, &msg_ps->ext_object_def); + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: no outvb space\n")); + snmp_error_response(msg_ps,SNMP_ES_TOOBIG); + } + } + + while ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && + (msg_ps->vb_idx < msg_ps->invb.count)) + { + struct mib_node *mn; + struct snmp_name_ptr np; + + if (msg_ps->vb_idx == 0) + { + msg_ps->vb_ptr = msg_ps->invb.head; + } + else + { + msg_ps->vb_ptr = msg_ps->vb_ptr->next; + } + /** test object identifier for .iso.org.dod.internet prefix */ + if (snmp_iso_prefix_tst(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident)) + { + mn = snmp_search_tree((struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4, + msg_ps->vb_ptr->ident + 4, &np); + if (mn != NULL) + { + if (mn->node_type == MIB_NODE_EX) + { + /* external object */ + struct mib_external_node *en = (struct mib_external_node*)mn; + + msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF; + /* save en && args in msg_ps!! */ + msg_ps->ext_mib_node = en; + msg_ps->ext_name_ptr = np; + + en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident); + } + else + { + /* internal object */ + struct obj_def object_def; + + msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF; + mn->get_object_def(np.ident_len, np.ident, &object_def); + if ((object_def.instance != MIB_OBJECT_NONE) && + (object_def.access & MIB_ACCESS_READ)) + { + mn = mn; + } + else + { + /* search failed, object id points to unknown object (nosuchname) */ + mn = NULL; + } + if (mn != NULL) + { + struct snmp_varbind *vb; + + msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE; + /* allocate output varbind */ + vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND); + if (vb != NULL) + { + vb->next = NULL; + vb->prev = NULL; + + /* move name from invb to outvb */ + vb->ident = msg_ps->vb_ptr->ident; + vb->ident_len = msg_ps->vb_ptr->ident_len; + /* ensure this memory is refereced once only */ + msg_ps->vb_ptr->ident = NULL; + msg_ps->vb_ptr->ident_len = 0; + + vb->value_type = object_def.asn_type; + LWIP_ASSERT("invalid length", object_def.v_len <= 0xff); + vb->value_len = (u8_t)object_def.v_len; + if (vb->value_len > 0) + { + LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", + vb->value_len <= SNMP_MAX_VALUE_SIZE); + vb->value = memp_malloc(MEMP_SNMP_VALUE); + if (vb->value != NULL) + { + mn->get_value(&object_def, vb->value_len, vb->value); + snmp_varbind_tail_add(&msg_ps->outvb, vb); + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + else + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: couldn't allocate variable space\n")); + msg_ps->vb_ptr->ident = vb->ident; + msg_ps->vb_ptr->ident_len = vb->ident_len; + vb->ident = NULL; + vb->ident_len = 0; + memp_free(MEMP_SNMP_VARBIND, vb); + snmp_error_response(msg_ps,SNMP_ES_TOOBIG); + } + } + else + { + /* vb->value_len == 0, empty value (e.g. empty string) */ + vb->value = NULL; + snmp_varbind_tail_add(&msg_ps->outvb, vb); + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + } + else + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: couldn't allocate outvb space\n")); + snmp_error_response(msg_ps,SNMP_ES_TOOBIG); + } + } + } + } + } + else + { + mn = NULL; + } + if (mn == NULL) + { + /* mn == NULL, noSuchName */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + if ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && + (msg_ps->vb_idx == msg_ps->invb.count)) + { + snmp_ok_response(msg_ps); + } +} + +/** + * Service an internal or external event for SNMP GETNEXT. + * + * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) + * @param msg_ps points to the assosicated message process state + */ +static void +snmp_msg_getnext_event(u8_t request_id, struct snmp_msg_pstat *msg_ps) +{ + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_getnext_event: msg_ps->state==%"U16_F"\n",(u16_t)msg_ps->state)); + + if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF) + { + struct mib_external_node *en; + + /* get_object_def() answer*/ + en = msg_ps->ext_mib_node; + + /* translate answer into a known lifeform */ + en->get_object_def_a(request_id, 1, &msg_ps->ext_oid.id[msg_ps->ext_oid.len - 1], &msg_ps->ext_object_def); + if (msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) + { + msg_ps->state = SNMP_MSG_EXTERNAL_GET_VALUE; + en->get_value_q(request_id, &msg_ps->ext_object_def); + } + else + { + en->get_object_def_pc(request_id, 1, &msg_ps->ext_oid.id[msg_ps->ext_oid.len - 1]); + /* search failed, object id points to unknown object (nosuchname) */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + else if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_VALUE) + { + struct mib_external_node *en; + struct snmp_varbind *vb; + + /* get_value() answer */ + en = msg_ps->ext_mib_node; + + LWIP_ASSERT("invalid length", msg_ps->ext_object_def.v_len <= 0xff); + vb = snmp_varbind_alloc(&msg_ps->ext_oid, + msg_ps->ext_object_def.asn_type, + (u8_t)msg_ps->ext_object_def.v_len); + if (vb != NULL) + { + en->get_value_a(request_id, &msg_ps->ext_object_def, vb->value_len, vb->value); + snmp_varbind_tail_add(&msg_ps->outvb, vb); + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + else + { + en->get_value_pc(request_id, &msg_ps->ext_object_def); + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_getnext_event: couldn't allocate outvb space\n")); + snmp_error_response(msg_ps,SNMP_ES_TOOBIG); + } + } + + while ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && + (msg_ps->vb_idx < msg_ps->invb.count)) + { + struct mib_node *mn; + struct snmp_obj_id oid; + + if (msg_ps->vb_idx == 0) + { + msg_ps->vb_ptr = msg_ps->invb.head; + } + else + { + msg_ps->vb_ptr = msg_ps->vb_ptr->next; + } + if (snmp_iso_prefix_expand(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident, &oid)) + { + if (msg_ps->vb_ptr->ident_len > 3) + { + /* can offset ident_len and ident */ + mn = snmp_expand_tree((struct mib_node*)&internet, + msg_ps->vb_ptr->ident_len - 4, + msg_ps->vb_ptr->ident + 4, &oid); + } + else + { + /* can't offset ident_len -4, ident + 4 */ + mn = snmp_expand_tree((struct mib_node*)&internet, 0, NULL, &oid); + } + } + else + { + mn = NULL; + } + if (mn != NULL) + { + if (mn->node_type == MIB_NODE_EX) + { + /* external object */ + struct mib_external_node *en = (struct mib_external_node*)mn; + + msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF; + /* save en && args in msg_ps!! */ + msg_ps->ext_mib_node = en; + msg_ps->ext_oid = oid; + + en->get_object_def_q(en->addr_inf, request_id, 1, &oid.id[oid.len - 1]); + } + else + { + /* internal object */ + struct obj_def object_def; + struct snmp_varbind *vb; + + msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF; + mn->get_object_def(1, &oid.id[oid.len - 1], &object_def); + + LWIP_ASSERT("invalid length", object_def.v_len <= 0xff); + vb = snmp_varbind_alloc(&oid, object_def.asn_type, (u8_t)object_def.v_len); + if (vb != NULL) + { + msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE; + mn->get_value(&object_def, object_def.v_len, vb->value); + snmp_varbind_tail_add(&msg_ps->outvb, vb); + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + else + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv couldn't allocate outvb space\n")); + snmp_error_response(msg_ps,SNMP_ES_TOOBIG); + } + } + } + if (mn == NULL) + { + /* mn == NULL, noSuchName */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + if ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && + (msg_ps->vb_idx == msg_ps->invb.count)) + { + snmp_ok_response(msg_ps); + } +} + +/** + * Service an internal or external event for SNMP SET. + * + * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) + * @param msg_ps points to the assosicated message process state + */ +static void +snmp_msg_set_event(u8_t request_id, struct snmp_msg_pstat *msg_ps) +{ + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_set_event: msg_ps->state==%"U16_F"\n",(u16_t)msg_ps->state)); + + if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF) + { + struct mib_external_node *en; + struct snmp_name_ptr np; + + /* get_object_def() answer*/ + en = msg_ps->ext_mib_node; + np = msg_ps->ext_name_ptr; + + /* translate answer into a known lifeform */ + en->get_object_def_a(request_id, np.ident_len, np.ident, &msg_ps->ext_object_def); + if (msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) + { + msg_ps->state = SNMP_MSG_EXTERNAL_SET_TEST; + en->set_test_q(request_id, &msg_ps->ext_object_def); + } + else + { + en->get_object_def_pc(request_id, np.ident_len, np.ident); + /* search failed, object id points to unknown object (nosuchname) */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + else if (msg_ps->state == SNMP_MSG_EXTERNAL_SET_TEST) + { + struct mib_external_node *en; + + /* set_test() answer*/ + en = msg_ps->ext_mib_node; + + if (msg_ps->ext_object_def.access & MIB_ACCESS_WRITE) + { + if ((msg_ps->ext_object_def.asn_type == msg_ps->vb_ptr->value_type) && + (en->set_test_a(request_id,&msg_ps->ext_object_def, + msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value) != 0)) + { + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + else + { + en->set_test_pc(request_id,&msg_ps->ext_object_def); + /* bad value */ + snmp_error_response(msg_ps,SNMP_ES_BADVALUE); + } + } + else + { + en->set_test_pc(request_id,&msg_ps->ext_object_def); + /* object not available for set */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + else if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF_S) + { + struct mib_external_node *en; + struct snmp_name_ptr np; + + /* get_object_def() answer*/ + en = msg_ps->ext_mib_node; + np = msg_ps->ext_name_ptr; + + /* translate answer into a known lifeform */ + en->get_object_def_a(request_id, np.ident_len, np.ident, &msg_ps->ext_object_def); + if (msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) + { + msg_ps->state = SNMP_MSG_EXTERNAL_SET_VALUE; + en->set_value_q(request_id, &msg_ps->ext_object_def, + msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value); + } + else + { + en->get_object_def_pc(request_id, np.ident_len, np.ident); + /* set_value failed, object has disappeared for some odd reason?? */ + snmp_error_response(msg_ps,SNMP_ES_GENERROR); + } + } + else if (msg_ps->state == SNMP_MSG_EXTERNAL_SET_VALUE) + { + struct mib_external_node *en; + + /** set_value_a() */ + en = msg_ps->ext_mib_node; + en->set_value_a(request_id, &msg_ps->ext_object_def, + msg_ps->vb_ptr->value_len, msg_ps->vb_ptr->value); + + /** @todo use set_value_pc() if toobig */ + msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE; + msg_ps->vb_idx += 1; + } + + /* test all values before setting */ + while ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && + (msg_ps->vb_idx < msg_ps->invb.count)) + { + struct mib_node *mn; + struct snmp_name_ptr np; + + if (msg_ps->vb_idx == 0) + { + msg_ps->vb_ptr = msg_ps->invb.head; + } + else + { + msg_ps->vb_ptr = msg_ps->vb_ptr->next; + } + /** test object identifier for .iso.org.dod.internet prefix */ + if (snmp_iso_prefix_tst(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident)) + { + mn = snmp_search_tree((struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4, + msg_ps->vb_ptr->ident + 4, &np); + if (mn != NULL) + { + if (mn->node_type == MIB_NODE_EX) + { + /* external object */ + struct mib_external_node *en = (struct mib_external_node*)mn; + + msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF; + /* save en && args in msg_ps!! */ + msg_ps->ext_mib_node = en; + msg_ps->ext_name_ptr = np; + + en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident); + } + else + { + /* internal object */ + struct obj_def object_def; + + msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF; + mn->get_object_def(np.ident_len, np.ident, &object_def); + if (object_def.instance != MIB_OBJECT_NONE) + { + mn = mn; + } + else + { + /* search failed, object id points to unknown object (nosuchname) */ + mn = NULL; + } + if (mn != NULL) + { + msg_ps->state = SNMP_MSG_INTERNAL_SET_TEST; + + if (object_def.access & MIB_ACCESS_WRITE) + { + if ((object_def.asn_type == msg_ps->vb_ptr->value_type) && + (mn->set_test(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value) != 0)) + { + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + msg_ps->vb_idx += 1; + } + else + { + /* bad value */ + snmp_error_response(msg_ps,SNMP_ES_BADVALUE); + } + } + else + { + /* object not available for set */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + } + } + } + else + { + mn = NULL; + } + if (mn == NULL) + { + /* mn == NULL, noSuchName */ + snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); + } + } + + if ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && + (msg_ps->vb_idx == msg_ps->invb.count)) + { + msg_ps->vb_idx = 0; + msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE; + } + + /* set all values "atomically" (be as "atomic" as possible) */ + while ((msg_ps->state == SNMP_MSG_INTERNAL_SET_VALUE) && + (msg_ps->vb_idx < msg_ps->invb.count)) + { + struct mib_node *mn; + struct snmp_name_ptr np; + + if (msg_ps->vb_idx == 0) + { + msg_ps->vb_ptr = msg_ps->invb.head; + } + else + { + msg_ps->vb_ptr = msg_ps->vb_ptr->next; + } + /* skip iso prefix test, was done previously while settesting() */ + mn = snmp_search_tree((struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4, + msg_ps->vb_ptr->ident + 4, &np); + /* check if object is still available + (e.g. external hot-plug thingy present?) */ + if (mn != NULL) + { + if (mn->node_type == MIB_NODE_EX) + { + /* external object */ + struct mib_external_node *en = (struct mib_external_node*)mn; + + msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF_S; + /* save en && args in msg_ps!! */ + msg_ps->ext_mib_node = en; + msg_ps->ext_name_ptr = np; + + en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident); + } + else + { + /* internal object */ + struct obj_def object_def; + + msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF_S; + mn->get_object_def(np.ident_len, np.ident, &object_def); + msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE; + mn->set_value(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value); + msg_ps->vb_idx += 1; + } + } + } + if ((msg_ps->state == SNMP_MSG_INTERNAL_SET_VALUE) && + (msg_ps->vb_idx == msg_ps->invb.count)) + { + /* simply echo the input if we can set it + @todo do we need to return the actual value? + e.g. if value is silently modified or behaves sticky? */ + msg_ps->outvb = msg_ps->invb; + msg_ps->invb.head = NULL; + msg_ps->invb.tail = NULL; + msg_ps->invb.count = 0; + snmp_ok_response(msg_ps); + } +} + + +/** + * Handle one internal or external event. + * Called for one async event. (recv external/private answer) + * + * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) + */ +void +snmp_msg_event(u8_t request_id) +{ + struct snmp_msg_pstat *msg_ps; + + if (request_id < SNMP_CONCURRENT_REQUESTS) + { + msg_ps = &msg_input_list[request_id]; + if (msg_ps->rt == SNMP_ASN1_PDU_GET_NEXT_REQ) + { + snmp_msg_getnext_event(request_id, msg_ps); + } + else if (msg_ps->rt == SNMP_ASN1_PDU_GET_REQ) + { + snmp_msg_get_event(request_id, msg_ps); + } + else if(msg_ps->rt == SNMP_ASN1_PDU_SET_REQ) + { + snmp_msg_set_event(request_id, msg_ps); + } + } +} + + +/* lwIP UDP receive callback function */ +static void +snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) +{ + struct snmp_msg_pstat *msg_ps; + u8_t req_idx; + err_t err_ret; + u16_t payload_len = p->tot_len; + u16_t payload_ofs = 0; + u16_t varbind_ofs = 0; + + /* suppress unused argument warning */ + LWIP_UNUSED_ARG(arg); + + /* traverse input message process list, look for SNMP_MSG_EMPTY */ + msg_ps = &msg_input_list[0]; + req_idx = 0; + while ((req_idx < SNMP_CONCURRENT_REQUESTS) && (msg_ps->state != SNMP_MSG_EMPTY)) + { + req_idx++; + msg_ps++; + } + if (req_idx == SNMP_CONCURRENT_REQUESTS) + { + /* exceeding number of concurrent requests */ + pbuf_free(p); + return; + } + + /* accepting request */ + snmp_inc_snmpinpkts(); + /* record used 'protocol control block' */ + msg_ps->pcb = pcb; + /* source address (network order) */ + msg_ps->sip = *addr; + /* source port (host order (lwIP oddity)) */ + msg_ps->sp = port; + + /* check total length, version, community, pdu type */ + err_ret = snmp_pdu_header_check(p, payload_ofs, payload_len, &varbind_ofs, msg_ps); + /* Only accept requests and requests without error (be robust) */ + /* Reject response and trap headers or error requests as input! */ + if ((err_ret != ERR_OK) || + ((msg_ps->rt != SNMP_ASN1_PDU_GET_REQ) && + (msg_ps->rt != SNMP_ASN1_PDU_GET_NEXT_REQ) && + (msg_ps->rt != SNMP_ASN1_PDU_SET_REQ)) || + ((msg_ps->error_status != SNMP_ES_NOERROR) || + (msg_ps->error_index != 0)) ) + { + /* header check failed drop request silently, do not return error! */ + pbuf_free(p); + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_header_check() failed\n")); + return; + } + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv ok, community %s\n", msg_ps->community)); + + /* Builds a list of variable bindings. Copy the varbinds from the pbuf + chain to glue them when these are divided over two or more pbuf's. */ + err_ret = snmp_pdu_dec_varbindlist(p, varbind_ofs, &varbind_ofs, msg_ps); + /* we've decoded the incoming message, release input msg now */ + pbuf_free(p); + if ((err_ret != ERR_OK) || (msg_ps->invb.count == 0)) + { + /* varbind-list decode failed, or varbind list empty. + drop request silently, do not return error! + (errors are only returned for a specific varbind failure) */ + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_dec_varbindlist() failed\n")); + return; + } + + msg_ps->error_status = SNMP_ES_NOERROR; + msg_ps->error_index = 0; + /* find object for each variable binding */ + msg_ps->state = SNMP_MSG_SEARCH_OBJ; + /* first variable binding from list to inspect */ + msg_ps->vb_idx = 0; + + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv varbind cnt=%"U16_F"\n",(u16_t)msg_ps->invb.count)); + + /* handle input event and as much objects as possible in one go */ + snmp_msg_event(req_idx); +} + +/** + * Checks and decodes incoming SNMP message header, logs header errors. + * + * @param p points to pbuf chain of SNMP message (UDP payload) + * @param ofs points to first octet of SNMP message + * @param pdu_len the length of the UDP payload + * @param ofs_ret returns the ofset of the variable bindings + * @param m_stat points to the current message request state return + * @return + * - ERR_OK SNMP header is sane and accepted + * - ERR_ARG SNMP header is either malformed or rejected + */ +static err_t +snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat) +{ + err_t derr; + u16_t len, ofs_base; + u8_t len_octets; + u8_t type; + s32_t version; + + ofs_base = ofs; + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || + (pdu_len != (1 + len_octets + len)) || + (type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ))) + { + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + ofs += (1 + len_octets); + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) + { + /* can't decode or no integer (version) */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &version); + if (derr != ERR_OK) + { + /* can't decode */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + if (version != 0) + { + /* not version 1 */ + snmp_inc_snmpinbadversions(); + return ERR_ARG; + } + ofs += (1 + len_octets + len); + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR))) + { + /* can't decode or no octet string (community) */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, SNMP_COMMUNITY_STR_LEN, m_stat->community); + if (derr != ERR_OK) + { + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + /* add zero terminator */ + len = ((len < (SNMP_COMMUNITY_STR_LEN))?(len):(SNMP_COMMUNITY_STR_LEN)); + m_stat->community[len] = 0; + m_stat->com_strlen = (u8_t)len; + if (strncmp(snmp_publiccommunity, (const char*)m_stat->community, SNMP_COMMUNITY_STR_LEN) != 0) + { + /** @todo: move this if we need to check more names */ + snmp_inc_snmpinbadcommunitynames(); + snmp_authfail_trap(); + return ERR_ARG; + } + ofs += (1 + len_octets + len); + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if (derr != ERR_OK) + { + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + switch(type) + { + case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_REQ): + /* GetRequest PDU */ + snmp_inc_snmpingetrequests(); + derr = ERR_OK; + break; + case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_NEXT_REQ): + /* GetNextRequest PDU */ + snmp_inc_snmpingetnexts(); + derr = ERR_OK; + break; + case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_RESP): + /* GetResponse PDU */ + snmp_inc_snmpingetresponses(); + derr = ERR_ARG; + break; + case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_SET_REQ): + /* SetRequest PDU */ + snmp_inc_snmpinsetrequests(); + derr = ERR_OK; + break; + case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_TRAP): + /* Trap PDU */ + snmp_inc_snmpintraps(); + derr = ERR_ARG; + break; + default: + snmp_inc_snmpinasnparseerrs(); + derr = ERR_ARG; + break; + } + if (derr != ERR_OK) + { + /* unsupported input PDU for this agent (no parse error) */ + return ERR_ARG; + } + m_stat->rt = type & 0x1F; + ofs += (1 + len_octets); + if (len != (pdu_len - (ofs - ofs_base))) + { + /* decoded PDU length does not equal actual payload length */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) + { + /* can't decode or no integer (request ID) */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->rid); + if (derr != ERR_OK) + { + /* can't decode */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + ofs += (1 + len_octets + len); + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) + { + /* can't decode or no integer (error-status) */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + /* must be noError (0) for incoming requests. + log errors for mib-2 completeness and for debug purposes */ + derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->error_status); + if (derr != ERR_OK) + { + /* can't decode */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + switch (m_stat->error_status) + { + case SNMP_ES_TOOBIG: + snmp_inc_snmpintoobigs(); + break; + case SNMP_ES_NOSUCHNAME: + snmp_inc_snmpinnosuchnames(); + break; + case SNMP_ES_BADVALUE: + snmp_inc_snmpinbadvalues(); + break; + case SNMP_ES_READONLY: + snmp_inc_snmpinreadonlys(); + break; + case SNMP_ES_GENERROR: + snmp_inc_snmpingenerrs(); + break; + } + ofs += (1 + len_octets + len); + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) + { + /* can't decode or no integer (error-index) */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + /* must be 0 for incoming requests. + decode anyway to catch bad integers (and dirty tricks) */ + derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->error_index); + if (derr != ERR_OK) + { + /* can't decode */ + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + ofs += (1 + len_octets + len); + *ofs_ret = ofs; + return ERR_OK; +} + +static err_t +snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat) +{ + err_t derr; + u16_t len, vb_len; + u8_t len_octets; + u8_t type; + + /* variable binding list */ + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &vb_len); + if ((derr != ERR_OK) || + (type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ))) + { + snmp_inc_snmpinasnparseerrs(); + return ERR_ARG; + } + ofs += (1 + len_octets); + + /* start with empty list */ + m_stat->invb.count = 0; + m_stat->invb.head = NULL; + m_stat->invb.tail = NULL; + + while (vb_len > 0) + { + struct snmp_obj_id oid, oid_value; + struct snmp_varbind *vb; + + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || + (type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)) || + (len == 0) || (len > vb_len)) + { + snmp_inc_snmpinasnparseerrs(); + /* free varbinds (if available) */ + snmp_varbind_list_free(&m_stat->invb); + return ERR_ARG; + } + ofs += (1 + len_octets); + vb_len -= (1 + len_octets); + + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID))) + { + /* can't decode object name length */ + snmp_inc_snmpinasnparseerrs(); + /* free varbinds (if available) */ + snmp_varbind_list_free(&m_stat->invb); + return ERR_ARG; + } + derr = snmp_asn1_dec_oid(p, ofs + 1 + len_octets, len, &oid); + if (derr != ERR_OK) + { + /* can't decode object name */ + snmp_inc_snmpinasnparseerrs(); + /* free varbinds (if available) */ + snmp_varbind_list_free(&m_stat->invb); + return ERR_ARG; + } + ofs += (1 + len_octets + len); + vb_len -= (1 + len_octets + len); + + snmp_asn1_dec_type(p, ofs, &type); + derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); + if (derr != ERR_OK) + { + /* can't decode object value length */ + snmp_inc_snmpinasnparseerrs(); + /* free varbinds (if available) */ + snmp_varbind_list_free(&m_stat->invb); + return ERR_ARG; + } + + switch (type) + { + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG): + vb = snmp_varbind_alloc(&oid, type, sizeof(s32_t)); + if (vb != NULL) + { + s32_t *vptr = (s32_t*)vb->value; + + derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, vptr); + snmp_varbind_tail_add(&m_stat->invb, vb); + } + else + { + derr = ERR_ARG; + } + break; + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS): + vb = snmp_varbind_alloc(&oid, type, sizeof(u32_t)); + if (vb != NULL) + { + u32_t *vptr = (u32_t*)vb->value; + + derr = snmp_asn1_dec_u32t(p, ofs + 1 + len_octets, len, vptr); + snmp_varbind_tail_add(&m_stat->invb, vb); + } + else + { + derr = ERR_ARG; + } + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE): + LWIP_ASSERT("invalid length", len <= 0xff); + vb = snmp_varbind_alloc(&oid, type, (u8_t)len); + if (vb != NULL) + { + derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, vb->value_len, (u8_t*)vb->value); + snmp_varbind_tail_add(&m_stat->invb, vb); + } + else + { + derr = ERR_ARG; + } + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL): + vb = snmp_varbind_alloc(&oid, type, 0); + if (vb != NULL) + { + snmp_varbind_tail_add(&m_stat->invb, vb); + derr = ERR_OK; + } + else + { + derr = ERR_ARG; + } + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID): + derr = snmp_asn1_dec_oid(p, ofs + 1 + len_octets, len, &oid_value); + if (derr == ERR_OK) + { + vb = snmp_varbind_alloc(&oid, type, oid_value.len * sizeof(s32_t)); + if (vb != NULL) + { + u8_t i = oid_value.len; + s32_t *vptr = (s32_t*)vb->value; + + while(i > 0) + { + i--; + vptr[i] = oid_value.id[i]; + } + snmp_varbind_tail_add(&m_stat->invb, vb); + derr = ERR_OK; + } + else + { + derr = ERR_ARG; + } + } + break; + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR): + if (len == 4) + { + /* must be exactly 4 octets! */ + vb = snmp_varbind_alloc(&oid, type, 4); + if (vb != NULL) + { + derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, vb->value_len, (u8_t*)vb->value); + snmp_varbind_tail_add(&m_stat->invb, vb); + } + else + { + derr = ERR_ARG; + } + } + else + { + derr = ERR_ARG; + } + break; + default: + derr = ERR_ARG; + break; + } + if (derr != ERR_OK) + { + snmp_inc_snmpinasnparseerrs(); + /* free varbinds (if available) */ + snmp_varbind_list_free(&m_stat->invb); + return ERR_ARG; + } + ofs += (1 + len_octets + len); + vb_len -= (1 + len_octets + len); + } + + if (m_stat->rt == SNMP_ASN1_PDU_SET_REQ) + { + snmp_add_snmpintotalsetvars(m_stat->invb.count); + } + else + { + snmp_add_snmpintotalreqvars(m_stat->invb.count); + } + + *ofs_ret = ofs; + return ERR_OK; +} + +struct snmp_varbind* +snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len) +{ + struct snmp_varbind *vb; + + vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND); + if (vb != NULL) + { + u8_t i; + + vb->next = NULL; + vb->prev = NULL; + i = oid->len; + vb->ident_len = i; + if (i > 0) + { + LWIP_ASSERT("SNMP_MAX_TREE_DEPTH is configured too low", i <= SNMP_MAX_TREE_DEPTH); + /* allocate array of s32_t for our object identifier */ + vb->ident = (s32_t*)memp_malloc(MEMP_SNMP_VALUE); + if (vb->ident == NULL) + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate ident value space\n")); + memp_free(MEMP_SNMP_VARBIND, vb); + return NULL; + } + while(i > 0) + { + i--; + vb->ident[i] = oid->id[i]; + } + } + else + { + /* i == 0, pass zero length object identifier */ + vb->ident = NULL; + } + vb->value_type = type; + vb->value_len = len; + if (len > 0) + { + LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE); + /* allocate raw bytes for our object value */ + vb->value = memp_malloc(MEMP_SNMP_VALUE); + if (vb->value == NULL) + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate value space\n")); + if (vb->ident != NULL) + { + memp_free(MEMP_SNMP_VALUE, vb->ident); + } + memp_free(MEMP_SNMP_VARBIND, vb); + return NULL; + } + } + else + { + /* ASN1_NUL type, or zero length ASN1_OC_STR */ + vb->value = NULL; + } + } + else + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate varbind space\n")); + } + return vb; +} + +void +snmp_varbind_free(struct snmp_varbind *vb) +{ + if (vb->value != NULL ) + { + memp_free(MEMP_SNMP_VALUE, vb->value); + } + if (vb->ident != NULL ) + { + memp_free(MEMP_SNMP_VALUE, vb->ident); + } + memp_free(MEMP_SNMP_VARBIND, vb); +} + +void +snmp_varbind_list_free(struct snmp_varbind_root *root) +{ + struct snmp_varbind *vb, *prev; + + vb = root->tail; + while ( vb != NULL ) + { + prev = vb->prev; + snmp_varbind_free(vb); + vb = prev; + } + root->count = 0; + root->head = NULL; + root->tail = NULL; +} + +void +snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb) +{ + if (root->count == 0) + { + /* add first varbind to list */ + root->head = vb; + root->tail = vb; + } + else + { + /* add nth varbind to list tail */ + root->tail->next = vb; + vb->prev = root->tail; + root->tail = vb; + } + root->count += 1; +} + +struct snmp_varbind* +snmp_varbind_tail_remove(struct snmp_varbind_root *root) +{ + struct snmp_varbind* vb; + + if (root->count > 0) + { + /* remove tail varbind */ + vb = root->tail; + root->tail = vb->prev; + vb->prev->next = NULL; + root->count -= 1; + } + else + { + /* nothing to remove */ + vb = NULL; + } + return vb; +} + +#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/msg_out.c b/user/mpy/lib/lwip/src/core/snmp/msg_out.c new file mode 100644 index 0000000..485f076 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/snmp/msg_out.c @@ -0,0 +1,674 @@ +/** + * @file + * SNMP output message processing (RFC1157). + * + * Output responses and traps are build in two passes: + * + * Pass 0: iterate over the output message backwards to determine encoding lengths + * Pass 1: the actual forward encoding of internal form into ASN1 + * + * The single-pass encoding method described by Comer & Stevens + * requires extra buffer space and copying for reversal of the packet. + * The buffer requirement can be prohibitively large for big payloads + * (>= 484) therefore we use the two encoding passes. + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/udp.h" +#include "lwip/netif.h" +#include "lwip/snmp.h" +#include "lwip/snmp_asn1.h" +#include "lwip/snmp_msg.h" + +struct snmp_trap_dst +{ + /* destination IP address in network order */ + ip_addr_t dip; + /* set to 0 when disabled, >0 when enabled */ + u8_t enable; +}; +struct snmp_trap_dst trap_dst[SNMP_TRAP_DESTINATIONS]; + +/** TRAP message structure */ +struct snmp_msg_trap trap_msg; + +static u16_t snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len); +static u16_t snmp_trap_header_sum(struct snmp_msg_trap *m_trap, u16_t vb_len); +static u16_t snmp_varbind_list_sum(struct snmp_varbind_root *root); + +static u16_t snmp_resp_header_enc(struct snmp_msg_pstat *m_stat, struct pbuf *p); +static u16_t snmp_trap_header_enc(struct snmp_msg_trap *m_trap, struct pbuf *p); +static u16_t snmp_varbind_list_enc(struct snmp_varbind_root *root, struct pbuf *p, u16_t ofs); + +/** + * Sets enable switch for this trap destination. + * @param dst_idx index in 0 .. SNMP_TRAP_DESTINATIONS-1 + * @param enable switch if 0 destination is disabled >0 enabled. + */ +void +snmp_trap_dst_enable(u8_t dst_idx, u8_t enable) +{ + if (dst_idx < SNMP_TRAP_DESTINATIONS) + { + trap_dst[dst_idx].enable = enable; + } +} + +/** + * Sets IPv4 address for this trap destination. + * @param dst_idx index in 0 .. SNMP_TRAP_DESTINATIONS-1 + * @param dst IPv4 address in host order. + */ +void +snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst) +{ + if (dst_idx < SNMP_TRAP_DESTINATIONS) + { + ip_addr_set(&trap_dst[dst_idx].dip, dst); + } +} + +/** + * Sends a 'getresponse' message to the request originator. + * + * @param m_stat points to the current message request state source + * @return ERR_OK when success, ERR_MEM if we're out of memory + * + * @note the caller is responsible for filling in outvb in the m_stat + * and provide error-status and index (except for tooBig errors) ... + */ +err_t +snmp_send_response(struct snmp_msg_pstat *m_stat) +{ + struct snmp_varbind_root emptyvb = {NULL, NULL, 0, 0, 0}; + struct pbuf *p; + u16_t tot_len; + err_t err; + + /* pass 0, calculate length fields */ + tot_len = snmp_varbind_list_sum(&m_stat->outvb); + tot_len = snmp_resp_header_sum(m_stat, tot_len); + + /* try allocating pbuf(s) for complete response */ + p = pbuf_alloc(PBUF_TRANSPORT, tot_len, PBUF_POOL); + if (p == NULL) + { + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_snd_response() tooBig\n")); + + /* can't construct reply, return error-status tooBig */ + m_stat->error_status = SNMP_ES_TOOBIG; + m_stat->error_index = 0; + /* pass 0, recalculate lengths, for empty varbind-list */ + tot_len = snmp_varbind_list_sum(&emptyvb); + tot_len = snmp_resp_header_sum(m_stat, tot_len); + /* retry allocation once for header and empty varbind-list */ + p = pbuf_alloc(PBUF_TRANSPORT, tot_len, PBUF_POOL); + } + if (p != NULL) + { + /* first pbuf alloc try or retry alloc success */ + u16_t ofs; + + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_snd_response() p != NULL\n")); + + /* pass 1, size error, encode packet ino the pbuf(s) */ + ofs = snmp_resp_header_enc(m_stat, p); + snmp_varbind_list_enc(&m_stat->outvb, p, ofs); + + switch (m_stat->error_status) + { + case SNMP_ES_TOOBIG: + snmp_inc_snmpouttoobigs(); + break; + case SNMP_ES_NOSUCHNAME: + snmp_inc_snmpoutnosuchnames(); + break; + case SNMP_ES_BADVALUE: + snmp_inc_snmpoutbadvalues(); + break; + case SNMP_ES_GENERROR: + snmp_inc_snmpoutgenerrs(); + break; + } + snmp_inc_snmpoutgetresponses(); + snmp_inc_snmpoutpkts(); + + /** @todo do we need separate rx and tx pcbs for threaded case? */ + /** connect to the originating source */ + udp_connect(m_stat->pcb, &m_stat->sip, m_stat->sp); + err = udp_send(m_stat->pcb, p); + if (err == ERR_MEM) + { + /** @todo release some memory, retry and return tooBig? tooMuchHassle? */ + err = ERR_MEM; + } + else + { + err = ERR_OK; + } + /** disassociate remote address and port with this pcb */ + udp_disconnect(m_stat->pcb); + + pbuf_free(p); + LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_snd_response() done\n")); + return err; + } + else + { + /* first pbuf alloc try or retry alloc failed + very low on memory, couldn't return tooBig */ + return ERR_MEM; + } +} + + +/** + * Sends an generic or enterprise specific trap message. + * + * @param generic_trap is the trap code + * @param eoid points to enterprise object identifier + * @param specific_trap used for enterprise traps when generic_trap == 6 + * @return ERR_OK when success, ERR_MEM if we're out of memory + * + * @note the caller is responsible for filling in outvb in the trap_msg + * @note the use of the enterpise identifier field + * is per RFC1215. + * Use .iso.org.dod.internet.mgmt.mib-2.snmp for generic traps + * and .iso.org.dod.internet.private.enterprises.yourenterprise + * (sysObjectID) for specific traps. + */ +err_t +snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap) +{ + struct snmp_trap_dst *td; + struct netif *dst_if; + ip_addr_t dst_ip; + struct pbuf *p; + u16_t i,tot_len; + + for (i=0, td = &trap_dst[0]; ienable != 0) && !ip_addr_isany(&td->dip)) + { + /* network order trap destination */ + ip_addr_copy(trap_msg.dip, td->dip); + /* lookup current source address for this dst */ + dst_if = ip_route(&td->dip); + ip_addr_copy(dst_ip, dst_if->ip_addr); + /* @todo: what about IPv6? */ + trap_msg.sip_raw[0] = ip4_addr1(&dst_ip); + trap_msg.sip_raw[1] = ip4_addr2(&dst_ip); + trap_msg.sip_raw[2] = ip4_addr3(&dst_ip); + trap_msg.sip_raw[3] = ip4_addr4(&dst_ip); + trap_msg.gen_trap = generic_trap; + trap_msg.spc_trap = specific_trap; + if (generic_trap == SNMP_GENTRAP_ENTERPRISESPC) + { + /* enterprise-Specific trap */ + trap_msg.enterprise = eoid; + } + else + { + /* generic (MIB-II) trap */ + snmp_get_snmpgrpid_ptr(&trap_msg.enterprise); + } + snmp_get_sysuptime(&trap_msg.ts); + + /* pass 0, calculate length fields */ + tot_len = snmp_varbind_list_sum(&trap_msg.outvb); + tot_len = snmp_trap_header_sum(&trap_msg, tot_len); + + /* allocate pbuf(s) */ + p = pbuf_alloc(PBUF_TRANSPORT, tot_len, PBUF_POOL); + if (p != NULL) + { + u16_t ofs; + + /* pass 1, encode packet ino the pbuf(s) */ + ofs = snmp_trap_header_enc(&trap_msg, p); + snmp_varbind_list_enc(&trap_msg.outvb, p, ofs); + + snmp_inc_snmpouttraps(); + snmp_inc_snmpoutpkts(); + + /** send to the TRAP destination */ + udp_sendto(trap_msg.pcb, p, &trap_msg.dip, SNMP_TRAP_PORT); + + pbuf_free(p); + } + else + { + return ERR_MEM; + } + } + } + return ERR_OK; +} + +void +snmp_coldstart_trap(void) +{ + trap_msg.outvb.head = NULL; + trap_msg.outvb.tail = NULL; + trap_msg.outvb.count = 0; + snmp_send_trap(SNMP_GENTRAP_COLDSTART, NULL, 0); +} + +void +snmp_authfail_trap(void) +{ + u8_t enable; + snmp_get_snmpenableauthentraps(&enable); + if (enable == 1) + { + trap_msg.outvb.head = NULL; + trap_msg.outvb.tail = NULL; + trap_msg.outvb.count = 0; + snmp_send_trap(SNMP_GENTRAP_AUTHFAIL, NULL, 0); + } +} + +/** + * Sums response header field lengths from tail to head and + * returns resp_header_lengths for second encoding pass. + * + * @param vb_len varbind-list length + * @param rhl points to returned header lengths + * @return the required lenght for encoding the response header + */ +static u16_t +snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len) +{ + u16_t tot_len; + struct snmp_resp_header_lengths *rhl; + + rhl = &m_stat->rhl; + tot_len = vb_len; + snmp_asn1_enc_s32t_cnt(m_stat->error_index, &rhl->erridxlen); + snmp_asn1_enc_length_cnt(rhl->erridxlen, &rhl->erridxlenlen); + tot_len += 1 + rhl->erridxlenlen + rhl->erridxlen; + + snmp_asn1_enc_s32t_cnt(m_stat->error_status, &rhl->errstatlen); + snmp_asn1_enc_length_cnt(rhl->errstatlen, &rhl->errstatlenlen); + tot_len += 1 + rhl->errstatlenlen + rhl->errstatlen; + + snmp_asn1_enc_s32t_cnt(m_stat->rid, &rhl->ridlen); + snmp_asn1_enc_length_cnt(rhl->ridlen, &rhl->ridlenlen); + tot_len += 1 + rhl->ridlenlen + rhl->ridlen; + + rhl->pdulen = tot_len; + snmp_asn1_enc_length_cnt(rhl->pdulen, &rhl->pdulenlen); + tot_len += 1 + rhl->pdulenlen; + + rhl->comlen = m_stat->com_strlen; + snmp_asn1_enc_length_cnt(rhl->comlen, &rhl->comlenlen); + tot_len += 1 + rhl->comlenlen + rhl->comlen; + + snmp_asn1_enc_s32t_cnt(snmp_version, &rhl->verlen); + snmp_asn1_enc_length_cnt(rhl->verlen, &rhl->verlenlen); + tot_len += 1 + rhl->verlen + rhl->verlenlen; + + rhl->seqlen = tot_len; + snmp_asn1_enc_length_cnt(rhl->seqlen, &rhl->seqlenlen); + tot_len += 1 + rhl->seqlenlen; + + return tot_len; +} + +/** + * Sums trap header field lengths from tail to head and + * returns trap_header_lengths for second encoding pass. + * + * @param vb_len varbind-list length + * @param thl points to returned header lengths + * @return the required lenght for encoding the trap header + */ +static u16_t +snmp_trap_header_sum(struct snmp_msg_trap *m_trap, u16_t vb_len) +{ + u16_t tot_len; + struct snmp_trap_header_lengths *thl; + + thl = &m_trap->thl; + tot_len = vb_len; + + snmp_asn1_enc_u32t_cnt(m_trap->ts, &thl->tslen); + snmp_asn1_enc_length_cnt(thl->tslen, &thl->tslenlen); + tot_len += 1 + thl->tslen + thl->tslenlen; + + snmp_asn1_enc_s32t_cnt(m_trap->spc_trap, &thl->strplen); + snmp_asn1_enc_length_cnt(thl->strplen, &thl->strplenlen); + tot_len += 1 + thl->strplen + thl->strplenlen; + + snmp_asn1_enc_s32t_cnt(m_trap->gen_trap, &thl->gtrplen); + snmp_asn1_enc_length_cnt(thl->gtrplen, &thl->gtrplenlen); + tot_len += 1 + thl->gtrplen + thl->gtrplenlen; + + thl->aaddrlen = 4; + snmp_asn1_enc_length_cnt(thl->aaddrlen, &thl->aaddrlenlen); + tot_len += 1 + thl->aaddrlen + thl->aaddrlenlen; + + snmp_asn1_enc_oid_cnt(m_trap->enterprise->len, &m_trap->enterprise->id[0], &thl->eidlen); + snmp_asn1_enc_length_cnt(thl->eidlen, &thl->eidlenlen); + tot_len += 1 + thl->eidlen + thl->eidlenlen; + + thl->pdulen = tot_len; + snmp_asn1_enc_length_cnt(thl->pdulen, &thl->pdulenlen); + tot_len += 1 + thl->pdulenlen; + + thl->comlen = sizeof(snmp_publiccommunity) - 1; + snmp_asn1_enc_length_cnt(thl->comlen, &thl->comlenlen); + tot_len += 1 + thl->comlenlen + thl->comlen; + + snmp_asn1_enc_s32t_cnt(snmp_version, &thl->verlen); + snmp_asn1_enc_length_cnt(thl->verlen, &thl->verlenlen); + tot_len += 1 + thl->verlen + thl->verlenlen; + + thl->seqlen = tot_len; + snmp_asn1_enc_length_cnt(thl->seqlen, &thl->seqlenlen); + tot_len += 1 + thl->seqlenlen; + + return tot_len; +} + +/** + * Sums varbind lengths from tail to head and + * annotates lengths in varbind for second encoding pass. + * + * @param root points to the root of the variable binding list + * @return the required lenght for encoding the variable bindings + */ +static u16_t +snmp_varbind_list_sum(struct snmp_varbind_root *root) +{ + struct snmp_varbind *vb; + u32_t *uint_ptr; + s32_t *sint_ptr; + u16_t tot_len; + + tot_len = 0; + vb = root->tail; + while ( vb != NULL ) + { + /* encoded value lenght depends on type */ + switch (vb->value_type) + { + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG): + sint_ptr = (s32_t*)vb->value; + snmp_asn1_enc_s32t_cnt(*sint_ptr, &vb->vlen); + break; + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS): + uint_ptr = (u32_t*)vb->value; + snmp_asn1_enc_u32t_cnt(*uint_ptr, &vb->vlen); + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR): + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE): + vb->vlen = vb->value_len; + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID): + sint_ptr = (s32_t*)vb->value; + snmp_asn1_enc_oid_cnt(vb->value_len / sizeof(s32_t), sint_ptr, &vb->vlen); + break; + default: + /* unsupported type */ + vb->vlen = 0; + break; + }; + /* encoding length of value length field */ + snmp_asn1_enc_length_cnt(vb->vlen, &vb->vlenlen); + snmp_asn1_enc_oid_cnt(vb->ident_len, vb->ident, &vb->olen); + snmp_asn1_enc_length_cnt(vb->olen, &vb->olenlen); + + vb->seqlen = 1 + vb->vlenlen + vb->vlen; + vb->seqlen += 1 + vb->olenlen + vb->olen; + snmp_asn1_enc_length_cnt(vb->seqlen, &vb->seqlenlen); + + /* varbind seq */ + tot_len += 1 + vb->seqlenlen + vb->seqlen; + + vb = vb->prev; + } + + /* varbind-list seq */ + root->seqlen = tot_len; + snmp_asn1_enc_length_cnt(root->seqlen, &root->seqlenlen); + tot_len += 1 + root->seqlenlen; + + return tot_len; +} + +/** + * Encodes response header from head to tail. + */ +static u16_t +snmp_resp_header_enc(struct snmp_msg_pstat *m_stat, struct pbuf *p) +{ + u16_t ofs; + + ofs = 0; + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.seqlen); + ofs += m_stat->rhl.seqlenlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.verlen); + ofs += m_stat->rhl.verlenlen; + snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.verlen, snmp_version); + ofs += m_stat->rhl.verlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.comlen); + ofs += m_stat->rhl.comlenlen; + snmp_asn1_enc_raw(p, ofs, m_stat->rhl.comlen, m_stat->community); + ofs += m_stat->rhl.comlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_RESP)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.pdulen); + ofs += m_stat->rhl.pdulenlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.ridlen); + ofs += m_stat->rhl.ridlenlen; + snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.ridlen, m_stat->rid); + ofs += m_stat->rhl.ridlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.errstatlen); + ofs += m_stat->rhl.errstatlenlen; + snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.errstatlen, m_stat->error_status); + ofs += m_stat->rhl.errstatlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_stat->rhl.erridxlen); + ofs += m_stat->rhl.erridxlenlen; + snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.erridxlen, m_stat->error_index); + ofs += m_stat->rhl.erridxlen; + + return ofs; +} + +/** + * Encodes trap header from head to tail. + */ +static u16_t +snmp_trap_header_enc(struct snmp_msg_trap *m_trap, struct pbuf *p) +{ + u16_t ofs; + + ofs = 0; + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.seqlen); + ofs += m_trap->thl.seqlenlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.verlen); + ofs += m_trap->thl.verlenlen; + snmp_asn1_enc_s32t(p, ofs, m_trap->thl.verlen, snmp_version); + ofs += m_trap->thl.verlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.comlen); + ofs += m_trap->thl.comlenlen; + snmp_asn1_enc_raw(p, ofs, m_trap->thl.comlen, (u8_t *)&snmp_publiccommunity[0]); + ofs += m_trap->thl.comlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_TRAP)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.pdulen); + ofs += m_trap->thl.pdulenlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.eidlen); + ofs += m_trap->thl.eidlenlen; + snmp_asn1_enc_oid(p, ofs, m_trap->enterprise->len, &m_trap->enterprise->id[0]); + ofs += m_trap->thl.eidlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.aaddrlen); + ofs += m_trap->thl.aaddrlenlen; + snmp_asn1_enc_raw(p, ofs, m_trap->thl.aaddrlen, &m_trap->sip_raw[0]); + ofs += m_trap->thl.aaddrlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.gtrplen); + ofs += m_trap->thl.gtrplenlen; + snmp_asn1_enc_u32t(p, ofs, m_trap->thl.gtrplen, m_trap->gen_trap); + ofs += m_trap->thl.gtrplen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.strplen); + ofs += m_trap->thl.strplenlen; + snmp_asn1_enc_u32t(p, ofs, m_trap->thl.strplen, m_trap->spc_trap); + ofs += m_trap->thl.strplen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, m_trap->thl.tslen); + ofs += m_trap->thl.tslenlen; + snmp_asn1_enc_u32t(p, ofs, m_trap->thl.tslen, m_trap->ts); + ofs += m_trap->thl.tslen; + + return ofs; +} + +/** + * Encodes varbind list from head to tail. + */ +static u16_t +snmp_varbind_list_enc(struct snmp_varbind_root *root, struct pbuf *p, u16_t ofs) +{ + struct snmp_varbind *vb; + s32_t *sint_ptr; + u32_t *uint_ptr; + u8_t *raw_ptr; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, root->seqlen); + ofs += root->seqlenlen; + + vb = root->head; + while ( vb != NULL ) + { + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, vb->seqlen); + ofs += vb->seqlenlen; + + snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID)); + ofs += 1; + snmp_asn1_enc_length(p, ofs, vb->olen); + ofs += vb->olenlen; + snmp_asn1_enc_oid(p, ofs, vb->ident_len, &vb->ident[0]); + ofs += vb->olen; + + snmp_asn1_enc_type(p, ofs, vb->value_type); + ofs += 1; + snmp_asn1_enc_length(p, ofs, vb->vlen); + ofs += vb->vlenlen; + + switch (vb->value_type) + { + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG): + sint_ptr = (s32_t*)vb->value; + snmp_asn1_enc_s32t(p, ofs, vb->vlen, *sint_ptr); + break; + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS): + uint_ptr = (u32_t*)vb->value; + snmp_asn1_enc_u32t(p, ofs, vb->vlen, *uint_ptr); + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR): + case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE): + raw_ptr = (u8_t*)vb->value; + snmp_asn1_enc_raw(p, ofs, vb->vlen, raw_ptr); + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL): + break; + case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID): + sint_ptr = (s32_t*)vb->value; + snmp_asn1_enc_oid(p, ofs, vb->value_len / sizeof(s32_t), sint_ptr); + break; + default: + /* unsupported type */ + break; + }; + ofs += vb->vlen; + vb = vb->next; + } + return ofs; +} + +#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/stats.c b/user/mpy/lib/lwip/src/core/stats.c new file mode 100644 index 0000000..8ea8249 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/stats.c @@ -0,0 +1,176 @@ +/** + * @file + * Statistics module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_STATS /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/def.h" +#include "lwip/stats.h" +#include "lwip/mem.h" + +#include + +struct stats_ lwip_stats; + +void stats_init(void) +{ +#ifdef LWIP_DEBUG +#if MEMP_STATS + const char * memp_names[] = { +#define LWIP_MEMPOOL(name,num,size,desc) desc, +#include "lwip/memp_std.h" + }; + int i; + for (i = 0; i < MEMP_MAX; i++) { + lwip_stats.memp[i].name = memp_names[i]; + } +#endif /* MEMP_STATS */ +#if MEM_STATS + lwip_stats.mem.name = "MEM"; +#endif /* MEM_STATS */ +#endif /* LWIP_DEBUG */ +} + +#if LWIP_STATS_DISPLAY +void +stats_display_proto(struct stats_proto *proto, const char *name) +{ + LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); + LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); + LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); + LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); + LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); + LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); + LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); + LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); + LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); + LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); +} + +#if IGMP_STATS +void +stats_display_igmp(struct stats_igmp *igmp) +{ + LWIP_PLATFORM_DIAG(("\nIGMP\n\t")); + LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); + LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); + LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); + LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); + LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); + LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group)); + LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general)); + LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); + LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); + LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); + LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); +} +#endif /* IGMP_STATS */ + +#if MEM_STATS || MEMP_STATS +void +stats_display_mem(struct stats_mem *mem, const char *name) +{ + LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); + LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); + LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); + LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); + LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); +} + +#if MEMP_STATS +void +stats_display_memp(struct stats_mem *mem, int index) +{ + char * memp_names[] = { +#define LWIP_MEMPOOL(name,num,size,desc) desc, +#include "lwip/memp_std.h" + }; + if(index < MEMP_MAX) { + stats_display_mem(mem, memp_names[index]); + } +} +#endif /* MEMP_STATS */ +#endif /* MEM_STATS || MEMP_STATS */ + +#if SYS_STATS +void +stats_display_sys(struct stats_sys *sys) +{ + LWIP_PLATFORM_DIAG(("\nSYS\n\t")); + LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); + LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); + LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); + LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); + LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); + LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); + LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); + LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); + LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); +} +#endif /* SYS_STATS */ + +void +stats_display(void) +{ + s16_t i; + + LINK_STATS_DISPLAY(); + ETHARP_STATS_DISPLAY(); + IPFRAG_STATS_DISPLAY(); + IP_STATS_DISPLAY(); + IGMP_STATS_DISPLAY(); + ICMP_STATS_DISPLAY(); + UDP_STATS_DISPLAY(); + TCP_STATS_DISPLAY(); + MEM_STATS_DISPLAY(); + for (i = 0; i < MEMP_MAX; i++) { + MEMP_STATS_DISPLAY(i); + } + SYS_STATS_DISPLAY(); +} +#endif /* LWIP_STATS_DISPLAY */ + +#endif /* LWIP_STATS */ + diff --git a/user/mpy/lib/lwip/src/core/sys.c b/user/mpy/lib/lwip/src/core/sys.c new file mode 100644 index 0000000..f177737 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/sys.c @@ -0,0 +1,68 @@ +/** + * @file + * lwIP Operating System abstraction + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#include "lwip/sys.h" + +/* Most of the functions defined in sys.h must be implemented in the + * architecture-dependent file sys_arch.c */ + +#if !NO_SYS + +#ifndef sys_msleep +/** + * Sleep for some ms. Timeouts are NOT processed while sleeping. + * + * @param ms number of milliseconds to sleep + */ +void +sys_msleep(u32_t ms) +{ + if (ms > 0) { + sys_sem_t delaysem; + err_t err = sys_sem_new(&delaysem, 0); + if (err == ERR_OK) { + sys_arch_sem_wait(&delaysem, ms); + sys_sem_free(&delaysem); + } + } +} +#endif /* sys_msleep */ + +#endif /* !NO_SYS */ diff --git a/user/mpy/lib/lwip/src/core/tcp.c b/user/mpy/lib/lwip/src/core/tcp.c new file mode 100644 index 0000000..b710d2e --- /dev/null +++ b/user/mpy/lib/lwip/src/core/tcp.c @@ -0,0 +1,1742 @@ +/** + * @file + * Transmission Control Protocol for IP + * + * This file contains common functions for the TCP implementation, such as functinos + * for manipulating the data structures and the TCP timer functions. TCP functions + * related to input and output is found in tcp_in.c and tcp_out.c respectively. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/snmp.h" +#include "lwip/tcp.h" +#include "lwip/tcp_impl.h" +#include "lwip/debug.h" +#include "lwip/stats.h" + +#include + +#ifndef TCP_LOCAL_PORT_RANGE_START +/* From http://www.iana.org/assignments/port-numbers: + "The Dynamic and/or Private Ports are those from 49152 through 65535" */ +#define TCP_LOCAL_PORT_RANGE_START 0xc000 +#define TCP_LOCAL_PORT_RANGE_END 0xffff +#define TCP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START) +#endif + +#if LWIP_TCP_KEEPALIVE +#define TCP_KEEP_DUR(pcb) ((pcb)->keep_cnt * (pcb)->keep_intvl) +#define TCP_KEEP_INTVL(pcb) ((pcb)->keep_intvl) +#else /* LWIP_TCP_KEEPALIVE */ +#define TCP_KEEP_DUR(pcb) TCP_MAXIDLE +#define TCP_KEEP_INTVL(pcb) TCP_KEEPINTVL_DEFAULT +#endif /* LWIP_TCP_KEEPALIVE */ + +const char * const tcp_state_str[] = { + "CLOSED", + "LISTEN", + "SYN_SENT", + "SYN_RCVD", + "ESTABLISHED", + "FIN_WAIT_1", + "FIN_WAIT_2", + "CLOSE_WAIT", + "CLOSING", + "LAST_ACK", + "TIME_WAIT" +}; + +/* last local TCP port */ +static u16_t tcp_port = TCP_LOCAL_PORT_RANGE_START; + +/* Incremented every coarse grained timer shot (typically every 500 ms). */ +u32_t tcp_ticks; +const u8_t tcp_backoff[13] = + { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7}; + /* Times per slowtmr hits */ +const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; + +/* The TCP PCB lists. */ + +/** List of all TCP PCBs bound but not yet (connected || listening) */ +struct tcp_pcb *tcp_bound_pcbs; +/** List of all TCP PCBs in LISTEN state */ +union tcp_listen_pcbs_t tcp_listen_pcbs; +/** List of all TCP PCBs that are in a state in which + * they accept or send data. */ +struct tcp_pcb *tcp_active_pcbs; +/** List of all TCP PCBs in TIME-WAIT state */ +struct tcp_pcb *tcp_tw_pcbs; + +#define NUM_TCP_PCB_LISTS 4 +#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 +/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */ +struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs, + &tcp_active_pcbs, &tcp_tw_pcbs}; + +/** Only used for temporary storage. */ +struct tcp_pcb *tcp_tmp_pcb; + +u8_t tcp_active_pcbs_changed; + +/** Timer counter to handle calling slow-timer from tcp_tmr() */ +static u8_t tcp_timer; +static u8_t tcp_timer_ctr; +static u16_t tcp_new_port(void); + +/** + * Initialize this module. + */ +void +tcp_init(void) +{ +#if LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) + tcp_port = TCP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()); +#endif /* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) */ +} + +/** + * Called periodically to dispatch TCP timers. + */ +void +tcp_tmr(void) +{ + /* Call tcp_fasttmr() every 250 ms */ + tcp_fasttmr(); + + if (++tcp_timer & 1) { + /* Call tcp_tmr() every 500 ms, i.e., every other timer + tcp_tmr() is called. */ + tcp_slowtmr(); + } +} + +/** + * Closes the TX side of a connection held by the PCB. + * For tcp_close(), a RST is sent if the application didn't receive all data + * (tcp_recved() not called for all data passed to recv callback). + * + * Listening pcbs are freed and may not be referenced any more. + * Connection pcbs are freed if not yet connected and may not be referenced + * any more. If a connection is established (at least SYN received or in + * a closing state), the connection is closed, and put in a closing state. + * The pcb is then automatically freed in tcp_slowtmr(). It is therefore + * unsafe to reference it. + * + * @param pcb the tcp_pcb to close + * @return ERR_OK if connection has been closed + * another err_t if closing failed and pcb is not freed + */ +static err_t +tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data) +{ + err_t err; + + if (rst_on_unacked_data && ((pcb->state == ESTABLISHED) || (pcb->state == CLOSE_WAIT))) { + if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) { + /* Not all data received by application, send RST to tell the remote + side about this. */ + LWIP_ASSERT("pcb->flags & TF_RXCLOSED", pcb->flags & TF_RXCLOSED); + + /* don't call tcp_abort here: we must not deallocate the pcb since + that might not be expected when calling tcp_close */ + tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, + pcb->local_port, pcb->remote_port); + + tcp_pcb_purge(pcb); + TCP_RMV_ACTIVE(pcb); + if (pcb->state == ESTABLISHED) { + /* move to TIME_WAIT since we close actively */ + pcb->state = TIME_WAIT; + TCP_REG(&tcp_tw_pcbs, pcb); + } else { + /* CLOSE_WAIT: deallocate the pcb since we already sent a RST for it */ + memp_free(MEMP_TCP_PCB, pcb); + } + return ERR_OK; + } + } + + switch (pcb->state) { + case CLOSED: + /* Closing a pcb in the CLOSED state might seem erroneous, + * however, it is in this state once allocated and as yet unused + * and the user needs some way to free it should the need arise. + * Calling tcp_close() with a pcb that has already been closed, (i.e. twice) + * or for a pcb that has been used and then entered the CLOSED state + * is erroneous, but this should never happen as the pcb has in those cases + * been freed, and so any remaining handles are bogus. */ + err = ERR_OK; + if (pcb->local_port != 0) { + TCP_RMV(&tcp_bound_pcbs, pcb); + } + memp_free(MEMP_TCP_PCB, pcb); + pcb = NULL; + break; + case LISTEN: + err = ERR_OK; + tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb); + memp_free(MEMP_TCP_PCB_LISTEN, pcb); + pcb = NULL; + break; + case SYN_SENT: + err = ERR_OK; + TCP_PCB_REMOVE_ACTIVE(pcb); + memp_free(MEMP_TCP_PCB, pcb); + pcb = NULL; + snmp_inc_tcpattemptfails(); + break; + case SYN_RCVD: + err = tcp_send_fin(pcb); + if (err == ERR_OK) { + snmp_inc_tcpattemptfails(); + pcb->state = FIN_WAIT_1; + } + break; + case ESTABLISHED: + err = tcp_send_fin(pcb); + if (err == ERR_OK) { + snmp_inc_tcpestabresets(); + pcb->state = FIN_WAIT_1; + } + break; + case CLOSE_WAIT: + err = tcp_send_fin(pcb); + if (err == ERR_OK) { + snmp_inc_tcpestabresets(); + pcb->state = LAST_ACK; + } + break; + default: + /* Has already been closed, do nothing. */ + err = ERR_OK; + pcb = NULL; + break; + } + + if (pcb != NULL && err == ERR_OK) { + /* To ensure all data has been sent when tcp_close returns, we have + to make sure tcp_output doesn't fail. + Since we don't really have to ensure all data has been sent when tcp_close + returns (unsent data is sent from tcp timer functions, also), we don't care + for the return value of tcp_output for now. */ + /* @todo: When implementing SO_LINGER, this must be changed somehow: + If SOF_LINGER is set, the data should be sent and acked before close returns. + This can only be valid for sequential APIs, not for the raw API. */ + tcp_output(pcb); + } + return err; +} + +/** + * Closes the connection held by the PCB. + * + * Listening pcbs are freed and may not be referenced any more. + * Connection pcbs are freed if not yet connected and may not be referenced + * any more. If a connection is established (at least SYN received or in + * a closing state), the connection is closed, and put in a closing state. + * The pcb is then automatically freed in tcp_slowtmr(). It is therefore + * unsafe to reference it (unless an error is returned). + * + * @param pcb the tcp_pcb to close + * @return ERR_OK if connection has been closed + * another err_t if closing failed and pcb is not freed + */ +err_t +tcp_close(struct tcp_pcb *pcb) +{ +#if TCP_DEBUG + LWIP_DEBUGF(TCP_DEBUG, ("tcp_close: closing in ")); + tcp_debug_print_state(pcb->state); +#endif /* TCP_DEBUG */ + + if (pcb->state != LISTEN) { + /* Set a flag not to receive any more data... */ + pcb->flags |= TF_RXCLOSED; + } + /* ... and close */ + return tcp_close_shutdown(pcb, 1); +} + +/** + * Causes all or part of a full-duplex connection of this PCB to be shut down. + * This doesn't deallocate the PCB unless shutting down both sides! + * Shutting down both sides is the same as calling tcp_close, so if it succeds, + * the PCB should not be referenced any more. + * + * @param pcb PCB to shutdown + * @param shut_rx shut down receive side if this is != 0 + * @param shut_tx shut down send side if this is != 0 + * @return ERR_OK if shutdown succeeded (or the PCB has already been shut down) + * another err_t on error. + */ +err_t +tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx) +{ + if (pcb->state == LISTEN) { + return ERR_CONN; + } + if (shut_rx) { + /* shut down the receive side: set a flag not to receive any more data... */ + pcb->flags |= TF_RXCLOSED; + if (shut_tx) { + /* shutting down the tx AND rx side is the same as closing for the raw API */ + return tcp_close_shutdown(pcb, 1); + } + /* ... and free buffered data */ + if (pcb->refused_data != NULL) { + pbuf_free(pcb->refused_data); + pcb->refused_data = NULL; + } + } + if (shut_tx) { + /* This can't happen twice since if it succeeds, the pcb's state is changed. + Only close in these states as the others directly deallocate the PCB */ + switch (pcb->state) { + case SYN_RCVD: + case ESTABLISHED: + case CLOSE_WAIT: + return tcp_close_shutdown(pcb, shut_rx); + default: + /* Not (yet?) connected, cannot shutdown the TX side as that would bring us + into CLOSED state, where the PCB is deallocated. */ + return ERR_CONN; + } + } + return ERR_OK; +} + +/** + * Abandons a connection and optionally sends a RST to the remote + * host. Deletes the local protocol control block. This is done when + * a connection is killed because of shortage of memory. + * + * @param pcb the tcp_pcb to abort + * @param reset boolean to indicate whether a reset should be sent + */ +void +tcp_abandon(struct tcp_pcb *pcb, int reset) +{ + u32_t seqno, ackno; +#if LWIP_CALLBACK_API + tcp_err_fn errf; +#endif /* LWIP_CALLBACK_API */ + void *errf_arg; + + /* pcb->state LISTEN not allowed here */ + LWIP_ASSERT("don't call tcp_abort/tcp_abandon for listen-pcbs", + pcb->state != LISTEN); + /* Figure out on which TCP PCB list we are, and remove us. If we + are in an active state, call the receive function associated with + the PCB with a NULL argument, and send an RST to the remote end. */ + if (pcb->state == TIME_WAIT) { + tcp_pcb_remove(&tcp_tw_pcbs, pcb); + memp_free(MEMP_TCP_PCB, pcb); + } else { + seqno = pcb->snd_nxt; + ackno = pcb->rcv_nxt; +#if LWIP_CALLBACK_API + errf = pcb->errf; +#endif /* LWIP_CALLBACK_API */ + errf_arg = pcb->callback_arg; + TCP_PCB_REMOVE_ACTIVE(pcb); + if (pcb->unacked != NULL) { + tcp_segs_free(pcb->unacked); + } + if (pcb->unsent != NULL) { + tcp_segs_free(pcb->unsent); + } +#if TCP_QUEUE_OOSEQ + if (pcb->ooseq != NULL) { + tcp_segs_free(pcb->ooseq); + } +#endif /* TCP_QUEUE_OOSEQ */ + if (reset) { + LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n")); + tcp_rst(seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port); + } + memp_free(MEMP_TCP_PCB, pcb); + TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT); + } +} + +/** + * Aborts the connection by sending a RST (reset) segment to the remote + * host. The pcb is deallocated. This function never fails. + * + * ATTENTION: When calling this from one of the TCP callbacks, make + * sure you always return ERR_ABRT (and never return ERR_ABRT otherwise + * or you will risk accessing deallocated memory or memory leaks! + * + * @param pcb the tcp pcb to abort + */ +void +tcp_abort(struct tcp_pcb *pcb) +{ + tcp_abandon(pcb, 1); +} + +/** + * Binds the connection to a local portnumber and IP address. If the + * IP address is not given (i.e., ipaddr == NULL), the IP address of + * the outgoing network interface is used instead. + * + * @param pcb the tcp_pcb to bind (no check is done whether this pcb is + * already bound!) + * @param ipaddr the local ip address to bind to (use IP_ADDR_ANY to bind + * to any local address + * @param port the local port to bind to + * @return ERR_USE if the port is already in use + * ERR_VAL if bind failed because the PCB is not in a valid state + * ERR_OK if bound + */ +err_t +tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) +{ + int i; + int max_pcb_list = NUM_TCP_PCB_LISTS; + struct tcp_pcb *cpcb; + + LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL); + +#if SO_REUSE + /* Unless the REUSEADDR flag is set, + we have to check the pcbs in TIME-WAIT state, also. + We do not dump TIME_WAIT pcb's; they can still be matched by incoming + packets using both local and remote IP addresses and ports to distinguish. + */ + if (ip_get_option(pcb, SOF_REUSEADDR)) { + max_pcb_list = NUM_TCP_PCB_LISTS_NO_TIME_WAIT; + } +#endif /* SO_REUSE */ + + if (port == 0) { + port = tcp_new_port(); + if (port == 0) { + return ERR_BUF; + } + } + + /* Check if the address already is in use (on all lists) */ + for (i = 0; i < max_pcb_list; i++) { + for(cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { + if (cpcb->local_port == port) { +#if SO_REUSE + /* Omit checking for the same port if both pcbs have REUSEADDR set. + For SO_REUSEADDR, the duplicate-check for a 5-tuple is done in + tcp_connect. */ + if (!ip_get_option(pcb, SOF_REUSEADDR) || + !ip_get_option(cpcb, SOF_REUSEADDR)) +#endif /* SO_REUSE */ + { + if (ip_addr_isany(&(cpcb->local_ip)) || + ip_addr_isany(ipaddr) || + ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { + return ERR_USE; + } + } + } + } + } + + if (!ip_addr_isany(ipaddr)) { + pcb->local_ip = *ipaddr; + } + pcb->local_port = port; + TCP_REG(&tcp_bound_pcbs, pcb); + LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %"U16_F"\n", port)); + return ERR_OK; +} +#if LWIP_CALLBACK_API +/** + * Default accept callback if no accept callback is specified by the user. + */ +static err_t +tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) +{ + LWIP_UNUSED_ARG(arg); + LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(err); + + return ERR_ABRT; +} +#endif /* LWIP_CALLBACK_API */ + +/** + * Set the state of the connection to be LISTEN, which means that it + * is able to accept incoming connections. The protocol control block + * is reallocated in order to consume less memory. Setting the + * connection to LISTEN is an irreversible process. + * + * @param pcb the original tcp_pcb + * @param backlog the incoming connections queue limit + * @return tcp_pcb used for listening, consumes less memory. + * + * @note The original tcp_pcb is freed. This function therefore has to be + * called like this: + * tpcb = tcp_listen(tpcb); + */ +struct tcp_pcb * +tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) +{ + struct tcp_pcb_listen *lpcb; + + LWIP_UNUSED_ARG(backlog); + LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL); + + /* already listening? */ + if (pcb->state == LISTEN) { + return pcb; + } +#if SO_REUSE + if (ip_get_option(pcb, SOF_REUSEADDR)) { + /* Since SOF_REUSEADDR allows reusing a local address before the pcb's usage + is declared (listen-/connection-pcb), we have to make sure now that + this port is only used once for every local IP. */ + for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { + if (lpcb->local_port == pcb->local_port) { + if (ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) { + /* this address/port is already used */ + return NULL; + } + } + } + } +#endif /* SO_REUSE */ + lpcb = (struct tcp_pcb_listen *)memp_malloc(MEMP_TCP_PCB_LISTEN); + if (lpcb == NULL) { + return NULL; + } + lpcb->callback_arg = pcb->callback_arg; + lpcb->local_port = pcb->local_port; + lpcb->state = LISTEN; + lpcb->prio = pcb->prio; + lpcb->so_options = pcb->so_options; + ip_set_option(lpcb, SOF_ACCEPTCONN); + lpcb->ttl = pcb->ttl; + lpcb->tos = pcb->tos; + ip_addr_copy(lpcb->local_ip, pcb->local_ip); + if (pcb->local_port != 0) { + TCP_RMV(&tcp_bound_pcbs, pcb); + } + memp_free(MEMP_TCP_PCB, pcb); +#if LWIP_CALLBACK_API + lpcb->accept = tcp_accept_null; +#endif /* LWIP_CALLBACK_API */ +#if TCP_LISTEN_BACKLOG + lpcb->accepts_pending = 0; + lpcb->backlog = (backlog ? backlog : 1); +#endif /* TCP_LISTEN_BACKLOG */ + TCP_REG(&tcp_listen_pcbs.pcbs, (struct tcp_pcb *)lpcb); + return (struct tcp_pcb *)lpcb; +} + +/** + * Update the state that tracks the available window space to advertise. + * + * Returns how much extra window would be advertised if we sent an + * update now. + */ +u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb) +{ + u32_t new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd; + + if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) { + /* we can advertise more window */ + pcb->rcv_ann_wnd = pcb->rcv_wnd; + return new_right_edge - pcb->rcv_ann_right_edge; + } else { + if (TCP_SEQ_GT(pcb->rcv_nxt, pcb->rcv_ann_right_edge)) { + /* Can happen due to other end sending out of advertised window, + * but within actual available (but not yet advertised) window */ + pcb->rcv_ann_wnd = 0; + } else { + /* keep the right edge of window constant */ + u32_t new_rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt; + LWIP_ASSERT("new_rcv_ann_wnd <= 0xffff", new_rcv_ann_wnd <= 0xffff); + pcb->rcv_ann_wnd = (u16_t)new_rcv_ann_wnd; + } + return 0; + } +} + +/** + * This function should be called by the application when it has + * processed the data. The purpose is to advertise a larger window + * when the data has been processed. + * + * @param pcb the tcp_pcb for which data is read + * @param len the amount of bytes that have been read by the application + */ +void +tcp_recved(struct tcp_pcb *pcb, u16_t len) +{ + int wnd_inflation; + + /* pcb->state LISTEN not allowed here */ + LWIP_ASSERT("don't call tcp_recved for listen-pcbs", + pcb->state != LISTEN); + LWIP_ASSERT("tcp_recved: len would wrap rcv_wnd\n", + len <= 0xffff - pcb->rcv_wnd ); + + pcb->rcv_wnd += len; + if (pcb->rcv_wnd > TCP_WND) { + pcb->rcv_wnd = TCP_WND; + } + + wnd_inflation = tcp_update_rcv_ann_wnd(pcb); + + /* If the change in the right edge of window is significant (default + * watermark is TCP_WND/4), then send an explicit update now. + * Otherwise wait for a packet to be sent in the normal course of + * events (or more window to be available later) */ + if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD) { + tcp_ack_now(pcb); + tcp_output(pcb); + } + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %"U16_F" bytes, wnd %"U16_F" (%"U16_F").\n", + len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd)); +} + +/** + * Allocate a new local TCP port. + * + * @return a new (free) local TCP port number + */ +static u16_t +tcp_new_port(void) +{ + u8_t i; + u16_t n = 0; + struct tcp_pcb *pcb; + +again: + if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) { + tcp_port = TCP_LOCAL_PORT_RANGE_START; + } + /* Check all PCB lists. */ + for (i = 0; i < NUM_TCP_PCB_LISTS; i++) { + for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) { + if (pcb->local_port == tcp_port) { + if (++n > (TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START)) { + return 0; + } + goto again; + } + } + } + return tcp_port; +} + +/** + * Connects to another host. The function given as the "connected" + * argument will be called when the connection has been established. + * + * @param pcb the tcp_pcb used to establish the connection + * @param ipaddr the remote ip address to connect to + * @param port the remote tcp port to connect to + * @param connected callback function to call when connected (or on error) + * @return ERR_VAL if invalid arguments are given + * ERR_OK if connect request has been sent + * other err_t values if connect request couldn't be sent + */ +err_t +tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, + tcp_connected_fn connected) +{ + err_t ret; + u32_t iss; + u16_t old_local_port; + + LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN); + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port)); + if (ipaddr != NULL) { + pcb->remote_ip = *ipaddr; + } else { + return ERR_VAL; + } + pcb->remote_port = port; + + /* check if we have a route to the remote host */ + if (ip_addr_isany(&(pcb->local_ip))) { + /* no local IP address set, yet. */ + struct netif *netif = ip_route(&(pcb->remote_ip)); + if (netif == NULL) { + /* Don't even try to send a SYN packet if we have no route + since that will fail. */ + return ERR_RTE; + } + /* Use the netif's IP address as local address. */ + ip_addr_copy(pcb->local_ip, netif->ip_addr); + } + + old_local_port = pcb->local_port; + if (pcb->local_port == 0) { + pcb->local_port = tcp_new_port(); + if (pcb->local_port == 0) { + return ERR_BUF; + } + } +#if SO_REUSE + if (ip_get_option(pcb, SOF_REUSEADDR)) { + /* Since SOF_REUSEADDR allows reusing a local address, we have to make sure + now that the 5-tuple is unique. */ + struct tcp_pcb *cpcb; + int i; + /* Don't check listen- and bound-PCBs, check active- and TIME-WAIT PCBs. */ + for (i = 2; i < NUM_TCP_PCB_LISTS; i++) { + for(cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { + if ((cpcb->local_port == pcb->local_port) && + (cpcb->remote_port == port) && + ip_addr_cmp(&cpcb->local_ip, &pcb->local_ip) && + ip_addr_cmp(&cpcb->remote_ip, ipaddr)) { + /* linux returns EISCONN here, but ERR_USE should be OK for us */ + return ERR_USE; + } + } + } + } +#endif /* SO_REUSE */ + iss = tcp_next_iss(); + pcb->rcv_nxt = 0; + pcb->snd_nxt = iss; + pcb->lastack = iss - 1; + pcb->snd_lbb = iss - 1; + pcb->rcv_wnd = TCP_WND; + pcb->rcv_ann_wnd = TCP_WND; + pcb->rcv_ann_right_edge = pcb->rcv_nxt; + pcb->snd_wnd = TCP_WND; + /* As initial send MSS, we use TCP_MSS but limit it to 536. + The send MSS is updated when an MSS option is received. */ + pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; +#if TCP_CALCULATE_EFF_SEND_MSS + pcb->mss = tcp_eff_send_mss(pcb->mss, ipaddr); +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + pcb->cwnd = 1; + pcb->ssthresh = pcb->mss * 10; +#if LWIP_CALLBACK_API + pcb->connected = connected; +#else /* LWIP_CALLBACK_API */ + LWIP_UNUSED_ARG(connected); +#endif /* LWIP_CALLBACK_API */ + + /* Send a SYN together with the MSS option. */ + ret = tcp_enqueue_flags(pcb, TCP_SYN); + if (ret == ERR_OK) { + /* SYN segment was enqueued, changed the pcbs state now */ + pcb->state = SYN_SENT; + if (old_local_port != 0) { + TCP_RMV(&tcp_bound_pcbs, pcb); + } + TCP_REG_ACTIVE(pcb); + snmp_inc_tcpactiveopens(); + + tcp_output(pcb); + } + return ret; +} + +/** + * Called every 500 ms and implements the retransmission timer and the timer that + * removes PCBs that have been in TIME-WAIT for enough time. It also increments + * various timers such as the inactivity timer in each PCB. + * + * Automatically called from tcp_tmr(). + */ +void +tcp_slowtmr(void) +{ + struct tcp_pcb *pcb, *prev; + u16_t eff_wnd; + u8_t pcb_remove; /* flag if a PCB should be removed */ + u8_t pcb_reset; /* flag if a RST should be sent when removing */ + err_t err; + + err = ERR_OK; + + ++tcp_ticks; + ++tcp_timer_ctr; + +tcp_slowtmr_start: + /* Steps through all of the active PCBs. */ + prev = NULL; + pcb = tcp_active_pcbs; + if (pcb == NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n")); + } + while (pcb != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n")); + LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED); + LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN); + LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT); + if (pcb->last_timer == tcp_timer_ctr) { + /* skip this pcb, we have already processed it */ + pcb = pcb->next; + continue; + } + pcb->last_timer = tcp_timer_ctr; + + pcb_remove = 0; + pcb_reset = 0; + + if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) { + ++pcb_remove; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); + } + else if (pcb->nrtx == TCP_MAXRTX) { + ++pcb_remove; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); + } else { + if (pcb->persist_backoff > 0) { + /* If snd_wnd is zero, use persist timer to send 1 byte probes + * instead of using the standard retransmission mechanism. */ + pcb->persist_cnt++; + if (pcb->persist_cnt >= tcp_persist_backoff[pcb->persist_backoff-1]) { + pcb->persist_cnt = 0; + if (pcb->persist_backoff < sizeof(tcp_persist_backoff)) { + pcb->persist_backoff++; + } + tcp_zero_window_probe(pcb); + } + } else { + /* Increase the retransmission timer if it is running */ + if(pcb->rtime >= 0) { + ++pcb->rtime; + } + + if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) { + /* Time for a retransmission. */ + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %"S16_F + " pcb->rto %"S16_F"\n", + pcb->rtime, pcb->rto)); + + /* Double retransmission time-out unless we are trying to + * connect to somebody (i.e., we are in SYN_SENT). */ + if (pcb->state != SYN_SENT) { + pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx]; + } + + /* Reset the retransmission timer. */ + pcb->rtime = 0; + + /* Reduce congestion window and ssthresh. */ + eff_wnd = LWIP_MIN(pcb->cwnd, pcb->snd_wnd); + pcb->ssthresh = eff_wnd >> 1; + if (pcb->ssthresh < (pcb->mss << 1)) { + pcb->ssthresh = (pcb->mss << 1); + } + pcb->cwnd = pcb->mss; + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F + " ssthresh %"U16_F"\n", + pcb->cwnd, pcb->ssthresh)); + + /* The following needs to be called AFTER cwnd is set to one + mss - STJ */ + tcp_rexmit_rto(pcb); + } + } + } + /* Check if this PCB has stayed too long in FIN-WAIT-2 */ + if (pcb->state == FIN_WAIT_2) { + /* If this PCB is in FIN_WAIT_2 because of SHUT_WR don't let it time out. */ + if (pcb->flags & TF_RXCLOSED) { + /* PCB was fully closed (either through close() or SHUT_RDWR): + normal FIN-WAIT timeout handling. */ + if ((u32_t)(tcp_ticks - pcb->tmr) > + TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { + ++pcb_remove; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); + } + } + } + + /* Check if KEEPALIVE should be sent */ + if(ip_get_option(pcb, SOF_KEEPALIVE) && + ((pcb->state == ESTABLISHED) || + (pcb->state == CLOSE_WAIT))) { + if((u32_t)(tcp_ticks - pcb->tmr) > + (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) + { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n", + ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), + ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); + + ++pcb_remove; + ++pcb_reset; + } + else if((u32_t)(tcp_ticks - pcb->tmr) > + (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb)) + / TCP_SLOW_INTERVAL) + { + tcp_keepalive(pcb); + pcb->keep_cnt_sent++; + } + } + + /* If this PCB has queued out of sequence data, but has been + inactive for too long, will drop the data (it will eventually + be retransmitted). */ +#if TCP_QUEUE_OOSEQ + if (pcb->ooseq != NULL && + (u32_t)tcp_ticks - pcb->tmr >= pcb->rto * TCP_OOSEQ_TIMEOUT) { + tcp_segs_free(pcb->ooseq); + pcb->ooseq = NULL; + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); + } +#endif /* TCP_QUEUE_OOSEQ */ + + /* Check if this PCB has stayed too long in SYN-RCVD */ + if (pcb->state == SYN_RCVD) { + if ((u32_t)(tcp_ticks - pcb->tmr) > + TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { + ++pcb_remove; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); + } + } + + /* Check if this PCB has stayed too long in LAST-ACK */ + if (pcb->state == LAST_ACK) { + if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { + ++pcb_remove; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in LAST-ACK\n")); + } + } + + /* If the PCB should be removed, do it. */ + if (pcb_remove) { + struct tcp_pcb *pcb2; + tcp_err_fn err_fn; + void *err_arg; + tcp_pcb_purge(pcb); + /* Remove PCB from tcp_active_pcbs list. */ + if (prev != NULL) { + LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs); + prev->next = pcb->next; + } else { + /* This PCB was the first. */ + LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb); + tcp_active_pcbs = pcb->next; + } + + if (pcb_reset) { + tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, + pcb->local_port, pcb->remote_port); + } + + err_fn = pcb->errf; + err_arg = pcb->callback_arg; + pcb2 = pcb; + pcb = pcb->next; + memp_free(MEMP_TCP_PCB, pcb2); + + tcp_active_pcbs_changed = 0; + TCP_EVENT_ERR(err_fn, err_arg, ERR_ABRT); + if (tcp_active_pcbs_changed) { + goto tcp_slowtmr_start; + } + } else { + /* get the 'next' element now and work with 'prev' below (in case of abort) */ + prev = pcb; + pcb = pcb->next; + + /* We check if we should poll the connection. */ + ++prev->polltmr; + if (prev->polltmr >= prev->pollinterval) { + prev->polltmr = 0; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n")); + tcp_active_pcbs_changed = 0; + TCP_EVENT_POLL(prev, err); + if (tcp_active_pcbs_changed) { + goto tcp_slowtmr_start; + } + /* if err == ERR_ABRT, 'prev' is already deallocated */ + if (err == ERR_OK) { + tcp_output(prev); + } + } + } + } + + + /* Steps through all of the TIME-WAIT PCBs. */ + prev = NULL; + pcb = tcp_tw_pcbs; + while (pcb != NULL) { + LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); + pcb_remove = 0; + + /* Check if this PCB has stayed long enough in TIME-WAIT */ + if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { + ++pcb_remove; + } + + + + /* If the PCB should be removed, do it. */ + if (pcb_remove) { + struct tcp_pcb *pcb2; + tcp_pcb_purge(pcb); + /* Remove PCB from tcp_tw_pcbs list. */ + if (prev != NULL) { + LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs); + prev->next = pcb->next; + } else { + /* This PCB was the first. */ + LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", tcp_tw_pcbs == pcb); + tcp_tw_pcbs = pcb->next; + } + pcb2 = pcb; + pcb = pcb->next; + memp_free(MEMP_TCP_PCB, pcb2); + } else { + prev = pcb; + pcb = pcb->next; + } + } +} + +/** + * Is called every TCP_FAST_INTERVAL (250 ms) and process data previously + * "refused" by upper layer (application) and sends delayed ACKs. + * + * Automatically called from tcp_tmr(). + */ +void +tcp_fasttmr(void) +{ + struct tcp_pcb *pcb; + + ++tcp_timer_ctr; + +tcp_fasttmr_start: + pcb = tcp_active_pcbs; + + while(pcb != NULL) { + if (pcb->last_timer != tcp_timer_ctr) { + struct tcp_pcb *next; + pcb->last_timer = tcp_timer_ctr; + /* send delayed ACKs */ + if (pcb->flags & TF_ACK_DELAY) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); + tcp_ack_now(pcb); + tcp_output(pcb); + pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); + } + + next = pcb->next; + + /* If there is data which was previously "refused" by upper layer */ + if (pcb->refused_data != NULL) { + tcp_active_pcbs_changed = 0; + tcp_process_refused_data(pcb); + if (tcp_active_pcbs_changed) { + /* application callback has changed the pcb list: restart the loop */ + goto tcp_fasttmr_start; + } + } + pcb = next; + } + } +} + +/** Pass pcb->refused_data to the recv callback */ +err_t +tcp_process_refused_data(struct tcp_pcb *pcb) +{ + err_t err; + u8_t refused_flags = pcb->refused_data->flags; + /* set pcb->refused_data to NULL in case the callback frees it and then + closes the pcb */ + struct pbuf *refused_data = pcb->refused_data; + pcb->refused_data = NULL; + /* Notify again application with data previously received. */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: notify kept packet\n")); + TCP_EVENT_RECV(pcb, refused_data, ERR_OK, err); + if (err == ERR_OK) { + /* did refused_data include a FIN? */ + if (refused_flags & PBUF_FLAG_TCP_FIN) { + /* correct rcv_wnd as the application won't call tcp_recved() + for the FIN's seqno */ + if (pcb->rcv_wnd != TCP_WND) { + pcb->rcv_wnd++; + } + TCP_EVENT_CLOSED(pcb, err); + if (err == ERR_ABRT) { + return ERR_ABRT; + } + } + } else if (err == ERR_ABRT) { + /* if err == ERR_ABRT, 'pcb' is already deallocated */ + /* Drop incoming packets because pcb is "full" (only if the incoming + segment contains data). */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: drop incoming packets, because pcb is \"full\"\n")); + return ERR_ABRT; + } else { + /* data is still refused, pbuf is still valid (go on for ACK-only packets) */ + pcb->refused_data = refused_data; + } + return ERR_OK; +} + +/** + * Deallocates a list of TCP segments (tcp_seg structures). + * + * @param seg tcp_seg list of TCP segments to free + */ +void +tcp_segs_free(struct tcp_seg *seg) +{ + while (seg != NULL) { + struct tcp_seg *next = seg->next; + tcp_seg_free(seg); + seg = next; + } +} + +/** + * Frees a TCP segment (tcp_seg structure). + * + * @param seg single tcp_seg to free + */ +void +tcp_seg_free(struct tcp_seg *seg) +{ + if (seg != NULL) { + if (seg->p != NULL) { + pbuf_free(seg->p); +#if TCP_DEBUG + seg->p = NULL; +#endif /* TCP_DEBUG */ + } + memp_free(MEMP_TCP_SEG, seg); + } +} + +/** + * Sets the priority of a connection. + * + * @param pcb the tcp_pcb to manipulate + * @param prio new priority + */ +void +tcp_setprio(struct tcp_pcb *pcb, u8_t prio) +{ + pcb->prio = prio; +} + +#if TCP_QUEUE_OOSEQ +/** + * Returns a copy of the given TCP segment. + * The pbuf and data are not copied, only the pointers + * + * @param seg the old tcp_seg + * @return a copy of seg + */ +struct tcp_seg * +tcp_seg_copy(struct tcp_seg *seg) +{ + struct tcp_seg *cseg; + + cseg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (cseg == NULL) { + return NULL; + } + SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); + pbuf_ref(cseg->p); + return cseg; +} +#endif /* TCP_QUEUE_OOSEQ */ + +#if LWIP_CALLBACK_API +/** + * Default receive callback that is called if the user didn't register + * a recv callback for the pcb. + */ +err_t +tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) +{ + LWIP_UNUSED_ARG(arg); + if (p != NULL) { + tcp_recved(pcb, p->tot_len); + pbuf_free(p); + } else if (err == ERR_OK) { + return tcp_close(pcb); + } + return ERR_OK; +} +#endif /* LWIP_CALLBACK_API */ + +/** + * Kills the oldest active connection that has the same or lower priority than + * 'prio'. + * + * @param prio minimum priority + */ +static void +tcp_kill_prio(u8_t prio) +{ + struct tcp_pcb *pcb, *inactive; + u32_t inactivity; + u8_t mprio; + + + mprio = TCP_PRIO_MAX; + + /* We kill the oldest active connection that has lower priority than prio. */ + inactivity = 0; + inactive = NULL; + for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { + if (pcb->prio <= prio && + pcb->prio <= mprio && + (u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { + inactivity = tcp_ticks - pcb->tmr; + inactive = pcb; + mprio = pcb->prio; + } + } + if (inactive != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%"S32_F")\n", + (void *)inactive, inactivity)); + tcp_abort(inactive); + } +} + +/** + * Kills the oldest connection that is in TIME_WAIT state. + * Called from tcp_alloc() if no more connections are available. + */ +static void +tcp_kill_timewait(void) +{ + struct tcp_pcb *pcb, *inactive; + u32_t inactivity; + + inactivity = 0; + inactive = NULL; + /* Go through the list of TIME_WAIT pcbs and get the oldest pcb. */ + for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { + if ((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { + inactivity = tcp_ticks - pcb->tmr; + inactive = pcb; + } + } + if (inactive != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%"S32_F")\n", + (void *)inactive, inactivity)); + tcp_abort(inactive); + } +} + +/** + * Allocate a new tcp_pcb structure. + * + * @param prio priority for the new pcb + * @return a new tcp_pcb that initially is in state CLOSED + */ +struct tcp_pcb * +tcp_alloc(u8_t prio) +{ + struct tcp_pcb *pcb; + u32_t iss; + + pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == NULL) { + /* Try killing oldest connection in TIME-WAIT. */ + LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n")); + tcp_kill_timewait(); + /* Try to allocate a tcp_pcb again. */ + pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == NULL) { + /* Try killing active connections with lower priority than the new one. */ + LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing connection with prio lower than %d\n", prio)); + tcp_kill_prio(prio); + /* Try to allocate a tcp_pcb again. */ + pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb != NULL) { + /* adjust err stats: memp_malloc failed twice before */ + MEMP_STATS_DEC(err, MEMP_TCP_PCB); + } + } + if (pcb != NULL) { + /* adjust err stats: timewait PCB was freed above */ + MEMP_STATS_DEC(err, MEMP_TCP_PCB); + } + } + if (pcb != NULL) { + memset(pcb, 0, sizeof(struct tcp_pcb)); + pcb->prio = prio; + pcb->snd_buf = TCP_SND_BUF; + pcb->snd_queuelen = 0; + pcb->rcv_wnd = TCP_WND; + pcb->rcv_ann_wnd = TCP_WND; + pcb->tos = 0; + pcb->ttl = TCP_TTL; + /* As initial send MSS, we use TCP_MSS but limit it to 536. + The send MSS is updated when an MSS option is received. */ + pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; + pcb->rto = 3000 / TCP_SLOW_INTERVAL; + pcb->sa = 0; + pcb->sv = 3000 / TCP_SLOW_INTERVAL; + pcb->rtime = -1; + pcb->cwnd = 1; + iss = tcp_next_iss(); + pcb->snd_wl2 = iss; + pcb->snd_nxt = iss; + pcb->lastack = iss; + pcb->snd_lbb = iss; + pcb->tmr = tcp_ticks; + pcb->last_timer = tcp_timer_ctr; + + pcb->polltmr = 0; + +#if LWIP_CALLBACK_API + pcb->recv = tcp_recv_null; +#endif /* LWIP_CALLBACK_API */ + + /* Init KEEPALIVE timer */ + pcb->keep_idle = TCP_KEEPIDLE_DEFAULT; + +#if LWIP_TCP_KEEPALIVE + pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT; + pcb->keep_cnt = TCP_KEEPCNT_DEFAULT; +#endif /* LWIP_TCP_KEEPALIVE */ + + pcb->keep_cnt_sent = 0; + } + return pcb; +} + +/** + * Creates a new TCP protocol control block but doesn't place it on + * any of the TCP PCB lists. + * The pcb is not put on any list until binding using tcp_bind(). + * + * @internal: Maybe there should be a idle TCP PCB list where these + * PCBs are put on. Port reservation using tcp_bind() is implemented but + * allocated pcbs that are not bound can't be killed automatically if wanting + * to allocate a pcb with higher prio (@see tcp_kill_prio()) + * + * @return a new tcp_pcb that initially is in state CLOSED + */ +struct tcp_pcb * +tcp_new(void) +{ + return tcp_alloc(TCP_PRIO_NORMAL); +} + +/** + * Used to specify the argument that should be passed callback + * functions. + * + * @param pcb tcp_pcb to set the callback argument + * @param arg void pointer argument to pass to callback functions + */ +void +tcp_arg(struct tcp_pcb *pcb, void *arg) +{ + /* This function is allowed to be called for both listen pcbs and + connection pcbs. */ + pcb->callback_arg = arg; +} +#if LWIP_CALLBACK_API + +/** + * Used to specify the function that should be called when a TCP + * connection receives data. + * + * @param pcb tcp_pcb to set the recv callback + * @param recv callback function to call for this pcb when data is received + */ +void +tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) +{ + LWIP_ASSERT("invalid socket state for recv callback", pcb->state != LISTEN); + pcb->recv = recv; +} + +/** + * Used to specify the function that should be called when TCP data + * has been successfully delivered to the remote host. + * + * @param pcb tcp_pcb to set the sent callback + * @param sent callback function to call for this pcb when data is successfully sent + */ +void +tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) +{ + LWIP_ASSERT("invalid socket state for sent callback", pcb->state != LISTEN); + pcb->sent = sent; +} + +/** + * Used to specify the function that should be called when a fatal error + * has occured on the connection. + * + * @param pcb tcp_pcb to set the err callback + * @param err callback function to call for this pcb when a fatal error + * has occured on the connection + */ +void +tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) +{ + LWIP_ASSERT("invalid socket state for err callback", pcb->state != LISTEN); + pcb->errf = err; +} + +/** + * Used for specifying the function that should be called when a + * LISTENing connection has been connected to another host. + * + * @param pcb tcp_pcb to set the accept callback + * @param accept callback function to call for this pcb when LISTENing + * connection has been connected to another host + */ +void +tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) +{ + /* This function is allowed to be called for both listen pcbs and + connection pcbs. */ + pcb->accept = accept; +} +#endif /* LWIP_CALLBACK_API */ + + +/** + * Used to specify the function that should be called periodically + * from TCP. The interval is specified in terms of the TCP coarse + * timer interval, which is called twice a second. + * + */ +void +tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval) +{ + LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN); +#if LWIP_CALLBACK_API + pcb->poll = poll; +#else /* LWIP_CALLBACK_API */ + LWIP_UNUSED_ARG(poll); +#endif /* LWIP_CALLBACK_API */ + pcb->pollinterval = interval; +} + +/** + * Purges a TCP PCB. Removes any buffered data and frees the buffer memory + * (pcb->ooseq, pcb->unsent and pcb->unacked are freed). + * + * @param pcb tcp_pcb to purge. The pcb itself is not deallocated! + */ +void +tcp_pcb_purge(struct tcp_pcb *pcb) +{ + if (pcb->state != CLOSED && + pcb->state != TIME_WAIT && + pcb->state != LISTEN) { + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n")); + +#if TCP_LISTEN_BACKLOG + if (pcb->state == SYN_RCVD) { + /* Need to find the corresponding listen_pcb and decrease its accepts_pending */ + struct tcp_pcb_listen *lpcb; + LWIP_ASSERT("tcp_pcb_purge: pcb->state == SYN_RCVD but tcp_listen_pcbs is NULL", + tcp_listen_pcbs.listen_pcbs != NULL); + for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { + if ((lpcb->local_port == pcb->local_port) && + (ip_addr_isany(&lpcb->local_ip) || + ip_addr_cmp(&pcb->local_ip, &lpcb->local_ip))) { + /* port and address of the listen pcb match the timed-out pcb */ + LWIP_ASSERT("tcp_pcb_purge: listen pcb does not have accepts pending", + lpcb->accepts_pending > 0); + lpcb->accepts_pending--; + break; + } + } + } +#endif /* TCP_LISTEN_BACKLOG */ + + + if (pcb->refused_data != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->refused_data\n")); + pbuf_free(pcb->refused_data); + pcb->refused_data = NULL; + } + if (pcb->unsent != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n")); + } + if (pcb->unacked != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n")); + } +#if TCP_QUEUE_OOSEQ + if (pcb->ooseq != NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n")); + } + tcp_segs_free(pcb->ooseq); + pcb->ooseq = NULL; +#endif /* TCP_QUEUE_OOSEQ */ + + /* Stop the retransmission timer as it will expect data on unacked + queue if it fires */ + pcb->rtime = -1; + + tcp_segs_free(pcb->unsent); + tcp_segs_free(pcb->unacked); + pcb->unacked = pcb->unsent = NULL; +#if TCP_OVERSIZE + pcb->unsent_oversize = 0; +#endif /* TCP_OVERSIZE */ + } +} + +/** + * Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first. + * + * @param pcblist PCB list to purge. + * @param pcb tcp_pcb to purge. The pcb itself is NOT deallocated! + */ +void +tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) +{ + TCP_RMV(pcblist, pcb); + + tcp_pcb_purge(pcb); + + /* if there is an outstanding delayed ACKs, send it */ + if (pcb->state != TIME_WAIT && + pcb->state != LISTEN && + pcb->flags & TF_ACK_DELAY) { + pcb->flags |= TF_ACK_NOW; + tcp_output(pcb); + } + + if (pcb->state != LISTEN) { + LWIP_ASSERT("unsent segments leaking", pcb->unsent == NULL); + LWIP_ASSERT("unacked segments leaking", pcb->unacked == NULL); +#if TCP_QUEUE_OOSEQ + LWIP_ASSERT("ooseq segments leaking", pcb->ooseq == NULL); +#endif /* TCP_QUEUE_OOSEQ */ + } + + pcb->state = CLOSED; + + LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane()); +} + +/** + * Calculates a new initial sequence number for new connections. + * + * @return u32_t pseudo random sequence number + */ +u32_t +tcp_next_iss(void) +{ + static u32_t iss = 6510; + + iss += tcp_ticks; /* XXX */ + return iss; +} + +#if TCP_CALCULATE_EFF_SEND_MSS +/** + * Calcluates the effective send mss that can be used for a specific IP address + * by using ip_route to determin the netif used to send to the address and + * calculating the minimum of TCP_MSS and that netif's mtu (if set). + */ +u16_t +tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr) +{ + u16_t mss_s; + struct netif *outif; + + outif = ip_route(addr); + if ((outif != NULL) && (outif->mtu != 0)) { + mss_s = outif->mtu - IP_HLEN - TCP_HLEN; + /* RFC 1122, chap 4.2.2.6: + * Eff.snd.MSS = min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize + * We correct for TCP options in tcp_write(), and don't support IP options. + */ + sendmss = LWIP_MIN(sendmss, mss_s); + } + return sendmss; +} +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + +const char* +tcp_debug_state_str(enum tcp_state s) +{ + return tcp_state_str[s]; +} + +#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG +/** + * Print a tcp header for debugging purposes. + * + * @param tcphdr pointer to a struct tcp_hdr + */ +void +tcp_debug_print(struct tcp_hdr *tcphdr) +{ + LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n")); + LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(TCP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", + ntohs(tcphdr->src), ntohs(tcphdr->dest))); + LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (seq no)\n", + ntohl(tcphdr->seqno))); + LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (ack no)\n", + ntohl(tcphdr->ackno))); + LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(TCP_DEBUG, ("| %2"U16_F" | |%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"| %5"U16_F" | (hdrlen, flags (", + TCPH_HDRLEN(tcphdr), + TCPH_FLAGS(tcphdr) >> 5 & 1, + TCPH_FLAGS(tcphdr) >> 4 & 1, + TCPH_FLAGS(tcphdr) >> 3 & 1, + TCPH_FLAGS(tcphdr) >> 2 & 1, + TCPH_FLAGS(tcphdr) >> 1 & 1, + TCPH_FLAGS(tcphdr) & 1, + ntohs(tcphdr->wnd))); + tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); + LWIP_DEBUGF(TCP_DEBUG, ("), win)\n")); + LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04"X16_F" | %5"U16_F" | (chksum, urgp)\n", + ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); + LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); +} + +/** + * Print a tcp state for debugging purposes. + * + * @param s enum tcp_state to print + */ +void +tcp_debug_print_state(enum tcp_state s) +{ + LWIP_DEBUGF(TCP_DEBUG, ("State: %s\n", tcp_state_str[s])); +} + +/** + * Print tcp flags for debugging purposes. + * + * @param flags tcp flags, all active flags are printed + */ +void +tcp_debug_print_flags(u8_t flags) +{ + if (flags & TCP_FIN) { + LWIP_DEBUGF(TCP_DEBUG, ("FIN ")); + } + if (flags & TCP_SYN) { + LWIP_DEBUGF(TCP_DEBUG, ("SYN ")); + } + if (flags & TCP_RST) { + LWIP_DEBUGF(TCP_DEBUG, ("RST ")); + } + if (flags & TCP_PSH) { + LWIP_DEBUGF(TCP_DEBUG, ("PSH ")); + } + if (flags & TCP_ACK) { + LWIP_DEBUGF(TCP_DEBUG, ("ACK ")); + } + if (flags & TCP_URG) { + LWIP_DEBUGF(TCP_DEBUG, ("URG ")); + } + if (flags & TCP_ECE) { + LWIP_DEBUGF(TCP_DEBUG, ("ECE ")); + } + if (flags & TCP_CWR) { + LWIP_DEBUGF(TCP_DEBUG, ("CWR ")); + } + LWIP_DEBUGF(TCP_DEBUG, ("\n")); +} + +/** + * Print all tcp_pcbs in every list for debugging purposes. + */ +void +tcp_debug_print_pcbs(void) +{ + struct tcp_pcb *pcb; + LWIP_DEBUGF(TCP_DEBUG, ("Active PCB states:\n")); + for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", + pcb->local_port, pcb->remote_port, + pcb->snd_nxt, pcb->rcv_nxt)); + tcp_debug_print_state(pcb->state); + } + LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); + for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", + pcb->local_port, pcb->remote_port, + pcb->snd_nxt, pcb->rcv_nxt)); + tcp_debug_print_state(pcb->state); + } + LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); + for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", + pcb->local_port, pcb->remote_port, + pcb->snd_nxt, pcb->rcv_nxt)); + tcp_debug_print_state(pcb->state); + } +} + +/** + * Check state consistency of the tcp_pcb lists. + */ +s16_t +tcp_pcbs_sane(void) +{ + struct tcp_pcb *pcb; + for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != CLOSED", pcb->state != CLOSED); + LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != LISTEN", pcb->state != LISTEN); + LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); + } + for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_ASSERT("tcp_pcbs_sane: tw pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); + } + return 1; +} +#endif /* TCP_DEBUG */ + +#endif /* LWIP_TCP */ diff --git a/user/mpy/lib/lwip/src/core/tcp_in.c b/user/mpy/lib/lwip/src/core/tcp_in.c new file mode 100644 index 0000000..4ec971a --- /dev/null +++ b/user/mpy/lib/lwip/src/core/tcp_in.c @@ -0,0 +1,1619 @@ +/** + * @file + * Transmission Control Protocol, incoming traffic + * + * The input processing functions of the TCP layer. + * + * These functions are generally called in the order (ip_input() ->) + * tcp_input() -> * tcp_process() -> tcp_receive() (-> application). + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/tcp_impl.h" +#include "lwip/def.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/inet_chksum.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" +#include "arch/perf.h" + +/* These variables are global to all functions involved in the input + processing of TCP segments. They are set by the tcp_input() + function. */ +static struct tcp_seg inseg; +static struct tcp_hdr *tcphdr; +static struct ip_hdr *iphdr; +static u32_t seqno, ackno; +static u8_t flags; +static u16_t tcplen; + +static u8_t recv_flags; +static struct pbuf *recv_data; + +struct tcp_pcb *tcp_input_pcb; + +/* Forward declarations. */ +static err_t tcp_process(struct tcp_pcb *pcb); +static void tcp_receive(struct tcp_pcb *pcb); +static void tcp_parseopt(struct tcp_pcb *pcb); + +static err_t tcp_listen_input(struct tcp_pcb_listen *pcb); +static err_t tcp_timewait_input(struct tcp_pcb *pcb); + +/** + * The initial input processing of TCP. It verifies the TCP header, demultiplexes + * the segment between the PCBs and passes it on to tcp_process(), which implements + * the TCP finite state machine. This function is called by the IP layer (in + * ip_input()). + * + * @param p received TCP segment to process (p->payload pointing to the IP header) + * @param inp network interface on which this segment was received + */ +void +tcp_input(struct pbuf *p, struct netif *inp) +{ + struct tcp_pcb *pcb, *prev; + struct tcp_pcb_listen *lpcb; +#if SO_REUSE + struct tcp_pcb *lpcb_prev = NULL; + struct tcp_pcb_listen *lpcb_any = NULL; +#endif /* SO_REUSE */ + u8_t hdrlen; + err_t err; + + PERF_START; + + TCP_STATS_INC(tcp.recv); + snmp_inc_tcpinsegs(); + + iphdr = (struct ip_hdr *)p->payload; + tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4); + +#if TCP_INPUT_DEBUG + tcp_debug_print(tcphdr); +#endif + + /* remove header from payload */ + if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { + /* drop short packets */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%"U16_F" bytes) discarded\n", p->tot_len)); + TCP_STATS_INC(tcp.lenerr); + goto dropped; + } + + /* Don't even process incoming broadcasts/multicasts. */ + if (ip_addr_isbroadcast(¤t_iphdr_dest, inp) || + ip_addr_ismulticast(¤t_iphdr_dest)) { + TCP_STATS_INC(tcp.proterr); + goto dropped; + } + +#if CHECKSUM_CHECK_TCP + /* Verify TCP checksum. */ + if (inet_chksum_pseudo(p, ip_current_src_addr(), ip_current_dest_addr(), + IP_PROTO_TCP, p->tot_len) != 0) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04"X16_F"\n", + inet_chksum_pseudo(p, ip_current_src_addr(), ip_current_dest_addr(), + IP_PROTO_TCP, p->tot_len))); +#if TCP_DEBUG + tcp_debug_print(tcphdr); +#endif /* TCP_DEBUG */ + TCP_STATS_INC(tcp.chkerr); + goto dropped; + } +#endif + + /* Move the payload pointer in the pbuf so that it points to the + TCP data instead of the TCP header. */ + hdrlen = TCPH_HDRLEN(tcphdr); + if(pbuf_header(p, -(hdrlen * 4))){ + /* drop short packets */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet\n")); + TCP_STATS_INC(tcp.lenerr); + goto dropped; + } + + /* Convert fields in TCP header to host byte order. */ + tcphdr->src = ntohs(tcphdr->src); + tcphdr->dest = ntohs(tcphdr->dest); + seqno = tcphdr->seqno = ntohl(tcphdr->seqno); + ackno = tcphdr->ackno = ntohl(tcphdr->ackno); + tcphdr->wnd = ntohs(tcphdr->wnd); + + flags = TCPH_FLAGS(tcphdr); + tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0); + + /* Demultiplex an incoming segment. First, we check if it is destined + for an active connection. */ + prev = NULL; + + + for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); + LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); + LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN); + if (pcb->remote_port == tcphdr->src && + pcb->local_port == tcphdr->dest && + ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) && + ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest)) { + + /* Move this PCB to the front of the list so that subsequent + lookups will be faster (we exploit locality in TCP segment + arrivals). */ + LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb); + if (prev != NULL) { + prev->next = pcb->next; + pcb->next = tcp_active_pcbs; + tcp_active_pcbs = pcb; + } + LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb); + break; + } + prev = pcb; + } + + if (pcb == NULL) { + /* If it did not go to an active connection, we check the connections + in the TIME-WAIT state. */ + for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { + LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); + if (pcb->remote_port == tcphdr->src && + pcb->local_port == tcphdr->dest && + ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) && + ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest)) { + /* We don't really care enough to move this PCB to the front + of the list since we are not very likely to receive that + many segments for connections in TIME-WAIT. */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n")); + tcp_timewait_input(pcb); + pbuf_free(p); + return; + } + } + + /* Finally, if we still did not get a match, we check all PCBs that + are LISTENing for incoming connections. */ + prev = NULL; + for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { + if (lpcb->local_port == tcphdr->dest) { +#if SO_REUSE + if (ip_addr_cmp(&(lpcb->local_ip), ¤t_iphdr_dest)) { + /* found an exact match */ + break; + } else if(ip_addr_isany(&(lpcb->local_ip))) { + /* found an ANY-match */ + lpcb_any = lpcb; + lpcb_prev = prev; + } +#else /* SO_REUSE */ + if (ip_addr_cmp(&(lpcb->local_ip), ¤t_iphdr_dest) || + ip_addr_isany(&(lpcb->local_ip))) { + /* found a match */ + break; + } +#endif /* SO_REUSE */ + } + prev = (struct tcp_pcb *)lpcb; + } +#if SO_REUSE + /* first try specific local IP */ + if (lpcb == NULL) { + /* only pass to ANY if no specific local IP has been found */ + lpcb = lpcb_any; + prev = lpcb_prev; + } +#endif /* SO_REUSE */ + if (lpcb != NULL) { + /* Move this PCB to the front of the list so that subsequent + lookups will be faster (we exploit locality in TCP segment + arrivals). */ + if (prev != NULL) { + ((struct tcp_pcb_listen *)prev)->next = lpcb->next; + /* our successor is the remainder of the listening list */ + lpcb->next = tcp_listen_pcbs.listen_pcbs; + /* put this listening pcb at the head of the listening list */ + tcp_listen_pcbs.listen_pcbs = lpcb; + } + + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); + tcp_listen_input(lpcb); + pbuf_free(p); + return; + } + } + +#if TCP_INPUT_DEBUG + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ")); + tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n")); +#endif /* TCP_INPUT_DEBUG */ + + + if (pcb != NULL) { + /* The incoming segment belongs to a connection. */ +#if TCP_INPUT_DEBUG +#if TCP_DEBUG + tcp_debug_print_state(pcb->state); +#endif /* TCP_DEBUG */ +#endif /* TCP_INPUT_DEBUG */ + + /* Set up a tcp_seg structure. */ + inseg.next = NULL; + inseg.len = p->tot_len; + inseg.p = p; + inseg.tcphdr = tcphdr; + + recv_data = NULL; + recv_flags = 0; + + if (flags & TCP_PSH) { + p->flags |= PBUF_FLAG_PUSH; + } + + /* If there is data which was previously "refused" by upper layer */ + if (pcb->refused_data != NULL) { + if ((tcp_process_refused_data(pcb) == ERR_ABRT) || + ((pcb->refused_data != NULL) && (tcplen > 0))) { + /* pcb has been aborted or refused data is still refused and the new + segment contains data */ + TCP_STATS_INC(tcp.drop); + snmp_inc_tcpinerrs(); + goto aborted; + } + } + tcp_input_pcb = pcb; + err = tcp_process(pcb); + /* A return value of ERR_ABRT means that tcp_abort() was called + and that the pcb has been freed. If so, we don't do anything. */ + if (err != ERR_ABRT) { + if (recv_flags & TF_RESET) { + /* TF_RESET means that the connection was reset by the other + end. We then call the error callback to inform the + application that the connection is dead before we + deallocate the PCB. */ + TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST); + tcp_pcb_remove(&tcp_active_pcbs, pcb); + memp_free(MEMP_TCP_PCB, pcb); + } else if (recv_flags & TF_CLOSED) { + /* The connection has been closed and we will deallocate the + PCB. */ + if (!(pcb->flags & TF_RXCLOSED)) { + /* Connection closed although the application has only shut down the + tx side: call the PCB's err callback and indicate the closure to + ensure the application doesn't continue using the PCB. */ + TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_CLSD); + } + tcp_pcb_remove(&tcp_active_pcbs, pcb); + memp_free(MEMP_TCP_PCB, pcb); + } else { + err = ERR_OK; + /* If the application has registered a "sent" function to be + called when new send buffer space is available, we call it + now. */ + if (pcb->acked > 0) { + TCP_EVENT_SENT(pcb, pcb->acked, err); + if (err == ERR_ABRT) { + goto aborted; + } + } + + if (recv_data != NULL) { + LWIP_ASSERT("pcb->refused_data == NULL", pcb->refused_data == NULL); + if (pcb->flags & TF_RXCLOSED) { + /* received data although already closed -> abort (send RST) to + notify the remote host that not all data has been processed */ + pbuf_free(recv_data); + tcp_abort(pcb); + goto aborted; + } + + /* Notify application that data has been received. */ + TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err); + if (err == ERR_ABRT) { + goto aborted; + } + + /* If the upper layer can't receive this data, store it */ + if (err != ERR_OK) { + pcb->refused_data = recv_data; + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: keep incoming packet, because pcb is \"full\"\n")); + } + } + + /* If a FIN segment was received, we call the callback + function with a NULL buffer to indicate EOF. */ + if (recv_flags & TF_GOT_FIN) { + if (pcb->refused_data != NULL) { + /* Delay this if we have refused data. */ + pcb->refused_data->flags |= PBUF_FLAG_TCP_FIN; + } else { + /* correct rcv_wnd as the application won't call tcp_recved() + for the FIN's seqno */ + if (pcb->rcv_wnd != TCP_WND) { + pcb->rcv_wnd++; + } + TCP_EVENT_CLOSED(pcb, err); + if (err == ERR_ABRT) { + goto aborted; + } + } + } + + tcp_input_pcb = NULL; + /* Try to send something out. */ + tcp_output(pcb); +#if TCP_INPUT_DEBUG +#if TCP_DEBUG + tcp_debug_print_state(pcb->state); +#endif /* TCP_DEBUG */ +#endif /* TCP_INPUT_DEBUG */ + } + } + /* Jump target if pcb has been aborted in a callback (by calling tcp_abort()). + Below this line, 'pcb' may not be dereferenced! */ +aborted: + tcp_input_pcb = NULL; + recv_data = NULL; + + /* give up our reference to inseg.p */ + if (inseg.p != NULL) + { + pbuf_free(inseg.p); + inseg.p = NULL; + } + } else { + + /* If no matching PCB was found, send a TCP RST (reset) to the + sender. */ + LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); + if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) { + TCP_STATS_INC(tcp.proterr); + TCP_STATS_INC(tcp.drop); + tcp_rst(ackno, seqno + tcplen, + ip_current_dest_addr(), ip_current_src_addr(), + tcphdr->dest, tcphdr->src); + } + pbuf_free(p); + } + + LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); + PERF_STOP("tcp_input"); + return; +dropped: + TCP_STATS_INC(tcp.drop); + snmp_inc_tcpinerrs(); + pbuf_free(p); +} + +/** + * Called by tcp_input() when a segment arrives for a listening + * connection (from tcp_input()). + * + * @param pcb the tcp_pcb_listen for which a segment arrived + * @return ERR_OK if the segment was processed + * another err_t on error + * + * @note the return value is not (yet?) used in tcp_input() + * @note the segment which arrived is saved in global variables, therefore only the pcb + * involved is passed as a parameter to this function + */ +static err_t +tcp_listen_input(struct tcp_pcb_listen *pcb) +{ + struct tcp_pcb *npcb; + err_t rc; + + if (flags & TCP_RST) { + /* An incoming RST should be ignored. Return. */ + return ERR_OK; + } + + /* In the LISTEN state, we check for incoming SYN segments, + creates a new PCB, and responds with a SYN|ACK. */ + if (flags & TCP_ACK) { + /* For incoming segments with the ACK flag set, respond with a + RST. */ + LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n")); + tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } else if (flags & TCP_SYN) { + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest)); +#if TCP_LISTEN_BACKLOG + if (pcb->accepts_pending >= pcb->backlog) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: listen backlog exceeded for port %"U16_F"\n", tcphdr->dest)); + return ERR_ABRT; + } +#endif /* TCP_LISTEN_BACKLOG */ + npcb = tcp_alloc(pcb->prio); + /* If a new PCB could not be created (probably due to lack of memory), + we don't do anything, but rely on the sender will retransmit the + SYN at a time when we have more memory available. */ + if (npcb == NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); + TCP_STATS_INC(tcp.memerr); + return ERR_MEM; + } +#if TCP_LISTEN_BACKLOG + pcb->accepts_pending++; +#endif /* TCP_LISTEN_BACKLOG */ + /* Set up the new PCB. */ + ip_addr_copy(npcb->local_ip, current_iphdr_dest); + npcb->local_port = pcb->local_port; + ip_addr_copy(npcb->remote_ip, current_iphdr_src); + npcb->remote_port = tcphdr->src; + npcb->state = SYN_RCVD; + npcb->rcv_nxt = seqno + 1; + npcb->rcv_ann_right_edge = npcb->rcv_nxt; + npcb->snd_wnd = tcphdr->wnd; + npcb->snd_wnd_max = tcphdr->wnd; + npcb->ssthresh = npcb->snd_wnd; + npcb->snd_wl1 = seqno - 1;/* initialise to seqno-1 to force window update */ + npcb->callback_arg = pcb->callback_arg; +#if LWIP_CALLBACK_API + npcb->accept = pcb->accept; +#endif /* LWIP_CALLBACK_API */ + /* inherit socket options */ + npcb->so_options = pcb->so_options & SOF_INHERITED; + /* Register the new PCB so that we can begin receiving segments + for it. */ + TCP_REG_ACTIVE(npcb); + + /* Parse any options in the SYN. */ + tcp_parseopt(npcb); +#if TCP_CALCULATE_EFF_SEND_MSS + npcb->mss = tcp_eff_send_mss(npcb->mss, &(npcb->remote_ip)); +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + + snmp_inc_tcppassiveopens(); + + /* Send a SYN|ACK together with the MSS option. */ + rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK); + if (rc != ERR_OK) { + tcp_abandon(npcb, 0); + return rc; + } + return tcp_output(npcb); + } + return ERR_OK; +} + +/** + * Called by tcp_input() when a segment arrives for a connection in + * TIME_WAIT. + * + * @param pcb the tcp_pcb for which a segment arrived + * + * @note the segment which arrived is saved in global variables, therefore only the pcb + * involved is passed as a parameter to this function + */ +static err_t +tcp_timewait_input(struct tcp_pcb *pcb) +{ + /* RFC 1337: in TIME_WAIT, ignore RST and ACK FINs + any 'acceptable' segments */ + /* RFC 793 3.9 Event Processing - Segment Arrives: + * - first check sequence number - we skip that one in TIME_WAIT (always + * acceptable since we only send ACKs) + * - second check the RST bit (... return) */ + if (flags & TCP_RST) { + return ERR_OK; + } + /* - fourth, check the SYN bit, */ + if (flags & TCP_SYN) { + /* If an incoming segment is not acceptable, an acknowledgment + should be sent in reply */ + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) { + /* If the SYN is in the window it is an error, send a reset */ + tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), + tcphdr->dest, tcphdr->src); + return ERR_OK; + } + } else if (flags & TCP_FIN) { + /* - eighth, check the FIN bit: Remain in the TIME-WAIT state. + Restart the 2 MSL time-wait timeout.*/ + pcb->tmr = tcp_ticks; + } + + if ((tcplen > 0)) { + /* Acknowledge data, FIN or out-of-window SYN */ + pcb->flags |= TF_ACK_NOW; + return tcp_output(pcb); + } + return ERR_OK; +} + +/** + * Implements the TCP state machine. Called by tcp_input. In some + * states tcp_receive() is called to receive data. The tcp_seg + * argument will be freed by the caller (tcp_input()) unless the + * recv_data pointer in the pcb is set. + * + * @param pcb the tcp_pcb for which a segment arrived + * + * @note the segment which arrived is saved in global variables, therefore only the pcb + * involved is passed as a parameter to this function + */ +static err_t +tcp_process(struct tcp_pcb *pcb) +{ + struct tcp_seg *rseg; + u8_t acceptable = 0; + err_t err; + + err = ERR_OK; + + /* Process incoming RST segments. */ + if (flags & TCP_RST) { + /* First, determine if the reset is acceptable. */ + if (pcb->state == SYN_SENT) { + if (ackno == pcb->snd_nxt) { + acceptable = 1; + } + } else { + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, + pcb->rcv_nxt+pcb->rcv_wnd)) { + acceptable = 1; + } + } + + if (acceptable) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n")); + LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED); + recv_flags |= TF_RESET; + pcb->flags &= ~TF_ACK_DELAY; + return ERR_RST; + } else { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", + seqno, pcb->rcv_nxt)); + LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", + seqno, pcb->rcv_nxt)); + return ERR_OK; + } + } + + if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) { + /* Cope with new connection attempt after remote end crashed */ + tcp_ack_now(pcb); + return ERR_OK; + } + + if ((pcb->flags & TF_RXCLOSED) == 0) { + /* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */ + pcb->tmr = tcp_ticks; + } + pcb->keep_cnt_sent = 0; + + tcp_parseopt(pcb); + + /* Do different things depending on the TCP state. */ + switch (pcb->state) { + case SYN_SENT: + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %"U32_F" pcb->snd_nxt %"U32_F" unacked %"U32_F"\n", ackno, + pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); + /* received SYN ACK with expected sequence number? */ + if ((flags & TCP_ACK) && (flags & TCP_SYN) + && ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) { + pcb->snd_buf++; + pcb->rcv_nxt = seqno + 1; + pcb->rcv_ann_right_edge = pcb->rcv_nxt; + pcb->lastack = ackno; + pcb->snd_wnd = tcphdr->wnd; + pcb->snd_wnd_max = tcphdr->wnd; + pcb->snd_wl1 = seqno - 1; /* initialise to seqno - 1 to force window update */ + pcb->state = ESTABLISHED; + +#if TCP_CALCULATE_EFF_SEND_MSS + pcb->mss = tcp_eff_send_mss(pcb->mss, &(pcb->remote_ip)); +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + + /* Set ssthresh again after changing pcb->mss (already set in tcp_connect + * but for the default value of pcb->mss) */ + pcb->ssthresh = pcb->mss * 10; + + pcb->cwnd = ((pcb->cwnd == 1) ? (pcb->mss * 2) : pcb->mss); + LWIP_ASSERT("pcb->snd_queuelen > 0", (pcb->snd_queuelen > 0)); + --pcb->snd_queuelen; + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %"U16_F"\n", (u16_t)pcb->snd_queuelen)); + rseg = pcb->unacked; + pcb->unacked = rseg->next; + tcp_seg_free(rseg); + + /* If there's nothing left to acknowledge, stop the retransmit + timer, otherwise reset it to start again */ + if(pcb->unacked == NULL) + pcb->rtime = -1; + else { + pcb->rtime = 0; + pcb->nrtx = 0; + } + + /* Call the user specified function to call when sucessfully + * connected. */ + TCP_EVENT_CONNECTED(pcb, ERR_OK, err); + if (err == ERR_ABRT) { + return ERR_ABRT; + } + tcp_ack_now(pcb); + } + /* received ACK? possibly a half-open connection */ + else if (flags & TCP_ACK) { + /* send a RST to bring the other side in a non-synchronized state. */ + tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), + tcphdr->dest, tcphdr->src); + } + break; + case SYN_RCVD: + if (flags & TCP_ACK) { + /* expected ACK number? */ + if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) { + u16_t old_cwnd; + pcb->state = ESTABLISHED; + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); +#if LWIP_CALLBACK_API + LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL); +#endif + /* Call the accept function. */ + TCP_EVENT_ACCEPT(pcb, ERR_OK, err); + if (err != ERR_OK) { + /* If the accept function returns with an error, we abort + * the connection. */ + /* Already aborted? */ + if (err != ERR_ABRT) { + tcp_abort(pcb); + } + return ERR_ABRT; + } + old_cwnd = pcb->cwnd; + /* If there was any data contained within this ACK, + * we'd better pass it on to the application as well. */ + tcp_receive(pcb); + + /* Prevent ACK for SYN to generate a sent event */ + if (pcb->acked != 0) { + pcb->acked--; + } + + pcb->cwnd = ((old_cwnd == 1) ? (pcb->mss * 2) : pcb->mss); + + if (recv_flags & TF_GOT_FIN) { + tcp_ack_now(pcb); + pcb->state = CLOSE_WAIT; + } + } else { + /* incorrect ACK number, send RST */ + tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), + tcphdr->dest, tcphdr->src); + } + } else if ((flags & TCP_SYN) && (seqno == pcb->rcv_nxt - 1)) { + /* Looks like another copy of the SYN - retransmit our SYN-ACK */ + tcp_rexmit(pcb); + } + break; + case CLOSE_WAIT: + /* FALLTHROUGH */ + case ESTABLISHED: + tcp_receive(pcb); + if (recv_flags & TF_GOT_FIN) { /* passive close */ + tcp_ack_now(pcb); + pcb->state = CLOSE_WAIT; + } + break; + case FIN_WAIT_1: + tcp_receive(pcb); + if (recv_flags & TF_GOT_FIN) { + if ((flags & TCP_ACK) && (ackno == pcb->snd_nxt)) { + LWIP_DEBUGF(TCP_DEBUG, + ("TCP connection closed: FIN_WAIT_1 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + tcp_ack_now(pcb); + tcp_pcb_purge(pcb); + TCP_RMV_ACTIVE(pcb); + pcb->state = TIME_WAIT; + TCP_REG(&tcp_tw_pcbs, pcb); + } else { + tcp_ack_now(pcb); + pcb->state = CLOSING; + } + } else if ((flags & TCP_ACK) && (ackno == pcb->snd_nxt)) { + pcb->state = FIN_WAIT_2; + } + break; + case FIN_WAIT_2: + tcp_receive(pcb); + if (recv_flags & TF_GOT_FIN) { + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: FIN_WAIT_2 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + tcp_ack_now(pcb); + tcp_pcb_purge(pcb); + TCP_RMV_ACTIVE(pcb); + pcb->state = TIME_WAIT; + TCP_REG(&tcp_tw_pcbs, pcb); + } + break; + case CLOSING: + tcp_receive(pcb); + if (flags & TCP_ACK && ackno == pcb->snd_nxt) { + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: CLOSING %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + tcp_pcb_purge(pcb); + TCP_RMV_ACTIVE(pcb); + pcb->state = TIME_WAIT; + TCP_REG(&tcp_tw_pcbs, pcb); + } + break; + case LAST_ACK: + tcp_receive(pcb); + if (flags & TCP_ACK && ackno == pcb->snd_nxt) { + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: LAST_ACK %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + /* bugfix #21699: don't set pcb->state to CLOSED here or we risk leaking segments */ + recv_flags |= TF_CLOSED; + } + break; + default: + break; + } + return ERR_OK; +} + +#if TCP_QUEUE_OOSEQ +/** + * Insert segment into the list (segments covered with new one will be deleted) + * + * Called from tcp_receive() + */ +static void +tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next) +{ + struct tcp_seg *old_seg; + + if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { + /* received segment overlaps all following segments */ + tcp_segs_free(next); + next = NULL; + } + else { + /* delete some following segments + oos queue may have segments with FIN flag */ + while (next && + TCP_SEQ_GEQ((seqno + cseg->len), + (next->tcphdr->seqno + next->len))) { + /* cseg with FIN already processed */ + if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) { + TCPH_SET_FLAG(cseg->tcphdr, TCP_FIN); + } + old_seg = next; + next = next->next; + tcp_seg_free(old_seg); + } + if (next && + TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) { + /* We need to trim the incoming segment. */ + cseg->len = (u16_t)(next->tcphdr->seqno - seqno); + pbuf_realloc(cseg->p, cseg->len); + } + } + cseg->next = next; +} +#endif /* TCP_QUEUE_OOSEQ */ + +/** + * Called by tcp_process. Checks if the given segment is an ACK for outstanding + * data, and if so frees the memory of the buffered data. Next, is places the + * segment on any of the receive queues (pcb->recved or pcb->ooseq). If the segment + * is buffered, the pbuf is referenced by pbuf_ref so that it will not be freed until + * it has been removed from the buffer. + * + * If the incoming segment constitutes an ACK for a segment that was used for RTT + * estimation, the RTT is estimated here as well. + * + * Called from tcp_process(). + */ +static void +tcp_receive(struct tcp_pcb *pcb) +{ + struct tcp_seg *next; +#if TCP_QUEUE_OOSEQ + struct tcp_seg *prev, *cseg; +#endif /* TCP_QUEUE_OOSEQ */ + struct pbuf *p; + s32_t off; + s16_t m; + u32_t right_wnd_edge; + u16_t new_tot_len; + int found_dupack = 0; +#if TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS + u32_t ooseq_blen; + u16_t ooseq_qlen; +#endif /* TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS */ + + LWIP_ASSERT("tcp_receive: wrong state", pcb->state >= ESTABLISHED); + + if (flags & TCP_ACK) { + right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2; + + /* Update window. */ + if (TCP_SEQ_LT(pcb->snd_wl1, seqno) || + (pcb->snd_wl1 == seqno && TCP_SEQ_LT(pcb->snd_wl2, ackno)) || + (pcb->snd_wl2 == ackno && tcphdr->wnd > pcb->snd_wnd)) { + pcb->snd_wnd = tcphdr->wnd; + /* keep track of the biggest window announced by the remote host to calculate + the maximum segment size */ + if (pcb->snd_wnd_max < tcphdr->wnd) { + pcb->snd_wnd_max = tcphdr->wnd; + } + pcb->snd_wl1 = seqno; + pcb->snd_wl2 = ackno; + if (pcb->snd_wnd == 0) { + if (pcb->persist_backoff == 0) { + /* start persist timer */ + pcb->persist_cnt = 0; + pcb->persist_backoff = 1; + } + } else if (pcb->persist_backoff > 0) { + /* stop persist timer */ + pcb->persist_backoff = 0; + } + LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %"U16_F"\n", pcb->snd_wnd)); +#if TCP_WND_DEBUG + } else { + if (pcb->snd_wnd != tcphdr->wnd) { + LWIP_DEBUGF(TCP_WND_DEBUG, + ("tcp_receive: no window update lastack %"U32_F" ackno %" + U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n", + pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); + } +#endif /* TCP_WND_DEBUG */ + } + + /* (From Stevens TCP/IP Illustrated Vol II, p970.) Its only a + * duplicate ack if: + * 1) It doesn't ACK new data + * 2) length of received packet is zero (i.e. no payload) + * 3) the advertised window hasn't changed + * 4) There is outstanding unacknowledged data (retransmission timer running) + * 5) The ACK is == biggest ACK sequence number so far seen (snd_una) + * + * If it passes all five, should process as a dupack: + * a) dupacks < 3: do nothing + * b) dupacks == 3: fast retransmit + * c) dupacks > 3: increase cwnd + * + * If it only passes 1-3, should reset dupack counter (and add to + * stats, which we don't do in lwIP) + * + * If it only passes 1, should reset dupack counter + * + */ + + /* Clause 1 */ + if (TCP_SEQ_LEQ(ackno, pcb->lastack)) { + pcb->acked = 0; + /* Clause 2 */ + if (tcplen == 0) { + /* Clause 3 */ + if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge){ + /* Clause 4 */ + if (pcb->rtime >= 0) { + /* Clause 5 */ + if (pcb->lastack == ackno) { + found_dupack = 1; + if ((u8_t)(pcb->dupacks + 1) > pcb->dupacks) { + ++pcb->dupacks; + } + if (pcb->dupacks > 3) { + /* Inflate the congestion window, but not if it means that + the value overflows. */ + if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { + pcb->cwnd += pcb->mss; + } + } else if (pcb->dupacks == 3) { + /* Do fast retransmit */ + tcp_rexmit_fast(pcb); + } + } + } + } + } + /* If Clause (1) or more is true, but not a duplicate ack, reset + * count of consecutive duplicate acks */ + if (!found_dupack) { + pcb->dupacks = 0; + } + } else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){ + /* We come here when the ACK acknowledges new data. */ + + /* Reset the "IN Fast Retransmit" flag, since we are no longer + in fast retransmit. Also reset the congestion window to the + slow start threshold. */ + if (pcb->flags & TF_INFR) { + pcb->flags &= ~TF_INFR; + pcb->cwnd = pcb->ssthresh; + } + + /* Reset the number of retransmissions. */ + pcb->nrtx = 0; + + /* Reset the retransmission time-out. */ + pcb->rto = (pcb->sa >> 3) + pcb->sv; + + /* Update the send buffer space. Diff between the two can never exceed 64K? */ + pcb->acked = (u16_t)(ackno - pcb->lastack); + + pcb->snd_buf += pcb->acked; + + /* Reset the fast retransmit variables. */ + pcb->dupacks = 0; + pcb->lastack = ackno; + + /* Update the congestion control variables (cwnd and + ssthresh). */ + if (pcb->state >= ESTABLISHED) { + if (pcb->cwnd < pcb->ssthresh) { + if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { + pcb->cwnd += pcb->mss; + } + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %"U16_F"\n", pcb->cwnd)); + } else { + u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd); + if (new_cwnd > pcb->cwnd) { + pcb->cwnd = new_cwnd; + } + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %"U16_F"\n", pcb->cwnd)); + } + } + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n", + ackno, + pcb->unacked != NULL? + ntohl(pcb->unacked->tcphdr->seqno): 0, + pcb->unacked != NULL? + ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); + + /* Remove segment from the unacknowledged list if the incoming + ACK acknowlegdes them. */ + while (pcb->unacked != NULL && + TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + + TCP_TCPLEN(pcb->unacked), ackno)) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unacked\n", + ntohl(pcb->unacked->tcphdr->seqno), + ntohl(pcb->unacked->tcphdr->seqno) + + TCP_TCPLEN(pcb->unacked))); + + next = pcb->unacked; + pcb->unacked = pcb->unacked->next; + + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); + LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); + /* Prevent ACK for FIN to generate a sent event */ + if ((pcb->acked != 0) && ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) != 0)) { + pcb->acked--; + } + + pcb->snd_queuelen -= pbuf_clen(next->p); + tcp_seg_free(next); + + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unacked)\n", (u16_t)pcb->snd_queuelen)); + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || + pcb->unsent != NULL); + } + } + + /* If there's nothing left to acknowledge, stop the retransmit + timer, otherwise reset it to start again */ + if(pcb->unacked == NULL) + pcb->rtime = -1; + else + pcb->rtime = 0; + + pcb->polltmr = 0; + } else { + /* Fix bug bug #21582: out of sequence ACK, didn't really ack anything */ + pcb->acked = 0; + } + + /* We go through the ->unsent list to see if any of the segments + on the list are acknowledged by the ACK. This may seem + strange since an "unsent" segment shouldn't be acked. The + rationale is that lwIP puts all outstanding segments on the + ->unsent list after a retransmission, so these segments may + in fact have been sent once. */ + while (pcb->unsent != NULL && + TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + + TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", + ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + + TCP_TCPLEN(pcb->unsent))); + + next = pcb->unsent; + pcb->unsent = pcb->unsent->next; +#if TCP_OVERSIZE + if (pcb->unsent == NULL) { + pcb->unsent_oversize = 0; + } +#endif /* TCP_OVERSIZE */ + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); + LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); + /* Prevent ACK for FIN to generate a sent event */ + if ((pcb->acked != 0) && ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) != 0)) { + pcb->acked--; + } + pcb->snd_queuelen -= pbuf_clen(next->p); + tcp_seg_free(next); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unsent)\n", (u16_t)pcb->snd_queuelen)); + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_receive: valid queue length", + pcb->unacked != NULL || pcb->unsent != NULL); + } + } + /* End of ACK for new data processing. */ + + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %"U32_F" rtseq %"U32_F" ackno %"U32_F"\n", + pcb->rttest, pcb->rtseq, ackno)); + + /* RTT estimation calculations. This is done by checking if the + incoming segment acknowledges the segment we use to take a + round-trip time measurement. */ + if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) { + /* diff between this shouldn't exceed 32K since this are tcp timer ticks + and a round-trip shouldn't be that long... */ + m = (s16_t)(tcp_ticks - pcb->rttest); + + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %"U16_F" ticks (%"U16_F" msec).\n", + m, m * TCP_SLOW_INTERVAL)); + + /* This is taken directly from VJs original code in his paper */ + m = m - (pcb->sa >> 3); + pcb->sa += m; + if (m < 0) { + m = -m; + } + m = m - (pcb->sv >> 2); + pcb->sv += m; + pcb->rto = (pcb->sa >> 3) + pcb->sv; + + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %"U16_F" (%"U16_F" milliseconds)\n", + pcb->rto, pcb->rto * TCP_SLOW_INTERVAL)); + + pcb->rttest = 0; + } + } + + /* If the incoming segment contains data, we must process it + further unless the pcb already received a FIN. + (RFC 793, chapeter 3.9, "SEGMENT ARRIVES" in states CLOSE-WAIT, CLOSING, + LAST-ACK and TIME-WAIT: "Ignore the segment text.") */ + if ((tcplen > 0) && (pcb->state < CLOSE_WAIT)) { + /* This code basically does three things: + + +) If the incoming segment contains data that is the next + in-sequence data, this data is passed to the application. This + might involve trimming the first edge of the data. The rcv_nxt + variable and the advertised window are adjusted. + + +) If the incoming segment has data that is above the next + sequence number expected (->rcv_nxt), the segment is placed on + the ->ooseq queue. This is done by finding the appropriate + place in the ->ooseq queue (which is ordered by sequence + number) and trim the segment in both ends if needed. An + immediate ACK is sent to indicate that we received an + out-of-sequence segment. + + +) Finally, we check if the first segment on the ->ooseq queue + now is in sequence (i.e., if rcv_nxt >= ooseq->seqno). If + rcv_nxt > ooseq->seqno, we must trim the first edge of the + segment on ->ooseq before we adjust rcv_nxt. The data in the + segments that are now on sequence are chained onto the + incoming segment so that we only need to call the application + once. + */ + + /* First, we check if we must trim the first edge. We have to do + this if the sequence number of the incoming segment is less + than rcv_nxt, and the sequence number plus the length of the + segment is larger than rcv_nxt. */ + /* if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ + if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {*/ + if (TCP_SEQ_BETWEEN(pcb->rcv_nxt, seqno + 1, seqno + tcplen - 1)){ + /* Trimming the first edge is done by pushing the payload + pointer in the pbuf downwards. This is somewhat tricky since + we do not want to discard the full contents of the pbuf up to + the new starting point of the data since we have to keep the + TCP header which is present in the first pbuf in the chain. + + What is done is really quite a nasty hack: the first pbuf in + the pbuf chain is pointed to by inseg.p. Since we need to be + able to deallocate the whole pbuf, we cannot change this + inseg.p pointer to point to any of the later pbufs in the + chain. Instead, we point the ->payload pointer in the first + pbuf to data in one of the later pbufs. We also set the + inseg.data pointer to point to the right place. This way, the + ->p pointer will still point to the first pbuf, but the + ->p->payload pointer will point to data in another pbuf. + + After we are done with adjusting the pbuf pointers we must + adjust the ->data pointer in the seg and the segment + length.*/ + + off = pcb->rcv_nxt - seqno; + p = inseg.p; + LWIP_ASSERT("inseg.p != NULL", inseg.p); + LWIP_ASSERT("insane offset!", (off < 0x7fff)); + if (inseg.p->len < off) { + LWIP_ASSERT("pbuf too short!", (((s32_t)inseg.p->tot_len) >= off)); + new_tot_len = (u16_t)(inseg.p->tot_len - off); + while (p->len < off) { + off -= p->len; + /* KJM following line changed (with addition of new_tot_len var) + to fix bug #9076 + inseg.p->tot_len -= p->len; */ + p->tot_len = new_tot_len; + p->len = 0; + p = p->next; + } + if(pbuf_header(p, (s16_t)-off)) { + /* Do we need to cope with this failing? Assert for now */ + LWIP_ASSERT("pbuf_header failed", 0); + } + } else { + if(pbuf_header(inseg.p, (s16_t)-off)) { + /* Do we need to cope with this failing? Assert for now */ + LWIP_ASSERT("pbuf_header failed", 0); + } + } + inseg.len -= (u16_t)(pcb->rcv_nxt - seqno); + inseg.tcphdr->seqno = seqno = pcb->rcv_nxt; + } + else { + if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ + /* the whole segment is < rcv_nxt */ + /* must be a duplicate of a packet that has already been correctly handled */ + + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %"U32_F"\n", seqno)); + tcp_ack_now(pcb); + } + } + + /* The sequence number must be within the window (above rcv_nxt + and below rcv_nxt + rcv_wnd) in order to be further + processed. */ + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, + pcb->rcv_nxt + pcb->rcv_wnd - 1)){ + if (pcb->rcv_nxt == seqno) { + /* The incoming segment is the next in sequence. We check if + we have to trim the end of the segment and update rcv_nxt + and pass the data to the application. */ + tcplen = TCP_TCPLEN(&inseg); + + if (tcplen > pcb->rcv_wnd) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, + ("tcp_receive: other end overran receive window" + "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", + seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); + if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { + /* Must remove the FIN from the header as we're trimming + * that byte of sequence-space from the packet */ + TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN); + } + /* Adjust length of segment to fit in the window. */ + inseg.len = pcb->rcv_wnd; + if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { + inseg.len -= 1; + } + pbuf_realloc(inseg.p, inseg.len); + tcplen = TCP_TCPLEN(&inseg); + LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n", + (seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd)); + } +#if TCP_QUEUE_OOSEQ + /* Received in-sequence data, adjust ooseq data if: + - FIN has been received or + - inseq overlaps with ooseq */ + if (pcb->ooseq != NULL) { + if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, + ("tcp_receive: received in-order FIN, binning ooseq queue\n")); + /* Received in-order FIN means anything that was received + * out of order must now have been received in-order, so + * bin the ooseq queue */ + while (pcb->ooseq != NULL) { + struct tcp_seg *old_ooseq = pcb->ooseq; + pcb->ooseq = pcb->ooseq->next; + tcp_seg_free(old_ooseq); + } + } else { + next = pcb->ooseq; + /* Remove all segments on ooseq that are covered by inseg already. + * FIN is copied from ooseq to inseg if present. */ + while (next && + TCP_SEQ_GEQ(seqno + tcplen, + next->tcphdr->seqno + next->len)) { + /* inseg cannot have FIN here (already processed above) */ + if (TCPH_FLAGS(next->tcphdr) & TCP_FIN && + (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) == 0) { + TCPH_SET_FLAG(inseg.tcphdr, TCP_FIN); + tcplen = TCP_TCPLEN(&inseg); + } + prev = next; + next = next->next; + tcp_seg_free(prev); + } + /* Now trim right side of inseg if it overlaps with the first + * segment on ooseq */ + if (next && + TCP_SEQ_GT(seqno + tcplen, + next->tcphdr->seqno)) { + /* inseg cannot have FIN here (already processed above) */ + inseg.len = (u16_t)(next->tcphdr->seqno - seqno); + if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { + inseg.len -= 1; + } + pbuf_realloc(inseg.p, inseg.len); + tcplen = TCP_TCPLEN(&inseg); + LWIP_ASSERT("tcp_receive: segment not trimmed correctly to ooseq queue\n", + (seqno + tcplen) == next->tcphdr->seqno); + } + pcb->ooseq = next; + } + } +#endif /* TCP_QUEUE_OOSEQ */ + + pcb->rcv_nxt = seqno + tcplen; + + /* Update the receiver's (our) window. */ + LWIP_ASSERT("tcp_receive: tcplen > rcv_wnd\n", pcb->rcv_wnd >= tcplen); + pcb->rcv_wnd -= tcplen; + + tcp_update_rcv_ann_wnd(pcb); + + /* If there is data in the segment, we make preparations to + pass this up to the application. The ->recv_data variable + is used for holding the pbuf that goes to the + application. The code for reassembling out-of-sequence data + chains its data on this pbuf as well. + + If the segment was a FIN, we set the TF_GOT_FIN flag that will + be used to indicate to the application that the remote side has + closed its end of the connection. */ + if (inseg.p->tot_len > 0) { + recv_data = inseg.p; + /* Since this pbuf now is the responsibility of the + application, we delete our reference to it so that we won't + (mistakingly) deallocate it. */ + inseg.p = NULL; + } + if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.\n")); + recv_flags |= TF_GOT_FIN; + } + +#if TCP_QUEUE_OOSEQ + /* We now check if we have segments on the ->ooseq queue that + are now in sequence. */ + while (pcb->ooseq != NULL && + pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) { + + cseg = pcb->ooseq; + seqno = pcb->ooseq->tcphdr->seqno; + + pcb->rcv_nxt += TCP_TCPLEN(cseg); + LWIP_ASSERT("tcp_receive: ooseq tcplen > rcv_wnd\n", + pcb->rcv_wnd >= TCP_TCPLEN(cseg)); + pcb->rcv_wnd -= TCP_TCPLEN(cseg); + + tcp_update_rcv_ann_wnd(pcb); + + if (cseg->p->tot_len > 0) { + /* Chain this pbuf onto the pbuf that we will pass to + the application. */ + if (recv_data) { + pbuf_cat(recv_data, cseg->p); + } else { + recv_data = cseg->p; + } + cseg->p = NULL; + } + if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.\n")); + recv_flags |= TF_GOT_FIN; + if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */ + pcb->state = CLOSE_WAIT; + } + } + + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } +#endif /* TCP_QUEUE_OOSEQ */ + + + /* Acknowledge the segment(s). */ + tcp_ack(pcb); + + } else { + /* We get here if the incoming segment is out-of-sequence. */ + tcp_send_empty_ack(pcb); +#if TCP_QUEUE_OOSEQ + /* We queue the segment on the ->ooseq queue. */ + if (pcb->ooseq == NULL) { + pcb->ooseq = tcp_seg_copy(&inseg); + } else { + /* If the queue is not empty, we walk through the queue and + try to find a place where the sequence number of the + incoming segment is between the sequence numbers of the + previous and the next segment on the ->ooseq queue. That is + the place where we put the incoming segment. If needed, we + trim the second edges of the previous and the incoming + segment so that it will fit into the sequence. + + If the incoming segment has the same sequence number as a + segment on the ->ooseq queue, we discard the segment that + contains less data. */ + + prev = NULL; + for(next = pcb->ooseq; next != NULL; next = next->next) { + if (seqno == next->tcphdr->seqno) { + /* The sequence number of the incoming segment is the + same as the sequence number of the segment on + ->ooseq. We check the lengths to see which one to + discard. */ + if (inseg.len > next->len) { + /* The incoming segment is larger than the old + segment. We replace some segments with the new + one. */ + cseg = tcp_seg_copy(&inseg); + if (cseg != NULL) { + if (prev != NULL) { + prev->next = cseg; + } else { + pcb->ooseq = cseg; + } + tcp_oos_insert_segment(cseg, next); + } + break; + } else { + /* Either the lenghts are the same or the incoming + segment was smaller than the old one; in either + case, we ditch the incoming segment. */ + break; + } + } else { + if (prev == NULL) { + if (TCP_SEQ_LT(seqno, next->tcphdr->seqno)) { + /* The sequence number of the incoming segment is lower + than the sequence number of the first segment on the + queue. We put the incoming segment first on the + queue. */ + cseg = tcp_seg_copy(&inseg); + if (cseg != NULL) { + pcb->ooseq = cseg; + tcp_oos_insert_segment(cseg, next); + } + break; + } + } else { + /*if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) && + TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {*/ + if (TCP_SEQ_BETWEEN(seqno, prev->tcphdr->seqno+1, next->tcphdr->seqno-1)) { + /* The sequence number of the incoming segment is in + between the sequence numbers of the previous and + the next segment on ->ooseq. We trim trim the previous + segment, delete next segments that included in received segment + and trim received, if needed. */ + cseg = tcp_seg_copy(&inseg); + if (cseg != NULL) { + if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) { + /* We need to trim the prev segment. */ + prev->len = (u16_t)(seqno - prev->tcphdr->seqno); + pbuf_realloc(prev->p, prev->len); + } + prev->next = cseg; + tcp_oos_insert_segment(cseg, next); + } + break; + } + } + /* If the "next" segment is the last segment on the + ooseq queue, we add the incoming segment to the end + of the list. */ + if (next->next == NULL && + TCP_SEQ_GT(seqno, next->tcphdr->seqno)) { + if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) { + /* segment "next" already contains all data */ + break; + } + next->next = tcp_seg_copy(&inseg); + if (next->next != NULL) { + if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) { + /* We need to trim the last segment. */ + next->len = (u16_t)(seqno - next->tcphdr->seqno); + pbuf_realloc(next->p, next->len); + } + /* check if the remote side overruns our receive window */ + if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, + ("tcp_receive: other end overran receive window" + "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", + seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); + if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) { + /* Must remove the FIN from the header as we're trimming + * that byte of sequence-space from the packet */ + TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN); + } + /* Adjust length of segment to fit in the window. */ + next->next->len = pcb->rcv_nxt + pcb->rcv_wnd - seqno; + pbuf_realloc(next->next->p, next->next->len); + tcplen = TCP_TCPLEN(next->next); + LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n", + (seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd)); + } + } + break; + } + } + prev = next; + } + } +#if TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS + /* Check that the data on ooseq doesn't exceed one of the limits + and throw away everything above that limit. */ + ooseq_blen = 0; + ooseq_qlen = 0; + prev = NULL; + for(next = pcb->ooseq; next != NULL; prev = next, next = next->next) { + struct pbuf *p = next->p; + ooseq_blen += p->tot_len; + ooseq_qlen += pbuf_clen(p); + if ((ooseq_blen > TCP_OOSEQ_MAX_BYTES) || + (ooseq_qlen > TCP_OOSEQ_MAX_PBUFS)) { + /* too much ooseq data, dump this and everything after it */ + tcp_segs_free(next); + if (prev == NULL) { + /* first ooseq segment is too much, dump the whole queue */ + pcb->ooseq = NULL; + } else { + /* just dump 'next' and everything after it */ + prev->next = NULL; + } + break; + } + } +#endif /* TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS */ +#endif /* TCP_QUEUE_OOSEQ */ + } + } else { + /* The incoming segment is not withing the window. */ + tcp_send_empty_ack(pcb); + } + } else { + /* Segments with length 0 is taken care of here. Segments that + fall out of the window are ACKed. */ + /*if (TCP_SEQ_GT(pcb->rcv_nxt, seqno) || + TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {*/ + if(!TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd-1)){ + tcp_ack_now(pcb); + } + } +} + +/** + * Parses the options contained in the incoming segment. + * + * Called from tcp_listen_input() and tcp_process(). + * Currently, only the MSS option is supported! + * + * @param pcb the tcp_pcb for which a segment arrived + */ +static void +tcp_parseopt(struct tcp_pcb *pcb) +{ + u16_t c, max_c; + u16_t mss; + u8_t *opts, opt; +#if LWIP_TCP_TIMESTAMPS + u32_t tsval; +#endif + + opts = (u8_t *)tcphdr + TCP_HLEN; + + /* Parse the TCP MSS option, if present. */ + if(TCPH_HDRLEN(tcphdr) > 0x5) { + max_c = (TCPH_HDRLEN(tcphdr) - 5) << 2; + for (c = 0; c < max_c; ) { + opt = opts[c]; + switch (opt) { + case 0x00: + /* End of options. */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: EOL\n")); + return; + case 0x01: + /* NOP option. */ + ++c; + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: NOP\n")); + break; + case 0x02: + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: MSS\n")); + if (opts[c + 1] != 0x04 || c + 0x04 > max_c) { + /* Bad length */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); + return; + } + /* An MSS option with the right option length. */ + mss = (opts[c + 2] << 8) | opts[c + 3]; + /* Limit the mss to the configured TCP_MSS and prevent division by zero */ + pcb->mss = ((mss > TCP_MSS) || (mss == 0)) ? TCP_MSS : mss; + /* Advance to next option */ + c += 0x04; + break; +#if LWIP_TCP_TIMESTAMPS + case 0x08: + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: TS\n")); + if (opts[c + 1] != 0x0A || c + 0x0A > max_c) { + /* Bad length */ + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); + return; + } + /* TCP timestamp option with valid length */ + tsval = (opts[c+2]) | (opts[c+3] << 8) | + (opts[c+4] << 16) | (opts[c+5] << 24); + if (flags & TCP_SYN) { + pcb->ts_recent = ntohl(tsval); + pcb->flags |= TF_TIMESTAMP; + } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno+tcplen)) { + pcb->ts_recent = ntohl(tsval); + } + /* Advance to next option */ + c += 0x0A; + break; +#endif + default: + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: other\n")); + if (opts[c + 1] == 0) { + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); + /* If the length field is zero, the options are malformed + and we don't process them further. */ + return; + } + /* All other options have a length field, so that we easily + can skip past them. */ + c += opts[c + 1]; + } + } + } +} + +#endif /* LWIP_TCP */ diff --git a/user/mpy/lib/lwip/src/core/tcp_out.c b/user/mpy/lib/lwip/src/core/tcp_out.c new file mode 100644 index 0000000..ee19fe0 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/tcp_out.c @@ -0,0 +1,1485 @@ +/** + * @file + * Transmission Control Protocol, outgoing traffic + * + * The output functions of TCP. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#include "lwip/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/tcp_impl.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/memp.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/inet_chksum.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" +#if LWIP_TCP_TIMESTAMPS +#include "lwip/sys.h" +#endif + +#include + +/* Define some copy-macros for checksum-on-copy so that the code looks + nicer by preventing too many ifdef's. */ +#if TCP_CHECKSUM_ON_COPY +#define TCP_DATA_COPY(dst, src, len, seg) do { \ + tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst, src, len), \ + len, &seg->chksum, &seg->chksum_swapped); \ + seg->flags |= TF_SEG_DATA_CHECKSUMMED; } while(0) +#define TCP_DATA_COPY2(dst, src, len, chksum, chksum_swapped) \ + tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst, src, len), len, chksum, chksum_swapped); +#else /* TCP_CHECKSUM_ON_COPY*/ +#define TCP_DATA_COPY(dst, src, len, seg) MEMCPY(dst, src, len) +#define TCP_DATA_COPY2(dst, src, len, chksum, chksum_swapped) MEMCPY(dst, src, len) +#endif /* TCP_CHECKSUM_ON_COPY*/ + +/** Define this to 1 for an extra check that the output checksum is valid + * (usefule when the checksum is generated by the application, not the stack) */ +#ifndef TCP_CHECKSUM_ON_COPY_SANITY_CHECK +#define TCP_CHECKSUM_ON_COPY_SANITY_CHECK 0 +#endif + +/* Forward declarations.*/ +static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb); + +/** Allocate a pbuf and create a tcphdr at p->payload, used for output + * functions other than the default tcp_output -> tcp_output_segment + * (e.g. tcp_send_empty_ack, etc.) + * + * @param pcb tcp pcb for which to send a packet (used to initialize tcp_hdr) + * @param optlen length of header-options + * @param datalen length of tcp data to reserve in pbuf + * @param seqno_be seqno in network byte order (big-endian) + * @return pbuf with p->payload being the tcp_hdr + */ +static struct pbuf * +tcp_output_alloc_header(struct tcp_pcb *pcb, u16_t optlen, u16_t datalen, + u32_t seqno_be /* already in network byte order */) +{ + struct tcp_hdr *tcphdr; + struct pbuf *p = pbuf_alloc(PBUF_IP, TCP_HLEN + optlen + datalen, PBUF_RAM); + if (p != NULL) { + LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", + (p->len >= TCP_HLEN + optlen)); + tcphdr = (struct tcp_hdr *)p->payload; + tcphdr->src = htons(pcb->local_port); + tcphdr->dest = htons(pcb->remote_port); + tcphdr->seqno = seqno_be; + tcphdr->ackno = htonl(pcb->rcv_nxt); + TCPH_HDRLEN_FLAGS_SET(tcphdr, (5 + optlen / 4), TCP_ACK); + tcphdr->wnd = htons(pcb->rcv_ann_wnd); + tcphdr->chksum = 0; + tcphdr->urgp = 0; + + /* If we're sending a packet, update the announced right window edge */ + pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; + } + return p; +} + +/** + * Called by tcp_close() to send a segment including FIN flag but not data. + * + * @param pcb the tcp_pcb over which to send a segment + * @return ERR_OK if sent, another err_t otherwise + */ +err_t +tcp_send_fin(struct tcp_pcb *pcb) +{ + /* first, try to add the fin to the last unsent segment */ + if (pcb->unsent != NULL) { + struct tcp_seg *last_unsent; + for (last_unsent = pcb->unsent; last_unsent->next != NULL; + last_unsent = last_unsent->next); + + if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { + /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ + TCPH_SET_FLAG(last_unsent->tcphdr, TCP_FIN); + pcb->flags |= TF_FIN; + return ERR_OK; + } + } + /* no data, no length, flags, copy=1, no optdata */ + return tcp_enqueue_flags(pcb, TCP_FIN); +} + +/** + * Create a TCP segment with prefilled header. + * + * Called by tcp_write and tcp_enqueue_flags. + * + * @param pcb Protocol control block for the TCP connection. + * @param p pbuf that is used to hold the TCP header. + * @param flags TCP flags for header. + * @param seqno TCP sequence number of this packet + * @param optflags options to include in TCP header + * @return a new tcp_seg pointing to p, or NULL. + * The TCP header is filled in except ackno and wnd. + * p is freed on failure. + */ +static struct tcp_seg * +tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, u8_t optflags) +{ + struct tcp_seg *seg; + u8_t optlen = LWIP_TCP_OPT_LENGTH(optflags); + + if ((seg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG)) == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_create_segment: no memory.\n")); + pbuf_free(p); + return NULL; + } + seg->flags = optflags; + seg->next = NULL; + seg->p = p; + seg->len = p->tot_len - optlen; +#if TCP_OVERSIZE_DBGCHECK + seg->oversize_left = 0; +#endif /* TCP_OVERSIZE_DBGCHECK */ +#if TCP_CHECKSUM_ON_COPY + seg->chksum = 0; + seg->chksum_swapped = 0; + /* check optflags */ + LWIP_ASSERT("invalid optflags passed: TF_SEG_DATA_CHECKSUMMED", + (optflags & TF_SEG_DATA_CHECKSUMMED) == 0); +#endif /* TCP_CHECKSUM_ON_COPY */ + + /* build TCP header */ + if (pbuf_header(p, TCP_HLEN)) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_create_segment: no room for TCP header in pbuf.\n")); + TCP_STATS_INC(tcp.err); + tcp_seg_free(seg); + return NULL; + } + seg->tcphdr = (struct tcp_hdr *)seg->p->payload; + seg->tcphdr->src = htons(pcb->local_port); + seg->tcphdr->dest = htons(pcb->remote_port); + seg->tcphdr->seqno = htonl(seqno); + /* ackno is set in tcp_output */ + TCPH_HDRLEN_FLAGS_SET(seg->tcphdr, (5 + optlen / 4), flags); + /* wnd and chksum are set in tcp_output */ + seg->tcphdr->urgp = 0; + return seg; +} + +/** + * Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. + * + * This function is like pbuf_alloc(layer, length, PBUF_RAM) except + * there may be extra bytes available at the end. + * + * @param layer flag to define header size. + * @param length size of the pbuf's payload. + * @param max_length maximum usable size of payload+oversize. + * @param oversize pointer to a u16_t that will receive the number of usable tail bytes. + * @param pcb The TCP connection that willo enqueue the pbuf. + * @param apiflags API flags given to tcp_write. + * @param first_seg true when this pbuf will be used in the first enqueued segment. + * @param + */ +#if TCP_OVERSIZE +static struct pbuf * +tcp_pbuf_prealloc(pbuf_layer layer, u16_t length, u16_t max_length, + u16_t *oversize, struct tcp_pcb *pcb, u8_t apiflags, + u8_t first_seg) +{ + struct pbuf *p; + u16_t alloc = length; + +#if LWIP_NETIF_TX_SINGLE_PBUF + LWIP_UNUSED_ARG(max_length); + LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(apiflags); + LWIP_UNUSED_ARG(first_seg); + /* always create MSS-sized pbufs */ + alloc = max_length; +#else /* LWIP_NETIF_TX_SINGLE_PBUF */ + if (length < max_length) { + /* Should we allocate an oversized pbuf, or just the minimum + * length required? If tcp_write is going to be called again + * before this segment is transmitted, we want the oversized + * buffer. If the segment will be transmitted immediately, we can + * save memory by allocating only length. We use a simple + * heuristic based on the following information: + * + * Did the user set TCP_WRITE_FLAG_MORE? + * + * Will the Nagle algorithm defer transmission of this segment? + */ + if ((apiflags & TCP_WRITE_FLAG_MORE) || + (!(pcb->flags & TF_NODELAY) && + (!first_seg || + pcb->unsent != NULL || + pcb->unacked != NULL))) { + alloc = LWIP_MIN(max_length, LWIP_MEM_ALIGN_SIZE(length + TCP_OVERSIZE)); + } + } +#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ + p = pbuf_alloc(layer, alloc, PBUF_RAM); + if (p == NULL) { + return NULL; + } + LWIP_ASSERT("need unchained pbuf", p->next == NULL); + *oversize = p->len - length; + /* trim p->len to the currently used size */ + p->len = p->tot_len = length; + return p; +} +#else /* TCP_OVERSIZE */ +#define tcp_pbuf_prealloc(layer, length, mx, os, pcb, api, fst) pbuf_alloc((layer), (length), PBUF_RAM) +#endif /* TCP_OVERSIZE */ + +#if TCP_CHECKSUM_ON_COPY +/** Add a checksum of newly added data to the segment */ +static void +tcp_seg_add_chksum(u16_t chksum, u16_t len, u16_t *seg_chksum, + u8_t *seg_chksum_swapped) +{ + u32_t helper; + /* add chksum to old chksum and fold to u16_t */ + helper = chksum + *seg_chksum; + chksum = FOLD_U32T(helper); + if ((len & 1) != 0) { + *seg_chksum_swapped = 1 - *seg_chksum_swapped; + chksum = SWAP_BYTES_IN_WORD(chksum); + } + *seg_chksum = chksum; +} +#endif /* TCP_CHECKSUM_ON_COPY */ + +/** Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen). + * + * @param pcb the tcp pcb to check for + * @param len length of data to send (checked agains snd_buf) + * @return ERR_OK if tcp_write is allowed to proceed, another err_t otherwise + */ +static err_t +tcp_write_checks(struct tcp_pcb *pcb, u16_t len) +{ + /* connection is in invalid state for data transmission? */ + if ((pcb->state != ESTABLISHED) && + (pcb->state != CLOSE_WAIT) && + (pcb->state != SYN_SENT) && + (pcb->state != SYN_RCVD)) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_STATE | LWIP_DBG_LEVEL_SEVERE, ("tcp_write() called in invalid state\n")); + return ERR_CONN; + } else if (len == 0) { + return ERR_OK; + } + + /* fail on too much data */ + if (len > pcb->snd_buf) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_write: too much data (len=%"U16_F" > snd_buf=%"U16_F")\n", + len, pcb->snd_buf)); + pcb->flags |= TF_NAGLEMEMERR; + return ERR_MEM; + } + + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); + + /* If total number of pbufs on the unsent/unacked queues exceeds the + * configured maximum, return an error */ + /* check for configured max queuelen and possible overflow */ + if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_write: too long queue %"U16_F" (max %"U16_F")\n", + pcb->snd_queuelen, TCP_SND_QUEUELEN)); + TCP_STATS_INC(tcp.memerr); + pcb->flags |= TF_NAGLEMEMERR; + return ERR_MEM; + } + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_write: pbufs on queue => at least one queue non-empty", + pcb->unacked != NULL || pcb->unsent != NULL); + } else { + LWIP_ASSERT("tcp_write: no pbufs on queue => both queues empty", + pcb->unacked == NULL && pcb->unsent == NULL); + } + return ERR_OK; +} + +/** + * Write data for sending (but does not send it immediately). + * + * It waits in the expectation of more data being sent soon (as + * it can send them more efficiently by combining them together). + * To prompt the system to send data now, call tcp_output() after + * calling tcp_write(). + * + * @param pcb Protocol control block for the TCP connection to enqueue data for. + * @param arg Pointer to the data to be enqueued for sending. + * @param len Data length in bytes + * @param apiflags combination of following flags : + * - TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack + * - TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will be set on last segment sent, + * @return ERR_OK if enqueued, another err_t on error + */ +err_t +tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) +{ + struct pbuf *concat_p = NULL; + struct tcp_seg *last_unsent = NULL, *seg = NULL, *prev_seg = NULL, *queue = NULL; + u16_t pos = 0; /* position in 'arg' data */ + u16_t queuelen; + u8_t optlen = 0; + u8_t optflags = 0; +#if TCP_OVERSIZE + u16_t oversize = 0; + u16_t oversize_used = 0; +#endif /* TCP_OVERSIZE */ +#if TCP_CHECKSUM_ON_COPY + u16_t concat_chksum = 0; + u8_t concat_chksum_swapped = 0; + u16_t concat_chksummed = 0; +#endif /* TCP_CHECKSUM_ON_COPY */ + err_t err; + /* don't allocate segments bigger than half the maximum window we ever received */ + u16_t mss_local = LWIP_MIN(pcb->mss, pcb->snd_wnd_max/2); + +#if LWIP_NETIF_TX_SINGLE_PBUF + /* Always copy to try to create single pbufs for TX */ + apiflags |= TCP_WRITE_FLAG_COPY; +#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ + + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n", + (void *)pcb, arg, len, (u16_t)apiflags)); + LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)", + arg != NULL, return ERR_ARG;); + + err = tcp_write_checks(pcb, len); + if (err != ERR_OK) { + return err; + } + queuelen = pcb->snd_queuelen; + +#if LWIP_TCP_TIMESTAMPS + if ((pcb->flags & TF_TIMESTAMP)) { + optflags = TF_SEG_OPTS_TS; + optlen = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS); + } +#endif /* LWIP_TCP_TIMESTAMPS */ + + + /* + * TCP segmentation is done in three phases with increasing complexity: + * + * 1. Copy data directly into an oversized pbuf. + * 2. Chain a new pbuf to the end of pcb->unsent. + * 3. Create new segments. + * + * We may run out of memory at any point. In that case we must + * return ERR_MEM and not change anything in pcb. Therefore, all + * changes are recorded in local variables and committed at the end + * of the function. Some pcb fields are maintained in local copies: + * + * queuelen = pcb->snd_queuelen + * oversize = pcb->unsent_oversize + * + * These variables are set consistently by the phases: + * + * seg points to the last segment tampered with. + * + * pos records progress as data is segmented. + */ + + /* Find the tail of the unsent queue. */ + if (pcb->unsent != NULL) { + u16_t space; + u16_t unsent_optlen; + + /* @todo: this could be sped up by keeping last_unsent in the pcb */ + for (last_unsent = pcb->unsent; last_unsent->next != NULL; + last_unsent = last_unsent->next); + + /* Usable space at the end of the last unsent segment */ + unsent_optlen = LWIP_TCP_OPT_LENGTH(last_unsent->flags); + space = mss_local - (last_unsent->len + unsent_optlen); + + /* + * Phase 1: Copy data directly into an oversized pbuf. + * + * The number of bytes copied is recorded in the oversize_used + * variable. The actual copying is done at the bottom of the + * function. + */ +#if TCP_OVERSIZE +#if TCP_OVERSIZE_DBGCHECK + /* check that pcb->unsent_oversize matches last_unsent->unsent_oversize */ + LWIP_ASSERT("unsent_oversize mismatch (pcb vs. last_unsent)", + pcb->unsent_oversize == last_unsent->oversize_left); +#endif /* TCP_OVERSIZE_DBGCHECK */ + oversize = pcb->unsent_oversize; + if (oversize > 0) { + LWIP_ASSERT("inconsistent oversize vs. space", oversize_used <= space); + seg = last_unsent; + oversize_used = oversize < len ? oversize : len; + pos += oversize_used; + oversize -= oversize_used; + space -= oversize_used; + } + /* now we are either finished or oversize is zero */ + LWIP_ASSERT("inconsistend oversize vs. len", (oversize == 0) || (pos == len)); +#endif /* TCP_OVERSIZE */ + + /* + * Phase 2: Chain a new pbuf to the end of pcb->unsent. + * + * We don't extend segments containing SYN/FIN flags or options + * (len==0). The new pbuf is kept in concat_p and pbuf_cat'ed at + * the end. + */ + if ((pos < len) && (space > 0) && (last_unsent->len > 0)) { + u16_t seglen = space < len - pos ? space : len - pos; + seg = last_unsent; + + /* Create a pbuf with a copy or reference to seglen bytes. We + * can use PBUF_RAW here since the data appears in the middle of + * a segment. A header will never be prepended. */ + if (apiflags & TCP_WRITE_FLAG_COPY) { + /* Data is copied */ + if ((concat_p = tcp_pbuf_prealloc(PBUF_RAW, seglen, space, &oversize, pcb, apiflags, 1)) == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, + ("tcp_write : could not allocate memory for pbuf copy size %"U16_F"\n", + seglen)); + goto memerr; + } +#if TCP_OVERSIZE_DBGCHECK + last_unsent->oversize_left += oversize; +#endif /* TCP_OVERSIZE_DBGCHECK */ + TCP_DATA_COPY2(concat_p->payload, (u8_t*)arg + pos, seglen, &concat_chksum, &concat_chksum_swapped); +#if TCP_CHECKSUM_ON_COPY + concat_chksummed += seglen; +#endif /* TCP_CHECKSUM_ON_COPY */ + } else { + /* Data is not copied */ + if ((concat_p = pbuf_alloc(PBUF_RAW, seglen, PBUF_ROM)) == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, + ("tcp_write: could not allocate memory for zero-copy pbuf\n")); + goto memerr; + } +#if TCP_CHECKSUM_ON_COPY + /* calculate the checksum of nocopy-data */ + tcp_seg_add_chksum(~inet_chksum((u8_t*)arg + pos, seglen), seglen, + &concat_chksum, &concat_chksum_swapped); + concat_chksummed += seglen; +#endif /* TCP_CHECKSUM_ON_COPY */ + /* reference the non-volatile payload data */ + concat_p->payload = (u8_t*)arg + pos; + } + + pos += seglen; + queuelen += pbuf_clen(concat_p); + } + } else { +#if TCP_OVERSIZE + LWIP_ASSERT("unsent_oversize mismatch (pcb->unsent is NULL)", + pcb->unsent_oversize == 0); +#endif /* TCP_OVERSIZE */ + } + + /* + * Phase 3: Create new segments. + * + * The new segments are chained together in the local 'queue' + * variable, ready to be appended to pcb->unsent. + */ + while (pos < len) { + struct pbuf *p; + u16_t left = len - pos; + u16_t max_len = mss_local - optlen; + u16_t seglen = left > max_len ? max_len : left; +#if TCP_CHECKSUM_ON_COPY + u16_t chksum = 0; + u8_t chksum_swapped = 0; +#endif /* TCP_CHECKSUM_ON_COPY */ + + if (apiflags & TCP_WRITE_FLAG_COPY) { + /* If copy is set, memory should be allocated and data copied + * into pbuf */ + if ((p = tcp_pbuf_prealloc(PBUF_TRANSPORT, seglen + optlen, mss_local, &oversize, pcb, apiflags, queue == NULL)) == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write : could not allocate memory for pbuf copy size %"U16_F"\n", seglen)); + goto memerr; + } + LWIP_ASSERT("tcp_write: check that first pbuf can hold the complete seglen", + (p->len >= seglen)); + TCP_DATA_COPY2((char *)p->payload + optlen, (u8_t*)arg + pos, seglen, &chksum, &chksum_swapped); + } else { + /* Copy is not set: First allocate a pbuf for holding the data. + * Since the referenced data is available at least until it is + * sent out on the link (as it has to be ACKed by the remote + * party) we can safely use PBUF_ROM instead of PBUF_REF here. + */ + struct pbuf *p2; +#if TCP_OVERSIZE + LWIP_ASSERT("oversize == 0", oversize == 0); +#endif /* TCP_OVERSIZE */ + if ((p2 = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: could not allocate memory for zero-copy pbuf\n")); + goto memerr; + } +#if TCP_CHECKSUM_ON_COPY + /* calculate the checksum of nocopy-data */ + chksum = ~inet_chksum((u8_t*)arg + pos, seglen); +#endif /* TCP_CHECKSUM_ON_COPY */ + /* reference the non-volatile payload data */ + p2->payload = (u8_t*)arg + pos; + + /* Second, allocate a pbuf for the headers. */ + if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { + /* If allocation fails, we have to deallocate the data pbuf as + * well. */ + pbuf_free(p2); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: could not allocate memory for header pbuf\n")); + goto memerr; + } + /* Concatenate the headers and data pbufs together. */ + pbuf_cat(p/*header*/, p2/*data*/); + } + + queuelen += pbuf_clen(p); + + /* Now that there are more segments queued, we check again if the + * length of the queue exceeds the configured maximum or + * overflows. */ + if ((queuelen > TCP_SND_QUEUELEN) || (queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: queue too long %"U16_F" (%"U16_F")\n", queuelen, TCP_SND_QUEUELEN)); + pbuf_free(p); + goto memerr; + } + + if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) { + goto memerr; + } +#if TCP_OVERSIZE_DBGCHECK + seg->oversize_left = oversize; +#endif /* TCP_OVERSIZE_DBGCHECK */ +#if TCP_CHECKSUM_ON_COPY + seg->chksum = chksum; + seg->chksum_swapped = chksum_swapped; + seg->flags |= TF_SEG_DATA_CHECKSUMMED; +#endif /* TCP_CHECKSUM_ON_COPY */ + + /* first segment of to-be-queued data? */ + if (queue == NULL) { + queue = seg; + } else { + /* Attach the segment to the end of the queued segments */ + LWIP_ASSERT("prev_seg != NULL", prev_seg != NULL); + prev_seg->next = seg; + } + /* remember last segment of to-be-queued data for next iteration */ + prev_seg = seg; + + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_write: queueing %"U32_F":%"U32_F"\n", + ntohl(seg->tcphdr->seqno), + ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); + + pos += seglen; + } + + /* + * All three segmentation phases were successful. We can commit the + * transaction. + */ + + /* + * Phase 1: If data has been added to the preallocated tail of + * last_unsent, we update the length fields of the pbuf chain. + */ +#if TCP_OVERSIZE + if (oversize_used > 0) { + struct pbuf *p; + /* Bump tot_len of whole chain, len of tail */ + for (p = last_unsent->p; p; p = p->next) { + p->tot_len += oversize_used; + if (p->next == NULL) { + TCP_DATA_COPY((char *)p->payload + p->len, arg, oversize_used, last_unsent); + p->len += oversize_used; + } + } + last_unsent->len += oversize_used; +#if TCP_OVERSIZE_DBGCHECK + LWIP_ASSERT("last_unsent->oversize_left >= oversize_used", + last_unsent->oversize_left >= oversize_used); + last_unsent->oversize_left -= oversize_used; +#endif /* TCP_OVERSIZE_DBGCHECK */ + } + pcb->unsent_oversize = oversize; +#endif /* TCP_OVERSIZE */ + + /* + * Phase 2: concat_p can be concatenated onto last_unsent->p + */ + if (concat_p != NULL) { + LWIP_ASSERT("tcp_write: cannot concatenate when pcb->unsent is empty", + (last_unsent != NULL)); + pbuf_cat(last_unsent->p, concat_p); + last_unsent->len += concat_p->tot_len; +#if TCP_CHECKSUM_ON_COPY + if (concat_chksummed) { + tcp_seg_add_chksum(concat_chksum, concat_chksummed, &last_unsent->chksum, + &last_unsent->chksum_swapped); + last_unsent->flags |= TF_SEG_DATA_CHECKSUMMED; + } +#endif /* TCP_CHECKSUM_ON_COPY */ + } + + /* + * Phase 3: Append queue to pcb->unsent. Queue may be NULL, but that + * is harmless + */ + if (last_unsent == NULL) { + pcb->unsent = queue; + } else { + last_unsent->next = queue; + } + + /* + * Finally update the pcb state. + */ + pcb->snd_lbb += len; + pcb->snd_buf -= len; + pcb->snd_queuelen = queuelen; + + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: %"S16_F" (after enqueued)\n", + pcb->snd_queuelen)); + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_write: valid queue length", + pcb->unacked != NULL || pcb->unsent != NULL); + } + + /* Set the PSH flag in the last segment that we enqueued. */ + if (seg != NULL && seg->tcphdr != NULL && ((apiflags & TCP_WRITE_FLAG_MORE)==0)) { + TCPH_SET_FLAG(seg->tcphdr, TCP_PSH); + } + + return ERR_OK; +memerr: + pcb->flags |= TF_NAGLEMEMERR; + TCP_STATS_INC(tcp.memerr); + + if (concat_p != NULL) { + pbuf_free(concat_p); + } + if (queue != NULL) { + tcp_segs_free(queue); + } + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_write: valid queue length", pcb->unacked != NULL || + pcb->unsent != NULL); + } + LWIP_DEBUGF(TCP_QLEN_DEBUG | LWIP_DBG_STATE, ("tcp_write: %"S16_F" (with mem err)\n", pcb->snd_queuelen)); + return ERR_MEM; +} + +/** + * Enqueue TCP options for transmission. + * + * Called by tcp_connect(), tcp_listen_input(), and tcp_send_ctrl(). + * + * @param pcb Protocol control block for the TCP connection. + * @param flags TCP header flags to set in the outgoing segment. + * @param optdata pointer to TCP options, or NULL. + * @param optlen length of TCP options in bytes. + */ +err_t +tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) +{ + struct pbuf *p; + struct tcp_seg *seg; + u8_t optflags = 0; + u8_t optlen = 0; + + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue_flags: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); + + LWIP_ASSERT("tcp_enqueue_flags: need either TCP_SYN or TCP_FIN in flags (programmer violates API)", + (flags & (TCP_SYN | TCP_FIN)) != 0); + + /* check for configured max queuelen and possible overflow */ + if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue_flags: too long queue %"U16_F" (max %"U16_F")\n", + pcb->snd_queuelen, TCP_SND_QUEUELEN)); + TCP_STATS_INC(tcp.memerr); + pcb->flags |= TF_NAGLEMEMERR; + return ERR_MEM; + } + + if (flags & TCP_SYN) { + optflags = TF_SEG_OPTS_MSS; + } +#if LWIP_TCP_TIMESTAMPS + if ((pcb->flags & TF_TIMESTAMP)) { + optflags |= TF_SEG_OPTS_TS; + } +#endif /* LWIP_TCP_TIMESTAMPS */ + optlen = LWIP_TCP_OPT_LENGTH(optflags); + + /* tcp_enqueue_flags is always called with either SYN or FIN in flags. + * We need one available snd_buf byte to do that. + * This means we can't send FIN while snd_buf==0. A better fix would be to + * not include SYN and FIN sequence numbers in the snd_buf count. */ + if (pcb->snd_buf == 0) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue_flags: no send buffer available\n")); + TCP_STATS_INC(tcp.memerr); + return ERR_MEM; + } + + /* Allocate pbuf with room for TCP header + options */ + if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { + pcb->flags |= TF_NAGLEMEMERR; + TCP_STATS_INC(tcp.memerr); + return ERR_MEM; + } + LWIP_ASSERT("tcp_enqueue_flags: check that first pbuf can hold optlen", + (p->len >= optlen)); + + /* Allocate memory for tcp_seg, and fill in fields. */ + if ((seg = tcp_create_segment(pcb, p, flags, pcb->snd_lbb, optflags)) == NULL) { + pcb->flags |= TF_NAGLEMEMERR; + TCP_STATS_INC(tcp.memerr); + return ERR_MEM; + } + LWIP_ASSERT("seg->tcphdr not aligned", ((mem_ptr_t)seg->tcphdr % MEM_ALIGNMENT) == 0); + LWIP_ASSERT("tcp_enqueue_flags: invalid segment length", seg->len == 0); + + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, + ("tcp_enqueue_flags: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n", + ntohl(seg->tcphdr->seqno), + ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), + (u16_t)flags)); + + /* Now append seg to pcb->unsent queue */ + if (pcb->unsent == NULL) { + pcb->unsent = seg; + } else { + struct tcp_seg *useg; + for (useg = pcb->unsent; useg->next != NULL; useg = useg->next); + useg->next = seg; + } +#if TCP_OVERSIZE + /* The new unsent tail has no space */ + pcb->unsent_oversize = 0; +#endif /* TCP_OVERSIZE */ + + /* SYN and FIN bump the sequence number */ + if ((flags & TCP_SYN) || (flags & TCP_FIN)) { + pcb->snd_lbb++; + /* optlen does not influence snd_buf */ + pcb->snd_buf--; + } + if (flags & TCP_FIN) { + pcb->flags |= TF_FIN; + } + + /* update number of segments on the queues */ + pcb->snd_queuelen += pbuf_clen(seg->p); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue_flags: %"S16_F" (after enqueued)\n", pcb->snd_queuelen)); + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_enqueue_flags: invalid queue length", + pcb->unacked != NULL || pcb->unsent != NULL); + } + + return ERR_OK; +} + +#if LWIP_TCP_TIMESTAMPS +/* Build a timestamp option (12 bytes long) at the specified options pointer) + * + * @param pcb tcp_pcb + * @param opts option pointer where to store the timestamp option + */ +static void +tcp_build_timestamp_option(struct tcp_pcb *pcb, u32_t *opts) +{ + /* Pad with two NOP options to make everything nicely aligned */ + opts[0] = PP_HTONL(0x0101080A); + opts[1] = htonl(sys_now()); + opts[2] = htonl(pcb->ts_recent); +} +#endif + +/** Send an ACK without data. + * + * @param pcb Protocol control block for the TCP connection to send the ACK + */ +err_t +tcp_send_empty_ack(struct tcp_pcb *pcb) +{ + struct pbuf *p; + struct tcp_hdr *tcphdr; + u8_t optlen = 0; + +#if LWIP_TCP_TIMESTAMPS + if (pcb->flags & TF_TIMESTAMP) { + optlen = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS); + } +#endif + + p = tcp_output_alloc_header(pcb, optlen, 0, htonl(pcb->snd_nxt)); + if (p == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); + return ERR_BUF; + } + tcphdr = (struct tcp_hdr *)p->payload; + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, + ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt)); + /* remove ACK flags from the PCB, as we send an empty ACK now */ + pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); + + /* NB. MSS option is only sent on SYNs, so ignore it here */ +#if LWIP_TCP_TIMESTAMPS + pcb->ts_lastacksent = pcb->rcv_nxt; + + if (pcb->flags & TF_TIMESTAMP) { + tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1)); + } +#endif + +#if CHECKSUM_GEN_TCP + tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip), + IP_PROTO_TCP, p->tot_len); +#endif +#if LWIP_NETIF_HWADDRHINT + ip_output_hinted(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, + IP_PROTO_TCP, &(pcb->addr_hint)); +#else /* LWIP_NETIF_HWADDRHINT*/ + ip_output(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, + IP_PROTO_TCP); +#endif /* LWIP_NETIF_HWADDRHINT*/ + pbuf_free(p); + + return ERR_OK; +} + +/** + * Find out what we can send and send it + * + * @param pcb Protocol control block for the TCP connection to send data + * @return ERR_OK if data has been sent or nothing to send + * another err_t on error + */ +err_t +tcp_output(struct tcp_pcb *pcb) +{ + struct tcp_seg *seg, *useg; + u32_t wnd, snd_nxt; +#if TCP_CWND_DEBUG + s16_t i = 0; +#endif /* TCP_CWND_DEBUG */ + + /* pcb->state LISTEN not allowed here */ + LWIP_ASSERT("don't call tcp_output for listen-pcbs", + pcb->state != LISTEN); + + /* First, check if we are invoked by the TCP input processing + code. If so, we do not output anything. Instead, we rely on the + input processing code to call us when input processing is done + with. */ + if (tcp_input_pcb == pcb) { + return ERR_OK; + } + + wnd = LWIP_MIN(pcb->snd_wnd, pcb->cwnd); + + seg = pcb->unsent; + + /* If the TF_ACK_NOW flag is set and no data will be sent (either + * because the ->unsent queue is empty or because the window does + * not allow it), construct an empty ACK segment and send it. + * + * If data is to be sent, we will just piggyback the ACK (see below). + */ + if (pcb->flags & TF_ACK_NOW && + (seg == NULL || + ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) { + return tcp_send_empty_ack(pcb); + } + + /* useg should point to last segment on unacked queue */ + useg = pcb->unacked; + if (useg != NULL) { + for (; useg->next != NULL; useg = useg->next); + } + +#if TCP_OUTPUT_DEBUG + if (seg == NULL) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", + (void*)pcb->unsent)); + } +#endif /* TCP_OUTPUT_DEBUG */ +#if TCP_CWND_DEBUG + if (seg == NULL) { + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F + ", cwnd %"U16_F", wnd %"U32_F + ", seg == NULL, ack %"U32_F"\n", + pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); + } else { + LWIP_DEBUGF(TCP_CWND_DEBUG, + ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F + ", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", + pcb->snd_wnd, pcb->cwnd, wnd, + ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, + ntohl(seg->tcphdr->seqno), pcb->lastack)); + } +#endif /* TCP_CWND_DEBUG */ + /* data available and window allows it to be sent? */ + while (seg != NULL && + ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { + LWIP_ASSERT("RST not expected here!", + (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0); + /* Stop sending if the nagle algorithm would prevent it + * Don't stop: + * - if tcp_write had a memory error before (prevent delayed ACK timeout) or + * - if FIN was already enqueued for this PCB (SYN is always alone in a segment - + * either seg->next != NULL or pcb->unacked == NULL; + * RST is no sent using tcp_write/tcp_output. + */ + if((tcp_do_output_nagle(pcb) == 0) && + ((pcb->flags & (TF_NAGLEMEMERR | TF_FIN)) == 0)){ + break; + } +#if TCP_CWND_DEBUG + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F", i %"S16_F"\n", + pcb->snd_wnd, pcb->cwnd, wnd, + ntohl(seg->tcphdr->seqno) + seg->len - + pcb->lastack, + ntohl(seg->tcphdr->seqno), pcb->lastack, i)); + ++i; +#endif /* TCP_CWND_DEBUG */ + + pcb->unsent = seg->next; + + if (pcb->state != SYN_SENT) { + TCPH_SET_FLAG(seg->tcphdr, TCP_ACK); + pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); + } + + tcp_output_segment(seg, pcb); + snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); + if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) { + pcb->snd_nxt = snd_nxt; + } + /* put segment on unacknowledged list if length > 0 */ + if (TCP_TCPLEN(seg) > 0) { + seg->next = NULL; + /* unacked list is empty? */ + if (pcb->unacked == NULL) { + pcb->unacked = seg; + useg = seg; + /* unacked list is not empty? */ + } else { + /* In the case of fast retransmit, the packet should not go to the tail + * of the unacked queue, but rather somewhere before it. We need to check for + * this case. -STJ Jul 27, 2004 */ + if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) { + /* add segment to before tail of unacked list, keeping the list sorted */ + struct tcp_seg **cur_seg = &(pcb->unacked); + while (*cur_seg && + TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { + cur_seg = &((*cur_seg)->next ); + } + seg->next = (*cur_seg); + (*cur_seg) = seg; + } else { + /* add segment to tail of unacked list */ + useg->next = seg; + useg = useg->next; + } + } + /* do not queue empty segments on the unacked list */ + } else { + tcp_seg_free(seg); + } + seg = pcb->unsent; + } +#if TCP_OVERSIZE + if (pcb->unsent == NULL) { + /* last unsent has been removed, reset unsent_oversize */ + pcb->unsent_oversize = 0; + } +#endif /* TCP_OVERSIZE */ + + pcb->flags &= ~TF_NAGLEMEMERR; + return ERR_OK; +} + +/** + * Called by tcp_output() to actually send a TCP segment over IP. + * + * @param seg the tcp_seg to send + * @param pcb the tcp_pcb for the TCP connection used to send the segment + */ +static void +tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) +{ + u16_t len; + struct netif *netif; + u32_t *opts; + + /** @bug Exclude retransmitted segments from this count. */ + snmp_inc_tcpoutsegs(); + + /* The TCP header has already been constructed, but the ackno and + wnd fields remain. */ + seg->tcphdr->ackno = htonl(pcb->rcv_nxt); + + /* advertise our receive window size in this TCP segment */ + seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd); + + pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; + + /* Add any requested options. NB MSS option is only set on SYN + packets, so ignore it here */ + opts = (u32_t *)(void *)(seg->tcphdr + 1); + if (seg->flags & TF_SEG_OPTS_MSS) { + u16_t mss; +#if TCP_CALCULATE_EFF_SEND_MSS + mss = tcp_eff_send_mss(TCP_MSS, &pcb->remote_ip); +#else /* TCP_CALCULATE_EFF_SEND_MSS */ + mss = TCP_MSS; +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + *opts = TCP_BUILD_MSS_OPTION(mss); + opts += 1; + } +#if LWIP_TCP_TIMESTAMPS + pcb->ts_lastacksent = pcb->rcv_nxt; + + if (seg->flags & TF_SEG_OPTS_TS) { + tcp_build_timestamp_option(pcb, opts); + opts += 3; + } +#endif + + /* Set retransmission timer running if it is not currently enabled + This must be set before checking the route. */ + if (pcb->rtime == -1) { + pcb->rtime = 0; + } + + /* If we don't have a local IP address, we get one by + calling ip_route(). */ + if (ip_addr_isany(&(pcb->local_ip))) { + netif = ip_route(&(pcb->remote_ip)); + if (netif == NULL) { + return; + } + ip_addr_copy(pcb->local_ip, netif->ip_addr); + } + + if (pcb->rttest == 0) { + pcb->rttest = tcp_ticks; + pcb->rtseq = ntohl(seg->tcphdr->seqno); + + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %"U32_F"\n", pcb->rtseq)); + } + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %"U32_F":%"U32_F"\n", + htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + + seg->len)); + + len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload); + + seg->p->len -= len; + seg->p->tot_len -= len; + + seg->p->payload = seg->tcphdr; + + seg->tcphdr->chksum = 0; +#if CHECKSUM_GEN_TCP +#if TCP_CHECKSUM_ON_COPY + { + u32_t acc; +#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK + u16_t chksum_slow = inet_chksum_pseudo(seg->p, &(pcb->local_ip), + &(pcb->remote_ip), + IP_PROTO_TCP, seg->p->tot_len); +#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ + if ((seg->flags & TF_SEG_DATA_CHECKSUMMED) == 0) { + LWIP_ASSERT("data included but not checksummed", + seg->p->tot_len == (TCPH_HDRLEN(seg->tcphdr) * 4)); + } + + /* rebuild TCP header checksum (TCP header changes for retransmissions!) */ + acc = inet_chksum_pseudo_partial(seg->p, &(pcb->local_ip), + &(pcb->remote_ip), + IP_PROTO_TCP, seg->p->tot_len, TCPH_HDRLEN(seg->tcphdr) * 4); + /* add payload checksum */ + if (seg->chksum_swapped) { + seg->chksum = SWAP_BYTES_IN_WORD(seg->chksum); + seg->chksum_swapped = 0; + } + acc += (u16_t)~(seg->chksum); + seg->tcphdr->chksum = FOLD_U32T(acc); +#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK + if (chksum_slow != seg->tcphdr->chksum) { + LWIP_DEBUGF(TCP_DEBUG | LWIP_DBG_LEVEL_WARNING, + ("tcp_output_segment: calculated checksum is %"X16_F" instead of %"X16_F"\n", + seg->tcphdr->chksum, chksum_slow)); + seg->tcphdr->chksum = chksum_slow; + } +#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ + } +#else /* TCP_CHECKSUM_ON_COPY */ + seg->tcphdr->chksum = inet_chksum_pseudo(seg->p, &(pcb->local_ip), + &(pcb->remote_ip), + IP_PROTO_TCP, seg->p->tot_len); +#endif /* TCP_CHECKSUM_ON_COPY */ +#endif /* CHECKSUM_GEN_TCP */ + TCP_STATS_INC(tcp.xmit); + +#if LWIP_NETIF_HWADDRHINT + ip_output_hinted(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, + IP_PROTO_TCP, &(pcb->addr_hint)); +#else /* LWIP_NETIF_HWADDRHINT*/ + ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, + IP_PROTO_TCP); +#endif /* LWIP_NETIF_HWADDRHINT*/ +} + +/** + * Send a TCP RESET packet (empty segment with RST flag set) either to + * abort a connection or to show that there is no matching local connection + * for a received segment. + * + * Called by tcp_abort() (to abort a local connection), tcp_input() (if no + * matching local pcb was found), tcp_listen_input() (if incoming segment + * has ACK flag set) and tcp_process() (received segment in the wrong state) + * + * Since a RST segment is in most cases not sent for an active connection, + * tcp_rst() has a number of arguments that are taken from a tcp_pcb for + * most other segment output functions. + * + * @param seqno the sequence number to use for the outgoing segment + * @param ackno the acknowledge number to use for the outgoing segment + * @param local_ip the local IP address to send the segment from + * @param remote_ip the remote IP address to send the segment to + * @param local_port the local TCP port to send the segment from + * @param remote_port the remote TCP port to send the segment to + */ +void +tcp_rst(u32_t seqno, u32_t ackno, + ip_addr_t *local_ip, ip_addr_t *remote_ip, + u16_t local_port, u16_t remote_port) +{ + struct pbuf *p; + struct tcp_hdr *tcphdr; + p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); + if (p == NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n")); + return; + } + LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", + (p->len >= sizeof(struct tcp_hdr))); + + tcphdr = (struct tcp_hdr *)p->payload; + tcphdr->src = htons(local_port); + tcphdr->dest = htons(remote_port); + tcphdr->seqno = htonl(seqno); + tcphdr->ackno = htonl(ackno); + TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN/4, TCP_RST | TCP_ACK); + tcphdr->wnd = PP_HTONS(TCP_WND); + tcphdr->chksum = 0; + tcphdr->urgp = 0; + +#if CHECKSUM_GEN_TCP + tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip, + IP_PROTO_TCP, p->tot_len); +#endif + TCP_STATS_INC(tcp.xmit); + snmp_inc_tcpoutrsts(); + /* Send output with hardcoded TTL since we have no access to the pcb */ + ip_output(p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP); + pbuf_free(p); + LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %"U32_F" ackno %"U32_F".\n", seqno, ackno)); +} + +/** + * Requeue all unacked segments for retransmission + * + * Called by tcp_slowtmr() for slow retransmission. + * + * @param pcb the tcp_pcb for which to re-enqueue all unacked segments + */ +void +tcp_rexmit_rto(struct tcp_pcb *pcb) +{ + struct tcp_seg *seg; + + if (pcb->unacked == NULL) { + return; + } + + /* Move all unacked segments to the head of the unsent queue */ + for (seg = pcb->unacked; seg->next != NULL; seg = seg->next); + /* concatenate unsent queue after unacked queue */ + seg->next = pcb->unsent; + /* unsent queue is the concatenated queue (of unacked, unsent) */ + pcb->unsent = pcb->unacked; + /* unacked queue is now empty */ + pcb->unacked = NULL; + /* last unsent hasn't changed, no need to reset unsent_oversize */ + + /* increment number of retransmissions */ + ++pcb->nrtx; + + /* Don't take any RTT measurements after retransmitting. */ + pcb->rttest = 0; + + /* Do the actual retransmission */ + tcp_output(pcb); +} + +/** + * Requeue the first unacked segment for retransmission + * + * Called by tcp_receive() for fast retramsmit. + * + * @param pcb the tcp_pcb for which to retransmit the first unacked segment + */ +void +tcp_rexmit(struct tcp_pcb *pcb) +{ + struct tcp_seg *seg; + struct tcp_seg **cur_seg; + + if (pcb->unacked == NULL) { + return; + } + + /* Move the first unacked segment to the unsent queue */ + /* Keep the unsent queue sorted. */ + seg = pcb->unacked; + pcb->unacked = seg->next; + + cur_seg = &(pcb->unsent); + while (*cur_seg && + TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { + cur_seg = &((*cur_seg)->next ); + } + seg->next = *cur_seg; + *cur_seg = seg; +#if TCP_OVERSIZE + if (seg->next == NULL) { + /* the retransmitted segment is last in unsent, so reset unsent_oversize */ + pcb->unsent_oversize = 0; + } +#endif /* TCP_OVERSIZE */ + + ++pcb->nrtx; + + /* Don't take any rtt measurements after retransmitting. */ + pcb->rttest = 0; + + /* Do the actual retransmission. */ + snmp_inc_tcpretranssegs(); + /* No need to call tcp_output: we are always called from tcp_input() + and thus tcp_output directly returns. */ +} + + +/** + * Handle retransmission after three dupacks received + * + * @param pcb the tcp_pcb for which to retransmit the first unacked segment + */ +void +tcp_rexmit_fast(struct tcp_pcb *pcb) +{ + if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) { + /* This is fast retransmit. Retransmit the first unacked segment. */ + LWIP_DEBUGF(TCP_FR_DEBUG, + ("tcp_receive: dupacks %"U16_F" (%"U32_F + "), fast retransmit %"U32_F"\n", + (u16_t)pcb->dupacks, pcb->lastack, + ntohl(pcb->unacked->tcphdr->seqno))); + tcp_rexmit(pcb); + + /* Set ssthresh to half of the minimum of the current + * cwnd and the advertised window */ + if (pcb->cwnd > pcb->snd_wnd) { + pcb->ssthresh = pcb->snd_wnd / 2; + } else { + pcb->ssthresh = pcb->cwnd / 2; + } + + /* The minimum value for ssthresh should be 2 MSS */ + if (pcb->ssthresh < 2*pcb->mss) { + LWIP_DEBUGF(TCP_FR_DEBUG, + ("tcp_receive: The minimum value for ssthresh %"U16_F + " should be min 2 mss %"U16_F"...\n", + pcb->ssthresh, 2*pcb->mss)); + pcb->ssthresh = 2*pcb->mss; + } + + pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; + pcb->flags |= TF_INFR; + } +} + + +/** + * Send keepalive packets to keep a connection active although + * no data is sent over it. + * + * Called by tcp_slowtmr() + * + * @param pcb the tcp_pcb for which to send a keepalive packet + */ +void +tcp_keepalive(struct tcp_pcb *pcb) +{ + struct pbuf *p; + struct tcp_hdr *tcphdr; + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), + ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", + tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); + + p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1)); + if(p == NULL) { + LWIP_DEBUGF(TCP_DEBUG, + ("tcp_keepalive: could not allocate memory for pbuf\n")); + return; + } + tcphdr = (struct tcp_hdr *)p->payload; + +#if CHECKSUM_GEN_TCP + tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, + IP_PROTO_TCP, p->tot_len); +#endif + TCP_STATS_INC(tcp.xmit); + + /* Send output to IP */ +#if LWIP_NETIF_HWADDRHINT + ip_output_hinted(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP, + &(pcb->addr_hint)); +#else /* LWIP_NETIF_HWADDRHINT*/ + ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); +#endif /* LWIP_NETIF_HWADDRHINT*/ + + pbuf_free(p); + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: seqno %"U32_F" ackno %"U32_F".\n", + pcb->snd_nxt - 1, pcb->rcv_nxt)); +} + + +/** + * Send persist timer zero-window probes to keep a connection active + * when a window update is lost. + * + * Called by tcp_slowtmr() + * + * @param pcb the tcp_pcb for which to send a zero-window probe packet + */ +void +tcp_zero_window_probe(struct tcp_pcb *pcb) +{ + struct pbuf *p; + struct tcp_hdr *tcphdr; + struct tcp_seg *seg; + u16_t len; + u8_t is_fin; + + LWIP_DEBUGF(TCP_DEBUG, + ("tcp_zero_window_probe: sending ZERO WINDOW probe to %" + U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), + ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); + + LWIP_DEBUGF(TCP_DEBUG, + ("tcp_zero_window_probe: tcp_ticks %"U32_F + " pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", + tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); + + seg = pcb->unacked; + + if(seg == NULL) { + seg = pcb->unsent; + } + if(seg == NULL) { + return; + } + + is_fin = ((TCPH_FLAGS(seg->tcphdr) & TCP_FIN) != 0) && (seg->len == 0); + /* we want to send one seqno: either FIN or data (no options) */ + len = is_fin ? 0 : 1; + + p = tcp_output_alloc_header(pcb, 0, len, seg->tcphdr->seqno); + if(p == NULL) { + LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: no memory for pbuf\n")); + return; + } + tcphdr = (struct tcp_hdr *)p->payload; + + if (is_fin) { + /* FIN segment, no data */ + TCPH_FLAGS_SET(tcphdr, TCP_ACK | TCP_FIN); + } else { + /* Data segment, copy in one byte from the head of the unacked queue */ + char *d = ((char *)p->payload + TCP_HLEN); + /* Depending on whether the segment has already been sent (unacked) or not + (unsent), seg->p->payload points to the IP header or TCP header. + Ensure we copy the first TCP data byte: */ + pbuf_copy_partial(seg->p, d, 1, seg->p->tot_len - seg->len); + } + +#if CHECKSUM_GEN_TCP + tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, + IP_PROTO_TCP, p->tot_len); +#endif + TCP_STATS_INC(tcp.xmit); + + /* Send output to IP */ +#if LWIP_NETIF_HWADDRHINT + ip_output_hinted(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP, + &(pcb->addr_hint)); +#else /* LWIP_NETIF_HWADDRHINT*/ + ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); +#endif /* LWIP_NETIF_HWADDRHINT*/ + + pbuf_free(p); + + LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: seqno %"U32_F + " ackno %"U32_F".\n", + pcb->snd_nxt - 1, pcb->rcv_nxt)); +} +#endif /* LWIP_TCP */ diff --git a/user/mpy/lib/lwip/src/core/timers.c b/user/mpy/lib/lwip/src/core/timers.c new file mode 100644 index 0000000..e308466 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/timers.c @@ -0,0 +1,487 @@ +/** + * @file + * Stack-internal timers implementation. + * This file includes timer callbacks for stack-internal timers as well as + * functions to set up or stop timers and check for expired timers. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * Simon Goldschmidt + * + */ + +#include "lwip/opt.h" + +#include "lwip/timers.h" +#include "lwip/tcp_impl.h" + +#if LWIP_TIMERS + +#include "lwip/def.h" +#include "lwip/memp.h" +#include "lwip/tcpip.h" + +#include "lwip/ip_frag.h" +#include "netif/etharp.h" +#include "lwip/dhcp.h" +#include "lwip/autoip.h" +#include "lwip/igmp.h" +#include "lwip/dns.h" +#include "lwip/sys.h" +#include "lwip/pbuf.h" + + +/** The one and only timeout list */ +static struct sys_timeo *next_timeout; +#if NO_SYS +static u32_t timeouts_last_time; +#endif /* NO_SYS */ + +#if LWIP_TCP +/** global variable that shows if the tcp timer is currently scheduled or not */ +static int tcpip_tcp_timer_active; + +/** + * Timer callback function that calls tcp_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +tcpip_tcp_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + + /* call TCP timer handler */ + tcp_tmr(); + /* timer still needed? */ + if (tcp_active_pcbs || tcp_tw_pcbs) { + /* restart timer */ + sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); + } else { + /* disable timer */ + tcpip_tcp_timer_active = 0; + } +} + +/** + * Called from TCP_REG when registering a new PCB: + * the reason is to have the TCP timer only running when + * there are active (or time-wait) PCBs. + */ +void +tcp_timer_needed(void) +{ + /* timer is off but needed again? */ + if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) { + /* enable and start timer */ + tcpip_tcp_timer_active = 1; + sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); + } +} +#endif /* LWIP_TCP */ + +#if IP_REASSEMBLY +/** + * Timer callback function that calls ip_reass_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +ip_reass_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: ip_reass_tmr()\n")); + ip_reass_tmr(); + sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); +} +#endif /* IP_REASSEMBLY */ + +#if LWIP_ARP +/** + * Timer callback function that calls etharp_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +arp_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: etharp_tmr()\n")); + etharp_tmr(); + sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); +} +#endif /* LWIP_ARP */ + +#if LWIP_DHCP +/** + * Timer callback function that calls dhcp_coarse_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +dhcp_timer_coarse(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_coarse_tmr()\n")); + dhcp_coarse_tmr(); + sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); +} + +/** + * Timer callback function that calls dhcp_fine_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +dhcp_timer_fine(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_fine_tmr()\n")); + dhcp_fine_tmr(); + sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); +} +#endif /* LWIP_DHCP */ + +#if LWIP_AUTOIP +/** + * Timer callback function that calls autoip_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +autoip_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: autoip_tmr()\n")); + autoip_tmr(); + sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); +} +#endif /* LWIP_AUTOIP */ + +#if LWIP_IGMP +/** + * Timer callback function that calls igmp_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +igmp_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: igmp_tmr()\n")); + igmp_tmr(); + sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); +} +#endif /* LWIP_IGMP */ + +#if LWIP_DNS +/** + * Timer callback function that calls dns_tmr() and reschedules itself. + * + * @param arg unused argument + */ +static void +dns_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dns_tmr()\n")); + dns_tmr(); + sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); +} +#endif /* LWIP_DNS */ + +/** Initialize this module */ +void sys_timeouts_init(void) +{ +#if IP_REASSEMBLY + sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); +#endif /* IP_REASSEMBLY */ +#if LWIP_ARP + sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); +#endif /* LWIP_ARP */ +#if LWIP_DHCP + sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); + sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); +#endif /* LWIP_DHCP */ +#if LWIP_AUTOIP + sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); +#endif /* LWIP_AUTOIP */ +#if LWIP_IGMP + sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); +#endif /* LWIP_IGMP */ +#if LWIP_DNS + sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); +#endif /* LWIP_DNS */ + +#if NO_SYS + /* Initialise timestamp for sys_check_timeouts */ + timeouts_last_time = sys_now(); +#endif +} + +/** + * Create a one-shot timer (aka timeout). Timeouts are processed in the + * following cases: + * - while waiting for a message using sys_timeouts_mbox_fetch() + * - by calling sys_check_timeouts() (NO_SYS==1 only) + * + * @param msecs time in milliseconds after that the timer should expire + * @param handler callback function to call when msecs have elapsed + * @param arg argument to pass to the callback function + */ +#if LWIP_DEBUG_TIMERNAMES +void +sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name) +#else /* LWIP_DEBUG_TIMERNAMES */ +void +sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) +#endif /* LWIP_DEBUG_TIMERNAMES */ +{ + struct sys_timeo *timeout, *t; + + timeout = (struct sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); + if (timeout == NULL) { + LWIP_ASSERT("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty", timeout != NULL); + return; + } + timeout->next = NULL; + timeout->h = handler; + timeout->arg = arg; + timeout->time = msecs; +#if LWIP_DEBUG_TIMERNAMES + timeout->handler_name = handler_name; + LWIP_DEBUGF(TIMERS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" handler=%s arg=%p\n", + (void *)timeout, msecs, handler_name, (void *)arg)); +#endif /* LWIP_DEBUG_TIMERNAMES */ + + if (next_timeout == NULL) { + next_timeout = timeout; + return; + } + + if (next_timeout->time > msecs) { + next_timeout->time -= msecs; + timeout->next = next_timeout; + next_timeout = timeout; + } else { + for(t = next_timeout; t != NULL; t = t->next) { + timeout->time -= t->time; + if (t->next == NULL || t->next->time > timeout->time) { + if (t->next != NULL) { + t->next->time -= timeout->time; + } + timeout->next = t->next; + t->next = timeout; + break; + } + } + } +} + +/** + * Go through timeout list (for this task only) and remove the first matching + * entry, even though the timeout has not triggered yet. + * + * @note This function only works as expected if there is only one timeout + * calling 'handler' in the list of timeouts. + * + * @param handler callback function that would be called by the timeout + * @param arg callback argument that would be passed to handler +*/ +void +sys_untimeout(sys_timeout_handler handler, void *arg) +{ + struct sys_timeo *prev_t, *t; + + if (next_timeout == NULL) { + return; + } + + for (t = next_timeout, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { + if ((t->h == handler) && (t->arg == arg)) { + /* We have a match */ + /* Unlink from previous in list */ + if (prev_t == NULL) { + next_timeout = t->next; + } else { + prev_t->next = t->next; + } + /* If not the last one, add time of this one back to next */ + if (t->next != NULL) { + t->next->time += t->time; + } + memp_free(MEMP_SYS_TIMEOUT, t); + return; + } + } + return; +} + +#if NO_SYS + +/** Handle timeouts for NO_SYS==1 (i.e. without using + * tcpip_thread/sys_timeouts_mbox_fetch(). Uses sys_now() to call timeout + * handler functions when timeouts expire. + * + * Must be called periodically from your main loop. + */ +void +sys_check_timeouts(void) +{ + if (next_timeout) { + struct sys_timeo *tmptimeout; + u32_t diff; + sys_timeout_handler handler; + void *arg; + u8_t had_one; + u32_t now; + + now = sys_now(); + /* this cares for wraparounds */ + diff = now - timeouts_last_time; + do + { +#if PBUF_POOL_FREE_OOSEQ + PBUF_CHECK_FREE_OOSEQ(); +#endif /* PBUF_POOL_FREE_OOSEQ */ + had_one = 0; + tmptimeout = next_timeout; + if (tmptimeout && (tmptimeout->time <= diff)) { + /* timeout has expired */ + had_one = 1; + timeouts_last_time = now; + diff -= tmptimeout->time; + next_timeout = tmptimeout->next; + handler = tmptimeout->h; + arg = tmptimeout->arg; +#if LWIP_DEBUG_TIMERNAMES + if (handler != NULL) { + LWIP_DEBUGF(TIMERS_DEBUG, ("sct calling h=%s arg=%p\n", + tmptimeout->handler_name, arg)); + } +#endif /* LWIP_DEBUG_TIMERNAMES */ + memp_free(MEMP_SYS_TIMEOUT, tmptimeout); + if (handler != NULL) { + handler(arg); + } + } + /* repeat until all expired timers have been called */ + }while(had_one); + } +} + +/** Set back the timestamp of the last call to sys_check_timeouts() + * This is necessary if sys_check_timeouts() hasn't been called for a long + * time (e.g. while saving energy) to prevent all timer functions of that + * period being called. + */ +void +sys_restart_timeouts(void) +{ + timeouts_last_time = sys_now(); +} + +#else /* NO_SYS */ + +/** + * Wait (forever) for a message to arrive in an mbox. + * While waiting, timeouts are processed. + * + * @param mbox the mbox to fetch the message from + * @param msg the place to store the message + */ +void +sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) +{ + u32_t time_needed; + struct sys_timeo *tmptimeout; + sys_timeout_handler handler; + void *arg; + + again: + if (!next_timeout) { + time_needed = sys_arch_mbox_fetch(mbox, msg, 0); + } else { + if (next_timeout->time > 0) { + time_needed = sys_arch_mbox_fetch(mbox, msg, next_timeout->time); + } else { + time_needed = SYS_ARCH_TIMEOUT; + } + + if (time_needed == SYS_ARCH_TIMEOUT) { + /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message + could be fetched. We should now call the timeout handler and + deallocate the memory allocated for the timeout. */ + tmptimeout = next_timeout; + next_timeout = tmptimeout->next; + handler = tmptimeout->h; + arg = tmptimeout->arg; +#if LWIP_DEBUG_TIMERNAMES + if (handler != NULL) { + LWIP_DEBUGF(TIMERS_DEBUG, ("stmf calling h=%s arg=%p\n", + tmptimeout->handler_name, arg)); + } +#endif /* LWIP_DEBUG_TIMERNAMES */ + memp_free(MEMP_SYS_TIMEOUT, tmptimeout); + if (handler != NULL) { + /* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the + timeout handler function. */ + LOCK_TCPIP_CORE(); + handler(arg); + UNLOCK_TCPIP_CORE(); + } + LWIP_TCPIP_THREAD_ALIVE(); + + /* We try again to fetch a message from the mbox. */ + goto again; + } else { + /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout + occured. The time variable is set to the number of + milliseconds we waited for the message. */ + if (time_needed < next_timeout->time) { + next_timeout->time -= time_needed; + } else { + next_timeout->time = 0; + } + } + } +} + +#endif /* NO_SYS */ + +#else /* LWIP_TIMERS */ +/* Satisfy the TCP code which calls this function */ +void +tcp_timer_needed(void) +{ +} +#endif /* LWIP_TIMERS */ diff --git a/user/mpy/lib/lwip/src/core/udp.c b/user/mpy/lib/lwip/src/core/udp.c new file mode 100644 index 0000000..32c7d38 --- /dev/null +++ b/user/mpy/lib/lwip/src/core/udp.c @@ -0,0 +1,1013 @@ +/** + * @file + * User Datagram Protocol module + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + + +/* udp.c + * + * The code for the User Datagram Protocol UDP & UDPLite (RFC 3828). + * + */ + +/* @todo Check the use of '(struct udp_pcb).chksum_len_rx'! + */ + +#include "lwip/opt.h" + +#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/udp.h" +#include "lwip/def.h" +#include "lwip/memp.h" +#include "lwip/inet_chksum.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/icmp.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" +#include "arch/perf.h" +#include "lwip/dhcp.h" + +#include + +#ifndef UDP_LOCAL_PORT_RANGE_START +/* From http://www.iana.org/assignments/port-numbers: + "The Dynamic and/or Private Ports are those from 49152 through 65535" */ +#define UDP_LOCAL_PORT_RANGE_START 0xc000 +#define UDP_LOCAL_PORT_RANGE_END 0xffff +#define UDP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~UDP_LOCAL_PORT_RANGE_START) + UDP_LOCAL_PORT_RANGE_START) +#endif + +/* last local UDP port */ +static u16_t udp_port = UDP_LOCAL_PORT_RANGE_START; + +/* The list of UDP PCBs */ +/* exported in udp.h (was static) */ +struct udp_pcb *udp_pcbs; + +/** + * Initialize this module. + */ +void +udp_init(void) +{ +#if LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) + udp_port = UDP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()); +#endif /* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) */ +} + +/** + * Allocate a new local UDP port. + * + * @return a new (free) local UDP port number + */ +static u16_t +udp_new_port(void) +{ + u16_t n = 0; + struct udp_pcb *pcb; + +again: + if (udp_port++ == UDP_LOCAL_PORT_RANGE_END) { + udp_port = UDP_LOCAL_PORT_RANGE_START; + } + /* Check all PCBs. */ + for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { + if (pcb->local_port == udp_port) { + if (++n > (UDP_LOCAL_PORT_RANGE_END - UDP_LOCAL_PORT_RANGE_START)) { + return 0; + } + goto again; + } + } + return udp_port; +#if 0 + struct udp_pcb *ipcb = udp_pcbs; + while ((ipcb != NULL) && (udp_port != UDP_LOCAL_PORT_RANGE_END)) { + if (ipcb->local_port == udp_port) { + /* port is already used by another udp_pcb */ + udp_port++; + /* restart scanning all udp pcbs */ + ipcb = udp_pcbs; + } else { + /* go on with next udp pcb */ + ipcb = ipcb->next; + } + } + if (ipcb != NULL) { + return 0; + } + return udp_port; +#endif +} + +/** + * Process an incoming UDP datagram. + * + * Given an incoming UDP datagram (as a chain of pbufs) this function + * finds a corresponding UDP PCB and hands over the pbuf to the pcbs + * recv function. If no pcb is found or the datagram is incorrect, the + * pbuf is freed. + * + * @param p pbuf to be demultiplexed to a UDP PCB. + * @param inp network interface on which the datagram was received. + * + */ +void +udp_input(struct pbuf *p, struct netif *inp) +{ + struct udp_hdr *udphdr; + struct udp_pcb *pcb, *prev; + struct udp_pcb *uncon_pcb; + struct ip_hdr *iphdr; + u16_t src, dest; + u8_t local_match; + u8_t broadcast; + + PERF_START; + + UDP_STATS_INC(udp.recv); + + iphdr = (struct ip_hdr *)p->payload; + + /* Check minimum length (IP header + UDP header) + * and move payload pointer to UDP header */ + if (p->tot_len < (IPH_HL(iphdr) * 4 + UDP_HLEN) || pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4))) { + /* drop short packets */ + LWIP_DEBUGF(UDP_DEBUG, + ("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len)); + UDP_STATS_INC(udp.lenerr); + UDP_STATS_INC(udp.drop); + snmp_inc_udpinerrors(); + pbuf_free(p); + goto end; + } + + udphdr = (struct udp_hdr *)p->payload; + + /* is broadcast packet ? */ + broadcast = ip_addr_isbroadcast(¤t_iphdr_dest, inp); + + LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); + + /* convert src and dest ports to host byte order */ + src = ntohs(udphdr->src); + dest = ntohs(udphdr->dest); + + udp_debug_print(udphdr); + + /* print the UDP source and destination */ + LWIP_DEBUGF(UDP_DEBUG, + ("udp (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") <-- " + "(%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", + ip4_addr1_16(&iphdr->dest), ip4_addr2_16(&iphdr->dest), + ip4_addr3_16(&iphdr->dest), ip4_addr4_16(&iphdr->dest), ntohs(udphdr->dest), + ip4_addr1_16(&iphdr->src), ip4_addr2_16(&iphdr->src), + ip4_addr3_16(&iphdr->src), ip4_addr4_16(&iphdr->src), ntohs(udphdr->src))); + +#if LWIP_DHCP + pcb = NULL; + /* when LWIP_DHCP is active, packets to DHCP_CLIENT_PORT may only be processed by + the dhcp module, no other UDP pcb may use the local UDP port DHCP_CLIENT_PORT */ + if (dest == DHCP_CLIENT_PORT) { + /* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */ + if (src == DHCP_SERVER_PORT) { + if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) { + /* accept the packe if + (- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY! + - inp->dhcp->pcb->remote == ANY or iphdr->src */ + if ((ip_addr_isany(&inp->dhcp->pcb->remote_ip) || + ip_addr_cmp(&(inp->dhcp->pcb->remote_ip), ¤t_iphdr_src))) { + pcb = inp->dhcp->pcb; + } + } + } + } else +#endif /* LWIP_DHCP */ + { + prev = NULL; + local_match = 0; + uncon_pcb = NULL; + /* Iterate through the UDP pcb list for a matching pcb. + * 'Perfect match' pcbs (connected to the remote port & ip address) are + * preferred. If no perfect match is found, the first unconnected pcb that + * matches the local port and ip address gets the datagram. */ + for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { + local_match = 0; + /* print the PCB local and remote address */ + LWIP_DEBUGF(UDP_DEBUG, + ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- " + "(%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", + ip4_addr1_16(&pcb->local_ip), ip4_addr2_16(&pcb->local_ip), + ip4_addr3_16(&pcb->local_ip), ip4_addr4_16(&pcb->local_ip), pcb->local_port, + ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), + ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip), pcb->remote_port)); + + /* compare PCB local addr+port to UDP destination addr+port */ + if (pcb->local_port == dest) { + if ( + (!broadcast && ip_addr_isany(&pcb->local_ip)) || + ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest) || +#if LWIP_IGMP + ip_addr_ismulticast(¤t_iphdr_dest) || +#endif /* LWIP_IGMP */ +#if IP_SOF_BROADCAST_RECV + (broadcast && ip_get_option(pcb, SOF_BROADCAST) && + (ip_addr_isany(&pcb->local_ip) || + ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))) { +#else /* IP_SOF_BROADCAST_RECV */ + (broadcast && + (ip_addr_isany(&pcb->local_ip) || + ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))) { +#endif /* IP_SOF_BROADCAST_RECV */ + local_match = 1; + if ((uncon_pcb == NULL) && + ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { + /* the first unconnected matching PCB */ + uncon_pcb = pcb; + } + } + } + /* compare PCB remote addr+port to UDP source addr+port */ + if ((local_match != 0) && + (pcb->remote_port == src) && + (ip_addr_isany(&pcb->remote_ip) || + ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src))) { + /* the first fully matching PCB */ + if (prev != NULL) { + /* move the pcb to the front of udp_pcbs so that is + found faster next time */ + prev->next = pcb->next; + pcb->next = udp_pcbs; + udp_pcbs = pcb; + } else { + UDP_STATS_INC(udp.cachehit); + } + break; + } + prev = pcb; + } + /* no fully matching pcb found? then look for an unconnected pcb */ + if (pcb == NULL) { + pcb = uncon_pcb; + } + } + + /* Check checksum if this is a match or if it was directed at us. */ + if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, ¤t_iphdr_dest)) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n")); +#if LWIP_UDPLITE + if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) { + /* Do the UDP Lite checksum */ +#if CHECKSUM_CHECK_UDP + u16_t chklen = ntohs(udphdr->len); + if (chklen < sizeof(struct udp_hdr)) { + if (chklen == 0) { + /* For UDP-Lite, checksum length of 0 means checksum + over the complete packet (See RFC 3828 chap. 3.1) */ + chklen = p->tot_len; + } else { + /* At least the UDP-Lite header must be covered by the + checksum! (Again, see RFC 3828 chap. 3.1) */ + UDP_STATS_INC(udp.chkerr); + UDP_STATS_INC(udp.drop); + snmp_inc_udpinerrors(); + pbuf_free(p); + goto end; + } + } + if (inet_chksum_pseudo_partial(p, ¤t_iphdr_src, ¤t_iphdr_dest, + IP_PROTO_UDPLITE, p->tot_len, chklen) != 0) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("udp_input: UDP Lite datagram discarded due to failing checksum\n")); + UDP_STATS_INC(udp.chkerr); + UDP_STATS_INC(udp.drop); + snmp_inc_udpinerrors(); + pbuf_free(p); + goto end; + } +#endif /* CHECKSUM_CHECK_UDP */ + } else +#endif /* LWIP_UDPLITE */ + { +#if CHECKSUM_CHECK_UDP + if (udphdr->chksum != 0) { + if (inet_chksum_pseudo(p, ip_current_src_addr(), ip_current_dest_addr(), + IP_PROTO_UDP, p->tot_len) != 0) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("udp_input: UDP datagram discarded due to failing checksum\n")); + UDP_STATS_INC(udp.chkerr); + UDP_STATS_INC(udp.drop); + snmp_inc_udpinerrors(); + pbuf_free(p); + goto end; + } + } +#endif /* CHECKSUM_CHECK_UDP */ + } + if(pbuf_header(p, -UDP_HLEN)) { + /* Can we cope with this failing? Just assert for now */ + LWIP_ASSERT("pbuf_header failed\n", 0); + UDP_STATS_INC(udp.drop); + snmp_inc_udpinerrors(); + pbuf_free(p); + goto end; + } + if (pcb != NULL) { + snmp_inc_udpindatagrams(); +#if SO_REUSE && SO_REUSE_RXTOALL + if ((broadcast || ip_addr_ismulticast(¤t_iphdr_dest)) && + ip_get_option(pcb, SOF_REUSEADDR)) { + /* pass broadcast- or multicast packets to all multicast pcbs + if SOF_REUSEADDR is set on the first match */ + struct udp_pcb *mpcb; + u8_t p_header_changed = 0; + for (mpcb = udp_pcbs; mpcb != NULL; mpcb = mpcb->next) { + if (mpcb != pcb) { + /* compare PCB local addr+port to UDP destination addr+port */ + if ((mpcb->local_port == dest) && + ((!broadcast && ip_addr_isany(&mpcb->local_ip)) || + ip_addr_cmp(&(mpcb->local_ip), ¤t_iphdr_dest) || +#if LWIP_IGMP + ip_addr_ismulticast(¤t_iphdr_dest) || +#endif /* LWIP_IGMP */ +#if IP_SOF_BROADCAST_RECV + (broadcast && ip_get_option(mpcb, SOF_BROADCAST)))) { +#else /* IP_SOF_BROADCAST_RECV */ + (broadcast))) { +#endif /* IP_SOF_BROADCAST_RECV */ + /* pass a copy of the packet to all local matches */ + if (mpcb->recv != NULL) { + struct pbuf *q; + /* for that, move payload to IP header again */ + if (p_header_changed == 0) { + pbuf_header(p, (s16_t)((IPH_HL(iphdr) * 4) + UDP_HLEN)); + p_header_changed = 1; + } + q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); + if (q != NULL) { + err_t err = pbuf_copy(q, p); + if (err == ERR_OK) { + /* move payload to UDP data */ + pbuf_header(q, -(s16_t)((IPH_HL(iphdr) * 4) + UDP_HLEN)); + mpcb->recv(mpcb->recv_arg, mpcb, q, ip_current_src_addr(), src); + } + } + } + } + } + } + if (p_header_changed) { + /* and move payload to UDP data again */ + pbuf_header(p, -(s16_t)((IPH_HL(iphdr) * 4) + UDP_HLEN)); + } + } +#endif /* SO_REUSE && SO_REUSE_RXTOALL */ + /* callback */ + if (pcb->recv != NULL) { + /* now the recv function is responsible for freeing p */ + pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr(), src); + } else { + /* no recv function registered? then we have to free the pbuf! */ + pbuf_free(p); + goto end; + } + } else { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: not for us.\n")); + +#if LWIP_ICMP + /* No match was found, send ICMP destination port unreachable unless + destination address was broadcast/multicast. */ + if (!broadcast && + !ip_addr_ismulticast(¤t_iphdr_dest)) { + /* move payload pointer back to ip header */ + pbuf_header(p, (IPH_HL(iphdr) * 4) + UDP_HLEN); + LWIP_ASSERT("p->payload == iphdr", (p->payload == iphdr)); + icmp_dest_unreach(p, ICMP_DUR_PORT); + } +#endif /* LWIP_ICMP */ + UDP_STATS_INC(udp.proterr); + UDP_STATS_INC(udp.drop); + snmp_inc_udpnoports(); + pbuf_free(p); + } + } else { + pbuf_free(p); + } +end: + PERF_STOP("udp_input"); +} + +/** + * Send data using UDP. + * + * @param pcb UDP PCB used to send the data. + * @param p chain of pbuf's to be sent. + * + * The datagram will be sent to the current remote_ip & remote_port + * stored in pcb. If the pcb is not bound to a port, it will + * automatically be bound to a random port. + * + * @return lwIP error code. + * - ERR_OK. Successful. No error occured. + * - ERR_MEM. Out of memory. + * - ERR_RTE. Could not find route to destination address. + * - More errors could be returned by lower protocol layers. + * + * @see udp_disconnect() udp_sendto() + */ +err_t +udp_send(struct udp_pcb *pcb, struct pbuf *p) +{ + /* send to the packet using remote ip and port stored in the pcb */ + return udp_sendto(pcb, p, &pcb->remote_ip, pcb->remote_port); +} + +#if LWIP_CHECKSUM_ON_COPY +/** Same as udp_send() but with checksum + */ +err_t +udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, + u8_t have_chksum, u16_t chksum) +{ + /* send to the packet using remote ip and port stored in the pcb */ + return udp_sendto_chksum(pcb, p, &pcb->remote_ip, pcb->remote_port, + have_chksum, chksum); +} +#endif /* LWIP_CHECKSUM_ON_COPY */ + +/** + * Send data to a specified address using UDP. + * + * @param pcb UDP PCB used to send the data. + * @param p chain of pbuf's to be sent. + * @param dst_ip Destination IP address. + * @param dst_port Destination UDP port. + * + * dst_ip & dst_port are expected to be in the same byte order as in the pcb. + * + * If the PCB already has a remote address association, it will + * be restored after the data is sent. + * + * @return lwIP error code (@see udp_send for possible error codes) + * + * @see udp_disconnect() udp_send() + */ +err_t +udp_sendto(struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *dst_ip, u16_t dst_port) +{ +#if LWIP_CHECKSUM_ON_COPY + return udp_sendto_chksum(pcb, p, dst_ip, dst_port, 0, 0); +} + +/** Same as udp_sendto(), but with checksum */ +err_t +udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, + u16_t dst_port, u8_t have_chksum, u16_t chksum) +{ +#endif /* LWIP_CHECKSUM_ON_COPY */ + struct netif *netif; + + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n")); + + /* find the outgoing network interface for this packet */ +#if LWIP_IGMP + netif = ip_route((ip_addr_ismulticast(dst_ip))?(&(pcb->multicast_ip)):(dst_ip)); +#else + netif = ip_route(dst_ip); +#endif /* LWIP_IGMP */ + + /* no outgoing network interface could be found? */ + if (netif == NULL) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(dst_ip), ip4_addr2_16(dst_ip), ip4_addr3_16(dst_ip), ip4_addr4_16(dst_ip))); + UDP_STATS_INC(udp.rterr); + return ERR_RTE; + } +#if LWIP_CHECKSUM_ON_COPY + return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum); +#else /* LWIP_CHECKSUM_ON_COPY */ + return udp_sendto_if(pcb, p, dst_ip, dst_port, netif); +#endif /* LWIP_CHECKSUM_ON_COPY */ +} + +/** + * Send data to a specified address using UDP. + * The netif used for sending can be specified. + * + * This function exists mainly for DHCP, to be able to send UDP packets + * on a netif that is still down. + * + * @param pcb UDP PCB used to send the data. + * @param p chain of pbuf's to be sent. + * @param dst_ip Destination IP address. + * @param dst_port Destination UDP port. + * @param netif the netif used for sending. + * + * dst_ip & dst_port are expected to be in the same byte order as in the pcb. + * + * @return lwIP error code (@see udp_send for possible error codes) + * + * @see udp_disconnect() udp_send() + */ +err_t +udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif) +{ +#if LWIP_CHECKSUM_ON_COPY + return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0); +} + +/** Same as udp_sendto_if(), but with checksum */ +err_t +udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, + u16_t dst_port, struct netif *netif, u8_t have_chksum, + u16_t chksum) +{ +#endif /* LWIP_CHECKSUM_ON_COPY */ + struct udp_hdr *udphdr; + ip_addr_t *src_ip; + err_t err; + struct pbuf *q; /* q will be sent down the stack */ + +#if IP_SOF_BROADCAST + /* broadcast filter? */ + if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(dst_ip, netif)) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, + ("udp_sendto_if: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); + return ERR_VAL; + } +#endif /* IP_SOF_BROADCAST */ + + /* if the PCB is not yet bound to a port, bind it here */ + if (pcb->local_port == 0) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send: not yet bound to a port, binding now\n")); + err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); + if (err != ERR_OK) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: forced port bind failed\n")); + return err; + } + } + + /* not enough space to add an UDP header to first pbuf in given p chain? */ + if (pbuf_header(p, UDP_HLEN)) { + /* allocate header in a separate new pbuf */ + q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM); + /* new header pbuf could not be allocated? */ + if (q == NULL) { + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: could not allocate header\n")); + return ERR_MEM; + } + if (p->tot_len != 0) { + /* chain header q in front of given pbuf p (only if p contains data) */ + pbuf_chain(q, p); + } + /* first pbuf q points to header pbuf */ + LWIP_DEBUGF(UDP_DEBUG, + ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); + } else { + /* adding space for header within p succeeded */ + /* first pbuf q equals given pbuf */ + q = p; + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p)); + } + LWIP_ASSERT("check that first pbuf can hold struct udp_hdr", + (q->len >= sizeof(struct udp_hdr))); + /* q now represents the packet to be sent */ + udphdr = (struct udp_hdr *)q->payload; + udphdr->src = htons(pcb->local_port); + udphdr->dest = htons(dst_port); + /* in UDP, 0 checksum means 'no checksum' */ + udphdr->chksum = 0x0000; + + /* Multicast Loop? */ +#if LWIP_IGMP + if (ip_addr_ismulticast(dst_ip) && ((pcb->flags & UDP_FLAGS_MULTICAST_LOOP) != 0)) { + q->flags |= PBUF_FLAG_MCASTLOOP; + } +#endif /* LWIP_IGMP */ + + + /* PCB local address is IP_ANY_ADDR? */ + if (ip_addr_isany(&pcb->local_ip)) { + /* use outgoing network interface IP address as source address */ + src_ip = &(netif->ip_addr); + } else { + /* check if UDP PCB local IP address is correct + * this could be an old address if netif->ip_addr has changed */ + if (!ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) { + /* local_ip doesn't match, drop the packet */ + if (q != p) { + /* free the header pbuf */ + pbuf_free(q); + q = NULL; + /* p is still referenced by the caller, and will live on */ + } + return ERR_VAL; + } + /* use UDP PCB local IP address as source address */ + src_ip = &(pcb->local_ip); + } + + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len)); + +#if LWIP_UDPLITE + /* UDP Lite protocol? */ + if (pcb->flags & UDP_FLAGS_UDPLITE) { + u16_t chklen, chklen_hdr; + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len)); + /* set UDP message length in UDP header */ + chklen_hdr = chklen = pcb->chksum_len_tx; + if ((chklen < sizeof(struct udp_hdr)) || (chklen > q->tot_len)) { + if (chklen != 0) { + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE pcb->chksum_len is illegal: %"U16_F"\n", chklen)); + } + /* For UDP-Lite, checksum length of 0 means checksum + over the complete packet. (See RFC 3828 chap. 3.1) + At least the UDP-Lite header must be covered by the + checksum, therefore, if chksum_len has an illegal + value, we generate the checksum over the complete + packet to be safe. */ + chklen_hdr = 0; + chklen = q->tot_len; + } + udphdr->len = htons(chklen_hdr); + /* calculate checksum */ +#if CHECKSUM_GEN_UDP + udphdr->chksum = inet_chksum_pseudo_partial(q, src_ip, dst_ip, + IP_PROTO_UDPLITE, q->tot_len, +#if !LWIP_CHECKSUM_ON_COPY + chklen); +#else /* !LWIP_CHECKSUM_ON_COPY */ + (have_chksum ? UDP_HLEN : chklen)); + if (have_chksum) { + u32_t acc; + acc = udphdr->chksum + (u16_t)~(chksum); + udphdr->chksum = FOLD_U32T(acc); + } +#endif /* !LWIP_CHECKSUM_ON_COPY */ + + /* chksum zero must become 0xffff, as zero means 'no checksum' */ + if (udphdr->chksum == 0x0000) { + udphdr->chksum = 0xffff; + } +#endif /* CHECKSUM_GEN_UDP */ + /* output to IP */ + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n")); + NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint); + err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); + NETIF_SET_HWADDRHINT(netif, NULL); + } else +#endif /* LWIP_UDPLITE */ + { /* UDP */ + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); + udphdr->len = htons(q->tot_len); + /* calculate checksum */ +#if CHECKSUM_GEN_UDP + if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { + u16_t udpchksum; +#if LWIP_CHECKSUM_ON_COPY + if (have_chksum) { + u32_t acc; + udpchksum = inet_chksum_pseudo_partial(q, src_ip, dst_ip, IP_PROTO_UDP, + q->tot_len, UDP_HLEN); + acc = udpchksum + (u16_t)~(chksum); + udpchksum = FOLD_U32T(acc); + } else +#endif /* LWIP_CHECKSUM_ON_COPY */ + { + udpchksum = inet_chksum_pseudo(q, src_ip, dst_ip, IP_PROTO_UDP, q->tot_len); + } + + /* chksum zero must become 0xffff, as zero means 'no checksum' */ + if (udpchksum == 0x0000) { + udpchksum = 0xffff; + } + udphdr->chksum = udpchksum; + } +#endif /* CHECKSUM_GEN_UDP */ + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); + /* output to IP */ + NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint); + err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif); + NETIF_SET_HWADDRHINT(netif, NULL); + } + /* TODO: must this be increased even if error occured? */ + snmp_inc_udpoutdatagrams(); + + /* did we chain a separate header pbuf earlier? */ + if (q != p) { + /* free the header pbuf */ + pbuf_free(q); + q = NULL; + /* p is still referenced by the caller, and will live on */ + } + + UDP_STATS_INC(udp.xmit); + return err; +} + +/** + * Bind an UDP PCB. + * + * @param pcb UDP PCB to be bound with a local address ipaddr and port. + * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to + * bind to all local interfaces. + * @param port local UDP port to bind with. Use 0 to automatically bind + * to a random port between UDP_LOCAL_PORT_RANGE_START and + * UDP_LOCAL_PORT_RANGE_END. + * + * ipaddr & port are expected to be in the same byte order as in the pcb. + * + * @return lwIP error code. + * - ERR_OK. Successful. No error occured. + * - ERR_USE. The specified ipaddr and port are already bound to by + * another UDP PCB. + * + * @see udp_disconnect() + */ +err_t +udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) +{ + struct udp_pcb *ipcb; + u8_t rebind; + + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_bind(ipaddr = ")); + ip_addr_debug_print(UDP_DEBUG, ipaddr); + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, (", port = %"U16_F")\n", port)); + + rebind = 0; + /* Check for double bind and rebind of the same pcb */ + for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { + /* is this UDP PCB already on active list? */ + if (pcb == ipcb) { + /* pcb may occur at most once in active list */ + LWIP_ASSERT("rebind == 0", rebind == 0); + /* pcb already in list, just rebind */ + rebind = 1; + } + + /* By default, we don't allow to bind to a port that any other udp + PCB is alread bound to, unless *all* PCBs with that port have tha + REUSEADDR flag set. */ +#if SO_REUSE + else if (!ip_get_option(pcb, SOF_REUSEADDR) && + !ip_get_option(ipcb, SOF_REUSEADDR)) { +#else /* SO_REUSE */ + /* port matches that of PCB in list and REUSEADDR not set -> reject */ + else { +#endif /* SO_REUSE */ + if ((ipcb->local_port == port) && + /* IP address matches, or one is IP_ADDR_ANY? */ + (ip_addr_isany(&(ipcb->local_ip)) || + ip_addr_isany(ipaddr) || + ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { + /* other PCB already binds to this local IP and port */ + LWIP_DEBUGF(UDP_DEBUG, + ("udp_bind: local port %"U16_F" already bound by another pcb\n", port)); + return ERR_USE; + } + } + } + + ip_addr_set(&pcb->local_ip, ipaddr); + + /* no port specified? */ + if (port == 0) { + port = udp_new_port(); + if (port == 0) { + /* no more ports available in local range */ + LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n")); + return ERR_USE; + } + } + pcb->local_port = port; + snmp_insert_udpidx_tree(pcb); + /* pcb not active yet? */ + if (rebind == 0) { + /* place the PCB on the active list if not already there */ + pcb->next = udp_pcbs; + udp_pcbs = pcb; + } + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n", + ip4_addr1_16(&pcb->local_ip), ip4_addr2_16(&pcb->local_ip), + ip4_addr3_16(&pcb->local_ip), ip4_addr4_16(&pcb->local_ip), + pcb->local_port)); + return ERR_OK; +} +/** + * Connect an UDP PCB. + * + * This will associate the UDP PCB with the remote address. + * + * @param pcb UDP PCB to be connected with remote address ipaddr and port. + * @param ipaddr remote IP address to connect with. + * @param port remote UDP port to connect with. + * + * @return lwIP error code + * + * ipaddr & port are expected to be in the same byte order as in the pcb. + * + * The udp pcb is bound to a random local port if not already bound. + * + * @see udp_disconnect() + */ +err_t +udp_connect(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) +{ + struct udp_pcb *ipcb; + + if (pcb->local_port == 0) { + err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); + if (err != ERR_OK) { + return err; + } + } + + ip_addr_set(&pcb->remote_ip, ipaddr); + pcb->remote_port = port; + pcb->flags |= UDP_FLAGS_CONNECTED; +/** TODO: this functionality belongs in upper layers */ +#ifdef LWIP_UDP_TODO + /* Nail down local IP for netconn_addr()/getsockname() */ + if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) { + struct netif *netif; + + if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { + LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr)); + UDP_STATS_INC(udp.rterr); + return ERR_RTE; + } + /** TODO: this will bind the udp pcb locally, to the interface which + is used to route output packets to the remote address. However, we + might want to accept incoming packets on any interface! */ + pcb->local_ip = netif->ip_addr; + } else if (ip_addr_isany(&pcb->remote_ip)) { + pcb->local_ip.addr = 0; + } +#endif + LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, + ("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n", + ip4_addr1_16(&pcb->local_ip), ip4_addr2_16(&pcb->local_ip), + ip4_addr3_16(&pcb->local_ip), ip4_addr4_16(&pcb->local_ip), + pcb->local_port)); + + /* Insert UDP PCB into the list of active UDP PCBs. */ + for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { + if (pcb == ipcb) { + /* already on the list, just return */ + return ERR_OK; + } + } + /* PCB not yet on the list, add PCB now */ + pcb->next = udp_pcbs; + udp_pcbs = pcb; + return ERR_OK; +} + +/** + * Disconnect a UDP PCB + * + * @param pcb the udp pcb to disconnect. + */ +void +udp_disconnect(struct udp_pcb *pcb) +{ + /* reset remote address association */ + ip_addr_set_any(&pcb->remote_ip); + pcb->remote_port = 0; + /* mark PCB as unconnected */ + pcb->flags &= ~UDP_FLAGS_CONNECTED; +} + +/** + * Set a receive callback for a UDP PCB + * + * This callback will be called when receiving a datagram for the pcb. + * + * @param pcb the pcb for wich to set the recv callback + * @param recv function pointer of the callback function + * @param recv_arg additional argument to pass to the callback function + */ +void +udp_recv(struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg) +{ + /* remember recv() callback and user data */ + pcb->recv = recv; + pcb->recv_arg = recv_arg; +} + +/** + * Remove an UDP PCB. + * + * @param pcb UDP PCB to be removed. The PCB is removed from the list of + * UDP PCB's and the data structure is freed from memory. + * + * @see udp_new() + */ +void +udp_remove(struct udp_pcb *pcb) +{ + struct udp_pcb *pcb2; + + snmp_delete_udpidx_tree(pcb); + /* pcb to be removed is first in list? */ + if (udp_pcbs == pcb) { + /* make list start at 2nd pcb */ + udp_pcbs = udp_pcbs->next; + /* pcb not 1st in list */ + } else { + for (pcb2 = udp_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { + /* find pcb in udp_pcbs list */ + if (pcb2->next != NULL && pcb2->next == pcb) { + /* remove pcb from list */ + pcb2->next = pcb->next; + } + } + } + memp_free(MEMP_UDP_PCB, pcb); +} + +/** + * Create a UDP PCB. + * + * @return The UDP PCB which was created. NULL if the PCB data structure + * could not be allocated. + * + * @see udp_remove() + */ +struct udp_pcb * +udp_new(void) +{ + struct udp_pcb *pcb; + pcb = (struct udp_pcb *)memp_malloc(MEMP_UDP_PCB); + /* could allocate UDP PCB? */ + if (pcb != NULL) { + /* UDP Lite: by initializing to all zeroes, chksum_len is set to 0 + * which means checksum is generated over the whole datagram per default + * (recommended as default by RFC 3828). */ + /* initialize PCB to all zeroes */ + memset(pcb, 0, sizeof(struct udp_pcb)); + pcb->ttl = UDP_TTL; + } + return pcb; +} + +#if UDP_DEBUG +/** + * Print UDP header information for debug purposes. + * + * @param udphdr pointer to the udp header in memory. + */ +void +udp_debug_print(struct udp_hdr *udphdr) +{ + LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); + LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", + ntohs(udphdr->src), ntohs(udphdr->dest))); + LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); + LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n", + ntohs(udphdr->len), ntohs(udphdr->chksum))); + LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); +} +#endif /* UDP_DEBUG */ + +#endif /* LWIP_UDP */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h new file mode 100644 index 0000000..e62b72e --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h @@ -0,0 +1,118 @@ +/** + * @file + * + * AutoIP Automatic LinkLocal IP Configuration + */ + +/* + * + * Copyright (c) 2007 Dominik Spies + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Dominik Spies + * + * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform + * with RFC 3927. + * + * + * Please coordinate changes and requests with Dominik Spies + * + */ + +#ifndef __LWIP_AUTOIP_H__ +#define __LWIP_AUTOIP_H__ + +#include "lwip/opt.h" + +#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/netif.h" +#include "lwip/udp.h" +#include "netif/etharp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* AutoIP Timing */ +#define AUTOIP_TMR_INTERVAL 100 +#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) + +/* RFC 3927 Constants */ +#define PROBE_WAIT 1 /* second (initial random delay) */ +#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ +#define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ +#define PROBE_NUM 3 /* (number of probe packets) */ +#define ANNOUNCE_NUM 2 /* (number of announcement packets) */ +#define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ +#define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ +#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ +#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ +#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ + +/* AutoIP client states */ +#define AUTOIP_STATE_OFF 0 +#define AUTOIP_STATE_PROBING 1 +#define AUTOIP_STATE_ANNOUNCING 2 +#define AUTOIP_STATE_BOUND 3 + +struct autoip +{ + ip_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */ + u8_t state; /* current AutoIP state machine state */ + u8_t sent_num; /* sent number of probes or announces, dependent on state */ + u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ + u8_t lastconflict; /* ticks until a conflict can be solved by defending */ + u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */ +}; + + +#define autoip_init() /* Compatibility define, no init needed. */ + +/** Set a struct autoip allocated by the application to work with */ +void autoip_set_struct(struct netif *netif, struct autoip *autoip); + +/** Start AutoIP client */ +err_t autoip_start(struct netif *netif); + +/** Stop AutoIP client */ +err_t autoip_stop(struct netif *netif); + +/** Handles every incoming ARP Packet, called by etharp_arp_input */ +void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); + +/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */ +void autoip_tmr(void); + +/** Handle a possible change in the network configuration */ +void autoip_network_changed(struct netif *netif); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_AUTOIP */ + +#endif /* __LWIP_AUTOIP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h new file mode 100644 index 0000000..d47a7d8 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_ICMP_H__ +#define __LWIP_ICMP_H__ + +#include "lwip/opt.h" +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ICMP_ER 0 /* echo reply */ +#define ICMP_DUR 3 /* destination unreachable */ +#define ICMP_SQ 4 /* source quench */ +#define ICMP_RD 5 /* redirect */ +#define ICMP_ECHO 8 /* echo */ +#define ICMP_TE 11 /* time exceeded */ +#define ICMP_PP 12 /* parameter problem */ +#define ICMP_TS 13 /* timestamp */ +#define ICMP_TSR 14 /* timestamp reply */ +#define ICMP_IRQ 15 /* information request */ +#define ICMP_IR 16 /* information reply */ + +enum icmp_dur_type { + ICMP_DUR_NET = 0, /* net unreachable */ + ICMP_DUR_HOST = 1, /* host unreachable */ + ICMP_DUR_PROTO = 2, /* protocol unreachable */ + ICMP_DUR_PORT = 3, /* port unreachable */ + ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ + ICMP_DUR_SR = 5 /* source route failed */ +}; + +enum icmp_te_type { + ICMP_TE_TTL = 0, /* time to live exceeded in transit */ + ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ +}; + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +/** This is the standard ICMP header only that the u32_t data + * is splitted to two u16_t like ICMP echo needs it. + * This header is also used for other ICMP types that do not + * use the data part. + */ +PACK_STRUCT_BEGIN +struct icmp_echo_hdr { + PACK_STRUCT_FIELD(u8_t type); + PACK_STRUCT_FIELD(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u16_t id); + PACK_STRUCT_FIELD(u16_t seqno); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define ICMPH_TYPE(hdr) ((hdr)->type) +#define ICMPH_CODE(hdr) ((hdr)->code) + +/** Combines type and code to an u16_t */ +#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) +#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) + + +#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ + +void icmp_input(struct pbuf *p, struct netif *inp); +void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); +void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); + +#endif /* LWIP_ICMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_ICMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h new file mode 100644 index 0000000..8aabac2 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2002 CITEL Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is a contribution to the lwIP TCP/IP stack. + * The Swedish Institute of Computer Science and Adam Dunkels + * are specifically granted permission to redistribute this + * source code. +*/ + +#ifndef __LWIP_IGMP_H__ +#define __LWIP_IGMP_H__ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/pbuf.h" + +#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* IGMP timer */ +#define IGMP_TMR_INTERVAL 100 /* Milliseconds */ +#define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) +#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) + +/* MAC Filter Actions, these are passed to a netif's + * igmp_mac_filter callback function. */ +#define IGMP_DEL_MAC_FILTER 0 +#define IGMP_ADD_MAC_FILTER 1 + + +/** + * igmp group structure - there is + * a list of groups for each interface + * these should really be linked from the interface, but + * if we keep them separate we will not affect the lwip original code + * too much + * + * There will be a group for the all systems group address but this + * will not run the state machine as it is used to kick off reports + * from all the other groups + */ +struct igmp_group { + /** next link */ + struct igmp_group *next; + /** interface on which the group is active */ + struct netif *netif; + /** multicast address */ + ip_addr_t group_address; + /** signifies we were the last person to report */ + u8_t last_reporter_flag; + /** current state of the group */ + u8_t group_state; + /** timer for reporting, negative is OFF */ + u16_t timer; + /** counter of simultaneous uses */ + u8_t use; +}; + +/* Prototypes */ +void igmp_init(void); +err_t igmp_start(struct netif *netif); +err_t igmp_stop(struct netif *netif); +void igmp_report_groups(struct netif *netif); +struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); +void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); +err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); +err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); +void igmp_tmr(void); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IGMP */ + +#endif /* __LWIP_IGMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h new file mode 100644 index 0000000..7bff49b --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_INET_H__ +#define __LWIP_INET_H__ + +#include "lwip/opt.h" +#include "lwip/def.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** For compatibility with BSD code */ +struct in_addr { + u32_t s_addr; +}; + +/** 255.255.255.255 */ +#define INADDR_NONE IPADDR_NONE +/** 127.0.0.1 */ +#define INADDR_LOOPBACK IPADDR_LOOPBACK +/** 0.0.0.0 */ +#define INADDR_ANY IPADDR_ANY +/** 255.255.255.255 */ +#define INADDR_BROADCAST IPADDR_BROADCAST + +/* Definitions of the bits in an Internet address integer. + + On subnets, host and network parts are found according to + the subnet mask, not these masks. */ +#define IN_CLASSA(a) IP_CLASSA(a) +#define IN_CLASSA_NET IP_CLASSA_NET +#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT +#define IN_CLASSA_HOST IP_CLASSA_HOST +#define IN_CLASSA_MAX IP_CLASSA_MAX + +#define IN_CLASSB(b) IP_CLASSB(b) +#define IN_CLASSB_NET IP_CLASSB_NET +#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT +#define IN_CLASSB_HOST IP_CLASSB_HOST +#define IN_CLASSB_MAX IP_CLASSB_MAX + +#define IN_CLASSC(c) IP_CLASSC(c) +#define IN_CLASSC_NET IP_CLASSC_NET +#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT +#define IN_CLASSC_HOST IP_CLASSC_HOST +#define IN_CLASSC_MAX IP_CLASSC_MAX + +#define IN_CLASSD(d) IP_CLASSD(d) +#define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ +#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ +#define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ +#define IN_CLASSD_MAX IP_CLASSD_MAX + +#define IN_MULTICAST(a) IP_MULTICAST(a) + +#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) +#define IN_BADCLASS(a) IP_BADCLASS(a) + +#define IN_LOOPBACKNET IP_LOOPBACKNET + +#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) +#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) +/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */ +#define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr)) + +/* directly map this to the lwip internal functions */ +#define inet_addr(cp) ipaddr_addr(cp) +#define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr) +#define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr)) +#define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen) + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_INET_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h new file mode 100644 index 0000000..79a2d90 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_INET_CHKSUM_H__ +#define __LWIP_INET_CHKSUM_H__ + +#include "lwip/opt.h" + +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" + +/** Swap the bytes in an u16_t: much like htons() for little-endian */ +#ifndef SWAP_BYTES_IN_WORD +#if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) +/* little endian and PLATFORM_BYTESWAP defined */ +#define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) +#else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ +/* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ +#define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) +#endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ +#endif /* SWAP_BYTES_IN_WORD */ + +/** Split an u32_t in two u16_ts and add them up */ +#ifndef FOLD_U32T +#define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) +#endif + +#if LWIP_CHECKSUM_ON_COPY +/** Function-like macro: same as MEMCPY but returns the checksum of copied data + as u16_t */ +#ifndef LWIP_CHKSUM_COPY +#define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) +#ifndef LWIP_CHKSUM_COPY_ALGORITHM +#define LWIP_CHKSUM_COPY_ALGORITHM 1 +#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ +#endif /* LWIP_CHKSUM_COPY */ +#else /* LWIP_CHECKSUM_ON_COPY */ +#define LWIP_CHKSUM_COPY_ALGORITHM 0 +#endif /* LWIP_CHECKSUM_ON_COPY */ + +#ifdef __cplusplus +extern "C" { +#endif + +u16_t inet_chksum(void *dataptr, u16_t len); +u16_t inet_chksum_pbuf(struct pbuf *p); +u16_t inet_chksum_pseudo(struct pbuf *p, + ip_addr_t *src, ip_addr_t *dest, + u8_t proto, u16_t proto_len); +u16_t inet_chksum_pseudo_partial(struct pbuf *p, + ip_addr_t *src, ip_addr_t *dest, + u8_t proto, u16_t proto_len, u16_t chksum_len); +#if LWIP_CHKSUM_COPY_ALGORITHM +u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); +#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_INET_H__ */ + diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h new file mode 100644 index 0000000..00c83a0 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_IP_H__ +#define __LWIP_IP_H__ + +#include "lwip/opt.h" + +#include "lwip/def.h" +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" +#include "lwip/err.h" +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Currently, the function ip_output_if_opt() is only used with IGMP */ +#define IP_OPTIONS_SEND LWIP_IGMP + +#define IP_HLEN 20 + +#define IP_PROTO_ICMP 1 +#define IP_PROTO_IGMP 2 +#define IP_PROTO_UDP 17 +#define IP_PROTO_UDPLITE 136 +#define IP_PROTO_TCP 6 + +/* This is passed as the destination address to ip_output_if (not + to ip_output), meaning that an IP header already is constructed + in the pbuf. This is used when TCP retransmits. */ +#ifdef IP_HDRINCL +#undef IP_HDRINCL +#endif /* IP_HDRINCL */ +#define IP_HDRINCL NULL + +#if LWIP_NETIF_HWADDRHINT +#define IP_PCB_ADDRHINT ;u8_t addr_hint +#else +#define IP_PCB_ADDRHINT +#endif /* LWIP_NETIF_HWADDRHINT */ + +/* This is the common part of all PCB types. It needs to be at the + beginning of a PCB type definition. It is located here so that + changes to this common part are made in one location instead of + having to change all PCB structs. */ +#define IP_PCB \ + /* ip addresses in network byte order */ \ + ip_addr_t local_ip; \ + ip_addr_t remote_ip; \ + /* Socket options */ \ + u8_t so_options; \ + /* Type Of Service */ \ + u8_t tos; \ + /* Time To Live */ \ + u8_t ttl \ + /* link layer address resolution hint */ \ + IP_PCB_ADDRHINT + +struct ip_pcb { +/* Common members of all PCB types */ + IP_PCB; +}; + +/* + * Option flags per-socket. These are the same like SO_XXX. + */ +/*#define SOF_DEBUG 0x01U Unimplemented: turn on debugging info recording */ +#define SOF_ACCEPTCONN 0x02U /* socket has had listen() */ +#define SOF_REUSEADDR 0x04U /* allow local address reuse */ +#define SOF_KEEPALIVE 0x08U /* keep connections alive */ +/*#define SOF_DONTROUTE 0x10U Unimplemented: just use interface addresses */ +#define SOF_BROADCAST 0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ +/*#define SOF_USELOOPBACK 0x40U Unimplemented: bypass hardware when possible */ +#define SOF_LINGER 0x80U /* linger on close if data present */ +/*#define SOF_OOBINLINE 0x0100U Unimplemented: leave received OOB data in line */ +/*#define SOF_REUSEPORT 0x0200U Unimplemented: allow local address & port reuse */ + +/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */ +#define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/) + + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip_hdr { + /* version / header length */ + PACK_STRUCT_FIELD(u8_t _v_hl); + /* type of service */ + PACK_STRUCT_FIELD(u8_t _tos); + /* total length */ + PACK_STRUCT_FIELD(u16_t _len); + /* identification */ + PACK_STRUCT_FIELD(u16_t _id); + /* fragment offset field */ + PACK_STRUCT_FIELD(u16_t _offset); +#define IP_RF 0x8000U /* reserved fragment flag */ +#define IP_DF 0x4000U /* dont fragment flag */ +#define IP_MF 0x2000U /* more fragments flag */ +#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */ + /* time to live */ + PACK_STRUCT_FIELD(u8_t _ttl); + /* protocol*/ + PACK_STRUCT_FIELD(u8_t _proto); + /* checksum */ + PACK_STRUCT_FIELD(u16_t _chksum); + /* source and destination IP addresses */ + PACK_STRUCT_FIELD(ip_addr_p_t src); + PACK_STRUCT_FIELD(ip_addr_p_t dest); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define IPH_V(hdr) ((hdr)->_v_hl >> 4) +#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f) +#define IPH_TOS(hdr) ((hdr)->_tos) +#define IPH_LEN(hdr) ((hdr)->_len) +#define IPH_ID(hdr) ((hdr)->_id) +#define IPH_OFFSET(hdr) ((hdr)->_offset) +#define IPH_TTL(hdr) ((hdr)->_ttl) +#define IPH_PROTO(hdr) ((hdr)->_proto) +#define IPH_CHKSUM(hdr) ((hdr)->_chksum) + +#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (((v) << 4) | (hl)) +#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos) +#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len) +#define IPH_ID_SET(hdr, id) (hdr)->_id = (id) +#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off) +#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl) +#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) +#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) + +/** The interface that provided the packet for the current callback invocation. */ +extern struct netif *current_netif; +/** Header of the input packet currently being processed. */ +extern const struct ip_hdr *current_header; +/** Source IP address of current_header */ +extern ip_addr_t current_iphdr_src; +/** Destination IP address of current_header */ +extern ip_addr_t current_iphdr_dest; + +#define ip_init() /* Compatibility define, not init needed. */ +struct netif *ip_route(ip_addr_t *dest); +err_t ip_input(struct pbuf *p, struct netif *inp); +err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto); +err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto, + struct netif *netif); +#if LWIP_NETIF_HWADDRHINT +err_t ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint); +#endif /* LWIP_NETIF_HWADDRHINT */ +#if IP_OPTIONS_SEND +err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, + u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, + u16_t optlen); +#endif /* IP_OPTIONS_SEND */ +/** Get the interface that received the current packet. + * This function must only be called from a receive callback (udp_recv, + * raw_recv, tcp_accept). It will return NULL otherwise. */ +#define ip_current_netif() (current_netif) +/** Get the IP header of the current packet. + * This function must only be called from a receive callback (udp_recv, + * raw_recv, tcp_accept). It will return NULL otherwise. */ +#define ip_current_header() (current_header) +/** Source IP address of current_header */ +#define ip_current_src_addr() (¤t_iphdr_src) +/** Destination IP address of current_header */ +#define ip_current_dest_addr() (¤t_iphdr_dest) + +/** Gets an IP pcb option (SOF_* flags) */ +#define ip_get_option(pcb, opt) ((pcb)->so_options & (opt)) +/** Sets an IP pcb option (SOF_* flags) */ +#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) +/** Resets an IP pcb option (SOF_* flags) */ +#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt)) + +#if IP_DEBUG +void ip_debug_print(struct pbuf *p); +#else +#define ip_debug_print(p) +#endif /* IP_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_IP_H__ */ + + diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h new file mode 100644 index 0000000..77f84e0 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_IP_ADDR_H__ +#define __LWIP_IP_ADDR_H__ + +#include "lwip/opt.h" +#include "lwip/def.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the aligned version of ip_addr_t, + used as local variable, on the stack, etc. */ +struct ip_addr { + u32_t addr; +}; + +/* This is the packed version of ip_addr_t, + used in network headers that are itself packed */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip_addr_packed { + PACK_STRUCT_FIELD(u32_t addr); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** ip_addr_t uses a struct for convenience only, so that the same defines can + * operate both on ip_addr_t as well as on ip_addr_p_t. */ +typedef struct ip_addr ip_addr_t; +typedef struct ip_addr_packed ip_addr_p_t; + +/* + * struct ipaddr2 is used in the definition of the ARP packet format in + * order to support compilers that don't have structure packing. + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip_addr2 { + PACK_STRUCT_FIELD(u16_t addrw[2]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* Forward declaration to not include netif.h */ +struct netif; + +extern const ip_addr_t ip_addr_any; +extern const ip_addr_t ip_addr_broadcast; + +/** IP_ADDR_ can be used as a fixed IP address + * for the wildcard and the broadcast address + */ +#define IP_ADDR_ANY ((ip_addr_t *)&ip_addr_any) +#define IP_ADDR_BROADCAST ((ip_addr_t *)&ip_addr_broadcast) + +/** 255.255.255.255 */ +#define IPADDR_NONE ((u32_t)0xffffffffUL) +/** 127.0.0.1 */ +#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) +/** 0.0.0.0 */ +#define IPADDR_ANY ((u32_t)0x00000000UL) +/** 255.255.255.255 */ +#define IPADDR_BROADCAST ((u32_t)0xffffffffUL) + +/* Definitions of the bits in an Internet address integer. + + On subnets, host and network parts are found according to + the subnet mask, not these masks. */ +#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) +#define IP_CLASSA_NET 0xff000000 +#define IP_CLASSA_NSHIFT 24 +#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) +#define IP_CLASSA_MAX 128 + +#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) +#define IP_CLASSB_NET 0xffff0000 +#define IP_CLASSB_NSHIFT 16 +#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET) +#define IP_CLASSB_MAX 65536 + +#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) +#define IP_CLASSC_NET 0xffffff00 +#define IP_CLASSC_NSHIFT 8 +#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET) + +#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) +#define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */ +#define IP_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */ +#define IP_MULTICAST(a) IP_CLASSD(a) + +#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) +#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) + +#define IP_LOOPBACKNET 127 /* official! */ + + +#if BYTE_ORDER == BIG_ENDIAN +/** Set an IP address given by the four byte-parts */ +#define IP4_ADDR(ipaddr, a,b,c,d) \ + (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \ + ((u32_t)((b) & 0xff) << 16) | \ + ((u32_t)((c) & 0xff) << 8) | \ + (u32_t)((d) & 0xff) +#else +/** Set an IP address given by the four byte-parts. + Little-endian version that prevents the use of htonl. */ +#define IP4_ADDR(ipaddr, a,b,c,d) \ + (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \ + ((u32_t)((c) & 0xff) << 16) | \ + ((u32_t)((b) & 0xff) << 8) | \ + (u32_t)((a) & 0xff) +#endif + +/** MEMCPY-like copying of IP addresses where addresses are known to be + * 16-bit-aligned if the port is correctly configured (so a port could define + * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ +#ifndef IPADDR2_COPY +#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t)) +#endif + +/** Copy IP address - faster than ip_addr_set: no NULL check */ +#define ip_addr_copy(dest, src) ((dest).addr = (src).addr) +/** Safely copy one IP address to another (src may be NULL) */ +#define ip_addr_set(dest, src) ((dest)->addr = \ + ((src) == NULL ? 0 : \ + (src)->addr)) +/** Set complete address to zero */ +#define ip_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) +/** Set address to IPADDR_ANY (no need for htonl()) */ +#define ip_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) +/** Set address to loopback address */ +#define ip_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) +/** Safely copy one IP address to another and change byte order + * from host- to network-order. */ +#define ip_addr_set_hton(dest, src) ((dest)->addr = \ + ((src) == NULL ? 0:\ + htonl((src)->addr))) +/** IPv4 only: set the IP address given as an u32_t */ +#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) +/** IPv4 only: get the IP address as an u32_t */ +#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) + +/** Get the network address by combining host address with netmask */ +#define ip_addr_get_network(target, host, netmask) ((target)->addr = ((host)->addr) & ((netmask)->addr)) + +/** + * Determine if two address are on the same network. + * + * @arg addr1 IP address 1 + * @arg addr2 IP address 2 + * @arg mask network identifier mask + * @return !0 if the network identifiers of both address match + */ +#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ + (mask)->addr) == \ + ((addr2)->addr & \ + (mask)->addr)) +#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) + +#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY) + +#define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif)) +u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif); + +#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr) +u8_t ip4_addr_netmask_valid(u32_t netmask); + +#define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL)) + +#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) + +#define ip_addr_debug_print(debug, ipaddr) \ + LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ + ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \ + ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \ + ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \ + ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0)) + +/* Get one byte from the 4-byte address */ +#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0]) +#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1]) +#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2]) +#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3]) +/* These are cast to u16_t, with the intent that they are often arguments + * to printf using the U16_F format from cc.h. */ +#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) +#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) +#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) +#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) + +/** For backwards compatibility */ +#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) + +u32_t ipaddr_addr(const char *cp); +int ipaddr_aton(const char *cp, ip_addr_t *addr); +/** returns ptr to static buffer; not reentrant! */ +char *ipaddr_ntoa(const ip_addr_t *addr); +char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen); + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_IP_ADDR_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h new file mode 100644 index 0000000..77b5eb1 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Jani Monoses + * + */ + +#ifndef __LWIP_IP_FRAG_H__ +#define __LWIP_IP_FRAG_H__ + +#include "lwip/opt.h" +#include "lwip/err.h" +#include "lwip/pbuf.h" +#include "lwip/netif.h" +#include "lwip/ip_addr.h" +#include "lwip/ip.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if IP_REASSEMBLY +/* The IP reassembly timer interval in milliseconds. */ +#define IP_TMR_INTERVAL 1000 + +/* IP reassembly helper struct. + * This is exported because memp needs to know the size. + */ +struct ip_reassdata { + struct ip_reassdata *next; + struct pbuf *p; + struct ip_hdr iphdr; + u16_t datagram_len; + u8_t flags; + u8_t timer; +}; + +void ip_reass_init(void); +void ip_reass_tmr(void); +struct pbuf * ip_reass(struct pbuf *p); +#endif /* IP_REASSEMBLY */ + +#if IP_FRAG +#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF +/** A custom pbuf that holds a reference to another pbuf, which is freed + * when this custom pbuf is freed. This is used to create a custom PBUF_REF + * that points into the original pbuf. */ +struct pbuf_custom_ref { + /** 'base class' */ + struct pbuf_custom pc; + /** pointer to the original pbuf that is referenced */ + struct pbuf *original; +}; +#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ + +err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest); +#endif /* IP_FRAG */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_IP_FRAG_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h new file mode 100644 index 0000000..87e9ffd --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_ICMP_H__ +#define __LWIP_ICMP_H__ + +#include "lwip/opt.h" + +#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/pbuf.h" +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ICMP6_DUR 1 +#define ICMP6_TE 3 +#define ICMP6_ECHO 128 /* echo */ +#define ICMP6_ER 129 /* echo reply */ + + +enum icmp_dur_type { + ICMP_DUR_NET = 0, /* net unreachable */ + ICMP_DUR_HOST = 1, /* host unreachable */ + ICMP_DUR_PROTO = 2, /* protocol unreachable */ + ICMP_DUR_PORT = 3, /* port unreachable */ + ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ + ICMP_DUR_SR = 5 /* source route failed */ +}; + +enum icmp_te_type { + ICMP_TE_TTL = 0, /* time to live exceeded in transit */ + ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ +}; + +void icmp_input(struct pbuf *p, struct netif *inp); + +void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); +void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); + +struct icmp_echo_hdr { + u8_t type; + u8_t icode; + u16_t chksum; + u16_t id; + u16_t seqno; +}; + +struct icmp_dur_hdr { + u8_t type; + u8_t icode; + u16_t chksum; + u32_t unused; +}; + +struct icmp_te_hdr { + u8_t type; + u8_t icode; + u16_t chksum; + u32_t unused; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_ICMP */ + +#endif /* __LWIP_ICMP_H__ */ + diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h new file mode 100644 index 0000000..de1a0b6 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_INET_H__ +#define __LWIP_INET_H__ + +#include "lwip/opt.h" +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +u16_t inet_chksum(void *data, u16_t len); +u16_t inet_chksum_pbuf(struct pbuf *p); +u16_t inet_chksum_pseudo(struct pbuf *p, + struct ip_addr *src, struct ip_addr *dest, + u8_t proto, u32_t proto_len); + +u32_t inet_addr(const char *cp); +s8_t inet_aton(const char *cp, struct in_addr *addr); + +#ifndef _MACHINE_ENDIAN_H_ +#ifndef _NETINET_IN_H +#ifndef _LINUX_BYTEORDER_GENERIC_H +u16_t htons(u16_t n); +u16_t ntohs(u16_t n); +u32_t htonl(u32_t n); +u32_t ntohl(u32_t n); +#endif /* _LINUX_BYTEORDER_GENERIC_H */ +#endif /* _NETINET_IN_H */ +#endif /* _MACHINE_ENDIAN_H_ */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_INET_H__ */ + diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h new file mode 100644 index 0000000..a01cfc6 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_IP_H__ +#define __LWIP_IP_H__ + +#include "lwip/opt.h" +#include "lwip/def.h" +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" + +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define IP_HLEN 40 + +#define IP_PROTO_ICMP 58 +#define IP_PROTO_UDP 17 +#define IP_PROTO_UDPLITE 136 +#define IP_PROTO_TCP 6 + +/* This is passed as the destination address to ip_output_if (not + to ip_output), meaning that an IP header already is constructed + in the pbuf. This is used when TCP retransmits. */ +#ifdef IP_HDRINCL +#undef IP_HDRINCL +#endif /* IP_HDRINCL */ +#define IP_HDRINCL NULL + +#if LWIP_NETIF_HWADDRHINT +#define IP_PCB_ADDRHINT ;u8_t addr_hint +#else +#define IP_PCB_ADDRHINT +#endif /* LWIP_NETIF_HWADDRHINT */ + +/* This is the common part of all PCB types. It needs to be at the + beginning of a PCB type definition. It is located here so that + changes to this common part are made in one location instead of + having to change all PCB structs. */ +#define IP_PCB struct ip_addr local_ip; \ + struct ip_addr remote_ip; \ + /* Socket options */ \ + u16_t so_options; \ + /* Type Of Service */ \ + u8_t tos; \ + /* Time To Live */ \ + u8_t ttl; \ + /* link layer address resolution hint */ \ + IP_PCB_ADDRHINT + + +/* The IPv6 header. */ +struct ip_hdr { +#if BYTE_ORDER == LITTLE_ENDIAN + u8_t tclass1:4, v:4; + u8_t flow1:4, tclass2:4; +#else + u8_t v:4, tclass1:4; + u8_t tclass2:8, flow1:4; +#endif + u16_t flow2; + u16_t len; /* payload length */ + u8_t nexthdr; /* next header */ + u8_t hoplim; /* hop limit (TTL) */ + struct ip_addr src, dest; /* source and destination IP addresses */ +}; + +#define IPH_PROTO(hdr) (iphdr->nexthdr) + +void ip_init(void); + +#include "lwip/netif.h" + +struct netif *ip_route(struct ip_addr *dest); + +void ip_input(struct pbuf *p, struct netif *inp); + +/* source and destination addresses in network byte order, please */ +err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, + u8_t ttl, u8_t proto); + +err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, + u8_t ttl, u8_t proto, + struct netif *netif); + +#define ip_current_netif() NULL +#define ip_current_header() NULL + +#if IP_DEBUG +void ip_debug_print(struct pbuf *p); +#endif /* IP_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_IP_H__ */ + + diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h new file mode 100644 index 0000000..b2d8ae5 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_IP_ADDR_H__ +#define __LWIP_IP_ADDR_H__ + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define IP_ADDR_ANY 0 + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN + struct ip_addr { + PACK_STRUCT_FIELD(u32_t addr[4]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* + * struct ipaddr2 is used in the definition of the ARP packet format in + * order to support compilers that don't have structure packing. + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip_addr2 { + PACK_STRUCT_FIELD(u16_t addrw[2]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)((a & 0xffff) << 16) | (b & 0xffff)); \ + (ipaddr)->addr[1] = htonl(((c & 0xffff) << 16) | (d & 0xffff)); \ + (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \ + (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0) + +u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, + struct ip_addr *mask); +u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); +void ip_addr_set(struct ip_addr *dest, struct ip_addr *src); +u8_t ip_addr_isany(struct ip_addr *addr); + +#define ip_addr_debug_print(debug, ipaddr) \ + LWIP_DEBUGF(debug, ("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F"\n", \ + (ntohl(ipaddr->addr[0]) >> 16) & 0xffff, \ + ntohl(ipaddr->addr[0]) & 0xffff, \ + (ntohl(ipaddr->addr[1]) >> 16) & 0xffff, \ + ntohl(ipaddr->addr[1]) & 0xffff, \ + (ntohl(ipaddr->addr[2]) >> 16) & 0xffff, \ + ntohl(ipaddr->addr[2]) & 0xffff, \ + (ntohl(ipaddr->addr[3]) >> 16) & 0xffff, \ + ntohl(ipaddr->addr[3]) & 0xffff)); + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_IP_ADDR_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/api.h b/user/mpy/lib/lwip/src/include/lwip/api.h new file mode 100644 index 0000000..7a9fa93 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/api.h @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_API_H__ +#define __LWIP_API_H__ + +#include "lwip/opt.h" + +#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ + +#include /* for size_t */ + +#include "lwip/netbuf.h" +#include "lwip/sys.h" +#include "lwip/ip_addr.h" +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Throughout this file, IP addresses and port numbers are expected to be in + * the same byte order as in the corresponding pcb. + */ + +/* Flags for netconn_write (u8_t) */ +#define NETCONN_NOFLAG 0x00 +#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */ +#define NETCONN_COPY 0x01 +#define NETCONN_MORE 0x02 +#define NETCONN_DONTBLOCK 0x04 + +/* Flags for struct netconn.flags (u8_t) */ +/** TCP: when data passed to netconn_write doesn't fit into the send buffer, + this temporarily stores whether to wake up the original application task + if data couldn't be sent in the first try. */ +#define NETCONN_FLAG_WRITE_DELAYED 0x01 +/** Should this netconn avoid blocking? */ +#define NETCONN_FLAG_NON_BLOCKING 0x02 +/** Was the last connect action a non-blocking one? */ +#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 +/** If this is set, a TCP netconn must call netconn_recved() to update + the TCP receive window (done automatically if not set). */ +#define NETCONN_FLAG_NO_AUTO_RECVED 0x08 +/** If a nonblocking write has been rejected before, poll_tcp needs to + check if the netconn is writable again */ +#define NETCONN_FLAG_CHECK_WRITESPACE 0x10 + + +/* Helpers to process several netconn_types by the same code */ +#define NETCONNTYPE_GROUP(t) (t&0xF0) +#define NETCONNTYPE_DATAGRAM(t) (t&0xE0) + +/** Protocol family and type of the netconn */ +enum netconn_type { + NETCONN_INVALID = 0, + /* NETCONN_TCP Group */ + NETCONN_TCP = 0x10, + /* NETCONN_UDP Group */ + NETCONN_UDP = 0x20, + NETCONN_UDPLITE = 0x21, + NETCONN_UDPNOCHKSUM= 0x22, + /* NETCONN_RAW Group */ + NETCONN_RAW = 0x40 +}; + +/** Current state of the netconn. Non-TCP netconns are always + * in state NETCONN_NONE! */ +enum netconn_state { + NETCONN_NONE, + NETCONN_WRITE, + NETCONN_LISTEN, + NETCONN_CONNECT, + NETCONN_CLOSE +}; + +/** Use to inform the callback function about changes */ +enum netconn_evt { + NETCONN_EVT_RCVPLUS, + NETCONN_EVT_RCVMINUS, + NETCONN_EVT_SENDPLUS, + NETCONN_EVT_SENDMINUS, + NETCONN_EVT_ERROR +}; + +#if LWIP_IGMP +/** Used for netconn_join_leave_group() */ +enum netconn_igmp { + NETCONN_JOIN, + NETCONN_LEAVE +}; +#endif /* LWIP_IGMP */ + +/* forward-declare some structs to avoid to include their headers */ +struct ip_pcb; +struct tcp_pcb; +struct udp_pcb; +struct raw_pcb; +struct netconn; +struct api_msg_msg; + +/** A callback prototype to inform about events for a netconn */ +typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len); + +/** A netconn descriptor */ +struct netconn { + /** type of the netconn (TCP, UDP or RAW) */ + enum netconn_type type; + /** current state of the netconn */ + enum netconn_state state; + /** the lwIP internal protocol control block */ + union { + struct ip_pcb *ip; + struct tcp_pcb *tcp; + struct udp_pcb *udp; + struct raw_pcb *raw; + } pcb; + /** the last error this netconn had */ + err_t last_err; + /** sem that is used to synchroneously execute functions in the core context */ + sys_sem_t op_completed; + /** mbox where received packets are stored until they are fetched + by the netconn application thread (can grow quite big) */ + sys_mbox_t recvmbox; +#if LWIP_TCP + /** mbox where new connections are stored until processed + by the application thread */ + sys_mbox_t acceptmbox; +#endif /* LWIP_TCP */ + /** only used for socket layer */ +#if LWIP_SOCKET + int socket; +#endif /* LWIP_SOCKET */ +#if LWIP_SO_SNDTIMEO + /** timeout to wait for sending data (which means enqueueing data for sending + in internal buffers) */ + s32_t send_timeout; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVTIMEO + /** timeout to wait for new data to be received + (or connections to arrive for listening netconns) */ + int recv_timeout; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + /** maximum amount of bytes queued in recvmbox + not used for TCP: adjust TCP_WND instead! */ + int recv_bufsize; + /** number of bytes currently in recvmbox to be received, + tested against recv_bufsize to limit bytes on recvmbox + for UDP and RAW, used for FIONREAD */ + s16_t recv_avail; +#endif /* LWIP_SO_RCVBUF */ + /** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */ + u8_t flags; +#if LWIP_TCP + /** TCP: when data passed to netconn_write doesn't fit into the send buffer, + this temporarily stores how much is already sent. */ + size_t write_offset; + /** TCP: when data passed to netconn_write doesn't fit into the send buffer, + this temporarily stores the message. + Also used during connect and close. */ + struct api_msg_msg *current_msg; +#endif /* LWIP_TCP */ + /** A callback function that is informed about events for this netconn */ + netconn_callback callback; +}; + +/** Register an Network connection event */ +#define API_EVENT(c,e,l) if (c->callback) { \ + (*c->callback)(c, e, l); \ + } + +/** Set conn->last_err to err but don't overwrite fatal errors */ +#define NETCONN_SET_SAFE_ERR(conn, err) do { \ + SYS_ARCH_DECL_PROTECT(lev); \ + SYS_ARCH_PROTECT(lev); \ + if (!ERR_IS_FATAL((conn)->last_err)) { \ + (conn)->last_err = err; \ + } \ + SYS_ARCH_UNPROTECT(lev); \ +} while(0); + +/* Network connection functions: */ +#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) +#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) +struct +netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, + netconn_callback callback); +err_t netconn_delete(struct netconn *conn); +/** Get the type of a netconn (as enum netconn_type). */ +#define netconn_type(conn) (conn->type) + +err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, + u16_t *port, u8_t local); +#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) +#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) + +err_t netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port); +err_t netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port); +err_t netconn_disconnect (struct netconn *conn); +err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); +#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) +err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); +err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); +err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); +void netconn_recved(struct netconn *conn, u32_t length); +err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, + ip_addr_t *addr, u16_t port); +err_t netconn_send(struct netconn *conn, struct netbuf *buf); +err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, + u8_t apiflags, size_t *bytes_written); +#define netconn_write(conn, dataptr, size, apiflags) \ + netconn_write_partly(conn, dataptr, size, apiflags, NULL) +err_t netconn_close(struct netconn *conn); +err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); + +#if LWIP_IGMP +err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr, + ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); +#endif /* LWIP_IGMP */ +#if LWIP_DNS +err_t netconn_gethostbyname(const char *name, ip_addr_t *addr); +#endif /* LWIP_DNS */ + +#define netconn_err(conn) ((conn)->last_err) +#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) + +/** Set the blocking status of netconn calls (@todo: write/send is missing) */ +#define netconn_set_nonblocking(conn, val) do { if(val) { \ + (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ +} else { \ + (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) +/** Get the blocking status of netconn calls (@todo: write/send is missing) */ +#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) + +/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */ +#define netconn_set_noautorecved(conn, val) do { if(val) { \ + (conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \ +} else { \ + (conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0) +/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */ +#define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0) + +#if LWIP_SO_SNDTIMEO +/** Set the send timeout in milliseconds */ +#define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) +/** Get the send timeout in milliseconds */ +#define netconn_get_sendtimeout(conn) ((conn)->send_timeout) +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO +/** Set the receive timeout in milliseconds */ +#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) +/** Get the receive timeout in milliseconds */ +#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF +/** Set the receive buffer in bytes */ +#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) +/** Get the receive buffer in bytes */ +#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) +#endif /* LWIP_SO_RCVBUF*/ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETCONN */ + +#endif /* __LWIP_API_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/api_msg.h b/user/mpy/lib/lwip/src/include/lwip/api_msg.h new file mode 100644 index 0000000..f9e1c7d --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/api_msg.h @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_API_MSG_H__ +#define __LWIP_API_MSG_H__ + +#include "lwip/opt.h" + +#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ + +#include /* for size_t */ + +#include "lwip/ip_addr.h" +#include "lwip/err.h" +#include "lwip/sys.h" +#include "lwip/igmp.h" +#include "lwip/api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* For the netconn API, these values are use as a bitmask! */ +#define NETCONN_SHUT_RD 1 +#define NETCONN_SHUT_WR 2 +#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) + +/* IP addresses and port numbers are expected to be in + * the same byte order as in the corresponding pcb. + */ +/** This struct includes everything that is necessary to execute a function + for a netconn in another thread context (mainly used to process netconns + in the tcpip_thread context to be thread safe). */ +struct api_msg_msg { + /** The netconn which to process - always needed: it includes the semaphore + which is used to block the application thread until the function finished. */ + struct netconn *conn; + /** The return value of the function executed in tcpip_thread. */ + err_t err; + /** Depending on the executed function, one of these union members is used */ + union { + /** used for do_send */ + struct netbuf *b; + /** used for do_newconn */ + struct { + u8_t proto; + } n; + /** used for do_bind and do_connect */ + struct { + ip_addr_t *ipaddr; + u16_t port; + } bc; + /** used for do_getaddr */ + struct { + ip_addr_t *ipaddr; + u16_t *port; + u8_t local; + } ad; + /** used for do_write */ + struct { + const void *dataptr; + size_t len; + u8_t apiflags; +#if LWIP_SO_SNDTIMEO + u32_t time_started; +#endif /* LWIP_SO_SNDTIMEO */ + } w; + /** used for do_recv */ + struct { + u32_t len; + } r; + /** used for do_close (/shutdown) */ + struct { + u8_t shut; + } sd; +#if LWIP_IGMP + /** used for do_join_leave_group */ + struct { + ip_addr_t *multiaddr; + ip_addr_t *netif_addr; + enum netconn_igmp join_or_leave; + } jl; +#endif /* LWIP_IGMP */ +#if TCP_LISTEN_BACKLOG + struct { + u8_t backlog; + } lb; +#endif /* TCP_LISTEN_BACKLOG */ + } msg; +}; + +/** This struct contains a function to execute in another thread context and + a struct api_msg_msg that serves as an argument for this function. + This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ +struct api_msg { + /** function to execute in tcpip_thread context */ + void (* function)(struct api_msg_msg *msg); + /** arguments for this function */ + struct api_msg_msg msg; +}; + +#if LWIP_DNS +/** As do_gethostbyname requires more arguments but doesn't require a netconn, + it has its own struct (to avoid struct api_msg getting bigger than necessary). + do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg + (see netconn_gethostbyname). */ +struct dns_api_msg { + /** Hostname to query or dotted IP address string */ + const char *name; + /** Rhe resolved address is stored here */ + ip_addr_t *addr; + /** This semaphore is posted when the name is resolved, the application thread + should wait on it. */ + sys_sem_t *sem; + /** Errors are given back here */ + err_t *err; +}; +#endif /* LWIP_DNS */ + +void do_newconn ( struct api_msg_msg *msg); +void do_delconn ( struct api_msg_msg *msg); +void do_bind ( struct api_msg_msg *msg); +void do_connect ( struct api_msg_msg *msg); +void do_disconnect ( struct api_msg_msg *msg); +void do_listen ( struct api_msg_msg *msg); +void do_send ( struct api_msg_msg *msg); +void do_recv ( struct api_msg_msg *msg); +void do_write ( struct api_msg_msg *msg); +void do_getaddr ( struct api_msg_msg *msg); +void do_close ( struct api_msg_msg *msg); +void do_shutdown ( struct api_msg_msg *msg); +#if LWIP_IGMP +void do_join_leave_group( struct api_msg_msg *msg); +#endif /* LWIP_IGMP */ + +#if LWIP_DNS +void do_gethostbyname(void *arg); +#endif /* LWIP_DNS */ + +struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); +void netconn_free(struct netconn *conn); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETCONN */ + +#endif /* __LWIP_API_MSG_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/arch.h b/user/mpy/lib/lwip/src/include/lwip/arch.h new file mode 100644 index 0000000..4d6df77 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/arch.h @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_ARCH_H__ +#define __LWIP_ARCH_H__ + +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN 1234 +#endif + +#ifndef BIG_ENDIAN +#define BIG_ENDIAN 4321 +#endif + +#include "arch/cc.h" + +/** Temporary: define format string for size_t if not defined in cc.h */ +#ifndef SZT_F +#define SZT_F U32_F +#endif /* SZT_F */ +/** Temporary upgrade helper: define format string for u8_t as hex if not + defined in cc.h */ +#ifndef X8_F +#define X8_F "02x" +#endif /* X8_F */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef PACK_STRUCT_BEGIN +#define PACK_STRUCT_BEGIN +#endif /* PACK_STRUCT_BEGIN */ + +#ifndef PACK_STRUCT_END +#define PACK_STRUCT_END +#endif /* PACK_STRUCT_END */ + +#ifndef PACK_STRUCT_FIELD +#define PACK_STRUCT_FIELD(x) x +#endif /* PACK_STRUCT_FIELD */ + + +#ifndef LWIP_UNUSED_ARG +#define LWIP_UNUSED_ARG(x) (void)x +#endif /* LWIP_UNUSED_ARG */ + + +#ifdef LWIP_PROVIDE_ERRNO + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ + +#ifndef errno +extern int errno; +#endif + +#endif /* LWIP_PROVIDE_ERRNO */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_ARCH_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/debug.h b/user/mpy/lib/lwip/src/include/lwip/debug.h new file mode 100644 index 0000000..0fe0413 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/debug.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_DEBUG_H__ +#define __LWIP_DEBUG_H__ + +#include "lwip/arch.h" +#include "lwip/opt.h" + +/** lower two bits indicate debug level + * - 0 all + * - 1 warning + * - 2 serious + * - 3 severe + */ +#define LWIP_DBG_LEVEL_ALL 0x00 +#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ +#define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ +#define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ +#define LWIP_DBG_LEVEL_SEVERE 0x03 +#define LWIP_DBG_MASK_LEVEL 0x03 + +/** flag for LWIP_DEBUGF to enable that debug message */ +#define LWIP_DBG_ON 0x80U +/** flag for LWIP_DEBUGF to disable that debug message */ +#define LWIP_DBG_OFF 0x00U + +/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ +#define LWIP_DBG_TRACE 0x40U +/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ +#define LWIP_DBG_STATE 0x20U +/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ +#define LWIP_DBG_FRESH 0x10U +/** flag for LWIP_DEBUGF to halt after printing this debug message */ +#define LWIP_DBG_HALT 0x08U + +#ifndef LWIP_NOASSERT +#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ + LWIP_PLATFORM_ASSERT(message); } while(0) +#else /* LWIP_NOASSERT */ +#define LWIP_ASSERT(message, assertion) +#endif /* LWIP_NOASSERT */ + +/** if "expression" isn't true, then print "message" and execute "handler" expression */ +#ifndef LWIP_ERROR +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + LWIP_PLATFORM_ASSERT(message); handler;}} while(0) +#endif /* LWIP_ERROR */ + +#ifdef LWIP_DEBUG +/** print debug message only if debug message type is enabled... + * AND is of correct type AND is at least LWIP_DBG_LEVEL + */ +#define LWIP_DEBUGF(debug, message) do { \ + if ( \ + ((debug) & LWIP_DBG_ON) && \ + ((debug) & LWIP_DBG_TYPES_ON) && \ + ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ + LWIP_PLATFORM_DIAG(message); \ + if ((debug) & LWIP_DBG_HALT) { \ + while(1); \ + } \ + } \ + } while(0) + +#else /* LWIP_DEBUG */ +#define LWIP_DEBUGF(debug, message) +#endif /* LWIP_DEBUG */ + +#endif /* __LWIP_DEBUG_H__ */ + diff --git a/user/mpy/lib/lwip/src/include/lwip/def.h b/user/mpy/lib/lwip/src/include/lwip/def.h new file mode 100644 index 0000000..73a1b56 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/def.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_DEF_H__ +#define __LWIP_DEF_H__ + +/* arch.h might define NULL already */ +#include "lwip/arch.h" +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) +#define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* Endianess-optimized shifting of two u8_t to create one u16_t */ +#if BYTE_ORDER == LITTLE_ENDIAN +#define LWIP_MAKE_U16(a, b) ((a << 8) | b) +#else +#define LWIP_MAKE_U16(a, b) ((b << 8) | a) +#endif + +#ifndef LWIP_PLATFORM_BYTESWAP +#define LWIP_PLATFORM_BYTESWAP 0 +#endif + +#ifndef LWIP_PREFIX_BYTEORDER_FUNCS +/* workaround for naming collisions on some platforms */ + +#ifdef htons +#undef htons +#endif /* htons */ +#ifdef htonl +#undef htonl +#endif /* htonl */ +#ifdef ntohs +#undef ntohs +#endif /* ntohs */ +#ifdef ntohl +#undef ntohl +#endif /* ntohl */ + +#define htons(x) lwip_htons(x) +#define ntohs(x) lwip_ntohs(x) +#define htonl(x) lwip_htonl(x) +#define ntohl(x) lwip_ntohl(x) +#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ + +#if BYTE_ORDER == BIG_ENDIAN +#define lwip_htons(x) (x) +#define lwip_ntohs(x) (x) +#define lwip_htonl(x) (x) +#define lwip_ntohl(x) (x) +#define PP_HTONS(x) (x) +#define PP_NTOHS(x) (x) +#define PP_HTONL(x) (x) +#define PP_NTOHL(x) (x) +#else /* BYTE_ORDER != BIG_ENDIAN */ +#if LWIP_PLATFORM_BYTESWAP +#define lwip_htons(x) LWIP_PLATFORM_HTONS(x) +#define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) +#define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) +#define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) +#else /* LWIP_PLATFORM_BYTESWAP */ +u16_t lwip_htons(u16_t x); +u16_t lwip_ntohs(u16_t x); +u32_t lwip_htonl(u32_t x); +u32_t lwip_ntohl(u32_t x); +#endif /* LWIP_PLATFORM_BYTESWAP */ + +/* These macros should be calculated by the preprocessor and are used + with compile-time constants only (so that there is no little-endian + overhead at runtime). */ +#define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) +#define PP_NTOHS(x) PP_HTONS(x) +#define PP_HTONL(x) ((((x) & 0xff) << 24) | \ + (((x) & 0xff00) << 8) | \ + (((x) & 0xff0000UL) >> 8) | \ + (((x) & 0xff000000UL) >> 24)) +#define PP_NTOHL(x) PP_HTONL(x) + +#endif /* BYTE_ORDER == BIG_ENDIAN */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_DEF_H__ */ + diff --git a/user/mpy/lib/lwip/src/include/lwip/dhcp.h b/user/mpy/lib/lwip/src/include/lwip/dhcp.h new file mode 100644 index 0000000..32d9338 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/dhcp.h @@ -0,0 +1,242 @@ +/** @file + */ + +#ifndef __LWIP_DHCP_H__ +#define __LWIP_DHCP_H__ + +#include "lwip/opt.h" + +#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/netif.h" +#include "lwip/udp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** period (in seconds) of the application calling dhcp_coarse_tmr() */ +#define DHCP_COARSE_TIMER_SECS 60 +/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ +#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) +/** period (in milliseconds) of the application calling dhcp_fine_tmr() */ +#define DHCP_FINE_TIMER_MSECS 500 + +#define DHCP_CHADDR_LEN 16U +#define DHCP_SNAME_LEN 64U +#define DHCP_FILE_LEN 128U + +struct dhcp +{ + /** transaction identifier of last sent request */ + u32_t xid; + /** our connection to the DHCP server */ + struct udp_pcb *pcb; + /** incoming msg */ + struct dhcp_msg *msg_in; + /** current DHCP state machine state */ + u8_t state; + /** retries of current request */ + u8_t tries; +#if LWIP_DHCP_AUTOIP_COOP + u8_t autoip_coop_state; +#endif + u8_t subnet_mask_given; + + struct pbuf *p_out; /* pbuf of outcoming msg */ + struct dhcp_msg *msg_out; /* outgoing msg */ + u16_t options_out_len; /* outgoing msg options length */ + u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ + u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ + u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ + ip_addr_t server_ip_addr; /* dhcp server address that offered this lease */ + ip_addr_t offered_ip_addr; + ip_addr_t offered_sn_mask; + ip_addr_t offered_gw_addr; + + u32_t offered_t0_lease; /* lease period (in seconds) */ + u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ + u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */ + /* @todo: LWIP_DHCP_BOOTP_FILE configuration option? + integrate with possible TFTP-client for booting? */ +#if LWIP_DHCP_BOOTP_FILE + ip_addr_t offered_si_addr; + char boot_file_name[DHCP_FILE_LEN]; +#endif /* LWIP_DHCP_BOOTPFILE */ +}; + +/* MUST be compiled with "pack structs" or equivalent! */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** minimum set of fields of any DHCP message */ +struct dhcp_msg +{ + PACK_STRUCT_FIELD(u8_t op); + PACK_STRUCT_FIELD(u8_t htype); + PACK_STRUCT_FIELD(u8_t hlen); + PACK_STRUCT_FIELD(u8_t hops); + PACK_STRUCT_FIELD(u32_t xid); + PACK_STRUCT_FIELD(u16_t secs); + PACK_STRUCT_FIELD(u16_t flags); + PACK_STRUCT_FIELD(ip_addr_p_t ciaddr); + PACK_STRUCT_FIELD(ip_addr_p_t yiaddr); + PACK_STRUCT_FIELD(ip_addr_p_t siaddr); + PACK_STRUCT_FIELD(ip_addr_p_t giaddr); + PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]); + PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]); + PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]); + PACK_STRUCT_FIELD(u32_t cookie); +#define DHCP_MIN_OPTIONS_LEN 68U +/** make sure user does not configure this too small */ +#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) +# undef DHCP_OPTIONS_LEN +#endif +/** allow this to be configured in lwipopts.h, but not too small */ +#if (!defined(DHCP_OPTIONS_LEN)) +/** set this to be sufficient for your options in outgoing DHCP msgs */ +# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN +#endif + PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); +/** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */ +#define dhcp_remove_struct(netif) do { (netif)->dhcp = NULL; } while(0) +void dhcp_cleanup(struct netif *netif); +/** start DHCP configuration */ +err_t dhcp_start(struct netif *netif); +/** enforce early lease renewal (not needed normally)*/ +err_t dhcp_renew(struct netif *netif); +/** release the DHCP lease, usually called before dhcp_stop()*/ +err_t dhcp_release(struct netif *netif); +/** stop DHCP configuration */ +void dhcp_stop(struct netif *netif); +/** inform server of our manual IP address */ +void dhcp_inform(struct netif *netif); +/** Handle a possible change in the network configuration */ +void dhcp_network_changed(struct netif *netif); + +/** if enabled, check whether the offered IP address is not in use, using ARP */ +#if DHCP_DOES_ARP_CHECK +void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr); +#endif + +/** to be called every minute */ +void dhcp_coarse_tmr(void); +/** to be called every half second */ +void dhcp_fine_tmr(void); + +/** DHCP message item offsets and length */ +#define DHCP_OP_OFS 0 +#define DHCP_HTYPE_OFS 1 +#define DHCP_HLEN_OFS 2 +#define DHCP_HOPS_OFS 3 +#define DHCP_XID_OFS 4 +#define DHCP_SECS_OFS 8 +#define DHCP_FLAGS_OFS 10 +#define DHCP_CIADDR_OFS 12 +#define DHCP_YIADDR_OFS 16 +#define DHCP_SIADDR_OFS 20 +#define DHCP_GIADDR_OFS 24 +#define DHCP_CHADDR_OFS 28 +#define DHCP_SNAME_OFS 44 +#define DHCP_FILE_OFS 108 +#define DHCP_MSG_LEN 236 + +#define DHCP_COOKIE_OFS DHCP_MSG_LEN +#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4) + +#define DHCP_CLIENT_PORT 68 +#define DHCP_SERVER_PORT 67 + +/** DHCP client states */ +#define DHCP_OFF 0 +#define DHCP_REQUESTING 1 +#define DHCP_INIT 2 +#define DHCP_REBOOTING 3 +#define DHCP_REBINDING 4 +#define DHCP_RENEWING 5 +#define DHCP_SELECTING 6 +#define DHCP_INFORMING 7 +#define DHCP_CHECKING 8 +#define DHCP_PERMANENT 9 +#define DHCP_BOUND 10 +/** not yet implemented #define DHCP_RELEASING 11 */ +#define DHCP_BACKING_OFF 12 + +/** AUTOIP cooperatation flags */ +#define DHCP_AUTOIP_COOP_STATE_OFF 0 +#define DHCP_AUTOIP_COOP_STATE_ON 1 + +#define DHCP_BOOTREQUEST 1 +#define DHCP_BOOTREPLY 2 + +/** DHCP message types */ +#define DHCP_DISCOVER 1 +#define DHCP_OFFER 2 +#define DHCP_REQUEST 3 +#define DHCP_DECLINE 4 +#define DHCP_ACK 5 +#define DHCP_NAK 6 +#define DHCP_RELEASE 7 +#define DHCP_INFORM 8 + +/** DHCP hardware type, currently only ethernet is supported */ +#define DHCP_HTYPE_ETH 1 + +#define DHCP_MAGIC_COOKIE 0x63825363UL + +/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */ + +/** BootP options */ +#define DHCP_OPTION_PAD 0 +#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ +#define DHCP_OPTION_ROUTER 3 +#define DHCP_OPTION_DNS_SERVER 6 +#define DHCP_OPTION_HOSTNAME 12 +#define DHCP_OPTION_IP_TTL 23 +#define DHCP_OPTION_MTU 26 +#define DHCP_OPTION_BROADCAST 28 +#define DHCP_OPTION_TCP_TTL 37 +#define DHCP_OPTION_END 255 + +/** DHCP options */ +#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ +#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ +#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ + +#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ +#define DHCP_OPTION_MESSAGE_TYPE_LEN 1 + +#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ +#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ + +#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ +#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 + +#define DHCP_OPTION_T1 58 /* T1 renewal time */ +#define DHCP_OPTION_T2 59 /* T2 rebinding time */ +#define DHCP_OPTION_US 60 +#define DHCP_OPTION_CLIENT_ID 61 +#define DHCP_OPTION_TFTP_SERVERNAME 66 +#define DHCP_OPTION_BOOTFILE 67 + +/** possible combinations of overloading the file and sname fields with options */ +#define DHCP_OVERLOAD_NONE 0 +#define DHCP_OVERLOAD_FILE 1 +#define DHCP_OVERLOAD_SNAME 2 +#define DHCP_OVERLOAD_SNAME_FILE 3 + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_DHCP */ + +#endif /*__LWIP_DHCP_H__*/ diff --git a/user/mpy/lib/lwip/src/include/lwip/dns.h b/user/mpy/lib/lwip/src/include/lwip/dns.h new file mode 100644 index 0000000..6c7d9b0 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/dns.h @@ -0,0 +1,124 @@ +/** + * lwip DNS resolver header file. + + * Author: Jim Pettinato + * April 2007 + + * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LWIP_DNS_H__ +#define __LWIP_DNS_H__ + +#include "lwip/opt.h" + +#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** DNS timer period */ +#define DNS_TMR_INTERVAL 1000 + +/** DNS field TYPE used for "Resource Records" */ +#define DNS_RRTYPE_A 1 /* a host address */ +#define DNS_RRTYPE_NS 2 /* an authoritative name server */ +#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ +#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ +#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ +#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ +#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ +#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ +#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ +#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ +#define DNS_RRTYPE_WKS 11 /* a well known service description */ +#define DNS_RRTYPE_PTR 12 /* a domain name pointer */ +#define DNS_RRTYPE_HINFO 13 /* host information */ +#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ +#define DNS_RRTYPE_MX 15 /* mail exchange */ +#define DNS_RRTYPE_TXT 16 /* text strings */ + +/** DNS field CLASS used for "Resource Records" */ +#define DNS_RRCLASS_IN 1 /* the Internet */ +#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ +#define DNS_RRCLASS_CH 3 /* the CHAOS class */ +#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ +#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ + +/* The size used for the next line is rather a hack, but it prevents including socket.h in all files + that include memp.h, and that would possibly break portability (since socket.h defines some types + and constants possibly already define by the OS). + Calculation rule: + sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */ +#define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1) + +#if DNS_LOCAL_HOSTLIST +/** struct used for local host-list */ +struct local_hostlist_entry { + /** static hostname */ + const char *name; + /** static host address in network byteorder */ + ip_addr_t addr; + struct local_hostlist_entry *next; +}; +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC +#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN +#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH +#endif +#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ +#endif /* DNS_LOCAL_HOSTLIST */ + +/** Callback which is invoked when a hostname is found. + * A function of this type must be implemented by the application using the DNS resolver. + * @param name pointer to the name that was looked up. + * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, + * or NULL if the name could not be found (or on any other error). + * @param callback_arg a user-specified callback argument passed to dns_gethostbyname +*/ +typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); + +void dns_init(void); +void dns_tmr(void); +void dns_setserver(u8_t numdns, ip_addr_t *dnsserver); +ip_addr_t dns_getserver(u8_t numdns); +err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, + dns_found_callback found, void *callback_arg); + +#if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC +int dns_local_removehost(const char *hostname, const ip_addr_t *addr); +err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); +#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_DNS */ + +#endif /* __LWIP_DNS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/err.h b/user/mpy/lib/lwip/src/include/lwip/err.h new file mode 100644 index 0000000..ac90772 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/err.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_ERR_H__ +#define __LWIP_ERR_H__ + +#include "lwip/opt.h" +#include "lwip/arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Define LWIP_ERR_T in cc.h if you want to use + * a different type for your platform (must be signed). */ +#ifdef LWIP_ERR_T +typedef LWIP_ERR_T err_t; +#else /* LWIP_ERR_T */ +typedef s8_t err_t; +#endif /* LWIP_ERR_T*/ + +/* Definitions for error constants. */ + +#define ERR_OK 0 /* No error, everything OK. */ +#define ERR_MEM -1 /* Out of memory error. */ +#define ERR_BUF -2 /* Buffer error. */ +#define ERR_TIMEOUT -3 /* Timeout. */ +#define ERR_RTE -4 /* Routing problem. */ +#define ERR_INPROGRESS -5 /* Operation in progress */ +#define ERR_VAL -6 /* Illegal value. */ +#define ERR_WOULDBLOCK -7 /* Operation would block. */ +#define ERR_USE -8 /* Address in use. */ +#define ERR_ISCONN -9 /* Already connected. */ + +#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) + +#define ERR_ABRT -10 /* Connection aborted. */ +#define ERR_RST -11 /* Connection reset. */ +#define ERR_CLSD -12 /* Connection closed. */ +#define ERR_CONN -13 /* Not connected. */ + +#define ERR_ARG -14 /* Illegal argument. */ + +#define ERR_IF -15 /* Low-level netif error */ + + +#ifdef LWIP_DEBUG +extern const char *lwip_strerr(err_t err); +#else +#define lwip_strerr(x) "" +#endif /* LWIP_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_ERR_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/init.h b/user/mpy/lib/lwip/src/include/lwip/init.h new file mode 100644 index 0000000..4e2e285 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/init.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_INIT_H__ +#define __LWIP_INIT_H__ + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** X.x.x: Major version of the stack */ +#define LWIP_VERSION_MAJOR 1U +/** x.X.x: Minor version of the stack */ +#define LWIP_VERSION_MINOR 4U +/** x.x.X: Revision of the stack */ +#define LWIP_VERSION_REVISION 1U +/** For release candidates, this is set to 1..254 + * For official releases, this is set to 255 (LWIP_RC_RELEASE) + * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ +#define LWIP_VERSION_RC 0U + +/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ +#define LWIP_RC_RELEASE 255U +/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ +#define LWIP_RC_DEVELOPMENT 0U + +#define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) +#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) +#define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) + +/** Provides the version of the stack */ +#define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ + LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) + +/* Modules initialization */ +void lwip_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_INIT_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/mem.h b/user/mpy/lib/lwip/src/include/lwip/mem.h new file mode 100644 index 0000000..5bb906b --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/mem.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_MEM_H__ +#define __LWIP_MEM_H__ + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if MEM_LIBC_MALLOC + +#include /* for size_t */ + +typedef size_t mem_size_t; +#define MEM_SIZE_F SZT_F + +/* aliases for C library malloc() */ +#define mem_init() +/* in case C library malloc() needs extra protection, + * allow these defines to be overridden. + */ +#ifndef mem_free +#define mem_free free +#endif +#ifndef mem_malloc +#define mem_malloc malloc +#endif +#ifndef mem_calloc +#define mem_calloc calloc +#endif +/* Since there is no C library allocation function to shrink memory without + moving it, define this to nothing. */ +#ifndef mem_trim +#define mem_trim(mem, size) (mem) +#endif +#else /* MEM_LIBC_MALLOC */ + +/* MEM_SIZE would have to be aligned, but using 64000 here instead of + * 65535 leaves some room for alignment... + */ +#if MEM_SIZE > 64000L +typedef u32_t mem_size_t; +#define MEM_SIZE_F U32_F +#else +typedef u16_t mem_size_t; +#define MEM_SIZE_F U16_F +#endif /* MEM_SIZE > 64000 */ + +#if MEM_USE_POOLS +/** mem_init is not used when using pools instead of a heap */ +#define mem_init() +/** mem_trim is not used when using pools instead of a heap: + we can't free part of a pool element and don't want to copy the rest */ +#define mem_trim(mem, size) (mem) +#else /* MEM_USE_POOLS */ +/* lwIP alternative malloc */ +void mem_init(void); +void *mem_trim(void *mem, mem_size_t size); +#endif /* MEM_USE_POOLS */ +void *mem_malloc(mem_size_t size); +void *mem_calloc(mem_size_t count, mem_size_t size); +void mem_free(void *mem); +#endif /* MEM_LIBC_MALLOC */ + +/** Calculate memory size for an aligned buffer - returns the next highest + * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and + * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4). + */ +#ifndef LWIP_MEM_ALIGN_SIZE +#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) +#endif + +/** Calculate safe memory size for an aligned buffer when using an unaligned + * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the + * start (e.g. if buffer is u8_t[] and actual data will be u32_t*) + */ +#ifndef LWIP_MEM_ALIGN_BUFFER +#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1)) +#endif + +/** Align a memory pointer to the alignment defined by MEM_ALIGNMENT + * so that ADDR % MEM_ALIGNMENT == 0 + */ +#ifndef LWIP_MEM_ALIGN +#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_MEM_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/memp.h b/user/mpy/lib/lwip/src/include/lwip/memp.h new file mode 100644 index 0000000..f0d0739 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/memp.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#ifndef __LWIP_MEMP_H__ +#define __LWIP_MEMP_H__ + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ +typedef enum { +#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, +#include "lwip/memp_std.h" + MEMP_MAX +} memp_t; + +#if MEM_USE_POOLS +/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ +typedef enum { + /* Get the first (via: + MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ + MEMP_POOL_HELPER_FIRST = ((u8_t) +#define LWIP_MEMPOOL(name,num,size,desc) +#define LWIP_MALLOC_MEMPOOL_START 1 +#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 +#define LWIP_MALLOC_MEMPOOL_END +#include "lwip/memp_std.h" + ) , + /* Get the last (via: + MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ + MEMP_POOL_HELPER_LAST = ((u8_t) +#define LWIP_MEMPOOL(name,num,size,desc) +#define LWIP_MALLOC_MEMPOOL_START +#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * +#define LWIP_MALLOC_MEMPOOL_END 1 +#include "lwip/memp_std.h" + ) +} memp_pool_helper_t; + +/* The actual start and stop values are here (cast them over) + We use this helper type and these defines so we can avoid using const memp_t values */ +#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) +#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) +#endif /* MEM_USE_POOLS */ + +#if MEMP_MEM_MALLOC || MEM_USE_POOLS +extern const u16_t memp_sizes[MEMP_MAX]; +#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ + +#if MEMP_MEM_MALLOC + +#include "mem.h" + +#define memp_init() +#define memp_malloc(type) mem_malloc(memp_sizes[type]) +#define memp_free(type, mem) mem_free(mem) + +#else /* MEMP_MEM_MALLOC */ + +#if MEM_USE_POOLS +/** This structure is used to save the pool one element came from. */ +struct memp_malloc_helper +{ + memp_t poolnr; +}; +#endif /* MEM_USE_POOLS */ + +void memp_init(void); + +#if MEMP_OVERFLOW_CHECK +void *memp_malloc_fn(memp_t type, const char* file, const int line); +#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) +#else +void *memp_malloc(memp_t type); +#endif +void memp_free(memp_t type, void *mem); + +#endif /* MEMP_MEM_MALLOC */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_MEMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/memp_std.h b/user/mpy/lib/lwip/src/include/lwip/memp_std.h new file mode 100644 index 0000000..461ed1a --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/memp_std.h @@ -0,0 +1,122 @@ +/* + * SETUP: Make sure we define everything we will need. + * + * We have create three types of pools: + * 1) MEMPOOL - standard pools + * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c + * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct + * + * If the include'r doesn't require any special treatment of each of the types + * above, then will declare #2 & #3 to be just standard mempools. + */ +#ifndef LWIP_MALLOC_MEMPOOL +/* This treats "malloc pools" just like any other pool. + The pools are a little bigger to provide 'size' as the amount of user data. */ +#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size) +#define LWIP_MALLOC_MEMPOOL_START +#define LWIP_MALLOC_MEMPOOL_END +#endif /* LWIP_MALLOC_MEMPOOL */ + +#ifndef LWIP_PBUF_MEMPOOL +/* This treats "pbuf pools" just like any other pool. + * Allocates buffers for a pbuf struct AND a payload size */ +#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc) +#endif /* LWIP_PBUF_MEMPOOL */ + + +/* + * A list of internal pools used by LWIP. + * + * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description) + * creates a pool name MEMP_pool_name. description is used in stats.c + */ +#if LWIP_RAW +LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB") +#endif /* LWIP_RAW */ + +#if LWIP_UDP +LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB") +#endif /* LWIP_UDP */ + +#if LWIP_TCP +LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") +LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN") +LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG") +#endif /* LWIP_TCP */ + +#if IP_REASSEMBLY +LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA") +#endif /* IP_REASSEMBLY */ +#if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF +LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF") +#endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ + +#if LWIP_NETCONN +LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF") +LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN") +#endif /* LWIP_NETCONN */ + +#if NO_SYS==0 +LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API") +#if !LWIP_TCPIP_CORE_LOCKING_INPUT +LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT") +#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ +#endif /* NO_SYS==0 */ + +#if LWIP_ARP && ARP_QUEUEING +LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE") +#endif /* LWIP_ARP && ARP_QUEUEING */ + +#if LWIP_IGMP +LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP") +#endif /* LWIP_IGMP */ + +#if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */ +LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT") +#endif /* LWIP_TIMERS */ + +#if LWIP_SNMP +LWIP_MEMPOOL(SNMP_ROOTNODE, MEMP_NUM_SNMP_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE") +LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_node), "SNMP_NODE") +LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND") +LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE") +#endif /* LWIP_SNMP */ +#if LWIP_DNS && LWIP_SOCKET +LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB") +#endif /* LWIP_DNS && LWIP_SOCKET */ +#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC +LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST") +#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ +#if PPP_SUPPORT && PPPOE_SUPPORT +LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF") +#endif /* PPP_SUPPORT && PPPOE_SUPPORT */ + +/* + * A list of pools of pbuf's used by LWIP. + * + * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description) + * creates a pool name MEMP_pool_name. description is used in stats.c + * This allocates enough space for the pbuf struct and a payload. + * (Example: pbuf_payload_size=0 allocates only size for the struct) + */ +LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM") +LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL") + + +/* + * Allow for user-defined pools; this must be explicitly set in lwipopts.h + * since the default is to NOT look for lwippools.h + */ +#if MEMP_USE_CUSTOM_POOLS +#include "lwippools.h" +#endif /* MEMP_USE_CUSTOM_POOLS */ + +/* + * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later + * (#undef is ignored for something that is not defined) + */ +#undef LWIP_MEMPOOL +#undef LWIP_MALLOC_MEMPOOL +#undef LWIP_MALLOC_MEMPOOL_START +#undef LWIP_MALLOC_MEMPOOL_END +#undef LWIP_PBUF_MEMPOOL diff --git a/user/mpy/lib/lwip/src/include/lwip/netbuf.h b/user/mpy/lib/lwip/src/include/lwip/netbuf.h new file mode 100644 index 0000000..7d247d7 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/netbuf.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_NETBUF_H__ +#define __LWIP_NETBUF_H__ + +#include "lwip/opt.h" +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** This netbuf has dest-addr/port set */ +#define NETBUF_FLAG_DESTADDR 0x01 +/** This netbuf includes a checksum */ +#define NETBUF_FLAG_CHKSUM 0x02 + +struct netbuf { + struct pbuf *p, *ptr; + ip_addr_t addr; + u16_t port; +#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY +#if LWIP_CHECKSUM_ON_COPY + u8_t flags; +#endif /* LWIP_CHECKSUM_ON_COPY */ + u16_t toport_chksum; +#if LWIP_NETBUF_RECVINFO + ip_addr_t toaddr; +#endif /* LWIP_NETBUF_RECVINFO */ +#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ +}; + +/* Network buffer functions: */ +struct netbuf * netbuf_new (void); +void netbuf_delete (struct netbuf *buf); +void * netbuf_alloc (struct netbuf *buf, u16_t size); +void netbuf_free (struct netbuf *buf); +err_t netbuf_ref (struct netbuf *buf, + const void *dataptr, u16_t size); +void netbuf_chain (struct netbuf *head, + struct netbuf *tail); + +err_t netbuf_data (struct netbuf *buf, + void **dataptr, u16_t *len); +s8_t netbuf_next (struct netbuf *buf); +void netbuf_first (struct netbuf *buf); + + +#define netbuf_copy_partial(buf, dataptr, len, offset) \ + pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) +#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) +#define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) +#define netbuf_len(buf) ((buf)->p->tot_len) +#define netbuf_fromaddr(buf) (&((buf)->addr)) +#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr) +#define netbuf_fromport(buf) ((buf)->port) +#if LWIP_NETBUF_RECVINFO +#define netbuf_destaddr(buf) (&((buf)->toaddr)) +#define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr) +#define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) +#endif /* LWIP_NETBUF_RECVINFO */ +#if LWIP_CHECKSUM_ON_COPY +#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ + (buf)->toport_chksum = chksum; } while(0) +#endif /* LWIP_CHECKSUM_ON_COPY */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_NETBUF_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/netdb.h b/user/mpy/lib/lwip/src/include/lwip/netdb.h new file mode 100644 index 0000000..7587e2f --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/netdb.h @@ -0,0 +1,124 @@ +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ +#ifndef __LWIP_NETDB_H__ +#define __LWIP_NETDB_H__ + +#include "lwip/opt.h" + +#if LWIP_DNS && LWIP_SOCKET + +#include /* for size_t */ + +#include "lwip/inet.h" +#include "lwip/sockets.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* some rarely used options */ +#ifndef LWIP_DNS_API_DECLARE_H_ERRNO +#define LWIP_DNS_API_DECLARE_H_ERRNO 1 +#endif + +#ifndef LWIP_DNS_API_DEFINE_ERRORS +#define LWIP_DNS_API_DEFINE_ERRORS 1 +#endif + +#ifndef LWIP_DNS_API_DECLARE_STRUCTS +#define LWIP_DNS_API_DECLARE_STRUCTS 1 +#endif + +#if LWIP_DNS_API_DEFINE_ERRORS +/** Errors used by the DNS API functions, h_errno can be one of them */ +#define EAI_NONAME 200 +#define EAI_SERVICE 201 +#define EAI_FAIL 202 +#define EAI_MEMORY 203 + +#define HOST_NOT_FOUND 210 +#define NO_DATA 211 +#define NO_RECOVERY 212 +#define TRY_AGAIN 213 +#endif /* LWIP_DNS_API_DEFINE_ERRORS */ + +#if LWIP_DNS_API_DECLARE_STRUCTS +struct hostent { + char *h_name; /* Official name of the host. */ + char **h_aliases; /* A pointer to an array of pointers to alternative host names, + terminated by a null pointer. */ + int h_addrtype; /* Address type. */ + int h_length; /* The length, in bytes, of the address. */ + char **h_addr_list; /* A pointer to an array of pointers to network addresses (in + network byte order) for the host, terminated by a null pointer. */ +#define h_addr h_addr_list[0] /* for backward compatibility */ +}; + +struct addrinfo { + int ai_flags; /* Input flags. */ + int ai_family; /* Address family of socket. */ + int ai_socktype; /* Socket type. */ + int ai_protocol; /* Protocol of socket. */ + socklen_t ai_addrlen; /* Length of socket address. */ + struct sockaddr *ai_addr; /* Socket address of socket. */ + char *ai_canonname; /* Canonical name of service location. */ + struct addrinfo *ai_next; /* Pointer to next in list. */ +}; +#endif /* LWIP_DNS_API_DECLARE_STRUCTS */ + +#if LWIP_DNS_API_DECLARE_H_ERRNO +/* application accessable error code set by the DNS API functions */ +extern int h_errno; +#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/ + +struct hostent *lwip_gethostbyname(const char *name); +int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, + size_t buflen, struct hostent **result, int *h_errnop); +void lwip_freeaddrinfo(struct addrinfo *ai); +int lwip_getaddrinfo(const char *nodename, + const char *servname, + const struct addrinfo *hints, + struct addrinfo **res); + +#if LWIP_COMPAT_SOCKETS +#define gethostbyname(name) lwip_gethostbyname(name) +#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \ + lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop) +#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo) +#define getaddrinfo(nodname, servname, hints, res) \ + lwip_getaddrinfo(nodname, servname, hints, res) +#endif /* LWIP_COMPAT_SOCKETS */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_DNS && LWIP_SOCKET */ + +#endif /* __LWIP_NETDB_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/netif.h b/user/mpy/lib/lwip/src/include/lwip/netif.h new file mode 100644 index 0000000..f7e4937 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/netif.h @@ -0,0 +1,328 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_NETIF_H__ +#define __LWIP_NETIF_H__ + +#include "lwip/opt.h" + +#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) + +#include "lwip/err.h" + +#include "lwip/ip_addr.h" + +#include "lwip/def.h" +#include "lwip/pbuf.h" +#if LWIP_DHCP +struct dhcp; +#endif +#if LWIP_AUTOIP +struct autoip; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Throughout this file, IP addresses are expected to be in + * the same byte order as in IP_PCB. */ + +/** must be the maximum of all used hardware address lengths + across all types of interfaces in use */ +#define NETIF_MAX_HWADDR_LEN 6U + +/** Whether the network interface is 'up'. This is + * a software flag used to control whether this network + * interface is enabled and processes traffic. + * It is set by the startup code (for static IP configuration) or + * by dhcp/autoip when an address has been assigned. + */ +#define NETIF_FLAG_UP 0x01U +/** If set, the netif has broadcast capability. + * Set by the netif driver in its init function. */ +#define NETIF_FLAG_BROADCAST 0x02U +/** If set, the netif is one end of a point-to-point connection. + * Set by the netif driver in its init function. */ +#define NETIF_FLAG_POINTTOPOINT 0x04U +/** If set, the interface is configured using DHCP. + * Set by the DHCP code when starting or stopping DHCP. */ +#define NETIF_FLAG_DHCP 0x08U +/** If set, the interface has an active link + * (set by the network interface driver). + * Either set by the netif driver in its init function (if the link + * is up at that time) or at a later point once the link comes up + * (if link detection is supported by the hardware). */ +#define NETIF_FLAG_LINK_UP 0x10U +/** If set, the netif is an ethernet device using ARP. + * Set by the netif driver in its init function. + * Used to check input packet types and use of DHCP. */ +#define NETIF_FLAG_ETHARP 0x20U +/** If set, the netif is an ethernet device. It might not use + * ARP or TCP/IP if it is used for PPPoE only. + */ +#define NETIF_FLAG_ETHERNET 0x40U +/** If set, the netif has IGMP capability. + * Set by the netif driver in its init function. */ +#define NETIF_FLAG_IGMP 0x80U + +/** Function prototype for netif init functions. Set up flags and output/linkoutput + * callback functions in this function. + * + * @param netif The netif to initialize + */ +typedef err_t (*netif_init_fn)(struct netif *netif); +/** Function prototype for netif->input functions. This function is saved as 'input' + * callback function in the netif struct. Call it when a packet has been received. + * + * @param p The received packet, copied into a pbuf + * @param inp The netif which received the packet + */ +typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); +/** Function prototype for netif->output functions. Called by lwIP when a packet + * shall be sent. For ethernet netif, set this to 'etharp_output' and set + * 'linkoutput'. + * + * @param netif The netif which shall send a packet + * @param p The packet to send (p->payload points to IP header) + * @param ipaddr The IP address to which the packet shall be sent + */ +typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, + ip_addr_t *ipaddr); +/** Function prototype for netif->linkoutput functions. Only used for ethernet + * netifs. This function is called by ARP when a packet shall be sent. + * + * @param netif The netif which shall send a packet + * @param p The packet to send (raw ethernet packet) + */ +typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); +/** Function prototype for netif status- or link-callback functions. */ +typedef void (*netif_status_callback_fn)(struct netif *netif); +/** Function prototype for netif igmp_mac_filter functions */ +typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, + ip_addr_t *group, u8_t action); + +/** Generic data structure used for all lwIP network interfaces. + * The following fields should be filled in by the initialization + * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ +struct netif { + /** pointer to next in linked list */ + struct netif *next; + + /** IP address configuration in network byte order */ + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + + /** This function is called by the network device driver + * to pass a packet up the TCP/IP stack. */ + netif_input_fn input; + /** This function is called by the IP module when it wants + * to send a packet on the interface. This function typically + * first resolves the hardware address, then sends the packet. */ + netif_output_fn output; + /** This function is called by the ARP module when it wants + * to send a packet on the interface. This function outputs + * the pbuf as-is on the link medium. */ + netif_linkoutput_fn linkoutput; +#if LWIP_NETIF_STATUS_CALLBACK + /** This function is called when the netif state is set to up or down + */ + netif_status_callback_fn status_callback; +#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#if LWIP_NETIF_LINK_CALLBACK + /** This function is called when the netif link is set to up or down + */ + netif_status_callback_fn link_callback; +#endif /* LWIP_NETIF_LINK_CALLBACK */ +#if LWIP_NETIF_REMOVE_CALLBACK + /** This function is called when the netif has been removed */ + netif_status_callback_fn remove_callback; +#endif /* LWIP_NETIF_REMOVE_CALLBACK */ + /** This field can be set by the device driver and could point + * to state information for the device. */ + void *state; +#if LWIP_DHCP + /** the DHCP client state information for this netif */ + struct dhcp *dhcp; +#endif /* LWIP_DHCP */ +#if LWIP_AUTOIP + /** the AutoIP client state information for this netif */ + struct autoip *autoip; +#endif +#if LWIP_NETIF_HOSTNAME + /* the hostname for this netif, NULL is a valid value */ + char* hostname; +#endif /* LWIP_NETIF_HOSTNAME */ + /** maximum transfer unit (in bytes) */ + u16_t mtu; + /** number of bytes used in hwaddr */ + u8_t hwaddr_len; + /** link level hardware address of this interface */ + u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; + /** flags (see NETIF_FLAG_ above) */ + u8_t flags; + /** descriptive abbreviation */ + char name[2]; + /** number of this interface */ + u8_t num; +#if LWIP_SNMP + /** link type (from "snmp_ifType" enum from snmp.h) */ + u8_t link_type; + /** (estimate) link speed */ + u32_t link_speed; + /** timestamp at last change made (up/down) */ + u32_t ts; + /** counters */ + u32_t ifinoctets; + u32_t ifinucastpkts; + u32_t ifinnucastpkts; + u32_t ifindiscards; + u32_t ifoutoctets; + u32_t ifoutucastpkts; + u32_t ifoutnucastpkts; + u32_t ifoutdiscards; +#endif /* LWIP_SNMP */ +#if LWIP_IGMP + /** This function could be called to add or delete a entry in the multicast + filter table of the ethernet MAC.*/ + netif_igmp_mac_filter_fn igmp_mac_filter; +#endif /* LWIP_IGMP */ +#if LWIP_NETIF_HWADDRHINT + u8_t *addr_hint; +#endif /* LWIP_NETIF_HWADDRHINT */ +#if ENABLE_LOOPBACK + /* List of packets to be queued for ourselves. */ + struct pbuf *loop_first; + struct pbuf *loop_last; +#if LWIP_LOOPBACK_MAX_PBUFS + u16_t loop_cnt_current; +#endif /* LWIP_LOOPBACK_MAX_PBUFS */ +#endif /* ENABLE_LOOPBACK */ +}; + +#if LWIP_SNMP +#define NETIF_INIT_SNMP(netif, type, speed) \ + /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ + (netif)->link_type = (type); \ + /* your link speed here (units: bits per second) */ \ + (netif)->link_speed = (speed); \ + (netif)->ts = 0; \ + (netif)->ifinoctets = 0; \ + (netif)->ifinucastpkts = 0; \ + (netif)->ifinnucastpkts = 0; \ + (netif)->ifindiscards = 0; \ + (netif)->ifoutoctets = 0; \ + (netif)->ifoutucastpkts = 0; \ + (netif)->ifoutnucastpkts = 0; \ + (netif)->ifoutdiscards = 0 +#else /* LWIP_SNMP */ +#define NETIF_INIT_SNMP(netif, type, speed) +#endif /* LWIP_SNMP */ + + +/** The list of network interfaces. */ +extern struct netif *netif_list; +/** The default network interface. */ +extern struct netif *netif_default; + +void netif_init(void); + +struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, + ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input); + +void +netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, + ip_addr_t *gw); +void netif_remove(struct netif * netif); + +/* Returns a network interface given its name. The name is of the form + "et0", where the first two letters are the "name" field in the + netif structure, and the digit is in the num field in the same + structure. */ +struct netif *netif_find(char *name); + +void netif_set_default(struct netif *netif); + +void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr); +void netif_set_netmask(struct netif *netif, ip_addr_t *netmask); +void netif_set_gw(struct netif *netif, ip_addr_t *gw); + +void netif_set_up(struct netif *netif); +void netif_set_down(struct netif *netif); +/** Ask if an interface is up */ +#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) + +#if LWIP_NETIF_STATUS_CALLBACK +void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); +#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#if LWIP_NETIF_REMOVE_CALLBACK +void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); +#endif /* LWIP_NETIF_REMOVE_CALLBACK */ + +void netif_set_link_up(struct netif *netif); +void netif_set_link_down(struct netif *netif); +/** Ask if a link is up */ +#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) + +#if LWIP_NETIF_LINK_CALLBACK +void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); +#endif /* LWIP_NETIF_LINK_CALLBACK */ + +#if LWIP_NETIF_HOSTNAME +#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) +#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) +#endif /* LWIP_NETIF_HOSTNAME */ + +#if LWIP_IGMP +#define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) +#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) +#endif /* LWIP_IGMP */ + +#if ENABLE_LOOPBACK +err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); +void netif_poll(struct netif *netif); +#if !LWIP_NETIF_LOOPBACK_MULTITHREADING +void netif_poll_all(void); +#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ +#endif /* ENABLE_LOOPBACK */ + +#if LWIP_NETIF_HWADDRHINT +#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) +#else /* LWIP_NETIF_HWADDRHINT */ +#define NETIF_SET_HWADDRHINT(netif, hint) +#endif /* LWIP_NETIF_HWADDRHINT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_NETIF_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/netifapi.h b/user/mpy/lib/lwip/src/include/lwip/netifapi.h new file mode 100644 index 0000000..33318ef --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/netifapi.h @@ -0,0 +1,108 @@ +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#ifndef __LWIP_NETIFAPI_H__ +#define __LWIP_NETIFAPI_H__ + +#include "lwip/opt.h" + +#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/sys.h" +#include "lwip/netif.h" +#include "lwip/dhcp.h" +#include "lwip/autoip.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*netifapi_void_fn)(struct netif *netif); +typedef err_t (*netifapi_errt_fn)(struct netif *netif); + +struct netifapi_msg_msg { +#if !LWIP_TCPIP_CORE_LOCKING + sys_sem_t sem; +#endif /* !LWIP_TCPIP_CORE_LOCKING */ + err_t err; + struct netif *netif; + union { + struct { + ip_addr_t *ipaddr; + ip_addr_t *netmask; + ip_addr_t *gw; + void *state; + netif_init_fn init; + netif_input_fn input; + } add; + struct { + netifapi_void_fn voidfunc; + netifapi_errt_fn errtfunc; + } common; + } msg; +}; + +struct netifapi_msg { + void (* function)(struct netifapi_msg_msg *msg); + struct netifapi_msg_msg msg; +}; + + +/* API for application */ +err_t netifapi_netif_add ( struct netif *netif, + ip_addr_t *ipaddr, + ip_addr_t *netmask, + ip_addr_t *gw, + void *state, + netif_init_fn init, + netif_input_fn input); + +err_t netifapi_netif_set_addr ( struct netif *netif, + ip_addr_t *ipaddr, + ip_addr_t *netmask, + ip_addr_t *gw ); + +err_t netifapi_netif_common ( struct netif *netif, + netifapi_void_fn voidfunc, + netifapi_errt_fn errtfunc); + +#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) +#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) +#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) +#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) +#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) +#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) +#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) +#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETIF_API */ + +#endif /* __LWIP_NETIFAPI_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/opt.h b/user/mpy/lib/lwip/src/include/lwip/opt.h new file mode 100644 index 0000000..b8ebec8 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/opt.h @@ -0,0 +1,2133 @@ +/** + * @file + * + * lwIP Options Configuration + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_OPT_H__ +#define __LWIP_OPT_H__ + +/* + * Include user defined options first. Anything not defined in these files + * will be set to standard values. Override anything you dont like! + */ +#include "lwipopts.h" +#include "lwip/debug.h" + +/* + ----------------------------------------------- + ---------- Platform specific locking ---------- + ----------------------------------------------- +*/ + +/** + * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain + * critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#ifndef SYS_LIGHTWEIGHT_PROT +#define SYS_LIGHTWEIGHT_PROT 0 +#endif + +/** + * NO_SYS==1: Provides VERY minimal functionality. Otherwise, + * use lwIP facilities. + */ +#ifndef NO_SYS +#define NO_SYS 0 +#endif + +/** + * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 + * Mainly for compatibility to old versions. + */ +#ifndef NO_SYS_NO_TIMERS +#define NO_SYS_NO_TIMERS 0 +#endif + +/** + * MEMCPY: override this if you have a faster implementation at hand than the + * one included in your C library + */ +#ifndef MEMCPY +#define MEMCPY(dst,src,len) memcpy(dst,src,len) +#endif + +/** + * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a + * call to memcpy() if the length is known at compile time and is small. + */ +#ifndef SMEMCPY +#define SMEMCPY(dst,src,len) memcpy(dst,src,len) +#endif + +/* + ------------------------------------ + ---------- Memory options ---------- + ------------------------------------ +*/ +/** + * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library + * instead of the lwip internal allocator. Can save code size if you + * already use it. + */ +#ifndef MEM_LIBC_MALLOC +#define MEM_LIBC_MALLOC 0 +#endif + +/** +* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. +* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution +* speed and usage from interrupts! +*/ +#ifndef MEMP_MEM_MALLOC +#define MEMP_MEM_MALLOC 0 +#endif + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#ifndef MEM_ALIGNMENT +#define MEM_ALIGNMENT 1 +#endif + +/** + * MEM_SIZE: the size of the heap memory. If the application will send + * a lot of data that needs to be copied, this should be set high. + */ +#ifndef MEM_SIZE +#define MEM_SIZE 1600 +#endif + +/** + * MEMP_SEPARATE_POOLS: if defined to 1, each pool is placed in its own array. + * This can be used to individually change the location of each pool. + * Default is one big array for all pools + */ +#ifndef MEMP_SEPARATE_POOLS +#define MEMP_SEPARATE_POOLS 0 +#endif + +/** + * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable + * amount of bytes before and after each memp element in every pool and fills + * it with a prominent default value. + * MEMP_OVERFLOW_CHECK == 0 no checking + * MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed + * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time + * memp_malloc() or memp_free() is called (useful but slow!) + */ +#ifndef MEMP_OVERFLOW_CHECK +#define MEMP_OVERFLOW_CHECK 0 +#endif + +/** + * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make + * sure that there are no cycles in the linked lists. + */ +#ifndef MEMP_SANITY_CHECK +#define MEMP_SANITY_CHECK 0 +#endif + +/** + * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set + * of memory pools of various sizes. When mem_malloc is called, an element of + * the smallest pool that can provide the length needed is returned. + * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled. + */ +#ifndef MEM_USE_POOLS +#define MEM_USE_POOLS 0 +#endif + +/** + * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next + * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more + * reliable. */ +#ifndef MEM_USE_POOLS_TRY_BIGGER_POOL +#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 +#endif + +/** + * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h + * that defines additional pools beyond the "standard" ones required + * by lwIP. If you set this to 1, you must have lwippools.h in your + * inlude path somewhere. + */ +#ifndef MEMP_USE_CUSTOM_POOLS +#define MEMP_USE_CUSTOM_POOLS 0 +#endif + +/** + * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from + * interrupt context (or another context that doesn't allow waiting for a + * semaphore). + * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, + * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs + * with each loop so that mem_free can run. + * + * ATTENTION: As you can see from the above description, this leads to dis-/ + * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc + * can need longer. + * + * If you don't want that, at least for NO_SYS=0, you can still use the following + * functions to enqueue a deallocation call which then runs in the tcpip_thread + * context: + * - pbuf_free_callback(p); + * - mem_free_callback(m); + */ +#ifndef LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT +#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 +#endif + +/* + ------------------------------------------------ + ---------- Internal Memory Pool Sizes ---------- + ------------------------------------------------ +*/ +/** + * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). + * If the application sends a lot of data out of ROM (or other static memory), + * this should be set high. + */ +#ifndef MEMP_NUM_PBUF +#define MEMP_NUM_PBUF 16 +#endif + +/** + * MEMP_NUM_RAW_PCB: Number of raw connection PCBs + * (requires the LWIP_RAW option) + */ +#ifndef MEMP_NUM_RAW_PCB +#define MEMP_NUM_RAW_PCB 4 +#endif + +/** + * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + * per active UDP "connection". + * (requires the LWIP_UDP option) + */ +#ifndef MEMP_NUM_UDP_PCB +#define MEMP_NUM_UDP_PCB 4 +#endif + +/** + * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. + * (requires the LWIP_TCP option) + */ +#ifndef MEMP_NUM_TCP_PCB +#define MEMP_NUM_TCP_PCB 5 +#endif + +/** + * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. + * (requires the LWIP_TCP option) + */ +#ifndef MEMP_NUM_TCP_PCB_LISTEN +#define MEMP_NUM_TCP_PCB_LISTEN 8 +#endif + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#ifndef MEMP_NUM_TCP_SEG +#define MEMP_NUM_TCP_SEG 16 +#endif + +/** + * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for + * reassembly (whole packets, not fragments!) + */ +#ifndef MEMP_NUM_REASSDATA +#define MEMP_NUM_REASSDATA 5 +#endif + +/** + * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent + * (fragments, not whole packets!). + * This is only used with IP_FRAG_USES_STATIC_BUF==0 and + * LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 with DMA-enabled MACs + * where the packet is not yet sent when netif->output returns. + */ +#ifndef MEMP_NUM_FRAG_PBUF +#define MEMP_NUM_FRAG_PBUF 15 +#endif + +/** + * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing + * packets (pbufs) that are waiting for an ARP request (to resolve + * their destination address) to finish. + * (requires the ARP_QUEUEING option) + */ +#ifndef MEMP_NUM_ARP_QUEUE +#define MEMP_NUM_ARP_QUEUE 30 +#endif + +/** + * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces + * can be members et the same time (one per netif - allsystems group -, plus one + * per netif membership). + * (requires the LWIP_IGMP option) + */ +#ifndef MEMP_NUM_IGMP_GROUP +#define MEMP_NUM_IGMP_GROUP 8 +#endif + +/** + * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. + * (requires NO_SYS==0) + * The default number of timeouts is calculated here for all enabled modules. + * The formula expects settings to be either '0' or '1'. + */ +#ifndef MEMP_NUM_SYS_TIMEOUT +#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT) +#endif + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#ifndef MEMP_NUM_NETBUF +#define MEMP_NUM_NETBUF 2 +#endif + +/** + * MEMP_NUM_NETCONN: the number of struct netconns. + * (only needed if you use the sequential API, like api_lib.c) + */ +#ifndef MEMP_NUM_NETCONN +#define MEMP_NUM_NETCONN 4 +#endif + +/** + * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used + * for callback/timeout API communication. + * (only needed if you use tcpip.c) + */ +#ifndef MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_TCPIP_MSG_API 8 +#endif + +/** + * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used + * for incoming packets. + * (only needed if you use tcpip.c) + */ +#ifndef MEMP_NUM_TCPIP_MSG_INPKT +#define MEMP_NUM_TCPIP_MSG_INPKT 8 +#endif + +/** + * MEMP_NUM_SNMP_NODE: the number of leafs in the SNMP tree. + */ +#ifndef MEMP_NUM_SNMP_NODE +#define MEMP_NUM_SNMP_NODE 50 +#endif + +/** + * MEMP_NUM_SNMP_ROOTNODE: the number of branches in the SNMP tree. + * Every branch has one leaf (MEMP_NUM_SNMP_NODE) at least! + */ +#ifndef MEMP_NUM_SNMP_ROOTNODE +#define MEMP_NUM_SNMP_ROOTNODE 30 +#endif + +/** + * MEMP_NUM_SNMP_VARBIND: the number of concurrent requests (does not have to + * be changed normally) - 2 of these are used per request (1 for input, + * 1 for output) + */ +#ifndef MEMP_NUM_SNMP_VARBIND +#define MEMP_NUM_SNMP_VARBIND 2 +#endif + +/** + * MEMP_NUM_SNMP_VALUE: the number of OID or values concurrently used + * (does not have to be changed normally) - 3 of these are used per request + * (1 for the value read and 2 for OIDs - input and output) + */ +#ifndef MEMP_NUM_SNMP_VALUE +#define MEMP_NUM_SNMP_VALUE 3 +#endif + +/** + * MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls + * (before freeing the corresponding memory using lwip_freeaddrinfo()). + */ +#ifndef MEMP_NUM_NETDB +#define MEMP_NUM_NETDB 1 +#endif + +/** + * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list + * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1. + */ +#ifndef MEMP_NUM_LOCALHOSTLIST +#define MEMP_NUM_LOCALHOSTLIST 1 +#endif + +/** + * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE + * interfaces (only used with PPPOE_SUPPORT==1) + */ +#ifndef MEMP_NUM_PPPOE_INTERFACES +#define MEMP_NUM_PPPOE_INTERFACES 1 +#endif + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + */ +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE 16 +#endif + +/* + --------------------------------- + ---------- ARP options ---------- + --------------------------------- +*/ +/** + * LWIP_ARP==1: Enable ARP functionality. + */ +#ifndef LWIP_ARP +#define LWIP_ARP 1 +#endif + +/** + * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached. + */ +#ifndef ARP_TABLE_SIZE +#define ARP_TABLE_SIZE 10 +#endif + +/** + * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address + * resolution. By default, only the most recent packet is queued per IP address. + * This is sufficient for most protocols and mainly reduces TCP connection + * startup time. Set this to 1 if you know your application sends more than one + * packet in a row to an IP address that is not in the ARP cache. + */ +#ifndef ARP_QUEUEING +#define ARP_QUEUEING 0 +#endif + +/** + * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be + * updated with the source MAC and IP addresses supplied in the packet. + * You may want to disable this if you do not trust LAN peers to have the + * correct addresses, or as a limited approach to attempt to handle + * spoofing. If disabled, lwIP will need to make a new ARP request if + * the peer is not already in the ARP table, adding a little latency. + * The peer *is* in the ARP table if it requested our address before. + * Also notice that this slows down input processing of every IP packet! + */ +#ifndef ETHARP_TRUST_IP_MAC +#define ETHARP_TRUST_IP_MAC 0 +#endif + +/** + * ETHARP_SUPPORT_VLAN==1: support receiving ethernet packets with VLAN header. + * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check. + * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted. + * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted. + * Alternatively, define a function/define ETHARP_VLAN_CHECK_FN(eth_hdr, vlan) + * that returns 1 to accept a packet or 0 to drop a packet. + */ +#ifndef ETHARP_SUPPORT_VLAN +#define ETHARP_SUPPORT_VLAN 0 +#endif + +/** LWIP_ETHERNET==1: enable ethernet support for PPPoE even though ARP + * might be disabled + */ +#ifndef LWIP_ETHERNET +#define LWIP_ETHERNET (LWIP_ARP || PPPOE_SUPPORT) +#endif + +/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure + * alignment of payload after that header. Since the header is 14 bytes long, + * without this padding e.g. addresses in the IP header will not be aligned + * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms. + */ +#ifndef ETH_PAD_SIZE +#define ETH_PAD_SIZE 0 +#endif + +/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table + * entries (using etharp_add_static_entry/etharp_remove_static_entry). + */ +#ifndef ETHARP_SUPPORT_STATIC_ENTRIES +#define ETHARP_SUPPORT_STATIC_ENTRIES 0 +#endif + + +/* + -------------------------------- + ---------- IP options ---------- + -------------------------------- +*/ +/** + * IP_FORWARD==1: Enables the ability to forward IP packets across network + * interfaces. If you are going to run lwIP on a device with only one network + * interface, define this to 0. + */ +#ifndef IP_FORWARD +#define IP_FORWARD 0 +#endif + +/** + * IP_OPTIONS_ALLOWED: Defines the behavior for IP options. + * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. + * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). + */ +#ifndef IP_OPTIONS_ALLOWED +#define IP_OPTIONS_ALLOWED 1 +#endif + +/** + * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that + * this option does not affect outgoing packet sizes, which can be controlled + * via IP_FRAG. + */ +#ifndef IP_REASSEMBLY +#define IP_REASSEMBLY 1 +#endif + +/** + * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note + * that this option does not affect incoming packet sizes, which can be + * controlled via IP_REASSEMBLY. + */ +#ifndef IP_FRAG +#define IP_FRAG 1 +#endif + +/** + * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) + * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived + * in this time, the whole packet is discarded. + */ +#ifndef IP_REASS_MAXAGE +#define IP_REASS_MAXAGE 3 +#endif + +/** + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + */ +#ifndef IP_REASS_MAX_PBUFS +#define IP_REASS_MAX_PBUFS 10 +#endif + +/** + * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP + * fragmentation. Otherwise pbufs are allocated and reference the original + * packet data to be fragmented (or with LWIP_NETIF_TX_SINGLE_PBUF==1, + * new PBUF_RAM pbufs are used for fragments). + * ATTENTION: IP_FRAG_USES_STATIC_BUF==1 may not be used for DMA-enabled MACs! + */ +#ifndef IP_FRAG_USES_STATIC_BUF +#define IP_FRAG_USES_STATIC_BUF 0 +#endif + +/** + * IP_FRAG_MAX_MTU: Assumed max MTU on any interface for IP frag buffer + * (requires IP_FRAG_USES_STATIC_BUF==1) + */ +#if IP_FRAG_USES_STATIC_BUF && !defined(IP_FRAG_MAX_MTU) +#define IP_FRAG_MAX_MTU 1500 +#endif + +/** + * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers. + */ +#ifndef IP_DEFAULT_TTL +#define IP_DEFAULT_TTL 255 +#endif + +/** + * IP_SOF_BROADCAST=1: Use the SOF_BROADCAST field to enable broadcast + * filter per pcb on udp and raw send operations. To enable broadcast filter + * on recv operations, you also have to set IP_SOF_BROADCAST_RECV=1. + */ +#ifndef IP_SOF_BROADCAST +#define IP_SOF_BROADCAST 0 +#endif + +/** + * IP_SOF_BROADCAST_RECV (requires IP_SOF_BROADCAST=1) enable the broadcast + * filter on recv operations. + */ +#ifndef IP_SOF_BROADCAST_RECV +#define IP_SOF_BROADCAST_RECV 0 +#endif + +/** + * IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1: allow ip_forward() to send packets back + * out on the netif where it was received. This should only be used for + * wireless networks. + * ATTENTION: When this is 1, make sure your netif driver correctly marks incoming + * link-layer-broadcast/multicast packets as such using the corresponding pbuf flags! + */ +#ifndef IP_FORWARD_ALLOW_TX_ON_RX_NETIF +#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0 +#endif + +/** + * LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first + * local TCP/UDP pcb (default==0). This can prevent creating predictable port + * numbers after booting a device. + */ +#ifndef LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0 +#endif + +/* + ---------------------------------- + ---------- ICMP options ---------- + ---------------------------------- +*/ +/** + * LWIP_ICMP==1: Enable ICMP module inside the IP stack. + * Be careful, disable that make your product non-compliant to RFC1122 + */ +#ifndef LWIP_ICMP +#define LWIP_ICMP 1 +#endif + +/** + * ICMP_TTL: Default value for Time-To-Live used by ICMP packets. + */ +#ifndef ICMP_TTL +#define ICMP_TTL (IP_DEFAULT_TTL) +#endif + +/** + * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) + */ +#ifndef LWIP_BROADCAST_PING +#define LWIP_BROADCAST_PING 0 +#endif + +/** + * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only) + */ +#ifndef LWIP_MULTICAST_PING +#define LWIP_MULTICAST_PING 0 +#endif + +/* + --------------------------------- + ---------- RAW options ---------- + --------------------------------- +*/ +/** + * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. + */ +#ifndef LWIP_RAW +#define LWIP_RAW 1 +#endif + +/** + * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. + */ +#ifndef RAW_TTL +#define RAW_TTL (IP_DEFAULT_TTL) +#endif + +/* + ---------------------------------- + ---------- DHCP options ---------- + ---------------------------------- +*/ +/** + * LWIP_DHCP==1: Enable DHCP module. + */ +#ifndef LWIP_DHCP +#define LWIP_DHCP 0 +#endif + +/** + * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address. + */ +#ifndef DHCP_DOES_ARP_CHECK +#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP)) +#endif + +/* + ------------------------------------ + ---------- AUTOIP options ---------- + ------------------------------------ +*/ +/** + * LWIP_AUTOIP==1: Enable AUTOIP module. + */ +#ifndef LWIP_AUTOIP +#define LWIP_AUTOIP 0 +#endif + +/** + * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on + * the same interface at the same time. + */ +#ifndef LWIP_DHCP_AUTOIP_COOP +#define LWIP_DHCP_AUTOIP_COOP 0 +#endif + +/** + * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes + * that should be sent before falling back on AUTOIP. This can be set + * as low as 1 to get an AutoIP address very quickly, but you should + * be prepared to handle a changing IP address when DHCP overrides + * AutoIP. + */ +#ifndef LWIP_DHCP_AUTOIP_COOP_TRIES +#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 +#endif + +/* + ---------------------------------- + ---------- SNMP options ---------- + ---------------------------------- +*/ +/** + * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP + * transport. + */ +#ifndef LWIP_SNMP +#define LWIP_SNMP 0 +#endif + +/** + * SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will + * allow. At least one request buffer is required. + * Does not have to be changed unless external MIBs answer request asynchronously + */ +#ifndef SNMP_CONCURRENT_REQUESTS +#define SNMP_CONCURRENT_REQUESTS 1 +#endif + +/** + * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap + * destination is required + */ +#ifndef SNMP_TRAP_DESTINATIONS +#define SNMP_TRAP_DESTINATIONS 1 +#endif + +/** + * SNMP_PRIVATE_MIB: + * When using a private MIB, you have to create a file 'private_mib.h' that contains + * a 'struct mib_array_node mib_private' which contains your MIB. + */ +#ifndef SNMP_PRIVATE_MIB +#define SNMP_PRIVATE_MIB 0 +#endif + +/** + * Only allow SNMP write actions that are 'safe' (e.g. disabeling netifs is not + * a safe action and disabled when SNMP_SAFE_REQUESTS = 1). + * Unsafe requests are disabled by default! + */ +#ifndef SNMP_SAFE_REQUESTS +#define SNMP_SAFE_REQUESTS 1 +#endif + +/** + * The maximum length of strings used. This affects the size of + * MEMP_SNMP_VALUE elements. + */ +#ifndef SNMP_MAX_OCTET_STRING_LEN +#define SNMP_MAX_OCTET_STRING_LEN 127 +#endif + +/** + * The maximum depth of the SNMP tree. + * With private MIBs enabled, this depends on your MIB! + * This affects the size of MEMP_SNMP_VALUE elements. + */ +#ifndef SNMP_MAX_TREE_DEPTH +#define SNMP_MAX_TREE_DEPTH 15 +#endif + +/** + * The size of the MEMP_SNMP_VALUE elements, normally calculated from + * SNMP_MAX_OCTET_STRING_LEN and SNMP_MAX_TREE_DEPTH. + */ +#ifndef SNMP_MAX_VALUE_SIZE +#define SNMP_MAX_VALUE_SIZE LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN)+1, sizeof(s32_t)*(SNMP_MAX_TREE_DEPTH)) +#endif + +/* + ---------------------------------- + ---------- IGMP options ---------- + ---------------------------------- +*/ +/** + * LWIP_IGMP==1: Turn on IGMP module. + */ +#ifndef LWIP_IGMP +#define LWIP_IGMP 0 +#endif + +/* + ---------------------------------- + ---------- DNS options ----------- + ---------------------------------- +*/ +/** + * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS + * transport. + */ +#ifndef LWIP_DNS +#define LWIP_DNS 0 +#endif + +/** DNS maximum number of entries to maintain locally. */ +#ifndef DNS_TABLE_SIZE +#define DNS_TABLE_SIZE 4 +#endif + +/** DNS maximum host name length supported in the name table. */ +#ifndef DNS_MAX_NAME_LENGTH +#define DNS_MAX_NAME_LENGTH 256 +#endif + +/** The maximum of DNS servers */ +#ifndef DNS_MAX_SERVERS +#define DNS_MAX_SERVERS 2 +#endif + +/** DNS do a name checking between the query and the response. */ +#ifndef DNS_DOES_NAME_CHECK +#define DNS_DOES_NAME_CHECK 1 +#endif + +/** DNS message max. size. Default value is RFC compliant. */ +#ifndef DNS_MSG_SIZE +#define DNS_MSG_SIZE 512 +#endif + +/** DNS_LOCAL_HOSTLIST: Implements a local host-to-address list. If enabled, + * you have to define + * #define DNS_LOCAL_HOSTLIST_INIT {{"host1", 0x123}, {"host2", 0x234}} + * (an array of structs name/address, where address is an u32_t in network + * byte order). + * + * Instead, you can also use an external function: + * #define DNS_LOOKUP_LOCAL_EXTERN(x) extern u32_t my_lookup_function(const char *name) + * that returns the IP address or INADDR_NONE if not found. + */ +#ifndef DNS_LOCAL_HOSTLIST +#define DNS_LOCAL_HOSTLIST 0 +#endif /* DNS_LOCAL_HOSTLIST */ + +/** If this is turned on, the local host-list can be dynamically changed + * at runtime. */ +#ifndef DNS_LOCAL_HOSTLIST_IS_DYNAMIC +#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0 +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + +/* + --------------------------------- + ---------- UDP options ---------- + --------------------------------- +*/ +/** + * LWIP_UDP==1: Turn on UDP. + */ +#ifndef LWIP_UDP +#define LWIP_UDP 1 +#endif + +/** + * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP) + */ +#ifndef LWIP_UDPLITE +#define LWIP_UDPLITE 0 +#endif + +/** + * UDP_TTL: Default Time-To-Live value. + */ +#ifndef UDP_TTL +#define UDP_TTL (IP_DEFAULT_TTL) +#endif + +/** + * LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf. + */ +#ifndef LWIP_NETBUF_RECVINFO +#define LWIP_NETBUF_RECVINFO 0 +#endif + +/* + --------------------------------- + ---------- TCP options ---------- + --------------------------------- +*/ +/** + * LWIP_TCP==1: Turn on TCP. + */ +#ifndef LWIP_TCP +#define LWIP_TCP 1 +#endif + +/** + * TCP_TTL: Default Time-To-Live value. + */ +#ifndef TCP_TTL +#define TCP_TTL (IP_DEFAULT_TTL) +#endif + +/** + * TCP_WND: The size of a TCP window. This must be at least + * (2 * TCP_MSS) for things to work well + */ +#ifndef TCP_WND +#define TCP_WND (4 * TCP_MSS) +#endif + +/** + * TCP_MAXRTX: Maximum number of retransmissions of data segments. + */ +#ifndef TCP_MAXRTX +#define TCP_MAXRTX 12 +#endif + +/** + * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments. + */ +#ifndef TCP_SYNMAXRTX +#define TCP_SYNMAXRTX 6 +#endif + +/** + * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order. + * Define to 0 if your device is low on memory. + */ +#ifndef TCP_QUEUE_OOSEQ +#define TCP_QUEUE_OOSEQ (LWIP_TCP) +#endif + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +#ifndef TCP_MSS +#define TCP_MSS 536 +#endif + +/** + * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really + * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which + * reflects the available reassembly buffer size at the remote host) and the + * largest size permitted by the IP layer" (RFC 1122) + * Setting this to 1 enables code that checks TCP_MSS against the MTU of the + * netif used for a connection and limits the MSS if it would be too big otherwise. + */ +#ifndef TCP_CALCULATE_EFF_SEND_MSS +#define TCP_CALCULATE_EFF_SEND_MSS 1 +#endif + + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * To achieve good performance, this should be at least 2 * TCP_MSS. + */ +#ifndef TCP_SND_BUF +#define TCP_SND_BUF (2 * TCP_MSS) +#endif + +/** + * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least + * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. + */ +#ifndef TCP_SND_QUEUELEN +#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) +#endif + +/** + * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than + * TCP_SND_BUF. It is the amount of space which must be available in the + * TCP snd_buf for select to return writable (combined with TCP_SNDQUEUELOWAT). + */ +#ifndef TCP_SNDLOWAT +#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) +#endif + +/** + * TCP_SNDQUEUELOWAT: TCP writable bufs (pbuf count). This must be less + * than TCP_SND_QUEUELEN. If the number of pbufs queued on a pcb drops below + * this number, select returns writable (combined with TCP_SNDLOWAT). + */ +#ifndef TCP_SNDQUEUELOWAT +#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5) +#endif + +/** + * TCP_OOSEQ_MAX_BYTES: The maximum number of bytes queued on ooseq per pcb. + * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==0. + */ +#ifndef TCP_OOSEQ_MAX_BYTES +#define TCP_OOSEQ_MAX_BYTES 0 +#endif + +/** + * TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs queued on ooseq per pcb. + * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==0. + */ +#ifndef TCP_OOSEQ_MAX_PBUFS +#define TCP_OOSEQ_MAX_PBUFS 0 +#endif + +/** + * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb. + */ +#ifndef TCP_LISTEN_BACKLOG +#define TCP_LISTEN_BACKLOG 0 +#endif + +/** + * The maximum allowed backlog for TCP listen netconns. + * This backlog is used unless another is explicitly specified. + * 0xff is the maximum (u8_t). + */ +#ifndef TCP_DEFAULT_LISTEN_BACKLOG +#define TCP_DEFAULT_LISTEN_BACKLOG 0xff +#endif + +/** + * TCP_OVERSIZE: The maximum number of bytes that tcp_write may + * allocate ahead of time in an attempt to create shorter pbuf chains + * for transmission. The meaningful range is 0 to TCP_MSS. Some + * suggested values are: + * + * 0: Disable oversized allocation. Each tcp_write() allocates a new + pbuf (old behaviour). + * 1: Allocate size-aligned pbufs with minimal excess. Use this if your + * scatter-gather DMA requires aligned fragments. + * 128: Limit the pbuf/memory overhead to 20%. + * TCP_MSS: Try to create unfragmented TCP packets. + * TCP_MSS/4: Try to create 4 fragments or less per TCP packet. + */ +#ifndef TCP_OVERSIZE +#define TCP_OVERSIZE TCP_MSS +#endif + +/** + * LWIP_TCP_TIMESTAMPS==1: support the TCP timestamp option. + */ +#ifndef LWIP_TCP_TIMESTAMPS +#define LWIP_TCP_TIMESTAMPS 0 +#endif + +/** + * TCP_WND_UPDATE_THRESHOLD: difference in window to trigger an + * explicit window update + */ +#ifndef TCP_WND_UPDATE_THRESHOLD +#define TCP_WND_UPDATE_THRESHOLD (TCP_WND / 4) +#endif + +/** + * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1. + * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all + * events (accept, sent, etc) that happen in the system. + * LWIP_CALLBACK_API==1: The PCB callback function is called directly + * for the event. This is the default. + */ +#if !defined(LWIP_EVENT_API) && !defined(LWIP_CALLBACK_API) +#define LWIP_EVENT_API 0 +#define LWIP_CALLBACK_API 1 +#endif + + +/* + ---------------------------------- + ---------- Pbuf options ---------- + ---------------------------------- +*/ +/** + * PBUF_LINK_HLEN: the number of bytes that should be allocated for a + * link level header. The default is 14, the standard value for + * Ethernet. + */ +#ifndef PBUF_LINK_HLEN +#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) +#endif + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accomodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. + */ +#ifndef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN) +#endif + +/* + ------------------------------------------------ + ---------- Network Interfaces options ---------- + ------------------------------------------------ +*/ +/** + * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname + * field. + */ +#ifndef LWIP_NETIF_HOSTNAME +#define LWIP_NETIF_HOSTNAME 0 +#endif + +/** + * LWIP_NETIF_API==1: Support netif api (in netifapi.c) + */ +#ifndef LWIP_NETIF_API +#define LWIP_NETIF_API 0 +#endif + +/** + * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface + * changes its up/down status (i.e., due to DHCP IP acquistion) + */ +#ifndef LWIP_NETIF_STATUS_CALLBACK +#define LWIP_NETIF_STATUS_CALLBACK 0 +#endif + +/** + * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface + * whenever the link changes (i.e., link down) + */ +#ifndef LWIP_NETIF_LINK_CALLBACK +#define LWIP_NETIF_LINK_CALLBACK 0 +#endif + +/** + * LWIP_NETIF_REMOVE_CALLBACK==1: Support a callback function that is called + * when a netif has been removed + */ +#ifndef LWIP_NETIF_REMOVE_CALLBACK +#define LWIP_NETIF_REMOVE_CALLBACK 0 +#endif + +/** + * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table + * indices) in struct netif. TCP and UDP can make use of this to prevent + * scanning the ARP table for every sent packet. While this is faster for big + * ARP tables or many concurrent connections, it might be counterproductive + * if you have a tiny ARP table or if there never are concurrent connections. + */ +#ifndef LWIP_NETIF_HWADDRHINT +#define LWIP_NETIF_HWADDRHINT 0 +#endif + +/** + * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP + * address equal to the netif IP address, looping them back up the stack. + */ +#ifndef LWIP_NETIF_LOOPBACK +#define LWIP_NETIF_LOOPBACK 0 +#endif + +/** + * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback + * sending for each netif (0 = disabled) + */ +#ifndef LWIP_LOOPBACK_MAX_PBUFS +#define LWIP_LOOPBACK_MAX_PBUFS 0 +#endif + +/** + * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in + * the system, as netifs must change how they behave depending on this setting + * for the LWIP_NETIF_LOOPBACK option to work. + * Setting this is needed to avoid reentering non-reentrant functions like + * tcp_input(). + * LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a + * multithreaded environment like tcpip.c. In this case, netif->input() + * is called directly. + * LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. + * The packets are put on a list and netif_poll() must be called in + * the main application loop. + */ +#ifndef LWIP_NETIF_LOOPBACK_MULTITHREADING +#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) +#endif + +/** + * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data + * to be sent into one single pbuf. This is for compatibility with DMA-enabled + * MACs that do not support scatter-gather. + * Beware that this might involve CPU-memcpy before transmitting that would not + * be needed without this flag! Use this only if you need to! + * + * @todo: TCP and IP-frag do not work with this, yet: + */ +#ifndef LWIP_NETIF_TX_SINGLE_PBUF +#define LWIP_NETIF_TX_SINGLE_PBUF 0 +#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ + +/* + ------------------------------------ + ---------- LOOPIF options ---------- + ------------------------------------ +*/ +/** + * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c + */ +#ifndef LWIP_HAVE_LOOPIF +#define LWIP_HAVE_LOOPIF 0 +#endif + +/* + ------------------------------------ + ---------- SLIPIF options ---------- + ------------------------------------ +*/ +/** + * LWIP_HAVE_SLIPIF==1: Support slip interface and slipif.c + */ +#ifndef LWIP_HAVE_SLIPIF +#define LWIP_HAVE_SLIPIF 0 +#endif + +/* + ------------------------------------ + ---------- Thread options ---------- + ------------------------------------ +*/ +/** + * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread. + */ +#ifndef TCPIP_THREAD_NAME +#define TCPIP_THREAD_NAME "tcpip_thread" +#endif + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef TCPIP_THREAD_STACKSIZE +#define TCPIP_THREAD_STACKSIZE 0 +#endif + +/** + * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef TCPIP_THREAD_PRIO +#define TCPIP_THREAD_PRIO 1 +#endif + +/** + * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages + * The queue size value itself is platform-dependent, but is passed to + * sys_mbox_new() when tcpip_init is called. + */ +#ifndef TCPIP_MBOX_SIZE +#define TCPIP_MBOX_SIZE 0 +#endif + +/** + * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread. + */ +#ifndef SLIPIF_THREAD_NAME +#define SLIPIF_THREAD_NAME "slipif_loop" +#endif + +/** + * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef SLIPIF_THREAD_STACKSIZE +#define SLIPIF_THREAD_STACKSIZE 0 +#endif + +/** + * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef SLIPIF_THREAD_PRIO +#define SLIPIF_THREAD_PRIO 1 +#endif + +/** + * PPP_THREAD_NAME: The name assigned to the pppInputThread. + */ +#ifndef PPP_THREAD_NAME +#define PPP_THREAD_NAME "pppInputThread" +#endif + +/** + * PPP_THREAD_STACKSIZE: The stack size used by the pppInputThread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef PPP_THREAD_STACKSIZE +#define PPP_THREAD_STACKSIZE 0 +#endif + +/** + * PPP_THREAD_PRIO: The priority assigned to the pppInputThread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef PPP_THREAD_PRIO +#define PPP_THREAD_PRIO 1 +#endif + +/** + * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread. + */ +#ifndef DEFAULT_THREAD_NAME +#define DEFAULT_THREAD_NAME "lwIP" +#endif + +/** + * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef DEFAULT_THREAD_STACKSIZE +#define DEFAULT_THREAD_STACKSIZE 0 +#endif + +/** + * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread. + * The priority value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef DEFAULT_THREAD_PRIO +#define DEFAULT_THREAD_PRIO 1 +#endif + +/** + * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a + * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed + * to sys_mbox_new() when the recvmbox is created. + */ +#ifndef DEFAULT_RAW_RECVMBOX_SIZE +#define DEFAULT_RAW_RECVMBOX_SIZE 0 +#endif + +/** + * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a + * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed + * to sys_mbox_new() when the recvmbox is created. + */ +#ifndef DEFAULT_UDP_RECVMBOX_SIZE +#define DEFAULT_UDP_RECVMBOX_SIZE 0 +#endif + +/** + * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a + * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed + * to sys_mbox_new() when the recvmbox is created. + */ +#ifndef DEFAULT_TCP_RECVMBOX_SIZE +#define DEFAULT_TCP_RECVMBOX_SIZE 0 +#endif + +/** + * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections. + * The queue size value itself is platform-dependent, but is passed to + * sys_mbox_new() when the acceptmbox is created. + */ +#ifndef DEFAULT_ACCEPTMBOX_SIZE +#define DEFAULT_ACCEPTMBOX_SIZE 0 +#endif + +/* + ---------------------------------------------- + ---------- Sequential layer options ---------- + ---------------------------------------------- +*/ +/** + * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) + * Don't use it if you're not an active lwIP project member + */ +#ifndef LWIP_TCPIP_CORE_LOCKING +#define LWIP_TCPIP_CORE_LOCKING 0 +#endif + +/** + * LWIP_TCPIP_CORE_LOCKING_INPUT: (EXPERIMENTAL!) + * Don't use it if you're not an active lwIP project member + */ +#ifndef LWIP_TCPIP_CORE_LOCKING_INPUT +#define LWIP_TCPIP_CORE_LOCKING_INPUT 0 +#endif + +/** + * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) + */ +#ifndef LWIP_NETCONN +#define LWIP_NETCONN 1 +#endif + +/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout tod create + * timers running in tcpip_thread from another thread. + */ +#ifndef LWIP_TCPIP_TIMEOUT +#define LWIP_TCPIP_TIMEOUT 1 +#endif + +/* + ------------------------------------ + ---------- Socket options ---------- + ------------------------------------ +*/ +/** + * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) + */ +#ifndef LWIP_SOCKET +#define LWIP_SOCKET 1 +#endif + +/** + * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. + * (only used if you use sockets.c) + */ +#ifndef LWIP_COMPAT_SOCKETS +#define LWIP_COMPAT_SOCKETS 1 +#endif + +/** + * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names. + * Disable this option if you use a POSIX operating system that uses the same + * names (read, write & close). (only used if you use sockets.c) + */ +#ifndef LWIP_POSIX_SOCKETS_IO_NAMES +#define LWIP_POSIX_SOCKETS_IO_NAMES 1 +#endif + +/** + * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT + * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set + * in seconds. (does not require sockets.c, and will affect tcp.c) + */ +#ifndef LWIP_TCP_KEEPALIVE +#define LWIP_TCP_KEEPALIVE 0 +#endif + +/** + * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and + * SO_SNDTIMEO processing. + */ +#ifndef LWIP_SO_SNDTIMEO +#define LWIP_SO_SNDTIMEO 0 +#endif + +/** + * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and + * SO_RCVTIMEO processing. + */ +#ifndef LWIP_SO_RCVTIMEO +#define LWIP_SO_RCVTIMEO 0 +#endif + +/** + * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing. + */ +#ifndef LWIP_SO_RCVBUF +#define LWIP_SO_RCVBUF 0 +#endif + +/** + * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize. + */ +#ifndef RECV_BUFSIZE_DEFAULT +#define RECV_BUFSIZE_DEFAULT INT_MAX +#endif + +/** + * SO_REUSE==1: Enable SO_REUSEADDR option. + */ +#ifndef SO_REUSE +#define SO_REUSE 0 +#endif + +/** + * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets + * to all local matches if SO_REUSEADDR is turned on. + * WARNING: Adds a memcpy for every packet if passing to more than one pcb! + */ +#ifndef SO_REUSE_RXTOALL +#define SO_REUSE_RXTOALL 0 +#endif + +/* + ---------------------------------------- + ---------- Statistics options ---------- + ---------------------------------------- +*/ +/** + * LWIP_STATS==1: Enable statistics collection in lwip_stats. + */ +#ifndef LWIP_STATS +#define LWIP_STATS 1 +#endif + +#if LWIP_STATS + +/** + * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions. + */ +#ifndef LWIP_STATS_DISPLAY +#define LWIP_STATS_DISPLAY 0 +#endif + +/** + * LINK_STATS==1: Enable link stats. + */ +#ifndef LINK_STATS +#define LINK_STATS 1 +#endif + +/** + * ETHARP_STATS==1: Enable etharp stats. + */ +#ifndef ETHARP_STATS +#define ETHARP_STATS (LWIP_ARP) +#endif + +/** + * IP_STATS==1: Enable IP stats. + */ +#ifndef IP_STATS +#define IP_STATS 1 +#endif + +/** + * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is + * on if using either frag or reass. + */ +#ifndef IPFRAG_STATS +#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG) +#endif + +/** + * ICMP_STATS==1: Enable ICMP stats. + */ +#ifndef ICMP_STATS +#define ICMP_STATS 1 +#endif + +/** + * IGMP_STATS==1: Enable IGMP stats. + */ +#ifndef IGMP_STATS +#define IGMP_STATS (LWIP_IGMP) +#endif + +/** + * UDP_STATS==1: Enable UDP stats. Default is on if + * UDP enabled, otherwise off. + */ +#ifndef UDP_STATS +#define UDP_STATS (LWIP_UDP) +#endif + +/** + * TCP_STATS==1: Enable TCP stats. Default is on if TCP + * enabled, otherwise off. + */ +#ifndef TCP_STATS +#define TCP_STATS (LWIP_TCP) +#endif + +/** + * MEM_STATS==1: Enable mem.c stats. + */ +#ifndef MEM_STATS +#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0)) +#endif + +/** + * MEMP_STATS==1: Enable memp.c pool stats. + */ +#ifndef MEMP_STATS +#define MEMP_STATS (MEMP_MEM_MALLOC == 0) +#endif + +/** + * SYS_STATS==1: Enable system stats (sem and mbox counts, etc). + */ +#ifndef SYS_STATS +#define SYS_STATS (NO_SYS == 0) +#endif + +#else + +#define LINK_STATS 0 +#define IP_STATS 0 +#define IPFRAG_STATS 0 +#define ICMP_STATS 0 +#define IGMP_STATS 0 +#define UDP_STATS 0 +#define TCP_STATS 0 +#define MEM_STATS 0 +#define MEMP_STATS 0 +#define SYS_STATS 0 +#define LWIP_STATS_DISPLAY 0 + +#endif /* LWIP_STATS */ + +/* + --------------------------------- + ---------- PPP options ---------- + --------------------------------- +*/ +/** + * PPP_SUPPORT==1: Enable PPP. + */ +#ifndef PPP_SUPPORT +#define PPP_SUPPORT 0 +#endif + +/** + * PPPOE_SUPPORT==1: Enable PPP Over Ethernet + */ +#ifndef PPPOE_SUPPORT +#define PPPOE_SUPPORT 0 +#endif + +/** + * PPPOS_SUPPORT==1: Enable PPP Over Serial + */ +#ifndef PPPOS_SUPPORT +#define PPPOS_SUPPORT PPP_SUPPORT +#endif + +#if PPP_SUPPORT + +/** + * NUM_PPP: Max PPP sessions. + */ +#ifndef NUM_PPP +#define NUM_PPP 1 +#endif + +/** + * PAP_SUPPORT==1: Support PAP. + */ +#ifndef PAP_SUPPORT +#define PAP_SUPPORT 0 +#endif + +/** + * CHAP_SUPPORT==1: Support CHAP. + */ +#ifndef CHAP_SUPPORT +#define CHAP_SUPPORT 0 +#endif + +/** + * MSCHAP_SUPPORT==1: Support MSCHAP. CURRENTLY NOT SUPPORTED! DO NOT SET! + */ +#ifndef MSCHAP_SUPPORT +#define MSCHAP_SUPPORT 0 +#endif + +/** + * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET! + */ +#ifndef CBCP_SUPPORT +#define CBCP_SUPPORT 0 +#endif + +/** + * CCP_SUPPORT==1: Support CCP. CURRENTLY NOT SUPPORTED! DO NOT SET! + */ +#ifndef CCP_SUPPORT +#define CCP_SUPPORT 0 +#endif + +/** + * VJ_SUPPORT==1: Support VJ header compression. + */ +#ifndef VJ_SUPPORT +#define VJ_SUPPORT 0 +#endif + +/** + * MD5_SUPPORT==1: Support MD5 (see also CHAP). + */ +#ifndef MD5_SUPPORT +#define MD5_SUPPORT 0 +#endif + +/* + * Timeouts + */ +#ifndef FSM_DEFTIMEOUT +#define FSM_DEFTIMEOUT 6 /* Timeout time in seconds */ +#endif + +#ifndef FSM_DEFMAXTERMREQS +#define FSM_DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ +#endif + +#ifndef FSM_DEFMAXCONFREQS +#define FSM_DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ +#endif + +#ifndef FSM_DEFMAXNAKLOOPS +#define FSM_DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */ +#endif + +#ifndef UPAP_DEFTIMEOUT +#define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */ +#endif + +#ifndef UPAP_DEFREQTIME +#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ +#endif + +#ifndef CHAP_DEFTIMEOUT +#define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */ +#endif + +#ifndef CHAP_DEFTRANSMITS +#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ +#endif + +/* Interval in seconds between keepalive echo requests, 0 to disable. */ +#ifndef LCP_ECHOINTERVAL +#define LCP_ECHOINTERVAL 0 +#endif + +/* Number of unanswered echo requests before failure. */ +#ifndef LCP_MAXECHOFAILS +#define LCP_MAXECHOFAILS 3 +#endif + +/* Max Xmit idle time (in jiffies) before resend flag char. */ +#ifndef PPP_MAXIDLEFLAG +#define PPP_MAXIDLEFLAG 100 +#endif + +/* + * Packet sizes + * + * Note - lcp shouldn't be allowed to negotiate stuff outside these + * limits. See lcp.h in the pppd directory. + * (XXX - these constants should simply be shared by lcp.c instead + * of living in lcp.h) + */ +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#ifndef PPP_MAXMTU +/* #define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) */ +#define PPP_MAXMTU 1500 /* Largest MTU we allow */ +#endif +#define PPP_MINMTU 64 +#define PPP_MRU 1500 /* default MRU = max length of info field */ +#define PPP_MAXMRU 1500 /* Largest MRU we allow */ +#ifndef PPP_DEFMRU +#define PPP_DEFMRU 296 /* Try for this */ +#endif +#define PPP_MINMRU 128 /* No MRUs below this */ + +#ifndef MAXNAMELEN +#define MAXNAMELEN 256 /* max length of hostname or name for auth */ +#endif +#ifndef MAXSECRETLEN +#define MAXSECRETLEN 256 /* max length of password or secret */ +#endif + +#endif /* PPP_SUPPORT */ + +/* + -------------------------------------- + ---------- Checksum options ---------- + -------------------------------------- +*/ +/** + * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets. + */ +#ifndef CHECKSUM_GEN_IP +#define CHECKSUM_GEN_IP 1 +#endif + +/** + * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets. + */ +#ifndef CHECKSUM_GEN_UDP +#define CHECKSUM_GEN_UDP 1 +#endif + +/** + * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets. + */ +#ifndef CHECKSUM_GEN_TCP +#define CHECKSUM_GEN_TCP 1 +#endif + +/** + * CHECKSUM_GEN_ICMP==1: Generate checksums in software for outgoing ICMP packets. + */ +#ifndef CHECKSUM_GEN_ICMP +#define CHECKSUM_GEN_ICMP 1 +#endif + +/** + * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. + */ +#ifndef CHECKSUM_CHECK_IP +#define CHECKSUM_CHECK_IP 1 +#endif + +/** + * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets. + */ +#ifndef CHECKSUM_CHECK_UDP +#define CHECKSUM_CHECK_UDP 1 +#endif + +/** + * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets. + */ +#ifndef CHECKSUM_CHECK_TCP +#define CHECKSUM_CHECK_TCP 1 +#endif + +/** + * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from + * application buffers to pbufs. + */ +#ifndef LWIP_CHECKSUM_ON_COPY +#define LWIP_CHECKSUM_ON_COPY 0 +#endif + +/* + --------------------------------------- + ---------- Hook options --------------- + --------------------------------------- +*/ + +/* Hooks are undefined by default, define them to a function if you need them. */ + +/** + * LWIP_HOOK_IP4_INPUT(pbuf, input_netif): + * - called from ip_input() (IPv4) + * - pbuf: received struct pbuf passed to ip_input() + * - input_netif: struct netif on which the packet has been received + * Return values: + * - 0: Hook has not consumed the packet, packet is processed as normal + * - != 0: Hook has consumed the packet. + * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook + * (i.e. free it when done). + */ + +/** + * LWIP_HOOK_IP4_ROUTE(dest): + * - called from ip_route() (IPv4) + * - dest: destination IPv4 address + * Returns the destination netif or NULL if no destination netif is found. In + * that case, ip_route() continues as normal. + */ + +/* + --------------------------------------- + ---------- Debugging options ---------- + --------------------------------------- +*/ +/** + * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is + * compared against this value. If it is smaller, then debugging + * messages are written. + */ +#ifndef LWIP_DBG_MIN_LEVEL +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#endif + +/** + * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable + * debug messages of certain types. + */ +#ifndef LWIP_DBG_TYPES_ON +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#endif + +/** + * ETHARP_DEBUG: Enable debugging in etharp.c. + */ +#ifndef ETHARP_DEBUG +#define ETHARP_DEBUG LWIP_DBG_OFF +#endif + +/** + * NETIF_DEBUG: Enable debugging in netif.c. + */ +#ifndef NETIF_DEBUG +#define NETIF_DEBUG LWIP_DBG_OFF +#endif + +/** + * PBUF_DEBUG: Enable debugging in pbuf.c. + */ +#ifndef PBUF_DEBUG +#define PBUF_DEBUG LWIP_DBG_OFF +#endif + +/** + * API_LIB_DEBUG: Enable debugging in api_lib.c. + */ +#ifndef API_LIB_DEBUG +#define API_LIB_DEBUG LWIP_DBG_OFF +#endif + +/** + * API_MSG_DEBUG: Enable debugging in api_msg.c. + */ +#ifndef API_MSG_DEBUG +#define API_MSG_DEBUG LWIP_DBG_OFF +#endif + +/** + * SOCKETS_DEBUG: Enable debugging in sockets.c. + */ +#ifndef SOCKETS_DEBUG +#define SOCKETS_DEBUG LWIP_DBG_OFF +#endif + +/** + * ICMP_DEBUG: Enable debugging in icmp.c. + */ +#ifndef ICMP_DEBUG +#define ICMP_DEBUG LWIP_DBG_OFF +#endif + +/** + * IGMP_DEBUG: Enable debugging in igmp.c. + */ +#ifndef IGMP_DEBUG +#define IGMP_DEBUG LWIP_DBG_OFF +#endif + +/** + * INET_DEBUG: Enable debugging in inet.c. + */ +#ifndef INET_DEBUG +#define INET_DEBUG LWIP_DBG_OFF +#endif + +/** + * IP_DEBUG: Enable debugging for IP. + */ +#ifndef IP_DEBUG +#define IP_DEBUG LWIP_DBG_OFF +#endif + +/** + * IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass. + */ +#ifndef IP_REASS_DEBUG +#define IP_REASS_DEBUG LWIP_DBG_OFF +#endif + +/** + * RAW_DEBUG: Enable debugging in raw.c. + */ +#ifndef RAW_DEBUG +#define RAW_DEBUG LWIP_DBG_OFF +#endif + +/** + * MEM_DEBUG: Enable debugging in mem.c. + */ +#ifndef MEM_DEBUG +#define MEM_DEBUG LWIP_DBG_OFF +#endif + +/** + * MEMP_DEBUG: Enable debugging in memp.c. + */ +#ifndef MEMP_DEBUG +#define MEMP_DEBUG LWIP_DBG_OFF +#endif + +/** + * SYS_DEBUG: Enable debugging in sys.c. + */ +#ifndef SYS_DEBUG +#define SYS_DEBUG LWIP_DBG_OFF +#endif + +/** + * TIMERS_DEBUG: Enable debugging in timers.c. + */ +#ifndef TIMERS_DEBUG +#define TIMERS_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_DEBUG: Enable debugging for TCP. + */ +#ifndef TCP_DEBUG +#define TCP_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug. + */ +#ifndef TCP_INPUT_DEBUG +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit. + */ +#ifndef TCP_FR_DEBUG +#define TCP_FR_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_RTO_DEBUG: Enable debugging in TCP for retransmit + * timeout. + */ +#ifndef TCP_RTO_DEBUG +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_CWND_DEBUG: Enable debugging for TCP congestion window. + */ +#ifndef TCP_CWND_DEBUG +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating. + */ +#ifndef TCP_WND_DEBUG +#define TCP_WND_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions. + */ +#ifndef TCP_OUTPUT_DEBUG +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_RST_DEBUG: Enable debugging for TCP with the RST message. + */ +#ifndef TCP_RST_DEBUG +#define TCP_RST_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths. + */ +#ifndef TCP_QLEN_DEBUG +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#endif + +/** + * UDP_DEBUG: Enable debugging in UDP. + */ +#ifndef UDP_DEBUG +#define UDP_DEBUG LWIP_DBG_OFF +#endif + +/** + * TCPIP_DEBUG: Enable debugging in tcpip.c. + */ +#ifndef TCPIP_DEBUG +#define TCPIP_DEBUG LWIP_DBG_OFF +#endif + +/** + * PPP_DEBUG: Enable debugging for PPP. + */ +#ifndef PPP_DEBUG +#define PPP_DEBUG LWIP_DBG_OFF +#endif + +/** + * SLIP_DEBUG: Enable debugging in slipif.c. + */ +#ifndef SLIP_DEBUG +#define SLIP_DEBUG LWIP_DBG_OFF +#endif + +/** + * DHCP_DEBUG: Enable debugging in dhcp.c. + */ +#ifndef DHCP_DEBUG +#define DHCP_DEBUG LWIP_DBG_OFF +#endif + +/** + * AUTOIP_DEBUG: Enable debugging in autoip.c. + */ +#ifndef AUTOIP_DEBUG +#define AUTOIP_DEBUG LWIP_DBG_OFF +#endif + +/** + * SNMP_MSG_DEBUG: Enable debugging for SNMP messages. + */ +#ifndef SNMP_MSG_DEBUG +#define SNMP_MSG_DEBUG LWIP_DBG_OFF +#endif + +/** + * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs. + */ +#ifndef SNMP_MIB_DEBUG +#define SNMP_MIB_DEBUG LWIP_DBG_OFF +#endif + +/** + * DNS_DEBUG: Enable debugging for DNS. + */ +#ifndef DNS_DEBUG +#define DNS_DEBUG LWIP_DBG_OFF +#endif + +#endif /* __LWIP_OPT_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/pbuf.h b/user/mpy/lib/lwip/src/include/lwip/pbuf.h new file mode 100644 index 0000000..99d5443 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/pbuf.h @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#ifndef __LWIP_PBUF_H__ +#define __LWIP_PBUF_H__ + +#include "lwip/opt.h" +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Currently, the pbuf_custom code is only needed for one specific configuration + * of IP_FRAG */ +#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) + +#define PBUF_TRANSPORT_HLEN 20 +#define PBUF_IP_HLEN 20 + +typedef enum { + PBUF_TRANSPORT, + PBUF_IP, + PBUF_LINK, + PBUF_RAW +} pbuf_layer; + +typedef enum { + PBUF_RAM, /* pbuf data is stored in RAM */ + PBUF_ROM, /* pbuf data is stored in ROM */ + PBUF_REF, /* pbuf comes from the pbuf pool */ + PBUF_POOL /* pbuf payload refers to RAM */ +} pbuf_type; + + +/** indicates this packet's data should be immediately passed to the application */ +#define PBUF_FLAG_PUSH 0x01U +/** indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a + a pbuf differently */ +#define PBUF_FLAG_IS_CUSTOM 0x02U +/** indicates this pbuf is UDP multicast to be looped back */ +#define PBUF_FLAG_MCASTLOOP 0x04U +/** indicates this pbuf was received as link-level broadcast */ +#define PBUF_FLAG_LLBCAST 0x08U +/** indicates this pbuf was received as link-level multicast */ +#define PBUF_FLAG_LLMCAST 0x10U +/** indicates this pbuf includes a TCP FIN flag */ +#define PBUF_FLAG_TCP_FIN 0x20U + +struct pbuf { + /** next pbuf in singly linked pbuf chain */ + struct pbuf *next; + + /** pointer to the actual data in the buffer */ + void *payload; + + /** + * total length of this buffer and all next buffers in chain + * belonging to the same packet. + * + * For non-queue packet chains this is the invariant: + * p->tot_len == p->len + (p->next? p->next->tot_len: 0) + */ + u16_t tot_len; + + /** length of this buffer */ + u16_t len; + + /** pbuf_type as u8_t instead of enum to save space */ + u8_t /*pbuf_type*/ type; + + /** misc flags */ + u8_t flags; + + /** + * the reference count always equals the number of pointers + * that refer to this pbuf. This can be pointers from an application, + * the stack itself, or pbuf->next pointers from a chain. + */ + u16_t ref; +}; + +#if LWIP_SUPPORT_CUSTOM_PBUF +/** Prototype for a function to free a custom pbuf */ +typedef void (*pbuf_free_custom_fn)(struct pbuf *p); + +/** A custom pbuf: like a pbuf, but following a function pointer to free it. */ +struct pbuf_custom { + /** The actual pbuf */ + struct pbuf pbuf; + /** This function is called when pbuf_free deallocates this pbuf(_custom) */ + pbuf_free_custom_fn custom_free_function; +}; +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ + +#if LWIP_TCP && TCP_QUEUE_OOSEQ +/** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */ +#ifndef PBUF_POOL_FREE_OOSEQ +#define PBUF_POOL_FREE_OOSEQ 1 +#endif /* PBUF_POOL_FREE_OOSEQ */ +#if NO_SYS && PBUF_POOL_FREE_OOSEQ +extern volatile u8_t pbuf_free_ooseq_pending; +void pbuf_free_ooseq(); +/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() + at regular intervals from main level to check if ooseq pbufs need to be + freed! */ +#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \ + /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \ + ooseq queued pbufs now */ \ + pbuf_free_ooseq(); }}while(0) +#endif /* NO_SYS && PBUF_POOL_FREE_OOSEQ*/ +#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ */ + +/* Initializes the pbuf module. This call is empty for now, but may not be in future. */ +#define pbuf_init() + +struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); +#if LWIP_SUPPORT_CUSTOM_PBUF +struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, + struct pbuf_custom *p, void *payload_mem, + u16_t payload_mem_len); +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ +void pbuf_realloc(struct pbuf *p, u16_t size); +u8_t pbuf_header(struct pbuf *p, s16_t header_size); +void pbuf_ref(struct pbuf *p); +u8_t pbuf_free(struct pbuf *p); +u8_t pbuf_clen(struct pbuf *p); +void pbuf_cat(struct pbuf *head, struct pbuf *tail); +void pbuf_chain(struct pbuf *head, struct pbuf *tail); +struct pbuf *pbuf_dechain(struct pbuf *p); +err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from); +u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset); +err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); +struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); +#if LWIP_CHECKSUM_ON_COPY +err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, + u16_t len, u16_t *chksum); +#endif /* LWIP_CHECKSUM_ON_COPY */ + +u8_t pbuf_get_at(struct pbuf* p, u16_t offset); +u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n); +u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset); +u16_t pbuf_strstr(struct pbuf* p, const char* substr); + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_PBUF_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/raw.h b/user/mpy/lib/lwip/src/include/lwip/raw.h new file mode 100644 index 0000000..17d0a1c --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/raw.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_RAW_H__ +#define __LWIP_RAW_H__ + +#include "lwip/opt.h" + +#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/pbuf.h" +#include "lwip/def.h" +#include "lwip/ip.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct raw_pcb; + +/** Function prototype for raw pcb receive callback functions. + * @param arg user supplied argument (raw_pcb.recv_arg) + * @param pcb the raw_pcb which received data + * @param p the packet buffer that was received + * @param addr the remote IP address from which the packet was received + * @return 1 if the packet was 'eaten' (aka. deleted), + * 0 if the packet lives on + * If returning 1, the callback is responsible for freeing the pbuf + * if it's not used any more. + */ +typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, + ip_addr_t *addr); + +struct raw_pcb { + /* Common members of all PCB types */ + IP_PCB; + + struct raw_pcb *next; + + u8_t protocol; + + /** receive callback function */ + raw_recv_fn recv; + /* user-supplied argument for the recv callback */ + void *recv_arg; +}; + +/* The following functions is the application layer interface to the + RAW code. */ +struct raw_pcb * raw_new (u8_t proto); +void raw_remove (struct raw_pcb *pcb); +err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr); +err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr); + +void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); +err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr); +err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); + +/* The following functions are the lower layer interface to RAW. */ +u8_t raw_input (struct pbuf *p, struct netif *inp); +#define raw_init() /* Compatibility define, not init needed. */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_RAW */ + +#endif /* __LWIP_RAW_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/sio.h b/user/mpy/lib/lwip/src/include/lwip/sio.h new file mode 100644 index 0000000..28ae2f2 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/sio.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + */ + +/* + * This is the interface to the platform specific serial IO module + * It needs to be implemented by those platforms which need SLIP or PPP + */ + +#ifndef __SIO_H__ +#define __SIO_H__ + +#include "lwip/arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* If you want to define sio_fd_t elsewhere or differently, + define this in your cc.h file. */ +#ifndef __sio_fd_t_defined +typedef void * sio_fd_t; +#endif + +/* The following functions can be defined to something else in your cc.h file + or be implemented in your custom sio.c file. */ + +#ifndef sio_open +/** + * Opens a serial device for communication. + * + * @param devnum device number + * @return handle to serial device if successful, NULL otherwise + */ +sio_fd_t sio_open(u8_t devnum); +#endif + +#ifndef sio_send +/** + * Sends a single character to the serial device. + * + * @param c character to send + * @param fd serial device handle + * + * @note This function will block until the character can be sent. + */ +void sio_send(u8_t c, sio_fd_t fd); +#endif + +#ifndef sio_recv +/** + * Receives a single character from the serial device. + * + * @param fd serial device handle + * + * @note This function will block until a character is received. + */ +u8_t sio_recv(sio_fd_t fd); +#endif + +#ifndef sio_read +/** + * Reads from the serial device. + * + * @param fd serial device handle + * @param data pointer to data buffer for receiving + * @param len maximum length (in bytes) of data to receive + * @return number of bytes actually received - may be 0 if aborted by sio_read_abort + * + * @note This function will block until data can be received. The blocking + * can be cancelled by calling sio_read_abort(). + */ +u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); +#endif + +#ifndef sio_tryread +/** + * Tries to read from the serial device. Same as sio_read but returns + * immediately if no data is available and never blocks. + * + * @param fd serial device handle + * @param data pointer to data buffer for receiving + * @param len maximum length (in bytes) of data to receive + * @return number of bytes actually received + */ +u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); +#endif + +#ifndef sio_write +/** + * Writes to the serial device. + * + * @param fd serial device handle + * @param data pointer to data to send + * @param len length (in bytes) of data to send + * @return number of bytes actually sent + * + * @note This function will block until all data can be sent. + */ +u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); +#endif + +#ifndef sio_read_abort +/** + * Aborts a blocking sio_read() call. + * + * @param fd serial device handle + */ +void sio_read_abort(sio_fd_t fd); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __SIO_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp.h b/user/mpy/lib/lwip/src/include/lwip/snmp.h new file mode 100644 index 0000000..2ed043d --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/snmp.h @@ -0,0 +1,367 @@ +/* + * Copyright (c) 2001, 2002 Leon Woestenberg + * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Leon Woestenberg + * + */ +#ifndef __LWIP_SNMP_H__ +#define __LWIP_SNMP_H__ + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "lwip/ip_addr.h" + +struct udp_pcb; +struct netif; + +/** + * @see RFC1213, "MIB-II, 6. Definitions" + */ +enum snmp_ifType { + snmp_ifType_other=1, /* none of the following */ + snmp_ifType_regular1822, + snmp_ifType_hdh1822, + snmp_ifType_ddn_x25, + snmp_ifType_rfc877_x25, + snmp_ifType_ethernet_csmacd, + snmp_ifType_iso88023_csmacd, + snmp_ifType_iso88024_tokenBus, + snmp_ifType_iso88025_tokenRing, + snmp_ifType_iso88026_man, + snmp_ifType_starLan, + snmp_ifType_proteon_10Mbit, + snmp_ifType_proteon_80Mbit, + snmp_ifType_hyperchannel, + snmp_ifType_fddi, + snmp_ifType_lapb, + snmp_ifType_sdlc, + snmp_ifType_ds1, /* T-1 */ + snmp_ifType_e1, /* european equiv. of T-1 */ + snmp_ifType_basicISDN, + snmp_ifType_primaryISDN, /* proprietary serial */ + snmp_ifType_propPointToPointSerial, + snmp_ifType_ppp, + snmp_ifType_softwareLoopback, + snmp_ifType_eon, /* CLNP over IP [11] */ + snmp_ifType_ethernet_3Mbit, + snmp_ifType_nsip, /* XNS over IP */ + snmp_ifType_slip, /* generic SLIP */ + snmp_ifType_ultra, /* ULTRA technologies */ + snmp_ifType_ds3, /* T-3 */ + snmp_ifType_sip, /* SMDS */ + snmp_ifType_frame_relay +}; + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +/** SNMP "sysuptime" Interval */ +#define SNMP_SYSUPTIME_INTERVAL 10 + +/** fixed maximum length for object identifier type */ +#define LWIP_SNMP_OBJ_ID_LEN 32 + +/** internal object identifier representation */ +struct snmp_obj_id +{ + u8_t len; + s32_t id[LWIP_SNMP_OBJ_ID_LEN]; +}; + +/* system */ +void snmp_set_sysdesr(u8_t* str, u8_t* len); +void snmp_set_sysobjid(struct snmp_obj_id *oid); +void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid); +void snmp_inc_sysuptime(void); +void snmp_add_sysuptime(u32_t value); +void snmp_get_sysuptime(u32_t *value); +void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen); +void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen); +void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen); + +/* network interface */ +void snmp_add_ifinoctets(struct netif *ni, u32_t value); +void snmp_inc_ifinucastpkts(struct netif *ni); +void snmp_inc_ifinnucastpkts(struct netif *ni); +void snmp_inc_ifindiscards(struct netif *ni); +void snmp_add_ifoutoctets(struct netif *ni, u32_t value); +void snmp_inc_ifoutucastpkts(struct netif *ni); +void snmp_inc_ifoutnucastpkts(struct netif *ni); +void snmp_inc_ifoutdiscards(struct netif *ni); +void snmp_inc_iflist(void); +void snmp_dec_iflist(void); + +/* ARP (for atTable and ipNetToMediaTable) */ +void snmp_insert_arpidx_tree(struct netif *ni, ip_addr_t *ip); +void snmp_delete_arpidx_tree(struct netif *ni, ip_addr_t *ip); + +/* IP */ +void snmp_inc_ipinreceives(void); +void snmp_inc_ipinhdrerrors(void); +void snmp_inc_ipinaddrerrors(void); +void snmp_inc_ipforwdatagrams(void); +void snmp_inc_ipinunknownprotos(void); +void snmp_inc_ipindiscards(void); +void snmp_inc_ipindelivers(void); +void snmp_inc_ipoutrequests(void); +void snmp_inc_ipoutdiscards(void); +void snmp_inc_ipoutnoroutes(void); +void snmp_inc_ipreasmreqds(void); +void snmp_inc_ipreasmoks(void); +void snmp_inc_ipreasmfails(void); +void snmp_inc_ipfragoks(void); +void snmp_inc_ipfragfails(void); +void snmp_inc_ipfragcreates(void); +void snmp_inc_iproutingdiscards(void); +void snmp_insert_ipaddridx_tree(struct netif *ni); +void snmp_delete_ipaddridx_tree(struct netif *ni); +void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni); +void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni); + +/* ICMP */ +void snmp_inc_icmpinmsgs(void); +void snmp_inc_icmpinerrors(void); +void snmp_inc_icmpindestunreachs(void); +void snmp_inc_icmpintimeexcds(void); +void snmp_inc_icmpinparmprobs(void); +void snmp_inc_icmpinsrcquenchs(void); +void snmp_inc_icmpinredirects(void); +void snmp_inc_icmpinechos(void); +void snmp_inc_icmpinechoreps(void); +void snmp_inc_icmpintimestamps(void); +void snmp_inc_icmpintimestampreps(void); +void snmp_inc_icmpinaddrmasks(void); +void snmp_inc_icmpinaddrmaskreps(void); +void snmp_inc_icmpoutmsgs(void); +void snmp_inc_icmpouterrors(void); +void snmp_inc_icmpoutdestunreachs(void); +void snmp_inc_icmpouttimeexcds(void); +void snmp_inc_icmpoutparmprobs(void); +void snmp_inc_icmpoutsrcquenchs(void); +void snmp_inc_icmpoutredirects(void); +void snmp_inc_icmpoutechos(void); +void snmp_inc_icmpoutechoreps(void); +void snmp_inc_icmpouttimestamps(void); +void snmp_inc_icmpouttimestampreps(void); +void snmp_inc_icmpoutaddrmasks(void); +void snmp_inc_icmpoutaddrmaskreps(void); + +/* TCP */ +void snmp_inc_tcpactiveopens(void); +void snmp_inc_tcppassiveopens(void); +void snmp_inc_tcpattemptfails(void); +void snmp_inc_tcpestabresets(void); +void snmp_inc_tcpinsegs(void); +void snmp_inc_tcpoutsegs(void); +void snmp_inc_tcpretranssegs(void); +void snmp_inc_tcpinerrs(void); +void snmp_inc_tcpoutrsts(void); + +/* UDP */ +void snmp_inc_udpindatagrams(void); +void snmp_inc_udpnoports(void); +void snmp_inc_udpinerrors(void); +void snmp_inc_udpoutdatagrams(void); +void snmp_insert_udpidx_tree(struct udp_pcb *pcb); +void snmp_delete_udpidx_tree(struct udp_pcb *pcb); + +/* SNMP */ +void snmp_inc_snmpinpkts(void); +void snmp_inc_snmpoutpkts(void); +void snmp_inc_snmpinbadversions(void); +void snmp_inc_snmpinbadcommunitynames(void); +void snmp_inc_snmpinbadcommunityuses(void); +void snmp_inc_snmpinasnparseerrs(void); +void snmp_inc_snmpintoobigs(void); +void snmp_inc_snmpinnosuchnames(void); +void snmp_inc_snmpinbadvalues(void); +void snmp_inc_snmpinreadonlys(void); +void snmp_inc_snmpingenerrs(void); +void snmp_add_snmpintotalreqvars(u8_t value); +void snmp_add_snmpintotalsetvars(u8_t value); +void snmp_inc_snmpingetrequests(void); +void snmp_inc_snmpingetnexts(void); +void snmp_inc_snmpinsetrequests(void); +void snmp_inc_snmpingetresponses(void); +void snmp_inc_snmpintraps(void); +void snmp_inc_snmpouttoobigs(void); +void snmp_inc_snmpoutnosuchnames(void); +void snmp_inc_snmpoutbadvalues(void); +void snmp_inc_snmpoutgenerrs(void); +void snmp_inc_snmpoutgetrequests(void); +void snmp_inc_snmpoutgetnexts(void); +void snmp_inc_snmpoutsetrequests(void); +void snmp_inc_snmpoutgetresponses(void); +void snmp_inc_snmpouttraps(void); +void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid); +void snmp_set_snmpenableauthentraps(u8_t *value); +void snmp_get_snmpenableauthentraps(u8_t *value); + +/* LWIP_SNMP support not available */ +/* define everything to be empty */ +#else + +/* system */ +#define snmp_set_sysdesr(str, len) +#define snmp_set_sysobjid(oid); +#define snmp_get_sysobjid_ptr(oid) +#define snmp_inc_sysuptime() +#define snmp_add_sysuptime(value) +#define snmp_get_sysuptime(value) +#define snmp_set_syscontact(ocstr, ocstrlen); +#define snmp_set_sysname(ocstr, ocstrlen); +#define snmp_set_syslocation(ocstr, ocstrlen); + +/* network interface */ +#define snmp_add_ifinoctets(ni,value) +#define snmp_inc_ifinucastpkts(ni) +#define snmp_inc_ifinnucastpkts(ni) +#define snmp_inc_ifindiscards(ni) +#define snmp_add_ifoutoctets(ni,value) +#define snmp_inc_ifoutucastpkts(ni) +#define snmp_inc_ifoutnucastpkts(ni) +#define snmp_inc_ifoutdiscards(ni) +#define snmp_inc_iflist() +#define snmp_dec_iflist() + +/* ARP */ +#define snmp_insert_arpidx_tree(ni,ip) +#define snmp_delete_arpidx_tree(ni,ip) + +/* IP */ +#define snmp_inc_ipinreceives() +#define snmp_inc_ipinhdrerrors() +#define snmp_inc_ipinaddrerrors() +#define snmp_inc_ipforwdatagrams() +#define snmp_inc_ipinunknownprotos() +#define snmp_inc_ipindiscards() +#define snmp_inc_ipindelivers() +#define snmp_inc_ipoutrequests() +#define snmp_inc_ipoutdiscards() +#define snmp_inc_ipoutnoroutes() +#define snmp_inc_ipreasmreqds() +#define snmp_inc_ipreasmoks() +#define snmp_inc_ipreasmfails() +#define snmp_inc_ipfragoks() +#define snmp_inc_ipfragfails() +#define snmp_inc_ipfragcreates() +#define snmp_inc_iproutingdiscards() +#define snmp_insert_ipaddridx_tree(ni) +#define snmp_delete_ipaddridx_tree(ni) +#define snmp_insert_iprteidx_tree(dflt, ni) +#define snmp_delete_iprteidx_tree(dflt, ni) + +/* ICMP */ +#define snmp_inc_icmpinmsgs() +#define snmp_inc_icmpinerrors() +#define snmp_inc_icmpindestunreachs() +#define snmp_inc_icmpintimeexcds() +#define snmp_inc_icmpinparmprobs() +#define snmp_inc_icmpinsrcquenchs() +#define snmp_inc_icmpinredirects() +#define snmp_inc_icmpinechos() +#define snmp_inc_icmpinechoreps() +#define snmp_inc_icmpintimestamps() +#define snmp_inc_icmpintimestampreps() +#define snmp_inc_icmpinaddrmasks() +#define snmp_inc_icmpinaddrmaskreps() +#define snmp_inc_icmpoutmsgs() +#define snmp_inc_icmpouterrors() +#define snmp_inc_icmpoutdestunreachs() +#define snmp_inc_icmpouttimeexcds() +#define snmp_inc_icmpoutparmprobs() +#define snmp_inc_icmpoutsrcquenchs() +#define snmp_inc_icmpoutredirects() +#define snmp_inc_icmpoutechos() +#define snmp_inc_icmpoutechoreps() +#define snmp_inc_icmpouttimestamps() +#define snmp_inc_icmpouttimestampreps() +#define snmp_inc_icmpoutaddrmasks() +#define snmp_inc_icmpoutaddrmaskreps() +/* TCP */ +#define snmp_inc_tcpactiveopens() +#define snmp_inc_tcppassiveopens() +#define snmp_inc_tcpattemptfails() +#define snmp_inc_tcpestabresets() +#define snmp_inc_tcpinsegs() +#define snmp_inc_tcpoutsegs() +#define snmp_inc_tcpretranssegs() +#define snmp_inc_tcpinerrs() +#define snmp_inc_tcpoutrsts() + +/* UDP */ +#define snmp_inc_udpindatagrams() +#define snmp_inc_udpnoports() +#define snmp_inc_udpinerrors() +#define snmp_inc_udpoutdatagrams() +#define snmp_insert_udpidx_tree(pcb) +#define snmp_delete_udpidx_tree(pcb) + +/* SNMP */ +#define snmp_inc_snmpinpkts() +#define snmp_inc_snmpoutpkts() +#define snmp_inc_snmpinbadversions() +#define snmp_inc_snmpinbadcommunitynames() +#define snmp_inc_snmpinbadcommunityuses() +#define snmp_inc_snmpinasnparseerrs() +#define snmp_inc_snmpintoobigs() +#define snmp_inc_snmpinnosuchnames() +#define snmp_inc_snmpinbadvalues() +#define snmp_inc_snmpinreadonlys() +#define snmp_inc_snmpingenerrs() +#define snmp_add_snmpintotalreqvars(value) +#define snmp_add_snmpintotalsetvars(value) +#define snmp_inc_snmpingetrequests() +#define snmp_inc_snmpingetnexts() +#define snmp_inc_snmpinsetrequests() +#define snmp_inc_snmpingetresponses() +#define snmp_inc_snmpintraps() +#define snmp_inc_snmpouttoobigs() +#define snmp_inc_snmpoutnosuchnames() +#define snmp_inc_snmpoutbadvalues() +#define snmp_inc_snmpoutgenerrs() +#define snmp_inc_snmpoutgetrequests() +#define snmp_inc_snmpoutgetnexts() +#define snmp_inc_snmpoutsetrequests() +#define snmp_inc_snmpoutgetresponses() +#define snmp_inc_snmpouttraps() +#define snmp_get_snmpgrpid_ptr(oid) +#define snmp_set_snmpenableauthentraps(value) +#define snmp_get_snmpenableauthentraps(value) + +#endif /* LWIP_SNMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_SNMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h b/user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h new file mode 100644 index 0000000..605fa3f --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h @@ -0,0 +1,101 @@ +/** + * @file + * Abstract Syntax Notation One (ISO 8824, 8825) codec. + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#ifndef __LWIP_SNMP_ASN1_H__ +#define __LWIP_SNMP_ASN1_H__ + +#include "lwip/opt.h" +#include "lwip/err.h" +#include "lwip/pbuf.h" +#include "lwip/snmp.h" + +#if LWIP_SNMP + +#ifdef __cplusplus +extern "C" { +#endif + +#define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ +#define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ +#define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ + +#define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ +#define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ + +/* universal tags */ +#define SNMP_ASN1_INTEG 2 +#define SNMP_ASN1_OC_STR 4 +#define SNMP_ASN1_NUL 5 +#define SNMP_ASN1_OBJ_ID 6 +#define SNMP_ASN1_SEQ 16 + +/* application specific (SNMP) tags */ +#define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ +#define SNMP_ASN1_COUNTER 1 /* u32_t */ +#define SNMP_ASN1_GAUGE 2 /* u32_t */ +#define SNMP_ASN1_TIMETICKS 3 /* u32_t */ +#define SNMP_ASN1_OPAQUE 4 /* octet string */ + +/* context specific (SNMP) tags */ +#define SNMP_ASN1_PDU_GET_REQ 0 +#define SNMP_ASN1_PDU_GET_NEXT_REQ 1 +#define SNMP_ASN1_PDU_GET_RESP 2 +#define SNMP_ASN1_PDU_SET_REQ 3 +#define SNMP_ASN1_PDU_TRAP 4 + +err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); +err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); +err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); +err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); +err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); +err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); + +void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); +void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); +void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); +void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); +err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); +err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); +err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); +err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); +err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); +err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_SNMP */ + +#endif /* __LWIP_SNMP_ASN1_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp_msg.h b/user/mpy/lib/lwip/src/include/lwip/snmp_msg.h new file mode 100644 index 0000000..1183e3a --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/snmp_msg.h @@ -0,0 +1,315 @@ +/** + * @file + * SNMP Agent message handling structures. + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#ifndef __LWIP_SNMP_MSG_H__ +#define __LWIP_SNMP_MSG_H__ + +#include "lwip/opt.h" +#include "lwip/snmp.h" +#include "lwip/snmp_structs.h" +#include "lwip/ip_addr.h" +#include "lwip/err.h" + +#if LWIP_SNMP + +#if SNMP_PRIVATE_MIB +/* When using a private MIB, you have to create a file 'private_mib.h' that contains + * a 'struct mib_array_node mib_private' which contains your MIB. */ +#include "private_mib.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* The listen port of the SNMP agent. Clients have to make their requests to + this port. Most standard clients won't work if you change this! */ +#ifndef SNMP_IN_PORT +#define SNMP_IN_PORT 161 +#endif +/* The remote port the SNMP agent sends traps to. Most standard trap sinks won't + work if you change this! */ +#ifndef SNMP_TRAP_PORT +#define SNMP_TRAP_PORT 162 +#endif + +#define SNMP_ES_NOERROR 0 +#define SNMP_ES_TOOBIG 1 +#define SNMP_ES_NOSUCHNAME 2 +#define SNMP_ES_BADVALUE 3 +#define SNMP_ES_READONLY 4 +#define SNMP_ES_GENERROR 5 + +#define SNMP_GENTRAP_COLDSTART 0 +#define SNMP_GENTRAP_WARMSTART 1 +#define SNMP_GENTRAP_AUTHFAIL 4 +#define SNMP_GENTRAP_ENTERPRISESPC 6 + +struct snmp_varbind +{ + /* next pointer, NULL for last in list */ + struct snmp_varbind *next; + /* previous pointer, NULL for first in list */ + struct snmp_varbind *prev; + + /* object identifier length (in s32_t) */ + u8_t ident_len; + /* object identifier array */ + s32_t *ident; + + /* object value ASN1 type */ + u8_t value_type; + /* object value length (in u8_t) */ + u8_t value_len; + /* object value */ + void *value; + + /* encoding varbind seq length length */ + u8_t seqlenlen; + /* encoding object identifier length length */ + u8_t olenlen; + /* encoding object value length length */ + u8_t vlenlen; + /* encoding varbind seq length */ + u16_t seqlen; + /* encoding object identifier length */ + u16_t olen; + /* encoding object value length */ + u16_t vlen; +}; + +struct snmp_varbind_root +{ + struct snmp_varbind *head; + struct snmp_varbind *tail; + /* number of variable bindings in list */ + u8_t count; + /* encoding varbind-list seq length length */ + u8_t seqlenlen; + /* encoding varbind-list seq length */ + u16_t seqlen; +}; + +/** output response message header length fields */ +struct snmp_resp_header_lengths +{ + /* encoding error-index length length */ + u8_t erridxlenlen; + /* encoding error-status length length */ + u8_t errstatlenlen; + /* encoding request id length length */ + u8_t ridlenlen; + /* encoding pdu length length */ + u8_t pdulenlen; + /* encoding community length length */ + u8_t comlenlen; + /* encoding version length length */ + u8_t verlenlen; + /* encoding sequence length length */ + u8_t seqlenlen; + + /* encoding error-index length */ + u16_t erridxlen; + /* encoding error-status length */ + u16_t errstatlen; + /* encoding request id length */ + u16_t ridlen; + /* encoding pdu length */ + u16_t pdulen; + /* encoding community length */ + u16_t comlen; + /* encoding version length */ + u16_t verlen; + /* encoding sequence length */ + u16_t seqlen; +}; + +/** output response message header length fields */ +struct snmp_trap_header_lengths +{ + /* encoding timestamp length length */ + u8_t tslenlen; + /* encoding specific-trap length length */ + u8_t strplenlen; + /* encoding generic-trap length length */ + u8_t gtrplenlen; + /* encoding agent-addr length length */ + u8_t aaddrlenlen; + /* encoding enterprise-id length length */ + u8_t eidlenlen; + /* encoding pdu length length */ + u8_t pdulenlen; + /* encoding community length length */ + u8_t comlenlen; + /* encoding version length length */ + u8_t verlenlen; + /* encoding sequence length length */ + u8_t seqlenlen; + + /* encoding timestamp length */ + u16_t tslen; + /* encoding specific-trap length */ + u16_t strplen; + /* encoding generic-trap length */ + u16_t gtrplen; + /* encoding agent-addr length */ + u16_t aaddrlen; + /* encoding enterprise-id length */ + u16_t eidlen; + /* encoding pdu length */ + u16_t pdulen; + /* encoding community length */ + u16_t comlen; + /* encoding version length */ + u16_t verlen; + /* encoding sequence length */ + u16_t seqlen; +}; + +/* Accepting new SNMP messages. */ +#define SNMP_MSG_EMPTY 0 +/* Search for matching object for variable binding. */ +#define SNMP_MSG_SEARCH_OBJ 1 +/* Perform SNMP operation on in-memory object. + Pass-through states, for symmetry only. */ +#define SNMP_MSG_INTERNAL_GET_OBJDEF 2 +#define SNMP_MSG_INTERNAL_GET_VALUE 3 +#define SNMP_MSG_INTERNAL_SET_TEST 4 +#define SNMP_MSG_INTERNAL_GET_OBJDEF_S 5 +#define SNMP_MSG_INTERNAL_SET_VALUE 6 +/* Perform SNMP operation on object located externally. + In theory this could be used for building a proxy agent. + Practical use is for an enterprise spc. app. gateway. */ +#define SNMP_MSG_EXTERNAL_GET_OBJDEF 7 +#define SNMP_MSG_EXTERNAL_GET_VALUE 8 +#define SNMP_MSG_EXTERNAL_SET_TEST 9 +#define SNMP_MSG_EXTERNAL_GET_OBJDEF_S 10 +#define SNMP_MSG_EXTERNAL_SET_VALUE 11 + +#define SNMP_COMMUNITY_STR_LEN 64 +struct snmp_msg_pstat +{ + /* lwIP local port (161) binding */ + struct udp_pcb *pcb; + /* source IP address */ + ip_addr_t sip; + /* source UDP port */ + u16_t sp; + /* request type */ + u8_t rt; + /* request ID */ + s32_t rid; + /* error status */ + s32_t error_status; + /* error index */ + s32_t error_index; + /* community name (zero terminated) */ + u8_t community[SNMP_COMMUNITY_STR_LEN + 1]; + /* community string length (exclusive zero term) */ + u8_t com_strlen; + /* one out of MSG_EMPTY, MSG_DEMUX, MSG_INTERNAL, MSG_EXTERNAL_x */ + u8_t state; + /* saved arguments for MSG_EXTERNAL_x */ + struct mib_external_node *ext_mib_node; + struct snmp_name_ptr ext_name_ptr; + struct obj_def ext_object_def; + struct snmp_obj_id ext_oid; + /* index into input variable binding list */ + u8_t vb_idx; + /* ptr into input variable binding list */ + struct snmp_varbind *vb_ptr; + /* list of variable bindings from input */ + struct snmp_varbind_root invb; + /* list of variable bindings to output */ + struct snmp_varbind_root outvb; + /* output response lengths used in ASN encoding */ + struct snmp_resp_header_lengths rhl; +}; + +struct snmp_msg_trap +{ + /* lwIP local port (161) binding */ + struct udp_pcb *pcb; + /* destination IP address in network order */ + ip_addr_t dip; + + /* source enterprise ID (sysObjectID) */ + struct snmp_obj_id *enterprise; + /* source IP address, raw network order format */ + u8_t sip_raw[4]; + /* generic trap code */ + u32_t gen_trap; + /* specific trap code */ + u32_t spc_trap; + /* timestamp */ + u32_t ts; + /* list of variable bindings to output */ + struct snmp_varbind_root outvb; + /* output trap lengths used in ASN encoding */ + struct snmp_trap_header_lengths thl; +}; + +/** Agent Version constant, 0 = v1 oddity */ +extern const s32_t snmp_version; +/** Agent default "public" community string */ +extern const char snmp_publiccommunity[7]; + +extern struct snmp_msg_trap trap_msg; + +/** Agent setup, start listening to port 161. */ +void snmp_init(void); +void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); +void snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst); + +/** Varbind-list functions. */ +struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len); +void snmp_varbind_free(struct snmp_varbind *vb); +void snmp_varbind_list_free(struct snmp_varbind_root *root); +void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb); +struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root); + +/** Handle an internal (recv) or external (private response) event. */ +void snmp_msg_event(u8_t request_id); +err_t snmp_send_response(struct snmp_msg_pstat *m_stat); +err_t snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap); +void snmp_coldstart_trap(void); +void snmp_authfail_trap(void); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_SNMP */ + +#endif /* __LWIP_SNMP_MSG_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp_structs.h b/user/mpy/lib/lwip/src/include/lwip/snmp_structs.h new file mode 100644 index 0000000..0d3b46a --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/snmp_structs.h @@ -0,0 +1,268 @@ +/** + * @file + * Generic MIB tree structures. + * + * @todo namespace prefixes + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + */ + +#ifndef __LWIP_SNMP_STRUCTS_H__ +#define __LWIP_SNMP_STRUCTS_H__ + +#include "lwip/opt.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/snmp.h" + +#if SNMP_PRIVATE_MIB +/* When using a private MIB, you have to create a file 'private_mib.h' that contains + * a 'struct mib_array_node mib_private' which contains your MIB. */ +#include "private_mib.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* MIB object instance */ +#define MIB_OBJECT_NONE 0 +#define MIB_OBJECT_SCALAR 1 +#define MIB_OBJECT_TAB 2 + +/* MIB access types */ +#define MIB_ACCESS_READ 1 +#define MIB_ACCESS_WRITE 2 + +/* MIB object access */ +#define MIB_OBJECT_READ_ONLY MIB_ACCESS_READ +#define MIB_OBJECT_READ_WRITE (MIB_ACCESS_READ | MIB_ACCESS_WRITE) +#define MIB_OBJECT_WRITE_ONLY MIB_ACCESS_WRITE +#define MIB_OBJECT_NOT_ACCESSIBLE 0 + +/** object definition returned by (get_object_def)() */ +struct obj_def +{ + /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */ + u8_t instance; + /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */ + u8_t access; + /* ASN type for this object */ + u8_t asn_type; + /* value length (host length) */ + u16_t v_len; + /* length of instance part of supplied object identifier */ + u8_t id_inst_len; + /* instance part of supplied object identifier */ + s32_t *id_inst_ptr; +}; + +struct snmp_name_ptr +{ + u8_t ident_len; + s32_t *ident; +}; + +/** MIB const scalar (.0) node */ +#define MIB_NODE_SC 0x01 +/** MIB const array node */ +#define MIB_NODE_AR 0x02 +/** MIB array node (mem_malloced from RAM) */ +#define MIB_NODE_RA 0x03 +/** MIB list root node (mem_malloced from RAM) */ +#define MIB_NODE_LR 0x04 +/** MIB node for external objects */ +#define MIB_NODE_EX 0x05 + +/** node "base class" layout, the mandatory fields for a node */ +struct mib_node +{ + /** returns struct obj_def for the given object identifier */ + void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); + /** returns object value for the given object identifier, + @note the caller must allocate at least len bytes for the value */ + void (*get_value)(struct obj_def *od, u16_t len, void *value); + /** tests length and/or range BEFORE setting */ + u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); + /** sets object value, only to be called when set_test() */ + void (*set_value)(struct obj_def *od, u16_t len, void *value); + /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */ + u8_t node_type; + /* array or max list length */ + u16_t maxlength; +}; + +/** derived node for scalars .0 index */ +typedef struct mib_node mib_scalar_node; + +/** derived node, points to a fixed size const array + of sub-identifiers plus a 'child' pointer */ +struct mib_array_node +{ + /* inherited "base class" members */ + void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); + void (*get_value)(struct obj_def *od, u16_t len, void *value); + u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); + void (*set_value)(struct obj_def *od, u16_t len, void *value); + + u8_t node_type; + u16_t maxlength; + + /* additional struct members */ + const s32_t *objid; + struct mib_node* const *nptr; +}; + +/** derived node, points to a fixed size mem_malloced array + of sub-identifiers plus a 'child' pointer */ +struct mib_ram_array_node +{ + /* inherited "base class" members */ + void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); + void (*get_value)(struct obj_def *od, u16_t len, void *value); + u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); + void (*set_value)(struct obj_def *od, u16_t len, void *value); + + u8_t node_type; + u16_t maxlength; + + /* aditional struct members */ + s32_t *objid; + struct mib_node **nptr; +}; + +struct mib_list_node +{ + struct mib_list_node *prev; + struct mib_list_node *next; + s32_t objid; + struct mib_node *nptr; +}; + +/** derived node, points to a doubly linked list + of sub-identifiers plus a 'child' pointer */ +struct mib_list_rootnode +{ + /* inherited "base class" members */ + void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); + void (*get_value)(struct obj_def *od, u16_t len, void *value); + u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); + void (*set_value)(struct obj_def *od, u16_t len, void *value); + + u8_t node_type; + u16_t maxlength; + + /* additional struct members */ + struct mib_list_node *head; + struct mib_list_node *tail; + /* counts list nodes in list */ + u16_t count; +}; + +/** derived node, has access functions for mib object in external memory or device + using 'tree_level' and 'idx', with a range 0 .. (level_length() - 1) */ +struct mib_external_node +{ + /* inherited "base class" members */ + void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); + void (*get_value)(struct obj_def *od, u16_t len, void *value); + u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); + void (*set_value)(struct obj_def *od, u16_t len, void *value); + + u8_t node_type; + u16_t maxlength; + + /* additional struct members */ + /** points to an external (in memory) record of some sort of addressing + information, passed to and interpreted by the funtions below */ + void* addr_inf; + /** tree levels under this node */ + u8_t tree_levels; + /** number of objects at this level */ + u16_t (*level_length)(void* addr_inf, u8_t level); + /** compares object sub identifier with external id + return zero when equal, nonzero when unequal */ + s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id); + void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id); + + /** async Questions */ + void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident); + void (*get_value_q)(u8_t rid, struct obj_def *od); + void (*set_test_q)(u8_t rid, struct obj_def *od); + void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value); + /** async Answers */ + void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od); + void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); + u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); + void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); + /** async Panic Close (agent returns error reply, + e.g. used for external transaction cleanup) */ + void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident); + void (*get_value_pc)(u8_t rid, struct obj_def *od); + void (*set_test_pc)(u8_t rid, struct obj_def *od); + void (*set_value_pc)(u8_t rid, struct obj_def *od); +}; + +/** export MIB tree from mib2.c */ +extern const struct mib_array_node internet; + +/** dummy function pointers for non-leaf MIB nodes from mib2.c */ +void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); +void noleafs_get_value(struct obj_def *od, u16_t len, void *value); +u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value); +void noleafs_set_value(struct obj_def *od, u16_t len, void *value); + +void snmp_oidtoip(s32_t *ident, ip_addr_t *ip); +void snmp_iptooid(ip_addr_t *ip, s32_t *ident); +void snmp_ifindextonetif(s32_t ifindex, struct netif **netif); +void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx); + +struct mib_list_node* snmp_mib_ln_alloc(s32_t id); +void snmp_mib_ln_free(struct mib_list_node *ln); +struct mib_list_rootnode* snmp_mib_lrn_alloc(void); +void snmp_mib_lrn_free(struct mib_list_rootnode *lrn); + +s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn); +s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn); +struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n); + +struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np); +struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); +u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident); +u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_SNMP */ + +#endif /* __LWIP_SNMP_STRUCTS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/sockets.h b/user/mpy/lib/lwip/src/include/lwip/sockets.h new file mode 100644 index 0000000..3ea32f1 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/sockets.h @@ -0,0 +1,379 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + + +#ifndef __LWIP_SOCKETS_H__ +#define __LWIP_SOCKETS_H__ + +#include "lwip/opt.h" + +#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ + +#include /* for size_t */ + +#include "lwip/ip_addr.h" +#include "lwip/inet.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* members are in network byte order */ +struct sockaddr_in { + u8_t sin_len; + u8_t sin_family; + u16_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +struct sockaddr { + u8_t sa_len; + u8_t sa_family; + char sa_data[14]; +}; + +/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED + to prevent this code from redefining it. */ +#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) +typedef u32_t socklen_t; +#endif + +/* Socket protocol types (TCP/UDP/RAW) */ +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#define SOCK_RAW 3 + +/* + * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c) + */ +#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* Allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ +#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */ +#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */ + +#define SO_DONTLINGER ((int)(~SO_LINGER)) + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* Unimplemented: send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */ +#define SO_NO_CHECK 0x100a /* don't create UDP checksum */ + + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ +}; + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xfff /* options for socket level */ + + +#define AF_UNSPEC 0 +#define AF_INET 2 +#define PF_INET AF_INET +#define PF_UNSPEC AF_UNSPEC + +#define IPPROTO_IP 0 +#define IPPROTO_TCP 6 +#define IPPROTO_UDP 17 +#define IPPROTO_UDPLITE 136 + +/* Flags we can use with send and recv. */ +#define MSG_PEEK 0x01 /* Peeks at an incoming message */ +#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */ +#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */ +#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */ +#define MSG_MORE 0x10 /* Sender will send more */ + + +/* + * Options for level IPPROTO_IP + */ +#define IP_TOS 1 +#define IP_TTL 2 + +#if LWIP_TCP +/* + * Options for level IPPROTO_TCP + */ +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */ +#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */ +#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */ +#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */ +#endif /* LWIP_TCP */ + +#if LWIP_UDP && LWIP_UDPLITE +/* + * Options for level IPPROTO_UDPLITE + */ +#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ +#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ +#endif /* LWIP_UDP && LWIP_UDPLITE*/ + + +#if LWIP_IGMP +/* + * Options and types for UDP multicast traffic handling + */ +#define IP_ADD_MEMBERSHIP 3 +#define IP_DROP_MEMBERSHIP 4 +#define IP_MULTICAST_TTL 5 +#define IP_MULTICAST_IF 6 +#define IP_MULTICAST_LOOP 7 + +typedef struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +} ip_mreq; +#endif /* LWIP_IGMP */ + +/* + * The Type of Service provides an indication of the abstract + * parameters of the quality of service desired. These parameters are + * to be used to guide the selection of the actual service parameters + * when transmitting a datagram through a particular network. Several + * networks offer service precedence, which somehow treats high + * precedence traffic as more important than other traffic (generally + * by accepting only traffic above a certain precedence at time of high + * load). The major choice is a three way tradeoff between low-delay, + * high-reliability, and high-throughput. + * The use of the Delay, Throughput, and Reliability indications may + * increase the cost (in some sense) of the service. In many networks + * better performance for one of these parameters is coupled with worse + * performance on another. Except for very unusual cases at most two + * of these three indications should be set. + */ +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_LOWCOST 0x02 +#define IPTOS_MINCOST IPTOS_LOWCOST + +/* + * The Network Control precedence designation is intended to be used + * within a network only. The actual use and control of that + * designation is up to each network. The Internetwork Control + * designation is intended for use by gateway control originators only. + * If the actual use of these precedence designations is of concern to + * a particular network, it is the responsibility of that network to + * control the access to, and use of, those precedence designations. + */ +#define IPTOS_PREC_MASK 0xe0 +#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + + +/* + * Commands for ioctlsocket(), taken from the BSD file fcntl.h. + * lwip_ioctl only supports FIONREAD and FIONBIO, for now + * + * Ioctl's have the command encoded in the lower word, + * and the size of any in or out parameters in the upper + * word. The high 2 bits of the upper word are used + * to encode the in/out status of the parameter; for now + * we restrict parameters to at most 128 bytes. + */ +#if !defined(FIONREAD) || !defined(FIONBIO) +#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */ +#define IOC_VOID 0x20000000UL /* no parameters */ +#define IOC_OUT 0x40000000UL /* copy out parameters */ +#define IOC_IN 0x80000000UL /* copy in parameters */ +#define IOC_INOUT (IOC_IN|IOC_OUT) + /* 0x20000000 distinguishes new & + old ioctl's */ +#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) + +#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) + +#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#endif /* !defined(FIONREAD) || !defined(FIONBIO) */ + +#ifndef FIONREAD +#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */ +#endif +#ifndef FIONBIO +#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */ +#endif + +/* Socket I/O Controls: unimplemented */ +#ifndef SIOCSHIWAT +#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */ +#endif + +/* commands for fnctl */ +#ifndef F_GETFL +#define F_GETFL 3 +#endif +#ifndef F_SETFL +#define F_SETFL 4 +#endif + +/* File status flags and file access modes for fnctl, + these are bits in an int. */ +#ifndef O_NONBLOCK +#define O_NONBLOCK 1 /* nonblocking I/O */ +#endif +#ifndef O_NDELAY +#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */ +#endif + +#ifndef SHUT_RD + #define SHUT_RD 0 + #define SHUT_WR 1 + #define SHUT_RDWR 2 +#endif + +/* FD_SET used for lwip_select */ +#ifndef FD_SET + #undef FD_SETSIZE + /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */ + #define FD_SETSIZE MEMP_NUM_NETCONN + #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7))) + #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7))) + #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7))) + #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p))) + + typedef struct fd_set { + unsigned char fd_bits [(FD_SETSIZE+7)/8]; + } fd_set; + +#endif /* FD_SET */ + +/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided + * by your system, set this to 0 and include in cc.h */ +#ifndef LWIP_TIMEVAL_PRIVATE +#define LWIP_TIMEVAL_PRIVATE 1 +#endif + +#if LWIP_TIMEVAL_PRIVATE +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* and microseconds */ +}; +#endif /* LWIP_TIMEVAL_PRIVATE */ + +void lwip_socket_init(void); + +int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen); +int lwip_shutdown(int s, int how); +int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); +int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); +int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); +int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); +int lwip_close(int s); +int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); +int lwip_listen(int s, int backlog); +int lwip_recv(int s, void *mem, size_t len, int flags); +int lwip_read(int s, void *mem, size_t len); +int lwip_recvfrom(int s, void *mem, size_t len, int flags, + struct sockaddr *from, socklen_t *fromlen); +int lwip_send(int s, const void *dataptr, size_t size, int flags); +int lwip_sendto(int s, const void *dataptr, size_t size, int flags, + const struct sockaddr *to, socklen_t tolen); +int lwip_socket(int domain, int type, int protocol); +int lwip_write(int s, const void *dataptr, size_t size); +int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, + struct timeval *timeout); +int lwip_ioctl(int s, long cmd, void *argp); +int lwip_fcntl(int s, int cmd, int val); + +#if LWIP_COMPAT_SOCKETS +#define accept(a,b,c) lwip_accept(a,b,c) +#define bind(a,b,c) lwip_bind(a,b,c) +#define shutdown(a,b) lwip_shutdown(a,b) +#define closesocket(s) lwip_close(s) +#define connect(a,b,c) lwip_connect(a,b,c) +#define getsockname(a,b,c) lwip_getsockname(a,b,c) +#define getpeername(a,b,c) lwip_getpeername(a,b,c) +#define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e) +#define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e) +#define listen(a,b) lwip_listen(a,b) +#define recv(a,b,c,d) lwip_recv(a,b,c,d) +#define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f) +#define send(a,b,c,d) lwip_send(a,b,c,d) +#define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f) +#define socket(a,b,c) lwip_socket(a,b,c) +#define select(a,b,c,d,e) lwip_select(a,b,c,d,e) +#define ioctlsocket(a,b,c) lwip_ioctl(a,b,c) + +#if LWIP_POSIX_SOCKETS_IO_NAMES +#define read(a,b,c) lwip_read(a,b,c) +#define write(a,b,c) lwip_write(a,b,c) +#define close(s) lwip_close(s) +#define fcntl(a,b,c) lwip_fcntl(a,b,c) +#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */ + +#endif /* LWIP_COMPAT_SOCKETS */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_SOCKET */ + +#endif /* __LWIP_SOCKETS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/stats.h b/user/mpy/lib/lwip/src/include/lwip/stats.h new file mode 100644 index 0000000..1f5152a --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/stats.h @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_STATS_H__ +#define __LWIP_STATS_H__ + +#include "lwip/opt.h" + +#include "lwip/mem.h" +#include "lwip/memp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_STATS + +#ifndef LWIP_STATS_LARGE +#define LWIP_STATS_LARGE 0 +#endif + +#if LWIP_STATS_LARGE +#define STAT_COUNTER u32_t +#define STAT_COUNTER_F U32_F +#else +#define STAT_COUNTER u16_t +#define STAT_COUNTER_F U16_F +#endif + +struct stats_proto { + STAT_COUNTER xmit; /* Transmitted packets. */ + STAT_COUNTER recv; /* Received packets. */ + STAT_COUNTER fw; /* Forwarded packets. */ + STAT_COUNTER drop; /* Dropped packets. */ + STAT_COUNTER chkerr; /* Checksum error. */ + STAT_COUNTER lenerr; /* Invalid length error. */ + STAT_COUNTER memerr; /* Out of memory error. */ + STAT_COUNTER rterr; /* Routing error. */ + STAT_COUNTER proterr; /* Protocol error. */ + STAT_COUNTER opterr; /* Error in options. */ + STAT_COUNTER err; /* Misc error. */ + STAT_COUNTER cachehit; +}; + +struct stats_igmp { + STAT_COUNTER xmit; /* Transmitted packets. */ + STAT_COUNTER recv; /* Received packets. */ + STAT_COUNTER drop; /* Dropped packets. */ + STAT_COUNTER chkerr; /* Checksum error. */ + STAT_COUNTER lenerr; /* Invalid length error. */ + STAT_COUNTER memerr; /* Out of memory error. */ + STAT_COUNTER proterr; /* Protocol error. */ + STAT_COUNTER rx_v1; /* Received v1 frames. */ + STAT_COUNTER rx_group; /* Received group-specific queries. */ + STAT_COUNTER rx_general; /* Received general queries. */ + STAT_COUNTER rx_report; /* Received reports. */ + STAT_COUNTER tx_join; /* Sent joins. */ + STAT_COUNTER tx_leave; /* Sent leaves. */ + STAT_COUNTER tx_report; /* Sent reports. */ +}; + +struct stats_mem { +#ifdef LWIP_DEBUG + const char *name; +#endif /* LWIP_DEBUG */ + mem_size_t avail; + mem_size_t used; + mem_size_t max; + STAT_COUNTER err; + STAT_COUNTER illegal; +}; + +struct stats_syselem { + STAT_COUNTER used; + STAT_COUNTER max; + STAT_COUNTER err; +}; + +struct stats_sys { + struct stats_syselem sem; + struct stats_syselem mutex; + struct stats_syselem mbox; +}; + +struct stats_ { +#if LINK_STATS + struct stats_proto link; +#endif +#if ETHARP_STATS + struct stats_proto etharp; +#endif +#if IPFRAG_STATS + struct stats_proto ip_frag; +#endif +#if IP_STATS + struct stats_proto ip; +#endif +#if ICMP_STATS + struct stats_proto icmp; +#endif +#if IGMP_STATS + struct stats_igmp igmp; +#endif +#if UDP_STATS + struct stats_proto udp; +#endif +#if TCP_STATS + struct stats_proto tcp; +#endif +#if MEM_STATS + struct stats_mem mem; +#endif +#if MEMP_STATS + struct stats_mem memp[MEMP_MAX]; +#endif +#if SYS_STATS + struct stats_sys sys; +#endif +}; + +extern struct stats_ lwip_stats; + +void stats_init(void); + +#define STATS_INC(x) ++lwip_stats.x +#define STATS_DEC(x) --lwip_stats.x +#define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \ + if (lwip_stats.x.max < lwip_stats.x.used) { \ + lwip_stats.x.max = lwip_stats.x.used; \ + } \ + } while(0) +#else /* LWIP_STATS */ +#define stats_init() +#define STATS_INC(x) +#define STATS_DEC(x) +#define STATS_INC_USED(x) +#endif /* LWIP_STATS */ + +#if TCP_STATS +#define TCP_STATS_INC(x) STATS_INC(x) +#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP") +#else +#define TCP_STATS_INC(x) +#define TCP_STATS_DISPLAY() +#endif + +#if UDP_STATS +#define UDP_STATS_INC(x) STATS_INC(x) +#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP") +#else +#define UDP_STATS_INC(x) +#define UDP_STATS_DISPLAY() +#endif + +#if ICMP_STATS +#define ICMP_STATS_INC(x) STATS_INC(x) +#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP") +#else +#define ICMP_STATS_INC(x) +#define ICMP_STATS_DISPLAY() +#endif + +#if IGMP_STATS +#define IGMP_STATS_INC(x) STATS_INC(x) +#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp) +#else +#define IGMP_STATS_INC(x) +#define IGMP_STATS_DISPLAY() +#endif + +#if IP_STATS +#define IP_STATS_INC(x) STATS_INC(x) +#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP") +#else +#define IP_STATS_INC(x) +#define IP_STATS_DISPLAY() +#endif + +#if IPFRAG_STATS +#define IPFRAG_STATS_INC(x) STATS_INC(x) +#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG") +#else +#define IPFRAG_STATS_INC(x) +#define IPFRAG_STATS_DISPLAY() +#endif + +#if ETHARP_STATS +#define ETHARP_STATS_INC(x) STATS_INC(x) +#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP") +#else +#define ETHARP_STATS_INC(x) +#define ETHARP_STATS_DISPLAY() +#endif + +#if LINK_STATS +#define LINK_STATS_INC(x) STATS_INC(x) +#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK") +#else +#define LINK_STATS_INC(x) +#define LINK_STATS_DISPLAY() +#endif + +#if MEM_STATS +#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y +#define MEM_STATS_INC(x) STATS_INC(mem.x) +#define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y) +#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y +#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP") +#else +#define MEM_STATS_AVAIL(x, y) +#define MEM_STATS_INC(x) +#define MEM_STATS_INC_USED(x, y) +#define MEM_STATS_DEC_USED(x, y) +#define MEM_STATS_DISPLAY() +#endif + +#if MEMP_STATS +#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y +#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x) +#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x) +#define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1) +#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i) +#else +#define MEMP_STATS_AVAIL(x, i, y) +#define MEMP_STATS_INC(x, i) +#define MEMP_STATS_DEC(x, i) +#define MEMP_STATS_INC_USED(x, i) +#define MEMP_STATS_DISPLAY(i) +#endif + +#if SYS_STATS +#define SYS_STATS_INC(x) STATS_INC(sys.x) +#define SYS_STATS_DEC(x) STATS_DEC(sys.x) +#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1) +#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys) +#else +#define SYS_STATS_INC(x) +#define SYS_STATS_DEC(x) +#define SYS_STATS_INC_USED(x) +#define SYS_STATS_DISPLAY() +#endif + +/* Display of statistics */ +#if LWIP_STATS_DISPLAY +void stats_display(void); +void stats_display_proto(struct stats_proto *proto, const char *name); +void stats_display_igmp(struct stats_igmp *igmp); +void stats_display_mem(struct stats_mem *mem, const char *name); +void stats_display_memp(struct stats_mem *mem, int index); +void stats_display_sys(struct stats_sys *sys); +#else /* LWIP_STATS_DISPLAY */ +#define stats_display() +#define stats_display_proto(proto, name) +#define stats_display_igmp(igmp) +#define stats_display_mem(mem, name) +#define stats_display_memp(mem, index) +#define stats_display_sys(sys) +#endif /* LWIP_STATS_DISPLAY */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_STATS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/sys.h b/user/mpy/lib/lwip/src/include/lwip/sys.h new file mode 100644 index 0000000..dc93513 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/sys.h @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_SYS_H__ +#define __LWIP_SYS_H__ + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if NO_SYS + +/* For a totally minimal and standalone system, we provide null + definitions of the sys_ functions. */ +typedef u8_t sys_sem_t; +typedef u8_t sys_mutex_t; +typedef u8_t sys_mbox_t; + +#define sys_sem_new(s, c) ERR_OK +#define sys_sem_signal(s) +#define sys_sem_wait(s) +#define sys_arch_sem_wait(s,t) +#define sys_sem_free(s) +#define sys_sem_valid(s) 0 +#define sys_sem_set_invalid(s) +#define sys_mutex_new(mu) ERR_OK +#define sys_mutex_lock(mu) +#define sys_mutex_unlock(mu) +#define sys_mutex_free(mu) +#define sys_mutex_valid(mu) 0 +#define sys_mutex_set_invalid(mu) +#define sys_mbox_new(m, s) ERR_OK +#define sys_mbox_fetch(m,d) +#define sys_mbox_tryfetch(m,d) +#define sys_mbox_post(m,d) +#define sys_mbox_trypost(m,d) +#define sys_mbox_free(m) +#define sys_mbox_valid(m) +#define sys_mbox_set_invalid(m) + +#define sys_thread_new(n,t,a,s,p) + +#define sys_msleep(t) + +#else /* NO_SYS */ + +/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ +#define SYS_ARCH_TIMEOUT 0xffffffffUL + +/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. + * For now we use the same magic value, but we allow this to change in future. + */ +#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT + +#include "lwip/err.h" +#include "arch/sys_arch.h" + +/** Function prototype for thread functions */ +typedef void (*lwip_thread_fn)(void *arg); + +/* Function prototypes for functions to be implemented by platform ports + (in sys_arch.c) */ + +/* Mutex functions: */ + +/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores + should be used instead */ +#if LWIP_COMPAT_MUTEX +/* for old ports that don't have mutexes: define them to binary semaphores */ +#define sys_mutex_t sys_sem_t +#define sys_mutex_new(mutex) sys_sem_new(mutex, 1) +#define sys_mutex_lock(mutex) sys_sem_wait(mutex) +#define sys_mutex_unlock(mutex) sys_sem_signal(mutex) +#define sys_mutex_free(mutex) sys_sem_free(mutex) +#define sys_mutex_valid(mutex) sys_sem_valid(mutex) +#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) + +#else /* LWIP_COMPAT_MUTEX */ + +/** Create a new mutex + * @param mutex pointer to the mutex to create + * @return a new mutex */ +err_t sys_mutex_new(sys_mutex_t *mutex); +/** Lock a mutex + * @param mutex the mutex to lock */ +void sys_mutex_lock(sys_mutex_t *mutex); +/** Unlock a mutex + * @param mutex the mutex to unlock */ +void sys_mutex_unlock(sys_mutex_t *mutex); +/** Delete a semaphore + * @param mutex the mutex to delete */ +void sys_mutex_free(sys_mutex_t *mutex); +#ifndef sys_mutex_valid +/** Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid */ +int sys_mutex_valid(sys_mutex_t *mutex); +#endif +#ifndef sys_mutex_set_invalid +/** Set a mutex invalid so that sys_mutex_valid returns 0 */ +void sys_mutex_set_invalid(sys_mutex_t *mutex); +#endif +#endif /* LWIP_COMPAT_MUTEX */ + +/* Semaphore functions: */ + +/** Create a new semaphore + * @param sem pointer to the semaphore to create + * @param count initial count of the semaphore + * @return ERR_OK if successful, another err_t otherwise */ +err_t sys_sem_new(sys_sem_t *sem, u8_t count); +/** Signals a semaphore + * @param sem the semaphore to signal */ +void sys_sem_signal(sys_sem_t *sem); +/** Wait for a semaphore for the specified timeout + * @param sem the semaphore to wait for + * @param timeout timeout in milliseconds to wait (0 = wait forever) + * @return time (in milliseconds) waited for the semaphore + * or SYS_ARCH_TIMEOUT on timeout */ +u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout); +/** Delete a semaphore + * @param sem semaphore to delete */ +void sys_sem_free(sys_sem_t *sem); +/** Wait for a semaphore - forever/no timeout */ +#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0) +#ifndef sys_sem_valid +/** Check if a sempahore is valid/allocated: return 1 for valid, 0 for invalid */ +int sys_sem_valid(sys_sem_t *sem); +#endif +#ifndef sys_sem_set_invalid +/** Set a semaphore invalid so that sys_sem_valid returns 0 */ +void sys_sem_set_invalid(sys_sem_t *sem); +#endif + +/* Time functions. */ +#ifndef sys_msleep +void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */ +#endif + +/* Mailbox functions. */ + +/** Create a new mbox of specified size + * @param mbox pointer to the mbox to create + * @param size (miminum) number of messages in this mbox + * @return ERR_OK if successful, another err_t otherwise */ +err_t sys_mbox_new(sys_mbox_t *mbox, int size); +/** Post a message to an mbox - may not fail + * -> blocks if full, only used from tasks not from ISR + * @param mbox mbox to posts the message + * @param msg message to post (ATTENTION: can be NULL) */ +void sys_mbox_post(sys_mbox_t *mbox, void *msg); +/** Try to post a message to an mbox - may fail if full or ISR + * @param mbox mbox to posts the message + * @param msg message to post (ATTENTION: can be NULL) */ +err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg); +/** Wait for a new message to arrive in the mbox + * @param mbox mbox to get a message from + * @param msg pointer where the message is stored + * @param timeout maximum time (in milliseconds) to wait for a message + * @return time (in milliseconds) waited for a message, may be 0 if not waited + or SYS_ARCH_TIMEOUT on timeout + * The returned time has to be accurate to prevent timer jitter! */ +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout); +/* Allow port to override with a macro, e.g. special timout for sys_arch_mbox_fetch() */ +#ifndef sys_arch_mbox_tryfetch +/** Wait for a new message to arrive in the mbox + * @param mbox mbox to get a message from + * @param msg pointer where the message is stored + * @param timeout maximum time (in milliseconds) to wait for a message + * @return 0 (milliseconds) if a message has been received + * or SYS_MBOX_EMPTY if the mailbox is empty */ +u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg); +#endif +/** For now, we map straight to sys_arch implementation. */ +#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) +/** Delete an mbox + * @param mbox mbox to delete */ +void sys_mbox_free(sys_mbox_t *mbox); +#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0) +#ifndef sys_mbox_valid +/** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */ +int sys_mbox_valid(sys_mbox_t *mbox); +#endif +#ifndef sys_mbox_set_invalid +/** Set an mbox invalid so that sys_mbox_valid returns 0 */ +void sys_mbox_set_invalid(sys_mbox_t *mbox); +#endif + +/** The only thread function: + * Creates a new thread + * @param name human-readable name for the thread (used for debugging purposes) + * @param thread thread-function + * @param arg parameter passed to 'thread' + * @param stacksize stack size in bytes for the new thread (may be ignored by ports) + * @param prio priority of the new thread (may be ignored by ports) */ +sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio); + +#endif /* NO_SYS */ + +/* sys_init() must be called before anthing else. */ +void sys_init(void); + +#ifndef sys_jiffies +/** Ticks/jiffies since power up. */ +u32_t sys_jiffies(void); +#endif + +/** Returns the current time in milliseconds, + * may be the same as sys_jiffies or at least based on it. */ +u32_t sys_now(void); + +/* Critical Region Protection */ +/* These functions must be implemented in the sys_arch.c file. + In some implementations they can provide a more light-weight protection + mechanism than using semaphores. Otherwise semaphores can be used for + implementation */ +#ifndef SYS_ARCH_PROTECT +/** SYS_LIGHTWEIGHT_PROT + * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection + * for certain critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#if SYS_LIGHTWEIGHT_PROT + +/** SYS_ARCH_DECL_PROTECT + * declare a protection variable. This macro will default to defining a variable of + * type sys_prot_t. If a particular port needs a different implementation, then + * this macro may be defined in sys_arch.h. + */ +#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev +/** SYS_ARCH_PROTECT + * Perform a "fast" protect. This could be implemented by + * disabling interrupts for an embedded system or by using a semaphore or + * mutex. The implementation should allow calling SYS_ARCH_PROTECT when + * already protected. The old protection level is returned in the variable + * "lev". This macro will default to calling the sys_arch_protect() function + * which should be implemented in sys_arch.c. If a particular port needs a + * different implementation, then this macro may be defined in sys_arch.h + */ +#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() +/** SYS_ARCH_UNPROTECT + * Perform a "fast" set of the protection level to "lev". This could be + * implemented by setting the interrupt level to "lev" within the MACRO or by + * using a semaphore or mutex. This macro will default to calling the + * sys_arch_unprotect() function which should be implemented in + * sys_arch.c. If a particular port needs a different implementation, then + * this macro may be defined in sys_arch.h + */ +#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) +sys_prot_t sys_arch_protect(void); +void sys_arch_unprotect(sys_prot_t pval); + +#else + +#define SYS_ARCH_DECL_PROTECT(lev) +#define SYS_ARCH_PROTECT(lev) +#define SYS_ARCH_UNPROTECT(lev) + +#endif /* SYS_LIGHTWEIGHT_PROT */ + +#endif /* SYS_ARCH_PROTECT */ + +/* + * Macros to set/get and increase/decrease variables in a thread-safe way. + * Use these for accessing variable that are used from more than one thread. + */ + +#ifndef SYS_ARCH_INC +#define SYS_ARCH_INC(var, val) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + var += val; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_INC */ + +#ifndef SYS_ARCH_DEC +#define SYS_ARCH_DEC(var, val) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + var -= val; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_DEC */ + +#ifndef SYS_ARCH_GET +#define SYS_ARCH_GET(var, ret) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + ret = var; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_GET */ + +#ifndef SYS_ARCH_SET +#define SYS_ARCH_SET(var, val) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + var = val; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_SET */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __LWIP_SYS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/tcp.h b/user/mpy/lib/lwip/src/include/lwip/tcp.h new file mode 100644 index 0000000..c6e61ad --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/tcp.h @@ -0,0 +1,379 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_TCP_H__ +#define __LWIP_TCP_H__ + +#include "lwip/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include "lwip/ip.h" +#include "lwip/icmp.h" +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct tcp_pcb; + +/** Function prototype for tcp accept callback functions. Called when a new + * connection can be accepted on a listening pcb. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param newpcb The new connection pcb + * @param err An error code if there has been an error accepting. + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err); + +/** Function prototype for tcp receive callback functions. Called when data has + * been received. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb The connection pcb which received data + * @param p The received data (or NULL when the connection has been closed!) + * @param err An error code if there has been an error receiving + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb, + struct pbuf *p, err_t err); + +/** Function prototype for tcp sent callback functions. Called when sent data has + * been acknowledged by the remote side. Use it to free corresponding resources. + * This also means that the pcb has now space available to send new data. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb The connection pcb for which data has been acknowledged + * @param len The amount of bytes acknowledged + * @return ERR_OK: try to send some data by calling tcp_output + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb, + u16_t len); + +/** Function prototype for tcp poll callback functions. Called periodically as + * specified by @see tcp_poll. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb tcp pcb + * @return ERR_OK: try to send some data by calling tcp_output + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb); + +/** Function prototype for tcp error callback functions. Called when the pcb + * receives a RST or is unexpectedly closed for any other reason. + * + * @note The corresponding pcb is already freed when this callback is called! + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param err Error code to indicate why the pcb has been closed + * ERR_ABRT: aborted through tcp_abort or by a TCP timer + * ERR_RST: the connection was reset by the remote host + */ +typedef void (*tcp_err_fn)(void *arg, err_t err); + +/** Function prototype for tcp connected callback functions. Called when a pcb + * is connected to the remote side after initiating a connection attempt by + * calling tcp_connect(). + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb The connection pcb which is connected + * @param err An unused error code, always ERR_OK currently ;-) TODO! + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + * + * @note When a connection attempt fails, the error callback is currently called! + */ +typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err); + +enum tcp_state { + CLOSED = 0, + LISTEN = 1, + SYN_SENT = 2, + SYN_RCVD = 3, + ESTABLISHED = 4, + FIN_WAIT_1 = 5, + FIN_WAIT_2 = 6, + CLOSE_WAIT = 7, + CLOSING = 8, + LAST_ACK = 9, + TIME_WAIT = 10 +}; + +#if LWIP_CALLBACK_API + /* Function to call when a listener has been connected. + * @param arg user-supplied argument (tcp_pcb.callback_arg) + * @param pcb a new tcp_pcb that now is connected + * @param err an error argument (TODO: that is current always ERR_OK?) + * @return ERR_OK: accept the new connection, + * any other err_t abortsthe new connection + */ +#define DEF_ACCEPT_CALLBACK tcp_accept_fn accept; +#else /* LWIP_CALLBACK_API */ +#define DEF_ACCEPT_CALLBACK +#endif /* LWIP_CALLBACK_API */ + +/** + * members common to struct tcp_pcb and struct tcp_listen_pcb + */ +#define TCP_PCB_COMMON(type) \ + type *next; /* for the linked list */ \ + void *callback_arg; \ + /* the accept callback for listen- and normal pcbs, if LWIP_CALLBACK_API */ \ + DEF_ACCEPT_CALLBACK \ + enum tcp_state state; /* TCP state */ \ + u8_t prio; \ + /* ports are in host byte order */ \ + u16_t local_port + + +/* the TCP protocol control block */ +struct tcp_pcb { +/** common PCB members */ + IP_PCB; +/** protocol specific PCB members */ + TCP_PCB_COMMON(struct tcp_pcb); + + /* ports are in host byte order */ + u16_t remote_port; + + u8_t flags; +#define TF_ACK_DELAY ((u8_t)0x01U) /* Delayed ACK. */ +#define TF_ACK_NOW ((u8_t)0x02U) /* Immediate ACK. */ +#define TF_INFR ((u8_t)0x04U) /* In fast recovery. */ +#define TF_TIMESTAMP ((u8_t)0x08U) /* Timestamp option enabled */ +#define TF_RXCLOSED ((u8_t)0x10U) /* rx closed by tcp_shutdown */ +#define TF_FIN ((u8_t)0x20U) /* Connection was closed locally (FIN segment enqueued). */ +#define TF_NODELAY ((u8_t)0x40U) /* Disable Nagle algorithm */ +#define TF_NAGLEMEMERR ((u8_t)0x80U) /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ + + /* the rest of the fields are in host byte order + as we have to do some math with them */ + + /* Timers */ + u8_t polltmr, pollinterval; + u8_t last_timer; + u32_t tmr; + + /* receiver variables */ + u32_t rcv_nxt; /* next seqno expected */ + u16_t rcv_wnd; /* receiver window available */ + u16_t rcv_ann_wnd; /* receiver window to announce */ + u32_t rcv_ann_right_edge; /* announced right edge of window */ + + /* Retransmission timer. */ + s16_t rtime; + + u16_t mss; /* maximum segment size */ + + /* RTT (round trip time) estimation variables */ + u32_t rttest; /* RTT estimate in 500ms ticks */ + u32_t rtseq; /* sequence number being timed */ + s16_t sa, sv; /* @todo document this */ + + s16_t rto; /* retransmission time-out */ + u8_t nrtx; /* number of retransmissions */ + + /* fast retransmit/recovery */ + u8_t dupacks; + u32_t lastack; /* Highest acknowledged seqno. */ + + /* congestion avoidance/control variables */ + u16_t cwnd; + u16_t ssthresh; + + /* sender variables */ + u32_t snd_nxt; /* next new seqno to be sent */ + u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last + window update. */ + u32_t snd_lbb; /* Sequence number of next byte to be buffered. */ + u16_t snd_wnd; /* sender window */ + u16_t snd_wnd_max; /* the maximum sender window announced by the remote host */ + + u16_t acked; + + u16_t snd_buf; /* Available buffer space for sending (in bytes). */ +#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) + u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */ + +#if TCP_OVERSIZE + /* Extra bytes available at the end of the last pbuf in unsent. */ + u16_t unsent_oversize; +#endif /* TCP_OVERSIZE */ + + /* These are ordered by sequence number: */ + struct tcp_seg *unsent; /* Unsent (queued) segments. */ + struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ +#if TCP_QUEUE_OOSEQ + struct tcp_seg *ooseq; /* Received out of sequence segments. */ +#endif /* TCP_QUEUE_OOSEQ */ + + struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */ + +#if LWIP_CALLBACK_API + /* Function to be called when more send buffer space is available. */ + tcp_sent_fn sent; + /* Function to be called when (in-sequence) data has arrived. */ + tcp_recv_fn recv; + /* Function to be called when a connection has been set up. */ + tcp_connected_fn connected; + /* Function which is called periodically. */ + tcp_poll_fn poll; + /* Function to be called whenever a fatal error occurs. */ + tcp_err_fn errf; +#endif /* LWIP_CALLBACK_API */ + +#if LWIP_TCP_TIMESTAMPS + u32_t ts_lastacksent; + u32_t ts_recent; +#endif /* LWIP_TCP_TIMESTAMPS */ + + /* idle time before KEEPALIVE is sent */ + u32_t keep_idle; +#if LWIP_TCP_KEEPALIVE + u32_t keep_intvl; + u32_t keep_cnt; +#endif /* LWIP_TCP_KEEPALIVE */ + + /* Persist timer counter */ + u8_t persist_cnt; + /* Persist timer back-off */ + u8_t persist_backoff; + + /* KEEPALIVE counter */ + u8_t keep_cnt_sent; +}; + +struct tcp_pcb_listen { +/* Common members of all PCB types */ + IP_PCB; +/* Protocol specific PCB members */ + TCP_PCB_COMMON(struct tcp_pcb_listen); + +#if TCP_LISTEN_BACKLOG + u8_t backlog; + u8_t accepts_pending; +#endif /* TCP_LISTEN_BACKLOG */ +}; + +#if LWIP_EVENT_API + +enum lwip_event { + LWIP_EVENT_ACCEPT, + LWIP_EVENT_SENT, + LWIP_EVENT_RECV, + LWIP_EVENT_CONNECTED, + LWIP_EVENT_POLL, + LWIP_EVENT_ERR +}; + +err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, + enum lwip_event, + struct pbuf *p, + u16_t size, + err_t err); + +#endif /* LWIP_EVENT_API */ + +/* Application program's interface: */ +struct tcp_pcb * tcp_new (void); + +void tcp_arg (struct tcp_pcb *pcb, void *arg); +void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); +void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv); +void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent); +void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval); +void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); + +#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss) +#define tcp_sndbuf(pcb) ((pcb)->snd_buf) +#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) +#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) +#define tcp_nagle_enable(pcb) ((pcb)->flags &= ~TF_NODELAY) +#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) + +#if TCP_LISTEN_BACKLOG +#define tcp_accepted(pcb) do { \ + LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", pcb->state == LISTEN); \ + (((struct tcp_pcb_listen *)(pcb))->accepts_pending--); } while(0) +#else /* TCP_LISTEN_BACKLOG */ +#define tcp_accepted(pcb) LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", \ + (pcb)->state == LISTEN) +#endif /* TCP_LISTEN_BACKLOG */ + +void tcp_recved (struct tcp_pcb *pcb, u16_t len); +err_t tcp_bind (struct tcp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port); +err_t tcp_connect (struct tcp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port, tcp_connected_fn connected); + +struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); +#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) + +void tcp_abort (struct tcp_pcb *pcb); +err_t tcp_close (struct tcp_pcb *pcb); +err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx); + +/* Flags for "apiflags" parameter in tcp_write */ +#define TCP_WRITE_FLAG_COPY 0x01 +#define TCP_WRITE_FLAG_MORE 0x02 + +err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, + u8_t apiflags); + +void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); + +#define TCP_PRIO_MIN 1 +#define TCP_PRIO_NORMAL 64 +#define TCP_PRIO_MAX 127 + +err_t tcp_output (struct tcp_pcb *pcb); + + +const char* tcp_debug_state_str(enum tcp_state s); + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_TCP */ + +#endif /* __LWIP_TCP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/tcp_impl.h b/user/mpy/lib/lwip/src/include/lwip/tcp_impl.h new file mode 100644 index 0000000..173de44 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/tcp_impl.h @@ -0,0 +1,486 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_TCP_IMPL_H__ +#define __LWIP_TCP_IMPL_H__ + +#include "lwip/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/tcp.h" +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include "lwip/ip.h" +#include "lwip/icmp.h" +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Functions for interfacing with TCP: */ + +/* Lower layer interface to TCP: */ +void tcp_init (void); /* Initialize this module. */ +void tcp_tmr (void); /* Must be called every + TCP_TMR_INTERVAL + ms. (Typically 250 ms). */ +/* It is also possible to call these two functions at the right + intervals (instead of calling tcp_tmr()). */ +void tcp_slowtmr (void); +void tcp_fasttmr (void); + + +/* Only used by IP to pass a TCP segment to TCP: */ +void tcp_input (struct pbuf *p, struct netif *inp); +/* Used within the TCP code only: */ +struct tcp_pcb * tcp_alloc (u8_t prio); +void tcp_abandon (struct tcp_pcb *pcb, int reset); +err_t tcp_send_empty_ack(struct tcp_pcb *pcb); +void tcp_rexmit (struct tcp_pcb *pcb); +void tcp_rexmit_rto (struct tcp_pcb *pcb); +void tcp_rexmit_fast (struct tcp_pcb *pcb); +u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); +err_t tcp_process_refused_data(struct tcp_pcb *pcb); + +/** + * This is the Nagle algorithm: try to combine user data to send as few TCP + * segments as possible. Only send if + * - no previously transmitted data on the connection remains unacknowledged or + * - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or + * - the only unsent segment is at least pcb->mss bytes long (or there is more + * than one unsent segment - with lwIP, this can happen although unsent->len < mss) + * - or if we are in fast-retransmit (TF_INFR) + */ +#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ + ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \ + (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ + ((tpcb)->unsent->len >= (tpcb)->mss))) || \ + ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \ + ) ? 1 : 0) +#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) + + +#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) +#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) +#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) +#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) +/* is b<=a<=c? */ +#if 0 /* see bug #10548 */ +#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) +#endif +#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) +#define TCP_FIN 0x01U +#define TCP_SYN 0x02U +#define TCP_RST 0x04U +#define TCP_PSH 0x08U +#define TCP_ACK 0x10U +#define TCP_URG 0x20U +#define TCP_ECE 0x40U +#define TCP_CWR 0x80U + +#define TCP_FLAGS 0x3fU + +/* Length of the TCP header, excluding options. */ +#define TCP_HLEN 20 + +#ifndef TCP_TMR_INTERVAL +#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ +#endif /* TCP_TMR_INTERVAL */ + +#ifndef TCP_FAST_INTERVAL +#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ +#endif /* TCP_FAST_INTERVAL */ + +#ifndef TCP_SLOW_INTERVAL +#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ +#endif /* TCP_SLOW_INTERVAL */ + +#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ +#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ + +#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ + +#ifndef TCP_MSL +#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */ +#endif + +/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ +#ifndef TCP_KEEPIDLE_DEFAULT +#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ +#endif + +#ifndef TCP_KEEPINTVL_DEFAULT +#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ +#endif + +#ifndef TCP_KEEPCNT_DEFAULT +#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ +#endif + +#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */ + +/* Fields are (of course) in network byte order. + * Some fields are converted to host byte order in tcp_input(). + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct tcp_hdr { + PACK_STRUCT_FIELD(u16_t src); + PACK_STRUCT_FIELD(u16_t dest); + PACK_STRUCT_FIELD(u32_t seqno); + PACK_STRUCT_FIELD(u32_t ackno); + PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); + PACK_STRUCT_FIELD(u16_t wnd); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u16_t urgp); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12) +#define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS) + +#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr)) +#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags)) +#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags)) + +#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags)) +#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) ) + +#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0)) + +/** Flags used on input processing, not on pcb->flags +*/ +#define TF_RESET (u8_t)0x08U /* Connection was reset. */ +#define TF_CLOSED (u8_t)0x10U /* Connection was sucessfully closed. */ +#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ + + +#if LWIP_EVENT_API + +#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_ACCEPT, NULL, 0, err) +#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_SENT, NULL, space, ERR_OK) +#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_RECV, (p), 0, (err)) +#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_RECV, NULL, 0, ERR_OK) +#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_CONNECTED, NULL, 0, (err)) +#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_POLL, NULL, 0, ERR_OK) +#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \ + LWIP_EVENT_ERR, NULL, 0, (err)) + +#else /* LWIP_EVENT_API */ + +#define TCP_EVENT_ACCEPT(pcb,err,ret) \ + do { \ + if((pcb)->accept != NULL) \ + (ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \ + else (ret) = ERR_ARG; \ + } while (0) + +#define TCP_EVENT_SENT(pcb,space,ret) \ + do { \ + if((pcb)->sent != NULL) \ + (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \ + else (ret) = ERR_OK; \ + } while (0) + +#define TCP_EVENT_RECV(pcb,p,err,ret) \ + do { \ + if((pcb)->recv != NULL) { \ + (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\ + } else { \ + (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \ + } \ + } while (0) + +#define TCP_EVENT_CLOSED(pcb,ret) \ + do { \ + if(((pcb)->recv != NULL)) { \ + (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\ + } else { \ + (ret) = ERR_OK; \ + } \ + } while (0) + +#define TCP_EVENT_CONNECTED(pcb,err,ret) \ + do { \ + if((pcb)->connected != NULL) \ + (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \ + else (ret) = ERR_OK; \ + } while (0) + +#define TCP_EVENT_POLL(pcb,ret) \ + do { \ + if((pcb)->poll != NULL) \ + (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \ + else (ret) = ERR_OK; \ + } while (0) + +#define TCP_EVENT_ERR(errf,arg,err) \ + do { \ + if((errf) != NULL) \ + (errf)((arg),(err)); \ + } while (0) + +#endif /* LWIP_EVENT_API */ + +/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */ +#if TCP_OVERSIZE && defined(LWIP_DEBUG) +#define TCP_OVERSIZE_DBGCHECK 1 +#else +#define TCP_OVERSIZE_DBGCHECK 0 +#endif + +/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ +#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) + +/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */ +struct tcp_seg { + struct tcp_seg *next; /* used when putting segements on a queue */ + struct pbuf *p; /* buffer containing data + TCP header */ + u16_t len; /* the TCP length of this segment */ +#if TCP_OVERSIZE_DBGCHECK + u16_t oversize_left; /* Extra bytes available at the end of the last + pbuf in unsent (used for asserting vs. + tcp_pcb.unsent_oversized only) */ +#endif /* TCP_OVERSIZE_DBGCHECK */ +#if TCP_CHECKSUM_ON_COPY + u16_t chksum; + u8_t chksum_swapped; +#endif /* TCP_CHECKSUM_ON_COPY */ + u8_t flags; +#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */ +#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */ +#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is + checksummed into 'chksum' */ + struct tcp_hdr *tcphdr; /* the TCP header */ +}; + +#define LWIP_TCP_OPT_LENGTH(flags) \ + (flags & TF_SEG_OPTS_MSS ? 4 : 0) + \ + (flags & TF_SEG_OPTS_TS ? 12 : 0) + +/** This returns a TCP header option for MSS in an u32_t */ +#define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF)) + +/* Global variables: */ +extern struct tcp_pcb *tcp_input_pcb; +extern u32_t tcp_ticks; +extern u8_t tcp_active_pcbs_changed; + +/* The TCP PCB lists. */ +union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ + struct tcp_pcb_listen *listen_pcbs; + struct tcp_pcb *pcbs; +}; +extern struct tcp_pcb *tcp_bound_pcbs; +extern union tcp_listen_pcbs_t tcp_listen_pcbs; +extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a + state in which they accept or send + data. */ +extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ + +extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */ + +/* Axioms about the above lists: + 1) Every TCP PCB that is not CLOSED is in one of the lists. + 2) A PCB is only in one of the lists. + 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. + 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. +*/ +/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB + with a PCB list or removes a PCB from a list, respectively. */ +#ifndef TCP_DEBUG_PCB_LISTS +#define TCP_DEBUG_PCB_LISTS 0 +#endif +#if TCP_DEBUG_PCB_LISTS +#define TCP_REG(pcbs, npcb) do {\ + LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \ + for(tcp_tmp_pcb = *(pcbs); \ + tcp_tmp_pcb != NULL; \ + tcp_tmp_pcb = tcp_tmp_pcb->next) { \ + LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \ + } \ + LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \ + (npcb)->next = *(pcbs); \ + LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \ + *(pcbs) = (npcb); \ + LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ + tcp_timer_needed(); \ + } while(0) +#define TCP_RMV(pcbs, npcb) do { \ + LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \ + LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \ + if(*(pcbs) == (npcb)) { \ + *(pcbs) = (*pcbs)->next; \ + } else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ + if(tcp_tmp_pcb->next == (npcb)) { \ + tcp_tmp_pcb->next = (npcb)->next; \ + break; \ + } \ + } \ + (npcb)->next = NULL; \ + LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ + LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \ + } while(0) + +#else /* LWIP_DEBUG */ + +#define TCP_REG(pcbs, npcb) \ + do { \ + (npcb)->next = *pcbs; \ + *(pcbs) = (npcb); \ + tcp_timer_needed(); \ + } while (0) + +#define TCP_RMV(pcbs, npcb) \ + do { \ + if(*(pcbs) == (npcb)) { \ + (*(pcbs)) = (*pcbs)->next; \ + } \ + else { \ + for(tcp_tmp_pcb = *pcbs; \ + tcp_tmp_pcb != NULL; \ + tcp_tmp_pcb = tcp_tmp_pcb->next) { \ + if(tcp_tmp_pcb->next == (npcb)) { \ + tcp_tmp_pcb->next = (npcb)->next; \ + break; \ + } \ + } \ + } \ + (npcb)->next = NULL; \ + } while(0) + +#endif /* LWIP_DEBUG */ + +#define TCP_REG_ACTIVE(npcb) \ + do { \ + TCP_REG(&tcp_active_pcbs, npcb); \ + tcp_active_pcbs_changed = 1; \ + } while (0) + +#define TCP_RMV_ACTIVE(npcb) \ + do { \ + TCP_RMV(&tcp_active_pcbs, npcb); \ + tcp_active_pcbs_changed = 1; \ + } while (0) + +#define TCP_PCB_REMOVE_ACTIVE(pcb) \ + do { \ + tcp_pcb_remove(&tcp_active_pcbs, pcb); \ + tcp_active_pcbs_changed = 1; \ + } while (0) + + +/* Internal functions: */ +struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); +void tcp_pcb_purge(struct tcp_pcb *pcb); +void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); + +void tcp_segs_free(struct tcp_seg *seg); +void tcp_seg_free(struct tcp_seg *seg); +struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); + +#define tcp_ack(pcb) \ + do { \ + if((pcb)->flags & TF_ACK_DELAY) { \ + (pcb)->flags &= ~TF_ACK_DELAY; \ + (pcb)->flags |= TF_ACK_NOW; \ + } \ + else { \ + (pcb)->flags |= TF_ACK_DELAY; \ + } \ + } while (0) + +#define tcp_ack_now(pcb) \ + do { \ + (pcb)->flags |= TF_ACK_NOW; \ + } while (0) + +err_t tcp_send_fin(struct tcp_pcb *pcb); +err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags); + +void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); + +void tcp_rst(u32_t seqno, u32_t ackno, + ip_addr_t *local_ip, ip_addr_t *remote_ip, + u16_t local_port, u16_t remote_port); + +u32_t tcp_next_iss(void); + +void tcp_keepalive(struct tcp_pcb *pcb); +void tcp_zero_window_probe(struct tcp_pcb *pcb); + +#if TCP_CALCULATE_EFF_SEND_MSS +u16_t tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr); +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + +#if LWIP_CALLBACK_API +err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); +#endif /* LWIP_CALLBACK_API */ + +#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG +void tcp_debug_print(struct tcp_hdr *tcphdr); +void tcp_debug_print_flags(u8_t flags); +void tcp_debug_print_state(enum tcp_state s); +void tcp_debug_print_pcbs(void); +s16_t tcp_pcbs_sane(void); +#else +# define tcp_debug_print(tcphdr) +# define tcp_debug_print_flags(flags) +# define tcp_debug_print_state(s) +# define tcp_debug_print_pcbs() +# define tcp_pcbs_sane() 1 +#endif /* TCP_DEBUG */ + +/** External function (implemented in timers.c), called when TCP detects + * that a timer is needed (i.e. active- or time-wait-pcb found). */ +void tcp_timer_needed(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_TCP */ + +#endif /* __LWIP_TCP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/tcpip.h b/user/mpy/lib/lwip/src/include/lwip/tcpip.h new file mode 100644 index 0000000..637476e --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/tcpip.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_TCPIP_H__ +#define __LWIP_TCPIP_H__ + +#include "lwip/opt.h" + +#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/api_msg.h" +#include "lwip/netifapi.h" +#include "lwip/pbuf.h" +#include "lwip/api.h" +#include "lwip/sys.h" +#include "lwip/timers.h" +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Define this to something that triggers a watchdog. This is called from + * tcpip_thread after processing a message. */ +#ifndef LWIP_TCPIP_THREAD_ALIVE +#define LWIP_TCPIP_THREAD_ALIVE() +#endif + +#if LWIP_TCPIP_CORE_LOCKING +/** The global semaphore to lock the stack. */ +extern sys_mutex_t lock_tcpip_core; +#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core) +#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core) +#define TCPIP_APIMSG(m) tcpip_apimsg_lock(m) +#define TCPIP_APIMSG_ACK(m) +#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m) +#define TCPIP_NETIFAPI_ACK(m) +#else /* LWIP_TCPIP_CORE_LOCKING */ +#define LOCK_TCPIP_CORE() +#define UNLOCK_TCPIP_CORE() +#define TCPIP_APIMSG(m) tcpip_apimsg(m) +#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed) +#define TCPIP_NETIFAPI(m) tcpip_netifapi(m) +#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem) +#endif /* LWIP_TCPIP_CORE_LOCKING */ + +/** Function prototype for the init_done function passed to tcpip_init */ +typedef void (*tcpip_init_done_fn)(void *arg); +/** Function prototype for functions passed to tcpip_callback() */ +typedef void (*tcpip_callback_fn)(void *ctx); + +/* Forward declarations */ +struct tcpip_callback_msg; + +void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); + +#if LWIP_NETCONN +err_t tcpip_apimsg(struct api_msg *apimsg); +#if LWIP_TCPIP_CORE_LOCKING +err_t tcpip_apimsg_lock(struct api_msg *apimsg); +#endif /* LWIP_TCPIP_CORE_LOCKING */ +#endif /* LWIP_NETCONN */ + +err_t tcpip_input(struct pbuf *p, struct netif *inp); + +#if LWIP_NETIF_API +err_t tcpip_netifapi(struct netifapi_msg *netifapimsg); +#if LWIP_TCPIP_CORE_LOCKING +err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg); +#endif /* LWIP_TCPIP_CORE_LOCKING */ +#endif /* LWIP_NETIF_API */ + +err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); +#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) + +struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx); +void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg); +err_t tcpip_trycallback(struct tcpip_callback_msg* msg); + +/* free pbufs or heap memory from another context without blocking */ +err_t pbuf_free_callback(struct pbuf *p); +err_t mem_free_callback(void *m); + +#if LWIP_TCPIP_TIMEOUT +err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); +err_t tcpip_untimeout(sys_timeout_handler h, void *arg); +#endif /* LWIP_TCPIP_TIMEOUT */ + +enum tcpip_msg_type { +#if LWIP_NETCONN + TCPIP_MSG_API, +#endif /* LWIP_NETCONN */ + TCPIP_MSG_INPKT, +#if LWIP_NETIF_API + TCPIP_MSG_NETIFAPI, +#endif /* LWIP_NETIF_API */ +#if LWIP_TCPIP_TIMEOUT + TCPIP_MSG_TIMEOUT, + TCPIP_MSG_UNTIMEOUT, +#endif /* LWIP_TCPIP_TIMEOUT */ + TCPIP_MSG_CALLBACK, + TCPIP_MSG_CALLBACK_STATIC +}; + +struct tcpip_msg { + enum tcpip_msg_type type; + sys_sem_t *sem; + union { +#if LWIP_NETCONN + struct api_msg *apimsg; +#endif /* LWIP_NETCONN */ +#if LWIP_NETIF_API + struct netifapi_msg *netifapimsg; +#endif /* LWIP_NETIF_API */ + struct { + struct pbuf *p; + struct netif *netif; + } inp; + struct { + tcpip_callback_fn function; + void *ctx; + } cb; +#if LWIP_TCPIP_TIMEOUT + struct { + u32_t msecs; + sys_timeout_handler h; + void *arg; + } tmo; +#endif /* LWIP_TCPIP_TIMEOUT */ + } msg; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* !NO_SYS */ + +#endif /* __LWIP_TCPIP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/timers.h b/user/mpy/lib/lwip/src/include/lwip/timers.h new file mode 100644 index 0000000..04e78e0 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/timers.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * Simon Goldschmidt + * + */ +#ifndef __LWIP_TIMERS_H__ +#define __LWIP_TIMERS_H__ + +#include "lwip/opt.h" + +/* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ +#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) + +#if LWIP_TIMERS + +#include "lwip/err.h" +#if !NO_SYS +#include "lwip/sys.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef LWIP_DEBUG_TIMERNAMES +#ifdef LWIP_DEBUG +#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG +#else /* LWIP_DEBUG */ +#define LWIP_DEBUG_TIMERNAMES 0 +#endif /* LWIP_DEBUG*/ +#endif + +/** Function prototype for a timeout callback function. Register such a function + * using sys_timeout(). + * + * @param arg Additional argument to pass to the function - set up by sys_timeout() + */ +typedef void (* sys_timeout_handler)(void *arg); + +struct sys_timeo { + struct sys_timeo *next; + u32_t time; + sys_timeout_handler h; + void *arg; +#if LWIP_DEBUG_TIMERNAMES + const char* handler_name; +#endif /* LWIP_DEBUG_TIMERNAMES */ +}; + +void sys_timeouts_init(void); + +#if LWIP_DEBUG_TIMERNAMES +void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); +#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) +#else /* LWIP_DEBUG_TIMERNAMES */ +void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); +#endif /* LWIP_DEBUG_TIMERNAMES */ + +void sys_untimeout(sys_timeout_handler handler, void *arg); +#if NO_SYS +void sys_check_timeouts(void); +void sys_restart_timeouts(void); +#else /* NO_SYS */ +void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); +#endif /* NO_SYS */ + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_TIMERS */ +#endif /* __LWIP_TIMERS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/udp.h b/user/mpy/lib/lwip/src/include/lwip/udp.h new file mode 100644 index 0000000..f1e6d3f --- /dev/null +++ b/user/mpy/lib/lwip/src/include/lwip/udp.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __LWIP_UDP_H__ +#define __LWIP_UDP_H__ + +#include "lwip/opt.h" + +#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/pbuf.h" +#include "lwip/netif.h" +#include "lwip/ip_addr.h" +#include "lwip/ip.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define UDP_HLEN 8 + +/* Fields are (of course) in network byte order. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct udp_hdr { + PACK_STRUCT_FIELD(u16_t src); + PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ + PACK_STRUCT_FIELD(u16_t len); + PACK_STRUCT_FIELD(u16_t chksum); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define UDP_FLAGS_NOCHKSUM 0x01U +#define UDP_FLAGS_UDPLITE 0x02U +#define UDP_FLAGS_CONNECTED 0x04U +#define UDP_FLAGS_MULTICAST_LOOP 0x08U + +struct udp_pcb; + +/** Function prototype for udp pcb receive callback functions + * addr and port are in same byte order as in the pcb + * The callback is responsible for freeing the pbuf + * if it's not used any more. + * + * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf + * makes 'addr' invalid, too. + * + * @param arg user supplied argument (udp_pcb.recv_arg) + * @param pcb the udp_pcb which received data + * @param p the packet buffer that was received + * @param addr the remote IP address from which the packet was received + * @param port the remote port from which the packet was received + */ +typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *addr, u16_t port); + + +struct udp_pcb { +/* Common members of all PCB types */ + IP_PCB; + +/* Protocol specific PCB members */ + + struct udp_pcb *next; + + u8_t flags; + /** ports are in host byte order */ + u16_t local_port, remote_port; + +#if LWIP_IGMP + /** outgoing network interface for multicast packets */ + ip_addr_t multicast_ip; +#endif /* LWIP_IGMP */ + +#if LWIP_UDPLITE + /** used for UDP_LITE only */ + u16_t chksum_len_rx, chksum_len_tx; +#endif /* LWIP_UDPLITE */ + + /** receive callback function */ + udp_recv_fn recv; + /** user-supplied argument for the recv callback */ + void *recv_arg; +}; +/* udp_pcbs export for exernal reference (e.g. SNMP agent) */ +extern struct udp_pcb *udp_pcbs; + +/* The following functions is the application layer interface to the + UDP code. */ +struct udp_pcb * udp_new (void); +void udp_remove (struct udp_pcb *pcb); +err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port); +err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr, + u16_t port); +void udp_disconnect (struct udp_pcb *pcb); +void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, + void *recv_arg); +err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *dst_ip, u16_t dst_port, + struct netif *netif); +err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *dst_ip, u16_t dst_port); +err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); + +#if LWIP_CHECKSUM_ON_COPY +err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *dst_ip, u16_t dst_port, + struct netif *netif, u8_t have_chksum, + u16_t chksum); +err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, + ip_addr_t *dst_ip, u16_t dst_port, + u8_t have_chksum, u16_t chksum); +err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, + u8_t have_chksum, u16_t chksum); +#endif /* LWIP_CHECKSUM_ON_COPY */ + +#define udp_flags(pcb) ((pcb)->flags) +#define udp_setflags(pcb, f) ((pcb)->flags = (f)) + +/* The following functions are the lower layer interface to UDP. */ +void udp_input (struct pbuf *p, struct netif *inp); + +void udp_init (void); + +#if UDP_DEBUG +void udp_debug_print(struct udp_hdr *udphdr); +#else +#define udp_debug_print(udphdr) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_UDP */ + +#endif /* __LWIP_UDP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/netif/etharp.h b/user/mpy/lib/lwip/src/include/netif/etharp.h new file mode 100644 index 0000000..859608d --- /dev/null +++ b/user/mpy/lib/lwip/src/include/netif/etharp.h @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * Copyright (c) 2003-2004 Leon Woestenberg + * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#ifndef __NETIF_ETHARP_H__ +#define __NETIF_ETHARP_H__ + +#include "lwip/opt.h" + +#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/pbuf.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" +#include "lwip/ip.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ETHARP_HWADDR_LEN +#define ETHARP_HWADDR_LEN 6 +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct eth_addr { + PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** Ethernet header */ +struct eth_hdr { +#if ETH_PAD_SIZE + PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); +#endif + PACK_STRUCT_FIELD(struct eth_addr dest); + PACK_STRUCT_FIELD(struct eth_addr src); + PACK_STRUCT_FIELD(u16_t type); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE) + +#if ETHARP_SUPPORT_VLAN + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** VLAN header inserted between ethernet header and payload + * if 'type' in ethernet header is ETHTYPE_VLAN. + * See IEEE802.Q */ +struct eth_vlan_hdr { + PACK_STRUCT_FIELD(u16_t prio_vid); + PACK_STRUCT_FIELD(u16_t tpid); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define SIZEOF_VLAN_HDR 4 +#define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF) + +#endif /* ETHARP_SUPPORT_VLAN */ + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** the ARP message, see RFC 826 ("Packet format") */ +struct etharp_hdr { + PACK_STRUCT_FIELD(u16_t hwtype); + PACK_STRUCT_FIELD(u16_t proto); + PACK_STRUCT_FIELD(u8_t hwlen); + PACK_STRUCT_FIELD(u8_t protolen); + PACK_STRUCT_FIELD(u16_t opcode); + PACK_STRUCT_FIELD(struct eth_addr shwaddr); + PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); + PACK_STRUCT_FIELD(struct eth_addr dhwaddr); + PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define SIZEOF_ETHARP_HDR 28 +#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR) + +/** 5 seconds period */ +#define ARP_TMR_INTERVAL 5000 + +#define ETHTYPE_ARP 0x0806U +#define ETHTYPE_IP 0x0800U +#define ETHTYPE_VLAN 0x8100U +#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */ +#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */ + +/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables + * or known to be 32-bit aligned within the protocol header. */ +#ifndef ETHADDR32_COPY +#define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) +#endif + +/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local + * variables and known to be 16-bit aligned within the protocol header. */ +#ifndef ETHADDR16_COPY +#define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) +#endif + +#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ + +/** ARP message types (opcodes) */ +#define ARP_REQUEST 1 +#define ARP_REPLY 2 + +/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) + * to a filter function that returns the correct netif when using multiple + * netifs on one hardware interface where the netif's low-level receive + * routine cannot decide for the correct netif (e.g. when mapping multiple + * IP addresses to one hardware interface). + */ +#ifndef LWIP_ARP_FILTER_NETIF +#define LWIP_ARP_FILTER_NETIF 0 +#endif + +#if ARP_QUEUEING +/** struct for queueing outgoing packets for unknown address + * defined here to be accessed by memp.h + */ +struct etharp_q_entry { + struct etharp_q_entry *next; + struct pbuf *p; +}; +#endif /* ARP_QUEUEING */ + +#define etharp_init() /* Compatibility define, not init needed. */ +void etharp_tmr(void); +s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, + struct eth_addr **eth_ret, ip_addr_t **ip_ret); +err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr); +err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q); +err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr); +/** For Ethernet network interfaces, we might want to send "gratuitous ARP"; + * this is an ARP packet sent by a node in order to spontaneously cause other + * nodes to update an entry in their ARP cache. + * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ +#define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) +void etharp_cleanup_netif(struct netif *netif); + +#if ETHARP_SUPPORT_STATIC_ENTRIES +err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr); +err_t etharp_remove_static_entry(ip_addr_t *ipaddr); +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + +#if LWIP_AUTOIP +err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, + const struct eth_addr *ethdst_addr, + const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr, + const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr, + const u16_t opcode); +#endif /* LWIP_AUTOIP */ + +#endif /* LWIP_ARP */ + +err_t ethernet_input(struct pbuf *p, struct netif *netif); + +#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0) + +extern const struct eth_addr ethbroadcast, ethzero; + +#endif /* LWIP_ARP || LWIP_ETHERNET */ + +#ifdef __cplusplus +} +#endif + +#endif /* __NETIF_ARP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/netif/ppp_oe.h b/user/mpy/lib/lwip/src/include/netif/ppp_oe.h new file mode 100644 index 0000000..e1cdfa5 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/netif/ppp_oe.h @@ -0,0 +1,190 @@ +/***************************************************************************** +* ppp_oe.h - PPP Over Ethernet implementation for lwIP. +* +* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 06-01-01 Marc Boucher +* Ported to lwIP. +*****************************************************************************/ + + + +/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Martin Husemann . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PPP_OE_H +#define PPP_OE_H + +#include "lwip/opt.h" + +#if PPPOE_SUPPORT > 0 + +#include "netif/etharp.h" + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct pppoehdr { + PACK_STRUCT_FIELD(u8_t vertype); + PACK_STRUCT_FIELD(u8_t code); + PACK_STRUCT_FIELD(u16_t session); + PACK_STRUCT_FIELD(u16_t plen); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct pppoetag { + PACK_STRUCT_FIELD(u16_t tag); + PACK_STRUCT_FIELD(u16_t len); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + + +#define PPPOE_STATE_INITIAL 0 +#define PPPOE_STATE_PADI_SENT 1 +#define PPPOE_STATE_PADR_SENT 2 +#define PPPOE_STATE_SESSION 3 +#define PPPOE_STATE_CLOSING 4 +/* passive */ +#define PPPOE_STATE_PADO_SENT 1 + +#define PPPOE_HEADERLEN sizeof(struct pppoehdr) +#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ + +#define PPPOE_TAG_EOL 0x0000 /* end of list */ +#define PPPOE_TAG_SNAME 0x0101 /* service name */ +#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ +#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ +#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ +#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ +#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ +#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ +#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ +#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ + +#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ +#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ +#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ +#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ +#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ + +#ifndef ETHERMTU +#define ETHERMTU 1500 +#endif + +/* two byte PPP protocol discriminator, then IP data */ +#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2) + +#ifndef PPPOE_MAX_AC_COOKIE_LEN +#define PPPOE_MAX_AC_COOKIE_LEN 64 +#endif + +struct pppoe_softc { + struct pppoe_softc *next; + struct netif *sc_ethif; /* ethernet interface we are using */ + int sc_pd; /* ppp unit number */ + void (*sc_linkStatusCB)(int pd, int up); + + int sc_state; /* discovery phase or session connected */ + struct eth_addr sc_dest; /* hardware address of concentrator */ + u16_t sc_session; /* PPPoE session id */ + +#ifdef PPPOE_TODO + char *sc_service_name; /* if != NULL: requested name of service */ + char *sc_concentrator_name; /* if != NULL: requested concentrator id */ +#endif /* PPPOE_TODO */ + u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */ + size_t sc_ac_cookie_len; /* length of cookie data */ +#ifdef PPPOE_SERVER + u8_t *sc_hunique; /* content of host unique we must echo back */ + size_t sc_hunique_len; /* length of host unique */ +#endif + int sc_padi_retried; /* number of PADI retries already done */ + int sc_padr_retried; /* number of PADR retries already done */ +}; + + +#define pppoe_init() /* compatibility define, no initialization needed */ + +err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr); +err_t pppoe_destroy(struct netif *ifp); + +int pppoe_connect(struct pppoe_softc *sc); +void pppoe_disconnect(struct pppoe_softc *sc); + +void pppoe_disc_input(struct netif *netif, struct pbuf *p); +void pppoe_data_input(struct netif *netif, struct pbuf *p); + +err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb); + +/** used in ppp.c */ +#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN) + +#endif /* PPPOE_SUPPORT */ + +#endif /* PPP_OE_H */ diff --git a/user/mpy/lib/lwip/src/include/netif/slipif.h b/user/mpy/lib/lwip/src/include/netif/slipif.h new file mode 100644 index 0000000..7b6ce5e --- /dev/null +++ b/user/mpy/lib/lwip/src/include/netif/slipif.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __NETIF_SLIPIF_H__ +#define __NETIF_SLIPIF_H__ + +#include "lwip/opt.h" +#include "lwip/netif.h" + +/** Set this to 1 to start a thread that blocks reading on the serial line + * (using sio_read()). + */ +#ifndef SLIP_USE_RX_THREAD +#define SLIP_USE_RX_THREAD !NO_SYS +#endif + +/** Set this to 1 to enable functions to pass in RX bytes from ISR context. + * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled + * packets on a queue, which is fed into lwIP from slipif_poll(). + * If disabled, slipif_poll() polls the serila line (using sio_tryread()). + */ +#ifndef SLIP_RX_FROM_ISR +#define SLIP_RX_FROM_ISR 0 +#endif + +/** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets + * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. + * If disabled, packets will be dropped if more than one packet is received. + */ +#ifndef SLIP_RX_QUEUE +#define SLIP_RX_QUEUE SLIP_RX_FROM_ISR +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +err_t slipif_init(struct netif * netif); +void slipif_poll(struct netif *netif); +#if SLIP_RX_FROM_ISR +void slipif_process_rxqueue(struct netif *netif); +void slipif_received_byte(struct netif *netif, u8_t data); +void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); +#endif /* SLIP_RX_FROM_ISR */ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/user/mpy/lib/lwip/src/include/posix/netdb.h b/user/mpy/lib/lwip/src/include/posix/netdb.h new file mode 100644 index 0000000..7134032 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/posix/netdb.h @@ -0,0 +1,33 @@ +/** + * @file + * This file is a posix wrapper for lwip/netdb.h. + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#include "lwip/netdb.h" diff --git a/user/mpy/lib/lwip/src/include/posix/sys/socket.h b/user/mpy/lib/lwip/src/include/posix/sys/socket.h new file mode 100644 index 0000000..f7c7066 --- /dev/null +++ b/user/mpy/lib/lwip/src/include/posix/sys/socket.h @@ -0,0 +1,33 @@ +/** + * @file + * This file is a posix wrapper for lwip/sockets.h. + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#include "lwip/sockets.h" diff --git a/user/mpy/lib/lwip/src/netif/FILES b/user/mpy/lib/lwip/src/netif/FILES new file mode 100644 index 0000000..099dbf3 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/FILES @@ -0,0 +1,29 @@ +This directory contains generic network interface device drivers that +do not contain any hardware or architecture specific code. The files +are: + +etharp.c + Implements the ARP (Address Resolution Protocol) over + Ethernet. The code in this file should be used together with + Ethernet device drivers. Note that this module has been + largely made Ethernet independent so you should be able to + adapt this for other link layers (such as Firewire). + +ethernetif.c + An example of how an Ethernet device driver could look. This + file can be used as a "skeleton" for developing new Ethernet + network device drivers. It uses the etharp.c ARP code. + +loopif.c + A "loopback" network interface driver. It requires configuration + through the define LWIP_LOOPIF_MULTITHREADING (see opt.h). + +slipif.c + A generic implementation of the SLIP (Serial Line IP) + protocol. It requires a sio (serial I/O) module to work. + +ppp/ Point-to-Point Protocol stack + The PPP stack has been ported from ucip (http://ucip.sourceforge.net). + It matches quite well to pppd 2.3.1 (http://ppp.samba.org), although + compared to that, it has some modifications for embedded systems and + the source code has been reordered a bit. \ No newline at end of file diff --git a/user/mpy/lib/lwip/src/netif/etharp.c b/user/mpy/lib/lwip/src/netif/etharp.c new file mode 100644 index 0000000..5e382d1 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/etharp.c @@ -0,0 +1,1399 @@ +/** + * @file + * Address Resolution Protocol module for IP over Ethernet + * + * Functionally, ARP is divided into two parts. The first maps an IP address + * to a physical address when sending a packet, and the second part answers + * requests from other machines for our physical address. + * + * This implementation complies with RFC 826 (Ethernet ARP). It supports + * Gratuitious ARP from RFC3220 (IP Mobility Support for IPv4) section 4.6 + * if an interface calls etharp_gratuitous(our_netif) upon address change. + */ + +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * Copyright (c) 2003-2004 Leon Woestenberg + * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#include "lwip/opt.h" + +#if LWIP_ARP || LWIP_ETHERNET + +#include "lwip/ip_addr.h" +#include "lwip/def.h" +#include "lwip/ip.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" +#include "lwip/dhcp.h" +#include "lwip/autoip.h" +#include "netif/etharp.h" + +#if PPPOE_SUPPORT +#include "netif/ppp_oe.h" +#endif /* PPPOE_SUPPORT */ + +#include + +const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; +const struct eth_addr ethzero = {{0,0,0,0,0,0}}; + +/** The 24-bit IANA multicast OUI is 01-00-5e: */ +#define LL_MULTICAST_ADDR_0 0x01 +#define LL_MULTICAST_ADDR_1 0x00 +#define LL_MULTICAST_ADDR_2 0x5e + +#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ + +/** the time an ARP entry stays valid after its last update, + * for ARP_TMR_INTERVAL = 5000, this is + * (240 * 5) seconds = 20 minutes. + */ +#define ARP_MAXAGE 240 +/** Re-request a used ARP entry 1 minute before it would expire to prevent + * breaking a steadily used connection because the ARP entry timed out. */ +#define ARP_AGE_REREQUEST_USED (ARP_MAXAGE - 12) + +/** the time an ARP entry stays pending after first request, + * for ARP_TMR_INTERVAL = 5000, this is + * (2 * 5) seconds = 10 seconds. + * + * @internal Keep this number at least 2, otherwise it might + * run out instantly if the timeout occurs directly after a request. + */ +#define ARP_MAXPENDING 2 + +#define HWTYPE_ETHERNET 1 + +enum etharp_state { + ETHARP_STATE_EMPTY = 0, + ETHARP_STATE_PENDING, + ETHARP_STATE_STABLE, + ETHARP_STATE_STABLE_REREQUESTING +#if ETHARP_SUPPORT_STATIC_ENTRIES + ,ETHARP_STATE_STATIC +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ +}; + +struct etharp_entry { +#if ARP_QUEUEING + /** Pointer to queue of pending outgoing packets on this ARP entry. */ + struct etharp_q_entry *q; +#else /* ARP_QUEUEING */ + /** Pointer to a single pending outgoing packet on this ARP entry. */ + struct pbuf *q; +#endif /* ARP_QUEUEING */ + ip_addr_t ipaddr; + struct netif *netif; + struct eth_addr ethaddr; + u8_t state; + u8_t ctime; +}; + +static struct etharp_entry arp_table[ARP_TABLE_SIZE]; + +#if !LWIP_NETIF_HWADDRHINT +static u8_t etharp_cached_entry; +#endif /* !LWIP_NETIF_HWADDRHINT */ + +/** Try hard to create a new entry - we want the IP address to appear in + the cache (even if this means removing an active entry or so). */ +#define ETHARP_FLAG_TRY_HARD 1 +#define ETHARP_FLAG_FIND_ONLY 2 +#if ETHARP_SUPPORT_STATIC_ENTRIES +#define ETHARP_FLAG_STATIC_ENTRY 4 +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + +#if LWIP_NETIF_HWADDRHINT +#define ETHARP_SET_HINT(netif, hint) if (((netif) != NULL) && ((netif)->addr_hint != NULL)) \ + *((netif)->addr_hint) = (hint); +#else /* LWIP_NETIF_HWADDRHINT */ +#define ETHARP_SET_HINT(netif, hint) (etharp_cached_entry = (hint)) +#endif /* LWIP_NETIF_HWADDRHINT */ + + +/* Some checks, instead of etharp_init(): */ +#if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f)) + #error "ARP_TABLE_SIZE must fit in an s8_t, you have to reduce it in your lwipopts.h" +#endif + + +#if ARP_QUEUEING +/** + * Free a complete queue of etharp entries + * + * @param q a qeueue of etharp_q_entry's to free + */ +static void +free_etharp_q(struct etharp_q_entry *q) +{ + struct etharp_q_entry *r; + LWIP_ASSERT("q != NULL", q != NULL); + LWIP_ASSERT("q->p != NULL", q->p != NULL); + while (q) { + r = q; + q = q->next; + LWIP_ASSERT("r->p != NULL", (r->p != NULL)); + pbuf_free(r->p); + memp_free(MEMP_ARP_QUEUE, r); + } +} +#else /* ARP_QUEUEING */ + +/** Compatibility define: free the queued pbuf */ +#define free_etharp_q(q) pbuf_free(q) + +#endif /* ARP_QUEUEING */ + +/** Clean up ARP table entries */ +static void +etharp_free_entry(int i) +{ + /* remove from SNMP ARP index tree */ + snmp_delete_arpidx_tree(arp_table[i].netif, &arp_table[i].ipaddr); + /* and empty packet queue */ + if (arp_table[i].q != NULL) { + /* remove all queued packets */ + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_free_entry: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].q))); + free_etharp_q(arp_table[i].q); + arp_table[i].q = NULL; + } + /* recycle entry for re-use */ + arp_table[i].state = ETHARP_STATE_EMPTY; +#ifdef LWIP_DEBUG + /* for debugging, clean out the complete entry */ + arp_table[i].ctime = 0; + arp_table[i].netif = NULL; + ip_addr_set_zero(&arp_table[i].ipaddr); + arp_table[i].ethaddr = ethzero; +#endif /* LWIP_DEBUG */ +} + +/** + * Clears expired entries in the ARP table. + * + * This function should be called every ETHARP_TMR_INTERVAL milliseconds (5 seconds), + * in order to expire entries in the ARP table. + */ +void +etharp_tmr(void) +{ + u8_t i; + + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n")); + /* remove expired entries from the ARP table */ + for (i = 0; i < ARP_TABLE_SIZE; ++i) { + u8_t state = arp_table[i].state; + if (state != ETHARP_STATE_EMPTY +#if ETHARP_SUPPORT_STATIC_ENTRIES + && (state != ETHARP_STATE_STATIC) +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + ) { + arp_table[i].ctime++; + if ((arp_table[i].ctime >= ARP_MAXAGE) || + ((arp_table[i].state == ETHARP_STATE_PENDING) && + (arp_table[i].ctime >= ARP_MAXPENDING))) { + /* pending or stable entry has become old! */ + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired %s entry %"U16_F".\n", + arp_table[i].state >= ETHARP_STATE_STABLE ? "stable" : "pending", (u16_t)i)); + /* clean up entries that have just been expired */ + etharp_free_entry(i); + } + else if (arp_table[i].state == ETHARP_STATE_STABLE_REREQUESTING) { + /* Reset state to stable, so that the next transmitted packet will + re-send an ARP request. */ + arp_table[i].state = ETHARP_STATE_STABLE; + } +#if ARP_QUEUEING + /* still pending entry? (not expired) */ + if (arp_table[i].state == ETHARP_STATE_PENDING) { + /* resend an ARP query here? */ + } +#endif /* ARP_QUEUEING */ + } + } +} + +/** + * Search the ARP table for a matching or new entry. + * + * If an IP address is given, return a pending or stable ARP entry that matches + * the address. If no match is found, create a new entry with this address set, + * but in state ETHARP_EMPTY. The caller must check and possibly change the + * state of the returned entry. + * + * If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY. + * + * In all cases, attempt to create new entries from an empty entry. If no + * empty entries are available and ETHARP_FLAG_TRY_HARD flag is set, recycle + * old entries. Heuristic choose the least important entry for recycling. + * + * @param ipaddr IP address to find in ARP cache, or to add if not found. + * @param flags @see definition of ETHARP_FLAG_* + * @param netif netif related to this address (used for NETIF_HWADDRHINT) + * + * @return The ARP entry index that matched or is created, ERR_MEM if no + * entry is found or could be recycled. + */ +static s8_t +etharp_find_entry(ip_addr_t *ipaddr, u8_t flags) +{ + s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE; + s8_t empty = ARP_TABLE_SIZE; + u8_t i = 0, age_pending = 0, age_stable = 0; + /* oldest entry with packets on queue */ + s8_t old_queue = ARP_TABLE_SIZE; + /* its age */ + u8_t age_queue = 0; + + /** + * a) do a search through the cache, remember candidates + * b) select candidate entry + * c) create new entry + */ + + /* a) in a single search sweep, do all of this + * 1) remember the first empty entry (if any) + * 2) remember the oldest stable entry (if any) + * 3) remember the oldest pending entry without queued packets (if any) + * 4) remember the oldest pending entry with queued packets (if any) + * 5) search for a matching IP entry, either pending or stable + * until 5 matches, or all entries are searched for. + */ + + for (i = 0; i < ARP_TABLE_SIZE; ++i) { + u8_t state = arp_table[i].state; + /* no empty entry found yet and now we do find one? */ + if ((empty == ARP_TABLE_SIZE) && (state == ETHARP_STATE_EMPTY)) { + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_find_entry: found empty entry %"U16_F"\n", (u16_t)i)); + /* remember first empty entry */ + empty = i; + } else if (state != ETHARP_STATE_EMPTY) { + LWIP_ASSERT("state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE", + state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE); + /* if given, does IP address match IP address in ARP entry? */ + if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: found matching entry %"U16_F"\n", (u16_t)i)); + /* found exact IP address match, simply bail out */ + return i; + } + /* pending entry? */ + if (state == ETHARP_STATE_PENDING) { + /* pending with queued packets? */ + if (arp_table[i].q != NULL) { + if (arp_table[i].ctime >= age_queue) { + old_queue = i; + age_queue = arp_table[i].ctime; + } + } else + /* pending without queued packets? */ + { + if (arp_table[i].ctime >= age_pending) { + old_pending = i; + age_pending = arp_table[i].ctime; + } + } + /* stable entry? */ + } else if (state >= ETHARP_STATE_STABLE) { +#if ETHARP_SUPPORT_STATIC_ENTRIES + /* don't record old_stable for static entries since they never expire */ + if (state < ETHARP_STATE_STATIC) +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + { + /* remember entry with oldest stable entry in oldest, its age in maxtime */ + if (arp_table[i].ctime >= age_stable) { + old_stable = i; + age_stable = arp_table[i].ctime; + } + } + } + } + } + /* { we have no match } => try to create a new entry */ + + /* don't create new entry, only search? */ + if (((flags & ETHARP_FLAG_FIND_ONLY) != 0) || + /* or no empty entry found and not allowed to recycle? */ + ((empty == ARP_TABLE_SIZE) && ((flags & ETHARP_FLAG_TRY_HARD) == 0))) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: no empty entry found and not allowed to recycle\n")); + return (s8_t)ERR_MEM; + } + + /* b) choose the least destructive entry to recycle: + * 1) empty entry + * 2) oldest stable entry + * 3) oldest pending entry without queued packets + * 4) oldest pending entry with queued packets + * + * { ETHARP_FLAG_TRY_HARD is set at this point } + */ + + /* 1) empty entry available? */ + if (empty < ARP_TABLE_SIZE) { + i = empty; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting empty entry %"U16_F"\n", (u16_t)i)); + } else { + /* 2) found recyclable stable entry? */ + if (old_stable < ARP_TABLE_SIZE) { + /* recycle oldest stable*/ + i = old_stable; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i)); + /* no queued packets should exist on stable entries */ + LWIP_ASSERT("arp_table[i].q == NULL", arp_table[i].q == NULL); + /* 3) found recyclable pending entry without queued packets? */ + } else if (old_pending < ARP_TABLE_SIZE) { + /* recycle oldest pending */ + i = old_pending; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i)); + /* 4) found recyclable pending entry with queued packets? */ + } else if (old_queue < ARP_TABLE_SIZE) { + /* recycle oldest pending (queued packets are free in etharp_free_entry) */ + i = old_queue; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q))); + /* no empty or recyclable entries found */ + } else { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: no empty or recyclable entries found\n")); + return (s8_t)ERR_MEM; + } + + /* { empty or recyclable entry found } */ + LWIP_ASSERT("i < ARP_TABLE_SIZE", i < ARP_TABLE_SIZE); + etharp_free_entry(i); + } + + LWIP_ASSERT("i < ARP_TABLE_SIZE", i < ARP_TABLE_SIZE); + LWIP_ASSERT("arp_table[i].state == ETHARP_STATE_EMPTY", + arp_table[i].state == ETHARP_STATE_EMPTY); + + /* IP address given? */ + if (ipaddr != NULL) { + /* set IP address */ + ip_addr_copy(arp_table[i].ipaddr, *ipaddr); + } + arp_table[i].ctime = 0; + return (err_t)i; +} + +/** + * Send an IP packet on the network using netif->linkoutput + * The ethernet header is filled in before sending. + * + * @params netif the lwIP network interface on which to send the packet + * @params p the packet to send, p->payload pointing to the (uninitialized) ethernet header + * @params src the source MAC address to be copied into the ethernet header + * @params dst the destination MAC address to be copied into the ethernet header + * @return ERR_OK if the packet was sent, any other err_t on failure + */ +static err_t +etharp_send_ip(struct netif *netif, struct pbuf *p, struct eth_addr *src, struct eth_addr *dst) +{ + struct eth_hdr *ethhdr = (struct eth_hdr *)p->payload; + + LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!", + (netif->hwaddr_len == ETHARP_HWADDR_LEN)); + ETHADDR32_COPY(ðhdr->dest, dst); + ETHADDR16_COPY(ðhdr->src, src); + ethhdr->type = PP_HTONS(ETHTYPE_IP); + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_send_ip: sending packet %p\n", (void *)p)); + /* send the packet */ + return netif->linkoutput(netif, p); +} + +/** + * Update (or insert) a IP/MAC address pair in the ARP cache. + * + * If a pending entry is resolved, any queued packets will be sent + * at this point. + * + * @param netif netif related to this entry (used for NETIF_ADDRHINT) + * @param ipaddr IP address of the inserted ARP entry. + * @param ethaddr Ethernet address of the inserted ARP entry. + * @param flags @see definition of ETHARP_FLAG_* + * + * @return + * - ERR_OK Succesfully updated ARP cache. + * - ERR_MEM If we could not add a new ARP entry when ETHARP_FLAG_TRY_HARD was set. + * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. + * + * @see pbuf_free() + */ +static err_t +etharp_update_arp_entry(struct netif *netif, ip_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags) +{ + s8_t i; + LWIP_ASSERT("netif->hwaddr_len == ETHARP_HWADDR_LEN", netif->hwaddr_len == ETHARP_HWADDR_LEN); + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n", + ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr), + ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], + ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); + /* non-unicast address? */ + if (ip_addr_isany(ipaddr) || + ip_addr_isbroadcast(ipaddr, netif) || + ip_addr_ismulticast(ipaddr)) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: will not add non-unicast IP address to ARP cache\n")); + return ERR_ARG; + } + /* find or create ARP entry */ + i = etharp_find_entry(ipaddr, flags); + /* bail out if no entry could be found */ + if (i < 0) { + return (err_t)i; + } + +#if ETHARP_SUPPORT_STATIC_ENTRIES + if (flags & ETHARP_FLAG_STATIC_ENTRY) { + /* record static type */ + arp_table[i].state = ETHARP_STATE_STATIC; + } else +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + { + /* mark it stable */ + arp_table[i].state = ETHARP_STATE_STABLE; + } + + /* record network interface */ + arp_table[i].netif = netif; + /* insert in SNMP ARP index tree */ + snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr); + + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i)); + /* update address */ + ETHADDR32_COPY(&arp_table[i].ethaddr, ethaddr); + /* reset time stamp */ + arp_table[i].ctime = 0; + /* this is where we will send out queued packets! */ +#if ARP_QUEUEING + while (arp_table[i].q != NULL) { + struct pbuf *p; + /* remember remainder of queue */ + struct etharp_q_entry *q = arp_table[i].q; + /* pop first item off the queue */ + arp_table[i].q = q->next; + /* get the packet pointer */ + p = q->p; + /* now queue entry can be freed */ + memp_free(MEMP_ARP_QUEUE, q); +#else /* ARP_QUEUEING */ + if (arp_table[i].q != NULL) { + struct pbuf *p = arp_table[i].q; + arp_table[i].q = NULL; +#endif /* ARP_QUEUEING */ + /* send the queued IP packet */ + etharp_send_ip(netif, p, (struct eth_addr*)(netif->hwaddr), ethaddr); + /* free the queued IP packet */ + pbuf_free(p); + } + return ERR_OK; +} + +#if ETHARP_SUPPORT_STATIC_ENTRIES +/** Add a new static entry to the ARP table. If an entry exists for the + * specified IP address, this entry is overwritten. + * If packets are queued for the specified IP address, they are sent out. + * + * @param ipaddr IP address for the new static entry + * @param ethaddr ethernet address for the new static entry + * @return @see return values of etharp_add_static_entry + */ +err_t +etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr) +{ + struct netif *netif; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_add_static_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n", + ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr), + ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], + ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); + + netif = ip_route(ipaddr); + if (netif == NULL) { + return ERR_RTE; + } + + return etharp_update_arp_entry(netif, ipaddr, ethaddr, ETHARP_FLAG_TRY_HARD | ETHARP_FLAG_STATIC_ENTRY); +} + +/** Remove a static entry from the ARP table previously added with a call to + * etharp_add_static_entry. + * + * @param ipaddr IP address of the static entry to remove + * @return ERR_OK: entry removed + * ERR_MEM: entry wasn't found + * ERR_ARG: entry wasn't a static entry but a dynamic one + */ +err_t +etharp_remove_static_entry(ip_addr_t *ipaddr) +{ + s8_t i; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_remove_static_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", + ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr))); + + /* find or create ARP entry */ + i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY); + /* bail out if no entry could be found */ + if (i < 0) { + return (err_t)i; + } + + if (arp_table[i].state != ETHARP_STATE_STATIC) { + /* entry wasn't a static entry, cannot remove it */ + return ERR_ARG; + } + /* entry found, free it */ + etharp_free_entry(i); + return ERR_OK; +} +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + +/** + * Remove all ARP table entries of the specified netif. + * + * @param netif points to a network interface + */ +void etharp_cleanup_netif(struct netif *netif) +{ + u8_t i; + + for (i = 0; i < ARP_TABLE_SIZE; ++i) { + u8_t state = arp_table[i].state; + if ((state != ETHARP_STATE_EMPTY) && (arp_table[i].netif == netif)) { + etharp_free_entry(i); + } + } +} + +/** + * Finds (stable) ethernet/IP address pair from ARP table + * using interface and IP address index. + * @note the addresses in the ARP table are in network order! + * + * @param netif points to interface index + * @param ipaddr points to the (network order) IP address index + * @param eth_ret points to return pointer + * @param ip_ret points to return pointer + * @return table index if found, -1 otherwise + */ +s8_t +etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, + struct eth_addr **eth_ret, ip_addr_t **ip_ret) +{ + s8_t i; + + LWIP_ASSERT("eth_ret != NULL && ip_ret != NULL", + eth_ret != NULL && ip_ret != NULL); + + LWIP_UNUSED_ARG(netif); + + i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY); + if((i >= 0) && (arp_table[i].state >= ETHARP_STATE_STABLE)) { + *eth_ret = &arp_table[i].ethaddr; + *ip_ret = &arp_table[i].ipaddr; + return i; + } + return -1; +} + +#if ETHARP_TRUST_IP_MAC +/** + * Updates the ARP table using the given IP packet. + * + * Uses the incoming IP packet's source address to update the + * ARP cache for the local network. The function does not alter + * or free the packet. This function must be called before the + * packet p is passed to the IP layer. + * + * @param netif The lwIP network interface on which the IP packet pbuf arrived. + * @param p The IP packet that arrived on netif. + * + * @return NULL + * + * @see pbuf_free() + */ +static void +etharp_ip_input(struct netif *netif, struct pbuf *p) +{ + struct eth_hdr *ethhdr; + struct ip_hdr *iphdr; + ip_addr_t iphdr_src; + LWIP_ERROR("netif != NULL", (netif != NULL), return;); + + /* Only insert an entry if the source IP address of the + incoming IP packet comes from a host on the local network. */ + ethhdr = (struct eth_hdr *)p->payload; + iphdr = (struct ip_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR); +#if ETHARP_SUPPORT_VLAN + if (ethhdr->type == PP_HTONS(ETHTYPE_VLAN)) { + iphdr = (struct ip_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR); + } +#endif /* ETHARP_SUPPORT_VLAN */ + + ip_addr_copy(iphdr_src, iphdr->src); + + /* source is not on the local network? */ + if (!ip_addr_netcmp(&iphdr_src, &(netif->ip_addr), &(netif->netmask))) { + /* do nothing */ + return; + } + + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n")); + /* update the source IP address in the cache, if present */ + /* @todo We could use ETHARP_FLAG_TRY_HARD if we think we are going to talk + * back soon (for example, if the destination IP address is ours. */ + etharp_update_arp_entry(netif, &iphdr_src, &(ethhdr->src), ETHARP_FLAG_FIND_ONLY); +} +#endif /* ETHARP_TRUST_IP_MAC */ + +/** + * Responds to ARP requests to us. Upon ARP replies to us, add entry to cache + * send out queued IP packets. Updates cache with snooped address pairs. + * + * Should be called for incoming ARP packets. The pbuf in the argument + * is freed by this function. + * + * @param netif The lwIP network interface on which the ARP packet pbuf arrived. + * @param ethaddr Ethernet address of netif. + * @param p The ARP packet that arrived on netif. Is freed by this function. + * + * @return NULL + * + * @see pbuf_free() + */ +static void +etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) +{ + struct etharp_hdr *hdr; + struct eth_hdr *ethhdr; + /* these are aligned properly, whereas the ARP header fields might not be */ + ip_addr_t sipaddr, dipaddr; + u8_t for_us; +#if LWIP_AUTOIP + const u8_t * ethdst_hwaddr; +#endif /* LWIP_AUTOIP */ + + LWIP_ERROR("netif != NULL", (netif != NULL), return;); + + /* drop short ARP packets: we have to check for p->len instead of p->tot_len here + since a struct etharp_hdr is pointed to p->payload, so it musn't be chained! */ + if (p->len < SIZEOF_ETHARP_PACKET) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, + ("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, + (s16_t)SIZEOF_ETHARP_PACKET)); + ETHARP_STATS_INC(etharp.lenerr); + ETHARP_STATS_INC(etharp.drop); + pbuf_free(p); + return; + } + + ethhdr = (struct eth_hdr *)p->payload; + hdr = (struct etharp_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR); +#if ETHARP_SUPPORT_VLAN + if (ethhdr->type == PP_HTONS(ETHTYPE_VLAN)) { + hdr = (struct etharp_hdr *)(((u8_t*)ethhdr) + SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR); + } +#endif /* ETHARP_SUPPORT_VLAN */ + + /* RFC 826 "Packet Reception": */ + if ((hdr->hwtype != PP_HTONS(HWTYPE_ETHERNET)) || + (hdr->hwlen != ETHARP_HWADDR_LEN) || + (hdr->protolen != sizeof(ip_addr_t)) || + (hdr->proto != PP_HTONS(ETHTYPE_IP))) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, + ("etharp_arp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n", + hdr->hwtype, hdr->hwlen, hdr->proto, hdr->protolen)); + ETHARP_STATS_INC(etharp.proterr); + ETHARP_STATS_INC(etharp.drop); + pbuf_free(p); + return; + } + ETHARP_STATS_INC(etharp.recv); + +#if LWIP_AUTOIP + /* We have to check if a host already has configured our random + * created link local address and continously check if there is + * a host with this IP-address so we can detect collisions */ + autoip_arp_reply(netif, hdr); +#endif /* LWIP_AUTOIP */ + + /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without + * structure packing (not using structure copy which breaks strict-aliasing rules). */ + IPADDR2_COPY(&sipaddr, &hdr->sipaddr); + IPADDR2_COPY(&dipaddr, &hdr->dipaddr); + + /* this interface is not configured? */ + if (ip_addr_isany(&netif->ip_addr)) { + for_us = 0; + } else { + /* ARP packet directed to us? */ + for_us = (u8_t)ip_addr_cmp(&dipaddr, &(netif->ip_addr)); + } + + /* ARP message directed to us? + -> add IP address in ARP cache; assume requester wants to talk to us, + can result in directly sending the queued packets for this host. + ARP message not directed to us? + -> update the source IP address in the cache, if present */ + etharp_update_arp_entry(netif, &sipaddr, &(hdr->shwaddr), + for_us ? ETHARP_FLAG_TRY_HARD : ETHARP_FLAG_FIND_ONLY); + + /* now act on the message itself */ + switch (hdr->opcode) { + /* ARP request? */ + case PP_HTONS(ARP_REQUEST): + /* ARP request. If it asked for our address, we send out a + * reply. In any case, we time-stamp any existing ARP entry, + * and possiby send out an IP packet that was queued on it. */ + + LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP request\n")); + /* ARP request for our address? */ + if (for_us) { + + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n")); + /* Re-use pbuf to send ARP reply. + Since we are re-using an existing pbuf, we can't call etharp_raw since + that would allocate a new pbuf. */ + hdr->opcode = htons(ARP_REPLY); + + IPADDR2_COPY(&hdr->dipaddr, &hdr->sipaddr); + IPADDR2_COPY(&hdr->sipaddr, &netif->ip_addr); + + LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!", + (netif->hwaddr_len == ETHARP_HWADDR_LEN)); +#if LWIP_AUTOIP + /* If we are using Link-Local, all ARP packets that contain a Link-Local + * 'sender IP address' MUST be sent using link-layer broadcast instead of + * link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */ + ethdst_hwaddr = ip_addr_islinklocal(&netif->ip_addr) ? (u8_t*)(ethbroadcast.addr) : hdr->shwaddr.addr; +#endif /* LWIP_AUTOIP */ + + ETHADDR16_COPY(&hdr->dhwaddr, &hdr->shwaddr); +#if LWIP_AUTOIP + ETHADDR16_COPY(ðhdr->dest, ethdst_hwaddr); +#else /* LWIP_AUTOIP */ + ETHADDR16_COPY(ðhdr->dest, &hdr->shwaddr); +#endif /* LWIP_AUTOIP */ + ETHADDR16_COPY(&hdr->shwaddr, ethaddr); + ETHADDR16_COPY(ðhdr->src, ethaddr); + + /* hwtype, hwaddr_len, proto, protolen and the type in the ethernet header + are already correct, we tested that before */ + + /* return ARP reply */ + netif->linkoutput(netif, p); + /* we are not configured? */ + } else if (ip_addr_isany(&netif->ip_addr)) { + /* { for_us == 0 and netif->ip_addr.addr == 0 } */ + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n")); + /* request was not directed to us */ + } else { + /* { for_us == 0 and netif->ip_addr.addr != 0 } */ + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n")); + } + break; + case PP_HTONS(ARP_REPLY): + /* ARP reply. We already updated the ARP cache earlier. */ + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n")); +#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) + /* DHCP wants to know about ARP replies from any host with an + * IP address also offered to us by the DHCP server. We do not + * want to take a duplicate IP address on a single network. + * @todo How should we handle redundant (fail-over) interfaces? */ + dhcp_arp_reply(netif, &sipaddr); +#endif /* (LWIP_DHCP && DHCP_DOES_ARP_CHECK) */ + break; + default: + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode))); + ETHARP_STATS_INC(etharp.err); + break; + } + /* free ARP packet */ + pbuf_free(p); +} + +/** Just a small helper function that sends a pbuf to an ethernet address + * in the arp_table specified by the index 'arp_idx'. + */ +static err_t +etharp_output_to_arp_index(struct netif *netif, struct pbuf *q, u8_t arp_idx) +{ + LWIP_ASSERT("arp_table[arp_idx].state >= ETHARP_STATE_STABLE", + arp_table[arp_idx].state >= ETHARP_STATE_STABLE); + /* if arp table entry is about to expire: re-request it, + but only if its state is ETHARP_STATE_STABLE to prevent flooding the + network with ARP requests if this address is used frequently. */ + if ((arp_table[arp_idx].state == ETHARP_STATE_STABLE) && + (arp_table[arp_idx].ctime >= ARP_AGE_REREQUEST_USED)) { + if (etharp_request(netif, &arp_table[arp_idx].ipaddr) == ERR_OK) { + arp_table[arp_idx].state = ETHARP_STATE_STABLE_REREQUESTING; + } + } + + return etharp_send_ip(netif, q, (struct eth_addr*)(netif->hwaddr), + &arp_table[arp_idx].ethaddr); +} + +/** + * Resolve and fill-in Ethernet address header for outgoing IP packet. + * + * For IP multicast and broadcast, corresponding Ethernet addresses + * are selected and the packet is transmitted on the link. + * + * For unicast addresses, the packet is submitted to etharp_query(). In + * case the IP address is outside the local network, the IP address of + * the gateway is used. + * + * @param netif The lwIP network interface which the IP packet will be sent on. + * @param q The pbuf(s) containing the IP packet to be sent. + * @param ipaddr The IP address of the packet destination. + * + * @return + * - ERR_RTE No route to destination (no gateway to external networks), + * or the return type of either etharp_query() or etharp_send_ip(). + */ +err_t +etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) +{ + struct eth_addr *dest; + struct eth_addr mcastaddr; + ip_addr_t *dst_addr = ipaddr; + + LWIP_ASSERT("netif != NULL", netif != NULL); + LWIP_ASSERT("q != NULL", q != NULL); + LWIP_ASSERT("ipaddr != NULL", ipaddr != NULL); + + /* make room for Ethernet header - should not fail */ + if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) { + /* bail out */ + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, + ("etharp_output: could not allocate room for header.\n")); + LINK_STATS_INC(link.lenerr); + return ERR_BUF; + } + + /* Determine on destination hardware address. Broadcasts and multicasts + * are special, other IP addresses are looked up in the ARP table. */ + + /* broadcast destination IP address? */ + if (ip_addr_isbroadcast(ipaddr, netif)) { + /* broadcast on Ethernet also */ + dest = (struct eth_addr *)ðbroadcast; + /* multicast destination IP address? */ + } else if (ip_addr_ismulticast(ipaddr)) { + /* Hash IP multicast address to MAC address.*/ + mcastaddr.addr[0] = LL_MULTICAST_ADDR_0; + mcastaddr.addr[1] = LL_MULTICAST_ADDR_1; + mcastaddr.addr[2] = LL_MULTICAST_ADDR_2; + mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f; + mcastaddr.addr[4] = ip4_addr3(ipaddr); + mcastaddr.addr[5] = ip4_addr4(ipaddr); + /* destination Ethernet address is multicast */ + dest = &mcastaddr; + /* unicast destination IP address? */ + } else { + s8_t i; + /* outside local network? if so, this can neither be a global broadcast nor + a subnet broadcast. */ + if (!ip_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask)) && + !ip_addr_islinklocal(ipaddr)) { +#if LWIP_AUTOIP + struct ip_hdr *iphdr = (struct ip_hdr*)((u8_t*)q->payload + + sizeof(struct eth_hdr)); + /* According to RFC 3297, chapter 2.6.2 (Forwarding Rules), a packet with + a link-local source address must always be "directly to its destination + on the same physical link. The host MUST NOT send the packet to any + router for forwarding". */ + if (!ip_addr_islinklocal(&iphdr->src)) +#endif /* LWIP_AUTOIP */ + { + /* interface has default gateway? */ + if (!ip_addr_isany(&netif->gw)) { + /* send to hardware address of default gateway IP address */ + dst_addr = &(netif->gw); + /* no default gateway available */ + } else { + /* no route to destination error (default gateway missing) */ + return ERR_RTE; + } + } + } +#if LWIP_NETIF_HWADDRHINT + if (netif->addr_hint != NULL) { + /* per-pcb cached entry was given */ + u8_t etharp_cached_entry = *(netif->addr_hint); + if (etharp_cached_entry < ARP_TABLE_SIZE) { +#endif /* LWIP_NETIF_HWADDRHINT */ + if ((arp_table[etharp_cached_entry].state >= ETHARP_STATE_STABLE) && + (ip_addr_cmp(dst_addr, &arp_table[etharp_cached_entry].ipaddr))) { + /* the per-pcb-cached entry is stable and the right one! */ + ETHARP_STATS_INC(etharp.cachehit); + return etharp_output_to_arp_index(netif, q, etharp_cached_entry); + } +#if LWIP_NETIF_HWADDRHINT + } + } +#endif /* LWIP_NETIF_HWADDRHINT */ + + /* find stable entry: do this here since this is a critical path for + throughput and etharp_find_entry() is kind of slow */ + for (i = 0; i < ARP_TABLE_SIZE; i++) { + if ((arp_table[i].state >= ETHARP_STATE_STABLE) && + (ip_addr_cmp(dst_addr, &arp_table[i].ipaddr))) { + /* found an existing, stable entry */ + ETHARP_SET_HINT(netif, i); + return etharp_output_to_arp_index(netif, q, i); + } + } + /* no stable entry found, use the (slower) query function: + queue on destination Ethernet address belonging to ipaddr */ + return etharp_query(netif, dst_addr, q); + } + + /* continuation for multicast/broadcast destinations */ + /* obtain source Ethernet address of the given interface */ + /* send packet directly on the link */ + return etharp_send_ip(netif, q, (struct eth_addr*)(netif->hwaddr), dest); +} + +/** + * Send an ARP request for the given IP address and/or queue a packet. + * + * If the IP address was not yet in the cache, a pending ARP cache entry + * is added and an ARP request is sent for the given address. The packet + * is queued on this entry. + * + * If the IP address was already pending in the cache, a new ARP request + * is sent for the given address. The packet is queued on this entry. + * + * If the IP address was already stable in the cache, and a packet is + * given, it is directly sent and no ARP request is sent out. + * + * If the IP address was already stable in the cache, and no packet is + * given, an ARP request is sent out. + * + * @param netif The lwIP network interface on which ipaddr + * must be queried for. + * @param ipaddr The IP address to be resolved. + * @param q If non-NULL, a pbuf that must be delivered to the IP address. + * q is not freed by this function. + * + * @note q must only be ONE packet, not a packet queue! + * + * @return + * - ERR_BUF Could not make room for Ethernet header. + * - ERR_MEM Hardware address unknown, and no more ARP entries available + * to query for address or queue the packet. + * - ERR_MEM Could not queue packet due to memory shortage. + * - ERR_RTE No route to destination (no gateway to external networks). + * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. + * + */ +err_t +etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q) +{ + struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr; + err_t result = ERR_MEM; + s8_t i; /* ARP entry index */ + + /* non-unicast address? */ + if (ip_addr_isbroadcast(ipaddr, netif) || + ip_addr_ismulticast(ipaddr) || + ip_addr_isany(ipaddr)) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: will not add non-unicast IP address to ARP cache\n")); + return ERR_ARG; + } + + /* find entry in ARP cache, ask to create entry if queueing packet */ + i = etharp_find_entry(ipaddr, ETHARP_FLAG_TRY_HARD); + + /* could not find or create entry? */ + if (i < 0) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not create ARP entry\n")); + if (q) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: packet dropped\n")); + ETHARP_STATS_INC(etharp.memerr); + } + return (err_t)i; + } + + /* mark a fresh entry as pending (we just sent a request) */ + if (arp_table[i].state == ETHARP_STATE_EMPTY) { + arp_table[i].state = ETHARP_STATE_PENDING; + } + + /* { i is either a STABLE or (new or existing) PENDING entry } */ + LWIP_ASSERT("arp_table[i].state == PENDING or STABLE", + ((arp_table[i].state == ETHARP_STATE_PENDING) || + (arp_table[i].state >= ETHARP_STATE_STABLE))); + + /* do we have a pending entry? or an implicit query request? */ + if ((arp_table[i].state == ETHARP_STATE_PENDING) || (q == NULL)) { + /* try to resolve it; send out ARP request */ + result = etharp_request(netif, ipaddr); + if (result != ERR_OK) { + /* ARP request couldn't be sent */ + /* We don't re-send arp request in etharp_tmr, but we still queue packets, + since this failure could be temporary, and the next packet calling + etharp_query again could lead to sending the queued packets. */ + } + if (q == NULL) { + return result; + } + } + + /* packet given? */ + LWIP_ASSERT("q != NULL", q != NULL); + /* stable entry? */ + if (arp_table[i].state >= ETHARP_STATE_STABLE) { + /* we have a valid IP->Ethernet address mapping */ + ETHARP_SET_HINT(netif, i); + /* send the packet */ + result = etharp_send_ip(netif, q, srcaddr, &(arp_table[i].ethaddr)); + /* pending entry? (either just created or already pending */ + } else if (arp_table[i].state == ETHARP_STATE_PENDING) { + /* entry is still pending, queue the given packet 'q' */ + struct pbuf *p; + int copy_needed = 0; + /* IF q includes a PBUF_REF, PBUF_POOL or PBUF_RAM, we have no choice but + * to copy the whole queue into a new PBUF_RAM (see bug #11400) + * PBUF_ROMs can be left as they are, since ROM must not get changed. */ + p = q; + while (p) { + LWIP_ASSERT("no packet queues allowed!", (p->len != p->tot_len) || (p->next == 0)); + if(p->type != PBUF_ROM) { + copy_needed = 1; + break; + } + p = p->next; + } + if(copy_needed) { + /* copy the whole packet into new pbufs */ + p = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); + if(p != NULL) { + if (pbuf_copy(p, q) != ERR_OK) { + pbuf_free(p); + p = NULL; + } + } + } else { + /* referencing the old pbuf is enough */ + p = q; + pbuf_ref(p); + } + /* packet could be taken over? */ + if (p != NULL) { + /* queue packet ... */ +#if ARP_QUEUEING + struct etharp_q_entry *new_entry; + /* allocate a new arp queue entry */ + new_entry = (struct etharp_q_entry *)memp_malloc(MEMP_ARP_QUEUE); + if (new_entry != NULL) { + new_entry->next = 0; + new_entry->p = p; + if(arp_table[i].q != NULL) { + /* queue was already existent, append the new entry to the end */ + struct etharp_q_entry *r; + r = arp_table[i].q; + while (r->next != NULL) { + r = r->next; + } + r->next = new_entry; + } else { + /* queue did not exist, first item in queue */ + arp_table[i].q = new_entry; + } + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); + result = ERR_OK; + } else { + /* the pool MEMP_ARP_QUEUE is empty */ + pbuf_free(p); + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q)); + result = ERR_MEM; + } +#else /* ARP_QUEUEING */ + /* always queue one packet per ARP request only, freeing a previously queued packet */ + if (arp_table[i].q != NULL) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: dropped previously queued packet %p for ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); + pbuf_free(arp_table[i].q); + } + arp_table[i].q = p; + result = ERR_OK; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); +#endif /* ARP_QUEUEING */ + } else { + ETHARP_STATS_INC(etharp.memerr); + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q)); + result = ERR_MEM; + } + } + return result; +} + +/** + * Send a raw ARP packet (opcode and all addresses can be modified) + * + * @param netif the lwip network interface on which to send the ARP packet + * @param ethsrc_addr the source MAC address for the ethernet header + * @param ethdst_addr the destination MAC address for the ethernet header + * @param hwsrc_addr the source MAC address for the ARP protocol header + * @param ipsrc_addr the source IP address for the ARP protocol header + * @param hwdst_addr the destination MAC address for the ARP protocol header + * @param ipdst_addr the destination IP address for the ARP protocol header + * @param opcode the type of the ARP packet + * @return ERR_OK if the ARP packet has been sent + * ERR_MEM if the ARP packet couldn't be allocated + * any other err_t on failure + */ +#if !LWIP_AUTOIP +static +#endif /* LWIP_AUTOIP */ +err_t +etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, + const struct eth_addr *ethdst_addr, + const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr, + const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr, + const u16_t opcode) +{ + struct pbuf *p; + err_t result = ERR_OK; + struct eth_hdr *ethhdr; + struct etharp_hdr *hdr; +#if LWIP_AUTOIP + const u8_t * ethdst_hwaddr; +#endif /* LWIP_AUTOIP */ + + LWIP_ASSERT("netif != NULL", netif != NULL); + + /* allocate a pbuf for the outgoing ARP request packet */ + p = pbuf_alloc(PBUF_RAW, SIZEOF_ETHARP_PACKET, PBUF_RAM); + /* could allocate a pbuf for an ARP request? */ + if (p == NULL) { + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, + ("etharp_raw: could not allocate pbuf for ARP request.\n")); + ETHARP_STATS_INC(etharp.memerr); + return ERR_MEM; + } + LWIP_ASSERT("check that first pbuf can hold struct etharp_hdr", + (p->len >= SIZEOF_ETHARP_PACKET)); + + ethhdr = (struct eth_hdr *)p->payload; + hdr = (struct etharp_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR); + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_raw: sending raw ARP packet.\n")); + hdr->opcode = htons(opcode); + + LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!", + (netif->hwaddr_len == ETHARP_HWADDR_LEN)); +#if LWIP_AUTOIP + /* If we are using Link-Local, all ARP packets that contain a Link-Local + * 'sender IP address' MUST be sent using link-layer broadcast instead of + * link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */ + ethdst_hwaddr = ip_addr_islinklocal(ipsrc_addr) ? (u8_t*)(ethbroadcast.addr) : ethdst_addr->addr; +#endif /* LWIP_AUTOIP */ + /* Write the ARP MAC-Addresses */ + ETHADDR16_COPY(&hdr->shwaddr, hwsrc_addr); + ETHADDR16_COPY(&hdr->dhwaddr, hwdst_addr); + /* Write the Ethernet MAC-Addresses */ +#if LWIP_AUTOIP + ETHADDR16_COPY(ðhdr->dest, ethdst_hwaddr); +#else /* LWIP_AUTOIP */ + ETHADDR16_COPY(ðhdr->dest, ethdst_addr); +#endif /* LWIP_AUTOIP */ + ETHADDR16_COPY(ðhdr->src, ethsrc_addr); + /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without + * structure packing. */ + IPADDR2_COPY(&hdr->sipaddr, ipsrc_addr); + IPADDR2_COPY(&hdr->dipaddr, ipdst_addr); + + hdr->hwtype = PP_HTONS(HWTYPE_ETHERNET); + hdr->proto = PP_HTONS(ETHTYPE_IP); + /* set hwlen and protolen */ + hdr->hwlen = ETHARP_HWADDR_LEN; + hdr->protolen = sizeof(ip_addr_t); + + ethhdr->type = PP_HTONS(ETHTYPE_ARP); + /* send ARP query */ + result = netif->linkoutput(netif, p); + ETHARP_STATS_INC(etharp.xmit); + /* free ARP query packet */ + pbuf_free(p); + p = NULL; + /* could not allocate pbuf for ARP request */ + + return result; +} + +/** + * Send an ARP request packet asking for ipaddr. + * + * @param netif the lwip network interface on which to send the request + * @param ipaddr the IP address for which to ask + * @return ERR_OK if the request has been sent + * ERR_MEM if the ARP packet couldn't be allocated + * any other err_t on failure + */ +err_t +etharp_request(struct netif *netif, ip_addr_t *ipaddr) +{ + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_request: sending ARP request.\n")); + return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast, + (struct eth_addr *)netif->hwaddr, &netif->ip_addr, ðzero, + ipaddr, ARP_REQUEST); +} +#endif /* LWIP_ARP */ + +/** + * Process received ethernet frames. Using this function instead of directly + * calling ip_input and passing ARP frames through etharp in ethernetif_input, + * the ARP cache is protected from concurrent access. + * + * @param p the recevied packet, p->payload pointing to the ethernet header + * @param netif the network interface on which the packet was received + */ +err_t +ethernet_input(struct pbuf *p, struct netif *netif) +{ + struct eth_hdr* ethhdr; + u16_t type; +#if LWIP_ARP || ETHARP_SUPPORT_VLAN + s16_t ip_hdr_offset = SIZEOF_ETH_HDR; +#endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */ + + if (p->len <= SIZEOF_ETH_HDR) { + /* a packet with only an ethernet header (or less) is not valid for us */ + ETHARP_STATS_INC(etharp.proterr); + ETHARP_STATS_INC(etharp.drop); + goto free_and_return; + } + + /* points to packet payload, which starts with an Ethernet header */ + ethhdr = (struct eth_hdr *)p->payload; + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, + ("ethernet_input: dest:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", src:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", type:%"X16_F"\n", + (unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2], + (unsigned)ethhdr->dest.addr[3], (unsigned)ethhdr->dest.addr[4], (unsigned)ethhdr->dest.addr[5], + (unsigned)ethhdr->src.addr[0], (unsigned)ethhdr->src.addr[1], (unsigned)ethhdr->src.addr[2], + (unsigned)ethhdr->src.addr[3], (unsigned)ethhdr->src.addr[4], (unsigned)ethhdr->src.addr[5], + (unsigned)htons(ethhdr->type))); + + type = ethhdr->type; +#if ETHARP_SUPPORT_VLAN + if (type == PP_HTONS(ETHTYPE_VLAN)) { + struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr*)(((char*)ethhdr) + SIZEOF_ETH_HDR); + if (p->len <= SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) { + /* a packet with only an ethernet/vlan header (or less) is not valid for us */ + ETHARP_STATS_INC(etharp.proterr); + ETHARP_STATS_INC(etharp.drop); + goto free_and_return; + } +#if defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) /* if not, allow all VLANs */ +#ifdef ETHARP_VLAN_CHECK_FN + if (!ETHARP_VLAN_CHECK_FN(ethhdr, vlan)) { +#elif defined(ETHARP_VLAN_CHECK) + if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) { +#endif + /* silently ignore this packet: not for our VLAN */ + pbuf_free(p); + return ERR_OK; + } +#endif /* defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) */ + type = vlan->tpid; + ip_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR; + } +#endif /* ETHARP_SUPPORT_VLAN */ + +#if LWIP_ARP_FILTER_NETIF + netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, htons(type)); +#endif /* LWIP_ARP_FILTER_NETIF*/ + + if (ethhdr->dest.addr[0] & 1) { + /* this might be a multicast or broadcast packet */ + if (ethhdr->dest.addr[0] == LL_MULTICAST_ADDR_0) { + if ((ethhdr->dest.addr[1] == LL_MULTICAST_ADDR_1) && + (ethhdr->dest.addr[2] == LL_MULTICAST_ADDR_2)) { + /* mark the pbuf as link-layer multicast */ + p->flags |= PBUF_FLAG_LLMCAST; + } + } else if (eth_addr_cmp(ðhdr->dest, ðbroadcast)) { + /* mark the pbuf as link-layer broadcast */ + p->flags |= PBUF_FLAG_LLBCAST; + } + } + + switch (type) { +#if LWIP_ARP + /* IP packet? */ + case PP_HTONS(ETHTYPE_IP): + if (!(netif->flags & NETIF_FLAG_ETHARP)) { + goto free_and_return; + } +#if ETHARP_TRUST_IP_MAC + /* update ARP table */ + etharp_ip_input(netif, p); +#endif /* ETHARP_TRUST_IP_MAC */ + /* skip Ethernet header */ + if(pbuf_header(p, -ip_hdr_offset)) { + LWIP_ASSERT("Can't move over header in packet", 0); + goto free_and_return; + } else { + /* pass to IP layer */ + ip_input(p, netif); + } + break; + + case PP_HTONS(ETHTYPE_ARP): + if (!(netif->flags & NETIF_FLAG_ETHARP)) { + goto free_and_return; + } + /* pass p to ARP module */ + etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p); + break; +#endif /* LWIP_ARP */ +#if PPPOE_SUPPORT + case PP_HTONS(ETHTYPE_PPPOEDISC): /* PPP Over Ethernet Discovery Stage */ + pppoe_disc_input(netif, p); + break; + + case PP_HTONS(ETHTYPE_PPPOE): /* PPP Over Ethernet Session Stage */ + pppoe_data_input(netif, p); + break; +#endif /* PPPOE_SUPPORT */ + + default: + ETHARP_STATS_INC(etharp.proterr); + ETHARP_STATS_INC(etharp.drop); + goto free_and_return; + } + + /* This means the pbuf is freed or consumed, + so the caller doesn't have to free it again */ + return ERR_OK; + +free_and_return: + pbuf_free(p); + return ERR_OK; +} +#endif /* LWIP_ARP || LWIP_ETHERNET */ diff --git a/user/mpy/lib/lwip/src/netif/ethernetif.c b/user/mpy/lib/lwip/src/netif/ethernetif.c new file mode 100644 index 0000000..8ec40be --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ethernetif.c @@ -0,0 +1,317 @@ +/** + * @file + * Ethernet Interface Skeleton + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +/* + * This file is a skeleton for developing Ethernet network interface + * drivers for lwIP. Add code to the low_level functions and do a + * search-and-replace for the word "ethernetif" to replace it with + * something that better describes your network interface. + */ + +#include "lwip/opt.h" + +#if 0 /* don't build, this is only a skeleton, see previous comment */ + +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include +#include +#include "netif/etharp.h" +#include "netif/ppp_oe.h" + +/* Define those to better describe your network interface. */ +#define IFNAME0 'e' +#define IFNAME1 'n' + +/** + * Helper struct to hold private data used to operate your ethernet interface. + * Keeping the ethernet address of the MAC in this struct is not necessary + * as it is already kept in the struct netif. + * But this is only an example, anyway... + */ +struct ethernetif { + struct eth_addr *ethaddr; + /* Add whatever per-interface state that is needed here. */ +}; + +/* Forward declarations. */ +static void ethernetif_input(struct netif *netif); + +/** + * In this function, the hardware should be initialized. + * Called from ethernetif_init(). + * + * @param netif the already initialized lwip network interface structure + * for this ethernetif + */ +static void +low_level_init(struct netif *netif) +{ + struct ethernetif *ethernetif = netif->state; + + /* set MAC hardware address length */ + netif->hwaddr_len = ETHARP_HWADDR_LEN; + + /* set MAC hardware address */ + netif->hwaddr[0] = ; + ... + netif->hwaddr[5] = ; + + /* maximum transfer unit */ + netif->mtu = 1500; + + /* device capabilities */ + /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ + netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + + /* Do whatever else is needed to initialize interface. */ +} + +/** + * This function should do the actual transmission of the packet. The packet is + * contained in the pbuf that is passed to the function. This pbuf + * might be chained. + * + * @param netif the lwip network interface structure for this ethernetif + * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type) + * @return ERR_OK if the packet could be sent + * an err_t value if the packet couldn't be sent + * + * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to + * strange results. You might consider waiting for space in the DMA queue + * to become availale since the stack doesn't retry to send a packet + * dropped because of memory failure (except for the TCP timers). + */ + +static err_t +low_level_output(struct netif *netif, struct pbuf *p) +{ + struct ethernetif *ethernetif = netif->state; + struct pbuf *q; + + initiate transfer(); + +#if ETH_PAD_SIZE + pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ +#endif + + for(q = p; q != NULL; q = q->next) { + /* Send the data from the pbuf to the interface, one pbuf at a + time. The size of the data in each pbuf is kept in the ->len + variable. */ + send data from(q->payload, q->len); + } + + signal that packet should be sent(); + +#if ETH_PAD_SIZE + pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ +#endif + + LINK_STATS_INC(link.xmit); + + return ERR_OK; +} + +/** + * Should allocate a pbuf and transfer the bytes of the incoming + * packet from the interface into the pbuf. + * + * @param netif the lwip network interface structure for this ethernetif + * @return a pbuf filled with the received packet (including MAC header) + * NULL on memory error + */ +static struct pbuf * +low_level_input(struct netif *netif) +{ + struct ethernetif *ethernetif = netif->state; + struct pbuf *p, *q; + u16_t len; + + /* Obtain the size of the packet and put it into the "len" + variable. */ + len = ; + +#if ETH_PAD_SIZE + len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ +#endif + + /* We allocate a pbuf chain of pbufs from the pool. */ + p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); + + if (p != NULL) { + +#if ETH_PAD_SIZE + pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ +#endif + + /* We iterate over the pbuf chain until we have read the entire + * packet into the pbuf. */ + for(q = p; q != NULL; q = q->next) { + /* Read enough bytes to fill this pbuf in the chain. The + * available data in the pbuf is given by the q->len + * variable. + * This does not necessarily have to be a memcpy, you can also preallocate + * pbufs for a DMA-enabled MAC and after receiving truncate it to the + * actually received size. In this case, ensure the tot_len member of the + * pbuf is the sum of the chained pbuf len members. + */ + read data into(q->payload, q->len); + } + acknowledge that packet has been read(); + +#if ETH_PAD_SIZE + pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ +#endif + + LINK_STATS_INC(link.recv); + } else { + drop packet(); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + } + + return p; +} + +/** + * This function should be called when a packet is ready to be read + * from the interface. It uses the function low_level_input() that + * should handle the actual reception of bytes from the network + * interface. Then the type of the received packet is determined and + * the appropriate input function is called. + * + * @param netif the lwip network interface structure for this ethernetif + */ +static void +ethernetif_input(struct netif *netif) +{ + struct ethernetif *ethernetif; + struct eth_hdr *ethhdr; + struct pbuf *p; + + ethernetif = netif->state; + + /* move received packet into a new pbuf */ + p = low_level_input(netif); + /* no packet could be read, silently ignore this */ + if (p == NULL) return; + /* points to packet payload, which starts with an Ethernet header */ + ethhdr = p->payload; + + switch (htons(ethhdr->type)) { + /* IP or ARP packet? */ + case ETHTYPE_IP: + case ETHTYPE_ARP: +#if PPPOE_SUPPORT + /* PPPoE packet? */ + case ETHTYPE_PPPOEDISC: + case ETHTYPE_PPPOE: +#endif /* PPPOE_SUPPORT */ + /* full packet send to tcpip_thread to process */ + if (netif->input(p, netif)!=ERR_OK) + { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + pbuf_free(p); + p = NULL; + } + break; + + default: + pbuf_free(p); + p = NULL; + break; + } +} + +/** + * Should be called at the beginning of the program to set up the + * network interface. It calls the function low_level_init() to do the + * actual setup of the hardware. + * + * This function should be passed as a parameter to netif_add(). + * + * @param netif the lwip network interface structure for this ethernetif + * @return ERR_OK if the loopif is initialized + * ERR_MEM if private data couldn't be allocated + * any other err_t on error + */ +err_t +ethernetif_init(struct netif *netif) +{ + struct ethernetif *ethernetif; + + LWIP_ASSERT("netif != NULL", (netif != NULL)); + + ethernetif = mem_malloc(sizeof(struct ethernetif)); + if (ethernetif == NULL) { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n")); + return ERR_MEM; + } + +#if LWIP_NETIF_HOSTNAME + /* Initialize interface hostname */ + netif->hostname = "lwip"; +#endif /* LWIP_NETIF_HOSTNAME */ + + /* + * Initialize the snmp variables and counters inside the struct netif. + * The last argument should be replaced with your link speed, in units + * of bits per second. + */ + NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS); + + netif->state = ethernetif; + netif->name[0] = IFNAME0; + netif->name[1] = IFNAME1; + /* We directly use etharp_output() here to save a function call. + * You can instead declare your own function an call etharp_output() + * from it if you have to do some checks before sending (e.g. if link + * is available...) */ + netif->output = etharp_output; + netif->linkoutput = low_level_output; + + ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); + + /* initialize the hardware */ + low_level_init(netif); + + return ERR_OK; +} + +#endif /* 0 */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/auth.c b/user/mpy/lib/lwip/src/netif/ppp/auth.c new file mode 100644 index 0000000..0fd87a3 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/auth.c @@ -0,0 +1,1334 @@ +/***************************************************************************** +* auth.c - Network Authentication and Phase Control program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* Copyright (c) 1997 by Global Election Systems Inc. All rights reserved. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-08 Guy Lancaster , Global Election Systems Inc. +* Ported from public pppd code. +*****************************************************************************/ +/* + * auth.c - PPP authentication and phase control. + * + * Copyright (c) 1993 The Australian National University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the Australian National University. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "fsm.h" +#include "lcp.h" +#include "pap.h" +#include "chap.h" +#include "auth.h" +#include "ipcp.h" + +#if CBCP_SUPPORT +#include "cbcp.h" +#endif /* CBCP_SUPPORT */ + +#include "lwip/inet.h" + +#include + +#if 0 /* UNUSED */ +/* Bits in scan_authfile return value */ +#define NONWILD_SERVER 1 +#define NONWILD_CLIENT 2 + +#define ISWILD(word) (word[0] == '*' && word[1] == 0) +#endif /* UNUSED */ + +#if PAP_SUPPORT || CHAP_SUPPORT +/* The name by which the peer authenticated itself to us. */ +static char peer_authname[MAXNAMELEN]; +#endif /* PAP_SUPPORT || CHAP_SUPPORT */ + +/* Records which authentication operations haven't completed yet. */ +static int auth_pending[NUM_PPP]; + +/* Set if we have successfully called plogin() */ +static int logged_in; + +/* Set if we have run the /etc/ppp/auth-up script. */ +static int did_authup; /* @todo, we don't need this in lwip*/ + +/* List of addresses which the peer may use. */ +static struct wordlist *addresses[NUM_PPP]; + +#if 0 /* UNUSED */ +/* Wordlist giving addresses which the peer may use + without authenticating itself. */ +static struct wordlist *noauth_addrs; + +/* Extra options to apply, from the secrets file entry for the peer. */ +static struct wordlist *extra_options; +#endif /* UNUSED */ + +/* Number of network protocols which we have opened. */ +static int num_np_open; + +/* Number of network protocols which have come up. */ +static int num_np_up; + +#if PAP_SUPPORT || CHAP_SUPPORT +/* Set if we got the contents of passwd[] from the pap-secrets file. */ +static int passwd_from_file; +#endif /* PAP_SUPPORT || CHAP_SUPPORT */ + +#if 0 /* UNUSED */ +/* Set if we require authentication only because we have a default route. */ +static bool default_auth; + +/* Hook to enable a plugin to control the idle time limit */ +int (*idle_time_hook) __P((struct ppp_idle *)) = NULL; + +/* Hook for a plugin to say whether we can possibly authenticate any peer */ +int (*pap_check_hook) __P((void)) = NULL; + +/* Hook for a plugin to check the PAP user and password */ +int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp, + struct wordlist **paddrs, + struct wordlist **popts)) = NULL; + +/* Hook for a plugin to know about the PAP user logout */ +void (*pap_logout_hook) __P((void)) = NULL; + +/* Hook for a plugin to get the PAP password for authenticating us */ +int (*pap_passwd_hook) __P((char *user, char *passwd)) = NULL; + +/* + * This is used to ensure that we don't start an auth-up/down + * script while one is already running. + */ +enum script_state { + s_down, + s_up +}; + +static enum script_state auth_state = s_down; +static enum script_state auth_script_state = s_down; +static pid_t auth_script_pid = 0; + +/* + * Option variables. + * lwip: some of these are present in the ppp_settings structure + */ +bool uselogin = 0; /* Use /etc/passwd for checking PAP */ +bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ +bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ +bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ +bool usehostname = 0; /* Use hostname for our_name */ +bool auth_required = 0; /* Always require authentication from peer */ +bool allow_any_ip = 0; /* Allow peer to use any IP address */ +bool explicit_remote = 0; /* User specified explicit remote name */ +char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ + +#endif /* UNUSED */ + +/* Bits in auth_pending[] */ +#define PAP_WITHPEER 1 +#define PAP_PEER 2 +#define CHAP_WITHPEER 4 +#define CHAP_PEER 8 + +/* @todo, move this somewhere */ +/* Used for storing a sequence of words. Usually malloced. */ +struct wordlist { + struct wordlist *next; + char word[1]; +}; + + +extern char *crypt (const char *, const char *); + +/* Prototypes for procedures local to this file. */ + +static void network_phase (int); +static void check_idle (void *); +static void connect_time_expired (void *); +#if 0 +static int plogin (char *, char *, char **, int *); +#endif +static void plogout (void); +static int null_login (int); +static int get_pap_passwd (int, char *, char *); +static int have_pap_secret (void); +static int have_chap_secret (char *, char *, u32_t); +static int ip_addr_check (u32_t, struct wordlist *); + +#if 0 /* PAP_SUPPORT || CHAP_SUPPORT */ +static int scan_authfile (FILE *, char *, char *, char *, + struct wordlist **, struct wordlist **, + char *); +static void free_wordlist (struct wordlist *); +static void auth_script (char *); +static void auth_script_done (void *); +static void set_allowed_addrs (int unit, struct wordlist *addrs); +static int some_ip_ok (struct wordlist *); +static int setupapfile (char **); +static int privgroup (char **); +static int set_noauth_addr (char **); +static void check_access (FILE *, char *); +#endif /* 0 */ /* PAP_SUPPORT || CHAP_SUPPORT */ + +#if 0 /* UNUSED */ +/* + * Authentication-related options. + */ +option_t auth_options[] = { + { "require-pap", o_bool, &lcp_wantoptions[0].neg_upap, + "Require PAP authentication from peer", 1, &auth_required }, + { "+pap", o_bool, &lcp_wantoptions[0].neg_upap, + "Require PAP authentication from peer", 1, &auth_required }, + { "refuse-pap", o_bool, &refuse_pap, + "Don't agree to auth to peer with PAP", 1 }, + { "-pap", o_bool, &refuse_pap, + "Don't allow PAP authentication with peer", 1 }, + { "require-chap", o_bool, &lcp_wantoptions[0].neg_chap, + "Require CHAP authentication from peer", 1, &auth_required }, + { "+chap", o_bool, &lcp_wantoptions[0].neg_chap, + "Require CHAP authentication from peer", 1, &auth_required }, + { "refuse-chap", o_bool, &refuse_chap, + "Don't agree to auth to peer with CHAP", 1 }, + { "-chap", o_bool, &refuse_chap, + "Don't allow CHAP authentication with peer", 1 }, + { "name", o_string, our_name, + "Set local name for authentication", + OPT_PRIV|OPT_STATIC, NULL, MAXNAMELEN }, + { "user", o_string, user, + "Set name for auth with peer", OPT_STATIC, NULL, MAXNAMELEN }, + { "usehostname", o_bool, &usehostname, + "Must use hostname for authentication", 1 }, + { "remotename", o_string, remote_name, + "Set remote name for authentication", OPT_STATIC, + &explicit_remote, MAXNAMELEN }, + { "auth", o_bool, &auth_required, + "Require authentication from peer", 1 }, + { "noauth", o_bool, &auth_required, + "Don't require peer to authenticate", OPT_PRIV, &allow_any_ip }, + { "login", o_bool, &uselogin, + "Use system password database for PAP", 1 }, + { "papcrypt", o_bool, &cryptpap, + "PAP passwords are encrypted", 1 }, + { "+ua", o_special, (void *)setupapfile, + "Get PAP user and password from file" }, + { "password", o_string, passwd, + "Password for authenticating us to the peer", OPT_STATIC, + NULL, MAXSECRETLEN }, + { "privgroup", o_special, (void *)privgroup, + "Allow group members to use privileged options", OPT_PRIV }, + { "allow-ip", o_special, (void *)set_noauth_addr, + "Set IP address(es) which can be used without authentication", + OPT_PRIV }, + { NULL } +}; +#endif /* UNUSED */ +#if 0 /* UNUSED */ +/* + * setupapfile - specifies UPAP info for authenticating with peer. + */ +static int +setupapfile(char **argv) +{ + FILE * ufile; + int l; + + lcp_allowoptions[0].neg_upap = 1; + + /* open user info file */ + seteuid(getuid()); + ufile = fopen(*argv, "r"); + seteuid(0); + if (ufile == NULL) { + option_error("unable to open user login data file %s", *argv); + return 0; + } + check_access(ufile, *argv); + + /* get username */ + if (fgets(user, MAXNAMELEN - 1, ufile) == NULL + || fgets(passwd, MAXSECRETLEN - 1, ufile) == NULL){ + option_error("unable to read user login data file %s", *argv); + return 0; + } + fclose(ufile); + + /* get rid of newlines */ + l = strlen(user); + if (l > 0 && user[l-1] == '\n') + user[l-1] = 0; + l = strlen(passwd); + if (l > 0 && passwd[l-1] == '\n') + passwd[l-1] = 0; + + return (1); +} +#endif /* UNUSED */ + +#if 0 /* UNUSED */ +/* + * privgroup - allow members of the group to have privileged access. + */ +static int +privgroup(char **argv) +{ + struct group *g; + int i; + + g = getgrnam(*argv); + if (g == 0) { + option_error("group %s is unknown", *argv); + return 0; + } + for (i = 0; i < ngroups; ++i) { + if (groups[i] == g->gr_gid) { + privileged = 1; + break; + } + } + return 1; +} +#endif + +#if 0 /* UNUSED */ +/* + * set_noauth_addr - set address(es) that can be used without authentication. + * Equivalent to specifying an entry like `"" * "" addr' in pap-secrets. + */ +static int +set_noauth_addr(char **argv) +{ + char *addr = *argv; + int l = strlen(addr); + struct wordlist *wp; + + wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l + 1); + if (wp == NULL) + novm("allow-ip argument"); + wp->word = (char *) (wp + 1); + wp->next = noauth_addrs; + BCOPY(addr, wp->word, l); + noauth_addrs = wp; + return 1; +} +#endif /* UNUSED */ + +/* + * An Open on LCP has requested a change from Dead to Establish phase. + * Do what's necessary to bring the physical layer up. + */ +void +link_required(int unit) +{ + LWIP_UNUSED_ARG(unit); + + AUTHDEBUG(LOG_INFO, ("link_required: %d\n", unit)); +} + +/* + * LCP has terminated the link; go to the Dead phase and take the + * physical layer down. + */ +void +link_terminated(int unit) +{ + AUTHDEBUG(LOG_INFO, ("link_terminated: %d\n", unit)); + if (lcp_phase[unit] == PHASE_DEAD) { + return; + } + if (logged_in) { + plogout(); + } + lcp_phase[unit] = PHASE_DEAD; + AUTHDEBUG(LOG_NOTICE, ("Connection terminated.\n")); + pppLinkTerminated(unit); +} + +/* + * LCP has gone down; it will either die or try to re-establish. + */ +void +link_down(int unit) +{ + int i; + struct protent *protp; + + AUTHDEBUG(LOG_INFO, ("link_down: %d\n", unit)); + + if (did_authup) { + /* XXX Do link down processing. */ + did_authup = 0; + } + for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { + if (!protp->enabled_flag) { + continue; + } + if (protp->protocol != PPP_LCP && protp->lowerdown != NULL) { + (*protp->lowerdown)(unit); + } + if (protp->protocol < 0xC000 && protp->close != NULL) { + (*protp->close)(unit, "LCP down"); + } + } + num_np_open = 0; /* number of network protocols we have opened */ + num_np_up = 0; /* Number of network protocols which have come up */ + + if (lcp_phase[unit] != PHASE_DEAD) { + lcp_phase[unit] = PHASE_TERMINATE; + } + pppLinkDown(unit); +} + +/* + * The link is established. + * Proceed to the Dead, Authenticate or Network phase as appropriate. + */ +void +link_established(int unit) +{ + int auth; + int i; + struct protent *protp; + lcp_options *wo = &lcp_wantoptions[unit]; + lcp_options *go = &lcp_gotoptions[unit]; +#if PAP_SUPPORT || CHAP_SUPPORT + lcp_options *ho = &lcp_hisoptions[unit]; +#endif /* PAP_SUPPORT || CHAP_SUPPORT */ + + AUTHDEBUG(LOG_INFO, ("link_established: unit %d; Lowering up all protocols...\n", unit)); + /* + * Tell higher-level protocols that LCP is up. + */ + for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { + if (protp->protocol != PPP_LCP && protp->enabled_flag && protp->lowerup != NULL) { + (*protp->lowerup)(unit); + } + } + if (ppp_settings.auth_required && !(go->neg_chap || go->neg_upap)) { + /* + * We wanted the peer to authenticate itself, and it refused: + * treat it as though it authenticated with PAP using a username + * of "" and a password of "". If that's not OK, boot it out. + */ + if (!wo->neg_upap || !null_login(unit)) { + AUTHDEBUG(LOG_WARNING, ("peer refused to authenticate\n")); + lcp_close(unit, "peer refused to authenticate"); + return; + } + } + + lcp_phase[unit] = PHASE_AUTHENTICATE; + auth = 0; +#if CHAP_SUPPORT + if (go->neg_chap) { + ChapAuthPeer(unit, ppp_settings.our_name, go->chap_mdtype); + auth |= CHAP_PEER; + } +#endif /* CHAP_SUPPORT */ +#if PAP_SUPPORT && CHAP_SUPPORT + else +#endif /* PAP_SUPPORT && CHAP_SUPPORT */ +#if PAP_SUPPORT + if (go->neg_upap) { + upap_authpeer(unit); + auth |= PAP_PEER; + } +#endif /* PAP_SUPPORT */ +#if CHAP_SUPPORT + if (ho->neg_chap) { + ChapAuthWithPeer(unit, ppp_settings.user, ho->chap_mdtype); + auth |= CHAP_WITHPEER; + } +#endif /* CHAP_SUPPORT */ +#if PAP_SUPPORT && CHAP_SUPPORT + else +#endif /* PAP_SUPPORT && CHAP_SUPPORT */ +#if PAP_SUPPORT + if (ho->neg_upap) { + if (ppp_settings.passwd[0] == 0) { + passwd_from_file = 1; + if (!get_pap_passwd(unit, ppp_settings.user, ppp_settings.passwd)) { + AUTHDEBUG(LOG_ERR, ("No secret found for PAP login\n")); + } + } + upap_authwithpeer(unit, ppp_settings.user, ppp_settings.passwd); + auth |= PAP_WITHPEER; + } +#endif /* PAP_SUPPORT */ + auth_pending[unit] = auth; + + if (!auth) { + network_phase(unit); + } +} + +/* + * Proceed to the network phase. + */ +static void +network_phase(int unit) +{ + int i; + struct protent *protp; + lcp_options *go = &lcp_gotoptions[unit]; + + /* + * If the peer had to authenticate, run the auth-up script now. + */ + if ((go->neg_chap || go->neg_upap) && !did_authup) { + /* XXX Do setup for peer authentication. */ + did_authup = 1; + } + +#if CBCP_SUPPORT + /* + * If we negotiated callback, do it now. + */ + if (go->neg_cbcp) { + lcp_phase[unit] = PHASE_CALLBACK; + (*cbcp_protent.open)(unit); + return; + } +#endif /* CBCP_SUPPORT */ + + lcp_phase[unit] = PHASE_NETWORK; + for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { + if (protp->protocol < 0xC000 && protp->enabled_flag && protp->open != NULL) { + (*protp->open)(unit); + if (protp->protocol != PPP_CCP) { + ++num_np_open; + } + } + } + + if (num_np_open == 0) { + /* nothing to do */ + lcp_close(0, "No network protocols running"); + } +} +/* @todo: add void start_networks(void) here (pppd 2.3.11) */ + +/* + * The peer has failed to authenticate himself using `protocol'. + */ +void +auth_peer_fail(int unit, u16_t protocol) +{ + LWIP_UNUSED_ARG(protocol); + + AUTHDEBUG(LOG_INFO, ("auth_peer_fail: %d proto=%X\n", unit, protocol)); + /* + * Authentication failure: take the link down + */ + lcp_close(unit, "Authentication failed"); +} + + +#if PAP_SUPPORT || CHAP_SUPPORT +/* + * The peer has been successfully authenticated using `protocol'. + */ +void +auth_peer_success(int unit, u16_t protocol, char *name, int namelen) +{ + int pbit; + + AUTHDEBUG(LOG_INFO, ("auth_peer_success: %d proto=%X\n", unit, protocol)); + switch (protocol) { + case PPP_CHAP: + pbit = CHAP_PEER; + break; + case PPP_PAP: + pbit = PAP_PEER; + break; + default: + AUTHDEBUG(LOG_WARNING, ("auth_peer_success: unknown protocol %x\n", protocol)); + return; + } + + /* + * Save the authenticated name of the peer for later. + */ + if (namelen > (int)sizeof(peer_authname) - 1) { + namelen = sizeof(peer_authname) - 1; + } + BCOPY(name, peer_authname, namelen); + peer_authname[namelen] = 0; + + /* + * If there is no more authentication still to be done, + * proceed to the network (or callback) phase. + */ + if ((auth_pending[unit] &= ~pbit) == 0) { + network_phase(unit); + } +} + +/* + * We have failed to authenticate ourselves to the peer using `protocol'. + */ +void +auth_withpeer_fail(int unit, u16_t protocol) +{ + int errCode = PPPERR_AUTHFAIL; + + LWIP_UNUSED_ARG(protocol); + + AUTHDEBUG(LOG_INFO, ("auth_withpeer_fail: %d proto=%X\n", unit, protocol)); + if (passwd_from_file) { + BZERO(ppp_settings.passwd, MAXSECRETLEN); + } + + /* + * We've failed to authenticate ourselves to our peer. + * He'll probably take the link down, and there's not much + * we can do except wait for that. + */ + pppIOCtl(unit, PPPCTLS_ERRCODE, &errCode); + lcp_close(unit, "Failed to authenticate ourselves to peer"); +} + +/* + * We have successfully authenticated ourselves with the peer using `protocol'. + */ +void +auth_withpeer_success(int unit, u16_t protocol) +{ + int pbit; + + AUTHDEBUG(LOG_INFO, ("auth_withpeer_success: %d proto=%X\n", unit, protocol)); + switch (protocol) { + case PPP_CHAP: + pbit = CHAP_WITHPEER; + break; + case PPP_PAP: + if (passwd_from_file) { + BZERO(ppp_settings.passwd, MAXSECRETLEN); + } + pbit = PAP_WITHPEER; + break; + default: + AUTHDEBUG(LOG_WARNING, ("auth_peer_success: unknown protocol %x\n", protocol)); + pbit = 0; + } + + /* + * If there is no more authentication still being done, + * proceed to the network (or callback) phase. + */ + if ((auth_pending[unit] &= ~pbit) == 0) { + network_phase(unit); + } +} +#endif /* PAP_SUPPORT || CHAP_SUPPORT */ + + +/* + * np_up - a network protocol has come up. + */ +void +np_up(int unit, u16_t proto) +{ + LWIP_UNUSED_ARG(unit); + LWIP_UNUSED_ARG(proto); + + AUTHDEBUG(LOG_INFO, ("np_up: %d proto=%X\n", unit, proto)); + if (num_np_up == 0) { + AUTHDEBUG(LOG_INFO, ("np_up: maxconnect=%d idle_time_limit=%d\n",ppp_settings.maxconnect,ppp_settings.idle_time_limit)); + /* + * At this point we consider that the link has come up successfully. + */ + if (ppp_settings.idle_time_limit > 0) { + TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit); + } + + /* + * Set a timeout to close the connection once the maximum + * connect time has expired. + */ + if (ppp_settings.maxconnect > 0) { + TIMEOUT(connect_time_expired, 0, ppp_settings.maxconnect); + } + } + ++num_np_up; +} + +/* + * np_down - a network protocol has gone down. + */ +void +np_down(int unit, u16_t proto) +{ + LWIP_UNUSED_ARG(unit); + LWIP_UNUSED_ARG(proto); + + AUTHDEBUG(LOG_INFO, ("np_down: %d proto=%X\n", unit, proto)); + if (--num_np_up == 0 && ppp_settings.idle_time_limit > 0) { + UNTIMEOUT(check_idle, NULL); + } +} + +/* + * np_finished - a network protocol has finished using the link. + */ +void +np_finished(int unit, u16_t proto) +{ + LWIP_UNUSED_ARG(unit); + LWIP_UNUSED_ARG(proto); + + AUTHDEBUG(LOG_INFO, ("np_finished: %d proto=%X\n", unit, proto)); + if (--num_np_open <= 0) { + /* no further use for the link: shut up shop. */ + lcp_close(0, "No network protocols running"); + } +} + +/* + * check_idle - check whether the link has been idle for long + * enough that we can shut it down. + */ +static void +check_idle(void *arg) +{ + struct ppp_idle idle; + u_short itime; + + LWIP_UNUSED_ARG(arg); + if (!get_idle_time(0, &idle)) { + return; + } + itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); + if (itime >= ppp_settings.idle_time_limit) { + /* link is idle: shut it down. */ + AUTHDEBUG(LOG_INFO, ("Terminating connection due to lack of activity.\n")); + lcp_close(0, "Link inactive"); + } else { + TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit - itime); + } +} + +/* + * connect_time_expired - log a message and close the connection. + */ +static void +connect_time_expired(void *arg) +{ + LWIP_UNUSED_ARG(arg); + + AUTHDEBUG(LOG_INFO, ("Connect time expired\n")); + lcp_close(0, "Connect time expired"); /* Close connection */ +} + +#if 0 /* UNUSED */ +/* + * auth_check_options - called to check authentication options. + */ +void +auth_check_options(void) +{ + lcp_options *wo = &lcp_wantoptions[0]; + int can_auth; + ipcp_options *ipwo = &ipcp_wantoptions[0]; + u32_t remote; + + /* Default our_name to hostname, and user to our_name */ + if (ppp_settings.our_name[0] == 0 || ppp_settings.usehostname) { + strcpy(ppp_settings.our_name, ppp_settings.hostname); + } + + if (ppp_settings.user[0] == 0) { + strcpy(ppp_settings.user, ppp_settings.our_name); + } + + /* If authentication is required, ask peer for CHAP or PAP. */ + if (ppp_settings.auth_required && !wo->neg_chap && !wo->neg_upap) { + wo->neg_chap = 1; + wo->neg_upap = 1; + } + + /* + * Check whether we have appropriate secrets to use + * to authenticate the peer. + */ + can_auth = wo->neg_upap && have_pap_secret(); + if (!can_auth && wo->neg_chap) { + remote = ipwo->accept_remote? 0: ipwo->hisaddr; + can_auth = have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote); + } + + if (ppp_settings.auth_required && !can_auth) { + ppp_panic("No auth secret"); + } +} +#endif /* UNUSED */ + +/* + * auth_reset - called when LCP is starting negotiations to recheck + * authentication options, i.e. whether we have appropriate secrets + * to use for authenticating ourselves and/or the peer. + */ +void +auth_reset(int unit) +{ + lcp_options *go = &lcp_gotoptions[unit]; + lcp_options *ao = &lcp_allowoptions[0]; + ipcp_options *ipwo = &ipcp_wantoptions[0]; + u32_t remote; + + AUTHDEBUG(LOG_INFO, ("auth_reset: %d\n", unit)); + ao->neg_upap = !ppp_settings.refuse_pap && (ppp_settings.passwd[0] != 0 || get_pap_passwd(unit, NULL, NULL)); + ao->neg_chap = !ppp_settings.refuse_chap && ppp_settings.passwd[0] != 0 /*have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0)*/; + + if (go->neg_upap && !have_pap_secret()) { + go->neg_upap = 0; + } + if (go->neg_chap) { + remote = ipwo->accept_remote? 0: ipwo->hisaddr; + if (!have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote)) { + go->neg_chap = 0; + } + } +} + +#if PAP_SUPPORT +/* + * check_passwd - Check the user name and passwd against the PAP secrets + * file. If requested, also check against the system password database, + * and login the user if OK. + * + * returns: + * UPAP_AUTHNAK: Authentication failed. + * UPAP_AUTHACK: Authentication succeeded. + * In either case, msg points to an appropriate message. + */ +u_char +check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, char **msg, int *msglen) +{ +#if 1 /* XXX Assume all entries OK. */ + LWIP_UNUSED_ARG(unit); + LWIP_UNUSED_ARG(auser); + LWIP_UNUSED_ARG(userlen); + LWIP_UNUSED_ARG(apasswd); + LWIP_UNUSED_ARG(passwdlen); + LWIP_UNUSED_ARG(msglen); + *msg = (char *) 0; + return UPAP_AUTHACK; /* XXX Assume all entries OK. */ +#else + u_char ret = 0; + struct wordlist *addrs = NULL; + char passwd[256], user[256]; + char secret[MAXWORDLEN]; + static u_short attempts = 0; + + /* + * Make copies of apasswd and auser, then null-terminate them. + */ + BCOPY(apasswd, passwd, passwdlen); + passwd[passwdlen] = '\0'; + BCOPY(auser, user, userlen); + user[userlen] = '\0'; + *msg = (char *) 0; + + /* XXX Validate user name and password. */ + ret = UPAP_AUTHACK; /* XXX Assume all entries OK. */ + + if (ret == UPAP_AUTHNAK) { + if (*msg == (char *) 0) { + *msg = "Login incorrect"; + } + *msglen = strlen(*msg); + /* + * Frustrate passwd stealer programs. + * Allow 10 tries, but start backing off after 3 (stolen from login). + * On 10'th, drop the connection. + */ + if (attempts++ >= 10) { + AUTHDEBUG(LOG_WARNING, ("%d LOGIN FAILURES BY %s\n", attempts, user)); + /*ppp_panic("Excess Bad Logins");*/ + } + if (attempts > 3) { + /* @todo: this was sleep(), i.e. seconds, not milliseconds + * I don't think we really need this in lwIP - we would block tcpip_thread! + */ + /*sys_msleep((attempts - 3) * 5);*/ + } + if (addrs != NULL) { + free_wordlist(addrs); + } + } else { + attempts = 0; /* Reset count */ + if (*msg == (char *) 0) { + *msg = "Login ok"; + } + *msglen = strlen(*msg); + set_allowed_addrs(unit, addrs); + } + + BZERO(passwd, sizeof(passwd)); + BZERO(secret, sizeof(secret)); + + return ret; +#endif +} +#endif /* PAP_SUPPORT */ + +#if 0 /* UNUSED */ +/* + * This function is needed for PAM. + */ + +#ifdef USE_PAM + +/* lwip does not support PAM*/ + +#endif /* USE_PAM */ + +#endif /* UNUSED */ + + +#if 0 /* UNUSED */ +/* + * plogin - Check the user name and password against the system + * password database, and login the user if OK. + * + * returns: + * UPAP_AUTHNAK: Login failed. + * UPAP_AUTHACK: Login succeeded. + * In either case, msg points to an appropriate message. + */ +static int +plogin(char *user, char *passwd, char **msg, int *msglen) +{ + + LWIP_UNUSED_ARG(user); + LWIP_UNUSED_ARG(passwd); + LWIP_UNUSED_ARG(msg); + LWIP_UNUSED_ARG(msglen); + + + /* The new lines are here align the file when + * compared against the pppd 2.3.11 code */ + + + + + + + + + + + + + + + + + /* XXX Fail until we decide that we want to support logins. */ + return (UPAP_AUTHNAK); +} +#endif + + + +/* + * plogout - Logout the user. + */ +static void +plogout(void) +{ + logged_in = 0; +} + +/* + * null_login - Check if a username of "" and a password of "" are + * acceptable, and iff so, set the list of acceptable IP addresses + * and return 1. + */ +static int +null_login(int unit) +{ + LWIP_UNUSED_ARG(unit); + /* XXX Fail until we decide that we want to support logins. */ + return 0; +} + + +/* + * get_pap_passwd - get a password for authenticating ourselves with + * our peer using PAP. Returns 1 on success, 0 if no suitable password + * could be found. + */ +static int +get_pap_passwd(int unit, char *user, char *passwd) +{ + LWIP_UNUSED_ARG(unit); +/* normally we would reject PAP if no password is provided, + but this causes problems with some providers (like CHT in Taiwan) + who incorrectly request PAP and expect a bogus/empty password, so + always provide a default user/passwd of "none"/"none" + + @todo: This should be configured by the user, instead of being hardcoded here! +*/ + if(user) { + strcpy(user, "none"); + } + if(passwd) { + strcpy(passwd, "none"); + } + return 1; +} + +/* + * have_pap_secret - check whether we have a PAP file with any + * secrets that we could possibly use for authenticating the peer. + */ +static int +have_pap_secret(void) +{ + /* XXX Fail until we set up our passwords. */ + return 0; +} + +/* + * have_chap_secret - check whether we have a CHAP file with a + * secret that we could possibly use for authenticating `client' + * on `server'. Either can be the null string, meaning we don't + * know the identity yet. + */ +static int +have_chap_secret(char *client, char *server, u32_t remote) +{ + LWIP_UNUSED_ARG(client); + LWIP_UNUSED_ARG(server); + LWIP_UNUSED_ARG(remote); + + /* XXX Fail until we set up our passwords. */ + return 0; +} +#if CHAP_SUPPORT + +/* + * get_secret - open the CHAP secret file and return the secret + * for authenticating the given client on the given server. + * (We could be either client or server). + */ +int +get_secret(int unit, char *client, char *server, char *secret, int *secret_len, int save_addrs) +{ +#if 1 + int len; + struct wordlist *addrs; + + LWIP_UNUSED_ARG(unit); + LWIP_UNUSED_ARG(server); + LWIP_UNUSED_ARG(save_addrs); + + addrs = NULL; + + if(!client || !client[0] || strcmp(client, ppp_settings.user)) { + return 0; + } + + len = (int)strlen(ppp_settings.passwd); + if (len > MAXSECRETLEN) { + AUTHDEBUG(LOG_ERR, ("Secret for %s on %s is too long\n", client, server)); + len = MAXSECRETLEN; + } + + BCOPY(ppp_settings.passwd, secret, len); + *secret_len = len; + + return 1; +#else + int ret = 0, len; + struct wordlist *addrs; + char secbuf[MAXWORDLEN]; + + addrs = NULL; + secbuf[0] = 0; + + /* XXX Find secret. */ + if (ret < 0) { + return 0; + } + + if (save_addrs) { + set_allowed_addrs(unit, addrs); + } + + len = strlen(secbuf); + if (len > MAXSECRETLEN) { + AUTHDEBUG(LOG_ERR, ("Secret for %s on %s is too long\n", client, server)); + len = MAXSECRETLEN; + } + + BCOPY(secbuf, secret, len); + BZERO(secbuf, sizeof(secbuf)); + *secret_len = len; + + return 1; +#endif +} +#endif /* CHAP_SUPPORT */ + + +#if 0 /* PAP_SUPPORT || CHAP_SUPPORT */ +/* + * set_allowed_addrs() - set the list of allowed addresses. + */ +static void +set_allowed_addrs(int unit, struct wordlist *addrs) +{ + if (addresses[unit] != NULL) { + free_wordlist(addresses[unit]); + } + addresses[unit] = addrs; + +#if 0 + /* + * If there's only one authorized address we might as well + * ask our peer for that one right away + */ + if (addrs != NULL && addrs->next == NULL) { + char *p = addrs->word; + struct ipcp_options *wo = &ipcp_wantoptions[unit]; + u32_t a; + struct hostent *hp; + + if (wo->hisaddr == 0 && *p != '!' && *p != '-' && strchr(p, '/') == NULL) { + hp = gethostbyname(p); + if (hp != NULL && hp->h_addrtype == AF_INET) { + a = *(u32_t *)hp->h_addr; + } else { + a = inet_addr(p); + } + if (a != (u32_t) -1) { + wo->hisaddr = a; + } + } + } +#endif +} +#endif /* 0 */ /* PAP_SUPPORT || CHAP_SUPPORT */ + +/* + * auth_ip_addr - check whether the peer is authorized to use + * a given IP address. Returns 1 if authorized, 0 otherwise. + */ +int +auth_ip_addr(int unit, u32_t addr) +{ + return ip_addr_check(addr, addresses[unit]); +} + +static int /* @todo: integrate this funtion into auth_ip_addr()*/ +ip_addr_check(u32_t addr, struct wordlist *addrs) +{ + /* don't allow loopback or multicast address */ + if (bad_ip_adrs(addr)) { + return 0; + } + + if (addrs == NULL) { + return !ppp_settings.auth_required; /* no addresses authorized */ + } + + /* XXX All other addresses allowed. */ + return 1; +} + +/* + * bad_ip_adrs - return 1 if the IP address is one we don't want + * to use, such as an address in the loopback net or a multicast address. + * addr is in network byte order. + */ +int +bad_ip_adrs(u32_t addr) +{ + addr = ntohl(addr); + return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET + || IN_MULTICAST(addr) || IN_BADCLASS(addr); +} + +#if 0 /* UNUSED */ /* PAP_SUPPORT || CHAP_SUPPORT */ +/* + * some_ip_ok - check a wordlist to see if it authorizes any + * IP address(es). + */ +static int +some_ip_ok(struct wordlist *addrs) +{ + for (; addrs != 0; addrs = addrs->next) { + if (addrs->word[0] == '-') + break; + if (addrs->word[0] != '!') + return 1; /* some IP address is allowed */ + } + return 0; +} + +/* + * check_access - complain if a secret file has too-liberal permissions. + */ +static void +check_access(FILE *f, char *filename) +{ + struct stat sbuf; + + if (fstat(fileno(f), &sbuf) < 0) { + warn("cannot stat secret file %s: %m", filename); + } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) { + warn("Warning - secret file %s has world and/or group access", + filename); + } +} + + +/* + * scan_authfile - Scan an authorization file for a secret suitable + * for authenticating `client' on `server'. The return value is -1 + * if no secret is found, otherwise >= 0. The return value has + * NONWILD_CLIENT set if the secret didn't have "*" for the client, and + * NONWILD_SERVER set if the secret didn't have "*" for the server. + * Any following words on the line up to a "--" (i.e. address authorization + * info) are placed in a wordlist and returned in *addrs. Any + * following words (extra options) are placed in a wordlist and + * returned in *opts. + * We assume secret is NULL or points to MAXWORDLEN bytes of space. + */ +static int +scan_authfile(FILE *f, char *client, char *server, char *secret, struct wordlist **addrs, struct wordlist **opts, char *filename) +{ + /* We do not (currently) need this in lwip */ + return 0; /* dummy */ +} +/* + * free_wordlist - release memory allocated for a wordlist. + */ +static void +free_wordlist(struct wordlist *wp) +{ + struct wordlist *next; + + while (wp != NULL) { + next = wp->next; + free(wp); + wp = next; + } +} + +/* + * auth_script_done - called when the auth-up or auth-down script + * has finished. + */ +static void +auth_script_done(void *arg) +{ + auth_script_pid = 0; + switch (auth_script_state) { + case s_up: + if (auth_state == s_down) { + auth_script_state = s_down; + auth_script(_PATH_AUTHDOWN); + } + break; + case s_down: + if (auth_state == s_up) { + auth_script_state = s_up; + auth_script(_PATH_AUTHUP); + } + break; + } +} + +/* + * auth_script - execute a script with arguments + * interface-name peer-name real-user tty speed + */ +static void +auth_script(char *script) +{ + char strspeed[32]; + struct passwd *pw; + char struid[32]; + char *user_name; + char *argv[8]; + + if ((pw = getpwuid(getuid())) != NULL && pw->pw_name != NULL) + user_name = pw->pw_name; + else { + slprintf(struid, sizeof(struid), "%d", getuid()); + user_name = struid; + } + slprintf(strspeed, sizeof(strspeed), "%d", baud_rate); + + argv[0] = script; + argv[1] = ifname; + argv[2] = peer_authname; + argv[3] = user_name; + argv[4] = devnam; + argv[5] = strspeed; + argv[6] = NULL; + + auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL); +} +#endif /* 0 */ /* PAP_SUPPORT || CHAP_SUPPORT */ +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/auth.h b/user/mpy/lib/lwip/src/netif/ppp/auth.h new file mode 100644 index 0000000..a8069ec --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/auth.h @@ -0,0 +1,111 @@ +/***************************************************************************** +* auth.h - PPP Authentication and phase control header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1998 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-04 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD pppd.h. +*****************************************************************************/ +/* + * pppd.h - PPP daemon global declarations. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef AUTH_H +#define AUTH_H + +/*********************** +*** PUBLIC FUNCTIONS *** +***********************/ + +/* we are starting to use the link */ +void link_required (int); + +/* we are finished with the link */ +void link_terminated (int); + +/* the LCP layer has left the Opened state */ +void link_down (int); + +/* the link is up; authenticate now */ +void link_established (int); + +/* a network protocol has come up */ +void np_up (int, u16_t); + +/* a network protocol has gone down */ +void np_down (int, u16_t); + +/* a network protocol no longer needs link */ +void np_finished (int, u16_t); + +/* peer failed to authenticate itself */ +void auth_peer_fail (int, u16_t); + +/* peer successfully authenticated itself */ +void auth_peer_success (int, u16_t, char *, int); + +/* we failed to authenticate ourselves */ +void auth_withpeer_fail (int, u16_t); + +/* we successfully authenticated ourselves */ +void auth_withpeer_success (int, u16_t); + +/* check authentication options supplied */ +void auth_check_options (void); + +/* check what secrets we have */ +void auth_reset (int); + +/* Check peer-supplied username/password */ +u_char check_passwd (int, char *, int, char *, int, char **, int *); + +/* get "secret" for chap */ +int get_secret (int, char *, char *, char *, int *, int); + +/* check if IP address is authorized */ +int auth_ip_addr (int, u32_t); + +/* check if IP address is unreasonable */ +int bad_ip_adrs (u32_t); + +#endif /* AUTH_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chap.c b/user/mpy/lib/lwip/src/netif/ppp/chap.c new file mode 100644 index 0000000..f10e27d --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/chap.c @@ -0,0 +1,908 @@ +/*** WARNING - THIS HAS NEVER BEEN FINISHED ***/ +/***************************************************************************** +* chap.c - Network Challenge Handshake Authentication Protocol program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-04 Guy Lancaster , Global Election Systems Inc. +* Original based on BSD chap.c. +*****************************************************************************/ +/* + * chap.c - Challenge Handshake Authentication Protocol. + * + * Copyright (c) 1993 The Australian National University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the Australian National University. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Copyright (c) 1991 Gregory M. Christy. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Gregory M. Christy. The name of the author may not be used to + * endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#if CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "magic.h" +#include "randm.h" +#include "auth.h" +#include "md5.h" +#include "chap.h" +#include "chpms.h" + +#include + +#if 0 /* UNUSED */ +/* + * Command-line options. + */ +static option_t chap_option_list[] = { + { "chap-restart", o_int, &chap[0].timeouttime, + "Set timeout for CHAP" }, + { "chap-max-challenge", o_int, &chap[0].max_transmits, + "Set max #xmits for challenge" }, + { "chap-interval", o_int, &chap[0].chal_interval, + "Set interval for rechallenge" }, +#ifdef MSLANMAN + { "ms-lanman", o_bool, &ms_lanman, + "Use LanMan passwd when using MS-CHAP", 1 }, +#endif + { NULL } +}; +#endif /* UNUSED */ + +/* + * Protocol entry points. + */ +static void ChapInit (int); +static void ChapLowerUp (int); +static void ChapLowerDown (int); +static void ChapInput (int, u_char *, int); +static void ChapProtocolReject (int); +#if PPP_ADDITIONAL_CALLBACKS +static int ChapPrintPkt (u_char *, int, void (*) (void *, char *, ...), void *); +#endif + +struct protent chap_protent = { + PPP_CHAP, + ChapInit, + ChapInput, + ChapProtocolReject, + ChapLowerUp, + ChapLowerDown, + NULL, + NULL, +#if PPP_ADDITIONAL_CALLBACKS + ChapPrintPkt, + NULL, +#endif /* PPP_ADDITIONAL_CALLBACKS */ + 1, + "CHAP", +#if PPP_ADDITIONAL_CALLBACKS + NULL, + NULL, + NULL +#endif /* PPP_ADDITIONAL_CALLBACKS */ +}; + +chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */ + +static void ChapChallengeTimeout (void *); +static void ChapResponseTimeout (void *); +static void ChapReceiveChallenge (chap_state *, u_char *, u_char, int); +static void ChapRechallenge (void *); +static void ChapReceiveResponse (chap_state *, u_char *, int, int); +static void ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len); +static void ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len); +static void ChapSendStatus (chap_state *, int); +static void ChapSendChallenge (chap_state *); +static void ChapSendResponse (chap_state *); +static void ChapGenChallenge (chap_state *); + +/* + * ChapInit - Initialize a CHAP unit. + */ +static void +ChapInit(int unit) +{ + chap_state *cstate = &chap[unit]; + + BZERO(cstate, sizeof(*cstate)); + cstate->unit = unit; + cstate->clientstate = CHAPCS_INITIAL; + cstate->serverstate = CHAPSS_INITIAL; + cstate->timeouttime = CHAP_DEFTIMEOUT; + cstate->max_transmits = CHAP_DEFTRANSMITS; + /* random number generator is initialized in magic_init */ +} + + +/* + * ChapAuthWithPeer - Authenticate us with our peer (start client). + * + */ +void +ChapAuthWithPeer(int unit, char *our_name, u_char digest) +{ + chap_state *cstate = &chap[unit]; + + cstate->resp_name = our_name; + cstate->resp_type = digest; + + if (cstate->clientstate == CHAPCS_INITIAL || + cstate->clientstate == CHAPCS_PENDING) { + /* lower layer isn't up - wait until later */ + cstate->clientstate = CHAPCS_PENDING; + return; + } + + /* + * We get here as a result of LCP coming up. + * So even if CHAP was open before, we will + * have to re-authenticate ourselves. + */ + cstate->clientstate = CHAPCS_LISTEN; +} + + +/* + * ChapAuthPeer - Authenticate our peer (start server). + */ +void +ChapAuthPeer(int unit, char *our_name, u_char digest) +{ + chap_state *cstate = &chap[unit]; + + cstate->chal_name = our_name; + cstate->chal_type = digest; + + if (cstate->serverstate == CHAPSS_INITIAL || + cstate->serverstate == CHAPSS_PENDING) { + /* lower layer isn't up - wait until later */ + cstate->serverstate = CHAPSS_PENDING; + return; + } + + ChapGenChallenge(cstate); + ChapSendChallenge(cstate); /* crank it up dude! */ + cstate->serverstate = CHAPSS_INITIAL_CHAL; +} + + +/* + * ChapChallengeTimeout - Timeout expired on sending challenge. + */ +static void +ChapChallengeTimeout(void *arg) +{ + chap_state *cstate = (chap_state *) arg; + + /* if we aren't sending challenges, don't worry. then again we */ + /* probably shouldn't be here either */ + if (cstate->serverstate != CHAPSS_INITIAL_CHAL && + cstate->serverstate != CHAPSS_RECHALLENGE) { + return; + } + + if (cstate->chal_transmits >= cstate->max_transmits) { + /* give up on peer */ + CHAPDEBUG(LOG_ERR, ("Peer failed to respond to CHAP challenge\n")); + cstate->serverstate = CHAPSS_BADAUTH; + auth_peer_fail(cstate->unit, PPP_CHAP); + return; + } + + ChapSendChallenge(cstate); /* Re-send challenge */ +} + + +/* + * ChapResponseTimeout - Timeout expired on sending response. + */ +static void +ChapResponseTimeout(void *arg) +{ + chap_state *cstate = (chap_state *) arg; + + /* if we aren't sending a response, don't worry. */ + if (cstate->clientstate != CHAPCS_RESPONSE) { + return; + } + + ChapSendResponse(cstate); /* re-send response */ +} + + +/* + * ChapRechallenge - Time to challenge the peer again. + */ +static void +ChapRechallenge(void *arg) +{ + chap_state *cstate = (chap_state *) arg; + + /* if we aren't sending a response, don't worry. */ + if (cstate->serverstate != CHAPSS_OPEN) { + return; + } + + ChapGenChallenge(cstate); + ChapSendChallenge(cstate); + cstate->serverstate = CHAPSS_RECHALLENGE; +} + + +/* + * ChapLowerUp - The lower layer is up. + * + * Start up if we have pending requests. + */ +static void +ChapLowerUp(int unit) +{ + chap_state *cstate = &chap[unit]; + + if (cstate->clientstate == CHAPCS_INITIAL) { + cstate->clientstate = CHAPCS_CLOSED; + } else if (cstate->clientstate == CHAPCS_PENDING) { + cstate->clientstate = CHAPCS_LISTEN; + } + + if (cstate->serverstate == CHAPSS_INITIAL) { + cstate->serverstate = CHAPSS_CLOSED; + } else if (cstate->serverstate == CHAPSS_PENDING) { + ChapGenChallenge(cstate); + ChapSendChallenge(cstate); + cstate->serverstate = CHAPSS_INITIAL_CHAL; + } +} + + +/* + * ChapLowerDown - The lower layer is down. + * + * Cancel all timeouts. + */ +static void +ChapLowerDown(int unit) +{ + chap_state *cstate = &chap[unit]; + + /* Timeout(s) pending? Cancel if so. */ + if (cstate->serverstate == CHAPSS_INITIAL_CHAL || + cstate->serverstate == CHAPSS_RECHALLENGE) { + UNTIMEOUT(ChapChallengeTimeout, cstate); + } else if (cstate->serverstate == CHAPSS_OPEN + && cstate->chal_interval != 0) { + UNTIMEOUT(ChapRechallenge, cstate); + } + if (cstate->clientstate == CHAPCS_RESPONSE) { + UNTIMEOUT(ChapResponseTimeout, cstate); + } + cstate->clientstate = CHAPCS_INITIAL; + cstate->serverstate = CHAPSS_INITIAL; +} + + +/* + * ChapProtocolReject - Peer doesn't grok CHAP. + */ +static void +ChapProtocolReject(int unit) +{ + chap_state *cstate = &chap[unit]; + + if (cstate->serverstate != CHAPSS_INITIAL && + cstate->serverstate != CHAPSS_CLOSED) { + auth_peer_fail(unit, PPP_CHAP); + } + if (cstate->clientstate != CHAPCS_INITIAL && + cstate->clientstate != CHAPCS_CLOSED) { + auth_withpeer_fail(unit, PPP_CHAP); /* lwip: just sets the PPP error code on this unit to PPPERR_AUTHFAIL */ + } + ChapLowerDown(unit); /* shutdown chap */ +} + + +/* + * ChapInput - Input CHAP packet. + */ +static void +ChapInput(int unit, u_char *inpacket, int packet_len) +{ + chap_state *cstate = &chap[unit]; + u_char *inp; + u_char code, id; + int len; + + /* + * Parse header (code, id and length). + * If packet too short, drop it. + */ + inp = inpacket; + if (packet_len < CHAP_HEADERLEN) { + CHAPDEBUG(LOG_INFO, ("ChapInput: rcvd short header.\n")); + return; + } + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < CHAP_HEADERLEN) { + CHAPDEBUG(LOG_INFO, ("ChapInput: rcvd illegal length.\n")); + return; + } + if (len > packet_len) { + CHAPDEBUG(LOG_INFO, ("ChapInput: rcvd short packet.\n")); + return; + } + len -= CHAP_HEADERLEN; + + /* + * Action depends on code (as in fact it usually does :-). + */ + switch (code) { + case CHAP_CHALLENGE: + ChapReceiveChallenge(cstate, inp, id, len); + break; + + case CHAP_RESPONSE: + ChapReceiveResponse(cstate, inp, id, len); + break; + + case CHAP_FAILURE: + ChapReceiveFailure(cstate, inp, id, len); + break; + + case CHAP_SUCCESS: + ChapReceiveSuccess(cstate, inp, id, len); + break; + + default: /* Need code reject? */ + CHAPDEBUG(LOG_WARNING, ("Unknown CHAP code (%d) received.\n", code)); + break; + } +} + + +/* + * ChapReceiveChallenge - Receive Challenge and send Response. + */ +static void +ChapReceiveChallenge(chap_state *cstate, u_char *inp, u_char id, int len) +{ + int rchallenge_len; + u_char *rchallenge; + int secret_len; + char secret[MAXSECRETLEN]; + char rhostname[256]; + MD5_CTX mdContext; + u_char hash[MD5_SIGNATURE_SIZE]; + + CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: Rcvd id %d.\n", id)); + if (cstate->clientstate == CHAPCS_CLOSED || + cstate->clientstate == CHAPCS_PENDING) { + CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: in state %d\n", + cstate->clientstate)); + return; + } + + if (len < 2) { + CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: rcvd short packet.\n")); + return; + } + + GETCHAR(rchallenge_len, inp); + len -= sizeof (u_char) + rchallenge_len; /* now name field length */ + if (len < 0) { + CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: rcvd short packet.\n")); + return; + } + rchallenge = inp; + INCPTR(rchallenge_len, inp); + + if (len >= (int)sizeof(rhostname)) { + len = sizeof(rhostname) - 1; + } + BCOPY(inp, rhostname, len); + rhostname[len] = '\000'; + + CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: received name field '%s'\n", + rhostname)); + + /* Microsoft doesn't send their name back in the PPP packet */ + if (ppp_settings.remote_name[0] != 0 && (ppp_settings.explicit_remote || rhostname[0] == 0)) { + strncpy(rhostname, ppp_settings.remote_name, sizeof(rhostname)); + rhostname[sizeof(rhostname) - 1] = 0; + CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: using '%s' as remote name\n", + rhostname)); + } + + /* get secret for authenticating ourselves with the specified host */ + if (!get_secret(cstate->unit, cstate->resp_name, rhostname, + secret, &secret_len, 0)) { + secret_len = 0; /* assume null secret if can't find one */ + CHAPDEBUG(LOG_WARNING, ("No CHAP secret found for authenticating us to %s\n", + rhostname)); + } + + /* cancel response send timeout if necessary */ + if (cstate->clientstate == CHAPCS_RESPONSE) { + UNTIMEOUT(ChapResponseTimeout, cstate); + } + + cstate->resp_id = id; + cstate->resp_transmits = 0; + + /* generate MD based on negotiated type */ + switch (cstate->resp_type) { + + case CHAP_DIGEST_MD5: + MD5Init(&mdContext); + MD5Update(&mdContext, &cstate->resp_id, 1); + MD5Update(&mdContext, (u_char*)secret, secret_len); + MD5Update(&mdContext, rchallenge, rchallenge_len); + MD5Final(hash, &mdContext); + BCOPY(hash, cstate->response, MD5_SIGNATURE_SIZE); + cstate->resp_length = MD5_SIGNATURE_SIZE; + break; + +#if MSCHAP_SUPPORT + case CHAP_MICROSOFT: + ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len); + break; +#endif + + default: + CHAPDEBUG(LOG_INFO, ("unknown digest type %d\n", cstate->resp_type)); + return; + } + + BZERO(secret, sizeof(secret)); + ChapSendResponse(cstate); +} + + +/* + * ChapReceiveResponse - Receive and process response. + */ +static void +ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) +{ + u_char *remmd, remmd_len; + int secret_len, old_state; + int code; + char rhostname[256]; + MD5_CTX mdContext; + char secret[MAXSECRETLEN]; + u_char hash[MD5_SIGNATURE_SIZE]; + + CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: Rcvd id %d.\n", id)); + + if (cstate->serverstate == CHAPSS_CLOSED || + cstate->serverstate == CHAPSS_PENDING) { + CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: in state %d\n", + cstate->serverstate)); + return; + } + + if (id != cstate->chal_id) { + return; /* doesn't match ID of last challenge */ + } + + /* + * If we have received a duplicate or bogus Response, + * we have to send the same answer (Success/Failure) + * as we did for the first Response we saw. + */ + if (cstate->serverstate == CHAPSS_OPEN) { + ChapSendStatus(cstate, CHAP_SUCCESS); + return; + } + if (cstate->serverstate == CHAPSS_BADAUTH) { + ChapSendStatus(cstate, CHAP_FAILURE); + return; + } + + if (len < 2) { + CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: rcvd short packet.\n")); + return; + } + GETCHAR(remmd_len, inp); /* get length of MD */ + remmd = inp; /* get pointer to MD */ + INCPTR(remmd_len, inp); + + len -= sizeof (u_char) + remmd_len; + if (len < 0) { + CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: rcvd short packet.\n")); + return; + } + + UNTIMEOUT(ChapChallengeTimeout, cstate); + + if (len >= (int)sizeof(rhostname)) { + len = sizeof(rhostname) - 1; + } + BCOPY(inp, rhostname, len); + rhostname[len] = '\000'; + + CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: received name field: %s\n", + rhostname)); + + /* + * Get secret for authenticating them with us, + * do the hash ourselves, and compare the result. + */ + code = CHAP_FAILURE; + if (!get_secret(cstate->unit, rhostname, cstate->chal_name, + secret, &secret_len, 1)) { + CHAPDEBUG(LOG_WARNING, ("No CHAP secret found for authenticating %s\n", + rhostname)); + } else { + /* generate MD based on negotiated type */ + switch (cstate->chal_type) { + + case CHAP_DIGEST_MD5: /* only MD5 is defined for now */ + if (remmd_len != MD5_SIGNATURE_SIZE) { + break; /* it's not even the right length */ + } + MD5Init(&mdContext); + MD5Update(&mdContext, &cstate->chal_id, 1); + MD5Update(&mdContext, (u_char*)secret, secret_len); + MD5Update(&mdContext, cstate->challenge, cstate->chal_len); + MD5Final(hash, &mdContext); + + /* compare local and remote MDs and send the appropriate status */ + if (memcmp (hash, remmd, MD5_SIGNATURE_SIZE) == 0) { + code = CHAP_SUCCESS; /* they are the same! */ + } + break; + + default: + CHAPDEBUG(LOG_INFO, ("unknown digest type %d\n", cstate->chal_type)); + } + } + + BZERO(secret, sizeof(secret)); + ChapSendStatus(cstate, code); + + if (code == CHAP_SUCCESS) { + old_state = cstate->serverstate; + cstate->serverstate = CHAPSS_OPEN; + if (old_state == CHAPSS_INITIAL_CHAL) { + auth_peer_success(cstate->unit, PPP_CHAP, rhostname, len); + } + if (cstate->chal_interval != 0) { + TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval); + } + } else { + CHAPDEBUG(LOG_ERR, ("CHAP peer authentication failed\n")); + cstate->serverstate = CHAPSS_BADAUTH; + auth_peer_fail(cstate->unit, PPP_CHAP); + } +} + +/* + * ChapReceiveSuccess - Receive Success + */ +static void +ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len) +{ + LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(inp); + + CHAPDEBUG(LOG_INFO, ("ChapReceiveSuccess: Rcvd id %d.\n", id)); + + if (cstate->clientstate == CHAPCS_OPEN) { + /* presumably an answer to a duplicate response */ + return; + } + + if (cstate->clientstate != CHAPCS_RESPONSE) { + /* don't know what this is */ + CHAPDEBUG(LOG_INFO, ("ChapReceiveSuccess: in state %d\n", + cstate->clientstate)); + return; + } + + UNTIMEOUT(ChapResponseTimeout, cstate); + + /* + * Print message. + */ + if (len > 0) { + PRINTMSG(inp, len); + } + + cstate->clientstate = CHAPCS_OPEN; + + auth_withpeer_success(cstate->unit, PPP_CHAP); +} + + +/* + * ChapReceiveFailure - Receive failure. + */ +static void +ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len) +{ + LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(inp); + + CHAPDEBUG(LOG_INFO, ("ChapReceiveFailure: Rcvd id %d.\n", id)); + + if (cstate->clientstate != CHAPCS_RESPONSE) { + /* don't know what this is */ + CHAPDEBUG(LOG_INFO, ("ChapReceiveFailure: in state %d\n", + cstate->clientstate)); + return; + } + + UNTIMEOUT(ChapResponseTimeout, cstate); + + /* + * Print message. + */ + if (len > 0) { + PRINTMSG(inp, len); + } + + CHAPDEBUG(LOG_ERR, ("CHAP authentication failed\n")); + auth_withpeer_fail(cstate->unit, PPP_CHAP); /* lwip: just sets the PPP error code on this unit to PPPERR_AUTHFAIL */ +} + + +/* + * ChapSendChallenge - Send an Authenticate challenge. + */ +static void +ChapSendChallenge(chap_state *cstate) +{ + u_char *outp; + int chal_len, name_len; + int outlen; + + chal_len = cstate->chal_len; + name_len = (int)strlen(cstate->chal_name); + outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len; + outp = outpacket_buf[cstate->unit]; + + MAKEHEADER(outp, PPP_CHAP); /* paste in a CHAP header */ + + PUTCHAR(CHAP_CHALLENGE, outp); + PUTCHAR(cstate->chal_id, outp); + PUTSHORT(outlen, outp); + + PUTCHAR(chal_len, outp); /* put length of challenge */ + BCOPY(cstate->challenge, outp, chal_len); + INCPTR(chal_len, outp); + + BCOPY(cstate->chal_name, outp, name_len); /* append hostname */ + + pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); + + CHAPDEBUG(LOG_INFO, ("ChapSendChallenge: Sent id %d.\n", cstate->chal_id)); + + TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime); + ++cstate->chal_transmits; +} + + +/* + * ChapSendStatus - Send a status response (ack or nak). + */ +static void +ChapSendStatus(chap_state *cstate, int code) +{ + u_char *outp; + int outlen, msglen; + char msg[256]; /* @todo: this can be a char*, no strcpy needed */ + + if (code == CHAP_SUCCESS) { + strcpy(msg, "Welcome!"); + } else { + strcpy(msg, "I don't like you. Go 'way."); + } + msglen = (int)strlen(msg); + + outlen = CHAP_HEADERLEN + msglen; + outp = outpacket_buf[cstate->unit]; + + MAKEHEADER(outp, PPP_CHAP); /* paste in a header */ + + PUTCHAR(code, outp); + PUTCHAR(cstate->chal_id, outp); + PUTSHORT(outlen, outp); + BCOPY(msg, outp, msglen); + pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); + + CHAPDEBUG(LOG_INFO, ("ChapSendStatus: Sent code %d, id %d.\n", code, + cstate->chal_id)); +} + +/* + * ChapGenChallenge is used to generate a pseudo-random challenge string of + * a pseudo-random length between min_len and max_len. The challenge + * string and its length are stored in *cstate, and various other fields of + * *cstate are initialized. + */ + +static void +ChapGenChallenge(chap_state *cstate) +{ + int chal_len; + u_char *ptr = cstate->challenge; + int i; + + /* pick a random challenge length between MIN_CHALLENGE_LENGTH and + MAX_CHALLENGE_LENGTH */ + chal_len = (unsigned) + ((((magic() >> 16) * + (MAX_CHALLENGE_LENGTH - MIN_CHALLENGE_LENGTH)) >> 16) + + MIN_CHALLENGE_LENGTH); + LWIP_ASSERT("chal_len <= 0xff", chal_len <= 0xffff); + cstate->chal_len = (u_char)chal_len; + cstate->chal_id = ++cstate->id; + cstate->chal_transmits = 0; + + /* generate a random string */ + for (i = 0; i < chal_len; i++ ) { + *ptr++ = (char) (magic() & 0xff); + } +} + +/* + * ChapSendResponse - send a response packet with values as specified + * in *cstate. + */ +/* ARGSUSED */ +static void +ChapSendResponse(chap_state *cstate) +{ + u_char *outp; + int outlen, md_len, name_len; + + md_len = cstate->resp_length; + name_len = (int)strlen(cstate->resp_name); + outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len; + outp = outpacket_buf[cstate->unit]; + + MAKEHEADER(outp, PPP_CHAP); + + PUTCHAR(CHAP_RESPONSE, outp); /* we are a response */ + PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */ + PUTSHORT(outlen, outp); /* packet length */ + + PUTCHAR(md_len, outp); /* length of MD */ + BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */ + INCPTR(md_len, outp); + + BCOPY(cstate->resp_name, outp, name_len); /* append our name */ + + /* send the packet */ + pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); + + cstate->clientstate = CHAPCS_RESPONSE; + TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime); + ++cstate->resp_transmits; +} + +#if PPP_ADDITIONAL_CALLBACKS +static char *ChapCodenames[] = { + "Challenge", "Response", "Success", "Failure" +}; +/* + * ChapPrintPkt - print the contents of a CHAP packet. + */ +static int +ChapPrintPkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) +{ + int code, id, len; + int clen, nlen; + u_char x; + + if (plen < CHAP_HEADERLEN) { + return 0; + } + GETCHAR(code, p); + GETCHAR(id, p); + GETSHORT(len, p); + if (len < CHAP_HEADERLEN || len > plen) { + return 0; + } + + if (code >= 1 && code <= sizeof(ChapCodenames) / sizeof(char *)) { + printer(arg, " %s", ChapCodenames[code-1]); + } else { + printer(arg, " code=0x%x", code); + } + printer(arg, " id=0x%x", id); + len -= CHAP_HEADERLEN; + switch (code) { + case CHAP_CHALLENGE: + case CHAP_RESPONSE: + if (len < 1) { + break; + } + clen = p[0]; + if (len < clen + 1) { + break; + } + ++p; + nlen = len - clen - 1; + printer(arg, " <"); + for (; clen > 0; --clen) { + GETCHAR(x, p); + printer(arg, "%.2x", x); + } + printer(arg, ">, name = %.*Z", nlen, p); + break; + case CHAP_FAILURE: + case CHAP_SUCCESS: + printer(arg, " %.*Z", len, p); + break; + default: + for (clen = len; clen > 0; --clen) { + GETCHAR(x, p); + printer(arg, " %.2x", x); + } + } + + return len + CHAP_HEADERLEN; +} +#endif /* PPP_ADDITIONAL_CALLBACKS */ + +#endif /* CHAP_SUPPORT */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chap.h b/user/mpy/lib/lwip/src/netif/ppp/chap.h new file mode 100644 index 0000000..fedcab8 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/chap.h @@ -0,0 +1,150 @@ +/***************************************************************************** +* chap.h - Network Challenge Handshake Authentication Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1998 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-03 Guy Lancaster , Global Election Systems Inc. +* Original built from BSD network code. +******************************************************************************/ +/* + * chap.h - Challenge Handshake Authentication Protocol definitions. + * + * Copyright (c) 1993 The Australian National University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the Australian National University. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Copyright (c) 1991 Gregory M. Christy + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the author. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: chap.h,v 1.6 2010/01/24 13:19:34 goldsimon Exp $ + */ + +#ifndef CHAP_H +#define CHAP_H + +/* Code + ID + length */ +#define CHAP_HEADERLEN 4 + +/* + * CHAP codes. + */ + +#define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */ +#define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */ +#define CHAP_MICROSOFT 0x80 /* use Microsoft-compatible alg. */ +#define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */ + +#define CHAP_CHALLENGE 1 +#define CHAP_RESPONSE 2 +#define CHAP_SUCCESS 3 +#define CHAP_FAILURE 4 + +/* + * Challenge lengths (for challenges we send) and other limits. + */ +#define MIN_CHALLENGE_LENGTH 32 +#define MAX_CHALLENGE_LENGTH 64 +#define MAX_RESPONSE_LENGTH 64 /* sufficient for MD5 or MS-CHAP */ + +/* + * Each interface is described by a chap structure. + */ + +typedef struct chap_state { + int unit; /* Interface unit number */ + int clientstate; /* Client state */ + int serverstate; /* Server state */ + u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */ + u_char chal_len; /* challenge length */ + u_char chal_id; /* ID of last challenge */ + u_char chal_type; /* hash algorithm for challenges */ + u_char id; /* Current id */ + char *chal_name; /* Our name to use with challenge */ + int chal_interval; /* Time until we challenge peer again */ + int timeouttime; /* Timeout time in seconds */ + int max_transmits; /* Maximum # of challenge transmissions */ + int chal_transmits; /* Number of transmissions of challenge */ + int resp_transmits; /* Number of transmissions of response */ + u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */ + u_char resp_length; /* length of response */ + u_char resp_id; /* ID for response messages */ + u_char resp_type; /* hash algorithm for responses */ + char *resp_name; /* Our name to send with response */ +} chap_state; + + +/* + * Client (peer) states. + */ +#define CHAPCS_INITIAL 0 /* Lower layer down, not opened */ +#define CHAPCS_CLOSED 1 /* Lower layer up, not opened */ +#define CHAPCS_PENDING 2 /* Auth us to peer when lower up */ +#define CHAPCS_LISTEN 3 /* Listening for a challenge */ +#define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */ +#define CHAPCS_OPEN 5 /* We've received Success */ + +/* + * Server (authenticator) states. + */ +#define CHAPSS_INITIAL 0 /* Lower layer down, not opened */ +#define CHAPSS_CLOSED 1 /* Lower layer up, not opened */ +#define CHAPSS_PENDING 2 /* Auth peer when lower up */ +#define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */ +#define CHAPSS_OPEN 4 /* We've sent a Success msg */ +#define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */ +#define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */ + +extern chap_state chap[]; + +void ChapAuthWithPeer (int, char *, u_char); +void ChapAuthPeer (int, char *, u_char); + +extern struct protent chap_protent; + +#endif /* CHAP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chpms.c b/user/mpy/lib/lwip/src/netif/ppp/chpms.c new file mode 100644 index 0000000..81a887b --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/chpms.c @@ -0,0 +1,396 @@ +/*** WARNING - THIS CODE HAS NOT BEEN FINISHED! ***/ +/*** The original PPPD code is written in a way to require either the UNIX DES + encryption functions encrypt(3) and setkey(3) or the DES library libdes. + Since both is not included in lwIP, MSCHAP currently does not work! */ +/***************************************************************************** +* chpms.c - Network MicroSoft Challenge Handshake Authentication Protocol program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* Copyright (c) 1997 by Global Election Systems Inc. All rights reserved. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-08 Guy Lancaster , Global Election Systems Inc. +* Original based on BSD chap_ms.c. +*****************************************************************************/ +/* + * chap_ms.c - Microsoft MS-CHAP compatible implementation. + * + * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. + * http://www.strataware.com/ + * + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Eric Rosenquist. The name of the author may not be used to + * endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* + * Modifications by Lauri Pesonen / lpesonen@clinet.fi, april 1997 + * + * Implemented LANManager type password response to MS-CHAP challenges. + * Now pppd provides both NT style and LANMan style blocks, and the + * prefered is set by option "ms-lanman". Default is to use NT. + * The hash text (StdText) was taken from Win95 RASAPI32.DLL. + * + * You should also use DOMAIN\\USERNAME as described in README.MSCHAP80 + */ + +#define USE_CRYPT + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#if MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "md4.h" +#ifndef USE_CRYPT +#include "des.h" +#endif +#include "chap.h" +#include "chpms.h" + +#include + + +/*************************/ +/*** LOCAL DEFINITIONS ***/ +/*************************/ + + +/************************/ +/*** LOCAL DATA TYPES ***/ +/************************/ +typedef struct { + u_char LANManResp[24]; + u_char NTResp[24]; + u_char UseNT; /* If 1, ignore the LANMan response field */ +} MS_ChapResponse; +/* We use MS_CHAP_RESPONSE_LEN, rather than sizeof(MS_ChapResponse), + in case this struct gets padded. */ + + + +/***********************************/ +/*** LOCAL FUNCTION DECLARATIONS ***/ +/***********************************/ + +/* XXX Don't know what to do with these. */ +extern void setkey(const char *); +extern void encrypt(char *, int); + +static void DesEncrypt (u_char *, u_char *, u_char *); +static void MakeKey (u_char *, u_char *); + +#ifdef USE_CRYPT +static void Expand (u_char *, u_char *); +static void Collapse (u_char *, u_char *); +#endif + +static void ChallengeResponse( + u_char *challenge, /* IN 8 octets */ + u_char *pwHash, /* IN 16 octets */ + u_char *response /* OUT 24 octets */ +); +static void ChapMS_NT( + char *rchallenge, + int rchallenge_len, + char *secret, + int secret_len, + MS_ChapResponse *response +); +static u_char Get7Bits( + u_char *input, + int startBit +); + +static void +ChallengeResponse( u_char *challenge, /* IN 8 octets */ + u_char *pwHash, /* IN 16 octets */ + u_char *response /* OUT 24 octets */) +{ + u_char ZPasswordHash[21]; + + BZERO(ZPasswordHash, sizeof(ZPasswordHash)); + BCOPY(pwHash, ZPasswordHash, 16); + +#if 0 + log_packet(ZPasswordHash, sizeof(ZPasswordHash), "ChallengeResponse - ZPasswordHash", LOG_DEBUG); +#endif + + DesEncrypt(challenge, ZPasswordHash + 0, response + 0); + DesEncrypt(challenge, ZPasswordHash + 7, response + 8); + DesEncrypt(challenge, ZPasswordHash + 14, response + 16); + +#if 0 + log_packet(response, 24, "ChallengeResponse - response", LOG_DEBUG); +#endif +} + + +#ifdef USE_CRYPT +static void +DesEncrypt( u_char *clear, /* IN 8 octets */ + u_char *key, /* IN 7 octets */ + u_char *cipher /* OUT 8 octets */) +{ + u_char des_key[8]; + u_char crypt_key[66]; + u_char des_input[66]; + + MakeKey(key, des_key); + + Expand(des_key, crypt_key); + setkey((char*)crypt_key); + +#if 0 + CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X\n", + clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); +#endif + + Expand(clear, des_input); + encrypt((char*)des_input, 0); + Collapse(des_input, cipher); + +#if 0 + CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X\n", + cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); +#endif +} + +#else /* USE_CRYPT */ + +static void +DesEncrypt( u_char *clear, /* IN 8 octets */ + u_char *key, /* IN 7 octets */ + u_char *cipher /* OUT 8 octets */) +{ + des_cblock des_key; + des_key_schedule key_schedule; + + MakeKey(key, des_key); + + des_set_key(&des_key, key_schedule); + +#if 0 + CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X\n", + clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); +#endif + + des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, key_schedule, 1); + +#if 0 + CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X\n", + cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); +#endif +} + +#endif /* USE_CRYPT */ + + +static u_char +Get7Bits( u_char *input, int startBit) +{ + register unsigned int word; + + word = (unsigned)input[startBit / 8] << 8; + word |= (unsigned)input[startBit / 8 + 1]; + + word >>= 15 - (startBit % 8 + 7); + + return word & 0xFE; +} + +#ifdef USE_CRYPT + +/* in == 8-byte string (expanded version of the 56-bit key) + * out == 64-byte string where each byte is either 1 or 0 + * Note that the low-order "bit" is always ignored by by setkey() + */ +static void +Expand(u_char *in, u_char *out) +{ + int j, c; + int i; + + for(i = 0; i < 64; in++){ + c = *in; + for(j = 7; j >= 0; j--) { + *out++ = (c >> j) & 01; + } + i += 8; + } +} + +/* The inverse of Expand + */ +static void +Collapse(u_char *in, u_char *out) +{ + int j; + int i; + unsigned int c; + + for (i = 0; i < 64; i += 8, out++) { + c = 0; + for (j = 7; j >= 0; j--, in++) { + c |= *in << j; + } + *out = c & 0xff; + } +} +#endif + +static void +MakeKey( u_char *key, /* IN 56 bit DES key missing parity bits */ + u_char *des_key /* OUT 64 bit DES key with parity bits added */) +{ + des_key[0] = Get7Bits(key, 0); + des_key[1] = Get7Bits(key, 7); + des_key[2] = Get7Bits(key, 14); + des_key[3] = Get7Bits(key, 21); + des_key[4] = Get7Bits(key, 28); + des_key[5] = Get7Bits(key, 35); + des_key[6] = Get7Bits(key, 42); + des_key[7] = Get7Bits(key, 49); + +#ifndef USE_CRYPT + des_set_odd_parity((des_cblock *)des_key); +#endif + +#if 0 + CHAPDEBUG(LOG_INFO, ("MakeKey: 56-bit input : %02X%02X%02X%02X%02X%02X%02X\n", + key[0], key[1], key[2], key[3], key[4], key[5], key[6])); + CHAPDEBUG(LOG_INFO, ("MakeKey: 64-bit output: %02X%02X%02X%02X%02X%02X%02X%02X\n", + des_key[0], des_key[1], des_key[2], des_key[3], des_key[4], des_key[5], des_key[6], des_key[7])); +#endif +} + +static void +ChapMS_NT( char *rchallenge, + int rchallenge_len, + char *secret, + int secret_len, + MS_ChapResponse *response) +{ + int i; + MDstruct md4Context; + u_char unicodePassword[MAX_NT_PASSWORD * 2]; + static int low_byte_first = -1; + + LWIP_UNUSED_ARG(rchallenge_len); + + /* Initialize the Unicode version of the secret (== password). */ + /* This implicitly supports 8-bit ISO8859/1 characters. */ + BZERO(unicodePassword, sizeof(unicodePassword)); + for (i = 0; i < secret_len; i++) { + unicodePassword[i * 2] = (u_char)secret[i]; + } + MDbegin(&md4Context); + MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */ + + if (low_byte_first == -1) { + low_byte_first = (PP_HTONS((unsigned short int)1) != 1); + } + if (low_byte_first == 0) { + /* @todo: arg type - u_long* or u_int* ? */ + MDreverse((unsigned int*)&md4Context); /* sfb 961105 */ + } + + MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */ + + ChallengeResponse((u_char*)rchallenge, (u_char*)md4Context.buffer, response->NTResp); +} + +#ifdef MSLANMAN +static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ + +static void +ChapMS_LANMan( char *rchallenge, + int rchallenge_len, + char *secret, + int secret_len, + MS_ChapResponse *response) +{ + int i; + u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ + u_char PasswordHash[16]; + + /* LANMan password is case insensitive */ + BZERO(UcasePassword, sizeof(UcasePassword)); + for (i = 0; i < secret_len; i++) { + UcasePassword[i] = (u_char)toupper(secret[i]); + } + DesEncrypt( StdText, UcasePassword + 0, PasswordHash + 0 ); + DesEncrypt( StdText, UcasePassword + 7, PasswordHash + 8 ); + ChallengeResponse(rchallenge, PasswordHash, response->LANManResp); +} +#endif + +void +ChapMS( chap_state *cstate, char *rchallenge, int rchallenge_len, char *secret, int secret_len) +{ + MS_ChapResponse response; +#ifdef MSLANMAN + extern int ms_lanman; +#endif + +#if 0 + CHAPDEBUG(LOG_INFO, ("ChapMS: secret is '%.*s'\n", secret_len, secret)); +#endif + BZERO(&response, sizeof(response)); + + /* Calculate both always */ + ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, &response); + +#ifdef MSLANMAN + ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, &response); + + /* prefered method is set by option */ + response.UseNT = !ms_lanman; +#else + response.UseNT = 1; +#endif + + BCOPY(&response, cstate->response, MS_CHAP_RESPONSE_LEN); + cstate->resp_length = MS_CHAP_RESPONSE_LEN; +} + +#endif /* MSCHAP_SUPPORT */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chpms.h b/user/mpy/lib/lwip/src/netif/ppp/chpms.h new file mode 100644 index 0000000..df070fb --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/chpms.h @@ -0,0 +1,64 @@ +/***************************************************************************** +* chpms.h - Network Microsoft Challenge Handshake Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1998 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 98-01-30 Guy Lancaster , Global Election Systems Inc. +* Original built from BSD network code. +******************************************************************************/ +/* + * chap.h - Challenge Handshake Authentication Protocol definitions. + * + * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. + * http://www.strataware.com/ + * + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Eric Rosenquist. The name of the author may not be used to + * endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $ + */ + +#ifndef CHPMS_H +#define CHPMS_H + +#define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ + +void ChapMS (chap_state *, char *, int, char *, int); + +#endif /* CHPMS_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/fsm.c b/user/mpy/lib/lwip/src/netif/ppp/fsm.c new file mode 100644 index 0000000..e8a254e --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/fsm.c @@ -0,0 +1,890 @@ +/***************************************************************************** +* fsm.c - Network Control Protocol Finite State Machine program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-01 Guy Lancaster , Global Election Systems Inc. +* Original based on BSD fsm.c. +*****************************************************************************/ +/* + * fsm.c - {Link, IP} Control Protocol Finite State Machine. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* + * TODO: + * Randomize fsm id on link/init. + * Deal with variable outgoing MTU. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "fsm.h" + +#include + +#if PPP_DEBUG +static const char *ppperr_strerr[] = { + "LS_INITIAL", /* LS_INITIAL 0 */ + "LS_STARTING", /* LS_STARTING 1 */ + "LS_CLOSED", /* LS_CLOSED 2 */ + "LS_STOPPED", /* LS_STOPPED 3 */ + "LS_CLOSING", /* LS_CLOSING 4 */ + "LS_STOPPING", /* LS_STOPPING 5 */ + "LS_REQSENT", /* LS_REQSENT 6 */ + "LS_ACKRCVD", /* LS_ACKRCVD 7 */ + "LS_ACKSENT", /* LS_ACKSENT 8 */ + "LS_OPENED" /* LS_OPENED 9 */ +}; +#endif /* PPP_DEBUG */ + +static void fsm_timeout (void *); +static void fsm_rconfreq (fsm *, u_char, u_char *, int); +static void fsm_rconfack (fsm *, int, u_char *, int); +static void fsm_rconfnakrej (fsm *, int, int, u_char *, int); +static void fsm_rtermreq (fsm *, int, u_char *, int); +static void fsm_rtermack (fsm *); +static void fsm_rcoderej (fsm *, u_char *, int); +static void fsm_sconfreq (fsm *, int); + +#define PROTO_NAME(f) ((f)->callbacks->proto_name) + +int peer_mru[NUM_PPP]; + + +/* + * fsm_init - Initialize fsm. + * + * Initialize fsm state. + */ +void +fsm_init(fsm *f) +{ + f->state = LS_INITIAL; + f->flags = 0; + f->id = 0; /* XXX Start with random id? */ + f->timeouttime = FSM_DEFTIMEOUT; + f->maxconfreqtransmits = FSM_DEFMAXCONFREQS; + f->maxtermtransmits = FSM_DEFMAXTERMREQS; + f->maxnakloops = FSM_DEFMAXNAKLOOPS; + f->term_reason_len = 0; +} + + +/* + * fsm_lowerup - The lower layer is up. + */ +void +fsm_lowerup(fsm *f) +{ + int oldState = f->state; + + LWIP_UNUSED_ARG(oldState); + + switch( f->state ) { + case LS_INITIAL: + f->state = LS_CLOSED; + break; + + case LS_STARTING: + if( f->flags & OPT_SILENT ) { + f->state = LS_STOPPED; + } else { + /* Send an initial configure-request */ + fsm_sconfreq(f, 0); + f->state = LS_REQSENT; + } + break; + + default: + FSMDEBUG(LOG_INFO, ("%s: Up event in state %d (%s)!\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + } + + FSMDEBUG(LOG_INFO, ("%s: lowerup state %d (%s) -> %d (%s)\n", + PROTO_NAME(f), oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); +} + + +/* + * fsm_lowerdown - The lower layer is down. + * + * Cancel all timeouts and inform upper layers. + */ +void +fsm_lowerdown(fsm *f) +{ + int oldState = f->state; + + LWIP_UNUSED_ARG(oldState); + + switch( f->state ) { + case LS_CLOSED: + f->state = LS_INITIAL; + break; + + case LS_STOPPED: + f->state = LS_STARTING; + if( f->callbacks->starting ) { + (*f->callbacks->starting)(f); + } + break; + + case LS_CLOSING: + f->state = LS_INITIAL; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + break; + + case LS_STOPPING: + case LS_REQSENT: + case LS_ACKRCVD: + case LS_ACKSENT: + f->state = LS_STARTING; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + break; + + case LS_OPENED: + if( f->callbacks->down ) { + (*f->callbacks->down)(f); + } + f->state = LS_STARTING; + break; + + default: + FSMDEBUG(LOG_INFO, ("%s: Down event in state %d (%s)!\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + } + + FSMDEBUG(LOG_INFO, ("%s: lowerdown state %d (%s) -> %d (%s)\n", + PROTO_NAME(f), oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); +} + + +/* + * fsm_open - Link is allowed to come up. + */ +void +fsm_open(fsm *f) +{ + int oldState = f->state; + + LWIP_UNUSED_ARG(oldState); + + switch( f->state ) { + case LS_INITIAL: + f->state = LS_STARTING; + if( f->callbacks->starting ) { + (*f->callbacks->starting)(f); + } + break; + + case LS_CLOSED: + if( f->flags & OPT_SILENT ) { + f->state = LS_STOPPED; + } else { + /* Send an initial configure-request */ + fsm_sconfreq(f, 0); + f->state = LS_REQSENT; + } + break; + + case LS_CLOSING: + f->state = LS_STOPPING; + /* fall through */ + case LS_STOPPED: + case LS_OPENED: + if( f->flags & OPT_RESTART ) { + fsm_lowerdown(f); + fsm_lowerup(f); + } + break; + } + + FSMDEBUG(LOG_INFO, ("%s: open state %d (%s) -> %d (%s)\n", + PROTO_NAME(f), oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); +} + +#if 0 /* backport pppd 2.4.4b1; */ +/* + * terminate_layer - Start process of shutting down the FSM + * + * Cancel any timeout running, notify upper layers we're done, and + * send a terminate-request message as configured. + */ +static void +terminate_layer(fsm *f, int nextstate) +{ + /* @todo */ +} +#endif + +/* + * fsm_close - Start closing connection. + * + * Cancel timeouts and either initiate close or possibly go directly to + * the LS_CLOSED state. + */ +void +fsm_close(fsm *f, char *reason) +{ + int oldState = f->state; + + LWIP_UNUSED_ARG(oldState); + + f->term_reason = reason; + f->term_reason_len = (reason == NULL ? 0 : (int)strlen(reason)); + switch( f->state ) { + case LS_STARTING: + f->state = LS_INITIAL; + break; + case LS_STOPPED: + f->state = LS_CLOSED; + break; + case LS_STOPPING: + f->state = LS_CLOSING; + break; + + case LS_REQSENT: + case LS_ACKRCVD: + case LS_ACKSENT: + case LS_OPENED: + if( f->state != LS_OPENED ) { + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + } else if( f->callbacks->down ) { + (*f->callbacks->down)(f); /* Inform upper layers we're down */ + } + /* Init restart counter, send Terminate-Request */ + f->retransmits = f->maxtermtransmits; + fsm_sdata(f, TERMREQ, f->reqid = ++f->id, + (u_char *) f->term_reason, f->term_reason_len); + TIMEOUT(fsm_timeout, f, f->timeouttime); + --f->retransmits; + + f->state = LS_CLOSING; + break; + } + + FSMDEBUG(LOG_INFO, ("%s: close reason=%s state %d (%s) -> %d (%s)\n", + PROTO_NAME(f), reason, oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); +} + + +/* + * fsm_timeout - Timeout expired. + */ +static void +fsm_timeout(void *arg) +{ + fsm *f = (fsm *) arg; + + switch (f->state) { + case LS_CLOSING: + case LS_STOPPING: + if( f->retransmits <= 0 ) { + FSMDEBUG(LOG_WARNING, ("%s: timeout sending Terminate-Request state=%d (%s)\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + /* + * We've waited for an ack long enough. Peer probably heard us. + */ + f->state = (f->state == LS_CLOSING)? LS_CLOSED: LS_STOPPED; + if( f->callbacks->finished ) { + (*f->callbacks->finished)(f); + } + } else { + FSMDEBUG(LOG_WARNING, ("%s: timeout resending Terminate-Requests state=%d (%s)\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + /* Send Terminate-Request */ + fsm_sdata(f, TERMREQ, f->reqid = ++f->id, + (u_char *) f->term_reason, f->term_reason_len); + TIMEOUT(fsm_timeout, f, f->timeouttime); + --f->retransmits; + } + break; + + case LS_REQSENT: + case LS_ACKRCVD: + case LS_ACKSENT: + if (f->retransmits <= 0) { + FSMDEBUG(LOG_WARNING, ("%s: timeout sending Config-Requests state=%d (%s)\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + f->state = LS_STOPPED; + if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished ) { + (*f->callbacks->finished)(f); + } + } else { + FSMDEBUG(LOG_WARNING, ("%s: timeout resending Config-Request state=%d (%s)\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + /* Retransmit the configure-request */ + if (f->callbacks->retransmit) { + (*f->callbacks->retransmit)(f); + } + fsm_sconfreq(f, 1); /* Re-send Configure-Request */ + if( f->state == LS_ACKRCVD ) { + f->state = LS_REQSENT; + } + } + break; + + default: + FSMDEBUG(LOG_INFO, ("%s: UNHANDLED timeout event in state %d (%s)!\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + } +} + + +/* + * fsm_input - Input packet. + */ +void +fsm_input(fsm *f, u_char *inpacket, int l) +{ + u_char *inp = inpacket; + u_char code, id; + int len; + + /* + * Parse header (code, id and length). + * If packet too short, drop it. + */ + if (l < HEADERLEN) { + FSMDEBUG(LOG_WARNING, ("fsm_input(%x): Rcvd short header.\n", + f->protocol)); + return; + } + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < HEADERLEN) { + FSMDEBUG(LOG_INFO, ("fsm_input(%x): Rcvd illegal length.\n", + f->protocol)); + return; + } + if (len > l) { + FSMDEBUG(LOG_INFO, ("fsm_input(%x): Rcvd short packet.\n", + f->protocol)); + return; + } + len -= HEADERLEN; /* subtract header length */ + + if( f->state == LS_INITIAL || f->state == LS_STARTING ) { + FSMDEBUG(LOG_INFO, ("fsm_input(%x): Rcvd packet in state %d (%s).\n", + f->protocol, f->state, ppperr_strerr[f->state])); + return; + } + FSMDEBUG(LOG_INFO, ("fsm_input(%s):%d,%d,%d\n", PROTO_NAME(f), code, id, l)); + /* + * Action depends on code. + */ + switch (code) { + case CONFREQ: + fsm_rconfreq(f, id, inp, len); + break; + + case CONFACK: + fsm_rconfack(f, id, inp, len); + break; + + case CONFNAK: + case CONFREJ: + fsm_rconfnakrej(f, code, id, inp, len); + break; + + case TERMREQ: + fsm_rtermreq(f, id, inp, len); + break; + + case TERMACK: + fsm_rtermack(f); + break; + + case CODEREJ: + fsm_rcoderej(f, inp, len); + break; + + default: + FSMDEBUG(LOG_INFO, ("fsm_input(%s): default: \n", PROTO_NAME(f))); + if( !f->callbacks->extcode || + !(*f->callbacks->extcode)(f, code, id, inp, len) ) { + fsm_sdata(f, CODEREJ, ++f->id, inpacket, len + HEADERLEN); + } + break; + } +} + + +/* + * fsm_rconfreq - Receive Configure-Request. + */ +static void +fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) +{ + int code, reject_if_disagree; + + FSMDEBUG(LOG_INFO, ("fsm_rconfreq(%s): Rcvd id %d state=%d (%s)\n", + PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); + switch( f->state ) { + case LS_CLOSED: + /* Go away, we're closed */ + fsm_sdata(f, TERMACK, id, NULL, 0); + return; + case LS_CLOSING: + case LS_STOPPING: + return; + + case LS_OPENED: + /* Go down and restart negotiation */ + if( f->callbacks->down ) { + (*f->callbacks->down)(f); /* Inform upper layers */ + } + fsm_sconfreq(f, 0); /* Send initial Configure-Request */ + break; + + case LS_STOPPED: + /* Negotiation started by our peer */ + fsm_sconfreq(f, 0); /* Send initial Configure-Request */ + f->state = LS_REQSENT; + break; + } + + /* + * Pass the requested configuration options + * to protocol-specific code for checking. + */ + if (f->callbacks->reqci) { /* Check CI */ + reject_if_disagree = (f->nakloops >= f->maxnakloops); + code = (*f->callbacks->reqci)(f, inp, &len, reject_if_disagree); + } else if (len) { + code = CONFREJ; /* Reject all CI */ + } else { + code = CONFACK; + } + + /* send the Ack, Nak or Rej to the peer */ + fsm_sdata(f, (u_char)code, id, inp, len); + + if (code == CONFACK) { + if (f->state == LS_ACKRCVD) { + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + f->state = LS_OPENED; + if (f->callbacks->up) { + (*f->callbacks->up)(f); /* Inform upper layers */ + } + } else { + f->state = LS_ACKSENT; + } + f->nakloops = 0; + } else { + /* we sent CONFACK or CONFREJ */ + if (f->state != LS_ACKRCVD) { + f->state = LS_REQSENT; + } + if( code == CONFNAK ) { + ++f->nakloops; + } + } +} + + +/* + * fsm_rconfack - Receive Configure-Ack. + */ +static void +fsm_rconfack(fsm *f, int id, u_char *inp, int len) +{ + FSMDEBUG(LOG_INFO, ("fsm_rconfack(%s): Rcvd id %d state=%d (%s)\n", + PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); + + if (id != f->reqid || f->seen_ack) { /* Expected id? */ + return; /* Nope, toss... */ + } + if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len): (len == 0)) ) { + /* Ack is bad - ignore it */ + FSMDEBUG(LOG_INFO, ("%s: received bad Ack (length %d)\n", + PROTO_NAME(f), len)); + return; + } + f->seen_ack = 1; + + switch (f->state) { + case LS_CLOSED: + case LS_STOPPED: + fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); + break; + + case LS_REQSENT: + f->state = LS_ACKRCVD; + f->retransmits = f->maxconfreqtransmits; + break; + + case LS_ACKRCVD: + /* Huh? an extra valid Ack? oh well... */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + fsm_sconfreq(f, 0); + f->state = LS_REQSENT; + break; + + case LS_ACKSENT: + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + f->state = LS_OPENED; + f->retransmits = f->maxconfreqtransmits; + if (f->callbacks->up) { + (*f->callbacks->up)(f); /* Inform upper layers */ + } + break; + + case LS_OPENED: + /* Go down and restart negotiation */ + if (f->callbacks->down) { + (*f->callbacks->down)(f); /* Inform upper layers */ + } + fsm_sconfreq(f, 0); /* Send initial Configure-Request */ + f->state = LS_REQSENT; + break; + } +} + + +/* + * fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. + */ +static void +fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) +{ + int (*proc) (fsm *, u_char *, int); + int ret; + + FSMDEBUG(LOG_INFO, ("fsm_rconfnakrej(%s): Rcvd id %d state=%d (%s)\n", + PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); + + if (id != f->reqid || f->seen_ack) { /* Expected id? */ + return; /* Nope, toss... */ + } + proc = (code == CONFNAK)? f->callbacks->nakci: f->callbacks->rejci; + if (!proc || !((ret = proc(f, inp, len)))) { + /* Nak/reject is bad - ignore it */ + FSMDEBUG(LOG_INFO, ("%s: received bad %s (length %d)\n", + PROTO_NAME(f), (code==CONFNAK? "Nak": "reject"), len)); + return; + } + f->seen_ack = 1; + + switch (f->state) { + case LS_CLOSED: + case LS_STOPPED: + fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); + break; + + case LS_REQSENT: + case LS_ACKSENT: + /* They didn't agree to what we wanted - try another request */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + if (ret < 0) { + f->state = LS_STOPPED; /* kludge for stopping CCP */ + } else { + fsm_sconfreq(f, 0); /* Send Configure-Request */ + } + break; + + case LS_ACKRCVD: + /* Got a Nak/reject when we had already had an Ack?? oh well... */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + fsm_sconfreq(f, 0); + f->state = LS_REQSENT; + break; + + case LS_OPENED: + /* Go down and restart negotiation */ + if (f->callbacks->down) { + (*f->callbacks->down)(f); /* Inform upper layers */ + } + fsm_sconfreq(f, 0); /* Send initial Configure-Request */ + f->state = LS_REQSENT; + break; + } +} + + +/* + * fsm_rtermreq - Receive Terminate-Req. + */ +static void +fsm_rtermreq(fsm *f, int id, u_char *p, int len) +{ + LWIP_UNUSED_ARG(p); + + FSMDEBUG(LOG_INFO, ("fsm_rtermreq(%s): Rcvd id %d state=%d (%s)\n", + PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); + + switch (f->state) { + case LS_ACKRCVD: + case LS_ACKSENT: + f->state = LS_REQSENT; /* Start over but keep trying */ + break; + + case LS_OPENED: + if (len > 0) { + FSMDEBUG(LOG_INFO, ("%s terminated by peer (%p)\n", PROTO_NAME(f), p)); + } else { + FSMDEBUG(LOG_INFO, ("%s terminated by peer\n", PROTO_NAME(f))); + } + if (f->callbacks->down) { + (*f->callbacks->down)(f); /* Inform upper layers */ + } + f->retransmits = 0; + f->state = LS_STOPPING; + TIMEOUT(fsm_timeout, f, f->timeouttime); + break; + } + + fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); +} + + +/* + * fsm_rtermack - Receive Terminate-Ack. + */ +static void +fsm_rtermack(fsm *f) +{ + FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): state=%d (%s)\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + + switch (f->state) { + case LS_CLOSING: + UNTIMEOUT(fsm_timeout, f); + f->state = LS_CLOSED; + if( f->callbacks->finished ) { + (*f->callbacks->finished)(f); + } + break; + + case LS_STOPPING: + UNTIMEOUT(fsm_timeout, f); + f->state = LS_STOPPED; + if( f->callbacks->finished ) { + (*f->callbacks->finished)(f); + } + break; + + case LS_ACKRCVD: + f->state = LS_REQSENT; + break; + + case LS_OPENED: + if (f->callbacks->down) { + (*f->callbacks->down)(f); /* Inform upper layers */ + } + fsm_sconfreq(f, 0); + break; + default: + FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): UNHANDLED state=%d (%s)!!!\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + } +} + + +/* + * fsm_rcoderej - Receive an Code-Reject. + */ +static void +fsm_rcoderej(fsm *f, u_char *inp, int len) +{ + u_char code, id; + + FSMDEBUG(LOG_INFO, ("fsm_rcoderej(%s): state=%d (%s)\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + + if (len < HEADERLEN) { + FSMDEBUG(LOG_INFO, ("fsm_rcoderej: Rcvd short Code-Reject packet!\n")); + return; + } + GETCHAR(code, inp); + GETCHAR(id, inp); + FSMDEBUG(LOG_WARNING, ("%s: Rcvd Code-Reject for code %d, id %d\n", + PROTO_NAME(f), code, id)); + + if( f->state == LS_ACKRCVD ) { + f->state = LS_REQSENT; + } +} + + +/* + * fsm_protreject - Peer doesn't speak this protocol. + * + * Treat this as a catastrophic error (RXJ-). + */ +void +fsm_protreject(fsm *f) +{ + switch( f->state ) { + case LS_CLOSING: + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + /* fall through */ + case LS_CLOSED: + f->state = LS_CLOSED; + if( f->callbacks->finished ) { + (*f->callbacks->finished)(f); + } + break; + + case LS_STOPPING: + case LS_REQSENT: + case LS_ACKRCVD: + case LS_ACKSENT: + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + /* fall through */ + case LS_STOPPED: + f->state = LS_STOPPED; + if( f->callbacks->finished ) { + (*f->callbacks->finished)(f); + } + break; + + case LS_OPENED: + if( f->callbacks->down ) { + (*f->callbacks->down)(f); + } + /* Init restart counter, send Terminate-Request */ + f->retransmits = f->maxtermtransmits; + fsm_sdata(f, TERMREQ, f->reqid = ++f->id, + (u_char *) f->term_reason, f->term_reason_len); + TIMEOUT(fsm_timeout, f, f->timeouttime); + --f->retransmits; + + f->state = LS_STOPPING; + break; + + default: + FSMDEBUG(LOG_INFO, ("%s: Protocol-reject event in state %d (%s)!\n", + PROTO_NAME(f), f->state, ppperr_strerr[f->state])); + } +} + + +/* + * fsm_sconfreq - Send a Configure-Request. + */ +static void +fsm_sconfreq(fsm *f, int retransmit) +{ + u_char *outp; + int cilen; + + if( f->state != LS_REQSENT && f->state != LS_ACKRCVD && f->state != LS_ACKSENT ) { + /* Not currently negotiating - reset options */ + if( f->callbacks->resetci ) { + (*f->callbacks->resetci)(f); + } + f->nakloops = 0; + } + + if( !retransmit ) { + /* New request - reset retransmission counter, use new ID */ + f->retransmits = f->maxconfreqtransmits; + f->reqid = ++f->id; + } + + f->seen_ack = 0; + + /* + * Make up the request packet + */ + outp = outpacket_buf[f->unit] + PPP_HDRLEN + HEADERLEN; + if( f->callbacks->cilen && f->callbacks->addci ) { + cilen = (*f->callbacks->cilen)(f); + if( cilen > peer_mru[f->unit] - (int)HEADERLEN ) { + cilen = peer_mru[f->unit] - HEADERLEN; + } + if (f->callbacks->addci) { + (*f->callbacks->addci)(f, outp, &cilen); + } + } else { + cilen = 0; + } + + /* send the request to our peer */ + fsm_sdata(f, CONFREQ, f->reqid, outp, cilen); + + /* start the retransmit timer */ + --f->retransmits; + TIMEOUT(fsm_timeout, f, f->timeouttime); + + FSMDEBUG(LOG_INFO, ("%s: sending Configure-Request, id %d\n", + PROTO_NAME(f), f->reqid)); +} + + +/* + * fsm_sdata - Send some data. + * + * Used for all packets sent to our peer by this module. + */ +void +fsm_sdata( fsm *f, u_char code, u_char id, u_char *data, int datalen) +{ + u_char *outp; + int outlen; + + /* Adjust length to be smaller than MTU */ + outp = outpacket_buf[f->unit]; + if (datalen > peer_mru[f->unit] - (int)HEADERLEN) { + datalen = peer_mru[f->unit] - HEADERLEN; + } + if (datalen && data != outp + PPP_HDRLEN + HEADERLEN) { + BCOPY(data, outp + PPP_HDRLEN + HEADERLEN, datalen); + } + outlen = datalen + HEADERLEN; + MAKEHEADER(outp, f->protocol); + PUTCHAR(code, outp); + PUTCHAR(id, outp); + PUTSHORT(outlen, outp); + pppWrite(f->unit, outpacket_buf[f->unit], outlen + PPP_HDRLEN); + FSMDEBUG(LOG_INFO, ("fsm_sdata(%s): Sent code %d,%d,%d.\n", + PROTO_NAME(f), code, id, outlen)); +} + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/fsm.h b/user/mpy/lib/lwip/src/netif/ppp/fsm.h new file mode 100644 index 0000000..8d41b5f --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/fsm.h @@ -0,0 +1,157 @@ +/***************************************************************************** +* fsm.h - Network Control Protocol Finite State Machine header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-11-05 Guy Lancaster , Global Election Systems Inc. +* Original based on BSD code. +*****************************************************************************/ +/* + * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: fsm.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $ + */ + +#ifndef FSM_H +#define FSM_H + +/* + * LCP Packet header = Code, id, length. + */ +#define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) + + +/* + * CP (LCP, IPCP, etc.) codes. + */ +#define CONFREQ 1 /* Configuration Request */ +#define CONFACK 2 /* Configuration Ack */ +#define CONFNAK 3 /* Configuration Nak */ +#define CONFREJ 4 /* Configuration Reject */ +#define TERMREQ 5 /* Termination Request */ +#define TERMACK 6 /* Termination Ack */ +#define CODEREJ 7 /* Code Reject */ + + +/* + * Each FSM is described by an fsm structure and fsm callbacks. + */ +typedef struct fsm { + int unit; /* Interface unit number */ + u_short protocol; /* Data Link Layer Protocol field value */ + int state; /* State */ + int flags; /* Contains option bits */ + u_char id; /* Current id */ + u_char reqid; /* Current request id */ + u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */ + int timeouttime; /* Timeout time in milliseconds */ + int maxconfreqtransmits; /* Maximum Configure-Request transmissions */ + int retransmits; /* Number of retransmissions left */ + int maxtermtransmits; /* Maximum Terminate-Request transmissions */ + int nakloops; /* Number of nak loops since last ack */ + int maxnakloops; /* Maximum number of nak loops tolerated */ + struct fsm_callbacks* callbacks; /* Callback routines */ + char* term_reason; /* Reason for closing protocol */ + int term_reason_len; /* Length of term_reason */ +} fsm; + + +typedef struct fsm_callbacks { + void (*resetci)(fsm*); /* Reset our Configuration Information */ + int (*cilen)(fsm*); /* Length of our Configuration Information */ + void (*addci)(fsm*, u_char*, int*); /* Add our Configuration Information */ + int (*ackci)(fsm*, u_char*, int); /* ACK our Configuration Information */ + int (*nakci)(fsm*, u_char*, int); /* NAK our Configuration Information */ + int (*rejci)(fsm*, u_char*, int); /* Reject our Configuration Information */ + int (*reqci)(fsm*, u_char*, int*, int); /* Request peer's Configuration Information */ + void (*up)(fsm*); /* Called when fsm reaches LS_OPENED state */ + void (*down)(fsm*); /* Called when fsm leaves LS_OPENED state */ + void (*starting)(fsm*); /* Called when we want the lower layer */ + void (*finished)(fsm*); /* Called when we don't want the lower layer */ + void (*protreject)(int); /* Called when Protocol-Reject received */ + void (*retransmit)(fsm*); /* Retransmission is necessary */ + int (*extcode)(fsm*, int, u_char, u_char*, int); /* Called when unknown code received */ + char *proto_name; /* String name for protocol (for messages) */ +} fsm_callbacks; + + +/* + * Link states. + */ +#define LS_INITIAL 0 /* Down, hasn't been opened */ +#define LS_STARTING 1 /* Down, been opened */ +#define LS_CLOSED 2 /* Up, hasn't been opened */ +#define LS_STOPPED 3 /* Open, waiting for down event */ +#define LS_CLOSING 4 /* Terminating the connection, not open */ +#define LS_STOPPING 5 /* Terminating, but open */ +#define LS_REQSENT 6 /* We've sent a Config Request */ +#define LS_ACKRCVD 7 /* We've received a Config Ack */ +#define LS_ACKSENT 8 /* We've sent a Config Ack */ +#define LS_OPENED 9 /* Connection available */ + +/* + * Flags - indicate options controlling FSM operation + */ +#define OPT_PASSIVE 1 /* Don't die if we don't get a response */ +#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */ +#define OPT_SILENT 4 /* Wait for peer to speak first */ + + +/* + * Prototypes + */ +void fsm_init (fsm*); +void fsm_lowerup (fsm*); +void fsm_lowerdown (fsm*); +void fsm_open (fsm*); +void fsm_close (fsm*, char*); +void fsm_input (fsm*, u_char*, int); +void fsm_protreject (fsm*); +void fsm_sdata (fsm*, u_char, u_char, u_char*, int); + + +/* + * Variables + */ +extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */ + +#endif /* FSM_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ipcp.c b/user/mpy/lib/lwip/src/netif/ppp/ipcp.c new file mode 100644 index 0000000..f0ab2e0 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/ipcp.c @@ -0,0 +1,1411 @@ +/** In contrast to pppd 2.3.1, DNS support has been added, proxy-ARP and + dial-on-demand has been stripped. */ +/***************************************************************************** +* ipcp.c - Network PPP IP Control Protocol program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-08 Guy Lancaster , Global Election Systems Inc. +* Original. +*****************************************************************************/ +/* + * ipcp.c - PPP IP Control Protocol. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "auth.h" +#include "fsm.h" +#include "vj.h" +#include "ipcp.h" + +#include "lwip/inet.h" + +#include + +/* #define OLD_CI_ADDRS 1 */ /* Support deprecated address negotiation. */ + +/* global vars */ +ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */ +ipcp_options ipcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ +ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ +ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ + +/* local vars */ +static int default_route_set[NUM_PPP]; /* Have set up a default route */ +static int cis_received[NUM_PPP]; /* # Conf-Reqs received */ + + +/* + * Callbacks for fsm code. (CI = Configuration Information) + */ +static void ipcp_resetci (fsm *); /* Reset our CI */ +static int ipcp_cilen (fsm *); /* Return length of our CI */ +static void ipcp_addci (fsm *, u_char *, int *); /* Add our CI */ +static int ipcp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */ +static int ipcp_nakci (fsm *, u_char *, int); /* Peer nak'd our CI */ +static int ipcp_rejci (fsm *, u_char *, int); /* Peer rej'd our CI */ +static int ipcp_reqci (fsm *, u_char *, int *, int); /* Rcv CI */ +static void ipcp_up (fsm *); /* We're UP */ +static void ipcp_down (fsm *); /* We're DOWN */ +#if PPP_ADDITIONAL_CALLBACKS +static void ipcp_script (fsm *, char *); /* Run an up/down script */ +#endif +static void ipcp_finished (fsm *); /* Don't need lower layer */ + + +fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */ + + +static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */ + ipcp_resetci, /* Reset our Configuration Information */ + ipcp_cilen, /* Length of our Configuration Information */ + ipcp_addci, /* Add our Configuration Information */ + ipcp_ackci, /* ACK our Configuration Information */ + ipcp_nakci, /* NAK our Configuration Information */ + ipcp_rejci, /* Reject our Configuration Information */ + ipcp_reqci, /* Request peer's Configuration Information */ + ipcp_up, /* Called when fsm reaches LS_OPENED state */ + ipcp_down, /* Called when fsm leaves LS_OPENED state */ + NULL, /* Called when we want the lower layer up */ + ipcp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + NULL, /* Called to handle protocol-specific codes */ + "IPCP" /* String name of protocol */ +}; + +/* + * Protocol entry points from main code. + */ +static void ipcp_init (int); +static void ipcp_open (int); +static void ipcp_close (int, char *); +static void ipcp_lowerup (int); +static void ipcp_lowerdown (int); +static void ipcp_input (int, u_char *, int); +static void ipcp_protrej (int); + + +struct protent ipcp_protent = { + PPP_IPCP, + ipcp_init, + ipcp_input, + ipcp_protrej, + ipcp_lowerup, + ipcp_lowerdown, + ipcp_open, + ipcp_close, +#if PPP_ADDITIONAL_CALLBACKS + ipcp_printpkt, + NULL, +#endif /* PPP_ADDITIONAL_CALLBACKS */ + 1, + "IPCP", +#if PPP_ADDITIONAL_CALLBACKS + ip_check_options, + NULL, + ip_active_pkt +#endif /* PPP_ADDITIONAL_CALLBACKS */ +}; + +static void ipcp_clear_addrs (int); + +/* + * Lengths of configuration options. + */ +#define CILEN_VOID 2 +#define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ +#define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ +#define CILEN_ADDR 6 /* new-style single address option */ +#define CILEN_ADDRS 10 /* old-style dual address option */ + + +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") + + +/* + * ipcp_init - Initialize IPCP. + */ +static void +ipcp_init(int unit) +{ + fsm *f = &ipcp_fsm[unit]; + ipcp_options *wo = &ipcp_wantoptions[unit]; + ipcp_options *ao = &ipcp_allowoptions[unit]; + + f->unit = unit; + f->protocol = PPP_IPCP; + f->callbacks = &ipcp_callbacks; + fsm_init(&ipcp_fsm[unit]); + + memset(wo, 0, sizeof(*wo)); + memset(ao, 0, sizeof(*ao)); + + wo->neg_addr = 1; + wo->ouraddr = 0; +#if VJ_SUPPORT + wo->neg_vj = 1; +#else /* VJ_SUPPORT */ + wo->neg_vj = 0; +#endif /* VJ_SUPPORT */ + wo->vj_protocol = IPCP_VJ_COMP; + wo->maxslotindex = MAX_SLOTS - 1; + wo->cflag = 0; + wo->default_route = 1; + + ao->neg_addr = 1; +#if VJ_SUPPORT + ao->neg_vj = 1; +#else /* VJ_SUPPORT */ + ao->neg_vj = 0; +#endif /* VJ_SUPPORT */ + ao->maxslotindex = MAX_SLOTS - 1; + ao->cflag = 1; + ao->default_route = 1; +} + + +/* + * ipcp_open - IPCP is allowed to come up. + */ +static void +ipcp_open(int unit) +{ + fsm_open(&ipcp_fsm[unit]); +} + + +/* + * ipcp_close - Take IPCP down. + */ +static void +ipcp_close(int unit, char *reason) +{ + fsm_close(&ipcp_fsm[unit], reason); +} + + +/* + * ipcp_lowerup - The lower layer is up. + */ +static void +ipcp_lowerup(int unit) +{ + fsm_lowerup(&ipcp_fsm[unit]); +} + + +/* + * ipcp_lowerdown - The lower layer is down. + */ +static void +ipcp_lowerdown(int unit) +{ + fsm_lowerdown(&ipcp_fsm[unit]); +} + + +/* + * ipcp_input - Input IPCP packet. + */ +static void +ipcp_input(int unit, u_char *p, int len) +{ + fsm_input(&ipcp_fsm[unit], p, len); +} + + +/* + * ipcp_protrej - A Protocol-Reject was received for IPCP. + * + * Pretend the lower layer went down, so we shut up. + */ +static void +ipcp_protrej(int unit) +{ + fsm_lowerdown(&ipcp_fsm[unit]); +} + + +/* + * ipcp_resetci - Reset our CI. + */ +static void +ipcp_resetci(fsm *f) +{ + ipcp_options *wo = &ipcp_wantoptions[f->unit]; + + wo->req_addr = wo->neg_addr && ipcp_allowoptions[f->unit].neg_addr; + if (wo->ouraddr == 0) { + wo->accept_local = 1; + } + if (wo->hisaddr == 0) { + wo->accept_remote = 1; + } + /* Request DNS addresses from the peer */ + wo->req_dns1 = ppp_settings.usepeerdns; + wo->req_dns2 = ppp_settings.usepeerdns; + ipcp_gotoptions[f->unit] = *wo; + cis_received[f->unit] = 0; +} + + +/* + * ipcp_cilen - Return length of our CI. + */ +static int +ipcp_cilen(fsm *f) +{ + ipcp_options *go = &ipcp_gotoptions[f->unit]; + ipcp_options *wo = &ipcp_wantoptions[f->unit]; + ipcp_options *ho = &ipcp_hisoptions[f->unit]; + +#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) +#define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0) +#define LENCIDNS(neg) (neg ? (CILEN_ADDR) : 0) + + /* + * First see if we want to change our options to the old + * forms because we have received old forms from the peer. + */ + if (wo->neg_addr && !go->neg_addr && !go->old_addrs) { + /* use the old style of address negotiation */ + go->neg_addr = 1; + go->old_addrs = 1; + } + if (wo->neg_vj && !go->neg_vj && !go->old_vj) { + /* try an older style of VJ negotiation */ + if (cis_received[f->unit] == 0) { + /* keep trying the new style until we see some CI from the peer */ + go->neg_vj = 1; + } else { + /* use the old style only if the peer did */ + if (ho->neg_vj && ho->old_vj) { + go->neg_vj = 1; + go->old_vj = 1; + go->vj_protocol = ho->vj_protocol; + } + } + } + + return (LENCIADDR(go->neg_addr, go->old_addrs) + + LENCIVJ(go->neg_vj, go->old_vj) + + LENCIDNS(go->req_dns1) + + LENCIDNS(go->req_dns2)); +} + + +/* + * ipcp_addci - Add our desired CIs to a packet. + */ +static void +ipcp_addci(fsm *f, u_char *ucp, int *lenp) +{ + ipcp_options *go = &ipcp_gotoptions[f->unit]; + int len = *lenp; + +#define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \ + if (neg) { \ + int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ + if (len >= vjlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(vjlen, ucp); \ + PUTSHORT(val, ucp); \ + if (!old) { \ + PUTCHAR(maxslotindex, ucp); \ + PUTCHAR(cflag, ucp); \ + } \ + len -= vjlen; \ + } else { \ + neg = 0; \ + } \ + } + +#define ADDCIADDR(opt, neg, old, val1, val2) \ + if (neg) { \ + int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ + if (len >= addrlen) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(addrlen, ucp); \ + l = ntohl(val1); \ + PUTLONG(l, ucp); \ + if (old) { \ + l = ntohl(val2); \ + PUTLONG(l, ucp); \ + } \ + len -= addrlen; \ + } else { \ + neg = 0; \ + } \ + } + +#define ADDCIDNS(opt, neg, addr) \ + if (neg) { \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = ntohl(addr); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else { \ + neg = 0; \ + } \ + } + + ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, + go->old_addrs, go->ouraddr, go->hisaddr); + + ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, + go->maxslotindex, go->cflag); + + ADDCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]); + + ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]); + + *lenp -= len; +} + + +/* + * ipcp_ackci - Ack our CIs. + * + * Returns: + * 0 - Ack was bad. + * 1 - Ack was good. + */ +static int +ipcp_ackci(fsm *f, u_char *p, int len) +{ + ipcp_options *go = &ipcp_gotoptions[f->unit]; + u_short cilen, citype, cishort; + u32_t cilong; + u_char cimaxslotindex, cicflag; + + /* + * CIs must be in exactly the same order that we sent... + * Check packet length and CI length at each step. + * If we find any deviations, then this packet is bad. + */ + +#define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \ + if (neg) { \ + int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ + if ((len -= vjlen) < 0) { \ + goto bad; \ + } \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != vjlen || \ + citype != opt) { \ + goto bad; \ + } \ + GETSHORT(cishort, p); \ + if (cishort != val) { \ + goto bad; \ + } \ + if (!old) { \ + GETCHAR(cimaxslotindex, p); \ + if (cimaxslotindex != maxslotindex) { \ + goto bad; \ + } \ + GETCHAR(cicflag, p); \ + if (cicflag != cflag) { \ + goto bad; \ + } \ + } \ + } + +#define ACKCIADDR(opt, neg, old, val1, val2) \ + if (neg) { \ + int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ + u32_t l; \ + if ((len -= addrlen) < 0) { \ + goto bad; \ + } \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != addrlen || \ + citype != opt) { \ + goto bad; \ + } \ + GETLONG(l, p); \ + cilong = htonl(l); \ + if (val1 != cilong) { \ + goto bad; \ + } \ + if (old) { \ + GETLONG(l, p); \ + cilong = htonl(l); \ + if (val2 != cilong) { \ + goto bad; \ + } \ + } \ + } + +#define ACKCIDNS(opt, neg, addr) \ + if (neg) { \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) { \ + goto bad; \ + } \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || \ + citype != opt) { \ + goto bad; \ + } \ + GETLONG(l, p); \ + cilong = htonl(l); \ + if (addr != cilong) { \ + goto bad; \ + } \ + } + + ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, + go->old_addrs, go->ouraddr, go->hisaddr); + + ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, + go->maxslotindex, go->cflag); + + ACKCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]); + + ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]); + + /* + * If there are any remaining CIs, then this packet is bad. + */ + if (len != 0) { + goto bad; + } + return (1); + +bad: + IPCPDEBUG(LOG_INFO, ("ipcp_ackci: received bad Ack!\n")); + return (0); +} + +/* + * ipcp_nakci - Peer has sent a NAK for some of our CIs. + * This should not modify any state if the Nak is bad + * or if IPCP is in the LS_OPENED state. + * + * Returns: + * 0 - Nak was bad. + * 1 - Nak was good. + */ +static int +ipcp_nakci(fsm *f, u_char *p, int len) +{ + ipcp_options *go = &ipcp_gotoptions[f->unit]; + u_char cimaxslotindex, cicflag; + u_char citype, cilen, *next; + u_short cishort; + u32_t ciaddr1, ciaddr2, l, cidnsaddr; + ipcp_options no; /* options we've seen Naks for */ + ipcp_options try; /* options to request next time */ + + BZERO(&no, sizeof(no)); + try = *go; + + /* + * Any Nak'd CIs must be in exactly the same order that we sent. + * Check packet length and CI length at each step. + * If we find any deviations, then this packet is bad. + */ +#define NAKCIADDR(opt, neg, old, code) \ + if (go->neg && \ + len >= (cilen = (old? CILEN_ADDRS: CILEN_ADDR)) && \ + p[1] == cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + ciaddr1 = htonl(l); \ + if (old) { \ + GETLONG(l, p); \ + ciaddr2 = htonl(l); \ + no.old_addrs = 1; \ + } else { \ + ciaddr2 = 0; \ + } \ + no.neg = 1; \ + code \ + } + +#define NAKCIVJ(opt, neg, code) \ + if (go->neg && \ + ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ + code \ + } + +#define NAKCIDNS(opt, neg, code) \ + if (go->neg && \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cidnsaddr = htonl(l); \ + no.neg = 1; \ + code \ + } + + /* + * Accept the peer's idea of {our,his} address, if different + * from our idea, only if the accept_{local,remote} flag is set. + */ + NAKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, go->old_addrs, + if (go->accept_local && ciaddr1) { /* Do we know our address? */ + try.ouraddr = ciaddr1; + IPCPDEBUG(LOG_INFO, ("local IP address %s\n", + inet_ntoa(ciaddr1))); + } + if (go->accept_remote && ciaddr2) { /* Does he know his? */ + try.hisaddr = ciaddr2; + IPCPDEBUG(LOG_INFO, ("remote IP address %s\n", + inet_ntoa(ciaddr2))); + } + ); + + /* + * Accept the peer's value of maxslotindex provided that it + * is less than what we asked for. Turn off slot-ID compression + * if the peer wants. Send old-style compress-type option if + * the peer wants. + */ + NAKCIVJ(CI_COMPRESSTYPE, neg_vj, + if (cilen == CILEN_VJ) { + GETCHAR(cimaxslotindex, p); + GETCHAR(cicflag, p); + if (cishort == IPCP_VJ_COMP) { + try.old_vj = 0; + if (cimaxslotindex < go->maxslotindex) { + try.maxslotindex = cimaxslotindex; + } + if (!cicflag) { + try.cflag = 0; + } + } else { + try.neg_vj = 0; + } + } else { + if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { + try.old_vj = 1; + try.vj_protocol = cishort; + } else { + try.neg_vj = 0; + } + } + ); + + NAKCIDNS(CI_MS_DNS1, req_dns1, + try.dnsaddr[0] = cidnsaddr; + IPCPDEBUG(LOG_INFO, ("primary DNS address %s\n", inet_ntoa(cidnsaddr))); + ); + + NAKCIDNS(CI_MS_DNS2, req_dns2, + try.dnsaddr[1] = cidnsaddr; + IPCPDEBUG(LOG_INFO, ("secondary DNS address %s\n", inet_ntoa(cidnsaddr))); + ); + + /* + * There may be remaining CIs, if the peer is requesting negotiation + * on an option that we didn't include in our request packet. + * If they want to negotiate about IP addresses, we comply. + * If they want us to ask for compression, we refuse. + */ + while (len > CILEN_VOID) { + GETCHAR(citype, p); + GETCHAR(cilen, p); + if( (len -= cilen) < 0 ) { + goto bad; + } + next = p + cilen - 2; + + switch (citype) { + case CI_COMPRESSTYPE: + if (go->neg_vj || no.neg_vj || + (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { + goto bad; + } + no.neg_vj = 1; + break; + case CI_ADDRS: + if ((go->neg_addr && go->old_addrs) || no.old_addrs + || cilen != CILEN_ADDRS) { + goto bad; + } + try.neg_addr = 1; + try.old_addrs = 1; + GETLONG(l, p); + ciaddr1 = htonl(l); + if (ciaddr1 && go->accept_local) { + try.ouraddr = ciaddr1; + } + GETLONG(l, p); + ciaddr2 = htonl(l); + if (ciaddr2 && go->accept_remote) { + try.hisaddr = ciaddr2; + } + no.old_addrs = 1; + break; + case CI_ADDR: + if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) { + goto bad; + } + try.old_addrs = 0; + GETLONG(l, p); + ciaddr1 = htonl(l); + if (ciaddr1 && go->accept_local) { + try.ouraddr = ciaddr1; + } + if (try.ouraddr != 0) { + try.neg_addr = 1; + } + no.neg_addr = 1; + break; + } + p = next; + } + + /* If there is still anything left, this packet is bad. */ + if (len != 0) { + goto bad; + } + + /* + * OK, the Nak is good. Now we can update state. + */ + if (f->state != LS_OPENED) { + *go = try; + } + + return 1; + +bad: + IPCPDEBUG(LOG_INFO, ("ipcp_nakci: received bad Nak!\n")); + return 0; +} + + +/* + * ipcp_rejci - Reject some of our CIs. + */ +static int +ipcp_rejci(fsm *f, u_char *p, int len) +{ + ipcp_options *go = &ipcp_gotoptions[f->unit]; + u_char cimaxslotindex, ciflag, cilen; + u_short cishort; + u32_t cilong; + ipcp_options try; /* options to request next time */ + + try = *go; + /* + * Any Rejected CIs must be in exactly the same order that we sent. + * Check packet length and CI length at each step. + * If we find any deviations, then this packet is bad. + */ +#define REJCIADDR(opt, neg, old, val1, val2) \ + if (go->neg && \ + len >= (cilen = old? CILEN_ADDRS: CILEN_ADDR) && \ + p[1] == cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val1) { \ + goto bad; \ + } \ + if (old) { \ + GETLONG(l, p); \ + cilong = htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val2) { \ + goto bad; \ + } \ + } \ + try.neg = 0; \ + } + +#define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ + if (go->neg && \ + p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ + len >= p[1] && \ + p[0] == opt) { \ + len -= p[1]; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) { \ + goto bad; \ + } \ + if (!old) { \ + GETCHAR(cimaxslotindex, p); \ + if (cimaxslotindex != maxslot) { \ + goto bad; \ + } \ + GETCHAR(ciflag, p); \ + if (ciflag != cflag) { \ + goto bad; \ + } \ + } \ + try.neg = 0; \ + } + +#define REJCIDNS(opt, neg, dnsaddr) \ + if (go->neg && \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = htonl(l); \ + /* Check rejected value. */ \ + if (cilong != dnsaddr) { \ + goto bad; \ + } \ + try.neg = 0; \ + } + + REJCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, + go->old_addrs, go->ouraddr, go->hisaddr); + + REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, + go->maxslotindex, go->cflag); + + REJCIDNS(CI_MS_DNS1, req_dns1, go->dnsaddr[0]); + + REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]); + + /* + * If there are any remaining CIs, then this packet is bad. + */ + if (len != 0) { + goto bad; + } + /* + * Now we can update state. + */ + if (f->state != LS_OPENED) { + *go = try; + } + return 1; + +bad: + IPCPDEBUG(LOG_INFO, ("ipcp_rejci: received bad Reject!\n")); + return 0; +} + + +/* + * ipcp_reqci - Check the peer's requested CIs and send appropriate response. + * + * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified + * appropriately. If reject_if_disagree is non-zero, doesn't return + * CONFNAK; returns CONFREJ if it can't return CONFACK. + */ +static int +ipcp_reqci(fsm *f, u_char *inp/* Requested CIs */,int *len/* Length of requested CIs */,int reject_if_disagree) +{ + ipcp_options *wo = &ipcp_wantoptions[f->unit]; + ipcp_options *ho = &ipcp_hisoptions[f->unit]; + ipcp_options *ao = &ipcp_allowoptions[f->unit]; +#ifdef OLD_CI_ADDRS + ipcp_options *go = &ipcp_gotoptions[f->unit]; +#endif + u_char *cip, *next; /* Pointer to current and next CIs */ + u_short cilen, citype; /* Parsed len, type */ + u_short cishort; /* Parsed short value */ + u32_t tl, ciaddr1; /* Parsed address values */ +#ifdef OLD_CI_ADDRS + u32_t ciaddr2; /* Parsed address values */ +#endif + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *ucp = inp; /* Pointer to current output char */ + int l = *len; /* Length left */ + u_char maxslotindex, cflag; + int d; + + cis_received[f->unit] = 1; + + /* + * Reset all his options. + */ + BZERO(ho, sizeof(*ho)); + + /* + * Process all his options. + */ + next = inp; + while (l) { + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: bad CI length!\n")); + orc = CONFREJ; /* Reject bad CI */ + cilen = (u_short)l;/* Reject till end of packet */ + l = 0; /* Don't loop again */ + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ +#ifdef OLD_CI_ADDRS /* Need to save space... */ + case CI_ADDRS: + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: received ADDRS\n")); + if (!ao->neg_addr || + cilen != CILEN_ADDRS) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no address, or if we both have his address but + * disagree about it, then NAK it with our idea. + * In particular, if we don't know his address, but he does, + * then accept it. + */ + GETLONG(tl, p); /* Parse source address (his) */ + ciaddr1 = htonl(tl); + IPCPDEBUG(LOG_INFO, ("his addr %s\n", inet_ntoa(ciaddr1))); + if (ciaddr1 != wo->hisaddr + && (ciaddr1 == 0 || !wo->accept_remote)) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = ntohl(wo->hisaddr); + PUTLONG(tl, p); + } + } else if (ciaddr1 == 0 && wo->hisaddr == 0) { + /* + * If neither we nor he knows his address, reject the option. + */ + orc = CONFREJ; + wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ + break; + } + + /* + * If he doesn't know our address, or if we both have our address + * but disagree about it, then NAK it with our idea. + */ + GETLONG(tl, p); /* Parse desination address (ours) */ + ciaddr2 = htonl(tl); + IPCPDEBUG(LOG_INFO, ("our addr %s\n", inet_ntoa(ciaddr2))); + if (ciaddr2 != wo->ouraddr) { + if (ciaddr2 == 0 || !wo->accept_local) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = ntohl(wo->ouraddr); + PUTLONG(tl, p); + } + } else { + go->ouraddr = ciaddr2; /* accept peer's idea */ + } + } + + ho->neg_addr = 1; + ho->old_addrs = 1; + ho->hisaddr = ciaddr1; + ho->ouraddr = ciaddr2; + break; +#endif + + case CI_ADDR: + if (!ao->neg_addr) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Reject ADDR not allowed\n")); + orc = CONFREJ; /* Reject CI */ + break; + } else if (cilen != CILEN_ADDR) { /* Check CI length */ + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Reject ADDR bad len\n")); + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no address, or if we both have his address but + * disagree about it, then NAK it with our idea. + * In particular, if we don't know his address, but he does, + * then accept it. + */ + GETLONG(tl, p); /* Parse source address (his) */ + ciaddr1 = htonl(tl); + if (ciaddr1 != wo->hisaddr + && (ciaddr1 == 0 || !wo->accept_remote)) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = ntohl(wo->hisaddr); + PUTLONG(tl, p); + } + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Nak ADDR %s\n", inet_ntoa(ciaddr1))); + } else if (ciaddr1 == 0 && wo->hisaddr == 0) { + /* + * Don't ACK an address of 0.0.0.0 - reject it instead. + */ + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Reject ADDR %s\n", inet_ntoa(ciaddr1))); + orc = CONFREJ; + wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ + break; + } + + ho->neg_addr = 1; + ho->hisaddr = ciaddr1; + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: ADDR %s\n", inet_ntoa(ciaddr1))); + break; + + case CI_MS_DNS1: + case CI_MS_DNS2: + /* Microsoft primary or secondary DNS request */ + d = citype == CI_MS_DNS2; + + /* If we do not have a DNS address then we cannot send it */ + if (ao->dnsaddr[d] == 0 || + cilen != CILEN_ADDR) { /* Check CI length */ + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting DNS%d Request\n", d+1)); + orc = CONFREJ; /* Reject CI */ + break; + } + GETLONG(tl, p); + if (htonl(tl) != ao->dnsaddr[d]) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking DNS%d Request %s\n", + d+1, inet_ntoa(tl))); + DECPTR(sizeof(u32_t), p); + tl = ntohl(ao->dnsaddr[d]); + PUTLONG(tl, p); + orc = CONFNAK; + } + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: received DNS%d Request\n", d+1)); + break; + + case CI_MS_WINS1: + case CI_MS_WINS2: + /* Microsoft primary or secondary WINS request */ + d = citype == CI_MS_WINS2; + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: received WINS%d Request\n", d+1)); + + /* If we do not have a DNS address then we cannot send it */ + if (ao->winsaddr[d] == 0 || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETLONG(tl, p); + if (htonl(tl) != ao->winsaddr[d]) { + DECPTR(sizeof(u32_t), p); + tl = ntohl(ao->winsaddr[d]); + PUTLONG(tl, p); + orc = CONFNAK; + } + break; + + case CI_COMPRESSTYPE: + if (!ao->neg_vj) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting COMPRESSTYPE not allowed\n")); + orc = CONFREJ; + break; + } else if (cilen != CILEN_VJ && cilen != CILEN_COMPRESS) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting COMPRESSTYPE len=%d\n", cilen)); + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + + if (!(cishort == IPCP_VJ_COMP || + (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting COMPRESSTYPE %d\n", cishort)); + orc = CONFREJ; + break; + } + + ho->neg_vj = 1; + ho->vj_protocol = cishort; + if (cilen == CILEN_VJ) { + GETCHAR(maxslotindex, p); + if (maxslotindex > ao->maxslotindex) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking VJ max slot %d\n", maxslotindex)); + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(1, p); + PUTCHAR(ao->maxslotindex, p); + } + } + GETCHAR(cflag, p); + if (cflag && !ao->cflag) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking VJ cflag %d\n", cflag)); + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(1, p); + PUTCHAR(wo->cflag, p); + } + } + ho->maxslotindex = maxslotindex; + ho->cflag = cflag; + } else { + ho->old_vj = 1; + ho->maxslotindex = MAX_SLOTS - 1; + ho->cflag = 1; + } + IPCPDEBUG(LOG_INFO, ( + "ipcp_reqci: received COMPRESSTYPE p=%d old=%d maxslot=%d cflag=%d\n", + ho->vj_protocol, ho->old_vj, ho->maxslotindex, ho->cflag)); + break; + + default: + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting unknown CI type %d\n", citype)); + orc = CONFREJ; + break; + } + +endswitch: + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) { /* but prior CI wasnt? */ + continue; /* Don't send this one */ + } + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree) { /* Getting fed up with sending NAKs? */ + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting too many naks\n")); + orc = CONFREJ; /* Get tough if so */ + } else { + if (rc == CONFREJ) { /* Rejecting prior CI? */ + continue; /* Don't send this one */ + } + if (rc == CONFACK) { /* Ack'd all prior CIs? */ + rc = CONFNAK; /* Not anymore... */ + ucp = inp; /* Backup */ + } + } + } + + if (orc == CONFREJ && /* Reject this CI */ + rc != CONFREJ) { /* but no prior ones? */ + rc = CONFREJ; + ucp = inp; /* Backup */ + } + + /* Need to move CI? */ + if (ucp != cip) { + BCOPY(cip, ucp, cilen); /* Move it */ + } + + /* Update output pointer */ + INCPTR(cilen, ucp); + } + + /* + * If we aren't rejecting this packet, and we want to negotiate + * their address, and they didn't send their address, then we + * send a NAK with a CI_ADDR option appended. We assume the + * input buffer is long enough that we can append the extra + * option safely. + */ + if (rc != CONFREJ && !ho->neg_addr && + wo->req_addr && !reject_if_disagree) { + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Requesting peer address\n")); + if (rc == CONFACK) { + rc = CONFNAK; + ucp = inp; /* reset pointer */ + wo->req_addr = 0; /* don't ask again */ + } + PUTCHAR(CI_ADDR, ucp); + PUTCHAR(CILEN_ADDR, ucp); + tl = ntohl(wo->hisaddr); + PUTLONG(tl, ucp); + } + + *len = (int)(ucp - inp); /* Compute output length */ + IPCPDEBUG(LOG_INFO, ("ipcp_reqci: returning Configure-%s\n", CODENAME(rc))); + return (rc); /* Return final code */ +} + + +#if 0 +/* + * ip_check_options - check that any IP-related options are OK, + * and assign appropriate defaults. + */ +static void +ip_check_options(u_long localAddr) +{ + ipcp_options *wo = &ipcp_wantoptions[0]; + + /* + * Load our default IP address but allow the remote host to give us + * a new address. + */ + if (wo->ouraddr == 0 && !ppp_settings.disable_defaultip) { + wo->accept_local = 1; /* don't insist on this default value */ + wo->ouraddr = htonl(localAddr); + } +} +#endif + + +/* + * ipcp_up - IPCP has come UP. + * + * Configure the IP network interface appropriately and bring it up. + */ +static void +ipcp_up(fsm *f) +{ + u32_t mask; + ipcp_options *ho = &ipcp_hisoptions[f->unit]; + ipcp_options *go = &ipcp_gotoptions[f->unit]; + ipcp_options *wo = &ipcp_wantoptions[f->unit]; + + np_up(f->unit, PPP_IP); + IPCPDEBUG(LOG_INFO, ("ipcp: up\n")); + + /* + * We must have a non-zero IP address for both ends of the link. + */ + if (!ho->neg_addr) { + ho->hisaddr = wo->hisaddr; + } + + if (ho->hisaddr == 0) { + IPCPDEBUG(LOG_ERR, ("Could not determine remote IP address\n")); + ipcp_close(f->unit, "Could not determine remote IP address"); + return; + } + if (go->ouraddr == 0) { + IPCPDEBUG(LOG_ERR, ("Could not determine local IP address\n")); + ipcp_close(f->unit, "Could not determine local IP address"); + return; + } + + if (ppp_settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { + /*pppGotDNSAddrs(go->dnsaddr[0], go->dnsaddr[1]);*/ + } + + /* + * Check that the peer is allowed to use the IP address it wants. + */ + if (!auth_ip_addr(f->unit, ho->hisaddr)) { + IPCPDEBUG(LOG_ERR, ("Peer is not authorized to use remote address %s\n", + inet_ntoa(ho->hisaddr))); + ipcp_close(f->unit, "Unauthorized remote IP address"); + return; + } + + /* set tcp compression */ + sifvjcomp(f->unit, ho->neg_vj, ho->cflag, ho->maxslotindex); + + /* + * Set IP addresses and (if specified) netmask. + */ + mask = GetMask(go->ouraddr); + + if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask, go->dnsaddr[0], go->dnsaddr[1])) { + IPCPDEBUG(LOG_WARNING, ("sifaddr failed\n")); + ipcp_close(f->unit, "Interface configuration failed"); + return; + } + + /* bring the interface up for IP */ + if (!sifup(f->unit)) { + IPCPDEBUG(LOG_WARNING, ("sifup failed\n")); + ipcp_close(f->unit, "Interface configuration failed"); + return; + } + + sifnpmode(f->unit, PPP_IP, NPMODE_PASS); + + /* assign a default route through the interface if required */ + if (ipcp_wantoptions[f->unit].default_route) { + if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr)) { + default_route_set[f->unit] = 1; + } + } + + IPCPDEBUG(LOG_NOTICE, ("local IP address %s\n", inet_ntoa(go->ouraddr))); + IPCPDEBUG(LOG_NOTICE, ("remote IP address %s\n", inet_ntoa(ho->hisaddr))); + if (go->dnsaddr[0]) { + IPCPDEBUG(LOG_NOTICE, ("primary DNS address %s\n", inet_ntoa(go->dnsaddr[0]))); + } + if (go->dnsaddr[1]) { + IPCPDEBUG(LOG_NOTICE, ("secondary DNS address %s\n", inet_ntoa(go->dnsaddr[1]))); + } +} + + +/* + * ipcp_down - IPCP has gone DOWN. + * + * Take the IP network interface down, clear its addresses + * and delete routes through it. + */ +static void +ipcp_down(fsm *f) +{ + IPCPDEBUG(LOG_INFO, ("ipcp: down\n")); + np_down(f->unit, PPP_IP); + sifvjcomp(f->unit, 0, 0, 0); + + sifdown(f->unit); + ipcp_clear_addrs(f->unit); +} + + +/* + * ipcp_clear_addrs() - clear the interface addresses, routes, etc. + */ +static void +ipcp_clear_addrs(int unit) +{ + u32_t ouraddr, hisaddr; + + ouraddr = ipcp_gotoptions[unit].ouraddr; + hisaddr = ipcp_hisoptions[unit].hisaddr; + if (default_route_set[unit]) { + cifdefaultroute(unit, ouraddr, hisaddr); + default_route_set[unit] = 0; + } + cifaddr(unit, ouraddr, hisaddr); +} + + +/* + * ipcp_finished - possibly shut down the lower layers. + */ +static void +ipcp_finished(fsm *f) +{ + np_finished(f->unit, PPP_IP); +} + +#if PPP_ADDITIONAL_CALLBACKS +static int +ipcp_printpkt(u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) +{ + LWIP_UNUSED_ARG(p); + LWIP_UNUSED_ARG(plen); + LWIP_UNUSED_ARG(printer); + LWIP_UNUSED_ARG(arg); + return 0; +} + +/* + * ip_active_pkt - see if this IP packet is worth bringing the link up for. + * We don't bring the link up for IP fragments or for TCP FIN packets + * with no data. + */ +#define IP_HDRLEN 20 /* bytes */ +#define IP_OFFMASK 0x1fff +#define IPPROTO_TCP 6 +#define TCP_HDRLEN 20 +#define TH_FIN 0x01 + +/* + * We use these macros because the IP header may be at an odd address, + * and some compilers might use word loads to get th_off or ip_hl. + */ + +#define net_short(x) (((x)[0] << 8) + (x)[1]) +#define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) +#define get_ipoff(x) net_short((unsigned char *)(x) + 6) +#define get_ipproto(x) (((unsigned char *)(x))[9]) +#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) +#define get_tcpflags(x) (((unsigned char *)(x))[13]) + +static int +ip_active_pkt(u_char *pkt, int len) +{ + u_char *tcp; + int hlen; + + len -= PPP_HDRLEN; + pkt += PPP_HDRLEN; + if (len < IP_HDRLEN) { + return 0; + } + if ((get_ipoff(pkt) & IP_OFFMASK) != 0) { + return 0; + } + if (get_ipproto(pkt) != IPPROTO_TCP) { + return 1; + } + hlen = get_iphl(pkt) * 4; + if (len < hlen + TCP_HDRLEN) { + return 0; + } + tcp = pkt + hlen; + if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4) { + return 0; + } + return 1; +} +#endif /* PPP_ADDITIONAL_CALLBACKS */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ipcp.h b/user/mpy/lib/lwip/src/netif/ppp/ipcp.h new file mode 100644 index 0000000..de03f46 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/ipcp.h @@ -0,0 +1,106 @@ +/***************************************************************************** +* ipcp.h - PPP IP NCP: Internet Protocol Network Control Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-04 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ +/* + * ipcp.h - IP Control Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: ipcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $ + */ + +#ifndef IPCP_H +#define IPCP_H + +/* + * Options. + */ +#define CI_ADDRS 1 /* IP Addresses */ +#define CI_COMPRESSTYPE 2 /* Compression Type */ +#define CI_ADDR 3 + +#define CI_MS_DNS1 129 /* Primary DNS value */ +#define CI_MS_WINS1 128 /* Primary WINS value */ +#define CI_MS_DNS2 131 /* Secondary DNS value */ +#define CI_MS_WINS2 130 /* Secondary WINS value */ + +#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */ +#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */ +#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */ + /* maxslot and slot number compression) */ + +#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option */ +#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */ + /* compression option */ + +typedef struct ipcp_options { + u_int neg_addr : 1; /* Negotiate IP Address? */ + u_int old_addrs : 1; /* Use old (IP-Addresses) option? */ + u_int req_addr : 1; /* Ask peer to send IP address? */ + u_int default_route : 1; /* Assign default route through interface? */ + u_int proxy_arp : 1; /* Make proxy ARP entry for peer? */ + u_int neg_vj : 1; /* Van Jacobson Compression? */ + u_int old_vj : 1; /* use old (short) form of VJ option? */ + u_int accept_local : 1; /* accept peer's value for ouraddr */ + u_int accept_remote : 1; /* accept peer's value for hisaddr */ + u_int req_dns1 : 1; /* Ask peer to send primary DNS address? */ + u_int req_dns2 : 1; /* Ask peer to send secondary DNS address? */ + u_short vj_protocol; /* protocol value to use in VJ option */ + u_char maxslotindex; /* VJ slots - 1. */ + u_char cflag; /* VJ slot compression flag. */ + u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ + u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ + u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ +} ipcp_options; + +extern fsm ipcp_fsm[]; +extern ipcp_options ipcp_wantoptions[]; +extern ipcp_options ipcp_gotoptions[]; +extern ipcp_options ipcp_allowoptions[]; +extern ipcp_options ipcp_hisoptions[]; + +extern struct protent ipcp_protent; + +#endif /* IPCP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/lcp.c b/user/mpy/lib/lwip/src/netif/ppp/lcp.c new file mode 100644 index 0000000..54f758a --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/lcp.c @@ -0,0 +1,2066 @@ +/***************************************************************************** +* lcp.c - Network Link Control Protocol program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-01 Guy Lancaster , Global Election Systems Inc. +* Original. +*****************************************************************************/ + +/* + * lcp.c - PPP Link Control Protocol. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "fsm.h" +#include "chap.h" +#include "magic.h" +#include "auth.h" +#include "lcp.h" + +#include + +#if PPPOE_SUPPORT +#include "netif/ppp_oe.h" +#else +#define PPPOE_MAXMTU PPP_MAXMRU +#endif + +#if 0 /* UNUSED */ +/* + * LCP-related command-line options. + */ +int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ +int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ +bool lax_recv = 0; /* accept control chars in asyncmap */ + +static int setescape (char **); + +static option_t lcp_option_list[] = { + /* LCP options */ + /* list stripped for simplicity */ + {NULL} +}; +#endif /* UNUSED */ + +/* options */ +LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */ +static u_int lcp_echo_interval = LCP_ECHOINTERVAL; /* Interval between LCP echo-requests */ +static u_int lcp_echo_fails = LCP_MAXECHOFAILS; /* Tolerance to unanswered echo-requests */ + +/* global vars */ +static fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/ +lcp_options lcp_wantoptions[NUM_PPP]; /* Options that we want to request */ +lcp_options lcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ +lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ +lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ +ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */ + +static u32_t lcp_echos_pending = 0; /* Number of outstanding echo msgs */ +static u32_t lcp_echo_number = 0; /* ID number of next echo frame */ +static u32_t lcp_echo_timer_running = 0; /* TRUE if a timer is running */ + +/* @todo: do we really need such a large buffer? The typical 1500 bytes seem too much. */ +static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ + +/* + * Callbacks for fsm code. (CI = Configuration Information) + */ +static void lcp_resetci (fsm*); /* Reset our CI */ +static int lcp_cilen (fsm*); /* Return length of our CI */ +static void lcp_addci (fsm*, u_char*, int*); /* Add our CI to pkt */ +static int lcp_ackci (fsm*, u_char*, int); /* Peer ack'd our CI */ +static int lcp_nakci (fsm*, u_char*, int); /* Peer nak'd our CI */ +static int lcp_rejci (fsm*, u_char*, int); /* Peer rej'd our CI */ +static int lcp_reqci (fsm*, u_char*, int*, int); /* Rcv peer CI */ +static void lcp_up (fsm*); /* We're UP */ +static void lcp_down (fsm*); /* We're DOWN */ +static void lcp_starting (fsm*); /* We need lower layer up */ +static void lcp_finished (fsm*); /* We need lower layer down */ +static int lcp_extcode (fsm*, int, u_char, u_char*, int); +static void lcp_rprotrej (fsm*, u_char*, int); + +/* + * routines to send LCP echos to peer + */ + +static void lcp_echo_lowerup (int); +static void lcp_echo_lowerdown (int); +static void LcpEchoTimeout (void*); +static void lcp_received_echo_reply (fsm*, int, u_char*, int); +static void LcpSendEchoRequest (fsm*); +static void LcpLinkFailure (fsm*); +static void LcpEchoCheck (fsm*); + +static fsm_callbacks lcp_callbacks = { /* LCP callback routines */ + lcp_resetci, /* Reset our Configuration Information */ + lcp_cilen, /* Length of our Configuration Information */ + lcp_addci, /* Add our Configuration Information */ + lcp_ackci, /* ACK our Configuration Information */ + lcp_nakci, /* NAK our Configuration Information */ + lcp_rejci, /* Reject our Configuration Information */ + lcp_reqci, /* Request peer's Configuration Information */ + lcp_up, /* Called when fsm reaches LS_OPENED state */ + lcp_down, /* Called when fsm leaves LS_OPENED state */ + lcp_starting, /* Called when we want the lower layer up */ + lcp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + lcp_extcode, /* Called to handle LCP-specific codes */ + "LCP" /* String name of protocol */ +}; + +/* + * Protocol entry points. + * Some of these are called directly. + */ + +static void lcp_input (int, u_char *, int); +static void lcp_protrej (int); + +struct protent lcp_protent = { + PPP_LCP, + lcp_init, + lcp_input, + lcp_protrej, + lcp_lowerup, + lcp_lowerdown, + lcp_open, + lcp_close, +#if PPP_ADDITIONAL_CALLBACKS + lcp_printpkt, + NULL, +#endif /* PPP_ADDITIONAL_CALLBACKS */ + 1, + "LCP", +#if PPP_ADDITIONAL_CALLBACKS + NULL, + NULL, + NULL +#endif /* PPP_ADDITIONAL_CALLBACKS */ +}; + +int lcp_loopbackfail = DEFLOOPBACKFAIL; + +/* + * Length of each type of configuration option (in octets) + */ +#define CILEN_VOID 2 +#define CILEN_CHAR 3 +#define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */ +#define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */ +#define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */ +#define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */ +#define CILEN_CBCP 3 + +#define CODENAME(x) ((x) == CONFACK ? "ACK" : (x) == CONFNAK ? "NAK" : "REJ") + +#if 0 /* UNUSED */ +/* + * setescape - add chars to the set we escape on transmission. + */ +static int +setescape(argv) + char **argv; +{ + int n, ret; + char *p, *endp; + + p = *argv; + ret = 1; + while (*p) { + n = strtol(p, &endp, 16); + if (p == endp) { + option_error("escape parameter contains invalid hex number '%s'", p); + return 0; + } + p = endp; + if (n < 0 || n == 0x5E || n > 0xFF) { + option_error("can't escape character 0x%x", n); + ret = 0; + } else + xmit_accm[0][n >> 5] |= 1 << (n & 0x1F); + while (*p == ',' || *p == ' ') + ++p; + } + return ret; +} +#endif /* UNUSED */ + +/* + * lcp_init - Initialize LCP. + */ +void +lcp_init(int unit) +{ + fsm *f = &lcp_fsm[unit]; + lcp_options *wo = &lcp_wantoptions[unit]; + lcp_options *ao = &lcp_allowoptions[unit]; + + f->unit = unit; + f->protocol = PPP_LCP; + f->callbacks = &lcp_callbacks; + + fsm_init(f); + + wo->passive = 0; + wo->silent = 0; + wo->restart = 0; /* Set to 1 in kernels or multi-line implementations */ + wo->neg_mru = 1; + wo->mru = PPP_DEFMRU; + wo->neg_asyncmap = 1; + wo->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */ + wo->neg_chap = 0; /* Set to 1 on server */ + wo->neg_upap = 0; /* Set to 1 on server */ + wo->chap_mdtype = CHAP_DIGEST_MD5; + wo->neg_magicnumber = 1; + wo->neg_pcompression = 1; + wo->neg_accompression = 1; + wo->neg_lqr = 0; /* no LQR implementation yet */ + wo->neg_cbcp = 0; + + ao->neg_mru = 1; + ao->mru = PPP_MAXMRU; + ao->neg_asyncmap = 1; + ao->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */ + ao->neg_chap = (CHAP_SUPPORT != 0); + ao->chap_mdtype = CHAP_DIGEST_MD5; + ao->neg_upap = (PAP_SUPPORT != 0); + ao->neg_magicnumber = 1; + ao->neg_pcompression = 1; + ao->neg_accompression = 1; + ao->neg_lqr = 0; /* no LQR implementation yet */ + ao->neg_cbcp = (CBCP_SUPPORT != 0); + + /* + * Set transmit escape for the flag and escape characters plus anything + * set for the allowable options. + */ + memset(xmit_accm[unit], 0, sizeof(xmit_accm[0])); + xmit_accm[unit][15] = 0x60; + xmit_accm[unit][0] = (u_char)((ao->asyncmap & 0xFF)); + xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF); + xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF); + xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF); + LCPDEBUG(LOG_INFO, ("lcp_init: xmit_accm=%X %X %X %X\n", + xmit_accm[unit][0], + xmit_accm[unit][1], + xmit_accm[unit][2], + xmit_accm[unit][3])); + + lcp_phase[unit] = PHASE_INITIALIZE; +} + + +/* + * lcp_open - LCP is allowed to come up. + */ +void +lcp_open(int unit) +{ + fsm *f = &lcp_fsm[unit]; + lcp_options *wo = &lcp_wantoptions[unit]; + + f->flags = 0; + if (wo->passive) { + f->flags |= OPT_PASSIVE; + } + if (wo->silent) { + f->flags |= OPT_SILENT; + } + fsm_open(f); + + lcp_phase[unit] = PHASE_ESTABLISH; +} + + +/* + * lcp_close - Take LCP down. + */ +void +lcp_close(int unit, char *reason) +{ + fsm *f = &lcp_fsm[unit]; + + if (lcp_phase[unit] != PHASE_DEAD) { + lcp_phase[unit] = PHASE_TERMINATE; + } + if (f->state == LS_STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) { + /* + * This action is not strictly according to the FSM in RFC1548, + * but it does mean that the program terminates if you do an + * lcp_close() in passive/silent mode when a connection hasn't + * been established. + */ + f->state = LS_CLOSED; + lcp_finished(f); + } else { + fsm_close(f, reason); + } +} + + +/* + * lcp_lowerup - The lower layer is up. + */ +void +lcp_lowerup(int unit) +{ + lcp_options *wo = &lcp_wantoptions[unit]; + + /* + * Don't use A/C or protocol compression on transmission, + * but accept A/C and protocol compressed packets + * if we are going to ask for A/C and protocol compression. + */ + ppp_set_xaccm(unit, &xmit_accm[unit]); + ppp_send_config(unit, PPP_MRU, 0xffffffffl, 0, 0); + ppp_recv_config(unit, PPP_MRU, 0x00000000l, + wo->neg_pcompression, wo->neg_accompression); + peer_mru[unit] = PPP_MRU; + lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0] + | ((u_long)xmit_accm[unit][1] << 8) + | ((u_long)xmit_accm[unit][2] << 16) + | ((u_long)xmit_accm[unit][3] << 24); + LCPDEBUG(LOG_INFO, ("lcp_lowerup: asyncmap=%X %X %X %X\n", + xmit_accm[unit][3], + xmit_accm[unit][2], + xmit_accm[unit][1], + xmit_accm[unit][0])); + + fsm_lowerup(&lcp_fsm[unit]); +} + + +/* + * lcp_lowerdown - The lower layer is down. + */ +void +lcp_lowerdown(int unit) +{ + fsm_lowerdown(&lcp_fsm[unit]); +} + + +/* + * lcp_input - Input LCP packet. + */ +static void +lcp_input(int unit, u_char *p, int len) +{ + fsm *f = &lcp_fsm[unit]; + + fsm_input(f, p, len); +} + + +/* + * lcp_extcode - Handle a LCP-specific code. + */ +static int +lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len) +{ + u_char *magp; + + switch( code ){ + case PROTREJ: + lcp_rprotrej(f, inp, len); + break; + + case ECHOREQ: + if (f->state != LS_OPENED) { + break; + } + LCPDEBUG(LOG_INFO, ("lcp: Echo-Request, Rcvd id %d\n", id)); + magp = inp; + PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp); + fsm_sdata(f, ECHOREP, id, inp, len); + break; + + case ECHOREP: + lcp_received_echo_reply(f, id, inp, len); + break; + + case DISCREQ: + break; + + default: + return 0; + } + return 1; +} + + +/* + * lcp_rprotrej - Receive an Protocol-Reject. + * + * Figure out which protocol is rejected and inform it. + */ +static void +lcp_rprotrej(fsm *f, u_char *inp, int len) +{ + int i; + struct protent *protp; + u_short prot; + + if (len < (int)sizeof (u_short)) { + LCPDEBUG(LOG_INFO, ("lcp_rprotrej: Rcvd short Protocol-Reject packet!\n")); + return; + } + + GETSHORT(prot, inp); + + LCPDEBUG(LOG_INFO, ("lcp_rprotrej: Rcvd Protocol-Reject packet for %x!\n", prot)); + + /* + * Protocol-Reject packets received in any state other than the LCP + * LS_OPENED state SHOULD be silently discarded. + */ + if( f->state != LS_OPENED ) { + LCPDEBUG(LOG_INFO, ("Protocol-Reject discarded: LCP in state %d\n", f->state)); + return; + } + + /* + * Upcall the proper Protocol-Reject routine. + */ + for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { + if (protp->protocol == prot && protp->enabled_flag) { + (*protp->protrej)(f->unit); + return; + } + } + + LCPDEBUG(LOG_WARNING, ("Protocol-Reject for unsupported protocol 0x%x\n", prot)); +} + + +/* + * lcp_protrej - A Protocol-Reject was received. + */ +static void +lcp_protrej(int unit) +{ + LWIP_UNUSED_ARG(unit); + /* + * Can't reject LCP! + */ + LCPDEBUG(LOG_WARNING, ("lcp_protrej: Received Protocol-Reject for LCP!\n")); + fsm_protreject(&lcp_fsm[unit]); +} + + +/* + * lcp_sprotrej - Send a Protocol-Reject for some protocol. + */ +void +lcp_sprotrej(int unit, u_char *p, int len) +{ + /* + * Send back the protocol and the information field of the + * rejected packet. We only get here if LCP is in the LS_OPENED state. + */ + + fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id, p, len); +} + + +/* + * lcp_resetci - Reset our CI. + */ +static void +lcp_resetci(fsm *f) +{ + lcp_wantoptions[f->unit].magicnumber = magic(); + lcp_wantoptions[f->unit].numloops = 0; + lcp_gotoptions[f->unit] = lcp_wantoptions[f->unit]; + peer_mru[f->unit] = PPP_MRU; + auth_reset(f->unit); +} + + +/* + * lcp_cilen - Return length of our CI. + */ +static int +lcp_cilen(fsm *f) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + +#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) +#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) +#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) +#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) +#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) +#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) + /* + * NB: we only ask for one of CHAP and UPAP, even if we will + * accept either. + */ + return (LENCISHORT(go->neg_mru && go->mru != PPP_DEFMRU) + + LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) + + LENCICHAP(go->neg_chap) + + LENCISHORT(!go->neg_chap && go->neg_upap) + + LENCILQR(go->neg_lqr) + + LENCICBCP(go->neg_cbcp) + + LENCILONG(go->neg_magicnumber) + + LENCIVOID(go->neg_pcompression) + + LENCIVOID(go->neg_accompression)); +} + + +/* + * lcp_addci - Add our desired CIs to a packet. + */ +static void +lcp_addci(fsm *f, u_char *ucp, int *lenp) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + u_char *start_ucp = ucp; + +#define ADDCIVOID(opt, neg) \ + if (neg) { \ + LCPDEBUG(LOG_INFO, ("lcp_addci: opt=%d\n", opt)); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_VOID, ucp); \ + } +#define ADDCISHORT(opt, neg, val) \ + if (neg) { \ + LCPDEBUG(LOG_INFO, ("lcp_addci: INT opt=%d %X\n", opt, val)); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_SHORT, ucp); \ + PUTSHORT(val, ucp); \ + } +#define ADDCICHAP(opt, neg, val, digest) \ + if (neg) { \ + LCPDEBUG(LOG_INFO, ("lcp_addci: CHAP opt=%d %X\n", opt, val)); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_CHAP, ucp); \ + PUTSHORT(val, ucp); \ + PUTCHAR(digest, ucp); \ + } +#define ADDCILONG(opt, neg, val) \ + if (neg) { \ + LCPDEBUG(LOG_INFO, ("lcp_addci: L opt=%d %lX\n", opt, val)); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_LONG, ucp); \ + PUTLONG(val, ucp); \ + } +#define ADDCILQR(opt, neg, val) \ + if (neg) { \ + LCPDEBUG(LOG_INFO, ("lcp_addci: LQR opt=%d %lX\n", opt, val)); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_LQR, ucp); \ + PUTSHORT(PPP_LQR, ucp); \ + PUTLONG(val, ucp); \ + } +#define ADDCICHAR(opt, neg, val) \ + if (neg) { \ + LCPDEBUG(LOG_INFO, ("lcp_addci: CHAR opt=%d %X '%z'\n", opt, val, val)); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_CHAR, ucp); \ + PUTCHAR(val, ucp); \ + } + + ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); + ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap); + ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype); + ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP); + ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period); + ADDCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT); + ADDCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber); + ADDCIVOID(CI_PCOMPRESSION, go->neg_pcompression); + ADDCIVOID(CI_ACCOMPRESSION, go->neg_accompression); + + if (ucp - start_ucp != *lenp) { + /* this should never happen, because peer_mtu should be 1500 */ + LCPDEBUG(LOG_ERR, ("Bug in lcp_addci: wrong length\n")); + } +} + + +/* + * lcp_ackci - Ack our CIs. + * This should not modify any state if the Ack is bad. + * + * Returns: + * 0 - Ack was bad. + * 1 - Ack was good. + */ +static int +lcp_ackci(fsm *f, u_char *p, int len) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + u_char cilen, citype, cichar; + u_short cishort; + u32_t cilong; + + /* + * CIs must be in exactly the same order that we sent. + * Check packet length and CI length at each step. + * If we find any deviations, then this packet is bad. + */ +#define ACKCIVOID(opt, neg) \ + if (neg) { \ + if ((len -= CILEN_VOID) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_VOID || citype != opt) \ + goto bad; \ + } +#define ACKCISHORT(opt, neg, val) \ + if (neg) { \ + if ((len -= CILEN_SHORT) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_SHORT || citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ + } +#define ACKCICHAR(opt, neg, val) \ + if (neg) { \ + if ((len -= CILEN_CHAR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAR || citype != opt) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != val) \ + goto bad; \ + } +#define ACKCICHAP(opt, neg, val, digest) \ + if (neg) { \ + if ((len -= CILEN_CHAP) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAP || citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != digest) \ + goto bad; \ + } +#define ACKCILONG(opt, neg, val) \ + if (neg) { \ + if ((len -= CILEN_LONG) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_LONG || citype != opt) \ + goto bad; \ + GETLONG(cilong, p); \ + if (cilong != val) \ + goto bad; \ + } +#define ACKCILQR(opt, neg, val) \ + if (neg) { \ + if ((len -= CILEN_LQR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_LQR || citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != PPP_LQR) \ + goto bad; \ + GETLONG(cilong, p); \ + if (cilong != val) \ + goto bad; \ + } + + ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); + ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap); + ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype); + ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP); + ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period); + ACKCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT); + ACKCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber); + ACKCIVOID(CI_PCOMPRESSION, go->neg_pcompression); + ACKCIVOID(CI_ACCOMPRESSION, go->neg_accompression); + + /* + * If there are any remaining CIs, then this packet is bad. + */ + if (len != 0) { + goto bad; + } + LCPDEBUG(LOG_INFO, ("lcp_acki: Ack\n")); + return (1); +bad: + LCPDEBUG(LOG_WARNING, ("lcp_acki: received bad Ack!\n")); + return (0); +} + + +/* + * lcp_nakci - Peer has sent a NAK for some of our CIs. + * This should not modify any state if the Nak is bad + * or if LCP is in the LS_OPENED state. + * + * Returns: + * 0 - Nak was bad. + * 1 - Nak was good. + */ +static int +lcp_nakci(fsm *f, u_char *p, int len) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + lcp_options *wo = &lcp_wantoptions[f->unit]; + u_char citype, cichar, *next; + u_short cishort; + u32_t cilong; + lcp_options no; /* options we've seen Naks for */ + lcp_options try; /* options to request next time */ + int looped_back = 0; + int cilen; + + BZERO(&no, sizeof(no)); + try = *go; + + /* + * Any Nak'd CIs must be in exactly the same order that we sent. + * Check packet length and CI length at each step. + * If we find any deviations, then this packet is bad. + */ +#define NAKCIVOID(opt, neg, code) \ + if (go->neg && \ + len >= CILEN_VOID && \ + p[1] == CILEN_VOID && \ + p[0] == opt) { \ + len -= CILEN_VOID; \ + INCPTR(CILEN_VOID, p); \ + no.neg = 1; \ + code \ + } +#define NAKCICHAP(opt, neg, code) \ + if (go->neg && \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + no.neg = 1; \ + code \ + } +#define NAKCICHAR(opt, neg, code) \ + if (go->neg && \ + len >= CILEN_CHAR && \ + p[1] == CILEN_CHAR && \ + p[0] == opt) { \ + len -= CILEN_CHAR; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + no.neg = 1; \ + code \ + } +#define NAKCISHORT(opt, neg, code) \ + if (go->neg && \ + len >= CILEN_SHORT && \ + p[1] == CILEN_SHORT && \ + p[0] == opt) { \ + len -= CILEN_SHORT; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ + code \ + } +#define NAKCILONG(opt, neg, code) \ + if (go->neg && \ + len >= CILEN_LONG && \ + p[1] == CILEN_LONG && \ + p[0] == opt) { \ + len -= CILEN_LONG; \ + INCPTR(2, p); \ + GETLONG(cilong, p); \ + no.neg = 1; \ + code \ + } +#define NAKCILQR(opt, neg, code) \ + if (go->neg && \ + len >= CILEN_LQR && \ + p[1] == CILEN_LQR && \ + p[0] == opt) { \ + len -= CILEN_LQR; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETLONG(cilong, p); \ + no.neg = 1; \ + code \ + } + + /* + * We don't care if they want to send us smaller packets than + * we want. Therefore, accept any MRU less than what we asked for, + * but then ignore the new value when setting the MRU in the kernel. + * If they send us a bigger MRU than what we asked, accept it, up to + * the limit of the default MRU we'd get if we didn't negotiate. + */ + if (go->neg_mru && go->mru != PPP_DEFMRU) { + NAKCISHORT(CI_MRU, neg_mru, + if (cishort <= wo->mru || cishort < PPP_DEFMRU) { + try.mru = cishort; + } + ); + } + + /* + * Add any characters they want to our (receive-side) asyncmap. + */ + if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) { + NAKCILONG(CI_ASYNCMAP, neg_asyncmap, + try.asyncmap = go->asyncmap | cilong; + ); + } + + /* + * If they've nak'd our authentication-protocol, check whether + * they are proposing a different protocol, or a different + * hash algorithm for CHAP. + */ + if ((go->neg_chap || go->neg_upap) + && len >= CILEN_SHORT + && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { + cilen = p[1]; + len -= cilen; + no.neg_chap = go->neg_chap; + no.neg_upap = go->neg_upap; + INCPTR(2, p); + GETSHORT(cishort, p); + if (cishort == PPP_PAP && cilen == CILEN_SHORT) { + /* + * If we were asking for CHAP, they obviously don't want to do it. + * If we weren't asking for CHAP, then we were asking for PAP, + * in which case this Nak is bad. + */ + if (!go->neg_chap) { + goto bad; + } + try.neg_chap = 0; + + } else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { + GETCHAR(cichar, p); + if (go->neg_chap) { + /* + * We were asking for CHAP/MD5; they must want a different + * algorithm. If they can't do MD5, we'll have to stop + * asking for CHAP. + */ + if (cichar != go->chap_mdtype) { + try.neg_chap = 0; + } + } else { + /* + * Stop asking for PAP if we were asking for it. + */ + try.neg_upap = 0; + } + + } else { + /* + * We don't recognize what they're suggesting. + * Stop asking for what we were asking for. + */ + if (go->neg_chap) { + try.neg_chap = 0; + } else { + try.neg_upap = 0; + } + p += cilen - CILEN_SHORT; + } + } + + /* + * If they can't cope with our link quality protocol, we'll have + * to stop asking for LQR. We haven't got any other protocol. + * If they Nak the reporting period, take their value XXX ? + */ + NAKCILQR(CI_QUALITY, neg_lqr, + if (cishort != PPP_LQR) { + try.neg_lqr = 0; + } else { + try.lqr_period = cilong; + } + ); + + /* + * Only implementing CBCP...not the rest of the callback options + */ + NAKCICHAR(CI_CALLBACK, neg_cbcp, + try.neg_cbcp = 0; + ); + + /* + * Check for a looped-back line. + */ + NAKCILONG(CI_MAGICNUMBER, neg_magicnumber, + try.magicnumber = magic(); + looped_back = 1; + ); + + /* + * Peer shouldn't send Nak for protocol compression or + * address/control compression requests; they should send + * a Reject instead. If they send a Nak, treat it as a Reject. + */ + NAKCIVOID(CI_PCOMPRESSION, neg_pcompression, + try.neg_pcompression = 0; + ); + NAKCIVOID(CI_ACCOMPRESSION, neg_accompression, + try.neg_accompression = 0; + ); + + /* + * There may be remaining CIs, if the peer is requesting negotiation + * on an option that we didn't include in our request packet. + * If we see an option that we requested, or one we've already seen + * in this packet, then this packet is bad. + * If we wanted to respond by starting to negotiate on the requested + * option(s), we could, but we don't, because except for the + * authentication type and quality protocol, if we are not negotiating + * an option, it is because we were told not to. + * For the authentication type, the Nak from the peer means + * `let me authenticate myself with you' which is a bit pointless. + * For the quality protocol, the Nak means `ask me to send you quality + * reports', but if we didn't ask for them, we don't want them. + * An option we don't recognize represents the peer asking to + * negotiate some option we don't support, so ignore it. + */ + while (len > CILEN_VOID) { + GETCHAR(citype, p); + GETCHAR(cilen, p); + if (cilen < CILEN_VOID || (len -= cilen) < 0) { + goto bad; + } + next = p + cilen - 2; + + switch (citype) { + case CI_MRU: + if ((go->neg_mru && go->mru != PPP_DEFMRU) + || no.neg_mru || cilen != CILEN_SHORT) { + goto bad; + } + GETSHORT(cishort, p); + if (cishort < PPP_DEFMRU) { + try.mru = cishort; + } + break; + case CI_ASYNCMAP: + if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) + || no.neg_asyncmap || cilen != CILEN_LONG) { + goto bad; + } + break; + case CI_AUTHTYPE: + if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap) { + goto bad; + } + break; + case CI_MAGICNUMBER: + if (go->neg_magicnumber || no.neg_magicnumber || + cilen != CILEN_LONG) { + goto bad; + } + break; + case CI_PCOMPRESSION: + if (go->neg_pcompression || no.neg_pcompression + || cilen != CILEN_VOID) { + goto bad; + } + break; + case CI_ACCOMPRESSION: + if (go->neg_accompression || no.neg_accompression + || cilen != CILEN_VOID) { + goto bad; + } + break; + case CI_QUALITY: + if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) { + goto bad; + } + break; + } + p = next; + } + + /* If there is still anything left, this packet is bad. */ + if (len != 0) { + goto bad; + } + + /* + * OK, the Nak is good. Now we can update state. + */ + if (f->state != LS_OPENED) { + if (looped_back) { + if (++try.numloops >= lcp_loopbackfail) { + LCPDEBUG(LOG_NOTICE, ("Serial line is looped back.\n")); + lcp_close(f->unit, "Loopback detected"); + } + } else { + try.numloops = 0; + } + *go = try; + } + + return 1; + +bad: + LCPDEBUG(LOG_WARNING, ("lcp_nakci: received bad Nak!\n")); + return 0; +} + + +/* + * lcp_rejci - Peer has Rejected some of our CIs. + * This should not modify any state if the Reject is bad + * or if LCP is in the LS_OPENED state. + * + * Returns: + * 0 - Reject was bad. + * 1 - Reject was good. + */ +static int +lcp_rejci(fsm *f, u_char *p, int len) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + u_char cichar; + u_short cishort; + u32_t cilong; + lcp_options try; /* options to request next time */ + + try = *go; + + /* + * Any Rejected CIs must be in exactly the same order that we sent. + * Check packet length and CI length at each step. + * If we find any deviations, then this packet is bad. + */ +#define REJCIVOID(opt, neg) \ + if (go->neg && \ + len >= CILEN_VOID && \ + p[1] == CILEN_VOID && \ + p[0] == opt) { \ + len -= CILEN_VOID; \ + INCPTR(CILEN_VOID, p); \ + try.neg = 0; \ + LCPDEBUG(LOG_INFO, ("lcp_rejci: void opt %d rejected\n", opt)); \ + } +#define REJCISHORT(opt, neg, val) \ + if (go->neg && \ + len >= CILEN_SHORT && \ + p[1] == CILEN_SHORT && \ + p[0] == opt) { \ + len -= CILEN_SHORT; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) { \ + goto bad; \ + } \ + try.neg = 0; \ + LCPDEBUG(LOG_INFO, ("lcp_rejci: short opt %d rejected\n", opt)); \ + } +#define REJCICHAP(opt, neg, val, digest) \ + if (go->neg && \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if (cishort != val || cichar != digest) { \ + goto bad; \ + } \ + try.neg = 0; \ + try.neg_upap = 0; \ + LCPDEBUG(LOG_INFO, ("lcp_rejci: chap opt %d rejected\n", opt)); \ + } +#define REJCILONG(opt, neg, val) \ + if (go->neg && \ + len >= CILEN_LONG && \ + p[1] == CILEN_LONG && \ + p[0] == opt) { \ + len -= CILEN_LONG; \ + INCPTR(2, p); \ + GETLONG(cilong, p); \ + /* Check rejected value. */ \ + if (cilong != val) { \ + goto bad; \ + } \ + try.neg = 0; \ + LCPDEBUG(LOG_INFO, ("lcp_rejci: long opt %d rejected\n", opt)); \ + } +#define REJCILQR(opt, neg, val) \ + if (go->neg && \ + len >= CILEN_LQR && \ + p[1] == CILEN_LQR && \ + p[0] == opt) { \ + len -= CILEN_LQR; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETLONG(cilong, p); \ + /* Check rejected value. */ \ + if (cishort != PPP_LQR || cilong != val) { \ + goto bad; \ + } \ + try.neg = 0; \ + LCPDEBUG(LOG_INFO, ("lcp_rejci: LQR opt %d rejected\n", opt)); \ + } +#define REJCICBCP(opt, neg, val) \ + if (go->neg && \ + len >= CILEN_CBCP && \ + p[1] == CILEN_CBCP && \ + p[0] == opt) { \ + len -= CILEN_CBCP; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if (cichar != val) { \ + goto bad; \ + } \ + try.neg = 0; \ + LCPDEBUG(LOG_INFO, ("lcp_rejci: Callback opt %d rejected\n", opt)); \ + } + + REJCISHORT(CI_MRU, neg_mru, go->mru); + REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap); + REJCICHAP(CI_AUTHTYPE, neg_chap, PPP_CHAP, go->chap_mdtype); + if (!go->neg_chap) { + REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); + } + REJCILQR(CI_QUALITY, neg_lqr, go->lqr_period); + REJCICBCP(CI_CALLBACK, neg_cbcp, CBCP_OPT); + REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber); + REJCIVOID(CI_PCOMPRESSION, neg_pcompression); + REJCIVOID(CI_ACCOMPRESSION, neg_accompression); + + /* + * If there are any remaining CIs, then this packet is bad. + */ + if (len != 0) { + goto bad; + } + /* + * Now we can update state. + */ + if (f->state != LS_OPENED) { + *go = try; + } + return 1; + +bad: + LCPDEBUG(LOG_WARNING, ("lcp_rejci: received bad Reject!\n")); + return 0; +} + + +/* + * lcp_reqci - Check the peer's requested CIs and send appropriate response. + * + * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified + * appropriately. If reject_if_disagree is non-zero, doesn't return + * CONFNAK; returns CONFREJ if it can't return CONFACK. + */ +static int +lcp_reqci(fsm *f, + u_char *inp, /* Requested CIs */ + int *lenp, /* Length of requested CIs */ + int reject_if_disagree) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + lcp_options *ho = &lcp_hisoptions[f->unit]; + lcp_options *ao = &lcp_allowoptions[f->unit]; + u_char *cip, *next; /* Pointer to current and next CIs */ + int cilen, citype; /* Parsed len, type */ + u_char cichar; /* Parsed char value */ + u_short cishort; /* Parsed short value */ + u32_t cilong; /* Parse long value */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *rejp; /* Pointer to next char in reject frame */ + u_char *nakp; /* Pointer to next char in Nak frame */ + int l = *lenp; /* Length left */ +#if TRACELCP > 0 + char traceBuf[80]; + size_t traceNdx = 0; +#endif + + /* + * Reset all his options. + */ + BZERO(ho, sizeof(*ho)); + + /* + * Process all his options. + */ + next = inp; + nakp = nak_buffer; + rejp = inp; + while (l) { + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + LCPDEBUG(LOG_WARNING, ("lcp_reqci: bad CI length!\n")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + citype = 0; + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_MRU: + if (!ao->neg_mru) { /* Allow option? */ + LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject MRU - not allowed\n")); + orc = CONFREJ; /* Reject CI */ + break; + } else if (cilen != CILEN_SHORT) { /* Check CI length */ + LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject MRU - bad length\n")); + orc = CONFREJ; /* Reject CI */ + break; + } + GETSHORT(cishort, p); /* Parse MRU */ + + /* + * He must be able to receive at least our minimum. + * No need to check a maximum. If he sends a large number, + * we'll just ignore it. + */ + if (cishort < PPP_MINMRU) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak - MRU too small\n")); + orc = CONFNAK; /* Nak CI */ + PUTCHAR(CI_MRU, nakp); + PUTCHAR(CILEN_SHORT, nakp); + PUTSHORT(PPP_MINMRU, nakp); /* Give him a hint */ + break; + } + ho->neg_mru = 1; /* Remember he sent MRU */ + ho->mru = cishort; /* And remember value */ +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " MRU %d", cishort); + traceNdx = strlen(traceBuf); +#endif + break; + + case CI_ASYNCMAP: + if (!ao->neg_asyncmap) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject ASYNCMAP not allowed\n")); + orc = CONFREJ; + break; + } else if (cilen != CILEN_LONG) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject ASYNCMAP bad length\n")); + orc = CONFREJ; + break; + } + GETLONG(cilong, p); + + /* + * Asyncmap must have set at least the bits + * which are set in lcp_allowoptions[unit].asyncmap. + */ + if ((ao->asyncmap & ~cilong) != 0) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak ASYNCMAP %lX missing %lX\n", + cilong, ao->asyncmap)); + orc = CONFNAK; + PUTCHAR(CI_ASYNCMAP, nakp); + PUTCHAR(CILEN_LONG, nakp); + PUTLONG(ao->asyncmap | cilong, nakp); + break; + } + ho->neg_asyncmap = 1; + ho->asyncmap = cilong; +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ASYNCMAP=%lX", cilong); + traceNdx = strlen(traceBuf); +#endif + break; + + case CI_AUTHTYPE: + if (cilen < CILEN_SHORT) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject AUTHTYPE missing arg\n")); + orc = CONFREJ; + break; + } else if (!(ao->neg_upap || ao->neg_chap)) { + /* + * Reject the option if we're not willing to authenticate. + */ + LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject AUTHTYPE not allowed\n")); + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + + /* + * Authtype must be UPAP or CHAP. + * + * Note: if both ao->neg_upap and ao->neg_chap are set, + * and the peer sends a Configure-Request with two + * authenticate-protocol requests, one for CHAP and one + * for UPAP, then we will reject the second request. + * Whether we end up doing CHAP or UPAP depends then on + * the ordering of the CIs in the peer's Configure-Request. + */ + + if (cishort == PPP_PAP) { + if (ho->neg_chap) { /* we've already accepted CHAP */ + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP already accepted\n")); + orc = CONFREJ; + break; + } else if (cilen != CILEN_SHORT) { + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP bad len\n")); + orc = CONFREJ; + break; + } + if (!ao->neg_upap) { /* we don't want to do PAP */ + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE PAP not allowed\n")); + orc = CONFNAK; /* NAK it and suggest CHAP */ + PUTCHAR(CI_AUTHTYPE, nakp); + PUTCHAR(CILEN_CHAP, nakp); + PUTSHORT(PPP_CHAP, nakp); + PUTCHAR(ao->chap_mdtype, nakp); + break; + } + ho->neg_upap = 1; +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PAP (%X)", cishort); + traceNdx = strlen(traceBuf); +#endif + break; + } + if (cishort == PPP_CHAP) { + if (ho->neg_upap) { /* we've already accepted PAP */ + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE CHAP accepted PAP\n")); + orc = CONFREJ; + break; + } else if (cilen != CILEN_CHAP) { + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE CHAP bad len\n")); + orc = CONFREJ; + break; + } + if (!ao->neg_chap) { /* we don't want to do CHAP */ + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE CHAP not allowed\n")); + orc = CONFNAK; /* NAK it and suggest PAP */ + PUTCHAR(CI_AUTHTYPE, nakp); + PUTCHAR(CILEN_SHORT, nakp); + PUTSHORT(PPP_PAP, nakp); + break; + } + GETCHAR(cichar, p); /* get digest type*/ + if (cichar != CHAP_DIGEST_MD5 +#if MSCHAP_SUPPORT + && cichar != CHAP_MICROSOFT +#endif + ) { + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE CHAP digest=%d\n", (int)cichar)); + orc = CONFNAK; + PUTCHAR(CI_AUTHTYPE, nakp); + PUTCHAR(CILEN_CHAP, nakp); + PUTSHORT(PPP_CHAP, nakp); + PUTCHAR(ao->chap_mdtype, nakp); + break; + } +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CHAP %X,%d", cishort, (int)cichar); + traceNdx = strlen(traceBuf); +#endif + ho->chap_mdtype = cichar; /* save md type */ + ho->neg_chap = 1; + break; + } + + /* + * We don't recognize the protocol they're asking for. + * Nak it with something we're willing to do. + * (At this point we know ao->neg_upap || ao->neg_chap.) + */ + orc = CONFNAK; + PUTCHAR(CI_AUTHTYPE, nakp); + if (ao->neg_chap) { + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE %d req CHAP\n", cishort)); + PUTCHAR(CILEN_CHAP, nakp); + PUTSHORT(PPP_CHAP, nakp); + PUTCHAR(ao->chap_mdtype, nakp); + } else { + LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE %d req PAP\n", cishort)); + PUTCHAR(CILEN_SHORT, nakp); + PUTSHORT(PPP_PAP, nakp); + } + break; + + case CI_QUALITY: + GETSHORT(cishort, p); + GETLONG(cilong, p); +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " QUALITY (%x %x)", cishort, (unsigned int) cilong); + traceNdx = strlen(traceBuf); +#endif + + if (!ao->neg_lqr || + cilen != CILEN_LQR) { + orc = CONFREJ; + break; + } + + /* + * Check the protocol and the reporting period. + * XXX When should we Nak this, and what with? + */ + if (cishort != PPP_LQR) { + orc = CONFNAK; + PUTCHAR(CI_QUALITY, nakp); + PUTCHAR(CILEN_LQR, nakp); + PUTSHORT(PPP_LQR, nakp); + PUTLONG(ao->lqr_period, nakp); + break; + } + break; + + case CI_MAGICNUMBER: + if (!(ao->neg_magicnumber || go->neg_magicnumber) || + cilen != CILEN_LONG) { + orc = CONFREJ; + break; + } + GETLONG(cilong, p); +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " MAGICNUMBER (%lX)", cilong); + traceNdx = strlen(traceBuf); +#endif + + /* + * He must have a different magic number. + */ + if (go->neg_magicnumber && + cilong == go->magicnumber) { + cilong = magic(); /* Don't put magic() inside macro! */ + orc = CONFNAK; + PUTCHAR(CI_MAGICNUMBER, nakp); + PUTCHAR(CILEN_LONG, nakp); + PUTLONG(cilong, nakp); + break; + } + ho->neg_magicnumber = 1; + ho->magicnumber = cilong; + break; + + + case CI_PCOMPRESSION: +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PCOMPRESSION"); + traceNdx = strlen(traceBuf); +#endif + if (!ao->neg_pcompression || + cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_pcompression = 1; + break; + + case CI_ACCOMPRESSION: +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ACCOMPRESSION"); + traceNdx = strlen(traceBuf); +#endif + if (!ao->neg_accompression || + cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_accompression = 1; + break; + + case CI_MRRU: +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_MRRU"); + traceNdx = strlen(traceBuf); +#endif + orc = CONFREJ; + break; + + case CI_SSNHF: +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_SSNHF"); + traceNdx = strlen(traceBuf); +#endif + orc = CONFREJ; + break; + + case CI_EPDISC: +#if TRACELCP > 0 + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_EPDISC"); + traceNdx = strlen(traceBuf); +#endif + orc = CONFREJ; + break; + + default: +#if TRACELCP + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " unknown %d", citype); + traceNdx = strlen(traceBuf); +#endif + orc = CONFREJ; + break; + } + + endswitch: +#if TRACELCP + if (traceNdx >= 80 - 32) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: rcvd%s\n", traceBuf)); + traceNdx = 0; + } +#endif + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) { /* but prior CI wasnt? */ + continue; /* Don't send this one */ + } + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree /* Getting fed up with sending NAKs? */ + && citype != CI_MAGICNUMBER) { + orc = CONFREJ; /* Get tough if so */ + } else { + if (rc == CONFREJ) { /* Rejecting prior CI? */ + continue; /* Don't send this one */ + } + rc = CONFNAK; + } + } + if (orc == CONFREJ) { /* Reject this CI */ + rc = CONFREJ; + if (cip != rejp) { /* Need to move rejected CI? */ + BCOPY(cip, rejp, cilen); /* Move it */ + } + INCPTR(cilen, rejp); /* Update output pointer */ + } + } + + /* + * If we wanted to send additional NAKs (for unsent CIs), the + * code would go here. The extra NAKs would go at *nakp. + * At present there are no cases where we want to ask the + * peer to negotiate an option. + */ + + switch (rc) { + case CONFACK: + *lenp = (int)(next - inp); + break; + case CONFNAK: + /* + * Copy the Nak'd options from the nak_buffer to the caller's buffer. + */ + *lenp = (int)(nakp - nak_buffer); + BCOPY(nak_buffer, inp, *lenp); + break; + case CONFREJ: + *lenp = (int)(rejp - inp); + break; + } + +#if TRACELCP > 0 + if (traceNdx > 0) { + LCPDEBUG(LOG_INFO, ("lcp_reqci: %s\n", traceBuf)); + } +#endif + LCPDEBUG(LOG_INFO, ("lcp_reqci: returning CONF%s.\n", CODENAME(rc))); + return (rc); /* Return final code */ +} + + +/* + * lcp_up - LCP has come UP. + */ +static void +lcp_up(fsm *f) +{ + lcp_options *wo = &lcp_wantoptions[f->unit]; + lcp_options *ho = &lcp_hisoptions[f->unit]; + lcp_options *go = &lcp_gotoptions[f->unit]; + lcp_options *ao = &lcp_allowoptions[f->unit]; + + if (!go->neg_magicnumber) { + go->magicnumber = 0; + } + if (!ho->neg_magicnumber) { + ho->magicnumber = 0; + } + + /* + * Set our MTU to the smaller of the MTU we wanted and + * the MRU our peer wanted. If we negotiated an MRU, + * set our MRU to the larger of value we wanted and + * the value we got in the negotiation. + */ + ppp_send_config(f->unit, LWIP_MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)), + (ho->neg_asyncmap? ho->asyncmap: 0xffffffffl), + ho->neg_pcompression, ho->neg_accompression); + /* + * If the asyncmap hasn't been negotiated, we really should + * set the receive asyncmap to ffffffff, but we set it to 0 + * for backwards contemptibility. + */ + ppp_recv_config(f->unit, (go->neg_mru? LWIP_MAX(wo->mru, go->mru): PPP_MRU), + (go->neg_asyncmap? go->asyncmap: 0x00000000), + go->neg_pcompression, go->neg_accompression); + + if (ho->neg_mru) { + peer_mru[f->unit] = ho->mru; + } + + lcp_echo_lowerup(f->unit); /* Enable echo messages */ + + link_established(f->unit); /* The link is up; authenticate now */ +} + + +/* + * lcp_down - LCP has gone DOWN. + * + * Alert other protocols. + */ +static void +lcp_down(fsm *f) +{ + lcp_options *go = &lcp_gotoptions[f->unit]; + + lcp_echo_lowerdown(f->unit); + + link_down(f->unit); + + ppp_send_config(f->unit, PPP_MRU, 0xffffffffl, 0, 0); + ppp_recv_config(f->unit, PPP_MRU, + (go->neg_asyncmap? go->asyncmap: 0x00000000), + go->neg_pcompression, go->neg_accompression); + peer_mru[f->unit] = PPP_MRU; +} + + +/* + * lcp_starting - LCP needs the lower layer up. + */ +static void +lcp_starting(fsm *f) +{ + link_required(f->unit); /* lwip: currently does nothing */ +} + + +/* + * lcp_finished - LCP has finished with the lower layer. + */ +static void +lcp_finished(fsm *f) +{ + link_terminated(f->unit); /* we are finished with the link */ +} + + +#if PPP_ADDITIONAL_CALLBACKS +/* + * print_string - print a readable representation of a string using + * printer. + */ +static void +print_string( char *p, int len, void (*printer) (void *, char *, ...), void *arg) +{ + int c; + + printer(arg, "\""); + for (; len > 0; --len) { + c = *p++; + if (' ' <= c && c <= '~') { + if (c == '\\' || c == '"') { + printer(arg, "\\"); + } + printer(arg, "%c", c); + } else { + switch (c) { + case '\n': + printer(arg, "\\n"); + break; + case '\r': + printer(arg, "\\r"); + break; + case '\t': + printer(arg, "\\t"); + break; + default: + printer(arg, "\\%.3o", c); + } + } + } + printer(arg, "\""); +} + + +/* + * lcp_printpkt - print the contents of an LCP packet. + */ +static char *lcp_codenames[] = { + "ConfReq", "ConfAck", "ConfNak", "ConfRej", + "TermReq", "TermAck", "CodeRej", "ProtRej", + "EchoReq", "EchoRep", "DiscReq" +}; + +static int +lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) +{ + int code, id, len, olen; + u_char *pstart, *optend; + u_short cishort; + u32_t cilong; + + if (plen < HEADERLEN) { + return 0; + } + pstart = p; + GETCHAR(code, p); + GETCHAR(id, p); + GETSHORT(len, p); + if (len < HEADERLEN || len > plen) { + return 0; + } + + if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *)) { + printer(arg, " %s", lcp_codenames[code-1]); + } else { + printer(arg, " code=0x%x", code); + } + printer(arg, " id=0x%x", id); + len -= HEADERLEN; + switch (code) { + case CONFREQ: + case CONFACK: + case CONFNAK: + case CONFREJ: + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { + case CI_MRU: + if (olen == CILEN_SHORT) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "mru %d", cishort); + } + break; + case CI_ASYNCMAP: + if (olen == CILEN_LONG) { + p += 2; + GETLONG(cilong, p); + printer(arg, "asyncmap 0x%lx", cilong); + } + break; + case CI_AUTHTYPE: + if (olen >= CILEN_SHORT) { + p += 2; + printer(arg, "auth "); + GETSHORT(cishort, p); + switch (cishort) { + case PPP_PAP: + printer(arg, "pap"); + break; + case PPP_CHAP: + printer(arg, "chap"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; + case CI_QUALITY: + if (olen >= CILEN_SHORT) { + p += 2; + printer(arg, "quality "); + GETSHORT(cishort, p); + switch (cishort) { + case PPP_LQR: + printer(arg, "lqr"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; + case CI_CALLBACK: + if (olen >= CILEN_CHAR) { + p += 2; + printer(arg, "callback "); + GETSHORT(cishort, p); + switch (cishort) { + case CBCP_OPT: + printer(arg, "CBCP"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; + case CI_MAGICNUMBER: + if (olen == CILEN_LONG) { + p += 2; + GETLONG(cilong, p); + printer(arg, "magic 0x%x", cilong); + } + break; + case CI_PCOMPRESSION: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "pcomp"); + } + break; + case CI_ACCOMPRESSION: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "accomp"); + } + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; + + case TERMACK: + case TERMREQ: + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + print_string((char*)p, len, printer, arg); + p += len; + len = 0; + } + break; + + case ECHOREQ: + case ECHOREP: + case DISCREQ: + if (len >= 4) { + GETLONG(cilong, p); + printer(arg, " magic=0x%x", cilong); + p += 4; + len -= 4; + } + break; + } + + /* print the rest of the bytes in the packet */ + for (; len > 0; --len) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + + return (int)(p - pstart); +} +#endif /* PPP_ADDITIONAL_CALLBACKS */ + +/* + * Time to shut down the link because there is nothing out there. + */ +static void +LcpLinkFailure (fsm *f) +{ + if (f->state == LS_OPENED) { + LCPDEBUG(LOG_INFO, ("No response to %d echo-requests\n", lcp_echos_pending)); + LCPDEBUG(LOG_NOTICE, ("Serial link appears to be disconnected.\n")); + lcp_close(f->unit, "Peer not responding"); + } +} + +/* + * Timer expired for the LCP echo requests from this process. + */ +static void +LcpEchoCheck (fsm *f) +{ + LcpSendEchoRequest (f); + + /* + * Start the timer for the next interval. + */ + LWIP_ASSERT("lcp_echo_timer_running == 0", lcp_echo_timer_running == 0); + + TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval); + lcp_echo_timer_running = 1; +} + +/* + * LcpEchoTimeout - Timer expired on the LCP echo + */ +static void +LcpEchoTimeout (void *arg) +{ + if (lcp_echo_timer_running != 0) { + lcp_echo_timer_running = 0; + LcpEchoCheck ((fsm *) arg); + } +} + +/* + * LcpEchoReply - LCP has received a reply to the echo + */ +static void +lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len) +{ + u32_t magic; + + LWIP_UNUSED_ARG(id); + + /* Check the magic number - don't count replies from ourselves. */ + if (len < 4) { + LCPDEBUG(LOG_WARNING, ("lcp: received short Echo-Reply, length %d\n", len)); + return; + } + GETLONG(magic, inp); + if (lcp_gotoptions[f->unit].neg_magicnumber && magic == lcp_gotoptions[f->unit].magicnumber) { + LCPDEBUG(LOG_WARNING, ("appear to have received our own echo-reply!\n")); + return; + } + + /* Reset the number of outstanding echo frames */ + lcp_echos_pending = 0; +} + +/* + * LcpSendEchoRequest - Send an echo request frame to the peer + */ +static void +LcpSendEchoRequest (fsm *f) +{ + u32_t lcp_magic; + u_char pkt[4], *pktp; + + /* + * Detect the failure of the peer at this point. + */ + if (lcp_echo_fails != 0) { + if (lcp_echos_pending >= lcp_echo_fails) { + LcpLinkFailure(f); + lcp_echos_pending = 0; + } + } + + /* + * Make and send the echo request frame. + */ + if (f->state == LS_OPENED) { + lcp_magic = lcp_gotoptions[f->unit].magicnumber; + pktp = pkt; + PUTLONG(lcp_magic, pktp); + fsm_sdata(f, ECHOREQ, (u_char)(lcp_echo_number++ & 0xFF), pkt, (int)(pktp - pkt)); + ++lcp_echos_pending; + } +} + +/* + * lcp_echo_lowerup - Start the timer for the LCP frame + */ + +static void +lcp_echo_lowerup (int unit) +{ + fsm *f = &lcp_fsm[unit]; + + /* Clear the parameters for generating echo frames */ + lcp_echos_pending = 0; + lcp_echo_number = 0; + lcp_echo_timer_running = 0; + + /* If a timeout interval is specified then start the timer */ + if (lcp_echo_interval != 0) { + LcpEchoCheck (f); + } +} + +/* + * lcp_echo_lowerdown - Stop the timer for the LCP frame + */ + +static void +lcp_echo_lowerdown (int unit) +{ + fsm *f = &lcp_fsm[unit]; + + if (lcp_echo_timer_running != 0) { + UNTIMEOUT (LcpEchoTimeout, f); + lcp_echo_timer_running = 0; + } +} + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/lcp.h b/user/mpy/lib/lwip/src/netif/ppp/lcp.h new file mode 100644 index 0000000..b9201ee --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/lcp.h @@ -0,0 +1,151 @@ +/***************************************************************************** +* lcp.h - Network Link Control Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-11-05 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ +/* + * lcp.h - Link Control Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: lcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $ + */ + +#ifndef LCP_H +#define LCP_H +/* + * Options. + */ +#define CI_MRU 1 /* Maximum Receive Unit */ +#define CI_ASYNCMAP 2 /* Async Control Character Map */ +#define CI_AUTHTYPE 3 /* Authentication Type */ +#define CI_QUALITY 4 /* Quality Protocol */ +#define CI_MAGICNUMBER 5 /* Magic Number */ +#define CI_PCOMPRESSION 7 /* Protocol Field Compression */ +#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */ +#define CI_CALLBACK 13 /* callback */ +#define CI_MRRU 17 /* max reconstructed receive unit; multilink */ +#define CI_SSNHF 18 /* short sequence numbers for multilink */ +#define CI_EPDISC 19 /* endpoint discriminator */ + +/* + * LCP-specific packet types (code numbers). + */ +#define PROTREJ 8 /* Protocol Reject */ +#define ECHOREQ 9 /* Echo Request */ +#define ECHOREP 10 /* Echo Reply */ +#define DISCREQ 11 /* Discard Request */ +#define CBCP_OPT 6 /* Use callback control protocol */ + +/* + * The state of options is described by an lcp_options structure. + */ +typedef struct lcp_options { + u_int passive : 1; /* Don't die if we don't get a response */ + u_int silent : 1; /* Wait for the other end to start first */ + u_int restart : 1; /* Restart vs. exit after close */ + u_int neg_mru : 1; /* Negotiate the MRU? */ + u_int neg_asyncmap : 1; /* Negotiate the async map? */ + u_int neg_upap : 1; /* Ask for UPAP authentication? */ + u_int neg_chap : 1; /* Ask for CHAP authentication? */ + u_int neg_magicnumber : 1; /* Ask for magic number? */ + u_int neg_pcompression : 1; /* HDLC Protocol Field Compression? */ + u_int neg_accompression : 1; /* HDLC Address/Control Field Compression? */ + u_int neg_lqr : 1; /* Negotiate use of Link Quality Reports */ + u_int neg_cbcp : 1; /* Negotiate use of CBCP */ +#ifdef PPP_MULTILINK + u_int neg_mrru : 1; /* Negotiate multilink MRRU */ + u_int neg_ssnhf : 1; /* Negotiate short sequence numbers */ + u_int neg_endpoint : 1; /* Negotiate endpoint discriminator */ +#endif + u_short mru; /* Value of MRU */ +#ifdef PPP_MULTILINK + u_short mrru; /* Value of MRRU, and multilink enable */ +#endif + u_char chap_mdtype; /* which MD type (hashing algorithm) */ + u32_t asyncmap; /* Value of async map */ + u32_t magicnumber; + int numloops; /* Number of loops during magic number neg. */ + u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ +#ifdef PPP_MULTILINK + struct epdisc endpoint; /* endpoint discriminator */ +#endif +} lcp_options; + +/* + * Values for phase from BSD pppd.h based on RFC 1661. + */ +typedef enum { + PHASE_DEAD = 0, + PHASE_INITIALIZE, + PHASE_ESTABLISH, + PHASE_AUTHENTICATE, + PHASE_CALLBACK, + PHASE_NETWORK, + PHASE_TERMINATE +} LinkPhase; + + + +extern LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */ +extern lcp_options lcp_wantoptions[]; +extern lcp_options lcp_gotoptions[]; +extern lcp_options lcp_allowoptions[]; +extern lcp_options lcp_hisoptions[]; +extern ext_accm xmit_accm[]; + + +void lcp_init (int); +void lcp_open (int); +void lcp_close (int, char *); +void lcp_lowerup (int); +void lcp_lowerdown(int); +void lcp_sprotrej (int, u_char *, int); /* send protocol reject */ + +extern struct protent lcp_protent; + +/* Default number of times we receive our magic number from the peer + before deciding the link is looped-back. */ +#define DEFLOOPBACKFAIL 10 + +#endif /* LCP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/magic.c b/user/mpy/lib/lwip/src/netif/ppp/magic.c new file mode 100644 index 0000000..3732a42 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/magic.c @@ -0,0 +1,80 @@ +/***************************************************************************** +* magic.c - Network Random Number Generator program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-04 Guy Lancaster , Global Election Systems Inc. +* Original based on BSD magic.c. +*****************************************************************************/ +/* + * magic.c - PPP Magic Number routines. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT + +#include "ppp_impl.h" +#include "randm.h" +#include "magic.h" + + +/* + * magicInit - Initialize the magic number generator. + * + * Since we use another random number generator that has its own + * initialization, we do nothing here. + */ +void magicInit() +{ + return; +} + +/* + * magic - Returns the next magic number. + */ +u32_t magic() +{ + return avRandom(); +} + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/magic.h b/user/mpy/lib/lwip/src/netif/ppp/magic.h new file mode 100644 index 0000000..eba70d2 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/magic.h @@ -0,0 +1,63 @@ +/***************************************************************************** +* magic.h - Network Random Number Generator header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-04 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ +/* + * magic.h - PPP Magic Number definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: magic.h,v 1.3 2010/01/18 20:49:43 goldsimon Exp $ + */ + +#ifndef MAGIC_H +#define MAGIC_H + +/* Initialize the magic number generator */ +void magicInit(void); + +/* Returns the next magic number */ +u32_t magic(void); + +#endif /* MAGIC_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/md5.c b/user/mpy/lib/lwip/src/netif/ppp/md5.c new file mode 100644 index 0000000..dc3cc75 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/md5.c @@ -0,0 +1,320 @@ +/* + *********************************************************************** + ** md5.c -- the source code for MD5 routines ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. ** + *********************************************************************** + */ + +/* + *********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + *********************************************************************** + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#if CHAP_SUPPORT || MD5_SUPPORT + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "md5.h" + +#include + +/* + *********************************************************************** + ** Message-digest routines: ** + ** To form the message digest for a message M ** + ** (1) Initialize a context buffer mdContext using MD5Init ** + ** (2) Call MD5Update on mdContext and M ** + ** (3) Call MD5Final on mdContext ** + ** The message digest is now in mdContext->digest[0...15] ** + *********************************************************************** + */ + +/* forward declaration */ +static void Transform (u32_t *buf, u32_t *in); + +static unsigned char PADDING[64] = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* F, G, H and I are basic MD5 functions */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ +/* Rotation is separate from addition to prevent recomputation */ +#define FF(a, b, c, d, x, s, ac) \ + {(a) += F ((b), (c), (d)) + (x) + (u32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) \ + {(a) += G ((b), (c), (d)) + (x) + (u32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) \ + {(a) += H ((b), (c), (d)) + (x) + (u32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) \ + {(a) += I ((b), (c), (d)) + (x) + (u32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +#ifdef __STDC__ +#define UL(x) x##UL +#else +#ifdef WIN32 +#define UL(x) x##UL +#else +#define UL(x) x +#endif +#endif + +/* The routine MD5Init initializes the message-digest context + mdContext. All fields are set to zero. + */ +void +MD5Init (MD5_CTX *mdContext) +{ + mdContext->i[0] = mdContext->i[1] = (u32_t)0; + + /* Load magic initialization constants. */ + mdContext->buf[0] = (u32_t)0x67452301UL; + mdContext->buf[1] = (u32_t)0xefcdab89UL; + mdContext->buf[2] = (u32_t)0x98badcfeUL; + mdContext->buf[3] = (u32_t)0x10325476UL; +} + +/* The routine MD5Update updates the message-digest context to + account for the presence of each of the characters inBuf[0..inLen-1] + in the message whose digest is being computed. + */ +void +MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) +{ + u32_t in[16]; + int mdi; + unsigned int i, ii; + +#if 0 + PPPDEBUG(LOG_INFO, ("MD5Update: %u:%.*H\n", inLen, LWIP_MIN(inLen, 20) * 2, inBuf)); + PPPDEBUG(LOG_INFO, ("MD5Update: %u:%s\n", inLen, inBuf)); +#endif + + /* compute number of bytes mod 64 */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* update number of bits */ + if ((mdContext->i[0] + ((u32_t)inLen << 3)) < mdContext->i[0]) { + mdContext->i[1]++; + } + mdContext->i[0] += ((u32_t)inLen << 3); + mdContext->i[1] += ((u32_t)inLen >> 29); + + while (inLen--) { + /* add new character to buffer, increment mdi */ + mdContext->in[mdi++] = *inBuf++; + + /* transform if necessary */ + if (mdi == 0x40) { + for (i = 0, ii = 0; i < 16; i++, ii += 4) { + in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | + (((u32_t)mdContext->in[ii+2]) << 16) | + (((u32_t)mdContext->in[ii+1]) << 8) | + ((u32_t)mdContext->in[ii]); + } + Transform (mdContext->buf, in); + mdi = 0; + } + } +} + +/* The routine MD5Final terminates the message-digest computation and + ends with the desired message digest in mdContext->digest[0...15]. + */ +void +MD5Final (unsigned char hash[], MD5_CTX *mdContext) +{ + u32_t in[16]; + int mdi; + unsigned int i, ii; + unsigned int padLen; + + /* save number of bits */ + in[14] = mdContext->i[0]; + in[15] = mdContext->i[1]; + + /* compute number of bytes mod 64 */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* pad out to 56 mod 64 */ + padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); + MD5Update (mdContext, PADDING, padLen); + + /* append length in bits and transform */ + for (i = 0, ii = 0; i < 14; i++, ii += 4) { + in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | + (((u32_t)mdContext->in[ii+2]) << 16) | + (((u32_t)mdContext->in[ii+1]) << 8) | + ((u32_t)mdContext->in[ii]); + } + Transform (mdContext->buf, in); + + /* store buffer in digest */ + for (i = 0, ii = 0; i < 4; i++, ii += 4) { + mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); + mdContext->digest[ii+1] = + (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); + mdContext->digest[ii+2] = + (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); + mdContext->digest[ii+3] = + (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); + } + SMEMCPY(hash, mdContext->digest, 16); +} + +/* Basic MD5 step. Transforms buf based on in. + */ +static void +Transform (u32_t *buf, u32_t *in) +{ + u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3]; + + /* Round 1 */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 + FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */ + FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */ + FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */ + FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */ + FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */ + FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */ + FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */ + FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */ + FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */ + FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */ + FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */ + FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */ + FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */ + FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */ + FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */ + FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */ + + /* Round 2 */ +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 + GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */ + GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */ + GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */ + GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */ + GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */ + GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */ + GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */ + GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */ + GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */ + GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */ + GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */ + GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */ + GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */ + GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */ + GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */ + GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */ + + /* Round 3 */ +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 + HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */ + HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */ + HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */ + HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */ + HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */ + HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */ + HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */ + HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */ + HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */ + HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */ + HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */ + HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */ + HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */ + HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */ + HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */ + HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */ + + /* Round 4 */ +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */ + II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */ + II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */ + II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */ + II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */ + II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */ + II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */ + II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */ + II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */ + II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */ + II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */ + II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */ + II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */ + II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */ + II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */ + II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */ + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +#endif /* CHAP_SUPPORT || MD5_SUPPORT */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/md5.h b/user/mpy/lib/lwip/src/netif/ppp/md5.h new file mode 100644 index 0000000..e129533 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/md5.h @@ -0,0 +1,55 @@ +/* + *********************************************************************** + ** md5.h -- header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** + */ + +/* + *********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + *********************************************************************** + */ + +#ifndef MD5_H +#define MD5_H + +/* Data structure for MD5 (Message-Digest) computation */ +typedef struct { + u32_t i[2]; /* number of _bits_ handled mod 2^64 */ + u32_t buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after MD5Final call */ +} MD5_CTX; + +void MD5Init ( MD5_CTX *mdContext); +void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); +void MD5Final ( unsigned char hash[], MD5_CTX *mdContext); + +#endif /* MD5_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/pap.c b/user/mpy/lib/lwip/src/netif/ppp/pap.c new file mode 100644 index 0000000..5fb9f88 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/pap.c @@ -0,0 +1,628 @@ +/***************************************************************************** +* pap.c - Network Password Authentication Protocol program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-12 Guy Lancaster , Global Election Systems Inc. +* Original. +*****************************************************************************/ +/* + * upap.c - User/Password Authentication Protocol. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "auth.h" +#include "pap.h" + +#include + +#if 0 /* UNUSED */ +static bool hide_password = 1; + +/* + * Command-line options. + */ +static option_t pap_option_list[] = { + { "hide-password", o_bool, &hide_password, + "Don't output passwords to log", 1 }, + { "show-password", o_bool, &hide_password, + "Show password string in debug log messages", 0 }, + { "pap-restart", o_int, &upap[0].us_timeouttime, + "Set retransmit timeout for PAP" }, + { "pap-max-authreq", o_int, &upap[0].us_maxtransmits, + "Set max number of transmissions for auth-reqs" }, + { "pap-timeout", o_int, &upap[0].us_reqtimeout, + "Set time limit for peer PAP authentication" }, + { NULL } +}; +#endif + +/* + * Protocol entry points. + */ +static void upap_init (int); +static void upap_lowerup (int); +static void upap_lowerdown (int); +static void upap_input (int, u_char *, int); +static void upap_protrej (int); +#if PPP_ADDITIONAL_CALLBACKS +static int upap_printpkt (u_char *, int, void (*)(void *, char *, ...), void *); +#endif /* PPP_ADDITIONAL_CALLBACKS */ + +struct protent pap_protent = { + PPP_PAP, + upap_init, + upap_input, + upap_protrej, + upap_lowerup, + upap_lowerdown, + NULL, + NULL, +#if PPP_ADDITIONAL_CALLBACKS + upap_printpkt, + NULL, +#endif /* PPP_ADDITIONAL_CALLBACKS */ + 1, + "PAP", +#if PPP_ADDITIONAL_CALLBACKS + NULL, + NULL, + NULL +#endif /* PPP_ADDITIONAL_CALLBACKS */ +}; + +upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */ + +static void upap_timeout (void *); +static void upap_reqtimeout(void *); +static void upap_rauthreq (upap_state *, u_char *, u_char, int); +static void upap_rauthack (upap_state *, u_char *, int, int); +static void upap_rauthnak (upap_state *, u_char *, int, int); +static void upap_sauthreq (upap_state *); +static void upap_sresp (upap_state *, u_char, u_char, char *, int); + + +/* + * upap_init - Initialize a UPAP unit. + */ +static void +upap_init(int unit) +{ + upap_state *u = &upap[unit]; + + UPAPDEBUG(LOG_INFO, ("upap_init: %d\n", unit)); + u->us_unit = unit; + u->us_user = NULL; + u->us_userlen = 0; + u->us_passwd = NULL; + u->us_passwdlen = 0; + u->us_clientstate = UPAPCS_INITIAL; + u->us_serverstate = UPAPSS_INITIAL; + u->us_id = 0; + u->us_timeouttime = UPAP_DEFTIMEOUT; + u->us_maxtransmits = 10; + u->us_reqtimeout = UPAP_DEFREQTIME; +} + +/* + * upap_authwithpeer - Authenticate us with our peer (start client). + * + * Set new state and send authenticate's. + */ +void +upap_authwithpeer(int unit, char *user, char *password) +{ + upap_state *u = &upap[unit]; + + UPAPDEBUG(LOG_INFO, ("upap_authwithpeer: %d user=%s password=%s s=%d\n", + unit, user, password, u->us_clientstate)); + + /* Save the username and password we're given */ + u->us_user = user; + u->us_userlen = (int)strlen(user); + u->us_passwd = password; + u->us_passwdlen = (int)strlen(password); + + u->us_transmits = 0; + + /* Lower layer up yet? */ + if (u->us_clientstate == UPAPCS_INITIAL || + u->us_clientstate == UPAPCS_PENDING) { + u->us_clientstate = UPAPCS_PENDING; + return; + } + + upap_sauthreq(u); /* Start protocol */ +} + + +/* + * upap_authpeer - Authenticate our peer (start server). + * + * Set new state. + */ +void +upap_authpeer(int unit) +{ + upap_state *u = &upap[unit]; + + /* Lower layer up yet? */ + if (u->us_serverstate == UPAPSS_INITIAL || + u->us_serverstate == UPAPSS_PENDING) { + u->us_serverstate = UPAPSS_PENDING; + return; + } + + u->us_serverstate = UPAPSS_LISTEN; + if (u->us_reqtimeout > 0) { + TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); + } +} + +/* + * upap_timeout - Retransmission timer for sending auth-reqs expired. + */ +static void +upap_timeout(void *arg) +{ + upap_state *u = (upap_state *) arg; + + UPAPDEBUG(LOG_INFO, ("upap_timeout: %d timeout %d expired s=%d\n", + u->us_unit, u->us_timeouttime, u->us_clientstate)); + + if (u->us_clientstate != UPAPCS_AUTHREQ) { + UPAPDEBUG(LOG_INFO, ("upap_timeout: not in AUTHREQ state!\n")); + return; + } + + if (u->us_transmits >= u->us_maxtransmits) { + /* give up in disgust */ + UPAPDEBUG(LOG_ERR, ("No response to PAP authenticate-requests\n")); + u->us_clientstate = UPAPCS_BADAUTH; + auth_withpeer_fail(u->us_unit, PPP_PAP); + return; + } + + upap_sauthreq(u); /* Send Authenticate-Request and set upap timeout*/ +} + + +/* + * upap_reqtimeout - Give up waiting for the peer to send an auth-req. + */ +static void +upap_reqtimeout(void *arg) +{ + upap_state *u = (upap_state *) arg; + + if (u->us_serverstate != UPAPSS_LISTEN) { + return; /* huh?? */ + } + + auth_peer_fail(u->us_unit, PPP_PAP); + u->us_serverstate = UPAPSS_BADAUTH; +} + + +/* + * upap_lowerup - The lower layer is up. + * + * Start authenticating if pending. + */ +static void +upap_lowerup(int unit) +{ + upap_state *u = &upap[unit]; + + UPAPDEBUG(LOG_INFO, ("upap_lowerup: init %d clientstate s=%d\n", unit, u->us_clientstate)); + + if (u->us_clientstate == UPAPCS_INITIAL) { + u->us_clientstate = UPAPCS_CLOSED; + } else if (u->us_clientstate == UPAPCS_PENDING) { + upap_sauthreq(u); /* send an auth-request */ + /* now client state is UPAPCS__AUTHREQ */ + } + + if (u->us_serverstate == UPAPSS_INITIAL) { + u->us_serverstate = UPAPSS_CLOSED; + } else if (u->us_serverstate == UPAPSS_PENDING) { + u->us_serverstate = UPAPSS_LISTEN; + if (u->us_reqtimeout > 0) { + TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); + } + } +} + + +/* + * upap_lowerdown - The lower layer is down. + * + * Cancel all timeouts. + */ +static void +upap_lowerdown(int unit) +{ + upap_state *u = &upap[unit]; + + UPAPDEBUG(LOG_INFO, ("upap_lowerdown: %d s=%d\n", unit, u->us_clientstate)); + + if (u->us_clientstate == UPAPCS_AUTHREQ) { /* Timeout pending? */ + UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ + } + if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0) { + UNTIMEOUT(upap_reqtimeout, u); + } + + u->us_clientstate = UPAPCS_INITIAL; + u->us_serverstate = UPAPSS_INITIAL; +} + + +/* + * upap_protrej - Peer doesn't speak this protocol. + * + * This shouldn't happen. In any case, pretend lower layer went down. + */ +static void +upap_protrej(int unit) +{ + upap_state *u = &upap[unit]; + + if (u->us_clientstate == UPAPCS_AUTHREQ) { + UPAPDEBUG(LOG_ERR, ("PAP authentication failed due to protocol-reject\n")); + auth_withpeer_fail(unit, PPP_PAP); + } + if (u->us_serverstate == UPAPSS_LISTEN) { + UPAPDEBUG(LOG_ERR, ("PAP authentication of peer failed (protocol-reject)\n")); + auth_peer_fail(unit, PPP_PAP); + } + upap_lowerdown(unit); +} + + +/* + * upap_input - Input UPAP packet. + */ +static void +upap_input(int unit, u_char *inpacket, int l) +{ + upap_state *u = &upap[unit]; + u_char *inp; + u_char code, id; + int len; + + /* + * Parse header (code, id and length). + * If packet too short, drop it. + */ + inp = inpacket; + if (l < (int)UPAP_HEADERLEN) { + UPAPDEBUG(LOG_INFO, ("pap_input: rcvd short header.\n")); + return; + } + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < (int)UPAP_HEADERLEN) { + UPAPDEBUG(LOG_INFO, ("pap_input: rcvd illegal length.\n")); + return; + } + if (len > l) { + UPAPDEBUG(LOG_INFO, ("pap_input: rcvd short packet.\n")); + return; + } + len -= UPAP_HEADERLEN; + + /* + * Action depends on code. + */ + switch (code) { + case UPAP_AUTHREQ: + upap_rauthreq(u, inp, id, len); + break; + + case UPAP_AUTHACK: + upap_rauthack(u, inp, id, len); + break; + + case UPAP_AUTHNAK: + upap_rauthnak(u, inp, id, len); + break; + + default: /* XXX Need code reject */ + UPAPDEBUG(LOG_INFO, ("pap_input: UNHANDLED default: code: %d, id: %d, len: %d.\n", code, id, len)); + break; + } +} + + +/* + * upap_rauth - Receive Authenticate. + */ +static void +upap_rauthreq(upap_state *u, u_char *inp, u_char id, int len) +{ + u_char ruserlen, rpasswdlen; + char *ruser, *rpasswd; + u_char retcode; + char *msg; + int msglen; + + UPAPDEBUG(LOG_INFO, ("pap_rauth: Rcvd id %d.\n", id)); + + if (u->us_serverstate < UPAPSS_LISTEN) { + return; + } + + /* + * If we receive a duplicate authenticate-request, we are + * supposed to return the same status as for the first request. + */ + if (u->us_serverstate == UPAPSS_OPEN) { + upap_sresp(u, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ + return; + } + if (u->us_serverstate == UPAPSS_BADAUTH) { + upap_sresp(u, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ + return; + } + + /* + * Parse user/passwd. + */ + if (len < (int)sizeof (u_char)) { + UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); + return; + } + GETCHAR(ruserlen, inp); + len -= sizeof (u_char) + ruserlen + sizeof (u_char); + if (len < 0) { + UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); + return; + } + ruser = (char *) inp; + INCPTR(ruserlen, inp); + GETCHAR(rpasswdlen, inp); + if (len < rpasswdlen) { + UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); + return; + } + rpasswd = (char *) inp; + + /* + * Check the username and password given. + */ + retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen); + /* lwip: currently retcode is always UPAP_AUTHACK */ + BZERO(rpasswd, rpasswdlen); + + upap_sresp(u, retcode, id, msg, msglen); + + if (retcode == UPAP_AUTHACK) { + u->us_serverstate = UPAPSS_OPEN; + auth_peer_success(u->us_unit, PPP_PAP, ruser, ruserlen); + } else { + u->us_serverstate = UPAPSS_BADAUTH; + auth_peer_fail(u->us_unit, PPP_PAP); + } + + if (u->us_reqtimeout > 0) { + UNTIMEOUT(upap_reqtimeout, u); + } +} + + +/* + * upap_rauthack - Receive Authenticate-Ack. + */ +static void +upap_rauthack(upap_state *u, u_char *inp, int id, int len) +{ + u_char msglen; + char *msg; + + LWIP_UNUSED_ARG(id); + + UPAPDEBUG(LOG_INFO, ("pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate)); + + if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ + UPAPDEBUG(LOG_INFO, ("pap_rauthack: us_clientstate != UPAPCS_AUTHREQ\n")); + return; + } + + /* + * Parse message. + */ + if (len < (int)sizeof (u_char)) { + UPAPDEBUG(LOG_INFO, ("pap_rauthack: ignoring missing msg-length.\n")); + } else { + GETCHAR(msglen, inp); + if (msglen > 0) { + len -= sizeof (u_char); + if (len < msglen) { + UPAPDEBUG(LOG_INFO, ("pap_rauthack: rcvd short packet.\n")); + return; + } + msg = (char *) inp; + PRINTMSG(msg, msglen); + } + } + UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ + u->us_clientstate = UPAPCS_OPEN; + + auth_withpeer_success(u->us_unit, PPP_PAP); +} + + +/* + * upap_rauthnak - Receive Authenticate-Nak. + */ +static void +upap_rauthnak(upap_state *u, u_char *inp, int id, int len) +{ + u_char msglen; + char *msg; + + LWIP_UNUSED_ARG(id); + + UPAPDEBUG(LOG_INFO, ("pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate)); + + if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ + return; + } + + /* + * Parse message. + */ + if (len < sizeof (u_char)) { + UPAPDEBUG(LOG_INFO, ("pap_rauthnak: ignoring missing msg-length.\n")); + } else { + GETCHAR(msglen, inp); + if(msglen > 0) { + len -= sizeof (u_char); + if (len < msglen) { + UPAPDEBUG(LOG_INFO, ("pap_rauthnak: rcvd short packet.\n")); + return; + } + msg = (char *) inp; + PRINTMSG(msg, msglen); + } + } + + u->us_clientstate = UPAPCS_BADAUTH; + + UPAPDEBUG(LOG_ERR, ("PAP authentication failed\n")); + auth_withpeer_fail(u->us_unit, PPP_PAP); +} + + +/* + * upap_sauthreq - Send an Authenticate-Request. + */ +static void +upap_sauthreq(upap_state *u) +{ + u_char *outp; + int outlen; + + outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + + u->us_userlen + u->us_passwdlen; + outp = outpacket_buf[u->us_unit]; + + MAKEHEADER(outp, PPP_PAP); + + PUTCHAR(UPAP_AUTHREQ, outp); + PUTCHAR(++u->us_id, outp); + PUTSHORT(outlen, outp); + PUTCHAR(u->us_userlen, outp); + BCOPY(u->us_user, outp, u->us_userlen); + INCPTR(u->us_userlen, outp); + PUTCHAR(u->us_passwdlen, outp); + BCOPY(u->us_passwd, outp, u->us_passwdlen); + + pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); + + UPAPDEBUG(LOG_INFO, ("pap_sauth: Sent id %d\n", u->us_id)); + + TIMEOUT(upap_timeout, u, u->us_timeouttime); + ++u->us_transmits; + u->us_clientstate = UPAPCS_AUTHREQ; +} + + +/* + * upap_sresp - Send a response (ack or nak). + */ +static void +upap_sresp(upap_state *u, u_char code, u_char id, char *msg, int msglen) +{ + u_char *outp; + int outlen; + + outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen; + outp = outpacket_buf[u->us_unit]; + MAKEHEADER(outp, PPP_PAP); + + PUTCHAR(code, outp); + PUTCHAR(id, outp); + PUTSHORT(outlen, outp); + PUTCHAR(msglen, outp); + BCOPY(msg, outp, msglen); + pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); + + UPAPDEBUG(LOG_INFO, ("pap_sresp: Sent code %d, id %d s=%d\n", code, id, u->us_clientstate)); +} + +#if PPP_ADDITIONAL_CALLBACKS +static char *upap_codenames[] = { + "AuthReq", "AuthAck", "AuthNak" +}; + +/* + * upap_printpkt - print the contents of a PAP packet. + */ +static int upap_printpkt( + u_char *p, + int plen, + void (*printer) (void *, char *, ...), + void *arg +) +{ + LWIP_UNUSED_ARG(p); + LWIP_UNUSED_ARG(plen); + LWIP_UNUSED_ARG(printer); + LWIP_UNUSED_ARG(arg); + return 0; +} +#endif /* PPP_ADDITIONAL_CALLBACKS */ + +#endif /* PAP_SUPPORT */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/pap.h b/user/mpy/lib/lwip/src/netif/ppp/pap.h new file mode 100644 index 0000000..c99a204 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/pap.h @@ -0,0 +1,118 @@ +/***************************************************************************** +* pap.h - PPP Password Authentication Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-12-04 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ +/* + * upap.h - User/Password Authentication Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef PAP_H +#define PAP_H + +#if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +/* + * Packet header = Code, id, length. + */ +#define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) + + +/* + * UPAP codes. + */ +#define UPAP_AUTHREQ 1 /* Authenticate-Request */ +#define UPAP_AUTHACK 2 /* Authenticate-Ack */ +#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ + +/* + * Each interface is described by upap structure. + */ +typedef struct upap_state { + int us_unit; /* Interface unit number */ + const char *us_user; /* User */ + int us_userlen; /* User length */ + const char *us_passwd; /* Password */ + int us_passwdlen; /* Password length */ + int us_clientstate; /* Client state */ + int us_serverstate; /* Server state */ + u_char us_id; /* Current id */ + int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */ + int us_transmits; /* Number of auth-reqs sent */ + int us_maxtransmits; /* Maximum number of auth-reqs to send */ + int us_reqtimeout; /* Time to wait for auth-req from peer */ +} upap_state; + +/* + * Client states. + */ +#define UPAPCS_INITIAL 0 /* Connection down */ +#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ +#define UPAPCS_OPEN 4 /* We've received an Ack */ +#define UPAPCS_BADAUTH 5 /* We've received a Nak */ + +/* + * Server states. + */ +#define UPAPSS_INITIAL 0 /* Connection down */ +#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ +#define UPAPSS_OPEN 4 /* We've sent an Ack */ +#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ + + +extern upap_state upap[]; + +void upap_authwithpeer (int, char *, char *); +void upap_authpeer (int); + +extern struct protent pap_protent; + +#endif /* PAP_SUPPORT */ + +#endif /* PAP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp.c b/user/mpy/lib/lwip/src/netif/ppp/ppp.c new file mode 100644 index 0000000..8e8fae9 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/ppp.c @@ -0,0 +1,2045 @@ +/***************************************************************************** +* ppp.c - Network Point to Point Protocol program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-11-05 Guy Lancaster , Global Election Systems Inc. +* Original. +*****************************************************************************/ + +/* + * ppp_defs.h - PPP definitions. + * + * if_pppvar.h - private structures and declarations for PPP. + * + * Copyright (c) 1994 The Australian National University. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, provided that the above copyright + * notice appears in all copies. This software is provided without any + * warranty, express or implied. The Australian National University + * makes no representations about the suitability of this software for + * any purpose. + * + * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY + * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, + * OR MODIFICATIONS. + */ + +/* + * if_ppp.h - Point-to-Point Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "lwip/ip.h" /* for ip_input() */ + +#include "pppdebug.h" + +#include "randm.h" +#include "fsm.h" +#if PAP_SUPPORT +#include "pap.h" +#endif /* PAP_SUPPORT */ +#if CHAP_SUPPORT +#include "chap.h" +#endif /* CHAP_SUPPORT */ +#include "ipcp.h" +#include "lcp.h" +#include "magic.h" +#include "auth.h" +#if VJ_SUPPORT +#include "vj.h" +#endif /* VJ_SUPPORT */ +#if PPPOE_SUPPORT +#include "netif/ppp_oe.h" +#endif /* PPPOE_SUPPORT */ + +#include "lwip/tcpip.h" +#include "lwip/api.h" +#include "lwip/snmp.h" + +#include + +/*************************/ +/*** LOCAL DEFINITIONS ***/ +/*************************/ + +/** PPP_INPROC_MULTITHREADED==1 call pppInput using tcpip_callback(). + * Set this to 0 if pppInProc is called inside tcpip_thread or with NO_SYS==1. + * Default is 1 for NO_SYS==0 (multithreaded) and 0 for NO_SYS==1 (single-threaded). + */ +#ifndef PPP_INPROC_MULTITHREADED +#define PPP_INPROC_MULTITHREADED (NO_SYS==0) +#endif + +/** PPP_INPROC_OWNTHREAD==1: start a dedicated RX thread per PPP session. + * Default is 0: call pppos_input() for received raw characters, charcater + * reception is up to the port */ +#ifndef PPP_INPROC_OWNTHREAD +#define PPP_INPROC_OWNTHREAD PPP_INPROC_MULTITHREADED +#endif + +#if PPP_INPROC_OWNTHREAD && !PPP_INPROC_MULTITHREADED + #error "PPP_INPROC_OWNTHREAD needs PPP_INPROC_MULTITHREADED==1" +#endif + +/* + * The basic PPP frame. + */ +#define PPP_ADDRESS(p) (((u_char *)(p))[0]) +#define PPP_CONTROL(p) (((u_char *)(p))[1]) +#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3]) + +/* PPP packet parser states. Current state indicates operation yet to be + * completed. */ +typedef enum { + PDIDLE = 0, /* Idle state - waiting. */ + PDSTART, /* Process start flag. */ + PDADDRESS, /* Process address field. */ + PDCONTROL, /* Process control field. */ + PDPROTOCOL1, /* Process protocol field 1. */ + PDPROTOCOL2, /* Process protocol field 2. */ + PDDATA /* Process data byte. */ +} PPPDevStates; + +#define ESCAPE_P(accm, c) ((accm)[(c) >> 3] & pppACCMMask[c & 0x07]) + +/************************/ +/*** LOCAL DATA TYPES ***/ +/************************/ + +/** RX buffer size: this may be configured smaller! */ +#ifndef PPPOS_RX_BUFSIZE +#define PPPOS_RX_BUFSIZE (PPP_MRU + PPP_HDRLEN) +#endif + +typedef struct PPPControlRx_s { + /** unit number / ppp descriptor */ + int pd; + /** the rx file descriptor */ + sio_fd_t fd; + /** receive buffer - encoded data is stored here */ +#if PPP_INPROC_OWNTHREAD + u_char rxbuf[PPPOS_RX_BUFSIZE]; +#endif /* PPP_INPROC_OWNTHREAD */ + + /* The input packet. */ + struct pbuf *inHead, *inTail; + +#if PPPOS_SUPPORT + u16_t inProtocol; /* The input protocol code. */ + u16_t inFCS; /* Input Frame Check Sequence value. */ +#endif /* PPPOS_SUPPORT */ + PPPDevStates inState; /* The input process state. */ + char inEscaped; /* Escape next character. */ + ext_accm inACCM; /* Async-Ctl-Char-Map for input. */ +} PPPControlRx; + +/* + * PPP interface control block. + */ +typedef struct PPPControl_s { + PPPControlRx rx; + char openFlag; /* True when in use. */ +#if PPPOE_SUPPORT + struct netif *ethif; + struct pppoe_softc *pppoe_sc; +#endif /* PPPOE_SUPPORT */ + int if_up; /* True when the interface is up. */ + int errCode; /* Code indicating why interface is down. */ +#if PPPOS_SUPPORT + sio_fd_t fd; /* File device ID of port. */ +#endif /* PPPOS_SUPPORT */ + u16_t mtu; /* Peer's mru */ + int pcomp; /* Does peer accept protocol compression? */ + int accomp; /* Does peer accept addr/ctl compression? */ + u_long lastXMit; /* Time of last transmission. */ + ext_accm outACCM; /* Async-Ctl-Char-Map for output. */ +#if PPPOS_SUPPORT && VJ_SUPPORT + int vjEnabled; /* Flag indicating VJ compression enabled. */ + struct vjcompress vjComp; /* Van Jacobson compression header. */ +#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ + + struct netif netif; + + struct ppp_addrs addrs; + + void (*linkStatusCB)(void *ctx, int errCode, void *arg); + void *linkStatusCtx; + +} PPPControl; + + +/* + * Ioctl definitions. + */ + +struct npioctl { + int protocol; /* PPP procotol, e.g. PPP_IP */ + enum NPmode mode; +}; + + + +/***********************************/ +/*** LOCAL FUNCTION DECLARATIONS ***/ +/***********************************/ +#if PPPOS_SUPPORT +#if PPP_INPROC_OWNTHREAD +static void pppInputThread(void *arg); +#endif /* PPP_INPROC_OWNTHREAD */ +static void pppDrop(PPPControlRx *pcrx); +static void pppInProc(PPPControlRx *pcrx, u_char *s, int l); +static void pppFreeCurrentInputPacket(PPPControlRx *pcrx); +#endif /* PPPOS_SUPPORT */ + + +/******************************/ +/*** PUBLIC DATA STRUCTURES ***/ +/******************************/ +u_long subnetMask; + +static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */ + +/* + * PPP Data Link Layer "protocol" table. + * One entry per supported protocol. + * The last entry must be NULL. + */ +struct protent *ppp_protocols[] = { + &lcp_protent, +#if PAP_SUPPORT + &pap_protent, +#endif /* PAP_SUPPORT */ +#if CHAP_SUPPORT + &chap_protent, +#endif /* CHAP_SUPPORT */ +#if CBCP_SUPPORT + &cbcp_protent, +#endif /* CBCP_SUPPORT */ + &ipcp_protent, +#if CCP_SUPPORT + &ccp_protent, +#endif /* CCP_SUPPORT */ + NULL +}; + + +/* + * Buffers for outgoing packets. This must be accessed only from the appropriate + * PPP task so that it doesn't need to be protected to avoid collisions. + */ +u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; + + +/*****************************/ +/*** LOCAL DATA STRUCTURES ***/ +/*****************************/ + +#if PPPOS_SUPPORT +/* + * FCS lookup table as calculated by genfcstab. + * @todo: smaller, slower implementation for lower memory footprint? + */ +static const u_short fcstab[256] = { + 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, + 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, + 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, + 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, + 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, + 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, + 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, + 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, + 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, + 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, + 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, + 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, + 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, + 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, + 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, + 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, + 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, + 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, + 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, + 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, + 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, + 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, + 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, + 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, + 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, + 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, + 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, + 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, + 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, + 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, + 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, + 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 +}; + +/* PPP's Asynchronous-Control-Character-Map. The mask array is used + * to select the specific bit for a character. */ +static u_char pppACCMMask[] = { + 0x01, + 0x02, + 0x04, + 0x08, + 0x10, + 0x20, + 0x40, + 0x80 +}; + +#if PPP_INPROC_OWNTHREAD +/** Wake up the task blocked in reading from serial line (if any) */ +static void +pppRecvWakeup(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppRecvWakeup: unit %d\n", pd)); + if (pppControl[pd].openFlag != 0) { + sio_read_abort(pppControl[pd].fd); + } +} +#endif /* PPP_INPROC_OWNTHREAD */ +#endif /* PPPOS_SUPPORT */ + +void +pppLinkTerminated(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: unit %d\n", pd)); + +#if PPPOE_SUPPORT + if (pppControl[pd].ethif) { + pppoe_disconnect(pppControl[pd].pppoe_sc); + } else +#endif /* PPPOE_SUPPORT */ + { +#if PPPOS_SUPPORT + PPPControl* pc; +#if PPP_INPROC_OWNTHREAD + pppRecvWakeup(pd); +#endif /* PPP_INPROC_OWNTHREAD */ + pc = &pppControl[pd]; + + PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); + if (pc->linkStatusCB) { + pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, NULL); + } + + pc->openFlag = 0;/**/ +#endif /* PPPOS_SUPPORT */ + } + PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: finished.\n")); +} + +void +pppLinkDown(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppLinkDown: unit %d\n", pd)); + +#if PPPOE_SUPPORT + if (pppControl[pd].ethif) { + pppoe_disconnect(pppControl[pd].pppoe_sc); + } else +#endif /* PPPOE_SUPPORT */ + { +#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD + pppRecvWakeup(pd); +#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD*/ + } +} + +/** Initiate LCP open request */ +static void +pppStart(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppStart: unit %d\n", pd)); + lcp_lowerup(pd); + lcp_open(pd); /* Start protocol */ + PPPDEBUG(LOG_DEBUG, ("pppStart: finished\n")); +} + +/** LCP close request */ +static void +pppStop(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppStop: unit %d\n", pd)); + lcp_close(pd, "User request"); +} + +/** Called when carrier/link is lost */ +static void +pppHup(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppHupCB: unit %d\n", pd)); + lcp_lowerdown(pd); + link_terminated(pd); +} + +/***********************************/ +/*** PUBLIC FUNCTION DEFINITIONS ***/ +/***********************************/ +/* Initialize the PPP subsystem. */ + +struct ppp_settings ppp_settings; + +void +pppInit(void) +{ + struct protent *protp; + int i, j; + + memset(&ppp_settings, 0, sizeof(ppp_settings)); + ppp_settings.usepeerdns = 1; + pppSetAuth(PPPAUTHTYPE_NONE, NULL, NULL); + + magicInit(); + + subnetMask = PP_HTONL(0xffffff00UL); + + for (i = 0; i < NUM_PPP; i++) { + /* Initialize each protocol to the standard option set. */ + for (j = 0; (protp = ppp_protocols[j]) != NULL; ++j) { + (*protp->init)(i); + } + } +} + +void +pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) +{ + switch(authType) { + case PPPAUTHTYPE_NONE: + default: +#ifdef LWIP_PPP_STRICT_PAP_REJECT + ppp_settings.refuse_pap = 1; +#else /* LWIP_PPP_STRICT_PAP_REJECT */ + /* some providers request pap and accept an empty login/pw */ + ppp_settings.refuse_pap = 0; +#endif /* LWIP_PPP_STRICT_PAP_REJECT */ + ppp_settings.refuse_chap = 1; + break; + + case PPPAUTHTYPE_ANY: + /* Warning: Using PPPAUTHTYPE_ANY might have security consequences. + * RFC 1994 says: + * + * In practice, within or associated with each PPP server, there is a + * database which associates "user" names with authentication + * information ("secrets"). It is not anticipated that a particular + * named user would be authenticated by multiple methods. This would + * make the user vulnerable to attacks which negotiate the least secure + * method from among a set (such as PAP rather than CHAP). If the same + * secret was used, PAP would reveal the secret to be used later with + * CHAP. + * + * Instead, for each user name there should be an indication of exactly + * one method used to authenticate that user name. If a user needs to + * make use of different authentication methods under different + * circumstances, then distinct user names SHOULD be employed, each of + * which identifies exactly one authentication method. + * + */ + ppp_settings.refuse_pap = 0; + ppp_settings.refuse_chap = 0; + break; + + case PPPAUTHTYPE_PAP: + ppp_settings.refuse_pap = 0; + ppp_settings.refuse_chap = 1; + break; + + case PPPAUTHTYPE_CHAP: + ppp_settings.refuse_pap = 1; + ppp_settings.refuse_chap = 0; + break; + } + + if(user) { + strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1); + ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0'; + } else { + ppp_settings.user[0] = '\0'; + } + + if(passwd) { + strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1); + ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0'; + } else { + ppp_settings.passwd[0] = '\0'; + } +} + +#if PPPOS_SUPPORT +/** Open a new PPP connection using the given I/O device. + * This initializes the PPP control block but does not + * attempt to negotiate the LCP session. If this port + * connects to a modem, the modem connection must be + * established before calling this. + * Return a new PPP connection descriptor on success or + * an error code (negative) on failure. + * + * pppOpen() is directly defined to this function. + */ +int +pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx) +{ + PPPControl *pc; + int pd; + + if (linkStatusCB == NULL) { + /* PPP is single-threaded: without a callback, + * there is no way to know when the link is up. */ + return PPPERR_PARAM; + } + + /* Find a free PPP session descriptor. */ + for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++); + + if (pd >= NUM_PPP) { + pd = PPPERR_OPEN; + } else { + pc = &pppControl[pd]; + /* input pbuf left over from last session? */ + pppFreeCurrentInputPacket(&pc->rx); + /* @todo: is this correct or do I overwrite something? */ + memset(pc, 0, sizeof(PPPControl)); + pc->rx.pd = pd; + pc->rx.fd = fd; + + pc->openFlag = 1; + pc->fd = fd; + +#if VJ_SUPPORT + vj_compress_init(&pc->vjComp); +#endif /* VJ_SUPPORT */ + + /* + * Default the in and out accm so that escape and flag characters + * are always escaped. + */ + pc->rx.inACCM[15] = 0x60; /* no need to protect since RX is not running */ + pc->outACCM[15] = 0x60; + + pc->linkStatusCB = linkStatusCB; + pc->linkStatusCtx = linkStatusCtx; + + /* + * Start the connection and handle incoming events (packet or timeout). + */ + PPPDEBUG(LOG_INFO, ("pppOverSerialOpen: unit %d: Connecting\n", pd)); + pppStart(pd); +#if PPP_INPROC_OWNTHREAD + sys_thread_new(PPP_THREAD_NAME, pppInputThread, (void*)&pc->rx, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); +#endif /* PPP_INPROC_OWNTHREAD */ + } + + return pd; +} +#endif /* PPPOS_SUPPORT */ + +#if PPPOE_SUPPORT +static void pppOverEthernetLinkStatusCB(int pd, int up); + +void +pppOverEthernetClose(int pd) +{ + PPPControl* pc = &pppControl[pd]; + + /* *TJL* There's no lcp_deinit */ + lcp_close(pd, NULL); + + pppoe_destroy(&pc->netif); +} + +int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, + pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx) +{ + PPPControl *pc; + int pd; + + LWIP_UNUSED_ARG(service_name); + LWIP_UNUSED_ARG(concentrator_name); + + if (linkStatusCB == NULL) { + /* PPP is single-threaded: without a callback, + * there is no way to know when the link is up. */ + return PPPERR_PARAM; + } + + /* Find a free PPP session descriptor. Critical region? */ + for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++); + if (pd >= NUM_PPP) { + pd = PPPERR_OPEN; + } else { + pc = &pppControl[pd]; + memset(pc, 0, sizeof(PPPControl)); + pc->openFlag = 1; + pc->ethif = ethif; + + pc->linkStatusCB = linkStatusCB; + pc->linkStatusCtx = linkStatusCtx; + + lcp_wantoptions[pd].mru = PPPOE_MAXMTU; + lcp_wantoptions[pd].neg_asyncmap = 0; + lcp_wantoptions[pd].neg_pcompression = 0; + lcp_wantoptions[pd].neg_accompression = 0; + + lcp_allowoptions[pd].mru = PPPOE_MAXMTU; + lcp_allowoptions[pd].neg_asyncmap = 0; + lcp_allowoptions[pd].neg_pcompression = 0; + lcp_allowoptions[pd].neg_accompression = 0; + + if(pppoe_create(ethif, pd, pppOverEthernetLinkStatusCB, &pc->pppoe_sc) != ERR_OK) { + pc->openFlag = 0; + return PPPERR_OPEN; + } + + pppoe_connect(pc->pppoe_sc); + } + + return pd; +} +#endif /* PPPOE_SUPPORT */ + + +/* Close a PPP connection and release the descriptor. + * Any outstanding packets in the queues are dropped. + * Return 0 on success, an error code on failure. */ +int +pppClose(int pd) +{ + PPPControl *pc = &pppControl[pd]; + int st = 0; + + PPPDEBUG(LOG_DEBUG, ("pppClose() called\n")); + + /* Disconnect */ +#if PPPOE_SUPPORT + if(pc->ethif) { + PPPDEBUG(LOG_DEBUG, ("pppClose: unit %d kill_link -> pppStop\n", pd)); + pc->errCode = PPPERR_USER; + /* This will leave us at PHASE_DEAD. */ + pppStop(pd); + } else +#endif /* PPPOE_SUPPORT */ + { +#if PPPOS_SUPPORT + PPPDEBUG(LOG_DEBUG, ("pppClose: unit %d kill_link -> pppStop\n", pd)); + pc->errCode = PPPERR_USER; + /* This will leave us at PHASE_DEAD. */ + pppStop(pd); +#if PPP_INPROC_OWNTHREAD + pppRecvWakeup(pd); +#endif /* PPP_INPROC_OWNTHREAD */ +#endif /* PPPOS_SUPPORT */ + } + + return st; +} + +/* This function is called when carrier is lost on the PPP channel. */ +void +pppSigHUP(int pd) +{ + PPPDEBUG(LOG_DEBUG, ("pppSigHUP: unit %d sig_hup -> pppHupCB\n", pd)); + pppHup(pd); +} + +#if PPPOS_SUPPORT +static void +nPut(PPPControl *pc, struct pbuf *nb) +{ + struct pbuf *b; + int c; + + for(b = nb; b != NULL; b = b->next) { + if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) { + PPPDEBUG(LOG_WARNING, + ("PPP nPut: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (size_t)pc->fd, b->len, c, c)); + LINK_STATS_INC(link.err); + pc->lastXMit = 0; /* prepend PPP_FLAG to next packet */ + snmp_inc_ifoutdiscards(&pc->netif); + pbuf_free(nb); + return; + } + } + + snmp_add_ifoutoctets(&pc->netif, nb->tot_len); + snmp_inc_ifoutucastpkts(&pc->netif); + pbuf_free(nb); + LINK_STATS_INC(link.xmit); +} + +/* + * pppAppend - append given character to end of given pbuf. If outACCM + * is not NULL and the character needs to be escaped, do so. + * If pbuf is full, append another. + * Return the current pbuf. + */ +static struct pbuf * +pppAppend(u_char c, struct pbuf *nb, ext_accm *outACCM) +{ + struct pbuf *tb = nb; + + /* Make sure there is room for the character and an escape code. + * Sure we don't quite fill the buffer if the character doesn't + * get escaped but is one character worth complicating this? */ + /* Note: We assume no packet header. */ + if (nb && (PBUF_POOL_BUFSIZE - nb->len) < 2) { + tb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); + if (tb) { + nb->next = tb; + } else { + LINK_STATS_INC(link.memerr); + } + nb = tb; + } + + if (nb) { + if (outACCM && ESCAPE_P(*outACCM, c)) { + *((u_char*)nb->payload + nb->len++) = PPP_ESCAPE; + *((u_char*)nb->payload + nb->len++) = c ^ PPP_TRANS; + } else { + *((u_char*)nb->payload + nb->len++) = c; + } + } + + return tb; +} +#endif /* PPPOS_SUPPORT */ + +#if PPPOE_SUPPORT +static err_t +pppifOutputOverEthernet(int pd, struct pbuf *p) +{ + PPPControl *pc = &pppControl[pd]; + struct pbuf *pb; + u_short protocol = PPP_IP; + int i=0; + u16_t tot_len; + + /* @todo: try to use pbuf_header() here! */ + pb = pbuf_alloc(PBUF_LINK, PPPOE_HDRLEN + sizeof(protocol), PBUF_RAM); + if(!pb) { + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.proterr); + snmp_inc_ifoutdiscards(&pc->netif); + return ERR_MEM; + } + + pbuf_header(pb, -(s16_t)PPPOE_HDRLEN); + + pc->lastXMit = sys_jiffies(); + + if (!pc->pcomp || protocol > 0xFF) { + *((u_char*)pb->payload + i++) = (protocol >> 8) & 0xFF; + } + *((u_char*)pb->payload + i) = protocol & 0xFF; + + pbuf_chain(pb, p); + tot_len = pb->tot_len; + + if(pppoe_xmit(pc->pppoe_sc, pb) != ERR_OK) { + LINK_STATS_INC(link.err); + snmp_inc_ifoutdiscards(&pc->netif); + return PPPERR_DEVICE; + } + + snmp_add_ifoutoctets(&pc->netif, tot_len); + snmp_inc_ifoutucastpkts(&pc->netif); + LINK_STATS_INC(link.xmit); + return ERR_OK; +} +#endif /* PPPOE_SUPPORT */ + +/* Send a packet on the given connection. */ +static err_t +pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) +{ + int pd = (int)(size_t)netif->state; + PPPControl *pc = &pppControl[pd]; +#if PPPOS_SUPPORT + u_short protocol = PPP_IP; + u_int fcsOut = PPP_INITFCS; + struct pbuf *headMB = NULL, *tailMB = NULL, *p; + u_char c; +#endif /* PPPOS_SUPPORT */ + + LWIP_UNUSED_ARG(ipaddr); + + /* Validate parameters. */ + /* We let any protocol value go through - it can't hurt us + * and the peer will just drop it if it's not accepting it. */ + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag || !pb) { + PPPDEBUG(LOG_WARNING, ("pppifOutput[%d]: bad parms prot=%d pb=%p\n", + pd, PPP_IP, pb)); + LINK_STATS_INC(link.opterr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(netif); + return ERR_ARG; + } + + /* Check that the link is up. */ + if (lcp_phase[pd] == PHASE_DEAD) { + PPPDEBUG(LOG_ERR, ("pppifOutput[%d]: link not up\n", pd)); + LINK_STATS_INC(link.rterr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(netif); + return ERR_RTE; + } + +#if PPPOE_SUPPORT + if(pc->ethif) { + return pppifOutputOverEthernet(pd, pb); + } +#endif /* PPPOE_SUPPORT */ + +#if PPPOS_SUPPORT + /* Grab an output buffer. */ + headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); + if (headMB == NULL) { + PPPDEBUG(LOG_WARNING, ("pppifOutput[%d]: first alloc fail\n", pd)); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(netif); + return ERR_MEM; + } + +#if VJ_SUPPORT + /* + * Attempt Van Jacobson header compression if VJ is configured and + * this is an IP packet. + */ + if (protocol == PPP_IP && pc->vjEnabled) { + switch (vj_compress_tcp(&pc->vjComp, pb)) { + case TYPE_IP: + /* No change... + protocol = PPP_IP_PROTOCOL; */ + break; + case TYPE_COMPRESSED_TCP: + protocol = PPP_VJC_COMP; + break; + case TYPE_UNCOMPRESSED_TCP: + protocol = PPP_VJC_UNCOMP; + break; + default: + PPPDEBUG(LOG_WARNING, ("pppifOutput[%d]: bad IP packet\n", pd)); + LINK_STATS_INC(link.proterr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(netif); + pbuf_free(headMB); + return ERR_VAL; + } + } +#endif /* VJ_SUPPORT */ + + tailMB = headMB; + + /* Build the PPP header. */ + if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) { + tailMB = pppAppend(PPP_FLAG, tailMB, NULL); + } + + pc->lastXMit = sys_jiffies(); + if (!pc->accomp) { + fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS); + tailMB = pppAppend(PPP_ALLSTATIONS, tailMB, &pc->outACCM); + fcsOut = PPP_FCS(fcsOut, PPP_UI); + tailMB = pppAppend(PPP_UI, tailMB, &pc->outACCM); + } + if (!pc->pcomp || protocol > 0xFF) { + c = (protocol >> 8) & 0xFF; + fcsOut = PPP_FCS(fcsOut, c); + tailMB = pppAppend(c, tailMB, &pc->outACCM); + } + c = protocol & 0xFF; + fcsOut = PPP_FCS(fcsOut, c); + tailMB = pppAppend(c, tailMB, &pc->outACCM); + + /* Load packet. */ + for(p = pb; p; p = p->next) { + int n; + u_char *sPtr; + + sPtr = (u_char*)p->payload; + n = p->len; + while (n-- > 0) { + c = *sPtr++; + + /* Update FCS before checking for special characters. */ + fcsOut = PPP_FCS(fcsOut, c); + + /* Copy to output buffer escaping special characters. */ + tailMB = pppAppend(c, tailMB, &pc->outACCM); + } + } + + /* Add FCS and trailing flag. */ + c = ~fcsOut & 0xFF; + tailMB = pppAppend(c, tailMB, &pc->outACCM); + c = (~fcsOut >> 8) & 0xFF; + tailMB = pppAppend(c, tailMB, &pc->outACCM); + tailMB = pppAppend(PPP_FLAG, tailMB, NULL); + + /* If we failed to complete the packet, throw it away. */ + if (!tailMB) { + PPPDEBUG(LOG_WARNING, + ("pppifOutput[%d]: Alloc err - dropping proto=%d\n", + pd, protocol)); + pbuf_free(headMB); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + snmp_inc_ifoutdiscards(netif); + return ERR_MEM; + } + + /* Send it. */ + PPPDEBUG(LOG_INFO, ("pppifOutput[%d]: proto=0x%"X16_F"\n", pd, protocol)); + + nPut(pc, headMB); +#endif /* PPPOS_SUPPORT */ + + return ERR_OK; +} + +/* Get and set parameters for the given connection. + * Return 0 on success, an error code on failure. */ +int +pppIOCtl(int pd, int cmd, void *arg) +{ + PPPControl *pc = &pppControl[pd]; + int st = 0; + + if (pd < 0 || pd >= NUM_PPP) { + st = PPPERR_PARAM; + } else { + switch(cmd) { + case PPPCTLG_UPSTATUS: /* Get the PPP up status. */ + if (arg) { + *(int *)arg = (int)(pc->if_up); + } else { + st = PPPERR_PARAM; + } + break; + case PPPCTLS_ERRCODE: /* Set the PPP error code. */ + if (arg) { + pc->errCode = *(int *)arg; + } else { + st = PPPERR_PARAM; + } + break; + case PPPCTLG_ERRCODE: /* Get the PPP error code. */ + if (arg) { + *(int *)arg = (int)(pc->errCode); + } else { + st = PPPERR_PARAM; + } + break; +#if PPPOS_SUPPORT + case PPPCTLG_FD: /* Get the fd associated with the ppp */ + if (arg) { + *(sio_fd_t *)arg = pc->fd; + } else { + st = PPPERR_PARAM; + } + break; +#endif /* PPPOS_SUPPORT */ + default: + st = PPPERR_PARAM; + break; + } + } + + return st; +} + +/* + * Return the Maximum Transmission Unit for the given PPP connection. + */ +u_short +pppMTU(int pd) +{ + PPPControl *pc = &pppControl[pd]; + u_short st; + + /* Validate parameters. */ + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + } else { + st = pc->mtu; + } + + return st; +} + +#if PPPOE_SUPPORT +int +pppWriteOverEthernet(int pd, const u_char *s, int n) +{ + PPPControl *pc = &pppControl[pd]; + struct pbuf *pb; + + /* skip address & flags */ + s += 2; + n -= 2; + + LWIP_ASSERT("PPPOE_HDRLEN + n <= 0xffff", PPPOE_HDRLEN + n <= 0xffff); + pb = pbuf_alloc(PBUF_LINK, (u16_t)(PPPOE_HDRLEN + n), PBUF_RAM); + if(!pb) { + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.proterr); + snmp_inc_ifoutdiscards(&pc->netif); + return PPPERR_ALLOC; + } + + pbuf_header(pb, -(s16_t)PPPOE_HDRLEN); + + pc->lastXMit = sys_jiffies(); + + MEMCPY(pb->payload, s, n); + + if(pppoe_xmit(pc->pppoe_sc, pb) != ERR_OK) { + LINK_STATS_INC(link.err); + snmp_inc_ifoutdiscards(&pc->netif); + return PPPERR_DEVICE; + } + + snmp_add_ifoutoctets(&pc->netif, (u16_t)n); + snmp_inc_ifoutucastpkts(&pc->netif); + LINK_STATS_INC(link.xmit); + return PPPERR_NONE; +} +#endif /* PPPOE_SUPPORT */ + +/* + * Write n characters to a ppp link. + * RETURN: >= 0 Number of characters written + * -1 Failed to write to device + */ +int +pppWrite(int pd, const u_char *s, int n) +{ + PPPControl *pc = &pppControl[pd]; +#if PPPOS_SUPPORT + u_char c; + u_int fcsOut; + struct pbuf *headMB, *tailMB; +#endif /* PPPOS_SUPPORT */ + +#if PPPOE_SUPPORT + if(pc->ethif) { + return pppWriteOverEthernet(pd, s, n); + } +#endif /* PPPOE_SUPPORT */ + +#if PPPOS_SUPPORT + headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); + if (headMB == NULL) { + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.proterr); + snmp_inc_ifoutdiscards(&pc->netif); + return PPPERR_ALLOC; + } + + tailMB = headMB; + + /* If the link has been idle, we'll send a fresh flag character to + * flush any noise. */ + if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) { + tailMB = pppAppend(PPP_FLAG, tailMB, NULL); + } + pc->lastXMit = sys_jiffies(); + + fcsOut = PPP_INITFCS; + /* Load output buffer. */ + while (n-- > 0) { + c = *s++; + + /* Update FCS before checking for special characters. */ + fcsOut = PPP_FCS(fcsOut, c); + + /* Copy to output buffer escaping special characters. */ + tailMB = pppAppend(c, tailMB, &pc->outACCM); + } + + /* Add FCS and trailing flag. */ + c = ~fcsOut & 0xFF; + tailMB = pppAppend(c, tailMB, &pc->outACCM); + c = (~fcsOut >> 8) & 0xFF; + tailMB = pppAppend(c, tailMB, &pc->outACCM); + tailMB = pppAppend(PPP_FLAG, tailMB, NULL); + + /* If we failed to complete the packet, throw it away. + * Otherwise send it. */ + if (!tailMB) { + PPPDEBUG(LOG_WARNING, + ("pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->len)); + /*"pppWrite[%d]: Alloc err - dropping %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ + pbuf_free(headMB); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.proterr); + snmp_inc_ifoutdiscards(&pc->netif); + return PPPERR_ALLOC; + } + + PPPDEBUG(LOG_INFO, ("pppWrite[%d]: len=%d\n", pd, headMB->len)); + /* "pppWrite[%d]: %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ + nPut(pc, headMB); +#endif /* PPPOS_SUPPORT */ + + return PPPERR_NONE; +} + +/* + * ppp_send_config - configure the transmit characteristics of + * the ppp interface. + */ +void +ppp_send_config( int unit, u16_t mtu, u32_t asyncmap, int pcomp, int accomp) +{ + PPPControl *pc = &pppControl[unit]; + int i; + + pc->mtu = mtu; + pc->pcomp = pcomp; + pc->accomp = accomp; + + /* Load the ACCM bits for the 32 control codes. */ + for (i = 0; i < 32/8; i++) { + pc->outACCM[i] = (u_char)((asyncmap >> (8 * i)) & 0xFF); + } + PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]: outACCM=%X %X %X %X\n", + unit, + pc->outACCM[0], pc->outACCM[1], pc->outACCM[2], pc->outACCM[3])); +} + + +/* + * ppp_set_xaccm - set the extended transmit ACCM for the interface. + */ +void +ppp_set_xaccm(int unit, ext_accm *accm) +{ + SMEMCPY(pppControl[unit].outACCM, accm, sizeof(ext_accm)); + PPPDEBUG(LOG_INFO, ("ppp_set_xaccm[%d]: outACCM=%X %X %X %X\n", + unit, + pppControl[unit].outACCM[0], + pppControl[unit].outACCM[1], + pppControl[unit].outACCM[2], + pppControl[unit].outACCM[3])); +} + + +/* + * ppp_recv_config - configure the receive-side characteristics of + * the ppp interface. + */ +void +ppp_recv_config( int unit, int mru, u32_t asyncmap, int pcomp, int accomp) +{ + PPPControl *pc = &pppControl[unit]; + int i; + SYS_ARCH_DECL_PROTECT(lev); + + LWIP_UNUSED_ARG(accomp); + LWIP_UNUSED_ARG(pcomp); + LWIP_UNUSED_ARG(mru); + + /* Load the ACCM bits for the 32 control codes. */ + SYS_ARCH_PROTECT(lev); + for (i = 0; i < 32 / 8; i++) { + /* @todo: does this work? ext_accm has been modified from pppd! */ + pc->rx.inACCM[i] = (u_char)(asyncmap >> (i * 8)); + } + SYS_ARCH_UNPROTECT(lev); + PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]: inACCM=%X %X %X %X\n", + unit, + pc->rx.inACCM[0], pc->rx.inACCM[1], pc->rx.inACCM[2], pc->rx.inACCM[3])); +} + +#if 0 +/* + * ccp_test - ask kernel whether a given compression method + * is acceptable for use. Returns 1 if the method and parameters + * are OK, 0 if the method is known but the parameters are not OK + * (e.g. code size should be reduced), or -1 if the method is unknown. + */ +int +ccp_test( int unit, int opt_len, int for_transmit, u_char *opt_ptr) +{ + return 0; /* XXX Currently no compression. */ +} + +/* + * ccp_flags_set - inform kernel about the current state of CCP. + */ +void +ccp_flags_set(int unit, int isopen, int isup) +{ + /* XXX */ +} + +/* + * ccp_fatal_error - returns 1 if decompression was disabled as a + * result of an error detected after decompression of a packet, + * 0 otherwise. This is necessary because of patent nonsense. + */ +int +ccp_fatal_error(int unit) +{ + /* XXX */ + return 0; +} +#endif + +/* + * get_idle_time - return how long the link has been idle. + */ +int +get_idle_time(int u, struct ppp_idle *ip) +{ + /* XXX */ + LWIP_UNUSED_ARG(u); + LWIP_UNUSED_ARG(ip); + + return 0; +} + + +/* + * Return user specified netmask, modified by any mask we might determine + * for address `addr' (in network byte order). + * Here we scan through the system's list of interfaces, looking for + * any non-point-to-point interfaces which might appear to be on the same + * network as `addr'. If we find any, we OR in their netmask to the + * user-specified netmask. + */ +u32_t +GetMask(u32_t addr) +{ + u32_t mask, nmask; + + addr = htonl(addr); + if (IP_CLASSA(addr)) { /* determine network mask for address class */ + nmask = IP_CLASSA_NET; + } else if (IP_CLASSB(addr)) { + nmask = IP_CLASSB_NET; + } else { + nmask = IP_CLASSC_NET; + } + + /* class D nets are disallowed by bad_ip_adrs */ + mask = subnetMask | htonl(nmask); + + /* XXX + * Scan through the system's network interfaces. + * Get each netmask and OR them into our mask. + */ + + return mask; +} + +/* + * sifvjcomp - config tcp header compression + */ +int +sifvjcomp(int pd, int vjcomp, u8_t cidcomp, u8_t maxcid) +{ +#if PPPOS_SUPPORT && VJ_SUPPORT + PPPControl *pc = &pppControl[pd]; + + pc->vjEnabled = vjcomp; + pc->vjComp.compressSlot = cidcomp; + pc->vjComp.maxSlotIndex = maxcid; + PPPDEBUG(LOG_INFO, ("sifvjcomp: VJ compress enable=%d slot=%d max slot=%d\n", + vjcomp, cidcomp, maxcid)); +#else /* PPPOS_SUPPORT && VJ_SUPPORT */ + LWIP_UNUSED_ARG(pd); + LWIP_UNUSED_ARG(vjcomp); + LWIP_UNUSED_ARG(cidcomp); + LWIP_UNUSED_ARG(maxcid); +#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ + + return 0; +} + +/* + * pppifNetifInit - netif init callback + */ +static err_t +pppifNetifInit(struct netif *netif) +{ + netif->name[0] = 'p'; + netif->name[1] = 'p'; + netif->output = pppifOutput; + netif->mtu = pppMTU((int)(size_t)netif->state); + netif->flags = NETIF_FLAG_POINTTOPOINT | NETIF_FLAG_LINK_UP; +#if LWIP_NETIF_HOSTNAME + /* @todo: Initialize interface hostname */ + /* netif_set_hostname(netif, "lwip"); */ +#endif /* LWIP_NETIF_HOSTNAME */ + return ERR_OK; +} + + +/* + * sifup - Config the interface up and enable IP packets to pass. + */ +int +sifup(int pd) +{ + PPPControl *pc = &pppControl[pd]; + int st = 1; + + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); + } else { + netif_remove(&pc->netif); + if (netif_add(&pc->netif, &pc->addrs.our_ipaddr, &pc->addrs.netmask, + &pc->addrs.his_ipaddr, (void *)(size_t)pd, pppifNetifInit, ip_input)) { + netif_set_up(&pc->netif); + pc->if_up = 1; + pc->errCode = PPPERR_NONE; + + PPPDEBUG(LOG_DEBUG, ("sifup: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); + if (pc->linkStatusCB) { + pc->linkStatusCB(pc->linkStatusCtx, pc->errCode, &pc->addrs); + } + } else { + st = 0; + PPPDEBUG(LOG_ERR, ("sifup[%d]: netif_add failed\n", pd)); + } + } + + return st; +} + +/* + * sifnpmode - Set the mode for handling packets for a given NP. + */ +int +sifnpmode(int u, int proto, enum NPmode mode) +{ + LWIP_UNUSED_ARG(u); + LWIP_UNUSED_ARG(proto); + LWIP_UNUSED_ARG(mode); + return 0; +} + +/* + * sifdown - Config the interface down and disable IP. + */ +int +sifdown(int pd) +{ + PPPControl *pc = &pppControl[pd]; + int st = 1; + + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sifdown[%d]: bad parms\n", pd)); + } else { + pc->if_up = 0; + /* make sure the netif status callback is called */ + netif_set_down(&pc->netif); + netif_remove(&pc->netif); + PPPDEBUG(LOG_DEBUG, ("sifdown: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); + if (pc->linkStatusCB) { + pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, NULL); + } + } + return st; +} + +/** + * sifaddr - Config the interface IP addresses and netmask. + * @param pd Interface unit ??? + * @param o Our IP address ??? + * @param h His IP address ??? + * @param m IP subnet mask ??? + * @param ns1 Primary DNS + * @param ns2 Secondary DNS + */ +int +sifaddr( int pd, u32_t o, u32_t h, u32_t m, u32_t ns1, u32_t ns2) +{ + PPPControl *pc = &pppControl[pd]; + int st = 1; + + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); + } else { + SMEMCPY(&pc->addrs.our_ipaddr, &o, sizeof(o)); + SMEMCPY(&pc->addrs.his_ipaddr, &h, sizeof(h)); + SMEMCPY(&pc->addrs.netmask, &m, sizeof(m)); + SMEMCPY(&pc->addrs.dns1, &ns1, sizeof(ns1)); + SMEMCPY(&pc->addrs.dns2, &ns2, sizeof(ns2)); + } + return st; +} + +/** + * cifaddr - Clear the interface IP addresses, and delete routes + * through the interface if possible. + * @param pd Interface unit ??? + * @param o Our IP address ??? + * @param h IP broadcast address ??? + */ +int +cifaddr( int pd, u32_t o, u32_t h) +{ + PPPControl *pc = &pppControl[pd]; + int st = 1; + + LWIP_UNUSED_ARG(o); + LWIP_UNUSED_ARG(h); + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); + } else { + IP4_ADDR(&pc->addrs.our_ipaddr, 0,0,0,0); + IP4_ADDR(&pc->addrs.his_ipaddr, 0,0,0,0); + IP4_ADDR(&pc->addrs.netmask, 255,255,255,0); + IP4_ADDR(&pc->addrs.dns1, 0,0,0,0); + IP4_ADDR(&pc->addrs.dns2, 0,0,0,0); + } + return st; +} + +/* + * sifdefaultroute - assign a default route through the address given. + */ +int +sifdefaultroute(int pd, u32_t l, u32_t g) +{ + PPPControl *pc = &pppControl[pd]; + int st = 1; + + LWIP_UNUSED_ARG(l); + LWIP_UNUSED_ARG(g); + + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); + } else { + netif_set_default(&pc->netif); + } + + /* TODO: check how PPP handled the netMask, previously not set by ipSetDefault */ + + return st; +} + +/* + * cifdefaultroute - delete a default route through the address given. + */ +int +cifdefaultroute(int pd, u32_t l, u32_t g) +{ + PPPControl *pc = &pppControl[pd]; + int st = 1; + + LWIP_UNUSED_ARG(l); + LWIP_UNUSED_ARG(g); + + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); + } else { + netif_set_default(NULL); + } + + return st; +} + +/**********************************/ +/*** LOCAL FUNCTION DEFINITIONS ***/ +/**********************************/ + +#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD +/* The main PPP process function. This implements the state machine according + * to section 4 of RFC 1661: The Point-To-Point Protocol. */ +static void +pppInputThread(void *arg) +{ + int count; + PPPControlRx *pcrx = arg; + + while (lcp_phase[pcrx->pd] != PHASE_DEAD) { + count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE); + if(count > 0) { + pppInProc(pcrx, pcrx->rxbuf, count); + } else { + /* nothing received, give other tasks a chance to run */ + sys_msleep(1); + } + } +} +#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */ + +#if PPPOE_SUPPORT + +void +pppOverEthernetInitFailed(int pd) +{ + PPPControl* pc; + + pppHup(pd); + pppStop(pd); + + pc = &pppControl[pd]; + pppoe_destroy(&pc->netif); + pc->openFlag = 0; + + if(pc->linkStatusCB) { + pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, NULL); + } +} + +static void +pppOverEthernetLinkStatusCB(int pd, int up) +{ + if(up) { + PPPDEBUG(LOG_INFO, ("pppOverEthernetLinkStatusCB: unit %d: Connecting\n", pd)); + pppStart(pd); + } else { + pppOverEthernetInitFailed(pd); + } +} +#endif /* PPPOE_SUPPORT */ + +struct pbuf * +pppSingleBuf(struct pbuf *p) +{ + struct pbuf *q, *b; + u_char *pl; + + if(p->tot_len == p->len) { + return p; + } + + q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); + if(!q) { + PPPDEBUG(LOG_ERR, + ("pppSingleBuf: unable to alloc new buf (%d)\n", p->tot_len)); + return p; /* live dangerously */ + } + + for(b = p, pl = q->payload; b != NULL; b = b->next) { + MEMCPY(pl, b->payload, b->len); + pl += b->len; + } + + pbuf_free(p); + + return q; +} + +struct pppInputHeader { + int unit; + u16_t proto; +}; + +/* + * Pass the processed input packet to the appropriate handler. + * This function and all handlers run in the context of the tcpip_thread + */ +static void +pppInput(void *arg) +{ + struct pbuf *nb = (struct pbuf *)arg; + u16_t protocol; + int pd; + + pd = ((struct pppInputHeader *)nb->payload)->unit; + protocol = ((struct pppInputHeader *)nb->payload)->proto; + + if(pbuf_header(nb, -(int)sizeof(struct pppInputHeader))) { + LWIP_ASSERT("pbuf_header failed\n", 0); + goto drop; + } + + LINK_STATS_INC(link.recv); + snmp_inc_ifinucastpkts(&pppControl[pd].netif); + snmp_add_ifinoctets(&pppControl[pd].netif, nb->tot_len); + + /* + * Toss all non-LCP packets unless LCP is OPEN. + * Until we get past the authentication phase, toss all packets + * except LCP, LQR and authentication packets. + */ + if((lcp_phase[pd] <= PHASE_AUTHENTICATE) && (protocol != PPP_LCP)) { + if(!((protocol == PPP_LQR) || (protocol == PPP_PAP) || (protocol == PPP_CHAP)) || + (lcp_phase[pd] != PHASE_AUTHENTICATE)) { + PPPDEBUG(LOG_INFO, ("pppInput: discarding proto 0x%"X16_F" in phase %d\n", protocol, lcp_phase[pd])); + goto drop; + } + } + + switch(protocol) { + case PPP_VJC_COMP: /* VJ compressed TCP */ +#if PPPOS_SUPPORT && VJ_SUPPORT + PPPDEBUG(LOG_INFO, ("pppInput[%d]: vj_comp in pbuf len=%d\n", pd, nb->len)); + /* + * Clip off the VJ header and prepend the rebuilt TCP/IP header and + * pass the result to IP. + */ + if ((vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) && (pppControl[pd].netif.input)) { + pppControl[pd].netif.input(nb, &pppControl[pd].netif); + return; + } + /* Something's wrong so drop it. */ + PPPDEBUG(LOG_WARNING, ("pppInput[%d]: Dropping VJ compressed\n", pd)); +#else /* PPPOS_SUPPORT && VJ_SUPPORT */ + /* No handler for this protocol so drop the packet. */ + PPPDEBUG(LOG_INFO, ("pppInput[%d]: drop VJ Comp in %d:%s\n", pd, nb->len, nb->payload)); +#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ + break; + + case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */ +#if PPPOS_SUPPORT && VJ_SUPPORT + PPPDEBUG(LOG_INFO, ("pppInput[%d]: vj_un in pbuf len=%d\n", pd, nb->len)); + /* + * Process the TCP/IP header for VJ header compression and then pass + * the packet to IP. + */ + if ((vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) && pppControl[pd].netif.input) { + pppControl[pd].netif.input(nb, &pppControl[pd].netif); + return; + } + /* Something's wrong so drop it. */ + PPPDEBUG(LOG_WARNING, ("pppInput[%d]: Dropping VJ uncompressed\n", pd)); +#else /* PPPOS_SUPPORT && VJ_SUPPORT */ + /* No handler for this protocol so drop the packet. */ + PPPDEBUG(LOG_INFO, + ("pppInput[%d]: drop VJ UnComp in %d:.*H\n", + pd, nb->len, LWIP_MIN(nb->len * 2, 40), nb->payload)); +#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ + break; + + case PPP_IP: /* Internet Protocol */ + PPPDEBUG(LOG_INFO, ("pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len)); + if (pppControl[pd].netif.input) { + pppControl[pd].netif.input(nb, &pppControl[pd].netif); + return; + } + break; + + default: { + struct protent *protp; + int i; + + /* + * Upcall the proper protocol input routine. + */ + for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { + if (protp->protocol == protocol && protp->enabled_flag) { + PPPDEBUG(LOG_INFO, ("pppInput[%d]: %s len=%d\n", pd, protp->name, nb->len)); + nb = pppSingleBuf(nb); + (*protp->input)(pd, nb->payload, nb->len); + PPPDEBUG(LOG_DETAIL, ("pppInput[%d]: packet processed\n", pd)); + goto out; + } + } + + /* No handler for this protocol so reject the packet. */ + PPPDEBUG(LOG_INFO, ("pppInput[%d]: rejecting unsupported proto 0x%"X16_F" len=%d\n", pd, protocol, nb->len)); + if (pbuf_header(nb, sizeof(protocol))) { + LWIP_ASSERT("pbuf_header failed\n", 0); + goto drop; + } +#if BYTE_ORDER == LITTLE_ENDIAN + protocol = htons(protocol); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + SMEMCPY(nb->payload, &protocol, sizeof(protocol)); + lcp_sprotrej(pd, nb->payload, nb->len); + } + break; + } + +drop: + LINK_STATS_INC(link.drop); + snmp_inc_ifindiscards(&pppControl[pd].netif); + +out: + pbuf_free(nb); + return; +} + +#if PPPOS_SUPPORT +/* + * Drop the input packet. + */ +static void +pppFreeCurrentInputPacket(PPPControlRx *pcrx) +{ + if (pcrx->inHead != NULL) { + if (pcrx->inTail && (pcrx->inTail != pcrx->inHead)) { + pbuf_free(pcrx->inTail); + } + pbuf_free(pcrx->inHead); + pcrx->inHead = NULL; + } + pcrx->inTail = NULL; +} + +/* + * Drop the input packet and increase error counters. + */ +static void +pppDrop(PPPControlRx *pcrx) +{ + if (pcrx->inHead != NULL) { +#if 0 + PPPDEBUG(LOG_INFO, ("pppDrop: %d:%.*H\n", pcrx->inHead->len, min(60, pcrx->inHead->len * 2), pcrx->inHead->payload)); +#endif + PPPDEBUG(LOG_INFO, ("pppDrop: pbuf len=%d, addr %p\n", pcrx->inHead->len, (void*)pcrx->inHead)); + } + pppFreeCurrentInputPacket(pcrx); +#if VJ_SUPPORT + vj_uncompress_err(&pppControl[pcrx->pd].vjComp); +#endif /* VJ_SUPPORT */ + + LINK_STATS_INC(link.drop); + snmp_inc_ifindiscards(&pppControl[pcrx->pd].netif); +} + +#if !PPP_INPROC_OWNTHREAD +/** Pass received raw characters to PPPoS to be decoded. This function is + * thread-safe and can be called from a dedicated RX-thread or from a main-loop. + * + * @param pd PPP descriptor index, returned by pppOpen() + * @param data received data + * @param len length of received data + */ +void +pppos_input(int pd, u_char* data, int len) +{ + pppInProc(&pppControl[pd].rx, data, len); +} +#endif + +/** + * Process a received octet string. + */ +static void +pppInProc(PPPControlRx *pcrx, u_char *s, int l) +{ + struct pbuf *nextNBuf; + u_char curChar; + u_char escaped; + SYS_ARCH_DECL_PROTECT(lev); + + PPPDEBUG(LOG_DEBUG, ("pppInProc[%d]: got %d bytes\n", pcrx->pd, l)); + while (l-- > 0) { + curChar = *s++; + + SYS_ARCH_PROTECT(lev); + escaped = ESCAPE_P(pcrx->inACCM, curChar); + SYS_ARCH_UNPROTECT(lev); + /* Handle special characters. */ + if (escaped) { + /* Check for escape sequences. */ + /* XXX Note that this does not handle an escaped 0x5d character which + * would appear as an escape character. Since this is an ASCII ']' + * and there is no reason that I know of to escape it, I won't complicate + * the code to handle this case. GLL */ + if (curChar == PPP_ESCAPE) { + pcrx->inEscaped = 1; + /* Check for the flag character. */ + } else if (curChar == PPP_FLAG) { + /* If this is just an extra flag character, ignore it. */ + if (pcrx->inState <= PDADDRESS) { + /* ignore it */; + /* If we haven't received the packet header, drop what has come in. */ + } else if (pcrx->inState < PDDATA) { + PPPDEBUG(LOG_WARNING, + ("pppInProc[%d]: Dropping incomplete packet %d\n", + pcrx->pd, pcrx->inState)); + LINK_STATS_INC(link.lenerr); + pppDrop(pcrx); + /* If the fcs is invalid, drop the packet. */ + } else if (pcrx->inFCS != PPP_GOODFCS) { + PPPDEBUG(LOG_INFO, + ("pppInProc[%d]: Dropping bad fcs 0x%"X16_F" proto=0x%"X16_F"\n", + pcrx->pd, pcrx->inFCS, pcrx->inProtocol)); + /* Note: If you get lots of these, check for UART frame errors or try different baud rate */ + LINK_STATS_INC(link.chkerr); + pppDrop(pcrx); + /* Otherwise it's a good packet so pass it on. */ + } else { + struct pbuf *inp; + /* Trim off the checksum. */ + if(pcrx->inTail->len >= 2) { + pcrx->inTail->len -= 2; + + pcrx->inTail->tot_len = pcrx->inTail->len; + if (pcrx->inTail != pcrx->inHead) { + pbuf_cat(pcrx->inHead, pcrx->inTail); + } + } else { + pcrx->inTail->tot_len = pcrx->inTail->len; + if (pcrx->inTail != pcrx->inHead) { + pbuf_cat(pcrx->inHead, pcrx->inTail); + } + + pbuf_realloc(pcrx->inHead, pcrx->inHead->tot_len - 2); + } + + /* Dispatch the packet thereby consuming it. */ + inp = pcrx->inHead; + /* Packet consumed, release our references. */ + pcrx->inHead = NULL; + pcrx->inTail = NULL; +#if PPP_INPROC_MULTITHREADED + if(tcpip_callback_with_block(pppInput, inp, 0) != ERR_OK) { + PPPDEBUG(LOG_ERR, ("pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pcrx->pd)); + pbuf_free(inp); + LINK_STATS_INC(link.drop); + snmp_inc_ifindiscards(&pppControl[pcrx->pd].netif); + } +#else /* PPP_INPROC_MULTITHREADED */ + pppInput(inp); +#endif /* PPP_INPROC_MULTITHREADED */ + } + + /* Prepare for a new packet. */ + pcrx->inFCS = PPP_INITFCS; + pcrx->inState = PDADDRESS; + pcrx->inEscaped = 0; + /* Other characters are usually control characters that may have + * been inserted by the physical layer so here we just drop them. */ + } else { + PPPDEBUG(LOG_WARNING, + ("pppInProc[%d]: Dropping ACCM char <%d>\n", pcrx->pd, curChar)); + } + /* Process other characters. */ + } else { + /* Unencode escaped characters. */ + if (pcrx->inEscaped) { + pcrx->inEscaped = 0; + curChar ^= PPP_TRANS; + } + + /* Process character relative to current state. */ + switch(pcrx->inState) { + case PDIDLE: /* Idle state - waiting. */ + /* Drop the character if it's not 0xff + * we would have processed a flag character above. */ + if (curChar != PPP_ALLSTATIONS) { + break; + } + + /* Fall through */ + case PDSTART: /* Process start flag. */ + /* Prepare for a new packet. */ + pcrx->inFCS = PPP_INITFCS; + + /* Fall through */ + case PDADDRESS: /* Process address field. */ + if (curChar == PPP_ALLSTATIONS) { + pcrx->inState = PDCONTROL; + break; + } + /* Else assume compressed address and control fields so + * fall through to get the protocol... */ + case PDCONTROL: /* Process control field. */ + /* If we don't get a valid control code, restart. */ + if (curChar == PPP_UI) { + pcrx->inState = PDPROTOCOL1; + break; + } +#if 0 + else { + PPPDEBUG(LOG_WARNING, + ("pppInProc[%d]: Invalid control <%d>\n", pcrx->pd, curChar)); + pcrx->inState = PDSTART; + } +#endif + case PDPROTOCOL1: /* Process protocol field 1. */ + /* If the lower bit is set, this is the end of the protocol + * field. */ + if (curChar & 1) { + pcrx->inProtocol = curChar; + pcrx->inState = PDDATA; + } else { + pcrx->inProtocol = (u_int)curChar << 8; + pcrx->inState = PDPROTOCOL2; + } + break; + case PDPROTOCOL2: /* Process protocol field 2. */ + pcrx->inProtocol |= curChar; + pcrx->inState = PDDATA; + break; + case PDDATA: /* Process data byte. */ + /* Make space to receive processed data. */ + if (pcrx->inTail == NULL || pcrx->inTail->len == PBUF_POOL_BUFSIZE) { + if (pcrx->inTail != NULL) { + pcrx->inTail->tot_len = pcrx->inTail->len; + if (pcrx->inTail != pcrx->inHead) { + pbuf_cat(pcrx->inHead, pcrx->inTail); + /* give up the inTail reference now */ + pcrx->inTail = NULL; + } + } + /* If we haven't started a packet, we need a packet header. */ + nextNBuf = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); + if (nextNBuf == NULL) { + /* No free buffers. Drop the input packet and let the + * higher layers deal with it. Continue processing + * the received pbuf chain in case a new packet starts. */ + PPPDEBUG(LOG_ERR, ("pppInProc[%d]: NO FREE MBUFS!\n", pcrx->pd)); + LINK_STATS_INC(link.memerr); + pppDrop(pcrx); + pcrx->inState = PDSTART; /* Wait for flag sequence. */ + break; + } + if (pcrx->inHead == NULL) { + struct pppInputHeader *pih = nextNBuf->payload; + + pih->unit = pcrx->pd; + pih->proto = pcrx->inProtocol; + + nextNBuf->len += sizeof(*pih); + + pcrx->inHead = nextNBuf; + } + pcrx->inTail = nextNBuf; + } + /* Load character into buffer. */ + ((u_char*)pcrx->inTail->payload)[pcrx->inTail->len++] = curChar; + break; + } + + /* update the frame check sequence number. */ + pcrx->inFCS = PPP_FCS(pcrx->inFCS, curChar); + } + } /* while (l-- > 0), all bytes processed */ + + avRandomize(); +} +#endif /* PPPOS_SUPPORT */ + +#if PPPOE_SUPPORT +void +pppInProcOverEthernet(int pd, struct pbuf *pb) +{ + struct pppInputHeader *pih; + u16_t inProtocol; + + if(pb->len < sizeof(inProtocol)) { + PPPDEBUG(LOG_ERR, ("pppInProcOverEthernet: too small for protocol field\n")); + goto drop; + } + + inProtocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1]; + + /* make room for pppInputHeader - should not fail */ + if (pbuf_header(pb, sizeof(*pih) - sizeof(inProtocol)) != 0) { + PPPDEBUG(LOG_ERR, ("pppInProcOverEthernet: could not allocate room for header\n")); + goto drop; + } + + pih = pb->payload; + + pih->unit = pd; + pih->proto = inProtocol; + + /* Dispatch the packet thereby consuming it. */ + pppInput(pb); + return; + +drop: + LINK_STATS_INC(link.drop); + snmp_inc_ifindiscards(&pppControl[pd].netif); + pbuf_free(pb); + return; +} +#endif /* PPPOE_SUPPORT */ + +#if LWIP_NETIF_STATUS_CALLBACK +/** Set the status callback of a PPP's netif + * + * @param pd The PPP descriptor returned by pppOpen() + * @param status_callback pointer to the status callback function + * + * @see netif_set_status_callback + */ +void +ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) +{ + netif_set_status_callback(&pppControl[pd].netif, status_callback); +} +#endif /* LWIP_NETIF_STATUS_CALLBACK */ + +#if LWIP_NETIF_LINK_CALLBACK +/** Set the link callback of a PPP's netif + * + * @param pd The PPP descriptor returned by pppOpen() + * @param link_callback pointer to the link callback function + * + * @see netif_set_link_callback + */ +void +ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback) +{ + netif_set_link_callback(&pppControl[pd].netif, link_callback); +} +#endif /* LWIP_NETIF_LINK_CALLBACK */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp.h b/user/mpy/lib/lwip/src/netif/ppp/ppp.h new file mode 100644 index 0000000..08d6e62 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/ppp.h @@ -0,0 +1,201 @@ +/***************************************************************************** +* ppp.h - Network Point to Point Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-11-05 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ + +#ifndef PPP_H +#define PPP_H + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/def.h" +#include "lwip/sio.h" +#include "lwip/stats.h" +#include "lwip/mem.h" +#include "lwip/netif.h" +#include "lwip/sys.h" +#include "lwip/timers.h" + + +#ifndef __u_char_defined + +/* Type definitions for BSD code. */ +typedef unsigned long u_long; +typedef unsigned int u_int; +typedef unsigned short u_short; +typedef unsigned char u_char; + +#endif + + +/************************* +*** PUBLIC DEFINITIONS *** +*************************/ + +/* Error codes. */ +#define PPPERR_NONE 0 /* No error. */ +#define PPPERR_PARAM -1 /* Invalid parameter. */ +#define PPPERR_OPEN -2 /* Unable to open PPP session. */ +#define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */ +#define PPPERR_ALLOC -4 /* Unable to allocate resources. */ +#define PPPERR_USER -5 /* User interrupt. */ +#define PPPERR_CONNECT -6 /* Connection lost. */ +#define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */ +#define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */ + +/* + * PPP IOCTL commands. + */ +/* + * Get the up status - 0 for down, non-zero for up. The argument must + * point to an int. + */ +#define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */ +#define PPPCTLS_ERRCODE 101 /* Set the error code */ +#define PPPCTLG_ERRCODE 102 /* Get the error code */ +#define PPPCTLG_FD 103 /* Get the fd associated with the ppp */ + +/************************ +*** PUBLIC DATA TYPES *** +************************/ + +struct ppp_addrs { + ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2; +}; + + +/*********************** +*** PUBLIC FUNCTIONS *** +***********************/ + +/* Initialize the PPP subsystem. */ +void pppInit(void); + +/* Warning: Using PPPAUTHTYPE_ANY might have security consequences. + * RFC 1994 says: + * + * In practice, within or associated with each PPP server, there is a + * database which associates "user" names with authentication + * information ("secrets"). It is not anticipated that a particular + * named user would be authenticated by multiple methods. This would + * make the user vulnerable to attacks which negotiate the least secure + * method from among a set (such as PAP rather than CHAP). If the same + * secret was used, PAP would reveal the secret to be used later with + * CHAP. + * + * Instead, for each user name there should be an indication of exactly + * one method used to authenticate that user name. If a user needs to + * make use of different authentication methods under different + * circumstances, then distinct user names SHOULD be employed, each of + * which identifies exactly one authentication method. + * + */ +enum pppAuthType { + PPPAUTHTYPE_NONE, + PPPAUTHTYPE_ANY, + PPPAUTHTYPE_PAP, + PPPAUTHTYPE_CHAP +}; + +void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd); + +/* Link status callback function prototype */ +typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg); + +#if PPPOS_SUPPORT +/* + * Open a new PPP connection using the given serial I/O device. + * This initializes the PPP control block but does not + * attempt to negotiate the LCP session. + * Return a new PPP connection descriptor on success or + * an error code (negative) on failure. + */ +int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx); +#endif /* PPPOS_SUPPORT */ + +#if PPPOE_SUPPORT +/* + * Open a new PPP Over Ethernet (PPPOE) connection. + */ +int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, + pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx); +#endif /* PPPOE_SUPPORT */ + +/* for source code compatibility */ +#define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls) + +/* + * Close a PPP connection and release the descriptor. + * Any outstanding packets in the queues are dropped. + * Return 0 on success, an error code on failure. + */ +int pppClose(int pd); + +/* + * Indicate to the PPP process that the line has disconnected. + */ +void pppSigHUP(int pd); + +/* + * Get and set parameters for the given connection. + * Return 0 on success, an error code on failure. + */ +int pppIOCtl(int pd, int cmd, void *arg); + +/* + * Return the Maximum Transmission Unit for the given PPP connection. + */ +u_short pppMTU(int pd); + +#if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD +/* + * PPP over Serial: this is the input function to be called for received data. + * If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking + * sio_read() is used, so this is deactivated. + */ +void pppos_input(int pd, u_char* data, int len); +#endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */ + + +#if LWIP_NETIF_STATUS_CALLBACK +/* Set an lwIP-style status-callback for the selected PPP device */ +void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback); +#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#if LWIP_NETIF_LINK_CALLBACK +/* Set an lwIP-style link-callback for the selected PPP device */ +void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback); +#endif /* LWIP_NETIF_LINK_CALLBACK */ + +#endif /* PPP_SUPPORT */ + +#endif /* PPP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h b/user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h new file mode 100644 index 0000000..89aea60 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h @@ -0,0 +1,363 @@ +/***************************************************************************** +* ppp.h - Network Point to Point Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-11-05 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ + +#ifndef PPP_IMPL_H +#define PPP_IMPL_H + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp.h" +#include "lwip/def.h" +#include "lwip/sio.h" +#include "lwip/stats.h" +#include "lwip/mem.h" +#include "lwip/netif.h" +#include "lwip/sys.h" +#include "lwip/timers.h" + +/** Some defines for code we skip compared to the original pppd. + * These are just here to minimise the use of the ugly "#if 0". */ +#define PPP_ADDITIONAL_CALLBACKS 0 + +/** Some error checks to test for unsupported code */ +#if CBCP_SUPPORT +#error "CBCP is not supported in lwIP PPP" +#endif +#if CCP_SUPPORT +#error "CCP is not supported in lwIP PPP" +#endif + +/* + * pppd.h - PPP daemon global declarations. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + */ +/* + * ppp_defs.h - PPP definitions. + * + * Copyright (c) 1994 The Australian National University. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, provided that the above copyright + * notice appears in all copies. This software is provided without any + * warranty, express or implied. The Australian National University + * makes no representations about the suitability of this software for + * any purpose. + * + * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY + * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, + * OR MODIFICATIONS. + */ + +#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0) +#define UNTIMEOUT(f, a) sys_untimeout((f), (a)) + + +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981, and numerous additions. + */ + +/* + * The basic PPP frame. + */ +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ + + +/* + * Significant octet values. + */ +#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ +#define PPP_UI 0x03 /* Unnumbered Information */ +#define PPP_FLAG 0x7e /* Flag Sequence */ +#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ +#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ + +/* + * Protocol field values. + */ +#define PPP_IP 0x21 /* Internet Protocol */ +#define PPP_AT 0x29 /* AppleTalk Protocol */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_COMP 0xfd /* compressed packet */ +#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_LQR 0xc025 /* Link Quality Report protocol */ +#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ +#define PPP_CBCP 0xc029 /* Callback Control Protocol */ + +/* + * Values for FCS calculations. + */ +#define PPP_INITFCS 0xffff /* Initial FCS value */ +#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) + +/* + * Extended asyncmap - allows any character to be escaped. + */ +typedef u_char ext_accm[32]; + +/* + * What to do with network protocol (NP) packets. + */ +enum NPmode { + NPMODE_PASS, /* pass the packet through */ + NPMODE_DROP, /* silently drop the packet */ + NPMODE_ERROR, /* return an error */ + NPMODE_QUEUE /* save it up for later. */ +}; + +/* + * Inline versions of get/put char/short/long. + * Pointer is advanced; we assume that both arguments + * are lvalues and will already be in registers. + * cp MUST be u_char *. + */ +#define GETCHAR(c, cp) { \ + (c) = *(cp)++; \ +} +#define PUTCHAR(c, cp) { \ + *(cp)++ = (u_char) (c); \ +} + + +#define GETSHORT(s, cp) { \ + (s) = *(cp); (cp)++; (s) <<= 8; \ + (s) |= *(cp); (cp)++; \ +} +#define PUTSHORT(s, cp) { \ + *(cp)++ = (u_char) ((s) >> 8); \ + *(cp)++ = (u_char) (s & 0xff); \ +} + +#define GETLONG(l, cp) { \ + (l) = *(cp); (cp)++; (l) <<= 8; \ + (l) |= *(cp); (cp)++; (l) <<= 8; \ + (l) |= *(cp); (cp)++; (l) <<= 8; \ + (l) |= *(cp); (cp)++; \ +} +#define PUTLONG(l, cp) { \ + *(cp)++ = (u_char) ((l) >> 24); \ + *(cp)++ = (u_char) ((l) >> 16); \ + *(cp)++ = (u_char) ((l) >> 8); \ + *(cp)++ = (u_char) (l); \ +} + + +#define INCPTR(n, cp) ((cp) += (n)) +#define DECPTR(n, cp) ((cp) -= (n)) + +#define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l)) +#define BCOPY(s, d, l) MEMCPY((d), (s), (l)) +#define BZERO(s, n) memset(s, 0, n) + +#if PPP_DEBUG +#define PRINTMSG(m, l) { m[l] = '\0'; LWIP_DEBUGF(LOG_INFO, ("Remote message: %s\n", m)); } +#else /* PPP_DEBUG */ +#define PRINTMSG(m, l) +#endif /* PPP_DEBUG */ + +/* + * MAKEHEADER - Add PPP Header fields to a packet. + */ +#define MAKEHEADER(p, t) { \ + PUTCHAR(PPP_ALLSTATIONS, p); \ + PUTCHAR(PPP_UI, p); \ + PUTSHORT(t, p); } + +/************************ +*** PUBLIC DATA TYPES *** +************************/ + +/* + * The following struct gives the addresses of procedures to call + * for a particular protocol. + */ +struct protent { + u_short protocol; /* PPP protocol number */ + /* Initialization procedure */ + void (*init) (int unit); + /* Process a received packet */ + void (*input) (int unit, u_char *pkt, int len); + /* Process a received protocol-reject */ + void (*protrej) (int unit); + /* Lower layer has come up */ + void (*lowerup) (int unit); + /* Lower layer has gone down */ + void (*lowerdown) (int unit); + /* Open the protocol */ + void (*open) (int unit); + /* Close the protocol */ + void (*close) (int unit, char *reason); +#if PPP_ADDITIONAL_CALLBACKS + /* Print a packet in readable form */ + int (*printpkt) (u_char *pkt, int len, + void (*printer) (void *, char *, ...), + void *arg); + /* Process a received data packet */ + void (*datainput) (int unit, u_char *pkt, int len); +#endif /* PPP_ADDITIONAL_CALLBACKS */ + int enabled_flag; /* 0 if protocol is disabled */ + char *name; /* Text name of protocol */ +#if PPP_ADDITIONAL_CALLBACKS + /* Check requested options, assign defaults */ + void (*check_options) (u_long); + /* Configure interface for demand-dial */ + int (*demand_conf) (int unit); + /* Say whether to bring up link for this pkt */ + int (*active_pkt) (u_char *pkt, int len); +#endif /* PPP_ADDITIONAL_CALLBACKS */ +}; + +/* + * The following structure records the time in seconds since + * the last NP packet was sent or received. + */ +struct ppp_idle { + u_short xmit_idle; /* seconds since last NP packet sent */ + u_short recv_idle; /* seconds since last NP packet received */ +}; + +struct ppp_settings { + + u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ + u_int auth_required : 1; /* Peer is required to authenticate */ + u_int explicit_remote : 1; /* remote_name specified with remotename opt */ + u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */ + u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */ + u_int usehostname : 1; /* Use hostname for our_name */ + u_int usepeerdns : 1; /* Ask peer for DNS adds */ + + u_short idle_time_limit; /* Shut down link if idle for this long */ + int maxconnect; /* Maximum connect time (seconds) */ + + char user [MAXNAMELEN + 1]; /* Username for PAP */ + char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ + char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */ + char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ +}; + +/***************************** +*** PUBLIC DATA STRUCTURES *** +*****************************/ + +/* Buffers for outgoing packets. */ +extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; + +extern struct ppp_settings ppp_settings; + +extern struct protent *ppp_protocols[]; /* Table of pointers to supported protocols */ + + +/*********************** +*** PUBLIC FUNCTIONS *** +***********************/ + +/* + * Write n characters to a ppp link. + * RETURN: >= 0 Number of characters written, -1 Failed to write to device. + */ +int pppWrite(int pd, const u_char *s, int n); + +void pppInProcOverEthernet(int pd, struct pbuf *pb); + +struct pbuf *pppSingleBuf(struct pbuf *p); + +void pppLinkTerminated(int pd); + +void pppLinkDown(int pd); + +/* Configure i/f transmit parameters */ +void ppp_send_config (int, u16_t, u32_t, int, int); +/* Set extended transmit ACCM */ +void ppp_set_xaccm (int, ext_accm *); +/* Configure i/f receive parameters */ +void ppp_recv_config (int, int, u32_t, int, int); +/* Find out how long link has been idle */ +int get_idle_time (int, struct ppp_idle *); + +/* Configure VJ TCP header compression */ +int sifvjcomp (int, int, u8_t, u8_t); +/* Configure i/f down (for IP) */ +int sifup (int); +/* Set mode for handling packets for proto */ +int sifnpmode (int u, int proto, enum NPmode mode); +/* Configure i/f down (for IP) */ +int sifdown (int); +/* Configure IP addresses for i/f */ +int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t); +/* Reset i/f IP addresses */ +int cifaddr (int, u32_t, u32_t); +/* Create default route through i/f */ +int sifdefaultroute (int, u32_t, u32_t); +/* Delete default route through i/f */ +int cifdefaultroute (int, u32_t, u32_t); + +/* Get appropriate netmask for address */ +u32_t GetMask (u32_t); + +#endif /* PPP_SUPPORT */ + +#endif /* PPP_IMPL_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c b/user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c new file mode 100644 index 0000000..fdf52ae --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c @@ -0,0 +1,1132 @@ +/***************************************************************************** +* ppp_oe.c - PPP Over Ethernet implementation for lwIP. +* +* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 06-01-01 Marc Boucher +* Ported to lwIP. +*****************************************************************************/ + + + +/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Martin Husemann . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "lwip/opt.h" + +#if PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "netif/ppp_oe.h" + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "lwip/timers.h" +#include "lwip/memp.h" + +#include +#include + + +/* Add a 16 bit unsigned value to a buffer pointed to by PTR */ +#define PPPOE_ADD_16(PTR, VAL) \ + *(PTR)++ = (u8_t)((VAL) / 256); \ + *(PTR)++ = (u8_t)((VAL) % 256) + +/* Add a complete PPPoE header to the buffer pointed to by PTR */ +#define PPPOE_ADD_HEADER(PTR, CODE, SESS, LEN) \ + *(PTR)++ = PPPOE_VERTYPE; \ + *(PTR)++ = (CODE); \ + PPPOE_ADD_16(PTR, SESS); \ + PPPOE_ADD_16(PTR, LEN) + +#define PPPOE_DISC_TIMEOUT (5*1000) /* base for quick timeout calculation */ +#define PPPOE_SLOW_RETRY (60*1000) /* persistent retry interval */ +#define PPPOE_DISC_MAXPADI 4 /* retry PADI four times (quickly) */ +#define PPPOE_DISC_MAXPADR 2 /* retry PADR twice */ + +#ifdef PPPOE_SERVER +#error "PPPOE_SERVER is not yet supported under lwIP!" +/* from if_spppsubr.c */ +#define IFF_PASSIVE IFF_LINK0 /* wait passively for connection */ +#endif + +#ifndef PPPOE_ERRORSTRING_LEN +#define PPPOE_ERRORSTRING_LEN 64 +#endif +static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN]; + + +/* input routines */ +static void pppoe_dispatch_disc_pkt(struct netif *, struct pbuf *); + +/* management routines */ +static int pppoe_do_disconnect(struct pppoe_softc *); +static void pppoe_abort_connect(struct pppoe_softc *); +static void pppoe_clear_softc(struct pppoe_softc *, const char *); + +/* internal timeout handling */ +static void pppoe_timeout(void *); + +/* sending actual protocol controll packets */ +static err_t pppoe_send_padi(struct pppoe_softc *); +static err_t pppoe_send_padr(struct pppoe_softc *); +#ifdef PPPOE_SERVER +static err_t pppoe_send_pado(struct pppoe_softc *); +static err_t pppoe_send_pads(struct pppoe_softc *); +#endif +static err_t pppoe_send_padt(struct netif *, u_int, const u8_t *); + +/* internal helper functions */ +static struct pppoe_softc * pppoe_find_softc_by_session(u_int, struct netif *); +static struct pppoe_softc * pppoe_find_softc_by_hunique(u8_t *, size_t, struct netif *); + +/** linked list of created pppoe interfaces */ +static struct pppoe_softc *pppoe_softc_list; + +err_t +pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr) +{ + struct pppoe_softc *sc; + + sc = (struct pppoe_softc *)memp_malloc(MEMP_PPPOE_IF); + if (sc == NULL) { + *scptr = NULL; + return ERR_MEM; + } + memset(sc, 0, sizeof(struct pppoe_softc)); + + /* changed to real address later */ + MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); + + sc->sc_pd = pd; + sc->sc_linkStatusCB = linkStatusCB; + sc->sc_ethif = ethif; + + /* put the new interface at the head of the list */ + sc->next = pppoe_softc_list; + pppoe_softc_list = sc; + + *scptr = sc; + + return ERR_OK; +} + +err_t +pppoe_destroy(struct netif *ifp) +{ + struct pppoe_softc *sc, *prev = NULL; + + for (sc = pppoe_softc_list; sc != NULL; prev = sc, sc = sc->next) { + if (sc->sc_ethif == ifp) { + break; + } + } + + if(!(sc && (sc->sc_ethif == ifp))) { + return ERR_IF; + } + + sys_untimeout(pppoe_timeout, sc); + if (prev == NULL) { + /* remove sc from the head of the list */ + pppoe_softc_list = sc->next; + } else { + /* remove sc from the list */ + prev->next = sc->next; + } + +#ifdef PPPOE_TODO + if (sc->sc_concentrator_name) { + mem_free(sc->sc_concentrator_name); + } + if (sc->sc_service_name) { + mem_free(sc->sc_service_name); + } +#endif /* PPPOE_TODO */ + memp_free(MEMP_PPPOE_IF, sc); + + return ERR_OK; +} + +/* + * Find the interface handling the specified session. + * Note: O(number of sessions open), this is a client-side only, mean + * and lean implementation, so number of open sessions typically should + * be 1. + */ +static struct pppoe_softc * +pppoe_find_softc_by_session(u_int session, struct netif *rcvif) +{ + struct pppoe_softc *sc; + + if (session == 0) { + return NULL; + } + + for (sc = pppoe_softc_list; sc != NULL; sc = sc->next) { + if (sc->sc_state == PPPOE_STATE_SESSION + && sc->sc_session == session) { + if (sc->sc_ethif == rcvif) { + return sc; + } else { + return NULL; + } + } + } + return NULL; +} + +/* Check host unique token passed and return appropriate softc pointer, + * or NULL if token is bogus. */ +static struct pppoe_softc * +pppoe_find_softc_by_hunique(u8_t *token, size_t len, struct netif *rcvif) +{ + struct pppoe_softc *sc, *t; + + if (pppoe_softc_list == NULL) { + return NULL; + } + + if (len != sizeof sc) { + return NULL; + } + MEMCPY(&t, token, len); + + for (sc = pppoe_softc_list; sc != NULL; sc = sc->next) { + if (sc == t) { + break; + } + } + + if (sc == NULL) { + PPPDEBUG(LOG_DEBUG, ("pppoe: alien host unique tag, no session found\n")); + return NULL; + } + + /* should be safe to access *sc now */ + if (sc->sc_state < PPPOE_STATE_PADI_SENT || sc->sc_state >= PPPOE_STATE_SESSION) { + printf("%c%c%"U16_F": host unique tag found, but it belongs to a connection in state %d\n", + sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_state); + return NULL; + } + if (sc->sc_ethif != rcvif) { + printf("%c%c%"U16_F": wrong interface, not accepting host unique\n", + sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); + return NULL; + } + return sc; +} + +static void +pppoe_linkstatus_up(struct pppoe_softc *sc) +{ + sc->sc_linkStatusCB(sc->sc_pd, 1); +} + +/* analyze and handle a single received packet while not in session state */ +static void +pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb) +{ + u16_t tag, len; + u16_t session, plen; + struct pppoe_softc *sc; + const char *err_msg; + char devname[6]; + u8_t *ac_cookie; + u16_t ac_cookie_len; +#ifdef PPPOE_SERVER + u8_t *hunique; + size_t hunique_len; +#endif + struct pppoehdr *ph; + struct pppoetag pt; + int off, err, errortag; + struct eth_hdr *ethhdr; + + pb = pppSingleBuf(pb); + + strcpy(devname, "pppoe"); /* as long as we don't know which instance */ + err_msg = NULL; + errortag = 0; + if (pb->len < sizeof(*ethhdr)) { + goto done; + } + ethhdr = (struct eth_hdr *)pb->payload; + off = sizeof(*ethhdr); + + ac_cookie = NULL; + ac_cookie_len = 0; +#ifdef PPPOE_SERVER + hunique = NULL; + hunique_len = 0; +#endif + session = 0; + if (pb->len - off < PPPOE_HEADERLEN) { + printf("pppoe: packet too short: %d\n", pb->len); + goto done; + } + + ph = (struct pppoehdr *) (ethhdr + 1); + if (ph->vertype != PPPOE_VERTYPE) { + printf("pppoe: unknown version/type packet: 0x%x\n", ph->vertype); + goto done; + } + session = ntohs(ph->session); + plen = ntohs(ph->plen); + off += sizeof(*ph); + + if (plen + off > pb->len) { + printf("pppoe: packet content does not fit: data available = %d, packet size = %u\n", + pb->len - off, plen); + goto done; + } + if(pb->tot_len == pb->len) { + pb->tot_len = pb->len = (u16_t)off + plen; /* ignore trailing garbage */ + } + tag = 0; + len = 0; + sc = NULL; + while (off + sizeof(pt) <= pb->len) { + MEMCPY(&pt, (u8_t*)pb->payload + off, sizeof(pt)); + tag = ntohs(pt.tag); + len = ntohs(pt.len); + if (off + sizeof(pt) + len > pb->len) { + printf("pppoe: tag 0x%x len 0x%x is too long\n", tag, len); + goto done; + } + switch (tag) { + case PPPOE_TAG_EOL: + goto breakbreak; + case PPPOE_TAG_SNAME: + break; /* ignored */ + case PPPOE_TAG_ACNAME: + break; /* ignored */ + case PPPOE_TAG_HUNIQUE: + if (sc != NULL) { + break; + } +#ifdef PPPOE_SERVER + hunique = (u8_t*)pb->payload + off + sizeof(pt); + hunique_len = len; +#endif + sc = pppoe_find_softc_by_hunique((u8_t*)pb->payload + off + sizeof(pt), len, netif); + if (sc != NULL) { + snprintf(devname, sizeof(devname), "%c%c%"U16_F, sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); + } + break; + case PPPOE_TAG_ACCOOKIE: + if (ac_cookie == NULL) { + ac_cookie = (u8_t*)pb->payload + off + sizeof(pt); + ac_cookie_len = len; + } + break; + case PPPOE_TAG_SNAME_ERR: + err_msg = "SERVICE NAME ERROR"; + errortag = 1; + break; + case PPPOE_TAG_ACSYS_ERR: + err_msg = "AC SYSTEM ERROR"; + errortag = 1; + break; + case PPPOE_TAG_GENERIC_ERR: + err_msg = "GENERIC ERROR"; + errortag = 1; + break; + } + if (err_msg) { + if (errortag && len) { + u16_t error_len = LWIP_MIN(len, sizeof(pppoe_error_tmp)-1); + strncpy(pppoe_error_tmp, (char*)pb->payload + off + sizeof(pt), error_len); + pppoe_error_tmp[error_len-1] = '\0'; + printf("%s: %s: %s\n", devname, err_msg, pppoe_error_tmp); + } else { + printf("%s: %s\n", devname, err_msg); + } + if (errortag) { + goto done; + } + } + off += sizeof(pt) + len; + } + +breakbreak:; + switch (ph->code) { + case PPPOE_CODE_PADI: +#ifdef PPPOE_SERVER + /* + * got service name, concentrator name, and/or host unique. + * ignore if we have no interfaces with IFF_PASSIVE|IFF_UP. + */ + if (LIST_EMPTY(&pppoe_softc_list)) { + goto done; + } + LIST_FOREACH(sc, &pppoe_softc_list, sc_list) { + if (!(sc->sc_sppp.pp_if.if_flags & IFF_UP)) { + continue; + } + if (!(sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) { + continue; + } + if (sc->sc_state == PPPOE_STATE_INITIAL) { + break; + } + } + if (sc == NULL) { + /* printf("pppoe: free passive interface is not found\n"); */ + goto done; + } + if (hunique) { + if (sc->sc_hunique) { + mem_free(sc->sc_hunique); + } + sc->sc_hunique = mem_malloc(hunique_len); + if (sc->sc_hunique == NULL) { + goto done; + } + sc->sc_hunique_len = hunique_len; + MEMCPY(sc->sc_hunique, hunique, hunique_len); + } + MEMCPY(&sc->sc_dest, eh->ether_shost, sizeof sc->sc_dest); + sc->sc_state = PPPOE_STATE_PADO_SENT; + pppoe_send_pado(sc); + break; +#endif /* PPPOE_SERVER */ + case PPPOE_CODE_PADR: +#ifdef PPPOE_SERVER + /* + * get sc from ac_cookie if IFF_PASSIVE + */ + if (ac_cookie == NULL) { + /* be quiet if there is not a single pppoe instance */ + printf("pppoe: received PADR but not includes ac_cookie\n"); + goto done; + } + sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len, netif); + if (sc == NULL) { + /* be quiet if there is not a single pppoe instance */ + if (!LIST_EMPTY(&pppoe_softc_list)) { + printf("pppoe: received PADR but could not find request for it\n"); + } + goto done; + } + if (sc->sc_state != PPPOE_STATE_PADO_SENT) { + printf("%c%c%"U16_F": received unexpected PADR\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); + goto done; + } + if (hunique) { + if (sc->sc_hunique) { + mem_free(sc->sc_hunique); + } + sc->sc_hunique = mem_malloc(hunique_len); + if (sc->sc_hunique == NULL) { + goto done; + } + sc->sc_hunique_len = hunique_len; + MEMCPY(sc->sc_hunique, hunique, hunique_len); + } + pppoe_send_pads(sc); + sc->sc_state = PPPOE_STATE_SESSION; + pppoe_linkstatus_up(sc); /* notify upper layers */ + break; +#else + /* ignore, we are no access concentrator */ + goto done; +#endif /* PPPOE_SERVER */ + case PPPOE_CODE_PADO: + if (sc == NULL) { + /* be quiet if there is not a single pppoe instance */ + if (pppoe_softc_list != NULL) { + printf("pppoe: received PADO but could not find request for it\n"); + } + goto done; + } + if (sc->sc_state != PPPOE_STATE_PADI_SENT) { + printf("%c%c%"U16_F": received unexpected PADO\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); + goto done; + } + if (ac_cookie) { + sc->sc_ac_cookie_len = ac_cookie_len; + MEMCPY(sc->sc_ac_cookie, ac_cookie, ac_cookie_len); + } + MEMCPY(&sc->sc_dest, ethhdr->src.addr, sizeof(sc->sc_dest.addr)); + sys_untimeout(pppoe_timeout, sc); + sc->sc_padr_retried = 0; + sc->sc_state = PPPOE_STATE_PADR_SENT; + if ((err = pppoe_send_padr(sc)) != 0) { + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADR, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); + } + sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc); + break; + case PPPOE_CODE_PADS: + if (sc == NULL) { + goto done; + } + sc->sc_session = session; + sys_untimeout(pppoe_timeout, sc); + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": session 0x%x connected\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, session)); + sc->sc_state = PPPOE_STATE_SESSION; + pppoe_linkstatus_up(sc); /* notify upper layers */ + break; + case PPPOE_CODE_PADT: + if (sc == NULL) { + goto done; + } + pppoe_clear_softc(sc, "received PADT"); + break; + default: + if(sc) { + printf("%c%c%"U16_F": unknown code (0x%"X16_F") session = 0x%"X16_F"\n", + sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, + (u16_t)ph->code, session); + } else { + printf("pppoe: unknown code (0x%"X16_F") session = 0x%"X16_F"\n", (u16_t)ph->code, session); + } + break; + } + +done: + pbuf_free(pb); + return; +} + +void +pppoe_disc_input(struct netif *netif, struct pbuf *p) +{ + /* avoid error messages if there is not a single pppoe instance */ + if (pppoe_softc_list != NULL) { + pppoe_dispatch_disc_pkt(netif, p); + } else { + pbuf_free(p); + } +} + +void +pppoe_data_input(struct netif *netif, struct pbuf *pb) +{ + u16_t session, plen; + struct pppoe_softc *sc; + struct pppoehdr *ph; +#ifdef PPPOE_TERM_UNKNOWN_SESSIONS + u8_t shost[ETHER_ADDR_LEN]; +#endif + +#ifdef PPPOE_TERM_UNKNOWN_SESSIONS + MEMCPY(shost, ((struct eth_hdr *)pb->payload)->src.addr, sizeof(shost)); +#endif + if (pbuf_header(pb, -(int)sizeof(struct eth_hdr)) != 0) { + /* bail out */ + PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header failed\n")); + LINK_STATS_INC(link.lenerr); + goto drop; + } + + pb = pppSingleBuf (pb); + + if (pb->len <= PPPOE_HEADERLEN) { + printf("pppoe (data): dropping too short packet: %d bytes\n", pb->len); + goto drop; + } + + if (pb->len < sizeof(*ph)) { + printf("pppoe_data_input: could not get PPPoE header\n"); + goto drop; + } + ph = (struct pppoehdr *)pb->payload; + + if (ph->vertype != PPPOE_VERTYPE) { + printf("pppoe (data): unknown version/type packet: 0x%x\n", ph->vertype); + goto drop; + } + if (ph->code != 0) { + goto drop; + } + + session = ntohs(ph->session); + sc = pppoe_find_softc_by_session(session, netif); + if (sc == NULL) { +#ifdef PPPOE_TERM_UNKNOWN_SESSIONS + printf("pppoe: input for unknown session 0x%x, sending PADT\n", session); + pppoe_send_padt(netif, session, shost); +#endif + goto drop; + } + + plen = ntohs(ph->plen); + + if (pbuf_header(pb, -(int)(PPPOE_HEADERLEN)) != 0) { + /* bail out */ + PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n")); + LINK_STATS_INC(link.lenerr); + goto drop; + } + + PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: %c%c%"U16_F": pkthdr.len=%d, pppoe.len=%d\n", + sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, + pb->len, plen)); + + if (pb->len < plen) { + goto drop; + } + + pppInProcOverEthernet(sc->sc_pd, pb); + + return; + +drop: + pbuf_free(pb); +} + +static err_t +pppoe_output(struct pppoe_softc *sc, struct pbuf *pb) +{ + struct eth_hdr *ethhdr; + u16_t etype; + err_t res; + + if (!sc->sc_ethif) { + pbuf_free(pb); + return ERR_IF; + } + + ethhdr = (struct eth_hdr *)pb->payload; + etype = sc->sc_state == PPPOE_STATE_SESSION ? ETHTYPE_PPPOE : ETHTYPE_PPPOEDISC; + ethhdr->type = htons(etype); + MEMCPY(ethhdr->dest.addr, sc->sc_dest.addr, sizeof(ethhdr->dest.addr)); + MEMCPY(ethhdr->src.addr, ((struct eth_addr *)sc->sc_ethif->hwaddr)->addr, sizeof(ethhdr->src.addr)); + + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F" (%x) state=%d, session=0x%x output -> %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F", len=%d\n", + sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, etype, + sc->sc_state, sc->sc_session, + sc->sc_dest.addr[0], sc->sc_dest.addr[1], sc->sc_dest.addr[2], sc->sc_dest.addr[3], sc->sc_dest.addr[4], sc->sc_dest.addr[5], + pb->tot_len)); + + res = sc->sc_ethif->linkoutput(sc->sc_ethif, pb); + + pbuf_free(pb); + + return res; +} + +static err_t +pppoe_send_padi(struct pppoe_softc *sc) +{ + struct pbuf *pb; + u8_t *p; + int len; +#ifdef PPPOE_TODO + int l1 = 0, l2 = 0; /* XXX: gcc */ +#endif /* PPPOE_TODO */ + + if (sc->sc_state >PPPOE_STATE_PADI_SENT) { + PPPDEBUG(LOG_ERR, ("ERROR: pppoe_send_padi in state %d", sc->sc_state)); + } + + /* calculate length of frame (excluding ethernet header + pppoe header) */ + len = 2 + 2 + 2 + 2 + sizeof sc; /* service name tag is required, host unique is send too */ +#ifdef PPPOE_TODO + if (sc->sc_service_name != NULL) { + l1 = (int)strlen(sc->sc_service_name); + len += l1; + } + if (sc->sc_concentrator_name != NULL) { + l2 = (int)strlen(sc->sc_concentrator_name); + len += 2 + 2 + l2; + } +#endif /* PPPOE_TODO */ + LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff", + sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff); + + /* allocate a buffer */ + pb = pbuf_alloc(PBUF_LINK, (u16_t)(sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len), PBUF_RAM); + if (!pb) { + return ERR_MEM; + } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); + + p = (u8_t*)pb->payload + sizeof (struct eth_hdr); + /* fill in pkt */ + PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, (u16_t)len); + PPPOE_ADD_16(p, PPPOE_TAG_SNAME); +#ifdef PPPOE_TODO + if (sc->sc_service_name != NULL) { + PPPOE_ADD_16(p, l1); + MEMCPY(p, sc->sc_service_name, l1); + p += l1; + } else +#endif /* PPPOE_TODO */ + { + PPPOE_ADD_16(p, 0); + } +#ifdef PPPOE_TODO + if (sc->sc_concentrator_name != NULL) { + PPPOE_ADD_16(p, PPPOE_TAG_ACNAME); + PPPOE_ADD_16(p, l2); + MEMCPY(p, sc->sc_concentrator_name, l2); + p += l2; + } +#endif /* PPPOE_TODO */ + PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); + PPPOE_ADD_16(p, sizeof(sc)); + MEMCPY(p, &sc, sizeof sc); + + /* send pkt */ + return pppoe_output(sc, pb); +} + +static void +pppoe_timeout(void *arg) +{ + int retry_wait, err; + struct pppoe_softc *sc = (struct pppoe_softc*)arg; + + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": timeout\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num)); + + switch (sc->sc_state) { + case PPPOE_STATE_PADI_SENT: + /* + * We have two basic ways of retrying: + * - Quick retry mode: try a few times in short sequence + * - Slow retry mode: we already had a connection successfully + * established and will try infinitely (without user + * intervention) + * We only enter slow retry mode if IFF_LINK1 (aka autodial) + * is not set. + */ + + /* initialize for quick retry mode */ + retry_wait = PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried); + + sc->sc_padi_retried++; + if (sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) { +#if 0 + if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) { + /* slow retry mode */ + retry_wait = PPPOE_SLOW_RETRY; + } else +#endif + { + pppoe_abort_connect(sc); + return; + } + } + if ((err = pppoe_send_padi(sc)) != 0) { + sc->sc_padi_retried--; + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to transmit PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); + } + sys_timeout(retry_wait, pppoe_timeout, sc); + break; + + case PPPOE_STATE_PADR_SENT: + sc->sc_padr_retried++; + if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) { + MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); + sc->sc_state = PPPOE_STATE_PADI_SENT; + sc->sc_padr_retried = 0; + if ((err = pppoe_send_padi(sc)) != 0) { + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); + } + sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried), pppoe_timeout, sc); + return; + } + if ((err = pppoe_send_padr(sc)) != 0) { + sc->sc_padr_retried--; + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADR, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); + } + sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc); + break; + case PPPOE_STATE_CLOSING: + pppoe_do_disconnect(sc); + break; + default: + return; /* all done, work in peace */ + } +} + +/* Start a connection (i.e. initiate discovery phase) */ +int +pppoe_connect(struct pppoe_softc *sc) +{ + int err; + + if (sc->sc_state != PPPOE_STATE_INITIAL) { + return EBUSY; + } + +#ifdef PPPOE_SERVER + /* wait PADI if IFF_PASSIVE */ + if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) { + return 0; + } +#endif + /* save state, in case we fail to send PADI */ + sc->sc_state = PPPOE_STATE_PADI_SENT; + sc->sc_padr_retried = 0; + err = pppoe_send_padi(sc); + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); + sys_timeout(PPPOE_DISC_TIMEOUT, pppoe_timeout, sc); + return err; +} + +/* disconnect */ +void +pppoe_disconnect(struct pppoe_softc *sc) +{ + if (sc->sc_state < PPPOE_STATE_SESSION) { + return; + } + /* + * Do not call pppoe_disconnect here, the upper layer state + * machine gets confused by this. We must return from this + * function and defer disconnecting to the timeout handler. + */ + sc->sc_state = PPPOE_STATE_CLOSING; + sys_timeout(20, pppoe_timeout, sc); +} + +static int +pppoe_do_disconnect(struct pppoe_softc *sc) +{ + int err; + + if (sc->sc_state < PPPOE_STATE_SESSION) { + err = EBUSY; + } else { + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num)); + err = pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest); + } + + /* cleanup softc */ + sc->sc_state = PPPOE_STATE_INITIAL; + MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); + sc->sc_ac_cookie_len = 0; +#ifdef PPPOE_SERVER + if (sc->sc_hunique) { + mem_free(sc->sc_hunique); + sc->sc_hunique = NULL; + } + sc->sc_hunique_len = 0; +#endif + sc->sc_session = 0; + + sc->sc_linkStatusCB(sc->sc_pd, 0); /* notify upper layers */ + + return err; +} + +/* Connection attempt aborted */ +static void +pppoe_abort_connect(struct pppoe_softc *sc) +{ + printf("%c%c%"U16_F": could not establish connection\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); + sc->sc_state = PPPOE_STATE_CLOSING; + + sc->sc_linkStatusCB(sc->sc_pd, 0); /* notify upper layers */ + + /* clear connection state */ + MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); + sc->sc_state = PPPOE_STATE_INITIAL; +} + +/* Send a PADR packet */ +static err_t +pppoe_send_padr(struct pppoe_softc *sc) +{ + struct pbuf *pb; + u8_t *p; + size_t len; +#ifdef PPPOE_TODO + size_t l1 = 0; /* XXX: gcc */ +#endif /* PPPOE_TODO */ + + if (sc->sc_state != PPPOE_STATE_PADR_SENT) { + return ERR_CONN; + } + + len = 2 + 2 + 2 + 2 + sizeof(sc); /* service name, host unique */ +#ifdef PPPOE_TODO + if (sc->sc_service_name != NULL) { /* service name tag maybe empty */ + l1 = strlen(sc->sc_service_name); + len += l1; + } +#endif /* PPPOE_TODO */ + if (sc->sc_ac_cookie_len > 0) { + len += 2 + 2 + sc->sc_ac_cookie_len; /* AC cookie */ + } + LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff", + sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff); + pb = pbuf_alloc(PBUF_LINK, (u16_t)(sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len), PBUF_RAM); + if (!pb) { + return ERR_MEM; + } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); + p = (u8_t*)pb->payload + sizeof (struct eth_hdr); + PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len); + PPPOE_ADD_16(p, PPPOE_TAG_SNAME); +#ifdef PPPOE_TODO + if (sc->sc_service_name != NULL) { + PPPOE_ADD_16(p, l1); + MEMCPY(p, sc->sc_service_name, l1); + p += l1; + } else +#endif /* PPPOE_TODO */ + { + PPPOE_ADD_16(p, 0); + } + if (sc->sc_ac_cookie_len > 0) { + PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE); + PPPOE_ADD_16(p, sc->sc_ac_cookie_len); + MEMCPY(p, sc->sc_ac_cookie, sc->sc_ac_cookie_len); + p += sc->sc_ac_cookie_len; + } + PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); + PPPOE_ADD_16(p, sizeof(sc)); + MEMCPY(p, &sc, sizeof sc); + + return pppoe_output(sc, pb); +} + +/* send a PADT packet */ +static err_t +pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest) +{ + struct pbuf *pb; + struct eth_hdr *ethhdr; + err_t res; + u8_t *p; + + pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN, PBUF_RAM); + if (!pb) { + return ERR_MEM; + } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); + + ethhdr = (struct eth_hdr *)pb->payload; + ethhdr->type = PP_HTONS(ETHTYPE_PPPOEDISC); + MEMCPY(ethhdr->dest.addr, dest, sizeof(ethhdr->dest.addr)); + MEMCPY(ethhdr->src.addr, ((struct eth_addr *)outgoing_if->hwaddr)->addr, sizeof(ethhdr->src.addr)); + + p = (u8_t*)(ethhdr + 1); + PPPOE_ADD_HEADER(p, PPPOE_CODE_PADT, session, 0); + + res = outgoing_if->linkoutput(outgoing_if, pb); + + pbuf_free(pb); + + return res; +} + +#ifdef PPPOE_SERVER +static err_t +pppoe_send_pado(struct pppoe_softc *sc) +{ + struct pbuf *pb; + u8_t *p; + size_t len; + + if (sc->sc_state != PPPOE_STATE_PADO_SENT) { + return ERR_CONN; + } + + /* calc length */ + len = 0; + /* include ac_cookie */ + len += 2 + 2 + sizeof(sc); + /* include hunique */ + len += 2 + 2 + sc->sc_hunique_len; + pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM); + if (!pb) { + return ERR_MEM; + } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); + p = (u8_t*)pb->payload + sizeof (struct eth_hdr); + PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, len); + PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE); + PPPOE_ADD_16(p, sizeof(sc)); + MEMCPY(p, &sc, sizeof(sc)); + p += sizeof(sc); + PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); + PPPOE_ADD_16(p, sc->sc_hunique_len); + MEMCPY(p, sc->sc_hunique, sc->sc_hunique_len); + return pppoe_output(sc, pb); +} + +static err_t +pppoe_send_pads(struct pppoe_softc *sc) +{ + struct pbuf *pb; + u8_t *p; + size_t len, l1 = 0; /* XXX: gcc */ + + if (sc->sc_state != PPPOE_STATE_PADO_SENT) { + return ERR_CONN; + } + + sc->sc_session = mono_time.tv_sec % 0xff + 1; + /* calc length */ + len = 0; + /* include hunique */ + len += 2 + 2 + 2 + 2 + sc->sc_hunique_len; /* service name, host unique*/ + if (sc->sc_service_name != NULL) { /* service name tag maybe empty */ + l1 = strlen(sc->sc_service_name); + len += l1; + } + pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM); + if (!pb) { + return ERR_MEM; + } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); + p = (u8_t*)pb->payload + sizeof (struct eth_hdr); + PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, len); + PPPOE_ADD_16(p, PPPOE_TAG_SNAME); + if (sc->sc_service_name != NULL) { + PPPOE_ADD_16(p, l1); + MEMCPY(p, sc->sc_service_name, l1); + p += l1; + } else { + PPPOE_ADD_16(p, 0); + } + PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); + PPPOE_ADD_16(p, sc->sc_hunique_len); + MEMCPY(p, sc->sc_hunique, sc->sc_hunique_len); + return pppoe_output(sc, pb); +} +#endif + +err_t +pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb) +{ + u8_t *p; + size_t len; + + /* are we ready to process data yet? */ + if (sc->sc_state < PPPOE_STATE_SESSION) { + /*sppp_flush(&sc->sc_sppp.pp_if);*/ + pbuf_free(pb); + return ERR_CONN; + } + + len = pb->tot_len; + + /* make room for Ethernet header - should not fail */ + if (pbuf_header(pb, sizeof(struct eth_hdr) + PPPOE_HEADERLEN) != 0) { + /* bail out */ + PPPDEBUG(LOG_ERR, ("pppoe: %c%c%"U16_F": pppoe_xmit: could not allocate room for header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num)); + LINK_STATS_INC(link.lenerr); + pbuf_free(pb); + return ERR_BUF; + } + + p = (u8_t*)pb->payload + sizeof(struct eth_hdr); + PPPOE_ADD_HEADER(p, 0, sc->sc_session, len); + + return pppoe_output(sc, pb); +} + +#if 0 /*def PFIL_HOOKS*/ +static int +pppoe_ifattach_hook(void *arg, struct pbuf **mp, struct netif *ifp, int dir) +{ + struct pppoe_softc *sc; + int s; + + if (mp != (struct pbuf **)PFIL_IFNET_DETACH) { + return 0; + } + + LIST_FOREACH(sc, &pppoe_softc_list, sc_list) { + if (sc->sc_ethif != ifp) { + continue; + } + if (sc->sc_sppp.pp_if.if_flags & IFF_UP) { + sc->sc_sppp.pp_if.if_flags &= ~(IFF_UP|IFF_RUNNING); + printf("%c%c%"U16_F": ethernet interface detached, going down\n", + sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); + } + sc->sc_ethif = NULL; + pppoe_clear_softc(sc, "ethernet interface detached"); + } + + return 0; +} +#endif + +static void +pppoe_clear_softc(struct pppoe_softc *sc, const char *message) +{ + LWIP_UNUSED_ARG(message); + + /* stop timer */ + sys_untimeout(pppoe_timeout, sc); + PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": session 0x%x terminated, %s\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_session, message)); + + /* fix our state */ + sc->sc_state = PPPOE_STATE_INITIAL; + + /* notify upper layers */ + sc->sc_linkStatusCB(sc->sc_pd, 0); + + /* clean up softc */ + MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); + sc->sc_ac_cookie_len = 0; + sc->sc_session = 0; +} + +#endif /* PPPOE_SUPPORT */ + diff --git a/user/mpy/lib/lwip/src/netif/ppp/pppdebug.h b/user/mpy/lib/lwip/src/netif/ppp/pppdebug.h new file mode 100644 index 0000000..8134997 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/pppdebug.h @@ -0,0 +1,73 @@ +/***************************************************************************** +* pppdebug.h - System debugging utilities. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1998 Global Election Systems Inc. +* portions Copyright (c) 2001 by Cognizant Pty Ltd. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY (please don't use tabs!) +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 98-07-29 Guy Lancaster , Global Election Systems Inc. +* Original. +* +***************************************************************************** +*/ +#ifndef PPPDEBUG_H +#define PPPDEBUG_H + +/* Trace levels. */ +#define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) +#define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) +#define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) +#define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) +#define LOG_INFO (PPP_DEBUG) +#define LOG_DETAIL (PPP_DEBUG) +#define LOG_DEBUG (PPP_DEBUG) + + +#define TRACELCP PPP_DEBUG + +#if PPP_DEBUG + +#define AUTHDEBUG(a, b) LWIP_DEBUGF(a, b) +#define IPCPDEBUG(a, b) LWIP_DEBUGF(a, b) +#define UPAPDEBUG(a, b) LWIP_DEBUGF(a, b) +#define LCPDEBUG(a, b) LWIP_DEBUGF(a, b) +#define FSMDEBUG(a, b) LWIP_DEBUGF(a, b) +#define CHAPDEBUG(a, b) LWIP_DEBUGF(a, b) +#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) + +#else /* PPP_DEBUG */ + +#define AUTHDEBUG(a, b) +#define IPCPDEBUG(a, b) +#define UPAPDEBUG(a, b) +#define LCPDEBUG(a, b) +#define FSMDEBUG(a, b) +#define CHAPDEBUG(a, b) +#define PPPDEBUG(a, b) + +#endif /* PPP_DEBUG */ + +#endif /* PPPDEBUG_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/randm.c b/user/mpy/lib/lwip/src/netif/ppp/randm.c new file mode 100644 index 0000000..b736091 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/randm.c @@ -0,0 +1,249 @@ +/***************************************************************************** +* randm.c - Random number generator program file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* Copyright (c) 1998 by Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 98-06-03 Guy Lancaster , Global Election Systems Inc. +* Extracted from avos. +*****************************************************************************/ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "md5.h" +#include "randm.h" + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include + +#if MD5_SUPPORT /* this module depends on MD5 */ +#define RANDPOOLSZ 16 /* Bytes stored in the pool of randomness. */ + +/*****************************/ +/*** LOCAL DATA STRUCTURES ***/ +/*****************************/ +static char randPool[RANDPOOLSZ]; /* Pool of randomness. */ +static long randCount = 0; /* Pseudo-random incrementer */ + + +/***********************************/ +/*** PUBLIC FUNCTION DEFINITIONS ***/ +/***********************************/ +/* + * Initialize the random number generator. + * + * Since this is to be called on power up, we don't have much + * system randomess to work with. Here all we use is the + * real-time clock. We'll accumulate more randomness as soon + * as things start happening. + */ +void +avRandomInit() +{ + avChurnRand(NULL, 0); +} + +/* + * Churn the randomness pool on a random event. Call this early and often + * on random and semi-random system events to build randomness in time for + * usage. For randomly timed events, pass a null pointer and a zero length + * and this will use the system timer and other sources to add randomness. + * If new random data is available, pass a pointer to that and it will be + * included. + * + * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 + */ +void +avChurnRand(char *randData, u32_t randLen) +{ + MD5_CTX md5; + + /* LWIP_DEBUGF(LOG_INFO, ("churnRand: %u@%P\n", randLen, randData)); */ + MD5Init(&md5); + MD5Update(&md5, (u_char *)randPool, sizeof(randPool)); + if (randData) { + MD5Update(&md5, (u_char *)randData, randLen); + } else { + struct { + /* INCLUDE fields for any system sources of randomness */ + char foobar; + } sysData; + + /* Load sysData fields here. */ + MD5Update(&md5, (u_char *)&sysData, sizeof(sysData)); + } + MD5Final((u_char *)randPool, &md5); +/* LWIP_DEBUGF(LOG_INFO, ("churnRand: -> 0\n")); */ +} + +/* + * Use the random pool to generate random data. This degrades to pseudo + * random when used faster than randomness is supplied using churnRand(). + * Note: It's important that there be sufficient randomness in randPool + * before this is called for otherwise the range of the result may be + * narrow enough to make a search feasible. + * + * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 + * + * XXX Why does he not just call churnRand() for each block? Probably + * so that you don't ever publish the seed which could possibly help + * predict future values. + * XXX Why don't we preserve md5 between blocks and just update it with + * randCount each time? Probably there is a weakness but I wish that + * it was documented. + */ +void +avGenRand(char *buf, u32_t bufLen) +{ + MD5_CTX md5; + u_char tmp[16]; + u32_t n; + + while (bufLen > 0) { + n = LWIP_MIN(bufLen, RANDPOOLSZ); + MD5Init(&md5); + MD5Update(&md5, (u_char *)randPool, sizeof(randPool)); + MD5Update(&md5, (u_char *)&randCount, sizeof(randCount)); + MD5Final(tmp, &md5); + randCount++; + MEMCPY(buf, tmp, n); + buf += n; + bufLen -= n; + } +} + +/* + * Return a new random number. + */ +u32_t +avRandom() +{ + u32_t newRand; + + avGenRand((char *)&newRand, sizeof(newRand)); + + return newRand; +} + +#else /* MD5_SUPPORT */ + +/*****************************/ +/*** LOCAL DATA STRUCTURES ***/ +/*****************************/ +static int avRandomized = 0; /* Set when truely randomized. */ +static u32_t avRandomSeed = 0; /* Seed used for random number generation. */ + + +/***********************************/ +/*** PUBLIC FUNCTION DEFINITIONS ***/ +/***********************************/ +/* + * Initialize the random number generator. + * + * Here we attempt to compute a random number seed but even if + * it isn't random, we'll randomize it later. + * + * The current method uses the fields from the real time clock, + * the idle process counter, the millisecond counter, and the + * hardware timer tick counter. When this is invoked + * in startup(), then the idle counter and timer values may + * repeat after each boot and the real time clock may not be + * operational. Thus we call it again on the first random + * event. + */ +void +avRandomInit() +{ +#if 0 + /* Get a pointer into the last 4 bytes of clockBuf. */ + u32_t *lptr1 = (u32_t *)((char *)&clockBuf[3]); + + /* + * Initialize our seed using the real-time clock, the idle + * counter, the millisecond timer, and the hardware timer + * tick counter. The real-time clock and the hardware + * tick counter are the best sources of randomness but + * since the tick counter is only 16 bit (and truncated + * at that), the idle counter and millisecond timer + * (which may be small values) are added to help + * randomize the lower 16 bits of the seed. + */ + readClk(); + avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr + + ppp_mtime() + ((u32_t)TM1 << 16) + TM1; +#else + avRandomSeed += sys_jiffies(); /* XXX */ +#endif + + /* Initialize the Borland random number generator. */ + srand((unsigned)avRandomSeed); +} + +/* + * Randomize our random seed value. Here we use the fact that + * this function is called at *truely random* times by the polling + * and network functions. Here we only get 16 bits of new random + * value but we use the previous value to randomize the other 16 + * bits. + */ +void +avRandomize(void) +{ + static u32_t last_jiffies; + + if (!avRandomized) { + avRandomized = !0; + avRandomInit(); + /* The initialization function also updates the seed. */ + } else { + /* avRandomSeed += (avRandomSeed << 16) + TM1; */ + avRandomSeed += (sys_jiffies() - last_jiffies); /* XXX */ + } + last_jiffies = sys_jiffies(); +} + +/* + * Return a new random number. + * Here we use the Borland rand() function to supply a pseudo random + * number which we make truely random by combining it with our own + * seed which is randomized by truely random events. + * Thus the numbers will be truely random unless there have been no + * operator or network events in which case it will be pseudo random + * seeded by the real time clock. + */ +u32_t +avRandom() +{ + return ((((u32_t)rand() << 16) + rand()) + avRandomSeed); +} + +#endif /* MD5_SUPPORT */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/randm.h b/user/mpy/lib/lwip/src/netif/ppp/randm.h new file mode 100644 index 0000000..a0984b0 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/randm.h @@ -0,0 +1,81 @@ +/***************************************************************************** +* randm.h - Random number generator header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* Copyright (c) 1998 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 98-05-29 Guy Lancaster , Global Election Systems Inc. +* Extracted from avos. +*****************************************************************************/ + +#ifndef RANDM_H +#define RANDM_H + +/*********************** +*** PUBLIC FUNCTIONS *** +***********************/ +/* + * Initialize the random number generator. + */ +void avRandomInit(void); + +/* + * Churn the randomness pool on a random event. Call this early and often + * on random and semi-random system events to build randomness in time for + * usage. For randomly timed events, pass a null pointer and a zero length + * and this will use the system timer and other sources to add randomness. + * If new random data is available, pass a pointer to that and it will be + * included. + */ +void avChurnRand(char *randData, u32_t randLen); + +/* + * Randomize our random seed value. To be called for truely random events + * such as user operations and network traffic. + */ +#if MD5_SUPPORT +#define avRandomize() avChurnRand(NULL, 0) +#else /* MD5_SUPPORT */ +void avRandomize(void); +#endif /* MD5_SUPPORT */ + +/* + * Use the random pool to generate random data. This degrades to pseudo + * random when used faster than randomness is supplied using churnRand(). + * Thus it's important to make sure that the results of this are not + * published directly because one could predict the next result to at + * least some degree. Also, it's important to get a good seed before + * the first use. + */ +void avGenRand(char *buf, u32_t bufLen); + +/* + * Return a new random number. + */ +u32_t avRandom(void); + + +#endif /* RANDM_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/vj.c b/user/mpy/lib/lwip/src/netif/ppp/vj.c new file mode 100644 index 0000000..40fdad1 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/vj.c @@ -0,0 +1,652 @@ +/* + * Routines to compress and uncompess tcp packets (for transmission + * over low speed serial lines. + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: + * Initial distribution. + * + * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au, + * so that the entire packet being decompressed doesn't have + * to be in contiguous memory (just the compressed header). + * + * Modified March 1998 by Guy Lancaster, glanca@gesn.com, + * for a 16 bit processor. + */ + +#include "lwip/opt.h" + +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#include "ppp_impl.h" +#include "pppdebug.h" + +#include "vj.h" + +#include + +#if VJ_SUPPORT + +#if LINK_STATS +#define INCR(counter) ++comp->stats.counter +#else +#define INCR(counter) +#endif + +void +vj_compress_init(struct vjcompress *comp) +{ + register u_char i; + register struct cstate *tstate = comp->tstate; + +#if MAX_SLOTS == 0 + memset((char *)comp, 0, sizeof(*comp)); +#endif + comp->maxSlotIndex = MAX_SLOTS - 1; + comp->compressSlot = 0; /* Disable slot ID compression by default. */ + for (i = MAX_SLOTS - 1; i > 0; --i) { + tstate[i].cs_id = i; + tstate[i].cs_next = &tstate[i - 1]; + } + tstate[0].cs_next = &tstate[MAX_SLOTS - 1]; + tstate[0].cs_id = 0; + comp->last_cs = &tstate[0]; + comp->last_recv = 255; + comp->last_xmit = 255; + comp->flags = VJF_TOSS; +} + + +/* ENCODE encodes a number that is known to be non-zero. ENCODEZ + * checks for zero (since zero has to be encoded in the long, 3 byte + * form). + */ +#define ENCODE(n) { \ + if ((u_short)(n) >= 256) { \ + *cp++ = 0; \ + cp[1] = (u_char)(n); \ + cp[0] = (u_char)((n) >> 8); \ + cp += 2; \ + } else { \ + *cp++ = (u_char)(n); \ + } \ +} +#define ENCODEZ(n) { \ + if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \ + *cp++ = 0; \ + cp[1] = (u_char)(n); \ + cp[0] = (u_char)((n) >> 8); \ + cp += 2; \ + } else { \ + *cp++ = (u_char)(n); \ + } \ +} + +#define DECODEL(f) { \ + if (*cp == 0) {\ + u32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \ + (f) = htonl(tmp); \ + cp += 3; \ + } else { \ + u32_t tmp = ntohl(f) + (u32_t)*cp++; \ + (f) = htonl(tmp); \ + } \ +} + +#define DECODES(f) { \ + if (*cp == 0) {\ + u_short tmp = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \ + (f) = htons(tmp); \ + cp += 3; \ + } else { \ + u_short tmp = ntohs(f) + (u_short)*cp++; \ + (f) = htons(tmp); \ + } \ +} + +#define DECODEU(f) { \ + if (*cp == 0) {\ + (f) = htons(((u_short)cp[1] << 8) | cp[2]); \ + cp += 3; \ + } else { \ + (f) = htons((u_short)*cp++); \ + } \ +} + +/* + * vj_compress_tcp - Attempt to do Van Jacobson header compression on a + * packet. This assumes that nb and comp are not null and that the first + * buffer of the chain contains a valid IP header. + * Return the VJ type code indicating whether or not the packet was + * compressed. + */ +u_int +vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) +{ + register struct ip_hdr *ip = (struct ip_hdr *)pb->payload; + register struct cstate *cs = comp->last_cs->cs_next; + register u_short hlen = IPH_HL(ip); + register struct tcp_hdr *oth; + register struct tcp_hdr *th; + register u_short deltaS, deltaA; + register u_long deltaL; + register u_int changes = 0; + u_char new_seq[16]; + register u_char *cp = new_seq; + + /* + * Check that the packet is IP proto TCP. + */ + if (IPH_PROTO(ip) != IP_PROTO_TCP) { + return (TYPE_IP); + } + + /* + * Bail if this is an IP fragment or if the TCP packet isn't + * `compressible' (i.e., ACK isn't set or some other control bit is + * set). + */ + if ((IPH_OFFSET(ip) & PP_HTONS(0x3fff)) || pb->tot_len < 40) { + return (TYPE_IP); + } + th = (struct tcp_hdr *)&((long *)ip)[hlen]; + if ((TCPH_FLAGS(th) & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK) { + return (TYPE_IP); + } + /* + * Packet is compressible -- we're going to send either a + * COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need + * to locate (or create) the connection state. Special case the + * most recently used connection since it's most likely to be used + * again & we don't have to do any reordering if it's used. + */ + INCR(vjs_packets); + if (!ip_addr_cmp(&ip->src, &cs->cs_ip.src) + || !ip_addr_cmp(&ip->dest, &cs->cs_ip.dest) + || *(long *)th != ((long *)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { + /* + * Wasn't the first -- search for it. + * + * States are kept in a circularly linked list with + * last_cs pointing to the end of the list. The + * list is kept in lru order by moving a state to the + * head of the list whenever it is referenced. Since + * the list is short and, empirically, the connection + * we want is almost always near the front, we locate + * states via linear search. If we don't find a state + * for the datagram, the oldest state is (re-)used. + */ + register struct cstate *lcs; + register struct cstate *lastcs = comp->last_cs; + + do { + lcs = cs; cs = cs->cs_next; + INCR(vjs_searches); + if (ip_addr_cmp(&ip->src, &cs->cs_ip.src) + && ip_addr_cmp(&ip->dest, &cs->cs_ip.dest) + && *(long *)th == ((long *)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { + goto found; + } + } while (cs != lastcs); + + /* + * Didn't find it -- re-use oldest cstate. Send an + * uncompressed packet that tells the other side what + * connection number we're using for this conversation. + * Note that since the state list is circular, the oldest + * state points to the newest and we only need to set + * last_cs to update the lru linkage. + */ + INCR(vjs_misses); + comp->last_cs = lcs; + hlen += TCPH_HDRLEN(th); + hlen <<= 2; + /* Check that the IP/TCP headers are contained in the first buffer. */ + if (hlen > pb->len) { + return (TYPE_IP); + } + goto uncompressed; + + found: + /* + * Found it -- move to the front on the connection list. + */ + if (cs == lastcs) { + comp->last_cs = lcs; + } else { + lcs->cs_next = cs->cs_next; + cs->cs_next = lastcs->cs_next; + lastcs->cs_next = cs; + } + } + + oth = (struct tcp_hdr *)&((long *)&cs->cs_ip)[hlen]; + deltaS = hlen; + hlen += TCPH_HDRLEN(th); + hlen <<= 2; + /* Check that the IP/TCP headers are contained in the first buffer. */ + if (hlen > pb->len) { + PPPDEBUG(LOG_INFO, ("vj_compress_tcp: header len %d spans buffers\n", hlen)); + return (TYPE_IP); + } + + /* + * Make sure that only what we expect to change changed. The first + * line of the `if' checks the IP protocol version, header length & + * type of service. The 2nd line checks the "Don't fragment" bit. + * The 3rd line checks the time-to-live and protocol (the protocol + * check is unnecessary but costless). The 4th line checks the TCP + * header length. The 5th line checks IP options, if any. The 6th + * line checks TCP options, if any. If any of these things are + * different between the previous & current datagram, we send the + * current datagram `uncompressed'. + */ + if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] + || ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] + || ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] + || TCPH_HDRLEN(th) != TCPH_HDRLEN(oth) + || (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) + || (TCPH_HDRLEN(th) > 5 && BCMP(th + 1, oth + 1, (TCPH_HDRLEN(th) - 5) << 2))) { + goto uncompressed; + } + + /* + * Figure out which of the changing fields changed. The + * receiver expects changes in the order: urgent, window, + * ack, seq (the order minimizes the number of temporaries + * needed in this section of code). + */ + if (TCPH_FLAGS(th) & TCP_URG) { + deltaS = ntohs(th->urgp); + ENCODEZ(deltaS); + changes |= NEW_U; + } else if (th->urgp != oth->urgp) { + /* argh! URG not set but urp changed -- a sensible + * implementation should never do this but RFC793 + * doesn't prohibit the change so we have to deal + * with it. */ + goto uncompressed; + } + + if ((deltaS = (u_short)(ntohs(th->wnd) - ntohs(oth->wnd))) != 0) { + ENCODE(deltaS); + changes |= NEW_W; + } + + if ((deltaL = ntohl(th->ackno) - ntohl(oth->ackno)) != 0) { + if (deltaL > 0xffff) { + goto uncompressed; + } + deltaA = (u_short)deltaL; + ENCODE(deltaA); + changes |= NEW_A; + } + + if ((deltaL = ntohl(th->seqno) - ntohl(oth->seqno)) != 0) { + if (deltaL > 0xffff) { + goto uncompressed; + } + deltaS = (u_short)deltaL; + ENCODE(deltaS); + changes |= NEW_S; + } + + switch(changes) { + case 0: + /* + * Nothing changed. If this packet contains data and the + * last one didn't, this is probably a data packet following + * an ack (normal on an interactive connection) and we send + * it compressed. Otherwise it's probably a retransmit, + * retransmitted ack or window probe. Send it uncompressed + * in case the other side missed the compressed version. + */ + if (IPH_LEN(ip) != IPH_LEN(&cs->cs_ip) && + ntohs(IPH_LEN(&cs->cs_ip)) == hlen) { + break; + } + + /* (fall through) */ + + case SPECIAL_I: + case SPECIAL_D: + /* + * actual changes match one of our special case encodings -- + * send packet uncompressed. + */ + goto uncompressed; + + case NEW_S|NEW_A: + if (deltaS == deltaA && deltaS == ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { + /* special case for echoed terminal traffic */ + changes = SPECIAL_I; + cp = new_seq; + } + break; + + case NEW_S: + if (deltaS == ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { + /* special case for data xfer */ + changes = SPECIAL_D; + cp = new_seq; + } + break; + } + + deltaS = (u_short)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip))); + if (deltaS != 1) { + ENCODEZ(deltaS); + changes |= NEW_I; + } + if (TCPH_FLAGS(th) & TCP_PSH) { + changes |= TCP_PUSH_BIT; + } + /* + * Grab the cksum before we overwrite it below. Then update our + * state with this packet's header. + */ + deltaA = ntohs(th->chksum); + BCOPY(ip, &cs->cs_ip, hlen); + + /* + * We want to use the original packet as our compressed packet. + * (cp - new_seq) is the number of bytes we need for compressed + * sequence numbers. In addition we need one byte for the change + * mask, one for the connection id and two for the tcp checksum. + * So, (cp - new_seq) + 4 bytes of header are needed. hlen is how + * many bytes of the original packet to toss so subtract the two to + * get the new packet size. + */ + deltaS = (u_short)(cp - new_seq); + if (!comp->compressSlot || comp->last_xmit != cs->cs_id) { + comp->last_xmit = cs->cs_id; + hlen -= deltaS + 4; + if(pbuf_header(pb, -hlen)){ + /* Can we cope with this failing? Just assert for now */ + LWIP_ASSERT("pbuf_header failed\n", 0); + } + cp = (u_char *)pb->payload; + *cp++ = (u_char)(changes | NEW_C); + *cp++ = cs->cs_id; + } else { + hlen -= deltaS + 3; + if(pbuf_header(pb, -hlen)) { + /* Can we cope with this failing? Just assert for now */ + LWIP_ASSERT("pbuf_header failed\n", 0); + } + cp = (u_char *)pb->payload; + *cp++ = (u_char)changes; + } + *cp++ = (u_char)(deltaA >> 8); + *cp++ = (u_char)deltaA; + BCOPY(new_seq, cp, deltaS); + INCR(vjs_compressed); + return (TYPE_COMPRESSED_TCP); + + /* + * Update connection state cs & send uncompressed packet (that is, + * a regular ip/tcp packet but with the 'conversation id' we hope + * to use on future compressed packets in the protocol field). + */ +uncompressed: + BCOPY(ip, &cs->cs_ip, hlen); + IPH_PROTO_SET(ip, cs->cs_id); + comp->last_xmit = cs->cs_id; + return (TYPE_UNCOMPRESSED_TCP); +} + +/* + * Called when we may have missed a packet. + */ +void +vj_uncompress_err(struct vjcompress *comp) +{ + comp->flags |= VJF_TOSS; + INCR(vjs_errorin); +} + +/* + * "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP. + * Return 0 on success, -1 on failure. + */ +int +vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) +{ + register u_int hlen; + register struct cstate *cs; + register struct ip_hdr *ip; + + ip = (struct ip_hdr *)nb->payload; + hlen = IPH_HL(ip) << 2; + if (IPH_PROTO(ip) >= MAX_SLOTS + || hlen + sizeof(struct tcp_hdr) > nb->len + || (hlen += TCPH_HDRLEN(((struct tcp_hdr *)&((char *)ip)[hlen])) << 2) + > nb->len + || hlen > MAX_HDR) { + PPPDEBUG(LOG_INFO, ("vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n", + IPH_PROTO(ip), hlen, nb->len)); + comp->flags |= VJF_TOSS; + INCR(vjs_errorin); + return -1; + } + cs = &comp->rstate[comp->last_recv = IPH_PROTO(ip)]; + comp->flags &=~ VJF_TOSS; + IPH_PROTO_SET(ip, IP_PROTO_TCP); + BCOPY(ip, &cs->cs_ip, hlen); + cs->cs_hlen = (u_short)hlen; + INCR(vjs_uncompressedin); + return 0; +} + +/* + * Uncompress a packet of type TYPE_COMPRESSED_TCP. + * The packet is composed of a buffer chain and the first buffer + * must contain an accurate chain length. + * The first buffer must include the entire compressed TCP/IP header. + * This procedure replaces the compressed header with the uncompressed + * header and returns the length of the VJ header. + */ +int +vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) +{ + u_char *cp; + struct tcp_hdr *th; + struct cstate *cs; + u_short *bp; + struct pbuf *n0 = *nb; + u32_t tmp; + u_int vjlen, hlen, changes; + + INCR(vjs_compressedin); + cp = (u_char *)n0->payload; + changes = *cp++; + if (changes & NEW_C) { + /* + * Make sure the state index is in range, then grab the state. + * If we have a good state index, clear the 'discard' flag. + */ + if (*cp >= MAX_SLOTS) { + PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: bad cid=%d\n", *cp)); + goto bad; + } + + comp->flags &=~ VJF_TOSS; + comp->last_recv = *cp++; + } else { + /* + * this packet has an implicit state index. If we've + * had a line error since the last time we got an + * explicit state index, we have to toss the packet. + */ + if (comp->flags & VJF_TOSS) { + PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: tossing\n")); + INCR(vjs_tossed); + return (-1); + } + } + cs = &comp->rstate[comp->last_recv]; + hlen = IPH_HL(&cs->cs_ip) << 2; + th = (struct tcp_hdr *)&((u_char *)&cs->cs_ip)[hlen]; + th->chksum = htons((*cp << 8) | cp[1]); + cp += 2; + if (changes & TCP_PUSH_BIT) { + TCPH_SET_FLAG(th, TCP_PSH); + } else { + TCPH_UNSET_FLAG(th, TCP_PSH); + } + + switch (changes & SPECIALS_MASK) { + case SPECIAL_I: + { + register u32_t i = ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; + /* some compilers can't nest inline assembler.. */ + tmp = ntohl(th->ackno) + i; + th->ackno = htonl(tmp); + tmp = ntohl(th->seqno) + i; + th->seqno = htonl(tmp); + } + break; + + case SPECIAL_D: + /* some compilers can't nest inline assembler.. */ + tmp = ntohl(th->seqno) + ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; + th->seqno = htonl(tmp); + break; + + default: + if (changes & NEW_U) { + TCPH_SET_FLAG(th, TCP_URG); + DECODEU(th->urgp); + } else { + TCPH_UNSET_FLAG(th, TCP_URG); + } + if (changes & NEW_W) { + DECODES(th->wnd); + } + if (changes & NEW_A) { + DECODEL(th->ackno); + } + if (changes & NEW_S) { + DECODEL(th->seqno); + } + break; + } + if (changes & NEW_I) { + DECODES(cs->cs_ip._id); + } else { + IPH_ID_SET(&cs->cs_ip, ntohs(IPH_ID(&cs->cs_ip)) + 1); + IPH_ID_SET(&cs->cs_ip, htons(IPH_ID(&cs->cs_ip))); + } + + /* + * At this point, cp points to the first byte of data in the + * packet. Fill in the IP total length and update the IP + * header checksum. + */ + vjlen = (u_short)(cp - (u_char*)n0->payload); + if (n0->len < vjlen) { + /* + * We must have dropped some characters (crc should detect + * this but the old slip framing won't) + */ + PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: head buffer %d too short %d\n", + n0->len, vjlen)); + goto bad; + } + +#if BYTE_ORDER == LITTLE_ENDIAN + tmp = n0->tot_len - vjlen + cs->cs_hlen; + IPH_LEN_SET(&cs->cs_ip, htons((u_short)tmp)); +#else + IPH_LEN_SET(&cs->cs_ip, htons(n0->tot_len - vjlen + cs->cs_hlen)); +#endif + + /* recompute the ip header checksum */ + bp = (u_short *) &cs->cs_ip; + IPH_CHKSUM_SET(&cs->cs_ip, 0); + for (tmp = 0; hlen > 0; hlen -= 2) { + tmp += *bp++; + } + tmp = (tmp & 0xffff) + (tmp >> 16); + tmp = (tmp & 0xffff) + (tmp >> 16); + IPH_CHKSUM_SET(&cs->cs_ip, (u_short)(~tmp)); + + /* Remove the compressed header and prepend the uncompressed header. */ + if(pbuf_header(n0, -((s16_t)(vjlen)))) { + /* Can we cope with this failing? Just assert for now */ + LWIP_ASSERT("pbuf_header failed\n", 0); + goto bad; + } + + if(LWIP_MEM_ALIGN(n0->payload) != n0->payload) { + struct pbuf *np, *q; + u8_t *bufptr; + + np = pbuf_alloc(PBUF_RAW, n0->len + cs->cs_hlen, PBUF_POOL); + if(!np) { + PPPDEBUG(LOG_WARNING, ("vj_uncompress_tcp: realign failed\n")); + goto bad; + } + + if(pbuf_header(np, -cs->cs_hlen)) { + /* Can we cope with this failing? Just assert for now */ + LWIP_ASSERT("pbuf_header failed\n", 0); + goto bad; + } + + bufptr = n0->payload; + for(q = np; q != NULL; q = q->next) { + MEMCPY(q->payload, bufptr, q->len); + bufptr += q->len; + } + + if(n0->next) { + pbuf_chain(np, n0->next); + pbuf_dechain(n0); + } + pbuf_free(n0); + n0 = np; + } + + if(pbuf_header(n0, cs->cs_hlen)) { + struct pbuf *np; + + LWIP_ASSERT("vj_uncompress_tcp: cs->cs_hlen <= PBUF_POOL_BUFSIZE", cs->cs_hlen <= PBUF_POOL_BUFSIZE); + np = pbuf_alloc(PBUF_RAW, cs->cs_hlen, PBUF_POOL); + if(!np) { + PPPDEBUG(LOG_WARNING, ("vj_uncompress_tcp: prepend failed\n")); + goto bad; + } + pbuf_cat(np, n0); + n0 = np; + } + LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen); + MEMCPY(n0->payload, &cs->cs_ip, cs->cs_hlen); + + *nb = n0; + + return vjlen; + +bad: + comp->flags |= VJF_TOSS; + INCR(vjs_errorin); + return (-1); +} + +#endif /* VJ_SUPPORT */ + +#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/vj.h b/user/mpy/lib/lwip/src/netif/ppp/vj.h new file mode 100644 index 0000000..fad1213 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/ppp/vj.h @@ -0,0 +1,156 @@ +/* + * Definitions for tcp compression routines. + * + * $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $ + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: + * - Initial distribution. + */ + +#ifndef VJ_H +#define VJ_H + +#include "lwip/ip.h" +#include "lwip/tcp_impl.h" + +#define MAX_SLOTS 16 /* must be > 2 and < 256 */ +#define MAX_HDR 128 + +/* + * Compressed packet format: + * + * The first octet contains the packet type (top 3 bits), TCP + * 'push' bit, and flags that indicate which of the 4 TCP sequence + * numbers have changed (bottom 5 bits). The next octet is a + * conversation number that associates a saved IP/TCP header with + * the compressed packet. The next two octets are the TCP checksum + * from the original datagram. The next 0 to 15 octets are + * sequence number changes, one change per bit set in the header + * (there may be no changes and there are two special cases where + * the receiver implicitly knows what changed -- see below). + * + * There are 5 numbers which can change (they are always inserted + * in the following order): TCP urgent pointer, window, + * acknowlegement, sequence number and IP ID. (The urgent pointer + * is different from the others in that its value is sent, not the + * change in value.) Since typical use of SLIP links is biased + * toward small packets (see comments on MTU/MSS below), changes + * use a variable length coding with one octet for numbers in the + * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the + * range 256 - 65535 or 0. (If the change in sequence number or + * ack is more than 65535, an uncompressed packet is sent.) + */ + +/* + * Packet types (must not conflict with IP protocol version) + * + * The top nibble of the first octet is the packet type. There are + * three possible types: IP (not proto TCP or tcp with one of the + * control flags set); uncompressed TCP (a normal IP/TCP packet but + * with the 8-bit protocol field replaced by an 8-bit connection id -- + * this type of packet syncs the sender & receiver); and compressed + * TCP (described above). + * + * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and + * is logically part of the 4-bit "changes" field that follows. Top + * three bits are actual packet type. For backward compatibility + * and in the interest of conserving bits, numbers are chosen so the + * IP protocol version number (4) which normally appears in this nibble + * means "IP packet". + */ + +/* packet types */ +#define TYPE_IP 0x40 +#define TYPE_UNCOMPRESSED_TCP 0x70 +#define TYPE_COMPRESSED_TCP 0x80 +#define TYPE_ERROR 0x00 + +/* Bits in first octet of compressed packet */ +#define NEW_C 0x40 /* flag bits for what changed in a packet */ +#define NEW_I 0x20 +#define NEW_S 0x08 +#define NEW_A 0x04 +#define NEW_W 0x02 +#define NEW_U 0x01 + +/* reserved, special-case values of above */ +#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ +#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ +#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) + +#define TCP_PUSH_BIT 0x10 + + +/* + * "state" data for each active tcp conversation on the wire. This is + * basically a copy of the entire IP/TCP header from the last packet + * we saw from the conversation together with a small identifier + * the transmit & receive ends of the line use to locate saved header. + */ +struct cstate { + struct cstate *cs_next; /* next most recently used state (xmit only) */ + u_short cs_hlen; /* size of hdr (receive only) */ + u_char cs_id; /* connection # associated with this state */ + u_char cs_filler; + union { + char csu_hdr[MAX_HDR]; + struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */ + } vjcs_u; +}; +#define cs_ip vjcs_u.csu_ip +#define cs_hdr vjcs_u.csu_hdr + + +struct vjstat { + unsigned long vjs_packets; /* outbound packets */ + unsigned long vjs_compressed; /* outbound compressed packets */ + unsigned long vjs_searches; /* searches for connection state */ + unsigned long vjs_misses; /* times couldn't find conn. state */ + unsigned long vjs_uncompressedin; /* inbound uncompressed packets */ + unsigned long vjs_compressedin; /* inbound compressed packets */ + unsigned long vjs_errorin; /* inbound unknown type packets */ + unsigned long vjs_tossed; /* inbound packets tossed because of error */ +}; + +/* + * all the state data for one serial line (we need one of these per line). + */ +struct vjcompress { + struct cstate *last_cs; /* most recently used tstate */ + u_char last_recv; /* last rcvd conn. id */ + u_char last_xmit; /* last sent conn. id */ + u_short flags; + u_char maxSlotIndex; + u_char compressSlot; /* Flag indicating OK to compress slot ID. */ +#if LINK_STATS + struct vjstat stats; +#endif + struct cstate tstate[MAX_SLOTS]; /* xmit connection states */ + struct cstate rstate[MAX_SLOTS]; /* receive connection states */ +}; + +/* flag values */ +#define VJF_TOSS 1U /* tossing rcvd frames because of input err */ + +extern void vj_compress_init (struct vjcompress *comp); +extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb); +extern void vj_uncompress_err (struct vjcompress *comp); +extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp); +extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp); + +#endif /* VJ_H */ diff --git a/user/mpy/lib/lwip/src/netif/slipif.c b/user/mpy/lib/lwip/src/netif/slipif.c new file mode 100644 index 0000000..2777630 --- /dev/null +++ b/user/mpy/lib/lwip/src/netif/slipif.c @@ -0,0 +1,510 @@ +/** + * @file + * SLIP Interface + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is built upon the file: src/arch/rtxc/netif/sioslip.c + * + * Author: Magnus Ivarsson + * Simon Goldschmidt + * + * Usage: This netif can be used in three ways: + * 1) For NO_SYS==0, an RX thread can be used which blocks on sio_read() + * until data is received. + * 2) In your main loop, call slipif_poll() to check for new RX bytes, + * completed packets are fed into netif->input(). + * 3) Call slipif_received_byte[s]() from your serial RX ISR and + * slipif_process_rxqueue() from your main loop. ISR level decodes + * packets and puts completed packets on a queue which is fed into + * the stack from the main loop (needs SYS_LIGHTWEIGHT_PROT for + * pbuf_alloc to work on ISR level!). + * + */ + +/* + * This is an arch independent SLIP netif. The specific serial hooks must be + * provided by another file. They are sio_open, sio_read/sio_tryread and sio_send + */ + +#include "netif/slipif.h" +#include "lwip/opt.h" + +#if LWIP_HAVE_SLIPIF + +#include "lwip/def.h" +#include "lwip/pbuf.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" +#include "lwip/sio.h" +#include "lwip/sys.h" + +#define SLIP_END 0xC0 /* 0300: start and end of every packet */ +#define SLIP_ESC 0xDB /* 0333: escape start (one byte escaped data follows) */ +#define SLIP_ESC_END 0xDC /* 0334: following escape: original byte is 0xC0 (END) */ +#define SLIP_ESC_ESC 0xDD /* 0335: following escape: original byte is 0xDB (ESC) */ + +/** Maximum packet size that is received by this netif */ +#ifndef SLIP_MAX_SIZE +#define SLIP_MAX_SIZE 1500 +#endif + +/** Define this to the interface speed for SNMP + * (sio_fd is the sio_fd_t returned by sio_open). + * The default value of zero means 'unknown'. + */ +#ifndef SLIP_SIO_SPEED +#define SLIP_SIO_SPEED(sio_fd) 0 +#endif + +enum slipif_recv_state { + SLIP_RECV_NORMAL, + SLIP_RECV_ESCAPE, +}; + +struct slipif_priv { + sio_fd_t sd; + /* q is the whole pbuf chain for a packet, p is the current pbuf in the chain */ + struct pbuf *p, *q; + u8_t state; + u16_t i, recved; +#if SLIP_RX_FROM_ISR + struct pbuf *rxpackets; +#endif +}; + +/** + * Send a pbuf doing the necessary SLIP encapsulation + * + * Uses the serial layer's sio_send() + * + * @param netif the lwip network interface structure for this slipif + * @param p the pbuf chaing packet to send + * @param ipaddr the ip address to send the packet to (not used for slipif) + * @return always returns ERR_OK since the serial layer does not provide return values + */ +err_t +slipif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) +{ + struct slipif_priv *priv; + struct pbuf *q; + u16_t i; + u8_t c; + + LWIP_ASSERT("netif != NULL", (netif != NULL)); + LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); + LWIP_ASSERT("p != NULL", (p != NULL)); + + LWIP_UNUSED_ARG(ipaddr); + + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_output(%"U16_F"): sending %"U16_F" bytes\n", (u16_t)netif->num, p->tot_len)); + priv = netif->state; + + /* Send pbuf out on the serial I/O device. */ + /* Start with packet delimiter. */ + sio_send(SLIP_END, priv->sd); + + for (q = p; q != NULL; q = q->next) { + for (i = 0; i < q->len; i++) { + c = ((u8_t *)q->payload)[i]; + switch (c) { + case SLIP_END: + /* need to escape this byte (0xC0 -> 0xDB, 0xDC) */ + sio_send(SLIP_ESC, priv->sd); + sio_send(SLIP_ESC_END, priv->sd); + break; + case SLIP_ESC: + /* need to escape this byte (0xDB -> 0xDB, 0xDD) */ + sio_send(SLIP_ESC, priv->sd); + sio_send(SLIP_ESC_ESC, priv->sd); + break; + default: + /* normal byte - no need for escaping */ + sio_send(c, priv->sd); + break; + } + } + } + /* End with packet delimiter. */ + sio_send(SLIP_END, priv->sd); + return ERR_OK; +} + +/** + * Handle the incoming SLIP stream character by character + * + * @param netif the lwip network interface structure for this slipif + * @param c received character (multiple calls to this function will + * return a complete packet, NULL is returned before - used for polling) + * @return The IP packet when SLIP_END is received + */ +static struct pbuf* +slipif_rxbyte(struct netif *netif, u8_t c) +{ + struct slipif_priv *priv; + struct pbuf *t; + + LWIP_ASSERT("netif != NULL", (netif != NULL)); + LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); + + priv = netif->state; + + switch (priv->state) { + case SLIP_RECV_NORMAL: + switch (c) { + case SLIP_END: + if (priv->recved > 0) { + /* Received whole packet. */ + /* Trim the pbuf to the size of the received packet. */ + pbuf_realloc(priv->q, priv->recved); + + LINK_STATS_INC(link.recv); + + LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet (%"U16_F" bytes)\n", priv->recved)); + t = priv->q; + priv->p = priv->q = NULL; + priv->i = priv->recved = 0; + return t; + } + return NULL; + case SLIP_ESC: + priv->state = SLIP_RECV_ESCAPE; + return NULL; + } /* end switch (c) */ + break; + case SLIP_RECV_ESCAPE: + /* un-escape END or ESC bytes, leave other bytes + (although that would be a protocol error) */ + switch (c) { + case SLIP_ESC_END: + c = SLIP_END; + break; + case SLIP_ESC_ESC: + c = SLIP_ESC; + break; + } + priv->state = SLIP_RECV_NORMAL; + break; + } /* end switch (priv->state) */ + + /* byte received, packet not yet completely received */ + if (priv->p == NULL) { + /* allocate a new pbuf */ + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n")); + priv->p = pbuf_alloc(PBUF_LINK, (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN), PBUF_POOL); + + if (priv->p == NULL) { + LINK_STATS_INC(link.drop); + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n")); + /* don't process any further since we got no pbuf to receive to */ + return NULL; + } + + if (priv->q != NULL) { + /* 'chain' the pbuf to the existing chain */ + pbuf_cat(priv->q, priv->p); + } else { + /* p is the first pbuf in the chain */ + priv->q = priv->p; + } + } + + /* this automatically drops bytes if > SLIP_MAX_SIZE */ + if ((priv->p != NULL) && (priv->recved <= SLIP_MAX_SIZE)) { + ((u8_t *)priv->p->payload)[priv->i] = c; + priv->recved++; + priv->i++; + if (priv->i >= priv->p->len) { + /* on to the next pbuf */ + priv->i = 0; + if (priv->p->next != NULL && priv->p->next->len > 0) { + /* p is a chain, on to the next in the chain */ + priv->p = priv->p->next; + } else { + /* p is a single pbuf, set it to NULL so next time a new + * pbuf is allocated */ + priv->p = NULL; + } + } + } + return NULL; +} + +/** Like slipif_rxbyte, but passes completed packets to netif->input + * + * @param netif The lwip network interface structure for this slipif + * @param data received character + */ +static void +slipif_rxbyte_input(struct netif *netif, u8_t c) +{ + struct pbuf *p; + p = slipif_rxbyte(netif, c); + if (p != NULL) { + if (netif->input(p, netif) != ERR_OK) { + pbuf_free(p); + } + } +} + +#if SLIP_USE_RX_THREAD +/** + * The SLIP input thread. + * + * Feed the IP layer with incoming packets + * + * @param nf the lwip network interface structure for this slipif + */ +static void +slipif_loop_thread(void *nf) +{ + u8_t c; + struct netif *netif = (struct netif *)nf; + struct slipif_priv *priv = (struct slipif_priv *)netif->state; + + while (1) { + if (sio_read(priv->sd, &c, 1) > 0) { + slipif_rxbyte_input(netif, c); + } + } +} +#endif /* SLIP_USE_RX_THREAD */ + +/** + * SLIP netif initialization + * + * Call the arch specific sio_open and remember + * the opened device in the state field of the netif. + * + * @param netif the lwip network interface structure for this slipif + * @return ERR_OK if serial line could be opened, + * ERR_MEM if no memory could be allocated, + * ERR_IF is serial line couldn't be opened + * + * @note netif->num must contain the number of the serial port to open + * (0 by default). If netif->state is != NULL, it is interpreted as an + * u8_t pointer pointing to the serial port number instead of netif->num. + * + */ +err_t +slipif_init(struct netif *netif) +{ + struct slipif_priv *priv; + u8_t sio_num; + + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num)); + + /* Allocate private data */ + priv = (struct slipif_priv *)mem_malloc(sizeof(struct slipif_priv)); + if (!priv) { + return ERR_MEM; + } + + netif->name[0] = 's'; + netif->name[1] = 'l'; + netif->output = slipif_output; + netif->mtu = SLIP_MAX_SIZE; + netif->flags |= NETIF_FLAG_POINTTOPOINT; + + /* netif->state or netif->num contain the port number */ + if (netif->state != NULL) { + sio_num = *(u8_t*)netif->state; + } else { + sio_num = netif->num; + } + /* Try to open the serial port. */ + priv->sd = sio_open(sio_num); + if (!priv->sd) { + /* Opening the serial port failed. */ + mem_free(priv); + return ERR_IF; + } + + /* Initialize private data */ + priv->p = NULL; + priv->q = NULL; + priv->state = SLIP_RECV_NORMAL; + priv->i = 0; + priv->recved = 0; +#if SLIP_RX_FROM_ISR + priv->rxpackets = NULL; +#endif + + netif->state = priv; + + /* initialize the snmp variables and counters inside the struct netif */ + NETIF_INIT_SNMP(netif, snmp_ifType_slip, SLIP_SIO_SPEED(priv->sd)); + +#if SLIP_USE_RX_THREAD + /* Create a thread to poll the serial line. */ + sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop_thread, netif, + SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO); +#endif /* SLIP_USE_RX_THREAD */ + return ERR_OK; +} + +/** + * Polls the serial device and feeds the IP layer with incoming packets. + * + * @param netif The lwip network interface structure for this slipif + */ +void +slipif_poll(struct netif *netif) +{ + u8_t c; + struct slipif_priv *priv; + + LWIP_ASSERT("netif != NULL", (netif != NULL)); + LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); + + priv = (struct slipif_priv *)netif->state; + + while (sio_tryread(priv->sd, &c, 1) > 0) { + slipif_rxbyte_input(netif, c); + } +} + +#if SLIP_RX_FROM_ISR +/** + * Feeds the IP layer with incoming packets that were receive + * + * @param netif The lwip network interface structure for this slipif + */ +void +slipif_process_rxqueue(struct netif *netif) +{ + struct slipif_priv *priv; + SYS_ARCH_DECL_PROTECT(old_level); + + LWIP_ASSERT("netif != NULL", (netif != NULL)); + LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); + + priv = (struct slipif_priv *)netif->state; + + SYS_ARCH_PROTECT(old_level); + while (priv->rxpackets != NULL) { + struct pbuf *p = priv->rxpackets; +#if SLIP_RX_QUEUE + /* dequeue packet */ + struct pbuf *q = p; + while ((q->len != q->tot_len) && (q->next != NULL)) { + q = q->next; + } + priv->rxpackets = q->next; + q->next = NULL; +#else /* SLIP_RX_QUEUE */ + priv->rxpackets = NULL; +#endif /* SLIP_RX_QUEUE */ + SYS_ARCH_UNPROTECT(old_level); + if (netif->input(p, netif) != ERR_OK) { + pbuf_free(p); + } + SYS_ARCH_PROTECT(old_level); + } +} + +/** Like slipif_rxbyte, but queues completed packets. + * + * @param netif The lwip network interface structure for this slipif + * @param data Received serial byte + */ +static void +slipif_rxbyte_enqueue(struct netif *netif, u8_t data) +{ + struct pbuf *p; + struct slipif_priv *priv = (struct slipif_priv *)netif->state; + SYS_ARCH_DECL_PROTECT(old_level); + + p = slipif_rxbyte(netif, data); + if (p != NULL) { + SYS_ARCH_PROTECT(old_level); + if (priv->rxpackets != NULL) { +#if SLIP_RX_QUEUE + /* queue multiple pbufs */ + struct pbuf *q = p; + while(q->next != NULL) { + q = q->next; + } + q->next = p; + } else { +#else /* SLIP_RX_QUEUE */ + pbuf_free(priv->rxpackets); + } + { +#endif /* SLIP_RX_QUEUE */ + priv->rxpackets = p; + } + SYS_ARCH_UNPROTECT(old_level); + } +} + +/** + * Process a received byte, completed packets are put on a queue that is + * fed into IP through slipif_process_rxqueue(). + * + * This function can be called from ISR if SYS_LIGHTWEIGHT_PROT is enabled. + * + * @param netif The lwip network interface structure for this slipif + * @param data received character + */ +void +slipif_received_byte(struct netif *netif, u8_t data) +{ + LWIP_ASSERT("netif != NULL", (netif != NULL)); + LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); + slipif_rxbyte_enqueue(netif, data); +} + +/** + * Process multiple received byte, completed packets are put on a queue that is + * fed into IP through slipif_process_rxqueue(). + * + * This function can be called from ISR if SYS_LIGHTWEIGHT_PROT is enabled. + * + * @param netif The lwip network interface structure for this slipif + * @param data received character + * @param len Number of received characters + */ +void +slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len) +{ + u8_t i; + u8_t *rxdata = data; + LWIP_ASSERT("netif != NULL", (netif != NULL)); + LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); + + for (i = 0; i < len; i++, rxdata++) { + slipif_rxbyte_enqueue(netif, *rxdata); + } +} +#endif /* SLIP_RX_FROM_ISR */ + +#endif /* LWIP_HAVE_SLIPIF */ diff --git a/user/mpy/lib/lwip/test/unit/core/test_mem.c b/user/mpy/lib/lwip/test/unit/core/test_mem.c new file mode 100644 index 0000000..d3a5d54 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/core/test_mem.c @@ -0,0 +1,73 @@ +#include "test_mem.h" + +#include "lwip/mem.h" +#include "lwip/stats.h" + +#if !LWIP_STATS || !MEM_STATS +#error "This tests needs MEM-statistics enabled" +#endif +#if LWIP_DNS +#error "This test needs DNS turned off (as it mallocs on init)" +#endif + +/* Setups/teardown functions */ + +static void +mem_setup(void) +{ +} + +static void +mem_teardown(void) +{ +} + + +/* Test functions */ + +/** Call mem_malloc, mem_free and mem_trim and check stats */ +START_TEST(test_mem_one) +{ +#define SIZE1 16 +#define SIZE1_2 12 +#define SIZE2 16 + void *p1, *p2; + mem_size_t s1, s2; + LWIP_UNUSED_ARG(_i); + +#if LWIP_DNS + fail("This test needs DNS turned off (as it mallocs on init)"); +#endif + + fail_unless(lwip_stats.mem.used == 0); + + p1 = mem_malloc(SIZE1); + fail_unless(p1 != NULL); + fail_unless(lwip_stats.mem.used >= SIZE1); + s1 = lwip_stats.mem.used; + + p2 = mem_malloc(SIZE2); + fail_unless(p2 != NULL); + fail_unless(lwip_stats.mem.used >= SIZE2 + s1); + s2 = lwip_stats.mem.used; + + mem_trim(p1, SIZE1_2); + + mem_free(p2); + fail_unless(lwip_stats.mem.used <= s2 - SIZE2); + + mem_free(p1); + fail_unless(lwip_stats.mem.used == 0); +} +END_TEST + + +/** Create the suite including all tests for this module */ +Suite * +mem_suite(void) +{ + TFun tests[] = { + test_mem_one + }; + return create_suite("MEM", tests, sizeof(tests)/sizeof(TFun), mem_setup, mem_teardown); +} diff --git a/user/mpy/lib/lwip/test/unit/core/test_mem.h b/user/mpy/lib/lwip/test/unit/core/test_mem.h new file mode 100644 index 0000000..13803ed --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/core/test_mem.h @@ -0,0 +1,8 @@ +#ifndef __TEST_MEM_H__ +#define __TEST_MEM_H__ + +#include "../lwip_check.h" + +Suite *mem_suite(void); + +#endif diff --git a/user/mpy/lib/lwip/test/unit/etharp/test_etharp.c b/user/mpy/lib/lwip/test/unit/etharp/test_etharp.c new file mode 100644 index 0000000..cbbc950 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/etharp/test_etharp.c @@ -0,0 +1,262 @@ +#include "test_etharp.h" + +#include "lwip/udp.h" +#include "netif/etharp.h" +#include "lwip/stats.h" + +#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS || !ETHARP_STATS +#error "This tests needs UDP-, MEMP- and ETHARP-statistics enabled" +#endif +#if !ETHARP_SUPPORT_STATIC_ENTRIES +#error "This test needs ETHARP_SUPPORT_STATIC_ENTRIES enabled" +#endif + +static struct netif test_netif; +static ip_addr_t test_ipaddr, test_netmask, test_gw; +struct eth_addr test_ethaddr = {1,1,1,1,1,1}; +struct eth_addr test_ethaddr2 = {1,1,1,1,1,2}; +struct eth_addr test_ethaddr3 = {1,1,1,1,1,3}; +struct eth_addr test_ethaddr4 = {1,1,1,1,1,4}; +static int linkoutput_ctr; + +/* Helper functions */ +static void +etharp_remove_all(void) +{ + int i; + /* call etharp_tmr often enough to have all entries cleaned */ + for(i = 0; i < 0xff; i++) { + etharp_tmr(); + } +} + +static err_t +default_netif_linkoutput(struct netif *netif, struct pbuf *p) +{ + fail_unless(netif == &test_netif); + fail_unless(p != NULL); + linkoutput_ctr++; + return ERR_OK; +} + +static err_t +default_netif_init(struct netif *netif) +{ + fail_unless(netif != NULL); + netif->linkoutput = default_netif_linkoutput; + netif->output = etharp_output; + netif->mtu = 1500; + netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + netif->hwaddr_len = ETHARP_HWADDR_LEN; + return ERR_OK; +} + +static void +default_netif_add(void) +{ + IP4_ADDR(&test_gw, 192,168,0,1); + IP4_ADDR(&test_ipaddr, 192,168,0,1); + IP4_ADDR(&test_netmask, 255,255,0,0); + + fail_unless(netif_default == NULL); + netif_set_default(netif_add(&test_netif, &test_ipaddr, &test_netmask, + &test_gw, NULL, default_netif_init, NULL)); + netif_set_up(&test_netif); +} + +static void +default_netif_remove(void) +{ + fail_unless(netif_default == &test_netif); + netif_remove(&test_netif); +} + +static void +create_arp_response(ip_addr_t *adr) +{ + int k; + struct eth_hdr *ethhdr; + struct etharp_hdr *etharphdr; + struct pbuf *p = pbuf_alloc(PBUF_RAW, sizeof(struct eth_hdr) + sizeof(struct etharp_hdr), PBUF_RAM); + if(p == NULL) { + FAIL_RET(); + } + ethhdr = (struct eth_hdr*)p->payload; + etharphdr = (struct etharp_hdr*)(ethhdr + 1); + + ethhdr->dest = test_ethaddr; + ethhdr->src = test_ethaddr2; + ethhdr->type = htons(ETHTYPE_ARP); + + etharphdr->hwtype = htons(/*HWTYPE_ETHERNET*/ 1); + etharphdr->proto = htons(ETHTYPE_IP); + etharphdr->hwlen = ETHARP_HWADDR_LEN; + etharphdr->protolen = sizeof(ip_addr_t); + etharphdr->opcode = htons(ARP_REPLY); + + SMEMCPY(ðarphdr->sipaddr, adr, sizeof(ip_addr_t)); + SMEMCPY(ðarphdr->dipaddr, &test_ipaddr, sizeof(ip_addr_t)); + + k = 6; + while(k > 0) { + k--; + /* Write the ARP MAC-Addresses */ + etharphdr->shwaddr.addr[k] = test_ethaddr2.addr[k]; + etharphdr->dhwaddr.addr[k] = test_ethaddr.addr[k]; + /* Write the Ethernet MAC-Addresses */ + ethhdr->dest.addr[k] = test_ethaddr.addr[k]; + ethhdr->src.addr[k] = test_ethaddr2.addr[k]; + } + + ethernet_input(p, &test_netif); +} + +/* Setups/teardown functions */ + +static void +etharp_setup(void) +{ + etharp_remove_all(); + default_netif_add(); +} + +static void +etharp_teardown(void) +{ + etharp_remove_all(); + default_netif_remove(); +} + + +/* Test functions */ + +START_TEST(test_etharp_table) +{ +#if ETHARP_SUPPORT_STATIC_ENTRIES + err_t err; +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + s8_t idx; + ip_addr_t *unused_ipaddr; + struct eth_addr *unused_ethaddr; + struct udp_pcb* pcb; + LWIP_UNUSED_ARG(_i); + + if (netif_default != &test_netif) { + fail("This test needs a default netif"); + } + + linkoutput_ctr = 0; + + pcb = udp_new(); + fail_unless(pcb != NULL); + if (pcb != NULL) { + ip_addr_t adrs[ARP_TABLE_SIZE + 2]; + int i; + for(i = 0; i < ARP_TABLE_SIZE + 2; i++) { + IP4_ADDR(&adrs[i], 192,168,0,i+2); + } + /* fill ARP-table with dynamic entries */ + for(i = 0; i < ARP_TABLE_SIZE; i++) { + struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, 10, PBUF_RAM); + fail_unless(p != NULL); + if (p != NULL) { + err_t err = udp_sendto(pcb, p, &adrs[i], 123); + fail_unless(err == ERR_OK); + /* etharp request sent? */ + fail_unless(linkoutput_ctr == (2*i) + 1); + pbuf_free(p); + + /* create an ARP response */ + create_arp_response(&adrs[i]); + /* queued UDP packet sent? */ + fail_unless(linkoutput_ctr == (2*i) + 2); + + idx = etharp_find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == i); + etharp_tmr(); + } + } + linkoutput_ctr = 0; +#if ETHARP_SUPPORT_STATIC_ENTRIES + /* create one static entry */ + err = etharp_add_static_entry(&adrs[ARP_TABLE_SIZE], &test_ethaddr3); + fail_unless(err == ERR_OK); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == 0); + fail_unless(linkoutput_ctr == 0); +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + + linkoutput_ctr = 0; + /* fill ARP-table with dynamic entries */ + for(i = 0; i < ARP_TABLE_SIZE; i++) { + struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, 10, PBUF_RAM); + fail_unless(p != NULL); + if (p != NULL) { + err_t err = udp_sendto(pcb, p, &adrs[i], 123); + fail_unless(err == ERR_OK); + /* etharp request sent? */ + fail_unless(linkoutput_ctr == (2*i) + 1); + pbuf_free(p); + + /* create an ARP response */ + create_arp_response(&adrs[i]); + /* queued UDP packet sent? */ + fail_unless(linkoutput_ctr == (2*i) + 2); + + idx = etharp_find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr); + if (i < ARP_TABLE_SIZE - 1) { + fail_unless(idx == i+1); + } else { + /* the last entry must not overwrite the static entry! */ + fail_unless(idx == 1); + } + etharp_tmr(); + } + } +#if ETHARP_SUPPORT_STATIC_ENTRIES + /* create a second static entry */ + err = etharp_add_static_entry(&adrs[ARP_TABLE_SIZE+1], &test_ethaddr4); + fail_unless(err == ERR_OK); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == 0); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == 2); + /* and remove it again */ + err = etharp_remove_static_entry(&adrs[ARP_TABLE_SIZE+1]); + fail_unless(err == ERR_OK); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == 0); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == -1); +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + + /* check that static entries don't time out */ + etharp_remove_all(); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == 0); + +#if ETHARP_SUPPORT_STATIC_ENTRIES + /* remove the first static entry */ + err = etharp_remove_static_entry(&adrs[ARP_TABLE_SIZE]); + fail_unless(err == ERR_OK); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == -1); + idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr); + fail_unless(idx == -1); +#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ + + udp_remove(pcb); + } +} +END_TEST + + +/** Create the suite including all tests for this module */ +Suite * +etharp_suite(void) +{ + TFun tests[] = { + test_etharp_table + }; + return create_suite("ETHARP", tests, sizeof(tests)/sizeof(TFun), etharp_setup, etharp_teardown); +} diff --git a/user/mpy/lib/lwip/test/unit/etharp/test_etharp.h b/user/mpy/lib/lwip/test/unit/etharp/test_etharp.h new file mode 100644 index 0000000..96e00c3 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/etharp/test_etharp.h @@ -0,0 +1,8 @@ +#ifndef __TEST_ETHARP_H__ +#define __TEST_ETHARP_H__ + +#include "../lwip_check.h" + +Suite* etharp_suite(void); + +#endif diff --git a/user/mpy/lib/lwip/test/unit/lwip_check.h b/user/mpy/lib/lwip/test/unit/lwip_check.h new file mode 100644 index 0000000..e27f55a --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/lwip_check.h @@ -0,0 +1,37 @@ +#ifndef __LWIP_CHECK_H__ +#define __LWIP_CHECK_H__ + +/* Common header file for lwIP unit tests using the check framework */ + +#include +#include +#include + +#define FAIL_RET() do { fail(); return; } while(0) +#define EXPECT(x) fail_unless(x) +#define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0) +#define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) +#define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) + +/** typedef for a function returning a test suite */ +typedef Suite* (suite_getter_fn)(void); + +/** Create a test suite */ +static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown) +{ + size_t i; + Suite *s = suite_create(name); + + for(i = 0; i < num_tests; i++) { + /* Core test case */ + TCase *tc_core = tcase_create("Core"); + if ((setup != NULL) || (teardown != NULL)) { + tcase_add_checked_fixture(tc_core, setup, teardown); + } + tcase_add_test(tc_core, tests[i]); + suite_add_tcase(s, tc_core); + } + return s; +} + +#endif /* __LWIP_CHECK_H__ */ diff --git a/user/mpy/lib/lwip/test/unit/lwip_unittests.c b/user/mpy/lib/lwip/test/unit/lwip_unittests.c new file mode 100644 index 0000000..4f537e6 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/lwip_unittests.c @@ -0,0 +1,45 @@ +#include "lwip_check.h" + +#include "udp/test_udp.h" +#include "tcp/test_tcp.h" +#include "tcp/test_tcp_oos.h" +#include "core/test_mem.h" +#include "etharp/test_etharp.h" + +#include "lwip/init.h" + + +int main() +{ + int number_failed; + SRunner *sr; + size_t i; + suite_getter_fn* suites[] = { + udp_suite, + tcp_suite, + tcp_oos_suite, + mem_suite, + etharp_suite + }; + size_t num = sizeof(suites)/sizeof(void*); + LWIP_ASSERT("No suites defined", num > 0); + + lwip_init(); + + sr = srunner_create((suites[0])()); + for(i = 1; i < num; i++) { + srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); + } + +#ifdef LWIP_UNITTESTS_NOFORK + srunner_set_fork_status(sr, CK_NOFORK); +#endif +#ifdef LWIP_UNITTESTS_FORK + srunner_set_fork_status(sr, CK_FORK); +#endif + + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/user/mpy/lib/lwip/test/unit/lwipopts.h b/user/mpy/lib/lwip/test/unit/lwipopts.h new file mode 100644 index 0000000..88e76d7 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/lwipopts.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ +#ifndef __LWIPOPTS_H__ +#define __LWIPOPTS_H__ + +/* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */ +#define NO_SYS 1 +#define LWIP_NETCONN 0 +#define LWIP_SOCKET 0 + +/* Minimal changes to opt.h required for tcp unit tests: */ +#define MEM_SIZE 16000 +#define TCP_SND_QUEUELEN 40 +#define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN +#define TCP_SND_BUF (12 * TCP_MSS) +#define TCP_WND (10 * TCP_MSS) + +/* Minimal changes to opt.h required for etharp unit tests: */ +#define ETHARP_SUPPORT_STATIC_ENTRIES 1 + +#endif /* __LWIPOPTS_H__ */ diff --git a/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c b/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c new file mode 100644 index 0000000..dd550f1 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c @@ -0,0 +1,294 @@ +#include "tcp_helper.h" + +#include "lwip/tcp_impl.h" +#include "lwip/stats.h" +#include "lwip/pbuf.h" +#include "lwip/inet_chksum.h" + +#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS +#error "This tests needs TCP- and MEMP-statistics enabled" +#endif + +/** Remove all pcbs on the given list. */ +static void +tcp_remove(struct tcp_pcb* pcb_list) +{ + struct tcp_pcb *pcb = pcb_list; + struct tcp_pcb *pcb2; + + while(pcb != NULL) { + pcb2 = pcb; + pcb = pcb->next; + tcp_abort(pcb2); + } +} + +/** Remove all pcbs on listen-, active- and time-wait-list (bound- isn't exported). */ +void +tcp_remove_all(void) +{ + tcp_remove(tcp_listen_pcbs.pcbs); + tcp_remove(tcp_active_pcbs); + tcp_remove(tcp_tw_pcbs); + fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0); + fail_unless(lwip_stats.memp[MEMP_TCP_PCB_LISTEN].used == 0); + fail_unless(lwip_stats.memp[MEMP_TCP_SEG].used == 0); + fail_unless(lwip_stats.memp[MEMP_PBUF_POOL].used == 0); +} + +/** Create a TCP segment usable for passing to tcp_input */ +static struct pbuf* +tcp_create_segment_wnd(ip_addr_t* src_ip, ip_addr_t* dst_ip, + u16_t src_port, u16_t dst_port, void* data, size_t data_len, + u32_t seqno, u32_t ackno, u8_t headerflags, u16_t wnd) +{ + struct pbuf *p, *q; + struct ip_hdr* iphdr; + struct tcp_hdr* tcphdr; + u16_t pbuf_len = (u16_t)(sizeof(struct ip_hdr) + sizeof(struct tcp_hdr) + data_len); + + p = pbuf_alloc(PBUF_RAW, pbuf_len, PBUF_POOL); + EXPECT_RETNULL(p != NULL); + /* first pbuf must be big enough to hold the headers */ + EXPECT_RETNULL(p->len >= (sizeof(struct ip_hdr) + sizeof(struct tcp_hdr))); + if (data_len > 0) { + /* first pbuf must be big enough to hold at least 1 data byte, too */ + EXPECT_RETNULL(p->len > (sizeof(struct ip_hdr) + sizeof(struct tcp_hdr))); + } + + for(q = p; q != NULL; q = q->next) { + memset(q->payload, 0, q->len); + } + + iphdr = p->payload; + /* fill IP header */ + iphdr->dest.addr = dst_ip->addr; + iphdr->src.addr = src_ip->addr; + IPH_VHL_SET(iphdr, 4, IP_HLEN / 4); + IPH_TOS_SET(iphdr, 0); + IPH_LEN_SET(iphdr, htons(p->tot_len)); + IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); + + /* let p point to TCP header */ + pbuf_header(p, -(s16_t)sizeof(struct ip_hdr)); + + tcphdr = p->payload; + tcphdr->src = htons(src_port); + tcphdr->dest = htons(dst_port); + tcphdr->seqno = htonl(seqno); + tcphdr->ackno = htonl(ackno); + TCPH_HDRLEN_SET(tcphdr, sizeof(struct tcp_hdr)/4); + TCPH_FLAGS_SET(tcphdr, headerflags); + tcphdr->wnd = htons(wnd); + + if (data_len > 0) { + /* let p point to TCP data */ + pbuf_header(p, -(s16_t)sizeof(struct tcp_hdr)); + /* copy data */ + pbuf_take(p, data, data_len); + /* let p point to TCP header again */ + pbuf_header(p, sizeof(struct tcp_hdr)); + } + + /* calculate checksum */ + + tcphdr->chksum = inet_chksum_pseudo(p, src_ip, dst_ip, + IP_PROTO_TCP, p->tot_len); + + pbuf_header(p, sizeof(struct ip_hdr)); + + return p; +} + +/** Create a TCP segment usable for passing to tcp_input */ +struct pbuf* +tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, + u16_t src_port, u16_t dst_port, void* data, size_t data_len, + u32_t seqno, u32_t ackno, u8_t headerflags) +{ + return tcp_create_segment_wnd(src_ip, dst_ip, src_port, dst_port, data, + data_len, seqno, ackno, headerflags, TCP_WND); +} + +/** Create a TCP segment usable for passing to tcp_input + * - IP-addresses, ports, seqno and ackno are taken from pcb + * - seqno and ackno can be altered with an offset + */ +struct pbuf* +tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, u32_t seqno_offset, + u32_t ackno_offset, u8_t headerflags) +{ + return tcp_create_segment(&pcb->remote_ip, &pcb->local_ip, pcb->remote_port, pcb->local_port, + data, data_len, pcb->rcv_nxt + seqno_offset, pcb->lastack + ackno_offset, headerflags); +} + +/** Create a TCP segment usable for passing to tcp_input + * - IP-addresses, ports, seqno and ackno are taken from pcb + * - seqno and ackno can be altered with an offset + * - TCP window can be adjusted + */ +struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, + u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd) +{ + return tcp_create_segment_wnd(&pcb->remote_ip, &pcb->local_ip, pcb->remote_port, pcb->local_port, + data, data_len, pcb->rcv_nxt + seqno_offset, pcb->lastack + ackno_offset, headerflags, wnd); +} + +/** Safely bring a tcp_pcb into the requested state */ +void +tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, + ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port) +{ + /* @todo: are these all states? */ + /* @todo: remove from previous list */ + pcb->state = state; + if (state == ESTABLISHED) { + TCP_REG(&tcp_active_pcbs, pcb); + pcb->local_ip.addr = local_ip->addr; + pcb->local_port = local_port; + pcb->remote_ip.addr = remote_ip->addr; + pcb->remote_port = remote_port; + } else if(state == LISTEN) { + TCP_REG(&tcp_listen_pcbs.pcbs, pcb); + pcb->local_ip.addr = local_ip->addr; + pcb->local_port = local_port; + } else if(state == TIME_WAIT) { + TCP_REG(&tcp_tw_pcbs, pcb); + pcb->local_ip.addr = local_ip->addr; + pcb->local_port = local_port; + pcb->remote_ip.addr = remote_ip->addr; + pcb->remote_port = remote_port; + } else { + fail(); + } +} + +void +test_tcp_counters_err(void* arg, err_t err) +{ + struct test_tcp_counters* counters = arg; + EXPECT_RET(arg != NULL); + counters->err_calls++; + counters->last_err = err; +} + +static void +test_tcp_counters_check_rxdata(struct test_tcp_counters* counters, struct pbuf* p) +{ + struct pbuf* q; + u32_t i, received; + if(counters->expected_data == NULL) { + /* no data to compare */ + return; + } + EXPECT_RET(counters->recved_bytes + p->tot_len <= counters->expected_data_len); + received = counters->recved_bytes; + for(q = p; q != NULL; q = q->next) { + char *data = q->payload; + for(i = 0; i < q->len; i++) { + EXPECT_RET(data[i] == counters->expected_data[received]); + received++; + } + } + EXPECT(received == counters->recved_bytes + p->tot_len); +} + +err_t +test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err) +{ + struct test_tcp_counters* counters = arg; + EXPECT_RETX(arg != NULL, ERR_OK); + EXPECT_RETX(pcb != NULL, ERR_OK); + EXPECT_RETX(err == ERR_OK, ERR_OK); + + if (p != NULL) { + if (counters->close_calls == 0) { + counters->recv_calls++; + test_tcp_counters_check_rxdata(counters, p); + counters->recved_bytes += p->tot_len; + } else { + counters->recv_calls_after_close++; + counters->recved_bytes_after_close += p->tot_len; + } + pbuf_free(p); + } else { + counters->close_calls++; + } + EXPECT(counters->recv_calls_after_close == 0 && counters->recved_bytes_after_close == 0); + return ERR_OK; +} + +/** Allocate a pcb and set up the test_tcp_counters_* callbacks */ +struct tcp_pcb* +test_tcp_new_counters_pcb(struct test_tcp_counters* counters) +{ + struct tcp_pcb* pcb = tcp_new(); + if (pcb != NULL) { + /* set up args and callbacks */ + tcp_arg(pcb, counters); + tcp_recv(pcb, test_tcp_counters_recv); + tcp_err(pcb, test_tcp_counters_err); + pcb->snd_wnd = TCP_WND; + pcb->snd_wnd_max = TCP_WND; + } + return pcb; +} + +/** Calls tcp_input() after adjusting current_iphdr_dest */ +void test_tcp_input(struct pbuf *p, struct netif *inp) +{ + struct ip_hdr *iphdr = (struct ip_hdr*)p->payload; + ip_addr_copy(current_iphdr_dest, iphdr->dest); + ip_addr_copy(current_iphdr_src, iphdr->src); + current_netif = inp; + current_header = iphdr; + + tcp_input(p, inp); + + current_iphdr_dest.addr = 0; + current_iphdr_src.addr = 0; + current_netif = NULL; + current_header = NULL; +} + +static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p, + ip_addr_t *ipaddr) +{ + struct test_tcp_txcounters *txcounters = (struct test_tcp_txcounters*)netif->state; + LWIP_UNUSED_ARG(ipaddr); + txcounters->num_tx_calls++; + txcounters->num_tx_bytes += p->tot_len; + if (txcounters->copy_tx_packets) { + struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); + err_t err; + EXPECT(p_copy != NULL); + err = pbuf_copy(p_copy, p); + EXPECT(err == ERR_OK); + if (txcounters->tx_packets == NULL) { + txcounters->tx_packets = p_copy; + } else { + pbuf_cat(txcounters->tx_packets, p_copy); + } + } + return ERR_OK; +} + +void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, + ip_addr_t *ip_addr, ip_addr_t *netmask) +{ + struct netif *n; + memset(netif, 0, sizeof(struct netif)); + memset(txcounters, 0, sizeof(struct test_tcp_txcounters)); + netif->output = test_tcp_netif_output; + netif->state = txcounters; + netif->flags |= NETIF_FLAG_UP; + ip_addr_copy(netif->netmask, *netmask); + ip_addr_copy(netif->ip_addr, *ip_addr); + for (n = netif_list; n != NULL; n = n->next) { + if (n == netif) { + return; + } + } + netif->next = NULL; + netif_list = netif; +} diff --git a/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h b/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h new file mode 100644 index 0000000..4a72c93 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h @@ -0,0 +1,52 @@ +#ifndef __TCP_HELPER_H__ +#define __TCP_HELPER_H__ + +#include "../lwip_check.h" +#include "lwip/arch.h" +#include "lwip/tcp.h" +#include "lwip/netif.h" + +/* counters used for test_tcp_counters_* callback functions */ +struct test_tcp_counters { + u32_t recv_calls; + u32_t recved_bytes; + u32_t recv_calls_after_close; + u32_t recved_bytes_after_close; + u32_t close_calls; + u32_t err_calls; + err_t last_err; + char* expected_data; + u32_t expected_data_len; +}; + +struct test_tcp_txcounters { + u32_t num_tx_calls; + u32_t num_tx_bytes; + u8_t copy_tx_packets; + struct pbuf *tx_packets; +}; + +/* Helper functions */ +void tcp_remove_all(void); + +struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, + u16_t src_port, u16_t dst_port, void* data, size_t data_len, + u32_t seqno, u32_t ackno, u8_t headerflags); +struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, + u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags); +struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, + u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd); +void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, + ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port); +void test_tcp_counters_err(void* arg, err_t err); +err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); + +struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters); + +void test_tcp_input(struct pbuf *p, struct netif *inp); + +void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, + ip_addr_t *ip_addr, ip_addr_t *netmask); + + +#endif diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp.c b/user/mpy/lib/lwip/test/unit/tcp/test_tcp.c new file mode 100644 index 0000000..6fd5be5 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/tcp/test_tcp.c @@ -0,0 +1,667 @@ +#include "test_tcp.h" + +#include "lwip/tcp_impl.h" +#include "lwip/stats.h" +#include "tcp_helper.h" + +#ifdef _MSC_VER +#pragma warning(disable: 4307) /* we explicitly wrap around TCP seqnos */ +#endif + +#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS +#error "This tests needs TCP- and MEMP-statistics enabled" +#endif +#if TCP_SND_BUF <= TCP_WND +#error "This tests needs TCP_SND_BUF to be > TCP_WND" +#endif + +static u8_t test_tcp_timer; + +/* our own version of tcp_tmr so we can reset fast/slow timer state */ +static void +test_tcp_tmr(void) +{ + tcp_fasttmr(); + if (++test_tcp_timer & 1) { + tcp_slowtmr(); + } +} + +/* Setups/teardown functions */ + +static void +tcp_setup(void) +{ + /* reset iss to default (6510) */ + tcp_ticks = 0; + tcp_ticks = 0 - (tcp_next_iss() - 6510); + tcp_next_iss(); + tcp_ticks = 0; + + test_tcp_timer = 0; + tcp_remove_all(); +} + +static void +tcp_teardown(void) +{ + netif_list = NULL; + tcp_remove_all(); +} + + +/* Test functions */ + +/** Call tcp_new() and tcp_abort() and test memp stats */ +START_TEST(test_tcp_new_abort) +{ + struct tcp_pcb* pcb; + LWIP_UNUSED_ARG(_i); + + fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0); + + pcb = tcp_new(); + fail_unless(pcb != NULL); + if (pcb != NULL) { + fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0); + } +} +END_TEST + +/** Create an ESTABLISHED pcb and check if receive callback is called */ +START_TEST(test_tcp_recv_inseq) +{ + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf* p; + char data[] = {1, 2, 3, 4}; + ip_addr_t remote_ip, local_ip; + u16_t data_len; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + LWIP_UNUSED_ARG(_i); + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + data_len = sizeof(data); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = data_len; + counters.expected_data = data; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + + /* create a segment */ + p = tcp_create_rx_segment(pcb, counters.expected_data, data_len, 0, 0, 0); + EXPECT(p != NULL); + if (p != NULL) { + /* pass the segment to tcp_input */ + test_tcp_input(p, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 1); + EXPECT(counters.recved_bytes == data_len); + EXPECT(counters.err_calls == 0); + } + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} +END_TEST + +/** Provoke fast retransmission by duplicate ACKs and then recover by ACKing all sent data. + * At the end, send more data. */ +START_TEST(test_tcp_fast_retx_recover) +{ + struct netif netif; + struct test_tcp_txcounters txcounters; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf* p; + char data1[] = { 1, 2, 3, 4}; + char data2[] = { 5, 6, 7, 8}; + char data3[] = { 9, 10, 11, 12}; + char data4[] = {13, 14, 15, 16}; + char data5[] = {17, 18, 19, 20}; + char data6[] = {21, 22, 23, 24}; + ip_addr_t remote_ip, local_ip, netmask; + u16_t remote_port = 0x100, local_port = 0x101; + err_t err; + LWIP_UNUSED_ARG(_i); + + /* initialize local vars */ + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + IP4_ADDR(&netmask, 255, 255, 255, 0); + test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); + memset(&counters, 0, sizeof(counters)); + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->mss = TCP_MSS; + /* disable initial congestion window (we don't send a SYN here...) */ + pcb->cwnd = pcb->snd_wnd; + + /* send data1 */ + err = tcp_write(pcb, data1, sizeof(data1), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + EXPECT_RET(txcounters.num_tx_calls == 1); + EXPECT_RET(txcounters.num_tx_bytes == sizeof(data1) + sizeof(struct tcp_hdr) + sizeof(struct ip_hdr)); + memset(&txcounters, 0, sizeof(txcounters)); + /* "recv" ACK for data1 */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 4, TCP_ACK); + EXPECT_RET(p != NULL); + test_tcp_input(p, &netif); + EXPECT_RET(txcounters.num_tx_calls == 0); + EXPECT_RET(pcb->unacked == NULL); + /* send data2 */ + err = tcp_write(pcb, data2, sizeof(data2), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + EXPECT_RET(txcounters.num_tx_calls == 1); + EXPECT_RET(txcounters.num_tx_bytes == sizeof(data2) + sizeof(struct tcp_hdr) + sizeof(struct ip_hdr)); + memset(&txcounters, 0, sizeof(txcounters)); + /* duplicate ACK for data1 (data2 is lost) */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + EXPECT_RET(p != NULL); + test_tcp_input(p, &netif); + EXPECT_RET(txcounters.num_tx_calls == 0); + EXPECT_RET(pcb->dupacks == 1); + /* send data3 */ + err = tcp_write(pcb, data3, sizeof(data3), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + /* nagle enabled, no tx calls */ + EXPECT_RET(txcounters.num_tx_calls == 0); + EXPECT_RET(txcounters.num_tx_bytes == 0); + memset(&txcounters, 0, sizeof(txcounters)); + /* 2nd duplicate ACK for data1 (data2 and data3 are lost) */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + EXPECT_RET(p != NULL); + test_tcp_input(p, &netif); + EXPECT_RET(txcounters.num_tx_calls == 0); + EXPECT_RET(pcb->dupacks == 2); + /* queue data4, don't send it (unsent-oversize is != 0) */ + err = tcp_write(pcb, data4, sizeof(data4), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + /* 3nd duplicate ACK for data1 (data2 and data3 are lost) -> fast retransmission */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + EXPECT_RET(p != NULL); + test_tcp_input(p, &netif); + /*EXPECT_RET(txcounters.num_tx_calls == 1);*/ + EXPECT_RET(pcb->dupacks == 3); + memset(&txcounters, 0, sizeof(txcounters)); + /* TODO: check expected data?*/ + + /* send data5, not output yet */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + /*err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK);*/ + EXPECT_RET(txcounters.num_tx_calls == 0); + EXPECT_RET(txcounters.num_tx_bytes == 0); + memset(&txcounters, 0, sizeof(txcounters)); + { + int i = 0; + do + { + err = tcp_write(pcb, data6, TCP_MSS, TCP_WRITE_FLAG_COPY); + i++; + }while(err == ERR_OK); + EXPECT_RET(err != ERR_OK); + } + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + /*EXPECT_RET(txcounters.num_tx_calls == 0); + EXPECT_RET(txcounters.num_tx_bytes == 0);*/ + memset(&txcounters, 0, sizeof(txcounters)); + + /* send even more data */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + /* ...and even more data */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + /* ...and even more data */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + /* ...and even more data */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + + /* send ACKs for data2 and data3 */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 12, TCP_ACK); + EXPECT_RET(p != NULL); + test_tcp_input(p, &netif); + /*EXPECT_RET(txcounters.num_tx_calls == 0);*/ + + /* ...and even more data */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + /* ...and even more data */ + err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + +#if 0 + /* create expected segment */ + p1 = tcp_create_rx_segment(pcb, counters.expected_data, data_len, 0, 0, 0); + EXPECT_RET(p != NULL); + if (p != NULL) { + /* pass the segment to tcp_input */ + test_tcp_input(p, &netif); + /* check if counters are as expected */ + EXPECT_RET(counters.close_calls == 0); + EXPECT_RET(counters.recv_calls == 1); + EXPECT_RET(counters.recved_bytes == data_len); + EXPECT_RET(counters.err_calls == 0); + } +#endif + /* make sure the pcb is freed */ + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} +END_TEST + +static u8_t tx_data[TCP_WND*2]; + +static void +check_seqnos(struct tcp_seg *segs, int num_expected, u32_t *seqnos_expected) +{ + struct tcp_seg *s = segs; + int i; + for (i = 0; i < num_expected; i++, s = s->next) { + EXPECT_RET(s != NULL); + EXPECT(s->tcphdr->seqno == htonl(seqnos_expected[i])); + } + EXPECT(s == NULL); +} + +/** Send data with sequence numbers that wrap around the u32_t range. + * Then, provoke fast retransmission by duplicate ACKs and check that all + * segment lists are still properly sorted. */ +START_TEST(test_tcp_fast_rexmit_wraparound) +{ + struct netif netif; + struct test_tcp_txcounters txcounters; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf* p; + ip_addr_t remote_ip, local_ip, netmask; + u16_t remote_port = 0x100, local_port = 0x101; + err_t err; +#define SEQNO1 (0xFFFFFF00 - TCP_MSS) +#define ISS 6510 + u16_t i, sent_total = 0; + u32_t seqnos[] = { + SEQNO1, + SEQNO1 + (1 * TCP_MSS), + SEQNO1 + (2 * TCP_MSS), + SEQNO1 + (3 * TCP_MSS), + SEQNO1 + (4 * TCP_MSS), + SEQNO1 + (5 * TCP_MSS)}; + LWIP_UNUSED_ARG(_i); + + for (i = 0; i < sizeof(tx_data); i++) { + tx_data[i] = (u8_t)i; + } + + /* initialize local vars */ + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + IP4_ADDR(&netmask, 255, 255, 255, 0); + test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); + memset(&counters, 0, sizeof(counters)); + + /* create and initialize the pcb */ + tcp_ticks = SEQNO1 - ISS; + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + EXPECT(pcb->lastack == SEQNO1); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->mss = TCP_MSS; + /* disable initial congestion window (we don't send a SYN here...) */ + pcb->cwnd = 2*TCP_MSS; + + /* send 6 mss-sized segments */ + for (i = 0; i < 6; i++) { + err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + sent_total += TCP_MSS; + } + check_seqnos(pcb->unsent, 6, seqnos); + EXPECT(pcb->unacked == NULL); + err = tcp_output(pcb); + EXPECT(txcounters.num_tx_calls == 2); + EXPECT(txcounters.num_tx_bytes == 2 * (TCP_MSS + 40U)); + memset(&txcounters, 0, sizeof(txcounters)); + + check_seqnos(pcb->unacked, 2, seqnos); + check_seqnos(pcb->unsent, 4, &seqnos[2]); + + /* ACK the first segment */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, TCP_MSS, TCP_ACK); + test_tcp_input(p, &netif); + /* ensure this didn't trigger a retransmission */ + EXPECT(txcounters.num_tx_calls == 1); + EXPECT(txcounters.num_tx_bytes == TCP_MSS + 40U); + memset(&txcounters, 0, sizeof(txcounters)); + check_seqnos(pcb->unacked, 2, &seqnos[1]); + check_seqnos(pcb->unsent, 3, &seqnos[3]); + + /* 3 dupacks */ + EXPECT(pcb->dupacks == 0); + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + test_tcp_input(p, &netif); + EXPECT(txcounters.num_tx_calls == 0); + EXPECT(pcb->dupacks == 1); + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + test_tcp_input(p, &netif); + EXPECT(txcounters.num_tx_calls == 0); + EXPECT(pcb->dupacks == 2); + /* 3rd dupack -> fast rexmit */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + test_tcp_input(p, &netif); + EXPECT(pcb->dupacks == 3); + EXPECT(txcounters.num_tx_calls == 4); + memset(&txcounters, 0, sizeof(txcounters)); + EXPECT(pcb->unsent == NULL); + check_seqnos(pcb->unacked, 5, &seqnos[1]); + + /* make sure the pcb is freed */ + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} +END_TEST + +/** Send data with sequence numbers that wrap around the u32_t range. + * Then, provoke RTO retransmission and check that all + * segment lists are still properly sorted. */ +START_TEST(test_tcp_rto_rexmit_wraparound) +{ + struct netif netif; + struct test_tcp_txcounters txcounters; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + ip_addr_t remote_ip, local_ip, netmask; + u16_t remote_port = 0x100, local_port = 0x101; + err_t err; +#define SEQNO1 (0xFFFFFF00 - TCP_MSS) +#define ISS 6510 + u16_t i, sent_total = 0; + u32_t seqnos[] = { + SEQNO1, + SEQNO1 + (1 * TCP_MSS), + SEQNO1 + (2 * TCP_MSS), + SEQNO1 + (3 * TCP_MSS), + SEQNO1 + (4 * TCP_MSS), + SEQNO1 + (5 * TCP_MSS)}; + LWIP_UNUSED_ARG(_i); + + for (i = 0; i < sizeof(tx_data); i++) { + tx_data[i] = (u8_t)i; + } + + /* initialize local vars */ + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + IP4_ADDR(&netmask, 255, 255, 255, 0); + test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); + memset(&counters, 0, sizeof(counters)); + + /* create and initialize the pcb */ + tcp_ticks = 0; + tcp_ticks = 0 - tcp_next_iss(); + tcp_ticks = SEQNO1 - tcp_next_iss(); + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + EXPECT(pcb->lastack == SEQNO1); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->mss = TCP_MSS; + /* disable initial congestion window (we don't send a SYN here...) */ + pcb->cwnd = 2*TCP_MSS; + + /* send 6 mss-sized segments */ + for (i = 0; i < 6; i++) { + err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + sent_total += TCP_MSS; + } + check_seqnos(pcb->unsent, 6, seqnos); + EXPECT(pcb->unacked == NULL); + err = tcp_output(pcb); + EXPECT(txcounters.num_tx_calls == 2); + EXPECT(txcounters.num_tx_bytes == 2 * (TCP_MSS + 40U)); + memset(&txcounters, 0, sizeof(txcounters)); + + check_seqnos(pcb->unacked, 2, seqnos); + check_seqnos(pcb->unsent, 4, &seqnos[2]); + + /* call the tcp timer some times */ + for (i = 0; i < 10; i++) { + test_tcp_tmr(); + EXPECT(txcounters.num_tx_calls == 0); + } + /* 11th call to tcp_tmr: RTO rexmit fires */ + test_tcp_tmr(); + EXPECT(txcounters.num_tx_calls == 1); + check_seqnos(pcb->unacked, 1, seqnos); + check_seqnos(pcb->unsent, 5, &seqnos[1]); + + /* fake greater cwnd */ + pcb->cwnd = pcb->snd_wnd; + /* send more data */ + err = tcp_output(pcb); + EXPECT(err == ERR_OK); + /* check queues are sorted */ + EXPECT(pcb->unsent == NULL); + check_seqnos(pcb->unacked, 6, seqnos); + + /* make sure the pcb is freed */ + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} +END_TEST + +/** Provoke fast retransmission by duplicate ACKs and then recover by ACKing all sent data. + * At the end, send more data. */ +static void test_tcp_tx_full_window_lost(u8_t zero_window_probe_from_unsent) +{ + struct netif netif; + struct test_tcp_txcounters txcounters; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *p; + ip_addr_t remote_ip, local_ip, netmask; + u16_t remote_port = 0x100, local_port = 0x101; + err_t err; + u16_t sent_total, i; + u8_t expected = 0xFE; + + for (i = 0; i < sizeof(tx_data); i++) { + u8_t d = (u8_t)i; + if (d == 0xFE) { + d = 0xF0; + } + tx_data[i] = d; + } + if (zero_window_probe_from_unsent) { + tx_data[TCP_WND] = expected; + } else { + tx_data[0] = expected; + } + + /* initialize local vars */ + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + IP4_ADDR(&netmask, 255, 255, 255, 0); + test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); + memset(&counters, 0, sizeof(counters)); + memset(&txcounters, 0, sizeof(txcounters)); + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->mss = TCP_MSS; + /* disable initial congestion window (we don't send a SYN here...) */ + pcb->cwnd = pcb->snd_wnd; + + /* send a full window (minus 1 packets) of TCP data in MSS-sized chunks */ + sent_total = 0; + if ((TCP_WND - TCP_MSS) % TCP_MSS != 0) { + u16_t initial_data_len = (TCP_WND - TCP_MSS) % TCP_MSS; + err = tcp_write(pcb, &tx_data[sent_total], initial_data_len, TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + EXPECT(txcounters.num_tx_calls == 1); + EXPECT(txcounters.num_tx_bytes == initial_data_len + 40U); + memset(&txcounters, 0, sizeof(txcounters)); + sent_total += initial_data_len; + } + for (; sent_total < (TCP_WND - TCP_MSS); sent_total += TCP_MSS) { + err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + EXPECT(txcounters.num_tx_calls == 1); + EXPECT(txcounters.num_tx_bytes == TCP_MSS + 40U); + memset(&txcounters, 0, sizeof(txcounters)); + } + EXPECT(sent_total == (TCP_WND - TCP_MSS)); + + /* now ACK the packet before the first */ + p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); + test_tcp_input(p, &netif); + /* ensure this didn't trigger a retransmission */ + EXPECT(txcounters.num_tx_calls == 0); + EXPECT(txcounters.num_tx_bytes == 0); + + EXPECT(pcb->persist_backoff == 0); + /* send the last packet, now a complete window has been sent */ + err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); + sent_total += TCP_MSS; + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + EXPECT(txcounters.num_tx_calls == 1); + EXPECT(txcounters.num_tx_bytes == TCP_MSS + 40U); + memset(&txcounters, 0, sizeof(txcounters)); + EXPECT(pcb->persist_backoff == 0); + + if (zero_window_probe_from_unsent) { + /* ACK all data but close the TX window */ + p = tcp_create_rx_segment_wnd(pcb, NULL, 0, 0, TCP_WND, TCP_ACK, 0); + test_tcp_input(p, &netif); + /* ensure this didn't trigger any transmission */ + EXPECT(txcounters.num_tx_calls == 0); + EXPECT(txcounters.num_tx_bytes == 0); + EXPECT(pcb->persist_backoff == 1); + } + + /* send one byte more (out of window) -> persist timer starts */ + err = tcp_write(pcb, &tx_data[sent_total], 1, TCP_WRITE_FLAG_COPY); + EXPECT_RET(err == ERR_OK); + err = tcp_output(pcb); + EXPECT_RET(err == ERR_OK); + EXPECT(txcounters.num_tx_calls == 0); + EXPECT(txcounters.num_tx_bytes == 0); + memset(&txcounters, 0, sizeof(txcounters)); + if (!zero_window_probe_from_unsent) { + /* no persist timer unless a zero window announcement has been received */ + EXPECT(pcb->persist_backoff == 0); + } else { + EXPECT(pcb->persist_backoff == 1); + + /* call tcp_timer some more times to let persist timer count up */ + for (i = 0; i < 4; i++) { + test_tcp_tmr(); + EXPECT(txcounters.num_tx_calls == 0); + EXPECT(txcounters.num_tx_bytes == 0); + } + + /* this should trigger the zero-window-probe */ + txcounters.copy_tx_packets = 1; + test_tcp_tmr(); + txcounters.copy_tx_packets = 0; + EXPECT(txcounters.num_tx_calls == 1); + EXPECT(txcounters.num_tx_bytes == 1 + 40U); + EXPECT(txcounters.tx_packets != NULL); + if (txcounters.tx_packets != NULL) { + u8_t sent; + u16_t ret; + ret = pbuf_copy_partial(txcounters.tx_packets, &sent, 1, 40U); + EXPECT(ret == 1); + EXPECT(sent == expected); + } + if (txcounters.tx_packets != NULL) { + pbuf_free(txcounters.tx_packets); + txcounters.tx_packets = NULL; + } + } + + /* make sure the pcb is freed */ + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} + +START_TEST(test_tcp_tx_full_window_lost_from_unsent) +{ + LWIP_UNUSED_ARG(_i); + test_tcp_tx_full_window_lost(1); +} +END_TEST + +START_TEST(test_tcp_tx_full_window_lost_from_unacked) +{ + LWIP_UNUSED_ARG(_i); + test_tcp_tx_full_window_lost(0); +} +END_TEST + +/** Create the suite including all tests for this module */ +Suite * +tcp_suite(void) +{ + TFun tests[] = { + test_tcp_new_abort, + test_tcp_recv_inseq, + test_tcp_fast_retx_recover, + test_tcp_fast_rexmit_wraparound, + test_tcp_rto_rexmit_wraparound, + test_tcp_tx_full_window_lost_from_unacked, + test_tcp_tx_full_window_lost_from_unsent + }; + return create_suite("TCP", tests, sizeof(tests)/sizeof(TFun), tcp_setup, tcp_teardown); +} diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp.h b/user/mpy/lib/lwip/test/unit/tcp/test_tcp.h new file mode 100644 index 0000000..f1c4a46 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/tcp/test_tcp.h @@ -0,0 +1,8 @@ +#ifndef __TEST_TCP_H__ +#define __TEST_TCP_H__ + +#include "../lwip_check.h" + +Suite *tcp_suite(void); + +#endif diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c b/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c new file mode 100644 index 0000000..764de1c --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c @@ -0,0 +1,944 @@ +#include "test_tcp_oos.h" + +#include "lwip/tcp_impl.h" +#include "lwip/stats.h" +#include "tcp_helper.h" + +#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS +#error "This tests needs TCP- and MEMP-statistics enabled" +#endif +#if !TCP_QUEUE_OOSEQ +#error "This tests needs TCP_QUEUE_OOSEQ enabled" +#endif + +/** CHECK_SEGMENTS_ON_OOSEQ: + * 1: check count, seqno and len of segments on pcb->ooseq (strict) + * 0: only check that bytes are received in correct order (less strict) */ +#define CHECK_SEGMENTS_ON_OOSEQ 1 + +#if CHECK_SEGMENTS_ON_OOSEQ +#define EXPECT_OOSEQ(x) EXPECT(x) +#else +#define EXPECT_OOSEQ(x) +#endif + +/* helper functions */ + +/** Get the numbers of segments on the ooseq list */ +static int tcp_oos_count(struct tcp_pcb* pcb) +{ + int num = 0; + struct tcp_seg* seg = pcb->ooseq; + while(seg != NULL) { + num++; + seg = seg->next; + } + return num; +} + +/** Get the numbers of pbufs on the ooseq list */ +static int tcp_oos_pbuf_count(struct tcp_pcb* pcb) +{ + int num = 0; + struct tcp_seg* seg = pcb->ooseq; + while(seg != NULL) { + num += pbuf_clen(seg->p); + seg = seg->next; + } + return num; +} + +/** Get the seqno of a segment (by index) on the ooseq list + * + * @param pcb the pcb to check for ooseq segments + * @param seg_index index of the segment on the ooseq list + * @return seqno of the segment + */ +static u32_t +tcp_oos_seg_seqno(struct tcp_pcb* pcb, int seg_index) +{ + int num = 0; + struct tcp_seg* seg = pcb->ooseq; + + /* then check the actual segment */ + while(seg != NULL) { + if(num == seg_index) { + return seg->tcphdr->seqno; + } + num++; + seg = seg->next; + } + fail(); + return 0; +} + +/** Get the tcplen (datalen + SYN/FIN) of a segment (by index) on the ooseq list + * + * @param pcb the pcb to check for ooseq segments + * @param seg_index index of the segment on the ooseq list + * @return tcplen of the segment + */ +static int +tcp_oos_seg_tcplen(struct tcp_pcb* pcb, int seg_index) +{ + int num = 0; + struct tcp_seg* seg = pcb->ooseq; + + /* then check the actual segment */ + while(seg != NULL) { + if(num == seg_index) { + return TCP_TCPLEN(seg); + } + num++; + seg = seg->next; + } + fail(); + return -1; +} + +/** Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list + * + * @param pcb the pcb to check for ooseq segments + * @return tcplen of all segment + */ +static int +tcp_oos_tcplen(struct tcp_pcb* pcb) +{ + int len = 0; + struct tcp_seg* seg = pcb->ooseq; + + /* then check the actual segment */ + while(seg != NULL) { + len += TCP_TCPLEN(seg); + seg = seg->next; + } + return len; +} + +/* Setup/teardown functions */ + +static void +tcp_oos_setup(void) +{ + tcp_remove_all(); +} + +static void +tcp_oos_teardown(void) +{ + tcp_remove_all(); +} + + + +/* Test functions */ + +/** create multiple segments and pass them to tcp_input in a wrong + * order to see if ooseq-caching works correctly + * FIN is received in out-of-sequence segments only */ +START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ) +{ + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq; + char data[] = { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16}; + ip_addr_t remote_ip, local_ip; + u16_t data_len; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + LWIP_UNUSED_ARG(_i); + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + data_len = sizeof(data); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = data_len; + counters.expected_data = data; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + + /* create segments */ + /* pinseq is sent as last segment! */ + pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK); + /* p1: 8 bytes before FIN */ + /* seqno: 8..16 */ + p_8_9 = tcp_create_rx_segment(pcb, &data[8], 8, 8, 0, TCP_ACK|TCP_FIN); + /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */ + /* seqno: 4..11 */ + p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK); + /* p3: same as p2 but 2 bytes longer */ + /* seqno: 4..13 */ + p_4_10 = tcp_create_rx_segment(pcb, &data[4], 10, 4, 0, TCP_ACK); + /* p4: 14 bytes before FIN, includes data from p1 and p2, plus partly from pinseq */ + /* seqno: 2..15 */ + p_2_14 = tcp_create_rx_segment(pcb, &data[2], 14, 2, 0, TCP_ACK); + /* FIN, seqno 16 */ + p_fin = tcp_create_rx_segment(pcb, NULL, 0,16, 0, TCP_ACK|TCP_FIN); + EXPECT(pinseq != NULL); + EXPECT(p_8_9 != NULL); + EXPECT(p_4_8 != NULL); + EXPECT(p_4_10 != NULL); + EXPECT(p_2_14 != NULL); + EXPECT(p_fin != NULL); + if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) { + /* pass the segment to tcp_input */ + test_tcp_input(p_8_9, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 8); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */ + + /* pass the segment to tcp_input */ + test_tcp_input(p_4_8, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */ + + /* pass the segment to tcp_input */ + test_tcp_input(p_4_10, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* ooseq queue: unchanged */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */ + + /* pass the segment to tcp_input */ + test_tcp_input(p_2_14, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */ + + /* pass the segment to tcp_input */ + test_tcp_input(p_fin, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* ooseq queue: unchanged */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */ + + /* pass the segment to tcp_input */ + test_tcp_input(pinseq, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 1); + EXPECT(counters.recv_calls == 1); + EXPECT(counters.recved_bytes == data_len); + EXPECT(counters.err_calls == 0); + EXPECT(pcb->ooseq == NULL); + } + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} +END_TEST + + +/** create multiple segments and pass them to tcp_input in a wrong + * order to see if ooseq-caching works correctly + * FIN is received IN-SEQUENCE at the end */ +START_TEST(test_tcp_recv_ooseq_FIN_INSEQ) +{ + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN; + char data[] = { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16}; + ip_addr_t remote_ip, local_ip; + u16_t data_len; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + LWIP_UNUSED_ARG(_i); + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + data_len = sizeof(data); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = data_len; + counters.expected_data = data; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + + /* create segments */ + /* p1: 7 bytes - 2 before FIN */ + /* seqno: 1..2 */ + p_1_2 = tcp_create_rx_segment(pcb, &data[1], 2, 1, 0, TCP_ACK); + /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */ + /* seqno: 4..11 */ + p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK); + /* p3: same as p2 but 2 bytes longer and one byte more at the front */ + /* seqno: 3..13 */ + p_3_11 = tcp_create_rx_segment(pcb, &data[3], 11, 3, 0, TCP_ACK); + /* p4: 13 bytes - 2 before FIN - should be ignored as contained in p1 and p3 */ + /* seqno: 2..13 */ + p_2_12 = tcp_create_rx_segment(pcb, &data[2], 12, 2, 0, TCP_ACK); + /* pinseq is the first segment that is held back to create ooseq! */ + /* seqno: 0..3 */ + pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK); + /* p5: last byte before FIN */ + /* seqno: 15 */ + p_15_1 = tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK); + /* p6: same as p5, should be ignored */ + p_15_1a= tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK); + /* pinseqFIN: last 2 bytes plus FIN */ + /* only segment containing seqno 14 and FIN */ + pinseqFIN = tcp_create_rx_segment(pcb, &data[14], 2, 14, 0, TCP_ACK|TCP_FIN); + EXPECT(pinseq != NULL); + EXPECT(p_1_2 != NULL); + EXPECT(p_4_8 != NULL); + EXPECT(p_3_11 != NULL); + EXPECT(p_2_12 != NULL); + EXPECT(p_15_1 != NULL); + EXPECT(p_15_1a != NULL); + EXPECT(pinseqFIN != NULL); + if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL) + && (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) { + /* pass the segment to tcp_input */ + test_tcp_input(p_1_2, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); + + /* pass the segment to tcp_input */ + test_tcp_input(p_4_8, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 4); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8); + + /* pass the segment to tcp_input */ + test_tcp_input(p_3_11, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); + /* p_3_11 has removed p_4_8 from ooseq */ + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 3); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11); + + /* pass the segment to tcp_input */ + test_tcp_input(p_2_12, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 2); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12); + + /* pass the segment to tcp_input */ + test_tcp_input(pinseq, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 1); + EXPECT(counters.recved_bytes == 14); + EXPECT(counters.err_calls == 0); + EXPECT(pcb->ooseq == NULL); + + /* pass the segment to tcp_input */ + test_tcp_input(p_15_1, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 1); + EXPECT(counters.recved_bytes == 14); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); + + /* pass the segment to tcp_input */ + test_tcp_input(p_15_1a, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 1); + EXPECT(counters.recved_bytes == 14); + EXPECT(counters.err_calls == 0); + /* check ooseq queue: unchanged */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); + EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15); + EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); + + /* pass the segment to tcp_input */ + test_tcp_input(pinseqFIN, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 1); + EXPECT(counters.recv_calls == 2); + EXPECT(counters.recved_bytes == data_len); + EXPECT(counters.err_calls == 0); + EXPECT(pcb->ooseq == NULL); + } + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} +END_TEST + +static char data_full_wnd[TCP_WND]; + +/** create multiple segments and pass them to tcp_input with the first segment missing + * to simulate overruning the rxwin with ooseq queueing enabled */ +START_TEST(test_tcp_recv_ooseq_overrun_rxwin) +{ +#if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS + int i, k; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *pinseq, *p_ovr; + ip_addr_t remote_ip, local_ip; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + int datalen = 0; + int datalen2; + + for(i = 0; i < sizeof(data_full_wnd); i++) { + data_full_wnd[i] = (char)i; + } + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = TCP_WND; + counters.expected_data = data_full_wnd; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->rcv_nxt = 0x8000; + + /* create segments */ + /* pinseq is sent as last segment! */ + pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); + + for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) { + int count, expected_datalen; + struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], + TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); + EXPECT_RET(p != NULL); + /* pass the segment to tcp_input */ + test_tcp_input(p, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + count = tcp_oos_count(pcb); + EXPECT_OOSEQ(count == k+1); + datalen = tcp_oos_tcplen(pcb); + if (i + TCP_MSS < TCP_WND) { + expected_datalen = (k+1)*TCP_MSS; + } else { + expected_datalen = TCP_WND - TCP_MSS; + } + if (datalen != expected_datalen) { + EXPECT_OOSEQ(datalen == expected_datalen); + } + } + + /* pass in one more segment, cleary overrunning the rxwin */ + p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); + EXPECT_RET(p_ovr != NULL); + /* pass the segment to tcp_input */ + test_tcp_input(p_ovr, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == k); + datalen2 = tcp_oos_tcplen(pcb); + EXPECT_OOSEQ(datalen == datalen2); + + /* now pass inseq */ + test_tcp_input(pinseq, &netif); + EXPECT(pcb->ooseq == NULL); + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +#endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */ + LWIP_UNUSED_ARG(_i); +} +END_TEST + +START_TEST(test_tcp_recv_ooseq_max_bytes) +{ +#if TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) + int i, k; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *p_ovr; + ip_addr_t remote_ip, local_ip; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + int datalen = 0; + int datalen2; + + for(i = 0; i < sizeof(data_full_wnd); i++) { + data_full_wnd[i] = (char)i; + } + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = TCP_WND; + counters.expected_data = data_full_wnd; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->rcv_nxt = 0x8000; + + /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */ + + /* create segments and 'recv' them */ + for(k = 1, i = 1; k < TCP_OOSEQ_MAX_BYTES; k += TCP_MSS, i++) { + int count; + struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[k], + TCP_MSS, k, 0, TCP_ACK); + EXPECT_RET(p != NULL); + EXPECT_RET(p->next == NULL); + /* pass the segment to tcp_input */ + test_tcp_input(p, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + count = tcp_oos_pbuf_count(pcb); + EXPECT_OOSEQ(count == i); + datalen = tcp_oos_tcplen(pcb); + EXPECT_OOSEQ(datalen == (i * TCP_MSS)); + } + + /* pass in one more segment, overrunning the limit */ + p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[k+1], 1, k+1, 0, TCP_ACK); + EXPECT_RET(p_ovr != NULL); + /* pass the segment to tcp_input */ + test_tcp_input(p_ovr, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue (ensure the new segment was not accepted) */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1)); + datalen2 = tcp_oos_tcplen(pcb); + EXPECT_OOSEQ(datalen2 == ((i-1) * TCP_MSS)); + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +#endif /* TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */ + LWIP_UNUSED_ARG(_i); +} +END_TEST + +START_TEST(test_tcp_recv_ooseq_max_pbufs) +{ +#if TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_PBUFS < ((TCP_WND / TCP_MSS) + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) + int i; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *p_ovr; + ip_addr_t remote_ip, local_ip; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + int datalen = 0; + int datalen2; + + for(i = 0; i < sizeof(data_full_wnd); i++) { + data_full_wnd[i] = (char)i; + } + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = TCP_WND; + counters.expected_data = data_full_wnd; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->rcv_nxt = 0x8000; + + /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */ + + /* create segments and 'recv' them */ + for(i = 1; i <= TCP_OOSEQ_MAX_PBUFS; i++) { + int count; + struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[i], + 1, i, 0, TCP_ACK); + EXPECT_RET(p != NULL); + EXPECT_RET(p->next == NULL); + /* pass the segment to tcp_input */ + test_tcp_input(p, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue */ + count = tcp_oos_pbuf_count(pcb); + EXPECT_OOSEQ(count == i); + datalen = tcp_oos_tcplen(pcb); + EXPECT_OOSEQ(datalen == i); + } + + /* pass in one more segment, overrunning the limit */ + p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[i+1], 1, i+1, 0, TCP_ACK); + EXPECT_RET(p_ovr != NULL); + /* pass the segment to tcp_input */ + test_tcp_input(p_ovr, &netif); + /* check if counters are as expected */ + EXPECT(counters.close_calls == 0); + EXPECT(counters.recv_calls == 0); + EXPECT(counters.recved_bytes == 0); + EXPECT(counters.err_calls == 0); + /* check ooseq queue (ensure the new segment was not accepted) */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1)); + datalen2 = tcp_oos_tcplen(pcb); + EXPECT_OOSEQ(datalen2 == (i-1)); + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +#endif /* TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */ + LWIP_UNUSED_ARG(_i); +} +END_TEST + +static void +check_rx_counters(struct tcp_pcb *pcb, struct test_tcp_counters *counters, u32_t exp_close_calls, u32_t exp_rx_calls, + u32_t exp_rx_bytes, u32_t exp_err_calls, int exp_oos_count, int exp_oos_len) +{ + int oos_len; + EXPECT(counters->close_calls == exp_close_calls); + EXPECT(counters->recv_calls == exp_rx_calls); + EXPECT(counters->recved_bytes == exp_rx_bytes); + EXPECT(counters->err_calls == exp_err_calls); + /* check that pbuf is queued in ooseq */ + EXPECT_OOSEQ(tcp_oos_count(pcb) == exp_oos_count); + oos_len = tcp_oos_tcplen(pcb); + EXPECT_OOSEQ(exp_oos_len == oos_len); +} + +/* this test uses 4 packets: + * - data (len=TCP_MSS) + * - FIN + * - data after FIN (len=1) (invalid) + * - 2nd FIN (invalid) + * + * the parameter 'delay_packet' is a bitmask that choses which on these packets is ooseq + */ +static void test_tcp_recv_ooseq_double_FINs(int delay_packet) +{ + int i, k; + struct test_tcp_counters counters; + struct tcp_pcb* pcb; + struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq; + ip_addr_t remote_ip, local_ip; + u16_t remote_port = 0x100, local_port = 0x101; + struct netif netif; + u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0; + int first_dropped = 0xff; + int last_dropped = 0; + + for(i = 0; i < sizeof(data_full_wnd); i++) { + data_full_wnd[i] = (char)i; + } + + /* initialize local vars */ + memset(&netif, 0, sizeof(netif)); + IP4_ADDR(&local_ip, 192, 168, 1, 1); + IP4_ADDR(&remote_ip, 192, 168, 1, 2); + /* initialize counter struct */ + memset(&counters, 0, sizeof(counters)); + counters.expected_data_len = TCP_WND; + counters.expected_data = data_full_wnd; + + /* create and initialize the pcb */ + pcb = test_tcp_new_counters_pcb(&counters); + EXPECT_RET(pcb != NULL); + tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); + pcb->rcv_nxt = 0x8000; + + /* create segments */ + p = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); + p_normal_fin = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS, 0, TCP_ACK|TCP_FIN); + k = 1; + p_data_after_fin = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS+1], k, TCP_MSS+1, 0, TCP_ACK); + p_2nd_fin_ooseq = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS+1+k, 0, TCP_ACK|TCP_FIN); + + if(delay_packet & 1) { + /* drop normal data */ + first_dropped = 1; + last_dropped = 1; + } else { + /* send normal data */ + test_tcp_input(p, &netif); + exp_rx_calls++; + exp_rx_bytes += TCP_MSS; + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 2) { + /* drop FIN */ + if(first_dropped > 2) { + first_dropped = 2; + } + last_dropped = 2; + } else { + /* send FIN */ + test_tcp_input(p_normal_fin, &netif); + if (first_dropped < 2) { + /* already dropped packets, this one is ooseq */ + exp_oos_pbufs++; + exp_oos_tcplen++; + } else { + /* inseq */ + exp_close_calls++; + } + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 4) { + /* drop data-after-FIN */ + if(first_dropped > 3) { + first_dropped = 3; + } + last_dropped = 3; + } else { + /* send data-after-FIN */ + test_tcp_input(p_data_after_fin, &netif); + if (first_dropped < 3) { + /* already dropped packets, this one is ooseq */ + if (delay_packet & 2) { + /* correct FIN was ooseq */ + exp_oos_pbufs++; + exp_oos_tcplen += k; + } + } else { + /* inseq: no change */ + } + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 8) { + /* drop 2nd-FIN */ + if(first_dropped > 4) { + first_dropped = 4; + } + last_dropped = 4; + } else { + /* send 2nd-FIN */ + test_tcp_input(p_2nd_fin_ooseq, &netif); + if (first_dropped < 3) { + /* already dropped packets, this one is ooseq */ + if (delay_packet & 2) { + /* correct FIN was ooseq */ + exp_oos_pbufs++; + exp_oos_tcplen++; + } + } else { + /* inseq: no change */ + } + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 1) { + /* dropped normal data before */ + test_tcp_input(p, &netif); + exp_rx_calls++; + exp_rx_bytes += TCP_MSS; + if((delay_packet & 2) == 0) { + /* normal FIN was NOT delayed */ + exp_close_calls++; + exp_oos_pbufs = exp_oos_tcplen = 0; + } + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 2) { + /* dropped normal FIN before */ + test_tcp_input(p_normal_fin, &netif); + exp_close_calls++; + exp_oos_pbufs = exp_oos_tcplen = 0; + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 4) { + /* dropped data-after-FIN before */ + test_tcp_input(p_data_after_fin, &netif); + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + if(delay_packet & 8) { + /* dropped 2nd-FIN before */ + test_tcp_input(p_2nd_fin_ooseq, &netif); + } + /* check if counters are as expected */ + check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); + + /* check that ooseq data has been dumped */ + EXPECT(pcb->ooseq == NULL); + + /* make sure the pcb is freed */ + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); + tcp_abort(pcb); + EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); +} + +/** create multiple segments and pass them to tcp_input with the first segment missing + * to simulate overruning the rxwin with ooseq queueing enabled */ +#define FIN_TEST(name, num) \ + START_TEST(name) \ + { \ + LWIP_UNUSED_ARG(_i); \ + test_tcp_recv_ooseq_double_FINs(num); \ + } \ + END_TEST +FIN_TEST(test_tcp_recv_ooseq_double_FIN_0, 0) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_1, 1) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_2, 2) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_3, 3) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_4, 4) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_5, 5) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_6, 6) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_7, 7) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_8, 8) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_9, 9) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_10, 10) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_11, 11) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_12, 12) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_13, 13) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_14, 14) +FIN_TEST(test_tcp_recv_ooseq_double_FIN_15, 15) + + +/** Create the suite including all tests for this module */ +Suite * +tcp_oos_suite(void) +{ + TFun tests[] = { + test_tcp_recv_ooseq_FIN_OOSEQ, + test_tcp_recv_ooseq_FIN_INSEQ, + test_tcp_recv_ooseq_overrun_rxwin, + test_tcp_recv_ooseq_max_bytes, + test_tcp_recv_ooseq_max_pbufs, + test_tcp_recv_ooseq_double_FIN_0, + test_tcp_recv_ooseq_double_FIN_1, + test_tcp_recv_ooseq_double_FIN_2, + test_tcp_recv_ooseq_double_FIN_3, + test_tcp_recv_ooseq_double_FIN_4, + test_tcp_recv_ooseq_double_FIN_5, + test_tcp_recv_ooseq_double_FIN_6, + test_tcp_recv_ooseq_double_FIN_7, + test_tcp_recv_ooseq_double_FIN_8, + test_tcp_recv_ooseq_double_FIN_9, + test_tcp_recv_ooseq_double_FIN_10, + test_tcp_recv_ooseq_double_FIN_11, + test_tcp_recv_ooseq_double_FIN_12, + test_tcp_recv_ooseq_double_FIN_13, + test_tcp_recv_ooseq_double_FIN_14, + test_tcp_recv_ooseq_double_FIN_15 + }; + return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(TFun), tcp_oos_setup, tcp_oos_teardown); +} diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h b/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h new file mode 100644 index 0000000..5e411f0 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h @@ -0,0 +1,8 @@ +#ifndef __TEST_TCP_OOS_H__ +#define __TEST_TCP_OOS_H__ + +#include "../lwip_check.h" + +Suite *tcp_oos_suite(void); + +#endif diff --git a/user/mpy/lib/lwip/test/unit/udp/test_udp.c b/user/mpy/lib/lwip/test/unit/udp/test_udp.c new file mode 100644 index 0000000..a2f02af --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/udp/test_udp.c @@ -0,0 +1,68 @@ +#include "test_udp.h" + +#include "lwip/udp.h" +#include "lwip/stats.h" + +#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS +#error "This tests needs UDP- and MEMP-statistics enabled" +#endif + +/* Helper functions */ +static void +udp_remove_all(void) +{ + struct udp_pcb *pcb = udp_pcbs; + struct udp_pcb *pcb2; + + while(pcb != NULL) { + pcb2 = pcb; + pcb = pcb->next; + udp_remove(pcb2); + } + fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); +} + +/* Setups/teardown functions */ + +static void +udp_setup(void) +{ + udp_remove_all(); +} + +static void +udp_teardown(void) +{ + udp_remove_all(); +} + + +/* Test functions */ + +START_TEST(test_udp_new_remove) +{ + struct udp_pcb* pcb; + LWIP_UNUSED_ARG(_i); + + fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); + + pcb = udp_new(); + fail_unless(pcb != NULL); + if (pcb != NULL) { + fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 1); + udp_remove(pcb); + fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); + } +} +END_TEST + + +/** Create the suite including all tests for this module */ +Suite * +udp_suite(void) +{ + TFun tests[] = { + test_udp_new_remove, + }; + return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown); +} diff --git a/user/mpy/lib/lwip/test/unit/udp/test_udp.h b/user/mpy/lib/lwip/test/unit/udp/test_udp.h new file mode 100644 index 0000000..9335368 --- /dev/null +++ b/user/mpy/lib/lwip/test/unit/udp/test_udp.h @@ -0,0 +1,8 @@ +#ifndef __TEST_UDP_H__ +#define __TEST_UDP_H__ + +#include "../lwip_check.h" + +Suite* udp_suite(void); + +#endif diff --git a/user/mpy/lib/memzip/README.md b/user/mpy/lib/memzip/README.md new file mode 100644 index 0000000..287d0fc --- /dev/null +++ b/user/mpy/lib/memzip/README.md @@ -0,0 +1,28 @@ +MEMZIP - a simple readonly file system + +memzip takes a zip file which is comprised of uncompressed files and +and presents it as a filesystem, allowing Python files to be imported. + +The script make-memzip.py takes a directory name and will create a zip file +containing uncompressed files found in the directory. It will then generate +a C file which contains the data from the zip file. + +A typical addition to a makefile would look like: +``` +SRC_C += \ + lib/memzip/import.c \ + lib/memzip/lexermemzip.c \ + lib/memzip/memzip.c \ + +OBJ += $(BUILD)/memzip-files.o + +MAKE_MEMZIP = ../lib/memzip/make-memzip.py + +$(BUILD)/memzip-files.o: $(BUILD)/memzip-files.c + $(call compile_c) + +$(BUILD)/memzip-files.c: $(shell find ${MEMZIP_DIR} -type f) + @$(ECHO) "Creating $@" + $(Q)$(PYTHON) $(MAKE_MEMZIP) --zip-file $(BUILD)/memzip-files.zip --c-file $@ $(MEMZIP_DIR) +``` + diff --git a/user/mpy/lib/memzip/import.c b/user/mpy/lib/memzip/import.c new file mode 100644 index 0000000..2d5225b --- /dev/null +++ b/user/mpy/lib/memzip/import.c @@ -0,0 +1,17 @@ +#include + +#include "py/lexer.h" +#include "memzip.h" + +mp_import_stat_t mp_import_stat(const char *path) { + MEMZIP_FILE_INFO info; + + if (memzip_stat(path, &info) != MZ_OK) { + return MP_IMPORT_STAT_NO_EXIST; + } + + if (info.is_dir) { + return MP_IMPORT_STAT_DIR; + } + return MP_IMPORT_STAT_FILE; +} diff --git a/user/mpy/lib/memzip/lexermemzip.c b/user/mpy/lib/memzip/lexermemzip.c new file mode 100644 index 0000000..6b26961 --- /dev/null +++ b/user/mpy/lib/memzip/lexermemzip.c @@ -0,0 +1,19 @@ +#include + +#include "py/lexer.h" +#include "py/runtime.h" +#include "py/mperrno.h" +#include "memzip.h" + +mp_lexer_t *mp_lexer_new_from_file(const char *filename) +{ + void *data; + size_t len; + + if (memzip_locate(filename, &data, &len) != MZ_OK) { + mp_raise_OSError(MP_ENOENT); + } + + return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (mp_uint_t)len, 0); +} + diff --git a/user/mpy/lib/memzip/make-memzip.py b/user/mpy/lib/memzip/make-memzip.py new file mode 100755 index 0000000..9730f5e --- /dev/null +++ b/user/mpy/lib/memzip/make-memzip.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# +# Takes a directory of files and zips them up (as uncompressed files). +# This then gets converted into a C data structure which can be read +# like a filesystem at runtime. +# +# This is somewhat like frozen modules in python, but allows arbitrary files +# to be used. + +from __future__ import print_function + +import argparse +import os +import subprocess +import sys +import types + +def create_zip(zip_filename, zip_dir): + abs_zip_filename = os.path.abspath(zip_filename) + save_cwd = os.getcwd() + os.chdir(zip_dir) + if os.path.exists(abs_zip_filename): + os.remove(abs_zip_filename) + subprocess.check_call(['zip', '-0', '-r', '-D', abs_zip_filename, '.']) + os.chdir(save_cwd) + +def create_c_from_file(c_filename, zip_filename): + with open(zip_filename, 'rb') as zip_file: + with open(c_filename, 'wb') as c_file: + print('#include ', file=c_file) + print('', file=c_file) + print('const uint8_t memzip_data[] = {', file=c_file) + while True: + buf = zip_file.read(16) + if not buf: + break + print(' ', end='', file=c_file) + for byte in buf: + if type(byte) is types.StringType: + print(' 0x{:02x},'.format(ord(byte)), end='', file=c_file) + else: + print(' 0x{:02x},'.format(byte), end='', file=c_file) + print('', file=c_file) + print('};', file=c_file) + +def main(): + parser = argparse.ArgumentParser( + prog='make-memzip.py', + usage='%(prog)s [options] [command]', + description='Generates a C source memzip file.' + ) + parser.add_argument( + '-z', '--zip-file', + dest='zip_filename', + help='Specifies the name of the created zip file.', + default='memzip_files.zip' + ) + parser.add_argument( + '-c', '--c-file', + dest='c_filename', + help='Specifies the name of the created C source file.', + default='memzip_files.c' + ) + parser.add_argument( + dest='source_dir', + default='memzip_files' + ) + args = parser.parse_args(sys.argv[1:]) + + print('args.zip_filename =', args.zip_filename) + print('args.c_filename =', args.c_filename) + print('args.source_dir =', args.source_dir) + + create_zip(args.zip_filename, args.source_dir) + create_c_from_file(args.c_filename, args.zip_filename) + +if __name__ == "__main__": + main() + diff --git a/user/mpy/lib/memzip/memzip.c b/user/mpy/lib/memzip/memzip.c new file mode 100644 index 0000000..3fbea8e --- /dev/null +++ b/user/mpy/lib/memzip/memzip.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include "py/mpconfig.h" +#include "py/misc.h" +#include "memzip.h" + +extern uint8_t memzip_data[]; + +const MEMZIP_FILE_HDR *memzip_find_file_header(const char *filename) { + + const MEMZIP_FILE_HDR *file_hdr = (const MEMZIP_FILE_HDR *)memzip_data; + uint8_t *mem_data; + + /* Zip file filenames don't have a leading /, so we strip it off */ + + if (*filename == '/') { + filename++; + } + while (file_hdr->signature == MEMZIP_FILE_HEADER_SIGNATURE) { + const char *file_hdr_filename = (const char *)&file_hdr[1]; + mem_data = (uint8_t *)file_hdr_filename; + mem_data += file_hdr->filename_len; + mem_data += file_hdr->extra_len; + if (!strncmp(file_hdr_filename, filename, file_hdr->filename_len)) { + /* We found a match */ + return file_hdr; + } + mem_data += file_hdr->uncompressed_size; + file_hdr = (const MEMZIP_FILE_HDR *)mem_data; + } + return NULL; +} + +bool memzip_is_dir(const char *filename) { + const MEMZIP_FILE_HDR *file_hdr = (const MEMZIP_FILE_HDR *)memzip_data; + uint8_t *mem_data; + + if (strcmp(filename, "/") == 0) { + // The root directory is a directory. + return true; + } + + // Zip filenames don't have a leading /, so we strip it off + if (*filename == '/') { + filename++; + } + size_t filename_len = strlen(filename); + + while (file_hdr->signature == MEMZIP_FILE_HEADER_SIGNATURE) { + const char *file_hdr_filename = (const char *)&file_hdr[1]; + if (filename_len < file_hdr->filename_len && + strncmp(file_hdr_filename, filename, filename_len) == 0 && + file_hdr_filename[filename_len] == '/') { + return true; + } + + mem_data = (uint8_t *)file_hdr_filename; + mem_data += file_hdr->filename_len; + mem_data += file_hdr->extra_len; + mem_data += file_hdr->uncompressed_size; + file_hdr = (const MEMZIP_FILE_HDR *)mem_data; + } + return NULL; + +} + +MEMZIP_RESULT memzip_locate(const char *filename, void **data, size_t *len) +{ + const MEMZIP_FILE_HDR *file_hdr = memzip_find_file_header(filename); + if (file_hdr == NULL) { + return MZ_NO_FILE; + } + if (file_hdr->compression_method != 0) { + return MZ_FILE_COMPRESSED; + } + + uint8_t *mem_data; + mem_data = (uint8_t *)&file_hdr[1]; + mem_data += file_hdr->filename_len; + mem_data += file_hdr->extra_len; + + *data = mem_data; + *len = file_hdr->uncompressed_size; + return MZ_OK; +} + +MEMZIP_RESULT memzip_stat(const char *path, MEMZIP_FILE_INFO *info) { + const MEMZIP_FILE_HDR *file_hdr = memzip_find_file_header(path); + if (file_hdr == NULL) { + if (memzip_is_dir(path)) { + info->file_size = 0; + info->last_mod_date = 0; + info->last_mod_time = 0; + info->is_dir = 1; + return MZ_OK; + } + return MZ_NO_FILE; + } + info->file_size = file_hdr->uncompressed_size; + info->last_mod_date = file_hdr->last_mod_date; + info->last_mod_time = file_hdr->last_mod_time; + info->is_dir = 0; + + return MZ_OK; +} diff --git a/user/mpy/lib/memzip/memzip.h b/user/mpy/lib/memzip/memzip.h new file mode 100644 index 0000000..667e2df --- /dev/null +++ b/user/mpy/lib/memzip/memzip.h @@ -0,0 +1,83 @@ +#pragma pack(push, 1) + +#define MEMZIP_FILE_HEADER_SIGNATURE 0x04034b50 +typedef struct +{ + uint32_t signature; + uint16_t version; + uint16_t flags; + uint16_t compression_method; + uint16_t last_mod_time; + uint16_t last_mod_date; + uint32_t crc32; + uint32_t compressed_size; + uint32_t uncompressed_size; + uint16_t filename_len; + uint16_t extra_len; + + /* char filename[filename_len] */ + /* uint8_t extra[extra_len] */ + +} MEMZIP_FILE_HDR; + +#define MEMZIP_CENTRAL_DIRECTORY_SIGNATURE 0x02014b50 +typedef struct +{ + uint32_t signature; + uint16_t version_made_by; + uint16_t version_read_with; + uint16_t flags; + uint16_t compression_method; + uint16_t last_mod_time; + uint16_t last_mod_date; + uint32_t crc32; + uint32_t compressed_size; + uint32_t uncompressed_size; + uint16_t filename_len; + uint16_t extra_len; + uint16_t disk_num; + uint16_t internal_file_attributes; + uint32_t external_file_attributes; + uint32_t file_header_offset; + + /* char filename[filename_len] */ + /* uint8_t extra[extra_len] */ + +} MEMZIP_CENTRAL_DIRECTORY_HDR; + +#define MEMZIP_END_OF_CENTRAL_DIRECTORY_SIGNATURE 0x06054b50 +typedef struct +{ + uint32_t signature; + uint16_t disk_num; + uint16_t central_directory_disk; + uint16_t num_central_directories_this_disk; + uint16_t total_central_directories; + uint32_t central_directory_size; + uint32_t central_directory_offset; + uint16_t comment_len; + + /* char comment[comment_len] */ + +} MEMZIP_END_OF_CENTRAL_DIRECTORY; + +#pragma pack(pop) + +typedef enum { + MZ_OK = 0, /* (0) Succeeded */ + MZ_NO_FILE, /* (1) Could not find the file. */ + MZ_FILE_COMPRESSED, /* (2) File is compressed (expecting uncompressed) */ + +} MEMZIP_RESULT; + +typedef struct { + uint32_t file_size; + uint16_t last_mod_date; + uint16_t last_mod_time; + uint8_t is_dir; + +} MEMZIP_FILE_INFO; + +MEMZIP_RESULT memzip_locate(const char *filename, void **data, size_t *len); + +MEMZIP_RESULT memzip_stat(const char *path, MEMZIP_FILE_INFO *info); diff --git a/user/mpy/lib/mp-readline/readline.c b/user/mpy/lib/mp-readline/readline.c new file mode 100644 index 0000000..9d254d8 --- /dev/null +++ b/user/mpy/lib/mp-readline/readline.c @@ -0,0 +1,447 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpstate.h" +#include "py/repl.h" +#include "py/mphal.h" +#include "lib/mp-readline/readline.h" + +#if 0 // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +#define READLINE_HIST_SIZE (MP_ARRAY_SIZE(MP_STATE_PORT(readline_hist))) + +enum { ESEQ_NONE, ESEQ_ESC, ESEQ_ESC_BRACKET, ESEQ_ESC_BRACKET_DIGIT, ESEQ_ESC_O }; + +void readline_init0(void) { + memset(MP_STATE_PORT(readline_hist), 0, READLINE_HIST_SIZE * sizeof(const char*)); +} + +STATIC char *str_dup_maybe(const char *str) { + uint32_t len = strlen(str); + char *s2 = m_new_maybe(char, len + 1); + if (s2 == NULL) { + return NULL; + } + memcpy(s2, str, len + 1); + return s2; +} + +// By default assume terminal which implements VT100 commands... +#ifndef MICROPY_HAL_HAS_VT100 +#define MICROPY_HAL_HAS_VT100 (1) +#endif + +// ...and provide the implementation using them +#if MICROPY_HAL_HAS_VT100 +STATIC void mp_hal_move_cursor_back(uint pos) { + if (pos <= 4) { + // fast path for most common case of 1 step back + mp_hal_stdout_tx_strn("\b\b\b\b", pos); + } else { + char vt100_command[6]; + // snprintf needs space for the terminating null character + int n = snprintf(&vt100_command[0], sizeof(vt100_command), "\x1b[%u", pos); + if (n > 0) { + vt100_command[n] = 'D'; // replace null char + mp_hal_stdout_tx_strn(vt100_command, n + 1); + } + } +} + +STATIC void mp_hal_erase_line_from_cursor(uint n_chars_to_erase) { + (void)n_chars_to_erase; + mp_hal_stdout_tx_strn("\x1b[K", 3); +} +#endif + +typedef struct _readline_t { + vstr_t *line; + size_t orig_line_len; + int escape_seq; + int hist_cur; + size_t cursor_pos; + char escape_seq_buf[1]; + const char *prompt; +} readline_t; + +STATIC readline_t rl; + +int readline_process_char(int c) { + size_t last_line_len = rl.line->len; + int redraw_step_back = 0; + bool redraw_from_cursor = false; + int redraw_step_forward = 0; + if (rl.escape_seq == ESEQ_NONE) { + if (CHAR_CTRL_A <= c && c <= CHAR_CTRL_E && vstr_len(rl.line) == rl.orig_line_len) { + // control character with empty line + return c; + } else if (c == CHAR_CTRL_A) { + // CTRL-A with non-empty line is go-to-start-of-line + goto home_key; + #if MICROPY_REPL_EMACS_KEYS + } else if (c == CHAR_CTRL_B) { + // CTRL-B with non-empty line is go-back-one-char + goto left_arrow_key; + #endif + } else if (c == CHAR_CTRL_C) { + // CTRL-C with non-empty line is cancel + return c; + #if MICROPY_REPL_EMACS_KEYS + } else if (c == CHAR_CTRL_D) { + // CTRL-D with non-empty line is delete-at-cursor + goto delete_key; + #endif + } else if (c == CHAR_CTRL_E) { + // CTRL-E is go-to-end-of-line + goto end_key; + #if MICROPY_REPL_EMACS_KEYS + } else if (c == CHAR_CTRL_F) { + // CTRL-F with non-empty line is go-forward-one-char + goto right_arrow_key; + } else if (c == CHAR_CTRL_K) { + // CTRL-K is kill from cursor to end-of-line, inclusive + vstr_cut_tail_bytes(rl.line, last_line_len - rl.cursor_pos); + // set redraw parameters + redraw_from_cursor = true; + } else if (c == CHAR_CTRL_N) { + // CTRL-N is go to next line in history + goto down_arrow_key; + } else if (c == CHAR_CTRL_P) { + // CTRL-P is go to previous line in history + goto up_arrow_key; + } else if (c == CHAR_CTRL_U) { + // CTRL-U is kill from beginning-of-line up to cursor + vstr_cut_out_bytes(rl.line, rl.orig_line_len, rl.cursor_pos - rl.orig_line_len); + // set redraw parameters + redraw_step_back = rl.cursor_pos - rl.orig_line_len; + redraw_from_cursor = true; + #endif + } else if (c == '\r') { + // newline + mp_hal_stdout_tx_str("\r\n"); + readline_push_history(vstr_null_terminated_str(rl.line) + rl.orig_line_len); + return 0; + } else if (c == 27) { + // escape sequence + rl.escape_seq = ESEQ_ESC; + } else if (c == 8 || c == 127) { + // backspace/delete + if (rl.cursor_pos > rl.orig_line_len) { + // work out how many chars to backspace + #if MICROPY_REPL_AUTO_INDENT + int nspace = 0; + for (size_t i = rl.orig_line_len; i < rl.cursor_pos; i++) { + if (rl.line->buf[i] != ' ') { + nspace = 0; + break; + } + nspace += 1; + } + if (nspace < 4) { + nspace = 1; + } else { + nspace = 4; + } + #else + int nspace = 1; + #endif + + // do the backspace + vstr_cut_out_bytes(rl.line, rl.cursor_pos - nspace, nspace); + // set redraw parameters + redraw_step_back = nspace; + redraw_from_cursor = true; + } + #if MICROPY_HELPER_REPL + } else if (c == 9) { + // tab magic + const char *compl_str; + size_t compl_len = mp_repl_autocomplete(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len, &mp_plat_print, &compl_str); + if (compl_len == 0) { + // no match + } else if (compl_len == (size_t)(-1)) { + // many matches + mp_hal_stdout_tx_str(rl.prompt); + mp_hal_stdout_tx_strn(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len); + redraw_from_cursor = true; + } else { + // one match + for (size_t i = 0; i < compl_len; ++i) { + vstr_ins_byte(rl.line, rl.cursor_pos + i, *compl_str++); + } + // set redraw parameters + redraw_from_cursor = true; + redraw_step_forward = compl_len; + } + #endif + } else if (32 <= c && c <= 126) { + // printable character + vstr_ins_char(rl.line, rl.cursor_pos, c); + // set redraw parameters + redraw_from_cursor = true; + redraw_step_forward = 1; + } + } else if (rl.escape_seq == ESEQ_ESC) { + switch (c) { + case '[': + rl.escape_seq = ESEQ_ESC_BRACKET; + break; + case 'O': + rl.escape_seq = ESEQ_ESC_O; + break; + default: + DEBUG_printf("(ESC %d)", c); + rl.escape_seq = ESEQ_NONE; + } + } else if (rl.escape_seq == ESEQ_ESC_BRACKET) { + if ('0' <= c && c <= '9') { + rl.escape_seq = ESEQ_ESC_BRACKET_DIGIT; + rl.escape_seq_buf[0] = c; + } else { + rl.escape_seq = ESEQ_NONE; + if (c == 'A') { +#if MICROPY_REPL_EMACS_KEYS +up_arrow_key: +#endif + // up arrow + if (rl.hist_cur + 1 < (int)READLINE_HIST_SIZE && MP_STATE_PORT(readline_hist)[rl.hist_cur + 1] != NULL) { + // increase hist num + rl.hist_cur += 1; + // set line to history + rl.line->len = rl.orig_line_len; + vstr_add_str(rl.line, MP_STATE_PORT(readline_hist)[rl.hist_cur]); + // set redraw parameters + redraw_step_back = rl.cursor_pos - rl.orig_line_len; + redraw_from_cursor = true; + redraw_step_forward = rl.line->len - rl.orig_line_len; + } + } else if (c == 'B') { +#if MICROPY_REPL_EMACS_KEYS +down_arrow_key: +#endif + // down arrow + if (rl.hist_cur >= 0) { + // decrease hist num + rl.hist_cur -= 1; + // set line to history + vstr_cut_tail_bytes(rl.line, rl.line->len - rl.orig_line_len); + if (rl.hist_cur >= 0) { + vstr_add_str(rl.line, MP_STATE_PORT(readline_hist)[rl.hist_cur]); + } + // set redraw parameters + redraw_step_back = rl.cursor_pos - rl.orig_line_len; + redraw_from_cursor = true; + redraw_step_forward = rl.line->len - rl.orig_line_len; + } + } else if (c == 'C') { +#if MICROPY_REPL_EMACS_KEYS +right_arrow_key: +#endif + // right arrow + if (rl.cursor_pos < rl.line->len) { + redraw_step_forward = 1; + } + } else if (c == 'D') { +#if MICROPY_REPL_EMACS_KEYS +left_arrow_key: +#endif + // left arrow + if (rl.cursor_pos > rl.orig_line_len) { + redraw_step_back = 1; + } + } else if (c == 'H') { + // home + goto home_key; + } else if (c == 'F') { + // end + goto end_key; + } else { + DEBUG_printf("(ESC [ %d)", c); + } + } + } else if (rl.escape_seq == ESEQ_ESC_BRACKET_DIGIT) { + if (c == '~') { + if (rl.escape_seq_buf[0] == '1' || rl.escape_seq_buf[0] == '7') { +home_key: + redraw_step_back = rl.cursor_pos - rl.orig_line_len; + } else if (rl.escape_seq_buf[0] == '4' || rl.escape_seq_buf[0] == '8') { +end_key: + redraw_step_forward = rl.line->len - rl.cursor_pos; + } else if (rl.escape_seq_buf[0] == '3') { + // delete +#if MICROPY_REPL_EMACS_KEYS +delete_key: +#endif + if (rl.cursor_pos < rl.line->len) { + vstr_cut_out_bytes(rl.line, rl.cursor_pos, 1); + redraw_from_cursor = true; + } + } else { + DEBUG_printf("(ESC [ %c %d)", rl.escape_seq_buf[0], c); + } + } else { + DEBUG_printf("(ESC [ %c %d)", rl.escape_seq_buf[0], c); + } + rl.escape_seq = ESEQ_NONE; + } else if (rl.escape_seq == ESEQ_ESC_O) { + switch (c) { + case 'H': + goto home_key; + case 'F': + goto end_key; + default: + DEBUG_printf("(ESC O %d)", c); + rl.escape_seq = ESEQ_NONE; + } + } else { + rl.escape_seq = ESEQ_NONE; + } + + // redraw command prompt, efficiently + if (redraw_step_back > 0) { + mp_hal_move_cursor_back(redraw_step_back); + rl.cursor_pos -= redraw_step_back; + } + if (redraw_from_cursor) { + if (rl.line->len < last_line_len) { + // erase old chars + mp_hal_erase_line_from_cursor(last_line_len - rl.cursor_pos); + } + // draw new chars + mp_hal_stdout_tx_strn(rl.line->buf + rl.cursor_pos, rl.line->len - rl.cursor_pos); + // move cursor forward if needed (already moved forward by length of line, so move it back) + mp_hal_move_cursor_back(rl.line->len - (rl.cursor_pos + redraw_step_forward)); + rl.cursor_pos += redraw_step_forward; + } else if (redraw_step_forward > 0) { + // draw over old chars to move cursor forwards + mp_hal_stdout_tx_strn(rl.line->buf + rl.cursor_pos, redraw_step_forward); + rl.cursor_pos += redraw_step_forward; + } + + return -1; +} + +#if MICROPY_REPL_AUTO_INDENT +STATIC void readline_auto_indent(void) { + vstr_t *line = rl.line; + if (line->len > 1 && line->buf[line->len - 1] == '\n') { + int i; + for (i = line->len - 1; i > 0; i--) { + if (line->buf[i - 1] == '\n') { + break; + } + } + size_t j; + for (j = i; j < line->len; j++) { + if (line->buf[j] != ' ') { + break; + } + } + // i=start of line; j=first non-space + if (i > 0 && j + 1 == line->len) { + // previous line is not first line and is all spaces + for (size_t k = i - 1; k > 0; --k) { + if (line->buf[k - 1] == '\n') { + // don't auto-indent if last 2 lines are all spaces + return; + } else if (line->buf[k - 1] != ' ') { + // 2nd previous line is not all spaces + break; + } + } + } + int n = (j - i) / 4; + if (line->buf[line->len - 2] == ':') { + n += 1; + } + while (n-- > 0) { + vstr_add_strn(line, " ", 4); + mp_hal_stdout_tx_strn(" ", 4); + rl.cursor_pos += 4; + } + } +} +#endif + +void readline_note_newline(const char *prompt) { + rl.orig_line_len = rl.line->len; + rl.cursor_pos = rl.orig_line_len; + rl.prompt = prompt; + mp_hal_stdout_tx_str(prompt); + #if MICROPY_REPL_AUTO_INDENT + readline_auto_indent(); + #endif +} + +void readline_init(vstr_t *line, const char *prompt) { + rl.line = line; + rl.orig_line_len = line->len; + rl.escape_seq = ESEQ_NONE; + rl.escape_seq_buf[0] = 0; + rl.hist_cur = -1; + rl.cursor_pos = rl.orig_line_len; + rl.prompt = prompt; + mp_hal_stdout_tx_str(prompt); + #if MICROPY_REPL_AUTO_INDENT + readline_auto_indent(); + #endif +} + +int readline(vstr_t *line, const char *prompt) { + readline_init(line, prompt); + for (;;) { + int c = mp_hal_stdin_rx_chr(); + int r = readline_process_char(c); + if (r >= 0) { + return r; + } + } +} + +void readline_push_history(const char *line) { + if (line[0] != '\0' + && (MP_STATE_PORT(readline_hist)[0] == NULL + || strcmp(MP_STATE_PORT(readline_hist)[0], line) != 0)) { + // a line which is not empty and different from the last one + // so update the history + char *most_recent_hist = str_dup_maybe(line); + if (most_recent_hist != NULL) { + for (int i = READLINE_HIST_SIZE - 1; i > 0; i--) { + MP_STATE_PORT(readline_hist)[i] = MP_STATE_PORT(readline_hist)[i - 1]; + } + MP_STATE_PORT(readline_hist)[0] = most_recent_hist; + } + } +} diff --git a/user/mpy/lib/mp-readline/readline.h b/user/mpy/lib/mp-readline/readline.h new file mode 100644 index 0000000..00aa962 --- /dev/null +++ b/user/mpy/lib/mp-readline/readline.h @@ -0,0 +1,48 @@ +/* + * 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_LIB_MP_READLINE_READLINE_H +#define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H + +#define CHAR_CTRL_A (1) +#define CHAR_CTRL_B (2) +#define CHAR_CTRL_C (3) +#define CHAR_CTRL_D (4) +#define CHAR_CTRL_E (5) +#define CHAR_CTRL_F (6) +#define CHAR_CTRL_K (11) +#define CHAR_CTRL_N (14) +#define CHAR_CTRL_P (16) +#define CHAR_CTRL_U (21) + +void readline_init0(void); +int readline(vstr_t *line, const char *prompt); +void readline_push_history(const char *line); + +void readline_init(vstr_t *line, const char *prompt); +void readline_note_newline(const char *prompt); +int readline_process_char(int c); + +#endif // MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H diff --git a/user/mpy/lib/netutils/netutils.c b/user/mpy/lib/netutils/netutils.c new file mode 100644 index 0000000..15e7039 --- /dev/null +++ b/user/mpy/lib/netutils/netutils.c @@ -0,0 +1,96 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2015 Daniel Campora + * + * 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. + */ + +#include +#include +#include + +#include "py/obj.h" +#include "py/nlr.h" +#include "py/runtime.h" +#include "lib/netutils/netutils.h" + +// Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. +mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian) { + char ip_str[16]; + mp_uint_t ip_len; + if (endian == NETUTILS_LITTLE) { + ip_len = snprintf(ip_str, 16, "%u.%u.%u.%u", ip[3], ip[2], ip[1], ip[0]); + } else { + ip_len = snprintf(ip_str, 16, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); + } + return mp_obj_new_str(ip_str, ip_len, false); +} + +// Takes an array with a raw IP address, and a port, and returns a net-address +// tuple such as ('192.168.0.1', 8080). +mp_obj_t netutils_format_inet_addr(uint8_t *ip, mp_uint_t port, netutils_endian_t endian) { + mp_obj_t tuple[2] = { + tuple[0] = netutils_format_ipv4_addr(ip, endian), + tuple[1] = mp_obj_new_int(port), + }; + return mp_obj_new_tuple(2, tuple); +} + +void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian) { + size_t addr_len; + const char *addr_str = mp_obj_str_get_data(addr_in, &addr_len); + if (addr_len == 0) { + // special case of no address given + memset(out_ip, 0, NETUTILS_IPV4ADDR_BUFSIZE); + return; + } + const char *s = addr_str; + const char *s_top = addr_str + addr_len; + for (mp_uint_t i = 3 ; ; i--) { + mp_uint_t val = 0; + for (; s < s_top && *s != '.'; s++) { + val = val * 10 + *s - '0'; + } + if (endian == NETUTILS_LITTLE) { + out_ip[i] = val; + } else { + out_ip[NETUTILS_IPV4ADDR_BUFSIZE - 1 - i] = val; + } + if (i == 0 && s == s_top) { + return; + } else if (i > 0 && s < s_top && *s == '.') { + s++; + } else { + mp_raise_ValueError("invalid arguments"); + } + } +} + +// Takes an address of the form ('192.168.0.1', 8080), returns the port and +// puts IP in out_ip (which must take at least IPADDR_BUF_SIZE bytes). +mp_uint_t netutils_parse_inet_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian) { + mp_obj_t *addr_items; + mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); + netutils_parse_ipv4_addr(addr_items[0], out_ip, endian); + return mp_obj_get_int(addr_items[1]); +} diff --git a/user/mpy/lib/netutils/netutils.h b/user/mpy/lib/netutils/netutils.h new file mode 100644 index 0000000..4befc90 --- /dev/null +++ b/user/mpy/lib/netutils/netutils.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2015 Daniel Campora + * + * 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_LIB_NETUTILS_NETUTILS_H +#define MICROPY_INCLUDED_LIB_NETUTILS_NETUTILS_H + +#define NETUTILS_IPV4ADDR_BUFSIZE 4 + +typedef enum _netutils_endian_t { + NETUTILS_LITTLE, + NETUTILS_BIG, +} netutils_endian_t; + +// Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. +mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian); + +// Takes an array with a raw IP address, and a port, and returns a net-address +// tuple such as ('192.168.0.1', 8080). +mp_obj_t netutils_format_inet_addr(uint8_t *ip, mp_uint_t port, netutils_endian_t endian); + +void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian); + +// Takes an address of the form ('192.168.0.1', 8080), returns the port and +// puts IP in out_ip (which must take at least IPADDR_BUF_SIZE bytes). +mp_uint_t netutils_parse_inet_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian); + +#endif // MICROPY_INCLUDED_LIB_NETUTILS_NETUTILS_H diff --git a/user/mpy/lib/oofatfs/diskio.h b/user/mpy/lib/oofatfs/diskio.h new file mode 100644 index 0000000..8deb68e --- /dev/null +++ b/user/mpy/lib/oofatfs/diskio.h @@ -0,0 +1,83 @@ +/* This file is part of ooFatFs, a customised version of FatFs + * See https://github.com/micropython/oofatfs for details + */ + +/*-----------------------------------------------------------------------/ +/ Low level disk interface modlue include file (C)ChaN, 2014 / +/-----------------------------------------------------------------------*/ + +#ifndef _DISKIO_DEFINED +#define _DISKIO_DEFINED + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* Status of Disk Functions */ +typedef BYTE DSTATUS; + +/* Results of Disk Functions */ +typedef enum { + RES_OK = 0, /* 0: Successful */ + RES_ERROR, /* 1: R/W Error */ + RES_WRPRT, /* 2: Write Protected */ + RES_NOTRDY, /* 3: Not Ready */ + RES_PARERR /* 4: Invalid Parameter */ +} DRESULT; + + +/*---------------------------------------*/ +/* Prototypes for disk control functions */ + + +DRESULT disk_read (void *drv, BYTE* buff, DWORD sector, UINT count); +DRESULT disk_write (void *drv, const BYTE* buff, DWORD sector, UINT count); +DRESULT disk_ioctl (void *drv, BYTE cmd, void* buff); + + +/* Disk Status Bits (DSTATUS) */ + +#define STA_NOINIT 0x01 /* Drive not initialized */ +#define STA_NODISK 0x02 /* No medium in the drive */ +#define STA_PROTECT 0x04 /* Write protected */ + + +/* Command code for disk_ioctrl fucntion */ + +/* Generic command (Used by FatFs) */ +#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ +#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ +#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ +#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ +#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ +#define IOCTL_INIT 5 +#define IOCTL_STATUS 6 + +/* Generic command (Not used by FatFs) */ +#define CTRL_POWER 5 /* Get/Set power status */ +#define CTRL_LOCK 6 /* Lock/Unlock media removal */ +#define CTRL_EJECT 7 /* Eject media */ +#define CTRL_FORMAT 8 /* Create physical format on the media */ + +/* MMC/SDC specific ioctl command */ +#define MMC_GET_TYPE 10 /* Get card type */ +#define MMC_GET_CSD 11 /* Get CSD */ +#define MMC_GET_CID 12 /* Get CID */ +#define MMC_GET_OCR 13 /* Get OCR */ +#define MMC_GET_SDSTAT 14 /* Get SD status */ +#define ISDIO_READ 55 /* Read data form SD iSDIO register */ +#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ +#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ + +/* ATA/CF specific ioctl command */ +#define ATA_GET_REV 20 /* Get F/W revision */ +#define ATA_GET_MODEL 21 /* Get model name */ +#define ATA_GET_SN 22 /* Get serial number */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/user/mpy/lib/oofatfs/ff.c b/user/mpy/lib/oofatfs/ff.c new file mode 100644 index 0000000..b098475 --- /dev/null +++ b/user/mpy/lib/oofatfs/ff.c @@ -0,0 +1,5594 @@ +/* This file is part of ooFatFs, a customised version of FatFs + * See https://github.com/micropython/oofatfs for details + */ + +/*----------------------------------------------------------------------------/ +/ FatFs - Generic FAT file system module R0.12b / +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2016, ChaN, all right reserved. +/ +/ FatFs module is an open source software. Redistribution and use of FatFs in +/ source and binary forms, with or without modification, are permitted provided +/ that the following condition is met: + +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/----------------------------------------------------------------------------*/ + + +#include + +#include "ff.h" /* Declarations of FatFs API */ +#include "diskio.h" /* Declarations of device I/O functions */ + +// DIR has been renamed FF_DIR in the public API so it doesn't clash with POSIX +#define DIR FF_DIR + +/*-------------------------------------------------------------------------- + + Module Private Definitions + +---------------------------------------------------------------------------*/ + +#if _FATFS != 68020 /* Revision ID */ +#error Wrong include file (ff.h). +#endif + + +#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } + + +/* Reentrancy related */ +#if _FS_REENTRANT +#if _USE_LFN == 1 +#error Static LFN work area cannot be used at thread-safe configuration +#endif +#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } +#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } +#else +#define ENTER_FF(fs) +#define LEAVE_FF(fs, res) return res +#endif + + + +/* Definitions of sector size */ +#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) +#error Wrong sector size configuration +#endif +#if _MAX_SS == _MIN_SS +#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ +#else +#define SS(fs) ((fs)->ssize) /* Variable sector size */ +#endif + + +/* Timestamp */ +#if _FS_NORTC == 1 +#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 +#error Invalid _FS_NORTC settings +#endif +#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) +#else +#define GET_FATTIME() get_fattime() +#endif + + +/* File lock controls */ +#if _FS_LOCK != 0 +#if _FS_READONLY +#error _FS_LOCK must be 0 at read-only configuration +#endif +typedef struct { + FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ + DWORD clu; /* Object ID 2, directory (0:root) */ + DWORD ofs; /* Object ID 3, directory offset */ + WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ +} FILESEM; +#endif + + + +/* DBCS code ranges and SBCS upper conversion tables */ + +#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ +#define _DF1S 0x81 /* DBC 1st byte range 1 start */ +#define _DF1E 0x9F /* DBC 1st byte range 1 end */ +#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ +#define _DF2E 0xFC /* DBC 1st byte range 2 end */ +#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ +#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ +#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ +#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ + +#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x40 +#define _DS1E 0x7E +#define _DS2S 0x80 +#define _DS2E 0xFE + +#elif _CODE_PAGE == 949 /* Korean */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x41 +#define _DS1E 0x5A +#define _DS2S 0x61 +#define _DS2E 0x7A +#define _DS3S 0x81 +#define _DS3E 0xFE + +#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x40 +#define _DS1E 0x7E +#define _DS2S 0xA1 +#define _DS2E 0xFE + +#elif _CODE_PAGE == 437 /* U.S. */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 720 /* Arabic */ +#define _DF1S 0 +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 737 /* Greek */ +#define _DF1S 0 +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ + 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 771 /* KBL */ +#define _DF1S 0 +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} + +#elif _CODE_PAGE == 775 /* Baltic */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ + 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 850 /* Latin 1 */ +#define _DF1S 0 +#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ + 0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \ + 0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 852 /* Latin 2 */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0xAC, \ + 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} + +#elif _CODE_PAGE == 855 /* Cyrillic */ +#define _DF1S 0 +#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ + 0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ + 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ + 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \ + 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 857 /* Turkish */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ + 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0x49,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 860 /* Portuguese */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ + 0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 861 /* Icelandic */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ + 0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 862 /* Hebrew */ +#define _DF1S 0 +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 863 /* Canadian-French */ +#define _DF1S 0 +#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ + 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ + 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 864 /* Arabic */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 865 /* Nordic */ +#define _DF1S 0 +#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 866 /* Russian */ +#define _DF1S 0 +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif _CODE_PAGE == 869 /* Greek 2 */ +#define _DF1S 0 +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ + 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ + 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ + 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} + +#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ +#if _USE_LFN != 0 +#error Cannot enable LFN without valid code page. +#endif +#define _DF1S 0 + +#else +#error Unknown code page + +#endif + + +/* Character code support macros */ +#define IsUpper(c) (((c)>='A')&&((c)<='Z')) +#define IsLower(c) (((c)>='a')&&((c)<='z')) +#define IsDigit(c) (((c)>='0')&&((c)<='9')) + +#if _DF1S != 0 /* Code page is DBCS */ + +#ifdef _DF2S /* Two 1st byte areas */ +#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) +#else /* One 1st byte area */ +#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) +#endif + +#ifdef _DS3S /* Three 2nd byte areas */ +#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) +#else /* Two 2nd byte areas */ +#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) +#endif + +#else /* Code page is SBCS */ + +#define IsDBCS1(c) 0 +#define IsDBCS2(c) 0 + +#endif /* _DF1S */ + + +/* File attribute bits (internal use) */ +#define AM_VOL 0x08 /* Volume label */ +#define AM_LFN 0x0F /* LFN entry */ +#define AM_MASK 0x3F /* Mask of defined bits */ + + +/* File access control and file status flags (internal use) */ +#define FA_SEEKEND 0x20 /* Seek to end of the file on file open */ +#define FA_MODIFIED 0x40 /* File has been modified */ +#define FA_DIRTY 0x80 /* FIL.buf[] needs to be written-back */ + + +/* Name status flags */ +#define NSFLAG 11 /* Index of name status byte in fn[] */ +#define NS_LOSS 0x01 /* Out of 8.3 format */ +#define NS_LFN 0x02 /* Force to create LFN entry */ +#define NS_LAST 0x04 /* Last segment */ +#define NS_BODY 0x08 /* Lower case flag (body) */ +#define NS_EXT 0x10 /* Lower case flag (ext) */ +#define NS_DOT 0x20 /* Dot entry */ +#define NS_NOLFN 0x40 /* Do not find LFN */ +#define NS_NONAME 0x80 /* Not followed */ + + +/* Limits and boundaries (differ from specs but correct for real DOS/Windows) */ +#define MAX_FAT12 0xFF5 /* Maximum number of FAT12 clusters */ +#define MAX_FAT16 0xFFF5 /* Maximum number of FAT16 clusters */ +#define MAX_FAT32 0xFFFFFF5 /* Maximum number of FAT32 clusters */ +#define MAX_EXFAT 0x7FFFFFFD /* Maximum number of exFAT clusters (limited by implementation) */ +#define MAX_DIR 0x200000 /* Maximum size of FAT directory */ +#define MAX_DIR_EX 0x10000000 /* Maximum size of exFAT directory */ + + +/* FatFs refers the members in the FAT structures as byte array instead of +/ structure members because the structure is not binary compatible between +/ different platforms */ + +#define BS_JmpBoot 0 /* x86 jump instruction (3-byte) */ +#define BS_OEMName 3 /* OEM name (8-byte) */ +#define BPB_BytsPerSec 11 /* Sector size [byte] (WORD) */ +#define BPB_SecPerClus 13 /* Cluster size [sector] (BYTE) */ +#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (WORD) */ +#define BPB_NumFATs 16 /* Number of FATs (BYTE) */ +#define BPB_RootEntCnt 17 /* Size of root directory area for FAT12/16 [entry] (WORD) */ +#define BPB_TotSec16 19 /* Volume size (16-bit) [sector] (WORD) */ +#define BPB_Media 21 /* Media descriptor byte (BYTE) */ +#define BPB_FATSz16 22 /* FAT size (16-bit) [sector] (WORD) */ +#define BPB_SecPerTrk 24 /* Track size for int13h [sector] (WORD) */ +#define BPB_NumHeads 26 /* Number of heads for int13h (WORD) */ +#define BPB_HiddSec 28 /* Volume offset from top of the drive (DWORD) */ +#define BPB_TotSec32 32 /* Volume size (32-bit) [sector] (DWORD) */ +#define BS_DrvNum 36 /* Physical drive number for int13h (BYTE) */ +#define BS_NTres 37 /* Error flag (BYTE) */ +#define BS_BootSig 38 /* Extended boot signature (BYTE) */ +#define BS_VolID 39 /* Volume serial number (DWORD) */ +#define BS_VolLab 43 /* Volume label string (8-byte) */ +#define BS_FilSysType 54 /* File system type string (8-byte) */ +#define BS_BootCode 62 /* Boot code (448-byte) */ +#define BS_55AA 510 /* Signature word (WORD) */ + +#define BPB_FATSz32 36 /* FAT32: FAT size [sector] (DWORD) */ +#define BPB_ExtFlags32 40 /* FAT32: Extended flags (WORD) */ +#define BPB_FSVer32 42 /* FAT32: File system version (WORD) */ +#define BPB_RootClus32 44 /* FAT32: Root directory cluster (DWORD) */ +#define BPB_FSInfo32 48 /* FAT32: Offset of FSINFO sector (WORD) */ +#define BPB_BkBootSec32 50 /* FAT32: Offset of backup boot sector (WORD) */ +#define BS_DrvNum32 64 /* FAT32: Physical drive number for int13h (BYTE) */ +#define BS_NTres32 65 /* FAT32: Error flag (BYTE) */ +#define BS_BootSig32 66 /* FAT32: Extended boot signature (BYTE) */ +#define BS_VolID32 67 /* FAT32: Volume serial number (DWORD) */ +#define BS_VolLab32 71 /* FAT32: Volume label string (8-byte) */ +#define BS_FilSysType32 82 /* FAT32: File system type string (8-byte) */ +#define BS_BootCode32 90 /* FAT32: Boot code (420-byte) */ + +#define BPB_ZeroedEx 11 /* exFAT: MBZ field (53-byte) */ +#define BPB_VolOfsEx 64 /* exFAT: Volume offset from top of the drive [sector] (QWORD) */ +#define BPB_TotSecEx 72 /* exFAT: Volume size [sector] (QWORD) */ +#define BPB_FatOfsEx 80 /* exFAT: FAT offset from top of the volume [sector] (DWORD) */ +#define BPB_FatSzEx 84 /* exFAT: FAT size [sector] (DWORD) */ +#define BPB_DataOfsEx 88 /* exFAT: Data offset from top of the volume [sector] (DWORD) */ +#define BPB_NumClusEx 92 /* exFAT: Number of clusters (DWORD) */ +#define BPB_RootClusEx 96 /* exFAT: Root directory cluster (DWORD) */ +#define BPB_VolIDEx 100 /* exFAT: Volume serial number (DWORD) */ +#define BPB_FSVerEx 104 /* exFAT: File system version (WORD) */ +#define BPB_VolFlagEx 106 /* exFAT: Volume flags (BYTE) */ +#define BPB_ActFatEx 107 /* exFAT: Active FAT flags (BYTE) */ +#define BPB_BytsPerSecEx 108 /* exFAT: Log2 of sector size in byte (BYTE) */ +#define BPB_SecPerClusEx 109 /* exFAT: Log2 of cluster size in sector (BYTE) */ +#define BPB_NumFATsEx 110 /* exFAT: Number of FATs (BYTE) */ +#define BPB_DrvNumEx 111 /* exFAT: Physical drive number for int13h (BYTE) */ +#define BPB_PercInUseEx 112 /* exFAT: Percent in use (BYTE) */ +#define BPB_RsvdEx 113 /* exFAT: Reserved (7-byte) */ +#define BS_BootCodeEx 120 /* exFAT: Boot code (390-byte) */ + +#define FSI_LeadSig 0 /* FAT32 FSI: Leading signature (DWORD) */ +#define FSI_StrucSig 484 /* FAT32 FSI: Structure signature (DWORD) */ +#define FSI_Free_Count 488 /* FAT32 FSI: Number of free clusters (DWORD) */ +#define FSI_Nxt_Free 492 /* FAT32 FSI: Last allocated cluster (DWORD) */ + +#define MBR_Table 446 /* MBR: Offset of partition table in the MBR */ +#define SZ_PTE 16 /* MBR: Size of a partition table entry */ +#define PTE_Boot 0 /* MBR PTE: Boot indicator */ +#define PTE_StHead 1 /* MBR PTE: Start head */ +#define PTE_StSec 2 /* MBR PTE: Start sector */ +#define PTE_StCyl 3 /* MBR PTE: Start cylinder */ +#define PTE_System 4 /* MBR PTE: System ID */ +#define PTE_EdHead 5 /* MBR PTE: End head */ +#define PTE_EdSec 6 /* MBR PTE: End sector */ +#define PTE_EdCyl 7 /* MBR PTE: End cylinder */ +#define PTE_StLba 8 /* MBR PTE: Start in LBA */ +#define PTE_SizLba 12 /* MBR PTE: Size in LBA */ + +#define DIR_Name 0 /* Short file name (11-byte) */ +#define DIR_Attr 11 /* Attribute (BYTE) */ +#define DIR_NTres 12 /* Lower case flag (BYTE) */ +#define DIR_CrtTime10 13 /* Created time sub-second (BYTE) */ +#define DIR_CrtTime 14 /* Created time (DWORD) */ +#define DIR_LstAccDate 18 /* Last accessed date (WORD) */ +#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (WORD) */ +#define DIR_ModTime 22 /* Modified time (DWORD) */ +#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (WORD) */ +#define DIR_FileSize 28 /* File size (DWORD) */ +#define LDIR_Ord 0 /* LFN entry order and LLE flag (BYTE) */ +#define LDIR_Attr 11 /* LFN attribute (BYTE) */ +#define LDIR_Type 12 /* LFN type (BYTE) */ +#define LDIR_Chksum 13 /* Checksum of the SFN entry (BYTE) */ +#define LDIR_FstClusLO 26 /* Must be zero (WORD) */ +#define XDIR_Type 0 /* Type of exFAT directory entry (BYTE) */ +#define XDIR_NumLabel 1 /* Number of volume label characters (BYTE) */ +#define XDIR_Label 2 /* Volume label (11-WORD) */ +#define XDIR_CaseSum 4 /* Sum of case conversion table (DWORD) */ +#define XDIR_NumSec 1 /* Number of secondary entries (BYTE) */ +#define XDIR_SetSum 2 /* Sum of the set of directory entries (WORD) */ +#define XDIR_Attr 4 /* File attribute (WORD) */ +#define XDIR_CrtTime 8 /* Created time (DWORD) */ +#define XDIR_ModTime 12 /* Modified time (DWORD) */ +#define XDIR_AccTime 16 /* Last accessed time (DWORD) */ +#define XDIR_CrtTime10 20 /* Created time subsecond (BYTE) */ +#define XDIR_ModTime10 21 /* Modified time subsecond (BYTE) */ +#define XDIR_CrtTZ 22 /* Created timezone (BYTE) */ +#define XDIR_ModTZ 23 /* Modified timezone (BYTE) */ +#define XDIR_AccTZ 24 /* Last accessed timezone (BYTE) */ +#define XDIR_GenFlags 33 /* Gneral secondary flags (WORD) */ +#define XDIR_NumName 35 /* Number of file name characters (BYTE) */ +#define XDIR_NameHash 36 /* Hash of file name (WORD) */ +#define XDIR_ValidFileSize 40 /* Valid file size (QWORD) */ +#define XDIR_FstClus 52 /* First cluster of the file data (DWORD) */ +#define XDIR_FileSize 56 /* File/Directory size (QWORD) */ + +#define SZDIRE 32 /* Size of a directory entry */ +#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ +#define DDEM 0xE5 /* Deleted directory entry mark set to DIR_Name[0] */ +#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ + + + + + +/*-------------------------------------------------------------------------- + + Module Private Work Area + +---------------------------------------------------------------------------*/ + +/* Remark: Variables here without initial value shall be guaranteed zero/null +/ at start-up. If not, either the linker or start-up routine being used is +/ not compliance with C standard. */ + +#if _VOLUMES < 1 || _VOLUMES > 9 +#error Wrong _VOLUMES setting +#endif +static WORD Fsid; /* File system mount ID */ + +#if _FS_LOCK != 0 +static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ +#endif + +#if _USE_LFN == 0 /* Non-LFN configuration */ +#define DEF_NAMBUF +#define INIT_NAMBUF(fs) +#define FREE_NAMBUF() +#else +#if _MAX_LFN < 12 || _MAX_LFN > 255 +#error Wrong _MAX_LFN setting +#endif + +#if _USE_LFN == 1 /* LFN enabled with static working buffer */ +#if _FS_EXFAT +static BYTE DirBuf[SZDIRE*19]; /* Directory entry block scratchpad buffer (19 entries in size) */ +#endif +static WCHAR LfnBuf[_MAX_LFN+1]; /* LFN enabled with static working buffer */ +#define DEF_NAMBUF +#define INIT_NAMBUF(fs) +#define FREE_NAMBUF() + +#elif _USE_LFN == 2 /* LFN enabled with dynamic working buffer on the stack */ +#if _FS_EXFAT +#define DEF_NAMBUF WCHAR lbuf[_MAX_LFN+1]; BYTE dbuf[SZDIRE*19]; +#define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; (fs)->dirbuf = dbuf; } +#define FREE_NAMBUF() +#else +#define DEF_NAMBUF WCHAR lbuf[_MAX_LFN+1]; +#define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; } +#define FREE_NAMBUF() +#endif + +#elif _USE_LFN == 3 /* LFN enabled with dynamic working buffer on the heap */ +#if _FS_EXFAT +#define DEF_NAMBUF WCHAR *lfn; +#define INIT_NAMBUF(fs) { lfn = ff_memalloc((_MAX_LFN+1)*2 + SZDIRE*19); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; (fs)->dirbuf = (BYTE*)(lfn+_MAX_LFN+1); } +#define FREE_NAMBUF() ff_memfree(lfn) +#else +#define DEF_NAMBUF WCHAR *lfn; +#define INIT_NAMBUF(fs) { lfn = ff_memalloc((_MAX_LFN+1)*2); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; } +#define FREE_NAMBUF() ff_memfree(lfn) +#endif + +#else +#error Wrong _USE_LFN setting +#endif +#endif + +#ifdef _EXCVT +static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for SBCS extended characters */ +#endif + + + + + + +/*-------------------------------------------------------------------------- + + Module Private Functions + +---------------------------------------------------------------------------*/ + + +/*-----------------------------------------------------------------------*/ +/* Load/Store multi-byte word in the FAT structure */ +/*-----------------------------------------------------------------------*/ + +static +WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ +{ + WORD rv; + + rv = ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} + +static +DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ +{ + DWORD rv; + + rv = ptr[3]; + rv = rv << 8 | ptr[2]; + rv = rv << 8 | ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} + +#if _FS_EXFAT +static +QWORD ld_qword (const BYTE* ptr) /* Load an 8-byte little-endian word */ +{ + QWORD rv; + + rv = ptr[7]; + rv = rv << 8 | ptr[6]; + rv = rv << 8 | ptr[5]; + rv = rv << 8 | ptr[4]; + rv = rv << 8 | ptr[3]; + rv = rv << 8 | ptr[2]; + rv = rv << 8 | ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} +#endif + +#if !_FS_READONLY +static +void st_word (BYTE* ptr, WORD val) /* Store a 2-byte word in little-endian */ +{ + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; +} + +static +void st_dword (BYTE* ptr, DWORD val) /* Store a 4-byte word in little-endian */ +{ + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; +} + +#if _FS_EXFAT +static +void st_qword (BYTE* ptr, QWORD val) /* Store an 8-byte word in little-endian */ +{ + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; val >>= 8; + *ptr++ = (BYTE)val; +} +#endif +#endif /* !_FS_READONLY */ + + + +/*-----------------------------------------------------------------------*/ +/* String functions */ +/*-----------------------------------------------------------------------*/ + +// These were originally provided by the FatFs library but we use externally +// provided versions from C stdlib to (hopefully) reduce code size and use +// more efficient versions. +#define mem_cpy memcpy +#define mem_set memset +#define mem_cmp memcmp + +/* Check if chr is contained in the string */ +static +int chk_chr (const char* str, int chr) { /* NZ:contained, ZR:not contained */ + while (*str && *str != chr) str++; + return *str; +} + + + + +#if _FS_REENTRANT +/*-----------------------------------------------------------------------*/ +/* Request/Release grant to access the volume */ +/*-----------------------------------------------------------------------*/ +static +int lock_fs ( + FATFS* fs /* File system object */ +) +{ + return ff_req_grant(fs->sobj); +} + + +static +void unlock_fs ( + FATFS* fs, /* File system object */ + FRESULT res /* Result code to be returned */ +) +{ + if (fs && res != FR_NOT_ENABLED && res != FR_INVALID_DRIVE && res != FR_TIMEOUT) { + ff_rel_grant(fs->sobj); + } +} + +#endif + + + +#if _FS_LOCK != 0 +/*-----------------------------------------------------------------------*/ +/* File lock control functions */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT chk_lock ( /* Check if the file can be accessed */ + DIR* dp, /* Directory object pointing the file to be checked */ + int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ +) +{ + UINT i, be; + + /* Search file semaphore table */ + for (i = be = 0; i < _FS_LOCK; i++) { + if (Files[i].fs) { /* Existing entry */ + if (Files[i].fs == dp->obj.fs && /* Check if the object matched with an open object */ + Files[i].clu == dp->obj.sclust && + Files[i].ofs == dp->dptr) break; + } else { /* Blank entry */ + be = 1; + } + } + if (i == _FS_LOCK) { /* The object is not opened */ + return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ + } + + /* The object has been opened. Reject any open against writing file and all write mode open */ + return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; +} + + +static +int enq_lock (void) /* Check if an entry is available for a new object */ +{ + UINT i; + + for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; + return (i == _FS_LOCK) ? 0 : 1; +} + + +static +UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ + DIR* dp, /* Directory object pointing the file to register or increment */ + int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ +) +{ + UINT i; + + + for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ + if (Files[i].fs == dp->obj.fs && + Files[i].clu == dp->obj.sclust && + Files[i].ofs == dp->dptr) break; + } + + if (i == _FS_LOCK) { /* Not opened. Register it as new. */ + for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; + if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ + Files[i].fs = dp->obj.fs; + Files[i].clu = dp->obj.sclust; + Files[i].ofs = dp->dptr; + Files[i].ctr = 0; + } + + if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ + + Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ + + return i + 1; +} + + +static +FRESULT dec_lock ( /* Decrement object open counter */ + UINT i /* Semaphore index (1..) */ +) +{ + WORD n; + FRESULT res; + + + if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ + n = Files[i].ctr; + if (n == 0x100) n = 0; /* If write mode open, delete the entry */ + if (n > 0) n--; /* Decrement read mode open count */ + Files[i].ctr = n; + if (n == 0) Files[i].fs = 0; /* Delete the entry if open count gets zero */ + res = FR_OK; + } else { + res = FR_INT_ERR; /* Invalid index nunber */ + } + return res; +} + + +static +void clear_lock ( /* Clear lock entries of the volume */ + FATFS *fs +) +{ + UINT i; + + for (i = 0; i < _FS_LOCK; i++) { + if (Files[i].fs == fs) Files[i].fs = 0; + } +} + +#endif /* _FS_LOCK != 0 */ + + + +/*-----------------------------------------------------------------------*/ +/* Move/Flush disk access window in the file system object */ +/*-----------------------------------------------------------------------*/ +#if !_FS_READONLY +static +FRESULT sync_window ( /* Returns FR_OK or FR_DISK_ERROR */ + FATFS* fs /* File system object */ +) +{ + DWORD wsect; + UINT nf; + FRESULT res = FR_OK; + + + if (fs->wflag) { /* Write back the sector if it is dirty */ + wsect = fs->winsect; /* Current sector number */ + if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { + res = FR_DISK_ERR; + } else { + fs->wflag = 0; + if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ + for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ + wsect += fs->fsize; + disk_write(fs->drv, fs->win, wsect, 1); + } + } + } + } + return res; +} +#endif + + +static +FRESULT move_window ( /* Returns FR_OK or FR_DISK_ERROR */ + FATFS* fs, /* File system object */ + DWORD sector /* Sector number to make appearance in the fs->win[] */ +) +{ + FRESULT res = FR_OK; + + + if (sector != fs->winsect) { /* Window offset changed? */ +#if !_FS_READONLY + res = sync_window(fs); /* Write-back changes */ +#endif + if (res == FR_OK) { /* Fill sector window with new data */ + if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { + sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ + res = FR_DISK_ERR; + } + fs->winsect = sector; + } + } + return res; +} + + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Synchronize file system and strage device */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT sync_fs ( /* FR_OK:succeeded, !=0:error */ + FATFS* fs /* File system object */ +) +{ + FRESULT res; + + + res = sync_window(fs); + if (res == FR_OK) { + /* Update FSInfo sector if needed */ + if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { + /* Create FSInfo structure */ + mem_set(fs->win, 0, SS(fs)); + st_word(fs->win + BS_55AA, 0xAA55); + st_dword(fs->win + FSI_LeadSig, 0x41615252); + st_dword(fs->win + FSI_StrucSig, 0x61417272); + st_dword(fs->win + FSI_Free_Count, fs->free_clst); + st_dword(fs->win + FSI_Nxt_Free, fs->last_clst); + /* Write it into the FSInfo sector */ + fs->winsect = fs->volbase + 1; + disk_write(fs->drv, fs->win, fs->winsect, 1); + fs->fsi_flag = 0; + } + /* Make sure that no pending write process in the physical drive */ + if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) res = FR_DISK_ERR; + } + + return res; +} + +#endif + + + +/*-----------------------------------------------------------------------*/ +/* Get sector# from cluster# */ +/*-----------------------------------------------------------------------*/ + +static +DWORD clust2sect ( /* !=0:Sector number, 0:Failed (invalid cluster#) */ + FATFS* fs, /* File system object */ + DWORD clst /* Cluster# to be converted */ +) +{ + clst -= 2; + if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ + return clst * fs->csize + fs->database; +} + + + + +/*-----------------------------------------------------------------------*/ +/* FAT access - Read value of a FAT entry */ +/*-----------------------------------------------------------------------*/ + +static +DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x7FFFFFFF:Cluster status */ + _FDID* obj, /* Corresponding object */ + DWORD clst /* Cluster number to get the value */ +) +{ + UINT wc, bc; + DWORD val; + FATFS *fs = obj->fs; + + + if (clst < 2 || clst >= fs->n_fatent) { /* Check if in valid range */ + val = 1; /* Internal error */ + + } else { + val = 0xFFFFFFFF; /* Default value falls on disk error */ + + switch (fs->fs_type) { + case FS_FAT12 : + bc = (UINT)clst; bc += bc / 2; + if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; + wc = fs->win[bc++ % SS(fs)]; + if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; + wc |= fs->win[bc % SS(fs)] << 8; + val = (clst & 1) ? (wc >> 4) : (wc & 0xFFF); + break; + + case FS_FAT16 : + if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; + val = ld_word(fs->win + clst * 2 % SS(fs)); + break; + + case FS_FAT32 : + if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; + val = ld_dword(fs->win + clst * 4 % SS(fs)) & 0x0FFFFFFF; + break; +#if _FS_EXFAT + case FS_EXFAT : + if (obj->objsize) { + DWORD cofs = clst - obj->sclust; /* Offset from start cluster */ + DWORD clen = (DWORD)((obj->objsize - 1) / SS(fs)) / fs->csize; /* Number of clusters - 1 */ + + if (obj->stat == 2) { /* Is there no valid chain on the FAT? */ + if (cofs <= clen) { + val = (cofs == clen) ? 0x7FFFFFFF : clst + 1; /* Generate the value */ + break; + } + } + if (obj->stat == 3 && cofs < obj->n_cont) { /* Is it in the contiguous part? */ + val = clst + 1; /* Generate the value */ + break; + } + if (obj->stat != 2) { /* Get value from FAT if FAT chain is valid */ + if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; + val = ld_dword(fs->win + clst * 4 % SS(fs)) & 0x7FFFFFFF; + break; + } + } + /* go next */ +#endif + default: + val = 1; /* Internal error */ + } + } + + return val; +} + + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* FAT access - Change value of a FAT entry */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT put_fat ( /* FR_OK(0):succeeded, !=0:error */ + FATFS* fs, /* Corresponding file system object */ + DWORD clst, /* FAT index number (cluster number) to be changed */ + DWORD val /* New value to be set to the entry */ +) +{ + UINT bc; + BYTE *p; + FRESULT res = FR_INT_ERR; + + + if (clst >= 2 && clst < fs->n_fatent) { /* Check if in valid range */ + switch (fs->fs_type) { + case FS_FAT12 : /* Bitfield items */ + bc = (UINT)clst; bc += bc / 2; + res = move_window(fs, fs->fatbase + (bc / SS(fs))); + if (res != FR_OK) break; + p = fs->win + bc++ % SS(fs); + *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; + fs->wflag = 1; + res = move_window(fs, fs->fatbase + (bc / SS(fs))); + if (res != FR_OK) break; + p = fs->win + bc % SS(fs); + *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); + fs->wflag = 1; + break; + + case FS_FAT16 : /* WORD aligned items */ + res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); + if (res != FR_OK) break; + st_word(fs->win + clst * 2 % SS(fs), (WORD)val); + fs->wflag = 1; + break; + + case FS_FAT32 : /* DWORD aligned items */ +#if _FS_EXFAT + case FS_EXFAT : +#endif + res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); + if (res != FR_OK) break; + if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { + val = (val & 0x0FFFFFFF) | (ld_dword(fs->win + clst * 4 % SS(fs)) & 0xF0000000); + } + st_dword(fs->win + clst * 4 % SS(fs), val); + fs->wflag = 1; + break; + } + } + return res; +} + +#endif /* !_FS_READONLY */ + + + + +#if _FS_EXFAT && !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* exFAT: Accessing FAT and Allocation Bitmap */ +/*-----------------------------------------------------------------------*/ + +/*---------------------------------------------*/ +/* exFAT: Find a contiguous free cluster block */ +/*---------------------------------------------*/ + +static +DWORD find_bitmap ( /* 0:No free cluster, 2..:Free cluster found, 0xFFFFFFFF:Disk error */ + FATFS* fs, /* File system object */ + DWORD clst, /* Cluster number to scan from */ + DWORD ncl /* Number of contiguous clusters to find (1..) */ +) +{ + BYTE bm, bv; + UINT i; + DWORD val, scl, ctr; + + + clst -= 2; /* The first bit in the bitmap corresponds to cluster #2 */ + if (clst >= fs->n_fatent - 2) clst = 0; + scl = val = clst; ctr = 0; + for (;;) { + if (move_window(fs, fs->database + val / 8 / SS(fs)) != FR_OK) return 0xFFFFFFFF; /* (assuming bitmap is located top of the cluster heap) */ + i = val / 8 % SS(fs); bm = 1 << (val % 8); + do { + do { + bv = fs->win[i] & bm; bm <<= 1; /* Get bit value */ + if (++val >= fs->n_fatent - 2) { /* Next cluster (with wrap-around) */ + val = 0; bm = 0; i = 4096; + } + if (!bv) { /* Is it a free cluster? */ + if (++ctr == ncl) return scl + 2; /* Check run length */ + } else { + scl = val; ctr = 0; /* Encountered a live cluster, restart to scan */ + } + if (val == clst) return 0; /* All cluster scanned? */ + } while (bm); + bm = 1; + } while (++i < SS(fs)); + } +} + + +/*------------------------------------*/ +/* exFAT: Set/Clear a block of bitmap */ +/*------------------------------------*/ + +static +FRESULT change_bitmap ( + FATFS* fs, /* File system object */ + DWORD clst, /* Cluster number to change from */ + DWORD ncl, /* Number of clusters to be changed */ + int bv /* bit value to be set (0 or 1) */ +) +{ + BYTE bm; + UINT i; + DWORD sect; + + + clst -= 2; /* The first bit corresponds to cluster #2 */ + sect = fs->database + clst / 8 / SS(fs); /* Sector address (assuming bitmap is located top of the cluster heap) */ + i = clst / 8 % SS(fs); /* Byte offset in the sector */ + bm = 1 << (clst % 8); /* Bit mask in the byte */ + for (;;) { + if (move_window(fs, sect++) != FR_OK) return FR_DISK_ERR; + do { + do { + if (bv == (int)((fs->win[i] & bm) != 0)) return FR_INT_ERR; /* Is the bit expected value? */ + fs->win[i] ^= bm; /* Flip the bit */ + fs->wflag = 1; + if (--ncl == 0) return FR_OK; /* All bits processed? */ + } while (bm <<= 1); /* Next bit */ + bm = 1; + } while (++i < SS(fs)); /* Next byte */ + i = 0; + } +} + + +/*---------------------------------------------*/ +/* Complement contiguous part of the FAT chain */ +/*---------------------------------------------*/ + +static +FRESULT fill_fat_chain ( + _FDID* obj /* Pointer to the corresponding object */ +) +{ + FRESULT res; + DWORD cl, n; + + if (obj->stat == 3) { /* Has the object been changed 'fragmented'? */ + for (cl = obj->sclust, n = obj->n_cont; n; cl++, n--) { /* Create cluster chain on the FAT */ + res = put_fat(obj->fs, cl, cl + 1); + if (res != FR_OK) return res; + } + obj->stat = 0; /* Change status 'FAT chain is valid' */ + } + return FR_OK; +} + +#endif /* _FS_EXFAT && !_FS_READONLY */ + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* FAT handling - Remove a cluster chain */ +/*-----------------------------------------------------------------------*/ +static +FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */ + _FDID* obj, /* Corresponding object */ + DWORD clst, /* Cluster to remove a chain from */ + DWORD pclst /* Previous cluster of clst (0:an entire chain) */ +) +{ + FRESULT res = FR_OK; + DWORD nxt; + FATFS *fs = obj->fs; +#if _FS_EXFAT || _USE_TRIM + DWORD scl = clst, ecl = clst; +#endif +#if _USE_TRIM + DWORD rt[2]; +#endif + + if (clst < 2 || clst >= fs->n_fatent) return FR_INT_ERR; /* Check if in valid range */ + + /* Mark the previous cluster 'EOC' on the FAT if it exists */ + if (pclst && (!_FS_EXFAT || fs->fs_type != FS_EXFAT || obj->stat != 2)) { + res = put_fat(fs, pclst, 0xFFFFFFFF); + if (res != FR_OK) return res; + } + + /* Remove the chain */ + do { + nxt = get_fat(obj, clst); /* Get cluster status */ + if (nxt == 0) break; /* Empty cluster? */ + if (nxt == 1) return FR_INT_ERR; /* Internal error? */ + if (nxt == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error? */ + if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { + res = put_fat(fs, clst, 0); /* Mark the cluster 'free' on the FAT */ + if (res != FR_OK) return res; + } + if (fs->free_clst < fs->n_fatent - 2) { /* Update FSINFO */ + fs->free_clst++; + fs->fsi_flag |= 1; + } +#if _FS_EXFAT || _USE_TRIM + if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ + ecl = nxt; + } else { /* End of contiguous cluster block */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + res = change_bitmap(fs, scl, ecl - scl + 1, 0); /* Mark the cluster block 'free' on the bitmap */ + if (res != FR_OK) return res; + } +#endif +#if _USE_TRIM + rt[0] = clust2sect(fs, scl); /* Start sector */ + rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ + disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Inform device the block can be erased */ +#endif + scl = ecl = nxt; + } +#endif + clst = nxt; /* Next cluster */ + } while (clst < fs->n_fatent); /* Repeat while not the last link */ + +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + if (pclst == 0) { /* Does object have no chain? */ + obj->stat = 0; /* Change the object status 'initial' */ + } else { + if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Did the chain got contiguous? */ + obj->stat = 2; /* Change the object status 'contiguous' */ + } + } + } +#endif + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* FAT handling - Stretch a chain or Create a new chain */ +/*-----------------------------------------------------------------------*/ +static +DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ + _FDID* obj, /* Corresponding object */ + DWORD clst /* Cluster# to stretch, 0:Create a new chain */ +) +{ + DWORD cs, ncl, scl; + FRESULT res; + FATFS *fs = obj->fs; + + + if (clst == 0) { /* Create a new chain */ + scl = fs->last_clst; /* Get suggested cluster to start from */ + if (scl == 0 || scl >= fs->n_fatent) scl = 1; + } + else { /* Stretch current chain */ + cs = get_fat(obj, clst); /* Check the cluster status */ + if (cs < 2) return 1; /* Invalid value */ + if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ + if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ + scl = clst; + } + +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + ncl = find_bitmap(fs, scl, 1); /* Find a free cluster */ + if (ncl == 0 || ncl == 0xFFFFFFFF) return ncl; /* No free cluster or hard error? */ + res = change_bitmap(fs, ncl, 1, 1); /* Mark the cluster 'in use' */ + if (res == FR_INT_ERR) return 1; + if (res == FR_DISK_ERR) return 0xFFFFFFFF; + if (clst == 0) { /* Is it a new chain? */ + obj->stat = 2; /* Set status 'contiguous chain' */ + } else { /* This is a stretched chain */ + if (obj->stat == 2 && ncl != scl + 1) { /* Is the chain got fragmented? */ + obj->n_cont = scl - obj->sclust; /* Set size of the contiguous part */ + obj->stat = 3; /* Change status 'just fragmented' */ + } + } + } else +#endif + { /* On the FAT12/16/32 volume */ + ncl = scl; /* Start cluster */ + for (;;) { + ncl++; /* Next cluster */ + if (ncl >= fs->n_fatent) { /* Check wrap-around */ + ncl = 2; + if (ncl > scl) return 0; /* No free cluster */ + } + cs = get_fat(obj, ncl); /* Get the cluster status */ + if (cs == 0) break; /* Found a free cluster */ + if (cs == 1 || cs == 0xFFFFFFFF) return cs; /* An error occurred */ + if (ncl == scl) return 0; /* No free cluster */ + } + } + + if (_FS_EXFAT && fs->fs_type == FS_EXFAT && obj->stat == 2) { /* Is it a contiguous chain? */ + res = FR_OK; /* FAT does not need to be written */ + } else { + res = put_fat(fs, ncl, 0xFFFFFFFF); /* Mark the new cluster 'EOC' */ + if (res == FR_OK && clst) { + res = put_fat(fs, clst, ncl); /* Link it from the previous one if needed */ + } + } + + if (res == FR_OK) { /* Update FSINFO if function succeeded. */ + fs->last_clst = ncl; + if (fs->free_clst < fs->n_fatent - 2) fs->free_clst--; + fs->fsi_flag |= 1; + } else { + ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; /* Failed. Create error status */ + } + + return ncl; /* Return new cluster number or error status */ +} + +#endif /* !_FS_READONLY */ + + + + +#if _USE_FASTSEEK +/*-----------------------------------------------------------------------*/ +/* FAT handling - Convert offset into cluster with link map table */ +/*-----------------------------------------------------------------------*/ + +static +DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ + FIL* fp, /* Pointer to the file object */ + FSIZE_t ofs /* File offset to be converted to cluster# */ +) +{ + DWORD cl, ncl, *tbl; + FATFS *fs = fp->obj.fs; + + + tbl = fp->cltbl + 1; /* Top of CLMT */ + cl = (DWORD)(ofs / SS(fs) / fs->csize); /* Cluster order from top of the file */ + for (;;) { + ncl = *tbl++; /* Number of cluters in the fragment */ + if (ncl == 0) return 0; /* End of table? (error) */ + if (cl < ncl) break; /* In this fragment? */ + cl -= ncl; tbl++; /* Next fragment */ + } + return cl + *tbl; /* Return the cluster number */ +} + +#endif /* _USE_FASTSEEK */ + + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Set directory index */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_sdi ( /* FR_OK(0):succeeded, !=0:error */ + DIR* dp, /* Pointer to directory object */ + DWORD ofs /* Offset of directory table */ +) +{ + DWORD csz, clst; + FATFS *fs = dp->obj.fs; + + + if (ofs >= (DWORD)((_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR) || ofs % SZDIRE) { /* Check range of offset and alignment */ + return FR_INT_ERR; + } + dp->dptr = ofs; /* Set current offset */ + clst = dp->obj.sclust; /* Table start cluster (0:root) */ + if (clst == 0 && fs->fs_type >= FS_FAT32) { /* Replace cluster# 0 with root cluster# */ + clst = fs->dirbase; + if (_FS_EXFAT) dp->obj.stat = 0; /* exFAT: Root dir has an FAT chain */ + } + + if (clst == 0) { /* Static table (root-directory in FAT12/16) */ + if (ofs / SZDIRE >= fs->n_rootdir) return FR_INT_ERR; /* Is index out of range? */ + dp->sect = fs->dirbase; + + } else { /* Dynamic table (sub-directory or root-directory in FAT32+) */ + csz = (DWORD)fs->csize * SS(fs); /* Bytes per cluster */ + while (ofs >= csz) { /* Follow cluster chain */ + clst = get_fat(&dp->obj, clst); /* Get next cluster */ + if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ + if (clst < 2 || clst >= fs->n_fatent) return FR_INT_ERR; /* Reached to end of table or internal error */ + ofs -= csz; + } + dp->sect = clust2sect(fs, clst); + } + dp->clust = clst; /* Current cluster# */ + if (!dp->sect) return FR_INT_ERR; + dp->sect += ofs / SS(fs); /* Sector# of the directory entry */ + dp->dir = fs->win + (ofs % SS(fs)); /* Pointer to the entry in the win[] */ + + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Move directory table index next */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ + DIR* dp, /* Pointer to the directory object */ + int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ +) +{ + DWORD ofs, clst; + FATFS *fs = dp->obj.fs; +#if !_FS_READONLY + UINT n; +#endif + + ofs = dp->dptr + SZDIRE; /* Next entry */ + if (!dp->sect || ofs >= (DWORD)((_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) return FR_NO_FILE; /* Report EOT when offset has reached max value */ + + if (ofs % SS(fs) == 0) { /* Sector changed? */ + dp->sect++; /* Next sector */ + + if (!dp->clust) { /* Static table */ + if (ofs / SZDIRE >= fs->n_rootdir) { /* Report EOT if it reached end of static table */ + dp->sect = 0; return FR_NO_FILE; + } + } + else { /* Dynamic table */ + if ((ofs / SS(fs) & (fs->csize - 1)) == 0) { /* Cluster changed? */ + clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ + if (clst <= 1) return FR_INT_ERR; /* Internal error */ + if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ + if (clst >= fs->n_fatent) { /* Reached end of dynamic table */ +#if !_FS_READONLY + if (!stretch) { /* If no stretch, report EOT */ + dp->sect = 0; return FR_NO_FILE; + } + clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ + if (clst == 0) return FR_DENIED; /* No free cluster */ + if (clst == 1) return FR_INT_ERR; /* Internal error */ + if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ + /* Clean-up the stretched table */ + if (_FS_EXFAT) dp->obj.stat |= 4; /* The directory needs to be updated */ + if (sync_window(fs) != FR_OK) return FR_DISK_ERR; /* Flush disk access window */ + mem_set(fs->win, 0, SS(fs)); /* Clear window buffer */ + for (n = 0, fs->winsect = clust2sect(fs, clst); n < fs->csize; n++, fs->winsect++) { /* Fill the new cluster with 0 */ + fs->wflag = 1; + if (sync_window(fs) != FR_OK) return FR_DISK_ERR; + } + fs->winsect -= n; /* Restore window offset */ +#else + if (!stretch) dp->sect = 0; /* If no stretch, report EOT (this is to suppress warning) */ + dp->sect = 0; return FR_NO_FILE; /* Report EOT */ +#endif + } + dp->clust = clst; /* Initialize data for new cluster */ + dp->sect = clust2sect(fs, clst); + } + } + } + dp->dptr = ofs; /* Current entry */ + dp->dir = fs->win + ofs % SS(fs); /* Pointer to the entry in the win[] */ + + return FR_OK; +} + + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Directory handling - Reserve a block of directory entries */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_alloc ( /* FR_OK(0):succeeded, !=0:error */ + DIR* dp, /* Pointer to the directory object */ + UINT nent /* Number of contiguous entries to allocate */ +) +{ + FRESULT res; + UINT n; + FATFS *fs = dp->obj.fs; + + + res = dir_sdi(dp, 0); + if (res == FR_OK) { + n = 0; + do { + res = move_window(fs, dp->sect); + if (res != FR_OK) break; +#if _FS_EXFAT + if ((fs->fs_type == FS_EXFAT) ? (int)((dp->dir[XDIR_Type] & 0x80) == 0) : (int)(dp->dir[DIR_Name] == DDEM || dp->dir[DIR_Name] == 0)) { +#else + if (dp->dir[DIR_Name] == DDEM || dp->dir[DIR_Name] == 0) { +#endif + if (++n == nent) break; /* A block of contiguous free entries is found */ + } else { + n = 0; /* Not a blank entry. Restart to search */ + } + res = dir_next(dp, 1); + } while (res == FR_OK); /* Next entry with table stretch enabled */ + } + + if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ + return res; +} + +#endif /* !_FS_READONLY */ + + + + +/*-----------------------------------------------------------------------*/ +/* FAT: Directory handling - Load/Store start cluster number */ +/*-----------------------------------------------------------------------*/ + +static +DWORD ld_clust ( /* Returns the top cluster value of the SFN entry */ + FATFS* fs, /* Pointer to the fs object */ + const BYTE* dir /* Pointer to the key entry */ +) +{ + DWORD cl; + + cl = ld_word(dir + DIR_FstClusLO); + if (fs->fs_type == FS_FAT32) { + cl |= (DWORD)ld_word(dir + DIR_FstClusHI) << 16; + } + + return cl; +} + + +#if !_FS_READONLY +static +void st_clust ( + FATFS* fs, /* Pointer to the fs object */ + BYTE* dir, /* Pointer to the key entry */ + DWORD cl /* Value to be set */ +) +{ + st_word(dir + DIR_FstClusLO, (WORD)cl); + if (fs->fs_type == FS_FAT32) { + st_word(dir + DIR_FstClusHI, (WORD)(cl >> 16)); + } +} +#endif + + + +#if _USE_LFN != 0 +/*------------------------------------------------------------------------*/ +/* FAT-LFN: LFN handling */ +/*------------------------------------------------------------------------*/ +static +const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ + + +/*--------------------------------------------------------*/ +/* FAT-LFN: Compare a part of file name with an LFN entry */ +/*--------------------------------------------------------*/ +static +int cmp_lfn ( /* 1:matched, 0:not matched */ + const WCHAR* lfnbuf, /* Pointer to the LFN working buffer to be compared */ + BYTE* dir /* Pointer to the directory entry containing the part of LFN */ +) +{ + UINT i, s; + WCHAR wc, uc; + + + if (ld_word(dir + LDIR_FstClusLO) != 0) return 0; /* Check LDIR_FstClusLO */ + + i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ + + for (wc = 1, s = 0; s < 13; s++) { /* Process all characters in the entry */ + uc = ld_word(dir + LfnOfs[s]); /* Pick an LFN character */ + if (wc) { + if (i >= _MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++])) { /* Compare it */ + return 0; /* Not matched */ + } + wc = uc; + } else { + if (uc != 0xFFFF) return 0; /* Check filler */ + } + } + + if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) return 0; /* Last segment matched but different length */ + + return 1; /* The part of LFN matched */ +} + + +#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 || _USE_LABEL || _FS_EXFAT +/*-----------------------------------------------------*/ +/* FAT-LFN: Pick a part of file name from an LFN entry */ +/*-----------------------------------------------------*/ +static +int pick_lfn ( /* 1:succeeded, 0:buffer overflow or invalid LFN entry */ + WCHAR* lfnbuf, /* Pointer to the LFN working buffer */ + BYTE* dir /* Pointer to the LFN entry */ +) +{ + UINT i, s; + WCHAR wc, uc; + + + if (ld_word(dir + LDIR_FstClusLO) != 0) return 0; /* Check LDIR_FstClusLO */ + + i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ + + for (wc = 1, s = 0; s < 13; s++) { /* Process all characters in the entry */ + uc = ld_word(dir + LfnOfs[s]); /* Pick an LFN character */ + if (wc) { + if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ + lfnbuf[i++] = wc = uc; /* Store it */ + } else { + if (uc != 0xFFFF) return 0; /* Check filler */ + } + } + + if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ + if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ + lfnbuf[i] = 0; + } + + return 1; /* The part of LFN is valid */ +} +#endif + + +#if !_FS_READONLY +/*-----------------------------------------*/ +/* FAT-LFN: Create an entry of LFN entries */ +/*-----------------------------------------*/ +static +void put_lfn ( + const WCHAR* lfn, /* Pointer to the LFN */ + BYTE* dir, /* Pointer to the LFN entry to be created */ + BYTE ord, /* LFN order (1-20) */ + BYTE sum /* Checksum of the corresponding SFN */ +) +{ + UINT i, s; + WCHAR wc; + + + dir[LDIR_Chksum] = sum; /* Set checksum */ + dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ + dir[LDIR_Type] = 0; + st_word(dir + LDIR_FstClusLO, 0); + + i = (ord - 1) * 13; /* Get offset in the LFN working buffer */ + s = wc = 0; + do { + if (wc != 0xFFFF) wc = lfn[i++]; /* Get an effective character */ + st_word(dir + LfnOfs[s], wc); /* Put it */ + if (wc == 0) wc = 0xFFFF; /* Padding characters for left locations */ + } while (++s < 13); + if (wc == 0xFFFF || !lfn[i]) ord |= LLEF; /* Last LFN part is the start of LFN sequence */ + dir[LDIR_Ord] = ord; /* Set the LFN order */ +} + +#endif /* !_FS_READONLY */ +#endif /* _USE_LFN != 0 */ + + + +#if _USE_LFN != 0 && !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* FAT-LFN: Create a Numbered SFN */ +/*-----------------------------------------------------------------------*/ + +static +void gen_numname ( + BYTE* dst, /* Pointer to the buffer to store numbered SFN */ + const BYTE* src, /* Pointer to SFN */ + const WCHAR* lfn, /* Pointer to LFN */ + UINT seq /* Sequence number */ +) +{ + BYTE ns[8], c; + UINT i, j; + WCHAR wc; + DWORD sr; + + + mem_cpy(dst, src, 11); + + if (seq > 5) { /* In case of many collisions, generate a hash number instead of sequential number */ + sr = seq; + while (*lfn) { /* Create a CRC */ + wc = *lfn++; + for (i = 0; i < 16; i++) { + sr = (sr << 1) + (wc & 1); + wc >>= 1; + if (sr & 0x10000) sr ^= 0x11021; + } + } + seq = (UINT)sr; + } + + /* itoa (hexdecimal) */ + i = 7; + do { + c = (BYTE)((seq % 16) + '0'); + if (c > '9') c += 7; + ns[i--] = c; + seq /= 16; + } while (seq); + ns[i] = '~'; + + /* Append the number */ + for (j = 0; j < i && dst[j] != ' '; j++) { + if (IsDBCS1(dst[j])) { + if (j == i - 1) break; + j++; + } + } + do { + dst[j++] = (i < 8) ? ns[i++] : ' '; + } while (j < 8); +} +#endif /* _USE_LFN != 0 && !_FS_READONLY */ + + + +#if _USE_LFN != 0 +/*-----------------------------------------------------------------------*/ +/* FAT-LFN: Calculate checksum of an SFN entry */ +/*-----------------------------------------------------------------------*/ + +static +BYTE sum_sfn ( + const BYTE* dir /* Pointer to the SFN entry */ +) +{ + BYTE sum = 0; + UINT n = 11; + + do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); + return sum; +} + +#endif /* _USE_LFN != 0 */ + + + +#if _FS_EXFAT +/*-----------------------------------------------------------------------*/ +/* exFAT: Checksum */ +/*-----------------------------------------------------------------------*/ + +static +WORD xdir_sum ( /* Get checksum of the directoly block */ + const BYTE* dir /* Directory entry block to be calculated */ +) +{ + UINT i, szblk; + WORD sum; + + + szblk = (dir[XDIR_NumSec] + 1) * SZDIRE; + for (i = sum = 0; i < szblk; i++) { + if (i == XDIR_SetSum) { /* Skip sum field */ + i++; + } else { + sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + dir[i]; + } + } + return sum; +} + + + +static +WORD xname_sum ( /* Get check sum (to be used as hash) of the name */ + const WCHAR* name /* File name to be calculated */ +) +{ + WCHAR chr; + WORD sum = 0; + + + while ((chr = *name++) != 0) { + chr = ff_wtoupper(chr); /* File name needs to be ignored case */ + sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr & 0xFF); + sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr >> 8); + } + return sum; +} + + +#if !_FS_READONLY && _USE_MKFS +static +DWORD xsum32 ( + BYTE dat, /* Data to be sumed */ + DWORD sum /* Previous value */ +) +{ + sum = ((sum & 1) ? 0x80000000 : 0) + (sum >> 1) + dat; + return sum; +} +#endif + + +#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 +/*------------------------------------------------------*/ +/* exFAT: Get object information from a directory block */ +/*------------------------------------------------------*/ + +static +void get_xdir_info ( + BYTE* dirb, /* Pointer to the direcotry entry block 85+C0+C1s */ + FILINFO* fno /* Buffer to store the extracted file information */ +) +{ + UINT di, si; + WCHAR w; +#if !_LFN_UNICODE + UINT nc; +#endif + + /* Get file name */ +#if _LFN_UNICODE + if (dirb[XDIR_NumName] <= _MAX_LFN) { + for (si = SZDIRE * 2, di = 0; di < dirb[XDIR_NumName]; si += 2, di++) { + if ((si % SZDIRE) == 0) si += 2; /* Skip entry type field */ + w = ld_word(dirb + si); /* Get a character */ + fno->fname[di] = w; /* Store it */ + } + } else { + di = 0; /* Buffer overflow and inaccessible object */ + } +#else + for (si = SZDIRE * 2, di = nc = 0; nc < dirb[XDIR_NumName]; si += 2, nc++) { + if ((si % SZDIRE) == 0) si += 2; /* Skip entry type field */ + w = ld_word(dirb + si); /* Get a character */ + w = ff_convert(w, 0); /* Unicode -> OEM */ + if (w == 0) { di = 0; break; } /* Could not be converted and inaccessible object */ + if (_DF1S && w >= 0x100) { /* Put 1st byte if it is a DBC (always false at SBCS cfg) */ + fno->fname[di++] = (char)(w >> 8); + } + if (di >= _MAX_LFN) { di = 0; break; } /* Buffer overflow and inaccessible object */ + fno->fname[di++] = (char)w; + } +#endif + if (di == 0) fno->fname[di++] = '?'; /* Inaccessible object? */ + fno->fname[di] = 0; /* Terminate file name */ + + fno->altname[0] = 0; /* No SFN */ + fno->fattrib = dirb[XDIR_Attr]; /* Attribute */ + fno->fsize = (fno->fattrib & AM_DIR) ? 0 : ld_qword(dirb + XDIR_FileSize); /* Size */ + fno->ftime = ld_word(dirb + XDIR_ModTime + 0); /* Time */ + fno->fdate = ld_word(dirb + XDIR_ModTime + 2); /* Date */ +} + +#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ + + +/*-----------------------------------*/ +/* exFAT: Get a directry entry block */ +/*-----------------------------------*/ + +static +FRESULT load_xdir ( /* FR_INT_ERR: invalid entry block */ + DIR* dp /* Pointer to the reading direcotry object pointing the 85 entry */ +) +{ + FRESULT res; + UINT i, nent; + BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory direcotry entry block 85+C0+C1s */ + + + /* Load 85 entry */ + res = move_window(dp->obj.fs, dp->sect); + if (res != FR_OK) return res; + if (dp->dir[XDIR_Type] != 0x85) return FR_INT_ERR; + mem_cpy(dirb, dp->dir, SZDIRE); + nent = dirb[XDIR_NumSec] + 1; + + /* Load C0 entry */ + res = dir_next(dp, 0); + if (res != FR_OK) return res; + res = move_window(dp->obj.fs, dp->sect); + if (res != FR_OK) return res; + if (dp->dir[XDIR_Type] != 0xC0) return FR_INT_ERR; + mem_cpy(dirb + SZDIRE, dp->dir, SZDIRE); + + /* Load C1 entries */ + if (nent < 3 || nent > 19) return FR_NO_FILE; + i = SZDIRE * 2; nent *= SZDIRE; + do { + res = dir_next(dp, 0); + if (res != FR_OK) return res; + res = move_window(dp->obj.fs, dp->sect); + if (res != FR_OK) return res; + if (dp->dir[XDIR_Type] != 0xC1) return FR_INT_ERR; + mem_cpy(dirb + i, dp->dir, SZDIRE); + i += SZDIRE; + } while (i < nent); + + /* Sanity check */ + if (xdir_sum(dirb) != ld_word(dirb + XDIR_SetSum)) return FR_INT_ERR; + + return FR_OK; +} + + +#if !_FS_READONLY || _FS_RPATH != 0 +/*------------------------------------------------*/ +/* exFAT: Load the object's directory entry block */ +/*------------------------------------------------*/ +static +FRESULT load_obj_dir ( + DIR* dp, /* Blank directory object to be used to access containing direcotry */ + const _FDID* obj /* Object with containing directory information */ +) +{ + FRESULT res; + + + /* Open object containing directory */ + dp->obj.fs = obj->fs; + dp->obj.sclust = obj->c_scl; + dp->obj.stat = (BYTE)obj->c_size; + dp->obj.objsize = obj->c_size & 0xFFFFFF00; + dp->blk_ofs = obj->c_ofs; + + res = dir_sdi(dp, dp->blk_ofs); /* Goto the block location */ + if (res == FR_OK) { + res = load_xdir(dp); /* Load the object's entry block */ + } + return res; +} +#endif + + +#if !_FS_READONLY +/*-----------------------------------------------*/ +/* exFAT: Store the directory block to the media */ +/*-----------------------------------------------*/ +static +FRESULT store_xdir ( + DIR* dp /* Pointer to the direcotry object */ +) +{ + FRESULT res; + UINT nent; + BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the direcotry entry block 85+C0+C1s */ + + /* Create set sum */ + st_word(dirb + XDIR_SetSum, xdir_sum(dirb)); + nent = dirb[XDIR_NumSec] + 1; + + /* Store the set of directory to the volume */ + res = dir_sdi(dp, dp->blk_ofs); + while (res == FR_OK) { + res = move_window(dp->obj.fs, dp->sect); + if (res != FR_OK) break; + mem_cpy(dp->dir, dirb, SZDIRE); + dp->obj.fs->wflag = 1; + if (--nent == 0) break; + dirb += SZDIRE; + res = dir_next(dp, 0); + } + return (res == FR_OK || res == FR_DISK_ERR) ? res : FR_INT_ERR; +} + + + +/*-------------------------------------------*/ +/* exFAT: Create a new directory enrty block */ +/*-------------------------------------------*/ + +static +void create_xdir ( + BYTE* dirb, /* Pointer to the direcotry entry block buffer */ + const WCHAR* lfn /* Pointer to the nul terminated file name */ +) +{ + UINT i; + BYTE nb, nc; + WCHAR chr; + + + mem_set(dirb, 0, 2 * SZDIRE); /* Initialize 85+C0 entry */ + dirb[XDIR_Type] = 0x85; + dirb[XDIR_Type + SZDIRE] = 0xC0; + st_word(dirb + XDIR_NameHash, xname_sum(lfn)); /* Set name hash */ + + i = SZDIRE * 2; /* C1 offset */ + nc = 0; nb = 1; chr = 1; + do { + dirb[i++] = 0xC1; dirb[i++] = 0; /* Entry type C1 */ + do { /* Fill name field */ + if (chr && (chr = lfn[nc]) != 0) nc++; /* Get a character if exist */ + st_word(dirb + i, chr); i += 2; /* Store it */ + } while (i % SZDIRE); + nb++; + } while (lfn[nc]); /* Fill next entry if any char follows */ + + dirb[XDIR_NumName] = nc; /* Set name length */ + dirb[XDIR_NumSec] = nb; /* Set number of C0+C1s */ +} + +#endif /* !_FS_READONLY */ +#endif /* _FS_EXFAT */ + + + +#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 || _USE_LABEL || _FS_EXFAT +/*-----------------------------------------------------------------------*/ +/* Read an object from the directory */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_read ( + DIR* dp, /* Pointer to the directory object */ + int vol /* Filtered by 0:file/directory or 1:volume label */ +) +{ + FRESULT res = FR_NO_FILE; + FATFS *fs = dp->obj.fs; + BYTE a, c; +#if _USE_LFN != 0 + BYTE ord = 0xFF, sum = 0xFF; +#endif + + while (dp->sect) { + res = move_window(fs, dp->sect); + if (res != FR_OK) break; + c = dp->dir[DIR_Name]; /* Test for the entry type */ + if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of the directory */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + if (_USE_LABEL && vol) { + if (c == 0x83) break; /* Volume label entry? */ + } else { + if (c == 0x85) { /* Start of the file entry block? */ + dp->blk_ofs = dp->dptr; /* Get location of the block */ + res = load_xdir(dp); /* Load the entry block */ + if (res == FR_OK) { + dp->obj.attr = fs->dirbuf[XDIR_Attr] & AM_MASK; /* Get attribute */ + } + break; + } + } + } else +#endif + { /* On the FAT12/16/32 volume */ + dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */ +#if _USE_LFN != 0 /* LFN configuration */ + if (c == DDEM || c == '.' || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ + ord = 0xFF; + } else { + if (a == AM_LFN) { /* An LFN entry is found */ + if (c & LLEF) { /* Is it start of an LFN sequence? */ + sum = dp->dir[LDIR_Chksum]; + c &= (BYTE)~LLEF; ord = c; + dp->blk_ofs = dp->dptr; + } + /* Check LFN validity and capture it */ + ord = (c == ord && sum == dp->dir[LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF; + } else { /* An SFN entry is found */ + if (ord || sum != sum_sfn(dp->dir)) { /* Is there a valid LFN? */ + dp->blk_ofs = 0xFFFFFFFF; /* It has no LFN. */ + } + break; + } + } +#else /* Non LFN configuration */ + if (c != DDEM && c != '.' && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) { /* Is it a valid entry? */ + break; + } +#endif + } + res = dir_next(dp, 0); /* Next entry */ + if (res != FR_OK) break; + } + + if (res != FR_OK) dp->sect = 0; /* Terminate the read operation on error or EOT */ + return res; +} + +#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Find an object in the directory */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */ + DIR* dp /* Pointer to the directory object with the file name */ +) +{ + FRESULT res; + FATFS *fs = dp->obj.fs; + BYTE c; +#if _USE_LFN != 0 + BYTE a, ord, sum; +#endif + + res = dir_sdi(dp, 0); /* Rewind directory object */ + if (res != FR_OK) return res; +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + BYTE nc; + UINT di, ni; + WORD hash = xname_sum(fs->lfnbuf); /* Hash value of the name to find */ + + while ((res = dir_read(dp, 0)) == FR_OK) { /* Read an item */ + if (ld_word(fs->dirbuf + XDIR_NameHash) != hash) continue; /* Skip the comparison if hash value mismatched */ + for (nc = fs->dirbuf[XDIR_NumName], di = SZDIRE * 2, ni = 0; nc; nc--, di += 2, ni++) { /* Compare the name */ + if ((di % SZDIRE) == 0) di += 2; + if (ff_wtoupper(ld_word(fs->dirbuf + di)) != ff_wtoupper(fs->lfnbuf[ni])) break; + } + if (nc == 0 && !fs->lfnbuf[ni]) break; /* Name matched? */ + } + return res; + } +#endif + /* On the FAT12/16/32 volume */ +#if _USE_LFN != 0 + ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */ +#endif + do { + res = move_window(fs, dp->sect); + if (res != FR_OK) break; + c = dp->dir[DIR_Name]; + if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ +#if _USE_LFN != 0 /* LFN configuration */ + dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; + if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ + ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */ + } else { + if (a == AM_LFN) { /* An LFN entry is found */ + if (!(dp->fn[NSFLAG] & NS_NOLFN)) { + if (c & LLEF) { /* Is it start of LFN sequence? */ + sum = dp->dir[LDIR_Chksum]; + c &= (BYTE)~LLEF; ord = c; /* LFN start order */ + dp->blk_ofs = dp->dptr; /* Start offset of LFN */ + } + /* Check validity of the LFN entry and compare it with given name */ + ord = (c == ord && sum == dp->dir[LDIR_Chksum] && cmp_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF; + } + } else { /* An SFN entry is found */ + if (!ord && sum == sum_sfn(dp->dir)) break; /* LFN matched? */ + if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dp->dir, dp->fn, 11)) break; /* SFN matched? */ + ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */ + } + } +#else /* Non LFN configuration */ + dp->obj.attr = dp->dir[DIR_Attr] & AM_MASK; + if (!(dp->dir[DIR_Attr] & AM_VOL) && !mem_cmp(dp->dir, dp->fn, 11)) break; /* Is it a valid entry? */ +#endif + res = dir_next(dp, 0); /* Next entry */ + } while (res == FR_OK); + + return res; +} + + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Register an object to the directory */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */ + DIR* dp /* Target directory with object name to be created */ +) +{ + FRESULT res; + FATFS *fs = dp->obj.fs; +#if _USE_LFN != 0 /* LFN configuration */ + UINT n, nlen, nent; + BYTE sn[12], sum; + + + if (dp->fn[NSFLAG] & (NS_DOT | NS_NONAME)) return FR_INVALID_NAME; /* Check name validity */ + for (nlen = 0; fs->lfnbuf[nlen]; nlen++) ; /* Get lfn length */ + +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + DIR dj; + + nent = (nlen + 14) / 15 + 2; /* Number of entries to allocate (85+C0+C1s) */ + res = dir_alloc(dp, nent); /* Allocate entries */ + if (res != FR_OK) return res; + dp->blk_ofs = dp->dptr - SZDIRE * (nent - 1); /* Set block position */ + + if (dp->obj.sclust != 0 && (dp->obj.stat & 4)) { /* Has the sub-directory been stretched? */ + dp->obj.stat &= 3; + dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase object size by cluster size */ + res = fill_fat_chain(&dp->obj); /* Complement FAT chain if needed */ + if (res != FR_OK) return res; + res = load_obj_dir(&dj, &dp->obj); + if (res != FR_OK) return res; /* Load the object status */ + st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize); /* Update the allocation status */ + st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize); + fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1; + res = store_xdir(&dj); /* Store the object status */ + if (res != FR_OK) return res; + } + + create_xdir(fs->dirbuf, fs->lfnbuf); /* Create on-memory directory block to be written later */ + return FR_OK; + } +#endif + /* On the FAT12/16/32 volume */ + mem_cpy(sn, dp->fn, 12); + if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ + dp->fn[NSFLAG] = NS_NOLFN; /* Find only SFN */ + for (n = 1; n < 100; n++) { + gen_numname(dp->fn, sn, fs->lfnbuf, n); /* Generate a numbered name */ + res = dir_find(dp); /* Check if the name collides with existing SFN */ + if (res != FR_OK) break; + } + if (n == 100) return FR_DENIED; /* Abort if too many collisions */ + if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ + dp->fn[NSFLAG] = sn[NSFLAG]; + } + + /* Create an SFN with/without LFNs. */ + nent = (sn[NSFLAG] & NS_LFN) ? (nlen + 12) / 13 + 1 : 1; /* Number of entries to allocate */ + res = dir_alloc(dp, nent); /* Allocate entries */ + if (res == FR_OK && --nent) { /* Set LFN entry if needed */ + res = dir_sdi(dp, dp->dptr - nent * SZDIRE); + if (res == FR_OK) { + sum = sum_sfn(dp->fn); /* Checksum value of the SFN tied to the LFN */ + do { /* Store LFN entries in bottom first */ + res = move_window(fs, dp->sect); + if (res != FR_OK) break; + put_lfn(fs->lfnbuf, dp->dir, (BYTE)nent, sum); + fs->wflag = 1; + res = dir_next(dp, 0); /* Next entry */ + } while (res == FR_OK && --nent); + } + } + +#else /* Non LFN configuration */ + res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ + +#endif + + /* Set SFN entry */ + if (res == FR_OK) { + res = move_window(fs, dp->sect); + if (res == FR_OK) { + mem_set(dp->dir, 0, SZDIRE); /* Clean the entry */ + mem_cpy(dp->dir + DIR_Name, dp->fn, 11); /* Put SFN */ +#if _USE_LFN != 0 + dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ +#endif + fs->wflag = 1; + } + } + + return res; +} + +#endif /* !_FS_READONLY */ + + + +#if !_FS_READONLY && _FS_MINIMIZE == 0 +/*-----------------------------------------------------------------------*/ +/* Remove an object from the directory */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */ + DIR* dp /* Directory object pointing the entry to be removed */ +) +{ + FRESULT res; + FATFS *fs = dp->obj.fs; +#if _USE_LFN != 0 /* LFN configuration */ + DWORD last = dp->dptr; + + res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs); /* Goto top of the entry block if LFN is exist */ + if (res == FR_OK) { + do { + res = move_window(fs, dp->sect); + if (res != FR_OK) break; + /* Mark an entry 'deleted' */ + if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + dp->dir[XDIR_Type] &= 0x7F; + } else { /* On the FAT12/16/32 volume */ + dp->dir[DIR_Name] = DDEM; + } + fs->wflag = 1; + if (dp->dptr >= last) break; /* If reached last entry then all entries of the object has been deleted. */ + res = dir_next(dp, 0); /* Next entry */ + } while (res == FR_OK); + if (res == FR_NO_FILE) res = FR_INT_ERR; + } +#else /* Non LFN configuration */ + + res = move_window(fs, dp->sect); + if (res == FR_OK) { + dp->dir[DIR_Name] = DDEM; + fs->wflag = 1; + } +#endif + + return res; +} + +#endif /* !_FS_READONLY && _FS_MINIMIZE == 0 */ + + + +#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 +/*-----------------------------------------------------------------------*/ +/* Get file information from directory entry */ +/*-----------------------------------------------------------------------*/ + +static +void get_fileinfo ( /* No return code */ + DIR* dp, /* Pointer to the directory object */ + FILINFO* fno /* Pointer to the file information to be filled */ +) +{ + UINT i, j; + TCHAR c; + DWORD tm; +#if _USE_LFN != 0 + WCHAR w, lfv; + FATFS *fs = dp->obj.fs; +#endif + + + fno->fname[0] = 0; /* Invaidate file info */ + if (!dp->sect) return; /* Exit if read pointer has reached end of directory */ + +#if _USE_LFN != 0 /* LFN configuration */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + get_xdir_info(fs->dirbuf, fno); + return; + } else +#endif + { /* On the FAT12/16/32 volume */ + if (dp->blk_ofs != 0xFFFFFFFF) { /* Get LFN if available */ + i = j = 0; + while ((w = fs->lfnbuf[j++]) != 0) { /* Get an LFN character */ +#if !_LFN_UNICODE + w = ff_convert(w, 0); /* Unicode -> OEM */ + if (w == 0) { i = 0; break; } /* No LFN if it could not be converted */ + if (_DF1S && w >= 0x100) { /* Put 1st byte if it is a DBC (always false at SBCS cfg) */ + fno->fname[i++] = (char)(w >> 8); + } +#endif + if (i >= _MAX_LFN) { i = 0; break; } /* No LFN if buffer overflow */ + fno->fname[i++] = (TCHAR)w; + } + fno->fname[i] = 0; /* Terminate the LFN */ + } + } + + i = j = 0; + lfv = fno->fname[i]; /* LFN is exist if non-zero */ + while (i < 11) { /* Copy name body and extension */ + c = (TCHAR)dp->dir[i++]; + if (c == ' ') continue; /* Skip padding spaces */ + if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ + if (i == 9) { /* Insert a . if extension is exist */ + if (!lfv) fno->fname[j] = '.'; + fno->altname[j++] = '.'; + } +#if _LFN_UNICODE + if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dp->dir[i])) { + c = c << 8 | dp->dir[i++]; + } + c = ff_convert(c, 1); /* OEM -> Unicode */ + if (!c) c = '?'; +#endif + fno->altname[j] = c; + if (!lfv) { + if (IsUpper(c) && (dp->dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) { + c += 0x20; /* To lower */ + } + fno->fname[j] = c; + } + j++; + } + if (!lfv) { + fno->fname[j] = 0; + if (!dp->dir[DIR_NTres]) j = 0; /* Altname is no longer needed if neither LFN nor case info is exist. */ + } + fno->altname[j] = 0; /* Terminate the SFN */ + +#else /* Non-LFN configuration */ + i = j = 0; + while (i < 11) { /* Copy name body and extension */ + c = (TCHAR)dp->dir[i++]; + if (c == ' ') continue; /* Skip padding spaces */ + if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ + if (i == 9) fno->fname[j++] = '.'; /* Insert a . if extension is exist */ + fno->fname[j++] = c; + } + fno->fname[j] = 0; +#endif + + fno->fattrib = dp->dir[DIR_Attr]; /* Attribute */ + fno->fsize = ld_dword(dp->dir + DIR_FileSize); /* Size */ + tm = ld_dword(dp->dir + DIR_ModTime); /* Timestamp */ + fno->ftime = (WORD)tm; fno->fdate = (WORD)(tm >> 16); +} + +#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ + + + +#if _USE_FIND && _FS_MINIMIZE <= 1 +/*-----------------------------------------------------------------------*/ +/* Pattern matching */ +/*-----------------------------------------------------------------------*/ + +static +WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ + const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ +) +{ +#if !_LFN_UNICODE + WCHAR chr; + + chr = (BYTE)*(*ptr)++; /* Get a byte */ + if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ +#ifdef _EXCVT + if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ +#else + if (IsDBCS1(chr) && IsDBCS2(**ptr)) { /* Get DBC 2nd byte if needed */ + chr = chr << 8 | (BYTE)*(*ptr)++; + } +#endif + return chr; +#else + return ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ +#endif +} + + +static +int pattern_matching ( /* 0:not matched, 1:matched */ + const TCHAR* pat, /* Matching pattern */ + const TCHAR* nam, /* String to be tested */ + int skip, /* Number of pre-skip chars (number of ?s) */ + int inf /* Infinite search (* specified) */ +) +{ + const TCHAR *pp, *np; + WCHAR pc, nc; + int nm, nx; + + + while (skip--) { /* Pre-skip name chars */ + if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ + } + if (!*pat && inf) return 1; /* (short circuit) */ + + do { + pp = pat; np = nam; /* Top of pattern and name to match */ + for (;;) { + if (*pp == '?' || *pp == '*') { /* Wildcard? */ + nm = nx = 0; + do { /* Analyze the wildcard chars */ + if (*pp++ == '?') nm++; else nx = 1; + } while (*pp == '?' || *pp == '*'); + if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ + nc = *np; break; /* Branch mismatched */ + } + pc = get_achar(&pp); /* Get a pattern char */ + nc = get_achar(&np); /* Get a name char */ + if (pc != nc) break; /* Branch mismatched? */ + if (pc == 0) return 1; /* Branch matched? (matched at end of both strings) */ + } + get_achar(&nam); /* nam++ */ + } while (inf && nc); /* Retry until end of name if infinite search is specified */ + + return 0; +} + +#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ + + + +/*-----------------------------------------------------------------------*/ +/* Pick a top segment and create the object name in directory form */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */ + DIR* dp, /* Pointer to the directory object */ + const TCHAR** path /* Pointer to pointer to the segment in the path string */ +) +{ +#if _USE_LFN != 0 /* LFN configuration */ + BYTE b, cf; + WCHAR w, *lfn; + UINT i, ni, si, di; + const TCHAR *p; + + /* Create LFN in Unicode */ + p = *path; lfn = dp->obj.fs->lfnbuf; si = di = 0; + for (;;) { + w = p[si++]; /* Get a character */ + if (w < ' ') break; /* Break if end of the path name */ + if (w == '/' || w == '\\') { /* Break if a separator is found */ + while (p[si] == '/' || p[si] == '\\') si++; /* Skip duplicated separator if exist */ + break; + } + if (di >= _MAX_LFN) return FR_INVALID_NAME; /* Reject too long name */ +#if !_LFN_UNICODE + w &= 0xFF; + if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ + b = (BYTE)p[si++]; /* Get 2nd byte */ + w = (w << 8) + b; /* Create a DBC */ + if (!IsDBCS2(b)) return FR_INVALID_NAME; /* Reject invalid sequence */ + } + w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ + if (!w) return FR_INVALID_NAME; /* Reject invalid code */ +#endif + if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) return FR_INVALID_NAME; /* Reject illegal characters for LFN */ + lfn[di++] = w; /* Store the Unicode character */ + } + *path = &p[si]; /* Return pointer to the next segment */ + cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of the path */ +#if _FS_RPATH != 0 + if ((di == 1 && lfn[di - 1] == '.') || + (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { /* Is this segment a dot name? */ + lfn[di] = 0; + for (i = 0; i < 11; i++) /* Create dot name for SFN entry */ + dp->fn[i] = (i < di) ? '.' : ' '; + dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ + return FR_OK; + } +#endif + while (di) { /* Snip off trailing spaces and dots if exist */ + w = lfn[di - 1]; + if (w != ' ' && w != '.') break; + di--; + } + lfn[di] = 0; /* LFN is created */ + if (di == 0) return FR_INVALID_NAME; /* Reject nul name */ + + /* Create SFN in directory form */ + mem_set(dp->fn, ' ', 11); + for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ + if (si) cf |= NS_LOSS | NS_LFN; + while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ + + i = b = 0; ni = 8; + for (;;) { + w = lfn[si++]; /* Get an LFN character */ + if (!w) break; /* Break on end of the LFN */ + if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ + cf |= NS_LOSS | NS_LFN; continue; + } + + if (i >= ni || si == di) { /* Extension or end of SFN */ + if (ni == 11) { /* Long extension */ + cf |= NS_LOSS | NS_LFN; break; + } + if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ + if (si > di) break; /* No extension */ + si = di; i = 8; ni = 11; /* Enter extension section */ + b <<= 2; continue; + } + + if (w >= 0x80) { /* Non ASCII character */ +#ifdef _EXCVT + w = ff_convert(w, 0); /* Unicode -> OEM code */ + if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ +#else + w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ +#endif + cf |= NS_LFN; /* Force create LFN entry */ + } + + if (_DF1S && w >= 0x100) { /* Is this DBC? (always false at SBCS cfg) */ + if (i >= ni - 1) { + cf |= NS_LOSS | NS_LFN; i = ni; continue; + } + dp->fn[i++] = (BYTE)(w >> 8); + } else { /* SBC */ + if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ + w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ + } else { + if (IsUpper(w)) { /* ASCII large capital */ + b |= 2; + } else { + if (IsLower(w)) { /* ASCII small capital */ + b |= 1; w -= 0x20; + } + } + } + } + dp->fn[i++] = (BYTE)w; + } + + if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with DDEM, replace it with RDDEM */ + + if (ni == 8) b <<= 2; + if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) cf |= NS_LFN; /* Create LFN entry when there are composite capitals */ + if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ + if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ + if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ + } + + dp->fn[NSFLAG] = cf; /* SFN is created */ + + return FR_OK; + + +#else /* _USE_LFN != 0 : Non-LFN configuration */ + BYTE c, d, *sfn; + UINT ni, si, i; + const char *p; + + /* Create file name in directory form */ + p = *path; sfn = dp->fn; + mem_set(sfn, ' ', 11); + si = i = 0; ni = 8; +#if _FS_RPATH != 0 + if (p[si] == '.') { /* Is this a dot entry? */ + for (;;) { + c = (BYTE)p[si++]; + if (c != '.' || si >= 3) break; + sfn[i++] = c; + } + if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; + *path = p + si; /* Return pointer to the next segment */ + sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of the path */ + return FR_OK; + } +#endif + for (;;) { + c = (BYTE)p[si++]; + if (c <= ' ') break; /* Break if end of the path name */ + if (c == '/' || c == '\\') { /* Break if a separator is found */ + while (p[si] == '/' || p[si] == '\\') si++; /* Skip duplicated separator if exist */ + break; + } + if (c == '.' || i >= ni) { /* End of body or over size? */ + if (ni == 11 || c != '.') return FR_INVALID_NAME; /* Over size or invalid dot */ + i = 8; ni = 11; /* Goto extension */ + continue; + } + if (c >= 0x80) { /* Extended character? */ +#ifdef _EXCVT + c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ +#else +#if !_DF1S + return FR_INVALID_NAME; /* Reject extended characters (ASCII only cfg) */ +#endif +#endif + } + if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false at SBCS cfg.) */ + d = (BYTE)p[si++]; /* Get 2nd byte */ + if (!IsDBCS2(d) || i >= ni - 1) return FR_INVALID_NAME; /* Reject invalid DBC */ + sfn[i++] = c; + sfn[i++] = d; + } else { /* SBC */ + if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) return FR_INVALID_NAME; /* Reject illegal chrs for SFN */ + if (IsLower(c)) c -= 0x20; /* To upper */ + sfn[i++] = c; + } + } + *path = p + si; /* Return pointer to the next segment */ + if (i == 0) return FR_INVALID_NAME; /* Reject nul string */ + + if (sfn[0] == DDEM) sfn[0] = RDDEM; /* If the first character collides with DDEM, replace it with RDDEM */ + sfn[NSFLAG] = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of the path */ + + return FR_OK; +#endif /* _USE_LFN != 0 */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Follow a file path */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ + DIR* dp, /* Directory object to return last directory and found object */ + const TCHAR* path /* Full-path string to find a file or directory */ +) +{ + FRESULT res; + BYTE ns; + _FDID *obj = &dp->obj; + FATFS *fs = obj->fs; + + +#if _FS_RPATH != 0 + if (*path != '/' && *path != '\\') { /* Without heading separator */ + obj->sclust = fs->cdir; /* Start from the current directory */ + } else +#endif + { /* With heading separator */ + while (*path == '/' || *path == '\\') path++; /* Strip heading separator */ + obj->sclust = 0; /* Start from the root directory */ + } +#if _FS_EXFAT && _FS_RPATH != 0 + if (fs->fs_type == FS_EXFAT && obj->sclust) { /* Retrieve the sub-directory status if needed */ + DIR dj; + + obj->c_scl = fs->cdc_scl; + obj->c_size = fs->cdc_size; + obj->c_ofs = fs->cdc_ofs; + res = load_obj_dir(&dj, obj); + if (res != FR_OK) return res; + obj->objsize = ld_dword(fs->dirbuf + XDIR_FileSize); + obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; + } +#endif + + if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ + dp->fn[NSFLAG] = NS_NONAME; + res = dir_sdi(dp, 0); + + } else { /* Follow path */ + for (;;) { + res = create_name(dp, &path); /* Get a segment name of the path */ + if (res != FR_OK) break; + res = dir_find(dp); /* Find an object with the segment name */ + ns = dp->fn[NSFLAG]; + if (res != FR_OK) { /* Failed to find the object */ + if (res == FR_NO_FILE) { /* Object is not found */ + if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, stay there */ + if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ + dp->fn[NSFLAG] = NS_NONAME; + res = FR_OK; + } else { /* Could not find the object */ + if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ + } + } + break; + } + if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ + /* Get into the sub-directory */ + if (!(obj->attr & AM_DIR)) { /* It is not a sub-directory and cannot follow */ + res = FR_NO_PATH; break; + } +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + obj->c_scl = obj->sclust; /* Save containing directory information for next dir */ + obj->c_size = ((DWORD)obj->objsize & 0xFFFFFF00) | obj->stat; + obj->c_ofs = dp->blk_ofs; + obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Open next directory */ + obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; + obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); + } else +#endif + { + obj->sclust = ld_clust(fs, fs->win + dp->dptr % SS(fs)); /* Open next directory */ + } + } + } + + return res; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Load a sector and check if it is an FAT boot sector */ +/*-----------------------------------------------------------------------*/ + +static +BYTE check_fs ( /* 0:FAT, 1:exFAT, 2:Valid BS but not FAT, 3:Not a BS, 4:Disk error */ + FATFS* fs, /* File system object */ + DWORD sect /* Sector# (lba) to check if it is an FAT-VBR or not */ +) +{ + fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ + if (move_window(fs, sect) != FR_OK) return 4; /* Load boot record */ + + if (ld_word(fs->win + BS_55AA) != 0xAA55) return 3; /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ + + if (fs->win[BS_JmpBoot] == 0xE9 || (fs->win[BS_JmpBoot] == 0xEB && fs->win[BS_JmpBoot + 2] == 0x90)) { + if ((ld_dword(fs->win + BS_FilSysType) & 0xFFFFFF) == 0x544146) return 0; /* Check "FAT" string */ + if (ld_dword(fs->win + BS_FilSysType32) == 0x33544146) return 0; /* Check "FAT3" string */ + } +#if _FS_EXFAT + if (!mem_cmp(fs->win + BS_JmpBoot, "\xEB\x76\x90" "EXFAT ", 11)) return 1; +#endif + return 2; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Find logical drive and check if the volume is mounted */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ + FATFS* fs, /* Pointer to the file system object */ + BYTE mode /* !=0: Check write protection for write access */ +) +{ + BYTE fmt, *pt; + DSTATUS stat; + DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; + WORD nrsv; + UINT i; + + + ENTER_FF(fs); /* Lock the volume */ + + mode &= (BYTE)~FA_READ; /* Desired access mode, write access or not */ + if (fs->fs_type) { /* If the volume has been mounted */ + disk_ioctl(fs->drv, IOCTL_STATUS, &stat); + if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ + if (!_FS_READONLY && mode && (stat & STA_PROTECT)) { /* Check write protection if needed */ + return FR_WRITE_PROTECTED; + } + return FR_OK; /* The file system object is valid */ + } + } + + /* The file system object is not valid. */ + /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ + + fs->fs_type = 0; /* Clear the file system object */ + disk_ioctl(fs->drv, IOCTL_INIT, &stat); /* Initialize the physical drive */ + if (stat & STA_NOINIT) { /* Check if the initialization succeeded */ + return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ + } + if (!_FS_READONLY && mode && (stat & STA_PROTECT)) { /* Check disk write protection if needed */ + return FR_WRITE_PROTECTED; + } +#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ + if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK) return FR_DISK_ERR; + if (SS(fs) > _MAX_SS || SS(fs) < _MIN_SS || (SS(fs) & (SS(fs) - 1))) return FR_DISK_ERR; +#endif + /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ + bsect = 0; + fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT-VBR as SFD */ + if (fmt == 2 || (fmt < 2 && LD2PT(fs) != 0)) { /* Not an FAT-VBR or forced partition number */ + for (i = 0; i < 4; i++) { /* Get partition offset */ + pt = fs->win + (MBR_Table + i * SZ_PTE); + br[i] = pt[PTE_System] ? ld_dword(pt + PTE_StLba) : 0; + } + i = LD2PT(fs); /* Partition number: 0:auto, 1-4:forced */ + if (i) i--; + do { /* Find an FAT volume */ + bsect = br[i]; + fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */ + } while (!LD2PT(fs) && fmt >= 2 && ++i < 4); + } + if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ + if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */ + + /* An FAT volume is found. Following code initializes the file system object */ + +#if _FS_EXFAT + if (fmt == 1) { + QWORD maxlba; + + for (i = BPB_ZeroedEx; i < BPB_ZeroedEx + 53 && fs->win[i] == 0; i++) ; /* Check zero filler */ + if (i < BPB_ZeroedEx + 53) return FR_NO_FILESYSTEM; + + if (ld_word(fs->win + BPB_FSVerEx) != 0x100) return FR_NO_FILESYSTEM; /* Check exFAT revision (Must be 1.0) */ + + if (1 << fs->win[BPB_BytsPerSecEx] != SS(fs)) /* (BPB_BytsPerSecEx must be equal to the physical sector size) */ + return FR_NO_FILESYSTEM; + + maxlba = ld_qword(fs->win + BPB_TotSecEx) + bsect; /* Last LBA + 1 of the volume */ + if (maxlba >= 0x100000000) return FR_NO_FILESYSTEM; /* (It cannot be handled in 32-bit LBA) */ + + fs->fsize = ld_dword(fs->win + BPB_FatSzEx); /* Number of sectors per FAT */ + + fs->n_fats = fs->win[BPB_NumFATsEx]; /* Number of FATs */ + if (fs->n_fats != 1) return FR_NO_FILESYSTEM; /* (Supports only 1 FAT) */ + + fs->csize = 1 << fs->win[BPB_SecPerClusEx]; /* Cluster size */ + if (fs->csize == 0) return FR_NO_FILESYSTEM; /* (Must be 1..32768) */ + + nclst = ld_dword(fs->win + BPB_NumClusEx); /* Number of clusters */ + if (nclst > MAX_EXFAT) return FR_NO_FILESYSTEM; /* (Too many clusters) */ + fs->n_fatent = nclst + 2; + + /* Boundaries and Limits */ + fs->volbase = bsect; + fs->database = bsect + ld_dword(fs->win + BPB_DataOfsEx); + fs->fatbase = bsect + ld_dword(fs->win + BPB_FatOfsEx); + if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */ + fs->dirbase = ld_dword(fs->win + BPB_RootClusEx); + + /* Check if bitmap location is in assumption (at the first cluster) */ + if (move_window(fs, clust2sect(fs, fs->dirbase)) != FR_OK) return FR_DISK_ERR; + for (i = 0; i < SS(fs); i += SZDIRE) { + if (fs->win[i] == 0x81 && ld_dword(fs->win + i + 20) == 2) break; /* 81 entry with cluster #2? */ + } + if (i == SS(fs)) return FR_NO_FILESYSTEM; +#if !_FS_READONLY + fs->last_clst = fs->free_clst = 0xFFFFFFFF; /* Initialize cluster allocation information */ +#endif + fmt = FS_EXFAT; /* FAT sub-type */ + } else +#endif /* _FS_EXFAT */ + { + if (ld_word(fs->win + BPB_BytsPerSec) != SS(fs)) return FR_NO_FILESYSTEM; /* (BPB_BytsPerSec must be equal to the physical sector size) */ + + fasize = ld_word(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ + if (fasize == 0) fasize = ld_dword(fs->win + BPB_FATSz32); + fs->fsize = fasize; + + fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FATs */ + if (fs->n_fats != 1 && fs->n_fats != 2) return FR_NO_FILESYSTEM; /* (Must be 1 or 2) */ + fasize *= fs->n_fats; /* Number of sectors for FAT area */ + + fs->csize = fs->win[BPB_SecPerClus]; /* Cluster size */ + if (fs->csize == 0 || (fs->csize & (fs->csize - 1))) return FR_NO_FILESYSTEM; /* (Must be power of 2) */ + + fs->n_rootdir = ld_word(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ + if (fs->n_rootdir % (SS(fs) / SZDIRE)) return FR_NO_FILESYSTEM; /* (Must be sector aligned) */ + + tsect = ld_word(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ + if (tsect == 0) tsect = ld_dword(fs->win + BPB_TotSec32); + + nrsv = ld_word(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ + if (nrsv == 0) return FR_NO_FILESYSTEM; /* (Must not be 0) */ + + /* Determine the FAT sub type */ + sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZDIRE); /* RSV + FAT + DIR */ + if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ + nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ + if (nclst == 0) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ + fmt = FS_FAT32; + if (nclst <= MAX_FAT16) fmt = FS_FAT16; + if (nclst <= MAX_FAT12) fmt = FS_FAT12; + + /* Boundaries and Limits */ + fs->n_fatent = nclst + 2; /* Number of FAT entries */ + fs->volbase = bsect; /* Volume start sector */ + fs->fatbase = bsect + nrsv; /* FAT start sector */ + fs->database = bsect + sysect; /* Data start sector */ + if (fmt == FS_FAT32) { + if (ld_word(fs->win + BPB_FSVer32) != 0) return FR_NO_FILESYSTEM; /* (Must be FAT32 revision 0.0) */ + if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ + fs->dirbase = ld_dword(fs->win + BPB_RootClus32); /* Root directory start cluster */ + szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ + } else { + if (fs->n_rootdir == 0) return FR_NO_FILESYSTEM;/* (BPB_RootEntCnt must not be 0) */ + fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ + szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ + fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); + } + if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) return FR_NO_FILESYSTEM; /* (BPB_FATSz must not be less than the size needed) */ + +#if !_FS_READONLY + /* Get FSINFO if available */ + fs->last_clst = fs->free_clst = 0xFFFFFFFF; /* Initialize cluster allocation information */ + fs->fsi_flag = 0x80; +#if (_FS_NOFSINFO & 3) != 3 + if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo32 == 1 */ + && ld_word(fs->win + BPB_FSInfo32) == 1 + && move_window(fs, bsect + 1) == FR_OK) + { + fs->fsi_flag = 0; + if (ld_word(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ + && ld_dword(fs->win + FSI_LeadSig) == 0x41615252 + && ld_dword(fs->win + FSI_StrucSig) == 0x61417272) + { +#if (_FS_NOFSINFO & 1) == 0 + fs->free_clst = ld_dword(fs->win + FSI_Free_Count); +#endif +#if (_FS_NOFSINFO & 2) == 0 + fs->last_clst = ld_dword(fs->win + FSI_Nxt_Free); +#endif + } + } +#endif /* (_FS_NOFSINFO & 3) != 3 */ +#endif /* !_FS_READONLY */ + } + + fs->fs_type = fmt; /* FAT sub-type */ + fs->id = ++Fsid; /* File system mount ID */ +#if _USE_LFN == 1 + fs->lfnbuf = LfnBuf; /* Static LFN working buffer */ +#if _FS_EXFAT + fs->dirbuf = DirBuf; /* Static directory block working buuffer */ +#endif +#endif +#if _FS_RPATH != 0 + fs->cdir = 0; /* Initialize current directory */ +#endif +#if _FS_LOCK != 0 /* Clear file lock semaphores */ + clear_lock(fs); +#endif + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Check if the file/directory object is valid or not */ +/*-----------------------------------------------------------------------*/ + +static +FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */ + _FDID* obj, /* Pointer to the _OBJ, the 1st member in the FIL/DIR object, to check validity */ + FATFS** fs /* Pointer to pointer to the owner file system object to return */ +) +{ + FRESULT res; + DSTATUS stat; + + + if (!obj || !obj->fs || !obj->fs->fs_type || obj->fs->id != obj->id || disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) != RES_OK || (stat & STA_NOINIT)) { + *fs = 0; /* The object is invalid */ + res = FR_INVALID_OBJECT; + } else { + *fs = obj->fs; /* Owner file sytem object */ + ENTER_FF(obj->fs); /* Lock file system */ + res = FR_OK; + } + return res; +} + + + + +/*--------------------------------------------------------------------------- + + Public Functions (FatFs API) + +----------------------------------------------------------------------------*/ + + + +/*-----------------------------------------------------------------------*/ +/* Mount/Unmount a Logical Drive */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_mount ( + FATFS* fs /* Pointer to the file system object to mount */ +) +{ + FRESULT res; + + fs->fs_type = 0; /* Clear new fs object */ +#if _FS_REENTRANT /* Create sync object for the new volume */ + if (!ff_cre_syncobj(fs, &fs->sobj)) return FR_INT_ERR; +#endif + + res = find_volume(fs, 0); /* Force mounted the volume */ + LEAVE_FF(fs, res); +} + + +FRESULT f_umount ( + FATFS* fs /* Pointer to the file system object to unmount */ +) +{ +#if _FS_LOCK + clear_lock(fs); +#endif +#if _FS_REENTRANT /* Discard sync object of the current volume */ + if (!ff_del_syncobj(fs->sobj)) return FR_INT_ERR; +#endif + fs->fs_type = 0; /* Clear old fs object */ + + return FR_OK; +} + + +/*-----------------------------------------------------------------------*/ +/* Open or Create a File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_open ( + FATFS *fs, + FIL* fp, /* Pointer to the blank file object */ + const TCHAR* path, /* Pointer to the file name */ + BYTE mode /* Access mode and file open mode flags */ +) +{ + FRESULT res; + DIR dj; +#if !_FS_READONLY + DWORD dw, cl, bcs, clst, sc; + FSIZE_t ofs; +#endif + DEF_NAMBUF + + + if (!fp) return FR_INVALID_OBJECT; + + /* Get logical drive */ + mode &= _FS_READONLY ? FA_READ : FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_CREATE_NEW | FA_OPEN_ALWAYS | FA_OPEN_APPEND | FA_SEEKEND; + res = find_volume(fs, mode); + if (res == FR_OK) { + dj.obj.fs = fs; + INIT_NAMBUF(fs); + res = follow_path(&dj, path); /* Follow the file path */ +#if !_FS_READONLY /* R/W configuration */ + if (res == FR_OK) { + if (dj.fn[NSFLAG] & NS_NONAME) { /* Origin directory itself? */ + res = FR_INVALID_NAME; + } +#if _FS_LOCK != 0 + else { + res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); + } +#endif + } + /* Create or Open a file */ + if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { + if (res != FR_OK) { /* No file, create new */ + if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ +#if _FS_LOCK != 0 + res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; +#else + res = dir_register(&dj); +#endif + mode |= FA_CREATE_ALWAYS; /* File is created */ + } + else { /* Any object is already existing */ + if (dj.obj.attr & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ + res = FR_DENIED; + } else { + if (mode & FA_CREATE_NEW) res = FR_EXIST; /* Cannot create as new file */ + } + } + if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ + dw = GET_FATTIME(); +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + /* Get current allocation info */ + fp->obj.fs = fs; + fp->obj.sclust = ld_dword(fs->dirbuf + XDIR_FstClus); + fp->obj.objsize = ld_qword(fs->dirbuf + XDIR_FileSize); + fp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2; + /* Initialize directory entry block */ + st_dword(fs->dirbuf + XDIR_CrtTime, dw); /* Set created time */ + fs->dirbuf[XDIR_CrtTime10] = 0; + st_dword(fs->dirbuf + XDIR_ModTime, dw); /* Set modified time */ + fs->dirbuf[XDIR_ModTime10] = 0; + fs->dirbuf[XDIR_Attr] = AM_ARC; /* Reset attribute */ + st_dword(fs->dirbuf + XDIR_FstClus, 0); /* Reset file allocation info */ + st_qword(fs->dirbuf + XDIR_FileSize, 0); + st_qword(fs->dirbuf + XDIR_ValidFileSize, 0); + fs->dirbuf[XDIR_GenFlags] = 1; + res = store_xdir(&dj); + if (res == FR_OK && fp->obj.sclust) { /* Remove the cluster chain if exist */ + res = remove_chain(&fp->obj, fp->obj.sclust, 0); + fs->last_clst = fp->obj.sclust - 1; /* Reuse the cluster hole */ + } + } else +#endif + { + /* Clean directory info */ + st_dword(dj.dir + DIR_CrtTime, dw); /* Set created time */ + st_dword(dj.dir + DIR_ModTime, dw); /* Set modified time */ + dj.dir[DIR_Attr] = AM_ARC; /* Reset attribute */ + cl = ld_clust(fs, dj.dir); /* Get cluster chain */ + st_clust(fs, dj.dir, 0); /* Reset file allocation info */ + st_dword(dj.dir + DIR_FileSize, 0); + fs->wflag = 1; + + if (cl) { /* Remove the cluster chain if exist */ + dw = fs->winsect; + res = remove_chain(&dj.obj, cl, 0); + if (res == FR_OK) { + res = move_window(fs, dw); + fs->last_clst = cl - 1; /* Reuse the cluster hole */ + } + } + } + } + } + else { /* Open an existing file */ + if (res == FR_OK) { /* Following succeeded */ + if (dj.obj.attr & AM_DIR) { /* It is a directory */ + res = FR_NO_FILE; + } else { + if ((mode & FA_WRITE) && (dj.obj.attr & AM_RDO)) { /* R/O violation */ + res = FR_DENIED; + } + } + } + } + if (res == FR_OK) { + if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ + mode |= FA_MODIFIED; + fp->dir_sect = fs->winsect; /* Pointer to the directory entry */ + fp->dir_ptr = dj.dir; +#if _FS_LOCK != 0 + fp->obj.lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); + if (!fp->obj.lockid) res = FR_INT_ERR; +#endif + } +#else /* R/O configuration */ + if (res == FR_OK) { + if (dj.fn[NSFLAG] & NS_NONAME) { /* Origin directory itself? */ + res = FR_INVALID_NAME; + } else { + if (dj.obj.attr & AM_DIR) { /* It is a directory */ + res = FR_NO_FILE; + } + } + } +#endif + + if (res == FR_OK) { +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + fp->obj.sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Get allocation info */ + fp->obj.objsize = ld_qword(fs->dirbuf + XDIR_FileSize); + fp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2; + fp->obj.c_scl = dj.obj.sclust; + fp->obj.c_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat; + fp->obj.c_ofs = dj.blk_ofs; + } else +#endif + { + fp->obj.sclust = ld_clust(fs, dj.dir); /* Get allocation info */ + fp->obj.objsize = ld_dword(dj.dir + DIR_FileSize); + } +#if _USE_FASTSEEK + fp->cltbl = 0; /* Disable fast seek mode */ +#endif + fp->obj.fs = fs; /* Validate the file object */ + fp->obj.id = fs->id; + fp->flag = mode; /* Set file access mode */ + fp->err = 0; /* Clear error flag */ + fp->sect = 0; /* Invalidate current data sector */ + fp->fptr = 0; /* Set file pointer top of the file */ +#if !_FS_READONLY +#if !_FS_TINY + mem_set(fp->buf, 0, _MAX_SS); /* Clear sector buffer */ +#endif + if ((mode & FA_SEEKEND) && fp->obj.objsize > 0) { /* Seek to end of file if FA_OPEN_APPEND is specified */ + fp->fptr = fp->obj.objsize; /* Offset to seek */ + bcs = (DWORD)fs->csize * SS(fs); /* Cluster size in byte */ + clst = fp->obj.sclust; /* Follow the cluster chain */ + for (ofs = fp->obj.objsize; res == FR_OK && ofs > bcs; ofs -= bcs) { + clst = get_fat(&fp->obj, clst); + if (clst <= 1) res = FR_INT_ERR; + if (clst == 0xFFFFFFFF) res = FR_DISK_ERR; + } + fp->clust = clst; + if (res == FR_OK && ofs % SS(fs)) { /* Fill sector buffer if not on the sector boundary */ + if ((sc = clust2sect(fs, clst)) == 0) { + res = FR_INT_ERR; + } else { + fp->sect = sc + (DWORD)(ofs / SS(fs)); +#if !_FS_TINY + if (disk_read(fs->drv, fp->buf, fp->sect, 1) != RES_OK) res = FR_DISK_ERR; +#endif + } + } + } +#endif + } + + FREE_NAMBUF(); + } + + if (res != FR_OK) fp->obj.fs = 0; /* Invalidate file object on error */ + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Read File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_read ( + FIL* fp, /* Pointer to the file object */ + void* buff, /* Pointer to data buffer */ + UINT btr, /* Number of bytes to read */ + UINT* br /* Pointer to number of bytes read */ +) +{ + FRESULT res; + FATFS *fs; + DWORD clst, sect; + FSIZE_t remain; + UINT rcnt, cc, csect; + BYTE *rbuff = (BYTE*)buff; + + + *br = 0; /* Clear read byte counter */ + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */ + if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ + remain = fp->obj.objsize - fp->fptr; + if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ + + for ( ; btr; /* Repeat until all data read */ + rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { + if (fp->fptr % SS(fs) == 0) { /* On the sector boundary? */ + csect = (UINT)(fp->fptr / SS(fs) & (fs->csize - 1)); /* Sector offset in the cluster */ + if (csect == 0) { /* On the cluster boundary? */ + if (fp->fptr == 0) { /* On the top of the file? */ + clst = fp->obj.sclust; /* Follow cluster chain from the origin */ + } else { /* Middle or end of the file */ +#if _USE_FASTSEEK + if (fp->cltbl) { + clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ + } else +#endif + { + clst = get_fat(&fp->obj, fp->clust); /* Follow cluster chain on the FAT */ + } + } + if (clst < 2) ABORT(fs, FR_INT_ERR); + if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); + fp->clust = clst; /* Update current cluster */ + } + sect = clust2sect(fs, fp->clust); /* Get current sector */ + if (!sect) ABORT(fs, FR_INT_ERR); + sect += csect; + cc = btr / SS(fs); /* When remaining bytes >= sector size, */ + if (cc) { /* Read maximum contiguous sectors directly */ + if (csect + cc > fs->csize) { /* Clip at cluster boundary */ + cc = fs->csize - csect; + } + if (disk_read(fs->drv, rbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR); +#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ +#if _FS_TINY + if (fs->wflag && fs->winsect - sect < cc) { + mem_cpy(rbuff + ((fs->winsect - sect) * SS(fs)), fs->win, SS(fs)); + } +#else + if ((fp->flag & FA_DIRTY) && fp->sect - sect < cc) { + mem_cpy(rbuff + ((fp->sect - sect) * SS(fs)), fp->buf, SS(fs)); + } +#endif +#endif + rcnt = SS(fs) * cc; /* Number of bytes transferred */ + continue; + } +#if !_FS_TINY + if (fp->sect != sect) { /* Load data sector if not in cache */ +#if !_FS_READONLY + if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif + if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */ + } +#endif + fp->sect = sect; + } + rcnt = SS(fs) - (UINT)fp->fptr % SS(fs); /* Number of bytes left in the sector */ + if (rcnt > btr) rcnt = btr; /* Clip it by btr if needed */ +#if _FS_TINY + if (move_window(fs, fp->sect) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Move sector window */ + mem_cpy(rbuff, fs->win + fp->fptr % SS(fs), rcnt); /* Extract partial sector */ +#else + mem_cpy(rbuff, fp->buf + fp->fptr % SS(fs), rcnt); /* Extract partial sector */ +#endif + } + + LEAVE_FF(fs, FR_OK); +} + + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Write File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_write ( + FIL* fp, /* Pointer to the file object */ + const void* buff, /* Pointer to the data to be written */ + UINT btw, /* Number of bytes to write */ + UINT* bw /* Pointer to number of bytes written */ +) +{ + FRESULT res; + FATFS *fs; + DWORD clst, sect; + UINT wcnt, cc, csect; + const BYTE *wbuff = (const BYTE*)buff; + + + *bw = 0; /* Clear write byte counter */ + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */ + if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ + + /* Check fptr wrap-around (file size cannot reach 4GiB on FATxx) */ + if ((!_FS_EXFAT || fs->fs_type != FS_EXFAT) && (DWORD)(fp->fptr + btw) < (DWORD)fp->fptr) { + btw = (UINT)(0xFFFFFFFF - (DWORD)fp->fptr); + } + + for ( ; btw; /* Repeat until all data written */ + wbuff += wcnt, fp->fptr += wcnt, fp->obj.objsize = (fp->fptr > fp->obj.objsize) ? fp->fptr : fp->obj.objsize, *bw += wcnt, btw -= wcnt) { + if (fp->fptr % SS(fs) == 0) { /* On the sector boundary? */ + csect = (UINT)(fp->fptr / SS(fs)) & (fs->csize - 1); /* Sector offset in the cluster */ + if (csect == 0) { /* On the cluster boundary? */ + if (fp->fptr == 0) { /* On the top of the file? */ + clst = fp->obj.sclust; /* Follow from the origin */ + if (clst == 0) { /* If no cluster is allocated, */ + clst = create_chain(&fp->obj, 0); /* create a new cluster chain */ + } + } else { /* On the middle or end of the file */ +#if _USE_FASTSEEK + if (fp->cltbl) { + clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ + } else +#endif + { + clst = create_chain(&fp->obj, fp->clust); /* Follow or stretch cluster chain on the FAT */ + } + } + if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ + if (clst == 1) ABORT(fs, FR_INT_ERR); + if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); + fp->clust = clst; /* Update current cluster */ + if (fp->obj.sclust == 0) fp->obj.sclust = clst; /* Set start cluster if the first write */ + } +#if _FS_TINY + if (fs->winsect == fp->sect && sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Write-back sector cache */ +#else + if (fp->flag & FA_DIRTY) { /* Write-back sector cache */ + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif + sect = clust2sect(fs, fp->clust); /* Get current sector */ + if (!sect) ABORT(fs, FR_INT_ERR); + sect += csect; + cc = btw / SS(fs); /* When remaining bytes >= sector size, */ + if (cc) { /* Write maximum contiguous sectors directly */ + if (csect + cc > fs->csize) { /* Clip at cluster boundary */ + cc = fs->csize - csect; + } + if (disk_write(fs->drv, wbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR); +#if _FS_MINIMIZE <= 2 +#if _FS_TINY + if (fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ + mem_cpy(fs->win, wbuff + ((fs->winsect - sect) * SS(fs)), SS(fs)); + fs->wflag = 0; + } +#else + if (fp->sect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ + mem_cpy(fp->buf, wbuff + ((fp->sect - sect) * SS(fs)), SS(fs)); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif +#endif + wcnt = SS(fs) * cc; /* Number of bytes transferred */ + continue; + } +#if _FS_TINY + if (fp->fptr >= fp->obj.objsize) { /* Avoid silly cache filling on the growing edge */ + if (sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR); + fs->winsect = sect; + } +#else + if (fp->sect != sect && /* Fill sector cache with file data */ + fp->fptr < fp->obj.objsize && + disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) { + ABORT(fs, FR_DISK_ERR); + } +#endif + fp->sect = sect; + } + wcnt = SS(fs) - (UINT)fp->fptr % SS(fs); /* Number of bytes left in the sector */ + if (wcnt > btw) wcnt = btw; /* Clip it by btw if needed */ +#if _FS_TINY + if (move_window(fs, fp->sect) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Move sector window */ + mem_cpy(fs->win + fp->fptr % SS(fs), wbuff, wcnt); /* Fit data to the sector */ + fs->wflag = 1; +#else + mem_cpy(fp->buf + fp->fptr % SS(fs), wbuff, wcnt); /* Fit data to the sector */ + fp->flag |= FA_DIRTY; +#endif + } + + fp->flag |= FA_MODIFIED; /* Set file change flag */ + + LEAVE_FF(fs, FR_OK); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Synchronize the File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_sync ( + FIL* fp /* Pointer to the file object */ +) +{ + FRESULT res; + FATFS *fs; + DWORD tm; + BYTE *dir; +#if _FS_EXFAT + DEF_NAMBUF +#endif + + + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res == FR_OK) { + if (fp->flag & FA_MODIFIED) { /* Is there any change to the file? */ +#if !_FS_TINY + if (fp->flag & FA_DIRTY) { /* Write-back cached data if needed */ + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) LEAVE_FF(fs, FR_DISK_ERR); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif + /* Update the directory entry */ + tm = GET_FATTIME(); /* Modified time */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + res = fill_fat_chain(&fp->obj); /* Create FAT chain if needed */ + if (res == FR_OK) { + DIR dj; + + INIT_NAMBUF(fs); + res = load_obj_dir(&dj, &fp->obj); /* Load directory entry block */ + if (res == FR_OK) { + fs->dirbuf[XDIR_Attr] |= AM_ARC; /* Set archive bit */ + fs->dirbuf[XDIR_GenFlags] = fp->obj.stat | 1; /* Update file allocation info */ + st_dword(fs->dirbuf + XDIR_FstClus, fp->obj.sclust); + st_qword(fs->dirbuf + XDIR_FileSize, fp->obj.objsize); + st_qword(fs->dirbuf + XDIR_ValidFileSize, fp->obj.objsize); + st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Update modified time */ + fs->dirbuf[XDIR_ModTime10] = 0; + st_dword(fs->dirbuf + XDIR_AccTime, 0); + res = store_xdir(&dj); /* Restore it to the directory */ + if (res == FR_OK) { + res = sync_fs(fs); + fp->flag &= (BYTE)~FA_MODIFIED; + } + } + FREE_NAMBUF(); + } + } else +#endif + { + res = move_window(fs, fp->dir_sect); + if (res == FR_OK) { + dir = fp->dir_ptr; + dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ + st_clust(fp->obj.fs, dir, fp->obj.sclust); /* Update file allocation info */ + st_dword(dir + DIR_FileSize, (DWORD)fp->obj.objsize); /* Update file size */ + st_dword(dir + DIR_ModTime, tm); /* Update modified time */ + st_word(dir + DIR_LstAccDate, 0); + fs->wflag = 1; + res = sync_fs(fs); /* Restore it to the directory */ + fp->flag &= (BYTE)~FA_MODIFIED; + } + } + } + } + + LEAVE_FF(fs, res); +} + +#endif /* !_FS_READONLY */ + + + + +/*-----------------------------------------------------------------------*/ +/* Close File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_close ( + FIL* fp /* Pointer to the file object to be closed */ +) +{ + FRESULT res; + FATFS *fs; + +#if !_FS_READONLY + res = f_sync(fp); /* Flush cached data */ + if (res == FR_OK) +#endif + { + res = validate(&fp->obj, &fs); /* Lock volume */ + if (res == FR_OK) { +#if _FS_LOCK != 0 + res = dec_lock(fp->obj.lockid); /* Decrement file open counter */ + if (res == FR_OK) +#endif + { + fp->obj.fs = 0; /* Invalidate file object */ + } +#if _FS_REENTRANT + unlock_fs(fs, FR_OK); /* Unlock volume */ +#endif + } + } + return res; +} + + + + +#if _FS_RPATH >= 1 +/*-----------------------------------------------------------------------*/ +/* Change Current Directory or Current Drive, Get Current Directory */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_chdir ( + FATFS *fs, + const TCHAR* path /* Pointer to the directory path */ +) +{ + FRESULT res; + DIR dj; + DEF_NAMBUF + + /* Get logical drive */ + res = find_volume(fs, 0); + if (res == FR_OK) { + dj.obj.fs = fs; + INIT_NAMBUF(fs); + res = follow_path(&dj, path); /* Follow the path */ + if (res == FR_OK) { /* Follow completed */ + if (dj.fn[NSFLAG] & NS_NONAME) { + fs->cdir = dj.obj.sclust; /* It is the start directory itself */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + fs->cdc_scl = dj.obj.c_scl; + fs->cdc_size = dj.obj.c_size; + fs->cdc_ofs = dj.obj.c_ofs; + } +#endif + } else { + if (dj.obj.attr & AM_DIR) { /* It is a sub-directory */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + fs->cdir = ld_dword(fs->dirbuf + XDIR_FstClus); /* Sub-directory cluster */ + fs->cdc_scl = dj.obj.sclust; /* Save containing directory information */ + fs->cdc_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat; + fs->cdc_ofs = dj.blk_ofs; + } else +#endif + { + fs->cdir = ld_clust(fs, dj.dir); /* Sub-directory cluster */ + } + } else { + res = FR_NO_PATH; /* Reached but a file */ + } + } + } + FREE_NAMBUF(); + if (res == FR_NO_FILE) res = FR_NO_PATH; + } + + LEAVE_FF(fs, res); +} + + +#if _FS_RPATH >= 2 +FRESULT f_getcwd ( + FATFS *fs, + TCHAR* buff, /* Pointer to the directory path */ + UINT len /* Size of path */ +) +{ + FRESULT res; + DIR dj; + UINT i, n; + DWORD ccl; + TCHAR *tp; + FILINFO fno; + DEF_NAMBUF + + + *buff = 0; + /* Get logical drive */ + res = find_volume(fs, 0); /* Get current volume */ + if (res == FR_OK) { + dj.obj.fs = fs; + INIT_NAMBUF(fs); + i = len; /* Bottom of buffer (directory stack base) */ + if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { /* (Cannot do getcwd on exFAT and returns root path) */ + dj.obj.sclust = fs->cdir; /* Start to follow upper directory from current directory */ + while ((ccl = dj.obj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ + res = dir_sdi(&dj, 1 * SZDIRE); /* Get parent directory */ + if (res != FR_OK) break; + res = move_window(fs, dj.sect); + if (res != FR_OK) break; + dj.obj.sclust = ld_clust(fs, dj.dir); /* Goto parent directory */ + res = dir_sdi(&dj, 0); + if (res != FR_OK) break; + do { /* Find the entry links to the child directory */ + res = dir_read(&dj, 0); + if (res != FR_OK) break; + if (ccl == ld_clust(fs, dj.dir)) break; /* Found the entry */ + res = dir_next(&dj, 0); + } while (res == FR_OK); + if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ + if (res != FR_OK) break; + get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ + for (n = 0; fno.fname[n]; n++) ; + if (i < n + 3) { + res = FR_NOT_ENOUGH_CORE; break; + } + while (n) buff[--i] = fno.fname[--n]; + buff[--i] = '/'; + } + } + tp = buff; + if (res == FR_OK) { + if (i == len) { /* Root-directory */ + *tp++ = '/'; + } else { /* Sub-directroy */ + do /* Add stacked path str */ + *tp++ = buff[i++]; + while (i < len); + } + } + *tp = 0; + FREE_NAMBUF(); + } + + LEAVE_FF(fs, res); +} + +#endif /* _FS_RPATH >= 2 */ +#endif /* _FS_RPATH >= 1 */ + + + +#if _FS_MINIMIZE <= 2 +/*-----------------------------------------------------------------------*/ +/* Seek File R/W Pointer */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_lseek ( + FIL* fp, /* Pointer to the file object */ + FSIZE_t ofs /* File pointer from top of file */ +) +{ + FRESULT res; + FATFS *fs; + DWORD clst, bcs, nsect; + FSIZE_t ifptr; +#if _USE_FASTSEEK + DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; +#endif + + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */ +#if _USE_FASTSEEK + if (fp->cltbl) { /* Fast seek */ + if (ofs == CREATE_LINKMAP) { /* Create CLMT */ + tbl = fp->cltbl; + tlen = *tbl++; ulen = 2; /* Given table size and required table size */ + cl = fp->obj.sclust; /* Origin of the chain */ + if (cl) { + do { + /* Get a fragment */ + tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ + do { + pcl = cl; ncl++; + cl = get_fat(&fp->obj, cl); + if (cl <= 1) ABORT(fs, FR_INT_ERR); + if (cl == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); + } while (cl == pcl + 1); + if (ulen <= tlen) { /* Store the length and top of the fragment */ + *tbl++ = ncl; *tbl++ = tcl; + } + } while (cl < fs->n_fatent); /* Repeat until end of chain */ + } + *fp->cltbl = ulen; /* Number of items used */ + if (ulen <= tlen) { + *tbl = 0; /* Terminate table */ + } else { + res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ + } + } else { /* Fast seek */ + if (ofs > fp->obj.objsize) ofs = fp->obj.objsize; /* Clip offset at the file size */ + fp->fptr = ofs; /* Set file pointer */ + if (ofs) { + fp->clust = clmt_clust(fp, ofs - 1); + dsc = clust2sect(fs, fp->clust); + if (!dsc) ABORT(fs, FR_INT_ERR); + dsc += (DWORD)((ofs - 1) / SS(fs)) & (fs->csize - 1); + if (fp->fptr % SS(fs) && dsc != fp->sect) { /* Refill sector cache if needed */ +#if !_FS_TINY +#if !_FS_READONLY + if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif + if (disk_read(fs->drv, fp->buf, dsc, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Load current sector */ +#endif + fp->sect = dsc; + } + } + } + } else +#endif + + /* Normal Seek */ + { +#if _FS_EXFAT + if (fs->fs_type != FS_EXFAT && ofs >= 0x100000000) ofs = 0xFFFFFFFF; /* Clip at 4GiB-1 if at FATxx */ +#endif + if (ofs > fp->obj.objsize && (_FS_READONLY || !(fp->flag & FA_WRITE))) { /* In read-only mode, clip offset with the file size */ + ofs = fp->obj.objsize; + } + ifptr = fp->fptr; + fp->fptr = nsect = 0; + if (ofs) { + bcs = (DWORD)fs->csize * SS(fs); /* Cluster size (byte) */ + if (ifptr > 0 && + (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ + fp->fptr = (ifptr - 1) & ~(FSIZE_t)(bcs - 1); /* start from the current cluster */ + ofs -= fp->fptr; + clst = fp->clust; + } else { /* When seek to back cluster, */ + clst = fp->obj.sclust; /* start from the first cluster */ +#if !_FS_READONLY + if (clst == 0) { /* If no cluster chain, create a new chain */ + clst = create_chain(&fp->obj, 0); + if (clst == 1) ABORT(fs, FR_INT_ERR); + if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); + fp->obj.sclust = clst; + } +#endif + fp->clust = clst; + } + if (clst != 0) { + while (ofs > bcs) { /* Cluster following loop */ + ofs -= bcs; fp->fptr += bcs; +#if !_FS_READONLY + if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ + if (_FS_EXFAT && fp->fptr > fp->obj.objsize) { /* No FAT chain object needs correct objsize to generate FAT value */ + fp->obj.objsize = fp->fptr; + fp->flag |= FA_MODIFIED; + } + clst = create_chain(&fp->obj, clst); /* Follow chain with forceed stretch */ + if (clst == 0) { /* Clip file size in case of disk full */ + ofs = 0; break; + } + } else +#endif + { + clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */ + } + if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); + if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR); + fp->clust = clst; + } + fp->fptr += ofs; + if (ofs % SS(fs)) { + nsect = clust2sect(fs, clst); /* Current sector */ + if (!nsect) ABORT(fs, FR_INT_ERR); + nsect += (DWORD)(ofs / SS(fs)); + } + } + } + if (!_FS_READONLY && fp->fptr > fp->obj.objsize) { /* Set file change flag if the file size is extended */ + fp->obj.objsize = fp->fptr; + fp->flag |= FA_MODIFIED; + } + if (fp->fptr % SS(fs) && nsect != fp->sect) { /* Fill sector cache if needed */ +#if !_FS_TINY +#if !_FS_READONLY + if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif + if (disk_read(fs->drv, fp->buf, nsect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */ +#endif + fp->sect = nsect; + } + } + + LEAVE_FF(fs, res); +} + + + +#if _FS_MINIMIZE <= 1 +/*-----------------------------------------------------------------------*/ +/* Create a Directory Object */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_opendir ( + FATFS *fs, + DIR* dp, /* Pointer to directory object to create */ + const TCHAR* path /* Pointer to the directory path */ +) +{ + FRESULT res; + _FDID *obj; + DEF_NAMBUF + + + if (!dp) return FR_INVALID_OBJECT; + + /* Get logical drive */ + obj = &dp->obj; + res = find_volume(fs, 0); + if (res == FR_OK) { + obj->fs = fs; + INIT_NAMBUF(fs); + res = follow_path(dp, path); /* Follow the path to the directory */ + if (res == FR_OK) { /* Follow completed */ + if (!(dp->fn[NSFLAG] & NS_NONAME)) { /* It is not the origin directory itself */ + if (obj->attr & AM_DIR) { /* This object is a sub-directory */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + obj->c_scl = obj->sclust; /* Save containing directory inforamation */ + obj->c_size = ((DWORD)obj->objsize & 0xFFFFFF00) | obj->stat; + obj->c_ofs = dp->blk_ofs; + obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Get object location and status */ + obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); + obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; + } else +#endif + { + obj->sclust = ld_clust(fs, dp->dir); /* Get object location */ + } + } else { /* This object is a file */ + res = FR_NO_PATH; + } + } + if (res == FR_OK) { + obj->id = fs->id; + res = dir_sdi(dp, 0); /* Rewind directory */ +#if _FS_LOCK != 0 + if (res == FR_OK) { + if (obj->sclust) { + obj->lockid = inc_lock(dp, 0); /* Lock the sub directory */ + if (!obj->lockid) res = FR_TOO_MANY_OPEN_FILES; + } else { + obj->lockid = 0; /* Root directory need not to be locked */ + } + } +#endif + } + } + FREE_NAMBUF(); + if (res == FR_NO_FILE) res = FR_NO_PATH; + } + if (res != FR_OK) obj->fs = 0; /* Invalidate the directory object if function faild */ + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Close Directory */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_closedir ( + DIR *dp /* Pointer to the directory object to be closed */ +) +{ + FRESULT res; + FATFS *fs; + + + res = validate(&dp->obj, &fs); /* Check validity of the file object */ + if (res == FR_OK) { +#if _FS_LOCK != 0 + if (dp->obj.lockid) { /* Decrement sub-directory open counter */ + res = dec_lock(dp->obj.lockid); + } + if (res == FR_OK) +#endif + { + dp->obj.fs = 0; /* Invalidate directory object */ + } +#if _FS_REENTRANT + unlock_fs(fs, FR_OK); /* Unlock volume */ +#endif + } + return res; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Read Directory Entries in Sequence */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_readdir ( + DIR* dp, /* Pointer to the open directory object */ + FILINFO* fno /* Pointer to file information to return */ +) +{ + FRESULT res; + FATFS *fs; + DEF_NAMBUF + + + res = validate(&dp->obj, &fs); /* Check validity of the directory object */ + if (res == FR_OK) { + if (!fno) { + res = dir_sdi(dp, 0); /* Rewind the directory object */ + } else { + INIT_NAMBUF(fs); + res = dir_read(dp, 0); /* Read an item */ + if (res == FR_NO_FILE) res = FR_OK; /* Ignore end of directory */ + if (res == FR_OK) { /* A valid entry is found */ + get_fileinfo(dp, fno); /* Get the object information */ + res = dir_next(dp, 0); /* Increment index for next */ + if (res == FR_NO_FILE) res = FR_OK; /* Ignore end of directory now */ + } + FREE_NAMBUF(); + } + } + LEAVE_FF(fs, res); +} + + + +#if _USE_FIND +/*-----------------------------------------------------------------------*/ +/* Find Next File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_findnext ( + DIR* dp, /* Pointer to the open directory object */ + FILINFO* fno /* Pointer to the file information structure */ +) +{ + FRESULT res; + + + for (;;) { + res = f_readdir(dp, fno); /* Get a directory item */ + if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ + if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for the file name */ +#if _USE_LFN != 0 && _USE_FIND == 2 + if (pattern_matching(dp->pat, fno->altname, 0, 0)) break; /* Test for alternative name if exist */ +#endif + } + return res; +} + + + +/*-----------------------------------------------------------------------*/ +/* Find First File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_findfirst ( + DIR* dp, /* Pointer to the blank directory object */ + FILINFO* fno, /* Pointer to the file information structure */ + const TCHAR* path, /* Pointer to the directory to open */ + const TCHAR* pattern /* Pointer to the matching pattern */ +) +{ + FRESULT res; + + + dp->pat = pattern; /* Save pointer to pattern string */ + res = f_opendir(dp, path); /* Open the target directory */ + if (res == FR_OK) { + res = f_findnext(dp, fno); /* Find the first item */ + } + return res; +} + +#endif /* _USE_FIND */ + + + +#if _FS_MINIMIZE == 0 +/*-----------------------------------------------------------------------*/ +/* Get File Status */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_stat ( + FATFS *fs, + const TCHAR* path, /* Pointer to the file path */ + FILINFO* fno /* Pointer to file information to return */ +) +{ + FRESULT res; + DIR dj; + DEF_NAMBUF + + + /* Get logical drive */ + res = find_volume(fs, 0); + dj.obj.fs = fs; + if (res == FR_OK) { + INIT_NAMBUF(dj.obj.fs); + res = follow_path(&dj, path); /* Follow the file path */ + if (res == FR_OK) { /* Follow completed */ + if (dj.fn[NSFLAG] & NS_NONAME) { /* It is origin directory */ + res = FR_INVALID_NAME; + } else { /* Found an object */ + if (fno) get_fileinfo(&dj, fno); + } + } + FREE_NAMBUF(); + } + + LEAVE_FF(dj.obj.fs, res); +} + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Get Number of Free Clusters */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_getfree ( + FATFS *fs, + DWORD* nclst /* Pointer to a variable to return number of free clusters */ +) +{ + FRESULT res; + DWORD nfree, clst, sect, stat; + UINT i; + BYTE *p; + _FDID obj; + + + /* Get logical drive */ + res = find_volume(fs, 0); + if (res == FR_OK) { + /* If free_clst is valid, return it without full cluster scan */ + if (fs->free_clst <= fs->n_fatent - 2) { + *nclst = fs->free_clst; + } else { + /* Get number of free clusters */ + nfree = 0; + if (fs->fs_type == FS_FAT12) { /* FAT12: Sector unalighed FAT entries */ + clst = 2; obj.fs = fs; + do { + stat = get_fat(&obj, clst); + if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } + if (stat == 1) { res = FR_INT_ERR; break; } + if (stat == 0) nfree++; + } while (++clst < fs->n_fatent); + } else { +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* exFAT: Scan bitmap table */ + BYTE bm; + UINT b; + + clst = fs->n_fatent - 2; + sect = fs->database; + i = 0; + do { + if (i == 0 && (res = move_window(fs, sect++)) != FR_OK) break; + for (b = 8, bm = fs->win[i]; b && clst; b--, clst--) { + if (!(bm & 1)) nfree++; + bm >>= 1; + } + i = (i + 1) % SS(fs); + } while (clst); + } else +#endif + { /* FAT16/32: Sector alighed FAT entries */ + clst = fs->n_fatent; sect = fs->fatbase; + i = 0; p = 0; + do { + if (i == 0) { + res = move_window(fs, sect++); + if (res != FR_OK) break; + p = fs->win; + i = SS(fs); + } + if (fs->fs_type == FS_FAT16) { + if (ld_word(p) == 0) nfree++; + p += 2; i -= 2; + } else { + if ((ld_dword(p) & 0x0FFFFFFF) == 0) nfree++; + p += 4; i -= 4; + } + } while (--clst); + } + } + *nclst = nfree; /* Return the free clusters */ + fs->free_clst = nfree; /* Now free_clst is valid */ + fs->fsi_flag |= 1; /* FSInfo is to be updated */ + } + } + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Truncate File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_truncate ( + FIL* fp /* Pointer to the file object */ +) +{ + FRESULT res; + FATFS *fs; + DWORD ncl; + + + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); + if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ + + if (fp->obj.objsize > fp->fptr) { + if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ + res = remove_chain(&fp->obj, fp->obj.sclust, 0); + fp->obj.sclust = 0; + } else { /* When truncate a part of the file, remove remaining clusters */ + ncl = get_fat(&fp->obj, fp->clust); + res = FR_OK; + if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; + if (ncl == 1) res = FR_INT_ERR; + if (res == FR_OK && ncl < fs->n_fatent) { + res = remove_chain(&fp->obj, ncl, fp->clust); + } + } + fp->obj.objsize = fp->fptr; /* Set file size to current R/W point */ + fp->flag |= FA_MODIFIED; +#if !_FS_TINY + if (res == FR_OK && (fp->flag & FA_DIRTY)) { + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) { + res = FR_DISK_ERR; + } else { + fp->flag &= (BYTE)~FA_DIRTY; + } + } +#endif + if (res != FR_OK) ABORT(fs, res); + } + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Delete a File/Directory */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_unlink ( + FATFS *fs, + const TCHAR* path /* Pointer to the file or directory path */ +) +{ + FRESULT res; + DIR dj, sdj; + DWORD dclst = 0; +#if _FS_EXFAT + _FDID obj; +#endif + DEF_NAMBUF + + + /* Get logical drive */ + res = find_volume(fs, FA_WRITE); + dj.obj.fs = fs; + if (res == FR_OK) { + INIT_NAMBUF(fs); + res = follow_path(&dj, path); /* Follow the file path */ + if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) { + res = FR_INVALID_NAME; /* Cannot remove dot entry */ + } +#if _FS_LOCK != 0 + if (res == FR_OK) res = chk_lock(&dj, 2); /* Check if it is an open object */ +#endif + if (res == FR_OK) { /* The object is accessible */ + if (dj.fn[NSFLAG] & NS_NONAME) { + res = FR_INVALID_NAME; /* Cannot remove the origin directory */ + } else { + if (dj.obj.attr & AM_RDO) { + res = FR_DENIED; /* Cannot remove R/O object */ + } + } + if (res == FR_OK) { +#if _FS_EXFAT + obj.fs = fs; + if (fs->fs_type == FS_EXFAT) { + obj.sclust = dclst = ld_dword(fs->dirbuf + XDIR_FstClus); + obj.objsize = ld_qword(fs->dirbuf + XDIR_FileSize); + obj.stat = fs->dirbuf[XDIR_GenFlags] & 2; + } else +#endif + { + dclst = ld_clust(fs, dj.dir); + } + if (dj.obj.attr & AM_DIR) { /* Is it a sub-directory ? */ +#if _FS_RPATH != 0 + if (dclst == fs->cdir) { /* Is it the current directory? */ + res = FR_DENIED; + } else +#endif + { + sdj.obj.fs = fs; /* Open the sub-directory */ + sdj.obj.sclust = dclst; +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + sdj.obj.objsize = obj.objsize; + sdj.obj.stat = obj.stat; + } +#endif + res = dir_sdi(&sdj, 0); + if (res == FR_OK) { + res = dir_read(&sdj, 0); /* Read an item */ + if (res == FR_OK) res = FR_DENIED; /* Not empty? */ + if (res == FR_NO_FILE) res = FR_OK; /* Empty? */ + } + } + } + } + if (res == FR_OK) { + res = dir_remove(&dj); /* Remove the directory entry */ + if (res == FR_OK && dclst) { /* Remove the cluster chain if exist */ +#if _FS_EXFAT + res = remove_chain(&obj, dclst, 0); +#else + res = remove_chain(&dj.obj, dclst, 0); +#endif + } + if (res == FR_OK) res = sync_fs(fs); + } + } + FREE_NAMBUF(); + } + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Create a Directory */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_mkdir ( + FATFS *fs, + const TCHAR* path /* Pointer to the directory path */ +) +{ + FRESULT res; + DIR dj; + BYTE *dir; + UINT n; + DWORD dsc, dcl, pcl, tm; + DEF_NAMBUF + + + /* Get logical drive */ + res = find_volume(fs, FA_WRITE); + dj.obj.fs = fs; + if (res == FR_OK) { + INIT_NAMBUF(fs); + res = follow_path(&dj, path); /* Follow the file path */ + if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ + if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) { + res = FR_INVALID_NAME; + } + if (res == FR_NO_FILE) { /* Can create a new directory */ + dcl = create_chain(&dj.obj, 0); /* Allocate a cluster for the new directory table */ + dj.obj.objsize = (DWORD)fs->csize * SS(fs); + res = FR_OK; + if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ + if (dcl == 1) res = FR_INT_ERR; + if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; + if (res == FR_OK) res = sync_window(fs); /* Flush FAT */ + tm = GET_FATTIME(); + if (res == FR_OK) { /* Initialize the new directory table */ + dsc = clust2sect(fs, dcl); + dir = fs->win; + mem_set(dir, 0, SS(fs)); + if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { + mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ + dir[DIR_Name] = '.'; + dir[DIR_Attr] = AM_DIR; + st_dword(dir + DIR_ModTime, tm); + st_clust(fs, dir, dcl); + mem_cpy(dir + SZDIRE, dir, SZDIRE); /* Create ".." entry */ + dir[SZDIRE + 1] = '.'; pcl = dj.obj.sclust; + if (fs->fs_type == FS_FAT32 && pcl == fs->dirbase) pcl = 0; + st_clust(fs, dir + SZDIRE, pcl); + } + for (n = fs->csize; n; n--) { /* Write dot entries and clear following sectors */ + fs->winsect = dsc++; + fs->wflag = 1; + res = sync_window(fs); + if (res != FR_OK) break; + mem_set(dir, 0, SS(fs)); + } + } + if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ + if (res == FR_OK) { +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* Initialize directory entry block */ + st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Created time */ + st_dword(fs->dirbuf + XDIR_FstClus, dcl); /* Table start cluster */ + st_dword(fs->dirbuf + XDIR_FileSize, (DWORD)dj.obj.objsize); /* File size needs to be valid */ + st_dword(fs->dirbuf + XDIR_ValidFileSize, (DWORD)dj.obj.objsize); + fs->dirbuf[XDIR_GenFlags] = 3; /* Initialize the object flag (contiguous) */ + fs->dirbuf[XDIR_Attr] = AM_DIR; /* Attribute */ + res = store_xdir(&dj); + } else +#endif + { + dir = dj.dir; + st_dword(dir + DIR_ModTime, tm); /* Created time */ + st_clust(fs, dir, dcl); /* Table start cluster */ + dir[DIR_Attr] = AM_DIR; /* Attribute */ + fs->wflag = 1; + } + if (res == FR_OK) res = sync_fs(fs); + } else { + remove_chain(&dj.obj, dcl, 0); /* Could not register, remove cluster chain */ + } + } + FREE_NAMBUF(); + } + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Rename a File/Directory */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_rename ( + FATFS *fs, + const TCHAR* path_old, /* Pointer to the object name to be renamed */ + const TCHAR* path_new /* Pointer to the new name */ +) +{ + FRESULT res; + DIR djo, djn; + BYTE buf[_FS_EXFAT ? SZDIRE * 2 : 24], *dir; + DWORD dw; + DEF_NAMBUF + + + res = find_volume(fs, FA_WRITE); + if (res == FR_OK) { + djo.obj.fs = fs; + INIT_NAMBUF(fs); + res = follow_path(&djo, path_old); /* Check old object */ + if (res == FR_OK && (djo.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME; /* Check validity of name */ +#if _FS_LOCK != 0 + if (res == FR_OK) res = chk_lock(&djo, 2); +#endif + if (res == FR_OK) { /* Object to be renamed is found */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* At exFAT */ + BYTE nf, nn; + WORD nh; + + mem_cpy(buf, fs->dirbuf, SZDIRE * 2); /* Save 85+C0 entry of old object */ + mem_cpy(&djn, &djo, sizeof djo); + res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */ + if (res == FR_OK) { /* Is new name already in use by any other object? */ + res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST; + } + if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ + res = dir_register(&djn); /* Register the new entry */ + if (res == FR_OK) { + nf = fs->dirbuf[XDIR_NumSec]; nn = fs->dirbuf[XDIR_NumName]; + nh = ld_word(fs->dirbuf + XDIR_NameHash); + mem_cpy(fs->dirbuf, buf, SZDIRE * 2); + fs->dirbuf[XDIR_NumSec] = nf; fs->dirbuf[XDIR_NumName] = nn; + st_word(fs->dirbuf + XDIR_NameHash, nh); +/* Start of critical section where any interruption can cause a cross-link */ + res = store_xdir(&djn); + } + } + } else +#endif + { /* At FAT12/FAT16/FAT32 */ + mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about the object except name */ + mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ + res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */ + if (res == FR_OK) { /* Is new name already in use by any other object? */ + res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST; + } + if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ + res = dir_register(&djn); /* Register the new entry */ + if (res == FR_OK) { + dir = djn.dir; /* Copy information about object except name */ + mem_cpy(dir + 13, buf + 2, 19); + dir[DIR_Attr] = buf[0] | AM_ARC; + fs->wflag = 1; + if ((dir[DIR_Attr] & AM_DIR) && djo.obj.sclust != djn.obj.sclust) { /* Update .. entry in the sub-directory if needed */ + dw = clust2sect(fs, ld_clust(fs, dir)); + if (!dw) { + res = FR_INT_ERR; + } else { +/* Start of critical section where any interruption can cause a cross-link */ + res = move_window(fs, dw); + dir = fs->win + SZDIRE * 1; /* Ptr to .. entry */ + if (res == FR_OK && dir[1] == '.') { + st_clust(fs, dir, djn.obj.sclust); + fs->wflag = 1; + } + } + } + } + } + } + if (res == FR_OK) { + res = dir_remove(&djo); /* Remove old entry */ + if (res == FR_OK) { + res = sync_fs(fs); + } + } +/* End of critical section */ + } + FREE_NAMBUF(); + } + + LEAVE_FF(fs, res); +} + +#endif /* !_FS_READONLY */ +#endif /* _FS_MINIMIZE == 0 */ +#endif /* _FS_MINIMIZE <= 1 */ +#endif /* _FS_MINIMIZE <= 2 */ + + + +#if _USE_CHMOD && !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Change Attribute */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_chmod ( + FATFS *fs, + const TCHAR* path, /* Pointer to the file path */ + BYTE attr, /* Attribute bits */ + BYTE mask /* Attribute mask to change */ +) +{ + FRESULT res; + DIR dj; + DEF_NAMBUF + + + res = find_volume(fs, FA_WRITE); /* Get logical drive */ + dj.obj.fs = fs; + if (res == FR_OK) { + INIT_NAMBUF(fs); + res = follow_path(&dj, path); /* Follow the file path */ + if (res == FR_OK && (dj.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME; /* Check object validity */ + if (res == FR_OK) { + mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + fs->dirbuf[XDIR_Attr] = (attr & mask) | (fs->dirbuf[XDIR_Attr] & (BYTE)~mask); /* Apply attribute change */ + res = store_xdir(&dj); + } else +#endif + { + dj.dir[DIR_Attr] = (attr & mask) | (dj.dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ + fs->wflag = 1; + } + if (res == FR_OK) res = sync_fs(fs); + } + FREE_NAMBUF(); + } + + LEAVE_FF(fs, res); +} + + + + +/*-----------------------------------------------------------------------*/ +/* Change Timestamp */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_utime ( + FATFS *fs, + const TCHAR* path, /* Pointer to the file/directory name */ + const FILINFO* fno /* Pointer to the time stamp to be set */ +) +{ + FRESULT res; + DIR dj; + DEF_NAMBUF + + + res = find_volume(fs, FA_WRITE); /* Get logical drive */ + dj.obj.fs = fs; + if (res == FR_OK) { + INIT_NAMBUF(fs); + res = follow_path(&dj, path); /* Follow the file path */ + if (res == FR_OK && (dj.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME; /* Check object validity */ + if (res == FR_OK) { +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + st_dword(fs->dirbuf + XDIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime); + res = store_xdir(&dj); + } else +#endif + { + st_dword(dj.dir + DIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime); + fs->wflag = 1; + } + if (res == FR_OK) res = sync_fs(fs); + } + FREE_NAMBUF(); + } + + LEAVE_FF(fs, res); +} + +#endif /* _USE_CHMOD && !_FS_READONLY */ + + + +#if _USE_LABEL +/*-----------------------------------------------------------------------*/ +/* Get Volume Label */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_getlabel ( + FATFS *fs, + TCHAR* label, /* Pointer to a buffer to return the volume label */ + DWORD* vsn /* Pointer to a variable to return the volume serial number */ +) +{ + FRESULT res; + DIR dj; + UINT si, di; +#if _LFN_UNICODE || _FS_EXFAT + WCHAR w; +#endif + + /* Get logical drive */ + res = find_volume(fs, 0); + + /* Get volume label */ + if (res == FR_OK && label) { + dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */ + res = dir_sdi(&dj, 0); + if (res == FR_OK) { + res = dir_read(&dj, 1); /* Find a volume label entry */ + if (res == FR_OK) { +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + for (si = di = 0; si < dj.dir[XDIR_NumLabel]; si++) { /* Extract volume label from 83 entry */ + w = ld_word(dj.dir + XDIR_Label + si * 2); +#if _LFN_UNICODE + label[di++] = w; +#else + w = ff_convert(w, 0); /* Unicode -> OEM */ + if (w == 0) w = '?'; /* Replace wrong character */ + if (_DF1S && w >= 0x100) label[di++] = (char)(w >> 8); + label[di++] = (char)w; +#endif + } + label[di] = 0; + } else +#endif + { + si = di = 0; /* Extract volume label from AM_VOL entry with code comversion */ + do { +#if _LFN_UNICODE + w = (si < 11) ? dj.dir[si++] : ' '; + if (IsDBCS1(w) && si < 11 && IsDBCS2(dj.dir[si])) { + w = w << 8 | dj.dir[si++]; + } + label[di++] = ff_convert(w, 1); /* OEM -> Unicode */ +#else + label[di++] = dj.dir[si++]; +#endif + } while (di < 11); + do { /* Truncate trailing spaces */ + label[di] = 0; + if (di == 0) break; + } while (label[--di] == ' '); + } + } + } + if (res == FR_NO_FILE) { /* No label entry and return nul string */ + label[0] = 0; + res = FR_OK; + } + } + + /* Get volume serial number */ + if (res == FR_OK && vsn) { + res = move_window(fs, fs->volbase); + if (res == FR_OK) { + switch (fs->fs_type) { + case FS_EXFAT: di = BPB_VolIDEx; break; + case FS_FAT32: di = BS_VolID32; break; + default: di = BS_VolID; + } + *vsn = ld_dword(fs->win + di); + } + } + + LEAVE_FF(fs, res); +} + + + +#if !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Set Volume Label */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_setlabel ( + FATFS *fs, + const TCHAR* label /* Pointer to the volume label to set */ +) +{ + FRESULT res; + DIR dj; + BYTE dirvn[22]; + UINT i, j, slen; + WCHAR w; + static const char badchr[] = "\"*+,.:;<=>\?[]|\x7F"; + + + /* Get logical drive */ + res = find_volume(fs, FA_WRITE); + if (res != FR_OK) LEAVE_FF(fs, res); + dj.obj.fs = fs; + + /* Get length of given volume label */ + for (slen = 0; (UINT)label[slen] >= ' '; slen++) { } /* Get name length */ + +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ + for (i = j = 0; i < slen; ) { /* Create volume label in directory form */ + w = label[i++]; +#if !_LFN_UNICODE + if (IsDBCS1(w)) { + w = (i < slen && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; + } + w = ff_convert(w, 1); +#endif + if (w == 0 || chk_chr(badchr, w) || j == 22) { /* Check validity check validity of the volume label */ + LEAVE_FF(fs, FR_INVALID_NAME); + } + st_word(dirvn + j, w); j += 2; + } + slen = j; + } else +#endif + { /* On the FAT12/16/32 volume */ + for ( ; slen && label[slen - 1] == ' '; slen--) ; /* Remove trailing spaces */ + if (slen) { /* Is there a volume label to be set? */ + dirvn[0] = 0; i = j = 0; /* Create volume label in directory form */ + do { +#if _LFN_UNICODE + w = ff_convert(ff_wtoupper(label[i++]), 0); +#else + w = (BYTE)label[i++]; + if (IsDBCS1(w)) { + w = (j < 10 && i < slen && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; + } +#if _USE_LFN != 0 + w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); +#else + if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ +#ifdef _EXCVT + if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ +#else + if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ +#endif +#endif +#endif + if (w == 0 || chk_chr(badchr, w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) { /* Reject invalid characters for volume label */ + LEAVE_FF(fs, FR_INVALID_NAME); + } + if (w >= 0x100) dirvn[j++] = (BYTE)(w >> 8); + dirvn[j++] = (BYTE)w; + } while (i < slen); + while (j < 11) dirvn[j++] = ' '; /* Fill remaining name field */ + if (dirvn[0] == DDEM) LEAVE_FF(fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ + } + } + + /* Set volume label */ + dj.obj.sclust = 0; /* Open root directory */ + res = dir_sdi(&dj, 0); + if (res == FR_OK) { + res = dir_read(&dj, 1); /* Get volume label entry */ + if (res == FR_OK) { + if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { + dj.dir[XDIR_NumLabel] = (BYTE)(slen / 2); /* Change the volume label */ + mem_cpy(dj.dir + XDIR_Label, dirvn, slen); + } else { + if (slen) { + mem_cpy(dj.dir, dirvn, 11); /* Change the volume label */ + } else { + dj.dir[DIR_Name] = DDEM; /* Remove the volume label */ + } + } + fs->wflag = 1; + res = sync_fs(fs); + } else { /* No volume label entry is found or error */ + if (res == FR_NO_FILE) { + res = FR_OK; + if (slen) { /* Create a volume label entry */ + res = dir_alloc(&dj, 1); /* Allocate an entry */ + if (res == FR_OK) { + mem_set(dj.dir, 0, SZDIRE); /* Clear the entry */ + if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { + dj.dir[XDIR_Type] = 0x83; /* Create 83 entry */ + dj.dir[XDIR_NumLabel] = (BYTE)(slen / 2); + mem_cpy(dj.dir + XDIR_Label, dirvn, slen); + } else { + dj.dir[DIR_Attr] = AM_VOL; /* Create volume label entry */ + mem_cpy(dj.dir, dirvn, 11); + } + fs->wflag = 1; + res = sync_fs(fs); + } + } + } + } + } + + LEAVE_FF(fs, res); +} + +#endif /* !_FS_READONLY */ +#endif /* _USE_LABEL */ + + + +#if _USE_EXPAND && !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Allocate a Contiguous Blocks to the File */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_expand ( + FIL* fp, /* Pointer to the file object */ + FSIZE_t fsz, /* File size to be expanded to */ + BYTE opt /* Operation mode 0:Find and prepare or 1:Find and allocate */ +) +{ + FRESULT res; + FATFS *fs; + DWORD n, clst, stcl, scl, ncl, tcl, lclst; + + + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); + if (fsz == 0 || fp->obj.objsize != 0 || !(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); +#if _FS_EXFAT + if (fs->fs_type != FS_EXFAT && fsz >= 0x100000000) LEAVE_FF(fs, FR_DENIED); /* Check if in size limit */ +#endif + n = (DWORD)fs->csize * SS(fs); /* Cluster size */ + tcl = (DWORD)(fsz / n) + ((fsz & (n - 1)) ? 1 : 0); /* Number of clusters required */ + stcl = fs->last_clst; lclst = 0; + if (stcl < 2 || stcl >= fs->n_fatent) stcl = 2; + +#if _FS_EXFAT + if (fs->fs_type == FS_EXFAT) { + scl = find_bitmap(fs, stcl, tcl); /* Find a contiguous cluster block */ + if (scl == 0) res = FR_DENIED; /* No contiguous cluster block was found */ + if (scl == 0xFFFFFFFF) res = FR_DISK_ERR; + if (res == FR_OK) { + if (opt) { + res = change_bitmap(fs, scl, tcl, 1); /* Mark the cluster block 'in use' */ + lclst = scl + tcl - 1; + } else { + lclst = scl - 1; + } + } + } else +#endif + { + scl = clst = stcl; ncl = 0; + for (;;) { /* Find a contiguous cluster block */ + n = get_fat(&fp->obj, clst); + if (++clst >= fs->n_fatent) clst = 2; + if (n == 1) { res = FR_INT_ERR; break; } + if (n == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } + if (n == 0) { /* Is it a free cluster? */ + if (++ncl == tcl) break; /* Break if a contiguous cluster block is found */ + } else { + scl = clst; ncl = 0; /* Not a free cluster */ + } + if (clst == stcl) { res = FR_DENIED; break; } /* No contiguous cluster? */ + } + if (res == FR_OK) { + if (opt) { + for (clst = scl, n = tcl; n; clst++, n--) { /* Create a cluster chain on the FAT */ + res = put_fat(fs, clst, (n == 1) ? 0xFFFFFFFF : clst + 1); + if (res != FR_OK) break; + lclst = clst; + } + } else { + lclst = scl - 1; + } + } + } + + if (res == FR_OK) { + fs->last_clst = lclst; /* Set suggested start cluster to start next */ + if (opt) { + fp->obj.sclust = scl; /* Update object allocation information */ + fp->obj.objsize = fsz; + if (_FS_EXFAT) fp->obj.stat = 2; /* Set status 'contiguous chain' */ + fp->flag |= FA_MODIFIED; + if (fs->free_clst < fs->n_fatent - 2) { /* Update FSINFO */ + fs->free_clst -= tcl; + fs->fsi_flag |= 1; + } + } + } + + LEAVE_FF(fs, res); +} + +#endif /* _USE_EXPAND && !_FS_READONLY */ + + + +#if _USE_FORWARD +/*-----------------------------------------------------------------------*/ +/* Forward data to the stream directly */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_forward ( + FIL* fp, /* Pointer to the file object */ + UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ + UINT btf, /* Number of bytes to forward */ + UINT* bf /* Pointer to number of bytes forwarded */ +) +{ + FRESULT res; + FATFS *fs; + DWORD clst, sect; + FSIZE_t remain; + UINT rcnt, csect; + BYTE *dbuf; + + + *bf = 0; /* Clear transfer byte counter */ + res = validate(&fp->obj, &fs); /* Check validity of the file object */ + if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); + if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ + + remain = fp->obj.objsize - fp->fptr; + if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ + + for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream goes busy */ + fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { + csect = (UINT)(fp->fptr / SS(fs) & (fs->csize - 1)); /* Sector offset in the cluster */ + if (fp->fptr % SS(fs) == 0) { /* On the sector boundary? */ + if (csect == 0) { /* On the cluster boundary? */ + clst = (fp->fptr == 0) ? /* On the top of the file? */ + fp->obj.sclust : get_fat(&fp->obj, fp->clust); + if (clst <= 1) ABORT(fs, FR_INT_ERR); + if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); + fp->clust = clst; /* Update current cluster */ + } + } + sect = clust2sect(fs, fp->clust); /* Get current data sector */ + if (!sect) ABORT(fs, FR_INT_ERR); + sect += csect; +#if _FS_TINY + if (move_window(fs, sect) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Move sector window to the file data */ + dbuf = fs->win; +#else + if (fp->sect != sect) { /* Fill sector cache with file data */ +#if !_FS_READONLY + if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ + if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); + fp->flag &= (BYTE)~FA_DIRTY; + } +#endif + if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); + } + dbuf = fp->buf; +#endif + fp->sect = sect; + rcnt = SS(fs) - (UINT)fp->fptr % SS(fs); /* Number of bytes left in the sector */ + if (rcnt > btf) rcnt = btf; /* Clip it by btr if needed */ + rcnt = (*func)(dbuf + ((UINT)fp->fptr % SS(fs)), rcnt); /* Forward the file data */ + if (!rcnt) ABORT(fs, FR_INT_ERR); + } + + LEAVE_FF(fs, FR_OK); +} +#endif /* _USE_FORWARD */ + + + +#if _USE_MKFS && !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Create FAT file system on the logical drive */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_mkfs ( + FATFS *fs, + BYTE opt, /* Format option */ + DWORD au, /* Size of allocation unit [byte] */ + void* work, /* Pointer to working buffer */ + UINT len /* Size of working buffer */ +) +{ + const UINT n_fats = 1; /* Number of FATs for FAT12/16/32 volume (1 or 2) */ + const UINT n_rootdir = 512; /* Number of root directory entries for FAT12/16 volume */ + static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT12/16 volume (4Ks unit) */ + static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */ + BYTE fmt, sys, *buf, *pte, part; void *pdrv; + WORD ss; + DWORD szb_buf, sz_buf, sz_blk, n_clst, pau, sect, nsect, n; + DWORD b_vol, b_fat, b_data; /* Base LBA for volume, fat, data */ + DWORD sz_vol, sz_rsv, sz_fat, sz_dir; /* Size for volume, fat, dir, data */ + UINT i; + DSTATUS stat; +#if _USE_TRIM || _FS_EXFAT + DWORD tbl[3]; +#endif + + + /* Check mounted drive and clear work area */ + fs->fs_type = 0; /* Clear mounted volume */ + pdrv = fs->drv; /* Physical drive */ + part = LD2PT(fs); /* Partition (0:create as new, 1-4:get from partition table) */ + + /* Check physical drive status */ + disk_ioctl(pdrv, IOCTL_INIT, &stat); + if (stat & STA_NOINIT) return FR_NOT_READY; + if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; + if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_blk) != RES_OK || !sz_blk || sz_blk > 32768 || (sz_blk & (sz_blk - 1))) sz_blk = 1; /* Erase block to align data area */ +#if _MAX_SS != _MIN_SS /* Get sector size of the medium */ + if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) return FR_DISK_ERR; + if (ss > _MAX_SS || ss < _MIN_SS || (ss & (ss - 1))) return FR_DISK_ERR; +#else + ss = _MAX_SS; +#endif + if ((au != 0 && au < ss) || au > 0x1000000 || (au & (au - 1))) return FR_INVALID_PARAMETER; /* Check if au is valid */ + au /= ss; /* Cluster size in unit of sector */ + + /* Get working buffer */ + buf = (BYTE*)work; /* Working buffer */ + sz_buf = len / ss; /* Size of working buffer (sector) */ + szb_buf = sz_buf * ss; /* Size of working buffer (byte) */ + if (!szb_buf) return FR_MKFS_ABORTED; + + /* Determine where the volume to be located (b_vol, sz_vol) */ + if (_MULTI_PARTITION && part != 0) { + /* Get partition information from partition table in the MBR */ + if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */ + if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if MBR is valid */ + pte = buf + (MBR_Table + (part - 1) * SZ_PTE); + if (!pte[PTE_System]) return FR_MKFS_ABORTED; /* No partition? */ + b_vol = ld_dword(pte + PTE_StLba); /* Get volume start sector */ + sz_vol = ld_dword(pte + PTE_SizLba); /* Get volume size */ + } else { + /* Create a single-partition in this function */ + if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_vol) != RES_OK) return FR_DISK_ERR; + b_vol = (opt & FM_SFD) ? 0 : 63; /* Volume start sector */ + if (sz_vol < b_vol) return FR_MKFS_ABORTED; + sz_vol -= b_vol; /* Volume size */ + } + if (sz_vol < 50) return FR_MKFS_ABORTED; /* Check if volume size is >=50s */ + + /* Pre-determine the FAT type */ + do { + if (_FS_EXFAT && (opt & FM_EXFAT)) { /* exFAT possible? */ + if ((opt & FM_ANY) == FM_EXFAT || sz_vol >= 0x4000000 || au > 128) { /* exFAT only, vol >= 64Ms or au > 128s ? */ + fmt = FS_EXFAT; break; + } + } + if (au > 128) return FR_INVALID_PARAMETER; /* Too large au for FAT/FAT32 */ + if (opt & FM_FAT32) { /* FAT32 possible? */ + if ((opt & FM_ANY) == FM_FAT32 || !(opt & FM_FAT)) { /* FAT32 only or no-FAT? */ + fmt = FS_FAT32; break; + } + } + if (!(opt & FM_FAT)) return FR_INVALID_PARAMETER; /* no-FAT? */ + fmt = FS_FAT16; + } while (0); + +#if _FS_EXFAT + if (fmt == FS_EXFAT) { /* Create an exFAT volume */ + DWORD szb_bit, szb_case, sum, nb, cl; + WCHAR ch, si; + UINT j, st; + BYTE b; + + if (sz_vol < 0x1000) return FR_MKFS_ABORTED; /* Too small volume? */ +#if _USE_TRIM + tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1; /* Inform the device the volume area can be erased */ + disk_ioctl(pdrv, CTRL_TRIM, tbl); +#endif + /* Determine FAT location, data location and number of clusters */ + if (!au) { /* au auto-selection */ + au = 8; + if (sz_vol >= 0x80000) au = 64; /* >= 512Ks */ + if (sz_vol >= 0x4000000) au = 256; /* >= 64Ms */ + } + b_fat = b_vol + 32; /* FAT start at offset 32 */ + sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss; /* Number of FAT sectors */ + b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1); /* Align data area to the erase block boundary */ + if (b_data >= sz_vol / 2) return FR_MKFS_ABORTED; /* Too small volume? */ + n_clst = (sz_vol - (b_data - b_vol)) / au; /* Number of clusters */ + if (n_clst <16) return FR_MKFS_ABORTED; /* Too few clusters? */ + if (n_clst > MAX_EXFAT) return FR_MKFS_ABORTED; /* Too many clusters? */ + + szb_bit = (n_clst + 7) / 8; /* Size of allocation bitmap */ + tbl[0] = (szb_bit + au * ss - 1) / (au * ss); /* Number of allocation bitmap clusters */ + + /* Create a compressed up-case table */ + sect = b_data + au * tbl[0]; /* Table start sector */ + sum = 0; /* Table checksum to be stored in the 82 entry */ + st = si = i = j = szb_case = 0; + do { + switch (st) { + case 0: + ch = ff_wtoupper(si); /* Get an up-case char */ + if (ch != si) { + si++; break; /* Store the up-case char if exist */ + } + for (j = 1; (WCHAR)(si + j) && (WCHAR)(si + j) == ff_wtoupper((WCHAR)(si + j)); j++) ; /* Get run length of no-case block */ + if (j >= 128) { + ch = 0xFFFF; st = 2; break; /* Compress the no-case block if run is >= 128 */ + } + st = 1; /* Do not compress short run */ + /* continue */ + case 1: + ch = si++; /* Fill the short run */ + if (--j == 0) st = 0; + break; + default: + ch = (WCHAR)j; si += j; /* Number of chars to skip */ + st = 0; + } + sum = xsum32(buf[i + 0] = (BYTE)ch, sum); /* Put it into the write buffer */ + sum = xsum32(buf[i + 1] = (BYTE)(ch >> 8), sum); + i += 2; szb_case += 2; + if (!si || i == szb_buf) { /* Write buffered data when buffer full or end of process */ + n = (i + ss - 1) / ss; + if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; + sect += n; i = 0; + } + } while (si); + tbl[1] = (szb_case + au * ss - 1) / (au * ss); /* Number of up-case table clusters */ + tbl[2] = 1; /* Number of root dir clusters */ + + /* Initialize the allocation bitmap */ + sect = b_data; nsect = (szb_bit + ss - 1) / ss; /* Start of bitmap and number of sectors */ + nb = tbl[0] + tbl[1] + tbl[2]; /* Number of clusters in-use by system */ + do { + mem_set(buf, 0, szb_buf); + for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ; + for (b = 1; nb && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ; + n = (nsect > sz_buf) ? sz_buf : nsect; /* Write the buffered data */ + if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; + sect += n; nsect -= n; + } while (nsect); + + /* Initialize the FAT */ + sect = b_fat; nsect = sz_fat; /* Start of FAT and number of FAT sectors */ + j = nb = cl = 0; + do { + mem_set(buf, 0, szb_buf); i = 0; /* Clear work area and reset write index */ + if (cl == 0) { /* Set entry 0 and 1 */ + st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++; + st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++; + } + do { /* Create chains of bitmap, up-case and root dir */ + while (nb && i < szb_buf) { /* Create a chain */ + st_dword(buf + i, (nb > 1) ? cl + 1 : 0xFFFFFFFF); + i += 4; cl++; nb--; + } + if (!nb && j < 3) nb = tbl[j++]; /* Next chain */ + } while (nb && i < szb_buf); + n = (nsect > sz_buf) ? sz_buf : nsect; /* Write the buffered data */ + if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; + sect += n; nsect -= n; + } while (nsect); + + /* Initialize the root directory */ + mem_set(buf, 0, szb_buf); + buf[SZDIRE * 0 + 0] = 0x83; /* 83 entry (volume label) */ + buf[SZDIRE * 1 + 0] = 0x81; /* 81 entry (allocation bitmap) */ + st_dword(buf + SZDIRE * 1 + 20, 2); + st_dword(buf + SZDIRE * 1 + 24, szb_bit); + buf[SZDIRE * 2 + 0] = 0x82; /* 82 entry (up-case table) */ + st_dword(buf + SZDIRE * 2 + 4, sum); + st_dword(buf + SZDIRE * 2 + 20, 2 + tbl[0]); + st_dword(buf + SZDIRE * 2 + 24, szb_case); + sect = b_data + au * (tbl[0] + tbl[1]); nsect = au; /* Start of the root directory and number of sectors */ + do { /* Fill root directory sectors */ + n = (nsect > sz_buf) ? sz_buf : nsect; + if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; + mem_set(buf, 0, ss); + sect += n; nsect -= n; + } while (nsect); + + /* Create two set of the exFAT VBR blocks */ + sect = b_vol; + for (n = 0; n < 2; n++) { + /* Main record (+0) */ + mem_set(buf, 0, ss); + mem_cpy(buf + BS_JmpBoot, "\xEB\x76\x90" "EXFAT ", 11); /* Boot jump code (x86), OEM name */ + st_dword(buf + BPB_VolOfsEx, b_vol); /* Volume offset in the physical drive [sector] */ + st_dword(buf + BPB_TotSecEx, sz_vol); /* Volume size [sector] */ + st_dword(buf + BPB_FatOfsEx, b_fat - b_vol); /* FAT offset [sector] */ + st_dword(buf + BPB_FatSzEx, sz_fat); /* FAT size [sector] */ + st_dword(buf + BPB_DataOfsEx, b_data - b_vol); /* Data offset [sector] */ + st_dword(buf + BPB_NumClusEx, n_clst); /* Number of clusters */ + st_dword(buf + BPB_RootClusEx, 2 + tbl[0] + tbl[1]); /* Root dir cluster # */ + st_dword(buf + BPB_VolIDEx, GET_FATTIME()); /* VSN */ + st_word(buf + BPB_FSVerEx, 0x100); /* File system version (1.00) */ + for (buf[BPB_BytsPerSecEx] = 0, i = ss; i >>= 1; buf[BPB_BytsPerSecEx]++) ; /* Log2 of sector size [byte] */ + for (buf[BPB_SecPerClusEx] = 0, i = au; i >>= 1; buf[BPB_SecPerClusEx]++) ; /* Log2 of cluster size [sector] */ + buf[BPB_NumFATsEx] = 1; /* Number of FATs */ + buf[BPB_DrvNumEx] = 0x80; /* Drive number (for int13) */ + st_word(buf + BS_BootCodeEx, 0xFEEB); /* Boot code (x86) */ + st_word(buf + BS_55AA, 0xAA55); /* Signature (placed here regardless of sector size) */ + for (i = sum = 0; i < ss; i++) { /* VBR checksum */ + if (i != BPB_VolFlagEx && i != BPB_VolFlagEx + 1 && i != BPB_PercInUseEx) sum = xsum32(buf[i], sum); + } + if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; + /* Extended bootstrap record (+1..+8) */ + mem_set(buf, 0, ss); + st_word(buf + ss - 2, 0xAA55); /* Signature (placed at end of sector) */ + for (j = 1; j < 9; j++) { + for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ; /* VBR checksum */ + if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; + } + /* OEM/Reserved record (+9..+10) */ + mem_set(buf, 0, ss); + for ( ; j < 11; j++) { + for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ; /* VBR checksum */ + if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; + } + /* Sum record (+11) */ + for (i = 0; i < ss; i += 4) st_dword(buf + i, sum); /* Fill with checksum value */ + if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; + } + + } else +#endif /* _FS_EXFAT */ + { /* Create an FAT12/16/32 volume */ + do { + pau = au; + /* Pre-determine number of clusters and FAT sub-type */ + if (fmt == FS_FAT32) { /* FAT32 volume */ + if (!pau) { /* au auto-selection */ + n = sz_vol / 0x20000; /* Volume size in unit of 128KS */ + for (i = 0, pau = 1; cst32[i] && cst32[i] <= n; i++, pau <<= 1) ; /* Get from table */ + } + n_clst = sz_vol / pau; /* Number of clusters */ + sz_fat = (n_clst * 4 + 8 + ss - 1) / ss; /* FAT size [sector] */ + sz_rsv = 32; /* Number of reserved sectors */ + sz_dir = 0; /* No static directory */ + if (n_clst <= MAX_FAT16 || n_clst > MAX_FAT32) return FR_MKFS_ABORTED; + } else { /* FAT12/16 volume */ + if (!pau) { /* au auto-selection */ + n = sz_vol / 0x1000; /* Volume size in unit of 4KS */ + for (i = 0, pau = 1; cst[i] && cst[i] <= n; i++, pau <<= 1) ; /* Get from table */ + } + n_clst = sz_vol / pau; + if (n_clst > MAX_FAT12) { + n = n_clst * 2 + 4; /* FAT size [byte] */ + } else { + fmt = FS_FAT12; + n = (n_clst * 3 + 1) / 2 + 3; /* FAT size [byte] */ + } + sz_fat = (n + ss - 1) / ss; /* FAT size [sector] */ + sz_rsv = 1; /* Number of reserved sectors */ + sz_dir = (DWORD)n_rootdir * SZDIRE / ss; /* Rootdir size [sector] */ + } + b_fat = b_vol + sz_rsv; /* FAT base */ + b_data = b_fat + sz_fat * n_fats + sz_dir; /* Data base */ + + /* Align data base to erase block boundary (for flash memory media) */ + n = ((b_data + sz_blk - 1) & ~(sz_blk - 1)) - b_data; /* Next nearest erase block from current data base */ + if (fmt == FS_FAT32) { /* FAT32: Move FAT base */ + sz_rsv += n; b_fat += n; + } else { /* FAT12/16: Expand FAT size */ + sz_fat += n / n_fats; + } + + /* Determine number of clusters and final check of validity of the FAT sub-type */ + if (sz_vol < b_data + pau * 16 - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ + n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir) / pau; + if (fmt == FS_FAT32) { + if (n_clst <= MAX_FAT16) { /* Too few clusters for FAT32 */ + if (!au && (au = pau / 2) != 0) continue; /* Adjust cluster size and retry */ + return FR_MKFS_ABORTED; + } + } + if (fmt == FS_FAT16) { + if (n_clst > MAX_FAT16) { /* Too many clusters for FAT16 */ + if (!au && (pau * 2) <= 64) { + au = pau * 2; continue; /* Adjust cluster size and retry */ + } + if ((opt & FM_FAT32)) { + fmt = FS_FAT32; continue; /* Switch type to FAT32 and retry */ + } + if (!au && (au = pau * 2) <= 128) continue; /* Adjust cluster size and retry */ + return FR_MKFS_ABORTED; + } + if (n_clst <= MAX_FAT12) { /* Too few clusters for FAT16 */ + if (!au && (au = pau * 2) <= 128) continue; /* Adjust cluster size and retry */ + return FR_MKFS_ABORTED; + } + } + if (fmt == FS_FAT12 && n_clst > MAX_FAT12) return FR_MKFS_ABORTED; /* Too many clusters for FAT12 */ + + /* Ok, it is the valid cluster configuration */ + break; + } while (1); + +#if _USE_TRIM + tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1; /* Inform the device the volume area can be erased */ + disk_ioctl(pdrv, CTRL_TRIM, tbl); +#endif + /* Create FAT VBR */ + mem_set(buf, 0, ss); + mem_cpy(buf + BS_JmpBoot, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code (x86), OEM name */ + st_word(buf + BPB_BytsPerSec, ss); /* Sector size [byte] */ + buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */ + st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */ + buf[BPB_NumFATs] = (BYTE)n_fats; /* Number of FATs */ + st_word(buf + BPB_RootEntCnt, (WORD)((fmt == FS_FAT32) ? 0 : n_rootdir)); /* Number of root directory entries */ + if (sz_vol < 0x10000) { + st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */ + } else { + st_dword(buf + BPB_TotSec32, sz_vol); /* Volume size in 32-bit LBA */ + } + buf[BPB_Media] = 0xF8; /* Media descriptor byte */ + st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */ + st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */ + st_dword(buf + BPB_HiddSec, b_vol); /* Volume offset in the physical drive [sector] */ + if (fmt == FS_FAT32) { + st_dword(buf + BS_VolID32, GET_FATTIME()); /* VSN */ + st_dword(buf + BPB_FATSz32, sz_fat); /* FAT size [sector] */ + st_dword(buf + BPB_RootClus32, 2); /* Root directory cluster # (2) */ + st_word(buf + BPB_FSInfo32, 1); /* Offset of FSINFO sector (VBR + 1) */ + st_word(buf + BPB_BkBootSec32, 6); /* Offset of backup VBR (VBR + 6) */ + buf[BS_DrvNum32] = 0x80; /* Drive number (for int13) */ + buf[BS_BootSig32] = 0x29; /* Extended boot signature */ + mem_cpy(buf + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ + } else { + st_dword(buf + BS_VolID, GET_FATTIME()); /* VSN */ + st_word(buf + BPB_FATSz16, (WORD)sz_fat); /* FAT size [sector] */ + buf[BS_DrvNum] = 0x80; /* Drive number (for int13) */ + buf[BS_BootSig] = 0x29; /* Extended boot signature */ + mem_cpy(buf + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ + } + st_word(buf + BS_55AA, 0xAA55); /* Signature (offset is fixed here regardless of sector size) */ + if (disk_write(pdrv, buf, b_vol, 1) != RES_OK) return FR_DISK_ERR; /* Write it to the VBR sector */ + + /* Create FSINFO record if needed */ + if (fmt == FS_FAT32) { + disk_write(pdrv, buf, b_vol + 6, 1); /* Write backup VBR (VBR + 6) */ + mem_set(buf, 0, ss); + st_dword(buf + FSI_LeadSig, 0x41615252); + st_dword(buf + FSI_StrucSig, 0x61417272); + st_dword(buf + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ + st_dword(buf + FSI_Nxt_Free, 2); /* Last allocated cluster# */ + st_word(buf + BS_55AA, 0xAA55); + disk_write(pdrv, buf, b_vol + 7, 1); /* Write backup FSINFO (VBR + 7) */ + disk_write(pdrv, buf, b_vol + 1, 1); /* Write original FSINFO (VBR + 1) */ + } + + /* Initialize FAT area */ + mem_set(buf, 0, (UINT)szb_buf); + sect = b_fat; /* FAT start sector */ + for (i = 0; i < n_fats; i++) { /* Initialize FATs each */ + if (fmt == FS_FAT32) { + st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */ + st_dword(buf + 4, 0xFFFFFFFF); /* Entry 1 */ + st_dword(buf + 8, 0x0FFFFFFF); /* Entry 2 (root directory) */ + } else { + st_dword(buf + 0, (fmt == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */ + } + nsect = sz_fat; /* Number of FAT sectors */ + do { /* Fill FAT sectors */ + n = (nsect > sz_buf) ? sz_buf : nsect; + if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR; + mem_set(buf, 0, ss); + sect += n; nsect -= n; + } while (nsect); + } + + /* Initialize root directory (fill with zero) */ + nsect = (fmt == FS_FAT32) ? pau : sz_dir; /* Number of root directory sectors */ + do { + n = (nsect > sz_buf) ? sz_buf : nsect; + if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR; + sect += n; nsect -= n; + } while (nsect); + } + + /* Determine system ID in the partition table */ + if (_FS_EXFAT && fmt == FS_EXFAT) { + sys = 0x07; /* HPFS/NTFS/exFAT */ + } else { + if (fmt == FS_FAT32) { + sys = 0x0C; /* FAT32X */ + } else { + if (sz_vol >= 0x10000) { + sys = 0x06; /* FAT12/16 (>=64KS) */ + } else { + sys = (fmt == FS_FAT16) ? 0x04 : 0x01; /* FAT16 (<64KS) : FAT12 (<64KS) */ + } + } + } + + if (_MULTI_PARTITION && part != 0) { + /* Update system ID in the partition table */ + if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Read the MBR */ + buf[MBR_Table + (part - 1) * SZ_PTE + PTE_System] = sys; /* Set system type */ + if (disk_write(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Write it back to the MBR */ + } else { + if (!(opt & FM_SFD)) { + /* Create partition table in FDISK format */ + mem_set(buf, 0, ss); + st_word(buf + BS_55AA, 0xAA55); /* MBR signature */ + pte = buf + MBR_Table; /* Create partition table for single partition in the drive */ + pte[PTE_Boot] = 0; /* Boot indicator */ + pte[PTE_StHead] = 1; /* Start head */ + pte[PTE_StSec] = 1; /* Start sector */ + pte[PTE_StCyl] = 0; /* Start cylinder */ + pte[PTE_System] = sys; /* System type */ + n = (b_vol + sz_vol) / (63 * 255); /* (End CHS is incorrect) */ + pte[PTE_EdHead] = 254; /* End head */ + pte[PTE_EdSec] = (BYTE)(n >> 2 | 63); /* End sector */ + pte[PTE_EdCyl] = (BYTE)n; /* End cylinder */ + st_dword(pte + PTE_StLba, b_vol); /* Start offset in LBA */ + st_dword(pte + PTE_SizLba, sz_vol); /* Size in sectors */ + if (disk_write(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Write it to the MBR */ + } + } + + if (disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) return FR_DISK_ERR; + + return FR_OK; +} + + + +#if _MULTI_PARTITION +/*-----------------------------------------------------------------------*/ +/* Create partition table on the physical drive */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_fdisk ( + void *pdrv, /* Physical drive number */ + const DWORD* szt, /* Pointer to the size table for each partitions */ + void* work /* Pointer to the working buffer */ +) +{ + UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; + BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; + DSTATUS stat; + DWORD sz_disk, sz_part, s_part; + + + disk_ioctl(pdrv, IOCTL_INIT, &stat); + if (stat & STA_NOINIT) return FR_NOT_READY; + if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; + if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; + + /* Determine the CHS without any care of the drive geometry */ + for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; + if (n == 256) n--; + e_hd = n - 1; + sz_cyl = 63 * n; + tot_cyl = sz_disk / sz_cyl; + + /* Create partition table */ + mem_set(buf, 0, _MAX_SS); + p = buf + MBR_Table; b_cyl = 0; + for (i = 0; i < 4; i++, p += SZ_PTE) { + p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; + if (!p_cyl) continue; + s_part = (DWORD)sz_cyl * b_cyl; + sz_part = (DWORD)sz_cyl * p_cyl; + if (i == 0) { /* Exclude first track of cylinder 0 */ + s_hd = 1; + s_part += 63; sz_part -= 63; + } else { + s_hd = 0; + } + e_cyl = b_cyl + p_cyl - 1; + if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; + + /* Set partition table */ + p[1] = s_hd; /* Start head */ + p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ + p[3] = (BYTE)b_cyl; /* Start cylinder */ + p[4] = 0x06; /* System type (temporary setting) */ + p[5] = e_hd; /* End head */ + p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ + p[7] = (BYTE)e_cyl; /* End cylinder */ + st_dword(p + 8, s_part); /* Start sector in LBA */ + st_dword(p + 12, sz_part); /* Partition size */ + + /* Next partition */ + b_cyl += p_cyl; + } + st_word(p, 0xAA55); + + /* Write it to the MBR */ + return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; +} + +#endif /* _MULTI_PARTITION */ +#endif /* _USE_MKFS && !_FS_READONLY */ diff --git a/user/mpy/lib/oofatfs/ff.h b/user/mpy/lib/oofatfs/ff.h new file mode 100644 index 0000000..068de11 --- /dev/null +++ b/user/mpy/lib/oofatfs/ff.h @@ -0,0 +1,380 @@ +/* This file is part of ooFatFs, a customised version of FatFs + * See https://github.com/micropython/oofatfs for details + */ + +/*----------------------------------------------------------------------------/ +/ FatFs - Generic FAT file system module R0.12b / +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2016, ChaN, all right reserved. +/ +/ FatFs module is an open source software. Redistribution and use of FatFs in +/ source and binary forms, with or without modification, are permitted provided +/ that the following condition is met: + +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/----------------------------------------------------------------------------*/ + + +#ifndef _FATFS +#define _FATFS 68020 /* Revision ID */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* This type MUST be 8-bit */ +typedef uint8_t BYTE; + +/* These types MUST be 16-bit */ +typedef int16_t SHORT; +typedef uint16_t WORD; +typedef uint16_t WCHAR; + +/* These types MUST be 16-bit or 32-bit */ +typedef int INT; +typedef unsigned int UINT; + +/* These types MUST be 32-bit */ +typedef int32_t LONG; +typedef uint32_t DWORD; + +/* This type MUST be 64-bit (Remove this for C89 compatibility) */ +typedef uint64_t QWORD; + +#include FFCONF_H /* FatFs configuration options */ + +#if _FATFS != _FFCONF +#error Wrong configuration file (ffconf.h). +#endif + + + +/* Definitions of volume management */ + +#if _MULTI_PARTITION /* Multiple partition configuration */ +#define LD2PT(fs) (fs->part) /* Get partition index */ +#else /* Single partition configuration */ +#define LD2PT(fs) 0 /* Find first valid partition or in SFD */ +#endif + + + +/* Type of path name strings on FatFs API */ + +#if _LFN_UNICODE /* Unicode (UTF-16) string */ +#if _USE_LFN == 0 +#error _LFN_UNICODE must be 0 at non-LFN cfg. +#endif +#ifndef _INC_TCHAR +typedef WCHAR TCHAR; +#define _T(x) L ## x +#define _TEXT(x) L ## x +#endif +#else /* ANSI/OEM string */ +#ifndef _INC_TCHAR +typedef char TCHAR; +#define _T(x) x +#define _TEXT(x) x +#endif +#endif + + + +/* Type of file size variables */ + +#if _FS_EXFAT +#if _USE_LFN == 0 +#error LFN must be enabled when enable exFAT +#endif +typedef QWORD FSIZE_t; +#else +typedef DWORD FSIZE_t; +#endif + + + +/* File system object structure (FATFS) */ + +typedef struct { + void *drv; // block device underlying this filesystem +#if _MULTI_PARTITION /* Multiple partition configuration */ + BYTE part; // Partition: 0:Auto detect, 1-4:Forced partition +#endif + BYTE fs_type; /* File system type (0:N/A) */ + BYTE n_fats; /* Number of FATs (1 or 2) */ + BYTE wflag; /* win[] flag (b0:dirty) */ + BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ + WORD id; /* File system mount ID */ + WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ + WORD csize; /* Cluster size [sectors] */ +#if _MAX_SS != _MIN_SS + WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */ +#endif +#if _USE_LFN != 0 + WCHAR* lfnbuf; /* LFN working buffer */ +#endif +#if _FS_EXFAT + BYTE* dirbuf; /* Directory entry block scratchpad buffer */ +#endif +#if _FS_REENTRANT + _SYNC_t sobj; /* Identifier of sync object */ +#endif +#if !_FS_READONLY + DWORD last_clst; /* Last allocated cluster */ + DWORD free_clst; /* Number of free clusters */ +#endif +#if _FS_RPATH != 0 + DWORD cdir; /* Current directory start cluster (0:root) */ +#if _FS_EXFAT + DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */ + DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */ + DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */ +#endif +#endif + DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */ + DWORD fsize; /* Size of an FAT [sectors] */ + DWORD volbase; /* Volume base sector */ + DWORD fatbase; /* FAT base sector */ + DWORD dirbase; /* Root directory base sector/cluster */ + DWORD database; /* Data base sector */ + DWORD winsect; /* Current sector appearing in the win[] */ + BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ +} FATFS; + + + +/* Object ID and allocation information (_FDID) */ + +typedef struct { + FATFS* fs; /* Pointer to the owner file system object */ + WORD id; /* Owner file system mount ID */ + BYTE attr; /* Object attribute */ + BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous (no data on FAT), =3:got flagmented, b2:sub-directory stretched) */ + DWORD sclust; /* Object start cluster (0:no cluster or root directory) */ + FSIZE_t objsize; /* Object size (valid when sclust != 0) */ +#if _FS_EXFAT + DWORD n_cont; /* Size of coutiguous part, clusters - 1 (valid when stat == 3) */ + DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */ + DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */ + DWORD c_ofs; /* Offset in the containing directory (valid when sclust != 0) */ +#endif +#if _FS_LOCK != 0 + UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ +#endif +} _FDID; + + + +/* File object structure (FIL) */ + +typedef struct { + _FDID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */ + BYTE flag; /* File status flags */ + BYTE err; /* Abort flag (error code) */ + FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */ + DWORD clust; /* Current cluster of fpter (invalid when fprt is 0) */ + DWORD sect; /* Sector number appearing in buf[] (0:invalid) */ +#if !_FS_READONLY + DWORD dir_sect; /* Sector number containing the directory entry */ + BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ +#endif +#if _USE_FASTSEEK + DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */ +#endif +#if !_FS_TINY + BYTE buf[_MAX_SS]; /* File private data read/write window */ +#endif +} FIL; + + + +/* Directory object structure (FF_DIR) */ + +typedef struct { + _FDID obj; /* Object identifier */ + DWORD dptr; /* Current read/write offset */ + DWORD clust; /* Current cluster */ + DWORD sect; /* Current sector */ + BYTE* dir; /* Pointer to the directory item in the win[] */ + BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */ +#if _USE_LFN != 0 + DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */ +#endif +#if _USE_FIND + const TCHAR* pat; /* Pointer to the name matching pattern */ +#endif +} FF_DIR; + + + +/* File information structure (FILINFO) */ + +typedef struct { + FSIZE_t fsize; /* File size */ + WORD fdate; /* Modified date */ + WORD ftime; /* Modified time */ + BYTE fattrib; /* File attribute */ +#if _USE_LFN != 0 + TCHAR altname[13]; /* Altenative file name */ + TCHAR fname[_MAX_LFN + 1]; /* Primary file name */ +#else + TCHAR fname[13]; /* File name */ +#endif +} FILINFO; + + + +/* File function return code (FRESULT) */ + +typedef enum { + FR_OK = 0, /* (0) Succeeded */ + FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ + FR_INT_ERR, /* (2) Assertion failed */ + FR_NOT_READY, /* (3) The physical drive cannot work */ + FR_NO_FILE, /* (4) Could not find the file */ + FR_NO_PATH, /* (5) Could not find the path */ + FR_INVALID_NAME, /* (6) The path name format is invalid */ + FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ + FR_EXIST, /* (8) Access denied due to prohibited access */ + FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ + FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ + FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ + FR_NOT_ENABLED, /* (12) The volume has no work area */ + FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ + FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */ + FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ + FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ + FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ + FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */ + FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ +} FRESULT; + + + +/*--------------------------------------------------------------*/ +/* FatFs module application interface */ + +FRESULT f_open (FATFS *fs, FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ +FRESULT f_close (FIL* fp); /* Close an open file object */ +FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */ +FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */ +FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ +FRESULT f_truncate (FIL* fp); /* Truncate the file */ +FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */ +FRESULT f_opendir (FATFS *fs, FF_DIR* dp, const TCHAR* path); /* Open a directory */ +FRESULT f_closedir (FF_DIR* dp); /* Close an open directory */ +FRESULT f_readdir (FF_DIR* dp, FILINFO* fno); /* Read a directory item */ +FRESULT f_findfirst (FF_DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ +FRESULT f_findnext (FF_DIR* dp, FILINFO* fno); /* Find next file */ +FRESULT f_mkdir (FATFS *fs, const TCHAR* path); /* Create a sub directory */ +FRESULT f_unlink (FATFS *fs, const TCHAR* path); /* Delete an existing file or directory */ +FRESULT f_rename (FATFS *fs, const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ +FRESULT f_stat (FATFS *fs, const TCHAR* path, FILINFO* fno); /* Get file status */ +FRESULT f_chmod (FATFS *fs, const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */ +FRESULT f_utime (FATFS *fs, const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */ +FRESULT f_chdir (FATFS *fs, const TCHAR* path); /* Change current directory */ +FRESULT f_getcwd (FATFS *fs, TCHAR* buff, UINT len); /* Get current directory */ +FRESULT f_getfree (FATFS *fs, DWORD* nclst); /* Get number of free clusters on the drive */ +FRESULT f_getlabel (FATFS *fs, TCHAR* label, DWORD* vsn); /* Get volume label */ +FRESULT f_setlabel (FATFS *fs, const TCHAR* label); /* Set volume label */ +FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ +FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt); /* Allocate a contiguous block to the file */ +FRESULT f_mount (FATFS* fs); /* Mount/Unmount a logical drive */ +FRESULT f_umount (FATFS* fs); /* Unmount a logical drive */ +FRESULT f_mkfs (FATFS *fs, BYTE opt, DWORD au, void* work, UINT len); /* Create a FAT volume */ +FRESULT f_fdisk (void *pdrv, const DWORD* szt, void* work); /* Divide a physical drive into some partitions */ + +#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize)) +#define f_error(fp) ((fp)->err) +#define f_tell(fp) ((fp)->fptr) +#define f_size(fp) ((fp)->obj.objsize) +#define f_rewind(fp) f_lseek((fp), 0) +#define f_rewinddir(dp) f_readdir((dp), 0) + +#ifndef EOF +#define EOF (-1) +#endif + + + + +/*--------------------------------------------------------------*/ +/* Additional user defined functions */ + +/* RTC function */ +#if !_FS_READONLY && !_FS_NORTC +DWORD get_fattime (void); +#endif + +/* Unicode support functions */ +#if _USE_LFN != 0 /* Unicode - OEM code conversion */ +WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ +WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ +#if _USE_LFN == 3 /* Memory functions */ +void* ff_memalloc (UINT msize); /* Allocate memory block */ +void ff_memfree (void* mblock); /* Free memory block */ +#endif +#endif + +/* Sync functions */ +#if _FS_REENTRANT +int ff_cre_syncobj (FATFS *fatfs, _SYNC_t* sobj); /* Create a sync object */ +int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ +void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ +int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ +#endif + + + + +/*--------------------------------------------------------------*/ +/* Flags and offset address */ + + +/* File access mode and open method flags (3rd argument of f_open) */ +#define FA_READ 0x01 +#define FA_WRITE 0x02 +#define FA_OPEN_EXISTING 0x00 +#define FA_CREATE_NEW 0x04 +#define FA_CREATE_ALWAYS 0x08 +#define FA_OPEN_ALWAYS 0x10 +#define FA_OPEN_APPEND 0x30 + +/* Fast seek controls (2nd argument of f_lseek) */ +#define CREATE_LINKMAP ((FSIZE_t)0 - 1) + +/* Format options (2nd argument of f_mkfs) */ +#define FM_FAT 0x01 +#define FM_FAT32 0x02 +#define FM_EXFAT 0x04 +#define FM_ANY 0x07 +#define FM_SFD 0x08 + +/* Filesystem type (FATFS.fs_type) */ +#define FS_FAT12 1 +#define FS_FAT16 2 +#define FS_FAT32 3 +#define FS_EXFAT 4 + +/* File attribute bits for directory entry (FILINFO.fattrib) */ +#define AM_RDO 0x01 /* Read only */ +#define AM_HID 0x02 /* Hidden */ +#define AM_SYS 0x04 /* System */ +#define AM_DIR 0x10 /* Directory */ +#define AM_ARC 0x20 /* Archive */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _FATFS */ diff --git a/user/mpy/lib/oofatfs/ffconf.h b/user/mpy/lib/oofatfs/ffconf.h new file mode 100644 index 0000000..315101f --- /dev/null +++ b/user/mpy/lib/oofatfs/ffconf.h @@ -0,0 +1,349 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * Original file from: + * FatFs - FAT file system module configuration file R0.12a (C)ChaN, 2016 + * + * The MIT License (MIT) + * + * Copyright (c) 2013-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. + */ + +#include "py/mpconfig.h" + +/*---------------------------------------------------------------------------/ +/ FatFs - FAT file system module configuration file +/---------------------------------------------------------------------------*/ + +#define _FFCONF 68020 /* Revision ID */ + +/*---------------------------------------------------------------------------/ +/ Function Configurations +/---------------------------------------------------------------------------*/ + +#define _FS_READONLY 0 +/* This option switches read-only configuration. (0:Read/Write or 1:Read-only) +/ Read-only configuration removes writing API functions, f_write(), f_sync(), +/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree() +/ and optional writing functions as well. */ + + +#define _FS_MINIMIZE 0 +/* This option defines minimization level to remove some basic API functions. +/ +/ 0: All basic functions are enabled. +/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename() +/ are removed. +/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. +/ 3: f_lseek() function is removed in addition to 2. */ + + +#define _USE_STRFUNC 0 +/* This option switches string functions, f_gets(), f_putc(), f_puts() and +/ f_printf(). +/ +/ 0: Disable string functions. +/ 1: Enable without LF-CRLF conversion. +/ 2: Enable with LF-CRLF conversion. */ + + +#define _USE_FIND 0 +/* This option switches filtered directory read functions, f_findfirst() and +/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ + + +#define _USE_MKFS 1 +/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ + + +#define _USE_FASTSEEK 0 +/* This option switches fast seek function. (0:Disable or 1:Enable) */ + + +#define _USE_EXPAND 0 +/* This option switches f_expand function. (0:Disable or 1:Enable) */ + + +#define _USE_CHMOD 1 +/* This option switches attribute manipulation functions, f_chmod() and f_utime(). +/ (0:Disable or 1:Enable) Also _FS_READONLY needs to be 0 to enable this option. */ + + +#ifdef MICROPY_FATFS_USE_LABEL +#define _USE_LABEL (MICROPY_FATFS_USE_LABEL) +#else +#define _USE_LABEL 0 +#endif +/* This option switches volume label functions, f_getlabel() and f_setlabel(). +/ (0:Disable or 1:Enable) */ + + +#define _USE_FORWARD 0 +/* This option switches f_forward() function. (0:Disable or 1:Enable) */ + + +/*---------------------------------------------------------------------------/ +/ Locale and Namespace Configurations +/---------------------------------------------------------------------------*/ + +#ifdef MICROPY_FATFS_LFN_CODE_PAGE +#define _CODE_PAGE (MICROPY_FATFS_LFN_CODE_PAGE) +#else +#define _CODE_PAGE 1 +#endif +/* This option specifies the OEM code page to be used on the target system. +/ Incorrect setting of the code page can cause a file open failure. +/ +/ 1 - ASCII (No extended character. Non-LFN cfg. only) +/ 437 - U.S. +/ 720 - Arabic +/ 737 - Greek +/ 771 - KBL +/ 775 - Baltic +/ 850 - Latin 1 +/ 852 - Latin 2 +/ 855 - Cyrillic +/ 857 - Turkish +/ 860 - Portuguese +/ 861 - Icelandic +/ 862 - Hebrew +/ 863 - Canadian French +/ 864 - Arabic +/ 865 - Nordic +/ 866 - Russian +/ 869 - Greek 2 +/ 932 - Japanese (DBCS) +/ 936 - Simplified Chinese (DBCS) +/ 949 - Korean (DBCS) +/ 950 - Traditional Chinese (DBCS) +*/ + + +#ifdef MICROPY_FATFS_ENABLE_LFN +#define _USE_LFN (MICROPY_FATFS_ENABLE_LFN) +#else +#define _USE_LFN 0 +#endif +#ifdef MICROPY_FATFS_MAX_LFN +#define _MAX_LFN (MICROPY_FATFS_MAX_LFN) +#else +#define _MAX_LFN 255 +#endif +/* The _USE_LFN switches the support of long file name (LFN). +/ +/ 0: Disable support of LFN. _MAX_LFN has no effect. +/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. +/ 2: Enable LFN with dynamic working buffer on the STACK. +/ 3: Enable LFN with dynamic working buffer on the HEAP. +/ +/ To enable the LFN, Unicode handling functions (option/unicode.c) must be added +/ to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and +/ additional 608 bytes at exFAT enabled. _MAX_LFN can be in range from 12 to 255. +/ It should be set 255 to support full featured LFN operations. +/ When use stack for the working buffer, take care on stack overflow. When use heap +/ memory for the working buffer, memory management functions, ff_memalloc() and +/ ff_memfree(), must be added to the project. */ + + +#define _LFN_UNICODE 0 +/* This option switches character encoding on the API. (0:ANSI/OEM or 1:UTF-16) +/ To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1. +/ This option also affects behavior of string I/O functions. */ + + +#define _STRF_ENCODE 3 +/* When _LFN_UNICODE == 1, this option selects the character encoding ON THE FILE to +/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf(). +/ +/ 0: ANSI/OEM +/ 1: UTF-16LE +/ 2: UTF-16BE +/ 3: UTF-8 +/ +/ This option has no effect when _LFN_UNICODE == 0. */ + + +#ifdef MICROPY_FATFS_RPATH +#define _FS_RPATH (MICROPY_FATFS_RPATH) +#else +#define _FS_RPATH 0 +#endif +/* This option configures support of relative path. +/ +/ 0: Disable relative path and remove related functions. +/ 1: Enable relative path. f_chdir() and f_chdrive() are available. +/ 2: f_getcwd() function is available in addition to 1. +*/ + + +/*---------------------------------------------------------------------------/ +/ Drive/Volume Configurations +/---------------------------------------------------------------------------*/ + +#define _VOLUMES 1 +/* Number of volumes (logical drives) to be used. */ + + +#define _STR_VOLUME_ID 0 +#define _VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" +/* _STR_VOLUME_ID switches string support of volume ID. +/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive +/ number in the path name. _VOLUME_STRS defines the drive ID strings for each +/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for +/ the drive ID strings are: A-Z and 0-9. */ + + +#ifdef MICROPY_FATFS_MULTI_PARTITION +#define _MULTI_PARTITION (MICROPY_FATFS_MULTI_PARTITION) +#else +#define _MULTI_PARTITION 0 +#endif +/* This option switches support of multi-partition on a physical drive. +/ By default (0), each logical drive number is bound to the same physical drive +/ number and only an FAT volume found on the physical drive will be mounted. +/ When multi-partition is enabled (1), each logical drive number can be bound to +/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() +/ funciton will be available. */ + + +#define _MIN_SS 512 +#ifdef MICROPY_FATFS_MAX_SS +#define _MAX_SS (MICROPY_FATFS_MAX_SS) +#else +#define _MAX_SS 512 +#endif +/* These options configure the range of sector size to be supported. (512, 1024, +/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and +/ harddisk. But a larger value may be required for on-board flash memory and some +/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured +/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the +/ disk_ioctl() function. */ + + +#define _USE_TRIM 0 +/* This option switches support of ATA-TRIM. (0:Disable or 1:Enable) +/ To enable Trim function, also CTRL_TRIM command should be implemented to the +/ disk_ioctl() function. */ + + +#define _FS_NOFSINFO 0 +/* If you need to know correct free space on the FAT32 volume, set bit 0 of this +/ option, and f_getfree() function at first time after volume mount will force +/ a full FAT scan. Bit 1 controls the use of last allocated cluster number. +/ +/ bit0=0: Use free cluster count in the FSINFO if available. +/ bit0=1: Do not trust free cluster count in the FSINFO. +/ bit1=0: Use last allocated cluster number in the FSINFO if available. +/ bit1=1: Do not trust last allocated cluster number in the FSINFO. +*/ + + + +/*---------------------------------------------------------------------------/ +/ System Configurations +/---------------------------------------------------------------------------*/ + +#define _FS_TINY 1 +/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) +/ At the tiny configuration, size of file object (FIL) is reduced _MAX_SS bytes. +/ Instead of private sector buffer eliminated from the file object, common sector +/ buffer in the file system object (FATFS) is used for the file data transfer. */ + + +#ifdef MICROPY_FATFS_EXFAT +#define _FS_EXFAT (MICROPY_FATFS_EXFAT) +#else +#define _FS_EXFAT 0 +#endif +/* This option switches support of exFAT file system. (0:Disable or 1:Enable) +/ When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1) +/ Note that enabling exFAT discards C89 compatibility. */ + + +#ifdef MICROPY_FATFS_NORTC +#define _FS_NORTC (MICROPY_FATFS_NORTC) +#else +#define _FS_NORTC 0 +#endif +#define _NORTC_MON 1 +#define _NORTC_MDAY 1 +#define _NORTC_YEAR 2016 +/* The option _FS_NORTC switches timestamp functiton. If the system does not have +/ any RTC function or valid timestamp is not needed, set _FS_NORTC = 1 to disable +/ the timestamp function. All objects modified by FatFs will have a fixed timestamp +/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time. +/ To enable timestamp function (_FS_NORTC = 0), get_fattime() function need to be +/ added to the project to get current time form real-time clock. _NORTC_MON, +/ _NORTC_MDAY and _NORTC_YEAR have no effect. +/ These options have no effect at read-only configuration (_FS_READONLY = 1). */ + + +#define _FS_LOCK 0 +/* The option _FS_LOCK switches file lock function to control duplicated file open +/ and illegal operation to open objects. This option must be 0 when _FS_READONLY +/ is 1. +/ +/ 0: Disable file lock function. To avoid volume corruption, application program +/ should avoid illegal open, remove and rename to the open objects. +/ >0: Enable file lock function. The value defines how many files/sub-directories +/ can be opened simultaneously under file lock control. Note that the file +/ lock control is independent of re-entrancy. */ + + +#ifdef MICROPY_FATFS_REENTRANT +#define _FS_REENTRANT (MICROPY_FATFS_REENTRANT) +#else +#define _FS_REENTRANT 0 +#endif + +// milliseconds +#ifdef MICROPY_FATFS_TIMEOUT +#define _FS_TIMEOUT (MICROPY_FATFS_TIMEOUT) +#else +#define _FS_TIMEOUT 1000 +#endif + +#ifdef MICROPY_FATFS_SYNC_T +#define _SYNC_t MICROPY_FATFS_SYNC_T +#else +#define _SYNC_t HANDLE +#endif +/* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs +/ module itself. Note that regardless of this option, file access to different +/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs() +/ and f_fdisk() function, are always not re-entrant. Only file/directory access +/ to the same volume is under control of this function. +/ +/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect. +/ 1: Enable re-entrancy. Also user provided synchronization handlers, +/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() +/ function, must be added to the project. Samples are available in +/ option/syscall.c. +/ +/ The _FS_TIMEOUT defines timeout period in unit of time tick. +/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, +/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be +/ included somewhere in the scope of ff.h. */ + +/* #include // O/S definitions */ + + +/*--- End of configuration options ---*/ diff --git a/user/mpy/lib/oofatfs/option/ccsbcs.c b/user/mpy/lib/oofatfs/option/ccsbcs.c new file mode 100644 index 0000000..fdded96 --- /dev/null +++ b/user/mpy/lib/oofatfs/option/ccsbcs.c @@ -0,0 +1,388 @@ +/*------------------------------------------------------------------------*/ +/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ +/* (SBCS code pages) */ +/*------------------------------------------------------------------------*/ +/* 437 U.S. +/ 720 Arabic +/ 737 Greek +/ 771 KBL +/ 775 Baltic +/ 850 Latin 1 +/ 852 Latin 2 +/ 855 Cyrillic +/ 857 Turkish +/ 860 Portuguese +/ 861 Icelandic +/ 862 Hebrew +/ 863 Canadian French +/ 864 Arabic +/ 865 Nordic +/ 866 Russian +/ 869 Greek 2 +*/ + +#include "../ff.h" + + +#if _CODE_PAGE == 437 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, + 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 720 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ + 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, + 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, + 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 737 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ + 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, + 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, + 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, + 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 771 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, + 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 775 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ + 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, + 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, + 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, + 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, + 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 850 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, + 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, + 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, + 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, + 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 852 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, + 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, + 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, + 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, + 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 855 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ + 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, + 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, + 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, + 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, + 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, + 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 857 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, + 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, + 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, + 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, + 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 860 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, + 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 861 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, + 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 862 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ + 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, + 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 863 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, + 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, + 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 864 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ + 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, + 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, + 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, + 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, + 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, + 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, + 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, + 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 +}; + +#elif _CODE_PAGE == 865 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, + 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 866 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, + 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 +}; + +#elif _CODE_PAGE == 869 +#define _TBLDEF 1 +static +const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ + 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, + 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, + 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, + 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, + 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, + 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 +}; + +#endif + + +#if !_TBLDEF || !_USE_LFN +#error This file is not needed at current configuration. Remove from the project. +#endif + + + + +WCHAR ff_convert ( /* Converted character, Returns zero on error */ + WCHAR chr, /* Character code to be converted */ + UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ +) +{ + WCHAR c; + + + if (chr < 0x80) { /* ASCII */ + c = chr; + + } else { + if (dir) { /* OEM code to Unicode */ + c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; + + } else { /* Unicode to OEM code */ + for (c = 0; c < 0x80; c++) { + if (chr == Tbl[c]) break; + } + c = (c + 0x80) & 0xFF; + } + } + + return c; +} + + + +WCHAR ff_wtoupper ( /* Returns upper converted character */ + WCHAR chr /* Unicode character to be upper converted (BMP only) */ +) +{ + /* Compressed upper conversion table */ + static const WCHAR cvt1[] = { /* U+0000 - U+0FFF */ + /* Basic Latin */ + 0x0061,0x031A, + /* Latin-1 Supplement */ + 0x00E0,0x0317, 0x00F8,0x0307, 0x00FF,0x0001,0x0178, + /* Latin Extended-A */ + 0x0100,0x0130, 0x0132,0x0106, 0x0139,0x0110, 0x014A,0x012E, 0x0179,0x0106, + /* Latin Extended-B */ + 0x0180,0x004D,0x0243,0x0181,0x0182,0x0182,0x0184,0x0184,0x0186,0x0187,0x0187,0x0189,0x018A,0x018B,0x018B,0x018D,0x018E,0x018F,0x0190,0x0191,0x0191,0x0193,0x0194,0x01F6,0x0196,0x0197,0x0198,0x0198,0x023D,0x019B,0x019C,0x019D,0x0220,0x019F,0x01A0,0x01A0,0x01A2,0x01A2,0x01A4,0x01A4,0x01A6,0x01A7,0x01A7,0x01A9,0x01AA,0x01AB,0x01AC,0x01AC,0x01AE,0x01AF,0x01AF,0x01B1,0x01B2,0x01B3,0x01B3,0x01B5,0x01B5,0x01B7,0x01B8,0x01B8,0x01BA,0x01BB,0x01BC,0x01BC,0x01BE,0x01F7,0x01C0,0x01C1,0x01C2,0x01C3,0x01C4,0x01C5,0x01C4,0x01C7,0x01C8,0x01C7,0x01CA,0x01CB,0x01CA, + 0x01CD,0x0110, 0x01DD,0x0001,0x018E, 0x01DE,0x0112, 0x01F3,0x0003,0x01F1,0x01F4,0x01F4, 0x01F8,0x0128, + 0x0222,0x0112, 0x023A,0x0009,0x2C65,0x023B,0x023B,0x023D,0x2C66,0x023F,0x0240,0x0241,0x0241, 0x0246,0x010A, + /* IPA Extensions */ + 0x0253,0x0040,0x0181,0x0186,0x0255,0x0189,0x018A,0x0258,0x018F,0x025A,0x0190,0x025C,0x025D,0x025E,0x025F,0x0193,0x0261,0x0262,0x0194,0x0264,0x0265,0x0266,0x0267,0x0197,0x0196,0x026A,0x2C62,0x026C,0x026D,0x026E,0x019C,0x0270,0x0271,0x019D,0x0273,0x0274,0x019F,0x0276,0x0277,0x0278,0x0279,0x027A,0x027B,0x027C,0x2C64,0x027E,0x027F,0x01A6,0x0281,0x0282,0x01A9,0x0284,0x0285,0x0286,0x0287,0x01AE,0x0244,0x01B1,0x01B2,0x0245,0x028D,0x028E,0x028F,0x0290,0x0291,0x01B7, + /* Greek, Coptic */ + 0x037B,0x0003,0x03FD,0x03FE,0x03FF, 0x03AC,0x0004,0x0386,0x0388,0x0389,0x038A, 0x03B1,0x0311, + 0x03C2,0x0002,0x03A3,0x03A3, 0x03C4,0x0308, 0x03CC,0x0003,0x038C,0x038E,0x038F, 0x03D8,0x0118, + 0x03F2,0x000A,0x03F9,0x03F3,0x03F4,0x03F5,0x03F6,0x03F7,0x03F7,0x03F9,0x03FA,0x03FA, + /* Cyrillic */ + 0x0430,0x0320, 0x0450,0x0710, 0x0460,0x0122, 0x048A,0x0136, 0x04C1,0x010E, 0x04CF,0x0001,0x04C0, 0x04D0,0x0144, + /* Armenian */ + 0x0561,0x0426, + + 0x0000 + }; + static const WCHAR cvt2[] = { /* U+1000 - U+FFFF */ + /* Phonetic Extensions */ + 0x1D7D,0x0001,0x2C63, + /* Latin Extended Additional */ + 0x1E00,0x0196, 0x1EA0,0x015A, + /* Greek Extended */ + 0x1F00,0x0608, 0x1F10,0x0606, 0x1F20,0x0608, 0x1F30,0x0608, 0x1F40,0x0606, + 0x1F51,0x0007,0x1F59,0x1F52,0x1F5B,0x1F54,0x1F5D,0x1F56,0x1F5F, 0x1F60,0x0608, + 0x1F70,0x000E,0x1FBA,0x1FBB,0x1FC8,0x1FC9,0x1FCA,0x1FCB,0x1FDA,0x1FDB,0x1FF8,0x1FF9,0x1FEA,0x1FEB,0x1FFA,0x1FFB, + 0x1F80,0x0608, 0x1F90,0x0608, 0x1FA0,0x0608, 0x1FB0,0x0004,0x1FB8,0x1FB9,0x1FB2,0x1FBC, + 0x1FCC,0x0001,0x1FC3, 0x1FD0,0x0602, 0x1FE0,0x0602, 0x1FE5,0x0001,0x1FEC, 0x1FF2,0x0001,0x1FFC, + /* Letterlike Symbols */ + 0x214E,0x0001,0x2132, + /* Number forms */ + 0x2170,0x0210, 0x2184,0x0001,0x2183, + /* Enclosed Alphanumerics */ + 0x24D0,0x051A, 0x2C30,0x042F, + /* Latin Extended-C */ + 0x2C60,0x0102, 0x2C67,0x0106, 0x2C75,0x0102, + /* Coptic */ + 0x2C80,0x0164, + /* Georgian Supplement */ + 0x2D00,0x0826, + /* Full-width */ + 0xFF41,0x031A, + + 0x0000 + }; + const WCHAR *p; + WCHAR bc, nc, cmd; + + + p = chr < 0x1000 ? cvt1 : cvt2; + for (;;) { + bc = *p++; /* Get block base */ + if (!bc || chr < bc) break; + nc = *p++; cmd = nc >> 8; nc &= 0xFF; /* Get processing command and block size */ + if (chr < bc + nc) { /* In the block? */ + switch (cmd) { + case 0: chr = p[chr - bc]; break; /* Table conversion */ + case 1: chr -= (chr - bc) & 1; break; /* Case pairs */ + case 2: chr -= 16; break; /* Shift -16 */ + case 3: chr -= 32; break; /* Shift -32 */ + case 4: chr -= 48; break; /* Shift -48 */ + case 5: chr -= 26; break; /* Shift -26 */ + case 6: chr += 8; break; /* Shift +8 */ + case 7: chr -= 80; break; /* Shift -80 */ + case 8: chr -= 0x1C60; break; /* Shift -0x1C60 */ + } + break; + } + if (!cmd) p += nc; + } + + return chr; +} + diff --git a/user/mpy/lib/oofatfs/option/unicode.c b/user/mpy/lib/oofatfs/option/unicode.c new file mode 100644 index 0000000..e48d09c --- /dev/null +++ b/user/mpy/lib/oofatfs/option/unicode.c @@ -0,0 +1,17 @@ +#include "../ff.h" + +#if _USE_LFN != 0 + +#if _CODE_PAGE == 932 /* Japanese Shift_JIS */ +#include "cc932.c" +#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ +#include "cc936.c" +#elif _CODE_PAGE == 949 /* Korean */ +#include "cc949.c" +#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ +#include "cc950.c" +#else /* Single Byte Character-Set */ +#include "ccsbcs.c" +#endif + +#endif diff --git a/user/mpy/lib/timeutils/timeutils.c b/user/mpy/lib/timeutils/timeutils.c new file mode 100644 index 0000000..eb3dc80 --- /dev/null +++ b/user/mpy/lib/timeutils/timeutils.c @@ -0,0 +1,215 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2015 Daniel Campora + * + * 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. + */ + +#include "py/obj.h" + +#include "lib/timeutils/timeutils.h" + +// LEAPOCH corresponds to 2000-03-01, which is a mod-400 year, immediately +// after Feb 29. We calculate seconds as a signed integer relative to that. +// +// Our timebase is relative to 2000-01-01. + +#define LEAPOCH ((31 + 29) * 86400) + +#define DAYS_PER_400Y (365*400 + 97) +#define DAYS_PER_100Y (365*100 + 24) +#define DAYS_PER_4Y (365*4 + 1) + +STATIC const uint16_t days_since_jan1[]= { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; + +bool timeutils_is_leap_year(mp_uint_t year) { + return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; +} + +// month is one based +mp_uint_t timeutils_days_in_month(mp_uint_t year, mp_uint_t month) { + mp_uint_t mdays = days_since_jan1[month] - days_since_jan1[month - 1]; + if (month == 2 && timeutils_is_leap_year(year)) { + mdays++; + } + return mdays; +} + +// compute the day of the year, between 1 and 366 +// month should be between 1 and 12, date should start at 1 +mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t date) { + mp_uint_t yday = days_since_jan1[month - 1] + date; + if (month >= 3 && timeutils_is_leap_year(year)) { + yday += 1; + } + return yday; +} + +void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, timeutils_struct_time_t *tm) { + // The following algorithm was adapted from musl's __secs_to_tm and adapted + // for differences in MicroPython's timebase. + + mp_int_t seconds = t - LEAPOCH; + + mp_int_t days = seconds / 86400; + seconds %= 86400; + if (seconds < 0) { + seconds += 86400; + days -= 1; + } + tm->tm_hour = seconds / 3600; + tm->tm_min = seconds / 60 % 60; + tm->tm_sec = seconds % 60; + + mp_int_t wday = (days + 2) % 7; // Mar 1, 2000 was a Wednesday (2) + if (wday < 0) { + wday += 7; + } + tm->tm_wday = wday; + + mp_int_t qc_cycles = days / DAYS_PER_400Y; + days %= DAYS_PER_400Y; + if (days < 0) { + days += DAYS_PER_400Y; + qc_cycles--; + } + mp_int_t c_cycles = days / DAYS_PER_100Y; + if (c_cycles == 4) { + c_cycles--; + } + days -= (c_cycles * DAYS_PER_100Y); + + mp_int_t q_cycles = days / DAYS_PER_4Y; + if (q_cycles == 25) { + q_cycles--; + } + days -= q_cycles * DAYS_PER_4Y; + + mp_int_t years = days / 365; + if (years == 4) { + years--; + } + days -= (years * 365); + + /* We will compute tm_yday at the very end + mp_int_t leap = !years && (q_cycles || !c_cycles); + + tm->tm_yday = days + 31 + 28 + leap; + if (tm->tm_yday >= 365 + leap) { + tm->tm_yday -= 365 + leap; + } + + tm->tm_yday++; // Make one based + */ + + tm->tm_year = 2000 + years + 4 * q_cycles + 100 * c_cycles + 400 * qc_cycles; + + // Note: days_in_month[0] corresponds to March + STATIC const int8_t days_in_month[] = {31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29}; + + mp_int_t month; + for (month = 0; days_in_month[month] <= days; month++) { + days -= days_in_month[month]; + } + + tm->tm_mon = month + 2; + if (tm->tm_mon >= 12) { + tm->tm_mon -= 12; + tm->tm_year++; + } + tm->tm_mday = days + 1; // Make one based + tm->tm_mon++; // Make one based + + tm->tm_yday = timeutils_year_day(tm->tm_year, tm->tm_mon, tm->tm_mday); +} + +// returns the number of seconds, as an integer, since 2000-01-01 +mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month, + mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second) { + return + second + + minute * 60 + + hour * 3600 + + (timeutils_year_day(year, month, date) - 1 + + ((year - 2000 + 3) / 4) // add a day each 4 years starting with 2001 + - ((year - 2000 + 99) / 100) // subtract a day each 100 years starting with 2001 + + ((year - 2000 + 399) / 400) // add a day each 400 years starting with 2001 + ) * 86400 + + (year - 2000) * 31536000; +} + +mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, + mp_int_t hours, mp_int_t minutes, mp_int_t seconds) { + + // Normalize the tuple. This allows things like: + // + // tm_tomorrow = list(time.localtime()) + // tm_tomorrow[2] += 1 # Adds 1 to mday + // tomorrow = time.mktime(tm_tomorrow) + // + // And not have to worry about all the weird overflows. + // + // You can subtract dates/times this way as well. + + minutes += seconds / 60; + if ((seconds = seconds % 60) < 0) { + seconds += 60; + minutes--; + } + + hours += minutes / 60; + if ((minutes = minutes % 60) < 0) { + minutes += 60; + hours--; + } + + mday += hours / 24; + if ((hours = hours % 24) < 0) { + hours += 24; + mday--; + } + + month--; // make month zero based + year += month / 12; + if ((month = month % 12) < 0) { + month += 12; + year--; + } + month++; // back to one based + + while (mday < 1) { + if (--month == 0) { + month = 12; + year--; + } + mday += timeutils_days_in_month(year, month); + } + while ((mp_uint_t)mday > timeutils_days_in_month(year, month)) { + mday -= timeutils_days_in_month(year, month); + if (++month == 13) { + month = 1; + year++; + } + } + return timeutils_seconds_since_2000(year, month, mday, hours, minutes, seconds); +} diff --git a/user/mpy/lib/timeutils/timeutils.h b/user/mpy/lib/timeutils/timeutils.h new file mode 100644 index 0000000..9b1abeb --- /dev/null +++ b/user/mpy/lib/timeutils/timeutils.h @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2015 Daniel Campora + * + * 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_LIB_TIMEUTILS_TIMEUTILS_H +#define MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H + +typedef struct _timeutils_struct_time_t { + uint16_t tm_year; // i.e. 2014 + uint8_t tm_mon; // 1..12 + uint8_t tm_mday; // 1..31 + uint8_t tm_hour; // 0..23 + uint8_t tm_min; // 0..59 + uint8_t tm_sec; // 0..59 + uint8_t tm_wday; // 0..6 0 = Monday + uint16_t tm_yday; // 1..366 +} timeutils_struct_time_t; + +bool timeutils_is_leap_year(mp_uint_t year); +mp_uint_t timeutils_days_in_month(mp_uint_t year, mp_uint_t month); +mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t date); + +void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, + timeutils_struct_time_t *tm); + +mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month, + mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second); + +mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, + mp_int_t hours, mp_int_t minutes, mp_int_t seconds); + +#endif // MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H diff --git a/user/mpy/lib/utils/interrupt_char.c b/user/mpy/lib/utils/interrupt_char.c new file mode 100644 index 0000000..fca0f95 --- /dev/null +++ b/user/mpy/lib/utils/interrupt_char.c @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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. + */ + +#include "py/obj.h" +#include "py/mpstate.h" + +#if MICROPY_KBD_EXCEPTION + +int mp_interrupt_char; + +void mp_hal_set_interrupt_char(int c) { + if (c != -1) { + mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); + } + mp_interrupt_char = c; +} + +void mp_keyboard_interrupt(void) { + MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)); + #if MICROPY_ENABLE_SCHEDULER + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } + #endif +} + +#endif diff --git a/user/mpy/lib/utils/interrupt_char.h b/user/mpy/lib/utils/interrupt_char.h new file mode 100644 index 0000000..ca50d4d --- /dev/null +++ b/user/mpy/lib/utils/interrupt_char.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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_LIB_UTILS_INTERRUPT_CHAR_H +#define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H + +extern int mp_interrupt_char; +void mp_hal_set_interrupt_char(int c); +void mp_keyboard_interrupt(void); + +#endif // MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H diff --git a/user/mpy/lib/utils/printf.c b/user/mpy/lib/utils/printf.c new file mode 100644 index 0000000..51dfa5b --- /dev/null +++ b/user/mpy/lib/utils/printf.c @@ -0,0 +1,135 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" + +#if MICROPY_USE_INTERNAL_PRINTF + +#include +#include +#include + +#include "py/obj.h" +#include "py/mphal.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include "py/formatfloat.h" +#endif + +#undef putchar // Some stdlibs have a #define for putchar +int printf(const char *fmt, ...); +int vprintf(const char *fmt, va_list ap); +int putchar(int c); +int puts(const char *s); +int vsnprintf(char *str, size_t size, const char *fmt, va_list ap); +int snprintf(char *str, size_t size, const char *fmt, ...); + +int printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = mp_vprintf(&mp_plat_print, fmt, ap); + va_end(ap); + return ret; +} + +int vprintf(const char *fmt, va_list ap) { + return mp_vprintf(&mp_plat_print, fmt, ap); +} + +#if MICROPY_DEBUG_PRINTERS +int DEBUG_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + #ifndef MICROPY_DEBUG_PRINTER_DEST + #define MICROPY_DEBUG_PRINTER_DEST mp_plat_print + #endif + extern const mp_print_t MICROPY_DEBUG_PRINTER_DEST; + int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap); + va_end(ap); + return ret; +} +#endif + +// need this because gcc optimises printf("%c", c) -> putchar(c), and printf("a") -> putchar('a') +int putchar(int c) { + char chr = c; + mp_hal_stdout_tx_strn_cooked(&chr, 1); + return chr; +} + +// need this because gcc optimises printf("string\n") -> puts("string") +int puts(const char *s) { + mp_hal_stdout_tx_strn_cooked(s, strlen(s)); + char chr = '\n'; + mp_hal_stdout_tx_strn_cooked(&chr, 1); + return 1; +} + +typedef struct _strn_print_env_t { + char *cur; + size_t remain; +} strn_print_env_t; + +STATIC void strn_print_strn(void *data, const char *str, size_t len) { + strn_print_env_t *strn_print_env = data; + if (len > strn_print_env->remain) { + len = strn_print_env->remain; + } + memcpy(strn_print_env->cur, str, len); + strn_print_env->cur += len; + strn_print_env->remain -= len; +} + +#if defined(__GNUC__) && !defined(__clang__) +// uClibc requires this alias to be defined, or there may be link errors +// when linkings against it statically. +int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias ("vsnprintf"))); +#endif + +int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { + strn_print_env_t strn_print_env = {str, size}; + mp_print_t print = {&strn_print_env, strn_print_strn}; + int len = mp_vprintf(&print, fmt, ap); + // add terminating null byte + if (size > 0) { + if (strn_print_env.remain == 0) { + strn_print_env.cur[-1] = 0; + } else { + strn_print_env.cur[0] = 0; + } + } + return len; +} + +int snprintf(char *str, size_t size, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = vsnprintf(str, size, fmt, ap); + va_end(ap); + return ret; +} + +#endif //MICROPY_USE_INTERNAL_PRINTF diff --git a/user/mpy/lib/utils/pyexec.c b/user/mpy/lib/utils/pyexec.c new file mode 100644 index 0000000..d3500b4 --- /dev/null +++ b/user/mpy/lib/utils/pyexec.c @@ -0,0 +1,531 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/nlr.h" +#include "py/compile.h" +#include "py/runtime.h" +#include "py/repl.h" +#include "py/gc.h" +#include "py/frozenmod.h" +#include "py/mphal.h" +#if defined(USE_DEVICE_MODE) +#include "irq.h" +#include "usb.h" +#endif +#include "lib/mp-readline/readline.h" +#include "lib/utils/pyexec.h" +#include "genhdr/mpversion.h" + +pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; +int pyexec_system_exit = 0; +STATIC bool repl_display_debugging_info = 0; + +#define EXEC_FLAG_PRINT_EOF (1) +#define EXEC_FLAG_ALLOW_DEBUGGING (2) +#define EXEC_FLAG_IS_REPL (4) +#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) +#define EXEC_FLAG_SOURCE_IS_VSTR (16) +#define EXEC_FLAG_SOURCE_IS_FILENAME (32) + +// parses, compiles and executes the code in the lexer +// frees the lexer before returning +// EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output +// EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code +// EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile) +STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, int exec_flags) { + int ret = 0; + uint32_t start = 0; + + // by default a SystemExit exception returns 0 + pyexec_system_exit = 0; + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t module_fun; + #if MICROPY_MODULE_FROZEN_MPY + if (exec_flags & EXEC_FLAG_SOURCE_IS_RAW_CODE) { + // source is a raw_code object, create the function + module_fun = mp_make_function_from_raw_code(source, MP_OBJ_NULL, MP_OBJ_NULL); + } else + #endif + { + #if MICROPY_ENABLE_COMPILER + mp_lexer_t *lex; + if (exec_flags & EXEC_FLAG_SOURCE_IS_VSTR) { + const vstr_t *vstr = source; + lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr->buf, vstr->len, 0); + } else if (exec_flags & EXEC_FLAG_SOURCE_IS_FILENAME) { + lex = mp_lexer_new_from_file(source); + } else { + lex = (mp_lexer_t*)source; + } + // source is a lexer, parse and compile the script + qstr source_name = lex->source_name; + mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); + module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL); + #else + mp_raise_msg(&mp_type_RuntimeError, "script compilation not supported"); + #endif + } + + // execute code + mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us + start = mp_hal_ticks_ms(); + mp_call_function_0(module_fun); + mp_hal_set_interrupt_char(-1); // disable interrupt + nlr_pop(); + ret = 1; + if (exec_flags & EXEC_FLAG_PRINT_EOF) { + mp_hal_stdout_tx_strn("\x04", 1); + } + } else { + // uncaught exception + // FIXME it could be that an interrupt happens just before we disable it here + mp_hal_set_interrupt_char(-1); // disable interrupt + // print EOF after normal output + if (exec_flags & EXEC_FLAG_PRINT_EOF) { + mp_hal_stdout_tx_strn("\x04", 1); + } + // check for SystemExit + if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) { + // at the moment, the value of SystemExit is unused + ret = pyexec_system_exit; + } else { + mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); + ret = 0; + } + } + + // display debugging info if wanted + if ((exec_flags & EXEC_FLAG_ALLOW_DEBUGGING) && repl_display_debugging_info) { + mp_uint_t ticks = mp_hal_ticks_ms() - start; // TODO implement a function that does this properly + printf("took " UINT_FMT " ms\n", ticks); + // qstr info + { + size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; + qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); + printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n " + "n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", + (unsigned)n_pool, (unsigned)n_qstr, (unsigned)n_str_data_bytes, (unsigned)n_total_bytes); + } + + #if MICROPY_ENABLE_GC + // run collection and print GC info + gc_collect(); + gc_dump_info(); + #endif + } + + if (exec_flags & EXEC_FLAG_PRINT_EOF) { + mp_hal_stdout_tx_strn("\x04", 1); + } + + return ret; +} + +#if MICROPY_ENABLE_COMPILER +#if MICROPY_REPL_EVENT_DRIVEN + +typedef struct _repl_t { + // This structure originally also held current REPL line, + // but it was moved to MP_STATE_VM(repl_line) as containing + // root pointer. Still keep structure in case more state + // will be added later. + //vstr_t line; + bool cont_line; +} repl_t; + +repl_t repl; + +STATIC int pyexec_raw_repl_process_char(int c); +STATIC int pyexec_friendly_repl_process_char(int c); + +void pyexec_event_repl_init(void) { + MP_STATE_VM(repl_line) = vstr_new(32); + repl.cont_line = false; + // no prompt before printing friendly REPL banner or entering raw REPL + readline_init(MP_STATE_VM(repl_line), ""); + if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { + pyexec_raw_repl_process_char(CHAR_CTRL_A); + } else { + pyexec_friendly_repl_process_char(CHAR_CTRL_B); + } +} + +STATIC int pyexec_raw_repl_process_char(int c) { + if (c == CHAR_CTRL_A) { + // reset raw REPL + mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n"); + goto reset; + } else if (c == CHAR_CTRL_B) { + // change to friendly REPL + pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; + vstr_reset(MP_STATE_VM(repl_line)); + repl.cont_line = false; + pyexec_friendly_repl_process_char(CHAR_CTRL_B); + return 0; + } else if (c == CHAR_CTRL_C) { + // clear line + vstr_reset(MP_STATE_VM(repl_line)); + return 0; + } else if (c == CHAR_CTRL_D) { + // input finished + } else { + // let through any other raw 8-bit value + vstr_add_byte(MP_STATE_VM(repl_line), c); + return 0; + } + + // indicate reception of command + mp_hal_stdout_tx_str("OK"); + + if (MP_STATE_VM(repl_line)->len == 0) { + // exit for a soft reset + mp_hal_stdout_tx_str("\r\n"); + vstr_clear(MP_STATE_VM(repl_line)); + return PYEXEC_FORCED_EXIT; + } + + int ret = parse_compile_execute(MP_STATE_VM(repl_line), MP_PARSE_FILE_INPUT, EXEC_FLAG_PRINT_EOF | EXEC_FLAG_SOURCE_IS_VSTR); + if (ret & PYEXEC_FORCED_EXIT) { + return ret; + } + +reset: + vstr_reset(MP_STATE_VM(repl_line)); + mp_hal_stdout_tx_str(">"); + + return 0; +} + +STATIC int pyexec_friendly_repl_process_char(int c) { + int ret = readline_process_char(c); + + if (!repl.cont_line) { + + if (ret == CHAR_CTRL_A) { + // change to raw REPL + pyexec_mode_kind = PYEXEC_MODE_RAW_REPL; + mp_hal_stdout_tx_str("\r\n"); + pyexec_raw_repl_process_char(CHAR_CTRL_A); + return 0; + } else if (ret == CHAR_CTRL_B) { + // reset friendly REPL + mp_hal_stdout_tx_str("\r\n"); + mp_hal_stdout_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n"); + #if MICROPY_PY_BUILTINS_HELP + mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n"); + #endif + goto input_restart; + } else if (ret == CHAR_CTRL_C) { + // break + mp_hal_stdout_tx_str("\r\n"); + goto input_restart; + } else if (ret == CHAR_CTRL_D) { + // exit for a soft reset + mp_hal_stdout_tx_str("\r\n"); + vstr_clear(MP_STATE_VM(repl_line)); + return PYEXEC_FORCED_EXIT; + } + + if (ret < 0) { + return 0; + } + + if (!mp_repl_continue_with_input(vstr_null_terminated_str(MP_STATE_VM(repl_line)))) { + goto exec; + } + + vstr_add_byte(MP_STATE_VM(repl_line), '\n'); + repl.cont_line = true; + readline_note_newline("... "); + return 0; + + } else { + + if (ret == CHAR_CTRL_C) { + // cancel everything + mp_hal_stdout_tx_str("\r\n"); + repl.cont_line = false; + goto input_restart; + } else if (ret == CHAR_CTRL_D) { + // stop entering compound statement + goto exec; + } + + if (ret < 0) { + return 0; + } + + if (mp_repl_continue_with_input(vstr_null_terminated_str(MP_STATE_VM(repl_line)))) { + vstr_add_byte(MP_STATE_VM(repl_line), '\n'); + readline_note_newline("... "); + return 0; + } + +exec: ; + int ret = parse_compile_execute(MP_STATE_VM(repl_line), MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL | EXEC_FLAG_SOURCE_IS_VSTR); + if (ret & PYEXEC_FORCED_EXIT) { + return ret; + } + +input_restart: + vstr_reset(MP_STATE_VM(repl_line)); + repl.cont_line = false; + readline_init(MP_STATE_VM(repl_line), ">>> "); + return 0; + } +} + +uint8_t pyexec_repl_active; +int pyexec_event_repl_process_char(int c) { + pyexec_repl_active = 1; + int res; + if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { + res = pyexec_raw_repl_process_char(c); + } else { + res = pyexec_friendly_repl_process_char(c); + } + pyexec_repl_active = 0; + return res; +} + +#else // MICROPY_REPL_EVENT_DRIVEN + +int pyexec_raw_repl(void) { + vstr_t line; + vstr_init(&line, 32); + +raw_repl_reset: + mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n"); + + for (;;) { + vstr_reset(&line); + mp_hal_stdout_tx_str(">"); + for (;;) { + int c = mp_hal_stdin_rx_chr(); + if (c == CHAR_CTRL_A) { + // reset raw REPL + goto raw_repl_reset; + } else if (c == CHAR_CTRL_B) { + // change to friendly REPL + mp_hal_stdout_tx_str("\r\n"); + vstr_clear(&line); + pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; + return 0; + } else if (c == CHAR_CTRL_C) { + // clear line + vstr_reset(&line); + } else if (c == CHAR_CTRL_D) { + // input finished + break; + } else { + // let through any other raw 8-bit value + vstr_add_byte(&line, c); + } + } + + // indicate reception of command + mp_hal_stdout_tx_str("OK"); + + if (line.len == 0) { + // exit for a soft reset + mp_hal_stdout_tx_str("\r\n"); + vstr_clear(&line); + return PYEXEC_FORCED_EXIT; + } + + int ret = parse_compile_execute(&line, MP_PARSE_FILE_INPUT, EXEC_FLAG_PRINT_EOF | EXEC_FLAG_SOURCE_IS_VSTR); + if (ret & PYEXEC_FORCED_EXIT) { + return ret; + } + } +} + +int pyexec_friendly_repl(void) { + vstr_t line; + vstr_init(&line, 32); + +#if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD + // in host mode, we enable the LCD for the repl + mp_obj_t lcd_o = mp_call_function_0(mp_load_name(qstr_from_str("LCD"))); + mp_call_function_1(mp_load_attr(lcd_o, qstr_from_str("light")), mp_const_true); +#endif + +friendly_repl_reset: + mp_hal_stdout_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n"); + #if MICROPY_PY_BUILTINS_HELP + mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n"); + #endif + + // to test ctrl-C + /* + { + uint32_t x[4] = {0x424242, 0xdeaddead, 0x242424, 0xdeadbeef}; + for (;;) { + nlr_buf_t nlr; + printf("pyexec_repl: %p\n", x); + mp_hal_set_interrupt_char(CHAR_CTRL_C); + if (nlr_push(&nlr) == 0) { + for (;;) { + } + } else { + printf("break\n"); + } + } + } + */ + + for (;;) { + input_restart: + + #if defined(USE_DEVICE_MODE) + if (usb_vcp_is_enabled()) { + // If the user gets to here and interrupts are disabled then + // they'll never see the prompt, traceback etc. The USB REPL needs + // interrupts to be enabled or no transfers occur. So we try to + // do the user a favor and reenable interrupts. + if (query_irq() == IRQ_STATE_DISABLED) { + enable_irq(IRQ_STATE_ENABLED); + mp_hal_stdout_tx_str("PYB: enabling IRQs\r\n"); + } + } + #endif + + vstr_reset(&line); + int ret = readline(&line, ">>> "); + mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT; + + if (ret == CHAR_CTRL_A) { + // change to raw REPL + mp_hal_stdout_tx_str("\r\n"); + vstr_clear(&line); + pyexec_mode_kind = PYEXEC_MODE_RAW_REPL; + return 0; + } else if (ret == CHAR_CTRL_B) { + // reset friendly REPL + mp_hal_stdout_tx_str("\r\n"); + goto friendly_repl_reset; + } else if (ret == CHAR_CTRL_C) { + // break + mp_hal_stdout_tx_str("\r\n"); + continue; + } else if (ret == CHAR_CTRL_D) { + // exit for a soft reset + mp_hal_stdout_tx_str("\r\n"); + vstr_clear(&line); + return PYEXEC_FORCED_EXIT; + } else if (ret == CHAR_CTRL_E) { + // paste mode + mp_hal_stdout_tx_str("\r\npaste mode; Ctrl-C to cancel, Ctrl-D to finish\r\n=== "); + vstr_reset(&line); + for (;;) { + char c = mp_hal_stdin_rx_chr(); + if (c == CHAR_CTRL_C) { + // cancel everything + mp_hal_stdout_tx_str("\r\n"); + goto input_restart; + } else if (c == CHAR_CTRL_D) { + // end of input + mp_hal_stdout_tx_str("\r\n"); + break; + } else { + // add char to buffer and echo + vstr_add_byte(&line, c); + if (c == '\r') { + mp_hal_stdout_tx_str("\r\n=== "); + } else { + mp_hal_stdout_tx_strn(&c, 1); + } + } + } + parse_input_kind = MP_PARSE_FILE_INPUT; + } else if (vstr_len(&line) == 0) { + continue; + } else { + // got a line with non-zero length, see if it needs continuing + while (mp_repl_continue_with_input(vstr_null_terminated_str(&line))) { + vstr_add_byte(&line, '\n'); + ret = readline(&line, "... "); + if (ret == CHAR_CTRL_C) { + // cancel everything + mp_hal_stdout_tx_str("\r\n"); + goto input_restart; + } else if (ret == CHAR_CTRL_D) { + // stop entering compound statement + break; + } + } + } + + ret = parse_compile_execute(&line, parse_input_kind, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL | EXEC_FLAG_SOURCE_IS_VSTR); + if (ret & PYEXEC_FORCED_EXIT) { + return ret; + } + } +} + +#endif // MICROPY_REPL_EVENT_DRIVEN +#endif // MICROPY_ENABLE_COMPILER + +int pyexec_file(const char *filename) { + return parse_compile_execute(filename, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_FILENAME); +} + +#if MICROPY_MODULE_FROZEN +int pyexec_frozen_module(const char *name) { + void *frozen_data; + int frozen_type = mp_find_frozen_module(name, strlen(name), &frozen_data); + + switch (frozen_type) { + #if MICROPY_MODULE_FROZEN_STR + case MP_FROZEN_STR: + return parse_compile_execute(frozen_data, MP_PARSE_FILE_INPUT, 0); + #endif + + #if MICROPY_MODULE_FROZEN_MPY + case MP_FROZEN_MPY: + return parse_compile_execute(frozen_data, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_RAW_CODE); + #endif + + default: + printf("could not find module '%s'\n", name); + return false; + } +} +#endif + +mp_obj_t pyb_set_repl_info(mp_obj_t o_value) { + repl_display_debugging_info = mp_obj_get_int(o_value); + return mp_const_none; +} + +MP_DEFINE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj, pyb_set_repl_info); diff --git a/user/mpy/lib/utils/pyexec.h b/user/mpy/lib/utils/pyexec.h new file mode 100644 index 0000000..bc98ba9 --- /dev/null +++ b/user/mpy/lib/utils/pyexec.h @@ -0,0 +1,54 @@ +/* + * 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_LIB_UTILS_PYEXEC_H +#define MICROPY_INCLUDED_LIB_UTILS_PYEXEC_H + +typedef enum { + PYEXEC_MODE_RAW_REPL, + PYEXEC_MODE_FRIENDLY_REPL, +} pyexec_mode_kind_t; + +extern pyexec_mode_kind_t pyexec_mode_kind; + +// Set this to the value (eg PYEXEC_FORCED_EXIT) that will be propagated through +// the pyexec functions if a SystemExit exception is raised by the running code. +// It will reset to 0 at the start of each execution (eg each REPL entry). +extern int pyexec_system_exit; + +#define PYEXEC_FORCED_EXIT (0x100) +#define PYEXEC_SWITCH_MODE (0x200) + +int pyexec_raw_repl(void); +int pyexec_friendly_repl(void); +int pyexec_file(const char *filename); +int pyexec_frozen_module(const char *name); +void pyexec_event_repl_init(void); +int pyexec_event_repl_process_char(int c); +extern uint8_t pyexec_repl_active; + +MP_DECLARE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj); + +#endif // MICROPY_INCLUDED_LIB_UTILS_PYEXEC_H diff --git a/user/mpy/lib/utils/stdout_helpers.c b/user/mpy/lib/utils/stdout_helpers.c new file mode 100644 index 0000000..3de1197 --- /dev/null +++ b/user/mpy/lib/utils/stdout_helpers.c @@ -0,0 +1,26 @@ +#include +#include +#include "py/mpconfig.h" +#include "py/mphal.h" + +/* + * Extra stdout functions + * These can be either optimized for a particular port, or reference + * implementation below can be used. + */ + +// Send "cooked" string of given length, where every occurrence of +// LF character is replaced with CR LF. +void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { + while (len--) { + if (*str == '\n') { + mp_hal_stdout_tx_strn("\r", 1); + } + mp_hal_stdout_tx_strn(str++, 1); + } +} + +// Send zero-terminated string +void mp_hal_stdout_tx_str(const char *str) { + mp_hal_stdout_tx_strn(str, strlen(str)); +} diff --git a/user/mpy/lib/utils/sys_stdio_mphal.c b/user/mpy/lib/utils/sys_stdio_mphal.c new file mode 100644 index 0000000..fc8a74e --- /dev/null +++ b/user/mpy/lib/utils/sys_stdio_mphal.c @@ -0,0 +1,163 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-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. + */ + +#include +#include + +#include "py/obj.h" +#include "py/stream.h" +#include "py/mperrno.h" +#include "py/mphal.h" + +// TODO make stdin, stdout and stderr writable objects so they can +// be changed by Python code. This requires some changes, as these +// objects are in a read-only module (py/modsys.c). + +/******************************************************************************/ +// MicroPython bindings + +#define STDIO_FD_IN (0) +#define STDIO_FD_OUT (1) +#define STDIO_FD_ERR (2) + +typedef struct _sys_stdio_obj_t { + mp_obj_base_t base; + int fd; +} sys_stdio_obj_t; + +#if MICROPY_PY_SYS_STDIO_BUFFER +STATIC const sys_stdio_obj_t stdio_buffer_obj; +#endif + +void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + sys_stdio_obj_t *self = self_in; + mp_printf(print, "", self->fd); +} + +STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + sys_stdio_obj_t *self = self_in; + if (self->fd == STDIO_FD_IN) { + for (uint i = 0; i < size; i++) { + int c = mp_hal_stdin_rx_chr(); + if (c == '\r') { + c = '\n'; + } + ((byte*)buf)[i] = c; + } + return size; + } else { + *errcode = MP_EPERM; + return MP_STREAM_ERROR; + } +} + +STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + sys_stdio_obj_t *self = self_in; + if (self->fd == STDIO_FD_OUT || self->fd == STDIO_FD_ERR) { + mp_hal_stdout_tx_strn_cooked(buf, size); + return size; + } else { + *errcode = MP_EPERM; + return MP_STREAM_ERROR; + } +} + +STATIC mp_obj_t stdio_obj___exit__(size_t n_args, const mp_obj_t *args) { + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_obj___exit__); + +// TODO gc hook to close the file if not already closed + +STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = { +#if MICROPY_PY_SYS_STDIO_BUFFER + { MP_ROM_QSTR(MP_QSTR_buffer), MP_ROM_PTR(&stdio_buffer_obj) }, +#endif + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj)}, + { MP_ROM_QSTR(MP_QSTR_readlines), MP_ROM_PTR(&mp_stream_unbuffered_readlines_obj)}, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_identity_obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_identity_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&stdio_obj___exit___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(stdio_locals_dict, stdio_locals_dict_table); + +STATIC const mp_stream_p_t stdio_obj_stream_p = { + .read = stdio_read, + .write = stdio_write, + .is_text = true, +}; + +STATIC const mp_obj_type_t stdio_obj_type = { + { &mp_type_type }, + .name = MP_QSTR_FileIO, + // TODO .make_new? + .print = stdio_obj_print, + .getiter = mp_identity_getiter, + .iternext = mp_stream_unbuffered_iter, + .protocol = &stdio_obj_stream_p, + .locals_dict = (mp_obj_dict_t*)&stdio_locals_dict, +}; + +const sys_stdio_obj_t mp_sys_stdin_obj = {{&stdio_obj_type}, .fd = STDIO_FD_IN}; +const sys_stdio_obj_t mp_sys_stdout_obj = {{&stdio_obj_type}, .fd = STDIO_FD_OUT}; +const sys_stdio_obj_t mp_sys_stderr_obj = {{&stdio_obj_type}, .fd = STDIO_FD_ERR}; + +#if MICROPY_PY_SYS_STDIO_BUFFER +STATIC mp_uint_t stdio_buffer_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { + for (uint i = 0; i < size; i++) { + ((byte*)buf)[i] = mp_hal_stdin_rx_chr(); + } + return size; +} + +STATIC mp_uint_t stdio_buffer_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + mp_hal_stdout_tx_strn(buf, size); + return size; +} + +STATIC const mp_stream_p_t stdio_buffer_obj_stream_p = { + .read = stdio_buffer_read, + .write = stdio_buffer_write, + .is_text = false, +}; + +STATIC const mp_obj_type_t stdio_buffer_obj_type = { + { &mp_type_type }, + .name = MP_QSTR_FileIO, + .print = stdio_obj_print, + .getiter = mp_identity_getiter, + .iternext = mp_stream_unbuffered_iter, + .protocol = &stdio_buffer_obj_stream_p, + .locals_dict = (mp_obj_t)&stdio_locals_dict, +}; + +STATIC const sys_stdio_obj_t stdio_buffer_obj = {{&stdio_buffer_obj_type}, .fd = 0}; // fd unused +#endif diff --git a/user/mpy/mkrules.mk b/user/mpy/mkrules.mk new file mode 100644 index 0000000..1a3e5f0 --- /dev/null +++ b/user/mpy/mkrules.mk @@ -0,0 +1,16 @@ +$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) | $(HEADER_BUILD)/mpversion.h + $(ECHO) "GEN $@" + $(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(if $?,$?,$^) >$(HEADER_BUILD)/qstr.i.last; + +$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last + $(ECHO) "GEN $@" + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) + $(Q)touch $@ + +$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split + $(ECHO) "GEN $@" + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) + +$(BUILD)/_frozen_mpy.c: user/mpy/forzentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h + @echo "MISC freezing bytecode" + user/mpy/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@ diff --git a/user/mpy/mpconfigport.h b/user/mpy/mpconfigport.h new file mode 100644 index 0000000..ce4f8f2 --- /dev/null +++ b/user/mpy/mpconfigport.h @@ -0,0 +1,97 @@ +#include + +// options to control how MicroPython is built + +// You can disable the built-in MicroPython compiler by setting the following +// config option to 0. If you do this then you won't get a REPL prompt, but you +// will still be able to execute pre-compiled scripts, compiled with mpy-cross. +#define MICROPY_ENABLE_COMPILER (1) + +#define MICROPY_QSTR_BYTES_IN_HASH (1) +#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool +#define MICROPY_ALLOC_PATH_MAX (256) +#define MICROPY_ALLOC_PARSE_CHUNK_INIT (16) +#define MICROPY_EMIT_X64 (0) +#define MICROPY_EMIT_THUMB (0) +#define MICROPY_EMIT_INLINE_THUMB (0) +#define MICROPY_COMP_MODULE_CONST (0) +#define MICROPY_COMP_CONST (0) +#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0) +#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0) +#define MICROPY_MEM_STATS (0) +#define MICROPY_DEBUG_PRINTERS (0) +#define MICROPY_ENABLE_GC (1) +#define MICROPY_GC_ALLOC_THRESHOLD (0) +#define MICROPY_REPL_EVENT_DRIVEN (0) +#define MICROPY_HELPER_REPL (1) +#define MICROPY_HELPER_LEXER_UNIX (0) +#define MICROPY_ENABLE_SOURCE_LINE (0) +#define MICROPY_ENABLE_DOC_STRING (0) +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) +#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) +#define MICROPY_PY_ASYNC_AWAIT (0) +#define MICROPY_PY_BUILTINS_BYTEARRAY (0) +#define MICROPY_PY_BUILTINS_MEMORYVIEW (0) +#define MICROPY_PY_BUILTINS_ENUMERATE (0) +#define MICROPY_PY_BUILTINS_FILTER (0) +#define MICROPY_PY_BUILTINS_FROZENSET (0) +#define MICROPY_PY_BUILTINS_REVERSED (0) +#define MICROPY_PY_BUILTINS_SET (0) +#define MICROPY_PY_BUILTINS_SLICE (0) +#define MICROPY_PY_BUILTINS_PROPERTY (0) +#define MICROPY_PY_BUILTINS_MIN_MAX (0) +#define MICROPY_PY___FILE__ (0) +#define MICROPY_PY_GC (0) +#define MICROPY_PY_ARRAY (0) +#define MICROPY_PY_ATTRTUPLE (0) +#define MICROPY_PY_COLLECTIONS (0) +#define MICROPY_PY_MATH (0) +#define MICROPY_PY_CMATH (0) +#define MICROPY_PY_IO (0) +#define MICROPY_PY_STRUCT (0) +#define MICROPY_PY_SYS (0) +#define MICROPY_MODULE_FROZEN_MPY (1) +#define MICROPY_CPYTHON_COMPAT (0) +#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) + +// type definitions for the specific machine + +#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1)) + +// This port is intended to be 32-bit, but unfortunately, int32_t for +// different targets may be defined in different ways - either as int +// or as long. This requires different printf formatting specifiers +// to print such value. So, we avoid int32_t and use int directly. +#define UINT_FMT "%u" +#define INT_FMT "%d" +typedef int mp_int_t; // must be pointer size +typedef unsigned mp_uint_t; // must be pointer size + +typedef long mp_off_t; + +#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) + +// extra built in names to add to the global namespace +#define MICROPY_PORT_BUILTINS \ + { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, + +// We need to provide a declaration/definition of alloca() +#include + +#define MICROPY_HW_BOARD_NAME "minimal" +#define MICROPY_HW_MCU_NAME "unknown-cpu" + +#ifdef __linux__ +#define MICROPY_MIN_USE_STDOUT (1) +#endif + +#ifdef __thumb__ +#define MICROPY_MIN_USE_CORTEX_CPU (1) +#define MICROPY_MIN_USE_STM32_MCU (1) +#endif + +#define MP_STATE_PORT MP_STATE_VM + +#define MICROPY_PORT_ROOT_POINTERS \ + const char *readline_hist[8]; diff --git a/user/mpy/mphalport.c b/user/mpy/mphalport.c new file mode 100644 index 0000000..fb3246a --- /dev/null +++ b/user/mpy/mphalport.c @@ -0,0 +1,18 @@ +#include "platform.h" +#include "py/mphal.h" + + +int mp_hal_stdin_rx_chr() { + char c; + int fd = open("/dev/ttyS0", 0); + + read(fd, &c, 1); + close(fd); + return c; +} + +void mp_hal_stdout_tx_strn(const char *s, mp_uint_t n) { + while (n--) { + __printk_putchar(*s++); + } +} diff --git a/user/mpy/mphalport.h b/user/mpy/mphalport.h new file mode 100644 index 0000000..9937063 --- /dev/null +++ b/user/mpy/mphalport.h @@ -0,0 +1,4 @@ +#define mp_hal_stdout_tx_strn_cooked(s, l) printk(s); +#define mp_hal_stdout_tx_str(s) printk(s); +#define mp_hal_set_interrupt_char(n) (0) +#define mp_hal_ticks_ms() (0) diff --git a/user/mpy/py.mk b/user/mpy/py.mk new file mode 100644 index 0000000..a9afb96 --- /dev/null +++ b/user/mpy/py.mk @@ -0,0 +1,319 @@ +# where py object files go (they have a name prefix to prevent filename clashes) +PY_BUILD = $(BUILD)/py + +# where autogenerated header files go +HEADER_BUILD = $(BUILD)/genhdr + +# file containing qstr defs for the core Python bit +PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h + +# If qstr autogeneration is not disabled we specify the output header +# for all collected qstrings. +ifneq ($(QSTR_AUTOGEN_DISABLE),1) +QSTR_DEFS_COLLECTED = $(HEADER_BUILD)/qstrdefs.collected.h +endif + +# some code is performance bottleneck and compiled with other optimization options +CSUPEROPT = -O3 + +# this sets the config file for FatFs +CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\" + +ifeq ($(MICROPY_PY_USSL),1) +CFLAGS_MOD += -DMICROPY_PY_USSL=1 +ifeq ($(MICROPY_SSL_AXTLS),1) +CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/lib/axtls/config +LDFLAGS_MOD += -Lbuild -laxtls +else ifeq ($(MICROPY_SSL_MBEDTLS),1) +# Can be overridden by ports which have "builtin" mbedTLS +MICROPY_SSL_MBEDTLS_INCLUDE ?= $(TOP)/lib/mbedtls/include +CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE) +LDFLAGS_MOD += -L$(TOP)/lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto +endif +endif + +#ifeq ($(MICROPY_PY_LWIP),1) +#CFLAGS_MOD += -DMICROPY_PY_LWIP=1 -I../lib/lwip/src/include -I../lib/lwip/src/include/ipv4 -I../extmod/lwip-include +#endif + +ifeq ($(MICROPY_PY_LWIP),1) +LWIP_DIR = lib/lwip/src +INC += -I$(TOP)/lib/lwip/src/include -I$(TOP)/lib/lwip/src/include/ipv4 -I$(TOP)/extmod/lwip-include +CFLAGS_MOD += -DMICROPY_PY_LWIP=1 +SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c +SRC_MOD += $(addprefix $(LWIP_DIR)/,\ + core/def.c \ + core/dns.c \ + core/init.c \ + core/mem.c \ + core/memp.c \ + core/netif.c \ + core/pbuf.c \ + core/raw.c \ + core/stats.c \ + core/sys.c \ + core/tcp.c \ + core/tcp_in.c \ + core/tcp_out.c \ + core/timers.c \ + core/udp.c \ + core/ipv4/autoip.c \ + core/ipv4/icmp.c \ + core/ipv4/igmp.c \ + core/ipv4/inet.c \ + core/ipv4/inet_chksum.c \ + core/ipv4/ip_addr.c \ + core/ipv4/ip.c \ + core/ipv4/ip_frag.c \ + ) +ifeq ($(MICROPY_PY_LWIP_SLIP),1) +CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1 +SRC_MOD += $(LWIP_DIR)/netif/slipif.c +endif +endif + +ifeq ($(MICROPY_PY_BTREE),1) +BTREE_DIR = lib/berkeley-db-1.xx +BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ -Dvirt_fd_t=mp_obj_t "-DVIRT_FD_T_HEADER=" +INC += -I$(TOP)/$(BTREE_DIR)/PORT/include +SRC_MOD += extmod/modbtree.c +SRC_MOD += $(addprefix $(BTREE_DIR)/,\ +btree/bt_close.c \ +btree/bt_conv.c \ +btree/bt_debug.c \ +btree/bt_delete.c \ +btree/bt_get.c \ +btree/bt_open.c \ +btree/bt_overflow.c \ +btree/bt_page.c \ +btree/bt_put.c \ +btree/bt_search.c \ +btree/bt_seq.c \ +btree/bt_split.c \ +btree/bt_utils.c \ +mpool/mpool.c \ + ) +CFLAGS_MOD += -DMICROPY_PY_BTREE=1 +# we need to suppress certain warnings to get berkeley-db to compile cleanly +# and we have separate BTREE_DEFS so the definitions don't interfere with other source code +$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS) +$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS) +endif + +# py object files +PY_O_BASENAME = \ + mpstate.o \ + nlrx86.o \ + nlrx64.o \ + nlrthumb.o \ + nlrxtensa.o \ + nlrsetjmp.o \ + malloc.o \ + gc.o \ + qstr.o \ + vstr.o \ + mpprint.o \ + unicode.o \ + mpz.o \ + reader.o \ + lexer.o \ + parse.o \ + scope.o \ + compile.o \ + emitcommon.o \ + emitbc.o \ + asmbase.o \ + asmx64.o \ + emitnx64.o \ + asmx86.o \ + emitnx86.o \ + asmthumb.o \ + emitnthumb.o \ + emitinlinethumb.o \ + asmarm.o \ + emitnarm.o \ + asmxtensa.o \ + emitnxtensa.o \ + emitinlinextensa.o \ + formatfloat.o \ + parsenumbase.o \ + parsenum.o \ + emitglue.o \ + persistentcode.o \ + runtime.o \ + runtime_utils.o \ + scheduler.o \ + nativeglue.o \ + stackctrl.o \ + argcheck.o \ + warning.o \ + map.o \ + obj.o \ + objarray.o \ + objattrtuple.o \ + objbool.o \ + objboundmeth.o \ + objcell.o \ + objclosure.o \ + objcomplex.o \ + objdict.o \ + objenumerate.o \ + objexcept.o \ + objfilter.o \ + objfloat.o \ + objfun.o \ + objgenerator.o \ + objgetitemiter.o \ + objint.o \ + objint_longlong.o \ + objint_mpz.o \ + objlist.o \ + objmap.o \ + objmodule.o \ + objobject.o \ + objpolyiter.o \ + objproperty.o \ + objnone.o \ + objnamedtuple.o \ + objrange.o \ + objreversed.o \ + objset.o \ + objsingleton.o \ + objslice.o \ + objstr.o \ + objstrunicode.o \ + objstringio.o \ + objtuple.o \ + objtype.o \ + objzip.o \ + opmethods.o \ + sequence.o \ + stream.o \ + binary.o \ + builtinimport.o \ + builtinevex.o \ + builtinhelp.o \ + modarray.o \ + modbuiltins.o \ + modcollections.o \ + modgc.o \ + modio.o \ + modmath.o \ + modcmath.o \ + modmicropython.o \ + modstruct.o \ + modsys.o \ + moduerrno.o \ + modthread.o \ + vm.o \ + bc.o \ + showbc.o \ + repl.o \ + smallint.o \ + frozenmod.o \ + ../extmod/moductypes.o \ + ../extmod/modujson.o \ + ../extmod/modure.o \ + ../extmod/moduzlib.o \ + ../extmod/moduheapq.o \ + ../extmod/modutimeq.o \ + ../extmod/moduhashlib.o \ + ../extmod/modubinascii.o \ + ../extmod/virtpin.o \ + ../extmod/machine_mem.o \ + ../extmod/machine_pinbase.o \ + ../extmod/machine_signal.o \ + ../extmod/machine_pulse.o \ + ../extmod/machine_i2c.o \ + ../extmod/machine_spi.o \ + ../extmod/modussl_axtls.o \ + ../extmod/modussl_mbedtls.o \ + ../extmod/modurandom.o \ + ../extmod/moduselect.o \ + ../extmod/modwebsocket.o \ + ../extmod/modwebrepl.o \ + ../extmod/modframebuf.o \ + ../extmod/vfs.o \ + ../extmod/vfs_reader.o \ + ../extmod/vfs_fat.o \ + ../extmod/vfs_fat_diskio.o \ + ../extmod/vfs_fat_file.o \ + ../extmod/vfs_fat_misc.o \ + ../extmod/utime_mphal.o \ + ../extmod/uos_dupterm.o \ + ../lib/embed/abort_.o \ + ../lib/utils/printf.o \ + +# prepend the build destination prefix to the py object files +PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME)) + +# object file for frozen files +ifneq ($(FROZEN_DIR),) +PY_O += $(BUILD)/$(BUILD)/frozen.o +endif + +# object file for frozen bytecode (froPY_QSTR_DEFSzen .mpy files) +ifneq ($(FROZEN_MPY_DIR),) +PY_O += $(BUILD)/$(BUILD)/frozen_mpy.o +endif + +# Sources that may contain qstrings +SRC_QSTR_IGNORE = nlr% emitnx86% emitnx64% emitnthumb% emitnarm% emitnxtensa% +SRC_QSTR = $(SRC_MOD) $(addprefix py/,$(filter-out $(SRC_QSTR_IGNORE),$(PY_O_BASENAME:.o=.c)) emitnative.c) + +$(HEADER_BUILD)/mpversion.h: | $(HEADER_BUILD) + $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ + +# mpconfigport.mk is optional, but changes to it may drastically change +# overall config, so they need to be caught +MPCONFIGPORT_MK = $(wildcard mpconfigport.mk) + +# qstr data +# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get +# created before we run the script to generate the .h +# Note: we need to protect the qstr names from the preprocessor, so we wrap +# the lines in "" and then unwrap after the preprocessor is finished. +$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py $(TOP)/mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) + $(ECHO) "GEN $@" + $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ + +# Force nlr code to always be compiled with space-saving optimisation so +# that the function preludes are of a minimal and predictable form. +$(PY_BUILD)/nlr%.o: CFLAGS += -Os + +# emitters + +# $(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64 +# $(PY_BUILD)/emitnx64.o: py/emitnative.c +# $(call compile_c) + +# $(PY_BUILD)/emitnx86.o: CFLAGS += -DN_X86 +# $(PY_BUILD)/emitnx86.o: py/emitnative.c +# $(call compile_c) + +# $(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB +# $(PY_BUILD)/emitnthumb.o: py/emitnative.c +# $(call compile_c) + +# $(PY_BUILD)/emitnarm.o: CFLAGS += -DN_ARM +# $(PY_BUILD)/emitnarm.o: py/emitnative.c +# $(call compile_c) + +# $(PY_BUILD)/emitnxtensa.o: CFLAGS += -DN_XTENSA +# $(PY_BUILD)/emitnxtensa.o: py/emitnative.c +# $(call compile_c) + +# optimising gc for speed; 5ms down to 4ms on pybv2 +$(PY_BUILD)/gc.o: CFLAGS += $(CSUPEROPT) + +# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster) +$(PY_BUILD)/vm.o: CFLAGS += $(CSUPEROPT) +# Optimizing vm.o for modern deeply pipelined CPUs with branch predictors +# may require disabling tail jump optimization. This will make sure that +# each opcode has its own dispatching jump which will improve branch +# branch predictor efficiency. +# http://article.gmane.org/gmane.comp.lang.lua.general/75426 +# http://hg.python.org/cpython/file/b127046831e2/Python/ceval.c#l828 +# http://www.emulators.com/docs/nx25_nostradamus.htm +#-fno-crossjumping diff --git a/user/mpy/py/__pycache__/makeqstrdata.cpython-35.pyc b/user/mpy/py/__pycache__/makeqstrdata.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a62a8c80af08d42f153c47c553710e2acbd176fd GIT binary patch literal 4914 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 +#include + +#include "py/nlr.h" +#include "py/runtime.h" + +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) { + // TODO maybe take the function name as an argument so we can print nicer error messages + + if (n_kw && !takes_kw) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + mp_raise_TypeError("function does not take keyword arguments"); + } + } + + if (n_args_min == n_args_max) { + if (n_args != n_args_min) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function takes %d positional arguments but %d were given", + n_args_min, n_args)); + } + } + } else { + if (n_args < n_args_min) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function missing %d required positional arguments", + n_args_min - n_args)); + } + } else if (n_args > n_args_max) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function expected at most %d arguments, got %d", + n_args_max, n_args)); + } + } + } +} + +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) { + size_t pos_found = 0, kws_found = 0; + for (size_t i = 0; i < n_allowed; i++) { + mp_obj_t given_arg; + if (i < n_pos) { + if (allowed[i].flags & MP_ARG_KW_ONLY) { + goto extra_positional; + } + pos_found++; + given_arg = pos[i]; + } else { + mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qst), MP_MAP_LOOKUP); + if (kw == NULL) { + if (allowed[i].flags & MP_ARG_REQUIRED) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%q' argument required", allowed[i].qst)); + } + } + out_vals[i] = allowed[i].defval; + continue; + } else { + kws_found++; + given_arg = kw->value; + } + } + if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_BOOL) { + out_vals[i].u_bool = mp_obj_is_true(given_arg); + } else if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_INT) { + out_vals[i].u_int = mp_obj_get_int(given_arg); + } else { + assert((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_OBJ); + out_vals[i].u_obj = given_arg; + } + } + if (pos_found < n_pos) { + extra_positional: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + // TODO better error message + mp_raise_TypeError("extra positional arguments given"); + } + } + if (kws_found < kws->used) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + // TODO better error message + mp_raise_TypeError("extra keyword arguments given"); + } + } +} + +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) { + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, args + n_pos); + mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals); +} + +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE || _MSC_VER +NORETURN void mp_arg_error_terse_mismatch(void) { + mp_raise_TypeError("argument num/types mismatch"); +} +#endif + +#if MICROPY_CPYTHON_COMPAT +NORETURN void mp_arg_error_unimpl_kw(void) { + mp_raise_NotImplementedError("keyword argument(s) not yet implemented - use normal args instead"); +} +#endif diff --git a/user/mpy/py/asmarm.c b/user/mpy/py/asmarm.c new file mode 100644 index 0000000..552fdfb --- /dev/null +++ b/user/mpy/py/asmarm.c @@ -0,0 +1,368 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Fabian Vogt + * 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. + */ + +#include +#include +#include + +#include "py/mpconfig.h" + +// wrapper around everything in this file +#if MICROPY_EMIT_ARM + +#include "py/asmarm.h" + +#define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000) + +void asm_arm_end_pass(asm_arm_t *as) { + if (as->base.pass == MP_ASM_PASS_EMIT) { +#ifdef __arm__ + // flush I- and D-cache + asm volatile( + "0:" + "mrc p15, 0, r15, c7, c10, 3\n" + "bne 0b\n" + "mov r0, #0\n" + "mcr p15, 0, r0, c7, c7, 0\n" + : : : "r0", "cc"); +#endif + } +} + +// Insert word into instruction flow +STATIC void emit(asm_arm_t *as, uint op) { + uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4); + if (c != NULL) { + *(uint32_t*)c = op; + } +} + +// Insert word into instruction flow, add "ALWAYS" condition code +STATIC void emit_al(asm_arm_t *as, uint op) { + emit(as, op | ASM_ARM_CC_AL); +} + +// Basic instructions without condition code +STATIC uint asm_arm_op_push(uint reglist) { + // stmfd sp!, {reglist} + return 0x92d0000 | (reglist & 0xFFFF); +} + +STATIC uint asm_arm_op_pop(uint reglist) { + // ldmfd sp!, {reglist} + return 0x8bd0000 | (reglist & 0xFFFF); +} + +STATIC uint asm_arm_op_mov_reg(uint rd, uint rn) { + // mov rd, rn + return 0x1a00000 | (rd << 12) | rn; +} + +STATIC uint asm_arm_op_mov_imm(uint rd, uint imm) { + // mov rd, #imm + return 0x3a00000 | (rd << 12) | imm; +} + +STATIC uint asm_arm_op_mvn_imm(uint rd, uint imm) { + // mvn rd, #imm + return 0x3e00000 | (rd << 12) | imm; +} + +STATIC uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) { + // add rd, rn, #imm + return 0x2800000 | (rn << 16) | (rd << 12) | (imm & 0xFF); +} + +STATIC uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) { + // add rd, rn, rm + return 0x0800000 | (rn << 16) | (rd << 12) | rm; +} + +STATIC uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) { + // sub rd, rn, #imm + return 0x2400000 | (rn << 16) | (rd << 12) | (imm & 0xFF); +} + +STATIC uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) { + // sub rd, rn, rm + return 0x0400000 | (rn << 16) | (rd << 12) | rm; +} + +STATIC uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) { + // mul rd, rm, rs + assert(rd != rm); + return 0x0000090 | (rd << 16) | (rs << 8) | rm; +} + +STATIC uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) { + // and rd, rn, rm + return 0x0000000 | (rn << 16) | (rd << 12) | rm; +} + +STATIC uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) { + // eor rd, rn, rm + return 0x0200000 | (rn << 16) | (rd << 12) | rm; +} + +STATIC uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) { + // orr rd, rn, rm + return 0x1800000 | (rn << 16) | (rd << 12) | rm; +} + +void asm_arm_bkpt(asm_arm_t *as) { + // bkpt #0 + emit_al(as, 0x1200070); +} + +// locals: +// - stored on the stack in ascending order +// - numbered 0 through num_locals-1 +// - SP points to first local +// +// | SP +// v +// l0 l1 l2 ... l(n-1) +// ^ ^ +// | low address | high address in RAM + +void asm_arm_entry(asm_arm_t *as, int num_locals) { + + if (num_locals < 0) { + num_locals = 0; + } + + as->stack_adjust = 0; + as->push_reglist = 1 << ASM_ARM_REG_R1 + | 1 << ASM_ARM_REG_R2 + | 1 << ASM_ARM_REG_R3 + | 1 << ASM_ARM_REG_R4 + | 1 << ASM_ARM_REG_R5 + | 1 << ASM_ARM_REG_R6 + | 1 << ASM_ARM_REG_R7 + | 1 << ASM_ARM_REG_R8; + + // Only adjust the stack if there are more locals than usable registers + if (num_locals > 3) { + as->stack_adjust = num_locals * 4; + // Align stack to 8 bytes + if (num_locals & 1) { + as->stack_adjust += 4; + } + } + + emit_al(as, asm_arm_op_push(as->push_reglist | 1 << ASM_ARM_REG_LR)); + if (as->stack_adjust > 0) { + emit_al(as, asm_arm_op_sub_imm(ASM_ARM_REG_SP, ASM_ARM_REG_SP, as->stack_adjust)); + } +} + +void asm_arm_exit(asm_arm_t *as) { + if (as->stack_adjust > 0) { + emit_al(as, asm_arm_op_add_imm(ASM_ARM_REG_SP, ASM_ARM_REG_SP, as->stack_adjust)); + } + + emit_al(as, asm_arm_op_pop(as->push_reglist | (1 << ASM_ARM_REG_PC))); +} + +void asm_arm_push(asm_arm_t *as, uint reglist) { + emit_al(as, asm_arm_op_push(reglist)); +} + +void asm_arm_pop(asm_arm_t *as, uint reglist) { + emit_al(as, asm_arm_op_pop(reglist)); +} + +void asm_arm_mov_reg_reg(asm_arm_t *as, uint reg_dest, uint reg_src) { + emit_al(as, asm_arm_op_mov_reg(reg_dest, reg_src)); +} + +void asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm) { + // TODO: There are more variants of immediate values + if ((imm & 0xFF) == imm) { + emit_al(as, asm_arm_op_mov_imm(rd, imm)); + } else if (imm < 0 && imm >= -256) { + // mvn is "move not", not "move negative" + emit_al(as, asm_arm_op_mvn_imm(rd, ~imm)); + } else { + //Insert immediate into code and jump over it + emit_al(as, 0x59f0000 | (rd << 12)); // ldr rd, [pc] + emit_al(as, 0xa000000); // b pc + emit(as, imm); + } +} + +void asm_arm_mov_local_reg(asm_arm_t *as, int local_num, uint rd) { + // str rd, [sp, #local_num*4] + emit_al(as, 0x58d0000 | (rd << 12) | (local_num << 2)); +} + +void asm_arm_mov_reg_local(asm_arm_t *as, uint rd, int local_num) { + // ldr rd, [sp, #local_num*4] + emit_al(as, 0x59d0000 | (rd << 12) | (local_num << 2)); +} + +void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm) { + // cmp rd, #imm + emit_al(as, 0x3500000 | (rd << 16) | (imm & 0xFF)); +} + +void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn) { + // cmp rd, rn + emit_al(as, 0x1500000 | (rd << 16) | rn); +} + +void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond) { + emit(as, asm_arm_op_mov_imm(rd, 1) | cond); // movCOND rd, #1 + emit(as, asm_arm_op_mov_imm(rd, 0) | (cond ^ (1 << 28))); // mov!COND rd, #0 +} + +void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { + // add rd, rn, rm + emit_al(as, asm_arm_op_add_reg(rd, rn, rm)); +} + +void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { + // sub rd, rn, rm + emit_al(as, asm_arm_op_sub_reg(rd, rn, rm)); +} + +void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rs, uint rm) { + // rs and rm are swapped because of restriction rd!=rm + // mul rd, rm, rs + emit_al(as, asm_arm_op_mul_reg(rd, rm, rs)); +} + +void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { + // and rd, rn, rm + emit_al(as, asm_arm_op_and_reg(rd, rn, rm)); +} + +void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { + // eor rd, rn, rm + emit_al(as, asm_arm_op_eor_reg(rd, rn, rm)); +} + +void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { + // orr rd, rn, rm + emit_al(as, asm_arm_op_orr_reg(rd, rn, rm)); +} + +void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num) { + // add rd, sp, #local_num*4 + emit_al(as, asm_arm_op_add_imm(rd, ASM_ARM_REG_SP, local_num << 2)); +} + +void asm_arm_lsl_reg_reg(asm_arm_t *as, uint rd, uint rs) { + // mov rd, rd, lsl rs + emit_al(as, 0x1a00010 | (rd << 12) | (rs << 8) | rd); +} + +void asm_arm_asr_reg_reg(asm_arm_t *as, uint rd, uint rs) { + // mov rd, rd, asr rs + emit_al(as, 0x1a00050 | (rd << 12) | (rs << 8) | rd); +} + +void asm_arm_ldr_reg_reg(asm_arm_t *as, uint rd, uint rn, uint byte_offset) { + // ldr rd, [rn, #off] + emit_al(as, 0x5900000 | (rn << 16) | (rd << 12) | byte_offset); +} + +void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn) { + // ldrh rd, [rn] + emit_al(as, 0x1d000b0 | (rn << 16) | (rd << 12)); +} + +void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn) { + // ldrb rd, [rn] + emit_al(as, 0x5d00000 | (rn << 16) | (rd << 12)); +} + +void asm_arm_str_reg_reg(asm_arm_t *as, uint rd, uint rm, uint byte_offset) { + // str rd, [rm, #off] + emit_al(as, 0x5800000 | (rm << 16) | (rd << 12) | byte_offset); +} + +void asm_arm_strh_reg_reg(asm_arm_t *as, uint rd, uint rm) { + // strh rd, [rm] + emit_al(as, 0x1c000b0 | (rm << 16) | (rd << 12)); +} + +void asm_arm_strb_reg_reg(asm_arm_t *as, uint rd, uint rm) { + // strb rd, [rm] + emit_al(as, 0x5c00000 | (rm << 16) | (rd << 12)); +} + +void asm_arm_str_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) { + // str rd, [rm, rn, lsl #2] + emit_al(as, 0x7800100 | (rm << 16) | (rd << 12) | rn); +} + +void asm_arm_strh_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) { + // strh doesn't support scaled register index + emit_al(as, 0x1a00080 | (ASM_ARM_REG_R8 << 12) | rn); // mov r8, rn, lsl #1 + emit_al(as, 0x18000b0 | (rm << 16) | (rd << 12) | ASM_ARM_REG_R8); // strh rd, [rm, r8] +} + +void asm_arm_strb_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) { + // strb rd, [rm, rn] + emit_al(as, 0x7c00000 | (rm << 16) | (rd << 12) | rn); +} + +void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label) { + assert(label < as->base.max_num_labels); + mp_uint_t dest = as->base.label_offsets[label]; + mp_int_t rel = dest - as->base.code_offset; + rel -= 8; // account for instruction prefetch, PC is 8 bytes ahead of this instruction + rel >>= 2; // in ARM mode the branch target is 32-bit aligned, so the 2 LSB are omitted + + if (SIGNED_FIT24(rel)) { + emit(as, cond | 0xa000000 | (rel & 0xffffff)); + } else { + printf("asm_arm_bcc: branch does not fit in 24 bits\n"); + } +} + +void asm_arm_b_label(asm_arm_t *as, uint label) { + asm_arm_bcc_label(as, ASM_ARM_CC_AL, label); +} + +void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp) { + // If the table offset fits into the ldr instruction + if (fun_id < (0x1000 / 4)) { + emit_al(as, asm_arm_op_mov_reg(ASM_ARM_REG_LR, ASM_ARM_REG_PC)); // mov lr, pc + emit_al(as, 0x597f000 | (fun_id << 2)); // ldr pc, [r7, #fun_id*4] + return; + } + + emit_al(as, 0x59f0004 | (reg_temp << 12)); // ldr rd, [pc, #4] + // Set lr after fun_ptr + emit_al(as, asm_arm_op_add_imm(ASM_ARM_REG_LR, ASM_ARM_REG_PC, 4)); // add lr, pc, #4 + emit_al(as, asm_arm_op_mov_reg(ASM_ARM_REG_PC, reg_temp)); // mov pc, reg_temp + emit(as, (uint) fun_ptr); +} + +#endif // MICROPY_EMIT_ARM diff --git a/user/mpy/py/asmarm.h b/user/mpy/py/asmarm.h new file mode 100644 index 0000000..a302b15 --- /dev/null +++ b/user/mpy/py/asmarm.h @@ -0,0 +1,205 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Fabian Vogt + * 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_ASMARM_H +#define MICROPY_INCLUDED_PY_ASMARM_H + +#include "py/misc.h" +#include "py/asmbase.h" + +#define ASM_ARM_REG_R0 (0) +#define ASM_ARM_REG_R1 (1) +#define ASM_ARM_REG_R2 (2) +#define ASM_ARM_REG_R3 (3) +#define ASM_ARM_REG_R4 (4) +#define ASM_ARM_REG_R5 (5) +#define ASM_ARM_REG_R6 (6) +#define ASM_ARM_REG_R7 (7) +#define ASM_ARM_REG_R8 (8) +#define ASM_ARM_REG_R9 (9) +#define ASM_ARM_REG_R10 (10) +#define ASM_ARM_REG_R11 (11) +#define ASM_ARM_REG_R12 (12) +#define ASM_ARM_REG_R13 (13) +#define ASM_ARM_REG_R14 (14) +#define ASM_ARM_REG_R15 (15) +#define ASM_ARM_REG_SP (ASM_ARM_REG_R13) +#define ASM_ARM_REG_LR (ASM_ARM_REG_R14) +#define ASM_ARM_REG_PC (ASM_ARM_REG_R15) + +#define ASM_ARM_CC_EQ (0x0 << 28) +#define ASM_ARM_CC_NE (0x1 << 28) +#define ASM_ARM_CC_CS (0x2 << 28) +#define ASM_ARM_CC_CC (0x3 << 28) +#define ASM_ARM_CC_MI (0x4 << 28) +#define ASM_ARM_CC_PL (0x5 << 28) +#define ASM_ARM_CC_VS (0x6 << 28) +#define ASM_ARM_CC_VC (0x7 << 28) +#define ASM_ARM_CC_HI (0x8 << 28) +#define ASM_ARM_CC_LS (0x9 << 28) +#define ASM_ARM_CC_GE (0xa << 28) +#define ASM_ARM_CC_LT (0xb << 28) +#define ASM_ARM_CC_GT (0xc << 28) +#define ASM_ARM_CC_LE (0xd << 28) +#define ASM_ARM_CC_AL (0xe << 28) + +typedef struct _asm_arm_t { + mp_asm_base_t base; + uint push_reglist; + uint stack_adjust; +} asm_arm_t; + +void asm_arm_end_pass(asm_arm_t *as); + +void asm_arm_entry(asm_arm_t *as, int num_locals); +void asm_arm_exit(asm_arm_t *as); + +void asm_arm_bkpt(asm_arm_t *as); + +// mov +void asm_arm_mov_reg_reg(asm_arm_t *as, uint reg_dest, uint reg_src); +void asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm); +void asm_arm_mov_local_reg(asm_arm_t *as, int local_num, uint rd); +void asm_arm_mov_reg_local(asm_arm_t *as, uint rd, int local_num); +void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond); + +// compare +void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm); +void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn); + +// arithmetic +void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); +void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); +void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); +void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); +void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); +void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); +void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num); +void asm_arm_lsl_reg_reg(asm_arm_t *as, uint rd, uint rs); +void asm_arm_asr_reg_reg(asm_arm_t *as, uint rd, uint rs); + +// memory +void asm_arm_ldr_reg_reg(asm_arm_t *as, uint rd, uint rn, uint byte_offset); +void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn); +void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn); +void asm_arm_str_reg_reg(asm_arm_t *as, uint rd, uint rm, uint byte_offset); +void asm_arm_strh_reg_reg(asm_arm_t *as, uint rd, uint rm); +void asm_arm_strb_reg_reg(asm_arm_t *as, uint rd, uint rm); +// store to array +void asm_arm_str_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn); +void asm_arm_strh_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn); +void asm_arm_strb_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn); + +// stack +void asm_arm_push(asm_arm_t *as, uint reglist); +void asm_arm_pop(asm_arm_t *as, uint reglist); + +// control flow +void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label); +void asm_arm_b_label(asm_arm_t *as, uint label); +void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp); + +#if GENERIC_ASM_API + +// The following macros provide a (mostly) arch-independent API to +// generate native code, and are used by the native emitter. + +#define ASM_WORD_SIZE (4) + +#define REG_RET ASM_ARM_REG_R0 +#define REG_ARG_1 ASM_ARM_REG_R0 +#define REG_ARG_2 ASM_ARM_REG_R1 +#define REG_ARG_3 ASM_ARM_REG_R2 +#define REG_ARG_4 ASM_ARM_REG_R3 + +#define REG_TEMP0 ASM_ARM_REG_R0 +#define REG_TEMP1 ASM_ARM_REG_R1 +#define REG_TEMP2 ASM_ARM_REG_R2 + +#define REG_LOCAL_1 ASM_ARM_REG_R4 +#define REG_LOCAL_2 ASM_ARM_REG_R5 +#define REG_LOCAL_3 ASM_ARM_REG_R6 +#define REG_LOCAL_NUM (3) + +#define ASM_T asm_arm_t +#define ASM_END_PASS asm_arm_end_pass +#define ASM_ENTRY asm_arm_entry +#define ASM_EXIT asm_arm_exit + +#define ASM_JUMP asm_arm_b_label +#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ + do { \ + asm_arm_cmp_reg_i8(as, reg, 0); \ + asm_arm_bcc_label(as, ASM_ARM_CC_EQ, label); \ + } while (0) +#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ + do { \ + asm_arm_cmp_reg_i8(as, reg, 0); \ + asm_arm_bcc_label(as, ASM_ARM_CC_NE, label); \ + } while (0) +#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ + do { \ + asm_arm_cmp_reg_reg(as, reg1, reg2); \ + asm_arm_bcc_label(as, ASM_ARM_CC_EQ, label); \ + } while (0) +#define ASM_CALL_IND(as, ptr, idx) asm_arm_bl_ind(as, ptr, idx, ASM_ARM_REG_R3) + +#define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_arm_mov_local_reg(as, (local_num), (reg)) +#define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_arm_mov_reg_i32(as, (reg), (imm)) +#define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_arm_mov_reg_i32(as, (reg), (imm)) +#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ + do { \ + asm_arm_mov_reg_i32(as, (reg_temp), (imm)); \ + asm_arm_mov_local_reg(as, (local_num), (reg_temp)); \ + } while (false) +#define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_arm_mov_reg_local(as, (reg), (local_num)) +#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_arm_mov_reg_reg((as), (reg_dest), (reg_src)) +#define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_arm_mov_reg_local_addr(as, (reg), (local_num)) + +#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_arm_lsl_reg_reg((as), (reg_dest), (reg_shift)) +#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_arm_asr_reg_reg((as), (reg_dest), (reg_shift)) +#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_arm_orr_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_arm_eor_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_arm_and_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_arm_add_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_arm_sub_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_arm_mul_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) + +#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_arm_ldr_reg_reg((as), (reg_dest), (reg_base), 0) +#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_arm_ldr_reg_reg((as), (reg_dest), (reg_base), 4 * (word_offset)) +#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_arm_ldrb_reg_reg((as), (reg_dest), (reg_base)) +#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_arm_ldrh_reg_reg((as), (reg_dest), (reg_base)) +#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_arm_ldr_reg_reg((as), (reg_dest), (reg_base), 0) + +#define ASM_STORE_REG_REG(as, reg_value, reg_base) asm_arm_str_reg_reg((as), (reg_value), (reg_base), 0) +#define ASM_STORE_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_arm_str_reg_reg((as), (reg_dest), (reg_base), 4 * (word_offset)) +#define ASM_STORE8_REG_REG(as, reg_value, reg_base) asm_arm_strb_reg_reg((as), (reg_value), (reg_base)) +#define ASM_STORE16_REG_REG(as, reg_value, reg_base) asm_arm_strh_reg_reg((as), (reg_value), (reg_base)) +#define ASM_STORE32_REG_REG(as, reg_value, reg_base) asm_arm_str_reg_reg((as), (reg_value), (reg_base), 0) + +#endif // GENERIC_ASM_API + +#endif // MICROPY_INCLUDED_PY_ASMARM_H diff --git a/user/mpy/py/asmbase.c b/user/mpy/py/asmbase.c new file mode 100644 index 0000000..c941e91 --- /dev/null +++ b/user/mpy/py/asmbase.c @@ -0,0 +1,102 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include + +#include "py/obj.h" +#include "py/misc.h" +#include "py/asmbase.h" + +#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM + +void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels) { + as->max_num_labels = max_num_labels; + as->label_offsets = m_new(size_t, max_num_labels); +} + +void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code) { + if (free_code) { + MP_PLAT_FREE_EXEC(as->code_base, as->code_size); + } + m_del(size_t, as->label_offsets, as->max_num_labels); +} + +void mp_asm_base_start_pass(mp_asm_base_t *as, int pass) { + if (pass == MP_ASM_PASS_COMPUTE) { + // reset all labels + memset(as->label_offsets, -1, as->max_num_labels * sizeof(size_t)); + } else if (pass == MP_ASM_PASS_EMIT) { + // allocating executable RAM is platform specific + MP_PLAT_ALLOC_EXEC(as->code_offset, (void**)&as->code_base, &as->code_size); + assert(as->code_base != NULL); + } + as->pass = pass; + as->code_offset = 0; +} + +// all functions must go through this one to emit bytes +// if as->pass < MP_ASM_PASS_EMIT, then this function just counts the number +// of bytes needed and returns NULL, and callers should not store any data +uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write) { + uint8_t *c = NULL; + if (as->pass == MP_ASM_PASS_EMIT) { + assert(as->code_offset + num_bytes_to_write <= as->code_size); + c = as->code_base + as->code_offset; + } + as->code_offset += num_bytes_to_write; + return c; +} + +void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label) { + assert(label < as->max_num_labels); + if (as->pass < MP_ASM_PASS_EMIT) { + // assign label offset + assert(as->label_offsets[label] == (size_t)-1); + as->label_offsets[label] = as->code_offset; + } else { + // ensure label offset has not changed from PASS_COMPUTE to PASS_EMIT + assert(as->label_offsets[label] == as->code_offset); + } +} + +// align must be a multiple of 2 +void mp_asm_base_align(mp_asm_base_t* as, unsigned int align) { + as->code_offset = (as->code_offset + align - 1) & (~(align - 1)); +} + +// this function assumes a little endian machine +void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val) { + uint8_t *c = mp_asm_base_get_cur_to_write_bytes(as, bytesize); + if (c != NULL) { + for (unsigned int i = 0; i < bytesize; i++) { + *c++ = val; + val >>= 8; + } + } +} + +#endif // MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM diff --git a/user/mpy/py/asmbase.h b/user/mpy/py/asmbase.h new file mode 100644 index 0000000..d2b4038 --- /dev/null +++ b/user/mpy/py/asmbase.h @@ -0,0 +1,69 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_ASMBASE_H +#define MICROPY_INCLUDED_PY_ASMBASE_H + +#include +#include + +#define MP_ASM_PASS_COMPUTE (1) +#define MP_ASM_PASS_EMIT (2) + +typedef struct _mp_asm_base_t { + int pass; + size_t code_offset; + size_t code_size; + uint8_t *code_base; + + size_t max_num_labels; + size_t *label_offsets; +} mp_asm_base_t; + +void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); +void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code); +void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); +uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); +void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); +void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); +void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); + +static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { + return as->code_offset; +} + +static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { + return as->code_size; +} + +static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { + #if defined(MP_PLAT_COMMIT_EXEC) + return MP_PLAT_COMMIT_EXEC(as->code_base, as->code_size); + #else + return as->code_base; + #endif +} + +#endif // MICROPY_INCLUDED_PY_ASMBASE_H diff --git a/user/mpy/py/asmthumb.c b/user/mpy/py/asmthumb.c new file mode 100644 index 0000000..4360a6a --- /dev/null +++ b/user/mpy/py/asmthumb.c @@ -0,0 +1,379 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpconfig.h" + +// wrapper around everything in this file +#if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB + +#include "py/asmthumb.h" + +#define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0) +#define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0) +#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) +#define SIGNED_FIT9(x) (((x) & 0xffffff00) == 0) || (((x) & 0xffffff00) == 0xffffff00) +#define SIGNED_FIT12(x) (((x) & 0xfffff800) == 0) || (((x) & 0xfffff800) == 0xfffff800) +#define SIGNED_FIT23(x) (((x) & 0xffc00000) == 0) || (((x) & 0xffc00000) == 0xffc00000) + +static inline byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int n) { + return mp_asm_base_get_cur_to_write_bytes(&as->base, n); +} + +void asm_thumb_end_pass(asm_thumb_t *as) { + (void)as; + // could check labels are resolved... + + #if defined(MCU_SERIES_F7) + if (as->base.pass == MP_ASM_PASS_EMIT) { + // flush D-cache, so the code emitted is stored in memory + SCB_CleanDCache_by_Addr((uint32_t*)as->base.code_base, as->base.code_size); + // invalidate I-cache + SCB_InvalidateICache(); + } + #endif +} + +/* +STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) { + byte *c = asm_thumb_get_cur_to_write_bytes(as, 1); + c[0] = b1; +} +*/ + +/* +#define IMM32_L0(x) ((x) & 0xff) +#define IMM32_L1(x) (((x) >> 8) & 0xff) +#define IMM32_L2(x) (((x) >> 16) & 0xff) +#define IMM32_L3(x) (((x) >> 24) & 0xff) + +STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) { + byte *c = asm_thumb_get_cur_to_write_bytes(as, 4); + c[0] = IMM32_L0(w32); + c[1] = IMM32_L1(w32); + c[2] = IMM32_L2(w32); + c[3] = IMM32_L3(w32); +} +*/ + +// rlolist is a bit map indicating desired lo-registers +#define OP_PUSH_RLIST(rlolist) (0xb400 | (rlolist)) +#define OP_PUSH_RLIST_LR(rlolist) (0xb400 | 0x0100 | (rlolist)) +#define OP_POP_RLIST(rlolist) (0xbc00 | (rlolist)) +#define OP_POP_RLIST_PC(rlolist) (0xbc00 | 0x0100 | (rlolist)) + +#define OP_ADD_SP(num_words) (0xb000 | (num_words)) +#define OP_SUB_SP(num_words) (0xb080 | (num_words)) + +// locals: +// - stored on the stack in ascending order +// - numbered 0 through num_locals-1 +// - SP points to first local +// +// | SP +// v +// l0 l1 l2 ... l(n-1) +// ^ ^ +// | low address | high address in RAM + +void asm_thumb_entry(asm_thumb_t *as, int num_locals) { + // work out what to push and how many extra spaces to reserve on stack + // so that we have enough for all locals and it's aligned an 8-byte boundary + // we push extra regs (r1, r2, r3) to help do the stack adjustment + // we probably should just always subtract from sp, since this would be more efficient + // for push rlist, lowest numbered register at the lowest address + uint reglist; + uint stack_adjust; + if (num_locals < 0) { + num_locals = 0; + } + // don't pop r0 because it's used for return value + switch (num_locals) { + case 0: + reglist = 0xf2; + stack_adjust = 0; + break; + + case 1: + reglist = 0xf2; + stack_adjust = 0; + break; + + case 2: + reglist = 0xfe; + stack_adjust = 0; + break; + + case 3: + reglist = 0xfe; + stack_adjust = 0; + break; + + default: + reglist = 0xfe; + stack_adjust = ((num_locals - 3) + 1) & (~1); + break; + } + asm_thumb_op16(as, OP_PUSH_RLIST_LR(reglist)); + if (stack_adjust > 0) { + asm_thumb_op16(as, OP_SUB_SP(stack_adjust)); + } + as->push_reglist = reglist; + as->stack_adjust = stack_adjust; +} + +void asm_thumb_exit(asm_thumb_t *as) { + if (as->stack_adjust > 0) { + asm_thumb_op16(as, OP_ADD_SP(as->stack_adjust)); + } + asm_thumb_op16(as, OP_POP_RLIST_PC(as->push_reglist)); +} + +STATIC mp_uint_t get_label_dest(asm_thumb_t *as, uint label) { + assert(label < as->base.max_num_labels); + return as->base.label_offsets[label]; +} + +void asm_thumb_op16(asm_thumb_t *as, uint op) { + byte *c = asm_thumb_get_cur_to_write_bytes(as, 2); + if (c != NULL) { + // little endian + c[0] = op; + c[1] = op >> 8; + } +} + +void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2) { + byte *c = asm_thumb_get_cur_to_write_bytes(as, 4); + if (c != NULL) { + // little endian, op1 then op2 + c[0] = op1; + c[1] = op1 >> 8; + c[2] = op2; + c[3] = op2 >> 8; + } +} + +#define OP_FORMAT_4(op, rlo_dest, rlo_src) ((op) | ((rlo_src) << 3) | (rlo_dest)) + +void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src) { + assert(rlo_dest < ASM_THUMB_REG_R8); + assert(rlo_src < ASM_THUMB_REG_R8); + asm_thumb_op16(as, OP_FORMAT_4(op, rlo_dest, rlo_src)); +} + +void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src) { + uint op_lo; + if (reg_src < 8) { + op_lo = reg_src << 3; + } else { + op_lo = 0x40 | ((reg_src - 8) << 3); + } + if (reg_dest < 8) { + op_lo |= reg_dest; + } else { + op_lo |= 0x80 | (reg_dest - 8); + } + // mov reg_dest, reg_src + asm_thumb_op16(as, 0x4600 | op_lo); +} + +// if loading lo half with movw, the i16 value will be zero extended into the r32 register! +void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) { + assert(reg_dest < ASM_THUMB_REG_R15); + // mov[wt] reg_dest, #i16_src + asm_thumb_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), ((i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff)); +} + +#define OP_B_N(byte_offset) (0xe000 | (((byte_offset) >> 1) & 0x07ff)) + +bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction + asm_thumb_op16(as, OP_B_N(rel)); + return as->base.pass != MP_ASM_PASS_EMIT || SIGNED_FIT12(rel); +} + +#define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff)) + +// all these bit arithmetics need coverage testing! +#define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f)) +#define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff)) + +bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction + if (!wide) { + asm_thumb_op16(as, OP_BCC_N(cond, rel)); + return as->base.pass != MP_ASM_PASS_EMIT || SIGNED_FIT9(rel); + } else { + asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel)); + return true; + } +} + +#define OP_BL_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff)) +#define OP_BL_LO(byte_offset) (0xf800 | (((byte_offset) >> 1) & 0x07ff)) + +bool asm_thumb_bl_label(asm_thumb_t *as, uint label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction + asm_thumb_op32(as, OP_BL_HI(rel), OP_BL_LO(rel)); + return as->base.pass != MP_ASM_PASS_EMIT || SIGNED_FIT23(rel); +} + +void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32) { + // movw, movt does it in 8 bytes + // ldr [pc, #], dw does it in 6 bytes, but we might not reach to end of code for dw + + asm_thumb_mov_reg_i16(as, ASM_THUMB_OP_MOVW, reg_dest, i32); + asm_thumb_mov_reg_i16(as, ASM_THUMB_OP_MOVT, reg_dest, i32 >> 16); +} + +void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32) { + if (reg_dest < 8 && UNSIGNED_FIT8(i32)) { + asm_thumb_mov_rlo_i8(as, reg_dest, i32); + } else if (UNSIGNED_FIT16(i32)) { + asm_thumb_mov_reg_i16(as, ASM_THUMB_OP_MOVW, reg_dest, i32); + } else { + asm_thumb_mov_reg_i32(as, reg_dest, i32); + } +} + +// i32 is stored as a full word in the code, and aligned to machine-word boundary +// TODO this is very inefficient, improve it! +void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32) { + // align on machine-word + 2 + if ((as->base.code_offset & 3) == 0) { + asm_thumb_op16(as, ASM_THUMB_OP_NOP); + } + // jump over the i32 value (instruction prefetch adds 2 to PC) + asm_thumb_op16(as, OP_B_N(2)); + // store i32 on machine-word aligned boundary + mp_asm_base_data(&as->base, 4, i32); + // do the actual load of the i32 value + asm_thumb_mov_reg_i32_optimised(as, reg_dest, i32); +} + +#define OP_STR_TO_SP_OFFSET(rlo_dest, word_offset) (0x9000 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) +#define OP_LDR_FROM_SP_OFFSET(rlo_dest, word_offset) (0x9800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) + +void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num, uint rlo_src) { + assert(rlo_src < ASM_THUMB_REG_R8); + int word_offset = local_num; + assert(as->base.pass < MP_ASM_PASS_EMIT || word_offset >= 0); + asm_thumb_op16(as, OP_STR_TO_SP_OFFSET(rlo_src, word_offset)); +} + +void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num) { + assert(rlo_dest < ASM_THUMB_REG_R8); + int word_offset = local_num; + assert(as->base.pass < MP_ASM_PASS_EMIT || word_offset >= 0); + asm_thumb_op16(as, OP_LDR_FROM_SP_OFFSET(rlo_dest, word_offset)); +} + +#define OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset) (0xa800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) + +void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num) { + assert(rlo_dest < ASM_THUMB_REG_R8); + int word_offset = local_num; + assert(as->base.pass < MP_ASM_PASS_EMIT || word_offset >= 0); + asm_thumb_op16(as, OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset)); +} + +// this could be wrong, because it should have a range of +/- 16MiB... +#define OP_BW_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff)) +#define OP_BW_LO(byte_offset) (0xb800 | (((byte_offset) >> 1) & 0x07ff)) + +void asm_thumb_b_label(asm_thumb_t *as, uint label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction + if (dest != (mp_uint_t)-1 && rel <= -4) { + // is a backwards jump, so we know the size of the jump on the first pass + // calculate rel assuming 12 bit relative jump + if (SIGNED_FIT12(rel)) { + asm_thumb_op16(as, OP_B_N(rel)); + } else { + goto large_jump; + } + } else { + // is a forwards jump, so need to assume it's large + large_jump: + asm_thumb_op32(as, OP_BW_HI(rel), OP_BW_LO(rel)); + } +} + +void asm_thumb_bcc_label(asm_thumb_t *as, int cond, uint label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction + if (dest != (mp_uint_t)-1 && rel <= -4) { + // is a backwards jump, so we know the size of the jump on the first pass + // calculate rel assuming 9 bit relative jump + if (SIGNED_FIT9(rel)) { + asm_thumb_op16(as, OP_BCC_N(cond, rel)); + } else { + goto large_jump; + } + } else { + // is a forwards jump, so need to assume it's large + large_jump: + asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel)); + } +} + +#define OP_BLX(reg) (0x4780 | ((reg) << 3)) +#define OP_SVC(arg) (0xdf00 | (arg)) + +void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp) { + /* TODO make this use less bytes + uint rlo_base = ASM_THUMB_REG_R3; + uint rlo_dest = ASM_THUMB_REG_R7; + uint word_offset = 4; + asm_thumb_op16(as, 0x0000); + asm_thumb_op16(as, 0x6800 | (word_offset << 6) | (rlo_base << 3) | rlo_dest); // ldr rlo_dest, [rlo_base, #offset] + asm_thumb_op16(as, 0x4780 | (ASM_THUMB_REG_R9 << 3)); // blx reg + */ + + if (fun_id < 32) { + // load ptr to function from table, indexed by fun_id (must be in range 0-31); 4 bytes + asm_thumb_op16(as, ASM_THUMB_FORMAT_9_10_ENCODE(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, reg_temp, ASM_THUMB_REG_R7, fun_id)); + asm_thumb_op16(as, OP_BLX(reg_temp)); + } else { + // load ptr to function into register using immediate; 6 bytes + asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr); + asm_thumb_op16(as, OP_BLX(reg_temp)); + } +} + +#endif // MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB diff --git a/user/mpy/py/asmthumb.h b/user/mpy/py/asmthumb.h new file mode 100644 index 0000000..7070e03 --- /dev/null +++ b/user/mpy/py/asmthumb.h @@ -0,0 +1,321 @@ +/* + * 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_ASMTHUMB_H +#define MICROPY_INCLUDED_PY_ASMTHUMB_H + +#include "py/misc.h" +#include "py/asmbase.h" + +#define ASM_THUMB_REG_R0 (0) +#define ASM_THUMB_REG_R1 (1) +#define ASM_THUMB_REG_R2 (2) +#define ASM_THUMB_REG_R3 (3) +#define ASM_THUMB_REG_R4 (4) +#define ASM_THUMB_REG_R5 (5) +#define ASM_THUMB_REG_R6 (6) +#define ASM_THUMB_REG_R7 (7) +#define ASM_THUMB_REG_R8 (8) +#define ASM_THUMB_REG_R9 (9) +#define ASM_THUMB_REG_R10 (10) +#define ASM_THUMB_REG_R11 (11) +#define ASM_THUMB_REG_R12 (12) +#define ASM_THUMB_REG_R13 (13) +#define ASM_THUMB_REG_R14 (14) +#define ASM_THUMB_REG_R15 (15) +#define ASM_THUMB_REG_LR (REG_R14) + +#define ASM_THUMB_CC_EQ (0x0) +#define ASM_THUMB_CC_NE (0x1) +#define ASM_THUMB_CC_CS (0x2) +#define ASM_THUMB_CC_CC (0x3) +#define ASM_THUMB_CC_MI (0x4) +#define ASM_THUMB_CC_PL (0x5) +#define ASM_THUMB_CC_VS (0x6) +#define ASM_THUMB_CC_VC (0x7) +#define ASM_THUMB_CC_HI (0x8) +#define ASM_THUMB_CC_LS (0x9) +#define ASM_THUMB_CC_GE (0xa) +#define ASM_THUMB_CC_LT (0xb) +#define ASM_THUMB_CC_GT (0xc) +#define ASM_THUMB_CC_LE (0xd) + +typedef struct _asm_thumb_t { + mp_asm_base_t base; + uint32_t push_reglist; + uint32_t stack_adjust; +} asm_thumb_t; + +void asm_thumb_end_pass(asm_thumb_t *as); + +void asm_thumb_entry(asm_thumb_t *as, int num_locals); +void asm_thumb_exit(asm_thumb_t *as); + +// argument order follows ARM, in general dest is first +// note there is a difference between movw and mov.w, and many others! + +#define ASM_THUMB_OP_IT (0xbf00) +#define ASM_THUMB_OP_ITE_EQ (0xbf0c) +#define ASM_THUMB_OP_ITE_CS (0xbf2c) +#define ASM_THUMB_OP_ITE_MI (0xbf4c) +#define ASM_THUMB_OP_ITE_VS (0xbf6c) +#define ASM_THUMB_OP_ITE_HI (0xbf8c) +#define ASM_THUMB_OP_ITE_GE (0xbfac) +#define ASM_THUMB_OP_ITE_GT (0xbfcc) + +#define ASM_THUMB_OP_NOP (0xbf00) +#define ASM_THUMB_OP_WFI (0xbf30) +#define ASM_THUMB_OP_CPSID_I (0xb672) // cpsid i, disable irq +#define ASM_THUMB_OP_CPSIE_I (0xb662) // cpsie i, enable irq + +void asm_thumb_op16(asm_thumb_t *as, uint op); +void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2); + +static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask) + { asm_thumb_op16(as, ASM_THUMB_OP_IT | (cc << 4) | mask); } + +// FORMAT 1: move shifted register + +#define ASM_THUMB_FORMAT_1_LSL (0x0000) +#define ASM_THUMB_FORMAT_1_LSR (0x0800) +#define ASM_THUMB_FORMAT_1_ASR (0x1000) + +#define ASM_THUMB_FORMAT_1_ENCODE(op, rlo_dest, rlo_src, offset) \ + ((op) | ((offset) << 6) | ((rlo_src) << 3) | (rlo_dest)) + +static inline void asm_thumb_format_1(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, uint offset) { + assert(rlo_dest < ASM_THUMB_REG_R8); + assert(rlo_src < ASM_THUMB_REG_R8); + asm_thumb_op16(as, ASM_THUMB_FORMAT_1_ENCODE(op, rlo_dest, rlo_src, offset)); +} + +// FORMAT 2: add/subtract + +#define ASM_THUMB_FORMAT_2_ADD (0x1800) +#define ASM_THUMB_FORMAT_2_SUB (0x1a00) +#define ASM_THUMB_FORMAT_2_REG_OPERAND (0x0000) +#define ASM_THUMB_FORMAT_2_IMM_OPERAND (0x0400) + +#define ASM_THUMB_FORMAT_2_ENCODE(op, rlo_dest, rlo_src, src_b) \ + ((op) | ((src_b) << 6) | ((rlo_src) << 3) | (rlo_dest)) + +static inline void asm_thumb_format_2(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, int src_b) { + assert(rlo_dest < ASM_THUMB_REG_R8); + assert(rlo_src < ASM_THUMB_REG_R8); + asm_thumb_op16(as, ASM_THUMB_FORMAT_2_ENCODE(op, rlo_dest, rlo_src, src_b)); +} + +static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) + { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b); } +static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) + { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src); } +static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) + { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b); } +static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) + { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src); } + +// FORMAT 3: move/compare/add/subtract immediate +// These instructions all do zero extension of the i8 value + +#define ASM_THUMB_FORMAT_3_MOV (0x2000) +#define ASM_THUMB_FORMAT_3_CMP (0x2800) +#define ASM_THUMB_FORMAT_3_ADD (0x3000) +#define ASM_THUMB_FORMAT_3_SUB (0x3800) + +#define ASM_THUMB_FORMAT_3_ENCODE(op, rlo, i8) ((op) | ((rlo) << 8) | (i8)) + +static inline void asm_thumb_format_3(asm_thumb_t *as, uint op, uint rlo, int i8) { + assert(rlo < ASM_THUMB_REG_R8); + asm_thumb_op16(as, ASM_THUMB_FORMAT_3_ENCODE(op, rlo, i8)); +} + +static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_MOV, rlo, i8); } +static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_CMP, rlo, i8); } +static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_ADD, rlo, i8); } +static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_SUB, rlo, i8); } + +// FORMAT 4: ALU operations + +#define ASM_THUMB_FORMAT_4_AND (0x4000) +#define ASM_THUMB_FORMAT_4_EOR (0x4040) +#define ASM_THUMB_FORMAT_4_LSL (0x4080) +#define ASM_THUMB_FORMAT_4_LSR (0x40c0) +#define ASM_THUMB_FORMAT_4_ASR (0x4100) +#define ASM_THUMB_FORMAT_4_ADC (0x4140) +#define ASM_THUMB_FORMAT_4_SBC (0x4180) +#define ASM_THUMB_FORMAT_4_ROR (0x41c0) +#define ASM_THUMB_FORMAT_4_TST (0x4200) +#define ASM_THUMB_FORMAT_4_NEG (0x4240) +#define ASM_THUMB_FORMAT_4_CMP (0x4280) +#define ASM_THUMB_FORMAT_4_CMN (0x42c0) +#define ASM_THUMB_FORMAT_4_ORR (0x4300) +#define ASM_THUMB_FORMAT_4_MUL (0x4340) +#define ASM_THUMB_FORMAT_4_BIC (0x4380) +#define ASM_THUMB_FORMAT_4_MVN (0x43c0) + +void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src); + +static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src) { asm_thumb_format_4(as, ASM_THUMB_FORMAT_4_CMP, rlo_dest, rlo_src); } + +// FORMAT 9: load/store with immediate offset +// For word transfers the offset must be aligned, and >>2 + +// FORMAT 10: load/store halfword +// The offset must be aligned, and >>1 +// The load is zero extended into the register + +#define ASM_THUMB_FORMAT_9_STR (0x6000) +#define ASM_THUMB_FORMAT_9_LDR (0x6800) +#define ASM_THUMB_FORMAT_9_WORD_TRANSFER (0x0000) +#define ASM_THUMB_FORMAT_9_BYTE_TRANSFER (0x1000) + +#define ASM_THUMB_FORMAT_10_STRH (0x8000) +#define ASM_THUMB_FORMAT_10_LDRH (0x8800) + +#define ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset) \ + ((op) | (((offset) << 6) & 0x07c0) | ((rlo_base) << 3) | (rlo_dest)) + +static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_base, uint offset) + { asm_thumb_op16(as, ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset)); } + +static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint word_offset) + { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_src, rlo_base, word_offset); } +static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER, rlo_src, rlo_base, byte_offset); } +static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_STRH, rlo_src, rlo_base, byte_offset); } +static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint word_offset) + { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_dest, rlo_base, word_offset); } +static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER , rlo_dest, rlo_base, byte_offset); } +static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) + { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_LDRH, rlo_dest, rlo_base, byte_offset); } + +// TODO convert these to above format style + +#define ASM_THUMB_OP_MOVW (0xf240) +#define ASM_THUMB_OP_MOVT (0xf2c0) + +void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src); +void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src); + +// these return true if the destination is in range, false otherwise +bool asm_thumb_b_n_label(asm_thumb_t *as, uint label); +bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide); +bool asm_thumb_bl_label(asm_thumb_t *as, uint label); + +void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32_src); // convenience +void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32_src); // convenience +void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32); // convenience +void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num_dest, uint rlo_src); // convenience +void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num); // convenience +void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num); // convenience + +void asm_thumb_b_label(asm_thumb_t *as, uint label); // convenience: picks narrow or wide branch +void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); // convenience: picks narrow or wide branch +void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); // convenience + +#if GENERIC_ASM_API + +// The following macros provide a (mostly) arch-independent API to +// generate native code, and are used by the native emitter. + +#define ASM_WORD_SIZE (4) + +#define REG_RET ASM_THUMB_REG_R0 +#define REG_ARG_1 ASM_THUMB_REG_R0 +#define REG_ARG_2 ASM_THUMB_REG_R1 +#define REG_ARG_3 ASM_THUMB_REG_R2 +#define REG_ARG_4 ASM_THUMB_REG_R3 +// rest of args go on stack + +#define REG_TEMP0 ASM_THUMB_REG_R0 +#define REG_TEMP1 ASM_THUMB_REG_R1 +#define REG_TEMP2 ASM_THUMB_REG_R2 + +#define REG_LOCAL_1 ASM_THUMB_REG_R4 +#define REG_LOCAL_2 ASM_THUMB_REG_R5 +#define REG_LOCAL_3 ASM_THUMB_REG_R6 +#define REG_LOCAL_NUM (3) + +#define ASM_T asm_thumb_t +#define ASM_END_PASS asm_thumb_end_pass +#define ASM_ENTRY asm_thumb_entry +#define ASM_EXIT asm_thumb_exit + +#define ASM_JUMP asm_thumb_b_label +#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ + do { \ + asm_thumb_cmp_rlo_i8(as, reg, 0); \ + asm_thumb_bcc_label(as, ASM_THUMB_CC_EQ, label); \ + } while (0) +#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ + do { \ + asm_thumb_cmp_rlo_i8(as, reg, 0); \ + asm_thumb_bcc_label(as, ASM_THUMB_CC_NE, label); \ + } while (0) +#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ + do { \ + asm_thumb_cmp_rlo_rlo(as, reg1, reg2); \ + asm_thumb_bcc_label(as, ASM_THUMB_CC_EQ, label); \ + } while (0) +#define ASM_CALL_IND(as, ptr, idx) asm_thumb_bl_ind(as, ptr, idx, ASM_THUMB_REG_R3) + +#define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_thumb_mov_local_reg(as, (local_num), (reg)) +#define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_thumb_mov_reg_i32_optimised(as, (reg), (imm)) +#define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_thumb_mov_reg_i32_aligned(as, (reg), (imm)) +#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ + do { \ + asm_thumb_mov_reg_i32_optimised(as, (reg_temp), (imm)); \ + asm_thumb_mov_local_reg(as, (local_num), (reg_temp)); \ + } while (false) +#define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_thumb_mov_reg_local(as, (reg), (local_num)) +#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_thumb_mov_reg_reg((as), (reg_dest), (reg_src)) +#define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_thumb_mov_reg_local_addr(as, (reg), (local_num)) + +#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSL, (reg_dest), (reg_shift)) +#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ASR, (reg_dest), (reg_shift)) +#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ORR, (reg_dest), (reg_src)) +#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_EOR, (reg_dest), (reg_src)) +#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_AND, (reg_dest), (reg_src)) +#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_thumb_add_rlo_rlo_rlo((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_thumb_sub_rlo_rlo_rlo((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_MUL, (reg_dest), (reg_src)) + +#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_thumb_ldr_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) +#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_thumb_ldr_rlo_rlo_i5((as), (reg_dest), (reg_base), (word_offset)) +#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_thumb_ldrb_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) +#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_thumb_ldrh_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) +#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_thumb_ldr_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) + +#define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_thumb_str_rlo_rlo_i5((as), (reg_src), (reg_base), 0) +#define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_thumb_str_rlo_rlo_i5((as), (reg_src), (reg_base), (word_offset)) +#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_thumb_strb_rlo_rlo_i5((as), (reg_src), (reg_base), 0) +#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_thumb_strh_rlo_rlo_i5((as), (reg_src), (reg_base), 0) +#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_thumb_str_rlo_rlo_i5((as), (reg_src), (reg_base), 0) + +#endif // GENERIC_ASM_API + +#endif // MICROPY_INCLUDED_PY_ASMTHUMB_H diff --git a/user/mpy/py/asmx64.c b/user/mpy/py/asmx64.c new file mode 100644 index 0000000..aa2a8ec --- /dev/null +++ b/user/mpy/py/asmx64.c @@ -0,0 +1,632 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/mpconfig.h" + +// wrapper around everything in this file +#if MICROPY_EMIT_X64 + +#include "py/asmx64.h" + +/* all offsets are measured in multiples of 8 bytes */ +#define WORD_SIZE (8) + +#define OPCODE_NOP (0x90) +#define OPCODE_PUSH_R64 (0x50) /* +rq */ +#define OPCODE_PUSH_I64 (0x68) +#define OPCODE_PUSH_M64 (0xff) /* /6 */ +#define OPCODE_POP_R64 (0x58) /* +rq */ +#define OPCODE_RET (0xc3) +#define OPCODE_MOV_I8_TO_R8 (0xb0) /* +rb */ +#define OPCODE_MOV_I64_TO_R64 (0xb8) /* +rq */ +#define OPCODE_MOV_I32_TO_RM32 (0xc7) +#define OPCODE_MOV_R8_TO_RM8 (0x88) /* /r */ +#define OPCODE_MOV_R64_TO_RM64 (0x89) /* /r */ +#define OPCODE_MOV_RM64_TO_R64 (0x8b) /* /r */ +#define OPCODE_MOVZX_RM8_TO_R64 (0xb6) /* 0x0f 0xb6/r */ +#define OPCODE_MOVZX_RM16_TO_R64 (0xb7) /* 0x0f 0xb7/r */ +#define OPCODE_LEA_MEM_TO_R64 (0x8d) /* /r */ +#define OPCODE_AND_R64_TO_RM64 (0x21) /* /r */ +#define OPCODE_OR_R64_TO_RM64 (0x09) /* /r */ +#define OPCODE_XOR_R64_TO_RM64 (0x31) /* /r */ +#define OPCODE_ADD_R64_TO_RM64 (0x01) /* /r */ +#define OPCODE_ADD_I32_TO_RM32 (0x81) /* /0 */ +#define OPCODE_ADD_I8_TO_RM32 (0x83) /* /0 */ +#define OPCODE_SUB_R64_FROM_RM64 (0x29) +#define OPCODE_SUB_I32_FROM_RM64 (0x81) /* /5 */ +#define OPCODE_SUB_I8_FROM_RM64 (0x83) /* /5 */ +//#define OPCODE_SHL_RM32_BY_I8 (0xc1) /* /4 */ +//#define OPCODE_SHR_RM32_BY_I8 (0xc1) /* /5 */ +//#define OPCODE_SAR_RM32_BY_I8 (0xc1) /* /7 */ +#define OPCODE_SHL_RM64_CL (0xd3) /* /4 */ +#define OPCODE_SAR_RM64_CL (0xd3) /* /7 */ +//#define OPCODE_CMP_I32_WITH_RM32 (0x81) /* /7 */ +//#define OPCODE_CMP_I8_WITH_RM32 (0x83) /* /7 */ +#define OPCODE_CMP_R64_WITH_RM64 (0x39) /* /r */ +//#define OPCODE_CMP_RM32_WITH_R32 (0x3b) +#define OPCODE_TEST_R8_WITH_RM8 (0x84) /* /r */ +#define OPCODE_JMP_REL8 (0xeb) +#define OPCODE_JMP_REL32 (0xe9) +#define OPCODE_JCC_REL8 (0x70) /* | jcc type */ +#define OPCODE_JCC_REL32_A (0x0f) +#define OPCODE_JCC_REL32_B (0x80) /* | jcc type */ +#define OPCODE_SETCC_RM8_A (0x0f) +#define OPCODE_SETCC_RM8_B (0x90) /* | jcc type, /0 */ +#define OPCODE_CALL_REL32 (0xe8) +#define OPCODE_CALL_RM32 (0xff) /* /2 */ +#define OPCODE_LEAVE (0xc9) + +#define MODRM_R64(x) (((x) & 0x7) << 3) +#define MODRM_RM_DISP0 (0x00) +#define MODRM_RM_DISP8 (0x40) +#define MODRM_RM_DISP32 (0x80) +#define MODRM_RM_REG (0xc0) +#define MODRM_RM_R64(x) ((x) & 0x7) + +#define OP_SIZE_PREFIX (0x66) + +#define REX_PREFIX (0x40) +#define REX_W (0x08) // width +#define REX_R (0x04) // register +#define REX_X (0x02) // index +#define REX_B (0x01) // base +#define REX_W_FROM_R64(r64) ((r64) >> 0 & 0x08) +#define REX_R_FROM_R64(r64) ((r64) >> 1 & 0x04) +#define REX_X_FROM_R64(r64) ((r64) >> 2 & 0x02) +#define REX_B_FROM_R64(r64) ((r64) >> 3 & 0x01) + +#define IMM32_L0(x) ((x) & 0xff) +#define IMM32_L1(x) (((x) >> 8) & 0xff) +#define IMM32_L2(x) (((x) >> 16) & 0xff) +#define IMM32_L3(x) (((x) >> 24) & 0xff) +#define IMM64_L4(x) (((x) >> 32) & 0xff) +#define IMM64_L5(x) (((x) >> 40) & 0xff) +#define IMM64_L6(x) (((x) >> 48) & 0xff) +#define IMM64_L7(x) (((x) >> 56) & 0xff) + +#define UNSIGNED_FIT8(x) (((x) & 0xffffffffffffff00) == 0) +#define UNSIGNED_FIT32(x) (((x) & 0xffffffff00000000) == 0) +#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) + +static inline byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int n) { + return mp_asm_base_get_cur_to_write_bytes(&as->base, n); +} + +STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) { + byte* c = asm_x64_get_cur_to_write_bytes(as, 1); + if (c != NULL) { + c[0] = b1; + } +} + +STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) { + byte* c = asm_x64_get_cur_to_write_bytes(as, 2); + if (c != NULL) { + c[0] = b1; + c[1] = b2; + } +} + +STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) { + byte* c = asm_x64_get_cur_to_write_bytes(as, 3); + if (c != NULL) { + c[0] = b1; + c[1] = b2; + c[2] = b3; + } +} + +STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) { + byte* c = asm_x64_get_cur_to_write_bytes(as, 4); + if (c != NULL) { + c[0] = IMM32_L0(w32); + c[1] = IMM32_L1(w32); + c[2] = IMM32_L2(w32); + c[3] = IMM32_L3(w32); + } +} + +STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) { + byte* c = asm_x64_get_cur_to_write_bytes(as, 8); + if (c != NULL) { + c[0] = IMM32_L0(w64); + c[1] = IMM32_L1(w64); + c[2] = IMM32_L2(w64); + c[3] = IMM32_L3(w64); + c[4] = IMM64_L4(w64); + c[5] = IMM64_L5(w64); + c[6] = IMM64_L6(w64); + c[7] = IMM64_L7(w64); + } +} + +/* unused +STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) { + byte* c; + assert(offset + 4 <= as->code_size); + c = as->code_base + offset; + c[0] = IMM32_L0(w32); + c[1] = IMM32_L1(w32); + c[2] = IMM32_L2(w32); + c[3] = IMM32_L3(w32); +} +*/ + +STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) { + assert(disp_r64 != ASM_X64_REG_RSP); + + if (disp_r64 == ASM_X64_REG_R12) { + // special case for r12; not fully implemented + assert(SIGNED_FIT8(disp_offset)); + asm_x64_write_byte_3(as, MODRM_R64(r64) | MODRM_RM_DISP8 | MODRM_RM_R64(disp_r64), 0x24, IMM32_L0(disp_offset)); + return; + } + + if (disp_offset == 0 && disp_r64 != ASM_X64_REG_RBP) { + asm_x64_write_byte_1(as, MODRM_R64(r64) | MODRM_RM_DISP0 | MODRM_RM_R64(disp_r64)); + } else if (SIGNED_FIT8(disp_offset)) { + asm_x64_write_byte_2(as, MODRM_R64(r64) | MODRM_RM_DISP8 | MODRM_RM_R64(disp_r64), IMM32_L0(disp_offset)); + } else { + asm_x64_write_byte_1(as, MODRM_R64(r64) | MODRM_RM_DISP32 | MODRM_RM_R64(disp_r64)); + asm_x64_write_word32(as, disp_offset); + } +} + +STATIC void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) { + asm_x64_write_byte_3(as, REX_PREFIX | REX_W | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), op, MODRM_R64(src_r64) | MODRM_RM_REG | MODRM_RM_R64(dest_r64)); +} + +void asm_x64_nop(asm_x64_t *as) { + asm_x64_write_byte_1(as, OPCODE_NOP); +} + +void asm_x64_push_r64(asm_x64_t *as, int src_r64) { + if (src_r64 < 8) { + asm_x64_write_byte_1(as, OPCODE_PUSH_R64 | src_r64); + } else { + asm_x64_write_byte_2(as, REX_PREFIX | REX_B, OPCODE_PUSH_R64 | (src_r64 & 7)); + } +} + +/* +void asm_x64_push_i32(asm_x64_t *as, int src_i32) { + asm_x64_write_byte_1(as, OPCODE_PUSH_I64); + asm_x64_write_word32(as, src_i32); // will be sign extended to 64 bits +} +*/ + +/* +void asm_x64_push_disp(asm_x64_t *as, int src_r64, int src_offset) { + assert(src_r64 < 8); + asm_x64_write_byte_1(as, OPCODE_PUSH_M64); + asm_x64_write_r64_disp(as, 6, src_r64, src_offset); +} +*/ + +void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) { + if (dest_r64 < 8) { + asm_x64_write_byte_1(as, OPCODE_POP_R64 | dest_r64); + } else { + asm_x64_write_byte_2(as, REX_PREFIX | REX_B, OPCODE_POP_R64 | (dest_r64 & 7)); + } +} + +STATIC void asm_x64_ret(asm_x64_t *as) { + asm_x64_write_byte_1(as, OPCODE_RET); +} + +void asm_x64_mov_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_MOV_R64_TO_RM64); +} + +void asm_x64_mov_r8_to_mem8(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { + if (src_r64 < 8 && dest_r64 < 8) { + asm_x64_write_byte_1(as, OPCODE_MOV_R8_TO_RM8); + } else { + asm_x64_write_byte_2(as, REX_PREFIX | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R8_TO_RM8); + } + asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); +} + +void asm_x64_mov_r16_to_mem16(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { + if (src_r64 < 8 && dest_r64 < 8) { + asm_x64_write_byte_2(as, OP_SIZE_PREFIX, OPCODE_MOV_R64_TO_RM64); + } else { + asm_x64_write_byte_3(as, OP_SIZE_PREFIX, REX_PREFIX | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R64_TO_RM64); + } + asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); +} + +void asm_x64_mov_r32_to_mem32(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { + if (src_r64 < 8 && dest_r64 < 8) { + asm_x64_write_byte_1(as, OPCODE_MOV_R64_TO_RM64); + } else { + asm_x64_write_byte_2(as, REX_PREFIX | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R64_TO_RM64); + } + asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); +} + +void asm_x64_mov_r64_to_mem64(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { + // use REX prefix for 64 bit operation + asm_x64_write_byte_2(as, REX_PREFIX | REX_W | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R64_TO_RM64); + asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); +} + +void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { + assert(src_r64 < 8); + if (dest_r64 < 8) { + asm_x64_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM8_TO_R64); + } else { + asm_x64_write_byte_3(as, REX_PREFIX | REX_R, 0x0f, OPCODE_MOVZX_RM8_TO_R64); + } + asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); +} + +void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { + assert(src_r64 < 8); + if (dest_r64 < 8) { + asm_x64_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM16_TO_R64); + } else { + asm_x64_write_byte_3(as, REX_PREFIX | REX_R, 0x0f, OPCODE_MOVZX_RM16_TO_R64); + } + asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); +} + +void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { + assert(src_r64 < 8); + if (dest_r64 < 8) { + asm_x64_write_byte_1(as, OPCODE_MOV_RM64_TO_R64); + } else { + asm_x64_write_byte_2(as, REX_PREFIX | REX_R, OPCODE_MOV_RM64_TO_R64); + } + asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); +} + +void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { + // use REX prefix for 64 bit operation + asm_x64_write_byte_2(as, REX_PREFIX | REX_W | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), OPCODE_MOV_RM64_TO_R64); + asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); +} + +STATIC void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { + // use REX prefix for 64 bit operation + assert(src_r64 < 8); + assert(dest_r64 < 8); + asm_x64_write_byte_2(as, REX_PREFIX | REX_W, OPCODE_LEA_MEM_TO_R64); + asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); +} + +/* +void asm_x64_mov_i8_to_r8(asm_x64_t *as, int src_i8, int dest_r64) { + assert(dest_r64 < 8); + asm_x64_write_byte_2(as, OPCODE_MOV_I8_TO_R8 | dest_r64, src_i8); +} +*/ + +STATIC void asm_x64_mov_i32_to_r64(asm_x64_t *as, int src_i32, int dest_r64) { + // cpu defaults to i32 to r64, with zero extension + if (dest_r64 < 8) { + asm_x64_write_byte_1(as, OPCODE_MOV_I64_TO_R64 | dest_r64); + } else { + asm_x64_write_byte_2(as, REX_PREFIX | REX_B, OPCODE_MOV_I64_TO_R64 | (dest_r64 & 7)); + } + asm_x64_write_word32(as, src_i32); +} + +void asm_x64_mov_i64_to_r64(asm_x64_t *as, int64_t src_i64, int dest_r64) { + // cpu defaults to i32 to r64 + // to mov i64 to r64 need to use REX prefix + asm_x64_write_byte_2(as, + REX_PREFIX | REX_W | (dest_r64 < 8 ? 0 : REX_B), + OPCODE_MOV_I64_TO_R64 | (dest_r64 & 7)); + asm_x64_write_word64(as, src_i64); +} + +void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r64) { + // TODO use movzx, movsx if possible + if (UNSIGNED_FIT32(src_i64)) { + // 5 bytes + asm_x64_mov_i32_to_r64(as, src_i64 & 0xffffffff, dest_r64); + } else { + // 10 bytes + asm_x64_mov_i64_to_r64(as, src_i64, dest_r64); + } +} + +// src_i64 is stored as a full word in the code, and aligned to machine-word boundary +void asm_x64_mov_i64_to_r64_aligned(asm_x64_t *as, int64_t src_i64, int dest_r64) { + // mov instruction uses 2 bytes for the instruction, before the i64 + while (((as->base.code_offset + 2) & (WORD_SIZE - 1)) != 0) { + asm_x64_nop(as); + } + asm_x64_mov_i64_to_r64(as, src_i64, dest_r64); +} + +void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_AND_R64_TO_RM64); +} + +void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_OR_R64_TO_RM64); +} + +void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_XOR_R64_TO_RM64); +} + +void asm_x64_shl_r64_cl(asm_x64_t* as, int dest_r64) { + asm_x64_generic_r64_r64(as, dest_r64, 4, OPCODE_SHL_RM64_CL); +} + +void asm_x64_sar_r64_cl(asm_x64_t* as, int dest_r64) { + asm_x64_generic_r64_r64(as, dest_r64, 7, OPCODE_SAR_RM64_CL); +} + +void asm_x64_add_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_ADD_R64_TO_RM64); +} + +void asm_x64_sub_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_SUB_R64_FROM_RM64); +} + +void asm_x64_mul_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { + // imul reg64, reg/mem64 -- 0x0f 0xaf /r + asm_x64_write_byte_1(as, REX_PREFIX | REX_W | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64)); + asm_x64_write_byte_3(as, 0x0f, 0xaf, MODRM_R64(dest_r64) | MODRM_RM_REG | MODRM_RM_R64(src_r64)); +} + +/* +void asm_x64_sub_i32_from_r32(asm_x64_t *as, int src_i32, int dest_r32) { + if (SIGNED_FIT8(src_i32)) { + // defaults to 32 bit operation + asm_x64_write_byte_2(as, OPCODE_SUB_I8_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r32)); + asm_x64_write_byte_1(as, src_i32 & 0xff); + } else { + // defaults to 32 bit operation + asm_x64_write_byte_2(as, OPCODE_SUB_I32_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r32)); + asm_x64_write_word32(as, src_i32); + } +} +*/ + +STATIC void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) { + assert(dest_r64 < 8); + if (SIGNED_FIT8(src_i32)) { + // use REX prefix for 64 bit operation + asm_x64_write_byte_3(as, REX_PREFIX | REX_W, OPCODE_SUB_I8_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r64)); + asm_x64_write_byte_1(as, src_i32 & 0xff); + } else { + // use REX prefix for 64 bit operation + asm_x64_write_byte_3(as, REX_PREFIX | REX_W, OPCODE_SUB_I32_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r64)); + asm_x64_write_word32(as, src_i32); + } +} + +/* +void asm_x64_shl_r32_by_imm(asm_x64_t *as, int r32, int imm) { + asm_x64_write_byte_2(as, OPCODE_SHL_RM32_BY_I8, MODRM_R64(4) | MODRM_RM_REG | MODRM_RM_R64(r32)); + asm_x64_write_byte_1(as, imm); +} + +void asm_x64_shr_r32_by_imm(asm_x64_t *as, int r32, int imm) { + asm_x64_write_byte_2(as, OPCODE_SHR_RM32_BY_I8, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(r32)); + asm_x64_write_byte_1(as, imm); +} + +void asm_x64_sar_r32_by_imm(asm_x64_t *as, int r32, int imm) { + asm_x64_write_byte_2(as, OPCODE_SAR_RM32_BY_I8, MODRM_R64(7) | MODRM_RM_REG | MODRM_RM_R64(r32)); + asm_x64_write_byte_1(as, imm); +} +*/ + +void asm_x64_cmp_r64_with_r64(asm_x64_t *as, int src_r64_a, int src_r64_b) { + asm_x64_generic_r64_r64(as, src_r64_b, src_r64_a, OPCODE_CMP_R64_WITH_RM64); +} + +/* +void asm_x64_cmp_i32_with_r32(asm_x64_t *as, int src_i32, int src_r32) { + if (SIGNED_FIT8(src_i32)) { + asm_x64_write_byte_2(as, OPCODE_CMP_I8_WITH_RM32, MODRM_R64(7) | MODRM_RM_REG | MODRM_RM_R64(src_r32)); + asm_x64_write_byte_1(as, src_i32 & 0xff); + } else { + asm_x64_write_byte_2(as, OPCODE_CMP_I32_WITH_RM32, MODRM_R64(7) | MODRM_RM_REG | MODRM_RM_R64(src_r32)); + asm_x64_write_word32(as, src_i32); + } +} +*/ + +void asm_x64_test_r8_with_r8(asm_x64_t *as, int src_r64_a, int src_r64_b) { + // TODO implement for other registers + assert(src_r64_a == ASM_X64_REG_RAX); + assert(src_r64_b == ASM_X64_REG_RAX); + asm_x64_write_byte_2(as, OPCODE_TEST_R8_WITH_RM8, MODRM_R64(src_r64_a) | MODRM_RM_REG | MODRM_RM_R64(src_r64_b)); +} + +void asm_x64_setcc_r8(asm_x64_t *as, int jcc_type, int dest_r8) { + assert(dest_r8 < 8); + asm_x64_write_byte_3(as, OPCODE_SETCC_RM8_A, OPCODE_SETCC_RM8_B | jcc_type, MODRM_R64(0) | MODRM_RM_REG | MODRM_RM_R64(dest_r8)); +} + +STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) { + assert(label < as->base.max_num_labels); + return as->base.label_offsets[label]; +} + +void asm_x64_jmp_label(asm_x64_t *as, mp_uint_t label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + if (dest != (mp_uint_t)-1 && rel < 0) { + // is a backwards jump, so we know the size of the jump on the first pass + // calculate rel assuming 8 bit relative jump + rel -= 2; + if (SIGNED_FIT8(rel)) { + asm_x64_write_byte_2(as, OPCODE_JMP_REL8, rel & 0xff); + } else { + rel += 2; + goto large_jump; + } + } else { + // is a forwards jump, so need to assume it's large + large_jump: + rel -= 5; + asm_x64_write_byte_1(as, OPCODE_JMP_REL32); + asm_x64_write_word32(as, rel); + } +} + +void asm_x64_jcc_label(asm_x64_t *as, int jcc_type, mp_uint_t label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + if (dest != (mp_uint_t)-1 && rel < 0) { + // is a backwards jump, so we know the size of the jump on the first pass + // calculate rel assuming 8 bit relative jump + rel -= 2; + if (SIGNED_FIT8(rel)) { + asm_x64_write_byte_2(as, OPCODE_JCC_REL8 | jcc_type, rel & 0xff); + } else { + rel += 2; + goto large_jump; + } + } else { + // is a forwards jump, so need to assume it's large + large_jump: + rel -= 6; + asm_x64_write_byte_2(as, OPCODE_JCC_REL32_A, OPCODE_JCC_REL32_B | jcc_type); + asm_x64_write_word32(as, rel); + } +} + +void asm_x64_entry(asm_x64_t *as, int num_locals) { + asm_x64_push_r64(as, ASM_X64_REG_RBP); + asm_x64_mov_r64_r64(as, ASM_X64_REG_RBP, ASM_X64_REG_RSP); + if (num_locals < 0) { + num_locals = 0; + } + num_locals |= 1; // make it odd so stack is aligned on 16 byte boundary + asm_x64_sub_r64_i32(as, ASM_X64_REG_RSP, num_locals * WORD_SIZE); + asm_x64_push_r64(as, ASM_X64_REG_RBX); + asm_x64_push_r64(as, ASM_X64_REG_R12); + asm_x64_push_r64(as, ASM_X64_REG_R13); + as->num_locals = num_locals; +} + +void asm_x64_exit(asm_x64_t *as) { + asm_x64_pop_r64(as, ASM_X64_REG_R13); + asm_x64_pop_r64(as, ASM_X64_REG_R12); + asm_x64_pop_r64(as, ASM_X64_REG_RBX); + asm_x64_write_byte_1(as, OPCODE_LEAVE); + asm_x64_ret(as); +} + +// locals: +// - stored on the stack in ascending order +// - numbered 0 through as->num_locals-1 +// - RBP points above the last local +// +// | RBP +// v +// l0 l1 l2 ... l(n-1) +// ^ ^ +// | low address | high address in RAM +// +STATIC int asm_x64_local_offset_from_ebp(asm_x64_t *as, int local_num) { + return (-as->num_locals + local_num) * WORD_SIZE; +} + +void asm_x64_mov_local_to_r64(asm_x64_t *as, int src_local_num, int dest_r64) { + asm_x64_mov_mem64_to_r64(as, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, src_local_num), dest_r64); +} + +void asm_x64_mov_r64_to_local(asm_x64_t *as, int src_r64, int dest_local_num) { + asm_x64_mov_r64_to_mem64(as, src_r64, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, dest_local_num)); +} + +void asm_x64_mov_local_addr_to_r64(asm_x64_t *as, int local_num, int dest_r64) { + int offset = asm_x64_local_offset_from_ebp(as, local_num); + if (offset == 0) { + asm_x64_mov_r64_r64(as, dest_r64, ASM_X64_REG_RBP); + } else { + asm_x64_lea_disp_to_r64(as, ASM_X64_REG_RBP, offset, dest_r64); + } +} + +/* +void asm_x64_push_local(asm_x64_t *as, int local_num) { + asm_x64_push_disp(as, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, local_num)); +} + +void asm_x64_push_local_addr(asm_x64_t *as, int local_num, int temp_r64) { + asm_x64_mov_r64_r64(as, temp_r64, ASM_X64_REG_RBP); + asm_x64_add_i32_to_r32(as, asm_x64_local_offset_from_ebp(as, local_num), temp_r64); + asm_x64_push_r64(as, temp_r64); +} +*/ + +/* + can't use these because code might be relocated when resized + +void asm_x64_call(asm_x64_t *as, void* func) { + asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP); + asm_x64_write_byte_1(as, OPCODE_CALL_REL32); + asm_x64_write_word32(as, func - (void*)(as->code_cur + 4)); + asm_x64_mov_r64_r64(as, ASM_X64_REG_RSP, ASM_X64_REG_RBP); +} + +void asm_x64_call_i1(asm_x64_t *as, void* func, int i1) { + asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP); + asm_x64_sub_i32_from_r32(as, 12, ASM_X64_REG_RSP); + asm_x64_push_i32(as, i1); + asm_x64_write_byte_1(as, OPCODE_CALL_REL32); + asm_x64_write_word32(as, func - (void*)(as->code_cur + 4)); + asm_x64_add_i32_to_r32(as, 16, ASM_X64_REG_RSP); + asm_x64_mov_r64_r64(as, ASM_X64_REG_RSP, ASM_X64_REG_RBP); +} +*/ + +void asm_x64_call_ind(asm_x64_t *as, void *ptr, int temp_r64) { + assert(temp_r64 < 8); +#ifdef __LP64__ + asm_x64_mov_i64_to_r64_optimised(as, (int64_t)ptr, temp_r64); +#else + // If we get here, sizeof(int) == sizeof(void*). + asm_x64_mov_i64_to_r64_optimised(as, (int64_t)(unsigned int)ptr, temp_r64); +#endif + asm_x64_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R64(2) | MODRM_RM_REG | MODRM_RM_R64(temp_r64)); + // this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all + // doesn't work anymore because calls are 64 bits away + /* + asm_x64_write_byte_1(as, OPCODE_CALL_REL32); + asm_x64_write_word32(as, ptr - (void*)(as->code_base + as->code_offset + 4)); + */ +} + +#endif // MICROPY_EMIT_X64 diff --git a/user/mpy/py/asmx64.h b/user/mpy/py/asmx64.h new file mode 100644 index 0000000..425bdf2 --- /dev/null +++ b/user/mpy/py/asmx64.h @@ -0,0 +1,200 @@ +/* + * 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_ASMX64_H +#define MICROPY_INCLUDED_PY_ASMX64_H + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/asmbase.h" + +// AMD64 calling convention is: +// - args pass in: RDI, RSI, RDX, RCX, R08, R09 +// - return value in RAX +// - stack must be aligned on a 16-byte boundary before all calls +// - RAX, RCX, RDX, RSI, RDI, R08, R09, R10, R11 are caller-save +// - RBX, RBP, R12, R13, R14, R15 are callee-save + +// In the functions below, argument order follows x86 docs and generally +// the destination is the first argument. +// NOTE: this is a change from the old convention used in this file and +// some functions still use the old (reverse) convention. + +#define ASM_X64_REG_RAX (0) +#define ASM_X64_REG_RCX (1) +#define ASM_X64_REG_RDX (2) +#define ASM_X64_REG_RBX (3) +#define ASM_X64_REG_RSP (4) +#define ASM_X64_REG_RBP (5) +#define ASM_X64_REG_RSI (6) +#define ASM_X64_REG_RDI (7) +#define ASM_X64_REG_R08 (8) +#define ASM_X64_REG_R09 (9) +#define ASM_X64_REG_R10 (10) +#define ASM_X64_REG_R11 (11) +#define ASM_X64_REG_R12 (12) +#define ASM_X64_REG_R13 (13) +#define ASM_X64_REG_R14 (14) +#define ASM_X64_REG_R15 (15) + +// condition codes, used for jcc and setcc (despite their j-name!) +#define ASM_X64_CC_JB (0x2) // below, unsigned +#define ASM_X64_CC_JZ (0x4) +#define ASM_X64_CC_JE (0x4) +#define ASM_X64_CC_JNZ (0x5) +#define ASM_X64_CC_JNE (0x5) +#define ASM_X64_CC_JL (0xc) // less, signed +#define ASM_X64_CC_JGE (0xd) // greater or equal, signed +#define ASM_X64_CC_JLE (0xe) // less or equal, signed +#define ASM_X64_CC_JG (0xf) // greater, signed + +typedef struct _asm_x64_t { + mp_asm_base_t base; + int num_locals; +} asm_x64_t; + +static inline void asm_x64_end_pass(asm_x64_t *as) { + (void)as; +} + +void asm_x64_nop(asm_x64_t* as); +void asm_x64_push_r64(asm_x64_t* as, int src_r64); +void asm_x64_pop_r64(asm_x64_t* as, int dest_r64); +void asm_x64_mov_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); +void asm_x64_mov_i64_to_r64(asm_x64_t* as, int64_t src_i64, int dest_r64); +void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r64); +void asm_x64_mov_i64_to_r64_aligned(asm_x64_t *as, int64_t src_i64, int dest_r64); +void asm_x64_mov_r8_to_mem8(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); +void asm_x64_mov_r16_to_mem16(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); +void asm_x64_mov_r32_to_mem32(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); +void asm_x64_mov_r64_to_mem64(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); +void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); +void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); +void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); +void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); +void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64); +void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64); +void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64); +void asm_x64_shl_r64_cl(asm_x64_t* as, int dest_r64); +void asm_x64_sar_r64_cl(asm_x64_t* as, int dest_r64); +void asm_x64_add_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); +void asm_x64_sub_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); +void asm_x64_mul_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); +void asm_x64_cmp_r64_with_r64(asm_x64_t* as, int src_r64_a, int src_r64_b); +void asm_x64_test_r8_with_r8(asm_x64_t* as, int src_r64_a, int src_r64_b); +void asm_x64_setcc_r8(asm_x64_t* as, int jcc_type, int dest_r8); +void asm_x64_jmp_label(asm_x64_t* as, mp_uint_t label); +void asm_x64_jcc_label(asm_x64_t* as, int jcc_type, mp_uint_t label); +void asm_x64_entry(asm_x64_t* as, int num_locals); +void asm_x64_exit(asm_x64_t* as); +void asm_x64_mov_local_to_r64(asm_x64_t* as, int src_local_num, int dest_r64); +void asm_x64_mov_r64_to_local(asm_x64_t* as, int src_r64, int dest_local_num); +void asm_x64_mov_local_addr_to_r64(asm_x64_t* as, int local_num, int dest_r64); +void asm_x64_call_ind(asm_x64_t* as, void* ptr, int temp_r32); + +#if GENERIC_ASM_API + +// The following macros provide a (mostly) arch-independent API to +// generate native code, and are used by the native emitter. + +#define ASM_WORD_SIZE (8) + +#define REG_RET ASM_X64_REG_RAX +#define REG_ARG_1 ASM_X64_REG_RDI +#define REG_ARG_2 ASM_X64_REG_RSI +#define REG_ARG_3 ASM_X64_REG_RDX +#define REG_ARG_4 ASM_X64_REG_RCX +#define REG_ARG_5 ASM_X64_REG_R08 + +// caller-save +#define REG_TEMP0 ASM_X64_REG_RAX +#define REG_TEMP1 ASM_X64_REG_RDI +#define REG_TEMP2 ASM_X64_REG_RSI + +// callee-save +#define REG_LOCAL_1 ASM_X64_REG_RBX +#define REG_LOCAL_2 ASM_X64_REG_R12 +#define REG_LOCAL_3 ASM_X64_REG_R13 +#define REG_LOCAL_NUM (3) + +#define ASM_T asm_x64_t +#define ASM_END_PASS asm_x64_end_pass +#define ASM_ENTRY asm_x64_entry +#define ASM_EXIT asm_x64_exit + +#define ASM_JUMP asm_x64_jmp_label +#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ + do { \ + asm_x64_test_r8_with_r8(as, reg, reg); \ + asm_x64_jcc_label(as, ASM_X64_CC_JZ, label); \ + } while (0) +#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ + do { \ + asm_x64_test_r8_with_r8(as, reg, reg); \ + asm_x64_jcc_label(as, ASM_X64_CC_JNZ, label); \ + } while (0) +#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ + do { \ + asm_x64_cmp_r64_with_r64(as, reg1, reg2); \ + asm_x64_jcc_label(as, ASM_X64_CC_JE, label); \ + } while (0) +#define ASM_CALL_IND(as, ptr, idx) asm_x64_call_ind(as, ptr, ASM_X64_REG_RAX) + +#define ASM_MOV_REG_TO_LOCAL asm_x64_mov_r64_to_local +#define ASM_MOV_IMM_TO_REG asm_x64_mov_i64_to_r64_optimised +#define ASM_MOV_ALIGNED_IMM_TO_REG asm_x64_mov_i64_to_r64_aligned +#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ + do { \ + asm_x64_mov_i64_to_r64_optimised(as, (imm), (reg_temp)); \ + asm_x64_mov_r64_to_local(as, (reg_temp), (local_num)); \ + } while (false) +#define ASM_MOV_LOCAL_TO_REG asm_x64_mov_local_to_r64 +#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_x64_mov_r64_r64((as), (reg_dest), (reg_src)) +#define ASM_MOV_LOCAL_ADDR_TO_REG asm_x64_mov_local_addr_to_r64 + +#define ASM_LSL_REG(as, reg) asm_x64_shl_r64_cl((as), (reg)) +#define ASM_ASR_REG(as, reg) asm_x64_sar_r64_cl((as), (reg)) +#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_x64_or_r64_r64((as), (reg_dest), (reg_src)) +#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_x64_xor_r64_r64((as), (reg_dest), (reg_src)) +#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_x64_and_r64_r64((as), (reg_dest), (reg_src)) +#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_x64_add_r64_r64((as), (reg_dest), (reg_src)) +#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_x64_sub_r64_r64((as), (reg_dest), (reg_src)) +#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_x64_mul_r64_r64((as), (reg_dest), (reg_src)) + +#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem64_to_r64((as), (reg_base), 0, (reg_dest)) +#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_x64_mov_mem64_to_r64((as), (reg_base), 8 * (word_offset), (reg_dest)) +#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem8_to_r64zx((as), (reg_base), 0, (reg_dest)) +#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem16_to_r64zx((as), (reg_base), 0, (reg_dest)) +#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem32_to_r64zx((as), (reg_base), 0, (reg_dest)) + +#define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_x64_mov_r64_to_mem64((as), (reg_src), (reg_base), 0) +#define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_x64_mov_r64_to_mem64((as), (reg_src), (reg_base), 8 * (word_offset)) +#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_x64_mov_r8_to_mem8((as), (reg_src), (reg_base), 0) +#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_x64_mov_r16_to_mem16((as), (reg_src), (reg_base), 0) +#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_x64_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) + +#endif // GENERIC_ASM_API + +#endif // MICROPY_INCLUDED_PY_ASMX64_H diff --git a/user/mpy/py/asmx86.c b/user/mpy/py/asmx86.c new file mode 100644 index 0000000..6a78fbd --- /dev/null +++ b/user/mpy/py/asmx86.c @@ -0,0 +1,511 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/mpconfig.h" + +// wrapper around everything in this file +#if MICROPY_EMIT_X86 + +#include "py/asmx86.h" + +/* all offsets are measured in multiples of 4 bytes */ +#define WORD_SIZE (4) + +#define OPCODE_NOP (0x90) +#define OPCODE_PUSH_R32 (0x50) +//#define OPCODE_PUSH_I32 (0x68) +//#define OPCODE_PUSH_M32 (0xff) /* /6 */ +#define OPCODE_POP_R32 (0x58) +#define OPCODE_RET (0xc3) +//#define OPCODE_MOV_I8_TO_R8 (0xb0) /* +rb */ +#define OPCODE_MOV_I32_TO_R32 (0xb8) +//#define OPCODE_MOV_I32_TO_RM32 (0xc7) +#define OPCODE_MOV_R8_TO_RM8 (0x88) /* /r */ +#define OPCODE_MOV_R32_TO_RM32 (0x89) /* /r */ +#define OPCODE_MOV_RM32_TO_R32 (0x8b) /* /r */ +#define OPCODE_MOVZX_RM8_TO_R32 (0xb6) /* 0x0f 0xb6/r */ +#define OPCODE_MOVZX_RM16_TO_R32 (0xb7) /* 0x0f 0xb7/r */ +#define OPCODE_LEA_MEM_TO_R32 (0x8d) /* /r */ +#define OPCODE_AND_R32_TO_RM32 (0x21) /* /r */ +#define OPCODE_OR_R32_TO_RM32 (0x09) /* /r */ +#define OPCODE_XOR_R32_TO_RM32 (0x31) /* /r */ +#define OPCODE_ADD_R32_TO_RM32 (0x01) +#define OPCODE_ADD_I32_TO_RM32 (0x81) /* /0 */ +#define OPCODE_ADD_I8_TO_RM32 (0x83) /* /0 */ +#define OPCODE_SUB_R32_FROM_RM32 (0x29) +#define OPCODE_SUB_I32_FROM_RM32 (0x81) /* /5 */ +#define OPCODE_SUB_I8_FROM_RM32 (0x83) /* /5 */ +//#define OPCODE_SHL_RM32_BY_I8 (0xc1) /* /4 */ +//#define OPCODE_SHR_RM32_BY_I8 (0xc1) /* /5 */ +//#define OPCODE_SAR_RM32_BY_I8 (0xc1) /* /7 */ +#define OPCODE_SHL_RM32_CL (0xd3) /* /4 */ +#define OPCODE_SAR_RM32_CL (0xd3) /* /7 */ +//#define OPCODE_CMP_I32_WITH_RM32 (0x81) /* /7 */ +//#define OPCODE_CMP_I8_WITH_RM32 (0x83) /* /7 */ +#define OPCODE_CMP_R32_WITH_RM32 (0x39) +//#define OPCODE_CMP_RM32_WITH_R32 (0x3b) +#define OPCODE_TEST_R8_WITH_RM8 (0x84) /* /r */ +#define OPCODE_JMP_REL8 (0xeb) +#define OPCODE_JMP_REL32 (0xe9) +#define OPCODE_JCC_REL8 (0x70) /* | jcc type */ +#define OPCODE_JCC_REL32_A (0x0f) +#define OPCODE_JCC_REL32_B (0x80) /* | jcc type */ +#define OPCODE_SETCC_RM8_A (0x0f) +#define OPCODE_SETCC_RM8_B (0x90) /* | jcc type, /0 */ +#define OPCODE_CALL_REL32 (0xe8) +#define OPCODE_CALL_RM32 (0xff) /* /2 */ +#define OPCODE_LEAVE (0xc9) + +#define MODRM_R32(x) ((x) << 3) +#define MODRM_RM_DISP0 (0x00) +#define MODRM_RM_DISP8 (0x40) +#define MODRM_RM_DISP32 (0x80) +#define MODRM_RM_REG (0xc0) +#define MODRM_RM_R32(x) (x) + +#define OP_SIZE_PREFIX (0x66) + +#define IMM32_L0(x) ((x) & 0xff) +#define IMM32_L1(x) (((x) >> 8) & 0xff) +#define IMM32_L2(x) (((x) >> 16) & 0xff) +#define IMM32_L3(x) (((x) >> 24) & 0xff) + +#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) + +STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) { + byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1); + if (c != NULL) { + c[0] = b1; + } +} + +STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) { + byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2); + if (c != NULL) { + c[0] = b1; + c[1] = b2; + } +} + +STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) { + byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3); + if (c != NULL) { + c[0] = b1; + c[1] = b2; + c[2] = b3; + } +} + +STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) { + byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4); + if (c != NULL) { + c[0] = IMM32_L0(w32); + c[1] = IMM32_L1(w32); + c[2] = IMM32_L2(w32); + c[3] = IMM32_L3(w32); + } +} + +STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) { + assert(disp_r32 != ASM_X86_REG_ESP); + + if (disp_offset == 0 && disp_r32 != ASM_X86_REG_EBP) { + asm_x86_write_byte_1(as, MODRM_R32(r32) | MODRM_RM_DISP0 | MODRM_RM_R32(disp_r32)); + } else if (SIGNED_FIT8(disp_offset)) { + asm_x86_write_byte_2(as, MODRM_R32(r32) | MODRM_RM_DISP8 | MODRM_RM_R32(disp_r32), IMM32_L0(disp_offset)); + } else { + asm_x86_write_byte_1(as, MODRM_R32(r32) | MODRM_RM_DISP32 | MODRM_RM_R32(disp_r32)); + asm_x86_write_word32(as, disp_offset); + } +} + +STATIC void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) { + asm_x86_write_byte_2(as, op, MODRM_R32(src_r32) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); +} + +STATIC void asm_x86_nop(asm_x86_t *as) { + asm_x86_write_byte_1(as, OPCODE_NOP); +} + +STATIC void asm_x86_push_r32(asm_x86_t *as, int src_r32) { + asm_x86_write_byte_1(as, OPCODE_PUSH_R32 | src_r32); +} + +#if 0 +void asm_x86_push_i32(asm_x86_t *as, int src_i32) { + asm_x86_write_byte_1(as, OPCODE_PUSH_I32); + asm_x86_write_word32(as, src_i32); +} + +void asm_x86_push_disp(asm_x86_t *as, int src_r32, int src_offset) { + asm_x86_write_byte_1(as, OPCODE_PUSH_M32); + asm_x86_write_r32_disp(as, 6, src_r32, src_offset); +} +#endif + +STATIC void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) { + asm_x86_write_byte_1(as, OPCODE_POP_R32 | dest_r32); +} + +STATIC void asm_x86_ret(asm_x86_t *as) { + asm_x86_write_byte_1(as, OPCODE_RET); +} + +void asm_x86_mov_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_MOV_R32_TO_RM32); +} + +void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp) { + asm_x86_write_byte_1(as, OPCODE_MOV_R8_TO_RM8); + asm_x86_write_r32_disp(as, src_r32, dest_r32, dest_disp); +} + +void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp) { + asm_x86_write_byte_2(as, OP_SIZE_PREFIX, OPCODE_MOV_R32_TO_RM32); + asm_x86_write_r32_disp(as, src_r32, dest_r32, dest_disp); +} + +void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp) { + asm_x86_write_byte_1(as, OPCODE_MOV_R32_TO_RM32); + asm_x86_write_r32_disp(as, src_r32, dest_r32, dest_disp); +} + +void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { + asm_x86_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM8_TO_R32); + asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); +} + +void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { + asm_x86_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM16_TO_R32); + asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); +} + +void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { + asm_x86_write_byte_1(as, OPCODE_MOV_RM32_TO_R32); + asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); +} + +STATIC void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { + asm_x86_write_byte_1(as, OPCODE_LEA_MEM_TO_R32); + asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); +} + +#if 0 +void asm_x86_mov_i8_to_r8(asm_x86_t *as, int src_i8, int dest_r32) { + asm_x86_write_byte_2(as, OPCODE_MOV_I8_TO_R8 | dest_r32, src_i8); +} +#endif + +void asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32) { + asm_x86_write_byte_1(as, OPCODE_MOV_I32_TO_R32 | dest_r32); + asm_x86_write_word32(as, src_i32); +} + +// src_i32 is stored as a full word in the code, and aligned to machine-word boundary +void asm_x86_mov_i32_to_r32_aligned(asm_x86_t *as, int32_t src_i32, int dest_r32) { + // mov instruction uses 1 byte for the instruction, before the i32 + while (((as->base.code_offset + 1) & (WORD_SIZE - 1)) != 0) { + asm_x86_nop(as); + } + asm_x86_mov_i32_to_r32(as, src_i32, dest_r32); +} + +void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_AND_R32_TO_RM32); +} + +void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_OR_R32_TO_RM32); +} + +void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_XOR_R32_TO_RM32); +} + +void asm_x86_shl_r32_cl(asm_x86_t* as, int dest_r32) { + asm_x86_generic_r32_r32(as, dest_r32, 4, OPCODE_SHL_RM32_CL); +} + +void asm_x86_sar_r32_cl(asm_x86_t* as, int dest_r32) { + asm_x86_generic_r32_r32(as, dest_r32, 7, OPCODE_SAR_RM32_CL); +} + +void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_ADD_R32_TO_RM32); +} + +STATIC void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) { + if (SIGNED_FIT8(src_i32)) { + asm_x86_write_byte_2(as, OPCODE_ADD_I8_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); + asm_x86_write_byte_1(as, src_i32 & 0xff); + } else { + asm_x86_write_byte_2(as, OPCODE_ADD_I32_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); + asm_x86_write_word32(as, src_i32); + } +} + +void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_SUB_R32_FROM_RM32); +} + +STATIC void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) { + if (SIGNED_FIT8(src_i32)) { + // defaults to 32 bit operation + asm_x86_write_byte_2(as, OPCODE_SUB_I8_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); + asm_x86_write_byte_1(as, src_i32 & 0xff); + } else { + // defaults to 32 bit operation + asm_x86_write_byte_2(as, OPCODE_SUB_I32_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); + asm_x86_write_word32(as, src_i32); + } +} + +void asm_x86_mul_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { + // imul reg32, reg/mem32 -- 0x0f 0xaf /r + asm_x86_write_byte_3(as, 0x0f, 0xaf, MODRM_R32(dest_r32) | MODRM_RM_REG | MODRM_RM_R32(src_r32)); +} + +#if 0 +/* shifts not tested */ +void asm_x86_shl_r32_by_imm(asm_x86_t *as, int r32, int imm) { + asm_x86_write_byte_2(as, OPCODE_SHL_RM32_BY_I8, MODRM_R32(4) | MODRM_RM_REG | MODRM_RM_R32(r32)); + asm_x86_write_byte_1(as, imm); +} + +void asm_x86_shr_r32_by_imm(asm_x86_t *as, int r32, int imm) { + asm_x86_write_byte_2(as, OPCODE_SHR_RM32_BY_I8, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(r32)); + asm_x86_write_byte_1(as, imm); +} + +void asm_x86_sar_r32_by_imm(asm_x86_t *as, int r32, int imm) { + asm_x86_write_byte_2(as, OPCODE_SAR_RM32_BY_I8, MODRM_R32(7) | MODRM_RM_REG | MODRM_RM_R32(r32)); + asm_x86_write_byte_1(as, imm); +} +#endif + +void asm_x86_cmp_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32_b) { + asm_x86_write_byte_2(as, OPCODE_CMP_R32_WITH_RM32, MODRM_R32(src_r32_a) | MODRM_RM_REG | MODRM_RM_R32(src_r32_b)); +} + +#if 0 +void asm_x86_cmp_i32_with_r32(asm_x86_t *as, int src_i32, int src_r32) { + if (SIGNED_FIT8(src_i32)) { + asm_x86_write_byte_2(as, OPCODE_CMP_I8_WITH_RM32, MODRM_R32(7) | MODRM_RM_REG | MODRM_RM_R32(src_r32)); + asm_x86_write_byte_1(as, src_i32 & 0xff); + } else { + asm_x86_write_byte_2(as, OPCODE_CMP_I32_WITH_RM32, MODRM_R32(7) | MODRM_RM_REG | MODRM_RM_R32(src_r32)); + asm_x86_write_word32(as, src_i32); + } +} +#endif + +void asm_x86_test_r8_with_r8(asm_x86_t *as, int src_r32_a, int src_r32_b) { + // TODO implement for other registers + assert(src_r32_a == ASM_X86_REG_EAX); + assert(src_r32_b == ASM_X86_REG_EAX); + asm_x86_write_byte_2(as, OPCODE_TEST_R8_WITH_RM8, MODRM_R32(src_r32_a) | MODRM_RM_REG | MODRM_RM_R32(src_r32_b)); +} + +void asm_x86_setcc_r8(asm_x86_t *as, mp_uint_t jcc_type, int dest_r8) { + asm_x86_write_byte_3(as, OPCODE_SETCC_RM8_A, OPCODE_SETCC_RM8_B | jcc_type, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r8)); +} + +STATIC mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) { + assert(label < as->base.max_num_labels); + return as->base.label_offsets[label]; +} + +void asm_x86_jmp_label(asm_x86_t *as, mp_uint_t label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + if (dest != (mp_uint_t)-1 && rel < 0) { + // is a backwards jump, so we know the size of the jump on the first pass + // calculate rel assuming 8 bit relative jump + rel -= 2; + if (SIGNED_FIT8(rel)) { + asm_x86_write_byte_2(as, OPCODE_JMP_REL8, rel & 0xff); + } else { + rel += 2; + goto large_jump; + } + } else { + // is a forwards jump, so need to assume it's large + large_jump: + rel -= 5; + asm_x86_write_byte_1(as, OPCODE_JMP_REL32); + asm_x86_write_word32(as, rel); + } +} + +void asm_x86_jcc_label(asm_x86_t *as, mp_uint_t jcc_type, mp_uint_t label) { + mp_uint_t dest = get_label_dest(as, label); + mp_int_t rel = dest - as->base.code_offset; + if (dest != (mp_uint_t)-1 && rel < 0) { + // is a backwards jump, so we know the size of the jump on the first pass + // calculate rel assuming 8 bit relative jump + rel -= 2; + if (SIGNED_FIT8(rel)) { + asm_x86_write_byte_2(as, OPCODE_JCC_REL8 | jcc_type, rel & 0xff); + } else { + rel += 2; + goto large_jump; + } + } else { + // is a forwards jump, so need to assume it's large + large_jump: + rel -= 6; + asm_x86_write_byte_2(as, OPCODE_JCC_REL32_A, OPCODE_JCC_REL32_B | jcc_type); + asm_x86_write_word32(as, rel); + } +} + +void asm_x86_entry(asm_x86_t *as, mp_uint_t num_locals) { + asm_x86_push_r32(as, ASM_X86_REG_EBP); + asm_x86_mov_r32_r32(as, ASM_X86_REG_EBP, ASM_X86_REG_ESP); + if (num_locals > 0) { + asm_x86_sub_r32_i32(as, ASM_X86_REG_ESP, num_locals * WORD_SIZE); + } + asm_x86_push_r32(as, ASM_X86_REG_EBX); + asm_x86_push_r32(as, ASM_X86_REG_ESI); + asm_x86_push_r32(as, ASM_X86_REG_EDI); + // TODO align stack on 16-byte boundary + as->num_locals = num_locals; +} + +void asm_x86_exit(asm_x86_t *as) { + asm_x86_pop_r32(as, ASM_X86_REG_EDI); + asm_x86_pop_r32(as, ASM_X86_REG_ESI); + asm_x86_pop_r32(as, ASM_X86_REG_EBX); + asm_x86_write_byte_1(as, OPCODE_LEAVE); + asm_x86_ret(as); +} + +#if 0 +void asm_x86_push_arg(asm_x86_t *as, int src_arg_num) { + asm_x86_push_disp(as, ASM_X86_REG_EBP, 2 * WORD_SIZE + src_arg_num * WORD_SIZE); +} +#endif + +void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32) { + asm_x86_mov_mem32_to_r32(as, ASM_X86_REG_EBP, 2 * WORD_SIZE + src_arg_num * WORD_SIZE, dest_r32); +} + +#if 0 +void asm_x86_mov_r32_to_arg(asm_x86_t *as, int src_r32, int dest_arg_num) { + asm_x86_mov_r32_to_mem32(as, src_r32, ASM_X86_REG_EBP, 2 * WORD_SIZE + dest_arg_num * WORD_SIZE); +} +#endif + +// locals: +// - stored on the stack in ascending order +// - numbered 0 through as->num_locals-1 +// - EBP points above the last local +// +// | EBP +// v +// l0 l1 l2 ... l(n-1) +// ^ ^ +// | low address | high address in RAM +// +STATIC int asm_x86_local_offset_from_ebp(asm_x86_t *as, int local_num) { + return (-as->num_locals + local_num) * WORD_SIZE; +} + +void asm_x86_mov_local_to_r32(asm_x86_t *as, int src_local_num, int dest_r32) { + asm_x86_mov_mem32_to_r32(as, ASM_X86_REG_EBP, asm_x86_local_offset_from_ebp(as, src_local_num), dest_r32); +} + +void asm_x86_mov_r32_to_local(asm_x86_t *as, int src_r32, int dest_local_num) { + asm_x86_mov_r32_to_mem32(as, src_r32, ASM_X86_REG_EBP, asm_x86_local_offset_from_ebp(as, dest_local_num)); +} + +void asm_x86_mov_local_addr_to_r32(asm_x86_t *as, int local_num, int dest_r32) { + int offset = asm_x86_local_offset_from_ebp(as, local_num); + if (offset == 0) { + asm_x86_mov_r32_r32(as, dest_r32, ASM_X86_REG_EBP); + } else { + asm_x86_lea_disp_to_r32(as, ASM_X86_REG_EBP, offset, dest_r32); + } +} + +#if 0 +void asm_x86_push_local(asm_x86_t *as, int local_num) { + asm_x86_push_disp(as, ASM_X86_REG_EBP, asm_x86_local_offset_from_ebp(as, local_num)); +} + +void asm_x86_push_local_addr(asm_x86_t *as, int local_num, int temp_r32) +{ + asm_x86_mov_r32_r32(as, temp_r32, ASM_X86_REG_EBP); + asm_x86_add_i32_to_r32(as, asm_x86_local_offset_from_ebp(as, local_num), temp_r32); + asm_x86_push_r32(as, temp_r32); +} +#endif + +void asm_x86_call_ind(asm_x86_t *as, void *ptr, mp_uint_t n_args, int temp_r32) { + // TODO align stack on 16-byte boundary before the call + assert(n_args <= 5); + if (n_args > 4) { + asm_x86_push_r32(as, ASM_X86_REG_ARG_5); + } + if (n_args > 3) { + asm_x86_push_r32(as, ASM_X86_REG_ARG_4); + } + if (n_args > 2) { + asm_x86_push_r32(as, ASM_X86_REG_ARG_3); + } + if (n_args > 1) { + asm_x86_push_r32(as, ASM_X86_REG_ARG_2); + } + if (n_args > 0) { + asm_x86_push_r32(as, ASM_X86_REG_ARG_1); + } +#ifdef __LP64__ + // We wouldn't run x86 code on an x64 machine. This is here to enable + // testing of the x86 emitter only. + asm_x86_mov_i32_to_r32(as, (int32_t)(int64_t)ptr, temp_r32); +#else + // If we get here, sizeof(int) == sizeof(void*). + asm_x86_mov_i32_to_r32(as, (int32_t)ptr, temp_r32); +#endif + asm_x86_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R32(2) | MODRM_RM_REG | MODRM_RM_R32(temp_r32)); + // this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all + /* + asm_x86_write_byte_1(as, OPCODE_CALL_REL32); + asm_x86_write_word32(as, ptr - (void*)(as->code_base + as->base.code_offset + 4)); + */ + + // the caller must clean up the stack + if (n_args > 0) { + asm_x86_add_i32_to_r32(as, WORD_SIZE * n_args, ASM_X86_REG_ESP); + } +} + +#endif // MICROPY_EMIT_X86 diff --git a/user/mpy/py/asmx86.h b/user/mpy/py/asmx86.h new file mode 100644 index 0000000..0a00e2e --- /dev/null +++ b/user/mpy/py/asmx86.h @@ -0,0 +1,198 @@ +/* + * 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_ASMX86_H +#define MICROPY_INCLUDED_PY_ASMX86_H + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/asmbase.h" + +// x86 cdecl calling convention is: +// - args passed on the stack in reverse order +// - return value in EAX +// - caller cleans up the stack after a call +// - stack must be aligned to 16-byte boundary before all calls +// - EAX, ECX, EDX are caller-save +// - EBX, ESI, EDI, EBP, ESP, EIP are callee-save + +// In the functions below, argument order follows x86 docs and generally +// the destination is the first argument. +// NOTE: this is a change from the old convention used in this file and +// some functions still use the old (reverse) convention. + +#define ASM_X86_REG_EAX (0) +#define ASM_X86_REG_ECX (1) +#define ASM_X86_REG_EDX (2) +#define ASM_X86_REG_EBX (3) +#define ASM_X86_REG_ESP (4) +#define ASM_X86_REG_EBP (5) +#define ASM_X86_REG_ESI (6) +#define ASM_X86_REG_EDI (7) + +// x86 passes values on the stack, but the emitter is register based, so we need +// to define registers that can temporarily hold the function arguments. They +// need to be defined here so that asm_x86_call_ind can push them onto the stack +// before the call. +#define ASM_X86_REG_ARG_1 ASM_X86_REG_EAX +#define ASM_X86_REG_ARG_2 ASM_X86_REG_ECX +#define ASM_X86_REG_ARG_3 ASM_X86_REG_EDX +#define ASM_X86_REG_ARG_4 ASM_X86_REG_EBX +#define ASM_X86_REG_ARG_5 ASM_X86_REG_ESI + +// condition codes, used for jcc and setcc (despite their j-name!) +#define ASM_X86_CC_JB (0x2) // below, unsigned +#define ASM_X86_CC_JZ (0x4) +#define ASM_X86_CC_JE (0x4) +#define ASM_X86_CC_JNZ (0x5) +#define ASM_X86_CC_JNE (0x5) +#define ASM_X86_CC_JL (0xc) // less, signed +#define ASM_X86_CC_JGE (0xd) // greater or equal, signed +#define ASM_X86_CC_JLE (0xe) // less or equal, signed +#define ASM_X86_CC_JG (0xf) // greater, signed + +typedef struct _asm_x86_t { + mp_asm_base_t base; + int num_locals; +} asm_x86_t; + +static inline void asm_x86_end_pass(asm_x86_t *as) { + (void)as; +} + +void asm_x86_mov_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); +void asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32); +void asm_x86_mov_i32_to_r32_aligned(asm_x86_t *as, int32_t src_i32, int dest_r32); +void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp); +void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp); +void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp); +void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32); +void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32); +void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32); +void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32); +void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32); +void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32); +void asm_x86_shl_r32_cl(asm_x86_t* as, int dest_r32); +void asm_x86_sar_r32_cl(asm_x86_t* as, int dest_r32); +void asm_x86_add_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); +void asm_x86_sub_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); +void asm_x86_mul_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); +void asm_x86_cmp_r32_with_r32(asm_x86_t* as, int src_r32_a, int src_r32_b); +void asm_x86_test_r8_with_r8(asm_x86_t* as, int src_r32_a, int src_r32_b); +void asm_x86_setcc_r8(asm_x86_t* as, mp_uint_t jcc_type, int dest_r8); +void asm_x86_jmp_label(asm_x86_t* as, mp_uint_t label); +void asm_x86_jcc_label(asm_x86_t* as, mp_uint_t jcc_type, mp_uint_t label); +void asm_x86_entry(asm_x86_t* as, mp_uint_t num_locals); +void asm_x86_exit(asm_x86_t* as); +void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32); +void asm_x86_mov_local_to_r32(asm_x86_t* as, int src_local_num, int dest_r32); +void asm_x86_mov_r32_to_local(asm_x86_t* as, int src_r32, int dest_local_num); +void asm_x86_mov_local_addr_to_r32(asm_x86_t* as, int local_num, int dest_r32); +void asm_x86_call_ind(asm_x86_t* as, void* ptr, mp_uint_t n_args, int temp_r32); + +#if GENERIC_ASM_API + +// The following macros provide a (mostly) arch-independent API to +// generate native code, and are used by the native emitter. + +#define ASM_WORD_SIZE (4) + +#define REG_RET ASM_X86_REG_EAX +#define REG_ARG_1 ASM_X86_REG_ARG_1 +#define REG_ARG_2 ASM_X86_REG_ARG_2 +#define REG_ARG_3 ASM_X86_REG_ARG_3 +#define REG_ARG_4 ASM_X86_REG_ARG_4 +#define REG_ARG_5 ASM_X86_REG_ARG_5 + +// caller-save, so can be used as temporaries +#define REG_TEMP0 ASM_X86_REG_EAX +#define REG_TEMP1 ASM_X86_REG_ECX +#define REG_TEMP2 ASM_X86_REG_EDX + +// callee-save, so can be used as locals +#define REG_LOCAL_1 ASM_X86_REG_EBX +#define REG_LOCAL_2 ASM_X86_REG_ESI +#define REG_LOCAL_3 ASM_X86_REG_EDI +#define REG_LOCAL_NUM (3) + +#define ASM_T asm_x86_t +#define ASM_END_PASS asm_x86_end_pass +#define ASM_ENTRY asm_x86_entry +#define ASM_EXIT asm_x86_exit + +#define ASM_JUMP asm_x86_jmp_label +#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ + do { \ + asm_x86_test_r8_with_r8(as, reg, reg); \ + asm_x86_jcc_label(as, ASM_X86_CC_JZ, label); \ + } while (0) +#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ + do { \ + asm_x86_test_r8_with_r8(as, reg, reg); \ + asm_x86_jcc_label(as, ASM_X86_CC_JNZ, label); \ + } while (0) +#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ + do { \ + asm_x86_cmp_r32_with_r32(as, reg1, reg2); \ + asm_x86_jcc_label(as, ASM_X86_CC_JE, label); \ + } while (0) +#define ASM_CALL_IND(as, ptr, idx) asm_x86_call_ind(as, ptr, mp_f_n_args[idx], ASM_X86_REG_EAX) + +#define ASM_MOV_REG_TO_LOCAL asm_x86_mov_r32_to_local +#define ASM_MOV_IMM_TO_REG asm_x86_mov_i32_to_r32 +#define ASM_MOV_ALIGNED_IMM_TO_REG asm_x86_mov_i32_to_r32_aligned +#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ + do { \ + asm_x86_mov_i32_to_r32(as, (imm), (reg_temp)); \ + asm_x86_mov_r32_to_local(as, (reg_temp), (local_num)); \ + } while (false) +#define ASM_MOV_LOCAL_TO_REG asm_x86_mov_local_to_r32 +#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_x86_mov_r32_r32((as), (reg_dest), (reg_src)) +#define ASM_MOV_LOCAL_ADDR_TO_REG asm_x86_mov_local_addr_to_r32 + +#define ASM_LSL_REG(as, reg) asm_x86_shl_r32_cl((as), (reg)) +#define ASM_ASR_REG(as, reg) asm_x86_sar_r32_cl((as), (reg)) +#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_x86_or_r32_r32((as), (reg_dest), (reg_src)) +#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_x86_xor_r32_r32((as), (reg_dest), (reg_src)) +#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_x86_and_r32_r32((as), (reg_dest), (reg_src)) +#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_x86_add_r32_r32((as), (reg_dest), (reg_src)) +#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_x86_sub_r32_r32((as), (reg_dest), (reg_src)) +#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_x86_mul_r32_r32((as), (reg_dest), (reg_src)) + +#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem32_to_r32((as), (reg_base), 0, (reg_dest)) +#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_x86_mov_mem32_to_r32((as), (reg_base), 4 * (word_offset), (reg_dest)) +#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem8_to_r32zx((as), (reg_base), 0, (reg_dest)) +#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem16_to_r32zx((as), (reg_base), 0, (reg_dest)) +#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem32_to_r32((as), (reg_base), 0, (reg_dest)) + +#define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) +#define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 4 * (word_offset)) +#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_x86_mov_r8_to_mem8((as), (reg_src), (reg_base), 0) +#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_x86_mov_r16_to_mem16((as), (reg_src), (reg_base), 0) +#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) + +#endif // GENERIC_ASM_API + +#endif // MICROPY_INCLUDED_PY_ASMX86_H diff --git a/user/mpy/py/asmxtensa.c b/user/mpy/py/asmxtensa.c new file mode 100644 index 0000000..00448df --- /dev/null +++ b/user/mpy/py/asmxtensa.c @@ -0,0 +1,174 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include + +#include "py/mpconfig.h" + +// wrapper around everything in this file +#if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA + +#include "py/asmxtensa.h" + +#define WORD_SIZE (4) +#define SIGNED_FIT8(x) ((((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)) +#define SIGNED_FIT12(x) ((((x) & 0xfffff800) == 0) || (((x) & 0xfffff800) == 0xfffff800)) + +void asm_xtensa_end_pass(asm_xtensa_t *as) { + as->num_const = as->cur_const; + as->cur_const = 0; + + #if 0 + // make a hex dump of the machine code + if (as->base.pass == MP_ASM_PASS_EMIT) { + uint8_t *d = as->base.code_base; + printf("XTENSA ASM:"); + for (int i = 0; i < ((as->base.code_size + 15) & ~15); ++i) { + if (i % 16 == 0) { + printf("\n%08x:", (uint32_t)&d[i]); + } + if (i % 2 == 0) { + printf(" "); + } + printf("%02x", d[i]); + } + printf("\n"); + } + #endif +} + +void asm_xtensa_entry(asm_xtensa_t *as, int num_locals) { + // jump over the constants + asm_xtensa_op_j(as, as->num_const * WORD_SIZE + 4 - 4); + mp_asm_base_get_cur_to_write_bytes(&as->base, 1); // padding/alignment byte + as->const_table = (uint32_t*)mp_asm_base_get_cur_to_write_bytes(&as->base, as->num_const * 4); + + // adjust the stack-pointer to store a0, a12, a13, a14 and locals, 16-byte aligned + as->stack_adjust = (((4 + num_locals) * WORD_SIZE) + 15) & ~15; + asm_xtensa_op_addi(as, ASM_XTENSA_REG_A1, ASM_XTENSA_REG_A1, -as->stack_adjust); + + // save return value (a0) and callee-save registers (a12, a13, a14) + asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A0, ASM_XTENSA_REG_A1, 0); + asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A12, ASM_XTENSA_REG_A1, 1); + asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A13, ASM_XTENSA_REG_A1, 2); + asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A14, ASM_XTENSA_REG_A1, 3); +} + +void asm_xtensa_exit(asm_xtensa_t *as) { + // restore registers + asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A14, ASM_XTENSA_REG_A1, 3); + asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A13, ASM_XTENSA_REG_A1, 2); + asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A12, ASM_XTENSA_REG_A1, 1); + asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A0, ASM_XTENSA_REG_A1, 0); + + // restore stack-pointer and return + asm_xtensa_op_addi(as, ASM_XTENSA_REG_A1, ASM_XTENSA_REG_A1, as->stack_adjust); + asm_xtensa_op_ret_n(as); +} + +STATIC uint32_t get_label_dest(asm_xtensa_t *as, uint label) { + assert(label < as->base.max_num_labels); + return as->base.label_offsets[label]; +} + +void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op) { + uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2); + if (c != NULL) { + c[0] = op; + c[1] = op >> 8; + } +} + +void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op) { + uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3); + if (c != NULL) { + c[0] = op; + c[1] = op >> 8; + c[2] = op >> 16; + } +} + +void asm_xtensa_j_label(asm_xtensa_t *as, uint label) { + uint32_t dest = get_label_dest(as, label); + int32_t rel = dest - as->base.code_offset - 4; + // we assume rel, as a signed int, fits in 18-bits + asm_xtensa_op_j(as, rel); +} + +void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label) { + uint32_t dest = get_label_dest(as, label); + int32_t rel = dest - as->base.code_offset - 4; + if (as->base.pass == MP_ASM_PASS_EMIT && !SIGNED_FIT12(rel)) { + printf("ERROR: xtensa bccz out of range\n"); + } + asm_xtensa_op_bccz(as, cond, reg, rel); +} + +void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label) { + uint32_t dest = get_label_dest(as, label); + int32_t rel = dest - as->base.code_offset - 4; + if (as->base.pass == MP_ASM_PASS_EMIT && !SIGNED_FIT8(rel)) { + printf("ERROR: xtensa bcc out of range\n"); + } + asm_xtensa_op_bcc(as, cond, reg1, reg2, rel); +} + +// convenience function; reg_dest must be different from reg_src[12] +void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2) { + asm_xtensa_op_movi_n(as, reg_dest, 1); + asm_xtensa_op_bcc(as, cond, reg_src1, reg_src2, 1); + asm_xtensa_op_movi_n(as, reg_dest, 0); +} + +void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) { + if (SIGNED_FIT12(i32)) { + asm_xtensa_op_movi(as, reg_dest, i32); + } else { + // load the constant + asm_xtensa_op_l32r(as, reg_dest, as->base.code_offset, 4 + as->cur_const * WORD_SIZE); + // store the constant in the table + if (as->const_table != NULL) { + as->const_table[as->cur_const] = i32; + } + ++as->cur_const; + } +} + +void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src) { + asm_xtensa_op_s32i(as, reg_src, ASM_XTENSA_REG_A1, 4 + local_num); +} + +void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num) { + asm_xtensa_op_l32i(as, reg_dest, ASM_XTENSA_REG_A1, 4 + local_num); +} + +void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num) { + asm_xtensa_op_mov_n(as, reg_dest, ASM_XTENSA_REG_A1); + asm_xtensa_op_addi(as, reg_dest, reg_dest, (4 + local_num) * WORD_SIZE); +} + +#endif // MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA diff --git a/user/mpy/py/asmxtensa.h b/user/mpy/py/asmxtensa.h new file mode 100644 index 0000000..7db6c0d --- /dev/null +++ b/user/mpy/py/asmxtensa.h @@ -0,0 +1,324 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_ASMXTENSA_H +#define MICROPY_INCLUDED_PY_ASMXTENSA_H + +#include "py/asmbase.h" + +// calling conventions: +// up to 6 args in a2-a7 +// return value in a2 +// PC stored in a0 +// stack pointer is a1, stack full descending, is aligned to 16 bytes +// callee save: a1, a12, a13, a14, a15 +// caller save: a3 + +#define ASM_XTENSA_REG_A0 (0) +#define ASM_XTENSA_REG_A1 (1) +#define ASM_XTENSA_REG_A2 (2) +#define ASM_XTENSA_REG_A3 (3) +#define ASM_XTENSA_REG_A4 (4) +#define ASM_XTENSA_REG_A5 (5) +#define ASM_XTENSA_REG_A6 (6) +#define ASM_XTENSA_REG_A7 (7) +#define ASM_XTENSA_REG_A8 (8) +#define ASM_XTENSA_REG_A9 (9) +#define ASM_XTENSA_REG_A10 (10) +#define ASM_XTENSA_REG_A11 (11) +#define ASM_XTENSA_REG_A12 (12) +#define ASM_XTENSA_REG_A13 (13) +#define ASM_XTENSA_REG_A14 (14) +#define ASM_XTENSA_REG_A15 (15) + +// for bccz +#define ASM_XTENSA_CCZ_EQ (0) +#define ASM_XTENSA_CCZ_NE (1) + +// for bcc and setcc +#define ASM_XTENSA_CC_NONE (0) +#define ASM_XTENSA_CC_EQ (1) +#define ASM_XTENSA_CC_LT (2) +#define ASM_XTENSA_CC_LTU (3) +#define ASM_XTENSA_CC_ALL (4) +#define ASM_XTENSA_CC_BC (5) +#define ASM_XTENSA_CC_ANY (8) +#define ASM_XTENSA_CC_NE (9) +#define ASM_XTENSA_CC_GE (10) +#define ASM_XTENSA_CC_GEU (11) +#define ASM_XTENSA_CC_NALL (12) +#define ASM_XTENSA_CC_BS (13) + +// macros for encoding instructions (little endian versions) +#define ASM_XTENSA_ENCODE_RRR(op0, op1, op2, r, s, t) \ + ((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_RRI4(op0, op1, r, s, t, imm4) \ + (((imm4) << 20) | ((op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_RRI8(op0, r, s, t, imm8) \ + ((((uint32_t)imm8) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_RI16(op0, t, imm16) \ + (((imm16) << 8) | ((t) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_RSR(op0, op1, op2, rs, t) \ + (((op2) << 20) | ((op1) << 16) | ((rs) << 8) | ((t) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_CALL(op0, n, offset) \ + (((offset) << 6) | ((n) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_CALLX(op0, op1, op2, r, s, m, n) \ + ((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_BRI8(op0, r, s, m, n, imm8) \ + (((imm8) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_BRI12(op0, s, m, n, imm12) \ + (((imm12) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_RRRN(op0, r, s, t) \ + (((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) +#define ASM_XTENSA_ENCODE_RI7(op0, s, imm7) \ + ((((imm7) & 0xf) << 12) | ((s) << 8) | ((imm7) & 0x70) | (op0)) + +typedef struct _asm_xtensa_t { + mp_asm_base_t base; + uint32_t cur_const; + uint32_t num_const; + uint32_t *const_table; + uint32_t stack_adjust; +} asm_xtensa_t; + +void asm_xtensa_end_pass(asm_xtensa_t *as); + +void asm_xtensa_entry(asm_xtensa_t *as, int num_locals); +void asm_xtensa_exit(asm_xtensa_t *as); + +void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op); +void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op); + +// raw instructions + +static inline void asm_xtensa_op_add(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 8, reg_dest, reg_src_a, reg_src_b)); +} + +static inline void asm_xtensa_op_addi(asm_xtensa_t *as, uint reg_dest, uint reg_src, int imm8) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 12, reg_dest, reg_src, imm8 & 0xff)); +} + +static inline void asm_xtensa_op_and(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 1, reg_dest, reg_src_a, reg_src_b)); +} + +static inline void asm_xtensa_op_bcc(asm_xtensa_t *as, uint cond, uint reg_src1, uint reg_src2, int32_t rel8) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(7, cond, reg_src1, reg_src2, rel8 & 0xff)); +} + +static inline void asm_xtensa_op_bccz(asm_xtensa_t *as, uint cond, uint reg_src, int32_t rel12) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_BRI12(6, reg_src, cond, 1, rel12 & 0xfff)); +} + +static inline void asm_xtensa_op_callx0(asm_xtensa_t *as, uint reg) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_CALLX(0, 0, 0, 0, reg, 3, 0)); +} + +static inline void asm_xtensa_op_j(asm_xtensa_t *as, int32_t rel18) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_CALL(6, 0, rel18 & 0x3ffff)); +} + +static inline void asm_xtensa_op_jx(asm_xtensa_t *as, uint reg) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_CALLX(0, 0, 0, 0, reg, 2, 2)); +} + +static inline void asm_xtensa_op_l8ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint byte_offset) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 0, reg_base, reg_dest, byte_offset & 0xff)); +} + +static inline void asm_xtensa_op_l16ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint half_word_offset) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 1, reg_base, reg_dest, half_word_offset & 0xff)); +} + +static inline void asm_xtensa_op_l32i(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 2, reg_base, reg_dest, word_offset & 0xff)); +} + +static inline void asm_xtensa_op_l32i_n(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(8, word_offset & 0xf, reg_base, reg_dest)); +} + +static inline void asm_xtensa_op_l32r(asm_xtensa_t *as, uint reg_dest, uint32_t op_off, uint32_t dest_off) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RI16(1, reg_dest, ((dest_off - ((op_off + 3) & ~3)) >> 2) & 0xffff)); +} + +static inline void asm_xtensa_op_mov_n(asm_xtensa_t *as, uint reg_dest, uint reg_src) { + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(13, 0, reg_src, reg_dest)); +} + +static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t imm12) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 10, (imm12 >> 8) & 0xf, reg_dest, imm12 & 0xff)); +} + +static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) { + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm4)); +} + +static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 2, 8, reg_dest, reg_src_a, reg_src_b)); +} + +static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 2, reg_dest, reg_src_a, reg_src_b)); +} + +static inline void asm_xtensa_op_ret_n(asm_xtensa_t *as) { + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(13, 15, 0, 0)); +} + +static inline void asm_xtensa_op_s8i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint byte_offset) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 4, reg_base, reg_src, byte_offset & 0xff)); +} + +static inline void asm_xtensa_op_s16i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint half_word_offset) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 5, reg_base, reg_src, half_word_offset & 0xff)); +} + +static inline void asm_xtensa_op_s32i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 6, reg_base, reg_src, word_offset & 0xff)); +} + +static inline void asm_xtensa_op_s32i_n(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(9, word_offset & 0xf, reg_base, reg_src)); +} + +static inline void asm_xtensa_op_sll(asm_xtensa_t *as, uint reg_dest, uint reg_src) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 1, 10, reg_dest, reg_src, 0)); +} + +static inline void asm_xtensa_op_sra(asm_xtensa_t *as, uint reg_dest, uint reg_src) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 1, 11, reg_dest, 0, reg_src)); +} + +static inline void asm_xtensa_op_ssl(asm_xtensa_t *as, uint reg_src) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 4, 1, reg_src, 0)); +} + +static inline void asm_xtensa_op_ssr(asm_xtensa_t *as, uint reg_src) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 4, 0, reg_src, 0)); +} + +static inline void asm_xtensa_op_sub(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 12, reg_dest, reg_src_a, reg_src_b)); +} + +static inline void asm_xtensa_op_xor(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 3, reg_dest, reg_src_a, reg_src_b)); +} + +// convenience functions +void asm_xtensa_j_label(asm_xtensa_t *as, uint label); +void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label); +void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label); +void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2); +void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32); +void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src); +void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num); +void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num); + +#if GENERIC_ASM_API + +// The following macros provide a (mostly) arch-independent API to +// generate native code, and are used by the native emitter. + +#define ASM_WORD_SIZE (4) + +#define REG_RET ASM_XTENSA_REG_A2 +#define REG_ARG_1 ASM_XTENSA_REG_A2 +#define REG_ARG_2 ASM_XTENSA_REG_A3 +#define REG_ARG_3 ASM_XTENSA_REG_A4 +#define REG_ARG_4 ASM_XTENSA_REG_A5 +#define REG_ARG_5 ASM_XTENSA_REG_A6 + +#define REG_TEMP0 ASM_XTENSA_REG_A2 +#define REG_TEMP1 ASM_XTENSA_REG_A3 +#define REG_TEMP2 ASM_XTENSA_REG_A4 + +#define REG_LOCAL_1 ASM_XTENSA_REG_A12 +#define REG_LOCAL_2 ASM_XTENSA_REG_A13 +#define REG_LOCAL_3 ASM_XTENSA_REG_A14 +#define REG_LOCAL_NUM (3) + +#define ASM_T asm_xtensa_t +#define ASM_END_PASS asm_xtensa_end_pass +#define ASM_ENTRY asm_xtensa_entry +#define ASM_EXIT asm_xtensa_exit + +#define ASM_JUMP asm_xtensa_j_label +#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ + asm_xtensa_bccz_reg_label(as, ASM_XTENSA_CCZ_EQ, reg, label) +#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ + asm_xtensa_bccz_reg_label(as, ASM_XTENSA_CCZ_NE, reg, label) +#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ + asm_xtensa_bcc_reg_reg_label(as, ASM_XTENSA_CC_EQ, reg1, reg2, label) +#define ASM_CALL_IND(as, ptr, idx) \ + do { \ + asm_xtensa_mov_reg_i32(as, ASM_XTENSA_REG_A0, (uint32_t)ptr); \ + asm_xtensa_op_callx0(as, ASM_XTENSA_REG_A0); \ + } while (0) + +#define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_xtensa_mov_local_reg(as, (local_num), (reg)) +#define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_xtensa_mov_reg_i32(as, (reg), (imm)) +#define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_xtensa_mov_reg_i32(as, (reg), (imm)) +#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ + do { \ + asm_xtensa_mov_reg_i32(as, (reg_temp), (imm)); \ + asm_xtensa_mov_local_reg(as, (local_num), (reg_temp)); \ + } while (0) +#define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_xtensa_mov_reg_local(as, (reg), (local_num)) +#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_mov_n((as), (reg_dest), (reg_src)) +#define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_xtensa_mov_reg_local_addr(as, (reg), (local_num)) + +#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) \ + do { \ + asm_xtensa_op_ssl((as), (reg_shift)); \ + asm_xtensa_op_sll((as), (reg_dest), (reg_dest)); \ + } while (0) +#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) \ + do { \ + asm_xtensa_op_ssr((as), (reg_shift)); \ + asm_xtensa_op_sra((as), (reg_dest), (reg_dest)); \ + } while (0) +#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_or((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_xor((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_and((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_add((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_sub((as), (reg_dest), (reg_dest), (reg_src)) +#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_mull((as), (reg_dest), (reg_dest), (reg_src)) + +#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_xtensa_op_l32i_n((as), (reg_dest), (reg_base), (word_offset)) +#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l8ui((as), (reg_dest), (reg_base), 0) +#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l16ui((as), (reg_dest), (reg_base), 0) +#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l32i_n((as), (reg_dest), (reg_base), 0) + +#define ASM_STORE_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_xtensa_op_s32i_n((as), (reg_dest), (reg_base), (word_offset)) +#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s8i((as), (reg_src), (reg_base), 0) +#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s16i((as), (reg_src), (reg_base), 0) +#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s32i_n((as), (reg_src), (reg_base), 0) + +#endif // GENERIC_ASM_API + +#endif // MICROPY_INCLUDED_PY_ASMXTENSA_H diff --git a/user/mpy/py/bc.c b/user/mpy/py/bc.c new file mode 100644 index 0000000..917eba5 --- /dev/null +++ b/user/mpy/py/bc.c @@ -0,0 +1,417 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/objfun.h" +#include "py/runtime0.h" +#include "py/bc0.h" +#include "py/bc.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#else // don't print debugging info +#define DEBUG_PRINT (0) +#define DEBUG_printf(...) (void)0 +#endif + +mp_uint_t mp_decode_uint(const byte **ptr) { + mp_uint_t unum = 0; + byte val; + const byte *p = *ptr; + do { + val = *p++; + unum = (unum << 7) | (val & 0x7f); + } while ((val & 0x80) != 0); + *ptr = p; + return unum; +} + +// This function is used to help reduce stack usage at the caller, for the case when +// the caller doesn't need to increase the ptr argument. If ptr is a local variable +// and the caller uses mp_decode_uint(&ptr) instead of this function, then the compiler +// must allocate a slot on the stack for ptr, and this slot cannot be reused for +// anything else in the function because the pointer may have been stored in a global +// and reused later in the function. +mp_uint_t mp_decode_uint_value(const byte *ptr) { + return mp_decode_uint(&ptr); +} + +// This function is used to help reduce stack usage at the caller, for the case when +// the caller doesn't need the actual value and just wants to skip over it. +const byte *mp_decode_uint_skip(const byte *ptr) { + while ((*ptr++) & 0x80) { + } + return ptr; +} + +STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) { +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE + // generic message, used also for other argument issues + (void)f; + (void)expected; + (void)given; + mp_arg_error_terse_mismatch(); +#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL + (void)f; + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function takes %d positional arguments but %d were given", expected, given)); +#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "%q() takes %d positional arguments but %d were given", + mp_obj_fun_get_name(MP_OBJ_FROM_PTR(f)), expected, given)); +#endif +} + +#if DEBUG_PRINT +STATIC void dump_args(const mp_obj_t *a, size_t sz) { + DEBUG_printf("%p: ", a); + for (size_t i = 0; i < sz; i++) { + DEBUG_printf("%p ", a[i]); + } + DEBUG_printf("\n"); +} +#else +#define dump_args(...) (void)0 +#endif + +// On entry code_state should be allocated somewhere (stack/heap) and +// contain the following valid entries: +// - code_state->fun_bc should contain a pointer to the function object +// - code_state->ip should contain the offset in bytes from the pointer +// code_state->fun_bc->bytecode to the entry n_state (0 for bytecode, non-zero for native) +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) { + // This function is pretty complicated. It's main aim is to be efficient in speed and RAM + // usage for the common case of positional only args. + + // get the function object that we want to set up (could be bytecode or native code) + mp_obj_fun_bc_t *self = code_state->fun_bc; + + // ip comes in as an offset into bytecode, so turn it into a true pointer + code_state->ip = self->bytecode + (size_t)code_state->ip; + + #if MICROPY_STACKLESS + code_state->prev = NULL; + #endif + + // get params + size_t n_state = mp_decode_uint(&code_state->ip); + code_state->ip = mp_decode_uint_skip(code_state->ip); // skip n_exc_stack + size_t scope_flags = *code_state->ip++; + size_t n_pos_args = *code_state->ip++; + size_t n_kwonly_args = *code_state->ip++; + size_t n_def_pos_args = *code_state->ip++; + + code_state->sp = &code_state->state[0] - 1; + code_state->exc_sp = (mp_exc_stack_t*)(code_state->state + n_state) - 1; + + // zero out the local stack to begin with + memset(code_state->state, 0, n_state * sizeof(*code_state->state)); + + const mp_obj_t *kwargs = args + n_args; + + // var_pos_kw_args points to the stack where the var-args tuple, and var-kw dict, should go (if they are needed) + mp_obj_t *var_pos_kw_args = &code_state->state[n_state - 1 - n_pos_args - n_kwonly_args]; + + // check positional arguments + + if (n_args > n_pos_args) { + // given more than enough arguments + if ((scope_flags & MP_SCOPE_FLAG_VARARGS) == 0) { + fun_pos_args_mismatch(self, n_pos_args, n_args); + } + // put extra arguments in varargs tuple + *var_pos_kw_args-- = mp_obj_new_tuple(n_args - n_pos_args, args + n_pos_args); + n_args = n_pos_args; + } else { + if ((scope_flags & MP_SCOPE_FLAG_VARARGS) != 0) { + DEBUG_printf("passing empty tuple as *args\n"); + *var_pos_kw_args-- = mp_const_empty_tuple; + } + // Apply processing and check below only if we don't have kwargs, + // otherwise, kw handling code below has own extensive checks. + if (n_kw == 0 && (scope_flags & MP_SCOPE_FLAG_DEFKWARGS) == 0) { + if (n_args >= (size_t)(n_pos_args - n_def_pos_args)) { + // given enough arguments, but may need to use some default arguments + for (size_t i = n_args; i < n_pos_args; i++) { + code_state->state[n_state - 1 - i] = self->extra_args[i - (n_pos_args - n_def_pos_args)]; + } + } else { + fun_pos_args_mismatch(self, n_pos_args - n_def_pos_args, n_args); + } + } + } + + // copy positional args into state + for (size_t i = 0; i < n_args; i++) { + code_state->state[n_state - 1 - i] = args[i]; + } + + // check keyword arguments + + if (n_kw != 0 || (scope_flags & MP_SCOPE_FLAG_DEFKWARGS) != 0) { + DEBUG_printf("Initial args: "); + dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); + + mp_obj_t dict = MP_OBJ_NULL; + if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) { + dict = mp_obj_new_dict(n_kw); // TODO: better go conservative with 0? + *var_pos_kw_args = dict; + } + + // get pointer to arg_names array + const mp_obj_t *arg_names = (const mp_obj_t*)self->const_table; + + for (size_t i = 0; i < n_kw; i++) { + // the keys in kwargs are expected to be qstr objects + mp_obj_t wanted_arg_name = kwargs[2 * i]; + for (size_t j = 0; j < n_pos_args + n_kwonly_args; j++) { + if (wanted_arg_name == arg_names[j]) { + if (code_state->state[n_state - 1 - j] != MP_OBJ_NULL) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function got multiple values for argument '%q'", MP_OBJ_QSTR_VALUE(wanted_arg_name))); + } + code_state->state[n_state - 1 - j] = kwargs[2 * i + 1]; + goto continue2; + } + } + // Didn't find name match with positional args + if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) == 0) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("unexpected keyword argument"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "unexpected keyword argument '%q'", MP_OBJ_QSTR_VALUE(wanted_arg_name))); + } + } + mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]); +continue2:; + } + + DEBUG_printf("Args with kws flattened: "); + dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); + + // fill in defaults for positional args + mp_obj_t *d = &code_state->state[n_state - n_pos_args]; + mp_obj_t *s = &self->extra_args[n_def_pos_args - 1]; + for (size_t i = n_def_pos_args; i > 0; i--, d++, s--) { + if (*d == MP_OBJ_NULL) { + *d = *s; + } + } + + DEBUG_printf("Args after filling default positional: "); + dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); + + // Check that all mandatory positional args are specified + while (d < &code_state->state[n_state]) { + if (*d++ == MP_OBJ_NULL) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function missing required positional argument #%d", &code_state->state[n_state] - d)); + } + } + + // Check that all mandatory keyword args are specified + // Fill in default kw args if we have them + for (size_t i = 0; i < n_kwonly_args; i++) { + if (code_state->state[n_state - 1 - n_pos_args - i] == MP_OBJ_NULL) { + mp_map_elem_t *elem = NULL; + if ((scope_flags & MP_SCOPE_FLAG_DEFKWARGS) != 0) { + elem = mp_map_lookup(&((mp_obj_dict_t*)MP_OBJ_TO_PTR(self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP); + } + if (elem != NULL) { + code_state->state[n_state - 1 - n_pos_args - i] = elem->value; + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function missing required keyword argument '%q'", MP_OBJ_QSTR_VALUE(arg_names[n_pos_args + i]))); + } + } + } + + } else { + // no keyword arguments given + if (n_kwonly_args != 0) { + mp_raise_TypeError("function missing keyword-only argument"); + } + if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) { + *var_pos_kw_args = mp_obj_new_dict(0); + } + } + + // get the ip and skip argument names + const byte *ip = code_state->ip; + + // jump over code info (source file and line-number mapping) + ip += mp_decode_uint_value(ip); + + // bytecode prelude: initialise closed over variables + size_t local_num; + while ((local_num = *ip++) != 255) { + code_state->state[n_state - 1 - local_num] = + mp_obj_new_cell(code_state->state[n_state - 1 - local_num]); + } + + // now that we skipped over the prelude, set the ip for the VM + code_state->ip = ip; + + DEBUG_printf("Calling: n_pos_args=%d, n_kwonly_args=%d\n", n_pos_args, n_kwonly_args); + dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); + dump_args(code_state->state, n_state); +} + +#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE + +// The following table encodes the number of bytes that a specific opcode +// takes up. There are 3 special opcodes that always have an extra byte: +// MP_BC_MAKE_CLOSURE +// MP_BC_MAKE_CLOSURE_DEFARGS +// MP_BC_RAISE_VARARGS +// There are 4 special opcodes that have an extra byte only when +// MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE is enabled: +// MP_BC_LOAD_NAME +// MP_BC_LOAD_GLOBAL +// MP_BC_LOAD_ATTR +// MP_BC_STORE_ATTR +#define OC4(a, b, c, d) (a | (b << 2) | (c << 4) | (d << 6)) +#define U (0) // undefined opcode +#define B (MP_OPCODE_BYTE) // single byte +#define Q (MP_OPCODE_QSTR) // single byte plus 2-byte qstr +#define V (MP_OPCODE_VAR_UINT) // single byte plus variable encoded unsigned int +#define O (MP_OPCODE_OFFSET) // single byte plus 2-byte bytecode offset +STATIC const byte opcode_format_table[64] = { + OC4(U, U, U, U), // 0x00-0x03 + OC4(U, U, U, U), // 0x04-0x07 + OC4(U, U, U, U), // 0x08-0x0b + OC4(U, U, U, U), // 0x0c-0x0f + OC4(B, B, B, U), // 0x10-0x13 + OC4(V, U, Q, V), // 0x14-0x17 + OC4(B, V, V, Q), // 0x18-0x1b + OC4(Q, Q, Q, Q), // 0x1c-0x1f + OC4(B, B, V, V), // 0x20-0x23 + OC4(Q, Q, Q, B), // 0x24-0x27 + OC4(V, V, Q, Q), // 0x28-0x2b + OC4(U, U, U, U), // 0x2c-0x2f + OC4(B, B, B, B), // 0x30-0x33 + OC4(B, O, O, O), // 0x34-0x37 + OC4(O, O, U, U), // 0x38-0x3b + OC4(U, O, B, O), // 0x3c-0x3f + OC4(O, B, B, O), // 0x40-0x43 + OC4(B, B, O, U), // 0x44-0x47 + OC4(U, U, U, U), // 0x48-0x4b + OC4(U, U, U, U), // 0x4c-0x4f + OC4(V, V, U, V), // 0x50-0x53 + OC4(B, U, V, V), // 0x54-0x57 + OC4(V, V, V, B), // 0x58-0x5b + OC4(B, B, B, U), // 0x5c-0x5f + OC4(V, V, V, V), // 0x60-0x63 + OC4(V, V, V, V), // 0x64-0x67 + OC4(Q, Q, B, U), // 0x68-0x6b + OC4(U, U, U, U), // 0x6c-0x6f + + OC4(B, B, B, B), // 0x70-0x73 + OC4(B, B, B, B), // 0x74-0x77 + OC4(B, B, B, B), // 0x78-0x7b + OC4(B, B, B, B), // 0x7c-0x7f + OC4(B, B, B, B), // 0x80-0x83 + OC4(B, B, B, B), // 0x84-0x87 + OC4(B, B, B, B), // 0x88-0x8b + OC4(B, B, B, B), // 0x8c-0x8f + OC4(B, B, B, B), // 0x90-0x93 + OC4(B, B, B, B), // 0x94-0x97 + OC4(B, B, B, B), // 0x98-0x9b + OC4(B, B, B, B), // 0x9c-0x9f + OC4(B, B, B, B), // 0xa0-0xa3 + OC4(B, B, B, B), // 0xa4-0xa7 + OC4(B, B, B, B), // 0xa8-0xab + OC4(B, B, B, B), // 0xac-0xaf + + OC4(B, B, B, B), // 0xb0-0xb3 + OC4(B, B, B, B), // 0xb4-0xb7 + OC4(B, B, B, B), // 0xb8-0xbb + OC4(B, B, B, B), // 0xbc-0xbf + + OC4(B, B, B, B), // 0xc0-0xc3 + OC4(B, B, B, B), // 0xc4-0xc7 + OC4(B, B, B, B), // 0xc8-0xcb + OC4(B, B, B, B), // 0xcc-0xcf + + OC4(B, B, B, B), // 0xd0-0xd3 + OC4(B, B, B, B), // 0xd4-0xd7 + OC4(B, B, B, B), // 0xd8-0xdb + OC4(B, B, B, B), // 0xdc-0xdf + + OC4(B, B, B, B), // 0xe0-0xe3 + OC4(B, B, B, B), // 0xe4-0xe7 + OC4(B, B, B, B), // 0xe8-0xeb + OC4(B, B, B, B), // 0xec-0xef + + OC4(B, B, B, B), // 0xf0-0xf3 + OC4(B, B, B, B), // 0xf4-0xf7 + OC4(B, B, B, U), // 0xf8-0xfb + OC4(U, U, U, U), // 0xfc-0xff +}; +#undef OC4 +#undef U +#undef B +#undef Q +#undef V +#undef O + +uint mp_opcode_format(const byte *ip, size_t *opcode_size) { + uint f = (opcode_format_table[*ip >> 2] >> (2 * (*ip & 3))) & 3; + const byte *ip_start = ip; + if (f == MP_OPCODE_QSTR) { + ip += 3; + } else { + int extra_byte = ( + *ip == MP_BC_RAISE_VARARGS + || *ip == MP_BC_MAKE_CLOSURE + || *ip == MP_BC_MAKE_CLOSURE_DEFARGS + #if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE + || *ip == MP_BC_LOAD_NAME + || *ip == MP_BC_LOAD_GLOBAL + || *ip == MP_BC_LOAD_ATTR + || *ip == MP_BC_STORE_ATTR + #endif + ); + ip += 1; + if (f == MP_OPCODE_VAR_UINT) { + while ((*ip++ & 0x80) != 0) { + } + } else if (f == MP_OPCODE_OFFSET) { + ip += 2; + } + ip += extra_byte; + } + *opcode_size = ip - ip_start; + return f; +} + +#endif // MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE diff --git a/user/mpy/py/bc.h b/user/mpy/py/bc.h new file mode 100644 index 0000000..69e213e --- /dev/null +++ b/user/mpy/py/bc.h @@ -0,0 +1,122 @@ +/* + * 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_BC_H +#define MICROPY_INCLUDED_PY_BC_H + +#include "py/runtime.h" +#include "py/obj.h" +#include "py/objfun.h" + +// bytecode layout: +// +// n_state : var uint +// n_exc_stack : var uint +// scope_flags : byte +// n_pos_args : byte number of arguments this function takes +// n_kwonly_args : byte number of keyword-only arguments this function takes +// n_def_pos_args : byte number of default positional arguments +// +// code_info_size : var uint | code_info_size counts bytes in this chunk +// simple_name : var qstr | +// source_file : var qstr | +// | +// | only needed if bytecode contains pointers +// +// local_num0 : byte | +// ... : byte | +// local_numN : byte | N = num_cells +// 255 : byte | end of list sentinel +// | +// +// +// constant table layout: +// +// argname0 : obj (qstr) +// ... : obj (qstr) +// argnameN : obj (qstr) N = num_pos_args + num_kwonly_args +// const0 : obj +// constN : obj + +// Exception stack entry +typedef struct _mp_exc_stack_t { + const byte *handler; + // bit 0 is saved currently_in_except_block value + // bit 1 is whether the opcode was SETUP_WITH or SETUP_FINALLY + mp_obj_t *val_sp; + // Saved exception, valid if currently_in_except_block bit is 1 + mp_obj_base_t *prev_exc; +} mp_exc_stack_t; + +typedef struct _mp_code_state_t { + // The fun_bc entry points to the underlying function object that is being executed. + // It is needed to access the start of bytecode and the const_table. + // It is also needed to prevent the GC from reclaiming the bytecode during execution, + // because the ip pointer below will always point to the interior of the bytecode. + mp_obj_fun_bc_t *fun_bc; + const byte *ip; + mp_obj_t *sp; + // bit 0 is saved currently_in_except_block value + mp_exc_stack_t *exc_sp; + mp_obj_dict_t *old_globals; + #if MICROPY_STACKLESS + struct _mp_code_state_t *prev; + #endif + // Variable-length + mp_obj_t state[0]; + // Variable-length, never accessed by name, only as (void*)(state + n_state) + //mp_exc_stack_t exc_state[0]; +} mp_code_state_t; + +mp_uint_t mp_decode_uint(const byte **ptr); +mp_uint_t mp_decode_uint_value(const byte *ptr); +const byte *mp_decode_uint_skip(const byte *ptr); + +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); +void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); +const byte *mp_bytecode_print_str(const byte *ip); +#define mp_bytecode_print_inst(code, const_table) mp_bytecode_print2(code, 1, const_table) + +// Helper macros to access pointer with least significant bits holding flags +#define MP_TAGPTR_PTR(x) ((void*)((uintptr_t)(x) & ~((uintptr_t)3))) +#define MP_TAGPTR_TAG0(x) ((uintptr_t)(x) & 1) +#define MP_TAGPTR_TAG1(x) ((uintptr_t)(x) & 2) +#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((uintptr_t)(ptr) | (tag))) + +#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE + +#define MP_OPCODE_BYTE (0) +#define MP_OPCODE_QSTR (1) +#define MP_OPCODE_VAR_UINT (2) +#define MP_OPCODE_OFFSET (3) + +uint mp_opcode_format(const byte *ip, size_t *opcode_size); + +#endif + +#endif // MICROPY_INCLUDED_PY_BC_H diff --git a/user/mpy/py/bc0.h b/user/mpy/py/bc0.h new file mode 100644 index 0000000..f671c5b --- /dev/null +++ b/user/mpy/py/bc0.h @@ -0,0 +1,119 @@ +/* + * 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_BC0_H +#define MICROPY_INCLUDED_PY_BC0_H + +// MicroPython byte-codes. +// The comment at the end of the line (if it exists) tells the arguments to the byte-code. + +#define MP_BC_LOAD_CONST_FALSE (0x10) +#define MP_BC_LOAD_CONST_NONE (0x11) +#define MP_BC_LOAD_CONST_TRUE (0x12) +#define MP_BC_LOAD_CONST_SMALL_INT (0x14) // signed var-int +#define MP_BC_LOAD_CONST_STRING (0x16) // qstr +#define MP_BC_LOAD_CONST_OBJ (0x17) // ptr +#define MP_BC_LOAD_NULL (0x18) + +#define MP_BC_LOAD_FAST_N (0x19) // uint +#define MP_BC_LOAD_DEREF (0x1a) // uint +#define MP_BC_LOAD_NAME (0x1b) // qstr +#define MP_BC_LOAD_GLOBAL (0x1c) // qstr +#define MP_BC_LOAD_ATTR (0x1d) // qstr +#define MP_BC_LOAD_METHOD (0x1e) // qstr +#define MP_BC_LOAD_SUPER_METHOD (0x1f) // qstr +#define MP_BC_LOAD_BUILD_CLASS (0x20) +#define MP_BC_LOAD_SUBSCR (0x21) + +#define MP_BC_STORE_FAST_N (0x22) // uint +#define MP_BC_STORE_DEREF (0x23) // uint +#define MP_BC_STORE_NAME (0x24) // qstr +#define MP_BC_STORE_GLOBAL (0x25) // qstr +#define MP_BC_STORE_ATTR (0x26) // qstr +#define MP_BC_STORE_SUBSCR (0x27) + +#define MP_BC_DELETE_FAST (0x28) // uint +#define MP_BC_DELETE_DEREF (0x29) // uint +#define MP_BC_DELETE_NAME (0x2a) // qstr +#define MP_BC_DELETE_GLOBAL (0x2b) // qstr + +#define MP_BC_DUP_TOP (0x30) +#define MP_BC_DUP_TOP_TWO (0x31) +#define MP_BC_POP_TOP (0x32) +#define MP_BC_ROT_TWO (0x33) +#define MP_BC_ROT_THREE (0x34) + +#define MP_BC_JUMP (0x35) // rel byte code offset, 16-bit signed, in excess +#define MP_BC_POP_JUMP_IF_TRUE (0x36) // rel byte code offset, 16-bit signed, in excess +#define MP_BC_POP_JUMP_IF_FALSE (0x37) // rel byte code offset, 16-bit signed, in excess +#define MP_BC_JUMP_IF_TRUE_OR_POP (0x38) // rel byte code offset, 16-bit signed, in excess +#define MP_BC_JUMP_IF_FALSE_OR_POP (0x39) // rel byte code offset, 16-bit signed, in excess +#define MP_BC_SETUP_WITH (0x3d) // rel byte code offset, 16-bit unsigned +#define MP_BC_WITH_CLEANUP (0x3e) +#define MP_BC_SETUP_EXCEPT (0x3f) // rel byte code offset, 16-bit unsigned +#define MP_BC_SETUP_FINALLY (0x40) // rel byte code offset, 16-bit unsigned +#define MP_BC_END_FINALLY (0x41) +#define MP_BC_GET_ITER (0x42) +#define MP_BC_FOR_ITER (0x43) // rel byte code offset, 16-bit unsigned +#define MP_BC_POP_BLOCK (0x44) +#define MP_BC_POP_EXCEPT (0x45) +#define MP_BC_UNWIND_JUMP (0x46) // rel byte code offset, 16-bit signed, in excess; then a byte +#define MP_BC_GET_ITER_STACK (0x47) + +#define MP_BC_BUILD_TUPLE (0x50) // uint +#define MP_BC_BUILD_LIST (0x51) // uint +#define MP_BC_BUILD_MAP (0x53) // uint +#define MP_BC_STORE_MAP (0x54) +#define MP_BC_BUILD_SET (0x56) // uint +#define MP_BC_BUILD_SLICE (0x58) // uint +#define MP_BC_STORE_COMP (0x57) // uint +#define MP_BC_UNPACK_SEQUENCE (0x59) // uint +#define MP_BC_UNPACK_EX (0x5a) // uint + +#define MP_BC_RETURN_VALUE (0x5b) +#define MP_BC_RAISE_VARARGS (0x5c) // byte +#define MP_BC_YIELD_VALUE (0x5d) +#define MP_BC_YIELD_FROM (0x5e) + +#define MP_BC_MAKE_FUNCTION (0x60) // uint +#define MP_BC_MAKE_FUNCTION_DEFARGS (0x61) // uint +#define MP_BC_MAKE_CLOSURE (0x62) // uint +#define MP_BC_MAKE_CLOSURE_DEFARGS (0x63) // uint +#define MP_BC_CALL_FUNCTION (0x64) // uint +#define MP_BC_CALL_FUNCTION_VAR_KW (0x65) // uint +#define MP_BC_CALL_METHOD (0x66) // uint +#define MP_BC_CALL_METHOD_VAR_KW (0x67) // uint + +#define MP_BC_IMPORT_NAME (0x68) // qstr +#define MP_BC_IMPORT_FROM (0x69) // qstr +#define MP_BC_IMPORT_STAR (0x6a) + +#define MP_BC_LOAD_CONST_SMALL_INT_MULTI (0x70) // + N(64) +#define MP_BC_LOAD_FAST_MULTI (0xb0) // + N(16) +#define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16) +#define MP_BC_UNARY_OP_MULTI (0xd0) // + op(7) +#define MP_BC_BINARY_OP_MULTI (0xd7) // + op(36) + +#endif // MICROPY_INCLUDED_PY_BC0_H diff --git a/user/mpy/py/binary.c b/user/mpy/py/binary.c new file mode 100644 index 0000000..870a094 --- /dev/null +++ b/user/mpy/py/binary.c @@ -0,0 +1,392 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +#include "py/binary.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/runtime.h" + +// Helpers to work with binary-encoded data + +#ifndef alignof +#define alignof(type) offsetof(struct { char c; type t; }, t) +#endif + +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) { + size_t size = 0; + int align = 1; + switch (struct_type) { + case '<': case '>': + switch (val_type) { + case 'b': case 'B': + size = 1; break; + case 'h': case 'H': + size = 2; break; + case 'i': case 'I': + size = 4; break; + case 'l': case 'L': + size = 4; break; + case 'q': case 'Q': + size = 8; break; + case 'P': case 'O': case 'S': + size = sizeof(void*); break; + case 'f': + size = sizeof(float); break; + case 'd': + size = sizeof(double); break; + } + break; + case '@': { + // TODO: + // The simplest heuristic for alignment is to align by value + // size, but that doesn't work for "bigger than int" types, + // for example, long long may very well have long alignment + // So, we introduce separate alignment handling, but having + // formal support for that is different from actually supporting + // particular (or any) ABI. + switch (val_type) { + case BYTEARRAY_TYPECODE: + case 'b': case 'B': + align = size = 1; break; + case 'h': case 'H': + align = alignof(short); + size = sizeof(short); break; + case 'i': case 'I': + align = alignof(int); + size = sizeof(int); break; + case 'l': case 'L': + align = alignof(long); + size = sizeof(long); break; + case 'q': case 'Q': + align = alignof(long long); + size = sizeof(long long); break; + case 'P': case 'O': case 'S': + align = alignof(void*); + size = sizeof(void*); break; + case 'f': + align = alignof(float); + size = sizeof(float); break; + case 'd': + align = alignof(double); + size = sizeof(double); break; + } + } + } + + if (size == 0) { + mp_raise_ValueError("bad typecode"); + } + + if (palign != NULL) { + *palign = align; + } + return size; +} + +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { + mp_int_t val = 0; + switch (typecode) { + case 'b': + val = ((signed char*)p)[index]; + break; + case BYTEARRAY_TYPECODE: + case 'B': + val = ((unsigned char*)p)[index]; + break; + case 'h': + val = ((short*)p)[index]; + break; + case 'H': + val = ((unsigned short*)p)[index]; + break; + case 'i': + return mp_obj_new_int(((int*)p)[index]); + case 'I': + return mp_obj_new_int_from_uint(((unsigned int*)p)[index]); + case 'l': + return mp_obj_new_int(((long*)p)[index]); + case 'L': + return mp_obj_new_int_from_uint(((unsigned long*)p)[index]); + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + case 'q': + return mp_obj_new_int_from_ll(((long long*)p)[index]); + case 'Q': + return mp_obj_new_int_from_ull(((unsigned long long*)p)[index]); + #endif +#if MICROPY_PY_BUILTINS_FLOAT + case 'f': + return mp_obj_new_float(((float*)p)[index]); + case 'd': + return mp_obj_new_float(((double*)p)[index]); +#endif + // Extension to CPython: array of objects + case 'O': + return ((mp_obj_t*)p)[index]; + // Extension to CPython: array of pointers + case 'P': + return mp_obj_new_int((mp_int_t)(uintptr_t)((void**)p)[index]); + } + return MP_OBJ_NEW_SMALL_INT(val); +} + +// The long long type is guaranteed to hold at least 64 bits, and size is at +// most 8 (for q and Q), so we will always be able to parse the given data +// and fit it into a long long. +long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src) { + int delta; + if (!big_endian) { + delta = -1; + src += size - 1; + } else { + delta = 1; + } + + long long val = 0; + if (is_signed && *src & 0x80) { + val = -1; + } + for (uint i = 0; i < size; i++) { + val <<= 8; + val |= *src; + src += delta; + } + + return val; +} + +#define is_signed(typecode) (typecode > 'Z') +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) { + byte *p = *ptr; + mp_uint_t align; + + size_t size = mp_binary_get_size(struct_type, val_type, &align); + if (struct_type == '@') { + // Make pointer aligned + p = (byte*)MP_ALIGN(p, (size_t)align); + #if MP_ENDIANNESS_LITTLE + struct_type = '<'; + #else + struct_type = '>'; + #endif + } + *ptr = p + size; + + long long val = mp_binary_get_int(size, is_signed(val_type), (struct_type == '>'), p); + + if (val_type == 'O') { + return (mp_obj_t)(mp_uint_t)val; + } else if (val_type == 'S') { + const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val; + return mp_obj_new_str(s_val, strlen(s_val), false); +#if MICROPY_PY_BUILTINS_FLOAT + } else if (val_type == 'f') { + union { uint32_t i; float f; } fpu = {val}; + return mp_obj_new_float(fpu.f); + } else if (val_type == 'd') { + union { uint64_t i; double f; } fpu = {val}; + return mp_obj_new_float(fpu.f); +#endif + } else if (is_signed(val_type)) { + if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) { + return mp_obj_new_int((mp_int_t)val); + } else { + return mp_obj_new_int_from_ll(val); + } + } else { + if ((unsigned long long)val <= (unsigned long long)MP_SMALL_INT_MAX) { + return mp_obj_new_int_from_uint((mp_uint_t)val); + } else { + return mp_obj_new_int_from_ull(val); + } + } +} + +void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val) { + if (MP_ENDIANNESS_LITTLE && !big_endian) { + memcpy(dest, &val, val_sz); + } else if (MP_ENDIANNESS_BIG && big_endian) { + // only copy the least-significant val_sz bytes + memcpy(dest, (byte*)&val + sizeof(mp_uint_t) - val_sz, val_sz); + } else { + const byte *src; + if (MP_ENDIANNESS_LITTLE) { + src = (const byte*)&val + val_sz; + } else { + src = (const byte*)&val + sizeof(mp_uint_t); + } + while (val_sz--) { + *dest++ = *--src; + } + } +} + +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr) { + byte *p = *ptr; + mp_uint_t align; + + size_t size = mp_binary_get_size(struct_type, val_type, &align); + if (struct_type == '@') { + // Make pointer aligned + p = (byte*)MP_ALIGN(p, (size_t)align); + if (MP_ENDIANNESS_LITTLE) { + struct_type = '<'; + } else { + struct_type = '>'; + } + } + *ptr = p + size; + + mp_uint_t val; + switch (val_type) { + case 'O': + val = (mp_uint_t)val_in; + break; +#if MICROPY_PY_BUILTINS_FLOAT + case 'f': { + union { uint32_t i; float f; } fp_sp; + fp_sp.f = mp_obj_get_float(val_in); + val = fp_sp.i; + break; + } + case 'd': { + union { uint64_t i64; uint32_t i32[2]; double f; } fp_dp; + fp_dp.f = mp_obj_get_float(val_in); + if (BYTES_PER_WORD == 8) { + val = fp_dp.i64; + } else { + int be = struct_type == '>'; + mp_binary_set_int(sizeof(uint32_t), be, p, fp_dp.i32[MP_ENDIANNESS_BIG ^ be]); + p += sizeof(uint32_t); + val = fp_dp.i32[MP_ENDIANNESS_LITTLE ^ be]; + } + break; + } +#endif + default: + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) { + mp_obj_int_to_bytes_impl(val_in, struct_type == '>', size, p); + return; + } else + #endif + { + val = mp_obj_get_int(val_in); + // zero/sign extend if needed + if (BYTES_PER_WORD < 8 && size > sizeof(val)) { + int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00; + memset(p, c, size); + if (struct_type == '>') { + p += size - sizeof(val); + } + } + } + } + + mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val); +} + +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) { + switch (typecode) { +#if MICROPY_PY_BUILTINS_FLOAT + case 'f': + ((float*)p)[index] = mp_obj_get_float(val_in); + break; + case 'd': + ((double*)p)[index] = mp_obj_get_float(val_in); + break; +#endif + // Extension to CPython: array of objects + case 'O': + ((mp_obj_t*)p)[index] = val_in; + break; + default: + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) { + size_t size = mp_binary_get_size('@', typecode, NULL); + mp_obj_int_to_bytes_impl(val_in, MP_ENDIANNESS_BIG, + size, (uint8_t*)p + index * size); + return; + } + #endif + mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in)); + } +} + +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val) { + switch (typecode) { + case 'b': + ((signed char*)p)[index] = val; + break; + case BYTEARRAY_TYPECODE: + case 'B': + ((unsigned char*)p)[index] = val; + break; + case 'h': + ((short*)p)[index] = val; + break; + case 'H': + ((unsigned short*)p)[index] = val; + break; + case 'i': + ((int*)p)[index] = val; + break; + case 'I': + ((unsigned int*)p)[index] = val; + break; + case 'l': + ((long*)p)[index] = val; + break; + case 'L': + ((unsigned long*)p)[index] = val; + break; + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + case 'q': + ((long long*)p)[index] = val; + break; + case 'Q': + ((unsigned long long*)p)[index] = val; + break; + #endif +#if MICROPY_PY_BUILTINS_FLOAT + case 'f': + ((float*)p)[index] = val; + break; + case 'd': + ((double*)p)[index] = val; + break; +#endif + // Extension to CPython: array of pointers + case 'P': + ((void**)p)[index] = (void*)(uintptr_t)val; + break; + } +} diff --git a/user/mpy/py/binary.h b/user/mpy/py/binary.h new file mode 100644 index 0000000..7b5c60f --- /dev/null +++ b/user/mpy/py/binary.h @@ -0,0 +1,44 @@ +/* + * 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_BINARY_H +#define MICROPY_INCLUDED_PY_BINARY_H + +#include "py/obj.h" + +// Use special typecode to differentiate repr() of bytearray vs array.array('B') +// (underlyingly they're same). +#define BYTEARRAY_TYPECODE 0 + +size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); +mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); +void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); +void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); +mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); +void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); +long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src); +void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val); + +#endif // MICROPY_INCLUDED_PY_BINARY_H diff --git a/user/mpy/py/builtin.h b/user/mpy/py/builtin.h new file mode 100644 index 0000000..a637b6e --- /dev/null +++ b/user/mpy/py/builtin.h @@ -0,0 +1,123 @@ +/* + * 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_BUILTIN_H +#define MICROPY_INCLUDED_PY_BUILTIN_H + +#include "py/obj.h" + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); + +MP_DECLARE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_abs_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_all_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_any_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_bin_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_callable_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_chr_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_execfile_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj); +MP_DECLARE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_builtin_globals_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_hash_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_hex_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_id_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_isinstance_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_iter_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_len_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_builtin_locals_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_max_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_min_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_next_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_oct_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_ord_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_print_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_repr_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj); +// Defined by a port, but declared here for simplicity +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj); + +MP_DECLARE_CONST_FUN_OBJ_2(mp_namedtuple_obj); + +MP_DECLARE_CONST_FUN_OBJ_2(mp_op_contains_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_op_getitem_obj); +MP_DECLARE_CONST_FUN_OBJ_3(mp_op_setitem_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_op_delitem_obj); + +extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; +extern const mp_obj_module_t mp_module_array; +extern const mp_obj_module_t mp_module_collections; +extern const mp_obj_module_t mp_module_io; +extern const mp_obj_module_t mp_module_math; +extern const mp_obj_module_t mp_module_cmath; +extern const mp_obj_module_t mp_module_micropython; +extern const mp_obj_module_t mp_module_ustruct; +extern const mp_obj_module_t mp_module_sys; +extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_module_t mp_module_thread; + +extern const mp_obj_dict_t mp_module_builtins_globals; + +// extmod modules +extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_uctypes; +extern const mp_obj_module_t mp_module_uzlib; +extern const mp_obj_module_t mp_module_ujson; +extern const mp_obj_module_t mp_module_ure; +extern const mp_obj_module_t mp_module_uheapq; +extern const mp_obj_module_t mp_module_uhashlib; +extern const mp_obj_module_t mp_module_ubinascii; +extern const mp_obj_module_t mp_module_urandom; +extern const mp_obj_module_t mp_module_uselect; +extern const mp_obj_module_t mp_module_ussl; +extern const mp_obj_module_t mp_module_utimeq; +extern const mp_obj_module_t mp_module_machine; +extern const mp_obj_module_t mp_module_lwip; +extern const mp_obj_module_t mp_module_websocket; +extern const mp_obj_module_t mp_module_webrepl; +extern const mp_obj_module_t mp_module_framebuf; +extern const mp_obj_module_t mp_module_btree; + +extern const char *MICROPY_PY_BUILTINS_HELP_TEXT; + +#endif // MICROPY_INCLUDED_PY_BUILTIN_H diff --git a/user/mpy/py/builtinevex.c b/user/mpy/py/builtinevex.c new file mode 100644 index 0000000..ba8048f --- /dev/null +++ b/user/mpy/py/builtinevex.c @@ -0,0 +1,168 @@ +/* + * 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. + */ + +#include + +#include "py/nlr.h" +#include "py/objfun.h" +#include "py/compile.h" +#include "py/runtime.h" +#include "py/builtin.h" + +#if MICROPY_PY_BUILTINS_COMPILE + +typedef struct _mp_obj_code_t { + mp_obj_base_t base; + mp_obj_t module_fun; +} mp_obj_code_t; + +STATIC const mp_obj_type_t mp_type_code = { + { &mp_type_type }, + .name = MP_QSTR_code, +}; + +STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { + // save context and set new context + mp_obj_dict_t *old_globals = mp_globals_get(); + mp_obj_dict_t *old_locals = mp_locals_get(); + mp_globals_set(globals); + mp_locals_set(locals); + + // a bit of a hack: fun_bc will re-set globals, so need to make sure it's + // the correct one + if (MP_OBJ_IS_TYPE(self->module_fun, &mp_type_fun_bc)) { + mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(self->module_fun); + fun_bc->globals = globals; + } + + // execute code + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t ret = mp_call_function_0(self->module_fun); + nlr_pop(); + mp_globals_set(old_globals); + mp_locals_set(old_locals); + return ret; + } else { + // exception; restore context and re-raise same exception + mp_globals_set(old_globals); + mp_locals_set(old_locals); + nlr_jump(nlr.ret_val); + } +} + +STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) { + (void)n_args; + + // get the source + size_t str_len; + const char *str = mp_obj_str_get_data(args[0], &str_len); + + // get the filename + qstr filename = mp_obj_str_get_qstr(args[1]); + + // create the lexer + mp_lexer_t *lex = mp_lexer_new_from_str_len(filename, str, str_len, 0); + + // get the compile mode + qstr mode = mp_obj_str_get_qstr(args[2]); + mp_parse_input_kind_t parse_input_kind; + switch (mode) { + case MP_QSTR_single: parse_input_kind = MP_PARSE_SINGLE_INPUT; break; + case MP_QSTR_exec: parse_input_kind = MP_PARSE_FILE_INPUT; break; + case MP_QSTR_eval: parse_input_kind = MP_PARSE_EVAL_INPUT; break; + default: + mp_raise_ValueError("bad compile mode"); + } + + mp_obj_code_t *code = m_new_obj(mp_obj_code_t); + code->base.type = &mp_type_code; + code->module_fun = mp_parse_compile_execute(lex, parse_input_kind, NULL, NULL); + return MP_OBJ_FROM_PTR(code); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_compile); + +#endif // MICROPY_PY_BUILTINS_COMPILE + +#if MICROPY_PY_BUILTINS_EVAL_EXEC + +STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) { + // work out the context + mp_obj_dict_t *globals = mp_globals_get(); + mp_obj_dict_t *locals = mp_locals_get(); + for (size_t i = 1; i < 3 && i < n_args; ++i) { + if (args[i] != mp_const_none) { + if (!MP_OBJ_IS_TYPE(args[i], &mp_type_dict)) { + mp_raise_TypeError(NULL); + } + locals = MP_OBJ_TO_PTR(args[i]); + if (i == 1) { + globals = locals; + } + } + } + + #if MICROPY_PY_BUILTINS_COMPILE + if (MP_OBJ_IS_TYPE(args[0], &mp_type_code)) { + return code_execute(MP_OBJ_TO_PTR(args[0]), globals, locals); + } + #endif + + size_t str_len; + const char *str = mp_obj_str_get_data(args[0], &str_len); + + // create the lexer + // MP_PARSE_SINGLE_INPUT is used to indicate a file input + mp_lexer_t *lex; + if (MICROPY_PY_BUILTINS_EXECFILE && parse_input_kind == MP_PARSE_SINGLE_INPUT) { + lex = mp_lexer_new_from_file(str); + parse_input_kind = MP_PARSE_FILE_INPUT; + } else { + lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0); + } + + return mp_parse_compile_execute(lex, parse_input_kind, globals, locals); +} + +STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) { + return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj, 1, 3, mp_builtin_eval); + +STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) { + return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec); + +#endif // MICROPY_PY_BUILTINS_EVAL_EXEC + +#if MICROPY_PY_BUILTINS_EXECFILE +STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) { + // MP_PARSE_SINGLE_INPUT is used to indicate a file input + return eval_exec_helper(n_args, args, MP_PARSE_SINGLE_INPUT); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_execfile_obj, 1, 3, mp_builtin_execfile); +#endif diff --git a/user/mpy/py/builtinhelp.c b/user/mpy/py/builtinhelp.c new file mode 100644 index 0000000..dbcd6e0 --- /dev/null +++ b/user/mpy/py/builtinhelp.c @@ -0,0 +1,180 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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. + */ + +#include +#include + +#include "py/builtin.h" +#include "py/objmodule.h" + +#if MICROPY_PY_BUILTINS_HELP + +const char *mp_help_default_text = +"Welcome to MicroPython!\n" +"\n" +"For online docs please visit http://docs.micropython.org/\n" +"\n" +"Control commands:\n" +" CTRL-A -- on a blank line, enter raw REPL mode\n" +" CTRL-B -- on a blank line, enter normal REPL mode\n" +" CTRL-C -- interrupt a running program\n" +" CTRL-D -- on a blank line, exit or do a soft reset\n" +" CTRL-E -- on a blank line, enter paste mode\n" +"\n" +"For further help on a specific object, type help(obj)\n" +; + +STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) { + mp_print_str(MP_PYTHON_PRINTER, " "); + mp_obj_print(name_o, PRINT_STR); + mp_print_str(MP_PYTHON_PRINTER, " -- "); + mp_obj_print(value, PRINT_STR); + mp_print_str(MP_PYTHON_PRINTER, "\n"); +} + +#if MICROPY_PY_BUILTINS_HELP_MODULES +STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) { + for (size_t i = 0; i < map->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + mp_obj_list_append(list, map->table[i].key); + } + } +} + +#if MICROPY_MODULE_FROZEN +STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) { + while (*name) { + size_t l = strlen(name); + // name should end in '.py' and we strip it off + mp_obj_list_append(list, mp_obj_new_str(name, l - 3, false)); + name += l + 1; + } +} +#endif + +STATIC void mp_help_print_modules(void) { + mp_obj_t list = mp_obj_new_list(0, NULL); + + mp_help_add_from_map(list, &mp_builtin_module_map); + + #if MICROPY_MODULE_WEAK_LINKS + mp_help_add_from_map(list, &mp_builtin_module_weak_links_map); + #endif + + #if MICROPY_MODULE_FROZEN_STR + extern const char mp_frozen_str_names[]; + mp_help_add_from_names(list, mp_frozen_str_names); + #endif + + #if MICROPY_MODULE_FROZEN_MPY + extern const char mp_frozen_mpy_names[]; + mp_help_add_from_names(list, mp_frozen_mpy_names); + #endif + + // sort the list so it's printed in alphabetical order + mp_obj_list_sort(1, &list, (mp_map_t*)&mp_const_empty_map); + + // print the list of modules in a column-first order + #define NUM_COLUMNS (4) + #define COLUMN_WIDTH (18) + mp_uint_t len; + mp_obj_t *items; + mp_obj_list_get(list, &len, &items); + unsigned int num_rows = (len + NUM_COLUMNS - 1) / NUM_COLUMNS; + for (unsigned int i = 0; i < num_rows; ++i) { + unsigned int j = i; + for (;;) { + int l = mp_print_str(MP_PYTHON_PRINTER, mp_obj_str_get_str(items[j])); + j += num_rows; + if (j >= len) { + break; + } + int gap = COLUMN_WIDTH - l; + while (gap < 1) { + gap += COLUMN_WIDTH; + } + while (gap--) { + mp_print_str(MP_PYTHON_PRINTER, " "); + } + } + mp_print_str(MP_PYTHON_PRINTER, "\n"); + } + + // let the user know there may be other modules available from the filesystem + mp_print_str(MP_PYTHON_PRINTER, "Plus any modules on the filesystem\n"); +} +#endif + +STATIC void mp_help_print_obj(const mp_obj_t obj) { + #if MICROPY_PY_BUILTINS_HELP_MODULES + if (obj == MP_OBJ_NEW_QSTR(MP_QSTR_modules)) { + mp_help_print_modules(); + return; + } + #endif + + // try to print something sensible about the given object + mp_print_str(MP_PYTHON_PRINTER, "object "); + mp_obj_print(obj, PRINT_STR); + mp_printf(MP_PYTHON_PRINTER, " is of type %s\n", mp_obj_get_type_str(obj)); + + mp_map_t *map = NULL; + if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) { + map = mp_obj_dict_get_map(mp_obj_module_get_globals(obj)); + } else { + mp_obj_type_t *type; + if (MP_OBJ_IS_TYPE(obj, &mp_type_type)) { + type = obj; + } else { + type = mp_obj_get_type(obj); + } + if (type->locals_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(type->locals_dict, &mp_type_dict)) { + map = mp_obj_dict_get_map(type->locals_dict); + } + } + if (map != NULL) { + for (uint i = 0; i < map->alloc; i++) { + if (map->table[i].key != MP_OBJ_NULL) { + mp_help_print_info_about_object(map->table[i].key, map->table[i].value); + } + } + } +} + +STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + // print a general help message + mp_print_str(MP_PYTHON_PRINTER, MICROPY_PY_BUILTINS_HELP_TEXT); + } else { + // try to print something sensible about the given object + mp_help_print_obj(args[0]); + } + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj, 0, 1, mp_builtin_help); + +#endif // MICROPY_PY_BUILTINS_HELP diff --git a/user/mpy/py/builtinimport.c b/user/mpy/py/builtinimport.c new file mode 100644 index 0000000..f5bfb0d --- /dev/null +++ b/user/mpy/py/builtinimport.c @@ -0,0 +1,475 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/compile.h" +#include "py/objmodule.h" +#include "py/persistentcode.h" +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/frozenmod.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_PRINT (0) +#define DEBUG_printf(...) (void)0 +#endif + +#define PATH_SEP_CHAR '/' + +bool mp_obj_is_package(mp_obj_t module) { + mp_obj_t dest[2]; + mp_load_method_maybe(module, MP_QSTR___path__, dest); + return dest[0] != MP_OBJ_NULL; +} + +// Stat either frozen or normal module by a given path +// (whatever is available, if at all). +STATIC mp_import_stat_t mp_import_stat_any(const char *path) { + #if MICROPY_MODULE_FROZEN + mp_import_stat_t st = mp_frozen_stat(path); + if (st != MP_IMPORT_STAT_NO_EXIST) { + return st; + } + #endif + return mp_import_stat(path); +} + +STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { + mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + if (stat == MP_IMPORT_STAT_FILE) { + return stat; + } + + #if MICROPY_PERSISTENT_CODE_LOAD + vstr_ins_byte(path, path->len - 2, 'm'); + stat = mp_import_stat_any(vstr_null_terminated_str(path)); + if (stat == MP_IMPORT_STAT_FILE) { + return stat; + } + #endif + + return MP_IMPORT_STAT_NO_EXIST; +} + +STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) { + mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + DEBUG_printf("stat %s: %d\n", vstr_str(path), stat); + if (stat == MP_IMPORT_STAT_DIR) { + return stat; + } + + // not a directory, add .py and try as a file + vstr_add_str(path, ".py"); + return stat_file_py_or_mpy(path); +} + +STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { +#if MICROPY_PY_SYS + // extract the list of paths + size_t path_num; + mp_obj_t *path_items; + mp_obj_list_get(mp_sys_path, &path_num, &path_items); + + if (path_num == 0) { +#endif + // mp_sys_path is empty, so just use the given file name + vstr_add_strn(dest, file_str, file_len); + return stat_dir_or_file(dest); +#if MICROPY_PY_SYS + } else { + // go through each path looking for a directory or file + for (size_t i = 0; i < path_num; i++) { + vstr_reset(dest); + size_t p_len; + const char *p = mp_obj_str_get_data(path_items[i], &p_len); + if (p_len > 0) { + vstr_add_strn(dest, p, p_len); + vstr_add_char(dest, PATH_SEP_CHAR); + } + vstr_add_strn(dest, file_str, file_len); + mp_import_stat_t stat = stat_dir_or_file(dest); + if (stat != MP_IMPORT_STAT_NO_EXIST) { + return stat; + } + } + + // could not find a directory or file + return MP_IMPORT_STAT_NO_EXIST; + } +#endif +} + +#if MICROPY_ENABLE_COMPILER +STATIC void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) { + #if MICROPY_PY___FILE__ + qstr source_name = lex->source_name; + mp_store_attr(module_obj, MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name)); + #endif + + // parse, compile and execute the module in its context + mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); + mp_parse_compile_execute(lex, MP_PARSE_FILE_INPUT, mod_globals, mod_globals); +} +#endif + +#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_MODULE_FROZEN_MPY +STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code) { + #if MICROPY_PY___FILE__ + // TODO + //qstr source_name = lex->source_name; + //mp_store_attr(module_obj, MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name)); + #endif + + // execute the module in its context + mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); + + // save context + mp_obj_dict_t *volatile old_globals = mp_globals_get(); + mp_obj_dict_t *volatile old_locals = mp_locals_get(); + + // set new context + mp_globals_set(mod_globals); + mp_locals_set(mod_globals); + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t module_fun = mp_make_function_from_raw_code(raw_code, MP_OBJ_NULL, MP_OBJ_NULL); + mp_call_function_0(module_fun); + + // finish nlr block, restore context + nlr_pop(); + mp_globals_set(old_globals); + mp_locals_set(old_locals); + } else { + // exception; restore context and re-raise same exception + mp_globals_set(old_globals); + mp_locals_set(old_locals); + nlr_jump(nlr.ret_val); + } +} +#endif + +STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { + #if MICROPY_MODULE_FROZEN || MICROPY_PERSISTENT_CODE_LOAD || MICROPY_ENABLE_COMPILER + char *file_str = vstr_null_terminated_str(file); + #endif + + // If we support frozen modules (either as str or mpy) then try to find the + // requested filename in the list of frozen module filenames. + #if MICROPY_MODULE_FROZEN + void *modref; + int frozen_type = mp_find_frozen_module(file_str, file->len, &modref); + #endif + + // If we support frozen str modules and the compiler is enabled, and we + // found the filename in the list of frozen files, then load and execute it. + #if MICROPY_MODULE_FROZEN_STR + if (frozen_type == MP_FROZEN_STR) { + do_load_from_lexer(module_obj, modref); + return; + } + #endif + + // If we support frozen mpy modules and we found a corresponding file (and + // its data) in the list of frozen files, execute it. + #if MICROPY_MODULE_FROZEN_MPY + if (frozen_type == MP_FROZEN_MPY) { + do_execute_raw_code(module_obj, modref); + return; + } + #endif + + // If we support loading .mpy files then check if the file extension is of + // the correct format and, if so, load and execute the file. + #if MICROPY_PERSISTENT_CODE_LOAD + if (file_str[file->len - 3] == 'm') { + mp_raw_code_t *raw_code = mp_raw_code_load_file(file_str); + do_execute_raw_code(module_obj, raw_code); + return; + } + #endif + + // If we can compile scripts then load the file and compile and execute it. + #if MICROPY_ENABLE_COMPILER + { + mp_lexer_t *lex = mp_lexer_new_from_file(file_str); + do_load_from_lexer(module_obj, lex); + return; + } + #else + + // If we get here then the file was not frozen and we can't compile scripts. + mp_raise_msg(&mp_type_ImportError, "script compilation not supported"); + #endif +} + +STATIC void chop_component(const char *start, const char **end) { + const char *p = *end; + while (p > start) { + if (*--p == '.') { + *end = p; + return; + } + } + *end = p; +} + +mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { +#if DEBUG_PRINT + DEBUG_printf("__import__:\n"); + for (size_t i = 0; i < n_args; i++) { + DEBUG_printf(" "); + mp_obj_print(args[i], PRINT_REPR); + DEBUG_printf("\n"); + } +#endif + + mp_obj_t module_name = args[0]; + mp_obj_t fromtuple = mp_const_none; + mp_int_t level = 0; + if (n_args >= 4) { + fromtuple = args[3]; + if (n_args >= 5) { + level = MP_OBJ_SMALL_INT_VALUE(args[4]); + if (level < 0) { + mp_raise_ValueError(NULL); + } + } + } + + size_t mod_len; + const char *mod_str = mp_obj_str_get_data(module_name, &mod_len); + + if (level != 0) { + // What we want to do here is to take name of current module, + // chop trailing components, and concatenate with passed-in + // module name, thus resolving relative import name into absolute. + // This even appears to be correct per + // http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name + // "Relative imports use a module's __name__ attribute to determine that + // module's position in the package hierarchy." + level--; + mp_obj_t this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___name__)); + assert(this_name_q != MP_OBJ_NULL); + #if MICROPY_CPYTHON_COMPAT + if (MP_OBJ_QSTR_VALUE(this_name_q) == MP_QSTR___main__) { + // This is a module run by -m command-line switch, get its real name from backup attribute + this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + } + #endif + mp_map_t *globals_map = &mp_globals_get()->map; + mp_map_elem_t *elem = mp_map_lookup(globals_map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP); + bool is_pkg = (elem != NULL); + +#if DEBUG_PRINT + DEBUG_printf("Current module/package: "); + mp_obj_print(this_name_q, PRINT_REPR); + DEBUG_printf(", is_package: %d", is_pkg); + DEBUG_printf("\n"); +#endif + + size_t this_name_l; + const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l); + + const char *p = this_name + this_name_l; + if (!is_pkg) { + // We have module, but relative imports are anchored at package, so + // go there. + chop_component(this_name, &p); + } + + while (level--) { + chop_component(this_name, &p); + } + + // We must have some component left over to import from + if (p == this_name) { + mp_raise_ValueError("cannot perform relative import"); + } + + uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); + char *new_mod = alloca(new_mod_l); + memcpy(new_mod, this_name, p - this_name); + if (mod_len != 0) { + new_mod[p - this_name] = '.'; + memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len); + } + + qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); + DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); + module_name = MP_OBJ_NEW_QSTR(new_mod_q); + mod_str = new_mod; + mod_len = new_mod_l; + } + + // check if module already exists + qstr module_name_qstr = mp_obj_str_get_qstr(module_name); + mp_obj_t module_obj = mp_module_get(module_name_qstr); + if (module_obj != MP_OBJ_NULL) { + DEBUG_printf("Module already loaded\n"); + // If it's not a package, return module right away + char *p = strchr(mod_str, '.'); + if (p == NULL) { + return module_obj; + } + // If fromlist is not empty, return leaf module + if (fromtuple != mp_const_none) { + return module_obj; + } + // Otherwise, we need to return top-level package + qstr pkg_name = qstr_from_strn(mod_str, p - mod_str); + return mp_module_get(pkg_name); + } + DEBUG_printf("Module not yet loaded\n"); + + uint last = 0; + VSTR_FIXED(path, MICROPY_ALLOC_PATH_MAX) + module_obj = MP_OBJ_NULL; + mp_obj_t top_module_obj = MP_OBJ_NULL; + mp_obj_t outer_module_obj = MP_OBJ_NULL; + uint i; + for (i = 1; i <= mod_len; i++) { + if (i == mod_len || mod_str[i] == '.') { + // create a qstr for the module name up to this depth + qstr mod_name = qstr_from_strn(mod_str, i); + DEBUG_printf("Processing module: %s\n", qstr_str(mod_name)); + DEBUG_printf("Previous path: =%.*s=\n", vstr_len(&path), vstr_str(&path)); + + // find the file corresponding to the module name + mp_import_stat_t stat; + if (vstr_len(&path) == 0) { + // first module in the dotted-name; search for a directory or file + stat = find_file(mod_str, i, &path); + } else { + // latter module in the dotted-name; append to path + vstr_add_char(&path, PATH_SEP_CHAR); + vstr_add_strn(&path, mod_str + last, i - last); + stat = stat_dir_or_file(&path); + } + DEBUG_printf("Current path: %.*s\n", vstr_len(&path), vstr_str(&path)); + + if (stat == MP_IMPORT_STAT_NO_EXIST) { + #if MICROPY_MODULE_WEAK_LINKS + // check if there is a weak link to this module + if (i == mod_len) { + mp_map_elem_t *el = mp_map_lookup((mp_map_t*)&mp_builtin_module_weak_links_map, MP_OBJ_NEW_QSTR(mod_name), MP_MAP_LOOKUP); + if (el == NULL) { + goto no_exist; + } + // found weak linked module + module_obj = el->value; + } else { + no_exist: + #else + { + #endif + // couldn't find the file, so fail + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_msg(&mp_type_ImportError, "module not found"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, + "no module named '%q'", mod_name)); + } + } + } else { + // found the file, so get the module + module_obj = mp_module_get(mod_name); + } + + if (module_obj == MP_OBJ_NULL) { + // module not already loaded, so load it! + + module_obj = mp_obj_new_module(mod_name); + + // if args[3] (fromtuple) has magic value False, set up + // this module for command-line "-m" option (set module's + // name to __main__ instead of real name). Do this only + // for *modules* however - packages never have their names + // replaced, instead they're -m'ed using a special __main__ + // submodule in them. (This all apparently is done to not + // touch package name itself, which is important for future + // imports). + if (i == mod_len && fromtuple == mp_const_false && stat != MP_IMPORT_STAT_DIR) { + mp_obj_module_t *o = MP_OBJ_TO_PTR(module_obj); + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + #if MICROPY_CPYTHON_COMPAT + // Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules). + mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj); + // Store real name in "__main__" attribute. Chosen semi-randonly, to reuse existing qstr's. + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(mod_name)); + #endif + } + + if (stat == MP_IMPORT_STAT_DIR) { + DEBUG_printf("%.*s is dir\n", vstr_len(&path), vstr_str(&path)); + // https://docs.python.org/3/reference/import.html + // "Specifically, any module that contains a __path__ attribute is considered a package." + mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(&path), vstr_len(&path), false)); + size_t orig_path_len = path.len; + vstr_add_char(&path, PATH_SEP_CHAR); + vstr_add_str(&path, "__init__.py"); + if (stat_file_py_or_mpy(&path) != MP_IMPORT_STAT_FILE) { + //mp_warning("%s is imported as namespace package", vstr_str(&path)); + } else { + do_load(module_obj, &path); + } + path.len = orig_path_len; + } else { // MP_IMPORT_STAT_FILE + do_load(module_obj, &path); + // This should be the last component in the import path. If there are + // remaining components then it's an ImportError because the current path + // (the module that was just loaded) is not a package. This will be caught + // on the next iteration because the file will not exist. + } + } + if (outer_module_obj != MP_OBJ_NULL) { + qstr s = qstr_from_strn(mod_str + last, i - last); + mp_store_attr(outer_module_obj, s, module_obj); + } + outer_module_obj = module_obj; + if (top_module_obj == MP_OBJ_NULL) { + top_module_obj = module_obj; + } + last = i + 1; + } + } + + // If fromlist is not empty, return leaf module + if (fromtuple != mp_const_none) { + return module_obj; + } + // Otherwise, we need to return top-level package + return top_module_obj; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj, 1, 5, mp_builtin___import__); diff --git a/user/mpy/py/compile.c b/user/mpy/py/compile.c new file mode 100644 index 0000000..00052e1 --- /dev/null +++ b/user/mpy/py/compile.c @@ -0,0 +1,3522 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2015 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. + */ + +#include +#include +#include +#include +#include + +#include "py/scope.h" +#include "py/emit.h" +#include "py/compile.h" +#include "py/runtime.h" +#include "py/asmbase.h" + +#if MICROPY_ENABLE_COMPILER + +// TODO need to mangle __attr names + +#define INVALID_LABEL (0xffff) + +typedef enum { +// define rules with a compile function +#define DEF_RULE(rule, comp, kind, ...) PN_##rule, +#define DEF_RULE_NC(rule, kind, ...) +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC + PN_const_object, // special node for a constant, generic Python object +// define rules without a compile function +#define DEF_RULE(rule, comp, kind, ...) +#define DEF_RULE_NC(rule, kind, ...) PN_##rule, +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC +} pn_kind_t; + +#define NEED_METHOD_TABLE MICROPY_EMIT_NATIVE + +#if NEED_METHOD_TABLE + +// we need a method table to do the lookup for the emitter functions +#define EMIT(fun) (comp->emit_method_table->fun(comp->emit)) +#define EMIT_ARG(fun, ...) (comp->emit_method_table->fun(comp->emit, __VA_ARGS__)) +#define EMIT_LOAD_FAST(qst, local_num) (comp->emit_method_table->load_id.fast(comp->emit, qst, local_num)) +#define EMIT_LOAD_GLOBAL(qst) (comp->emit_method_table->load_id.global(comp->emit, qst)) + +#else + +// if we only have the bytecode emitter enabled then we can do a direct call to the functions +#define EMIT(fun) (mp_emit_bc_##fun(comp->emit)) +#define EMIT_ARG(fun, ...) (mp_emit_bc_##fun(comp->emit, __VA_ARGS__)) +#define EMIT_LOAD_FAST(qst, local_num) (mp_emit_bc_load_fast(comp->emit, qst, local_num)) +#define EMIT_LOAD_GLOBAL(qst) (mp_emit_bc_load_global(comp->emit, qst)) + +#endif + +#if MICROPY_EMIT_NATIVE +// define a macro to access external native emitter +#if MICROPY_EMIT_X64 +#define NATIVE_EMITTER(f) emit_native_x64_##f +#elif MICROPY_EMIT_X86 +#define NATIVE_EMITTER(f) emit_native_x86_##f +#elif MICROPY_EMIT_THUMB +#define NATIVE_EMITTER(f) emit_native_thumb_##f +#elif MICROPY_EMIT_ARM +#define NATIVE_EMITTER(f) emit_native_arm_##f +#elif MICROPY_EMIT_XTENSA +#define NATIVE_EMITTER(f) emit_native_xtensa_##f +#else +#error "unknown native emitter" +#endif +#endif + +#if MICROPY_EMIT_INLINE_ASM +// define macros for inline assembler +#if MICROPY_EMIT_INLINE_THUMB +#define ASM_DECORATOR_QSTR MP_QSTR_asm_thumb +#define ASM_EMITTER(f) emit_inline_thumb_##f +#elif MICROPY_EMIT_INLINE_XTENSA +#define ASM_DECORATOR_QSTR MP_QSTR_asm_xtensa +#define ASM_EMITTER(f) emit_inline_xtensa_##f +#else +#error "unknown asm emitter" +#endif +#endif + +#define EMIT_INLINE_ASM(fun) (comp->emit_inline_asm_method_table->fun(comp->emit_inline_asm)) +#define EMIT_INLINE_ASM_ARG(fun, ...) (comp->emit_inline_asm_method_table->fun(comp->emit_inline_asm, __VA_ARGS__)) + +// elements in this struct are ordered to make it compact +typedef struct _compiler_t { + qstr source_file; + + uint8_t is_repl; + uint8_t pass; // holds enum type pass_kind_t + uint8_t have_star; + + // try to keep compiler clean from nlr + mp_obj_t compile_error; // set to an exception object if there's an error + size_t compile_error_line; // set to best guess of line of error + + uint next_label; + + uint16_t num_dict_params; + uint16_t num_default_params; + + uint16_t break_label; // highest bit set indicates we are breaking out of a for loop + uint16_t continue_label; + uint16_t cur_except_level; // increased for SETUP_EXCEPT, SETUP_FINALLY; decreased for POP_BLOCK, POP_EXCEPT + uint16_t break_continue_except_level; + + scope_t *scope_head; + scope_t *scope_cur; + + emit_t *emit; // current emitter + #if NEED_METHOD_TABLE + const emit_method_table_t *emit_method_table; // current emit method table + #endif + + #if MICROPY_EMIT_INLINE_ASM + emit_inline_asm_t *emit_inline_asm; // current emitter for inline asm + const emit_inline_asm_method_table_t *emit_inline_asm_method_table; // current emit method table for inline asm + #endif +} compiler_t; + +STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) { + // if the line of the error is unknown then try to update it from the pn + if (comp->compile_error_line == 0 && MP_PARSE_NODE_IS_STRUCT(pn)) { + comp->compile_error_line = ((mp_parse_node_struct_t*)pn)->source_line; + } +} + +STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const char *msg) { + // only register the error if there has been no other error + if (comp->compile_error == MP_OBJ_NULL) { + comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); + compile_error_set_line(comp, pn); + } +} + +STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra); +STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind); +STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn); + +STATIC uint comp_next_label(compiler_t *comp) { + return comp->next_label++; +} + +STATIC void compile_increase_except_level(compiler_t *comp) { + comp->cur_except_level += 1; + if (comp->cur_except_level > comp->scope_cur->exc_stack_size) { + comp->scope_cur->exc_stack_size = comp->cur_except_level; + } +} + +STATIC void compile_decrease_except_level(compiler_t *comp) { + assert(comp->cur_except_level > 0); + comp->cur_except_level -= 1; +} + +STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) { + scope_t *scope = scope_new(kind, pn, comp->source_file, emit_options); + scope->parent = comp->scope_cur; + scope->next = NULL; + if (comp->scope_head == NULL) { + comp->scope_head = scope; + } else { + scope_t *s = comp->scope_head; + while (s->next != NULL) { + s = s->next; + } + s->next = scope; + } + return scope; +} + +typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn); + +STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) { + if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, pn_list_kind)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + for (int i = 0; i < num_nodes; i++) { + f(comp, pns->nodes[i]); + } + } else if (!MP_PARSE_NODE_IS_NULL(pn)) { + f(comp, pn); + } +} + +STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) { + int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + for (int i = 0; i < num_nodes; i++) { + compile_node(comp, pns->nodes[i]); + if (comp->compile_error != MP_OBJ_NULL) { + // add line info for the error in case it didn't have a line number + compile_error_set_line(comp, pns->nodes[i]); + return; + } + } +} + +STATIC void compile_load_id(compiler_t *comp, qstr qst) { + if (comp->pass == MP_PASS_SCOPE) { + mp_emit_common_get_id_for_load(comp->scope_cur, qst); + } else { + #if NEED_METHOD_TABLE + mp_emit_common_id_op(comp->emit, &comp->emit_method_table->load_id, comp->scope_cur, qst); + #else + mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_load_id_ops, comp->scope_cur, qst); + #endif + } +} + +STATIC void compile_store_id(compiler_t *comp, qstr qst) { + if (comp->pass == MP_PASS_SCOPE) { + mp_emit_common_get_id_for_modification(comp->scope_cur, qst); + } else { + #if NEED_METHOD_TABLE + mp_emit_common_id_op(comp->emit, &comp->emit_method_table->store_id, comp->scope_cur, qst); + #else + mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_store_id_ops, comp->scope_cur, qst); + #endif + } +} + +STATIC void compile_delete_id(compiler_t *comp, qstr qst) { + if (comp->pass == MP_PASS_SCOPE) { + mp_emit_common_get_id_for_modification(comp->scope_cur, qst); + } else { + #if NEED_METHOD_TABLE + mp_emit_common_id_op(comp->emit, &comp->emit_method_table->delete_id, comp->scope_cur, qst); + #else + mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_delete_id_ops, comp->scope_cur, qst); + #endif + } +} + +STATIC void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) { + int total = 0; + if (!MP_PARSE_NODE_IS_NULL(pn)) { + compile_node(comp, pn); + total += 1; + } + if (pns_list != NULL) { + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_list); + for (int i = 0; i < n; i++) { + compile_node(comp, pns_list->nodes[i]); + } + total += n; + } + EMIT_ARG(build_tuple, total); +} + +STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) { + // a simple tuple expression + c_tuple(comp, MP_PARSE_NODE_NULL, pns); +} + +STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) { + if (mp_parse_node_is_const_false(pn)) { + if (jump_if == false) { + EMIT_ARG(jump, label); + } + return; + } else if (mp_parse_node_is_const_true(pn)) { + if (jump_if == true) { + EMIT_ARG(jump, label); + } + return; + } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test) { + if (jump_if == false) { + and_or_logic1:; + uint label2 = comp_next_label(comp); + for (int i = 0; i < n - 1; i++) { + c_if_cond(comp, pns->nodes[i], !jump_if, label2); + } + c_if_cond(comp, pns->nodes[n - 1], jump_if, label); + EMIT_ARG(label_assign, label2); + } else { + and_or_logic2: + for (int i = 0; i < n; i++) { + c_if_cond(comp, pns->nodes[i], jump_if, label); + } + } + return; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_and_test) { + if (jump_if == false) { + goto and_or_logic2; + } else { + goto and_or_logic1; + } + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_not_test_2) { + c_if_cond(comp, pns->nodes[0], !jump_if, label); + return; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_atom_paren) { + // cond is something in parenthesis + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // empty tuple, acts as false for the condition + if (jump_if == false) { + EMIT_ARG(jump, label); + } + } else { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); + // non-empty tuple, acts as true for the condition + if (jump_if == true) { + EMIT_ARG(jump, label); + } + } + return; + } + } + + // nothing special, fall back to default compiling for node and jump + compile_node(comp, pn); + EMIT_ARG(pop_jump_if, jump_if, label); +} + +typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t; +STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind); + +STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) { + if (assign_kind != ASSIGN_AUG_STORE) { + compile_node(comp, pns->nodes[0]); + } + + if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_atom_expr_trailers) { + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); + if (assign_kind != ASSIGN_AUG_STORE) { + for (int i = 0; i < n - 1; i++) { + compile_node(comp, pns1->nodes[i]); + } + } + assert(MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])); + pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; + } + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_bracket) { + if (assign_kind == ASSIGN_AUG_STORE) { + EMIT(rot_three); + EMIT(store_subscr); + } else { + compile_node(comp, pns1->nodes[0]); + if (assign_kind == ASSIGN_AUG_LOAD) { + EMIT(dup_top_two); + EMIT(load_subscr); + } else { + EMIT(store_subscr); + } + } + } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_period) { + assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); + if (assign_kind == ASSIGN_AUG_LOAD) { + EMIT(dup_top); + EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])); + } else { + if (assign_kind == ASSIGN_AUG_STORE) { + EMIT(rot_two); + } + EMIT_ARG(store_attr, MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])); + } + } else { + goto cannot_assign; + } + } else { + goto cannot_assign; + } + + return; + +cannot_assign: + compile_syntax_error(comp, (mp_parse_node_t)pns, "can't assign to expression"); +} + +// we need to allow for a caller passing in 1 initial node (node_head) followed by an array of nodes (nodes_tail) +STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num_tail, mp_parse_node_t *nodes_tail) { + uint num_head = (node_head == MP_PARSE_NODE_NULL) ? 0 : 1; + + // look for star expression + uint have_star_index = -1; + if (num_head != 0 && MP_PARSE_NODE_IS_STRUCT_KIND(node_head, PN_star_expr)) { + EMIT_ARG(unpack_ex, 0, num_tail); + have_star_index = 0; + } + for (uint i = 0; i < num_tail; i++) { + if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes_tail[i], PN_star_expr)) { + if (have_star_index == (uint)-1) { + EMIT_ARG(unpack_ex, num_head + i, num_tail - i - 1); + have_star_index = num_head + i; + } else { + compile_syntax_error(comp, nodes_tail[i], "multiple *x in assignment"); + return; + } + } + } + if (have_star_index == (uint)-1) { + EMIT_ARG(unpack_sequence, num_head + num_tail); + } + if (num_head != 0) { + if (0 == have_star_index) { + c_assign(comp, ((mp_parse_node_struct_t*)node_head)->nodes[0], ASSIGN_STORE); + } else { + c_assign(comp, node_head, ASSIGN_STORE); + } + } + for (uint i = 0; i < num_tail; i++) { + if (num_head + i == have_star_index) { + c_assign(comp, ((mp_parse_node_struct_t*)nodes_tail[i])->nodes[0], ASSIGN_STORE); + } else { + c_assign(comp, nodes_tail[i], ASSIGN_STORE); + } + } +} + +// assigns top of stack to pn +STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) { + assert(!MP_PARSE_NODE_IS_NULL(pn)); + if (MP_PARSE_NODE_IS_LEAF(pn)) { + if (MP_PARSE_NODE_IS_ID(pn)) { + qstr arg = MP_PARSE_NODE_LEAF_ARG(pn); + switch (assign_kind) { + case ASSIGN_STORE: + case ASSIGN_AUG_STORE: + compile_store_id(comp, arg); + break; + case ASSIGN_AUG_LOAD: + default: + compile_load_id(comp, arg); + break; + } + } else { + goto cannot_assign; + } + } else { + // pn must be a struct + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + switch (MP_PARSE_NODE_STRUCT_KIND(pns)) { + case PN_atom_expr_normal: + // lhs is an index or attribute + c_assign_atom_expr(comp, pns, assign_kind); + break; + + case PN_testlist_star_expr: + case PN_exprlist: + // lhs is a tuple + if (assign_kind != ASSIGN_STORE) { + goto cannot_assign; + } + c_assign_tuple(comp, MP_PARSE_NODE_NULL, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); + break; + + case PN_atom_paren: + // lhs is something in parenthesis + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // empty tuple + goto cannot_assign; + } else { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); + if (assign_kind != ASSIGN_STORE) { + goto cannot_assign; + } + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + goto testlist_comp; + } + break; + + case PN_atom_bracket: + // lhs is something in brackets + if (assign_kind != ASSIGN_STORE) { + goto cannot_assign; + } + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // empty list, assignment allowed + c_assign_tuple(comp, MP_PARSE_NODE_NULL, 0, NULL); + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + goto testlist_comp; + } else { + // brackets around 1 item + c_assign_tuple(comp, pns->nodes[0], 0, NULL); + } + break; + + default: + goto cannot_assign; + } + return; + + testlist_comp: + // lhs is a sequence + if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { + // sequence of one item, with trailing comma + assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); + c_assign_tuple(comp, pns->nodes[0], 0, NULL); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { + // sequence of many items + uint n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns2); + c_assign_tuple(comp, pns->nodes[0], n, pns2->nodes); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { + goto cannot_assign; + } else { + // sequence with 2 items + goto sequence_with_2_items; + } + } else { + // sequence with 2 items + sequence_with_2_items: + c_assign_tuple(comp, MP_PARSE_NODE_NULL, 2, pns->nodes); + } + return; + } + return; + + cannot_assign: + compile_syntax_error(comp, pn, "can't assign to expression"); +} + +// stuff for lambda and comprehensions and generators: +// if n_pos_defaults > 0 then there is a tuple on the stack with the positional defaults +// if n_kw_defaults > 0 then there is a dictionary on the stack with the keyword defaults +// if both exist, the tuple is above the dictionary (ie the first pop gets the tuple) +STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) { + assert(n_pos_defaults >= 0); + assert(n_kw_defaults >= 0); + + // set flags + if (n_kw_defaults > 0) { + this_scope->scope_flags |= MP_SCOPE_FLAG_DEFKWARGS; + } + this_scope->num_def_pos_args = n_pos_defaults; + + // make closed over variables, if any + // ensure they are closed over in the order defined in the outer scope (mainly to agree with CPython) + int nfree = 0; + if (comp->scope_cur->kind != SCOPE_MODULE) { + for (int i = 0; i < comp->scope_cur->id_info_len; i++) { + id_info_t *id = &comp->scope_cur->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { + for (int j = 0; j < this_scope->id_info_len; j++) { + id_info_t *id2 = &this_scope->id_info[j]; + if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { + // in MicroPython we load closures using LOAD_FAST + EMIT_LOAD_FAST(id->qst, id->local_num); + nfree += 1; + } + } + } + } + } + + // make the function/closure + if (nfree == 0) { + EMIT_ARG(make_function, this_scope, n_pos_defaults, n_kw_defaults); + } else { + EMIT_ARG(make_closure, this_scope, nfree, n_pos_defaults, n_kw_defaults); + } +} + +STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) { + // For efficiency of the code below we extract the parse-node kind here + int pn_kind; + if (MP_PARSE_NODE_IS_ID(pn)) { + pn_kind = -1; + } else { + assert(MP_PARSE_NODE_IS_STRUCT(pn)); + pn_kind = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn); + } + + if (pn_kind == PN_typedargslist_star || pn_kind == PN_varargslist_star) { + comp->have_star = true; + /* don't need to distinguish bare from named star + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // bare star + } else { + // named star + } + */ + + } else if (pn_kind == PN_typedargslist_dbl_star || pn_kind == PN_varargslist_dbl_star) { + // named double star + // TODO do we need to do anything with this? + + } else { + mp_parse_node_t pn_id; + mp_parse_node_t pn_colon; + mp_parse_node_t pn_equal; + if (pn_kind == -1) { + // this parameter is just an id + + pn_id = pn; + pn_colon = MP_PARSE_NODE_NULL; + pn_equal = MP_PARSE_NODE_NULL; + + } else if (pn_kind == PN_typedargslist_name) { + // this parameter has a colon and/or equal specifier + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + pn_id = pns->nodes[0]; + pn_colon = pns->nodes[1]; + pn_equal = pns->nodes[2]; + + } else { + assert(pn_kind == PN_varargslist_name); // should be + // this parameter has an equal specifier + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + pn_id = pns->nodes[0]; + pn_equal = pns->nodes[1]; + } + + if (MP_PARSE_NODE_IS_NULL(pn_equal)) { + // this parameter does not have a default value + + // check for non-default parameters given after default parameters (allowed by parser, but not syntactically valid) + if (!comp->have_star && comp->num_default_params != 0) { + compile_syntax_error(comp, pn, "non-default argument follows default argument"); + return; + } + + } else { + // this parameter has a default value + // in CPython, None (and True, False?) as default parameters are loaded with LOAD_NAME; don't understandy why + + if (comp->have_star) { + comp->num_dict_params += 1; + // in MicroPython we put the default dict parameters into a dictionary using the bytecode + if (comp->num_dict_params == 1) { + // in MicroPython we put the default positional parameters into a tuple using the bytecode + // we need to do this here before we start building the map for the default keywords + if (comp->num_default_params > 0) { + EMIT_ARG(build_tuple, comp->num_default_params); + } else { + EMIT(load_null); // sentinel indicating empty default positional args + } + // first default dict param, so make the map + EMIT_ARG(build_map, 0); + } + + // compile value then key, then store it to the dict + compile_node(comp, pn_equal); + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id)); + EMIT(store_map); + } else { + comp->num_default_params += 1; + compile_node(comp, pn_equal); + } + } + + // TODO pn_colon not implemented + (void)pn_colon; + } +} + +STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) { + // When we call compile_funcdef_lambdef_param below it can compile an arbitrary + // expression for default arguments, which may contain a lambda. The lambda will + // call here in a nested way, so we must save and restore the relevant state. + bool orig_have_star = comp->have_star; + uint16_t orig_num_dict_params = comp->num_dict_params; + uint16_t orig_num_default_params = comp->num_default_params; + + // compile default parameters + comp->have_star = false; + comp->num_dict_params = 0; + comp->num_default_params = 0; + apply_to_single_or_list(comp, pn_params, pn_list_kind, compile_funcdef_lambdef_param); + + if (comp->compile_error != MP_OBJ_NULL) { + return; + } + + // in MicroPython we put the default positional parameters into a tuple using the bytecode + // the default keywords args may have already made the tuple; if not, do it now + if (comp->num_default_params > 0 && comp->num_dict_params == 0) { + EMIT_ARG(build_tuple, comp->num_default_params); + EMIT(load_null); // sentinel indicating empty default keyword args + } + + // make the function + close_over_variables_etc(comp, scope, comp->num_default_params, comp->num_dict_params); + + // restore state + comp->have_star = orig_have_star; + comp->num_dict_params = orig_num_dict_params; + comp->num_default_params = orig_num_default_params; +} + +// leaves function object on stack +// returns function name +STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { + if (comp->pass == MP_PASS_SCOPE) { + // create a new scope for this function + scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options); + // store the function scope so the compiling function can use it at each pass + pns->nodes[4] = (mp_parse_node_t)s; + } + + // get the scope for this function + scope_t *fscope = (scope_t*)pns->nodes[4]; + + // compile the function definition + compile_funcdef_lambdef(comp, fscope, pns->nodes[1], PN_typedargslist); + + // return its name (the 'f' in "def f(...):") + return fscope->simple_name; +} + +// leaves class object on stack +// returns class name +STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { + if (comp->pass == MP_PASS_SCOPE) { + // create a new scope for this class + scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options); + // store the class scope so the compiling function can use it at each pass + pns->nodes[3] = (mp_parse_node_t)s; + } + + EMIT(load_build_class); + + // scope for this class + scope_t *cscope = (scope_t*)pns->nodes[3]; + + // compile the class + close_over_variables_etc(comp, cscope, 0, 0); + + // get its name + EMIT_ARG(load_const_str, cscope->simple_name); + + // nodes[1] has parent classes, if any + // empty parenthesis (eg class C():) gets here as an empty PN_classdef_2 and needs special handling + mp_parse_node_t parents = pns->nodes[1]; + if (MP_PARSE_NODE_IS_STRUCT_KIND(parents, PN_classdef_2)) { + parents = MP_PARSE_NODE_NULL; + } + compile_trailer_paren_helper(comp, parents, false, 2); + + // return its name (the 'C' in class C(...):") + return cscope->simple_name; +} + +// returns true if it was a built-in decorator (even if the built-in had an error) +STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_node_t *name_nodes, uint *emit_options) { + if (MP_PARSE_NODE_LEAF_ARG(name_nodes[0]) != MP_QSTR_micropython) { + return false; + } + + if (name_len != 2) { + compile_syntax_error(comp, name_nodes[0], "invalid micropython decorator"); + return true; + } + + qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]); + if (attr == MP_QSTR_bytecode) { + *emit_options = MP_EMIT_OPT_BYTECODE; +#if MICROPY_EMIT_NATIVE + } else if (attr == MP_QSTR_native) { + *emit_options = MP_EMIT_OPT_NATIVE_PYTHON; + } else if (attr == MP_QSTR_viper) { + *emit_options = MP_EMIT_OPT_VIPER; +#endif + #if MICROPY_EMIT_INLINE_ASM + } else if (attr == ASM_DECORATOR_QSTR) { + *emit_options = MP_EMIT_OPT_ASM; + #endif + } else { + compile_syntax_error(comp, name_nodes[1], "invalid micropython decorator"); + } + + return true; +} + +STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) { + // get the list of decorators + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes); + + // inherit emit options for this function/class definition + uint emit_options = comp->scope_cur->emit_options; + + // compile each decorator + int num_built_in_decorators = 0; + for (int i = 0; i < n; i++) { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(nodes[i], PN_decorator)); // should be + mp_parse_node_struct_t *pns_decorator = (mp_parse_node_struct_t*)nodes[i]; + + // nodes[0] contains the decorator function, which is a dotted name + mp_parse_node_t *name_nodes; + int name_len = mp_parse_node_extract_list(&pns_decorator->nodes[0], PN_dotted_name, &name_nodes); + + // check for built-in decorators + if (compile_built_in_decorator(comp, name_len, name_nodes, &emit_options)) { + // this was a built-in + num_built_in_decorators += 1; + + } else { + // not a built-in, compile normally + + // compile the decorator function + compile_node(comp, name_nodes[0]); + for (int j = 1; j < name_len; j++) { + assert(MP_PARSE_NODE_IS_ID(name_nodes[j])); // should be + EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(name_nodes[j])); + } + + // nodes[1] contains arguments to the decorator function, if any + if (!MP_PARSE_NODE_IS_NULL(pns_decorator->nodes[1])) { + // call the decorator function with the arguments in nodes[1] + compile_node(comp, pns_decorator->nodes[1]); + } + } + } + + // compile the body (funcdef, async funcdef or classdef) and get its name + mp_parse_node_struct_t *pns_body = (mp_parse_node_struct_t*)pns->nodes[1]; + qstr body_name = 0; + if (MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_funcdef) { + body_name = compile_funcdef_helper(comp, pns_body, emit_options); + #if MICROPY_PY_ASYNC_AWAIT + } else if (MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_async_funcdef) { + assert(MP_PARSE_NODE_IS_STRUCT(pns_body->nodes[0])); + mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns_body->nodes[0]; + body_name = compile_funcdef_helper(comp, pns0, emit_options); + scope_t *fscope = (scope_t*)pns0->nodes[4]; + fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; + #endif + } else { + assert(MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_classdef); // should be + body_name = compile_classdef_helper(comp, pns_body, emit_options); + } + + // call each decorator + for (int i = 0; i < n - num_built_in_decorators; i++) { + EMIT_ARG(call_function, 1, 0, 0); + } + + // store func/class object into name + compile_store_id(comp, body_name); +} + +STATIC void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) { + qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options); + // store function object into function name + compile_store_id(comp, fname); +} + +STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) { + if (MP_PARSE_NODE_IS_ID(pn)) { + compile_delete_id(comp, MP_PARSE_NODE_LEAF_ARG(pn)); + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_expr_normal)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + + compile_node(comp, pns->nodes[0]); // base of the atom_expr_normal node + + if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_atom_expr_trailers) { + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); + for (int i = 0; i < n - 1; i++) { + compile_node(comp, pns1->nodes[i]); + } + assert(MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])); + pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; + } + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_bracket) { + compile_node(comp, pns1->nodes[0]); + EMIT(delete_subscr); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_period) { + assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); + EMIT_ARG(delete_attr, MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])); + } else { + goto cannot_delete; + } + } else { + goto cannot_delete; + } + + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_paren)) { + pn = ((mp_parse_node_struct_t*)pn)->nodes[0]; + if (MP_PARSE_NODE_IS_NULL(pn)) { + goto cannot_delete; + } else { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + // TODO perhaps factorise testlist_comp code with other uses of PN_testlist_comp + + if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3b) { + // sequence of one item, with trailing comma + assert(MP_PARSE_NODE_IS_NULL(pns1->nodes[0])); + c_del_stmt(comp, pns->nodes[0]); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3c) { + // sequence of many items + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); + c_del_stmt(comp, pns->nodes[0]); + for (int i = 0; i < n; i++) { + c_del_stmt(comp, pns1->nodes[i]); + } + } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for) { + goto cannot_delete; + } else { + // sequence with 2 items + goto sequence_with_2_items; + } + } else { + // sequence with 2 items + sequence_with_2_items: + c_del_stmt(comp, pns->nodes[0]); + c_del_stmt(comp, pns->nodes[1]); + } + } + } else { + // some arbitrary statement that we can't delete (eg del 1) + goto cannot_delete; + } + + return; + +cannot_delete: + compile_syntax_error(comp, (mp_parse_node_t)pn, "can't delete expression"); +} + +STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt); +} + +STATIC void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->break_label == INVALID_LABEL) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' outside loop"); + } + assert(comp->cur_except_level >= comp->break_continue_except_level); + EMIT_ARG(break_loop, comp->break_label, comp->cur_except_level - comp->break_continue_except_level); +} + +STATIC void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->continue_label == INVALID_LABEL) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' outside loop"); + } + assert(comp->cur_except_level >= comp->break_continue_except_level); + EMIT_ARG(continue_loop, comp->continue_label, comp->cur_except_level - comp->break_continue_except_level); +} + +STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->scope_cur->kind != SCOPE_FUNCTION) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' outside function"); + return; + } + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // no argument to 'return', so return None + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + } else if (MICROPY_COMP_RETURN_IF_EXPR + && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_test_if_expr)) { + // special case when returning an if-expression; to match CPython optimisation + mp_parse_node_struct_t *pns_test_if_expr = (mp_parse_node_struct_t*)pns->nodes[0]; + mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns_test_if_expr->nodes[1]; + + uint l_fail = comp_next_label(comp); + c_if_cond(comp, pns_test_if_else->nodes[0], false, l_fail); // condition + compile_node(comp, pns_test_if_expr->nodes[0]); // success value + EMIT(return_value); + EMIT_ARG(label_assign, l_fail); + compile_node(comp, pns_test_if_else->nodes[1]); // failure value + } else { + compile_node(comp, pns->nodes[0]); + } + EMIT(return_value); +} + +STATIC void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[0]); + EMIT(pop_top); +} + +STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // raise + EMIT_ARG(raise_varargs, 0); + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_raise_stmt_arg)) { + // raise x from y + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + compile_node(comp, pns->nodes[0]); + compile_node(comp, pns->nodes[1]); + EMIT_ARG(raise_varargs, 2); + } else { + // raise x + compile_node(comp, pns->nodes[0]); + EMIT_ARG(raise_varargs, 1); + } +} + +// q_base holds the base of the name +// eg a -> q_base=a +// a.b.c -> q_base=a +STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) { + bool is_as = false; + if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_as_name)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + // a name of the form x as y; unwrap it + *q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[1]); + pn = pns->nodes[0]; + is_as = true; + } + if (MP_PARSE_NODE_IS_NULL(pn)) { + // empty name (eg, from . import x) + *q_base = MP_QSTR_; + EMIT_ARG(import_name, MP_QSTR_); // import the empty string + } else if (MP_PARSE_NODE_IS_ID(pn)) { + // just a simple name + qstr q_full = MP_PARSE_NODE_LEAF_ARG(pn); + if (!is_as) { + *q_base = q_full; + } + EMIT_ARG(import_name, q_full); + } else { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_name)); // should be + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + { + // a name of the form a.b.c + if (!is_as) { + *q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + } + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + int len = n - 1; + for (int i = 0; i < n; i++) { + len += qstr_len(MP_PARSE_NODE_LEAF_ARG(pns->nodes[i])); + } + byte *q_ptr; + byte *str_dest = qstr_build_start(len, &q_ptr); + for (int i = 0; i < n; i++) { + if (i > 0) { + *str_dest++ = '.'; + } + size_t str_src_len; + const byte *str_src = qstr_data(MP_PARSE_NODE_LEAF_ARG(pns->nodes[i]), &str_src_len); + memcpy(str_dest, str_src, str_src_len); + str_dest += str_src_len; + } + qstr q_full = qstr_build_end(q_ptr); + EMIT_ARG(import_name, q_full); + if (is_as) { + for (int i = 1; i < n; i++) { + EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[i])); + } + } + } + } +} + +STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) { + EMIT_ARG(load_const_small_int, 0); // level 0 import + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // not importing from anything + qstr q_base; + do_import_name(comp, pn, &q_base); + compile_store_id(comp, q_base); +} + +STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) { + apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name); +} + +STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) { + mp_parse_node_t pn_import_source = pns->nodes[0]; + + // extract the preceding .'s (if any) for a relative import, to compute the import level + uint import_level = 0; + do { + mp_parse_node_t pn_rel; + if (MP_PARSE_NODE_IS_TOKEN(pn_import_source) || MP_PARSE_NODE_IS_STRUCT_KIND(pn_import_source, PN_one_or_more_period_or_ellipsis)) { + // This covers relative imports with dots only like "from .. import" + pn_rel = pn_import_source; + pn_import_source = MP_PARSE_NODE_NULL; + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn_import_source, PN_import_from_2b)) { + // This covers relative imports starting with dot(s) like "from .foo import" + mp_parse_node_struct_t *pns_2b = (mp_parse_node_struct_t*)pn_import_source; + pn_rel = pns_2b->nodes[0]; + pn_import_source = pns_2b->nodes[1]; + assert(!MP_PARSE_NODE_IS_NULL(pn_import_source)); // should not be + } else { + // Not a relative import + break; + } + + // get the list of . and/or ...'s + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pn_rel, PN_one_or_more_period_or_ellipsis, &nodes); + + // count the total number of .'s + for (int i = 0; i < n; i++) { + if (MP_PARSE_NODE_IS_TOKEN_KIND(nodes[i], MP_TOKEN_DEL_PERIOD)) { + import_level++; + } else { + // should be an MP_TOKEN_ELLIPSIS + import_level += 3; + } + } + } while (0); + + if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_STAR)) { + EMIT_ARG(load_const_small_int, import_level); + + // build the "fromlist" tuple + EMIT_ARG(load_const_str, MP_QSTR__star_); + EMIT_ARG(build_tuple, 1); + + // do the import + qstr dummy_q; + do_import_name(comp, pn_import_source, &dummy_q); + EMIT(import_star); + + } else { + EMIT_ARG(load_const_small_int, import_level); + + // build the "fromlist" tuple + mp_parse_node_t *pn_nodes; + int n = mp_parse_node_extract_list(&pns->nodes[1], PN_import_as_names, &pn_nodes); + for (int i = 0; i < n; i++) { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)); + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; + qstr id2 = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[0]); // should be id + EMIT_ARG(load_const_str, id2); + } + EMIT_ARG(build_tuple, n); + + // do the import + qstr dummy_q; + do_import_name(comp, pn_import_source, &dummy_q); + for (int i = 0; i < n; i++) { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)); + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; + qstr id2 = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[0]); // should be id + EMIT_ARG(import_from, id2); + if (MP_PARSE_NODE_IS_NULL(pns3->nodes[1])) { + compile_store_id(comp, id2); + } else { + compile_store_id(comp, MP_PARSE_NODE_LEAF_ARG(pns3->nodes[1])); + } + } + EMIT(pop_top); + } +} + +STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, qstr qst) { + bool added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); + if (!added && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) { + compile_syntax_error(comp, pn, "identifier redefined as global"); + return; + } + id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; + + // if the id exists in the global scope, set its kind to EXPLICIT_GLOBAL + id_info = scope_find_global(comp->scope_cur, qst); + if (id_info != NULL) { + id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; + } +} + +STATIC void compile_global_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->pass == MP_PASS_SCOPE) { + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); + for (int i = 0; i < n; i++) { + compile_declare_global(comp, (mp_parse_node_t)pns, MP_PARSE_NODE_LEAF_ARG(nodes[i])); + } + } +} + +STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, qstr qst) { + bool added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); + if (added) { + scope_find_local_and_close_over(comp->scope_cur, id_info, qst); + if (id_info->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + compile_syntax_error(comp, pn, "no binding for nonlocal found"); + } + } else if (id_info->kind != ID_INFO_KIND_FREE) { + compile_syntax_error(comp, pn, "identifier redefined as nonlocal"); + } +} + +STATIC void compile_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->pass == MP_PASS_SCOPE) { + if (comp->scope_cur->kind == SCOPE_MODULE) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "can't declare nonlocal in outer code"); + return; + } + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); + for (int i = 0; i < n; i++) { + compile_declare_nonlocal(comp, (mp_parse_node_t)pns, MP_PARSE_NODE_LEAF_ARG(nodes[i])); + } + } +} + +STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + // with optimisations enabled we don't compile assertions + if (MP_STATE_VM(mp_optimise_value) != 0) { + return; + } + + uint l_end = comp_next_label(comp); + c_if_cond(comp, pns->nodes[0], true, l_end); + EMIT_LOAD_GLOBAL(MP_QSTR_AssertionError); // we load_global instead of load_id, to be consistent with CPython + if (!MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { + // assertion message + compile_node(comp, pns->nodes[1]); + EMIT_ARG(call_function, 1, 0, 0); + } + EMIT_ARG(raise_varargs, 1); + EMIT_ARG(label_assign, l_end); +} + +STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + uint l_end = comp_next_label(comp); + + // optimisation: don't emit anything when "if False" + if (!mp_parse_node_is_const_false(pns->nodes[0])) { + uint l_fail = comp_next_label(comp); + c_if_cond(comp, pns->nodes[0], false, l_fail); // if condition + + compile_node(comp, pns->nodes[1]); // if block + + // optimisation: skip everything else when "if True" + if (mp_parse_node_is_const_true(pns->nodes[0])) { + goto done; + } + + if ( + // optimisation: don't jump over non-existent elif/else blocks + !(MP_PARSE_NODE_IS_NULL(pns->nodes[2]) && MP_PARSE_NODE_IS_NULL(pns->nodes[3])) + // optimisation: don't jump if last instruction was return + && !EMIT(last_emit_was_return_value) + ) { + // jump over elif/else blocks + EMIT_ARG(jump, l_end); + } + + EMIT_ARG(label_assign, l_fail); + } + + // compile elif blocks (if any) + mp_parse_node_t *pn_elif; + int n_elif = mp_parse_node_extract_list(&pns->nodes[2], PN_if_stmt_elif_list, &pn_elif); + for (int i = 0; i < n_elif; i++) { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_elif[i], PN_if_stmt_elif)); // should be + mp_parse_node_struct_t *pns_elif = (mp_parse_node_struct_t*)pn_elif[i]; + + // optimisation: don't emit anything when "if False" + if (!mp_parse_node_is_const_false(pns_elif->nodes[0])) { + uint l_fail = comp_next_label(comp); + c_if_cond(comp, pns_elif->nodes[0], false, l_fail); // elif condition + + compile_node(comp, pns_elif->nodes[1]); // elif block + + // optimisation: skip everything else when "elif True" + if (mp_parse_node_is_const_true(pns_elif->nodes[0])) { + goto done; + } + + // optimisation: don't jump if last instruction was return + if (!EMIT(last_emit_was_return_value)) { + EMIT_ARG(jump, l_end); + } + EMIT_ARG(label_assign, l_fail); + } + } + + // compile else block + compile_node(comp, pns->nodes[3]); // can be null + +done: + EMIT_ARG(label_assign, l_end); +} + +#define START_BREAK_CONTINUE_BLOCK \ + uint16_t old_break_label = comp->break_label; \ + uint16_t old_continue_label = comp->continue_label; \ + uint16_t old_break_continue_except_level = comp->break_continue_except_level; \ + uint break_label = comp_next_label(comp); \ + uint continue_label = comp_next_label(comp); \ + comp->break_label = break_label; \ + comp->continue_label = continue_label; \ + comp->break_continue_except_level = comp->cur_except_level; + +#define END_BREAK_CONTINUE_BLOCK \ + comp->break_label = old_break_label; \ + comp->continue_label = old_continue_label; \ + comp->break_continue_except_level = old_break_continue_except_level; + +STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + START_BREAK_CONTINUE_BLOCK + + if (!mp_parse_node_is_const_false(pns->nodes[0])) { // optimisation: don't emit anything for "while False" + uint top_label = comp_next_label(comp); + if (!mp_parse_node_is_const_true(pns->nodes[0])) { // optimisation: don't jump to cond for "while True" + EMIT_ARG(jump, continue_label); + } + EMIT_ARG(label_assign, top_label); + compile_node(comp, pns->nodes[1]); // body + EMIT_ARG(label_assign, continue_label); + c_if_cond(comp, pns->nodes[0], true, top_label); // condition + } + + // break/continue apply to outer loop (if any) in the else block + END_BREAK_CONTINUE_BLOCK + + compile_node(comp, pns->nodes[2]); // else + + EMIT_ARG(label_assign, break_label); +} + +// This function compiles an optimised for-loop of the form: +// for in range(, , ): +// +// else: +// +// must be an identifier and must be a small-int. +// +// Semantics of for-loop require: +// - final failing value should not be stored in the loop variable +// - if the loop never runs, the loop variable should never be assigned +// - assignments to , or in the body do not alter the loop +// ( is a constant for us, so no need to worry about it changing) +// +// If is a small-int, then the stack during the for-loop contains just +// the current value of . Otherwise, the stack contains then the +// current value of . +STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) { + START_BREAK_CONTINUE_BLOCK + + uint top_label = comp_next_label(comp); + uint entry_label = comp_next_label(comp); + + // put the end value on the stack if it's not a small-int constant + bool end_on_stack = !MP_PARSE_NODE_IS_SMALL_INT(pn_end); + if (end_on_stack) { + compile_node(comp, pn_end); + } + + // compile: start + compile_node(comp, pn_start); + + EMIT_ARG(jump, entry_label); + EMIT_ARG(label_assign, top_label); + + // duplicate next value and store it to var + EMIT(dup_top); + c_assign(comp, pn_var, ASSIGN_STORE); + + // compile body + compile_node(comp, pn_body); + + EMIT_ARG(label_assign, continue_label); + + // compile: var + step + compile_node(comp, pn_step); + EMIT_ARG(binary_op, MP_BINARY_OP_INPLACE_ADD); + + EMIT_ARG(label_assign, entry_label); + + // compile: if var end: goto top + if (end_on_stack) { + EMIT(dup_top_two); + EMIT(rot_two); + } else { + EMIT(dup_top); + compile_node(comp, pn_end); + } + assert(MP_PARSE_NODE_IS_SMALL_INT(pn_step)); + if (MP_PARSE_NODE_LEAF_SMALL_INT(pn_step) >= 0) { + EMIT_ARG(binary_op, MP_BINARY_OP_LESS); + } else { + EMIT_ARG(binary_op, MP_BINARY_OP_MORE); + } + EMIT_ARG(pop_jump_if, true, top_label); + + // break/continue apply to outer loop (if any) in the else block + END_BREAK_CONTINUE_BLOCK + + // Compile the else block. We must pop the iterator variables before + // executing the else code because it may contain break/continue statements. + uint end_label = 0; + if (!MP_PARSE_NODE_IS_NULL(pn_else)) { + // discard final value of "var", and possible "end" value + EMIT(pop_top); + if (end_on_stack) { + EMIT(pop_top); + } + compile_node(comp, pn_else); + end_label = comp_next_label(comp); + EMIT_ARG(jump, end_label); + EMIT_ARG(adjust_stack_size, 1 + end_on_stack); + } + + EMIT_ARG(label_assign, break_label); + + // discard final value of var that failed the loop condition + EMIT(pop_top); + + // discard value if it's on the stack + if (end_on_stack) { + EMIT(pop_top); + } + + if (!MP_PARSE_NODE_IS_NULL(pn_else)) { + EMIT_ARG(label_assign, end_label); + } +} + +STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + // this bit optimises: for in range(...), turning it into an explicitly incremented variable + // this is actually slower, but uses no heap memory + // for viper it will be much, much faster + if (/*comp->scope_cur->emit_options == MP_EMIT_OPT_VIPER &&*/ MP_PARSE_NODE_IS_ID(pns->nodes[0]) && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_atom_expr_normal)) { + mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_IS_ID(pns_it->nodes[0]) + && MP_PARSE_NODE_LEAF_ARG(pns_it->nodes[0]) == MP_QSTR_range + && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pns_it->nodes[1]) == PN_trailer_paren) { + mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0]; + mp_parse_node_t *args; + int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args); + mp_parse_node_t pn_range_start; + mp_parse_node_t pn_range_end; + mp_parse_node_t pn_range_step; + bool optimize = false; + if (1 <= n_args && n_args <= 3) { + optimize = true; + if (n_args == 1) { + pn_range_start = mp_parse_node_new_small_int(0); + pn_range_end = args[0]; + pn_range_step = mp_parse_node_new_small_int(1); + } else if (n_args == 2) { + pn_range_start = args[0]; + pn_range_end = args[1]; + pn_range_step = mp_parse_node_new_small_int(1); + } else { + pn_range_start = args[0]; + pn_range_end = args[1]; + pn_range_step = args[2]; + // the step must be a non-zero constant integer to do the optimisation + if (!MP_PARSE_NODE_IS_SMALL_INT(pn_range_step) + || MP_PARSE_NODE_LEAF_SMALL_INT(pn_range_step) == 0) { + optimize = false; + } + } + // arguments must be able to be compiled as standard expressions + if (optimize && MP_PARSE_NODE_IS_STRUCT(pn_range_start)) { + int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_range_start); + if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { + optimize = false; + } + } + if (optimize && MP_PARSE_NODE_IS_STRUCT(pn_range_end)) { + int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_range_end); + if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { + optimize = false; + } + } + } + if (optimize) { + compile_for_stmt_optimised_range(comp, pns->nodes[0], pn_range_start, pn_range_end, pn_range_step, pns->nodes[2], pns->nodes[3]); + return; + } + } + } + + START_BREAK_CONTINUE_BLOCK + comp->break_label |= MP_EMIT_BREAK_FROM_FOR; + + uint pop_label = comp_next_label(comp); + + compile_node(comp, pns->nodes[1]); // iterator + EMIT_ARG(get_iter, true); + EMIT_ARG(label_assign, continue_label); + EMIT_ARG(for_iter, pop_label); + c_assign(comp, pns->nodes[0], ASSIGN_STORE); // variable + compile_node(comp, pns->nodes[2]); // body + if (!EMIT(last_emit_was_return_value)) { + EMIT_ARG(jump, continue_label); + } + EMIT_ARG(label_assign, pop_label); + EMIT(for_iter_end); + + // break/continue apply to outer loop (if any) in the else block + END_BREAK_CONTINUE_BLOCK + + compile_node(comp, pns->nodes[3]); // else (may be empty) + + EMIT_ARG(label_assign, break_label); +} + +STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) { + // setup code + uint l1 = comp_next_label(comp); + uint success_label = comp_next_label(comp); + + EMIT_ARG(setup_except, l1); + compile_increase_except_level(comp); + + compile_node(comp, pn_body); // body + EMIT(pop_block); + EMIT_ARG(jump, success_label); // jump over exception handler + + EMIT_ARG(label_assign, l1); // start of exception handler + EMIT(start_except_handler); + + // at this point the top of the stack contains the exception instance that was raised + + uint l2 = comp_next_label(comp); + + for (int i = 0; i < n_except; i++) { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_excepts[i], PN_try_stmt_except)); // should be + mp_parse_node_struct_t *pns_except = (mp_parse_node_struct_t*)pn_excepts[i]; + + qstr qstr_exception_local = 0; + uint end_finally_label = comp_next_label(comp); + + if (MP_PARSE_NODE_IS_NULL(pns_except->nodes[0])) { + // this is a catch all exception handler + if (i + 1 != n_except) { + compile_syntax_error(comp, pn_excepts[i], "default 'except' must be last"); + compile_decrease_except_level(comp); + return; + } + } else { + // this exception handler requires a match to a certain type of exception + mp_parse_node_t pns_exception_expr = pns_except->nodes[0]; + if (MP_PARSE_NODE_IS_STRUCT(pns_exception_expr)) { + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns_exception_expr; + if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_try_stmt_as_name) { + // handler binds the exception to a local + pns_exception_expr = pns3->nodes[0]; + qstr_exception_local = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[1]); + } + } + EMIT(dup_top); + compile_node(comp, pns_exception_expr); + EMIT_ARG(binary_op, MP_BINARY_OP_EXCEPTION_MATCH); + EMIT_ARG(pop_jump_if, false, end_finally_label); + } + + // either discard or store the exception instance + if (qstr_exception_local == 0) { + EMIT(pop_top); + } else { + compile_store_id(comp, qstr_exception_local); + } + + uint l3 = 0; + if (qstr_exception_local != 0) { + l3 = comp_next_label(comp); + EMIT_ARG(setup_finally, l3); + compile_increase_except_level(comp); + } + compile_node(comp, pns_except->nodes[1]); + if (qstr_exception_local != 0) { + EMIT(pop_block); + } + EMIT(pop_except); + if (qstr_exception_local != 0) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT_ARG(label_assign, l3); + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + compile_store_id(comp, qstr_exception_local); + compile_delete_id(comp, qstr_exception_local); + + compile_decrease_except_level(comp); + EMIT(end_finally); + } + EMIT_ARG(jump, l2); + EMIT_ARG(label_assign, end_finally_label); + EMIT_ARG(adjust_stack_size, 1); // stack adjust for the exception instance + } + + compile_decrease_except_level(comp); + EMIT(end_finally); + EMIT(end_except_handler); + + EMIT_ARG(label_assign, success_label); + compile_node(comp, pn_else); // else block, can be null + EMIT_ARG(label_assign, l2); +} + +STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) { + uint l_finally_block = comp_next_label(comp); + + EMIT_ARG(setup_finally, l_finally_block); + compile_increase_except_level(comp); + + if (n_except == 0) { + assert(MP_PARSE_NODE_IS_NULL(pn_else)); + EMIT_ARG(adjust_stack_size, 3); // stack adjust for possible UNWIND_JUMP state + compile_node(comp, pn_body); + EMIT_ARG(adjust_stack_size, -3); + } else { + compile_try_except(comp, pn_body, n_except, pn_except, pn_else); + } + EMIT(pop_block); + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT_ARG(label_assign, l_finally_block); + compile_node(comp, pn_finally); + + compile_decrease_except_level(comp); + EMIT(end_finally); +} + +STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should be + { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_try_stmt_finally) { + // just try-finally + compile_try_finally(comp, pns->nodes[0], 0, NULL, MP_PARSE_NODE_NULL, pns2->nodes[0]); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_try_stmt_except_and_more) { + // try-except and possibly else and/or finally + mp_parse_node_t *pn_excepts; + int n_except = mp_parse_node_extract_list(&pns2->nodes[0], PN_try_stmt_except_list, &pn_excepts); + if (MP_PARSE_NODE_IS_NULL(pns2->nodes[2])) { + // no finally + compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1]); + } else { + // have finally + compile_try_finally(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1], ((mp_parse_node_struct_t*)pns2->nodes[2])->nodes[0]); + } + } else { + // just try-except + mp_parse_node_t *pn_excepts; + int n_except = mp_parse_node_extract_list(&pns->nodes[1], PN_try_stmt_except_list, &pn_excepts); + compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, MP_PARSE_NODE_NULL); + } + } +} + +STATIC void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, mp_parse_node_t body) { + if (n == 0) { + // no more pre-bits, compile the body of the with + compile_node(comp, body); + } else { + uint l_end = comp_next_label(comp); + if (MICROPY_EMIT_NATIVE && comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) { + // we need to allocate an extra label for the native emitter + // it will use l_end+1 as an auxiliary label + comp_next_label(comp); + } + if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes[0], PN_with_item)) { + // this pre-bit is of the form "a as b" + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0]; + compile_node(comp, pns->nodes[0]); + EMIT_ARG(setup_with, l_end); + c_assign(comp, pns->nodes[1], ASSIGN_STORE); + } else { + // this pre-bit is just an expression + compile_node(comp, nodes[0]); + EMIT_ARG(setup_with, l_end); + EMIT(pop_top); + } + compile_increase_except_level(comp); + // compile additional pre-bits and the body + compile_with_stmt_helper(comp, n - 1, nodes + 1, body); + // finish this with block + EMIT_ARG(with_cleanup, l_end); + compile_decrease_except_level(comp); + EMIT(end_finally); + } +} + +STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit) + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes); + assert(n > 0); + + // compile in a nested fashion + compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]); +} + +STATIC void compile_yield_from(compiler_t *comp) { + EMIT_ARG(get_iter, false); + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT(yield_from); +} + +#if MICROPY_PY_ASYNC_AWAIT +STATIC void compile_await_object_method(compiler_t *comp, qstr method) { + EMIT_ARG(load_method, method, false); + EMIT_ARG(call_method, 0, 0, 0); + compile_yield_from(comp); +} + +STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + // comp->break_label |= MP_EMIT_BREAK_FROM_FOR; + + qstr context = MP_PARSE_NODE_LEAF_ARG(pns->nodes[1]); + uint while_else_label = comp_next_label(comp); + uint try_exception_label = comp_next_label(comp); + uint try_else_label = comp_next_label(comp); + uint try_finally_label = comp_next_label(comp); + + compile_node(comp, pns->nodes[1]); // iterator + compile_await_object_method(comp, MP_QSTR___aiter__); + compile_store_id(comp, context); + + START_BREAK_CONTINUE_BLOCK + + EMIT_ARG(label_assign, continue_label); + + EMIT_ARG(setup_except, try_exception_label); + compile_increase_except_level(comp); + + compile_load_id(comp, context); + compile_await_object_method(comp, MP_QSTR___anext__); + c_assign(comp, pns->nodes[0], ASSIGN_STORE); // variable + EMIT(pop_block); + EMIT_ARG(jump, try_else_label); + + EMIT_ARG(label_assign, try_exception_label); + EMIT(start_except_handler); + EMIT(dup_top); + EMIT_LOAD_GLOBAL(MP_QSTR_StopAsyncIteration); + EMIT_ARG(binary_op, MP_BINARY_OP_EXCEPTION_MATCH); + EMIT_ARG(pop_jump_if, false, try_finally_label); + EMIT(pop_top); // pop exception instance + EMIT(pop_except); + EMIT_ARG(jump, while_else_label); + + EMIT_ARG(label_assign, try_finally_label); + EMIT_ARG(adjust_stack_size, 1); // if we jump here, the exc is on the stack + compile_decrease_except_level(comp); + EMIT(end_finally); + EMIT(end_except_handler); + + EMIT_ARG(label_assign, try_else_label); + compile_node(comp, pns->nodes[2]); // body + + EMIT_ARG(jump, continue_label); + // break/continue apply to outer loop (if any) in the else block + END_BREAK_CONTINUE_BLOCK + + EMIT_ARG(label_assign, while_else_label); + compile_node(comp, pns->nodes[3]); // else + + EMIT_ARG(label_assign, break_label); +} + +STATIC void compile_async_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, mp_parse_node_t body) { + if (n == 0) { + // no more pre-bits, compile the body of the with + compile_node(comp, body); + } else { + uint try_exception_label = comp_next_label(comp); + uint no_reraise_label = comp_next_label(comp); + uint try_else_label = comp_next_label(comp); + uint end_label = comp_next_label(comp); + qstr context; + + if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes[0], PN_with_item)) { + // this pre-bit is of the form "a as b" + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0]; + compile_node(comp, pns->nodes[0]); + context = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + compile_store_id(comp, context); + compile_load_id(comp, context); + compile_await_object_method(comp, MP_QSTR___aenter__); + c_assign(comp, pns->nodes[1], ASSIGN_STORE); + } else { + // this pre-bit is just an expression + compile_node(comp, nodes[0]); + context = MP_PARSE_NODE_LEAF_ARG(nodes[0]); + compile_store_id(comp, context); + compile_load_id(comp, context); + compile_await_object_method(comp, MP_QSTR___aenter__); + EMIT(pop_top); + } + + compile_load_id(comp, context); + EMIT_ARG(load_method, MP_QSTR___aexit__, false); + + EMIT_ARG(setup_except, try_exception_label); + compile_increase_except_level(comp); + // compile additional pre-bits and the body + compile_async_with_stmt_helper(comp, n - 1, nodes + 1, body); + // finish this with block + EMIT(pop_block); + EMIT_ARG(jump, try_else_label); // jump over exception handler + + EMIT_ARG(label_assign, try_exception_label); // start of exception handler + EMIT(start_except_handler); + + // at this point the stack contains: ..., __aexit__, self, exc + EMIT(dup_top); + #if MICROPY_CPYTHON_COMPAT + EMIT_ARG(load_attr, MP_QSTR___class__); // get type(exc) + #else + compile_load_id(comp, MP_QSTR_type); + EMIT(rot_two); + EMIT_ARG(call_function, 1, 0, 0); // get type(exc) + #endif + EMIT(rot_two); + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // dummy traceback value + // at this point the stack contains: ..., __aexit__, self, type(exc), exc, None + EMIT_ARG(call_method, 3, 0, 0); + + compile_yield_from(comp); + EMIT_ARG(pop_jump_if, true, no_reraise_label); + EMIT_ARG(raise_varargs, 0); + + EMIT_ARG(label_assign, no_reraise_label); + EMIT(pop_except); + EMIT_ARG(jump, end_label); + + EMIT_ARG(adjust_stack_size, 3); // adjust for __aexit__, self, exc + compile_decrease_except_level(comp); + EMIT(end_finally); + EMIT(end_except_handler); + + EMIT_ARG(label_assign, try_else_label); // start of try-else handler + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT(dup_top); + EMIT(dup_top); + EMIT_ARG(call_method, 3, 0, 0); + compile_yield_from(comp); + EMIT(pop_top); + + EMIT_ARG(label_assign, end_label); + + } +} + +STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit) + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes); + assert(n > 0); + + // compile in a nested fashion + compile_async_with_stmt_helper(comp, n, nodes, pns->nodes[1]); +} + +STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[0])); + mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_funcdef) { + // async def + compile_funcdef(comp, pns0); + scope_t *fscope = (scope_t*)pns0->nodes[4]; + fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_for_stmt) { + // async for + compile_async_for_stmt(comp, pns0); + } else { + // async with + assert(MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_with_stmt); + compile_async_with_stmt(comp, pns0); + } +} +#endif + +STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { + if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) { + // for REPL, evaluate then print the expression + compile_load_id(comp, MP_QSTR___repl_print__); + compile_node(comp, pns->nodes[0]); + EMIT_ARG(call_function, 1, 0, 0); + EMIT(pop_top); + + } else { + // for non-REPL, evaluate then discard the expression + if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0]) && !MP_PARSE_NODE_IS_ID(pns->nodes[0])) + || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_const_object)) { + // do nothing with a lonely constant + } else { + compile_node(comp, pns->nodes[0]); // just an expression + EMIT(pop_top); // discard last result since this is a statement and leaves nothing on the stack + } + } + } else if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + int kind = MP_PARSE_NODE_STRUCT_KIND(pns1); + if (kind == PN_expr_stmt_augassign) { + c_assign(comp, pns->nodes[0], ASSIGN_AUG_LOAD); // lhs load for aug assign + compile_node(comp, pns1->nodes[1]); // rhs + assert(MP_PARSE_NODE_IS_TOKEN(pns1->nodes[0])); + mp_binary_op_t op; + switch (MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])) { + case MP_TOKEN_DEL_PIPE_EQUAL: op = MP_BINARY_OP_INPLACE_OR; break; + case MP_TOKEN_DEL_CARET_EQUAL: op = MP_BINARY_OP_INPLACE_XOR; break; + case MP_TOKEN_DEL_AMPERSAND_EQUAL: op = MP_BINARY_OP_INPLACE_AND; break; + case MP_TOKEN_DEL_DBL_LESS_EQUAL: op = MP_BINARY_OP_INPLACE_LSHIFT; break; + case MP_TOKEN_DEL_DBL_MORE_EQUAL: op = MP_BINARY_OP_INPLACE_RSHIFT; break; + case MP_TOKEN_DEL_PLUS_EQUAL: op = MP_BINARY_OP_INPLACE_ADD; break; + case MP_TOKEN_DEL_MINUS_EQUAL: op = MP_BINARY_OP_INPLACE_SUBTRACT; break; + case MP_TOKEN_DEL_STAR_EQUAL: op = MP_BINARY_OP_INPLACE_MULTIPLY; break; + case MP_TOKEN_DEL_DBL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_FLOOR_DIVIDE; break; + case MP_TOKEN_DEL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_TRUE_DIVIDE; break; + case MP_TOKEN_DEL_PERCENT_EQUAL: op = MP_BINARY_OP_INPLACE_MODULO; break; + case MP_TOKEN_DEL_DBL_STAR_EQUAL: default: op = MP_BINARY_OP_INPLACE_POWER; break; + } + EMIT_ARG(binary_op, op); + c_assign(comp, pns->nodes[0], ASSIGN_AUG_STORE); // lhs store for aug assign + } else if (kind == PN_expr_stmt_assign_list) { + int rhs = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1) - 1; + compile_node(comp, pns1->nodes[rhs]); // rhs + // following CPython, we store left-most first + if (rhs > 0) { + EMIT(dup_top); + } + c_assign(comp, pns->nodes[0], ASSIGN_STORE); // lhs store + for (int i = 0; i < rhs; i++) { + if (i + 1 < rhs) { + EMIT(dup_top); + } + c_assign(comp, pns1->nodes[i], ASSIGN_STORE); // middle store + } + } else { + plain_assign: + if (MICROPY_COMP_DOUBLE_TUPLE_ASSIGN + && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_testlist_star_expr) + && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_star_expr) + && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[1]) == 2 + && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 2) { + // optimisation for a, b = c, d + mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; + mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr) + || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr)) { + // can't optimise when it's a star expression on the lhs + goto no_optimisation; + } + compile_node(comp, pns10->nodes[0]); // rhs + compile_node(comp, pns10->nodes[1]); // rhs + EMIT(rot_two); + c_assign(comp, pns0->nodes[0], ASSIGN_STORE); // lhs store + c_assign(comp, pns0->nodes[1], ASSIGN_STORE); // lhs store + } else if (MICROPY_COMP_TRIPLE_TUPLE_ASSIGN + && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_testlist_star_expr) + && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_star_expr) + && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[1]) == 3 + && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 3) { + // optimisation for a, b, c = d, e, f + mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; + mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr) + || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr) + || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[2], PN_star_expr)) { + // can't optimise when it's a star expression on the lhs + goto no_optimisation; + } + compile_node(comp, pns10->nodes[0]); // rhs + compile_node(comp, pns10->nodes[1]); // rhs + compile_node(comp, pns10->nodes[2]); // rhs + EMIT(rot_three); + EMIT(rot_two); + c_assign(comp, pns0->nodes[0], ASSIGN_STORE); // lhs store + c_assign(comp, pns0->nodes[1], ASSIGN_STORE); // lhs store + c_assign(comp, pns0->nodes[2], ASSIGN_STORE); // lhs store + } else { + no_optimisation: + compile_node(comp, pns->nodes[1]); // rhs + c_assign(comp, pns->nodes[0], ASSIGN_STORE); // lhs store + } + } + } else { + goto plain_assign; + } +} + +STATIC void c_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns, mp_binary_op_t binary_op) { + int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + compile_node(comp, pns->nodes[0]); + for (int i = 1; i < num_nodes; i += 1) { + compile_node(comp, pns->nodes[i]); + EMIT_ARG(binary_op, binary_op); + } +} + +STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else)); + mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns->nodes[1]; + + uint l_fail = comp_next_label(comp); + uint l_end = comp_next_label(comp); + c_if_cond(comp, pns_test_if_else->nodes[0], false, l_fail); // condition + compile_node(comp, pns->nodes[0]); // success value + EMIT_ARG(jump, l_end); + EMIT_ARG(label_assign, l_fail); + EMIT_ARG(adjust_stack_size, -1); // adjust stack size + compile_node(comp, pns_test_if_else->nodes[1]); // failure value + EMIT_ARG(label_assign, l_end); +} + +STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->pass == MP_PASS_SCOPE) { + // create a new scope for this lambda + scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options); + // store the lambda scope so the compiling function (this one) can use it at each pass + pns->nodes[2] = (mp_parse_node_t)s; + } + + // get the scope for this lambda + scope_t *this_scope = (scope_t*)pns->nodes[2]; + + // compile the lambda definition + compile_funcdef_lambdef(comp, this_scope, pns->nodes[0], PN_varargslist); +} + +STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns, bool cond) { + uint l_end = comp_next_label(comp); + int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + for (int i = 0; i < n; i += 1) { + compile_node(comp, pns->nodes[i]); + if (i + 1 < n) { + EMIT_ARG(jump_if_or_pop, cond, l_end); + } + } + EMIT_ARG(label_assign, l_end); +} + +STATIC void compile_or_test(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_or_and_test(comp, pns, true); +} + +STATIC void compile_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_or_and_test(comp, pns, false); +} + +STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[0]); + EMIT_ARG(unary_op, MP_UNARY_OP_NOT); +} + +STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) { + int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + compile_node(comp, pns->nodes[0]); + bool multi = (num_nodes > 3); + uint l_fail = 0; + if (multi) { + l_fail = comp_next_label(comp); + } + for (int i = 1; i + 1 < num_nodes; i += 2) { + compile_node(comp, pns->nodes[i + 1]); + if (i + 2 < num_nodes) { + EMIT(dup_top); + EMIT(rot_three); + } + if (MP_PARSE_NODE_IS_TOKEN(pns->nodes[i])) { + mp_binary_op_t op; + switch (MP_PARSE_NODE_LEAF_ARG(pns->nodes[i])) { + case MP_TOKEN_OP_LESS: op = MP_BINARY_OP_LESS; break; + case MP_TOKEN_OP_MORE: op = MP_BINARY_OP_MORE; break; + case MP_TOKEN_OP_DBL_EQUAL: op = MP_BINARY_OP_EQUAL; break; + case MP_TOKEN_OP_LESS_EQUAL: op = MP_BINARY_OP_LESS_EQUAL; break; + case MP_TOKEN_OP_MORE_EQUAL: op = MP_BINARY_OP_MORE_EQUAL; break; + case MP_TOKEN_OP_NOT_EQUAL: op = MP_BINARY_OP_NOT_EQUAL; break; + case MP_TOKEN_KW_IN: default: op = MP_BINARY_OP_IN; break; + } + EMIT_ARG(binary_op, op); + } else { + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[i])); // should be + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[i]; + int kind = MP_PARSE_NODE_STRUCT_KIND(pns2); + if (kind == PN_comp_op_not_in) { + EMIT_ARG(binary_op, MP_BINARY_OP_NOT_IN); + } else { + assert(kind == PN_comp_op_is); // should be + if (MP_PARSE_NODE_IS_NULL(pns2->nodes[0])) { + EMIT_ARG(binary_op, MP_BINARY_OP_IS); + } else { + EMIT_ARG(binary_op, MP_BINARY_OP_IS_NOT); + } + } + } + if (i + 2 < num_nodes) { + EMIT_ARG(jump_if_or_pop, false, l_fail); + } + } + if (multi) { + uint l_end = comp_next_label(comp); + EMIT_ARG(jump, l_end); + EMIT_ARG(label_assign, l_fail); + EMIT_ARG(adjust_stack_size, 1); + EMIT(rot_two); + EMIT(pop_top); + EMIT_ARG(label_assign, l_end); + } +} + +STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "*x must be assignment target"); +} + +STATIC void compile_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + c_binary_op(comp, pns, MP_BINARY_OP_OR); +} + +STATIC void compile_xor_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + c_binary_op(comp, pns, MP_BINARY_OP_XOR); +} + +STATIC void compile_and_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + c_binary_op(comp, pns, MP_BINARY_OP_AND); +} + +STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) { + int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + compile_node(comp, pns->nodes[0]); + for (int i = 1; i + 1 < num_nodes; i += 2) { + compile_node(comp, pns->nodes[i + 1]); + mp_binary_op_t op; + mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[i]); + switch (tok) { + case MP_TOKEN_OP_PLUS: op = MP_BINARY_OP_ADD; break; + case MP_TOKEN_OP_MINUS: op = MP_BINARY_OP_SUBTRACT; break; + case MP_TOKEN_OP_STAR: op = MP_BINARY_OP_MULTIPLY; break; + case MP_TOKEN_OP_DBL_SLASH: op = MP_BINARY_OP_FLOOR_DIVIDE; break; + case MP_TOKEN_OP_SLASH: op = MP_BINARY_OP_TRUE_DIVIDE; break; + case MP_TOKEN_OP_PERCENT: op = MP_BINARY_OP_MODULO; break; + case MP_TOKEN_OP_DBL_LESS: op = MP_BINARY_OP_LSHIFT; break; + default: + assert(tok == MP_TOKEN_OP_DBL_MORE); + op = MP_BINARY_OP_RSHIFT; + break; + } + EMIT_ARG(binary_op, op); + } +} + +STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[1]); + mp_unary_op_t op; + mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + switch (tok) { + case MP_TOKEN_OP_PLUS: op = MP_UNARY_OP_POSITIVE; break; + case MP_TOKEN_OP_MINUS: op = MP_UNARY_OP_NEGATIVE; break; + default: + assert(tok == MP_TOKEN_OP_TILDE); + op = MP_UNARY_OP_INVERT; + break; + } + EMIT_ARG(unary_op, op); +} + +STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) { + // compile the subject of the expression + compile_node(comp, pns->nodes[0]); + + // compile_atom_expr_await may call us with a NULL node + if (MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { + return; + } + + // get the array of trailers (known to be an array of PARSE_NODE_STRUCT) + size_t num_trail = 1; + mp_parse_node_struct_t **pns_trail = (mp_parse_node_struct_t**)&pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_atom_expr_trailers) { + num_trail = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_trail[0]); + pns_trail = (mp_parse_node_struct_t**)&pns_trail[0]->nodes[0]; + } + + // the current index into the array of trailers + size_t i = 0; + + // handle special super() call + if (comp->scope_cur->kind == SCOPE_FUNCTION + && MP_PARSE_NODE_IS_ID(pns->nodes[0]) + && MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]) == MP_QSTR_super + && MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_trailer_paren + && MP_PARSE_NODE_IS_NULL(pns_trail[0]->nodes[0])) { + // at this point we have matched "super()" within a function + + // load the class for super to search for a parent + compile_load_id(comp, MP_QSTR___class__); + + // look for first argument to function (assumes it's "self") + bool found = false; + id_info_t *id = &comp->scope_cur->id_info[0]; + for (size_t n = comp->scope_cur->id_info_len; n > 0; --n, ++id) { + if (id->flags & ID_FLAG_IS_PARAM) { + // first argument found; load it + compile_load_id(comp, id->qst); + found = true; + break; + } + } + if (!found) { + compile_syntax_error(comp, (mp_parse_node_t)pns_trail[0], + "super() can't find self"); // really a TypeError + return; + } + + if (num_trail >= 3 + && MP_PARSE_NODE_STRUCT_KIND(pns_trail[1]) == PN_trailer_period + && MP_PARSE_NODE_STRUCT_KIND(pns_trail[2]) == PN_trailer_paren) { + // optimisation for method calls super().f(...), to eliminate heap allocation + mp_parse_node_struct_t *pns_period = pns_trail[1]; + mp_parse_node_struct_t *pns_paren = pns_trail[2]; + EMIT_ARG(load_method, MP_PARSE_NODE_LEAF_ARG(pns_period->nodes[0]), true); + compile_trailer_paren_helper(comp, pns_paren->nodes[0], true, 0); + i = 3; + } else { + // a super() call + EMIT_ARG(call_function, 2, 0, 0); + i = 1; + } + } + + // compile the remaining trailers + for (; i < num_trail; i++) { + if (i + 1 < num_trail + && MP_PARSE_NODE_STRUCT_KIND(pns_trail[i]) == PN_trailer_period + && MP_PARSE_NODE_STRUCT_KIND(pns_trail[i + 1]) == PN_trailer_paren) { + // optimisation for method calls a.f(...), following PyPy + mp_parse_node_struct_t *pns_period = pns_trail[i]; + mp_parse_node_struct_t *pns_paren = pns_trail[i + 1]; + EMIT_ARG(load_method, MP_PARSE_NODE_LEAF_ARG(pns_period->nodes[0]), false); + compile_trailer_paren_helper(comp, pns_paren->nodes[0], true, 0); + i += 1; + } else { + // node is one of: trailer_paren, trailer_bracket, trailer_period + compile_node(comp, (mp_parse_node_t)pns_trail[i]); + } + } +} + +STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_generic_all_nodes(comp, pns); // 2 nodes, arguments of power + EMIT_ARG(binary_op, MP_BINARY_OP_POWER); +} + +STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) { + // function to call is on top of stack + + // get the list of arguments + mp_parse_node_t *args; + int n_args = mp_parse_node_extract_list(&pn_arglist, PN_arglist, &args); + + // compile the arguments + // Rather than calling compile_node on the list, we go through the list of args + // explicitly here so that we can count the number of arguments and give sensible + // error messages. + int n_positional = n_positional_extra; + uint n_keyword = 0; + uint star_flags = 0; + mp_parse_node_struct_t *star_args_node = NULL, *dblstar_args_node = NULL; + for (int i = 0; i < n_args; i++) { + if (MP_PARSE_NODE_IS_STRUCT(args[i])) { + mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t*)args[i]; + if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_star) { + if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) { + compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple *x"); + return; + } + star_flags |= MP_EMIT_STAR_FLAG_SINGLE; + star_args_node = pns_arg; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_dbl_star) { + if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) { + compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple **x"); + return; + } + star_flags |= MP_EMIT_STAR_FLAG_DOUBLE; + dblstar_args_node = pns_arg; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_argument) { + if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns_arg->nodes[1], PN_comp_for)) { + if (!MP_PARSE_NODE_IS_ID(pns_arg->nodes[0])) { + compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id"); + return; + } + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0])); + compile_node(comp, pns_arg->nodes[1]); + n_keyword += 1; + } else { + compile_comprehension(comp, pns_arg, SCOPE_GEN_EXPR); + n_positional++; + } + } else { + goto normal_argument; + } + } else { + normal_argument: + if (star_flags) { + compile_syntax_error(comp, args[i], "non-keyword arg after */**"); + return; + } + if (n_keyword > 0) { + compile_syntax_error(comp, args[i], "non-keyword arg after keyword arg"); + return; + } + compile_node(comp, args[i]); + n_positional++; + } + } + + // compile the star/double-star arguments if we had them + // if we had one but not the other then we load "null" as a place holder + if (star_flags != 0) { + if (star_args_node == NULL) { + EMIT(load_null); + } else { + compile_node(comp, star_args_node->nodes[0]); + } + if (dblstar_args_node == NULL) { + EMIT(load_null); + } else { + compile_node(comp, dblstar_args_node->nodes[0]); + } + } + + // emit the function/method call + if (is_method_call) { + EMIT_ARG(call_method, n_positional, n_keyword, star_flags); + } else { + EMIT_ARG(call_function, n_positional, n_keyword, star_flags); + } +} + +// pns needs to have 2 nodes, first is lhs of comprehension, second is PN_comp_for node +STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) { + assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2); + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)); + mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; + + if (comp->pass == MP_PASS_SCOPE) { + // create a new scope for this comprehension + scope_t *s = scope_new_and_link(comp, kind, (mp_parse_node_t)pns, comp->scope_cur->emit_options); + // store the comprehension scope so the compiling function (this one) can use it at each pass + pns_comp_for->nodes[3] = (mp_parse_node_t)s; + } + + // get the scope for this comprehension + scope_t *this_scope = (scope_t*)pns_comp_for->nodes[3]; + + // compile the comprehension + close_over_variables_etc(comp, this_scope, 0, 0); + + compile_node(comp, pns_comp_for->nodes[1]); // source of the iterator + if (kind == SCOPE_GEN_EXPR) { + EMIT_ARG(get_iter, false); + } + EMIT_ARG(call_function, 1, 0, 0); +} + +STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // an empty tuple + c_tuple(comp, MP_PARSE_NODE_NULL, NULL); + } else { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + assert(!MP_PARSE_NODE_IS_NULL(pns->nodes[1])); + if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { + // tuple of one item, with trailing comma + assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); + c_tuple(comp, pns->nodes[0], NULL); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { + // tuple of many items + c_tuple(comp, pns->nodes[0], pns2); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { + // generator expression + compile_comprehension(comp, pns, SCOPE_GEN_EXPR); + } else { + // tuple with 2 items + goto tuple_with_2_items; + } + } else { + // tuple with 2 items + tuple_with_2_items: + c_tuple(comp, MP_PARSE_NODE_NULL, pns); + } + } +} + +STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // empty list + EMIT_ARG(build_list, 0); + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[0]; + if (MP_PARSE_NODE_IS_STRUCT(pns2->nodes[1])) { + mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns2->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3b) { + // list of one item, with trailing comma + assert(MP_PARSE_NODE_IS_NULL(pns3->nodes[0])); + compile_node(comp, pns2->nodes[0]); + EMIT_ARG(build_list, 1); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3c) { + // list of many items + compile_node(comp, pns2->nodes[0]); + compile_generic_all_nodes(comp, pns3); + EMIT_ARG(build_list, 1 + MP_PARSE_NODE_STRUCT_NUM_NODES(pns3)); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_comp_for) { + // list comprehension + compile_comprehension(comp, pns2, SCOPE_LIST_COMP); + } else { + // list with 2 items + goto list_with_2_items; + } + } else { + // list with 2 items + list_with_2_items: + compile_node(comp, pns2->nodes[0]); + compile_node(comp, pns2->nodes[1]); + EMIT_ARG(build_list, 2); + } + } else { + // list with 1 item + compile_node(comp, pns->nodes[0]); + EMIT_ARG(build_list, 1); + } +} + +STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) { + mp_parse_node_t pn = pns->nodes[0]; + if (MP_PARSE_NODE_IS_NULL(pn)) { + // empty dict + EMIT_ARG(build_map, 0); + } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { + pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker_item) { + // dict with one element + EMIT_ARG(build_map, 1); + compile_node(comp, pn); + EMIT(store_map); + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker) { + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should succeed + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_dictorsetmaker_list) { + // dict/set with multiple elements + + // get tail elements (2nd, 3rd, ...) + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns1->nodes[0], PN_dictorsetmaker_list2, &nodes); + + // first element sets whether it's a dict or set + bool is_dict; + if (!MICROPY_PY_BUILTINS_SET || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_dictorsetmaker_item)) { + // a dictionary + EMIT_ARG(build_map, 1 + n); + compile_node(comp, pns->nodes[0]); + EMIT(store_map); + is_dict = true; + } else { + // a set + compile_node(comp, pns->nodes[0]); // 1st value of set + is_dict = false; + } + + // process rest of elements + for (int i = 0; i < n; i++) { + mp_parse_node_t pn_i = nodes[i]; + bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND(pn_i, PN_dictorsetmaker_item); + compile_node(comp, pn_i); + if (is_dict) { + if (!is_key_value) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); + } else { + compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict"); + } + return; + } + EMIT(store_map); + } else { + if (is_key_value) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); + } else { + compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set"); + } + return; + } + } + } + + #if MICROPY_PY_BUILTINS_SET + // if it's a set, build it + if (!is_dict) { + EMIT_ARG(build_set, 1 + n); + } + #endif + } else { + assert(MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for); // should be + // dict/set comprehension + if (!MICROPY_PY_BUILTINS_SET || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_dictorsetmaker_item)) { + // a dictionary comprehension + compile_comprehension(comp, pns, SCOPE_DICT_COMP); + } else { + // a set comprehension + compile_comprehension(comp, pns, SCOPE_SET_COMP); + } + } + } else { + // set with one element + goto set_with_one_element; + } + } else { + // set with one element + set_with_one_element: + #if MICROPY_PY_BUILTINS_SET + compile_node(comp, pn); + EMIT_ARG(build_set, 1); + #else + assert(0); + #endif + } +} + +STATIC void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_trailer_paren_helper(comp, pns->nodes[0], false, 0); +} + +STATIC void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { + // object who's index we want is on top of stack + compile_node(comp, pns->nodes[0]); // the index + EMIT(load_subscr); +} + +STATIC void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) { + // object who's attribute we want is on top of stack + EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // attribute to get +} + +#if MICROPY_PY_BUILTINS_SLICE +STATIC void compile_subscript_3_helper(compiler_t *comp, mp_parse_node_struct_t *pns) { + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3); // should always be + mp_parse_node_t pn = pns->nodes[0]; + if (MP_PARSE_NODE_IS_NULL(pn)) { + // [?:] + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT_ARG(build_slice, 2); + } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { + pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3c) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + pn = pns->nodes[0]; + if (MP_PARSE_NODE_IS_NULL(pn)) { + // [?::] + EMIT_ARG(build_slice, 2); + } else { + // [?::x] + compile_node(comp, pn); + EMIT_ARG(build_slice, 3); + } + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3d) { + compile_node(comp, pns->nodes[0]); + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be + pns = (mp_parse_node_struct_t*)pns->nodes[1]; + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_sliceop); // should always be + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // [?:x:] + EMIT_ARG(build_slice, 2); + } else { + // [?:x:x] + compile_node(comp, pns->nodes[0]); + EMIT_ARG(build_slice, 3); + } + } else { + // [?:x] + compile_node(comp, pn); + EMIT_ARG(build_slice, 2); + } + } else { + // [?:x] + compile_node(comp, pn); + EMIT_ARG(build_slice, 2); + } +} + +STATIC void compile_subscript_2(compiler_t *comp, mp_parse_node_struct_t *pns) { + compile_node(comp, pns->nodes[0]); // start of slice + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be + compile_subscript_3_helper(comp, (mp_parse_node_struct_t*)pns->nodes[1]); +} + +STATIC void compile_subscript_3(compiler_t *comp, mp_parse_node_struct_t *pns) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + compile_subscript_3_helper(comp, pns); +} +#endif // MICROPY_PY_BUILTINS_SLICE + +STATIC void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) { + // if this is called then we are compiling a dict key:value pair + compile_node(comp, pns->nodes[1]); // value + compile_node(comp, pns->nodes[0]); // key +} + +STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) { + qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options); + // store class object into class name + compile_store_id(comp, cname); +} + +STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'yield' outside function"); + return; + } + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT(yield_value); + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_yield_arg_from)) { + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + compile_node(comp, pns->nodes[0]); + compile_yield_from(comp); + } else { + compile_node(comp, pns->nodes[0]); + EMIT(yield_value); + } +} + +#if MICROPY_PY_ASYNC_AWAIT +STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) { + if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) { + compile_syntax_error(comp, (mp_parse_node_t)pns, "'await' outside function"); + return; + } + compile_atom_expr_normal(comp, pns); + compile_yield_from(comp); +} +#endif + +STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) { + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + // nodes are 32-bit pointers, but need to extract 64-bit object + return (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32); + #else + return (mp_obj_t)pns->nodes[0]; + #endif +} + +STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) { + EMIT_ARG(load_const_obj, get_const_object(pns)); +} + +typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*); +STATIC const compile_function_t compile_function[] = { +// only define rules with a compile function +#define c(f) compile_##f +#define DEF_RULE(rule, comp, kind, ...) comp, +#define DEF_RULE_NC(rule, kind, ...) +#include "py/grammar.h" +#undef c +#undef DEF_RULE +#undef DEF_RULE_NC + compile_const_object, +}; + +STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) { + if (MP_PARSE_NODE_IS_NULL(pn)) { + // pass + } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) { + mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn); + #if MICROPY_DYNAMIC_COMPILER + mp_uint_t sign_mask = -(1 << (mp_dynamic_compiler.small_int_bits - 1)); + if ((arg & sign_mask) == 0 || (arg & sign_mask) == sign_mask) { + // integer fits in target runtime's small-int + EMIT_ARG(load_const_small_int, arg); + } else { + // integer doesn't fit, so create a multi-precision int object + // (but only create the actual object on the last pass) + if (comp->pass != MP_PASS_EMIT) { + EMIT_ARG(load_const_obj, mp_const_none); + } else { + EMIT_ARG(load_const_obj, mp_obj_new_int_from_ll(arg)); + } + } + #else + EMIT_ARG(load_const_small_int, arg); + #endif + } else if (MP_PARSE_NODE_IS_LEAF(pn)) { + uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn); + switch (MP_PARSE_NODE_LEAF_KIND(pn)) { + case MP_PARSE_NODE_ID: compile_load_id(comp, arg); break; + case MP_PARSE_NODE_STRING: EMIT_ARG(load_const_str, arg); break; + case MP_PARSE_NODE_BYTES: + // only create and load the actual bytes object on the last pass + if (comp->pass != MP_PASS_EMIT) { + EMIT_ARG(load_const_obj, mp_const_none); + } else { + size_t len; + const byte *data = qstr_data(arg, &len); + EMIT_ARG(load_const_obj, mp_obj_new_bytes(data, len)); + } + break; + case MP_PARSE_NODE_TOKEN: default: + if (arg == MP_TOKEN_NEWLINE) { + // this can occur when file_input lets through a NEWLINE (eg if file starts with a newline) + // or when single_input lets through a NEWLINE (user enters a blank line) + // do nothing + } else { + EMIT_ARG(load_const_tok, arg); + } + break; + } + } else { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + EMIT_ARG(set_source_line, pns->source_line); + assert(MP_PARSE_NODE_STRUCT_KIND(pns) <= PN_const_object); + compile_function_t f = compile_function[MP_PARSE_NODE_STRUCT_KIND(pns)]; + f(comp, pns); + } +} + +STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) { + // check that **kw is last + if ((comp->scope_cur->scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) { + compile_syntax_error(comp, pn, "invalid syntax"); + return; + } + + qstr param_name = MP_QSTR_NULL; + uint param_flag = ID_FLAG_IS_PARAM; + if (MP_PARSE_NODE_IS_ID(pn)) { + param_name = MP_PARSE_NODE_LEAF_ARG(pn); + if (comp->have_star) { + // comes after a star, so counts as a keyword-only parameter + comp->scope_cur->num_kwonly_args += 1; + } else { + // comes before a star, so counts as a positional parameter + comp->scope_cur->num_pos_args += 1; + } + } else { + assert(MP_PARSE_NODE_IS_STRUCT(pn)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == pn_name) { + param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + if (comp->have_star) { + // comes after a star, so counts as a keyword-only parameter + comp->scope_cur->num_kwonly_args += 1; + } else { + // comes before a star, so counts as a positional parameter + comp->scope_cur->num_pos_args += 1; + } + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == pn_star) { + if (comp->have_star) { + // more than one star + compile_syntax_error(comp, pn, "invalid syntax"); + return; + } + comp->have_star = true; + param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_STAR_PARAM; + if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { + // bare star + // TODO see http://www.python.org/dev/peps/pep-3102/ + //assert(comp->scope_cur->num_dict_params == 0); + } else if (MP_PARSE_NODE_IS_ID(pns->nodes[0])) { + // named star + comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARARGS; + param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + } else { + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)); // should be + // named star with possible annotation + comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARARGS; + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + } + } else { + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == pn_dbl_star); // should be + param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_DBL_STAR_PARAM; + comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARKEYWORDS; + } + } + + if (param_name != MP_QSTR_NULL) { + bool added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, param_name, &added); + if (!added) { + compile_syntax_error(comp, pn, "name reused for argument"); + return; + } + id_info->kind = ID_INFO_KIND_LOCAL; + id_info->flags = param_flag; + } +} + +STATIC void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) { + compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star); +} + +STATIC void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) { + compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star); +} + +#if MICROPY_EMIT_NATIVE +STATIC void compile_scope_func_annotations(compiler_t *comp, mp_parse_node_t pn) { + if (!MP_PARSE_NODE_IS_STRUCT(pn)) { + // no annotation + return; + } + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_typedargslist_name) { + // named parameter with possible annotation + // fallthrough + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_typedargslist_star) { + if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)) { + // named star with possible annotation + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + // fallthrough + } else { + // no annotation + return; + } + } else { + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_typedargslist_dbl_star); + // double star with possible annotation + // fallthrough + } + + mp_parse_node_t pn_annotation = pns->nodes[1]; + + if (!MP_PARSE_NODE_IS_NULL(pn_annotation)) { + qstr param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); + id_info_t *id_info = scope_find(comp->scope_cur, param_name); + assert(id_info != NULL); + + if (MP_PARSE_NODE_IS_ID(pn_annotation)) { + qstr arg_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); + EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_ARG, id_info->local_num, arg_type); + } else { + compile_syntax_error(comp, pn_annotation, "parameter annotation must be an identifier"); + } + } +} +#endif // MICROPY_EMIT_NATIVE + +STATIC void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) { + uint l_top = comp_next_label(comp); + uint l_end = comp_next_label(comp); + EMIT_ARG(label_assign, l_top); + EMIT_ARG(for_iter, l_end); + c_assign(comp, pns_comp_for->nodes[0], ASSIGN_STORE); + mp_parse_node_t pn_iter = pns_comp_for->nodes[2]; + + tail_recursion: + if (MP_PARSE_NODE_IS_NULL(pn_iter)) { + // no more nested if/for; compile inner expression + compile_node(comp, pn_inner_expr); + if (comp->scope_cur->kind == SCOPE_GEN_EXPR) { + EMIT(yield_value); + EMIT(pop_top); + } else { + EMIT_ARG(store_comp, comp->scope_cur->kind, 4 * for_depth + 5); + } + } else if (MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_if) { + // if condition + mp_parse_node_struct_t *pns_comp_if = (mp_parse_node_struct_t*)pn_iter; + c_if_cond(comp, pns_comp_if->nodes[0], false, l_top); + pn_iter = pns_comp_if->nodes[1]; + goto tail_recursion; + } else { + assert(MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_for); // should be + // for loop + mp_parse_node_struct_t *pns_comp_for2 = (mp_parse_node_struct_t*)pn_iter; + compile_node(comp, pns_comp_for2->nodes[1]); + EMIT_ARG(get_iter, true); + compile_scope_comp_iter(comp, pns_comp_for2, pn_inner_expr, for_depth + 1); + } + + EMIT_ARG(jump, l_top); + EMIT_ARG(label_assign, l_end); + EMIT(for_iter_end); +} + +STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) { +#if MICROPY_ENABLE_DOC_STRING + // see http://www.python.org/dev/peps/pep-0257/ + + // look for the first statement + if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) { + // a statement; fall through + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_file_input_2)) { + // file input; find the first non-newline node + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + for (int i = 0; i < num_nodes; i++) { + pn = pns->nodes[i]; + if (!(MP_PARSE_NODE_IS_LEAF(pn) && MP_PARSE_NODE_LEAF_KIND(pn) == MP_PARSE_NODE_TOKEN && MP_PARSE_NODE_LEAF_ARG(pn) == MP_TOKEN_NEWLINE)) { + // not a newline, so this is the first statement; finish search + break; + } + } + // if we didn't find a non-newline then it's okay to fall through; pn will be a newline and so doc-string test below will fail gracefully + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_suite_block_stmts)) { + // a list of statements; get the first one + pn = ((mp_parse_node_struct_t*)pn)->nodes[0]; + } else { + return; + } + + // check the first statement for a doc string + if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0]) + && MP_PARSE_NODE_LEAF_KIND(pns->nodes[0]) == MP_PARSE_NODE_STRING) + || (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_const_object) + && MP_OBJ_IS_STR(get_const_object((mp_parse_node_struct_t*)pns->nodes[0])))) { + // compile the doc string + compile_node(comp, pns->nodes[0]); + // store the doc string + compile_store_id(comp, MP_QSTR___doc__); + } + } +#else + (void)comp; + (void)pn; +#endif +} + +STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { + comp->pass = pass; + comp->scope_cur = scope; + comp->next_label = 0; + EMIT_ARG(start_pass, pass, scope); + + if (comp->pass == MP_PASS_SCOPE) { + // reset maximum stack sizes in scope + // they will be computed in this first pass + scope->stack_size = 0; + scope->exc_stack_size = 0; + } + + // compile + if (MP_PARSE_NODE_IS_STRUCT_KIND(scope->pn, PN_eval_input)) { + assert(scope->kind == SCOPE_MODULE); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + compile_node(comp, pns->nodes[0]); // compile the expression + EMIT(return_value); + } else if (scope->kind == SCOPE_MODULE) { + if (!comp->is_repl) { + check_for_doc_string(comp, scope->pn); + } + compile_node(comp, scope->pn); + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT(return_value); + } else if (scope->kind == SCOPE_FUNCTION) { + assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef); + + // work out number of parameters, keywords and default parameters, and add them to the id_info array + // must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc) + if (comp->pass == MP_PASS_SCOPE) { + comp->have_star = false; + apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param); + } + #if MICROPY_EMIT_NATIVE + else if (scope->emit_options == MP_EMIT_OPT_VIPER) { + // compile annotations; only needed on latter compiler passes + // only needed for viper emitter + + // argument annotations + apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_annotations); + + // pns->nodes[2] is return/whole function annotation + mp_parse_node_t pn_annotation = pns->nodes[2]; + if (!MP_PARSE_NODE_IS_NULL(pn_annotation)) { + // nodes[2] can be null or a test-expr + if (MP_PARSE_NODE_IS_ID(pn_annotation)) { + qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); + EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_RETURN, 0, ret_type); + } else { + compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier"); + } + } + } + #endif // MICROPY_EMIT_NATIVE + + compile_node(comp, pns->nodes[3]); // 3 is function body + // emit return if it wasn't the last opcode + if (!EMIT(last_emit_was_return_value)) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + EMIT(return_value); + } + } else if (scope->kind == SCOPE_LAMBDA) { + assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3); + + // work out number of parameters, keywords and default parameters, and add them to the id_info array + // must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc) + if (comp->pass == MP_PASS_SCOPE) { + comp->have_star = false; + apply_to_single_or_list(comp, pns->nodes[0], PN_varargslist, compile_scope_lambda_param); + } + + compile_node(comp, pns->nodes[1]); // 1 is lambda body + + // if the lambda is a generator, then we return None, not the result of the expression of the lambda + if (scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) { + EMIT(pop_top); + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + } + EMIT(return_value); + } else if (scope->kind == SCOPE_LIST_COMP || scope->kind == SCOPE_DICT_COMP || scope->kind == SCOPE_SET_COMP || scope->kind == SCOPE_GEN_EXPR) { + // a bit of a hack at the moment + + assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2); + assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)); + mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; + + // We need a unique name for the comprehension argument (the iterator). + // CPython uses .0, but we should be able to use anything that won't + // clash with a user defined variable. Best to use an existing qstr, + // so we use the blank qstr. + qstr qstr_arg = MP_QSTR_; + if (comp->pass == MP_PASS_SCOPE) { + bool added; + id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qstr_arg, &added); + assert(added); + id_info->kind = ID_INFO_KIND_LOCAL; + scope->num_pos_args = 1; + } + + if (scope->kind == SCOPE_LIST_COMP) { + EMIT_ARG(build_list, 0); + } else if (scope->kind == SCOPE_DICT_COMP) { + EMIT_ARG(build_map, 0); + #if MICROPY_PY_BUILTINS_SET + } else if (scope->kind == SCOPE_SET_COMP) { + EMIT_ARG(build_set, 0); + #endif + } + + // There are 4 slots on the stack for the iterator, and the first one is + // NULL to indicate that the second one points to the iterator object. + if (scope->kind == SCOPE_GEN_EXPR) { + // TODO static assert that MP_OBJ_ITER_BUF_NSLOTS == 4 + EMIT(load_null); + compile_load_id(comp, qstr_arg); + EMIT(load_null); + EMIT(load_null); + } else { + compile_load_id(comp, qstr_arg); + EMIT_ARG(get_iter, true); + } + + compile_scope_comp_iter(comp, pns_comp_for, pns->nodes[0], 0); + + if (scope->kind == SCOPE_GEN_EXPR) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + } + EMIT(return_value); + } else { + assert(scope->kind == SCOPE_CLASS); + assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_classdef); + + if (comp->pass == MP_PASS_SCOPE) { + bool added; + id_info_t *id_info = scope_find_or_add_id(scope, MP_QSTR___class__, &added); + assert(added); + id_info->kind = ID_INFO_KIND_LOCAL; + } + + compile_load_id(comp, MP_QSTR___name__); + compile_store_id(comp, MP_QSTR___module__); + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // 0 is class name + compile_store_id(comp, MP_QSTR___qualname__); + + check_for_doc_string(comp, pns->nodes[2]); + compile_node(comp, pns->nodes[2]); // 2 is class body + + id_info_t *id = scope_find(scope, MP_QSTR___class__); + assert(id != NULL); + if (id->kind == ID_INFO_KIND_LOCAL) { + EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); + } else { + EMIT_LOAD_FAST(MP_QSTR___class__, id->local_num); + } + EMIT(return_value); + } + + EMIT(end_pass); + + // make sure we match all the exception levels + assert(comp->cur_except_level == 0); +} + +#if MICROPY_EMIT_INLINE_ASM +// requires 3 passes: SCOPE, CODE_SIZE, EMIT +STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) { + comp->pass = pass; + comp->scope_cur = scope; + comp->next_label = 0; + + if (scope->kind != SCOPE_FUNCTION) { + compile_syntax_error(comp, MP_PARSE_NODE_NULL, "inline assembler must be a function"); + return; + } + + if (comp->pass > MP_PASS_SCOPE) { + EMIT_INLINE_ASM_ARG(start_pass, comp->pass, &comp->compile_error); + } + + // get the function definition parse node + assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; + assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef); + + //qstr f_id = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); // function name + + // parameters are in pns->nodes[1] + if (comp->pass == MP_PASS_CODE_SIZE) { + mp_parse_node_t *pn_params; + int n_params = mp_parse_node_extract_list(&pns->nodes[1], PN_typedargslist, &pn_params); + scope->num_pos_args = EMIT_INLINE_ASM_ARG(count_params, n_params, pn_params); + if (comp->compile_error != MP_OBJ_NULL) { + goto inline_asm_error; + } + } + + // pns->nodes[2] is function return annotation + mp_uint_t type_sig = MP_NATIVE_TYPE_INT; + mp_parse_node_t pn_annotation = pns->nodes[2]; + if (!MP_PARSE_NODE_IS_NULL(pn_annotation)) { + // nodes[2] can be null or a test-expr + if (MP_PARSE_NODE_IS_ID(pn_annotation)) { + qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); + switch (ret_type) { + case MP_QSTR_object: type_sig = MP_NATIVE_TYPE_OBJ; break; + case MP_QSTR_bool: type_sig = MP_NATIVE_TYPE_BOOL; break; + case MP_QSTR_int: type_sig = MP_NATIVE_TYPE_INT; break; + case MP_QSTR_uint: type_sig = MP_NATIVE_TYPE_UINT; break; + default: compile_syntax_error(comp, pn_annotation, "unknown type"); return; + } + } else { + compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier"); + } + } + + mp_parse_node_t pn_body = pns->nodes[3]; // body + mp_parse_node_t *nodes; + int num = mp_parse_node_extract_list(&pn_body, PN_suite_block_stmts, &nodes); + + for (int i = 0; i < num; i++) { + assert(MP_PARSE_NODE_IS_STRUCT(nodes[i])); + mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)nodes[i]; + if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_pass_stmt) { + // no instructions + continue; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) != PN_expr_stmt) { + // not an instruction; error + not_an_instruction: + compile_syntax_error(comp, nodes[i], "expecting an assembler instruction"); + return; + } + + // check structure of parse node + assert(MP_PARSE_NODE_IS_STRUCT(pns2->nodes[0])); + if (!MP_PARSE_NODE_IS_NULL(pns2->nodes[1])) { + goto not_an_instruction; + } + pns2 = (mp_parse_node_struct_t*)pns2->nodes[0]; + if (MP_PARSE_NODE_STRUCT_KIND(pns2) != PN_atom_expr_normal) { + goto not_an_instruction; + } + if (!MP_PARSE_NODE_IS_ID(pns2->nodes[0])) { + goto not_an_instruction; + } + if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns2->nodes[1], PN_trailer_paren)) { + goto not_an_instruction; + } + + // parse node looks like an instruction + // get instruction name and args + qstr op = MP_PARSE_NODE_LEAF_ARG(pns2->nodes[0]); + pns2 = (mp_parse_node_struct_t*)pns2->nodes[1]; // PN_trailer_paren + mp_parse_node_t *pn_arg; + int n_args = mp_parse_node_extract_list(&pns2->nodes[0], PN_arglist, &pn_arg); + + // emit instructions + if (op == MP_QSTR_label) { + if (!(n_args == 1 && MP_PARSE_NODE_IS_ID(pn_arg[0]))) { + compile_syntax_error(comp, nodes[i], "'label' requires 1 argument"); + return; + } + uint lab = comp_next_label(comp); + if (pass > MP_PASS_SCOPE) { + if (!EMIT_INLINE_ASM_ARG(label, lab, MP_PARSE_NODE_LEAF_ARG(pn_arg[0]))) { + compile_syntax_error(comp, nodes[i], "label redefined"); + return; + } + } + } else if (op == MP_QSTR_align) { + if (!(n_args == 1 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) { + compile_syntax_error(comp, nodes[i], "'align' requires 1 argument"); + return; + } + if (pass > MP_PASS_SCOPE) { + mp_asm_base_align((mp_asm_base_t*)comp->emit_inline_asm, + MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0])); + } + } else if (op == MP_QSTR_data) { + if (!(n_args >= 2 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) { + compile_syntax_error(comp, nodes[i], "'data' requires at least 2 arguments"); + return; + } + if (pass > MP_PASS_SCOPE) { + mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]); + for (uint j = 1; j < n_args; j++) { + if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) { + compile_syntax_error(comp, nodes[i], "'data' requires integer arguments"); + return; + } + mp_asm_base_data((mp_asm_base_t*)comp->emit_inline_asm, + bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j])); + } + } + } else { + if (pass > MP_PASS_SCOPE) { + EMIT_INLINE_ASM_ARG(op, op, n_args, pn_arg); + } + } + + if (comp->compile_error != MP_OBJ_NULL) { + pns = pns2; // this is the parse node that had the error + goto inline_asm_error; + } + } + + if (comp->pass > MP_PASS_SCOPE) { + EMIT_INLINE_ASM_ARG(end_pass, type_sig); + + if (comp->pass == MP_PASS_EMIT) { + void *f = mp_asm_base_get_code((mp_asm_base_t*)comp->emit_inline_asm); + mp_emit_glue_assign_native(comp->scope_cur->raw_code, MP_CODE_NATIVE_ASM, + f, mp_asm_base_get_code_size((mp_asm_base_t*)comp->emit_inline_asm), + NULL, comp->scope_cur->num_pos_args, 0, type_sig); + } + } + + if (comp->compile_error != MP_OBJ_NULL) { + // inline assembler had an error; set line for its exception + inline_asm_error: + comp->compile_error_line = pns->source_line; + } +} +#endif + +STATIC void scope_compute_things(scope_t *scope) { + // in MicroPython we put the *x parameter after all other parameters (except **y) + if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) { + id_info_t *id_param = NULL; + for (int i = scope->id_info_len - 1; i >= 0; i--) { + id_info_t *id = &scope->id_info[i]; + if (id->flags & ID_FLAG_IS_STAR_PARAM) { + if (id_param != NULL) { + // swap star param with last param + id_info_t temp = *id_param; *id_param = *id; *id = temp; + } + break; + } else if (id_param == NULL && id->flags == ID_FLAG_IS_PARAM) { + id_param = id; + } + } + } + + // in functions, turn implicit globals into explicit globals + // compute the index of each local + scope->num_locals = 0; + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (scope->kind == SCOPE_CLASS && id->qst == MP_QSTR___class__) { + // __class__ is not counted as a local; if it's used then it becomes a ID_INFO_KIND_CELL + continue; + } + if (SCOPE_IS_FUNC_LIKE(scope->kind) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; + } + // params always count for 1 local, even if they are a cell + if (id->kind == ID_INFO_KIND_LOCAL || (id->flags & ID_FLAG_IS_PARAM)) { + id->local_num = scope->num_locals++; + } + } + + // compute the index of cell vars + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + // in MicroPython the cells come right after the fast locals + // parameters are not counted here, since they remain at the start + // of the locals, even if they are cell vars + if (id->kind == ID_INFO_KIND_CELL && !(id->flags & ID_FLAG_IS_PARAM)) { + id->local_num = scope->num_locals; + scope->num_locals += 1; + } + } + + // compute the index of free vars + // make sure they are in the order of the parent scope + if (scope->parent != NULL) { + int num_free = 0; + for (int i = 0; i < scope->parent->id_info_len; i++) { + id_info_t *id = &scope->parent->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { + for (int j = 0; j < scope->id_info_len; j++) { + id_info_t *id2 = &scope->id_info[j]; + if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { + assert(!(id2->flags & ID_FLAG_IS_PARAM)); // free vars should not be params + // in MicroPython the frees come first, before the params + id2->local_num = num_free; + num_free += 1; + } + } + } + } + // in MicroPython shift all other locals after the free locals + if (num_free > 0) { + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (id->kind != ID_INFO_KIND_FREE || (id->flags & ID_FLAG_IS_PARAM)) { + id->local_num += num_free; + } + } + scope->num_pos_args += num_free; // free vars are counted as params for passing them into the function + scope->num_locals += num_free; + } + } +} + +#if !MICROPY_PERSISTENT_CODE_SAVE +STATIC +#endif +mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl) { + // put compiler state on the stack, it's relatively small + compiler_t comp_state = {0}; + compiler_t *comp = &comp_state; + + comp->source_file = source_file; + comp->is_repl = is_repl; + comp->break_label = INVALID_LABEL; + comp->continue_label = INVALID_LABEL; + + // create the module scope + scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, parse_tree->root, emit_opt); + + // create standard emitter; it's used at least for MP_PASS_SCOPE + emit_t *emit_bc = emit_bc_new(); + + // compile pass 1 + comp->emit = emit_bc; + #if MICROPY_EMIT_NATIVE + comp->emit_method_table = &emit_bc_method_table; + #endif + uint max_num_labels = 0; + for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) { + if (false) { + #if MICROPY_EMIT_INLINE_ASM + } else if (s->emit_options == MP_EMIT_OPT_ASM) { + compile_scope_inline_asm(comp, s, MP_PASS_SCOPE); + #endif + } else { + compile_scope(comp, s, MP_PASS_SCOPE); + } + + // update maximim number of labels needed + if (comp->next_label > max_num_labels) { + max_num_labels = comp->next_label; + } + } + + // compute some things related to scope and identifiers + for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) { + scope_compute_things(s); + } + + // set max number of labels now that it's calculated + emit_bc_set_max_num_labels(emit_bc, max_num_labels); + + // compile pass 2 and 3 +#if MICROPY_EMIT_NATIVE + emit_t *emit_native = NULL; +#endif + for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) { + if (false) { + // dummy + + #if MICROPY_EMIT_INLINE_ASM + } else if (s->emit_options == MP_EMIT_OPT_ASM) { + // inline assembly + if (comp->emit_inline_asm == NULL) { + comp->emit_inline_asm = ASM_EMITTER(new)(max_num_labels); + } + comp->emit = NULL; + comp->emit_inline_asm_method_table = &ASM_EMITTER(method_table); + compile_scope_inline_asm(comp, s, MP_PASS_CODE_SIZE); + #if MICROPY_EMIT_INLINE_XTENSA + // Xtensa requires an extra pass to compute size of l32r const table + // TODO this can be improved by calculating it during SCOPE pass + // but that requires some other structural changes to the asm emitters + compile_scope_inline_asm(comp, s, MP_PASS_CODE_SIZE); + #endif + if (comp->compile_error == MP_OBJ_NULL) { + compile_scope_inline_asm(comp, s, MP_PASS_EMIT); + } + #endif + + } else { + + // choose the emit type + + switch (s->emit_options) { + +#if MICROPY_EMIT_NATIVE + case MP_EMIT_OPT_NATIVE_PYTHON: + case MP_EMIT_OPT_VIPER: + if (emit_native == NULL) { + emit_native = NATIVE_EMITTER(new)(&comp->compile_error, max_num_labels); + } + comp->emit_method_table = &NATIVE_EMITTER(method_table); + comp->emit = emit_native; + EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_ENABLE, s->emit_options == MP_EMIT_OPT_VIPER, 0); + break; +#endif // MICROPY_EMIT_NATIVE + + default: + comp->emit = emit_bc; + #if MICROPY_EMIT_NATIVE + comp->emit_method_table = &emit_bc_method_table; + #endif + break; + } + + // need a pass to compute stack size + compile_scope(comp, s, MP_PASS_STACK_SIZE); + + // second last pass: compute code size + if (comp->compile_error == MP_OBJ_NULL) { + compile_scope(comp, s, MP_PASS_CODE_SIZE); + } + + // final pass: emit code + if (comp->compile_error == MP_OBJ_NULL) { + compile_scope(comp, s, MP_PASS_EMIT); + } + } + } + + if (comp->compile_error != MP_OBJ_NULL) { + // if there is no line number for the error then use the line + // number for the start of this scope + compile_error_set_line(comp, comp->scope_cur->pn); + // add a traceback to the exception using relevant source info + mp_obj_exception_add_traceback(comp->compile_error, comp->source_file, + comp->compile_error_line, comp->scope_cur->simple_name); + } + + // free the emitters + + emit_bc_free(emit_bc); +#if MICROPY_EMIT_NATIVE + if (emit_native != NULL) { + NATIVE_EMITTER(free)(emit_native); + } +#endif + #if MICROPY_EMIT_INLINE_ASM + if (comp->emit_inline_asm != NULL) { + ASM_EMITTER(free)(comp->emit_inline_asm); + } + #endif + + // free the parse tree + mp_parse_tree_clear(parse_tree); + + // free the scopes + mp_raw_code_t *outer_raw_code = module_scope->raw_code; + for (scope_t *s = module_scope; s;) { + scope_t *next = s->next; + scope_free(s); + s = next; + } + + if (comp->compile_error != MP_OBJ_NULL) { + nlr_raise(comp->compile_error); + } else { + return outer_raw_code; + } +} + +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl) { + mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl); + // return function that executes the outer module + return mp_make_function_from_raw_code(rc, MP_OBJ_NULL, MP_OBJ_NULL); +} + +#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/compile.h b/user/mpy/py/compile.h new file mode 100644 index 0000000..3297e83 --- /dev/null +++ b/user/mpy/py/compile.h @@ -0,0 +1,54 @@ +/* + * 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_COMPILE_H +#define MICROPY_INCLUDED_PY_COMPILE_H + +#include "py/lexer.h" +#include "py/parse.h" +#include "py/emitglue.h" + +// These must fit in 8 bits; see scope.h +enum { + MP_EMIT_OPT_NONE, + MP_EMIT_OPT_BYTECODE, + MP_EMIT_OPT_NATIVE_PYTHON, + MP_EMIT_OPT_VIPER, + MP_EMIT_OPT_ASM, +}; + +// the compiler will raise an exception if an error occurred +// the compiler will clear the parse tree before it returns +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl); + +#if MICROPY_PERSISTENT_CODE_SAVE +// this has the same semantics as mp_compile +mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl); +#endif + +// this is implemented in runtime.c +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); + +#endif // MICROPY_INCLUDED_PY_COMPILE_H diff --git a/user/mpy/py/emit.h b/user/mpy/py/emit.h new file mode 100644 index 0000000..2b2c904 --- /dev/null +++ b/user/mpy/py/emit.h @@ -0,0 +1,286 @@ +/* + * 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_EMIT_H +#define MICROPY_INCLUDED_PY_EMIT_H + +#include "py/lexer.h" +#include "py/scope.h" +#include "py/runtime0.h" + +/* Notes on passes: + * We don't know exactly the opcodes in pass 1 because they depend on the + * closing over of variables (LOAD_CLOSURE, BUILD_TUPLE, MAKE_CLOSURE), which + * depends on determining the scope of variables in each function, and this + * is not known until the end of pass 1. + * As a consequence, we don't know the maximum stack size until the end of pass 2. + * This is problematic for some emitters (x64) since they need to know the maximum + * stack size to compile the entry to the function, and this affects code size. + */ + +typedef enum { + MP_PASS_SCOPE = 1, // work out id's and their kind, and number of labels + MP_PASS_STACK_SIZE = 2, // work out maximum stack size + MP_PASS_CODE_SIZE = 3, // work out code size and label offsets + MP_PASS_EMIT = 4, // emit code +} pass_kind_t; + +#define MP_EMIT_STAR_FLAG_SINGLE (0x01) +#define MP_EMIT_STAR_FLAG_DOUBLE (0x02) + +#define MP_EMIT_BREAK_FROM_FOR (0x8000) + +#define MP_EMIT_NATIVE_TYPE_ENABLE (0) +#define MP_EMIT_NATIVE_TYPE_RETURN (1) +#define MP_EMIT_NATIVE_TYPE_ARG (2) + +typedef struct _emit_t emit_t; + +typedef struct _mp_emit_method_table_id_ops_t { + void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); + void (*name)(emit_t *emit, qstr qst); + void (*global)(emit_t *emit, qstr qst); +} mp_emit_method_table_id_ops_t; + +typedef struct _emit_method_table_t { + void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); + void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); + void (*end_pass)(emit_t *emit); + bool (*last_emit_was_return_value)(emit_t *emit); + void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); + void (*set_source_line)(emit_t *emit, mp_uint_t line); + + mp_emit_method_table_id_ops_t load_id; + mp_emit_method_table_id_ops_t store_id; + mp_emit_method_table_id_ops_t delete_id; + + void (*label_assign)(emit_t *emit, mp_uint_t l); + void (*import_name)(emit_t *emit, qstr qst); + void (*import_from)(emit_t *emit, qstr qst); + void (*import_star)(emit_t *emit); + void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); + void (*load_const_small_int)(emit_t *emit, mp_int_t arg); + void (*load_const_str)(emit_t *emit, qstr qst); + void (*load_const_obj)(emit_t *emit, mp_obj_t obj); + void (*load_null)(emit_t *emit); + void (*load_attr)(emit_t *emit, qstr qst); + void (*load_method)(emit_t *emit, qstr qst, bool is_super); + void (*load_build_class)(emit_t *emit); + void (*load_subscr)(emit_t *emit); + void (*store_attr)(emit_t *emit, qstr qst); + void (*store_subscr)(emit_t *emit); + void (*delete_attr)(emit_t *emit, qstr qst); + void (*delete_subscr)(emit_t *emit); + void (*dup_top)(emit_t *emit); + void (*dup_top_two)(emit_t *emit); + void (*pop_top)(emit_t *emit); + void (*rot_two)(emit_t *emit); + void (*rot_three)(emit_t *emit); + void (*jump)(emit_t *emit, mp_uint_t label); + void (*pop_jump_if)(emit_t *emit, bool cond, mp_uint_t label); + void (*jump_if_or_pop)(emit_t *emit, bool cond, mp_uint_t label); + void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); + void (*setup_with)(emit_t *emit, mp_uint_t label); + void (*with_cleanup)(emit_t *emit, mp_uint_t label); + void (*setup_except)(emit_t *emit, mp_uint_t label); + void (*setup_finally)(emit_t *emit, mp_uint_t label); + void (*end_finally)(emit_t *emit); + void (*get_iter)(emit_t *emit, bool use_stack); + void (*for_iter)(emit_t *emit, mp_uint_t label); + void (*for_iter_end)(emit_t *emit); + void (*pop_block)(emit_t *emit); + void (*pop_except)(emit_t *emit); + void (*unary_op)(emit_t *emit, mp_unary_op_t op); + void (*binary_op)(emit_t *emit, mp_binary_op_t op); + void (*build_tuple)(emit_t *emit, mp_uint_t n_args); + void (*build_list)(emit_t *emit, mp_uint_t n_args); + void (*build_map)(emit_t *emit, mp_uint_t n_args); + void (*store_map)(emit_t *emit); + #if MICROPY_PY_BUILTINS_SET + void (*build_set)(emit_t *emit, mp_uint_t n_args); + #endif + #if MICROPY_PY_BUILTINS_SLICE + void (*build_slice)(emit_t *emit, mp_uint_t n_args); + #endif + void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); + void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); + void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); + void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); + void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); + void (*return_value)(emit_t *emit); + void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); + void (*yield_value)(emit_t *emit); + void (*yield_from)(emit_t *emit); + + // these methods are used to control entry to/exit from an exception handler + // they may or may not emit code + void (*start_except_handler)(emit_t *emit); + void (*end_except_handler)(emit_t *emit); +} emit_method_table_t; + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); + +extern const emit_method_table_t emit_bc_method_table; +extern const emit_method_table_t emit_native_x64_method_table; +extern const emit_method_table_t emit_native_x86_method_table; +extern const emit_method_table_t emit_native_thumb_method_table; +extern const emit_method_table_t emit_native_arm_method_table; +extern const emit_method_table_t emit_native_xtensa_method_table; + +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; +extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; + +emit_t *emit_bc_new(void); +emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); +emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); + +void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); + +void emit_bc_free(emit_t *emit); +void emit_native_x64_free(emit_t *emit); +void emit_native_x86_free(emit_t *emit); +void emit_native_thumb_free(emit_t *emit); +void emit_native_arm_free(emit_t *emit); +void emit_native_xtensa_free(emit_t *emit); + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); +void mp_emit_bc_end_pass(emit_t *emit); +bool mp_emit_bc_last_emit_was_return_value(emit_t *emit); +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_load_name(emit_t *emit, qstr qst); +void mp_emit_bc_load_global(emit_t *emit, qstr qst); +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_store_name(emit_t *emit, qstr qst); +void mp_emit_bc_store_global(emit_t *emit, qstr qst); +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); +void mp_emit_bc_delete_name(emit_t *emit, qstr qst); +void mp_emit_bc_delete_global(emit_t *emit, qstr qst); + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); +void mp_emit_bc_import_name(emit_t *emit, qstr qst); +void mp_emit_bc_import_from(emit_t *emit, qstr qst); +void mp_emit_bc_import_star(emit_t *emit); +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); +void mp_emit_bc_load_null(emit_t *emit); +void mp_emit_bc_load_attr(emit_t *emit, qstr qst); +void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super); +void mp_emit_bc_load_build_class(emit_t *emit); +void mp_emit_bc_load_subscr(emit_t *emit); +void mp_emit_bc_store_attr(emit_t *emit, qstr qst); +void mp_emit_bc_store_subscr(emit_t *emit); +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); +void mp_emit_bc_delete_subscr(emit_t *emit); +void mp_emit_bc_dup_top(emit_t *emit); +void mp_emit_bc_dup_top_two(emit_t *emit); +void mp_emit_bc_pop_top(emit_t *emit); +void mp_emit_bc_rot_two(emit_t *emit); +void mp_emit_bc_rot_three(emit_t *emit); +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); +void mp_emit_bc_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label); +void mp_emit_bc_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label); +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); +#define mp_emit_bc_break_loop mp_emit_bc_unwind_jump +#define mp_emit_bc_continue_loop mp_emit_bc_unwind_jump +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); +void mp_emit_bc_end_finally(emit_t *emit); +void mp_emit_bc_get_iter(emit_t *emit, bool use_stack); +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); +void mp_emit_bc_for_iter_end(emit_t *emit); +void mp_emit_bc_pop_block(emit_t *emit); +void mp_emit_bc_pop_except(emit_t *emit); +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_store_map(emit_t *emit); +#if MICROPY_PY_BUILTINS_SET +void mp_emit_bc_build_set(emit_t *emit, mp_uint_t n_args); +#endif +#if MICROPY_PY_BUILTINS_SLICE +void mp_emit_bc_build_slice(emit_t *emit, mp_uint_t n_args); +#endif +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); +void mp_emit_bc_return_value(emit_t *emit); +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); +void mp_emit_bc_yield_value(emit_t *emit); +void mp_emit_bc_yield_from(emit_t *emit); +void mp_emit_bc_start_except_handler(emit_t *emit); +void mp_emit_bc_end_except_handler(emit_t *emit); + +typedef struct _emit_inline_asm_t emit_inline_asm_t; + +typedef struct _emit_inline_asm_method_table_t { + void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); + void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); + mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); + bool (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); + void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); +} emit_inline_asm_method_table_t; + +extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; +extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); + +void emit_inline_thumb_free(emit_inline_asm_t *emit); +void emit_inline_xtensa_free(emit_inline_asm_t *emit); + +#if MICROPY_WARNINGS +void mp_emitter_warning(pass_kind_t pass, const char *msg); +#else +#define mp_emitter_warning(pass, msg) +#endif + +#endif // MICROPY_INCLUDED_PY_EMIT_H diff --git a/user/mpy/py/emitbc.c b/user/mpy/py/emitbc.c new file mode 100644 index 0000000..6770209 --- /dev/null +++ b/user/mpy/py/emitbc.c @@ -0,0 +1,1076 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +#include "py/mpstate.h" +#include "py/emit.h" +#include "py/bc0.h" + +#if MICROPY_ENABLE_COMPILER + +#define BYTES_FOR_INT ((BYTES_PER_WORD * 8 + 6) / 7) +#define DUMMY_DATA_SIZE (BYTES_FOR_INT) + +struct _emit_t { + // Accessed as mp_obj_t, so must be aligned as such, and we rely on the + // memory allocator returning a suitably aligned pointer. + // Should work for cases when mp_obj_t is 64-bit on a 32-bit machine. + byte dummy_data[DUMMY_DATA_SIZE]; + + pass_kind_t pass : 8; + mp_uint_t last_emit_was_return_value : 8; + + int stack_size; + + scope_t *scope; + + mp_uint_t last_source_line_offset; + mp_uint_t last_source_line; + + mp_uint_t max_num_labels; + mp_uint_t *label_offsets; + + size_t code_info_offset; + size_t code_info_size; + size_t bytecode_offset; + size_t bytecode_size; + byte *code_base; // stores both byte code and code info + + #if MICROPY_PERSISTENT_CODE + uint16_t ct_cur_obj; + uint16_t ct_num_obj; + uint16_t ct_cur_raw_code; + #endif + mp_uint_t *const_table; +}; + +emit_t *emit_bc_new(void) { + emit_t *emit = m_new0(emit_t, 1); + return emit; +} + +void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels) { + emit->max_num_labels = max_num_labels; + emit->label_offsets = m_new(mp_uint_t, emit->max_num_labels); +} + +void emit_bc_free(emit_t *emit) { + m_del(mp_uint_t, emit->label_offsets, emit->max_num_labels); + m_del_obj(emit_t, emit); +} + +typedef byte *(*emit_allocator_t)(emit_t *emit, int nbytes); + +STATIC void emit_write_uint(emit_t *emit, emit_allocator_t allocator, mp_uint_t val) { + // We store each 7 bits in a separate byte, and that's how many bytes needed + byte buf[BYTES_FOR_INT]; + byte *p = buf + sizeof(buf); + // We encode in little-ending order, but store in big-endian, to help decoding + do { + *--p = val & 0x7f; + val >>= 7; + } while (val != 0); + byte *c = allocator(emit, buf + sizeof(buf) - p); + while (p != buf + sizeof(buf) - 1) { + *c++ = *p++ | 0x80; + } + *c = *p; +} + +// all functions must go through this one to emit code info +STATIC byte *emit_get_cur_to_write_code_info(emit_t *emit, int num_bytes_to_write) { + //printf("emit %d\n", num_bytes_to_write); + if (emit->pass < MP_PASS_EMIT) { + emit->code_info_offset += num_bytes_to_write; + return emit->dummy_data; + } else { + assert(emit->code_info_offset + num_bytes_to_write <= emit->code_info_size); + byte *c = emit->code_base + emit->code_info_offset; + emit->code_info_offset += num_bytes_to_write; + return c; + } +} + +STATIC void emit_write_code_info_byte(emit_t* emit, byte val) { + *emit_get_cur_to_write_code_info(emit, 1) = val; +} + +STATIC void emit_write_code_info_uint(emit_t* emit, mp_uint_t val) { + emit_write_uint(emit, emit_get_cur_to_write_code_info, val); +} + +STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) { + #if MICROPY_PERSISTENT_CODE + assert((qst >> 16) == 0); + byte *c = emit_get_cur_to_write_code_info(emit, 2); + c[0] = qst; + c[1] = qst >> 8; + #else + emit_write_uint(emit, emit_get_cur_to_write_code_info, qst); + #endif +} + +#if MICROPY_ENABLE_SOURCE_LINE +STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) { + assert(bytes_to_skip > 0 || lines_to_skip > 0); + //printf(" %d %d\n", bytes_to_skip, lines_to_skip); + while (bytes_to_skip > 0 || lines_to_skip > 0) { + mp_uint_t b, l; + if (lines_to_skip <= 6 || bytes_to_skip > 0xf) { + // use 0b0LLBBBBB encoding + b = MIN(bytes_to_skip, 0x1f); + if (b < bytes_to_skip) { + // we can't skip any lines until we skip all the bytes + l = 0; + } else { + l = MIN(lines_to_skip, 0x3); + } + *emit_get_cur_to_write_code_info(emit, 1) = b | (l << 5); + } else { + // use 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) + b = MIN(bytes_to_skip, 0xf); + l = MIN(lines_to_skip, 0x7ff); + byte *ci = emit_get_cur_to_write_code_info(emit, 2); + ci[0] = 0x80 | b | ((l >> 4) & 0x70); + ci[1] = l; + } + bytes_to_skip -= b; + lines_to_skip -= l; + } +} +#endif + +// all functions must go through this one to emit byte code +STATIC byte *emit_get_cur_to_write_bytecode(emit_t *emit, int num_bytes_to_write) { + //printf("emit %d\n", num_bytes_to_write); + if (emit->pass < MP_PASS_EMIT) { + emit->bytecode_offset += num_bytes_to_write; + return emit->dummy_data; + } else { + assert(emit->bytecode_offset + num_bytes_to_write <= emit->bytecode_size); + byte *c = emit->code_base + emit->code_info_size + emit->bytecode_offset; + emit->bytecode_offset += num_bytes_to_write; + return c; + } +} + +STATIC void emit_write_bytecode_byte(emit_t *emit, byte b1) { + byte *c = emit_get_cur_to_write_bytecode(emit, 1); + c[0] = b1; +} + +STATIC void emit_write_bytecode_byte_byte(emit_t* emit, byte b1, byte b2) { + byte *c = emit_get_cur_to_write_bytecode(emit, 2); + c[0] = b1; + c[1] = b2; +} + +// Similar to emit_write_bytecode_uint(), just some extra handling to encode sign +STATIC void emit_write_bytecode_byte_int(emit_t *emit, byte b1, mp_int_t num) { + emit_write_bytecode_byte(emit, b1); + + // We store each 7 bits in a separate byte, and that's how many bytes needed + byte buf[BYTES_FOR_INT]; + byte *p = buf + sizeof(buf); + // We encode in little-ending order, but store in big-endian, to help decoding + do { + *--p = num & 0x7f; + num >>= 7; + } while (num != 0 && num != -1); + // Make sure that highest bit we stored (mask 0x40) matches sign + // of the number. If not, store extra byte just to encode sign + if (num == -1 && (*p & 0x40) == 0) { + *--p = 0x7f; + } else if (num == 0 && (*p & 0x40) != 0) { + *--p = 0; + } + + byte *c = emit_get_cur_to_write_bytecode(emit, buf + sizeof(buf) - p); + while (p != buf + sizeof(buf) - 1) { + *c++ = *p++ | 0x80; + } + *c = *p; +} + +STATIC void emit_write_bytecode_byte_uint(emit_t *emit, byte b, mp_uint_t val) { + emit_write_bytecode_byte(emit, b); + emit_write_uint(emit, emit_get_cur_to_write_bytecode, val); +} + +#if MICROPY_PERSISTENT_CODE +STATIC void emit_write_bytecode_byte_const(emit_t *emit, byte b, mp_uint_t n, mp_uint_t c) { + if (emit->pass == MP_PASS_EMIT) { + emit->const_table[n] = c; + } + emit_write_bytecode_byte_uint(emit, b, n); +} +#endif + +STATIC void emit_write_bytecode_byte_qstr(emit_t* emit, byte b, qstr qst) { + #if MICROPY_PERSISTENT_CODE + assert((qst >> 16) == 0); + byte *c = emit_get_cur_to_write_bytecode(emit, 3); + c[0] = b; + c[1] = qst; + c[2] = qst >> 8; + #else + emit_write_bytecode_byte_uint(emit, b, qst); + #endif +} + +STATIC void emit_write_bytecode_byte_obj(emit_t *emit, byte b, mp_obj_t obj) { + #if MICROPY_PERSISTENT_CODE + emit_write_bytecode_byte_const(emit, b, + emit->scope->num_pos_args + emit->scope->num_kwonly_args + + emit->ct_cur_obj++, (mp_uint_t)obj); + #else + // aligns the pointer so it is friendly to GC + emit_write_bytecode_byte(emit, b); + emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(mp_obj_t)); + mp_obj_t *c = (mp_obj_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_obj_t)); + // Verify thar c is already uint-aligned + assert(c == MP_ALIGN(c, sizeof(mp_obj_t))); + *c = obj; + #endif +} + +STATIC void emit_write_bytecode_byte_raw_code(emit_t *emit, byte b, mp_raw_code_t *rc) { + #if MICROPY_PERSISTENT_CODE + emit_write_bytecode_byte_const(emit, b, + emit->scope->num_pos_args + emit->scope->num_kwonly_args + + emit->ct_num_obj + emit->ct_cur_raw_code++, (mp_uint_t)(uintptr_t)rc); + #else + // aligns the pointer so it is friendly to GC + emit_write_bytecode_byte(emit, b); + emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(void*)); + void **c = (void**)emit_get_cur_to_write_bytecode(emit, sizeof(void*)); + // Verify thar c is already uint-aligned + assert(c == MP_ALIGN(c, sizeof(void*))); + *c = rc; + #endif +} + +// unsigned labels are relative to ip following this instruction, stored as 16 bits +STATIC void emit_write_bytecode_byte_unsigned_label(emit_t *emit, byte b1, mp_uint_t label) { + mp_uint_t bytecode_offset; + if (emit->pass < MP_PASS_EMIT) { + bytecode_offset = 0; + } else { + bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3; + } + byte *c = emit_get_cur_to_write_bytecode(emit, 3); + c[0] = b1; + c[1] = bytecode_offset; + c[2] = bytecode_offset >> 8; +} + +// signed labels are relative to ip following this instruction, stored as 16 bits, in excess +STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint_t label) { + int bytecode_offset; + if (emit->pass < MP_PASS_EMIT) { + bytecode_offset = 0; + } else { + bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3 + 0x8000; + } + byte *c = emit_get_cur_to_write_bytecode(emit, 3); + c[0] = b1; + c[1] = bytecode_offset; + c[2] = bytecode_offset >> 8; +} + +void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { + emit->pass = pass; + emit->stack_size = 0; + emit->last_emit_was_return_value = false; + emit->scope = scope; + emit->last_source_line_offset = 0; + emit->last_source_line = 1; + if (pass < MP_PASS_EMIT) { + memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(mp_uint_t)); + } + emit->bytecode_offset = 0; + emit->code_info_offset = 0; + + // Write local state size and exception stack size. + { + mp_uint_t n_state = scope->num_locals + scope->stack_size; + if (n_state == 0) { + // Need at least 1 entry in the state, in the case an exception is + // propagated through this function, the exception is returned in + // the highest slot in the state (fastn[0], see vm.c). + n_state = 1; + } + emit_write_code_info_uint(emit, n_state); + emit_write_code_info_uint(emit, scope->exc_stack_size); + } + + // Write scope flags and number of arguments. + // TODO check that num args all fit in a byte + emit_write_code_info_byte(emit, emit->scope->scope_flags); + emit_write_code_info_byte(emit, emit->scope->num_pos_args); + emit_write_code_info_byte(emit, emit->scope->num_kwonly_args); + emit_write_code_info_byte(emit, emit->scope->num_def_pos_args); + + // Write size of the rest of the code info. We don't know how big this + // variable uint will be on the MP_PASS_CODE_SIZE pass so we reserve 2 bytes + // for it and hope that is enough! TODO assert this or something. + if (pass == MP_PASS_EMIT) { + emit_write_code_info_uint(emit, emit->code_info_size - emit->code_info_offset); + } else { + emit_get_cur_to_write_code_info(emit, 2); + } + + // Write the name and source file of this function. + emit_write_code_info_qstr(emit, scope->simple_name); + emit_write_code_info_qstr(emit, scope->source_file); + + // bytecode prelude: initialise closed over variables + for (int i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL) { + assert(id->local_num < 255); + emit_write_bytecode_byte(emit, id->local_num); // write the local which should be converted to a cell + } + } + emit_write_bytecode_byte(emit, 255); // end of list sentinel + + #if MICROPY_PERSISTENT_CODE + emit->ct_cur_obj = 0; + emit->ct_cur_raw_code = 0; + #endif + + if (pass == MP_PASS_EMIT) { + // Write argument names (needed to resolve positional args passed as + // keywords). We store them as full word-sized objects for efficient access + // in mp_setup_code_state this is the start of the prelude and is guaranteed + // to be aligned on a word boundary. + + // For a given argument position (indexed by i) we need to find the + // corresponding id_info which is a parameter, as it has the correct + // qstr name to use as the argument name. Note that it's not a simple + // 1-1 mapping (ie i!=j in general) because of possible closed-over + // variables. In the case that the argument i has no corresponding + // parameter we use "*" as its name (since no argument can ever be named + // "*"). We could use a blank qstr but "*" is better for debugging. + // Note: there is some wasted RAM here for the case of storing a qstr + // for each closed-over variable, and maybe there is a better way to do + // it, but that would require changes to mp_setup_code_state. + for (int i = 0; i < scope->num_pos_args + scope->num_kwonly_args; i++) { + qstr qst = MP_QSTR__star_; + for (int j = 0; j < scope->id_info_len; ++j) { + id_info_t *id = &scope->id_info[j]; + if ((id->flags & ID_FLAG_IS_PARAM) && id->local_num == i) { + qst = id->qst; + break; + } + } + emit->const_table[i] = (mp_uint_t)MP_OBJ_NEW_QSTR(qst); + } + } +} + +void mp_emit_bc_end_pass(emit_t *emit) { + if (emit->pass == MP_PASS_SCOPE) { + return; + } + + // check stack is back to zero size + assert(emit->stack_size == 0); + + emit_write_code_info_byte(emit, 0); // end of line number info + + #if MICROPY_PERSISTENT_CODE + assert(emit->pass <= MP_PASS_STACK_SIZE || (emit->ct_num_obj == emit->ct_cur_obj)); + emit->ct_num_obj = emit->ct_cur_obj; + #endif + + if (emit->pass == MP_PASS_CODE_SIZE) { + #if !MICROPY_PERSISTENT_CODE + // so bytecode is aligned + emit->code_info_offset = (size_t)MP_ALIGN(emit->code_info_offset, sizeof(mp_uint_t)); + #endif + + // calculate size of total code-info + bytecode, in bytes + emit->code_info_size = emit->code_info_offset; + emit->bytecode_size = emit->bytecode_offset; + emit->code_base = m_new0(byte, emit->code_info_size + emit->bytecode_size); + + #if MICROPY_PERSISTENT_CODE + emit->const_table = m_new0(mp_uint_t, + emit->scope->num_pos_args + emit->scope->num_kwonly_args + + emit->ct_cur_obj + emit->ct_cur_raw_code); + #else + emit->const_table = m_new0(mp_uint_t, + emit->scope->num_pos_args + emit->scope->num_kwonly_args); + #endif + + } else if (emit->pass == MP_PASS_EMIT) { + mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base, + emit->code_info_size + emit->bytecode_size, + emit->const_table, + #if MICROPY_PERSISTENT_CODE_SAVE + emit->ct_cur_obj, emit->ct_cur_raw_code, + #endif + emit->scope->scope_flags); + } +} + +bool mp_emit_bc_last_emit_was_return_value(emit_t *emit) { + return emit->last_emit_was_return_value; +} + +void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta) { + if (emit->pass == MP_PASS_SCOPE) { + return; + } + assert((mp_int_t)emit->stack_size + delta >= 0); + emit->stack_size += delta; + if (emit->stack_size > emit->scope->stack_size) { + emit->scope->stack_size = emit->stack_size; + } + emit->last_emit_was_return_value = false; +} + +static inline void emit_bc_pre(emit_t *emit, mp_int_t stack_size_delta) { + mp_emit_bc_adjust_stack_size(emit, stack_size_delta); +} + +void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) { + //printf("source: line %d -> %d offset %d -> %d\n", emit->last_source_line, source_line, emit->last_source_line_offset, emit->bytecode_offset); +#if MICROPY_ENABLE_SOURCE_LINE + if (MP_STATE_VM(mp_optimise_value) >= 3) { + // If we compile with -O3, don't store line numbers. + return; + } + if (source_line > emit->last_source_line) { + mp_uint_t bytes_to_skip = emit->bytecode_offset - emit->last_source_line_offset; + mp_uint_t lines_to_skip = source_line - emit->last_source_line; + emit_write_code_info_bytes_lines(emit, bytes_to_skip, lines_to_skip); + emit->last_source_line_offset = emit->bytecode_offset; + emit->last_source_line = source_line; + } +#else + (void)emit; + (void)source_line; +#endif +} + +void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) { + emit_bc_pre(emit, 0); + if (emit->pass == MP_PASS_SCOPE) { + return; + } + assert(l < emit->max_num_labels); + if (emit->pass < MP_PASS_EMIT) { + // assign label offset + assert(emit->label_offsets[l] == (mp_uint_t)-1); + emit->label_offsets[l] = emit->bytecode_offset; + } else { + // ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT + //printf("l%d: (at %d vs %d)\n", l, emit->bytecode_offset, emit->label_offsets[l]); + assert(emit->label_offsets[l] == emit->bytecode_offset); + } +} + +void mp_emit_bc_import_name(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_qstr(emit, MP_BC_IMPORT_NAME, qst); +} + +void mp_emit_bc_import_from(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, MP_BC_IMPORT_FROM, qst); +} + +void mp_emit_bc_import_star(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, MP_BC_IMPORT_STAR); +} + +void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { + emit_bc_pre(emit, 1); + switch (tok) { + case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_FALSE); break; + case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_NONE); break; + case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_TRUE); break; + default: + assert(tok == MP_TOKEN_ELLIPSIS); + emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj)); + break; + } +} + +void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) { + emit_bc_pre(emit, 1); + if (-16 <= arg && arg <= 47) { + emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_SMALL_INT_MULTI + 16 + arg); + } else { + emit_write_bytecode_byte_int(emit, MP_BC_LOAD_CONST_SMALL_INT, arg); + } +} + +void mp_emit_bc_load_const_str(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_CONST_STRING, qst); +} + +void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, obj); +} + +void mp_emit_bc_load_null(emit_t *emit) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte(emit, MP_BC_LOAD_NULL); +}; + +void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, 1); + if (local_num <= 15) { + emit_write_bytecode_byte(emit, MP_BC_LOAD_FAST_MULTI + local_num); + } else { + emit_write_bytecode_byte_uint(emit, MP_BC_LOAD_FAST_N, local_num); + } +} + +void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_uint(emit, MP_BC_LOAD_DEREF, local_num); +} + +void mp_emit_bc_load_name(emit_t *emit, qstr qst) { + (void)qst; + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_NAME, qst); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_load_global(emit_t *emit, qstr qst) { + (void)qst; + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_GLOBAL, qst); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_load_attr(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_ATTR, qst); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super) { + emit_bc_pre(emit, 1 - 2 * is_super); + emit_write_bytecode_byte_qstr(emit, is_super ? MP_BC_LOAD_SUPER_METHOD : MP_BC_LOAD_METHOD, qst); +} + +void mp_emit_bc_load_build_class(emit_t *emit) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte(emit, MP_BC_LOAD_BUILD_CLASS); +} + +void mp_emit_bc_load_subscr(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, MP_BC_LOAD_SUBSCR); +} + +void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, -1); + if (local_num <= 15) { + emit_write_bytecode_byte(emit, MP_BC_STORE_FAST_MULTI + local_num); + } else { + emit_write_bytecode_byte_uint(emit, MP_BC_STORE_FAST_N, local_num); + } +} + +void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_uint(emit, MP_BC_STORE_DEREF, local_num); +} + +void mp_emit_bc_store_name(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_qstr(emit, MP_BC_STORE_NAME, qst); +} + +void mp_emit_bc_store_global(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_qstr(emit, MP_BC_STORE_GLOBAL, qst); +} + +void mp_emit_bc_store_attr(emit_t *emit, qstr qst) { + emit_bc_pre(emit, -2); + emit_write_bytecode_byte_qstr(emit, MP_BC_STORE_ATTR, qst); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { + emit_write_bytecode_byte(emit, 0); + } +} + +void mp_emit_bc_store_subscr(emit_t *emit) { + emit_bc_pre(emit, -3); + emit_write_bytecode_byte(emit, MP_BC_STORE_SUBSCR); +} + +void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_FAST, local_num); +} + +void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + (void)qst; + emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_DEREF, local_num); +} + +void mp_emit_bc_delete_name(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_qstr(emit, MP_BC_DELETE_NAME, qst); +} + +void mp_emit_bc_delete_global(emit_t *emit, qstr qst) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_qstr(emit, MP_BC_DELETE_GLOBAL, qst); +} + +void mp_emit_bc_delete_attr(emit_t *emit, qstr qst) { + mp_emit_bc_load_null(emit); + mp_emit_bc_rot_two(emit); + mp_emit_bc_store_attr(emit, qst); +} + +void mp_emit_bc_delete_subscr(emit_t *emit) { + mp_emit_bc_load_null(emit); + mp_emit_bc_rot_three(emit); + mp_emit_bc_store_subscr(emit); +} + +void mp_emit_bc_dup_top(emit_t *emit) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte(emit, MP_BC_DUP_TOP); +} + +void mp_emit_bc_dup_top_two(emit_t *emit) { + emit_bc_pre(emit, 2); + emit_write_bytecode_byte(emit, MP_BC_DUP_TOP_TWO); +} + +void mp_emit_bc_pop_top(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, MP_BC_POP_TOP); +} + +void mp_emit_bc_rot_two(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, MP_BC_ROT_TWO); +} + +void mp_emit_bc_rot_three(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, MP_BC_ROT_THREE); +} + +void mp_emit_bc_jump(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP, label); +} + +void mp_emit_bc_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) { + emit_bc_pre(emit, -1); + if (cond) { + emit_write_bytecode_byte_signed_label(emit, MP_BC_POP_JUMP_IF_TRUE, label); + } else { + emit_write_bytecode_byte_signed_label(emit, MP_BC_POP_JUMP_IF_FALSE, label); + } +} + +void mp_emit_bc_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) { + emit_bc_pre(emit, -1); + if (cond) { + emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP_IF_TRUE_OR_POP, label); + } else { + emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP_IF_FALSE_OR_POP, label); + } +} + +void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { + if (except_depth == 0) { + emit_bc_pre(emit, 0); + if (label & MP_EMIT_BREAK_FROM_FOR) { + // need to pop the iterator if we are breaking out of a for loop + emit_write_bytecode_byte(emit, MP_BC_POP_TOP); + // also pop the iter_buf + for (size_t i = 0; i < MP_OBJ_ITER_BUF_NSLOTS - 1; ++i) { + emit_write_bytecode_byte(emit, MP_BC_POP_TOP); + } + } + emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP, label & ~MP_EMIT_BREAK_FROM_FOR); + } else { + emit_write_bytecode_byte_signed_label(emit, MP_BC_UNWIND_JUMP, label & ~MP_EMIT_BREAK_FROM_FOR); + emit_write_bytecode_byte(emit, ((label & MP_EMIT_BREAK_FROM_FOR) ? 0x80 : 0) | except_depth); + } +} + +void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label) { + // The SETUP_WITH opcode pops ctx_mgr from the top of the stack + // and then pushes 3 entries: __exit__, ctx_mgr, as_value. + emit_bc_pre(emit, 2); + emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_WITH, label); +} + +void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label) { + mp_emit_bc_pop_block(emit); + mp_emit_bc_load_const_tok(emit, MP_TOKEN_KW_NONE); + mp_emit_bc_label_assign(emit, label); + emit_bc_pre(emit, 2); // ensure we have enough stack space to call the __exit__ method + emit_write_bytecode_byte(emit, MP_BC_WITH_CLEANUP); + emit_bc_pre(emit, -4); // cancel the 2 above, plus the 2 from mp_emit_bc_setup_with +} + +void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_EXCEPT, label); +} + +void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_FINALLY, label); +} + +void mp_emit_bc_end_finally(emit_t *emit) { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, MP_BC_END_FINALLY); +} + +void mp_emit_bc_get_iter(emit_t *emit, bool use_stack) { + emit_bc_pre(emit, use_stack ? MP_OBJ_ITER_BUF_NSLOTS - 1 : 0); + emit_write_bytecode_byte(emit, use_stack ? MP_BC_GET_ITER_STACK : MP_BC_GET_ITER); +} + +void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_unsigned_label(emit, MP_BC_FOR_ITER, label); +} + +void mp_emit_bc_for_iter_end(emit_t *emit) { + emit_bc_pre(emit, -MP_OBJ_ITER_BUF_NSLOTS); +} + +void mp_emit_bc_pop_block(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, MP_BC_POP_BLOCK); +} + +void mp_emit_bc_pop_except(emit_t *emit) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, MP_BC_POP_EXCEPT); +} + +void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, MP_BC_UNARY_OP_MULTI + op); +} + +void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op) { + bool invert = false; + if (op == MP_BINARY_OP_NOT_IN) { + invert = true; + op = MP_BINARY_OP_IN; + } else if (op == MP_BINARY_OP_IS_NOT) { + invert = true; + op = MP_BINARY_OP_IS; + } + emit_bc_pre(emit, -1); + emit_write_bytecode_byte(emit, MP_BC_BINARY_OP_MULTI + op); + if (invert) { + emit_bc_pre(emit, 0); + emit_write_bytecode_byte(emit, MP_BC_UNARY_OP_MULTI + MP_UNARY_OP_NOT); + } +} + +void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1 - n_args); + emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_TUPLE, n_args); +} + +void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1 - n_args); + emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_LIST, n_args); +} + +void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_MAP, n_args); +} + +void mp_emit_bc_store_map(emit_t *emit) { + emit_bc_pre(emit, -2); + emit_write_bytecode_byte(emit, MP_BC_STORE_MAP); +} + +#if MICROPY_PY_BUILTINS_SET +void mp_emit_bc_build_set(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1 - n_args); + emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_SET, n_args); +} +#endif + +#if MICROPY_PY_BUILTINS_SLICE +void mp_emit_bc_build_slice(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, 1 - n_args); + emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_SLICE, n_args); +} +#endif + +void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_stack_index) { + int t; + int n; + if (kind == SCOPE_LIST_COMP) { + n = 0; + t = 0; + } else if (!MICROPY_PY_BUILTINS_SET || kind == SCOPE_DICT_COMP) { + n = 1; + t = 1; + } else if (MICROPY_PY_BUILTINS_SET) { + n = 0; + t = 2; + } + emit_bc_pre(emit, -1 - n); + // the lower 2 bits of the opcode argument indicate the collection type + emit_write_bytecode_byte_uint(emit, MP_BC_STORE_COMP, ((collection_stack_index + n) << 2) | t); +} + +void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args) { + emit_bc_pre(emit, -1 + n_args); + emit_write_bytecode_byte_uint(emit, MP_BC_UNPACK_SEQUENCE, n_args); +} + +void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) { + emit_bc_pre(emit, -1 + n_left + n_right + 1); + emit_write_bytecode_byte_uint(emit, MP_BC_UNPACK_EX, n_left | (n_right << 8)); +} + +void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { + if (n_pos_defaults == 0 && n_kw_defaults == 0) { + emit_bc_pre(emit, 1); + emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_FUNCTION, scope->raw_code); + } else { + emit_bc_pre(emit, -1); + emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_FUNCTION_DEFARGS, scope->raw_code); + } +} + +void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { + if (n_pos_defaults == 0 && n_kw_defaults == 0) { + emit_bc_pre(emit, -n_closed_over + 1); + emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_CLOSURE, scope->raw_code); + emit_write_bytecode_byte(emit, n_closed_over); + } else { + assert(n_closed_over <= 255); + emit_bc_pre(emit, -2 - (mp_int_t)n_closed_over + 1); + emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_CLOSURE_DEFARGS, scope->raw_code); + emit_write_bytecode_byte(emit, n_closed_over); + } +} + +STATIC void emit_bc_call_function_method_helper(emit_t *emit, mp_int_t stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + if (star_flags) { + emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword - 2); + emit_write_bytecode_byte_uint(emit, bytecode_base + 1, (n_keyword << 8) | n_positional); // TODO make it 2 separate uints? + } else { + emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword); + emit_write_bytecode_byte_uint(emit, bytecode_base, (n_keyword << 8) | n_positional); // TODO make it 2 separate uints? + } +} + +void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + emit_bc_call_function_method_helper(emit, 0, MP_BC_CALL_FUNCTION, n_positional, n_keyword, star_flags); +} + +void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + emit_bc_call_function_method_helper(emit, -1, MP_BC_CALL_METHOD, n_positional, n_keyword, star_flags); +} + +void mp_emit_bc_return_value(emit_t *emit) { + emit_bc_pre(emit, -1); + emit->last_emit_was_return_value = true; + emit_write_bytecode_byte(emit, MP_BC_RETURN_VALUE); +} + +void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args) { + assert(n_args <= 2); + emit_bc_pre(emit, -n_args); + emit_write_bytecode_byte_byte(emit, MP_BC_RAISE_VARARGS, n_args); +} + +void mp_emit_bc_yield_value(emit_t *emit) { + emit_bc_pre(emit, 0); + emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; + emit_write_bytecode_byte(emit, MP_BC_YIELD_VALUE); +} + +void mp_emit_bc_yield_from(emit_t *emit) { + emit_bc_pre(emit, -1); + emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; + emit_write_bytecode_byte(emit, MP_BC_YIELD_FROM); +} + +void mp_emit_bc_start_except_handler(emit_t *emit) { + mp_emit_bc_adjust_stack_size(emit, 4); // stack adjust for the exception instance, +3 for possible UNWIND_JUMP state +} + +void mp_emit_bc_end_except_handler(emit_t *emit) { + mp_emit_bc_adjust_stack_size(emit, -3); // stack adjust +} + +#if MICROPY_EMIT_NATIVE +const emit_method_table_t emit_bc_method_table = { + NULL, // set_native_type is never called when emitting bytecode + mp_emit_bc_start_pass, + mp_emit_bc_end_pass, + mp_emit_bc_last_emit_was_return_value, + mp_emit_bc_adjust_stack_size, + mp_emit_bc_set_source_line, + + { + mp_emit_bc_load_fast, + mp_emit_bc_load_deref, + mp_emit_bc_load_name, + mp_emit_bc_load_global, + }, + { + mp_emit_bc_store_fast, + mp_emit_bc_store_deref, + mp_emit_bc_store_name, + mp_emit_bc_store_global, + }, + { + mp_emit_bc_delete_fast, + mp_emit_bc_delete_deref, + mp_emit_bc_delete_name, + mp_emit_bc_delete_global, + }, + + mp_emit_bc_label_assign, + mp_emit_bc_import_name, + mp_emit_bc_import_from, + mp_emit_bc_import_star, + mp_emit_bc_load_const_tok, + mp_emit_bc_load_const_small_int, + mp_emit_bc_load_const_str, + mp_emit_bc_load_const_obj, + mp_emit_bc_load_null, + mp_emit_bc_load_attr, + mp_emit_bc_load_method, + mp_emit_bc_load_build_class, + mp_emit_bc_load_subscr, + mp_emit_bc_store_attr, + mp_emit_bc_store_subscr, + mp_emit_bc_delete_attr, + mp_emit_bc_delete_subscr, + mp_emit_bc_dup_top, + mp_emit_bc_dup_top_two, + mp_emit_bc_pop_top, + mp_emit_bc_rot_two, + mp_emit_bc_rot_three, + mp_emit_bc_jump, + mp_emit_bc_pop_jump_if, + mp_emit_bc_jump_if_or_pop, + mp_emit_bc_unwind_jump, + mp_emit_bc_unwind_jump, + mp_emit_bc_setup_with, + mp_emit_bc_with_cleanup, + mp_emit_bc_setup_except, + mp_emit_bc_setup_finally, + mp_emit_bc_end_finally, + mp_emit_bc_get_iter, + mp_emit_bc_for_iter, + mp_emit_bc_for_iter_end, + mp_emit_bc_pop_block, + mp_emit_bc_pop_except, + mp_emit_bc_unary_op, + mp_emit_bc_binary_op, + mp_emit_bc_build_tuple, + mp_emit_bc_build_list, + mp_emit_bc_build_map, + mp_emit_bc_store_map, + #if MICROPY_PY_BUILTINS_SET + mp_emit_bc_build_set, + #endif + #if MICROPY_PY_BUILTINS_SLICE + mp_emit_bc_build_slice, + #endif + mp_emit_bc_store_comp, + mp_emit_bc_unpack_sequence, + mp_emit_bc_unpack_ex, + mp_emit_bc_make_function, + mp_emit_bc_make_closure, + mp_emit_bc_call_function, + mp_emit_bc_call_method, + mp_emit_bc_return_value, + mp_emit_bc_raise_varargs, + mp_emit_bc_yield_value, + mp_emit_bc_yield_from, + + mp_emit_bc_start_except_handler, + mp_emit_bc_end_except_handler, +}; +#else +const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops = { + mp_emit_bc_load_fast, + mp_emit_bc_load_deref, + mp_emit_bc_load_name, + mp_emit_bc_load_global, +}; + +const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops = { + mp_emit_bc_store_fast, + mp_emit_bc_store_deref, + mp_emit_bc_store_name, + mp_emit_bc_store_global, +}; + +const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops = { + mp_emit_bc_delete_fast, + mp_emit_bc_delete_deref, + mp_emit_bc_delete_name, + mp_emit_bc_delete_global, +}; +#endif + +#endif //MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/emitcommon.c b/user/mpy/py/emitcommon.c new file mode 100644 index 0000000..07b1dbb --- /dev/null +++ b/user/mpy/py/emitcommon.c @@ -0,0 +1,77 @@ +/* + * 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. + */ + +#include + +#include "py/emit.h" + +#if MICROPY_ENABLE_COMPILER + +void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst) { + // name adding/lookup + bool added; + id_info_t *id = scope_find_or_add_id(scope, qst, &added); + if (added) { + scope_find_local_and_close_over(scope, id, qst); + } +} + +void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst) { + // name adding/lookup + bool added; + id_info_t *id = scope_find_or_add_id(scope, qst, &added); + if (added) { + if (SCOPE_IS_FUNC_LIKE(scope->kind)) { + id->kind = ID_INFO_KIND_LOCAL; + } else { + id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; + } + } else if (SCOPE_IS_FUNC_LIKE(scope->kind) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + // rebind as a local variable + id->kind = ID_INFO_KIND_LOCAL; + } +} + +void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst) { + // assumes pass is greater than 1, ie that all identifiers are defined in the scope + + id_info_t *id = scope_find(scope, qst); + assert(id != NULL); + + // call the emit backend with the correct code + if (id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { + emit_method_table->name(emit, qst); + } else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) { + emit_method_table->global(emit, qst); + } else if (id->kind == ID_INFO_KIND_LOCAL) { + emit_method_table->fast(emit, qst, id->local_num); + } else { + assert(id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE); + emit_method_table->deref(emit, qst, id->local_num); + } +} + +#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/emitglue.c b/user/mpy/py/emitglue.c new file mode 100644 index 0000000..d2add98 --- /dev/null +++ b/user/mpy/py/emitglue.c @@ -0,0 +1,170 @@ +/* + * 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. + */ + +// This code glues the code emitters to the runtime. + +#include +#include +#include +#include + +#include "py/emitglue.h" +#include "py/runtime0.h" +#include "py/bc.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define WRITE_CODE (1) +#define DEBUG_printf DEBUG_printf +#define DEBUG_OP_printf(...) DEBUG_printf(__VA_ARGS__) +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#define DEBUG_OP_printf(...) (void)0 +#endif + +#if MICROPY_DEBUG_PRINTERS +mp_uint_t mp_verbose_flag = 0; +#endif + +mp_raw_code_t *mp_emit_glue_new_raw_code(void) { + mp_raw_code_t *rc = m_new0(mp_raw_code_t, 1); + rc->kind = MP_CODE_RESERVED; + return rc; +} + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + #if MICROPY_PERSISTENT_CODE_SAVE + uint16_t n_obj, uint16_t n_raw_code, + #endif + mp_uint_t scope_flags) { + + rc->kind = MP_CODE_BYTECODE; + rc->scope_flags = scope_flags; + rc->data.u_byte.bytecode = code; + rc->data.u_byte.const_table = const_table; + #if MICROPY_PERSISTENT_CODE_SAVE + rc->data.u_byte.bc_len = len; + rc->data.u_byte.n_obj = n_obj; + rc->data.u_byte.n_raw_code = n_raw_code; + #endif + +#ifdef DEBUG_PRINT + DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags); +#endif +#if MICROPY_DEBUG_PRINTERS + if (mp_verbose_flag >= 2) { + mp_bytecode_print(rc, code, len, const_table); + } +#endif +} + +#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig) { + assert(kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER || kind == MP_CODE_NATIVE_ASM); + rc->kind = kind; + rc->scope_flags = scope_flags; + rc->n_pos_args = n_pos_args; + rc->data.u_native.fun_data = fun_data; + rc->data.u_native.const_table = const_table; + rc->data.u_native.type_sig = type_sig; + +#ifdef DEBUG_PRINT + DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, n_pos_args, (uint)scope_flags); + for (mp_uint_t i = 0; i < fun_len; i++) { + if (i > 0 && i % 16 == 0) { + DEBUG_printf("\n"); + } + DEBUG_printf(" %02x", ((byte*)fun_data)[i]); + } + DEBUG_printf("\n"); + +#ifdef WRITE_CODE + FILE *fp_write_code = fopen("out-code", "wb"); + fwrite(fun_data, fun_len, 1, fp_write_code); + fclose(fp_write_code); +#endif +#else + (void)fun_len; +#endif +} +#endif + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args) { + DEBUG_OP_printf("make_function_from_raw_code %p\n", rc); + assert(rc != NULL); + + // def_args must be MP_OBJ_NULL or a tuple + assert(def_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_args, &mp_type_tuple)); + + // def_kw_args must be MP_OBJ_NULL or a dict + assert(def_kw_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_kw_args, &mp_type_dict)); + + // make the function, depending on the raw code kind + mp_obj_t fun; + switch (rc->kind) { + #if MICROPY_EMIT_NATIVE + case MP_CODE_NATIVE_PY: + fun = mp_obj_new_fun_native(def_args, def_kw_args, rc->data.u_native.fun_data, rc->data.u_native.const_table); + break; + case MP_CODE_NATIVE_VIPER: + fun = mp_obj_new_fun_viper(rc->n_pos_args, rc->data.u_native.fun_data, rc->data.u_native.type_sig); + break; + #endif + #if MICROPY_EMIT_INLINE_ASM + case MP_CODE_NATIVE_ASM: + fun = mp_obj_new_fun_asm(rc->n_pos_args, rc->data.u_native.fun_data, rc->data.u_native.type_sig); + break; + #endif + default: + // rc->kind should always be set and BYTECODE is the only remaining case + assert(rc->kind == MP_CODE_BYTECODE); + fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table); + break; + } + + // check for generator functions and if so wrap in generator object + if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) { + fun = mp_obj_new_gen_wrap(fun); + } + + return fun; +} + +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args) { + DEBUG_OP_printf("make_closure_from_raw_code %p " UINT_FMT " %p\n", rc, n_closed_over, args); + // make function object + mp_obj_t ffun; + if (n_closed_over & 0x100) { + // default positional and keyword args given + ffun = mp_make_function_from_raw_code(rc, args[0], args[1]); + } else { + // default positional and keyword args not given + ffun = mp_make_function_from_raw_code(rc, MP_OBJ_NULL, MP_OBJ_NULL); + } + // wrap function in closure object + return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2)); +} diff --git a/user/mpy/py/emitglue.h b/user/mpy/py/emitglue.h new file mode 100644 index 0000000..4393033 --- /dev/null +++ b/user/mpy/py/emitglue.h @@ -0,0 +1,77 @@ +/* + * 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_EMITGLUE_H +#define MICROPY_INCLUDED_PY_EMITGLUE_H + +#include "py/obj.h" + +// These variables and functions glue the code emitters to the runtime. + +typedef enum { + MP_CODE_UNUSED, + MP_CODE_RESERVED, + MP_CODE_BYTECODE, + MP_CODE_NATIVE_PY, + MP_CODE_NATIVE_VIPER, + MP_CODE_NATIVE_ASM, +} mp_raw_code_kind_t; + +typedef struct _mp_raw_code_t { + mp_raw_code_kind_t kind : 3; + mp_uint_t scope_flags : 7; + mp_uint_t n_pos_args : 11; + union { + struct { + const byte *bytecode; + const mp_uint_t *const_table; + #if MICROPY_PERSISTENT_CODE_SAVE + mp_uint_t bc_len; + uint16_t n_obj; + uint16_t n_raw_code; + #endif + } u_byte; + struct { + void *fun_data; + const mp_uint_t *const_table; + mp_uint_t type_sig; // for viper, compressed as 2-bit types; ret is MSB, then arg0, arg1, etc + } u_native; + } data; +} mp_raw_code_t; + +mp_raw_code_t *mp_emit_glue_new_raw_code(void); + +void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, + const mp_uint_t *const_table, + #if MICROPY_PERSISTENT_CODE_SAVE + uint16_t n_obj, uint16_t n_raw_code, + #endif + mp_uint_t scope_flags); +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); + +mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); +mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); + +#endif // MICROPY_INCLUDED_PY_EMITGLUE_H diff --git a/user/mpy/py/emitinlinethumb.c b/user/mpy/py/emitinlinethumb.c new file mode 100644 index 0000000..577f656 --- /dev/null +++ b/user/mpy/py/emitinlinethumb.c @@ -0,0 +1,822 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +#include "py/emit.h" +#include "py/asmthumb.h" + +#if MICROPY_EMIT_INLINE_THUMB + +typedef enum { +// define rules with a compile function +#define DEF_RULE(rule, comp, kind, ...) PN_##rule, +#define DEF_RULE_NC(rule, kind, ...) +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC + PN_const_object, // special node for a constant, generic Python object +// define rules without a compile function +#define DEF_RULE(rule, comp, kind, ...) +#define DEF_RULE_NC(rule, kind, ...) PN_##rule, +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC +} pn_kind_t; + +struct _emit_inline_asm_t { + asm_thumb_t as; + uint16_t pass; + mp_obj_t *error_slot; + mp_uint_t max_num_labels; + qstr *label_lookup; +}; + +STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const char *msg) { + *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); +} + +STATIC void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) { + *emit->error_slot = exc; +} + +emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels) { + emit_inline_asm_t *emit = m_new_obj(emit_inline_asm_t); + memset(&emit->as, 0, sizeof(emit->as)); + mp_asm_base_init(&emit->as.base, max_num_labels); + emit->max_num_labels = max_num_labels; + emit->label_lookup = m_new(qstr, max_num_labels); + return emit; +} + +void emit_inline_thumb_free(emit_inline_asm_t *emit) { + m_del(qstr, emit->label_lookup, emit->max_num_labels); + mp_asm_base_deinit(&emit->as.base, false); + m_del_obj(emit_inline_asm_t, emit); +} + +STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) { + emit->pass = pass; + emit->error_slot = error_slot; + if (emit->pass == MP_PASS_CODE_SIZE) { + memset(emit->label_lookup, 0, emit->max_num_labels * sizeof(qstr)); + } + mp_asm_base_start_pass(&emit->as.base, pass == MP_PASS_EMIT ? MP_ASM_PASS_EMIT : MP_ASM_PASS_COMPUTE); + asm_thumb_entry(&emit->as, 0); +} + +STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) { + asm_thumb_exit(&emit->as); + asm_thumb_end_pass(&emit->as); +} + +STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) { + if (n_params > 4) { + emit_inline_thumb_error_msg(emit, "can only have up to 4 parameters to Thumb assembly"); + return 0; + } + for (mp_uint_t i = 0; i < n_params; i++) { + if (!MP_PARSE_NODE_IS_ID(pn_params[i])) { + emit_inline_thumb_error_msg(emit, "parameters must be registers in sequence r0 to r3"); + return 0; + } + const char *p = qstr_str(MP_PARSE_NODE_LEAF_ARG(pn_params[i])); + if (!(strlen(p) == 2 && p[0] == 'r' && p[1] == '0' + i)) { + emit_inline_thumb_error_msg(emit, "parameters must be registers in sequence r0 to r3"); + return 0; + } + } + return n_params; +} + +STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) { + assert(label_num < emit->max_num_labels); + if (emit->pass == MP_PASS_CODE_SIZE) { + // check for duplicate label on first pass + for (uint i = 0; i < emit->max_num_labels; i++) { + if (emit->label_lookup[i] == label_id) { + return false; + } + } + } + emit->label_lookup[label_num] = label_id; + mp_asm_base_label_assign(&emit->as.base, label_num); + return true; +} + +typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t; +STATIC const reg_name_t reg_name_table[] = { + {0, "r0\0"}, + {1, "r1\0"}, + {2, "r2\0"}, + {3, "r3\0"}, + {4, "r4\0"}, + {5, "r5\0"}, + {6, "r6\0"}, + {7, "r7\0"}, + {8, "r8\0"}, + {9, "r9\0"}, + {10, "r10"}, + {11, "r11"}, + {12, "r12"}, + {13, "r13"}, + {14, "r14"}, + {15, "r15"}, + {10, "sl\0"}, + {11, "fp\0"}, + {13, "sp\0"}, + {14, "lr\0"}, + {15, "pc\0"}, +}; + +#define MAX_SPECIAL_REGISTER_NAME_LENGTH 7 +typedef struct _special_reg_name_t { byte reg; char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1]; } special_reg_name_t; +STATIC const special_reg_name_t special_reg_name_table[] = { + {5, "IPSR"}, + {17, "BASEPRI"}, +}; + +// return empty string in case of error, so we can attempt to parse the string +// without a special check if it was in fact a string +STATIC const char *get_arg_str(mp_parse_node_t pn) { + if (MP_PARSE_NODE_IS_ID(pn)) { + qstr qst = MP_PARSE_NODE_LEAF_ARG(pn); + return qstr_str(qst); + } else { + return ""; + } +} + +STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) { + const char *reg_str = get_arg_str(pn); + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) { + const reg_name_t *r = ®_name_table[i]; + if (reg_str[0] == r->name[0] + && reg_str[1] == r->name[1] + && reg_str[2] == r->name[2] + && (reg_str[2] == '\0' || reg_str[3] == '\0')) { + if (r->reg > max_reg) { + emit_inline_thumb_error_exc(emit, + mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, + "'%s' expects at most r%d", op, max_reg)); + return 0; + } else { + return r->reg; + } + } + } + emit_inline_thumb_error_exc(emit, + mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, + "'%s' expects a register", op)); + return 0; +} + +STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { + const char *reg_str = get_arg_str(pn); + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(special_reg_name_table); i++) { + const special_reg_name_t *r = &special_reg_name_table[i]; + if (strcmp(r->name, reg_str) == 0) { + return r->reg; + } + } + emit_inline_thumb_error_exc(emit, + mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, + "'%s' expects a special register", op)); + return 0; +} + +#if MICROPY_EMIT_INLINE_THUMB_FLOAT +STATIC mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { + const char *reg_str = get_arg_str(pn); + if (reg_str[0] == 's' && reg_str[1] != '\0') { + mp_uint_t regno = 0; + for (++reg_str; *reg_str; ++reg_str) { + mp_uint_t v = *reg_str; + if (!('0' <= v && v <= '9')) { + goto malformed; + } + regno = 10 * regno + v - '0'; + } + if (regno > 31) { + emit_inline_thumb_error_exc(emit, + mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, + "'%s' expects at most r%d", op, 31)); + return 0; + } else { + return regno; + } + } +malformed: + emit_inline_thumb_error_exc(emit, + mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, + "'%s' expects an FPU register", op)); + return 0; +} +#endif + +STATIC mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { + // a register list looks like {r0, r1, r2} and is parsed as a Python set + + if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_brace)) { + goto bad_arg; + } + + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 1); // should always be + pn = pns->nodes[0]; + + mp_uint_t reglist = 0; + + if (MP_PARSE_NODE_IS_ID(pn)) { + // set with one element + reglist |= 1 << get_arg_reg(emit, op, pn, 15); + } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { + pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker) { + assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should succeed + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; + if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_dictorsetmaker_list) { + // set with multiple elements + + // get first element of set (we rely on get_arg_reg to catch syntax errors) + reglist |= 1 << get_arg_reg(emit, op, pns->nodes[0], 15); + + // get tail elements (2nd, 3rd, ...) + mp_parse_node_t *nodes; + int n = mp_parse_node_extract_list(&pns1->nodes[0], PN_dictorsetmaker_list2, &nodes); + + // process rest of elements + for (int i = 0; i < n; i++) { + reglist |= 1 << get_arg_reg(emit, op, nodes[i], 15); + } + } else { + goto bad_arg; + } + } else { + goto bad_arg; + } + } else { + goto bad_arg; + } + + return reglist; + +bad_arg: + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects {r0, r1, ...}", op)); + return 0; +} + +STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) { + mp_obj_t o; + if (!mp_parse_node_get_int_maybe(pn, &o)) { + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects an integer", op)); + return 0; + } + uint32_t i = mp_obj_get_int_truncated(o); + if ((i & (~fit_mask)) != 0) { + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer 0x%x does not fit in mask 0x%x", op, i, fit_mask)); + return 0; + } + return i; +} + +STATIC bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_parse_node_t *pn_base, mp_parse_node_t *pn_offset) { + if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_bracket)) { + goto bad_arg; + } + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { + goto bad_arg; + } + pns = (mp_parse_node_struct_t*)pns->nodes[0]; + if (MP_PARSE_NODE_STRUCT_NUM_NODES(pns) != 2) { + goto bad_arg; + } + + *pn_base = pns->nodes[0]; + *pn_offset = pns->nodes[1]; + return true; + +bad_arg: + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects an address of the form [a, b]", op)); + return false; +} + +STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { + if (!MP_PARSE_NODE_IS_ID(pn)) { + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects a label", op)); + return 0; + } + qstr label_qstr = MP_PARSE_NODE_LEAF_ARG(pn); + for (uint i = 0; i < emit->max_num_labels; i++) { + if (emit->label_lookup[i] == label_qstr) { + return i; + } + } + // only need to have the labels on the last pass + if (emit->pass == MP_PASS_EMIT) { + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "label '%q' not defined", label_qstr)); + } + return 0; +} + +typedef struct _cc_name_t { byte cc; byte name[2]; } cc_name_t; +STATIC const cc_name_t cc_name_table[] = { + { ASM_THUMB_CC_EQ, "eq" }, + { ASM_THUMB_CC_NE, "ne" }, + { ASM_THUMB_CC_CS, "cs" }, + { ASM_THUMB_CC_CC, "cc" }, + { ASM_THUMB_CC_MI, "mi" }, + { ASM_THUMB_CC_PL, "pl" }, + { ASM_THUMB_CC_VS, "vs" }, + { ASM_THUMB_CC_VC, "vc" }, + { ASM_THUMB_CC_HI, "hi" }, + { ASM_THUMB_CC_LS, "ls" }, + { ASM_THUMB_CC_GE, "ge" }, + { ASM_THUMB_CC_LT, "lt" }, + { ASM_THUMB_CC_GT, "gt" }, + { ASM_THUMB_CC_LE, "le" }, +}; + +typedef struct _format_4_op_t { byte op; char name[3]; } format_4_op_t; +#define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops +STATIC const format_4_op_t format_4_op_table[] = { + { X(ASM_THUMB_FORMAT_4_EOR), "eor" }, + { X(ASM_THUMB_FORMAT_4_LSL), "lsl" }, + { X(ASM_THUMB_FORMAT_4_LSR), "lsr" }, + { X(ASM_THUMB_FORMAT_4_ASR), "asr" }, + { X(ASM_THUMB_FORMAT_4_ADC), "adc" }, + { X(ASM_THUMB_FORMAT_4_SBC), "sbc" }, + { X(ASM_THUMB_FORMAT_4_ROR), "ror" }, + { X(ASM_THUMB_FORMAT_4_TST), "tst" }, + { X(ASM_THUMB_FORMAT_4_NEG), "neg" }, + { X(ASM_THUMB_FORMAT_4_CMP), "cmp" }, + { X(ASM_THUMB_FORMAT_4_CMN), "cmn" }, + { X(ASM_THUMB_FORMAT_4_ORR), "orr" }, + { X(ASM_THUMB_FORMAT_4_MUL), "mul" }, + { X(ASM_THUMB_FORMAT_4_BIC), "bic" }, + { X(ASM_THUMB_FORMAT_4_MVN), "mvn" }, +}; +#undef X + +// name is actually a qstr, which should fit in 16 bits +typedef struct _format_9_10_op_t { uint16_t op; uint16_t name; } format_9_10_op_t; +#define X(x) (x) +STATIC const format_9_10_op_t format_9_10_op_table[] = { + { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_ldr }, + { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_ldrb }, + { X(ASM_THUMB_FORMAT_10_LDRH), MP_QSTR_ldrh }, + { X(ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_str }, + { X(ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_strb }, + { X(ASM_THUMB_FORMAT_10_STRH), MP_QSTR_strh }, +}; +#undef X + +#if MICROPY_EMIT_INLINE_THUMB_FLOAT +// actual opcodes are: 0xee00 | op.hi_nibble, 0x0a00 | op.lo_nibble +typedef struct _format_vfp_op_t { byte op; char name[3]; } format_vfp_op_t; +STATIC const format_vfp_op_t format_vfp_op_table[] = { + { 0x30, "add" }, + { 0x34, "sub" }, + { 0x20, "mul" }, + { 0x80, "div" }, +}; +#endif + +// shorthand alias for whether we allow ARMv7-M instructions +#define ARMV7M MICROPY_EMIT_INLINE_THUMB_ARMV7M + +STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) { + // TODO perhaps make two tables: + // one_args = + // "b", LAB, asm_thumb_b_n, + // "bgt", LAB, asm_thumb_bgt_n, + // two_args = + // "movs", RLO, I8, asm_thumb_movs_reg_i8 + // "movw", REG, REG, asm_thumb_movw_reg_i16 + // three_args = + // "subs", RLO, RLO, I3, asm_thumb_subs_reg_reg_i3 + + size_t op_len; + const char *op_str = (const char*)qstr_data(op, &op_len); + + #if MICROPY_EMIT_INLINE_THUMB_FLOAT + if (op_str[0] == 'v') { + // floating point operations + if (n_args == 2) { + mp_uint_t op_code = 0x0ac0, op_code_hi; + if (op == MP_QSTR_vcmp) { + op_code_hi = 0xeeb4; + op_vfp_twoargs:; + mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]); + mp_uint_t vm = get_arg_vfpreg(emit, op_str, pn_args[1]); + asm_thumb_op32(&emit->as, + op_code_hi | ((vd & 1) << 6), + op_code | ((vd & 0x1e) << 11) | ((vm & 1) << 5) | (vm & 0x1e) >> 1); + } else if (op == MP_QSTR_vsqrt) { + op_code_hi = 0xeeb1; + goto op_vfp_twoargs; + } else if (op == MP_QSTR_vneg) { + op_code_hi = 0xeeb1; + op_code = 0x0a40; + goto op_vfp_twoargs; + } else if (op == MP_QSTR_vcvt_f32_s32) { + op_code_hi = 0xeeb8; // int to float + goto op_vfp_twoargs; + } else if (op == MP_QSTR_vcvt_s32_f32) { + op_code_hi = 0xeebd; // float to int + goto op_vfp_twoargs; + } else if (op == MP_QSTR_vmrs) { + mp_uint_t reg_dest; + const char *reg_str0 = get_arg_str(pn_args[0]); + if (strcmp(reg_str0, "APSR_nzcv") == 0) { + reg_dest = 15; + } else { + reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); + } + const char *reg_str1 = get_arg_str(pn_args[1]); + if (strcmp(reg_str1, "FPSCR") == 0) { + // FP status to ARM reg + asm_thumb_op32(&emit->as, 0xeef1, 0x0a10 | (reg_dest << 12)); + } else { + goto unknown_op; + } + } else if (op == MP_QSTR_vmov) { + op_code_hi = 0xee00; + mp_uint_t r_arm, vm; + const char *reg_str = get_arg_str(pn_args[0]); + if (reg_str[0] == 'r') { + r_arm = get_arg_reg(emit, op_str, pn_args[0], 15); + vm = get_arg_vfpreg(emit, op_str, pn_args[1]); + op_code_hi |= 0x10; + } else { + vm = get_arg_vfpreg(emit, op_str, pn_args[0]); + r_arm = get_arg_reg(emit, op_str, pn_args[1], 15); + } + asm_thumb_op32(&emit->as, + op_code_hi | ((vm & 0x1e) >> 1), + 0x0a10 | (r_arm << 12) | ((vm & 1) << 7)); + } else if (op == MP_QSTR_vldr) { + op_code_hi = 0xed90; + op_vldr_vstr:; + mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]); + mp_parse_node_t pn_base, pn_offset; + if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) { + mp_uint_t rlo_base = get_arg_reg(emit, op_str, pn_base, 7); + mp_uint_t i8; + i8 = get_arg_i(emit, op_str, pn_offset, 0x3fc) >> 2; + asm_thumb_op32(&emit->as, + op_code_hi | rlo_base | ((vd & 1) << 6), + 0x0a00 | ((vd & 0x1e) << 11) | i8); + } + } else if (op == MP_QSTR_vstr) { + op_code_hi = 0xed80; + goto op_vldr_vstr; + } else { + goto unknown_op; + } + } else if (n_args == 3) { + // search table for arith ops + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(format_vfp_op_table); i++) { + if (strncmp(op_str + 1, format_vfp_op_table[i].name, 3) == 0 && op_str[4] == '\0') { + mp_uint_t op_code_hi = 0xee00 | (format_vfp_op_table[i].op & 0xf0); + mp_uint_t op_code = 0x0a00 | ((format_vfp_op_table[i].op & 0x0f) << 4); + mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]); + mp_uint_t vn = get_arg_vfpreg(emit, op_str, pn_args[1]); + mp_uint_t vm = get_arg_vfpreg(emit, op_str, pn_args[2]); + asm_thumb_op32(&emit->as, + op_code_hi | ((vd & 1) << 6) | (vn >> 1), + op_code | (vm >> 1) | ((vm & 1) << 5) | ((vd & 0x1e) << 11) | ((vn & 1) << 7)); + return; + } + } + goto unknown_op; + } else { + goto unknown_op; + } + } else + #endif + if (n_args == 0) { + if (op == MP_QSTR_nop) { + asm_thumb_op16(&emit->as, ASM_THUMB_OP_NOP); + } else if (op == MP_QSTR_wfi) { + asm_thumb_op16(&emit->as, ASM_THUMB_OP_WFI); + } else { + goto unknown_op; + } + + } else if (n_args == 1) { + if (op == MP_QSTR_b) { + int label_num = get_arg_label(emit, op_str, pn_args[0]); + if (!asm_thumb_b_n_label(&emit->as, label_num)) { + goto branch_not_in_range; + } + } else if (op == MP_QSTR_bl) { + int label_num = get_arg_label(emit, op_str, pn_args[0]); + if (!asm_thumb_bl_label(&emit->as, label_num)) { + goto branch_not_in_range; + } + } else if (op == MP_QSTR_bx) { + mp_uint_t r = get_arg_reg(emit, op_str, pn_args[0], 15); + asm_thumb_op16(&emit->as, 0x4700 | (r << 3)); + } else if (op_str[0] == 'b' && (op_len == 3 + || (op_len == 5 && op_str[3] == '_' + && (op_str[4] == 'n' || (ARMV7M && op_str[4] == 'w'))))) { + mp_uint_t cc = -1; + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) { + if (op_str[1] == cc_name_table[i].name[0] && op_str[2] == cc_name_table[i].name[1]) { + cc = cc_name_table[i].cc; + } + } + if (cc == (mp_uint_t)-1) { + goto unknown_op; + } + int label_num = get_arg_label(emit, op_str, pn_args[0]); + if (!asm_thumb_bcc_nw_label(&emit->as, cc, label_num, op_len == 5 && op_str[4] == 'w')) { + goto branch_not_in_range; + } + } else if (ARMV7M && op_str[0] == 'i' && op_str[1] == 't') { + const char *arg_str = get_arg_str(pn_args[0]); + mp_uint_t cc = -1; + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) { + if (arg_str[0] == cc_name_table[i].name[0] + && arg_str[1] == cc_name_table[i].name[1] + && arg_str[2] == '\0') { + cc = cc_name_table[i].cc; + break; + } + } + if (cc == (mp_uint_t)-1) { + goto unknown_op; + } + const char *os = op_str + 2; + while (*os != '\0') { + os++; + } + if (os > op_str + 5) { + goto unknown_op; + } + mp_uint_t it_mask = 8; + while (--os >= op_str + 2) { + it_mask >>= 1; + if (*os == 't') { + it_mask |= (cc & 1) << 3; + } else if (*os == 'e') { + it_mask |= ((~cc) & 1) << 3; + } else { + goto unknown_op; + } + } + asm_thumb_it_cc(&emit->as, cc, it_mask); + } else if (op == MP_QSTR_cpsid) { + // TODO check pn_args[0] == i + asm_thumb_op16(&emit->as, ASM_THUMB_OP_CPSID_I); + } else if (op == MP_QSTR_cpsie) { + // TODO check pn_args[0] == i + asm_thumb_op16(&emit->as, ASM_THUMB_OP_CPSIE_I); + } else if (op == MP_QSTR_push) { + mp_uint_t reglist = get_arg_reglist(emit, op_str, pn_args[0]); + if ((reglist & 0xff00) == 0) { + asm_thumb_op16(&emit->as, 0xb400 | reglist); + } else { + if (!ARMV7M) { + goto unknown_op; + } + asm_thumb_op32(&emit->as, 0xe92d, reglist); + } + } else if (op == MP_QSTR_pop) { + mp_uint_t reglist = get_arg_reglist(emit, op_str, pn_args[0]); + if ((reglist & 0xff00) == 0) { + asm_thumb_op16(&emit->as, 0xbc00 | reglist); + } else { + if (!ARMV7M) { + goto unknown_op; + } + asm_thumb_op32(&emit->as, 0xe8bd, reglist); + } + } else { + goto unknown_op; + } + + } else if (n_args == 2) { + if (MP_PARSE_NODE_IS_ID(pn_args[1])) { + // second arg is a register (or should be) + mp_uint_t op_code, op_code_hi; + if (op == MP_QSTR_mov) { + mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); + mp_uint_t reg_src = get_arg_reg(emit, op_str, pn_args[1], 15); + asm_thumb_mov_reg_reg(&emit->as, reg_dest, reg_src); + } else if (ARMV7M && op == MP_QSTR_clz) { + op_code_hi = 0xfab0; + op_code = 0xf080; + mp_uint_t rd, rm; + op_clz_rbit: + rd = get_arg_reg(emit, op_str, pn_args[0], 15); + rm = get_arg_reg(emit, op_str, pn_args[1], 15); + asm_thumb_op32(&emit->as, op_code_hi | rm, op_code | (rd << 8) | rm); + } else if (ARMV7M && op == MP_QSTR_rbit) { + op_code_hi = 0xfa90; + op_code = 0xf0a0; + goto op_clz_rbit; + } else if (ARMV7M && op == MP_QSTR_mrs){ + mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 12); + mp_uint_t reg_src = get_arg_special_reg(emit, op_str, pn_args[1]); + asm_thumb_op32(&emit->as, 0xf3ef, 0x8000 | (reg_dest << 8) | reg_src); + } else { + if (op == MP_QSTR_and_) { + op_code = ASM_THUMB_FORMAT_4_AND; + mp_uint_t reg_dest, reg_src; + op_format_4: + reg_dest = get_arg_reg(emit, op_str, pn_args[0], 7); + reg_src = get_arg_reg(emit, op_str, pn_args[1], 7); + asm_thumb_format_4(&emit->as, op_code, reg_dest, reg_src); + return; + } + // search table for ALU ops + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(format_4_op_table); i++) { + if (strncmp(op_str, format_4_op_table[i].name, 3) == 0 && op_str[3] == '\0') { + op_code = 0x4000 | (format_4_op_table[i].op << 4); + goto op_format_4; + } + } + goto unknown_op; + } + } else { + // second arg is not a register + mp_uint_t op_code; + if (op == MP_QSTR_mov) { + op_code = ASM_THUMB_FORMAT_3_MOV; + mp_uint_t rlo_dest, i8_src; + op_format_3: + rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); + i8_src = get_arg_i(emit, op_str, pn_args[1], 0xff); + asm_thumb_format_3(&emit->as, op_code, rlo_dest, i8_src); + } else if (op == MP_QSTR_cmp) { + op_code = ASM_THUMB_FORMAT_3_CMP; + goto op_format_3; + } else if (op == MP_QSTR_add) { + op_code = ASM_THUMB_FORMAT_3_ADD; + goto op_format_3; + } else if (op == MP_QSTR_sub) { + op_code = ASM_THUMB_FORMAT_3_SUB; + goto op_format_3; + } else if (ARMV7M && op == MP_QSTR_movw) { + op_code = ASM_THUMB_OP_MOVW; + mp_uint_t reg_dest; + op_movw_movt: + reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); + int i_src = get_arg_i(emit, op_str, pn_args[1], 0xffff); + asm_thumb_mov_reg_i16(&emit->as, op_code, reg_dest, i_src); + } else if (ARMV7M && op == MP_QSTR_movt) { + op_code = ASM_THUMB_OP_MOVT; + goto op_movw_movt; + } else if (ARMV7M && op == MP_QSTR_movwt) { + // this is a convenience instruction + mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); + uint32_t i_src = get_arg_i(emit, op_str, pn_args[1], 0xffffffff); + asm_thumb_mov_reg_i16(&emit->as, ASM_THUMB_OP_MOVW, reg_dest, i_src & 0xffff); + asm_thumb_mov_reg_i16(&emit->as, ASM_THUMB_OP_MOVT, reg_dest, (i_src >> 16) & 0xffff); + } else if (ARMV7M && op == MP_QSTR_ldrex) { + mp_uint_t r_dest = get_arg_reg(emit, op_str, pn_args[0], 15); + mp_parse_node_t pn_base, pn_offset; + if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) { + mp_uint_t r_base = get_arg_reg(emit, op_str, pn_base, 15); + mp_uint_t i8 = get_arg_i(emit, op_str, pn_offset, 0xff) >> 2; + asm_thumb_op32(&emit->as, 0xe850 | r_base, 0x0f00 | (r_dest << 12) | i8); + } + } else { + // search table for ldr/str instructions + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(format_9_10_op_table); i++) { + if (op == format_9_10_op_table[i].name) { + op_code = format_9_10_op_table[i].op; + mp_parse_node_t pn_base, pn_offset; + mp_uint_t rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); + if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) { + mp_uint_t rlo_base = get_arg_reg(emit, op_str, pn_base, 7); + mp_uint_t i5; + if (op_code & ASM_THUMB_FORMAT_9_BYTE_TRANSFER) { + i5 = get_arg_i(emit, op_str, pn_offset, 0x1f); + } else if (op_code & ASM_THUMB_FORMAT_10_STRH) { // also catches LDRH + i5 = get_arg_i(emit, op_str, pn_offset, 0x3e) >> 1; + } else { + i5 = get_arg_i(emit, op_str, pn_offset, 0x7c) >> 2; + } + asm_thumb_format_9_10(&emit->as, op_code, rlo_dest, rlo_base, i5); + return; + } + break; + } + } + goto unknown_op; + } + } + + } else if (n_args == 3) { + mp_uint_t op_code; + if (op == MP_QSTR_lsl) { + op_code = ASM_THUMB_FORMAT_1_LSL; + mp_uint_t rlo_dest, rlo_src, i5; + op_format_1: + rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); + rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7); + i5 = get_arg_i(emit, op_str, pn_args[2], 0x1f); + asm_thumb_format_1(&emit->as, op_code, rlo_dest, rlo_src, i5); + } else if (op == MP_QSTR_lsr) { + op_code = ASM_THUMB_FORMAT_1_LSR; + goto op_format_1; + } else if (op == MP_QSTR_asr) { + op_code = ASM_THUMB_FORMAT_1_ASR; + goto op_format_1; + } else if (op == MP_QSTR_add) { + op_code = ASM_THUMB_FORMAT_2_ADD; + mp_uint_t rlo_dest, rlo_src; + op_format_2: + rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); + rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7); + int src_b; + if (MP_PARSE_NODE_IS_ID(pn_args[2])) { + op_code |= ASM_THUMB_FORMAT_2_REG_OPERAND; + src_b = get_arg_reg(emit, op_str, pn_args[2], 7); + } else { + op_code |= ASM_THUMB_FORMAT_2_IMM_OPERAND; + src_b = get_arg_i(emit, op_str, pn_args[2], 0x7); + } + asm_thumb_format_2(&emit->as, op_code, rlo_dest, rlo_src, src_b); + } else if (ARMV7M && op == MP_QSTR_sdiv) { + op_code = 0xfb90; // sdiv high part + mp_uint_t rd, rn, rm; + op_sdiv_udiv: + rd = get_arg_reg(emit, op_str, pn_args[0], 15); + rn = get_arg_reg(emit, op_str, pn_args[1], 15); + rm = get_arg_reg(emit, op_str, pn_args[2], 15); + asm_thumb_op32(&emit->as, op_code | rn, 0xf0f0 | (rd << 8) | rm); + } else if (ARMV7M && op == MP_QSTR_udiv) { + op_code = 0xfbb0; // udiv high part + goto op_sdiv_udiv; + } else if (op == MP_QSTR_sub) { + op_code = ASM_THUMB_FORMAT_2_SUB; + goto op_format_2; + } else if (ARMV7M && op == MP_QSTR_strex) { + mp_uint_t r_dest = get_arg_reg(emit, op_str, pn_args[0], 15); + mp_uint_t r_src = get_arg_reg(emit, op_str, pn_args[1], 15); + mp_parse_node_t pn_base, pn_offset; + if (get_arg_addr(emit, op_str, pn_args[2], &pn_base, &pn_offset)) { + mp_uint_t r_base = get_arg_reg(emit, op_str, pn_base, 15); + mp_uint_t i8 = get_arg_i(emit, op_str, pn_offset, 0xff) >> 2; + asm_thumb_op32(&emit->as, 0xe840 | r_base, (r_src << 12) | (r_dest << 8) | i8); + } + } else { + goto unknown_op; + } + + } else { + goto unknown_op; + } + + return; + +unknown_op: + emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "unsupported Thumb instruction '%s' with %d arguments", op_str, n_args)); + return; + +branch_not_in_range: + emit_inline_thumb_error_msg(emit, "branch not in range"); + return; +} + +const emit_inline_asm_method_table_t emit_inline_thumb_method_table = { + emit_inline_thumb_start_pass, + emit_inline_thumb_end_pass, + emit_inline_thumb_count_params, + emit_inline_thumb_label, + emit_inline_thumb_op, +}; + +#endif // MICROPY_EMIT_INLINE_THUMB diff --git a/user/mpy/py/emitinlinextensa.c b/user/mpy/py/emitinlinextensa.c new file mode 100644 index 0000000..3d3217f --- /dev/null +++ b/user/mpy/py/emitinlinextensa.c @@ -0,0 +1,345 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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. + */ + +#include +#include +#include +#include +#include + +#include "py/emit.h" +#include "py/asmxtensa.h" + +#if MICROPY_EMIT_INLINE_XTENSA + +struct _emit_inline_asm_t { + asm_xtensa_t as; + uint16_t pass; + mp_obj_t *error_slot; + mp_uint_t max_num_labels; + qstr *label_lookup; +}; + +STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const char *msg) { + *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); +} + +STATIC void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) { + *emit->error_slot = exc; +} + +emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels) { + emit_inline_asm_t *emit = m_new_obj(emit_inline_asm_t); + memset(&emit->as, 0, sizeof(emit->as)); + mp_asm_base_init(&emit->as.base, max_num_labels); + emit->max_num_labels = max_num_labels; + emit->label_lookup = m_new(qstr, max_num_labels); + return emit; +} + +void emit_inline_xtensa_free(emit_inline_asm_t *emit) { + m_del(qstr, emit->label_lookup, emit->max_num_labels); + mp_asm_base_deinit(&emit->as.base, false); + m_del_obj(emit_inline_asm_t, emit); +} + +STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) { + emit->pass = pass; + emit->error_slot = error_slot; + if (emit->pass == MP_PASS_CODE_SIZE) { + memset(emit->label_lookup, 0, emit->max_num_labels * sizeof(qstr)); + } + mp_asm_base_start_pass(&emit->as.base, pass == MP_PASS_EMIT ? MP_ASM_PASS_EMIT : MP_ASM_PASS_COMPUTE); + asm_xtensa_entry(&emit->as, 0); +} + +STATIC void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) { + asm_xtensa_exit(&emit->as); + asm_xtensa_end_pass(&emit->as); +} + +STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) { + if (n_params > 4) { + emit_inline_xtensa_error_msg(emit, "can only have up to 4 parameters to Xtensa assembly"); + return 0; + } + for (mp_uint_t i = 0; i < n_params; i++) { + if (!MP_PARSE_NODE_IS_ID(pn_params[i])) { + emit_inline_xtensa_error_msg(emit, "parameters must be registers in sequence a2 to a5"); + return 0; + } + const char *p = qstr_str(MP_PARSE_NODE_LEAF_ARG(pn_params[i])); + if (!(strlen(p) == 2 && p[0] == 'a' && p[1] == '2' + i)) { + emit_inline_xtensa_error_msg(emit, "parameters must be registers in sequence a2 to a5"); + return 0; + } + } + return n_params; +} + +STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) { + assert(label_num < emit->max_num_labels); + if (emit->pass == MP_PASS_CODE_SIZE) { + // check for duplicate label on first pass + for (uint i = 0; i < emit->max_num_labels; i++) { + if (emit->label_lookup[i] == label_id) { + return false; + } + } + } + emit->label_lookup[label_num] = label_id; + mp_asm_base_label_assign(&emit->as.base, label_num); + return true; +} + +typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t; +STATIC const reg_name_t reg_name_table[] = { + {0, "a0\0"}, + {1, "a1\0"}, + {2, "a2\0"}, + {3, "a3\0"}, + {4, "a4\0"}, + {5, "a5\0"}, + {6, "a6\0"}, + {7, "a7\0"}, + {8, "a8\0"}, + {9, "a9\0"}, + {10, "a10"}, + {11, "a11"}, + {12, "a12"}, + {13, "a13"}, + {14, "a14"}, + {15, "a15"}, +}; + +// return empty string in case of error, so we can attempt to parse the string +// without a special check if it was in fact a string +STATIC const char *get_arg_str(mp_parse_node_t pn) { + if (MP_PARSE_NODE_IS_ID(pn)) { + qstr qst = MP_PARSE_NODE_LEAF_ARG(pn); + return qstr_str(qst); + } else { + return ""; + } +} + +STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { + const char *reg_str = get_arg_str(pn); + for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) { + const reg_name_t *r = ®_name_table[i]; + if (reg_str[0] == r->name[0] + && reg_str[1] == r->name[1] + && reg_str[2] == r->name[2] + && (reg_str[2] == '\0' || reg_str[3] == '\0')) { + return r->reg; + } + } + emit_inline_xtensa_error_exc(emit, + mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, + "'%s' expects a register", op)); + return 0; +} + +STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) { + mp_obj_t o; + if (!mp_parse_node_get_int_maybe(pn, &o)) { + emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects an integer", op)); + return 0; + } + uint32_t i = mp_obj_get_int_truncated(o); + if (min != max && ((int)i < min || (int)i > max)) { + emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer %d is not within range %d..%d", op, i, min, max)); + return 0; + } + return i; +} + +STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { + if (!MP_PARSE_NODE_IS_ID(pn)) { + emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects a label", op)); + return 0; + } + qstr label_qstr = MP_PARSE_NODE_LEAF_ARG(pn); + for (uint i = 0; i < emit->max_num_labels; i++) { + if (emit->label_lookup[i] == label_qstr) { + return i; + } + } + // only need to have the labels on the last pass + if (emit->pass == MP_PASS_EMIT) { + emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "label '%q' not defined", label_qstr)); + } + return 0; +} + +#define RRR (0) +#define RRI8 (1) +#define RRI8_B (2) + +typedef struct _opcode_table_3arg_t { + uint16_t name; // actually a qstr, which should fit in 16 bits + uint8_t type; + uint8_t a0 : 4; + uint8_t a1 : 4; +} opcode_table_3arg_t; + +STATIC const opcode_table_3arg_t opcode_table_3arg[] = { + // arithmetic opcodes: reg, reg, reg + {MP_QSTR_and_, RRR, 0, 1}, + {MP_QSTR_or_, RRR, 0, 2}, + {MP_QSTR_xor, RRR, 0, 3}, + {MP_QSTR_add, RRR, 0, 8}, + {MP_QSTR_sub, RRR, 0, 12}, + {MP_QSTR_mull, RRR, 2, 8}, + + // load/store/addi opcodes: reg, reg, imm + // upper nibble of type encodes the range of the immediate arg + {MP_QSTR_l8ui, RRI8 | 0x10, 2, 0}, + {MP_QSTR_l16ui, RRI8 | 0x30, 2, 1}, + {MP_QSTR_l32i, RRI8 | 0x50, 2, 2}, + {MP_QSTR_s8i, RRI8 | 0x10, 2, 4}, + {MP_QSTR_s16i, RRI8 | 0x30, 2, 5}, + {MP_QSTR_s32i, RRI8 | 0x50, 2, 6}, + {MP_QSTR_l16si, RRI8 | 0x30, 2, 9}, + {MP_QSTR_addi, RRI8 | 0x00, 2, 12}, + + // branch opcodes: reg, reg, label + {MP_QSTR_ball, RRI8_B, ASM_XTENSA_CC_ALL, 0}, + {MP_QSTR_bany, RRI8_B, ASM_XTENSA_CC_ANY, 0}, + {MP_QSTR_bbc, RRI8_B, ASM_XTENSA_CC_BC, 0}, + {MP_QSTR_bbs, RRI8_B, ASM_XTENSA_CC_BS, 0}, + {MP_QSTR_beq, RRI8_B, ASM_XTENSA_CC_EQ, 0}, + {MP_QSTR_bge, RRI8_B, ASM_XTENSA_CC_GE, 0}, + {MP_QSTR_bgeu, RRI8_B, ASM_XTENSA_CC_GEU, 0}, + {MP_QSTR_blt, RRI8_B, ASM_XTENSA_CC_LT, 0}, + {MP_QSTR_bnall, RRI8_B, ASM_XTENSA_CC_NALL, 0}, + {MP_QSTR_bne, RRI8_B, ASM_XTENSA_CC_NE, 0}, + {MP_QSTR_bnone, RRI8_B, ASM_XTENSA_CC_NONE, 0}, +}; + +STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) { + size_t op_len; + const char *op_str = (const char*)qstr_data(op, &op_len); + + if (n_args == 0) { + if (op == MP_QSTR_ret_n) { + asm_xtensa_op_ret_n(&emit->as); + } else { + goto unknown_op; + } + + } else if (n_args == 1) { + if (op == MP_QSTR_callx0) { + uint r0 = get_arg_reg(emit, op_str, pn_args[0]); + asm_xtensa_op_callx0(&emit->as, r0); + } else if (op == MP_QSTR_j) { + int label = get_arg_label(emit, op_str, pn_args[0]); + asm_xtensa_j_label(&emit->as, label); + } else if (op == MP_QSTR_jx) { + uint r0 = get_arg_reg(emit, op_str, pn_args[0]); + asm_xtensa_op_jx(&emit->as, r0); + } else { + goto unknown_op; + } + + } else if (n_args == 2) { + uint r0 = get_arg_reg(emit, op_str, pn_args[0]); + if (op == MP_QSTR_beqz) { + int label = get_arg_label(emit, op_str, pn_args[1]); + asm_xtensa_bccz_reg_label(&emit->as, ASM_XTENSA_CCZ_EQ, r0, label); + } else if (op == MP_QSTR_bnez) { + int label = get_arg_label(emit, op_str, pn_args[1]); + asm_xtensa_bccz_reg_label(&emit->as, ASM_XTENSA_CCZ_NE, r0, label); + } else if (op == MP_QSTR_mov || op == MP_QSTR_mov_n) { + // we emit mov.n for both "mov" and "mov_n" opcodes + uint r1 = get_arg_reg(emit, op_str, pn_args[1]); + asm_xtensa_op_mov_n(&emit->as, r0, r1); + } else if (op == MP_QSTR_movi) { + // for convenience we emit l32r if the integer doesn't fit in movi + uint32_t imm = get_arg_i(emit, op_str, pn_args[1], 0, 0); + asm_xtensa_mov_reg_i32(&emit->as, r0, imm); + } else { + goto unknown_op; + } + + } else if (n_args == 3) { + // search table for 3 arg instructions + for (uint i = 0; i < MP_ARRAY_SIZE(opcode_table_3arg); i++) { + const opcode_table_3arg_t *o = &opcode_table_3arg[i]; + if (op == o->name) { + uint r0 = get_arg_reg(emit, op_str, pn_args[0]); + uint r1 = get_arg_reg(emit, op_str, pn_args[1]); + if (o->type == RRR) { + uint r2 = get_arg_reg(emit, op_str, pn_args[2]); + asm_xtensa_op24(&emit->as, ASM_XTENSA_ENCODE_RRR(0, o->a0, o->a1, r0, r1, r2)); + } else if (o->type == RRI8_B) { + int label = get_arg_label(emit, op_str, pn_args[2]); + asm_xtensa_bcc_reg_reg_label(&emit->as, o->a0, r0, r1, label); + } else { + int shift, min, max; + if ((o->type & 0xf0) == 0) { + shift = 0; + min = -128; + max = 127; + } else { + shift = (o->type & 0xf0) >> 5; + min = 0; + max = 0xff << shift; + } + uint32_t imm = get_arg_i(emit, op_str, pn_args[2], min, max); + asm_xtensa_op24(&emit->as, ASM_XTENSA_ENCODE_RRI8(o->a0, o->a1, r1, r0, (imm >> shift) & 0xff)); + } + return; + } + } + goto unknown_op; + + } else { + goto unknown_op; + } + + return; + +unknown_op: + emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "unsupported Xtensa instruction '%s' with %d arguments", op_str, n_args)); + return; + + /* +branch_not_in_range: + emit_inline_xtensa_error_msg(emit, "branch not in range"); + return; + */ +} + +const emit_inline_asm_method_table_t emit_inline_xtensa_method_table = { + emit_inline_xtensa_start_pass, + emit_inline_xtensa_end_pass, + emit_inline_xtensa_count_params, + emit_inline_xtensa_label, + emit_inline_xtensa_op, +}; + +#endif // MICROPY_EMIT_INLINE_XTENSA diff --git a/user/mpy/py/emitnative.c b/user/mpy/py/emitnative.c new file mode 100644 index 0000000..4608cd1 --- /dev/null +++ b/user/mpy/py/emitnative.c @@ -0,0 +1,2350 @@ +/* + * 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. + */ + +// Essentially normal Python has 1 type: Python objects +// Viper has more than 1 type, and is just a more complicated (a superset of) Python. +// If you declare everything in Viper as a Python object (ie omit type decls) then +// it should in principle be exactly the same as Python native. +// Having types means having more opcodes, like binary_op_nat_nat, binary_op_nat_obj etc. +// In practice we won't have a VM but rather do this in asm which is actually very minimal. + +// Because it breaks strict Python equivalence it should be a completely separate +// decorator. It breaks equivalence because overflow on integers wraps around. +// It shouldn't break equivalence if you don't use the new types, but since the +// type decls might be used in normal Python for other reasons, it's probably safest, +// cleanest and clearest to make it a separate decorator. + +// Actually, it does break equivalence because integers default to native integers, +// not Python objects. + +// for x in l[0:8]: can be compiled into a native loop if l has pointer type + +#include +#include +#include + +#include "py/nlr.h" +#include "py/emit.h" +#include "py/bc.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +// wrapper around everything in this file +#if (MICROPY_EMIT_X64 && N_X64) \ + || (MICROPY_EMIT_X86 && N_X86) \ + || (MICROPY_EMIT_THUMB && N_THUMB) \ + || (MICROPY_EMIT_ARM && N_ARM) \ + || (MICROPY_EMIT_XTENSA && N_XTENSA) \ + +// this is defined so that the assembler exports generic assembler API macros +#define GENERIC_ASM_API (1) + +#if N_X64 + +// x64 specific stuff +#include "py/asmx64.h" +#define EXPORT_FUN(name) emit_native_x64_##name + +#elif N_X86 + +// x86 specific stuff + +STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = { + [MP_F_CONVERT_OBJ_TO_NATIVE] = 2, + [MP_F_CONVERT_NATIVE_TO_OBJ] = 2, + [MP_F_LOAD_NAME] = 1, + [MP_F_LOAD_GLOBAL] = 1, + [MP_F_LOAD_BUILD_CLASS] = 0, + [MP_F_LOAD_ATTR] = 2, + [MP_F_LOAD_METHOD] = 3, + [MP_F_LOAD_SUPER_METHOD] = 2, + [MP_F_STORE_NAME] = 2, + [MP_F_STORE_GLOBAL] = 2, + [MP_F_STORE_ATTR] = 3, + [MP_F_OBJ_SUBSCR] = 3, + [MP_F_OBJ_IS_TRUE] = 1, + [MP_F_UNARY_OP] = 2, + [MP_F_BINARY_OP] = 3, + [MP_F_BUILD_TUPLE] = 2, + [MP_F_BUILD_LIST] = 2, + [MP_F_LIST_APPEND] = 2, + [MP_F_BUILD_MAP] = 1, + [MP_F_STORE_MAP] = 3, +#if MICROPY_PY_BUILTINS_SET + [MP_F_BUILD_SET] = 2, + [MP_F_STORE_SET] = 2, +#endif + [MP_F_MAKE_FUNCTION_FROM_RAW_CODE] = 3, + [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3, + [MP_F_CALL_METHOD_N_KW] = 3, + [MP_F_CALL_METHOD_N_KW_VAR] = 3, + [MP_F_NATIVE_GETITER] = 2, + [MP_F_NATIVE_ITERNEXT] = 1, + [MP_F_NLR_PUSH] = 1, + [MP_F_NLR_POP] = 0, + [MP_F_NATIVE_RAISE] = 1, + [MP_F_IMPORT_NAME] = 3, + [MP_F_IMPORT_FROM] = 2, + [MP_F_IMPORT_ALL] = 1, +#if MICROPY_PY_BUILTINS_SLICE + [MP_F_NEW_SLICE] = 3, +#endif + [MP_F_UNPACK_SEQUENCE] = 3, + [MP_F_UNPACK_EX] = 3, + [MP_F_DELETE_NAME] = 1, + [MP_F_DELETE_GLOBAL] = 1, + [MP_F_NEW_CELL] = 1, + [MP_F_MAKE_CLOSURE_FROM_RAW_CODE] = 3, + [MP_F_SETUP_CODE_STATE] = 5, +}; + +#include "py/asmx86.h" +#define EXPORT_FUN(name) emit_native_x86_##name + +#elif N_THUMB + +// thumb specific stuff +#include "py/asmthumb.h" +#define EXPORT_FUN(name) emit_native_thumb_##name + +#elif N_ARM + +// ARM specific stuff +#include "py/asmarm.h" +#define EXPORT_FUN(name) emit_native_arm_##name + +#elif N_XTENSA + +// Xtensa specific stuff +#include "py/asmxtensa.h" +#define EXPORT_FUN(name) emit_native_xtensa_##name + +#else + +#error unknown native emitter + +#endif + +#define EMIT_NATIVE_VIPER_TYPE_ERROR(emit, ...) do { \ + *emit->error_slot = mp_obj_new_exception_msg_varg(&mp_type_ViperTypeError, __VA_ARGS__); \ + } while (0) + +typedef enum { + STACK_VALUE, + STACK_REG, + STACK_IMM, +} stack_info_kind_t; + +// these enums must be distinct and the bottom 4 bits +// must correspond to the correct MP_NATIVE_TYPE_xxx value +typedef enum { + VTYPE_PYOBJ = 0x00 | MP_NATIVE_TYPE_OBJ, + VTYPE_BOOL = 0x00 | MP_NATIVE_TYPE_BOOL, + VTYPE_INT = 0x00 | MP_NATIVE_TYPE_INT, + VTYPE_UINT = 0x00 | MP_NATIVE_TYPE_UINT, + VTYPE_PTR = 0x00 | MP_NATIVE_TYPE_PTR, + VTYPE_PTR8 = 0x00 | MP_NATIVE_TYPE_PTR8, + VTYPE_PTR16 = 0x00 | MP_NATIVE_TYPE_PTR16, + VTYPE_PTR32 = 0x00 | MP_NATIVE_TYPE_PTR32, + + VTYPE_PTR_NONE = 0x50 | MP_NATIVE_TYPE_PTR, + + VTYPE_UNBOUND = 0x60 | MP_NATIVE_TYPE_OBJ, + VTYPE_BUILTIN_CAST = 0x70 | MP_NATIVE_TYPE_OBJ, +} vtype_kind_t; + +STATIC qstr vtype_to_qstr(vtype_kind_t vtype) { + switch (vtype) { + case VTYPE_PYOBJ: return MP_QSTR_object; + case VTYPE_BOOL: return MP_QSTR_bool; + case VTYPE_INT: return MP_QSTR_int; + case VTYPE_UINT: return MP_QSTR_uint; + case VTYPE_PTR: return MP_QSTR_ptr; + case VTYPE_PTR8: return MP_QSTR_ptr8; + case VTYPE_PTR16: return MP_QSTR_ptr16; + case VTYPE_PTR32: return MP_QSTR_ptr32; + case VTYPE_PTR_NONE: default: return MP_QSTR_None; + } +} + +typedef struct _stack_info_t { + vtype_kind_t vtype; + stack_info_kind_t kind; + union { + int u_reg; + mp_int_t u_imm; + } data; +} stack_info_t; + +struct _emit_t { + mp_obj_t *error_slot; + int pass; + + bool do_viper_types; + + vtype_kind_t return_vtype; + + mp_uint_t local_vtype_alloc; + vtype_kind_t *local_vtype; + + mp_uint_t stack_info_alloc; + stack_info_t *stack_info; + vtype_kind_t saved_stack_vtype; + + int prelude_offset; + int const_table_offset; + int n_state; + int stack_start; + int stack_size; + + bool last_emit_was_return_value; + + scope_t *scope; + + ASM_T *as; +}; + +emit_t *EXPORT_FUN(new)(mp_obj_t *error_slot, mp_uint_t max_num_labels) { + emit_t *emit = m_new0(emit_t, 1); + emit->error_slot = error_slot; + emit->as = m_new0(ASM_T, 1); + mp_asm_base_init(&emit->as->base, max_num_labels); + return emit; +} + +void EXPORT_FUN(free)(emit_t *emit) { + mp_asm_base_deinit(&emit->as->base, false); + m_del_obj(ASM_T, emit->as); + m_del(vtype_kind_t, emit->local_vtype, emit->local_vtype_alloc); + m_del(stack_info_t, emit->stack_info, emit->stack_info_alloc); + m_del_obj(emit_t, emit); +} + +STATIC void emit_native_set_native_type(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2) { + switch (op) { + case MP_EMIT_NATIVE_TYPE_ENABLE: + emit->do_viper_types = arg1; + break; + + default: { + vtype_kind_t type; + switch (arg2) { + case MP_QSTR_object: type = VTYPE_PYOBJ; break; + case MP_QSTR_bool: type = VTYPE_BOOL; break; + case MP_QSTR_int: type = VTYPE_INT; break; + case MP_QSTR_uint: type = VTYPE_UINT; break; + case MP_QSTR_ptr: type = VTYPE_PTR; break; + case MP_QSTR_ptr8: type = VTYPE_PTR8; break; + case MP_QSTR_ptr16: type = VTYPE_PTR16; break; + case MP_QSTR_ptr32: type = VTYPE_PTR32; break; + default: EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "unknown type '%q'", arg2); return; + } + if (op == MP_EMIT_NATIVE_TYPE_RETURN) { + emit->return_vtype = type; + } else { + assert(arg1 < emit->local_vtype_alloc); + emit->local_vtype[arg1] = type; + } + break; + } + } +} + +STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest); +STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg); +STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); +STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); + +#define STATE_START (sizeof(mp_code_state_t) / sizeof(mp_uint_t)) + +STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { + DEBUG_printf("start_pass(pass=%u, scope=%p)\n", pass, scope); + + emit->pass = pass; + emit->stack_start = 0; + emit->stack_size = 0; + emit->last_emit_was_return_value = false; + emit->scope = scope; + + // allocate memory for keeping track of the types of locals + if (emit->local_vtype_alloc < scope->num_locals) { + emit->local_vtype = m_renew(vtype_kind_t, emit->local_vtype, emit->local_vtype_alloc, scope->num_locals); + emit->local_vtype_alloc = scope->num_locals; + } + + // allocate memory for keeping track of the objects on the stack + // XXX don't know stack size on entry, and it should be maximum over all scopes + // XXX this is such a big hack and really needs to be fixed + if (emit->stack_info == NULL) { + emit->stack_info_alloc = scope->stack_size + 200; + emit->stack_info = m_new(stack_info_t, emit->stack_info_alloc); + } + + // set default type for return + emit->return_vtype = VTYPE_PYOBJ; + + // set default type for arguments + mp_uint_t num_args = emit->scope->num_pos_args + emit->scope->num_kwonly_args; + if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) { + num_args += 1; + } + if (scope->scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) { + num_args += 1; + } + for (mp_uint_t i = 0; i < num_args; i++) { + emit->local_vtype[i] = VTYPE_PYOBJ; + } + + // local variables begin unbound, and have unknown type + for (mp_uint_t i = num_args; i < emit->local_vtype_alloc; i++) { + emit->local_vtype[i] = VTYPE_UNBOUND; + } + + // values on stack begin unbound + for (mp_uint_t i = 0; i < emit->stack_info_alloc; i++) { + emit->stack_info[i].kind = STACK_VALUE; + emit->stack_info[i].vtype = VTYPE_UNBOUND; + } + + mp_asm_base_start_pass(&emit->as->base, pass == MP_PASS_EMIT ? MP_ASM_PASS_EMIT : MP_ASM_PASS_COMPUTE); + + // generate code for entry to function + + if (emit->do_viper_types) { + + // right now we have a restriction of maximum of 4 arguments + if (scope->num_pos_args >= 5) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "Viper functions don't currently support more than 4 arguments"); + return; + } + + // entry to function + int num_locals = 0; + if (pass > MP_PASS_SCOPE) { + num_locals = scope->num_locals - REG_LOCAL_NUM; + if (num_locals < 0) { + num_locals = 0; + } + emit->stack_start = num_locals; + num_locals += scope->stack_size; + } + ASM_ENTRY(emit->as, num_locals); + + // TODO don't load r7 if we don't need it + #if N_THUMB + asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); + #elif N_ARM + asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); + #endif + + #if N_X86 + for (int i = 0; i < scope->num_pos_args; i++) { + if (i == 0) { + asm_x86_mov_arg_to_r32(emit->as, i, REG_LOCAL_1); + } else if (i == 1) { + asm_x86_mov_arg_to_r32(emit->as, i, REG_LOCAL_2); + } else if (i == 2) { + asm_x86_mov_arg_to_r32(emit->as, i, REG_LOCAL_3); + } else { + asm_x86_mov_arg_to_r32(emit->as, i, REG_TEMP0); + asm_x86_mov_r32_to_local(emit->as, REG_TEMP0, i - REG_LOCAL_NUM); + } + } + #else + for (int i = 0; i < scope->num_pos_args; i++) { + if (i == 0) { + ASM_MOV_REG_REG(emit->as, REG_LOCAL_1, REG_ARG_1); + } else if (i == 1) { + ASM_MOV_REG_REG(emit->as, REG_LOCAL_2, REG_ARG_2); + } else if (i == 2) { + ASM_MOV_REG_REG(emit->as, REG_LOCAL_3, REG_ARG_3); + } else { + assert(i == 3); // should be true; max 4 args is checked above + ASM_MOV_REG_TO_LOCAL(emit->as, REG_ARG_4, i - REG_LOCAL_NUM); + } + } + #endif + + } else { + // work out size of state (locals plus stack) + emit->n_state = scope->num_locals + scope->stack_size; + + // allocate space on C-stack for code_state structure, which includes state + ASM_ENTRY(emit->as, STATE_START + emit->n_state); + + // TODO don't load r7 if we don't need it + #if N_THUMB + asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); + #elif N_ARM + asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); + #endif + + // prepare incoming arguments for call to mp_setup_code_state + + #if N_X86 + asm_x86_mov_arg_to_r32(emit->as, 0, REG_ARG_1); + asm_x86_mov_arg_to_r32(emit->as, 1, REG_ARG_2); + asm_x86_mov_arg_to_r32(emit->as, 2, REG_ARG_3); + asm_x86_mov_arg_to_r32(emit->as, 3, REG_ARG_4); + #endif + + // set code_state.fun_bc + ASM_MOV_REG_TO_LOCAL(emit->as, REG_ARG_1, offsetof(mp_code_state_t, fun_bc) / sizeof(uintptr_t)); + + // set code_state.ip (offset from start of this function to prelude info) + // XXX this encoding may change size + ASM_MOV_IMM_TO_LOCAL_USING(emit->as, emit->prelude_offset, offsetof(mp_code_state_t, ip) / sizeof(uintptr_t), REG_ARG_1); + + // put address of code_state into first arg + ASM_MOV_LOCAL_ADDR_TO_REG(emit->as, 0, REG_ARG_1); + + // call mp_setup_code_state to prepare code_state structure + #if N_THUMB + asm_thumb_bl_ind(emit->as, mp_fun_table[MP_F_SETUP_CODE_STATE], MP_F_SETUP_CODE_STATE, ASM_THUMB_REG_R4); + #elif N_ARM + asm_arm_bl_ind(emit->as, mp_fun_table[MP_F_SETUP_CODE_STATE], MP_F_SETUP_CODE_STATE, ASM_ARM_REG_R4); + #else + ASM_CALL_IND(emit->as, mp_fun_table[MP_F_SETUP_CODE_STATE], MP_F_SETUP_CODE_STATE); + #endif + + // cache some locals in registers + if (scope->num_locals > 0) { + ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - 0, REG_LOCAL_1); + if (scope->num_locals > 1) { + ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - 1, REG_LOCAL_2); + if (scope->num_locals > 2) { + ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - 2, REG_LOCAL_3); + } + } + } + + // set the type of closed over variables + for (mp_uint_t i = 0; i < scope->id_info_len; i++) { + id_info_t *id = &scope->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL) { + emit->local_vtype[id->local_num] = VTYPE_PYOBJ; + } + } + } + +} + +STATIC void emit_native_end_pass(emit_t *emit) { + if (!emit->last_emit_was_return_value) { + ASM_EXIT(emit->as); + } + + if (!emit->do_viper_types) { + emit->prelude_offset = mp_asm_base_get_code_pos(&emit->as->base); + mp_asm_base_data(&emit->as->base, 1, 0x80 | ((emit->n_state >> 7) & 0x7f)); + mp_asm_base_data(&emit->as->base, 1, emit->n_state & 0x7f); + mp_asm_base_data(&emit->as->base, 1, 0); // n_exc_stack + mp_asm_base_data(&emit->as->base, 1, emit->scope->scope_flags); + mp_asm_base_data(&emit->as->base, 1, emit->scope->num_pos_args); + mp_asm_base_data(&emit->as->base, 1, emit->scope->num_kwonly_args); + mp_asm_base_data(&emit->as->base, 1, emit->scope->num_def_pos_args); + + // write code info + #if MICROPY_PERSISTENT_CODE + mp_asm_base_data(&emit->as->base, 1, 5); + mp_asm_base_data(&emit->as->base, 1, emit->scope->simple_name); + mp_asm_base_data(&emit->as->base, 1, emit->scope->simple_name >> 8); + mp_asm_base_data(&emit->as->base, 1, emit->scope->source_file); + mp_asm_base_data(&emit->as->base, 1, emit->scope->source_file >> 8); + #else + mp_asm_base_data(&emit->as->base, 1, 1); + #endif + + // bytecode prelude: initialise closed over variables + for (int i = 0; i < emit->scope->id_info_len; i++) { + id_info_t *id = &emit->scope->id_info[i]; + if (id->kind == ID_INFO_KIND_CELL) { + assert(id->local_num < 255); + mp_asm_base_data(&emit->as->base, 1, id->local_num); // write the local which should be converted to a cell + } + } + mp_asm_base_data(&emit->as->base, 1, 255); // end of list sentinel + + mp_asm_base_align(&emit->as->base, ASM_WORD_SIZE); + emit->const_table_offset = mp_asm_base_get_code_pos(&emit->as->base); + + // write argument names as qstr objects + // see comment in corresponding part of emitbc.c about the logic here + for (int i = 0; i < emit->scope->num_pos_args + emit->scope->num_kwonly_args; i++) { + qstr qst = MP_QSTR__star_; + for (int j = 0; j < emit->scope->id_info_len; ++j) { + id_info_t *id = &emit->scope->id_info[j]; + if ((id->flags & ID_FLAG_IS_PARAM) && id->local_num == i) { + qst = id->qst; + break; + } + } + mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (mp_uint_t)MP_OBJ_NEW_QSTR(qst)); + } + + } + + ASM_END_PASS(emit->as); + + // check stack is back to zero size + assert(emit->stack_size == 0); + + if (emit->pass == MP_PASS_EMIT) { + void *f = mp_asm_base_get_code(&emit->as->base); + mp_uint_t f_len = mp_asm_base_get_code_size(&emit->as->base); + + // compute type signature + // note that the lower 4 bits of a vtype are tho correct MP_NATIVE_TYPE_xxx + mp_uint_t type_sig = emit->return_vtype & 0xf; + for (mp_uint_t i = 0; i < emit->scope->num_pos_args; i++) { + type_sig |= (emit->local_vtype[i] & 0xf) << (i * 4 + 4); + } + + mp_emit_glue_assign_native(emit->scope->raw_code, + emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY, + f, f_len, (mp_uint_t*)((byte*)f + emit->const_table_offset), + emit->scope->num_pos_args, emit->scope->scope_flags, type_sig); + } +} + +STATIC bool emit_native_last_emit_was_return_value(emit_t *emit) { + return emit->last_emit_was_return_value; +} + +STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) { + assert((mp_int_t)emit->stack_size + stack_size_delta >= 0); + emit->stack_size += stack_size_delta; + if (emit->pass > MP_PASS_SCOPE && emit->stack_size > emit->scope->stack_size) { + emit->scope->stack_size = emit->stack_size; + } +#ifdef DEBUG_PRINT + DEBUG_printf(" adjust_stack; stack_size=%d+%d; stack now:", emit->stack_size - stack_size_delta, stack_size_delta); + for (int i = 0; i < emit->stack_size; i++) { + stack_info_t *si = &emit->stack_info[i]; + DEBUG_printf(" (v=%d k=%d %d)", si->vtype, si->kind, si->data.u_reg); + } + DEBUG_printf("\n"); +#endif +} + +STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) { + DEBUG_printf("adjust_stack_size(" INT_FMT ")\n", delta); + // If we are adjusting the stack in a positive direction (pushing) then we + // need to fill in values for the stack kind and vtype of the newly-pushed + // entries. These should be set to "value" (ie not reg or imm) because we + // should only need to adjust the stack due to a jump to this part in the + // code (and hence we have settled the stack before the jump). + for (mp_int_t i = 0; i < delta; i++) { + stack_info_t *si = &emit->stack_info[emit->stack_size + i]; + si->kind = STACK_VALUE; + // TODO we don't know the vtype to use here. At the moment this is a + // hack to get the case of multi comparison working. + if (delta == 1) { + si->vtype = emit->saved_stack_vtype; + } else { + si->vtype = VTYPE_PYOBJ; + } + } + adjust_stack(emit, delta); +} + +STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) { + (void)emit; + (void)source_line; +} + +// this must be called at start of emit functions +STATIC void emit_native_pre(emit_t *emit) { + emit->last_emit_was_return_value = false; +} + +// depth==0 is top, depth==1 is before top, etc +STATIC stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) { + return &emit->stack_info[emit->stack_size - 1 - depth]; +} + +// depth==0 is top, depth==1 is before top, etc +STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) { + return peek_stack(emit, depth)->vtype; +} + +// pos=1 is TOS, pos=2 is next, etc +// use pos=0 for no skipping +STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) { + skip_stack_pos = emit->stack_size - skip_stack_pos; + for (int i = 0; i < emit->stack_size; i++) { + if (i != skip_stack_pos) { + stack_info_t *si = &emit->stack_info[i]; + if (si->kind == STACK_REG && si->data.u_reg == reg_needed) { + si->kind = STACK_VALUE; + ASM_MOV_REG_TO_LOCAL(emit->as, si->data.u_reg, emit->stack_start + i); + } + } + } +} + +STATIC void need_reg_all(emit_t *emit) { + for (int i = 0; i < emit->stack_size; i++) { + stack_info_t *si = &emit->stack_info[i]; + if (si->kind == STACK_REG) { + si->kind = STACK_VALUE; + ASM_MOV_REG_TO_LOCAL(emit->as, si->data.u_reg, emit->stack_start + i); + } + } +} + +STATIC void need_stack_settled(emit_t *emit) { + DEBUG_printf(" need_stack_settled; stack_size=%d\n", emit->stack_size); + for (int i = 0; i < emit->stack_size; i++) { + stack_info_t *si = &emit->stack_info[i]; + if (si->kind == STACK_REG) { + DEBUG_printf(" reg(%u) to local(%u)\n", si->data.u_reg, emit->stack_start + i); + si->kind = STACK_VALUE; + ASM_MOV_REG_TO_LOCAL(emit->as, si->data.u_reg, emit->stack_start + i); + } + } + for (int i = 0; i < emit->stack_size; i++) { + stack_info_t *si = &emit->stack_info[i]; + if (si->kind == STACK_IMM) { + DEBUG_printf(" imm(" INT_FMT ") to local(%u)\n", si->data.u_imm, emit->stack_start + i); + si->kind = STACK_VALUE; + ASM_MOV_IMM_TO_LOCAL_USING(emit->as, si->data.u_imm, emit->stack_start + i, REG_TEMP0); + } + } +} + +// pos=1 is TOS, pos=2 is next, etc +STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int reg_dest) { + need_reg_single(emit, reg_dest, pos); + stack_info_t *si = &emit->stack_info[emit->stack_size - pos]; + *vtype = si->vtype; + switch (si->kind) { + case STACK_VALUE: + ASM_MOV_LOCAL_TO_REG(emit->as, emit->stack_start + emit->stack_size - pos, reg_dest); + break; + + case STACK_REG: + if (si->data.u_reg != reg_dest) { + ASM_MOV_REG_REG(emit->as, reg_dest, si->data.u_reg); + } + break; + + case STACK_IMM: + ASM_MOV_IMM_TO_REG(emit->as, si->data.u_imm, reg_dest); + break; + } +} + +// does an efficient X=pop(); discard(); push(X) +// needs a (non-temp) register in case the poped element was stored in the stack +STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) { + stack_info_t *si = &emit->stack_info[emit->stack_size - 2]; + si[0] = si[1]; + if (si->kind == STACK_VALUE) { + // if folded element was on the stack we need to put it in a register + ASM_MOV_LOCAL_TO_REG(emit->as, emit->stack_start + emit->stack_size - 1, reg_dest); + si->kind = STACK_REG; + si->data.u_reg = reg_dest; + } + adjust_stack(emit, -1); +} + +// If stacked value is in a register and the register is not r1 or r2, then +// *reg_dest is set to that register. Otherwise the value is put in *reg_dest. +STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *reg_dest, int not_r1, int not_r2) { + emit->last_emit_was_return_value = false; + stack_info_t *si = peek_stack(emit, 0); + if (si->kind == STACK_REG && si->data.u_reg != not_r1 && si->data.u_reg != not_r2) { + *vtype = si->vtype; + *reg_dest = si->data.u_reg; + need_reg_single(emit, *reg_dest, 1); + } else { + emit_access_stack(emit, 1, vtype, *reg_dest); + } + adjust_stack(emit, -1); +} + +STATIC void emit_pre_pop_discard(emit_t *emit) { + emit->last_emit_was_return_value = false; + adjust_stack(emit, -1); +} + +STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest) { + emit->last_emit_was_return_value = false; + emit_access_stack(emit, 1, vtype, reg_dest); + adjust_stack(emit, -1); +} + +STATIC void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb) { + emit_pre_pop_reg(emit, vtypea, rega); + emit_pre_pop_reg(emit, vtypeb, regb); +} + +STATIC void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb, vtype_kind_t *vtypec, int regc) { + emit_pre_pop_reg(emit, vtypea, rega); + emit_pre_pop_reg(emit, vtypeb, regb); + emit_pre_pop_reg(emit, vtypec, regc); +} + +STATIC void emit_post(emit_t *emit) { + (void)emit; +} + +STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) { + stack_info_t *si = &emit->stack_info[emit->stack_size - 1]; + si->vtype = new_vtype; +} + +STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) { + stack_info_t *si = &emit->stack_info[emit->stack_size]; + si->vtype = vtype; + si->kind = STACK_REG; + si->data.u_reg = reg; + adjust_stack(emit, 1); +} + +STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) { + stack_info_t *si = &emit->stack_info[emit->stack_size]; + si->vtype = vtype; + si->kind = STACK_IMM; + si->data.u_imm = imm; + adjust_stack(emit, 1); +} + +STATIC void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb) { + emit_post_push_reg(emit, vtypea, rega); + emit_post_push_reg(emit, vtypeb, regb); +} + +STATIC void emit_post_push_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc) { + emit_post_push_reg(emit, vtypea, rega); + emit_post_push_reg(emit, vtypeb, regb); + emit_post_push_reg(emit, vtypec, regc); +} + +STATIC void emit_post_push_reg_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc, vtype_kind_t vtyped, int regd) { + emit_post_push_reg(emit, vtypea, rega); + emit_post_push_reg(emit, vtypeb, regb); + emit_post_push_reg(emit, vtypec, regc); + emit_post_push_reg(emit, vtyped, regd); +} + +STATIC void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) { + need_reg_all(emit); + ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); +} + +STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) { + need_reg_all(emit); + ASM_MOV_IMM_TO_REG(emit->as, arg_val, arg_reg); + ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); +} + +// the first arg is stored in the code aligned on a mp_uint_t boundary +STATIC void emit_call_with_imm_arg_aligned(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) { + need_reg_all(emit); + ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, arg_val, arg_reg); + ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); +} + +STATIC void emit_call_with_2_imm_args(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val1, int arg_reg1, mp_int_t arg_val2, int arg_reg2) { + need_reg_all(emit); + ASM_MOV_IMM_TO_REG(emit->as, arg_val1, arg_reg1); + ASM_MOV_IMM_TO_REG(emit->as, arg_val2, arg_reg2); + ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); +} + +// the first arg is stored in the code aligned on a mp_uint_t boundary +STATIC void emit_call_with_3_imm_args_and_first_aligned(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val1, int arg_reg1, mp_int_t arg_val2, int arg_reg2, mp_int_t arg_val3, int arg_reg3) { + need_reg_all(emit); + ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, arg_val1, arg_reg1); + ASM_MOV_IMM_TO_REG(emit->as, arg_val2, arg_reg2); + ASM_MOV_IMM_TO_REG(emit->as, arg_val3, arg_reg3); + ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); +} + +// vtype of all n_pop objects is VTYPE_PYOBJ +// Will convert any items that are not VTYPE_PYOBJ to this type and put them back on the stack. +// If any conversions of non-immediate values are needed, then it uses REG_ARG_1, REG_ARG_2 and REG_RET. +// Otherwise, it does not use any temporary registers (but may use reg_dest before loading it with stack pointer). +STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_pop) { + need_reg_all(emit); + + // First, store any immediate values to their respective place on the stack. + for (mp_uint_t i = 0; i < n_pop; i++) { + stack_info_t *si = &emit->stack_info[emit->stack_size - 1 - i]; + // must push any imm's to stack + // must convert them to VTYPE_PYOBJ for viper code + if (si->kind == STACK_IMM) { + si->kind = STACK_VALUE; + switch (si->vtype) { + case VTYPE_PYOBJ: + ASM_MOV_IMM_TO_LOCAL_USING(emit->as, si->data.u_imm, emit->stack_start + emit->stack_size - 1 - i, reg_dest); + break; + case VTYPE_BOOL: + if (si->data.u_imm == 0) { + ASM_MOV_IMM_TO_LOCAL_USING(emit->as, (mp_uint_t)mp_const_false, emit->stack_start + emit->stack_size - 1 - i, reg_dest); + } else { + ASM_MOV_IMM_TO_LOCAL_USING(emit->as, (mp_uint_t)mp_const_true, emit->stack_start + emit->stack_size - 1 - i, reg_dest); + } + si->vtype = VTYPE_PYOBJ; + break; + case VTYPE_INT: + case VTYPE_UINT: + ASM_MOV_IMM_TO_LOCAL_USING(emit->as, (uintptr_t)MP_OBJ_NEW_SMALL_INT(si->data.u_imm), emit->stack_start + emit->stack_size - 1 - i, reg_dest); + si->vtype = VTYPE_PYOBJ; + break; + default: + // not handled + mp_raise_NotImplementedError("conversion to object"); + } + } + + // verify that this value is on the stack + assert(si->kind == STACK_VALUE); + } + + // Second, convert any non-VTYPE_PYOBJ to that type. + for (mp_uint_t i = 0; i < n_pop; i++) { + stack_info_t *si = &emit->stack_info[emit->stack_size - 1 - i]; + if (si->vtype != VTYPE_PYOBJ) { + mp_uint_t local_num = emit->stack_start + emit->stack_size - 1 - i; + ASM_MOV_LOCAL_TO_REG(emit->as, local_num, REG_ARG_1); + emit_call_with_imm_arg(emit, MP_F_CONVERT_NATIVE_TO_OBJ, si->vtype, REG_ARG_2); // arg2 = type + ASM_MOV_REG_TO_LOCAL(emit->as, REG_RET, local_num); + si->vtype = VTYPE_PYOBJ; + DEBUG_printf(" convert_native_to_obj(local_num=" UINT_FMT ")\n", local_num); + } + } + + // Adujust the stack for a pop of n_pop items, and load the stack pointer into reg_dest. + adjust_stack(emit, -n_pop); + ASM_MOV_LOCAL_ADDR_TO_REG(emit->as, emit->stack_start + emit->stack_size, reg_dest); +} + +// vtype of all n_push objects is VTYPE_PYOBJ +STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_push) { + need_reg_all(emit); + for (mp_uint_t i = 0; i < n_push; i++) { + emit->stack_info[emit->stack_size + i].kind = STACK_VALUE; + emit->stack_info[emit->stack_size + i].vtype = VTYPE_PYOBJ; + } + ASM_MOV_LOCAL_ADDR_TO_REG(emit->as, emit->stack_start + emit->stack_size, reg_dest); + adjust_stack(emit, n_push); +} + +STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) { + DEBUG_printf("label_assign(" UINT_FMT ")\n", l); + emit_native_pre(emit); + // need to commit stack because we can jump here from elsewhere + need_stack_settled(emit); + mp_asm_base_label_assign(&emit->as->base, l); + emit_post(emit); +} + +STATIC void emit_native_import_name(emit_t *emit, qstr qst) { + DEBUG_printf("import_name %s\n", qstr_str(qst)); + + // get arguments from stack: arg2 = fromlist, arg3 = level + // if using viper types these arguments must be converted to proper objects + if (emit->do_viper_types) { + // fromlist should be None or a tuple + stack_info_t *top = peek_stack(emit, 0); + if (top->vtype == VTYPE_PTR_NONE) { + emit_pre_pop_discard(emit); + ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)mp_const_none, REG_ARG_2); + } else { + vtype_kind_t vtype_fromlist; + emit_pre_pop_reg(emit, &vtype_fromlist, REG_ARG_2); + assert(vtype_fromlist == VTYPE_PYOBJ); + } + + // level argument should be an immediate integer + top = peek_stack(emit, 0); + assert(top->vtype == VTYPE_INT && top->kind == STACK_IMM); + ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)MP_OBJ_NEW_SMALL_INT(top->data.u_imm), REG_ARG_3); + emit_pre_pop_discard(emit); + + } else { + vtype_kind_t vtype_fromlist; + vtype_kind_t vtype_level; + emit_pre_pop_reg_reg(emit, &vtype_fromlist, REG_ARG_2, &vtype_level, REG_ARG_3); + assert(vtype_fromlist == VTYPE_PYOBJ); + assert(vtype_level == VTYPE_PYOBJ); + } + + emit_call_with_imm_arg(emit, MP_F_IMPORT_NAME, qst, REG_ARG_1); // arg1 = import name + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_import_from(emit_t *emit, qstr qst) { + DEBUG_printf("import_from %s\n", qstr_str(qst)); + emit_native_pre(emit); + vtype_kind_t vtype_module; + emit_access_stack(emit, 1, &vtype_module, REG_ARG_1); // arg1 = module + assert(vtype_module == VTYPE_PYOBJ); + emit_call_with_imm_arg(emit, MP_F_IMPORT_FROM, qst, REG_ARG_2); // arg2 = import name + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_import_star(emit_t *emit) { + DEBUG_printf("import_star\n"); + vtype_kind_t vtype_module; + emit_pre_pop_reg(emit, &vtype_module, REG_ARG_1); // arg1 = module + assert(vtype_module == VTYPE_PYOBJ); + emit_call(emit, MP_F_IMPORT_ALL); + emit_post(emit); +} + +STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) { + DEBUG_printf("load_const_tok(tok=%u)\n", tok); + emit_native_pre(emit); + vtype_kind_t vtype; + mp_uint_t val; + if (emit->do_viper_types) { + switch (tok) { + case MP_TOKEN_KW_NONE: vtype = VTYPE_PTR_NONE; val = 0; break; + case MP_TOKEN_KW_FALSE: vtype = VTYPE_BOOL; val = 0; break; + case MP_TOKEN_KW_TRUE: vtype = VTYPE_BOOL; val = 1; break; + default: + assert(tok == MP_TOKEN_ELLIPSIS); + vtype = VTYPE_PYOBJ; val = (mp_uint_t)&mp_const_ellipsis_obj; break; + } + } else { + vtype = VTYPE_PYOBJ; + switch (tok) { + case MP_TOKEN_KW_NONE: val = (mp_uint_t)mp_const_none; break; + case MP_TOKEN_KW_FALSE: val = (mp_uint_t)mp_const_false; break; + case MP_TOKEN_KW_TRUE: val = (mp_uint_t)mp_const_true; break; + default: + assert(tok == MP_TOKEN_ELLIPSIS); + val = (mp_uint_t)&mp_const_ellipsis_obj; break; + } + } + emit_post_push_imm(emit, vtype, val); +} + +STATIC void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) { + DEBUG_printf("load_const_small_int(int=" INT_FMT ")\n", arg); + emit_native_pre(emit); + if (emit->do_viper_types) { + emit_post_push_imm(emit, VTYPE_INT, arg); + } else { + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)MP_OBJ_NEW_SMALL_INT(arg)); + } +} + +STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) { + emit_native_pre(emit); + // TODO: Eventually we want to be able to work with raw pointers in viper to + // do native array access. For now we just load them as any other object. + /* + if (emit->do_viper_types) { + // load a pointer to the asciiz string? + emit_post_push_imm(emit, VTYPE_PTR, (mp_uint_t)qstr_str(qst)); + } else + */ + { + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)MP_OBJ_NEW_QSTR(qst)); + } +} + +STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) { + emit_native_pre(emit); + need_reg_single(emit, REG_RET, 0); + ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, (mp_uint_t)obj, REG_RET); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_load_null(emit_t *emit) { + emit_native_pre(emit); + emit_post_push_imm(emit, VTYPE_PYOBJ, 0); +} + +STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + DEBUG_printf("load_fast(%s, " UINT_FMT ")\n", qstr_str(qst), local_num); + vtype_kind_t vtype = emit->local_vtype[local_num]; + if (vtype == VTYPE_UNBOUND) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "local '%q' used before type known", qst); + } + emit_native_pre(emit); + if (local_num == 0) { + emit_post_push_reg(emit, vtype, REG_LOCAL_1); + } else if (local_num == 1) { + emit_post_push_reg(emit, vtype, REG_LOCAL_2); + } else if (local_num == 2) { + emit_post_push_reg(emit, vtype, REG_LOCAL_3); + } else { + need_reg_single(emit, REG_TEMP0, 0); + if (emit->do_viper_types) { + ASM_MOV_LOCAL_TO_REG(emit->as, local_num - REG_LOCAL_NUM, REG_TEMP0); + } else { + ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - local_num, REG_TEMP0); + } + emit_post_push_reg(emit, vtype, REG_TEMP0); + } +} + +STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + DEBUG_printf("load_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num); + need_reg_single(emit, REG_RET, 0); + emit_native_load_fast(emit, qst, local_num); + vtype_kind_t vtype; + int reg_base = REG_RET; + emit_pre_pop_reg_flexible(emit, &vtype, ®_base, -1, -1); + ASM_LOAD_REG_REG_OFFSET(emit->as, REG_RET, reg_base, 1); + // closed over vars are always Python objects + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_load_name(emit_t *emit, qstr qst) { + DEBUG_printf("load_name(%s)\n", qstr_str(qst)); + emit_native_pre(emit); + emit_call_with_imm_arg(emit, MP_F_LOAD_NAME, qst, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_load_global(emit_t *emit, qstr qst) { + DEBUG_printf("load_global(%s)\n", qstr_str(qst)); + emit_native_pre(emit); + // check for builtin casting operators + if (emit->do_viper_types && qst == MP_QSTR_int) { + emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_INT); + } else if (emit->do_viper_types && qst == MP_QSTR_uint) { + emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_UINT); + } else if (emit->do_viper_types && qst == MP_QSTR_ptr) { + emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR); + } else if (emit->do_viper_types && qst == MP_QSTR_ptr8) { + emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR8); + } else if (emit->do_viper_types && qst == MP_QSTR_ptr16) { + emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR16); + } else if (emit->do_viper_types && qst == MP_QSTR_ptr32) { + emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR32); + } else { + emit_call_with_imm_arg(emit, MP_F_LOAD_GLOBAL, qst, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } +} + +STATIC void emit_native_load_attr(emit_t *emit, qstr qst) { + // depends on type of subject: + // - integer, function, pointer to integers: error + // - pointer to structure: get member, quite easy + // - Python object: call mp_load_attr, and needs to be typed to convert result + vtype_kind_t vtype_base; + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base + assert(vtype_base == VTYPE_PYOBJ); + emit_call_with_imm_arg(emit, MP_F_LOAD_ATTR, qst, REG_ARG_2); // arg2 = attribute name + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) { + if (is_super) { + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, 3); // arg2 = dest ptr + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_2, 2); // arg2 = dest ptr + emit_call_with_imm_arg(emit, MP_F_LOAD_SUPER_METHOD, qst, REG_ARG_1); // arg1 = method name + } else { + vtype_kind_t vtype_base; + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base + assert(vtype_base == VTYPE_PYOBJ); + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, 2); // arg3 = dest ptr + emit_call_with_imm_arg(emit, MP_F_LOAD_METHOD, qst, REG_ARG_2); // arg2 = method name + } +} + +STATIC void emit_native_load_build_class(emit_t *emit) { + emit_native_pre(emit); + emit_call(emit, MP_F_LOAD_BUILD_CLASS); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_load_subscr(emit_t *emit) { + DEBUG_printf("load_subscr\n"); + // need to compile: base[index] + + // pop: index, base + // optimise case where index is an immediate + vtype_kind_t vtype_base = peek_vtype(emit, 1); + + if (vtype_base == VTYPE_PYOBJ) { + // standard Python subscr + // TODO factor this implicit cast code with other uses of it + vtype_kind_t vtype_index = peek_vtype(emit, 0); + if (vtype_index == VTYPE_PYOBJ) { + emit_pre_pop_reg(emit, &vtype_index, REG_ARG_2); + } else { + emit_pre_pop_reg(emit, &vtype_index, REG_ARG_1); + emit_call_with_imm_arg(emit, MP_F_CONVERT_NATIVE_TO_OBJ, vtype_index, REG_ARG_2); // arg2 = type + ASM_MOV_REG_REG(emit->as, REG_ARG_2, REG_RET); + } + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); + emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_SENTINEL, REG_ARG_3); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } else { + // viper load + // TODO The different machine architectures have very different + // capabilities and requirements for loads, so probably best to + // write a completely separate load-optimiser for each one. + stack_info_t *top = peek_stack(emit, 0); + if (top->vtype == VTYPE_INT && top->kind == STACK_IMM) { + // index is an immediate + mp_int_t index_value = top->data.u_imm; + emit_pre_pop_discard(emit); // discard index + int reg_base = REG_ARG_1; + int reg_index = REG_ARG_2; + emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_index); + switch (vtype_base) { + case VTYPE_PTR8: { + // pointer to 8-bit memory + // TODO optimise to use thumb ldrb r1, [r2, r3] + if (index_value != 0) { + // index is non-zero + #if N_THUMB + if (index_value > 0 && index_value < 32) { + asm_thumb_ldrb_rlo_rlo_i5(emit->as, REG_RET, reg_base, index_value); + break; + } + #endif + ASM_MOV_IMM_TO_REG(emit->as, index_value, reg_index); + ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add index to base + reg_base = reg_index; + } + ASM_LOAD8_REG_REG(emit->as, REG_RET, reg_base); // load from (base+index) + break; + } + case VTYPE_PTR16: { + // pointer to 16-bit memory + if (index_value != 0) { + // index is a non-zero immediate + #if N_THUMB + if (index_value > 0 && index_value < 32) { + asm_thumb_ldrh_rlo_rlo_i5(emit->as, REG_RET, reg_base, index_value); + break; + } + #endif + ASM_MOV_IMM_TO_REG(emit->as, index_value << 1, reg_index); + ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 2*index to base + reg_base = reg_index; + } + ASM_LOAD16_REG_REG(emit->as, REG_RET, reg_base); // load from (base+2*index) + break; + } + case VTYPE_PTR32: { + // pointer to 32-bit memory + if (index_value != 0) { + // index is a non-zero immediate + #if N_THUMB + if (index_value > 0 && index_value < 32) { + asm_thumb_ldr_rlo_rlo_i5(emit->as, REG_RET, reg_base, index_value); + break; + } + #endif + ASM_MOV_IMM_TO_REG(emit->as, index_value << 2, reg_index); + ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 4*index to base + reg_base = reg_index; + } + ASM_LOAD32_REG_REG(emit->as, REG_RET, reg_base); // load from (base+4*index) + break; + } + default: + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't load from '%q'", vtype_to_qstr(vtype_base)); + } + } else { + // index is not an immediate + vtype_kind_t vtype_index; + int reg_index = REG_ARG_2; + emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, REG_ARG_1); + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); + if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't load with '%q' index", vtype_to_qstr(vtype_index)); + } + switch (vtype_base) { + case VTYPE_PTR8: { + // pointer to 8-bit memory + // TODO optimise to use thumb ldrb r1, [r2, r3] + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_LOAD8_REG_REG(emit->as, REG_RET, REG_ARG_1); // store value to (base+index) + break; + } + case VTYPE_PTR16: { + // pointer to 16-bit memory + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_LOAD16_REG_REG(emit->as, REG_RET, REG_ARG_1); // load from (base+2*index) + break; + } + case VTYPE_PTR32: { + // pointer to word-size memory + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_LOAD32_REG_REG(emit->as, REG_RET, REG_ARG_1); // load from (base+4*index) + break; + } + default: + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't load from '%q'", vtype_to_qstr(vtype_base)); + } + } + emit_post_push_reg(emit, VTYPE_INT, REG_RET); + } +} + +STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + vtype_kind_t vtype; + if (local_num == 0) { + emit_pre_pop_reg(emit, &vtype, REG_LOCAL_1); + } else if (local_num == 1) { + emit_pre_pop_reg(emit, &vtype, REG_LOCAL_2); + } else if (local_num == 2) { + emit_pre_pop_reg(emit, &vtype, REG_LOCAL_3); + } else { + emit_pre_pop_reg(emit, &vtype, REG_TEMP0); + if (emit->do_viper_types) { + ASM_MOV_REG_TO_LOCAL(emit->as, REG_TEMP0, local_num - REG_LOCAL_NUM); + } else { + ASM_MOV_REG_TO_LOCAL(emit->as, REG_TEMP0, STATE_START + emit->n_state - 1 - local_num); + } + } + emit_post(emit); + + // check types + if (emit->local_vtype[local_num] == VTYPE_UNBOUND) { + // first time this local is assigned, so give it a type of the object stored in it + emit->local_vtype[local_num] = vtype; + } else if (emit->local_vtype[local_num] != vtype) { + // type of local is not the same as object stored in it + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "local '%q' has type '%q' but source is '%q'", + qst, vtype_to_qstr(emit->local_vtype[local_num]), vtype_to_qstr(vtype)); + } +} + +STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + DEBUG_printf("store_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num); + need_reg_single(emit, REG_TEMP0, 0); + need_reg_single(emit, REG_TEMP1, 0); + emit_native_load_fast(emit, qst, local_num); + vtype_kind_t vtype; + int reg_base = REG_TEMP0; + emit_pre_pop_reg_flexible(emit, &vtype, ®_base, -1, -1); + int reg_src = REG_TEMP1; + emit_pre_pop_reg_flexible(emit, &vtype, ®_src, reg_base, reg_base); + ASM_STORE_REG_REG_OFFSET(emit->as, reg_src, reg_base, 1); + emit_post(emit); +} + +STATIC void emit_native_store_name(emit_t *emit, qstr qst) { + // mp_store_name, but needs conversion of object (maybe have mp_viper_store_name(obj, type)) + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_ARG_2); + assert(vtype == VTYPE_PYOBJ); + emit_call_with_imm_arg(emit, MP_F_STORE_NAME, qst, REG_ARG_1); // arg1 = name + emit_post(emit); +} + +STATIC void emit_native_store_global(emit_t *emit, qstr qst) { + vtype_kind_t vtype = peek_vtype(emit, 0); + if (vtype == VTYPE_PYOBJ) { + emit_pre_pop_reg(emit, &vtype, REG_ARG_2); + } else { + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); + emit_call_with_imm_arg(emit, MP_F_CONVERT_NATIVE_TO_OBJ, vtype, REG_ARG_2); // arg2 = type + ASM_MOV_REG_REG(emit->as, REG_ARG_2, REG_RET); + } + emit_call_with_imm_arg(emit, MP_F_STORE_GLOBAL, qst, REG_ARG_1); // arg1 = name + emit_post(emit); +} + +STATIC void emit_native_store_attr(emit_t *emit, qstr qst) { + vtype_kind_t vtype_base, vtype_val; + emit_pre_pop_reg_reg(emit, &vtype_base, REG_ARG_1, &vtype_val, REG_ARG_3); // arg1 = base, arg3 = value + assert(vtype_base == VTYPE_PYOBJ); + assert(vtype_val == VTYPE_PYOBJ); + emit_call_with_imm_arg(emit, MP_F_STORE_ATTR, qst, REG_ARG_2); // arg2 = attribute name + emit_post(emit); +} + +STATIC void emit_native_store_subscr(emit_t *emit) { + DEBUG_printf("store_subscr\n"); + // need to compile: base[index] = value + + // pop: index, base, value + // optimise case where index is an immediate + vtype_kind_t vtype_base = peek_vtype(emit, 1); + + if (vtype_base == VTYPE_PYOBJ) { + // standard Python subscr + vtype_kind_t vtype_index = peek_vtype(emit, 0); + vtype_kind_t vtype_value = peek_vtype(emit, 2); + if (vtype_index != VTYPE_PYOBJ || vtype_value != VTYPE_PYOBJ) { + // need to implicitly convert non-objects to objects + // TODO do this properly + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, 3); + adjust_stack(emit, 3); + } + emit_pre_pop_reg_reg_reg(emit, &vtype_index, REG_ARG_2, &vtype_base, REG_ARG_1, &vtype_value, REG_ARG_3); + emit_call(emit, MP_F_OBJ_SUBSCR); + } else { + // viper store + // TODO The different machine architectures have very different + // capabilities and requirements for stores, so probably best to + // write a completely separate store-optimiser for each one. + stack_info_t *top = peek_stack(emit, 0); + if (top->vtype == VTYPE_INT && top->kind == STACK_IMM) { + // index is an immediate + mp_int_t index_value = top->data.u_imm; + emit_pre_pop_discard(emit); // discard index + vtype_kind_t vtype_value; + int reg_base = REG_ARG_1; + int reg_index = REG_ARG_2; + int reg_value = REG_ARG_3; + emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_value); + #if N_X86 + // special case: x86 needs byte stores to be from lower 4 regs (REG_ARG_3 is EDX) + emit_pre_pop_reg(emit, &vtype_value, reg_value); + #else + emit_pre_pop_reg_flexible(emit, &vtype_value, ®_value, reg_base, reg_index); + #endif + if (vtype_value != VTYPE_BOOL && vtype_value != VTYPE_INT && vtype_value != VTYPE_UINT) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't store '%q'", vtype_to_qstr(vtype_value)); + } + switch (vtype_base) { + case VTYPE_PTR8: { + // pointer to 8-bit memory + // TODO optimise to use thumb strb r1, [r2, r3] + if (index_value != 0) { + // index is non-zero + #if N_THUMB + if (index_value > 0 && index_value < 32) { + asm_thumb_strb_rlo_rlo_i5(emit->as, reg_value, reg_base, index_value); + break; + } + #endif + ASM_MOV_IMM_TO_REG(emit->as, index_value, reg_index); + #if N_ARM + asm_arm_strb_reg_reg_reg(emit->as, reg_value, reg_base, reg_index); + return; + #endif + ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add index to base + reg_base = reg_index; + } + ASM_STORE8_REG_REG(emit->as, reg_value, reg_base); // store value to (base+index) + break; + } + case VTYPE_PTR16: { + // pointer to 16-bit memory + if (index_value != 0) { + // index is a non-zero immediate + #if N_THUMB + if (index_value > 0 && index_value < 32) { + asm_thumb_strh_rlo_rlo_i5(emit->as, reg_value, reg_base, index_value); + break; + } + #endif + ASM_MOV_IMM_TO_REG(emit->as, index_value << 1, reg_index); + #if N_ARM + asm_arm_strh_reg_reg_reg(emit->as, reg_value, reg_base, reg_index); + return; + #endif + ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 2*index to base + reg_base = reg_index; + } + ASM_STORE16_REG_REG(emit->as, reg_value, reg_base); // store value to (base+2*index) + break; + } + case VTYPE_PTR32: { + // pointer to 32-bit memory + if (index_value != 0) { + // index is a non-zero immediate + #if N_THUMB + if (index_value > 0 && index_value < 32) { + asm_thumb_str_rlo_rlo_i5(emit->as, reg_value, reg_base, index_value); + break; + } + #endif + ASM_MOV_IMM_TO_REG(emit->as, index_value << 2, reg_index); + #if N_ARM + asm_arm_str_reg_reg_reg(emit->as, reg_value, reg_base, reg_index); + return; + #endif + ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 4*index to base + reg_base = reg_index; + } + ASM_STORE32_REG_REG(emit->as, reg_value, reg_base); // store value to (base+4*index) + break; + } + default: + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't store to '%q'", vtype_to_qstr(vtype_base)); + } + } else { + // index is not an immediate + vtype_kind_t vtype_index, vtype_value; + int reg_index = REG_ARG_2; + int reg_value = REG_ARG_3; + emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, reg_value); + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); + if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't store with '%q' index", vtype_to_qstr(vtype_index)); + } + #if N_X86 + // special case: x86 needs byte stores to be from lower 4 regs (REG_ARG_3 is EDX) + emit_pre_pop_reg(emit, &vtype_value, reg_value); + #else + emit_pre_pop_reg_flexible(emit, &vtype_value, ®_value, REG_ARG_1, reg_index); + #endif + if (vtype_value != VTYPE_BOOL && vtype_value != VTYPE_INT && vtype_value != VTYPE_UINT) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't store '%q'", vtype_to_qstr(vtype_value)); + } + switch (vtype_base) { + case VTYPE_PTR8: { + // pointer to 8-bit memory + // TODO optimise to use thumb strb r1, [r2, r3] + #if N_ARM + asm_arm_strb_reg_reg_reg(emit->as, reg_value, REG_ARG_1, reg_index); + break; + #endif + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_STORE8_REG_REG(emit->as, reg_value, REG_ARG_1); // store value to (base+index) + break; + } + case VTYPE_PTR16: { + // pointer to 16-bit memory + #if N_ARM + asm_arm_strh_reg_reg_reg(emit->as, reg_value, REG_ARG_1, reg_index); + break; + #endif + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_STORE16_REG_REG(emit->as, reg_value, REG_ARG_1); // store value to (base+2*index) + break; + } + case VTYPE_PTR32: { + // pointer to 32-bit memory + #if N_ARM + asm_arm_str_reg_reg_reg(emit->as, reg_value, REG_ARG_1, reg_index); + break; + #endif + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base + ASM_STORE32_REG_REG(emit->as, reg_value, REG_ARG_1); // store value to (base+4*index) + break; + } + default: + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't store to '%q'", vtype_to_qstr(vtype_base)); + } + } + + } +} + +STATIC void emit_native_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { + // TODO: This is not compliant implementation. We could use MP_OBJ_SENTINEL + // to mark deleted vars but then every var would need to be checked on + // each access. Very inefficient, so just set value to None to enable GC. + emit_native_load_const_tok(emit, MP_TOKEN_KW_NONE); + emit_native_store_fast(emit, qst, local_num); +} + +STATIC void emit_native_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { + // TODO implement me! + (void)emit; + (void)qst; + (void)local_num; +} + +STATIC void emit_native_delete_name(emit_t *emit, qstr qst) { + emit_native_pre(emit); + emit_call_with_imm_arg(emit, MP_F_DELETE_NAME, qst, REG_ARG_1); + emit_post(emit); +} + +STATIC void emit_native_delete_global(emit_t *emit, qstr qst) { + emit_native_pre(emit); + emit_call_with_imm_arg(emit, MP_F_DELETE_GLOBAL, qst, REG_ARG_1); + emit_post(emit); +} + +STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) { + vtype_kind_t vtype_base; + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base + assert(vtype_base == VTYPE_PYOBJ); + emit_call_with_2_imm_args(emit, MP_F_STORE_ATTR, qst, REG_ARG_2, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); // arg2 = attribute name, arg3 = value (null for delete) + emit_post(emit); +} + +STATIC void emit_native_delete_subscr(emit_t *emit) { + vtype_kind_t vtype_index, vtype_base; + emit_pre_pop_reg_reg(emit, &vtype_index, REG_ARG_2, &vtype_base, REG_ARG_1); // index, base + assert(vtype_index == VTYPE_PYOBJ); + assert(vtype_base == VTYPE_PYOBJ); + emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); +} + +STATIC void emit_native_dup_top(emit_t *emit) { + DEBUG_printf("dup_top\n"); + vtype_kind_t vtype; + int reg = REG_TEMP0; + emit_pre_pop_reg_flexible(emit, &vtype, ®, -1, -1); + emit_post_push_reg_reg(emit, vtype, reg, vtype, reg); +} + +STATIC void emit_native_dup_top_two(emit_t *emit) { + vtype_kind_t vtype0, vtype1; + emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1); + emit_post_push_reg_reg_reg_reg(emit, vtype1, REG_TEMP1, vtype0, REG_TEMP0, vtype1, REG_TEMP1, vtype0, REG_TEMP0); +} + +STATIC void emit_native_pop_top(emit_t *emit) { + DEBUG_printf("pop_top\n"); + emit_pre_pop_discard(emit); + emit_post(emit); +} + +STATIC void emit_native_rot_two(emit_t *emit) { + DEBUG_printf("rot_two\n"); + vtype_kind_t vtype0, vtype1; + emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1); + emit_post_push_reg_reg(emit, vtype0, REG_TEMP0, vtype1, REG_TEMP1); +} + +STATIC void emit_native_rot_three(emit_t *emit) { + DEBUG_printf("rot_three\n"); + vtype_kind_t vtype0, vtype1, vtype2; + emit_pre_pop_reg_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1, &vtype2, REG_TEMP2); + emit_post_push_reg_reg_reg(emit, vtype0, REG_TEMP0, vtype2, REG_TEMP2, vtype1, REG_TEMP1); +} + +STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) { + DEBUG_printf("jump(label=" UINT_FMT ")\n", label); + emit_native_pre(emit); + // need to commit stack because we are jumping elsewhere + need_stack_settled(emit); + ASM_JUMP(emit->as, label); + emit_post(emit); +} + +STATIC void emit_native_jump_helper(emit_t *emit, bool pop) { + vtype_kind_t vtype = peek_vtype(emit, 0); + if (vtype == VTYPE_PYOBJ) { + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); + if (!pop) { + adjust_stack(emit, 1); + } + emit_call(emit, MP_F_OBJ_IS_TRUE); + } else { + emit_pre_pop_reg(emit, &vtype, REG_RET); + if (!pop) { + adjust_stack(emit, 1); + } + if (!(vtype == VTYPE_BOOL || vtype == VTYPE_INT || vtype == VTYPE_UINT)) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't implicitly convert '%q' to 'bool'", vtype_to_qstr(vtype)); + } + } + // For non-pop need to save the vtype so that emit_native_adjust_stack_size + // can use it. This is a bit of a hack. + if (!pop) { + emit->saved_stack_vtype = vtype; + } + // need to commit stack because we may jump elsewhere + need_stack_settled(emit); +} + +STATIC void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) { + DEBUG_printf("pop_jump_if(cond=%u, label=" UINT_FMT ")\n", cond, label); + emit_native_jump_helper(emit, true); + if (cond) { + ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); + } else { + ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label); + } + emit_post(emit); +} + +STATIC void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) { + DEBUG_printf("jump_if_or_pop(cond=%u, label=" UINT_FMT ")\n", cond, label); + emit_native_jump_helper(emit, false); + if (cond) { + ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); + } else { + ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label); + } + adjust_stack(emit, -1); + emit_post(emit); +} + +STATIC void emit_native_break_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { + (void)except_depth; + emit_native_jump(emit, label & ~MP_EMIT_BREAK_FROM_FOR); // TODO properly +} + +STATIC void emit_native_continue_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { + (void)except_depth; + emit_native_jump(emit, label); // TODO properly +} + +STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) { + // the context manager is on the top of the stack + // stack: (..., ctx_mgr) + + // get __exit__ method + vtype_kind_t vtype; + emit_access_stack(emit, 1, &vtype, REG_ARG_1); // arg1 = ctx_mgr + assert(vtype == VTYPE_PYOBJ); + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, 2); // arg3 = dest ptr + emit_call_with_imm_arg(emit, MP_F_LOAD_METHOD, MP_QSTR___exit__, REG_ARG_2); + // stack: (..., ctx_mgr, __exit__, self) + + emit_pre_pop_reg(emit, &vtype, REG_ARG_3); // self + emit_pre_pop_reg(emit, &vtype, REG_ARG_2); // __exit__ + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); // ctx_mgr + emit_post_push_reg(emit, vtype, REG_ARG_2); // __exit__ + emit_post_push_reg(emit, vtype, REG_ARG_3); // self + // stack: (..., __exit__, self) + // REG_ARG_1=ctx_mgr + + // get __enter__ method + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, 2); // arg3 = dest ptr + emit_call_with_imm_arg(emit, MP_F_LOAD_METHOD, MP_QSTR___enter__, REG_ARG_2); // arg2 = method name + // stack: (..., __exit__, self, __enter__, self) + + // call __enter__ method + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 2); // pointer to items, including meth and self + emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, 0, REG_ARG_1, 0, REG_ARG_2); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // push return value of __enter__ + // stack: (..., __exit__, self, as_value) + + // need to commit stack because we may jump elsewhere + need_stack_settled(emit); + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_1, sizeof(nlr_buf_t) / sizeof(mp_uint_t)); // arg1 = pointer to nlr buf + emit_call(emit, MP_F_NLR_PUSH); + ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); + + emit_access_stack(emit, sizeof(nlr_buf_t) / sizeof(mp_uint_t) + 1, &vtype, REG_RET); // access return value of __enter__ + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // push return value of __enter__ + // stack: (..., __exit__, self, as_value, nlr_buf, as_value) +} + +STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) { + // note: label+1 is available as an auxiliary label + + // stack: (..., __exit__, self, as_value, nlr_buf) + emit_native_pre(emit); + emit_call(emit, MP_F_NLR_POP); + adjust_stack(emit, -(mp_int_t)(sizeof(nlr_buf_t) / sizeof(mp_uint_t)) - 1); + // stack: (..., __exit__, self) + + // call __exit__ + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 5); + emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, 3, REG_ARG_1, 0, REG_ARG_2); + + // jump to after with cleanup nlr_catch block + adjust_stack(emit, 1); // dummy nlr_buf.prev + emit_native_load_const_tok(emit, MP_TOKEN_KW_NONE); // nlr_buf.ret_val = no exception + emit_native_jump(emit, label + 1); + + // nlr_catch + emit_native_label_assign(emit, label); + + // adjust stack counter for: __exit__, self, as_value + adjust_stack(emit, 3); + // stack: (..., __exit__, self, as_value, nlr_buf.prev, nlr_buf.ret_val) + + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); // get the thrown value (exc) + adjust_stack(emit, -2); // discard nlr_buf.prev and as_value + // stack: (..., __exit__, self) + // REG_ARG_1=exc + + emit_pre_pop_reg(emit, &vtype, REG_ARG_2); // self + emit_pre_pop_reg(emit, &vtype, REG_ARG_3); // __exit__ + adjust_stack(emit, 1); // dummy nlr_buf.prev + emit_post_push_reg(emit, vtype, REG_ARG_1); // push exc to save it for later + emit_post_push_reg(emit, vtype, REG_ARG_3); // __exit__ + emit_post_push_reg(emit, vtype, REG_ARG_2); // self + // stack: (..., exc, __exit__, self) + // REG_ARG_1=exc + + ASM_LOAD_REG_REG_OFFSET(emit->as, REG_ARG_2, REG_ARG_1, 0); // get type(exc) + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_ARG_2); // push type(exc) + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_ARG_1); // push exc value + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); // traceback info + // stack: (..., exc, __exit__, self, type(exc), exc, traceback) + + // call __exit__ method + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 5); + emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, 3, REG_ARG_1, 0, REG_ARG_2); + // stack: (..., exc) + + // if REG_RET is true then we need to replace top-of-stack with None (swallow exception) + if (REG_ARG_1 != REG_RET) { + ASM_MOV_REG_REG(emit->as, REG_ARG_1, REG_RET); + } + emit_call(emit, MP_F_OBJ_IS_TRUE); + ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label + 1); + + // replace exc with None + emit_pre_pop_discard(emit); + emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); + + // end of with cleanup nlr_catch block + emit_native_label_assign(emit, label + 1); +} + +STATIC void emit_native_setup_except(emit_t *emit, mp_uint_t label) { + emit_native_pre(emit); + // need to commit stack because we may jump elsewhere + need_stack_settled(emit); + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_1, sizeof(nlr_buf_t) / sizeof(mp_uint_t)); // arg1 = pointer to nlr buf + emit_call(emit, MP_F_NLR_PUSH); + ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); + emit_post(emit); +} + +STATIC void emit_native_setup_finally(emit_t *emit, mp_uint_t label) { + emit_native_setup_except(emit, label); +} + +STATIC void emit_native_end_finally(emit_t *emit) { + // logic: + // exc = pop_stack + // if exc == None: pass + // else: raise exc + // the check if exc is None is done in the MP_F_NATIVE_RAISE stub + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); // get nlr_buf.ret_val + emit_pre_pop_discard(emit); // discard nlr_buf.prev + emit_call(emit, MP_F_NATIVE_RAISE); + emit_post(emit); +} + +STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) { + // perhaps the difficult one, as we want to rewrite for loops using native code + // in cases where we iterate over a Python object, can we use normal runtime calls? + + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); + assert(vtype == VTYPE_PYOBJ); + if (use_stack) { + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_2, MP_OBJ_ITER_BUF_NSLOTS); + emit_call(emit, MP_F_NATIVE_GETITER); + } else { + // mp_getiter will allocate the iter_buf on the heap + ASM_MOV_IMM_TO_REG(emit->as, 0, REG_ARG_2); + emit_call(emit, MP_F_NATIVE_GETITER); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } +} + +STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) { + emit_native_pre(emit); + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, MP_OBJ_ITER_BUF_NSLOTS); + adjust_stack(emit, MP_OBJ_ITER_BUF_NSLOTS); + emit_call(emit, MP_F_NATIVE_ITERNEXT); + ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)MP_OBJ_STOP_ITERATION, REG_TEMP1); + ASM_JUMP_IF_REG_EQ(emit->as, REG_RET, REG_TEMP1, label); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_for_iter_end(emit_t *emit) { + // adjust stack counter (we get here from for_iter ending, which popped the value for us) + emit_native_pre(emit); + adjust_stack(emit, -MP_OBJ_ITER_BUF_NSLOTS); + emit_post(emit); +} + +STATIC void emit_native_pop_block(emit_t *emit) { + emit_native_pre(emit); + emit_call(emit, MP_F_NLR_POP); + adjust_stack(emit, -(mp_int_t)(sizeof(nlr_buf_t) / sizeof(mp_uint_t)) + 1); + emit_post(emit); +} + +STATIC void emit_native_pop_except(emit_t *emit) { + (void)emit; +} + +STATIC void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) { + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_ARG_2); + if (vtype == VTYPE_PYOBJ) { + emit_call_with_imm_arg(emit, MP_F_UNARY_OP, op, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } else { + adjust_stack(emit, 1); + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "unary op %q not implemented", mp_unary_op_method_name[op]); + } +} + +STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) { + DEBUG_printf("binary_op(" UINT_FMT ")\n", op); + vtype_kind_t vtype_lhs = peek_vtype(emit, 1); + vtype_kind_t vtype_rhs = peek_vtype(emit, 0); + if (vtype_lhs == VTYPE_INT && vtype_rhs == VTYPE_INT) { + #if N_X64 || N_X86 + // special cases for x86 and shifting + if (op == MP_BINARY_OP_LSHIFT + || op == MP_BINARY_OP_INPLACE_LSHIFT + || op == MP_BINARY_OP_RSHIFT + || op == MP_BINARY_OP_INPLACE_RSHIFT) { + #if N_X64 + emit_pre_pop_reg_reg(emit, &vtype_rhs, ASM_X64_REG_RCX, &vtype_lhs, REG_RET); + #else + emit_pre_pop_reg_reg(emit, &vtype_rhs, ASM_X86_REG_ECX, &vtype_lhs, REG_RET); + #endif + if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) { + ASM_LSL_REG(emit->as, REG_RET); + } else { + ASM_ASR_REG(emit->as, REG_RET); + } + emit_post_push_reg(emit, VTYPE_INT, REG_RET); + return; + } + #endif + int reg_rhs = REG_ARG_3; + emit_pre_pop_reg_flexible(emit, &vtype_rhs, ®_rhs, REG_RET, REG_ARG_2); + emit_pre_pop_reg(emit, &vtype_lhs, REG_ARG_2); + if (0) { + // dummy + #if !(N_X64 || N_X86) + } else if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) { + ASM_LSL_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (op == MP_BINARY_OP_RSHIFT || op == MP_BINARY_OP_INPLACE_RSHIFT) { + ASM_ASR_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + #endif + } else if (op == MP_BINARY_OP_OR || op == MP_BINARY_OP_INPLACE_OR) { + ASM_OR_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (op == MP_BINARY_OP_XOR || op == MP_BINARY_OP_INPLACE_XOR) { + ASM_XOR_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (op == MP_BINARY_OP_AND || op == MP_BINARY_OP_INPLACE_AND) { + ASM_AND_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (op == MP_BINARY_OP_ADD || op == MP_BINARY_OP_INPLACE_ADD) { + ASM_ADD_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (op == MP_BINARY_OP_SUBTRACT || op == MP_BINARY_OP_INPLACE_SUBTRACT) { + ASM_SUB_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (op == MP_BINARY_OP_MULTIPLY || op == MP_BINARY_OP_INPLACE_MULTIPLY) { + ASM_MUL_REG_REG(emit->as, REG_ARG_2, reg_rhs); + emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); + } else if (MP_BINARY_OP_LESS <= op && op <= MP_BINARY_OP_NOT_EQUAL) { + // comparison ops are (in enum order): + // 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 + need_reg_single(emit, REG_RET, 0); + #if N_X64 + asm_x64_xor_r64_r64(emit->as, REG_RET, REG_RET); + asm_x64_cmp_r64_with_r64(emit->as, reg_rhs, REG_ARG_2); + static byte ops[6] = { + ASM_X64_CC_JL, + ASM_X64_CC_JG, + ASM_X64_CC_JE, + ASM_X64_CC_JLE, + ASM_X64_CC_JGE, + ASM_X64_CC_JNE, + }; + asm_x64_setcc_r8(emit->as, ops[op - MP_BINARY_OP_LESS], REG_RET); + #elif N_X86 + asm_x86_xor_r32_r32(emit->as, REG_RET, REG_RET); + asm_x86_cmp_r32_with_r32(emit->as, reg_rhs, REG_ARG_2); + static byte ops[6] = { + ASM_X86_CC_JL, + ASM_X86_CC_JG, + ASM_X86_CC_JE, + ASM_X86_CC_JLE, + ASM_X86_CC_JGE, + ASM_X86_CC_JNE, + }; + asm_x86_setcc_r8(emit->as, ops[op - MP_BINARY_OP_LESS], REG_RET); + #elif N_THUMB + asm_thumb_cmp_rlo_rlo(emit->as, REG_ARG_2, reg_rhs); + static uint16_t ops[6] = { + ASM_THUMB_OP_ITE_GE, + ASM_THUMB_OP_ITE_GT, + ASM_THUMB_OP_ITE_EQ, + ASM_THUMB_OP_ITE_GT, + ASM_THUMB_OP_ITE_GE, + ASM_THUMB_OP_ITE_EQ, + }; + static byte ret[6] = { 0, 1, 1, 0, 1, 0, }; + asm_thumb_op16(emit->as, ops[op - MP_BINARY_OP_LESS]); + asm_thumb_mov_rlo_i8(emit->as, REG_RET, ret[op - MP_BINARY_OP_LESS]); + asm_thumb_mov_rlo_i8(emit->as, REG_RET, ret[op - MP_BINARY_OP_LESS] ^ 1); + #elif N_ARM + asm_arm_cmp_reg_reg(emit->as, REG_ARG_2, reg_rhs); + static uint ccs[6] = { + ASM_ARM_CC_LT, + ASM_ARM_CC_GT, + ASM_ARM_CC_EQ, + ASM_ARM_CC_LE, + ASM_ARM_CC_GE, + ASM_ARM_CC_NE, + }; + asm_arm_setcc_reg(emit->as, REG_RET, ccs[op - MP_BINARY_OP_LESS]); + #elif N_XTENSA + static uint8_t ccs[6] = { + ASM_XTENSA_CC_LT, + 0x80 | ASM_XTENSA_CC_LT, // for GT we'll swap args + ASM_XTENSA_CC_EQ, + 0x80 | ASM_XTENSA_CC_GE, // for LE we'll swap args + ASM_XTENSA_CC_GE, + ASM_XTENSA_CC_NE, + }; + uint8_t cc = ccs[op - MP_BINARY_OP_LESS]; + if ((cc & 0x80) == 0) { + asm_xtensa_setcc_reg_reg_reg(emit->as, cc, REG_RET, REG_ARG_2, reg_rhs); + } else { + asm_xtensa_setcc_reg_reg_reg(emit->as, cc & ~0x80, REG_RET, reg_rhs, REG_ARG_2); + } + #else + #error not implemented + #endif + emit_post_push_reg(emit, VTYPE_BOOL, REG_RET); + } else { + // TODO other ops not yet implemented + adjust_stack(emit, 1); + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "binary op %q not implemented", mp_binary_op_method_name[op]); + } + } else if (vtype_lhs == VTYPE_PYOBJ && vtype_rhs == VTYPE_PYOBJ) { + emit_pre_pop_reg_reg(emit, &vtype_rhs, REG_ARG_3, &vtype_lhs, REG_ARG_2); + bool invert = false; + if (op == MP_BINARY_OP_NOT_IN) { + invert = true; + op = MP_BINARY_OP_IN; + } else if (op == MP_BINARY_OP_IS_NOT) { + invert = true; + op = MP_BINARY_OP_IS; + } + emit_call_with_imm_arg(emit, MP_F_BINARY_OP, op, REG_ARG_1); + if (invert) { + ASM_MOV_REG_REG(emit->as, REG_ARG_2, REG_RET); + emit_call_with_imm_arg(emit, MP_F_UNARY_OP, MP_UNARY_OP_NOT, REG_ARG_1); + } + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } else { + adjust_stack(emit, -1); + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "can't do binary op between '%q' and '%q'", + vtype_to_qstr(vtype_lhs), vtype_to_qstr(vtype_rhs)); + } +} + +STATIC void emit_native_build_tuple(emit_t *emit, mp_uint_t n_args) { + // for viper: call runtime, with types of args + // if wrapped in byte_array, or something, allocates memory and fills it + emit_native_pre(emit); + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items + emit_call_with_imm_arg(emit, MP_F_BUILD_TUPLE, n_args, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new tuple +} + +STATIC void emit_native_build_list(emit_t *emit, mp_uint_t n_args) { + emit_native_pre(emit); + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items + emit_call_with_imm_arg(emit, MP_F_BUILD_LIST, n_args, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new list +} + +STATIC void emit_native_build_map(emit_t *emit, mp_uint_t n_args) { + emit_native_pre(emit); + emit_call_with_imm_arg(emit, MP_F_BUILD_MAP, n_args, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new map +} + +STATIC void emit_native_store_map(emit_t *emit) { + vtype_kind_t vtype_key, vtype_value, vtype_map; + emit_pre_pop_reg_reg_reg(emit, &vtype_key, REG_ARG_2, &vtype_value, REG_ARG_3, &vtype_map, REG_ARG_1); // key, value, map + assert(vtype_key == VTYPE_PYOBJ); + assert(vtype_value == VTYPE_PYOBJ); + assert(vtype_map == VTYPE_PYOBJ); + emit_call(emit, MP_F_STORE_MAP); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // map +} + +#if MICROPY_PY_BUILTINS_SET +STATIC void emit_native_build_set(emit_t *emit, mp_uint_t n_args) { + emit_native_pre(emit); + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items + emit_call_with_imm_arg(emit, MP_F_BUILD_SET, n_args, REG_ARG_1); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new set +} +#endif + +#if MICROPY_PY_BUILTINS_SLICE +STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) { + DEBUG_printf("build_slice %d\n", n_args); + if (n_args == 2) { + vtype_kind_t vtype_start, vtype_stop; + emit_pre_pop_reg_reg(emit, &vtype_stop, REG_ARG_2, &vtype_start, REG_ARG_1); // arg1 = start, arg2 = stop + assert(vtype_start == VTYPE_PYOBJ); + assert(vtype_stop == VTYPE_PYOBJ); + emit_call_with_imm_arg(emit, MP_F_NEW_SLICE, (mp_uint_t)mp_const_none, REG_ARG_3); // arg3 = step + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } else { + assert(n_args == 3); + vtype_kind_t vtype_start, vtype_stop, vtype_step; + emit_pre_pop_reg_reg_reg(emit, &vtype_step, REG_ARG_3, &vtype_stop, REG_ARG_2, &vtype_start, REG_ARG_1); // arg1 = start, arg2 = stop, arg3 = step + assert(vtype_start == VTYPE_PYOBJ); + assert(vtype_stop == VTYPE_PYOBJ); + assert(vtype_step == VTYPE_PYOBJ); + emit_call(emit, MP_F_NEW_SLICE); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } +} +#endif + +STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_index) { + mp_fun_kind_t f; + if (kind == SCOPE_LIST_COMP) { + vtype_kind_t vtype_item; + emit_pre_pop_reg(emit, &vtype_item, REG_ARG_2); + assert(vtype_item == VTYPE_PYOBJ); + f = MP_F_LIST_APPEND; + #if MICROPY_PY_BUILTINS_SET + } else if (kind == SCOPE_SET_COMP) { + vtype_kind_t vtype_item; + emit_pre_pop_reg(emit, &vtype_item, REG_ARG_2); + assert(vtype_item == VTYPE_PYOBJ); + f = MP_F_STORE_SET; + #endif + } else { + // SCOPE_DICT_COMP + vtype_kind_t vtype_key, vtype_value; + emit_pre_pop_reg_reg(emit, &vtype_key, REG_ARG_2, &vtype_value, REG_ARG_3); + assert(vtype_key == VTYPE_PYOBJ); + assert(vtype_value == VTYPE_PYOBJ); + f = MP_F_STORE_MAP; + } + vtype_kind_t vtype_collection; + emit_access_stack(emit, collection_index, &vtype_collection, REG_ARG_1); + assert(vtype_collection == VTYPE_PYOBJ); + emit_call(emit, f); + emit_post(emit); +} + +STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) { + DEBUG_printf("unpack_sequence %d\n", n_args); + vtype_kind_t vtype_base; + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq + assert(vtype_base == VTYPE_PYOBJ); + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, n_args); // arg3 = dest ptr + emit_call_with_imm_arg(emit, MP_F_UNPACK_SEQUENCE, n_args, REG_ARG_2); // arg2 = n_args +} + +STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) { + DEBUG_printf("unpack_ex %d %d\n", n_left, n_right); + vtype_kind_t vtype_base; + emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq + assert(vtype_base == VTYPE_PYOBJ); + emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, n_left + n_right + 1); // arg3 = dest ptr + emit_call_with_imm_arg(emit, MP_F_UNPACK_EX, n_left | (n_right << 8), REG_ARG_2); // arg2 = n_left + n_right +} + +STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { + // call runtime, with type info for args, or don't support dict/default params, or only support Python objects for them + emit_native_pre(emit); + if (n_pos_defaults == 0 && n_kw_defaults == 0) { + emit_call_with_3_imm_args_and_first_aligned(emit, MP_F_MAKE_FUNCTION_FROM_RAW_CODE, (mp_uint_t)scope->raw_code, REG_ARG_1, (mp_uint_t)MP_OBJ_NULL, REG_ARG_2, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); + } else { + vtype_kind_t vtype_def_tuple, vtype_def_dict; + emit_pre_pop_reg_reg(emit, &vtype_def_dict, REG_ARG_3, &vtype_def_tuple, REG_ARG_2); + assert(vtype_def_tuple == VTYPE_PYOBJ); + assert(vtype_def_dict == VTYPE_PYOBJ); + emit_call_with_imm_arg_aligned(emit, MP_F_MAKE_FUNCTION_FROM_RAW_CODE, (mp_uint_t)scope->raw_code, REG_ARG_1); + } + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { + emit_native_pre(emit); + if (n_pos_defaults == 0 && n_kw_defaults == 0) { + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_closed_over); + ASM_MOV_IMM_TO_REG(emit->as, n_closed_over, REG_ARG_2); + } else { + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_closed_over + 2); + ASM_MOV_IMM_TO_REG(emit->as, 0x100 | n_closed_over, REG_ARG_2); + } + ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, (mp_uint_t)scope->raw_code, REG_ARG_1); + ASM_CALL_IND(emit->as, mp_fun_table[MP_F_MAKE_CLOSURE_FROM_RAW_CODE], MP_F_MAKE_CLOSURE_FROM_RAW_CODE); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); +} + +STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + DEBUG_printf("call_function(n_pos=" UINT_FMT ", n_kw=" UINT_FMT ", star_flags=" UINT_FMT ")\n", n_positional, n_keyword, star_flags); + + // TODO: in viper mode, call special runtime routine with type info for args, + // and wanted type info for return, to remove need for boxing/unboxing + + emit_native_pre(emit); + vtype_kind_t vtype_fun = peek_vtype(emit, n_positional + 2 * n_keyword); + if (vtype_fun == VTYPE_BUILTIN_CAST) { + // casting operator + assert(n_positional == 1 && n_keyword == 0); + assert(!star_flags); + DEBUG_printf(" cast to %d\n", vtype_fun); + vtype_kind_t vtype_cast = peek_stack(emit, 1)->data.u_imm; + switch (peek_vtype(emit, 0)) { + case VTYPE_PYOBJ: { + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_ARG_1); + emit_pre_pop_discard(emit); + emit_call_with_imm_arg(emit, MP_F_CONVERT_OBJ_TO_NATIVE, vtype_cast, REG_ARG_2); // arg2 = type + emit_post_push_reg(emit, vtype_cast, REG_RET); + break; + } + case VTYPE_BOOL: + case VTYPE_INT: + case VTYPE_UINT: + case VTYPE_PTR: + case VTYPE_PTR8: + case VTYPE_PTR16: + case VTYPE_PTR32: + case VTYPE_PTR_NONE: + emit_fold_stack_top(emit, REG_ARG_1); + emit_post_top_set_vtype(emit, vtype_cast); + break; + default: + // this can happen when casting a cast: int(int) + mp_raise_NotImplementedError("casting"); + } + } else { + assert(vtype_fun == VTYPE_PYOBJ); + if (star_flags) { + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 3); // pointer to args + emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 0, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } else { + if (n_positional != 0 || n_keyword != 0) { + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword); // pointer to args + } + emit_pre_pop_reg(emit, &vtype_fun, REG_ARG_1); // the function + emit_call_with_imm_arg(emit, MP_F_NATIVE_CALL_FUNCTION_N_KW, n_positional | (n_keyword << 8), REG_ARG_2); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } + } +} + +STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { + if (star_flags) { + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 4); // pointer to args + emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 1, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } else { + emit_native_pre(emit); + emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 2 + n_positional + 2 * n_keyword); // pointer to items, including meth and self + emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, n_positional, REG_ARG_1, n_keyword, REG_ARG_2); + emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); + } +} + +STATIC void emit_native_return_value(emit_t *emit) { + DEBUG_printf("return_value\n"); + if (emit->do_viper_types) { + if (peek_vtype(emit, 0) == VTYPE_PTR_NONE) { + emit_pre_pop_discard(emit); + if (emit->return_vtype == VTYPE_PYOBJ) { + ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)mp_const_none, REG_RET); + } else { + ASM_MOV_IMM_TO_REG(emit->as, 0, REG_RET); + } + } else { + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_RET); + if (vtype != emit->return_vtype) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, + "return expected '%q' but got '%q'", + vtype_to_qstr(emit->return_vtype), vtype_to_qstr(vtype)); + } + } + } else { + vtype_kind_t vtype; + emit_pre_pop_reg(emit, &vtype, REG_RET); + assert(vtype == VTYPE_PYOBJ); + } + emit->last_emit_was_return_value = true; + ASM_EXIT(emit->as); +} + +STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) { + assert(n_args == 1); + vtype_kind_t vtype_exc; + emit_pre_pop_reg(emit, &vtype_exc, REG_ARG_1); // arg1 = object to raise + if (vtype_exc != VTYPE_PYOBJ) { + EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "must raise an object"); + } + // TODO probably make this 1 call to the runtime (which could even call convert, native_raise(obj, type)) + emit_call(emit, MP_F_NATIVE_RAISE); +} + +STATIC void emit_native_yield_value(emit_t *emit) { + // not supported (for now) + (void)emit; + mp_raise_NotImplementedError("native yield"); +} +STATIC void emit_native_yield_from(emit_t *emit) { + // not supported (for now) + (void)emit; + mp_raise_NotImplementedError("native yield from"); +} + +STATIC void emit_native_start_except_handler(emit_t *emit) { + // This instruction follows an nlr_pop, so the stack counter is back to zero, when really + // it should be up by a whole nlr_buf_t. We then want to pop the nlr_buf_t here, but save + // the first 2 elements, so we can get the thrown value. + adjust_stack(emit, 1); + vtype_kind_t vtype_nlr; + emit_pre_pop_reg(emit, &vtype_nlr, REG_ARG_1); // get the thrown value + emit_pre_pop_discard(emit); // discard the linked-list pointer in the nlr_buf + emit_post_push_reg_reg_reg(emit, VTYPE_PYOBJ, REG_ARG_1, VTYPE_PYOBJ, REG_ARG_1, VTYPE_PYOBJ, REG_ARG_1); // push the 3 exception items +} + +STATIC void emit_native_end_except_handler(emit_t *emit) { + adjust_stack(emit, -1); +} + +const emit_method_table_t EXPORT_FUN(method_table) = { + emit_native_set_native_type, + emit_native_start_pass, + emit_native_end_pass, + emit_native_last_emit_was_return_value, + emit_native_adjust_stack_size, + emit_native_set_source_line, + + { + emit_native_load_fast, + emit_native_load_deref, + emit_native_load_name, + emit_native_load_global, + }, + { + emit_native_store_fast, + emit_native_store_deref, + emit_native_store_name, + emit_native_store_global, + }, + { + emit_native_delete_fast, + emit_native_delete_deref, + emit_native_delete_name, + emit_native_delete_global, + }, + + emit_native_label_assign, + emit_native_import_name, + emit_native_import_from, + emit_native_import_star, + emit_native_load_const_tok, + emit_native_load_const_small_int, + emit_native_load_const_str, + emit_native_load_const_obj, + emit_native_load_null, + emit_native_load_attr, + emit_native_load_method, + emit_native_load_build_class, + emit_native_load_subscr, + emit_native_store_attr, + emit_native_store_subscr, + emit_native_delete_attr, + emit_native_delete_subscr, + emit_native_dup_top, + emit_native_dup_top_two, + emit_native_pop_top, + emit_native_rot_two, + emit_native_rot_three, + emit_native_jump, + emit_native_pop_jump_if, + emit_native_jump_if_or_pop, + emit_native_break_loop, + emit_native_continue_loop, + emit_native_setup_with, + emit_native_with_cleanup, + emit_native_setup_except, + emit_native_setup_finally, + emit_native_end_finally, + emit_native_get_iter, + emit_native_for_iter, + emit_native_for_iter_end, + emit_native_pop_block, + emit_native_pop_except, + emit_native_unary_op, + emit_native_binary_op, + emit_native_build_tuple, + emit_native_build_list, + emit_native_build_map, + emit_native_store_map, + #if MICROPY_PY_BUILTINS_SET + emit_native_build_set, + #endif + #if MICROPY_PY_BUILTINS_SLICE + emit_native_build_slice, + #endif + emit_native_store_comp, + emit_native_unpack_sequence, + emit_native_unpack_ex, + emit_native_make_function, + emit_native_make_closure, + emit_native_call_function, + emit_native_call_method, + emit_native_return_value, + emit_native_raise_varargs, + emit_native_yield_value, + emit_native_yield_from, + + emit_native_start_except_handler, + emit_native_end_except_handler, +}; + +#endif diff --git a/user/mpy/py/formatfloat.c b/user/mpy/py/formatfloat.c new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/user/mpy/py/formatfloat.c @@ -0,0 +1,428 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" +#if MICROPY_FLOAT_IMPL != MICROPY_FLOAT_IMPL_NONE + +#include +#include +#include +#include "py/formatfloat.h" + +/*********************************************************************** + + Routine for converting a arbitrary floating + point number into a string. + + The code in this funcion was inspired from Fred Bayer's pdouble.c. + Since pdouble.c was released as Public Domain, I'm releasing this + code as public domain as well. + + The original code can be found in https://github.com/dhylands/format-float + + Dave Hylands + +***********************************************************************/ + +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT +// 1 sign bit, 8 exponent bits, and 23 mantissa bits. +// exponent values 0 and 255 are reserved, exponent can be 1 to 254. +// exponent is stored with a bias of 127. +// The min and max floats are on the order of 1x10^37 and 1x10^-37 + +#define FPTYPE float +#define FPCONST(x) x##F +#define FPROUND_TO_ONE 0.9999995F +#define FPDECEXP 32 +#define FPMIN_BUF_SIZE 6 // +9e+99 + +#define FLT_SIGN_MASK 0x80000000 +#define FLT_EXP_MASK 0x7F800000 +#define FLT_MAN_MASK 0x007FFFFF + +union floatbits { + float f; + uint32_t u; +}; +static inline int fp_signbit(float x) { union floatbits fb = {x}; return fb.u & FLT_SIGN_MASK; } +static inline int fp_isspecial(float x) { union floatbits fb = {x}; return (fb.u & FLT_EXP_MASK) == FLT_EXP_MASK; } +static inline int fp_isinf(float x) { union floatbits fb = {x}; return (fb.u & FLT_MAN_MASK) == 0; } +static inline int fp_iszero(float x) { union floatbits fb = {x}; return fb.u == 0; } +static inline int fp_isless1(float x) { union floatbits fb = {x}; return fb.u < 0x3f800000; } +// Assumes both fp_isspecial() and fp_isinf() were applied before +#define fp_isnan(x) 1 + +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE + +#define FPTYPE double +#define FPCONST(x) x +#define FPROUND_TO_ONE 0.999999999995 +#define FPDECEXP 256 +#define FPMIN_BUF_SIZE 7 // +9e+199 +#include +#define fp_signbit(x) signbit(x) +#define fp_isspecial(x) 1 +#define fp_isnan(x) isnan(x) +#define fp_isinf(x) isinf(x) +#define fp_iszero(x) (x == 0) +#define fp_isless1(x) (x < 1.0) + +#endif + +static const FPTYPE g_pos_pow[] = { + #if FPDECEXP > 32 + 1e256, 1e128, 1e64, + #endif + 1e32, 1e16, 1e8, 1e4, 1e2, 1e1 +}; +static const FPTYPE g_neg_pow[] = { + #if FPDECEXP > 32 + 1e-256, 1e-128, 1e-64, + #endif + 1e-32, 1e-16, 1e-8, 1e-4, 1e-2, 1e-1 +}; + +int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, char sign) { + + char *s = buf; + + if (buf_size <= FPMIN_BUF_SIZE) { + // FPMIN_BUF_SIZE is the minimum size needed to store any FP number. + // If the buffer does not have enough room for this (plus null terminator) + // then don't try to format the float. + + if (buf_size >= 2) { + *s++ = '?'; + } + if (buf_size >= 1) { + *s++ = '\0'; + } + return buf_size >= 2; + } + if (fp_signbit(f)) { + *s++ = '-'; + f = -f; + } else { + if (sign) { + *s++ = sign; + } + } + + // buf_remaining contains bytes available for digits and exponent. + // It is buf_size minus room for the sign and null byte. + int buf_remaining = buf_size - 1 - (s - buf); + + if (fp_isspecial(f)) { + char uc = fmt & 0x20; + if (fp_isinf(f)) { + *s++ = 'I' ^ uc; + *s++ = 'N' ^ uc; + *s++ = 'F' ^ uc; + goto ret; + } else if (fp_isnan(f)) { + *s++ = 'N' ^ uc; + *s++ = 'A' ^ uc; + *s++ = 'N' ^ uc; + ret: + *s = '\0'; + return s - buf; + } + } + + if (prec < 0) { + prec = 6; + } + char e_char = 'E' | (fmt & 0x20); // e_char will match case of fmt + fmt |= 0x20; // Force fmt to be lowercase + char org_fmt = fmt; + if (fmt == 'g' && prec == 0) { + prec = 1; + } + int e, e1; + int dec = 0; + char e_sign = '\0'; + int num_digits = 0; + const FPTYPE *pos_pow = g_pos_pow; + const FPTYPE *neg_pow = g_neg_pow; + + if (fp_iszero(f)) { + e = 0; + if (fmt == 'f') { + // Truncate precision to prevent buffer overflow + if (prec + 2 > buf_remaining) { + prec = buf_remaining - 2; + } + num_digits = prec + 1; + } else { + // Truncate precision to prevent buffer overflow + if (prec + 6 > buf_remaining) { + prec = buf_remaining - 6; + } + if (fmt == 'e') { + e_sign = '+'; + } + } + } else if (fp_isless1(f)) { + // We need to figure out what an integer digit will be used + // in case 'f' is used (or we revert other format to it below). + // As we just tested number to be <1, this is obviously 0, + // but we can round it up to 1 below. + char first_dig = '0'; + if (f >= FPROUND_TO_ONE) { + first_dig = '1'; + } + + // Build negative exponent + for (e = 0, e1 = FPDECEXP; e1; e1 >>= 1, pos_pow++, neg_pow++) { + if (*neg_pow > f) { + e += e1; + f *= *pos_pow; + } + } + char e_sign_char = '-'; + if (fp_isless1(f) && f >= FPROUND_TO_ONE) { + f = FPCONST(1.0); + if (e == 0) { + e_sign_char = '+'; + } + } else if (fp_isless1(f)) { + e++; + f *= FPCONST(10.0); + } + + // If the user specified 'g' format, and e is <= 4, then we'll switch + // to the fixed format ('f') + + if (fmt == 'f' || (fmt == 'g' && e <= 4)) { + fmt = 'f'; + dec = -1; + *s++ = first_dig; + + if (org_fmt == 'g') { + prec += (e - 1); + } + + // truncate precision to prevent buffer overflow + if (prec + 2 > buf_remaining) { + prec = buf_remaining - 2; + } + + num_digits = prec; + if (num_digits) { + *s++ = '.'; + while (--e && num_digits) { + *s++ = '0'; + num_digits--; + } + } + } else { + // For e & g formats, we'll be printing the exponent, so set the + // sign. + e_sign = e_sign_char; + dec = 0; + + if (prec > (buf_remaining - FPMIN_BUF_SIZE)) { + prec = buf_remaining - FPMIN_BUF_SIZE; + if (fmt == 'g') { + prec++; + } + } + } + } else { + // Build positive exponent + for (e = 0, e1 = FPDECEXP; e1; e1 >>= 1, pos_pow++, neg_pow++) { + if (*pos_pow <= f) { + e += e1; + f *= *neg_pow; + } + } + + // It can be that f was right on the edge of an entry in pos_pow needs to be reduced + if (f >= FPCONST(10.0)) { + e += 1; + f *= FPCONST(0.1); + } + + // If the user specified fixed format (fmt == 'f') and e makes the + // number too big to fit into the available buffer, then we'll + // switch to the 'e' format. + + if (fmt == 'f') { + if (e >= buf_remaining) { + fmt = 'e'; + } else if ((e + prec + 2) > buf_remaining) { + prec = buf_remaining - e - 2; + if (prec < 0) { + // This means no decimal point, so we can add one back + // for the decimal. + prec++; + } + } + } + if (fmt == 'e' && prec > (buf_remaining - FPMIN_BUF_SIZE)) { + prec = buf_remaining - FPMIN_BUF_SIZE; + } + if (fmt == 'g'){ + // Truncate precision to prevent buffer overflow + if (prec + (FPMIN_BUF_SIZE - 1) > buf_remaining) { + prec = buf_remaining - (FPMIN_BUF_SIZE - 1); + } + } + // If the user specified 'g' format, and e is < prec, then we'll switch + // to the fixed format. + + if (fmt == 'g' && e < prec) { + fmt = 'f'; + prec -= (e + 1); + } + if (fmt == 'f') { + dec = e; + num_digits = prec + e + 1; + } else { + e_sign = '+'; + } + } + if (prec < 0) { + // This can happen when the prec is trimmed to prevent buffer overflow + prec = 0; + } + + // We now have num.f as a floating point number between >= 1 and < 10 + // (or equal to zero), and e contains the absolute value of the power of + // 10 exponent. and (dec + 1) == the number of dgits before the decimal. + + // For e, prec is # digits after the decimal + // For f, prec is # digits after the decimal + // For g, prec is the max number of significant digits + // + // For e & g there will be a single digit before the decimal + // for f there will be e digits before the decimal + + if (fmt == 'e') { + num_digits = prec + 1; + } else if (fmt == 'g') { + if (prec == 0) { + prec = 1; + } + num_digits = prec; + } + + // Print the digits of the mantissa + for (int i = 0; i < num_digits; ++i, --dec) { + int32_t d = (int32_t)f; + *s++ = '0' + d; + if (dec == 0 && prec > 0) { + *s++ = '.'; + } + f -= (FPTYPE)d; + f *= FPCONST(10.0); + } + + // Round + // If we print non-exponential format (i.e. 'f'), but a digit we're going + // to round by (e) is too far away, then there's nothing to round. + if ((org_fmt != 'f' || e <= 1) && f >= FPCONST(5.0)) { + char *rs = s; + rs--; + while (1) { + if (*rs == '.') { + rs--; + continue; + } + if (*rs < '0' || *rs > '9') { + // + or - + rs++; // So we sit on the digit to the right of the sign + break; + } + if (*rs < '9') { + (*rs)++; + break; + } + *rs = '0'; + if (rs == buf) { + break; + } + rs--; + } + if (*rs == '0') { + // We need to insert a 1 + if (rs[1] == '.' && fmt != 'f') { + // We're going to round 9.99 to 10.00 + // Move the decimal point + rs[0] = '.'; + rs[1] = '0'; + if (e_sign == '-') { + e--; + if (e == 0) { + e_sign = '+'; + } + } else { + e++; + } + } else { + // Need at extra digit at the end to make room for the leading '1' + s++; + } + char *ss = s; + while (ss > rs) { + *ss = ss[-1]; + ss--; + } + *rs = '1'; + } + } + + // verify that we did not overrun the input buffer so far + assert((size_t)(s + 1 - buf) <= buf_size); + + if (org_fmt == 'g' && prec > 0) { + // Remove trailing zeros and a trailing decimal point + while (s[-1] == '0') { + s--; + } + if (s[-1] == '.') { + s--; + } + } + // Append the exponent + if (e_sign) { + *s++ = e_char; + *s++ = e_sign; + if (FPMIN_BUF_SIZE == 7 && e >= 100) { + *s++ = '0' + (e / 100); + } + *s++ = '0' + ((e / 10) % 10); + *s++ = '0' + (e % 10); + } + *s = '\0'; + + // verify that we did not overrun the input buffer + assert((size_t)(s + 1 - buf) <= buf_size); + + return s - buf; +} + +#endif // MICROPY_FLOAT_IMPL != MICROPY_FLOAT_IMPL_NONE diff --git a/user/mpy/py/formatfloat.h b/user/mpy/py/formatfloat.h new file mode 100644 index 0000000..9a1643b --- /dev/null +++ b/user/mpy/py/formatfloat.h @@ -0,0 +1,35 @@ +/* + * 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_FORMATFLOAT_H +#define MICROPY_INCLUDED_PY_FORMATFLOAT_H + +#include "py/mpconfig.h" + +#if MICROPY_PY_BUILTINS_FLOAT +int mp_format_float(mp_float_t f, char *buf, size_t bufSize, char fmt, int prec, char sign); +#endif + +#endif // MICROPY_INCLUDED_PY_FORMATFLOAT_H diff --git a/user/mpy/py/frozenmod.c b/user/mpy/py/frozenmod.c new file mode 100644 index 0000000..06d4f84 --- /dev/null +++ b/user/mpy/py/frozenmod.c @@ -0,0 +1,156 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 Paul Sokolovsky + * Copyright (c) 2016 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. + */ + +#include +#include + +#include "py/lexer.h" +#include "py/frozenmod.h" + +#if MICROPY_MODULE_FROZEN_STR + +#ifndef MICROPY_MODULE_FROZEN_LEXER +#define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str_len +#else +mp_lexer_t *MICROPY_MODULE_FROZEN_LEXER(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len); +#endif + +extern const char mp_frozen_str_names[]; +extern const uint32_t mp_frozen_str_sizes[]; +extern const char mp_frozen_str_content[]; + +// On input, *len contains size of name, on output - size of content +const char *mp_find_frozen_str(const char *str, size_t *len) { + const char *name = mp_frozen_str_names; + + size_t offset = 0; + for (int i = 0; *name != 0; i++) { + size_t l = strlen(name); + if (l == *len && !memcmp(str, name, l)) { + *len = mp_frozen_str_sizes[i]; + return mp_frozen_str_content + offset; + } + name += l + 1; + offset += mp_frozen_str_sizes[i] + 1; + } + return NULL; +} + +STATIC mp_lexer_t *mp_lexer_frozen_str(const char *str, size_t len) { + size_t name_len = len; + const char *content = mp_find_frozen_str(str, &len); + + if (content == NULL) { + return NULL; + } + + qstr source = qstr_from_strn(str, name_len); + mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, content, len, 0); + return lex; +} + +#endif + +#if MICROPY_MODULE_FROZEN_MPY + +#include "py/emitglue.h" + +extern const char mp_frozen_mpy_names[]; +extern const mp_raw_code_t *const mp_frozen_mpy_content[]; + +STATIC const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t len) { + const char *name = mp_frozen_mpy_names; + for (size_t i = 0; *name != 0; i++) { + size_t l = strlen(name); + if (l == len && !memcmp(str, name, l)) { + return mp_frozen_mpy_content[i]; + } + name += l + 1; + } + return NULL; +} + +#endif + +#if MICROPY_MODULE_FROZEN + +STATIC mp_import_stat_t mp_frozen_stat_helper(const char *name, const char *str) { + size_t len = strlen(str); + + for (int i = 0; *name != 0; i++) { + size_t l = strlen(name); + if (l >= len && !memcmp(str, name, len)) { + if (name[len] == 0) { + return MP_IMPORT_STAT_FILE; + } else if (name[len] == '/') { + return MP_IMPORT_STAT_DIR; + } + } + name += l + 1; + } + return MP_IMPORT_STAT_NO_EXIST; +} + +mp_import_stat_t mp_frozen_stat(const char *str) { + mp_import_stat_t stat; + + #if MICROPY_MODULE_FROZEN_STR + stat = mp_frozen_stat_helper(mp_frozen_str_names, str); + if (stat != MP_IMPORT_STAT_NO_EXIST) { + return stat; + } + #endif + + #if MICROPY_MODULE_FROZEN_MPY + stat = mp_frozen_stat_helper(mp_frozen_mpy_names, str); + if (stat != MP_IMPORT_STAT_NO_EXIST) { + return stat; + } + #endif + + return MP_IMPORT_STAT_NO_EXIST; +} + +int mp_find_frozen_module(const char *str, size_t len, void **data) { + #if MICROPY_MODULE_FROZEN_STR + mp_lexer_t *lex = mp_lexer_frozen_str(str, len); + if (lex != NULL) { + *data = lex; + return MP_FROZEN_STR; + } + #endif + #if MICROPY_MODULE_FROZEN_MPY + const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len); + if (rc != NULL) { + *data = (void*)rc; + return MP_FROZEN_MPY; + } + #endif + return MP_FROZEN_NONE; +} + +#endif diff --git a/user/mpy/py/frozenmod.h b/user/mpy/py/frozenmod.h new file mode 100644 index 0000000..8cddef6 --- /dev/null +++ b/user/mpy/py/frozenmod.h @@ -0,0 +1,41 @@ +/* + * 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_FROZENMOD_H +#define MICROPY_INCLUDED_PY_FROZENMOD_H + +#include "py/lexer.h" + +enum { + MP_FROZEN_NONE, + MP_FROZEN_STR, + MP_FROZEN_MPY, +}; + +int mp_find_frozen_module(const char *str, size_t len, void **data); +const char *mp_find_frozen_str(const char *str, size_t *len); +mp_import_stat_t mp_frozen_stat(const char *str); + +#endif // MICROPY_INCLUDED_PY_FROZENMOD_H diff --git a/user/mpy/py/gc.c b/user/mpy/py/gc.c new file mode 100644 index 0000000..3a505e9 --- /dev/null +++ b/user/mpy/py/gc.c @@ -0,0 +1,918 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpstate.h" +#include "py/gc.h" +#include "py/obj.h" +#include "py/runtime.h" + +#if MICROPY_ENABLE_GC + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_PRINT (0) +#define DEBUG_printf(...) (void)0 +#endif + +// make this 1 to dump the heap each time it changes +#define EXTENSIVE_HEAP_PROFILING (0) + +#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_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 MICROPY_ENABLE_FINALISER +// 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 + +#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL +#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 +#define GC_ENTER() +#define GC_EXIT() +#endif + +// 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 MICROPY_ENABLE_FINALISER + MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len * BITS_PER_BYTE / (BITS_PER_BYTE + BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK); +#else + MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len / (1 + BITS_PER_BYTE / 2 * BYTES_PER_BLOCK); +#endif + + MP_STATE_MEM(gc_alloc_table_start) = (byte*)start; + +#if MICROPY_ENABLE_FINALISER + 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 + + 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 MICROPY_ENABLE_FINALISER + assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len); +#endif + + // clear ATBs + memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len)); + +#if MICROPY_ENABLE_FINALISER + // clear FTBs + memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len); +#endif + + // set last free ATB index to start of heap + MP_STATE_MEM(gc_last_free_atb_index) = 0; + + // unlock the GC + MP_STATE_MEM(gc_lock_depth) = 0; + + // allow auto collection + MP_STATE_MEM(gc_auto_collect_enabled) = 1; + + #if MICROPY_GC_ALLOC_THRESHOLD + // 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 + + #if MICROPY_PY_THREAD + mp_thread_mutex_init(&MP_STATE_MEM(gc_mutex)); + #endif + + 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 MICROPY_ENABLE_FINALISER + 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 + 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) { + GC_ENTER(); + MP_STATE_MEM(gc_lock_depth)++; + GC_EXIT(); +} + +void gc_unlock(void) { + GC_ENTER(); + MP_STATE_MEM(gc_lock_depth)--; + GC_EXIT(); +} + +bool gc_is_locked(void) { + return MP_STATE_MEM(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 */ \ + ) + +// ptr should be of type void* +#define VERIFY_MARK_AND_PUSH(ptr) \ + do { \ + if (VERIFY_PTR(ptr)) { \ + size_t _block = BLOCK_FROM_PTR(ptr); \ + if (ATB_GET_KIND(_block) == AT_HEAD) { \ + /* an unmarked head, mark it, and push it on gc stack */ \ + DEBUG_printf("gc_mark(%p)\n", ptr); \ + ATB_HEAD_TO_MARK(_block); \ + if (MP_STATE_MEM(gc_sp) < &MP_STATE_MEM(gc_stack)[MICROPY_ALLOC_GC_STACK_SIZE]) { \ + *MP_STATE_MEM(gc_sp)++ = _block; \ + } else { \ + MP_STATE_MEM(gc_stack_overflow) = 1; \ + } \ + } \ + } \ + } while (0) + +STATIC void gc_drain_stack(void) { + while (MP_STATE_MEM(gc_sp) > MP_STATE_MEM(gc_stack)) { + // pop the next block off the stack + size_t block = *--MP_STATE_MEM(gc_sp); + + // 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; + VERIFY_MARK_AND_PUSH(ptr); + } + } +} + +STATIC void gc_deal_with_stack_overflow(void) { + while (MP_STATE_MEM(gc_stack_overflow)) { + MP_STATE_MEM(gc_stack_overflow) = 0; + MP_STATE_MEM(gc_sp) = MP_STATE_MEM(gc_stack); + + // 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) { + *MP_STATE_MEM(gc_sp)++ = block; + gc_drain_stack(); + } + } + } +} + +STATIC void gc_sweep(void) { + #if MICROPY_PY_GC_COLLECT_RETVAL + MP_STATE_MEM(gc_collected) = 0; + #endif + // 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 MICROPY_ENABLE_FINALISER + 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 MICROPY_ENABLE_SCHEDULER + mp_sched_lock(); + #endif + mp_call_function_1_protected(dest[0], dest[1]); + #if MICROPY_ENABLE_SCHEDULER + mp_sched_unlock(); + #endif + } + } + // clear finaliser flag + FTB_CLEAR(block); + } +#endif + free_tail = 1; + DEBUG_printf("gc_sweep(%x)\n", PTR_FROM_BLOCK(block)); + #if MICROPY_PY_GC_COLLECT_RETVAL + MP_STATE_MEM(gc_collected)++; + #endif + // fall through to free the head + + case AT_TAIL: + if (free_tail) { + ATB_ANY_TO_FREE(block); + } + break; + + case AT_MARK: + ATB_MARK_TO_HEAD(block); + free_tail = 0; + break; + } + } +} + +void gc_collect_start(void) { + GC_ENTER(); + MP_STATE_MEM(gc_lock_depth)++; + #if MICROPY_GC_ALLOC_THRESHOLD + MP_STATE_MEM(gc_alloc_amount) = 0; + #endif + MP_STATE_MEM(gc_stack_overflow) = 0; + MP_STATE_MEM(gc_sp) = MP_STATE_MEM(gc_stack); + // 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; + gc_collect_root(ptrs, offsetof(mp_state_ctx_t, vm.qstr_last_chunk) / sizeof(void*)); +} + +void gc_collect_root(void **ptrs, size_t len) { + for (size_t i = 0; i < len; i++) { + void *ptr = ptrs[i]; + VERIFY_MARK_AND_PUSH(ptr); + gc_drain_stack(); + } +} + +void gc_collect_end(void) { + gc_deal_with_stack_overflow(); + gc_sweep(); + MP_STATE_MEM(gc_last_free_atb_index) = 0; + MP_STATE_MEM(gc_lock_depth)--; + GC_EXIT(); +} + +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, bool 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; + } + + GC_ENTER(); + + // check if GC is locked + if (MP_STATE_MEM(gc_lock_depth) > 0) { + GC_EXIT(); + return NULL; + } + + size_t i; + size_t end_block; + size_t start_block; + size_t n_free = 0; + int collected = !MP_STATE_MEM(gc_auto_collect_enabled); + + #if MICROPY_GC_ALLOC_THRESHOLD + if (!collected && MP_STATE_MEM(gc_alloc_amount) >= MP_STATE_MEM(gc_alloc_threshold)) { + GC_EXIT(); + gc_collect(); + GC_ENTER(); + } + #endif + + for (;;) { + + // look for a run of n_blocks available blocks + 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]; + 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; } + } + + 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 MICROPY_GC_ALLOC_THRESHOLD + MP_STATE_MEM(gc_alloc_amount) += n_blocks; + #endif + + GC_EXIT(); + + #if MICROPY_GC_CONSERVATIVE_CLEAR + // be conservative and zero out all the newly allocated blocks + memset((byte*)ret_ptr, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK); + #else + // 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 + + #if MICROPY_ENABLE_FINALISER + 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 + (void)has_finaliser; + #endif + + #if EXTENSIVE_HEAP_PROFILING + gc_dump_alloc_table(); + #endif + + 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) { + GC_ENTER(); + if (MP_STATE_MEM(gc_lock_depth) > 0) { + // TODO how to deal with this error? + GC_EXIT(); + return; + } + + 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 MICROPY_ENABLE_FINALISER + FTB_CLEAR(block); + #endif + + // 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 EXTENSIVE_HEAP_PROFILING + gc_dump_alloc_table(); + #endif + } +} + +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 +// 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 MICROPY_ENABLE_FINALISER + has_finaliser = FTB_GET(BLOCK_FROM_PTR((mp_uint_t)ptr)); +#else + has_finaliser = false; +#endif + } + 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 + +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; + } + + void *ptr = ptr_in; + + // sanity check the ptr + if (!VERIFY_PTR(ptr)) { + return NULL; + } + + // get first block + size_t block = BLOCK_FROM_PTR(ptr); + + GC_ENTER(); + + // sanity check the ptr is pointing to the head of a block + if (ATB_GET_KIND(block) != AT_HEAD) { + GC_EXIT(); + return NULL; + } + + if (MP_STATE_MEM(gc_lock_depth) > 0) { + GC_EXIT(); + return NULL; + } + + // 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 EXTENSIVE_HEAP_PROFILING + gc_dump_alloc_table(); + #endif + + 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 MICROPY_GC_CONSERVATIVE_CLEAR + // 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 + // 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 + + #if EXTENSIVE_HEAP_PROFILING + gc_dump_alloc_table(); + #endif + + return ptr_in; + } + + #if MICROPY_ENABLE_FINALISER + bool ftb_state = FTB_GET(block); + #else + bool ftb_state = false; + #endif + + 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 + +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 !EXTENSIVE_HEAP_PROFILING + // 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 + 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 MICROPY_PY_BUILTINS_BYTEARRAY + else if (*ptr == &mp_type_bytearray) { c = 'A'; } + #endif + #if MICROPY_PY_ARRAY + else if (*ptr == &mp_type_array) { c = 'A'; } + #endif + #if MICROPY_PY_BUILTINS_FLOAT + else if (*ptr == &mp_type_float) { c = 'F'; } + #endif + else if (*ptr == &mp_type_fun_bc) { c = 'B'; } + else if (*ptr == &mp_type_module) { c = 'M'; } + else { + c = 'h'; + #if 0 + // 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 + } + 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 DEBUG_PRINT +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 + +#endif // MICROPY_ENABLE_GC diff --git a/user/mpy/py/gc.h b/user/mpy/py/gc.h new file mode 100644 index 0000000..739349c --- /dev/null +++ b/user/mpy/py/gc.h @@ -0,0 +1,67 @@ +/* + * 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 + +#include + +#include "py/mpconfig.h" +#include "py/misc.h" + +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); + +void *gc_alloc(size_t n_bytes, bool has_finaliser); +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 diff --git a/user/mpy/py/grammar.h b/user/mpy/py/grammar.h new file mode 100644 index 0000000..6abb1de --- /dev/null +++ b/user/mpy/py/grammar.h @@ -0,0 +1,357 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2015 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. + */ + +// rules for writing rules: +// - zero_or_more is implemented using opt_rule around a one_or_more rule +// - don't put opt_rule in arguments of or rule; instead, wrap the call to this or rule in opt_rule + +// # Start symbols for the grammar: +// # single_input is a single interactive statement; +// # file_input is a module or sequence of commands read from an input file; +// # eval_input is the input for the eval() functions. +// # NB: compound_stmt in single_input is followed by extra NEWLINE! --> not in MicroPython +// single_input: NEWLINE | simple_stmt | compound_stmt +// file_input: (NEWLINE | stmt)* ENDMARKER +// eval_input: testlist NEWLINE* ENDMARKER + +DEF_RULE_NC(single_input, or(3), tok(NEWLINE), rule(simple_stmt), rule(compound_stmt)) +DEF_RULE(file_input, c(generic_all_nodes), and_ident(1), opt_rule(file_input_2)) +DEF_RULE(file_input_2, c(generic_all_nodes), one_or_more, rule(file_input_3)) +DEF_RULE_NC(file_input_3, or(2), tok(NEWLINE), rule(stmt)) +DEF_RULE_NC(eval_input, and_ident(2), rule(testlist), opt_rule(eval_input_2)) +DEF_RULE_NC(eval_input_2, and(1), tok(NEWLINE)) + +// decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE +// decorators: decorator+ +// decorated: decorators (classdef | funcdef | async_funcdef) +// funcdef: 'def' NAME parameters ['->' test] ':' suite +// async_funcdef: 'async' funcdef +// parameters: '(' [typedargslist] ')' +// typedargslist: tfpdef ['=' test] (',' tfpdef ['=' test])* [',' ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]] | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef +// tfpdef: NAME [':' test] +// varargslist: vfpdef ['=' test] (',' vfpdef ['=' test])* [',' ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]] | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef +// vfpdef: NAME + +DEF_RULE_NC(decorator, and(4), tok(DEL_AT), rule(dotted_name), opt_rule(trailer_paren), tok(NEWLINE)) +DEF_RULE_NC(decorators, one_or_more, rule(decorator)) +DEF_RULE(decorated, c(decorated), and_ident(2), rule(decorators), rule(decorated_body)) +#if MICROPY_PY_ASYNC_AWAIT +DEF_RULE_NC(decorated_body, or(3), rule(classdef), rule(funcdef), rule(async_funcdef)) +DEF_RULE_NC(async_funcdef, and(2), tok(KW_ASYNC), rule(funcdef)) +#else +DEF_RULE_NC(decorated_body, or(2), rule(classdef), rule(funcdef)) +#endif +DEF_RULE(funcdef, c(funcdef), and_blank(8), tok(KW_DEF), tok(NAME), tok(DEL_PAREN_OPEN), opt_rule(typedargslist), tok(DEL_PAREN_CLOSE), opt_rule(funcdefrettype), tok(DEL_COLON), rule(suite)) +DEF_RULE_NC(funcdefrettype, and_ident(2), tok(DEL_MINUS_MORE), rule(test)) +// note: typedargslist lets through more than is allowed, compiler does further checks +DEF_RULE_NC(typedargslist, list_with_end, rule(typedargslist_item), tok(DEL_COMMA)) +DEF_RULE_NC(typedargslist_item, or(3), rule(typedargslist_name), rule(typedargslist_star), rule(typedargslist_dbl_star)) +DEF_RULE_NC(typedargslist_name, and_ident(3), tok(NAME), opt_rule(typedargslist_colon), opt_rule(typedargslist_equal)) +DEF_RULE_NC(typedargslist_star, and(2), tok(OP_STAR), opt_rule(tfpdef)) +DEF_RULE_NC(typedargslist_dbl_star, and(3), tok(OP_DBL_STAR), tok(NAME), opt_rule(typedargslist_colon)) +DEF_RULE_NC(typedargslist_colon, and_ident(2), tok(DEL_COLON), rule(test)) +DEF_RULE_NC(typedargslist_equal, and_ident(2), tok(DEL_EQUAL), rule(test)) +DEF_RULE_NC(tfpdef, and(2), tok(NAME), opt_rule(typedargslist_colon)) +// note: varargslist lets through more than is allowed, compiler does further checks +DEF_RULE_NC(varargslist, list_with_end, rule(varargslist_item), tok(DEL_COMMA)) +DEF_RULE_NC(varargslist_item, or(3), rule(varargslist_name), rule(varargslist_star), rule(varargslist_dbl_star)) +DEF_RULE_NC(varargslist_name, and_ident(2), tok(NAME), opt_rule(varargslist_equal)) +DEF_RULE_NC(varargslist_star, and(2), tok(OP_STAR), opt_rule(vfpdef)) +DEF_RULE_NC(varargslist_dbl_star, and(2), tok(OP_DBL_STAR), tok(NAME)) +DEF_RULE_NC(varargslist_equal, and_ident(2), tok(DEL_EQUAL), rule(test)) +DEF_RULE_NC(vfpdef, and_ident(1), tok(NAME)) + +// stmt: compound_stmt | simple_stmt + +DEF_RULE_NC(stmt, or(2), rule(compound_stmt), rule(simple_stmt)) + +// simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE + +DEF_RULE_NC(simple_stmt, and_ident(2), rule(simple_stmt_2), tok(NEWLINE)) +DEF_RULE(simple_stmt_2, c(generic_all_nodes), list_with_end, rule(small_stmt), tok(DEL_SEMICOLON)) + +// small_stmt: expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt +// expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist_star_expr))*) +// testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [','] +// augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=' +// # For normal assignments, additional restrictions enforced by the interpreter + +DEF_RULE_NC(small_stmt, or(8), rule(del_stmt), rule(pass_stmt), rule(flow_stmt), rule(import_stmt), rule(global_stmt), rule(nonlocal_stmt), rule(assert_stmt), rule(expr_stmt)) +DEF_RULE(expr_stmt, c(expr_stmt), and(2), rule(testlist_star_expr), opt_rule(expr_stmt_2)) +DEF_RULE_NC(expr_stmt_2, or(2), rule(expr_stmt_augassign), rule(expr_stmt_assign_list)) +DEF_RULE_NC(expr_stmt_augassign, and_ident(2), rule(augassign), rule(expr_stmt_6)) +DEF_RULE_NC(expr_stmt_assign_list, one_or_more, rule(expr_stmt_assign)) +DEF_RULE_NC(expr_stmt_assign, and_ident(2), tok(DEL_EQUAL), rule(expr_stmt_6)) +DEF_RULE_NC(expr_stmt_6, or(2), rule(yield_expr), rule(testlist_star_expr)) +DEF_RULE(testlist_star_expr, c(generic_tuple), list_with_end, rule(testlist_star_expr_2), tok(DEL_COMMA)) +DEF_RULE_NC(testlist_star_expr_2, or(2), rule(star_expr), rule(test)) +DEF_RULE_NC(augassign, or(12), tok(DEL_PLUS_EQUAL), tok(DEL_MINUS_EQUAL), tok(DEL_STAR_EQUAL), tok(DEL_SLASH_EQUAL), tok(DEL_PERCENT_EQUAL), tok(DEL_AMPERSAND_EQUAL), tok(DEL_PIPE_EQUAL), tok(DEL_CARET_EQUAL), tok(DEL_DBL_LESS_EQUAL), tok(DEL_DBL_MORE_EQUAL), tok(DEL_DBL_STAR_EQUAL), tok(DEL_DBL_SLASH_EQUAL)) + +// del_stmt: 'del' exprlist +// pass_stmt: 'pass' +// flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt +// break_stmt: 'break' +// continue_stmt: 'continue' +// return_stmt: 'return' [testlist] +// yield_stmt: yield_expr +// raise_stmt: 'raise' [test ['from' test]] + +DEF_RULE(del_stmt, c(del_stmt), and(2), tok(KW_DEL), rule(exprlist)) +DEF_RULE(pass_stmt, c(generic_all_nodes), and(1), tok(KW_PASS)) +DEF_RULE_NC(flow_stmt, or(5), rule(break_stmt), rule(continue_stmt), rule(return_stmt), rule(raise_stmt), rule(yield_stmt)) +DEF_RULE(break_stmt, c(break_stmt), and(1), tok(KW_BREAK)) +DEF_RULE(continue_stmt, c(continue_stmt), and(1), tok(KW_CONTINUE)) +DEF_RULE(return_stmt, c(return_stmt), and(2), tok(KW_RETURN), opt_rule(testlist)) +DEF_RULE(yield_stmt, c(yield_stmt), and(1), rule(yield_expr)) +DEF_RULE(raise_stmt, c(raise_stmt), and(2), tok(KW_RAISE), opt_rule(raise_stmt_arg)) +DEF_RULE_NC(raise_stmt_arg, and_ident(2), rule(test), opt_rule(raise_stmt_from)) +DEF_RULE_NC(raise_stmt_from, and_ident(2), tok(KW_FROM), rule(test)) + +// import_stmt: import_name | import_from +// import_name: 'import' dotted_as_names +// import_from: 'from' (('.' | '...')* dotted_name | ('.' | '...')+) 'import' ('*' | '(' import_as_names ')' | import_as_names) +// import_as_name: NAME ['as' NAME] +// dotted_as_name: dotted_name ['as' NAME] +// import_as_names: import_as_name (',' import_as_name)* [','] +// dotted_as_names: dotted_as_name (',' dotted_as_name)* +// dotted_name: NAME ('.' NAME)* +// global_stmt: 'global' NAME (',' NAME)* +// nonlocal_stmt: 'nonlocal' NAME (',' NAME)* +// assert_stmt: 'assert' test [',' test] + +DEF_RULE_NC(import_stmt, or(2), rule(import_name), rule(import_from)) +DEF_RULE(import_name, c(import_name), and(2), tok(KW_IMPORT), rule(dotted_as_names)) +DEF_RULE(import_from, c(import_from), and(4), tok(KW_FROM), rule(import_from_2), tok(KW_IMPORT), rule(import_from_3)) +DEF_RULE_NC(import_from_2, or(2), rule(dotted_name), rule(import_from_2b)) +DEF_RULE_NC(import_from_2b, and_ident(2), rule(one_or_more_period_or_ellipsis), opt_rule(dotted_name)) +DEF_RULE_NC(import_from_3, or(3), tok(OP_STAR), rule(import_as_names_paren), rule(import_as_names)) +DEF_RULE_NC(import_as_names_paren, and_ident(3), tok(DEL_PAREN_OPEN), rule(import_as_names), tok(DEL_PAREN_CLOSE)) +DEF_RULE_NC(one_or_more_period_or_ellipsis, one_or_more, rule(period_or_ellipsis)) +DEF_RULE_NC(period_or_ellipsis, or(2), tok(DEL_PERIOD), tok(ELLIPSIS)) +DEF_RULE_NC(import_as_name, and(2), tok(NAME), opt_rule(as_name)) +DEF_RULE_NC(dotted_as_name, and_ident(2), rule(dotted_name), opt_rule(as_name)) +DEF_RULE_NC(as_name, and_ident(2), tok(KW_AS), tok(NAME)) +DEF_RULE_NC(import_as_names, list_with_end, rule(import_as_name), tok(DEL_COMMA)) +DEF_RULE_NC(dotted_as_names, list, rule(dotted_as_name), tok(DEL_COMMA)) +DEF_RULE_NC(dotted_name, list, tok(NAME), tok(DEL_PERIOD)) +DEF_RULE(global_stmt, c(global_stmt), and(2), tok(KW_GLOBAL), rule(name_list)) +DEF_RULE(nonlocal_stmt, c(nonlocal_stmt), and(2), tok(KW_NONLOCAL), rule(name_list)) +DEF_RULE_NC(name_list, list, tok(NAME), tok(DEL_COMMA)) +DEF_RULE(assert_stmt, c(assert_stmt), and(3), tok(KW_ASSERT), rule(test), opt_rule(assert_stmt_extra)) +DEF_RULE_NC(assert_stmt_extra, and_ident(2), tok(DEL_COMMA), rule(test)) + +// compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt +// if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] +// while_stmt: 'while' test ':' suite ['else' ':' suite] +// for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] +// try_stmt: 'try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite) +// # NB compile.c makes sure that the default except clause is last +// except_clause: 'except' [test ['as' NAME]] +// with_stmt: 'with' with_item (',' with_item)* ':' suite +// with_item: test ['as' expr] +// suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT +// async_stmt: 'async' (funcdef | with_stmt | for_stmt) + +#if MICROPY_PY_ASYNC_AWAIT +DEF_RULE_NC(compound_stmt, or(9), rule(if_stmt), rule(while_stmt), rule(for_stmt), rule(try_stmt), rule(with_stmt), rule(funcdef), rule(classdef), rule(decorated), rule(async_stmt)) +DEF_RULE(async_stmt, c(async_stmt), and(2), tok(KW_ASYNC), rule(async_stmt_2)) +DEF_RULE_NC(async_stmt_2, or(3), rule(funcdef), rule(with_stmt), rule(for_stmt)) +#else +DEF_RULE_NC(compound_stmt, or(8), rule(if_stmt), rule(while_stmt), rule(for_stmt), rule(try_stmt), rule(with_stmt), rule(funcdef), rule(classdef), rule(decorated)) +#endif +DEF_RULE(if_stmt, c(if_stmt), and(6), tok(KW_IF), rule(test), tok(DEL_COLON), rule(suite), opt_rule(if_stmt_elif_list), opt_rule(else_stmt)) +DEF_RULE_NC(if_stmt_elif_list, one_or_more, rule(if_stmt_elif)) +DEF_RULE_NC(if_stmt_elif, and(4), tok(KW_ELIF), rule(test), tok(DEL_COLON), rule(suite)) +DEF_RULE(while_stmt, c(while_stmt), and(5), tok(KW_WHILE), rule(test), tok(DEL_COLON), rule(suite), opt_rule(else_stmt)) +DEF_RULE(for_stmt, c(for_stmt), and(7), tok(KW_FOR), rule(exprlist), tok(KW_IN), rule(testlist), tok(DEL_COLON), rule(suite), opt_rule(else_stmt)) +DEF_RULE(try_stmt, c(try_stmt), and(4), tok(KW_TRY), tok(DEL_COLON), rule(suite), rule(try_stmt_2)) +DEF_RULE_NC(try_stmt_2, or(2), rule(try_stmt_except_and_more), rule(try_stmt_finally)) +DEF_RULE_NC(try_stmt_except_and_more, and_ident(3), rule(try_stmt_except_list), opt_rule(else_stmt), opt_rule(try_stmt_finally)) +DEF_RULE_NC(try_stmt_except, and(4), tok(KW_EXCEPT), opt_rule(try_stmt_as_name), tok(DEL_COLON), rule(suite)) +DEF_RULE_NC(try_stmt_as_name, and_ident(2), rule(test), opt_rule(as_name)) +DEF_RULE_NC(try_stmt_except_list, one_or_more, rule(try_stmt_except)) +DEF_RULE_NC(try_stmt_finally, and(3), tok(KW_FINALLY), tok(DEL_COLON), rule(suite)) +DEF_RULE_NC(else_stmt, and_ident(3), tok(KW_ELSE), tok(DEL_COLON), rule(suite)) +DEF_RULE(with_stmt, c(with_stmt), and(4), tok(KW_WITH), rule(with_stmt_list), tok(DEL_COLON), rule(suite)) +DEF_RULE_NC(with_stmt_list, list, rule(with_item), tok(DEL_COMMA)) +DEF_RULE_NC(with_item, and_ident(2), rule(test), opt_rule(with_item_as)) +DEF_RULE_NC(with_item_as, and_ident(2), tok(KW_AS), rule(expr)) +DEF_RULE_NC(suite, or(2), rule(suite_block), rule(simple_stmt)) +DEF_RULE_NC(suite_block, and_ident(4), tok(NEWLINE), tok(INDENT), rule(suite_block_stmts), tok(DEDENT)) +DEF_RULE(suite_block_stmts, c(generic_all_nodes), one_or_more, rule(stmt)) + +// test: or_test ['if' or_test 'else' test] | lambdef +// test_nocond: or_test | lambdef_nocond +// lambdef: 'lambda' [varargslist] ':' test +// lambdef_nocond: 'lambda' [varargslist] ':' test_nocond + +DEF_RULE_NC(test, or(2), rule(lambdef), rule(test_if_expr)) +DEF_RULE(test_if_expr, c(test_if_expr), and_ident(2), rule(or_test), opt_rule(test_if_else)) +DEF_RULE_NC(test_if_else, and(4), tok(KW_IF), rule(or_test), tok(KW_ELSE), rule(test)) +DEF_RULE_NC(test_nocond, or(2), rule(lambdef_nocond), rule(or_test)) +DEF_RULE(lambdef, c(lambdef), and_blank(4), tok(KW_LAMBDA), opt_rule(varargslist), tok(DEL_COLON), rule(test)) +DEF_RULE(lambdef_nocond, c(lambdef), and_blank(4), tok(KW_LAMBDA), opt_rule(varargslist), tok(DEL_COLON), rule(test_nocond)) + +// or_test: and_test ('or' and_test)* +// and_test: not_test ('and' not_test)* +// not_test: 'not' not_test | comparison +// comparison: expr (comp_op expr)* +// comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not' +// star_expr: '*' expr +// expr: xor_expr ('|' xor_expr)* +// xor_expr: and_expr ('^' and_expr)* +// and_expr: shift_expr ('&' shift_expr)* +// shift_expr: arith_expr (('<<'|'>>') arith_expr)* +// arith_expr: term (('+'|'-') term)* +// term: factor (('*'|'/'|'%'|'//') factor)* +// factor: ('+'|'-'|'~') factor | power +// power: atom_expr ['**' factor] +// atom_expr: 'await' atom trailer* | atom trailer* + +DEF_RULE(or_test, c(or_test), list, rule(and_test), tok(KW_OR)) +DEF_RULE(and_test, c(and_test), list, rule(not_test), tok(KW_AND)) +DEF_RULE_NC(not_test, or(2), rule(not_test_2), rule(comparison)) +DEF_RULE(not_test_2, c(not_test_2), and(2), tok(KW_NOT), rule(not_test)) +DEF_RULE(comparison, c(comparison), list, rule(expr), rule(comp_op)) +DEF_RULE_NC(comp_op, or(9), tok(OP_LESS), tok(OP_MORE), tok(OP_DBL_EQUAL), tok(OP_LESS_EQUAL), tok(OP_MORE_EQUAL), tok(OP_NOT_EQUAL), tok(KW_IN), rule(comp_op_not_in), rule(comp_op_is)) +DEF_RULE_NC(comp_op_not_in, and(2), tok(KW_NOT), tok(KW_IN)) +DEF_RULE_NC(comp_op_is, and(2), tok(KW_IS), opt_rule(comp_op_is_not)) +DEF_RULE_NC(comp_op_is_not, and(1), tok(KW_NOT)) +DEF_RULE(star_expr, c(star_expr), and(2), tok(OP_STAR), rule(expr)) +DEF_RULE(expr, c(expr), list, rule(xor_expr), tok(OP_PIPE)) +DEF_RULE(xor_expr, c(xor_expr), list, rule(and_expr), tok(OP_CARET)) +DEF_RULE(and_expr, c(and_expr), list, rule(shift_expr), tok(OP_AMPERSAND)) +DEF_RULE(shift_expr, c(term), list, rule(arith_expr), rule(shift_op)) +DEF_RULE_NC(shift_op, or(2), tok(OP_DBL_LESS), tok(OP_DBL_MORE)) +DEF_RULE(arith_expr, c(term), list, rule(term), rule(arith_op)) +DEF_RULE_NC(arith_op, or(2), tok(OP_PLUS), tok(OP_MINUS)) +DEF_RULE(term, c(term), list, rule(factor), rule(term_op)) +DEF_RULE_NC(term_op, or(4), tok(OP_STAR), tok(OP_SLASH), tok(OP_PERCENT), tok(OP_DBL_SLASH)) +DEF_RULE_NC(factor, or(2), rule(factor_2), rule(power)) +DEF_RULE(factor_2, c(factor_2), and_ident(2), rule(factor_op), rule(factor)) +DEF_RULE_NC(factor_op, or(3), tok(OP_PLUS), tok(OP_MINUS), tok(OP_TILDE)) +DEF_RULE(power, c(power), and_ident(2), rule(atom_expr), opt_rule(power_dbl_star)) +#if MICROPY_PY_ASYNC_AWAIT +DEF_RULE_NC(atom_expr, or(2), rule(atom_expr_await), rule(atom_expr_normal)) +DEF_RULE(atom_expr_await, c(atom_expr_await), and(3), tok(KW_AWAIT), rule(atom), opt_rule(atom_expr_trailers)) +#else +DEF_RULE_NC(atom_expr, or(1), rule(atom_expr_normal)) +#endif +DEF_RULE(atom_expr_normal, c(atom_expr_normal), and_ident(2), rule(atom), opt_rule(atom_expr_trailers)) +DEF_RULE_NC(atom_expr_trailers, one_or_more, rule(trailer)) +DEF_RULE_NC(power_dbl_star, and_ident(2), tok(OP_DBL_STAR), rule(factor)) + +// atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False' +// testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) +// trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME + +DEF_RULE_NC(atom, or(12), tok(NAME), tok(INTEGER), tok(FLOAT_OR_IMAG), tok(STRING), tok(BYTES), tok(ELLIPSIS), tok(KW_NONE), tok(KW_TRUE), tok(KW_FALSE), rule(atom_paren), rule(atom_bracket), rule(atom_brace)) +DEF_RULE(atom_paren, c(atom_paren), and(3), tok(DEL_PAREN_OPEN), opt_rule(atom_2b), tok(DEL_PAREN_CLOSE)) +DEF_RULE_NC(atom_2b, or(2), rule(yield_expr), rule(testlist_comp)) +DEF_RULE(atom_bracket, c(atom_bracket), and(3), tok(DEL_BRACKET_OPEN), opt_rule(testlist_comp), tok(DEL_BRACKET_CLOSE)) +DEF_RULE(atom_brace, c(atom_brace), and(3), tok(DEL_BRACE_OPEN), opt_rule(dictorsetmaker), tok(DEL_BRACE_CLOSE)) +DEF_RULE_NC(testlist_comp, and_ident(2), rule(testlist_comp_2), opt_rule(testlist_comp_3)) +DEF_RULE_NC(testlist_comp_2, or(2), rule(star_expr), rule(test)) +DEF_RULE_NC(testlist_comp_3, or(2), rule(comp_for), rule(testlist_comp_3b)) +DEF_RULE_NC(testlist_comp_3b, and_ident(2), tok(DEL_COMMA), opt_rule(testlist_comp_3c)) +DEF_RULE_NC(testlist_comp_3c, list_with_end, rule(testlist_comp_2), tok(DEL_COMMA)) +DEF_RULE_NC(trailer, or(3), rule(trailer_paren), rule(trailer_bracket), rule(trailer_period)) +DEF_RULE(trailer_paren, c(trailer_paren), and(3), tok(DEL_PAREN_OPEN), opt_rule(arglist), tok(DEL_PAREN_CLOSE)) +DEF_RULE(trailer_bracket, c(trailer_bracket), and(3), tok(DEL_BRACKET_OPEN), rule(subscriptlist), tok(DEL_BRACKET_CLOSE)) +DEF_RULE(trailer_period, c(trailer_period), and(2), tok(DEL_PERIOD), tok(NAME)) + +// subscriptlist: subscript (',' subscript)* [','] +// subscript: test | [test] ':' [test] [sliceop] +// sliceop: ':' [test] + +#if MICROPY_PY_BUILTINS_SLICE +DEF_RULE(subscriptlist, c(generic_tuple), list_with_end, rule(subscript), tok(DEL_COMMA)) +DEF_RULE_NC(subscript, or(2), rule(subscript_3), rule(subscript_2)) +DEF_RULE(subscript_2, c(subscript_2), and_ident(2), rule(test), opt_rule(subscript_3)) +DEF_RULE(subscript_3, c(subscript_3), and(2), tok(DEL_COLON), opt_rule(subscript_3b)) +DEF_RULE_NC(subscript_3b, or(2), rule(subscript_3c), rule(subscript_3d)) +DEF_RULE_NC(subscript_3c, and(2), tok(DEL_COLON), opt_rule(test)) +DEF_RULE_NC(subscript_3d, and_ident(2), rule(test), opt_rule(sliceop)) +DEF_RULE_NC(sliceop, and(2), tok(DEL_COLON), opt_rule(test)) +#else +DEF_RULE(subscriptlist, c(generic_tuple), list_with_end, rule(test), tok(DEL_COMMA)) +#endif + +// exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] +// testlist: test (',' test)* [','] +// dictorsetmaker: (test ':' test (comp_for | (',' test ':' test)* [','])) | (test (comp_for | (',' test)* [','])) + +DEF_RULE_NC(exprlist, list_with_end, rule(exprlist_2), tok(DEL_COMMA)) +DEF_RULE_NC(exprlist_2, or(2), rule(star_expr), rule(expr)) +DEF_RULE(testlist, c(generic_tuple), list_with_end, rule(test), tok(DEL_COMMA)) +// TODO dictorsetmaker lets through more than is allowed +DEF_RULE_NC(dictorsetmaker, and_ident(2), rule(dictorsetmaker_item), opt_rule(dictorsetmaker_tail)) +#if MICROPY_PY_BUILTINS_SET +DEF_RULE(dictorsetmaker_item, c(dictorsetmaker_item), and_ident(2), rule(test), opt_rule(dictorsetmaker_colon)) +DEF_RULE_NC(dictorsetmaker_colon, and_ident(2), tok(DEL_COLON), rule(test)) +#else +DEF_RULE(dictorsetmaker_item, c(dictorsetmaker_item), and(3), rule(test), tok(DEL_COLON), rule(test)) +#endif +DEF_RULE_NC(dictorsetmaker_tail, or(2), rule(comp_for), rule(dictorsetmaker_list)) +DEF_RULE_NC(dictorsetmaker_list, and(2), tok(DEL_COMMA), opt_rule(dictorsetmaker_list2)) +DEF_RULE_NC(dictorsetmaker_list2, list_with_end, rule(dictorsetmaker_item), tok(DEL_COMMA)) + +// classdef: 'class' NAME ['(' [arglist] ')'] ':' suite + +DEF_RULE(classdef, c(classdef), and_blank(5), tok(KW_CLASS), tok(NAME), opt_rule(classdef_2), tok(DEL_COLON), rule(suite)) +DEF_RULE_NC(classdef_2, and_ident(3), tok(DEL_PAREN_OPEN), opt_rule(arglist), tok(DEL_PAREN_CLOSE)) + +// arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test) + +// TODO arglist lets through more than is allowed, compiler needs to do further verification +DEF_RULE_NC(arglist, list_with_end, rule(arglist_2), tok(DEL_COMMA)) +DEF_RULE_NC(arglist_2, or(3), rule(arglist_star), rule(arglist_dbl_star), rule(argument)) +DEF_RULE_NC(arglist_star, and(2), tok(OP_STAR), rule(test)) +DEF_RULE_NC(arglist_dbl_star, and(2), tok(OP_DBL_STAR), rule(test)) + +// # The reason that keywords are test nodes instead of NAME is that using NAME +// # results in an ambiguity. ast.c makes sure it's a NAME. +// argument: test [comp_for] | test '=' test # Really [keyword '='] test +// comp_iter: comp_for | comp_if +// comp_for: 'for' exprlist 'in' or_test [comp_iter] +// comp_if: 'if' test_nocond [comp_iter] + +DEF_RULE_NC(argument, and_ident(2), rule(test), opt_rule(argument_2)) +DEF_RULE_NC(argument_2, or(2), rule(comp_for), rule(argument_3)) +DEF_RULE_NC(argument_3, and_ident(2), tok(DEL_EQUAL), rule(test)) +DEF_RULE_NC(comp_iter, or(2), rule(comp_for), rule(comp_if)) +DEF_RULE_NC(comp_for, and_blank(5), tok(KW_FOR), rule(exprlist), tok(KW_IN), rule(or_test), opt_rule(comp_iter)) +DEF_RULE_NC(comp_if, and(3), tok(KW_IF), rule(test_nocond), opt_rule(comp_iter)) + +// # not used in grammar, but may appear in "node" passed from Parser to Compiler +// encoding_decl: NAME + +// yield_expr: 'yield' [yield_arg] +// yield_arg: 'from' test | testlist + +DEF_RULE(yield_expr, c(yield_expr), and(2), tok(KW_YIELD), opt_rule(yield_arg)) +DEF_RULE_NC(yield_arg, or(2), rule(yield_arg_from), rule(testlist)) +DEF_RULE_NC(yield_arg_from, and(2), tok(KW_FROM), rule(test)) diff --git a/user/mpy/py/lexer.c b/user/mpy/py/lexer.c new file mode 100644 index 0000000..074d6f3 --- /dev/null +++ b/user/mpy/py/lexer.c @@ -0,0 +1,763 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpstate.h" +#include "py/reader.h" +#include "py/lexer.h" +#include "py/runtime.h" + +#if MICROPY_ENABLE_COMPILER + +#define TAB_SIZE (8) + +// TODO seems that CPython allows NULL byte in the input stream +// don't know if that's intentional or not, but we don't allow it + +#define MP_LEXER_EOF ((unichar)MP_READER_EOF) +#define CUR_CHAR(lex) ((lex)->chr0) + +STATIC bool is_end(mp_lexer_t *lex) { + return lex->chr0 == MP_LEXER_EOF; +} + +STATIC bool is_physical_newline(mp_lexer_t *lex) { + return lex->chr0 == '\n'; +} + +STATIC bool is_char(mp_lexer_t *lex, byte c) { + return lex->chr0 == c; +} + +STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr0 == c1 || lex->chr0 == c2; +} + +STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) { + return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3; +} + +STATIC bool is_char_following(mp_lexer_t *lex, byte c) { + return lex->chr1 == c; +} + +STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr1 == c1 || lex->chr1 == c2; +} + +STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr2 == c1 || lex->chr2 == c2; +} + +STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) { + return lex->chr0 == c1 && lex->chr1 == c2; +} + +STATIC bool is_whitespace(mp_lexer_t *lex) { + return unichar_isspace(lex->chr0); +} + +STATIC bool is_letter(mp_lexer_t *lex) { + return unichar_isalpha(lex->chr0); +} + +STATIC bool is_digit(mp_lexer_t *lex) { + return unichar_isdigit(lex->chr0); +} + +STATIC bool is_following_digit(mp_lexer_t *lex) { + return unichar_isdigit(lex->chr1); +} + +STATIC bool is_following_base_char(mp_lexer_t *lex) { + const unichar chr1 = lex->chr1 | 0x20; + return chr1 == 'b' || chr1 == 'o' || chr1 == 'x'; +} + +STATIC bool is_following_odigit(mp_lexer_t *lex) { + return lex->chr1 >= '0' && lex->chr1 <= '7'; +} + +STATIC bool is_string_or_bytes(mp_lexer_t *lex) { + return is_char_or(lex, '\'', '\"') + || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"')) + || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r')) + && is_char_following_following_or(lex, '\'', '\"')); +} + +// to easily parse utf-8 identifiers we allow any raw byte with high bit set +STATIC bool is_head_of_identifier(mp_lexer_t *lex) { + return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80; +} + +STATIC bool is_tail_of_identifier(mp_lexer_t *lex) { + return is_head_of_identifier(lex) || is_digit(lex); +} + +STATIC void next_char(mp_lexer_t *lex) { + if (lex->chr0 == '\n') { + // a new line + ++lex->line; + lex->column = 1; + } else if (lex->chr0 == '\t') { + // a tab + lex->column = (((lex->column - 1 + TAB_SIZE) / TAB_SIZE) * TAB_SIZE) + 1; + } else { + // a character worth one column + ++lex->column; + } + + lex->chr0 = lex->chr1; + lex->chr1 = lex->chr2; + lex->chr2 = lex->reader.readbyte(lex->reader.data); + + if (lex->chr1 == '\r') { + // CR is a new line, converted to LF + lex->chr1 = '\n'; + if (lex->chr2 == '\n') { + // CR LF is a single new line, throw out the extra LF + lex->chr2 = lex->reader.readbyte(lex->reader.data); + } + } + + // check if we need to insert a newline at end of file + if (lex->chr2 == MP_LEXER_EOF && lex->chr1 != MP_LEXER_EOF && lex->chr1 != '\n') { + lex->chr2 = '\n'; + } +} + +STATIC void indent_push(mp_lexer_t *lex, size_t indent) { + if (lex->num_indent_level >= lex->alloc_indent_level) { + lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC); + lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC; + } + lex->indent_level[lex->num_indent_level++] = indent; +} + +STATIC size_t indent_top(mp_lexer_t *lex) { + return lex->indent_level[lex->num_indent_level - 1]; +} + +STATIC void indent_pop(mp_lexer_t *lex) { + lex->num_indent_level -= 1; +} + +// some tricky operator encoding: +// = begin with , if this opchar matches then begin here +// e = end with , if this opchar matches then end +// c = continue with , if this opchar matches then continue matching +// this means if the start of two ops are the same then they are equal til the last char + +STATIC const char *const tok_enc = + "()[]{},:;@~" // singles + "e=c>e=" // > >= >> >>= + "*e=c*e=" // * *= ** **= + "+e=" // + += + "-e=e>" // - -= -> + "&e=" // & &= + "|e=" // | |= + "/e=c/e=" // / /= // //= + "%e=" // % %= + "^e=" // ^ ^= + "=e=" // = == + "!."; // start of special cases: != . ... + +// TODO static assert that number of tokens is less than 256 so we can safely make this table with byte sized entries +STATIC const uint8_t tok_enc_kind[] = { + MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, MP_TOKEN_DEL_COLON, MP_TOKEN_DEL_SEMICOLON, MP_TOKEN_DEL_AT, MP_TOKEN_OP_TILDE, + + MP_TOKEN_OP_LESS, MP_TOKEN_OP_LESS_EQUAL, MP_TOKEN_OP_DBL_LESS, MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_OP_MORE, MP_TOKEN_OP_MORE_EQUAL, MP_TOKEN_OP_DBL_MORE, MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_OP_STAR, MP_TOKEN_DEL_STAR_EQUAL, MP_TOKEN_OP_DBL_STAR, MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_OP_PLUS, MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_OP_MINUS, MP_TOKEN_DEL_MINUS_EQUAL, MP_TOKEN_DEL_MINUS_MORE, + MP_TOKEN_OP_AMPERSAND, MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_OP_PIPE, MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_OP_SLASH, MP_TOKEN_DEL_SLASH_EQUAL, MP_TOKEN_OP_DBL_SLASH, MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_OP_PERCENT, MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_OP_CARET, MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_EQUAL, MP_TOKEN_OP_DBL_EQUAL, +}; + +// must have the same order as enum in lexer.h +// must be sorted according to strcmp +STATIC const char *const tok_kw[] = { + "False", + "None", + "True", + "__debug__", + "and", + "as", + "assert", + #if MICROPY_PY_ASYNC_AWAIT + "async", + "await", + #endif + "break", + "class", + "continue", + "def", + "del", + "elif", + "else", + "except", + "finally", + "for", + "from", + "global", + "if", + "import", + "in", + "is", + "lambda", + "nonlocal", + "not", + "or", + "pass", + "raise", + "return", + "try", + "while", + "with", + "yield", +}; + +// This is called with CUR_CHAR() before first hex digit, and should return with +// it pointing to last hex digit +// num_digits must be greater than zero +STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) { + mp_uint_t num = 0; + while (num_digits-- != 0) { + next_char(lex); + unichar c = CUR_CHAR(lex); + if (!unichar_isxdigit(c)) { + return false; + } + num = (num << 4) + unichar_xdigit_value(c); + } + *result = num; + return true; +} + +STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) { + // get first quoting character + char quote_char = '\''; + if (is_char(lex, '\"')) { + quote_char = '\"'; + } + next_char(lex); + + // work out if it's a single or triple quoted literal + size_t num_quotes; + if (is_char_and(lex, quote_char, quote_char)) { + // triple quotes + next_char(lex); + next_char(lex); + num_quotes = 3; + } else { + // single quotes + num_quotes = 1; + } + + size_t n_closing = 0; + while (!is_end(lex) && (num_quotes > 1 || !is_char(lex, '\n')) && n_closing < num_quotes) { + if (is_char(lex, quote_char)) { + n_closing += 1; + vstr_add_char(&lex->vstr, CUR_CHAR(lex)); + } else { + n_closing = 0; + if (is_char(lex, '\\')) { + next_char(lex); + unichar c = CUR_CHAR(lex); + if (is_raw) { + // raw strings allow escaping of quotes, but the backslash is also emitted + vstr_add_char(&lex->vstr, '\\'); + } else { + switch (c) { + // note: "c" can never be MP_LEXER_EOF because next_char + // always inserts a newline at the end of the input stream + case '\n': c = MP_LEXER_EOF; break; // backslash escape the newline, just ignore it + case '\\': break; + case '\'': break; + case '"': break; + case 'a': c = 0x07; break; + case 'b': c = 0x08; break; + case 't': c = 0x09; break; + case 'n': c = 0x0a; break; + case 'v': c = 0x0b; break; + case 'f': c = 0x0c; break; + case 'r': c = 0x0d; break; + case 'u': + case 'U': + if (lex->tok_kind == MP_TOKEN_BYTES) { + // b'\u1234' == b'\\u1234' + vstr_add_char(&lex->vstr, '\\'); + break; + } + // Otherwise fall through. + case 'x': + { + mp_uint_t num = 0; + if (!get_hex(lex, (c == 'x' ? 2 : c == 'u' ? 4 : 8), &num)) { + // not enough hex chars for escape sequence + lex->tok_kind = MP_TOKEN_INVALID; + } + c = num; + break; + } + case 'N': + // Supporting '\N{LATIN SMALL LETTER A}' == 'a' would require keeping the + // entire Unicode name table in the core. As of Unicode 6.3.0, that's nearly + // 3MB of text; even gzip-compressed and with minimal structure, it'll take + // roughly half a meg of storage. This form of Unicode escape may be added + // later on, but it's definitely not a priority right now. -- CJA 20140607 + mp_raise_NotImplementedError("unicode name escapes"); + break; + default: + if (c >= '0' && c <= '7') { + // Octal sequence, 1-3 chars + size_t digits = 3; + mp_uint_t num = c - '0'; + while (is_following_odigit(lex) && --digits != 0) { + next_char(lex); + num = num * 8 + (CUR_CHAR(lex) - '0'); + } + c = num; + } else { + // unrecognised escape character; CPython lets this through verbatim as '\' and then the character + vstr_add_char(&lex->vstr, '\\'); + } + break; + } + } + if (c != MP_LEXER_EOF) { + if (MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) { + if (c < 0x110000 && lex->tok_kind == MP_TOKEN_STRING) { + vstr_add_char(&lex->vstr, c); + } else if (c < 0x100 && lex->tok_kind == MP_TOKEN_BYTES) { + vstr_add_byte(&lex->vstr, c); + } else { + // unicode character out of range + // this raises a generic SyntaxError; could provide more info + lex->tok_kind = MP_TOKEN_INVALID; + } + } else { + // without unicode everything is just added as an 8-bit byte + if (c < 0x100) { + vstr_add_byte(&lex->vstr, c); + } else { + // 8-bit character out of range + // this raises a generic SyntaxError; could provide more info + lex->tok_kind = MP_TOKEN_INVALID; + } + } + } + } else { + // Add the "character" as a byte so that we remain 8-bit clean. + // This way, strings are parsed correctly whether or not they contain utf-8 chars. + vstr_add_byte(&lex->vstr, CUR_CHAR(lex)); + } + } + next_char(lex); + } + + // check we got the required end quotes + if (n_closing < num_quotes) { + lex->tok_kind = MP_TOKEN_LONELY_STRING_OPEN; + } + + // cut off the end quotes from the token text + vstr_cut_tail_bytes(&lex->vstr, n_closing); +} + +STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) { + bool had_physical_newline = false; + while (!is_end(lex)) { + if (is_physical_newline(lex)) { + if (stop_at_newline && lex->nested_bracket_level == 0) { + break; + } + had_physical_newline = true; + next_char(lex); + } else if (is_whitespace(lex)) { + next_char(lex); + } else if (is_char(lex, '#')) { + next_char(lex); + while (!is_end(lex) && !is_physical_newline(lex)) { + next_char(lex); + } + // had_physical_newline will be set on next loop + } else if (is_char_and(lex, '\\', '\n')) { + // line-continuation, so don't set had_physical_newline + next_char(lex); + next_char(lex); + } else { + break; + } + } + return had_physical_newline; +} + +void mp_lexer_to_next(mp_lexer_t *lex) { + // start new token text + vstr_reset(&lex->vstr); + + // skip white space and comments + bool had_physical_newline = skip_whitespace(lex, false); + + // set token source information + lex->tok_line = lex->line; + lex->tok_column = lex->column; + + if (lex->emit_dent < 0) { + lex->tok_kind = MP_TOKEN_DEDENT; + lex->emit_dent += 1; + + } else if (lex->emit_dent > 0) { + lex->tok_kind = MP_TOKEN_INDENT; + lex->emit_dent -= 1; + + } else if (had_physical_newline && lex->nested_bracket_level == 0) { + lex->tok_kind = MP_TOKEN_NEWLINE; + + size_t num_spaces = lex->column - 1; + if (num_spaces == indent_top(lex)) { + } else if (num_spaces > indent_top(lex)) { + indent_push(lex, num_spaces); + lex->emit_dent += 1; + } else { + while (num_spaces < indent_top(lex)) { + indent_pop(lex); + lex->emit_dent -= 1; + } + if (num_spaces != indent_top(lex)) { + lex->tok_kind = MP_TOKEN_DEDENT_MISMATCH; + } + } + + } else if (is_end(lex)) { + lex->tok_kind = MP_TOKEN_END; + + } else if (is_string_or_bytes(lex)) { + // a string or bytes literal + + // Python requires adjacent string/bytes literals to be automatically + // concatenated. We do it here in the tokeniser to make efficient use of RAM, + // because then the lexer's vstr can be used to accumulate the string literal, + // in contrast to creating a parse tree of strings and then joining them later + // in the compiler. It's also more compact in code size to do it here. + + // MP_TOKEN_END is used to indicate that this is the first string token + lex->tok_kind = MP_TOKEN_END; + + // Loop to accumulate string/bytes literals + do { + // parse type codes + bool is_raw = false; + mp_token_kind_t kind = MP_TOKEN_STRING; + int n_char = 0; + if (is_char(lex, 'u')) { + n_char = 1; + } else if (is_char(lex, 'b')) { + kind = MP_TOKEN_BYTES; + n_char = 1; + if (is_char_following(lex, 'r')) { + is_raw = true; + n_char = 2; + } + } else if (is_char(lex, 'r')) { + is_raw = true; + n_char = 1; + if (is_char_following(lex, 'b')) { + kind = MP_TOKEN_BYTES; + n_char = 2; + } + } + + // Set or check token kind + if (lex->tok_kind == MP_TOKEN_END) { + lex->tok_kind = kind; + } else if (lex->tok_kind != kind) { + // Can't concatenate string with bytes + break; + } + + // Skip any type code characters + if (n_char != 0) { + next_char(lex); + if (n_char == 2) { + next_char(lex); + } + } + + // Parse the literal + parse_string_literal(lex, is_raw); + + // Skip whitespace so we can check if there's another string following + skip_whitespace(lex, true); + + } while (is_string_or_bytes(lex)); + + } else if (is_head_of_identifier(lex)) { + lex->tok_kind = MP_TOKEN_NAME; + + // get first char (add as byte to remain 8-bit clean and support utf-8) + vstr_add_byte(&lex->vstr, CUR_CHAR(lex)); + next_char(lex); + + // get tail chars + while (!is_end(lex) && is_tail_of_identifier(lex)) { + vstr_add_byte(&lex->vstr, CUR_CHAR(lex)); + next_char(lex); + } + + // Check if the name is a keyword. + // We also check for __debug__ here and convert it to its value. This is + // so the parser gives a syntax error on, eg, x.__debug__. Otherwise, we + // need to check for this special token in many places in the compiler. + const char *s = vstr_null_terminated_str(&lex->vstr); + for (size_t i = 0; i < MP_ARRAY_SIZE(tok_kw); i++) { + int cmp = strcmp(s, tok_kw[i]); + if (cmp == 0) { + lex->tok_kind = MP_TOKEN_KW_FALSE + i; + if (lex->tok_kind == MP_TOKEN_KW___DEBUG__) { + lex->tok_kind = (MP_STATE_VM(mp_optimise_value) == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE); + } + break; + } else if (cmp < 0) { + // Table is sorted and comparison was less-than, so stop searching + break; + } + } + + } else if (is_digit(lex) || (is_char(lex, '.') && is_following_digit(lex))) { + bool forced_integer = false; + if (is_char(lex, '.')) { + lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; + } else { + lex->tok_kind = MP_TOKEN_INTEGER; + if (is_char(lex, '0') && is_following_base_char(lex)) { + forced_integer = true; + } + } + + // get first char + vstr_add_char(&lex->vstr, CUR_CHAR(lex)); + next_char(lex); + + // get tail chars + while (!is_end(lex)) { + if (!forced_integer && is_char_or(lex, 'e', 'E')) { + lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; + vstr_add_char(&lex->vstr, 'e'); + next_char(lex); + if (is_char(lex, '+') || is_char(lex, '-')) { + vstr_add_char(&lex->vstr, CUR_CHAR(lex)); + next_char(lex); + } + } else if (is_letter(lex) || is_digit(lex) || is_char(lex, '.')) { + if (is_char_or3(lex, '.', 'j', 'J')) { + lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; + } + vstr_add_char(&lex->vstr, CUR_CHAR(lex)); + next_char(lex); + } else { + break; + } + } + + } else { + // search for encoded delimiter or operator + + const char *t = tok_enc; + size_t tok_enc_index = 0; + for (; *t != 0 && !is_char(lex, *t); t += 1) { + if (*t == 'e' || *t == 'c') { + t += 1; + } + tok_enc_index += 1; + } + + next_char(lex); + + if (*t == 0) { + // didn't match any delimiter or operator characters + lex->tok_kind = MP_TOKEN_INVALID; + + } else if (*t == '!') { + // "!=" is a special case because "!" is not a valid operator + if (is_char(lex, '=')) { + next_char(lex); + lex->tok_kind = MP_TOKEN_OP_NOT_EQUAL; + } else { + lex->tok_kind = MP_TOKEN_INVALID; + } + + } else if (*t == '.') { + // "." and "..." are special cases because ".." is not a valid operator + if (is_char_and(lex, '.', '.')) { + next_char(lex); + next_char(lex); + lex->tok_kind = MP_TOKEN_ELLIPSIS; + } else { + lex->tok_kind = MP_TOKEN_DEL_PERIOD; + } + + } else { + // matched a delimiter or operator character + + // get the maximum characters for a valid token + t += 1; + size_t t_index = tok_enc_index; + while (*t == 'c' || *t == 'e') { + t_index += 1; + if (is_char(lex, t[1])) { + next_char(lex); + tok_enc_index = t_index; + if (*t == 'e') { + break; + } + } else if (*t == 'c') { + break; + } + t += 2; + } + + // set token kind + lex->tok_kind = tok_enc_kind[tok_enc_index]; + + // compute bracket level for implicit line joining + if (lex->tok_kind == MP_TOKEN_DEL_PAREN_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACKET_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACE_OPEN) { + lex->nested_bracket_level += 1; + } else if (lex->tok_kind == MP_TOKEN_DEL_PAREN_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACKET_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACE_CLOSE) { + lex->nested_bracket_level -= 1; + } + } + } +} + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) { + mp_lexer_t *lex = m_new_obj(mp_lexer_t); + + lex->source_name = src_name; + lex->reader = reader; + lex->line = 1; + lex->column = (size_t)-2; // account for 3 dummy bytes + lex->emit_dent = 0; + lex->nested_bracket_level = 0; + lex->alloc_indent_level = MICROPY_ALLOC_LEXER_INDENT_INIT; + lex->num_indent_level = 1; + lex->indent_level = m_new(uint16_t, lex->alloc_indent_level); + vstr_init(&lex->vstr, 32); + + // store sentinel for first indentation level + lex->indent_level[0] = 0; + + // load lexer with start of file, advancing lex->column to 1 + // start with dummy bytes and use next_char() for proper EOL/EOF handling + lex->chr0 = lex->chr1 = lex->chr2 = 0; + next_char(lex); + next_char(lex); + next_char(lex); + + // preload first token + mp_lexer_to_next(lex); + + // Check that the first token is in the first column. If it's not then we + // convert the token kind to INDENT so that the parser gives a syntax error. + if (lex->tok_column != 1) { + lex->tok_kind = MP_TOKEN_INDENT; + } + + return lex; +} + +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len) { + mp_reader_t reader; + mp_reader_new_mem(&reader, (const byte*)str, len, free_len); + return mp_lexer_new(src_name, reader); +} + +#if MICROPY_READER_POSIX || MICROPY_READER_VFS + +mp_lexer_t *mp_lexer_new_from_file(const char *filename) { + mp_reader_t reader; + mp_reader_new_file(&reader, filename); + return mp_lexer_new(qstr_from_str(filename), reader); +} + +#if MICROPY_HELPER_LEXER_UNIX + +mp_lexer_t *mp_lexer_new_from_fd(qstr filename, int fd, bool close_fd) { + mp_reader_t reader; + mp_reader_new_file_from_fd(&reader, fd, close_fd); + return mp_lexer_new(filename, reader); +} + +#endif + +#endif + +void mp_lexer_free(mp_lexer_t *lex) { + if (lex) { + lex->reader.close(lex->reader.data); + vstr_clear(&lex->vstr); + m_del(uint16_t, lex->indent_level, lex->alloc_indent_level); + m_del_obj(mp_lexer_t, lex); + } +} + +#if 0 +// This function is used to print the current token and should only be +// needed to debug the lexer, so it's not available via a config option. +void mp_lexer_show_token(const mp_lexer_t *lex) { + printf("(" UINT_FMT ":" UINT_FMT ") kind:%u str:%p len:%zu", lex->tok_line, lex->tok_column, lex->tok_kind, lex->vstr.buf, lex->vstr.len); + if (lex->vstr.len > 0) { + const byte *i = (const byte *)lex->vstr.buf; + const byte *j = (const byte *)i + lex->vstr.len; + printf(" "); + while (i < j) { + unichar c = utf8_get_char(i); + i = utf8_next_char(i); + if (unichar_isprint(c)) { + printf("%c", (int)c); + } else { + printf("?"); + } + } + } + printf("\n"); +} +#endif + +#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/lexer.h b/user/mpy/py/lexer.h new file mode 100644 index 0000000..a297091 --- /dev/null +++ b/user/mpy/py/lexer.h @@ -0,0 +1,195 @@ +/* + * 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_LEXER_H +#define MICROPY_INCLUDED_PY_LEXER_H + +#include + +#include "py/mpconfig.h" +#include "py/qstr.h" +#include "py/reader.h" + +/* lexer.h -- simple tokeniser for MicroPython + * + * Uses (byte) length instead of null termination. + * Tokens are the same - UTF-8 with (byte) length. + */ + +typedef enum _mp_token_kind_t { + MP_TOKEN_END, + + MP_TOKEN_INVALID, + MP_TOKEN_DEDENT_MISMATCH, + MP_TOKEN_LONELY_STRING_OPEN, + + MP_TOKEN_NEWLINE, + MP_TOKEN_INDENT, + MP_TOKEN_DEDENT, + + MP_TOKEN_NAME, + MP_TOKEN_INTEGER, + MP_TOKEN_FLOAT_OR_IMAG, + MP_TOKEN_STRING, + MP_TOKEN_BYTES, + + MP_TOKEN_ELLIPSIS, + + MP_TOKEN_KW_FALSE, + MP_TOKEN_KW_NONE, + MP_TOKEN_KW_TRUE, + MP_TOKEN_KW___DEBUG__, + MP_TOKEN_KW_AND, + MP_TOKEN_KW_AS, + MP_TOKEN_KW_ASSERT, + #if MICROPY_PY_ASYNC_AWAIT + MP_TOKEN_KW_ASYNC, + MP_TOKEN_KW_AWAIT, + #endif + MP_TOKEN_KW_BREAK, + MP_TOKEN_KW_CLASS, + MP_TOKEN_KW_CONTINUE, + MP_TOKEN_KW_DEF, + MP_TOKEN_KW_DEL, + MP_TOKEN_KW_ELIF, + MP_TOKEN_KW_ELSE, + MP_TOKEN_KW_EXCEPT, + MP_TOKEN_KW_FINALLY, + MP_TOKEN_KW_FOR, + MP_TOKEN_KW_FROM, + MP_TOKEN_KW_GLOBAL, + MP_TOKEN_KW_IF, + MP_TOKEN_KW_IMPORT, + MP_TOKEN_KW_IN, + MP_TOKEN_KW_IS, + MP_TOKEN_KW_LAMBDA, + MP_TOKEN_KW_NONLOCAL, + MP_TOKEN_KW_NOT, + MP_TOKEN_KW_OR, + MP_TOKEN_KW_PASS, + MP_TOKEN_KW_RAISE, + MP_TOKEN_KW_RETURN, + MP_TOKEN_KW_TRY, + MP_TOKEN_KW_WHILE, + MP_TOKEN_KW_WITH, + MP_TOKEN_KW_YIELD, + + MP_TOKEN_OP_PLUS, + MP_TOKEN_OP_MINUS, + MP_TOKEN_OP_STAR, + MP_TOKEN_OP_DBL_STAR, + MP_TOKEN_OP_SLASH, + MP_TOKEN_OP_DBL_SLASH, + MP_TOKEN_OP_PERCENT, + MP_TOKEN_OP_LESS, + MP_TOKEN_OP_DBL_LESS, + MP_TOKEN_OP_MORE, + MP_TOKEN_OP_DBL_MORE, + MP_TOKEN_OP_AMPERSAND, + MP_TOKEN_OP_PIPE, + MP_TOKEN_OP_CARET, + MP_TOKEN_OP_TILDE, + MP_TOKEN_OP_LESS_EQUAL, + MP_TOKEN_OP_MORE_EQUAL, + MP_TOKEN_OP_DBL_EQUAL, + MP_TOKEN_OP_NOT_EQUAL, + + MP_TOKEN_DEL_PAREN_OPEN, + MP_TOKEN_DEL_PAREN_CLOSE, + MP_TOKEN_DEL_BRACKET_OPEN, + MP_TOKEN_DEL_BRACKET_CLOSE, + MP_TOKEN_DEL_BRACE_OPEN, + MP_TOKEN_DEL_BRACE_CLOSE, + MP_TOKEN_DEL_COMMA, + MP_TOKEN_DEL_COLON, + MP_TOKEN_DEL_PERIOD, + MP_TOKEN_DEL_SEMICOLON, + MP_TOKEN_DEL_AT, + MP_TOKEN_DEL_EQUAL, + MP_TOKEN_DEL_PLUS_EQUAL, + MP_TOKEN_DEL_MINUS_EQUAL, + MP_TOKEN_DEL_STAR_EQUAL, + MP_TOKEN_DEL_SLASH_EQUAL, + MP_TOKEN_DEL_DBL_SLASH_EQUAL, + MP_TOKEN_DEL_PERCENT_EQUAL, + MP_TOKEN_DEL_AMPERSAND_EQUAL, + MP_TOKEN_DEL_PIPE_EQUAL, + MP_TOKEN_DEL_CARET_EQUAL, + MP_TOKEN_DEL_DBL_MORE_EQUAL, + MP_TOKEN_DEL_DBL_LESS_EQUAL, + MP_TOKEN_DEL_DBL_STAR_EQUAL, + MP_TOKEN_DEL_MINUS_MORE, +} mp_token_kind_t; + +// this data structure is exposed for efficiency +// public members are: source_name, tok_line, tok_column, tok_kind, vstr +typedef struct _mp_lexer_t { + qstr source_name; // name of source + mp_reader_t reader; // stream source + + unichar chr0, chr1, chr2; // current cached characters from source + + size_t line; // current source line + size_t column; // current source column + + mp_int_t emit_dent; // non-zero when there are INDENT/DEDENT tokens to emit + mp_int_t nested_bracket_level; // >0 when there are nested brackets over multiple lines + + size_t alloc_indent_level; + size_t num_indent_level; + uint16_t *indent_level; + + size_t tok_line; // token source line + size_t tok_column; // token source column + mp_token_kind_t tok_kind; // token kind + vstr_t vstr; // token data +} mp_lexer_t; + +mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); +mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); + +void mp_lexer_free(mp_lexer_t *lex); +void mp_lexer_to_next(mp_lexer_t *lex); + +/******************************************************************/ +// platform specific import function; must be implemented for a specific port +// TODO tidy up, rename, or put elsewhere + +//mp_lexer_t *mp_import_open_file(qstr mod_name); + +typedef enum { + MP_IMPORT_STAT_NO_EXIST, + MP_IMPORT_STAT_DIR, + MP_IMPORT_STAT_FILE, +} mp_import_stat_t; + +mp_import_stat_t mp_import_stat(const char *path); +mp_lexer_t *mp_lexer_new_from_file(const char *filename); + +#if MICROPY_HELPER_LEXER_UNIX +mp_lexer_t *mp_lexer_new_from_fd(qstr filename, int fd, bool close_fd); +#endif + +#endif // MICROPY_INCLUDED_PY_LEXER_H diff --git a/user/mpy/py/makeqstrdata.py b/user/mpy/py/makeqstrdata.py new file mode 100644 index 0000000..7249769 --- /dev/null +++ b/user/mpy/py/makeqstrdata.py @@ -0,0 +1,158 @@ +""" +Process raw qstr file and output qstr data with length, hash and data bytes. + +This script works with Python 2.6, 2.7, 3.3 and 3.4. +""" + +from __future__ import print_function + +import re +import sys + +# Python 2/3 compatibility: +# - iterating through bytes is different +# - codepoint2name lives in a different module +import platform +if platform.python_version_tuple()[0] == '2': + bytes_cons = lambda val, enc=None: bytearray(val) + from htmlentitydefs import codepoint2name +elif platform.python_version_tuple()[0] == '3': + bytes_cons = bytes + from html.entities import codepoint2name +# end compatibility code + +codepoint2name[ord('-')] = 'hyphen'; + +# add some custom names to map characters that aren't in HTML +codepoint2name[ord(' ')] = 'space' +codepoint2name[ord('\'')] = 'squot' +codepoint2name[ord(',')] = 'comma' +codepoint2name[ord('.')] = 'dot' +codepoint2name[ord(':')] = 'colon' +codepoint2name[ord(';')] = 'semicolon' +codepoint2name[ord('/')] = 'slash' +codepoint2name[ord('%')] = 'percent' +codepoint2name[ord('#')] = 'hash' +codepoint2name[ord('(')] = 'paren_open' +codepoint2name[ord(')')] = 'paren_close' +codepoint2name[ord('[')] = 'bracket_open' +codepoint2name[ord(']')] = 'bracket_close' +codepoint2name[ord('{')] = 'brace_open' +codepoint2name[ord('}')] = 'brace_close' +codepoint2name[ord('*')] = 'star' +codepoint2name[ord('!')] = 'bang' +codepoint2name[ord('\\')] = 'backslash' +codepoint2name[ord('+')] = 'plus' +codepoint2name[ord('$')] = 'dollar' +codepoint2name[ord('=')] = 'equals' +codepoint2name[ord('?')] = 'question' +codepoint2name[ord('@')] = 'at_sign' +codepoint2name[ord('^')] = 'caret' +codepoint2name[ord('|')] = 'pipe' +codepoint2name[ord('~')] = 'tilde' + +# this must match the equivalent function in qstr.c +def compute_hash(qstr, bytes_hash): + hash = 5381 + for b in qstr: + hash = (hash * 33) ^ b + # Make sure that valid hash is never zero, zero means "hash not computed" + return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1 + +def qstr_escape(qst): + def esc_char(m): + c = ord(m.group(0)) + try: + name = codepoint2name[c] + except KeyError: + name = '0x%02x' % c + return "_" + name + '_' + return re.sub(r'[^A-Za-z0-9_]', esc_char, qst) + +def parse_input_headers(infiles): + # read the qstrs in from the input files + qcfgs = {} + qstrs = {} + for infile in infiles: + with open(infile, 'rt') as f: + for line in f: + line = line.strip() + + # is this a config line? + match = re.match(r'^QCFG\((.+), (.+)\)', line) + if match: + value = match.group(2) + if value[0] == '(' and value[-1] == ')': + # strip parenthesis from config value + value = value[1:-1] + qcfgs[match.group(1)] = value + continue + + # is this a QSTR line? + match = re.match(r'^Q\((.*)\)$', line) + if not match: + continue + + # get the qstr value + qstr = match.group(1) + + # special case to specify control characters + if qstr == '\\n': + qstr = '\n' + + # work out the corresponding qstr name + ident = qstr_escape(qstr) + + # don't add duplicates + if ident in qstrs: + continue + + # add the qstr to the list, with order number to retain original order in file + qstrs[ident] = (len(qstrs), ident, qstr) + + if not qcfgs: + sys.stderr.write("ERROR: Empty preprocessor output - check for errors above\n") + sys.exit(1) + + return qcfgs, qstrs + +def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr): + qbytes = bytes_cons(qstr, 'utf8') + qlen = len(qbytes) + qhash = compute_hash(qbytes, cfg_bytes_hash) + if all(32 <= ord(c) <= 126 and c != '\\' and c != '"' for c in qstr): + # qstr is all printable ASCII so render it as-is (for easier debugging) + qdata = qstr + else: + # qstr contains non-printable codes so render entire thing as hex pairs + qdata = ''.join(('\\x%02x' % b) for b in qbytes) + if qlen >= (1 << (8 * cfg_bytes_len)): + print('qstr is too long:', qstr) + assert False + qlen_str = ('\\x%02x' * cfg_bytes_len) % tuple(((qlen >> (8 * i)) & 0xff) for i in range(cfg_bytes_len)) + qhash_str = ('\\x%02x' * cfg_bytes_hash) % tuple(((qhash >> (8 * i)) & 0xff) for i in range(cfg_bytes_hash)) + return '(const byte*)"%s%s" "%s"' % (qhash_str, qlen_str, qdata) + +def print_qstr_data(qcfgs, qstrs): + # get config variables + cfg_bytes_len = int(qcfgs['BYTES_IN_LEN']) + cfg_bytes_hash = int(qcfgs['BYTES_IN_HASH']) + + # print out the starter of the generated C header file + print('// This file was automatically generated by makeqstrdata.py') + print('') + + # add NULL qstr with no hash or data + print('QDEF(MP_QSTR_NULL, (const byte*)"%s%s" "")' % ('\\x00' * cfg_bytes_hash, '\\x00' * cfg_bytes_len)) + + # go through each qstr and print it out + for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]): + qbytes = make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr) + print('QDEF(MP_QSTR_%s, %s)' % (ident, qbytes)) + +def do_work(infiles): + qcfgs, qstrs = parse_input_headers(infiles) + print_qstr_data(qcfgs, qstrs) + +if __name__ == "__main__": + do_work(sys.argv[1:]) diff --git a/user/mpy/py/makeqstrdefs.py b/user/mpy/py/makeqstrdefs.py new file mode 100644 index 0000000..525dec1 --- /dev/null +++ b/user/mpy/py/makeqstrdefs.py @@ -0,0 +1,111 @@ +""" +This script processes the output from the C preprocessor and extracts all +qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'. + +This script works with Python 2.6, 2.7, 3.3 and 3.4. +""" + +from __future__ import print_function + +import re +import sys +import os + +# Blacklist of qstrings that are specially handled in further +# processing and should be ignored +QSTRING_BLACK_LIST = set(['NULL', 'number_of']) + + +def write_out(fname, output): + if output: + for m, r in [("/", "__"), ("\\", "__"), (":", "@"), ("..", "@@")]: + fname = fname.replace(m, r) + with open(args.output_dir + "/" + fname + ".qstr", "w") as f: + f.write("\n".join(output) + "\n") + +def process_file(f): + output = [] + last_fname = None + for line in f: + # match gcc-like output (# n "file") and msvc-like output (#line n "file") + if line and (line[0:2] == "# " or line[0:5] == "#line"): + m = re.match(r"#[line]*\s\d+\s\"([^\"]+)\"", line) + assert m is not None + fname = m.group(1) + if not fname.endswith(".c"): + continue + if fname != last_fname: + write_out(last_fname, output) + output = [] + last_fname = fname + continue + for match in re.findall(r'MP_QSTR_[_a-zA-Z0-9]+', line): + name = match.replace('MP_QSTR_', '') + if name not in QSTRING_BLACK_LIST: + output.append('Q(' + name + ')') + + write_out(last_fname, output) + return "" + + +def cat_together(): + import glob + import hashlib + hasher = hashlib.md5() + all_lines = [] + outf = open(args.output_dir + "/out", "wb") + for fname in glob.glob(args.output_dir + "/*.qstr"): + with open(fname, "rb") as f: + lines = f.readlines() + all_lines += lines + all_lines.sort() + all_lines = b"\n".join(all_lines) + outf.write(all_lines) + outf.close() + hasher.update(all_lines) + new_hash = hasher.hexdigest() + #print(new_hash) + old_hash = None + try: + with open(args.output_file + ".hash") as f: + old_hash = f.read() + except IOError: + pass + if old_hash != new_hash: + print("QSTR updated") + try: + # rename below might fail if file exists + os.remove(args.output_file) + except: + pass + os.rename(args.output_dir + "/out", args.output_file) + with open(args.output_file + ".hash", "w") as f: + f.write(new_hash) + else: + print("QSTR not updated") + + +if __name__ == "__main__": + if len(sys.argv) != 5: + print('usage: %s command input_filename output_dir output_file' % sys.argv[0]) + sys.exit(2) + + class Args: + pass + args = Args() + args.command = sys.argv[1] + args.input_filename = sys.argv[2] + args.output_dir = sys.argv[3] + args.output_file = sys.argv[4] + + try: + os.makedirs(args.output_dir) + except OSError: + pass + + if args.command == "split": + with open(args.input_filename) as infile: + process_file(infile) + + if args.command == "cat": + cat_together() diff --git a/user/mpy/py/makeversionhdr.py b/user/mpy/py/makeversionhdr.py new file mode 100644 index 0000000..749160b --- /dev/null +++ b/user/mpy/py/makeversionhdr.py @@ -0,0 +1,107 @@ +""" +Generate header file with macros defining MicroPython version info. + +This script works with Python 2.6, 2.7, 3.3 and 3.4. +""" + +from __future__ import print_function + +import sys +import os +import datetime +import subprocess + +def get_version_info_from_git(): + # Python 2.6 doesn't have check_output, so check for that + try: + subprocess.check_output + subprocess.check_call + except AttributeError: + return None + + # Note: git describe doesn't work if no tag is available + try: + git_tag = subprocess.check_output(["git", "describe", "--dirty", "--always"], stderr=subprocess.STDOUT, universal_newlines=True).strip() + except subprocess.CalledProcessError as er: + if er.returncode == 128: + # git exit code of 128 means no repository found + return None + git_tag = "" + except OSError: + return None + try: + git_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], stderr=subprocess.STDOUT, universal_newlines=True).strip() + except subprocess.CalledProcessError: + git_hash = "unknown" + except OSError: + return None + + try: + # Check if there are any modified files. + subprocess.check_call(["git", "diff", "--no-ext-diff", "--quiet", "--exit-code"], stderr=subprocess.STDOUT) + # Check if there are any staged files. + subprocess.check_call(["git", "diff-index", "--cached", "--quiet", "HEAD", "--"], stderr=subprocess.STDOUT) + except subprocess.CalledProcessError: + git_hash += "-dirty" + except OSError: + return None + + # Try to extract MicroPython version from git tag + if git_tag.startswith("v"): + ver = git_tag[1:].split("-")[0].split(".") + if len(ver) == 2: + ver.append("0") + else: + ver = ["0", "0", "1"] + + return git_tag, git_hash, ver + +def get_version_info_from_docs_conf(): + with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "docs", "conf.py")) as f: + for line in f: + if line.startswith("version = release = '"): + ver = line.strip().split(" = ")[2].strip("'") + git_tag = "v" + ver + ver = ver.split(".") + if len(ver) == 2: + ver.append("0") + return git_tag, "", ver + return None + +def make_version_header(filename): + # Get version info using git, with fallback to docs/conf.py + info = get_version_info_from_git() + if info is None: + info = get_version_info_from_docs_conf() + + git_tag, git_hash, ver = info + + # Generate the file with the git and version info + file_data = """\ +// This file was generated by py/makeversionhdr.py +#define MICROPY_GIT_TAG "%s" +#define MICROPY_GIT_HASH "%s" +#define MICROPY_BUILD_DATE "%s" +#define MICROPY_VERSION_MAJOR (%s) +#define MICROPY_VERSION_MINOR (%s) +#define MICROPY_VERSION_MICRO (%s) +#define MICROPY_VERSION_STRING "%s.%s.%s" +""" % (git_tag, git_hash, datetime.date.today().strftime("%Y-%m-%d"), + ver[0], ver[1], ver[2], ver[0], ver[1], ver[2]) + + # Check if the file contents changed from last time + write_file = True + if os.path.isfile(filename): + with open(filename, 'r') as f: + existing_data = f.read() + if existing_data == file_data: + write_file = False + + # Only write the file if we need to + if write_file: + print("Generating %s" % filename) + with open(filename, 'w') as f: + f.write(file_data) + +if __name__ == "__main__": + make_version_header(sys.argv[1]) diff --git a/user/mpy/py/malloc.c b/user/mpy/py/malloc.c new file mode 100644 index 0000000..af4ccf2 --- /dev/null +++ b/user/mpy/py/malloc.c @@ -0,0 +1,199 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/mpstate.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +#if MICROPY_MEM_STATS +#define UPDATE_PEAK() { if (MP_STATE_MEM(current_bytes_allocated) > MP_STATE_MEM(peak_bytes_allocated)) MP_STATE_MEM(peak_bytes_allocated) = MP_STATE_MEM(current_bytes_allocated); } +#endif + +#if MICROPY_ENABLE_GC +#include "py/gc.h" + +// We redirect standard alloc functions to GC heap - just for the rest of +// this module. In the rest of MicroPython source, system malloc can be +// freely accessed - for interfacing with system and 3rd-party libs for +// example. On the other hand, some (e.g. bare-metal) ports may use GC +// heap as system heap, so, to avoid warnings, we do undef's first. +#undef malloc +#undef free +#undef realloc +#define malloc(b) gc_alloc((b), false) +#define malloc_with_finaliser(b) gc_alloc((b), true) +#define free gc_free +#define realloc(ptr, n) gc_realloc(ptr, n, true) +#define realloc_ext(ptr, n, mv) gc_realloc(ptr, n, mv) +#else +STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) { + if (allow_move) { + return realloc(ptr, n_bytes); + } else { + // We are asked to resize, but without moving the memory region pointed to + // by ptr. Unless the underlying memory manager has special provision for + // this behaviour there is nothing we can do except fail to resize. + return NULL; + } +} +#endif // MICROPY_ENABLE_GC + +void *m_malloc(size_t num_bytes) { + void *ptr = malloc(num_bytes); + if (ptr == NULL && num_bytes != 0) { + return m_malloc_fail(num_bytes); + } +#if MICROPY_MEM_STATS + MP_STATE_MEM(total_bytes_allocated) += num_bytes; + MP_STATE_MEM(current_bytes_allocated) += num_bytes; + UPDATE_PEAK(); +#endif + DEBUG_printf("malloc %d : %p\n", num_bytes, ptr); + return ptr; +} + +void *m_malloc_maybe(size_t num_bytes) { + void *ptr = malloc(num_bytes); +#if MICROPY_MEM_STATS + MP_STATE_MEM(total_bytes_allocated) += num_bytes; + MP_STATE_MEM(current_bytes_allocated) += num_bytes; + UPDATE_PEAK(); +#endif + DEBUG_printf("malloc %d : %p\n", num_bytes, ptr); + return ptr; +} + +#if MICROPY_ENABLE_FINALISER +void *m_malloc_with_finaliser(size_t num_bytes) { + void *ptr = malloc_with_finaliser(num_bytes); + if (ptr == NULL && num_bytes != 0) { + return m_malloc_fail(num_bytes); + } +#if MICROPY_MEM_STATS + MP_STATE_MEM(total_bytes_allocated) += num_bytes; + MP_STATE_MEM(current_bytes_allocated) += num_bytes; + UPDATE_PEAK(); +#endif + DEBUG_printf("malloc %d : %p\n", num_bytes, ptr); + return ptr; +} +#endif + +void *m_malloc0(size_t num_bytes) { + void *ptr = m_malloc(num_bytes); + if (ptr == NULL && num_bytes != 0) { + return m_malloc_fail(num_bytes); + } + // If this config is set then the GC clears all memory, so we don't need to. + #if !MICROPY_GC_CONSERVATIVE_CLEAR + memset(ptr, 0, num_bytes); + #endif + return ptr; +} + +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE +void *m_realloc(void *ptr, size_t old_num_bytes, size_t new_num_bytes) { +#else +void *m_realloc(void *ptr, size_t new_num_bytes) { +#endif + void *new_ptr = realloc(ptr, new_num_bytes); + if (new_ptr == NULL && new_num_bytes != 0) { + return m_malloc_fail(new_num_bytes); + } +#if MICROPY_MEM_STATS + // At first thought, "Total bytes allocated" should only grow, + // after all, it's *total*. But consider for example 2K block + // shrunk to 1K and then grown to 2K again. It's still 2K + // allocated total. If we process only positive increments, + // we'll count 3K. + size_t diff = new_num_bytes - old_num_bytes; + MP_STATE_MEM(total_bytes_allocated) += diff; + MP_STATE_MEM(current_bytes_allocated) += diff; + UPDATE_PEAK(); +#endif + DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr); + return new_ptr; +} + +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE +void *m_realloc_maybe(void *ptr, size_t old_num_bytes, size_t new_num_bytes, bool allow_move) { +#else +void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move) { +#endif + void *new_ptr = realloc_ext(ptr, new_num_bytes, allow_move); +#if MICROPY_MEM_STATS + // At first thought, "Total bytes allocated" should only grow, + // after all, it's *total*. But consider for example 2K block + // shrunk to 1K and then grown to 2K again. It's still 2K + // allocated total. If we process only positive increments, + // we'll count 3K. + // Also, don't count failed reallocs. + if (!(new_ptr == NULL && new_num_bytes != 0)) { + size_t diff = new_num_bytes - old_num_bytes; + MP_STATE_MEM(total_bytes_allocated) += diff; + MP_STATE_MEM(current_bytes_allocated) += diff; + UPDATE_PEAK(); + } +#endif + DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr); + return new_ptr; +} + +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE +void m_free(void *ptr, size_t num_bytes) { +#else +void m_free(void *ptr) { +#endif + free(ptr); +#if MICROPY_MEM_STATS + MP_STATE_MEM(current_bytes_allocated) -= num_bytes; +#endif + DEBUG_printf("free %p, %d\n", ptr, num_bytes); +} + +#if MICROPY_MEM_STATS +size_t m_get_total_bytes_allocated(void) { + return MP_STATE_MEM(total_bytes_allocated); +} + +size_t m_get_current_bytes_allocated(void) { + return MP_STATE_MEM(current_bytes_allocated); +} + +size_t m_get_peak_bytes_allocated(void) { + return MP_STATE_MEM(peak_bytes_allocated); +} +#endif diff --git a/user/mpy/py/map.c b/user/mpy/py/map.c new file mode 100644 index 0000000..7f3c900 --- /dev/null +++ b/user/mpy/py/map.c @@ -0,0 +1,436 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +// Fixed empty map. Useful when need to call kw-receiving functions +// without any keywords from C, etc. +const mp_map_t mp_const_empty_map = { + .all_keys_are_qstrs = 0, + .is_fixed = 1, + .is_ordered = 1, + .used = 0, + .alloc = 0, + .table = NULL, +}; + +// This table of sizes is used to control the growth of hash tables. +// The first set of sizes are chosen so the allocation fits exactly in a +// 4-word GC block, and it's not so important for these small values to be +// prime. The latter sizes are prime and increase at an increasing rate. +STATIC const uint16_t hash_allocation_sizes[] = { + 0, 2, 4, 6, 8, 10, 12, // +2 + 17, 23, 29, 37, 47, 59, 73, // *1.25 + 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, // *1.33 + 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, // *1.5 +}; + +STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x) { + for (size_t i = 0; i < MP_ARRAY_SIZE(hash_allocation_sizes); i++) { + if (hash_allocation_sizes[i] >= x) { + return hash_allocation_sizes[i]; + } + } + // ran out of primes in the table! + // return something sensible, at least make it odd + return (x + x / 2) | 1; +} + +/******************************************************************************/ +/* map */ + +void mp_map_init(mp_map_t *map, size_t n) { + if (n == 0) { + map->alloc = 0; + map->table = NULL; + } else { + map->alloc = n; + map->table = m_new0(mp_map_elem_t, map->alloc); + } + map->used = 0; + map->all_keys_are_qstrs = 1; + map->is_fixed = 0; + map->is_ordered = 0; +} + +void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table) { + map->alloc = n; + map->used = n; + map->all_keys_are_qstrs = 1; + map->is_fixed = 1; + map->is_ordered = 1; + map->table = (mp_map_elem_t*)table; +} + +mp_map_t *mp_map_new(size_t n) { + mp_map_t *map = m_new(mp_map_t, 1); + mp_map_init(map, n); + return map; +} + +// Differentiate from mp_map_clear() - semantics is different +void mp_map_deinit(mp_map_t *map) { + if (!map->is_fixed) { + m_del(mp_map_elem_t, map->table, map->alloc); + } + map->used = map->alloc = 0; +} + +void mp_map_free(mp_map_t *map) { + mp_map_deinit(map); + m_del_obj(mp_map_t, map); +} + +void mp_map_clear(mp_map_t *map) { + if (!map->is_fixed) { + m_del(mp_map_elem_t, map->table, map->alloc); + } + map->alloc = 0; + map->used = 0; + map->all_keys_are_qstrs = 1; + map->is_fixed = 0; + map->table = NULL; +} + +STATIC void mp_map_rehash(mp_map_t *map) { + size_t old_alloc = map->alloc; + size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1); + mp_map_elem_t *old_table = map->table; + mp_map_elem_t *new_table = m_new0(mp_map_elem_t, new_alloc); + // If we reach this point, table resizing succeeded, now we can edit the old map. + map->alloc = new_alloc; + map->used = 0; + map->all_keys_are_qstrs = 1; + map->table = new_table; + for (size_t i = 0; i < old_alloc; i++) { + if (old_table[i].key != MP_OBJ_NULL && old_table[i].key != MP_OBJ_SENTINEL) { + mp_map_lookup(map, old_table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = old_table[i].value; + } + } + m_del(mp_map_elem_t, old_table, old_alloc); +} + +// MP_MAP_LOOKUP behaviour: +// - returns NULL if not found, else the slot it was found in with key,value non-null +// MP_MAP_LOOKUP_ADD_IF_NOT_FOUND behaviour: +// - returns slot, with key non-null and value=MP_OBJ_NULL if it was added +// MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour: +// - returns NULL if not found, else the slot if was found in with key null and value non-null +mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { + + if (map->is_fixed && lookup_kind != MP_MAP_LOOKUP) { + // can't add/remove from a fixed array + return NULL; + } + + // Work out if we can compare just pointers + bool compare_only_ptrs = map->all_keys_are_qstrs; + if (compare_only_ptrs) { + if (MP_OBJ_IS_QSTR(index)) { + // Index is a qstr, so can just do ptr comparison. + } else if (MP_OBJ_IS_TYPE(index, &mp_type_str)) { + // Index is a non-interned string. + // We can either intern the string, or force a full equality comparison. + // We chose the latter, since interning costs time and potentially RAM, + // and it won't necessarily benefit subsequent calls because these calls + // most likely won't pass the newly-interned string. + compare_only_ptrs = false; + } else if (lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + // If we are not adding, then we can return straight away a failed + // lookup because we know that the index will never be found. + return NULL; + } + } + + // if the map is an ordered array then we must do a brute force linear search + if (map->is_ordered) { + for (mp_map_elem_t *elem = &map->table[0], *top = &map->table[map->used]; elem < top; elem++) { + if (elem->key == index || (!compare_only_ptrs && mp_obj_equal(elem->key, index))) { + if (MP_UNLIKELY(lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND)) { + // remove the found element by moving the rest of the array down + mp_obj_t value = elem->value; + --map->used; + memmove(elem, elem + 1, (top - elem - 1) * sizeof(*elem)); + // put the found element after the end so the caller can access it if needed + elem = &map->table[map->used]; + elem->key = MP_OBJ_NULL; + elem->value = value; + } + return elem; + } + } + if (MP_LIKELY(lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)) { + return NULL; + } + if (map->used == map->alloc) { + // TODO: Alloc policy + map->alloc += 4; + map->table = m_renew(mp_map_elem_t, map->table, map->used, map->alloc); + mp_seq_clear(map->table, map->used, map->alloc, sizeof(*map->table)); + } + mp_map_elem_t *elem = map->table + map->used++; + elem->key = index; + if (!MP_OBJ_IS_QSTR(index)) { + map->all_keys_are_qstrs = 0; + } + return elem; + } + + // map is a hash table (not an ordered array), so do a hash lookup + + if (map->alloc == 0) { + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + mp_map_rehash(map); + } else { + return NULL; + } + } + + // get hash of index, with fast path for common case of qstr + mp_uint_t hash; + if (MP_OBJ_IS_QSTR(index)) { + hash = qstr_hash(MP_OBJ_QSTR_VALUE(index)); + } else { + hash = MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, index)); + } + + size_t pos = hash % map->alloc; + size_t start_pos = pos; + mp_map_elem_t *avail_slot = NULL; + for (;;) { + mp_map_elem_t *slot = &map->table[pos]; + if (slot->key == MP_OBJ_NULL) { + // found NULL slot, so index is not in table + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + map->used += 1; + if (avail_slot == NULL) { + avail_slot = slot; + } + avail_slot->key = index; + avail_slot->value = MP_OBJ_NULL; + if (!MP_OBJ_IS_QSTR(index)) { + map->all_keys_are_qstrs = 0; + } + return avail_slot; + } else { + return NULL; + } + } else if (slot->key == MP_OBJ_SENTINEL) { + // found deleted slot, remember for later + if (avail_slot == NULL) { + avail_slot = slot; + } + } else if (slot->key == index || (!compare_only_ptrs && mp_obj_equal(slot->key, index))) { + // found index + // Note: CPython does not replace the index; try x={True:'true'};x[1]='one';x + if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + // delete element in this slot + map->used--; + if (map->table[(pos + 1) % map->alloc].key == MP_OBJ_NULL) { + // optimisation if next slot is empty + slot->key = MP_OBJ_NULL; + } else { + slot->key = MP_OBJ_SENTINEL; + } + // keep slot->value so that caller can access it if needed + } + return slot; + } + + // not yet found, keep searching in this table + pos = (pos + 1) % map->alloc; + + if (pos == start_pos) { + // search got back to starting position, so index is not in table + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + if (avail_slot != NULL) { + // there was an available slot, so use that + map->used++; + avail_slot->key = index; + avail_slot->value = MP_OBJ_NULL; + if (!MP_OBJ_IS_QSTR(index)) { + map->all_keys_are_qstrs = 0; + } + return avail_slot; + } else { + // not enough room in table, rehash it + mp_map_rehash(map); + // restart the search for the new element + start_pos = pos = hash % map->alloc; + } + } else { + return NULL; + } + } + } +} + +/******************************************************************************/ +/* set */ + +#if MICROPY_PY_BUILTINS_SET + +void mp_set_init(mp_set_t *set, size_t n) { + set->alloc = n; + set->used = 0; + set->table = m_new0(mp_obj_t, set->alloc); +} + +STATIC void mp_set_rehash(mp_set_t *set) { + size_t old_alloc = set->alloc; + mp_obj_t *old_table = set->table; + set->alloc = get_hash_alloc_greater_or_equal_to(set->alloc + 1); + set->used = 0; + set->table = m_new0(mp_obj_t, set->alloc); + for (size_t i = 0; i < old_alloc; i++) { + if (old_table[i] != MP_OBJ_NULL && old_table[i] != MP_OBJ_SENTINEL) { + mp_set_lookup(set, old_table[i], MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + } + } + m_del(mp_obj_t, old_table, old_alloc); +} + +mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { + // Note: lookup_kind can be MP_MAP_LOOKUP_ADD_IF_NOT_FOUND_OR_REMOVE_IF_FOUND which + // is handled by using bitwise operations. + + if (set->alloc == 0) { + if (lookup_kind & MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + mp_set_rehash(set); + } else { + return MP_OBJ_NULL; + } + } + mp_uint_t hash = MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, index)); + size_t pos = hash % set->alloc; + size_t start_pos = pos; + mp_obj_t *avail_slot = NULL; + for (;;) { + mp_obj_t elem = set->table[pos]; + if (elem == MP_OBJ_NULL) { + // found NULL slot, so index is not in table + if (lookup_kind & MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + if (avail_slot == NULL) { + avail_slot = &set->table[pos]; + } + set->used++; + *avail_slot = index; + return index; + } else { + return MP_OBJ_NULL; + } + } else if (elem == MP_OBJ_SENTINEL) { + // found deleted slot, remember for later + if (avail_slot == NULL) { + avail_slot = &set->table[pos]; + } + } else if (mp_obj_equal(elem, index)) { + // found index + if (lookup_kind & MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + // delete element + set->used--; + if (set->table[(pos + 1) % set->alloc] == MP_OBJ_NULL) { + // optimisation if next slot is empty + set->table[pos] = MP_OBJ_NULL; + } else { + set->table[pos] = MP_OBJ_SENTINEL; + } + } + return elem; + } + + // not yet found, keep searching in this table + pos = (pos + 1) % set->alloc; + + if (pos == start_pos) { + // search got back to starting position, so index is not in table + if (lookup_kind & MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + if (avail_slot != NULL) { + // there was an available slot, so use that + set->used++; + *avail_slot = index; + return index; + } else { + // not enough room in table, rehash it + mp_set_rehash(set); + // restart the search for the new element + start_pos = pos = hash % set->alloc; + } + } else { + return MP_OBJ_NULL; + } + } + } +} + +mp_obj_t mp_set_remove_first(mp_set_t *set) { + for (size_t pos = 0; pos < set->alloc; pos++) { + if (MP_SET_SLOT_IS_FILLED(set, pos)) { + mp_obj_t elem = set->table[pos]; + // delete element + set->used--; + if (set->table[(pos + 1) % set->alloc] == MP_OBJ_NULL) { + // optimisation if next slot is empty + set->table[pos] = MP_OBJ_NULL; + } else { + set->table[pos] = MP_OBJ_SENTINEL; + } + return elem; + } + } + return MP_OBJ_NULL; +} + +void mp_set_clear(mp_set_t *set) { + m_del(mp_obj_t, set->table, set->alloc); + set->alloc = 0; + set->used = 0; + set->table = NULL; +} + +#endif // MICROPY_PY_BUILTINS_SET + +#if defined(DEBUG_PRINT) && DEBUG_PRINT +void mp_map_dump(mp_map_t *map) { + for (size_t i = 0; i < map->alloc; i++) { + if (map->table[i].key != NULL) { + mp_obj_print(map->table[i].key, PRINT_REPR); + } else { + printf("(nil)"); + } + printf(": %p\n", map->table[i].value); + } + printf("---\n"); +} +#endif diff --git a/user/mpy/py/misc.h b/user/mpy/py/misc.h new file mode 100644 index 0000000..71425b8 --- /dev/null +++ b/user/mpy/py/misc.h @@ -0,0 +1,226 @@ +/* + * 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 *******************************************************/ + +#include +#include +#include + +typedef unsigned char byte; +typedef unsigned int uint; + +/** generic ops *************************************************/ + +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +// Classical double-indirection stringification of preprocessor macro's value +#define _MP_STRINGIFY(x) #x +#define MP_STRINGIFY(x) _MP_STRINGIFY(x) + +/** 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 MICROPY_ENABLE_FINALISER +#define m_new_obj_with_finaliser(type) ((type*)(m_malloc_with_finaliser(sizeof(type)))) +#else +#define m_new_obj_with_finaliser(type) m_new_obj(type) +#endif +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE +#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 +#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 +#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 MICROPY_MALLOC_USES_ALLOCATED_SIZE +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 +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 +NORETURN void *m_malloc_fail(size_t num_bytes); + +#if MICROPY_MEM_STATS +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 + +/** 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 MICROPY_PY_BUILTINS_STR_UNICODE +// with unicode enabled we need a type which can fit chars up to 0x10ffff +typedef uint32_t unichar; +#else +// 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 + +unichar utf8_get_char(const byte *s); +const byte *utf8_next_char(const byte *s); + +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_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); +mp_uint_t unichar_charlen(const char *str, mp_uint_t len); +#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 + +// Debugging helpers +int DEBUG_printf(const char *fmt, ...); + +extern mp_uint_t mp_verbose_flag; + +// This is useful for unicode handling. Some CPU archs has +// special instructions for efficient implementation of this +// function (e.g. CLZ on ARM). +// NOTE: this function is unused at the moment +#ifndef count_lead_ones +static inline mp_uint_t count_lead_ones(byte val) { + mp_uint_t c = 0; + for (byte mask = 0x80; val & mask; mask >>= 1) { + c++; + } + return c; +} +#endif + +/** float internals *************/ + +#if MICROPY_PY_BUILTINS_FLOAT +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE +#define MP_FLOAT_EXP_BITS (11) +#define MP_FLOAT_FRAC_BITS (52) +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT +#define MP_FLOAT_EXP_BITS (8) +#define MP_FLOAT_FRAC_BITS (23) +#endif +#define MP_FLOAT_EXP_BIAS ((1 << (MP_FLOAT_EXP_BITS - 1)) - 1) +#endif // MICROPY_PY_BUILTINS_FLOAT + +#endif // MICROPY_INCLUDED_PY_MISC_H diff --git a/user/mpy/py/mkenv.mk b/user/mpy/py/mkenv.mk new file mode 100644 index 0000000..b167b25 --- /dev/null +++ b/user/mpy/py/mkenv.mk @@ -0,0 +1,70 @@ +ifneq ($(lastword a b),b) +$(error These Makefiles require make 3.81 or newer) +endif + +# Set TOP to be the path to get from the current directory (where make was +# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns +# the name of this makefile relative to where make was invoked. +# +# We assume that this file is in the py directory so we use $(dir ) twice +# to get to the top of the tree. + +THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) +TOP := $(patsubst %/py/mkenv.mk,%,$(THIS_MAKEFILE)) + +# Turn on increased build verbosity by defining BUILD_VERBOSE in your main +# Makefile or in your environment. You can also use V=1 on the make command +# line. + +ifeq ("$(origin V)", "command line") +BUILD_VERBOSE=$(V) +endif +ifndef BUILD_VERBOSE +BUILD_VERBOSE = 0 +endif +ifeq ($(BUILD_VERBOSE),0) +Q = @ +else +Q = +endif +# Since this is a new feature, advertise it +ifeq ($(BUILD_VERBOSE),0) +$(info Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.) +endif + +# default settings; can be overridden in main Makefile + +PY_SRC ?= $(TOP)/py +BUILD ?= build + +RM = rm +ECHO = @echo +CP = cp +MKDIR = mkdir +SED = sed +PYTHON = python + +AS = $(CROSS_COMPILE)as +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +LD = $(CROSS_COMPILE)ld +OBJCOPY = $(CROSS_COMPILE)objcopy +SIZE = $(CROSS_COMPILE)size +STRIP = $(CROSS_COMPILE)strip +AR = $(CROSS_COMPILE)ar +ifeq ($(MICROPY_FORCE_32BIT),1) +CC += -m32 +CXX += -m32 +LD += -m32 +endif + +MAKE_FROZEN = $(TOP)/tools/make-frozen.py +MPY_CROSS = $(TOP)/mpy-cross/mpy-cross +MPY_TOOL = $(TOP)/tools/mpy-tool.py + +all: +.PHONY: all + +.DELETE_ON_ERROR: + +MKENV_INCLUDED = 1 diff --git a/user/mpy/py/mkrules.mk b/user/mpy/py/mkrules.mk new file mode 100644 index 0000000..bb8a77a --- /dev/null +++ b/user/mpy/py/mkrules.mk @@ -0,0 +1,175 @@ +ifneq ($(MKENV_INCLUDED),1) +# We assume that mkenv is in the same directory as this file. +THIS_MAKEFILE = $(lastword $(MAKEFILE_LIST)) +include $(dir $(THIS_MAKEFILE))mkenv.mk +endif + +# This file expects that OBJ contains a list of all of the object files. +# The directory portion of each object file is used to locate the source +# and should not contain any ..'s but rather be relative to the top of the +# tree. +# +# So for example, py/map.c would have an object file name py/map.o +# The object files will go into the build directory and mantain the same +# directory structure as the source tree. So the final dependency will look +# like this: +# +# build/py/map.o: py/map.c +# +# We set vpath to point to the top of the tree so that the source files +# can be located. By following this scheme, it allows a single build rule +# to be used to compile all .c files. + +vpath %.S . $(TOP) +$(BUILD)/%.o: %.S + $(ECHO) "CC $<" + $(Q)$(CC) $(CFLAGS) -c -o $@ $< + +vpath %.s . $(TOP) +$(BUILD)/%.o: %.s + $(ECHO) "AS $<" + $(Q)$(AS) -o $@ $< + +define compile_c +$(ECHO) "CC $<" +$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $< +@# The following fixes the dependency file. +@# See http://make.paulandlesley.org/autodep.html for details. +@# Regex adjusted from the above to play better with Windows paths, etc. +@$(CP) $(@:.o=.d) $(@:.o=.P); \ + $(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ + $(RM) -f $(@:.o=.d) +endef + +vpath %.c . $(TOP) +$(BUILD)/%.o: %.c + $(call compile_c) + +# List all native flags since the current build system doesn't have +# the MicroPython configuration available. However, these flags are +# needed to extract all qstrings +QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB -DN_ARM -DN_XTENSA +QSTR_GEN_EXTRA_CFLAGS += -I$(BUILD)/tmp + +vpath %.c . $(TOP) + +$(BUILD)/%.pp: %.c + $(ECHO) "PreProcess $<" + $(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $< + +# The following rule uses | to create an order only prerequisite. Order only +# prerequisites only get built if they don't exist. They don't cause timestamp +# checking to be performed. +# +# We don't know which source files actually need the generated.h (since +# it is #included from str.h). The compiler generated dependencies will cause +# the right .o's to get recompiled if the generated.h file changes. Adding +# an order-only dependency to all of the .o's will cause the generated .h +# to get built before we try to compile any of them. +$(OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h + +$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) | $(HEADER_BUILD)/mpversion.h + $(ECHO) "GEN $@" + $(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(if $?,$?,$^) >$(HEADER_BUILD)/qstr.i.last; + +$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last + $(ECHO) "GEN $@" + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) + $(Q)touch $@ + +$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split + $(ECHO) "GEN $@" + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) + +# $(sort $(var)) removes duplicates +# +# The net effect of this, is it causes the objects to depend on the +# object directories (but only for existence), and the object directories +# will be created if they don't exist. +OBJ_DIRS = $(sort $(dir $(OBJ))) +$(OBJ): | $(OBJ_DIRS) +$(OBJ_DIRS): + $(MKDIR) -p $@ + +$(HEADER_BUILD): + $(MKDIR) -p $@ + +ifneq ($(FROZEN_DIR),) +$(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DEPS) + $(ECHO) "Generating $@" + $(Q)$(MAKE_FROZEN) $(FROZEN_DIR) > $@ +endif + +ifneq ($(FROZEN_MPY_DIR),) +# to build the MicroPython cross compiler +$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/windows/fmode.c + $(Q)$(MAKE) -C $(TOP)/mpy-cross + +# make a list of all the .py files that need compiling and freezing +FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)/==') +FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/frozen_mpy/,$(FROZEN_MPY_PY_FILES:.py=.mpy)) + +# to build .mpy files from .py files +$(BUILD)/frozen_mpy/%.mpy: $(FROZEN_MPY_DIR)/%.py $(TOP)/mpy-cross/mpy-cross + @$(ECHO) "MPY $<" + $(Q)$(MKDIR) -p $(dir $@) + $(Q)$(MPY_CROSS) -o $@ -s $(<:$(FROZEN_MPY_DIR)/%=%) $(MPY_CROSS_FLAGS) $< + +# to build frozen_mpy.c from all .mpy files +$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h + @$(ECHO) "Creating $@" + $(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@ +endif + +ifneq ($(PROG),) +# Build a standalone executable (unix does this) + +all: $(PROG) + +$(PROG): $(OBJ) + $(ECHO) "LINK $@" +# Do not pass COPT here - it's *C* compiler optimizations. For example, +# we may want to compile using Thumb, but link with non-Thumb libc. + $(Q)$(CC) -o $@ $^ $(LIB) $(LDFLAGS) +ifndef DEBUG + $(Q)$(STRIP) $(STRIPFLAGS_EXTRA) $(PROG) +endif + $(Q)$(SIZE) $$(find $(BUILD)/build -name "frozen*.o") $(PROG) + +clean: clean-prog +clean-prog: + $(RM) -f $(PROG) + $(RM) -f $(PROG).map + +.PHONY: clean-prog +endif + +LIBMICROPYTHON = libmicropython.a + +# We can execute extra commands after library creation using +# LIBMICROPYTHON_EXTRA_CMD. This may be needed e.g. to integrate +# with 3rd-party projects which don't have proper dependency +# tracking. Then LIBMICROPYTHON_EXTRA_CMD can e.g. touch some +# other file to cause needed effect, e.g. relinking with new lib. +lib $(LIBMICROPYTHON): $(OBJ) + $(AR) rcs $(LIBMICROPYTHON) $^ + $(LIBMICROPYTHON_EXTRA_CMD) + +clean-py: + $(RM) -rf $(BUILD) $(CLEAN_EXTRA) +.PHONY: clean + +print-cfg: + $(ECHO) "PY_SRC = $(PY_SRC)" + $(ECHO) "BUILD = $(BUILD)" + $(ECHO) "OBJ = $(OBJ)" +.PHONY: print-cfg + +print-def: + @$(ECHO) "The following defines are built into the $(CC) compiler" + touch __empty__.c + @$(CC) -E -Wp,-dM __empty__.c + @$(RM) -f __empty__.c + +-include $(OBJ:.o=.P) diff --git a/user/mpy/py/modarray.c b/user/mpy/py/modarray.c new file mode 100644 index 0000000..c0cdca9 --- /dev/null +++ b/user/mpy/py/modarray.c @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#include "py/builtin.h" + +#if MICROPY_PY_ARRAY + +STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_array) }, + { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_type_array) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table); + +const mp_obj_module_t mp_module_array = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_array_globals, +}; + +#endif diff --git a/user/mpy/py/modbuiltins.c b/user/mpy/py/modbuiltins.c new file mode 100644 index 0000000..1c76b80 --- /dev/null +++ b/user/mpy/py/modbuiltins.c @@ -0,0 +1,774 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/objstr.h" +#include "py/objtype.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/stream.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include +#endif + +#if MICROPY_PY_IO +extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need pointer +#endif + +// args[0] is function from class body +// args[1] is class name +// args[2:] are base objects +STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) { + assert(2 <= n_args); + + // set the new classes __locals__ object + mp_obj_dict_t *old_locals = mp_locals_get(); + mp_obj_t class_locals = mp_obj_new_dict(0); + mp_locals_set(MP_OBJ_TO_PTR(class_locals)); + + // call the class code + mp_obj_t cell = mp_call_function_0(args[0]); + + // restore old __locals__ object + mp_locals_set(old_locals); + + // get the class type (meta object) from the base objects + mp_obj_t meta; + if (n_args == 2) { + // no explicit bases, so use 'type' + meta = MP_OBJ_FROM_PTR(&mp_type_type); + } else { + // use type of first base object + meta = MP_OBJ_FROM_PTR(mp_obj_get_type(args[2])); + } + + // TODO do proper metaclass resolution for multiple base objects + + // create the new class using a call to the meta object + mp_obj_t meta_args[3]; + meta_args[0] = args[1]; // class name + meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); // tuple of bases + meta_args[2] = class_locals; // dict of members + mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args); + + // store into cell if neede + if (cell != mp_const_none) { + mp_obj_cell_set(cell, new_class); + } + + return new_class; +} +MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__); + +STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) { + #if MICROPY_PY_BUILTINS_FLOAT + if (mp_obj_is_float(o_in)) { + mp_float_t value = mp_obj_float_get(o_in); + // TODO check for NaN etc + if (value < 0) { + return mp_obj_new_float(-value); + } else { + return o_in; + } + #if MICROPY_PY_BUILTINS_COMPLEX + } else if (MP_OBJ_IS_TYPE(o_in, &mp_type_complex)) { + mp_float_t real, imag; + mp_obj_complex_get(o_in, &real, &imag); + return mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(real*real + imag*imag)); + #endif + } + #endif + + // this will raise a TypeError if the argument is not integral + return mp_obj_int_abs(o_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs); + +STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(o_in, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (!mp_obj_is_true(item)) { + return mp_const_false; + } + } + return mp_const_true; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all); + +STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(o_in, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (mp_obj_is_true(item)) { + return mp_const_true; + } + } + return mp_const_false; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any); + +STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) { + mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in }; + return mp_obj_str_format(MP_ARRAY_SIZE(args), args, NULL); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin); + +STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) { + if (mp_obj_is_callable(o_in)) { + return mp_const_true; + } else { + return mp_const_false; + } +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable); + +STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { + #if MICROPY_PY_BUILTINS_STR_UNICODE + mp_uint_t c = mp_obj_get_int(o_in); + char str[4]; + int len = 0; + if (c < 0x80) { + *str = c; len = 1; + } else if (c < 0x800) { + str[0] = (c >> 6) | 0xC0; + str[1] = (c & 0x3F) | 0x80; + len = 2; + } else if (c < 0x10000) { + str[0] = (c >> 12) | 0xE0; + str[1] = ((c >> 6) & 0x3F) | 0x80; + str[2] = (c & 0x3F) | 0x80; + len = 3; + } else if (c < 0x110000) { + str[0] = (c >> 18) | 0xF0; + str[1] = ((c >> 12) & 0x3F) | 0x80; + str[2] = ((c >> 6) & 0x3F) | 0x80; + str[3] = (c & 0x3F) | 0x80; + len = 4; + } else { + mp_raise_ValueError("chr() arg not in range(0x110000)"); + } + return mp_obj_new_str(str, len, true); + #else + mp_int_t ord = mp_obj_get_int(o_in); + if (0 <= ord && ord <= 0xff) { + char str[1] = {ord}; + return mp_obj_new_str(str, 1, true); + } else { + mp_raise_ValueError("chr() arg not in range(256)"); + } + #endif +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr); + +STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { + // TODO make this function more general and less of a hack + + mp_obj_dict_t *dict = NULL; + mp_map_t *members = NULL; + if (n_args == 0) { + // make a list of names in the local name space + dict = mp_locals_get(); + } else { // n_args == 1 + // make a list of names in the given object + if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) { + dict = mp_obj_module_get_globals(args[0]); + } else { + mp_obj_type_t *type; + if (MP_OBJ_IS_TYPE(args[0], &mp_type_type)) { + type = MP_OBJ_TO_PTR(args[0]); + } else { + type = mp_obj_get_type(args[0]); + } + if (type->locals_dict != NULL && type->locals_dict->base.type == &mp_type_dict) { + dict = type->locals_dict; + } + } + if (mp_obj_is_instance_type(mp_obj_get_type(args[0]))) { + mp_obj_instance_t *inst = MP_OBJ_TO_PTR(args[0]); + members = &inst->members; + } + } + + mp_obj_t dir = mp_obj_new_list(0, NULL); + if (dict != NULL) { + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + mp_obj_list_append(dir, dict->map.table[i].key); + } + } + } + if (members != NULL) { + for (size_t i = 0; i < members->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(members, i)) { + mp_obj_list_append(dir, members->table[i].key); + } + } + } + return dir; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir); + +STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) { + return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod); + +STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) { + // result is guaranteed to be a (small) int + return mp_unary_op(MP_UNARY_OP_HASH, o_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash); + +STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) { + return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex); + +#if MICROPY_PY_BUILTINS_INPUT + +#include "py/mphal.h" +#include "lib/mp-readline/readline.h" + +// A port can define mp_hal_readline if they want to use a custom function here +#ifndef mp_hal_readline +#define mp_hal_readline readline +#endif + +STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) { + if (n_args == 1) { + mp_obj_print(args[0], PRINT_STR); + } + vstr_t line; + vstr_init(&line, 16); + int ret = mp_hal_readline(&line, ""); + if (ret == CHAR_CTRL_C) { + nlr_raise(mp_obj_new_exception(&mp_type_KeyboardInterrupt)); + } + if (line.len == 0 && ret == CHAR_CTRL_D) { + nlr_raise(mp_obj_new_exception(&mp_type_EOFError)); + } + return mp_obj_new_str_from_vstr(&mp_type_str, &line); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input); + +#endif + +STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) { + return mp_getiter(o_in, NULL); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter); + +#if MICROPY_PY_BUILTINS_MIN_MAX + +STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) { + mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP); + mp_map_elem_t *default_elem; + mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value; + if (n_args == 1) { + // given an iterable + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(args[0], &iter_buf); + mp_obj_t best_key = MP_OBJ_NULL; + mp_obj_t best_obj = MP_OBJ_NULL; + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + mp_obj_t key = key_fn == MP_OBJ_NULL ? item : mp_call_function_1(key_fn, item); + if (best_obj == MP_OBJ_NULL || (mp_binary_op(op, key, best_key) == mp_const_true)) { + best_key = key; + best_obj = item; + } + } + if (best_obj == MP_OBJ_NULL) { + default_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_default), MP_MAP_LOOKUP); + if (default_elem != NULL) { + best_obj = default_elem->value; + } else { + mp_raise_ValueError("arg is an empty sequence"); + } + } + return best_obj; + } else { + // given many args + mp_obj_t best_key = MP_OBJ_NULL; + mp_obj_t best_obj = MP_OBJ_NULL; + for (size_t i = 0; i < n_args; i++) { + mp_obj_t key = key_fn == MP_OBJ_NULL ? args[i] : mp_call_function_1(key_fn, args[i]); + if (best_obj == MP_OBJ_NULL || (mp_binary_op(op, key, best_key) == mp_const_true)) { + best_key = key; + best_obj = args[i]; + } + } + return best_obj; + } +} + +STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE); +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max); + +STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS); +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min); + +#endif + +STATIC mp_obj_t mp_builtin_next(mp_obj_t o) { + mp_obj_t ret = mp_iternext_allow_raise(o); + if (ret == MP_OBJ_STOP_ITERATION) { + nlr_raise(mp_obj_new_exception(&mp_type_StopIteration)); + } else { + return ret; + } +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next); + +STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) { + return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct); + +STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) { + size_t len; + const char *str = mp_obj_str_get_data(o_in, &len); + #if MICROPY_PY_BUILTINS_STR_UNICODE + if (MP_OBJ_IS_STR(o_in)) { + len = unichar_charlen(str, len); + if (len == 1) { + if (!UTF8_IS_NONASCII(*str)) { + goto return_first_byte; + } + mp_int_t ord = *str++ & 0x7F; + for (mp_int_t mask = 0x40; ord & mask; mask >>= 1) { + ord &= ~mask; + } + while (UTF8_IS_CONT(*str)) { + ord = (ord << 6) | (*str++ & 0x3F); + } + return mp_obj_new_int(ord); + } + } else { + // a bytes object + if (len == 1) { + return_first_byte: + return MP_OBJ_NEW_SMALL_INT(((const byte*)str)[0]); + } + } + #else + if (len == 1) { + // don't sign extend when converting to ord + return mp_obj_new_int(((const byte*)str)[0]); + } + #endif + + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("ord expects a character"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "ord() expected a character, but string of length %d found", (int)len)); + } +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord); + +STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) { + switch (n_args) { + case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]); + default: +#if !MICROPY_PY_BUILTINS_POW3 + mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported"); +#elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ + return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); +#else + return mp_obj_int_pow3(args[0], args[1], args[2]); +#endif + } +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow); + +STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP); + mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP); + const char *sep_data = " "; + size_t sep_len = 1; + const char *end_data = "\n"; + size_t end_len = 1; + if (sep_elem != NULL && sep_elem->value != mp_const_none) { + sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len); + } + if (end_elem != NULL && end_elem->value != mp_const_none) { + end_data = mp_obj_str_get_data(end_elem->value, &end_len); + } + #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES + void *stream_obj = &mp_sys_stdout_obj; + mp_map_elem_t *file_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_file), MP_MAP_LOOKUP); + if (file_elem != NULL && file_elem->value != mp_const_none) { + stream_obj = MP_OBJ_TO_PTR(file_elem->value); // XXX may not be a concrete object + } + + mp_print_t print = {stream_obj, mp_stream_write_adaptor}; + #endif + for (size_t i = 0; i < n_args; i++) { + if (i > 0) { + #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES + mp_stream_write_adaptor(stream_obj, sep_data, sep_len); + #else + mp_print_strn(&mp_plat_print, sep_data, sep_len, 0, 0, 0); + #endif + } + #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES + mp_obj_print_helper(&print, args[i], PRINT_STR); + #else + mp_obj_print_helper(&mp_plat_print, args[i], PRINT_STR); + #endif + } + #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES + mp_stream_write_adaptor(stream_obj, end_data, end_len); + #else + mp_print_strn(&mp_plat_print, end_data, end_len, 0, 0, 0); + #endif + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print); + +STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { + if (o != mp_const_none) { + mp_obj_print_helper(MP_PYTHON_PRINTER, o, PRINT_REPR); + mp_print_str(MP_PYTHON_PRINTER, "\n"); + #if MICROPY_CAN_OVERRIDE_BUILTINS + // Set "_" special variable + mp_obj_t dest[2] = {MP_OBJ_SENTINEL, o}; + mp_type_module.attr(MP_OBJ_FROM_PTR(&mp_module_builtins), MP_QSTR__, dest); + #endif + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__); + +STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + mp_obj_print_helper(&print, o_in, PRINT_REPR); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr); + +STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) { + mp_obj_t o_in = args[0]; + if (MP_OBJ_IS_INT(o_in)) { + return o_in; + } +#if MICROPY_PY_BUILTINS_FLOAT + mp_int_t num_dig = 0; + if (n_args > 1) { + num_dig = mp_obj_get_int(args[1]); + mp_float_t val = mp_obj_get_float(o_in); + mp_float_t mult = MICROPY_FLOAT_C_FUN(pow)(10, num_dig); + // TODO may lead to overflow + mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val * mult) / mult; + return mp_obj_new_float(rounded); + } + mp_float_t val = mp_obj_get_float(o_in); + mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val); + return mp_obj_new_int_from_float(rounded); +#else + mp_int_t r = mp_obj_get_int(o_in); + return mp_obj_new_int(r); +#endif +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round); + +STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) { + mp_obj_t value; + switch (n_args) { + case 1: value = MP_OBJ_NEW_SMALL_INT(0); break; + default: value = args[1]; break; + } + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(args[0], &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + value = mp_binary_op(MP_BINARY_OP_ADD, value, item); + } + return value; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum); + +STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + if (n_args > 1) { + mp_raise_TypeError("must use keyword argument for key function"); + } + mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); + mp_obj_list_sort(1, &self, kwargs); + + return self; +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted); + +// See mp_load_attr() if making any changes +static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t defval) { + mp_obj_t dest[2]; + // use load_method, raising or not raising exception + ((defval == MP_OBJ_NULL) ? mp_load_method : mp_load_method_maybe)(base, attr, dest); + if (dest[0] == MP_OBJ_NULL) { + return defval; + } else if (dest[1] == MP_OBJ_NULL) { + // load_method returned just a normal attribute + return dest[0]; + } else { + // load_method returned a method, so build a bound method object + return mp_obj_new_bound_meth(dest[0], dest[1]); + } +} + +STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) { + mp_obj_t defval = MP_OBJ_NULL; + if (n_args > 2) { + defval = args[2]; + } + return mp_load_attr_default(args[0], mp_obj_str_get_qstr(args[1]), defval); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr); + +STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) { + mp_store_attr(base, mp_obj_str_get_qstr(attr), value); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr); + +#if MICROPY_CPYTHON_COMPAT +STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) { + return mp_builtin_setattr(base, attr, MP_OBJ_NULL); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr); +#endif + +STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { + qstr attr = mp_obj_str_get_qstr(attr_in); + + mp_obj_t dest[2]; + // TODO: https://docs.python.org/3/library/functions.html?highlight=hasattr#hasattr + // explicitly says "This is implemented by calling getattr(object, name) and seeing + // whether it raises an AttributeError or not.", so we should explicitly wrap this + // in nlr_push and handle exception. + mp_load_method_maybe(object_in, attr, dest); + + return mp_obj_new_bool(dest[0] != MP_OBJ_NULL); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr); + +STATIC mp_obj_t mp_builtin_globals(void) { + return MP_OBJ_FROM_PTR(mp_globals_get()); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals); + +STATIC mp_obj_t mp_builtin_locals(void) { + return MP_OBJ_FROM_PTR(mp_locals_get()); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals); + +// These are defined in terms of MicroPython API functions right away +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id); +MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len); + +STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) }, + + // built-in core functions + { MP_ROM_QSTR(MP_QSTR___build_class__), MP_ROM_PTR(&mp_builtin___build_class___obj) }, + { MP_ROM_QSTR(MP_QSTR___import__), MP_ROM_PTR(&mp_builtin___import___obj) }, + { MP_ROM_QSTR(MP_QSTR___repl_print__), MP_ROM_PTR(&mp_builtin___repl_print___obj) }, + + // built-in types + { MP_ROM_QSTR(MP_QSTR_bool), MP_ROM_PTR(&mp_type_bool) }, + { MP_ROM_QSTR(MP_QSTR_bytes), MP_ROM_PTR(&mp_type_bytes) }, + #if MICROPY_PY_BUILTINS_BYTEARRAY + { MP_ROM_QSTR(MP_QSTR_bytearray), MP_ROM_PTR(&mp_type_bytearray) }, + #endif + #if MICROPY_PY_BUILTINS_COMPLEX + { MP_ROM_QSTR(MP_QSTR_complex), MP_ROM_PTR(&mp_type_complex) }, + #endif + { MP_ROM_QSTR(MP_QSTR_dict), MP_ROM_PTR(&mp_type_dict) }, + #if MICROPY_PY_BUILTINS_ENUMERATE + { MP_ROM_QSTR(MP_QSTR_enumerate), MP_ROM_PTR(&mp_type_enumerate) }, + #endif + #if MICROPY_PY_BUILTINS_FILTER + { MP_ROM_QSTR(MP_QSTR_filter), MP_ROM_PTR(&mp_type_filter) }, + #endif + #if MICROPY_PY_BUILTINS_FLOAT + { MP_ROM_QSTR(MP_QSTR_float), MP_ROM_PTR(&mp_type_float) }, + #endif + #if MICROPY_PY_BUILTINS_SET && MICROPY_PY_BUILTINS_FROZENSET + { MP_ROM_QSTR(MP_QSTR_frozenset), MP_ROM_PTR(&mp_type_frozenset) }, + #endif + { MP_ROM_QSTR(MP_QSTR_int), MP_ROM_PTR(&mp_type_int) }, + { MP_ROM_QSTR(MP_QSTR_list), MP_ROM_PTR(&mp_type_list) }, + { MP_ROM_QSTR(MP_QSTR_map), MP_ROM_PTR(&mp_type_map) }, + #if MICROPY_PY_BUILTINS_MEMORYVIEW + { MP_ROM_QSTR(MP_QSTR_memoryview), MP_ROM_PTR(&mp_type_memoryview) }, + #endif + { MP_ROM_QSTR(MP_QSTR_object), MP_ROM_PTR(&mp_type_object) }, + #if MICROPY_PY_BUILTINS_PROPERTY + { MP_ROM_QSTR(MP_QSTR_property), MP_ROM_PTR(&mp_type_property) }, + #endif + { MP_ROM_QSTR(MP_QSTR_range), MP_ROM_PTR(&mp_type_range) }, + #if MICROPY_PY_BUILTINS_REVERSED + { MP_ROM_QSTR(MP_QSTR_reversed), MP_ROM_PTR(&mp_type_reversed) }, + #endif + #if MICROPY_PY_BUILTINS_SET + { MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&mp_type_set) }, + #endif + #if MICROPY_PY_BUILTINS_SLICE + { MP_ROM_QSTR(MP_QSTR_slice), MP_ROM_PTR(&mp_type_slice) }, + #endif + { MP_ROM_QSTR(MP_QSTR_str), MP_ROM_PTR(&mp_type_str) }, + { MP_ROM_QSTR(MP_QSTR_super), MP_ROM_PTR(&mp_type_super) }, + { MP_ROM_QSTR(MP_QSTR_tuple), MP_ROM_PTR(&mp_type_tuple) }, + { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&mp_type_type) }, + { MP_ROM_QSTR(MP_QSTR_zip), MP_ROM_PTR(&mp_type_zip) }, + + { MP_ROM_QSTR(MP_QSTR_classmethod), MP_ROM_PTR(&mp_type_classmethod) }, + { MP_ROM_QSTR(MP_QSTR_staticmethod), MP_ROM_PTR(&mp_type_staticmethod) }, + + // built-in objects + { MP_ROM_QSTR(MP_QSTR_Ellipsis), MP_ROM_PTR(&mp_const_ellipsis_obj) }, + #if MICROPY_PY_BUILTINS_NOTIMPLEMENTED + { MP_ROM_QSTR(MP_QSTR_NotImplemented), MP_ROM_PTR(&mp_const_notimplemented_obj) }, + #endif + + // built-in user functions + { MP_ROM_QSTR(MP_QSTR_abs), MP_ROM_PTR(&mp_builtin_abs_obj) }, + { MP_ROM_QSTR(MP_QSTR_all), MP_ROM_PTR(&mp_builtin_all_obj) }, + { MP_ROM_QSTR(MP_QSTR_any), MP_ROM_PTR(&mp_builtin_any_obj) }, + { MP_ROM_QSTR(MP_QSTR_bin), MP_ROM_PTR(&mp_builtin_bin_obj) }, + { MP_ROM_QSTR(MP_QSTR_callable), MP_ROM_PTR(&mp_builtin_callable_obj) }, + #if MICROPY_PY_BUILTINS_COMPILE + { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mp_builtin_compile_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_chr), MP_ROM_PTR(&mp_builtin_chr_obj) }, + #if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR_delattr), MP_ROM_PTR(&mp_builtin_delattr_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_dir), MP_ROM_PTR(&mp_builtin_dir_obj) }, + { MP_ROM_QSTR(MP_QSTR_divmod), MP_ROM_PTR(&mp_builtin_divmod_obj) }, + #if MICROPY_PY_BUILTINS_EVAL_EXEC + { MP_ROM_QSTR(MP_QSTR_eval), MP_ROM_PTR(&mp_builtin_eval_obj) }, + { MP_ROM_QSTR(MP_QSTR_exec), MP_ROM_PTR(&mp_builtin_exec_obj) }, + #endif + #if MICROPY_PY_BUILTINS_EXECFILE + { MP_ROM_QSTR(MP_QSTR_execfile), MP_ROM_PTR(&mp_builtin_execfile_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_getattr), MP_ROM_PTR(&mp_builtin_getattr_obj) }, + { MP_ROM_QSTR(MP_QSTR_setattr), MP_ROM_PTR(&mp_builtin_setattr_obj) }, + { MP_ROM_QSTR(MP_QSTR_globals), MP_ROM_PTR(&mp_builtin_globals_obj) }, + { MP_ROM_QSTR(MP_QSTR_hasattr), MP_ROM_PTR(&mp_builtin_hasattr_obj) }, + { MP_ROM_QSTR(MP_QSTR_hash), MP_ROM_PTR(&mp_builtin_hash_obj) }, + #if MICROPY_PY_BUILTINS_HELP + { MP_ROM_QSTR(MP_QSTR_help), MP_ROM_PTR(&mp_builtin_help_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&mp_builtin_hex_obj) }, + { MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&mp_builtin_id_obj) }, + #if MICROPY_PY_BUILTINS_INPUT + { MP_ROM_QSTR(MP_QSTR_input), MP_ROM_PTR(&mp_builtin_input_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_isinstance), MP_ROM_PTR(&mp_builtin_isinstance_obj) }, + { MP_ROM_QSTR(MP_QSTR_issubclass), MP_ROM_PTR(&mp_builtin_issubclass_obj) }, + { MP_ROM_QSTR(MP_QSTR_iter), MP_ROM_PTR(&mp_builtin_iter_obj) }, + { MP_ROM_QSTR(MP_QSTR_len), MP_ROM_PTR(&mp_builtin_len_obj) }, + { MP_ROM_QSTR(MP_QSTR_locals), MP_ROM_PTR(&mp_builtin_locals_obj) }, + #if MICROPY_PY_BUILTINS_MIN_MAX + { MP_ROM_QSTR(MP_QSTR_max), MP_ROM_PTR(&mp_builtin_max_obj) }, + { MP_ROM_QSTR(MP_QSTR_min), MP_ROM_PTR(&mp_builtin_min_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_next), MP_ROM_PTR(&mp_builtin_next_obj) }, + { MP_ROM_QSTR(MP_QSTR_oct), MP_ROM_PTR(&mp_builtin_oct_obj) }, + { MP_ROM_QSTR(MP_QSTR_ord), MP_ROM_PTR(&mp_builtin_ord_obj) }, + { MP_ROM_QSTR(MP_QSTR_pow), MP_ROM_PTR(&mp_builtin_pow_obj) }, + { MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&mp_builtin_print_obj) }, + { MP_ROM_QSTR(MP_QSTR_repr), MP_ROM_PTR(&mp_builtin_repr_obj) }, + { MP_ROM_QSTR(MP_QSTR_round), MP_ROM_PTR(&mp_builtin_round_obj) }, + { MP_ROM_QSTR(MP_QSTR_sorted), MP_ROM_PTR(&mp_builtin_sorted_obj) }, + { MP_ROM_QSTR(MP_QSTR_sum), MP_ROM_PTR(&mp_builtin_sum_obj) }, + + // built-in exceptions + { MP_ROM_QSTR(MP_QSTR_BaseException), MP_ROM_PTR(&mp_type_BaseException) }, + { MP_ROM_QSTR(MP_QSTR_ArithmeticError), MP_ROM_PTR(&mp_type_ArithmeticError) }, + { MP_ROM_QSTR(MP_QSTR_AssertionError), MP_ROM_PTR(&mp_type_AssertionError) }, + { MP_ROM_QSTR(MP_QSTR_AttributeError), MP_ROM_PTR(&mp_type_AttributeError) }, + { MP_ROM_QSTR(MP_QSTR_EOFError), MP_ROM_PTR(&mp_type_EOFError) }, + { MP_ROM_QSTR(MP_QSTR_Exception), MP_ROM_PTR(&mp_type_Exception) }, + { MP_ROM_QSTR(MP_QSTR_GeneratorExit), MP_ROM_PTR(&mp_type_GeneratorExit) }, + { MP_ROM_QSTR(MP_QSTR_ImportError), MP_ROM_PTR(&mp_type_ImportError) }, + { MP_ROM_QSTR(MP_QSTR_IndentationError), MP_ROM_PTR(&mp_type_IndentationError) }, + { MP_ROM_QSTR(MP_QSTR_IndexError), MP_ROM_PTR(&mp_type_IndexError) }, + { MP_ROM_QSTR(MP_QSTR_KeyboardInterrupt), MP_ROM_PTR(&mp_type_KeyboardInterrupt) }, + { MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) }, + { MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) }, + { MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) }, + { MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) }, + { MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) }, + { MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) }, + { MP_ROM_QSTR(MP_QSTR_OverflowError), MP_ROM_PTR(&mp_type_OverflowError) }, + { MP_ROM_QSTR(MP_QSTR_RuntimeError), MP_ROM_PTR(&mp_type_RuntimeError) }, + #if MICROPY_PY_ASYNC_AWAIT + { MP_ROM_QSTR(MP_QSTR_StopAsyncIteration), MP_ROM_PTR(&mp_type_StopAsyncIteration) }, + #endif + { MP_ROM_QSTR(MP_QSTR_StopIteration), MP_ROM_PTR(&mp_type_StopIteration) }, + { MP_ROM_QSTR(MP_QSTR_SyntaxError), MP_ROM_PTR(&mp_type_SyntaxError) }, + { MP_ROM_QSTR(MP_QSTR_SystemExit), MP_ROM_PTR(&mp_type_SystemExit) }, + { MP_ROM_QSTR(MP_QSTR_TypeError), MP_ROM_PTR(&mp_type_TypeError) }, + #if MICROPY_PY_BUILTINS_STR_UNICODE + { MP_ROM_QSTR(MP_QSTR_UnicodeError), MP_ROM_PTR(&mp_type_UnicodeError) }, + #endif + { MP_ROM_QSTR(MP_QSTR_ValueError), MP_ROM_PTR(&mp_type_ValueError) }, + #if MICROPY_EMIT_NATIVE + { MP_ROM_QSTR(MP_QSTR_ViperTypeError), MP_ROM_PTR(&mp_type_ViperTypeError) }, + #endif + { MP_ROM_QSTR(MP_QSTR_ZeroDivisionError), MP_ROM_PTR(&mp_type_ZeroDivisionError) }, + // Somehow CPython managed to have OverflowError not inherit from ValueError ;-/ + // TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation + + // Extra builtins as defined by a port + MICROPY_PORT_BUILTINS +}; + +MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_table); + +const mp_obj_module_t mp_module_builtins = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_builtins_globals, +}; diff --git a/user/mpy/py/modcmath.c b/user/mpy/py/modcmath.c new file mode 100644 index 0000000..627a2cb --- /dev/null +++ b/user/mpy/py/modcmath.c @@ -0,0 +1,166 @@ +/* + * 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. + */ + +#include "py/builtin.h" + +#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH + +#include + +/// \module cmath - mathematical functions for complex numbers +/// +/// The `cmath` module provides some basic mathematical funtions for +/// working with complex numbers. + +/// \function phase(z) +/// Returns the phase of the number `z`, in the range (-pi, +pi]. +STATIC mp_obj_t mp_cmath_phase(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + return mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase); + +/// \function polar(z) +/// Returns, as a tuple, the polar form of `z`. +STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + mp_obj_t tuple[2] = { + mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(real*real + imag*imag)), + mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real)), + }; + return mp_obj_new_tuple(2, tuple); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar); + +/// \function rect(r, phi) +/// Returns the complex number with modulus `r` and phase `phi`. +STATIC mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) { + mp_float_t r = mp_obj_get_float(r_obj); + mp_float_t phi = mp_obj_get_float(phi_obj); + return mp_obj_new_complex(r * MICROPY_FLOAT_C_FUN(cos)(phi), r * MICROPY_FLOAT_C_FUN(sin)(phi)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect); + +/// \function exp(z) +/// Return the exponential of `z`. +STATIC mp_obj_t mp_cmath_exp(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + mp_float_t exp_real = MICROPY_FLOAT_C_FUN(exp)(real); + return mp_obj_new_complex(exp_real * MICROPY_FLOAT_C_FUN(cos)(imag), exp_real * MICROPY_FLOAT_C_FUN(sin)(imag)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp); + +/// \function log(z) +/// Return the natural logarithm of `z`. The branch cut is along the negative real axis. +// TODO can take second argument, being the base +STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log)(real*real + imag*imag), MICROPY_FLOAT_C_FUN(atan2)(imag, real)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log); + +#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS +/// \function log10(z) +/// Return the base-10 logarithm of `z`. The branch cut is along the negative real axis. +STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log10)(real*real + imag*imag), 0.4342944819032518 * MICROPY_FLOAT_C_FUN(atan2)(imag, real)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10); +#endif + +/// \function sqrt(z) +/// Return the square-root of `z`. +STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real*real + imag*imag, 0.25); + mp_float_t theta = 0.5 * MICROPY_FLOAT_C_FUN(atan2)(imag, real); + return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt); + +/// \function cos(z) +/// Return the cosine of `z`. +STATIC mp_obj_t mp_cmath_cos(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), -MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos); + +/// \function sin(z) +/// Return the sine of `z`. +STATIC mp_obj_t mp_cmath_sin(mp_obj_t z_obj) { + mp_float_t real, imag; + mp_obj_get_complex(z_obj, &real, &imag); + return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin); + +STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cmath) }, + { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e }, + { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi }, + { MP_ROM_QSTR(MP_QSTR_phase), MP_ROM_PTR(&mp_cmath_phase_obj) }, + { MP_ROM_QSTR(MP_QSTR_polar), MP_ROM_PTR(&mp_cmath_polar_obj) }, + { MP_ROM_QSTR(MP_QSTR_rect), MP_ROM_PTR(&mp_cmath_rect_obj) }, + { MP_ROM_QSTR(MP_QSTR_exp), MP_ROM_PTR(&mp_cmath_exp_obj) }, + { MP_ROM_QSTR(MP_QSTR_log), MP_ROM_PTR(&mp_cmath_log_obj) }, + #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS + { MP_ROM_QSTR(MP_QSTR_log10), MP_ROM_PTR(&mp_cmath_log10_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_sqrt), MP_ROM_PTR(&mp_cmath_sqrt_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_acos), MP_ROM_PTR(&mp_cmath_acos_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_asin), MP_ROM_PTR(&mp_cmath_asin_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_atan), MP_ROM_PTR(&mp_cmath_atan_obj) }, + { MP_ROM_QSTR(MP_QSTR_cos), MP_ROM_PTR(&mp_cmath_cos_obj) }, + { MP_ROM_QSTR(MP_QSTR_sin), MP_ROM_PTR(&mp_cmath_sin_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_tan), MP_ROM_PTR(&mp_cmath_tan_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_acosh), MP_ROM_PTR(&mp_cmath_acosh_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_asinh), MP_ROM_PTR(&mp_cmath_asinh_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_atanh), MP_ROM_PTR(&mp_cmath_atanh_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_cosh), MP_ROM_PTR(&mp_cmath_cosh_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_sinh), MP_ROM_PTR(&mp_cmath_sinh_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_tanh), MP_ROM_PTR(&mp_cmath_tanh_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_isfinite), MP_ROM_PTR(&mp_cmath_isfinite_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_isinf), MP_ROM_PTR(&mp_cmath_isinf_obj) }, + //{ MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_cmath_isnan_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table); + +const mp_obj_module_t mp_module_cmath = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_cmath_globals, +}; + +#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH diff --git a/user/mpy/py/modcollections.c b/user/mpy/py/modcollections.c new file mode 100644 index 0000000..1a15603 --- /dev/null +++ b/user/mpy/py/modcollections.c @@ -0,0 +1,46 @@ +/* + * 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. + */ + +#include "py/builtin.h" + +#if MICROPY_PY_COLLECTIONS + +STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucollections) }, + { MP_ROM_QSTR(MP_QSTR_namedtuple), MP_ROM_PTR(&mp_namedtuple_obj) }, + #if MICROPY_PY_COLLECTIONS_ORDEREDDICT + { MP_ROM_QSTR(MP_QSTR_OrderedDict), MP_ROM_PTR(&mp_type_ordereddict) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table); + +const mp_obj_module_t mp_module_collections = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_collections_globals, +}; + +#endif // MICROPY_PY_COLLECTIONS diff --git a/user/mpy/py/modgc.c b/user/mpy/py/modgc.c new file mode 100644 index 0000000..d45e007 --- /dev/null +++ b/user/mpy/py/modgc.c @@ -0,0 +1,125 @@ +/* + * 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. + */ + +#include "py/mpstate.h" +#include "py/obj.h" +#include "py/gc.h" + +#if MICROPY_PY_GC && MICROPY_ENABLE_GC + +/// \module gc - control the garbage collector + +/// \function collect() +/// Run a garbage collection. +STATIC mp_obj_t py_gc_collect(void) { + gc_collect(); +#if MICROPY_PY_GC_COLLECT_RETVAL + return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected)); +#else + return mp_const_none; +#endif +} +MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect); + +/// \function disable() +/// Disable the garbage collector. +STATIC mp_obj_t gc_disable(void) { + MP_STATE_MEM(gc_auto_collect_enabled) = 0; + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable); + +/// \function enable() +/// Enable the garbage collector. +STATIC mp_obj_t gc_enable(void) { + MP_STATE_MEM(gc_auto_collect_enabled) = 1; + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable); + +STATIC mp_obj_t gc_isenabled(void) { + return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled)); +} +MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled); + +/// \function mem_free() +/// Return the number of bytes of available heap RAM. +STATIC mp_obj_t gc_mem_free(void) { + gc_info_t info; + gc_info(&info); + return MP_OBJ_NEW_SMALL_INT(info.free); +} +MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free); + +/// \function mem_alloc() +/// Return the number of bytes of heap RAM that are allocated. +STATIC mp_obj_t gc_mem_alloc(void) { + gc_info_t info; + gc_info(&info); + return MP_OBJ_NEW_SMALL_INT(info.used); +} +MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_alloc_obj, gc_mem_alloc); + +#if MICROPY_GC_ALLOC_THRESHOLD +STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + if (MP_STATE_MEM(gc_alloc_threshold) == (size_t)-1) { + return MP_OBJ_NEW_SMALL_INT(-1); + } + return mp_obj_new_int(MP_STATE_MEM(gc_alloc_threshold) * MICROPY_BYTES_PER_GC_BLOCK); + } + mp_int_t val = mp_obj_get_int(args[0]); + if (val < 0) { + MP_STATE_MEM(gc_alloc_threshold) = (size_t)-1; + } else { + MP_STATE_MEM(gc_alloc_threshold) = val / MICROPY_BYTES_PER_GC_BLOCK; + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gc_threshold_obj, 0, 1, gc_threshold); +#endif + +STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gc) }, + { MP_ROM_QSTR(MP_QSTR_collect), MP_ROM_PTR(&gc_collect_obj) }, + { MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&gc_disable_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable), MP_ROM_PTR(&gc_enable_obj) }, + { MP_ROM_QSTR(MP_QSTR_isenabled), MP_ROM_PTR(&gc_isenabled_obj) }, + { MP_ROM_QSTR(MP_QSTR_mem_free), MP_ROM_PTR(&gc_mem_free_obj) }, + { MP_ROM_QSTR(MP_QSTR_mem_alloc), MP_ROM_PTR(&gc_mem_alloc_obj) }, + #if MICROPY_GC_ALLOC_THRESHOLD + { MP_ROM_QSTR(MP_QSTR_threshold), MP_ROM_PTR(&gc_threshold_obj) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table); + +const mp_obj_module_t mp_module_gc = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_gc_globals, +}; + +#endif diff --git a/user/mpy/py/modio.c b/user/mpy/py/modio.c new file mode 100644 index 0000000..353a002 --- /dev/null +++ b/user/mpy/py/modio.c @@ -0,0 +1,215 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/stream.h" +#include "py/objstringio.h" +#include "py/frozenmod.h" + +#if MICROPY_PY_IO + +extern const mp_obj_type_t mp_type_fileio; +extern const mp_obj_type_t mp_type_textio; + +#if MICROPY_PY_IO_BUFFEREDWRITER +typedef struct _mp_obj_bufwriter_t { + mp_obj_base_t base; + mp_obj_t stream; + size_t alloc; + size_t len; + byte buf[0]; +} mp_obj_bufwriter_t; + +STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 2, false); + size_t alloc = mp_obj_get_int(args[1]); + mp_obj_bufwriter_t *o = m_new_obj_var(mp_obj_bufwriter_t, byte, alloc); + o->base.type = type; + o->stream = args[0]; + o->alloc = alloc; + o->len = 0; + return o; +} + +STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { + mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in); + + mp_uint_t org_size = size; + + while (size > 0) { + mp_uint_t rem = self->alloc - self->len; + if (size < rem) { + memcpy(self->buf + self->len, buf, size); + self->len += size; + return org_size; + } + + // Buffer flushing policy here is to flush entire buffer all the time. + // This allows e.g. to have a block device as backing storage and write + // entire block to it. memcpy below is not ideal and could be optimized + // in some cases. But the way it is now it at least ensures that buffer + // is word-aligned, to guard against obscure cases when it matters, e.g. + // https://github.com/micropython/micropython/issues/1863 + memcpy(self->buf + self->len, buf, rem); + buf = (byte*)buf + rem; + size -= rem; + mp_uint_t out_sz = mp_stream_write_exactly(self->stream, self->buf, self->alloc, errcode); + if (*errcode != 0) { + return MP_STREAM_ERROR; + } + // TODO: try to recover from a case of non-blocking stream, e.g. move + // remaining chunk to the beginning of buffer. + assert(out_sz == self->alloc); + self->len = 0; + } + + return org_size; +} + +STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) { + mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->len != 0) { + int err; + mp_uint_t out_sz = mp_stream_write_exactly(self->stream, self->buf, self->len, &err); + // TODO: try to recover from a case of non-blocking stream, e.g. move + // remaining chunk to the beginning of buffer. + assert(out_sz == self->len); + self->len = 0; + if (err != 0) { + mp_raise_OSError(err); + } + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush); + +STATIC const mp_rom_map_elem_t bufwriter_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&bufwriter_flush_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table); + +STATIC const mp_stream_p_t bufwriter_stream_p = { + .write = bufwriter_write, +}; + +STATIC const mp_obj_type_t bufwriter_type = { + { &mp_type_type }, + .name = MP_QSTR_BufferedWriter, + .make_new = bufwriter_make_new, + .protocol = &bufwriter_stream_p, + .locals_dict = (mp_obj_dict_t*)&bufwriter_locals_dict, +}; +#endif // MICROPY_PY_IO_BUFFEREDWRITER + +#if MICROPY_MODULE_FROZEN_STR +STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) { + VSTR_FIXED(path_buf, MICROPY_ALLOC_PATH_MAX); + size_t len; + + // As an extension to pkg_resources.resource_stream(), we support + // package parameter being None, the path_in is interpreted as a + // raw path. + if (package_in != mp_const_none) { + mp_obj_t args[5]; + args[0] = package_in; + args[1] = mp_const_none; // TODO should be globals + args[2] = mp_const_none; // TODO should be locals + args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module + args[4] = MP_OBJ_NEW_SMALL_INT(0); + + // TODO lookup __import__ and call that instead of going straight to builtin implementation + mp_obj_t pkg = mp_builtin___import__(5, args); + + mp_obj_t dest[2]; + mp_load_method_maybe(pkg, MP_QSTR___path__, dest); + if (dest[0] == MP_OBJ_NULL) { + mp_raise_TypeError(NULL); + } + + const char *path = mp_obj_str_get_data(dest[0], &len); + vstr_add_strn(&path_buf, path, len); + vstr_add_byte(&path_buf, '/'); + } + + const char *path = mp_obj_str_get_data(path_in, &len); + vstr_add_strn(&path_buf, path, len); + + len = path_buf.len; + const char *data = mp_find_frozen_str(path_buf.buf, &len); + if (data != NULL) { + mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); + o->base.type = &mp_type_bytesio; + o->vstr = m_new_obj(vstr_t); + vstr_init_fixed_buf(o->vstr, len + 1, (char*)data); + o->vstr->len = len; + o->pos = 0; + return MP_OBJ_FROM_PTR(o); + } + + mp_obj_t path_out = mp_obj_new_str(path_buf.buf, path_buf.len, false); + return mp_builtin_open(1, &path_out, (mp_map_t*)&mp_const_empty_map); +} +MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream); +#endif + +STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uio) }, + // Note: mp_builtin_open_obj should be defined by port, it's not + // part of the core. + { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, + #if MICROPY_PY_IO_RESOURCE_STREAM + { MP_ROM_QSTR(MP_QSTR_resource_stream), MP_ROM_PTR(&resource_stream_obj) }, + #endif + #if MICROPY_PY_IO_FILEIO + { MP_ROM_QSTR(MP_QSTR_FileIO), MP_ROM_PTR(&mp_type_fileio) }, + #if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR_TextIOWrapper), MP_ROM_PTR(&mp_type_textio) }, + #endif + #endif + { MP_ROM_QSTR(MP_QSTR_StringIO), MP_ROM_PTR(&mp_type_stringio) }, + #if MICROPY_PY_IO_BYTESIO + { MP_ROM_QSTR(MP_QSTR_BytesIO), MP_ROM_PTR(&mp_type_bytesio) }, + #endif + #if MICROPY_PY_IO_BUFFEREDWRITER + { MP_ROM_QSTR(MP_QSTR_BufferedWriter), MP_ROM_PTR(&bufwriter_type) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table); + +const mp_obj_module_t mp_module_io = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_io_globals, +}; + +#endif diff --git a/user/mpy/py/modmath.c b/user/mpy/py/modmath.c new file mode 100644 index 0000000..c56056a --- /dev/null +++ b/user/mpy/py/modmath.c @@ -0,0 +1,275 @@ +/* + * 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. + */ + +#include "py/builtin.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH + +#include + +// M_PI is not part of the math.h standard and may not be defined +// And by defining our own we can ensure it uses the correct const format. +#define MP_PI MICROPY_FLOAT_CONST(3.14159265358979323846) + +/// \module math - mathematical functions +/// +/// The `math` module provides some basic mathematical funtions for +/// working with floating-point numbers. + +STATIC NORETURN void math_error(void) { + mp_raise_ValueError("math domain error"); +} + +#define MATH_FUN_1(py_name, c_name) \ + STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + +#define MATH_FUN_2(py_name, c_name) \ + STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_float(y_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name); + +#define MATH_FUN_1_TO_BOOL(py_name, c_name) \ + STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + +#define MATH_FUN_1_TO_INT(py_name, c_name) \ + STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + +#define MATH_FUN_1_ERRCOND(py_name, c_name, error_condition) \ + STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { \ + mp_float_t x = mp_obj_get_float(x_obj); \ + if (error_condition) { \ + math_error(); \ + } \ + return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(x)); \ + } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + +#if MP_NEED_LOG2 +// 1.442695040888963407354163704 is 1/_M_LN2 +#define log2(x) (log(x) * 1.442695040888963407354163704) +#endif + +/// \function sqrt(x) +/// Returns the square root of `x`. +MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) +/// \function pow(x, y) +/// Returns `x` to the power of `y`. +MATH_FUN_2(pow, pow) +/// \function exp(x) +MATH_FUN_1(exp, exp) +#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS +/// \function expm1(x) +MATH_FUN_1(expm1, expm1) +/// \function log2(x) +MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0)) +/// \function log10(x) +MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0)) +/// \function cosh(x) +MATH_FUN_1(cosh, cosh) +/// \function sinh(x) +MATH_FUN_1(sinh, sinh) +/// \function tanh(x) +MATH_FUN_1(tanh, tanh) +/// \function acosh(x) +MATH_FUN_1(acosh, acosh) +/// \function asinh(x) +MATH_FUN_1(asinh, asinh) +/// \function atanh(x) +MATH_FUN_1(atanh, atanh) +#endif +/// \function cos(x) +MATH_FUN_1(cos, cos) +/// \function sin(x) +MATH_FUN_1(sin, sin) +/// \function tan(x) +MATH_FUN_1(tan, tan) +/// \function acos(x) +MATH_FUN_1(acos, acos) +/// \function asin(x) +MATH_FUN_1(asin, asin) +/// \function atan(x) +MATH_FUN_1(atan, atan) +/// \function atan2(y, x) +MATH_FUN_2(atan2, atan2) +/// \function ceil(x) +MATH_FUN_1_TO_INT(ceil, ceil) +/// \function copysign(x, y) +MATH_FUN_2(copysign, copysign) +/// \function fabs(x) +MATH_FUN_1(fabs, fabs) +/// \function floor(x) +MATH_FUN_1_TO_INT(floor, floor) //TODO: delegate to x.__floor__() if x is not a float +/// \function fmod(x, y) +MATH_FUN_2(fmod, fmod) +/// \function isfinite(x) +MATH_FUN_1_TO_BOOL(isfinite, isfinite) +/// \function isinf(x) +MATH_FUN_1_TO_BOOL(isinf, isinf) +/// \function isnan(x) +MATH_FUN_1_TO_BOOL(isnan, isnan) +/// \function trunc(x) +MATH_FUN_1_TO_INT(trunc, trunc) +/// \function ldexp(x, exp) +MATH_FUN_2(ldexp, ldexp) +#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS +/// \function erf(x) +/// Return the error function of `x`. +MATH_FUN_1(erf, erf) +/// \function erfc(x) +/// Return the complementary error function of `x`. +MATH_FUN_1(erfc, erfc) +/// \function gamma(x) +/// Return the gamma function of `x`. +MATH_FUN_1(gamma, tgamma) +/// \function lgamma(x) +/// return the natural logarithm of the gamma function of `x`. +MATH_FUN_1(lgamma, lgamma) +#endif +//TODO: factorial, fsum + +// Function that takes a variable number of arguments + +// log(x[, base]) +STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) { + mp_float_t x = mp_obj_get_float(args[0]); + if (x <= (mp_float_t)0.0) { + math_error(); + } + mp_float_t l = MICROPY_FLOAT_C_FUN(log)(x); + if (n_args == 1) { + return mp_obj_new_float(l); + } else { + mp_float_t base = mp_obj_get_float(args[1]); + if (base <= (mp_float_t)0.0) { + math_error(); + } else if (base == (mp_float_t)1.0) { + mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); + } + return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log); + +// Functions that return a tuple + +/// \function frexp(x) +/// Converts a floating-point number to fractional and integral components. +STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) { + int int_exponent = 0; + mp_float_t significand = MICROPY_FLOAT_C_FUN(frexp)(mp_obj_get_float(x_obj), &int_exponent); + mp_obj_t tuple[2]; + tuple[0] = mp_obj_new_float(significand); + tuple[1] = mp_obj_new_int(int_exponent); + return mp_obj_new_tuple(2, tuple); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp); + +/// \function modf(x) +STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) { + mp_float_t int_part = 0.0; + mp_float_t fractional_part = MICROPY_FLOAT_C_FUN(modf)(mp_obj_get_float(x_obj), &int_part); + mp_obj_t tuple[2]; + tuple[0] = mp_obj_new_float(fractional_part); + tuple[1] = mp_obj_new_float(int_part); + return mp_obj_new_tuple(2, tuple); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf); + +// Angular conversions + +/// \function radians(x) +STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) { + return mp_obj_new_float(mp_obj_get_float(x_obj) * (MP_PI / MICROPY_FLOAT_CONST(180.0))); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians); + +/// \function degrees(x) +STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) { + return mp_obj_new_float(mp_obj_get_float(x_obj) * (MICROPY_FLOAT_CONST(180.0) / MP_PI)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees); + +STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_math) }, + { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e }, + { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi }, + { MP_ROM_QSTR(MP_QSTR_sqrt), MP_ROM_PTR(&mp_math_sqrt_obj) }, + { MP_ROM_QSTR(MP_QSTR_pow), MP_ROM_PTR(&mp_math_pow_obj) }, + { MP_ROM_QSTR(MP_QSTR_exp), MP_ROM_PTR(&mp_math_exp_obj) }, + #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS + { MP_ROM_QSTR(MP_QSTR_expm1), MP_ROM_PTR(&mp_math_expm1_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_log), MP_ROM_PTR(&mp_math_log_obj) }, + #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS + { MP_ROM_QSTR(MP_QSTR_log2), MP_ROM_PTR(&mp_math_log2_obj) }, + { MP_ROM_QSTR(MP_QSTR_log10), MP_ROM_PTR(&mp_math_log10_obj) }, + { MP_ROM_QSTR(MP_QSTR_cosh), MP_ROM_PTR(&mp_math_cosh_obj) }, + { MP_ROM_QSTR(MP_QSTR_sinh), MP_ROM_PTR(&mp_math_sinh_obj) }, + { MP_ROM_QSTR(MP_QSTR_tanh), MP_ROM_PTR(&mp_math_tanh_obj) }, + { MP_ROM_QSTR(MP_QSTR_acosh), MP_ROM_PTR(&mp_math_acosh_obj) }, + { MP_ROM_QSTR(MP_QSTR_asinh), MP_ROM_PTR(&mp_math_asinh_obj) }, + { MP_ROM_QSTR(MP_QSTR_atanh), MP_ROM_PTR(&mp_math_atanh_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_cos), MP_ROM_PTR(&mp_math_cos_obj) }, + { MP_ROM_QSTR(MP_QSTR_sin), MP_ROM_PTR(&mp_math_sin_obj) }, + { MP_ROM_QSTR(MP_QSTR_tan), MP_ROM_PTR(&mp_math_tan_obj) }, + { MP_ROM_QSTR(MP_QSTR_acos), MP_ROM_PTR(&mp_math_acos_obj) }, + { MP_ROM_QSTR(MP_QSTR_asin), MP_ROM_PTR(&mp_math_asin_obj) }, + { MP_ROM_QSTR(MP_QSTR_atan), MP_ROM_PTR(&mp_math_atan_obj) }, + { MP_ROM_QSTR(MP_QSTR_atan2), MP_ROM_PTR(&mp_math_atan2_obj) }, + { MP_ROM_QSTR(MP_QSTR_ceil), MP_ROM_PTR(&mp_math_ceil_obj) }, + { MP_ROM_QSTR(MP_QSTR_copysign), MP_ROM_PTR(&mp_math_copysign_obj) }, + { MP_ROM_QSTR(MP_QSTR_fabs), MP_ROM_PTR(&mp_math_fabs_obj) }, + { MP_ROM_QSTR(MP_QSTR_floor), MP_ROM_PTR(&mp_math_floor_obj) }, + { MP_ROM_QSTR(MP_QSTR_fmod), MP_ROM_PTR(&mp_math_fmod_obj) }, + { MP_ROM_QSTR(MP_QSTR_frexp), MP_ROM_PTR(&mp_math_frexp_obj) }, + { MP_ROM_QSTR(MP_QSTR_ldexp), MP_ROM_PTR(&mp_math_ldexp_obj) }, + { MP_ROM_QSTR(MP_QSTR_modf), MP_ROM_PTR(&mp_math_modf_obj) }, + { MP_ROM_QSTR(MP_QSTR_isfinite), MP_ROM_PTR(&mp_math_isfinite_obj) }, + { MP_ROM_QSTR(MP_QSTR_isinf), MP_ROM_PTR(&mp_math_isinf_obj) }, + { MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_math_isnan_obj) }, + { MP_ROM_QSTR(MP_QSTR_trunc), MP_ROM_PTR(&mp_math_trunc_obj) }, + { MP_ROM_QSTR(MP_QSTR_radians), MP_ROM_PTR(&mp_math_radians_obj) }, + { MP_ROM_QSTR(MP_QSTR_degrees), MP_ROM_PTR(&mp_math_degrees_obj) }, + #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS + { MP_ROM_QSTR(MP_QSTR_erf), MP_ROM_PTR(&mp_math_erf_obj) }, + { MP_ROM_QSTR(MP_QSTR_erfc), MP_ROM_PTR(&mp_math_erfc_obj) }, + { MP_ROM_QSTR(MP_QSTR_gamma), MP_ROM_PTR(&mp_math_gamma_obj) }, + { MP_ROM_QSTR(MP_QSTR_lgamma), MP_ROM_PTR(&mp_math_lgamma_obj) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table); + +const mp_obj_module_t mp_module_math = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_math_globals, +}; + +#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/user/mpy/py/modmicropython.c b/user/mpy/py/modmicropython.c new file mode 100644 index 0000000..6fa3f9a --- /dev/null +++ b/user/mpy/py/modmicropython.c @@ -0,0 +1,188 @@ +/* + * 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. + */ + +#include + +#include "py/mpstate.h" +#include "py/builtin.h" +#include "py/stackctrl.h" +#include "py/runtime.h" +#include "py/gc.h" +#include "py/mphal.h" + +// Various builtins specific to MicroPython runtime, +// living in micropython module + +STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + return MP_OBJ_NEW_SMALL_INT(MP_STATE_VM(mp_optimise_value)); + } else { + MP_STATE_VM(mp_optimise_value) = mp_obj_get_int(args[0]); + return mp_const_none; + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level); + +#if MICROPY_PY_MICROPYTHON_MEM_INFO + +#if MICROPY_MEM_STATS +STATIC mp_obj_t mp_micropython_mem_total(void) { + return MP_OBJ_NEW_SMALL_INT(m_get_total_bytes_allocated()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total); + +STATIC mp_obj_t mp_micropython_mem_current(void) { + return MP_OBJ_NEW_SMALL_INT(m_get_current_bytes_allocated()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current); + +STATIC mp_obj_t mp_micropython_mem_peak(void) { + return MP_OBJ_NEW_SMALL_INT(m_get_peak_bytes_allocated()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak); +#endif + +mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) { + (void)args; +#if MICROPY_MEM_STATS + mp_printf(&mp_plat_print, "mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n", + (mp_uint_t)m_get_total_bytes_allocated(), (mp_uint_t)m_get_current_bytes_allocated(), (mp_uint_t)m_get_peak_bytes_allocated()); +#endif +#if MICROPY_STACK_CHECK + mp_printf(&mp_plat_print, "stack: " UINT_FMT " out of " UINT_FMT "\n", + mp_stack_usage(), (mp_uint_t)MP_STATE_THREAD(stack_limit)); +#else + mp_printf(&mp_plat_print, "stack: " UINT_FMT "\n", mp_stack_usage()); +#endif +#if MICROPY_ENABLE_GC + gc_dump_info(); + if (n_args == 1) { + // arg given means dump gc allocation table + gc_dump_alloc_table(); + } +#else + (void)n_args; +#endif + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info); + +STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) { + (void)args; + size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; + qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); + mp_printf(&mp_plat_print, "qstr pool: n_pool=%u, n_qstr=%u, n_str_data_bytes=%u, n_total_bytes=%u\n", + n_pool, n_qstr, n_str_data_bytes, n_total_bytes); + if (n_args == 1) { + // arg given means dump qstr data + qstr_dump_data(); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info); + +#if MICROPY_STACK_CHECK +STATIC mp_obj_t mp_micropython_stack_use(void) { + return MP_OBJ_NEW_SMALL_INT(mp_stack_usage()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use); +#endif + +#endif // MICROPY_PY_MICROPYTHON_MEM_INFO + +#if MICROPY_ENABLE_GC +STATIC mp_obj_t mp_micropython_heap_lock(void) { + gc_lock(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock); + +STATIC mp_obj_t mp_micropython_heap_unlock(void) { + gc_unlock(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock); +#endif + +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0) +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf); +#endif + +#if MICROPY_KBD_EXCEPTION +STATIC mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) { + mp_hal_set_interrupt_char(mp_obj_get_int(int_chr_in)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr); +#endif + +#if MICROPY_ENABLE_SCHEDULER +STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) { + if (!mp_sched_schedule(function, arg)) { + mp_raise_msg(&mp_type_RuntimeError, "schedule stack full"); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule); +#endif + +STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) }, + { MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) }, + { MP_ROM_QSTR(MP_QSTR_opt_level), MP_ROM_PTR(&mp_micropython_opt_level_obj) }, +#if MICROPY_PY_MICROPYTHON_MEM_INFO +#if MICROPY_MEM_STATS + { MP_ROM_QSTR(MP_QSTR_mem_total), MP_ROM_PTR(&mp_micropython_mem_total_obj) }, + { MP_ROM_QSTR(MP_QSTR_mem_current), MP_ROM_PTR(&mp_micropython_mem_current_obj) }, + { MP_ROM_QSTR(MP_QSTR_mem_peak), MP_ROM_PTR(&mp_micropython_mem_peak_obj) }, +#endif + { MP_ROM_QSTR(MP_QSTR_mem_info), MP_ROM_PTR(&mp_micropython_mem_info_obj) }, + { MP_ROM_QSTR(MP_QSTR_qstr_info), MP_ROM_PTR(&mp_micropython_qstr_info_obj) }, + #if MICROPY_STACK_CHECK + { MP_ROM_QSTR(MP_QSTR_stack_use), MP_ROM_PTR(&mp_micropython_stack_use_obj) }, + #endif +#endif +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0) + { MP_ROM_QSTR(MP_QSTR_alloc_emergency_exception_buf), MP_ROM_PTR(&mp_alloc_emergency_exception_buf_obj) }, +#endif + #if MICROPY_ENABLE_GC + { MP_ROM_QSTR(MP_QSTR_heap_lock), MP_ROM_PTR(&mp_micropython_heap_lock_obj) }, + { MP_ROM_QSTR(MP_QSTR_heap_unlock), MP_ROM_PTR(&mp_micropython_heap_unlock_obj) }, + #endif + #if MICROPY_KBD_EXCEPTION + { MP_ROM_QSTR(MP_QSTR_kbd_intr), MP_ROM_PTR(&mp_micropython_kbd_intr_obj) }, + #endif + #if MICROPY_ENABLE_SCHEDULER + { MP_ROM_QSTR(MP_QSTR_schedule), MP_ROM_PTR(&mp_micropython_schedule_obj) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table); + +const mp_obj_module_t mp_module_micropython = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_micropython_globals, +}; diff --git a/user/mpy/py/modstruct.c b/user/mpy/py/modstruct.c new file mode 100644 index 0000000..1daa333 --- /dev/null +++ b/user/mpy/py/modstruct.c @@ -0,0 +1,266 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/objtuple.h" +#include "py/binary.h" +#include "py/parsenum.h" + +#if MICROPY_PY_STRUCT + +/* + This module implements most of character typecodes from CPython, with + some extensions: + + O - (Pointer to) an arbitrary Python object. This is useful for callback + data, etc. Note that you must keep reference to passed object in + your Python application, otherwise it may be garbage-collected, + and then when you get back this value from callback it may be + invalid (and lead to crash). + S - Pointer to a string (returned as a Python string). Note the + difference from "Ns", - the latter says "in this place of structure + is character data of up to N bytes length", while "S" means + "in this place of a structure is a pointer to zero-terminated + character data". + */ + +STATIC char get_fmt_type(const char **fmt) { + char t = **fmt; + switch (t) { + case '!': + t = '>'; + break; + case '@': + case '=': + case '<': + case '>': + break; + default: + return '@'; + } + // Skip type char + (*fmt)++; + return t; +} + +STATIC mp_uint_t get_fmt_num(const char **p) { + const char *num = *p; + uint len = 1; + while (unichar_isdigit(*++num)) { + len++; + } + mp_uint_t val = (mp_uint_t)MP_OBJ_SMALL_INT_VALUE(mp_parse_num_integer(*p, len, 10, NULL)); + *p = num; + return val; +} + +STATIC uint calcsize_items(const char *fmt) { + uint cnt = 0; + while (*fmt) { + int num = 1; + if (unichar_isdigit(*fmt)) { + num = get_fmt_num(&fmt); + if (*fmt == 's') { + num = 1; + } + } + cnt += num; + fmt++; + } + return cnt; +} + +STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { + const char *fmt = mp_obj_str_get_str(fmt_in); + char fmt_type = get_fmt_type(&fmt); + mp_uint_t size; + for (size = 0; *fmt; fmt++) { + mp_uint_t cnt = 1; + if (unichar_isdigit(*fmt)) { + cnt = get_fmt_num(&fmt); + } + + if (*fmt == 's') { + size += cnt; + } else { + mp_uint_t align; + size_t sz = mp_binary_get_size(fmt_type, *fmt, &align); + while (cnt--) { + // Apply alignment + size = (size + align - 1) & ~(align - 1); + size += sz; + } + } + } + return MP_OBJ_NEW_SMALL_INT(size); +} +MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize); + +STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) { + // unpack requires that the buffer be exactly the right size. + // unpack_from requires that the buffer be "big enough". + // Since we implement unpack and unpack_from using the same function + // we relax the "exact" requirement, and only implement "big enough". + const char *fmt = mp_obj_str_get_str(args[0]); + char fmt_type = get_fmt_type(&fmt); + uint num_items = calcsize_items(fmt); + mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_items, NULL)); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); + byte *p = bufinfo.buf; + byte *end_p = &p[bufinfo.len]; + mp_int_t offset = 0; + + if (n_args > 2) { + // offset arg provided + offset = mp_obj_get_int(args[2]); + if (offset < 0) { + // negative offsets are relative to the end of the buffer + offset = bufinfo.len + offset; + if (offset < 0) { + mp_raise_ValueError("buffer too small"); + } + } + p += offset; + } + + for (uint i = 0; i < num_items;) { + mp_uint_t sz = 1; + if (unichar_isdigit(*fmt)) { + sz = get_fmt_num(&fmt); + } + if (p + sz > end_p) { + mp_raise_ValueError("buffer too small"); + } + mp_obj_t item; + if (*fmt == 's') { + item = mp_obj_new_bytes(p, sz); + p += sz; + res->items[i++] = item; + } else { + while (sz--) { + item = mp_binary_get_val(fmt_type, *fmt, &p); + res->items[i++] = item; + } + } + fmt++; + } + return MP_OBJ_FROM_PTR(res); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_from); + +STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args) { + const char *fmt = mp_obj_str_get_str(fmt_in); + char fmt_type = get_fmt_type(&fmt); + + size_t i; + for (i = 0; i < n_args;) { + mp_uint_t sz = 1; + if (*fmt == '\0') { + // more arguments given than used by format string; CPython raises struct.error here + break; + } + if (unichar_isdigit(*fmt)) { + sz = get_fmt_num(&fmt); + } + if (p + sz > end_p) { + mp_raise_ValueError("buffer too small"); + } + + if (*fmt == 's') { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[i++], &bufinfo, MP_BUFFER_READ); + mp_uint_t to_copy = sz; + if (bufinfo.len < to_copy) { + to_copy = bufinfo.len; + } + memcpy(p, bufinfo.buf, to_copy); + memset(p + to_copy, 0, sz - to_copy); + p += sz; + } else { + while (sz--) { + mp_binary_set_val(fmt_type, *fmt, args[i++], &p); + } + } + fmt++; + } +} + +STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { + // TODO: "The arguments must match the values required by the format exactly." + mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); + vstr_t vstr; + vstr_init_len(&vstr, size); + byte *p = (byte*)vstr.buf; + memset(p, 0, size); + byte *end_p = &p[size]; + struct_pack_into_internal(args[0], p, end_p, n_args - 1, &args[1]); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack); + +STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); + mp_int_t offset = mp_obj_get_int(args[2]); + if (offset < 0) { + // negative offsets are relative to the end of the buffer + offset = (mp_int_t)bufinfo.len + offset; + if (offset < 0) { + mp_raise_ValueError("buffer too small"); + } + } + byte *p = (byte *)bufinfo.buf; + byte *end_p = &p[bufinfo.len]; + p += offset; + + struct_pack_into_internal(args[0], p, end_p, n_args - 3, &args[3]); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into); + +STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ustruct) }, + { MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) }, + { MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) }, + { MP_ROM_QSTR(MP_QSTR_pack_into), MP_ROM_PTR(&struct_pack_into_obj) }, + { MP_ROM_QSTR(MP_QSTR_unpack), MP_ROM_PTR(&struct_unpack_from_obj) }, + { MP_ROM_QSTR(MP_QSTR_unpack_from), MP_ROM_PTR(&struct_unpack_from_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table); + +const mp_obj_module_t mp_module_ustruct = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_struct_globals, +}; + +#endif diff --git a/user/mpy/py/modsys.c b/user/mpy/py/modsys.c new file mode 100644 index 0000000..b7d55fd --- /dev/null +++ b/user/mpy/py/modsys.c @@ -0,0 +1,222 @@ +/* + * 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-2017 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. + */ + +#include "py/mpstate.h" +#include "py/nlr.h" +#include "py/builtin.h" +#include "py/objlist.h" +#include "py/objtuple.h" +#include "py/objstr.h" +#include "py/objint.h" +#include "py/objtype.h" +#include "py/stream.h" +#include "py/smallint.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_SYS + +#include "genhdr/mpversion.h" + +/// \module sys - system specific functions + +// defined per port; type of these is irrelevant, just need pointer +extern struct _mp_dummy_t mp_sys_stdin_obj; +extern struct _mp_dummy_t mp_sys_stdout_obj; +extern struct _mp_dummy_t mp_sys_stderr_obj; + +#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES +const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, mp_stream_write_adaptor}; +#endif + +/// \constant version - Python language version that this implementation conforms to, as a string +STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0"); + +/// \constant version_info - Python language version that this implementation conforms to, as a tuple of ints +#define I(n) MP_OBJ_NEW_SMALL_INT(n) +// TODO: CPython is now at 5-element array, but save 2 els so far... +STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}}; + +// sys.implementation object +// this holds the MicroPython version +STATIC const mp_obj_tuple_t mp_sys_implementation_version_info_obj = { + {&mp_type_tuple}, + 3, + { I(MICROPY_VERSION_MAJOR), I(MICROPY_VERSION_MINOR), I(MICROPY_VERSION_MICRO) } +}; +#if MICROPY_PY_ATTRTUPLE +STATIC const qstr impl_fields[] = { MP_QSTR_name, MP_QSTR_version }; +STATIC MP_DEFINE_ATTRTUPLE( + mp_sys_implementation_obj, + impl_fields, + 2, + MP_ROM_QSTR(MP_QSTR_micropython), + MP_ROM_PTR(&mp_sys_implementation_version_info_obj) +); +#else +STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = { + {&mp_type_tuple}, + 2, + { + MP_ROM_QSTR(MP_QSTR_micropython), + MP_ROM_PTR(&mp_sys_implementation_version_info_obj), + } +}; +#endif + +#undef I + +#ifdef MICROPY_PY_SYS_PLATFORM +/// \constant platform - the platform that MicroPython is running on +STATIC const MP_DEFINE_STR_OBJ(platform_obj, MICROPY_PY_SYS_PLATFORM); +#endif + +/// \function exit([retval]) +/// Raise a `SystemExit` exception. If an argument is given, it is the +/// value given to `SystemExit`. +STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) { + mp_obj_t exc; + if (n_args == 0) { + exc = mp_obj_new_exception(&mp_type_SystemExit); + } else { + exc = mp_obj_new_exception_arg1(&mp_type_SystemExit, args[0]); + } + nlr_raise(exc); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit); + +STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) { + #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES + void *stream_obj = &mp_sys_stdout_obj; + if (n_args > 1) { + stream_obj = MP_OBJ_TO_PTR(args[1]); // XXX may fail + } + + mp_print_t print = {stream_obj, mp_stream_write_adaptor}; + mp_obj_print_exception(&print, args[0]); + #else + (void)n_args; + mp_obj_print_exception(&mp_plat_print, args[0]); + #endif + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_print_exception_obj, 1, 2, mp_sys_print_exception); + +#if MICROPY_PY_SYS_EXC_INFO +STATIC mp_obj_t mp_sys_exc_info(void) { + mp_obj_t cur_exc = MP_OBJ_FROM_PTR(MP_STATE_VM(cur_exception)); + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); + + if (cur_exc == MP_OBJ_NULL) { + t->items[0] = mp_const_none; + t->items[1] = mp_const_none; + t->items[2] = mp_const_none; + return MP_OBJ_FROM_PTR(t); + } + + t->items[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(cur_exc)); + t->items[1] = cur_exc; + t->items[2] = mp_const_none; + return MP_OBJ_FROM_PTR(t); +} +MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info); +#endif + +STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) { + return mp_unary_op(MP_UNARY_OP_SIZEOF, obj); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof); + +STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) }, + + { MP_ROM_QSTR(MP_QSTR_path), MP_ROM_PTR(&MP_STATE_VM(mp_sys_path_obj)) }, + { MP_ROM_QSTR(MP_QSTR_argv), MP_ROM_PTR(&MP_STATE_VM(mp_sys_argv_obj)) }, + { MP_ROM_QSTR(MP_QSTR_version), MP_ROM_PTR(&version_obj) }, + { MP_ROM_QSTR(MP_QSTR_version_info), MP_ROM_PTR(&mp_sys_version_info_obj) }, + { MP_ROM_QSTR(MP_QSTR_implementation), MP_ROM_PTR(&mp_sys_implementation_obj) }, + #ifdef MICROPY_PY_SYS_PLATFORM + { MP_ROM_QSTR(MP_QSTR_platform), MP_ROM_PTR(&platform_obj) }, + #endif + /// \constant byteorder - the byte order of the system ("little" or "big") + #if MP_ENDIANNESS_LITTLE + { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_QSTR(MP_QSTR_little) }, + #else + { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_QSTR(MP_QSTR_big) }, + #endif + + #if MICROPY_PY_SYS_MAXSIZE + #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + // Maximum mp_int_t value is not representable as small int, so we have + // little choice but to use MP_SMALL_INT_MAX. Apps also should be careful + // to not try to compare sys.maxsize to some literal number (as this + // number might not fit in available int size), but instead count number + // of "one" bits in sys.maxsize. + { MP_ROM_QSTR(MP_QSTR_maxsize), MP_ROM_INT(MP_SMALL_INT_MAX) }, + #else + { MP_ROM_QSTR(MP_QSTR_maxsize), MP_ROM_PTR(&mp_maxsize_obj) }, + #endif + #endif + + #if MICROPY_PY_SYS_EXIT + // documented per-port + { MP_ROM_QSTR(MP_QSTR_exit), MP_ROM_PTR(&mp_sys_exit_obj) }, + #endif + + #if MICROPY_PY_SYS_STDFILES + // documented per-port + { MP_ROM_QSTR(MP_QSTR_stdin), MP_ROM_PTR(&mp_sys_stdin_obj) }, + { MP_ROM_QSTR(MP_QSTR_stdout), MP_ROM_PTR(&mp_sys_stdout_obj) }, + { MP_ROM_QSTR(MP_QSTR_stderr), MP_ROM_PTR(&mp_sys_stderr_obj) }, + #endif + + #if MICROPY_PY_SYS_MODULES + { MP_ROM_QSTR(MP_QSTR_modules), MP_ROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)) }, + #endif + #if MICROPY_PY_SYS_EXC_INFO + { MP_ROM_QSTR(MP_QSTR_exc_info), MP_ROM_PTR(&mp_sys_exc_info_obj) }, + #endif + #if MICROPY_PY_SYS_GETSIZEOF + { MP_ROM_QSTR(MP_QSTR_getsizeof), MP_ROM_PTR(&mp_sys_getsizeof_obj) }, + #endif + + /* + * Extensions to CPython + */ + + { MP_ROM_QSTR(MP_QSTR_print_exception), MP_ROM_PTR(&mp_sys_print_exception_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table); + +const mp_obj_module_t mp_module_sys = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_sys_globals, +}; + +#endif diff --git a/user/mpy/py/modthread.c b/user/mpy/py/modthread.c new file mode 100644 index 0000000..bf74128 --- /dev/null +++ b/user/mpy/py/modthread.c @@ -0,0 +1,294 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime.h" +#include "py/stackctrl.h" + +#if MICROPY_PY_THREAD + +#include "py/mpthread.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_PRINT (0) +#define DEBUG_printf(...) (void)0 +#endif + +/****************************************************************/ +// Lock object + +STATIC const mp_obj_type_t mp_type_thread_lock; + +typedef struct _mp_obj_thread_lock_t { + mp_obj_base_t base; + mp_thread_mutex_t mutex; + volatile bool locked; +} mp_obj_thread_lock_t; + +STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) { + mp_obj_thread_lock_t *self = m_new_obj(mp_obj_thread_lock_t); + self->base.type = &mp_type_thread_lock; + mp_thread_mutex_init(&self->mutex); + self->locked = false; + return self; +} + +STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) { + mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(args[0]); + bool wait = true; + if (n_args > 1) { + wait = mp_obj_get_int(args[1]); + // TODO support timeout arg + } + MP_THREAD_GIL_EXIT(); + int ret = mp_thread_mutex_lock(&self->mutex, wait); + MP_THREAD_GIL_ENTER(); + if (ret == 0) { + return mp_const_false; + } else if (ret == 1) { + self->locked = true; + return mp_const_true; + } else { + mp_raise_OSError(-ret); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire); + +STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) { + mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in); + if (!self->locked) { + mp_raise_msg(&mp_type_RuntimeError, NULL); + } + self->locked = false; + MP_THREAD_GIL_EXIT(); + mp_thread_mutex_unlock(&self->mutex); + MP_THREAD_GIL_ENTER(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release); + +STATIC mp_obj_t thread_lock_locked(mp_obj_t self_in) { + mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_bool(self->locked); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked); + +STATIC mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; // unused + return thread_lock_release(args[0]); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__); + +STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_acquire), MP_ROM_PTR(&thread_lock_acquire_obj) }, + { MP_ROM_QSTR(MP_QSTR_release), MP_ROM_PTR(&thread_lock_release_obj) }, + { MP_ROM_QSTR(MP_QSTR_locked), MP_ROM_PTR(&thread_lock_locked_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&thread_lock_acquire_obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&thread_lock___exit___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table); + +STATIC const mp_obj_type_t mp_type_thread_lock = { + { &mp_type_type }, + .name = MP_QSTR_lock, + .locals_dict = (mp_obj_dict_t*)&thread_lock_locals_dict, +}; + +/****************************************************************/ +// _thread module + +STATIC size_t thread_stack_size = 0; + +STATIC mp_obj_t mod_thread_get_ident(void) { + return mp_obj_new_int_from_uint((uintptr_t)mp_thread_get_state()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident); + +STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) { + mp_obj_t ret = mp_obj_new_int_from_uint(thread_stack_size); + if (n_args == 0) { + thread_stack_size = 0; + } else { + thread_stack_size = mp_obj_get_int(args[0]); + } + return ret; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size); + +typedef struct _thread_entry_args_t { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + size_t stack_size; + mp_obj_t fun; + size_t n_args; + size_t n_kw; + mp_obj_t args[]; +} thread_entry_args_t; + +STATIC void *thread_entry(void *args_in) { + // Execution begins here for a new thread. We do not have the GIL. + + thread_entry_args_t *args = (thread_entry_args_t*)args_in; + + mp_state_thread_t ts; + mp_thread_set_state(&ts); + + mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan + mp_stack_set_limit(args->stack_size); + + // set locals and globals from the calling context + mp_locals_set(args->dict_locals); + mp_globals_set(args->dict_globals); + + MP_THREAD_GIL_ENTER(); + + // signal that we are set up and running + mp_thread_start(); + + // TODO set more thread-specific state here: + // mp_pending_exception? (root pointer) + // cur_exception (root pointer) + + DEBUG_printf("[thread] start ts=%p args=%p stack=%p\n", &ts, &args, MP_STATE_THREAD(stack_top)); + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_call_function_n_kw(args->fun, args->n_args, args->n_kw, args->args); + nlr_pop(); + } else { + // uncaught exception + // check for SystemExit + mp_obj_base_t *exc = (mp_obj_base_t*)nlr.ret_val; + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) { + // swallow exception silently + } else { + // print exception out + mp_printf(&mp_plat_print, "Unhandled exception in thread started by "); + mp_obj_print_helper(&mp_plat_print, args->fun, PRINT_REPR); + mp_printf(&mp_plat_print, "\n"); + mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(exc)); + } + } + + DEBUG_printf("[thread] finish ts=%p\n", &ts); + + // signal that we are finished + mp_thread_finish(); + + MP_THREAD_GIL_EXIT(); + + return NULL; +} + +STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) { + // This structure holds the Python function and arguments for thread entry. + // We copy all arguments into this structure to keep ownership of them. + // We must be very careful about root pointers because this pointer may + // disappear from our address space before the thread is created. + thread_entry_args_t *th_args; + + // get positional arguments + size_t pos_args_len; + mp_obj_t *pos_args_items; + mp_obj_get_array(args[1], &pos_args_len, &pos_args_items); + + // check for keyword arguments + if (n_args == 2) { + // just position arguments + th_args = m_new_obj_var(thread_entry_args_t, mp_obj_t, pos_args_len); + th_args->n_kw = 0; + } else { + // positional and keyword arguments + if (mp_obj_get_type(args[2]) != &mp_type_dict) { + mp_raise_TypeError("expecting a dict for keyword args"); + } + mp_map_t *map = &((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[2]))->map; + th_args = m_new_obj_var(thread_entry_args_t, mp_obj_t, pos_args_len + 2 * map->used); + th_args->n_kw = map->used; + // copy across the keyword arguments + for (size_t i = 0, n = pos_args_len; i < map->alloc; ++i) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + th_args->args[n++] = map->table[i].key; + th_args->args[n++] = map->table[i].value; + } + } + } + + // copy agross the positional arguments + th_args->n_args = pos_args_len; + memcpy(th_args->args, pos_args_items, pos_args_len * sizeof(mp_obj_t)); + + // pass our locals and globals into the new thread + th_args->dict_locals = mp_locals_get(); + th_args->dict_globals = mp_globals_get(); + + // set the stack size to use + th_args->stack_size = thread_stack_size; + + // set the function for thread entry + th_args->fun = args[0]; + + // spawn the thread! + mp_thread_create(thread_entry, th_args, &th_args->stack_size); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread); + +STATIC mp_obj_t mod_thread_exit(void) { + nlr_raise(mp_obj_new_exception(&mp_type_SystemExit)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit); + +STATIC mp_obj_t mod_thread_allocate_lock(void) { + return MP_OBJ_FROM_PTR(mp_obj_new_thread_lock()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock); + +STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__thread) }, + { MP_ROM_QSTR(MP_QSTR_LockType), MP_ROM_PTR(&mp_type_thread_lock) }, + { MP_ROM_QSTR(MP_QSTR_get_ident), MP_ROM_PTR(&mod_thread_get_ident_obj) }, + { MP_ROM_QSTR(MP_QSTR_stack_size), MP_ROM_PTR(&mod_thread_stack_size_obj) }, + { MP_ROM_QSTR(MP_QSTR_start_new_thread), MP_ROM_PTR(&mod_thread_start_new_thread_obj) }, + { MP_ROM_QSTR(MP_QSTR_exit), MP_ROM_PTR(&mod_thread_exit_obj) }, + { MP_ROM_QSTR(MP_QSTR_allocate_lock), MP_ROM_PTR(&mod_thread_allocate_lock_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table); + +const mp_obj_module_t mp_module_thread = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_thread_globals, +}; + +#endif // MICROPY_PY_THREAD diff --git a/user/mpy/py/moduerrno.c b/user/mpy/py/moduerrno.c new file mode 100644 index 0000000..de66c94 --- /dev/null +++ b/user/mpy/py/moduerrno.c @@ -0,0 +1,122 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include +#include + +#include "py/obj.h" +#include "py/mperrno.h" + +#if MICROPY_PY_UERRNO + +// This list can be defined per port in mpconfigport.h to tailor it to a +// specific port's needs. If it's not defined then we provide a default. +#ifndef MICROPY_PY_UERRNO_LIST +#define MICROPY_PY_UERRNO_LIST \ + X(EPERM) \ + X(ENOENT) \ + X(EIO) \ + X(EBADF) \ + X(EAGAIN) \ + X(ENOMEM) \ + X(EACCES) \ + X(EEXIST) \ + X(ENODEV) \ + X(EISDIR) \ + X(EINVAL) \ + X(EOPNOTSUPP) \ + X(EADDRINUSE) \ + X(ECONNABORTED) \ + X(ECONNRESET) \ + X(ENOBUFS) \ + X(ENOTCONN) \ + X(ETIMEDOUT) \ + X(ECONNREFUSED) \ + X(EHOSTUNREACH) \ + X(EALREADY) \ + X(EINPROGRESS) \ + +#endif + +#if MICROPY_PY_UERRNO_ERRORCODE +STATIC const mp_rom_map_elem_t errorcode_table[] = { + #define X(e) { MP_ROM_INT(MP_ ## e), MP_ROM_QSTR(MP_QSTR_## e) }, + MICROPY_PY_UERRNO_LIST + #undef X +}; + +STATIC const mp_obj_dict_t errorcode_dict = { + .base = {&mp_type_dict}, + .map = { + .all_keys_are_qstrs = 0, // keys are integers + .is_fixed = 1, + .is_ordered = 1, + .used = MP_ARRAY_SIZE(errorcode_table), + .alloc = MP_ARRAY_SIZE(errorcode_table), + .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)errorcode_table, + }, +}; +#endif + +STATIC const mp_rom_map_elem_t mp_module_uerrno_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uerrno) }, + #if MICROPY_PY_UERRNO_ERRORCODE + { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) }, + #endif + + #define X(e) { MP_ROM_QSTR(MP_QSTR_## e), MP_ROM_INT(MP_ ## e) }, + MICROPY_PY_UERRNO_LIST + #undef X +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_uerrno_globals, mp_module_uerrno_globals_table); + +const mp_obj_module_t mp_module_uerrno = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_uerrno_globals, +}; + +qstr mp_errno_to_str(mp_obj_t errno_val) { + #if MICROPY_PY_UERRNO_ERRORCODE + // We have the errorcode dict so can do a lookup using the hash map + mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&errorcode_dict.map, errno_val, MP_MAP_LOOKUP); + if (elem == NULL) { + return MP_QSTR_NULL; + } else { + return MP_OBJ_QSTR_VALUE(elem->value); + } + #else + // We don't have the errorcode dict so do a simple search in the modules dict + for (size_t i = 0; i < MP_ARRAY_SIZE(mp_module_uerrno_globals_table); ++i) { + if (errno_val == mp_module_uerrno_globals_table[i].value) { + return MP_OBJ_QSTR_VALUE(mp_module_uerrno_globals_table[i].key); + } + } + return MP_QSTR_NULL; + #endif +} + +#endif //MICROPY_PY_UERRNO diff --git a/user/mpy/py/mpconfig.h b/user/mpy/py/mpconfig.h new file mode 100644 index 0000000..dac8a90 --- /dev/null +++ b/user/mpy/py/mpconfig.h @@ -0,0 +1,1266 @@ +/* + * 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 + +// 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=""' +// 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 +#include MP_CONFIGFILE +#else +#include +#endif + +// 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...xx10 : a qstr, bits 2 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...xx11 : a qstr, bits 2 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 qqqqq110 str with 20-bit qstr 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 and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000. +// This makes strs 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 00000000 00000000 iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int +// - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str +// - 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 + +/*****************************************************************************/ +/* 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 * BYTES_PER_WORD) +#endif + +// 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 + +// 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 + +// Support automatic GC when reaching allocation threshold, +// configurable by gc.threshold(). +#ifndef MICROPY_GC_ALLOC_THRESHOLD +#define MICROPY_GC_ALLOC_THRESHOLD (1) +#endif + +// 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 + +// Initial amount for lexer indentation level +#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT +#define MICROPY_ALLOC_LEXER_INDENT_INIT (10) +#endif + +// Increment for lexer indentation level +#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC +#define MICROPY_ALLOC_LEXEL_INDENT_INC (8) +#endif + +// Initial amount for parse rule stack +#ifndef MICROPY_ALLOC_PARSE_RULE_INIT +#define MICROPY_ALLOC_PARSE_RULE_INIT (64) +#endif + +// Increment for parse rule stack +#ifndef MICROPY_ALLOC_PARSE_RULE_INC +#define MICROPY_ALLOC_PARSE_RULE_INC (16) +#endif + +// Initial amount for parse result stack +#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT +#define MICROPY_ALLOC_PARSE_RESULT_INIT (32) +#endif + +// Increment for parse result stack +#ifndef MICROPY_ALLOC_PARSE_RESULT_INC +#define MICROPY_ALLOC_PARSE_RESULT_INC (16) +#endif + +// 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 + +// 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 + +// Initial amount for ids in a scope +#ifndef MICROPY_ALLOC_SCOPE_ID_INIT +#define MICROPY_ALLOC_SCOPE_ID_INIT (4) +#endif + +// Increment for ids in a scope +#ifndef MICROPY_ALLOC_SCOPE_ID_INC +#define MICROPY_ALLOC_SCOPE_ID_INC (6) +#endif + +// 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 + +// Initial size of module dict +#ifndef MICROPY_MODULE_DICT_SIZE +#define MICROPY_MODULE_DICT_SIZE (1) +#endif + +// 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 + +// 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 + +// Number of bytes used to store qstr hash +#ifndef MICROPY_QSTR_BYTES_IN_HASH +#define MICROPY_QSTR_BYTES_IN_HASH (2) +#endif + +// 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 + +// 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 + +// 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 defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA +#undef alloca +#define alloca(x) m_malloc(x) +#endif + +/*****************************************************************************/ +/* MicroPython emitters */ + +// Whether to support loading of persistent code +#ifndef MICROPY_PERSISTENT_CODE_LOAD +#define MICROPY_PERSISTENT_CODE_LOAD (0) +#endif + +// Whether to support saving of persistent code +#ifndef MICROPY_PERSISTENT_CODE_SAVE +#define MICROPY_PERSISTENT_CODE_SAVE (0) +#endif + +// 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 + +// Whether to emit x64 native code +#ifndef MICROPY_EMIT_X64 +#define MICROPY_EMIT_X64 (0) +#endif + +// Whether to emit x86 native code +#ifndef MICROPY_EMIT_X86 +#define MICROPY_EMIT_X86 (0) +#endif + +// Whether to emit thumb native code +#ifndef MICROPY_EMIT_THUMB +#define MICROPY_EMIT_THUMB (0) +#endif + +// Whether to enable the thumb inline assembler +#ifndef MICROPY_EMIT_INLINE_THUMB +#define MICROPY_EMIT_INLINE_THUMB (0) +#endif + +// 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 + +// Whether to enable float support in the Thumb2 inline assembler +#ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT +#define MICROPY_EMIT_INLINE_THUMB_FLOAT (1) +#endif + +// Whether to emit ARM native code +#ifndef MICROPY_EMIT_ARM +#define MICROPY_EMIT_ARM (0) +#endif + +// Whether to emit Xtensa native code +#ifndef MICROPY_EMIT_XTENSA +#define MICROPY_EMIT_XTENSA (0) +#endif + +// Whether to enable the Xtensa inline assembler +#ifndef MICROPY_EMIT_INLINE_XTENSA +#define MICROPY_EMIT_INLINE_XTENSA (0) +#endif + +// 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) + +// Convenience definition for whether any inline assembler emitter is enabled +#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA) + +/*****************************************************************************/ +/* Compiler configuration */ + +// Whether to include the compiler +#ifndef MICROPY_ENABLE_COMPILER +#define MICROPY_ENABLE_COMPILER (1) +#endif + +// Whether the compiler is dynamically configurable (ie at runtime) +#ifndef MICROPY_DYNAMIC_COMPILER +#define MICROPY_DYNAMIC_COMPILER (0) +#endif + +// Configure dynamic compiler macros +#if MICROPY_DYNAMIC_COMPILER +#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode) +#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode) +#else +#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE +#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE +#endif + +// Whether to enable constant folding; eg 1+2 rewritten as 3 +#ifndef MICROPY_COMP_CONST_FOLDING +#define MICROPY_COMP_CONST_FOLDING (1) +#endif + +// Whether to enable lookup of constants in modules; eg module.CONST +#ifndef MICROPY_COMP_MODULE_CONST +#define MICROPY_COMP_MODULE_CONST (0) +#endif + +// Whether to enable constant optimisation; id = const(value) +#ifndef MICROPY_COMP_CONST +#define MICROPY_COMP_CONST (1) +#endif + +// 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 (1) +#endif + +// Whether to enable optimisation of: a, b, c = d, e, f +// Cost 156 bytes (Thumb2) +#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN +#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0) +#endif + +// 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 + +/*****************************************************************************/ +/* Internal debugging stuff */ + +// Whether to collect memory allocation stats +#ifndef MICROPY_MEM_STATS +#define MICROPY_MEM_STATS (0) +#endif + +// 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 + +// Whether to enable all debugging outputs (it will be extremely verbose) +#ifndef MICROPY_DEBUG_VERBOSE +#define MICROPY_DEBUG_VERBOSE (0) +#endif + +/*****************************************************************************/ +/* 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 +#ifndef MICROPY_OPT_COMPUTED_GOTO +#define MICROPY_OPT_COMPUTED_GOTO (0) +#endif + +// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR, +// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and +// uses a bit of extra code ROM, but greatly improves lookup speed. +#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE +#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) +#endif + +// 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 + +/*****************************************************************************/ +/* Python internal features */ + +// Whether to use the POSIX reader for importing files +#ifndef MICROPY_READER_POSIX +#define MICROPY_READER_POSIX (0) +#endif + +// Whether to use the VFS reader for importing files +#ifndef MICROPY_READER_VFS +#define MICROPY_READER_VFS (0) +#endif + +// 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 + +// Hook for the VM during the opcode loop (but only after jump opcodes) +#ifndef MICROPY_VM_HOOK_LOOP +#define MICROPY_VM_HOOK_LOOP +#endif + +// Hook for the VM just before return opcode is finished being interpreted +#ifndef MICROPY_VM_HOOK_RETURN +#define MICROPY_VM_HOOK_RETURN +#endif + +// Whether to include the garbage collector +#ifndef MICROPY_ENABLE_GC +#define MICROPY_ENABLE_GC (0) +#endif + +// Whether to enable finalisers in the garbage collector (ie call __del__) +#ifndef MICROPY_ENABLE_FINALISER +#define MICROPY_ENABLE_FINALISER (0) +#endif + +// 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 + +// Whether to have an emergency exception buffer +#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF +#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0) +#endif +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF +# ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE +# define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation +# endif +#endif + +// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function +#ifndef MICROPY_KBD_EXCEPTION +#define MICROPY_KBD_EXCEPTION (0) +#endif + +// 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 + +// Whether to include REPL helper function +#ifndef MICROPY_HELPER_REPL +#define MICROPY_HELPER_REPL (0) +#endif + +// Whether to include emacs-style readline behavior in REPL +#ifndef MICROPY_REPL_EMACS_KEYS +#define MICROPY_REPL_EMACS_KEYS (0) +#endif + +// Whether to implement auto-indent in REPL +#ifndef MICROPY_REPL_AUTO_INDENT +#define MICROPY_REPL_AUTO_INDENT (0) +#endif + +// Whether port requires event-driven REPL functions +#ifndef MICROPY_REPL_EVENT_DRIVEN +#define MICROPY_REPL_EVENT_DRIVEN (0) +#endif + +// Whether to include lexer helper function for unix +#ifndef MICROPY_HELPER_LEXER_UNIX +#define MICROPY_HELPER_LEXER_UNIX (0) +#endif + +// 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 + +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG +typedef long long mp_longint_impl_t; +#endif + +// 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 + +// Whether to include doc strings (increases RAM usage) +#ifndef MICROPY_ENABLE_DOC_STRING +#define MICROPY_ENABLE_DOC_STRING (0) +#endif + +// 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 +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) +#endif + +// Whether issue warnings during compiling/execution +#ifndef MICROPY_WARNINGS +#define MICROPY_WARNINGS (0) +#endif + +// 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 + +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT +#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; +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE +#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 +#define MICROPY_PY_BUILTINS_FLOAT (0) +#endif + +#ifndef MICROPY_PY_BUILTINS_COMPLEX +#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT) +#endif + +// 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 + +// 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 (1) +#endif + +// 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 (1) +#endif + +// Whether POSIX-semantics non-blocking streams are supported +#ifndef MICROPY_STREAMS_NON_BLOCK +#define MICROPY_STREAMS_NON_BLOCK (0) +#endif + +// 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 + +// Whether to call __init__ when importing builtin modules for the first time +#ifndef MICROPY_MODULE_BUILTIN_INIT +#define MICROPY_MODULE_BUILTIN_INIT (0) +#endif + +// Whether module weak links are supported +#ifndef MICROPY_MODULE_WEAK_LINKS +#define MICROPY_MODULE_WEAK_LINKS (0) +#endif + +// Whether frozen modules are supported in the form of strings +#ifndef MICROPY_MODULE_FROZEN_STR +#define MICROPY_MODULE_FROZEN_STR (0) +#endif + +// Whether frozen modules are supported in the form of .mpy files +#ifndef MICROPY_MODULE_FROZEN_MPY +#define MICROPY_MODULE_FROZEN_MPY (0) +#endif + +// 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 + +// Whether you can override builtins in the builtins module +#ifndef MICROPY_CAN_OVERRIDE_BUILTINS +#define MICROPY_CAN_OVERRIDE_BUILTINS (0) +#endif + +// 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 (1) +#endif + +// Whether to use internally defined errno's (otherwise system provided ones) +#ifndef MICROPY_USE_INTERNAL_ERRNO +#define MICROPY_USE_INTERNAL_ERRNO (0) +#endif + +// Whether to use internally defined *printf() functions (otherwise external ones) +#ifndef MICROPY_USE_INTERNAL_PRINTF +#define MICROPY_USE_INTERNAL_PRINTF (1) +#endif + +// Support for internal scheduler +#ifndef MICROPY_ENABLE_SCHEDULER +#define MICROPY_ENABLE_SCHEDULER (0) +#endif + +// Maximum number of entries in the scheduler +#ifndef MICROPY_SCHEDULER_DEPTH +#define MICROPY_SCHEDULER_DEPTH (4) +#endif + +// Support for generic VFS sub-system +#ifndef MICROPY_VFS +#define MICROPY_VFS (0) +#endif + +/*****************************************************************************/ +/* Fine control over Python builtins, classes, modules, etc */ + +// Whether to implement attributes on functions +#ifndef MICROPY_PY_FUNCTION_ATTRS +#define MICROPY_PY_FUNCTION_ATTRS (0) +#endif + +// Whether to support descriptors (__get__ and __set__) +// This costs some code size and makes all load attrs and store attrs slow +#ifndef MICROPY_PY_DESCRIPTORS +#define MICROPY_PY_DESCRIPTORS (0) +#endif + +// Whether to support class __delattr__ and __setattr__ methods +// This costs some code size and makes all del attrs and store attrs slow +#ifndef MICROPY_PY_DELATTR_SETATTR +#define MICROPY_PY_DELATTR_SETATTR (0) +#endif + +// Support for async/await/async for/async with +#ifndef MICROPY_PY_ASYNC_AWAIT +#define MICROPY_PY_ASYNC_AWAIT (1) +#endif + +// 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 + +// Whether str object is proper unicode +#ifndef MICROPY_PY_BUILTINS_STR_UNICODE +#define MICROPY_PY_BUILTINS_STR_UNICODE (0) +#endif + +// Whether str.center() method provided +#ifndef MICROPY_PY_BUILTINS_STR_CENTER +#define MICROPY_PY_BUILTINS_STR_CENTER (0) +#endif + +// Whether str.partition()/str.rpartition() method provided +#ifndef MICROPY_PY_BUILTINS_STR_PARTITION +#define MICROPY_PY_BUILTINS_STR_PARTITION (0) +#endif + +// Whether str.splitlines() method provided +#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES +#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0) +#endif + +// Whether to support bytearray object +#ifndef MICROPY_PY_BUILTINS_BYTEARRAY +#define MICROPY_PY_BUILTINS_BYTEARRAY (1) +#endif + +// Whether to support memoryview object +#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW +#define MICROPY_PY_BUILTINS_MEMORYVIEW (0) +#endif + +// Whether to support set object +#ifndef MICROPY_PY_BUILTINS_SET +#define MICROPY_PY_BUILTINS_SET (1) +#endif + +// Whether to support slice subscript operators and slice object +#ifndef MICROPY_PY_BUILTINS_SLICE +#define MICROPY_PY_BUILTINS_SLICE (1) +#endif + +// 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 + +// Whether to support frozenset object +#ifndef MICROPY_PY_BUILTINS_FROZENSET +#define MICROPY_PY_BUILTINS_FROZENSET (0) +#endif + +// Whether to support property object +#ifndef MICROPY_PY_BUILTINS_PROPERTY +#define MICROPY_PY_BUILTINS_PROPERTY (1) +#endif + +// 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 (1) +#endif + +// Whether to support timeout exceptions (like socket.timeout) +#ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR +#define MICROPY_PY_BUILTINS_TIMEOUTERROR (0) +#endif + +// Whether to support complete set of special methods +// for user classes, otherwise only the most used +#ifndef MICROPY_PY_ALL_SPECIAL_METHODS +#define MICROPY_PY_ALL_SPECIAL_METHODS (0) +#endif + +// Whether to support compile function +#ifndef MICROPY_PY_BUILTINS_COMPILE +#define MICROPY_PY_BUILTINS_COMPILE (0) +#endif + +// Whether to support enumerate function(type) +#ifndef MICROPY_PY_BUILTINS_ENUMERATE +#define MICROPY_PY_BUILTINS_ENUMERATE (1) +#endif + +// 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 + +// Whether to support the Python 2 execfile function +#ifndef MICROPY_PY_BUILTINS_EXECFILE +#define MICROPY_PY_BUILTINS_EXECFILE (0) +#endif + +// Whether to support filter function(type) +#ifndef MICROPY_PY_BUILTINS_FILTER +#define MICROPY_PY_BUILTINS_FILTER (1) +#endif + +// Whether to support reversed function(type) +#ifndef MICROPY_PY_BUILTINS_REVERSED +#define MICROPY_PY_BUILTINS_REVERSED (1) +#endif + +// Whether to define "NotImplemented" special constant +#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) +#endif + +// Whether to provide the built-in input() function. The implementation of this +// uses mp-readline, so can only be enabled if the port uses this readline. +#ifndef MICROPY_PY_BUILTINS_INPUT +#define MICROPY_PY_BUILTINS_INPUT (0) +#endif + +// Whether to support min/max functions +#ifndef MICROPY_PY_BUILTINS_MIN_MAX +#define MICROPY_PY_BUILTINS_MIN_MAX (1) +#endif + +// Support for calls to pow() with 3 integer arguments +#ifndef MICROPY_PY_BUILTINS_POW3 +#define MICROPY_PY_BUILTINS_POW3 (0) +#endif + +// Whether to provide the help function +#ifndef MICROPY_PY_BUILTINS_HELP +#define MICROPY_PY_BUILTINS_HELP (0) +#endif + +// 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 + +// 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 + +// Whether to set __file__ for imported modules +#ifndef MICROPY_PY___FILE__ +#define MICROPY_PY___FILE__ (1) +#endif + +// Whether to provide mem-info related functions in micropython module +#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO +#define MICROPY_PY_MICROPYTHON_MEM_INFO (0) +#endif + +// 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 (1) +#endif + +// 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 + +// Whether to support attrtuple type (MicroPython extension) +// It provides space-efficient tuples with attribute access +#ifndef MICROPY_PY_ATTRTUPLE +#define MICROPY_PY_ATTRTUPLE (1) +#endif + +// Whether to provide "collections" module +#ifndef MICROPY_PY_COLLECTIONS +#define MICROPY_PY_COLLECTIONS (1) +#endif + +// Whether to provide "collections.OrderedDict" type +#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) +#endif + +// Whether to provide "math" module +#ifndef MICROPY_PY_MATH +#define MICROPY_PY_MATH (1) +#endif + +// 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 + +// Whether to provide "cmath" module +#ifndef MICROPY_PY_CMATH +#define MICROPY_PY_CMATH (0) +#endif + +// Whether to provide "gc" module +#ifndef MICROPY_PY_GC +#define MICROPY_PY_GC (1) +#endif + +// Whether to return number of collected objects from gc.collect() +#ifndef MICROPY_PY_GC_COLLECT_RETVAL +#define MICROPY_PY_GC_COLLECT_RETVAL (0) +#endif + +// Whether to provide "io" module +#ifndef MICROPY_PY_IO +#define MICROPY_PY_IO (1) +#endif + +// Whether to provide "uio.resource_stream()" function with +// the semantics of CPython's pkg_resources.resource_stream() +// (allows to access resources in frozen packages). +#ifndef MICROPY_PY_IO_RESOURCE_STREAM +#define MICROPY_PY_IO_RESOURCE_STREAM (0) +#endif + +// Whether to provide "io.FileIO" class +#ifndef MICROPY_PY_IO_FILEIO +#define MICROPY_PY_IO_FILEIO (0) +#endif + +// Whether to provide "io.BytesIO" class +#ifndef MICROPY_PY_IO_BYTESIO +#define MICROPY_PY_IO_BYTESIO (1) +#endif + +// Whether to provide "io.BufferedWriter" class +#ifndef MICROPY_PY_IO_BUFFEREDWRITER +#define MICROPY_PY_IO_BUFFEREDWRITER (0) +#endif + +// Whether to provide "struct" module +#ifndef MICROPY_PY_STRUCT +#define MICROPY_PY_STRUCT (1) +#endif + +// Whether to provide "sys" module +#ifndef MICROPY_PY_SYS +#define MICROPY_PY_SYS (1) +#endif + +// Whether to provide "sys.maxsize" constant +#ifndef MICROPY_PY_SYS_MAXSIZE +#define MICROPY_PY_SYS_MAXSIZE (0) +#endif + +// Whether to provide "sys.modules" dictionary +#ifndef MICROPY_PY_SYS_MODULES +#define MICROPY_PY_SYS_MODULES (1) +#endif + +// 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 + +// Whether to provide "sys.exit" function +#ifndef MICROPY_PY_SYS_EXIT +#define MICROPY_PY_SYS_EXIT (1) +#endif + +// Whether to provide "sys.getsizeof" function +#ifndef MICROPY_PY_SYS_GETSIZEOF +#define MICROPY_PY_SYS_GETSIZEOF (0) +#endif + +// Whether to provide sys.{stdin,stdout,stderr} objects +#ifndef MICROPY_PY_SYS_STDFILES +#define MICROPY_PY_SYS_STDFILES (0) +#endif + +// 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 + +// Whether to provide "uerrno" module +#ifndef MICROPY_PY_UERRNO +#define MICROPY_PY_UERRNO (0) +#endif + +// Whether to provide the uerrno.errorcode dict +#ifndef MICROPY_PY_UERRNO_ERRORCODE +#define MICROPY_PY_UERRNO_ERRORCODE (1) +#endif + +// Whether to provide "uselect" module (baremetal implementation) +#ifndef MICROPY_PY_USELECT +#define MICROPY_PY_USELECT (0) +#endif + +// 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 + +// 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 + +// Whether to provide "_thread" module +#ifndef MICROPY_PY_THREAD +#define MICROPY_PY_THREAD (0) +#endif + +// 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 + +// 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 + +// Extended modules + +#ifndef MICROPY_PY_UCTYPES +#define MICROPY_PY_UCTYPES (0) +#endif + +#ifndef MICROPY_PY_UZLIB +#define MICROPY_PY_UZLIB (0) +#endif + +#ifndef MICROPY_PY_UJSON +#define MICROPY_PY_UJSON (0) +#endif + +#ifndef MICROPY_PY_URE +#define MICROPY_PY_URE (0) +#endif + +#ifndef MICROPY_PY_UHEAPQ +#define MICROPY_PY_UHEAPQ (0) +#endif + +// Optimized heap queue for relative timestamps +#ifndef MICROPY_PY_UTIMEQ +#define MICROPY_PY_UTIMEQ (0) +#endif + +#ifndef MICROPY_PY_UHASHLIB +#define MICROPY_PY_UHASHLIB (0) +#endif + +#ifndef MICROPY_PY_UBINASCII +#define MICROPY_PY_UBINASCII (0) +#endif + +// Depends on MICROPY_PY_UZLIB +#ifndef MICROPY_PY_UBINASCII_CRC32 +#define MICROPY_PY_UBINASCII_CRC32 (0) +#endif + +#ifndef MICROPY_PY_URANDOM +#define MICROPY_PY_URANDOM (0) +#endif + +// Whether to include: randrange, randint, choice, random, uniform +#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS +#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) +#endif + +#ifndef MICROPY_PY_MACHINE +#define MICROPY_PY_MACHINE (0) +#endif + +// Whether to include: time_pulse_us +#ifndef MICROPY_PY_MACHINE_PULSE +#define MICROPY_PY_MACHINE_PULSE (0) +#endif + +#ifndef MICROPY_PY_MACHINE_I2C +#define MICROPY_PY_MACHINE_I2C (0) +#endif + +#ifndef MICROPY_PY_MACHINE_SPI +#define MICROPY_PY_MACHINE_SPI (0) +#endif + +#ifndef MICROPY_PY_USSL +#define MICROPY_PY_USSL (0) +#endif + +#ifndef MICROPY_PY_WEBSOCKET +#define MICROPY_PY_WEBSOCKET (0) +#endif + +#ifndef MICROPY_PY_FRAMEBUF +#define MICROPY_PY_FRAMEBUF (0) +#endif + +#ifndef MICROPY_PY_BTREE +#define MICROPY_PY_BTREE (0) +#endif + +/*****************************************************************************/ +/* Hooks for a port to add builtins */ + +// Additional builtin function definitions - see builtintables.c:builtin_object_table for format. +#ifndef MICROPY_PORT_BUILTINS +#define MICROPY_PORT_BUILTINS +#endif + +// Additional builtin module definitions - see builtintables.c:builtin_module_table for format. +#ifndef MICROPY_PORT_BUILTIN_MODULES +#define MICROPY_PORT_BUILTIN_MODULES +#endif + +// Any module weak links - see builtintables.c:mp_builtin_module_weak_links_table. +#ifndef MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS +#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS +#endif + +// Additional constant definitions for the compiler - see compile.c:mp_constants_table. +#ifndef MICROPY_PORT_CONSTANTS +#define MICROPY_PORT_CONSTANTS +#endif + +// Any root pointers for GC scanning - see mpstate.c +#ifndef MICROPY_PORT_ROOT_POINTERS +#define MICROPY_PORT_ROOT_POINTERS +#endif + +/*****************************************************************************/ +/* 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 + +// On embedded platforms, these will typically enable/disable irqs. +#ifndef MICROPY_BEGIN_ATOMIC_SECTION +#define MICROPY_BEGIN_ATOMIC_SECTION() (0) +#endif +#ifndef MICROPY_END_ATOMIC_SECTION +#define MICROPY_END_ATOMIC_SECTION(state) (void)(state) +#endif + +// 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 + +// Number of bytes in a word +#ifndef BYTES_PER_WORD +#define BYTES_PER_WORD (sizeof(mp_uint_t)) +#endif + +#define BITS_PER_BYTE (8) +#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD) +// mp_int_t value with most significant bit set +#define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1)) + +// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are +// defined and that they are the opposite of each other. +#if defined(MP_ENDIANNESS_LITTLE) +#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) +#elif defined(MP_ENDIANNESS_BIG) +#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG) +#else + // Endiannes not defined by port so try to autodetect it. + #if defined(__BYTE_ORDER__) + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define MP_ENDIANNESS_LITTLE (1) + #else + #define MP_ENDIANNESS_LITTLE (0) + #endif + #elif defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN) + #define MP_ENDIANNESS_LITTLE (1) + #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined (_BIG_ENDIAN) + #define MP_ENDIANNESS_LITTLE (0) + #else + #include + #if defined(__BYTE_ORDER) + #if __BYTE_ORDER == __LITTLE_ENDIAN + #define MP_ENDIANNESS_LITTLE (1) + #else + #define MP_ENDIANNESS_LITTLE (0) + #endif + #else + #error endianness not defined and cannot detect it + #endif + #endif + #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) +#endif + +// 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 + +// 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 + +#ifndef MP_PLAT_FREE_EXEC +#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size) +#endif + +// 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 + +#ifndef MP_SSIZE_MAX +#define MP_SSIZE_MAX SSIZE_MAX +#endif + +// printf format spec to use for mp_int_t and friends +#ifndef INT_FMT +#if defined(__LP64__) +// Archs where mp_int_t == long, long != int +#define UINT_FMT "%lu" +#define INT_FMT "%ld" +#elif defined(_WIN64) +#define UINT_FMT "%llu" +#define INT_FMT "%lld" +#else +// Archs where mp_int_t == int +#define UINT_FMT "%u" +#define INT_FMT "%d" +#endif +#endif //INT_FMT + +// Modifier for function which doesn't return +#ifndef NORETURN +#define NORETURN __attribute__((noreturn)) +#endif + +// Modifier for weak functions +#ifndef MP_WEAK +#define MP_WEAK __attribute__((weak)) +#endif + +// Modifier for functions which should be never inlined +#ifndef MP_NOINLINE +#define MP_NOINLINE __attribute__((noinline)) +#endif + +// Modifier for functions which should be always inlined +#ifndef MP_ALWAYSINLINE +#define MP_ALWAYSINLINE __attribute__((always_inline)) +#endif + +// Condition is likely to be true, to help branch prediction +#ifndef MP_LIKELY +#define MP_LIKELY(x) __builtin_expect((x), 1) +#endif + +// Condition is likely to be false, to help branch prediction +#ifndef MP_UNLIKELY +#define MP_UNLIKELY(x) __builtin_expect((x), 0) +#endif + +#endif // MICROPY_INCLUDED_PY_MPCONFIG_H diff --git a/user/mpy/py/mperrno.h b/user/mpy/py/mperrno.h new file mode 100644 index 0000000..f439f65 --- /dev/null +++ b/user/mpy/py/mperrno.h @@ -0,0 +1,150 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_MPERRNO_H +#define MICROPY_INCLUDED_PY_MPERRNO_H + +#include "py/mpconfig.h" + +#if MICROPY_USE_INTERNAL_ERRNO + +// MP_Exxx errno's are defined directly as numeric values +// (Linux constants are used as a reference) + +#define MP_EPERM (1) // Operation not permitted +#define MP_ENOENT (2) // No such file or directory +#define MP_ESRCH (3) // No such process +#define MP_EINTR (4) // Interrupted system call +#define MP_EIO (5) // I/O error +#define MP_ENXIO (6) // No such device or address +#define MP_E2BIG (7) // Argument list too long +#define MP_ENOEXEC (8) // Exec format error +#define MP_EBADF (9) // Bad file number +#define MP_ECHILD (10) // No child processes +#define MP_EAGAIN (11) // Try again +#define MP_ENOMEM (12) // Out of memory +#define MP_EACCES (13) // Permission denied +#define MP_EFAULT (14) // Bad address +#define MP_ENOTBLK (15) // Block device required +#define MP_EBUSY (16) // Device or resource busy +#define MP_EEXIST (17) // File exists +#define MP_EXDEV (18) // Cross-device link +#define MP_ENODEV (19) // No such device +#define MP_ENOTDIR (20) // Not a directory +#define MP_EISDIR (21) // Is a directory +#define MP_EINVAL (22) // Invalid argument +#define MP_ENFILE (23) // File table overflow +#define MP_EMFILE (24) // Too many open files +#define MP_ENOTTY (25) // Not a typewriter +#define MP_ETXTBSY (26) // Text file busy +#define MP_EFBIG (27) // File too large +#define MP_ENOSPC (28) // No space left on device +#define MP_ESPIPE (29) // Illegal seek +#define MP_EROFS (30) // Read-only file system +#define MP_EMLINK (31) // Too many links +#define MP_EPIPE (32) // Broken pipe +#define MP_EDOM (33) // Math argument out of domain of func +#define MP_ERANGE (34) // Math result not representable +#define MP_EWOULDBLOCK MP_EAGAIN // Operation would block +#define MP_EOPNOTSUPP (95) // Operation not supported on transport endpoint +#define MP_EAFNOSUPPORT (97) // Address family not supported by protocol +#define MP_EADDRINUSE (98) // Address already in use +#define MP_ECONNABORTED (103) // Software caused connection abort +#define MP_ECONNRESET (104) // Connection reset by peer +#define MP_ENOBUFS (105) // No buffer space available +#define MP_EISCONN (106) // Transport endpoint is already connected +#define MP_ENOTCONN (107) // Transport endpoint is not connected +#define MP_ETIMEDOUT (110) // Connection timed out +#define MP_ECONNREFUSED (111) // Connection refused +#define MP_EHOSTUNREACH (113) // No route to host +#define MP_EALREADY (114) // Operation already in progress +#define MP_EINPROGRESS (115) // Operation now in progress + +#else + +// MP_Exxx errno's are defined in terms of system supplied ones + +#include + +#define MP_EPERM EPERM +#define MP_ENOENT ENOENT +#define MP_ESRCH ESRCH +#define MP_EINTR EINTR +#define MP_EIO EIO +#define MP_ENXIO ENXIO +#define MP_E2BIG E2BIG +#define MP_ENOEXEC ENOEXEC +#define MP_EBADF EBADF +#define MP_ECHILD ECHILD +#define MP_EAGAIN EAGAIN +#define MP_ENOMEM ENOMEM +#define MP_EACCES EACCES +#define MP_EFAULT EFAULT +#define MP_ENOTBLK ENOTBLK +#define MP_EBUSY EBUSY +#define MP_EEXIST EEXIST +#define MP_EXDEV EXDEV +#define MP_ENODEV ENODEV +#define MP_ENOTDIR ENOTDIR +#define MP_EISDIR EISDIR +#define MP_EINVAL EINVAL +#define MP_ENFILE ENFILE +#define MP_EMFILE EMFILE +#define MP_ENOTTY ENOTTY +#define MP_ETXTBSY ETXTBSY +#define MP_EFBIG EFBIG +#define MP_ENOSPC ENOSPC +#define MP_ESPIPE ESPIPE +#define MP_EROFS EROFS +#define MP_EMLINK EMLINK +#define MP_EPIPE EPIPE +#define MP_EDOM EDOM +#define MP_ERANGE ERANGE +#define MP_EWOULDBLOCK EAGAIN +#define MP_EOPNOTSUPP EOPNOTSUPP +#define MP_EAFNOSUPPORT EAFNOSUPPORT +#define MP_EADDRINUSE EADDRINUSE +#define MP_ECONNABORTED ECONNABORTED +#define MP_ECONNRESET ECONNRESET +#define MP_ENOBUFS ENOBUFS +#define MP_EISCONN EISCONN +#define MP_ENOTCONN ENOTCONN +#define MP_ETIMEDOUT ETIMEDOUT +#define MP_ECONNREFUSED ECONNREFUSED +#define MP_EHOSTUNREACH EHOSTUNREACH +#define MP_EALREADY EALREADY +#define MP_EINPROGRESS EINPROGRESS + +#endif + +#if MICROPY_PY_UERRNO + +#include "py/obj.h" + +qstr mp_errno_to_str(mp_obj_t errno_val); + +#endif + +#endif // MICROPY_INCLUDED_PY_MPERRNO_H diff --git a/user/mpy/py/mphal.h b/user/mpy/py/mphal.h new file mode 100644 index 0000000..92de01d --- /dev/null +++ b/user/mpy/py/mphal.h @@ -0,0 +1,83 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 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_MPHAL_H +#define MICROPY_INCLUDED_PY_MPHAL_H + +#include "py/mpconfig.h" + +#ifdef MICROPY_MPHALPORT_H +#include MICROPY_MPHALPORT_H +#else +#include +#endif + +#ifndef mp_hal_stdin_rx_chr +int mp_hal_stdin_rx_chr(void); +#endif + +#ifndef mp_hal_stdout_tx_str +void mp_hal_stdout_tx_str(const char *str); +#endif + +#ifndef mp_hal_stdout_tx_strn +void mp_hal_stdout_tx_strn(const char *str, size_t len); +#endif + +#ifndef mp_hal_stdout_tx_strn_cooked +void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len); +#endif + +#ifndef mp_hal_delay_ms +void mp_hal_delay_ms(mp_uint_t ms); +#endif + +#ifndef mp_hal_delay_us +void mp_hal_delay_us(mp_uint_t us); +#endif + +#ifndef mp_hal_ticks_ms +mp_uint_t mp_hal_ticks_ms(void); +#endif + +#ifndef mp_hal_ticks_us +mp_uint_t mp_hal_ticks_us(void); +#endif + +#ifndef mp_hal_ticks_cpu +mp_uint_t mp_hal_ticks_cpu(void); +#endif + +// If port HAL didn't define its own pin API, use generic +// "virtual pin" API from the core. +#ifndef mp_hal_pin_obj_t +#define mp_hal_pin_obj_t mp_obj_t +#define mp_hal_get_pin_obj(pin) (pin) +#define mp_hal_pin_read(pin) mp_virtual_pin_read(pin) +#define mp_hal_pin_write(pin, v) mp_virtual_pin_write(pin, v) +#include "extmod/virtpin.h" +#endif + +#endif // MICROPY_INCLUDED_PY_MPHAL_H diff --git a/user/mpy/py/mpprint.c b/user/mpy/py/mpprint.c new file mode 100644 index 0000000..6c02d7c --- /dev/null +++ b/user/mpy/py/mpprint.c @@ -0,0 +1,555 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2015 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. + */ + +#include +#include +#include +#include +#include + +#include "py/mphal.h" +#include "py/mpprint.h" +#include "py/obj.h" +#include "py/objint.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include "py/formatfloat.h" +#endif + +static const char pad_spaces[] = " "; +static const char pad_zeroes[] = "0000000000000000"; + +STATIC void plat_print_strn(void *env, const char *str, size_t len) { + (void)env; + MP_PLAT_PRINT_STRN(str, len); +} + +const mp_print_t mp_plat_print = {NULL, plat_print_strn}; + +int mp_print_str(const mp_print_t *print, const char *str) { + size_t len = strlen(str); + if (len) { + print->print_strn(print->data, str, len); + } + return len; +} + +int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) { + int left_pad = 0; + int right_pad = 0; + int pad = width - len; + int pad_size; + int total_chars_printed = 0; + const char *pad_chars; + + if (!fill || fill == ' ') { + pad_chars = pad_spaces; + pad_size = sizeof(pad_spaces) - 1; + } else if (fill == '0') { + pad_chars = pad_zeroes; + pad_size = sizeof(pad_zeroes) - 1; + } else { + // Other pad characters are fairly unusual, so we'll take the hit + // and output them 1 at a time. + pad_chars = &fill; + pad_size = 1; + } + + if (flags & PF_FLAG_CENTER_ADJUST) { + left_pad = pad / 2; + right_pad = pad - left_pad; + } else if (flags & PF_FLAG_LEFT_ADJUST) { + right_pad = pad; + } else { + left_pad = pad; + } + + if (left_pad > 0) { + total_chars_printed += left_pad; + while (left_pad > 0) { + int p = left_pad; + if (p > pad_size) { + p = pad_size; + } + print->print_strn(print->data, pad_chars, p); + left_pad -= p; + } + } + if (len) { + print->print_strn(print->data, str, len); + total_chars_printed += len; + } + if (right_pad > 0) { + total_chars_printed += right_pad; + while (right_pad > 0) { + int p = right_pad; + if (p > pad_size) { + p = pad_size; + } + print->print_strn(print->data, pad_chars, p); + right_pad -= p; + } + } + return total_chars_printed; +} + +// 32-bits is 10 digits, add 3 for commas, 1 for sign, 1 for terminating null +// We can use 16 characters for 32-bit and 32 characters for 64-bit +#define INT_BUF_SIZE (sizeof(mp_int_t) * 4) + +// Our mp_vprintf function below does not support the '#' format modifier to +// print the prefix of a non-base-10 number, so we don't need code for this. +#define SUPPORT_INT_BASE_PREFIX (0) + +// This function is used exclusively by mp_vprintf to format ints. +// It needs to be a separate function to mp_print_mp_int, since converting to a mp_int looses the MSB. +STATIC int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) { + char sign = 0; + if (sgn) { + if ((mp_int_t)x < 0) { + sign = '-'; + x = -x; + } else if (flags & PF_FLAG_SHOW_SIGN) { + sign = '+'; + } else if (flags & PF_FLAG_SPACE_SIGN) { + sign = ' '; + } + } + + char buf[INT_BUF_SIZE]; + char *b = buf + INT_BUF_SIZE; + + if (x == 0) { + *(--b) = '0'; + } else { + do { + int c = x % base; + x /= base; + if (c >= 10) { + c += base_char - 10; + } else { + c += '0'; + } + *(--b) = c; + } while (b > buf && x != 0); + } + + #if SUPPORT_INT_BASE_PREFIX + char prefix_char = '\0'; + + if (flags & PF_FLAG_SHOW_PREFIX) { + if (base == 2) { + prefix_char = base_char + 'b' - 'a'; + } else if (base == 8) { + prefix_char = base_char + 'o' - 'a'; + } else if (base == 16) { + prefix_char = base_char + 'x' - 'a'; + } + } + #endif + + int len = 0; + if (flags & PF_FLAG_PAD_AFTER_SIGN) { + if (sign) { + len += mp_print_strn(print, &sign, 1, flags, fill, 1); + width--; + } + #if SUPPORT_INT_BASE_PREFIX + if (prefix_char) { + len += mp_print_strn(print, "0", 1, flags, fill, 1); + len += mp_print_strn(print, &prefix_char, 1, flags, fill, 1); + width -= 2; + } + #endif + } else { + #if SUPPORT_INT_BASE_PREFIX + if (prefix_char && b > &buf[1]) { + *(--b) = prefix_char; + *(--b) = '0'; + } + #endif + if (sign && b > buf) { + *(--b) = sign; + } + } + + len += mp_print_strn(print, b, buf + INT_BUF_SIZE - b, flags, fill, width); + return len; +} + +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) { + // These are the only values for "base" that are required to be supported by this + // function, since Python only allows the user to format integers in these bases. + // If needed this function could be generalised to handle other values. + assert(base == 2 || base == 8 || base == 10 || base == 16); + + if (!MP_OBJ_IS_INT(x)) { + // This will convert booleans to int, or raise an error for + // non-integer types. + x = MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(x)); + } + + if ((flags & (PF_FLAG_LEFT_ADJUST | PF_FLAG_CENTER_ADJUST)) == 0 && fill == '0') { + if (prec > width) { + width = prec; + } + prec = 0; + } + char prefix_buf[4]; + char *prefix = prefix_buf; + + if (mp_obj_int_sign(x) >= 0) { + if (flags & PF_FLAG_SHOW_SIGN) { + *prefix++ = '+'; + } else if (flags & PF_FLAG_SPACE_SIGN) { + *prefix++ = ' '; + } + } + + if (flags & PF_FLAG_SHOW_PREFIX) { + if (base == 2) { + *prefix++ = '0'; + *prefix++ = base_char + 'b' - 'a'; + } else if (base == 8) { + *prefix++ = '0'; + if (flags & PF_FLAG_SHOW_OCTAL_LETTER) { + *prefix++ = base_char + 'o' - 'a'; + } + } else if (base == 16) { + *prefix++ = '0'; + *prefix++ = base_char + 'x' - 'a'; + } + } + *prefix = '\0'; + int prefix_len = prefix - prefix_buf; + prefix = prefix_buf; + + char comma = '\0'; + if (flags & PF_FLAG_SHOW_COMMA) { + comma = ','; + } + + // The size of this buffer is rather arbitrary. If it's not large + // enough, a dynamic one will be allocated. + char stack_buf[sizeof(mp_int_t) * 4]; + char *buf = stack_buf; + size_t buf_size = sizeof(stack_buf); + size_t fmt_size = 0; + char *str; + + if (prec > 1) { + flags |= PF_FLAG_PAD_AFTER_SIGN; + } + char sign = '\0'; + if (flags & PF_FLAG_PAD_AFTER_SIGN) { + // We add the pad in this function, so since the pad goes after + // the sign & prefix, we format without a prefix + str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, + x, base, NULL, base_char, comma); + if (*str == '-') { + sign = *str++; + fmt_size--; + } + } else { + str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, + x, base, prefix, base_char, comma); + } + + int spaces_before = 0; + int spaces_after = 0; + + if (prec > 1) { + // If prec was specified, then prec specifies the width to zero-pad the + // the number to. This zero-padded number then gets left or right + // aligned in width characters. + + int prec_width = fmt_size; // The digits + if (prec_width < prec) { + prec_width = prec; + } + if (flags & PF_FLAG_PAD_AFTER_SIGN) { + if (sign) { + prec_width++; + } + prec_width += prefix_len; + } + if (prec_width < width) { + if (flags & PF_FLAG_LEFT_ADJUST) { + spaces_after = width - prec_width; + } else { + spaces_before = width - prec_width; + } + } + fill = '0'; + flags &= ~PF_FLAG_LEFT_ADJUST; + } + + int len = 0; + if (spaces_before) { + len += mp_print_strn(print, "", 0, 0, ' ', spaces_before); + } + if (flags & PF_FLAG_PAD_AFTER_SIGN) { + // pad after sign implies pad after prefix as well. + if (sign) { + len += mp_print_strn(print, &sign, 1, 0, 0, 1); + width--; + } + if (prefix_len) { + len += mp_print_strn(print, prefix, prefix_len, 0, 0, 1); + width -= prefix_len; + } + } + if (prec > 1) { + width = prec; + } + + len += mp_print_strn(print, str, fmt_size, flags, fill, width); + + if (spaces_after) { + len += mp_print_strn(print, "", 0, 0, ' ', spaces_after); + } + + if (buf != stack_buf) { + m_del(char, buf, buf_size); + } + return len; +} + +#if MICROPY_PY_BUILTINS_FLOAT +int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec) { + char buf[32]; + char sign = '\0'; + int chrs = 0; + + if (flags & PF_FLAG_SHOW_SIGN) { + sign = '+'; + } + else + if (flags & PF_FLAG_SPACE_SIGN) { + sign = ' '; + } + + int len = mp_format_float(f, buf, sizeof(buf), fmt, prec, sign); + + char *s = buf; + + if ((flags & PF_FLAG_ADD_PERCENT) && (size_t)(len + 1) < sizeof(buf)) { + buf[len++] = '%'; + buf[len] = '\0'; + } + + // buf[0] < '0' returns true if the first character is space, + or - + if ((flags & PF_FLAG_PAD_AFTER_SIGN) && buf[0] < '0') { + // We have a sign character + s++; + chrs += mp_print_strn(print, &buf[0], 1, 0, 0, 1); + width--; + len--; + } + + chrs += mp_print_strn(print, s, len, flags, fill, width); + + return chrs; +} +#endif + +int mp_printf(const mp_print_t *print, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = mp_vprintf(print, fmt, ap); + va_end(ap); + return ret; +} + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) { + int chrs = 0; + for (;;) { + { + const char *f = fmt; + while (*f != '\0' && *f != '%') { + ++f; // XXX UTF8 advance char + } + if (f > fmt) { + print->print_strn(print->data, fmt, f - fmt); + chrs += f - fmt; + fmt = f; + } + } + + if (*fmt == '\0') { + break; + } + + // move past % character + ++fmt; + + // parse flags, if they exist + int flags = 0; + char fill = ' '; + while (*fmt != '\0') { + if (*fmt == '-') flags |= PF_FLAG_LEFT_ADJUST; + else if (*fmt == '+') flags |= PF_FLAG_SHOW_SIGN; + else if (*fmt == ' ') flags |= PF_FLAG_SPACE_SIGN; + else if (*fmt == '!') flags |= PF_FLAG_NO_TRAILZ; + else if (*fmt == '0') { + flags |= PF_FLAG_PAD_AFTER_SIGN; + fill = '0'; + } else break; + ++fmt; + } + + // parse width, if it exists + int width = 0; + for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { + width = width * 10 + *fmt - '0'; + } + + // parse precision, if it exists + int prec = -1; + if (*fmt == '.') { + ++fmt; + if (*fmt == '*') { + ++fmt; + prec = va_arg(args, int); + } else { + prec = 0; + for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { + prec = prec * 10 + *fmt - '0'; + } + } + if (prec < 0) { + prec = 0; + } + } + + // parse long specifiers (current not used) + //bool long_arg = false; + if (*fmt == 'l') { + ++fmt; + //long_arg = true; + } + + if (*fmt == '\0') { + break; + } + + switch (*fmt) { + case 'b': + if (va_arg(args, int)) { + chrs += mp_print_strn(print, "true", 4, flags, fill, width); + } else { + chrs += mp_print_strn(print, "false", 5, flags, fill, width); + } + break; + case 'c': + { + char str = va_arg(args, int); + chrs += mp_print_strn(print, &str, 1, flags, fill, width); + break; + } + case 'q': + { + qstr qst = va_arg(args, qstr); + size_t len; + const char *str = (const char*)qstr_data(qst, &len); + if (prec < 0) { + prec = len; + } + chrs += mp_print_strn(print, str, prec, flags, fill, width); + break; + } + case 's': + { + const char *str = va_arg(args, const char*); + if (str) { + if (prec < 0) { + prec = strlen(str); + } + chrs += mp_print_strn(print, str, prec, flags, fill, width); + } else { + chrs += mp_print_strn(print, "(null)", 6, flags, fill, width); + } + break; + } + case 'u': + chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 10, 'a', flags, fill, width); + break; + case 'd': + chrs += mp_print_int(print, va_arg(args, int), 1, 10, 'a', flags, fill, width); + break; + case 'x': + chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 16, 'a', flags, fill, width); + break; + case 'X': + chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 16, 'A', flags, fill, width); + break; + case 'p': + case 'P': // don't bother to handle upcase for 'P' + chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 16, 'a', flags, fill, width); + break; +#if MICROPY_PY_BUILTINS_FLOAT + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + { +#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE)) + mp_float_t f = va_arg(args, double); + chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec); +#else +#error Unknown MICROPY FLOAT IMPL +#endif + break; + } +#endif + // Because 'l' is eaten above, another 'l' means %ll. We need to support + // this length specifier for OBJ_REPR_D (64-bit NaN boxing). + // TODO Either enable this unconditionally, or provide a specific config var. + #if (MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D) || defined(_WIN64) + case 'l': { + unsigned long long int arg_value = va_arg(args, unsigned long long int); + ++fmt; + if (*fmt == 'u' || *fmt == 'd') { + chrs += mp_print_int(print, arg_value, *fmt == 'd', 10, 'a', flags, fill, width); + break; + } + assert(!"unsupported fmt char"); + } + #endif + default: + // if it's not %% then it's an unsupported format character + assert(*fmt == '%' || !"unsupported fmt char"); + print->print_strn(print->data, fmt, 1); + chrs += 1; + break; + } + ++fmt; + } + return chrs; +} diff --git a/user/mpy/py/mpprint.h b/user/mpy/py/mpprint.h new file mode 100644 index 0000000..07462bd --- /dev/null +++ b/user/mpy/py/mpprint.h @@ -0,0 +1,74 @@ +/* + * 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 + +#include "py/mpconfig.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 MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES +# define MP_PYTHON_PRINTER &mp_sys_stdout_print +#else +# define MP_PYTHON_PRINTER &mp_plat_print +#endif + +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; + +// 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 MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES +// 2) Wrapper for printing to sys.stdout. +extern const mp_print_t mp_sys_stdout_print; +#endif + +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 MICROPY_PY_BUILTINS_FLOAT +int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec); +#endif + +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 + +#endif // MICROPY_INCLUDED_PY_MPPRINT_H diff --git a/user/mpy/py/mpstate.c b/user/mpy/py/mpstate.c new file mode 100644 index 0000000..6ce64ad --- /dev/null +++ b/user/mpy/py/mpstate.c @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#include "py/mpstate.h" + +#if MICROPY_DYNAMIC_COMPILER +mp_dynamic_compiler_t mp_dynamic_compiler = {0}; +#endif + +mp_state_ctx_t mp_state_ctx; diff --git a/user/mpy/py/mpstate.h b/user/mpy/py/mpstate.h new file mode 100644 index 0000000..eca14a9 --- /dev/null +++ b/user/mpy/py/mpstate.h @@ -0,0 +1,251 @@ +/* + * 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 + +#include + +#include "py/mpconfig.h" +#include "py/mpthread.h" +#include "py/misc.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/objlist.h" +#include "py/objexcept.h" + +// 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 MICROPY_DYNAMIC_COMPILER +typedef struct mp_dynamic_compiler_t { + uint8_t small_int_bits; // must be <= host small_int_bits + bool opt_cache_map_lookup_in_bytecode; + bool py_builtins_str_unicode; +} mp_dynamic_compiler_t; +extern mp_dynamic_compiler_t mp_dynamic_compiler; +#endif + +// 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 MICROPY_MEM_STATS + size_t total_bytes_allocated; + size_t current_bytes_allocated; + size_t peak_bytes_allocated; + #endif + + byte *gc_alloc_table_start; + size_t gc_alloc_table_byte_len; + #if MICROPY_ENABLE_FINALISER + byte *gc_finaliser_table_start; + #endif + byte *gc_pool_start; + byte *gc_pool_end; + + int gc_stack_overflow; + size_t gc_stack[MICROPY_ALLOC_GC_STACK_SIZE]; + size_t *gc_sp; + uint16_t gc_lock_depth; + + // 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 MICROPY_GC_ALLOC_THRESHOLD + size_t gc_alloc_amount; + size_t gc_alloc_threshold; + #endif + + size_t gc_last_free_atb_index; + + #if MICROPY_PY_GC_COLLECT_RETVAL + size_t gc_collected; + #endif + + #if MICROPY_PY_THREAD + // This is a global mutex used to make the GC thread-safe. + mp_thread_mutex_t gc_mutex; + #endif +} 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 { + //////////////////////////////////////////////////////////// + // START ROOT POINTER SECTION + // everything that needs GC scanning must go here + // this must start at the start of this structure + // + + 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 MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF + #if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0 + // 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 + // dynamically allocated buf + byte *mp_emergency_exception_buf; + #endif + #endif + + #if MICROPY_KBD_EXCEPTION + // exception object of type KeyboardInterrupt + mp_obj_exception_t mp_kbd_exception; + #endif + + // dictionary with loaded modules (may be exposed as sys.modules) + mp_obj_dict_t mp_loaded_modules_dict; + + // pending exception object (MP_OBJ_NULL if not pending) + volatile mp_obj_t mp_pending_exception; + + #if MICROPY_ENABLE_SCHEDULER + volatile int16_t sched_state; + uint16_t sched_sp; + mp_sched_item_t sched_stack[MICROPY_SCHEDULER_DEPTH]; + #endif + + // current exception being handled, for sys.exc_info() + #if MICROPY_PY_SYS_EXC_INFO + mp_obj_base_t *cur_exception; + #endif + + // 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 MICROPY_CAN_OVERRIDE_BUILTINS + mp_obj_dict_t *mp_module_builtins_override_dict; + #endif + + // include any root pointers defined by a port + MICROPY_PORT_ROOT_POINTERS + + // root pointers for extmod + + #if MICROPY_PY_OS_DUPTERM + mp_obj_t term_obj; + mp_obj_t dupterm_arr_obj; + #endif + + #if MICROPY_PY_LWIP_SLIP + mp_obj_t lwip_slip_stream; + #endif + + #if MICROPY_VFS + struct _mp_vfs_mount_t *vfs_cur; + struct _mp_vfs_mount_t *vfs_mount_table; + #endif + + // + // 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 MICROPY_PY_THREAD + // This is a global mutex used to make qstr interning thread-safe. + mp_thread_mutex_t qstr_mutex; + #endif + + mp_uint_t mp_optimise_value; + + // size of the emergency exception buf, if it's dynamically allocated + #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0 + mp_int_t mp_emergency_exception_buf_size; + #endif + + #if MICROPY_PY_THREAD_GIL + // This is a global mutex used to make the VM/runtime thread-safe. + mp_thread_mutex_t gil_mutex; + #endif +} 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 { + mp_obj_dict_t *dict_locals; + mp_obj_dict_t *dict_globals; + + // Note: nlr asm code has the offset of this hard-coded + nlr_buf_t *nlr_top; // ROOT POINTER + + // Stack top at the start of program + char *stack_top; + + #if MICROPY_STACK_CHECK + size_t stack_limit; + #endif +} 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. +// Note: if this structure changes then revisit all nlr asm code since they +// have the offset of nlr_top hard-coded. +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) + +#if MICROPY_PY_THREAD +extern mp_state_thread_t *mp_thread_get_state(void); +#define MP_STATE_THREAD(x) (mp_thread_get_state()->x) +#else +#define MP_STATE_THREAD(x) (mp_state_ctx.thread.x) +#endif + +#endif // MICROPY_INCLUDED_PY_MPSTATE_H diff --git a/user/mpy/py/mpthread.h b/user/mpy/py/mpthread.h new file mode 100644 index 0000000..602df83 --- /dev/null +++ b/user/mpy/py/mpthread.h @@ -0,0 +1,61 @@ +/* + * 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 + +#include "py/mpconfig.h" + +#if MICROPY_PY_THREAD + +#ifdef MICROPY_MPTHREADPORT_H +#include MICROPY_MPTHREADPORT_H +#else +#include +#endif + +struct _mp_state_thread_t; + +struct _mp_state_thread_t *mp_thread_get_state(void); +void mp_thread_set_state(void *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 + +#if MICROPY_PY_THREAD && MICROPY_PY_THREAD_GIL +#include "py/mpstate.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 +#define MP_THREAD_GIL_ENTER() +#define MP_THREAD_GIL_EXIT() +#endif + +#endif // MICROPY_INCLUDED_PY_MPTHREAD_H diff --git a/user/mpy/py/mpz.c b/user/mpy/py/mpz.c new file mode 100644 index 0000000..d300a8e --- /dev/null +++ b/user/mpy/py/mpz.c @@ -0,0 +1,1766 @@ +/* + * 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. + */ + +#include +#include + +#include "py/mpz.h" + +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ + +#define DIG_SIZE (MPZ_DIG_SIZE) +#define DIG_MASK ((MPZ_LONG_1 << DIG_SIZE) - 1) +#define DIG_MSB (MPZ_LONG_1 << (DIG_SIZE - 1)) +#define DIG_BASE (MPZ_LONG_1 << DIG_SIZE) + +/* + mpz is an arbitrary precision integer type with a public API. + + mpn functions act on non-negative integers represented by an array of generalised + digits (eg a word per digit). You also need to specify separately the length of the + array. There is no public API for mpn. Rather, the functions are used by mpz to + implement its features. + + Integer values are stored little endian (first digit is first in memory). + + Definition of normalise: ? +*/ + +STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) { + for (--idig; idig >= oidig && *idig == 0; --idig) { + } + return idig + 1 - oidig; +} + +/* compares i with j + returns sign(i - j) + assumes i, j are normalised +*/ +STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) { + if (ilen < jlen) { return -1; } + if (ilen > jlen) { return 1; } + + for (idig += ilen, jdig += ilen; ilen > 0; --ilen) { + mpz_dbl_dig_signed_t cmp = (mpz_dbl_dig_t)*(--idig) - (mpz_dbl_dig_t)*(--jdig); + if (cmp < 0) { return -1; } + if (cmp > 0) { return 1; } + } + + return 0; +} + +/* computes i = j << n + returns number of digits in i + assumes enough memory in i; assumes normalised j; assumes n > 0 + can have i, j pointing to same memory +*/ +STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) { + mp_uint_t n_whole = (n + DIG_SIZE - 1) / DIG_SIZE; + mp_uint_t n_part = n % DIG_SIZE; + if (n_part == 0) { + n_part = DIG_SIZE; + } + + // start from the high end of the digit arrays + idig += jlen + n_whole - 1; + jdig += jlen - 1; + + // shift the digits + mpz_dbl_dig_t d = 0; + for (size_t i = jlen; i > 0; i--, idig--, jdig--) { + d |= *jdig; + *idig = (d >> (DIG_SIZE - n_part)) & DIG_MASK; + d <<= DIG_SIZE; + } + + // store remaining bits + *idig = (d >> (DIG_SIZE - n_part)) & DIG_MASK; + idig -= n_whole - 1; + memset(idig, 0, (n_whole - 1) * sizeof(mpz_dig_t)); + + // work out length of result + jlen += n_whole; + while (jlen != 0 && idig[jlen - 1] == 0) { + jlen--; + } + + // return length of result + return jlen; +} + +/* computes i = j >> n + returns number of digits in i + assumes enough memory in i; assumes normalised j; assumes n > 0 + can have i, j pointing to same memory +*/ +STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) { + mp_uint_t n_whole = n / DIG_SIZE; + mp_uint_t n_part = n % DIG_SIZE; + + if (n_whole >= jlen) { + return 0; + } + + jdig += n_whole; + jlen -= n_whole; + + for (size_t i = jlen; i > 0; i--, idig++, jdig++) { + mpz_dbl_dig_t d = *jdig; + if (i > 1) { + d |= (mpz_dbl_dig_t)jdig[1] << DIG_SIZE; + } + d >>= n_part; + *idig = d & DIG_MASK; + } + + if (idig[-1] == 0) { + jlen--; + } + + return jlen; +} + +/* computes i = j + k + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { + mpz_dig_t *oidig = idig; + mpz_dbl_dig_t carry = 0; + + jlen -= klen; + + for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { + carry += (mpz_dbl_dig_t)*jdig + (mpz_dbl_dig_t)*kdig; + *idig = carry & DIG_MASK; + carry >>= DIG_SIZE; + } + + for (; jlen > 0; --jlen, ++idig, ++jdig) { + carry += *jdig; + *idig = carry & DIG_MASK; + carry >>= DIG_SIZE; + } + + if (carry != 0) { + *idig++ = carry; + } + + return idig - oidig; +} + +/* computes i = j - k + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes j >= k + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { + mpz_dig_t *oidig = idig; + mpz_dbl_dig_signed_t borrow = 0; + + jlen -= klen; + + for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { + borrow += (mpz_dbl_dig_t)*jdig - (mpz_dbl_dig_t)*kdig; + *idig = borrow & DIG_MASK; + borrow >>= DIG_SIZE; + } + + for (; jlen > 0; --jlen, ++idig, ++jdig) { + borrow += *jdig; + *idig = borrow & DIG_MASK; + borrow >>= DIG_SIZE; + } + + return mpn_remove_trailing_zeros(oidig, idig); +} + +#if MICROPY_OPT_MPZ_BITWISE + +/* computes i = j & k + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen (jlen argument not needed) + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) { + mpz_dig_t *oidig = idig; + + for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { + *idig = *jdig & *kdig; + } + + return mpn_remove_trailing_zeros(oidig, idig); +} + +#endif + +/* i = -((-j) & (-k)) = ~((~j + 1) & (~k + 1)) + 1 + i = (j & (-k)) = (j & (~k + 1)) = ( j & (~k + 1)) + i = ((-j) & k) = ((~j + 1) & k) = ((~j + 1) & k ) + computes general form: + i = (im ^ (((j ^ jm) + jc) & ((k ^ km) + kc))) + ic where Xm = Xc == 0 ? 0 : DIG_MASK + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes length j >= length k + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, + mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { + mpz_dig_t *oidig = idig; + mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK; + mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK; + mpz_dig_t kmask = (0 == carryk) ? 0 : DIG_MASK; + + for (; jlen > 0; ++idig, ++jdig) { + carryj += *jdig ^ jmask; + carryk += (--klen <= --jlen) ? (*kdig++ ^ kmask) : kmask; + carryi += ((carryj & carryk) ^ imask) & DIG_MASK; + *idig = carryi & DIG_MASK; + carryk >>= DIG_SIZE; + carryj >>= DIG_SIZE; + carryi >>= DIG_SIZE; + } + + if (0 != carryi) { + *idig++ = carryi; + } + + return mpn_remove_trailing_zeros(oidig, idig); +} + +#if MICROPY_OPT_MPZ_BITWISE + +/* computes i = j | k + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { + mpz_dig_t *oidig = idig; + + jlen -= klen; + + for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { + *idig = *jdig | *kdig; + } + + for (; jlen > 0; --jlen, ++idig, ++jdig) { + *idig = *jdig; + } + + return idig - oidig; +} + +#endif + +/* i = -((-j) | (-k)) = ~((~j + 1) | (~k + 1)) + 1 + i = -(j | (-k)) = -(j | (~k + 1)) = ~( j | (~k + 1)) + 1 + i = -((-j) | k) = -((~j + 1) | k) = ~((~j + 1) | k ) + 1 + computes general form: + i = ~(((j ^ jm) + jc) | ((k ^ km) + kc)) + 1 where Xm = Xc == 0 ? 0 : DIG_MASK + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes length j >= length k + can have i, j, k pointing to same memory +*/ + +#if MICROPY_OPT_MPZ_BITWISE + +STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, + mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { + mpz_dig_t *oidig = idig; + mpz_dbl_dig_t carryi = 1; + mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK; + mpz_dig_t kmask = (0 == carryk) ? 0 : DIG_MASK; + + for (; jlen > 0; ++idig, ++jdig) { + carryj += *jdig ^ jmask; + carryk += (--klen <= --jlen) ? (*kdig++ ^ kmask) : kmask; + carryi += ((carryj | carryk) ^ DIG_MASK) & DIG_MASK; + *idig = carryi & DIG_MASK; + carryk >>= DIG_SIZE; + carryj >>= DIG_SIZE; + carryi >>= DIG_SIZE; + } + + // At least one of j,k must be negative so the above for-loop runs at least + // once. For carryi to be non-zero here it must be equal to 1 at the end of + // each iteration of the loop. So the accumulation of carryi must overflow + // each time, ie carryi += 0xff..ff. So carryj|carryk must be 0 in the + // DIG_MASK bits on each iteration. But considering all cases of signs of + // j,k one sees that this is not possible. + assert(carryi == 0); + + return mpn_remove_trailing_zeros(oidig, idig); +} + +#else + +STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, + mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { + mpz_dig_t *oidig = idig; + mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK; + mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK; + mpz_dig_t kmask = (0 == carryk) ? 0 : DIG_MASK; + + for (; jlen > 0; ++idig, ++jdig) { + carryj += *jdig ^ jmask; + carryk += (--klen <= --jlen) ? (*kdig++ ^ kmask) : kmask; + carryi += ((carryj | carryk) ^ imask) & DIG_MASK; + *idig = carryi & DIG_MASK; + carryk >>= DIG_SIZE; + carryj >>= DIG_SIZE; + carryi >>= DIG_SIZE; + } + + // See comment in above mpn_or_neg for why carryi must be 0. + assert(carryi == 0); + + return mpn_remove_trailing_zeros(oidig, idig); +} + +#endif + +#if MICROPY_OPT_MPZ_BITWISE + +/* computes i = j ^ k + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { + mpz_dig_t *oidig = idig; + + jlen -= klen; + + for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { + *idig = *jdig ^ *kdig; + } + + for (; jlen > 0; --jlen, ++idig, ++jdig) { + *idig = *jdig; + } + + return mpn_remove_trailing_zeros(oidig, idig); +} + +#endif + +/* i = (-j) ^ (-k) = ~(j - 1) ^ ~(k - 1) = (j - 1) ^ (k - 1) + i = -(j ^ (-k)) = -(j ^ ~(k - 1)) = ~(j ^ ~(k - 1)) + 1 = (j ^ (k - 1)) + 1 + i = -((-j) ^ k) = -(~(j - 1) ^ k) = ~(~(j - 1) ^ k) + 1 = ((j - 1) ^ k) + 1 + computes general form: + i = ((j - 1 + jc) ^ (k - 1 + kc)) + ic + returns number of digits in i + assumes enough memory in i; assumes normalised j, k; assumes length j >= length k + can have i, j, k pointing to same memory +*/ +STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, + mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { + mpz_dig_t *oidig = idig; + + for (; jlen > 0; ++idig, ++jdig) { + carryj += *jdig + DIG_MASK; + carryk += (--klen <= --jlen) ? (*kdig++ + DIG_MASK) : DIG_MASK; + carryi += (carryj ^ carryk) & DIG_MASK; + *idig = carryi & DIG_MASK; + carryk >>= DIG_SIZE; + carryj >>= DIG_SIZE; + carryi >>= DIG_SIZE; + } + + if (0 != carryi) { + *idig++ = carryi; + } + + return mpn_remove_trailing_zeros(oidig, idig); +} + +/* computes i = i * d1 + d2 + returns number of digits in i + assumes enough memory in i; assumes normalised i; assumes dmul != 0 +*/ +STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) { + mpz_dig_t *oidig = idig; + mpz_dbl_dig_t carry = dadd; + + for (; ilen > 0; --ilen, ++idig) { + carry += (mpz_dbl_dig_t)*idig * (mpz_dbl_dig_t)dmul; // will never overflow so long as DIG_SIZE <= 8*sizeof(mpz_dbl_dig_t)/2 + *idig = carry & DIG_MASK; + carry >>= DIG_SIZE; + } + + if (carry != 0) { + *idig++ = carry; + } + + return idig - oidig; +} + +/* computes i = j * k + returns number of digits in i + assumes enough memory in i; assumes i is zeroed; assumes normalised j, k + can have j, k point to same memory +*/ +STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) { + mpz_dig_t *oidig = idig; + size_t ilen = 0; + + for (; klen > 0; --klen, ++idig, ++kdig) { + mpz_dig_t *id = idig; + mpz_dbl_dig_t carry = 0; + + size_t jl = jlen; + for (mpz_dig_t *jd = jdig; jl > 0; --jl, ++jd, ++id) { + carry += (mpz_dbl_dig_t)*id + (mpz_dbl_dig_t)*jd * (mpz_dbl_dig_t)*kdig; // will never overflow so long as DIG_SIZE <= 8*sizeof(mpz_dbl_dig_t)/2 + *id = carry & DIG_MASK; + carry >>= DIG_SIZE; + } + + if (carry != 0) { + *id++ = carry; + } + + ilen = id - oidig; + } + + return ilen; +} + +/* natural_div - quo * den + new_num = old_num (ie num is replaced with rem) + assumes den != 0 + assumes num_dig has enough memory to be extended by 1 digit + assumes quo_dig has enough memory (as many digits as num) + assumes quo_dig is filled with zeros +*/ +STATIC void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len) { + mpz_dig_t *orig_num_dig = num_dig; + mpz_dig_t *orig_quo_dig = quo_dig; + mpz_dig_t norm_shift = 0; + mpz_dbl_dig_t lead_den_digit; + + // handle simple cases + { + int cmp = mpn_cmp(num_dig, *num_len, den_dig, den_len); + if (cmp == 0) { + *num_len = 0; + quo_dig[0] = 1; + *quo_len = 1; + return; + } else if (cmp < 0) { + // numerator remains the same + *quo_len = 0; + return; + } + } + + // We need to normalise the denominator (leading bit of leading digit is 1) + // so that the division routine works. Since the denominator memory is + // read-only we do the normalisation on the fly, each time a digit of the + // denominator is needed. We need to know is how many bits to shift by. + + // count number of leading zeros in leading digit of denominator + { + mpz_dig_t d = den_dig[den_len - 1]; + while ((d & DIG_MSB) == 0) { + d <<= 1; + ++norm_shift; + } + } + + // now need to shift numerator by same amount as denominator + // first, increase length of numerator in case we need more room to shift + num_dig[*num_len] = 0; + ++(*num_len); + for (mpz_dig_t *num = num_dig, carry = 0; num < num_dig + *num_len; ++num) { + mpz_dig_t n = *num; + *num = ((n << norm_shift) | carry) & DIG_MASK; + carry = (mpz_dbl_dig_t)n >> (DIG_SIZE - norm_shift); + } + + // cache the leading digit of the denominator + lead_den_digit = (mpz_dbl_dig_t)den_dig[den_len - 1] << norm_shift; + if (den_len >= 2) { + lead_den_digit |= (mpz_dbl_dig_t)den_dig[den_len - 2] >> (DIG_SIZE - norm_shift); + } + + // point num_dig to last digit in numerator + num_dig += *num_len - 1; + + // calculate number of digits in quotient + *quo_len = *num_len - den_len; + + // point to last digit to store for quotient + quo_dig += *quo_len - 1; + + // keep going while we have enough digits to divide + while (*num_len > den_len) { + mpz_dbl_dig_t quo = ((mpz_dbl_dig_t)*num_dig << DIG_SIZE) | num_dig[-1]; + + // get approximate quotient + quo /= lead_den_digit; + + // Multiply quo by den and subtract from num to get remainder. + // We have different code here to handle different compile-time + // configurations of mpz: + // + // 1. DIG_SIZE is stricly less than half the number of bits + // available in mpz_dbl_dig_t. In this case we can use a + // slightly more optimal (in time and space) routine that + // uses the extra bits in mpz_dbl_dig_signed_t to store a + // sign bit. + // + // 2. DIG_SIZE is exactly half the number of bits available in + // mpz_dbl_dig_t. In this (common) case we need to be careful + // not to overflow the borrow variable. And the shifting of + // borrow needs some special logic (it's a shift right with + // round up). + + if (DIG_SIZE < 8 * sizeof(mpz_dbl_dig_t) / 2) { + const mpz_dig_t *d = den_dig; + mpz_dbl_dig_t d_norm = 0; + mpz_dbl_dig_signed_t borrow = 0; + + for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { + d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); + borrow += (mpz_dbl_dig_t)*n - (mpz_dbl_dig_t)quo * (d_norm & DIG_MASK); // will overflow if DIG_SIZE >= 8*sizeof(mpz_dbl_dig_t)/2 + *n = borrow & DIG_MASK; + borrow >>= DIG_SIZE; + } + borrow += *num_dig; // will overflow if DIG_SIZE >= 8*sizeof(mpz_dbl_dig_t)/2 + *num_dig = borrow & DIG_MASK; + borrow >>= DIG_SIZE; + + // adjust quotient if it is too big + for (; borrow != 0; --quo) { + d = den_dig; + d_norm = 0; + mpz_dbl_dig_t carry = 0; + for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { + d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); + carry += (mpz_dbl_dig_t)*n + (d_norm & DIG_MASK); + *n = carry & DIG_MASK; + carry >>= DIG_SIZE; + } + carry += *num_dig; + *num_dig = carry & DIG_MASK; + carry >>= DIG_SIZE; + + borrow += carry; + } + } else { // DIG_SIZE == 8 * sizeof(mpz_dbl_dig_t) / 2 + const mpz_dig_t *d = den_dig; + mpz_dbl_dig_t d_norm = 0; + mpz_dbl_dig_t borrow = 0; + + for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { + d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); + mpz_dbl_dig_t x = (mpz_dbl_dig_t)quo * (d_norm & DIG_MASK); + if (x >= *n || *n - x <= borrow) { + borrow += (mpz_dbl_dig_t)x - (mpz_dbl_dig_t)*n; + *n = (-borrow) & DIG_MASK; + borrow = (borrow >> DIG_SIZE) + ((borrow & DIG_MASK) == 0 ? 0 : 1); // shift-right with round-up + } else { + *n = ((mpz_dbl_dig_t)*n - (mpz_dbl_dig_t)x - (mpz_dbl_dig_t)borrow) & DIG_MASK; + borrow = 0; + } + } + if (borrow >= *num_dig) { + borrow -= (mpz_dbl_dig_t)*num_dig; + *num_dig = (-borrow) & DIG_MASK; + borrow = (borrow >> DIG_SIZE) + ((borrow & DIG_MASK) == 0 ? 0 : 1); // shift-right with round-up + } else { + *num_dig = (*num_dig - borrow) & DIG_MASK; + borrow = 0; + } + + // adjust quotient if it is too big + for (; borrow != 0; --quo) { + d = den_dig; + d_norm = 0; + mpz_dbl_dig_t carry = 0; + for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { + d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); + carry += (mpz_dbl_dig_t)*n + (d_norm & DIG_MASK); + *n = carry & DIG_MASK; + carry >>= DIG_SIZE; + } + carry += (mpz_dbl_dig_t)*num_dig; + *num_dig = carry & DIG_MASK; + carry >>= DIG_SIZE; + + //assert(borrow >= carry); // enable this to check the logic + borrow -= carry; + } + } + + // store this digit of the quotient + *quo_dig = quo & DIG_MASK; + --quo_dig; + + // move down to next digit of numerator + --num_dig; + --(*num_len); + } + + // unnormalise numerator (remainder now) + for (mpz_dig_t *num = orig_num_dig + *num_len - 1, carry = 0; num >= orig_num_dig; --num) { + mpz_dig_t n = *num; + *num = ((n >> norm_shift) | carry) & DIG_MASK; + carry = (mpz_dbl_dig_t)n << (DIG_SIZE - norm_shift); + } + + // strip trailing zeros + + while (*quo_len > 0 && orig_quo_dig[*quo_len - 1] == 0) { + --(*quo_len); + } + + while (*num_len > 0 && orig_num_dig[*num_len - 1] == 0) { + --(*num_len); + } +} + +#define MIN_ALLOC (2) + +void mpz_init_zero(mpz_t *z) { + z->neg = 0; + z->fixed_dig = 0; + z->alloc = 0; + z->len = 0; + z->dig = NULL; +} + +void mpz_init_from_int(mpz_t *z, mp_int_t val) { + mpz_init_zero(z); + mpz_set_from_int(z, val); +} + +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t alloc, mp_int_t val) { + z->neg = 0; + z->fixed_dig = 1; + z->alloc = alloc; + z->len = 0; + z->dig = dig; + mpz_set_from_int(z, val); +} + +void mpz_deinit(mpz_t *z) { + if (z != NULL && !z->fixed_dig) { + m_del(mpz_dig_t, z->dig, z->alloc); + } +} + +#if 0 +these functions are unused + +mpz_t *mpz_zero(void) { + mpz_t *z = m_new_obj(mpz_t); + mpz_init_zero(z); + return z; +} + +mpz_t *mpz_from_int(mp_int_t val) { + mpz_t *z = mpz_zero(); + mpz_set_from_int(z, val); + return z; +} + +mpz_t *mpz_from_ll(long long val, bool is_signed) { + mpz_t *z = mpz_zero(); + mpz_set_from_ll(z, val, is_signed); + return z; +} + +#if MICROPY_PY_BUILTINS_FLOAT +mpz_t *mpz_from_float(mp_float_t val) { + mpz_t *z = mpz_zero(); + mpz_set_from_float(z, val); + return z; +} +#endif + +mpz_t *mpz_from_str(const char *str, size_t len, bool neg, unsigned int base) { + mpz_t *z = mpz_zero(); + mpz_set_from_str(z, str, len, neg, base); + return z; +} +#endif + +STATIC void mpz_free(mpz_t *z) { + if (z != NULL) { + m_del(mpz_dig_t, z->dig, z->alloc); + m_del_obj(mpz_t, z); + } +} + +STATIC void mpz_need_dig(mpz_t *z, size_t need) { + if (need < MIN_ALLOC) { + need = MIN_ALLOC; + } + + if (z->dig == NULL || z->alloc < need) { + // if z has fixed digit buffer there's not much we can do as the caller will + // be expecting a buffer with at least "need" bytes (but it shouldn't happen) + assert(!z->fixed_dig); + z->dig = m_renew(mpz_dig_t, z->dig, z->alloc, need); + z->alloc = need; + } +} + +STATIC mpz_t *mpz_clone(const mpz_t *src) { + mpz_t *z = m_new_obj(mpz_t); + z->neg = src->neg; + z->fixed_dig = 0; + z->alloc = src->alloc; + z->len = src->len; + if (src->dig == NULL) { + z->dig = NULL; + } else { + z->dig = m_new(mpz_dig_t, z->alloc); + memcpy(z->dig, src->dig, src->alloc * sizeof(mpz_dig_t)); + } + return z; +} + +/* sets dest = src + can have dest, src the same +*/ +void mpz_set(mpz_t *dest, const mpz_t *src) { + mpz_need_dig(dest, src->len); + dest->neg = src->neg; + dest->len = src->len; + memcpy(dest->dig, src->dig, src->len * sizeof(mpz_dig_t)); +} + +void mpz_set_from_int(mpz_t *z, mp_int_t val) { + if (val == 0) { + z->len = 0; + return; + } + + mpz_need_dig(z, MPZ_NUM_DIG_FOR_INT); + + mp_uint_t uval; + if (val < 0) { + z->neg = 1; + uval = -val; + } else { + z->neg = 0; + uval = val; + } + + z->len = 0; + while (uval > 0) { + z->dig[z->len++] = uval & DIG_MASK; + uval >>= DIG_SIZE; + } +} + +void mpz_set_from_ll(mpz_t *z, long long val, bool is_signed) { + mpz_need_dig(z, MPZ_NUM_DIG_FOR_LL); + + unsigned long long uval; + if (is_signed && val < 0) { + z->neg = 1; + uval = -val; + } else { + z->neg = 0; + uval = val; + } + + z->len = 0; + while (uval > 0) { + z->dig[z->len++] = uval & DIG_MASK; + uval >>= DIG_SIZE; + } +} + +#if MICROPY_PY_BUILTINS_FLOAT +void mpz_set_from_float(mpz_t *z, mp_float_t src) { +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE +typedef uint64_t mp_float_int_t; +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT +typedef uint32_t mp_float_int_t; +#endif + union { + mp_float_t f; + #if MP_ENDIANNESS_LITTLE + struct { mp_float_int_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; + #else + struct { mp_float_int_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; + #endif + } u = {src}; + + z->neg = u.p.sgn; + if (u.p.exp == 0) { + // value == 0 || value < 1 + mpz_set_from_int(z, 0); + } else if (u.p.exp == ((1 << MP_FLOAT_EXP_BITS) - 1)) { + // u.p.frc == 0 indicates inf, else NaN + // should be handled by caller + mpz_set_from_int(z, 0); + } else { + const int adj_exp = (int)u.p.exp - MP_FLOAT_EXP_BIAS; + if (adj_exp < 0) { + // value < 1 , truncates to 0 + mpz_set_from_int(z, 0); + } else if (adj_exp == 0) { + // 1 <= value < 2 , so truncates to 1 + mpz_set_from_int(z, 1); + } else { + // 2 <= value + const int dig_cnt = (adj_exp + 1 + (DIG_SIZE - 1)) / DIG_SIZE; + const unsigned int rem = adj_exp % DIG_SIZE; + int dig_ind, shft; + mp_float_int_t frc = u.p.frc | ((mp_float_int_t)1 << MP_FLOAT_FRAC_BITS); + + if (adj_exp < MP_FLOAT_FRAC_BITS) { + shft = 0; + dig_ind = 0; + frc >>= MP_FLOAT_FRAC_BITS - adj_exp; + } else { + shft = (rem - MP_FLOAT_FRAC_BITS) % DIG_SIZE; + dig_ind = (adj_exp - MP_FLOAT_FRAC_BITS) / DIG_SIZE; + } + mpz_need_dig(z, dig_cnt); + z->len = dig_cnt; + if (dig_ind != 0) { + memset(z->dig, 0, dig_ind * sizeof(mpz_dig_t)); + } + if (shft != 0) { + z->dig[dig_ind++] = (frc << shft) & DIG_MASK; + frc >>= DIG_SIZE - shft; + } +#if DIG_SIZE < (MP_FLOAT_FRAC_BITS + 1) + while (dig_ind != dig_cnt) { + z->dig[dig_ind++] = frc & DIG_MASK; + frc >>= DIG_SIZE; + } +#else + if (dig_ind != dig_cnt) { + z->dig[dig_ind] = frc; + } +#endif + } + } +} +#endif + +// returns number of bytes from str that were processed +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base) { + assert(base <= 36); + + const char *cur = str; + const char *top = str + len; + + mpz_need_dig(z, len * 8 / DIG_SIZE + 1); + + if (neg) { + z->neg = 1; + } else { + z->neg = 0; + } + + z->len = 0; + for (; cur < top; ++cur) { // XXX UTF8 next char + //mp_uint_t v = char_to_numeric(cur#); // XXX UTF8 get char + mp_uint_t v = *cur; + if ('0' <= v && v <= '9') { + v -= '0'; + } else if ('A' <= v && v <= 'Z') { + v -= 'A' - 10; + } else if ('a' <= v && v <= 'z') { + v -= 'a' - 10; + } else { + break; + } + if (v >= base) { + break; + } + z->len = mpn_mul_dig_add_dig(z->dig, z->len, base, v); + } + + return cur - str; +} + +void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf) { + int delta = 1; + if (big_endian) { + buf += len - 1; + delta = -1; + } + + mpz_need_dig(z, (len * 8 + DIG_SIZE - 1) / DIG_SIZE); + + mpz_dig_t d = 0; + int num_bits = 0; + z->neg = 0; + z->len = 0; + while (len) { + while (len && num_bits < DIG_SIZE) { + d |= *buf << num_bits; + num_bits += 8; + buf += delta; + len--; + } + z->dig[z->len++] = d & DIG_MASK; + // Need this #if because it's C undefined behavior to do: uint32_t >> 32 + #if DIG_SIZE != 8 && DIG_SIZE != 16 && DIG_SIZE != 32 + d >>= DIG_SIZE; + #else + d = 0; + #endif + num_bits -= DIG_SIZE; + } + + z->len = mpn_remove_trailing_zeros(z->dig, z->dig + z->len); +} + +#if 0 +these functions are unused + +bool mpz_is_pos(const mpz_t *z) { + return z->len > 0 && z->neg == 0; +} + +bool mpz_is_odd(const mpz_t *z) { + return z->len > 0 && (z->dig[0] & 1) != 0; +} + +bool mpz_is_even(const mpz_t *z) { + return z->len == 0 || (z->dig[0] & 1) == 0; +} +#endif + +int mpz_cmp(const mpz_t *z1, const mpz_t *z2) { + // to catch comparison of -0 with +0 + if (z1->len == 0 && z2->len == 0) { + return 0; + } + int cmp = (int)z2->neg - (int)z1->neg; + if (cmp != 0) { + return cmp; + } + cmp = mpn_cmp(z1->dig, z1->len, z2->dig, z2->len); + if (z1->neg != 0) { + cmp = -cmp; + } + return cmp; +} + +#if 0 +// obsolete +// compares mpz with an integer that fits within DIG_SIZE bits +mp_int_t mpz_cmp_sml_int(const mpz_t *z, mp_int_t sml_int) { + mp_int_t cmp; + if (z->neg == 0) { + if (sml_int < 0) return 1; + if (sml_int == 0) { + if (z->len == 0) return 0; + return 1; + } + if (z->len == 0) return -1; + assert(sml_int < (1 << DIG_SIZE)); + if (z->len != 1) return 1; + cmp = z->dig[0] - sml_int; + } else { + if (sml_int > 0) return -1; + if (sml_int == 0) { + if (z->len == 0) return 0; + return -1; + } + if (z->len == 0) return 1; + assert(sml_int > -(1 << DIG_SIZE)); + if (z->len != 1) return -1; + cmp = -z->dig[0] - sml_int; + } + if (cmp < 0) return -1; + if (cmp > 0) return 1; + return 0; +} +#endif + +#if 0 +these functions are unused + +/* returns abs(z) +*/ +mpz_t *mpz_abs(const mpz_t *z) { + mpz_t *z2 = mpz_clone(z); + z2->neg = 0; + return z2; +} + +/* returns -z +*/ +mpz_t *mpz_neg(const mpz_t *z) { + mpz_t *z2 = mpz_clone(z); + z2->neg = 1 - z2->neg; + return z2; +} + +/* returns lhs + rhs + can have lhs, rhs the same +*/ +mpz_t *mpz_add(const mpz_t *lhs, const mpz_t *rhs) { + mpz_t *z = mpz_zero(); + mpz_add_inpl(z, lhs, rhs); + return z; +} + +/* returns lhs - rhs + can have lhs, rhs the same +*/ +mpz_t *mpz_sub(const mpz_t *lhs, const mpz_t *rhs) { + mpz_t *z = mpz_zero(); + mpz_sub_inpl(z, lhs, rhs); + return z; +} + +/* returns lhs * rhs + can have lhs, rhs the same +*/ +mpz_t *mpz_mul(const mpz_t *lhs, const mpz_t *rhs) { + mpz_t *z = mpz_zero(); + mpz_mul_inpl(z, lhs, rhs); + return z; +} + +/* returns lhs ** rhs + can have lhs, rhs the same +*/ +mpz_t *mpz_pow(const mpz_t *lhs, const mpz_t *rhs) { + mpz_t *z = mpz_zero(); + mpz_pow_inpl(z, lhs, rhs); + return z; +} + +/* computes new integers in quo and rem such that: + quo * rhs + rem = lhs + 0 <= rem < rhs + can have lhs, rhs the same +*/ +void mpz_divmod(const mpz_t *lhs, const mpz_t *rhs, mpz_t **quo, mpz_t **rem) { + *quo = mpz_zero(); + *rem = mpz_zero(); + mpz_divmod_inpl(*quo, *rem, lhs, rhs); +} +#endif + +/* computes dest = abs(z) + can have dest, z the same +*/ +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z) { + if (dest != z) { + mpz_set(dest, z); + } + dest->neg = 0; +} + +/* computes dest = -z + can have dest, z the same +*/ +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z) { + if (dest != z) { + mpz_set(dest, z); + } + dest->neg = 1 - dest->neg; +} + +/* computes dest = ~z (= -z - 1) + can have dest, z the same +*/ +void mpz_not_inpl(mpz_t *dest, const mpz_t *z) { + if (dest != z) { + mpz_set(dest, z); + } + if (dest->len == 0) { + mpz_need_dig(dest, 1); + dest->dig[0] = 1; + dest->len = 1; + dest->neg = 1; + } else if (dest->neg) { + dest->neg = 0; + mpz_dig_t k = 1; + dest->len = mpn_sub(dest->dig, dest->dig, dest->len, &k, 1); + } else { + mpz_need_dig(dest, dest->len + 1); + mpz_dig_t k = 1; + dest->len = mpn_add(dest->dig, dest->dig, dest->len, &k, 1); + dest->neg = 1; + } +} + +/* computes dest = lhs << rhs + can have dest, lhs the same +*/ +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) { + if (lhs->len == 0 || rhs == 0) { + mpz_set(dest, lhs); + } else { + mpz_need_dig(dest, lhs->len + (rhs + DIG_SIZE - 1) / DIG_SIZE); + dest->len = mpn_shl(dest->dig, lhs->dig, lhs->len, rhs); + dest->neg = lhs->neg; + } +} + +/* computes dest = lhs >> rhs + can have dest, lhs the same +*/ +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) { + if (lhs->len == 0 || rhs == 0) { + mpz_set(dest, lhs); + } else { + mpz_need_dig(dest, lhs->len); + dest->len = mpn_shr(dest->dig, lhs->dig, lhs->len, rhs); + dest->neg = lhs->neg; + if (dest->neg) { + // arithmetic shift right, rounding to negative infinity + mp_uint_t n_whole = rhs / DIG_SIZE; + mp_uint_t n_part = rhs % DIG_SIZE; + mpz_dig_t round_up = 0; + for (size_t i = 0; i < lhs->len && i < n_whole; i++) { + if (lhs->dig[i] != 0) { + round_up = 1; + break; + } + } + if (n_whole < lhs->len && (lhs->dig[n_whole] & ((1 << n_part) - 1)) != 0) { + round_up = 1; + } + if (round_up) { + if (dest->len == 0) { + // dest == 0, so need to add 1 by hand (answer will be -1) + dest->dig[0] = 1; + dest->len = 1; + } else { + // dest > 0, so can use mpn_add to add 1 + dest->len = mpn_add(dest->dig, dest->dig, dest->len, &round_up, 1); + } + } + } + } +} + +/* computes dest = lhs + rhs + can have dest, lhs, rhs the same +*/ +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + if (mpn_cmp(lhs->dig, lhs->len, rhs->dig, rhs->len) < 0) { + const mpz_t *temp = lhs; + lhs = rhs; + rhs = temp; + } + + if (lhs->neg == rhs->neg) { + mpz_need_dig(dest, lhs->len + 1); + dest->len = mpn_add(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + } else { + mpz_need_dig(dest, lhs->len); + dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + } + + dest->neg = lhs->neg; +} + +/* computes dest = lhs - rhs + can have dest, lhs, rhs the same +*/ +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + bool neg = false; + + if (mpn_cmp(lhs->dig, lhs->len, rhs->dig, rhs->len) < 0) { + const mpz_t *temp = lhs; + lhs = rhs; + rhs = temp; + neg = true; + } + + if (lhs->neg != rhs->neg) { + mpz_need_dig(dest, lhs->len + 1); + dest->len = mpn_add(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + } else { + mpz_need_dig(dest, lhs->len); + dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + } + + if (neg) { + dest->neg = 1 - lhs->neg; + } else { + dest->neg = lhs->neg; + } +} + +/* computes dest = lhs & rhs + can have dest, lhs, rhs the same +*/ +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + // make sure lhs has the most digits + if (lhs->len < rhs->len) { + const mpz_t *temp = lhs; + lhs = rhs; + rhs = temp; + } + + #if MICROPY_OPT_MPZ_BITWISE + + if ((0 == lhs->neg) && (0 == rhs->neg)) { + mpz_need_dig(dest, lhs->len); + dest->len = mpn_and(dest->dig, lhs->dig, rhs->dig, rhs->len); + dest->neg = 0; + } else { + mpz_need_dig(dest, lhs->len + 1); + dest->len = mpn_and_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, + lhs->neg == rhs->neg, 0 != lhs->neg, 0 != rhs->neg); + dest->neg = lhs->neg & rhs->neg; + } + + #else + + mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg)); + dest->len = mpn_and_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, + (lhs->neg == rhs->neg) ? lhs->neg : 0, lhs->neg, rhs->neg); + dest->neg = lhs->neg & rhs->neg; + + #endif +} + +/* computes dest = lhs | rhs + can have dest, lhs, rhs the same +*/ +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + // make sure lhs has the most digits + if (lhs->len < rhs->len) { + const mpz_t *temp = lhs; + lhs = rhs; + rhs = temp; + } + + #if MICROPY_OPT_MPZ_BITWISE + + if ((0 == lhs->neg) && (0 == rhs->neg)) { + mpz_need_dig(dest, lhs->len); + dest->len = mpn_or(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + dest->neg = 0; + } else { + mpz_need_dig(dest, lhs->len + 1); + dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, + 0 != lhs->neg, 0 != rhs->neg); + dest->neg = 1; + } + + #else + + mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg)); + dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, + (lhs->neg || rhs->neg), lhs->neg, rhs->neg); + dest->neg = lhs->neg | rhs->neg; + + #endif +} + +/* computes dest = lhs ^ rhs + can have dest, lhs, rhs the same +*/ +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + // make sure lhs has the most digits + if (lhs->len < rhs->len) { + const mpz_t *temp = lhs; + lhs = rhs; + rhs = temp; + } + + #if MICROPY_OPT_MPZ_BITWISE + + if (lhs->neg == rhs->neg) { + mpz_need_dig(dest, lhs->len); + if (lhs->neg == 0) { + dest->len = mpn_xor(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + } else { + dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, 0, 0, 0); + } + dest->neg = 0; + } else { + mpz_need_dig(dest, lhs->len + 1); + dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, 1, + 0 == lhs->neg, 0 == rhs->neg); + dest->neg = 1; + } + + #else + + mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg)); + dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, + (lhs->neg != rhs->neg), 0 == lhs->neg, 0 == rhs->neg); + dest->neg = lhs->neg ^ rhs->neg; + + #endif +} + +/* computes dest = lhs * rhs + can have dest, lhs, rhs the same +*/ +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + if (lhs->len == 0 || rhs->len == 0) { + mpz_set_from_int(dest, 0); + return; + } + + mpz_t *temp = NULL; + if (lhs == dest) { + lhs = temp = mpz_clone(lhs); + if (rhs == dest) { + rhs = lhs; + } + } else if (rhs == dest) { + rhs = temp = mpz_clone(rhs); + } + + mpz_need_dig(dest, lhs->len + rhs->len); // min mem l+r-1, max mem l+r + memset(dest->dig, 0, dest->alloc * sizeof(mpz_dig_t)); + dest->len = mpn_mul(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); + + if (lhs->neg == rhs->neg) { + dest->neg = 0; + } else { + dest->neg = 1; + } + + mpz_free(temp); +} + +/* computes dest = lhs ** rhs + can have dest, lhs, rhs the same +*/ +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { + if (lhs->len == 0 || rhs->neg != 0) { + mpz_set_from_int(dest, 0); + return; + } + + if (rhs->len == 0) { + mpz_set_from_int(dest, 1); + return; + } + + mpz_t *x = mpz_clone(lhs); + mpz_t *n = mpz_clone(rhs); + + mpz_set_from_int(dest, 1); + + while (n->len > 0) { + if ((n->dig[0] & 1) != 0) { + mpz_mul_inpl(dest, dest, x); + } + n->len = mpn_shr(n->dig, n->dig, n->len, 1); + if (n->len == 0) { + break; + } + mpz_mul_inpl(x, x, x); + } + + mpz_free(x); + mpz_free(n); +} + +/* computes dest = (lhs ** rhs) % mod + can have dest, lhs, rhs the same; mod can't be the same as dest +*/ +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod) { + if (lhs->len == 0 || rhs->neg != 0) { + mpz_set_from_int(dest, 0); + return; + } + + if (rhs->len == 0) { + mpz_set_from_int(dest, 1); + return; + } + + mpz_t *x = mpz_clone(lhs); + mpz_t *n = mpz_clone(rhs); + mpz_t quo; mpz_init_zero(&quo); + + mpz_set_from_int(dest, 1); + + while (n->len > 0) { + if ((n->dig[0] & 1) != 0) { + mpz_mul_inpl(dest, dest, x); + mpz_divmod_inpl(&quo, dest, dest, mod); + } + n->len = mpn_shr(n->dig, n->dig, n->len, 1); + if (n->len == 0) { + break; + } + mpz_mul_inpl(x, x, x); + mpz_divmod_inpl(&quo, x, x, mod); + } + + mpz_deinit(&quo); + mpz_free(x); + mpz_free(n); +} + +#if 0 +these functions are unused + +/* computes gcd(z1, z2) + based on Knuth's modified gcd algorithm (I think?) + gcd(z1, z2) >= 0 + gcd(0, 0) = 0 + gcd(z, 0) = abs(z) +*/ +mpz_t *mpz_gcd(const mpz_t *z1, const mpz_t *z2) { + if (z1->len == 0) { + mpz_t *a = mpz_clone(z2); + a->neg = 0; + return a; + } else if (z2->len == 0) { + mpz_t *a = mpz_clone(z1); + a->neg = 0; + return a; + } + + mpz_t *a = mpz_clone(z1); + mpz_t *b = mpz_clone(z2); + mpz_t c; mpz_init_zero(&c); + a->neg = 0; + b->neg = 0; + + for (;;) { + if (mpz_cmp(a, b) < 0) { + if (a->len == 0) { + mpz_free(a); + mpz_deinit(&c); + return b; + } + mpz_t *t = a; a = b; b = t; + } + if (!(b->len >= 2 || (b->len == 1 && b->dig[0] > 1))) { // compute b > 0; could be mpz_cmp_small_int(b, 1) > 0 + break; + } + mpz_set(&c, b); + do { + mpz_add_inpl(&c, &c, &c); + } while (mpz_cmp(&c, a) <= 0); + c.len = mpn_shr(c.dig, c.dig, c.len, 1); + mpz_sub_inpl(a, a, &c); + } + + mpz_deinit(&c); + + if (b->len == 1 && b->dig[0] == 1) { // compute b == 1; could be mpz_cmp_small_int(b, 1) == 0 + mpz_free(a); + return b; + } else { + mpz_free(b); + return a; + } +} + +/* computes lcm(z1, z2) + = abs(z1) / gcd(z1, z2) * abs(z2) + lcm(z1, z1) >= 0 + lcm(0, 0) = 0 + lcm(z, 0) = 0 +*/ +mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) { + if (z1->len == 0 || z2->len == 0) { + return mpz_zero(); + } + + mpz_t *gcd = mpz_gcd(z1, z2); + mpz_t *quo = mpz_zero(); + mpz_t *rem = mpz_zero(); + mpz_divmod_inpl(quo, rem, z1, gcd); + mpz_mul_inpl(rem, quo, z2); + mpz_free(gcd); + mpz_free(quo); + rem->neg = 0; + return rem; +} +#endif + +/* computes new integers in quo and rem such that: + quo * rhs + rem = lhs + 0 <= rem < rhs + can have lhs, rhs the same + assumes rhs != 0 (undefined behaviour if it is) +*/ +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs) { + assert(!mpz_is_zero(rhs)); + + mpz_need_dig(dest_quo, lhs->len + 1); // +1 necessary? + memset(dest_quo->dig, 0, (lhs->len + 1) * sizeof(mpz_dig_t)); + dest_quo->len = 0; + mpz_need_dig(dest_rem, lhs->len + 1); // +1 necessary? + mpz_set(dest_rem, lhs); + mpn_div(dest_rem->dig, &dest_rem->len, rhs->dig, rhs->len, dest_quo->dig, &dest_quo->len); + + // check signs and do Python style modulo + if (lhs->neg != rhs->neg) { + dest_quo->neg = 1; + if (!mpz_is_zero(dest_rem)) { + mpz_t mpzone; mpz_init_from_int(&mpzone, -1); + mpz_add_inpl(dest_quo, dest_quo, &mpzone); + mpz_add_inpl(dest_rem, dest_rem, rhs); + } + } +} + +#if 0 +these functions are unused + +/* computes floor(lhs / rhs) + can have lhs, rhs the same +*/ +mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs) { + mpz_t *quo = mpz_zero(); + mpz_t rem; mpz_init_zero(&rem); + mpz_divmod_inpl(quo, &rem, lhs, rhs); + mpz_deinit(&rem); + return quo; +} + +/* computes lhs % rhs ( >= 0) + can have lhs, rhs the same +*/ +mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs) { + mpz_t quo; mpz_init_zero(&quo); + mpz_t *rem = mpz_zero(); + mpz_divmod_inpl(&quo, rem, lhs, rhs); + mpz_deinit(&quo); + return rem; +} +#endif + +// must return actual int value if it fits in mp_int_t +mp_int_t mpz_hash(const mpz_t *z) { + mp_int_t val = 0; + mpz_dig_t *d = z->dig + z->len; + + while (d-- > z->dig) { + val = (val << DIG_SIZE) | *d; + } + + if (z->neg != 0) { + val = -val; + } + + return val; +} + +bool mpz_as_int_checked(const mpz_t *i, mp_int_t *value) { + mp_uint_t val = 0; + mpz_dig_t *d = i->dig + i->len; + + while (d-- > i->dig) { + if (val > (~(WORD_MSBIT_HIGH) >> DIG_SIZE)) { + // will overflow + return false; + } + val = (val << DIG_SIZE) | *d; + } + + if (i->neg != 0) { + val = -val; + } + + *value = val; + return true; +} + +bool mpz_as_uint_checked(const mpz_t *i, mp_uint_t *value) { + if (i->neg != 0) { + // can't represent signed values + return false; + } + + mp_uint_t val = 0; + mpz_dig_t *d = i->dig + i->len; + + while (d-- > i->dig) { + if (val > (~(WORD_MSBIT_HIGH) >> (DIG_SIZE - 1))) { + // will overflow + return false; + } + val = (val << DIG_SIZE) | *d; + } + + *value = val; + return true; +} + +// writes at most len bytes to buf (so buf should be zeroed before calling) +void mpz_as_bytes(const mpz_t *z, bool big_endian, size_t len, byte *buf) { + byte *b = buf; + if (big_endian) { + b += len; + } + mpz_dig_t *zdig = z->dig; + int bits = 0; + mpz_dbl_dig_t d = 0; + mpz_dbl_dig_t carry = 1; + for (size_t zlen = z->len; zlen > 0; --zlen) { + bits += DIG_SIZE; + d = (d << DIG_SIZE) | *zdig++; + for (; bits >= 8; bits -= 8, d >>= 8) { + mpz_dig_t val = d; + if (z->neg) { + val = (~val & 0xff) + carry; + carry = val >> 8; + } + if (big_endian) { + *--b = val; + if (b == buf) { + return; + } + } else { + *b++ = val; + if (b == buf + len) { + return; + } + } + } + } +} + +#if MICROPY_PY_BUILTINS_FLOAT +mp_float_t mpz_as_float(const mpz_t *i) { + mp_float_t val = 0; + mpz_dig_t *d = i->dig + i->len; + + while (d-- > i->dig) { + val = val * DIG_BASE + *d; + } + + if (i->neg != 0) { + val = -val; + } + + return val; +} +#endif + +#if 0 +this function is unused +char *mpz_as_str(const mpz_t *i, unsigned int base) { + char *s = m_new(char, mp_int_format_size(mpz_max_num_bits(i), base, NULL, '\0')); + mpz_as_str_inpl(i, base, NULL, 'a', '\0', s); + return s; +} +#endif + +// assumes enough space as calculated by mp_int_format_size +// returns length of string, not including null byte +size_t mpz_as_str_inpl(const mpz_t *i, unsigned int base, const char *prefix, char base_char, char comma, char *str) { + if (str == NULL) { + return 0; + } + if (base < 2 || base > 32) { + str[0] = 0; + return 0; + } + + size_t ilen = i->len; + + char *s = str; + if (ilen == 0) { + if (prefix) { + while (*prefix) + *s++ = *prefix++; + } + *s++ = '0'; + *s = '\0'; + return s - str; + } + + // make a copy of mpz digits, so we can do the div/mod calculation + mpz_dig_t *dig = m_new(mpz_dig_t, ilen); + memcpy(dig, i->dig, ilen * sizeof(mpz_dig_t)); + + // convert + char *last_comma = str; + bool done; + do { + mpz_dig_t *d = dig + ilen; + mpz_dbl_dig_t a = 0; + + // compute next remainder + while (--d >= dig) { + a = (a << DIG_SIZE) | *d; + *d = a / base; + a %= base; + } + + // convert to character + a += '0'; + if (a > '9') { + a += base_char - '9' - 1; + } + *s++ = a; + + // check if number is zero + done = true; + for (d = dig; d < dig + ilen; ++d) { + if (*d != 0) { + done = false; + break; + } + } + if (comma && (s - last_comma) == 3) { + *s++ = comma; + last_comma = s; + } + } + while (!done); + + // free the copy of the digits array + m_del(mpz_dig_t, dig, ilen); + + if (prefix) { + const char *p = &prefix[strlen(prefix)]; + while (p > prefix) { + *s++ = *--p; + } + } + if (i->neg != 0) { + *s++ = '-'; + } + + // reverse string + for (char *u = str, *v = s - 1; u < v; ++u, --v) { + char temp = *u; + *u = *v; + *v = temp; + } + + *s = '\0'; // null termination + + return s - str; +} + +#endif // MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ diff --git a/user/mpy/py/mpz.h b/user/mpy/py/mpz.h new file mode 100644 index 0000000..e2d0c30 --- /dev/null +++ b/user/mpy/py/mpz.h @@ -0,0 +1,143 @@ +/* + * 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_MPZ_H +#define MICROPY_INCLUDED_PY_MPZ_H + +#include + +#include "py/mpconfig.h" +#include "py/misc.h" + +// This mpz module implements arbitrary precision integers. +// +// The storage for each digit is defined by mpz_dig_t. The actual number of +// bits in mpz_dig_t that are used is defined by MPZ_DIG_SIZE. The machine must +// also provide a type that is twice as wide as mpz_dig_t, in both signed and +// unsigned versions. +// +// MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most +// sense to have it as large as possible. If MPZ_DIG_SIZE is not already +// defined then it is auto-detected below, depending on the machine. The types +// are then set based on the value of MPZ_DIG_SIZE (although they can be freely +// changed so long as the constraints mentioned above are met). + +#ifndef MPZ_DIG_SIZE + #if defined(__x86_64__) || defined(_WIN64) + // 64-bit machine, using 32-bit storage for digits + #define MPZ_DIG_SIZE (32) + #else + // default: 32-bit machine, using 16-bit storage for digits + #define MPZ_DIG_SIZE (16) + #endif +#endif + +#if MPZ_DIG_SIZE > 16 +typedef uint32_t mpz_dig_t; +typedef uint64_t mpz_dbl_dig_t; +typedef int64_t mpz_dbl_dig_signed_t; +#elif MPZ_DIG_SIZE > 8 +typedef uint16_t mpz_dig_t; +typedef uint32_t mpz_dbl_dig_t; +typedef int32_t mpz_dbl_dig_signed_t; +#elif MPZ_DIG_SIZE > 4 +typedef uint8_t mpz_dig_t; +typedef uint16_t mpz_dbl_dig_t; +typedef int16_t mpz_dbl_dig_signed_t; +#else +typedef uint8_t mpz_dig_t; +typedef uint8_t mpz_dbl_dig_t; +typedef int8_t mpz_dbl_dig_signed_t; +#endif + +#ifdef _WIN64 + #ifdef __MINGW32__ + #define MPZ_LONG_1 1LL + #else + #define MPZ_LONG_1 1i64 + #endif +#else + #define MPZ_LONG_1 1L +#endif + +// these define the maximum storage needed to hold an int or long long +#define MPZ_NUM_DIG_FOR_INT ((sizeof(mp_int_t) * 8 + MPZ_DIG_SIZE - 1) / MPZ_DIG_SIZE) +#define MPZ_NUM_DIG_FOR_LL ((sizeof(long long) * 8 + MPZ_DIG_SIZE - 1) / MPZ_DIG_SIZE) + +typedef struct _mpz_t { + size_t neg : 1; + size_t fixed_dig : 1; + size_t alloc : 8 * sizeof(size_t) - 2; + size_t len; + mpz_dig_t *dig; +} mpz_t; + +// convenience macro to declare an mpz with a digit array from the stack, initialised by an integer +#define MPZ_CONST_INT(z, val) mpz_t z; mpz_dig_t z ## _digits[MPZ_NUM_DIG_FOR_INT]; mpz_init_fixed_from_int(&z, z_digits, MPZ_NUM_DIG_FOR_INT, val); + +void mpz_init_zero(mpz_t *z); +void mpz_init_from_int(mpz_t *z, mp_int_t val); +void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); +void mpz_deinit(mpz_t *z); + +void mpz_set(mpz_t *dest, const mpz_t *src); +void mpz_set_from_int(mpz_t *z, mp_int_t src); +void mpz_set_from_ll(mpz_t *z, long long i, bool is_signed); +#if MICROPY_PY_BUILTINS_FLOAT +void mpz_set_from_float(mpz_t *z, mp_float_t src); +#endif +size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base); +void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf); + +static inline bool mpz_is_zero(const mpz_t *z) { return z->len == 0; } +static inline bool mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } +int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); + +void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); +void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); +void mpz_not_inpl(mpz_t *dest, const mpz_t *z); +void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); +void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); +void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); +void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); + +static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * MPZ_DIG_SIZE; } +mp_int_t mpz_hash(const mpz_t *z); +bool mpz_as_int_checked(const mpz_t *z, mp_int_t *value); +bool mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); +void mpz_as_bytes(const mpz_t *z, bool big_endian, size_t len, byte *buf); +#if MICROPY_PY_BUILTINS_FLOAT +mp_float_t mpz_as_float(const mpz_t *z); +#endif +size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); + +#endif // MICROPY_INCLUDED_PY_MPZ_H diff --git a/user/mpy/py/nativeglue.c b/user/mpy/py/nativeglue.c new file mode 100644 index 0000000..e954234 --- /dev/null +++ b/user/mpy/py/nativeglue.c @@ -0,0 +1,183 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/emitglue.h" +#include "py/bc.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +#if MICROPY_EMIT_NATIVE + +// convert a MicroPython object to a valid native value based on type +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type) { + DEBUG_printf("mp_convert_obj_to_native(%p, " UINT_FMT ")\n", obj, type); + switch (type & 0xf) { + case MP_NATIVE_TYPE_OBJ: return (mp_uint_t)obj; + case MP_NATIVE_TYPE_BOOL: + case MP_NATIVE_TYPE_INT: + case MP_NATIVE_TYPE_UINT: return mp_obj_get_int_truncated(obj); + default: { // cast obj to a pointer + mp_buffer_info_t bufinfo; + if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_RW)) { + return (mp_uint_t)bufinfo.buf; + } else { + // assume obj is an integer that represents an address + return mp_obj_get_int_truncated(obj); + } + } + } +} + +#endif + +#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM + +// convert a native value to a MicroPython object based on type +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type) { + DEBUG_printf("mp_convert_native_to_obj(" UINT_FMT ", " UINT_FMT ")\n", val, type); + switch (type & 0xf) { + case MP_NATIVE_TYPE_OBJ: return (mp_obj_t)val; + case MP_NATIVE_TYPE_BOOL: return mp_obj_new_bool(val); + case MP_NATIVE_TYPE_INT: return mp_obj_new_int(val); + case MP_NATIVE_TYPE_UINT: return mp_obj_new_int_from_uint(val); + default: // a pointer + // we return just the value of the pointer as an integer + return mp_obj_new_int_from_uint(val); + } +} + +#endif + +#if MICROPY_EMIT_NATIVE + +// wrapper that accepts n_args and n_kw in one argument +// (native emitter can only pass at most 3 arguments to a function) +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) { + return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args); +} + +// wrapper that makes raise obj and raises it +// END_FINALLY opcode requires that we don't raise if o==None +void mp_native_raise(mp_obj_t o) { + if (o != mp_const_none) { + nlr_raise(mp_make_raise_obj(o)); + } +} + +// wrapper that handles iterator buffer +STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) { + if (iter == NULL) { + return mp_getiter(obj, NULL); + } else { + obj = mp_getiter(obj, iter); + if (obj != MP_OBJ_FROM_PTR(iter)) { + // Iterator didn't use the stack so indicate that with MP_OBJ_NULL. + iter->base.type = MP_OBJ_NULL; + iter->buf[0] = obj; + } + return NULL; + } +} + +// wrapper that handles iterator buffer +STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) { + mp_obj_t obj; + if (iter->base.type == MP_OBJ_NULL) { + obj = iter->buf[0]; + } else { + obj = MP_OBJ_FROM_PTR(iter); + } + return mp_iternext(obj); +} + +// these must correspond to the respective enum in runtime0.h +void *const mp_fun_table[MP_F_NUMBER_OF] = { + mp_convert_obj_to_native, + mp_convert_native_to_obj, + mp_load_name, + mp_load_global, + mp_load_build_class, + mp_load_attr, + mp_load_method, + mp_load_super_method, + mp_store_name, + mp_store_global, + mp_store_attr, + mp_obj_subscr, + mp_obj_is_true, + mp_unary_op, + mp_binary_op, + mp_obj_new_tuple, + mp_obj_new_list, + mp_obj_list_append, + mp_obj_new_dict, + mp_obj_dict_store, +#if MICROPY_PY_BUILTINS_SET + mp_obj_new_set, + mp_obj_set_store, +#endif + mp_make_function_from_raw_code, + mp_native_call_function_n_kw, + mp_call_method_n_kw, + mp_call_method_n_kw_var, + mp_native_getiter, + mp_native_iternext, + nlr_push, + nlr_pop, + mp_native_raise, + mp_import_name, + mp_import_from, + mp_import_all, +#if MICROPY_PY_BUILTINS_SLICE + mp_obj_new_slice, +#endif + mp_unpack_sequence, + mp_unpack_ex, + mp_delete_name, + mp_delete_global, + mp_obj_new_cell, + mp_make_closure_from_raw_code, + mp_setup_code_state, +}; + +/* +void mp_f_vector(mp_fun_kind_t fun_kind) { + (mp_f_table[fun_kind])(); +} +*/ + +#endif // MICROPY_EMIT_NATIVE diff --git a/user/mpy/py/nlr.h b/user/mpy/py/nlr.h new file mode 100644 index 0000000..63fe392 --- /dev/null +++ b/user/mpy/py/nlr.h @@ -0,0 +1,115 @@ +/* + * 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 + +#include +#include +#include + +#include "py/mpconfig.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 !defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP +#if defined(__i386__) + void *regs[6]; +#elif defined(__x86_64__) + #if defined(__CYGWIN__) + void *regs[12]; + #else + void *regs[8]; + #endif +#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__) + void *regs[10]; +#elif defined(__xtensa__) + void *regs[10]; +#else + #define MICROPY_NLR_SETJMP (1) + //#warning "No native NLR support for this arch, using setjmp implementation" +#endif +#endif + +#if MICROPY_NLR_SETJMP + jmp_buf jmpbuf; +#endif +}; + +#if MICROPY_NLR_SETJMP +#include "py/mpstate.h" + +NORETURN void nlr_setjmp_jump(void *val); +// nlr_push() must be defined as a macro, because "The stack context will be +// invalidated if the function which called setjmp() returns." +#define nlr_push(buf) ((buf)->prev = MP_STATE_THREAD(nlr_top), MP_STATE_THREAD(nlr_top) = (buf), setjmp((buf)->jmpbuf)) +#define nlr_pop() { MP_STATE_THREAD(nlr_top) = MP_STATE_THREAD(nlr_top)->prev; } +#define nlr_jump(val) nlr_setjmp_jump(val) +#else +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(void); +NORETURN void nlr_jump(void *val); +#endif + +// 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 +#include "mpstate.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 !MICROPY_NLR_SETJMP +#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 +*/ +#endif + +#endif + +#endif // MICROPY_INCLUDED_PY_NLR_H diff --git a/user/mpy/py/nlrsetjmp.c b/user/mpy/py/nlrsetjmp.c new file mode 100644 index 0000000..1fb4594 --- /dev/null +++ b/user/mpy/py/nlrsetjmp.c @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#include "py/nlr.h" + +#if MICROPY_NLR_SETJMP + +void nlr_setjmp_jump(void *val) { + 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; + *top_ptr = top->prev; + longjmp(top->jmpbuf, 1); +} + +#endif diff --git a/user/mpy/py/nlrthumb.c b/user/mpy/py/nlrthumb.c new file mode 100644 index 0000000..08a71ac --- /dev/null +++ b/user/mpy/py/nlrthumb.c @@ -0,0 +1,136 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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. + */ + +#include "py/mpstate.h" +#include "py/nlr.h" + +#if (!defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP) && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) + +#undef nlr_push + +// We only need the functions here if we are on arm/thumb, and we are not +// using setjmp/longjmp. +// +// For reference, arm/thumb callee save regs are: +// r4-r11, r13=sp + +__attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) { + + __asm volatile ( + "str r4, [r0, #12] \n" // store r4 into nlr_buf + "str r5, [r0, #16] \n" // store r5 into nlr_buf + "str r6, [r0, #20] \n" // store r6 into nlr_buf + "str r7, [r0, #24] \n" // store r7 into nlr_buf + +#if defined(__ARM_ARCH_6M__) + "mov r1, r8 \n" + "str r1, [r0, #28] \n" // store r8 into nlr_buf + "mov r1, r9 \n" + "str r1, [r0, #32] \n" // store r9 into nlr_buf + "mov r1, r10 \n" + "str r1, [r0, #36] \n" // store r10 into nlr_buf + "mov r1, r11 \n" + "str r1, [r0, #40] \n" // store r11 into nlr_buf + "mov r1, r13 \n" + "str r1, [r0, #44] \n" // store r13=sp into nlr_buf + "mov r1, lr \n" + "str r1, [r0, #8] \n" // store lr into nlr_buf +#else + "str r8, [r0, #28] \n" // store r8 into nlr_buf + "str r9, [r0, #32] \n" // store r9 into nlr_buf + "str r10, [r0, #36] \n" // store r10 into nlr_buf + "str r11, [r0, #40] \n" // store r11 into nlr_buf + "str r13, [r0, #44] \n" // store r13=sp into nlr_buf + "str lr, [r0, #8] \n" // store lr into nlr_buf +#endif + + "b nlr_push_tail \n" // do the rest in C + ); + + return 0; // needed to silence compiler warning +} + +__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + nlr->prev = *top; + *top = nlr; + return 0; // normal return +} + +void nlr_pop(void) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + *top = (*top)->prev; +} + +NORETURN __attribute__((naked)) void nlr_jump(void *val) { + 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; + *top_ptr = top->prev; + + __asm volatile ( + "mov r0, %0 \n" // r0 points to nlr_buf + "ldr r4, [r0, #12] \n" // load r4 from nlr_buf + "ldr r5, [r0, #16] \n" // load r5 from nlr_buf + "ldr r6, [r0, #20] \n" // load r6 from nlr_buf + "ldr r7, [r0, #24] \n" // load r7 from nlr_buf + +#if defined(__ARM_ARCH_6M__) + "ldr r1, [r0, #28] \n" // load r8 from nlr_buf + "mov r8, r1 \n" + "ldr r1, [r0, #32] \n" // load r9 from nlr_buf + "mov r9, r1 \n" + "ldr r1, [r0, #36] \n" // load r10 from nlr_buf + "mov r10, r1 \n" + "ldr r1, [r0, #40] \n" // load r11 from nlr_buf + "mov r11, r1 \n" + "ldr r1, [r0, #44] \n" // load r13=sp from nlr_buf + "mov r13, r1 \n" + "ldr r1, [r0, #8] \n" // load lr from nlr_buf + "mov lr, r1 \n" +#else + "ldr r8, [r0, #28] \n" // load r8 from nlr_buf + "ldr r9, [r0, #32] \n" // load r9 from nlr_buf + "ldr r10, [r0, #36] \n" // load r10 from nlr_buf + "ldr r11, [r0, #40] \n" // load r11 from nlr_buf + "ldr r13, [r0, #44] \n" // load r13=sp from nlr_buf + "ldr lr, [r0, #8] \n" // load lr from nlr_buf +#endif + "movs r0, #1 \n" // return 1, non-local return + "bx lr \n" // return + : // output operands + : "r"(top) // input operands + : // clobbered registers + ); + + for (;;); // needed to silence compiler warning +} + +#endif // (!defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP) && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) diff --git a/user/mpy/py/nlrx64.c b/user/mpy/py/nlrx64.c new file mode 100644 index 0000000..c23fd8f --- /dev/null +++ b/user/mpy/py/nlrx64.c @@ -0,0 +1,136 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-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. + */ + +#include "py/mpstate.h" +#include "py/nlr.h" + +#if !MICROPY_NLR_SETJMP && defined(__x86_64__) + +#undef nlr_push + +// x86-64 callee-save registers are: +// rbx, rbp, rsp, r12, r13, r14, r15 + +#define NLR_OS_WINDOWS (defined(_WIN32) || defined(__CYGWIN__)) + +__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr); + +unsigned int nlr_push(nlr_buf_t *nlr) { + (void)nlr; + + #if NLR_OS_WINDOWS + + __asm volatile ( + "movq (%rsp), %rax \n" // load return %rip + "movq %rax, 16(%rcx) \n" // store %rip into nlr_buf + "movq %rbp, 24(%rcx) \n" // store %rbp into nlr_buf + "movq %rsp, 32(%rcx) \n" // store %rsp into nlr_buf + "movq %rbx, 40(%rcx) \n" // store %rbx into nlr_buf + "movq %r12, 48(%rcx) \n" // store %r12 into nlr_buf + "movq %r13, 56(%rcx) \n" // store %r13 into nlr_buf + "movq %r14, 64(%rcx) \n" // store %r14 into nlr_buf + "movq %r15, 72(%rcx) \n" // store %r15 into nlr_buf + "movq %rdi, 80(%rcx) \n" // store %rdr into nlr_buf + "movq %rsi, 88(%rcx) \n" // store %rsi into nlr_buf + "jmp nlr_push_tail \n" // do the rest in C + ); + + #else + + __asm volatile ( + #if defined(__APPLE__) || defined(__MACH__) + "pop %rbp \n" // undo function's prelude + #endif + "movq (%rsp), %rax \n" // load return %rip + "movq %rax, 16(%rdi) \n" // store %rip into nlr_buf + "movq %rbp, 24(%rdi) \n" // store %rbp into nlr_buf + "movq %rsp, 32(%rdi) \n" // store %rsp into nlr_buf + "movq %rbx, 40(%rdi) \n" // store %rbx into nlr_buf + "movq %r12, 48(%rdi) \n" // store %r12 into nlr_buf + "movq %r13, 56(%rdi) \n" // store %r13 into nlr_buf + "movq %r14, 64(%rdi) \n" // store %r14 into nlr_buf + "movq %r15, 72(%rdi) \n" // store %r15 into nlr_buf + #if defined(__APPLE__) || defined(__MACH__) + "jmp _nlr_push_tail \n" // do the rest in C + #else + "jmp nlr_push_tail \n" // do the rest in C + #endif + ); + + #endif + + return 0; // needed to silence compiler warning +} + +__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + nlr->prev = *top; + *top = nlr; + return 0; // normal return +} + +void nlr_pop(void) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + *top = (*top)->prev; +} + +NORETURN void nlr_jump(void *val) { + 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; + *top_ptr = top->prev; + + __asm volatile ( + "movq %0, %%rcx \n" // %rcx points to nlr_buf + #if NLR_OS_WINDOWS + "movq 88(%%rcx), %%rsi \n" // load saved %rsi + "movq 80(%%rcx), %%rdi \n" // load saved %rdr + #endif + "movq 72(%%rcx), %%r15 \n" // load saved %r15 + "movq 64(%%rcx), %%r14 \n" // load saved %r14 + "movq 56(%%rcx), %%r13 \n" // load saved %r13 + "movq 48(%%rcx), %%r12 \n" // load saved %r12 + "movq 40(%%rcx), %%rbx \n" // load saved %rbx + "movq 32(%%rcx), %%rsp \n" // load saved %rsp + "movq 24(%%rcx), %%rbp \n" // load saved %rbp + "movq 16(%%rcx), %%rax \n" // load saved %rip + "movq %%rax, (%%rsp) \n" // store saved %rip to stack + "xorq %%rax, %%rax \n" // clear return register + "inc %%al \n" // increase to make 1, non-local return + "ret \n" // return + : // output operands + : "r"(top) // input operands + : // clobbered registers + ); + + for (;;); // needed to silence compiler warning +} + +#endif // !MICROPY_NLR_SETJMP && defined(__x86_64__) diff --git a/user/mpy/py/nlrx86.c b/user/mpy/py/nlrx86.c new file mode 100644 index 0000000..58aaa1a --- /dev/null +++ b/user/mpy/py/nlrx86.c @@ -0,0 +1,113 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-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. + */ + +#include "py/mpconfig.h" +#include "py/mpstate.h" +#include "py/nlr.h" + +#if !MICROPY_NLR_SETJMP && defined(__i386__) + +#undef nlr_push + +// For reference, x86 callee save regs are: +// ebx, esi, edi, ebp, esp, eip + +#define NLR_OS_WINDOWS (defined(_WIN32) || defined(__CYGWIN__)) + +#if NLR_OS_WINDOWS +unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail"); +#else +__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr); +#endif + +unsigned int nlr_push(nlr_buf_t *nlr) { + (void)nlr; + + __asm volatile ( + // Check for Zephyr, which uses a different calling convention + // by default. + // TODE: Better support for various x86 calling conventions + // (unfortunately, __attribute__((naked)) is not supported on x86). + #ifndef __ZEPHYR__ + "pop %ebp \n" // undo function's prelude + #endif + "mov 4(%esp), %edx \n" // load nlr_buf + "mov (%esp), %eax \n" // load return %eip + "mov %eax, 8(%edx) \n" // store %eip into nlr_buf + "mov %ebp, 12(%edx) \n" // store %ebp into nlr_buf + "mov %esp, 16(%edx) \n" // store %esp into nlr_buf + "mov %ebx, 20(%edx) \n" // store %ebx into nlr_buf + "mov %edi, 24(%edx) \n" // store %edi into nlr_buf + "mov %esi, 28(%edx) \n" // store %esi into nlr_buf + "jmp nlr_push_tail \n" // do the rest in C + ); + + return 0; // needed to silence compiler warning +} + +__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + nlr->prev = *top; + *top = nlr; + return 0; // normal return +} + +void nlr_pop(void) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + *top = (*top)->prev; +} + +NORETURN void nlr_jump(void *val) { + 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; + *top_ptr = top->prev; + + __asm volatile ( + "mov %0, %%edx \n" // %edx points to nlr_buf + "mov 28(%%edx), %%esi \n" // load saved %esi + "mov 24(%%edx), %%edi \n" // load saved %edi + "mov 20(%%edx), %%ebx \n" // load saved %ebx + "mov 16(%%edx), %%esp \n" // load saved %esp + "mov 12(%%edx), %%ebp \n" // load saved %ebp + "mov 8(%%edx), %%eax \n" // load saved %eip + "mov %%eax, (%%esp) \n" // store saved %eip to stack + "xor %%eax, %%eax \n" // clear return register + "inc %%al \n" // increase to make 1, non-local return + "ret \n" // return + : // output operands + : "r"(top) // input operands + : // clobbered registers + ); + + for (;;); // needed to silence compiler warning +} + +#endif // !MICROPY_NLR_SETJMP && defined(__i386__) diff --git a/user/mpy/py/nlrxtensa.c b/user/mpy/py/nlrxtensa.c new file mode 100644 index 0000000..ccac359 --- /dev/null +++ b/user/mpy/py/nlrxtensa.c @@ -0,0 +1,103 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014-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. + */ + +#include "py/mpstate.h" +#include "py/nlr.h" + +#if !MICROPY_NLR_SETJMP && defined(__xtensa__) + +#undef nlr_push + +// Xtensa calling conventions: +// a0 = return address +// a1 = stack pointer +// a2 = first arg, return value +// a3-a7 = rest of args + +unsigned int nlr_push(nlr_buf_t *nlr) { + + __asm volatile ( + "s32i.n a0, a2, 8 \n" // save regs... + "s32i.n a1, a2, 12 \n" + "s32i.n a8, a2, 16 \n" + "s32i.n a9, a2, 20 \n" + "s32i.n a10, a2, 24 \n" + "s32i.n a11, a2, 28 \n" + "s32i.n a12, a2, 32 \n" + "s32i.n a13, a2, 36 \n" + "s32i.n a14, a2, 40 \n" + "s32i.n a15, a2, 44 \n" + "j nlr_push_tail \n" // do the rest in C + ); + + return 0; // needed to silence compiler warning +} + +__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + nlr->prev = *top; + *top = nlr; + return 0; // normal return +} + +void nlr_pop(void) { + nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); + *top = (*top)->prev; +} + +NORETURN void nlr_jump(void *val) { + 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; + *top_ptr = top->prev; + + __asm volatile ( + "mov.n a2, %0 \n" // a2 points to nlr_buf + "l32i.n a0, a2, 8 \n" // restore regs... + "l32i.n a1, a2, 12 \n" + "l32i.n a8, a2, 16 \n" + "l32i.n a9, a2, 20 \n" + "l32i.n a10, a2, 24 \n" + "l32i.n a11, a2, 28 \n" + "l32i.n a12, a2, 32 \n" + "l32i.n a13, a2, 36 \n" + "l32i.n a14, a2, 40 \n" + "l32i.n a15, a2, 44 \n" + "movi.n a2, 1 \n" // return 1, non-local return + "ret.n \n" // return + : // output operands + : "r"(top) // input operands + : // clobbered registers + ); + + for (;;); // needed to silence compiler warning +} + +#endif // !MICROPY_NLR_SETJMP && defined(__xtensa__) diff --git a/user/mpy/py/obj.c b/user/mpy/py/obj.c new file mode 100644 index 0000000..515a95b --- /dev/null +++ b/user/mpy/py/obj.c @@ -0,0 +1,513 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/objtype.h" +#include "py/objint.h" +#include "py/objstr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/stackctrl.h" +#include "py/stream.h" // for mp_obj_print + +mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { + if (MP_OBJ_IS_SMALL_INT(o_in)) { + return (mp_obj_type_t*)&mp_type_int; + } else if (MP_OBJ_IS_QSTR(o_in)) { + return (mp_obj_type_t*)&mp_type_str; + #if MICROPY_PY_BUILTINS_FLOAT + } else if (mp_obj_is_float(o_in)) { + return (mp_obj_type_t*)&mp_type_float; + #endif + } else { + const mp_obj_base_t *o = MP_OBJ_TO_PTR(o_in); + return (mp_obj_type_t*)o->type; + } +} + +const char *mp_obj_get_type_str(mp_const_obj_t o_in) { + return qstr_str(mp_obj_get_type(o_in)->name); +} + +void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + // There can be data structures nested too deep, or just recursive + MP_STACK_CHECK(); +#ifndef NDEBUG + if (o_in == MP_OBJ_NULL) { + mp_print_str(print, "(nil)"); + return; + } +#endif + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->print != NULL) { + type->print((mp_print_t*)print, o_in, kind); + } else { + mp_printf(print, "<%q>", type->name); + } +} + +void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_print_helper(MP_PYTHON_PRINTER, o_in, kind); +} + +// helper function to print an exception with traceback +void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { + if (mp_obj_is_exception_instance(exc)) { + size_t n, *values; + mp_obj_exception_get_traceback(exc, &n, &values); + if (n > 0) { + assert(n % 3 == 0); + mp_print_str(print, "Traceback (most recent call last):\n"); + for (int i = n - 3; i >= 0; i -= 3) { +#if MICROPY_ENABLE_SOURCE_LINE + mp_printf(print, " File \"%q\", line %d", values[i], (int)values[i + 1]); +#else + mp_printf(print, " File \"%q\"", values[i]); +#endif + // the block name can be NULL if it's unknown + qstr block = values[i + 2]; + if (block == MP_QSTR_NULL) { + mp_print_str(print, "\n"); + } else { + mp_printf(print, ", in %q\n", block); + } + } + } + } + mp_obj_print_helper(print, exc, PRINT_EXC); + mp_print_str(print, "\n"); +} + +bool mp_obj_is_true(mp_obj_t arg) { + if (arg == mp_const_false) { + return 0; + } else if (arg == mp_const_true) { + return 1; + } else if (arg == mp_const_none) { + return 0; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + if (MP_OBJ_SMALL_INT_VALUE(arg) == 0) { + return 0; + } else { + return 1; + } + } else { + mp_obj_type_t *type = mp_obj_get_type(arg); + if (type->unary_op != NULL) { + mp_obj_t result = type->unary_op(MP_UNARY_OP_BOOL, arg); + if (result != MP_OBJ_NULL) { + return result == mp_const_true; + } + } + + mp_obj_t len = mp_obj_len_maybe(arg); + if (len != MP_OBJ_NULL) { + // obj has a length, truth determined if len != 0 + return len != MP_OBJ_NEW_SMALL_INT(0); + } else { + // any other obj is true per Python semantics + return 1; + } + } +} + +bool mp_obj_is_callable(mp_obj_t o_in) { + mp_call_fun_t call = mp_obj_get_type(o_in)->call; + if (call != mp_obj_instance_call) { + return call != NULL; + } + return mp_obj_instance_is_callable(o_in); +} + +// This function implements the '==' operator (and so the inverse of '!='). +// +// From the Python language reference: +// (https://docs.python.org/3/reference/expressions.html#not-in) +// "The objects need not have the same type. If both are numbers, they are converted +// to a common type. Otherwise, the == and != operators always consider objects of +// different types to be unequal." +// +// This means that False==0 and True==1 are true expressions. +// +// Furthermore, from the v3.4.2 code for object.c: "Practical amendments: If rich +// comparison returns NotImplemented, == and != are decided by comparing the object +// pointer." +bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) { + if (o1 == o2) { + return true; + } + if (o1 == mp_const_none || o2 == mp_const_none) { + return false; + } + + // fast path for small ints + if (MP_OBJ_IS_SMALL_INT(o1)) { + if (MP_OBJ_IS_SMALL_INT(o2)) { + // both SMALL_INT, and not equal if we get here + return false; + } else { + mp_obj_t temp = o2; o2 = o1; o1 = temp; + // o2 is now the SMALL_INT, o1 is not + // fall through to generic op + } + } + + // fast path for strings + if (MP_OBJ_IS_STR(o1)) { + if (MP_OBJ_IS_STR(o2)) { + // both strings, use special function + return mp_obj_str_equal(o1, o2); + } else { + // a string is never equal to anything else + goto str_cmp_err; + } + } else if (MP_OBJ_IS_STR(o2)) { + // o1 is not a string (else caught above), so the objects are not equal + str_cmp_err: + #if MICROPY_PY_STR_BYTES_CMP_WARN + if (MP_OBJ_IS_TYPE(o1, &mp_type_bytes) || MP_OBJ_IS_TYPE(o2, &mp_type_bytes)) { + mp_warning("Comparison between bytes and str"); + } + #endif + return false; + } + + // generic type, call binary_op(MP_BINARY_OP_EQUAL) + mp_obj_type_t *type = mp_obj_get_type(o1); + if (type->binary_op != NULL) { + mp_obj_t r = type->binary_op(MP_BINARY_OP_EQUAL, o1, o2); + if (r != MP_OBJ_NULL) { + return r == mp_const_true ? true : false; + } + } + + // equality not implemented, and objects are not the same object, so + // they are defined as not equal + return false; +} + +mp_int_t mp_obj_get_int(mp_const_obj_t arg) { + // This function essentially performs implicit type conversion to int + // Note that Python does NOT provide implicit type conversion from + // float to int in the core expression language, try some_list[1.0]. + if (arg == mp_const_false) { + return 0; + } else if (arg == mp_const_true) { + return 1; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + return MP_OBJ_SMALL_INT_VALUE(arg); + } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { + return mp_obj_int_get_checked(arg); + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("can't convert to int"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "can't convert %s to int", mp_obj_get_type_str(arg))); + } + } +} + +mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg) { + if (MP_OBJ_IS_INT(arg)) { + return mp_obj_int_get_truncated(arg); + } else { + return mp_obj_get_int(arg); + } +} + +// returns false if arg is not of integral type +// returns true and sets *value if it is of integral type +// can throw OverflowError if arg is of integral type, but doesn't fit in a mp_int_t +bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value) { + if (arg == mp_const_false) { + *value = 0; + } else if (arg == mp_const_true) { + *value = 1; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + *value = MP_OBJ_SMALL_INT_VALUE(arg); + } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { + *value = mp_obj_int_get_checked(arg); + } else { + return false; + } + return true; +} + +#if MICROPY_PY_BUILTINS_FLOAT +mp_float_t mp_obj_get_float(mp_obj_t arg) { + if (arg == mp_const_false) { + return 0; + } else if (arg == mp_const_true) { + return 1; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + return MP_OBJ_SMALL_INT_VALUE(arg); + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { + return mp_obj_int_as_float_impl(arg); + #endif + } else if (mp_obj_is_float(arg)) { + return mp_obj_float_get(arg); + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("can't convert to float"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "can't convert %s to float", mp_obj_get_type_str(arg))); + } + } +} + +#if MICROPY_PY_BUILTINS_COMPLEX +void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) { + if (arg == mp_const_false) { + *real = 0; + *imag = 0; + } else if (arg == mp_const_true) { + *real = 1; + *imag = 0; + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + *real = MP_OBJ_SMALL_INT_VALUE(arg); + *imag = 0; + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { + *real = mp_obj_int_as_float_impl(arg); + *imag = 0; + #endif + } else if (mp_obj_is_float(arg)) { + *real = mp_obj_float_get(arg); + *imag = 0; + } else if (MP_OBJ_IS_TYPE(arg, &mp_type_complex)) { + mp_obj_complex_get(arg, real, imag); + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("can't convert to complex"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "can't convert %s to complex", mp_obj_get_type_str(arg))); + } + } +} +#endif +#endif + +// note: returned value in *items may point to the interior of a GC block +void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) { + if (MP_OBJ_IS_TYPE(o, &mp_type_tuple)) { + mp_obj_tuple_get(o, len, items); + } else if (MP_OBJ_IS_TYPE(o, &mp_type_list)) { + mp_obj_list_get(o, len, items); + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("expected tuple/list"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "object '%s' is not a tuple or list", mp_obj_get_type_str(o))); + } + } +} + +// note: returned value in *items may point to the interior of a GC block +void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) { + size_t seq_len; + mp_obj_get_array(o, &seq_len, items); + if (seq_len != len) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_ValueError("tuple/list has wrong length"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "requested length %d but object has length %d", (int)len, (int)seq_len)); + } + } +} + +// is_slice determines whether the index is a slice index +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice) { + mp_int_t i; + if (MP_OBJ_IS_SMALL_INT(index)) { + i = MP_OBJ_SMALL_INT_VALUE(index); + } else if (!mp_obj_get_int_maybe(index, &i)) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("indices must be integers"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "%q indices must be integers, not %s", + type->name, mp_obj_get_type_str(index))); + } + } + + if (i < 0) { + i += len; + } + if (is_slice) { + if (i < 0) { + i = 0; + } else if ((mp_uint_t)i > len) { + i = len; + } + } else { + if (i < 0 || (mp_uint_t)i >= len) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_msg(&mp_type_IndexError, "index out of range"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_IndexError, + "%q index out of range", type->name)); + } + } + } + + // By this point 0 <= i <= len and so fits in a size_t + return (size_t)i; +} + +mp_obj_t mp_obj_id(mp_obj_t o_in) { + mp_int_t id = (mp_int_t)o_in; + if (!MP_OBJ_IS_OBJ(o_in)) { + return mp_obj_new_int(id); + } else if (id >= 0) { + // Many OSes and CPUs have affinity for putting "user" memories + // into low half of address space, and "system" into upper half. + // We're going to take advantage of that and return small int + // (signed) for such "user" addresses. + return MP_OBJ_NEW_SMALL_INT(id); + } else { + // If that didn't work, well, let's return long int, just as + // a (big) positive value, so it will never clash with the range + // of small int returned in previous case. + return mp_obj_new_int_from_uint((mp_uint_t)id); + } +} + +// will raise a TypeError if object has no length +mp_obj_t mp_obj_len(mp_obj_t o_in) { + mp_obj_t len = mp_obj_len_maybe(o_in); + if (len == MP_OBJ_NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object has no len"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "object of type '%s' has no len()", mp_obj_get_type_str(o_in))); + } + } else { + return len; + } +} + +// may return MP_OBJ_NULL +mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { + if ( +#if !MICROPY_PY_BUILTINS_STR_UNICODE + // It's simple - unicode is slow, non-unicode is fast + MP_OBJ_IS_STR(o_in) || +#endif + MP_OBJ_IS_TYPE(o_in, &mp_type_bytes)) { + GET_STR_LEN(o_in, l); + return MP_OBJ_NEW_SMALL_INT(l); + } else { + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->unary_op != NULL) { + return type->unary_op(MP_UNARY_OP_LEN, o_in); + } else { + return MP_OBJ_NULL; + } + } +} + +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(base); + if (type->subscr != NULL) { + mp_obj_t ret = type->subscr(base, index, value); + if (ret != MP_OBJ_NULL) { + return ret; + } + // TODO: call base classes here? + } + if (value == MP_OBJ_NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object does not support item deletion"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object does not support item deletion", mp_obj_get_type_str(base))); + } + } else if (value == MP_OBJ_SENTINEL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object is not subscriptable"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not subscriptable", mp_obj_get_type_str(base))); + } + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object does not support item assignment"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object does not support item assignment", mp_obj_get_type_str(base))); + } + } +} + +// Return input argument. Useful as .getiter for objects which are +// their own iterators, etc. +mp_obj_t mp_identity(mp_obj_t self) { + return self; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity); + +mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf) { + (void)iter_buf; + return self; +} + +bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + mp_obj_type_t *type = mp_obj_get_type(obj); + if (type->buffer_p.get_buffer == NULL) { + return false; + } + int ret = type->buffer_p.get_buffer(obj, bufinfo, flags); + if (ret != 0) { + return false; + } + return true; +} + +void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + if (!mp_get_buffer(obj, bufinfo, flags)) { + mp_raise_TypeError("object with buffer protocol required"); + } +} + +mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in) { + switch (op) { + case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in); + default: return MP_OBJ_NULL; // op not supported + } +} diff --git a/user/mpy/py/obj.h b/user/mpy/py/obj.h new file mode 100644 index 0000000..22bfda0 --- /dev/null +++ b/user/mpy/py/obj.h @@ -0,0 +1,867 @@ +/* + * 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 + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/qstr.h" +#include "py/mpprint.h" + +// 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 MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D +typedef uint64_t mp_obj_t; +typedef uint64_t mp_const_obj_t; +#else +typedef void *mp_obj_t; +typedef const void *mp_const_obj_t; +#endif + +// 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. + +#ifdef NDEBUG +#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)) +#else +#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)) +#endif + +// 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 MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A + +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)) & 3) == 2); } +#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2) +#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)) + +#if MICROPY_PY_BUILTINS_FLOAT +#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 + +static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } + +#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B + +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)) & 3) == 3); } +#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2) +#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 3)) + +#if MICROPY_PY_BUILTINS_FLOAT +#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 + +static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 1) == 0); } + +#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C + +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)) + +#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); +} + +static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return (((mp_uint_t)(o)) & 0xff800007) == 0x00000006; } +#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) | 0x00000006)) + +static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 3) == 0); } + +#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + +static inline bool MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 0xffff000000000000) == 0x0001000000000000); } +#define MP_OBJ_SMALL_INT_VALUE(o) (((intptr_t)(o)) >> 1) +#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)(((uintptr_t)(small_int)) << 1) | 0x0001000000000001) + +static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) + { return ((((mp_int_t)(o)) & 0xffff000000000000) == 0x0002000000000000); } +#define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff) +#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 1) | 0x0002000000000001)) + +#if MICROPY_PY_BUILTINS_FLOAT +#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b125769 + 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 + +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 MP_ENDIANNESS_LITTLE +#define MP_ROM_PTR(p) {.u32 = {.lo = (p), .hi = NULL}} +#else +#define MP_ROM_PTR(p) {.u32 = {.lo = NULL, .hi = (p)}} +#endif + +#endif + +// 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 + +// Cast object pointer to mp_obj_t +#ifndef MP_OBJ_FROM_PTR +#define MP_OBJ_FROM_PTR(p) ((mp_obj_t)p) +#endif + +// Macros to create objects that are stored in ROM. + +#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 + +// The macros below are derived from the ones above and are used to +// check for more specific object types. + +#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 +#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_FUN(o) (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function)) + +// Note: inline functions sometimes use much more code space than the +// equivalent macros, depending on the compiler. +//static inline bool MP_OBJ_IS_TYPE(mp_const_obj_t o, const mp_obj_type_t *t) { return (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)(o))->type == (t))); } // this does not work for checking a string, use below macro for that +//static inline bool MP_OBJ_IS_INT(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || MP_OBJ_IS_TYPE(o, &mp_type_int)); } // returns true if o is a small int or long int +// Need to forward declare these for the inline function to compile. +extern const mp_obj_type_t mp_type_int; +extern const mp_obj_type_t mp_type_bool; +static inline bool mp_obj_is_integer(mp_const_obj_t o) { return MP_OBJ_IS_INT(o) || MP_OBJ_IS_TYPE(o, &mp_type_bool); } // returns true if o is bool, small int or long int +//static inline bool MP_OBJ_IS_STR(mp_const_obj_t o) { return (MP_OBJ_IS_QSTR(o) || MP_OBJ_IS_TYPE(o, &mp_type_str)); } + + +// 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_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}, false, n_args_min, MP_OBJ_FUN_ARGS_MAX, .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}, false, n_args_min, n_args_max, .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}, true, n_args_min, MP_OBJ_FUN_ARGS_MAX, .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} + +// 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; + +// TODO maybe have a truncated mp_map_t for fixed tables, since alloc=used +// put alloc last in the structure, so the truncated version does not need it +// this would save 1 ROM word for all ROM objects that have a locals_dict +// would also need a trucated dict structure + +typedef struct _mp_map_t { + size_t all_keys_are_qstrs : 1; + size_t is_fixed : 1; // a fixed array that can't be modified; must also be ordered + size_t is_ordered : 1; // an ordered array + 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; + +extern const mp_map_t mp_const_empty_map; + +static inline bool MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { 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 *); + +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_uint_t op, mp_obj_t); +typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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 { + // if we'd bother to support various versions of structure + // (with different number of fields), we can distinguish + // them with ver = sizeof(struct). Cons: overkill for *micro*? + //int ver; // ? + + void *buf; // can be NULL if len == 0 + size_t len; // in bytes + int typecode; // as per binary.h + + // Rationale: to load arbitrary-sized sprites directly to LCD + // Cons: a bit adhoc usecase + // int stride; +} 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); + +// Stream protocol +typedef struct _mp_stream_p_t { + // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values + // are implementation-dependent, but will be exposed to user, e.g. via exception). + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); + mp_uint_t is_text : 1; // default is bytes, set this for text stream +} mp_stream_p_t; + +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; + + // The name of this type. + qstr 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_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_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_TimeoutError; +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 +// The macros are for convenience only +#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)) +#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)) +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; +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_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_MemoryError_obj; +extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; + +// General API for objects + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); +mp_obj_t mp_obj_new_none(void); +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, bool make_qstr_if_not_already); +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 MICROPY_PY_BUILTINS_FLOAT +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 +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!) +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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); +mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); + +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_instance_cast_to_native_base(mp_const_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); +bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2); + +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 MICROPY_PY_BUILTINS_FLOAT +mp_float_t mp_obj_get_float(mp_obj_t self_in); +void mp_obj_get_complex(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag); +#endif +//qstr mp_obj_get_qstr(mp_obj_t arg); +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_uint_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); + +// 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); + +// 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); +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes); + +#if MICROPY_PY_BUILTINS_FLOAT +// float +#if MICROPY_FLOAT_HIGH_QUALITY_HASH +mp_int_t mp_float_hash(mp_float_t val); +#else +static inline mp_int_t mp_float_hash(mp_float_t val) { return (mp_int_t)val; } +#endif +mp_obj_t mp_obj_float_binary_op(mp_uint_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_uint_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 +#define mp_obj_is_float(o) (false) +#endif + +// 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 +struct _mp_obj_list_t; +void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); +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; +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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); + +// set +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); + +// slice +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); + +// 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; + +#define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below +typedef struct _mp_obj_fun_builtin_var_t { + mp_obj_base_t base; + bool is_kw : 1; + mp_uint_t n_args_min : 15; // inclusive + mp_uint_t n_args_max : 16; // inclusive + 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; +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); +// 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 + +// slice indexes resolved to particular sequence +typedef struct { + mp_uint_t start; + mp_uint_t stop; + mp_int_t step; +} mp_bound_slice_t; + +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); +#if MICROPY_PY_BUILTINS_SLICE +bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes); +#endif +#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)) +#define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_sz) \ + /*printf("memcpy(%p, %p, %d)\n", dest + beg, slice, slice_len * (item_sz));*/ \ + memcpy(((char*)dest) + (beg) * (item_sz), slice, slice_len * (item_sz)); \ + /*printf("memmove(%p, %p, %d)\n", dest + (beg + slice_len), dest + end, (dest_len - end) * (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) \ + /*printf("memmove(%p, %p, %d)\n", dest + beg + len_adj, dest + beg, (dest_len - beg) * (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)); + +#endif // MICROPY_INCLUDED_PY_OBJ_H diff --git a/user/mpy/py/objarray.c b/user/mpy/py/objarray.c new file mode 100644 index 0000000..a31c536 --- /dev/null +++ b/user/mpy/py/objarray.c @@ -0,0 +1,634 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/binary.h" +#include "py/objstr.h" +#include "py/objarray.h" + +#if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW + +// About memoryview object: We want to reuse as much code as possible from +// array, and keep the memoryview object 4 words in size so it fits in 1 GC +// block. Also, memoryview must keep a pointer to the base of the buffer so +// that the buffer is not GC'd if the original parent object is no longer +// around (we are assuming that all memoryview'able objects return a pointer +// which points to the start of a GC chunk). Given the above constraints we +// do the following: +// - typecode high bit is set if the buffer is read-write (else read-only) +// - free is the offset in elements to the first item in the memoryview +// - len is the length in elements +// - items points to the start of the original buffer +// Note that we don't handle the case where the original buffer might change +// size due to a resize of the original parent object. + +// make (& TYPECODE_MASK) a null operation if memorview not enabled +#if MICROPY_PY_BUILTINS_MEMORYVIEW +#define TYPECODE_MASK (0x7f) +#else +#define TYPECODE_MASK (~(size_t)0) +#endif + +STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf); +STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg); +STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in); +STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +/******************************************************************************/ +// array + +#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY +STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in); + if (o->typecode == BYTEARRAY_TYPECODE) { + mp_print_str(print, "bytearray(b"); + mp_str_print_quoted(print, o->items, o->len, true); + } else { + mp_printf(print, "array('%c'", o->typecode); + if (o->len > 0) { + mp_print_str(print, ", ["); + for (size_t i = 0; i < o->len; i++) { + if (i > 0) { + mp_print_str(print, ", "); + } + mp_obj_print_helper(print, mp_binary_get_val_array(o->typecode, o->items, i), PRINT_REPR); + } + mp_print_str(print, "]"); + } + } + mp_print_str(print, ")"); +} +#endif + +#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY +STATIC mp_obj_array_t *array_new(char typecode, size_t n) { + int typecode_size = mp_binary_get_size('@', typecode, NULL); + mp_obj_array_t *o = m_new_obj(mp_obj_array_t); + #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY + o->base.type = (typecode == BYTEARRAY_TYPECODE) ? &mp_type_bytearray : &mp_type_array; + #elif MICROPY_PY_BUILTINS_BYTEARRAY + o->base.type = &mp_type_bytearray; + #else + o->base.type = &mp_type_array; + #endif + o->typecode = typecode; + o->free = 0; + o->len = n; + o->items = m_new(byte, typecode_size * o->len); + return o; +} +#endif + +#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY +STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) { + // bytearrays can be raw-initialised from anything with the buffer protocol + // other arrays can only be raw-initialised from bytes and bytearray objects + mp_buffer_info_t bufinfo; + if (((MICROPY_PY_BUILTINS_BYTEARRAY + && typecode == BYTEARRAY_TYPECODE) + || (MICROPY_PY_ARRAY + && (MP_OBJ_IS_TYPE(initializer, &mp_type_bytes) + || (MICROPY_PY_BUILTINS_BYTEARRAY && MP_OBJ_IS_TYPE(initializer, &mp_type_bytearray))))) + && mp_get_buffer(initializer, &bufinfo, MP_BUFFER_READ)) { + // construct array from raw bytes + // we round-down the len to make it a multiple of sz (CPython raises error) + size_t sz = mp_binary_get_size('@', typecode, NULL); + size_t len = bufinfo.len / sz; + mp_obj_array_t *o = array_new(typecode, len); + memcpy(o->items, bufinfo.buf, len * sz); + return MP_OBJ_FROM_PTR(o); + } + + size_t len; + // Try to create array of exact len if initializer len is known + mp_obj_t len_in = mp_obj_len_maybe(initializer); + if (len_in == MP_OBJ_NULL) { + len = 0; + } else { + len = MP_OBJ_SMALL_INT_VALUE(len_in); + } + + mp_obj_array_t *array = array_new(typecode, len); + + mp_obj_t iterable = mp_getiter(initializer, NULL); + mp_obj_t item; + size_t i = 0; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (len == 0) { + array_append(MP_OBJ_FROM_PTR(array), item); + } else { + mp_binary_set_val_array(typecode, array->items, i++, item); + } + } + + return MP_OBJ_FROM_PTR(array); +} +#endif + +#if MICROPY_PY_ARRAY +STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 1, 2, false); + + // get typecode + const char *typecode = mp_obj_str_get_str(args[0]); + + if (n_args == 1) { + // 1 arg: make an empty array + return MP_OBJ_FROM_PTR(array_new(*typecode, 0)); + } else { + // 2 args: construct the array from the given object + return array_construct(*typecode, args[1]); + } +} +#endif + +#if MICROPY_PY_BUILTINS_BYTEARRAY +STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 1, false); + + if (n_args == 0) { + // no args: construct an empty bytearray + return MP_OBJ_FROM_PTR(array_new(BYTEARRAY_TYPECODE, 0)); + } else if (MP_OBJ_IS_INT(args[0])) { + // 1 arg, an integer: construct a blank bytearray of that length + mp_uint_t len = mp_obj_get_int(args[0]); + mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, len); + memset(o->items, 0, len); + return MP_OBJ_FROM_PTR(o); + } else { + // 1 arg: construct the bytearray from that + return array_construct(BYTEARRAY_TYPECODE, args[0]); + } +} +#endif + +#if MICROPY_PY_BUILTINS_MEMORYVIEW + +mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) { + mp_obj_array_t *self = m_new_obj(mp_obj_array_t); + self->base.type = &mp_type_memoryview; + self->typecode = typecode; + self->free = 0; + self->len = nitems; + self->items = items; + return MP_OBJ_FROM_PTR(self); +} + +STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + // TODO possibly allow memoryview constructor to take start/stop so that one + // can do memoryview(b, 4, 8) instead of memoryview(b)[4:8] (uses less RAM) + + mp_arg_check_num(n_args, n_kw, 1, 1, false); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); + + mp_obj_array_t *self = MP_OBJ_TO_PTR(mp_obj_new_memoryview(bufinfo.typecode, + bufinfo.len / mp_binary_get_size('@', bufinfo.typecode, NULL), + bufinfo.buf)); + + // test if the object can be written to + if (mp_get_buffer(args[0], &bufinfo, MP_BUFFER_RW)) { + self->typecode |= 0x80; // used to indicate writable buffer + } + + return MP_OBJ_FROM_PTR(self); +} +#endif + +STATIC mp_obj_t array_unary_op(mp_uint_t op, mp_obj_t o_in) { + mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->len != 0); + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(o->len); + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t array_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in); + switch (op) { + case MP_BINARY_OP_ADD: { + // allow to add anything that has the buffer protocol (extension to CPython) + mp_buffer_info_t lhs_bufinfo; + mp_buffer_info_t rhs_bufinfo; + array_get_buffer(lhs_in, &lhs_bufinfo, MP_BUFFER_READ); + mp_get_buffer_raise(rhs_in, &rhs_bufinfo, MP_BUFFER_READ); + + size_t sz = mp_binary_get_size('@', lhs_bufinfo.typecode, NULL); + + // convert byte count to element count (in case rhs is not multiple of sz) + size_t rhs_len = rhs_bufinfo.len / sz; + + // note: lhs->len is element count of lhs, lhs_bufinfo.len is byte count + mp_obj_array_t *res = array_new(lhs_bufinfo.typecode, lhs->len + rhs_len); + mp_seq_cat((byte*)res->items, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_len * sz, byte); + return MP_OBJ_FROM_PTR(res); + } + + case MP_BINARY_OP_INPLACE_ADD: { + #if MICROPY_PY_BUILTINS_MEMORYVIEW + if (lhs->base.type == &mp_type_memoryview) { + return MP_OBJ_NULL; // op not supported + } + #endif + array_extend(lhs_in, rhs_in); + return lhs_in; + } + + case MP_BINARY_OP_IN: { + /* NOTE `a in b` is `b.__contains__(a)` */ + mp_buffer_info_t lhs_bufinfo; + mp_buffer_info_t rhs_bufinfo; + + // Can search string only in bytearray + if (mp_get_buffer(rhs_in, &rhs_bufinfo, MP_BUFFER_READ)) { + if (!MP_OBJ_IS_TYPE(lhs_in, &mp_type_bytearray)) { + return mp_const_false; + } + array_get_buffer(lhs_in, &lhs_bufinfo, MP_BUFFER_READ); + return mp_obj_new_bool( + find_subbytes(lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len, 1) != NULL); + } + + // Otherwise, can only look for a scalar numeric value in an array + if (MP_OBJ_IS_INT(rhs_in) || mp_obj_is_float(rhs_in)) { + mp_raise_NotImplementedError(""); + } + + return mp_const_false; + } + + case MP_BINARY_OP_EQUAL: { + mp_buffer_info_t lhs_bufinfo; + mp_buffer_info_t rhs_bufinfo; + array_get_buffer(lhs_in, &lhs_bufinfo, MP_BUFFER_READ); + if (!mp_get_buffer(rhs_in, &rhs_bufinfo, MP_BUFFER_READ)) { + return mp_const_false; + } + return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len)); + } + + default: + return MP_OBJ_NULL; // op not supported + } +} + +#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY +STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) { + // self is not a memoryview, so we don't need to use (& TYPECODE_MASK) + assert((MICROPY_PY_BUILTINS_BYTEARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_bytearray)) + || (MICROPY_PY_ARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_array))); + mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->free == 0) { + size_t item_sz = mp_binary_get_size('@', self->typecode, NULL); + // TODO: alloc policy + self->free = 8; + self->items = m_renew(byte, self->items, item_sz * self->len, item_sz * (self->len + self->free)); + mp_seq_clear(self->items, self->len + 1, self->len + self->free, item_sz); + } + mp_binary_set_val_array(self->typecode, self->items, self->len, arg); + // only update length/free if set succeeded + self->len++; + self->free--; + return mp_const_none; // return None, as per CPython +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_append_obj, array_append); + +STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { + // self is not a memoryview, so we don't need to use (& TYPECODE_MASK) + assert((MICROPY_PY_BUILTINS_BYTEARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_bytearray)) + || (MICROPY_PY_ARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_array))); + mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in); + + // allow to extend by anything that has the buffer protocol (extension to CPython) + mp_buffer_info_t arg_bufinfo; + mp_get_buffer_raise(arg_in, &arg_bufinfo, MP_BUFFER_READ); + + size_t sz = mp_binary_get_size('@', self->typecode, NULL); + + // convert byte count to element count + size_t len = arg_bufinfo.len / sz; + + // make sure we have enough room to extend + // TODO: alloc policy; at the moment we go conservative + if (self->free < len) { + self->items = m_renew(byte, self->items, (self->len + self->free) * sz, (self->len + len) * sz); + self->free = 0; + } else { + self->free -= len; + } + + // extend + mp_seq_copy((byte*)self->items + self->len * sz, arg_bufinfo.buf, len * sz, byte); + self->len += len; + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); +#endif + +STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { + if (value == MP_OBJ_NULL) { + // delete item + // TODO implement + // TODO: confirmed that both bytearray and array.array support + // slice deletion + return MP_OBJ_NULL; // op not supported + } else { + mp_obj_array_t *o = MP_OBJ_TO_PTR(self_in); + if (0) { +#if MICROPY_PY_BUILTINS_SLICE + } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { + mp_bound_slice_t slice; + if (!mp_seq_get_fast_slice_indexes(o->len, index_in, &slice)) { + mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); + } + if (value != MP_OBJ_SENTINEL) { + #if MICROPY_PY_ARRAY_SLICE_ASSIGN + // Assign + size_t src_len; + void *src_items; + size_t item_sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL); + if (MP_OBJ_IS_OBJ(value) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(value))->type->subscr == array_subscr) { + // value is array, bytearray or memoryview + mp_obj_array_t *src_slice = MP_OBJ_TO_PTR(value); + if (item_sz != mp_binary_get_size('@', src_slice->typecode & TYPECODE_MASK, NULL)) { + compat_error: + mp_raise_ValueError("lhs and rhs should be compatible"); + } + src_len = src_slice->len; + src_items = src_slice->items; + #if MICROPY_PY_BUILTINS_MEMORYVIEW + if (MP_OBJ_IS_TYPE(value, &mp_type_memoryview)) { + src_items = (uint8_t*)src_items + (src_slice->free * item_sz); + } + #endif + } else if (MP_OBJ_IS_TYPE(value, &mp_type_bytes)) { + if (item_sz != 1) { + goto compat_error; + } + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); + src_len = bufinfo.len; + src_items = bufinfo.buf; + } else { + mp_raise_NotImplementedError("array/bytes required on right side"); + } + + // TODO: check src/dst compat + mp_int_t len_adj = src_len - (slice.stop - slice.start); + uint8_t* dest_items = o->items; + #if MICROPY_PY_BUILTINS_MEMORYVIEW + if (o->base.type == &mp_type_memoryview) { + if ((o->typecode & 0x80) == 0) { + // store to read-only memoryview not allowed + return MP_OBJ_NULL; + } + if (len_adj != 0) { + goto compat_error; + } + dest_items += o->free * item_sz; + } + #endif + if (len_adj > 0) { + if (len_adj > o->free) { + // TODO: alloc policy; at the moment we go conservative + o->items = m_renew(byte, o->items, (o->len + o->free) * item_sz, (o->len + len_adj) * item_sz); + o->free = 0; + dest_items = o->items; + } + mp_seq_replace_slice_grow_inplace(dest_items, o->len, + slice.start, slice.stop, src_items, src_len, len_adj, item_sz); + } else { + mp_seq_replace_slice_no_grow(dest_items, o->len, + slice.start, slice.stop, src_items, src_len, item_sz); + // Clear "freed" elements at the end of list + // TODO: This is actually only needed for typecode=='O' + mp_seq_clear(dest_items, o->len + len_adj, o->len, item_sz); + // TODO: alloc policy after shrinking + } + o->len += len_adj; + return mp_const_none; + #else + return MP_OBJ_NULL; // op not supported + #endif + } + + mp_obj_array_t *res; + size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL); + assert(sz > 0); + if (0) { + // dummy + #if MICROPY_PY_BUILTINS_MEMORYVIEW + } else if (o->base.type == &mp_type_memoryview) { + res = m_new_obj(mp_obj_array_t); + *res = *o; + res->free += slice.start; + res->len = slice.stop - slice.start; + #endif + } else { + res = array_new(o->typecode, slice.stop - slice.start); + memcpy(res->items, (uint8_t*)o->items + slice.start * sz, (slice.stop - slice.start) * sz); + } + return MP_OBJ_FROM_PTR(res); +#endif + } else { + size_t index = mp_get_index(o->base.type, o->len, index_in, false); + #if MICROPY_PY_BUILTINS_MEMORYVIEW + if (o->base.type == &mp_type_memoryview) { + index += o->free; + if (value != MP_OBJ_SENTINEL && (o->typecode & 0x80) == 0) { + // store to read-only memoryview + return MP_OBJ_NULL; + } + } + #endif + if (value == MP_OBJ_SENTINEL) { + // load + return mp_binary_get_val_array(o->typecode & TYPECODE_MASK, o->items, index); + } else { + // store + mp_binary_set_val_array(o->typecode & TYPECODE_MASK, o->items, index, value); + return mp_const_none; + } + } + } +} + +STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in); + size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL); + bufinfo->buf = o->items; + bufinfo->len = o->len * sz; + bufinfo->typecode = o->typecode & TYPECODE_MASK; + #if MICROPY_PY_BUILTINS_MEMORYVIEW + if (o->base.type == &mp_type_memoryview) { + if ((o->typecode & 0x80) == 0 && (flags & MP_BUFFER_WRITE)) { + // read-only memoryview + return 1; + } + bufinfo->buf = (uint8_t*)bufinfo->buf + (size_t)o->free * sz; + } + #else + (void)flags; + #endif + return 0; +} + +#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY +STATIC const mp_rom_map_elem_t array_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) }, + { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table); +#endif + +#if MICROPY_PY_ARRAY +const mp_obj_type_t mp_type_array = { + { &mp_type_type }, + .name = MP_QSTR_array, + .print = array_print, + .make_new = array_make_new, + .getiter = array_iterator_new, + .unary_op = array_unary_op, + .binary_op = array_binary_op, + .subscr = array_subscr, + .buffer_p = { .get_buffer = array_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&array_locals_dict, +}; +#endif + +#if MICROPY_PY_BUILTINS_BYTEARRAY +const mp_obj_type_t mp_type_bytearray = { + { &mp_type_type }, + .name = MP_QSTR_bytearray, + .print = array_print, + .make_new = bytearray_make_new, + .getiter = array_iterator_new, + .unary_op = array_unary_op, + .binary_op = array_binary_op, + .subscr = array_subscr, + .buffer_p = { .get_buffer = array_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&array_locals_dict, +}; +#endif + +#if MICROPY_PY_BUILTINS_MEMORYVIEW +const mp_obj_type_t mp_type_memoryview = { + { &mp_type_type }, + .name = MP_QSTR_memoryview, + .make_new = memoryview_make_new, + .getiter = array_iterator_new, + .unary_op = array_unary_op, + .binary_op = array_binary_op, + .subscr = array_subscr, + .buffer_p = { .get_buffer = array_get_buffer }, +}; +#endif + +/* unused +size_t mp_obj_array_len(mp_obj_t self_in) { + return ((mp_obj_array_t *)self_in)->len; +} +*/ + +#if MICROPY_PY_BUILTINS_BYTEARRAY +mp_obj_t mp_obj_new_bytearray(size_t n, void *items) { + mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n); + memcpy(o->items, items, n); + return MP_OBJ_FROM_PTR(o); +} + +// Create bytearray which references specified memory area +mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items) { + mp_obj_array_t *o = m_new_obj(mp_obj_array_t); + o->base.type = &mp_type_bytearray; + o->typecode = BYTEARRAY_TYPECODE; + o->free = 0; + o->len = n; + o->items = items; + return MP_OBJ_FROM_PTR(o); +} +#endif + +/******************************************************************************/ +// array iterator + +typedef struct _mp_obj_array_it_t { + mp_obj_base_t base; + mp_obj_array_t *array; + size_t offset; + size_t cur; +} mp_obj_array_it_t; + +STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) { + mp_obj_array_it_t *self = MP_OBJ_TO_PTR(self_in); + if (self->cur < self->array->len) { + return mp_binary_get_val_array(self->array->typecode & TYPECODE_MASK, self->array->items, self->offset + self->cur++); + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +STATIC const mp_obj_type_t array_it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = array_it_iternext, +}; + +STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_array_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_array_t *array = MP_OBJ_TO_PTR(array_in); + mp_obj_array_it_t *o = (mp_obj_array_it_t*)iter_buf; + o->base.type = &array_it_type; + o->array = array; + o->offset = 0; + o->cur = 0; + #if MICROPY_PY_BUILTINS_MEMORYVIEW + if (array->base.type == &mp_type_memoryview) { + o->offset = array->free; + } + #endif + return MP_OBJ_FROM_PTR(o); +} + +#endif // MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW diff --git a/user/mpy/py/objarray.h b/user/mpy/py/objarray.h new file mode 100644 index 0000000..0389668 --- /dev/null +++ b/user/mpy/py/objarray.h @@ -0,0 +1,42 @@ +/* + * 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. + */ +#ifndef MICROPY_INCLUDED_PY_OBJARRAY_H +#define MICROPY_INCLUDED_PY_OBJARRAY_H + +#include "py/obj.h" + +typedef struct _mp_obj_array_t { + mp_obj_base_t base; + size_t typecode : 8; + // free is number of unused elements after len used elements + // alloc size = len + free + size_t free : (8 * sizeof(size_t) - 8); + size_t len; // in elements + void *items; +} mp_obj_array_t; + +#endif // MICROPY_INCLUDED_PY_OBJARRAY_H diff --git a/user/mpy/py/objattrtuple.c b/user/mpy/py/objattrtuple.c new file mode 100644 index 0000000..3cc298d --- /dev/null +++ b/user/mpy/py/objattrtuple.c @@ -0,0 +1,95 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 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. + */ + +#include "py/objtuple.h" + +#if MICROPY_PY_ATTRTUPLE || MICROPY_PY_COLLECTIONS + +// this helper function is used by collections.namedtuple +#if !MICROPY_PY_COLLECTIONS +STATIC +#endif +void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o) { + mp_print_str(print, "("); + for (size_t i = 0; i < o->len; i++) { + if (i > 0) { + mp_print_str(print, ", "); + } + mp_printf(print, "%q=", fields[i]); + mp_obj_print_helper(print, o->items[i], PRINT_REPR); + } + mp_print_str(print, ")"); +} + +#endif + +#if MICROPY_PY_ATTRTUPLE + +STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); + const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(o->items[o->len]); + mp_obj_attrtuple_print_helper(print, fields, o); +} + +STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] == MP_OBJ_NULL) { + // load attribute + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + size_t len = self->len; + const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(self->items[len]); + for (size_t i = 0; i < len; i++) { + if (fields[i] == attr) { + dest[0] = self->items[i]; + return; + } + } + } +} + +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) { + mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, n + 1); + o->base.type = &mp_type_attrtuple; + o->len = n; + for (size_t i = 0; i < n; i++) { + o->items[i] = items[i]; + } + o->items[n] = MP_OBJ_FROM_PTR(fields); + return MP_OBJ_FROM_PTR(o); +} + +const mp_obj_type_t mp_type_attrtuple = { + { &mp_type_type }, + .name = MP_QSTR_tuple, // reuse tuple to save on a qstr + .print = mp_obj_attrtuple_print, + .unary_op = mp_obj_tuple_unary_op, + .binary_op = mp_obj_tuple_binary_op, + .attr = mp_obj_attrtuple_attr, + .subscr = mp_obj_tuple_subscr, + .getiter = mp_obj_tuple_getiter, +}; + +#endif // MICROPY_PY_ATTRTUPLE diff --git a/user/mpy/py/objbool.c b/user/mpy/py/objbool.c new file mode 100644 index 0000000..e5bc3c2 --- /dev/null +++ b/user/mpy/py/objbool.c @@ -0,0 +1,89 @@ +/* + * 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. + */ + +#include + +#include "py/obj.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +typedef struct _mp_obj_bool_t { + mp_obj_base_t base; + bool value; +} mp_obj_bool_t; + +STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_obj_bool_t *self = MP_OBJ_TO_PTR(self_in); + if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + if (self->value) { + mp_print_str(print, "true"); + } else { + mp_print_str(print, "false"); + } + } else { + if (self->value) { + mp_print_str(print, "True"); + } else { + mp_print_str(print, "False"); + } + } +} + +STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 1, false); + + if (n_args == 0) { + return mp_const_false; + } else { + return mp_obj_new_bool(mp_obj_is_true(args[0])); + } +} + +STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { + if (op == MP_UNARY_OP_LEN) { + return MP_OBJ_NULL; + } + mp_obj_bool_t *self = MP_OBJ_TO_PTR(o_in); + return mp_unary_op(op, MP_OBJ_NEW_SMALL_INT(self->value)); +} + +STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_bool_t *self = MP_OBJ_TO_PTR(lhs_in); + return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in); +} + +const mp_obj_type_t mp_type_bool = { + { &mp_type_type }, + .name = MP_QSTR_bool, + .print = bool_print, + .make_new = bool_make_new, + .unary_op = bool_unary_op, + .binary_op = bool_binary_op, +}; + +const mp_obj_bool_t mp_const_false_obj = {{&mp_type_bool}, false}; +const mp_obj_bool_t mp_const_true_obj = {{&mp_type_bool}, true}; diff --git a/user/mpy/py/objboundmeth.c b/user/mpy/py/objboundmeth.c new file mode 100644 index 0000000..890f8b1 --- /dev/null +++ b/user/mpy/py/objboundmeth.c @@ -0,0 +1,109 @@ +/* + * 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. + */ + +#include + +#include "py/obj.h" +#include "py/runtime.h" + +typedef struct _mp_obj_bound_meth_t { + mp_obj_base_t base; + mp_obj_t meth; + mp_obj_t self; +} mp_obj_bound_meth_t; + +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED +STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(o_in); + mp_printf(print, "self, PRINT_REPR); + mp_print_str(print, "."); + mp_obj_print_helper(print, o->meth, PRINT_REPR); + mp_print_str(print, ">"); +} +#endif + +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) { + // need to insert self before all other args and then call meth + size_t n_total = n_args + 2 * n_kw; + mp_obj_t *args2 = NULL; + mp_obj_t *free_args2 = NULL; + if (n_total > 4) { + // try to use heap to allocate temporary args array + args2 = m_new_maybe(mp_obj_t, 1 + n_total); + free_args2 = args2; + } + if (args2 == NULL) { + // (fallback to) use stack to allocate temporary args array + args2 = alloca(sizeof(mp_obj_t) * (1 + n_total)); + } + args2[0] = self; + memcpy(args2 + 1, args, n_total * sizeof(mp_obj_t)); + mp_obj_t res = mp_call_function_n_kw(meth, n_args + 1, n_kw, args2); + if (free_args2 != NULL) { + m_del(mp_obj_t, free_args2, 1 + n_total); + } + return res; +} + +STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in); + return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args); +} + +#if MICROPY_PY_FUNCTION_ATTRS +STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != MP_OBJ_NULL) { + // not load attribute + return; + } + if (attr == MP_QSTR___name__) { + mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(self_in); + dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth)); + } +} +#endif + +STATIC const mp_obj_type_t mp_type_bound_meth = { + { &mp_type_type }, + .name = MP_QSTR_bound_method, +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED + .print = bound_meth_print, +#endif + .call = bound_meth_call, +#if MICROPY_PY_FUNCTION_ATTRS + .attr = bound_meth_attr, +#endif +}; + +mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) { + mp_obj_bound_meth_t *o = m_new_obj(mp_obj_bound_meth_t); + o->base.type = &mp_type_bound_meth; + o->meth = meth; + o->self = self; + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objcell.c b/user/mpy/py/objcell.c new file mode 100644 index 0000000..1119064 --- /dev/null +++ b/user/mpy/py/objcell.c @@ -0,0 +1,71 @@ +/* + * 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. + */ + +#include "py/obj.h" + +typedef struct _mp_obj_cell_t { + mp_obj_base_t base; + mp_obj_t obj; +} mp_obj_cell_t; + +mp_obj_t mp_obj_cell_get(mp_obj_t self_in) { + mp_obj_cell_t *self = MP_OBJ_TO_PTR(self_in); + return self->obj; +} + +void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) { + mp_obj_cell_t *self = MP_OBJ_TO_PTR(self_in); + self->obj = obj; +} + +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED +STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_cell_t *o = MP_OBJ_TO_PTR(o_in); + mp_printf(print, "obj); + if (o->obj == MP_OBJ_NULL) { + mp_print_str(print, "(nil)"); + } else { + mp_obj_print_helper(print, o->obj, PRINT_REPR); + } + mp_print_str(print, ">"); +} +#endif + +STATIC const mp_obj_type_t mp_type_cell = { + { &mp_type_type }, + .name = MP_QSTR_, // cell representation is just value in < > +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED + .print = cell_print, +#endif +}; + +mp_obj_t mp_obj_new_cell(mp_obj_t obj) { + mp_obj_cell_t *o = m_new_obj(mp_obj_cell_t); + o->base.type = &mp_type_cell; + o->obj = obj; + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objclosure.c b/user/mpy/py/objclosure.c new file mode 100644 index 0000000..4eb9eb8 --- /dev/null +++ b/user/mpy/py/objclosure.c @@ -0,0 +1,97 @@ +/* + * 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. + */ + +#include + +#include "py/obj.h" +#include "py/runtime.h" + +typedef struct _mp_obj_closure_t { + mp_obj_base_t base; + mp_obj_t fun; + size_t n_closed; + mp_obj_t closed[]; +} mp_obj_closure_t; + +STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in); + + // need to concatenate closed-over-vars and args + + size_t n_total = self->n_closed + n_args + 2 * n_kw; + if (n_total <= 5) { + // use stack to allocate temporary args array + mp_obj_t args2[5]; + memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); + memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + return mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); + } else { + // use heap to allocate temporary args array + mp_obj_t *args2 = m_new(mp_obj_t, n_total); + memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); + memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + mp_obj_t res = mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); + m_del(mp_obj_t, args2, n_total); + return res; + } +} + +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED +STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_closure_t *o = MP_OBJ_TO_PTR(o_in); + mp_print_str(print, "fun, PRINT_REPR); + mp_printf(print, " at %p, n_closed=%u ", o, (int)o->n_closed); + for (size_t i = 0; i < o->n_closed; i++) { + if (o->closed[i] == MP_OBJ_NULL) { + mp_print_str(print, "(nil)"); + } else { + mp_obj_print_helper(print, o->closed[i], PRINT_REPR); + } + mp_print_str(print, " "); + } + mp_print_str(print, ">"); +} +#endif + +const mp_obj_type_t closure_type = { + { &mp_type_type }, + .name = MP_QSTR_closure, +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED + .print = closure_print, +#endif + .call = closure_call, +}; + +mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) { + mp_obj_closure_t *o = m_new_obj_var(mp_obj_closure_t, mp_obj_t, n_closed_over); + o->base.type = &closure_type; + o->fun = fun; + o->n_closed = n_closed_over; + memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t)); + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objcomplex.c b/user/mpy/py/objcomplex.c new file mode 100644 index 0000000..f945f35 --- /dev/null +++ b/user/mpy/py/objcomplex.c @@ -0,0 +1,256 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/parsenum.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_COMPLEX + +#include +#include "py/formatfloat.h" + +typedef struct _mp_obj_complex_t { + mp_obj_base_t base; + mp_float_t real; + mp_float_t imag; +} mp_obj_complex_t; + +STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in); +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT + char buf[16]; + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C + const int precision = 6; + #else + const int precision = 7; + #endif +#else + char buf[32]; + const int precision = 16; +#endif + if (o->real == 0) { + mp_format_float(o->imag, buf, sizeof(buf), 'g', precision, '\0'); + mp_printf(print, "%sj", buf); + } else { + mp_format_float(o->real, buf, sizeof(buf), 'g', precision, '\0'); + mp_printf(print, "(%s", buf); + if (o->imag >= 0 || isnan(o->imag)) { + mp_print_str(print, "+"); + } + mp_format_float(o->imag, buf, sizeof(buf), 'g', precision, '\0'); + mp_printf(print, "%sj)", buf); + } +} + +STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 2, false); + + switch (n_args) { + case 0: + return mp_obj_new_complex(0, 0); + + case 1: + if (MP_OBJ_IS_STR(args[0])) { + // a string, parse it + size_t l; + const char *s = mp_obj_str_get_data(args[0], &l); + return mp_parse_num_decimal(s, l, true, true, NULL); + } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { + // a complex, just return it + return args[0]; + } else { + // something else, try to cast it to a complex + return mp_obj_new_complex(mp_obj_get_float(args[0]), 0); + } + + case 2: + default: { + mp_float_t real, imag; + if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { + mp_obj_complex_get(args[0], &real, &imag); + } else { + real = mp_obj_get_float(args[0]); + imag = 0; + } + if (MP_OBJ_IS_TYPE(args[1], &mp_type_complex)) { + mp_float_t real2, imag2; + mp_obj_complex_get(args[1], &real2, &imag2); + real -= imag2; + imag += real2; + } else { + imag += mp_obj_get_float(args[1]); + } + return mp_obj_new_complex(real, imag); + } + } +} + +STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) { + mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->real != 0 || o->imag != 0); + case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(o->real) ^ mp_float_hash(o->imag)); + case MP_UNARY_OP_POSITIVE: return o_in; + case MP_UNARY_OP_NEGATIVE: return mp_obj_new_complex(-o->real, -o->imag); + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t complex_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_complex_t *lhs = MP_OBJ_TO_PTR(lhs_in); + return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in); +} + +STATIC void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != MP_OBJ_NULL) { + // not load attribute + return; + } + mp_obj_complex_t *self = MP_OBJ_TO_PTR(self_in); + if (attr == MP_QSTR_real) { + dest[0] = mp_obj_new_float(self->real); + } else if (attr == MP_QSTR_imag) { + dest[0] = mp_obj_new_float(self->imag); + } +} + +const mp_obj_type_t mp_type_complex = { + { &mp_type_type }, + .name = MP_QSTR_complex, + .print = complex_print, + .make_new = complex_make_new, + .unary_op = complex_unary_op, + .binary_op = complex_binary_op, + .attr = complex_attr, +}; + +mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag) { + mp_obj_complex_t *o = m_new_obj(mp_obj_complex_t); + o->base.type = &mp_type_complex; + o->real = real; + o->imag = imag; + return MP_OBJ_FROM_PTR(o); +} + +void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_complex)); + mp_obj_complex_t *self = MP_OBJ_TO_PTR(self_in); + *real = self->real; + *imag = self->imag; +} + +mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in) { + mp_float_t rhs_real, rhs_imag; + mp_obj_get_complex(rhs_in, &rhs_real, &rhs_imag); // can be any type, this function will convert to float (if possible) + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: + lhs_real += rhs_real; + lhs_imag += rhs_imag; + break; + case MP_BINARY_OP_SUBTRACT: + case MP_BINARY_OP_INPLACE_SUBTRACT: + lhs_real -= rhs_real; + lhs_imag -= rhs_imag; + break; + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: { + mp_float_t real; + multiply: + real = lhs_real * rhs_real - lhs_imag * rhs_imag; + lhs_imag = lhs_real * rhs_imag + lhs_imag * rhs_real; + lhs_real = real; + break; + } + case MP_BINARY_OP_FLOOR_DIVIDE: + case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: + mp_raise_TypeError("can't do truncated division of a complex number"); + + case MP_BINARY_OP_TRUE_DIVIDE: + case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: + if (rhs_imag == 0) { + if (rhs_real == 0) { + mp_raise_msg(&mp_type_ZeroDivisionError, "complex division by zero"); + } + lhs_real /= rhs_real; + lhs_imag /= rhs_real; + } else if (rhs_real == 0) { + mp_float_t real = lhs_imag / rhs_imag; + lhs_imag = -lhs_real / rhs_imag; + lhs_real = real; + } else { + mp_float_t rhs_len_sq = rhs_real*rhs_real + rhs_imag*rhs_imag; + rhs_real /= rhs_len_sq; + rhs_imag /= -rhs_len_sq; + goto multiply; + } + break; + + case MP_BINARY_OP_POWER: + case MP_BINARY_OP_INPLACE_POWER: { + // z1**z2 = exp(z2*ln(z1)) + // = exp(z2*(ln(|z1|)+i*arg(z1))) + // = exp( (x2*ln1 - y2*arg1) + i*(y2*ln1 + x2*arg1) ) + // = exp(x3 + i*y3) + // = exp(x3)*(cos(y3) + i*sin(y3)) + mp_float_t abs1 = MICROPY_FLOAT_C_FUN(sqrt)(lhs_real*lhs_real + lhs_imag*lhs_imag); + if (abs1 == 0) { + if (rhs_imag == 0 && rhs_real >= 0) { + lhs_real = (rhs_real == 0); + rhs_real = 0; + } else { + mp_raise_msg(&mp_type_ZeroDivisionError, "0.0 to a complex power"); + } + } else { + mp_float_t ln1 = MICROPY_FLOAT_C_FUN(log)(abs1); + mp_float_t arg1 = MICROPY_FLOAT_C_FUN(atan2)(lhs_imag, lhs_real); + mp_float_t x3 = rhs_real * ln1 - rhs_imag * arg1; + mp_float_t y3 = rhs_imag * ln1 + rhs_real * arg1; + mp_float_t exp_x3 = MICROPY_FLOAT_C_FUN(exp)(x3); + lhs_real = exp_x3 * MICROPY_FLOAT_C_FUN(cos)(y3); + lhs_imag = exp_x3 * MICROPY_FLOAT_C_FUN(sin)(y3); + } + break; + } + + case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_real == rhs_real && lhs_imag == rhs_imag); + + default: + return MP_OBJ_NULL; // op not supported + } + return mp_obj_new_complex(lhs_real, lhs_imag); +} + +#endif diff --git a/user/mpy/py/objdict.c b/user/mpy/py/objdict.c new file mode 100644 index 0000000..f6357a9 --- /dev/null +++ b/user/mpy/py/objdict.c @@ -0,0 +1,615 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/objtype.h" + +#define MP_OBJ_IS_DICT_TYPE(o) (MP_OBJ_IS_OBJ(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new) + +STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); + +// This is a helper function to iterate through a dictionary. The state of +// the iteration is held in *cur and should be initialised with zero for the +// first call. Will return NULL when no more elements are available. +STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) { + size_t max = dict->map.alloc; + mp_map_t *map = &dict->map; + + for (size_t i = *cur; i < max; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + *cur = i + 1; + return &(map->table[i]); + } + } + + return NULL; +} + +STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + bool first = true; + if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { + kind = PRINT_REPR; + } + if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) { + mp_printf(print, "%q(", self->base.type->name); + } + mp_print_str(print, "{"); + size_t cur = 0; + mp_map_elem_t *next = NULL; + while ((next = dict_iter_next(self, &cur)) != NULL) { + if (!first) { + mp_print_str(print, ", "); + } + first = false; + mp_obj_print_helper(print, next->key, kind); + mp_print_str(print, ": "); + mp_obj_print_helper(print, next->value, kind); + } + mp_print_str(print, "}"); + if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) { + mp_print_str(print, ")"); + } +} + +STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_t dict_out = mp_obj_new_dict(0); + mp_obj_dict_t *dict = MP_OBJ_TO_PTR(dict_out); + dict->base.type = type; + #if MICROPY_PY_COLLECTIONS_ORDEREDDICT + if (type == &mp_type_ordereddict) { + dict->map.is_ordered = 1; + } + #endif + if (n_args > 0 || n_kw > 0) { + mp_obj_t args2[2] = {dict_out, args[0]}; // args[0] is always valid, even if it's not a positional arg + mp_map_t kwargs; + mp_map_init_fixed_table(&kwargs, n_kw, args + n_args); + dict_update(n_args + 1, args2, &kwargs); // dict_update will check that n_args + 1 == 1 or 2 + } + return dict_out; +} + +STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0); + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->map.used); + #if MICROPY_PY_SYS_GETSIZEOF + case MP_UNARY_OP_SIZEOF: { + size_t sz = sizeof(*self) + sizeof(*self->map.table) * self->map.alloc; + return MP_OBJ_NEW_SMALL_INT(sz); + } + #endif + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in); + switch (op) { + case MP_BINARY_OP_IN: { + mp_map_elem_t *elem = mp_map_lookup(&o->map, rhs_in, MP_MAP_LOOKUP); + return mp_obj_new_bool(elem != NULL); + } + case MP_BINARY_OP_EQUAL: { + #if MICROPY_PY_COLLECTIONS_ORDEREDDICT + if (MP_UNLIKELY(MP_OBJ_IS_TYPE(lhs_in, &mp_type_ordereddict) && MP_OBJ_IS_TYPE(rhs_in, &mp_type_ordereddict))) { + // Iterate through both dictionaries simultaneously and compare keys and values. + mp_obj_dict_t *rhs = MP_OBJ_TO_PTR(rhs_in); + size_t c1 = 0, c2 = 0; + mp_map_elem_t *e1 = dict_iter_next(o, &c1), *e2 = dict_iter_next(rhs, &c2); + for (; e1 != NULL && e2 != NULL; e1 = dict_iter_next(o, &c1), e2 = dict_iter_next(rhs, &c2)) { + if (!mp_obj_equal(e1->key, e2->key) || !mp_obj_equal(e1->value, e2->value)) { + return mp_const_false; + } + } + return e1 == NULL && e2 == NULL ? mp_const_true : mp_const_false; + } else + #endif + if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_dict)) { + mp_obj_dict_t *rhs = MP_OBJ_TO_PTR(rhs_in); + if (o->map.used != rhs->map.used) { + return mp_const_false; + } + + size_t cur = 0; + mp_map_elem_t *next = NULL; + while ((next = dict_iter_next(o, &cur)) != NULL) { + mp_map_elem_t *elem = mp_map_lookup(&rhs->map, next->key, MP_MAP_LOOKUP); + if (elem == NULL || !mp_obj_equal(next->value, elem->value)) { + return mp_const_false; + } + } + return mp_const_true; + } else { + // dict is not equal to instance of any other type + return mp_const_false; + } + } + default: + // op not supported + return MP_OBJ_NULL; + } +} + +// TODO: Make sure this is inlined in dict_subscr() below. +mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); + if (elem == NULL) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, index)); + } else { + return elem->value; + } +} + +STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_NULL) { + // delete + mp_obj_dict_delete(self_in, index); + return mp_const_none; + } else if (value == MP_OBJ_SENTINEL) { + // load + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); + if (elem == NULL) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, index)); + } else { + return elem->value; + } + } else { + // store + mp_obj_dict_store(self_in, index, value); + return mp_const_none; + } +} + +/******************************************************************************/ +/* dict iterator */ + +typedef struct _mp_obj_dict_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t dict; + size_t cur; +} mp_obj_dict_it_t; + +STATIC mp_obj_t dict_it_iternext(mp_obj_t self_in) { + mp_obj_dict_it_t *self = MP_OBJ_TO_PTR(self_in); + mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur); + + if (next == NULL) { + return MP_OBJ_STOP_ITERATION; + } else { + return next->key; + } +} + +STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_dict_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_dict_it_t *o = (mp_obj_dict_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = dict_it_iternext; + o->dict = self_in; + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} + +/******************************************************************************/ +/* dict methods */ + +STATIC mp_obj_t dict_clear(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + + mp_map_clear(&self->map); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear); + +STATIC mp_obj_t dict_copy(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t other_out = mp_obj_new_dict(self->map.alloc); + mp_obj_dict_t *other = MP_OBJ_TO_PTR(other_out); + other->base.type = self->base.type; + other->map.used = self->map.used; + other->map.all_keys_are_qstrs = self->map.all_keys_are_qstrs; + other->map.is_fixed = 0; + other->map.is_ordered = self->map.is_ordered; + memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t)); + return other_out; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, dict_copy); + +// this is a classmethod +STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) { + mp_obj_t iter = mp_getiter(args[1], NULL); + mp_obj_t value = mp_const_none; + mp_obj_t next = MP_OBJ_NULL; + + if (n_args > 2) { + value = args[2]; + } + + // optimisation to allocate result based on len of argument + mp_obj_t self_out; + mp_obj_t len = mp_obj_len_maybe(args[1]); + if (len == MP_OBJ_NULL) { + /* object's type doesn't have a __len__ slot */ + self_out = mp_obj_new_dict(0); + } else { + self_out = mp_obj_new_dict(MP_OBJ_SMALL_INT_VALUE(len)); + } + + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_out); + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + mp_map_lookup(&self->map, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + } + + return self_out; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys); +STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj)); + +STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(args[0])); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]); + mp_map_elem_t *elem = mp_map_lookup(&self->map, args[1], lookup_kind); + mp_obj_t value; + if (elem == NULL || elem->value == MP_OBJ_NULL) { + if (n_args == 2) { + if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, args[1])); + } else { + value = mp_const_none; + } + } else { + value = args[2]; + } + if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { + elem->value = value; + } + } else { + value = elem->value; + if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { + elem->value = MP_OBJ_NULL; // so that GC can collect the deleted value + } + } + return value; +} + +STATIC mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) { + return dict_get_helper(n_args, args, MP_MAP_LOOKUP); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get); + +STATIC mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) { + return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop); + +STATIC mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) { + return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault); + +STATIC mp_obj_t dict_popitem(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + size_t cur = 0; + mp_map_elem_t *next = dict_iter_next(self, &cur); + if (next == NULL) { + mp_raise_msg(&mp_type_KeyError, "popitem(): dictionary is empty"); + } + self->map.used--; + mp_obj_t items[] = {next->key, next->value}; + next->key = MP_OBJ_SENTINEL; // must mark key as sentinel to indicate that it was deleted + next->value = MP_OBJ_NULL; + mp_obj_t tuple = mp_obj_new_tuple(2, items); + + return tuple; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem); + +STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(args[0])); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]); + + mp_arg_check_num(n_args, kwargs->used, 1, 2, true); + + if (n_args == 2) { + // given a positional argument + + if (MP_OBJ_IS_DICT_TYPE(args[1])) { + // update from other dictionary (make sure other is not self) + if (args[1] != args[0]) { + size_t cur = 0; + mp_map_elem_t *elem = NULL; + while ((elem = dict_iter_next((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[1]), &cur)) != NULL) { + mp_map_lookup(&self->map, elem->key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = elem->value; + } + } + } else { + // update from a generic iterable of pairs + mp_obj_t iter = mp_getiter(args[1], NULL); + mp_obj_t next = MP_OBJ_NULL; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + mp_obj_t inneriter = mp_getiter(next, NULL); + mp_obj_t key = mp_iternext(inneriter); + mp_obj_t value = mp_iternext(inneriter); + mp_obj_t stop = mp_iternext(inneriter); + if (key == MP_OBJ_STOP_ITERATION + || value == MP_OBJ_STOP_ITERATION + || stop != MP_OBJ_STOP_ITERATION) { + mp_raise_ValueError("dict update sequence has wrong length"); + } else { + mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + } + } + } + } + + // update the dict with any keyword args + for (size_t i = 0; i < kwargs->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) { + mp_map_lookup(&self->map, kwargs->table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = kwargs->table[i].value; + } + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update); + + +/******************************************************************************/ +/* dict views */ + +STATIC const mp_obj_type_t dict_view_type; +STATIC const mp_obj_type_t dict_view_it_type; + +typedef enum _mp_dict_view_kind_t { + MP_DICT_VIEW_ITEMS, + MP_DICT_VIEW_KEYS, + MP_DICT_VIEW_VALUES, +} mp_dict_view_kind_t; + +STATIC const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"}; + +typedef struct _mp_obj_dict_view_it_t { + mp_obj_base_t base; + mp_dict_view_kind_t kind; + mp_obj_t dict; + size_t cur; +} mp_obj_dict_view_it_t; + +typedef struct _mp_obj_dict_view_t { + mp_obj_base_t base; + mp_obj_t dict; + mp_dict_view_kind_t kind; +} mp_obj_dict_view_t; + +STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &dict_view_it_type)); + mp_obj_dict_view_it_t *self = MP_OBJ_TO_PTR(self_in); + mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur); + + if (next == NULL) { + return MP_OBJ_STOP_ITERATION; + } else { + switch (self->kind) { + case MP_DICT_VIEW_ITEMS: + default: { + mp_obj_t items[] = {next->key, next->value}; + return mp_obj_new_tuple(2, items); + } + case MP_DICT_VIEW_KEYS: + return next->key; + case MP_DICT_VIEW_VALUES: + return next->value; + } + } +} + +STATIC const mp_obj_type_t dict_view_it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = dict_view_it_iternext, +}; + +STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_check_self(MP_OBJ_IS_TYPE(view_in, &dict_view_type)); + mp_obj_dict_view_t *view = MP_OBJ_TO_PTR(view_in); + mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t*)iter_buf; + o->base.type = &dict_view_it_type; + o->kind = view->kind; + o->dict = view->dict; + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} + +STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_check_self(MP_OBJ_IS_TYPE(self_in, &dict_view_type)); + mp_obj_dict_view_t *self = MP_OBJ_TO_PTR(self_in); + bool first = true; + mp_print_str(print, mp_dict_view_names[self->kind]); + mp_print_str(print, "(["); + mp_obj_iter_buf_t iter_buf; + mp_obj_t self_iter = dict_view_getiter(self_in, &iter_buf); + mp_obj_t next = MP_OBJ_NULL; + while ((next = dict_view_it_iternext(self_iter)) != MP_OBJ_STOP_ITERATION) { + if (!first) { + mp_print_str(print, ", "); + } + first = false; + mp_obj_print_helper(print, next, PRINT_REPR); + } + mp_print_str(print, "])"); +} + +STATIC mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + // only supported for the 'keys' kind until sets and dicts are refactored + mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in); + if (o->kind != MP_DICT_VIEW_KEYS) { + return MP_OBJ_NULL; // op not supported + } + if (op != MP_BINARY_OP_IN) { + return MP_OBJ_NULL; // op not supported + } + return dict_binary_op(op, o->dict, rhs_in); +} + +STATIC const mp_obj_type_t dict_view_type = { + { &mp_type_type }, + .name = MP_QSTR_dict_view, + .print = dict_view_print, + .binary_op = dict_view_binary_op, + .getiter = dict_view_getiter, +}; + +STATIC mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) { + mp_obj_dict_view_t *o = m_new_obj(mp_obj_dict_view_t); + o->base.type = &dict_view_type; + o->dict = dict; + o->kind = kind; + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); + return mp_obj_new_dict_view(self_in, kind); +} + +STATIC mp_obj_t dict_items(mp_obj_t self_in) { + return dict_view(self_in, MP_DICT_VIEW_ITEMS); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items); + +STATIC mp_obj_t dict_keys(mp_obj_t self_in) { + return dict_view(self_in, MP_DICT_VIEW_KEYS); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys); + +STATIC mp_obj_t dict_values(mp_obj_t self_in) { + return dict_view(self_in, MP_DICT_VIEW_VALUES); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values); + +/******************************************************************************/ +/* dict constructors & public C API */ + +STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&dict_clear_obj) }, + { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&dict_copy_obj) }, + { MP_ROM_QSTR(MP_QSTR_fromkeys), MP_ROM_PTR(&dict_fromkeys_obj) }, + { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&dict_get_obj) }, + { MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&dict_items_obj) }, + { MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&dict_keys_obj) }, + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&dict_pop_obj) }, + { MP_ROM_QSTR(MP_QSTR_popitem), MP_ROM_PTR(&dict_popitem_obj) }, + { MP_ROM_QSTR(MP_QSTR_setdefault), MP_ROM_PTR(&dict_setdefault_obj) }, + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&dict_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_values), MP_ROM_PTR(&dict_values_obj) }, + { MP_ROM_QSTR(MP_QSTR___getitem__), MP_ROM_PTR(&mp_op_getitem_obj) }, + { MP_ROM_QSTR(MP_QSTR___setitem__), MP_ROM_PTR(&mp_op_setitem_obj) }, + { MP_ROM_QSTR(MP_QSTR___delitem__), MP_ROM_PTR(&mp_op_delitem_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table); + +const mp_obj_type_t mp_type_dict = { + { &mp_type_type }, + .name = MP_QSTR_dict, + .print = dict_print, + .make_new = dict_make_new, + .unary_op = dict_unary_op, + .binary_op = dict_binary_op, + .subscr = dict_subscr, + .getiter = dict_getiter, + .locals_dict = (mp_obj_dict_t*)&dict_locals_dict, +}; + +#if MICROPY_PY_COLLECTIONS_ORDEREDDICT +const mp_obj_type_t mp_type_ordereddict = { + { &mp_type_type }, + .name = MP_QSTR_OrderedDict, + .print = dict_print, + .make_new = dict_make_new, + .unary_op = dict_unary_op, + .binary_op = dict_binary_op, + .subscr = dict_subscr, + .getiter = dict_getiter, + .parent = &mp_type_dict, + .locals_dict = (mp_obj_dict_t*)&dict_locals_dict, +}; +#endif + +void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args) { + dict->base.type = &mp_type_dict; + mp_map_init(&dict->map, n_args); +} + +mp_obj_t mp_obj_new_dict(size_t n_args) { + mp_obj_dict_t *o = m_new_obj(mp_obj_dict_t); + mp_obj_dict_init(o, n_args); + return MP_OBJ_FROM_PTR(o); +} + +size_t mp_obj_dict_len(mp_obj_t self_in) { + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + return self->map.used; +} + +mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + return self_in; +} + +mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key) { + mp_obj_t args[2] = {self_in, key}; + dict_get_helper(2, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); + return self_in; +} + +mp_map_t *mp_obj_dict_get_map(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); + mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); + return &self->map; +} diff --git a/user/mpy/py/objenumerate.c b/user/mpy/py/objenumerate.c new file mode 100644 index 0000000..1a9d30f --- /dev/null +++ b/user/mpy/py/objenumerate.c @@ -0,0 +1,92 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_ENUMERATE + +typedef struct _mp_obj_enumerate_t { + mp_obj_base_t base; + mp_obj_t iter; + mp_int_t cur; +} mp_obj_enumerate_t; + +STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in); + +STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +#if MICROPY_CPYTHON_COMPAT + static const mp_arg_t allowed_args[] = { + { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_start, MP_ARG_INT, {.u_int = 0} }, + }; + + // parse args + struct { + mp_arg_val_t iterable, start; + } arg_vals; + mp_arg_parse_all_kw_array(n_args, n_kw, args, + MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&arg_vals); + + // create enumerate object + mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); + o->base.type = type; + o->iter = mp_getiter(arg_vals.iterable.u_obj, NULL); + o->cur = arg_vals.start.u_int; +#else + (void)n_kw; + mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); + o->base.type = type; + o->iter = mp_getiter(args[0], NULL); + o->cur = n_args > 1 ? mp_obj_get_int(args[1]) : 0; +#endif + + return MP_OBJ_FROM_PTR(o); +} + +const mp_obj_type_t mp_type_enumerate = { + { &mp_type_type }, + .name = MP_QSTR_enumerate, + .make_new = enumerate_make_new, + .iternext = enumerate_iternext, + .getiter = mp_identity_getiter, +}; + +STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_enumerate)); + mp_obj_enumerate_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t next = mp_iternext(self->iter); + if (next == MP_OBJ_STOP_ITERATION) { + return MP_OBJ_STOP_ITERATION; + } else { + mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(self->cur++), next}; + return mp_obj_new_tuple(2, items); + } +} + +#endif // MICROPY_PY_BUILTINS_ENUMERATE diff --git a/user/mpy/py/objexcept.c b/user/mpy/py/objexcept.c new file mode 100644 index 0000000..a9fe040 --- /dev/null +++ b/user/mpy/py/objexcept.c @@ -0,0 +1,479 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/mpstate.h" +#include "py/objlist.h" +#include "py/objstr.h" +#include "py/objtuple.h" +#include "py/objtype.h" +#include "py/runtime.h" +#include "py/gc.h" +#include "py/mperrno.h" + +// Instance of MemoryError exception - needed by mp_malloc_fail +const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; + +// Optionally allocated buffer for storing the first argument of an exception +// allocated when the heap is locked. +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF +# if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0 +#define mp_emergency_exception_buf_size MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE + +void mp_init_emergency_exception_buf(void) { + // Nothing to do since the buffer was declared statically. We put this + // definition here so that the calling code can call this function + // regardless of how its configured (makes the calling code a bit cleaner). +} + +#else +#define mp_emergency_exception_buf_size MP_STATE_VM(mp_emergency_exception_buf_size) + +void mp_init_emergency_exception_buf(void) { + mp_emergency_exception_buf_size = 0; + MP_STATE_VM(mp_emergency_exception_buf) = NULL; +} + +mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in) { + mp_int_t size = mp_obj_get_int(size_in); + void *buf = NULL; + if (size > 0) { + buf = m_new(byte, size); + } + + int old_size = mp_emergency_exception_buf_size; + void *old_buf = MP_STATE_VM(mp_emergency_exception_buf); + + // Update the 2 variables atomically so that an interrupt can't occur + // between the assignments. + mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); + mp_emergency_exception_buf_size = size; + MP_STATE_VM(mp_emergency_exception_buf) = buf; + MICROPY_END_ATOMIC_SECTION(atomic_state); + + if (old_buf != NULL) { + m_del(byte, old_buf, old_size); + } + return mp_const_none; +} +#endif +#endif // MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF + +// Instance of GeneratorExit exception - needed by generator.close() +// This would belong to objgenerator.c, but to keep mp_obj_exception_t +// definition module-private so far, have it here. +const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; + +STATIC void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_exception_t *o = MP_OBJ_TO_PTR(o_in); + mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; + bool is_subclass = kind & PRINT_EXC_SUBCLASS; + if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) { + mp_print_str(print, qstr_str(o->base.type->name)); + } + + if (k == PRINT_EXC) { + mp_print_str(print, ": "); + } + + if (k == PRINT_STR || k == PRINT_EXC) { + if (o->args == NULL || o->args->len == 0) { + mp_print_str(print, ""); + return; + } else if (o->args->len == 1) { + #if MICROPY_PY_UERRNO + // try to provide a nice OSError error message + if (o->base.type == &mp_type_OSError && MP_OBJ_IS_SMALL_INT(o->args->items[0])) { + qstr qst = mp_errno_to_str(o->args->items[0]); + if (qst != MP_QSTR_NULL) { + mp_printf(print, "[Errno %d] %q", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), qst); + return; + } + } + #endif + mp_obj_print_helper(print, o->args->items[0], PRINT_STR); + return; + } + } + mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind); +} + +mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); + mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0); + if (o == NULL) { + // Couldn't allocate heap memory; use local data instead. + o = &MP_STATE_VM(mp_emergency_exception_obj); + // We can't store any args. + o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; + } else { + o->args = MP_OBJ_TO_PTR(mp_obj_new_tuple(n_args, args)); + } + o->base.type = type; + o->traceback_data = NULL; + return MP_OBJ_FROM_PTR(o); +} + +// Get exception "value" - that is, first argument, or None +mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) { + mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in); + if (self->args->len == 0) { + return mp_const_none; + } else { + return self->args->items[0]; + } +} + +STATIC void exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in); + if (dest[0] != MP_OBJ_NULL) { + // store/delete attribute + if (attr == MP_QSTR___traceback__ && dest[1] == mp_const_none) { + // We allow 'exc.__traceback__ = None' assignment as low-level + // optimization of pre-allocating exception instance and raising + // it repeatedly - this avoids memory allocation during raise. + // However, uPy will keep adding traceback entries to such + // exception instance, so before throwing it, traceback should + // be cleared like above. + self->traceback_len = 0; + dest[0] = MP_OBJ_NULL; // indicate success + } + return; + } + if (attr == MP_QSTR_args) { + dest[0] = MP_OBJ_FROM_PTR(self->args); + } else if (self->base.type == &mp_type_StopIteration && attr == MP_QSTR_value) { + dest[0] = mp_obj_exception_get_value(self_in); + } +} + +STATIC mp_obj_t exc___init__(size_t n_args, const mp_obj_t *args) { + mp_obj_exception_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_t argst = mp_obj_new_tuple(n_args - 1, args + 1); + self->args = MP_OBJ_TO_PTR(argst); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(exc___init___obj, 1, MP_OBJ_FUN_ARGS_MAX, exc___init__); + +STATIC const mp_rom_map_elem_t exc_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&exc___init___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(exc_locals_dict, exc_locals_dict_table); + +const mp_obj_type_t mp_type_BaseException = { + { &mp_type_type }, + .name = MP_QSTR_BaseException, + .print = mp_obj_exception_print, + .make_new = mp_obj_exception_make_new, + .attr = exception_attr, + .locals_dict = (mp_obj_dict_t*)&exc_locals_dict, +}; + +#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 = exception_attr, \ + .parent = &mp_type_ ## base_name, \ +}; + +// List of all exceptions, arranged as in the table at: +// http://docs.python.org/3/library/exceptions.html +MP_DEFINE_EXCEPTION(SystemExit, BaseException) +MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException) +MP_DEFINE_EXCEPTION(GeneratorExit, BaseException) +MP_DEFINE_EXCEPTION(Exception, BaseException) + #if MICROPY_PY_ASYNC_AWAIT + MP_DEFINE_EXCEPTION(StopAsyncIteration, Exception) + #endif + MP_DEFINE_EXCEPTION(StopIteration, Exception) + MP_DEFINE_EXCEPTION(ArithmeticError, Exception) + //MP_DEFINE_EXCEPTION(FloatingPointError, ArithmeticError) + MP_DEFINE_EXCEPTION(OverflowError, ArithmeticError) + MP_DEFINE_EXCEPTION(ZeroDivisionError, ArithmeticError) + MP_DEFINE_EXCEPTION(AssertionError, Exception) + MP_DEFINE_EXCEPTION(AttributeError, Exception) + //MP_DEFINE_EXCEPTION(BufferError, Exception) + //MP_DEFINE_EXCEPTION(EnvironmentError, Exception) use OSError instead + MP_DEFINE_EXCEPTION(EOFError, Exception) + MP_DEFINE_EXCEPTION(ImportError, Exception) + //MP_DEFINE_EXCEPTION(IOError, Exception) use OSError instead + MP_DEFINE_EXCEPTION(LookupError, Exception) + MP_DEFINE_EXCEPTION(IndexError, LookupError) + MP_DEFINE_EXCEPTION(KeyError, LookupError) + MP_DEFINE_EXCEPTION(MemoryError, Exception) + MP_DEFINE_EXCEPTION(NameError, Exception) + /* + MP_DEFINE_EXCEPTION(UnboundLocalError, NameError) + */ + MP_DEFINE_EXCEPTION(OSError, Exception) +#if MICROPY_PY_BUILTINS_TIMEOUTERROR + MP_DEFINE_EXCEPTION(TimeoutError, OSError) +#endif + /* + MP_DEFINE_EXCEPTION(BlockingIOError, OSError) + MP_DEFINE_EXCEPTION(ChildProcessError, OSError) + MP_DEFINE_EXCEPTION(ConnectionError, OSError) + MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError) + MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError) + MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError) + MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError) + MP_DEFINE_EXCEPTION(InterruptedError, OSError) + MP_DEFINE_EXCEPTION(IsADirectoryError, OSError) + MP_DEFINE_EXCEPTION(NotADirectoryError, OSError) + MP_DEFINE_EXCEPTION(PermissionError, OSError) + MP_DEFINE_EXCEPTION(ProcessLookupError, OSError) + MP_DEFINE_EXCEPTION(FileExistsError, OSError) + MP_DEFINE_EXCEPTION(FileNotFoundError, OSError) + MP_DEFINE_EXCEPTION(ReferenceError, Exception) + */ + MP_DEFINE_EXCEPTION(RuntimeError, Exception) + MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError) + MP_DEFINE_EXCEPTION(SyntaxError, Exception) + MP_DEFINE_EXCEPTION(IndentationError, SyntaxError) + /* + MP_DEFINE_EXCEPTION(TabError, IndentationError) + */ + //MP_DEFINE_EXCEPTION(SystemError, Exception) + MP_DEFINE_EXCEPTION(TypeError, Exception) +#if MICROPY_EMIT_NATIVE + MP_DEFINE_EXCEPTION(ViperTypeError, TypeError) +#endif + MP_DEFINE_EXCEPTION(ValueError, Exception) +#if MICROPY_PY_BUILTINS_STR_UNICODE + MP_DEFINE_EXCEPTION(UnicodeError, ValueError) + //TODO: Implement more UnicodeError subclasses which take arguments +#endif + /* + MP_DEFINE_EXCEPTION(Warning, Exception) + MP_DEFINE_EXCEPTION(DeprecationWarning, Warning) + MP_DEFINE_EXCEPTION(PendingDeprecationWarning, Warning) + MP_DEFINE_EXCEPTION(RuntimeWarning, Warning) + MP_DEFINE_EXCEPTION(SyntaxWarning, Warning) + MP_DEFINE_EXCEPTION(UserWarning, Warning) + MP_DEFINE_EXCEPTION(FutureWarning, Warning) + MP_DEFINE_EXCEPTION(ImportWarning, Warning) + MP_DEFINE_EXCEPTION(UnicodeWarning, Warning) + MP_DEFINE_EXCEPTION(BytesWarning, Warning) + MP_DEFINE_EXCEPTION(ResourceWarning, Warning) + */ + +mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) { + return mp_obj_new_exception_args(exc_type, 0, NULL); +} + +// "Optimized" version for common(?) case of having 1 exception arg +mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { + return mp_obj_new_exception_args(exc_type, 1, &arg); +} + +mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args) { + assert(exc_type->make_new == mp_obj_exception_make_new); + return exc_type->make_new(exc_type, n_args, 0, args); +} + +mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg) { + return mp_obj_new_exception_msg_varg(exc_type, msg); +} + +mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...) { + // check that the given type is an exception type + assert(exc_type->make_new == mp_obj_exception_make_new); + + // make exception object + mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0); + if (o == NULL) { + // Couldn't allocate heap memory; use local data instead. + // Unfortunately, we won't be able to format the string... + o = &MP_STATE_VM(mp_emergency_exception_obj); + o->base.type = exc_type; + o->traceback_data = NULL; + o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; + +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF + // If the user has provided a buffer, then we try to create a tuple + // of length 1, which has a string object and the string data. + + if (mp_emergency_exception_buf_size > (sizeof(mp_obj_tuple_t) + sizeof(mp_obj_str_t) + sizeof(mp_obj_t))) { + mp_obj_tuple_t *tuple = (mp_obj_tuple_t *)MP_STATE_VM(mp_emergency_exception_buf); + mp_obj_str_t *str = (mp_obj_str_t *)&tuple->items[1]; + + tuple->base.type = &mp_type_tuple; + tuple->len = 1; + tuple->items[0] = MP_OBJ_FROM_PTR(str); + + byte *str_data = (byte *)&str[1]; + size_t max_len = (byte*)MP_STATE_VM(mp_emergency_exception_buf) + mp_emergency_exception_buf_size + - str_data; + + vstr_t vstr; + vstr_init_fixed_buf(&vstr, max_len, (char *)str_data); + + va_list ap; + va_start(ap, fmt); + vstr_vprintf(&vstr, fmt, ap); + va_end(ap); + + str->base.type = &mp_type_str; + str->hash = qstr_compute_hash(str_data, str->len); + str->len = vstr.len; + str->data = str_data; + + o->args = tuple; + + size_t offset = &str_data[str->len] - (byte*)MP_STATE_VM(mp_emergency_exception_buf); + offset += sizeof(void *) - 1; + offset &= ~(sizeof(void *) - 1); + + if ((mp_emergency_exception_buf_size - offset) > (sizeof(o->traceback_data[0]) * 3)) { + // We have room to store some traceback. + o->traceback_data = (size_t*)((byte *)MP_STATE_VM(mp_emergency_exception_buf) + offset); + o->traceback_alloc = ((byte*)MP_STATE_VM(mp_emergency_exception_buf) + mp_emergency_exception_buf_size - (byte *)o->traceback_data) / sizeof(o->traceback_data[0]); + o->traceback_len = 0; + } + } +#endif // MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF + } else { + o->base.type = exc_type; + o->traceback_data = NULL; + o->args = MP_OBJ_TO_PTR(mp_obj_new_tuple(1, NULL)); + + assert(fmt != NULL); + { + if (strchr(fmt, '%') == NULL) { + // no formatting substitutions, avoid allocating vstr. + o->args->items[0] = mp_obj_new_str(fmt, strlen(fmt), false); + } else { + // render exception message and store as .args[0] + va_list ap; + vstr_t vstr; + vstr_init(&vstr, 16); + va_start(ap, fmt); + vstr_vprintf(&vstr, fmt, ap); + va_end(ap); + o->args->items[0] = mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + } + } + } + + return MP_OBJ_FROM_PTR(o); +} + +// return true if the given object is an exception type +bool mp_obj_is_exception_type(mp_obj_t self_in) { + if (MP_OBJ_IS_TYPE(self_in, &mp_type_type)) { + // optimisation when self_in is a builtin exception + mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); + if (self->make_new == mp_obj_exception_make_new) { + return true; + } + } + return mp_obj_is_subclass_fast(self_in, MP_OBJ_FROM_PTR(&mp_type_BaseException)); +} + +// return true if the given object is an instance of an exception type +bool mp_obj_is_exception_instance(mp_obj_t self_in) { + return mp_obj_is_exception_type(MP_OBJ_FROM_PTR(mp_obj_get_type(self_in))); +} + +// Return true if exception (type or instance) is a subclass of given +// exception type. Assumes exc_type is a subclass of BaseException, as +// defined by mp_obj_is_exception_type(exc_type). +bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { + // if exc is an instance of an exception, then extract and use its type + if (mp_obj_is_exception_instance(exc)) { + exc = MP_OBJ_FROM_PTR(mp_obj_get_type(exc)); + } + return mp_obj_is_subclass_fast(exc, exc_type); +} + +// traceback handling functions + +#define GET_NATIVE_EXCEPTION(self, self_in) \ + /* make sure self_in is an exception instance */ \ + assert(mp_obj_is_exception_instance(self_in)); \ + mp_obj_exception_t *self; \ + if (mp_obj_is_native_exception_instance(self_in)) { \ + self = MP_OBJ_TO_PTR(self_in); \ + } else { \ + self = MP_OBJ_TO_PTR(((mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in))->subobj[0]); \ + } + +void mp_obj_exception_clear_traceback(mp_obj_t self_in) { + GET_NATIVE_EXCEPTION(self, self_in); + // just set the traceback to the null object + // we don't want to call any memory management functions here + self->traceback_data = NULL; +} + +void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { + GET_NATIVE_EXCEPTION(self, self_in); + + // append this traceback info to traceback data + // if memory allocation fails (eg because gc is locked), just return + + if (self->traceback_data == NULL) { + self->traceback_data = m_new_maybe(size_t, 3); + if (self->traceback_data == NULL) { + return; + } + self->traceback_alloc = 3; + self->traceback_len = 0; + } else if (self->traceback_len + 3 > self->traceback_alloc) { + // be conservative with growing traceback data + size_t *tb_data = m_renew_maybe(size_t, self->traceback_data, self->traceback_alloc, self->traceback_alloc + 3, true); + if (tb_data == NULL) { + return; + } + self->traceback_data = tb_data; + self->traceback_alloc += 3; + } + + size_t *tb_data = &self->traceback_data[self->traceback_len]; + self->traceback_len += 3; + tb_data[0] = file; + tb_data[1] = line; + tb_data[2] = block; +} + +void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values) { + GET_NATIVE_EXCEPTION(self, self_in); + + if (self->traceback_data == NULL) { + *n = 0; + *values = NULL; + } else { + *n = self->traceback_len; + *values = self->traceback_data; + } +} diff --git a/user/mpy/py/objexcept.h b/user/mpy/py/objexcept.h new file mode 100644 index 0000000..f67651a --- /dev/null +++ b/user/mpy/py/objexcept.h @@ -0,0 +1,40 @@ +/* + * 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 + +#include "py/obj.h" +#include "py/objtuple.h" + +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; + +#endif // MICROPY_INCLUDED_PY_OBJEXCEPT_H diff --git a/user/mpy/py/objfilter.c b/user/mpy/py/objfilter.c new file mode 100644 index 0000000..cb965d8 --- /dev/null +++ b/user/mpy/py/objfilter.c @@ -0,0 +1,72 @@ +/* + * 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. + */ + +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_FILTER + +typedef struct _mp_obj_filter_t { + mp_obj_base_t base; + mp_obj_t fun; + mp_obj_t iter; +} mp_obj_filter_t; + +STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 2, false); + mp_obj_filter_t *o = m_new_obj(mp_obj_filter_t); + o->base.type = type; + o->fun = args[0]; + o->iter = mp_getiter(args[1], NULL); + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t filter_iternext(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_filter)); + mp_obj_filter_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t next; + while ((next = mp_iternext(self->iter)) != MP_OBJ_STOP_ITERATION) { + mp_obj_t val; + if (self->fun != mp_const_none) { + val = mp_call_function_n_kw(self->fun, 1, 0, &next); + } else { + val = next; + } + if (mp_obj_is_true(val)) { + return next; + } + } + return MP_OBJ_STOP_ITERATION; +} + +const mp_obj_type_t mp_type_filter = { + { &mp_type_type }, + .name = MP_QSTR_filter, + .make_new = filter_make_new, + .getiter = mp_identity_getiter, + .iternext = filter_iternext, +}; + +#endif // MICROPY_PY_BUILTINS_FILTER diff --git a/user/mpy/py/objfloat.c b/user/mpy/py/objfloat.c new file mode 100644 index 0000000..15edd81 --- /dev/null +++ b/user/mpy/py/objfloat.c @@ -0,0 +1,314 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/nlr.h" +#include "py/parsenum.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_FLOAT + +#include +#include "py/formatfloat.h" + +#if MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_C && MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D + +// M_E and M_PI are not part of the math.h standard and may not be defined +#ifndef M_E +#define M_E (2.7182818284590452354) +#endif +#ifndef M_PI +#define M_PI (3.14159265358979323846) +#endif + +typedef struct _mp_obj_float_t { + mp_obj_base_t base; + mp_float_t value; +} mp_obj_float_t; + +const mp_obj_float_t mp_const_float_e_obj = {{&mp_type_float}, M_E}; +const mp_obj_float_t mp_const_float_pi_obj = {{&mp_type_float}, M_PI}; + +#endif + +#if MICROPY_FLOAT_HIGH_QUALITY_HASH +// must return actual integer value if it fits in mp_int_t +mp_int_t mp_float_hash(mp_float_t src) { +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE +typedef uint64_t mp_float_uint_t; +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT +typedef uint32_t mp_float_uint_t; +#endif + union { + mp_float_t f; + #if MP_ENDIANNESS_LITTLE + struct { mp_float_uint_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; + #else + struct { mp_float_uint_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; + #endif + mp_float_uint_t i; + } u = {.f = src}; + + mp_int_t val; + const int adj_exp = (int)u.p.exp - MP_FLOAT_EXP_BIAS; + if (adj_exp < 0) { + // value < 1; must be sure to handle 0.0 correctly (ie return 0) + val = u.i; + } else { + // if adj_exp is max then: u.p.frc==0 indicates inf, else NaN + // else: 1 <= value + mp_float_uint_t frc = u.p.frc | ((mp_float_uint_t)1 << MP_FLOAT_FRAC_BITS); + + if (adj_exp <= MP_FLOAT_FRAC_BITS) { + // number may have a fraction; xor the integer part with the fractional part + val = (frc >> (MP_FLOAT_FRAC_BITS - adj_exp)) + ^ (frc & ((1 << (MP_FLOAT_FRAC_BITS - adj_exp)) - 1)); + } else if ((unsigned int)adj_exp < BITS_PER_BYTE * sizeof(mp_int_t) - 1) { + // the number is a (big) whole integer and will fit in val's signed-width + val = (mp_int_t)frc << (adj_exp - MP_FLOAT_FRAC_BITS); + } else { + // integer part will overflow val's width so just use what bits we can + val = frc; + } + } + + if (u.p.sgn) { + val = -val; + } + + return val; +} +#endif + +STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_float_t o_val = mp_obj_float_get(o_in); +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT + char buf[16]; + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C + const int precision = 6; + #else + const int precision = 7; + #endif +#else + char buf[32]; + const int precision = 16; +#endif + mp_format_float(o_val, buf, sizeof(buf), 'g', precision, '\0'); + mp_print_str(print, buf); + if (strchr(buf, '.') == NULL && strchr(buf, 'e') == NULL && strchr(buf, 'n') == NULL) { + // Python floats always have decimal point (unless inf or nan) + mp_print_str(print, ".0"); + } +} + +STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 1, false); + + switch (n_args) { + case 0: + return mp_obj_new_float(0); + + case 1: + default: + if (MP_OBJ_IS_STR(args[0])) { + // a string, parse it + size_t l; + const char *s = mp_obj_str_get_data(args[0], &l); + return mp_parse_num_decimal(s, l, false, false, NULL); + } else if (mp_obj_is_float(args[0])) { + // a float, just return it + return args[0]; + } else { + // something else, try to cast it to a float + return mp_obj_new_float(mp_obj_get_float(args[0])); + } + } +} + +STATIC mp_obj_t float_unary_op(mp_uint_t op, mp_obj_t o_in) { + mp_float_t val = mp_obj_float_get(o_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(val != 0); + case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(val)); + case MP_UNARY_OP_POSITIVE: return o_in; + case MP_UNARY_OP_NEGATIVE: return mp_obj_new_float(-val); + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t float_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_float_t lhs_val = mp_obj_float_get(lhs_in); +#if MICROPY_PY_BUILTINS_COMPLEX + if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) { + return mp_obj_complex_binary_op(op, lhs_val, 0, rhs_in); + } else +#endif + { + return mp_obj_float_binary_op(op, lhs_val, rhs_in); + } +} + +const mp_obj_type_t mp_type_float = { + { &mp_type_type }, + .name = MP_QSTR_float, + .print = float_print, + .make_new = float_make_new, + .unary_op = float_unary_op, + .binary_op = float_binary_op, +}; + +#if MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_C && MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D + +mp_obj_t mp_obj_new_float(mp_float_t value) { + mp_obj_float_t *o = m_new(mp_obj_float_t, 1); + o->base.type = &mp_type_float; + o->value = value; + return MP_OBJ_FROM_PTR(o); +} + +mp_float_t mp_obj_float_get(mp_obj_t self_in) { + assert(mp_obj_is_float(self_in)); + mp_obj_float_t *self = MP_OBJ_TO_PTR(self_in); + return self->value; +} + +#endif + +STATIC void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) { + // logic here follows that of CPython + // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations + // x == (x//y)*y + (x%y) + // divmod(x, y) == (x//y, x%y) + mp_float_t mod = MICROPY_FLOAT_C_FUN(fmod)(*x, *y); + mp_float_t div = (*x - mod) / *y; + + // Python specs require that mod has same sign as second operand + if (mod == 0.0) { + mod = MICROPY_FLOAT_C_FUN(copysign)(0.0, *y); + } else { + if ((mod < 0.0) != (*y < 0.0)) { + mod += *y; + div -= 1.0; + } + } + + mp_float_t floordiv; + if (div == 0.0) { + // if division is zero, take the correct sign of zero + floordiv = MICROPY_FLOAT_C_FUN(copysign)(0.0, *x / *y); + } else { + // Python specs require that x == (x//y)*y + (x%y) + floordiv = MICROPY_FLOAT_C_FUN(floor)(div); + if (div - floordiv > 0.5) { + floordiv += 1.0; + } + } + + // return results + *x = floordiv; + *y = mod; +} + +mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs_in) { + mp_float_t rhs_val = mp_obj_get_float(rhs_in); // can be any type, this function will convert to float (if possible) + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break; + case MP_BINARY_OP_SUBTRACT: + case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break; + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: lhs_val *= rhs_val; break; + case MP_BINARY_OP_FLOOR_DIVIDE: + case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: + if (rhs_val == 0) { + zero_division_error: + mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); + } + // Python specs require that x == (x//y)*y + (x%y) so we must + // call divmod to compute the correct floor division, which + // returns the floor divide in lhs_val. + mp_obj_float_divmod(&lhs_val, &rhs_val); + break; + case MP_BINARY_OP_TRUE_DIVIDE: + case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: + if (rhs_val == 0) { + goto zero_division_error; + } + lhs_val /= rhs_val; + break; + case MP_BINARY_OP_MODULO: + case MP_BINARY_OP_INPLACE_MODULO: + if (rhs_val == 0) { + goto zero_division_error; + } + lhs_val = MICROPY_FLOAT_C_FUN(fmod)(lhs_val, rhs_val); + // Python specs require that mod has same sign as second operand + if (lhs_val == 0.0) { + lhs_val = MICROPY_FLOAT_C_FUN(copysign)(0.0, rhs_val); + } else { + if ((lhs_val < 0.0) != (rhs_val < 0.0)) { + lhs_val += rhs_val; + } + } + break; + case MP_BINARY_OP_POWER: + case MP_BINARY_OP_INPLACE_POWER: + if (lhs_val == 0 && rhs_val < 0) { + goto zero_division_error; + } + lhs_val = MICROPY_FLOAT_C_FUN(pow)(lhs_val, rhs_val); + break; + case MP_BINARY_OP_DIVMOD: { + if (rhs_val == 0) { + goto zero_division_error; + } + mp_obj_float_divmod(&lhs_val, &rhs_val); + mp_obj_t tuple[2] = { + mp_obj_new_float(lhs_val), + mp_obj_new_float(rhs_val), + }; + return mp_obj_new_tuple(2, tuple); + } + case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val); + case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val); + case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_val == rhs_val); + case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val); + case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val); + + default: + return MP_OBJ_NULL; // op not supported + } + return mp_obj_new_float(lhs_val); +} + +#endif // MICROPY_PY_BUILTINS_FLOAT diff --git a/user/mpy/py/objfun.c b/user/mpy/py/objfun.c new file mode 100644 index 0000000..5606511 --- /dev/null +++ b/user/mpy/py/objfun.c @@ -0,0 +1,573 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objtuple.h" +#include "py/objfun.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/bc.h" +#include "py/stackctrl.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#else // don't print debugging info +#define DEBUG_PRINT (0) +#define DEBUG_printf(...) (void)0 +#endif + +// Note: the "name" entry in mp_obj_type_t for a function type must be +// MP_QSTR_function because it is used to determine if an object is of generic +// function type. + +/******************************************************************************/ +/* builtin functions */ + +STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)args; + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_0)); + mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); + mp_arg_check_num(n_args, n_kw, 0, 0, false); + return self->fun._0(); +} + +const mp_obj_type_t mp_type_fun_builtin_0 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_0_call, + .unary_op = mp_generic_unary_op, +}; + +STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_1)); + mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); + mp_arg_check_num(n_args, n_kw, 1, 1, false); + return self->fun._1(args[0]); +} + +const mp_obj_type_t mp_type_fun_builtin_1 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_1_call, + .unary_op = mp_generic_unary_op, +}; + +STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_2)); + mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); + mp_arg_check_num(n_args, n_kw, 2, 2, false); + return self->fun._2(args[0], args[1]); +} + +const mp_obj_type_t mp_type_fun_builtin_2 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_2_call, + .unary_op = mp_generic_unary_op, +}; + +STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_3)); + mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); + mp_arg_check_num(n_args, n_kw, 3, 3, false); + return self->fun._3(args[0], args[1], args[2]); +} + +const mp_obj_type_t mp_type_fun_builtin_3 = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_3_call, + .unary_op = mp_generic_unary_op, +}; + +STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_var)); + mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in); + + // check number of arguments + mp_arg_check_num(n_args, n_kw, self->n_args_min, self->n_args_max, self->is_kw); + + if (self->is_kw) { + // function allows keywords + + // we create a map directly from the given args array + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); + + return self->fun.kw(n_args, args, &kw_args); + + } else { + // function takes a variable number of arguments, but no keywords + + return self->fun.var(n_args, args); + } +} + +const mp_obj_type_t mp_type_fun_builtin_var = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_builtin_var_call, + .unary_op = mp_generic_unary_op, +}; + +/******************************************************************************/ +/* byte code functions */ + +qstr mp_obj_code_get_name(const byte *code_info) { + code_info = mp_decode_uint_skip(code_info); // skip code_info_size entry + #if MICROPY_PERSISTENT_CODE + return code_info[0] | (code_info[1] << 8); + #else + return mp_decode_uint_value(code_info); + #endif +} + +#if MICROPY_EMIT_NATIVE +STATIC const mp_obj_type_t mp_type_fun_native; +#endif + +qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) { + const mp_obj_fun_bc_t *fun = MP_OBJ_TO_PTR(fun_in); + #if MICROPY_EMIT_NATIVE + if (fun->base.type == &mp_type_fun_native) { + // TODO native functions don't have name stored + return MP_QSTR_; + } + #endif + + const byte *bc = fun->bytecode; + bc = mp_decode_uint_skip(bc); // skip n_state + bc = mp_decode_uint_skip(bc); // skip n_exc_stack + bc++; // skip scope_params + bc++; // skip n_pos_args + bc++; // skip n_kwonly_args + bc++; // skip n_def_pos_args + return mp_obj_code_get_name(bc); +} + +#if MICROPY_CPYTHON_COMPAT +STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in); + mp_printf(print, "", mp_obj_fun_get_name(o_in), o); +} +#endif + +#if DEBUG_PRINT +STATIC void dump_args(const mp_obj_t *a, size_t sz) { + DEBUG_printf("%p: ", a); + for (size_t i = 0; i < sz; i++) { + DEBUG_printf("%p ", a[i]); + } + DEBUG_printf("\n"); +} +#else +#define dump_args(...) (void)0 +#endif + +// With this macro you can tune the maximum number of function state bytes +// that will be allocated on the stack. Any function that needs more +// than this will try to use the heap, with fallback to stack allocation. +#define VM_MAX_STATE_ON_STACK (11 * sizeof(mp_uint_t)) + +// Set this to enable a simple stack overflow check. +#define VM_DETECT_STACK_OVERFLOW (0) + +#if MICROPY_STACKLESS +mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + MP_STACK_CHECK(); + mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in); + + // bytecode prelude: state size and exception stack size + size_t n_state = mp_decode_uint_value(self->bytecode); + size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode)); + + // allocate state for locals and stack + size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t); + mp_code_state_t *code_state; + code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size); + if (!code_state) { + return NULL; + } + + code_state->fun_bc = self; + code_state->ip = 0; + mp_setup_code_state(code_state, n_args, n_kw, args); + + // execute the byte code with the correct globals context + code_state->old_globals = mp_globals_get(); + mp_globals_set(self->globals); + + return code_state; +} +#endif + +STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + MP_STACK_CHECK(); + + DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw); + DEBUG_printf("Input pos args: "); + dump_args(args, n_args); + DEBUG_printf("Input kw args: "); + dump_args(args + n_args, n_kw * 2); + mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in); + DEBUG_printf("Func n_def_args: %d\n", self->n_def_args); + + // bytecode prelude: state size and exception stack size + size_t n_state = mp_decode_uint_value(self->bytecode); + size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode)); + +#if VM_DETECT_STACK_OVERFLOW + n_state += 1; +#endif + + // allocate state for locals and stack + size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t); + mp_code_state_t *code_state = NULL; + if (state_size > VM_MAX_STATE_ON_STACK) { + code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size); + } + if (code_state == NULL) { + code_state = alloca(sizeof(mp_code_state_t) + state_size); + state_size = 0; // indicate that we allocated using alloca + } + + code_state->fun_bc = self; + code_state->ip = 0; + mp_setup_code_state(code_state, n_args, n_kw, args); + + // execute the byte code with the correct globals context + code_state->old_globals = mp_globals_get(); + mp_globals_set(self->globals); + mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode(code_state, MP_OBJ_NULL); + mp_globals_set(code_state->old_globals); + +#if VM_DETECT_STACK_OVERFLOW + if (vm_return_kind == MP_VM_RETURN_NORMAL) { + if (code_state->sp < code_state->state) { + printf("VM stack underflow: " INT_FMT "\n", code_state->sp - code_state->state); + assert(0); + } + } + // We can't check the case when an exception is returned in state[n_state - 1] + // and there are no arguments, because in this case our detection slot may have + // been overwritten by the returned exception (which is allowed). + if (!(vm_return_kind == MP_VM_RETURN_EXCEPTION && self->n_pos_args + self->n_kwonly_args == 0)) { + // Just check to see that we have at least 1 null object left in the state. + bool overflow = true; + for (size_t i = 0; i < n_state - self->n_pos_args - self->n_kwonly_args; i++) { + if (code_state->state[i] == MP_OBJ_NULL) { + overflow = false; + break; + } + } + if (overflow) { + printf("VM stack overflow state=%p n_state+1=" UINT_FMT "\n", code_state->state, n_state); + assert(0); + } + } +#endif + + mp_obj_t result; + if (vm_return_kind == MP_VM_RETURN_NORMAL) { + // return value is in *sp + result = *code_state->sp; + } else { + // must be an exception because normal functions can't yield + assert(vm_return_kind == MP_VM_RETURN_EXCEPTION); + // return value is in fastn[0]==state[n_state - 1] + result = code_state->state[n_state - 1]; + } + + // free the state if it was allocated on the heap + if (state_size != 0) { + m_del_var(mp_code_state_t, byte, state_size, code_state); + } + + if (vm_return_kind == MP_VM_RETURN_NORMAL) { + return result; + } else { // MP_VM_RETURN_EXCEPTION + nlr_raise(result); + } +} + +#if MICROPY_PY_FUNCTION_ATTRS +STATIC void fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != MP_OBJ_NULL) { + // not load attribute + return; + } + if (attr == MP_QSTR___name__) { + dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(self_in)); + } +} +#endif + +const mp_obj_type_t mp_type_fun_bc = { + { &mp_type_type }, + .name = MP_QSTR_function, +#if MICROPY_CPYTHON_COMPAT + .print = fun_bc_print, +#endif + .call = fun_bc_call, + .unary_op = mp_generic_unary_op, +#if MICROPY_PY_FUNCTION_ATTRS + .attr = fun_bc_attr, +#endif +}; + +mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) { + size_t n_def_args = 0; + size_t n_extra_args = 0; + mp_obj_tuple_t *def_args = MP_OBJ_TO_PTR(def_args_in); + if (def_args_in != MP_OBJ_NULL) { + assert(MP_OBJ_IS_TYPE(def_args_in, &mp_type_tuple)); + n_def_args = def_args->len; + n_extra_args = def_args->len; + } + if (def_kw_args != MP_OBJ_NULL) { + n_extra_args += 1; + } + mp_obj_fun_bc_t *o = m_new_obj_var(mp_obj_fun_bc_t, mp_obj_t, n_extra_args); + o->base.type = &mp_type_fun_bc; + o->globals = mp_globals_get(); + o->bytecode = code; + o->const_table = const_table; + if (def_args != NULL) { + memcpy(o->extra_args, def_args->items, n_def_args * sizeof(mp_obj_t)); + } + if (def_kw_args != MP_OBJ_NULL) { + o->extra_args[n_def_args] = def_kw_args; + } + return MP_OBJ_FROM_PTR(o); +} + +/******************************************************************************/ +/* native functions */ + +#if MICROPY_EMIT_NATIVE + +STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + MP_STACK_CHECK(); + mp_obj_fun_bc_t *self = self_in; + mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void*)self->bytecode); + return fun(self_in, n_args, n_kw, args); +} + +STATIC const mp_obj_type_t mp_type_fun_native = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_native_call, + .unary_op = mp_generic_unary_op, +}; + +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_fun_bc_t *o = mp_obj_new_fun_bc(def_args_in, def_kw_args, (const byte*)fun_data, const_table); + o->base.type = &mp_type_fun_native; + return o; +} + +#endif // MICROPY_EMIT_NATIVE + +/******************************************************************************/ +/* viper functions */ + +#if MICROPY_EMIT_NATIVE + +typedef struct _mp_obj_fun_viper_t { + mp_obj_base_t base; + size_t n_args; + void *fun_data; // GC must be able to trace this pointer + mp_uint_t type_sig; +} mp_obj_fun_viper_t; + +typedef mp_uint_t (*viper_fun_0_t)(void); +typedef mp_uint_t (*viper_fun_1_t)(mp_uint_t); +typedef mp_uint_t (*viper_fun_2_t)(mp_uint_t, mp_uint_t); +typedef mp_uint_t (*viper_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t); +typedef mp_uint_t (*viper_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t); + +STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_fun_viper_t *self = self_in; + + mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); + + void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data); + + mp_uint_t ret; + if (n_args == 0) { + ret = ((viper_fun_0_t)fun)(); + } else if (n_args == 1) { + ret = ((viper_fun_1_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4)); + } else if (n_args == 2) { + ret = ((viper_fun_2_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4), mp_convert_obj_to_native(args[1], self->type_sig >> 8)); + } else if (n_args == 3) { + ret = ((viper_fun_3_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4), mp_convert_obj_to_native(args[1], self->type_sig >> 8), mp_convert_obj_to_native(args[2], self->type_sig >> 12)); + } else { + // compiler allows at most 4 arguments + assert(n_args == 4); + ret = ((viper_fun_4_t)fun)( + mp_convert_obj_to_native(args[0], self->type_sig >> 4), + mp_convert_obj_to_native(args[1], self->type_sig >> 8), + mp_convert_obj_to_native(args[2], self->type_sig >> 12), + mp_convert_obj_to_native(args[3], self->type_sig >> 16) + ); + } + + return mp_convert_native_to_obj(ret, self->type_sig); +} + +STATIC const mp_obj_type_t mp_type_fun_viper = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_viper_call, + .unary_op = mp_generic_unary_op, +}; + +mp_obj_t mp_obj_new_fun_viper(size_t n_args, void *fun_data, mp_uint_t type_sig) { + mp_obj_fun_viper_t *o = m_new_obj(mp_obj_fun_viper_t); + o->base.type = &mp_type_fun_viper; + o->n_args = n_args; + o->fun_data = fun_data; + o->type_sig = type_sig; + return o; +} + +#endif // MICROPY_EMIT_NATIVE + +/******************************************************************************/ +/* inline assembler functions */ + +#if MICROPY_EMIT_INLINE_ASM + +typedef struct _mp_obj_fun_asm_t { + mp_obj_base_t base; + size_t n_args; + void *fun_data; // GC must be able to trace this pointer + mp_uint_t type_sig; +} mp_obj_fun_asm_t; + +typedef mp_uint_t (*inline_asm_fun_0_t)(void); +typedef mp_uint_t (*inline_asm_fun_1_t)(mp_uint_t); +typedef mp_uint_t (*inline_asm_fun_2_t)(mp_uint_t, mp_uint_t); +typedef mp_uint_t (*inline_asm_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t); +typedef mp_uint_t (*inline_asm_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t); + +// convert a MicroPython object to a sensible value for inline asm +STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) { + // TODO for byte_array, pass pointer to the array + if (MP_OBJ_IS_SMALL_INT(obj)) { + return MP_OBJ_SMALL_INT_VALUE(obj); + } else if (obj == mp_const_none) { + return 0; + } else if (obj == mp_const_false) { + return 0; + } else if (obj == mp_const_true) { + return 1; + } else if (MP_OBJ_IS_TYPE(obj, &mp_type_int)) { + return mp_obj_int_get_truncated(obj); + } else if (MP_OBJ_IS_STR(obj)) { + // pointer to the string (it's probably constant though!) + size_t l; + return (mp_uint_t)mp_obj_str_get_data(obj, &l); + } else { + mp_obj_type_t *type = mp_obj_get_type(obj); + if (0) { +#if MICROPY_PY_BUILTINS_FLOAT + } else if (type == &mp_type_float) { + // convert float to int (could also pass in float registers) + return (mp_int_t)mp_obj_float_get(obj); +#endif + } else if (type == &mp_type_tuple || type == &mp_type_list) { + // pointer to start of tuple (could pass length, but then could use len(x) for that) + size_t len; + mp_obj_t *items; + mp_obj_get_array(obj, &len, &items); + return (mp_uint_t)items; + } else { + mp_buffer_info_t bufinfo; + if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_WRITE)) { + // supports the buffer protocol, return a pointer to the data + return (mp_uint_t)bufinfo.buf; + } else { + // just pass along a pointer to the object + return (mp_uint_t)obj; + } + } + } +} + +STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_fun_asm_t *self = self_in; + + mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); + + void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data); + + mp_uint_t ret; + if (n_args == 0) { + ret = ((inline_asm_fun_0_t)fun)(); + } else if (n_args == 1) { + ret = ((inline_asm_fun_1_t)fun)(convert_obj_for_inline_asm(args[0])); + } else if (n_args == 2) { + ret = ((inline_asm_fun_2_t)fun)(convert_obj_for_inline_asm(args[0]), convert_obj_for_inline_asm(args[1])); + } else if (n_args == 3) { + ret = ((inline_asm_fun_3_t)fun)(convert_obj_for_inline_asm(args[0]), convert_obj_for_inline_asm(args[1]), convert_obj_for_inline_asm(args[2])); + } else { + // compiler allows at most 4 arguments + assert(n_args == 4); + ret = ((inline_asm_fun_4_t)fun)( + convert_obj_for_inline_asm(args[0]), + convert_obj_for_inline_asm(args[1]), + convert_obj_for_inline_asm(args[2]), + convert_obj_for_inline_asm(args[3]) + ); + } + + return mp_convert_native_to_obj(ret, self->type_sig); +} + +STATIC const mp_obj_type_t mp_type_fun_asm = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = fun_asm_call, + .unary_op = mp_generic_unary_op, +}; + +mp_obj_t mp_obj_new_fun_asm(size_t n_args, void *fun_data, mp_uint_t type_sig) { + mp_obj_fun_asm_t *o = m_new_obj(mp_obj_fun_asm_t); + o->base.type = &mp_type_fun_asm; + o->n_args = n_args; + o->fun_data = fun_data; + o->type_sig = type_sig; + return o; +} + +#endif // MICROPY_EMIT_INLINE_ASM diff --git a/user/mpy/py/objfun.h b/user/mpy/py/objfun.h new file mode 100644 index 0000000..fbb3516 --- /dev/null +++ b/user/mpy/py/objfun.h @@ -0,0 +1,44 @@ +/* + * 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_OBJFUN_H +#define MICROPY_INCLUDED_PY_OBJFUN_H + +#include "py/obj.h" + +typedef struct _mp_obj_fun_bc_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; // the context within which this function was defined + const byte *bytecode; // bytecode for the function + const mp_uint_t *const_table; // constant table + // the following extra_args array is allocated space to take (in order): + // - values of positional default args (if any) + // - a single slot for default kw args dict (if it has them) + // - a single slot for var args tuple (if it takes them) + // - a single slot for kw args dict (if it takes them) + mp_obj_t extra_args[]; +} mp_obj_fun_bc_t; + +#endif // MICROPY_INCLUDED_PY_OBJFUN_H diff --git a/user/mpy/py/objgenerator.c b/user/mpy/py/objgenerator.c new file mode 100644 index 0000000..2f39f3a --- /dev/null +++ b/user/mpy/py/objgenerator.c @@ -0,0 +1,243 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "py/bc.h" +#include "py/objgenerator.h" +#include "py/objfun.h" + +/******************************************************************************/ +/* generator wrapper */ + +typedef struct _mp_obj_gen_wrap_t { + mp_obj_base_t base; + mp_obj_t *fun; +} mp_obj_gen_wrap_t; + +typedef struct _mp_obj_gen_instance_t { + mp_obj_base_t base; + mp_obj_dict_t *globals; + mp_code_state_t code_state; +} mp_obj_gen_instance_t; + +STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_gen_wrap_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun; + assert(self_fun->base.type == &mp_type_fun_bc); + + // bytecode prelude: get state size and exception stack size + size_t n_state = mp_decode_uint_value(self_fun->bytecode); + size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode)); + + // allocate the generator object, with room for local stack and exception stack + mp_obj_gen_instance_t *o = m_new_obj_var(mp_obj_gen_instance_t, byte, + n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t)); + o->base.type = &mp_type_gen_instance; + + o->globals = self_fun->globals; + o->code_state.fun_bc = self_fun; + o->code_state.ip = 0; + mp_setup_code_state(&o->code_state, n_args, n_kw, args); + return MP_OBJ_FROM_PTR(o); +} + +const mp_obj_type_t mp_type_gen_wrap = { + { &mp_type_type }, + .name = MP_QSTR_generator, + .call = gen_wrap_call, + .unary_op = mp_generic_unary_op, +}; + +mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) { + mp_obj_gen_wrap_t *o = m_new_obj(mp_obj_gen_wrap_t); + o->base.type = &mp_type_gen_wrap; + o->fun = MP_OBJ_TO_PTR(fun); + return MP_OBJ_FROM_PTR(o); +} + +/******************************************************************************/ +/* generator instance */ + +STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self); +} + +mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_gen_instance)); + mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in); + if (self->code_state.ip == 0) { + // Trying to resume already stopped generator + *ret_val = MP_OBJ_STOP_ITERATION; + return MP_VM_RETURN_NORMAL; + } + if (self->code_state.sp == self->code_state.state - 1) { + if (send_value != mp_const_none) { + mp_raise_TypeError("can't send non-None value to a just-started generator"); + } + } else { + *self->code_state.sp = send_value; + } + mp_obj_dict_t *old_globals = mp_globals_get(); + mp_globals_set(self->globals); + mp_vm_return_kind_t ret_kind = mp_execute_bytecode(&self->code_state, throw_value); + mp_globals_set(old_globals); + + switch (ret_kind) { + case MP_VM_RETURN_NORMAL: + default: + // Explicitly mark generator as completed. If we don't do this, + // subsequent next() may re-execute statements after last yield + // again and again, leading to side effects. + // TODO: check how return with value behaves under such conditions + // in CPython. + self->code_state.ip = 0; + *ret_val = *self->code_state.sp; + break; + + case MP_VM_RETURN_YIELD: + *ret_val = *self->code_state.sp; + if (*ret_val == MP_OBJ_STOP_ITERATION) { + self->code_state.ip = 0; + } + break; + + case MP_VM_RETURN_EXCEPTION: { + size_t n_state = mp_decode_uint_value(self->code_state.fun_bc->bytecode); + self->code_state.ip = 0; + *ret_val = self->code_state.state[n_state - 1]; + break; + } + } + + return ret_kind; +} + +STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value) { + mp_obj_t ret; + switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) { + case MP_VM_RETURN_NORMAL: + default: + // Optimize return w/o value in case generator is used in for loop + if (ret == mp_const_none || ret == MP_OBJ_STOP_ITERATION) { + return MP_OBJ_STOP_ITERATION; + } else { + nlr_raise(mp_obj_new_exception_args(&mp_type_StopIteration, 1, &ret)); + } + + case MP_VM_RETURN_YIELD: + return ret; + + case MP_VM_RETURN_EXCEPTION: + // TODO: Optimization of returning MP_OBJ_STOP_ITERATION is really part + // of mp_iternext() protocol, but this function is called by other methods + // too, which may not handled MP_OBJ_STOP_ITERATION. + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(ret)), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { + mp_obj_t val = mp_obj_exception_get_value(ret); + if (val == mp_const_none) { + return MP_OBJ_STOP_ITERATION; + } + } + nlr_raise(ret); + } +} + +STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) { + return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL); +} + +STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) { + mp_obj_t ret = gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL); + if (ret == MP_OBJ_STOP_ITERATION) { + nlr_raise(mp_obj_new_exception(&mp_type_StopIteration)); + } else { + return ret; + } +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send); + +STATIC mp_obj_t gen_instance_close(mp_obj_t self_in); +STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) { + mp_obj_t exc = (n_args == 2) ? args[1] : args[2]; + + mp_obj_t ret = gen_resume_and_raise(args[0], mp_const_none, exc); + if (ret == MP_OBJ_STOP_ITERATION) { + nlr_raise(mp_obj_new_exception(&mp_type_StopIteration)); + } else { + return ret; + } +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw); + +STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) { + mp_obj_t ret; + switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) { + case MP_VM_RETURN_YIELD: + mp_raise_msg(&mp_type_RuntimeError, "generator ignored GeneratorExit"); + + // Swallow StopIteration & GeneratorExit (== successful close), and re-raise any other + case MP_VM_RETURN_EXCEPTION: + // ret should always be an instance of an exception class + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(ret)), MP_OBJ_FROM_PTR(&mp_type_GeneratorExit)) || + mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(ret)), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { + return mp_const_none; + } + nlr_raise(ret); + + default: + // The only choice left is MP_VM_RETURN_NORMAL which is successful close + return mp_const_none; + } +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close); + +STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&gen_instance_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&gen_instance_send_obj) }, + { MP_ROM_QSTR(MP_QSTR_throw), MP_ROM_PTR(&gen_instance_throw_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table); + +const mp_obj_type_t mp_type_gen_instance = { + { &mp_type_type }, + .name = MP_QSTR_generator, + .print = gen_instance_print, + .unary_op = mp_generic_unary_op, + .getiter = mp_identity_getiter, + .iternext = gen_instance_iternext, + .locals_dict = (mp_obj_dict_t*)&gen_instance_locals_dict, +}; diff --git a/user/mpy/py/objgenerator.h b/user/mpy/py/objgenerator.h new file mode 100644 index 0000000..80bf9cd --- /dev/null +++ b/user/mpy/py/objgenerator.h @@ -0,0 +1,34 @@ +/* + * 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_OBJGENERATOR_H +#define MICROPY_INCLUDED_PY_OBJGENERATOR_H + +#include "py/obj.h" +#include "py/runtime.h" + +mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); + +#endif // MICROPY_INCLUDED_PY_OBJGENERATOR_H diff --git a/user/mpy/py/objgetitemiter.c b/user/mpy/py/objgetitemiter.c new file mode 100644 index 0000000..afd6fb2 --- /dev/null +++ b/user/mpy/py/objgetitemiter.c @@ -0,0 +1,77 @@ +/* + * 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. + */ + +#include + +#include "py/nlr.h" +#include "py/runtime.h" + +// this is a wrapper object that turns something that has a __getitem__ method into an iterator + +typedef struct _mp_obj_getitem_iter_t { + mp_obj_base_t base; + mp_obj_t args[3]; +} mp_obj_getitem_iter_t; + +STATIC mp_obj_t it_iternext(mp_obj_t self_in) { + mp_obj_getitem_iter_t *self = MP_OBJ_TO_PTR(self_in); + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + // try to get next item + mp_obj_t value = mp_call_method_n_kw(1, 0, self->args); + self->args[2] = MP_OBJ_NEW_SMALL_INT(MP_OBJ_SMALL_INT_VALUE(self->args[2]) + 1); + nlr_pop(); + return value; + } else { + // an exception was raised + mp_obj_type_t *t = (mp_obj_type_t*)((mp_obj_base_t*)nlr.ret_val)->type; + if (t == &mp_type_StopIteration || t == &mp_type_IndexError) { + // return MP_OBJ_STOP_ITERATION instead of raising + return MP_OBJ_STOP_ITERATION; + } else { + // re-raise exception + nlr_jump(nlr.ret_val); + } + } +} + +STATIC const mp_obj_type_t it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = it_iternext, +}; + +// args are those returned from mp_load_method_maybe (ie either an attribute or a method) +mp_obj_t mp_obj_new_getitem_iter(mp_obj_t *args, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_getitem_iter_t *o = (mp_obj_getitem_iter_t*)iter_buf; + o->base.type = &it_type; + o->args[0] = args[0]; + o->args[1] = args[1]; + o->args[2] = MP_OBJ_NEW_SMALL_INT(0); + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objint.c b/user/mpy/py/objint.c new file mode 100644 index 0000000..29d8896 --- /dev/null +++ b/user/mpy/py/objint.c @@ -0,0 +1,479 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/parsenum.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/objstr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/binary.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include +#endif + +// This dispatcher function is expected to be independent of the implementation of long int +STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 2, false); + + switch (n_args) { + case 0: + return MP_OBJ_NEW_SMALL_INT(0); + + case 1: + if (MP_OBJ_IS_INT(args[0])) { + // already an int (small or long), just return it + return args[0]; + } else if (MP_OBJ_IS_STR_OR_BYTES(args[0])) { + // a string, parse it + size_t l; + const char *s = mp_obj_str_get_data(args[0], &l); + return mp_parse_num_integer(s, l, 0, NULL); +#if MICROPY_PY_BUILTINS_FLOAT + } else if (mp_obj_is_float(args[0])) { + return mp_obj_new_int_from_float(mp_obj_float_get(args[0])); +#endif + } else { + // try to convert to small int (eg from bool) + return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(args[0])); + } + + case 2: + default: { + // should be a string, parse it + // TODO proper error checking of argument types + size_t l; + const char *s = mp_obj_str_get_data(args[0], &l); + return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]), NULL); + } + } +} + +#if MICROPY_PY_BUILTINS_FLOAT + +typedef enum { + MP_FP_CLASS_FIT_SMALLINT, + MP_FP_CLASS_FIT_LONGINT, + MP_FP_CLASS_OVERFLOW +} mp_fp_as_int_class_t; + +STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) { + union { + mp_float_t f; +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT + uint32_t i; +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE + uint32_t i[2]; +#endif + } u = {val}; + + uint32_t e; +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT + e = u.i; +#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE + e = u.i[MP_ENDIANNESS_LITTLE]; +#endif +#define MP_FLOAT_SIGN_SHIFT_I32 ((MP_FLOAT_FRAC_BITS + MP_FLOAT_EXP_BITS) % 32) +#define MP_FLOAT_EXP_SHIFT_I32 (MP_FLOAT_FRAC_BITS % 32) + + if (e & (1U << MP_FLOAT_SIGN_SHIFT_I32)) { +#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE + e |= u.i[MP_ENDIANNESS_BIG] != 0; +#endif + if ((e & ~(1 << MP_FLOAT_SIGN_SHIFT_I32)) == 0) { + // handle case of -0 (when sign is set but rest of bits are zero) + e = 0; + } else { + e += ((1 << MP_FLOAT_EXP_BITS) - 1) << MP_FLOAT_EXP_SHIFT_I32; + } + } else { + e &= ~((1 << MP_FLOAT_EXP_SHIFT_I32) - 1); + } + // 8 * sizeof(uintptr_t) counts the number of bits for a small int + // TODO provide a way to configure this properly + if (e <= ((8 * sizeof(uintptr_t) + MP_FLOAT_EXP_BIAS - 3) << MP_FLOAT_EXP_SHIFT_I32)) { + return MP_FP_CLASS_FIT_SMALLINT; + } +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG + if (e <= (((sizeof(long long) * BITS_PER_BYTE) + MP_FLOAT_EXP_BIAS - 2) << MP_FLOAT_EXP_SHIFT_I32)) { + return MP_FP_CLASS_FIT_LONGINT; + } +#endif +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ + return MP_FP_CLASS_FIT_LONGINT; +#else + return MP_FP_CLASS_OVERFLOW; +#endif +} +#undef MP_FLOAT_SIGN_SHIFT_I32 +#undef MP_FLOAT_EXP_SHIFT_I32 + +mp_obj_t mp_obj_new_int_from_float(mp_float_t val) { + int cl = fpclassify(val); + if (cl == FP_INFINITE) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OverflowError, "can't convert inf to int")); + } else if (cl == FP_NAN) { + mp_raise_ValueError("can't convert NaN to int"); + } else { + mp_fp_as_int_class_t icl = mp_classify_fp_as_int(val); + if (icl == MP_FP_CLASS_FIT_SMALLINT) { + return MP_OBJ_NEW_SMALL_INT((mp_int_t)val); + #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ + } else { + mp_obj_int_t *o = mp_obj_int_new_mpz(); + mpz_set_from_float(&o->mpz, val); + return MP_OBJ_FROM_PTR(o); + } + #else + #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG + } else if (icl == MP_FP_CLASS_FIT_LONGINT) { + return mp_obj_new_int_from_ll((long long)val); + #endif + } else { + mp_raise_ValueError("float too big"); + } + #endif + } +} + +#endif + +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG +typedef mp_longint_impl_t fmt_int_t; +typedef unsigned long long fmt_uint_t; +#else +typedef mp_int_t fmt_int_t; +typedef mp_uint_t fmt_uint_t; +#endif + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + // The size of this buffer is rather arbitrary. If it's not large + // enough, a dynamic one will be allocated. + char stack_buf[sizeof(fmt_int_t) * 4]; + char *buf = stack_buf; + size_t buf_size = sizeof(stack_buf); + size_t fmt_size; + + char *str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, self_in, 10, NULL, '\0', '\0'); + mp_print_str(print, str); + + if (buf != stack_buf) { + m_del(char, buf, buf_size); + } +} + +STATIC const uint8_t log_base2_floor[] = { + 0, 1, 1, 2, + 2, 2, 2, 3, + 3, 3, 3, 3, + 3, 3, 3, 4, + /* if needed, these are the values for higher bases + 4, 4, 4, 4, + 4, 4, 4, 4, + 4, 4, 4, 4, + 4, 4, 4, 5 + */ +}; + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma) { + assert(2 <= base && base <= 16); + size_t num_digits = num_bits / log_base2_floor[base - 1] + 1; + size_t num_commas = comma ? num_digits / 3 : 0; + size_t prefix_len = prefix ? strlen(prefix) : 0; + return num_digits + num_commas + prefix_len + 2; // +1 for sign, +1 for null byte +} + +// This routine expects you to pass in a buffer and size (in *buf and *buf_size). +// If, for some reason, this buffer is too small, then it will allocate a +// buffer and return the allocated buffer and size in *buf and *buf_size. It +// is the callers responsibility to free this allocated buffer. +// +// The resulting formatted string will be returned from this function and the +// formatted size will be in *fmt_size. +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma) { + fmt_int_t num; + if (MP_OBJ_IS_SMALL_INT(self_in)) { + // A small int; get the integer value to format. + num = MP_OBJ_SMALL_INT_VALUE(self_in); +#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + } else if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { + // Not a small int. +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG + const mp_obj_int_t *self = self_in; + // Get the value to format; mp_obj_get_int truncates to mp_int_t. + num = self->val; +#else + // Delegate to the implementation for the long int. + return mp_obj_int_formatted_impl(buf, buf_size, fmt_size, self_in, base, prefix, base_char, comma); +#endif +#endif + } else { + // Not an int. + **buf = '\0'; + *fmt_size = 0; + return *buf; + } + + char sign = '\0'; + if (num < 0) { + num = -num; + sign = '-'; + } + + size_t needed_size = mp_int_format_size(sizeof(fmt_int_t) * 8, base, prefix, comma); + if (needed_size > *buf_size) { + *buf = m_new(char, needed_size); + *buf_size = needed_size; + } + char *str = *buf; + + char *b = str + needed_size; + *(--b) = '\0'; + char *last_comma = b; + + if (num == 0) { + *(--b) = '0'; + } else { + do { + // The cast to fmt_uint_t is because num is positive and we want unsigned arithmetic + int c = (fmt_uint_t)num % base; + num = (fmt_uint_t)num / base; + if (c >= 10) { + c += base_char - 10; + } else { + c += '0'; + } + *(--b) = c; + if (comma && num != 0 && b > str && (last_comma - b) == 3) { + *(--b) = comma; + last_comma = b; + } + } + while (b > str && num != 0); + } + if (prefix) { + size_t prefix_len = strlen(prefix); + char *p = b - prefix_len; + if (p > str) { + b = p; + while (*prefix) { + *p++ = *prefix++; + } + } + } + if (sign && b > str) { + *(--b) = sign; + } + *fmt_size = *buf + needed_size - b - 1; + + return b; +} + +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + +int mp_obj_int_sign(mp_obj_t self_in) { + mp_int_t val = mp_obj_get_int(self_in); + if (val < 0) { + return -1; + } else if (val > 0) { + return 1; + } else { + return 0; + } +} + +// This must handle int and bool types, and must raise a +// TypeError if the argument is not integral +mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { + mp_int_t val = mp_obj_get_int(self_in); + if (val < 0) { + val = -val; + } + return MP_OBJ_NEW_SMALL_INT(val); +} + +// This is called for operations on SMALL_INT that are not handled by mp_unary_op +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { + return MP_OBJ_NULL; // op not supported +} + +// This is called for operations on SMALL_INT that are not handled by mp_binary_op +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); +} + +// This is called only with strings whose value doesn't fit in SMALL_INT +mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { + mp_raise_msg(&mp_type_OverflowError, "long int not supported in this build"); + return mp_const_none; +} + +// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT) +mp_obj_t mp_obj_new_int_from_ll(long long val) { + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return mp_const_none; +} + +// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT) +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return mp_const_none; +} + +mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { + // SMALL_INT accepts only signed numbers, so make sure the input + // value fits completely in the small-int positive range. + if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { + return MP_OBJ_NEW_SMALL_INT(value); + } + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return mp_const_none; +} + +mp_obj_t mp_obj_new_int(mp_int_t value) { + if (MP_SMALL_INT_FITS(value)) { + return MP_OBJ_NEW_SMALL_INT(value); + } + mp_raise_msg(&mp_type_OverflowError, "small int overflow"); + return mp_const_none; +} + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { + return MP_OBJ_SMALL_INT_VALUE(self_in); +} + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { + return MP_OBJ_SMALL_INT_VALUE(self_in); +} + +#endif // MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + +// This dispatcher function is expected to be independent of the implementation of long int +// It handles the extra cases for integer-like arithmetic +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + if (rhs_in == mp_const_false) { + // false acts as 0 + return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(0)); + } else if (rhs_in == mp_const_true) { + // true acts as 0 + return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(1)); + } else if (op == MP_BINARY_OP_MULTIPLY) { + if (MP_OBJ_IS_STR(rhs_in) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_bytes) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_list)) { + // multiply is commutative for these types, so delegate to them + return mp_binary_op(op, rhs_in, lhs_in); + } + } + return MP_OBJ_NULL; // op not supported +} + +// this is a classmethod +STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) { + // TODO: Support signed param (assumes signed=False at the moment) + (void)n_args; + + // get the buffer info + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); + + const byte* buf = (const byte*)bufinfo.buf; + int delta = 1; + if (args[2] == MP_OBJ_NEW_QSTR(MP_QSTR_little)) { + buf += bufinfo.len - 1; + delta = -1; + } + + mp_uint_t value = 0; + size_t len = bufinfo.len; + for (; len--; buf += delta) { + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + if (value > (MP_SMALL_INT_MAX >> 8)) { + // Result will overflow a small-int so construct a big-int + return mp_obj_int_from_bytes_impl(args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little), bufinfo.len, bufinfo.buf); + } + #endif + value = (value << 8) | *buf; + } + return mp_obj_new_int_from_uint(value); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes); +STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj)); + +STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) { + // TODO: Support signed param (assumes signed=False) + (void)n_args; + + mp_int_t len = mp_obj_get_int(args[1]); + if (len < 0) { + mp_raise_ValueError(NULL); + } + bool big_endian = args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little); + + vstr_t vstr; + vstr_init_len(&vstr, len); + byte *data = (byte*)vstr.buf; + memset(data, 0, len); + + #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE + if (!MP_OBJ_IS_SMALL_INT(args[0])) { + mp_obj_int_to_bytes_impl(args[0], big_endian, len, data); + } else + #endif + { + mp_int_t val = MP_OBJ_SMALL_INT_VALUE(args[0]); + size_t l = MIN((size_t)len, sizeof(val)); + mp_binary_set_int(l, big_endian, data + (big_endian ? (len - l) : 0), val); + } + + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes); + +STATIC const mp_rom_map_elem_t int_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) }, + { MP_ROM_QSTR(MP_QSTR_to_bytes), MP_ROM_PTR(&int_to_bytes_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table); + +const mp_obj_type_t mp_type_int = { + { &mp_type_type }, + .name = MP_QSTR_int, + .print = mp_obj_int_print, + .make_new = mp_obj_int_make_new, + .unary_op = mp_obj_int_unary_op, + .binary_op = mp_obj_int_binary_op, + .locals_dict = (mp_obj_dict_t*)&int_locals_dict, +}; diff --git a/user/mpy/py/objint.h b/user/mpy/py/objint.h new file mode 100644 index 0000000..394c237 --- /dev/null +++ b/user/mpy/py/objint.h @@ -0,0 +1,66 @@ +/* + * 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_OBJINT_H +#define MICROPY_INCLUDED_PY_OBJINT_H + +#include "py/mpz.h" +#include "py/obj.h" + +typedef struct _mp_obj_int_t { + mp_obj_base_t base; +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG + mp_longint_impl_t val; +#elif MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ + mpz_t mpz; +#endif +} mp_obj_int_t; + +extern const mp_obj_int_t mp_maxsize_obj; + +#if MICROPY_PY_BUILTINS_FLOAT +mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in); +#endif + +size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); + +mp_obj_int_t *mp_obj_int_new_mpz(void); + +void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); +char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma); +mp_int_t mp_obj_int_hash(mp_obj_t self_in); +mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf); +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf); +int mp_obj_int_sign(mp_obj_t self_in); +mp_obj_t mp_obj_int_abs(mp_obj_t self_in); +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); + +#endif // MICROPY_INCLUDED_PY_OBJINT_H diff --git a/user/mpy/py/objint_longlong.c b/user/mpy/py/objint_longlong.c new file mode 100644 index 0000000..02c005d --- /dev/null +++ b/user/mpy/py/objint_longlong.c @@ -0,0 +1,298 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include +#endif + +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG + +#if MICROPY_PY_SYS_MAXSIZE +// Export value for sys.maxsize +const mp_obj_int_t mp_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX}; +#endif + +mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) { + int delta = 1; + if (!big_endian) { + buf += len - 1; + delta = -1; + } + + mp_longint_impl_t value = 0; + for (; len--; buf += delta) { + value = (value << 8) | *buf; + } + return mp_obj_new_int_from_ll(value); +} + +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); + mp_obj_int_t *self = self_in; + long long val = self->val; + if (big_endian) { + byte *b = buf + len; + while (b > buf) { + *--b = val; + val >>= 8; + } + } else { + for (; len > 0; --len) { + *buf++ = val; + val >>= 8; + } + } +} + +int mp_obj_int_sign(mp_obj_t self_in) { + mp_longint_impl_t val; + if (MP_OBJ_IS_SMALL_INT(self_in)) { + val = MP_OBJ_SMALL_INT_VALUE(self_in); + } else { + mp_obj_int_t *self = self_in; + val = self->val; + } + if (val < 0) { + return -1; + } else if (val > 0) { + return 1; + } else { + return 0; + } +} + +// This must handle int and bool types, and must raise a +// TypeError if the argument is not integral +mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { + if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { + mp_obj_int_t *self = self_in; + self = mp_obj_new_int_from_ll(self->val); + if (self->val < 0) { + // TODO could overflow long long + self->val = -self->val; + } + return self; + } else { + mp_int_t val = mp_obj_get_int(self_in); + if (val == MP_SMALL_INT_MIN) { + return mp_obj_new_int_from_ll(-val); + } else { + if (val < 0) { + val = -val; + } + return MP_OBJ_NEW_SMALL_INT(val); + } + } +} + +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { + mp_obj_int_t *o = o_in; + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->val != 0); + + // truncate value to fit in mp_int_t, which gives the same hash as + // small int if the value fits without truncation + case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_int_t)o->val); + + case MP_UNARY_OP_POSITIVE: return o_in; + case MP_UNARY_OP_NEGATIVE: return mp_obj_new_int_from_ll(-o->val); + case MP_UNARY_OP_INVERT: return mp_obj_new_int_from_ll(~o->val); + default: return MP_OBJ_NULL; // op not supported + } +} + +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + long long lhs_val; + long long rhs_val; + + if (MP_OBJ_IS_SMALL_INT(lhs_in)) { + lhs_val = MP_OBJ_SMALL_INT_VALUE(lhs_in); + } else if (MP_OBJ_IS_TYPE(lhs_in, &mp_type_int)) { + lhs_val = ((mp_obj_int_t*)lhs_in)->val; + } else { + return MP_OBJ_NULL; // op not supported + } + + if (MP_OBJ_IS_SMALL_INT(rhs_in)) { + rhs_val = MP_OBJ_SMALL_INT_VALUE(rhs_in); + } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) { + rhs_val = ((mp_obj_int_t*)rhs_in)->val; + } else { + // delegate to generic function to check for extra cases + return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); + } + + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: + return mp_obj_new_int_from_ll(lhs_val + rhs_val); + case MP_BINARY_OP_SUBTRACT: + case MP_BINARY_OP_INPLACE_SUBTRACT: + return mp_obj_new_int_from_ll(lhs_val - rhs_val); + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: + return mp_obj_new_int_from_ll(lhs_val * rhs_val); + case MP_BINARY_OP_FLOOR_DIVIDE: + case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: + return mp_obj_new_int_from_ll(lhs_val / rhs_val); + case MP_BINARY_OP_MODULO: + case MP_BINARY_OP_INPLACE_MODULO: + return mp_obj_new_int_from_ll(lhs_val % rhs_val); + + case MP_BINARY_OP_AND: + case MP_BINARY_OP_INPLACE_AND: + return mp_obj_new_int_from_ll(lhs_val & rhs_val); + case MP_BINARY_OP_OR: + case MP_BINARY_OP_INPLACE_OR: + return mp_obj_new_int_from_ll(lhs_val | rhs_val); + case MP_BINARY_OP_XOR: + case MP_BINARY_OP_INPLACE_XOR: + return mp_obj_new_int_from_ll(lhs_val ^ rhs_val); + + case MP_BINARY_OP_LSHIFT: + case MP_BINARY_OP_INPLACE_LSHIFT: + return mp_obj_new_int_from_ll(lhs_val << (int)rhs_val); + case MP_BINARY_OP_RSHIFT: + case MP_BINARY_OP_INPLACE_RSHIFT: + return mp_obj_new_int_from_ll(lhs_val >> (int)rhs_val); + + case MP_BINARY_OP_POWER: + case MP_BINARY_OP_INPLACE_POWER: { + if (rhs_val < 0) { + #if MICROPY_PY_BUILTINS_FLOAT + return mp_obj_float_binary_op(op, lhs_val, rhs_in); + #else + mp_raise_ValueError("negative power with no float support"); + #endif + } + long long ans = 1; + while (rhs_val > 0) { + if (rhs_val & 1) { + ans *= lhs_val; + } + if (rhs_val == 1) { + break; + } + rhs_val /= 2; + lhs_val *= lhs_val; + } + return mp_obj_new_int_from_ll(ans); + } + + case MP_BINARY_OP_LESS: + return mp_obj_new_bool(lhs_val < rhs_val); + case MP_BINARY_OP_MORE: + return mp_obj_new_bool(lhs_val > rhs_val); + case MP_BINARY_OP_LESS_EQUAL: + return mp_obj_new_bool(lhs_val <= rhs_val); + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(lhs_val >= rhs_val); + case MP_BINARY_OP_EQUAL: + return mp_obj_new_bool(lhs_val == rhs_val); + + default: + return MP_OBJ_NULL; // op not supported + } +} + +mp_obj_t mp_obj_new_int(mp_int_t value) { + if (MP_SMALL_INT_FITS(value)) { + return MP_OBJ_NEW_SMALL_INT(value); + } + return mp_obj_new_int_from_ll(value); +} + +mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { + // SMALL_INT accepts only signed numbers, so make sure the input + // value fits completely in the small-int positive range. + if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { + return MP_OBJ_NEW_SMALL_INT(value); + } + return mp_obj_new_int_from_ll(value); +} + +mp_obj_t mp_obj_new_int_from_ll(long long val) { + mp_obj_int_t *o = m_new_obj(mp_obj_int_t); + o->base.type = &mp_type_int; + o->val = val; + return o; +} + +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { + // TODO raise an exception if the unsigned long long won't fit + if (val >> (sizeof(unsigned long long) * 8 - 1) != 0) { + mp_raise_msg(&mp_type_OverflowError, "ulonglong too large"); + } + mp_obj_int_t *o = m_new_obj(mp_obj_int_t); + o->base.type = &mp_type_int; + o->val = val; + return o; +} + +mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { + // TODO this does not honor the given length of the string, but it all cases it should anyway be null terminated + // TODO check overflow + mp_obj_int_t *o = m_new_obj(mp_obj_int_t); + o->base.type = &mp_type_int; + char *endptr; + o->val = strtoll(*str, &endptr, base); + *str = endptr; + return o; +} + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { + if (MP_OBJ_IS_SMALL_INT(self_in)) { + return MP_OBJ_SMALL_INT_VALUE(self_in); + } else { + const mp_obj_int_t *self = self_in; + return self->val; + } +} + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { + // TODO: Check overflow + return mp_obj_int_get_truncated(self_in); +} + +#if MICROPY_PY_BUILTINS_FLOAT +mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); + mp_obj_int_t *self = self_in; + return self->val; +} +#endif + +#endif diff --git a/user/mpy/py/objint_mpz.c b/user/mpy/py/objint_mpz.c new file mode 100644 index 0000000..0791a8a --- /dev/null +++ b/user/mpy/py/objint_mpz.c @@ -0,0 +1,438 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/parsenumbase.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include +#endif + +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ + +#if MICROPY_PY_SYS_MAXSIZE +// Export value for sys.maxsize +#define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1) +STATIC const mpz_dig_t maxsize_dig[] = { + #define NUM_DIG 1 + (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) & DIG_MASK, + #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) > DIG_MASK + #undef NUM_DIG + #define NUM_DIG 2 + (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 1) & DIG_MASK, + #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 1) > DIG_MASK + #undef NUM_DIG + #define NUM_DIG 3 + (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 2) & DIG_MASK, + #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 2) > DIG_MASK + #undef NUM_DIG + #define NUM_DIG 4 + (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 3) & DIG_MASK, + #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 3) > DIG_MASK + #error cannot encode MP_SSIZE_MAX as mpz + #endif + #endif + #endif + #endif +}; +const mp_obj_int_t mp_maxsize_obj = { + {&mp_type_int}, + {.fixed_dig = 1, .len = NUM_DIG, .alloc = NUM_DIG, .dig = (mpz_dig_t*)maxsize_dig} +}; +#undef DIG_MASK +#undef NUM_DIG +#endif + +mp_obj_int_t *mp_obj_int_new_mpz(void) { + mp_obj_int_t *o = m_new_obj(mp_obj_int_t); + o->base.type = &mp_type_int; + mpz_init_zero(&o->mpz); + return o; +} + +// This routine expects you to pass in a buffer and size (in *buf and buf_size). +// If, for some reason, this buffer is too small, then it will allocate a +// buffer and return the allocated buffer and size in *buf and *buf_size. It +// is the callers responsibility to free this allocated buffer. +// +// The resulting formatted string will be returned from this function and the +// formatted size will be in *fmt_size. +// +// This particular routine should only be called for the mpz representation of the int. +char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, + int base, const char *prefix, char base_char, char comma) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); + const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + + size_t needed_size = mp_int_format_size(mpz_max_num_bits(&self->mpz), base, prefix, comma); + if (needed_size > *buf_size) { + *buf = m_new(char, needed_size); + *buf_size = needed_size; + } + char *str = *buf; + + *fmt_size = mpz_as_str_inpl(&self->mpz, base, prefix, base_char, comma, str); + + return str; +} + +mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) { + mp_obj_int_t *o = mp_obj_int_new_mpz(); + mpz_set_from_bytes(&o->mpz, big_endian, len, buf); + return MP_OBJ_FROM_PTR(o); +} + +void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); + mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + memset(buf, 0, len); + mpz_as_bytes(&self->mpz, big_endian, len, buf); +} + +int mp_obj_int_sign(mp_obj_t self_in) { + if (MP_OBJ_IS_SMALL_INT(self_in)) { + mp_int_t val = MP_OBJ_SMALL_INT_VALUE(self_in); + if (val < 0) { + return -1; + } else if (val > 0) { + return 1; + } else { + return 0; + } + } + mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + if (self->mpz.len == 0) { + return 0; + } else if (self->mpz.neg == 0) { + return 1; + } else { + return -1; + } +} + +// This must handle int and bool types, and must raise a +// TypeError if the argument is not integral +mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { + if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { + mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_int_t *self2 = mp_obj_int_new_mpz(); + mpz_abs_inpl(&self2->mpz, &self->mpz); + return MP_OBJ_FROM_PTR(self2); + } else { + mp_int_t val = mp_obj_get_int(self_in); + if (val == MP_SMALL_INT_MIN) { + return mp_obj_new_int_from_ll(-val); + } else { + if (val < 0) { + val = -val; + } + return MP_OBJ_NEW_SMALL_INT(val); + } + } +} + +mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { + mp_obj_int_t *o = MP_OBJ_TO_PTR(o_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(!mpz_is_zero(&o->mpz)); + case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mpz_hash(&o->mpz)); + case MP_UNARY_OP_POSITIVE: return o_in; + case MP_UNARY_OP_NEGATIVE: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_neg_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); } + case MP_UNARY_OP_INVERT: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_not_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); } + default: return MP_OBJ_NULL; // op not supported + } +} + +mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + const mpz_t *zlhs; + const mpz_t *zrhs; + mpz_t z_int; + mpz_dig_t z_int_dig[MPZ_NUM_DIG_FOR_INT]; + + // lhs could be a small int (eg small-int + mpz) + if (MP_OBJ_IS_SMALL_INT(lhs_in)) { + mpz_init_fixed_from_int(&z_int, z_int_dig, MPZ_NUM_DIG_FOR_INT, MP_OBJ_SMALL_INT_VALUE(lhs_in)); + zlhs = &z_int; + } else if (MP_OBJ_IS_TYPE(lhs_in, &mp_type_int)) { + zlhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(lhs_in))->mpz; + } else { + // unsupported type + return MP_OBJ_NULL; + } + + // if rhs is small int, then lhs was not (otherwise mp_binary_op handles it) + if (MP_OBJ_IS_SMALL_INT(rhs_in)) { + mpz_init_fixed_from_int(&z_int, z_int_dig, MPZ_NUM_DIG_FOR_INT, MP_OBJ_SMALL_INT_VALUE(rhs_in)); + zrhs = &z_int; + } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) { + zrhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(rhs_in))->mpz; +#if MICROPY_PY_BUILTINS_FLOAT + } else if (mp_obj_is_float(rhs_in)) { + return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in); +#if MICROPY_PY_BUILTINS_COMPLEX + } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) { + return mp_obj_complex_binary_op(op, mpz_as_float(zlhs), 0, rhs_in); +#endif +#endif + } else { + // delegate to generic function to check for extra cases + return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); + } + + if (0) { +#if MICROPY_PY_BUILTINS_FLOAT + } else if (op == MP_BINARY_OP_TRUE_DIVIDE || op == MP_BINARY_OP_INPLACE_TRUE_DIVIDE) { + if (mpz_is_zero(zrhs)) { + goto zero_division_error; + } + mp_float_t flhs = mpz_as_float(zlhs); + mp_float_t frhs = mpz_as_float(zrhs); + return mp_obj_new_float(flhs / frhs); +#endif + + } else if (op <= MP_BINARY_OP_INPLACE_POWER) { + mp_obj_int_t *res = mp_obj_int_new_mpz(); + + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: + mpz_add_inpl(&res->mpz, zlhs, zrhs); + break; + case MP_BINARY_OP_SUBTRACT: + case MP_BINARY_OP_INPLACE_SUBTRACT: + mpz_sub_inpl(&res->mpz, zlhs, zrhs); + break; + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: + mpz_mul_inpl(&res->mpz, zlhs, zrhs); + break; + case MP_BINARY_OP_FLOOR_DIVIDE: + case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: { + if (mpz_is_zero(zrhs)) { + zero_division_error: + mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); + } + mpz_t rem; mpz_init_zero(&rem); + mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs); + mpz_deinit(&rem); + break; + } + case MP_BINARY_OP_MODULO: + case MP_BINARY_OP_INPLACE_MODULO: { + if (mpz_is_zero(zrhs)) { + goto zero_division_error; + } + mpz_t quo; mpz_init_zero(&quo); + mpz_divmod_inpl(&quo, &res->mpz, zlhs, zrhs); + mpz_deinit(&quo); + break; + } + + case MP_BINARY_OP_AND: + case MP_BINARY_OP_INPLACE_AND: + mpz_and_inpl(&res->mpz, zlhs, zrhs); + break; + case MP_BINARY_OP_OR: + case MP_BINARY_OP_INPLACE_OR: + mpz_or_inpl(&res->mpz, zlhs, zrhs); + break; + case MP_BINARY_OP_XOR: + case MP_BINARY_OP_INPLACE_XOR: + mpz_xor_inpl(&res->mpz, zlhs, zrhs); + break; + + case MP_BINARY_OP_LSHIFT: + case MP_BINARY_OP_INPLACE_LSHIFT: + case MP_BINARY_OP_RSHIFT: + case MP_BINARY_OP_INPLACE_RSHIFT: { + mp_int_t irhs = mp_obj_int_get_checked(rhs_in); + if (irhs < 0) { + mp_raise_ValueError("negative shift count"); + } + if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) { + mpz_shl_inpl(&res->mpz, zlhs, irhs); + } else { + mpz_shr_inpl(&res->mpz, zlhs, irhs); + } + break; + } + + case MP_BINARY_OP_POWER: + case MP_BINARY_OP_INPLACE_POWER: + if (mpz_is_neg(zrhs)) { + #if MICROPY_PY_BUILTINS_FLOAT + return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in); + #else + mp_raise_ValueError("negative power with no float support"); + #endif + } + mpz_pow_inpl(&res->mpz, zlhs, zrhs); + break; + + default: { + assert(op == MP_BINARY_OP_DIVMOD); + if (mpz_is_zero(zrhs)) { + goto zero_division_error; + } + mp_obj_int_t *quo = mp_obj_int_new_mpz(); + mpz_divmod_inpl(&quo->mpz, &res->mpz, zlhs, zrhs); + mp_obj_t tuple[2] = {MP_OBJ_FROM_PTR(quo), MP_OBJ_FROM_PTR(res)}; + return mp_obj_new_tuple(2, tuple); + } + } + + return MP_OBJ_FROM_PTR(res); + + } else { + int cmp = mpz_cmp(zlhs, zrhs); + switch (op) { + case MP_BINARY_OP_LESS: + return mp_obj_new_bool(cmp < 0); + case MP_BINARY_OP_MORE: + return mp_obj_new_bool(cmp > 0); + case MP_BINARY_OP_LESS_EQUAL: + return mp_obj_new_bool(cmp <= 0); + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(cmp >= 0); + case MP_BINARY_OP_EQUAL: + return mp_obj_new_bool(cmp == 0); + + default: + return MP_OBJ_NULL; // op not supported + } + } +} + +#if MICROPY_PY_BUILTINS_POW3 +STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) { + if (MP_OBJ_IS_SMALL_INT(arg)) { + mpz_init_from_int(temp, MP_OBJ_SMALL_INT_VALUE(arg)); + return temp; + } else { + mp_obj_int_t *arp_p = MP_OBJ_TO_PTR(arg); + return &(arp_p->mpz); + } +} + +mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus) { + if (!MP_OBJ_IS_INT(base) || !MP_OBJ_IS_INT(exponent) || !MP_OBJ_IS_INT(modulus)) { + mp_raise_TypeError("pow() with 3 arguments requires integers"); + } else { + mp_obj_t result = mp_obj_new_int_from_ull(0); // Use the _from_ull version as this forces an mpz int + mp_obj_int_t *res_p = (mp_obj_int_t *) MP_OBJ_TO_PTR(result); + + mpz_t l_temp, r_temp, m_temp; + mpz_t *lhs = mp_mpz_for_int(base, &l_temp); + mpz_t *rhs = mp_mpz_for_int(exponent, &r_temp); + mpz_t *mod = mp_mpz_for_int(modulus, &m_temp); + + mpz_pow3_inpl(&(res_p->mpz), lhs, rhs, mod); + + if (lhs == &l_temp) { mpz_deinit(lhs); } + if (rhs == &r_temp) { mpz_deinit(rhs); } + if (mod == &m_temp) { mpz_deinit(mod); } + return result; + } +} +#endif + +mp_obj_t mp_obj_new_int(mp_int_t value) { + if (MP_SMALL_INT_FITS(value)) { + return MP_OBJ_NEW_SMALL_INT(value); + } + return mp_obj_new_int_from_ll(value); +} + +mp_obj_t mp_obj_new_int_from_ll(long long val) { + mp_obj_int_t *o = mp_obj_int_new_mpz(); + mpz_set_from_ll(&o->mpz, val, true); + return MP_OBJ_FROM_PTR(o); +} + +mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { + mp_obj_int_t *o = mp_obj_int_new_mpz(); + mpz_set_from_ll(&o->mpz, val, false); + return MP_OBJ_FROM_PTR(o); +} + +mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { + // SMALL_INT accepts only signed numbers, so make sure the input + // value fits completely in the small-int positive range. + if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { + return MP_OBJ_NEW_SMALL_INT(value); + } + return mp_obj_new_int_from_ull(value); +} + +mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { + mp_obj_int_t *o = mp_obj_int_new_mpz(); + size_t n = mpz_set_from_str(&o->mpz, *str, len, neg, base); + *str += n; + return MP_OBJ_FROM_PTR(o); +} + +mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { + if (MP_OBJ_IS_SMALL_INT(self_in)) { + return MP_OBJ_SMALL_INT_VALUE(self_in); + } else { + const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + // hash returns actual int value if it fits in mp_int_t + return mpz_hash(&self->mpz); + } +} + +mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { + if (MP_OBJ_IS_SMALL_INT(self_in)) { + return MP_OBJ_SMALL_INT_VALUE(self_in); + } else { + const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t value; + if (mpz_as_int_checked(&self->mpz, &value)) { + return value; + } else { + // overflow + mp_raise_msg(&mp_type_OverflowError, "overflow converting long int to machine word"); + } + } +} + +#if MICROPY_PY_BUILTINS_FLOAT +mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); + mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); + return mpz_as_float(&self->mpz); +} +#endif + +#endif diff --git a/user/mpy/py/objlist.c b/user/mpy/py/objlist.c new file mode 100644 index 0000000..86d4300 --- /dev/null +++ b/user/mpy/py/objlist.c @@ -0,0 +1,533 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/stackctrl.h" + +STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf); +STATIC mp_obj_list_t *list_new(size_t n); +STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in); +STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); + +// TODO: Move to mpconfig.h +#define LIST_MIN_ALLOC 4 + +/******************************************************************************/ +/* list */ + +STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in); + if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { + kind = PRINT_REPR; + } + mp_print_str(print, "["); + for (size_t i = 0; i < o->len; i++) { + if (i > 0) { + mp_print_str(print, ", "); + } + mp_obj_print_helper(print, o->items[i], kind); + } + mp_print_str(print, "]"); +} + +STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) { + mp_obj_t iter = mp_getiter(iterable, NULL); + mp_obj_t item; + while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + mp_obj_list_append(list, item); + } + return list; +} + +STATIC mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + mp_arg_check_num(n_args, n_kw, 0, 1, false); + + switch (n_args) { + case 0: + // return a new, empty list + return mp_obj_new_list(0, NULL); + + case 1: + default: { + // make list from iterable + // TODO: optimize list/tuple + mp_obj_t list = mp_obj_new_list(0, NULL); + return list_extend_from_iter(list, args[0]); + } + } +} + +// Don't pass MP_BINARY_OP_NOT_EQUAL here +STATIC bool list_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + if (!MP_OBJ_IS_TYPE(another_in, &mp_type_list)) { + return false; + } + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *another = MP_OBJ_TO_PTR(another_in); + + return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); +} + +STATIC mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); + #if MICROPY_PY_SYS_GETSIZEOF + case MP_UNARY_OP_SIZEOF: { + size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc; + return MP_OBJ_NEW_SMALL_INT(sz); + } + #endif + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t list_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs); + switch (op) { + case MP_BINARY_OP_ADD: { + if (!MP_OBJ_IS_TYPE(rhs, &mp_type_list)) { + return MP_OBJ_NULL; // op not supported + } + mp_obj_list_t *p = MP_OBJ_TO_PTR(rhs); + mp_obj_list_t *s = list_new(o->len + p->len); + mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t); + return MP_OBJ_FROM_PTR(s); + } + case MP_BINARY_OP_INPLACE_ADD: { + list_extend(lhs, rhs); + return lhs; + } + case MP_BINARY_OP_MULTIPLY: { + mp_int_t n; + if (!mp_obj_get_int_maybe(rhs, &n)) { + return MP_OBJ_NULL; // op not supported + } + if (n < 0) { + n = 0; + } + mp_obj_list_t *s = list_new(o->len * n); + mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); + return MP_OBJ_FROM_PTR(s); + } + case MP_BINARY_OP_EQUAL: + case MP_BINARY_OP_LESS: + case MP_BINARY_OP_LESS_EQUAL: + case MP_BINARY_OP_MORE: + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(list_cmp_helper(op, lhs, rhs)); + + default: + return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_NULL) { + // delete +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_bound_slice_t slice; + if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { + mp_raise_NotImplementedError(""); + } + + mp_int_t len_adj = slice.start - slice.stop; + //printf("Len adj: %d\n", len_adj); + assert(len_adj <= 0); + mp_seq_replace_slice_no_grow(self->items, self->len, slice.start, slice.stop, self->items/*NULL*/, 0, sizeof(*self->items)); + // Clear "freed" elements at the end of list + mp_seq_clear(self->items, self->len + len_adj, self->len, sizeof(*self->items)); + self->len += len_adj; + return mp_const_none; + } +#endif + mp_obj_t args[2] = {self_in, index}; + list_pop(2, args); + return mp_const_none; + } else if (value == MP_OBJ_SENTINEL) { + // load + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_bound_slice_t slice; + if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { + return mp_seq_extract_slice(self->len, self->items, &slice); + } + mp_obj_list_t *res = list_new(slice.stop - slice.start); + mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t); + return MP_OBJ_FROM_PTR(res); + } +#endif + size_t index_val = mp_get_index(self->base.type, self->len, index, false); + return self->items[index_val]; + } else { +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + size_t value_len; mp_obj_t *value_items; + mp_obj_get_array(value, &value_len, &value_items); + mp_bound_slice_t slice_out; + if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice_out)) { + mp_raise_NotImplementedError(""); + } + mp_int_t len_adj = value_len - (slice_out.stop - slice_out.start); + //printf("Len adj: %d\n", len_adj); + if (len_adj > 0) { + if (self->len + len_adj > self->alloc) { + // TODO: Might optimize memory copies here by checking if block can + // be grown inplace or not + self->items = m_renew(mp_obj_t, self->items, self->alloc, self->len + len_adj); + self->alloc = self->len + len_adj; + } + mp_seq_replace_slice_grow_inplace(self->items, self->len, + slice_out.start, slice_out.stop, value_items, value_len, len_adj, sizeof(*self->items)); + } else { + mp_seq_replace_slice_no_grow(self->items, self->len, + slice_out.start, slice_out.stop, value_items, value_len, sizeof(*self->items)); + // Clear "freed" elements at the end of list + mp_seq_clear(self->items, self->len + len_adj, self->len, sizeof(*self->items)); + // TODO: apply allocation policy re: alloc_size + } + self->len += len_adj; + return mp_const_none; + } +#endif + mp_obj_list_store(self_in, index, value); + return mp_const_none; + } +} + +STATIC mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + return mp_obj_new_list_iterator(o_in, 0, iter_buf); +} + +mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + if (self->len >= self->alloc) { + self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc * 2); + self->alloc *= 2; + mp_seq_clear(self->items, self->len + 1, self->alloc, sizeof(*self->items)); + } + self->items[self->len++] = arg; + return mp_const_none; // return None, as per CPython +} + +STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + if (MP_OBJ_IS_TYPE(arg_in, &mp_type_list)) { + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *arg = MP_OBJ_TO_PTR(arg_in); + + if (self->len + arg->len > self->alloc) { + // TODO: use alloc policy for "4" + self->items = m_renew(mp_obj_t, self->items, self->alloc, self->len + arg->len + 4); + self->alloc = self->len + arg->len + 4; + mp_seq_clear(self->items, self->len + arg->len, self->alloc, sizeof(*self->items)); + } + + memcpy(self->items + self->len, arg->items, sizeof(mp_obj_t) * arg->len); + self->len += arg->len; + } else { + list_extend_from_iter(self_in, arg_in); + } + return mp_const_none; // return None, as per CPython +} + +STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) { + mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]); + if (self->len == 0) { + mp_raise_msg(&mp_type_IndexError, "pop from empty list"); + } + size_t index = mp_get_index(self->base.type, self->len, n_args == 1 ? MP_OBJ_NEW_SMALL_INT(-1) : args[1], false); + mp_obj_t ret = self->items[index]; + self->len -= 1; + memmove(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t)); + // Clear stale pointer from slot which just got freed to prevent GC issues + self->items[self->len] = MP_OBJ_NULL; + if (self->alloc > LIST_MIN_ALLOC && self->alloc > 2 * self->len) { + self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc/2); + self->alloc /= 2; + } + return ret; +} + +STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) { + MP_STACK_CHECK(); + while (head < tail) { + mp_obj_t *h = head - 1; + mp_obj_t *t = tail; + mp_obj_t v = key_fn == MP_OBJ_NULL ? tail[0] : mp_call_function_1(key_fn, tail[0]); // get pivot using key_fn + for (;;) { + do ++h; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, key_fn == MP_OBJ_NULL ? h[0] : mp_call_function_1(key_fn, h[0]), v) == binop_less_result); + do --t; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, v, key_fn == MP_OBJ_NULL ? t[0] : mp_call_function_1(key_fn, t[0])) == binop_less_result); + if (h >= t) break; + mp_obj_t x = h[0]; + h[0] = t[0]; + t[0] = x; + } + mp_obj_t x = h[0]; + h[0] = tail[0]; + tail[0] = x; + // do the smaller recursive call first, to keep stack within O(log(N)) + if (t - head < tail - h - 1) { + mp_quicksort(head, t, key_fn, binop_less_result); + head = h + 1; + } else { + mp_quicksort(h + 1, tail, key_fn, binop_less_result); + tail = t; + } + } +} + +// TODO Python defines sort to be stable but ours is not +mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + static const mp_arg_t allowed_args[] = { + { MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + { MP_QSTR_reverse, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + }; + + // parse args + struct { + mp_arg_val_t key, reverse; + } args; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, + MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); + + mp_check_self(MP_OBJ_IS_TYPE(pos_args[0], &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + if (self->len > 1) { + mp_quicksort(self->items, self->items + self->len - 1, + args.key.u_obj == mp_const_none ? MP_OBJ_NULL : args.key.u_obj, + args.reverse.u_bool ? mp_const_false : mp_const_true); + } + + return mp_const_none; +} + +STATIC mp_obj_t list_clear(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + self->len = 0; + self->items = m_renew(mp_obj_t, self->items, self->alloc, LIST_MIN_ALLOC); + self->alloc = LIST_MIN_ALLOC; + mp_seq_clear(self->items, 0, self->alloc, sizeof(*self->items)); + return mp_const_none; +} + +STATIC mp_obj_t list_copy(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_list(self->len, self->items); +} + +STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + return mp_seq_count_obj(self->items, self->len, value); +} + +STATIC mp_obj_t list_index(size_t n_args, const mp_obj_t *args) { + mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]); + return mp_seq_index_obj(self->items, self->len, n_args, args); +} + +STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + // insert has its own strange index logic + mp_int_t index = MP_OBJ_SMALL_INT_VALUE(idx); + if (index < 0) { + index += self->len; + } + if (index < 0) { + index = 0; + } + if ((size_t)index > self->len) { + index = self->len; + } + + mp_obj_list_append(self_in, mp_const_none); + + for (mp_int_t i = self->len-1; i > index; i--) { + self->items[i] = self->items[i-1]; + } + self->items[index] = obj; + + return mp_const_none; +} + +mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_t args[] = {self_in, value}; + args[1] = list_index(2, args); + list_pop(2, args); + + return mp_const_none; +} + +STATIC mp_obj_t list_reverse(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + + mp_int_t len = self->len; + for (mp_int_t i = 0; i < len/2; i++) { + mp_obj_t a = self->items[i]; + self->items[i] = self->items[len-i-1]; + self->items[len-i-1] = a; + } + + return mp_const_none; +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index); +STATIC MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort); + +STATIC const mp_rom_map_elem_t list_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&list_append_obj) }, + { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&list_clear_obj) }, + { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&list_copy_obj) }, + { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&list_count_obj) }, + { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&list_extend_obj) }, + { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&list_index_obj) }, + { MP_ROM_QSTR(MP_QSTR_insert), MP_ROM_PTR(&list_insert_obj) }, + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&list_pop_obj) }, + { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&list_remove_obj) }, + { MP_ROM_QSTR(MP_QSTR_reverse), MP_ROM_PTR(&list_reverse_obj) }, + { MP_ROM_QSTR(MP_QSTR_sort), MP_ROM_PTR(&list_sort_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table); + +const mp_obj_type_t mp_type_list = { + { &mp_type_type }, + .name = MP_QSTR_list, + .print = list_print, + .make_new = list_make_new, + .unary_op = list_unary_op, + .binary_op = list_binary_op, + .subscr = list_subscr, + .getiter = list_getiter, + .locals_dict = (mp_obj_dict_t*)&list_locals_dict, +}; + +void mp_obj_list_init(mp_obj_list_t *o, size_t n) { + o->base.type = &mp_type_list; + o->alloc = n < LIST_MIN_ALLOC ? LIST_MIN_ALLOC : n; + o->len = n; + o->items = m_new(mp_obj_t, o->alloc); + mp_seq_clear(o->items, n, o->alloc, sizeof(*o->items)); +} + +STATIC mp_obj_list_t *list_new(size_t n) { + mp_obj_list_t *o = m_new_obj(mp_obj_list_t); + mp_obj_list_init(o, n); + return o; +} + +mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items) { + mp_obj_list_t *o = list_new(n); + if (items != NULL) { + for (size_t i = 0; i < n; i++) { + o->items[i] = items[i]; + } + } + return MP_OBJ_FROM_PTR(o); +} + +void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + *len = self->len; + *items = self->items; +} + +void mp_obj_list_set_len(mp_obj_t self_in, size_t len) { + // trust that the caller knows what it's doing + // TODO realloc if len got much smaller than alloc + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + self->len = len; +} + +void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + size_t i = mp_get_index(self->base.type, self->len, index, false); + self->items[i] = value; +} + +/******************************************************************************/ +/* list iterator */ + +typedef struct _mp_obj_list_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t list; + size_t cur; +} mp_obj_list_it_t; + +STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) { + mp_obj_list_it_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *list = MP_OBJ_TO_PTR(self->list); + if (self->cur < list->len) { + mp_obj_t o_out = list->items[self->cur]; + self->cur += 1; + return o_out; + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_list_it_t *o = (mp_obj_list_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = list_it_iternext; + o->list = list; + o->cur = cur; + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objlist.h b/user/mpy/py/objlist.h new file mode 100644 index 0000000..28b5495 --- /dev/null +++ b/user/mpy/py/objlist.h @@ -0,0 +1,38 @@ +/* + * 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 + +#include "py/obj.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; + +#endif // MICROPY_INCLUDED_PY_OBJLIST_H diff --git a/user/mpy/py/objmap.c b/user/mpy/py/objmap.c new file mode 100644 index 0000000..908c615 --- /dev/null +++ b/user/mpy/py/objmap.c @@ -0,0 +1,73 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime.h" + +typedef struct _mp_obj_map_t { + mp_obj_base_t base; + size_t n_iters; + mp_obj_t fun; + mp_obj_t iters[]; +} mp_obj_map_t; + +STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false); + mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1); + o->base.type = type; + o->n_iters = n_args - 1; + o->fun = args[0]; + for (size_t i = 0; i < n_args - 1; i++) { + o->iters[i] = mp_getiter(args[i + 1], NULL); + } + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t map_iternext(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_map)); + mp_obj_map_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters); + + for (size_t i = 0; i < self->n_iters; i++) { + mp_obj_t next = mp_iternext(self->iters[i]); + if (next == MP_OBJ_STOP_ITERATION) { + m_del(mp_obj_t, nextses, self->n_iters); + return MP_OBJ_STOP_ITERATION; + } + nextses[i] = next; + } + return mp_call_function_n_kw(self->fun, self->n_iters, 0, nextses); +} + +const mp_obj_type_t mp_type_map = { + { &mp_type_type }, + .name = MP_QSTR_map, + .make_new = map_make_new, + .getiter = mp_identity_getiter, + .iternext = map_iternext, +}; diff --git a/user/mpy/py/objmodule.c b/user/mpy/py/objmodule.c new file mode 100644 index 0000000..fc8507c --- /dev/null +++ b/user/mpy/py/objmodule.c @@ -0,0 +1,272 @@ +/* + * 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. + */ + +#include +#include + +#include "py/mpstate.h" +#include "py/nlr.h" +#include "py/objmodule.h" +#include "py/runtime.h" +#include "py/builtin.h" + +STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); + + const char *module_name = ""; + mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_MAP_LOOKUP); + if (elem != NULL) { + module_name = mp_obj_str_get_str(elem->value); + } + +#if MICROPY_PY___FILE__ + // If we store __file__ to imported modules then try to lookup this + // symbol to give more information about the module. + elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___file__), MP_MAP_LOOKUP); + if (elem != NULL) { + mp_printf(print, "", module_name, mp_obj_str_get_str(elem->value)); + return; + } +#endif + + mp_printf(print, "", module_name); +} + +STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); + if (dest[0] == MP_OBJ_NULL) { + // load attribute + mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); + if (elem != NULL) { + dest[0] = elem->value; + } + } else { + // delete/store attribute + mp_obj_dict_t *dict = self->globals; + if (dict->map.is_fixed) { + #if MICROPY_CAN_OVERRIDE_BUILTINS + if (dict == &mp_module_builtins_globals) { + if (MP_STATE_VM(mp_module_builtins_override_dict) == NULL) { + MP_STATE_VM(mp_module_builtins_override_dict) = MP_OBJ_TO_PTR(mp_obj_new_dict(1)); + } + dict = MP_STATE_VM(mp_module_builtins_override_dict); + } else + #endif + { + // can't delete or store to fixed map + return; + } + } + if (dest[1] == MP_OBJ_NULL) { + // delete attribute + mp_obj_dict_delete(MP_OBJ_FROM_PTR(dict), MP_OBJ_NEW_QSTR(attr)); + } else { + // store attribute + // TODO CPython allows STORE_ATTR to a module, but is this the correct implementation? + mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), MP_OBJ_NEW_QSTR(attr), dest[1]); + } + dest[0] = MP_OBJ_NULL; // indicate success + } +} + +const mp_obj_type_t mp_type_module = { + { &mp_type_type }, + .name = MP_QSTR_module, + .print = module_print, + .attr = module_attr, +}; + +mp_obj_t mp_obj_new_module(qstr module_name) { + mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; + mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + // We could error out if module already exists, but let C extensions + // add new members to existing modules. + if (el->value != MP_OBJ_NULL) { + return el->value; + } + + // create new module object + mp_obj_module_t *o = m_new_obj(mp_obj_module_t); + o->base.type = &mp_type_module; + o->globals = MP_OBJ_TO_PTR(mp_obj_new_dict(MICROPY_MODULE_DICT_SIZE)); + + // store __name__ entry in the module + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(module_name)); + + // store the new module into the slot in the global dict holding all modules + el->value = MP_OBJ_FROM_PTR(o); + + // return the new module + return MP_OBJ_FROM_PTR(o); +} + +mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_module)); + mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); + return self->globals; +} + +/******************************************************************************/ +// Global module table and related functions + +STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { + { MP_ROM_QSTR(MP_QSTR___main__), MP_ROM_PTR(&mp_module___main__) }, + { MP_ROM_QSTR(MP_QSTR_builtins), MP_ROM_PTR(&mp_module_builtins) }, + { MP_ROM_QSTR(MP_QSTR_micropython), MP_ROM_PTR(&mp_module_micropython) }, + +#if MICROPY_PY_ARRAY + { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_module_array) }, +#endif +#if MICROPY_PY_IO + { MP_ROM_QSTR(MP_QSTR_uio), MP_ROM_PTR(&mp_module_io) }, +#endif +#if MICROPY_PY_COLLECTIONS + { MP_ROM_QSTR(MP_QSTR_ucollections), MP_ROM_PTR(&mp_module_collections) }, +#endif +#if MICROPY_PY_STRUCT + { MP_ROM_QSTR(MP_QSTR_ustruct), MP_ROM_PTR(&mp_module_ustruct) }, +#endif + +#if MICROPY_PY_BUILTINS_FLOAT +#if MICROPY_PY_MATH + { MP_ROM_QSTR(MP_QSTR_math), MP_ROM_PTR(&mp_module_math) }, +#endif +#if MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH + { MP_ROM_QSTR(MP_QSTR_cmath), MP_ROM_PTR(&mp_module_cmath) }, +#endif +#endif +#if MICROPY_PY_SYS + { MP_ROM_QSTR(MP_QSTR_sys), MP_ROM_PTR(&mp_module_sys) }, +#endif +#if MICROPY_PY_GC && MICROPY_ENABLE_GC + { MP_ROM_QSTR(MP_QSTR_gc), MP_ROM_PTR(&mp_module_gc) }, +#endif +#if MICROPY_PY_THREAD + { MP_ROM_QSTR(MP_QSTR__thread), MP_ROM_PTR(&mp_module_thread) }, +#endif + + // extmod modules + +#if MICROPY_PY_UERRNO + { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) }, +#endif +#if MICROPY_PY_UCTYPES + { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, +#endif +#if MICROPY_PY_UZLIB + { MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) }, +#endif +#if MICROPY_PY_UJSON + { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) }, +#endif +#if MICROPY_PY_URE + { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) }, +#endif +#if MICROPY_PY_UHEAPQ + { MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) }, +#endif +#if MICROPY_PY_UTIMEQ + { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&mp_module_utimeq) }, +#endif +#if MICROPY_PY_UHASHLIB + { MP_ROM_QSTR(MP_QSTR_uhashlib), MP_ROM_PTR(&mp_module_uhashlib) }, +#endif +#if MICROPY_PY_UBINASCII + { MP_ROM_QSTR(MP_QSTR_ubinascii), MP_ROM_PTR(&mp_module_ubinascii) }, +#endif +#if MICROPY_PY_URANDOM + { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_module_urandom) }, +#endif +#if MICROPY_PY_USELECT + { MP_ROM_QSTR(MP_QSTR_uselect), MP_ROM_PTR(&mp_module_uselect) }, +#endif +#if MICROPY_PY_USSL + { MP_ROM_QSTR(MP_QSTR_ussl), MP_ROM_PTR(&mp_module_ussl) }, +#endif +#if MICROPY_PY_LWIP + { MP_ROM_QSTR(MP_QSTR_lwip), MP_ROM_PTR(&mp_module_lwip) }, +#endif +#if MICROPY_PY_WEBSOCKET + { MP_ROM_QSTR(MP_QSTR_websocket), MP_ROM_PTR(&mp_module_websocket) }, +#endif +#if MICROPY_PY_WEBREPL + { MP_ROM_QSTR(MP_QSTR__webrepl), MP_ROM_PTR(&mp_module_webrepl) }, +#endif +#if MICROPY_PY_FRAMEBUF + { MP_ROM_QSTR(MP_QSTR_framebuf), MP_ROM_PTR(&mp_module_framebuf) }, +#endif +#if MICROPY_PY_BTREE + { MP_ROM_QSTR(MP_QSTR_btree), MP_ROM_PTR(&mp_module_btree) }, +#endif + + // extra builtin modules as defined by a port + MICROPY_PORT_BUILTIN_MODULES +}; + +MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); + +#if MICROPY_MODULE_WEAK_LINKS +STATIC const mp_rom_map_elem_t mp_builtin_module_weak_links_table[] = { + MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS +}; + +MP_DEFINE_CONST_MAP(mp_builtin_module_weak_links_map, mp_builtin_module_weak_links_table); +#endif + +// returns MP_OBJ_NULL if not found +mp_obj_t mp_module_get(qstr module_name) { + mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; + // lookup module + mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + + if (el == NULL) { + // module not found, look for builtin module names + el = mp_map_lookup((mp_map_t*)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + if (el == NULL) { + return MP_OBJ_NULL; + } + + if (MICROPY_MODULE_BUILTIN_INIT) { + // look for __init__ and call it if it exists + mp_obj_t dest[2]; + mp_load_method_maybe(el->value, MP_QSTR___init__, dest); + if (dest[0] != MP_OBJ_NULL) { + mp_call_method_n_kw(0, 0, dest); + // register module so __init__ is not called again + mp_module_register(module_name, el->value); + } + } + } + + // module found, return it + return el->value; +} + +void mp_module_register(qstr qst, mp_obj_t module) { + mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; + mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; +} diff --git a/user/mpy/py/objmodule.h b/user/mpy/py/objmodule.h new file mode 100644 index 0000000..b5c07dc --- /dev/null +++ b/user/mpy/py/objmodule.h @@ -0,0 +1,37 @@ +/* + * 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_OBJMODULE_H +#define MICROPY_INCLUDED_PY_OBJMODULE_H + +#include "py/obj.h" + +extern const mp_map_t mp_builtin_module_map; +extern const mp_map_t mp_builtin_module_weak_links_map; + +mp_obj_t mp_module_get(qstr module_name); +void mp_module_register(qstr qstr, mp_obj_t module); + +#endif // MICROPY_INCLUDED_PY_OBJMODULE_H diff --git a/user/mpy/py/objnamedtuple.c b/user/mpy/py/objnamedtuple.c new file mode 100644 index 0000000..fb9d9f0 --- /dev/null +++ b/user/mpy/py/objnamedtuple.c @@ -0,0 +1,165 @@ +/* + * 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. + */ + +#include + +#include "py/nlr.h" +#include "py/objtuple.h" +#include "py/runtime.h" +#include "py/objstr.h" + +#if MICROPY_PY_COLLECTIONS + +typedef struct _mp_obj_namedtuple_type_t { + mp_obj_type_t base; + size_t n_fields; + qstr fields[]; +} mp_obj_namedtuple_type_t; + +typedef struct _mp_obj_namedtuple_t { + mp_obj_tuple_t tuple; +} mp_obj_namedtuple_t; + +STATIC size_t namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name) { + for (size_t i = 0; i < type->n_fields; i++) { + if (type->fields[i] == name) { + return i; + } + } + return (size_t)-1; +} + +STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_namedtuple_t *o = MP_OBJ_TO_PTR(o_in); + mp_printf(print, "%q", o->tuple.base.type->name); + const qstr *fields = ((mp_obj_namedtuple_type_t*)o->tuple.base.type)->fields; + mp_obj_attrtuple_print_helper(print, fields, &o->tuple); +} + +STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] == MP_OBJ_NULL) { + // load attribute + mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in); + size_t id = namedtuple_find_field((mp_obj_namedtuple_type_t*)self->tuple.base.type, attr); + if (id == (size_t)-1) { + return; + } + dest[0] = self->tuple.items[id]; + } else { + // delete/store attribute + // provide more detailed error message than we'd get by just returning + mp_raise_msg(&mp_type_AttributeError, "can't set attribute"); + } +} + +STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t*)type_in; + size_t num_fields = type->n_fields; + if (n_args + n_kw != num_fields) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function takes %d positional arguments but %d were given", + num_fields, n_args + n_kw)); + } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "%q() takes %d positional arguments but %d were given", + type->base.name, num_fields, n_args + n_kw)); + } + } + + // Create a tuple and set the type to this namedtuple + mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_fields, NULL)); + tuple->base.type = type_in; + + // Copy the positional args into the first slots of the namedtuple + memcpy(&tuple->items[0], args, sizeof(mp_obj_t) * n_args); + + // Fill in the remaining slots with the keyword args + memset(&tuple->items[n_args], 0, sizeof(mp_obj_t) * n_kw); + for (size_t i = n_args; i < n_args + 2 * n_kw; i += 2) { + qstr kw = mp_obj_str_get_qstr(args[i]); + size_t id = namedtuple_find_field(type, kw); + if (id == (size_t)-1) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "unexpected keyword argument '%q'", kw)); + } + } + if (tuple->items[id] != MP_OBJ_NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_arg_error_terse_mismatch(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "function got multiple values for argument '%q'", kw)); + } + } + tuple->items[id] = args[i + 1]; + } + + return MP_OBJ_FROM_PTR(tuple); +} + +STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) { + mp_obj_namedtuple_type_t *o = m_new_obj_var(mp_obj_namedtuple_type_t, qstr, n_fields); + memset(&o->base, 0, sizeof(o->base)); + o->base.base.type = &mp_type_type; + o->base.name = name; + o->base.print = namedtuple_print; + o->base.make_new = namedtuple_make_new; + o->base.unary_op = mp_obj_tuple_unary_op; + o->base.binary_op = mp_obj_tuple_binary_op; + o->base.attr = namedtuple_attr; + o->base.subscr = mp_obj_tuple_subscr; + o->base.getiter = mp_obj_tuple_getiter; + o->base.parent = &mp_type_tuple; + o->n_fields = n_fields; + for (size_t i = 0; i < n_fields; i++) { + o->fields[i] = mp_obj_str_get_qstr(fields[i]); + } + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) { + qstr name = mp_obj_str_get_qstr(name_in); + size_t n_fields; + mp_obj_t *fields; + #if MICROPY_CPYTHON_COMPAT + if (MP_OBJ_IS_STR(fields_in)) { + fields_in = mp_obj_str_split(1, &fields_in); + } + #endif + mp_obj_get_array(fields_in, &n_fields, &fields); + return mp_obj_new_namedtuple_type(name, n_fields, fields); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_namedtuple_obj, new_namedtuple_type); + +#endif // MICROPY_PY_COLLECTIONS diff --git a/user/mpy/py/objnone.c b/user/mpy/py/objnone.c new file mode 100644 index 0000000..cd7319b --- /dev/null +++ b/user/mpy/py/objnone.c @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" + +typedef struct _mp_obj_none_t { + mp_obj_base_t base; +} mp_obj_none_t; + +STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)self_in; + if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + mp_print_str(print, "null"); + } else { + mp_print_str(print, "None"); + } +} + +const mp_obj_type_t mp_type_NoneType = { + { &mp_type_type }, + .name = MP_QSTR_NoneType, + .print = none_print, + .unary_op = mp_generic_unary_op, +}; + +const mp_obj_none_t mp_const_none_obj = {{&mp_type_NoneType}}; diff --git a/user/mpy/py/objobject.c b/user/mpy/py/objobject.c new file mode 100644 index 0000000..49d2ec6 --- /dev/null +++ b/user/mpy/py/objobject.c @@ -0,0 +1,81 @@ +/* + * 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. + */ + +#include + +#include "py/objtype.h" +#include "py/runtime.h" + +typedef struct _mp_obj_object_t { + mp_obj_base_t base; +} mp_obj_object_t; + +STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)args; + mp_arg_check_num(n_args, n_kw, 0, 0, false); + mp_obj_object_t *o = m_new_obj(mp_obj_object_t); + o->base.type = type; + return MP_OBJ_FROM_PTR(o); +} + +#if MICROPY_CPYTHON_COMPAT +STATIC mp_obj_t object___init__(mp_obj_t self) { + (void)self; + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__); + +STATIC mp_obj_t object___new__(mp_obj_t cls) { + if (!MP_OBJ_IS_TYPE(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t*)MP_OBJ_TO_PTR(cls))) { + mp_raise_TypeError("__new__ arg must be a user-type"); + } + mp_obj_t o = MP_OBJ_SENTINEL; + mp_obj_t res = mp_obj_instance_make_new(MP_OBJ_TO_PTR(cls), 1, 0, &o); + return res; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__); +STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj)); + +STATIC const mp_rom_map_elem_t object_locals_dict_table[] = { + #if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&object___init___obj) }, + #endif + #if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR___new__), MP_ROM_PTR(&object___new___obj) }, + #endif +}; + +STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table); +#endif + +const mp_obj_type_t mp_type_object = { + { &mp_type_type }, + .name = MP_QSTR_object, + .make_new = object_make_new, + #if MICROPY_CPYTHON_COMPAT + .locals_dict = (mp_obj_dict_t*)&object_locals_dict, + #endif +}; diff --git a/user/mpy/py/objpolyiter.c b/user/mpy/py/objpolyiter.c new file mode 100644 index 0000000..61bd1e0 --- /dev/null +++ b/user/mpy/py/objpolyiter.c @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 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. + */ + +#include + +#include "py/nlr.h" +#include "py/runtime.h" + +// This is universal iterator type which calls "iternext" method stored in +// particular object instance. (So, each instance of this time can have its +// own iteration behavior.) Having this type saves to define type objects +// for various internal iterator objects. + +// Any instance should have these 2 fields at the beginning +typedef struct _mp_obj_polymorph_iter_t { + mp_obj_base_t base; + mp_fun_1_t iternext; +} mp_obj_polymorph_iter_t; + +STATIC mp_obj_t polymorph_it_iternext(mp_obj_t self_in) { + mp_obj_polymorph_iter_t *self = MP_OBJ_TO_PTR(self_in); + // Redirect call to object instance's iternext method + return self->iternext(self_in); +} + +const mp_obj_type_t mp_type_polymorph_iter = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = polymorph_it_iternext, +}; diff --git a/user/mpy/py/objproperty.c b/user/mpy/py/objproperty.c new file mode 100644 index 0000000..0934fad --- /dev/null +++ b/user/mpy/py/objproperty.c @@ -0,0 +1,108 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_PROPERTY + +typedef struct _mp_obj_property_t { + mp_obj_base_t base; + mp_obj_t proxy[3]; // getter, setter, deleter +} mp_obj_property_t; + +STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + enum { ARG_fget, ARG_fset, ARG_fdel, ARG_doc }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + { MP_QSTR_doc, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, + }; + mp_arg_val_t vals[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, vals); + + mp_obj_property_t *o = m_new_obj(mp_obj_property_t); + o->base.type = type; + o->proxy[0] = vals[ARG_fget].u_obj; + o->proxy[1] = vals[ARG_fset].u_obj; + o->proxy[2] = vals[ARG_fdel].u_obj; + // vals[ARG_doc] is silently discarded + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) { + mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t); + *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in); + p2->proxy[0] = getter; + return MP_OBJ_FROM_PTR(p2); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter); + +STATIC mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) { + mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t); + *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in); + p2->proxy[1] = setter; + return MP_OBJ_FROM_PTR(p2); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter); + +STATIC mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) { + mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t); + *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in); + p2->proxy[2] = deleter; + return MP_OBJ_FROM_PTR(p2); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter); + +STATIC const mp_rom_map_elem_t property_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_getter), MP_ROM_PTR(&property_getter_obj) }, + { MP_ROM_QSTR(MP_QSTR_setter), MP_ROM_PTR(&property_setter_obj) }, + { MP_ROM_QSTR(MP_QSTR_deleter), MP_ROM_PTR(&property_deleter_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table); + +const mp_obj_type_t mp_type_property = { + { &mp_type_type }, + .name = MP_QSTR_property, + .make_new = property_make_new, + .locals_dict = (mp_obj_dict_t*)&property_locals_dict, +}; + +const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_property)); + mp_obj_property_t *self = MP_OBJ_TO_PTR(self_in); + return self->proxy; +} + +#endif // MICROPY_PY_BUILTINS_PROPERTY diff --git a/user/mpy/py/objrange.c b/user/mpy/py/objrange.c new file mode 100644 index 0000000..33b07a9 --- /dev/null +++ b/user/mpy/py/objrange.c @@ -0,0 +1,205 @@ +/* + * 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. + */ + +#include + +#include "py/nlr.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +/******************************************************************************/ +/* range iterator */ + +typedef struct _mp_obj_range_it_t { + mp_obj_base_t base; + // TODO make these values generic objects or something + mp_int_t cur; + mp_int_t stop; + mp_int_t step; +} mp_obj_range_it_t; + +STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) { + mp_obj_range_it_t *o = MP_OBJ_TO_PTR(o_in); + if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) { + mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(o->cur); + o->cur += o->step; + return o_out; + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +STATIC const mp_obj_type_t range_it_type = { + { &mp_type_type }, + .name = MP_QSTR_iterator, + .getiter = mp_identity_getiter, + .iternext = range_it_iternext, +}; + +STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_range_it_t *o = (mp_obj_range_it_t*)iter_buf; + o->base.type = &range_it_type; + o->cur = cur; + o->stop = stop; + o->step = step; + return MP_OBJ_FROM_PTR(o); +} + +/******************************************************************************/ +/* range */ + +typedef struct _mp_obj_range_t { + mp_obj_base_t base; + // TODO make these values generic objects or something + mp_int_t start; + mp_int_t stop; + mp_int_t step; +} mp_obj_range_t; + +STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "range(" INT_FMT ", " INT_FMT "", self->start, self->stop); + if (self->step == 1) { + mp_print_str(print, ")"); + } else { + mp_printf(print, ", " INT_FMT ")", self->step); + } +} + +STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 3, false); + + mp_obj_range_t *o = m_new_obj(mp_obj_range_t); + o->base.type = type; + o->start = 0; + o->step = 1; + + if (n_args == 1) { + o->stop = mp_obj_get_int(args[0]); + } else { + o->start = mp_obj_get_int(args[0]); + o->stop = mp_obj_get_int(args[1]); + if (n_args == 3) { + o->step = mp_obj_get_int(args[2]); + if (o->step == 0) { + mp_raise_ValueError("zero step"); + } + } + } + + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_int_t range_len(mp_obj_range_t *self) { + // When computing length, need to take into account step!=1 and step<0. + mp_int_t len = self->stop - self->start + self->step; + if (self->step > 0) { + len -= 1; + } else { + len += 1; + } + len = len / self->step; + if (len < 0) { + len = 0; + } + return len; +} + +STATIC mp_obj_t range_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t len = range_len(self); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len > 0); + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_SENTINEL) { + // load + mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t len = range_len(self); +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_bound_slice_t slice; + mp_seq_get_fast_slice_indexes(len, index, &slice); + mp_obj_range_t *o = m_new_obj(mp_obj_range_t); + o->base.type = &mp_type_range; + o->start = self->start + slice.start * self->step; + o->stop = self->start + slice.stop * self->step; + o->step = slice.step * self->step; + if (slice.step < 0) { + // Negative slice steps have inclusive stop, so adjust for exclusive + o->stop -= self->step; + } + return MP_OBJ_FROM_PTR(o); + } +#endif + size_t index_val = mp_get_index(self->base.type, len, index, false); + return MP_OBJ_NEW_SMALL_INT(self->start + index_val * self->step); + } else { + return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in); + return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf); +} + + +#if MICROPY_PY_BUILTINS_RANGE_ATTRS +STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != MP_OBJ_NULL) { + // not load attribute + return; + } + mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in); + if (attr == MP_QSTR_start) { + dest[0] = mp_obj_new_int(o->start); + } else if (attr == MP_QSTR_stop) { + dest[0] = mp_obj_new_int(o->stop); + } else if (attr == MP_QSTR_step) { + dest[0] = mp_obj_new_int(o->step); + } +} +#endif + +const mp_obj_type_t mp_type_range = { + { &mp_type_type }, + .name = MP_QSTR_range, + .print = range_print, + .make_new = range_make_new, + .unary_op = range_unary_op, + .subscr = range_subscr, + .getiter = range_getiter, +#if MICROPY_PY_BUILTINS_RANGE_ATTRS + .attr = range_attr, +#endif +}; diff --git a/user/mpy/py/objreversed.c b/user/mpy/py/objreversed.c new file mode 100644 index 0000000..a596a2f --- /dev/null +++ b/user/mpy/py/objreversed.c @@ -0,0 +1,81 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_REVERSED + +typedef struct _mp_obj_reversed_t { + mp_obj_base_t base; + mp_obj_t seq; // sequence object that we are reversing + mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0) +} mp_obj_reversed_t; + +STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); + + // check if __reversed__ exists, and if so delegate to it + mp_obj_t dest[2]; + mp_load_method_maybe(args[0], MP_QSTR___reversed__, dest); + if (dest[0] != MP_OBJ_NULL) { + return mp_call_method_n_kw(0, 0, dest); + } + + mp_obj_reversed_t *o = m_new_obj(mp_obj_reversed_t); + o->base.type = type; + o->seq = args[0]; + o->cur_index = mp_obj_get_int(mp_obj_len(args[0])); // start at the end of the sequence + + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_reversed)); + mp_obj_reversed_t *self = MP_OBJ_TO_PTR(self_in); + + // "raise" stop iteration if we are at the end (the start) of the sequence + if (self->cur_index == 0) { + return MP_OBJ_STOP_ITERATION; + } + + // pre-decrement and index sequence + self->cur_index -= 1; + return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); +} + +const mp_obj_type_t mp_type_reversed = { + { &mp_type_type }, + .name = MP_QSTR_reversed, + .make_new = reversed_make_new, + .getiter = mp_identity_getiter, + .iternext = reversed_iternext, +}; + +#endif // MICROPY_PY_BUILTINS_REVERSED diff --git a/user/mpy/py/objset.c b/user/mpy/py/objset.c new file mode 100644 index 0000000..376439b --- /dev/null +++ b/user/mpy/py/objset.c @@ -0,0 +1,609 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/runtime0.h" +#include "py/builtin.h" + +#if MICROPY_PY_BUILTINS_SET + +typedef struct _mp_obj_set_t { + mp_obj_base_t base; + mp_set_t set; +} mp_obj_set_t; + +typedef struct _mp_obj_set_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_set_t *set; + size_t cur; +} mp_obj_set_it_t; + +STATIC mp_obj_t set_it_iternext(mp_obj_t self_in); + +STATIC bool is_set_or_frozenset(mp_obj_t o) { + return MP_OBJ_IS_TYPE(o, &mp_type_set) +#if MICROPY_PY_BUILTINS_FROZENSET + || MP_OBJ_IS_TYPE(o, &mp_type_frozenset) +#endif + ; +} + +// This macro is shorthand for mp_check_self to verify the argument is a +// set or frozenset for methods that operate on both of these types. +#define check_set_or_frozenset(o) mp_check_self(is_set_or_frozenset(o)) + +// This function is used to verify the argument for methods that modify +// the set object, and raises an exception if the arg is a frozenset. +STATIC void check_set(mp_obj_t o) { + #if MICROPY_PY_BUILTINS_FROZENSET + if (MP_OBJ_IS_TYPE(o, &mp_type_frozenset)) { + // Mutable method called on frozenset; emulate CPython behavior, eg: + // AttributeError: 'frozenset' object has no attribute 'add' + mp_raise_msg(&mp_type_AttributeError, "'frozenset' has no such attribute"); + } + #endif + mp_check_self(MP_OBJ_IS_TYPE(o, &mp_type_set)); +} + +STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + #if MICROPY_PY_BUILTINS_FROZENSET + bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset); + #endif + if (self->set.used == 0) { + #if MICROPY_PY_BUILTINS_FROZENSET + if (is_frozen) { + mp_print_str(print, "frozen"); + } + #endif + mp_print_str(print, "set()"); + return; + } + bool first = true; + #if MICROPY_PY_BUILTINS_FROZENSET + if (is_frozen) { + mp_print_str(print, "frozenset("); + } + #endif + mp_print_str(print, "{"); + for (size_t i = 0; i < self->set.alloc; i++) { + if (MP_SET_SLOT_IS_FILLED(&self->set, i)) { + if (!first) { + mp_print_str(print, ", "); + } + first = false; + mp_obj_print_helper(print, self->set.table[i], PRINT_REPR); + } + } + mp_print_str(print, "}"); + #if MICROPY_PY_BUILTINS_FROZENSET + if (is_frozen) { + mp_print_str(print, ")"); + } + #endif +} + +STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); + + switch (n_args) { + case 0: { + // create a new, empty set + mp_obj_set_t *set = MP_OBJ_TO_PTR(mp_obj_new_set(0, NULL)); + // set actual set/frozenset type + set->base.type = type; + return MP_OBJ_FROM_PTR(set); + } + + case 1: + default: { // can only be 0 or 1 arg + // 1 argument, an iterable from which we make a new set + mp_obj_t set = mp_obj_new_set(0, NULL); + mp_obj_t iterable = mp_getiter(args[0], NULL); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + mp_obj_set_store(set, item); + } + // Set actual set/frozenset type + ((mp_obj_set_t*)MP_OBJ_TO_PTR(set))->base.type = type; + return set; + } + } +} + +STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) { + mp_obj_set_it_t *self = MP_OBJ_TO_PTR(self_in); + size_t max = self->set->set.alloc; + mp_set_t *set = &self->set->set; + + for (size_t i = self->cur; i < max; i++) { + if (MP_SET_SLOT_IS_FILLED(set, i)) { + self->cur = i + 1; + return set->table[i]; + } + } + + return MP_OBJ_STOP_ITERATION; +} + +STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_set_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_set_it_t *o = (mp_obj_set_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = set_it_iternext; + o->set = (mp_obj_set_t *)MP_OBJ_TO_PTR(set_in); + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} + + +/******************************************************************************/ +/* set methods */ + +STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) { + check_set(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add); + +STATIC mp_obj_t set_clear(mp_obj_t self_in) { + check_set(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + + mp_set_clear(&self->set); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear); + +STATIC mp_obj_t set_copy_as_mutable(mp_obj_t self_in) { + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_set_t *other = m_new_obj(mp_obj_set_t); + other->base.type = &mp_type_set; + mp_set_init(&other->set, self->set.alloc); + other->set.used = self->set.used; + memcpy(other->set.table, self->set.table, self->set.alloc * sizeof(mp_obj_t)); + + return MP_OBJ_FROM_PTR(other); +} + +STATIC mp_obj_t set_copy(mp_obj_t self_in) { + check_set_or_frozenset(self_in); + + mp_obj_t other = set_copy_as_mutable(self_in); + ((mp_obj_base_t*)MP_OBJ_TO_PTR(other))->type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(self_in))->type; + + return other; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy); + +STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) { + check_set(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard); + +STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) { + mp_obj_t self; + if (update) { + check_set(args[0]); + self = args[0]; + } else { + check_set_or_frozenset(args[0]); + self = set_copy_as_mutable(args[0]); + } + + + for (size_t i = 1; i < n_args; i++) { + mp_obj_t other = args[i]; + if (self == other) { + set_clear(self); + } else { + mp_obj_t iter = mp_getiter(other, NULL); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + set_discard(self, next); + } + } + } + + ((mp_obj_base_t*)MP_OBJ_TO_PTR(self))->type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]))->type; + return self; +} + +STATIC mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) { + return set_diff_int(n_args, args, false); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff); + +STATIC mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) { + set_diff_int(n_args, args, true); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update); + +STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) { + if (update) { + check_set(self_in); + } else { + check_set_or_frozenset(self_in); + } + + if (self_in == other) { + return update ? mp_const_none : set_copy(self_in); + } + + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_set_t *out = MP_OBJ_TO_PTR(mp_obj_new_set(0, NULL)); + + mp_obj_t iter = mp_getiter(other, NULL); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) { + set_add(MP_OBJ_FROM_PTR(out), next); + } + } + + if (update) { + m_del(mp_obj_t, self->set.table, self->set.alloc); + self->set.alloc = out->set.alloc; + self->set.used = out->set.used; + self->set.table = out->set.table; + } + + return update ? mp_const_none : MP_OBJ_FROM_PTR(out); +} + +STATIC mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) { + return set_intersect_int(self_in, other, false); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect); + +STATIC mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) { + return set_intersect_int(self_in, other, true); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update); + +STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) { + check_set_or_frozenset(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_iter_buf_t iter_buf; + mp_obj_t iter = mp_getiter(other, &iter_buf); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) { + return mp_const_false; + } + } + return mp_const_true; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint); + +STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) { + mp_obj_set_t *self; + bool cleanup_self = false; + if (is_set_or_frozenset(self_in)) { + self = MP_OBJ_TO_PTR(self_in); + } else { + self = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, 0, &self_in)); + cleanup_self = true; + } + + mp_obj_set_t *other; + bool cleanup_other = false; + if (is_set_or_frozenset(other_in)) { + other = MP_OBJ_TO_PTR(other_in); + } else { + other = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, 0, &other_in)); + cleanup_other = true; + } + bool out = true; + if (proper && self->set.used == other->set.used) { + out = false; + } else { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iter = set_getiter(MP_OBJ_FROM_PTR(self), &iter_buf); + mp_obj_t next; + while ((next = set_it_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + if (!mp_set_lookup(&other->set, next, MP_MAP_LOOKUP)) { + out = false; + break; + } + } + } + // TODO: Should free objects altogether + if (cleanup_self) { + set_clear(MP_OBJ_FROM_PTR(self)); + } + if (cleanup_other) { + set_clear(MP_OBJ_FROM_PTR(other)); + } + return mp_obj_new_bool(out); +} +STATIC mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) { + return set_issubset_internal(self_in, other_in, false); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset); + +STATIC mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) { + return set_issubset_internal(self_in, other_in, true); +} + +STATIC mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) { + return set_issubset_internal(other_in, self_in, false); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset); + +STATIC mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) { + return set_issubset_internal(other_in, self_in, true); +} + +STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) { + check_set_or_frozenset(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + if (!is_set_or_frozenset(other_in)) { + return mp_const_false; + } + mp_obj_set_t *other = MP_OBJ_TO_PTR(other_in); + if (self->set.used != other->set.used) { + return mp_const_false; + } + return set_issubset(self_in, other_in); +} + +STATIC mp_obj_t set_pop(mp_obj_t self_in) { + check_set(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t obj = mp_set_remove_first(&self->set); + if (obj == MP_OBJ_NULL) { + mp_raise_msg(&mp_type_KeyError, "pop from an empty set"); + } + return obj; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop); + +STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) { + check_set(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) { + nlr_raise(mp_obj_new_exception(&mp_type_KeyError)); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove); + +STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) { + check_set(self_in); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t iter = mp_getiter(other_in, NULL); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND_OR_REMOVE_IF_FOUND); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update); + +STATIC mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) { + check_set_or_frozenset(self_in); + mp_obj_t self_out = set_copy_as_mutable(self_in); + set_symmetric_difference_update(self_out, other_in); + ((mp_obj_base_t*)MP_OBJ_TO_PTR(self_out))->type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(self_in))->type; + return self_out; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference); + +STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) { + mp_obj_t iter = mp_getiter(other_in, NULL); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + } +} + +STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) { + check_set(args[0]); + for (size_t i = 1; i < n_args; i++) { + set_update_int(MP_OBJ_TO_PTR(args[0]), args[i]); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update); + +STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) { + check_set_or_frozenset(self_in); + mp_obj_t self = set_copy(self_in); + set_update_int(MP_OBJ_TO_PTR(self), other_in); + return self; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union); + +STATIC mp_obj_t set_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->set.used != 0); + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->set.used); +#if MICROPY_PY_BUILTINS_FROZENSET + case MP_UNARY_OP_HASH: + if (MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset)) { + // start hash with unique value + mp_int_t hash = (mp_int_t)(uintptr_t)&mp_type_frozenset; + size_t max = self->set.alloc; + mp_set_t *set = &self->set; + + for (size_t i = 0; i < max; i++) { + if (MP_SET_SLOT_IS_FILLED(set, i)) { + hash += MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, set->table[i])); + } + } + return MP_OBJ_NEW_SMALL_INT(hash); + } +#endif + default: return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t set_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + mp_obj_t args[] = {lhs, rhs}; + #if MICROPY_PY_BUILTINS_FROZENSET + bool update = MP_OBJ_IS_TYPE(lhs, &mp_type_set); + #else + bool update = true; + #endif + switch (op) { + case MP_BINARY_OP_OR: + return set_union(lhs, rhs); + case MP_BINARY_OP_XOR: + return set_symmetric_difference(lhs, rhs); + case MP_BINARY_OP_AND: + return set_intersect(lhs, rhs); + case MP_BINARY_OP_SUBTRACT: + return set_diff(2, args); + case MP_BINARY_OP_INPLACE_OR: + if (update) { + set_update(2, args); + return lhs; + } else { + return set_union(lhs, rhs); + } + case MP_BINARY_OP_INPLACE_XOR: + if (update) { + set_symmetric_difference_update(lhs, rhs); + return lhs; + } else { + return set_symmetric_difference(lhs, rhs); + } + case MP_BINARY_OP_INPLACE_AND: + rhs = set_intersect_int(lhs, rhs, update); + if (update) { + return lhs; + } else { + return rhs; + } + case MP_BINARY_OP_INPLACE_SUBTRACT: + return set_diff_int(2, args, update); + case MP_BINARY_OP_LESS: + return set_issubset_proper(lhs, rhs); + case MP_BINARY_OP_MORE: + return set_issuperset_proper(lhs, rhs); + case MP_BINARY_OP_EQUAL: + return set_equal(lhs, rhs); + case MP_BINARY_OP_LESS_EQUAL: + return set_issubset(lhs, rhs); + case MP_BINARY_OP_MORE_EQUAL: + return set_issuperset(lhs, rhs); + case MP_BINARY_OP_IN: { + mp_obj_set_t *o = MP_OBJ_TO_PTR(lhs); + mp_obj_t elem = mp_set_lookup(&o->set, rhs, MP_MAP_LOOKUP); + return mp_obj_new_bool(elem != MP_OBJ_NULL); + } + default: + return MP_OBJ_NULL; // op not supported + } +} + +/******************************************************************************/ +/* set constructors & public C API */ + + +STATIC const mp_rom_map_elem_t set_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_add), MP_ROM_PTR(&set_add_obj) }, + { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&set_clear_obj) }, + { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) }, + { MP_ROM_QSTR(MP_QSTR_discard), MP_ROM_PTR(&set_discard_obj) }, + { MP_ROM_QSTR(MP_QSTR_difference), MP_ROM_PTR(&set_diff_obj) }, + { MP_ROM_QSTR(MP_QSTR_difference_update), MP_ROM_PTR(&set_diff_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_intersection), MP_ROM_PTR(&set_intersect_obj) }, + { MP_ROM_QSTR(MP_QSTR_intersection_update), MP_ROM_PTR(&set_intersect_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_isdisjoint), MP_ROM_PTR(&set_isdisjoint_obj) }, + { MP_ROM_QSTR(MP_QSTR_issubset), MP_ROM_PTR(&set_issubset_obj) }, + { MP_ROM_QSTR(MP_QSTR_issuperset), MP_ROM_PTR(&set_issuperset_obj) }, + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&set_pop_obj) }, + { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&set_remove_obj) }, + { MP_ROM_QSTR(MP_QSTR_symmetric_difference), MP_ROM_PTR(&set_symmetric_difference_obj) }, + { MP_ROM_QSTR(MP_QSTR_symmetric_difference_update), MP_ROM_PTR(&set_symmetric_difference_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_union), MP_ROM_PTR(&set_union_obj) }, + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&set_update_obj) }, + { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table); + +const mp_obj_type_t mp_type_set = { + { &mp_type_type }, + .name = MP_QSTR_set, + .print = set_print, + .make_new = set_make_new, + .unary_op = set_unary_op, + .binary_op = set_binary_op, + .getiter = set_getiter, + .locals_dict = (mp_obj_dict_t*)&set_locals_dict, +}; + +#if MICROPY_PY_BUILTINS_FROZENSET +const mp_obj_type_t mp_type_frozenset = { + { &mp_type_type }, + .name = MP_QSTR_frozenset, + .print = set_print, + .make_new = set_make_new, + .unary_op = set_unary_op, + .binary_op = set_binary_op, + .getiter = set_getiter, + .locals_dict = (mp_obj_dict_t*)&set_locals_dict, +}; +#endif + +mp_obj_t mp_obj_new_set(size_t n_args, mp_obj_t *items) { + mp_obj_set_t *o = m_new_obj(mp_obj_set_t); + o->base.type = &mp_type_set; + mp_set_init(&o->set, n_args); + for (size_t i = 0; i < n_args; i++) { + mp_set_lookup(&o->set, items[i], MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + } + return MP_OBJ_FROM_PTR(o); +} + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_set)); + mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); + mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); +} + +#endif // MICROPY_PY_BUILTINS_SET diff --git a/user/mpy/py/objsingleton.c b/user/mpy/py/objsingleton.c new file mode 100644 index 0000000..ea72ae3 --- /dev/null +++ b/user/mpy/py/objsingleton.c @@ -0,0 +1,57 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" + +/******************************************************************************/ +/* singleton objects defined by Python */ + +typedef struct _mp_obj_singleton_t { + mp_obj_base_t base; + qstr name; +} mp_obj_singleton_t; + +STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_singleton_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "%q", self->name); +} + +const mp_obj_type_t mp_type_singleton = { + { &mp_type_type }, + .name = MP_QSTR_, + .print = singleton_print, +}; + +const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis}; +#if MICROPY_PY_BUILTINS_NOTIMPLEMENTED +const mp_obj_singleton_t mp_const_notimplemented_obj = {{&mp_type_singleton}, MP_QSTR_NotImplemented}; +#endif diff --git a/user/mpy/py/objslice.c b/user/mpy/py/objslice.c new file mode 100644 index 0000000..358c44d --- /dev/null +++ b/user/mpy/py/objslice.c @@ -0,0 +1,103 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" + +/******************************************************************************/ +/* slice object */ + +#if MICROPY_PY_BUILTINS_SLICE + +// TODO: This implements only variant of slice with 2 integer args only. +// CPython supports 3rd arg (step), plus args can be arbitrary Python objects. +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; + +STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_slice_t *o = MP_OBJ_TO_PTR(o_in); + mp_print_str(print, "slice("); + mp_obj_print_helper(print, o->start, PRINT_REPR); + mp_print_str(print, ", "); + mp_obj_print_helper(print, o->stop, PRINT_REPR); + mp_print_str(print, ", "); + mp_obj_print_helper(print, o->step, PRINT_REPR); + mp_print_str(print, ")"); +} + +#if MICROPY_PY_BUILTINS_SLICE_ATTRS +STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != MP_OBJ_NULL) { + // not load attribute + return; + } + mp_obj_slice_t *self = MP_OBJ_TO_PTR(self_in); + if (attr == MP_QSTR_start) { + dest[0] = self->start; + } else if (attr == MP_QSTR_stop) { + dest[0] = self->stop; + } else if (attr == MP_QSTR_step) { + dest[0] = self->step; + } +} +#endif + +const mp_obj_type_t mp_type_slice = { + { &mp_type_type }, + .name = MP_QSTR_slice, + .print = slice_print, +#if MICROPY_PY_BUILTINS_SLICE_ATTRS + .attr = slice_attr, +#endif +}; + +mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) { + mp_obj_slice_t *o = m_new_obj(mp_obj_slice_t); + o->base.type = &mp_type_slice; + o->start = ostart; + o->stop = ostop; + o->step = ostep; + return MP_OBJ_FROM_PTR(o); +} + +void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_slice)); + mp_obj_slice_t *self = MP_OBJ_TO_PTR(self_in); + *start = self->start; + *stop = self->stop; + *step = self->step; +} + +#endif diff --git a/user/mpy/py/objstr.c b/user/mpy/py/objstr.c new file mode 100644 index 0000000..d4c038a --- /dev/null +++ b/user/mpy/py/objstr.c @@ -0,0 +1,2169 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/unicode.h" +#include "py/objstr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/stackctrl.h" + +STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict); + +STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); +STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in); + +/******************************************************************************/ +/* str */ + +void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes) { + // this escapes characters, but it will be very slow to print (calling print many times) + bool has_single_quote = false; + bool has_double_quote = false; + for (const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) { + if (*s == '\'') { + has_single_quote = true; + } else if (*s == '"') { + has_double_quote = true; + } + } + int quote_char = '\''; + if (has_single_quote && !has_double_quote) { + quote_char = '"'; + } + mp_printf(print, "%c", quote_char); + for (const byte *s = str_data, *top = str_data + str_len; s < top; s++) { + if (*s == quote_char) { + mp_printf(print, "\\%c", quote_char); + } else if (*s == '\\') { + mp_print_str(print, "\\\\"); + } else if (*s >= 0x20 && *s != 0x7f && (!is_bytes || *s < 0x80)) { + // In strings, anything which is not ascii control character + // is printed as is, this includes characters in range 0x80-0xff + // (which can be non-Latin letters, etc.) + mp_printf(print, "%c", *s); + } else if (*s == '\n') { + mp_print_str(print, "\\n"); + } else if (*s == '\r') { + mp_print_str(print, "\\r"); + } else if (*s == '\t') { + mp_print_str(print, "\\t"); + } else { + mp_printf(print, "\\x%02x", *s); + } + } + mp_printf(print, "%c", quote_char); +} + +#if MICROPY_PY_UJSON +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len) { + // for JSON spec, see http://www.ietf.org/rfc/rfc4627.txt + // if we are given a valid utf8-encoded string, we will print it in a JSON-conforming way + mp_print_str(print, "\""); + for (const byte *s = str_data, *top = str_data + str_len; s < top; s++) { + if (*s == '"' || *s == '\\') { + mp_printf(print, "\\%c", *s); + } else if (*s >= 32) { + // this will handle normal and utf-8 encoded chars + mp_printf(print, "%c", *s); + } else if (*s == '\n') { + mp_print_str(print, "\\n"); + } else if (*s == '\r') { + mp_print_str(print, "\\r"); + } else if (*s == '\t') { + mp_print_str(print, "\\t"); + } else { + // this will handle control chars + mp_printf(print, "\\u%04x", *s); + } + } + mp_print_str(print, "\""); +} +#endif + +STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + GET_STR_DATA_LEN(self_in, str_data, str_len); + #if MICROPY_PY_UJSON + if (kind == PRINT_JSON) { + mp_str_print_json(print, str_data, str_len); + return; + } + #endif + #if !MICROPY_PY_BUILTINS_STR_UNICODE + bool is_bytes = MP_OBJ_IS_TYPE(self_in, &mp_type_bytes); + #else + bool is_bytes = true; + #endif + if (kind == PRINT_RAW || (!MICROPY_PY_BUILTINS_STR_UNICODE && kind == PRINT_STR && !is_bytes)) { + mp_printf(print, "%.*s", str_len, str_data); + } else { + if (is_bytes) { + mp_print_str(print, "b"); + } + mp_str_print_quoted(print, str_data, str_len, is_bytes); + } +} + +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +#if MICROPY_CPYTHON_COMPAT + if (n_kw != 0) { + mp_arg_error_unimpl_kw(); + } +#endif + + mp_arg_check_num(n_args, n_kw, 0, 3, false); + + switch (n_args) { + case 0: + return MP_OBJ_NEW_QSTR(MP_QSTR_); + + case 1: { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + mp_obj_print_helper(&print, args[0], PRINT_STR); + return mp_obj_new_str_from_vstr(type, &vstr); + } + + default: // 2 or 3 args + // TODO: validate 2nd/3rd args + if (MP_OBJ_IS_TYPE(args[0], &mp_type_bytes)) { + GET_STR_DATA_LEN(args[0], str_data, str_len); + GET_STR_HASH(args[0], str_hash); + if (str_hash == 0) { + str_hash = qstr_compute_hash(str_data, str_len); + } + mp_obj_str_t *o = MP_OBJ_TO_PTR(mp_obj_new_str_of_type(type, NULL, str_len)); + o->data = str_data; + o->hash = str_hash; + return MP_OBJ_FROM_PTR(o); + } else { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); + return mp_obj_new_str(bufinfo.buf, bufinfo.len, false); + } + } +} + +STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + #if MICROPY_CPYTHON_COMPAT + if (n_kw != 0) { + mp_arg_error_unimpl_kw(); + } + #else + (void)n_kw; + #endif + + if (n_args == 0) { + return mp_const_empty_bytes; + } + + if (MP_OBJ_IS_STR(args[0])) { + if (n_args < 2 || n_args > 3) { + goto wrong_args; + } + GET_STR_DATA_LEN(args[0], str_data, str_len); + GET_STR_HASH(args[0], str_hash); + if (str_hash == 0) { + str_hash = qstr_compute_hash(str_data, str_len); + } + mp_obj_str_t *o = MP_OBJ_TO_PTR(mp_obj_new_str_of_type(&mp_type_bytes, NULL, str_len)); + o->data = str_data; + o->hash = str_hash; + return MP_OBJ_FROM_PTR(o); + } + + if (n_args > 1) { + goto wrong_args; + } + + if (MP_OBJ_IS_SMALL_INT(args[0])) { + uint len = MP_OBJ_SMALL_INT_VALUE(args[0]); + vstr_t vstr; + vstr_init_len(&vstr, len); + memset(vstr.buf, 0, len); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); + } + + // check if argument has the buffer protocol + mp_buffer_info_t bufinfo; + if (mp_get_buffer(args[0], &bufinfo, MP_BUFFER_READ)) { + return mp_obj_new_str_of_type(&mp_type_bytes, bufinfo.buf, bufinfo.len); + } + + vstr_t vstr; + // Try to create array of exact len if initializer len is known + mp_obj_t len_in = mp_obj_len_maybe(args[0]); + if (len_in == MP_OBJ_NULL) { + vstr_init(&vstr, 16); + } else { + mp_int_t len = MP_OBJ_SMALL_INT_VALUE(len_in); + vstr_init(&vstr, len); + } + + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(args[0], &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + mp_int_t val = mp_obj_get_int(item); + #if MICROPY_FULL_CHECKS + if (val < 0 || val > 255) { + mp_raise_ValueError("bytes value out of range"); + } + #endif + vstr_add_byte(&vstr, val); + } + + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); + +wrong_args: + mp_raise_TypeError("wrong number of arguments"); +} + +// like strstr but with specified length and allows \0 bytes +// TODO replace with something more efficient/standard +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction) { + if (hlen >= nlen) { + size_t str_index, str_index_end; + if (direction > 0) { + str_index = 0; + str_index_end = hlen - nlen; + } else { + str_index = hlen - nlen; + str_index_end = 0; + } + for (;;) { + if (memcmp(&haystack[str_index], needle, nlen) == 0) { + //found + return haystack + str_index; + } + if (str_index == str_index_end) { + //not found + break; + } + str_index += direction; + } + } + return NULL; +} + +// Note: this function is used to check if an object is a str or bytes, which +// works because both those types use it as their binary_op method. Revisit +// MP_OBJ_IS_STR_OR_BYTES if this fact changes. +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + // check for modulo + if (op == MP_BINARY_OP_MODULO) { + mp_obj_t *args = &rhs_in; + size_t n_args = 1; + mp_obj_t dict = MP_OBJ_NULL; + if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_tuple)) { + // TODO: Support tuple subclasses? + mp_obj_tuple_get(rhs_in, &n_args, &args); + } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_dict)) { + dict = rhs_in; + } + return str_modulo_format(lhs_in, n_args, args, dict); + } + + // from now on we need lhs type and data, so extract them + mp_obj_type_t *lhs_type = mp_obj_get_type(lhs_in); + GET_STR_DATA_LEN(lhs_in, lhs_data, lhs_len); + + // check for multiply + if (op == MP_BINARY_OP_MULTIPLY) { + mp_int_t n; + if (!mp_obj_get_int_maybe(rhs_in, &n)) { + return MP_OBJ_NULL; // op not supported + } + if (n <= 0) { + if (lhs_type == &mp_type_str) { + return MP_OBJ_NEW_QSTR(MP_QSTR_); // empty str + } else { + return mp_const_empty_bytes; + } + } + vstr_t vstr; + vstr_init_len(&vstr, lhs_len * n); + mp_seq_multiply(lhs_data, sizeof(*lhs_data), lhs_len, n, vstr.buf); + return mp_obj_new_str_from_vstr(lhs_type, &vstr); + } + + // From now on all operations allow: + // - str with str + // - bytes with bytes + // - bytes with bytearray + // - bytes with array.array + // To do this efficiently we use the buffer protocol to extract the raw + // data for the rhs, but only if the lhs is a bytes object. + // + // NOTE: CPython does not allow comparison between bytes ard array.array + // (even if the array is of type 'b'), even though it allows addition of + // such types. We are not compatible with this (we do allow comparison + // of bytes with anything that has the buffer protocol). It would be + // easy to "fix" this with a bit of extra logic below, but it costs code + // size and execution time so we don't. + + const byte *rhs_data; + size_t rhs_len; + if (lhs_type == mp_obj_get_type(rhs_in)) { + GET_STR_DATA_LEN(rhs_in, rhs_data_, rhs_len_); + rhs_data = rhs_data_; + rhs_len = rhs_len_; + } else if (lhs_type == &mp_type_bytes) { + mp_buffer_info_t bufinfo; + if (!mp_get_buffer(rhs_in, &bufinfo, MP_BUFFER_READ)) { + return MP_OBJ_NULL; // op not supported + } + rhs_data = bufinfo.buf; + rhs_len = bufinfo.len; + } else { + // LHS is str and RHS has an incompatible type + // (except if operation is EQUAL, but that's handled by mp_obj_equal) + bad_implicit_conversion(rhs_in); + } + + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: { + if (lhs_len == 0 && mp_obj_get_type(rhs_in) == lhs_type) { + return rhs_in; + } + if (rhs_len == 0) { + return lhs_in; + } + + vstr_t vstr; + vstr_init_len(&vstr, lhs_len + rhs_len); + memcpy(vstr.buf, lhs_data, lhs_len); + memcpy(vstr.buf + lhs_len, rhs_data, rhs_len); + return mp_obj_new_str_from_vstr(lhs_type, &vstr); + } + + case MP_BINARY_OP_IN: + /* NOTE `a in b` is `b.__contains__(a)` */ + return mp_obj_new_bool(find_subbytes(lhs_data, lhs_len, rhs_data, rhs_len, 1) != NULL); + + //case MP_BINARY_OP_NOT_EQUAL: // This is never passed here + case MP_BINARY_OP_EQUAL: // This will be passed only for bytes, str is dealt with in mp_obj_equal() + case MP_BINARY_OP_LESS: + case MP_BINARY_OP_LESS_EQUAL: + case MP_BINARY_OP_MORE: + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_data, lhs_len, rhs_data, rhs_len)); + } + + return MP_OBJ_NULL; // op not supported +} + +#if !MICROPY_PY_BUILTINS_STR_UNICODE +// objstrunicode defines own version +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, bool is_slice) { + size_t index_val = mp_get_index(type, self_len, index, is_slice); + return self_data + index_val; +} +#endif + +// This is used for both bytes and 8-bit strings. This is not used for unicode strings. +STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + GET_STR_DATA_LEN(self_in, self_data, self_len); + if (value == MP_OBJ_SENTINEL) { + // load +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_bound_slice_t slice; + if (!mp_seq_get_fast_slice_indexes(self_len, index, &slice)) { + mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); + } + return mp_obj_new_str_of_type(type, self_data + slice.start, slice.stop - slice.start); + } +#endif + size_t index_val = mp_get_index(type, self_len, index, false); + // If we have unicode enabled the type will always be bytes, so take the short cut. + if (MICROPY_PY_BUILTINS_STR_UNICODE || type == &mp_type_bytes) { + return MP_OBJ_NEW_SMALL_INT(self_data[index_val]); + } else { + return mp_obj_new_str((char*)&self_data[index_val], 1, true); + } + } else { + return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(self_in)); + const mp_obj_type_t *self_type = mp_obj_get_type(self_in); + + // get separation string + GET_STR_DATA_LEN(self_in, sep_str, sep_len); + + // process args + size_t seq_len; + mp_obj_t *seq_items; + + if (!MP_OBJ_IS_TYPE(arg, &mp_type_list) && !MP_OBJ_IS_TYPE(arg, &mp_type_tuple)) { + // arg is not a list nor a tuple, try to convert it to a list + // TODO: Try to optimize? + arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); + } + mp_obj_get_array(arg, &seq_len, &seq_items); + + // count required length + size_t required_len = 0; + for (size_t i = 0; i < seq_len; i++) { + if (mp_obj_get_type(seq_items[i]) != self_type) { + mp_raise_TypeError( + "join expects a list of str/bytes objects consistent with self object"); + } + if (i > 0) { + required_len += sep_len; + } + GET_STR_LEN(seq_items[i], l); + required_len += l; + } + + // make joined string + vstr_t vstr; + vstr_init_len(&vstr, required_len); + byte *data = (byte*)vstr.buf; + for (size_t i = 0; i < seq_len; i++) { + if (i > 0) { + memcpy(data, sep_str, sep_len); + data += sep_len; + } + GET_STR_DATA_LEN(seq_items[i], s, l); + memcpy(data, s, l); + data += l; + } + + // return joined string + return mp_obj_new_str_from_vstr(self_type, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join); + +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + mp_int_t splits = -1; + mp_obj_t sep = mp_const_none; + if (n_args > 1) { + sep = args[1]; + if (n_args > 2) { + splits = mp_obj_get_int(args[2]); + } + } + + mp_obj_t res = mp_obj_new_list(0, NULL); + GET_STR_DATA_LEN(args[0], s, len); + const byte *top = s + len; + + if (sep == mp_const_none) { + // sep not given, so separate on whitespace + + // Initial whitespace is not counted as split, so we pre-do it + while (s < top && unichar_isspace(*s)) s++; + while (s < top && splits != 0) { + const byte *start = s; + while (s < top && !unichar_isspace(*s)) s++; + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); + if (s >= top) { + break; + } + while (s < top && unichar_isspace(*s)) s++; + if (splits > 0) { + splits--; + } + } + + if (s < top) { + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, s, top - s)); + } + + } else { + // sep given + if (mp_obj_get_type(sep) != self_type) { + bad_implicit_conversion(sep); + } + + size_t sep_len; + const char *sep_str = mp_obj_str_get_data(sep, &sep_len); + + if (sep_len == 0) { + mp_raise_ValueError("empty separator"); + } + + for (;;) { + const byte *start = s; + for (;;) { + if (splits == 0 || s + sep_len > top) { + s = top; + break; + } else if (memcmp(s, sep_str, sep_len) == 0) { + break; + } + s++; + } + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); + if (s >= top) { + break; + } + s += sep_len; + if (splits > 0) { + splits--; + } + } + } + + return res; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, mp_obj_str_split); + +#if MICROPY_PY_BUILTINS_STR_SPLITLINES +STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_keepends }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_keepends, MP_ARG_BOOL, {.u_bool = false} }, + }; + + // parse args + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const mp_obj_type_t *self_type = mp_obj_get_type(pos_args[0]); + mp_obj_t res = mp_obj_new_list(0, NULL); + + GET_STR_DATA_LEN(pos_args[0], s, len); + const byte *top = s + len; + + while (s < top) { + const byte *start = s; + size_t match = 0; + while (s < top) { + if (*s == '\n') { + match = 1; + break; + } else if (*s == '\r') { + if (s[1] == '\n') { + match = 2; + } else { + match = 1; + } + break; + } + s++; + } + size_t sub_len = s - start; + if (args[ARG_keepends].u_bool) { + sub_len += match; + } + mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, sub_len)); + s += match; + } + + return res; +} +MP_DEFINE_CONST_FUN_OBJ_KW(str_splitlines_obj, 1, str_splitlines); +#endif + +STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) { + if (n_args < 3) { + // If we don't have split limit, it doesn't matter from which side + // we split. + return mp_obj_str_split(n_args, args); + } + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + mp_obj_t sep = args[1]; + GET_STR_DATA_LEN(args[0], s, len); + + mp_int_t splits = mp_obj_get_int(args[2]); + if (splits < 0) { + // Negative limit means no limit, so delegate to split(). + return mp_obj_str_split(n_args, args); + } + + mp_int_t org_splits = splits; + // Preallocate list to the max expected # of elements, as we + // will fill it from the end. + mp_obj_list_t *res = MP_OBJ_TO_PTR(mp_obj_new_list(splits + 1, NULL)); + mp_int_t idx = splits; + + if (sep == mp_const_none) { + mp_raise_NotImplementedError("rsplit(None,n)"); + } else { + size_t sep_len; + const char *sep_str = mp_obj_str_get_data(sep, &sep_len); + + if (sep_len == 0) { + mp_raise_ValueError("empty separator"); + } + + const byte *beg = s; + const byte *last = s + len; + for (;;) { + s = last - sep_len; + for (;;) { + if (splits == 0 || s < beg) { + break; + } else if (memcmp(s, sep_str, sep_len) == 0) { + break; + } + s--; + } + if (s < beg || splits == 0) { + res->items[idx] = mp_obj_new_str_of_type(self_type, beg, last - beg); + break; + } + res->items[idx--] = mp_obj_new_str_of_type(self_type, s + sep_len, last - s - sep_len); + last = s; + if (splits > 0) { + splits--; + } + } + if (idx != 0) { + // We split less parts than split limit, now go cleanup surplus + size_t used = org_splits + 1 - idx; + memmove(res->items, &res->items[idx], used * sizeof(mp_obj_t)); + mp_seq_clear(res->items, used, res->alloc, sizeof(*res->items)); + res->len = used; + } + } + + return MP_OBJ_FROM_PTR(res); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit); + +STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); + + // check argument type + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + + GET_STR_DATA_LEN(args[0], haystack, haystack_len); + GET_STR_DATA_LEN(args[1], needle, needle_len); + + const byte *start = haystack; + const byte *end = haystack + haystack_len; + if (n_args >= 3 && args[2] != mp_const_none) { + start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], true); + } + if (n_args >= 4 && args[3] != mp_const_none) { + end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], true); + } + + const byte *p = find_subbytes(start, end - start, needle, needle_len, direction); + if (p == NULL) { + // not found + if (is_index) { + mp_raise_ValueError("substring not found"); + } else { + return MP_OBJ_NEW_SMALL_INT(-1); + } + } else { + // found + #if MICROPY_PY_BUILTINS_STR_UNICODE + if (self_type == &mp_type_str) { + return MP_OBJ_NEW_SMALL_INT(utf8_ptr_to_index(haystack, p)); + } + #endif + return MP_OBJ_NEW_SMALL_INT(p - haystack); + } +} + +STATIC mp_obj_t str_find(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, 1, false); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find); + +STATIC mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, -1, false); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj, 2, 4, str_rfind); + +STATIC mp_obj_t str_index(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, 1, true); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj, 2, 4, str_index); + +STATIC mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) { + return str_finder(n_args, args, -1, true); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj, 2, 4, str_rindex); + +// TODO: (Much) more variety in args +STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + GET_STR_DATA_LEN(args[0], str, str_len); + GET_STR_DATA_LEN(args[1], prefix, prefix_len); + const byte *start = str; + if (n_args > 2) { + start = str_index_to_ptr(self_type, str, str_len, args[2], true); + } + if (prefix_len + (start - str) > str_len) { + return mp_const_false; + } + return mp_obj_new_bool(memcmp(start, prefix, prefix_len) == 0); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj, 2, 3, str_startswith); + +STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) { + GET_STR_DATA_LEN(args[0], str, str_len); + GET_STR_DATA_LEN(args[1], suffix, suffix_len); + if (n_args > 2) { + mp_raise_NotImplementedError("start/end indices"); + } + + if (suffix_len > str_len) { + return mp_const_false; + } + return mp_obj_new_bool(memcmp(str + (str_len - suffix_len), suffix, suffix_len) == 0); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith); + +enum { LSTRIP, RSTRIP, STRIP }; + +STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) { + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + + const byte *chars_to_del; + uint chars_to_del_len; + static const byte whitespace[] = " \t\n\r\v\f"; + + if (n_args == 1) { + chars_to_del = whitespace; + chars_to_del_len = sizeof(whitespace); + } else { + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + GET_STR_DATA_LEN(args[1], s, l); + chars_to_del = s; + chars_to_del_len = l; + } + + GET_STR_DATA_LEN(args[0], orig_str, orig_str_len); + + size_t first_good_char_pos = 0; + bool first_good_char_pos_set = false; + size_t last_good_char_pos = 0; + size_t i = 0; + int delta = 1; + if (type == RSTRIP) { + i = orig_str_len - 1; + delta = -1; + } + for (size_t len = orig_str_len; len > 0; len--) { + if (find_subbytes(chars_to_del, chars_to_del_len, &orig_str[i], 1, 1) == NULL) { + if (!first_good_char_pos_set) { + first_good_char_pos_set = true; + first_good_char_pos = i; + if (type == LSTRIP) { + last_good_char_pos = orig_str_len - 1; + break; + } else if (type == RSTRIP) { + first_good_char_pos = 0; + last_good_char_pos = i; + break; + } + } + last_good_char_pos = i; + } + i += delta; + } + + if (!first_good_char_pos_set) { + // string is all whitespace, return '' + if (self_type == &mp_type_str) { + return MP_OBJ_NEW_QSTR(MP_QSTR_); + } else { + return mp_const_empty_bytes; + } + } + + assert(last_good_char_pos >= first_good_char_pos); + //+1 to accommodate the last character + size_t stripped_len = last_good_char_pos - first_good_char_pos + 1; + if (stripped_len == orig_str_len) { + // If nothing was stripped, don't bother to dup original string + // TODO: watch out for this case when we'll get to bytearray.strip() + assert(first_good_char_pos == 0); + return args[0]; + } + return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len); +} + +STATIC mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) { + return str_uni_strip(STRIP, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip); + +STATIC mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) { + return str_uni_strip(LSTRIP, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj, 1, 2, str_lstrip); + +STATIC mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) { + return str_uni_strip(RSTRIP, n_args, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj, 1, 2, str_rstrip); + +#if MICROPY_PY_BUILTINS_STR_CENTER +STATIC mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) { + GET_STR_DATA_LEN(str_in, str, str_len); + mp_uint_t width = mp_obj_get_int(width_in); + if (str_len >= width) { + return str_in; + } + + vstr_t vstr; + vstr_init_len(&vstr, width); + memset(vstr.buf, ' ', width); + int left = (width - str_len) / 2; + memcpy(vstr.buf + left, str, str_len); + return mp_obj_new_str_from_vstr(mp_obj_get_type(str_in), &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_2(str_center_obj, str_center); +#endif + +// Takes an int arg, but only parses unsigned numbers, and only changes +// *num if at least one digit was parsed. +STATIC const char *str_to_int(const char *str, const char *top, int *num) { + if (str < top && '0' <= *str && *str <= '9') { + *num = 0; + do { + *num = *num * 10 + (*str - '0'); + str++; + } + while (str < top && '0' <= *str && *str <= '9'); + } + return str; +} + +STATIC bool isalignment(char ch) { + return ch && strchr("<>=^", ch) != NULL; +} + +STATIC bool istype(char ch) { + return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL; +} + +STATIC bool arg_looks_integer(mp_obj_t arg) { + return MP_OBJ_IS_TYPE(arg, &mp_type_bool) || MP_OBJ_IS_INT(arg); +} + +STATIC bool arg_looks_numeric(mp_obj_t arg) { + return arg_looks_integer(arg) +#if MICROPY_PY_BUILTINS_FLOAT + || mp_obj_is_float(arg) +#endif + ; +} + +STATIC mp_obj_t arg_as_int(mp_obj_t arg) { +#if MICROPY_PY_BUILTINS_FLOAT + if (mp_obj_is_float(arg)) { + return mp_obj_new_int_from_float(mp_obj_float_get(arg)); + } +#endif + return arg; +} + +#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE +STATIC NORETURN void terse_str_format_value_error(void) { + mp_raise_ValueError("bad format string"); +} +#else +// define to nothing to improve coverage +#define terse_str_format_value_error() +#endif + +STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + + for (; str < top; str++) { + if (*str == '}') { + str++; + if (str < top && *str == '}') { + vstr_add_byte(&vstr, '}'); + continue; + } + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("single '}' encountered in format string"); + } + } + if (*str != '{') { + vstr_add_byte(&vstr, *str); + continue; + } + + str++; + if (str < top && *str == '{') { + vstr_add_byte(&vstr, '{'); + continue; + } + + // replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}" + + const char *field_name = NULL; + const char *field_name_top = NULL; + char conversion = '\0'; + const char *format_spec = NULL; + + if (str < top && *str != '}' && *str != '!' && *str != ':') { + field_name = (const char *)str; + while (str < top && *str != '}' && *str != '!' && *str != ':') { + ++str; + } + field_name_top = (const char *)str; + } + + // conversion ::= "r" | "s" + + if (str < top && *str == '!') { + str++; + if (str < top && (*str == 'r' || *str == 's')) { + conversion = *str++; + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { + mp_raise_ValueError("bad conversion specifier"); + } else { + if (str >= top) { + mp_raise_ValueError( + "end of format while looking for conversion specifier"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "unknown conversion specifier %c", *str)); + } + } + } + } + + if (str < top && *str == ':') { + str++; + // {:} is the same as {}, which is the same as {!s} + // This makes a difference when passing in a True or False + // '{}'.format(True) returns 'True' + // '{:d}'.format(True) returns '1' + // So we treat {:} as {} and this later gets treated to be {!s} + if (*str != '}') { + format_spec = str; + for (int nest = 1; str < top;) { + if (*str == '{') { + ++nest; + } else if (*str == '}') { + if (--nest == 0) { + break; + } + } + ++str; + } + } + } + if (str >= top) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("unmatched '{' in format"); + } + } + if (*str != '}') { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("expected ':' after format specifier"); + } + } + + mp_obj_t arg = mp_const_none; + + if (field_name) { + int index = 0; + if (MP_LIKELY(unichar_isdigit(*field_name))) { + if (*arg_i > 0) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "can't switch from automatic field numbering to manual field specification"); + } + } + field_name = str_to_int(field_name, field_name_top, &index); + if ((uint)index >= n_args - 1) { + mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); + } + arg = args[index + 1]; + *arg_i = -1; + } else { + const char *lookup; + for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++); + mp_obj_t field_q = mp_obj_new_str(field_name, lookup - field_name, true/*?*/); + field_name = lookup; + mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP); + if (key_elem == NULL) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, field_q)); + } + arg = key_elem->value; + } + if (field_name < field_name_top) { + mp_raise_NotImplementedError("attributes not supported yet"); + } + } else { + if (*arg_i < 0) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "can't switch from manual field specification to automatic field numbering"); + } + } + if ((uint)*arg_i >= n_args - 1) { + mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); + } + arg = args[(*arg_i) + 1]; + (*arg_i)++; + } + if (!format_spec && !conversion) { + conversion = 's'; + } + if (conversion) { + mp_print_kind_t print_kind; + if (conversion == 's') { + print_kind = PRINT_STR; + } else { + assert(conversion == 'r'); + print_kind = PRINT_REPR; + } + vstr_t arg_vstr; + mp_print_t arg_print; + vstr_init_print(&arg_vstr, 16, &arg_print); + mp_obj_print_helper(&arg_print, arg, print_kind); + arg = mp_obj_new_str_from_vstr(&mp_type_str, &arg_vstr); + } + + char fill = '\0'; + char align = '\0'; + int width = -1; + int precision = -1; + char type = '\0'; + int flags = 0; + + if (format_spec) { + // The format specifier (from http://docs.python.org/2/library/string.html#formatspec) + // + // [[fill]align][sign][#][0][width][,][.precision][type] + // fill ::= + // align ::= "<" | ">" | "=" | "^" + // sign ::= "+" | "-" | " " + // width ::= integer + // precision ::= integer + // type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" + + // recursively call the formatter to format any nested specifiers + MP_STACK_CHECK(); + vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs); + const char *s = vstr_null_terminated_str(&format_spec_vstr); + const char *stop = s + format_spec_vstr.len; + if (isalignment(*s)) { + align = *s++; + } else if (*s && isalignment(s[1])) { + fill = *s++; + align = *s++; + } + if (*s == '+' || *s == '-' || *s == ' ') { + if (*s == '+') { + flags |= PF_FLAG_SHOW_SIGN; + } else if (*s == ' ') { + flags |= PF_FLAG_SPACE_SIGN; + } + s++; + } + if (*s == '#') { + flags |= PF_FLAG_SHOW_PREFIX; + s++; + } + if (*s == '0') { + if (!align) { + align = '='; + } + if (!fill) { + fill = '0'; + } + } + s = str_to_int(s, stop, &width); + if (*s == ',') { + flags |= PF_FLAG_SHOW_COMMA; + s++; + } + if (*s == '.') { + s++; + s = str_to_int(s, stop, &precision); + } + if (istype(*s)) { + type = *s++; + } + if (*s) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("invalid format specifier"); + } + } + vstr_clear(&format_spec_vstr); + } + if (!align) { + if (arg_looks_numeric(arg)) { + align = '>'; + } else { + align = '<'; + } + } + if (!fill) { + fill = ' '; + } + + if (flags & (PF_FLAG_SHOW_SIGN | PF_FLAG_SPACE_SIGN)) { + if (type == 's') { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("sign not allowed in string format specifier"); + } + } + if (type == 'c') { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "sign not allowed with integer format specifier 'c'"); + } + } + } + + switch (align) { + case '<': flags |= PF_FLAG_LEFT_ADJUST; break; + case '=': flags |= PF_FLAG_PAD_AFTER_SIGN; break; + case '^': flags |= PF_FLAG_CENTER_ADJUST; break; + } + + if (arg_looks_integer(arg)) { + switch (type) { + case 'b': + mp_print_mp_int(&print, arg, 2, 'a', flags, fill, width, 0); + continue; + + case 'c': + { + char ch = mp_obj_get_int(arg); + mp_print_strn(&print, &ch, 1, flags, fill, width); + continue; + } + + case '\0': // No explicit format type implies 'd' + case 'n': // I don't think we support locales in uPy so use 'd' + case 'd': + mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0); + continue; + + case 'o': + if (flags & PF_FLAG_SHOW_PREFIX) { + flags |= PF_FLAG_SHOW_OCTAL_LETTER; + } + + mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, 0); + continue; + + case 'X': + case 'x': + mp_print_mp_int(&print, arg, 16, type - ('X' - 'A'), flags, fill, width, 0); + continue; + + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + case '%': + // The floating point formatters all work with anything that + // looks like an integer + break; + + default: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "unknown format code '%c' for object of type '%s'", + type, mp_obj_get_type_str(arg))); + } + } + } + + // NOTE: no else here. We need the e, f, g etc formats for integer + // arguments (from above if) to take this if. + if (arg_looks_numeric(arg)) { + if (!type) { + + // Even though the docs say that an unspecified type is the same + // as 'g', there is one subtle difference, when the exponent + // is one less than the precision. + // + // '{:10.1}'.format(0.0) ==> '0e+00' + // '{:10.1g}'.format(0.0) ==> '0' + // + // TODO: Figure out how to deal with this. + // + // A proper solution would involve adding a special flag + // or something to format_float, and create a format_double + // to deal with doubles. In order to fix this when using + // sprintf, we'd need to use the e format and tweak the + // returned result to strip trailing zeros like the g format + // does. + // + // {:10.3} and {:10.2e} with 1.23e2 both produce 1.23e+02 + // but with 1.e2 you get 1e+02 and 1.00e+02 + // + // Stripping the trailing 0's (like g) does would make the + // e format give us the right format. + // + // CPython sources say: + // Omitted type specifier. Behaves in the same way as repr(x) + // and str(x) if no precision is given, else like 'g', but with + // at least one digit after the decimal point. */ + + type = 'g'; + } + if (type == 'n') { + type = 'g'; + } + + switch (type) { +#if MICROPY_PY_BUILTINS_FLOAT + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + mp_print_float(&print, mp_obj_get_float(arg), type, flags, fill, width, precision); + break; + + case '%': + flags |= PF_FLAG_ADD_PERCENT; + #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT + #define F100 100.0F + #else + #define F100 100.0 + #endif + mp_print_float(&print, mp_obj_get_float(arg) * F100, 'f', flags, fill, width, precision); + #undef F100 + break; +#endif + + default: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "unknown format code '%c' for object of type 'float'", + type, mp_obj_get_type_str(arg))); + } + } + } else { + // arg doesn't look like a number + + if (align == '=') { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError( + "'=' alignment not allowed in string format specifier"); + } + } + + switch (type) { + case '\0': // no explicit format type implies 's' + case 's': { + size_t slen; + const char *s = mp_obj_str_get_data(arg, &slen); + if (precision < 0) { + precision = slen; + } + if (slen > (size_t)precision) { + slen = precision; + } + mp_print_strn(&print, s, slen, flags, fill, width); + break; + } + + default: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "unknown format code '%c' for object of type 'str'", + type, mp_obj_get_type_str(arg))); + } + } + } + } + + return vstr; +} + +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); + + GET_STR_DATA_LEN(args[0], str, len); + int arg_i = 0; + vstr_t vstr = mp_obj_str_format_helper((const char*)str, (const char*)str + len, &arg_i, n_args, args, kwargs); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format); + +STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) { + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(pattern)); + + GET_STR_DATA_LEN(pattern, str, len); + const byte *start_str = str; + bool is_bytes = MP_OBJ_IS_TYPE(pattern, &mp_type_bytes); + size_t arg_i = 0; + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 16, &print); + + for (const byte *top = str + len; str < top; str++) { + mp_obj_t arg = MP_OBJ_NULL; + if (*str != '%') { + vstr_add_byte(&vstr, *str); + continue; + } + if (++str >= top) { + goto incomplete_format; + } + if (*str == '%') { + vstr_add_byte(&vstr, '%'); + continue; + } + + // Dictionary value lookup + if (*str == '(') { + if (dict == MP_OBJ_NULL) { + mp_raise_TypeError("format requires a dict"); + } + arg_i = 1; // we used up the single dict argument + const byte *key = ++str; + while (*str != ')') { + if (str >= top) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("incomplete format key"); + } + } + ++str; + } + mp_obj_t k_obj = mp_obj_new_str((const char*)key, str - key, true); + arg = mp_obj_dict_get(dict, k_obj); + str++; + } + + int flags = 0; + char fill = ' '; + int alt = 0; + while (str < top) { + if (*str == '-') flags |= PF_FLAG_LEFT_ADJUST; + else if (*str == '+') flags |= PF_FLAG_SHOW_SIGN; + else if (*str == ' ') flags |= PF_FLAG_SPACE_SIGN; + else if (*str == '#') alt = PF_FLAG_SHOW_PREFIX; + else if (*str == '0') { + flags |= PF_FLAG_PAD_AFTER_SIGN; + fill = '0'; + } else break; + str++; + } + // parse width, if it exists + int width = 0; + if (str < top) { + if (*str == '*') { + if (arg_i >= n_args) { + goto not_enough_args; + } + width = mp_obj_get_int(args[arg_i++]); + str++; + } else { + str = (const byte*)str_to_int((const char*)str, (const char*)top, &width); + } + } + int prec = -1; + if (str < top && *str == '.') { + if (++str < top) { + if (*str == '*') { + if (arg_i >= n_args) { + goto not_enough_args; + } + prec = mp_obj_get_int(args[arg_i++]); + str++; + } else { + prec = 0; + str = (const byte*)str_to_int((const char*)str, (const char*)top, &prec); + } + } + } + + if (str >= top) { +incomplete_format: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + mp_raise_ValueError("incomplete format"); + } + } + + // Tuple value lookup + if (arg == MP_OBJ_NULL) { + if (arg_i >= n_args) { +not_enough_args: + mp_raise_TypeError("not enough arguments for format string"); + } + arg = args[arg_i++]; + } + switch (*str) { + case 'c': + if (MP_OBJ_IS_STR(arg)) { + size_t slen; + const char *s = mp_obj_str_get_data(arg, &slen); + if (slen != 1) { + mp_raise_TypeError("%%c requires int or char"); + } + mp_print_strn(&print, s, 1, flags, ' ', width); + } else if (arg_looks_integer(arg)) { + char ch = mp_obj_get_int(arg); + mp_print_strn(&print, &ch, 1, flags, ' ', width); + } else { + mp_raise_TypeError("integer required"); + } + break; + + case 'd': + case 'i': + case 'u': + mp_print_mp_int(&print, arg_as_int(arg), 10, 'a', flags, fill, width, prec); + break; + +#if MICROPY_PY_BUILTINS_FLOAT + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + mp_print_float(&print, mp_obj_get_float(arg), *str, flags, fill, width, prec); + break; +#endif + + case 'o': + if (alt) { + flags |= (PF_FLAG_SHOW_PREFIX | PF_FLAG_SHOW_OCTAL_LETTER); + } + mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, prec); + break; + + case 'r': + case 's': + { + vstr_t arg_vstr; + mp_print_t arg_print; + vstr_init_print(&arg_vstr, 16, &arg_print); + mp_print_kind_t print_kind = (*str == 'r' ? PRINT_REPR : PRINT_STR); + if (print_kind == PRINT_STR && is_bytes && MP_OBJ_IS_TYPE(arg, &mp_type_bytes)) { + // If we have something like b"%s" % b"1", bytes arg should be + // printed undecorated. + print_kind = PRINT_RAW; + } + mp_obj_print_helper(&arg_print, arg, print_kind); + uint vlen = arg_vstr.len; + if (prec < 0) { + prec = vlen; + } + if (vlen > (uint)prec) { + vlen = prec; + } + mp_print_strn(&print, arg_vstr.buf, vlen, flags, ' ', width); + vstr_clear(&arg_vstr); + break; + } + + case 'X': + case 'x': + mp_print_mp_int(&print, arg, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec); + break; + + default: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + terse_str_format_value_error(); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "unsupported format character '%c' (0x%x) at index %d", + *str, *str, str - start_str)); + } + } + } + + if (arg_i != n_args) { + mp_raise_TypeError("not all arguments converted during string formatting"); + } + + return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr); +} + +// The implementation is optimized, returning the original string if there's +// nothing to replace. +STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) { + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); + + mp_int_t max_rep = -1; + if (n_args == 4) { + max_rep = mp_obj_get_int(args[3]); + if (max_rep == 0) { + return args[0]; + } else if (max_rep < 0) { + max_rep = -1; + } + } + + // if max_rep is still -1 by this point we will need to do all possible replacements + + // check argument types + + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + + if (mp_obj_get_type(args[2]) != self_type) { + bad_implicit_conversion(args[2]); + } + + // extract string data + + GET_STR_DATA_LEN(args[0], str, str_len); + GET_STR_DATA_LEN(args[1], old, old_len); + GET_STR_DATA_LEN(args[2], new, new_len); + + // old won't exist in str if it's longer, so nothing to replace + if (old_len > str_len) { + return args[0]; + } + + // data for the replaced string + byte *data = NULL; + vstr_t vstr; + + // do 2 passes over the string: + // first pass computes the required length of the replaced string + // second pass does the replacements + for (;;) { + size_t replaced_str_index = 0; + size_t num_replacements_done = 0; + const byte *old_occurrence; + const byte *offset_ptr = str; + size_t str_len_remain = str_len; + if (old_len == 0) { + // if old_str is empty, copy new_str to start of replaced string + // copy the replacement string + if (data != NULL) { + memcpy(data, new, new_len); + } + replaced_str_index += new_len; + num_replacements_done++; + } + while (num_replacements_done != (size_t)max_rep && str_len_remain > 0 && (old_occurrence = find_subbytes(offset_ptr, str_len_remain, old, old_len, 1)) != NULL) { + if (old_len == 0) { + old_occurrence += 1; + } + // copy from just after end of last occurrence of to-be-replaced string to right before start of next occurrence + if (data != NULL) { + memcpy(data + replaced_str_index, offset_ptr, old_occurrence - offset_ptr); + } + replaced_str_index += old_occurrence - offset_ptr; + // copy the replacement string + if (data != NULL) { + memcpy(data + replaced_str_index, new, new_len); + } + replaced_str_index += new_len; + offset_ptr = old_occurrence + old_len; + str_len_remain = str + str_len - offset_ptr; + num_replacements_done++; + } + + // copy from just after end of last occurrence of to-be-replaced string to end of old string + if (data != NULL) { + memcpy(data + replaced_str_index, offset_ptr, str_len_remain); + } + replaced_str_index += str_len_remain; + + if (data == NULL) { + // first pass + if (num_replacements_done == 0) { + // no substr found, return original string + return args[0]; + } else { + // substr found, allocate new string + vstr_init_len(&vstr, replaced_str_index); + data = (byte*)vstr.buf; + assert(data != NULL); + } + } else { + // second pass, we are done + break; + } + } + + return mp_obj_new_str_from_vstr(self_type, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace); + +STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); + + // check argument type + if (mp_obj_get_type(args[1]) != self_type) { + bad_implicit_conversion(args[1]); + } + + GET_STR_DATA_LEN(args[0], haystack, haystack_len); + GET_STR_DATA_LEN(args[1], needle, needle_len); + + const byte *start = haystack; + const byte *end = haystack + haystack_len; + if (n_args >= 3 && args[2] != mp_const_none) { + start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], true); + } + if (n_args >= 4 && args[3] != mp_const_none) { + end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], true); + } + + // if needle_len is zero then we count each gap between characters as an occurrence + if (needle_len == 0) { + return MP_OBJ_NEW_SMALL_INT(unichar_charlen((const char*)start, end - start) + 1); + } + + // count the occurrences + mp_int_t num_occurrences = 0; + for (const byte *haystack_ptr = start; haystack_ptr + needle_len <= end;) { + if (memcmp(haystack_ptr, needle, needle_len) == 0) { + num_occurrences++; + haystack_ptr += needle_len; + } else { + haystack_ptr = utf8_next_char(haystack_ptr); + } + } + + return MP_OBJ_NEW_SMALL_INT(num_occurrences); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count); + +#if MICROPY_PY_BUILTINS_STR_PARTITION +STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) { + mp_check_self(MP_OBJ_IS_STR_OR_BYTES(self_in)); + mp_obj_type_t *self_type = mp_obj_get_type(self_in); + if (self_type != mp_obj_get_type(arg)) { + bad_implicit_conversion(arg); + } + + GET_STR_DATA_LEN(self_in, str, str_len); + GET_STR_DATA_LEN(arg, sep, sep_len); + + if (sep_len == 0) { + mp_raise_ValueError("empty separator"); + } + + mp_obj_t result[3]; + if (self_type == &mp_type_str) { + result[0] = MP_OBJ_NEW_QSTR(MP_QSTR_); + result[1] = MP_OBJ_NEW_QSTR(MP_QSTR_); + result[2] = MP_OBJ_NEW_QSTR(MP_QSTR_); + } else { + result[0] = mp_const_empty_bytes; + result[1] = mp_const_empty_bytes; + result[2] = mp_const_empty_bytes; + } + + if (direction > 0) { + result[0] = self_in; + } else { + result[2] = self_in; + } + + const byte *position_ptr = find_subbytes(str, str_len, sep, sep_len, direction); + if (position_ptr != NULL) { + size_t position = position_ptr - str; + result[0] = mp_obj_new_str_of_type(self_type, str, position); + result[1] = arg; + result[2] = mp_obj_new_str_of_type(self_type, str + position + sep_len, str_len - position - sep_len); + } + + return mp_obj_new_tuple(3, result); +} + +STATIC mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) { + return str_partitioner(self_in, arg, 1); +} +MP_DEFINE_CONST_FUN_OBJ_2(str_partition_obj, str_partition); + +STATIC mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) { + return str_partitioner(self_in, arg, -1); +} +MP_DEFINE_CONST_FUN_OBJ_2(str_rpartition_obj, str_rpartition); +#endif + +// Supposedly not too critical operations, so optimize for code size +STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) { + GET_STR_DATA_LEN(self_in, self_data, self_len); + vstr_t vstr; + vstr_init_len(&vstr, self_len); + byte *data = (byte*)vstr.buf; + for (size_t i = 0; i < self_len; i++) { + *data++ = op(*self_data++); + } + return mp_obj_new_str_from_vstr(mp_obj_get_type(self_in), &vstr); +} + +STATIC mp_obj_t str_lower(mp_obj_t self_in) { + return str_caseconv(unichar_tolower, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_lower_obj, str_lower); + +STATIC mp_obj_t str_upper(mp_obj_t self_in) { + return str_caseconv(unichar_toupper, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_upper_obj, str_upper); + +STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) { + GET_STR_DATA_LEN(self_in, self_data, self_len); + + if (self_len == 0) { + return mp_const_false; // default to False for empty str + } + + if (f != unichar_isupper && f != unichar_islower) { + for (size_t i = 0; i < self_len; i++) { + if (!f(*self_data++)) { + return mp_const_false; + } + } + } else { + bool contains_alpha = false; + + for (size_t i = 0; i < self_len; i++) { // only check alphanumeric characters + if (unichar_isalpha(*self_data++)) { + contains_alpha = true; + if (!f(*(self_data - 1))) { // -1 because we already incremented above + return mp_const_false; + } + } + } + + if (!contains_alpha) { + return mp_const_false; + } + } + + return mp_const_true; +} + +STATIC mp_obj_t str_isspace(mp_obj_t self_in) { + return str_uni_istype(unichar_isspace, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_isspace_obj, str_isspace); + +STATIC mp_obj_t str_isalpha(mp_obj_t self_in) { + return str_uni_istype(unichar_isalpha, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_isalpha_obj, str_isalpha); + +STATIC mp_obj_t str_isdigit(mp_obj_t self_in) { + return str_uni_istype(unichar_isdigit, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_isdigit_obj, str_isdigit); + +STATIC mp_obj_t str_isupper(mp_obj_t self_in) { + return str_uni_istype(unichar_isupper, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_isupper_obj, str_isupper); + +STATIC mp_obj_t str_islower(mp_obj_t self_in) { + return str_uni_istype(unichar_islower, self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower); + +#if MICROPY_CPYTHON_COMPAT +// These methods are superfluous in the presence of str() and bytes() +// constructors. +// TODO: should accept kwargs too +STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) { + mp_obj_t new_args[2]; + if (n_args == 1) { + new_args[0] = args[0]; + new_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_utf_hyphen_8); + args = new_args; + n_args++; + } + return mp_obj_str_make_new(&mp_type_str, n_args, 0, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode); + +// TODO: should accept kwargs too +STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) { + mp_obj_t new_args[2]; + if (n_args == 1) { + new_args[0] = args[0]; + new_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_utf_hyphen_8); + args = new_args; + n_args++; + } + return bytes_make_new(NULL, n_args, 0, args); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj, 1, 3, str_encode); +#endif + +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + if (flags == MP_BUFFER_READ) { + GET_STR_DATA_LEN(self_in, str_data, str_len); + bufinfo->buf = (void*)str_data; + bufinfo->len = str_len; + bufinfo->typecode = 'B'; // bytes should be unsigned, so should unicode byte-access + return 0; + } else { + // can't write to a string + bufinfo->buf = NULL; + bufinfo->len = 0; + bufinfo->typecode = -1; + return 1; + } +} + +STATIC const mp_rom_map_elem_t str8_locals_dict_table[] = { +#if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&bytes_decode_obj) }, + #if !MICROPY_PY_BUILTINS_STR_UNICODE + // If we have separate unicode type, then here we have methods only + // for bytes type, and it should not have encode() methods. Otherwise, + // we have non-compliant-but-practical bytestring type, which shares + // method table with bytes, so they both have encode() and decode() + // methods (which should do type checking at runtime). + { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&str_encode_obj) }, + #endif +#endif + { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&str_find_obj) }, + { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&str_rfind_obj) }, + { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&str_index_obj) }, + { MP_ROM_QSTR(MP_QSTR_rindex), MP_ROM_PTR(&str_rindex_obj) }, + { MP_ROM_QSTR(MP_QSTR_join), MP_ROM_PTR(&str_join_obj) }, + { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&str_split_obj) }, + #if MICROPY_PY_BUILTINS_STR_SPLITLINES + { MP_ROM_QSTR(MP_QSTR_splitlines), MP_ROM_PTR(&str_splitlines_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_rsplit), MP_ROM_PTR(&str_rsplit_obj) }, + { MP_ROM_QSTR(MP_QSTR_startswith), MP_ROM_PTR(&str_startswith_obj) }, + { MP_ROM_QSTR(MP_QSTR_endswith), MP_ROM_PTR(&str_endswith_obj) }, + { MP_ROM_QSTR(MP_QSTR_strip), MP_ROM_PTR(&str_strip_obj) }, + { MP_ROM_QSTR(MP_QSTR_lstrip), MP_ROM_PTR(&str_lstrip_obj) }, + { MP_ROM_QSTR(MP_QSTR_rstrip), MP_ROM_PTR(&str_rstrip_obj) }, + { MP_ROM_QSTR(MP_QSTR_format), MP_ROM_PTR(&str_format_obj) }, + { MP_ROM_QSTR(MP_QSTR_replace), MP_ROM_PTR(&str_replace_obj) }, + { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&str_count_obj) }, + #if MICROPY_PY_BUILTINS_STR_PARTITION + { MP_ROM_QSTR(MP_QSTR_partition), MP_ROM_PTR(&str_partition_obj) }, + { MP_ROM_QSTR(MP_QSTR_rpartition), MP_ROM_PTR(&str_rpartition_obj) }, + #endif + #if MICROPY_PY_BUILTINS_STR_CENTER + { MP_ROM_QSTR(MP_QSTR_center), MP_ROM_PTR(&str_center_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_lower), MP_ROM_PTR(&str_lower_obj) }, + { MP_ROM_QSTR(MP_QSTR_upper), MP_ROM_PTR(&str_upper_obj) }, + { MP_ROM_QSTR(MP_QSTR_isspace), MP_ROM_PTR(&str_isspace_obj) }, + { MP_ROM_QSTR(MP_QSTR_isalpha), MP_ROM_PTR(&str_isalpha_obj) }, + { MP_ROM_QSTR(MP_QSTR_isdigit), MP_ROM_PTR(&str_isdigit_obj) }, + { MP_ROM_QSTR(MP_QSTR_isupper), MP_ROM_PTR(&str_isupper_obj) }, + { MP_ROM_QSTR(MP_QSTR_islower), MP_ROM_PTR(&str_islower_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(str8_locals_dict, str8_locals_dict_table); + +#if !MICROPY_PY_BUILTINS_STR_UNICODE +STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); + +const mp_obj_type_t mp_type_str = { + { &mp_type_type }, + .name = MP_QSTR_str, + .print = str_print, + .make_new = mp_obj_str_make_new, + .binary_op = mp_obj_str_binary_op, + .subscr = bytes_subscr, + .getiter = mp_obj_new_str_iterator, + .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, +}; +#endif + +// Reuses most of methods from str +const mp_obj_type_t mp_type_bytes = { + { &mp_type_type }, + .name = MP_QSTR_bytes, + .print = str_print, + .make_new = bytes_make_new, + .binary_op = mp_obj_str_binary_op, + .subscr = bytes_subscr, + .getiter = mp_obj_new_bytes_iterator, + .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, +}; + +// the zero-length bytes +const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, NULL}; + +// Create a str/bytes object using the given data. New memory is allocated and +// the data is copied across. +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len) { + mp_obj_str_t *o = m_new_obj(mp_obj_str_t); + o->base.type = type; + o->len = len; + if (data) { + o->hash = qstr_compute_hash(data, len); + byte *p = m_new(byte, len + 1); + o->data = p; + memcpy(p, data, len * sizeof(byte)); + p[len] = '\0'; // for now we add null for compatibility with C ASCIIZ strings + } + return MP_OBJ_FROM_PTR(o); +} + +// Create a str/bytes object from the given vstr. The vstr buffer is resized to +// the exact length required and then reused for the str/bytes object. The vstr +// is cleared and can safely be passed to vstr_free if it was heap allocated. +mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) { + // if not a bytes object, look if a qstr with this data already exists + if (type == &mp_type_str) { + qstr q = qstr_find_strn(vstr->buf, vstr->len); + if (q != MP_QSTR_NULL) { + vstr_clear(vstr); + vstr->alloc = 0; + return MP_OBJ_NEW_QSTR(q); + } + } + + // make a new str/bytes object + mp_obj_str_t *o = m_new_obj(mp_obj_str_t); + o->base.type = type; + o->len = vstr->len; + o->hash = qstr_compute_hash((byte*)vstr->buf, vstr->len); + if (vstr->len + 1 == vstr->alloc) { + o->data = (byte*)vstr->buf; + } else { + o->data = (byte*)m_renew(char, vstr->buf, vstr->alloc, vstr->len + 1); + } + ((byte*)o->data)[o->len] = '\0'; // add null byte + vstr->buf = NULL; + vstr->alloc = 0; + return MP_OBJ_FROM_PTR(o); +} + +mp_obj_t mp_obj_new_str(const char* data, size_t len, bool make_qstr_if_not_already) { + if (make_qstr_if_not_already) { + // use existing, or make a new qstr + return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len)); + } else { + qstr q = qstr_find_strn(data, len); + if (q != MP_QSTR_NULL) { + // qstr with this data already exists + return MP_OBJ_NEW_QSTR(q); + } else { + // no existing qstr, don't make one + return mp_obj_new_str_of_type(&mp_type_str, (const byte*)data, len); + } + } +} + +mp_obj_t mp_obj_str_intern(mp_obj_t str) { + GET_STR_DATA_LEN(str, data, len); + return MP_OBJ_NEW_QSTR(qstr_from_strn((const char*)data, len)); +} + +mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) { + return mp_obj_new_str_of_type(&mp_type_bytes, data, len); +} + +bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { + if (MP_OBJ_IS_QSTR(s1) && MP_OBJ_IS_QSTR(s2)) { + return s1 == s2; + } else { + GET_STR_HASH(s1, h1); + GET_STR_HASH(s2, h2); + // If any of hashes is 0, it means it's not valid + if (h1 != 0 && h2 != 0 && h1 != h2) { + return false; + } + GET_STR_DATA_LEN(s1, d1, l1); + GET_STR_DATA_LEN(s2, d2, l2); + if (l1 != l2) { + return false; + } + return memcmp(d1, d2, l1) == 0; + } +} + +STATIC void bad_implicit_conversion(mp_obj_t self_in) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("can't convert to str implicitly"); + } else { + const qstr src_name = mp_obj_get_type(self_in)->name; + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "can't convert '%q' object to %q implicitly", + src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str)); + } +} + +// use this if you will anyway convert the string to a qstr +// will be more efficient for the case where it's already a qstr +qstr mp_obj_str_get_qstr(mp_obj_t self_in) { + if (MP_OBJ_IS_QSTR(self_in)) { + return MP_OBJ_QSTR_VALUE(self_in); + } else if (MP_OBJ_IS_TYPE(self_in, &mp_type_str)) { + mp_obj_str_t *self = MP_OBJ_TO_PTR(self_in); + return qstr_from_strn((char*)self->data, self->len); + } else { + bad_implicit_conversion(self_in); + } +} + +// only use this function if you need the str data to be zero terminated +// at the moment all strings are zero terminated to help with C ASCIIZ compatibility +const char *mp_obj_str_get_str(mp_obj_t self_in) { + if (MP_OBJ_IS_STR_OR_BYTES(self_in)) { + GET_STR_DATA_LEN(self_in, s, l); + (void)l; // len unused + return (const char*)s; + } else { + bad_implicit_conversion(self_in); + } +} + +const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len) { + if (MP_OBJ_IS_STR_OR_BYTES(self_in)) { + GET_STR_DATA_LEN(self_in, s, l); + *len = l; + return (const char*)s; + } else { + bad_implicit_conversion(self_in); + } +} + +#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C +const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len) { + if (MP_OBJ_IS_QSTR(self_in)) { + return qstr_data(MP_OBJ_QSTR_VALUE(self_in), len); + } else { + *len = ((mp_obj_str_t*)self_in)->len; + return ((mp_obj_str_t*)self_in)->data; + } +} +#endif + +/******************************************************************************/ +/* str iterator */ + +typedef struct _mp_obj_str8_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t str; + size_t cur; +} mp_obj_str8_it_t; + +#if !MICROPY_PY_BUILTINS_STR_UNICODE +STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { + mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in); + GET_STR_DATA_LEN(self->str, str, len); + if (self->cur < len) { + mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, true); + self->cur += 1; + return o_out; + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = str_it_iternext; + o->str = str; + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} +#endif + +STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) { + mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in); + GET_STR_DATA_LEN(self->str, str, len); + if (self->cur < len) { + mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(str[self->cur]); + self->cur += 1; + return o_out; + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = bytes_it_iternext; + o->str = str; + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objstr.h b/user/mpy/py/objstr.h new file mode 100644 index 0000000..3aef8c6 --- /dev/null +++ b/user/mpy/py/objstr.h @@ -0,0 +1,105 @@ +/* + * 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_OBJSTR_H +#define MICROPY_INCLUDED_PY_OBJSTR_H + +#include "py/obj.h" + +typedef struct _mp_obj_str_t { + mp_obj_base_t base; + mp_uint_t hash; + // len == number of bytes used in data, alloc = len + 1 because (at the moment) we also append a null byte + size_t len; + const byte *data; +} mp_obj_str_t; + +#define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str} + +// use this macro to extract the string hash +// warning: the hash can be 0, meaning invalid, and must then be explicitly computed from the data +#define GET_STR_HASH(str_obj_in, str_hash) \ + mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(str_obj_in)) \ + { str_hash = qstr_hash(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_hash = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->hash; } + +// use this macro to extract the string length +#define GET_STR_LEN(str_obj_in, str_len) \ + size_t str_len; if (MP_OBJ_IS_QSTR(str_obj_in)) \ + { str_len = qstr_len(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; } + +// use this macro to extract the string data and length +#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C +const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len); +#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) \ + size_t str_len; const byte *str_data = mp_obj_str_get_data_no_check(str_obj_in, &str_len); +#else +#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) \ + const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(str_obj_in)) \ + { str_data = qstr_data(MP_OBJ_QSTR_VALUE(str_obj_in), &str_len); } \ + else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; str_data = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->data; } +#endif + +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); +void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); +mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); +mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); +mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); + +mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); +mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); + +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, bool is_slice); +const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); + +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj); +MP_DECLARE_CONST_FUN_OBJ_2(str_join_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(str_splitlines_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj); +MP_DECLARE_CONST_FUN_OBJ_KW(str_format_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj); +MP_DECLARE_CONST_FUN_OBJ_2(str_partition_obj); +MP_DECLARE_CONST_FUN_OBJ_2(str_rpartition_obj); +MP_DECLARE_CONST_FUN_OBJ_2(str_center_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_lower_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_upper_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_isspace_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_isalpha_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_isdigit_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_isupper_obj); +MP_DECLARE_CONST_FUN_OBJ_1(str_islower_obj); + +#endif // MICROPY_INCLUDED_PY_OBJSTR_H diff --git a/user/mpy/py/objstringio.c b/user/mpy/py/objstringio.c new file mode 100644 index 0000000..046d325 --- /dev/null +++ b/user/mpy/py/objstringio.c @@ -0,0 +1,269 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objstr.h" +#include "py/objstringio.h" +#include "py/runtime.h" +#include "py/stream.h" + +#if MICROPY_PY_IO + +#if MICROPY_CPYTHON_COMPAT +STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) { + if (o->vstr == NULL) { + mp_raise_ValueError("I/O operation on closed file"); + } +} +#else +#define check_stringio_is_open(o) +#endif + +STATIC void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, self->base.type == &mp_type_stringio ? "" : "", self); +} + +STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { + (void)errcode; + mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); + check_stringio_is_open(o); + if (o->vstr->len <= o->pos) { // read to EOF, or seeked to EOF or beyond + return 0; + } + mp_uint_t remaining = o->vstr->len - o->pos; + if (size > remaining) { + size = remaining; + } + memcpy(buf, o->vstr->buf + o->pos, size); + o->pos += size; + return size; +} + +STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) { + const void *buf = o->vstr->buf; + o->vstr->buf = m_new(char, o->vstr->len); + memcpy(o->vstr->buf, buf, o->vstr->len); + o->vstr->fixed_buf = false; + o->ref_obj = MP_OBJ_NULL; +} + +STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { + (void)errcode; + mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); + check_stringio_is_open(o); + + if (o->vstr->fixed_buf) { + stringio_copy_on_write(o); + } + + mp_uint_t new_pos = o->pos + size; + if (new_pos < size) { + // Writing bytes will overflow o->pos beyond limit of mp_uint_t. + *errcode = MP_EFBIG; + return MP_STREAM_ERROR; + } + mp_uint_t org_len = o->vstr->len; + if (new_pos > o->vstr->alloc) { + // Take all what's already allocated... + o->vstr->len = o->vstr->alloc; + // ... and add more + vstr_add_len(o->vstr, new_pos - o->vstr->alloc); + } + // If there was a seek past EOF, clear the hole + if (o->pos > org_len) { + memset(o->vstr->buf + org_len, 0, o->pos - org_len); + } + memcpy(o->vstr->buf + o->pos, buf, size); + o->pos = new_pos; + if (new_pos > o->vstr->len) { + o->vstr->len = new_pos; + } + return size; +} + +STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { + (void)errcode; + mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); + switch (request) { + case MP_STREAM_SEEK: { + struct mp_stream_seek_t *s = (struct mp_stream_seek_t*)arg; + mp_uint_t ref = 0; + switch (s->whence) { + case 1: // SEEK_CUR + ref = o->pos; + break; + case 2: // SEEK_END + ref = o->vstr->len; + break; + } + o->pos = ref + s->offset; + s->offset = o->pos; + return 0; + } + case MP_STREAM_FLUSH: + return 0; + default: + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } +} + +#define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_bytes) + +STATIC mp_obj_t stringio_getvalue(mp_obj_t self_in) { + mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); + check_stringio_is_open(self); + // TODO: Try to avoid copying string + return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte*)self->vstr->buf, self->vstr->len); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue); + +STATIC mp_obj_t stringio_close(mp_obj_t self_in) { + mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); +#if MICROPY_CPYTHON_COMPAT + vstr_free(self->vstr); + self->vstr = NULL; +#else + vstr_clear(self->vstr); + self->vstr->alloc = 0; + self->vstr->len = 0; + self->pos = 0; +#endif + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_close_obj, stringio_close); + +STATIC mp_obj_t stringio___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + return stringio_close(args[0]); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stringio___exit___obj, 4, 4, stringio___exit__); + +STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) { + mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); + o->base.type = type; + o->pos = 0; + o->ref_obj = MP_OBJ_NULL; + return o; +} + +STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)n_kw; // TODO check n_kw==0 + + mp_uint_t sz = 16; + bool initdata = false; + mp_buffer_info_t bufinfo; + + mp_obj_stringio_t *o = stringio_new(type_in); + + if (n_args > 0) { + if (MP_OBJ_IS_INT(args[0])) { + sz = mp_obj_get_int(args[0]); + } else { + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); + + if (MP_OBJ_IS_STR_OR_BYTES(args[0])) { + o->vstr = m_new_obj(vstr_t); + vstr_init_fixed_buf(o->vstr, bufinfo.len, bufinfo.buf); + o->vstr->len = bufinfo.len; + o->ref_obj = args[0]; + return MP_OBJ_FROM_PTR(o); + } + + sz = bufinfo.len; + initdata = true; + } + } + + o->vstr = vstr_new(sz); + + if (initdata) { + stringio_write(MP_OBJ_FROM_PTR(o), bufinfo.buf, bufinfo.len, NULL); + // Cur ptr is always at the beginning of buffer at the construction + o->pos = 0; + } + return MP_OBJ_FROM_PTR(o); +} + +STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) }, + { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) }, + { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&stringio_close_obj) }, + { MP_ROM_QSTR(MP_QSTR_getvalue), MP_ROM_PTR(&stringio_getvalue_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&stringio___exit___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table); + +STATIC const mp_stream_p_t stringio_stream_p = { + .read = stringio_read, + .write = stringio_write, + .ioctl = stringio_ioctl, + .is_text = true, +}; + +STATIC const mp_stream_p_t bytesio_stream_p = { + .read = stringio_read, + .write = stringio_write, + .ioctl = stringio_ioctl, +}; + +const mp_obj_type_t mp_type_stringio = { + { &mp_type_type }, + .name = MP_QSTR_StringIO, + .print = stringio_print, + .make_new = stringio_make_new, + .getiter = mp_identity_getiter, + .iternext = mp_stream_unbuffered_iter, + .protocol = &stringio_stream_p, + .locals_dict = (mp_obj_dict_t*)&stringio_locals_dict, +}; + +#if MICROPY_PY_IO_BYTESIO +const mp_obj_type_t mp_type_bytesio = { + { &mp_type_type }, + .name = MP_QSTR_BytesIO, + .print = stringio_print, + .make_new = stringio_make_new, + .getiter = mp_identity_getiter, + .iternext = mp_stream_unbuffered_iter, + .protocol = &bytesio_stream_p, + .locals_dict = (mp_obj_dict_t*)&stringio_locals_dict, +}; +#endif + +#endif diff --git a/user/mpy/py/objstringio.h b/user/mpy/py/objstringio.h new file mode 100644 index 0000000..56738f4 --- /dev/null +++ b/user/mpy/py/objstringio.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_OBJSTRINGIO_H +#define MICROPY_INCLUDED_PY_OBJSTRINGIO_H + +#include "py/obj.h" + +typedef struct _mp_obj_stringio_t { + mp_obj_base_t base; + vstr_t *vstr; + // StringIO has single pointer used for both reading and writing + mp_uint_t pos; + // Underlying object buffered by this StringIO + mp_obj_t ref_obj; +} mp_obj_stringio_t; + +#endif // MICROPY_INCLUDED_PY_OBJSTRINGIO_H diff --git a/user/mpy/py/objstrunicode.c b/user/mpy/py/objstrunicode.c new file mode 100644 index 0000000..036f7f3 --- /dev/null +++ b/user/mpy/py/objstrunicode.c @@ -0,0 +1,314 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objstr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_PY_BUILTINS_STR_UNICODE + +STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); + +/******************************************************************************/ +/* str */ + +STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) { + // this escapes characters, but it will be very slow to print (calling print many times) + bool has_single_quote = false; + bool has_double_quote = false; + for (const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) { + if (*s == '\'') { + has_single_quote = true; + } else if (*s == '"') { + has_double_quote = true; + } + } + unichar quote_char = '\''; + if (has_single_quote && !has_double_quote) { + quote_char = '"'; + } + mp_printf(print, "%c", quote_char); + const byte *s = str_data, *top = str_data + str_len; + while (s < top) { + unichar ch; + ch = utf8_get_char(s); + s = utf8_next_char(s); + if (ch == quote_char) { + mp_printf(print, "\\%c", quote_char); + } else if (ch == '\\') { + mp_print_str(print, "\\\\"); + } else if (32 <= ch && ch <= 126) { + mp_printf(print, "%c", ch); + } else if (ch == '\n') { + mp_print_str(print, "\\n"); + } else if (ch == '\r') { + mp_print_str(print, "\\r"); + } else if (ch == '\t') { + mp_print_str(print, "\\t"); + } else if (ch < 0x100) { + mp_printf(print, "\\x%02x", ch); + } else if (ch < 0x10000) { + mp_printf(print, "\\u%04x", ch); + } else { + mp_printf(print, "\\U%08x", ch); + } + } + mp_printf(print, "%c", quote_char); +} + +STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + GET_STR_DATA_LEN(self_in, str_data, str_len); + #if MICROPY_PY_UJSON + if (kind == PRINT_JSON) { + mp_str_print_json(print, str_data, str_len); + return; + } + #endif + if (kind == PRINT_STR) { + mp_printf(print, "%.*s", str_len, str_data); + } else { + uni_print_quoted(print, str_data, str_len); + } +} + +STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) { + GET_STR_DATA_LEN(self_in, str_data, str_len); + switch (op) { + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(str_len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(unichar_charlen((const char *)str_data, str_len)); + default: + return MP_OBJ_NULL; // op not supported + } +} + +// Convert an index into a pointer to its lead byte. Out of bounds indexing will raise IndexError or +// be capped to the first/last character of the string, depending on is_slice. +const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + mp_obj_t index, bool is_slice) { + // All str functions also handle bytes objects, and they call str_index_to_ptr(), + // so it must handle bytes. + if (type == &mp_type_bytes) { + // Taken from objstr.c:str_index_to_ptr() + size_t index_val = mp_get_index(type, self_len, index, is_slice); + return self_data + index_val; + } + + mp_int_t i; + // Copied from mp_get_index; I don't want bounds checking, just give me + // the integer as-is. (I can't bounds-check without scanning the whole + // string; an out-of-bounds index will be caught in the loops below.) + if (MP_OBJ_IS_SMALL_INT(index)) { + i = MP_OBJ_SMALL_INT_VALUE(index); + } else if (!mp_obj_get_int_maybe(index, &i)) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "string indices must be integers, not %s", mp_obj_get_type_str(index))); + } + const byte *s, *top = self_data + self_len; + if (i < 0) + { + // Negative indexing is performed by counting from the end of the string. + for (s = top - 1; i; --s) { + if (s < self_data) { + if (is_slice) { + return self_data; + } + mp_raise_msg(&mp_type_IndexError, "string index out of range"); + } + if (!UTF8_IS_CONT(*s)) { + ++i; + } + } + ++s; + } else { + // Positive indexing, correspondingly, counts from the start of the string. + // It's assumed that negative indexing will generally be used with small + // absolute values (eg str[-1], not str[-1000000]), which means it'll be + // more efficient this way. + s = self_data; + while (1) { + // First check out-of-bounds + if (s >= top) { + if (is_slice) { + return top; + } + mp_raise_msg(&mp_type_IndexError, "string index out of range"); + } + // Then check completion + if (i-- == 0) { + break; + } + // Then skip UTF-8 char + ++s; + while (UTF8_IS_CONT(*s)) { + ++s; + } + } + } + return s; +} + +STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + assert(type == &mp_type_str); + GET_STR_DATA_LEN(self_in, self_data, self_len); + if (value == MP_OBJ_SENTINEL) { + // load +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_obj_t ostart, ostop, ostep; + mp_obj_slice_get(index, &ostart, &ostop, &ostep); + if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) { + mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); + } + + const byte *pstart, *pstop; + if (ostart != mp_const_none) { + pstart = str_index_to_ptr(type, self_data, self_len, ostart, true); + } else { + pstart = self_data; + } + if (ostop != mp_const_none) { + // pstop will point just after the stop character. This depends on + // the \0 at the end of the string. + pstop = str_index_to_ptr(type, self_data, self_len, ostop, true); + } else { + pstop = self_data + self_len; + } + if (pstop < pstart) { + return MP_OBJ_NEW_QSTR(MP_QSTR_); + } + return mp_obj_new_str_of_type(type, (const byte *)pstart, pstop - pstart); + } +#endif + const byte *s = str_index_to_ptr(type, self_data, self_len, index, false); + int len = 1; + if (UTF8_IS_NONASCII(*s)) { + // Count the number of 1 bits (after the first) + for (char mask = 0x40; *s & mask; mask >>= 1) { + ++len; + } + } + return mp_obj_new_str((const char*)s, len, true); // This will create a one-character string + } else { + return MP_OBJ_NULL; // op not supported + } +} + +STATIC const mp_rom_map_elem_t struni_locals_dict_table[] = { +#if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&str_encode_obj) }, +#endif + { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&str_find_obj) }, + { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&str_rfind_obj) }, + { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&str_index_obj) }, + { MP_ROM_QSTR(MP_QSTR_rindex), MP_ROM_PTR(&str_rindex_obj) }, + { MP_ROM_QSTR(MP_QSTR_join), MP_ROM_PTR(&str_join_obj) }, + { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&str_split_obj) }, + #if MICROPY_PY_BUILTINS_STR_SPLITLINES + { MP_ROM_QSTR(MP_QSTR_splitlines), MP_ROM_PTR(&str_splitlines_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_rsplit), MP_ROM_PTR(&str_rsplit_obj) }, + { MP_ROM_QSTR(MP_QSTR_startswith), MP_ROM_PTR(&str_startswith_obj) }, + { MP_ROM_QSTR(MP_QSTR_endswith), MP_ROM_PTR(&str_endswith_obj) }, + { MP_ROM_QSTR(MP_QSTR_strip), MP_ROM_PTR(&str_strip_obj) }, + { MP_ROM_QSTR(MP_QSTR_lstrip), MP_ROM_PTR(&str_lstrip_obj) }, + { MP_ROM_QSTR(MP_QSTR_rstrip), MP_ROM_PTR(&str_rstrip_obj) }, + { MP_ROM_QSTR(MP_QSTR_format), MP_ROM_PTR(&str_format_obj) }, + { MP_ROM_QSTR(MP_QSTR_replace), MP_ROM_PTR(&str_replace_obj) }, + { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&str_count_obj) }, + #if MICROPY_PY_BUILTINS_STR_PARTITION + { MP_ROM_QSTR(MP_QSTR_partition), MP_ROM_PTR(&str_partition_obj) }, + { MP_ROM_QSTR(MP_QSTR_rpartition), MP_ROM_PTR(&str_rpartition_obj) }, + #endif + #if MICROPY_PY_BUILTINS_STR_CENTER + { MP_ROM_QSTR(MP_QSTR_center), MP_ROM_PTR(&str_center_obj) }, + #endif + { MP_ROM_QSTR(MP_QSTR_lower), MP_ROM_PTR(&str_lower_obj) }, + { MP_ROM_QSTR(MP_QSTR_upper), MP_ROM_PTR(&str_upper_obj) }, + { MP_ROM_QSTR(MP_QSTR_isspace), MP_ROM_PTR(&str_isspace_obj) }, + { MP_ROM_QSTR(MP_QSTR_isalpha), MP_ROM_PTR(&str_isalpha_obj) }, + { MP_ROM_QSTR(MP_QSTR_isdigit), MP_ROM_PTR(&str_isdigit_obj) }, + { MP_ROM_QSTR(MP_QSTR_isupper), MP_ROM_PTR(&str_isupper_obj) }, + { MP_ROM_QSTR(MP_QSTR_islower), MP_ROM_PTR(&str_islower_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(struni_locals_dict, struni_locals_dict_table); + +const mp_obj_type_t mp_type_str = { + { &mp_type_type }, + .name = MP_QSTR_str, + .print = uni_print, + .make_new = mp_obj_str_make_new, + .unary_op = uni_unary_op, + .binary_op = mp_obj_str_binary_op, + .subscr = str_subscr, + .getiter = mp_obj_new_str_iterator, + .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, + .locals_dict = (mp_obj_dict_t*)&struni_locals_dict, +}; + +/******************************************************************************/ +/* str iterator */ + +typedef struct _mp_obj_str_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_t str; + size_t cur; +} mp_obj_str_it_t; + +STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { + mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in); + GET_STR_DATA_LEN(self->str, str, len); + if (self->cur < len) { + const byte *cur = str + self->cur; + const byte *end = utf8_next_char(str + self->cur); + mp_obj_t o_out = mp_obj_new_str((const char*)cur, end - cur, true); + self->cur += end - cur; + return o_out; + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_str_it_t *o = (mp_obj_str_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = str_it_iternext; + o->str = str; + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} + +#endif // MICROPY_PY_BUILTINS_STR_UNICODE diff --git a/user/mpy/py/objtuple.c b/user/mpy/py/objtuple.c new file mode 100644 index 0000000..765edb9 --- /dev/null +++ b/user/mpy/py/objtuple.c @@ -0,0 +1,291 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objtuple.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +/******************************************************************************/ +/* tuple */ + +void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); + if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + mp_print_str(print, "["); + } else { + mp_print_str(print, "("); + kind = PRINT_REPR; + } + for (size_t i = 0; i < o->len; i++) { + if (i > 0) { + mp_print_str(print, ", "); + } + mp_obj_print_helper(print, o->items[i], kind); + } + if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + mp_print_str(print, "]"); + } else { + if (o->len == 1) { + mp_print_str(print, ","); + } + mp_print_str(print, ")"); + } +} + +STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + mp_arg_check_num(n_args, n_kw, 0, 1, false); + + switch (n_args) { + case 0: + // return a empty tuple + return mp_const_empty_tuple; + + case 1: + default: { + // 1 argument, an iterable from which we make a new tuple + if (MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)) { + return args[0]; + } + + // TODO optimise for cases where we know the length of the iterator + + size_t alloc = 4; + size_t len = 0; + mp_obj_t *items = m_new(mp_obj_t, alloc); + + mp_obj_t iterable = mp_getiter(args[0], NULL); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (len >= alloc) { + items = m_renew(mp_obj_t, items, alloc, alloc * 2); + alloc *= 2; + } + items[len++] = item; + } + + mp_obj_t tuple = mp_obj_new_tuple(len, items); + m_del(mp_obj_t, items, alloc); + + return tuple; + } + } +} + +// Don't pass MP_BINARY_OP_NOT_EQUAL here +STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { + // type check is done on getiter method to allow tuple, namedtuple, attrtuple + mp_check_self(mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter); + mp_obj_type_t *another_type = mp_obj_get_type(another_in); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + if (another_type->getiter != mp_obj_tuple_getiter) { + // Slow path for user subclasses + another_in = mp_instance_cast_to_native_base(another_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); + if (another_in == MP_OBJ_NULL) { + return false; + } + } + mp_obj_tuple_t *another = MP_OBJ_TO_PTR(another_in); + + return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); +} + +mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + switch (op) { + case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); + case MP_UNARY_OP_HASH: { + // start hash with pointer to empty tuple, to make it fairly unique + mp_int_t hash = (mp_int_t)mp_const_empty_tuple; + for (size_t i = 0; i < self->len; i++) { + hash += MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, self->items[i])); + } + return MP_OBJ_NEW_SMALL_INT(hash); + } + case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); + default: return MP_OBJ_NULL; // op not supported + } +} + +mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + mp_obj_tuple_t *o = MP_OBJ_TO_PTR(lhs); + switch (op) { + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: { + if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(rhs)), MP_OBJ_FROM_PTR(&mp_type_tuple))) { + return MP_OBJ_NULL; // op not supported + } + mp_obj_tuple_t *p = MP_OBJ_TO_PTR(rhs); + mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(o->len + p->len, NULL)); + mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t); + return MP_OBJ_FROM_PTR(s); + } + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: { + mp_int_t n; + if (!mp_obj_get_int_maybe(rhs, &n)) { + return MP_OBJ_NULL; // op not supported + } + if (n <= 0) { + return mp_const_empty_tuple; + } + mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(o->len * n, NULL)); + mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); + return MP_OBJ_FROM_PTR(s); + } + case MP_BINARY_OP_EQUAL: + case MP_BINARY_OP_LESS: + case MP_BINARY_OP_LESS_EQUAL: + case MP_BINARY_OP_MORE: + case MP_BINARY_OP_MORE_EQUAL: + return mp_obj_new_bool(tuple_cmp_helper(op, lhs, rhs)); + + default: + return MP_OBJ_NULL; // op not supported + } +} + +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_SENTINEL) { + // load + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); +#if MICROPY_PY_BUILTINS_SLICE + if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { + mp_bound_slice_t slice; + if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { + mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); + } + mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice.stop - slice.start, NULL)); + mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t); + return MP_OBJ_FROM_PTR(res); + } +#endif + size_t index_value = mp_get_index(self->base.type, self->len, index, false); + return self->items[index_value]; + } else { + return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + return mp_seq_count_obj(self->items, self->len, value); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count); + +STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) { + mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]); + return mp_seq_index_obj(self->items, self->len, n_args, args); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index); + +STATIC const mp_rom_map_elem_t tuple_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&tuple_count_obj) }, + { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&tuple_index_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table); + +const mp_obj_type_t mp_type_tuple = { + { &mp_type_type }, + .name = MP_QSTR_tuple, + .print = mp_obj_tuple_print, + .make_new = mp_obj_tuple_make_new, + .unary_op = mp_obj_tuple_unary_op, + .binary_op = mp_obj_tuple_binary_op, + .subscr = mp_obj_tuple_subscr, + .getiter = mp_obj_tuple_getiter, + .locals_dict = (mp_obj_dict_t*)&tuple_locals_dict, +}; + +// the zero-length tuple +const mp_obj_tuple_t mp_const_empty_tuple_obj = {{&mp_type_tuple}, 0}; + +mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) { + if (n == 0) { + return mp_const_empty_tuple; + } + mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, n); + o->base.type = &mp_type_tuple; + o->len = n; + if (items) { + for (size_t i = 0; i < n; i++) { + o->items[i] = items[i]; + } + } + return MP_OBJ_FROM_PTR(o); +} + +void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + *len = self->len; + *items = &self->items[0]; +} + +void mp_obj_tuple_del(mp_obj_t self_in) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + m_del_var(mp_obj_tuple_t, mp_obj_t, self->len, self); +} + +/******************************************************************************/ +/* tuple iterator */ + +typedef struct _mp_obj_tuple_it_t { + mp_obj_base_t base; + mp_fun_1_t iternext; + mp_obj_tuple_t *tuple; + size_t cur; +} mp_obj_tuple_it_t; + +STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) { + mp_obj_tuple_it_t *self = MP_OBJ_TO_PTR(self_in); + if (self->cur < self->tuple->len) { + mp_obj_t o_out = self->tuple->items[self->cur]; + self->cur += 1; + return o_out; + } else { + return MP_OBJ_STOP_ITERATION; + } +} + +mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + assert(sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t)); + mp_obj_tuple_it_t *o = (mp_obj_tuple_it_t*)iter_buf; + o->base.type = &mp_type_polymorph_iter; + o->iternext = tuple_it_iternext; + o->tuple = MP_OBJ_TO_PTR(o_in); + o->cur = 0; + return MP_OBJ_FROM_PTR(o); +} diff --git a/user/mpy/py/objtuple.h b/user/mpy/py/objtuple.h new file mode 100644 index 0000000..05c6490 --- /dev/null +++ b/user/mpy/py/objtuple.h @@ -0,0 +1,64 @@ +/* + * 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 + +#include "py/obj.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_uint_t op, mp_obj_t self_in); +mp_obj_t mp_obj_tuple_binary_op(mp_uint_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 MICROPY_PY_COLLECTIONS +void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o); +#endif + +mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); + +#endif // MICROPY_INCLUDED_PY_OBJTUPLE_H diff --git a/user/mpy/py/objtype.c b/user/mpy/py/objtype.c new file mode 100644 index 0000000..e1a24da --- /dev/null +++ b/user/mpy/py/objtype.c @@ -0,0 +1,1207 @@ +/* + * 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-2016 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. + */ + +#include +#include +#include +#include + +#include "py/nlr.h" +#include "py/objtype.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_PRINT (0) +#define DEBUG_printf(...) (void)0 +#endif + +STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + +/******************************************************************************/ +// instance object + +STATIC mp_obj_t mp_obj_new_instance(const mp_obj_type_t *class, size_t subobjs) { + mp_obj_instance_t *o = m_new_obj_var(mp_obj_instance_t, mp_obj_t, subobjs); + o->base.type = class; + mp_map_init(&o->members, 0); + mp_seq_clear(o->subobj, 0, subobjs, sizeof(*o->subobj)); + return MP_OBJ_FROM_PTR(o); +} + +STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) { + int count = 0; + for (;;) { + if (type == &mp_type_object) { + // Not a "real" type, end search here. + return count; + } else if (mp_obj_is_native_type(type)) { + // Native types don't have parents (at least not from our perspective) so end. + *last_native_base = type; + return count + 1; + } else if (type->parent == NULL) { + // No parents so end search here. + return count; + } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { + // Multiple parents, search through them all recursively. + const mp_obj_tuple_t *parent_tuple = type->parent; + const mp_obj_t *item = parent_tuple->items; + const mp_obj_t *top = item + parent_tuple->len; + for (; item < top; ++item) { + assert(MP_OBJ_IS_TYPE(*item, &mp_type_type)); + const mp_obj_type_t *bt = (const mp_obj_type_t *)MP_OBJ_TO_PTR(*item); + count += instance_count_native_bases(bt, last_native_base); + } + return count; + } else { + // A single parent, use iteration to continue the search. + type = type->parent; + } + } +} + +// TODO +// This implements depth-first left-to-right MRO, which is not compliant with Python3 MRO +// http://python-history.blogspot.com/2010/06/method-resolution-order.html +// https://www.python.org/download/releases/2.3/mro/ +// +// will keep lookup->dest[0]'s value (should be MP_OBJ_NULL on invocation) if attribute +// is not found +// will set lookup->dest[0] to MP_OBJ_SENTINEL if special method was found in a native +// type base via slot id (as specified by lookup->meth_offset). As there can be only one +// native base, it's known that it applies to instance->subobj[0]. In most cases, we also +// don't need to know which type it was - because instance->subobj[0] is of that type. +// The only exception is when object is not yet constructed, then we need to know base +// native type to construct its instance->subobj[0] from. But this case is handled via +// instance_count_native_bases(), which returns a native base which it saw. +struct class_lookup_data { + mp_obj_instance_t *obj; + qstr attr; + size_t meth_offset; + mp_obj_t *dest; + bool is_type; +}; + +STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) { + assert(lookup->dest[0] == MP_OBJ_NULL); + assert(lookup->dest[1] == MP_OBJ_NULL); + for (;;) { + // Optimize special method lookup for native types + // This avoids extra method_name => slot lookup. On the other hand, + // this should not be applied to class types, as will result in extra + // lookup either. + if (lookup->meth_offset != 0 && mp_obj_is_native_type(type)) { + if (*(void**)((char*)type + lookup->meth_offset) != NULL) { + DEBUG_printf("mp_obj_class_lookup: matched special meth slot for %s\n", qstr_str(lookup->attr)); + lookup->dest[0] = MP_OBJ_SENTINEL; + return; + } + } + + if (type->locals_dict != NULL) { + // search locals_dict (the set of methods/attributes) + assert(type->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now + mp_map_t *locals_map = &type->locals_dict->map; + mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(lookup->attr), MP_MAP_LOOKUP); + if (elem != NULL) { + if (lookup->is_type) { + // If we look up a class method, we need to return original type for which we + // do a lookup, not a (base) type in which we found the class method. + const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj; + mp_convert_member_lookup(MP_OBJ_NULL, org_type, elem->value, lookup->dest); + } else { + mp_obj_instance_t *obj = lookup->obj; + mp_obj_t obj_obj; + if (obj != NULL && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) { + // If we're dealing with native base class, then it applies to native sub-object + obj_obj = obj->subobj[0]; + } else { + obj_obj = MP_OBJ_FROM_PTR(obj); + } + mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest); + } +#if DEBUG_PRINT + printf("mp_obj_class_lookup: Returning: "); + mp_obj_print(lookup->dest[0], PRINT_REPR); printf(" "); + mp_obj_print(lookup->dest[1], PRINT_REPR); printf("\n"); +#endif + return; + } + } + + // Previous code block takes care about attributes defined in .locals_dict, + // but some attributes of native types may be handled using .load_attr method, + // so make sure we try to lookup those too. + if (lookup->obj != NULL && !lookup->is_type && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) { + mp_load_method_maybe(lookup->obj->subobj[0], lookup->attr, lookup->dest); + if (lookup->dest[0] != MP_OBJ_NULL) { + return; + } + } + + // attribute not found, keep searching base classes + + if (type->parent == NULL) { + return; + } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { + const mp_obj_tuple_t *parent_tuple = type->parent; + const mp_obj_t *item = parent_tuple->items; + const mp_obj_t *top = item + parent_tuple->len - 1; + for (; item < top; ++item) { + assert(MP_OBJ_IS_TYPE(*item, &mp_type_type)); + mp_obj_type_t *bt = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item); + if (bt == &mp_type_object) { + // Not a "real" type + continue; + } + mp_obj_class_lookup(lookup, bt); + if (lookup->dest[0] != MP_OBJ_NULL) { + return; + } + } + + // search last base (simple tail recursion elimination) + assert(MP_OBJ_IS_TYPE(*item, &mp_type_type)); + type = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item); + } else { + type = type->parent; + } + if (type == &mp_type_object) { + // Not a "real" type + return; + } + } +} + +STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + qstr meth = (kind == PRINT_STR) ? MP_QSTR___str__ : MP_QSTR___repr__; + mp_obj_t member[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = self, + .attr = meth, + .meth_offset = offsetof(mp_obj_type_t, print), + .dest = member, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == MP_OBJ_NULL && kind == PRINT_STR) { + // If there's no __str__, fall back to __repr__ + lookup.attr = MP_QSTR___repr__; + lookup.meth_offset = 0; + mp_obj_class_lookup(&lookup, self->base.type); + } + + if (member[0] == MP_OBJ_SENTINEL) { + // Handle Exception subclasses specially + if (mp_obj_is_native_exception_instance(self->subobj[0])) { + if (kind != PRINT_STR) { + mp_print_str(print, qstr_str(self->base.type->name)); + } + mp_obj_print_helper(print, self->subobj[0], kind | PRINT_EXC_SUBCLASS); + } else { + mp_obj_print_helper(print, self->subobj[0], kind); + } + return; + } + + if (member[0] != MP_OBJ_NULL) { + mp_obj_t r = mp_call_function_1(member[0], self_in); + mp_obj_print_helper(print, r, PRINT_STR); + return; + } + + // TODO: CPython prints fully-qualified type name + mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self); +} + +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { + assert(mp_obj_is_instance_type(self)); + + const mp_obj_type_t *native_base; + size_t num_native_bases = instance_count_native_bases(self, &native_base); + assert(num_native_bases < 2); + + mp_obj_instance_t *o = MP_OBJ_TO_PTR(mp_obj_new_instance(self, num_native_bases)); + + // This executes only "__new__" part of obejection creation. + // TODO: This won't work will for classes with native bases. + // TODO: This is hack, should be resolved along the lines of + // https://github.com/micropython/micropython/issues/606#issuecomment-43685883 + if (n_args == 1 && *args == MP_OBJ_SENTINEL) { + return MP_OBJ_FROM_PTR(o); + } + + // look for __new__ function + mp_obj_t init_fn[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = NULL, + .attr = MP_QSTR___new__, + .meth_offset = offsetof(mp_obj_type_t, make_new), + .dest = init_fn, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self); + + mp_obj_t new_ret = MP_OBJ_FROM_PTR(o); + if (init_fn[0] == MP_OBJ_SENTINEL) { + // Native type's constructor is what wins - it gets all our arguments, + // and none Python classes are initialized at all. + o->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args); + } else if (init_fn[0] != MP_OBJ_NULL) { + // now call Python class __new__ function with all args + if (n_args == 0 && n_kw == 0) { + mp_obj_t args2[1] = {MP_OBJ_FROM_PTR(self)}; + new_ret = mp_call_function_n_kw(init_fn[0], 1, 0, args2); + } else { + mp_obj_t *args2 = m_new(mp_obj_t, 1 + n_args + 2 * n_kw); + args2[0] = MP_OBJ_FROM_PTR(self); + memcpy(args2 + 1, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + new_ret = mp_call_function_n_kw(init_fn[0], n_args + 1, n_kw, args2); + m_del(mp_obj_t, args2, 1 + n_args + 2 * n_kw); + } + + } + + // https://docs.python.org/3.4/reference/datamodel.html#object.__new__ + // "If __new__() does not return an instance of cls, then the new instance's __init__() method will not be invoked." + if (mp_obj_get_type(new_ret) != self) { + return new_ret; + } + + o = MP_OBJ_TO_PTR(new_ret); + + // now call Python class __init__ function with all args + init_fn[0] = init_fn[1] = MP_OBJ_NULL; + lookup.obj = o; + lookup.attr = MP_QSTR___init__; + lookup.meth_offset = 0; + mp_obj_class_lookup(&lookup, self); + if (init_fn[0] != MP_OBJ_NULL) { + mp_obj_t init_ret; + if (n_args == 0 && n_kw == 0) { + init_ret = mp_call_method_n_kw(0, 0, init_fn); + } else { + mp_obj_t *args2 = m_new(mp_obj_t, 2 + n_args + 2 * n_kw); + args2[0] = init_fn[0]; + args2[1] = init_fn[1]; + memcpy(args2 + 2, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); + init_ret = mp_call_method_n_kw(n_args, n_kw, args2); + m_del(mp_obj_t, args2, 2 + n_args + 2 * n_kw); + } + if (init_ret != mp_const_none) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("__init__() should return None"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "__init__() should return None, not '%s'", mp_obj_get_type_str(init_ret))); + } + } + + } + + return MP_OBJ_FROM_PTR(o); +} + +const qstr mp_unary_op_method_name[] = { + [MP_UNARY_OP_BOOL] = MP_QSTR___bool__, + [MP_UNARY_OP_LEN] = MP_QSTR___len__, + [MP_UNARY_OP_HASH] = MP_QSTR___hash__, + #if MICROPY_PY_ALL_SPECIAL_METHODS + [MP_UNARY_OP_POSITIVE] = MP_QSTR___pos__, + [MP_UNARY_OP_NEGATIVE] = MP_QSTR___neg__, + [MP_UNARY_OP_INVERT] = MP_QSTR___invert__, + #endif + #if MICROPY_PY_SYS_GETSIZEOF + [MP_UNARY_OP_SIZEOF] = MP_QSTR_getsizeof, + #endif + [MP_UNARY_OP_NOT] = MP_QSTR_, // don't need to implement this, used to make sure array has full size +}; + +STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + + #if MICROPY_PY_SYS_GETSIZEOF + if (MP_UNLIKELY(op == MP_UNARY_OP_SIZEOF)) { + // TODO: This doesn't count inherited objects (self->subobj) + const mp_obj_type_t *native_base; + size_t num_native_bases = instance_count_native_bases(mp_obj_get_type(self_in), &native_base); + + size_t sz = sizeof(*self) + sizeof(*self->subobj) * num_native_bases + + sizeof(*self->members.table) * self->members.alloc; + return MP_OBJ_NEW_SMALL_INT(sz); + } + #endif + + qstr op_name = mp_unary_op_method_name[op]; + /* Still try to lookup native slot + if (op_name == 0) { + return MP_OBJ_NULL; + } + */ + mp_obj_t member[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = self, + .attr = op_name, + .meth_offset = offsetof(mp_obj_type_t, unary_op), + .dest = member, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == MP_OBJ_SENTINEL) { + return mp_unary_op(op, self->subobj[0]); + } else if (member[0] != MP_OBJ_NULL) { + mp_obj_t val = mp_call_function_1(member[0], self_in); + // __hash__ must return a small int + if (op == MP_UNARY_OP_HASH) { + val = MP_OBJ_NEW_SMALL_INT(mp_obj_get_int_truncated(val)); + } + return val; + } else { + if (op == MP_UNARY_OP_HASH) { + lookup.attr = MP_QSTR___eq__; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == MP_OBJ_NULL) { + // https://docs.python.org/3/reference/datamodel.html#object.__hash__ + // "User-defined classes have __eq__() and __hash__() methods by default; + // with them, all objects compare unequal (except with themselves) and + // x.__hash__() returns an appropriate value such that x == y implies + // both that x is y and hash(x) == hash(y)." + return MP_OBJ_NEW_SMALL_INT((mp_uint_t)self_in); + } + // "A class that overrides __eq__() and does not define __hash__() will have its __hash__() implicitly set to None. + // When the __hash__() method of a class is None, instances of the class will raise an appropriate TypeError" + } + + return MP_OBJ_NULL; // op not supported + } +} + +const qstr mp_binary_op_method_name[] = { + /* + 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_QSTR___add__, + [MP_BINARY_OP_SUBTRACT] = MP_QSTR___sub__, + #if MICROPY_PY_ALL_SPECIAL_METHODS + [MP_BINARY_OP_MULTIPLY] = MP_QSTR___mul__, + [MP_BINARY_OP_FLOOR_DIVIDE] = MP_QSTR___floordiv__, + [MP_BINARY_OP_TRUE_DIVIDE] = MP_QSTR___truediv__, + #endif + /* + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, + 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,*/ + #if MICROPY_PY_ALL_SPECIAL_METHODS + [MP_BINARY_OP_INPLACE_ADD] = MP_QSTR___iadd__, + [MP_BINARY_OP_INPLACE_SUBTRACT] = MP_QSTR___isub__, + #endif + /*MP_BINARY_OP_INPLACE_MULTIPLY, + MP_BINARY_OP_INPLACE_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER,*/ + [MP_BINARY_OP_LESS] = MP_QSTR___lt__, + [MP_BINARY_OP_MORE] = MP_QSTR___gt__, + [MP_BINARY_OP_EQUAL] = MP_QSTR___eq__, + [MP_BINARY_OP_LESS_EQUAL] = MP_QSTR___le__, + [MP_BINARY_OP_MORE_EQUAL] = MP_QSTR___ge__, + /* + MP_BINARY_OP_NOT_EQUAL, // a != b calls a == b and inverts result + */ + [MP_BINARY_OP_IN] = MP_QSTR___contains__, + /* + MP_BINARY_OP_IS, + */ + [MP_BINARY_OP_EXCEPTION_MATCH] = MP_QSTR_, // not implemented, used to make sure array has full size +}; + +STATIC mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + // Note: For ducktyping, CPython does not look in the instance members or use + // __getattr__ or __getattribute__. It only looks in the class dictionary. + mp_obj_instance_t *lhs = MP_OBJ_TO_PTR(lhs_in); + qstr op_name = mp_binary_op_method_name[op]; + /* Still try to lookup native slot + if (op_name == 0) { + return MP_OBJ_NULL; + } + */ + mp_obj_t dest[3] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = lhs, + .attr = op_name, + .meth_offset = offsetof(mp_obj_type_t, binary_op), + .dest = dest, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, lhs->base.type); + if (dest[0] == MP_OBJ_SENTINEL) { + return mp_binary_op(op, lhs->subobj[0], rhs_in); + } else if (dest[0] != MP_OBJ_NULL) { + dest[2] = rhs_in; + return mp_call_method_n_kw(1, 0, dest); + } else { + return MP_OBJ_NULL; // op not supported + } +} + +STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + // logic: look in instance members then class locals + assert(mp_obj_is_instance_type(mp_obj_get_type(self_in))); + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + + mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); + if (elem != NULL) { + // object member, always treated as a value + // TODO should we check for properties? + dest[0] = elem->value; + return; + } +#if MICROPY_CPYTHON_COMPAT + if (attr == MP_QSTR___dict__) { + // Create a new dict with a copy of the instance's map items. + // This creates, unlike CPython, a 'read-only' __dict__: modifying + // it will not result in modifications to the actual instance members. + mp_map_t *map = &self->members; + mp_obj_t attr_dict = mp_obj_new_dict(map->used); + for (size_t i = 0; i < map->alloc; ++i) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + mp_obj_dict_store(attr_dict, map->table[i].key, map->table[i].value); + } + } + dest[0] = attr_dict; + return; + } +#endif + struct class_lookup_data lookup = { + .obj = self, + .attr = attr, + .meth_offset = 0, + .dest = dest, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + mp_obj_t member = dest[0]; + if (member != MP_OBJ_NULL) { + #if MICROPY_PY_BUILTINS_PROPERTY + if (MP_OBJ_IS_TYPE(member, &mp_type_property)) { + // object member is a property; delegate the load to the property + // Note: This is an optimisation for code size and execution time. + // The proper way to do it is have the functionality just below + // in a __get__ method of the property object, and then it would + // be called by the descriptor code down below. But that way + // requires overhead for the nested mp_call's and overhead for + // the code. + const mp_obj_t *proxy = mp_obj_property_get(member); + if (proxy[0] == mp_const_none) { + mp_raise_msg(&mp_type_AttributeError, "unreadable attribute"); + } else { + dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self_in); + } + return; + } + #endif + + #if MICROPY_PY_DESCRIPTORS + // found a class attribute; if it has a __get__ method then call it with the + // class instance and class as arguments and return the result + // Note that this is functionally correct but very slow: each load_attr + // requires an extra mp_load_method_maybe to check for the __get__. + mp_obj_t attr_get_method[4]; + mp_load_method_maybe(member, MP_QSTR___get__, attr_get_method); + if (attr_get_method[0] != MP_OBJ_NULL) { + attr_get_method[2] = self_in; + attr_get_method[3] = MP_OBJ_FROM_PTR(mp_obj_get_type(self_in)); + dest[0] = mp_call_method_n_kw(2, 0, attr_get_method); + } + #endif + return; + } + + // try __getattr__ + if (attr != MP_QSTR___getattr__) { + #if MICROPY_PY_DELATTR_SETATTR + // If the requested attr is __setattr__/__delattr__ then don't delegate the lookup + // to __getattr__. If we followed CPython's behaviour then __setattr__/__delattr__ + // would have already been found in the "object" base class. + if (attr == MP_QSTR___setattr__ || attr == MP_QSTR___delattr__) { + return; + } + #endif + + mp_obj_t dest2[3]; + mp_load_method_maybe(self_in, MP_QSTR___getattr__, dest2); + if (dest2[0] != MP_OBJ_NULL) { + // __getattr__ exists, call it and return its result + // XXX if this fails to load the requested attr, should we catch the attribute error and return silently? + dest2[2] = MP_OBJ_NEW_QSTR(attr); + dest[0] = mp_call_method_n_kw(1, 0, dest2); + return; + } + } +} + +STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + + #if MICROPY_PY_BUILTINS_PROPERTY || MICROPY_PY_DESCRIPTORS + // With property and/or descriptors enabled we need to do a lookup + // first in the class dict for the attribute to see if the store should + // be delegated. + // Note: this makes all stores slow... how to fix? + mp_obj_t member[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = self, + .attr = attr, + .meth_offset = 0, + .dest = member, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + + if (member[0] != MP_OBJ_NULL) { + #if MICROPY_PY_BUILTINS_PROPERTY + if (MP_OBJ_IS_TYPE(member[0], &mp_type_property)) { + // attribute exists and is a property; delegate the store/delete + // Note: This is an optimisation for code size and execution time. + // The proper way to do it is have the functionality just below in + // a __set__/__delete__ method of the property object, and then it + // would be called by the descriptor code down below. But that way + // requires overhead for the nested mp_call's and overhead for + // the code. + const mp_obj_t *proxy = mp_obj_property_get(member[0]); + mp_obj_t dest[2] = {self_in, value}; + if (value == MP_OBJ_NULL) { + // delete attribute + if (proxy[2] == mp_const_none) { + // TODO better error message? + return false; + } else { + mp_call_function_n_kw(proxy[2], 1, 0, dest); + return true; + } + } else { + // store attribute + if (proxy[1] == mp_const_none) { + // TODO better error message? + return false; + } else { + mp_call_function_n_kw(proxy[1], 2, 0, dest); + return true; + } + } + } + #endif + + #if MICROPY_PY_DESCRIPTORS + // found a class attribute; if it has a __set__/__delete__ method then + // call it with the class instance (and value) as arguments + if (value == MP_OBJ_NULL) { + // delete attribute + mp_obj_t attr_delete_method[3]; + mp_load_method_maybe(member[0], MP_QSTR___delete__, attr_delete_method); + if (attr_delete_method[0] != MP_OBJ_NULL) { + attr_delete_method[2] = self_in; + mp_call_method_n_kw(1, 0, attr_delete_method); + return true; + } + } else { + // store attribute + mp_obj_t attr_set_method[4]; + mp_load_method_maybe(member[0], MP_QSTR___set__, attr_set_method); + if (attr_set_method[0] != MP_OBJ_NULL) { + attr_set_method[2] = self_in; + attr_set_method[3] = value; + mp_call_method_n_kw(2, 0, attr_set_method); + return true; + } + } + #endif + } + #endif + + if (value == MP_OBJ_NULL) { + // delete attribute + #if MICROPY_PY_DELATTR_SETATTR + // try __delattr__ first + mp_obj_t attr_delattr_method[3]; + mp_load_method_maybe(self_in, MP_QSTR___delattr__, attr_delattr_method); + if (attr_delattr_method[0] != MP_OBJ_NULL) { + // __delattr__ exists, so call it + attr_delattr_method[2] = MP_OBJ_NEW_QSTR(attr); + mp_call_method_n_kw(1, 0, attr_delattr_method); + return true; + } + #endif + + mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_REMOVE_IF_FOUND); + return elem != NULL; + } else { + // store attribute + #if MICROPY_PY_DELATTR_SETATTR + // try __setattr__ first + mp_obj_t attr_setattr_method[4]; + mp_load_method_maybe(self_in, MP_QSTR___setattr__, attr_setattr_method); + if (attr_setattr_method[0] != MP_OBJ_NULL) { + // __setattr__ exists, so call it + attr_setattr_method[2] = MP_OBJ_NEW_QSTR(attr); + attr_setattr_method[3] = value; + mp_call_method_n_kw(2, 0, attr_setattr_method); + return true; + } + #endif + + mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; + return true; + } +} + +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] == MP_OBJ_NULL) { + mp_obj_instance_load_attr(self_in, attr, dest); + } else { + if (mp_obj_instance_store_attr(self_in, attr, dest[1])) { + dest[0] = MP_OBJ_NULL; // indicate success + } + } +} + +STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t member[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = self, + .meth_offset = offsetof(mp_obj_type_t, subscr), + .dest = member, + .is_type = false, + }; + size_t meth_args; + if (value == MP_OBJ_NULL) { + // delete item + lookup.attr = MP_QSTR___delitem__; + mp_obj_class_lookup(&lookup, self->base.type); + meth_args = 2; + } else if (value == MP_OBJ_SENTINEL) { + // load item + lookup.attr = MP_QSTR___getitem__; + mp_obj_class_lookup(&lookup, self->base.type); + meth_args = 2; + } else { + // store item + lookup.attr = MP_QSTR___setitem__; + mp_obj_class_lookup(&lookup, self->base.type); + meth_args = 3; + } + if (member[0] == MP_OBJ_SENTINEL) { + return mp_obj_subscr(self->subobj[0], index, value); + } else if (member[0] != MP_OBJ_NULL) { + mp_obj_t args[3] = {self_in, index, value}; + // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw + mp_obj_t ret = mp_call_function_n_kw(member[0], meth_args, 0, args); + if (value == MP_OBJ_SENTINEL) { + return ret; + } else { + return mp_const_none; + } + } else { + return MP_OBJ_NULL; // op not supported + } +} + +STATIC mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + struct class_lookup_data lookup = { + .obj = self, + .attr = MP_QSTR___call__, + .meth_offset = offsetof(mp_obj_type_t, call), + .dest = member, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + return member[0]; +} + +bool mp_obj_instance_is_callable(mp_obj_t self_in) { + mp_obj_t member[2] = {MP_OBJ_NULL, MP_OBJ_NULL}; + return mp_obj_instance_get_call(self_in, member) != MP_OBJ_NULL; +} + +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_t member[2] = {MP_OBJ_NULL, MP_OBJ_NULL}; + mp_obj_t call = mp_obj_instance_get_call(self_in, member); + if (call == MP_OBJ_NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object not callable"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not callable", mp_obj_get_type_str(self_in))); + } + } + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + if (call == MP_OBJ_SENTINEL) { + return mp_call_function_n_kw(self->subobj[0], n_args, n_kw, args); + } + + return mp_call_method_self_n_kw(member[0], member[1], n_args, n_kw, args); +} + +STATIC mp_obj_t instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t member[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = self, + .attr = MP_QSTR___iter__, + .meth_offset = offsetof(mp_obj_type_t, getiter), + .dest = member, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == MP_OBJ_NULL) { + return MP_OBJ_NULL; + } else if (member[0] == MP_OBJ_SENTINEL) { + mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); + return type->getiter(self->subobj[0], iter_buf); + } else { + return mp_call_method_n_kw(0, 0, member); + } +} + +STATIC mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t member[2] = {MP_OBJ_NULL}; + struct class_lookup_data lookup = { + .obj = self, + .attr = MP_QSTR_, // don't actually look for a method + .meth_offset = offsetof(mp_obj_type_t, buffer_p.get_buffer), + .dest = member, + .is_type = false, + }; + mp_obj_class_lookup(&lookup, self->base.type); + if (member[0] == MP_OBJ_SENTINEL) { + mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); + return type->buffer_p.get_buffer(self->subobj[0], bufinfo, flags); + } else { + return 1; // object does not support buffer protocol + } +} + +/******************************************************************************/ +// type object +// - the struct is mp_obj_type_t and is defined in obj.h so const types can be made +// - there is a constant mp_obj_type_t (called mp_type_type) for the 'type' object +// - creating a new class (a new type) creates a new mp_obj_type_t + +STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "", self->name); +} + +STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + + mp_arg_check_num(n_args, n_kw, 1, 3, false); + + switch (n_args) { + case 1: + return MP_OBJ_FROM_PTR(mp_obj_get_type(args[0])); + + case 3: + // args[0] = name + // args[1] = bases tuple + // args[2] = locals dict + return mp_obj_new_type(mp_obj_str_get_qstr(args[0]), args[1], args[2]); + + default: + mp_raise_TypeError("type takes 1 or 3 arguments"); + } +} + +STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + // instantiate an instance of a class + + mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->make_new == NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("cannot create instance"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "cannot create '%q' instances", self->name)); + } + } + + // make new instance + mp_obj_t o = self->make_new(self, n_args, n_kw, args); + + // return new instance + return o; +} + +STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_type)); + mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); + + if (dest[0] == MP_OBJ_NULL) { + // load attribute + #if MICROPY_CPYTHON_COMPAT + if (attr == MP_QSTR___name__) { + dest[0] = MP_OBJ_NEW_QSTR(self->name); + return; + } + #endif + struct class_lookup_data lookup = { + .obj = (mp_obj_instance_t*)self, + .attr = attr, + .meth_offset = 0, + .dest = dest, + .is_type = true, + }; + mp_obj_class_lookup(&lookup, self); + } else { + // delete/store attribute + + // TODO CPython allows STORE_ATTR to a class, but is this the correct implementation? + + if (self->locals_dict != NULL) { + assert(self->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now + mp_map_t *locals_map = &self->locals_dict->map; + if (dest[1] == MP_OBJ_NULL) { + // delete attribute + mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_REMOVE_IF_FOUND); + // note that locals_map may be in ROM, so remove will fail in that case + if (elem != NULL) { + dest[0] = MP_OBJ_NULL; // indicate success + } + } else { + // store attribute + mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + // note that locals_map may be in ROM, so add will fail in that case + if (elem != NULL) { + elem->value = dest[1]; + dest[0] = MP_OBJ_NULL; // indicate success + } + } + } + } +} + +const mp_obj_type_t mp_type_type = { + { &mp_type_type }, + .name = MP_QSTR_type, + .print = type_print, + .make_new = type_make_new, + .call = type_call, + .unary_op = mp_generic_unary_op, + .attr = type_attr, +}; + +mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) { + assert(MP_OBJ_IS_TYPE(bases_tuple, &mp_type_tuple)); // MicroPython restriction, for now + assert(MP_OBJ_IS_TYPE(locals_dict, &mp_type_dict)); // MicroPython restriction, for now + + // TODO might need to make a copy of locals_dict; at least that's how CPython does it + + // Basic validation of base classes + size_t len; + mp_obj_t *items; + mp_obj_tuple_get(bases_tuple, &len, &items); + for (size_t i = 0; i < len; i++) { + assert(MP_OBJ_IS_TYPE(items[i], &mp_type_type)); + mp_obj_type_t *t = MP_OBJ_TO_PTR(items[i]); + // TODO: Verify with CPy, tested on function type + if (t->make_new == NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("type is not an acceptable base type"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "type '%q' is not an acceptable base type", t->name)); + } + } + } + + mp_obj_type_t *o = m_new0(mp_obj_type_t, 1); + o->base.type = &mp_type_type; + o->name = name; + o->print = instance_print; + o->make_new = mp_obj_instance_make_new; + o->call = mp_obj_instance_call; + o->unary_op = instance_unary_op; + o->binary_op = instance_binary_op; + o->attr = mp_obj_instance_attr; + o->subscr = instance_subscr; + o->getiter = instance_getiter; + //o->iternext = ; not implemented + o->buffer_p.get_buffer = instance_get_buffer; + + if (len > 0) { + // Inherit protocol from a base class. This allows to define an + // abstract base class which would translate C-level protocol to + // Python method calls, and any subclass inheriting from it will + // support this feature. + o->protocol = ((mp_obj_type_t*)MP_OBJ_TO_PTR(items[0]))->protocol; + + if (len >= 2) { + o->parent = MP_OBJ_TO_PTR(bases_tuple); + } else { + o->parent = MP_OBJ_TO_PTR(items[0]); + } + } + + o->locals_dict = MP_OBJ_TO_PTR(locals_dict); + + const mp_obj_type_t *native_base; + size_t num_native_bases = instance_count_native_bases(o, &native_base); + if (num_native_bases > 1) { + mp_raise_TypeError("multiple bases have instance lay-out conflict"); + } + + mp_map_t *locals_map = &o->locals_dict->map; + mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(MP_QSTR___new__), MP_MAP_LOOKUP); + if (elem != NULL) { + // __new__ slot exists; check if it is a function + if (MP_OBJ_IS_FUN(elem->value)) { + // __new__ is a function, wrap it in a staticmethod decorator + elem->value = static_class_method_make_new(&mp_type_staticmethod, 1, 0, &elem->value); + } + } + + return MP_OBJ_FROM_PTR(o); +} + +/******************************************************************************/ +// super object + +typedef struct _mp_obj_super_t { + mp_obj_base_t base; + mp_obj_t type; + mp_obj_t obj; +} mp_obj_super_t; + +STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)kind; + mp_obj_super_t *self = MP_OBJ_TO_PTR(self_in); + mp_print_str(print, "type, PRINT_STR); + mp_print_str(print, ", "); + mp_obj_print_helper(print, self->obj, PRINT_STR); + mp_print_str(print, ">"); +} + +STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + (void)type_in; + // 0 arguments are turned into 2 in the compiler + // 1 argument is not yet implemented + mp_arg_check_num(n_args, n_kw, 2, 2, false); + mp_obj_super_t *o = m_new_obj(mp_obj_super_t); + *o = (mp_obj_super_t){{type_in}, args[0], args[1]}; + return MP_OBJ_FROM_PTR(o); +} + +STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + if (dest[0] != MP_OBJ_NULL) { + // not load attribute + return; + } + + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_super)); + mp_obj_super_t *self = MP_OBJ_TO_PTR(self_in); + + assert(MP_OBJ_IS_TYPE(self->type, &mp_type_type)); + + mp_obj_type_t *type = MP_OBJ_TO_PTR(self->type); + + struct class_lookup_data lookup = { + .obj = MP_OBJ_TO_PTR(self->obj), + .attr = attr, + .meth_offset = 0, + .dest = dest, + .is_type = false, + }; + + if (type->parent == NULL) { + // no parents, do nothing + } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { + const mp_obj_tuple_t *parent_tuple = type->parent; + size_t len = parent_tuple->len; + const mp_obj_t *items = parent_tuple->items; + for (size_t i = 0; i < len; i++) { + assert(MP_OBJ_IS_TYPE(items[i], &mp_type_type)); + mp_obj_class_lookup(&lookup, (mp_obj_type_t*)MP_OBJ_TO_PTR(items[i])); + if (dest[0] != MP_OBJ_NULL) { + return; + } + } + } else { + mp_obj_class_lookup(&lookup, type->parent); + if (dest[0] != MP_OBJ_NULL) { + return; + } + } + + mp_obj_class_lookup(&lookup, &mp_type_object); +} + +const mp_obj_type_t mp_type_super = { + { &mp_type_type }, + .name = MP_QSTR_super, + .print = super_print, + .make_new = super_make_new, + .attr = super_attr, +}; + +void mp_load_super_method(qstr attr, mp_obj_t *dest) { + mp_obj_super_t super = {{&mp_type_super}, dest[1], dest[2]}; + mp_load_method(MP_OBJ_FROM_PTR(&super), attr, dest); +} + +/******************************************************************************/ +// subclassing and built-ins specific to types + +// object and classinfo should be type objects +// (but the function will fail gracefully if they are not) +bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) { + for (;;) { + if (object == classinfo) { + return true; + } + + // not equivalent classes, keep searching base classes + + // object should always be a type object, but just return false if it's not + if (!MP_OBJ_IS_TYPE(object, &mp_type_type)) { + return false; + } + + const mp_obj_type_t *self = MP_OBJ_TO_PTR(object); + + if (self->parent == NULL) { + // type has no parents + return false; + } else if (((mp_obj_base_t*)self->parent)->type == &mp_type_tuple) { + // get the base objects (they should be type objects) + const mp_obj_tuple_t *parent_tuple = self->parent; + const mp_obj_t *item = parent_tuple->items; + const mp_obj_t *top = item + parent_tuple->len - 1; + + // iterate through the base objects + for (; item < top; ++item) { + if (mp_obj_is_subclass_fast(*item, classinfo)) { + return true; + } + } + + // search last base (simple tail recursion elimination) + object = *item; + } else { + // type has 1 parent + object = MP_OBJ_FROM_PTR(self->parent); + } + } +} + +STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) { + size_t len; + mp_obj_t *items; + if (MP_OBJ_IS_TYPE(classinfo, &mp_type_type)) { + len = 1; + items = &classinfo; + } else if (MP_OBJ_IS_TYPE(classinfo, &mp_type_tuple)) { + mp_obj_tuple_get(classinfo, &len, &items); + } else { + mp_raise_TypeError("issubclass() arg 2 must be a class or a tuple of classes"); + } + + for (size_t i = 0; i < len; i++) { + // We explicitly check for 'object' here since no-one explicitly derives from it + if (items[i] == MP_OBJ_FROM_PTR(&mp_type_object) || mp_obj_is_subclass_fast(object, items[i])) { + return mp_const_true; + } + } + return mp_const_false; +} + +STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) { + if (!MP_OBJ_IS_TYPE(object, &mp_type_type)) { + mp_raise_TypeError("issubclass() arg 1 must be a class"); + } + return mp_obj_is_subclass(object, classinfo); +} + +MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj, mp_builtin_issubclass); + +STATIC mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) { + return mp_obj_is_subclass(MP_OBJ_FROM_PTR(mp_obj_get_type(object)), classinfo); +} + +MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_isinstance_obj, mp_builtin_isinstance); + +mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t native_type) { + mp_obj_type_t *self_type = mp_obj_get_type(self_in); + if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(self_type), native_type)) { + return MP_OBJ_NULL; + } + mp_obj_instance_t *self = (mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in); + return self->subobj[0]; +} + +/******************************************************************************/ +// staticmethod and classmethod types (probably should go in a different file) + +STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { + assert(self == &mp_type_staticmethod || self == &mp_type_classmethod); + + mp_arg_check_num(n_args, n_kw, 1, 1, false); + + mp_obj_static_class_method_t *o = m_new_obj(mp_obj_static_class_method_t); + *o = (mp_obj_static_class_method_t){{self}, args[0]}; + return MP_OBJ_FROM_PTR(o); +} + +const mp_obj_type_t mp_type_staticmethod = { + { &mp_type_type }, + .name = MP_QSTR_staticmethod, + .make_new = static_class_method_make_new, +}; + +const mp_obj_type_t mp_type_classmethod = { + { &mp_type_type }, + .name = MP_QSTR_classmethod, + .make_new = static_class_method_make_new, +}; diff --git a/user/mpy/py/objtype.h b/user/mpy/py/objtype.h new file mode 100644 index 0000000..52419f3 --- /dev/null +++ b/user/mpy/py/objtype.h @@ -0,0 +1,52 @@ +/* + * 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_OBJTYPE_H +#define MICROPY_INCLUDED_PY_OBJTYPE_H + +#include "py/obj.h" + +// instance object +// creating an instance of a class makes one of these objects +typedef struct _mp_obj_instance_t { + mp_obj_base_t base; + mp_map_t members; + mp_obj_t subobj[]; + // TODO maybe cache __getattr__ and __setattr__ for efficient lookup of them +} mp_obj_instance_t; + +// this needs to be exposed for MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE to work +void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + +// these need to be exposed so mp_obj_is_callable can work correctly +bool mp_obj_instance_is_callable(mp_obj_t self_in); +mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + +#define mp_obj_is_instance_type(type) ((type)->make_new == mp_obj_instance_make_new) +#define mp_obj_is_native_type(type) ((type)->make_new != mp_obj_instance_make_new) +// this needs to be exposed for the above macros to work correctly +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); + +#endif // MICROPY_INCLUDED_PY_OBJTYPE_H diff --git a/user/mpy/py/objzip.c b/user/mpy/py/objzip.c new file mode 100644 index 0000000..0183925 --- /dev/null +++ b/user/mpy/py/objzip.c @@ -0,0 +1,76 @@ +/* + * 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. + */ + +#include +#include + +#include "py/objtuple.h" +#include "py/runtime.h" + +typedef struct _mp_obj_zip_t { + mp_obj_base_t base; + size_t n_iters; + mp_obj_t iters[]; +} mp_obj_zip_t; + +STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); + + mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args); + o->base.type = type; + o->n_iters = n_args; + for (size_t i = 0; i < n_args; i++) { + o->iters[i] = mp_getiter(args[i], NULL); + } + return MP_OBJ_FROM_PTR(o); +} + +STATIC mp_obj_t zip_iternext(mp_obj_t self_in) { + mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_zip)); + mp_obj_zip_t *self = MP_OBJ_TO_PTR(self_in); + if (self->n_iters == 0) { + return MP_OBJ_STOP_ITERATION; + } + mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(self->n_iters, NULL)); + + for (size_t i = 0; i < self->n_iters; i++) { + mp_obj_t next = mp_iternext(self->iters[i]); + if (next == MP_OBJ_STOP_ITERATION) { + mp_obj_tuple_del(MP_OBJ_FROM_PTR(tuple)); + return MP_OBJ_STOP_ITERATION; + } + tuple->items[i] = next; + } + return MP_OBJ_FROM_PTR(tuple); +} + +const mp_obj_type_t mp_type_zip = { + { &mp_type_type }, + .name = MP_QSTR_zip, + .make_new = zip_make_new, + .getiter = mp_identity_getiter, + .iternext = zip_iternext, +}; diff --git a/user/mpy/py/opmethods.c b/user/mpy/py/opmethods.c new file mode 100644 index 0000000..1200ba3 --- /dev/null +++ b/user/mpy/py/opmethods.c @@ -0,0 +1,52 @@ +/* + * 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. + */ + +#include "py/runtime0.h" +#include "py/builtin.h" + +STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); + +STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + return type->subscr(self_in, key_in, value_in); +} +MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); + +STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + return type->subscr(self_in, key_in, MP_OBJ_NULL); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); + +STATIC mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) { + mp_obj_type_t *type = mp_obj_get_type(lhs_in); + return type->binary_op(MP_BINARY_OP_IN, lhs_in, rhs_in); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_op_contains_obj, op_contains); diff --git a/user/mpy/py/parse.c b/user/mpy/py/parse.c new file mode 100644 index 0000000..e399aac --- /dev/null +++ b/user/mpy/py/parse.c @@ -0,0 +1,1084 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2015 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. + */ + +#include +#include +#include +#include // for ssize_t +#include +#include + +#include "py/nlr.h" +#include "py/lexer.h" +#include "py/parse.h" +#include "py/parsenum.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/objint.h" +#include "py/objstr.h" +#include "py/builtin.h" + +#if MICROPY_ENABLE_COMPILER + +#define RULE_ACT_ARG_MASK (0x0f) +#define RULE_ACT_KIND_MASK (0x30) +#define RULE_ACT_ALLOW_IDENT (0x40) +#define RULE_ACT_ADD_BLANK (0x80) +#define RULE_ACT_OR (0x10) +#define RULE_ACT_AND (0x20) +#define RULE_ACT_LIST (0x30) + +#define RULE_ARG_KIND_MASK (0xf000) +#define RULE_ARG_ARG_MASK (0x0fff) +#define RULE_ARG_TOK (0x1000) +#define RULE_ARG_RULE (0x2000) +#define RULE_ARG_OPT_RULE (0x3000) + +// (un)comment to use rule names; for debugging +//#define USE_RULE_NAME (1) + +typedef struct _rule_t { + byte rule_id; + byte act; +#ifdef USE_RULE_NAME + const char *rule_name; +#endif + uint16_t arg[]; +} rule_t; + +enum { +// define rules with a compile function +#define DEF_RULE(rule, comp, kind, ...) RULE_##rule, +#define DEF_RULE_NC(rule, kind, ...) +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC + RULE_const_object, // special node for a constant, generic Python object + +// define rules without a compile function +#define DEF_RULE(rule, comp, kind, ...) +#define DEF_RULE_NC(rule, kind, ...) RULE_##rule, +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC +}; + +#define or(n) (RULE_ACT_OR | n) +#define and(n) (RULE_ACT_AND | n) +#define and_ident(n) (RULE_ACT_AND | n | RULE_ACT_ALLOW_IDENT) +#define and_blank(n) (RULE_ACT_AND | n | RULE_ACT_ADD_BLANK) +#define one_or_more (RULE_ACT_LIST | 2) +#define list (RULE_ACT_LIST | 1) +#define list_with_end (RULE_ACT_LIST | 3) +#define tok(t) (RULE_ARG_TOK | MP_TOKEN_##t) +#define rule(r) (RULE_ARG_RULE | RULE_##r) +#define opt_rule(r) (RULE_ARG_OPT_RULE | RULE_##r) +#ifdef USE_RULE_NAME +#define DEF_RULE(rule, comp, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, #rule, { __VA_ARGS__ } }; +#define DEF_RULE_NC(rule, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, #rule, { __VA_ARGS__ } }; +#else +#define DEF_RULE(rule, comp, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, { __VA_ARGS__ } }; +#define DEF_RULE_NC(rule, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, { __VA_ARGS__ } }; +#endif +#include "py/grammar.h" +#undef or +#undef and +#undef list +#undef list_with_end +#undef tok +#undef rule +#undef opt_rule +#undef one_or_more +#undef DEF_RULE +#undef DEF_RULE_NC + +STATIC const rule_t *const rules[] = { +// define rules with a compile function +#define DEF_RULE(rule, comp, kind, ...) &rule_##rule, +#define DEF_RULE_NC(rule, kind, ...) +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC + NULL, // RULE_const_object + +// define rules without a compile function +#define DEF_RULE(rule, comp, kind, ...) +#define DEF_RULE_NC(rule, kind, ...) &rule_##rule, +#include "py/grammar.h" +#undef DEF_RULE +#undef DEF_RULE_NC +}; + +typedef struct _rule_stack_t { + size_t src_line : 8 * sizeof(size_t) - 8; // maximum bits storing source line number + size_t rule_id : 8; // this must be large enough to fit largest rule number + size_t arg_i; // this dictates the maximum nodes in a "list" of things +} rule_stack_t; + +typedef struct _mp_parse_chunk_t { + size_t alloc; + union { + size_t used; + struct _mp_parse_chunk_t *next; + } union_; + byte data[]; +} mp_parse_chunk_t; + +typedef struct _parser_t { + size_t rule_stack_alloc; + size_t rule_stack_top; + rule_stack_t *rule_stack; + + size_t result_stack_alloc; + size_t result_stack_top; + mp_parse_node_t *result_stack; + + mp_lexer_t *lexer; + + mp_parse_tree_t tree; + mp_parse_chunk_t *cur_chunk; + + #if MICROPY_COMP_CONST + mp_map_t consts; + #endif +} parser_t; + +STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) { + // use a custom memory allocator to store parse nodes sequentially in large chunks + + mp_parse_chunk_t *chunk = parser->cur_chunk; + + if (chunk != NULL && chunk->union_.used + num_bytes > chunk->alloc) { + // not enough room at end of previously allocated chunk so try to grow + mp_parse_chunk_t *new_data = (mp_parse_chunk_t*)m_renew_maybe(byte, chunk, + sizeof(mp_parse_chunk_t) + chunk->alloc, + sizeof(mp_parse_chunk_t) + chunk->alloc + num_bytes, false); + if (new_data == NULL) { + // could not grow existing memory; shrink it to fit previous + (void)m_renew_maybe(byte, chunk, sizeof(mp_parse_chunk_t) + chunk->alloc, + sizeof(mp_parse_chunk_t) + chunk->union_.used, false); + chunk->alloc = chunk->union_.used; + chunk->union_.next = parser->tree.chunk; + parser->tree.chunk = chunk; + chunk = NULL; + } else { + // could grow existing memory + chunk->alloc += num_bytes; + } + } + + if (chunk == NULL) { + // no previous chunk, allocate a new chunk + size_t alloc = MICROPY_ALLOC_PARSE_CHUNK_INIT; + if (alloc < num_bytes) { + alloc = num_bytes; + } + chunk = (mp_parse_chunk_t*)m_new(byte, sizeof(mp_parse_chunk_t) + alloc); + chunk->alloc = alloc; + chunk->union_.used = 0; + parser->cur_chunk = chunk; + } + + byte *ret = chunk->data + chunk->union_.used; + chunk->union_.used += num_bytes; + return ret; +} + +STATIC void push_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t arg_i) { + if (parser->rule_stack_top >= parser->rule_stack_alloc) { + rule_stack_t *rs = m_renew(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC); + parser->rule_stack = rs; + parser->rule_stack_alloc += MICROPY_ALLOC_PARSE_RULE_INC; + } + rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++]; + rs->src_line = src_line; + rs->rule_id = rule->rule_id; + rs->arg_i = arg_i; +} + +STATIC void push_rule_from_arg(parser_t *parser, size_t arg) { + assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE); + size_t rule_id = arg & RULE_ARG_ARG_MASK; + push_rule(parser, parser->lexer->tok_line, rules[rule_id], 0); +} + +STATIC void pop_rule(parser_t *parser, const rule_t **rule, size_t *arg_i, size_t *src_line) { + parser->rule_stack_top -= 1; + *rule = rules[parser->rule_stack[parser->rule_stack_top].rule_id]; + *arg_i = parser->rule_stack[parser->rule_stack_top].arg_i; + *src_line = parser->rule_stack[parser->rule_stack_top].src_line; +} + +bool mp_parse_node_is_const_false(mp_parse_node_t pn) { + return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_FALSE) + || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) == 0); +} + +bool mp_parse_node_is_const_true(mp_parse_node_t pn) { + return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_TRUE) + || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) != 0); +} + +bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) { + if (MP_PARSE_NODE_IS_SMALL_INT(pn)) { + *o = MP_OBJ_NEW_SMALL_INT(MP_PARSE_NODE_LEAF_SMALL_INT(pn)); + return true; + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_const_object)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + // nodes are 32-bit pointers, but need to extract 64-bit object + *o = (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32); + #else + *o = (mp_obj_t)pns->nodes[0]; + #endif + return MP_OBJ_IS_INT(*o); + } else { + return false; + } +} + +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes) { + if (MP_PARSE_NODE_IS_NULL(*pn)) { + *nodes = NULL; + return 0; + } else if (MP_PARSE_NODE_IS_LEAF(*pn)) { + *nodes = pn; + return 1; + } else { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)(*pn); + if (MP_PARSE_NODE_STRUCT_KIND(pns) != pn_kind) { + *nodes = pn; + return 1; + } else { + *nodes = pns->nodes; + return MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + } + } +} + +#if MICROPY_DEBUG_PRINTERS +void mp_parse_node_print(mp_parse_node_t pn, size_t indent) { + if (MP_PARSE_NODE_IS_STRUCT(pn)) { + printf("[% 4d] ", (int)((mp_parse_node_struct_t*)pn)->source_line); + } else { + printf(" "); + } + for (size_t i = 0; i < indent; i++) { + printf(" "); + } + if (MP_PARSE_NODE_IS_NULL(pn)) { + printf("NULL\n"); + } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) { + mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn); + printf("int(" INT_FMT ")\n", arg); + } else if (MP_PARSE_NODE_IS_LEAF(pn)) { + uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn); + switch (MP_PARSE_NODE_LEAF_KIND(pn)) { + case MP_PARSE_NODE_ID: printf("id(%s)\n", qstr_str(arg)); break; + case MP_PARSE_NODE_STRING: printf("str(%s)\n", qstr_str(arg)); break; + case MP_PARSE_NODE_BYTES: printf("bytes(%s)\n", qstr_str(arg)); break; + default: + assert(MP_PARSE_NODE_LEAF_KIND(pn) == MP_PARSE_NODE_TOKEN); + printf("tok(%u)\n", (uint)arg); break; + } + } else { + // node must be a mp_parse_node_struct_t + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_const_object) { + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + printf("literal const(%016llx)\n", (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32)); + #else + printf("literal const(%p)\n", (mp_obj_t)pns->nodes[0]); + #endif + } else { + size_t n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); +#ifdef USE_RULE_NAME + printf("%s(%u) (n=%u)\n", rules[MP_PARSE_NODE_STRUCT_KIND(pns)]->rule_name, (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n); +#else + printf("rule(%u) (n=%u)\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n); +#endif + for (size_t i = 0; i < n; i++) { + mp_parse_node_print(pns->nodes[i], indent + 2); + } + } + } +} +#endif // MICROPY_DEBUG_PRINTERS + +/* +STATIC void result_stack_show(parser_t *parser) { + printf("result stack, most recent first\n"); + for (ssize_t i = parser->result_stack_top - 1; i >= 0; i--) { + mp_parse_node_print(parser->result_stack[i], 0); + } +} +*/ + +STATIC mp_parse_node_t pop_result(parser_t *parser) { + assert(parser->result_stack_top > 0); + return parser->result_stack[--parser->result_stack_top]; +} + +STATIC mp_parse_node_t peek_result(parser_t *parser, size_t pos) { + assert(parser->result_stack_top > pos); + return parser->result_stack[parser->result_stack_top - 1 - pos]; +} + +STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) { + if (parser->result_stack_top >= parser->result_stack_alloc) { + mp_parse_node_t *stack = m_renew(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC); + parser->result_stack = stack; + parser->result_stack_alloc += MICROPY_ALLOC_PARSE_RESULT_INC; + } + parser->result_stack[parser->result_stack_top++] = pn; +} + +STATIC mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) { + mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_obj_t)); + pn->source_line = src_line; + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + // nodes are 32-bit pointers, but need to store 64-bit object + pn->kind_num_nodes = RULE_const_object | (2 << 8); + pn->nodes[0] = (uint64_t)obj; + pn->nodes[1] = (uint64_t)obj >> 32; + #else + pn->kind_num_nodes = RULE_const_object | (1 << 8); + pn->nodes[0] = (uintptr_t)obj; + #endif + return (mp_parse_node_t)pn; +} + +STATIC void push_result_token(parser_t *parser, const rule_t *rule) { + mp_parse_node_t pn; + mp_lexer_t *lex = parser->lexer; + if (lex->tok_kind == MP_TOKEN_NAME) { + qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len); + #if MICROPY_COMP_CONST + // if name is a standalone identifier, look it up in the table of dynamic constants + mp_map_elem_t *elem; + if (rule->rule_id == RULE_atom + && (elem = mp_map_lookup(&parser->consts, MP_OBJ_NEW_QSTR(id), MP_MAP_LOOKUP)) != NULL) { + if (MP_OBJ_IS_SMALL_INT(elem->value)) { + pn = mp_parse_node_new_small_int(MP_OBJ_SMALL_INT_VALUE(elem->value)); + } else { + pn = make_node_const_object(parser, lex->tok_line, elem->value); + } + } else { + pn = mp_parse_node_new_leaf(MP_PARSE_NODE_ID, id); + } + #else + (void)rule; + pn = mp_parse_node_new_leaf(MP_PARSE_NODE_ID, id); + #endif + } else if (lex->tok_kind == MP_TOKEN_INTEGER) { + mp_obj_t o = mp_parse_num_integer(lex->vstr.buf, lex->vstr.len, 0, lex); + if (MP_OBJ_IS_SMALL_INT(o)) { + pn = mp_parse_node_new_small_int(MP_OBJ_SMALL_INT_VALUE(o)); + } else { + pn = make_node_const_object(parser, lex->tok_line, o); + } + } else if (lex->tok_kind == MP_TOKEN_FLOAT_OR_IMAG) { + mp_obj_t o = mp_parse_num_decimal(lex->vstr.buf, lex->vstr.len, true, false, lex); + pn = make_node_const_object(parser, lex->tok_line, o); + } else if (lex->tok_kind == MP_TOKEN_STRING || lex->tok_kind == MP_TOKEN_BYTES) { + // Don't automatically intern all strings/bytes. doc strings (which are usually large) + // will be discarded by the compiler, and so we shouldn't intern them. + qstr qst = MP_QSTR_NULL; + if (lex->vstr.len <= MICROPY_ALLOC_PARSE_INTERN_STRING_LEN) { + // intern short strings + qst = qstr_from_strn(lex->vstr.buf, lex->vstr.len); + } else { + // check if this string is already interned + qst = qstr_find_strn(lex->vstr.buf, lex->vstr.len); + } + if (qst != MP_QSTR_NULL) { + // qstr exists, make a leaf node + pn = mp_parse_node_new_leaf(lex->tok_kind == MP_TOKEN_STRING ? MP_PARSE_NODE_STRING : MP_PARSE_NODE_BYTES, qst); + } else { + // not interned, make a node holding a pointer to the string/bytes object + mp_obj_t o = mp_obj_new_str_of_type( + lex->tok_kind == MP_TOKEN_STRING ? &mp_type_str : &mp_type_bytes, + (const byte*)lex->vstr.buf, lex->vstr.len); + pn = make_node_const_object(parser, lex->tok_line, o); + } + } else { + pn = mp_parse_node_new_leaf(MP_PARSE_NODE_TOKEN, lex->tok_kind); + } + push_result_node(parser, pn); +} + +#if MICROPY_COMP_MODULE_CONST +STATIC const mp_rom_map_elem_t mp_constants_table[] = { + #if MICROPY_PY_UERRNO + { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, + #endif + #if MICROPY_PY_UCTYPES + { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, + #endif + // Extra constants as defined by a port + MICROPY_PORT_CONSTANTS +}; +STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table); +#endif + +STATIC void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args); + +#if MICROPY_COMP_CONST_FOLDING +STATIC bool fold_logical_constants(parser_t *parser, const rule_t *rule, size_t *num_args) { + if (rule->rule_id == RULE_or_test + || rule->rule_id == RULE_and_test) { + // folding for binary logical ops: or and + size_t copy_to = *num_args; + for (size_t i = copy_to; i > 0;) { + mp_parse_node_t pn = peek_result(parser, --i); + parser->result_stack[parser->result_stack_top - copy_to] = pn; + if (i == 0) { + // always need to keep the last value + break; + } + if (rule->rule_id == RULE_or_test) { + if (mp_parse_node_is_const_true(pn)) { + // + break; + } else if (!mp_parse_node_is_const_false(pn)) { + copy_to -= 1; + } + } else { + // RULE_and_test + if (mp_parse_node_is_const_false(pn)) { + break; + } else if (!mp_parse_node_is_const_true(pn)) { + copy_to -= 1; + } + } + } + copy_to -= 1; // copy_to now contains number of args to pop + + // pop and discard all the short-circuited expressions + for (size_t i = 0; i < copy_to; ++i) { + pop_result(parser); + } + *num_args -= copy_to; + + // we did a complete folding if there's only 1 arg left + return *num_args == 1; + + } else if (rule->rule_id == RULE_not_test_2) { + // folding for unary logical op: not + mp_parse_node_t pn = peek_result(parser, 0); + if (mp_parse_node_is_const_false(pn)) { + pn = mp_parse_node_new_leaf(MP_PARSE_NODE_TOKEN, MP_TOKEN_KW_TRUE); + } else if (mp_parse_node_is_const_true(pn)) { + pn = mp_parse_node_new_leaf(MP_PARSE_NODE_TOKEN, MP_TOKEN_KW_FALSE); + } else { + return false; + } + pop_result(parser); + push_result_node(parser, pn); + return true; + } + + return false; +} + +STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args) { + // this code does folding of arbitrary integer expressions, eg 1 + 2 * 3 + 4 + // it does not do partial folding, eg 1 + 2 + x -> 3 + x + + mp_obj_t arg0; + if (rule->rule_id == RULE_expr + || rule->rule_id == RULE_xor_expr + || rule->rule_id == RULE_and_expr) { + // folding for binary ops: | ^ & + mp_parse_node_t pn = peek_result(parser, num_args - 1); + if (!mp_parse_node_get_int_maybe(pn, &arg0)) { + return false; + } + mp_binary_op_t op; + if (rule->rule_id == RULE_expr) { + op = MP_BINARY_OP_OR; + } else if (rule->rule_id == RULE_xor_expr) { + op = MP_BINARY_OP_XOR; + } else { + op = MP_BINARY_OP_AND; + } + for (ssize_t i = num_args - 2; i >= 0; --i) { + pn = peek_result(parser, i); + mp_obj_t arg1; + if (!mp_parse_node_get_int_maybe(pn, &arg1)) { + return false; + } + arg0 = mp_binary_op(op, arg0, arg1); + } + } else if (rule->rule_id == RULE_shift_expr + || rule->rule_id == RULE_arith_expr + || rule->rule_id == RULE_term) { + // folding for binary ops: << >> + - * / % // + mp_parse_node_t pn = peek_result(parser, num_args - 1); + if (!mp_parse_node_get_int_maybe(pn, &arg0)) { + return false; + } + for (ssize_t i = num_args - 2; i >= 1; i -= 2) { + pn = peek_result(parser, i - 1); + mp_obj_t arg1; + if (!mp_parse_node_get_int_maybe(pn, &arg1)) { + return false; + } + mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(peek_result(parser, i)); + static const uint8_t token_to_op[] = { + MP_BINARY_OP_ADD, + MP_BINARY_OP_SUBTRACT, + MP_BINARY_OP_MULTIPLY, + 255,//MP_BINARY_OP_POWER, + 255,//MP_BINARY_OP_TRUE_DIVIDE, + MP_BINARY_OP_FLOOR_DIVIDE, + MP_BINARY_OP_MODULO, + 255,//MP_BINARY_OP_LESS + MP_BINARY_OP_LSHIFT, + 255,//MP_BINARY_OP_MORE + MP_BINARY_OP_RSHIFT, + }; + mp_binary_op_t op = token_to_op[tok - MP_TOKEN_OP_PLUS]; + if (op == (mp_binary_op_t)255) { + return false; + } + int rhs_sign = mp_obj_int_sign(arg1); + if (op <= MP_BINARY_OP_RSHIFT) { + // << and >> can't have negative rhs + if (rhs_sign < 0) { + return false; + } + } else if (op >= MP_BINARY_OP_FLOOR_DIVIDE) { + // % and // can't have zero rhs + if (rhs_sign == 0) { + return false; + } + } + arg0 = mp_binary_op(op, arg0, arg1); + } + } else if (rule->rule_id == RULE_factor_2) { + // folding for unary ops: + - ~ + mp_parse_node_t pn = peek_result(parser, 0); + if (!mp_parse_node_get_int_maybe(pn, &arg0)) { + return false; + } + mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(peek_result(parser, 1)); + mp_unary_op_t op; + if (tok == MP_TOKEN_OP_PLUS) { + op = MP_UNARY_OP_POSITIVE; + } else if (tok == MP_TOKEN_OP_MINUS) { + op = MP_UNARY_OP_NEGATIVE; + } else { + assert(tok == MP_TOKEN_OP_TILDE); // should be + op = MP_UNARY_OP_INVERT; + } + arg0 = mp_unary_op(op, arg0); + + #if MICROPY_COMP_CONST + } else if (rule->rule_id == RULE_expr_stmt) { + mp_parse_node_t pn1 = peek_result(parser, 0); + if (!MP_PARSE_NODE_IS_NULL(pn1) + && !(MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_augassign) + || MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_assign_list))) { + // this node is of the form = + mp_parse_node_t pn0 = peek_result(parser, 1); + if (MP_PARSE_NODE_IS_ID(pn0) + && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_atom_expr_normal) + && MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t*)pn1)->nodes[0]) + && MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn1)->nodes[0]) == MP_QSTR_const + && MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t*)pn1)->nodes[1], RULE_trailer_paren) + ) { + // code to assign dynamic constants: id = const(value) + + // get the id + qstr id = MP_PARSE_NODE_LEAF_ARG(pn0); + + // get the value + mp_parse_node_t pn_value = ((mp_parse_node_struct_t*)((mp_parse_node_struct_t*)pn1)->nodes[1])->nodes[0]; + mp_obj_t value; + if (!mp_parse_node_get_int_maybe(pn_value, &value)) { + mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, + "constant must be an integer"); + mp_obj_exception_add_traceback(exc, parser->lexer->source_name, + ((mp_parse_node_struct_t*)pn1)->source_line, MP_QSTR_NULL); + nlr_raise(exc); + } + + // store the value in the table of dynamic constants + mp_map_elem_t *elem = mp_map_lookup(&parser->consts, MP_OBJ_NEW_QSTR(id), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); + assert(elem->value == MP_OBJ_NULL); + elem->value = value; + + // If the constant starts with an underscore then treat it as a private + // variable and don't emit any code to store the value to the id. + if (qstr_str(id)[0] == '_') { + pop_result(parser); // pop const(value) + pop_result(parser); // pop id + push_result_rule(parser, 0, rules[RULE_pass_stmt], 0); // replace with "pass" + return true; + } + + // replace const(value) with value + pop_result(parser); + push_result_node(parser, pn_value); + + // finished folding this assignment, but we still want it to be part of the tree + return false; + } + } + return false; + #endif + + #if MICROPY_COMP_MODULE_CONST + } else if (rule->rule_id == RULE_atom_expr_normal) { + mp_parse_node_t pn0 = peek_result(parser, 1); + mp_parse_node_t pn1 = peek_result(parser, 0); + if (!(MP_PARSE_NODE_IS_ID(pn0) + && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period))) { + return false; + } + // id1.id2 + // look it up in constant table, see if it can be replaced with an integer + mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pn1; + assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); + qstr q_base = MP_PARSE_NODE_LEAF_ARG(pn0); + qstr q_attr = MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0]); + mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&mp_constants_map, MP_OBJ_NEW_QSTR(q_base), MP_MAP_LOOKUP); + if (elem == NULL) { + return false; + } + mp_obj_t dest[2]; + mp_load_method_maybe(elem->value, q_attr, dest); + if (!(dest[0] != MP_OBJ_NULL && MP_OBJ_IS_INT(dest[0]) && dest[1] == MP_OBJ_NULL)) { + return false; + } + arg0 = dest[0]; + #endif + + } else { + return false; + } + + // success folding this rule + + for (size_t i = num_args; i > 0; i--) { + pop_result(parser); + } + if (MP_OBJ_IS_SMALL_INT(arg0)) { + push_result_node(parser, mp_parse_node_new_small_int(MP_OBJ_SMALL_INT_VALUE(arg0))); + } else { + // TODO reuse memory for parse node struct? + push_result_node(parser, make_node_const_object(parser, 0, arg0)); + } + + return true; +} +#endif + +STATIC void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args) { + // optimise away parenthesis around an expression if possible + if (rule->rule_id == RULE_atom_paren) { + // there should be just 1 arg for this rule + mp_parse_node_t pn = peek_result(parser, 0); + if (MP_PARSE_NODE_IS_NULL(pn)) { + // need to keep parenthesis for () + } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_testlist_comp)) { + // need to keep parenthesis for (a, b, ...) + } else { + // parenthesis around a single expression, so it's just the expression + return; + } + } + + #if MICROPY_COMP_CONST_FOLDING + if (fold_logical_constants(parser, rule, &num_args)) { + // we folded this rule so return straight away + return; + } + if (fold_constants(parser, rule, num_args)) { + // we folded this rule so return straight away + return; + } + #endif + + mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * num_args); + pn->source_line = src_line; + pn->kind_num_nodes = (rule->rule_id & 0xff) | (num_args << 8); + for (size_t i = num_args; i > 0; i--) { + pn->nodes[i - 1] = pop_result(parser); + } + push_result_node(parser, (mp_parse_node_t)pn); +} + +mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { + + // initialise parser and allocate memory for its stacks + + parser_t parser; + + parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT; + parser.rule_stack_top = 0; + parser.rule_stack = m_new(rule_stack_t, parser.rule_stack_alloc); + + parser.result_stack_alloc = MICROPY_ALLOC_PARSE_RESULT_INIT; + parser.result_stack_top = 0; + parser.result_stack = m_new(mp_parse_node_t, parser.result_stack_alloc); + + parser.lexer = lex; + + parser.tree.chunk = NULL; + parser.cur_chunk = NULL; + + #if MICROPY_COMP_CONST + mp_map_init(&parser.consts, 0); + #endif + + // work out the top-level rule to use, and push it on the stack + size_t top_level_rule; + switch (input_kind) { + case MP_PARSE_SINGLE_INPUT: top_level_rule = RULE_single_input; break; + case MP_PARSE_EVAL_INPUT: top_level_rule = RULE_eval_input; break; + default: top_level_rule = RULE_file_input; + } + push_rule(&parser, lex->tok_line, rules[top_level_rule], 0); + + // parse! + + size_t n, i; // state for the current rule + size_t rule_src_line; // source line for the first token matched by the current rule + bool backtrack = false; + const rule_t *rule = NULL; + + for (;;) { + next_rule: + if (parser.rule_stack_top == 0) { + break; + } + + pop_rule(&parser, &rule, &i, &rule_src_line); + n = rule->act & RULE_ACT_ARG_MASK; + + /* + // debugging + printf("depth=%d ", parser.rule_stack_top); + for (int j = 0; j < parser.rule_stack_top; ++j) { + printf(" "); + } + printf("%s n=%d i=%d bt=%d\n", rule->rule_name, n, i, backtrack); + */ + + switch (rule->act & RULE_ACT_KIND_MASK) { + case RULE_ACT_OR: + if (i > 0 && !backtrack) { + goto next_rule; + } else { + backtrack = false; + } + for (; i < n; ++i) { + uint16_t kind = rule->arg[i] & RULE_ARG_KIND_MASK; + if (kind == RULE_ARG_TOK) { + if (lex->tok_kind == (rule->arg[i] & RULE_ARG_ARG_MASK)) { + push_result_token(&parser, rule); + mp_lexer_to_next(lex); + goto next_rule; + } + } else { + assert(kind == RULE_ARG_RULE); + if (i + 1 < n) { + push_rule(&parser, rule_src_line, rule, i + 1); // save this or-rule + } + push_rule_from_arg(&parser, rule->arg[i]); // push child of or-rule + goto next_rule; + } + } + backtrack = true; + break; + + case RULE_ACT_AND: { + + // failed, backtrack if we can, else syntax error + if (backtrack) { + assert(i > 0); + if ((rule->arg[i - 1] & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE) { + // an optional rule that failed, so continue with next arg + push_result_node(&parser, MP_PARSE_NODE_NULL); + backtrack = false; + } else { + // a mandatory rule that failed, so propagate backtrack + if (i > 1) { + // already eaten tokens so can't backtrack + goto syntax_error; + } else { + goto next_rule; + } + } + } + + // progress through the rule + for (; i < n; ++i) { + if ((rule->arg[i] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { + // need to match a token + mp_token_kind_t tok_kind = rule->arg[i] & RULE_ARG_ARG_MASK; + if (lex->tok_kind == tok_kind) { + // matched token + if (tok_kind == MP_TOKEN_NAME) { + push_result_token(&parser, rule); + } + mp_lexer_to_next(lex); + } else { + // failed to match token + if (i > 0) { + // already eaten tokens so can't backtrack + goto syntax_error; + } else { + // this rule failed, so backtrack + backtrack = true; + goto next_rule; + } + } + } else { + push_rule(&parser, rule_src_line, rule, i + 1); // save this and-rule + push_rule_from_arg(&parser, rule->arg[i]); // push child of and-rule + goto next_rule; + } + } + + assert(i == n); + + // matched the rule, so now build the corresponding parse_node + + #if !MICROPY_ENABLE_DOC_STRING + // this code discards lonely statements, such as doc strings + if (input_kind != MP_PARSE_SINGLE_INPUT && rule->rule_id == RULE_expr_stmt && peek_result(&parser, 0) == MP_PARSE_NODE_NULL) { + mp_parse_node_t p = peek_result(&parser, 1); + if ((MP_PARSE_NODE_IS_LEAF(p) && !MP_PARSE_NODE_IS_ID(p)) + || MP_PARSE_NODE_IS_STRUCT_KIND(p, RULE_const_object)) { + pop_result(&parser); // MP_PARSE_NODE_NULL + pop_result(&parser); // const expression (leaf or RULE_const_object) + // Pushing the "pass" rule here will overwrite any RULE_const_object + // entry that was on the result stack, allowing the GC to reclaim + // the memory from the const object when needed. + push_result_rule(&parser, rule_src_line, rules[RULE_pass_stmt], 0); + break; + } + } + #endif + + // count number of arguments for the parse node + i = 0; + size_t num_not_nil = 0; + for (size_t x = n; x > 0;) { + --x; + if ((rule->arg[x] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { + mp_token_kind_t tok_kind = rule->arg[x] & RULE_ARG_ARG_MASK; + if (tok_kind == MP_TOKEN_NAME) { + // only tokens which were names are pushed to stack + i += 1; + num_not_nil += 1; + } + } else { + // rules are always pushed + if (peek_result(&parser, i) != MP_PARSE_NODE_NULL) { + num_not_nil += 1; + } + i += 1; + } + } + + if (num_not_nil == 1 && (rule->act & RULE_ACT_ALLOW_IDENT)) { + // this rule has only 1 argument and should not be emitted + mp_parse_node_t pn = MP_PARSE_NODE_NULL; + for (size_t x = 0; x < i; ++x) { + mp_parse_node_t pn2 = pop_result(&parser); + if (pn2 != MP_PARSE_NODE_NULL) { + pn = pn2; + } + } + push_result_node(&parser, pn); + } else { + // this rule must be emitted + + if (rule->act & RULE_ACT_ADD_BLANK) { + // and add an extra blank node at the end (used by the compiler to store data) + push_result_node(&parser, MP_PARSE_NODE_NULL); + i += 1; + } + + push_result_rule(&parser, rule_src_line, rule, i); + } + break; + } + + default: { + assert((rule->act & RULE_ACT_KIND_MASK) == RULE_ACT_LIST); + + // n=2 is: item item* + // n=1 is: item (sep item)* + // n=3 is: item (sep item)* [sep] + bool had_trailing_sep; + if (backtrack) { + list_backtrack: + had_trailing_sep = false; + if (n == 2) { + if (i == 1) { + // fail on item, first time round; propagate backtrack + goto next_rule; + } else { + // fail on item, in later rounds; finish with this rule + backtrack = false; + } + } else { + if (i == 1) { + // fail on item, first time round; propagate backtrack + goto next_rule; + } else if ((i & 1) == 1) { + // fail on item, in later rounds; have eaten tokens so can't backtrack + if (n == 3) { + // list allows trailing separator; finish parsing list + had_trailing_sep = true; + backtrack = false; + } else { + // list doesn't allowing trailing separator; fail + goto syntax_error; + } + } else { + // fail on separator; finish parsing list + backtrack = false; + } + } + } else { + for (;;) { + size_t arg = rule->arg[i & 1 & n]; + if ((arg & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { + if (lex->tok_kind == (arg & RULE_ARG_ARG_MASK)) { + if (i & 1 & n) { + // separators which are tokens are not pushed to result stack + } else { + push_result_token(&parser, rule); + } + mp_lexer_to_next(lex); + // got element of list, so continue parsing list + i += 1; + } else { + // couldn't get element of list + i += 1; + backtrack = true; + goto list_backtrack; + } + } else { + assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE); + push_rule(&parser, rule_src_line, rule, i + 1); // save this list-rule + push_rule_from_arg(&parser, arg); // push child of list-rule + goto next_rule; + } + } + } + assert(i >= 1); + + // compute number of elements in list, result in i + i -= 1; + if ((n & 1) && (rule->arg[1] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { + // don't count separators when they are tokens + i = (i + 1) / 2; + } + + if (i == 1) { + // list matched single item + if (had_trailing_sep) { + // if there was a trailing separator, make a list of a single item + push_result_rule(&parser, rule_src_line, rule, i); + } else { + // just leave single item on stack (ie don't wrap in a list) + } + } else { + push_result_rule(&parser, rule_src_line, rule, i); + } + break; + } + } + } + + #if MICROPY_COMP_CONST + mp_map_deinit(&parser.consts); + #endif + + // truncate final chunk and link into chain of chunks + if (parser.cur_chunk != NULL) { + (void)m_renew_maybe(byte, parser.cur_chunk, + sizeof(mp_parse_chunk_t) + parser.cur_chunk->alloc, + sizeof(mp_parse_chunk_t) + parser.cur_chunk->union_.used, + false); + parser.cur_chunk->alloc = parser.cur_chunk->union_.used; + parser.cur_chunk->union_.next = parser.tree.chunk; + parser.tree.chunk = parser.cur_chunk; + } + + if ( + lex->tok_kind != MP_TOKEN_END // check we are at the end of the token stream + || parser.result_stack_top == 0 // check that we got a node (can fail on empty input) + ) { + syntax_error:; + mp_obj_t exc; + if (lex->tok_kind == MP_TOKEN_INDENT) { + exc = mp_obj_new_exception_msg(&mp_type_IndentationError, + "unexpected indent"); + } else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) { + exc = mp_obj_new_exception_msg(&mp_type_IndentationError, + "unindent does not match any outer indentation level"); + } else { + exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, + "invalid syntax"); + } + // add traceback to give info about file name and location + // we don't have a 'block' name, so just pass the NULL qstr to indicate this + mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); + nlr_raise(exc); + } + + // get the root parse node that we created + assert(parser.result_stack_top == 1); + parser.tree.root = parser.result_stack[0]; + + // free the memory that we don't need anymore + m_del(rule_stack_t, parser.rule_stack, parser.rule_stack_alloc); + m_del(mp_parse_node_t, parser.result_stack, parser.result_stack_alloc); + + // we also free the lexer on behalf of the caller + mp_lexer_free(lex); + + return parser.tree; +} + +void mp_parse_tree_clear(mp_parse_tree_t *tree) { + mp_parse_chunk_t *chunk = tree->chunk; + while (chunk != NULL) { + mp_parse_chunk_t *next = chunk->union_.next; + m_del(byte, chunk, sizeof(mp_parse_chunk_t) + chunk->alloc); + chunk = next; + } +} + +#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/parse.h b/user/mpy/py/parse.h new file mode 100644 index 0000000..9a1a2b4 --- /dev/null +++ b/user/mpy/py/parse.h @@ -0,0 +1,107 @@ +/* + * 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_PARSE_H +#define MICROPY_INCLUDED_PY_PARSE_H + +#include +#include + +#include "py/obj.h" + +struct _mp_lexer_t; + +// a mp_parse_node_t is: +// - 0000...0000: no node +// - xxxx...xxx1: a small integer; bits 1 and above are the signed value, 2's complement +// - xxxx...xx00: pointer to mp_parse_node_struct_t +// - xx...xx0010: an identifier; bits 4 and above are the qstr +// - xx...xx0110: a string; bits 4 and above are the qstr holding the value +// - xx...xx1010: a string of bytes; bits 4 and above are the qstr holding the value +// - xx...xx1110: a token; bits 4 and above are mp_token_kind_t + +#define MP_PARSE_NODE_NULL (0) +#define MP_PARSE_NODE_SMALL_INT (0x1) +#define MP_PARSE_NODE_ID (0x02) +#define MP_PARSE_NODE_STRING (0x06) +#define MP_PARSE_NODE_BYTES (0x0a) +#define MP_PARSE_NODE_TOKEN (0x0e) + +typedef uintptr_t mp_parse_node_t; // must be pointer size + +typedef struct _mp_parse_node_struct_t { + uint32_t source_line; // line number in source file + uint32_t kind_num_nodes; // parse node kind, and number of nodes + mp_parse_node_t nodes[]; // nodes +} mp_parse_node_struct_t; + +// macros for mp_parse_node_t usage +// some of these evaluate their argument more than once + +#define MP_PARSE_NODE_IS_NULL(pn) ((pn) == MP_PARSE_NODE_NULL) +#define MP_PARSE_NODE_IS_LEAF(pn) ((pn) & 3) +#define MP_PARSE_NODE_IS_STRUCT(pn) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0) +#define MP_PARSE_NODE_IS_STRUCT_KIND(pn, k) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0 && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)(pn)) == (k)) + +#define MP_PARSE_NODE_IS_SMALL_INT(pn) (((pn) & 0x1) == MP_PARSE_NODE_SMALL_INT) +#define MP_PARSE_NODE_IS_ID(pn) (((pn) & 0x0f) == MP_PARSE_NODE_ID) +#define MP_PARSE_NODE_IS_TOKEN(pn) (((pn) & 0x0f) == MP_PARSE_NODE_TOKEN) +#define MP_PARSE_NODE_IS_TOKEN_KIND(pn, k) ((pn) == (MP_PARSE_NODE_TOKEN | ((k) << 4))) + +#define MP_PARSE_NODE_LEAF_KIND(pn) ((pn) & 0x0f) +#define MP_PARSE_NODE_LEAF_ARG(pn) (((uintptr_t)(pn)) >> 4) +#define MP_PARSE_NODE_LEAF_SMALL_INT(pn) (((mp_int_t)(intptr_t)(pn)) >> 1) +#define MP_PARSE_NODE_STRUCT_KIND(pns) ((pns)->kind_num_nodes & 0xff) +#define MP_PARSE_NODE_STRUCT_NUM_NODES(pns) ((pns)->kind_num_nodes >> 8) + +static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { + return (mp_parse_node_t)(MP_PARSE_NODE_SMALL_INT | ((mp_uint_t)val << 1)); +} +static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { + return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); +} +bool mp_parse_node_is_const_false(mp_parse_node_t pn); +bool mp_parse_node_is_const_true(mp_parse_node_t pn); +bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); +int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); +void mp_parse_node_print(mp_parse_node_t pn, size_t indent); + +typedef enum { + MP_PARSE_SINGLE_INPUT, + MP_PARSE_FILE_INPUT, + MP_PARSE_EVAL_INPUT, +} mp_parse_input_kind_t; + +typedef struct _mp_parse_t { + mp_parse_node_t root; + struct _mp_parse_chunk_t *chunk; +} mp_parse_tree_t; + +// the parser will raise an exception if an error occurred +// the parser will free the lexer before it returns +mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); +void mp_parse_tree_clear(mp_parse_tree_t *tree); + +#endif // MICROPY_INCLUDED_PY_PARSE_H diff --git a/user/mpy/py/parsenum.c b/user/mpy/py/parsenum.c new file mode 100644 index 0000000..b62029f --- /dev/null +++ b/user/mpy/py/parsenum.c @@ -0,0 +1,306 @@ +/* + * 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. + */ + +#include +#include + +#include "py/runtime.h" +#include "py/parsenumbase.h" +#include "py/parsenum.h" +#include "py/smallint.h" + +#if MICROPY_PY_BUILTINS_FLOAT +#include +#endif + +STATIC NORETURN void raise_exc(mp_obj_t exc, mp_lexer_t *lex) { + // if lex!=NULL then the parser called us and we need to convert the + // exception's type from ValueError to SyntaxError and add traceback info + if (lex != NULL) { + ((mp_obj_base_t*)MP_OBJ_TO_PTR(exc))->type = &mp_type_SyntaxError; + mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); + } + nlr_raise(exc); +} + +mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, mp_lexer_t *lex) { + const byte *restrict str = (const byte *)str_; + const byte *restrict top = str + len; + bool neg = false; + mp_obj_t ret_val; + + // check radix base + if ((base != 0 && base < 2) || base > 36) { + // this won't be reached if lex!=NULL + mp_raise_ValueError("int() arg 2 must be >= 2 and <= 36"); + } + + // skip leading space + for (; str < top && unichar_isspace(*str); str++) { + } + + // parse optional sign + if (str < top) { + if (*str == '+') { + str++; + } else if (*str == '-') { + str++; + neg = true; + } + } + + // parse optional base prefix + str += mp_parse_num_base((const char*)str, top - str, &base); + + // string should be an integer number + mp_int_t int_val = 0; + const byte *restrict str_val_start = str; + for (; str < top; str++) { + // get next digit as a value + mp_uint_t dig = *str; + if ('0' <= dig && dig <= '9') { + dig -= '0'; + } else { + dig |= 0x20; // make digit lower-case + if ('a' <= dig && dig <= 'z') { + dig -= 'a' - 10; + } else { + // unknown character + break; + } + } + if (dig >= (mp_uint_t)base) { + break; + } + + // add next digi and check for overflow + if (mp_small_int_mul_overflow(int_val, base)) { + goto overflow; + } + int_val = int_val * base + dig; + if (!MP_SMALL_INT_FITS(int_val)) { + goto overflow; + } + } + + // negate value if needed + if (neg) { + int_val = -int_val; + } + + // create the small int + ret_val = MP_OBJ_NEW_SMALL_INT(int_val); + +have_ret_val: + // check we parsed something + if (str == str_val_start) { + goto value_error; + } + + // skip trailing space + for (; str < top && unichar_isspace(*str); str++) { + } + + // check we reached the end of the string + if (str != top) { + goto value_error; + } + + // return the object + return ret_val; + +overflow: + // reparse using long int + { + const char *s2 = (const char*)str_val_start; + ret_val = mp_obj_new_int_from_str_len(&s2, top - str_val_start, neg, base); + str = (const byte*)s2; + goto have_ret_val; + } + +value_error: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_ValueError, + "invalid syntax for integer"); + raise_exc(exc, lex); + } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { + mp_obj_t exc = mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "invalid syntax for integer with base %d", base); + raise_exc(exc, lex); + } else { + vstr_t vstr; + mp_print_t print; + vstr_init_print(&vstr, 50, &print); + mp_printf(&print, "invalid syntax for integer with base %d: ", base); + mp_str_print_quoted(&print, str_val_start, top - str_val_start, true); + mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_ValueError, + mp_obj_new_str_from_vstr(&mp_type_str, &vstr)); + raise_exc(exc, lex); + } +} + +typedef enum { + PARSE_DEC_IN_INTG, + PARSE_DEC_IN_FRAC, + PARSE_DEC_IN_EXP, +} parse_dec_in_t; + +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool force_complex, mp_lexer_t *lex) { +#if MICROPY_PY_BUILTINS_FLOAT + const char *top = str + len; + mp_float_t dec_val = 0; + bool dec_neg = false; + bool imag = false; + + // skip leading space + for (; str < top && unichar_isspace(*str); str++) { + } + + // parse optional sign + if (str < top) { + if (*str == '+') { + str++; + } else if (*str == '-') { + str++; + dec_neg = true; + } + } + + const char *str_val_start = str; + + // determine what the string is + if (str < top && (str[0] | 0x20) == 'i') { + // string starts with 'i', should be 'inf' or 'infinity' (case insensitive) + if (str + 2 < top && (str[1] | 0x20) == 'n' && (str[2] | 0x20) == 'f') { + // inf + str += 3; + dec_val = INFINITY; + if (str + 4 < top && (str[0] | 0x20) == 'i' && (str[1] | 0x20) == 'n' && (str[2] | 0x20) == 'i' && (str[3] | 0x20) == 't' && (str[4] | 0x20) == 'y') { + // infinity + str += 5; + } + } + } else if (str < top && (str[0] | 0x20) == 'n') { + // string starts with 'n', should be 'nan' (case insensitive) + if (str + 2 < top && (str[1] | 0x20) == 'a' && (str[2] | 0x20) == 'n') { + // NaN + str += 3; + dec_val = MICROPY_FLOAT_C_FUN(nan)(""); + } + } else { + // string should be a decimal number + parse_dec_in_t in = PARSE_DEC_IN_INTG; + bool exp_neg = false; + mp_float_t frac_mult = 0.1; + mp_int_t exp_val = 0; + while (str < top) { + mp_uint_t dig = *str++; + if ('0' <= dig && dig <= '9') { + dig -= '0'; + if (in == PARSE_DEC_IN_EXP) { + exp_val = 10 * exp_val + dig; + } else { + if (in == PARSE_DEC_IN_FRAC) { + dec_val += dig * frac_mult; + frac_mult *= MICROPY_FLOAT_CONST(0.1); + } else { + dec_val = 10 * dec_val + dig; + } + } + } else if (in == PARSE_DEC_IN_INTG && dig == '.') { + in = PARSE_DEC_IN_FRAC; + } else if (in != PARSE_DEC_IN_EXP && ((dig | 0x20) == 'e')) { + in = PARSE_DEC_IN_EXP; + if (str < top) { + if (str[0] == '+') { + str++; + } else if (str[0] == '-') { + str++; + exp_neg = true; + } + } + if (str == top) { + goto value_error; + } + } else if (allow_imag && (dig | 0x20) == 'j') { + imag = true; + break; + } else { + // unknown character + str--; + break; + } + } + + // work out the exponent + if (exp_neg) { + exp_val = -exp_val; + } + + // apply the exponent + dec_val *= MICROPY_FLOAT_C_FUN(pow)(10, exp_val); + } + + // negate value if needed + if (dec_neg) { + dec_val = -dec_val; + } + + // check we parsed something + if (str == str_val_start) { + goto value_error; + } + + // skip trailing space + for (; str < top && unichar_isspace(*str); str++) { + } + + // check we reached the end of the string + if (str != top) { + goto value_error; + } + + // return the object +#if MICROPY_PY_BUILTINS_COMPLEX + if (imag) { + return mp_obj_new_complex(0, dec_val); + } else if (force_complex) { + return mp_obj_new_complex(dec_val, 0); +#else + if (imag || force_complex) { + raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "complex values not supported"), lex); +#endif + } else { + return mp_obj_new_float(dec_val); + } + +value_error: + raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid syntax for number"), lex); + +#else + raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "decimal numbers not supported"), lex); +#endif +} diff --git a/user/mpy/py/parsenum.h b/user/mpy/py/parsenum.h new file mode 100644 index 0000000..a5bed73 --- /dev/null +++ b/user/mpy/py/parsenum.h @@ -0,0 +1,37 @@ +/* + * 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_PARSENUM_H +#define MICROPY_INCLUDED_PY_PARSENUM_H + +#include "py/mpconfig.h" +#include "py/lexer.h" +#include "py/obj.h" + +// these functions raise a SyntaxError if lex!=NULL, else a ValueError +mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); +mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool force_complex, mp_lexer_t *lex); + +#endif // MICROPY_INCLUDED_PY_PARSENUM_H diff --git a/user/mpy/py/parsenumbase.c b/user/mpy/py/parsenumbase.c new file mode 100644 index 0000000..ba10591 --- /dev/null +++ b/user/mpy/py/parsenumbase.c @@ -0,0 +1,71 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/parsenumbase.h" + +// find real radix base, and strip preceding '0x', '0o' and '0b' +// puts base in *base, and returns number of bytes to skip the prefix +size_t mp_parse_num_base(const char *str, size_t len, int *base) { + const byte *p = (const byte*)str; + if (len <= 1) { + goto no_prefix; + } + unichar c = *(p++); + if ((*base == 0 || *base == 16) && c == '0') { + c = *(p++); + if ((c | 32) == 'x') { + *base = 16; + } else if (*base == 0 && (c | 32) == 'o') { + *base = 8; + } else if (*base == 0 && (c | 32) == 'b') { + *base = 2; + } else { + if (*base == 0) { + *base = 10; + } + p -= 2; + } + } else if (*base == 8 && c == '0') { + c = *(p++); + if ((c | 32) != 'o') { + p -= 2; + } + } else if (*base == 2 && c == '0') { + c = *(p++); + if ((c | 32) != 'b') { + p -= 2; + } + } else { + p--; + no_prefix: + if (*base == 0) { + *base = 10; + } + } + return p - (const byte*)str; +} diff --git a/user/mpy/py/parsenumbase.h b/user/mpy/py/parsenumbase.h new file mode 100644 index 0000000..3a525f9 --- /dev/null +++ b/user/mpy/py/parsenumbase.h @@ -0,0 +1,33 @@ +/* + * 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_PARSENUMBASE_H +#define MICROPY_INCLUDED_PY_PARSENUMBASE_H + +#include "py/mpconfig.h" + +size_t mp_parse_num_base(const char *str, size_t len, int *base); + +#endif // MICROPY_INCLUDED_PY_PARSENUMBASE_H diff --git a/user/mpy/py/persistentcode.c b/user/mpy/py/persistentcode.c new file mode 100644 index 0000000..2fa8c1d --- /dev/null +++ b/user/mpy/py/persistentcode.c @@ -0,0 +1,400 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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. + */ + +#include +#include +#include +#include + +#include "py/reader.h" +#include "py/emitglue.h" +#include "py/persistentcode.h" +#include "py/bc.h" + +#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE + +#include "py/smallint.h" + +// The current version of .mpy files +#define MPY_VERSION (2) + +// The feature flags byte encodes the compile-time config options that +// affect the generate bytecode. +#define MPY_FEATURE_FLAGS ( \ + ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) << 0) \ + | ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \ + ) +// This is a version of the flags that can be configured at runtime. +#define MPY_FEATURE_FLAGS_DYNAMIC ( \ + ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) << 0) \ + | ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \ + ) + +#if MICROPY_PERSISTENT_CODE_LOAD || (MICROPY_PERSISTENT_CODE_SAVE && !MICROPY_DYNAMIC_COMPILER) +// The bytecode will depend on the number of bits in a small-int, and +// this function computes that (could make it a fixed constant, but it +// would need to be defined in mpconfigport.h). +STATIC int mp_small_int_bits(void) { + mp_int_t i = MP_SMALL_INT_MAX; + int n = 1; + while (i != 0) { + i >>= 1; + ++n; + } + return n; +} +#endif + +typedef struct _bytecode_prelude_t { + uint n_state; + uint n_exc_stack; + uint scope_flags; + uint n_pos_args; + uint n_kwonly_args; + uint n_def_pos_args; + uint code_info_size; +} bytecode_prelude_t; + +// ip will point to start of opcodes +// ip2 will point to simple_name, source_file qstrs +STATIC void extract_prelude(const byte **ip, const byte **ip2, bytecode_prelude_t *prelude) { + prelude->n_state = mp_decode_uint(ip); + prelude->n_exc_stack = mp_decode_uint(ip); + prelude->scope_flags = *(*ip)++; + prelude->n_pos_args = *(*ip)++; + prelude->n_kwonly_args = *(*ip)++; + prelude->n_def_pos_args = *(*ip)++; + *ip2 = *ip; + prelude->code_info_size = mp_decode_uint(ip2); + *ip += prelude->code_info_size; + while (*(*ip)++ != 255) { + } +} + +#endif // MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE + +#if MICROPY_PERSISTENT_CODE_LOAD + +#include "py/parsenum.h" +#include "py/bc0.h" + +STATIC int read_byte(mp_reader_t *reader) { + return reader->readbyte(reader->data); +} + +STATIC void read_bytes(mp_reader_t *reader, byte *buf, size_t len) { + while (len-- > 0) { + *buf++ = reader->readbyte(reader->data); + } +} + +STATIC size_t read_uint(mp_reader_t *reader) { + size_t unum = 0; + for (;;) { + byte b = reader->readbyte(reader->data); + unum = (unum << 7) | (b & 0x7f); + if ((b & 0x80) == 0) { + break; + } + } + return unum; +} + +STATIC qstr load_qstr(mp_reader_t *reader) { + size_t len = read_uint(reader); + char *str = m_new(char, len); + read_bytes(reader, (byte*)str, len); + qstr qst = qstr_from_strn(str, len); + m_del(char, str, len); + return qst; +} + +STATIC mp_obj_t load_obj(mp_reader_t *reader) { + byte obj_type = read_byte(reader); + if (obj_type == 'e') { + return MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj); + } else { + size_t len = read_uint(reader); + vstr_t vstr; + vstr_init_len(&vstr, len); + read_bytes(reader, (byte*)vstr.buf, len); + if (obj_type == 's' || obj_type == 'b') { + return mp_obj_new_str_from_vstr(obj_type == 's' ? &mp_type_str : &mp_type_bytes, &vstr); + } else if (obj_type == 'i') { + return mp_parse_num_integer(vstr.buf, vstr.len, 10, NULL); + } else { + assert(obj_type == 'f' || obj_type == 'c'); + return mp_parse_num_decimal(vstr.buf, vstr.len, obj_type == 'c', false, NULL); + } + } +} + +STATIC void load_bytecode_qstrs(mp_reader_t *reader, byte *ip, byte *ip_top) { + while (ip < ip_top) { + size_t sz; + uint f = mp_opcode_format(ip, &sz); + if (f == MP_OPCODE_QSTR) { + qstr qst = load_qstr(reader); + ip[1] = qst; + ip[2] = qst >> 8; + } + ip += sz; + } +} + +STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader) { + // load bytecode + size_t bc_len = read_uint(reader); + byte *bytecode = m_new(byte, bc_len); + read_bytes(reader, bytecode, bc_len); + + // extract prelude + const byte *ip = bytecode; + const byte *ip2; + bytecode_prelude_t prelude; + extract_prelude(&ip, &ip2, &prelude); + + // load qstrs and link global qstr ids into bytecode + qstr simple_name = load_qstr(reader); + qstr source_file = load_qstr(reader); + ((byte*)ip2)[0] = simple_name; ((byte*)ip2)[1] = simple_name >> 8; + ((byte*)ip2)[2] = source_file; ((byte*)ip2)[3] = source_file >> 8; + load_bytecode_qstrs(reader, (byte*)ip, bytecode + bc_len); + + // load constant table + size_t n_obj = read_uint(reader); + size_t n_raw_code = read_uint(reader); + mp_uint_t *const_table = m_new(mp_uint_t, prelude.n_pos_args + prelude.n_kwonly_args + n_obj + n_raw_code); + mp_uint_t *ct = const_table; + for (size_t i = 0; i < prelude.n_pos_args + prelude.n_kwonly_args; ++i) { + *ct++ = (mp_uint_t)MP_OBJ_NEW_QSTR(load_qstr(reader)); + } + for (size_t i = 0; i < n_obj; ++i) { + *ct++ = (mp_uint_t)load_obj(reader); + } + for (size_t i = 0; i < n_raw_code; ++i) { + *ct++ = (mp_uint_t)(uintptr_t)load_raw_code(reader); + } + + // create raw_code and return it + mp_raw_code_t *rc = mp_emit_glue_new_raw_code(); + mp_emit_glue_assign_bytecode(rc, bytecode, bc_len, const_table, + #if MICROPY_PERSISTENT_CODE_SAVE + n_obj, n_raw_code, + #endif + prelude.scope_flags); + return rc; +} + +mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader) { + byte header[4]; + read_bytes(reader, header, sizeof(header)); + if (header[0] != 'M' + || header[1] != MPY_VERSION + || header[2] != MPY_FEATURE_FLAGS + || header[3] > mp_small_int_bits()) { + mp_raise_ValueError("incompatible .mpy file"); + } + mp_raw_code_t *rc = load_raw_code(reader); + reader->close(reader->data); + return rc; +} + +mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len) { + mp_reader_t reader; + mp_reader_new_mem(&reader, buf, len, 0); + return mp_raw_code_load(&reader); +} + +mp_raw_code_t *mp_raw_code_load_file(const char *filename) { + mp_reader_t reader; + mp_reader_new_file(&reader, filename); + return mp_raw_code_load(&reader); +} + +#endif // MICROPY_PERSISTENT_CODE_LOAD + +#if MICROPY_PERSISTENT_CODE_SAVE + +#include "py/objstr.h" + +STATIC void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) { + print->print_strn(print->data, (const char*)data, len); +} + +#define BYTES_FOR_INT ((BYTES_PER_WORD * 8 + 6) / 7) +STATIC void mp_print_uint(mp_print_t *print, size_t n) { + byte buf[BYTES_FOR_INT]; + byte *p = buf + sizeof(buf); + *--p = n & 0x7f; + n >>= 7; + for (; n != 0; n >>= 7) { + *--p = 0x80 | (n & 0x7f); + } + print->print_strn(print->data, (char*)p, buf + sizeof(buf) - p); +} + +STATIC void save_qstr(mp_print_t *print, qstr qst) { + size_t len; + const byte *str = qstr_data(qst, &len); + mp_print_uint(print, len); + mp_print_bytes(print, str, len); +} + +STATIC void save_obj(mp_print_t *print, mp_obj_t o) { + if (MP_OBJ_IS_STR_OR_BYTES(o)) { + byte obj_type; + if (MP_OBJ_IS_STR(o)) { + obj_type = 's'; + } else { + obj_type = 'b'; + } + mp_uint_t len; + const char *str = mp_obj_str_get_data(o, &len); + mp_print_bytes(print, &obj_type, 1); + mp_print_uint(print, len); + mp_print_bytes(print, (const byte*)str, len); + } else if (MP_OBJ_TO_PTR(o) == &mp_const_ellipsis_obj) { + byte obj_type = 'e'; + mp_print_bytes(print, &obj_type, 1); + } else { + // we save numbers using a simplistic text representation + // TODO could be improved + byte obj_type; + if (MP_OBJ_IS_TYPE(o, &mp_type_int)) { + obj_type = 'i'; + #if MICROPY_PY_BUILTINS_COMPLEX + } else if (MP_OBJ_IS_TYPE(o, &mp_type_complex)) { + obj_type = 'c'; + #endif + } else { + assert(mp_obj_is_float(o)); + obj_type = 'f'; + } + vstr_t vstr; + mp_print_t pr; + vstr_init_print(&vstr, 10, &pr); + mp_obj_print_helper(&pr, o, PRINT_REPR); + mp_print_bytes(print, &obj_type, 1); + mp_print_uint(print, vstr.len); + mp_print_bytes(print, (const byte*)vstr.buf, vstr.len); + vstr_clear(&vstr); + } +} + +STATIC void save_bytecode_qstrs(mp_print_t *print, const byte *ip, const byte *ip_top) { + while (ip < ip_top) { + size_t sz; + uint f = mp_opcode_format(ip, &sz); + if (f == MP_OPCODE_QSTR) { + qstr qst = ip[1] | (ip[2] << 8); + save_qstr(print, qst); + } + ip += sz; + } +} + +STATIC void save_raw_code(mp_print_t *print, mp_raw_code_t *rc) { + if (rc->kind != MP_CODE_BYTECODE) { + mp_raise_ValueError("can only save bytecode"); + } + + // save bytecode + mp_print_uint(print, rc->data.u_byte.bc_len); + mp_print_bytes(print, rc->data.u_byte.bytecode, rc->data.u_byte.bc_len); + + // extract prelude + const byte *ip = rc->data.u_byte.bytecode; + const byte *ip2; + bytecode_prelude_t prelude; + extract_prelude(&ip, &ip2, &prelude); + + // save qstrs + save_qstr(print, ip2[0] | (ip2[1] << 8)); // simple_name + save_qstr(print, ip2[2] | (ip2[3] << 8)); // source_file + save_bytecode_qstrs(print, ip, rc->data.u_byte.bytecode + rc->data.u_byte.bc_len); + + // save constant table + mp_print_uint(print, rc->data.u_byte.n_obj); + mp_print_uint(print, rc->data.u_byte.n_raw_code); + const mp_uint_t *const_table = rc->data.u_byte.const_table; + for (uint i = 0; i < prelude.n_pos_args + prelude.n_kwonly_args; ++i) { + mp_obj_t o = (mp_obj_t)*const_table++; + save_qstr(print, MP_OBJ_QSTR_VALUE(o)); + } + for (uint i = 0; i < rc->data.u_byte.n_obj; ++i) { + save_obj(print, (mp_obj_t)*const_table++); + } + for (uint i = 0; i < rc->data.u_byte.n_raw_code; ++i) { + save_raw_code(print, (mp_raw_code_t*)(uintptr_t)*const_table++); + } +} + +void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) { + // header contains: + // byte 'M' + // byte version + // byte feature flags + // byte number of bits in a small int + byte header[4] = {'M', MPY_VERSION, MPY_FEATURE_FLAGS_DYNAMIC, + #if MICROPY_DYNAMIC_COMPILER + mp_dynamic_compiler.small_int_bits, + #else + mp_small_int_bits(), + #endif + }; + mp_print_bytes(print, header, sizeof(header)); + + save_raw_code(print, rc); +} + +// here we define mp_raw_code_save_file depending on the port +// TODO abstract this away properly + +#if defined(__i386__) || defined(__x86_64__) || (defined(__arm__) && (defined(__unix__))) + +#include +#include +#include + +STATIC void fd_print_strn(void *env, const char *str, size_t len) { + int fd = (intptr_t)env; + ssize_t ret = write(fd, str, len); + (void)ret; +} + +void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename) { + int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); + mp_print_t fd_print = {(void*)(intptr_t)fd, fd_print_strn}; + mp_raw_code_save(rc, &fd_print); + close(fd); +} + +#else +#error mp_raw_code_save_file not implemented for this platform +#endif + +#endif // MICROPY_PERSISTENT_CODE_SAVE diff --git a/user/mpy/py/persistentcode.h b/user/mpy/py/persistentcode.h new file mode 100644 index 0000000..d04e0b6 --- /dev/null +++ b/user/mpy/py/persistentcode.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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_PERSISTENTCODE_H +#define MICROPY_INCLUDED_PY_PERSISTENTCODE_H + +#include "py/mpprint.h" +#include "py/reader.h" +#include "py/emitglue.h" + +mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader); +mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len); +mp_raw_code_t *mp_raw_code_load_file(const char *filename); + +void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print); +void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename); + +#endif // MICROPY_INCLUDED_PY_PERSISTENTCODE_H diff --git a/user/mpy/py/py.mk b/user/mpy/py/py.mk new file mode 100644 index 0000000..cd0e94e --- /dev/null +++ b/user/mpy/py/py.mk @@ -0,0 +1,324 @@ +# where py object files go (they have a name prefix to prevent filename clashes) +PY_BUILD = $(BUILD)/py + +# where autogenerated header files go +HEADER_BUILD = $(BUILD)/genhdr + +# file containing qstr defs for the core Python bit +PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h + +# If qstr autogeneration is not disabled we specify the output header +# for all collected qstrings. +ifneq ($(QSTR_AUTOGEN_DISABLE),1) +QSTR_DEFS_COLLECTED = $(HEADER_BUILD)/qstrdefs.collected.h +endif + +# some code is performance bottleneck and compiled with other optimization options +CSUPEROPT = -O3 + +# this sets the config file for FatFs +CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\" + +ifeq ($(MICROPY_PY_USSL),1) +CFLAGS_MOD += -DMICROPY_PY_USSL=1 +ifeq ($(MICROPY_SSL_AXTLS),1) +CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/lib/axtls/config +LDFLAGS_MOD += -Lbuild -laxtls +else ifeq ($(MICROPY_SSL_MBEDTLS),1) +# Can be overridden by ports which have "builtin" mbedTLS +MICROPY_SSL_MBEDTLS_INCLUDE ?= $(TOP)/lib/mbedtls/include +CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE) +LDFLAGS_MOD += -L$(TOP)/lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto +endif +endif + +#ifeq ($(MICROPY_PY_LWIP),1) +#CFLAGS_MOD += -DMICROPY_PY_LWIP=1 -I../lib/lwip/src/include -I../lib/lwip/src/include/ipv4 -I../extmod/lwip-include +#endif + +ifeq ($(MICROPY_PY_LWIP),1) +LWIP_DIR = lib/lwip/src +INC += -I$(TOP)/lib/lwip/src/include -I$(TOP)/lib/lwip/src/include/ipv4 -I$(TOP)/extmod/lwip-include +CFLAGS_MOD += -DMICROPY_PY_LWIP=1 +SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c +SRC_MOD += $(addprefix $(LWIP_DIR)/,\ + core/def.c \ + core/dns.c \ + core/init.c \ + core/mem.c \ + core/memp.c \ + core/netif.c \ + core/pbuf.c \ + core/raw.c \ + core/stats.c \ + core/sys.c \ + core/tcp.c \ + core/tcp_in.c \ + core/tcp_out.c \ + core/timers.c \ + core/udp.c \ + core/ipv4/autoip.c \ + core/ipv4/icmp.c \ + core/ipv4/igmp.c \ + core/ipv4/inet.c \ + core/ipv4/inet_chksum.c \ + core/ipv4/ip_addr.c \ + core/ipv4/ip.c \ + core/ipv4/ip_frag.c \ + ) +ifeq ($(MICROPY_PY_LWIP_SLIP),1) +CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1 +SRC_MOD += $(LWIP_DIR)/netif/slipif.c +endif +endif + +ifeq ($(MICROPY_PY_BTREE),1) +BTREE_DIR = lib/berkeley-db-1.xx +BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ -Dvirt_fd_t=mp_obj_t "-DVIRT_FD_T_HEADER=" +INC += -I$(TOP)/$(BTREE_DIR)/PORT/include +SRC_MOD += extmod/modbtree.c +SRC_MOD += $(addprefix $(BTREE_DIR)/,\ +btree/bt_close.c \ +btree/bt_conv.c \ +btree/bt_debug.c \ +btree/bt_delete.c \ +btree/bt_get.c \ +btree/bt_open.c \ +btree/bt_overflow.c \ +btree/bt_page.c \ +btree/bt_put.c \ +btree/bt_search.c \ +btree/bt_seq.c \ +btree/bt_split.c \ +btree/bt_utils.c \ +mpool/mpool.c \ + ) +CFLAGS_MOD += -DMICROPY_PY_BTREE=1 +# we need to suppress certain warnings to get berkeley-db to compile cleanly +# and we have separate BTREE_DEFS so the definitions don't interfere with other source code +$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS) +$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS) +endif + +# py object files +PY_O_BASENAME = \ + mpstate.o \ + nlrx86.o \ + nlrx64.o \ + nlrthumb.o \ + nlrxtensa.o \ + nlrsetjmp.o \ + malloc.o \ + gc.o \ + qstr.o \ + vstr.o \ + mpprint.o \ + unicode.o \ + mpz.o \ + reader.o \ + lexer.o \ + parse.o \ + scope.o \ + compile.o \ + emitcommon.o \ + emitbc.o \ + asmbase.o \ + asmx64.o \ + emitnx64.o \ + asmx86.o \ + emitnx86.o \ + asmthumb.o \ + emitnthumb.o \ + emitinlinethumb.o \ + asmarm.o \ + emitnarm.o \ + asmxtensa.o \ + emitnxtensa.o \ + emitinlinextensa.o \ + formatfloat.o \ + parsenumbase.o \ + parsenum.o \ + emitglue.o \ + persistentcode.o \ + runtime.o \ + runtime_utils.o \ + scheduler.o \ + nativeglue.o \ + stackctrl.o \ + argcheck.o \ + warning.o \ + map.o \ + obj.o \ + objarray.o \ + objattrtuple.o \ + objbool.o \ + objboundmeth.o \ + objcell.o \ + objclosure.o \ + objcomplex.o \ + objdict.o \ + objenumerate.o \ + objexcept.o \ + objfilter.o \ + objfloat.o \ + objfun.o \ + objgenerator.o \ + objgetitemiter.o \ + objint.o \ + objint_longlong.o \ + objint_mpz.o \ + objlist.o \ + objmap.o \ + objmodule.o \ + objobject.o \ + objpolyiter.o \ + objproperty.o \ + objnone.o \ + objnamedtuple.o \ + objrange.o \ + objreversed.o \ + objset.o \ + objsingleton.o \ + objslice.o \ + objstr.o \ + objstrunicode.o \ + objstringio.o \ + objtuple.o \ + objtype.o \ + objzip.o \ + opmethods.o \ + sequence.o \ + stream.o \ + binary.o \ + builtinimport.o \ + builtinevex.o \ + builtinhelp.o \ + modarray.o \ + modbuiltins.o \ + modcollections.o \ + modgc.o \ + modio.o \ + modmath.o \ + modcmath.o \ + modmicropython.o \ + modstruct.o \ + modsys.o \ + moduerrno.o \ + modthread.o \ + vm.o \ + bc.o \ + showbc.o \ + repl.o \ + smallint.o \ + frozenmod.o \ + ../extmod/moductypes.o \ + ../extmod/modujson.o \ + ../extmod/modure.o \ + ../extmod/moduzlib.o \ + ../extmod/moduheapq.o \ + ../extmod/modutimeq.o \ + ../extmod/moduhashlib.o \ + ../extmod/modubinascii.o \ + ../extmod/virtpin.o \ + ../extmod/machine_mem.o \ + ../extmod/machine_pinbase.o \ + ../extmod/machine_signal.o \ + ../extmod/machine_pulse.o \ + ../extmod/machine_i2c.o \ + ../extmod/machine_spi.o \ + ../extmod/modussl_axtls.o \ + ../extmod/modussl_mbedtls.o \ + ../extmod/modurandom.o \ + ../extmod/moduselect.o \ + ../extmod/modwebsocket.o \ + ../extmod/modwebrepl.o \ + ../extmod/modframebuf.o \ + ../extmod/vfs.o \ + ../extmod/vfs_reader.o \ + ../extmod/vfs_fat.o \ + ../extmod/vfs_fat_diskio.o \ + ../extmod/vfs_fat_file.o \ + ../extmod/vfs_fat_misc.o \ + ../extmod/utime_mphal.o \ + ../extmod/uos_dupterm.o \ + ../lib/embed/abort_.o \ + ../lib/utils/printf.o \ + +# prepend the build destination prefix to the py object files +PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME)) + +# object file for frozen files +ifneq ($(FROZEN_DIR),) +PY_O += $(BUILD)/$(BUILD)/frozen.o +endif + +# object file for frozen bytecode (frozen .mpy files) +ifneq ($(FROZEN_MPY_DIR),) +PY_O += $(BUILD)/$(BUILD)/frozen_mpy.o +endif + +# Sources that may contain qstrings +SRC_QSTR_IGNORE = nlr% emitnx86% emitnx64% emitnthumb% emitnarm% emitnxtensa% +SRC_QSTR = $(SRC_MOD) $(addprefix py/,$(filter-out $(SRC_QSTR_IGNORE),$(PY_O_BASENAME:.o=.c)) emitnative.c) + + +$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD) + $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ + +# mpconfigport.mk is optional, but changes to it may drastically change +# overall config, so they need to be caught +MPCONFIGPORT_MK = $(wildcard mpconfigport.mk) + +# qstr data +# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get +# created before we run the script to generate the .h +# Note: we need to protect the qstr names from the preprocessor, so we wrap +# the lines in "" and then unwrap after the preprocessor is finished. +$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) + $(ECHO) "GEN $@" + $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ + +# Force nlr code to always be compiled with space-saving optimisation so +# that the function preludes are of a minimal and predictable form. +$(PY_BUILD)/nlr%.o: CFLAGS += -Os + +# emitters + +$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64 +$(PY_BUILD)/emitnx64.o: py/emitnative.c + $(call compile_c) + +$(PY_BUILD)/emitnx86.o: CFLAGS += -DN_X86 +$(PY_BUILD)/emitnx86.o: py/emitnative.c + $(call compile_c) + +$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB +$(PY_BUILD)/emitnthumb.o: py/emitnative.c + $(call compile_c) + +$(PY_BUILD)/emitnarm.o: CFLAGS += -DN_ARM +$(PY_BUILD)/emitnarm.o: py/emitnative.c + $(call compile_c) + +$(PY_BUILD)/emitnxtensa.o: CFLAGS += -DN_XTENSA +$(PY_BUILD)/emitnxtensa.o: py/emitnative.c + $(call compile_c) + +# optimising gc for speed; 5ms down to 4ms on pybv2 +$(PY_BUILD)/gc.o: CFLAGS += $(CSUPEROPT) + +# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster) +$(PY_BUILD)/vm.o: CFLAGS += $(CSUPEROPT) +# Optimizing vm.o for modern deeply pipelined CPUs with branch predictors +# may require disabling tail jump optimization. This will make sure that +# each opcode has its own dispatching jump which will improve branch +# branch predictor efficiency. +# http://article.gmane.org/gmane.comp.lang.lua.general/75426 +# http://hg.python.org/cpython/file/b127046831e2/Python/ceval.c#l828 +# http://www.emulators.com/docs/nx25_nostradamus.htm +#-fno-crossjumping + +# Anything that depends on FORCE will be considered out-of-date +FORCE: +.PHONY: FORCE diff --git a/user/mpy/py/qstr.c b/user/mpy/py/qstr.c new file mode 100644 index 0000000..95c9b68 --- /dev/null +++ b/user/mpy/py/qstr.c @@ -0,0 +1,321 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpstate.h" +#include "py/qstr.h" +#include "py/gc.h" + +// NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings) +// ultimately we will replace this with a static hash table of some kind +// also probably need to include the length in the string data, to allow null bytes in the string + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_printf DEBUG_printf +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#endif + +// A qstr is an index into the qstr pool. +// The data for a qstr contains (hash, length, data): +// - hash (configurable number of bytes) +// - length (configurable number of bytes) +// - data ("length" number of bytes) +// - \0 terminated (so they can be printed using printf) + +#if MICROPY_QSTR_BYTES_IN_HASH == 1 + #define Q_HASH_MASK (0xff) + #define Q_GET_HASH(q) ((mp_uint_t)(q)[0]) + #define Q_SET_HASH(q, hash) do { (q)[0] = (hash); } while (0) +#elif MICROPY_QSTR_BYTES_IN_HASH == 2 + #define Q_HASH_MASK (0xffff) + #define Q_GET_HASH(q) ((mp_uint_t)(q)[0] | ((mp_uint_t)(q)[1] << 8)) + #define Q_SET_HASH(q, hash) do { (q)[0] = (hash); (q)[1] = (hash) >> 8; } while (0) +#else + #error unimplemented qstr hash decoding +#endif +#define Q_GET_ALLOC(q) (MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + Q_GET_LENGTH(q) + 1) +#define Q_GET_DATA(q) ((q) + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN) +#if MICROPY_QSTR_BYTES_IN_LEN == 1 + #define Q_GET_LENGTH(q) ((q)[MICROPY_QSTR_BYTES_IN_HASH]) + #define Q_SET_LENGTH(q, len) do { (q)[MICROPY_QSTR_BYTES_IN_HASH] = (len); } while (0) +#elif MICROPY_QSTR_BYTES_IN_LEN == 2 + #define Q_GET_LENGTH(q) ((q)[MICROPY_QSTR_BYTES_IN_HASH] | ((q)[MICROPY_QSTR_BYTES_IN_HASH + 1] << 8)) + #define Q_SET_LENGTH(q, len) do { (q)[MICROPY_QSTR_BYTES_IN_HASH] = (len); (q)[MICROPY_QSTR_BYTES_IN_HASH + 1] = (len) >> 8; } while (0) +#else + #error unimplemented qstr length decoding +#endif + +#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL +#define QSTR_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(qstr_mutex), 1) +#define QSTR_EXIT() mp_thread_mutex_unlock(&MP_STATE_VM(qstr_mutex)) +#else +#define QSTR_ENTER() +#define QSTR_EXIT() +#endif + +// this must match the equivalent function in makeqstrdata.py +mp_uint_t qstr_compute_hash(const byte *data, size_t len) { + // djb2 algorithm; see http://www.cse.yorku.ca/~oz/hash.html + mp_uint_t hash = 5381; + for (const byte *top = data + len; data < top; data++) { + hash = ((hash << 5) + hash) ^ (*data); // hash * 33 ^ data + } + hash &= Q_HASH_MASK; + // Make sure that valid hash is never zero, zero means "hash not computed" + if (hash == 0) { + hash++; + } + return hash; +} + +const qstr_pool_t mp_qstr_const_pool = { + NULL, // no previous pool + 0, // no previous pool + 10, // set so that the first dynamically allocated pool is twice this size; must be <= the len (just below) + MP_QSTRnumber_of, // corresponds to number of strings in array just below + { +#ifndef NO_QSTR +#define QDEF(id, str) str, +#include "genhdr/qstrdefs.generated.h" +#undef QDEF +#endif + }, +}; + +#ifdef MICROPY_QSTR_EXTRA_POOL +extern const qstr_pool_t MICROPY_QSTR_EXTRA_POOL; +#define CONST_POOL MICROPY_QSTR_EXTRA_POOL +#else +#define CONST_POOL mp_qstr_const_pool +#endif + +void qstr_init(void) { + MP_STATE_VM(last_pool) = (qstr_pool_t*)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left + MP_STATE_VM(qstr_last_chunk) = NULL; + + #if MICROPY_PY_THREAD + mp_thread_mutex_init(&MP_STATE_VM(qstr_mutex)); + #endif +} + +STATIC const byte *find_qstr(qstr q) { + // search pool for this qstr + for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) { + if (q >= pool->total_prev_len) { + return pool->qstrs[q - pool->total_prev_len]; + } + } + + // not found + return 0; +} + +// qstr_mutex must be taken while in this function +STATIC qstr qstr_add(const byte *q_ptr) { + DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", Q_GET_HASH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_DATA(q_ptr)); + + // make sure we have room in the pool for a new qstr + if (MP_STATE_VM(last_pool)->len >= MP_STATE_VM(last_pool)->alloc) { + qstr_pool_t *pool = m_new_obj_var_maybe(qstr_pool_t, const char*, MP_STATE_VM(last_pool)->alloc * 2); + if (pool == NULL) { + QSTR_EXIT(); + m_malloc_fail(MP_STATE_VM(last_pool)->alloc * 2); + } + pool->prev = MP_STATE_VM(last_pool); + pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len; + pool->alloc = MP_STATE_VM(last_pool)->alloc * 2; + pool->len = 0; + MP_STATE_VM(last_pool) = pool; + DEBUG_printf("QSTR: allocate new pool of size %d\n", MP_STATE_VM(last_pool)->alloc); + } + + // add the new qstr + MP_STATE_VM(last_pool)->qstrs[MP_STATE_VM(last_pool)->len++] = q_ptr; + + // return id for the newly-added qstr + return MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len - 1; +} + +qstr qstr_find_strn(const char *str, size_t str_len) { + // work out hash of str + mp_uint_t str_hash = qstr_compute_hash((const byte*)str, str_len); + + // search pools for the data + for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) { + for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { + if (Q_GET_HASH(*q) == str_hash && Q_GET_LENGTH(*q) == str_len && memcmp(Q_GET_DATA(*q), str, str_len) == 0) { + return pool->total_prev_len + (q - pool->qstrs); + } + } + } + + // not found; return null qstr + return 0; +} + +qstr qstr_from_str(const char *str) { + return qstr_from_strn(str, strlen(str)); +} + +qstr qstr_from_strn(const char *str, size_t len) { + assert(len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))); + QSTR_ENTER(); + qstr q = qstr_find_strn(str, len); + if (q == 0) { + // qstr does not exist in interned pool so need to add it + + // compute number of bytes needed to intern this string + size_t n_bytes = MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len + 1; + + if (MP_STATE_VM(qstr_last_chunk) != NULL && MP_STATE_VM(qstr_last_used) + n_bytes > MP_STATE_VM(qstr_last_alloc)) { + // not enough room at end of previously interned string so try to grow + byte *new_p = m_renew_maybe(byte, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_alloc) + n_bytes, false); + if (new_p == NULL) { + // could not grow existing memory; shrink it to fit previous + (void)m_renew_maybe(byte, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_used), false); + MP_STATE_VM(qstr_last_chunk) = NULL; + } else { + // could grow existing memory + MP_STATE_VM(qstr_last_alloc) += n_bytes; + } + } + + if (MP_STATE_VM(qstr_last_chunk) == NULL) { + // no existing memory for the interned string so allocate a new chunk + size_t al = n_bytes; + if (al < MICROPY_ALLOC_QSTR_CHUNK_INIT) { + al = MICROPY_ALLOC_QSTR_CHUNK_INIT; + } + MP_STATE_VM(qstr_last_chunk) = m_new_maybe(byte, al); + if (MP_STATE_VM(qstr_last_chunk) == NULL) { + // failed to allocate a large chunk so try with exact size + MP_STATE_VM(qstr_last_chunk) = m_new_maybe(byte, n_bytes); + if (MP_STATE_VM(qstr_last_chunk) == NULL) { + QSTR_EXIT(); + m_malloc_fail(n_bytes); + } + al = n_bytes; + } + MP_STATE_VM(qstr_last_alloc) = al; + MP_STATE_VM(qstr_last_used) = 0; + } + + // allocate memory from the chunk for this new interned string's data + byte *q_ptr = MP_STATE_VM(qstr_last_chunk) + MP_STATE_VM(qstr_last_used); + MP_STATE_VM(qstr_last_used) += n_bytes; + + // store the interned strings' data + mp_uint_t hash = qstr_compute_hash((const byte*)str, len); + Q_SET_HASH(q_ptr, hash); + Q_SET_LENGTH(q_ptr, len); + memcpy(q_ptr + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN, str, len); + q_ptr[MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len] = '\0'; + q = qstr_add(q_ptr); + } + QSTR_EXIT(); + return q; +} + +byte *qstr_build_start(size_t len, byte **q_ptr) { + assert(len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))); + *q_ptr = m_new(byte, MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len + 1); + Q_SET_LENGTH(*q_ptr, len); + return Q_GET_DATA(*q_ptr); +} + +qstr qstr_build_end(byte *q_ptr) { + QSTR_ENTER(); + qstr q = qstr_find_strn((const char*)Q_GET_DATA(q_ptr), Q_GET_LENGTH(q_ptr)); + if (q == 0) { + size_t len = Q_GET_LENGTH(q_ptr); + mp_uint_t hash = qstr_compute_hash(Q_GET_DATA(q_ptr), len); + Q_SET_HASH(q_ptr, hash); + q_ptr[MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len] = '\0'; + q = qstr_add(q_ptr); + } else { + m_del(byte, q_ptr, Q_GET_ALLOC(q_ptr)); + } + QSTR_EXIT(); + return q; +} + +mp_uint_t qstr_hash(qstr q) { + return Q_GET_HASH(find_qstr(q)); +} + +size_t qstr_len(qstr q) { + const byte *qd = find_qstr(q); + return Q_GET_LENGTH(qd); +} + +const char *qstr_str(qstr q) { + const byte *qd = find_qstr(q); + return (const char*)Q_GET_DATA(qd); +} + +const byte *qstr_data(qstr q, size_t *len) { + const byte *qd = find_qstr(q); + *len = Q_GET_LENGTH(qd); + return Q_GET_DATA(qd); +} + +void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, size_t *n_total_bytes) { + QSTR_ENTER(); + *n_pool = 0; + *n_qstr = 0; + *n_str_data_bytes = 0; + *n_total_bytes = 0; + for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL && pool != &CONST_POOL; pool = pool->prev) { + *n_pool += 1; + *n_qstr += pool->len; + for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { + *n_str_data_bytes += Q_GET_ALLOC(*q); + } + #if MICROPY_ENABLE_GC + *n_total_bytes += gc_nbytes(pool); // this counts actual bytes used in heap + #else + *n_total_bytes += sizeof(qstr_pool_t) + sizeof(qstr) * pool->alloc; + #endif + } + *n_total_bytes += *n_str_data_bytes; + QSTR_EXIT(); +} + +#if MICROPY_PY_MICROPYTHON_MEM_INFO +void qstr_dump_data(void) { + QSTR_ENTER(); + for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL && pool != &CONST_POOL; pool = pool->prev) { + for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { + mp_printf(&mp_plat_print, "Q(%s)\n", Q_GET_DATA(*q)); + } + } + QSTR_EXIT(); +} +#endif diff --git a/user/mpy/py/qstr.h b/user/mpy/py/qstr.h new file mode 100644 index 0000000..e2bdcc3 --- /dev/null +++ b/user/mpy/py/qstr.h @@ -0,0 +1,79 @@ +/* + * 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 + +#include "py/mpconfig.h" +#include "py/misc.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_static("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_QSTR_NULL=0, which indicates invalid/no qstr +enum { +#ifndef NO_QSTR +#define QDEF(id, str) id, +#include "genhdr/qstrdefs.generated.h" +#undef QDEF +#endif + 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_FROM_STR_STATIC(s) (qstr_from_strn((s), strlen(s))) + +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_QSTR_NULL if not found + +qstr qstr_from_str(const char *str); +qstr qstr_from_strn(const char *str, size_t len); + +byte *qstr_build_start(size_t len, byte **q_ptr); +qstr qstr_build_end(byte *q_ptr); + +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); + +#endif // MICROPY_INCLUDED_PY_QSTR_H diff --git a/user/mpy/py/qstrdefs.h b/user/mpy/py/qstrdefs.h new file mode 100644 index 0000000..9375b91 --- /dev/null +++ b/user/mpy/py/qstrdefs.h @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#include "py/mpconfig.h" + +// All the qstr definitions in this file are available as constants. +// That is, they are in ROM and you can reference them simply as MP_QSTR_xxxx. + +// qstr configuration passed to makeqstrdata.py of the form QCFG(key, value) +QCFG(BYTES_IN_LEN, MICROPY_QSTR_BYTES_IN_LEN) +QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH) + +Q() +Q(*) +Q(_) +Q(/) +Q(%#o) +Q(%#x) +Q({:#b}) +Q(\n) +Q(maximum recursion depth exceeded) +Q() +Q() +Q() +Q() +Q() +Q() +Q() +Q() +Q(utf-8) + +// The following qstrings not referenced from anywhere in the sources +Q(__locals__) +Q(BufferError) +Q(FileExistsError) +Q(FileNotFoundError) +Q(FloatingPointError) +Q(UnboundLocalError) diff --git a/user/mpy/py/reader.c b/user/mpy/py/reader.c new file mode 100644 index 0000000..c4d18d5 --- /dev/null +++ b/user/mpy/py/reader.c @@ -0,0 +1,135 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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. + */ + +#include +#include + +#include "py/runtime.h" +#include "py/mperrno.h" +#include "py/reader.h" + +typedef struct _mp_reader_mem_t { + size_t free_len; // if >0 mem is freed on close by: m_free(beg, free_len) + const byte *beg; + const byte *cur; + const byte *end; +} mp_reader_mem_t; + +STATIC mp_uint_t mp_reader_mem_readbyte(void *data) { + mp_reader_mem_t *reader = (mp_reader_mem_t*)data; + if (reader->cur < reader->end) { + return *reader->cur++; + } else { + return MP_READER_EOF; + } +} + +STATIC void mp_reader_mem_close(void *data) { + mp_reader_mem_t *reader = (mp_reader_mem_t*)data; + if (reader->free_len > 0) { + m_del(char, (char*)reader->beg, reader->free_len); + } + m_del_obj(mp_reader_mem_t, reader); +} + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len) { + mp_reader_mem_t *rm = m_new_obj(mp_reader_mem_t); + rm->free_len = free_len; + rm->beg = buf; + rm->cur = buf; + rm->end = buf + len; + reader->data = rm; + reader->readbyte = mp_reader_mem_readbyte; + reader->close = mp_reader_mem_close; +} + +#if MICROPY_READER_POSIX + +#include +#include +#include + +typedef struct _mp_reader_posix_t { + bool close_fd; + int fd; + size_t len; + size_t pos; + byte buf[20]; +} mp_reader_posix_t; + +STATIC mp_uint_t mp_reader_posix_readbyte(void *data) { + mp_reader_posix_t *reader = (mp_reader_posix_t*)data; + if (reader->pos >= reader->len) { + if (reader->len == 0) { + return MP_READER_EOF; + } else { + int n = read(reader->fd, reader->buf, sizeof(reader->buf)); + if (n <= 0) { + reader->len = 0; + return MP_READER_EOF; + } + reader->len = n; + reader->pos = 0; + } + } + return reader->buf[reader->pos++]; +} + +STATIC void mp_reader_posix_close(void *data) { + mp_reader_posix_t *reader = (mp_reader_posix_t*)data; + if (reader->close_fd) { + close(reader->fd); + } + m_del_obj(mp_reader_posix_t, reader); +} + +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, bool close_fd) { + mp_reader_posix_t *rp = m_new_obj(mp_reader_posix_t); + rp->close_fd = close_fd; + rp->fd = fd; + int n = read(rp->fd, rp->buf, sizeof(rp->buf)); + if (n == -1) { + if (close_fd) { + close(fd); + } + mp_raise_OSError(errno); + } + rp->len = n; + rp->pos = 0; + reader->data = rp; + reader->readbyte = mp_reader_posix_readbyte; + reader->close = mp_reader_posix_close; +} + +void mp_reader_new_file(mp_reader_t *reader, const char *filename) { + int fd = open(filename, O_RDONLY, 0644); + if (fd < 0) { + mp_raise_OSError(errno); + } + mp_reader_new_file_from_fd(reader, fd, true); +} + +#endif diff --git a/user/mpy/py/reader.h b/user/mpy/py/reader.h new file mode 100644 index 0000000..8511c72 --- /dev/null +++ b/user/mpy/py/reader.h @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 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_READER_H +#define MICROPY_INCLUDED_PY_READER_H + +#include "py/obj.h" + +// the readbyte function must return the next byte in the input stream +// it must return MP_READER_EOF if end of stream +// it can be called again after returning MP_READER_EOF, and in that case must return MP_READER_EOF +#define MP_READER_EOF ((mp_uint_t)(-1)) + +typedef struct _mp_reader_t { + void *data; + mp_uint_t (*readbyte)(void *data); + void (*close)(void *data); +} mp_reader_t; + +void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); +void mp_reader_new_file(mp_reader_t *reader, const char *filename); +void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, bool close_fd); + +#endif // MICROPY_INCLUDED_PY_READER_H diff --git a/user/mpy/py/repl.c b/user/mpy/py/repl.c new file mode 100644 index 0000000..7e8922e --- /dev/null +++ b/user/mpy/py/repl.c @@ -0,0 +1,278 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2015 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. + */ + +#include +#include "py/obj.h" +#include "py/runtime.h" +#include "py/repl.h" + +#if MICROPY_HELPER_REPL + +STATIC bool str_startswith_word(const char *str, const char *head) { + size_t i; + for (i = 0; str[i] && head[i]; i++) { + if (str[i] != head[i]) { + return false; + } + } + return head[i] == '\0' && (str[i] == '\0' || !unichar_isident(str[i])); +} + +bool mp_repl_continue_with_input(const char *input) { + // check for blank input + if (input[0] == '\0') { + return false; + } + + // check if input starts with a certain keyword + bool starts_with_compound_keyword = + input[0] == '@' + || str_startswith_word(input, "if") + || str_startswith_word(input, "while") + || str_startswith_word(input, "for") + || str_startswith_word(input, "try") + || str_startswith_word(input, "with") + || str_startswith_word(input, "def") + || str_startswith_word(input, "class") + #if MICROPY_PY_ASYNC_AWAIT + || str_startswith_word(input, "async") + #endif + ; + + // check for unmatched open bracket, quote or escape quote + #define Q_NONE (0) + #define Q_1_SINGLE (1) + #define Q_1_DOUBLE (2) + #define Q_3_SINGLE (3) + #define Q_3_DOUBLE (4) + int n_paren = 0; + int n_brack = 0; + int n_brace = 0; + int in_quote = Q_NONE; + const char *i; + for (i = input; *i; i++) { + if (*i == '\'') { + if ((in_quote == Q_NONE || in_quote == Q_3_SINGLE) && i[1] == '\'' && i[2] == '\'') { + i += 2; + in_quote = Q_3_SINGLE - in_quote; + } else if (in_quote == Q_NONE || in_quote == Q_1_SINGLE) { + in_quote = Q_1_SINGLE - in_quote; + } + } else if (*i == '"') { + if ((in_quote == Q_NONE || in_quote == Q_3_DOUBLE) && i[1] == '"' && i[2] == '"') { + i += 2; + in_quote = Q_3_DOUBLE - in_quote; + } else if (in_quote == Q_NONE || in_quote == Q_1_DOUBLE) { + in_quote = Q_1_DOUBLE - in_quote; + } + } else if (*i == '\\' && (i[1] == '\'' || i[1] == '"' || i[1] == '\\')) { + if (in_quote != Q_NONE) { + i++; + } + } else if (in_quote == Q_NONE) { + switch (*i) { + case '(': n_paren += 1; break; + case ')': n_paren -= 1; break; + case '[': n_brack += 1; break; + case ']': n_brack -= 1; break; + case '{': n_brace += 1; break; + case '}': n_brace -= 1; break; + default: break; + } + } + } + + // continue if unmatched brackets or quotes + if (n_paren > 0 || n_brack > 0 || n_brace > 0 || in_quote == Q_3_SINGLE || in_quote == Q_3_DOUBLE) { + return true; + } + + // continue if last character was backslash (for line continuation) + if (i[-1] == '\\') { + return true; + } + + // continue if compound keyword and last line was not empty + if (starts_with_compound_keyword && i[-1] != '\n') { + return true; + } + + // otherwise, don't continue + return false; +} + +size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str) { + // scan backwards to find start of "a.b.c" chain + const char *org_str = str; + const char *top = str + len; + for (const char *s = top; --s >= str;) { + if (!(unichar_isalpha(*s) || unichar_isdigit(*s) || *s == '_' || *s == '.')) { + ++s; + str = s; + break; + } + } + + // begin search in locals dict + mp_obj_dict_t *dict = mp_locals_get(); + + for (;;) { + // get next word in string to complete + const char *s_start = str; + while (str < top && *str != '.') { + ++str; + } + size_t s_len = str - s_start; + + if (str < top) { + // a complete word, lookup in current dict + + mp_obj_t obj = MP_OBJ_NULL; + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + size_t d_len; + const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); + if (s_len == d_len && strncmp(s_start, d_str, d_len) == 0) { + obj = dict->map.table[i].value; + break; + } + } + } + + if (obj == MP_OBJ_NULL) { + // lookup failed + return 0; + } + + // found an object of this name; try to get its dict + if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) { + dict = mp_obj_module_get_globals(obj); + } else { + mp_obj_type_t *type; + if (MP_OBJ_IS_TYPE(obj, &mp_type_type)) { + type = MP_OBJ_TO_PTR(obj); + } else { + type = mp_obj_get_type(obj); + } + if (type->locals_dict != NULL && type->locals_dict->base.type == &mp_type_dict) { + dict = type->locals_dict; + } else { + // obj has no dict + return 0; + } + } + + // skip '.' to move to next word + ++str; + + } else { + // end of string, do completion on this partial name + + // look for matches + int n_found = 0; + const char *match_str = NULL; + size_t match_len = 0; + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + size_t d_len; + const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); + if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { + if (match_str == NULL) { + match_str = d_str; + match_len = d_len; + } else { + // search for longest common prefix of match_str and d_str + // (assumes these strings are null-terminated) + for (size_t j = s_len; j <= match_len && j <= d_len; ++j) { + if (match_str[j] != d_str[j]) { + match_len = j; + break; + } + } + } + ++n_found; + } + } + } + + // nothing found + if (n_found == 0) { + // If there're no better alternatives, and if it's first word + // in the line, try to complete "import". + if (s_start == org_str) { + static const char import_str[] = "import "; + if (memcmp(s_start, import_str, s_len) == 0) { + *compl_str = import_str + s_len; + return sizeof(import_str) - 1 - s_len; + } + } + + return 0; + } + + // 1 match found, or multiple matches with a common prefix + if (n_found == 1 || match_len > s_len) { + *compl_str = match_str + s_len; + return match_len - s_len; + } + + // multiple matches found, print them out + + #define WORD_SLOT_LEN (16) + #define MAX_LINE_LEN (4 * WORD_SLOT_LEN) + + int line_len = MAX_LINE_LEN; // force a newline for first word + for (size_t i = 0; i < dict->map.alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { + size_t d_len; + const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); + if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { + int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len; + if (gap < 2) { + gap += WORD_SLOT_LEN; + } + if (line_len + gap + d_len <= MAX_LINE_LEN) { + // TODO optimise printing of gap? + for (int j = 0; j < gap; ++j) { + mp_print_str(print, " "); + } + mp_print_str(print, d_str); + line_len += gap + d_len; + } else { + mp_printf(print, "\n%s", d_str); + line_len = d_len; + } + } + } + } + mp_print_str(print, "\n"); + + return (size_t)(-1); // indicate many matches + } + } +} + +#endif // MICROPY_HELPER_REPL diff --git a/user/mpy/py/repl.h b/user/mpy/py/repl.h new file mode 100644 index 0000000..a7a4136 --- /dev/null +++ b/user/mpy/py/repl.h @@ -0,0 +1,38 @@ +/* + * 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_REPL_H +#define MICROPY_INCLUDED_PY_REPL_H + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/mpprint.h" + +#if MICROPY_HELPER_REPL +bool mp_repl_continue_with_input(const char *input); +size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str); +#endif + +#endif // MICROPY_INCLUDED_PY_REPL_H diff --git a/user/mpy/py/ringbuf.h b/user/mpy/py/ringbuf.h new file mode 100644 index 0000000..b416927 --- /dev/null +++ b/user/mpy/py/ringbuf.h @@ -0,0 +1,72 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ +#ifndef MICROPY_INCLUDED_PY_RINGBUF_H +#define MICROPY_INCLUDED_PY_RINGBUF_H + +typedef struct _ringbuf_t { + uint8_t *buf; + uint16_t size; + uint16_t iget; + uint16_t iput; +} ringbuf_t; + +// Static initialization: +// byte buf_array[N]; +// ringbuf_t buf = {buf_array, sizeof(buf_array)}; + +// Dynamic initialization. This creates root pointer! +#define ringbuf_alloc(r, sz) \ +{ \ + (r)->buf = m_new(uint8_t, sz); \ + (r)->size = sz; \ + (r)->iget = (r)->iput = 0; \ +} + +static inline int ringbuf_get(ringbuf_t *r) { + if (r->iget == r->iput) { + return -1; + } + uint8_t v = r->buf[r->iget++]; + if (r->iget >= r->size) { + r->iget = 0; + } + return v; +} + +static inline int ringbuf_put(ringbuf_t *r, uint8_t v) { + uint32_t iput_new = r->iput + 1; + if (iput_new >= r->size) { + iput_new = 0; + } + if (iput_new == r->iget) { + return -1; + } + r->buf[r->iput] = v; + r->iput = iput_new; + return 0; +} + +#endif // MICROPY_INCLUDED_PY_RINGBUF_H diff --git a/user/mpy/py/runtime.c b/user/mpy/py/runtime.c new file mode 100644 index 0000000..eb12988 --- /dev/null +++ b/user/mpy/py/runtime.c @@ -0,0 +1,1444 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpstate.h" +#include "py/nlr.h" +#include "py/parsenum.h" +#include "py/compile.h" +#include "py/objstr.h" +#include "py/objtuple.h" +#include "py/objlist.h" +#include "py/objmodule.h" +#include "py/objgenerator.h" +#include "py/smallint.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/stackctrl.h" +#include "py/gc.h" + +#if MICROPY_DEBUG_VERBOSE // print debugging info +#define DEBUG_PRINT (1) +#define DEBUG_printf DEBUG_printf +#define DEBUG_OP_printf(...) DEBUG_printf(__VA_ARGS__) +#else // don't print debugging info +#define DEBUG_printf(...) (void)0 +#define DEBUG_OP_printf(...) (void)0 +#endif + +const mp_obj_module_t mp_module___main__ = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&MP_STATE_VM(dict_main), +}; + +void mp_init(void) { + qstr_init(); + + // no pending exceptions to start with + MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + #if MICROPY_ENABLE_SCHEDULER + MP_STATE_VM(sched_state) = MP_SCHED_IDLE; + MP_STATE_VM(sched_sp) = 0; + #endif + +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF + mp_init_emergency_exception_buf(); +#endif + + #if MICROPY_KBD_EXCEPTION + // initialise the exception object for raising KeyboardInterrupt + MP_STATE_VM(mp_kbd_exception).base.type = &mp_type_KeyboardInterrupt; + MP_STATE_VM(mp_kbd_exception).traceback_alloc = 0; + MP_STATE_VM(mp_kbd_exception).traceback_len = 0; + MP_STATE_VM(mp_kbd_exception).traceback_data = NULL; + MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; + #endif + + // call port specific initialization if any +#ifdef MICROPY_PORT_INIT_FUNC + MICROPY_PORT_INIT_FUNC; +#endif + + // optimization disabled by default + MP_STATE_VM(mp_optimise_value) = 0; + + // init global module dict + mp_obj_dict_init(&MP_STATE_VM(mp_loaded_modules_dict), 3); + + // initialise the __main__ module + mp_obj_dict_init(&MP_STATE_VM(dict_main), 1); + mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(dict_main)), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + + // locals = globals for outer module (see Objects/frameobject.c/PyFrame_New()) + mp_locals_set(&MP_STATE_VM(dict_main)); + mp_globals_set(&MP_STATE_VM(dict_main)); + + #if MICROPY_CAN_OVERRIDE_BUILTINS + // start with no extensions to builtins + MP_STATE_VM(mp_module_builtins_override_dict) = NULL; + #endif + + #if MICROPY_FSUSERMOUNT + // zero out the pointers to the user-mounted devices + memset(MP_STATE_VM(fs_user_mount), 0, sizeof(MP_STATE_VM(fs_user_mount))); + #endif + + #if MICROPY_VFS + // initialise the VFS sub-system + MP_STATE_VM(vfs_cur) = NULL; + MP_STATE_VM(vfs_mount_table) = NULL; + #endif + + #if MICROPY_PY_THREAD_GIL + mp_thread_mutex_init(&MP_STATE_VM(gil_mutex)); + #endif + + MP_THREAD_GIL_ENTER(); +} + +void mp_deinit(void) { + //mp_obj_dict_free(&dict_main); + //mp_map_deinit(&MP_STATE_VM(mp_loaded_modules_map)); + + // call port specific deinitialization if any +#ifdef MICROPY_PORT_INIT_FUNC + MICROPY_PORT_DEINIT_FUNC; +#endif +} + +mp_obj_t mp_load_name(qstr qst) { + // logic: search locals, globals, builtins + DEBUG_OP_printf("load name %s\n", qstr_str(qst)); + // If we're at the outer scope (locals == globals), dispatch to load_global right away + if (mp_locals_get() != mp_globals_get()) { + mp_map_elem_t *elem = mp_map_lookup(&mp_locals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); + if (elem != NULL) { + return elem->value; + } + } + return mp_load_global(qst); +} + +mp_obj_t mp_load_global(qstr qst) { + // logic: search globals, builtins + DEBUG_OP_printf("load global %s\n", qstr_str(qst)); + mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); + if (elem == NULL) { + #if MICROPY_CAN_OVERRIDE_BUILTINS + if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) { + // lookup in additional dynamic table of builtins first + elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); + if (elem != NULL) { + return elem->value; + } + } + #endif + elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); + if (elem == NULL) { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_msg(&mp_type_NameError, "name not defined"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError, + "name '%q' is not defined", qst)); + } + } + } + return elem->value; +} + +mp_obj_t mp_load_build_class(void) { + DEBUG_OP_printf("load_build_class\n"); + #if MICROPY_CAN_OVERRIDE_BUILTINS + if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) { + // lookup in additional dynamic table of builtins first + mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(MP_QSTR___build_class__), MP_MAP_LOOKUP); + if (elem != NULL) { + return elem->value; + } + } + #endif + return MP_OBJ_FROM_PTR(&mp_builtin___build_class___obj); +} + +void mp_store_name(qstr qst, mp_obj_t obj) { + DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qst), obj); + mp_obj_dict_store(MP_OBJ_FROM_PTR(mp_locals_get()), MP_OBJ_NEW_QSTR(qst), obj); +} + +void mp_delete_name(qstr qst) { + DEBUG_OP_printf("delete name %s\n", qstr_str(qst)); + // TODO convert KeyError to NameError if qst not found + mp_obj_dict_delete(MP_OBJ_FROM_PTR(mp_locals_get()), MP_OBJ_NEW_QSTR(qst)); +} + +void mp_store_global(qstr qst, mp_obj_t obj) { + DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qst), obj); + mp_obj_dict_store(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(qst), obj); +} + +void mp_delete_global(qstr qst) { + DEBUG_OP_printf("delete global %s\n", qstr_str(qst)); + // TODO convert KeyError to NameError if qst not found + mp_obj_dict_delete(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(qst)); +} + +mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) { + DEBUG_OP_printf("unary " UINT_FMT " %p\n", op, arg); + + if (op == MP_UNARY_OP_NOT) { + // "not x" is the negative of whether "x" is true per Python semantics + return mp_obj_new_bool(mp_obj_is_true(arg) == 0); + } else if (MP_OBJ_IS_SMALL_INT(arg)) { + mp_int_t val = MP_OBJ_SMALL_INT_VALUE(arg); + switch (op) { + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(val != 0); + case MP_UNARY_OP_HASH: + return arg; + case MP_UNARY_OP_POSITIVE: + return arg; + case MP_UNARY_OP_NEGATIVE: + // check for overflow + if (val == MP_SMALL_INT_MIN) { + return mp_obj_new_int(-val); + } else { + return MP_OBJ_NEW_SMALL_INT(-val); + } + default: + assert(op == MP_UNARY_OP_INVERT); + return MP_OBJ_NEW_SMALL_INT(~val); + } + } else if (op == MP_UNARY_OP_HASH && MP_OBJ_IS_STR_OR_BYTES(arg)) { + // fast path for hashing str/bytes + GET_STR_HASH(arg, h); + if (h == 0) { + GET_STR_DATA_LEN(arg, data, len); + h = qstr_compute_hash(data, len); + } + return MP_OBJ_NEW_SMALL_INT(h); + } else { + mp_obj_type_t *type = mp_obj_get_type(arg); + if (type->unary_op != NULL) { + mp_obj_t result = type->unary_op(op, arg); + if (result != MP_OBJ_NULL) { + return result; + } + } + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("unsupported type for operator"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "unsupported type for %q: '%s'", + mp_unary_op_method_name[op], mp_obj_get_type_str(arg))); + } + } +} + +mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { + DEBUG_OP_printf("binary " UINT_FMT " %p %p\n", op, lhs, rhs); + + // TODO correctly distinguish inplace operators for mutable objects + // lookup logic that CPython uses for +=: + // check for implemented += + // then check for implemented + + // then check for implemented seq.inplace_concat + // then check for implemented seq.concat + // then fail + // note that list does not implement + or +=, so that inplace_concat is reached first for += + + // deal with is + if (op == MP_BINARY_OP_IS) { + return mp_obj_new_bool(lhs == rhs); + } + + // deal with == and != for all types + if (op == MP_BINARY_OP_EQUAL || op == MP_BINARY_OP_NOT_EQUAL) { + if (mp_obj_equal(lhs, rhs)) { + if (op == MP_BINARY_OP_EQUAL) { + return mp_const_true; + } else { + return mp_const_false; + } + } else { + if (op == MP_BINARY_OP_EQUAL) { + return mp_const_false; + } else { + return mp_const_true; + } + } + } + + // deal with exception_match for all types + if (op == MP_BINARY_OP_EXCEPTION_MATCH) { + // rhs must be issubclass(rhs, BaseException) + if (mp_obj_is_exception_type(rhs)) { + if (mp_obj_exception_match(lhs, rhs)) { + return mp_const_true; + } else { + return mp_const_false; + } + } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_tuple)) { + mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(rhs); + for (size_t i = 0; i < tuple->len; i++) { + rhs = tuple->items[i]; + if (!mp_obj_is_exception_type(rhs)) { + goto unsupported_op; + } + if (mp_obj_exception_match(lhs, rhs)) { + return mp_const_true; + } + } + return mp_const_false; + } + goto unsupported_op; + } + + if (MP_OBJ_IS_SMALL_INT(lhs)) { + mp_int_t lhs_val = MP_OBJ_SMALL_INT_VALUE(lhs); + if (MP_OBJ_IS_SMALL_INT(rhs)) { + mp_int_t rhs_val = MP_OBJ_SMALL_INT_VALUE(rhs); + // This is a binary operation: lhs_val op rhs_val + // We need to be careful to handle overflow; see CERT INT32-C + // Operations that can overflow: + // + result always fits in mp_int_t, then handled by SMALL_INT check + // - result always fits in mp_int_t, then handled by SMALL_INT check + // * checked explicitly + // / if lhs=MIN and rhs=-1; result always fits in mp_int_t, then handled by SMALL_INT check + // % if lhs=MIN and rhs=-1; result always fits in mp_int_t, then handled by SMALL_INT check + // << checked explicitly + switch (op) { + case MP_BINARY_OP_OR: + case MP_BINARY_OP_INPLACE_OR: lhs_val |= rhs_val; break; + case MP_BINARY_OP_XOR: + case MP_BINARY_OP_INPLACE_XOR: lhs_val ^= rhs_val; break; + case MP_BINARY_OP_AND: + case MP_BINARY_OP_INPLACE_AND: lhs_val &= rhs_val; break; + case MP_BINARY_OP_LSHIFT: + case MP_BINARY_OP_INPLACE_LSHIFT: { + if (rhs_val < 0) { + // negative shift not allowed + mp_raise_ValueError("negative shift count"); + } else if (rhs_val >= (mp_int_t)BITS_PER_WORD || lhs_val > (MP_SMALL_INT_MAX >> rhs_val) || lhs_val < (MP_SMALL_INT_MIN >> rhs_val)) { + // left-shift will overflow, so use higher precision integer + lhs = mp_obj_new_int_from_ll(lhs_val); + goto generic_binary_op; + } else { + // use standard precision + lhs_val <<= rhs_val; + } + break; + } + case MP_BINARY_OP_RSHIFT: + case MP_BINARY_OP_INPLACE_RSHIFT: + if (rhs_val < 0) { + // negative shift not allowed + mp_raise_ValueError("negative shift count"); + } else { + // standard precision is enough for right-shift + if (rhs_val >= (mp_int_t)BITS_PER_WORD) { + // Shifting to big amounts is underfined behavior + // in C and is CPU-dependent; propagate sign bit. + rhs_val = BITS_PER_WORD - 1; + } + lhs_val >>= rhs_val; + } + break; + case MP_BINARY_OP_ADD: + case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break; + case MP_BINARY_OP_SUBTRACT: + case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break; + case MP_BINARY_OP_MULTIPLY: + case MP_BINARY_OP_INPLACE_MULTIPLY: { + + // If long long type exists and is larger than mp_int_t, then + // we can use the following code to perform overflow-checked multiplication. + // Otherwise (eg in x64 case) we must use mp_small_int_mul_overflow. + #if 0 + // compute result using long long precision + long long res = (long long)lhs_val * (long long)rhs_val; + if (res > MP_SMALL_INT_MAX || res < MP_SMALL_INT_MIN) { + // result overflowed SMALL_INT, so return higher precision integer + return mp_obj_new_int_from_ll(res); + } else { + // use standard precision + lhs_val = (mp_int_t)res; + } + #endif + + if (mp_small_int_mul_overflow(lhs_val, rhs_val)) { + // use higher precision + lhs = mp_obj_new_int_from_ll(lhs_val); + goto generic_binary_op; + } else { + // use standard precision + return MP_OBJ_NEW_SMALL_INT(lhs_val * rhs_val); + } + break; + } + case MP_BINARY_OP_FLOOR_DIVIDE: + case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: + if (rhs_val == 0) { + goto zero_division; + } + lhs_val = mp_small_int_floor_divide(lhs_val, rhs_val); + break; + + #if MICROPY_PY_BUILTINS_FLOAT + case MP_BINARY_OP_TRUE_DIVIDE: + case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: + if (rhs_val == 0) { + goto zero_division; + } + return mp_obj_new_float((mp_float_t)lhs_val / (mp_float_t)rhs_val); + #endif + + case MP_BINARY_OP_MODULO: + case MP_BINARY_OP_INPLACE_MODULO: { + if (rhs_val == 0) { + goto zero_division; + } + lhs_val = mp_small_int_modulo(lhs_val, rhs_val); + break; + } + + case MP_BINARY_OP_POWER: + case MP_BINARY_OP_INPLACE_POWER: + if (rhs_val < 0) { + #if MICROPY_PY_BUILTINS_FLOAT + lhs = mp_obj_new_float(lhs_val); + goto generic_binary_op; + #else + mp_raise_ValueError("negative power with no float support"); + #endif + } else { + mp_int_t ans = 1; + while (rhs_val > 0) { + if (rhs_val & 1) { + if (mp_small_int_mul_overflow(ans, lhs_val)) { + goto power_overflow; + } + ans *= lhs_val; + } + if (rhs_val == 1) { + break; + } + rhs_val /= 2; + if (mp_small_int_mul_overflow(lhs_val, lhs_val)) { + goto power_overflow; + } + lhs_val *= lhs_val; + } + lhs_val = ans; + } + break; + + power_overflow: + // use higher precision + lhs = mp_obj_new_int_from_ll(MP_OBJ_SMALL_INT_VALUE(lhs)); + goto generic_binary_op; + + case MP_BINARY_OP_DIVMOD: { + if (rhs_val == 0) { + goto zero_division; + } + // to reduce stack usage we don't pass a temp array of the 2 items + mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL)); + tuple->items[0] = MP_OBJ_NEW_SMALL_INT(mp_small_int_floor_divide(lhs_val, rhs_val)); + tuple->items[1] = MP_OBJ_NEW_SMALL_INT(mp_small_int_modulo(lhs_val, rhs_val)); + return MP_OBJ_FROM_PTR(tuple); + } + + case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val); break; + case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val); break; + case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val); break; + case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val); break; + + default: + goto unsupported_op; + } + // TODO: We just should make mp_obj_new_int() inline and use that + if (MP_SMALL_INT_FITS(lhs_val)) { + return MP_OBJ_NEW_SMALL_INT(lhs_val); + } else { + return mp_obj_new_int(lhs_val); + } +#if MICROPY_PY_BUILTINS_FLOAT + } else if (mp_obj_is_float(rhs)) { + mp_obj_t res = mp_obj_float_binary_op(op, lhs_val, rhs); + if (res == MP_OBJ_NULL) { + goto unsupported_op; + } else { + return res; + } +#if MICROPY_PY_BUILTINS_COMPLEX + } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_complex)) { + mp_obj_t res = mp_obj_complex_binary_op(op, lhs_val, 0, rhs); + if (res == MP_OBJ_NULL) { + goto unsupported_op; + } else { + return res; + } +#endif +#endif + } + } + + /* deal with `in` + * + * NOTE `a in b` is `b.__contains__(a)`, hence why the generic dispatch + * needs to go below with swapped arguments + */ + if (op == MP_BINARY_OP_IN) { + mp_obj_type_t *type = mp_obj_get_type(rhs); + if (type->binary_op != NULL) { + mp_obj_t res = type->binary_op(op, rhs, lhs); + if (res != MP_OBJ_NULL) { + return res; + } + } + if (type->getiter != NULL) { + /* second attempt, walk the iterator */ + mp_obj_iter_buf_t iter_buf; + mp_obj_t iter = mp_getiter(rhs, &iter_buf); + mp_obj_t next; + while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { + if (mp_obj_equal(next, lhs)) { + return mp_const_true; + } + } + return mp_const_false; + } + + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object not iterable"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not iterable", mp_obj_get_type_str(rhs))); + } + } + + // generic binary_op supplied by type + mp_obj_type_t *type; +generic_binary_op: + type = mp_obj_get_type(lhs); + if (type->binary_op != NULL) { + mp_obj_t result = type->binary_op(op, lhs, rhs); + if (result != MP_OBJ_NULL) { + return result; + } + } + + // TODO implement dispatch for reverse binary ops + +unsupported_op: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("unsupported type for operator"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "unsupported types for %q: '%s', '%s'", + mp_binary_op_method_name[op], mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs))); + } + +zero_division: + mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); +} + +mp_obj_t mp_call_function_0(mp_obj_t fun) { + return mp_call_function_n_kw(fun, 0, 0, NULL); +} + +mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg) { + return mp_call_function_n_kw(fun, 1, 0, &arg); +} + +mp_obj_t mp_call_function_2(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { + mp_obj_t args[2]; + args[0] = arg1; + args[1] = arg2; + return mp_call_function_n_kw(fun, 2, 0, args); +} + +// args contains, eg: arg0 arg1 key0 value0 key1 value1 +mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + // TODO improve this: fun object can specify its type and we parse here the arguments, + // passing to the function arrays of fixed and keyword arguments + + DEBUG_OP_printf("calling function %p(n_args=" UINT_FMT ", n_kw=" UINT_FMT ", args=%p)\n", fun_in, n_args, n_kw, args); + + // get the type + mp_obj_type_t *type = mp_obj_get_type(fun_in); + + // do the call + if (type->call != NULL) { + return type->call(fun_in, n_args, n_kw, args); + } + + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object not callable"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not callable", mp_obj_get_type_str(fun_in))); + } +} + +// args contains: fun self/NULL arg(0) ... arg(n_args-2) arg(n_args-1) kw_key(0) kw_val(0) ... kw_key(n_kw-1) kw_val(n_kw-1) +// if n_args==0 and n_kw==0 then there are only fun and self/NULL +mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args) { + DEBUG_OP_printf("call method (fun=%p, self=%p, n_args=" UINT_FMT ", n_kw=" UINT_FMT ", args=%p)\n", args[0], args[1], n_args, n_kw, args); + int adjust = (args[1] == MP_OBJ_NULL) ? 0 : 1; + return mp_call_function_n_kw(args[0], n_args + adjust, n_kw, args + 2 - adjust); +} + +// This function only needs to be exposed externally when in stackless mode. +#if !MICROPY_STACKLESS +STATIC +#endif +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) { + mp_obj_t fun = *args++; + mp_obj_t self = MP_OBJ_NULL; + if (have_self) { + self = *args++; // may be MP_OBJ_NULL + } + uint n_args = n_args_n_kw & 0xff; + uint n_kw = (n_args_n_kw >> 8) & 0xff; + mp_obj_t pos_seq = args[n_args + 2 * n_kw]; // may be MP_OBJ_NULL + mp_obj_t kw_dict = args[n_args + 2 * n_kw + 1]; // may be MP_OBJ_NULL + + DEBUG_OP_printf("call method var (fun=%p, self=%p, n_args=%u, n_kw=%u, args=%p, seq=%p, dict=%p)\n", fun, self, n_args, n_kw, args, pos_seq, kw_dict); + + // We need to create the following array of objects: + // args[0 .. n_args] unpacked(pos_seq) args[n_args .. n_args + 2 * n_kw] unpacked(kw_dict) + // TODO: optimize one day to avoid constructing new arg array? Will be hard. + + // The new args array + mp_obj_t *args2; + uint args2_alloc; + uint args2_len = 0; + + // Try to get a hint for the size of the kw_dict + uint kw_dict_len = 0; + if (kw_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(kw_dict, &mp_type_dict)) { + kw_dict_len = mp_obj_dict_len(kw_dict); + } + + // Extract the pos_seq sequence to the new args array. + // Note that it can be arbitrary iterator. + if (pos_seq == MP_OBJ_NULL) { + // no sequence + + // allocate memory for the new array of args + args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len); + args2 = m_new(mp_obj_t, args2_alloc); + + // copy the self + if (self != MP_OBJ_NULL) { + args2[args2_len++] = self; + } + + // copy the fixed pos args + mp_seq_copy(args2 + args2_len, args, n_args, mp_obj_t); + args2_len += n_args; + + } else if (MP_OBJ_IS_TYPE(pos_seq, &mp_type_tuple) || MP_OBJ_IS_TYPE(pos_seq, &mp_type_list)) { + // optimise the case of a tuple and list + + // get the items + size_t len; + mp_obj_t *items; + mp_obj_get_array(pos_seq, &len, &items); + + // allocate memory for the new array of args + args2_alloc = 1 + n_args + len + 2 * (n_kw + kw_dict_len); + args2 = m_new(mp_obj_t, args2_alloc); + + // copy the self + if (self != MP_OBJ_NULL) { + args2[args2_len++] = self; + } + + // copy the fixed and variable position args + mp_seq_cat(args2 + args2_len, args, n_args, items, len, mp_obj_t); + args2_len += n_args + len; + + } else { + // generic iterator + + // allocate memory for the new array of args + args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len) + 3; + args2 = m_new(mp_obj_t, args2_alloc); + + // copy the self + if (self != MP_OBJ_NULL) { + args2[args2_len++] = self; + } + + // copy the fixed position args + mp_seq_copy(args2 + args2_len, args, n_args, mp_obj_t); + args2_len += n_args; + + // extract the variable position args from the iterator + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(pos_seq, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (args2_len >= args2_alloc) { + args2 = m_renew(mp_obj_t, args2, args2_alloc, args2_alloc * 2); + args2_alloc *= 2; + } + args2[args2_len++] = item; + } + } + + // The size of the args2 array now is the number of positional args. + uint pos_args_len = args2_len; + + // Copy the fixed kw args. + mp_seq_copy(args2 + args2_len, args + n_args, 2 * n_kw, mp_obj_t); + args2_len += 2 * n_kw; + + // Extract (key,value) pairs from kw_dict dictionary and append to args2. + // Note that it can be arbitrary iterator. + if (kw_dict == MP_OBJ_NULL) { + // pass + } else if (MP_OBJ_IS_TYPE(kw_dict, &mp_type_dict)) { + // dictionary + mp_map_t *map = mp_obj_dict_get_map(kw_dict); + assert(args2_len + 2 * map->used <= args2_alloc); // should have enough, since kw_dict_len is in this case hinted correctly above + for (size_t i = 0; i < map->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + // the key must be a qstr, so intern it if it's a string + mp_obj_t key = map->table[i].key; + if (MP_OBJ_IS_TYPE(key, &mp_type_str)) { + key = mp_obj_str_intern(key); + } + args2[args2_len++] = key; + args2[args2_len++] = map->table[i].value; + } + } + } else { + // generic mapping: + // - call keys() to get an iterable of all keys in the mapping + // - call __getitem__ for each key to get the corresponding value + + // get the keys iterable + mp_obj_t dest[3]; + mp_load_method(kw_dict, MP_QSTR_keys, dest); + mp_obj_t iterable = mp_getiter(mp_call_method_n_kw(0, 0, dest), NULL); + + mp_obj_t key; + while ((key = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + // expand size of args array if needed + if (args2_len + 1 >= args2_alloc) { + uint new_alloc = args2_alloc * 2; + if (new_alloc < 4) { + new_alloc = 4; + } + args2 = m_renew(mp_obj_t, args2, args2_alloc, new_alloc); + args2_alloc = new_alloc; + } + + // the key must be a qstr, so intern it if it's a string + if (MP_OBJ_IS_TYPE(key, &mp_type_str)) { + key = mp_obj_str_intern(key); + } + + // get the value corresponding to the key + mp_load_method(kw_dict, MP_QSTR___getitem__, dest); + dest[2] = key; + mp_obj_t value = mp_call_method_n_kw(1, 0, dest); + + // store the key/value pair in the argument array + args2[args2_len++] = key; + args2[args2_len++] = value; + } + } + + out_args->fun = fun; + out_args->args = args2; + out_args->n_args = pos_args_len; + out_args->n_kw = (args2_len - pos_args_len) / 2; + out_args->n_alloc = args2_alloc; +} + +mp_obj_t mp_call_method_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args) { + mp_call_args_t out_args; + mp_call_prepare_args_n_kw_var(have_self, n_args_n_kw, args, &out_args); + + mp_obj_t res = mp_call_function_n_kw(out_args.fun, out_args.n_args, out_args.n_kw, out_args.args); + m_del(mp_obj_t, out_args.args, out_args.n_alloc); + + return res; +} + +// unpacked items are stored in reverse order into the array pointed to by items +void mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) { + size_t seq_len; + if (MP_OBJ_IS_TYPE(seq_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(seq_in, &mp_type_list)) { + mp_obj_t *seq_items; + mp_obj_get_array(seq_in, &seq_len, &seq_items); + if (seq_len < num) { + goto too_short; + } else if (seq_len > num) { + goto too_long; + } + for (size_t i = 0; i < num; i++) { + items[i] = seq_items[num - 1 - i]; + } + } else { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(seq_in, &iter_buf); + + for (seq_len = 0; seq_len < num; seq_len++) { + mp_obj_t el = mp_iternext(iterable); + if (el == MP_OBJ_STOP_ITERATION) { + goto too_short; + } + items[num - 1 - seq_len] = el; + } + if (mp_iternext(iterable) != MP_OBJ_STOP_ITERATION) { + goto too_long; + } + } + return; + +too_short: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_ValueError("wrong number of values to unpack"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "need more than %d values to unpack", (int)seq_len)); + } +too_long: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_ValueError("wrong number of values to unpack"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "too many values to unpack (expected %d)", (int)num)); + } +} + +// unpacked items are stored in reverse order into the array pointed to by items +void mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) { + size_t num_left = num_in & 0xff; + size_t num_right = (num_in >> 8) & 0xff; + DEBUG_OP_printf("unpack ex " UINT_FMT " " UINT_FMT "\n", num_left, num_right); + size_t seq_len; + if (MP_OBJ_IS_TYPE(seq_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(seq_in, &mp_type_list)) { + mp_obj_t *seq_items; + mp_obj_get_array(seq_in, &seq_len, &seq_items); + if (seq_len < num_left + num_right) { + goto too_short; + } + for (size_t i = 0; i < num_right; i++) { + items[i] = seq_items[seq_len - 1 - i]; + } + items[num_right] = mp_obj_new_list(seq_len - num_left - num_right, seq_items + num_left); + for (size_t i = 0; i < num_left; i++) { + items[num_right + 1 + i] = seq_items[num_left - 1 - i]; + } + } else { + // Generic iterable; this gets a bit messy: we unpack known left length to the + // items destination array, then the rest to a dynamically created list. Once the + // iterable is exhausted, we take from this list for the right part of the items. + // TODO Improve to waste less memory in the dynamically created list. + mp_obj_t iterable = mp_getiter(seq_in, NULL); + mp_obj_t item; + for (seq_len = 0; seq_len < num_left; seq_len++) { + item = mp_iternext(iterable); + if (item == MP_OBJ_STOP_ITERATION) { + goto too_short; + } + items[num_left + num_right + 1 - 1 - seq_len] = item; + } + mp_obj_list_t *rest = MP_OBJ_TO_PTR(mp_obj_new_list(0, NULL)); + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + mp_obj_list_append(MP_OBJ_FROM_PTR(rest), item); + } + if (rest->len < num_right) { + goto too_short; + } + items[num_right] = MP_OBJ_FROM_PTR(rest); + for (size_t i = 0; i < num_right; i++) { + items[num_right - 1 - i] = rest->items[rest->len - num_right + i]; + } + mp_obj_list_set_len(MP_OBJ_FROM_PTR(rest), rest->len - num_right); + } + return; + +too_short: + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_ValueError("wrong number of values to unpack"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "need more than %d values to unpack", (int)seq_len)); + } +} + +mp_obj_t mp_load_attr(mp_obj_t base, qstr attr) { + DEBUG_OP_printf("load attr %p.%s\n", base, qstr_str(attr)); + // use load_method + mp_obj_t dest[2]; + mp_load_method(base, attr, dest); + if (dest[1] == MP_OBJ_NULL) { + // load_method returned just a normal attribute + return dest[0]; + } else { + // load_method returned a method, so build a bound method object + return mp_obj_new_bound_meth(dest[0], dest[1]); + } +} + +#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG + +// The following "checked fun" type is local to the mp_convert_member_lookup +// function, and serves to check that the first argument to a builtin function +// has the correct type. + +typedef struct _mp_obj_checked_fun_t { + mp_obj_base_t base; + const mp_obj_type_t *type; + mp_obj_t fun; +} mp_obj_checked_fun_t; + +STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_obj_checked_fun_t *self = MP_OBJ_TO_PTR(self_in); + if (n_args > 0) { + const mp_obj_type_t *arg0_type = mp_obj_get_type(args[0]); + if (arg0_type != self->type) { + if (MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_DETAILED) { + mp_raise_TypeError("argument has wrong type"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "argument should be a '%q' not a '%q'", self->type->name, arg0_type->name)); + } + } + } + return mp_call_function_n_kw(self->fun, n_args, n_kw, args); +} + +STATIC const mp_obj_type_t mp_type_checked_fun = { + { &mp_type_type }, + .name = MP_QSTR_function, + .call = checked_fun_call, +}; + +STATIC mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) { + mp_obj_checked_fun_t *o = m_new_obj(mp_obj_checked_fun_t); + o->base.type = &mp_type_checked_fun; + o->type = type; + o->fun = fun; + return MP_OBJ_FROM_PTR(o); +} + +#endif // MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG + +// Given a member that was extracted from an instance, convert it correctly +// and put the result in the dest[] array for a possible method call. +// Conversion means dealing with static/class methods, callables, and values. +// see http://docs.python.org/3/howto/descriptor.html +void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest) { + if (MP_OBJ_IS_TYPE(member, &mp_type_staticmethod)) { + // return just the function + dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun; + } else if (MP_OBJ_IS_TYPE(member, &mp_type_classmethod)) { + // return a bound method, with self being the type of this object + // this type should be the type of the original instance, not the base + // type (which is what is passed in the 'type' argument to this function) + if (self != MP_OBJ_NULL) { + type = mp_obj_get_type(self); + } + dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun; + dest[1] = MP_OBJ_FROM_PTR(type); + } else if (MP_OBJ_IS_TYPE(member, &mp_type_type)) { + // Don't try to bind types (even though they're callable) + dest[0] = member; + } else if (MP_OBJ_IS_FUN(member) + || (MP_OBJ_IS_OBJ(member) + && (((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_closure + || ((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_generator))) { + // only functions, closures and generators objects can be bound to self + #if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG + const mp_obj_type_t *m_type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type; + if (self == MP_OBJ_NULL + && (m_type == &mp_type_fun_builtin_0 + || m_type == &mp_type_fun_builtin_1 + || m_type == &mp_type_fun_builtin_2 + || m_type == &mp_type_fun_builtin_3 + || m_type == &mp_type_fun_builtin_var)) { + // we extracted a builtin method without a first argument, so we must + // wrap this function in a type checker + dest[0] = mp_obj_new_checked_fun(type, member); + } else + #endif + { + // return a bound method, with self being this object + dest[0] = member; + dest[1] = self; + } + } else { + // class member is a value, so just return that value + dest[0] = member; + } +} + +// no attribute found, returns: dest[0] == MP_OBJ_NULL, dest[1] == MP_OBJ_NULL +// normal attribute found, returns: dest[0] == , dest[1] == MP_OBJ_NULL +// method attribute found, returns: dest[0] == , dest[1] == +void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { + // clear output to indicate no attribute/method found yet + dest[0] = MP_OBJ_NULL; + dest[1] = MP_OBJ_NULL; + + // get the type + mp_obj_type_t *type = mp_obj_get_type(obj); + + // look for built-in names + if (0) { +#if MICROPY_CPYTHON_COMPAT + } else if (attr == MP_QSTR___class__) { + // a.__class__ is equivalent to type(a) + dest[0] = MP_OBJ_FROM_PTR(type); +#endif + + } else if (attr == MP_QSTR___next__ && type->iternext != NULL) { + dest[0] = MP_OBJ_FROM_PTR(&mp_builtin_next_obj); + dest[1] = obj; + + } else if (type->attr != NULL) { + // this type can do its own load, so call it + type->attr(obj, attr, dest); + + } else if (type->locals_dict != NULL) { + // generic method lookup + // this is a lookup in the object (ie not class or type) + assert(type->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now + mp_map_t *locals_map = &type->locals_dict->map; + mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); + if (elem != NULL) { + mp_convert_member_lookup(obj, type, elem->value, dest); + } + } +} + +void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { + DEBUG_OP_printf("load method %p.%s\n", base, qstr_str(attr)); + + mp_load_method_maybe(base, attr, dest); + + if (dest[0] == MP_OBJ_NULL) { + // no attribute/method called attr + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_msg(&mp_type_AttributeError, "no such attribute"); + } else { + // following CPython, we give a more detailed error message for type objects + if (MP_OBJ_IS_TYPE(base, &mp_type_type)) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, + "type object '%q' has no attribute '%q'", + ((mp_obj_type_t*)MP_OBJ_TO_PTR(base))->name, attr)); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, + "'%s' object has no attribute '%q'", + mp_obj_get_type_str(base), attr)); + } + } + } +} + +void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { + DEBUG_OP_printf("store attr %p.%s <- %p\n", base, qstr_str(attr), value); + mp_obj_type_t *type = mp_obj_get_type(base); + if (type->attr != NULL) { + mp_obj_t dest[2] = {MP_OBJ_SENTINEL, value}; + type->attr(base, attr, dest); + if (dest[0] == MP_OBJ_NULL) { + // success + return; + } + } + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_msg(&mp_type_AttributeError, "no such attribute"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, + "'%s' object has no attribute '%q'", + mp_obj_get_type_str(base), attr)); + } +} + +mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { + assert(o_in); + mp_obj_type_t *type = mp_obj_get_type(o_in); + + // Check for native getiter which is the identity. We handle this case explicitly + // so we don't unnecessarily allocate any RAM for the iter_buf, which won't be used. + if (type->getiter == mp_identity_getiter) { + return o_in; + } + + // if caller did not provide a buffer then allocate one on the heap + if (iter_buf == NULL) { + iter_buf = m_new_obj(mp_obj_iter_buf_t); + } + + // check for native getiter (corresponds to __iter__) + if (type->getiter != NULL) { + mp_obj_t iter = type->getiter(o_in, iter_buf); + if (iter != MP_OBJ_NULL) { + return iter; + } + } + + // check for __getitem__ + mp_obj_t dest[2]; + mp_load_method_maybe(o_in, MP_QSTR___getitem__, dest); + if (dest[0] != MP_OBJ_NULL) { + // __getitem__ exists, create and return an iterator + return mp_obj_new_getitem_iter(dest, iter_buf); + } + + // object not iterable + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object not iterable"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not iterable", mp_obj_get_type_str(o_in))); + } +} + +// may return MP_OBJ_STOP_ITERATION as an optimisation instead of raise StopIteration() +// may also raise StopIteration() +mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->iternext != NULL) { + return type->iternext(o_in); + } else { + // check for __next__ method + mp_obj_t dest[2]; + mp_load_method_maybe(o_in, MP_QSTR___next__, dest); + if (dest[0] != MP_OBJ_NULL) { + // __next__ exists, call it and return its result + return mp_call_method_n_kw(0, 0, dest); + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object not an iterator"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not an iterator", mp_obj_get_type_str(o_in))); + } + } + } +} + +// will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration() (or any subclass thereof) +// may raise other exceptions +mp_obj_t mp_iternext(mp_obj_t o_in) { + MP_STACK_CHECK(); // enumerate, filter, map and zip can recursively call mp_iternext + mp_obj_type_t *type = mp_obj_get_type(o_in); + if (type->iternext != NULL) { + return type->iternext(o_in); + } else { + // check for __next__ method + mp_obj_t dest[2]; + mp_load_method_maybe(o_in, MP_QSTR___next__, dest); + if (dest[0] != MP_OBJ_NULL) { + // __next__ exists, call it and return its result + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_obj_t ret = mp_call_method_n_kw(0, 0, dest); + nlr_pop(); + return ret; + } else { + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { + return MP_OBJ_STOP_ITERATION; + } else { + nlr_jump(nlr.ret_val); + } + } + } else { + if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + mp_raise_TypeError("object not an iterator"); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "'%s' object is not an iterator", mp_obj_get_type_str(o_in))); + } + } + } +} + +// TODO: Unclear what to do with StopIterarion exception here. +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) { + assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL)); + mp_obj_type_t *type = mp_obj_get_type(self_in); + + if (type == &mp_type_gen_instance) { + return mp_obj_gen_resume(self_in, send_value, throw_value, ret_val); + } + + if (type->iternext != NULL && send_value == mp_const_none) { + mp_obj_t ret = type->iternext(self_in); + if (ret != MP_OBJ_STOP_ITERATION) { + *ret_val = ret; + return MP_VM_RETURN_YIELD; + } else { + // Emulate raise StopIteration() + // Special case, handled in vm.c + *ret_val = MP_OBJ_NULL; + return MP_VM_RETURN_NORMAL; + } + } + + mp_obj_t dest[3]; // Reserve slot for send() arg + + // Python instance iterator protocol + if (send_value == mp_const_none) { + mp_load_method_maybe(self_in, MP_QSTR___next__, dest); + if (dest[0] != MP_OBJ_NULL) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + *ret_val = mp_call_method_n_kw(0, 0, dest); + nlr_pop(); + return MP_VM_RETURN_YIELD; + } else { + *ret_val = MP_OBJ_FROM_PTR(nlr.ret_val); + return MP_VM_RETURN_EXCEPTION; + } + } + } + + // Either python instance generator protocol, or native object + // generator protocol. + if (send_value != MP_OBJ_NULL) { + mp_load_method(self_in, MP_QSTR_send, dest); + dest[2] = send_value; + // TODO: This should have exception wrapping like __next__ case + // above. Not done right away to think how to optimize native + // generators better, see: + // https://github.com/micropython/micropython/issues/2628 + *ret_val = mp_call_method_n_kw(1, 0, dest); + return MP_VM_RETURN_YIELD; + } + + assert(throw_value != MP_OBJ_NULL); + { + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(throw_value)), MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) { + mp_load_method_maybe(self_in, MP_QSTR_close, dest); + if (dest[0] != MP_OBJ_NULL) { + // TODO: Exceptions raised in close() are not propagated, + // printed to sys.stderr + *ret_val = mp_call_method_n_kw(0, 0, dest); + // We assume one can't "yield" from close() + return MP_VM_RETURN_NORMAL; + } + } else { + mp_load_method_maybe(self_in, MP_QSTR_throw, dest); + if (dest[0] != MP_OBJ_NULL) { + dest[2] = throw_value; + *ret_val = mp_call_method_n_kw(1, 0, dest); + // If .throw() method returned, we assume it's value to yield + // - any exception would be thrown with nlr_raise(). + return MP_VM_RETURN_YIELD; + } + } + // If there's nowhere to throw exception into, then we assume that object + // is just incapable to handle it, so any exception thrown into it + // will be propagated up. This behavior is approved by test_pep380.py + // test_delegation_of_close_to_non_generator(), + // test_delegating_throw_to_non_generator() + *ret_val = throw_value; + return MP_VM_RETURN_EXCEPTION; + } +} + +mp_obj_t mp_make_raise_obj(mp_obj_t o) { + DEBUG_printf("raise %p\n", o); + if (mp_obj_is_exception_type(o)) { + // o is an exception type (it is derived from BaseException (or is BaseException)) + // create and return a new exception instance by calling o + // TODO could have an option to disable traceback, then builtin exceptions (eg TypeError) + // could have const instances in ROM which we return here instead + return mp_call_function_n_kw(o, 0, 0, NULL); + } else if (mp_obj_is_exception_instance(o)) { + // o is an instance of an exception, so use it as the exception + return o; + } else { + // o cannot be used as an exception, so return a type error (which will be raised by the caller) + return mp_obj_new_exception_msg(&mp_type_TypeError, "exceptions must derive from BaseException"); + } +} + +mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level) { + DEBUG_printf("import name '%s' level=%d\n", qstr_str(name), MP_OBJ_SMALL_INT_VALUE(level)); + + // build args array + mp_obj_t args[5]; + args[0] = MP_OBJ_NEW_QSTR(name); + args[1] = mp_const_none; // TODO should be globals + args[2] = mp_const_none; // TODO should be locals + args[3] = fromlist; + args[4] = level; // must be 0; we don't yet support other values + + // TODO lookup __import__ and call that instead of going straight to builtin implementation + return mp_builtin___import__(5, args); +} + +mp_obj_t mp_import_from(mp_obj_t module, qstr name) { + DEBUG_printf("import from %p %s\n", module, qstr_str(name)); + + mp_obj_t dest[2]; + + mp_load_method_maybe(module, name, dest); + + if (dest[1] != MP_OBJ_NULL) { + // Hopefully we can't import bound method from an object +import_error: + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "cannot import name %q", name)); + } + + if (dest[0] != MP_OBJ_NULL) { + return dest[0]; + } + + // See if it's a package, then can try FS import + if (!mp_obj_is_package(module)) { + goto import_error; + } + + mp_load_method_maybe(module, MP_QSTR___name__, dest); + size_t pkg_name_len; + const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len); + + const uint dot_name_len = pkg_name_len + 1 + qstr_len(name); + char *dot_name = alloca(dot_name_len); + memcpy(dot_name, pkg_name, pkg_name_len); + dot_name[pkg_name_len] = '.'; + memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name)); + qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len); + + mp_obj_t args[5]; + args[0] = MP_OBJ_NEW_QSTR(dot_name_q); + args[1] = mp_const_none; // TODO should be globals + args[2] = mp_const_none; // TODO should be locals + args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module + args[4] = MP_OBJ_NEW_SMALL_INT(0); + + // TODO lookup __import__ and call that instead of going straight to builtin implementation + return mp_builtin___import__(5, args); +} + +void mp_import_all(mp_obj_t module) { + DEBUG_printf("import all %p\n", module); + + // TODO: Support __all__ + mp_map_t *map = mp_obj_dict_get_map(MP_OBJ_FROM_PTR(mp_obj_module_get_globals(module))); + for (size_t i = 0; i < map->alloc; i++) { + if (MP_MAP_SLOT_IS_FILLED(map, i)) { + qstr name = MP_OBJ_QSTR_VALUE(map->table[i].key); + if (*qstr_str(name) != '_') { + mp_store_name(name, map->table[i].value); + } + } + } +} + +#if MICROPY_ENABLE_COMPILER + +// this is implemented in this file so it can optimise access to locals/globals +mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { + // save context + mp_obj_dict_t *volatile old_globals = mp_globals_get(); + mp_obj_dict_t *volatile old_locals = mp_locals_get(); + + // set new context + mp_globals_set(globals); + mp_locals_set(locals); + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + qstr source_name = lex->source_name; + mp_parse_tree_t parse_tree = mp_parse(lex, parse_input_kind); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false); + + mp_obj_t ret; + if (MICROPY_PY_BUILTINS_COMPILE && globals == NULL) { + // for compile only, return value is the module function + ret = module_fun; + } else { + // execute module function and get return value + ret = mp_call_function_0(module_fun); + } + + // finish nlr block, restore context and return value + nlr_pop(); + mp_globals_set(old_globals); + mp_locals_set(old_locals); + return ret; + } else { + // exception; restore context and re-raise same exception + mp_globals_set(old_globals); + mp_locals_set(old_locals); + nlr_jump(nlr.ret_val); + } +} + +#endif // MICROPY_ENABLE_COMPILER + +NORETURN void *m_malloc_fail(size_t num_bytes) { + DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes); + #if MICROPY_ENABLE_GC + if (gc_is_locked()) { + mp_raise_msg(&mp_type_MemoryError, "memory allocation failed, heap is locked"); + } + #endif + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError, + "memory allocation failed, allocating %u bytes", (uint)num_bytes)); +} + +NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) { + if (msg == NULL) { + nlr_raise(mp_obj_new_exception(exc_type)); + } else { + nlr_raise(mp_obj_new_exception_msg(exc_type, msg)); + } +} + +NORETURN void mp_raise_ValueError(const char *msg) { + mp_raise_msg(&mp_type_ValueError, msg); +} + +NORETURN void mp_raise_TypeError(const char *msg) { + mp_raise_msg(&mp_type_TypeError, msg); +} + +NORETURN void mp_raise_OSError(int errno_) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_))); +} + +NORETURN void mp_raise_NotImplementedError(const char *msg) { + mp_raise_msg(&mp_type_NotImplementedError, msg); +} diff --git a/user/mpy/py/runtime.h b/user/mpy/py/runtime.h new file mode 100644 index 0000000..428e257 --- /dev/null +++ b/user/mpy/py/runtime.h @@ -0,0 +1,181 @@ +/* + * 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 + +#include "py/mpstate.h" +#include "py/obj.h" + +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; + +// defined in objtype.c +extern const qstr mp_unary_op_method_name[]; +extern const qstr mp_binary_op_method_name[]; + +void mp_init(void); +void mp_deinit(void); + +void mp_handle_pending(void); +void mp_handle_pending_tail(mp_uint_t atomic_state); + +#if MICROPY_ENABLE_SCHEDULER +void mp_sched_lock(void); +void mp_sched_unlock(void); +static inline unsigned int mp_sched_num_pending(void) { return MP_STATE_VM(sched_sp); } +bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg); +#endif + +// 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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool 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_uint_t op, mp_obj_t arg); +mp_obj_t mp_binary_op(mp_uint_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 +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +void 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 MICROPY_STACKLESS +// 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 + +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_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); + +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); + +NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); +//NORETURN void nlr_raise_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); +NORETURN void mp_raise_ValueError(const char *msg); +NORETURN void mp_raise_TypeError(const char *msg); +NORETURN void mp_raise_NotImplementedError(const char *msg); +NORETURN void mp_raise_OSError(int errno_); +NORETURN void mp_exc_recursion_depth(void); + +#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG +#undef mp_check_self +#define mp_check_self(pred) +#else +// A port may define to raise TypeError for example +#ifndef mp_check_self +#define mp_check_self(pred) assert(pred) +#endif +#endif + +// helper functions for native/viper code +mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); +mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); +mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); +void mp_native_raise(mp_obj_t o); + +#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 MICROPY_WARNINGS +void mp_warning(const char *msg, ...); +#else +#define mp_warning(msg, ...) +#endif + +#endif // MICROPY_INCLUDED_PY_RUNTIME_H diff --git a/user/mpy/py/runtime0.h b/user/mpy/py/runtime0.h new file mode 100644 index 0000000..703c950 --- /dev/null +++ b/user/mpy/py/runtime0.h @@ -0,0 +1,155 @@ +/* + * 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 + +// These must fit in 8 bits; see scope.h +#define MP_SCOPE_FLAG_VARARGS (0x01) +#define MP_SCOPE_FLAG_VARKEYWORDS (0x02) +#define MP_SCOPE_FLAG_GENERATOR (0x04) +#define MP_SCOPE_FLAG_DEFKWARGS (0x08) + +// 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) + +typedef enum { + MP_UNARY_OP_BOOL, // __bool__ + MP_UNARY_OP_LEN, // __len__ + MP_UNARY_OP_HASH, // __hash__; must return a small int + MP_UNARY_OP_POSITIVE, + MP_UNARY_OP_NEGATIVE, + MP_UNARY_OP_INVERT, + MP_UNARY_OP_NOT, + MP_UNARY_OP_SIZEOF, // for sys.getsizeof() +} mp_unary_op_t; + +typedef enum { + 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_FLOOR_DIVIDE, + MP_BINARY_OP_TRUE_DIVIDE, + + MP_BINARY_OP_MODULO, + MP_BINARY_OP_POWER, + MP_BINARY_OP_DIVMOD, // not emitted by the compiler but supported by the runtime + 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_FLOOR_DIVIDE, + MP_BINARY_OP_INPLACE_TRUE_DIVIDE, + MP_BINARY_OP_INPLACE_MODULO, + MP_BINARY_OP_INPLACE_POWER, + + // these should return a bool + 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, + // these 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; + +typedef enum { + MP_F_CONVERT_OBJ_TO_NATIVE = 0, + MP_F_CONVERT_NATIVE_TO_OBJ, + MP_F_LOAD_NAME, + MP_F_LOAD_GLOBAL, + MP_F_LOAD_BUILD_CLASS, + MP_F_LOAD_ATTR, + MP_F_LOAD_METHOD, + MP_F_LOAD_SUPER_METHOD, + MP_F_STORE_NAME, + MP_F_STORE_GLOBAL, + MP_F_STORE_ATTR, + MP_F_OBJ_SUBSCR, + MP_F_OBJ_IS_TRUE, + MP_F_UNARY_OP, + MP_F_BINARY_OP, + MP_F_BUILD_TUPLE, + MP_F_BUILD_LIST, + MP_F_LIST_APPEND, + MP_F_BUILD_MAP, + MP_F_STORE_MAP, +#if MICROPY_PY_BUILTINS_SET + MP_F_BUILD_SET, + MP_F_STORE_SET, +#endif + MP_F_MAKE_FUNCTION_FROM_RAW_CODE, + MP_F_NATIVE_CALL_FUNCTION_N_KW, + MP_F_CALL_METHOD_N_KW, + MP_F_CALL_METHOD_N_KW_VAR, + MP_F_NATIVE_GETITER, + MP_F_NATIVE_ITERNEXT, + MP_F_NLR_PUSH, + MP_F_NLR_POP, + MP_F_NATIVE_RAISE, + MP_F_IMPORT_NAME, + MP_F_IMPORT_FROM, + MP_F_IMPORT_ALL, +#if MICROPY_PY_BUILTINS_SLICE + MP_F_NEW_SLICE, +#endif + MP_F_UNPACK_SEQUENCE, + MP_F_UNPACK_EX, + MP_F_DELETE_NAME, + MP_F_DELETE_GLOBAL, + MP_F_NEW_CELL, + MP_F_MAKE_CLOSURE_FROM_RAW_CODE, + MP_F_SETUP_CODE_STATE, + MP_F_NUMBER_OF, +} mp_fun_kind_t; + +extern void *const mp_fun_table[MP_F_NUMBER_OF]; + +#endif // MICROPY_INCLUDED_PY_RUNTIME0_H diff --git a/user/mpy/py/runtime_utils.c b/user/mpy/py/runtime_utils.c new file mode 100644 index 0000000..56a9180 --- /dev/null +++ b/user/mpy/py/runtime_utils.c @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 Josef Gajdusek + * Copyright (c) 2015 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. + */ + +#include "py/runtime.h" +#include "py/obj.h" +#include "py/nlr.h" + +void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_call_function_1(fun, arg); + nlr_pop(); + } else { + mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); + } +} + +void mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_call_function_2(fun, arg1, arg2); + nlr_pop(); + } else { + mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); + } +} diff --git a/user/mpy/py/scheduler.c b/user/mpy/py/scheduler.c new file mode 100644 index 0000000..30851a4 --- /dev/null +++ b/user/mpy/py/scheduler.c @@ -0,0 +1,117 @@ +/* + * 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. + */ + +#include + +#include "py/runtime.h" + +#if MICROPY_ENABLE_SCHEDULER + +// A variant of this is inlined in the VM at the pending exception check +void mp_handle_pending(void) { + if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { + mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); + mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + if (obj != MP_OBJ_NULL) { + MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + if (!mp_sched_num_pending()) { + MP_STATE_VM(sched_state) = MP_SCHED_IDLE; + } + MICROPY_END_ATOMIC_SECTION(atomic_state); + nlr_raise(obj); + } + mp_handle_pending_tail(atomic_state); + } +} + +// This function should only be called be mp_sched_handle_pending, +// or by the VM's inlined version of that function. +void mp_handle_pending_tail(mp_uint_t atomic_state) { + MP_STATE_VM(sched_state) = MP_SCHED_LOCKED; + if (MP_STATE_VM(sched_sp) > 0) { + mp_sched_item_t item = MP_STATE_VM(sched_stack)[--MP_STATE_VM(sched_sp)]; + MICROPY_END_ATOMIC_SECTION(atomic_state); + mp_call_function_1_protected(item.func, item.arg); + } else { + MICROPY_END_ATOMIC_SECTION(atomic_state); + } + mp_sched_unlock(); +} + +void mp_sched_lock(void) { + mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); + if (MP_STATE_VM(sched_state) < 0) { + --MP_STATE_VM(sched_state); + } else { + MP_STATE_VM(sched_state) = MP_SCHED_LOCKED; + } + MICROPY_END_ATOMIC_SECTION(atomic_state); +} + +void mp_sched_unlock(void) { + mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); + if (++MP_STATE_VM(sched_state) == 0) { + // vm became unlocked + if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL || mp_sched_num_pending()) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } else { + MP_STATE_VM(sched_state) = MP_SCHED_IDLE; + } + } + MICROPY_END_ATOMIC_SECTION(atomic_state); +} + +bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg) { + mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); + bool ret; + if (MP_STATE_VM(sched_sp) < MICROPY_SCHEDULER_DEPTH) { + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } + MP_STATE_VM(sched_stack)[MP_STATE_VM(sched_sp)].func = function; + MP_STATE_VM(sched_stack)[MP_STATE_VM(sched_sp)].arg = arg; + ++MP_STATE_VM(sched_sp); + ret = true; + } else { + // schedule stack is full + ret = false; + } + MICROPY_END_ATOMIC_SECTION(atomic_state); + return ret; +} + +#else // MICROPY_ENABLE_SCHEDULER + +// A variant of this is inlined in the VM at the pending exception check +void mp_handle_pending(void) { + if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { + mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + nlr_raise(obj); + } +} + +#endif // MICROPY_ENABLE_SCHEDULER diff --git a/user/mpy/py/scope.c b/user/mpy/py/scope.c new file mode 100644 index 0000000..1a6ae7b --- /dev/null +++ b/user/mpy/py/scope.c @@ -0,0 +1,150 @@ +/* + * 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. + */ + +#include + +#include "py/scope.h" + +#if MICROPY_ENABLE_COMPILER + +// these low numbered qstrs should fit in 8 bits +STATIC const uint8_t scope_simple_name_table[] = { + [SCOPE_MODULE] = MP_QSTR__lt_module_gt_, + [SCOPE_LAMBDA] = MP_QSTR__lt_lambda_gt_, + [SCOPE_LIST_COMP] = MP_QSTR__lt_listcomp_gt_, + [SCOPE_DICT_COMP] = MP_QSTR__lt_dictcomp_gt_, + [SCOPE_SET_COMP] = MP_QSTR__lt_setcomp_gt_, + [SCOPE_GEN_EXPR] = MP_QSTR__lt_genexpr_gt_, +}; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options) { + scope_t *scope = m_new0(scope_t, 1); + scope->kind = kind; + scope->pn = pn; + scope->source_file = source_file; + if (kind == SCOPE_FUNCTION || kind == SCOPE_CLASS) { + assert(MP_PARSE_NODE_IS_STRUCT(pn)); + scope->simple_name = MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn)->nodes[0]); + } else { + scope->simple_name = scope_simple_name_table[kind]; + } + scope->raw_code = mp_emit_glue_new_raw_code(); + scope->emit_options = emit_options; + scope->id_info_alloc = MICROPY_ALLOC_SCOPE_ID_INIT; + scope->id_info = m_new(id_info_t, scope->id_info_alloc); + + return scope; +} + +void scope_free(scope_t *scope) { + m_del(id_info_t, scope->id_info, scope->id_info_alloc); + m_del(scope_t, scope, 1); +} + +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qst, bool *added) { + id_info_t *id_info = scope_find(scope, qst); + if (id_info != NULL) { + *added = false; + return id_info; + } + + // make sure we have enough memory + if (scope->id_info_len >= scope->id_info_alloc) { + scope->id_info = m_renew(id_info_t, scope->id_info, scope->id_info_alloc, scope->id_info_alloc + MICROPY_ALLOC_SCOPE_ID_INC); + scope->id_info_alloc += MICROPY_ALLOC_SCOPE_ID_INC; + } + + // add new id to end of array of all ids; this seems to match CPython + // important thing is that function arguments are first, but that is + // handled by the compiler because it adds arguments before compiling the body + id_info = &scope->id_info[scope->id_info_len++]; + + id_info->kind = 0; + id_info->flags = 0; + id_info->local_num = 0; + id_info->qst = qst; + *added = true; + return id_info; +} + +id_info_t *scope_find(scope_t *scope, qstr qst) { + for (mp_uint_t i = 0; i < scope->id_info_len; i++) { + if (scope->id_info[i].qst == qst) { + return &scope->id_info[i]; + } + } + return NULL; +} + +id_info_t *scope_find_global(scope_t *scope, qstr qst) { + while (scope->parent != NULL) { + scope = scope->parent; + } + return scope_find(scope, qst); +} + +STATIC void scope_close_over_in_parents(scope_t *scope, qstr qst) { + assert(scope->parent != NULL); // we should have at least 1 parent + for (scope_t *s = scope->parent;; s = s->parent) { + assert(s->parent != NULL); // we should not get to the outer scope + bool added; + id_info_t *id = scope_find_or_add_id(s, qst, &added); + if (added) { + // variable not previously declared in this scope, so declare it as free and keep searching parents + id->kind = ID_INFO_KIND_FREE; + } else { + // variable is declared in this scope, so finish + if (id->kind == ID_INFO_KIND_LOCAL) { + // variable local to this scope, close it over + id->kind = ID_INFO_KIND_CELL; + } else { + // ID_INFO_KIND_FREE: variable already closed over in a parent scope + // ID_INFO_KIND_CELL: variable already closed over in this scope + assert(id->kind == ID_INFO_KIND_FREE || id->kind == ID_INFO_KIND_CELL); + } + return; + } + } +} + +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst) { + if (scope->parent != NULL) { + for (scope_t *s = scope->parent; s->parent != NULL; s = s->parent) { + id_info_t *id2 = scope_find(s, qst); + if (id2 != NULL) { + if (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE) { + id->kind = ID_INFO_KIND_FREE; + scope_close_over_in_parents(scope, qst); + return; + } + break; + } + } + } + id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; +} + +#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/scope.h b/user/mpy/py/scope.h new file mode 100644 index 0000000..e3b6a57 --- /dev/null +++ b/user/mpy/py/scope.h @@ -0,0 +1,97 @@ +/* + * 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_SCOPE_H +#define MICROPY_INCLUDED_PY_SCOPE_H + +#include "py/parse.h" +#include "py/emitglue.h" + +enum { + ID_INFO_KIND_GLOBAL_IMPLICIT, + ID_INFO_KIND_GLOBAL_EXPLICIT, + ID_INFO_KIND_LOCAL, // in a function f, written and only referenced by f + ID_INFO_KIND_CELL, // in a function f, read/written by children of f + ID_INFO_KIND_FREE, // in a function f, belongs to the parent of f +}; + +enum { + ID_FLAG_IS_PARAM = 0x01, + ID_FLAG_IS_STAR_PARAM = 0x02, + ID_FLAG_IS_DBL_STAR_PARAM = 0x04, +}; + +typedef struct _id_info_t { + uint8_t kind; + uint8_t flags; + // when it's an ID_INFO_KIND_LOCAL this is the unique number of the local + // whet it's an ID_INFO_KIND_CELL/FREE this is the unique number of the closed over variable + uint16_t local_num; + qstr qst; +} id_info_t; + +#define SCOPE_IS_FUNC_LIKE(s) ((s) >= SCOPE_LAMBDA) + +// scope is a "block" in Python parlance +typedef enum { + SCOPE_MODULE, + SCOPE_CLASS, + SCOPE_LAMBDA, + SCOPE_LIST_COMP, + SCOPE_DICT_COMP, + SCOPE_SET_COMP, + SCOPE_GEN_EXPR, + SCOPE_FUNCTION, +} scope_kind_t; + +typedef struct _scope_t { + scope_kind_t kind; + struct _scope_t *parent; + struct _scope_t *next; + mp_parse_node_t pn; + uint16_t source_file; // a qstr + uint16_t simple_name; // a qstr + mp_raw_code_t *raw_code; + uint8_t scope_flags; // see runtime0.h + uint8_t emit_options; // see compile.h + uint16_t num_pos_args; + uint16_t num_kwonly_args; + uint16_t num_def_pos_args; + uint16_t num_locals; + uint16_t stack_size; // maximum size of the locals stack + uint16_t exc_stack_size; // maximum size of the exception stack + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; +} scope_t; + +scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); +void scope_free(scope_t *scope); +id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added); +id_info_t *scope_find(scope_t *scope, qstr qstr); +id_info_t *scope_find_global(scope_t *scope, qstr qstr); +void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); + +#endif // MICROPY_INCLUDED_PY_SCOPE_H diff --git a/user/mpy/py/sequence.c b/user/mpy/py/sequence.c new file mode 100644 index 0000000..0752ee1 --- /dev/null +++ b/user/mpy/py/sequence.c @@ -0,0 +1,279 @@ +/* + * 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. + */ + +#include + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" +#include "py/runtime.h" + +// Helpers for sequence types + +#define SWAP(type, var1, var2) { type t = var2; var2 = var1; var1 = t; } + +// Implements backend of sequence * integer operation. Assumes elements are +// memory-adjacent in sequence. +void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest) { + for (size_t i = 0; i < times; i++) { + size_t copy_sz = item_sz * len; + memcpy(dest, items, copy_sz); + dest = (char*)dest + copy_sz; + } +} + +#if MICROPY_PY_BUILTINS_SLICE + +bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes) { + mp_obj_t ostart, ostop, ostep; + mp_int_t start, stop; + mp_obj_slice_get(slice, &ostart, &ostop, &ostep); + + if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) { + indexes->step = mp_obj_get_int(ostep); + if (indexes->step == 0) { + mp_raise_ValueError("slice step cannot be zero"); + } + } else { + indexes->step = 1; + } + + if (ostart == mp_const_none) { + if (indexes->step > 0) { + start = 0; + } else { + start = len - 1; + } + } else { + start = mp_obj_get_int(ostart); + } + if (ostop == mp_const_none) { + if (indexes->step > 0) { + stop = len; + } else { + stop = 0; + } + } else { + stop = mp_obj_get_int(ostop); + if (stop >= 0 && indexes->step < 0) { + stop += 1; + } + } + + // Unlike subscription, out-of-bounds slice indexes are never error + if (start < 0) { + start = len + start; + if (start < 0) { + if (indexes->step < 0) { + start = -1; + } else { + start = 0; + } + } + } else if (indexes->step > 0 && (mp_uint_t)start > len) { + start = len; + } else if (indexes->step < 0 && (mp_uint_t)start >= len) { + start = len - 1; + } + if (stop < 0) { + stop = len + stop; + if (stop < 0) { + stop = -1; + } + if (indexes->step < 0) { + stop += 1; + } + } else if ((mp_uint_t)stop > len) { + stop = len; + } + + // CPython returns empty sequence in such case, or point for assignment is at start + if (indexes->step > 0 && start > stop) { + stop = start; + } else if (indexes->step < 0 && start < stop) { + stop = start + 1; + } + + indexes->start = start; + indexes->stop = stop; + + return indexes->step == 1; +} + +#endif + +mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) { + (void)len; // TODO can we remove len from the arg list? + + mp_int_t start = indexes->start, stop = indexes->stop; + mp_int_t step = indexes->step; + + mp_obj_t res = mp_obj_new_list(0, NULL); + + if (step < 0) { + while (start >= stop) { + mp_obj_list_append(res, seq[start]); + start += step; + } + } else { + while (start < stop) { + mp_obj_list_append(res, seq[start]); + start += step; + } + } + return res; +} + +// Special-case comparison function for sequences of bytes +// Don't pass MP_BINARY_OP_NOT_EQUAL here +bool mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2) { + if (op == MP_BINARY_OP_EQUAL && len1 != len2) { + return false; + } + + // Let's deal only with > & >= + if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { + SWAP(const byte*, data1, data2); + SWAP(size_t, len1, len2); + if (op == MP_BINARY_OP_LESS) { + op = MP_BINARY_OP_MORE; + } else { + op = MP_BINARY_OP_MORE_EQUAL; + } + } + size_t min_len = len1 < len2 ? len1 : len2; + int res = memcmp(data1, data2, min_len); + if (op == MP_BINARY_OP_EQUAL) { + // If we are checking for equality, here're the answer + return res == 0; + } + if (res < 0) { + return false; + } + if (res > 0) { + return true; + } + + // If we had tie in the last element... + // ... and we have lists of different lengths... + if (len1 != len2) { + if (len1 < len2) { + // ... then longer list length wins (we deal only with >) + return false; + } + } else if (op == MP_BINARY_OP_MORE) { + // Otherwise, if we have strict relation, equality means failure + return false; + } + return true; +} + +// Special-case comparison function for sequences of mp_obj_t +// Don't pass MP_BINARY_OP_NOT_EQUAL here +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) { + if (op == MP_BINARY_OP_EQUAL && len1 != len2) { + return false; + } + + // Let's deal only with > & >= + if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { + SWAP(const mp_obj_t *, items1, items2); + SWAP(size_t, len1, len2); + if (op == MP_BINARY_OP_LESS) { + op = MP_BINARY_OP_MORE; + } else { + op = MP_BINARY_OP_MORE_EQUAL; + } + } + + size_t len = len1 < len2 ? len1 : len2; + for (size_t i = 0; i < len; i++) { + // If current elements equal, can't decide anything - go on + if (mp_obj_equal(items1[i], items2[i])) { + continue; + } + + // Othewise, if they are not equal, we can have final decision based on them + if (op == MP_BINARY_OP_EQUAL) { + // In particular, if we are checking for equality, here're the answer + return false; + } + + // Otherwise, application of relation op gives the answer + return (mp_binary_op(op, items1[i], items2[i]) == mp_const_true); + } + + // If we had tie in the last element... + // ... and we have lists of different lengths... + if (len1 != len2) { + if (len1 < len2) { + // ... then longer list length wins (we deal only with >) + return false; + } + } else if (op == MP_BINARY_OP_MORE) { + // Otherwise, if we have strict relation, sequence equality means failure + return false; + } + + return true; +} + +// Special-case of index() which searches for mp_obj_t +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_type_t *type = mp_obj_get_type(args[0]); + mp_obj_t value = args[1]; + size_t start = 0; + size_t stop = len; + + if (n_args >= 3) { + start = mp_get_index(type, len, args[2], true); + if (n_args >= 4) { + stop = mp_get_index(type, len, args[3], true); + } + } + + for (size_t i = start; i < stop; i++) { + if (mp_obj_equal(items[i], value)) { + // Common sense says this cannot overflow small int + return MP_OBJ_NEW_SMALL_INT(i); + } + } + + mp_raise_ValueError("object not in sequence"); +} + +mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) { + size_t count = 0; + for (size_t i = 0; i < len; i++) { + if (mp_obj_equal(items[i], value)) { + count++; + } + } + + // Common sense says this cannot overflow small int + return MP_OBJ_NEW_SMALL_INT(count); +} diff --git a/user/mpy/py/showbc.c b/user/mpy/py/showbc.c new file mode 100644 index 0000000..bb2b084 --- /dev/null +++ b/user/mpy/py/showbc.c @@ -0,0 +1,568 @@ +/* + * 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. + */ + +#include +#include + +#include "py/bc0.h" +#include "py/bc.h" + +#if MICROPY_DEBUG_PRINTERS + +// redirect all printfs in this file to the platform print stream +#define printf(...) mp_printf(&mp_plat_print, __VA_ARGS__) + +#define DECODE_UINT { \ + unum = 0; \ + do { \ + unum = (unum << 7) + (*ip & 0x7f); \ + } while ((*ip++ & 0x80) != 0); \ +} +#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0) +#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0) + +#if MICROPY_PERSISTENT_CODE + +#define DECODE_QSTR \ + qst = ip[0] | ip[1] << 8; \ + ip += 2; +#define DECODE_PTR \ + DECODE_UINT; \ + unum = mp_showbc_const_table[unum] +#define DECODE_OBJ \ + DECODE_UINT; \ + unum = mp_showbc_const_table[unum] + +#else + +#define DECODE_QSTR { \ + qst = 0; \ + do { \ + qst = (qst << 7) + (*ip & 0x7f); \ + } while ((*ip++ & 0x80) != 0); \ +} +#define DECODE_PTR do { \ + ip = (byte*)MP_ALIGN(ip, sizeof(void*)); \ + unum = (uintptr_t)*(void**)ip; \ + ip += sizeof(void*); \ +} while (0) +#define DECODE_OBJ do { \ + ip = (byte*)MP_ALIGN(ip, sizeof(mp_obj_t)); \ + unum = (mp_uint_t)*(mp_obj_t*)ip; \ + ip += sizeof(mp_obj_t); \ +} while (0) + +#endif + +const byte *mp_showbc_code_start; +const mp_uint_t *mp_showbc_const_table; + +void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const mp_uint_t *const_table) { + mp_showbc_code_start = ip; + + // get bytecode parameters + mp_uint_t n_state = mp_decode_uint(&ip); + mp_uint_t n_exc_stack = mp_decode_uint(&ip); + /*mp_uint_t scope_flags =*/ ip++; + mp_uint_t n_pos_args = *ip++; + mp_uint_t n_kwonly_args = *ip++; + /*mp_uint_t n_def_pos_args =*/ ip++; + + const byte *code_info = ip; + mp_uint_t code_info_size = mp_decode_uint(&code_info); + ip += code_info_size; + + #if MICROPY_PERSISTENT_CODE + qstr block_name = code_info[0] | (code_info[1] << 8); + qstr source_file = code_info[2] | (code_info[3] << 8); + code_info += 4; + #else + qstr block_name = mp_decode_uint(&code_info); + qstr source_file = mp_decode_uint(&code_info); + #endif + printf("File %s, code block '%s' (descriptor: %p, bytecode @%p " UINT_FMT " bytes)\n", + qstr_str(source_file), qstr_str(block_name), descr, mp_showbc_code_start, len); + + // raw bytecode dump + printf("Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n", code_info_size, len - code_info_size); + for (mp_uint_t i = 0; i < len; i++) { + if (i > 0 && i % 16 == 0) { + printf("\n"); + } + printf(" %02x", mp_showbc_code_start[i]); + } + printf("\n"); + + // bytecode prelude: arg names (as qstr objects) + printf("arg names:"); + for (mp_uint_t i = 0; i < n_pos_args + n_kwonly_args; i++) { + printf(" %s", qstr_str(MP_OBJ_QSTR_VALUE(const_table[i]))); + } + printf("\n"); + + printf("(N_STATE " UINT_FMT ")\n", n_state); + printf("(N_EXC_STACK " UINT_FMT ")\n", n_exc_stack); + + // for printing line number info + const byte *bytecode_start = ip; + + // bytecode prelude: initialise closed over variables + { + uint local_num; + while ((local_num = *ip++) != 255) { + printf("(INIT_CELL %u)\n", local_num); + } + len -= ip - mp_showbc_code_start; + } + + // print out line number info + { + mp_int_t bc = bytecode_start - ip; + mp_uint_t source_line = 1; + printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); + for (const byte* ci = code_info; *ci;) { + if ((ci[0] & 0x80) == 0) { + // 0b0LLBBBBB encoding + bc += ci[0] & 0x1f; + source_line += ci[0] >> 5; + ci += 1; + } else { + // 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) + bc += ci[0] & 0xf; + source_line += ((ci[0] << 4) & 0x700) | ci[1]; + ci += 2; + } + printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); + } + } + mp_bytecode_print2(ip, len - 0, const_table); +} + +const byte *mp_bytecode_print_str(const byte *ip) { + mp_uint_t unum; + qstr qst; + + switch (*ip++) { + case MP_BC_LOAD_CONST_FALSE: + printf("LOAD_CONST_FALSE"); + break; + + case MP_BC_LOAD_CONST_NONE: + printf("LOAD_CONST_NONE"); + break; + + case MP_BC_LOAD_CONST_TRUE: + printf("LOAD_CONST_TRUE"); + break; + + case MP_BC_LOAD_CONST_SMALL_INT: { + mp_int_t num = 0; + if ((ip[0] & 0x40) != 0) { + // Number is negative + num--; + } + do { + num = (num << 7) | (*ip & 0x7f); + } while ((*ip++ & 0x80) != 0); + printf("LOAD_CONST_SMALL_INT " INT_FMT, num); + break; + } + + case MP_BC_LOAD_CONST_STRING: + DECODE_QSTR; + printf("LOAD_CONST_STRING '%s'", qstr_str(qst)); + break; + + case MP_BC_LOAD_CONST_OBJ: + DECODE_OBJ; + printf("LOAD_CONST_OBJ %p=", MP_OBJ_TO_PTR(unum)); + mp_obj_print_helper(&mp_plat_print, (mp_obj_t)unum, PRINT_REPR); + break; + + case MP_BC_LOAD_NULL: + printf("LOAD_NULL"); + break; + + case MP_BC_LOAD_FAST_N: + DECODE_UINT; + printf("LOAD_FAST_N " UINT_FMT, unum); + break; + + case MP_BC_LOAD_DEREF: + DECODE_UINT; + printf("LOAD_DEREF " UINT_FMT, unum); + break; + + case MP_BC_LOAD_NAME: + DECODE_QSTR; + printf("LOAD_NAME %s", qstr_str(qst)); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { + printf(" (cache=%u)", *ip++); + } + break; + + case MP_BC_LOAD_GLOBAL: + DECODE_QSTR; + printf("LOAD_GLOBAL %s", qstr_str(qst)); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { + printf(" (cache=%u)", *ip++); + } + break; + + case MP_BC_LOAD_ATTR: + DECODE_QSTR; + printf("LOAD_ATTR %s", qstr_str(qst)); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { + printf(" (cache=%u)", *ip++); + } + break; + + case MP_BC_LOAD_METHOD: + DECODE_QSTR; + printf("LOAD_METHOD %s", qstr_str(qst)); + break; + + case MP_BC_LOAD_SUPER_METHOD: + DECODE_QSTR; + printf("LOAD_SUPER_METHOD %s", qstr_str(qst)); + break; + + case MP_BC_LOAD_BUILD_CLASS: + printf("LOAD_BUILD_CLASS"); + break; + + case MP_BC_LOAD_SUBSCR: + printf("LOAD_SUBSCR"); + break; + + case MP_BC_STORE_FAST_N: + DECODE_UINT; + printf("STORE_FAST_N " UINT_FMT, unum); + break; + + case MP_BC_STORE_DEREF: + DECODE_UINT; + printf("STORE_DEREF " UINT_FMT, unum); + break; + + case MP_BC_STORE_NAME: + DECODE_QSTR; + printf("STORE_NAME %s", qstr_str(qst)); + break; + + case MP_BC_STORE_GLOBAL: + DECODE_QSTR; + printf("STORE_GLOBAL %s", qstr_str(qst)); + break; + + case MP_BC_STORE_ATTR: + DECODE_QSTR; + printf("STORE_ATTR %s", qstr_str(qst)); + if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { + printf(" (cache=%u)", *ip++); + } + break; + + case MP_BC_STORE_SUBSCR: + printf("STORE_SUBSCR"); + break; + + case MP_BC_DELETE_FAST: + DECODE_UINT; + printf("DELETE_FAST " UINT_FMT, unum); + break; + + case MP_BC_DELETE_DEREF: + DECODE_UINT; + printf("DELETE_DEREF " UINT_FMT, unum); + break; + + case MP_BC_DELETE_NAME: + DECODE_QSTR; + printf("DELETE_NAME %s", qstr_str(qst)); + break; + + case MP_BC_DELETE_GLOBAL: + DECODE_QSTR; + printf("DELETE_GLOBAL %s", qstr_str(qst)); + break; + + case MP_BC_DUP_TOP: + printf("DUP_TOP"); + break; + + case MP_BC_DUP_TOP_TWO: + printf("DUP_TOP_TWO"); + break; + + case MP_BC_POP_TOP: + printf("POP_TOP"); + break; + + case MP_BC_ROT_TWO: + printf("ROT_TWO"); + break; + + case MP_BC_ROT_THREE: + printf("ROT_THREE"); + break; + + case MP_BC_JUMP: + DECODE_SLABEL; + printf("JUMP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_POP_JUMP_IF_TRUE: + DECODE_SLABEL; + printf("POP_JUMP_IF_TRUE " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_POP_JUMP_IF_FALSE: + DECODE_SLABEL; + printf("POP_JUMP_IF_FALSE " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_JUMP_IF_TRUE_OR_POP: + DECODE_SLABEL; + printf("JUMP_IF_TRUE_OR_POP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_JUMP_IF_FALSE_OR_POP: + DECODE_SLABEL; + printf("JUMP_IF_FALSE_OR_POP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_SETUP_WITH: + DECODE_ULABEL; // loop-like labels are always forward + printf("SETUP_WITH " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_WITH_CLEANUP: + printf("WITH_CLEANUP"); + break; + + case MP_BC_UNWIND_JUMP: + DECODE_SLABEL; + printf("UNWIND_JUMP " UINT_FMT " %d", (mp_uint_t)(ip + unum - mp_showbc_code_start), *ip); + ip += 1; + break; + + case MP_BC_SETUP_EXCEPT: + DECODE_ULABEL; // except labels are always forward + printf("SETUP_EXCEPT " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_SETUP_FINALLY: + DECODE_ULABEL; // except labels are always forward + printf("SETUP_FINALLY " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_END_FINALLY: + // if TOS is an exception, reraises the exception (3 values on TOS) + // if TOS is an integer, does something else + // if TOS is None, just pops it and continues + // else error + printf("END_FINALLY"); + break; + + case MP_BC_GET_ITER: + printf("GET_ITER"); + break; + + case MP_BC_GET_ITER_STACK: + printf("GET_ITER_STACK"); + break; + + case MP_BC_FOR_ITER: + DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward + printf("FOR_ITER " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); + break; + + case MP_BC_POP_BLOCK: + // pops block and restores the stack + printf("POP_BLOCK"); + break; + + case MP_BC_POP_EXCEPT: + // pops block, checks it's an exception block, and restores the stack, saving the 3 exception values to local threadstate + printf("POP_EXCEPT"); + break; + + case MP_BC_BUILD_TUPLE: + DECODE_UINT; + printf("BUILD_TUPLE " UINT_FMT, unum); + break; + + case MP_BC_BUILD_LIST: + DECODE_UINT; + printf("BUILD_LIST " UINT_FMT, unum); + break; + + case MP_BC_BUILD_MAP: + DECODE_UINT; + printf("BUILD_MAP " UINT_FMT, unum); + break; + + case MP_BC_STORE_MAP: + printf("STORE_MAP"); + break; + + case MP_BC_BUILD_SET: + DECODE_UINT; + printf("BUILD_SET " UINT_FMT, unum); + break; + +#if MICROPY_PY_BUILTINS_SLICE + case MP_BC_BUILD_SLICE: + DECODE_UINT; + printf("BUILD_SLICE " UINT_FMT, unum); + break; +#endif + + case MP_BC_STORE_COMP: + DECODE_UINT; + printf("STORE_COMP " UINT_FMT, unum); + break; + + case MP_BC_UNPACK_SEQUENCE: + DECODE_UINT; + printf("UNPACK_SEQUENCE " UINT_FMT, unum); + break; + + case MP_BC_UNPACK_EX: + DECODE_UINT; + printf("UNPACK_EX " UINT_FMT, unum); + break; + + case MP_BC_MAKE_FUNCTION: + DECODE_PTR; + printf("MAKE_FUNCTION %p", (void*)(uintptr_t)unum); + break; + + case MP_BC_MAKE_FUNCTION_DEFARGS: + DECODE_PTR; + printf("MAKE_FUNCTION_DEFARGS %p", (void*)(uintptr_t)unum); + break; + + case MP_BC_MAKE_CLOSURE: { + DECODE_PTR; + mp_uint_t n_closed_over = *ip++; + printf("MAKE_CLOSURE %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over); + break; + } + + case MP_BC_MAKE_CLOSURE_DEFARGS: { + DECODE_PTR; + mp_uint_t n_closed_over = *ip++; + printf("MAKE_CLOSURE_DEFARGS %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over); + break; + } + + case MP_BC_CALL_FUNCTION: + DECODE_UINT; + printf("CALL_FUNCTION n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); + break; + + case MP_BC_CALL_FUNCTION_VAR_KW: + DECODE_UINT; + printf("CALL_FUNCTION_VAR_KW n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); + break; + + case MP_BC_CALL_METHOD: + DECODE_UINT; + printf("CALL_METHOD n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); + break; + + case MP_BC_CALL_METHOD_VAR_KW: + DECODE_UINT; + printf("CALL_METHOD_VAR_KW n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); + break; + + case MP_BC_RETURN_VALUE: + printf("RETURN_VALUE"); + break; + + case MP_BC_RAISE_VARARGS: + unum = *ip++; + printf("RAISE_VARARGS " UINT_FMT, unum); + break; + + case MP_BC_YIELD_VALUE: + printf("YIELD_VALUE"); + break; + + case MP_BC_YIELD_FROM: + printf("YIELD_FROM"); + break; + + case MP_BC_IMPORT_NAME: + DECODE_QSTR; + printf("IMPORT_NAME '%s'", qstr_str(qst)); + break; + + case MP_BC_IMPORT_FROM: + DECODE_QSTR; + printf("IMPORT_FROM '%s'", qstr_str(qst)); + break; + + case MP_BC_IMPORT_STAR: + printf("IMPORT_STAR"); + break; + + default: + if (ip[-1] < MP_BC_LOAD_CONST_SMALL_INT_MULTI + 64) { + printf("LOAD_CONST_SMALL_INT " INT_FMT, (mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16); + } else if (ip[-1] < MP_BC_LOAD_FAST_MULTI + 16) { + printf("LOAD_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_LOAD_FAST_MULTI); + } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { + printf("STORE_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_STORE_FAST_MULTI); + } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + 7) { + printf("UNARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_UNARY_OP_MULTI); + } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + 36) { + mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI; + printf("BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op])); + } else { + printf("code %p, byte code 0x%02x not implemented\n", ip, ip[-1]); + assert(0); + return ip; + } + break; + } + + return ip; +} + +void mp_bytecode_print2(const byte *ip, size_t len, const mp_uint_t *const_table) { + mp_showbc_code_start = ip; + mp_showbc_const_table = const_table; + while (ip < len + mp_showbc_code_start) { + printf("%02u ", (uint)(ip - mp_showbc_code_start)); + ip = mp_bytecode_print_str(ip); + printf("\n"); + } +} + +#endif // MICROPY_DEBUG_PRINTERS diff --git a/user/mpy/py/smallint.c b/user/mpy/py/smallint.c new file mode 100644 index 0000000..aa542ca --- /dev/null +++ b/user/mpy/py/smallint.c @@ -0,0 +1,75 @@ +/* + * 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. + */ + +#include "py/smallint.h" + +bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y) { + // Check for multiply overflow; see CERT INT32-C + if (x > 0) { // x is positive + if (y > 0) { // x and y are positive + if (x > (MP_SMALL_INT_MAX / y)) { + return true; + } + } else { // x positive, y nonpositive + if (y < (MP_SMALL_INT_MIN / x)) { + return true; + } + } // x positive, y nonpositive + } else { // x is nonpositive + if (y > 0) { // x is nonpositive, y is positive + if (x < (MP_SMALL_INT_MIN / y)) { + return true; + } + } else { // x and y are nonpositive + if (x != 0 && y < (MP_SMALL_INT_MAX / x)) { + return true; + } + } // End if x and y are nonpositive + } // End if x is nonpositive + return false; +} + +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor) { + // Python specs require that mod has same sign as second operand + dividend %= divisor; + if ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0)) { + dividend += divisor; + } + return dividend; +} + +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom) { + if (num >= 0) { + if (denom < 0) { + num += -denom - 1; + } + } else { + if (denom >= 0) { + num += -denom + 1; + } + } + return num / denom; +} diff --git a/user/mpy/py/smallint.h b/user/mpy/py/smallint.h new file mode 100644 index 0000000..42679a7 --- /dev/null +++ b/user/mpy/py/smallint.h @@ -0,0 +1,68 @@ +/* + * 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_SMALLINT_H +#define MICROPY_INCLUDED_PY_SMALLINT_H + +#include "py/mpconfig.h" +#include "py/misc.h" + +// Functions for small integer arithmetic + +#ifndef MP_SMALL_INT_MIN + +// In SMALL_INT, next-to-highest bits is used as sign, so both must match for value in range +#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C + +#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 1)) +#define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & WORD_MSBIT_HIGH) == 0) +// Mask to truncate mp_int_t to positive value +#define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1)) + +#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B + +#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 2)) +#define MP_SMALL_INT_FITS(n) ((((n) & MP_SMALL_INT_MIN) == 0) || (((n) & MP_SMALL_INT_MIN) == MP_SMALL_INT_MIN)) +// Mask to truncate mp_int_t to positive value +#define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1) | (WORD_MSBIT_HIGH >> 2)) + +#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + +#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)0xffffffff80000000) >> 1)) +#define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & 0xffffffff80000000) == 0) +// Mask to truncate mp_int_t to positive value +#define MP_SMALL_INT_POSITIVE_MASK ~(0xffffffff80000000 | (0xffffffff80000000 >> 1)) + +#endif + +#endif + +#define MP_SMALL_INT_MAX ((mp_int_t)(~(MP_SMALL_INT_MIN))) + +bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); +mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); +mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); + +#endif // MICROPY_INCLUDED_PY_SMALLINT_H diff --git a/user/mpy/py/stackctrl.c b/user/mpy/py/stackctrl.c new file mode 100644 index 0000000..0bcd82f --- /dev/null +++ b/user/mpy/py/stackctrl.c @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#include "py/mpstate.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "py/stackctrl.h" + +void mp_stack_ctrl_init(void) { + volatile int stack_dummy; + MP_STATE_THREAD(stack_top) = (char*)&stack_dummy; +} + +void mp_stack_set_top(void *top) { + MP_STATE_THREAD(stack_top) = top; +} + +mp_uint_t mp_stack_usage(void) { + // Assumes descending stack + volatile int stack_dummy; + return MP_STATE_THREAD(stack_top) - (char*)&stack_dummy; +} + +#if MICROPY_STACK_CHECK + +void mp_stack_set_limit(mp_uint_t limit) { + MP_STATE_THREAD(stack_limit) = limit; +} + +void mp_exc_recursion_depth(void) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_RuntimeError, + MP_OBJ_NEW_QSTR(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded))); +} + +void mp_stack_check(void) { + if (mp_stack_usage() >= MP_STATE_THREAD(stack_limit)) { + mp_exc_recursion_depth(); + } +} + +#endif // MICROPY_STACK_CHECK diff --git a/user/mpy/py/stackctrl.h b/user/mpy/py/stackctrl.h new file mode 100644 index 0000000..ff8da0a --- /dev/null +++ b/user/mpy/py/stackctrl.h @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ +#ifndef MICROPY_INCLUDED_PY_STACKCTRL_H +#define MICROPY_INCLUDED_PY_STACKCTRL_H + +#include "py/mpconfig.h" + +void mp_stack_ctrl_init(void); +void mp_stack_set_top(void *top); +mp_uint_t mp_stack_usage(void); + +#if MICROPY_STACK_CHECK + +void mp_stack_set_limit(mp_uint_t limit); +void mp_stack_check(void); +#define MP_STACK_CHECK() mp_stack_check() + +#else + +#define mp_stack_set_limit(limit) +#define MP_STACK_CHECK() + +#endif + +#endif // MICROPY_INCLUDED_PY_STACKCTRL_H diff --git a/user/mpy/py/stream.c b/user/mpy/py/stream.c new file mode 100644 index 0000000..5d18681 --- /dev/null +++ b/user/mpy/py/stream.c @@ -0,0 +1,567 @@ +/* + * 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. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/objstr.h" +#include "py/stream.h" +#include "py/runtime.h" + +#if MICROPY_STREAMS_NON_BLOCK +#include +#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) +#define EWOULDBLOCK 140 +#endif +#endif + +// This file defines generic Python stream read/write methods which +// dispatch to the underlying stream interface of an object. + +// TODO: should be in mpconfig.h +#define DEFAULT_BUFFER_SIZE 256 + +STATIC mp_obj_t stream_readall(mp_obj_t self_in); + +#define STREAM_CONTENT_TYPE(stream) (((stream)->is_text) ? &mp_type_str : &mp_type_bytes) + +// Returns error condition in *errcode, if non-zero, return value is number of bytes written +// before error condition occurred. If *errcode == 0, returns total bytes written (which will +// be equal to input size). +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode, byte flags) { + byte *buf = buf_; + mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); + typedef mp_uint_t (*io_func_t)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + io_func_t io_func; + const mp_stream_p_t *stream_p = s->type->protocol; + if (flags & MP_STREAM_RW_WRITE) { + io_func = (io_func_t)stream_p->write; + } else { + io_func = stream_p->read; + } + + *errcode = 0; + mp_uint_t done = 0; + while (size > 0) { + mp_uint_t out_sz = io_func(stream, buf, size, errcode); + // For read, out_sz == 0 means EOF. For write, it's unspecified + // what it means, but we don't make any progress, so returning + // is still the best option. + if (out_sz == 0) { + return done; + } + if (out_sz == MP_STREAM_ERROR) { + // If we read something before getting EAGAIN, don't leak it + if (mp_is_nonblocking_error(*errcode) && done != 0) { + *errcode = 0; + } + return done; + } + if (flags & MP_STREAM_RW_ONCE) { + return out_sz; + } + + buf += out_sz; + size -= out_sz; + done += out_sz; + } + return done; +} + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + const mp_stream_p_t *stream_p = type->protocol; + if (stream_p == NULL + || ((flags & MP_STREAM_OP_READ) && stream_p->read == NULL) + || ((flags & MP_STREAM_OP_WRITE) && stream_p->write == NULL) + || ((flags & MP_STREAM_OP_IOCTL) && stream_p->ioctl == NULL)) { + // CPython: io.UnsupportedOperation, OSError subclass + mp_raise_msg(&mp_type_OSError, "stream operation not supported"); + } + return stream_p; +} + +mp_obj_t mp_stream_close(mp_obj_t stream) { + // TODO: Still consider using ioctl for close + mp_obj_t dest[2]; + mp_load_method(stream, MP_QSTR_close, dest); + return mp_call_method_n_kw(0, 0, dest); +} + +STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_READ); + + // What to do if sz < -1? Python docs don't specify this case. + // CPython does a readall, but here we silently let negatives through, + // and they will cause a MemoryError. + mp_int_t sz; + if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) { + return stream_readall(args[0]); + } + + #if MICROPY_PY_BUILTINS_STR_UNICODE + if (stream_p->is_text) { + // We need to read sz number of unicode characters. Because we don't have any + // buffering, and because the stream API can only read bytes, we must read here + // in units of bytes and must never over read. If we want sz chars, then reading + // sz bytes will never over-read, so we follow this approach, in a loop to keep + // reading until we have exactly enough chars. This will be 1 read for text + // with ASCII-only chars, and about 2 reads for text with a couple of non-ASCII + // chars. For text with lots of non-ASCII chars, it'll be pretty inefficient + // in time and memory. + + vstr_t vstr; + vstr_init(&vstr, sz); + mp_uint_t more_bytes = sz; + mp_uint_t last_buf_offset = 0; + while (more_bytes > 0) { + char *p = vstr_add_len(&vstr, more_bytes); + if (p == NULL) { + mp_raise_msg(&mp_type_MemoryError, "out of memory"); + } + int error; + mp_uint_t out_sz = mp_stream_read_exactly(args[0], p, more_bytes, &error); + if (error != 0) { + vstr_cut_tail_bytes(&vstr, more_bytes); + if (mp_is_nonblocking_error(error)) { + // With non-blocking streams, we read as much as we can. + // If we read nothing, return None, just like read(). + // Otherwise, return data read so far. + // TODO what if we have read only half a non-ASCII char? + if (vstr.len == 0) { + vstr_clear(&vstr); + return mp_const_none; + } + break; + } + mp_raise_OSError(error); + } + + if (out_sz < more_bytes) { + // Finish reading. + // TODO what if we have read only half a non-ASCII char? + vstr_cut_tail_bytes(&vstr, more_bytes - out_sz); + if (out_sz == 0) { + break; + } + } + + // count chars from bytes just read + for (mp_uint_t off = last_buf_offset;;) { + byte b = vstr.buf[off]; + int n; + if (!UTF8_IS_NONASCII(b)) { + // 1-byte ASCII char + n = 1; + } else if ((b & 0xe0) == 0xc0) { + // 2-byte char + n = 2; + } else if ((b & 0xf0) == 0xe0) { + // 3-byte char + n = 3; + } else if ((b & 0xf8) == 0xf0) { + // 4-byte char + n = 4; + } else { + // TODO + n = 5; + } + if (off + n <= vstr.len) { + // got a whole char in n bytes + off += n; + sz -= 1; + last_buf_offset = off; + if (off >= vstr.len) { + more_bytes = sz; + break; + } + } else { + // didn't get a whole char, so work out how many extra bytes are needed for + // this partial char, plus bytes for additional chars that we want + more_bytes = (off + n - vstr.len) + (sz - 1); + break; + } + } + } + + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + } + #endif + + vstr_t vstr; + vstr_init_len(&vstr, sz); + int error; + mp_uint_t out_sz = mp_stream_rw(args[0], vstr.buf, sz, &error, flags); + if (error != 0) { + vstr_clear(&vstr); + if (mp_is_nonblocking_error(error)) { + // https://docs.python.org/3.4/library/io.html#io.RawIOBase.read + // "If the object is in non-blocking mode and no bytes are available, + // None is returned." + // This is actually very weird, as naive truth check will treat + // this as EOF. + return mp_const_none; + } + mp_raise_OSError(error); + } else { + vstr.len = out_sz; + return mp_obj_new_str_from_vstr(STREAM_CONTENT_TYPE(stream_p), &vstr); + } +} + +STATIC mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) { + return stream_read_generic(n_args, args, MP_STREAM_RW_READ); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj, 1, 2, stream_read); + +STATIC mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) { + return stream_read_generic(n_args, args, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj, 1, 2, stream_read1); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags) { + mp_get_stream_raise(self_in, MP_STREAM_OP_WRITE); + + int error; + mp_uint_t out_sz = mp_stream_rw(self_in, (void*)buf, len, &error, flags); + if (error != 0) { + if (mp_is_nonblocking_error(error)) { + // http://docs.python.org/3/library/io.html#io.RawIOBase.write + // "None is returned if the raw stream is set not to block and + // no single byte could be readily written to it." + return mp_const_none; + } + mp_raise_OSError(error); + } else { + return MP_OBJ_NEW_SMALL_INT(out_sz); + } +} + +// XXX hack +void mp_stream_write_adaptor(void *self, const char *buf, size_t len) { + mp_stream_write(MP_OBJ_FROM_PTR(self), buf, len, MP_STREAM_RW_WRITE); +} + +STATIC mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); + size_t max_len = (size_t)-1; + size_t off = 0; + if (n_args == 3) { + max_len = mp_obj_get_int_truncated(args[2]); + } else if (n_args == 4) { + off = mp_obj_get_int_truncated(args[2]); + max_len = mp_obj_get_int_truncated(args[3]); + if (off > bufinfo.len) { + off = bufinfo.len; + } + } + bufinfo.len -= off; + return mp_stream_write(args[0], (byte*)bufinfo.buf + off, MIN(bufinfo.len, max_len), MP_STREAM_RW_WRITE); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj, 2, 4, stream_write_method); + +STATIC mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); + return mp_stream_write(self_in, bufinfo.buf, bufinfo.len, MP_STREAM_RW_WRITE | MP_STREAM_RW_ONCE); +} +MP_DEFINE_CONST_FUN_OBJ_2(mp_stream_write1_obj, stream_write1_method); + +STATIC mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) { + mp_get_stream_raise(args[0], MP_STREAM_OP_READ); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); + + // CPython extension: if 2nd arg is provided, that's max len to read, + // instead of full buffer. Similar to + // https://docs.python.org/3/library/socket.html#socket.socket.recv_into + mp_uint_t len = bufinfo.len; + if (n_args > 2) { + len = mp_obj_get_int(args[2]); + if (len > bufinfo.len) { + len = bufinfo.len; + } + } + + int error; + mp_uint_t out_sz = mp_stream_read_exactly(args[0], bufinfo.buf, len, &error); + if (error != 0) { + if (mp_is_nonblocking_error(error)) { + return mp_const_none; + } + mp_raise_OSError(error); + } else { + return MP_OBJ_NEW_SMALL_INT(out_sz); + } +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj, 2, 3, stream_readinto); + +STATIC mp_obj_t stream_readall(mp_obj_t self_in) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(self_in, MP_STREAM_OP_READ); + + mp_uint_t total_size = 0; + vstr_t vstr; + vstr_init(&vstr, DEFAULT_BUFFER_SIZE); + char *p = vstr.buf; + mp_uint_t current_read = DEFAULT_BUFFER_SIZE; + while (true) { + int error; + mp_uint_t out_sz = stream_p->read(self_in, p, current_read, &error); + if (out_sz == MP_STREAM_ERROR) { + if (mp_is_nonblocking_error(error)) { + // With non-blocking streams, we read as much as we can. + // If we read nothing, return None, just like read(). + // Otherwise, return data read so far. + if (total_size == 0) { + return mp_const_none; + } + break; + } + mp_raise_OSError(error); + } + if (out_sz == 0) { + break; + } + total_size += out_sz; + if (out_sz < current_read) { + current_read -= out_sz; + p += out_sz; + } else { + p = vstr_extend(&vstr, DEFAULT_BUFFER_SIZE); + current_read = DEFAULT_BUFFER_SIZE; + } + } + + vstr.len = total_size; + return mp_obj_new_str_from_vstr(STREAM_CONTENT_TYPE(stream_p), &vstr); +} + +// Unbuffered, inefficient implementation of readline() for raw I/O files. +STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_READ); + + mp_int_t max_size = -1; + if (n_args > 1) { + max_size = MP_OBJ_SMALL_INT_VALUE(args[1]); + } + + vstr_t vstr; + if (max_size != -1) { + vstr_init(&vstr, max_size); + } else { + vstr_init(&vstr, 16); + } + + while (max_size == -1 || max_size-- != 0) { + char *p = vstr_add_len(&vstr, 1); + if (p == NULL) { + mp_raise_msg(&mp_type_MemoryError, "out of memory"); + } + + int error; + mp_uint_t out_sz = stream_p->read(args[0], p, 1, &error); + if (out_sz == MP_STREAM_ERROR) { + if (mp_is_nonblocking_error(error)) { + if (vstr.len == 1) { + // We just incremented it, but otherwise we read nothing + // and immediately got EAGAIN. This case is not well + // specified in + // https://docs.python.org/3/library/io.html#io.IOBase.readline + // unlike similar case for read(). But we follow the latter's + // behavior - return None. + vstr_clear(&vstr); + return mp_const_none; + } else { + goto done; + } + } + mp_raise_OSError(error); + } + if (out_sz == 0) { +done: + // Back out previously added byte + // Consider, what's better - read a char and get OutOfMemory (so read + // char is lost), or allocate first as we do. + vstr_cut_tail_bytes(&vstr, 1); + break; + } + if (*p == '\n') { + break; + } + } + + return mp_obj_new_str_from_vstr(STREAM_CONTENT_TYPE(stream_p), &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj, 1, 2, stream_unbuffered_readline); + +// TODO take an optional extra argument (what does it do exactly?) +STATIC mp_obj_t stream_unbuffered_readlines(mp_obj_t self) { + mp_obj_t lines = mp_obj_new_list(0, NULL); + for (;;) { + mp_obj_t line = stream_unbuffered_readline(1, &self); + if (!mp_obj_is_true(line)) { + break; + } + mp_obj_list_append(lines, line); + } + return lines; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_unbuffered_readlines_obj, stream_unbuffered_readlines); + +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self) { + mp_obj_t l_in = stream_unbuffered_readline(1, &self); + if (mp_obj_is_true(l_in)) { + return l_in; + } + return MP_OBJ_STOP_ITERATION; +} + +STATIC mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_IOCTL); + + struct mp_stream_seek_t seek_s; + // TODO: Could be uint64 + seek_s.offset = mp_obj_get_int(args[1]); + seek_s.whence = 0; + if (n_args == 3) { + seek_s.whence = mp_obj_get_int(args[2]); + } + + int error; + mp_uint_t res = stream_p->ioctl(args[0], MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error); + if (res == MP_STREAM_ERROR) { + mp_raise_OSError(error); + } + + // TODO: Could be uint64 + return mp_obj_new_int_from_uint(seek_s.offset); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj, 2, 3, stream_seek); + +STATIC mp_obj_t stream_tell(mp_obj_t self) { + mp_obj_t offset = MP_OBJ_NEW_SMALL_INT(0); + mp_obj_t whence = MP_OBJ_NEW_SMALL_INT(SEEK_CUR); + const mp_obj_t args[3] = {self, offset, whence}; + return stream_seek(3, args); +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_tell_obj, stream_tell); + +STATIC mp_obj_t stream_flush(mp_obj_t self) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(self, MP_STREAM_OP_IOCTL); + int error; + mp_uint_t res = stream_p->ioctl(self, MP_STREAM_FLUSH, 0, &error); + if (res == MP_STREAM_ERROR) { + mp_raise_OSError(error); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_flush_obj, stream_flush); + +STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) { + const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_IOCTL); + + mp_buffer_info_t bufinfo; + uintptr_t val = 0; + if (n_args > 2) { + if (mp_get_buffer(args[2], &bufinfo, MP_BUFFER_WRITE)) { + val = (uintptr_t)bufinfo.buf; + } else { + val = mp_obj_get_int_truncated(args[2]); + } + } + + int error; + mp_uint_t res = stream_p->ioctl(args[0], mp_obj_get_int(args[1]), val, &error); + if (res == MP_STREAM_ERROR) { + mp_raise_OSError(error); + } + + return mp_obj_new_int(res); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj, 2, 3, stream_ioctl); + +#if MICROPY_STREAMS_POSIX_API +/* + * POSIX-like functions + * + * These functions have POSIX-compatible signature (except for "void *stream" + * first argument instead of "int fd"). They are useful to port existing + * POSIX-compatible software to work with MicroPython streams. + */ + +// errno-like variable. If any of the functions below returned with error +// status, this variable will contain error no. +int mp_stream_errno; + +ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len) { + mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); + const mp_stream_p_t *stream_p = o->type->protocol; + mp_uint_t out_sz = stream_p->write(stream, buf, len, &mp_stream_errno); + if (out_sz == MP_STREAM_ERROR) { + return -1; + } else { + return out_sz; + } +} + +ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len) { + mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); + const mp_stream_p_t *stream_p = o->type->protocol; + mp_uint_t out_sz = stream_p->read(stream, buf, len, &mp_stream_errno); + if (out_sz == MP_STREAM_ERROR) { + return -1; + } else { + return out_sz; + } +} + +off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence) { + const mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); + const mp_stream_p_t *stream_p = o->type->protocol; + struct mp_stream_seek_t seek_s; + seek_s.offset = offset; + seek_s.whence = whence; + mp_uint_t res = stream_p->ioctl(stream, MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &mp_stream_errno); + if (res == MP_STREAM_ERROR) { + return -1; + } + return seek_s.offset; +} + +int mp_stream_posix_fsync(mp_obj_t stream) { + mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); + const mp_stream_p_t *stream_p = o->type->protocol; + mp_uint_t res = stream_p->ioctl(stream, MP_STREAM_FLUSH, 0, &mp_stream_errno); + if (res == MP_STREAM_ERROR) { + return -1; + } + return res; +} + +#endif diff --git a/user/mpy/py/stream.h b/user/mpy/py/stream.h new file mode 100644 index 0000000..401ae31 --- /dev/null +++ b/user/mpy/py/stream.h @@ -0,0 +1,106 @@ +/* + * 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_STREAM_H +#define MICROPY_INCLUDED_PY_STREAM_H + +#include "py/obj.h" +#include "py/mperrno.h" + +#define MP_STREAM_ERROR ((mp_uint_t)-1) + +// Stream ioctl request codes +#define MP_STREAM_FLUSH (1) +#define MP_STREAM_SEEK (2) +#define MP_STREAM_POLL (3) +//#define MP_STREAM_CLOSE (4) // Not yet implemented +#define MP_STREAM_TIMEOUT (5) // Get/set timeout (single op) +#define MP_STREAM_GET_OPTS (6) // Get stream options +#define MP_STREAM_SET_OPTS (7) // Set stream options +#define MP_STREAM_GET_DATA_OPTS (8) // Get data/message options +#define MP_STREAM_SET_DATA_OPTS (9) // Set data/message options + +// These poll ioctl values are compatible with Linux +#define MP_STREAM_POLL_RD (0x0001) +#define MP_STREAM_POLL_WR (0x0004) +#define MP_STREAM_POLL_ERR (0x0008) +#define MP_STREAM_POLL_HUP (0x0010) + +// Argument structure for MP_STREAM_SEEK +struct mp_stream_seek_t { + mp_off_t offset; + int whence; +}; + +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_stream_unbuffered_readlines_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_stream_write1_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_stream_tell_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_stream_flush_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj); + +// these are for mp_get_stream_raise and can be or'd together +#define MP_STREAM_OP_READ (1) +#define MP_STREAM_OP_WRITE (2) +#define MP_STREAM_OP_IOCTL (4) + +const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); +mp_obj_t mp_stream_close(mp_obj_t stream); + +// Iterator which uses mp_stream_unbuffered_readline_obj +mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); + +mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); + +// C-level helper functions +#define MP_STREAM_RW_READ 0 +#define MP_STREAM_RW_WRITE 2 +#define MP_STREAM_RW_ONCE 1 +mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); +#define mp_stream_write_exactly(stream, buf, size, err) mp_stream_rw(stream, (byte*)buf, size, err, MP_STREAM_RW_WRITE) +#define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ) + +void mp_stream_write_adaptor(void *self, const char *buf, size_t len); + +#if MICROPY_STREAMS_POSIX_API +// Functions with POSIX-compatible signatures +ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len); +ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len); +off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence); +int mp_stream_posix_fsync(mp_obj_t stream); +#endif + +#if MICROPY_STREAMS_NON_BLOCK +#define mp_is_nonblocking_error(errno) ((errno) == EAGAIN || (errno) == EWOULDBLOCK) +#else +#define mp_is_nonblocking_error(errno) (0) +#endif + +#endif // MICROPY_INCLUDED_PY_STREAM_H diff --git a/user/mpy/py/unicode.c b/user/mpy/py/unicode.c new file mode 100644 index 0000000..eddb007 --- /dev/null +++ b/user/mpy/py/unicode.c @@ -0,0 +1,184 @@ +/* + * 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. + */ + +#include + +#include "py/unicode.h" + +// attribute flags +#define FL_PRINT (0x01) +#define FL_SPACE (0x02) +#define FL_DIGIT (0x04) +#define FL_ALPHA (0x08) +#define FL_UPPER (0x10) +#define FL_LOWER (0x20) +#define FL_XDIGIT (0x40) + +// shorthand character attributes +#define AT_PR (FL_PRINT) +#define AT_SP (FL_SPACE | FL_PRINT) +#define AT_DI (FL_DIGIT | FL_PRINT | FL_XDIGIT) +#define AT_AL (FL_ALPHA | FL_PRINT) +#define AT_UP (FL_UPPER | FL_ALPHA | FL_PRINT) +#define AT_LO (FL_LOWER | FL_ALPHA | FL_PRINT) +#define AT_UX (FL_UPPER | FL_ALPHA | FL_PRINT | FL_XDIGIT) +#define AT_LX (FL_LOWER | FL_ALPHA | FL_PRINT | FL_XDIGIT) + +// table of attributes for ascii characters +STATIC const uint8_t attr[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, AT_SP, AT_SP, AT_SP, AT_SP, AT_SP, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + AT_SP, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, + AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, + AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, + AT_DI, AT_DI, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, + AT_PR, AT_UX, AT_UX, AT_UX, AT_UX, AT_UX, AT_UX, AT_UP, + AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, + AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, + AT_UP, AT_UP, AT_UP, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, + AT_PR, AT_LX, AT_LX, AT_LX, AT_LX, AT_LX, AT_LX, AT_LO, + AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, + AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, + AT_LO, AT_LO, AT_LO, AT_PR, AT_PR, AT_PR, AT_PR, 0 +}; + +// TODO: Rename to str_get_char +unichar utf8_get_char(const byte *s) { +#if MICROPY_PY_BUILTINS_STR_UNICODE + unichar ord = *s++; + if (!UTF8_IS_NONASCII(ord)) return ord; + ord &= 0x7F; + for (unichar mask = 0x40; ord & mask; mask >>= 1) { + ord &= ~mask; + } + while (UTF8_IS_CONT(*s)) { + ord = (ord << 6) | (*s++ & 0x3F); + } + return ord; +#else + return *s; +#endif +} + +// TODO: Rename to str_next_char +const byte *utf8_next_char(const byte *s) { +#if MICROPY_PY_BUILTINS_STR_UNICODE + ++s; + while (UTF8_IS_CONT(*s)) { + ++s; + } + return s; +#else + return s + 1; +#endif +} + +mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr) { + mp_uint_t i = 0; + while (ptr > s) { + if (!UTF8_IS_CONT(*--ptr)) { + i++; + } + } + + return i; +} + +// TODO: Rename to str_charlen +mp_uint_t unichar_charlen(const char *str, mp_uint_t len) { +#if MICROPY_PY_BUILTINS_STR_UNICODE + mp_uint_t charlen = 0; + for (const char *top = str + len; str < top; ++str) { + if (!UTF8_IS_CONT(*str)) { + ++charlen; + } + } + return charlen; +#else + return len; +#endif +} + +// Be aware: These unichar_is* functions are actually ASCII-only! +bool unichar_isspace(unichar c) { + return c < 128 && (attr[c] & FL_SPACE) != 0; +} + +bool unichar_isalpha(unichar c) { + return c < 128 && (attr[c] & FL_ALPHA) != 0; +} + +/* unused +bool unichar_isprint(unichar c) { + return c < 128 && (attr[c] & FL_PRINT) != 0; +} +*/ + +bool unichar_isdigit(unichar c) { + return c < 128 && (attr[c] & FL_DIGIT) != 0; +} + +bool unichar_isxdigit(unichar c) { + return c < 128 && (attr[c] & FL_XDIGIT) != 0; +} + +bool unichar_isident(unichar c) { + return c < 128 && ((attr[c] & (FL_ALPHA | FL_DIGIT)) != 0 || c == '_'); +} + +bool unichar_isupper(unichar c) { + return c < 128 && (attr[c] & FL_UPPER) != 0; +} + +bool unichar_islower(unichar c) { + return c < 128 && (attr[c] & FL_LOWER) != 0; +} + +unichar unichar_tolower(unichar c) { + if (unichar_isupper(c)) { + return c + 0x20; + } + return c; +} + +unichar unichar_toupper(unichar c) { + if (unichar_islower(c)) { + return c - 0x20; + } + return c; +} + +mp_uint_t unichar_xdigit_value(unichar c) { + // c is assumed to be hex digit + mp_uint_t n = c - '0'; + if (n > 9) { + n &= ~('a' - 'A'); + n -= ('A' - ('9' + 1)); + } + return n; +} diff --git a/user/mpy/py/unicode.h b/user/mpy/py/unicode.h new file mode 100644 index 0000000..19487a6 --- /dev/null +++ b/user/mpy/py/unicode.h @@ -0,0 +1,34 @@ +/* + * 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_UNICODE_H +#define MICROPY_INCLUDED_PY_UNICODE_H + +#include "py/mpconfig.h" +#include "py/misc.h" + +mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); + +#endif // MICROPY_INCLUDED_PY_UNICODE_H diff --git a/user/mpy/py/vm.c b/user/mpy/py/vm.c new file mode 100644 index 0000000..c7fc83d --- /dev/null +++ b/user/mpy/py/vm.c @@ -0,0 +1,1461 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "py/mpstate.h" +#include "py/nlr.h" +#include "py/emitglue.h" +#include "py/objtype.h" +#include "py/runtime.h" +#include "py/bc0.h" +#include "py/bc.h" + +#if 0 +#define TRACE(ip) printf("sp=%d ", (int)(sp - &code_state->state[0] + 1)); mp_bytecode_print2(ip, 1, code_state->fun_bc->const_table); +#else +#define TRACE(ip) +#endif + +// Value stack grows up (this makes it incompatible with native C stack, but +// makes sure that arguments to functions are in natural order arg1..argN +// (Python semantics mandates left-to-right evaluation order, including for +// function arguments). Stack pointer is pre-incremented and points at the +// top element. +// Exception stack also grows up, top element is also pointed at. + +// Exception stack unwind reasons (WHY_* in CPython-speak) +// TODO perhaps compress this to RETURN=0, JUMP>0, with number of unwinds +// left to do encoded in the JUMP number +typedef enum { + UNWIND_RETURN = 1, + UNWIND_JUMP, +} mp_unwind_reason_t; + +#define DECODE_UINT \ + mp_uint_t unum = 0; \ + do { \ + unum = (unum << 7) + (*ip & 0x7f); \ + } while ((*ip++ & 0x80) != 0) +#define DECODE_ULABEL size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2 +#define DECODE_SLABEL size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2 + +#if MICROPY_PERSISTENT_CODE + +#define DECODE_QSTR \ + qstr qst = ip[0] | ip[1] << 8; \ + ip += 2; +#define DECODE_PTR \ + DECODE_UINT; \ + void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum] +#define DECODE_OBJ \ + DECODE_UINT; \ + mp_obj_t obj = (mp_obj_t)code_state->fun_bc->const_table[unum] + +#else + +#define DECODE_QSTR qstr qst = 0; \ + do { \ + qst = (qst << 7) + (*ip & 0x7f); \ + } while ((*ip++ & 0x80) != 0) +#define DECODE_PTR \ + ip = (byte*)MP_ALIGN(ip, sizeof(void*)); \ + void *ptr = *(void**)ip; \ + ip += sizeof(void*) +#define DECODE_OBJ \ + ip = (byte*)MP_ALIGN(ip, sizeof(mp_obj_t)); \ + mp_obj_t obj = *(mp_obj_t*)ip; \ + ip += sizeof(mp_obj_t) + +#endif + +#define PUSH(val) *++sp = (val) +#define POP() (*sp--) +#define TOP() (*sp) +#define SET_TOP(val) *sp = (val) + +#if MICROPY_PY_SYS_EXC_INFO +#define CLEAR_SYS_EXC_INFO() MP_STATE_VM(cur_exception) = NULL; +#else +#define CLEAR_SYS_EXC_INFO() +#endif + +#define PUSH_EXC_BLOCK(with_or_finally) do { \ + DECODE_ULABEL; /* except labels are always forward */ \ + ++exc_sp; \ + exc_sp->handler = ip + ulab; \ + exc_sp->val_sp = MP_TAGPTR_MAKE(sp, ((with_or_finally) << 1) | currently_in_except_block); \ + exc_sp->prev_exc = NULL; \ + currently_in_except_block = 0; /* in a try block now */ \ +} while (0) + +#define POP_EXC_BLOCK() \ + currently_in_except_block = MP_TAGPTR_TAG0(exc_sp->val_sp); /* restore previous state */ \ + exc_sp--; /* pop back to previous exception handler */ \ + CLEAR_SYS_EXC_INFO() /* just clear sys.exc_info(), not compliant, but it shouldn't be used in 1st place */ + +// fastn has items in reverse order (fastn[0] is local[0], fastn[-1] is local[1], etc) +// sp points to bottom of stack which grows up +// returns: +// MP_VM_RETURN_NORMAL, sp valid, return value in *sp +// MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp +// MP_VM_RETURN_EXCEPTION, exception in fastn[0] +mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { +#define SELECTIVE_EXC_IP (0) +#if SELECTIVE_EXC_IP +#define MARK_EXC_IP_SELECTIVE() { code_state->ip = ip; } /* stores ip 1 byte past last opcode */ +#define MARK_EXC_IP_GLOBAL() +#else +#define MARK_EXC_IP_SELECTIVE() +#define MARK_EXC_IP_GLOBAL() { code_state->ip = ip; } /* stores ip pointing to last opcode */ +#endif +#if MICROPY_OPT_COMPUTED_GOTO + #include "py/vmentrytable.h" + #define DISPATCH() do { \ + TRACE(ip); \ + MARK_EXC_IP_GLOBAL(); \ + goto *entry_table[*ip++]; \ + } while (0) + #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check + #define ENTRY(op) entry_##op + #define ENTRY_DEFAULT entry_default +#else + #define DISPATCH() break + #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check + #define ENTRY(op) case op + #define ENTRY_DEFAULT default +#endif + + // nlr_raise needs to be implemented as a goto, so that the C compiler's flow analyser + // sees that it's possible for us to jump from the dispatch loop to the exception + // handler. Without this, the code may have a different stack layout in the dispatch + // loop and the exception handler, leading to very obscure bugs. + #define RAISE(o) do { nlr_pop(); nlr.ret_val = MP_OBJ_TO_PTR(o); goto exception_handler; } while (0) + +#if MICROPY_STACKLESS +run_code_state: ; +#endif + // Pointers which are constant for particular invocation of mp_execute_bytecode() + mp_obj_t * /*const*/ fastn; + mp_exc_stack_t * /*const*/ exc_stack; + { + size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); + fastn = &code_state->state[n_state - 1]; + exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); + } + + // variables that are visible to the exception handler (declared volatile) + volatile bool currently_in_except_block = MP_TAGPTR_TAG0(code_state->exc_sp); // 0 or 1, to detect nested exceptions + mp_exc_stack_t *volatile exc_sp = MP_TAGPTR_PTR(code_state->exc_sp); // stack grows up, exc_sp points to top of stack + + #if MICROPY_PY_THREAD_GIL && MICROPY_PY_THREAD_GIL_VM_DIVISOR + // This needs to be volatile and outside the VM loop so it persists across handling + // of any exceptions. Otherwise it's possible that the VM never gives up the GIL. + volatile int gil_divisor = MICROPY_PY_THREAD_GIL_VM_DIVISOR; + #endif + + // outer exception handling loop + for (;;) { + nlr_buf_t nlr; +outer_dispatch_loop: + if (nlr_push(&nlr) == 0) { + // local variables that are not visible to the exception handler + const byte *ip = code_state->ip; + mp_obj_t *sp = code_state->sp; + mp_obj_t obj_shared; + MICROPY_VM_HOOK_INIT + + // If we have exception to inject, now that we finish setting up + // execution context, raise it. This works as if RAISE_VARARGS + // bytecode was executed. + // Injecting exc into yield from generator is a special case, + // handled by MP_BC_YIELD_FROM itself + if (inject_exc != MP_OBJ_NULL && *ip != MP_BC_YIELD_FROM) { + mp_obj_t exc = inject_exc; + inject_exc = MP_OBJ_NULL; + exc = mp_make_raise_obj(exc); + RAISE(exc); + } + + // loop to execute byte code + for (;;) { +dispatch_loop: +#if MICROPY_OPT_COMPUTED_GOTO + DISPATCH(); +#else + TRACE(ip); + MARK_EXC_IP_GLOBAL(); + switch (*ip++) { +#endif + + ENTRY(MP_BC_LOAD_CONST_FALSE): + PUSH(mp_const_false); + DISPATCH(); + + ENTRY(MP_BC_LOAD_CONST_NONE): + PUSH(mp_const_none); + DISPATCH(); + + ENTRY(MP_BC_LOAD_CONST_TRUE): + PUSH(mp_const_true); + DISPATCH(); + + ENTRY(MP_BC_LOAD_CONST_SMALL_INT): { + mp_int_t num = 0; + if ((ip[0] & 0x40) != 0) { + // Number is negative + num--; + } + do { + num = (num << 7) | (*ip & 0x7f); + } while ((*ip++ & 0x80) != 0); + PUSH(MP_OBJ_NEW_SMALL_INT(num)); + DISPATCH(); + } + + ENTRY(MP_BC_LOAD_CONST_STRING): { + DECODE_QSTR; + PUSH(MP_OBJ_NEW_QSTR(qst)); + DISPATCH(); + } + + ENTRY(MP_BC_LOAD_CONST_OBJ): { + DECODE_OBJ; + PUSH(obj); + DISPATCH(); + } + + ENTRY(MP_BC_LOAD_NULL): + PUSH(MP_OBJ_NULL); + DISPATCH(); + + ENTRY(MP_BC_LOAD_FAST_N): { + DECODE_UINT; + obj_shared = fastn[-unum]; + load_check: + if (obj_shared == MP_OBJ_NULL) { + local_name_error: { + MARK_EXC_IP_SELECTIVE(); + mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NameError, "local variable referenced before assignment"); + RAISE(obj); + } + } + PUSH(obj_shared); + DISPATCH(); + } + + ENTRY(MP_BC_LOAD_DEREF): { + DECODE_UINT; + obj_shared = mp_obj_cell_get(fastn[-unum]); + goto load_check; + } + + #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE + ENTRY(MP_BC_LOAD_NAME): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + PUSH(mp_load_name(qst)); + DISPATCH(); + } + #else + ENTRY(MP_BC_LOAD_NAME): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_obj_t key = MP_OBJ_NEW_QSTR(qst); + mp_uint_t x = *ip; + if (x < mp_locals_get()->map.alloc && mp_locals_get()->map.table[x].key == key) { + PUSH(mp_locals_get()->map.table[x].value); + } else { + mp_map_elem_t *elem = mp_map_lookup(&mp_locals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); + if (elem != NULL) { + *(byte*)ip = (elem - &mp_locals_get()->map.table[0]) & 0xff; + PUSH(elem->value); + } else { + PUSH(mp_load_name(MP_OBJ_QSTR_VALUE(key))); + } + } + ip++; + DISPATCH(); + } + #endif + + #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE + ENTRY(MP_BC_LOAD_GLOBAL): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + PUSH(mp_load_global(qst)); + DISPATCH(); + } + #else + ENTRY(MP_BC_LOAD_GLOBAL): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_obj_t key = MP_OBJ_NEW_QSTR(qst); + mp_uint_t x = *ip; + if (x < mp_globals_get()->map.alloc && mp_globals_get()->map.table[x].key == key) { + PUSH(mp_globals_get()->map.table[x].value); + } else { + mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); + if (elem != NULL) { + *(byte*)ip = (elem - &mp_globals_get()->map.table[0]) & 0xff; + PUSH(elem->value); + } else { + PUSH(mp_load_global(MP_OBJ_QSTR_VALUE(key))); + } + } + ip++; + DISPATCH(); + } + #endif + + #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE + ENTRY(MP_BC_LOAD_ATTR): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + SET_TOP(mp_load_attr(TOP(), qst)); + DISPATCH(); + } + #else + ENTRY(MP_BC_LOAD_ATTR): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_obj_t top = TOP(); + if (mp_obj_get_type(top)->attr == mp_obj_instance_attr) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); + mp_uint_t x = *ip; + mp_obj_t key = MP_OBJ_NEW_QSTR(qst); + mp_map_elem_t *elem; + if (x < self->members.alloc && self->members.table[x].key == key) { + elem = &self->members.table[x]; + } else { + elem = mp_map_lookup(&self->members, key, MP_MAP_LOOKUP); + if (elem != NULL) { + *(byte*)ip = elem - &self->members.table[0]; + } else { + goto load_attr_cache_fail; + } + } + SET_TOP(elem->value); + ip++; + DISPATCH(); + } + load_attr_cache_fail: + SET_TOP(mp_load_attr(top, qst)); + ip++; + DISPATCH(); + } + #endif + + ENTRY(MP_BC_LOAD_METHOD): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_load_method(*sp, qst, sp); + sp += 1; + DISPATCH(); + } + + ENTRY(MP_BC_LOAD_SUPER_METHOD): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + sp -= 1; + mp_load_super_method(qst, sp - 1); + DISPATCH(); + } + + ENTRY(MP_BC_LOAD_BUILD_CLASS): + MARK_EXC_IP_SELECTIVE(); + PUSH(mp_load_build_class()); + DISPATCH(); + + ENTRY(MP_BC_LOAD_SUBSCR): { + MARK_EXC_IP_SELECTIVE(); + mp_obj_t index = POP(); + SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); + DISPATCH(); + } + + ENTRY(MP_BC_STORE_FAST_N): { + DECODE_UINT; + fastn[-unum] = POP(); + DISPATCH(); + } + + ENTRY(MP_BC_STORE_DEREF): { + DECODE_UINT; + mp_obj_cell_set(fastn[-unum], POP()); + DISPATCH(); + } + + ENTRY(MP_BC_STORE_NAME): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_store_name(qst, POP()); + DISPATCH(); + } + + ENTRY(MP_BC_STORE_GLOBAL): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_store_global(qst, POP()); + DISPATCH(); + } + + #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE + ENTRY(MP_BC_STORE_ATTR): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_store_attr(sp[0], qst, sp[-1]); + sp -= 2; + DISPATCH(); + } + #else + // This caching code works with MICROPY_PY_BUILTINS_PROPERTY and/or + // MICROPY_PY_DESCRIPTORS enabled because if the attr exists in + // self->members then it can't be a property or have descriptors. A + // consequence of this is that we can't use MP_MAP_LOOKUP_ADD_IF_NOT_FOUND + // in the fast-path below, because that store could override a property. + ENTRY(MP_BC_STORE_ATTR): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_obj_t top = TOP(); + if (mp_obj_get_type(top)->attr == mp_obj_instance_attr && sp[-1] != MP_OBJ_NULL) { + mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); + mp_uint_t x = *ip; + mp_obj_t key = MP_OBJ_NEW_QSTR(qst); + mp_map_elem_t *elem; + if (x < self->members.alloc && self->members.table[x].key == key) { + elem = &self->members.table[x]; + } else { + elem = mp_map_lookup(&self->members, key, MP_MAP_LOOKUP); + if (elem != NULL) { + *(byte*)ip = elem - &self->members.table[0]; + } else { + goto store_attr_cache_fail; + } + } + elem->value = sp[-1]; + sp -= 2; + ip++; + DISPATCH(); + } + store_attr_cache_fail: + mp_store_attr(sp[0], qst, sp[-1]); + sp -= 2; + ip++; + DISPATCH(); + } + #endif + + ENTRY(MP_BC_STORE_SUBSCR): + MARK_EXC_IP_SELECTIVE(); + mp_obj_subscr(sp[-1], sp[0], sp[-2]); + sp -= 3; + DISPATCH(); + + ENTRY(MP_BC_DELETE_FAST): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + if (fastn[-unum] == MP_OBJ_NULL) { + goto local_name_error; + } + fastn[-unum] = MP_OBJ_NULL; + DISPATCH(); + } + + ENTRY(MP_BC_DELETE_DEREF): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + if (mp_obj_cell_get(fastn[-unum]) == MP_OBJ_NULL) { + goto local_name_error; + } + mp_obj_cell_set(fastn[-unum], MP_OBJ_NULL); + DISPATCH(); + } + + ENTRY(MP_BC_DELETE_NAME): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_delete_name(qst); + DISPATCH(); + } + + ENTRY(MP_BC_DELETE_GLOBAL): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_delete_global(qst); + DISPATCH(); + } + + ENTRY(MP_BC_DUP_TOP): { + mp_obj_t top = TOP(); + PUSH(top); + DISPATCH(); + } + + ENTRY(MP_BC_DUP_TOP_TWO): + sp += 2; + sp[0] = sp[-2]; + sp[-1] = sp[-3]; + DISPATCH(); + + ENTRY(MP_BC_POP_TOP): + sp -= 1; + DISPATCH(); + + ENTRY(MP_BC_ROT_TWO): { + mp_obj_t top = sp[0]; + sp[0] = sp[-1]; + sp[-1] = top; + DISPATCH(); + } + + ENTRY(MP_BC_ROT_THREE): { + mp_obj_t top = sp[0]; + sp[0] = sp[-1]; + sp[-1] = sp[-2]; + sp[-2] = top; + DISPATCH(); + } + + ENTRY(MP_BC_JUMP): { + DECODE_SLABEL; + ip += slab; + DISPATCH_WITH_PEND_EXC_CHECK(); + } + + ENTRY(MP_BC_POP_JUMP_IF_TRUE): { + DECODE_SLABEL; + if (mp_obj_is_true(POP())) { + ip += slab; + } + DISPATCH_WITH_PEND_EXC_CHECK(); + } + + ENTRY(MP_BC_POP_JUMP_IF_FALSE): { + DECODE_SLABEL; + if (!mp_obj_is_true(POP())) { + ip += slab; + } + DISPATCH_WITH_PEND_EXC_CHECK(); + } + + ENTRY(MP_BC_JUMP_IF_TRUE_OR_POP): { + DECODE_SLABEL; + if (mp_obj_is_true(TOP())) { + ip += slab; + } else { + sp--; + } + DISPATCH_WITH_PEND_EXC_CHECK(); + } + + ENTRY(MP_BC_JUMP_IF_FALSE_OR_POP): { + DECODE_SLABEL; + if (mp_obj_is_true(TOP())) { + sp--; + } else { + ip += slab; + } + DISPATCH_WITH_PEND_EXC_CHECK(); + } + + ENTRY(MP_BC_SETUP_WITH): { + MARK_EXC_IP_SELECTIVE(); + // stack: (..., ctx_mgr) + mp_obj_t obj = TOP(); + mp_load_method(obj, MP_QSTR___exit__, sp); + mp_load_method(obj, MP_QSTR___enter__, sp + 2); + mp_obj_t ret = mp_call_method_n_kw(0, 0, sp + 2); + sp += 1; + PUSH_EXC_BLOCK(1); + PUSH(ret); + // stack: (..., __exit__, ctx_mgr, as_value) + DISPATCH(); + } + + ENTRY(MP_BC_WITH_CLEANUP): { + MARK_EXC_IP_SELECTIVE(); + // Arriving here, there's "exception control block" on top of stack, + // and __exit__ method (with self) underneath it. Bytecode calls __exit__, + // and "deletes" it off stack, shifting "exception control block" + // to its place. + // The bytecode emitter ensures that there is enough space on the Python + // value stack to hold the __exit__ method plus an additional 4 entries. + if (TOP() == mp_const_none) { + // stack: (..., __exit__, ctx_mgr, None) + sp[1] = mp_const_none; + sp[2] = mp_const_none; + sp -= 2; + mp_call_method_n_kw(3, 0, sp); + SET_TOP(mp_const_none); + } else if (MP_OBJ_IS_SMALL_INT(TOP())) { + mp_int_t cause_val = MP_OBJ_SMALL_INT_VALUE(TOP()); + if (cause_val == UNWIND_RETURN) { + // stack: (..., __exit__, ctx_mgr, ret_val, UNWIND_RETURN) + mp_obj_t ret_val = sp[-1]; + sp[-1] = mp_const_none; + sp[0] = mp_const_none; + sp[1] = mp_const_none; + mp_call_method_n_kw(3, 0, sp - 3); + sp[-3] = ret_val; + sp[-2] = MP_OBJ_NEW_SMALL_INT(UNWIND_RETURN); + } else { + assert(cause_val == UNWIND_JUMP); + // stack: (..., __exit__, ctx_mgr, dest_ip, num_exc, UNWIND_JUMP) + mp_obj_t dest_ip = sp[-2]; + mp_obj_t num_exc = sp[-1]; + sp[-2] = mp_const_none; + sp[-1] = mp_const_none; + sp[0] = mp_const_none; + mp_call_method_n_kw(3, 0, sp - 4); + sp[-4] = dest_ip; + sp[-3] = num_exc; + sp[-2] = MP_OBJ_NEW_SMALL_INT(UNWIND_JUMP); + } + sp -= 2; // we removed (__exit__, ctx_mgr) + } else { + assert(mp_obj_is_exception_instance(TOP())); + // stack: (..., __exit__, ctx_mgr, exc_instance) + // Need to pass (exc_type, exc_instance, None) as arguments to __exit__. + sp[1] = sp[0]; + sp[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(sp[0])); + sp[2] = mp_const_none; + sp -= 2; + mp_obj_t ret_value = mp_call_method_n_kw(3, 0, sp); + if (mp_obj_is_true(ret_value)) { + // We need to silence/swallow the exception. This is done + // by popping the exception and the __exit__ handler and + // replacing it with None, which signals END_FINALLY to just + // execute the finally handler normally. + SET_TOP(mp_const_none); + assert(exc_sp >= exc_stack); + POP_EXC_BLOCK(); + } else { + // We need to re-raise the exception. We pop __exit__ handler + // by copying the exception instance down to the new top-of-stack. + sp[0] = sp[3]; + } + } + DISPATCH(); + } + + ENTRY(MP_BC_UNWIND_JUMP): { + MARK_EXC_IP_SELECTIVE(); + DECODE_SLABEL; + PUSH((mp_obj_t)(mp_uint_t)(uintptr_t)(ip + slab)); // push destination ip for jump + PUSH((mp_obj_t)(mp_uint_t)(*ip)); // push number of exception handlers to unwind (0x80 bit set if we also need to pop stack) +unwind_jump:; + mp_uint_t unum = (mp_uint_t)POP(); // get number of exception handlers to unwind + while ((unum & 0x7f) > 0) { + unum -= 1; + assert(exc_sp >= exc_stack); + if (MP_TAGPTR_TAG1(exc_sp->val_sp)) { + // Getting here the stack looks like: + // (..., X, dest_ip) + // where X is pointed to by exc_sp->val_sp and in the case + // of a "with" block contains the context manager info. + // We're going to run "finally" code as a coroutine + // (not calling it recursively). Set up a sentinel + // on a stack so it can return back to us when it is + // done (when WITH_CLEANUP or END_FINALLY reached). + PUSH((mp_obj_t)unum); // push number of exception handlers left to unwind + PUSH(MP_OBJ_NEW_SMALL_INT(UNWIND_JUMP)); // push sentinel + ip = exc_sp->handler; // get exception handler byte code address + exc_sp--; // pop exception handler + goto dispatch_loop; // run the exception handler + } + POP_EXC_BLOCK(); + } + ip = (const byte*)MP_OBJ_TO_PTR(POP()); // pop destination ip for jump + if (unum != 0) { + // pop the exhausted iterator + sp -= MP_OBJ_ITER_BUF_NSLOTS; + } + DISPATCH_WITH_PEND_EXC_CHECK(); + } + + // matched against: POP_BLOCK or POP_EXCEPT (anything else?) + ENTRY(MP_BC_SETUP_EXCEPT): + ENTRY(MP_BC_SETUP_FINALLY): { + MARK_EXC_IP_SELECTIVE(); + #if SELECTIVE_EXC_IP + PUSH_EXC_BLOCK((code_state->ip[-1] == MP_BC_SETUP_FINALLY) ? 1 : 0); + #else + PUSH_EXC_BLOCK((code_state->ip[0] == MP_BC_SETUP_FINALLY) ? 1 : 0); + #endif + DISPATCH(); + } + + ENTRY(MP_BC_END_FINALLY): + MARK_EXC_IP_SELECTIVE(); + // if TOS is None, just pops it and continues + // if TOS is an integer, finishes coroutine and returns control to caller + // if TOS is an exception, reraises the exception + if (TOP() == mp_const_none) { + sp--; + } else if (MP_OBJ_IS_SMALL_INT(TOP())) { + // We finished "finally" coroutine and now dispatch back + // to our caller, based on TOS value + mp_unwind_reason_t reason = MP_OBJ_SMALL_INT_VALUE(POP()); + if (reason == UNWIND_RETURN) { + goto unwind_return; + } else { + assert(reason == UNWIND_JUMP); + goto unwind_jump; + } + } else { + assert(mp_obj_is_exception_instance(TOP())); + RAISE(TOP()); + } + DISPATCH(); + + ENTRY(MP_BC_GET_ITER): + MARK_EXC_IP_SELECTIVE(); + SET_TOP(mp_getiter(TOP(), NULL)); + DISPATCH(); + + // An iterator for a for-loop takes MP_OBJ_ITER_BUF_NSLOTS slots on + // the Python value stack. These slots are either used to store the + // iterator object itself, or the first slot is MP_OBJ_NULL and + // the second slot holds a reference to the iterator object. + ENTRY(MP_BC_GET_ITER_STACK): { + MARK_EXC_IP_SELECTIVE(); + mp_obj_t obj = TOP(); + mp_obj_iter_buf_t *iter_buf = (mp_obj_iter_buf_t*)sp; + sp += MP_OBJ_ITER_BUF_NSLOTS - 1; + obj = mp_getiter(obj, iter_buf); + if (obj != MP_OBJ_FROM_PTR(iter_buf)) { + // Iterator didn't use the stack so indicate that with MP_OBJ_NULL. + sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] = MP_OBJ_NULL; + sp[-MP_OBJ_ITER_BUF_NSLOTS + 2] = obj; + } + DISPATCH(); + } + + ENTRY(MP_BC_FOR_ITER): { + MARK_EXC_IP_SELECTIVE(); + DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward + code_state->sp = sp; + mp_obj_t obj; + if (sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] == MP_OBJ_NULL) { + obj = sp[-MP_OBJ_ITER_BUF_NSLOTS + 2]; + } else { + obj = MP_OBJ_FROM_PTR(&sp[-MP_OBJ_ITER_BUF_NSLOTS + 1]); + } + mp_obj_t value = mp_iternext_allow_raise(obj); + if (value == MP_OBJ_STOP_ITERATION) { + sp -= MP_OBJ_ITER_BUF_NSLOTS; // pop the exhausted iterator + ip += ulab; // jump to after for-block + } else { + PUSH(value); // push the next iteration value + } + DISPATCH(); + } + + // matched against: SETUP_EXCEPT, SETUP_FINALLY, SETUP_WITH + ENTRY(MP_BC_POP_BLOCK): + // we are exiting an exception handler, so pop the last one of the exception-stack + assert(exc_sp >= exc_stack); + POP_EXC_BLOCK(); + DISPATCH(); + + // matched against: SETUP_EXCEPT + ENTRY(MP_BC_POP_EXCEPT): + assert(exc_sp >= exc_stack); + assert(currently_in_except_block); + POP_EXC_BLOCK(); + DISPATCH(); + + ENTRY(MP_BC_BUILD_TUPLE): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + sp -= unum - 1; + SET_TOP(mp_obj_new_tuple(unum, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_BUILD_LIST): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + sp -= unum - 1; + SET_TOP(mp_obj_new_list(unum, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_BUILD_MAP): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + PUSH(mp_obj_new_dict(unum)); + DISPATCH(); + } + + ENTRY(MP_BC_STORE_MAP): + MARK_EXC_IP_SELECTIVE(); + sp -= 2; + mp_obj_dict_store(sp[0], sp[2], sp[1]); + DISPATCH(); + +#if MICROPY_PY_BUILTINS_SET + ENTRY(MP_BC_BUILD_SET): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + sp -= unum - 1; + SET_TOP(mp_obj_new_set(unum, sp)); + DISPATCH(); + } +#endif + +#if MICROPY_PY_BUILTINS_SLICE + ENTRY(MP_BC_BUILD_SLICE): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + if (unum == 2) { + mp_obj_t stop = POP(); + mp_obj_t start = TOP(); + SET_TOP(mp_obj_new_slice(start, stop, mp_const_none)); + } else { + mp_obj_t step = POP(); + mp_obj_t stop = POP(); + mp_obj_t start = TOP(); + SET_TOP(mp_obj_new_slice(start, stop, step)); + } + DISPATCH(); + } +#endif + + ENTRY(MP_BC_STORE_COMP): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + mp_obj_t obj = sp[-(unum >> 2)]; + if ((unum & 3) == 0) { + mp_obj_list_append(obj, sp[0]); + sp--; + } else if (!MICROPY_PY_BUILTINS_SET || (unum & 3) == 1) { + mp_obj_dict_store(obj, sp[0], sp[-1]); + sp -= 2; + #if MICROPY_PY_BUILTINS_SET + } else { + mp_obj_set_store(obj, sp[0]); + sp--; + #endif + } + DISPATCH(); + } + + ENTRY(MP_BC_UNPACK_SEQUENCE): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + mp_unpack_sequence(sp[0], unum, sp); + sp += unum - 1; + DISPATCH(); + } + + ENTRY(MP_BC_UNPACK_EX): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + mp_unpack_ex(sp[0], unum, sp); + sp += (unum & 0xff) + ((unum >> 8) & 0xff); + DISPATCH(); + } + + ENTRY(MP_BC_MAKE_FUNCTION): { + DECODE_PTR; + PUSH(mp_make_function_from_raw_code(ptr, MP_OBJ_NULL, MP_OBJ_NULL)); + DISPATCH(); + } + + ENTRY(MP_BC_MAKE_FUNCTION_DEFARGS): { + DECODE_PTR; + // Stack layout: def_tuple def_dict <- TOS + mp_obj_t def_dict = POP(); + SET_TOP(mp_make_function_from_raw_code(ptr, TOP(), def_dict)); + DISPATCH(); + } + + ENTRY(MP_BC_MAKE_CLOSURE): { + DECODE_PTR; + size_t n_closed_over = *ip++; + // Stack layout: closed_overs <- TOS + sp -= n_closed_over - 1; + SET_TOP(mp_make_closure_from_raw_code(ptr, n_closed_over, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_MAKE_CLOSURE_DEFARGS): { + DECODE_PTR; + size_t n_closed_over = *ip++; + // Stack layout: def_tuple def_dict closed_overs <- TOS + sp -= 2 + n_closed_over - 1; + SET_TOP(mp_make_closure_from_raw_code(ptr, 0x100 | n_closed_over, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_CALL_FUNCTION): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + // unum & 0xff == n_positional + // (unum >> 8) & 0xff == n_keyword + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe); + #if MICROPY_STACKLESS + if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { + code_state->ip = ip; + code_state->sp = sp; + code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); + mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1); + if (new_state) { + new_state->prev = code_state; + code_state = new_state; + nlr_pop(); + goto run_code_state; + } + #if MICROPY_STACKLESS_STRICT + else { + deep_recursion_error: + mp_exc_recursion_depth(); + } + #endif + } + #endif + SET_TOP(mp_call_function_n_kw(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1)); + DISPATCH(); + } + + ENTRY(MP_BC_CALL_FUNCTION_VAR_KW): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + // unum & 0xff == n_positional + // (unum >> 8) & 0xff == n_keyword + // We have following stack layout here: + // fun arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 2; + #if MICROPY_STACKLESS + if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { + code_state->ip = ip; + code_state->sp = sp; + code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); + + mp_call_args_t out_args; + mp_call_prepare_args_n_kw_var(false, unum, sp, &out_args); + + mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(out_args.fun, + out_args.n_args, out_args.n_kw, out_args.args); + m_del(mp_obj_t, out_args.args, out_args.n_alloc); + if (new_state) { + new_state->prev = code_state; + code_state = new_state; + nlr_pop(); + goto run_code_state; + } + #if MICROPY_STACKLESS_STRICT + else { + goto deep_recursion_error; + } + #endif + } + #endif + SET_TOP(mp_call_method_n_kw_var(false, unum, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_CALL_METHOD): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + // unum & 0xff == n_positional + // (unum >> 8) & 0xff == n_keyword + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 1; + #if MICROPY_STACKLESS + if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { + code_state->ip = ip; + code_state->sp = sp; + code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); + + size_t n_args = unum & 0xff; + size_t n_kw = (unum >> 8) & 0xff; + int adjust = (sp[1] == MP_OBJ_NULL) ? 0 : 1; + + mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(*sp, n_args + adjust, n_kw, sp + 2 - adjust); + if (new_state) { + new_state->prev = code_state; + code_state = new_state; + nlr_pop(); + goto run_code_state; + } + #if MICROPY_STACKLESS_STRICT + else { + goto deep_recursion_error; + } + #endif + } + #endif + SET_TOP(mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_CALL_METHOD_VAR_KW): { + MARK_EXC_IP_SELECTIVE(); + DECODE_UINT; + // unum & 0xff == n_positional + // (unum >> 8) & 0xff == n_keyword + // We have following stack layout here: + // fun self arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS + sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 3; + #if MICROPY_STACKLESS + if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { + code_state->ip = ip; + code_state->sp = sp; + code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); + + mp_call_args_t out_args; + mp_call_prepare_args_n_kw_var(true, unum, sp, &out_args); + + mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(out_args.fun, + out_args.n_args, out_args.n_kw, out_args.args); + m_del(mp_obj_t, out_args.args, out_args.n_alloc); + if (new_state) { + new_state->prev = code_state; + code_state = new_state; + nlr_pop(); + goto run_code_state; + } + #if MICROPY_STACKLESS_STRICT + else { + goto deep_recursion_error; + } + #endif + } + #endif + SET_TOP(mp_call_method_n_kw_var(true, unum, sp)); + DISPATCH(); + } + + ENTRY(MP_BC_RETURN_VALUE): + MARK_EXC_IP_SELECTIVE(); + // These next 3 lines pop a try-finally exception handler, if one + // is there on the exception stack. Without this the finally block + // is executed a second time when the return is executed, because + // the try-finally exception handler is still on the stack. + // TODO Possibly find a better way to handle this case. + if (currently_in_except_block) { + POP_EXC_BLOCK(); + } +unwind_return: + while (exc_sp >= exc_stack) { + if (MP_TAGPTR_TAG1(exc_sp->val_sp)) { + // Getting here the stack looks like: + // (..., X, [iter0, iter1, ...,] ret_val) + // where X is pointed to by exc_sp->val_sp and in the case + // of a "with" block contains the context manager info. + // There may be 0 or more for-iterators between X and the + // return value, and these must be removed before control can + // pass to the finally code. We simply copy the ret_value down + // over these iterators, if they exist. If they don't then the + // following is a null operation. + mp_obj_t *finally_sp = MP_TAGPTR_PTR(exc_sp->val_sp); + finally_sp[1] = sp[0]; + sp = &finally_sp[1]; + // We're going to run "finally" code as a coroutine + // (not calling it recursively). Set up a sentinel + // on a stack so it can return back to us when it is + // done (when WITH_CLEANUP or END_FINALLY reached). + PUSH(MP_OBJ_NEW_SMALL_INT(UNWIND_RETURN)); + ip = exc_sp->handler; + exc_sp--; + goto dispatch_loop; + } + exc_sp--; + } + nlr_pop(); + code_state->sp = sp; + assert(exc_sp == exc_stack - 1); + MICROPY_VM_HOOK_RETURN + #if MICROPY_STACKLESS + if (code_state->prev != NULL) { + mp_obj_t res = *sp; + mp_globals_set(code_state->old_globals); + code_state = code_state->prev; + *code_state->sp = res; + goto run_code_state; + } + #endif + return MP_VM_RETURN_NORMAL; + + ENTRY(MP_BC_RAISE_VARARGS): { + MARK_EXC_IP_SELECTIVE(); + mp_uint_t unum = *ip++; + mp_obj_t obj; + if (unum == 2) { + mp_warning("exception chaining not supported"); + // ignore (pop) "from" argument + sp--; + } + if (unum == 0) { + // search for the inner-most previous exception, to reraise it + obj = MP_OBJ_NULL; + for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; e--) { + if (e->prev_exc != NULL) { + obj = MP_OBJ_FROM_PTR(e->prev_exc); + break; + } + } + if (obj == MP_OBJ_NULL) { + obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, "No active exception to reraise"); + RAISE(obj); + } + } else { + obj = POP(); + } + obj = mp_make_raise_obj(obj); + RAISE(obj); + } + + ENTRY(MP_BC_YIELD_VALUE): +yield: + nlr_pop(); + code_state->ip = ip; + code_state->sp = sp; + code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); + return MP_VM_RETURN_YIELD; + + ENTRY(MP_BC_YIELD_FROM): { + MARK_EXC_IP_SELECTIVE(); +//#define EXC_MATCH(exc, type) MP_OBJ_IS_TYPE(exc, type) +#define EXC_MATCH(exc, type) mp_obj_exception_match(exc, type) +#define GENERATOR_EXIT_IF_NEEDED(t) if (t != MP_OBJ_NULL && EXC_MATCH(t, MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) { RAISE(t); } + mp_vm_return_kind_t ret_kind; + mp_obj_t send_value = POP(); + mp_obj_t t_exc = MP_OBJ_NULL; + mp_obj_t ret_value; + if (inject_exc != MP_OBJ_NULL) { + t_exc = inject_exc; + inject_exc = MP_OBJ_NULL; + ret_kind = mp_resume(TOP(), MP_OBJ_NULL, t_exc, &ret_value); + } else { + ret_kind = mp_resume(TOP(), send_value, MP_OBJ_NULL, &ret_value); + } + + if (ret_kind == MP_VM_RETURN_YIELD) { + ip--; + PUSH(ret_value); + goto yield; + } else if (ret_kind == MP_VM_RETURN_NORMAL) { + // Pop exhausted gen + sp--; + // TODO: When ret_value can be MP_OBJ_NULL here?? + if (ret_value == MP_OBJ_NULL || ret_value == MP_OBJ_STOP_ITERATION) { + // Optimize StopIteration + // TODO: get StopIteration's value + PUSH(mp_const_none); + } else { + PUSH(ret_value); + } + + // If we injected GeneratorExit downstream, then even + // if it was swallowed, we re-raise GeneratorExit + GENERATOR_EXIT_IF_NEEDED(t_exc); + DISPATCH(); + } else { + assert(ret_kind == MP_VM_RETURN_EXCEPTION); + // Pop exhausted gen + sp--; + if (EXC_MATCH(ret_value, MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { + PUSH(mp_obj_exception_get_value(ret_value)); + // If we injected GeneratorExit downstream, then even + // if it was swallowed, we re-raise GeneratorExit + GENERATOR_EXIT_IF_NEEDED(t_exc); + DISPATCH(); + } else { + RAISE(ret_value); + } + } + } + + ENTRY(MP_BC_IMPORT_NAME): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_obj_t obj = POP(); + SET_TOP(mp_import_name(qst, obj, TOP())); + DISPATCH(); + } + + ENTRY(MP_BC_IMPORT_FROM): { + MARK_EXC_IP_SELECTIVE(); + DECODE_QSTR; + mp_obj_t obj = mp_import_from(TOP(), qst); + PUSH(obj); + DISPATCH(); + } + + ENTRY(MP_BC_IMPORT_STAR): + MARK_EXC_IP_SELECTIVE(); + mp_import_all(POP()); + DISPATCH(); + +#if MICROPY_OPT_COMPUTED_GOTO + ENTRY(MP_BC_LOAD_CONST_SMALL_INT_MULTI): + PUSH(MP_OBJ_NEW_SMALL_INT((mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16)); + DISPATCH(); + + ENTRY(MP_BC_LOAD_FAST_MULTI): + obj_shared = fastn[MP_BC_LOAD_FAST_MULTI - (mp_int_t)ip[-1]]; + goto load_check; + + ENTRY(MP_BC_STORE_FAST_MULTI): + fastn[MP_BC_STORE_FAST_MULTI - (mp_int_t)ip[-1]] = POP(); + DISPATCH(); + + ENTRY(MP_BC_UNARY_OP_MULTI): + MARK_EXC_IP_SELECTIVE(); + SET_TOP(mp_unary_op(ip[-1] - MP_BC_UNARY_OP_MULTI, TOP())); + DISPATCH(); + + ENTRY(MP_BC_BINARY_OP_MULTI): { + MARK_EXC_IP_SELECTIVE(); + mp_obj_t rhs = POP(); + mp_obj_t lhs = TOP(); + SET_TOP(mp_binary_op(ip[-1] - MP_BC_BINARY_OP_MULTI, lhs, rhs)); + DISPATCH(); + } + + ENTRY_DEFAULT: + MARK_EXC_IP_SELECTIVE(); +#else + ENTRY_DEFAULT: + if (ip[-1] < MP_BC_LOAD_CONST_SMALL_INT_MULTI + 64) { + PUSH(MP_OBJ_NEW_SMALL_INT((mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16)); + DISPATCH(); + } else if (ip[-1] < MP_BC_LOAD_FAST_MULTI + 16) { + obj_shared = fastn[MP_BC_LOAD_FAST_MULTI - (mp_int_t)ip[-1]]; + goto load_check; + } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { + fastn[MP_BC_STORE_FAST_MULTI - (mp_int_t)ip[-1]] = POP(); + DISPATCH(); + } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + 7) { + SET_TOP(mp_unary_op(ip[-1] - MP_BC_UNARY_OP_MULTI, TOP())); + DISPATCH(); + } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + 36) { + mp_obj_t rhs = POP(); + mp_obj_t lhs = TOP(); + SET_TOP(mp_binary_op(ip[-1] - MP_BC_BINARY_OP_MULTI, lhs, rhs)); + DISPATCH(); + } else +#endif + { + mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NotImplementedError, "byte code not implemented"); + nlr_pop(); + fastn[0] = obj; + return MP_VM_RETURN_EXCEPTION; + } + +#if !MICROPY_OPT_COMPUTED_GOTO + } // switch +#endif + +pending_exception_check: + MICROPY_VM_HOOK_LOOP + + #if MICROPY_ENABLE_SCHEDULER + // This is an inlined variant of mp_handle_pending + if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { + MARK_EXC_IP_SELECTIVE(); + mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); + mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + if (obj != MP_OBJ_NULL) { + MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + if (!mp_sched_num_pending()) { + MP_STATE_VM(sched_state) = MP_SCHED_IDLE; + } + MICROPY_END_ATOMIC_SECTION(atomic_state); + RAISE(obj); + } + mp_handle_pending_tail(atomic_state); + } + #else + // This is an inlined variant of mp_handle_pending + if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { + MARK_EXC_IP_SELECTIVE(); + mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + RAISE(obj); + } + #endif + + #if MICROPY_PY_THREAD_GIL + #if MICROPY_PY_THREAD_GIL_VM_DIVISOR + if (--gil_divisor == 0) { + gil_divisor = MICROPY_PY_THREAD_GIL_VM_DIVISOR; + #else + { + #endif + #if MICROPY_ENABLE_SCHEDULER + // can only switch threads if the scheduler is unlocked + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) + #endif + { + MP_THREAD_GIL_EXIT(); + MP_THREAD_GIL_ENTER(); + } + } + #endif + + } // for loop + + } else { +exception_handler: + // exception occurred + + #if MICROPY_PY_SYS_EXC_INFO + MP_STATE_VM(cur_exception) = nlr.ret_val; + #endif + + #if SELECTIVE_EXC_IP + // with selective ip, we store the ip 1 byte past the opcode, so move ptr back + code_state->ip -= 1; + #endif + + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { + if (code_state->ip) { + // check if it's a StopIteration within a for block + if (*code_state->ip == MP_BC_FOR_ITER) { + const byte *ip = code_state->ip + 1; + DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward + code_state->ip = ip + ulab; // jump to after for-block + code_state->sp -= MP_OBJ_ITER_BUF_NSLOTS; // pop the exhausted iterator + goto outer_dispatch_loop; // continue with dispatch loop + } else if (*code_state->ip == MP_BC_YIELD_FROM) { + // StopIteration inside yield from call means return a value of + // yield from, so inject exception's value as yield from's result + *++code_state->sp = mp_obj_exception_get_value(MP_OBJ_FROM_PTR(nlr.ret_val)); + code_state->ip++; // yield from is over, move to next instruction + goto outer_dispatch_loop; // continue with dispatch loop + } + } + } + +#if MICROPY_STACKLESS +unwind_loop: +#endif + // set file and line number that the exception occurred at + // TODO: don't set traceback for exceptions re-raised by END_FINALLY. + // But consider how to handle nested exceptions. + // TODO need a better way of not adding traceback to constant objects (right now, just GeneratorExit_obj and MemoryError_obj) + if (nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) { + const byte *ip = code_state->fun_bc->bytecode; + ip = mp_decode_uint_skip(ip); // skip n_state + ip = mp_decode_uint_skip(ip); // skip n_exc_stack + ip++; // skip scope_params + ip++; // skip n_pos_args + ip++; // skip n_kwonly_args + ip++; // skip n_def_pos_args + size_t bc = code_state->ip - ip; + size_t code_info_size = mp_decode_uint_value(ip); + ip = mp_decode_uint_skip(ip); // skip code_info_size + bc -= code_info_size; + #if MICROPY_PERSISTENT_CODE + qstr block_name = ip[0] | (ip[1] << 8); + qstr source_file = ip[2] | (ip[3] << 8); + ip += 4; + #else + qstr block_name = mp_decode_uint_value(ip); + ip = mp_decode_uint_skip(ip); + qstr source_file = mp_decode_uint_value(ip); + ip = mp_decode_uint_skip(ip); + #endif + size_t source_line = 1; + size_t c; + while ((c = *ip)) { + size_t b, l; + if ((c & 0x80) == 0) { + // 0b0LLBBBBB encoding + b = c & 0x1f; + l = c >> 5; + ip += 1; + } else { + // 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) + b = c & 0xf; + l = ((c << 4) & 0x700) | ip[1]; + ip += 2; + } + if (bc >= b) { + bc -= b; + source_line += l; + } else { + // found source line corresponding to bytecode offset + break; + } + } + mp_obj_exception_add_traceback(MP_OBJ_FROM_PTR(nlr.ret_val), source_file, source_line, block_name); + } + + while (currently_in_except_block) { + // nested exception + + assert(exc_sp >= exc_stack); + + // TODO make a proper message for nested exception + // at the moment we are just raising the very last exception (the one that caused the nested exception) + + // move up to previous exception handler + POP_EXC_BLOCK(); + } + + if (exc_sp >= exc_stack) { + // set flag to indicate that we are now handling an exception + currently_in_except_block = 1; + + // catch exception and pass to byte code + code_state->ip = exc_sp->handler; + mp_obj_t *sp = MP_TAGPTR_PTR(exc_sp->val_sp); + // save this exception in the stack so it can be used in a reraise, if needed + exc_sp->prev_exc = nlr.ret_val; + // push exception object so it can be handled by bytecode + PUSH(MP_OBJ_FROM_PTR(nlr.ret_val)); + code_state->sp = sp; + + #if MICROPY_STACKLESS + } else if (code_state->prev != NULL) { + mp_globals_set(code_state->old_globals); + code_state = code_state->prev; + size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); + fastn = &code_state->state[n_state - 1]; + exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); + // variables that are visible to the exception handler (declared volatile) + currently_in_except_block = MP_TAGPTR_TAG0(code_state->exc_sp); // 0 or 1, to detect nested exceptions + exc_sp = MP_TAGPTR_PTR(code_state->exc_sp); // stack grows up, exc_sp points to top of stack + goto unwind_loop; + + #endif + } else { + // propagate exception to higher level + // TODO what to do about ip and sp? they don't really make sense at this point + fastn[0] = MP_OBJ_FROM_PTR(nlr.ret_val); // must put exception here because sp is invalid + return MP_VM_RETURN_EXCEPTION; + } + } + } +} diff --git a/user/mpy/py/vmentrytable.h b/user/mpy/py/vmentrytable.h new file mode 100644 index 0000000..352a6dc --- /dev/null +++ b/user/mpy/py/vmentrytable.h @@ -0,0 +1,118 @@ +/* + * 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. + */ + +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winitializer-overrides" +#endif // __clang__ + +static const void *const entry_table[256] = { + [0 ... 255] = &&entry_default, + [MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE, + [MP_BC_LOAD_CONST_NONE] = &&entry_MP_BC_LOAD_CONST_NONE, + [MP_BC_LOAD_CONST_TRUE] = &&entry_MP_BC_LOAD_CONST_TRUE, + [MP_BC_LOAD_CONST_SMALL_INT] = &&entry_MP_BC_LOAD_CONST_SMALL_INT, + [MP_BC_LOAD_CONST_STRING] = &&entry_MP_BC_LOAD_CONST_STRING, + [MP_BC_LOAD_CONST_OBJ] = &&entry_MP_BC_LOAD_CONST_OBJ, + [MP_BC_LOAD_NULL] = &&entry_MP_BC_LOAD_NULL, + [MP_BC_LOAD_FAST_N] = &&entry_MP_BC_LOAD_FAST_N, + [MP_BC_LOAD_DEREF] = &&entry_MP_BC_LOAD_DEREF, + [MP_BC_LOAD_NAME] = &&entry_MP_BC_LOAD_NAME, + [MP_BC_LOAD_GLOBAL] = &&entry_MP_BC_LOAD_GLOBAL, + [MP_BC_LOAD_ATTR] = &&entry_MP_BC_LOAD_ATTR, + [MP_BC_LOAD_METHOD] = &&entry_MP_BC_LOAD_METHOD, + [MP_BC_LOAD_SUPER_METHOD] = &&entry_MP_BC_LOAD_SUPER_METHOD, + [MP_BC_LOAD_BUILD_CLASS] = &&entry_MP_BC_LOAD_BUILD_CLASS, + [MP_BC_LOAD_SUBSCR] = &&entry_MP_BC_LOAD_SUBSCR, + [MP_BC_STORE_FAST_N] = &&entry_MP_BC_STORE_FAST_N, + [MP_BC_STORE_DEREF] = &&entry_MP_BC_STORE_DEREF, + [MP_BC_STORE_NAME] = &&entry_MP_BC_STORE_NAME, + [MP_BC_STORE_GLOBAL] = &&entry_MP_BC_STORE_GLOBAL, + [MP_BC_STORE_ATTR] = &&entry_MP_BC_STORE_ATTR, + [MP_BC_STORE_SUBSCR] = &&entry_MP_BC_STORE_SUBSCR, + [MP_BC_DELETE_FAST] = &&entry_MP_BC_DELETE_FAST, + [MP_BC_DELETE_DEREF] = &&entry_MP_BC_DELETE_DEREF, + [MP_BC_DELETE_NAME] = &&entry_MP_BC_DELETE_NAME, + [MP_BC_DELETE_GLOBAL] = &&entry_MP_BC_DELETE_GLOBAL, + [MP_BC_DUP_TOP] = &&entry_MP_BC_DUP_TOP, + [MP_BC_DUP_TOP_TWO] = &&entry_MP_BC_DUP_TOP_TWO, + [MP_BC_POP_TOP] = &&entry_MP_BC_POP_TOP, + [MP_BC_ROT_TWO] = &&entry_MP_BC_ROT_TWO, + [MP_BC_ROT_THREE] = &&entry_MP_BC_ROT_THREE, + [MP_BC_JUMP] = &&entry_MP_BC_JUMP, + [MP_BC_POP_JUMP_IF_TRUE] = &&entry_MP_BC_POP_JUMP_IF_TRUE, + [MP_BC_POP_JUMP_IF_FALSE] = &&entry_MP_BC_POP_JUMP_IF_FALSE, + [MP_BC_JUMP_IF_TRUE_OR_POP] = &&entry_MP_BC_JUMP_IF_TRUE_OR_POP, + [MP_BC_JUMP_IF_FALSE_OR_POP] = &&entry_MP_BC_JUMP_IF_FALSE_OR_POP, + [MP_BC_SETUP_WITH] = &&entry_MP_BC_SETUP_WITH, + [MP_BC_WITH_CLEANUP] = &&entry_MP_BC_WITH_CLEANUP, + [MP_BC_UNWIND_JUMP] = &&entry_MP_BC_UNWIND_JUMP, + [MP_BC_SETUP_EXCEPT] = &&entry_MP_BC_SETUP_EXCEPT, + [MP_BC_SETUP_FINALLY] = &&entry_MP_BC_SETUP_FINALLY, + [MP_BC_END_FINALLY] = &&entry_MP_BC_END_FINALLY, + [MP_BC_GET_ITER] = &&entry_MP_BC_GET_ITER, + [MP_BC_GET_ITER_STACK] = &&entry_MP_BC_GET_ITER_STACK, + [MP_BC_FOR_ITER] = &&entry_MP_BC_FOR_ITER, + [MP_BC_POP_BLOCK] = &&entry_MP_BC_POP_BLOCK, + [MP_BC_POP_EXCEPT] = &&entry_MP_BC_POP_EXCEPT, + [MP_BC_BUILD_TUPLE] = &&entry_MP_BC_BUILD_TUPLE, + [MP_BC_BUILD_LIST] = &&entry_MP_BC_BUILD_LIST, + [MP_BC_BUILD_MAP] = &&entry_MP_BC_BUILD_MAP, + [MP_BC_STORE_MAP] = &&entry_MP_BC_STORE_MAP, + #if MICROPY_PY_BUILTINS_SET + [MP_BC_BUILD_SET] = &&entry_MP_BC_BUILD_SET, + #endif + #if MICROPY_PY_BUILTINS_SLICE + [MP_BC_BUILD_SLICE] = &&entry_MP_BC_BUILD_SLICE, + #endif + [MP_BC_STORE_COMP] = &&entry_MP_BC_STORE_COMP, + [MP_BC_UNPACK_SEQUENCE] = &&entry_MP_BC_UNPACK_SEQUENCE, + [MP_BC_UNPACK_EX] = &&entry_MP_BC_UNPACK_EX, + [MP_BC_MAKE_FUNCTION] = &&entry_MP_BC_MAKE_FUNCTION, + [MP_BC_MAKE_FUNCTION_DEFARGS] = &&entry_MP_BC_MAKE_FUNCTION_DEFARGS, + [MP_BC_MAKE_CLOSURE] = &&entry_MP_BC_MAKE_CLOSURE, + [MP_BC_MAKE_CLOSURE_DEFARGS] = &&entry_MP_BC_MAKE_CLOSURE_DEFARGS, + [MP_BC_CALL_FUNCTION] = &&entry_MP_BC_CALL_FUNCTION, + [MP_BC_CALL_FUNCTION_VAR_KW] = &&entry_MP_BC_CALL_FUNCTION_VAR_KW, + [MP_BC_CALL_METHOD] = &&entry_MP_BC_CALL_METHOD, + [MP_BC_CALL_METHOD_VAR_KW] = &&entry_MP_BC_CALL_METHOD_VAR_KW, + [MP_BC_RETURN_VALUE] = &&entry_MP_BC_RETURN_VALUE, + [MP_BC_RAISE_VARARGS] = &&entry_MP_BC_RAISE_VARARGS, + [MP_BC_YIELD_VALUE] = &&entry_MP_BC_YIELD_VALUE, + [MP_BC_YIELD_FROM] = &&entry_MP_BC_YIELD_FROM, + [MP_BC_IMPORT_NAME] = &&entry_MP_BC_IMPORT_NAME, + [MP_BC_IMPORT_FROM] = &&entry_MP_BC_IMPORT_FROM, + [MP_BC_IMPORT_STAR] = &&entry_MP_BC_IMPORT_STAR, + [MP_BC_LOAD_CONST_SMALL_INT_MULTI ... MP_BC_LOAD_CONST_SMALL_INT_MULTI + 63] = &&entry_MP_BC_LOAD_CONST_SMALL_INT_MULTI, + [MP_BC_LOAD_FAST_MULTI ... MP_BC_LOAD_FAST_MULTI + 15] = &&entry_MP_BC_LOAD_FAST_MULTI, + [MP_BC_STORE_FAST_MULTI ... MP_BC_STORE_FAST_MULTI + 15] = &&entry_MP_BC_STORE_FAST_MULTI, + [MP_BC_UNARY_OP_MULTI ... MP_BC_UNARY_OP_MULTI + 6] = &&entry_MP_BC_UNARY_OP_MULTI, + [MP_BC_BINARY_OP_MULTI ... MP_BC_BINARY_OP_MULTI + 35] = &&entry_MP_BC_BINARY_OP_MULTI, +}; + +#if __clang__ +#pragma clang diagnostic pop +#endif // __clang__ diff --git a/user/mpy/py/vstr.c b/user/mpy/py/vstr.c new file mode 100644 index 0000000..8a00f6c --- /dev/null +++ b/user/mpy/py/vstr.c @@ -0,0 +1,276 @@ +/* + * 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. + */ + +#include +#include +#include +#include + +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/mpprint.h" + +// returned value is always at least 1 greater than argument +#define ROUND_ALLOC(a) (((a) & ((~0U) - 7)) + 8) + +// Init the vstr so it allocs exactly given number of bytes. Set length to zero. +void vstr_init(vstr_t *vstr, size_t alloc) { + if (alloc < 1) { + alloc = 1; + } + vstr->alloc = alloc; + vstr->len = 0; + vstr->buf = m_new(char, vstr->alloc); + vstr->fixed_buf = false; +} + +// Init the vstr so it allocs exactly enough ram to hold a null-terminated +// string of the given length, and set the length. +void vstr_init_len(vstr_t *vstr, size_t len) { + vstr_init(vstr, len + 1); + vstr->len = len; +} + +void vstr_init_fixed_buf(vstr_t *vstr, size_t alloc, char *buf) { + vstr->alloc = alloc; + vstr->len = 0; + vstr->buf = buf; + vstr->fixed_buf = true; +} + +void vstr_init_print(vstr_t *vstr, size_t alloc, mp_print_t *print) { + vstr_init(vstr, alloc); + print->data = vstr; + print->print_strn = (mp_print_strn_t)vstr_add_strn; +} + +void vstr_clear(vstr_t *vstr) { + if (!vstr->fixed_buf) { + m_del(char, vstr->buf, vstr->alloc); + } + vstr->buf = NULL; +} + +vstr_t *vstr_new(size_t alloc) { + vstr_t *vstr = m_new_obj(vstr_t); + vstr_init(vstr, alloc); + return vstr; +} + +void vstr_free(vstr_t *vstr) { + if (vstr != NULL) { + if (!vstr->fixed_buf) { + m_del(char, vstr->buf, vstr->alloc); + } + m_del_obj(vstr_t, vstr); + } +} + +// Extend vstr strictly by requested size, return pointer to newly added chunk. +char *vstr_extend(vstr_t *vstr, size_t size) { + if (vstr->fixed_buf) { + return NULL; + } + char *new_buf = m_renew(char, vstr->buf, vstr->alloc, vstr->alloc + size); + char *p = new_buf + vstr->alloc; + vstr->alloc += size; + vstr->buf = new_buf; + return p; +} + +STATIC bool vstr_ensure_extra(vstr_t *vstr, size_t size) { + if (vstr->len + size > vstr->alloc) { + if (vstr->fixed_buf) { + return false; + } + size_t new_alloc = ROUND_ALLOC((vstr->len + size) + 16); + char *new_buf = m_renew(char, vstr->buf, vstr->alloc, new_alloc); + vstr->alloc = new_alloc; + vstr->buf = new_buf; + } + return true; +} + +void vstr_hint_size(vstr_t *vstr, size_t size) { + vstr_ensure_extra(vstr, size); +} + +char *vstr_add_len(vstr_t *vstr, size_t len) { + if (!vstr_ensure_extra(vstr, len)) { + return NULL; + } + char *buf = vstr->buf + vstr->len; + vstr->len += len; + return buf; +} + +// Doesn't increase len, just makes sure there is a null byte at the end +char *vstr_null_terminated_str(vstr_t *vstr) { + // If there's no more room, add single byte + if (vstr->alloc == vstr->len) { + if (vstr_extend(vstr, 1) == NULL) { + return NULL; + } + } + vstr->buf[vstr->len] = '\0'; + return vstr->buf; +} + +void vstr_add_byte(vstr_t *vstr, byte b) { + byte *buf = (byte*)vstr_add_len(vstr, 1); + if (buf == NULL) { + return; + } + buf[0] = b; +} + +void vstr_add_char(vstr_t *vstr, unichar c) { +#if MICROPY_PY_BUILTINS_STR_UNICODE + // TODO: Can this be simplified and deduplicated? + // Is it worth just calling vstr_add_len(vstr, 4)? + if (c < 0x80) { + byte *buf = (byte*)vstr_add_len(vstr, 1); + if (buf == NULL) { + return; + } + *buf = (byte)c; + } else if (c < 0x800) { + byte *buf = (byte*)vstr_add_len(vstr, 2); + if (buf == NULL) { + return; + } + buf[0] = (c >> 6) | 0xC0; + buf[1] = (c & 0x3F) | 0x80; + } else if (c < 0x10000) { + byte *buf = (byte*)vstr_add_len(vstr, 3); + if (buf == NULL) { + return; + } + buf[0] = (c >> 12) | 0xE0; + buf[1] = ((c >> 6) & 0x3F) | 0x80; + buf[2] = (c & 0x3F) | 0x80; + } else { + assert(c < 0x110000); + byte *buf = (byte*)vstr_add_len(vstr, 4); + if (buf == NULL) { + return; + } + buf[0] = (c >> 18) | 0xF0; + buf[1] = ((c >> 12) & 0x3F) | 0x80; + buf[2] = ((c >> 6) & 0x3F) | 0x80; + buf[3] = (c & 0x3F) | 0x80; + } +#else + vstr_add_byte(vstr, c); +#endif +} + +void vstr_add_str(vstr_t *vstr, const char *str) { + vstr_add_strn(vstr, str, strlen(str)); +} + +void vstr_add_strn(vstr_t *vstr, const char *str, size_t len) { + if (!vstr_ensure_extra(vstr, len)) { + // if buf is fixed, we got here because there isn't enough room left + // so just try to copy as much as we can, with room for a possible null byte + if (vstr->fixed_buf && vstr->len < vstr->alloc) { + len = vstr->alloc - vstr->len; + goto copy; + } + return; + } +copy: + memmove(vstr->buf + vstr->len, str, len); + vstr->len += len; +} + +STATIC char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) { + size_t l = vstr->len; + if (byte_pos > l) { + byte_pos = l; + } + if (byte_len > 0) { + // ensure room for the new bytes + if (!vstr_ensure_extra(vstr, byte_len)) { + return NULL; + } + // copy up the string to make room for the new bytes + memmove(vstr->buf + byte_pos + byte_len, vstr->buf + byte_pos, l - byte_pos); + // increase the length + vstr->len += byte_len; + } + return vstr->buf + byte_pos; +} + +void vstr_ins_byte(vstr_t *vstr, size_t byte_pos, byte b) { + char *s = vstr_ins_blank_bytes(vstr, byte_pos, 1); + if (s != NULL) { + *s = b; + } +} + +void vstr_ins_char(vstr_t *vstr, size_t char_pos, unichar chr) { + // TODO UNICODE + char *s = vstr_ins_blank_bytes(vstr, char_pos, 1); + if (s != NULL) { + *s = chr; + } +} + +void vstr_cut_head_bytes(vstr_t *vstr, size_t bytes_to_cut) { + vstr_cut_out_bytes(vstr, 0, bytes_to_cut); +} + +void vstr_cut_tail_bytes(vstr_t *vstr, size_t len) { + if (len > vstr->len) { + vstr->len = 0; + } else { + vstr->len -= len; + } +} + +void vstr_cut_out_bytes(vstr_t *vstr, size_t byte_pos, size_t bytes_to_cut) { + if (byte_pos >= vstr->len) { + return; + } else if (byte_pos + bytes_to_cut >= vstr->len) { + vstr->len = byte_pos; + } else { + memmove(vstr->buf + byte_pos, vstr->buf + byte_pos + bytes_to_cut, vstr->len - byte_pos - bytes_to_cut); + vstr->len -= bytes_to_cut; + } +} + +void vstr_printf(vstr_t *vstr, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vstr_vprintf(vstr, fmt, ap); + va_end(ap); +} + +void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap) { + mp_print_t print = {vstr, (mp_print_strn_t)vstr_add_strn}; + mp_vprintf(&print, fmt, ap); +} diff --git a/user/mpy/py/warning.c b/user/mpy/py/warning.c new file mode 100644 index 0000000..46b31ec --- /dev/null +++ b/user/mpy/py/warning.c @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#include +#include + +#include "py/emit.h" +#include "py/runtime.h" + +#if MICROPY_WARNINGS + +void mp_warning(const char *msg, ...) { + va_list args; + va_start(args, msg); + mp_print_str(&mp_plat_print, "Warning: "); + mp_vprintf(&mp_plat_print, msg, args); + mp_print_str(&mp_plat_print, "\n"); + va_end(args); +} + +void mp_emitter_warning(pass_kind_t pass, const char *msg) { + if (pass == MP_PASS_CODE_SIZE) { + mp_warning(msg, NULL); + } +} + +#endif // MICROPY_WARNINGS diff --git a/user/mpy/tools/.gitattributes b/user/mpy/tools/.gitattributes new file mode 100644 index 0000000..9206a0b --- /dev/null +++ b/user/mpy/tools/.gitattributes @@ -0,0 +1 @@ +*.tar.gz binary diff --git a/user/mpy/tools/.gitignore b/user/mpy/tools/.gitignore new file mode 100644 index 0000000..9f65f49 --- /dev/null +++ b/user/mpy/tools/.gitignore @@ -0,0 +1,8 @@ +tinytest/.gitignore +tinytest/.travis.yml +tinytest/Makefile +tinytest/Makefile.arm-cortex-m3-qemu +tinytest/Makefile.avr +tinytest/TODO +tinytest/portable_demo.c +tinytest/tinytest_demo.c diff --git a/user/mpy/tools/bootstrap_upip.sh b/user/mpy/tools/bootstrap_upip.sh new file mode 100755 index 0000000..667d084 --- /dev/null +++ b/user/mpy/tools/bootstrap_upip.sh @@ -0,0 +1,30 @@ +# This script performs bootstrap installation of upip package manager from PyPI +# All the other packages can be installed using it. + +saved="$PWD" + +if [ "$1" = "" ]; then + dest=~/.micropython/lib/ +else + dest="$1" +fi + +if [ -z "$TMPDIR" ]; then + cd /tmp +else + cd $TMPDIR +fi + +# Remove any stale old version +rm -rf micropython-upip-* +wget -nd -r -l1 https://pypi.python.org/pypi/micropython-upip/ --accept-regex ".*pypi.python.org/packages/source/.*.gz" --reject=html + +tar xfz micropython-upip-*.tar.gz +tmpd="$PWD" + +cd "$saved" +mkdir -p "$dest" +cp "$tmpd"/micropython-upip-*/upip*.py "$dest" + +echo "upip is installed. To use:" +echo "micropython -m upip --help" diff --git a/user/mpy/tools/build-stm-latest.sh b/user/mpy/tools/build-stm-latest.sh new file mode 100755 index 0000000..07cb168 --- /dev/null +++ b/user/mpy/tools/build-stm-latest.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# function for building firmware +function do_build() { + descr=$1 + board=$2 + shift + shift + echo "building $descr $board" + build_dir=/tmp/stm-build-$board + make -B $@ BOARD=$board BUILD=$build_dir || exit 1 + mv $build_dir/firmware.dfu $dest_dir/$descr-$date-$git_tag.dfu + rm -rf $build_dir +} + +# check/get parameters +if [ $# != 1 ]; then + echo "usage: $0 " + exit 1 +fi + +dest_dir=$1 + +# check we are in the correct directory +if [ ! -r modpyb.c ]; then + echo "must be in stm directory" + exit 1 +fi + +# get the date +date=$(date '+%Y-%m-%d') + +# get the git tag +git_tag="$(git describe --dirty || echo unknown)" + +# build the versions +do_build pybv3 PYBV3 +do_build pybv3-network PYBV3 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1 +do_build pybv10 PYBV10 +do_build pybv10-network PYBV10 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1 +do_build stm32f4disc STM32F4DISC +do_build espruino-pico ESPRUINO_PICO diff --git a/user/mpy/tools/cc1 b/user/mpy/tools/cc1 new file mode 100755 index 0000000..827d588 --- /dev/null +++ b/user/mpy/tools/cc1 @@ -0,0 +1,262 @@ +#!/usr/bin/env python3 + +""" +This is a middle-processor for MicroPython source files. It takes the output +of the C preprocessor, has the option to change it, then feeds this into the +C compiler. + +It currently has the ability to reorder static hash tables so they are actually +hashed, resulting in faster lookup times at runtime. + +To use, configure the Python variables below, and add the following line to the +Makefile: + +CFLAGS += -no-integrated-cpp -B$(shell pwd)/../tools +""" + +import sys +import os +import re + +################################################################################ +# these are the configuration variables +# TODO somehow make them externally configurable + +# this is the path to the true C compiler +cc1_path = '/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1' +#cc1_path = '/usr/lib/gcc/arm-none-eabi/5.3.0/cc1' + +# this must be the same as MICROPY_QSTR_BYTES_IN_HASH +bytes_in_qstr_hash = 2 + +# this must be 1 or more (can be a decimal) +# larger uses more code size but yields faster lookups +table_size_mult = 1 + +# these control output during processing +print_stats = True +print_debug = False + +# end configuration variables +################################################################################ + +# precompile regexs +re_preproc_line = re.compile(r'# [0-9]+ ') +re_map_entry = re.compile(r'\{.+?\(MP_QSTR_([A-Za-z0-9_]+)\).+\},') +re_mp_obj_dict_t = re.compile(r'(?P(static )?const mp_obj_dict_t (?P[a-z0-9_]+) = \{ \.base = \{&mp_type_dict\}, \.map = \{ \.all_keys_are_qstrs = 1, \.is_fixed = 1, \.is_ordered = )1(?P, \.used = .+ };)$') +re_mp_map_t = re.compile(r'(?P(static )?const mp_map_t (?P[a-z0-9_]+) = \{ \.all_keys_are_qstrs = 1, \.is_fixed = 1, \.is_ordered = )1(?P, \.used = .+ };)$') +re_mp_rom_map_elem_t = re.compile(r'static const mp_rom_map_elem_t [a-z_0-9]+\[\] = {$') + +# this must match the equivalent function in qstr.c +def compute_hash(qstr): + hash = 5381 + for char in qstr: + hash = (hash * 33) ^ ord(char) + # Make sure that valid hash is never zero, zero means "hash not computed" + return (hash & ((1 << (8 * bytes_in_qstr_hash)) - 1)) or 1 + +# this algo must match the equivalent in map.c +def hash_insert(map, key, value): + hash = compute_hash(key) + pos = hash % len(map) + start_pos = pos + if print_debug: + print(' insert %s: start at %u/%u -- ' % (key, pos, len(map)), end='') + while True: + if map[pos] is None: + # found empty slot, so key is not in table + if print_debug: + print('put at %u' % pos) + map[pos] = (key, value) + return + else: + # not yet found, keep searching + if map[pos][0] == key: + raise AssertionError("duplicate key '%s'" % (key,)) + pos = (pos + 1) % len(map) + assert pos != start_pos + +def hash_find(map, key): + hash = compute_hash(key) + pos = hash % len(map) + start_pos = pos + attempts = 0 + while True: + attempts += 1 + if map[pos] is None: + return attempts, None + elif map[pos][0] == key: + return attempts, map[pos][1] + else: + pos = (pos + 1) % len(map) + if pos == start_pos: + return attempts, None + +def process_map_table(file, line, output): + output.append(line) + + # consume all lines that are entries of the table and concat them + # (we do it this way because there can be multiple entries on one line) + table_contents = [] + while True: + line = file.readline() + if len(line) == 0: + print('unexpected end of input') + sys.exit(1) + line = line.strip() + if len(line) == 0: + # empty line + continue + if re_preproc_line.match(line): + # preprocessor line number comment + continue + if line == '};': + # end of table (we assume it appears on a single line) + break + table_contents.append(line) + + # make combined string of entries + entries_str = ''.join(table_contents) + + # split into individual entries + entries = [] + while entries_str: + # look for single entry, by matching nested braces + match = None + if entries_str[0] == '{': + nested_braces = 0 + for i in range(len(entries_str)): + if entries_str[i] == '{': + nested_braces += 1 + elif entries_str[i] == '}': + nested_braces -= 1 + if nested_braces == 0: + match = re_map_entry.match(entries_str[:i + 2]) + break + + if not match: + print('unknown line in table:', entries_str) + sys.exit(1) + + # extract single entry + line = match.group(0) + qstr = match.group(1) + entries_str = entries_str[len(line):].lstrip() + + # add the qstr and the whole line to list of all entries + entries.append((qstr, line)) + + # sort entries so hash table construction is deterministic + entries.sort() + + # create hash table + map = [None] * int(len(entries) * table_size_mult) + for qstr, line in entries: + # We assume that qstr does not have any escape sequences in it. + # This is reasonably safe, since keys in a module or class dict + # should be standard identifiers. + # TODO verify this and raise an error if escape sequence found + hash_insert(map, qstr, line) + + # compute statistics + total_attempts = 0 + for qstr, _ in entries: + attempts, line = hash_find(map, qstr) + assert line is not None + if print_debug: + print(' %s lookup took %u attempts' % (qstr, attempts)) + total_attempts += attempts + if len(entries): + stats = len(map), len(entries) / len(map), total_attempts / len(entries) + else: + stats = 0, 0, 0 + if print_debug: + print(' table stats: size=%d, load=%.2f, avg_lookups=%.1f' % stats) + + # output hash table + for row in map: + if row is None: + output.append('{ 0, 0 },\n') + else: + output.append(row[1] + '\n') + output.append('};\n') + + # skip to next non-blank line + while True: + line = file.readline() + if len(line) == 0: + print('unexpected end of input') + sys.exit(1) + line = line.strip() + if len(line) == 0: + continue + break + + # transform the is_ordered param from 1 to 0 + match = re_mp_obj_dict_t.match(line) + if match is None: + match = re_mp_map_t.match(line) + if match is None: + print('expecting mp_obj_dict_t or mp_map_t definition') + print(output[0]) + print(line) + sys.exit(1) + line = match.group('head') + '0' + match.group('tail') + '\n' + output.append(line) + + return (match.group('id'),) + stats + +def process_file(filename): + output = [] + file_changed = False + with open(filename, 'rt') as f: + while True: + line = f.readline() + if not line: + break + if re_mp_rom_map_elem_t.match(line): + file_changed = True + stats = process_map_table(f, line, output) + if print_stats: + print(' [%s: size=%d, load=%.2f, avg_lookups=%.1f]' % stats) + else: + output.append(line) + + if file_changed: + if print_debug: + print(' modifying static maps in', output[0].strip()) + with open(filename, 'wt') as f: + for line in output: + f.write(line) + +def main(): + # run actual C compiler + # need to quote args that have special characters in them + def quote(s): + if s.find('<') != -1 or s.find('>') != -1: + return "'" + s + "'" + else: + return s + ret = os.system(cc1_path + ' ' + ' '.join(quote(s) for s in sys.argv[1:])) + if ret != 0: + ret = (ret & 0x7f) or 127 # make it in range 0-127, but non-zero + sys.exit(ret) + + if sys.argv[1] == '-E': + # CPP has been run, now do our processing stage + for i, arg in enumerate(sys.argv): + if arg == '-o': + return process_file(sys.argv[i + 1]) + + print('%s: could not find "-o" option' % (sys.argv[0],)) + sys.exit(1) + elif sys.argv[1] == '-fpreprocessed': + # compiler has been run, nothing more to do + return + else: + # unknown processing stage + print('%s: unknown first option "%s"' % (sys.argv[0], sys.argv[1])) + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/user/mpy/tools/check_code_size.sh b/user/mpy/tools/check_code_size.sh new file mode 100755 index 0000000..c5f0c6f --- /dev/null +++ b/user/mpy/tools/check_code_size.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# This script check that changes don't lead to code size regressions. +# (Size of the language core (== minimal port should not grow)). +# + +REFERENCE=$HOME/persist/firmware.bin +#REFERENCE=/tmp/micropython +#TRAVIS_PULL_REQUEST=false + +if [ -f $REFERENCE ]; then + size_old=$(stat -c%s $REFERENCE) + size_new=$(stat -c%s minimal/build/firmware.bin) + echo "Old size: $size_old new size: $size_new" + if [ $size_new -gt $size_old ]; then + echo "Validation failure: Core code size increased" + if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + exit 1 + fi + fi +else + echo "Warning: reference file doesn't exist, code size check didn't run" +fi diff --git a/user/mpy/tools/codestats.sh b/user/mpy/tools/codestats.sh new file mode 100755 index 0000000..5272f3e --- /dev/null +++ b/user/mpy/tools/codestats.sh @@ -0,0 +1,187 @@ +#!/bin/sh +# +# This script generates statistics (build size, speed) for successive +# revisions of the code. It checks out git commits one an a time, compiles +# various ports to determine their size, and runs pystone on the unix port. +# Results are collected in the output file. +# +# Note: you will need to copy this file out of the tools directory before +# executing because it does not exist in old revisions of the repository. + +# check that we are in the root directory of the repository +if [ ! -d py -o ! -d unix -o ! -d stmhal ]; then + echo "script must be run from root of the repository" + exit 1 +fi + +# output file for the data; data is appended if file already exists +output=codestats.dat + +# utility programs +RM=/bin/rm +AWK=awk +MAKE="make -j2" + +# these are the binaries that are built; some have 2 or 3 depending on version +bin_unix=unix/micropython +bin_stmhal=stmhal/build-PYBV10/firmware.elf +bin_barearm_1=bare-arm/build/flash.elf +bin_barearm_2=bare-arm/build/firmware.elf +bin_minimal=minimal/build/firmware.elf +bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf +bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf +bin_cc3200_3=cc3200/build/WIPY/release/application.axf + +# start at zero size; if build fails reuse previous valid size +size_unix="0" +size_stmhal="0" +size_barearm="0" +size_minimal="0" +size_cc3200="0" + +# start at zero pystones +pystones="0" + +# this code runs pystone and averages the results +pystoneavg=/tmp/pystoneavg.py +cat > $pystoneavg << EOF +import pystone +samples = [pystone.pystones(300000)[1] for i in range(5)] +samples.sort() +stones = sum(samples[1:-1]) / (len(samples) - 2) # exclude smallest and largest +print("stones %g" % stones) +EOF + +function get_size() { + if [ -r $2 ]; then + size $2 | tail -n1 | $AWK '{print $1}' + else + echo $1 + fi +} + +function get_size2() { + if [ -r $2 ]; then + size $2 | tail -n1 | $AWK '{print $1}' + elif [ -r $3 ]; then + size $3 | tail -n1 | $AWK '{print $1}' + else + echo $1 + fi +} + +function get_size3() { + if [ -r $2 ]; then + size $2 | tail -n1 | $AWK '{print $1}' + elif [ -r $3 ]; then + size $3 | tail -n1 | $AWK '{print $1}' + elif [ -r $4 ]; then + size $4 | tail -n1 | $AWK '{print $1}' + else + echo $1 + fi +} + +# get the last revision in the data file; or start at v1.0 if no file +if [ -r $output ]; then + last_rev=$(tail -n1 $output | $AWK '{print $1}') +else + echo "# hash size_unix size_stmhal size_barearm size_minimal size_cc3200 pystones" > $output + last_rev="v1.0" +fi + +# get a list of hashes between last revision (exclusive) and master +hashes=$(git log --format=format:"%H" --reverse ${last_rev}..master) +#hashes=$(git log --format=format:"%H" --reverse ${last_rev}..master | $AWK '{if (NR % 10 == 0) print $0}') # do every 10th one + +for hash in $hashes; do + + #### checkout the revision #### + + git checkout $hash + if [ $? -ne 0 ]; then + echo "aborting" + exit 1 + fi + + #### apply patches to get it to build #### + + if grep -q '#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX' unix/modtime.c; then + echo apply patch + git apply - << EOF +diff --git a/unix/modtime.c b/unix/modtime.c +index 77d2945..dae0644 100644 +--- a/unix/modtime.c ++++ b/unix/modtime.c +@@ -55,10 +55,8 @@ void msec_sleep_tv(struct timeval *tv) { + #define MP_CLOCKS_PER_SEC CLOCKS_PER_SEC + #endif + +-#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX +-#define CLOCK_DIV 1000.0 +-#elif defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000) // WIN32 +-#define CLOCK_DIV 1.0 ++#if defined(MP_CLOCKS_PER_SEC) ++#define CLOCK_DIV (MP_CLOCKS_PER_SEC / 1000.0F) + #else + #error Unsupported clock() implementation + #endif +EOF + fi + + #### unix #### + + $RM $bin_unix + $MAKE -C unix CFLAGS_EXTRA=-DNDEBUG + size_unix=$(get_size $size_unix $bin_unix) + + # undo patch if it was applied + git checkout unix/modtime.c + + #### stmhal #### + + $RM $bin_stmhal + $MAKE -C stmhal board=PYBV10 + size_stmhal=$(get_size $size_stmhal $bin_stmhal) + + #### bare-arm #### + + $RM $bin_barearm_1 $bin_barearm_2 + $MAKE -C bare-arm + size_barearm=$(get_size2 $size_barearm $bin_barearm_1 $bin_barearm_2) + + #### minimal #### + + if [ -r minimal/Makefile ]; then + $RM $bin_minimal + $MAKE -C minimal CROSS=1 + size_minimal=$(get_size $size_minimal $bin_minimal) + fi + + #### cc3200 #### + + if [ -r cc3200/Makefile ]; then + $RM $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3 + $MAKE -C cc3200 BTARGET=application + size_cc3200=$(get_size3 $size_cc3200 $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3) + fi + + #### run pystone #### + + if [ -x $bin_unix ]; then + new_pystones=$($bin_unix $pystoneavg) + # only update the variable if pystone executed successfully + if echo $new_pystones | grep -q "^stones"; then + pystones=$(echo $new_pystones | $AWK '{print $2}') + fi + fi + + #### output data for this commit #### + + echo "$hash $size_unix $size_stmhal $size_barearm $size_minimal $size_cc3200 $pystones" >> $output + +done + +# checkout master and cleanup +git checkout master +$RM $pystoneavg diff --git a/user/mpy/tools/dfu.py b/user/mpy/tools/dfu.py new file mode 100755 index 0000000..54b6024 --- /dev/null +++ b/user/mpy/tools/dfu.py @@ -0,0 +1,121 @@ +#!/usr/bin/python + +# Written by Antonio Galea - 2010/11/18 +# Distributed under Gnu LGPL 3.0 +# see http://www.gnu.org/licenses/lgpl-3.0.txt + +import sys,struct,zlib,os +from optparse import OptionParser + +DEFAULT_DEVICE="0x0483:0xdf11" + +def named(tuple,names): + return dict(zip(names.split(),tuple)) +def consume(fmt,data,names): + n = struct.calcsize(fmt) + return named(struct.unpack(fmt,data[:n]),names),data[n:] +def cstring(string): + return string.split('\0',1)[0] +def compute_crc(data): + return 0xFFFFFFFF & -zlib.crc32(data) -1 + +def parse(file,dump_images=False): + print ('File: "%s"' % file) + data = open(file,'rb').read() + crc = compute_crc(data[:-4]) + prefix, data = consume('<5sBIB',data,'signature version size targets') + print ('%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix) + for t in range(prefix['targets']): + tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') + tprefix['num'] = t + if tprefix['named']: + tprefix['name'] = cstring(tprefix['name']) + else: + tprefix['name'] = '' + print ('%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix) + tsize = tprefix['size'] + target, data = data[:tsize], data[tsize:] + for e in range(tprefix['elements']): + eprefix, target = consume('<2I',target,'address size') + eprefix['num'] = e + print (' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix) + esize = eprefix['size'] + image, target = target[:esize], target[esize:] + if dump_images: + out = '%s.target%d.image%d.bin' % (file,t,e) + open(out,'wb').write(image) + print (' DUMPED IMAGE TO "%s"' % out) + if len(target): + print ("target %d: PARSE ERROR" % t) + suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') + print ('usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix) + if crc != suffix['crc']: + print ("CRC ERROR: computed crc32 is 0x%08x" % crc) + data = data[16:] + if data: + print ("PARSE ERROR") + +def build(file,targets,device=DEFAULT_DEVICE): + data = b'' + for t,target in enumerate(targets): + tdata = b'' + for image in target: + tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] + tdata = struct.pack('<6sBI255s2I',b'Target',0,1, b'ST...',len(tdata),len(target)) + tdata + data += tdata + data = struct.pack('<5sBIB',b'DfuSe',1,len(data)+11,len(targets)) + data + v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) + data += struct.pack('<4H3sB',0,d,v,0x011a,b'UFD',16) + crc = compute_crc(data) + data += struct.pack('= len(class_) or section[i] != class_[i]: + if i == 0: + filename = section[i].replace(' ', '_').lower() + rst = open(DOCPATH + filename + '.rst', 'w') + rst.write(HEADER) + rst.write(section[i] + '\n') + rst.write(RSTCHARS[0] * len(section[i])) + rst.write(time.strftime("\nGenerated %a %d %b %Y %X UTC\n\n", time.gmtime())) + toctree.append(filename) + else: + rst.write(section[i] + '\n') + rst.write(RSTCHARS[min(i, len(RSTCHARS)-1)] * len(section[i])) + rst.write('\n\n') + class_ = section + rst.write('.. _cpydiff_%s:\n\n' % output.name.rsplit('.', 1)[0]) + rst.write(output.desc + '\n') + rst.write('~' * len(output.desc) + '\n\n') + if output.cause != 'Unknown': + rst.write('**Cause:** ' + output.cause + '\n\n') + if output.workaround != 'Unknown': + rst.write('**Workaround:** ' + output.workaround + '\n\n') + + rst.write('Sample code::\n\n' + indent(output.code, TAB) + '\n') + output_cpy = indent(''.join(output.output_cpy[0:2]), TAB).rstrip() + output_cpy = ('::\n\n' if output_cpy != '' else '') + output_cpy + output_upy = indent(''.join(output.output_upy[0:2]), TAB).rstrip() + output_upy = ('::\n\n' if output_upy != '' else '') + output_upy + table = gen_table([['CPy output:', output_cpy], ['uPy output:', output_upy]]) + rst.write(table) + + template = open(INDEXTEMPLATE, 'r') + index = open(DOCPATH + INDEX, 'w') + index.write(HEADER) + index.write(template.read()) + for section in INDEXPRIORITY: + if section in toctree: + index.write(indent(section + '.rst', TAB)) + toctree.remove(section) + for section in toctree: + index.write(indent(section + '.rst', TAB)) + +def main(): + """ Main function """ + + # set search path so that test scripts find the test modules (and no other ones) + os.environ['PYTHONPATH'] = TESTPATH + os.environ['MICROPYPATH'] = TESTPATH + + files = readfiles() + results = run_tests(files) + gen_rst(results) + +main() diff --git a/user/mpy/tools/gendoc.py b/user/mpy/tools/gendoc.py new file mode 100644 index 0000000..61844d2 --- /dev/null +++ b/user/mpy/tools/gendoc.py @@ -0,0 +1,528 @@ +""" +Generate documentation for pyboard API from C files. +""" + +import os +import argparse +import re +import markdown + +# given a list of (name,regex) pairs, find the first one that matches the given line +def re_match_first(regexs, line): + for name, regex in regexs: + match = re.match(regex, line) + if match: + return name, match + return None, None + +def makedirs(d): + if not os.path.isdir(d): + os.makedirs(d) + +class Lexer: + class LexerError(Exception): + pass + + class EOF(Exception): + pass + + class Break(Exception): + pass + + def __init__(self, file): + self.filename = file + with open(file, 'rt') as f: + line_num = 0 + lines = [] + for line in f: + line_num += 1 + line = line.strip() + if line == '///': + lines.append((line_num, '')) + elif line.startswith('/// '): + lines.append((line_num, line[4:])) + elif len(lines) > 0 and lines[-1][1] is not None: + lines.append((line_num, None)) + if len(lines) > 0 and lines[-1][1] is not None: + lines.append((line_num, None)) + self.cur_line = 0 + self.lines = lines + + def opt_break(self): + if len(self.lines) > 0 and self.lines[0][1] is None: + self.lines.pop(0) + + def next(self): + if len(self.lines) == 0: + raise Lexer.EOF + else: + l = self.lines.pop(0) + self.cur_line = l[0] + if l[1] is None: + raise Lexer.Break + else: + return l[1] + + def error(self, msg): + print('({}:{}) {}'.format(self.filename, self.cur_line, msg)) + raise Lexer.LexerError + +class MarkdownWriter: + def __init__(self): + pass + + def start(self): + self.lines = [] + + def end(self): + return '\n'.join(self.lines) + + def heading(self, level, text): + if len(self.lines) > 0: + self.lines.append('') + self.lines.append(level * '#' + ' ' + text) + self.lines.append('') + + def para(self, text): + if len(self.lines) > 0 and self.lines[-1] != '': + self.lines.append('') + if isinstance(text, list): + self.lines.extend(text) + elif isinstance(text, str): + self.lines.append(text) + else: + assert False + self.lines.append('') + + def single_line(self, text): + self.lines.append(text) + + def module(self, name, short_descr, descr): + self.heading(1, 'module {}'.format(name)) + self.para(descr) + + def function(self, ctx, name, args, descr): + proto = '{}.{}{}'.format(ctx, self.name, self.args) + self.heading(3, '`' + proto + '`') + self.para(descr) + + def method(self, ctx, name, args, descr): + if name == '\\constructor': + proto = '{}{}'.format(ctx, args) + elif name == '\\call': + proto = '{}{}'.format(ctx, args) + else: + proto = '{}.{}{}'.format(ctx, name, args) + self.heading(3, '`' + proto + '`') + self.para(descr) + + def constant(self, ctx, name, descr): + self.single_line('`{}.{}` - {}'.format(ctx, name, descr)) + +class ReStructuredTextWriter: + head_chars = {1:'=', 2:'-', 3:'.'} + + def __init__(self): + pass + + def start(self): + self.lines = [] + + def end(self): + return '\n'.join(self.lines) + + def _convert(self, text): + return text.replace('`', '``').replace('*', '\\*') + + def heading(self, level, text, convert=True): + if len(self.lines) > 0: + self.lines.append('') + if convert: + text = self._convert(text) + self.lines.append(text) + self.lines.append(len(text) * self.head_chars[level]) + self.lines.append('') + + def para(self, text, indent=''): + if len(self.lines) > 0 and self.lines[-1] != '': + self.lines.append('') + if isinstance(text, list): + for t in text: + self.lines.append(indent + self._convert(t)) + elif isinstance(text, str): + self.lines.append(indent + self._convert(text)) + else: + assert False + self.lines.append('') + + def single_line(self, text): + self.lines.append(self._convert(text)) + + def module(self, name, short_descr, descr): + self.heading(1, ':mod:`{}` --- {}'.format(name, self._convert(short_descr)), convert=False) + self.lines.append('.. module:: {}'.format(name)) + self.lines.append(' :synopsis: {}'.format(short_descr)) + self.para(descr) + + def function(self, ctx, name, args, descr): + args = self._convert(args) + self.lines.append('.. function:: ' + name + args) + self.para(descr, indent=' ') + + def method(self, ctx, name, args, descr): + args = self._convert(args) + if name == '\\constructor': + self.lines.append('.. class:: ' + ctx + args) + elif name == '\\call': + self.lines.append('.. method:: ' + ctx + args) + else: + self.lines.append('.. method:: ' + ctx + '.' + name + args) + self.para(descr, indent=' ') + + def constant(self, ctx, name, descr): + self.lines.append('.. data:: ' + name) + self.para(descr, indent=' ') + +class DocValidateError(Exception): + pass + +class DocItem: + def __init__(self): + self.doc = [] + + def add_doc(self, lex): + try: + while True: + line = lex.next() + if len(line) > 0 or len(self.doc) > 0: + self.doc.append(line) + except Lexer.Break: + pass + + def dump(self, writer): + writer.para(self.doc) + +class DocConstant(DocItem): + def __init__(self, name, descr): + super().__init__() + self.name = name + self.descr = descr + + def dump(self, ctx, writer): + writer.constant(ctx, self.name, self.descr) + +class DocFunction(DocItem): + def __init__(self, name, args): + super().__init__() + self.name = name + self.args = args + + def dump(self, ctx, writer): + writer.function(ctx, self.name, self.args, self.doc) + +class DocMethod(DocItem): + def __init__(self, name, args): + super().__init__() + self.name = name + self.args = args + + def dump(self, ctx, writer): + writer.method(ctx, self.name, self.args, self.doc) + +class DocClass(DocItem): + def __init__(self, name, descr): + super().__init__() + self.name = name + self.descr = descr + self.constructors = {} + self.classmethods = {} + self.methods = {} + self.constants = {} + + def process_classmethod(self, lex, d): + name = d['id'] + if name == '\\constructor': + dict_ = self.constructors + else: + dict_ = self.classmethods + if name in dict_: + lex.error("multiple definition of method '{}'".format(name)) + method = dict_[name] = DocMethod(name, d['args']) + method.add_doc(lex) + + def process_method(self, lex, d): + name = d['id'] + dict_ = self.methods + if name in dict_: + lex.error("multiple definition of method '{}'".format(name)) + method = dict_[name] = DocMethod(name, d['args']) + method.add_doc(lex) + + def process_constant(self, lex, d): + name = d['id'] + if name in self.constants: + lex.error("multiple definition of constant '{}'".format(name)) + self.constants[name] = DocConstant(name, d['descr']) + lex.opt_break() + + def dump(self, writer): + writer.heading(1, 'class {}'.format(self.name)) + super().dump(writer) + if len(self.constructors) > 0: + writer.heading(2, 'Constructors') + for f in sorted(self.constructors.values(), key=lambda x:x.name): + f.dump(self.name, writer) + if len(self.classmethods) > 0: + writer.heading(2, 'Class methods') + for f in sorted(self.classmethods.values(), key=lambda x:x.name): + f.dump(self.name, writer) + if len(self.methods) > 0: + writer.heading(2, 'Methods') + for f in sorted(self.methods.values(), key=lambda x:x.name): + f.dump(self.name.lower(), writer) + if len(self.constants) > 0: + writer.heading(2, 'Constants') + for c in sorted(self.constants.values(), key=lambda x:x.name): + c.dump(self.name, writer) + +class DocModule(DocItem): + def __init__(self, name, descr): + super().__init__() + self.name = name + self.descr = descr + self.functions = {} + self.constants = {} + self.classes = {} + self.cur_class = None + + def new_file(self): + self.cur_class = None + + def process_function(self, lex, d): + name = d['id'] + if name in self.functions: + lex.error("multiple definition of function '{}'".format(name)) + function = self.functions[name] = DocFunction(name, d['args']) + function.add_doc(lex) + + #def process_classref(self, lex, d): + # name = d['id'] + # self.classes[name] = name + # lex.opt_break() + + def process_class(self, lex, d): + name = d['id'] + if name in self.classes: + lex.error("multiple definition of class '{}'".format(name)) + self.cur_class = self.classes[name] = DocClass(name, d['descr']) + self.cur_class.add_doc(lex) + + def process_classmethod(self, lex, d): + self.cur_class.process_classmethod(lex, d) + + def process_method(self, lex, d): + self.cur_class.process_method(lex, d) + + def process_constant(self, lex, d): + if self.cur_class is None: + # a module-level constant + name = d['id'] + if name in self.constants: + lex.error("multiple definition of constant '{}'".format(name)) + self.constants[name] = DocConstant(name, d['descr']) + lex.opt_break() + else: + # a class-level constant + self.cur_class.process_constant(lex, d) + + def validate(self): + if self.descr is None: + raise DocValidateError('module {} referenced but never defined'.format(self.name)) + + def dump(self, writer): + writer.module(self.name, self.descr, self.doc) + if self.functions: + writer.heading(2, 'Functions') + for f in sorted(self.functions.values(), key=lambda x:x.name): + f.dump(self.name, writer) + if self.constants: + writer.heading(2, 'Constants') + for c in sorted(self.constants.values(), key=lambda x:x.name): + c.dump(self.name, writer) + if self.classes: + writer.heading(2, 'Classes') + for c in sorted(self.classes.values(), key=lambda x:x.name): + writer.para('[`{}.{}`]({}) - {}'.format(self.name, c.name, c.name, c.descr)) + + def write_html(self, dir): + md_writer = MarkdownWriter() + md_writer.start() + self.dump(md_writer) + with open(os.path.join(dir, 'index.html'), 'wt') as f: + f.write(markdown.markdown(md_writer.end())) + for c in self.classes.values(): + class_dir = os.path.join(dir, c.name) + makedirs(class_dir) + md_writer.start() + md_writer.para('part of the [{} module](./)'.format(self.name)) + c.dump(md_writer) + with open(os.path.join(class_dir, 'index.html'), 'wt') as f: + f.write(markdown.markdown(md_writer.end())) + + def write_rst(self, dir): + rst_writer = ReStructuredTextWriter() + rst_writer.start() + self.dump(rst_writer) + with open(dir + '/' + self.name + '.rst', 'wt') as f: + f.write(rst_writer.end()) + for c in self.classes.values(): + rst_writer.start() + c.dump(rst_writer) + with open(dir + '/' + self.name + '.' + c.name + '.rst', 'wt') as f: + f.write(rst_writer.end()) + +class Doc: + def __init__(self): + self.modules = {} + self.cur_module = None + + def new_file(self): + self.cur_module = None + for m in self.modules.values(): + m.new_file() + + def check_module(self, lex): + if self.cur_module is None: + lex.error('module not defined') + + def process_module(self, lex, d): + name = d['id'] + if name not in self.modules: + self.modules[name] = DocModule(name, None) + self.cur_module = self.modules[name] + if self.cur_module.descr is not None: + lex.error("multiple definition of module '{}'".format(name)) + self.cur_module.descr = d['descr'] + self.cur_module.add_doc(lex) + + def process_moduleref(self, lex, d): + name = d['id'] + if name not in self.modules: + self.modules[name] = DocModule(name, None) + self.cur_module = self.modules[name] + lex.opt_break() + + def process_class(self, lex, d): + self.check_module(lex) + self.cur_module.process_class(lex, d) + + def process_function(self, lex, d): + self.check_module(lex) + self.cur_module.process_function(lex, d) + + def process_classmethod(self, lex, d): + self.check_module(lex) + self.cur_module.process_classmethod(lex, d) + + def process_method(self, lex, d): + self.check_module(lex) + self.cur_module.process_method(lex, d) + + def process_constant(self, lex, d): + self.check_module(lex) + self.cur_module.process_constant(lex, d) + + def validate(self): + for m in self.modules.values(): + m.validate() + + def dump(self, writer): + writer.heading(1, 'Modules') + writer.para('These are the Python modules that are implemented.') + for m in sorted(self.modules.values(), key=lambda x:x.name): + writer.para('[`{}`]({}/) - {}'.format(m.name, m.name, m.descr)) + + def write_html(self, dir): + md_writer = MarkdownWriter() + with open(os.path.join(dir, 'module', 'index.html'), 'wt') as f: + md_writer.start() + self.dump(md_writer) + f.write(markdown.markdown(md_writer.end())) + for m in self.modules.values(): + mod_dir = os.path.join(dir, 'module', m.name) + makedirs(mod_dir) + m.write_html(mod_dir) + + def write_rst(self, dir): + #with open(os.path.join(dir, 'module', 'index.html'), 'wt') as f: + # f.write(markdown.markdown(self.dump())) + for m in self.modules.values(): + m.write_rst(dir) + +regex_descr = r'(?P.*)' + +doc_regexs = ( + (Doc.process_module, re.compile(r'\\module (?P[a-z][a-z0-9]*) - ' + regex_descr + r'$')), + (Doc.process_moduleref, re.compile(r'\\moduleref (?P[a-z]+)$')), + (Doc.process_function, re.compile(r'\\function (?P[a-z0-9_]+)(?P\(.*\))$')), + (Doc.process_classmethod, re.compile(r'\\classmethod (?P\\?[a-z0-9_]+)(?P\(.*\))$')), + (Doc.process_method, re.compile(r'\\method (?P\\?[a-z0-9_]+)(?P\(.*\))$')), + (Doc.process_constant, re.compile(r'\\constant (?P[A-Za-z0-9_]+) - ' + regex_descr + r'$')), + #(Doc.process_classref, re.compile(r'\\classref (?P[A-Za-z0-9_]+)$')), + (Doc.process_class, re.compile(r'\\class (?P[A-Za-z0-9_]+) - ' + regex_descr + r'$')), +) + +def process_file(file, doc): + lex = Lexer(file) + doc.new_file() + try: + try: + while True: + line = lex.next() + fun, match = re_match_first(doc_regexs, line) + if fun == None: + lex.error('unknown line format: {}'.format(line)) + fun(doc, lex, match.groupdict()) + + except Lexer.Break: + lex.error('unexpected break') + + except Lexer.EOF: + pass + + except Lexer.LexerError: + return False + + return True + +def main(): + cmd_parser = argparse.ArgumentParser(description='Generate documentation for pyboard API from C files.') + cmd_parser.add_argument('--outdir', metavar='', default='gendoc-out', help='ouput directory') + cmd_parser.add_argument('--format', default='html', help='output format: html or rst') + cmd_parser.add_argument('files', nargs='+', help='input files') + args = cmd_parser.parse_args() + + doc = Doc() + for file in args.files: + print('processing', file) + if not process_file(file, doc): + return + try: + doc.validate() + except DocValidateError as e: + print(e) + + makedirs(args.outdir) + + if args.format == 'html': + doc.write_html(args.outdir) + elif args.format == 'rst': + doc.write_rst(args.outdir) + else: + print('unknown format:', args.format) + return + + print('written to', args.outdir) + +if __name__ == "__main__": + main() diff --git a/user/mpy/tools/insert-usb-ids.py b/user/mpy/tools/insert-usb-ids.py new file mode 100644 index 0000000..cdccd3b --- /dev/null +++ b/user/mpy/tools/insert-usb-ids.py @@ -0,0 +1,34 @@ +# Reads the USB VID and PID from the file specified by sys.argv[1] and then +# inserts those values into the template file specified by sys.argv[2], +# printing the result to stdout + +from __future__ import print_function + +import sys +import re +import string + +needed_keys = ('USB_PID_CDC_MSC', 'USB_PID_CDC_HID', 'USB_PID_CDC', 'USB_VID') + +def parse_usb_ids(filename): + rv = dict() + for line in open(filename).readlines(): + line = line.rstrip('\r\n') + match = re.match('^#define\s+(\w+)\s+\(0x([0-9A-Fa-f]+)\)$', line) + if match and match.group(1).startswith('USBD_'): + key = match.group(1).replace('USBD', 'USB') + val = match.group(2) + print("key =", key, "val =", val) + if key in needed_keys: + rv[key] = val + for k in needed_keys: + if k not in rv: + raise Exception("Unable to parse %s from %s" % (k, filename)) + return rv + +if __name__ == "__main__": + usb_ids_file = sys.argv[1] + template_file = sys.argv[2] + replacements = parse_usb_ids(usb_ids_file) + for line in open(template_file, 'r').readlines(): + print(string.Template(line).safe_substitute(replacements), end='') diff --git a/user/mpy/tools/make-frozen.py b/user/mpy/tools/make-frozen.py new file mode 100755 index 0000000..1051b52 --- /dev/null +++ b/user/mpy/tools/make-frozen.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# +# Create frozen modules structure for MicroPython. +# +# Usage: +# +# Have a directory with modules to be frozen (only modules, not packages +# supported so far): +# +# frozen/foo.py +# frozen/bar.py +# +# Run script, passing path to the directory above: +# +# ./make-frozen.py frozen > frozen.c +# +# Include frozen.c in your build, having defined MICROPY_MODULE_FROZEN_STR in +# config. +# +from __future__ import print_function +import sys +import os + + +def module_name(f): + return f + +modules = [] + +root = sys.argv[1].rstrip("/") +root_len = len(root) + +for dirpath, dirnames, filenames in os.walk(root): + for f in filenames: + fullpath = dirpath + "/" + f + st = os.stat(fullpath) + modules.append((fullpath[root_len + 1:], st)) + +print("#include ") +print("const char mp_frozen_str_names[] = {") +for f, st in modules: + m = module_name(f) + print('"%s\\0"' % m) +print('"\\0"};') + +print("const uint32_t mp_frozen_str_sizes[] = {") + +for f, st in modules: + print("%d," % st.st_size) + +print("};") + +print("const char mp_frozen_str_content[] = {") +for f, st in modules: + data = open(sys.argv[1] + "/" + f, "rb").read() + + # We need to properly escape the script data to create a C string. + # When C parses hex characters of the form \x00 it keeps parsing the hex + # data until it encounters a non-hex character. Thus one must create + # strings of the form "data\x01" "abc" to properly encode this kind of + # data. We could just encode all characters as hex digits but it's nice + # to be able to read the resulting C code as ASCII when possible. + + data = bytearray(data) # so Python2 extracts each byte as an integer + esc_dict = {ord('\n'): '\\n', ord('\r'): '\\r', ord('"'): '\\"', ord('\\'): '\\\\'} + chrs = ['"'] + break_str = False + for c in data: + try: + chrs.append(esc_dict[c]) + except KeyError: + if 32 <= c <= 126: + if break_str: + chrs.append('" "') + break_str = False + chrs.append(chr(c)) + else: + chrs.append('\\x%02x' % c) + break_str = True + chrs.append('\\0"') + print(''.join(chrs)) + +print("};") diff --git a/user/mpy/tools/mpy-tool.py b/user/mpy/tools/mpy-tool.py new file mode 100755 index 0000000..887b3f5 --- /dev/null +++ b/user/mpy/tools/mpy-tool.py @@ -0,0 +1,593 @@ +#!/usr/bin/env python3 +# +# This file is part of the MicroPython project, http://micropython.org/ +# +# The MIT License (MIT) +# +# Copyright (c) 2016 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. + +# Python 2/3 compatibility code +from __future__ import print_function +import platform +if platform.python_version_tuple()[0] == '2': + str_cons = lambda val, enc=None: val + bytes_cons = lambda val, enc=None: bytearray(val) + is_str_type = lambda o: type(o) is str + is_bytes_type = lambda o: type(o) is bytearray + is_int_type = lambda o: type(o) is int or type(o) is long +else: + str_cons = str + bytes_cons = bytes + is_str_type = lambda o: type(o) is str + is_bytes_type = lambda o: type(o) is bytes + is_int_type = lambda o: type(o) is int +# end compatibility code + +import sys +import struct +from collections import namedtuple + +sys.path.append(sys.path[0] + '/../py') +import makeqstrdata as qstrutil + +class FreezeError(Exception): + def __init__(self, rawcode, msg): + self.rawcode = rawcode + self.msg = msg + + def __str__(self): + return 'error while freezing %s: %s' % (self.rawcode.source_file, self.msg) + +class Config: + MPY_VERSION = 2 + MICROPY_LONGINT_IMPL_NONE = 0 + MICROPY_LONGINT_IMPL_LONGLONG = 1 + MICROPY_LONGINT_IMPL_MPZ = 2 +config = Config() + +MP_OPCODE_BYTE = 0 +MP_OPCODE_QSTR = 1 +MP_OPCODE_VAR_UINT = 2 +MP_OPCODE_OFFSET = 3 + +# extra bytes: +MP_BC_MAKE_CLOSURE = 0x62 +MP_BC_MAKE_CLOSURE_DEFARGS = 0x63 +MP_BC_RAISE_VARARGS = 0x5c +# extra byte if caching enabled: +MP_BC_LOAD_NAME = 0x1c +MP_BC_LOAD_GLOBAL = 0x1d +MP_BC_LOAD_ATTR = 0x1e +MP_BC_STORE_ATTR = 0x26 + +def make_opcode_format(): + def OC4(a, b, c, d): + return a | (b << 2) | (c << 4) | (d << 6) + U = 0 + B = 0 + Q = 1 + V = 2 + O = 3 + return bytes_cons(( + # this table is taken verbatim from py/bc.c + OC4(U, U, U, U), # 0x00-0x03 + OC4(U, U, U, U), # 0x04-0x07 + OC4(U, U, U, U), # 0x08-0x0b + OC4(U, U, U, U), # 0x0c-0x0f + OC4(B, B, B, U), # 0x10-0x13 + OC4(V, U, Q, V), # 0x14-0x17 + OC4(B, V, V, Q), # 0x18-0x1b + OC4(Q, Q, Q, Q), # 0x1c-0x1f + OC4(B, B, V, V), # 0x20-0x23 + OC4(Q, Q, Q, B), # 0x24-0x27 + OC4(V, V, Q, Q), # 0x28-0x2b + OC4(U, U, U, U), # 0x2c-0x2f + OC4(B, B, B, B), # 0x30-0x33 + OC4(B, O, O, O), # 0x34-0x37 + OC4(O, O, U, U), # 0x38-0x3b + OC4(U, O, B, O), # 0x3c-0x3f + OC4(O, B, B, O), # 0x40-0x43 + OC4(B, B, O, U), # 0x44-0x47 + OC4(U, U, U, U), # 0x48-0x4b + OC4(U, U, U, U), # 0x4c-0x4f + OC4(V, V, U, V), # 0x50-0x53 + OC4(B, U, V, V), # 0x54-0x57 + OC4(V, V, V, B), # 0x58-0x5b + OC4(B, B, B, U), # 0x5c-0x5f + OC4(V, V, V, V), # 0x60-0x63 + OC4(V, V, V, V), # 0x64-0x67 + OC4(Q, Q, B, U), # 0x68-0x6b + OC4(U, U, U, U), # 0x6c-0x6f + + OC4(B, B, B, B), # 0x70-0x73 + OC4(B, B, B, B), # 0x74-0x77 + OC4(B, B, B, B), # 0x78-0x7b + OC4(B, B, B, B), # 0x7c-0x7f + OC4(B, B, B, B), # 0x80-0x83 + OC4(B, B, B, B), # 0x84-0x87 + OC4(B, B, B, B), # 0x88-0x8b + OC4(B, B, B, B), # 0x8c-0x8f + OC4(B, B, B, B), # 0x90-0x93 + OC4(B, B, B, B), # 0x94-0x97 + OC4(B, B, B, B), # 0x98-0x9b + OC4(B, B, B, B), # 0x9c-0x9f + OC4(B, B, B, B), # 0xa0-0xa3 + OC4(B, B, B, B), # 0xa4-0xa7 + OC4(B, B, B, B), # 0xa8-0xab + OC4(B, B, B, B), # 0xac-0xaf + + OC4(B, B, B, B), # 0xb0-0xb3 + OC4(B, B, B, B), # 0xb4-0xb7 + OC4(B, B, B, B), # 0xb8-0xbb + OC4(B, B, B, B), # 0xbc-0xbf + + OC4(B, B, B, B), # 0xc0-0xc3 + OC4(B, B, B, B), # 0xc4-0xc7 + OC4(B, B, B, B), # 0xc8-0xcb + OC4(B, B, B, B), # 0xcc-0xcf + + OC4(B, B, B, B), # 0xd0-0xd3 + OC4(B, B, B, B), # 0xd4-0xd7 + OC4(B, B, B, B), # 0xd8-0xdb + OC4(B, B, B, B), # 0xdc-0xdf + + OC4(B, B, B, B), # 0xe0-0xe3 + OC4(B, B, B, B), # 0xe4-0xe7 + OC4(B, B, B, B), # 0xe8-0xeb + OC4(B, B, B, B), # 0xec-0xef + + OC4(B, B, B, B), # 0xf0-0xf3 + OC4(B, B, B, B), # 0xf4-0xf7 + OC4(B, B, B, U), # 0xf8-0xfb + OC4(U, U, U, U), # 0xfc-0xff + )) + +# this function mirrors that in py/bc.c +def mp_opcode_format(bytecode, ip, opcode_format=make_opcode_format()): + opcode = bytecode[ip] + ip_start = ip + f = (opcode_format[opcode >> 2] >> (2 * (opcode & 3))) & 3 + if f == MP_OPCODE_QSTR: + ip += 3 + else: + extra_byte = ( + opcode == MP_BC_RAISE_VARARGS + or opcode == MP_BC_MAKE_CLOSURE + or opcode == MP_BC_MAKE_CLOSURE_DEFARGS + or config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE and ( + opcode == MP_BC_LOAD_NAME + or opcode == MP_BC_LOAD_GLOBAL + or opcode == MP_BC_LOAD_ATTR + or opcode == MP_BC_STORE_ATTR + ) + ) + ip += 1 + if f == MP_OPCODE_VAR_UINT: + while bytecode[ip] & 0x80 != 0: + ip += 1 + ip += 1 + elif f == MP_OPCODE_OFFSET: + ip += 2 + ip += extra_byte + return f, ip - ip_start + +def decode_uint(bytecode, ip): + unum = 0 + while True: + val = bytecode[ip] + ip += 1 + unum = (unum << 7) | (val & 0x7f) + if not (val & 0x80): + break + return ip, unum + +def extract_prelude(bytecode): + ip = 0 + ip, n_state = decode_uint(bytecode, ip) + ip, n_exc_stack = decode_uint(bytecode, ip) + scope_flags = bytecode[ip]; ip += 1 + n_pos_args = bytecode[ip]; ip += 1 + n_kwonly_args = bytecode[ip]; ip += 1 + n_def_pos_args = bytecode[ip]; ip += 1 + ip2, code_info_size = decode_uint(bytecode, ip) + ip += code_info_size + while bytecode[ip] != 0xff: + ip += 1 + ip += 1 + # ip now points to first opcode + # ip2 points to simple_name qstr + return ip, ip2, (n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args, code_info_size) + +class RawCode: + # a set of all escaped names, to make sure they are unique + escaped_names = set() + + def __init__(self, bytecode, qstrs, objs, raw_codes): + # set core variables + self.bytecode = bytecode + self.qstrs = qstrs + self.objs = objs + self.raw_codes = raw_codes + + # extract prelude + self.ip, self.ip2, self.prelude = extract_prelude(self.bytecode) + self.simple_name = self._unpack_qstr(self.ip2) + self.source_file = self._unpack_qstr(self.ip2 + 2) + + def _unpack_qstr(self, ip): + qst = self.bytecode[ip] | self.bytecode[ip + 1] << 8 + return global_qstrs[qst] + + def dump(self): + # dump children first + for rc in self.raw_codes: + rc.freeze() + # TODO + + def freeze(self, parent_name): + self.escaped_name = parent_name + self.simple_name.qstr_esc + + # make sure the escaped name is unique + i = 2 + while self.escaped_name in RawCode.escaped_names: + self.escaped_name = parent_name + self.simple_name.qstr_esc + str(i) + i += 1 + RawCode.escaped_names.add(self.escaped_name) + + # emit children first + for rc in self.raw_codes: + rc.freeze(self.escaped_name + '_') + + # generate bytecode data + print() + print('// frozen bytecode for file %s, scope %s%s' % (self.source_file.str, parent_name, self.simple_name.str)) + print('STATIC ', end='') + if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: + print('const ', end='') + print('byte bytecode_data_%s[%u] = {' % (self.escaped_name, len(self.bytecode))) + print(' ', end='') + for i in range(self.ip2): + print(' 0x%02x,' % self.bytecode[i], end='') + print() + print(' ', self.simple_name.qstr_id, '& 0xff,', self.simple_name.qstr_id, '>> 8,') + print(' ', self.source_file.qstr_id, '& 0xff,', self.source_file.qstr_id, '>> 8,') + print(' ', end='') + for i in range(self.ip2 + 4, self.ip): + print(' 0x%02x,' % self.bytecode[i], end='') + print() + ip = self.ip + while ip < len(self.bytecode): + f, sz = mp_opcode_format(self.bytecode, ip) + if f == 1: + qst = self._unpack_qstr(ip + 1).qstr_id + print(' ', '0x%02x,' % self.bytecode[ip], qst, '& 0xff,', qst, '>> 8,') + else: + print(' ', ''.join('0x%02x, ' % self.bytecode[ip + i] for i in range(sz))) + ip += sz + print('};') + + # generate constant objects + for i, obj in enumerate(self.objs): + obj_name = 'const_obj_%s_%u' % (self.escaped_name, i) + if is_str_type(obj) or is_bytes_type(obj): + if is_str_type(obj): + obj = bytes_cons(obj, 'utf8') + obj_type = 'mp_type_str' + else: + obj_type = 'mp_type_bytes' + print('STATIC const mp_obj_str_t %s = {{&%s}, %u, %u, (const byte*)"%s"};' + % (obj_name, obj_type, qstrutil.compute_hash(obj, config.MICROPY_QSTR_BYTES_IN_HASH), + len(obj), ''.join(('\\x%02x' % b) for b in obj))) + elif is_int_type(obj): + if config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_NONE: + # TODO check if we can actually fit this long-int into a small-int + raise FreezeError(self, 'target does not support long int') + elif config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_LONGLONG: + # TODO + raise FreezeError(self, 'freezing int to long-long is not implemented') + elif config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_MPZ: + neg = 0 + if obj < 0: + obj = -obj + neg = 1 + bits_per_dig = config.MPZ_DIG_SIZE + digs = [] + z = obj + while z: + digs.append(z & ((1 << bits_per_dig) - 1)) + z >>= bits_per_dig + ndigs = len(digs) + digs = ','.join(('%#x' % d) for d in digs) + print('STATIC const mp_obj_int_t %s = {{&mp_type_int}, ' + '{.neg=%u, .fixed_dig=1, .alloc=%u, .len=%u, .dig=(uint%u_t[]){%s}}};' + % (obj_name, neg, ndigs, ndigs, bits_per_dig, digs)) + elif type(obj) is float: + print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') + print('STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};' + % (obj_name, obj)) + print('#endif') + elif type(obj) is complex: + print('STATIC const mp_obj_complex_t %s = {{&mp_type_complex}, %.16g, %.16g};' + % (obj_name, obj.real, obj.imag)) + else: + # TODO + raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,)) + + # generate constant table, if it has any entries + const_table_len = len(self.qstrs) + len(self.objs) + len(self.raw_codes) + if const_table_len: + print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {' + % (self.escaped_name, const_table_len)) + for qst in self.qstrs: + print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id) + for i in range(len(self.objs)): + if type(self.objs[i]) is float: + print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') + print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) + print('#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C') + n = struct.unpack('> 8 + +def read_bytecode_qstrs(file, bytecode, ip): + while ip < len(bytecode): + f, sz = mp_opcode_format(bytecode, ip) + if f == 1: + read_qstr_and_pack(file, bytecode, ip + 1) + ip += sz + +def read_raw_code(f): + bc_len = read_uint(f) + bytecode = bytearray(f.read(bc_len)) + ip, ip2, prelude = extract_prelude(bytecode) + read_qstr_and_pack(f, bytecode, ip2) # simple_name + read_qstr_and_pack(f, bytecode, ip2 + 2) # source_file + read_bytecode_qstrs(f, bytecode, ip) + n_obj = read_uint(f) + n_raw_code = read_uint(f) + qstrs = [read_qstr(f) for _ in range(prelude[3] + prelude[4])] + objs = [read_obj(f) for _ in range(n_obj)] + raw_codes = [read_raw_code(f) for _ in range(n_raw_code)] + return RawCode(bytecode, qstrs, objs, raw_codes) + +def read_mpy(filename): + with open(filename, 'rb') as f: + header = bytes_cons(f.read(4)) + if header[0] != ord('M'): + raise Exception('not a valid .mpy file') + if header[1] != config.MPY_VERSION: + raise Exception('incompatible .mpy version') + feature_flags = header[2] + config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = (feature_flags & 1) != 0 + config.MICROPY_PY_BUILTINS_STR_UNICODE = (feature_flags & 2) != 0 + config.mp_small_int_bits = header[3] + return read_raw_code(f) + +def dump_mpy(raw_codes): + for rc in raw_codes: + rc.dump() + +def freeze_mpy(base_qstrs, raw_codes): + # add to qstrs + new = {} + for q in global_qstrs: + # don't add duplicates + if q.qstr_esc in base_qstrs or q.qstr_esc in new: + continue + new[q.qstr_esc] = (len(new), q.qstr_esc, q.str) + new = sorted(new.values(), key=lambda x: x[0]) + + print('#include "py/mpconfig.h"') + print('#include "py/objint.h"') + print('#include "py/objstr.h"') + print('#include "py/emitglue.h"') + print() + + print('#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != %u' % config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) + print('#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"') + print('#endif') + print() + + print('#if MICROPY_LONGINT_IMPL != %u' % config.MICROPY_LONGINT_IMPL) + print('#error "incompatible MICROPY_LONGINT_IMPL"') + print('#endif') + print() + + if config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_MPZ: + print('#if MPZ_DIG_SIZE != %u' % config.MPZ_DIG_SIZE) + print('#error "incompatible MPZ_DIG_SIZE"') + print('#endif') + print() + + + print('#if MICROPY_PY_BUILTINS_FLOAT') + print('typedef struct _mp_obj_float_t {') + print(' mp_obj_base_t base;') + print(' mp_float_t value;') + print('} mp_obj_float_t;') + print('#endif') + print() + + print('#if MICROPY_PY_BUILTINS_COMPLEX') + print('typedef struct _mp_obj_complex_t {') + print(' mp_obj_base_t base;') + print(' mp_float_t real;') + print(' mp_float_t imag;') + print('} mp_obj_complex_t;') + print('#endif') + print() + + print('enum {') + for i in range(len(new)): + if i == 0: + print(' MP_QSTR_%s = MP_QSTRnumber_of,' % new[i][1]) + else: + print(' MP_QSTR_%s,' % new[i][1]) + print('};') + + print() + print('extern const qstr_pool_t mp_qstr_const_pool;'); + print('const qstr_pool_t mp_qstr_frozen_const_pool = {') + print(' (qstr_pool_t*)&mp_qstr_const_pool, // previous pool') + print(' MP_QSTRnumber_of, // previous pool size') + print(' %u, // allocated entries' % len(new)) + print(' %u, // used entries' % len(new)) + print(' {') + for _, _, qstr in new: + print(' %s,' + % qstrutil.make_bytes(config.MICROPY_QSTR_BYTES_IN_LEN, config.MICROPY_QSTR_BYTES_IN_HASH, qstr)) + print(' },') + print('};') + + for rc in raw_codes: + rc.freeze(rc.source_file.str.replace('/', '_')[:-3] + '_') + + print() + print('const char mp_frozen_mpy_names[] = {') + for rc in raw_codes: + module_name = rc.source_file.str + print('"%s\\0"' % module_name) + print('"\\0"};') + + print('const mp_raw_code_t *const mp_frozen_mpy_content[] = {') + for rc in raw_codes: + print(' &raw_code_%s,' % rc.escaped_name) + print('};') + +def main(): + import argparse + cmd_parser = argparse.ArgumentParser(description='A tool to work with MicroPython .mpy files.') + cmd_parser.add_argument('-d', '--dump', action='store_true', + help='dump contents of files') + cmd_parser.add_argument('-f', '--freeze', action='store_true', + help='freeze files') + cmd_parser.add_argument('-q', '--qstr-header', + help='qstr header file to freeze against') + cmd_parser.add_argument('-mlongint-impl', choices=['none', 'longlong', 'mpz'], default='mpz', + help='long-int implementation used by target (default mpz)') + cmd_parser.add_argument('-mmpz-dig-size', metavar='N', type=int, default=16, + help='mpz digit size used by target (default 16)') + cmd_parser.add_argument('files', nargs='+', + help='input .mpy files') + args = cmd_parser.parse_args() + + # set config values relevant to target machine + config.MICROPY_LONGINT_IMPL = { + 'none':config.MICROPY_LONGINT_IMPL_NONE, + 'longlong':config.MICROPY_LONGINT_IMPL_LONGLONG, + 'mpz':config.MICROPY_LONGINT_IMPL_MPZ, + }[args.mlongint_impl] + config.MPZ_DIG_SIZE = args.mmpz_dig_size + + # set config values for qstrs, and get the existing base set of qstrs + if args.qstr_header: + qcfgs, base_qstrs = qstrutil.parse_input_headers([args.qstr_header]) + config.MICROPY_QSTR_BYTES_IN_LEN = int(qcfgs['BYTES_IN_LEN']) + config.MICROPY_QSTR_BYTES_IN_HASH = int(qcfgs['BYTES_IN_HASH']) + else: + config.MICROPY_QSTR_BYTES_IN_LEN = 1 + config.MICROPY_QSTR_BYTES_IN_HASH = 1 + base_qstrs = {} + + raw_codes = [read_mpy(file) for file in args.files] + + if args.dump: + dump_mpy(raw_codes) + elif args.freeze: + try: + freeze_mpy(base_qstrs, raw_codes) + except FreezeError as er: + print(er, file=sys.stderr) + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/user/mpy/tools/mpy_bin2res.py b/user/mpy/tools/mpy_bin2res.py new file mode 100755 index 0000000..0c89e7e --- /dev/null +++ b/user/mpy/tools/mpy_bin2res.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# +# This tool converts binary resource files passed on the command line +# into a Python source file containing data from these files, which can +# be accessed using standard pkg_resources.resource_stream() function +# from micropython-lib: +# https://github.com/micropython/micropython-lib/tree/master/pkg_resources +# +import sys + +print("R = {") + +for fname in sys.argv[1:]: + with open(fname, "rb") as f: + b = f.read() + print("%r: %r," % (fname, b)) + +print("}") diff --git a/user/mpy/tools/mpy_cross_all.py b/user/mpy/tools/mpy_cross_all.py new file mode 100755 index 0000000..2bda71e --- /dev/null +++ b/user/mpy/tools/mpy_cross_all.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +import argparse +import os +import os.path + +argparser = argparse.ArgumentParser(description="Compile all .py files to .mpy recursively") +argparser.add_argument("-o", "--out", help="output directory (default: input dir)") +argparser.add_argument("--target", help="select MicroPython target config") +argparser.add_argument("-mcache-lookup-bc", action="store_true", help="cache map lookups in the bytecode") +argparser.add_argument("dir", help="input directory") +args = argparser.parse_args() + +TARGET_OPTS = { + "unix": "-mcache-lookup-bc", + "baremetal": "", +} + +args.dir = args.dir.rstrip("/") + +if not args.out: + args.out = args.dir + +path_prefix_len = len(args.dir) + 1 + +for path, subdirs, files in os.walk(args.dir): + for f in files: + if f.endswith(".py"): + fpath = path + "/" + f + #print(fpath) + out_fpath = args.out + "/" + fpath[path_prefix_len:-3] + ".mpy" + out_dir = os.path.dirname(out_fpath) + if not os.path.isdir(out_dir): + os.makedirs(out_dir) + cmd = "mpy-cross -v -v %s -s %s %s -o %s" % (TARGET_OPTS.get(args.target, ""), + fpath[path_prefix_len:], fpath, out_fpath) + #print(cmd) + res = os.system(cmd) + assert res == 0 diff --git a/user/mpy/tools/pyboard.py b/user/mpy/tools/pyboard.py new file mode 100755 index 0000000..d15f520 --- /dev/null +++ b/user/mpy/tools/pyboard.py @@ -0,0 +1,461 @@ +#!/usr/bin/env python +# +# This file is part of the MicroPython project, http://micropython.org/ +# +# The MIT License (MIT) +# +# Copyright (c) 2014-2016 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. + +""" +pyboard interface + +This module provides the Pyboard class, used to communicate with and +control the pyboard over a serial USB connection. + +Example usage: + + import pyboard + pyb = pyboard.Pyboard('/dev/ttyACM0') + +Or: + + pyb = pyboard.Pyboard('192.168.1.1') + +Then: + + pyb.enter_raw_repl() + pyb.exec('pyb.LED(1).on()') + pyb.exit_raw_repl() + +Note: if using Python2 then pyb.exec must be written as pyb.exec_. +To run a script from the local machine on the board and print out the results: + + import pyboard + pyboard.execfile('test.py', device='/dev/ttyACM0') + +This script can also be run directly. To execute a local script, use: + + ./pyboard.py test.py + +Or: + + python pyboard.py test.py + +""" + +import sys +import time +import os + +try: + stdout = sys.stdout.buffer +except AttributeError: + # Python2 doesn't have buffer attr + stdout = sys.stdout + +def stdout_write_bytes(b): + b = b.replace(b"\x04", b"") + stdout.write(b) + stdout.flush() + +class PyboardError(BaseException): + pass + +class TelnetToSerial: + def __init__(self, ip, user, password, read_timeout=None): + import telnetlib + self.tn = telnetlib.Telnet(ip, timeout=15) + self.read_timeout = read_timeout + if b'Login as:' in self.tn.read_until(b'Login as:', timeout=read_timeout): + self.tn.write(bytes(user, 'ascii') + b"\r\n") + + if b'Password:' in self.tn.read_until(b'Password:', timeout=read_timeout): + # needed because of internal implementation details of the telnet server + time.sleep(0.2) + self.tn.write(bytes(password, 'ascii') + b"\r\n") + + if b'for more information.' in self.tn.read_until(b'Type "help()" for more information.', timeout=read_timeout): + # login successful + from collections import deque + self.fifo = deque() + return + + raise PyboardError('Failed to establish a telnet connection with the board') + + def __del__(self): + self.close() + + def close(self): + try: + self.tn.close() + except: + # the telnet object might not exist yet, so ignore this one + pass + + def read(self, size=1): + while len(self.fifo) < size: + timeout_count = 0 + data = self.tn.read_eager() + if len(data): + self.fifo.extend(data) + timeout_count = 0 + else: + time.sleep(0.25) + if self.read_timeout is not None and timeout_count > 4 * self.read_timeout: + break + timeout_count += 1 + + data = b'' + while len(data) < size and len(self.fifo) > 0: + data += bytes([self.fifo.popleft()]) + return data + + def write(self, data): + self.tn.write(data) + return len(data) + + def inWaiting(self): + n_waiting = len(self.fifo) + if not n_waiting: + data = self.tn.read_eager() + self.fifo.extend(data) + return len(data) + else: + return n_waiting + + +class ProcessToSerial: + "Execute a process and emulate serial connection using its stdin/stdout." + + def __init__(self, cmd): + import subprocess + self.subp = subprocess.Popen(cmd.split(), bufsize=0, shell=True, preexec_fn=os.setsid, + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + + # Initially was implemented with selectors, but that adds Python3 + # dependency. However, there can be race conditions communicating + # with a particular child process (like QEMU), and selectors may + # still work better in that case, so left inplace for now. + # + #import selectors + #self.sel = selectors.DefaultSelector() + #self.sel.register(self.subp.stdout, selectors.EVENT_READ) + + import select + self.poll = select.poll() + self.poll.register(self.subp.stdout.fileno()) + + def close(self): + import signal + os.killpg(os.getpgid(self.subp.pid), signal.SIGTERM) + + def read(self, size=1): + data = b"" + while len(data) < size: + data += self.subp.stdout.read(size - len(data)) + return data + + def write(self, data): + self.subp.stdin.write(data) + return len(data) + + def inWaiting(self): + #res = self.sel.select(0) + res = self.poll.poll(0) + if res: + return 1 + return 0 + + +class ProcessPtyToTerminal: + """Execute a process which creates a PTY and prints slave PTY as + first line of its output, and emulate serial connection using + this PTY.""" + + def __init__(self, cmd): + import subprocess + import re + import serial + self.subp = subprocess.Popen(cmd.split(), bufsize=0, shell=False, preexec_fn=os.setsid, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + pty_line = self.subp.stderr.readline().decode("utf-8") + m = re.search(r"/dev/pts/[0-9]+", pty_line) + if not m: + print("Error: unable to find PTY device in startup line:", pty_line) + self.close() + sys.exit(1) + pty = m.group() + # rtscts, dsrdtr params are to workaround pyserial bug: + # http://stackoverflow.com/questions/34831131/pyserial-does-not-play-well-with-virtual-port + self.ser = serial.Serial(pty, interCharTimeout=1, rtscts=True, dsrdtr=True) + + def close(self): + import signal + os.killpg(os.getpgid(self.subp.pid), signal.SIGTERM) + + def read(self, size=1): + return self.ser.read(size) + + def write(self, data): + return self.ser.write(data) + + def inWaiting(self): + return self.ser.inWaiting() + + +class Pyboard: + def __init__(self, device, baudrate=115200, user='micro', password='python', wait=0): + if device.startswith("exec:"): + self.serial = ProcessToSerial(device[len("exec:"):]) + elif device.startswith("execpty:"): + self.serial = ProcessPtyToTerminal(device[len("qemupty:"):]) + elif device and device[0].isdigit() and device[-1].isdigit() and device.count('.') == 3: + # device looks like an IP address + self.serial = TelnetToSerial(device, user, password, read_timeout=10) + else: + import serial + delayed = False + for attempt in range(wait + 1): + try: + self.serial = serial.Serial(device, baudrate=baudrate, interCharTimeout=1) + break + except (OSError, IOError): # Py2 and Py3 have different errors + if wait == 0: + continue + if attempt == 0: + sys.stdout.write('Waiting {} seconds for pyboard '.format(wait)) + delayed = True + time.sleep(1) + sys.stdout.write('.') + sys.stdout.flush() + else: + if delayed: + print('') + raise PyboardError('failed to access ' + device) + if delayed: + print('') + + def close(self): + self.serial.close() + + def read_until(self, min_num_bytes, ending, timeout=10, data_consumer=None): + data = self.serial.read(min_num_bytes) + if data_consumer: + data_consumer(data) + timeout_count = 0 + while True: + if data.endswith(ending): + break + elif self.serial.inWaiting() > 0: + new_data = self.serial.read(1) + data = data + new_data + if data_consumer: + data_consumer(new_data) + timeout_count = 0 + else: + timeout_count += 1 + if timeout is not None and timeout_count >= 100 * timeout: + break + time.sleep(0.01) + return data + + def enter_raw_repl(self): + self.serial.write(b'\r\x03\x03') # ctrl-C twice: interrupt any running program + + # flush input (without relying on serial.flushInput()) + n = self.serial.inWaiting() + while n > 0: + self.serial.read(n) + n = self.serial.inWaiting() + + self.serial.write(b'\r\x01') # ctrl-A: enter raw REPL + data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n>') + if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'): + print(data) + raise PyboardError('could not enter raw repl') + + self.serial.write(b'\x04') # ctrl-D: soft reset + data = self.read_until(1, b'soft reboot\r\n') + if not data.endswith(b'soft reboot\r\n'): + print(data) + raise PyboardError('could not enter raw repl') + # By splitting this into 2 reads, it allows boot.py to print stuff, + # which will show up after the soft reboot and before the raw REPL. + data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n') + if not data.endswith(b'raw REPL; CTRL-B to exit\r\n'): + print(data) + raise PyboardError('could not enter raw repl') + + def exit_raw_repl(self): + self.serial.write(b'\r\x02') # ctrl-B: enter friendly REPL + + def follow(self, timeout, data_consumer=None): + # wait for normal output + data = self.read_until(1, b'\x04', timeout=timeout, data_consumer=data_consumer) + if not data.endswith(b'\x04'): + raise PyboardError('timeout waiting for first EOF reception') + data = data[:-1] + + # wait for error output + data_err = self.read_until(1, b'\x04', timeout=timeout) + if not data_err.endswith(b'\x04'): + raise PyboardError('timeout waiting for second EOF reception') + data_err = data_err[:-1] + + # return normal and error output + return data, data_err + + def exec_raw_no_follow(self, command): + if isinstance(command, bytes): + command_bytes = command + else: + command_bytes = bytes(command, encoding='utf8') + + # check we have a prompt + data = self.read_until(1, b'>') + if not data.endswith(b'>'): + raise PyboardError('could not enter raw repl') + + # write command + for i in range(0, len(command_bytes), 256): + self.serial.write(command_bytes[i:min(i + 256, len(command_bytes))]) + time.sleep(0.01) + self.serial.write(b'\x04') + + # check if we could exec command + data = self.serial.read(2) + if data != b'OK': + raise PyboardError('could not exec command (response: %s)' % data) + + def exec_raw(self, command, timeout=10, data_consumer=None): + self.exec_raw_no_follow(command); + return self.follow(timeout, data_consumer) + + def eval(self, expression): + ret = self.exec_('print({})'.format(expression)) + ret = ret.strip() + return ret + + def exec_(self, command): + ret, ret_err = self.exec_raw(command) + if ret_err: + raise PyboardError('exception', ret, ret_err) + return ret + + def execfile(self, filename): + with open(filename, 'rb') as f: + pyfile = f.read() + return self.exec_(pyfile) + + def get_time(self): + t = str(self.eval('pyb.RTC().datetime()'), encoding='utf8')[1:-1].split(', ') + return int(t[4]) * 3600 + int(t[5]) * 60 + int(t[6]) + +# in Python2 exec is a keyword so one must use "exec_" +# but for Python3 we want to provide the nicer version "exec" +setattr(Pyboard, "exec", Pyboard.exec_) + +def execfile(filename, device='/dev/ttyACM0', baudrate=115200, user='micro', password='python'): + pyb = Pyboard(device, baudrate, user, password) + pyb.enter_raw_repl() + output = pyb.execfile(filename) + stdout_write_bytes(output) + pyb.exit_raw_repl() + pyb.close() + +def main(): + import argparse + cmd_parser = argparse.ArgumentParser(description='Run scripts on the pyboard.') + cmd_parser.add_argument('--device', default='/dev/ttyACM0', help='the serial device or the IP address of the pyboard') + cmd_parser.add_argument('-b', '--baudrate', default=115200, help='the baud rate of the serial device') + cmd_parser.add_argument('-u', '--user', default='micro', help='the telnet login username') + cmd_parser.add_argument('-p', '--password', default='python', help='the telnet login password') + cmd_parser.add_argument('-c', '--command', help='program passed in as string') + cmd_parser.add_argument('-w', '--wait', default=0, type=int, help='seconds to wait for USB connected board to become available') + cmd_parser.add_argument('--follow', action='store_true', help='follow the output after running the scripts [default if no scripts given]') + cmd_parser.add_argument('files', nargs='*', help='input files') + args = cmd_parser.parse_args() + + # open the connection to the pyboard + try: + pyb = Pyboard(args.device, args.baudrate, args.user, args.password, args.wait) + except PyboardError as er: + print(er) + sys.exit(1) + + # run any command or file(s) + if args.command is not None or len(args.files): + # we must enter raw-REPL mode to execute commands + # this will do a soft-reset of the board + try: + pyb.enter_raw_repl() + except PyboardError as er: + print(er) + pyb.close() + sys.exit(1) + + def execbuffer(buf): + try: + ret, ret_err = pyb.exec_raw(buf, timeout=None, data_consumer=stdout_write_bytes) + except PyboardError as er: + print(er) + pyb.close() + sys.exit(1) + except KeyboardInterrupt: + sys.exit(1) + if ret_err: + pyb.exit_raw_repl() + pyb.close() + stdout_write_bytes(ret_err) + sys.exit(1) + + # run the command, if given + if args.command is not None: + execbuffer(args.command.encode('utf-8')) + + # run any files + for filename in args.files: + with open(filename, 'rb') as f: + pyfile = f.read() + execbuffer(pyfile) + + # exiting raw-REPL just drops to friendly-REPL mode + pyb.exit_raw_repl() + + # if asked explicitly, or no files given, then follow the output + if args.follow or (args.command is None and len(args.files) == 0): + try: + ret, ret_err = pyb.follow(timeout=None, data_consumer=stdout_write_bytes) + except PyboardError as er: + print(er) + sys.exit(1) + except KeyboardInterrupt: + sys.exit(1) + if ret_err: + pyb.close() + stdout_write_bytes(ret_err) + sys.exit(1) + + # close the connection to the pyboard + pyb.close() + +if __name__ == "__main__": + main() diff --git a/user/mpy/tools/pydfu.py b/user/mpy/tools/pydfu.py new file mode 100755 index 0000000..8c0220d --- /dev/null +++ b/user/mpy/tools/pydfu.py @@ -0,0 +1,540 @@ +#!/usr/bin/env python +# This file is part of the OpenMV project. +# Copyright (c) 2013/2014 Ibrahim Abdelkader +# This work is licensed under the MIT license, see the file LICENSE for +# details. + +"""This module implements enough functionality to program the STM32F4xx over +DFU, without requiringdfu-util. + +See app note AN3156 for a description of the DFU protocol. +See document UM0391 for a dscription of the DFuse file. +""" + +from __future__ import print_function + +import argparse +import re +import struct +import sys +import usb.core +import usb.util +import zlib + +# VID/PID +__VID = 0x0483 +__PID = 0xdf11 + +# USB request __TIMEOUT +__TIMEOUT = 4000 + +# DFU commands +__DFU_DETACH = 0 +__DFU_DNLOAD = 1 +__DFU_UPLOAD = 2 +__DFU_GETSTATUS = 3 +__DFU_CLRSTATUS = 4 +__DFU_GETSTATE = 5 +__DFU_ABORT = 6 + +# DFU status +__DFU_STATE_APP_IDLE = 0x00 +__DFU_STATE_APP_DETACH = 0x01 +__DFU_STATE_DFU_IDLE = 0x02 +__DFU_STATE_DFU_DOWNLOAD_SYNC = 0x03 +__DFU_STATE_DFU_DOWNLOAD_BUSY = 0x04 +__DFU_STATE_DFU_DOWNLOAD_IDLE = 0x05 +__DFU_STATE_DFU_MANIFEST_SYNC = 0x06 +__DFU_STATE_DFU_MANIFEST = 0x07 +__DFU_STATE_DFU_MANIFEST_WAIT_RESET = 0x08 +__DFU_STATE_DFU_UPLOAD_IDLE = 0x09 +__DFU_STATE_DFU_ERROR = 0x0a + +_DFU_DESCRIPTOR_TYPE = 0x21 + + +# USB device handle +__dev = None + +__verbose = None + +# USB DFU interface +__DFU_INTERFACE = 0 + +import inspect +if 'length' in inspect.getargspec(usb.util.get_string).args: + # PyUSB 1.0.0.b1 has the length argument + def get_string(dev, index): + return usb.util.get_string(dev, 255, index) +else: + # PyUSB 1.0.0.b2 dropped the length argument + def get_string(dev, index): + return usb.util.get_string(dev, index) + + +def init(): + """Initializes the found DFU device so that we can program it.""" + global __dev + devices = get_dfu_devices(idVendor=__VID, idProduct=__PID) + if not devices: + raise ValueError('No DFU device found') + if len(devices) > 1: + raise ValueError("Multiple DFU devices found") + __dev = devices[0] + + # Claim DFU interface + usb.util.claim_interface(__dev, __DFU_INTERFACE) + + # Clear status + clr_status() + + +def clr_status(): + """Clears any error status (perhaps left over from a previous session).""" + __dev.ctrl_transfer(0x21, __DFU_CLRSTATUS, 0, __DFU_INTERFACE, + None, __TIMEOUT) + + +def get_status(): + """Get the status of the last operation.""" + stat = __dev.ctrl_transfer(0xA1, __DFU_GETSTATUS, 0, __DFU_INTERFACE, + 6, 20000) + # print (__DFU_STAT[stat[4]], stat) + return stat[4] + + +def mass_erase(): + """Performs a MASS erase (i.e. erases the entire device.""" + # Send DNLOAD with first byte=0x41 + __dev.ctrl_transfer(0x21, __DFU_DNLOAD, 0, __DFU_INTERFACE, + "\x41", __TIMEOUT) + + # Execute last command + if get_status() != __DFU_STATE_DFU_DOWNLOAD_BUSY: + raise Exception("DFU: erase failed") + + # Check command state + if get_status() != __DFU_STATE_DFU_DOWNLOAD_IDLE: + raise Exception("DFU: erase failed") + + +def page_erase(addr): + """Erases a single page.""" + if __verbose: + print("Erasing page: 0x%x..." % (addr)) + + # Send DNLOAD with first byte=0x41 and page address + buf = struct.pack(" 0: + write_size = size + if not mass_erase_used: + for segment in mem_layout: + if addr >= segment['addr'] and \ + addr <= segment['last_addr']: + # We found the page containing the address we want to + # write, erase it + page_size = segment['page_size'] + page_addr = addr & ~(page_size - 1) + if addr + write_size > page_addr + page_size: + write_size = page_addr + page_size - addr + page_erase(page_addr) + break + write_memory(addr, data[:write_size], progress, + elem_addr, elem_size) + data = data[write_size:] + addr += write_size + size -= write_size + if progress: + progress(elem_addr, addr - elem_addr, elem_size) + + +def cli_progress(addr, offset, size): + """Prints a progress report suitable for use on the command line.""" + width = 25 + done = offset * width // size + print("\r0x{:08x} {:7d} [{}{}] {:3d}% " + .format(addr, size, '=' * done, ' ' * (width - done), + offset * 100 // size), end="") + sys.stdout.flush() + if offset == size: + print("") + + +def main(): + """Test program for verifying this files functionality.""" + global __verbose + # Parse CMD args + parser = argparse.ArgumentParser(description='DFU Python Util') + #parser.add_argument("path", help="file path") + parser.add_argument( + "-l", "--list", + help="list available DFU devices", + action="store_true", + default=False + ) + parser.add_argument( + "-m", "--mass-erase", + help="mass erase device", + action="store_true", + default=False + ) + parser.add_argument( + "-u", "--upload", + help="read file from DFU device", + dest="path", + default=False + ) + parser.add_argument( + "-v", "--verbose", + help="increase output verbosity", + action="store_true", + default=False + ) + args = parser.parse_args() + + __verbose = args.verbose + + if args.list: + list_dfu_devices(idVendor=__VID, idProduct=__PID) + return + + init() + + if args.mass_erase: + print ("Mass erase...") + mass_erase() + + if args.path: + elements = read_dfu_file(args.path) + if not elements: + return + print("Writing memory...") + write_elements(elements, args.mass_erase, progress=cli_progress) + + print("Exiting DFU...") + exit_dfu() + return + + print("No command specified") + +if __name__ == '__main__': + main() diff --git a/user/mpy/tools/tinytest-codegen.py b/user/mpy/tools/tinytest-codegen.py new file mode 100755 index 0000000..dadfea1 --- /dev/null +++ b/user/mpy/tools/tinytest-codegen.py @@ -0,0 +1,70 @@ +#! /usr/bin/env python3 + +import os, sys +from glob import glob +from re import sub + +def escape(s): + lookup = { + '\0': '\\0', + '\t': '\\t', + '\n': '\\n\"\n\"', + '\r': '\\r', + '\\': '\\\\', + '\"': '\\\"', + } + return "\"\"\n\"{}\"".format(''.join([lookup[x] if x in lookup else x for x in s])) + +def chew_filename(t): + return { 'func': "test_{}_fn".format(sub(r'/|\.|-', '_', t)), 'desc': t.split('/')[1] } + +def script_to_map(t): + r = { 'name': chew_filename(t)['func'] } + with open(t) as f: r['script'] = escape(''.join(f.readlines())) + return r + +test_function = ( + "void {name}(void* data) {{\n" + " const char * pystr = {script};\n" + " do_str(pystr);\n" + "}}" +) + +testcase_struct = ( + "struct testcase_t {name}_tests[] = {{\n{body}\n END_OF_TESTCASES\n}};" +) +testcase_member = ( + " {{ \"{desc}\", {func}, TT_ENABLED_, 0, 0 }}," +) + +testgroup_struct = ( + "struct testgroup_t groups[] = {{\n{body}\n END_OF_GROUPS\n}};" +) +testgroup_member = ( + " {{ \"{name}/\", {name}_tests }}," +) + +## XXX: may be we could have `--without ` argument... +# currently these tests are selected because they pass on qemu-arm +test_dirs = ('basics', 'micropython', 'float', 'extmod', 'inlineasm') # 'import', 'io', 'misc') +exclude_tests = ( + 'float/float2int_doubleprec_intbig.py', # requires double precision floating point to work + 'inlineasm/asmfpaddsub.py', 'inlineasm/asmfpcmp.py', 'inlineasm/asmfpldrstr.py', 'inlineasm/asmfpmuldiv.py', 'inlineasm/asmfpsqrt.py', + 'extmod/ticks_diff.py', 'extmod/time_ms_us.py', 'extmod/uheapq_timeq.py', + 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', 'extmod/vfs_fat_fsusermount.py', 'extmod/vfs_fat_oldproto.py', +) + +output = [] + +for group in test_dirs: + tests = [test for test in glob('{}/*.py'.format(group)) if test not in exclude_tests] + output.extend([test_function.format(**script_to_map(test)) for test in tests]) + testcase_members = [testcase_member.format(**chew_filename(test)) for test in tests] + output.append(testcase_struct.format(name=group, body='\n'.join(testcase_members))) + +testgroup_members = [testgroup_member.format(name=group) for group in test_dirs] + +output.append(testgroup_struct.format(body='\n'.join(testgroup_members))) + +## XXX: may be we could have `--output ` argument... +print('\n\n'.join(output)) diff --git a/user/mpy/tools/tinytest/README b/user/mpy/tools/tinytest/README new file mode 100644 index 0000000..902c4a2 --- /dev/null +++ b/user/mpy/tools/tinytest/README @@ -0,0 +1,18 @@ +Tinytest is a tiny little test framework written in C by Nick Mathewson. + +It is distributed under the 3-clause BSD license. You can use it in +your own programs so long as you follow the license's conditions. + +It's been tested on Windows, Mac, and many of the free Unixes. + +It knows how to fork before running certain tests, and it makes +text-mode output in a format I like. + +For info on how to use it, check out tinytest_demo.c. + +You can get the latest version using Git, by pulling from + git://github.com/nmathewson/tinytest.git + +Patches are welcome. Patches that turn this from tinytest to hugetest +will not be applied. If you want a huge test framework, use CUnit. + diff --git a/user/mpy/tools/tinytest/tinytest.c b/user/mpy/tools/tinytest/tinytest.c new file mode 100644 index 0000000..1ef957d --- /dev/null +++ b/user/mpy/tools/tinytest/tinytest.c @@ -0,0 +1,474 @@ +/* tinytest.c -- Copyright 2009-2012 Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifdef TINYTEST_LOCAL +#include "tinytest_local.h" +#endif + +#include +#include +#include +#include + +#ifndef NO_FORKING + +#ifdef _WIN32 +#include +#else +#include +#include +#include +#endif + +#if defined(__APPLE__) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +#if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 && \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +/* Workaround for a stupid bug in OSX 10.6 */ +#define FORK_BREAKS_GCOV +#include +#endif +#endif + +#endif /* !NO_FORKING */ + +#ifndef __GNUC__ +#define __attribute__(x) +#endif + +#include "tinytest.h" +#include "tinytest_macros.h" + +#define LONGEST_TEST_NAME 16384 + +static int in_tinytest_main = 0; /**< true if we're in tinytest_main().*/ +static int n_ok = 0; /**< Number of tests that have passed */ +static int n_bad = 0; /**< Number of tests that have failed. */ +static int n_skipped = 0; /**< Number of tests that have been skipped. */ + +static int opt_forked = 0; /**< True iff we're called from inside a win32 fork*/ +static int opt_nofork = 0; /**< Suppress calls to fork() for debugging. */ +static int opt_verbosity = 1; /**< -==quiet,0==terse,1==normal,2==verbose */ +const char *verbosity_flag = ""; + +const struct testlist_alias_t *cfg_aliases=NULL; + +enum outcome { SKIP=2, OK=1, FAIL=0 }; +static enum outcome cur_test_outcome = 0; +const char *cur_test_prefix = NULL; /**< prefix of the current test group */ +/** Name of the current test, if we haven't logged is yet. Used for --quiet */ +const char *cur_test_name = NULL; + +#ifdef _WIN32 +/* Copy of argv[0] for win32. */ +static char commandname[MAX_PATH+1]; +#endif + +static void usage(struct testgroup_t *groups, int list_groups) + __attribute__((noreturn)); +static int process_test_option(struct testgroup_t *groups, const char *test); + +static enum outcome +testcase_run_bare_(const struct testcase_t *testcase) +{ + void *env = NULL; + int outcome; + if (testcase->setup) { + env = testcase->setup->setup_fn(testcase); + if (!env) + return FAIL; + else if (env == (void*)TT_SKIP) + return SKIP; + } + + cur_test_outcome = OK; + testcase->fn(env); + outcome = cur_test_outcome; + + if (testcase->setup) { + if (testcase->setup->cleanup_fn(testcase, env) == 0) + outcome = FAIL; + } + + return outcome; +} + +#define MAGIC_EXITCODE 42 + +#ifndef NO_FORKING + +static enum outcome +testcase_run_forked_(const struct testgroup_t *group, + const struct testcase_t *testcase) +{ +#ifdef _WIN32 + /* Fork? On Win32? How primitive! We'll do what the smart kids do: + we'll invoke our own exe (whose name we recall from the command + line) with a command line that tells it to run just the test we + want, and this time without forking. + + (No, threads aren't an option. The whole point of forking is to + share no state between tests.) + */ + int ok; + char buffer[LONGEST_TEST_NAME+256]; + STARTUPINFOA si; + PROCESS_INFORMATION info; + DWORD exitcode; + + if (!in_tinytest_main) { + printf("\nERROR. On Windows, testcase_run_forked_ must be" + " called from within tinytest_main.\n"); + abort(); + } + if (opt_verbosity>0) + printf("[forking] "); + + snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s", + commandname, verbosity_flag, group->prefix, testcase->name); + + memset(&si, 0, sizeof(si)); + memset(&info, 0, sizeof(info)); + si.cb = sizeof(si); + + ok = CreateProcessA(commandname, buffer, NULL, NULL, 0, + 0, NULL, NULL, &si, &info); + if (!ok) { + printf("CreateProcess failed!\n"); + return 0; + } + WaitForSingleObject(info.hProcess, INFINITE); + GetExitCodeProcess(info.hProcess, &exitcode); + CloseHandle(info.hProcess); + CloseHandle(info.hThread); + if (exitcode == 0) + return OK; + else if (exitcode == MAGIC_EXITCODE) + return SKIP; + else + return FAIL; +#else + int outcome_pipe[2]; + pid_t pid; + (void)group; + + if (pipe(outcome_pipe)) + perror("opening pipe"); + + if (opt_verbosity>0) + printf("[forking] "); + pid = fork(); +#ifdef FORK_BREAKS_GCOV + vproc_transaction_begin(0); +#endif + if (!pid) { + /* child. */ + int test_r, write_r; + char b[1]; + close(outcome_pipe[0]); + test_r = testcase_run_bare_(testcase); + assert(0<=(int)test_r && (int)test_r<=2); + b[0] = "NYS"[test_r]; + write_r = (int)write(outcome_pipe[1], b, 1); + if (write_r != 1) { + perror("write outcome to pipe"); + exit(1); + } + exit(0); + return FAIL; /* unreachable */ + } else { + /* parent */ + int status, r; + char b[1]; + /* Close this now, so that if the other side closes it, + * our read fails. */ + close(outcome_pipe[1]); + r = (int)read(outcome_pipe[0], b, 1); + if (r == 0) { + printf("[Lost connection!] "); + return 0; + } else if (r != 1) { + perror("read outcome from pipe"); + } + waitpid(pid, &status, 0); + close(outcome_pipe[0]); + return b[0]=='Y' ? OK : (b[0]=='S' ? SKIP : FAIL); + } +#endif +} + +#endif /* !NO_FORKING */ + +int +testcase_run_one(const struct testgroup_t *group, + const struct testcase_t *testcase) +{ + enum outcome outcome; + + if (testcase->flags & (TT_SKIP|TT_OFF_BY_DEFAULT)) { + if (opt_verbosity>0) + printf("%s%s: %s\n", + group->prefix, testcase->name, + (testcase->flags & TT_SKIP) ? "SKIPPED" : "DISABLED"); + ++n_skipped; + return SKIP; + } + + if (opt_verbosity>0 && !opt_forked) { + printf("%s%s: ", group->prefix, testcase->name); + } else { + if (opt_verbosity==0) printf("."); + cur_test_prefix = group->prefix; + cur_test_name = testcase->name; + } + +#ifndef NO_FORKING + if ((testcase->flags & TT_FORK) && !(opt_forked||opt_nofork)) { + outcome = testcase_run_forked_(group, testcase); + } else { +#else + { +#endif + outcome = testcase_run_bare_(testcase); + } + + if (outcome == OK) { + ++n_ok; + if (opt_verbosity>0 && !opt_forked) + puts(opt_verbosity==1?"OK":""); + } else if (outcome == SKIP) { + ++n_skipped; + if (opt_verbosity>0 && !opt_forked) + puts("SKIPPED"); + } else { + ++n_bad; + if (!opt_forked) + printf("\n [%s FAILED]\n", testcase->name); + } + + if (opt_forked) { + exit(outcome==OK ? 0 : (outcome==SKIP?MAGIC_EXITCODE : 1)); + return 1; /* unreachable */ + } else { + return (int)outcome; + } +} + +int +tinytest_set_flag_(struct testgroup_t *groups, const char *arg, int set, unsigned long flag) +{ + int i, j; + size_t length = LONGEST_TEST_NAME; + char fullname[LONGEST_TEST_NAME]; + int found=0; + if (strstr(arg, "..")) + length = strstr(arg,"..")-arg; + for (i=0; groups[i].prefix; ++i) { + for (j=0; groups[i].cases[j].name; ++j) { + struct testcase_t *testcase = &groups[i].cases[j]; + snprintf(fullname, sizeof(fullname), "%s%s", + groups[i].prefix, testcase->name); + if (!flag) { /* Hack! */ + printf(" %s", fullname); + if (testcase->flags & TT_OFF_BY_DEFAULT) + puts(" (Off by default)"); + else if (testcase->flags & TT_SKIP) + puts(" (DISABLED)"); + else + puts(""); + } + if (!strncmp(fullname, arg, length)) { + if (set) + testcase->flags |= flag; + else + testcase->flags &= ~flag; + ++found; + } + } + } + return found; +} + +static void +usage(struct testgroup_t *groups, int list_groups) +{ + puts("Options are: [--verbose|--quiet|--terse] [--no-fork]"); + puts(" Specify tests by name, or using a prefix ending with '..'"); + puts(" To skip a test, prefix its name with a colon."); + puts(" To enable a disabled test, prefix its name with a plus."); + puts(" Use --list-tests for a list of tests."); + if (list_groups) { + puts("Known tests are:"); + tinytest_set_flag_(groups, "..", 1, 0); + } + exit(0); +} + +static int +process_test_alias(struct testgroup_t *groups, const char *test) +{ + int i, j, n, r; + for (i=0; cfg_aliases && cfg_aliases[i].name; ++i) { + if (!strcmp(cfg_aliases[i].name, test)) { + n = 0; + for (j = 0; cfg_aliases[i].tests[j]; ++j) { + r = process_test_option(groups, cfg_aliases[i].tests[j]); + if (r<0) + return -1; + n += r; + } + return n; + } + } + printf("No such test alias as @%s!",test); + return -1; +} + +static int +process_test_option(struct testgroup_t *groups, const char *test) +{ + int flag = TT_ENABLED_; + int n = 0; + if (test[0] == '@') { + return process_test_alias(groups, test + 1); + } else if (test[0] == ':') { + ++test; + flag = TT_SKIP; + } else if (test[0] == '+') { + ++test; + ++n; + if (!tinytest_set_flag_(groups, test, 0, TT_OFF_BY_DEFAULT)) { + printf("No such test as %s!\n", test); + return -1; + } + } else { + ++n; + } + if (!tinytest_set_flag_(groups, test, 1, flag)) { + printf("No such test as %s!\n", test); + return -1; + } + return n; +} + +void +tinytest_set_aliases(const struct testlist_alias_t *aliases) +{ + cfg_aliases = aliases; +} + +int +tinytest_main(int c, const char **v, struct testgroup_t *groups) +{ + int i, j, n=0; + +#ifdef _WIN32 + const char *sp = strrchr(v[0], '.'); + const char *extension = ""; + if (!sp || stricmp(sp, ".exe")) + extension = ".exe"; /* Add an exe so CreateProcess will work */ + snprintf(commandname, sizeof(commandname), "%s%s", v[0], extension); + commandname[MAX_PATH]='\0'; +#endif + for (i=1; i= 1) + printf("%d tests ok. (%d skipped)\n", n_ok, n_skipped); + + return (n_bad == 0) ? 0 : 1; +} + +int +tinytest_get_verbosity_(void) +{ + return opt_verbosity; +} + +void +tinytest_set_test_failed_(void) +{ + if (opt_verbosity <= 0 && cur_test_name) { + if (opt_verbosity==0) puts(""); + printf("%s%s: ", cur_test_prefix, cur_test_name); + cur_test_name = NULL; + } + cur_test_outcome = 0; +} + +void +tinytest_set_test_skipped_(void) +{ + if (cur_test_outcome==OK) + cur_test_outcome = SKIP; +} + diff --git a/user/mpy/tools/tinytest/tinytest.h b/user/mpy/tools/tinytest/tinytest.h new file mode 100644 index 0000000..dff440e --- /dev/null +++ b/user/mpy/tools/tinytest/tinytest.h @@ -0,0 +1,98 @@ +/* tinytest.h -- Copyright 2009-2012 Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TINYTEST_H_INCLUDED_ +#define TINYTEST_H_INCLUDED_ + +/** Flag for a test that needs to run in a subprocess. */ +#define TT_FORK (1<<0) +/** Runtime flag for a test we've decided to skip. */ +#define TT_SKIP (1<<1) +/** Internal runtime flag for a test we've decided to run. */ +#define TT_ENABLED_ (1<<2) +/** Flag for a test that's off by default. */ +#define TT_OFF_BY_DEFAULT (1<<3) +/** If you add your own flags, make them start at this point. */ +#define TT_FIRST_USER_FLAG (1<<4) + +typedef void (*testcase_fn)(void *); + +struct testcase_t; + +/** Functions to initialize/teardown a structure for a testcase. */ +struct testcase_setup_t { + /** Return a new structure for use by a given testcase. */ + void *(*setup_fn)(const struct testcase_t *); + /** Clean/free a structure from setup_fn. Return 1 if ok, 0 on err. */ + int (*cleanup_fn)(const struct testcase_t *, void *); +}; + +/** A single test-case that you can run. */ +struct testcase_t { + const char *name; /**< An identifier for this case. */ + testcase_fn fn; /**< The function to run to implement this case. */ + unsigned long flags; /**< Bitfield of TT_* flags. */ + const struct testcase_setup_t *setup; /**< Optional setup/cleanup fns*/ + void *setup_data; /**< Extra data usable by setup function */ +}; +#define END_OF_TESTCASES { NULL, NULL, 0, NULL, NULL } + +/** A group of tests that are selectable together. */ +struct testgroup_t { + const char *prefix; /**< Prefix to prepend to testnames. */ + struct testcase_t *cases; /** Array, ending with END_OF_TESTCASES */ +}; +#define END_OF_GROUPS { NULL, NULL} + +struct testlist_alias_t { + const char *name; + const char **tests; +}; +#define END_OF_ALIASES { NULL, NULL } + +/** Implementation: called from a test to indicate failure, before logging. */ +void tinytest_set_test_failed_(void); +/** Implementation: called from a test to indicate that we're skipping. */ +void tinytest_set_test_skipped_(void); +/** Implementation: return 0 for quiet, 1 for normal, 2 for loud. */ +int tinytest_get_verbosity_(void); +/** Implementation: Set a flag on tests matching a name; returns number + * of tests that matched. */ +int tinytest_set_flag_(struct testgroup_t *, const char *, int set, unsigned long); + +/** Set all tests in 'groups' matching the name 'named' to be skipped. */ +#define tinytest_skip(groups, named) \ + tinytest_set_flag_(groups, named, 1, TT_SKIP) + +/** Run a single testcase in a single group. */ +int testcase_run_one(const struct testgroup_t *,const struct testcase_t *); + +void tinytest_set_aliases(const struct testlist_alias_t *aliases); + +/** Run a set of testcases from an END_OF_GROUPS-terminated array of groups, + as selected from the command line. */ +int tinytest_main(int argc, const char **argv, struct testgroup_t *groups); + +#endif diff --git a/user/mpy/tools/tinytest/tinytest_macros.h b/user/mpy/tools/tinytest/tinytest_macros.h new file mode 100644 index 0000000..9ff69b1 --- /dev/null +++ b/user/mpy/tools/tinytest/tinytest_macros.h @@ -0,0 +1,184 @@ +/* tinytest_macros.h -- Copyright 2009-2012 Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TINYTEST_MACROS_H_INCLUDED_ +#define TINYTEST_MACROS_H_INCLUDED_ + +/* Helpers for defining statement-like macros */ +#define TT_STMT_BEGIN do { +#define TT_STMT_END } while (0) + +/* Redefine this if your test functions want to abort with something besides + * "goto end;" */ +#ifndef TT_EXIT_TEST_FUNCTION +#define TT_EXIT_TEST_FUNCTION TT_STMT_BEGIN goto end; TT_STMT_END +#endif + +/* Redefine this if you want to note success/failure in some different way. */ +#ifndef TT_DECLARE +#define TT_DECLARE(prefix, args) \ + TT_STMT_BEGIN \ + printf("\n %s %s:%d: ",prefix,__FILE__,__LINE__); \ + printf args ; \ + TT_STMT_END +#endif + +/* Announce a failure. Args are parenthesized printf args. */ +#define TT_GRIPE(args) TT_DECLARE("FAIL", args) + +/* Announce a non-failure if we're verbose. */ +#define TT_BLATHER(args) \ + TT_STMT_BEGIN \ + if (tinytest_get_verbosity_()>1) TT_DECLARE(" OK", args); \ + TT_STMT_END + +#define TT_DIE(args) \ + TT_STMT_BEGIN \ + tinytest_set_test_failed_(); \ + TT_GRIPE(args); \ + TT_EXIT_TEST_FUNCTION; \ + TT_STMT_END + +#define TT_FAIL(args) \ + TT_STMT_BEGIN \ + tinytest_set_test_failed_(); \ + TT_GRIPE(args); \ + TT_STMT_END + +/* Fail and abort the current test for the reason in msg */ +#define tt_abort_printf(msg) TT_DIE(msg) +#define tt_abort_perror(op) TT_DIE(("%s: %s [%d]",(op),strerror(errno), errno)) +#define tt_abort_msg(msg) TT_DIE(("%s", msg)) +#define tt_abort() TT_DIE(("%s", "(Failed.)")) + +/* Fail but do not abort the current test for the reason in msg. */ +#define tt_failprint_f(msg) TT_FAIL(msg) +#define tt_fail_perror(op) TT_FAIL(("%s: %s [%d]",(op),strerror(errno), errno)) +#define tt_fail_msg(msg) TT_FAIL(("%s", msg)) +#define tt_fail() TT_FAIL(("%s", "(Failed.)")) + +/* End the current test, and indicate we are skipping it. */ +#define tt_skip() \ + TT_STMT_BEGIN \ + tinytest_set_test_skipped_(); \ + TT_EXIT_TEST_FUNCTION; \ + TT_STMT_END + +#define tt_want_(b, msg, fail) \ + TT_STMT_BEGIN \ + if (!(b)) { \ + tinytest_set_test_failed_(); \ + TT_GRIPE(("%s",msg)); \ + fail; \ + } else { \ + TT_BLATHER(("%s",msg)); \ + } \ + TT_STMT_END + +/* Assert b, but do not stop the test if b fails. Log msg on failure. */ +#define tt_want_msg(b, msg) \ + tt_want_(b, msg, ); + +/* Assert b and stop the test if b fails. Log msg on failure. */ +#define tt_assert_msg(b, msg) \ + tt_want_(b, msg, TT_EXIT_TEST_FUNCTION); + +/* Assert b, but do not stop the test if b fails. */ +#define tt_want(b) tt_want_msg( (b), "want("#b")") +/* Assert b, and stop the test if b fails. */ +#define tt_assert(b) tt_assert_msg((b), "assert("#b")") + +#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \ + setup_block,cleanup_block,die_on_fail) \ + TT_STMT_BEGIN \ + type val1_ = (type)(a); \ + type val2_ = (type)(b); \ + int tt_status_ = (test); \ + if (!tt_status_ || tinytest_get_verbosity_()>1) { \ + printf_type print_; \ + printf_type print1_; \ + printf_type print2_; \ + type value_ = val1_; \ + setup_block; \ + print1_ = print_; \ + value_ = val2_; \ + setup_block; \ + print2_ = print_; \ + TT_DECLARE(tt_status_?" OK":"FAIL", \ + ("assert(%s): "printf_fmt" vs "printf_fmt, \ + str_test, print1_, print2_)); \ + print_ = print1_; \ + cleanup_block; \ + print_ = print2_; \ + cleanup_block; \ + if (!tt_status_) { \ + tinytest_set_test_failed_(); \ + die_on_fail ; \ + } \ + } \ + TT_STMT_END + +#define tt_assert_test_type(a,b,str_test,type,test,fmt,die_on_fail) \ + tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \ + {print_=value_;},{},die_on_fail) + +/* Helper: assert that a op b, when cast to type. Format the values with + * printf format fmt on failure. */ +#define tt_assert_op_type(a,op,b,type,fmt) \ + tt_assert_test_type(a,b,#a" "#op" "#b,type,(val1_ op val2_),fmt, \ + TT_EXIT_TEST_FUNCTION) + +#define tt_int_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \ + "%ld",TT_EXIT_TEST_FUNCTION) + +#define tt_uint_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \ + (val1_ op val2_),"%lu",TT_EXIT_TEST_FUNCTION) + +#define tt_ptr_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,void*, \ + (val1_ op val2_),"%p",TT_EXIT_TEST_FUNCTION) + +#define tt_str_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \ + (strcmp(val1_,val2_) op 0),"<%s>",TT_EXIT_TEST_FUNCTION) + +#define tt_want_int_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_),"%ld",(void)0) + +#define tt_want_uint_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \ + (val1_ op val2_),"%lu",(void)0) + +#define tt_want_ptr_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,void*, \ + (val1_ op val2_),"%p",(void)0) + +#define tt_want_str_op(a,op,b) \ + tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \ + (strcmp(val1_,val2_) op 0),"<%s>",(void)0) + +#endif diff --git a/user/mpy/tools/upip.py b/user/mpy/tools/upip.py new file mode 100644 index 0000000..7b85c71 --- /dev/null +++ b/user/mpy/tools/upip.py @@ -0,0 +1,307 @@ +import sys +import gc +import uos as os +import uerrno as errno +import ujson as json +import uzlib +import upip_utarfile as tarfile +gc.collect() + + +debug = False +install_path = None +cleanup_files = [] +gzdict_sz = 16 + 15 + +file_buf = bytearray(512) + +class NotFoundError(Exception): + pass + +def op_split(path): + if path == "": + return ("", "") + r = path.rsplit("/", 1) + if len(r) == 1: + return ("", path) + head = r[0] + if not head: + head = "/" + return (head, r[1]) + +def op_basename(path): + return op_split(path)[1] + +# Expects *file* name +def _makedirs(name, mode=0o777): + ret = False + s = "" + comps = name.rstrip("/").split("/")[:-1] + if comps[0] == "": + s = "/" + for c in comps: + if s and s[-1] != "/": + s += "/" + s += c + try: + os.mkdir(s) + ret = True + except OSError as e: + if e.args[0] != errno.EEXIST and e.args[0] != errno.EISDIR: + raise + ret = False + return ret + + +def save_file(fname, subf): + global file_buf + with open(fname, "wb") as outf: + while True: + sz = subf.readinto(file_buf) + if not sz: + break + outf.write(file_buf, sz) + +def install_tar(f, prefix): + meta = {} + for info in f: + #print(info) + fname = info.name + try: + fname = fname[fname.index("/") + 1:] + except ValueError: + fname = "" + + save = True + for p in ("setup.", "PKG-INFO", "README"): + #print(fname, p) + if fname.startswith(p) or ".egg-info" in fname: + if fname.endswith("/requires.txt"): + meta["deps"] = f.extractfile(info).read() + save = False + if debug: + print("Skipping", fname) + break + + if save: + outfname = prefix + fname + if info.type != tarfile.DIRTYPE: + if debug: + print("Extracting " + outfname) + _makedirs(outfname) + subf = f.extractfile(info) + save_file(outfname, subf) + return meta + +def expandhome(s): + if "~/" in s: + h = os.getenv("HOME") + s = s.replace("~/", h + "/") + return s + +import ussl +import usocket +warn_ussl = True +def url_open(url): + global warn_ussl + + if debug: + print(url) + + proto, _, host, urlpath = url.split('/', 3) + try: + ai = usocket.getaddrinfo(host, 443) + except OSError as e: + fatal("Unable to resolve %s (no Internet?)" % host, e) + #print("Address infos:", ai) + addr = ai[0][4] + + s = usocket.socket(ai[0][0]) + try: + #print("Connect address:", addr) + s.connect(addr) + + if proto == "https:": + s = ussl.wrap_socket(s) + if warn_ussl: + print("Warning: %s SSL certificate is not validated" % host) + warn_ussl = False + + # MicroPython rawsocket module supports file interface directly + s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host)) + l = s.readline() + protover, status, msg = l.split(None, 2) + if status != b"200": + if status == b"404" or status == b"301": + raise NotFoundError("Package not found") + raise ValueError(status) + while 1: + l = s.readline() + if not l: + raise ValueError("Unexpected EOF in HTTP headers") + if l == b'\r\n': + break + except Exception as e: + s.close() + raise e + + return s + + +def get_pkg_metadata(name): + f = url_open("https://pypi.python.org/pypi/%s/json" % name) + try: + return json.load(f) + finally: + f.close() + + +def fatal(msg, exc=None): + print("Error:", msg) + if exc and debug: + raise exc + sys.exit(1) + +def install_pkg(pkg_spec, install_path): + data = get_pkg_metadata(pkg_spec) + + latest_ver = data["info"]["version"] + packages = data["releases"][latest_ver] + del data + gc.collect() + assert len(packages) == 1 + package_url = packages[0]["url"] + print("Installing %s %s from %s" % (pkg_spec, latest_ver, package_url)) + package_fname = op_basename(package_url) + f1 = url_open(package_url) + try: + f2 = uzlib.DecompIO(f1, gzdict_sz) + f3 = tarfile.TarFile(fileobj=f2) + meta = install_tar(f3, install_path) + finally: + f1.close() + del f3 + del f2 + gc.collect() + return meta + +def install(to_install, install_path=None): + # Calculate gzip dictionary size to use + global gzdict_sz + sz = gc.mem_free() + gc.mem_alloc() + if sz <= 65536: + gzdict_sz = 16 + 12 + + if install_path is None: + install_path = get_install_path() + if install_path[-1] != "/": + install_path += "/" + if not isinstance(to_install, list): + to_install = [to_install] + print("Installing to: " + install_path) + # sets would be perfect here, but don't depend on them + installed = [] + try: + while to_install: + if debug: + print("Queue:", to_install) + pkg_spec = to_install.pop(0) + if pkg_spec in installed: + continue + meta = install_pkg(pkg_spec, install_path) + installed.append(pkg_spec) + if debug: + print(meta) + deps = meta.get("deps", "").rstrip() + if deps: + deps = deps.decode("utf-8").split("\n") + to_install.extend(deps) + except Exception as e: + print("Error installing '{}': {}, packages may be partially installed".format( + pkg_spec, e), + file=sys.stderr) + +def get_install_path(): + global install_path + if install_path is None: + # sys.path[0] is current module's path + install_path = sys.path[1] + install_path = expandhome(install_path) + return install_path + +def cleanup(): + for fname in cleanup_files: + try: + os.unlink(fname) + except OSError: + print("Warning: Cannot delete " + fname) + +def help(): + print("""\ +upip - Simple PyPI package manager for MicroPython +Usage: micropython -m upip install [-p ] ... | -r +import upip; upip.install(package_or_list, []) + +If is not given, packages will be installed into sys.path[1] +(can be set from MICROPYPATH environment variable, if current system +supports that).""") + print("Current value of sys.path[1]:", sys.path[1]) + print("""\ + +Note: only MicroPython packages (usually, named micropython-*) are supported +for installation, upip does not support arbitrary code in setup.py. +""") + +def main(): + global debug + global install_path + install_path = None + + if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help": + help() + return + + if sys.argv[1] != "install": + fatal("Only 'install' command supported") + + to_install = [] + + i = 2 + while i < len(sys.argv) and sys.argv[i][0] == "-": + opt = sys.argv[i] + i += 1 + if opt == "-h" or opt == "--help": + help() + return + elif opt == "-p": + install_path = sys.argv[i] + i += 1 + elif opt == "-r": + list_file = sys.argv[i] + i += 1 + with open(list_file) as f: + while True: + l = f.readline() + if not l: + break + if l[0] == "#": + continue + to_install.append(l.rstrip()) + elif opt == "--debug": + debug = True + else: + fatal("Unknown/unsupported option: " + opt) + + to_install.extend(sys.argv[i:]) + if not to_install: + help() + return + + install(to_install) + + if not debug: + cleanup() + + +if __name__ == "__main__": + main() diff --git a/user/mpy/tools/upip_utarfile.py b/user/mpy/tools/upip_utarfile.py new file mode 100644 index 0000000..65ce0bd --- /dev/null +++ b/user/mpy/tools/upip_utarfile.py @@ -0,0 +1,94 @@ +import uctypes + +# http://www.gnu.org/software/tar/manual/html_node/Standard.html +TAR_HEADER = { + "name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100), + "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 12), +} + +DIRTYPE = "dir" +REGTYPE = "file" + +def roundup(val, align): + return (val + align - 1) & ~(align - 1) + +class FileSection: + + def __init__(self, f, content_len, aligned_len): + self.f = f + self.content_len = content_len + self.align = aligned_len - content_len + + def read(self, sz=65536): + if self.content_len == 0: + return b"" + if sz > self.content_len: + sz = self.content_len + data = self.f.read(sz) + sz = len(data) + self.content_len -= sz + return data + + def readinto(self, buf): + if self.content_len == 0: + return 0 + if len(buf) > self.content_len: + buf = memoryview(buf)[:self.content_len] + sz = self.f.readinto(buf) + self.content_len -= sz + return sz + + def skip(self): + sz = self.content_len + self.align + if sz: + buf = bytearray(16) + while sz: + s = min(sz, 16) + self.f.readinto(buf, s) + sz -= s + +class TarInfo: + + def __str__(self): + return "TarInfo(%r, %s, %d)" % (self.name, self.type, self.size) + +class TarFile: + + def __init__(self, name=None, fileobj=None): + if fileobj: + self.f = fileobj + else: + self.f = open(name, "rb") + self.subf = None + + def next(self): + if self.subf: + self.subf.skip() + buf = self.f.read(512) + if not buf: + return None + + h = uctypes.struct(uctypes.addressof(buf), TAR_HEADER, uctypes.LITTLE_ENDIAN) + + # Empty block means end of archive + if h.name[0] == 0: + return None + + d = TarInfo() + d.name = str(h.name, "utf-8").rstrip() + d.size = int(bytes(h.size).rstrip(), 8) + d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"] + self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512)) + return d + + def __iter__(self): + return self + + def __next__(self): + v = self.next() + if v is None: + raise StopIteration + return v + + def extractfile(self, tarinfo): + return tarinfo.subf diff --git a/user/pyhton.c b/user/pyhton.c new file mode 100644 index 0000000..3d9606e --- /dev/null +++ b/user/pyhton.c @@ -0,0 +1,96 @@ +#include +#include +#include + +#include "sh.h" + +#include "py/nlr.h" +#include "py/compile.h" +#include "py/runtime.h" +#include "py/repl.h" +#include "py/gc.h" +#include "py/mperrno.h" +#include "lib/utils/pyexec.h" + +#if MICROPY_ENABLE_COMPILER +void do_str(const char *src, mp_parse_input_kind_t input_kind) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); + qstr source_name = lex->source_name; + mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); + mp_call_function_0(module_fun); + nlr_pop(); + } else { + // uncaught exception + mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); + } +} +#endif + +static char *stack_top; +static char heap[2048]; + +int python(int argc, char **argv) { + int stack_dummy; + stack_top = (char*)&stack_dummy; + + #if MICROPY_ENABLE_GC + gc_init(heap, heap + sizeof(heap)); + #endif + mp_init(); + #if MICROPY_ENABLE_COMPILER + #if MICROPY_REPL_EVENT_DRIVEN + pyexec_event_repl_init(); + for (;;) { + int c = mp_hal_stdin_rx_chr(); + if (pyexec_event_repl_process_char(c)) { + break; + } + } + #else + pyexec_friendly_repl(); + #endif + //do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\\n')", MP_PARSE_SINGLE_INPUT); + //do_str("for i in range(10):\r\n print(i)", MP_PARSE_FILE_INPUT); + #else + pyexec_frozen_module("frozentest.py"); + #endif + mp_deinit(); + return 0; +} + + +void gc_collect(void) { + // WARNING: This gc_collect implementation doesn't try to get root + // pointers from CPU registers, and thus may function incorrectly. + void *dummy; + gc_collect_start(); + gc_collect_root(&dummy, ((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t)); + gc_collect_end(); + gc_dump_info(); +} + +mp_lexer_t *mp_lexer_new_from_file(const char *filename) { + mp_raise_OSError(MP_ENOENT); +} + +mp_import_stat_t mp_import_stat(const char *path) { + return MP_IMPORT_STAT_NO_EXIST; +} + +mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); + +void nlr_jump_fail(void *val) { + while (1); +} + +void NORETURN __fatal_error(const char *msg) { + while (1); +} + +HOOK_BUILTIN_CMD(python, python); From b2b81342d221458ab3bef73f21a213f2f69ba600 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Wed, 16 Aug 2017 13:45:31 +0800 Subject: [PATCH 2/6] Remove copy file and use submodule for micropython --- .gitmodules | 3 + user/mpy/build/genhdr/mpversion.h | 8 - user/mpy/build/genhdr/qstr.i.last | 286426 --------------- user/mpy/build/genhdr/qstr.split | 0 .../qstr/user__mpy__py__builtinevex.c.qstr | 1 - .../qstr/user__mpy__py__builtinimport.c.qstr | 6 - .../genhdr/qstr/user__mpy__py__compile.c.qstr | 15 - .../genhdr/qstr/user__mpy__py__emitbc.c.qstr | 1 - .../qstr/user__mpy__py__modbuiltins.c.qstr | 83 - .../qstr/user__mpy__py__modmicropython.c.qstr | 6 - .../genhdr/qstr/user__mpy__py__objbool.c.qstr | 1 - .../qstr/user__mpy__py__objboundmeth.c.qstr | 1 - .../qstr/user__mpy__py__objclosure.c.qstr | 1 - .../genhdr/qstr/user__mpy__py__objdict.c.qstr | 17 - .../qstr/user__mpy__py__objexcept.c.qstr | 29 - .../genhdr/qstr/user__mpy__py__objfun.c.qstr | 6 - .../qstr/user__mpy__py__objgenerator.c.qstr | 5 - .../qstr/user__mpy__py__objgetitemiter.c.qstr | 1 - .../genhdr/qstr/user__mpy__py__objint.c.qstr | 5 - .../genhdr/qstr/user__mpy__py__objlist.c.qstr | 14 - .../genhdr/qstr/user__mpy__py__objmap.c.qstr | 1 - .../qstr/user__mpy__py__objmodule.c.qstr | 7 - .../genhdr/qstr/user__mpy__py__objnone.c.qstr | 1 - .../qstr/user__mpy__py__objobject.c.qstr | 1 - .../qstr/user__mpy__py__objpolyiter.c.qstr | 1 - .../qstr/user__mpy__py__objrange.c.qstr | 5 - .../qstr/user__mpy__py__objsingleton.c.qstr | 1 - .../genhdr/qstr/user__mpy__py__objstr.c.qstr | 27 - .../qstr/user__mpy__py__objtuple.c.qstr | 3 - .../genhdr/qstr/user__mpy__py__objtype.c.qstr | 30 - .../genhdr/qstr/user__mpy__py__objzip.c.qstr | 1 - .../genhdr/qstr/user__mpy__py__runtime.c.qstr | 16 - .../genhdr/qstr/user__mpy__py__scope.c.qstr | 6 - .../genhdr/qstr/user__mpy__py__stream.c.qstr | 1 - .../genhdr/qstr/user__mpy__py__vm.c.qstr | 2 - user/mpy/build/genhdr/qstrdefs.collected.h | 589 - .../build/genhdr/qstrdefs.collected.h.hash | 1 - user/mpy/build/genhdr/qstrdefs.generated.h | 202 - user/mpy/build/genhdr/qstrdefs.preprocessed.h | 1243 - user/mpy/extmod/crypto-algorithms/sha256.c | 157 - user/mpy/extmod/crypto-algorithms/sha256.h | 34 - user/mpy/extmod/lwip-include/arch/cc.h | 41 - user/mpy/extmod/lwip-include/arch/perf.h | 7 - user/mpy/extmod/lwip-include/lwipopts.h | 35 - user/mpy/extmod/machine_i2c.c | 640 - user/mpy/extmod/machine_i2c.h | 56 - user/mpy/extmod/machine_mem.c | 103 - user/mpy/extmod/machine_mem.h | 49 - user/mpy/extmod/machine_pinbase.c | 88 - user/mpy/extmod/machine_pinbase.h | 33 - user/mpy/extmod/machine_pulse.c | 65 - user/mpy/extmod/machine_pulse.h | 36 - user/mpy/extmod/machine_signal.c | 183 - user/mpy/extmod/machine_signal.h | 33 - user/mpy/extmod/machine_spi.c | 339 - user/mpy/extmod/machine_spi.h | 61 - user/mpy/extmod/misc.h | 44 - user/mpy/extmod/modbtree.c | 379 - user/mpy/extmod/modframebuf.c | 596 - user/mpy/extmod/modlwip.c | 1380 - user/mpy/extmod/modonewire.c | 162 - user/mpy/extmod/modubinascii.c | 244 - user/mpy/extmod/modubinascii.h | 41 - user/mpy/extmod/moductypes.c | 716 - user/mpy/extmod/moduhashlib.c | 159 - user/mpy/extmod/moduheapq.c | 122 - user/mpy/extmod/modujson.c | 299 - user/mpy/extmod/modurandom.c | 226 - user/mpy/extmod/modure.c | 255 - user/mpy/extmod/moduselect.c | 378 - user/mpy/extmod/modussl_axtls.c | 232 - user/mpy/extmod/modussl_mbedtls.c | 314 - user/mpy/extmod/modutimeq.c | 232 - user/mpy/extmod/moduzlib.c | 225 - user/mpy/extmod/modwebrepl.c | 354 - user/mpy/extmod/modwebsocket.c | 318 - user/mpy/extmod/modwebsocket.h | 10 - user/mpy/extmod/re1.5/charclass.c | 33 - user/mpy/extmod/re1.5/compilecode.c | 216 - user/mpy/extmod/re1.5/dumpcode.c | 65 - user/mpy/extmod/re1.5/re1.5.h | 151 - user/mpy/extmod/re1.5/recursiveloop.c | 84 - user/mpy/extmod/uos_dupterm.c | 92 - user/mpy/extmod/utime_mphal.c | 102 - user/mpy/extmod/utime_mphal.h | 41 - user/mpy/extmod/uzlib/adler32.c | 78 - user/mpy/extmod/uzlib/crc32.c | 63 - user/mpy/extmod/uzlib/tinf.h | 117 - user/mpy/extmod/uzlib/tinfgzip.c | 110 - user/mpy/extmod/uzlib/tinflate.c | 551 - user/mpy/extmod/uzlib/tinfzlib.c | 66 - user/mpy/extmod/vfs.c | 457 - user/mpy/extmod/vfs.h | 85 - user/mpy/extmod/vfs_fat.c | 345 - user/mpy/extmod/vfs_fat.h | 64 - user/mpy/extmod/vfs_fat_diskio.c | 280 - user/mpy/extmod/vfs_fat_file.c | 300 - user/mpy/extmod/vfs_fat_misc.c | 109 - user/mpy/extmod/vfs_reader.c | 87 - user/mpy/extmod/virtpin.c | 39 - user/mpy/extmod/virtpin.h | 47 - user/mpy/lib/README.md | 2 - user/mpy/lib/axtls/.gitignore | 11 - user/mpy/lib/axtls/Makefile | 185 - user/mpy/lib/axtls/README | 3 - user/mpy/lib/axtls/axtlswrap/Makefile | 68 - user/mpy/lib/axtls/axtlswrap/axtlswrap.c | 379 - user/mpy/lib/axtls/bindings/Config.in | 105 - user/mpy/lib/axtls/bindings/Makefile | 86 - user/mpy/lib/axtls/bindings/README | 43 - user/mpy/lib/axtls/bindings/csharp/Makefile | 35 - user/mpy/lib/axtls/bindings/csharp/axTLS.cs | 491 - .../axtls/bindings/generate_SWIG_interface.pl | 392 - .../lib/axtls/bindings/generate_interface.pl | 322 - user/mpy/lib/axtls/bindings/java/Makefile | 94 - user/mpy/lib/axtls/bindings/java/SSL.java | 137 - user/mpy/lib/axtls/bindings/java/SSLCTX.java | 229 - .../lib/axtls/bindings/java/SSLClient.java | 81 - .../axtls/bindings/java/SSLReadHolder.java | 61 - .../lib/axtls/bindings/java/SSLServer.java | 72 - user/mpy/lib/axtls/bindings/java/SSLUtil.java | 116 - user/mpy/lib/axtls/bindings/lua/Makefile | 67 - user/mpy/lib/axtls/bindings/perl/Makefile | 91 - user/mpy/lib/axtls/bindings/vbnet/Makefile | 35 - user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb | 200 - user/mpy/lib/axtls/config/Config.in | 130 - user/mpy/lib/axtls/config/JMeter.jmx | 247 - user/mpy/lib/axtls/config/Rules.mak | 221 - user/mpy/lib/axtls/config/axhttpd.aip | 136 - user/mpy/lib/axtls/config/axtls.RES | Bin 22748 -> 0 bytes user/mpy/lib/axtls/config/axtls.rc | 32 - user/mpy/lib/axtls/config/linuxconfig | 126 - user/mpy/lib/axtls/config/makefile.conf | 138 - .../mpy/lib/axtls/config/makefile.dotnet.conf | 65 - user/mpy/lib/axtls/config/makefile.java.conf | 58 - user/mpy/lib/axtls/config/makefile.post | 19 - .../scripts/config/Kconfig-language.txt | 255 - .../lib/axtls/config/scripts/config/Makefile | 121 - .../lib/axtls/config/scripts/config/conf.c | 583 - .../axtls/config/scripts/config/confdata.c | 458 - .../lib/axtls/config/scripts/config/expr.c | 1099 - .../lib/axtls/config/scripts/config/expr.h | 195 - .../config/scripts/config/lex.zconf.c_shipped | 3688 - .../mpy/lib/axtls/config/scripts/config/lkc.h | 123 - .../axtls/config/scripts/config/lkc_proto.h | 40 - .../scripts/config/lxdialog/BIG.FAT.WARNING | 4 - .../scripts/config/lxdialog/checklist.c | 372 - .../config/scripts/config/lxdialog/colors.h | 161 - .../config/scripts/config/lxdialog/dialog.h | 199 - .../config/scripts/config/lxdialog/inputbox.c | 240 - .../config/scripts/config/lxdialog/menubox.c | 438 - .../config/scripts/config/lxdialog/msgbox.c | 85 - .../config/scripts/config/lxdialog/textbox.c | 556 - .../config/scripts/config/lxdialog/util.c | 375 - .../config/scripts/config/lxdialog/yesno.c | 118 - .../lib/axtls/config/scripts/config/mconf.c | 977 - .../lib/axtls/config/scripts/config/menu.c | 390 - .../lib/axtls/config/scripts/config/mkconfigs | 67 - .../lib/axtls/config/scripts/config/symbol.c | 809 - .../lib/axtls/config/scripts/config/util.c | 109 - .../lib/axtls/config/scripts/config/zconf.l | 366 - .../config/scripts/config/zconf.tab.c_shipped | 2130 - .../config/scripts/config/zconf.tab.h_shipped | 125 - .../lib/axtls/config/scripts/config/zconf.y | 690 - user/mpy/lib/axtls/config/upyconfig | 117 - user/mpy/lib/axtls/config/upyconfig.client | 116 - user/mpy/lib/axtls/config/win32config | 119 - user/mpy/lib/axtls/crypto/Makefile | 52 - user/mpy/lib/axtls/crypto/aes.c | 452 - user/mpy/lib/axtls/crypto/bigint.c | 1516 - user/mpy/lib/axtls/crypto/bigint.h | 99 - user/mpy/lib/axtls/crypto/bigint_impl.h | 131 - user/mpy/lib/axtls/crypto/crypto.h | 273 - user/mpy/lib/axtls/crypto/crypto_misc.c | 378 - user/mpy/lib/axtls/crypto/hmac.c | 145 - user/mpy/lib/axtls/crypto/md5.c | 433 - user/mpy/lib/axtls/crypto/os_int.h | 67 - user/mpy/lib/axtls/crypto/rc4.c | 97 - user/mpy/lib/axtls/crypto/rsa.c | 284 - user/mpy/lib/axtls/crypto/sha1.c | 249 - user/mpy/lib/axtls/crypto/sha256.c | 278 - user/mpy/lib/axtls/crypto/sha384.c | 77 - user/mpy/lib/axtls/crypto/sha512.c | 220 - user/mpy/lib/axtls/docsrc/Makefile | 39 - user/mpy/lib/axtls/docsrc/axTLS.dox | 1372 - user/mpy/lib/axtls/docsrc/doco_footer.html | 3 - user/mpy/lib/axtls/docsrc/images/axolotl.jpg | Bin 3041 -> 0 bytes user/mpy/lib/axtls/docsrc/images/tsbasbw.gif | Bin 2481 -> 0 bytes user/mpy/lib/axtls/httpd/Config.in | 160 - user/mpy/lib/axtls/httpd/Makefile | 130 - user/mpy/lib/axtls/httpd/axhttp.h | 156 - user/mpy/lib/axtls/httpd/axhttpd.c | 713 - user/mpy/lib/axtls/httpd/htpasswd.c | 142 - .../kepler-1.1-snapshot-20070521-1825.tar.gz | Bin 768249 -> 0 bytes user/mpy/lib/axtls/httpd/kepler.patch | 64 - user/mpy/lib/axtls/httpd/proc.c | 1254 - user/mpy/lib/axtls/httpd/tdate_parse.c | 115 - user/mpy/lib/axtls/samples/Config.in | 63 - user/mpy/lib/axtls/samples/Makefile | 62 - user/mpy/lib/axtls/samples/c/Makefile | 77 - user/mpy/lib/axtls/samples/c/axssl.c | 904 - user/mpy/lib/axtls/samples/csharp/Makefile | 48 - user/mpy/lib/axtls/samples/csharp/axssl.cs | 758 - user/mpy/lib/axtls/samples/java/Makefile | 51 - user/mpy/lib/axtls/samples/java/axssl.java | 760 - user/mpy/lib/axtls/samples/java/manifest.mf | 1 - user/mpy/lib/axtls/samples/lua/Makefile | 43 - user/mpy/lib/axtls/samples/lua/axssl.lua | 562 - user/mpy/lib/axtls/samples/perl/Makefile | 43 - user/mpy/lib/axtls/samples/perl/axssl.pl | 634 - user/mpy/lib/axtls/samples/vbnet/Makefile | 48 - user/mpy/lib/axtls/samples/vbnet/axssl.vb | 702 - user/mpy/lib/axtls/ssl/BigIntConfig.in | 145 - user/mpy/lib/axtls/ssl/Config.in | 341 - user/mpy/lib/axtls/ssl/Makefile | 125 - user/mpy/lib/axtls/ssl/asn1.c | 776 - user/mpy/lib/axtls/ssl/cert.h | 54 - user/mpy/lib/axtls/ssl/crypto_misc.h | 213 - user/mpy/lib/axtls/ssl/gen_cert.c | 370 - user/mpy/lib/axtls/ssl/loader.c | 492 - user/mpy/lib/axtls/ssl/openssl.c | 318 - user/mpy/lib/axtls/ssl/os_port.c | 0 user/mpy/lib/axtls/ssl/os_port.h | 1 - user/mpy/lib/axtls/ssl/os_port_micropython.h | 85 - user/mpy/lib/axtls/ssl/p12.c | 483 - user/mpy/lib/axtls/ssl/private_key.h | 54 - user/mpy/lib/axtls/ssl/ssl.h | 538 - user/mpy/lib/axtls/ssl/test/Makefile | 100 - user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem | 27 - user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer | Bin 786 -> 0 bytes user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.pem | 19 - .../axtls/ssl/test/axTLS.ca_x509_sha256.pem | 19 - .../mpy/lib/axtls/ssl/test/axTLS.encrypted.p8 | Bin 673 -> 0 bytes .../lib/axtls/ssl/test/axTLS.encrypted_pem.p8 | 17 - user/mpy/lib/axtls/ssl/test/axTLS.key_1024 | Bin 609 -> 0 bytes .../mpy/lib/axtls/ssl/test/axTLS.key_1024.pem | 15 - user/mpy/lib/axtls/ssl/test/axTLS.key_2048 | Bin 1192 -> 0 bytes .../mpy/lib/axtls/ssl/test/axTLS.key_2048.pem | 27 - user/mpy/lib/axtls/ssl/test/axTLS.key_4096 | Bin 2347 -> 0 bytes .../mpy/lib/axtls/ssl/test/axTLS.key_4096.pem | 51 - .../lib/axtls/ssl/test/axTLS.key_aes128.pem | 18 - .../lib/axtls/ssl/test/axTLS.key_aes256.pem | 18 - .../lib/axtls/ssl/test/axTLS.key_device.pem | 27 - .../axtls/ssl/test/axTLS.key_end_chain.pem | 27 - .../ssl/test/axTLS.key_intermediate_ca.pem | 27 - .../ssl/test/axTLS.key_intermediate_ca2.pem | 27 - user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 | Bin 1612 -> 0 bytes .../lib/axtls/ssl/test/axTLS.unencrypted.p8 | Bin 635 -> 0 bytes .../axtls/ssl/test/axTLS.unencrypted_pem.p8 | 16 - user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 | Bin 2521 -> 0 bytes .../lib/axtls/ssl/test/axTLS.withoutCA.p12 | Bin 1702 -> 0 bytes .../lib/axtls/ssl/test/axTLS.x509_1024.cer | Bin 604 -> 0 bytes .../lib/axtls/ssl/test/axTLS.x509_1024.pem | 15 - .../axtls/ssl/test/axTLS.x509_1024_sha256.pem | 15 - .../axtls/ssl/test/axTLS.x509_1024_sha384.pem | 15 - .../axtls/ssl/test/axTLS.x509_1024_sha512.pem | 15 - .../lib/axtls/ssl/test/axTLS.x509_2048.cer | Bin 736 -> 0 bytes .../lib/axtls/ssl/test/axTLS.x509_2048.pem | 18 - .../lib/axtls/ssl/test/axTLS.x509_4096.cer | Bin 992 -> 0 bytes .../lib/axtls/ssl/test/axTLS.x509_4096.pem | 23 - .../lib/axtls/ssl/test/axTLS.x509_aes128.pem | 15 - .../lib/axtls/ssl/test/axTLS.x509_aes256.pem | 15 - .../axtls/ssl/test/axTLS.x509_bad_after.pem | 15 - .../axtls/ssl/test/axTLS.x509_bad_before.pem | 15 - .../lib/axtls/ssl/test/axTLS.x509_device.cer | Bin 466 -> 0 bytes .../lib/axtls/ssl/test/axTLS.x509_device.pem | 34 - .../axtls/ssl/test/axTLS.x509_end_chain.pem | 19 - .../ssl/test/axTLS.x509_end_chain_bad.pem | 19 - .../ssl/test/axTLS.x509_intermediate_ca.pem | 19 - .../ssl/test/axTLS.x509_intermediate_ca2.pem | 37 - user/mpy/lib/axtls/ssl/test/ca-bundle.crt | 3585 - .../axtls/ssl/test/camster_duckdns_org.crt | 31 - user/mpy/lib/axtls/ssl/test/comodo.sha384.cer | 32 - .../axtls/ssl/test/deutsche_telecom.x509_ca | Bin 670 -> 0 bytes user/mpy/lib/axtls/ssl/test/equifax.x509_ca | Bin 646 -> 0 bytes user/mpy/lib/axtls/ssl/test/gnutls.cer | Bin 599 -> 0 bytes user/mpy/lib/axtls/ssl/test/header_issue.dat | Bin 1159 -> 0 bytes user/mpy/lib/axtls/ssl/test/killgnutls.sh | 2 - user/mpy/lib/axtls/ssl/test/killopenssl.sh | 2 - user/mpy/lib/axtls/ssl/test/make_certs.sh | 253 - user/mpy/lib/axtls/ssl/test/microsoft.x509_ca | Bin 1046 -> 0 bytes .../lib/axtls/ssl/test/microsoft.x509_ca.pem | 24 - user/mpy/lib/axtls/ssl/test/ms_iis.cer | 13 - user/mpy/lib/axtls/ssl/test/perf_bigint.c | 234 - .../mpy/lib/axtls/ssl/test/qualityssl.com.der | Bin 1385 -> 0 bytes user/mpy/lib/axtls/ssl/test/socgen.cer | Bin 980 -> 0 bytes user/mpy/lib/axtls/ssl/test/ssltest.c | 2589 - user/mpy/lib/axtls/ssl/test/test_axssl.sh | 163 - user/mpy/lib/axtls/ssl/test/thawte.x509_ca | Bin 811 -> 0 bytes .../lib/axtls/ssl/test/verisign.x509_ca.pem | 16 - .../axtls/ssl/test/verisign.x509_my_cert.pem | 25 - user/mpy/lib/axtls/ssl/tls1.c | 2464 - user/mpy/lib/axtls/ssl/tls1.h | 329 - user/mpy/lib/axtls/ssl/tls1_clnt.c | 546 - user/mpy/lib/axtls/ssl/tls1_svr.c | 533 - user/mpy/lib/axtls/ssl/x509.c | 861 - user/mpy/lib/axtls/www/bin/.htaccess | 2 - user/mpy/lib/axtls/www/favicon.ico | Bin 22486 -> 0 bytes user/mpy/lib/axtls/www/index.html | 7103 - user/mpy/lib/axtls/www/lua/download.lua | 75 - user/mpy/lib/axtls/www/lua/env.lua | 26 - user/mpy/lib/axtls/www/lua/overview.lp | 64 - user/mpy/lib/axtls/www/lua/prepara_sql2.lua | 31 - user/mpy/lib/axtls/www/lua/test_conc.lua | 38 - user/mpy/lib/axtls/www/lua/test_cookies.lp | 13 - user/mpy/lib/axtls/www/lua/test_cookies.lua | 14 - user/mpy/lib/axtls/www/lua/test_err.lua | 4 - user/mpy/lib/axtls/www/lua/test_fs.lua | 23 - user/mpy/lib/axtls/www/lua/test_htk.lua | 22 - user/mpy/lib/axtls/www/lua/test_lib.lua | 31 - user/mpy/lib/axtls/www/lua/test_main.html | 127 - user/mpy/lib/axtls/www/lua/test_main.lp | 31 - user/mpy/lib/axtls/www/lua/test_main.lua | 46 - user/mpy/lib/axtls/www/lua/test_session.lua | 43 - user/mpy/lib/axtls/www/lua/test_sql.lua | 13 - user/mpy/lib/axtls/www/lua/test_sql2.lua | 24 - user/mpy/lib/axtls/www/lua/test_variables.lp | 14 - user/mpy/lib/axtls/www/test_dir/bin/.htaccess | 1 - .../lib/axtls/www/test_dir/no_http/.htaccess | 1 - .../lib/axtls/www/test_dir/no_http/.htpasswd | 2 - .../lib/axtls/www/test_dir/no_http/index.html | 6 - .../lib/axtls/www/test_dir/no_ssl/.htaccess | 1 - .../lib/axtls/www/test_dir/no_ssl/index.html | 6 - user/mpy/lib/berkeley-db-1.xx/Makefile.inc | 10 - user/mpy/lib/berkeley-db-1.xx/PORT/Makefile | 102 - user/mpy/lib/berkeley-db-1.xx/PORT/README | 131 - .../berkeley-db-1.xx/PORT/aix.3.2/Makefile | 102 - .../lib/berkeley-db-1.xx/PORT/aix.3.2/clib | 1 - .../PORT/aix.3.2/include/cdefs.h | 1 - .../PORT/aix.3.2/include/compat.h | 231 - .../PORT/aix.3.2/include/db.h | 1 - .../PORT/aix.3.2/include/mpool.h | 1 - .../PORT/aix.3.2/include/ndbm.h | 1 - .../PORT/aix.3.2/include/queue.h | 1 - .../mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys | 1 - .../berkeley-db-1.xx/PORT/bsd.4.4/Makefile | 1 - .../lib/berkeley-db-1.xx/PORT/bsd.4.4/clib | 1 - .../PORT/bsd.4.4/include/cdefs.h | 1 - .../PORT/bsd.4.4/include/compat.h | 1 - .../PORT/bsd.4.4/include/db.h | 222 - .../PORT/bsd.4.4/include/mpool.h | 1 - .../PORT/bsd.4.4/include/ndbm.h | 1 - .../PORT/bsd.4.4/include/queue.h | 1 - .../mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys | 1 - .../berkeley-db-1.xx/PORT/bsdi.1.0/Makefile | 1 - .../PORT/bsdi.1.0/OTHER_PATCHES | 19 - .../lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib | 1 - .../PORT/bsdi.1.0/include/assert.h | 54 - .../PORT/bsdi.1.0/include/cdefs.h | 1 - .../PORT/bsdi.1.0/include/compat.h | 231 - .../PORT/bsdi.1.0/include/db.h | 1 - .../PORT/bsdi.1.0/include/mpool.h | 1 - .../PORT/bsdi.1.0/include/ndbm.h | 1 - .../PORT/bsdi.1.0/include/queue.h | 1 - .../PORT/bsdi.1.0/local/local.h | 87 - .../PORT/bsdi.1.0/local/makebuf.c | 118 - .../PORT/bsdi.1.0/local/setvbuf.c | 148 - .../lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys | 1 - .../lib/berkeley-db-1.xx/PORT/clib/memmove.c | 139 - .../lib/berkeley-db-1.xx/PORT/clib/mktemp.c | 126 - .../lib/berkeley-db-1.xx/PORT/clib/snprintf.c | 54 - .../lib/berkeley-db-1.xx/PORT/clib/strerror.c | 67 - .../berkeley-db-1.xx/PORT/dgux.5.4/Makefile | 103 - .../lib/berkeley-db-1.xx/PORT/dgux.5.4/clib | 1 - .../PORT/dgux.5.4/include/cdefs.h | 1 - .../PORT/dgux.5.4/include/compat.h | 231 - .../PORT/dgux.5.4/include/db.h | 1 - .../PORT/dgux.5.4/include/mpool.h | 1 - .../PORT/dgux.5.4/include/ndbm.h | 1 - .../PORT/dgux.5.4/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/dgux.5.4/sys | 1 - user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 | 1 - .../berkeley-db-1.xx/PORT/hpux.9.01/Makefile | 102 - .../lib/berkeley-db-1.xx/PORT/hpux.9.01/clib | 1 - .../PORT/hpux.9.01/include/cdefs.h | 1 - .../PORT/hpux.9.01/include/compat.h | 231 - .../PORT/hpux.9.01/include/db.h | 1 - .../PORT/hpux.9.01/include/mpool.h | 1 - .../PORT/hpux.9.01/include/ndbm.h | 1 - .../PORT/hpux.9.01/include/queue.h | 1 - .../PORT/hpux.9.01/local/hp_siglist.c | 75 - .../lib/berkeley-db-1.xx/PORT/hpux.9.01/sys | 1 - .../berkeley-db-1.xx/PORT/include/bsd-queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/include/cdefs.h | 122 - .../berkeley-db-1.xx/PORT/include/compat.h | 233 - .../lib/berkeley-db-1.xx/PORT/include/db.h | 1 - .../PORT/include/filevtable.h | 1 - .../lib/berkeley-db-1.xx/PORT/include/mpool.h | 1 - .../lib/berkeley-db-1.xx/PORT/include/ndbm.h | 77 - .../lib/berkeley-db-1.xx/PORT/include/queue.h | 245 - .../berkeley-db-1.xx/PORT/irix.4.05F/Makefile | 103 - .../PORT/irix.4.05F/OTHER_PATCHES | 32 - .../lib/berkeley-db-1.xx/PORT/irix.4.05F/clib | 1 - .../PORT/irix.4.05F/include/cdefs.h | 1 - .../PORT/irix.4.05F/include/compat.h | 231 - .../PORT/irix.4.05F/include/db.h | 1 - .../PORT/irix.4.05F/include/mpool.h | 1 - .../PORT/irix.4.05F/include/ndbm.h | 1 - .../PORT/irix.4.05F/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/irix.4.05F/sys | 1 - .../lib/berkeley-db-1.xx/PORT/linux/Makefile | 102 - .../berkeley-db-1.xx/PORT/linux/OTHER_PATCHES | 29 - user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib | 1 - .../PORT/linux/include/compat.h | 231 - .../berkeley-db-1.xx/PORT/linux/include/db.h | 1 - .../PORT/linux/include/mpool.h | 1 - .../PORT/linux/include/ndbm.h | 1 - user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys | 1 - .../berkeley-db-1.xx/PORT/osf.1.0.2/Makefile | 102 - .../lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib | 1 - .../PORT/osf.1.0.2/include/cdefs.h | 1 - .../PORT/osf.1.0.2/include/compat.h | 231 - .../PORT/osf.1.0.2/include/db.h | 1 - .../PORT/osf.1.0.2/include/mpool.h | 1 - .../PORT/osf.1.0.2/include/ndbm.h | 1 - .../PORT/osf.1.0.2/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys | 1 - user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 | 1 - user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 | 1 - .../berkeley-db-1.xx/PORT/ptx.2.0/Makefile | 104 - .../PORT/ptx.2.0/OTHER_PATCHES | 95 - .../lib/berkeley-db-1.xx/PORT/ptx.2.0/clib | 1 - .../PORT/ptx.2.0/include/cdefs.h | 1 - .../PORT/ptx.2.0/include/compat.h | 232 - .../PORT/ptx.2.0/include/db.h | 1 - .../PORT/ptx.2.0/include/mpool.h | 1 - .../PORT/ptx.2.0/include/ndbm.h | 1 - .../PORT/ptx.2.0/include/pathnames.h | 45 - .../PORT/ptx.2.0/include/queue.h | 1 - .../mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys | 1 - .../berkeley-db-1.xx/PORT/sinix.5.41/Makefile | 102 - .../lib/berkeley-db-1.xx/PORT/sinix.5.41/clib | 1 - .../PORT/sinix.5.41/include/cdefs.h | 1 - .../PORT/sinix.5.41/include/compat.h | 231 - .../PORT/sinix.5.41/include/db.h | 1 - .../PORT/sinix.5.41/include/mpool.h | 1 - .../PORT/sinix.5.41/include/ndbm.h | 1 - .../PORT/sinix.5.41/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/sinix.5.41/sys | 1 - .../mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 | 1 - .../PORT/sunos.4.1.1/Makefile | 102 - .../berkeley-db-1.xx/PORT/sunos.4.1.1/clib | 1 - .../PORT/sunos.4.1.1/include/cdefs.h | 1 - .../PORT/sunos.4.1.1/include/compat.h | 231 - .../PORT/sunos.4.1.1/include/db.h | 1 - .../PORT/sunos.4.1.1/include/mpool.h | 1 - .../PORT/sunos.4.1.1/include/ndbm.h | 1 - .../PORT/sunos.4.1.1/include/pathnames.h | 45 - .../PORT/sunos.4.1.1/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys | 1 - .../mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 | 1 - .../mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 | 1 - .../berkeley-db-1.xx/PORT/sunos.5.2/Makefile | 102 - .../lib/berkeley-db-1.xx/PORT/sunos.5.2/clib | 1 - .../PORT/sunos.5.2/include/cdefs.h | 1 - .../PORT/sunos.5.2/include/compat.h | 236 - .../PORT/sunos.5.2/include/db.h | 1 - .../PORT/sunos.5.2/include/mpool.h | 1 - .../PORT/sunos.5.2/include/ndbm.h | 1 - .../PORT/sunos.5.2/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/sunos.5.2/sys | 1 - .../berkeley-db-1.xx/PORT/ultrix.4.2/Makefile | 102 - .../lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib | 1 - .../PORT/ultrix.4.2/include/cdefs.h | 1 - .../PORT/ultrix.4.2/include/compat.h | 231 - .../PORT/ultrix.4.2/include/db.h | 230 - .../PORT/ultrix.4.2/include/mpool.h | 1 - .../PORT/ultrix.4.2/include/ndbm.h | 1 - .../PORT/ultrix.4.2/include/queue.h | 1 - .../lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys | 1 - user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 | 1 - user/mpy/lib/berkeley-db-1.xx/README | 40 - .../lib/berkeley-db-1.xx/btree/Makefile.inc | 7 - .../mpy/lib/berkeley-db-1.xx/btree/bt_close.c | 179 - user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c | 221 - .../mpy/lib/berkeley-db-1.xx/btree/bt_debug.c | 329 - .../lib/berkeley-db-1.xx/btree/bt_delete.c | 657 - user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c | 105 - user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c | 412 - .../lib/berkeley-db-1.xx/btree/bt_overflow.c | 228 - user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c | 100 - user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c | 321 - .../lib/berkeley-db-1.xx/btree/bt_search.c | 213 - user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c | 460 - .../mpy/lib/berkeley-db-1.xx/btree/bt_split.c | 834 - .../mpy/lib/berkeley-db-1.xx/btree/bt_utils.c | 260 - user/mpy/lib/berkeley-db-1.xx/btree/btree.h | 384 - user/mpy/lib/berkeley-db-1.xx/btree/extern.h | 70 - user/mpy/lib/berkeley-db-1.xx/btree/tags | 1 - user/mpy/lib/berkeley-db-1.xx/changelog | 103 - user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc | 5 - user/mpy/lib/berkeley-db-1.xx/db/db.c | 99 - user/mpy/lib/berkeley-db-1.xx/db/tags | 205 - user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps | Bin 16754 -> 0 bytes .../mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps | Bin 26477 -> 0 bytes user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps | Bin 11349 -> 0 bytes .../lib/berkeley-db-1.xx/docs/hash.usenix.ps | Bin 158771 -> 0 bytes .../lib/berkeley-db-1.xx/docs/libtp.usenix.ps | Bin 168201 -> 0 bytes user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps | Bin 13573 -> 0 bytes user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps | Bin 14632 -> 0 bytes .../lib/berkeley-db-1.xx/hash/Makefile.inc | 6 - user/mpy/lib/berkeley-db-1.xx/hash/README | 72 - user/mpy/lib/berkeley-db-1.xx/hash/extern.h | 65 - user/mpy/lib/berkeley-db-1.xx/hash/hash.c | 994 - user/mpy/lib/berkeley-db-1.xx/hash/hash.h | 293 - .../lib/berkeley-db-1.xx/hash/hash_bigkey.c | 667 - user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c | 355 - .../mpy/lib/berkeley-db-1.xx/hash/hash_func.c | 212 - .../mpy/lib/berkeley-db-1.xx/hash/hash_log2.c | 54 - .../mpy/lib/berkeley-db-1.xx/hash/hash_page.c | 944 - user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c | 107 - user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c | 202 - user/mpy/lib/berkeley-db-1.xx/hash/page.h | 92 - user/mpy/lib/berkeley-db-1.xx/hash/search.h | 51 - user/mpy/lib/berkeley-db-1.xx/hash/tags | 1 - user/mpy/lib/berkeley-db-1.xx/include/db.h | 237 - .../lib/berkeley-db-1.xx/include/filevtable.h | 54 - user/mpy/lib/berkeley-db-1.xx/include/mpool.h | 101 - user/mpy/lib/berkeley-db-1.xx/include/tags | 1 - .../mpy/lib/berkeley-db-1.xx/man/Makefile.inc | 7 - user/mpy/lib/berkeley-db-1.xx/man/btree.3 | 233 - user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 | 476 - user/mpy/lib/berkeley-db-1.xx/man/hash.3 | 159 - user/mpy/lib/berkeley-db-1.xx/man/mpool.3 | 219 - user/mpy/lib/berkeley-db-1.xx/man/recno.3 | 216 - .../lib/berkeley-db-1.xx/mpool/Makefile.inc | 5 - user/mpy/lib/berkeley-db-1.xx/mpool/README | 7 - user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c | 452 - .../lib/berkeley-db-1.xx/mpool/mpool.libtp | 746 - user/mpy/lib/berkeley-db-1.xx/mpool/tags | 1 - .../lib/berkeley-db-1.xx/recno/Makefile.inc | 6 - user/mpy/lib/berkeley-db-1.xx/recno/extern.h | 54 - .../lib/berkeley-db-1.xx/recno/rec_close.c | 182 - .../lib/berkeley-db-1.xx/recno/rec_delete.c | 197 - user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c | 311 - .../mpy/lib/berkeley-db-1.xx/recno/rec_open.c | 241 - user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c | 280 - .../lib/berkeley-db-1.xx/recno/rec_search.c | 126 - user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c | 131 - .../lib/berkeley-db-1.xx/recno/rec_utils.c | 122 - user/mpy/lib/berkeley-db-1.xx/recno/recno.h | 39 - user/mpy/lib/berkeley-db-1.xx/recno/tags | 1 - user/mpy/lib/berkeley-db-1.xx/test/Makefile | 23 - user/mpy/lib/berkeley-db-1.xx/test/README | 74 - .../berkeley-db-1.xx/test/btree.tests/main.c | 765 - user/mpy/lib/berkeley-db-1.xx/test/dbtest.c | 753 - .../test/hash.tests/driver2.c | 114 - .../test/hash.tests/makedb.sh | 13 - .../test/hash.tests/tcreat3.c | 105 - .../berkeley-db-1.xx/test/hash.tests/tdel.c | 122 - .../berkeley-db-1.xx/test/hash.tests/testit | 147 - .../berkeley-db-1.xx/test/hash.tests/thash4.c | 132 - .../berkeley-db-1.xx/test/hash.tests/tread2.c | 105 - .../berkeley-db-1.xx/test/hash.tests/tseq.c | 88 - .../test/hash.tests/tverify.c | 107 - user/mpy/lib/berkeley-db-1.xx/test/run.test | 705 - user/mpy/lib/cmsis/inc/cmsis_armcc.h | 734 - user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h | 1800 - user/mpy/lib/cmsis/inc/cmsis_gcc.h | 1373 - user/mpy/lib/cmsis/inc/core_cm0.h | 798 - user/mpy/lib/cmsis/inc/core_cm0plus.h | 914 - user/mpy/lib/cmsis/inc/core_cm3.h | 1763 - user/mpy/lib/cmsis/inc/core_cm4.h | 1937 - user/mpy/lib/cmsis/inc/core_cm7.h | 2512 - user/mpy/lib/cmsis/inc/core_cmFunc.h | 87 - user/mpy/lib/cmsis/inc/core_cmInstr.h | 87 - user/mpy/lib/cmsis/inc/core_cmSimd.h | 96 - user/mpy/lib/cmsis/inc/core_sc000.h | 926 - user/mpy/lib/cmsis/inc/core_sc300.h | 1745 - user/mpy/lib/embed/abort_.c | 7 - user/mpy/lib/libc/string0.c | 219 - user/mpy/lib/libffi/.gitignore | 36 - user/mpy/lib/libffi/.travis.yml | 22 - user/mpy/lib/libffi/ChangeLog.libffi | 584 - user/mpy/lib/libffi/ChangeLog.libffi-3.1 | 6000 - user/mpy/lib/libffi/ChangeLog.libgcj | 40 - user/mpy/lib/libffi/ChangeLog.v1 | 764 - user/mpy/lib/libffi/LICENSE | 21 - user/mpy/lib/libffi/Makefile.am | 174 - user/mpy/lib/libffi/README | 450 - user/mpy/lib/libffi/acinclude.m4 | 92 - user/mpy/lib/libffi/autogen.sh | 2 - user/mpy/lib/libffi/configure.ac | 372 - user/mpy/lib/libffi/configure.host | 259 - user/mpy/lib/libffi/doc/libffi.texi | 765 - user/mpy/lib/libffi/doc/version.texi | 4 - .../generate-darwin-source-and-headers.py | 209 - user/mpy/lib/libffi/include/Makefile.am | 10 - user/mpy/lib/libffi/include/ffi.h.in | 503 - user/mpy/lib/libffi/include/ffi_cfi.h | 55 - user/mpy/lib/libffi/include/ffi_common.h | 132 - user/mpy/lib/libffi/libffi.pc.in | 11 - .../libffi/libffi.xcodeproj/project.pbxproj | 637 - user/mpy/lib/libffi/libtool-version | 29 - user/mpy/lib/libffi/m4/asmcfi.m4 | 13 - user/mpy/lib/libffi/m4/ax_append_flag.m4 | 69 - user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 | 181 - user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 | 122 - .../lib/libffi/m4/ax_check_compile_flag.m4 | 72 - user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 | 84 - user/mpy/lib/libffi/m4/ax_configure_args.m4 | 70 - user/mpy/lib/libffi/m4/ax_enable_builddir.m4 | 301 - user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 | 225 - user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 | 79 - user/mpy/lib/libffi/man/Makefile.am | 8 - user/mpy/lib/libffi/man/ffi.3 | 41 - user/mpy/lib/libffi/man/ffi_call.3 | 103 - user/mpy/lib/libffi/man/ffi_prep_cif.3 | 68 - user/mpy/lib/libffi/man/ffi_prep_cif_var.3 | 73 - user/mpy/lib/libffi/msvcc.sh | 257 - user/mpy/lib/libffi/src/aarch64/ffi.c | 1152 - user/mpy/lib/libffi/src/aarch64/ffitarget.h | 73 - user/mpy/lib/libffi/src/aarch64/internal.h | 67 - user/mpy/lib/libffi/src/aarch64/sysv.S | 434 - user/mpy/lib/libffi/src/alpha/ffi.c | 521 - user/mpy/lib/libffi/src/alpha/ffitarget.h | 57 - user/mpy/lib/libffi/src/alpha/internal.h | 23 - user/mpy/lib/libffi/src/alpha/osf.S | 282 - user/mpy/lib/libffi/src/arc/arcompact.S | 135 - user/mpy/lib/libffi/src/arc/ffi.c | 268 - user/mpy/lib/libffi/src/arc/ffitarget.h | 53 - user/mpy/lib/libffi/src/arm/ffi.c | 1043 - user/mpy/lib/libffi/src/arm/ffitarget.h | 69 - user/mpy/lib/libffi/src/arm/internal.h | 7 - user/mpy/lib/libffi/src/arm/sysv.S | 335 - user/mpy/lib/libffi/src/avr32/ffi.c | 423 - user/mpy/lib/libffi/src/avr32/ffitarget.h | 55 - user/mpy/lib/libffi/src/avr32/sysv.S | 208 - user/mpy/lib/libffi/src/bfin/ffi.c | 196 - user/mpy/lib/libffi/src/bfin/ffitarget.h | 43 - user/mpy/lib/libffi/src/bfin/sysv.S | 179 - user/mpy/lib/libffi/src/closures.c | 688 - user/mpy/lib/libffi/src/cris/ffi.c | 386 - user/mpy/lib/libffi/src/cris/ffitarget.h | 56 - user/mpy/lib/libffi/src/cris/sysv.S | 215 - user/mpy/lib/libffi/src/debug.c | 64 - user/mpy/lib/libffi/src/dlmalloc.c | 5161 - user/mpy/lib/libffi/src/frv/eabi.S | 128 - user/mpy/lib/libffi/src/frv/ffi.c | 292 - user/mpy/lib/libffi/src/frv/ffitarget.h | 62 - user/mpy/lib/libffi/src/ia64/ffi.c | 586 - user/mpy/lib/libffi/src/ia64/ffitarget.h | 55 - user/mpy/lib/libffi/src/ia64/ia64_flags.h | 40 - user/mpy/lib/libffi/src/ia64/unix.S | 560 - user/mpy/lib/libffi/src/java_raw_api.c | 374 - user/mpy/lib/libffi/src/m32r/ffi.c | 232 - user/mpy/lib/libffi/src/m32r/ffitarget.h | 53 - user/mpy/lib/libffi/src/m32r/sysv.S | 121 - user/mpy/lib/libffi/src/m68k/ffi.c | 362 - user/mpy/lib/libffi/src/m68k/ffitarget.h | 54 - user/mpy/lib/libffi/src/m68k/sysv.S | 330 - user/mpy/lib/libffi/src/m88k/ffi.c | 400 - user/mpy/lib/libffi/src/m88k/ffitarget.h | 49 - user/mpy/lib/libffi/src/m88k/obsd.S | 209 - user/mpy/lib/libffi/src/metag/ffi.c | 330 - user/mpy/lib/libffi/src/metag/ffitarget.h | 53 - user/mpy/lib/libffi/src/metag/sysv.S | 311 - user/mpy/lib/libffi/src/microblaze/ffi.c | 321 - .../mpy/lib/libffi/src/microblaze/ffitarget.h | 53 - user/mpy/lib/libffi/src/microblaze/sysv.S | 302 - user/mpy/lib/libffi/src/mips/ffi.c | 1050 - user/mpy/lib/libffi/src/mips/ffitarget.h | 247 - user/mpy/lib/libffi/src/mips/n32.S | 576 - user/mpy/lib/libffi/src/mips/o32.S | 381 - user/mpy/lib/libffi/src/moxie/eabi.S | 101 - user/mpy/lib/libffi/src/moxie/ffi.c | 272 - user/mpy/lib/libffi/src/moxie/ffitarget.h | 52 - user/mpy/lib/libffi/src/nios2/ffi.c | 304 - user/mpy/lib/libffi/src/nios2/ffitarget.h | 52 - user/mpy/lib/libffi/src/nios2/sysv.S | 136 - user/mpy/lib/libffi/src/or1k/ffi.c | 328 - user/mpy/lib/libffi/src/or1k/ffitarget.h | 58 - user/mpy/lib/libffi/src/or1k/sysv.S | 107 - user/mpy/lib/libffi/src/pa/ffi.c | 719 - user/mpy/lib/libffi/src/pa/ffitarget.h | 85 - user/mpy/lib/libffi/src/pa/hpux32.S | 368 - user/mpy/lib/libffi/src/pa/linux.S | 357 - user/mpy/lib/libffi/src/powerpc/aix.S | 328 - user/mpy/lib/libffi/src/powerpc/aix_closure.S | 447 - user/mpy/lib/libffi/src/powerpc/asm.h | 125 - user/mpy/lib/libffi/src/powerpc/darwin.S | 378 - .../lib/libffi/src/powerpc/darwin_closure.S | 571 - user/mpy/lib/libffi/src/powerpc/ffi.c | 173 - user/mpy/lib/libffi/src/powerpc/ffi_darwin.c | 1359 - user/mpy/lib/libffi/src/powerpc/ffi_linux64.c | 945 - user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h | 94 - user/mpy/lib/libffi/src/powerpc/ffi_sysv.c | 934 - user/mpy/lib/libffi/src/powerpc/ffitarget.h | 195 - user/mpy/lib/libffi/src/powerpc/linux64.S | 228 - .../lib/libffi/src/powerpc/linux64_closure.S | 488 - user/mpy/lib/libffi/src/powerpc/ppc_closure.S | 397 - user/mpy/lib/libffi/src/powerpc/sysv.S | 175 - user/mpy/lib/libffi/src/prep_cif.c | 242 - user/mpy/lib/libffi/src/raw_api.c | 267 - user/mpy/lib/libffi/src/s390/ffi.c | 756 - user/mpy/lib/libffi/src/s390/ffitarget.h | 70 - user/mpy/lib/libffi/src/s390/internal.h | 11 - user/mpy/lib/libffi/src/s390/sysv.S | 325 - user/mpy/lib/libffi/src/sh/ffi.c | 717 - user/mpy/lib/libffi/src/sh/ffitarget.h | 54 - user/mpy/lib/libffi/src/sh/sysv.S | 850 - user/mpy/lib/libffi/src/sh64/ffi.c | 469 - user/mpy/lib/libffi/src/sh64/ffitarget.h | 58 - user/mpy/lib/libffi/src/sh64/sysv.S | 539 - user/mpy/lib/libffi/src/sparc/ffi.c | 468 - user/mpy/lib/libffi/src/sparc/ffi64.c | 608 - user/mpy/lib/libffi/src/sparc/ffitarget.h | 81 - user/mpy/lib/libffi/src/sparc/internal.h | 26 - user/mpy/lib/libffi/src/sparc/v8.S | 443 - user/mpy/lib/libffi/src/sparc/v9.S | 440 - user/mpy/lib/libffi/src/tile/ffi.c | 355 - user/mpy/lib/libffi/src/tile/ffitarget.h | 65 - user/mpy/lib/libffi/src/tile/tile.S | 360 - user/mpy/lib/libffi/src/types.c | 106 - user/mpy/lib/libffi/src/vax/elfbsd.S | 195 - user/mpy/lib/libffi/src/vax/ffi.c | 276 - user/mpy/lib/libffi/src/vax/ffitarget.h | 49 - user/mpy/lib/libffi/src/x86/ffi.c | 729 - user/mpy/lib/libffi/src/x86/ffi64.c | 824 - user/mpy/lib/libffi/src/x86/ffitarget.h | 139 - user/mpy/lib/libffi/src/x86/ffiw64.c | 281 - user/mpy/lib/libffi/src/x86/internal.h | 29 - user/mpy/lib/libffi/src/x86/internal64.h | 22 - user/mpy/lib/libffi/src/x86/sysv.S | 1040 - user/mpy/lib/libffi/src/x86/unix64.S | 546 - user/mpy/lib/libffi/src/x86/win64.S | 219 - user/mpy/lib/libffi/src/xtensa/ffi.c | 298 - user/mpy/lib/libffi/src/xtensa/ffitarget.h | 53 - user/mpy/lib/libffi/src/xtensa/sysv.S | 253 - user/mpy/lib/libffi/stamp-h.in | 1 - user/mpy/lib/libffi/testsuite/Makefile.am | 85 - .../lib/libffi/testsuite/config/default.exp | 1 - user/mpy/lib/libffi/testsuite/lib/libffi.exp | 431 - .../libffi/testsuite/lib/target-libpath.exp | 283 - user/mpy/lib/libffi/testsuite/lib/wrapper.exp | 45 - .../lib/libffi/testsuite/libffi.call/call.exp | 30 - .../testsuite/libffi.call/closure_fn0.c | 89 - .../testsuite/libffi.call/closure_fn1.c | 81 - .../testsuite/libffi.call/closure_fn2.c | 81 - .../testsuite/libffi.call/closure_fn3.c | 82 - .../testsuite/libffi.call/closure_fn4.c | 89 - .../testsuite/libffi.call/closure_fn5.c | 92 - .../testsuite/libffi.call/closure_fn6.c | 90 - .../testsuite/libffi.call/closure_loc_fn0.c | 95 - .../testsuite/libffi.call/closure_simple.c | 55 - .../libffi/testsuite/libffi.call/cls_12byte.c | 94 - .../libffi/testsuite/libffi.call/cls_16byte.c | 95 - .../libffi/testsuite/libffi.call/cls_18byte.c | 96 - .../libffi/testsuite/libffi.call/cls_19byte.c | 102 - .../testsuite/libffi.call/cls_1_1byte.c | 89 - .../libffi/testsuite/libffi.call/cls_20byte.c | 91 - .../testsuite/libffi.call/cls_20byte1.c | 93 - .../libffi/testsuite/libffi.call/cls_24byte.c | 113 - .../libffi/testsuite/libffi.call/cls_2byte.c | 90 - .../testsuite/libffi.call/cls_3_1byte.c | 95 - .../libffi/testsuite/libffi.call/cls_3byte1.c | 90 - .../libffi/testsuite/libffi.call/cls_3byte2.c | 90 - .../testsuite/libffi.call/cls_4_1byte.c | 98 - .../libffi/testsuite/libffi.call/cls_4byte.c | 90 - .../testsuite/libffi.call/cls_5_1_byte.c | 109 - .../libffi/testsuite/libffi.call/cls_5byte.c | 98 - .../libffi/testsuite/libffi.call/cls_64byte.c | 124 - .../testsuite/libffi.call/cls_6_1_byte.c | 113 - .../libffi/testsuite/libffi.call/cls_6byte.c | 99 - .../testsuite/libffi.call/cls_7_1_byte.c | 117 - .../libffi/testsuite/libffi.call/cls_7byte.c | 97 - .../libffi/testsuite/libffi.call/cls_8byte.c | 88 - .../libffi/testsuite/libffi.call/cls_9byte1.c | 90 - .../libffi/testsuite/libffi.call/cls_9byte2.c | 91 - .../testsuite/libffi.call/cls_align_double.c | 93 - .../testsuite/libffi.call/cls_align_float.c | 91 - .../libffi.call/cls_align_longdouble.c | 92 - .../libffi.call/cls_align_longdouble_split.c | 132 - .../libffi.call/cls_align_longdouble_split2.c | 115 - .../testsuite/libffi.call/cls_align_pointer.c | 95 - .../testsuite/libffi.call/cls_align_sint16.c | 91 - .../testsuite/libffi.call/cls_align_sint32.c | 91 - .../testsuite/libffi.call/cls_align_sint64.c | 92 - .../testsuite/libffi.call/cls_align_uint16.c | 91 - .../testsuite/libffi.call/cls_align_uint32.c | 91 - .../testsuite/libffi.call/cls_align_uint64.c | 93 - .../testsuite/libffi.call/cls_dbls_struct.c | 66 - .../libffi/testsuite/libffi.call/cls_double.c | 43 - .../testsuite/libffi.call/cls_double_va.c | 61 - .../libffi/testsuite/libffi.call/cls_float.c | 42 - .../testsuite/libffi.call/cls_longdouble.c | 105 - .../testsuite/libffi.call/cls_longdouble_va.c | 61 - .../libffi.call/cls_many_mixed_args.c | 70 - .../libffi.call/cls_many_mixed_float_double.c | 55 - .../testsuite/libffi.call/cls_multi_schar.c | 74 - .../testsuite/libffi.call/cls_multi_sshort.c | 74 - .../libffi.call/cls_multi_sshortchar.c | 86 - .../testsuite/libffi.call/cls_multi_uchar.c | 91 - .../testsuite/libffi.call/cls_multi_ushort.c | 74 - .../libffi.call/cls_multi_ushortchar.c | 86 - .../testsuite/libffi.call/cls_pointer.c | 74 - .../testsuite/libffi.call/cls_pointer_stack.c | 142 - .../libffi/testsuite/libffi.call/cls_schar.c | 44 - .../libffi/testsuite/libffi.call/cls_sint.c | 42 - .../libffi/testsuite/libffi.call/cls_sshort.c | 42 - .../testsuite/libffi.call/cls_struct_va1.c | 114 - .../libffi/testsuite/libffi.call/cls_uchar.c | 42 - .../testsuite/libffi.call/cls_uchar_va.c | 44 - .../libffi/testsuite/libffi.call/cls_uint.c | 43 - .../testsuite/libffi.call/cls_uint_va.c | 45 - .../testsuite/libffi.call/cls_ulong_va.c | 45 - .../testsuite/libffi.call/cls_ulonglong.c | 47 - .../libffi/testsuite/libffi.call/cls_ushort.c | 43 - .../testsuite/libffi.call/cls_ushort_va.c | 44 - .../testsuite/libffi.call/err_bad_abi.c | 36 - .../testsuite/libffi.call/err_bad_typedef.c | 26 - .../libffi/testsuite/libffi.call/ffitest.h | 135 - .../lib/libffi/testsuite/libffi.call/float.c | 59 - .../lib/libffi/testsuite/libffi.call/float1.c | 60 - .../lib/libffi/testsuite/libffi.call/float2.c | 58 - .../lib/libffi/testsuite/libffi.call/float3.c | 74 - .../lib/libffi/testsuite/libffi.call/float4.c | 62 - .../libffi/testsuite/libffi.call/float_va.c | 107 - .../testsuite/libffi.call/huge_struct.c | 341 - .../lib/libffi/testsuite/libffi.call/many.c | 59 - .../lib/libffi/testsuite/libffi.call/many2.c | 57 - .../testsuite/libffi.call/many_double.c | 70 - .../libffi/testsuite/libffi.call/many_mixed.c | 78 - .../lib/libffi/testsuite/libffi.call/negint.c | 52 - .../testsuite/libffi.call/nested_struct.c | 152 - .../testsuite/libffi.call/nested_struct1.c | 161 - .../testsuite/libffi.call/nested_struct10.c | 133 - .../testsuite/libffi.call/nested_struct11.c | 121 - .../testsuite/libffi.call/nested_struct2.c | 110 - .../testsuite/libffi.call/nested_struct3.c | 111 - .../testsuite/libffi.call/nested_struct4.c | 111 - .../testsuite/libffi.call/nested_struct5.c | 112 - .../testsuite/libffi.call/nested_struct6.c | 131 - .../testsuite/libffi.call/nested_struct7.c | 111 - .../testsuite/libffi.call/nested_struct8.c | 131 - .../testsuite/libffi.call/nested_struct9.c | 131 - .../libffi/testsuite/libffi.call/pr1172638.c | 127 - .../libffi/testsuite/libffi.call/problem1.c | 90 - .../libffi/testsuite/libffi.call/promotion.c | 59 - .../libffi/testsuite/libffi.call/pyobjc-tc.c | 114 - .../libffi/testsuite/libffi.call/return_dbl.c | 36 - .../testsuite/libffi.call/return_dbl1.c | 43 - .../testsuite/libffi.call/return_dbl2.c | 42 - .../libffi/testsuite/libffi.call/return_fl.c | 35 - .../libffi/testsuite/libffi.call/return_fl1.c | 36 - .../libffi/testsuite/libffi.call/return_fl2.c | 49 - .../libffi/testsuite/libffi.call/return_fl3.c | 42 - .../libffi/testsuite/libffi.call/return_ldl.c | 34 - .../libffi/testsuite/libffi.call/return_ll.c | 41 - .../libffi/testsuite/libffi.call/return_ll1.c | 43 - .../libffi/testsuite/libffi.call/return_sc.c | 36 - .../libffi/testsuite/libffi.call/return_sl.c | 38 - .../libffi/testsuite/libffi.call/return_uc.c | 38 - .../libffi/testsuite/libffi.call/return_ul.c | 38 - .../testsuite/libffi.call/stret_large.c | 145 - .../testsuite/libffi.call/stret_large2.c | 148 - .../testsuite/libffi.call/stret_medium.c | 124 - .../testsuite/libffi.call/stret_medium2.c | 125 - .../lib/libffi/testsuite/libffi.call/strlen.c | 44 - .../libffi/testsuite/libffi.call/strlen2.c | 49 - .../libffi/testsuite/libffi.call/strlen3.c | 49 - .../libffi/testsuite/libffi.call/strlen4.c | 55 - .../libffi/testsuite/libffi.call/struct1.c | 67 - .../libffi/testsuite/libffi.call/struct2.c | 67 - .../libffi/testsuite/libffi.call/struct3.c | 60 - .../libffi/testsuite/libffi.call/struct4.c | 64 - .../libffi/testsuite/libffi.call/struct5.c | 66 - .../libffi/testsuite/libffi.call/struct6.c | 64 - .../libffi/testsuite/libffi.call/struct7.c | 74 - .../libffi/testsuite/libffi.call/struct8.c | 81 - .../libffi/testsuite/libffi.call/struct9.c | 68 - .../testsuite/libffi.call/testclosure.c | 70 - .../testsuite/libffi.call/uninitialized.c | 61 - .../testsuite/libffi.call/unwindtest.cc | 117 - .../libffi.call/unwindtest_ffi_call.cc | 54 - .../lib/libffi/testsuite/libffi.call/va_1.c | 196 - .../libffi/testsuite/libffi.call/va_struct1.c | 121 - .../libffi/testsuite/libffi.call/va_struct2.c | 123 - .../libffi/testsuite/libffi.call/va_struct3.c | 125 - .../libffi.complex/cls_align_complex.inc | 91 - .../libffi.complex/cls_align_complex_double.c | 10 - .../libffi.complex/cls_align_complex_float.c | 10 - .../cls_align_complex_longdouble.c | 10 - .../testsuite/libffi.complex/cls_complex.inc | 42 - .../libffi.complex/cls_complex_double.c | 10 - .../libffi.complex/cls_complex_float.c | 10 - .../libffi.complex/cls_complex_longdouble.c | 10 - .../libffi.complex/cls_complex_struct.inc | 71 - .../cls_complex_struct_double.c | 10 - .../libffi.complex/cls_complex_struct_float.c | 10 - .../cls_complex_struct_longdouble.c | 10 - .../libffi.complex/cls_complex_va.inc | 80 - .../libffi.complex/cls_complex_va_double.c | 10 - .../libffi.complex/cls_complex_va_float.c | 16 - .../cls_complex_va_longdouble.c | 10 - .../testsuite/libffi.complex/complex.exp | 36 - .../testsuite/libffi.complex/complex.inc | 51 - .../libffi.complex/complex_defs_double.inc | 7 - .../libffi.complex/complex_defs_float.inc | 7 - .../complex_defs_longdouble.inc | 7 - .../testsuite/libffi.complex/complex_double.c | 10 - .../testsuite/libffi.complex/complex_float.c | 10 - .../testsuite/libffi.complex/complex_int.c | 86 - .../libffi.complex/complex_longdouble.c | 10 - .../libffi/testsuite/libffi.complex/ffitest.h | 1 - .../testsuite/libffi.complex/many_complex.inc | 78 - .../libffi.complex/many_complex_double.c | 10 - .../libffi.complex/many_complex_float.c | 10 - .../libffi.complex/many_complex_longdouble.c | 10 - .../libffi.complex/return_complex.inc | 37 - .../libffi.complex/return_complex1.inc | 41 - .../libffi.complex/return_complex1_double.c | 10 - .../libffi.complex/return_complex1_float.c | 10 - .../return_complex1_longdouble.c | 10 - .../libffi.complex/return_complex2.inc | 44 - .../libffi.complex/return_complex2_double.c | 10 - .../libffi.complex/return_complex2_float.c | 10 - .../return_complex2_longdouble.c | 10 - .../libffi.complex/return_complex_double.c | 10 - .../libffi.complex/return_complex_float.c | 10 - .../return_complex_longdouble.c | 10 - .../libffi/testsuite/libffi.go/aa-direct.c | 34 - .../lib/libffi/testsuite/libffi.go/closure1.c | 28 - .../lib/libffi/testsuite/libffi.go/ffitest.h | 1 - .../mpy/lib/libffi/testsuite/libffi.go/go.exp | 36 - .../libffi/testsuite/libffi.go/static-chain.h | 19 - user/mpy/lib/libffi/texinfo.tex | 10079 - user/mpy/lib/libm/acoshf.c | 32 - user/mpy/lib/libm/asinfacosf.c | 130 - user/mpy/lib/libm/asinhf.c | 34 - user/mpy/lib/libm/atan2f.c | 89 - user/mpy/lib/libm/atanf.c | 100 - user/mpy/lib/libm/atanhf.c | 34 - user/mpy/lib/libm/ef_rem_pio2.c | 202 - user/mpy/lib/libm/ef_sqrt.c | 102 - user/mpy/lib/libm/erf_lgamma.c | 255 - user/mpy/lib/libm/fdlibm.h | 227 - user/mpy/lib/libm/fmodf.c | 70 - user/mpy/lib/libm/kf_cos.c | 68 - user/mpy/lib/libm/kf_rem_pio2.c | 218 - user/mpy/lib/libm/kf_sin.c | 58 - user/mpy/lib/libm/kf_tan.c | 105 - user/mpy/lib/libm/libm.h | 54 - user/mpy/lib/libm/log1pf.c | 83 - user/mpy/lib/libm/math.c | 822 - user/mpy/lib/libm/nearbyintf.c | 21 - user/mpy/lib/libm/roundf.c | 33 - user/mpy/lib/libm/sf_cos.c | 71 - user/mpy/lib/libm/sf_erf.c | 257 - user/mpy/lib/libm/sf_frexp.c | 70 - user/mpy/lib/libm/sf_ldexp.c | 53 - user/mpy/lib/libm/sf_modf.c | 82 - user/mpy/lib/libm/sf_sin.c | 71 - user/mpy/lib/libm/sf_tan.c | 66 - user/mpy/lib/libm/thumb_vfp_sqrtf.c | 11 - user/mpy/lib/libm/wf_lgamma.c | 98 - user/mpy/lib/libm/wf_tgamma.c | 69 - user/mpy/lib/libm_dbl/README | 32 - user/mpy/lib/libm_dbl/__cos.c | 71 - user/mpy/lib/libm_dbl/__expo2.c | 16 - user/mpy/lib/libm_dbl/__fpclassify.c | 11 - user/mpy/lib/libm_dbl/__rem_pio2.c | 177 - user/mpy/lib/libm_dbl/__rem_pio2_large.c | 442 - user/mpy/lib/libm_dbl/__signbit.c | 12 - user/mpy/lib/libm_dbl/__sin.c | 64 - user/mpy/lib/libm_dbl/__tan.c | 110 - user/mpy/lib/libm_dbl/acos.c | 101 - user/mpy/lib/libm_dbl/acosh.c | 24 - user/mpy/lib/libm_dbl/asin.c | 107 - user/mpy/lib/libm_dbl/asinh.c | 28 - user/mpy/lib/libm_dbl/atan.c | 116 - user/mpy/lib/libm_dbl/atan2.c | 107 - user/mpy/lib/libm_dbl/atanh.c | 29 - user/mpy/lib/libm_dbl/ceil.c | 31 - user/mpy/lib/libm_dbl/cos.c | 77 - user/mpy/lib/libm_dbl/cosh.c | 40 - user/mpy/lib/libm_dbl/erf.c | 273 - user/mpy/lib/libm_dbl/exp.c | 134 - user/mpy/lib/libm_dbl/expm1.c | 201 - user/mpy/lib/libm_dbl/floor.c | 31 - user/mpy/lib/libm_dbl/fmod.c | 68 - user/mpy/lib/libm_dbl/frexp.c | 23 - user/mpy/lib/libm_dbl/ldexp.c | 6 - user/mpy/lib/libm_dbl/lgamma.c | 8 - user/mpy/lib/libm_dbl/libm.h | 96 - user/mpy/lib/libm_dbl/log.c | 118 - user/mpy/lib/libm_dbl/log10.c | 7 - user/mpy/lib/libm_dbl/log1p.c | 122 - user/mpy/lib/libm_dbl/modf.c | 34 - user/mpy/lib/libm_dbl/nearbyint.c | 20 - user/mpy/lib/libm_dbl/pow.c | 328 - user/mpy/lib/libm_dbl/rint.c | 28 - user/mpy/lib/libm_dbl/scalbn.c | 33 - user/mpy/lib/libm_dbl/sin.c | 78 - user/mpy/lib/libm_dbl/sinh.c | 39 - user/mpy/lib/libm_dbl/sqrt.c | 185 - user/mpy/lib/libm_dbl/tan.c | 70 - user/mpy/lib/libm_dbl/tanh.c | 5 - user/mpy/lib/libm_dbl/tgamma.c | 222 - user/mpy/lib/libm_dbl/trunc.c | 19 - user/mpy/lib/lwip/CHANGELOG | 3339 - user/mpy/lib/lwip/COPYING | 33 - user/mpy/lib/lwip/FILES | 4 - user/mpy/lib/lwip/README | 89 - user/mpy/lib/lwip/UPGRADING | 144 - user/mpy/lib/lwip/doc/FILES | 6 - user/mpy/lib/lwip/doc/contrib.txt | 63 - user/mpy/lib/lwip/doc/rawapi.txt | 511 - user/mpy/lib/lwip/doc/savannah.txt | 135 - user/mpy/lib/lwip/doc/snmp_agent.txt | 181 - user/mpy/lib/lwip/doc/sys_arch.txt | 267 - user/mpy/lib/lwip/src/FILES | 13 - user/mpy/lib/lwip/src/api/api_lib.c | 780 - user/mpy/lib/lwip/src/api/api_msg.c | 1565 - user/mpy/lib/lwip/src/api/err.c | 75 - user/mpy/lib/lwip/src/api/netbuf.c | 245 - user/mpy/lib/lwip/src/api/netdb.c | 353 - user/mpy/lib/lwip/src/api/netifapi.c | 160 - user/mpy/lib/lwip/src/api/sockets.c | 2374 - user/mpy/lib/lwip/src/api/tcpip.c | 511 - user/mpy/lib/lwip/src/core/def.c | 108 - user/mpy/lib/lwip/src/core/dhcp.c | 1770 - user/mpy/lib/lwip/src/core/dns.c | 970 - user/mpy/lib/lwip/src/core/init.c | 332 - user/mpy/lib/lwip/src/core/ipv4/autoip.c | 528 - user/mpy/lib/lwip/src/core/ipv4/icmp.c | 339 - user/mpy/lib/lwip/src/core/ipv4/igmp.c | 805 - user/mpy/lib/lwip/src/core/ipv4/inet.c | 42 - user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c | 450 - user/mpy/lib/lwip/src/core/ipv4/ip.c | 924 - user/mpy/lib/lwip/src/core/ipv4/ip_addr.c | 312 - user/mpy/lib/lwip/src/core/ipv4/ip_frag.c | 863 - user/mpy/lib/lwip/src/core/ipv6/README | 1 - user/mpy/lib/lwip/src/core/ipv6/icmp6.c | 179 - user/mpy/lib/lwip/src/core/ipv6/inet6.c | 163 - user/mpy/lib/lwip/src/core/ipv6/ip6.c | 397 - user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c | 72 - user/mpy/lib/lwip/src/core/mem.c | 659 - user/mpy/lib/lwip/src/core/memp.c | 470 - user/mpy/lib/lwip/src/core/netif.c | 774 - user/mpy/lib/lwip/src/core/pbuf.c | 1179 - user/mpy/lib/lwip/src/core/raw.c | 350 - user/mpy/lib/lwip/src/core/snmp/asn1_dec.c | 657 - user/mpy/lib/lwip/src/core/snmp/asn1_enc.c | 611 - user/mpy/lib/lwip/src/core/snmp/mib2.c | 4146 - user/mpy/lib/lwip/src/core/snmp/mib_structs.c | 1174 - user/mpy/lib/lwip/src/core/snmp/msg_in.c | 1453 - user/mpy/lib/lwip/src/core/snmp/msg_out.c | 674 - user/mpy/lib/lwip/src/core/stats.c | 176 - user/mpy/lib/lwip/src/core/sys.c | 68 - user/mpy/lib/lwip/src/core/tcp.c | 1742 - user/mpy/lib/lwip/src/core/tcp_in.c | 1619 - user/mpy/lib/lwip/src/core/tcp_out.c | 1485 - user/mpy/lib/lwip/src/core/timers.c | 487 - user/mpy/lib/lwip/src/core/udp.c | 1013 - .../lib/lwip/src/include/ipv4/lwip/autoip.h | 118 - .../mpy/lib/lwip/src/include/ipv4/lwip/icmp.h | 111 - .../mpy/lib/lwip/src/include/ipv4/lwip/igmp.h | 106 - .../mpy/lib/lwip/src/include/ipv4/lwip/inet.h | 107 - .../lwip/src/include/ipv4/lwip/inet_chksum.h | 90 - user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h | 223 - .../lib/lwip/src/include/ipv4/lwip/ip_addr.h | 244 - .../lib/lwip/src/include/ipv4/lwip/ip_frag.h | 88 - .../mpy/lib/lwip/src/include/ipv6/lwip/icmp.h | 100 - .../mpy/lib/lwip/src/include/ipv6/lwip/inet.h | 68 - user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h | 130 - .../lib/lwip/src/include/ipv6/lwip/ip_addr.h | 97 - user/mpy/lib/lwip/src/include/lwip/api.h | 297 - user/mpy/lib/lwip/src/include/lwip/api_msg.h | 177 - user/mpy/lib/lwip/src/include/lwip/arch.h | 217 - user/mpy/lib/lwip/src/include/lwip/debug.h | 99 - user/mpy/lib/lwip/src/include/lwip/def.h | 123 - user/mpy/lib/lwip/src/include/lwip/dhcp.h | 242 - user/mpy/lib/lwip/src/include/lwip/dns.h | 124 - user/mpy/lib/lwip/src/include/lwip/err.h | 85 - user/mpy/lib/lwip/src/include/lwip/init.h | 72 - user/mpy/lib/lwip/src/include/lwip/mem.h | 123 - user/mpy/lib/lwip/src/include/lwip/memp.h | 116 - user/mpy/lib/lwip/src/include/lwip/memp_std.h | 122 - user/mpy/lib/lwip/src/include/lwip/netbuf.h | 101 - user/mpy/lib/lwip/src/include/lwip/netdb.h | 124 - user/mpy/lib/lwip/src/include/lwip/netif.h | 328 - user/mpy/lib/lwip/src/include/lwip/netifapi.h | 108 - user/mpy/lib/lwip/src/include/lwip/opt.h | 2133 - user/mpy/lib/lwip/src/include/lwip/pbuf.h | 178 - user/mpy/lib/lwip/src/include/lwip/raw.h | 98 - user/mpy/lib/lwip/src/include/lwip/sio.h | 141 - user/mpy/lib/lwip/src/include/lwip/snmp.h | 367 - .../mpy/lib/lwip/src/include/lwip/snmp_asn1.h | 101 - user/mpy/lib/lwip/src/include/lwip/snmp_msg.h | 315 - .../lib/lwip/src/include/lwip/snmp_structs.h | 268 - user/mpy/lib/lwip/src/include/lwip/sockets.h | 379 - user/mpy/lib/lwip/src/include/lwip/stats.h | 292 - user/mpy/lib/lwip/src/include/lwip/sys.h | 337 - user/mpy/lib/lwip/src/include/lwip/tcp.h | 379 - user/mpy/lib/lwip/src/include/lwip/tcp_impl.h | 486 - user/mpy/lib/lwip/src/include/lwip/tcpip.h | 167 - user/mpy/lib/lwip/src/include/lwip/timers.h | 100 - user/mpy/lib/lwip/src/include/lwip/udp.h | 171 - user/mpy/lib/lwip/src/include/netif/etharp.h | 222 - user/mpy/lib/lwip/src/include/netif/ppp_oe.h | 190 - user/mpy/lib/lwip/src/include/netif/slipif.h | 81 - user/mpy/lib/lwip/src/include/posix/netdb.h | 33 - .../lib/lwip/src/include/posix/sys/socket.h | 33 - user/mpy/lib/lwip/src/netif/FILES | 29 - user/mpy/lib/lwip/src/netif/etharp.c | 1399 - user/mpy/lib/lwip/src/netif/ethernetif.c | 317 - user/mpy/lib/lwip/src/netif/ppp/auth.c | 1334 - user/mpy/lib/lwip/src/netif/ppp/auth.h | 111 - user/mpy/lib/lwip/src/netif/ppp/chap.c | 908 - user/mpy/lib/lwip/src/netif/ppp/chap.h | 150 - user/mpy/lib/lwip/src/netif/ppp/chpms.c | 396 - user/mpy/lib/lwip/src/netif/ppp/chpms.h | 64 - user/mpy/lib/lwip/src/netif/ppp/fsm.c | 890 - user/mpy/lib/lwip/src/netif/ppp/fsm.h | 157 - user/mpy/lib/lwip/src/netif/ppp/ipcp.c | 1411 - user/mpy/lib/lwip/src/netif/ppp/ipcp.h | 106 - user/mpy/lib/lwip/src/netif/ppp/lcp.c | 2066 - user/mpy/lib/lwip/src/netif/ppp/lcp.h | 151 - user/mpy/lib/lwip/src/netif/ppp/magic.c | 80 - user/mpy/lib/lwip/src/netif/ppp/magic.h | 63 - user/mpy/lib/lwip/src/netif/ppp/md5.c | 320 - user/mpy/lib/lwip/src/netif/ppp/md5.h | 55 - user/mpy/lib/lwip/src/netif/ppp/pap.c | 628 - user/mpy/lib/lwip/src/netif/ppp/pap.h | 118 - user/mpy/lib/lwip/src/netif/ppp/ppp.c | 2045 - user/mpy/lib/lwip/src/netif/ppp/ppp.h | 201 - user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h | 363 - user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c | 1132 - user/mpy/lib/lwip/src/netif/ppp/pppdebug.h | 73 - user/mpy/lib/lwip/src/netif/ppp/randm.c | 249 - user/mpy/lib/lwip/src/netif/ppp/randm.h | 81 - user/mpy/lib/lwip/src/netif/ppp/vj.c | 652 - user/mpy/lib/lwip/src/netif/ppp/vj.h | 156 - user/mpy/lib/lwip/src/netif/slipif.c | 510 - user/mpy/lib/lwip/test/unit/core/test_mem.c | 73 - user/mpy/lib/lwip/test/unit/core/test_mem.h | 8 - .../lib/lwip/test/unit/etharp/test_etharp.c | 262 - .../lib/lwip/test/unit/etharp/test_etharp.h | 8 - user/mpy/lib/lwip/test/unit/lwip_check.h | 37 - user/mpy/lib/lwip/test/unit/lwip_unittests.c | 45 - user/mpy/lib/lwip/test/unit/lwipopts.h | 50 - user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c | 294 - user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h | 52 - user/mpy/lib/lwip/test/unit/tcp/test_tcp.c | 667 - user/mpy/lib/lwip/test/unit/tcp/test_tcp.h | 8 - .../mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c | 944 - .../mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h | 8 - user/mpy/lib/lwip/test/unit/udp/test_udp.c | 68 - user/mpy/lib/lwip/test/unit/udp/test_udp.h | 8 - user/mpy/lib/memzip/README.md | 28 - user/mpy/lib/memzip/import.c | 17 - user/mpy/lib/memzip/lexermemzip.c | 19 - user/mpy/lib/memzip/make-memzip.py | 79 - user/mpy/lib/memzip/memzip.c | 106 - user/mpy/lib/memzip/memzip.h | 83 - user/mpy/lib/mp-readline/readline.c | 447 - user/mpy/lib/mp-readline/readline.h | 48 - user/mpy/lib/netutils/netutils.c | 96 - user/mpy/lib/netutils/netutils.h | 50 - user/mpy/lib/oofatfs/diskio.h | 83 - user/mpy/lib/oofatfs/ff.c | 5594 - user/mpy/lib/oofatfs/ff.h | 380 - user/mpy/lib/oofatfs/ffconf.h | 349 - user/mpy/lib/oofatfs/option/ccsbcs.c | 388 - user/mpy/lib/oofatfs/option/unicode.c | 17 - user/mpy/lib/timeutils/timeutils.c | 215 - user/mpy/lib/timeutils/timeutils.h | 54 - user/mpy/lib/utils/interrupt_char.c | 50 - user/mpy/lib/utils/interrupt_char.h | 33 - user/mpy/lib/utils/printf.c | 135 - user/mpy/lib/utils/pyexec.c | 531 - user/mpy/lib/utils/pyexec.h | 54 - user/mpy/lib/utils/stdout_helpers.c | 26 - user/mpy/lib/utils/sys_stdio_mphal.c | 163 - user/mpy/micropython | 1 + .../__pycache__/makeqstrdata.cpython-35.pyc | Bin 4914 -> 0 bytes .../__pycache__/makeqstrdata.cpython-36.pyc | Bin 4503 -> 0 bytes user/mpy/py/argcheck.c | 147 - user/mpy/py/asmarm.c | 368 - user/mpy/py/asmarm.h | 205 - user/mpy/py/asmbase.c | 102 - user/mpy/py/asmbase.h | 69 - user/mpy/py/asmthumb.c | 379 - user/mpy/py/asmthumb.h | 321 - user/mpy/py/asmx64.c | 632 - user/mpy/py/asmx64.h | 200 - user/mpy/py/asmx86.c | 511 - user/mpy/py/asmx86.h | 198 - user/mpy/py/asmxtensa.c | 174 - user/mpy/py/asmxtensa.h | 324 - user/mpy/py/bc.c | 417 - user/mpy/py/bc.h | 122 - user/mpy/py/bc0.h | 119 - user/mpy/py/binary.c | 392 - user/mpy/py/binary.h | 44 - user/mpy/py/builtin.h | 123 - user/mpy/py/builtinevex.c | 168 - user/mpy/py/builtinhelp.c | 180 - user/mpy/py/builtinimport.c | 475 - user/mpy/py/compile.c | 3522 - user/mpy/py/compile.h | 54 - user/mpy/py/emit.h | 286 - user/mpy/py/emitbc.c | 1076 - user/mpy/py/emitcommon.c | 77 - user/mpy/py/emitglue.c | 170 - user/mpy/py/emitglue.h | 77 - user/mpy/py/emitinlinethumb.c | 822 - user/mpy/py/emitinlinextensa.c | 345 - user/mpy/py/emitnative.c | 2350 - user/mpy/py/formatfloat.c | 428 - user/mpy/py/formatfloat.h | 35 - user/mpy/py/frozenmod.c | 156 - user/mpy/py/frozenmod.h | 41 - user/mpy/py/gc.c | 918 - user/mpy/py/gc.h | 67 - user/mpy/py/grammar.h | 357 - user/mpy/py/lexer.c | 763 - user/mpy/py/lexer.h | 195 - user/mpy/py/makeqstrdata.py | 158 - user/mpy/py/makeqstrdefs.py | 111 - user/mpy/py/makeversionhdr.py | 107 - user/mpy/py/malloc.c | 199 - user/mpy/py/map.c | 436 - user/mpy/py/misc.h | 226 - user/mpy/py/mkenv.mk | 70 - user/mpy/py/mkrules.mk | 175 - user/mpy/py/modarray.c | 43 - user/mpy/py/modbuiltins.c | 774 - user/mpy/py/modcmath.c | 166 - user/mpy/py/modcollections.c | 46 - user/mpy/py/modgc.c | 125 - user/mpy/py/modio.c | 215 - user/mpy/py/modmath.c | 275 - user/mpy/py/modmicropython.c | 188 - user/mpy/py/modstruct.c | 266 - user/mpy/py/modsys.c | 222 - user/mpy/py/modthread.c | 294 - user/mpy/py/moduerrno.c | 122 - user/mpy/py/mpconfig.h | 1266 - user/mpy/py/mperrno.h | 150 - user/mpy/py/mphal.h | 83 - user/mpy/py/mpprint.c | 555 - user/mpy/py/mpprint.h | 74 - user/mpy/py/mpstate.c | 33 - user/mpy/py/mpstate.h | 251 - user/mpy/py/mpthread.h | 61 - user/mpy/py/mpz.c | 1766 - user/mpy/py/mpz.h | 143 - user/mpy/py/nativeglue.c | 183 - user/mpy/py/nlr.h | 115 - user/mpy/py/nlrsetjmp.c | 42 - user/mpy/py/nlrthumb.c | 136 - user/mpy/py/nlrx64.c | 136 - user/mpy/py/nlrx86.c | 113 - user/mpy/py/nlrxtensa.c | 103 - user/mpy/py/obj.c | 513 - user/mpy/py/obj.h | 867 - user/mpy/py/objarray.c | 634 - user/mpy/py/objarray.h | 42 - user/mpy/py/objattrtuple.c | 95 - user/mpy/py/objbool.c | 89 - user/mpy/py/objboundmeth.c | 109 - user/mpy/py/objcell.c | 71 - user/mpy/py/objclosure.c | 97 - user/mpy/py/objcomplex.c | 256 - user/mpy/py/objdict.c | 615 - user/mpy/py/objenumerate.c | 92 - user/mpy/py/objexcept.c | 479 - user/mpy/py/objexcept.h | 40 - user/mpy/py/objfilter.c | 72 - user/mpy/py/objfloat.c | 314 - user/mpy/py/objfun.c | 573 - user/mpy/py/objfun.h | 44 - user/mpy/py/objgenerator.c | 243 - user/mpy/py/objgenerator.h | 34 - user/mpy/py/objgetitemiter.c | 77 - user/mpy/py/objint.c | 479 - user/mpy/py/objint.h | 66 - user/mpy/py/objint_longlong.c | 298 - user/mpy/py/objint_mpz.c | 438 - user/mpy/py/objlist.c | 533 - user/mpy/py/objlist.h | 38 - user/mpy/py/objmap.c | 73 - user/mpy/py/objmodule.c | 272 - user/mpy/py/objmodule.h | 37 - user/mpy/py/objnamedtuple.c | 165 - user/mpy/py/objnone.c | 53 - user/mpy/py/objobject.c | 81 - user/mpy/py/objpolyiter.c | 54 - user/mpy/py/objproperty.c | 108 - user/mpy/py/objrange.c | 205 - user/mpy/py/objreversed.c | 81 - user/mpy/py/objset.c | 609 - user/mpy/py/objsingleton.c | 57 - user/mpy/py/objslice.c | 103 - user/mpy/py/objstr.c | 2169 - user/mpy/py/objstr.h | 105 - user/mpy/py/objstringio.c | 269 - user/mpy/py/objstringio.h | 40 - user/mpy/py/objstrunicode.c | 314 - user/mpy/py/objtuple.c | 291 - user/mpy/py/objtuple.h | 64 - user/mpy/py/objtype.c | 1207 - user/mpy/py/objtype.h | 52 - user/mpy/py/objzip.c | 76 - user/mpy/py/opmethods.c | 52 - user/mpy/py/parse.c | 1084 - user/mpy/py/parse.h | 107 - user/mpy/py/parsenum.c | 306 - user/mpy/py/parsenum.h | 37 - user/mpy/py/parsenumbase.c | 71 - user/mpy/py/parsenumbase.h | 33 - user/mpy/py/persistentcode.c | 400 - user/mpy/py/persistentcode.h | 40 - user/mpy/py/py.mk | 324 - user/mpy/py/qstr.c | 321 - user/mpy/py/qstr.h | 79 - user/mpy/py/qstrdefs.h | 61 - user/mpy/py/reader.c | 135 - user/mpy/py/reader.h | 46 - user/mpy/py/repl.c | 278 - user/mpy/py/repl.h | 38 - user/mpy/py/ringbuf.h | 72 - user/mpy/py/runtime.c | 1444 - user/mpy/py/runtime.h | 181 - user/mpy/py/runtime0.h | 155 - user/mpy/py/runtime_utils.c | 50 - user/mpy/py/scheduler.c | 117 - user/mpy/py/scope.c | 150 - user/mpy/py/scope.h | 97 - user/mpy/py/sequence.c | 279 - user/mpy/py/showbc.c | 568 - user/mpy/py/smallint.c | 75 - user/mpy/py/smallint.h | 68 - user/mpy/py/stackctrl.c | 65 - user/mpy/py/stackctrl.h | 48 - user/mpy/py/stream.c | 567 - user/mpy/py/stream.h | 106 - user/mpy/py/unicode.c | 184 - user/mpy/py/unicode.h | 34 - user/mpy/py/vm.c | 1461 - user/mpy/py/vmentrytable.h | 118 - user/mpy/py/vstr.c | 276 - user/mpy/py/warning.c | 50 - user/mpy/tools/.gitattributes | 1 - user/mpy/tools/.gitignore | 8 - user/mpy/tools/bootstrap_upip.sh | 30 - user/mpy/tools/build-stm-latest.sh | 42 - user/mpy/tools/cc1 | 262 - user/mpy/tools/check_code_size.sh | 23 - user/mpy/tools/codestats.sh | 187 - user/mpy/tools/dfu.py | 121 - user/mpy/tools/file2h.py | 30 - user/mpy/tools/gen-changelog.sh | 12 - user/mpy/tools/gen-cpydiff.py | 226 - user/mpy/tools/gendoc.py | 528 - user/mpy/tools/insert-usb-ids.py | 34 - user/mpy/tools/make-frozen.py | 83 - user/mpy/tools/mpy-tool.py | 593 - user/mpy/tools/mpy_bin2res.py | 18 - user/mpy/tools/mpy_cross_all.py | 38 - user/mpy/tools/pyboard.py | 461 - user/mpy/tools/pydfu.py | 540 - user/mpy/tools/tinytest-codegen.py | 70 - user/mpy/tools/tinytest/README | 18 - user/mpy/tools/tinytest/tinytest.c | 474 - user/mpy/tools/tinytest/tinytest.h | 98 - user/mpy/tools/tinytest/tinytest_macros.h | 184 - user/mpy/tools/upip.py | 307 - user/mpy/tools/upip_utarfile.py | 94 - 1371 files changed, 4 insertions(+), 613851 deletions(-) create mode 100644 .gitmodules delete mode 100644 user/mpy/build/genhdr/mpversion.h delete mode 100644 user/mpy/build/genhdr/qstr.i.last delete mode 100644 user/mpy/build/genhdr/qstr.split delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr delete mode 100644 user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr delete mode 100644 user/mpy/build/genhdr/qstrdefs.collected.h delete mode 100644 user/mpy/build/genhdr/qstrdefs.collected.h.hash delete mode 100644 user/mpy/build/genhdr/qstrdefs.generated.h delete mode 100644 user/mpy/build/genhdr/qstrdefs.preprocessed.h delete mode 100644 user/mpy/extmod/crypto-algorithms/sha256.c delete mode 100644 user/mpy/extmod/crypto-algorithms/sha256.h delete mode 100644 user/mpy/extmod/lwip-include/arch/cc.h delete mode 100644 user/mpy/extmod/lwip-include/arch/perf.h delete mode 100644 user/mpy/extmod/lwip-include/lwipopts.h delete mode 100644 user/mpy/extmod/machine_i2c.c delete mode 100644 user/mpy/extmod/machine_i2c.h delete mode 100644 user/mpy/extmod/machine_mem.c delete mode 100644 user/mpy/extmod/machine_mem.h delete mode 100644 user/mpy/extmod/machine_pinbase.c delete mode 100644 user/mpy/extmod/machine_pinbase.h delete mode 100644 user/mpy/extmod/machine_pulse.c delete mode 100644 user/mpy/extmod/machine_pulse.h delete mode 100644 user/mpy/extmod/machine_signal.c delete mode 100644 user/mpy/extmod/machine_signal.h delete mode 100644 user/mpy/extmod/machine_spi.c delete mode 100644 user/mpy/extmod/machine_spi.h delete mode 100644 user/mpy/extmod/misc.h delete mode 100644 user/mpy/extmod/modbtree.c delete mode 100644 user/mpy/extmod/modframebuf.c delete mode 100644 user/mpy/extmod/modlwip.c delete mode 100644 user/mpy/extmod/modonewire.c delete mode 100644 user/mpy/extmod/modubinascii.c delete mode 100644 user/mpy/extmod/modubinascii.h delete mode 100644 user/mpy/extmod/moductypes.c delete mode 100644 user/mpy/extmod/moduhashlib.c delete mode 100644 user/mpy/extmod/moduheapq.c delete mode 100644 user/mpy/extmod/modujson.c delete mode 100644 user/mpy/extmod/modurandom.c delete mode 100644 user/mpy/extmod/modure.c delete mode 100644 user/mpy/extmod/moduselect.c delete mode 100644 user/mpy/extmod/modussl_axtls.c delete mode 100644 user/mpy/extmod/modussl_mbedtls.c delete mode 100644 user/mpy/extmod/modutimeq.c delete mode 100644 user/mpy/extmod/moduzlib.c delete mode 100644 user/mpy/extmod/modwebrepl.c delete mode 100644 user/mpy/extmod/modwebsocket.c delete mode 100644 user/mpy/extmod/modwebsocket.h delete mode 100644 user/mpy/extmod/re1.5/charclass.c delete mode 100644 user/mpy/extmod/re1.5/compilecode.c delete mode 100644 user/mpy/extmod/re1.5/dumpcode.c delete mode 100644 user/mpy/extmod/re1.5/re1.5.h delete mode 100644 user/mpy/extmod/re1.5/recursiveloop.c delete mode 100644 user/mpy/extmod/uos_dupterm.c delete mode 100644 user/mpy/extmod/utime_mphal.c delete mode 100644 user/mpy/extmod/utime_mphal.h delete mode 100644 user/mpy/extmod/uzlib/adler32.c delete mode 100644 user/mpy/extmod/uzlib/crc32.c delete mode 100644 user/mpy/extmod/uzlib/tinf.h delete mode 100644 user/mpy/extmod/uzlib/tinfgzip.c delete mode 100644 user/mpy/extmod/uzlib/tinflate.c delete mode 100644 user/mpy/extmod/uzlib/tinfzlib.c delete mode 100644 user/mpy/extmod/vfs.c delete mode 100644 user/mpy/extmod/vfs.h delete mode 100644 user/mpy/extmod/vfs_fat.c delete mode 100644 user/mpy/extmod/vfs_fat.h delete mode 100644 user/mpy/extmod/vfs_fat_diskio.c delete mode 100644 user/mpy/extmod/vfs_fat_file.c delete mode 100644 user/mpy/extmod/vfs_fat_misc.c delete mode 100644 user/mpy/extmod/vfs_reader.c delete mode 100644 user/mpy/extmod/virtpin.c delete mode 100644 user/mpy/extmod/virtpin.h delete mode 100644 user/mpy/lib/README.md delete mode 100644 user/mpy/lib/axtls/.gitignore delete mode 100644 user/mpy/lib/axtls/Makefile delete mode 100644 user/mpy/lib/axtls/README delete mode 100755 user/mpy/lib/axtls/axtlswrap/Makefile delete mode 100755 user/mpy/lib/axtls/axtlswrap/axtlswrap.c delete mode 100644 user/mpy/lib/axtls/bindings/Config.in delete mode 100644 user/mpy/lib/axtls/bindings/Makefile delete mode 100644 user/mpy/lib/axtls/bindings/README delete mode 100644 user/mpy/lib/axtls/bindings/csharp/Makefile delete mode 100644 user/mpy/lib/axtls/bindings/csharp/axTLS.cs delete mode 100755 user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl delete mode 100755 user/mpy/lib/axtls/bindings/generate_interface.pl delete mode 100644 user/mpy/lib/axtls/bindings/java/Makefile delete mode 100644 user/mpy/lib/axtls/bindings/java/SSL.java delete mode 100644 user/mpy/lib/axtls/bindings/java/SSLCTX.java delete mode 100644 user/mpy/lib/axtls/bindings/java/SSLClient.java delete mode 100644 user/mpy/lib/axtls/bindings/java/SSLReadHolder.java delete mode 100644 user/mpy/lib/axtls/bindings/java/SSLServer.java delete mode 100644 user/mpy/lib/axtls/bindings/java/SSLUtil.java delete mode 100644 user/mpy/lib/axtls/bindings/lua/Makefile delete mode 100644 user/mpy/lib/axtls/bindings/perl/Makefile delete mode 100644 user/mpy/lib/axtls/bindings/vbnet/Makefile delete mode 100644 user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb delete mode 100644 user/mpy/lib/axtls/config/Config.in delete mode 100755 user/mpy/lib/axtls/config/JMeter.jmx delete mode 100644 user/mpy/lib/axtls/config/Rules.mak delete mode 100755 user/mpy/lib/axtls/config/axhttpd.aip delete mode 100644 user/mpy/lib/axtls/config/axtls.RES delete mode 100644 user/mpy/lib/axtls/config/axtls.rc delete mode 100644 user/mpy/lib/axtls/config/linuxconfig delete mode 100644 user/mpy/lib/axtls/config/makefile.conf delete mode 100644 user/mpy/lib/axtls/config/makefile.dotnet.conf delete mode 100644 user/mpy/lib/axtls/config/makefile.java.conf delete mode 100644 user/mpy/lib/axtls/config/makefile.post delete mode 100644 user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt delete mode 100644 user/mpy/lib/axtls/config/scripts/config/Makefile delete mode 100644 user/mpy/lib/axtls/config/scripts/config/conf.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/confdata.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/expr.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/expr.h delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lkc.h delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lkc_proto.h delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/mconf.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/menu.c delete mode 100755 user/mpy/lib/axtls/config/scripts/config/mkconfigs delete mode 100644 user/mpy/lib/axtls/config/scripts/config/symbol.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/util.c delete mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.l delete mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped delete mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped delete mode 100644 user/mpy/lib/axtls/config/scripts/config/zconf.y delete mode 100644 user/mpy/lib/axtls/config/upyconfig delete mode 100644 user/mpy/lib/axtls/config/upyconfig.client delete mode 100644 user/mpy/lib/axtls/config/win32config delete mode 100644 user/mpy/lib/axtls/crypto/Makefile delete mode 100644 user/mpy/lib/axtls/crypto/aes.c delete mode 100644 user/mpy/lib/axtls/crypto/bigint.c delete mode 100644 user/mpy/lib/axtls/crypto/bigint.h delete mode 100644 user/mpy/lib/axtls/crypto/bigint_impl.h delete mode 100644 user/mpy/lib/axtls/crypto/crypto.h delete mode 100644 user/mpy/lib/axtls/crypto/crypto_misc.c delete mode 100644 user/mpy/lib/axtls/crypto/hmac.c delete mode 100644 user/mpy/lib/axtls/crypto/md5.c delete mode 100644 user/mpy/lib/axtls/crypto/os_int.h delete mode 100644 user/mpy/lib/axtls/crypto/rc4.c delete mode 100644 user/mpy/lib/axtls/crypto/rsa.c delete mode 100644 user/mpy/lib/axtls/crypto/sha1.c delete mode 100644 user/mpy/lib/axtls/crypto/sha256.c delete mode 100644 user/mpy/lib/axtls/crypto/sha384.c delete mode 100644 user/mpy/lib/axtls/crypto/sha512.c delete mode 100644 user/mpy/lib/axtls/docsrc/Makefile delete mode 100644 user/mpy/lib/axtls/docsrc/axTLS.dox delete mode 100644 user/mpy/lib/axtls/docsrc/doco_footer.html delete mode 100644 user/mpy/lib/axtls/docsrc/images/axolotl.jpg delete mode 100644 user/mpy/lib/axtls/docsrc/images/tsbasbw.gif delete mode 100644 user/mpy/lib/axtls/httpd/Config.in delete mode 100644 user/mpy/lib/axtls/httpd/Makefile delete mode 100644 user/mpy/lib/axtls/httpd/axhttp.h delete mode 100644 user/mpy/lib/axtls/httpd/axhttpd.c delete mode 100644 user/mpy/lib/axtls/httpd/htpasswd.c delete mode 100755 user/mpy/lib/axtls/httpd/kepler-1.1-snapshot-20070521-1825.tar.gz delete mode 100644 user/mpy/lib/axtls/httpd/kepler.patch delete mode 100644 user/mpy/lib/axtls/httpd/proc.c delete mode 100644 user/mpy/lib/axtls/httpd/tdate_parse.c delete mode 100644 user/mpy/lib/axtls/samples/Config.in delete mode 100644 user/mpy/lib/axtls/samples/Makefile delete mode 100644 user/mpy/lib/axtls/samples/c/Makefile delete mode 100644 user/mpy/lib/axtls/samples/c/axssl.c delete mode 100644 user/mpy/lib/axtls/samples/csharp/Makefile delete mode 100644 user/mpy/lib/axtls/samples/csharp/axssl.cs delete mode 100644 user/mpy/lib/axtls/samples/java/Makefile delete mode 100644 user/mpy/lib/axtls/samples/java/axssl.java delete mode 100644 user/mpy/lib/axtls/samples/java/manifest.mf delete mode 100644 user/mpy/lib/axtls/samples/lua/Makefile delete mode 100755 user/mpy/lib/axtls/samples/lua/axssl.lua delete mode 100644 user/mpy/lib/axtls/samples/perl/Makefile delete mode 100755 user/mpy/lib/axtls/samples/perl/axssl.pl delete mode 100644 user/mpy/lib/axtls/samples/vbnet/Makefile delete mode 100644 user/mpy/lib/axtls/samples/vbnet/axssl.vb delete mode 100644 user/mpy/lib/axtls/ssl/BigIntConfig.in delete mode 100644 user/mpy/lib/axtls/ssl/Config.in delete mode 100644 user/mpy/lib/axtls/ssl/Makefile delete mode 100644 user/mpy/lib/axtls/ssl/asn1.c delete mode 100644 user/mpy/lib/axtls/ssl/cert.h delete mode 100644 user/mpy/lib/axtls/ssl/crypto_misc.h delete mode 100644 user/mpy/lib/axtls/ssl/gen_cert.c delete mode 100644 user/mpy/lib/axtls/ssl/loader.c delete mode 100644 user/mpy/lib/axtls/ssl/openssl.c delete mode 100644 user/mpy/lib/axtls/ssl/os_port.c delete mode 120000 user/mpy/lib/axtls/ssl/os_port.h delete mode 100644 user/mpy/lib/axtls/ssl/os_port_micropython.h delete mode 100644 user/mpy/lib/axtls/ssl/p12.c delete mode 100644 user/mpy/lib/axtls/ssl/private_key.h delete mode 100644 user/mpy/lib/axtls/ssl/ssl.h delete mode 100644 user/mpy/lib/axtls/ssl/test/Makefile delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.ca_x509_sha256.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.encrypted.p8 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_1024 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_2048 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_4096 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.unencrypted.p8 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.withoutCA.p12 delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024_sha256.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024_sha384.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_1024_sha512.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_aes128.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_aes256.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_bad_after.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_bad_before.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_device.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/ca-bundle.crt delete mode 100644 user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt delete mode 100644 user/mpy/lib/axtls/ssl/test/comodo.sha384.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/deutsche_telecom.x509_ca delete mode 100644 user/mpy/lib/axtls/ssl/test/equifax.x509_ca delete mode 100755 user/mpy/lib/axtls/ssl/test/gnutls.cer delete mode 100755 user/mpy/lib/axtls/ssl/test/header_issue.dat delete mode 100755 user/mpy/lib/axtls/ssl/test/killgnutls.sh delete mode 100755 user/mpy/lib/axtls/ssl/test/killopenssl.sh delete mode 100755 user/mpy/lib/axtls/ssl/test/make_certs.sh delete mode 100644 user/mpy/lib/axtls/ssl/test/microsoft.x509_ca delete mode 100644 user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem delete mode 100755 user/mpy/lib/axtls/ssl/test/ms_iis.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/perf_bigint.c delete mode 100644 user/mpy/lib/axtls/ssl/test/qualityssl.com.der delete mode 100755 user/mpy/lib/axtls/ssl/test/socgen.cer delete mode 100644 user/mpy/lib/axtls/ssl/test/ssltest.c delete mode 100755 user/mpy/lib/axtls/ssl/test/test_axssl.sh delete mode 100644 user/mpy/lib/axtls/ssl/test/thawte.x509_ca delete mode 100644 user/mpy/lib/axtls/ssl/test/verisign.x509_ca.pem delete mode 100644 user/mpy/lib/axtls/ssl/test/verisign.x509_my_cert.pem delete mode 100755 user/mpy/lib/axtls/ssl/tls1.c delete mode 100755 user/mpy/lib/axtls/ssl/tls1.h delete mode 100644 user/mpy/lib/axtls/ssl/tls1_clnt.c delete mode 100644 user/mpy/lib/axtls/ssl/tls1_svr.c delete mode 100644 user/mpy/lib/axtls/ssl/x509.c delete mode 100644 user/mpy/lib/axtls/www/bin/.htaccess delete mode 100644 user/mpy/lib/axtls/www/favicon.ico delete mode 100755 user/mpy/lib/axtls/www/index.html delete mode 100644 user/mpy/lib/axtls/www/lua/download.lua delete mode 100644 user/mpy/lib/axtls/www/lua/env.lua delete mode 100644 user/mpy/lib/axtls/www/lua/overview.lp delete mode 100644 user/mpy/lib/axtls/www/lua/prepara_sql2.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_conc.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_cookies.lp delete mode 100644 user/mpy/lib/axtls/www/lua/test_cookies.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_err.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_fs.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_htk.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_lib.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_main.html delete mode 100644 user/mpy/lib/axtls/www/lua/test_main.lp delete mode 100644 user/mpy/lib/axtls/www/lua/test_main.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_session.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_sql.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_sql2.lua delete mode 100644 user/mpy/lib/axtls/www/lua/test_variables.lp delete mode 100644 user/mpy/lib/axtls/www/test_dir/bin/.htaccess delete mode 100644 user/mpy/lib/axtls/www/test_dir/no_http/.htaccess delete mode 100644 user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd delete mode 100644 user/mpy/lib/axtls/www/test_dir/no_http/index.html delete mode 100644 user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess delete mode 100644 user/mpy/lib/axtls/www/test_dir/no_ssl/index.html delete mode 100644 user/mpy/lib/berkeley-db-1.xx/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/Makefile delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/README delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys delete mode 120000 user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/README delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/btree.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/btree/extern.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/btree/tags delete mode 100644 user/mpy/lib/berkeley-db-1.xx/changelog delete mode 100644 user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/db/db.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/db/tags delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/hash.usenix.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/libtp.usenix.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/README delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/extern.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/page.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/hash/search.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/hash/tags delete mode 100644 user/mpy/lib/berkeley-db-1.xx/include/db.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/include/filevtable.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/include/mpool.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/include/tags delete mode 100644 user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/man/btree.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/man/hash.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/man/mpool.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/man/recno.3 delete mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/README delete mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp delete mode 120000 user/mpy/lib/berkeley-db-1.xx/mpool/tags delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/extern.h delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/recno/recno.h delete mode 120000 user/mpy/lib/berkeley-db-1.xx/recno/tags delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/Makefile delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/README delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/dbtest.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c delete mode 100644 user/mpy/lib/berkeley-db-1.xx/test/run.test delete mode 100644 user/mpy/lib/cmsis/inc/cmsis_armcc.h delete mode 100644 user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h delete mode 100644 user/mpy/lib/cmsis/inc/cmsis_gcc.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cm0.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cm0plus.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cm3.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cm4.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cm7.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cmFunc.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cmInstr.h delete mode 100644 user/mpy/lib/cmsis/inc/core_cmSimd.h delete mode 100644 user/mpy/lib/cmsis/inc/core_sc000.h delete mode 100644 user/mpy/lib/cmsis/inc/core_sc300.h delete mode 100644 user/mpy/lib/embed/abort_.c delete mode 100644 user/mpy/lib/libc/string0.c delete mode 100644 user/mpy/lib/libffi/.gitignore delete mode 100644 user/mpy/lib/libffi/.travis.yml delete mode 100644 user/mpy/lib/libffi/ChangeLog.libffi delete mode 100644 user/mpy/lib/libffi/ChangeLog.libffi-3.1 delete mode 100644 user/mpy/lib/libffi/ChangeLog.libgcj delete mode 100644 user/mpy/lib/libffi/ChangeLog.v1 delete mode 100644 user/mpy/lib/libffi/LICENSE delete mode 100644 user/mpy/lib/libffi/Makefile.am delete mode 100644 user/mpy/lib/libffi/README delete mode 100644 user/mpy/lib/libffi/acinclude.m4 delete mode 100755 user/mpy/lib/libffi/autogen.sh delete mode 100644 user/mpy/lib/libffi/configure.ac delete mode 100644 user/mpy/lib/libffi/configure.host delete mode 100644 user/mpy/lib/libffi/doc/libffi.texi delete mode 100644 user/mpy/lib/libffi/doc/version.texi delete mode 100644 user/mpy/lib/libffi/generate-darwin-source-and-headers.py delete mode 100644 user/mpy/lib/libffi/include/Makefile.am delete mode 100644 user/mpy/lib/libffi/include/ffi.h.in delete mode 100644 user/mpy/lib/libffi/include/ffi_cfi.h delete mode 100644 user/mpy/lib/libffi/include/ffi_common.h delete mode 100644 user/mpy/lib/libffi/libffi.pc.in delete mode 100644 user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj delete mode 100644 user/mpy/lib/libffi/libtool-version delete mode 100644 user/mpy/lib/libffi/m4/asmcfi.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_append_flag.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_configure_args.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_enable_builddir.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 delete mode 100644 user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 delete mode 100644 user/mpy/lib/libffi/man/Makefile.am delete mode 100644 user/mpy/lib/libffi/man/ffi.3 delete mode 100644 user/mpy/lib/libffi/man/ffi_call.3 delete mode 100644 user/mpy/lib/libffi/man/ffi_prep_cif.3 delete mode 100644 user/mpy/lib/libffi/man/ffi_prep_cif_var.3 delete mode 100755 user/mpy/lib/libffi/msvcc.sh delete mode 100644 user/mpy/lib/libffi/src/aarch64/ffi.c delete mode 100644 user/mpy/lib/libffi/src/aarch64/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/aarch64/internal.h delete mode 100644 user/mpy/lib/libffi/src/aarch64/sysv.S delete mode 100644 user/mpy/lib/libffi/src/alpha/ffi.c delete mode 100644 user/mpy/lib/libffi/src/alpha/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/alpha/internal.h delete mode 100644 user/mpy/lib/libffi/src/alpha/osf.S delete mode 100644 user/mpy/lib/libffi/src/arc/arcompact.S delete mode 100644 user/mpy/lib/libffi/src/arc/ffi.c delete mode 100644 user/mpy/lib/libffi/src/arc/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/arm/ffi.c delete mode 100644 user/mpy/lib/libffi/src/arm/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/arm/internal.h delete mode 100644 user/mpy/lib/libffi/src/arm/sysv.S delete mode 100644 user/mpy/lib/libffi/src/avr32/ffi.c delete mode 100644 user/mpy/lib/libffi/src/avr32/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/avr32/sysv.S delete mode 100644 user/mpy/lib/libffi/src/bfin/ffi.c delete mode 100644 user/mpy/lib/libffi/src/bfin/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/bfin/sysv.S delete mode 100644 user/mpy/lib/libffi/src/closures.c delete mode 100644 user/mpy/lib/libffi/src/cris/ffi.c delete mode 100644 user/mpy/lib/libffi/src/cris/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/cris/sysv.S delete mode 100644 user/mpy/lib/libffi/src/debug.c delete mode 100644 user/mpy/lib/libffi/src/dlmalloc.c delete mode 100644 user/mpy/lib/libffi/src/frv/eabi.S delete mode 100644 user/mpy/lib/libffi/src/frv/ffi.c delete mode 100644 user/mpy/lib/libffi/src/frv/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/ia64/ffi.c delete mode 100644 user/mpy/lib/libffi/src/ia64/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/ia64/ia64_flags.h delete mode 100644 user/mpy/lib/libffi/src/ia64/unix.S delete mode 100644 user/mpy/lib/libffi/src/java_raw_api.c delete mode 100644 user/mpy/lib/libffi/src/m32r/ffi.c delete mode 100644 user/mpy/lib/libffi/src/m32r/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/m32r/sysv.S delete mode 100644 user/mpy/lib/libffi/src/m68k/ffi.c delete mode 100644 user/mpy/lib/libffi/src/m68k/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/m68k/sysv.S delete mode 100644 user/mpy/lib/libffi/src/m88k/ffi.c delete mode 100644 user/mpy/lib/libffi/src/m88k/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/m88k/obsd.S delete mode 100644 user/mpy/lib/libffi/src/metag/ffi.c delete mode 100644 user/mpy/lib/libffi/src/metag/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/metag/sysv.S delete mode 100644 user/mpy/lib/libffi/src/microblaze/ffi.c delete mode 100644 user/mpy/lib/libffi/src/microblaze/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/microblaze/sysv.S delete mode 100644 user/mpy/lib/libffi/src/mips/ffi.c delete mode 100644 user/mpy/lib/libffi/src/mips/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/mips/n32.S delete mode 100644 user/mpy/lib/libffi/src/mips/o32.S delete mode 100644 user/mpy/lib/libffi/src/moxie/eabi.S delete mode 100644 user/mpy/lib/libffi/src/moxie/ffi.c delete mode 100644 user/mpy/lib/libffi/src/moxie/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/nios2/ffi.c delete mode 100644 user/mpy/lib/libffi/src/nios2/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/nios2/sysv.S delete mode 100644 user/mpy/lib/libffi/src/or1k/ffi.c delete mode 100644 user/mpy/lib/libffi/src/or1k/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/or1k/sysv.S delete mode 100644 user/mpy/lib/libffi/src/pa/ffi.c delete mode 100644 user/mpy/lib/libffi/src/pa/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/pa/hpux32.S delete mode 100644 user/mpy/lib/libffi/src/pa/linux.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/aix.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/aix_closure.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/asm.h delete mode 100644 user/mpy/lib/libffi/src/powerpc/darwin.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/darwin_closure.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/ffi.c delete mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_darwin.c delete mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_linux64.c delete mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h delete mode 100644 user/mpy/lib/libffi/src/powerpc/ffi_sysv.c delete mode 100644 user/mpy/lib/libffi/src/powerpc/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/powerpc/linux64.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/linux64_closure.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/ppc_closure.S delete mode 100644 user/mpy/lib/libffi/src/powerpc/sysv.S delete mode 100644 user/mpy/lib/libffi/src/prep_cif.c delete mode 100644 user/mpy/lib/libffi/src/raw_api.c delete mode 100644 user/mpy/lib/libffi/src/s390/ffi.c delete mode 100644 user/mpy/lib/libffi/src/s390/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/s390/internal.h delete mode 100644 user/mpy/lib/libffi/src/s390/sysv.S delete mode 100644 user/mpy/lib/libffi/src/sh/ffi.c delete mode 100644 user/mpy/lib/libffi/src/sh/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/sh/sysv.S delete mode 100644 user/mpy/lib/libffi/src/sh64/ffi.c delete mode 100644 user/mpy/lib/libffi/src/sh64/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/sh64/sysv.S delete mode 100644 user/mpy/lib/libffi/src/sparc/ffi.c delete mode 100644 user/mpy/lib/libffi/src/sparc/ffi64.c delete mode 100644 user/mpy/lib/libffi/src/sparc/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/sparc/internal.h delete mode 100644 user/mpy/lib/libffi/src/sparc/v8.S delete mode 100644 user/mpy/lib/libffi/src/sparc/v9.S delete mode 100644 user/mpy/lib/libffi/src/tile/ffi.c delete mode 100644 user/mpy/lib/libffi/src/tile/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/tile/tile.S delete mode 100644 user/mpy/lib/libffi/src/types.c delete mode 100644 user/mpy/lib/libffi/src/vax/elfbsd.S delete mode 100644 user/mpy/lib/libffi/src/vax/ffi.c delete mode 100644 user/mpy/lib/libffi/src/vax/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/x86/ffi.c delete mode 100644 user/mpy/lib/libffi/src/x86/ffi64.c delete mode 100644 user/mpy/lib/libffi/src/x86/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/x86/ffiw64.c delete mode 100644 user/mpy/lib/libffi/src/x86/internal.h delete mode 100644 user/mpy/lib/libffi/src/x86/internal64.h delete mode 100644 user/mpy/lib/libffi/src/x86/sysv.S delete mode 100644 user/mpy/lib/libffi/src/x86/unix64.S delete mode 100644 user/mpy/lib/libffi/src/x86/win64.S delete mode 100644 user/mpy/lib/libffi/src/xtensa/ffi.c delete mode 100644 user/mpy/lib/libffi/src/xtensa/ffitarget.h delete mode 100644 user/mpy/lib/libffi/src/xtensa/sysv.S delete mode 100644 user/mpy/lib/libffi/stamp-h.in delete mode 100644 user/mpy/lib/libffi/testsuite/Makefile.am delete mode 100644 user/mpy/lib/libffi/testsuite/config/default.exp delete mode 100644 user/mpy/lib/libffi/testsuite/lib/libffi.exp delete mode 100644 user/mpy/lib/libffi/testsuite/lib/target-libpath.exp delete mode 100644 user/mpy/lib/libffi/testsuite/lib/wrapper.exp delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/call.exp delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float4.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/float_va.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/huge_struct.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/negint.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/problem1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/promotion.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct4.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct5.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct6.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct7.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct8.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/struct9.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/closure1.c delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/go.exp delete mode 100644 user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h delete mode 100644 user/mpy/lib/libffi/texinfo.tex delete mode 100644 user/mpy/lib/libm/acoshf.c delete mode 100644 user/mpy/lib/libm/asinfacosf.c delete mode 100644 user/mpy/lib/libm/asinhf.c delete mode 100644 user/mpy/lib/libm/atan2f.c delete mode 100644 user/mpy/lib/libm/atanf.c delete mode 100644 user/mpy/lib/libm/atanhf.c delete mode 100644 user/mpy/lib/libm/ef_rem_pio2.c delete mode 100644 user/mpy/lib/libm/ef_sqrt.c delete mode 100644 user/mpy/lib/libm/erf_lgamma.c delete mode 100644 user/mpy/lib/libm/fdlibm.h delete mode 100644 user/mpy/lib/libm/fmodf.c delete mode 100644 user/mpy/lib/libm/kf_cos.c delete mode 100644 user/mpy/lib/libm/kf_rem_pio2.c delete mode 100644 user/mpy/lib/libm/kf_sin.c delete mode 100644 user/mpy/lib/libm/kf_tan.c delete mode 100644 user/mpy/lib/libm/libm.h delete mode 100644 user/mpy/lib/libm/log1pf.c delete mode 100644 user/mpy/lib/libm/math.c delete mode 100644 user/mpy/lib/libm/nearbyintf.c delete mode 100644 user/mpy/lib/libm/roundf.c delete mode 100644 user/mpy/lib/libm/sf_cos.c delete mode 100644 user/mpy/lib/libm/sf_erf.c delete mode 100644 user/mpy/lib/libm/sf_frexp.c delete mode 100644 user/mpy/lib/libm/sf_ldexp.c delete mode 100644 user/mpy/lib/libm/sf_modf.c delete mode 100644 user/mpy/lib/libm/sf_sin.c delete mode 100644 user/mpy/lib/libm/sf_tan.c delete mode 100644 user/mpy/lib/libm/thumb_vfp_sqrtf.c delete mode 100644 user/mpy/lib/libm/wf_lgamma.c delete mode 100644 user/mpy/lib/libm/wf_tgamma.c delete mode 100644 user/mpy/lib/libm_dbl/README delete mode 100644 user/mpy/lib/libm_dbl/__cos.c delete mode 100644 user/mpy/lib/libm_dbl/__expo2.c delete mode 100644 user/mpy/lib/libm_dbl/__fpclassify.c delete mode 100644 user/mpy/lib/libm_dbl/__rem_pio2.c delete mode 100644 user/mpy/lib/libm_dbl/__rem_pio2_large.c delete mode 100644 user/mpy/lib/libm_dbl/__signbit.c delete mode 100644 user/mpy/lib/libm_dbl/__sin.c delete mode 100644 user/mpy/lib/libm_dbl/__tan.c delete mode 100644 user/mpy/lib/libm_dbl/acos.c delete mode 100644 user/mpy/lib/libm_dbl/acosh.c delete mode 100644 user/mpy/lib/libm_dbl/asin.c delete mode 100644 user/mpy/lib/libm_dbl/asinh.c delete mode 100644 user/mpy/lib/libm_dbl/atan.c delete mode 100644 user/mpy/lib/libm_dbl/atan2.c delete mode 100644 user/mpy/lib/libm_dbl/atanh.c delete mode 100644 user/mpy/lib/libm_dbl/ceil.c delete mode 100644 user/mpy/lib/libm_dbl/cos.c delete mode 100644 user/mpy/lib/libm_dbl/cosh.c delete mode 100644 user/mpy/lib/libm_dbl/erf.c delete mode 100644 user/mpy/lib/libm_dbl/exp.c delete mode 100644 user/mpy/lib/libm_dbl/expm1.c delete mode 100644 user/mpy/lib/libm_dbl/floor.c delete mode 100644 user/mpy/lib/libm_dbl/fmod.c delete mode 100644 user/mpy/lib/libm_dbl/frexp.c delete mode 100644 user/mpy/lib/libm_dbl/ldexp.c delete mode 100644 user/mpy/lib/libm_dbl/lgamma.c delete mode 100644 user/mpy/lib/libm_dbl/libm.h delete mode 100644 user/mpy/lib/libm_dbl/log.c delete mode 100644 user/mpy/lib/libm_dbl/log10.c delete mode 100644 user/mpy/lib/libm_dbl/log1p.c delete mode 100644 user/mpy/lib/libm_dbl/modf.c delete mode 100644 user/mpy/lib/libm_dbl/nearbyint.c delete mode 100644 user/mpy/lib/libm_dbl/pow.c delete mode 100644 user/mpy/lib/libm_dbl/rint.c delete mode 100644 user/mpy/lib/libm_dbl/scalbn.c delete mode 100644 user/mpy/lib/libm_dbl/sin.c delete mode 100644 user/mpy/lib/libm_dbl/sinh.c delete mode 100644 user/mpy/lib/libm_dbl/sqrt.c delete mode 100644 user/mpy/lib/libm_dbl/tan.c delete mode 100644 user/mpy/lib/libm_dbl/tanh.c delete mode 100644 user/mpy/lib/libm_dbl/tgamma.c delete mode 100644 user/mpy/lib/libm_dbl/trunc.c delete mode 100644 user/mpy/lib/lwip/CHANGELOG delete mode 100644 user/mpy/lib/lwip/COPYING delete mode 100644 user/mpy/lib/lwip/FILES delete mode 100644 user/mpy/lib/lwip/README delete mode 100644 user/mpy/lib/lwip/UPGRADING delete mode 100644 user/mpy/lib/lwip/doc/FILES delete mode 100644 user/mpy/lib/lwip/doc/contrib.txt delete mode 100644 user/mpy/lib/lwip/doc/rawapi.txt delete mode 100644 user/mpy/lib/lwip/doc/savannah.txt delete mode 100644 user/mpy/lib/lwip/doc/snmp_agent.txt delete mode 100644 user/mpy/lib/lwip/doc/sys_arch.txt delete mode 100644 user/mpy/lib/lwip/src/FILES delete mode 100644 user/mpy/lib/lwip/src/api/api_lib.c delete mode 100644 user/mpy/lib/lwip/src/api/api_msg.c delete mode 100644 user/mpy/lib/lwip/src/api/err.c delete mode 100644 user/mpy/lib/lwip/src/api/netbuf.c delete mode 100644 user/mpy/lib/lwip/src/api/netdb.c delete mode 100644 user/mpy/lib/lwip/src/api/netifapi.c delete mode 100644 user/mpy/lib/lwip/src/api/sockets.c delete mode 100644 user/mpy/lib/lwip/src/api/tcpip.c delete mode 100644 user/mpy/lib/lwip/src/core/def.c delete mode 100644 user/mpy/lib/lwip/src/core/dhcp.c delete mode 100644 user/mpy/lib/lwip/src/core/dns.c delete mode 100644 user/mpy/lib/lwip/src/core/init.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/autoip.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/icmp.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/igmp.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/inet.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/ip.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/ip_addr.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv4/ip_frag.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv6/README delete mode 100644 user/mpy/lib/lwip/src/core/ipv6/icmp6.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv6/inet6.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv6/ip6.c delete mode 100644 user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c delete mode 100644 user/mpy/lib/lwip/src/core/mem.c delete mode 100644 user/mpy/lib/lwip/src/core/memp.c delete mode 100644 user/mpy/lib/lwip/src/core/netif.c delete mode 100644 user/mpy/lib/lwip/src/core/pbuf.c delete mode 100644 user/mpy/lib/lwip/src/core/raw.c delete mode 100644 user/mpy/lib/lwip/src/core/snmp/asn1_dec.c delete mode 100644 user/mpy/lib/lwip/src/core/snmp/asn1_enc.c delete mode 100644 user/mpy/lib/lwip/src/core/snmp/mib2.c delete mode 100644 user/mpy/lib/lwip/src/core/snmp/mib_structs.c delete mode 100644 user/mpy/lib/lwip/src/core/snmp/msg_in.c delete mode 100644 user/mpy/lib/lwip/src/core/snmp/msg_out.c delete mode 100644 user/mpy/lib/lwip/src/core/stats.c delete mode 100644 user/mpy/lib/lwip/src/core/sys.c delete mode 100644 user/mpy/lib/lwip/src/core/tcp.c delete mode 100644 user/mpy/lib/lwip/src/core/tcp_in.c delete mode 100644 user/mpy/lib/lwip/src/core/tcp_out.c delete mode 100644 user/mpy/lib/lwip/src/core/timers.c delete mode 100644 user/mpy/lib/lwip/src/core/udp.c delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h delete mode 100644 user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/api.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/api_msg.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/arch.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/debug.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/def.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/dhcp.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/dns.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/err.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/init.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/mem.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/memp.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/memp_std.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/netbuf.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/netdb.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/netif.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/netifapi.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/opt.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/pbuf.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/raw.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/sio.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp_msg.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/snmp_structs.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/sockets.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/stats.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/sys.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/tcp.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/tcp_impl.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/tcpip.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/timers.h delete mode 100644 user/mpy/lib/lwip/src/include/lwip/udp.h delete mode 100644 user/mpy/lib/lwip/src/include/netif/etharp.h delete mode 100644 user/mpy/lib/lwip/src/include/netif/ppp_oe.h delete mode 100644 user/mpy/lib/lwip/src/include/netif/slipif.h delete mode 100644 user/mpy/lib/lwip/src/include/posix/netdb.h delete mode 100644 user/mpy/lib/lwip/src/include/posix/sys/socket.h delete mode 100644 user/mpy/lib/lwip/src/netif/FILES delete mode 100644 user/mpy/lib/lwip/src/netif/etharp.c delete mode 100644 user/mpy/lib/lwip/src/netif/ethernetif.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/auth.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/auth.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/chap.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/chap.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/chpms.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/chpms.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/fsm.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/fsm.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/ipcp.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/ipcp.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/lcp.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/lcp.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/magic.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/magic.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/md5.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/md5.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/pap.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/pap.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/pppdebug.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/randm.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/randm.h delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/vj.c delete mode 100644 user/mpy/lib/lwip/src/netif/ppp/vj.h delete mode 100644 user/mpy/lib/lwip/src/netif/slipif.c delete mode 100644 user/mpy/lib/lwip/test/unit/core/test_mem.c delete mode 100644 user/mpy/lib/lwip/test/unit/core/test_mem.h delete mode 100644 user/mpy/lib/lwip/test/unit/etharp/test_etharp.c delete mode 100644 user/mpy/lib/lwip/test/unit/etharp/test_etharp.h delete mode 100644 user/mpy/lib/lwip/test/unit/lwip_check.h delete mode 100644 user/mpy/lib/lwip/test/unit/lwip_unittests.c delete mode 100644 user/mpy/lib/lwip/test/unit/lwipopts.h delete mode 100644 user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c delete mode 100644 user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h delete mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp.c delete mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp.h delete mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c delete mode 100644 user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h delete mode 100644 user/mpy/lib/lwip/test/unit/udp/test_udp.c delete mode 100644 user/mpy/lib/lwip/test/unit/udp/test_udp.h delete mode 100644 user/mpy/lib/memzip/README.md delete mode 100644 user/mpy/lib/memzip/import.c delete mode 100644 user/mpy/lib/memzip/lexermemzip.c delete mode 100755 user/mpy/lib/memzip/make-memzip.py delete mode 100644 user/mpy/lib/memzip/memzip.c delete mode 100644 user/mpy/lib/memzip/memzip.h delete mode 100644 user/mpy/lib/mp-readline/readline.c delete mode 100644 user/mpy/lib/mp-readline/readline.h delete mode 100644 user/mpy/lib/netutils/netutils.c delete mode 100644 user/mpy/lib/netutils/netutils.h delete mode 100644 user/mpy/lib/oofatfs/diskio.h delete mode 100644 user/mpy/lib/oofatfs/ff.c delete mode 100644 user/mpy/lib/oofatfs/ff.h delete mode 100644 user/mpy/lib/oofatfs/ffconf.h delete mode 100644 user/mpy/lib/oofatfs/option/ccsbcs.c delete mode 100644 user/mpy/lib/oofatfs/option/unicode.c delete mode 100644 user/mpy/lib/timeutils/timeutils.c delete mode 100644 user/mpy/lib/timeutils/timeutils.h delete mode 100644 user/mpy/lib/utils/interrupt_char.c delete mode 100644 user/mpy/lib/utils/interrupt_char.h delete mode 100644 user/mpy/lib/utils/printf.c delete mode 100644 user/mpy/lib/utils/pyexec.c delete mode 100644 user/mpy/lib/utils/pyexec.h delete mode 100644 user/mpy/lib/utils/stdout_helpers.c delete mode 100644 user/mpy/lib/utils/sys_stdio_mphal.c create mode 160000 user/mpy/micropython delete mode 100644 user/mpy/py/__pycache__/makeqstrdata.cpython-35.pyc delete mode 100644 user/mpy/py/__pycache__/makeqstrdata.cpython-36.pyc delete mode 100644 user/mpy/py/argcheck.c delete mode 100644 user/mpy/py/asmarm.c delete mode 100644 user/mpy/py/asmarm.h delete mode 100644 user/mpy/py/asmbase.c delete mode 100644 user/mpy/py/asmbase.h delete mode 100644 user/mpy/py/asmthumb.c delete mode 100644 user/mpy/py/asmthumb.h delete mode 100644 user/mpy/py/asmx64.c delete mode 100644 user/mpy/py/asmx64.h delete mode 100644 user/mpy/py/asmx86.c delete mode 100644 user/mpy/py/asmx86.h delete mode 100644 user/mpy/py/asmxtensa.c delete mode 100644 user/mpy/py/asmxtensa.h delete mode 100644 user/mpy/py/bc.c delete mode 100644 user/mpy/py/bc.h delete mode 100644 user/mpy/py/bc0.h delete mode 100644 user/mpy/py/binary.c delete mode 100644 user/mpy/py/binary.h delete mode 100644 user/mpy/py/builtin.h delete mode 100644 user/mpy/py/builtinevex.c delete mode 100644 user/mpy/py/builtinhelp.c delete mode 100644 user/mpy/py/builtinimport.c delete mode 100644 user/mpy/py/compile.c delete mode 100644 user/mpy/py/compile.h delete mode 100644 user/mpy/py/emit.h delete mode 100644 user/mpy/py/emitbc.c delete mode 100644 user/mpy/py/emitcommon.c delete mode 100644 user/mpy/py/emitglue.c delete mode 100644 user/mpy/py/emitglue.h delete mode 100644 user/mpy/py/emitinlinethumb.c delete mode 100644 user/mpy/py/emitinlinextensa.c delete mode 100644 user/mpy/py/emitnative.c delete mode 100644 user/mpy/py/formatfloat.c delete mode 100644 user/mpy/py/formatfloat.h delete mode 100644 user/mpy/py/frozenmod.c delete mode 100644 user/mpy/py/frozenmod.h delete mode 100644 user/mpy/py/gc.c delete mode 100644 user/mpy/py/gc.h delete mode 100644 user/mpy/py/grammar.h delete mode 100644 user/mpy/py/lexer.c delete mode 100644 user/mpy/py/lexer.h delete mode 100644 user/mpy/py/makeqstrdata.py delete mode 100644 user/mpy/py/makeqstrdefs.py delete mode 100644 user/mpy/py/makeversionhdr.py delete mode 100644 user/mpy/py/malloc.c delete mode 100644 user/mpy/py/map.c delete mode 100644 user/mpy/py/misc.h delete mode 100644 user/mpy/py/mkenv.mk delete mode 100644 user/mpy/py/mkrules.mk delete mode 100644 user/mpy/py/modarray.c delete mode 100644 user/mpy/py/modbuiltins.c delete mode 100644 user/mpy/py/modcmath.c delete mode 100644 user/mpy/py/modcollections.c delete mode 100644 user/mpy/py/modgc.c delete mode 100644 user/mpy/py/modio.c delete mode 100644 user/mpy/py/modmath.c delete mode 100644 user/mpy/py/modmicropython.c delete mode 100644 user/mpy/py/modstruct.c delete mode 100644 user/mpy/py/modsys.c delete mode 100644 user/mpy/py/modthread.c delete mode 100644 user/mpy/py/moduerrno.c delete mode 100644 user/mpy/py/mpconfig.h delete mode 100644 user/mpy/py/mperrno.h delete mode 100644 user/mpy/py/mphal.h delete mode 100644 user/mpy/py/mpprint.c delete mode 100644 user/mpy/py/mpprint.h delete mode 100644 user/mpy/py/mpstate.c delete mode 100644 user/mpy/py/mpstate.h delete mode 100644 user/mpy/py/mpthread.h delete mode 100644 user/mpy/py/mpz.c delete mode 100644 user/mpy/py/mpz.h delete mode 100644 user/mpy/py/nativeglue.c delete mode 100644 user/mpy/py/nlr.h delete mode 100644 user/mpy/py/nlrsetjmp.c delete mode 100644 user/mpy/py/nlrthumb.c delete mode 100644 user/mpy/py/nlrx64.c delete mode 100644 user/mpy/py/nlrx86.c delete mode 100644 user/mpy/py/nlrxtensa.c delete mode 100644 user/mpy/py/obj.c delete mode 100644 user/mpy/py/obj.h delete mode 100644 user/mpy/py/objarray.c delete mode 100644 user/mpy/py/objarray.h delete mode 100644 user/mpy/py/objattrtuple.c delete mode 100644 user/mpy/py/objbool.c delete mode 100644 user/mpy/py/objboundmeth.c delete mode 100644 user/mpy/py/objcell.c delete mode 100644 user/mpy/py/objclosure.c delete mode 100644 user/mpy/py/objcomplex.c delete mode 100644 user/mpy/py/objdict.c delete mode 100644 user/mpy/py/objenumerate.c delete mode 100644 user/mpy/py/objexcept.c delete mode 100644 user/mpy/py/objexcept.h delete mode 100644 user/mpy/py/objfilter.c delete mode 100644 user/mpy/py/objfloat.c delete mode 100644 user/mpy/py/objfun.c delete mode 100644 user/mpy/py/objfun.h delete mode 100644 user/mpy/py/objgenerator.c delete mode 100644 user/mpy/py/objgenerator.h delete mode 100644 user/mpy/py/objgetitemiter.c delete mode 100644 user/mpy/py/objint.c delete mode 100644 user/mpy/py/objint.h delete mode 100644 user/mpy/py/objint_longlong.c delete mode 100644 user/mpy/py/objint_mpz.c delete mode 100644 user/mpy/py/objlist.c delete mode 100644 user/mpy/py/objlist.h delete mode 100644 user/mpy/py/objmap.c delete mode 100644 user/mpy/py/objmodule.c delete mode 100644 user/mpy/py/objmodule.h delete mode 100644 user/mpy/py/objnamedtuple.c delete mode 100644 user/mpy/py/objnone.c delete mode 100644 user/mpy/py/objobject.c delete mode 100644 user/mpy/py/objpolyiter.c delete mode 100644 user/mpy/py/objproperty.c delete mode 100644 user/mpy/py/objrange.c delete mode 100644 user/mpy/py/objreversed.c delete mode 100644 user/mpy/py/objset.c delete mode 100644 user/mpy/py/objsingleton.c delete mode 100644 user/mpy/py/objslice.c delete mode 100644 user/mpy/py/objstr.c delete mode 100644 user/mpy/py/objstr.h delete mode 100644 user/mpy/py/objstringio.c delete mode 100644 user/mpy/py/objstringio.h delete mode 100644 user/mpy/py/objstrunicode.c delete mode 100644 user/mpy/py/objtuple.c delete mode 100644 user/mpy/py/objtuple.h delete mode 100644 user/mpy/py/objtype.c delete mode 100644 user/mpy/py/objtype.h delete mode 100644 user/mpy/py/objzip.c delete mode 100644 user/mpy/py/opmethods.c delete mode 100644 user/mpy/py/parse.c delete mode 100644 user/mpy/py/parse.h delete mode 100644 user/mpy/py/parsenum.c delete mode 100644 user/mpy/py/parsenum.h delete mode 100644 user/mpy/py/parsenumbase.c delete mode 100644 user/mpy/py/parsenumbase.h delete mode 100644 user/mpy/py/persistentcode.c delete mode 100644 user/mpy/py/persistentcode.h delete mode 100644 user/mpy/py/py.mk delete mode 100644 user/mpy/py/qstr.c delete mode 100644 user/mpy/py/qstr.h delete mode 100644 user/mpy/py/qstrdefs.h delete mode 100644 user/mpy/py/reader.c delete mode 100644 user/mpy/py/reader.h delete mode 100644 user/mpy/py/repl.c delete mode 100644 user/mpy/py/repl.h delete mode 100644 user/mpy/py/ringbuf.h delete mode 100644 user/mpy/py/runtime.c delete mode 100644 user/mpy/py/runtime.h delete mode 100644 user/mpy/py/runtime0.h delete mode 100644 user/mpy/py/runtime_utils.c delete mode 100644 user/mpy/py/scheduler.c delete mode 100644 user/mpy/py/scope.c delete mode 100644 user/mpy/py/scope.h delete mode 100644 user/mpy/py/sequence.c delete mode 100644 user/mpy/py/showbc.c delete mode 100644 user/mpy/py/smallint.c delete mode 100644 user/mpy/py/smallint.h delete mode 100644 user/mpy/py/stackctrl.c delete mode 100644 user/mpy/py/stackctrl.h delete mode 100644 user/mpy/py/stream.c delete mode 100644 user/mpy/py/stream.h delete mode 100644 user/mpy/py/unicode.c delete mode 100644 user/mpy/py/unicode.h delete mode 100644 user/mpy/py/vm.c delete mode 100644 user/mpy/py/vmentrytable.h delete mode 100644 user/mpy/py/vstr.c delete mode 100644 user/mpy/py/warning.c delete mode 100644 user/mpy/tools/.gitattributes delete mode 100644 user/mpy/tools/.gitignore delete mode 100755 user/mpy/tools/bootstrap_upip.sh delete mode 100755 user/mpy/tools/build-stm-latest.sh delete mode 100755 user/mpy/tools/cc1 delete mode 100755 user/mpy/tools/check_code_size.sh delete mode 100755 user/mpy/tools/codestats.sh delete mode 100755 user/mpy/tools/dfu.py delete mode 100644 user/mpy/tools/file2h.py delete mode 100755 user/mpy/tools/gen-changelog.sh delete mode 100644 user/mpy/tools/gen-cpydiff.py delete mode 100644 user/mpy/tools/gendoc.py delete mode 100644 user/mpy/tools/insert-usb-ids.py delete mode 100755 user/mpy/tools/make-frozen.py delete mode 100755 user/mpy/tools/mpy-tool.py delete mode 100755 user/mpy/tools/mpy_bin2res.py delete mode 100755 user/mpy/tools/mpy_cross_all.py delete mode 100755 user/mpy/tools/pyboard.py delete mode 100755 user/mpy/tools/pydfu.py delete mode 100755 user/mpy/tools/tinytest-codegen.py delete mode 100644 user/mpy/tools/tinytest/README delete mode 100644 user/mpy/tools/tinytest/tinytest.c delete mode 100644 user/mpy/tools/tinytest/tinytest.h delete mode 100644 user/mpy/tools/tinytest/tinytest_macros.h delete mode 100644 user/mpy/tools/upip.py delete mode 100644 user/mpy/tools/upip_utarfile.py diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ce29bcd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "user/mpy/micropython"] + path = user/mpy/micropython + url = git@github.com:micropython/micropython.git diff --git a/user/mpy/build/genhdr/mpversion.h b/user/mpy/build/genhdr/mpversion.h deleted file mode 100644 index 7b33029..0000000 --- a/user/mpy/build/genhdr/mpversion.h +++ /dev/null @@ -1,8 +0,0 @@ -// This file was generated by py/makeversionhdr.py -#define MICROPY_GIT_TAG "1b8e0d5-dirty" -#define MICROPY_GIT_HASH "1b8e0d5-dirty" -#define MICROPY_BUILD_DATE "2017-08-15" -#define MICROPY_VERSION_MAJOR (0) -#define MICROPY_VERSION_MINOR (0) -#define MICROPY_VERSION_MICRO (1) -#define MICROPY_VERSION_STRING "0.0.1" diff --git a/user/mpy/build/genhdr/qstr.i.last b/user/mpy/build/genhdr/qstr.i.last deleted file mode 100644 index b299947..0000000 --- a/user/mpy/build/genhdr/qstr.i.last +++ /dev/null @@ -1,286426 +0,0 @@ -# 1 "user/mpy/py/mpstate.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/mpstate.c" -# 27 "user/mpy/py/mpstate.c" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 28 "user/mpy/py/mpstate.c" 2 - - - - - -mp_state_ctx_t mp_state_ctx; -# 1 "user/mpy/py/malloc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/malloc.c" -# 27 "user/mpy/py/malloc.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/malloc.c" 2 -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 29 "user/mpy/py/malloc.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/malloc.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/malloc.c" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 33 "user/mpy/py/malloc.c" 2 -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 34 "user/mpy/py/malloc.c" 2 -# 46 "user/mpy/py/malloc.c" -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 47 "user/mpy/py/malloc.c" 2 -# 74 "user/mpy/py/malloc.c" -void *m_malloc(size_t num_bytes) { - void *ptr = gc_alloc((num_bytes), -# 75 "user/mpy/py/malloc.c" 3 4 - 0 -# 75 "user/mpy/py/malloc.c" - ); - if (ptr == -# 76 "user/mpy/py/malloc.c" 3 4 - ((void *)0) -# 76 "user/mpy/py/malloc.c" - && num_bytes != 0) { - return m_malloc_fail(num_bytes); - } - - - - - - (void)0; - return ptr; -} - -void *m_malloc_maybe(size_t num_bytes) { - void *ptr = gc_alloc((num_bytes), -# 89 "user/mpy/py/malloc.c" 3 4 - 0 -# 89 "user/mpy/py/malloc.c" - ); - - - - - - (void)0; - return ptr; -} -# 115 "user/mpy/py/malloc.c" -void *m_malloc0(size_t num_bytes) { - void *ptr = m_malloc(num_bytes); - if (ptr == -# 117 "user/mpy/py/malloc.c" 3 4 - ((void *)0) -# 117 "user/mpy/py/malloc.c" - && num_bytes != 0) { - return m_malloc_fail(num_bytes); - } - - - - - return ptr; -} - - - - -void *m_realloc(void *ptr, size_t new_num_bytes) { - - void *new_ptr = gc_realloc(ptr, new_num_bytes, -# 132 "user/mpy/py/malloc.c" 3 4 - 1 -# 132 "user/mpy/py/malloc.c" - ); - if (new_ptr == -# 133 "user/mpy/py/malloc.c" 3 4 - ((void *)0) -# 133 "user/mpy/py/malloc.c" - && new_num_bytes != 0) { - return m_malloc_fail(new_num_bytes); - } -# 147 "user/mpy/py/malloc.c" - (void)0; - return new_ptr; -} - - - - -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 154 "user/mpy/py/malloc.c" 3 4 - _Bool -# 154 "user/mpy/py/malloc.c" - allow_move) { - - void *new_ptr = gc_realloc(ptr, new_num_bytes, allow_move); -# 171 "user/mpy/py/malloc.c" - (void)0; - return new_ptr; -} - - - - -void m_free(void *ptr) { - - gc_free(ptr); - - - - (void)0; -} -# 1 "user/mpy/py/gc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/gc.c" -# 27 "user/mpy/py/gc.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/gc.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 35 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/gc.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/gc.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 32 "user/mpy/py/gc.c" 2 -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 33 "user/mpy/py/gc.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 35 "user/mpy/py/gc.c" 2 -# 106 "user/mpy/py/gc.c" -void gc_init(void *start, void *end) { - - end = (void*)((uintptr_t)end & (~(((4 * (sizeof(mp_uint_t)))) - 1))); - (void)0; - - - - - - - size_t total_byte_len = (byte*)end - (byte*)start; - - - - (mp_state_ctx.mem.gc_alloc_table_byte_len) = total_byte_len / (1 + (8) / 2 * ((4 * (sizeof(mp_uint_t))))); - - - (mp_state_ctx.mem.gc_alloc_table_start) = (byte*)start; - - - - - - - size_t gc_pool_block_len = (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); - (mp_state_ctx.mem.gc_pool_start) = (byte*)end - gc_pool_block_len * ((4 * (sizeof(mp_uint_t)))); - (mp_state_ctx.mem.gc_pool_end) = end; - - - - - - - memset((mp_state_ctx.mem.gc_alloc_table_start), 0, (mp_state_ctx.mem.gc_alloc_table_byte_len)); - - - - - - - - (mp_state_ctx.mem.gc_last_free_atb_index) = 0; - - - (mp_state_ctx.mem.gc_lock_depth) = 0; - - - (mp_state_ctx.mem.gc_auto_collect_enabled) = 1; -# 165 "user/mpy/py/gc.c" - (void)0; - (void)0; - - - - (void)0; -} - -void gc_lock(void) { - ; - (mp_state_ctx.mem.gc_lock_depth)++; - ; -} - -void gc_unlock(void) { - ; - (mp_state_ctx.mem.gc_lock_depth)--; - ; -} - - -# 185 "user/mpy/py/gc.c" 3 4 -_Bool -# 185 "user/mpy/py/gc.c" - gc_is_locked(void) { - return (mp_state_ctx.mem.gc_lock_depth) != 0; -} -# 214 "user/mpy/py/gc.c" -static void gc_drain_stack(void) { - while ((mp_state_ctx.mem.gc_sp) > (mp_state_ctx.mem.gc_stack)) { - - size_t block = *--(mp_state_ctx.mem.gc_sp); - - - size_t n_blocks = 0; - do { - n_blocks += 1; - } while ((((mp_state_ctx.mem.gc_alloc_table_start)[(block + n_blocks) / (4)] >> (2 * ((block + n_blocks) & ((4) - 1)))) & 3) == (2)); - - - void **ptrs = (void**)(((block) * ((4 * (sizeof(mp_uint_t)))) + (uintptr_t)(mp_state_ctx.mem.gc_pool_start))); - for (size_t i = n_blocks * ((4 * (sizeof(mp_uint_t)))) / sizeof(void*); i > 0; i--, ptrs++) { - void *ptr = *ptrs; - do { if (( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { size_t _block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); if ((((mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] >> (2 * ((_block) & ((4) - 1)))) & 3) == (1)) { (void)0; do { (mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] |= ((3) << (2 * ((_block) & ((4) - 1)))); } while (0); if ((mp_state_ctx.mem.gc_sp) < &(mp_state_ctx.mem.gc_stack)[(64)]) { *(mp_state_ctx.mem.gc_sp)++ = _block; } else { (mp_state_ctx.mem.gc_stack_overflow) = 1; } } } } while (0); - } - } -} - -static void gc_deal_with_stack_overflow(void) { - while ((mp_state_ctx.mem.gc_stack_overflow)) { - (mp_state_ctx.mem.gc_stack_overflow) = 0; - (mp_state_ctx.mem.gc_sp) = (mp_state_ctx.mem.gc_stack); - - - for (size_t block = 0; block < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); block++) { - - if ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (3)) { - *(mp_state_ctx.mem.gc_sp)++ = block; - gc_drain_stack(); - } - } - } -} - -static void gc_sweep(void) { - - - - - int free_tail = 0; - for (size_t block = 0; block < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); block++) { - switch ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3)) { - case (1): -# 281 "user/mpy/py/gc.c" - free_tail = 1; - (void)0; - - - - - - case (2): - if (free_tail) { - do { (mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] &= (~((3) << (2 * ((block) & ((4) - 1))))); } while (0); - } - break; - - case (3): - do { (mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] &= (~((2) << (2 * ((block) & ((4) - 1))))); } while (0); - free_tail = 0; - break; - } - } -} - -void gc_collect_start(void) { - ; - (mp_state_ctx.mem.gc_lock_depth)++; - - - - (mp_state_ctx.mem.gc_stack_overflow) = 0; - (mp_state_ctx.mem.gc_sp) = (mp_state_ctx.mem.gc_stack); - - - - void **ptrs = (void**)(void*)&mp_state_ctx; - gc_collect_root(ptrs, -# 314 "user/mpy/py/gc.c" 3 4 - __builtin_offsetof ( -# 314 "user/mpy/py/gc.c" - mp_state_ctx_t -# 314 "user/mpy/py/gc.c" 3 4 - , -# 314 "user/mpy/py/gc.c" - vm.qstr_last_chunk -# 314 "user/mpy/py/gc.c" 3 4 - ) -# 314 "user/mpy/py/gc.c" - / sizeof(void*)); -} - -void gc_collect_root(void **ptrs, size_t len) { - for (size_t i = 0; i < len; i++) { - void *ptr = ptrs[i]; - do { if (( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { size_t _block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); if ((((mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] >> (2 * ((_block) & ((4) - 1)))) & 3) == (1)) { (void)0; do { (mp_state_ctx.mem.gc_alloc_table_start)[(_block) / (4)] |= ((3) << (2 * ((_block) & ((4) - 1)))); } while (0); if ((mp_state_ctx.mem.gc_sp) < &(mp_state_ctx.mem.gc_stack)[(64)]) { *(mp_state_ctx.mem.gc_sp)++ = _block; } else { (mp_state_ctx.mem.gc_stack_overflow) = 1; } } } } while (0); - gc_drain_stack(); - } -} - -void gc_collect_end(void) { - gc_deal_with_stack_overflow(); - gc_sweep(); - (mp_state_ctx.mem.gc_last_free_atb_index) = 0; - (mp_state_ctx.mem.gc_lock_depth)--; - ; -} - -void gc_info(gc_info_t *info) { - ; - info->total = (mp_state_ctx.mem.gc_pool_end) - (mp_state_ctx.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; - -# 342 "user/mpy/py/gc.c" 3 4 - _Bool -# 342 "user/mpy/py/gc.c" - finish = -# 342 "user/mpy/py/gc.c" 3 4 - 0 -# 342 "user/mpy/py/gc.c" - ; - for (size_t block = 0, len = 0, len_free = 0; !finish;) { - size_t kind = (((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3); - switch (kind) { - case (0): - info->free += 1; - len_free += 1; - len = 0; - break; - - case (1): - info->used += 1; - len = 1; - break; - - case (2): - info->used += 1; - len += 1; - break; - - case (3): - - break; - } - - block++; - finish = (block == (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4)); - - if (!finish) { - kind = (((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3); - } - - if (finish || kind == (0) || kind == (1)) { - 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 == (1)) { - if (len_free > info->max_free) { - info->max_free = len_free; - } - len_free = 0; - } - } - } - - info->used *= ((4 * (sizeof(mp_uint_t)))); - info->free *= ((4 * (sizeof(mp_uint_t)))); - ; -} - -void *gc_alloc(size_t n_bytes, -# 397 "user/mpy/py/gc.c" 3 4 - _Bool -# 397 "user/mpy/py/gc.c" - has_finaliser) { - size_t n_blocks = ((n_bytes + ((4 * (sizeof(mp_uint_t)))) - 1) & (~(((4 * (sizeof(mp_uint_t)))) - 1))) / ((4 * (sizeof(mp_uint_t)))); - (void)0; - - - if (n_blocks == 0) { - return -# 403 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 403 "user/mpy/py/gc.c" - ; - } - - ; - - - if ((mp_state_ctx.mem.gc_lock_depth) > 0) { - ; - return -# 411 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 411 "user/mpy/py/gc.c" - ; - } - - size_t i; - size_t end_block; - size_t start_block; - size_t n_free = 0; - int collected = !(mp_state_ctx.mem.gc_auto_collect_enabled); -# 428 "user/mpy/py/gc.c" - for (;;) { - - - for (i = (mp_state_ctx.mem.gc_last_free_atb_index); i < (mp_state_ctx.mem.gc_alloc_table_byte_len); i++) { - byte a = (mp_state_ctx.mem.gc_alloc_table_start)[i]; - if ((((a) & (0x03)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 0; goto found; } } else { n_free = 0; } - if ((((a) & (0x0c)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 1; goto found; } } else { n_free = 0; } - if ((((a) & (0x30)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 2; goto found; } } else { n_free = 0; } - if ((((a) & (0xc0)) == 0)) { if (++n_free >= n_blocks) { i = i * (4) + 3; goto found; } } else { n_free = 0; } - } - - ; - - if (collected) { - return -# 442 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 442 "user/mpy/py/gc.c" - ; - } - (void)0; - gc_collect(); - collected = 1; - ; - } - - -found: - - end_block = i; - start_block = i - n_free + 1; - - - - - - - if (n_free == 1) { - (mp_state_ctx.mem.gc_last_free_atb_index) = (i + 1) / (4); - } - - - do { (mp_state_ctx.mem.gc_alloc_table_start)[(start_block) / (4)] |= ((1) << (2 * ((start_block) & ((4) - 1)))); } while (0); - - - - for (size_t bl = start_block + 1; bl <= end_block; bl++) { - do { (mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] |= ((2) << (2 * ((bl) & ((4) - 1)))); } while (0); - } - - - - void *ret_ptr = (void*)((mp_state_ctx.mem.gc_pool_start) + start_block * ((4 * (sizeof(mp_uint_t))))); - (void)0; - - - - - - ; - - - - memset((byte*)ret_ptr, 0, (end_block - start_block + 1) * ((4 * (sizeof(mp_uint_t))))); -# 507 "user/mpy/py/gc.c" - (void)has_finaliser; - - - - - - - return ret_ptr; -} -# 529 "user/mpy/py/gc.c" -void gc_free(void *ptr) { - ; - if ((mp_state_ctx.mem.gc_lock_depth) > 0) { - - ; - return; - } - - (void)0; - - if (ptr == -# 539 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 539 "user/mpy/py/gc.c" - ) { - ; - } else { - - -# 543 "user/mpy/py/gc.c" 3 - (( -# 543 "user/mpy/py/gc.c" - ( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) ) -# 543 "user/mpy/py/gc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/gc.c", 543, __func__, -# 543 "user/mpy/py/gc.c" - "VERIFY_PTR(ptr)" -# 543 "user/mpy/py/gc.c" 3 - )) -# 543 "user/mpy/py/gc.c" - ; - size_t block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); - -# 545 "user/mpy/py/gc.c" 3 - (( -# 545 "user/mpy/py/gc.c" - (((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (1) -# 545 "user/mpy/py/gc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/gc.c", 545, __func__, -# 545 "user/mpy/py/gc.c" - "ATB_GET_KIND(block) == AT_HEAD" -# 545 "user/mpy/py/gc.c" 3 - )) -# 545 "user/mpy/py/gc.c" - ; - - - - - - - if (block / (4) < (mp_state_ctx.mem.gc_last_free_atb_index)) { - (mp_state_ctx.mem.gc_last_free_atb_index) = block / (4); - } - - - do { - do { (mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] &= (~((3) << (2 * ((block) & ((4) - 1))))); } while (0); - block += 1; - } while ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (2)); - - ; - - - - - } -} - -size_t gc_nbytes(const void *ptr) { - ; - if (( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { - size_t block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); - if ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) == (1)) { - - size_t n_blocks = 0; - do { - n_blocks += 1; - } while ((((mp_state_ctx.mem.gc_alloc_table_start)[(block + n_blocks) / (4)] >> (2 * ((block + n_blocks) & ((4) - 1)))) & 3) == (2)); - ; - return n_blocks * ((4 * (sizeof(mp_uint_t)))); - } - } - - - ; - return 0; -} -# 619 "user/mpy/py/gc.c" -void *gc_realloc(void *ptr_in, size_t n_bytes, -# 619 "user/mpy/py/gc.c" 3 4 - _Bool -# 619 "user/mpy/py/gc.c" - allow_move) { - - if (ptr_in == -# 621 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 621 "user/mpy/py/gc.c" - ) { - return gc_alloc(n_bytes, -# 622 "user/mpy/py/gc.c" 3 4 - 0 -# 622 "user/mpy/py/gc.c" - ); - } - - - if (n_bytes == 0) { - gc_free(ptr_in); - return -# 628 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 628 "user/mpy/py/gc.c" - ; - } - - void *ptr = ptr_in; - - - if (!( ((uintptr_t)(ptr) & (((4 * (sizeof(mp_uint_t)))) - 1)) == 0 && ptr >= (void*)(mp_state_ctx.mem.gc_pool_start) && ptr < (void*)(mp_state_ctx.mem.gc_pool_end) )) { - return -# 635 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 635 "user/mpy/py/gc.c" - ; - } - - - size_t block = (((byte*)(ptr) - (mp_state_ctx.mem.gc_pool_start)) / ((4 * (sizeof(mp_uint_t))))); - - ; - - - if ((((mp_state_ctx.mem.gc_alloc_table_start)[(block) / (4)] >> (2 * ((block) & ((4) - 1)))) & 3) != (1)) { - ; - return -# 646 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 646 "user/mpy/py/gc.c" - ; - } - - if ((mp_state_ctx.mem.gc_lock_depth) > 0) { - ; - return -# 651 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 651 "user/mpy/py/gc.c" - ; - } - - - size_t new_blocks = (n_bytes + ((4 * (sizeof(mp_uint_t)))) - 1) / ((4 * (sizeof(mp_uint_t)))); - - - - - - - - size_t n_free = 0; - size_t n_blocks = 1; - size_t max_block = (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); - for (size_t bl = block + n_blocks; bl < max_block; bl++) { - byte block_type = (((mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] >> (2 * ((bl) & ((4) - 1)))) & 3); - if (block_type == (2)) { - n_blocks++; - continue; - } - if (block_type == (0)) { - n_free++; - if (n_blocks + n_free >= new_blocks) { - - break; - } - continue; - } - break; - } - - - if (new_blocks == n_blocks) { - ; - return ptr_in; - } - - - if (new_blocks < n_blocks) { - - for (size_t bl = block + new_blocks, count = n_blocks - new_blocks; count > 0; bl++, count--) { - do { (mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] &= (~((3) << (2 * ((bl) & ((4) - 1))))); } while (0); - } - - - if ((block + new_blocks) / (4) < (mp_state_ctx.mem.gc_last_free_atb_index)) { - (mp_state_ctx.mem.gc_last_free_atb_index) = (block + new_blocks) / (4); - } - - ; - - - - - - return ptr_in; - } - - - if (new_blocks <= n_blocks + n_free) { - - for (size_t bl = block + n_blocks; bl < block + new_blocks; bl++) { - -# 714 "user/mpy/py/gc.c" 3 - (( -# 714 "user/mpy/py/gc.c" - (((mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] >> (2 * ((bl) & ((4) - 1)))) & 3) == (0) -# 714 "user/mpy/py/gc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/gc.c", 714, __func__, -# 714 "user/mpy/py/gc.c" - "ATB_GET_KIND(bl) == AT_FREE" -# 714 "user/mpy/py/gc.c" 3 - )) -# 714 "user/mpy/py/gc.c" - ; - do { (mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] |= ((2) << (2 * ((bl) & ((4) - 1)))); } while (0); - } - - ; - - - - memset((byte*)ptr_in + n_blocks * ((4 * (sizeof(mp_uint_t)))), 0, (new_blocks - n_blocks) * ((4 * (sizeof(mp_uint_t))))); -# 732 "user/mpy/py/gc.c" - return ptr_in; - } - - - - - -# 738 "user/mpy/py/gc.c" 3 4 - _Bool -# 738 "user/mpy/py/gc.c" - ftb_state = -# 738 "user/mpy/py/gc.c" 3 4 - 0 -# 738 "user/mpy/py/gc.c" - ; - - - ; - - if (!allow_move) { - - return -# 745 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 745 "user/mpy/py/gc.c" - ; - } - - - void *ptr_out = gc_alloc(n_bytes, ftb_state); - - - if (ptr_out == -# 752 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 752 "user/mpy/py/gc.c" - ) { - return -# 753 "user/mpy/py/gc.c" 3 4 - ((void *)0) -# 753 "user/mpy/py/gc.c" - ; - } - - (void)0; - memcpy(ptr_out, ptr_in, n_blocks * ((4 * (sizeof(mp_uint_t))))); - gc_free(ptr_in); - return ptr_out; -} - - -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) { - ; - static const size_t DUMP_BYTES_PER_LINE = 64; - - - - mp_printf(&mp_plat_print, "GC memory layout; from %p:", (mp_state_ctx.mem.gc_pool_start)); - - for (size_t bl = 0; bl < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4); bl++) { - if (bl % DUMP_BYTES_PER_LINE == 0) { - - { - - size_t bl2 = bl; - while (bl2 < (mp_state_ctx.mem.gc_alloc_table_byte_len) * (4) && (((mp_state_ctx.mem.gc_alloc_table_start)[(bl2) / (4)] >> (2 * ((bl2) & ((4) - 1)))) & 3) == (0)) { - bl2++; - } - if (bl2 - bl >= 2 * DUMP_BYTES_PER_LINE) { - - 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_ctx.mem.gc_alloc_table_byte_len) * (4)) { - - break; - } - } - } - - - - mp_printf(&mp_plat_print, "\n%05x: ", (uint)((bl * ((4 * (sizeof(mp_uint_t))))) & (uint32_t)0xfffff)); - } - int c = ' '; - switch ((((mp_state_ctx.mem.gc_alloc_table_start)[(bl) / (4)] >> (2 * ((bl) & ((4) - 1)))) & 3)) { - case (0): c = '.'; break; -# 834 "user/mpy/py/gc.c" - case (1): { - void **ptr = (void**)((mp_state_ctx.mem.gc_pool_start) + bl * ((4 * (sizeof(mp_uint_t))))); - 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'; } -# 849 "user/mpy/py/gc.c" - else if (*ptr == &mp_type_fun_bc) { c = 'B'; } - else if (*ptr == &mp_type_module) { c = 'M'; } - else { - c = 'h'; -# 870 "user/mpy/py/gc.c" - } - break; - } - case (2): c = '='; break; - case (3): c = 'm'; break; - } - mp_printf(&mp_plat_print, "%c", c); - } - mp_print_str(&mp_plat_print, "\n"); - ; -} -# 1 "user/mpy/py/qstr.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/qstr.c" -# 27 "user/mpy/py/qstr.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/qstr.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/qstr.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 61 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 30 "user/mpy/py/qstr.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 32 "user/mpy/py/qstr.c" 2 - -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 34 "user/mpy/py/qstr.c" 2 -# 84 "user/mpy/py/qstr.c" -mp_uint_t qstr_compute_hash(const byte *data, size_t len) { - - mp_uint_t hash = 5381; - for (const byte *top = data + len; data < top; data++) { - hash = ((hash << 5) + hash) ^ (*data); - } - hash &= (0xff); - - if (hash == 0) { - hash++; - } - return hash; -} - -const qstr_pool_t mp_qstr_const_pool = { - -# 99 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 99 "user/mpy/py/qstr.c" - , - 0, - 10, - MP_QSTRnumber_of, - { - - - - - - }, -}; - - -extern const qstr_pool_t mp_qstr_frozen_const_pool; - - - - - -void qstr_init(void) { - (mp_state_ctx.vm.last_pool) = (qstr_pool_t*)&mp_qstr_frozen_const_pool; - (mp_state_ctx.vm.qstr_last_chunk) = -# 121 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 121 "user/mpy/py/qstr.c" - ; - - - - -} - -static const byte *find_qstr(qstr q) { - - for (qstr_pool_t *pool = (mp_state_ctx.vm.last_pool); pool != -# 130 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 130 "user/mpy/py/qstr.c" - ; pool = pool->prev) { - if (q >= pool->total_prev_len) { - return pool->qstrs[q - pool->total_prev_len]; - } - } - - - return 0; -} - - -static qstr qstr_add(const byte *q_ptr) { - (void)0; - - - if ((mp_state_ctx.vm.last_pool)->len >= (mp_state_ctx.vm.last_pool)->alloc) { - qstr_pool_t *pool = ((qstr_pool_t*)m_malloc_maybe(sizeof(qstr_pool_t) + sizeof(const char*) * ((mp_state_ctx.vm.last_pool)->alloc * 2))); - if (pool == -# 147 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 147 "user/mpy/py/qstr.c" - ) { - ; - m_malloc_fail((mp_state_ctx.vm.last_pool)->alloc * 2); - } - pool->prev = (mp_state_ctx.vm.last_pool); - pool->total_prev_len = (mp_state_ctx.vm.last_pool)->total_prev_len + (mp_state_ctx.vm.last_pool)->len; - pool->alloc = (mp_state_ctx.vm.last_pool)->alloc * 2; - pool->len = 0; - (mp_state_ctx.vm.last_pool) = pool; - (void)0; - } - - - (mp_state_ctx.vm.last_pool)->qstrs[(mp_state_ctx.vm.last_pool)->len++] = q_ptr; - - - return (mp_state_ctx.vm.last_pool)->total_prev_len + (mp_state_ctx.vm.last_pool)->len - 1; -} - -qstr qstr_find_strn(const char *str, size_t str_len) { - - mp_uint_t str_hash = qstr_compute_hash((const byte*)str, str_len); - - - for (qstr_pool_t *pool = (mp_state_ctx.vm.last_pool); pool != -# 171 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 171 "user/mpy/py/qstr.c" - ; pool = pool->prev) { - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - if (((mp_uint_t)(*q)[0]) == str_hash && ((*q)[(1)]) == str_len && memcmp(((*q) + (1) + (1)), str, str_len) == 0) { - return pool->total_prev_len + (q - pool->qstrs); - } - } - } - - - return 0; -} - -qstr qstr_from_str(const char *str) { - return qstr_from_strn(str, strlen(str)); -} - -qstr qstr_from_strn(const char *str, size_t len) { - -# 188 "user/mpy/py/qstr.c" 3 - (( -# 188 "user/mpy/py/qstr.c" - len < (1 << (8 * (1))) -# 188 "user/mpy/py/qstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/qstr.c", 188, __func__, -# 188 "user/mpy/py/qstr.c" - "len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))" -# 188 "user/mpy/py/qstr.c" 3 - )) -# 188 "user/mpy/py/qstr.c" - ; - ; - qstr q = qstr_find_strn(str, len); - if (q == 0) { - - - - size_t n_bytes = (1) + (1) + len + 1; - - if ((mp_state_ctx.vm.qstr_last_chunk) != -# 197 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 197 "user/mpy/py/qstr.c" - && (mp_state_ctx.vm.qstr_last_used) + n_bytes > (mp_state_ctx.vm.qstr_last_alloc)) { - - byte *new_p = ((byte*)(m_realloc_maybe(((mp_state_ctx.vm.qstr_last_chunk)), sizeof(byte) * ((mp_state_ctx.vm.qstr_last_alloc) + n_bytes), ( -# 199 "user/mpy/py/qstr.c" 3 4 - 0 -# 199 "user/mpy/py/qstr.c" - )))); - if (new_p == -# 200 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 200 "user/mpy/py/qstr.c" - ) { - - (void)((byte*)(m_realloc_maybe(((mp_state_ctx.vm.qstr_last_chunk)), sizeof(byte) * ((mp_state_ctx.vm.qstr_last_used)), ( -# 202 "user/mpy/py/qstr.c" 3 4 - 0 -# 202 "user/mpy/py/qstr.c" - )))); - (mp_state_ctx.vm.qstr_last_chunk) = -# 203 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 203 "user/mpy/py/qstr.c" - ; - } else { - - (mp_state_ctx.vm.qstr_last_alloc) += n_bytes; - } - } - - if ((mp_state_ctx.vm.qstr_last_chunk) == -# 210 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 210 "user/mpy/py/qstr.c" - ) { - - size_t al = n_bytes; - if (al < (128)) { - al = (128); - } - (mp_state_ctx.vm.qstr_last_chunk) = ((byte*)(m_malloc_maybe(sizeof(byte) * (al)))); - if ((mp_state_ctx.vm.qstr_last_chunk) == -# 217 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 217 "user/mpy/py/qstr.c" - ) { - - (mp_state_ctx.vm.qstr_last_chunk) = ((byte*)(m_malloc_maybe(sizeof(byte) * (n_bytes)))); - if ((mp_state_ctx.vm.qstr_last_chunk) == -# 220 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 220 "user/mpy/py/qstr.c" - ) { - ; - m_malloc_fail(n_bytes); - } - al = n_bytes; - } - (mp_state_ctx.vm.qstr_last_alloc) = al; - (mp_state_ctx.vm.qstr_last_used) = 0; - } - - - byte *q_ptr = (mp_state_ctx.vm.qstr_last_chunk) + (mp_state_ctx.vm.qstr_last_used); - (mp_state_ctx.vm.qstr_last_used) += n_bytes; - - - mp_uint_t hash = qstr_compute_hash((const byte*)str, len); - do { (q_ptr)[0] = (hash); } while (0); - do { (q_ptr)[(1)] = (len); } while (0); - memcpy(q_ptr + (1) + (1), str, len); - q_ptr[(1) + (1) + len] = '\0'; - q = qstr_add(q_ptr); - } - ; - return q; -} - -byte *qstr_build_start(size_t len, byte **q_ptr) { - -# 247 "user/mpy/py/qstr.c" 3 - (( -# 247 "user/mpy/py/qstr.c" - len < (1 << (8 * (1))) -# 247 "user/mpy/py/qstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/qstr.c", 247, __func__, -# 247 "user/mpy/py/qstr.c" - "len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))" -# 247 "user/mpy/py/qstr.c" 3 - )) -# 247 "user/mpy/py/qstr.c" - ; - *q_ptr = ((byte*)(m_malloc(sizeof(byte) * ((1) + (1) + len + 1)))); - do { (*q_ptr)[(1)] = (len); } while (0); - return ((*q_ptr) + (1) + (1)); -} - -qstr qstr_build_end(byte *q_ptr) { - ; - qstr q = qstr_find_strn((const char*)((q_ptr) + (1) + (1)), ((q_ptr)[(1)])); - if (q == 0) { - size_t len = ((q_ptr)[(1)]); - mp_uint_t hash = qstr_compute_hash(((q_ptr) + (1) + (1)), len); - do { (q_ptr)[0] = (hash); } while (0); - q_ptr[(1) + (1) + len] = '\0'; - q = qstr_add(q_ptr); - } else { - ((void)(((1) + (1) + ((q_ptr)[(1)]) + 1)), m_free(q_ptr)); - } - ; - return q; -} - -mp_uint_t qstr_hash(qstr q) { - return ((mp_uint_t)(find_qstr(q))[0]); -} - -size_t qstr_len(qstr q) { - const byte *qd = find_qstr(q); - return ((qd)[(1)]); -} - -const char *qstr_str(qstr q) { - const byte *qd = find_qstr(q); - return (const char*)((qd) + (1) + (1)); -} - -const byte *qstr_data(qstr q, size_t *len) { - const byte *qd = find_qstr(q); - *len = ((qd)[(1)]); - return ((qd) + (1) + (1)); -} - -void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, size_t *n_total_bytes) { - ; - *n_pool = 0; - *n_qstr = 0; - *n_str_data_bytes = 0; - *n_total_bytes = 0; - for (qstr_pool_t *pool = (mp_state_ctx.vm.last_pool); pool != -# 295 "user/mpy/py/qstr.c" 3 4 - ((void *)0) -# 295 "user/mpy/py/qstr.c" - && pool != &mp_qstr_frozen_const_pool; pool = pool->prev) { - *n_pool += 1; - *n_qstr += pool->len; - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - *n_str_data_bytes += ((1) + (1) + ((*q)[(1)]) + 1); - } - - *n_total_bytes += gc_nbytes(pool); - - - - } - *n_total_bytes += *n_str_data_bytes; - ; -} -# 1 "user/mpy/py/vstr.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/vstr.c" -# 27 "user/mpy/py/vstr.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/vstr.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 29 "user/mpy/py/vstr.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/vstr.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/vstr.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 33 "user/mpy/py/vstr.c" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/vstr.c" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 35 "user/mpy/py/vstr.c" 2 - - - - - -void vstr_init(vstr_t *vstr, size_t alloc) { - if (alloc < 1) { - alloc = 1; - } - vstr->alloc = alloc; - vstr->len = 0; - vstr->buf = ((char*)(m_malloc(sizeof(char) * (vstr->alloc)))); - vstr->fixed_buf = -# 47 "user/mpy/py/vstr.c" 3 4 - 0 -# 47 "user/mpy/py/vstr.c" - ; -} - - - -void vstr_init_len(vstr_t *vstr, size_t len) { - vstr_init(vstr, len + 1); - vstr->len = len; -} - -void vstr_init_fixed_buf(vstr_t *vstr, size_t alloc, char *buf) { - vstr->alloc = alloc; - vstr->len = 0; - vstr->buf = buf; - vstr->fixed_buf = -# 61 "user/mpy/py/vstr.c" 3 4 - 1 -# 61 "user/mpy/py/vstr.c" - ; -} - -void vstr_init_print(vstr_t *vstr, size_t alloc, mp_print_t *print) { - vstr_init(vstr, alloc); - print->data = vstr; - print->print_strn = (mp_print_strn_t)vstr_add_strn; -} - -void vstr_clear(vstr_t *vstr) { - if (!vstr->fixed_buf) { - ((void)(vstr->alloc), m_free(vstr->buf)); - } - vstr->buf = -# 74 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 74 "user/mpy/py/vstr.c" - ; -} - -vstr_t *vstr_new(size_t alloc) { - vstr_t *vstr = (((vstr_t*)(m_malloc(sizeof(vstr_t) * (1))))); - vstr_init(vstr, alloc); - return vstr; -} - -void vstr_free(vstr_t *vstr) { - if (vstr != -# 84 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 84 "user/mpy/py/vstr.c" - ) { - if (!vstr->fixed_buf) { - ((void)(vstr->alloc), m_free(vstr->buf)); - } - (((void)(1), m_free(vstr))); - } -} - - -char *vstr_extend(vstr_t *vstr, size_t size) { - if (vstr->fixed_buf) { - return -# 95 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 95 "user/mpy/py/vstr.c" - ; - } - char *new_buf = ((char*)(m_realloc((vstr->buf), sizeof(char) * (vstr->alloc + size)))); - char *p = new_buf + vstr->alloc; - vstr->alloc += size; - vstr->buf = new_buf; - return p; -} - -static -# 104 "user/mpy/py/vstr.c" 3 4 - _Bool -# 104 "user/mpy/py/vstr.c" - vstr_ensure_extra(vstr_t *vstr, size_t size) { - if (vstr->len + size > vstr->alloc) { - if (vstr->fixed_buf) { - return -# 107 "user/mpy/py/vstr.c" 3 4 - 0 -# 107 "user/mpy/py/vstr.c" - ; - } - size_t new_alloc = ((((vstr->len + size) + 16) & ((~0U) - 7)) + 8); - char *new_buf = ((char*)(m_realloc((vstr->buf), sizeof(char) * (new_alloc)))); - vstr->alloc = new_alloc; - vstr->buf = new_buf; - } - return -# 114 "user/mpy/py/vstr.c" 3 4 - 1 -# 114 "user/mpy/py/vstr.c" - ; -} - -void vstr_hint_size(vstr_t *vstr, size_t size) { - vstr_ensure_extra(vstr, size); -} - -char *vstr_add_len(vstr_t *vstr, size_t len) { - if (!vstr_ensure_extra(vstr, len)) { - return -# 123 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 123 "user/mpy/py/vstr.c" - ; - } - char *buf = vstr->buf + vstr->len; - vstr->len += len; - return buf; -} - - -char *vstr_null_terminated_str(vstr_t *vstr) { - - if (vstr->alloc == vstr->len) { - if (vstr_extend(vstr, 1) == -# 134 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 134 "user/mpy/py/vstr.c" - ) { - return -# 135 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 135 "user/mpy/py/vstr.c" - ; - } - } - vstr->buf[vstr->len] = '\0'; - return vstr->buf; -} - -void vstr_add_byte(vstr_t *vstr, byte b) { - byte *buf = (byte*)vstr_add_len(vstr, 1); - if (buf == -# 144 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 144 "user/mpy/py/vstr.c" - ) { - return; - } - buf[0] = b; -} - -void vstr_add_char(vstr_t *vstr, unichar c) { -# 187 "user/mpy/py/vstr.c" - vstr_add_byte(vstr, c); - -} - -void vstr_add_str(vstr_t *vstr, const char *str) { - vstr_add_strn(vstr, str, strlen(str)); -} - -void vstr_add_strn(vstr_t *vstr, const char *str, size_t len) { - if (!vstr_ensure_extra(vstr, len)) { - - - if (vstr->fixed_buf && vstr->len < vstr->alloc) { - len = vstr->alloc - vstr->len; - goto copy; - } - return; - } -copy: - memmove(vstr->buf + vstr->len, str, len); - vstr->len += len; -} - -static char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) { - size_t l = vstr->len; - if (byte_pos > l) { - byte_pos = l; - } - if (byte_len > 0) { - - if (!vstr_ensure_extra(vstr, byte_len)) { - return -# 218 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 218 "user/mpy/py/vstr.c" - ; - } - - memmove(vstr->buf + byte_pos + byte_len, vstr->buf + byte_pos, l - byte_pos); - - vstr->len += byte_len; - } - return vstr->buf + byte_pos; -} - -void vstr_ins_byte(vstr_t *vstr, size_t byte_pos, byte b) { - char *s = vstr_ins_blank_bytes(vstr, byte_pos, 1); - if (s != -# 230 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 230 "user/mpy/py/vstr.c" - ) { - *s = b; - } -} - -void vstr_ins_char(vstr_t *vstr, size_t char_pos, unichar chr) { - - char *s = vstr_ins_blank_bytes(vstr, char_pos, 1); - if (s != -# 238 "user/mpy/py/vstr.c" 3 4 - ((void *)0) -# 238 "user/mpy/py/vstr.c" - ) { - *s = chr; - } -} - -void vstr_cut_head_bytes(vstr_t *vstr, size_t bytes_to_cut) { - vstr_cut_out_bytes(vstr, 0, bytes_to_cut); -} - -void vstr_cut_tail_bytes(vstr_t *vstr, size_t len) { - if (len > vstr->len) { - vstr->len = 0; - } else { - vstr->len -= len; - } -} - -void vstr_cut_out_bytes(vstr_t *vstr, size_t byte_pos, size_t bytes_to_cut) { - if (byte_pos >= vstr->len) { - return; - } else if (byte_pos + bytes_to_cut >= vstr->len) { - vstr->len = byte_pos; - } else { - memmove(vstr->buf + byte_pos, vstr->buf + byte_pos + bytes_to_cut, vstr->len - byte_pos - bytes_to_cut); - vstr->len -= bytes_to_cut; - } -} - -void vstr_printf(vstr_t *vstr, const char *fmt, ...) { - va_list ap; - -# 268 "user/mpy/py/vstr.c" 3 4 - __builtin_va_start( -# 268 "user/mpy/py/vstr.c" - ap -# 268 "user/mpy/py/vstr.c" 3 4 - , -# 268 "user/mpy/py/vstr.c" - fmt -# 268 "user/mpy/py/vstr.c" 3 4 - ) -# 268 "user/mpy/py/vstr.c" - ; - vstr_vprintf(vstr, fmt, ap); - -# 270 "user/mpy/py/vstr.c" 3 4 - __builtin_va_end( -# 270 "user/mpy/py/vstr.c" - ap -# 270 "user/mpy/py/vstr.c" 3 4 - ) -# 270 "user/mpy/py/vstr.c" - ; -} - -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap) { - mp_print_t print = {vstr, (mp_print_strn_t)vstr_add_strn}; - mp_vprintf(&print, fmt, ap); -} -# 1 "user/mpy/py/mpprint.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/mpprint.c" -# 27 "user/mpy/py/mpprint.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/mpprint.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 29 "user/mpy/py/mpprint.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpprint.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 35 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 31 "user/mpy/py/mpprint.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 32 "user/mpy/py/mpprint.c" 2 - -# 1 "user/mpy/py/mphal.h" 1 -# 29 "user/mpy/py/mphal.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/mphal.h" 2 - - - - -# 1 "user/mpy/mphalport.h" 1 -# 35 "user/mpy/py/mphal.h" 2 - - - -int mp_hal_stdin_rx_chr(void); - - - - - - - -void mp_hal_stdout_tx_strn(const char *str, size_t len); - - - - - - - -void mp_hal_delay_ms(mp_uint_t ms); - - - -void mp_hal_delay_us(mp_uint_t us); - - - - - - - -mp_uint_t mp_hal_ticks_us(void); - - - -mp_uint_t mp_hal_ticks_cpu(void); -# 80 "user/mpy/py/mphal.h" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 29 "user/mpy/extmod/virtpin.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/extmod/virtpin.h" 2 - - - - - - - -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 81 "user/mpy/py/mphal.h" 2 -# 34 "user/mpy/py/mpprint.c" 2 - - -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 - - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 37 "user/mpy/py/mpprint.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 38 "user/mpy/py/mpprint.c" 2 - - - - - -static const char pad_spaces[] = " "; -static const char pad_zeroes[] = "0000000000000000"; - -static void plat_print_strn(void *env, const char *str, size_t len) { - (void)env; - printk(str);; -} - -const mp_print_t mp_plat_print = { -# 51 "user/mpy/py/mpprint.c" 3 4 - ((void *)0) -# 51 "user/mpy/py/mpprint.c" - , plat_print_strn}; - -int mp_print_str(const mp_print_t *print, const char *str) { - size_t len = strlen(str); - if (len) { - print->print_strn(print->data, str, len); - } - return len; -} - -int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) { - int left_pad = 0; - int right_pad = 0; - int pad = width - len; - int pad_size; - int total_chars_printed = 0; - const char *pad_chars; - - if (!fill || fill == ' ') { - pad_chars = pad_spaces; - pad_size = sizeof(pad_spaces) - 1; - } else if (fill == '0') { - pad_chars = pad_zeroes; - pad_size = sizeof(pad_zeroes) - 1; - } else { - - - pad_chars = &fill; - pad_size = 1; - } - - if (flags & (0x080)) { - left_pad = pad / 2; - right_pad = pad - left_pad; - } else if (flags & (0x001)) { - right_pad = pad; - } else { - left_pad = pad; - } - - if (left_pad > 0) { - total_chars_printed += left_pad; - while (left_pad > 0) { - int p = left_pad; - if (p > pad_size) { - p = pad_size; - } - print->print_strn(print->data, pad_chars, p); - left_pad -= p; - } - } - if (len) { - print->print_strn(print->data, str, len); - total_chars_printed += len; - } - if (right_pad > 0) { - total_chars_printed += right_pad; - while (right_pad > 0) { - int p = right_pad; - if (p > pad_size) { - p = pad_size; - } - print->print_strn(print->data, pad_chars, p); - right_pad -= p; - } - } - return total_chars_printed; -} -# 130 "user/mpy/py/mpprint.c" -static int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) { - char sign = 0; - if (sgn) { - if ((mp_int_t)x < 0) { - sign = '-'; - x = -x; - } else if (flags & (0x002)) { - sign = '+'; - } else if (flags & (0x004)) { - sign = ' '; - } - } - - char buf[(sizeof(mp_int_t) * 4)]; - char *b = buf + (sizeof(mp_int_t) * 4); - - if (x == 0) { - *(--b) = '0'; - } else { - do { - int c = x % base; - x /= base; - if (c >= 10) { - c += base_char - 10; - } else { - c += '0'; - } - *(--b) = c; - } while (b > buf && x != 0); - } -# 175 "user/mpy/py/mpprint.c" - int len = 0; - if (flags & (0x040)) { - if (sign) { - len += mp_print_strn(print, &sign, 1, flags, fill, 1); - width--; - } - - - - - - - - } else { - - - - - - - if (sign && b > buf) { - *(--b) = sign; - } - } - - len += mp_print_strn(print, b, buf + (sizeof(mp_int_t) * 4) - b, flags, fill, width); - return len; -} - -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) { - - - - -# 208 "user/mpy/py/mpprint.c" 3 - (( -# 208 "user/mpy/py/mpprint.c" - base == 2 || base == 8 || base == 10 || base == 16 -# 208 "user/mpy/py/mpprint.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/mpprint.c", 208, __func__, -# 208 "user/mpy/py/mpprint.c" - "base == 2 || base == 8 || base == 10 || base == 16" -# 208 "user/mpy/py/mpprint.c" 3 - )) -# 208 "user/mpy/py/mpprint.c" - ; - - if (!(MP_OBJ_IS_SMALL_INT(x) || (MP_OBJ_IS_OBJ(x) && (((mp_obj_base_t*)((void*)x))->type == (&mp_type_int))))) { - - - x = ((mp_obj_t)((((mp_uint_t)(mp_obj_get_int(x))) << 1) | 1)); - } - - if ((flags & ((0x001) | (0x080))) == 0 && fill == '0') { - if (prec > width) { - width = prec; - } - prec = 0; - } - char prefix_buf[4]; - char *prefix = prefix_buf; - - if (mp_obj_int_sign(x) >= 0) { - if (flags & (0x002)) { - *prefix++ = '+'; - } else if (flags & (0x004)) { - *prefix++ = ' '; - } - } - - if (flags & (0x010)) { - if (base == 2) { - *prefix++ = '0'; - *prefix++ = base_char + 'b' - 'a'; - } else if (base == 8) { - *prefix++ = '0'; - if (flags & (0x200)) { - *prefix++ = base_char + 'o' - 'a'; - } - } else if (base == 16) { - *prefix++ = '0'; - *prefix++ = base_char + 'x' - 'a'; - } - } - *prefix = '\0'; - int prefix_len = prefix - prefix_buf; - prefix = prefix_buf; - - char comma = '\0'; - if (flags & (0x020)) { - comma = ','; - } - - - - char stack_buf[sizeof(mp_int_t) * 4]; - char *buf = stack_buf; - size_t buf_size = sizeof(stack_buf); - size_t fmt_size = 0; - char *str; - - if (prec > 1) { - flags |= (0x040); - } - char sign = '\0'; - if (flags & (0x040)) { - - - str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, - x, base, -# 272 "user/mpy/py/mpprint.c" 3 4 - ((void *)0) -# 272 "user/mpy/py/mpprint.c" - , base_char, comma); - if (*str == '-') { - sign = *str++; - fmt_size--; - } - } else { - str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, - x, base, prefix, base_char, comma); - } - - int spaces_before = 0; - int spaces_after = 0; - - if (prec > 1) { - - - - - int prec_width = fmt_size; - if (prec_width < prec) { - prec_width = prec; - } - if (flags & (0x040)) { - if (sign) { - prec_width++; - } - prec_width += prefix_len; - } - if (prec_width < width) { - if (flags & (0x001)) { - spaces_after = width - prec_width; - } else { - spaces_before = width - prec_width; - } - } - fill = '0'; - flags &= ~(0x001); - } - - int len = 0; - if (spaces_before) { - len += mp_print_strn(print, "", 0, 0, ' ', spaces_before); - } - if (flags & (0x040)) { - - if (sign) { - len += mp_print_strn(print, &sign, 1, 0, 0, 1); - width--; - } - if (prefix_len) { - len += mp_print_strn(print, prefix, prefix_len, 0, 0, 1); - width -= prefix_len; - } - } - if (prec > 1) { - width = prec; - } - - len += mp_print_strn(print, str, fmt_size, flags, fill, width); - - if (spaces_after) { - len += mp_print_strn(print, "", 0, 0, ' ', spaces_after); - } - - if (buf != stack_buf) { - ((void)(buf_size), m_free(buf)); - } - return len; -} -# 380 "user/mpy/py/mpprint.c" -int mp_printf(const mp_print_t *print, const char *fmt, ...) { - va_list ap; - -# 382 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_start( -# 382 "user/mpy/py/mpprint.c" - ap -# 382 "user/mpy/py/mpprint.c" 3 4 - , -# 382 "user/mpy/py/mpprint.c" - fmt -# 382 "user/mpy/py/mpprint.c" 3 4 - ) -# 382 "user/mpy/py/mpprint.c" - ; - int ret = mp_vprintf(print, fmt, ap); - -# 384 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_end( -# 384 "user/mpy/py/mpprint.c" - ap -# 384 "user/mpy/py/mpprint.c" 3 4 - ) -# 384 "user/mpy/py/mpprint.c" - ; - return ret; -} - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) { - int chrs = 0; - for (;;) { - { - const char *f = fmt; - while (*f != '\0' && *f != '%') { - ++f; - } - if (f > fmt) { - print->print_strn(print->data, fmt, f - fmt); - chrs += f - fmt; - fmt = f; - } - } - - if (*fmt == '\0') { - break; - } - - - ++fmt; - - - int flags = 0; - char fill = ' '; - while (*fmt != '\0') { - if (*fmt == '-') flags |= (0x001); - else if (*fmt == '+') flags |= (0x002); - else if (*fmt == ' ') flags |= (0x004); - else if (*fmt == '!') flags |= (0x008); - else if (*fmt == '0') { - flags |= (0x040); - fill = '0'; - } else break; - ++fmt; - } - - - int width = 0; - for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { - width = width * 10 + *fmt - '0'; - } - - - int prec = -1; - if (*fmt == '.') { - ++fmt; - if (*fmt == '*') { - ++fmt; - prec = -# 437 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 437 "user/mpy/py/mpprint.c" - args -# 437 "user/mpy/py/mpprint.c" 3 4 - , -# 437 "user/mpy/py/mpprint.c" - int -# 437 "user/mpy/py/mpprint.c" 3 4 - ) -# 437 "user/mpy/py/mpprint.c" - ; - } else { - prec = 0; - for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { - prec = prec * 10 + *fmt - '0'; - } - } - if (prec < 0) { - prec = 0; - } - } - - - - if (*fmt == 'l') { - ++fmt; - - } - - if (*fmt == '\0') { - break; - } - - switch (*fmt) { - case 'b': - if ( -# 462 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 462 "user/mpy/py/mpprint.c" - args -# 462 "user/mpy/py/mpprint.c" 3 4 - , -# 462 "user/mpy/py/mpprint.c" - int -# 462 "user/mpy/py/mpprint.c" 3 4 - ) -# 462 "user/mpy/py/mpprint.c" - ) { - chrs += mp_print_strn(print, "true", 4, flags, fill, width); - } else { - chrs += mp_print_strn(print, "false", 5, flags, fill, width); - } - break; - case 'c': - { - char str = -# 470 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 470 "user/mpy/py/mpprint.c" - args -# 470 "user/mpy/py/mpprint.c" 3 4 - , -# 470 "user/mpy/py/mpprint.c" - int -# 470 "user/mpy/py/mpprint.c" 3 4 - ) -# 470 "user/mpy/py/mpprint.c" - ; - chrs += mp_print_strn(print, &str, 1, flags, fill, width); - break; - } - case 'q': - { - qstr qst = -# 476 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 476 "user/mpy/py/mpprint.c" - args -# 476 "user/mpy/py/mpprint.c" 3 4 - , -# 476 "user/mpy/py/mpprint.c" - qstr -# 476 "user/mpy/py/mpprint.c" 3 4 - ) -# 476 "user/mpy/py/mpprint.c" - ; - size_t len; - const char *str = (const char*)qstr_data(qst, &len); - if (prec < 0) { - prec = len; - } - chrs += mp_print_strn(print, str, prec, flags, fill, width); - break; - } - case 's': - { - const char *str = -# 487 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 487 "user/mpy/py/mpprint.c" - args -# 487 "user/mpy/py/mpprint.c" 3 4 - , -# 487 "user/mpy/py/mpprint.c" - const char* -# 487 "user/mpy/py/mpprint.c" 3 4 - ) -# 487 "user/mpy/py/mpprint.c" - ; - if (str) { - if (prec < 0) { - prec = strlen(str); - } - chrs += mp_print_strn(print, str, prec, flags, fill, width); - } else { - chrs += mp_print_strn(print, "(null)", 6, flags, fill, width); - } - break; - } - case 'u': - chrs += mp_print_int(print, -# 499 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 499 "user/mpy/py/mpprint.c" - args -# 499 "user/mpy/py/mpprint.c" 3 4 - , -# 499 "user/mpy/py/mpprint.c" - unsigned int -# 499 "user/mpy/py/mpprint.c" 3 4 - ) -# 499 "user/mpy/py/mpprint.c" - , 0, 10, 'a', flags, fill, width); - break; - case 'd': - chrs += mp_print_int(print, -# 502 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 502 "user/mpy/py/mpprint.c" - args -# 502 "user/mpy/py/mpprint.c" 3 4 - , -# 502 "user/mpy/py/mpprint.c" - int -# 502 "user/mpy/py/mpprint.c" 3 4 - ) -# 502 "user/mpy/py/mpprint.c" - , 1, 10, 'a', flags, fill, width); - break; - case 'x': - chrs += mp_print_int(print, -# 505 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 505 "user/mpy/py/mpprint.c" - args -# 505 "user/mpy/py/mpprint.c" 3 4 - , -# 505 "user/mpy/py/mpprint.c" - unsigned int -# 505 "user/mpy/py/mpprint.c" 3 4 - ) -# 505 "user/mpy/py/mpprint.c" - , 0, 16, 'a', flags, fill, width); - break; - case 'X': - chrs += mp_print_int(print, -# 508 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 508 "user/mpy/py/mpprint.c" - args -# 508 "user/mpy/py/mpprint.c" 3 4 - , -# 508 "user/mpy/py/mpprint.c" - unsigned int -# 508 "user/mpy/py/mpprint.c" 3 4 - ) -# 508 "user/mpy/py/mpprint.c" - , 0, 16, 'A', flags, fill, width); - break; - case 'p': - case 'P': - chrs += mp_print_int(print, -# 512 "user/mpy/py/mpprint.c" 3 4 - __builtin_va_arg( -# 512 "user/mpy/py/mpprint.c" - args -# 512 "user/mpy/py/mpprint.c" 3 4 - , -# 512 "user/mpy/py/mpprint.c" - unsigned int -# 512 "user/mpy/py/mpprint.c" 3 4 - ) -# 512 "user/mpy/py/mpprint.c" - , 0, 16, 'a', flags, fill, width); - break; -# 545 "user/mpy/py/mpprint.c" - default: - - -# 547 "user/mpy/py/mpprint.c" 3 - (( -# 547 "user/mpy/py/mpprint.c" - *fmt == '%' || !"unsupported fmt char" -# 547 "user/mpy/py/mpprint.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/mpprint.c", 547, __func__, -# 547 "user/mpy/py/mpprint.c" - "*fmt == '%' || !\"unsupported fmt char\"" -# 547 "user/mpy/py/mpprint.c" 3 - )) -# 547 "user/mpy/py/mpprint.c" - ; - print->print_strn(print->data, fmt, 1); - chrs += 1; - break; - } - ++fmt; - } - return chrs; -} -# 1 "user/mpy/py/unicode.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/unicode.c" -# 27 "user/mpy/py/unicode.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/unicode.c" 2 - -# 1 "user/mpy/py/unicode.h" 1 -# 29 "user/mpy/py/unicode.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/unicode.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/unicode.h" 2 - -mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); -# 30 "user/mpy/py/unicode.c" 2 -# 51 "user/mpy/py/unicode.c" -static const uint8_t attr[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, ((0x02) | (0x01)), ((0x02) | (0x01)), ((0x02) | (0x01)), ((0x02) | (0x01)), ((0x02) | (0x01)), 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - ((0x02) | (0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), - ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), - ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), - ((0x04) | (0x01) | (0x40)), ((0x04) | (0x01) | (0x40)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), - ((0x01)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01) | (0x40)), ((0x10) | (0x08) | (0x01)), - ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), - ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), - ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x10) | (0x08) | (0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), - ((0x01)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01) | (0x40)), ((0x20) | (0x08) | (0x01)), - ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), - ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), - ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x20) | (0x08) | (0x01)), ((0x01)), ((0x01)), ((0x01)), ((0x01)), 0 -}; - - -unichar utf8_get_char(const byte *s) { -# 84 "user/mpy/py/unicode.c" - return *s; - -} - - -const byte *utf8_next_char(const byte *s) { - - - - - - - - return s + 1; - -} - -mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr) { - mp_uint_t i = 0; - while (ptr > s) { - if (!(((*--ptr) & 0xC0) == 0x80)) { - i++; - } - } - - return i; -} - - -mp_uint_t unichar_charlen(const char *str, mp_uint_t len) { -# 123 "user/mpy/py/unicode.c" - return len; - -} - - - -# 128 "user/mpy/py/unicode.c" 3 4 -_Bool -# 128 "user/mpy/py/unicode.c" - unichar_isspace(unichar c) { - return c < 128 && (attr[c] & (0x02)) != 0; -} - - -# 132 "user/mpy/py/unicode.c" 3 4 -_Bool -# 132 "user/mpy/py/unicode.c" - unichar_isalpha(unichar c) { - return c < 128 && (attr[c] & (0x08)) != 0; -} - - - - - - - - -# 142 "user/mpy/py/unicode.c" 3 4 -_Bool -# 142 "user/mpy/py/unicode.c" - unichar_isdigit(unichar c) { - return c < 128 && (attr[c] & (0x04)) != 0; -} - - -# 146 "user/mpy/py/unicode.c" 3 4 -_Bool -# 146 "user/mpy/py/unicode.c" - unichar_isxdigit(unichar c) { - return c < 128 && (attr[c] & (0x40)) != 0; -} - - -# 150 "user/mpy/py/unicode.c" 3 4 -_Bool -# 150 "user/mpy/py/unicode.c" - unichar_isident(unichar c) { - return c < 128 && ((attr[c] & ((0x08) | (0x04))) != 0 || c == '_'); -} - - -# 154 "user/mpy/py/unicode.c" 3 4 -_Bool -# 154 "user/mpy/py/unicode.c" - unichar_isupper(unichar c) { - return c < 128 && (attr[c] & (0x10)) != 0; -} - - -# 158 "user/mpy/py/unicode.c" 3 4 -_Bool -# 158 "user/mpy/py/unicode.c" - unichar_islower(unichar c) { - return c < 128 && (attr[c] & (0x20)) != 0; -} - -unichar unichar_tolower(unichar c) { - if (unichar_isupper(c)) { - return c + 0x20; - } - return c; -} - -unichar unichar_toupper(unichar c) { - if (unichar_islower(c)) { - return c - 0x20; - } - return c; -} - -mp_uint_t unichar_xdigit_value(unichar c) { - - mp_uint_t n = c - '0'; - if (n > 9) { - n &= ~('a' - 'A'); - n -= ('A' - ('9' + 1)); - } - return n; -} -# 1 "user/mpy/py/mpz.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/mpz.c" -# 27 "user/mpy/py/mpz.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/mpz.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/mpz.c" 2 - -# 1 "user/mpy/py/mpz.h" 1 -# 29 "user/mpy/py/mpz.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpz.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpz.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 33 "user/mpy/py/mpz.h" 2 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 31 "user/mpy/py/mpz.c" 2 -# 1 "user/mpy/py/reader.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/reader.c" -# 27 "user/mpy/py/reader.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/reader.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/reader.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/reader.c" 2 -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 32 "user/mpy/py/reader.c" 2 -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" - -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 33 "user/mpy/py/reader.c" 2 - -typedef struct _mp_reader_mem_t { - size_t free_len; - const byte *beg; - const byte *cur; - const byte *end; -} mp_reader_mem_t; - -static mp_uint_t mp_reader_mem_readbyte(void *data) { - mp_reader_mem_t *reader = (mp_reader_mem_t*)data; - if (reader->cur < reader->end) { - return *reader->cur++; - } else { - return ((mp_uint_t)(-1)); - } -} - -static void mp_reader_mem_close(void *data) { - mp_reader_mem_t *reader = (mp_reader_mem_t*)data; - if (reader->free_len > 0) { - ((void)(reader->free_len), m_free((char*)reader->beg)); - } - (((void)(1), m_free(reader))); -} - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len) { - mp_reader_mem_t *rm = (((mp_reader_mem_t*)(m_malloc(sizeof(mp_reader_mem_t) * (1))))); - rm->free_len = free_len; - rm->beg = buf; - rm->cur = buf; - rm->end = buf + len; - reader->data = rm; - reader->readbyte = mp_reader_mem_readbyte; - reader->close = mp_reader_mem_close; -} -# 1 "user/mpy/py/lexer.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/lexer.c" -# 27 "user/mpy/py/lexer.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/lexer.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/lexer.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/lexer.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 32 "user/mpy/py/lexer.c" 2 -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 33 "user/mpy/py/lexer.c" 2 -# 1 "user/mpy/py/lexer.h" 1 -# 41 "user/mpy/py/lexer.h" -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 34 "user/mpy/py/lexer.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 35 "user/mpy/py/lexer.c" 2 -# 46 "user/mpy/py/lexer.c" -static -# 46 "user/mpy/py/lexer.c" 3 4 - _Bool -# 46 "user/mpy/py/lexer.c" - is_end(mp_lexer_t *lex) { - return lex->chr0 == ((unichar)((mp_uint_t)(-1))); -} - -static -# 50 "user/mpy/py/lexer.c" 3 4 - _Bool -# 50 "user/mpy/py/lexer.c" - is_physical_newline(mp_lexer_t *lex) { - return lex->chr0 == '\n'; -} - -static -# 54 "user/mpy/py/lexer.c" 3 4 - _Bool -# 54 "user/mpy/py/lexer.c" - is_char(mp_lexer_t *lex, byte c) { - return lex->chr0 == c; -} - -static -# 58 "user/mpy/py/lexer.c" 3 4 - _Bool -# 58 "user/mpy/py/lexer.c" - is_char_or(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr0 == c1 || lex->chr0 == c2; -} - -static -# 62 "user/mpy/py/lexer.c" 3 4 - _Bool -# 62 "user/mpy/py/lexer.c" - is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) { - return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3; -} - -static -# 66 "user/mpy/py/lexer.c" 3 4 - _Bool -# 66 "user/mpy/py/lexer.c" - is_char_following(mp_lexer_t *lex, byte c) { - return lex->chr1 == c; -} - -static -# 70 "user/mpy/py/lexer.c" 3 4 - _Bool -# 70 "user/mpy/py/lexer.c" - is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr1 == c1 || lex->chr1 == c2; -} - -static -# 74 "user/mpy/py/lexer.c" 3 4 - _Bool -# 74 "user/mpy/py/lexer.c" - is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr2 == c1 || lex->chr2 == c2; -} - -static -# 78 "user/mpy/py/lexer.c" 3 4 - _Bool -# 78 "user/mpy/py/lexer.c" - is_char_and(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr0 == c1 && lex->chr1 == c2; -} - -static -# 82 "user/mpy/py/lexer.c" 3 4 - _Bool -# 82 "user/mpy/py/lexer.c" - is_whitespace(mp_lexer_t *lex) { - return unichar_isspace(lex->chr0); -} - -static -# 86 "user/mpy/py/lexer.c" 3 4 - _Bool -# 86 "user/mpy/py/lexer.c" - is_letter(mp_lexer_t *lex) { - return unichar_isalpha(lex->chr0); -} - -static -# 90 "user/mpy/py/lexer.c" 3 4 - _Bool -# 90 "user/mpy/py/lexer.c" - is_digit(mp_lexer_t *lex) { - return unichar_isdigit(lex->chr0); -} - -static -# 94 "user/mpy/py/lexer.c" 3 4 - _Bool -# 94 "user/mpy/py/lexer.c" - is_following_digit(mp_lexer_t *lex) { - return unichar_isdigit(lex->chr1); -} - -static -# 98 "user/mpy/py/lexer.c" 3 4 - _Bool -# 98 "user/mpy/py/lexer.c" - is_following_base_char(mp_lexer_t *lex) { - const unichar chr1 = lex->chr1 | 0x20; - return chr1 == 'b' || chr1 == 'o' || chr1 == 'x'; -} - -static -# 103 "user/mpy/py/lexer.c" 3 4 - _Bool -# 103 "user/mpy/py/lexer.c" - is_following_odigit(mp_lexer_t *lex) { - return lex->chr1 >= '0' && lex->chr1 <= '7'; -} - -static -# 107 "user/mpy/py/lexer.c" 3 4 - _Bool -# 107 "user/mpy/py/lexer.c" - is_string_or_bytes(mp_lexer_t *lex) { - return is_char_or(lex, '\'', '\"') - || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"')) - || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r')) - && is_char_following_following_or(lex, '\'', '\"')); -} - - -static -# 115 "user/mpy/py/lexer.c" 3 4 - _Bool -# 115 "user/mpy/py/lexer.c" - is_head_of_identifier(mp_lexer_t *lex) { - return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80; -} - -static -# 119 "user/mpy/py/lexer.c" 3 4 - _Bool -# 119 "user/mpy/py/lexer.c" - is_tail_of_identifier(mp_lexer_t *lex) { - return is_head_of_identifier(lex) || is_digit(lex); -} - -static void next_char(mp_lexer_t *lex) { - if (lex->chr0 == '\n') { - - ++lex->line; - lex->column = 1; - } else if (lex->chr0 == '\t') { - - lex->column = (((lex->column - 1 + (8)) / (8)) * (8)) + 1; - } else { - - ++lex->column; - } - - lex->chr0 = lex->chr1; - lex->chr1 = lex->chr2; - lex->chr2 = lex->reader.readbyte(lex->reader.data); - - if (lex->chr1 == '\r') { - - lex->chr1 = '\n'; - if (lex->chr2 == '\n') { - - lex->chr2 = lex->reader.readbyte(lex->reader.data); - } - } - - - if (lex->chr2 == ((unichar)((mp_uint_t)(-1))) && lex->chr1 != ((unichar)((mp_uint_t)(-1))) && lex->chr1 != '\n') { - lex->chr2 = '\n'; - } -} - -static void indent_push(mp_lexer_t *lex, size_t indent) { - if (lex->num_indent_level >= lex->alloc_indent_level) { - lex->indent_level = ((uint16_t*)(m_realloc((lex->indent_level), sizeof(uint16_t) * (lex->alloc_indent_level + (8))))); - lex->alloc_indent_level += (8); - } - lex->indent_level[lex->num_indent_level++] = indent; -} - -static size_t indent_top(mp_lexer_t *lex) { - return lex->indent_level[lex->num_indent_level - 1]; -} - -static void indent_pop(mp_lexer_t *lex) { - lex->num_indent_level -= 1; -} - - - - - - - -static const char *const tok_enc = - "()[]{},:;@~" - "e=c>e=" - "*e=c*e=" - "+e=" - "-e=e>" - "&e=" - "|e=" - "/e=c/e=" - "%e=" - "^e=" - "=e=" - "!."; - - -static const uint8_t tok_enc_kind[] = { - MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, MP_TOKEN_DEL_COLON, MP_TOKEN_DEL_SEMICOLON, MP_TOKEN_DEL_AT, MP_TOKEN_OP_TILDE, - - MP_TOKEN_OP_LESS, MP_TOKEN_OP_LESS_EQUAL, MP_TOKEN_OP_DBL_LESS, MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_OP_MORE, MP_TOKEN_OP_MORE_EQUAL, MP_TOKEN_OP_DBL_MORE, MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_OP_STAR, MP_TOKEN_DEL_STAR_EQUAL, MP_TOKEN_OP_DBL_STAR, MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_OP_PLUS, MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_OP_MINUS, MP_TOKEN_DEL_MINUS_EQUAL, MP_TOKEN_DEL_MINUS_MORE, - MP_TOKEN_OP_AMPERSAND, MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_OP_PIPE, MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_OP_SLASH, MP_TOKEN_DEL_SLASH_EQUAL, MP_TOKEN_OP_DBL_SLASH, MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_OP_PERCENT, MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_OP_CARET, MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_EQUAL, MP_TOKEN_OP_DBL_EQUAL, -}; - - - -static const char *const tok_kw[] = { - "False", - "None", - "True", - "__debug__", - "and", - "as", - "assert", - - - - - "break", - "class", - "continue", - "def", - "del", - "elif", - "else", - "except", - "finally", - "for", - "from", - "global", - "if", - "import", - "in", - "is", - "lambda", - "nonlocal", - "not", - "or", - "pass", - "raise", - "return", - "try", - "while", - "with", - "yield", -}; - - - - -static -# 258 "user/mpy/py/lexer.c" 3 4 - _Bool -# 258 "user/mpy/py/lexer.c" - get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) { - mp_uint_t num = 0; - while (num_digits-- != 0) { - next_char(lex); - unichar c = ((lex)->chr0); - if (!unichar_isxdigit(c)) { - return -# 264 "user/mpy/py/lexer.c" 3 4 - 0 -# 264 "user/mpy/py/lexer.c" - ; - } - num = (num << 4) + unichar_xdigit_value(c); - } - *result = num; - return -# 269 "user/mpy/py/lexer.c" 3 4 - 1 -# 269 "user/mpy/py/lexer.c" - ; -} - -static void parse_string_literal(mp_lexer_t *lex, -# 272 "user/mpy/py/lexer.c" 3 4 - _Bool -# 272 "user/mpy/py/lexer.c" - is_raw) { - - char quote_char = '\''; - if (is_char(lex, '\"')) { - quote_char = '\"'; - } - next_char(lex); - - - size_t num_quotes; - if (is_char_and(lex, quote_char, quote_char)) { - - next_char(lex); - next_char(lex); - num_quotes = 3; - } else { - - num_quotes = 1; - } - - size_t n_closing = 0; - while (!is_end(lex) && (num_quotes > 1 || !is_char(lex, '\n')) && n_closing < num_quotes) { - if (is_char(lex, quote_char)) { - n_closing += 1; - vstr_add_char(&lex->vstr, ((lex)->chr0)); - } else { - n_closing = 0; - if (is_char(lex, '\\')) { - next_char(lex); - unichar c = ((lex)->chr0); - if (is_raw) { - - vstr_add_char(&lex->vstr, '\\'); - } else { - switch (c) { - - - case '\n': c = ((unichar)((mp_uint_t)(-1))); break; - case '\\': break; - case '\'': break; - case '"': break; - case 'a': c = 0x07; break; - case 'b': c = 0x08; break; - case 't': c = 0x09; break; - case 'n': c = 0x0a; break; - case 'v': c = 0x0b; break; - case 'f': c = 0x0c; break; - case 'r': c = 0x0d; break; - case 'u': - case 'U': - if (lex->tok_kind == MP_TOKEN_BYTES) { - - vstr_add_char(&lex->vstr, '\\'); - break; - } - - case 'x': - { - mp_uint_t num = 0; - if (!get_hex(lex, (c == 'x' ? 2 : c == 'u' ? 4 : 8), &num)) { - - lex->tok_kind = MP_TOKEN_INVALID; - } - c = num; - break; - } - case 'N': - - - - - - mp_raise_NotImplementedError("unicode name escapes"); - break; - default: - if (c >= '0' && c <= '7') { - - size_t digits = 3; - mp_uint_t num = c - '0'; - while (is_following_odigit(lex) && --digits != 0) { - next_char(lex); - num = num * 8 + (((lex)->chr0) - '0'); - } - c = num; - } else { - - vstr_add_char(&lex->vstr, '\\'); - } - break; - } - } - if (c != ((unichar)((mp_uint_t)(-1)))) { - if ((0)) { - if (c < 0x110000 && lex->tok_kind == MP_TOKEN_STRING) { - vstr_add_char(&lex->vstr, c); - } else if (c < 0x100 && lex->tok_kind == MP_TOKEN_BYTES) { - vstr_add_byte(&lex->vstr, c); - } else { - - - lex->tok_kind = MP_TOKEN_INVALID; - } - } else { - - if (c < 0x100) { - vstr_add_byte(&lex->vstr, c); - } else { - - - lex->tok_kind = MP_TOKEN_INVALID; - } - } - } - } else { - - - vstr_add_byte(&lex->vstr, ((lex)->chr0)); - } - } - next_char(lex); - } - - - if (n_closing < num_quotes) { - lex->tok_kind = MP_TOKEN_LONELY_STRING_OPEN; - } - - - vstr_cut_tail_bytes(&lex->vstr, n_closing); -} - -static -# 403 "user/mpy/py/lexer.c" 3 4 - _Bool -# 403 "user/mpy/py/lexer.c" - skip_whitespace(mp_lexer_t *lex, -# 403 "user/mpy/py/lexer.c" 3 4 - _Bool -# 403 "user/mpy/py/lexer.c" - stop_at_newline) { - -# 404 "user/mpy/py/lexer.c" 3 4 - _Bool -# 404 "user/mpy/py/lexer.c" - had_physical_newline = -# 404 "user/mpy/py/lexer.c" 3 4 - 0 -# 404 "user/mpy/py/lexer.c" - ; - while (!is_end(lex)) { - if (is_physical_newline(lex)) { - if (stop_at_newline && lex->nested_bracket_level == 0) { - break; - } - had_physical_newline = -# 410 "user/mpy/py/lexer.c" 3 4 - 1 -# 410 "user/mpy/py/lexer.c" - ; - next_char(lex); - } else if (is_whitespace(lex)) { - next_char(lex); - } else if (is_char(lex, '#')) { - next_char(lex); - while (!is_end(lex) && !is_physical_newline(lex)) { - next_char(lex); - } - - } else if (is_char_and(lex, '\\', '\n')) { - - next_char(lex); - next_char(lex); - } else { - break; - } - } - return had_physical_newline; -} - -void mp_lexer_to_next(mp_lexer_t *lex) { - - vstr_reset(&lex->vstr); - - - -# 436 "user/mpy/py/lexer.c" 3 4 - _Bool -# 436 "user/mpy/py/lexer.c" - had_physical_newline = skip_whitespace(lex, -# 436 "user/mpy/py/lexer.c" 3 4 - 0 -# 436 "user/mpy/py/lexer.c" - ); - - - lex->tok_line = lex->line; - lex->tok_column = lex->column; - - if (lex->emit_dent < 0) { - lex->tok_kind = MP_TOKEN_DEDENT; - lex->emit_dent += 1; - - } else if (lex->emit_dent > 0) { - lex->tok_kind = MP_TOKEN_INDENT; - lex->emit_dent -= 1; - - } else if (had_physical_newline && lex->nested_bracket_level == 0) { - lex->tok_kind = MP_TOKEN_NEWLINE; - - size_t num_spaces = lex->column - 1; - if (num_spaces == indent_top(lex)) { - } else if (num_spaces > indent_top(lex)) { - indent_push(lex, num_spaces); - lex->emit_dent += 1; - } else { - while (num_spaces < indent_top(lex)) { - indent_pop(lex); - lex->emit_dent -= 1; - } - if (num_spaces != indent_top(lex)) { - lex->tok_kind = MP_TOKEN_DEDENT_MISMATCH; - } - } - - } else if (is_end(lex)) { - lex->tok_kind = MP_TOKEN_END; - - } else if (is_string_or_bytes(lex)) { -# 481 "user/mpy/py/lexer.c" - lex->tok_kind = MP_TOKEN_END; - - - do { - - -# 486 "user/mpy/py/lexer.c" 3 4 - _Bool -# 486 "user/mpy/py/lexer.c" - is_raw = -# 486 "user/mpy/py/lexer.c" 3 4 - 0 -# 486 "user/mpy/py/lexer.c" - ; - mp_token_kind_t kind = MP_TOKEN_STRING; - int n_char = 0; - if (is_char(lex, 'u')) { - n_char = 1; - } else if (is_char(lex, 'b')) { - kind = MP_TOKEN_BYTES; - n_char = 1; - if (is_char_following(lex, 'r')) { - is_raw = -# 495 "user/mpy/py/lexer.c" 3 4 - 1 -# 495 "user/mpy/py/lexer.c" - ; - n_char = 2; - } - } else if (is_char(lex, 'r')) { - is_raw = -# 499 "user/mpy/py/lexer.c" 3 4 - 1 -# 499 "user/mpy/py/lexer.c" - ; - n_char = 1; - if (is_char_following(lex, 'b')) { - kind = MP_TOKEN_BYTES; - n_char = 2; - } - } - - - if (lex->tok_kind == MP_TOKEN_END) { - lex->tok_kind = kind; - } else if (lex->tok_kind != kind) { - - break; - } - - - if (n_char != 0) { - next_char(lex); - if (n_char == 2) { - next_char(lex); - } - } - - - parse_string_literal(lex, is_raw); - - - skip_whitespace(lex, -# 527 "user/mpy/py/lexer.c" 3 4 - 1 -# 527 "user/mpy/py/lexer.c" - ); - - } while (is_string_or_bytes(lex)); - - } else if (is_head_of_identifier(lex)) { - lex->tok_kind = MP_TOKEN_NAME; - - - vstr_add_byte(&lex->vstr, ((lex)->chr0)); - next_char(lex); - - - while (!is_end(lex) && is_tail_of_identifier(lex)) { - vstr_add_byte(&lex->vstr, ((lex)->chr0)); - next_char(lex); - } - - - - - - const char *s = vstr_null_terminated_str(&lex->vstr); - for (size_t i = 0; i < (sizeof(tok_kw) / sizeof((tok_kw)[0])); i++) { - int cmp = strcmp(s, tok_kw[i]); - if (cmp == 0) { - lex->tok_kind = MP_TOKEN_KW_FALSE + i; - if (lex->tok_kind == MP_TOKEN_KW___DEBUG__) { - lex->tok_kind = ((mp_state_ctx.vm.mp_optimise_value) == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE); - } - break; - } else if (cmp < 0) { - - break; - } - } - - } else if (is_digit(lex) || (is_char(lex, '.') && is_following_digit(lex))) { - -# 564 "user/mpy/py/lexer.c" 3 4 - _Bool -# 564 "user/mpy/py/lexer.c" - forced_integer = -# 564 "user/mpy/py/lexer.c" 3 4 - 0 -# 564 "user/mpy/py/lexer.c" - ; - if (is_char(lex, '.')) { - lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; - } else { - lex->tok_kind = MP_TOKEN_INTEGER; - if (is_char(lex, '0') && is_following_base_char(lex)) { - forced_integer = -# 570 "user/mpy/py/lexer.c" 3 4 - 1 -# 570 "user/mpy/py/lexer.c" - ; - } - } - - - vstr_add_char(&lex->vstr, ((lex)->chr0)); - next_char(lex); - - - while (!is_end(lex)) { - if (!forced_integer && is_char_or(lex, 'e', 'E')) { - lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; - vstr_add_char(&lex->vstr, 'e'); - next_char(lex); - if (is_char(lex, '+') || is_char(lex, '-')) { - vstr_add_char(&lex->vstr, ((lex)->chr0)); - next_char(lex); - } - } else if (is_letter(lex) || is_digit(lex) || is_char(lex, '.')) { - if (is_char_or3(lex, '.', 'j', 'J')) { - lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; - } - vstr_add_char(&lex->vstr, ((lex)->chr0)); - next_char(lex); - } else { - break; - } - } - - } else { - - - const char *t = tok_enc; - size_t tok_enc_index = 0; - for (; *t != 0 && !is_char(lex, *t); t += 1) { - if (*t == 'e' || *t == 'c') { - t += 1; - } - tok_enc_index += 1; - } - - next_char(lex); - - if (*t == 0) { - - lex->tok_kind = MP_TOKEN_INVALID; - - } else if (*t == '!') { - - if (is_char(lex, '=')) { - next_char(lex); - lex->tok_kind = MP_TOKEN_OP_NOT_EQUAL; - } else { - lex->tok_kind = MP_TOKEN_INVALID; - } - - } else if (*t == '.') { - - if (is_char_and(lex, '.', '.')) { - next_char(lex); - next_char(lex); - lex->tok_kind = MP_TOKEN_ELLIPSIS; - } else { - lex->tok_kind = MP_TOKEN_DEL_PERIOD; - } - - } else { - - - - t += 1; - size_t t_index = tok_enc_index; - while (*t == 'c' || *t == 'e') { - t_index += 1; - if (is_char(lex, t[1])) { - next_char(lex); - tok_enc_index = t_index; - if (*t == 'e') { - break; - } - } else if (*t == 'c') { - break; - } - t += 2; - } - - - lex->tok_kind = tok_enc_kind[tok_enc_index]; - - - if (lex->tok_kind == MP_TOKEN_DEL_PAREN_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACKET_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACE_OPEN) { - lex->nested_bracket_level += 1; - } else if (lex->tok_kind == MP_TOKEN_DEL_PAREN_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACKET_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACE_CLOSE) { - lex->nested_bracket_level -= 1; - } - } - } -} - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) { - mp_lexer_t *lex = (((mp_lexer_t*)(m_malloc(sizeof(mp_lexer_t) * (1))))); - - lex->source_name = src_name; - lex->reader = reader; - lex->line = 1; - lex->column = (size_t)-2; - lex->emit_dent = 0; - lex->nested_bracket_level = 0; - lex->alloc_indent_level = (10); - lex->num_indent_level = 1; - lex->indent_level = ((uint16_t*)(m_malloc(sizeof(uint16_t) * (lex->alloc_indent_level)))); - vstr_init(&lex->vstr, 32); - - - lex->indent_level[0] = 0; - - - - lex->chr0 = lex->chr1 = lex->chr2 = 0; - next_char(lex); - next_char(lex); - next_char(lex); - - - mp_lexer_to_next(lex); - - - - if (lex->tok_column != 1) { - lex->tok_kind = MP_TOKEN_INDENT; - } - - return lex; -} - -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len) { - mp_reader_t reader; - mp_reader_new_mem(&reader, (const byte*)str, len, free_len); - return mp_lexer_new(src_name, reader); -} -# 731 "user/mpy/py/lexer.c" -void mp_lexer_free(mp_lexer_t *lex) { - if (lex) { - lex->reader.close(lex->reader.data); - vstr_clear(&lex->vstr); - ((void)(lex->alloc_indent_level), m_free(lex->indent_level)); - (((void)(1), m_free(lex))); - } -} -# 1 "user/mpy/py/parse.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/parse.c" -# 27 "user/mpy/py/parse.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 28 "user/mpy/py/parse.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 29 "user/mpy/py/parse.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 30 "user/mpy/py/parse.c" 2 -# 1 "/usr/arm-none-eabi/include/unistd.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/sys/unistd.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/unistd.h" 2 3 - -extern char **environ; - -void _exit (int __status ) __attribute__ ((__noreturn__)); - -int access (const char *__path, int __amode ); -unsigned alarm (unsigned __secs ); -int chdir (const char *__path ); -int chmod (const char *__path, mode_t __mode ); - -int chown (const char *__path, uid_t __owner, gid_t __group ); - - - - -int close (int __fildes ); -# 46 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int dup (int __fildes ); -int dup2 (int __fildes, int __fildes2 ); -# 61 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int execl (const char *__path, const char *, ... ); -int execle (const char *__path, const char *, ... ); -int execlp (const char *__file, const char *, ... ); - - - -int execv (const char *__path, char * const __argv[] ); -int execve (const char *__path, char * const __argv[], char * const __envp[] ); -int execvp (const char *__file, char * const __argv[] ); -# 79 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int fchmod (int __fildes, mode_t __mode ); - -int fchown (int __fildes, uid_t __owner, gid_t __group ); - - - - - - - -pid_t fork (void ); -long fpathconf (int __fd, int __name ); -int fsync (int __fd); -int fdatasync (int __fd); - - - -char * getcwd (char *__buf, size_t __size ); - - - - - - - -gid_t getegid (void ); -uid_t geteuid (void ); -gid_t getgid (void ); - -int getgroups (int __gidsetsize, gid_t __grouplist[] ); - - - -char * getlogin (void ); - - - -char * getpass (const char *__prompt); -int getpagesize (void); - - - -pid_t getpgid (pid_t); -pid_t getpgrp (void ); -pid_t getpid (void ); -pid_t getppid (void ); - - - - -uid_t getuid (void ); -# 140 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int isatty (int __fildes ); - - - - -int lchown (const char *__path, uid_t __owner, gid_t __group ); - -int link (const char *__path1, const char *__path2 ); - - - -int nice (int __nice_value ); - -off_t lseek (int __fildes, off_t __offset, int __whence ); -# 162 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -long pathconf (const char *__path, int __name ); -int pause (void ); - - - -int pipe (int __fildes[2] ); - - - -ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset); -ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t __offset); -int read (int __fd, void *__buf, size_t __nbyte ); - - - - -int rmdir (const char *__path ); - - - -void * sbrk (ptrdiff_t __incr); - - - - - -int setgid (gid_t __gid ); - - - - - - - -int setpgid (pid_t __pid, pid_t __pgid ); -int setpgrp (void ); - - - - -pid_t setsid (void ); - -int setuid (uid_t __uid ); - - - - -unsigned sleep (unsigned int __seconds ); -void swab (const void *restrict, void *restrict, ssize_t); -long sysconf (int __name ); -pid_t tcgetpgrp (int __fildes ); -int tcsetpgrp (int __fildes, pid_t __pgrp_id ); -char * ttyname (int __fildes ); -int ttyname_r (int, char *, size_t); -int unlink (const char *__path ); -int usleep (useconds_t __useconds); -int vhangup (void ); -int write (int __fd, const void *__buf, size_t __nbyte ); - - - - - - -extern char *optarg; -extern int optind, opterr, optopt; -int getopt(int, char * const [], const char *); -extern int optreset; -# 257 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int ftruncate (int __fd, off_t __length); -int truncate (const char *, off_t __length); -# 5 "/usr/arm-none-eabi/include/unistd.h" 2 3 -# 31 "user/mpy/py/parse.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/parse.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 33 "user/mpy/py/parse.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/lexer.h" 1 -# 32 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 35 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 36 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 37 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 34 "user/mpy/py/parsenum.h" -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 38 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 39 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 40 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 - - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 41 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 42 "user/mpy/py/parse.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 43 "user/mpy/py/parse.c" 2 -# 63 "user/mpy/py/parse.c" -typedef struct _rule_t { - byte rule_id; - byte act; - - - - uint16_t arg[]; -} rule_t; - -enum { - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" - -RULE_file_input, -RULE_file_input_2, - - - -# 58 "user/mpy/py/grammar.h" - - -RULE_decorated, - - - - - - -RULE_funcdef, - - - - - - - - - - - - - - - - - - - - - - - - - - -RULE_simple_stmt_2, - - - - - - - - -RULE_expr_stmt, - - - - - -RULE_testlist_star_expr, - - -# 122 "user/mpy/py/grammar.h" -RULE_del_stmt, -RULE_pass_stmt, - -RULE_break_stmt, -RULE_continue_stmt, -RULE_return_stmt, -RULE_yield_stmt, -RULE_raise_stmt, - - -# 145 "user/mpy/py/grammar.h" - -RULE_import_name, -RULE_import_from, - - - - - - - - - - - - -RULE_global_stmt, -RULE_nonlocal_stmt, - -RULE_assert_stmt, - -# 183 "user/mpy/py/grammar.h" - - -RULE_if_stmt, - - -RULE_while_stmt, -RULE_for_stmt, -RULE_try_stmt, - - - - - - - -RULE_with_stmt, - - - - - -RULE_suite_block_stmts, - - - - - - - -RULE_test_if_expr, - - -RULE_lambdef, -RULE_lambdef_nocond, -# 234 "user/mpy/py/grammar.h" -RULE_or_test, -RULE_and_test, - -RULE_not_test_2, -RULE_comparison, - - - - -RULE_star_expr, -RULE_expr, -RULE_xor_expr, -RULE_and_expr, -RULE_shift_expr, - -RULE_arith_expr, - -RULE_term, - - -RULE_factor_2, - -RULE_power, - - - - - - -RULE_atom_expr_normal, - - - - - - - - -RULE_atom_paren, - -RULE_atom_bracket, -RULE_atom_brace, - - - - - - -RULE_trailer_paren, -RULE_trailer_bracket, -RULE_trailer_period, -# 300 "user/mpy/py/grammar.h" -RULE_subscriptlist, - - - - - - - - -RULE_testlist, - - - - - - -RULE_dictorsetmaker_item, - - - - - - - -RULE_classdef, - - - - - - - - - -# 342 "user/mpy/py/grammar.h" - - - - - - - - - - - - - -RULE_yield_expr, - - -# 77 "user/mpy/py/parse.c" 2 - - - RULE_const_object, - - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" -RULE_single_input, - - -RULE_file_input_3, -RULE_eval_input, -RULE_eval_input_2, -# 58 "user/mpy/py/grammar.h" -RULE_decorator, -RULE_decorators, - - - - - -RULE_decorated_body, - - -RULE_funcdefrettype, - -RULE_typedargslist, -RULE_typedargslist_item, -RULE_typedargslist_name, -RULE_typedargslist_star, -RULE_typedargslist_dbl_star, -RULE_typedargslist_colon, -RULE_typedargslist_equal, -RULE_tfpdef, - -RULE_varargslist, -RULE_varargslist_item, -RULE_varargslist_name, -RULE_varargslist_star, -RULE_varargslist_dbl_star, -RULE_varargslist_equal, -RULE_vfpdef, - - - -RULE_stmt, - - - -RULE_simple_stmt, - - - - - - - - -RULE_small_stmt, - -RULE_expr_stmt_2, -RULE_expr_stmt_augassign, -RULE_expr_stmt_assign_list, -RULE_expr_stmt_assign, -RULE_expr_stmt_6, - -RULE_testlist_star_expr_2, -RULE_augassign, -# 122 "user/mpy/py/grammar.h" - - -RULE_flow_stmt, - - - - - -RULE_raise_stmt_arg, -RULE_raise_stmt_from, -# 145 "user/mpy/py/grammar.h" -RULE_import_stmt, - - -RULE_import_from_2, -RULE_import_from_2b, -RULE_import_from_3, -RULE_import_as_names_paren, -RULE_one_or_more_period_or_ellipsis, -RULE_period_or_ellipsis, -RULE_import_as_name, -RULE_dotted_as_name, -RULE_as_name, -RULE_import_as_names, -RULE_dotted_as_names, -RULE_dotted_name, - - -RULE_name_list, - -RULE_assert_stmt_extra, -# 183 "user/mpy/py/grammar.h" -RULE_compound_stmt, - - -RULE_if_stmt_elif_list, -RULE_if_stmt_elif, - - - -RULE_try_stmt_2, -RULE_try_stmt_except_and_more, -RULE_try_stmt_except, -RULE_try_stmt_as_name, -RULE_try_stmt_except_list, -RULE_try_stmt_finally, -RULE_else_stmt, - -RULE_with_stmt_list, -RULE_with_item, -RULE_with_item_as, -RULE_suite, -RULE_suite_block, - - - - - - - -RULE_test, - -RULE_test_if_else, -RULE_test_nocond, - - -# 234 "user/mpy/py/grammar.h" - - -RULE_not_test, - - -RULE_comp_op, -RULE_comp_op_not_in, -RULE_comp_op_is, -RULE_comp_op_is_not, - - - - - -RULE_shift_op, - -RULE_arith_op, - -RULE_term_op, -RULE_factor, - -RULE_factor_op, - - - - - -RULE_atom_expr, - - -RULE_atom_expr_trailers, -RULE_power_dbl_star, - - - - - -RULE_atom, - -RULE_atom_2b, - - -RULE_testlist_comp, -RULE_testlist_comp_2, -RULE_testlist_comp_3, -RULE_testlist_comp_3b, -RULE_testlist_comp_3c, -RULE_trailer, - - - -# 300 "user/mpy/py/grammar.h" - - - - - - - -RULE_exprlist, -RULE_exprlist_2, - - -RULE_dictorsetmaker, - - - - - - -RULE_dictorsetmaker_tail, -RULE_dictorsetmaker_list, -RULE_dictorsetmaker_list2, - - - - -RULE_classdef_2, - - - - -RULE_arglist, -RULE_arglist_2, -RULE_arglist_star, -RULE_arglist_dbl_star, -# 342 "user/mpy/py/grammar.h" -RULE_argument, -RULE_argument_2, -RULE_argument_3, -RULE_comp_iter, -RULE_comp_for, -RULE_comp_if, - - - - - - - - -RULE_yield_arg, -RULE_yield_arg_from, -# 85 "user/mpy/py/parse.c" 2 - - -}; -# 106 "user/mpy/py/parse.c" -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" -static const rule_t rule_single_input = { RULE_single_input, ((0x10) | 3), { ((0x1000) | MP_TOKEN_NEWLINE), ((0x2000) | RULE_simple_stmt), ((0x2000) | RULE_compound_stmt) } }; -static const rule_t rule_file_input = { RULE_file_input, ((0x20) | 1 | (0x40)), { ((0x3000) | RULE_file_input_2) } }; -static const rule_t rule_file_input_2 = { RULE_file_input_2, ((0x30) | 2), { ((0x2000) | RULE_file_input_3) } }; -static const rule_t rule_file_input_3 = { RULE_file_input_3, ((0x10) | 2), { ((0x1000) | MP_TOKEN_NEWLINE), ((0x2000) | RULE_stmt) } }; -static const rule_t rule_eval_input = { RULE_eval_input, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_testlist), ((0x3000) | RULE_eval_input_2) } }; -static const rule_t rule_eval_input_2 = { RULE_eval_input_2, ((0x20) | 1), { ((0x1000) | MP_TOKEN_NEWLINE) } }; -# 58 "user/mpy/py/grammar.h" -static const rule_t rule_decorator = { RULE_decorator, ((0x20) | 4), { ((0x1000) | MP_TOKEN_DEL_AT), ((0x2000) | RULE_dotted_name), ((0x3000) | RULE_trailer_paren), ((0x1000) | MP_TOKEN_NEWLINE) } }; -static const rule_t rule_decorators = { RULE_decorators, ((0x30) | 2), { ((0x2000) | RULE_decorator) } }; -static const rule_t rule_decorated = { RULE_decorated, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_decorators), ((0x2000) | RULE_decorated_body) } }; - - - - -static const rule_t rule_decorated_body = { RULE_decorated_body, ((0x10) | 2), { ((0x2000) | RULE_classdef), ((0x2000) | RULE_funcdef) } }; - -static const rule_t rule_funcdef = { RULE_funcdef, ((0x20) | 8 | (0x80)), { ((0x1000) | MP_TOKEN_KW_DEF), ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_typedargslist), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE), ((0x3000) | RULE_funcdefrettype), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_funcdefrettype = { RULE_funcdefrettype, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_MINUS_MORE), ((0x2000) | RULE_test) } }; - -static const rule_t rule_typedargslist = { RULE_typedargslist, ((0x30) | 3), { ((0x2000) | RULE_typedargslist_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_typedargslist_item = { RULE_typedargslist_item, ((0x10) | 3), { ((0x2000) | RULE_typedargslist_name), ((0x2000) | RULE_typedargslist_star), ((0x2000) | RULE_typedargslist_dbl_star) } }; -static const rule_t rule_typedargslist_name = { RULE_typedargslist_name, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_typedargslist_colon), ((0x3000) | RULE_typedargslist_equal) } }; -static const rule_t rule_typedargslist_star = { RULE_typedargslist_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x3000) | RULE_tfpdef) } }; -static const rule_t rule_typedargslist_dbl_star = { RULE_typedargslist_dbl_star, ((0x20) | 3), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_typedargslist_colon) } }; -static const rule_t rule_typedargslist_colon = { RULE_typedargslist_colon, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test) } }; -static const rule_t rule_typedargslist_equal = { RULE_typedargslist_equal, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_test) } }; -static const rule_t rule_tfpdef = { RULE_tfpdef, ((0x20) | 2), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_typedargslist_colon) } }; - -static const rule_t rule_varargslist = { RULE_varargslist, ((0x30) | 3), { ((0x2000) | RULE_varargslist_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_varargslist_item = { RULE_varargslist_item, ((0x10) | 3), { ((0x2000) | RULE_varargslist_name), ((0x2000) | RULE_varargslist_star), ((0x2000) | RULE_varargslist_dbl_star) } }; -static const rule_t rule_varargslist_name = { RULE_varargslist_name, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_varargslist_equal) } }; -static const rule_t rule_varargslist_star = { RULE_varargslist_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x3000) | RULE_vfpdef) } }; -static const rule_t rule_varargslist_dbl_star = { RULE_varargslist_dbl_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x1000) | MP_TOKEN_NAME) } }; -static const rule_t rule_varargslist_equal = { RULE_varargslist_equal, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_test) } }; -static const rule_t rule_vfpdef = { RULE_vfpdef, ((0x20) | 1 | (0x40)), { ((0x1000) | MP_TOKEN_NAME) } }; - - - -static const rule_t rule_stmt = { RULE_stmt, ((0x10) | 2), { ((0x2000) | RULE_compound_stmt), ((0x2000) | RULE_simple_stmt) } }; - - - -static const rule_t rule_simple_stmt = { RULE_simple_stmt, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_simple_stmt_2), ((0x1000) | MP_TOKEN_NEWLINE) } }; -static const rule_t rule_simple_stmt_2 = { RULE_simple_stmt_2, ((0x30) | 3), { ((0x2000) | RULE_small_stmt), ((0x1000) | MP_TOKEN_DEL_SEMICOLON) } }; - - - - - - - -static const rule_t rule_small_stmt = { RULE_small_stmt, ((0x10) | 8), { ((0x2000) | RULE_del_stmt), ((0x2000) | RULE_pass_stmt), ((0x2000) | RULE_flow_stmt), ((0x2000) | RULE_import_stmt), ((0x2000) | RULE_global_stmt), ((0x2000) | RULE_nonlocal_stmt), ((0x2000) | RULE_assert_stmt), ((0x2000) | RULE_expr_stmt) } }; -static const rule_t rule_expr_stmt = { RULE_expr_stmt, ((0x20) | 2), { ((0x2000) | RULE_testlist_star_expr), ((0x3000) | RULE_expr_stmt_2) } }; -static const rule_t rule_expr_stmt_2 = { RULE_expr_stmt_2, ((0x10) | 2), { ((0x2000) | RULE_expr_stmt_augassign), ((0x2000) | RULE_expr_stmt_assign_list) } }; -static const rule_t rule_expr_stmt_augassign = { RULE_expr_stmt_augassign, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_augassign), ((0x2000) | RULE_expr_stmt_6) } }; -static const rule_t rule_expr_stmt_assign_list = { RULE_expr_stmt_assign_list, ((0x30) | 2), { ((0x2000) | RULE_expr_stmt_assign) } }; -static const rule_t rule_expr_stmt_assign = { RULE_expr_stmt_assign, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_expr_stmt_6) } }; -static const rule_t rule_expr_stmt_6 = { RULE_expr_stmt_6, ((0x10) | 2), { ((0x2000) | RULE_yield_expr), ((0x2000) | RULE_testlist_star_expr) } }; -static const rule_t rule_testlist_star_expr = { RULE_testlist_star_expr, ((0x30) | 3), { ((0x2000) | RULE_testlist_star_expr_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_testlist_star_expr_2 = { RULE_testlist_star_expr_2, ((0x10) | 2), { ((0x2000) | RULE_star_expr), ((0x2000) | RULE_test) } }; -static const rule_t rule_augassign = { RULE_augassign, ((0x10) | 12), { ((0x1000) | MP_TOKEN_DEL_PLUS_EQUAL), ((0x1000) | MP_TOKEN_DEL_MINUS_EQUAL), ((0x1000) | MP_TOKEN_DEL_STAR_EQUAL), ((0x1000) | MP_TOKEN_DEL_SLASH_EQUAL), ((0x1000) | MP_TOKEN_DEL_PERCENT_EQUAL), ((0x1000) | MP_TOKEN_DEL_AMPERSAND_EQUAL), ((0x1000) | MP_TOKEN_DEL_PIPE_EQUAL), ((0x1000) | MP_TOKEN_DEL_CARET_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_LESS_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_MORE_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_STAR_EQUAL), ((0x1000) | MP_TOKEN_DEL_DBL_SLASH_EQUAL) } }; -# 122 "user/mpy/py/grammar.h" -static const rule_t rule_del_stmt = { RULE_del_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_DEL), ((0x2000) | RULE_exprlist) } }; -static const rule_t rule_pass_stmt = { RULE_pass_stmt, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_PASS) } }; -static const rule_t rule_flow_stmt = { RULE_flow_stmt, ((0x10) | 5), { ((0x2000) | RULE_break_stmt), ((0x2000) | RULE_continue_stmt), ((0x2000) | RULE_return_stmt), ((0x2000) | RULE_raise_stmt), ((0x2000) | RULE_yield_stmt) } }; -static const rule_t rule_break_stmt = { RULE_break_stmt, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_BREAK) } }; -static const rule_t rule_continue_stmt = { RULE_continue_stmt, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_CONTINUE) } }; -static const rule_t rule_return_stmt = { RULE_return_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_RETURN), ((0x3000) | RULE_testlist) } }; -static const rule_t rule_yield_stmt = { RULE_yield_stmt, ((0x20) | 1), { ((0x2000) | RULE_yield_expr) } }; -static const rule_t rule_raise_stmt = { RULE_raise_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_RAISE), ((0x3000) | RULE_raise_stmt_arg) } }; -static const rule_t rule_raise_stmt_arg = { RULE_raise_stmt_arg, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_raise_stmt_from) } }; -static const rule_t rule_raise_stmt_from = { RULE_raise_stmt_from, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_KW_FROM), ((0x2000) | RULE_test) } }; -# 145 "user/mpy/py/grammar.h" -static const rule_t rule_import_stmt = { RULE_import_stmt, ((0x10) | 2), { ((0x2000) | RULE_import_name), ((0x2000) | RULE_import_from) } }; -static const rule_t rule_import_name = { RULE_import_name, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_IMPORT), ((0x2000) | RULE_dotted_as_names) } }; -static const rule_t rule_import_from = { RULE_import_from, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_FROM), ((0x2000) | RULE_import_from_2), ((0x1000) | MP_TOKEN_KW_IMPORT), ((0x2000) | RULE_import_from_3) } }; -static const rule_t rule_import_from_2 = { RULE_import_from_2, ((0x10) | 2), { ((0x2000) | RULE_dotted_name), ((0x2000) | RULE_import_from_2b) } }; -static const rule_t rule_import_from_2b = { RULE_import_from_2b, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_one_or_more_period_or_ellipsis), ((0x3000) | RULE_dotted_name) } }; -static const rule_t rule_import_from_3 = { RULE_import_from_3, ((0x10) | 3), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x2000) | RULE_import_as_names_paren), ((0x2000) | RULE_import_as_names) } }; -static const rule_t rule_import_as_names_paren = { RULE_import_as_names_paren, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x2000) | RULE_import_as_names), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; -static const rule_t rule_one_or_more_period_or_ellipsis = { RULE_one_or_more_period_or_ellipsis, ((0x30) | 2), { ((0x2000) | RULE_period_or_ellipsis) } }; -static const rule_t rule_period_or_ellipsis = { RULE_period_or_ellipsis, ((0x10) | 2), { ((0x1000) | MP_TOKEN_DEL_PERIOD), ((0x1000) | MP_TOKEN_ELLIPSIS) } }; -static const rule_t rule_import_as_name = { RULE_import_as_name, ((0x20) | 2), { ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_as_name) } }; -static const rule_t rule_dotted_as_name = { RULE_dotted_as_name, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_dotted_name), ((0x3000) | RULE_as_name) } }; -static const rule_t rule_as_name = { RULE_as_name, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_KW_AS), ((0x1000) | MP_TOKEN_NAME) } }; -static const rule_t rule_import_as_names = { RULE_import_as_names, ((0x30) | 3), { ((0x2000) | RULE_import_as_name), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_dotted_as_names = { RULE_dotted_as_names, ((0x30) | 1), { ((0x2000) | RULE_dotted_as_name), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_dotted_name = { RULE_dotted_name, ((0x30) | 1), { ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_DEL_PERIOD) } }; -static const rule_t rule_global_stmt = { RULE_global_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_GLOBAL), ((0x2000) | RULE_name_list) } }; -static const rule_t rule_nonlocal_stmt = { RULE_nonlocal_stmt, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_NONLOCAL), ((0x2000) | RULE_name_list) } }; -static const rule_t rule_name_list = { RULE_name_list, ((0x30) | 1), { ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_assert_stmt = { RULE_assert_stmt, ((0x20) | 3), { ((0x1000) | MP_TOKEN_KW_ASSERT), ((0x2000) | RULE_test), ((0x3000) | RULE_assert_stmt_extra) } }; -static const rule_t rule_assert_stmt_extra = { RULE_assert_stmt_extra, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_COMMA), ((0x2000) | RULE_test) } }; -# 183 "user/mpy/py/grammar.h" -static const rule_t rule_compound_stmt = { RULE_compound_stmt, ((0x10) | 8), { ((0x2000) | RULE_if_stmt), ((0x2000) | RULE_while_stmt), ((0x2000) | RULE_for_stmt), ((0x2000) | RULE_try_stmt), ((0x2000) | RULE_with_stmt), ((0x2000) | RULE_funcdef), ((0x2000) | RULE_classdef), ((0x2000) | RULE_decorated) } }; - -static const rule_t rule_if_stmt = { RULE_if_stmt, ((0x20) | 6), { ((0x1000) | MP_TOKEN_KW_IF), ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x3000) | RULE_if_stmt_elif_list), ((0x3000) | RULE_else_stmt) } }; -static const rule_t rule_if_stmt_elif_list = { RULE_if_stmt_elif_list, ((0x30) | 2), { ((0x2000) | RULE_if_stmt_elif) } }; -static const rule_t rule_if_stmt_elif = { RULE_if_stmt_elif, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_ELIF), ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_while_stmt = { RULE_while_stmt, ((0x20) | 5), { ((0x1000) | MP_TOKEN_KW_WHILE), ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x3000) | RULE_else_stmt) } }; -static const rule_t rule_for_stmt = { RULE_for_stmt, ((0x20) | 7), { ((0x1000) | MP_TOKEN_KW_FOR), ((0x2000) | RULE_exprlist), ((0x1000) | MP_TOKEN_KW_IN), ((0x2000) | RULE_testlist), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x3000) | RULE_else_stmt) } }; -static const rule_t rule_try_stmt = { RULE_try_stmt, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_TRY), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite), ((0x2000) | RULE_try_stmt_2) } }; -static const rule_t rule_try_stmt_2 = { RULE_try_stmt_2, ((0x10) | 2), { ((0x2000) | RULE_try_stmt_except_and_more), ((0x2000) | RULE_try_stmt_finally) } }; -static const rule_t rule_try_stmt_except_and_more = { RULE_try_stmt_except_and_more, ((0x20) | 3 | (0x40)), { ((0x2000) | RULE_try_stmt_except_list), ((0x3000) | RULE_else_stmt), ((0x3000) | RULE_try_stmt_finally) } }; -static const rule_t rule_try_stmt_except = { RULE_try_stmt_except, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_EXCEPT), ((0x3000) | RULE_try_stmt_as_name), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_try_stmt_as_name = { RULE_try_stmt_as_name, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_as_name) } }; -static const rule_t rule_try_stmt_except_list = { RULE_try_stmt_except_list, ((0x30) | 2), { ((0x2000) | RULE_try_stmt_except) } }; -static const rule_t rule_try_stmt_finally = { RULE_try_stmt_finally, ((0x20) | 3), { ((0x1000) | MP_TOKEN_KW_FINALLY), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_else_stmt = { RULE_else_stmt, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_KW_ELSE), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_with_stmt = { RULE_with_stmt, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_WITH), ((0x2000) | RULE_with_stmt_list), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_with_stmt_list = { RULE_with_stmt_list, ((0x30) | 1), { ((0x2000) | RULE_with_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_with_item = { RULE_with_item, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_with_item_as) } }; -static const rule_t rule_with_item_as = { RULE_with_item_as, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_KW_AS), ((0x2000) | RULE_expr) } }; -static const rule_t rule_suite = { RULE_suite, ((0x10) | 2), { ((0x2000) | RULE_suite_block), ((0x2000) | RULE_simple_stmt) } }; -static const rule_t rule_suite_block = { RULE_suite_block, ((0x20) | 4 | (0x40)), { ((0x1000) | MP_TOKEN_NEWLINE), ((0x1000) | MP_TOKEN_INDENT), ((0x2000) | RULE_suite_block_stmts), ((0x1000) | MP_TOKEN_DEDENT) } }; -static const rule_t rule_suite_block_stmts = { RULE_suite_block_stmts, ((0x30) | 2), { ((0x2000) | RULE_stmt) } }; - - - - - - -static const rule_t rule_test = { RULE_test, ((0x10) | 2), { ((0x2000) | RULE_lambdef), ((0x2000) | RULE_test_if_expr) } }; -static const rule_t rule_test_if_expr = { RULE_test_if_expr, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_or_test), ((0x3000) | RULE_test_if_else) } }; -static const rule_t rule_test_if_else = { RULE_test_if_else, ((0x20) | 4), { ((0x1000) | MP_TOKEN_KW_IF), ((0x2000) | RULE_or_test), ((0x1000) | MP_TOKEN_KW_ELSE), ((0x2000) | RULE_test) } }; -static const rule_t rule_test_nocond = { RULE_test_nocond, ((0x10) | 2), { ((0x2000) | RULE_lambdef_nocond), ((0x2000) | RULE_or_test) } }; -static const rule_t rule_lambdef = { RULE_lambdef, ((0x20) | 4 | (0x80)), { ((0x1000) | MP_TOKEN_KW_LAMBDA), ((0x3000) | RULE_varargslist), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test) } }; -static const rule_t rule_lambdef_nocond = { RULE_lambdef_nocond, ((0x20) | 4 | (0x80)), { ((0x1000) | MP_TOKEN_KW_LAMBDA), ((0x3000) | RULE_varargslist), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test_nocond) } }; -# 234 "user/mpy/py/grammar.h" -static const rule_t rule_or_test = { RULE_or_test, ((0x30) | 1), { ((0x2000) | RULE_and_test), ((0x1000) | MP_TOKEN_KW_OR) } }; -static const rule_t rule_and_test = { RULE_and_test, ((0x30) | 1), { ((0x2000) | RULE_not_test), ((0x1000) | MP_TOKEN_KW_AND) } }; -static const rule_t rule_not_test = { RULE_not_test, ((0x10) | 2), { ((0x2000) | RULE_not_test_2), ((0x2000) | RULE_comparison) } }; -static const rule_t rule_not_test_2 = { RULE_not_test_2, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_NOT), ((0x2000) | RULE_not_test) } }; -static const rule_t rule_comparison = { RULE_comparison, ((0x30) | 1), { ((0x2000) | RULE_expr), ((0x2000) | RULE_comp_op) } }; -static const rule_t rule_comp_op = { RULE_comp_op, ((0x10) | 9), { ((0x1000) | MP_TOKEN_OP_LESS), ((0x1000) | MP_TOKEN_OP_MORE), ((0x1000) | MP_TOKEN_OP_DBL_EQUAL), ((0x1000) | MP_TOKEN_OP_LESS_EQUAL), ((0x1000) | MP_TOKEN_OP_MORE_EQUAL), ((0x1000) | MP_TOKEN_OP_NOT_EQUAL), ((0x1000) | MP_TOKEN_KW_IN), ((0x2000) | RULE_comp_op_not_in), ((0x2000) | RULE_comp_op_is) } }; -static const rule_t rule_comp_op_not_in = { RULE_comp_op_not_in, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_NOT), ((0x1000) | MP_TOKEN_KW_IN) } }; -static const rule_t rule_comp_op_is = { RULE_comp_op_is, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_IS), ((0x3000) | RULE_comp_op_is_not) } }; -static const rule_t rule_comp_op_is_not = { RULE_comp_op_is_not, ((0x20) | 1), { ((0x1000) | MP_TOKEN_KW_NOT) } }; -static const rule_t rule_star_expr = { RULE_star_expr, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x2000) | RULE_expr) } }; -static const rule_t rule_expr = { RULE_expr, ((0x30) | 1), { ((0x2000) | RULE_xor_expr), ((0x1000) | MP_TOKEN_OP_PIPE) } }; -static const rule_t rule_xor_expr = { RULE_xor_expr, ((0x30) | 1), { ((0x2000) | RULE_and_expr), ((0x1000) | MP_TOKEN_OP_CARET) } }; -static const rule_t rule_and_expr = { RULE_and_expr, ((0x30) | 1), { ((0x2000) | RULE_shift_expr), ((0x1000) | MP_TOKEN_OP_AMPERSAND) } }; -static const rule_t rule_shift_expr = { RULE_shift_expr, ((0x30) | 1), { ((0x2000) | RULE_arith_expr), ((0x2000) | RULE_shift_op) } }; -static const rule_t rule_shift_op = { RULE_shift_op, ((0x10) | 2), { ((0x1000) | MP_TOKEN_OP_DBL_LESS), ((0x1000) | MP_TOKEN_OP_DBL_MORE) } }; -static const rule_t rule_arith_expr = { RULE_arith_expr, ((0x30) | 1), { ((0x2000) | RULE_term), ((0x2000) | RULE_arith_op) } }; -static const rule_t rule_arith_op = { RULE_arith_op, ((0x10) | 2), { ((0x1000) | MP_TOKEN_OP_PLUS), ((0x1000) | MP_TOKEN_OP_MINUS) } }; -static const rule_t rule_term = { RULE_term, ((0x30) | 1), { ((0x2000) | RULE_factor), ((0x2000) | RULE_term_op) } }; -static const rule_t rule_term_op = { RULE_term_op, ((0x10) | 4), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x1000) | MP_TOKEN_OP_SLASH), ((0x1000) | MP_TOKEN_OP_PERCENT), ((0x1000) | MP_TOKEN_OP_DBL_SLASH) } }; -static const rule_t rule_factor = { RULE_factor, ((0x10) | 2), { ((0x2000) | RULE_factor_2), ((0x2000) | RULE_power) } }; -static const rule_t rule_factor_2 = { RULE_factor_2, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_factor_op), ((0x2000) | RULE_factor) } }; -static const rule_t rule_factor_op = { RULE_factor_op, ((0x10) | 3), { ((0x1000) | MP_TOKEN_OP_PLUS), ((0x1000) | MP_TOKEN_OP_MINUS), ((0x1000) | MP_TOKEN_OP_TILDE) } }; -static const rule_t rule_power = { RULE_power, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_atom_expr), ((0x3000) | RULE_power_dbl_star) } }; - - - - -static const rule_t rule_atom_expr = { RULE_atom_expr, ((0x10) | 1), { ((0x2000) | RULE_atom_expr_normal) } }; - -static const rule_t rule_atom_expr_normal = { RULE_atom_expr_normal, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_atom), ((0x3000) | RULE_atom_expr_trailers) } }; -static const rule_t rule_atom_expr_trailers = { RULE_atom_expr_trailers, ((0x30) | 2), { ((0x2000) | RULE_trailer) } }; -static const rule_t rule_power_dbl_star = { RULE_power_dbl_star, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x2000) | RULE_factor) } }; - - - - - -static const rule_t rule_atom = { RULE_atom, ((0x10) | 12), { ((0x1000) | MP_TOKEN_NAME), ((0x1000) | MP_TOKEN_INTEGER), ((0x1000) | MP_TOKEN_FLOAT_OR_IMAG), ((0x1000) | MP_TOKEN_STRING), ((0x1000) | MP_TOKEN_BYTES), ((0x1000) | MP_TOKEN_ELLIPSIS), ((0x1000) | MP_TOKEN_KW_NONE), ((0x1000) | MP_TOKEN_KW_TRUE), ((0x1000) | MP_TOKEN_KW_FALSE), ((0x2000) | RULE_atom_paren), ((0x2000) | RULE_atom_bracket), ((0x2000) | RULE_atom_brace) } }; -static const rule_t rule_atom_paren = { RULE_atom_paren, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_atom_2b), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; -static const rule_t rule_atom_2b = { RULE_atom_2b, ((0x10) | 2), { ((0x2000) | RULE_yield_expr), ((0x2000) | RULE_testlist_comp) } }; -static const rule_t rule_atom_bracket = { RULE_atom_bracket, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_BRACKET_OPEN), ((0x3000) | RULE_testlist_comp), ((0x1000) | MP_TOKEN_DEL_BRACKET_CLOSE) } }; -static const rule_t rule_atom_brace = { RULE_atom_brace, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_BRACE_OPEN), ((0x3000) | RULE_dictorsetmaker), ((0x1000) | MP_TOKEN_DEL_BRACE_CLOSE) } }; -static const rule_t rule_testlist_comp = { RULE_testlist_comp, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_testlist_comp_2), ((0x3000) | RULE_testlist_comp_3) } }; -static const rule_t rule_testlist_comp_2 = { RULE_testlist_comp_2, ((0x10) | 2), { ((0x2000) | RULE_star_expr), ((0x2000) | RULE_test) } }; -static const rule_t rule_testlist_comp_3 = { RULE_testlist_comp_3, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_testlist_comp_3b) } }; -static const rule_t rule_testlist_comp_3b = { RULE_testlist_comp_3b, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_COMMA), ((0x3000) | RULE_testlist_comp_3c) } }; -static const rule_t rule_testlist_comp_3c = { RULE_testlist_comp_3c, ((0x30) | 3), { ((0x2000) | RULE_testlist_comp_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_trailer = { RULE_trailer, ((0x10) | 3), { ((0x2000) | RULE_trailer_paren), ((0x2000) | RULE_trailer_bracket), ((0x2000) | RULE_trailer_period) } }; -static const rule_t rule_trailer_paren = { RULE_trailer_paren, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_arglist), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; -static const rule_t rule_trailer_bracket = { RULE_trailer_bracket, ((0x20) | 3), { ((0x1000) | MP_TOKEN_DEL_BRACKET_OPEN), ((0x2000) | RULE_subscriptlist), ((0x1000) | MP_TOKEN_DEL_BRACKET_CLOSE) } }; -static const rule_t rule_trailer_period = { RULE_trailer_period, ((0x20) | 2), { ((0x1000) | MP_TOKEN_DEL_PERIOD), ((0x1000) | MP_TOKEN_NAME) } }; -# 300 "user/mpy/py/grammar.h" -static const rule_t rule_subscriptlist = { RULE_subscriptlist, ((0x30) | 3), { ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; - - - - - - -static const rule_t rule_exprlist = { RULE_exprlist, ((0x30) | 3), { ((0x2000) | RULE_exprlist_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_exprlist_2 = { RULE_exprlist_2, ((0x10) | 2), { ((0x2000) | RULE_star_expr), ((0x2000) | RULE_expr) } }; -static const rule_t rule_testlist = { RULE_testlist, ((0x30) | 3), { ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; - -static const rule_t rule_dictorsetmaker = { RULE_dictorsetmaker, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_dictorsetmaker_item), ((0x3000) | RULE_dictorsetmaker_tail) } }; - - - - -static const rule_t rule_dictorsetmaker_item = { RULE_dictorsetmaker_item, ((0x20) | 3), { ((0x2000) | RULE_test), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_test) } }; - -static const rule_t rule_dictorsetmaker_tail = { RULE_dictorsetmaker_tail, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_dictorsetmaker_list) } }; -static const rule_t rule_dictorsetmaker_list = { RULE_dictorsetmaker_list, ((0x20) | 2), { ((0x1000) | MP_TOKEN_DEL_COMMA), ((0x3000) | RULE_dictorsetmaker_list2) } }; -static const rule_t rule_dictorsetmaker_list2 = { RULE_dictorsetmaker_list2, ((0x30) | 3), { ((0x2000) | RULE_dictorsetmaker_item), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; - - - -static const rule_t rule_classdef = { RULE_classdef, ((0x20) | 5 | (0x80)), { ((0x1000) | MP_TOKEN_KW_CLASS), ((0x1000) | MP_TOKEN_NAME), ((0x3000) | RULE_classdef_2), ((0x1000) | MP_TOKEN_DEL_COLON), ((0x2000) | RULE_suite) } }; -static const rule_t rule_classdef_2 = { RULE_classdef_2, ((0x20) | 3 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_PAREN_OPEN), ((0x3000) | RULE_arglist), ((0x1000) | MP_TOKEN_DEL_PAREN_CLOSE) } }; - - - - -static const rule_t rule_arglist = { RULE_arglist, ((0x30) | 3), { ((0x2000) | RULE_arglist_2), ((0x1000) | MP_TOKEN_DEL_COMMA) } }; -static const rule_t rule_arglist_2 = { RULE_arglist_2, ((0x10) | 3), { ((0x2000) | RULE_arglist_star), ((0x2000) | RULE_arglist_dbl_star), ((0x2000) | RULE_argument) } }; -static const rule_t rule_arglist_star = { RULE_arglist_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_STAR), ((0x2000) | RULE_test) } }; -static const rule_t rule_arglist_dbl_star = { RULE_arglist_dbl_star, ((0x20) | 2), { ((0x1000) | MP_TOKEN_OP_DBL_STAR), ((0x2000) | RULE_test) } }; -# 342 "user/mpy/py/grammar.h" -static const rule_t rule_argument = { RULE_argument, ((0x20) | 2 | (0x40)), { ((0x2000) | RULE_test), ((0x3000) | RULE_argument_2) } }; -static const rule_t rule_argument_2 = { RULE_argument_2, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_argument_3) } }; -static const rule_t rule_argument_3 = { RULE_argument_3, ((0x20) | 2 | (0x40)), { ((0x1000) | MP_TOKEN_DEL_EQUAL), ((0x2000) | RULE_test) } }; -static const rule_t rule_comp_iter = { RULE_comp_iter, ((0x10) | 2), { ((0x2000) | RULE_comp_for), ((0x2000) | RULE_comp_if) } }; -static const rule_t rule_comp_for = { RULE_comp_for, ((0x20) | 5 | (0x80)), { ((0x1000) | MP_TOKEN_KW_FOR), ((0x2000) | RULE_exprlist), ((0x1000) | MP_TOKEN_KW_IN), ((0x2000) | RULE_or_test), ((0x3000) | RULE_comp_iter) } }; -static const rule_t rule_comp_if = { RULE_comp_if, ((0x20) | 3), { ((0x1000) | MP_TOKEN_KW_IF), ((0x2000) | RULE_test_nocond), ((0x3000) | RULE_comp_iter) } }; - - - - - - - -static const rule_t rule_yield_expr = { RULE_yield_expr, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_YIELD), ((0x3000) | RULE_yield_arg) } }; -static const rule_t rule_yield_arg = { RULE_yield_arg, ((0x10) | 2), { ((0x2000) | RULE_yield_arg_from), ((0x2000) | RULE_testlist) } }; -static const rule_t rule_yield_arg_from = { RULE_yield_arg_from, ((0x20) | 2), { ((0x1000) | MP_TOKEN_KW_FROM), ((0x2000) | RULE_test) } }; -# 107 "user/mpy/py/parse.c" 2 -# 118 "user/mpy/py/parse.c" -static const rule_t *const rules[] = { - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" - -&rule_file_input, -&rule_file_input_2, - - - -# 58 "user/mpy/py/grammar.h" - - -&rule_decorated, - - - - - - -&rule_funcdef, - - - - - - - - - - - - - - - - - - - - - - - - - - -&rule_simple_stmt_2, - - - - - - - - -&rule_expr_stmt, - - - - - -&rule_testlist_star_expr, - - -# 122 "user/mpy/py/grammar.h" -&rule_del_stmt, -&rule_pass_stmt, - -&rule_break_stmt, -&rule_continue_stmt, -&rule_return_stmt, -&rule_yield_stmt, -&rule_raise_stmt, - - -# 145 "user/mpy/py/grammar.h" - -&rule_import_name, -&rule_import_from, - - - - - - - - - - - - -&rule_global_stmt, -&rule_nonlocal_stmt, - -&rule_assert_stmt, - -# 183 "user/mpy/py/grammar.h" - - -&rule_if_stmt, - - -&rule_while_stmt, -&rule_for_stmt, -&rule_try_stmt, - - - - - - - -&rule_with_stmt, - - - - - -&rule_suite_block_stmts, - - - - - - - -&rule_test_if_expr, - - -&rule_lambdef, -&rule_lambdef_nocond, -# 234 "user/mpy/py/grammar.h" -&rule_or_test, -&rule_and_test, - -&rule_not_test_2, -&rule_comparison, - - - - -&rule_star_expr, -&rule_expr, -&rule_xor_expr, -&rule_and_expr, -&rule_shift_expr, - -&rule_arith_expr, - -&rule_term, - - -&rule_factor_2, - -&rule_power, - - - - - - -&rule_atom_expr_normal, - - - - - - - - -&rule_atom_paren, - -&rule_atom_bracket, -&rule_atom_brace, - - - - - - -&rule_trailer_paren, -&rule_trailer_bracket, -&rule_trailer_period, -# 300 "user/mpy/py/grammar.h" -&rule_subscriptlist, - - - - - - - - -&rule_testlist, - - - - - - -&rule_dictorsetmaker_item, - - - - - - - -&rule_classdef, - - - - - - - - - -# 342 "user/mpy/py/grammar.h" - - - - - - - - - - - - - -&rule_yield_expr, - - -# 123 "user/mpy/py/parse.c" 2 - - - -# 125 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 125 "user/mpy/py/parse.c" - , - - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" -&rule_single_input, - - -&rule_file_input_3, -&rule_eval_input, -&rule_eval_input_2, -# 58 "user/mpy/py/grammar.h" -&rule_decorator, -&rule_decorators, - - - - - -&rule_decorated_body, - - -&rule_funcdefrettype, - -&rule_typedargslist, -&rule_typedargslist_item, -&rule_typedargslist_name, -&rule_typedargslist_star, -&rule_typedargslist_dbl_star, -&rule_typedargslist_colon, -&rule_typedargslist_equal, -&rule_tfpdef, - -&rule_varargslist, -&rule_varargslist_item, -&rule_varargslist_name, -&rule_varargslist_star, -&rule_varargslist_dbl_star, -&rule_varargslist_equal, -&rule_vfpdef, - - - -&rule_stmt, - - - -&rule_simple_stmt, - - - - - - - - -&rule_small_stmt, - -&rule_expr_stmt_2, -&rule_expr_stmt_augassign, -&rule_expr_stmt_assign_list, -&rule_expr_stmt_assign, -&rule_expr_stmt_6, - -&rule_testlist_star_expr_2, -&rule_augassign, -# 122 "user/mpy/py/grammar.h" - - -&rule_flow_stmt, - - - - - -&rule_raise_stmt_arg, -&rule_raise_stmt_from, -# 145 "user/mpy/py/grammar.h" -&rule_import_stmt, - - -&rule_import_from_2, -&rule_import_from_2b, -&rule_import_from_3, -&rule_import_as_names_paren, -&rule_one_or_more_period_or_ellipsis, -&rule_period_or_ellipsis, -&rule_import_as_name, -&rule_dotted_as_name, -&rule_as_name, -&rule_import_as_names, -&rule_dotted_as_names, -&rule_dotted_name, - - -&rule_name_list, - -&rule_assert_stmt_extra, -# 183 "user/mpy/py/grammar.h" -&rule_compound_stmt, - - -&rule_if_stmt_elif_list, -&rule_if_stmt_elif, - - - -&rule_try_stmt_2, -&rule_try_stmt_except_and_more, -&rule_try_stmt_except, -&rule_try_stmt_as_name, -&rule_try_stmt_except_list, -&rule_try_stmt_finally, -&rule_else_stmt, - -&rule_with_stmt_list, -&rule_with_item, -&rule_with_item_as, -&rule_suite, -&rule_suite_block, - - - - - - - -&rule_test, - -&rule_test_if_else, -&rule_test_nocond, - - -# 234 "user/mpy/py/grammar.h" - - -&rule_not_test, - - -&rule_comp_op, -&rule_comp_op_not_in, -&rule_comp_op_is, -&rule_comp_op_is_not, - - - - - -&rule_shift_op, - -&rule_arith_op, - -&rule_term_op, -&rule_factor, - -&rule_factor_op, - - - - - -&rule_atom_expr, - - -&rule_atom_expr_trailers, -&rule_power_dbl_star, - - - - - -&rule_atom, - -&rule_atom_2b, - - -&rule_testlist_comp, -&rule_testlist_comp_2, -&rule_testlist_comp_3, -&rule_testlist_comp_3b, -&rule_testlist_comp_3c, -&rule_trailer, - - - -# 300 "user/mpy/py/grammar.h" - - - - - - - -&rule_exprlist, -&rule_exprlist_2, - - -&rule_dictorsetmaker, - - - - - - -&rule_dictorsetmaker_tail, -&rule_dictorsetmaker_list, -&rule_dictorsetmaker_list2, - - - - -&rule_classdef_2, - - - - -&rule_arglist, -&rule_arglist_2, -&rule_arglist_star, -&rule_arglist_dbl_star, -# 342 "user/mpy/py/grammar.h" -&rule_argument, -&rule_argument_2, -&rule_argument_3, -&rule_comp_iter, -&rule_comp_for, -&rule_comp_if, - - - - - - - - -&rule_yield_arg, -&rule_yield_arg_from, -# 131 "user/mpy/py/parse.c" 2 - - -}; - -typedef struct _rule_stack_t { - size_t src_line : 8 * sizeof(size_t) - 8; - size_t rule_id : 8; - size_t arg_i; -} rule_stack_t; - -typedef struct _mp_parse_chunk_t { - size_t alloc; - union { - size_t used; - struct _mp_parse_chunk_t *next; - } union_; - byte data[]; -} mp_parse_chunk_t; - -typedef struct _parser_t { - size_t rule_stack_alloc; - size_t rule_stack_top; - rule_stack_t *rule_stack; - - size_t result_stack_alloc; - size_t result_stack_top; - mp_parse_node_t *result_stack; - - mp_lexer_t *lexer; - - mp_parse_tree_t tree; - mp_parse_chunk_t *cur_chunk; - - - - -} parser_t; - -static void *parser_alloc(parser_t *parser, size_t num_bytes) { - - - mp_parse_chunk_t *chunk = parser->cur_chunk; - - if (chunk != -# 174 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 174 "user/mpy/py/parse.c" - && chunk->union_.used + num_bytes > chunk->alloc) { - - mp_parse_chunk_t *new_data = (mp_parse_chunk_t*)((byte*)(m_realloc_maybe((chunk), sizeof(byte) * (sizeof(mp_parse_chunk_t) + chunk->alloc + num_bytes), ( -# 176 "user/mpy/py/parse.c" 3 4 - 0 -# 176 "user/mpy/py/parse.c" - )))) - - ; - if (new_data == -# 179 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 179 "user/mpy/py/parse.c" - ) { - - (void)((byte*)(m_realloc_maybe((chunk), sizeof(byte) * (sizeof(mp_parse_chunk_t) + chunk->union_.used), ( -# 181 "user/mpy/py/parse.c" 3 4 - 0 -# 181 "user/mpy/py/parse.c" - )))) - ; - chunk->alloc = chunk->union_.used; - chunk->union_.next = parser->tree.chunk; - parser->tree.chunk = chunk; - chunk = -# 186 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 186 "user/mpy/py/parse.c" - ; - } else { - - chunk->alloc += num_bytes; - } - } - - if (chunk == -# 193 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 193 "user/mpy/py/parse.c" - ) { - - size_t alloc = (16); - if (alloc < num_bytes) { - alloc = num_bytes; - } - chunk = (mp_parse_chunk_t*)((byte*)(m_malloc(sizeof(byte) * (sizeof(mp_parse_chunk_t) + alloc)))); - chunk->alloc = alloc; - chunk->union_.used = 0; - parser->cur_chunk = chunk; - } - - byte *ret = chunk->data + chunk->union_.used; - chunk->union_.used += num_bytes; - return ret; -} - -static void push_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t arg_i) { - if (parser->rule_stack_top >= parser->rule_stack_alloc) { - rule_stack_t *rs = ((rule_stack_t*)(m_realloc((parser->rule_stack), sizeof(rule_stack_t) * (parser->rule_stack_alloc + (16))))); - parser->rule_stack = rs; - parser->rule_stack_alloc += (16); - } - rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++]; - rs->src_line = src_line; - rs->rule_id = rule->rule_id; - rs->arg_i = arg_i; -} - -static void push_rule_from_arg(parser_t *parser, size_t arg) { - -# 223 "user/mpy/py/parse.c" 3 - (( -# 223 "user/mpy/py/parse.c" - (arg & (0xf000)) == (0x2000) || (arg & (0xf000)) == (0x3000) -# 223 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 223, __func__, -# 223 "user/mpy/py/parse.c" - "(arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE" -# 223 "user/mpy/py/parse.c" 3 - )) -# 223 "user/mpy/py/parse.c" - ; - size_t rule_id = arg & (0x0fff); - push_rule(parser, parser->lexer->tok_line, rules[rule_id], 0); -} - -static void pop_rule(parser_t *parser, const rule_t **rule, size_t *arg_i, size_t *src_line) { - parser->rule_stack_top -= 1; - *rule = rules[parser->rule_stack[parser->rule_stack_top].rule_id]; - *arg_i = parser->rule_stack[parser->rule_stack_top].arg_i; - *src_line = parser->rule_stack[parser->rule_stack_top].src_line; -} - - -# 235 "user/mpy/py/parse.c" 3 4 -_Bool -# 235 "user/mpy/py/parse.c" - mp_parse_node_is_const_false(mp_parse_node_t pn) { - return ((pn) == ((0x0e) | ((MP_TOKEN_KW_FALSE) << 4))) - || ((((pn) & 0x1) == (0x1)) && (((mp_int_t)(intptr_t)(pn)) >> 1) == 0); -} - - -# 240 "user/mpy/py/parse.c" 3 4 -_Bool -# 240 "user/mpy/py/parse.c" - mp_parse_node_is_const_true(mp_parse_node_t pn) { - return ((pn) == ((0x0e) | ((MP_TOKEN_KW_TRUE) << 4))) - || ((((pn) & 0x1) == (0x1)) && (((mp_int_t)(intptr_t)(pn)) >> 1) != 0); -} - - -# 245 "user/mpy/py/parse.c" 3 4 -_Bool -# 245 "user/mpy/py/parse.c" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) { - if ((((pn) & 0x1) == (0x1))) { - *o = ((mp_obj_t)((((mp_uint_t)((((mp_int_t)(intptr_t)(pn)) >> 1))) << 1) | 1)); - return -# 248 "user/mpy/py/parse.c" 3 4 - 1 -# 248 "user/mpy/py/parse.c" - ; - } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (RULE_const_object))) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - - - - - *o = (mp_obj_t)pns->nodes[0]; - - return (MP_OBJ_IS_SMALL_INT(*o) || (MP_OBJ_IS_OBJ(*o) && (((mp_obj_base_t*)((void*)*o))->type == (&mp_type_int)))); - } else { - return -# 259 "user/mpy/py/parse.c" 3 4 - 0 -# 259 "user/mpy/py/parse.c" - ; - } -} - -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes) { - if (((*pn) == (0))) { - *nodes = -# 265 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 265 "user/mpy/py/parse.c" - ; - return 0; - } else if (((*pn) & 3)) { - *nodes = pn; - return 1; - } else { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)(*pn); - if (((pns)->kind_num_nodes & 0xff) != pn_kind) { - *nodes = pn; - return 1; - } else { - *nodes = pns->nodes; - return ((pns)->kind_num_nodes >> 8); - } - } -} -# 340 "user/mpy/py/parse.c" -static mp_parse_node_t pop_result(parser_t *parser) { - -# 341 "user/mpy/py/parse.c" 3 - (( -# 341 "user/mpy/py/parse.c" - parser->result_stack_top > 0 -# 341 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 341, __func__, -# 341 "user/mpy/py/parse.c" - "parser->result_stack_top > 0" -# 341 "user/mpy/py/parse.c" 3 - )) -# 341 "user/mpy/py/parse.c" - ; - return parser->result_stack[--parser->result_stack_top]; -} - -static mp_parse_node_t peek_result(parser_t *parser, size_t pos) { - -# 346 "user/mpy/py/parse.c" 3 - (( -# 346 "user/mpy/py/parse.c" - parser->result_stack_top > pos -# 346 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 346, __func__, -# 346 "user/mpy/py/parse.c" - "parser->result_stack_top > pos" -# 346 "user/mpy/py/parse.c" 3 - )) -# 346 "user/mpy/py/parse.c" - ; - return parser->result_stack[parser->result_stack_top - 1 - pos]; -} - -static void push_result_node(parser_t *parser, mp_parse_node_t pn) { - if (parser->result_stack_top >= parser->result_stack_alloc) { - mp_parse_node_t *stack = ((mp_parse_node_t*)(m_realloc((parser->result_stack), sizeof(mp_parse_node_t) * (parser->result_stack_alloc + (16))))); - parser->result_stack = stack; - parser->result_stack_alloc += (16); - } - parser->result_stack[parser->result_stack_top++] = pn; -} - -static mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) { - mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_obj_t)); - pn->source_line = src_line; - - - - - - - pn->kind_num_nodes = RULE_const_object | (1 << 8); - pn->nodes[0] = (uintptr_t)obj; - - return (mp_parse_node_t)pn; -} - -static void push_result_token(parser_t *parser, const rule_t *rule) { - mp_parse_node_t pn; - mp_lexer_t *lex = parser->lexer; - if (lex->tok_kind == MP_TOKEN_NAME) { - qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len); -# 393 "user/mpy/py/parse.c" - (void)rule; - pn = mp_parse_node_new_leaf((0x02), id); - - } else if (lex->tok_kind == MP_TOKEN_INTEGER) { - mp_obj_t o = mp_parse_num_integer(lex->vstr.buf, lex->vstr.len, 0, lex); - if (MP_OBJ_IS_SMALL_INT(o)) { - pn = mp_parse_node_new_small_int((((mp_int_t)(o)) >> 1)); - } else { - pn = make_node_const_object(parser, lex->tok_line, o); - } - } else if (lex->tok_kind == MP_TOKEN_FLOAT_OR_IMAG) { - mp_obj_t o = mp_parse_num_decimal(lex->vstr.buf, lex->vstr.len, -# 404 "user/mpy/py/parse.c" 3 4 - 1 -# 404 "user/mpy/py/parse.c" - , -# 404 "user/mpy/py/parse.c" 3 4 - 0 -# 404 "user/mpy/py/parse.c" - , lex); - pn = make_node_const_object(parser, lex->tok_line, o); - } else if (lex->tok_kind == MP_TOKEN_STRING || lex->tok_kind == MP_TOKEN_BYTES) { - - - qstr qst = MP_QSTR_NULL; - if (lex->vstr.len <= (10)) { - - qst = qstr_from_strn(lex->vstr.buf, lex->vstr.len); - } else { - - qst = qstr_find_strn(lex->vstr.buf, lex->vstr.len); - } - if (qst != MP_QSTR_NULL) { - - pn = mp_parse_node_new_leaf(lex->tok_kind == MP_TOKEN_STRING ? (0x06) : (0x0a), qst); - } else { - - mp_obj_t o = mp_obj_new_str_of_type( - lex->tok_kind == MP_TOKEN_STRING ? &mp_type_str : &mp_type_bytes, - (const byte*)lex->vstr.buf, lex->vstr.len); - pn = make_node_const_object(parser, lex->tok_line, o); - } - } else { - pn = mp_parse_node_new_leaf((0x0e), lex->tok_kind); - } - push_result_node(parser, pn); -} -# 447 "user/mpy/py/parse.c" -static void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args); - - -static -# 450 "user/mpy/py/parse.c" 3 4 - _Bool -# 450 "user/mpy/py/parse.c" - fold_logical_constants(parser_t *parser, const rule_t *rule, size_t *num_args) { - if (rule->rule_id == RULE_or_test - || rule->rule_id == RULE_and_test) { - - size_t copy_to = *num_args; - for (size_t i = copy_to; i > 0;) { - mp_parse_node_t pn = peek_result(parser, --i); - parser->result_stack[parser->result_stack_top - copy_to] = pn; - if (i == 0) { - - break; - } - if (rule->rule_id == RULE_or_test) { - if (mp_parse_node_is_const_true(pn)) { - - break; - } else if (!mp_parse_node_is_const_false(pn)) { - copy_to -= 1; - } - } else { - - if (mp_parse_node_is_const_false(pn)) { - break; - } else if (!mp_parse_node_is_const_true(pn)) { - copy_to -= 1; - } - } - } - copy_to -= 1; - - - for (size_t i = 0; i < copy_to; ++i) { - pop_result(parser); - } - *num_args -= copy_to; - - - return *num_args == 1; - - } else if (rule->rule_id == RULE_not_test_2) { - - mp_parse_node_t pn = peek_result(parser, 0); - if (mp_parse_node_is_const_false(pn)) { - pn = mp_parse_node_new_leaf((0x0e), MP_TOKEN_KW_TRUE); - } else if (mp_parse_node_is_const_true(pn)) { - pn = mp_parse_node_new_leaf((0x0e), MP_TOKEN_KW_FALSE); - } else { - return -# 497 "user/mpy/py/parse.c" 3 4 - 0 -# 497 "user/mpy/py/parse.c" - ; - } - pop_result(parser); - push_result_node(parser, pn); - return -# 501 "user/mpy/py/parse.c" 3 4 - 1 -# 501 "user/mpy/py/parse.c" - ; - } - - return -# 504 "user/mpy/py/parse.c" 3 4 - 0 -# 504 "user/mpy/py/parse.c" - ; -} - -static -# 507 "user/mpy/py/parse.c" 3 4 - _Bool -# 507 "user/mpy/py/parse.c" - fold_constants(parser_t *parser, const rule_t *rule, size_t num_args) { - - - - mp_obj_t arg0; - if (rule->rule_id == RULE_expr - || rule->rule_id == RULE_xor_expr - || rule->rule_id == RULE_and_expr) { - - mp_parse_node_t pn = peek_result(parser, num_args - 1); - if (!mp_parse_node_get_int_maybe(pn, &arg0)) { - return -# 518 "user/mpy/py/parse.c" 3 4 - 0 -# 518 "user/mpy/py/parse.c" - ; - } - mp_binary_op_t op; - if (rule->rule_id == RULE_expr) { - op = MP_BINARY_OP_OR; - } else if (rule->rule_id == RULE_xor_expr) { - op = MP_BINARY_OP_XOR; - } else { - op = MP_BINARY_OP_AND; - } - for (ssize_t i = num_args - 2; i >= 0; --i) { - pn = peek_result(parser, i); - mp_obj_t arg1; - if (!mp_parse_node_get_int_maybe(pn, &arg1)) { - return -# 532 "user/mpy/py/parse.c" 3 4 - 0 -# 532 "user/mpy/py/parse.c" - ; - } - arg0 = mp_binary_op(op, arg0, arg1); - } - } else if (rule->rule_id == RULE_shift_expr - || rule->rule_id == RULE_arith_expr - || rule->rule_id == RULE_term) { - - mp_parse_node_t pn = peek_result(parser, num_args - 1); - if (!mp_parse_node_get_int_maybe(pn, &arg0)) { - return -# 542 "user/mpy/py/parse.c" 3 4 - 0 -# 542 "user/mpy/py/parse.c" - ; - } - for (ssize_t i = num_args - 2; i >= 1; i -= 2) { - pn = peek_result(parser, i - 1); - mp_obj_t arg1; - if (!mp_parse_node_get_int_maybe(pn, &arg1)) { - return -# 548 "user/mpy/py/parse.c" 3 4 - 0 -# 548 "user/mpy/py/parse.c" - ; - } - mp_token_kind_t tok = (((uintptr_t)(peek_result(parser, i))) >> 4); - static const uint8_t token_to_op[] = { - MP_BINARY_OP_ADD, - MP_BINARY_OP_SUBTRACT, - MP_BINARY_OP_MULTIPLY, - 255, - 255, - MP_BINARY_OP_FLOOR_DIVIDE, - MP_BINARY_OP_MODULO, - 255, - MP_BINARY_OP_LSHIFT, - 255, - MP_BINARY_OP_RSHIFT, - }; - mp_binary_op_t op = token_to_op[tok - MP_TOKEN_OP_PLUS]; - if (op == (mp_binary_op_t)255) { - return -# 566 "user/mpy/py/parse.c" 3 4 - 0 -# 566 "user/mpy/py/parse.c" - ; - } - int rhs_sign = mp_obj_int_sign(arg1); - if (op <= MP_BINARY_OP_RSHIFT) { - - if (rhs_sign < 0) { - return -# 572 "user/mpy/py/parse.c" 3 4 - 0 -# 572 "user/mpy/py/parse.c" - ; - } - } else if (op >= MP_BINARY_OP_FLOOR_DIVIDE) { - - if (rhs_sign == 0) { - return -# 577 "user/mpy/py/parse.c" 3 4 - 0 -# 577 "user/mpy/py/parse.c" - ; - } - } - arg0 = mp_binary_op(op, arg0, arg1); - } - } else if (rule->rule_id == RULE_factor_2) { - - mp_parse_node_t pn = peek_result(parser, 0); - if (!mp_parse_node_get_int_maybe(pn, &arg0)) { - return -# 586 "user/mpy/py/parse.c" 3 4 - 0 -# 586 "user/mpy/py/parse.c" - ; - } - mp_token_kind_t tok = (((uintptr_t)(peek_result(parser, 1))) >> 4); - mp_unary_op_t op; - if (tok == MP_TOKEN_OP_PLUS) { - op = MP_UNARY_OP_POSITIVE; - } else if (tok == MP_TOKEN_OP_MINUS) { - op = MP_UNARY_OP_NEGATIVE; - } else { - -# 595 "user/mpy/py/parse.c" 3 - (( -# 595 "user/mpy/py/parse.c" - tok == MP_TOKEN_OP_TILDE -# 595 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 595, __func__, -# 595 "user/mpy/py/parse.c" - "tok == MP_TOKEN_OP_TILDE" -# 595 "user/mpy/py/parse.c" 3 - )) -# 595 "user/mpy/py/parse.c" - ; - op = MP_UNARY_OP_INVERT; - } - arg0 = mp_unary_op(op, arg0); -# 681 "user/mpy/py/parse.c" - } else { - return -# 682 "user/mpy/py/parse.c" 3 4 - 0 -# 682 "user/mpy/py/parse.c" - ; - } - - - - for (size_t i = num_args; i > 0; i--) { - pop_result(parser); - } - if (MP_OBJ_IS_SMALL_INT(arg0)) { - push_result_node(parser, mp_parse_node_new_small_int((((mp_int_t)(arg0)) >> 1))); - } else { - - push_result_node(parser, make_node_const_object(parser, 0, arg0)); - } - - return -# 697 "user/mpy/py/parse.c" 3 4 - 1 -# 697 "user/mpy/py/parse.c" - ; -} - - -static void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args) { - - if (rule->rule_id == RULE_atom_paren) { - - mp_parse_node_t pn = peek_result(parser, 0); - if (((pn) == (0))) { - - } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (RULE_testlist_comp))) { - - } else { - - return; - } - } - - - if (fold_logical_constants(parser, rule, &num_args)) { - - return; - } - if (fold_constants(parser, rule, num_args)) { - - return; - } - - - mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * num_args); - pn->source_line = src_line; - pn->kind_num_nodes = (rule->rule_id & 0xff) | (num_args << 8); - for (size_t i = num_args; i > 0; i--) { - pn->nodes[i - 1] = pop_result(parser); - } - push_result_node(parser, (mp_parse_node_t)pn); -} - -mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { - - - - parser_t parser; - - parser.rule_stack_alloc = (64); - parser.rule_stack_top = 0; - parser.rule_stack = ((rule_stack_t*)(m_malloc(sizeof(rule_stack_t) * (parser.rule_stack_alloc)))); - - parser.result_stack_alloc = (32); - parser.result_stack_top = 0; - parser.result_stack = ((mp_parse_node_t*)(m_malloc(sizeof(mp_parse_node_t) * (parser.result_stack_alloc)))); - - parser.lexer = lex; - - parser.tree.chunk = -# 752 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 752 "user/mpy/py/parse.c" - ; - parser.cur_chunk = -# 753 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 753 "user/mpy/py/parse.c" - ; - - - - - - - size_t top_level_rule; - switch (input_kind) { - case MP_PARSE_SINGLE_INPUT: top_level_rule = RULE_single_input; break; - case MP_PARSE_EVAL_INPUT: top_level_rule = RULE_eval_input; break; - default: top_level_rule = RULE_file_input; - } - push_rule(&parser, lex->tok_line, rules[top_level_rule], 0); - - - - size_t n, i; - size_t rule_src_line; - -# 772 "user/mpy/py/parse.c" 3 4 - _Bool -# 772 "user/mpy/py/parse.c" - backtrack = -# 772 "user/mpy/py/parse.c" 3 4 - 0 -# 772 "user/mpy/py/parse.c" - ; - const rule_t *rule = -# 773 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 773 "user/mpy/py/parse.c" - ; - - for (;;) { - next_rule: - if (parser.rule_stack_top == 0) { - break; - } - - pop_rule(&parser, &rule, &i, &rule_src_line); - n = rule->act & (0x0f); -# 793 "user/mpy/py/parse.c" - switch (rule->act & (0x30)) { - case (0x10): - if (i > 0 && !backtrack) { - goto next_rule; - } else { - backtrack = -# 798 "user/mpy/py/parse.c" 3 4 - 0 -# 798 "user/mpy/py/parse.c" - ; - } - for (; i < n; ++i) { - uint16_t kind = rule->arg[i] & (0xf000); - if (kind == (0x1000)) { - if (lex->tok_kind == (rule->arg[i] & (0x0fff))) { - push_result_token(&parser, rule); - mp_lexer_to_next(lex); - goto next_rule; - } - } else { - -# 809 "user/mpy/py/parse.c" 3 - (( -# 809 "user/mpy/py/parse.c" - kind == (0x2000) -# 809 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 809, __func__, -# 809 "user/mpy/py/parse.c" - "kind == RULE_ARG_RULE" -# 809 "user/mpy/py/parse.c" 3 - )) -# 809 "user/mpy/py/parse.c" - ; - if (i + 1 < n) { - push_rule(&parser, rule_src_line, rule, i + 1); - } - push_rule_from_arg(&parser, rule->arg[i]); - goto next_rule; - } - } - backtrack = -# 817 "user/mpy/py/parse.c" 3 4 - 1 -# 817 "user/mpy/py/parse.c" - ; - break; - - case (0x20): { - - - if (backtrack) { - -# 824 "user/mpy/py/parse.c" 3 - (( -# 824 "user/mpy/py/parse.c" - i > 0 -# 824 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 824, __func__, -# 824 "user/mpy/py/parse.c" - "i > 0" -# 824 "user/mpy/py/parse.c" 3 - )) -# 824 "user/mpy/py/parse.c" - ; - if ((rule->arg[i - 1] & (0xf000)) == (0x3000)) { - - push_result_node(&parser, (0)); - backtrack = -# 828 "user/mpy/py/parse.c" 3 4 - 0 -# 828 "user/mpy/py/parse.c" - ; - } else { - - if (i > 1) { - - goto syntax_error; - } else { - goto next_rule; - } - } - } - - - for (; i < n; ++i) { - if ((rule->arg[i] & (0xf000)) == (0x1000)) { - - mp_token_kind_t tok_kind = rule->arg[i] & (0x0fff); - if (lex->tok_kind == tok_kind) { - - if (tok_kind == MP_TOKEN_NAME) { - push_result_token(&parser, rule); - } - mp_lexer_to_next(lex); - } else { - - if (i > 0) { - - goto syntax_error; - } else { - - backtrack = -# 858 "user/mpy/py/parse.c" 3 4 - 1 -# 858 "user/mpy/py/parse.c" - ; - goto next_rule; - } - } - } else { - push_rule(&parser, rule_src_line, rule, i + 1); - push_rule_from_arg(&parser, rule->arg[i]); - goto next_rule; - } - } - - -# 869 "user/mpy/py/parse.c" 3 - (( -# 869 "user/mpy/py/parse.c" - i == n -# 869 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 869, __func__, -# 869 "user/mpy/py/parse.c" - "i == n" -# 869 "user/mpy/py/parse.c" 3 - )) -# 869 "user/mpy/py/parse.c" - ; - - - - - - if (input_kind != MP_PARSE_SINGLE_INPUT && rule->rule_id == RULE_expr_stmt && peek_result(&parser, 0) == (0)) { - mp_parse_node_t p = peek_result(&parser, 1); - if ((((p) & 3) && !(((p) & 0x0f) == (0x02))) - || ((p) != (0) && ((p) & 3) == 0 && (((mp_parse_node_struct_t*)(p))->kind_num_nodes & 0xff) == (RULE_const_object))) { - pop_result(&parser); - pop_result(&parser); - - - - push_result_rule(&parser, rule_src_line, rules[RULE_pass_stmt], 0); - break; - } - } - - - - i = 0; - size_t num_not_nil = 0; - for (size_t x = n; x > 0;) { - --x; - if ((rule->arg[x] & (0xf000)) == (0x1000)) { - mp_token_kind_t tok_kind = rule->arg[x] & (0x0fff); - if (tok_kind == MP_TOKEN_NAME) { - - i += 1; - num_not_nil += 1; - } - } else { - - if (peek_result(&parser, i) != (0)) { - num_not_nil += 1; - } - i += 1; - } - } - - if (num_not_nil == 1 && (rule->act & (0x40))) { - - mp_parse_node_t pn = (0); - for (size_t x = 0; x < i; ++x) { - mp_parse_node_t pn2 = pop_result(&parser); - if (pn2 != (0)) { - pn = pn2; - } - } - push_result_node(&parser, pn); - } else { - - - if (rule->act & (0x80)) { - - push_result_node(&parser, (0)); - i += 1; - } - - push_result_rule(&parser, rule_src_line, rule, i); - } - break; - } - - default: { - -# 936 "user/mpy/py/parse.c" 3 - (( -# 936 "user/mpy/py/parse.c" - (rule->act & (0x30)) == (0x30) -# 936 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 936, __func__, -# 936 "user/mpy/py/parse.c" - "(rule->act & RULE_ACT_KIND_MASK) == RULE_ACT_LIST" -# 936 "user/mpy/py/parse.c" 3 - )) -# 936 "user/mpy/py/parse.c" - ; - - - - - -# 941 "user/mpy/py/parse.c" 3 4 - _Bool -# 941 "user/mpy/py/parse.c" - had_trailing_sep; - if (backtrack) { - list_backtrack: - had_trailing_sep = -# 944 "user/mpy/py/parse.c" 3 4 - 0 -# 944 "user/mpy/py/parse.c" - ; - if (n == 2) { - if (i == 1) { - - goto next_rule; - } else { - - backtrack = -# 951 "user/mpy/py/parse.c" 3 4 - 0 -# 951 "user/mpy/py/parse.c" - ; - } - } else { - if (i == 1) { - - goto next_rule; - } else if ((i & 1) == 1) { - - if (n == 3) { - - had_trailing_sep = -# 961 "user/mpy/py/parse.c" 3 4 - 1 -# 961 "user/mpy/py/parse.c" - ; - backtrack = -# 962 "user/mpy/py/parse.c" 3 4 - 0 -# 962 "user/mpy/py/parse.c" - ; - } else { - - goto syntax_error; - } - } else { - - backtrack = -# 969 "user/mpy/py/parse.c" 3 4 - 0 -# 969 "user/mpy/py/parse.c" - ; - } - } - } else { - for (;;) { - size_t arg = rule->arg[i & 1 & n]; - if ((arg & (0xf000)) == (0x1000)) { - if (lex->tok_kind == (arg & (0x0fff))) { - if (i & 1 & n) { - - } else { - push_result_token(&parser, rule); - } - mp_lexer_to_next(lex); - - i += 1; - } else { - - i += 1; - backtrack = -# 988 "user/mpy/py/parse.c" 3 4 - 1 -# 988 "user/mpy/py/parse.c" - ; - goto list_backtrack; - } - } else { - -# 992 "user/mpy/py/parse.c" 3 - (( -# 992 "user/mpy/py/parse.c" - (arg & (0xf000)) == (0x2000) -# 992 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 992, __func__, -# 992 "user/mpy/py/parse.c" - "(arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE" -# 992 "user/mpy/py/parse.c" 3 - )) -# 992 "user/mpy/py/parse.c" - ; - push_rule(&parser, rule_src_line, rule, i + 1); - push_rule_from_arg(&parser, arg); - goto next_rule; - } - } - } - -# 999 "user/mpy/py/parse.c" 3 - (( -# 999 "user/mpy/py/parse.c" - i >= 1 -# 999 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 999, __func__, -# 999 "user/mpy/py/parse.c" - "i >= 1" -# 999 "user/mpy/py/parse.c" 3 - )) -# 999 "user/mpy/py/parse.c" - ; - - - i -= 1; - if ((n & 1) && (rule->arg[1] & (0xf000)) == (0x1000)) { - - i = (i + 1) / 2; - } - - if (i == 1) { - - if (had_trailing_sep) { - - push_result_rule(&parser, rule_src_line, rule, i); - } else { - - } - } else { - push_result_rule(&parser, rule_src_line, rule, i); - } - break; - } - } - } - - - - - - - if (parser.cur_chunk != -# 1029 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 1029 "user/mpy/py/parse.c" - ) { - (void)((byte*)(m_realloc_maybe((parser.cur_chunk), sizeof(byte) * (sizeof(mp_parse_chunk_t) + parser.cur_chunk->union_.used), ( -# 1030 "user/mpy/py/parse.c" 3 4 - 0 -# 1030 "user/mpy/py/parse.c" - )))) - - - ; - parser.cur_chunk->alloc = parser.cur_chunk->union_.used; - parser.cur_chunk->union_.next = parser.tree.chunk; - parser.tree.chunk = parser.cur_chunk; - } - - if ( - lex->tok_kind != MP_TOKEN_END - || parser.result_stack_top == 0 - ) { - syntax_error:; - mp_obj_t exc; - if (lex->tok_kind == MP_TOKEN_INDENT) { - exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - "unexpected indent"); - } else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) { - exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - "unindent does not match any outer indentation level"); - } else { - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - "invalid syntax"); - } - - - mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); - nlr_jump(((void*)exc)); - } - - - -# 1062 "user/mpy/py/parse.c" 3 - (( -# 1062 "user/mpy/py/parse.c" - parser.result_stack_top == 1 -# 1062 "user/mpy/py/parse.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/parse.c", 1062, __func__, -# 1062 "user/mpy/py/parse.c" - "parser.result_stack_top == 1" -# 1062 "user/mpy/py/parse.c" 3 - )) -# 1062 "user/mpy/py/parse.c" - ; - parser.tree.root = parser.result_stack[0]; - - - ((void)(parser.rule_stack_alloc), m_free(parser.rule_stack)); - ((void)(parser.result_stack_alloc), m_free(parser.result_stack)); - - - mp_lexer_free(lex); - - return parser.tree; -} - -void mp_parse_tree_clear(mp_parse_tree_t *tree) { - mp_parse_chunk_t *chunk = tree->chunk; - while (chunk != -# 1077 "user/mpy/py/parse.c" 3 4 - ((void *)0) -# 1077 "user/mpy/py/parse.c" - ) { - mp_parse_chunk_t *next = chunk->union_.next; - ((void)(sizeof(mp_parse_chunk_t) + chunk->alloc), m_free(chunk)); - chunk = next; - } -} -# 1 "user/mpy/py/scope.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/scope.c" -# 27 "user/mpy/py/scope.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/scope.c" 2 - -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 30 "user/mpy/py/parse.h" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 31 "user/mpy/py/parse.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 - -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 33 "user/mpy/py/parse.h" 2 - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 30 "user/mpy/py/scope.c" 2 - - - - -static const uint8_t scope_simple_name_table[] = { - [SCOPE_MODULE] = MP_QSTR__lt_module_gt_, - [SCOPE_LAMBDA] = MP_QSTR__lt_lambda_gt_, - [SCOPE_LIST_COMP] = MP_QSTR__lt_listcomp_gt_, - [SCOPE_DICT_COMP] = MP_QSTR__lt_dictcomp_gt_, - [SCOPE_SET_COMP] = MP_QSTR__lt_setcomp_gt_, - [SCOPE_GEN_EXPR] = MP_QSTR__lt_genexpr_gt_, -}; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options) { - scope_t *scope = ((scope_t*)(m_malloc0(sizeof(scope_t) * (1)))); - scope->kind = kind; - scope->pn = pn; - scope->source_file = source_file; - if (kind == SCOPE_FUNCTION || kind == SCOPE_CLASS) { - -# 49 "user/mpy/py/scope.c" 3 - (( -# 49 "user/mpy/py/scope.c" - ((pn) != (0) && ((pn) & 3) == 0) -# 49 "user/mpy/py/scope.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 49, __func__, -# 49 "user/mpy/py/scope.c" - "MP_PARSE_NODE_IS_STRUCT(pn)" -# 49 "user/mpy/py/scope.c" 3 - )) -# 49 "user/mpy/py/scope.c" - ; - scope->simple_name = (((uintptr_t)(((mp_parse_node_struct_t*)pn)->nodes[0])) >> 4); - } else { - scope->simple_name = scope_simple_name_table[kind]; - } - scope->raw_code = mp_emit_glue_new_raw_code(); - scope->emit_options = emit_options; - scope->id_info_alloc = (4); - scope->id_info = ((id_info_t*)(m_malloc(sizeof(id_info_t) * (scope->id_info_alloc)))); - - return scope; -} - -void scope_free(scope_t *scope) { - ((void)(scope->id_info_alloc), m_free(scope->id_info)); - ((void)(1), m_free(scope)); -} - -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qst, -# 67 "user/mpy/py/scope.c" 3 4 - _Bool -# 67 "user/mpy/py/scope.c" - *added) { - id_info_t *id_info = scope_find(scope, qst); - if (id_info != -# 69 "user/mpy/py/scope.c" 3 4 - ((void *)0) -# 69 "user/mpy/py/scope.c" - ) { - *added = -# 70 "user/mpy/py/scope.c" 3 4 - 0 -# 70 "user/mpy/py/scope.c" - ; - return id_info; - } - - - if (scope->id_info_len >= scope->id_info_alloc) { - scope->id_info = ((id_info_t*)(m_realloc((scope->id_info), sizeof(id_info_t) * (scope->id_info_alloc + (6))))); - scope->id_info_alloc += (6); - } - - - - - id_info = &scope->id_info[scope->id_info_len++]; - - id_info->kind = 0; - id_info->flags = 0; - id_info->local_num = 0; - id_info->qst = qst; - *added = -# 89 "user/mpy/py/scope.c" 3 4 - 1 -# 89 "user/mpy/py/scope.c" - ; - return id_info; -} - -id_info_t *scope_find(scope_t *scope, qstr qst) { - for (mp_uint_t i = 0; i < scope->id_info_len; i++) { - if (scope->id_info[i].qst == qst) { - return &scope->id_info[i]; - } - } - return -# 99 "user/mpy/py/scope.c" 3 4 - ((void *)0) -# 99 "user/mpy/py/scope.c" - ; -} - -id_info_t *scope_find_global(scope_t *scope, qstr qst) { - while (scope->parent != -# 103 "user/mpy/py/scope.c" 3 4 - ((void *)0) -# 103 "user/mpy/py/scope.c" - ) { - scope = scope->parent; - } - return scope_find(scope, qst); -} - -static void scope_close_over_in_parents(scope_t *scope, qstr qst) { - -# 110 "user/mpy/py/scope.c" 3 - (( -# 110 "user/mpy/py/scope.c" - scope->parent != -# 110 "user/mpy/py/scope.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 110, __func__, -# 110 "user/mpy/py/scope.c" - "scope->parent != NULL" -# 110 "user/mpy/py/scope.c" 3 - )) -# 110 "user/mpy/py/scope.c" - ; - for (scope_t *s = scope->parent;; s = s->parent) { - -# 112 "user/mpy/py/scope.c" 3 - (( -# 112 "user/mpy/py/scope.c" - s->parent != -# 112 "user/mpy/py/scope.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 112, __func__, -# 112 "user/mpy/py/scope.c" - "s->parent != NULL" -# 112 "user/mpy/py/scope.c" 3 - )) -# 112 "user/mpy/py/scope.c" - ; - -# 113 "user/mpy/py/scope.c" 3 4 - _Bool -# 113 "user/mpy/py/scope.c" - added; - id_info_t *id = scope_find_or_add_id(s, qst, &added); - if (added) { - - id->kind = ID_INFO_KIND_FREE; - } else { - - if (id->kind == ID_INFO_KIND_LOCAL) { - - id->kind = ID_INFO_KIND_CELL; - } else { - - - -# 126 "user/mpy/py/scope.c" 3 - (( -# 126 "user/mpy/py/scope.c" - id->kind == ID_INFO_KIND_FREE || id->kind == ID_INFO_KIND_CELL -# 126 "user/mpy/py/scope.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/scope.c", 126, __func__, -# 126 "user/mpy/py/scope.c" - "id->kind == ID_INFO_KIND_FREE || id->kind == ID_INFO_KIND_CELL" -# 126 "user/mpy/py/scope.c" 3 - )) -# 126 "user/mpy/py/scope.c" - ; - } - return; - } - } -} - -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst) { - if (scope->parent != -# 134 "user/mpy/py/scope.c" 3 4 - ((void *)0) -# 134 "user/mpy/py/scope.c" - ) { - for (scope_t *s = scope->parent; s->parent != -# 135 "user/mpy/py/scope.c" 3 4 - ((void *)0) -# 135 "user/mpy/py/scope.c" - ; s = s->parent) { - id_info_t *id2 = scope_find(s, qst); - if (id2 != -# 137 "user/mpy/py/scope.c" 3 4 - ((void *)0) -# 137 "user/mpy/py/scope.c" - ) { - if (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE) { - id->kind = ID_INFO_KIND_FREE; - scope_close_over_in_parents(scope, qst); - return; - } - break; - } - } - } - id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; -} -# 1 "user/mpy/py/compile.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/compile.c" -# 27 "user/mpy/py/compile.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 28 "user/mpy/py/compile.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 29 "user/mpy/py/compile.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 30 "user/mpy/py/compile.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/compile.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/compile.c" 2 - -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 35 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 33 "user/mpy/py/parse.h" 2 - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 34 "user/mpy/py/compile.c" 2 -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 - -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 35 "user/mpy/py/compile.c" 2 -# 1 "user/mpy/py/compile.h" 1 -# 34 "user/mpy/py/compile.h" -enum { - MP_EMIT_OPT_NONE, - MP_EMIT_OPT_BYTECODE, - MP_EMIT_OPT_NATIVE_PYTHON, - MP_EMIT_OPT_VIPER, - MP_EMIT_OPT_ASM, -}; - - - -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, -# 44 "user/mpy/py/compile.h" 3 4 - _Bool -# 44 "user/mpy/py/compile.h" - is_repl); - - - - - - - -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); -# 36 "user/mpy/py/compile.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/compile.c" 2 -# 1 "user/mpy/py/asmbase.h" 1 -# 35 "user/mpy/py/asmbase.h" -typedef struct _mp_asm_base_t { - int pass; - size_t code_offset; - size_t code_size; - uint8_t *code_base; - - size_t max_num_labels; - size_t *label_offsets; -} mp_asm_base_t; - -void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); -void mp_asm_base_deinit(mp_asm_base_t *as, -# 46 "user/mpy/py/asmbase.h" 3 4 - _Bool -# 46 "user/mpy/py/asmbase.h" - free_code); -void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); -uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); -void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); -void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); -void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); - -static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { - return as->code_offset; -} - -static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { - return as->code_size; -} - -static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { - - - - return as->code_base; - -} -# 38 "user/mpy/py/compile.c" 2 - - - - - - - -typedef enum { - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" - -PN_file_input, -PN_file_input_2, - - - -# 58 "user/mpy/py/grammar.h" - - -PN_decorated, - - - - - - -PN_funcdef, - - - - - - - - - - - - - - - - - - - - - - - - - - -PN_simple_stmt_2, - - - - - - - - -PN_expr_stmt, - - - - - -PN_testlist_star_expr, - - -# 122 "user/mpy/py/grammar.h" -PN_del_stmt, -PN_pass_stmt, - -PN_break_stmt, -PN_continue_stmt, -PN_return_stmt, -PN_yield_stmt, -PN_raise_stmt, - - -# 145 "user/mpy/py/grammar.h" - -PN_import_name, -PN_import_from, - - - - - - - - - - - - -PN_global_stmt, -PN_nonlocal_stmt, - -PN_assert_stmt, - -# 183 "user/mpy/py/grammar.h" - - -PN_if_stmt, - - -PN_while_stmt, -PN_for_stmt, -PN_try_stmt, - - - - - - - -PN_with_stmt, - - - - - -PN_suite_block_stmts, - - - - - - - -PN_test_if_expr, - - -PN_lambdef, -PN_lambdef_nocond, -# 234 "user/mpy/py/grammar.h" -PN_or_test, -PN_and_test, - -PN_not_test_2, -PN_comparison, - - - - -PN_star_expr, -PN_expr, -PN_xor_expr, -PN_and_expr, -PN_shift_expr, - -PN_arith_expr, - -PN_term, - - -PN_factor_2, - -PN_power, - - - - - - -PN_atom_expr_normal, - - - - - - - - -PN_atom_paren, - -PN_atom_bracket, -PN_atom_brace, - - - - - - -PN_trailer_paren, -PN_trailer_bracket, -PN_trailer_period, -# 300 "user/mpy/py/grammar.h" -PN_subscriptlist, - - - - - - - - -PN_testlist, - - - - - - -PN_dictorsetmaker_item, - - - - - - - -PN_classdef, - - - - - - - - - -# 342 "user/mpy/py/grammar.h" - - - - - - - - - - - - - -PN_yield_expr, - - -# 50 "user/mpy/py/compile.c" 2 - - - PN_const_object, - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" -PN_single_input, - - -PN_file_input_3, -PN_eval_input, -PN_eval_input_2, -# 58 "user/mpy/py/grammar.h" -PN_decorator, -PN_decorators, - - - - - -PN_decorated_body, - - -PN_funcdefrettype, - -PN_typedargslist, -PN_typedargslist_item, -PN_typedargslist_name, -PN_typedargslist_star, -PN_typedargslist_dbl_star, -PN_typedargslist_colon, -PN_typedargslist_equal, -PN_tfpdef, - -PN_varargslist, -PN_varargslist_item, -PN_varargslist_name, -PN_varargslist_star, -PN_varargslist_dbl_star, -PN_varargslist_equal, -PN_vfpdef, - - - -PN_stmt, - - - -PN_simple_stmt, - - - - - - - - -PN_small_stmt, - -PN_expr_stmt_2, -PN_expr_stmt_augassign, -PN_expr_stmt_assign_list, -PN_expr_stmt_assign, -PN_expr_stmt_6, - -PN_testlist_star_expr_2, -PN_augassign, -# 122 "user/mpy/py/grammar.h" - - -PN_flow_stmt, - - - - - -PN_raise_stmt_arg, -PN_raise_stmt_from, -# 145 "user/mpy/py/grammar.h" -PN_import_stmt, - - -PN_import_from_2, -PN_import_from_2b, -PN_import_from_3, -PN_import_as_names_paren, -PN_one_or_more_period_or_ellipsis, -PN_period_or_ellipsis, -PN_import_as_name, -PN_dotted_as_name, -PN_as_name, -PN_import_as_names, -PN_dotted_as_names, -PN_dotted_name, - - -PN_name_list, - -PN_assert_stmt_extra, -# 183 "user/mpy/py/grammar.h" -PN_compound_stmt, - - -PN_if_stmt_elif_list, -PN_if_stmt_elif, - - - -PN_try_stmt_2, -PN_try_stmt_except_and_more, -PN_try_stmt_except, -PN_try_stmt_as_name, -PN_try_stmt_except_list, -PN_try_stmt_finally, -PN_else_stmt, - -PN_with_stmt_list, -PN_with_item, -PN_with_item_as, -PN_suite, -PN_suite_block, - - - - - - - -PN_test, - -PN_test_if_else, -PN_test_nocond, - - -# 234 "user/mpy/py/grammar.h" - - -PN_not_test, - - -PN_comp_op, -PN_comp_op_not_in, -PN_comp_op_is, -PN_comp_op_is_not, - - - - - -PN_shift_op, - -PN_arith_op, - -PN_term_op, -PN_factor, - -PN_factor_op, - - - - - -PN_atom_expr, - - -PN_atom_expr_trailers, -PN_power_dbl_star, - - - - - -PN_atom, - -PN_atom_2b, - - -PN_testlist_comp, -PN_testlist_comp_2, -PN_testlist_comp_3, -PN_testlist_comp_3b, -PN_testlist_comp_3c, -PN_trailer, - - - -# 300 "user/mpy/py/grammar.h" - - - - - - - -PN_exprlist, -PN_exprlist_2, - - -PN_dictorsetmaker, - - - - - - -PN_dictorsetmaker_tail, -PN_dictorsetmaker_list, -PN_dictorsetmaker_list2, - - - - -PN_classdef_2, - - - - -PN_arglist, -PN_arglist_2, -PN_arglist_star, -PN_arglist_dbl_star, -# 342 "user/mpy/py/grammar.h" -PN_argument, -PN_argument_2, -PN_argument_3, -PN_comp_iter, -PN_comp_for, -PN_comp_if, - - - - - - - - -PN_yield_arg, -PN_yield_arg_from, -# 57 "user/mpy/py/compile.c" 2 - - -} pn_kind_t; -# 115 "user/mpy/py/compile.c" -typedef struct _compiler_t { - qstr source_file; - - uint8_t is_repl; - uint8_t pass; - uint8_t have_star; - - - mp_obj_t compile_error; - size_t compile_error_line; - - uint next_label; - - uint16_t num_dict_params; - uint16_t num_default_params; - - uint16_t break_label; - uint16_t continue_label; - uint16_t cur_except_level; - uint16_t break_continue_except_level; - - scope_t *scope_head; - scope_t *scope_cur; - - emit_t *emit; -# 148 "user/mpy/py/compile.c" -} compiler_t; - -static void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) { - - if (comp->compile_error_line == 0 && ((pn) != (0) && ((pn) & 3) == 0)) { - comp->compile_error_line = ((mp_parse_node_struct_t*)pn)->source_line; - } -} - -static void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const char *msg) { - - if (comp->compile_error == (((mp_obj_t)(void*)0))) { - comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); - compile_error_set_line(comp, pn); - } -} - -static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, -# 165 "user/mpy/py/compile.c" 3 4 - _Bool -# 165 "user/mpy/py/compile.c" - is_method_call, int n_positional_extra); -static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind); -static void compile_node(compiler_t *comp, mp_parse_node_t pn); - -static uint comp_next_label(compiler_t *comp) { - return comp->next_label++; -} - -static void compile_increase_except_level(compiler_t *comp) { - comp->cur_except_level += 1; - if (comp->cur_except_level > comp->scope_cur->exc_stack_size) { - comp->scope_cur->exc_stack_size = comp->cur_except_level; - } -} - -static void compile_decrease_except_level(compiler_t *comp) { - -# 181 "user/mpy/py/compile.c" 3 - (( -# 181 "user/mpy/py/compile.c" - comp->cur_except_level > 0 -# 181 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 181, __func__, -# 181 "user/mpy/py/compile.c" - "comp->cur_except_level > 0" -# 181 "user/mpy/py/compile.c" 3 - )) -# 181 "user/mpy/py/compile.c" - ; - comp->cur_except_level -= 1; -} - -static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) { - scope_t *scope = scope_new(kind, pn, comp->source_file, emit_options); - scope->parent = comp->scope_cur; - scope->next = -# 188 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 188 "user/mpy/py/compile.c" - ; - if (comp->scope_head == -# 189 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 189 "user/mpy/py/compile.c" - ) { - comp->scope_head = scope; - } else { - scope_t *s = comp->scope_head; - while (s->next != -# 193 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 193 "user/mpy/py/compile.c" - ) { - s = s->next; - } - s->next = scope; - } - return scope; -} - -typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn); - -static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) { - if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (pn_list_kind))) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - int num_nodes = ((pns)->kind_num_nodes >> 8); - for (int i = 0; i < num_nodes; i++) { - f(comp, pns->nodes[i]); - } - } else if (!((pn) == (0))) { - f(comp, pn); - } -} - -static void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) { - int num_nodes = ((pns)->kind_num_nodes >> 8); - for (int i = 0; i < num_nodes; i++) { - compile_node(comp, pns->nodes[i]); - if (comp->compile_error != (((mp_obj_t)(void*)0))) { - - compile_error_set_line(comp, pns->nodes[i]); - return; - } - } -} - -static void compile_load_id(compiler_t *comp, qstr qst) { - if (comp->pass == MP_PASS_SCOPE) { - mp_emit_common_get_id_for_load(comp->scope_cur, qst); - } else { - - - - mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_load_id_ops, comp->scope_cur, qst); - - } -} - -static void compile_store_id(compiler_t *comp, qstr qst) { - if (comp->pass == MP_PASS_SCOPE) { - mp_emit_common_get_id_for_modification(comp->scope_cur, qst); - } else { - - - - mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_store_id_ops, comp->scope_cur, qst); - - } -} - -static void compile_delete_id(compiler_t *comp, qstr qst) { - if (comp->pass == MP_PASS_SCOPE) { - mp_emit_common_get_id_for_modification(comp->scope_cur, qst); - } else { - - - - mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_delete_id_ops, comp->scope_cur, qst); - - } -} - -static void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) { - int total = 0; - if (!((pn) == (0))) { - compile_node(comp, pn); - total += 1; - } - if (pns_list != -# 269 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 269 "user/mpy/py/compile.c" - ) { - int n = ((pns_list)->kind_num_nodes >> 8); - for (int i = 0; i < n; i++) { - compile_node(comp, pns_list->nodes[i]); - } - total += n; - } - (mp_emit_bc_build_tuple(comp->emit, total)); -} - -static void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) { - - c_tuple(comp, (0), pns); -} - -static void c_if_cond(compiler_t *comp, mp_parse_node_t pn, -# 284 "user/mpy/py/compile.c" 3 4 - _Bool -# 284 "user/mpy/py/compile.c" - jump_if, int label) { - if (mp_parse_node_is_const_false(pn)) { - if (jump_if == -# 286 "user/mpy/py/compile.c" 3 4 - 0 -# 286 "user/mpy/py/compile.c" - ) { - (mp_emit_bc_jump(comp->emit, label)); - } - return; - } else if (mp_parse_node_is_const_true(pn)) { - if (jump_if == -# 291 "user/mpy/py/compile.c" 3 4 - 1 -# 291 "user/mpy/py/compile.c" - ) { - (mp_emit_bc_jump(comp->emit, label)); - } - return; - } else if (((pn) != (0) && ((pn) & 3) == 0)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - int n = ((pns)->kind_num_nodes >> 8); - if (((pns)->kind_num_nodes & 0xff) == PN_or_test) { - if (jump_if == -# 299 "user/mpy/py/compile.c" 3 4 - 0 -# 299 "user/mpy/py/compile.c" - ) { - and_or_logic1:; - uint label2 = comp_next_label(comp); - for (int i = 0; i < n - 1; i++) { - c_if_cond(comp, pns->nodes[i], !jump_if, label2); - } - c_if_cond(comp, pns->nodes[n - 1], jump_if, label); - (mp_emit_bc_label_assign(comp->emit, label2)); - } else { - and_or_logic2: - for (int i = 0; i < n; i++) { - c_if_cond(comp, pns->nodes[i], jump_if, label); - } - } - return; - } else if (((pns)->kind_num_nodes & 0xff) == PN_and_test) { - if (jump_if == -# 315 "user/mpy/py/compile.c" 3 4 - 0 -# 315 "user/mpy/py/compile.c" - ) { - goto and_or_logic2; - } else { - goto and_or_logic1; - } - } else if (((pns)->kind_num_nodes & 0xff) == PN_not_test_2) { - c_if_cond(comp, pns->nodes[0], !jump_if, label); - return; - } else if (((pns)->kind_num_nodes & 0xff) == PN_atom_paren) { - - if (((pns->nodes[0]) == (0))) { - - if (jump_if == -# 327 "user/mpy/py/compile.c" 3 4 - 0 -# 327 "user/mpy/py/compile.c" - ) { - (mp_emit_bc_jump(comp->emit, label)); - } - } else { - -# 331 "user/mpy/py/compile.c" 3 - (( -# 331 "user/mpy/py/compile.c" - ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp)) -# 331 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 331, __func__, -# 331 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)" -# 331 "user/mpy/py/compile.c" 3 - )) -# 331 "user/mpy/py/compile.c" - ; - - if (jump_if == -# 333 "user/mpy/py/compile.c" 3 4 - 1 -# 333 "user/mpy/py/compile.c" - ) { - (mp_emit_bc_jump(comp->emit, label)); - } - } - return; - } - } - - - compile_node(comp, pn); - (mp_emit_bc_pop_jump_if(comp->emit, jump_if, label)); -} - -typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t; -static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind); - -static void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) { - if (assign_kind != ASSIGN_AUG_STORE) { - compile_node(comp, pns->nodes[0]); - } - - if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns1)->kind_num_nodes & 0xff) == PN_atom_expr_trailers) { - int n = ((pns1)->kind_num_nodes >> 8); - if (assign_kind != ASSIGN_AUG_STORE) { - for (int i = 0; i < n - 1; i++) { - compile_node(comp, pns1->nodes[i]); - } - } - -# 363 "user/mpy/py/compile.c" 3 - (( -# 363 "user/mpy/py/compile.c" - ((pns1->nodes[n - 1]) != (0) && ((pns1->nodes[n - 1]) & 3) == 0) -# 363 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 363, __func__, -# 363 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])" -# 363 "user/mpy/py/compile.c" 3 - )) -# 363 "user/mpy/py/compile.c" - ; - pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; - } - if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_bracket) { - if (assign_kind == ASSIGN_AUG_STORE) { - (mp_emit_bc_rot_three(comp->emit)); - (mp_emit_bc_store_subscr(comp->emit)); - } else { - compile_node(comp, pns1->nodes[0]); - if (assign_kind == ASSIGN_AUG_LOAD) { - (mp_emit_bc_dup_top_two(comp->emit)); - (mp_emit_bc_load_subscr(comp->emit)); - } else { - (mp_emit_bc_store_subscr(comp->emit)); - } - } - } else if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_period) { - -# 380 "user/mpy/py/compile.c" 3 - (( -# 380 "user/mpy/py/compile.c" - (((pns1->nodes[0]) & 0x0f) == (0x02)) -# 380 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 380, __func__, -# 380 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_ID(pns1->nodes[0])" -# 380 "user/mpy/py/compile.c" 3 - )) -# 380 "user/mpy/py/compile.c" - ; - if (assign_kind == ASSIGN_AUG_LOAD) { - (mp_emit_bc_dup_top(comp->emit)); - (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(pns1->nodes[0])) >> 4))); - } else { - if (assign_kind == ASSIGN_AUG_STORE) { - (mp_emit_bc_rot_two(comp->emit)); - } - (mp_emit_bc_store_attr(comp->emit, (((uintptr_t)(pns1->nodes[0])) >> 4))); - } - } else { - goto cannot_assign; - } - } else { - goto cannot_assign; - } - - return; - -cannot_assign: - compile_syntax_error(comp, (mp_parse_node_t)pns, "can't assign to expression"); -} - - -static void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num_tail, mp_parse_node_t *nodes_tail) { - uint num_head = (node_head == (0)) ? 0 : 1; - - - uint have_star_index = -1; - if (num_head != 0 && ((node_head) != (0) && ((node_head) & 3) == 0 && (((mp_parse_node_struct_t*)(node_head))->kind_num_nodes & 0xff) == (PN_star_expr))) { - (mp_emit_bc_unpack_ex(comp->emit, 0, num_tail)); - have_star_index = 0; - } - for (uint i = 0; i < num_tail; i++) { - if (((nodes_tail[i]) != (0) && ((nodes_tail[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(nodes_tail[i]))->kind_num_nodes & 0xff) == (PN_star_expr))) { - if (have_star_index == (uint)-1) { - (mp_emit_bc_unpack_ex(comp->emit, num_head + i, num_tail - i - 1)); - have_star_index = num_head + i; - } else { - compile_syntax_error(comp, nodes_tail[i], "multiple *x in assignment"); - return; - } - } - } - if (have_star_index == (uint)-1) { - (mp_emit_bc_unpack_sequence(comp->emit, num_head + num_tail)); - } - if (num_head != 0) { - if (0 == have_star_index) { - c_assign(comp, ((mp_parse_node_struct_t*)node_head)->nodes[0], ASSIGN_STORE); - } else { - c_assign(comp, node_head, ASSIGN_STORE); - } - } - for (uint i = 0; i < num_tail; i++) { - if (num_head + i == have_star_index) { - c_assign(comp, ((mp_parse_node_struct_t*)nodes_tail[i])->nodes[0], ASSIGN_STORE); - } else { - c_assign(comp, nodes_tail[i], ASSIGN_STORE); - } - } -} - - -static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) { - -# 445 "user/mpy/py/compile.c" 3 - (( -# 445 "user/mpy/py/compile.c" - !((pn) == (0)) -# 445 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 445, __func__, -# 445 "user/mpy/py/compile.c" - "!MP_PARSE_NODE_IS_NULL(pn)" -# 445 "user/mpy/py/compile.c" 3 - )) -# 445 "user/mpy/py/compile.c" - ; - if (((pn) & 3)) { - if ((((pn) & 0x0f) == (0x02))) { - qstr arg = (((uintptr_t)(pn)) >> 4); - switch (assign_kind) { - case ASSIGN_STORE: - case ASSIGN_AUG_STORE: - compile_store_id(comp, arg); - break; - case ASSIGN_AUG_LOAD: - default: - compile_load_id(comp, arg); - break; - } - } else { - goto cannot_assign; - } - } else { - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - switch (((pns)->kind_num_nodes & 0xff)) { - case PN_atom_expr_normal: - - c_assign_atom_expr(comp, pns, assign_kind); - break; - - case PN_testlist_star_expr: - case PN_exprlist: - - if (assign_kind != ASSIGN_STORE) { - goto cannot_assign; - } - c_assign_tuple(comp, (0), ((pns)->kind_num_nodes >> 8), pns->nodes); - break; - - case PN_atom_paren: - - if (((pns->nodes[0]) == (0))) { - - goto cannot_assign; - } else { - -# 486 "user/mpy/py/compile.c" 3 - (( -# 486 "user/mpy/py/compile.c" - ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp)) -# 486 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 486, __func__, -# 486 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)" -# 486 "user/mpy/py/compile.c" 3 - )) -# 486 "user/mpy/py/compile.c" - ; - if (assign_kind != ASSIGN_STORE) { - goto cannot_assign; - } - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - goto testlist_comp; - } - break; - - case PN_atom_bracket: - - if (assign_kind != ASSIGN_STORE) { - goto cannot_assign; - } - if (((pns->nodes[0]) == (0))) { - - c_assign_tuple(comp, (0), 0, -# 502 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 502 "user/mpy/py/compile.c" - ); - } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp))) { - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - goto testlist_comp; - } else { - - c_assign_tuple(comp, pns->nodes[0], 0, -# 508 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 508 "user/mpy/py/compile.c" - ); - } - break; - - default: - goto cannot_assign; - } - return; - - testlist_comp: - - if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { - - -# 523 "user/mpy/py/compile.c" 3 - (( -# 523 "user/mpy/py/compile.c" - ((pns2->nodes[0]) == (0)) -# 523 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 523, __func__, -# 523 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_NULL(pns2->nodes[0])" -# 523 "user/mpy/py/compile.c" 3 - )) -# 523 "user/mpy/py/compile.c" - ; - c_assign_tuple(comp, pns->nodes[0], 0, -# 524 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 524 "user/mpy/py/compile.c" - ); - } else if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { - - uint n = ((pns2)->kind_num_nodes >> 8); - c_assign_tuple(comp, pns->nodes[0], n, pns2->nodes); - } else if (((pns2)->kind_num_nodes & 0xff) == PN_comp_for) { - goto cannot_assign; - } else { - - goto sequence_with_2_items; - } - } else { - - sequence_with_2_items: - c_assign_tuple(comp, (0), 2, pns->nodes); - } - return; - } - return; - - cannot_assign: - compile_syntax_error(comp, pn, "can't assign to expression"); -} - - - - - -static void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) { - -# 553 "user/mpy/py/compile.c" 3 - (( -# 553 "user/mpy/py/compile.c" - n_pos_defaults >= 0 -# 553 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 553, __func__, -# 553 "user/mpy/py/compile.c" - "n_pos_defaults >= 0" -# 553 "user/mpy/py/compile.c" 3 - )) -# 553 "user/mpy/py/compile.c" - ; - -# 554 "user/mpy/py/compile.c" 3 - (( -# 554 "user/mpy/py/compile.c" - n_kw_defaults >= 0 -# 554 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 554, __func__, -# 554 "user/mpy/py/compile.c" - "n_kw_defaults >= 0" -# 554 "user/mpy/py/compile.c" 3 - )) -# 554 "user/mpy/py/compile.c" - ; - - - if (n_kw_defaults > 0) { - this_scope->scope_flags |= (0x08); - } - this_scope->num_def_pos_args = n_pos_defaults; - - - - int nfree = 0; - if (comp->scope_cur->kind != SCOPE_MODULE) { - for (int i = 0; i < comp->scope_cur->id_info_len; i++) { - id_info_t *id = &comp->scope_cur->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { - for (int j = 0; j < this_scope->id_info_len; j++) { - id_info_t *id2 = &this_scope->id_info[j]; - if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { - - (mp_emit_bc_load_fast(comp->emit, id->qst, id->local_num)); - nfree += 1; - } - } - } - } - } - - - if (nfree == 0) { - (mp_emit_bc_make_function(comp->emit, this_scope, n_pos_defaults, n_kw_defaults)); - } else { - (mp_emit_bc_make_closure(comp->emit, this_scope, nfree, n_pos_defaults, n_kw_defaults)); - } -} - -static void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) { - - int pn_kind; - if ((((pn) & 0x0f) == (0x02))) { - pn_kind = -1; - } else { - -# 595 "user/mpy/py/compile.c" 3 - (( -# 595 "user/mpy/py/compile.c" - ((pn) != (0) && ((pn) & 3) == 0) -# 595 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 595, __func__, -# 595 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pn)" -# 595 "user/mpy/py/compile.c" 3 - )) -# 595 "user/mpy/py/compile.c" - ; - pn_kind = (((mp_parse_node_struct_t*)pn)->kind_num_nodes & 0xff); - } - - if (pn_kind == PN_typedargslist_star || pn_kind == PN_varargslist_star) { - comp->have_star = -# 600 "user/mpy/py/compile.c" 3 4 - 1 -# 600 "user/mpy/py/compile.c" - ; -# 610 "user/mpy/py/compile.c" - } else if (pn_kind == PN_typedargslist_dbl_star || pn_kind == PN_varargslist_dbl_star) { - - - - } else { - mp_parse_node_t pn_id; - mp_parse_node_t pn_colon; - mp_parse_node_t pn_equal; - if (pn_kind == -1) { - - - pn_id = pn; - pn_colon = (0); - pn_equal = (0); - - } else if (pn_kind == PN_typedargslist_name) { - - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - pn_id = pns->nodes[0]; - pn_colon = pns->nodes[1]; - pn_equal = pns->nodes[2]; - - } else { - -# 634 "user/mpy/py/compile.c" 3 - (( -# 634 "user/mpy/py/compile.c" - pn_kind == PN_varargslist_name -# 634 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 634, __func__, -# 634 "user/mpy/py/compile.c" - "pn_kind == PN_varargslist_name" -# 634 "user/mpy/py/compile.c" 3 - )) -# 634 "user/mpy/py/compile.c" - ; - - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - pn_id = pns->nodes[0]; - pn_equal = pns->nodes[1]; - } - - if (((pn_equal) == (0))) { - - - - if (!comp->have_star && comp->num_default_params != 0) { - compile_syntax_error(comp, pn, "non-default argument follows default argument"); - return; - } - - } else { - - - - if (comp->have_star) { - comp->num_dict_params += 1; - - if (comp->num_dict_params == 1) { - - - if (comp->num_default_params > 0) { - (mp_emit_bc_build_tuple(comp->emit, comp->num_default_params)); - } else { - (mp_emit_bc_load_null(comp->emit)); - } - - (mp_emit_bc_build_map(comp->emit, 0)); - } - - - compile_node(comp, pn_equal); - (mp_emit_bc_load_const_str(comp->emit, (((uintptr_t)(pn_id)) >> 4))); - (mp_emit_bc_store_map(comp->emit)); - } else { - comp->num_default_params += 1; - compile_node(comp, pn_equal); - } - } - - - (void)pn_colon; - } -} - -static void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) { - - - - -# 689 "user/mpy/py/compile.c" 3 4 - _Bool -# 689 "user/mpy/py/compile.c" - orig_have_star = comp->have_star; - uint16_t orig_num_dict_params = comp->num_dict_params; - uint16_t orig_num_default_params = comp->num_default_params; - - - comp->have_star = -# 694 "user/mpy/py/compile.c" 3 4 - 0 -# 694 "user/mpy/py/compile.c" - ; - comp->num_dict_params = 0; - comp->num_default_params = 0; - apply_to_single_or_list(comp, pn_params, pn_list_kind, compile_funcdef_lambdef_param); - - if (comp->compile_error != (((mp_obj_t)(void*)0))) { - return; - } - - - - if (comp->num_default_params > 0 && comp->num_dict_params == 0) { - (mp_emit_bc_build_tuple(comp->emit, comp->num_default_params)); - (mp_emit_bc_load_null(comp->emit)); - } - - - close_over_variables_etc(comp, scope, comp->num_default_params, comp->num_dict_params); - - - comp->have_star = orig_have_star; - comp->num_dict_params = orig_num_dict_params; - comp->num_default_params = orig_num_default_params; -} - - - -static qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { - if (comp->pass == MP_PASS_SCOPE) { - - scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options); - - pns->nodes[4] = (mp_parse_node_t)s; - } - - - scope_t *fscope = (scope_t*)pns->nodes[4]; - - - compile_funcdef_lambdef(comp, fscope, pns->nodes[1], PN_typedargslist); - - - return fscope->simple_name; -} - - - -static qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { - if (comp->pass == MP_PASS_SCOPE) { - - scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options); - - pns->nodes[3] = (mp_parse_node_t)s; - } - - (mp_emit_bc_load_build_class(comp->emit)); - - - scope_t *cscope = (scope_t*)pns->nodes[3]; - - - close_over_variables_etc(comp, cscope, 0, 0); - - - (mp_emit_bc_load_const_str(comp->emit, cscope->simple_name)); - - - - mp_parse_node_t parents = pns->nodes[1]; - if (((parents) != (0) && ((parents) & 3) == 0 && (((mp_parse_node_struct_t*)(parents))->kind_num_nodes & 0xff) == (PN_classdef_2))) { - parents = (0); - } - compile_trailer_paren_helper(comp, parents, -# 766 "user/mpy/py/compile.c" 3 4 - 0 -# 766 "user/mpy/py/compile.c" - , 2); - - - return cscope->simple_name; -} - - -static -# 773 "user/mpy/py/compile.c" 3 4 - _Bool -# 773 "user/mpy/py/compile.c" - compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_node_t *name_nodes, uint *emit_options) { - if ((((uintptr_t)(name_nodes[0])) >> 4) != MP_QSTR_micropython) { - return -# 775 "user/mpy/py/compile.c" 3 4 - 0 -# 775 "user/mpy/py/compile.c" - ; - } - - if (name_len != 2) { - compile_syntax_error(comp, name_nodes[0], "invalid micropython decorator"); - return -# 780 "user/mpy/py/compile.c" 3 4 - 1 -# 780 "user/mpy/py/compile.c" - ; - } - - qstr attr = (((uintptr_t)(name_nodes[1])) >> 4); - if (attr == MP_QSTR_bytecode) { - *emit_options = MP_EMIT_OPT_BYTECODE; -# 796 "user/mpy/py/compile.c" - } else { - compile_syntax_error(comp, name_nodes[1], "invalid micropython decorator"); - } - - return -# 800 "user/mpy/py/compile.c" 3 4 - 1 -# 800 "user/mpy/py/compile.c" - ; -} - -static void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) { - - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes); - - - uint emit_options = comp->scope_cur->emit_options; - - - int num_built_in_decorators = 0; - for (int i = 0; i < n; i++) { - -# 814 "user/mpy/py/compile.c" 3 - (( -# 814 "user/mpy/py/compile.c" - ((nodes[i]) != (0) && ((nodes[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(nodes[i]))->kind_num_nodes & 0xff) == (PN_decorator)) -# 814 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 814, __func__, -# 814 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(nodes[i], PN_decorator)" -# 814 "user/mpy/py/compile.c" 3 - )) -# 814 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns_decorator = (mp_parse_node_struct_t*)nodes[i]; - - - mp_parse_node_t *name_nodes; - int name_len = mp_parse_node_extract_list(&pns_decorator->nodes[0], PN_dotted_name, &name_nodes); - - - if (compile_built_in_decorator(comp, name_len, name_nodes, &emit_options)) { - - num_built_in_decorators += 1; - - } else { - - - - compile_node(comp, name_nodes[0]); - for (int j = 1; j < name_len; j++) { - -# 832 "user/mpy/py/compile.c" 3 - (( -# 832 "user/mpy/py/compile.c" - (((name_nodes[j]) & 0x0f) == (0x02)) -# 832 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 832, __func__, -# 832 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_ID(name_nodes[j])" -# 832 "user/mpy/py/compile.c" 3 - )) -# 832 "user/mpy/py/compile.c" - ; - (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(name_nodes[j])) >> 4))); - } - - - if (!((pns_decorator->nodes[1]) == (0))) { - - compile_node(comp, pns_decorator->nodes[1]); - } - } - } - - - mp_parse_node_struct_t *pns_body = (mp_parse_node_struct_t*)pns->nodes[1]; - qstr body_name = 0; - if (((pns_body)->kind_num_nodes & 0xff) == PN_funcdef) { - body_name = compile_funcdef_helper(comp, pns_body, emit_options); -# 857 "user/mpy/py/compile.c" - } else { - -# 858 "user/mpy/py/compile.c" 3 - (( -# 858 "user/mpy/py/compile.c" - ((pns_body)->kind_num_nodes & 0xff) == PN_classdef -# 858 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 858, __func__, -# 858 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_classdef" -# 858 "user/mpy/py/compile.c" 3 - )) -# 858 "user/mpy/py/compile.c" - ; - body_name = compile_classdef_helper(comp, pns_body, emit_options); - } - - - for (int i = 0; i < n - num_built_in_decorators; i++) { - (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); - } - - - compile_store_id(comp, body_name); -} - -static void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) { - qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options); - - compile_store_id(comp, fname); -} - -static void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) { - if ((((pn) & 0x0f) == (0x02))) { - compile_delete_id(comp, (((uintptr_t)(pn)) >> 4)); - } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_atom_expr_normal))) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - - compile_node(comp, pns->nodes[0]); - - if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns1)->kind_num_nodes & 0xff) == PN_atom_expr_trailers) { - int n = ((pns1)->kind_num_nodes >> 8); - for (int i = 0; i < n - 1; i++) { - compile_node(comp, pns1->nodes[i]); - } - -# 892 "user/mpy/py/compile.c" 3 - (( -# 892 "user/mpy/py/compile.c" - ((pns1->nodes[n - 1]) != (0) && ((pns1->nodes[n - 1]) & 3) == 0) -# 892 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 892, __func__, -# 892 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])" -# 892 "user/mpy/py/compile.c" 3 - )) -# 892 "user/mpy/py/compile.c" - ; - pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; - } - if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_bracket) { - compile_node(comp, pns1->nodes[0]); - (mp_emit_bc_delete_subscr(comp->emit)); - } else if (((pns1)->kind_num_nodes & 0xff) == PN_trailer_period) { - -# 899 "user/mpy/py/compile.c" 3 - (( -# 899 "user/mpy/py/compile.c" - (((pns1->nodes[0]) & 0x0f) == (0x02)) -# 899 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 899, __func__, -# 899 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_ID(pns1->nodes[0])" -# 899 "user/mpy/py/compile.c" 3 - )) -# 899 "user/mpy/py/compile.c" - ; - (mp_emit_bc_delete_attr(comp->emit, (((uintptr_t)(pns1->nodes[0])) >> 4))); - } else { - goto cannot_delete; - } - } else { - goto cannot_delete; - } - - } else if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_atom_paren))) { - pn = ((mp_parse_node_struct_t*)pn)->nodes[0]; - if (((pn) == (0))) { - goto cannot_delete; - } else { - -# 913 "user/mpy/py/compile.c" 3 - (( -# 913 "user/mpy/py/compile.c" - ((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_testlist_comp)) -# 913 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 913, __func__, -# 913 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp)" -# 913 "user/mpy/py/compile.c" 3 - )) -# 913 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - - - if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns1)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { - - -# 921 "user/mpy/py/compile.c" 3 - (( -# 921 "user/mpy/py/compile.c" - ((pns1->nodes[0]) == (0)) -# 921 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 921, __func__, -# 921 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_NULL(pns1->nodes[0])" -# 921 "user/mpy/py/compile.c" 3 - )) -# 921 "user/mpy/py/compile.c" - ; - c_del_stmt(comp, pns->nodes[0]); - } else if (((pns1)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { - - int n = ((pns1)->kind_num_nodes >> 8); - c_del_stmt(comp, pns->nodes[0]); - for (int i = 0; i < n; i++) { - c_del_stmt(comp, pns1->nodes[i]); - } - } else if (((pns1)->kind_num_nodes & 0xff) == PN_comp_for) { - goto cannot_delete; - } else { - - goto sequence_with_2_items; - } - } else { - - sequence_with_2_items: - c_del_stmt(comp, pns->nodes[0]); - c_del_stmt(comp, pns->nodes[1]); - } - } - } else { - - goto cannot_delete; - } - - return; - -cannot_delete: - compile_syntax_error(comp, (mp_parse_node_t)pn, "can't delete expression"); -} - -static void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt); -} - -static void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->break_label == (0xffff)) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' outside loop"); - } - -# 962 "user/mpy/py/compile.c" 3 - (( -# 962 "user/mpy/py/compile.c" - comp->cur_except_level >= comp->break_continue_except_level -# 962 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 962, __func__, -# 962 "user/mpy/py/compile.c" - "comp->cur_except_level >= comp->break_continue_except_level" -# 962 "user/mpy/py/compile.c" 3 - )) -# 962 "user/mpy/py/compile.c" - ; - (mp_emit_bc_unwind_jump(comp->emit, comp->break_label, comp->cur_except_level - comp->break_continue_except_level)); -} - -static void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->continue_label == (0xffff)) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' outside loop"); - } - -# 970 "user/mpy/py/compile.c" 3 - (( -# 970 "user/mpy/py/compile.c" - comp->cur_except_level >= comp->break_continue_except_level -# 970 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 970, __func__, -# 970 "user/mpy/py/compile.c" - "comp->cur_except_level >= comp->break_continue_except_level" -# 970 "user/mpy/py/compile.c" 3 - )) -# 970 "user/mpy/py/compile.c" - ; - (mp_emit_bc_unwind_jump(comp->emit, comp->continue_label, comp->cur_except_level - comp->break_continue_except_level)); -} - -static void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->scope_cur->kind != SCOPE_FUNCTION) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' outside function"); - return; - } - if (((pns->nodes[0]) == (0))) { - - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - } else if ((0) - && ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_test_if_expr))) { - - mp_parse_node_struct_t *pns_test_if_expr = (mp_parse_node_struct_t*)pns->nodes[0]; - mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns_test_if_expr->nodes[1]; - - uint l_fail = comp_next_label(comp); - c_if_cond(comp, pns_test_if_else->nodes[0], -# 989 "user/mpy/py/compile.c" 3 4 - 0 -# 989 "user/mpy/py/compile.c" - , l_fail); - compile_node(comp, pns_test_if_expr->nodes[0]); - (mp_emit_bc_return_value(comp->emit)); - (mp_emit_bc_label_assign(comp->emit, l_fail)); - compile_node(comp, pns_test_if_else->nodes[1]); - } else { - compile_node(comp, pns->nodes[0]); - } - (mp_emit_bc_return_value(comp->emit)); -} - -static void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_pop_top(comp->emit)); -} - -static void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (((pns->nodes[0]) == (0))) { - - (mp_emit_bc_raise_varargs(comp->emit, 0)); - } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_raise_stmt_arg))) { - - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - compile_node(comp, pns->nodes[0]); - compile_node(comp, pns->nodes[1]); - (mp_emit_bc_raise_varargs(comp->emit, 2)); - } else { - - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_raise_varargs(comp->emit, 1)); - } -} - - - - -static void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) { - -# 1026 "user/mpy/py/compile.c" 3 4 - _Bool -# 1026 "user/mpy/py/compile.c" - is_as = -# 1026 "user/mpy/py/compile.c" 3 4 - 0 -# 1026 "user/mpy/py/compile.c" - ; - if (((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_dotted_as_name))) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - - *q_base = (((uintptr_t)(pns->nodes[1])) >> 4); - pn = pns->nodes[0]; - is_as = -# 1032 "user/mpy/py/compile.c" 3 4 - 1 -# 1032 "user/mpy/py/compile.c" - ; - } - if (((pn) == (0))) { - - *q_base = MP_QSTR_; - (mp_emit_bc_import_name(comp->emit, MP_QSTR_)); - } else if ((((pn) & 0x0f) == (0x02))) { - - qstr q_full = (((uintptr_t)(pn)) >> 4); - if (!is_as) { - *q_base = q_full; - } - (mp_emit_bc_import_name(comp->emit, q_full)); - } else { - -# 1046 "user/mpy/py/compile.c" 3 - (( -# 1046 "user/mpy/py/compile.c" - ((pn) != (0) && ((pn) & 3) == 0 && (((mp_parse_node_struct_t*)(pn))->kind_num_nodes & 0xff) == (PN_dotted_name)) -# 1046 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1046, __func__, -# 1046 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_name)" -# 1046 "user/mpy/py/compile.c" 3 - )) -# 1046 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - { - - if (!is_as) { - *q_base = (((uintptr_t)(pns->nodes[0])) >> 4); - } - int n = ((pns)->kind_num_nodes >> 8); - int len = n - 1; - for (int i = 0; i < n; i++) { - len += qstr_len((((uintptr_t)(pns->nodes[i])) >> 4)); - } - byte *q_ptr; - byte *str_dest = qstr_build_start(len, &q_ptr); - for (int i = 0; i < n; i++) { - if (i > 0) { - *str_dest++ = '.'; - } - size_t str_src_len; - const byte *str_src = qstr_data((((uintptr_t)(pns->nodes[i])) >> 4), &str_src_len); - memcpy(str_dest, str_src, str_src_len); - str_dest += str_src_len; - } - qstr q_full = qstr_build_end(q_ptr); - (mp_emit_bc_import_name(comp->emit, q_full)); - if (is_as) { - for (int i = 1; i < n; i++) { - (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(pns->nodes[i])) >> 4))); - } - } - } - } -} - -static void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) { - (mp_emit_bc_load_const_small_int(comp->emit, 0)); - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - qstr q_base; - do_import_name(comp, pn, &q_base); - compile_store_id(comp, q_base); -} - -static void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) { - apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name); -} - -static void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) { - mp_parse_node_t pn_import_source = pns->nodes[0]; - - - uint import_level = 0; - do { - mp_parse_node_t pn_rel; - if ((((pn_import_source) & 0x0f) == (0x0e)) || ((pn_import_source) != (0) && ((pn_import_source) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_import_source))->kind_num_nodes & 0xff) == (PN_one_or_more_period_or_ellipsis))) { - - pn_rel = pn_import_source; - pn_import_source = (0); - } else if (((pn_import_source) != (0) && ((pn_import_source) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_import_source))->kind_num_nodes & 0xff) == (PN_import_from_2b))) { - - mp_parse_node_struct_t *pns_2b = (mp_parse_node_struct_t*)pn_import_source; - pn_rel = pns_2b->nodes[0]; - pn_import_source = pns_2b->nodes[1]; - -# 1108 "user/mpy/py/compile.c" 3 - (( -# 1108 "user/mpy/py/compile.c" - !((pn_import_source) == (0)) -# 1108 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1108, __func__, -# 1108 "user/mpy/py/compile.c" - "!MP_PARSE_NODE_IS_NULL(pn_import_source)" -# 1108 "user/mpy/py/compile.c" 3 - )) -# 1108 "user/mpy/py/compile.c" - ; - } else { - - break; - } - - - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pn_rel, PN_one_or_more_period_or_ellipsis, &nodes); - - - for (int i = 0; i < n; i++) { - if (((nodes[i]) == ((0x0e) | ((MP_TOKEN_DEL_PERIOD) << 4)))) { - import_level++; - } else { - - import_level += 3; - } - } - } while (0); - - if (((pns->nodes[1]) == ((0x0e) | ((MP_TOKEN_OP_STAR) << 4)))) { - (mp_emit_bc_load_const_small_int(comp->emit, import_level)); - - - (mp_emit_bc_load_const_str(comp->emit, MP_QSTR__star_)); - (mp_emit_bc_build_tuple(comp->emit, 1)); - - - qstr dummy_q; - do_import_name(comp, pn_import_source, &dummy_q); - (mp_emit_bc_import_star(comp->emit)); - - } else { - (mp_emit_bc_load_const_small_int(comp->emit, import_level)); - - - mp_parse_node_t *pn_nodes; - int n = mp_parse_node_extract_list(&pns->nodes[1], PN_import_as_names, &pn_nodes); - for (int i = 0; i < n; i++) { - -# 1148 "user/mpy/py/compile.c" 3 - (( -# 1148 "user/mpy/py/compile.c" - ((pn_nodes[i]) != (0) && ((pn_nodes[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_nodes[i]))->kind_num_nodes & 0xff) == (PN_import_as_name)) -# 1148 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1148, __func__, -# 1148 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)" -# 1148 "user/mpy/py/compile.c" 3 - )) -# 1148 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; - qstr id2 = (((uintptr_t)(pns3->nodes[0])) >> 4); - (mp_emit_bc_load_const_str(comp->emit, id2)); - } - (mp_emit_bc_build_tuple(comp->emit, n)); - - - qstr dummy_q; - do_import_name(comp, pn_import_source, &dummy_q); - for (int i = 0; i < n; i++) { - -# 1159 "user/mpy/py/compile.c" 3 - (( -# 1159 "user/mpy/py/compile.c" - ((pn_nodes[i]) != (0) && ((pn_nodes[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_nodes[i]))->kind_num_nodes & 0xff) == (PN_import_as_name)) -# 1159 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1159, __func__, -# 1159 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)" -# 1159 "user/mpy/py/compile.c" 3 - )) -# 1159 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; - qstr id2 = (((uintptr_t)(pns3->nodes[0])) >> 4); - (mp_emit_bc_import_from(comp->emit, id2)); - if (((pns3->nodes[1]) == (0))) { - compile_store_id(comp, id2); - } else { - compile_store_id(comp, (((uintptr_t)(pns3->nodes[1])) >> 4)); - } - } - (mp_emit_bc_pop_top(comp->emit)); - } -} - -static void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, qstr qst) { - -# 1174 "user/mpy/py/compile.c" 3 4 - _Bool -# 1174 "user/mpy/py/compile.c" - added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); - if (!added && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) { - compile_syntax_error(comp, pn, "identifier redefined as global"); - return; - } - id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; - - - id_info = scope_find_global(comp->scope_cur, qst); - if (id_info != -# 1184 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 1184 "user/mpy/py/compile.c" - ) { - id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; - } -} - -static void compile_global_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->pass == MP_PASS_SCOPE) { - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); - for (int i = 0; i < n; i++) { - compile_declare_global(comp, (mp_parse_node_t)pns, (((uintptr_t)(nodes[i])) >> 4)); - } - } -} - -static void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, qstr qst) { - -# 1200 "user/mpy/py/compile.c" 3 4 - _Bool -# 1200 "user/mpy/py/compile.c" - added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); - if (added) { - scope_find_local_and_close_over(comp->scope_cur, id_info, qst); - if (id_info->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - compile_syntax_error(comp, pn, "no binding for nonlocal found"); - } - } else if (id_info->kind != ID_INFO_KIND_FREE) { - compile_syntax_error(comp, pn, "identifier redefined as nonlocal"); - } -} - -static void compile_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->pass == MP_PASS_SCOPE) { - if (comp->scope_cur->kind == SCOPE_MODULE) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "can't declare nonlocal in outer code"); - return; - } - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); - for (int i = 0; i < n; i++) { - compile_declare_nonlocal(comp, (mp_parse_node_t)pns, (((uintptr_t)(nodes[i])) >> 4)); - } - } -} - -static void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - - if ((mp_state_ctx.vm.mp_optimise_value) != 0) { - return; - } - - uint l_end = comp_next_label(comp); - c_if_cond(comp, pns->nodes[0], -# 1233 "user/mpy/py/compile.c" 3 4 - 1 -# 1233 "user/mpy/py/compile.c" - , l_end); - (mp_emit_bc_load_global(comp->emit, MP_QSTR_AssertionError)); - if (!((pns->nodes[1]) == (0))) { - - compile_node(comp, pns->nodes[1]); - (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); - } - (mp_emit_bc_raise_varargs(comp->emit, 1)); - (mp_emit_bc_label_assign(comp->emit, l_end)); -} - -static void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - uint l_end = comp_next_label(comp); - - - if (!mp_parse_node_is_const_false(pns->nodes[0])) { - uint l_fail = comp_next_label(comp); - c_if_cond(comp, pns->nodes[0], -# 1250 "user/mpy/py/compile.c" 3 4 - 0 -# 1250 "user/mpy/py/compile.c" - , l_fail); - - compile_node(comp, pns->nodes[1]); - - - if (mp_parse_node_is_const_true(pns->nodes[0])) { - goto done; - } - - if ( - - !(((pns->nodes[2]) == (0)) && ((pns->nodes[3]) == (0))) - - && !(mp_emit_bc_last_emit_was_return_value(comp->emit)) - ) { - - (mp_emit_bc_jump(comp->emit, l_end)); - } - - (mp_emit_bc_label_assign(comp->emit, l_fail)); - } - - - mp_parse_node_t *pn_elif; - int n_elif = mp_parse_node_extract_list(&pns->nodes[2], PN_if_stmt_elif_list, &pn_elif); - for (int i = 0; i < n_elif; i++) { - -# 1276 "user/mpy/py/compile.c" 3 - (( -# 1276 "user/mpy/py/compile.c" - ((pn_elif[i]) != (0) && ((pn_elif[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_elif[i]))->kind_num_nodes & 0xff) == (PN_if_stmt_elif)) -# 1276 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1276, __func__, -# 1276 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pn_elif[i], PN_if_stmt_elif)" -# 1276 "user/mpy/py/compile.c" 3 - )) -# 1276 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns_elif = (mp_parse_node_struct_t*)pn_elif[i]; - - - if (!mp_parse_node_is_const_false(pns_elif->nodes[0])) { - uint l_fail = comp_next_label(comp); - c_if_cond(comp, pns_elif->nodes[0], -# 1282 "user/mpy/py/compile.c" 3 4 - 0 -# 1282 "user/mpy/py/compile.c" - , l_fail); - - compile_node(comp, pns_elif->nodes[1]); - - - if (mp_parse_node_is_const_true(pns_elif->nodes[0])) { - goto done; - } - - - if (!(mp_emit_bc_last_emit_was_return_value(comp->emit))) { - (mp_emit_bc_jump(comp->emit, l_end)); - } - (mp_emit_bc_label_assign(comp->emit, l_fail)); - } - } - - - compile_node(comp, pns->nodes[3]); - -done: - (mp_emit_bc_label_assign(comp->emit, l_end)); -} -# 1321 "user/mpy/py/compile.c" -static void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - uint16_t old_break_label = comp->break_label; uint16_t old_continue_label = comp->continue_label; uint16_t old_break_continue_except_level = comp->break_continue_except_level; uint break_label = comp_next_label(comp); uint continue_label = comp_next_label(comp); comp->break_label = break_label; comp->continue_label = continue_label; comp->break_continue_except_level = comp->cur_except_level; - - if (!mp_parse_node_is_const_false(pns->nodes[0])) { - uint top_label = comp_next_label(comp); - if (!mp_parse_node_is_const_true(pns->nodes[0])) { - (mp_emit_bc_jump(comp->emit, continue_label)); - } - (mp_emit_bc_label_assign(comp->emit, top_label)); - compile_node(comp, pns->nodes[1]); - (mp_emit_bc_label_assign(comp->emit, continue_label)); - c_if_cond(comp, pns->nodes[0], -# 1332 "user/mpy/py/compile.c" 3 4 - 1 -# 1332 "user/mpy/py/compile.c" - , top_label); - } - - - comp->break_label = old_break_label; comp->continue_label = old_continue_label; comp->break_continue_except_level = old_break_continue_except_level; - - compile_node(comp, pns->nodes[2]); - - (mp_emit_bc_label_assign(comp->emit, break_label)); -} -# 1359 "user/mpy/py/compile.c" -static void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) { - uint16_t old_break_label = comp->break_label; uint16_t old_continue_label = comp->continue_label; uint16_t old_break_continue_except_level = comp->break_continue_except_level; uint break_label = comp_next_label(comp); uint continue_label = comp_next_label(comp); comp->break_label = break_label; comp->continue_label = continue_label; comp->break_continue_except_level = comp->cur_except_level; - - uint top_label = comp_next_label(comp); - uint entry_label = comp_next_label(comp); - - - -# 1366 "user/mpy/py/compile.c" 3 4 - _Bool -# 1366 "user/mpy/py/compile.c" - end_on_stack = !(((pn_end) & 0x1) == (0x1)); - if (end_on_stack) { - compile_node(comp, pn_end); - } - - - compile_node(comp, pn_start); - - (mp_emit_bc_jump(comp->emit, entry_label)); - (mp_emit_bc_label_assign(comp->emit, top_label)); - - - (mp_emit_bc_dup_top(comp->emit)); - c_assign(comp, pn_var, ASSIGN_STORE); - - - compile_node(comp, pn_body); - - (mp_emit_bc_label_assign(comp->emit, continue_label)); - - - compile_node(comp, pn_step); - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_INPLACE_ADD)); - - (mp_emit_bc_label_assign(comp->emit, entry_label)); - - - if (end_on_stack) { - (mp_emit_bc_dup_top_two(comp->emit)); - (mp_emit_bc_rot_two(comp->emit)); - } else { - (mp_emit_bc_dup_top(comp->emit)); - compile_node(comp, pn_end); - } - -# 1400 "user/mpy/py/compile.c" 3 - (( -# 1400 "user/mpy/py/compile.c" - (((pn_step) & 0x1) == (0x1)) -# 1400 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1400, __func__, -# 1400 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_SMALL_INT(pn_step)" -# 1400 "user/mpy/py/compile.c" 3 - )) -# 1400 "user/mpy/py/compile.c" - ; - if ((((mp_int_t)(intptr_t)(pn_step)) >> 1) >= 0) { - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_LESS)); - } else { - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_MORE)); - } - (mp_emit_bc_pop_jump_if(comp->emit, -# 1406 "user/mpy/py/compile.c" 3 4 - 1 -# 1406 "user/mpy/py/compile.c" - , top_label)); - - - comp->break_label = old_break_label; comp->continue_label = old_continue_label; comp->break_continue_except_level = old_break_continue_except_level; - - - - uint end_label = 0; - if (!((pn_else) == (0))) { - - (mp_emit_bc_pop_top(comp->emit)); - if (end_on_stack) { - (mp_emit_bc_pop_top(comp->emit)); - } - compile_node(comp, pn_else); - end_label = comp_next_label(comp); - (mp_emit_bc_jump(comp->emit, end_label)); - (mp_emit_bc_adjust_stack_size(comp->emit, 1 + end_on_stack)); - } - - (mp_emit_bc_label_assign(comp->emit, break_label)); - - - (mp_emit_bc_pop_top(comp->emit)); - - - if (end_on_stack) { - (mp_emit_bc_pop_top(comp->emit)); - } - - if (!((pn_else) == (0))) { - (mp_emit_bc_label_assign(comp->emit, end_label)); - } -} - -static void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - - - - if ( (((pns->nodes[0]) & 0x0f) == (0x02)) && ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_atom_expr_normal))) { - mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1]; - if ((((pns_it->nodes[0]) & 0x0f) == (0x02)) - && (((uintptr_t)(pns_it->nodes[0])) >> 4) == MP_QSTR_range - && (((mp_parse_node_struct_t*)pns_it->nodes[1])->kind_num_nodes & 0xff) == PN_trailer_paren) { - mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0]; - mp_parse_node_t *args; - int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args); - mp_parse_node_t pn_range_start; - mp_parse_node_t pn_range_end; - mp_parse_node_t pn_range_step; - -# 1456 "user/mpy/py/compile.c" 3 4 - _Bool -# 1456 "user/mpy/py/compile.c" - optimize = -# 1456 "user/mpy/py/compile.c" 3 4 - 0 -# 1456 "user/mpy/py/compile.c" - ; - if (1 <= n_args && n_args <= 3) { - optimize = -# 1458 "user/mpy/py/compile.c" 3 4 - 1 -# 1458 "user/mpy/py/compile.c" - ; - if (n_args == 1) { - pn_range_start = mp_parse_node_new_small_int(0); - pn_range_end = args[0]; - pn_range_step = mp_parse_node_new_small_int(1); - } else if (n_args == 2) { - pn_range_start = args[0]; - pn_range_end = args[1]; - pn_range_step = mp_parse_node_new_small_int(1); - } else { - pn_range_start = args[0]; - pn_range_end = args[1]; - pn_range_step = args[2]; - - if (!(((pn_range_step) & 0x1) == (0x1)) - || (((mp_int_t)(intptr_t)(pn_range_step)) >> 1) == 0) { - optimize = -# 1474 "user/mpy/py/compile.c" 3 4 - 0 -# 1474 "user/mpy/py/compile.c" - ; - } - } - - if (optimize && ((pn_range_start) != (0) && ((pn_range_start) & 3) == 0)) { - int k = (((mp_parse_node_struct_t*)pn_range_start)->kind_num_nodes & 0xff); - if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { - optimize = -# 1481 "user/mpy/py/compile.c" 3 4 - 0 -# 1481 "user/mpy/py/compile.c" - ; - } - } - if (optimize && ((pn_range_end) != (0) && ((pn_range_end) & 3) == 0)) { - int k = (((mp_parse_node_struct_t*)pn_range_end)->kind_num_nodes & 0xff); - if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { - optimize = -# 1487 "user/mpy/py/compile.c" 3 4 - 0 -# 1487 "user/mpy/py/compile.c" - ; - } - } - } - if (optimize) { - compile_for_stmt_optimised_range(comp, pns->nodes[0], pn_range_start, pn_range_end, pn_range_step, pns->nodes[2], pns->nodes[3]); - return; - } - } - } - - uint16_t old_break_label = comp->break_label; uint16_t old_continue_label = comp->continue_label; uint16_t old_break_continue_except_level = comp->break_continue_except_level; uint break_label = comp_next_label(comp); uint continue_label = comp_next_label(comp); comp->break_label = break_label; comp->continue_label = continue_label; comp->break_continue_except_level = comp->cur_except_level; - comp->break_label |= (0x8000); - - uint pop_label = comp_next_label(comp); - - compile_node(comp, pns->nodes[1]); - (mp_emit_bc_get_iter(comp->emit, -# 1504 "user/mpy/py/compile.c" 3 4 - 1 -# 1504 "user/mpy/py/compile.c" - )); - (mp_emit_bc_label_assign(comp->emit, continue_label)); - (mp_emit_bc_for_iter(comp->emit, pop_label)); - c_assign(comp, pns->nodes[0], ASSIGN_STORE); - compile_node(comp, pns->nodes[2]); - if (!(mp_emit_bc_last_emit_was_return_value(comp->emit))) { - (mp_emit_bc_jump(comp->emit, continue_label)); - } - (mp_emit_bc_label_assign(comp->emit, pop_label)); - (mp_emit_bc_for_iter_end(comp->emit)); - - - comp->break_label = old_break_label; comp->continue_label = old_continue_label; comp->break_continue_except_level = old_break_continue_except_level; - - compile_node(comp, pns->nodes[3]); - - (mp_emit_bc_label_assign(comp->emit, break_label)); -} - -static void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) { - - uint l1 = comp_next_label(comp); - uint success_label = comp_next_label(comp); - - (mp_emit_bc_setup_except(comp->emit, l1)); - compile_increase_except_level(comp); - - compile_node(comp, pn_body); - (mp_emit_bc_pop_block(comp->emit)); - (mp_emit_bc_jump(comp->emit, success_label)); - - (mp_emit_bc_label_assign(comp->emit, l1)); - (mp_emit_bc_start_except_handler(comp->emit)); - - - - uint l2 = comp_next_label(comp); - - for (int i = 0; i < n_except; i++) { - -# 1543 "user/mpy/py/compile.c" 3 - (( -# 1543 "user/mpy/py/compile.c" - ((pn_excepts[i]) != (0) && ((pn_excepts[i]) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_excepts[i]))->kind_num_nodes & 0xff) == (PN_try_stmt_except)) -# 1543 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1543, __func__, -# 1543 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pn_excepts[i], PN_try_stmt_except)" -# 1543 "user/mpy/py/compile.c" 3 - )) -# 1543 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns_except = (mp_parse_node_struct_t*)pn_excepts[i]; - - qstr qstr_exception_local = 0; - uint end_finally_label = comp_next_label(comp); - - if (((pns_except->nodes[0]) == (0))) { - - if (i + 1 != n_except) { - compile_syntax_error(comp, pn_excepts[i], "default 'except' must be last"); - compile_decrease_except_level(comp); - return; - } - } else { - - mp_parse_node_t pns_exception_expr = pns_except->nodes[0]; - if (((pns_exception_expr) != (0) && ((pns_exception_expr) & 3) == 0)) { - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns_exception_expr; - if (((pns3)->kind_num_nodes & 0xff) == PN_try_stmt_as_name) { - - pns_exception_expr = pns3->nodes[0]; - qstr_exception_local = (((uintptr_t)(pns3->nodes[1])) >> 4); - } - } - (mp_emit_bc_dup_top(comp->emit)); - compile_node(comp, pns_exception_expr); - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_EXCEPTION_MATCH)); - (mp_emit_bc_pop_jump_if(comp->emit, -# 1570 "user/mpy/py/compile.c" 3 4 - 0 -# 1570 "user/mpy/py/compile.c" - , end_finally_label)); - } - - - if (qstr_exception_local == 0) { - (mp_emit_bc_pop_top(comp->emit)); - } else { - compile_store_id(comp, qstr_exception_local); - } - - uint l3 = 0; - if (qstr_exception_local != 0) { - l3 = comp_next_label(comp); - (mp_emit_bc_setup_finally(comp->emit, l3)); - compile_increase_except_level(comp); - } - compile_node(comp, pns_except->nodes[1]); - if (qstr_exception_local != 0) { - (mp_emit_bc_pop_block(comp->emit)); - } - (mp_emit_bc_pop_except(comp->emit)); - if (qstr_exception_local != 0) { - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - (mp_emit_bc_label_assign(comp->emit, l3)); - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - compile_store_id(comp, qstr_exception_local); - compile_delete_id(comp, qstr_exception_local); - - compile_decrease_except_level(comp); - (mp_emit_bc_end_finally(comp->emit)); - } - (mp_emit_bc_jump(comp->emit, l2)); - (mp_emit_bc_label_assign(comp->emit, end_finally_label)); - (mp_emit_bc_adjust_stack_size(comp->emit, 1)); - } - - compile_decrease_except_level(comp); - (mp_emit_bc_end_finally(comp->emit)); - (mp_emit_bc_end_except_handler(comp->emit)); - - (mp_emit_bc_label_assign(comp->emit, success_label)); - compile_node(comp, pn_else); - (mp_emit_bc_label_assign(comp->emit, l2)); -} - -static void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) { - uint l_finally_block = comp_next_label(comp); - - (mp_emit_bc_setup_finally(comp->emit, l_finally_block)); - compile_increase_except_level(comp); - - if (n_except == 0) { - -# 1622 "user/mpy/py/compile.c" 3 - (( -# 1622 "user/mpy/py/compile.c" - ((pn_else) == (0)) -# 1622 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1622, __func__, -# 1622 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_NULL(pn_else)" -# 1622 "user/mpy/py/compile.c" 3 - )) -# 1622 "user/mpy/py/compile.c" - ; - (mp_emit_bc_adjust_stack_size(comp->emit, 3)); - compile_node(comp, pn_body); - (mp_emit_bc_adjust_stack_size(comp->emit, -3)); - } else { - compile_try_except(comp, pn_body, n_except, pn_except, pn_else); - } - (mp_emit_bc_pop_block(comp->emit)); - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - (mp_emit_bc_label_assign(comp->emit, l_finally_block)); - compile_node(comp, pn_finally); - - compile_decrease_except_level(comp); - (mp_emit_bc_end_finally(comp->emit)); -} - -static void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - -# 1639 "user/mpy/py/compile.c" 3 - (( -# 1639 "user/mpy/py/compile.c" - ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0) -# 1639 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1639, __func__, -# 1639 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])" -# 1639 "user/mpy/py/compile.c" 3 - )) -# 1639 "user/mpy/py/compile.c" - ; - { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns2)->kind_num_nodes & 0xff) == PN_try_stmt_finally) { - - compile_try_finally(comp, pns->nodes[0], 0, -# 1644 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 1644 "user/mpy/py/compile.c" - , (0), pns2->nodes[0]); - } else if (((pns2)->kind_num_nodes & 0xff) == PN_try_stmt_except_and_more) { - - mp_parse_node_t *pn_excepts; - int n_except = mp_parse_node_extract_list(&pns2->nodes[0], PN_try_stmt_except_list, &pn_excepts); - if (((pns2->nodes[2]) == (0))) { - - compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1]); - } else { - - compile_try_finally(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1], ((mp_parse_node_struct_t*)pns2->nodes[2])->nodes[0]); - } - } else { - - mp_parse_node_t *pn_excepts; - int n_except = mp_parse_node_extract_list(&pns->nodes[1], PN_try_stmt_except_list, &pn_excepts); - compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, (0)); - } - } -} - -static void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, mp_parse_node_t body) { - if (n == 0) { - - compile_node(comp, body); - } else { - uint l_end = comp_next_label(comp); - if (((0) || (0) || (0) || (0) || (0)) && comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) { - - - comp_next_label(comp); - } - if (((nodes[0]) != (0) && ((nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(nodes[0]))->kind_num_nodes & 0xff) == (PN_with_item))) { - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0]; - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_setup_with(comp->emit, l_end)); - c_assign(comp, pns->nodes[1], ASSIGN_STORE); - } else { - - compile_node(comp, nodes[0]); - (mp_emit_bc_setup_with(comp->emit, l_end)); - (mp_emit_bc_pop_top(comp->emit)); - } - compile_increase_except_level(comp); - - compile_with_stmt_helper(comp, n - 1, nodes + 1, body); - - (mp_emit_bc_with_cleanup(comp->emit, l_end)); - compile_decrease_except_level(comp); - (mp_emit_bc_end_finally(comp->emit)); - } -} - -static void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes); - -# 1702 "user/mpy/py/compile.c" 3 - (( -# 1702 "user/mpy/py/compile.c" - n > 0 -# 1702 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1702, __func__, -# 1702 "user/mpy/py/compile.c" - "n > 0" -# 1702 "user/mpy/py/compile.c" 3 - )) -# 1702 "user/mpy/py/compile.c" - ; - - - compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]); -} - -static void compile_yield_from(compiler_t *comp) { - (mp_emit_bc_get_iter(comp->emit, -# 1709 "user/mpy/py/compile.c" 3 4 - 0 -# 1709 "user/mpy/py/compile.c" - )); - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - (mp_emit_bc_yield_from(comp->emit)); -} -# 1889 "user/mpy/py/compile.c" -static void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (((pns->nodes[1]) == (0))) { - if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) { - - compile_load_id(comp, MP_QSTR___repl_print__); - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); - (mp_emit_bc_pop_top(comp->emit)); - - } else { - - if ((((pns->nodes[0]) & 3) && !(((pns->nodes[0]) & 0x0f) == (0x02))) - || ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_const_object))) { - - } else { - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_pop_top(comp->emit)); - } - } - } else if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - int kind = ((pns1)->kind_num_nodes & 0xff); - if (kind == PN_expr_stmt_augassign) { - c_assign(comp, pns->nodes[0], ASSIGN_AUG_LOAD); - compile_node(comp, pns1->nodes[1]); - -# 1914 "user/mpy/py/compile.c" 3 - (( -# 1914 "user/mpy/py/compile.c" - (((pns1->nodes[0]) & 0x0f) == (0x0e)) -# 1914 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 1914, __func__, -# 1914 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_TOKEN(pns1->nodes[0])" -# 1914 "user/mpy/py/compile.c" 3 - )) -# 1914 "user/mpy/py/compile.c" - ; - mp_binary_op_t op; - switch ((((uintptr_t)(pns1->nodes[0])) >> 4)) { - case MP_TOKEN_DEL_PIPE_EQUAL: op = MP_BINARY_OP_INPLACE_OR; break; - case MP_TOKEN_DEL_CARET_EQUAL: op = MP_BINARY_OP_INPLACE_XOR; break; - case MP_TOKEN_DEL_AMPERSAND_EQUAL: op = MP_BINARY_OP_INPLACE_AND; break; - case MP_TOKEN_DEL_DBL_LESS_EQUAL: op = MP_BINARY_OP_INPLACE_LSHIFT; break; - case MP_TOKEN_DEL_DBL_MORE_EQUAL: op = MP_BINARY_OP_INPLACE_RSHIFT; break; - case MP_TOKEN_DEL_PLUS_EQUAL: op = MP_BINARY_OP_INPLACE_ADD; break; - case MP_TOKEN_DEL_MINUS_EQUAL: op = MP_BINARY_OP_INPLACE_SUBTRACT; break; - case MP_TOKEN_DEL_STAR_EQUAL: op = MP_BINARY_OP_INPLACE_MULTIPLY; break; - case MP_TOKEN_DEL_DBL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_FLOOR_DIVIDE; break; - case MP_TOKEN_DEL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_TRUE_DIVIDE; break; - case MP_TOKEN_DEL_PERCENT_EQUAL: op = MP_BINARY_OP_INPLACE_MODULO; break; - case MP_TOKEN_DEL_DBL_STAR_EQUAL: default: op = MP_BINARY_OP_INPLACE_POWER; break; - } - (mp_emit_bc_binary_op(comp->emit, op)); - c_assign(comp, pns->nodes[0], ASSIGN_AUG_STORE); - } else if (kind == PN_expr_stmt_assign_list) { - int rhs = ((pns1)->kind_num_nodes >> 8) - 1; - compile_node(comp, pns1->nodes[rhs]); - - if (rhs > 0) { - (mp_emit_bc_dup_top(comp->emit)); - } - c_assign(comp, pns->nodes[0], ASSIGN_STORE); - for (int i = 0; i < rhs; i++) { - if (i + 1 < rhs) { - (mp_emit_bc_dup_top(comp->emit)); - } - c_assign(comp, pns1->nodes[i], ASSIGN_STORE); - } - } else { - plain_assign: - if ((0) - && ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) - && ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) - && (((mp_parse_node_struct_t*)pns->nodes[1])->kind_num_nodes >> 8) == 2 - && (((mp_parse_node_struct_t*)pns->nodes[0])->kind_num_nodes >> 8) == 2) { - - mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; - mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (((pns0->nodes[0]) != (0) && ((pns0->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[0]))->kind_num_nodes & 0xff) == (PN_star_expr)) - || ((pns0->nodes[1]) != (0) && ((pns0->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[1]))->kind_num_nodes & 0xff) == (PN_star_expr))) { - - goto no_optimisation; - } - compile_node(comp, pns10->nodes[0]); - compile_node(comp, pns10->nodes[1]); - (mp_emit_bc_rot_two(comp->emit)); - c_assign(comp, pns0->nodes[0], ASSIGN_STORE); - c_assign(comp, pns0->nodes[1], ASSIGN_STORE); - } else if ((0) - && ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) - && ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_star_expr)) - && (((mp_parse_node_struct_t*)pns->nodes[1])->kind_num_nodes >> 8) == 3 - && (((mp_parse_node_struct_t*)pns->nodes[0])->kind_num_nodes >> 8) == 3) { - - mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; - mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (((pns0->nodes[0]) != (0) && ((pns0->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[0]))->kind_num_nodes & 0xff) == (PN_star_expr)) - || ((pns0->nodes[1]) != (0) && ((pns0->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[1]))->kind_num_nodes & 0xff) == (PN_star_expr)) - || ((pns0->nodes[2]) != (0) && ((pns0->nodes[2]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns0->nodes[2]))->kind_num_nodes & 0xff) == (PN_star_expr))) { - - goto no_optimisation; - } - compile_node(comp, pns10->nodes[0]); - compile_node(comp, pns10->nodes[1]); - compile_node(comp, pns10->nodes[2]); - (mp_emit_bc_rot_three(comp->emit)); - (mp_emit_bc_rot_two(comp->emit)); - c_assign(comp, pns0->nodes[0], ASSIGN_STORE); - c_assign(comp, pns0->nodes[1], ASSIGN_STORE); - c_assign(comp, pns0->nodes[2], ASSIGN_STORE); - } else { - no_optimisation: - compile_node(comp, pns->nodes[1]); - c_assign(comp, pns->nodes[0], ASSIGN_STORE); - } - } - } else { - goto plain_assign; - } -} - -static void c_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns, mp_binary_op_t binary_op) { - int num_nodes = ((pns)->kind_num_nodes >> 8); - compile_node(comp, pns->nodes[0]); - for (int i = 1; i < num_nodes; i += 1) { - compile_node(comp, pns->nodes[i]); - (mp_emit_bc_binary_op(comp->emit, binary_op)); - } -} - -static void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - -# 2009 "user/mpy/py/compile.c" 3 - (( -# 2009 "user/mpy/py/compile.c" - ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_test_if_else)) -# 2009 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2009, __func__, -# 2009 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else)" -# 2009 "user/mpy/py/compile.c" 3 - )) -# 2009 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns->nodes[1]; - - uint l_fail = comp_next_label(comp); - uint l_end = comp_next_label(comp); - c_if_cond(comp, pns_test_if_else->nodes[0], -# 2014 "user/mpy/py/compile.c" 3 4 - 0 -# 2014 "user/mpy/py/compile.c" - , l_fail); - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_jump(comp->emit, l_end)); - (mp_emit_bc_label_assign(comp->emit, l_fail)); - (mp_emit_bc_adjust_stack_size(comp->emit, -1)); - compile_node(comp, pns_test_if_else->nodes[1]); - (mp_emit_bc_label_assign(comp->emit, l_end)); -} - -static void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->pass == MP_PASS_SCOPE) { - - scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options); - - pns->nodes[2] = (mp_parse_node_t)s; - } - - - scope_t *this_scope = (scope_t*)pns->nodes[2]; - - - compile_funcdef_lambdef(comp, this_scope, pns->nodes[0], PN_varargslist); -} - -static void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns, -# 2038 "user/mpy/py/compile.c" 3 4 - _Bool -# 2038 "user/mpy/py/compile.c" - cond) { - uint l_end = comp_next_label(comp); - int n = ((pns)->kind_num_nodes >> 8); - for (int i = 0; i < n; i += 1) { - compile_node(comp, pns->nodes[i]); - if (i + 1 < n) { - (mp_emit_bc_jump_if_or_pop(comp->emit, cond, l_end)); - } - } - (mp_emit_bc_label_assign(comp->emit, l_end)); -} - -static void compile_or_test(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_or_and_test(comp, pns, -# 2051 "user/mpy/py/compile.c" 3 4 - 1 -# 2051 "user/mpy/py/compile.c" - ); -} - -static void compile_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_or_and_test(comp, pns, -# 2055 "user/mpy/py/compile.c" 3 4 - 0 -# 2055 "user/mpy/py/compile.c" - ); -} - -static void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_unary_op(comp->emit, MP_UNARY_OP_NOT)); -} - -static void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) { - int num_nodes = ((pns)->kind_num_nodes >> 8); - compile_node(comp, pns->nodes[0]); - -# 2066 "user/mpy/py/compile.c" 3 4 - _Bool -# 2066 "user/mpy/py/compile.c" - multi = (num_nodes > 3); - uint l_fail = 0; - if (multi) { - l_fail = comp_next_label(comp); - } - for (int i = 1; i + 1 < num_nodes; i += 2) { - compile_node(comp, pns->nodes[i + 1]); - if (i + 2 < num_nodes) { - (mp_emit_bc_dup_top(comp->emit)); - (mp_emit_bc_rot_three(comp->emit)); - } - if ((((pns->nodes[i]) & 0x0f) == (0x0e))) { - mp_binary_op_t op; - switch ((((uintptr_t)(pns->nodes[i])) >> 4)) { - case MP_TOKEN_OP_LESS: op = MP_BINARY_OP_LESS; break; - case MP_TOKEN_OP_MORE: op = MP_BINARY_OP_MORE; break; - case MP_TOKEN_OP_DBL_EQUAL: op = MP_BINARY_OP_EQUAL; break; - case MP_TOKEN_OP_LESS_EQUAL: op = MP_BINARY_OP_LESS_EQUAL; break; - case MP_TOKEN_OP_MORE_EQUAL: op = MP_BINARY_OP_MORE_EQUAL; break; - case MP_TOKEN_OP_NOT_EQUAL: op = MP_BINARY_OP_NOT_EQUAL; break; - case MP_TOKEN_KW_IN: default: op = MP_BINARY_OP_IN; break; - } - (mp_emit_bc_binary_op(comp->emit, op)); - } else { - -# 2090 "user/mpy/py/compile.c" 3 - (( -# 2090 "user/mpy/py/compile.c" - ((pns->nodes[i]) != (0) && ((pns->nodes[i]) & 3) == 0) -# 2090 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2090, __func__, -# 2090 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pns->nodes[i])" -# 2090 "user/mpy/py/compile.c" 3 - )) -# 2090 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[i]; - int kind = ((pns2)->kind_num_nodes & 0xff); - if (kind == PN_comp_op_not_in) { - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_NOT_IN)); - } else { - -# 2096 "user/mpy/py/compile.c" 3 - (( -# 2096 "user/mpy/py/compile.c" - kind == PN_comp_op_is -# 2096 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2096, __func__, -# 2096 "user/mpy/py/compile.c" - "kind == PN_comp_op_is" -# 2096 "user/mpy/py/compile.c" 3 - )) -# 2096 "user/mpy/py/compile.c" - ; - if (((pns2->nodes[0]) == (0))) { - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_IS)); - } else { - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_IS_NOT)); - } - } - } - if (i + 2 < num_nodes) { - (mp_emit_bc_jump_if_or_pop(comp->emit, -# 2105 "user/mpy/py/compile.c" 3 4 - 0 -# 2105 "user/mpy/py/compile.c" - , l_fail)); - } - } - if (multi) { - uint l_end = comp_next_label(comp); - (mp_emit_bc_jump(comp->emit, l_end)); - (mp_emit_bc_label_assign(comp->emit, l_fail)); - (mp_emit_bc_adjust_stack_size(comp->emit, 1)); - (mp_emit_bc_rot_two(comp->emit)); - (mp_emit_bc_pop_top(comp->emit)); - (mp_emit_bc_label_assign(comp->emit, l_end)); - } -} - -static void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "*x must be assignment target"); -} - -static void compile_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - c_binary_op(comp, pns, MP_BINARY_OP_OR); -} - -static void compile_xor_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - c_binary_op(comp, pns, MP_BINARY_OP_XOR); -} - -static void compile_and_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - c_binary_op(comp, pns, MP_BINARY_OP_AND); -} - -static void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) { - int num_nodes = ((pns)->kind_num_nodes >> 8); - compile_node(comp, pns->nodes[0]); - for (int i = 1; i + 1 < num_nodes; i += 2) { - compile_node(comp, pns->nodes[i + 1]); - mp_binary_op_t op; - mp_token_kind_t tok = (((uintptr_t)(pns->nodes[i])) >> 4); - switch (tok) { - case MP_TOKEN_OP_PLUS: op = MP_BINARY_OP_ADD; break; - case MP_TOKEN_OP_MINUS: op = MP_BINARY_OP_SUBTRACT; break; - case MP_TOKEN_OP_STAR: op = MP_BINARY_OP_MULTIPLY; break; - case MP_TOKEN_OP_DBL_SLASH: op = MP_BINARY_OP_FLOOR_DIVIDE; break; - case MP_TOKEN_OP_SLASH: op = MP_BINARY_OP_TRUE_DIVIDE; break; - case MP_TOKEN_OP_PERCENT: op = MP_BINARY_OP_MODULO; break; - case MP_TOKEN_OP_DBL_LESS: op = MP_BINARY_OP_LSHIFT; break; - default: - -# 2151 "user/mpy/py/compile.c" 3 - (( -# 2151 "user/mpy/py/compile.c" - tok == MP_TOKEN_OP_DBL_MORE -# 2151 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2151, __func__, -# 2151 "user/mpy/py/compile.c" - "tok == MP_TOKEN_OP_DBL_MORE" -# 2151 "user/mpy/py/compile.c" 3 - )) -# 2151 "user/mpy/py/compile.c" - ; - op = MP_BINARY_OP_RSHIFT; - break; - } - (mp_emit_bc_binary_op(comp->emit, op)); - } -} - -static void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[1]); - mp_unary_op_t op; - mp_token_kind_t tok = (((uintptr_t)(pns->nodes[0])) >> 4); - switch (tok) { - case MP_TOKEN_OP_PLUS: op = MP_UNARY_OP_POSITIVE; break; - case MP_TOKEN_OP_MINUS: op = MP_UNARY_OP_NEGATIVE; break; - default: - -# 2167 "user/mpy/py/compile.c" 3 - (( -# 2167 "user/mpy/py/compile.c" - tok == MP_TOKEN_OP_TILDE -# 2167 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2167, __func__, -# 2167 "user/mpy/py/compile.c" - "tok == MP_TOKEN_OP_TILDE" -# 2167 "user/mpy/py/compile.c" 3 - )) -# 2167 "user/mpy/py/compile.c" - ; - op = MP_UNARY_OP_INVERT; - break; - } - (mp_emit_bc_unary_op(comp->emit, op)); -} - -static void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) { - - compile_node(comp, pns->nodes[0]); - - - if (((pns->nodes[1]) == (0))) { - return; - } - - - size_t num_trail = 1; - mp_parse_node_struct_t **pns_trail = (mp_parse_node_struct_t**)&pns->nodes[1]; - if (((pns_trail[0])->kind_num_nodes & 0xff) == PN_atom_expr_trailers) { - num_trail = ((pns_trail[0])->kind_num_nodes >> 8); - pns_trail = (mp_parse_node_struct_t**)&pns_trail[0]->nodes[0]; - } - - - size_t i = 0; - - - if (comp->scope_cur->kind == SCOPE_FUNCTION - && (((pns->nodes[0]) & 0x0f) == (0x02)) - && (((uintptr_t)(pns->nodes[0])) >> 4) == MP_QSTR_super - && ((pns_trail[0])->kind_num_nodes & 0xff) == PN_trailer_paren - && ((pns_trail[0]->nodes[0]) == (0))) { - - - - compile_load_id(comp, MP_QSTR___class__); - - - -# 2206 "user/mpy/py/compile.c" 3 4 - _Bool -# 2206 "user/mpy/py/compile.c" - found = -# 2206 "user/mpy/py/compile.c" 3 4 - 0 -# 2206 "user/mpy/py/compile.c" - ; - id_info_t *id = &comp->scope_cur->id_info[0]; - for (size_t n = comp->scope_cur->id_info_len; n > 0; --n, ++id) { - if (id->flags & ID_FLAG_IS_PARAM) { - - compile_load_id(comp, id->qst); - found = -# 2212 "user/mpy/py/compile.c" 3 4 - 1 -# 2212 "user/mpy/py/compile.c" - ; - break; - } - } - if (!found) { - compile_syntax_error(comp, (mp_parse_node_t)pns_trail[0], - "super() can't find self"); - return; - } - - if (num_trail >= 3 - && ((pns_trail[1])->kind_num_nodes & 0xff) == PN_trailer_period - && ((pns_trail[2])->kind_num_nodes & 0xff) == PN_trailer_paren) { - - mp_parse_node_struct_t *pns_period = pns_trail[1]; - mp_parse_node_struct_t *pns_paren = pns_trail[2]; - (mp_emit_bc_load_method(comp->emit, (((uintptr_t)(pns_period->nodes[0])) >> 4), -# 2228 "user/mpy/py/compile.c" 3 4 - 1 -# 2228 "user/mpy/py/compile.c" - )); - compile_trailer_paren_helper(comp, pns_paren->nodes[0], -# 2229 "user/mpy/py/compile.c" 3 4 - 1 -# 2229 "user/mpy/py/compile.c" - , 0); - i = 3; - } else { - - (mp_emit_bc_call_function(comp->emit, 2, 0, 0)); - i = 1; - } - } - - - for (; i < num_trail; i++) { - if (i + 1 < num_trail - && ((pns_trail[i])->kind_num_nodes & 0xff) == PN_trailer_period - && ((pns_trail[i + 1])->kind_num_nodes & 0xff) == PN_trailer_paren) { - - mp_parse_node_struct_t *pns_period = pns_trail[i]; - mp_parse_node_struct_t *pns_paren = pns_trail[i + 1]; - (mp_emit_bc_load_method(comp->emit, (((uintptr_t)(pns_period->nodes[0])) >> 4), -# 2246 "user/mpy/py/compile.c" 3 4 - 0 -# 2246 "user/mpy/py/compile.c" - )); - compile_trailer_paren_helper(comp, pns_paren->nodes[0], -# 2247 "user/mpy/py/compile.c" 3 4 - 1 -# 2247 "user/mpy/py/compile.c" - , 0); - i += 1; - } else { - - compile_node(comp, (mp_parse_node_t)pns_trail[i]); - } - } -} - -static void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_generic_all_nodes(comp, pns); - (mp_emit_bc_binary_op(comp->emit, MP_BINARY_OP_POWER)); -} - -static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, -# 2261 "user/mpy/py/compile.c" 3 4 - _Bool -# 2261 "user/mpy/py/compile.c" - is_method_call, int n_positional_extra) { - - - - mp_parse_node_t *args; - int n_args = mp_parse_node_extract_list(&pn_arglist, PN_arglist, &args); - - - - - - int n_positional = n_positional_extra; - uint n_keyword = 0; - uint star_flags = 0; - mp_parse_node_struct_t *star_args_node = -# 2275 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 2275 "user/mpy/py/compile.c" - , *dblstar_args_node = -# 2275 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 2275 "user/mpy/py/compile.c" - ; - for (int i = 0; i < n_args; i++) { - if (((args[i]) != (0) && ((args[i]) & 3) == 0)) { - mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t*)args[i]; - if (((pns_arg)->kind_num_nodes & 0xff) == PN_arglist_star) { - if (star_flags & (0x01)) { - compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple *x"); - return; - } - star_flags |= (0x01); - star_args_node = pns_arg; - } else if (((pns_arg)->kind_num_nodes & 0xff) == PN_arglist_dbl_star) { - if (star_flags & (0x02)) { - compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple **x"); - return; - } - star_flags |= (0x02); - dblstar_args_node = pns_arg; - } else if (((pns_arg)->kind_num_nodes & 0xff) == PN_argument) { - if (!((pns_arg->nodes[1]) != (0) && ((pns_arg->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns_arg->nodes[1]))->kind_num_nodes & 0xff) == (PN_comp_for))) { - if (!(((pns_arg->nodes[0]) & 0x0f) == (0x02))) { - compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id"); - return; - } - (mp_emit_bc_load_const_str(comp->emit, (((uintptr_t)(pns_arg->nodes[0])) >> 4))); - compile_node(comp, pns_arg->nodes[1]); - n_keyword += 1; - } else { - compile_comprehension(comp, pns_arg, SCOPE_GEN_EXPR); - n_positional++; - } - } else { - goto normal_argument; - } - } else { - normal_argument: - if (star_flags) { - compile_syntax_error(comp, args[i], "non-keyword arg after */**"); - return; - } - if (n_keyword > 0) { - compile_syntax_error(comp, args[i], "non-keyword arg after keyword arg"); - return; - } - compile_node(comp, args[i]); - n_positional++; - } - } - - - - if (star_flags != 0) { - if (star_args_node == -# 2327 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 2327 "user/mpy/py/compile.c" - ) { - (mp_emit_bc_load_null(comp->emit)); - } else { - compile_node(comp, star_args_node->nodes[0]); - } - if (dblstar_args_node == -# 2332 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 2332 "user/mpy/py/compile.c" - ) { - (mp_emit_bc_load_null(comp->emit)); - } else { - compile_node(comp, dblstar_args_node->nodes[0]); - } - } - - - if (is_method_call) { - (mp_emit_bc_call_method(comp->emit, n_positional, n_keyword, star_flags)); - } else { - (mp_emit_bc_call_function(comp->emit, n_positional, n_keyword, star_flags)); - } -} - - -static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) { - -# 2349 "user/mpy/py/compile.c" 3 - (( -# 2349 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes >> 8) == 2 -# 2349 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2349, __func__, -# 2349 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2" -# 2349 "user/mpy/py/compile.c" 3 - )) -# 2349 "user/mpy/py/compile.c" - ; - -# 2350 "user/mpy/py/compile.c" 3 - (( -# 2350 "user/mpy/py/compile.c" - ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_comp_for)) -# 2350 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2350, __func__, -# 2350 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)" -# 2350 "user/mpy/py/compile.c" 3 - )) -# 2350 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; - - if (comp->pass == MP_PASS_SCOPE) { - - scope_t *s = scope_new_and_link(comp, kind, (mp_parse_node_t)pns, comp->scope_cur->emit_options); - - pns_comp_for->nodes[3] = (mp_parse_node_t)s; - } - - - scope_t *this_scope = (scope_t*)pns_comp_for->nodes[3]; - - - close_over_variables_etc(comp, this_scope, 0, 0); - - compile_node(comp, pns_comp_for->nodes[1]); - if (kind == SCOPE_GEN_EXPR) { - (mp_emit_bc_get_iter(comp->emit, -# 2368 "user/mpy/py/compile.c" 3 4 - 0 -# 2368 "user/mpy/py/compile.c" - )); - } - (mp_emit_bc_call_function(comp->emit, 1, 0, 0)); -} - -static void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (((pns->nodes[0]) == (0))) { - - c_tuple(comp, (0), -# 2376 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 2376 "user/mpy/py/compile.c" - ); - } else { - -# 2378 "user/mpy/py/compile.c" 3 - (( -# 2378 "user/mpy/py/compile.c" - ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp)) -# 2378 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2378, __func__, -# 2378 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)" -# 2378 "user/mpy/py/compile.c" 3 - )) -# 2378 "user/mpy/py/compile.c" - ; - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - -# 2380 "user/mpy/py/compile.c" 3 - (( -# 2380 "user/mpy/py/compile.c" - !((pns->nodes[1]) == (0)) -# 2380 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2380, __func__, -# 2380 "user/mpy/py/compile.c" - "!MP_PARSE_NODE_IS_NULL(pns->nodes[1])" -# 2380 "user/mpy/py/compile.c" 3 - )) -# 2380 "user/mpy/py/compile.c" - ; - if (((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { - - -# 2385 "user/mpy/py/compile.c" 3 - (( -# 2385 "user/mpy/py/compile.c" - ((pns2->nodes[0]) == (0)) -# 2385 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2385, __func__, -# 2385 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_NULL(pns2->nodes[0])" -# 2385 "user/mpy/py/compile.c" 3 - )) -# 2385 "user/mpy/py/compile.c" - ; - c_tuple(comp, pns->nodes[0], -# 2386 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 2386 "user/mpy/py/compile.c" - ); - } else if (((pns2)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { - - c_tuple(comp, pns->nodes[0], pns2); - } else if (((pns2)->kind_num_nodes & 0xff) == PN_comp_for) { - - compile_comprehension(comp, pns, SCOPE_GEN_EXPR); - } else { - - goto tuple_with_2_items; - } - } else { - - tuple_with_2_items: - c_tuple(comp, (0), pns); - } - } -} - -static void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (((pns->nodes[0]) == (0))) { - - (mp_emit_bc_build_list(comp->emit, 0)); - } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_testlist_comp))) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (((pns2->nodes[1]) != (0) && ((pns2->nodes[1]) & 3) == 0)) { - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns2->nodes[1]; - if (((pns3)->kind_num_nodes & 0xff) == PN_testlist_comp_3b) { - - -# 2415 "user/mpy/py/compile.c" 3 - (( -# 2415 "user/mpy/py/compile.c" - ((pns3->nodes[0]) == (0)) -# 2415 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2415, __func__, -# 2415 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_NULL(pns3->nodes[0])" -# 2415 "user/mpy/py/compile.c" 3 - )) -# 2415 "user/mpy/py/compile.c" - ; - compile_node(comp, pns2->nodes[0]); - (mp_emit_bc_build_list(comp->emit, 1)); - } else if (((pns3)->kind_num_nodes & 0xff) == PN_testlist_comp_3c) { - - compile_node(comp, pns2->nodes[0]); - compile_generic_all_nodes(comp, pns3); - (mp_emit_bc_build_list(comp->emit, 1 + ((pns3)->kind_num_nodes >> 8))); - } else if (((pns3)->kind_num_nodes & 0xff) == PN_comp_for) { - - compile_comprehension(comp, pns2, SCOPE_LIST_COMP); - } else { - - goto list_with_2_items; - } - } else { - - list_with_2_items: - compile_node(comp, pns2->nodes[0]); - compile_node(comp, pns2->nodes[1]); - (mp_emit_bc_build_list(comp->emit, 2)); - } - } else { - - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_build_list(comp->emit, 1)); - } -} - -static void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) { - mp_parse_node_t pn = pns->nodes[0]; - if (((pn) == (0))) { - - (mp_emit_bc_build_map(comp->emit, 0)); - } else if (((pn) != (0) && ((pn) & 3) == 0)) { - pns = (mp_parse_node_struct_t*)pn; - if (((pns)->kind_num_nodes & 0xff) == PN_dictorsetmaker_item) { - - (mp_emit_bc_build_map(comp->emit, 1)); - compile_node(comp, pn); - (mp_emit_bc_store_map(comp->emit)); - } else if (((pns)->kind_num_nodes & 0xff) == PN_dictorsetmaker) { - -# 2457 "user/mpy/py/compile.c" 3 - (( -# 2457 "user/mpy/py/compile.c" - ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0) -# 2457 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2457, __func__, -# 2457 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])" -# 2457 "user/mpy/py/compile.c" 3 - )) -# 2457 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (((pns1)->kind_num_nodes & 0xff) == PN_dictorsetmaker_list) { - - - - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns1->nodes[0], PN_dictorsetmaker_list2, &nodes); - - - -# 2467 "user/mpy/py/compile.c" 3 4 - _Bool -# 2467 "user/mpy/py/compile.c" - is_dict; - if (!(0) || ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_dictorsetmaker_item))) { - - (mp_emit_bc_build_map(comp->emit, 1 + n)); - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_store_map(comp->emit)); - is_dict = -# 2473 "user/mpy/py/compile.c" 3 4 - 1 -# 2473 "user/mpy/py/compile.c" - ; - } else { - - compile_node(comp, pns->nodes[0]); - is_dict = -# 2477 "user/mpy/py/compile.c" 3 4 - 0 -# 2477 "user/mpy/py/compile.c" - ; - } - - - for (int i = 0; i < n; i++) { - mp_parse_node_t pn_i = nodes[i]; - -# 2483 "user/mpy/py/compile.c" 3 4 - _Bool -# 2483 "user/mpy/py/compile.c" - is_key_value = ((pn_i) != (0) && ((pn_i) & 3) == 0 && (((mp_parse_node_struct_t*)(pn_i))->kind_num_nodes & 0xff) == (PN_dictorsetmaker_item)); - compile_node(comp, pn_i); - if (is_dict) { - if (!is_key_value) { - if (((1)) == (1)) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); - } else { - compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict"); - } - return; - } - (mp_emit_bc_store_map(comp->emit)); - } else { - if (is_key_value) { - if (((1)) == (1)) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); - } else { - compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set"); - } - return; - } - } - } - - - - - - - - } else { - -# 2514 "user/mpy/py/compile.c" 3 - (( -# 2514 "user/mpy/py/compile.c" - ((pns1)->kind_num_nodes & 0xff) == PN_comp_for -# 2514 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2514, __func__, -# 2514 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for" -# 2514 "user/mpy/py/compile.c" 3 - )) -# 2514 "user/mpy/py/compile.c" - ; - - if (!(0) || ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_dictorsetmaker_item))) { - - compile_comprehension(comp, pns, SCOPE_DICT_COMP); - } else { - - compile_comprehension(comp, pns, SCOPE_SET_COMP); - } - } - } else { - - goto set_with_one_element; - } - } else { - - set_with_one_element: - - - - - -# 2535 "user/mpy/py/compile.c" 3 - (( -# 2535 "user/mpy/py/compile.c" - 0 -# 2535 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2535, __func__, -# 2535 "user/mpy/py/compile.c" - "0" -# 2535 "user/mpy/py/compile.c" 3 - )) -# 2535 "user/mpy/py/compile.c" - ; - - } -} - -static void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_trailer_paren_helper(comp, pns->nodes[0], -# 2541 "user/mpy/py/compile.c" 3 4 - 0 -# 2541 "user/mpy/py/compile.c" - , 0); -} - -static void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { - - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_load_subscr(comp->emit)); -} - -static void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) { - - (mp_emit_bc_load_attr(comp->emit, (((uintptr_t)(pns->nodes[0])) >> 4))); -} -# 2613 "user/mpy/py/compile.c" -static void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) { - - compile_node(comp, pns->nodes[1]); - compile_node(comp, pns->nodes[0]); -} - -static void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) { - qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options); - - compile_store_id(comp, cname); -} - -static void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'yield' outside function"); - return; - } - if (((pns->nodes[0]) == (0))) { - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - (mp_emit_bc_yield_value(comp->emit)); - } else if (((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_yield_arg_from))) { - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - compile_node(comp, pns->nodes[0]); - compile_yield_from(comp); - } else { - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_yield_value(comp->emit)); - } -} -# 2654 "user/mpy/py/compile.c" -static mp_obj_t get_const_object(mp_parse_node_struct_t *pns) { - - - - - return (mp_obj_t)pns->nodes[0]; - -} - -static void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) { - (mp_emit_bc_load_const_obj(comp->emit, get_const_object(pns))); -} - -typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*); -static const compile_function_t compile_function[] = { - - - - -# 1 "user/mpy/py/grammar.h" 1 -# 40 "user/mpy/py/grammar.h" - -compile_generic_all_nodes, -compile_generic_all_nodes, - - - -# 58 "user/mpy/py/grammar.h" - - -compile_decorated, - - - - - - -compile_funcdef, - - - - - - - - - - - - - - - - - - - - - - - - - - -compile_generic_all_nodes, - - - - - - - - -compile_expr_stmt, - - - - - -compile_generic_tuple, - - -# 122 "user/mpy/py/grammar.h" -compile_del_stmt, -compile_generic_all_nodes, - -compile_break_stmt, -compile_continue_stmt, -compile_return_stmt, -compile_yield_stmt, -compile_raise_stmt, - - -# 145 "user/mpy/py/grammar.h" - -compile_import_name, -compile_import_from, - - - - - - - - - - - - -compile_global_stmt, -compile_nonlocal_stmt, - -compile_assert_stmt, - -# 183 "user/mpy/py/grammar.h" - - -compile_if_stmt, - - -compile_while_stmt, -compile_for_stmt, -compile_try_stmt, - - - - - - - -compile_with_stmt, - - - - - -compile_generic_all_nodes, - - - - - - - -compile_test_if_expr, - - -compile_lambdef, -compile_lambdef, -# 234 "user/mpy/py/grammar.h" -compile_or_test, -compile_and_test, - -compile_not_test_2, -compile_comparison, - - - - -compile_star_expr, -compile_expr, -compile_xor_expr, -compile_and_expr, -compile_term, - -compile_term, - -compile_term, - - -compile_factor_2, - -compile_power, - - - - - - -compile_atom_expr_normal, - - - - - - - - -compile_atom_paren, - -compile_atom_bracket, -compile_atom_brace, - - - - - - -compile_trailer_paren, -compile_trailer_bracket, -compile_trailer_period, -# 300 "user/mpy/py/grammar.h" -compile_generic_tuple, - - - - - - - - -compile_generic_tuple, - - - - - - -compile_dictorsetmaker_item, - - - - - - - -compile_classdef, - - - - - - - - - -# 342 "user/mpy/py/grammar.h" - - - - - - - - - - - - - -compile_yield_expr, - - -# 2674 "user/mpy/py/compile.c" 2 - - - - compile_const_object, -}; - -static void compile_node(compiler_t *comp, mp_parse_node_t pn) { - if (((pn) == (0))) { - - } else if ((((pn) & 0x1) == (0x1))) { - mp_int_t arg = (((mp_int_t)(intptr_t)(pn)) >> 1); -# 2700 "user/mpy/py/compile.c" - (mp_emit_bc_load_const_small_int(comp->emit, arg)); - - } else if (((pn) & 3)) { - uintptr_t arg = (((uintptr_t)(pn)) >> 4); - switch (((pn) & 0x0f)) { - case (0x02): compile_load_id(comp, arg); break; - case (0x06): (mp_emit_bc_load_const_str(comp->emit, arg)); break; - case (0x0a): - - if (comp->pass != MP_PASS_EMIT) { - (mp_emit_bc_load_const_obj(comp->emit, (((mp_obj_t)&mp_const_none_obj)))); - } else { - size_t len; - const byte *data = qstr_data(arg, &len); - (mp_emit_bc_load_const_obj(comp->emit, mp_obj_new_bytes(data, len))); - } - break; - case (0x0e): default: - if (arg == MP_TOKEN_NEWLINE) { - - - - } else { - (mp_emit_bc_load_const_tok(comp->emit, arg)); - } - break; - } - } else { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - (mp_emit_bc_set_source_line(comp->emit, pns->source_line)); - -# 2730 "user/mpy/py/compile.c" 3 - (( -# 2730 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes & 0xff) <= PN_const_object -# 2730 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2730, __func__, -# 2730 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND(pns) <= PN_const_object" -# 2730 "user/mpy/py/compile.c" 3 - )) -# 2730 "user/mpy/py/compile.c" - ; - compile_function_t f = compile_function[((pns)->kind_num_nodes & 0xff)]; - f(comp, pns); - } -} - -static void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) { - - if ((comp->scope_cur->scope_flags & (0x02)) != 0) { - compile_syntax_error(comp, pn, "invalid syntax"); - return; - } - - qstr param_name = MP_QSTR_NULL; - uint param_flag = ID_FLAG_IS_PARAM; - if ((((pn) & 0x0f) == (0x02))) { - param_name = (((uintptr_t)(pn)) >> 4); - if (comp->have_star) { - - comp->scope_cur->num_kwonly_args += 1; - } else { - - comp->scope_cur->num_pos_args += 1; - } - } else { - -# 2755 "user/mpy/py/compile.c" 3 - (( -# 2755 "user/mpy/py/compile.c" - ((pn) != (0) && ((pn) & 3) == 0) -# 2755 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2755, __func__, -# 2755 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(pn)" -# 2755 "user/mpy/py/compile.c" 3 - )) -# 2755 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if (((pns)->kind_num_nodes & 0xff) == pn_name) { - param_name = (((uintptr_t)(pns->nodes[0])) >> 4); - if (comp->have_star) { - - comp->scope_cur->num_kwonly_args += 1; - } else { - - comp->scope_cur->num_pos_args += 1; - } - } else if (((pns)->kind_num_nodes & 0xff) == pn_star) { - if (comp->have_star) { - - compile_syntax_error(comp, pn, "invalid syntax"); - return; - } - comp->have_star = -# 2772 "user/mpy/py/compile.c" 3 4 - 1 -# 2772 "user/mpy/py/compile.c" - ; - param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_STAR_PARAM; - if (((pns->nodes[0]) == (0))) { - - - - } else if ((((pns->nodes[0]) & 0x0f) == (0x02))) { - - comp->scope_cur->scope_flags |= (0x01); - param_name = (((uintptr_t)(pns->nodes[0])) >> 4); - } else { - -# 2783 "user/mpy/py/compile.c" 3 - (( -# 2783 "user/mpy/py/compile.c" - ((pns->nodes[0]) != (0) && ((pns->nodes[0]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[0]))->kind_num_nodes & 0xff) == (PN_tfpdef)) -# 2783 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2783, __func__, -# 2783 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)" -# 2783 "user/mpy/py/compile.c" 3 - )) -# 2783 "user/mpy/py/compile.c" - ; - - comp->scope_cur->scope_flags |= (0x01); - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - param_name = (((uintptr_t)(pns->nodes[0])) >> 4); - } - } else { - -# 2790 "user/mpy/py/compile.c" 3 - (( -# 2790 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes & 0xff) == pn_dbl_star -# 2790 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2790, __func__, -# 2790 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND(pns) == pn_dbl_star" -# 2790 "user/mpy/py/compile.c" 3 - )) -# 2790 "user/mpy/py/compile.c" - ; - param_name = (((uintptr_t)(pns->nodes[0])) >> 4); - param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_DBL_STAR_PARAM; - comp->scope_cur->scope_flags |= (0x02); - } - } - - if (param_name != MP_QSTR_NULL) { - -# 2798 "user/mpy/py/compile.c" 3 4 - _Bool -# 2798 "user/mpy/py/compile.c" - added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, param_name, &added); - if (!added) { - compile_syntax_error(comp, pn, "name reused for argument"); - return; - } - id_info->kind = ID_INFO_KIND_LOCAL; - id_info->flags = param_flag; - } -} - -static void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) { - compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star); -} - -static void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) { - compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star); -} -# 2860 "user/mpy/py/compile.c" -static void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) { - uint l_top = comp_next_label(comp); - uint l_end = comp_next_label(comp); - (mp_emit_bc_label_assign(comp->emit, l_top)); - (mp_emit_bc_for_iter(comp->emit, l_end)); - c_assign(comp, pns_comp_for->nodes[0], ASSIGN_STORE); - mp_parse_node_t pn_iter = pns_comp_for->nodes[2]; - - tail_recursion: - if (((pn_iter) == (0))) { - - compile_node(comp, pn_inner_expr); - if (comp->scope_cur->kind == SCOPE_GEN_EXPR) { - (mp_emit_bc_yield_value(comp->emit)); - (mp_emit_bc_pop_top(comp->emit)); - } else { - (mp_emit_bc_store_comp(comp->emit, comp->scope_cur->kind, 4 * for_depth + 5)); - } - } else if ((((mp_parse_node_struct_t*)pn_iter)->kind_num_nodes & 0xff) == PN_comp_if) { - - mp_parse_node_struct_t *pns_comp_if = (mp_parse_node_struct_t*)pn_iter; - c_if_cond(comp, pns_comp_if->nodes[0], -# 2881 "user/mpy/py/compile.c" 3 4 - 0 -# 2881 "user/mpy/py/compile.c" - , l_top); - pn_iter = pns_comp_if->nodes[1]; - goto tail_recursion; - } else { - -# 2885 "user/mpy/py/compile.c" 3 - (( -# 2885 "user/mpy/py/compile.c" - (((mp_parse_node_struct_t*)pn_iter)->kind_num_nodes & 0xff) == PN_comp_for -# 2885 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2885, __func__, -# 2885 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_for" -# 2885 "user/mpy/py/compile.c" 3 - )) -# 2885 "user/mpy/py/compile.c" - ; - - mp_parse_node_struct_t *pns_comp_for2 = (mp_parse_node_struct_t*)pn_iter; - compile_node(comp, pns_comp_for2->nodes[1]); - (mp_emit_bc_get_iter(comp->emit, -# 2889 "user/mpy/py/compile.c" 3 4 - 1 -# 2889 "user/mpy/py/compile.c" - )); - compile_scope_comp_iter(comp, pns_comp_for2, pn_inner_expr, for_depth + 1); - } - - (mp_emit_bc_jump(comp->emit, l_top)); - (mp_emit_bc_label_assign(comp->emit, l_end)); - (mp_emit_bc_for_iter_end(comp->emit)); -} - -static void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) { -# 2938 "user/mpy/py/compile.c" - (void)comp; - (void)pn; - -} - -static void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { - comp->pass = pass; - comp->scope_cur = scope; - comp->next_label = 0; - (mp_emit_bc_start_pass(comp->emit, pass, scope)); - - if (comp->pass == MP_PASS_SCOPE) { - - - scope->stack_size = 0; - scope->exc_stack_size = 0; - } - - - if (((scope->pn) != (0) && ((scope->pn) & 3) == 0 && (((mp_parse_node_struct_t*)(scope->pn))->kind_num_nodes & 0xff) == (PN_eval_input))) { - -# 2958 "user/mpy/py/compile.c" 3 - (( -# 2958 "user/mpy/py/compile.c" - scope->kind == SCOPE_MODULE -# 2958 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2958, __func__, -# 2958 "user/mpy/py/compile.c" - "scope->kind == SCOPE_MODULE" -# 2958 "user/mpy/py/compile.c" 3 - )) -# 2958 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - compile_node(comp, pns->nodes[0]); - (mp_emit_bc_return_value(comp->emit)); - } else if (scope->kind == SCOPE_MODULE) { - if (!comp->is_repl) { - check_for_doc_string(comp, scope->pn); - } - compile_node(comp, scope->pn); - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - (mp_emit_bc_return_value(comp->emit)); - } else if (scope->kind == SCOPE_FUNCTION) { - -# 2970 "user/mpy/py/compile.c" 3 - (( -# 2970 "user/mpy/py/compile.c" - ((scope->pn) != (0) && ((scope->pn) & 3) == 0) -# 2970 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2970, __func__, -# 2970 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(scope->pn)" -# 2970 "user/mpy/py/compile.c" 3 - )) -# 2970 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - -# 2972 "user/mpy/py/compile.c" 3 - (( -# 2972 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes & 0xff) == PN_funcdef -# 2972 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 2972, __func__, -# 2972 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef" -# 2972 "user/mpy/py/compile.c" 3 - )) -# 2972 "user/mpy/py/compile.c" - ; - - - - if (comp->pass == MP_PASS_SCOPE) { - comp->have_star = -# 2977 "user/mpy/py/compile.c" 3 4 - 0 -# 2977 "user/mpy/py/compile.c" - ; - apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param); - } -# 3002 "user/mpy/py/compile.c" - compile_node(comp, pns->nodes[3]); - - if (!(mp_emit_bc_last_emit_was_return_value(comp->emit))) { - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - (mp_emit_bc_return_value(comp->emit)); - } - } else if (scope->kind == SCOPE_LAMBDA) { - -# 3009 "user/mpy/py/compile.c" 3 - (( -# 3009 "user/mpy/py/compile.c" - ((scope->pn) != (0) && ((scope->pn) & 3) == 0) -# 3009 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3009, __func__, -# 3009 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(scope->pn)" -# 3009 "user/mpy/py/compile.c" 3 - )) -# 3009 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - -# 3011 "user/mpy/py/compile.c" 3 - (( -# 3011 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes >> 8) == 3 -# 3011 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3011, __func__, -# 3011 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3" -# 3011 "user/mpy/py/compile.c" 3 - )) -# 3011 "user/mpy/py/compile.c" - ; - - - - if (comp->pass == MP_PASS_SCOPE) { - comp->have_star = -# 3016 "user/mpy/py/compile.c" 3 4 - 0 -# 3016 "user/mpy/py/compile.c" - ; - apply_to_single_or_list(comp, pns->nodes[0], PN_varargslist, compile_scope_lambda_param); - } - - compile_node(comp, pns->nodes[1]); - - - if (scope->scope_flags & (0x04)) { - (mp_emit_bc_pop_top(comp->emit)); - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - } - (mp_emit_bc_return_value(comp->emit)); - } else if (scope->kind == SCOPE_LIST_COMP || scope->kind == SCOPE_DICT_COMP || scope->kind == SCOPE_SET_COMP || scope->kind == SCOPE_GEN_EXPR) { - - - -# 3031 "user/mpy/py/compile.c" 3 - (( -# 3031 "user/mpy/py/compile.c" - ((scope->pn) != (0) && ((scope->pn) & 3) == 0) -# 3031 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3031, __func__, -# 3031 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(scope->pn)" -# 3031 "user/mpy/py/compile.c" 3 - )) -# 3031 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - -# 3033 "user/mpy/py/compile.c" 3 - (( -# 3033 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes >> 8) == 2 -# 3033 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3033, __func__, -# 3033 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2" -# 3033 "user/mpy/py/compile.c" 3 - )) -# 3033 "user/mpy/py/compile.c" - ; - -# 3034 "user/mpy/py/compile.c" 3 - (( -# 3034 "user/mpy/py/compile.c" - ((pns->nodes[1]) != (0) && ((pns->nodes[1]) & 3) == 0 && (((mp_parse_node_struct_t*)(pns->nodes[1]))->kind_num_nodes & 0xff) == (PN_comp_for)) -# 3034 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3034, __func__, -# 3034 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)" -# 3034 "user/mpy/py/compile.c" 3 - )) -# 3034 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; - - - - - - qstr qstr_arg = MP_QSTR_; - if (comp->pass == MP_PASS_SCOPE) { - -# 3043 "user/mpy/py/compile.c" 3 4 - _Bool -# 3043 "user/mpy/py/compile.c" - added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qstr_arg, &added); - -# 3045 "user/mpy/py/compile.c" 3 - (( -# 3045 "user/mpy/py/compile.c" - added -# 3045 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3045, __func__, -# 3045 "user/mpy/py/compile.c" - "added" -# 3045 "user/mpy/py/compile.c" 3 - )) -# 3045 "user/mpy/py/compile.c" - ; - id_info->kind = ID_INFO_KIND_LOCAL; - scope->num_pos_args = 1; - } - - if (scope->kind == SCOPE_LIST_COMP) { - (mp_emit_bc_build_list(comp->emit, 0)); - } else if (scope->kind == SCOPE_DICT_COMP) { - (mp_emit_bc_build_map(comp->emit, 0)); - - - - - } - - - - if (scope->kind == SCOPE_GEN_EXPR) { - - (mp_emit_bc_load_null(comp->emit)); - compile_load_id(comp, qstr_arg); - (mp_emit_bc_load_null(comp->emit)); - (mp_emit_bc_load_null(comp->emit)); - } else { - compile_load_id(comp, qstr_arg); - (mp_emit_bc_get_iter(comp->emit, -# 3070 "user/mpy/py/compile.c" 3 4 - 1 -# 3070 "user/mpy/py/compile.c" - )); - } - - compile_scope_comp_iter(comp, pns_comp_for, pns->nodes[0], 0); - - if (scope->kind == SCOPE_GEN_EXPR) { - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - } - (mp_emit_bc_return_value(comp->emit)); - } else { - -# 3080 "user/mpy/py/compile.c" 3 - (( -# 3080 "user/mpy/py/compile.c" - scope->kind == SCOPE_CLASS -# 3080 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3080, __func__, -# 3080 "user/mpy/py/compile.c" - "scope->kind == SCOPE_CLASS" -# 3080 "user/mpy/py/compile.c" 3 - )) -# 3080 "user/mpy/py/compile.c" - ; - -# 3081 "user/mpy/py/compile.c" 3 - (( -# 3081 "user/mpy/py/compile.c" - ((scope->pn) != (0) && ((scope->pn) & 3) == 0) -# 3081 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3081, __func__, -# 3081 "user/mpy/py/compile.c" - "MP_PARSE_NODE_IS_STRUCT(scope->pn)" -# 3081 "user/mpy/py/compile.c" 3 - )) -# 3081 "user/mpy/py/compile.c" - ; - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - -# 3083 "user/mpy/py/compile.c" 3 - (( -# 3083 "user/mpy/py/compile.c" - ((pns)->kind_num_nodes & 0xff) == PN_classdef -# 3083 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3083, __func__, -# 3083 "user/mpy/py/compile.c" - "MP_PARSE_NODE_STRUCT_KIND(pns) == PN_classdef" -# 3083 "user/mpy/py/compile.c" 3 - )) -# 3083 "user/mpy/py/compile.c" - ; - - if (comp->pass == MP_PASS_SCOPE) { - -# 3086 "user/mpy/py/compile.c" 3 4 - _Bool -# 3086 "user/mpy/py/compile.c" - added; - id_info_t *id_info = scope_find_or_add_id(scope, MP_QSTR___class__, &added); - -# 3088 "user/mpy/py/compile.c" 3 - (( -# 3088 "user/mpy/py/compile.c" - added -# 3088 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3088, __func__, -# 3088 "user/mpy/py/compile.c" - "added" -# 3088 "user/mpy/py/compile.c" 3 - )) -# 3088 "user/mpy/py/compile.c" - ; - id_info->kind = ID_INFO_KIND_LOCAL; - } - - compile_load_id(comp, MP_QSTR___name__); - compile_store_id(comp, MP_QSTR___module__); - (mp_emit_bc_load_const_str(comp->emit, (((uintptr_t)(pns->nodes[0])) >> 4))); - compile_store_id(comp, MP_QSTR___qualname__); - - check_for_doc_string(comp, pns->nodes[2]); - compile_node(comp, pns->nodes[2]); - - id_info_t *id = scope_find(scope, MP_QSTR___class__); - -# 3101 "user/mpy/py/compile.c" 3 - (( -# 3101 "user/mpy/py/compile.c" - id != -# 3101 "user/mpy/py/compile.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3101, __func__, -# 3101 "user/mpy/py/compile.c" - "id != NULL" -# 3101 "user/mpy/py/compile.c" 3 - )) -# 3101 "user/mpy/py/compile.c" - ; - if (id->kind == ID_INFO_KIND_LOCAL) { - (mp_emit_bc_load_const_tok(comp->emit, MP_TOKEN_KW_NONE)); - } else { - (mp_emit_bc_load_fast(comp->emit, MP_QSTR___class__, id->local_num)); - } - (mp_emit_bc_return_value(comp->emit)); - } - - (mp_emit_bc_end_pass(comp->emit)); - - - -# 3113 "user/mpy/py/compile.c" 3 - (( -# 3113 "user/mpy/py/compile.c" - comp->cur_except_level == 0 -# 3113 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3113, __func__, -# 3113 "user/mpy/py/compile.c" - "comp->cur_except_level == 0" -# 3113 "user/mpy/py/compile.c" 3 - )) -# 3113 "user/mpy/py/compile.c" - ; -} -# 3277 "user/mpy/py/compile.c" -static void scope_compute_things(scope_t *scope) { - - if (scope->scope_flags & (0x01)) { - id_info_t *id_param = -# 3280 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3280 "user/mpy/py/compile.c" - ; - for (int i = scope->id_info_len - 1; i >= 0; i--) { - id_info_t *id = &scope->id_info[i]; - if (id->flags & ID_FLAG_IS_STAR_PARAM) { - if (id_param != -# 3284 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3284 "user/mpy/py/compile.c" - ) { - - id_info_t temp = *id_param; *id_param = *id; *id = temp; - } - break; - } else if (id_param == -# 3289 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3289 "user/mpy/py/compile.c" - && id->flags == ID_FLAG_IS_PARAM) { - id_param = id; - } - } - } - - - - scope->num_locals = 0; - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (scope->kind == SCOPE_CLASS && id->qst == MP_QSTR___class__) { - - continue; - } - if (((scope->kind) >= SCOPE_LAMBDA) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; - } - - if (id->kind == ID_INFO_KIND_LOCAL || (id->flags & ID_FLAG_IS_PARAM)) { - id->local_num = scope->num_locals++; - } - } - - - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - - - - if (id->kind == ID_INFO_KIND_CELL && !(id->flags & ID_FLAG_IS_PARAM)) { - id->local_num = scope->num_locals; - scope->num_locals += 1; - } - } - - - - if (scope->parent != -# 3327 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3327 "user/mpy/py/compile.c" - ) { - int num_free = 0; - for (int i = 0; i < scope->parent->id_info_len; i++) { - id_info_t *id = &scope->parent->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { - for (int j = 0; j < scope->id_info_len; j++) { - id_info_t *id2 = &scope->id_info[j]; - if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { - -# 3335 "user/mpy/py/compile.c" 3 - (( -# 3335 "user/mpy/py/compile.c" - !(id2->flags & ID_FLAG_IS_PARAM) -# 3335 "user/mpy/py/compile.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/compile.c", 3335, __func__, -# 3335 "user/mpy/py/compile.c" - "!(id2->flags & ID_FLAG_IS_PARAM)" -# 3335 "user/mpy/py/compile.c" 3 - )) -# 3335 "user/mpy/py/compile.c" - ; - - id2->local_num = num_free; - num_free += 1; - } - } - } - } - - if (num_free > 0) { - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (id->kind != ID_INFO_KIND_FREE || (id->flags & ID_FLAG_IS_PARAM)) { - id->local_num += num_free; - } - } - scope->num_pos_args += num_free; - scope->num_locals += num_free; - } - } -} - - -static - -mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, -# 3360 "user/mpy/py/compile.c" 3 4 - _Bool -# 3360 "user/mpy/py/compile.c" - is_repl) { - - compiler_t comp_state = {0}; - compiler_t *comp = &comp_state; - - comp->source_file = source_file; - comp->is_repl = is_repl; - comp->break_label = (0xffff); - comp->continue_label = (0xffff); - - - scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, parse_tree->root, emit_opt); - - - emit_t *emit_bc = emit_bc_new(); - - - comp->emit = emit_bc; - - - - uint max_num_labels = 0; - for (scope_t *s = comp->scope_head; s != -# 3382 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3382 "user/mpy/py/compile.c" - && comp->compile_error == (((mp_obj_t)(void*)0)); s = s->next) { - if ( -# 3383 "user/mpy/py/compile.c" 3 4 - 0 -# 3383 "user/mpy/py/compile.c" - ) { - - - - - } else { - compile_scope(comp, s, MP_PASS_SCOPE); - } - - - if (comp->next_label > max_num_labels) { - max_num_labels = comp->next_label; - } - } - - - for (scope_t *s = comp->scope_head; s != -# 3399 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3399 "user/mpy/py/compile.c" - && comp->compile_error == (((mp_obj_t)(void*)0)); s = s->next) { - scope_compute_things(s); - } - - - emit_bc_set_max_num_labels(emit_bc, max_num_labels); - - - - - - for (scope_t *s = comp->scope_head; s != -# 3410 "user/mpy/py/compile.c" 3 4 - ((void *)0) -# 3410 "user/mpy/py/compile.c" - && comp->compile_error == (((mp_obj_t)(void*)0)); s = s->next) { - if ( -# 3411 "user/mpy/py/compile.c" 3 4 - 0 -# 3411 "user/mpy/py/compile.c" - ) { -# 3434 "user/mpy/py/compile.c" - } else { - - - - switch (s->emit_options) { -# 3452 "user/mpy/py/compile.c" - default: - comp->emit = emit_bc; - - - - break; - } - - - compile_scope(comp, s, MP_PASS_STACK_SIZE); - - - if (comp->compile_error == (((mp_obj_t)(void*)0))) { - compile_scope(comp, s, MP_PASS_CODE_SIZE); - } - - - if (comp->compile_error == (((mp_obj_t)(void*)0))) { - compile_scope(comp, s, MP_PASS_EMIT); - } - } - } - - if (comp->compile_error != (((mp_obj_t)(void*)0))) { - - - compile_error_set_line(comp, comp->scope_cur->pn); - - mp_obj_exception_add_traceback(comp->compile_error, comp->source_file, - comp->compile_error_line, comp->scope_cur->simple_name); - } - - - - emit_bc_free(emit_bc); -# 3499 "user/mpy/py/compile.c" - mp_parse_tree_clear(parse_tree); - - - mp_raw_code_t *outer_raw_code = module_scope->raw_code; - for (scope_t *s = module_scope; s;) { - scope_t *next = s->next; - scope_free(s); - s = next; - } - - if (comp->compile_error != (((mp_obj_t)(void*)0))) { - nlr_jump(((void*)comp->compile_error)); - } else { - return outer_raw_code; - } -} - -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, -# 3516 "user/mpy/py/compile.c" 3 4 - _Bool -# 3516 "user/mpy/py/compile.c" - is_repl) { - mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl); - - return mp_make_function_from_raw_code(rc, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))); -} -# 1 "user/mpy/py/emitcommon.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/emitcommon.c" -# 27 "user/mpy/py/emitcommon.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/emitcommon.c" 2 - -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 29 "user/mpy/py/lexer.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/lexer.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 31 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 30 "user/mpy/py/emitcommon.c" 2 - - - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst) { - - -# 35 "user/mpy/py/emitcommon.c" 3 4 - _Bool -# 35 "user/mpy/py/emitcommon.c" - added; - id_info_t *id = scope_find_or_add_id(scope, qst, &added); - if (added) { - scope_find_local_and_close_over(scope, id, qst); - } -} - -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst) { - - -# 44 "user/mpy/py/emitcommon.c" 3 4 - _Bool -# 44 "user/mpy/py/emitcommon.c" - added; - id_info_t *id = scope_find_or_add_id(scope, qst, &added); - if (added) { - if (((scope->kind) >= SCOPE_LAMBDA)) { - id->kind = ID_INFO_KIND_LOCAL; - } else { - id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; - } - } else if (((scope->kind) >= SCOPE_LAMBDA) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - - id->kind = ID_INFO_KIND_LOCAL; - } -} - -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst) { - - - id_info_t *id = scope_find(scope, qst); - -# 62 "user/mpy/py/emitcommon.c" 3 - (( -# 62 "user/mpy/py/emitcommon.c" - id != -# 62 "user/mpy/py/emitcommon.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/emitcommon.c", 62, __func__, -# 62 "user/mpy/py/emitcommon.c" - "id != NULL" -# 62 "user/mpy/py/emitcommon.c" 3 - )) -# 62 "user/mpy/py/emitcommon.c" - ; - - - if (id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - emit_method_table->name(emit, qst); - } else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) { - emit_method_table->global(emit, qst); - } else if (id->kind == ID_INFO_KIND_LOCAL) { - emit_method_table->fast(emit, qst, id->local_num); - } else { - -# 72 "user/mpy/py/emitcommon.c" 3 - (( -# 72 "user/mpy/py/emitcommon.c" - id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE -# 72 "user/mpy/py/emitcommon.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitcommon.c", 72, __func__, -# 72 "user/mpy/py/emitcommon.c" - "id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE" -# 72 "user/mpy/py/emitcommon.c" 3 - )) -# 72 "user/mpy/py/emitcommon.c" - ; - emit_method_table->deref(emit, qst, id->local_num); - } -} -# 1 "user/mpy/py/emitbc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/emitbc.c" -# 27 "user/mpy/py/emitbc.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 28 "user/mpy/py/emitbc.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 29 "user/mpy/py/emitbc.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 30 "user/mpy/py/emitbc.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/emitbc.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/emitbc.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 31 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 35 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 34 "user/mpy/py/emitbc.c" 2 -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 31 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 35 "user/mpy/py/emitbc.c" 2 -# 1 "user/mpy/py/bc0.h" 1 -# 36 "user/mpy/py/emitbc.c" 2 - - - - - - -struct _emit_t { - - - - byte dummy_data[((((sizeof(mp_uint_t)) * 8 + 6) / 7))]; - - pass_kind_t pass : 8; - mp_uint_t last_emit_was_return_value : 8; - - int stack_size; - - scope_t *scope; - - mp_uint_t last_source_line_offset; - mp_uint_t last_source_line; - - mp_uint_t max_num_labels; - mp_uint_t *label_offsets; - - size_t code_info_offset; - size_t code_info_size; - size_t bytecode_offset; - size_t bytecode_size; - byte *code_base; - - - uint16_t ct_cur_obj; - uint16_t ct_num_obj; - uint16_t ct_cur_raw_code; - - mp_uint_t *const_table; -}; - -emit_t *emit_bc_new(void) { - emit_t *emit = ((emit_t*)(m_malloc0(sizeof(emit_t) * (1)))); - return emit; -} - -void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels) { - emit->max_num_labels = max_num_labels; - emit->label_offsets = ((mp_uint_t*)(m_malloc(sizeof(mp_uint_t) * (emit->max_num_labels)))); -} - -void emit_bc_free(emit_t *emit) { - ((void)(emit->max_num_labels), m_free(emit->label_offsets)); - (((void)(1), m_free(emit))); -} - -typedef byte *(*emit_allocator_t)(emit_t *emit, int nbytes); - -static void emit_write_uint(emit_t *emit, emit_allocator_t allocator, mp_uint_t val) { - - byte buf[(((sizeof(mp_uint_t)) * 8 + 6) / 7)]; - byte *p = buf + sizeof(buf); - - do { - *--p = val & 0x7f; - val >>= 7; - } while (val != 0); - byte *c = allocator(emit, buf + sizeof(buf) - p); - while (p != buf + sizeof(buf) - 1) { - *c++ = *p++ | 0x80; - } - *c = *p; -} - - -static byte *emit_get_cur_to_write_code_info(emit_t *emit, int num_bytes_to_write) { - - if (emit->pass < MP_PASS_EMIT) { - emit->code_info_offset += num_bytes_to_write; - return emit->dummy_data; - } else { - -# 115 "user/mpy/py/emitbc.c" 3 - (( -# 115 "user/mpy/py/emitbc.c" - emit->code_info_offset + num_bytes_to_write <= emit->code_info_size -# 115 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 115, __func__, -# 115 "user/mpy/py/emitbc.c" - "emit->code_info_offset + num_bytes_to_write <= emit->code_info_size" -# 115 "user/mpy/py/emitbc.c" 3 - )) -# 115 "user/mpy/py/emitbc.c" - ; - byte *c = emit->code_base + emit->code_info_offset; - emit->code_info_offset += num_bytes_to_write; - return c; - } -} - -static void emit_write_code_info_byte(emit_t* emit, byte val) { - *emit_get_cur_to_write_code_info(emit, 1) = val; -} - -static void emit_write_code_info_uint(emit_t* emit, mp_uint_t val) { - emit_write_uint(emit, emit_get_cur_to_write_code_info, val); -} - -static void emit_write_code_info_qstr(emit_t *emit, qstr qst) { - - -# 132 "user/mpy/py/emitbc.c" 3 - (( -# 132 "user/mpy/py/emitbc.c" - (qst >> 16) == 0 -# 132 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 132, __func__, -# 132 "user/mpy/py/emitbc.c" - "(qst >> 16) == 0" -# 132 "user/mpy/py/emitbc.c" 3 - )) -# 132 "user/mpy/py/emitbc.c" - ; - byte *c = emit_get_cur_to_write_code_info(emit, 2); - c[0] = qst; - c[1] = qst >> 8; - - - -} -# 172 "user/mpy/py/emitbc.c" -static byte *emit_get_cur_to_write_bytecode(emit_t *emit, int num_bytes_to_write) { - - if (emit->pass < MP_PASS_EMIT) { - emit->bytecode_offset += num_bytes_to_write; - return emit->dummy_data; - } else { - -# 178 "user/mpy/py/emitbc.c" 3 - (( -# 178 "user/mpy/py/emitbc.c" - emit->bytecode_offset + num_bytes_to_write <= emit->bytecode_size -# 178 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 178, __func__, -# 178 "user/mpy/py/emitbc.c" - "emit->bytecode_offset + num_bytes_to_write <= emit->bytecode_size" -# 178 "user/mpy/py/emitbc.c" 3 - )) -# 178 "user/mpy/py/emitbc.c" - ; - byte *c = emit->code_base + emit->code_info_size + emit->bytecode_offset; - emit->bytecode_offset += num_bytes_to_write; - return c; - } -} - -static void emit_write_bytecode_byte(emit_t *emit, byte b1) { - byte *c = emit_get_cur_to_write_bytecode(emit, 1); - c[0] = b1; -} - -static void emit_write_bytecode_byte_byte(emit_t* emit, byte b1, byte b2) { - byte *c = emit_get_cur_to_write_bytecode(emit, 2); - c[0] = b1; - c[1] = b2; -} - - -static void emit_write_bytecode_byte_int(emit_t *emit, byte b1, mp_int_t num) { - emit_write_bytecode_byte(emit, b1); - - - byte buf[(((sizeof(mp_uint_t)) * 8 + 6) / 7)]; - byte *p = buf + sizeof(buf); - - do { - *--p = num & 0x7f; - num >>= 7; - } while (num != 0 && num != -1); - - - if (num == -1 && (*p & 0x40) == 0) { - *--p = 0x7f; - } else if (num == 0 && (*p & 0x40) != 0) { - *--p = 0; - } - - byte *c = emit_get_cur_to_write_bytecode(emit, buf + sizeof(buf) - p); - while (p != buf + sizeof(buf) - 1) { - *c++ = *p++ | 0x80; - } - *c = *p; -} - -static void emit_write_bytecode_byte_uint(emit_t *emit, byte b, mp_uint_t val) { - emit_write_bytecode_byte(emit, b); - emit_write_uint(emit, emit_get_cur_to_write_bytecode, val); -} - - -static void emit_write_bytecode_byte_const(emit_t *emit, byte b, mp_uint_t n, mp_uint_t c) { - if (emit->pass == MP_PASS_EMIT) { - emit->const_table[n] = c; - } - emit_write_bytecode_byte_uint(emit, b, n); -} - - -static void emit_write_bytecode_byte_qstr(emit_t* emit, byte b, qstr qst) { - - -# 239 "user/mpy/py/emitbc.c" 3 - (( -# 239 "user/mpy/py/emitbc.c" - (qst >> 16) == 0 -# 239 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 239, __func__, -# 239 "user/mpy/py/emitbc.c" - "(qst >> 16) == 0" -# 239 "user/mpy/py/emitbc.c" 3 - )) -# 239 "user/mpy/py/emitbc.c" - ; - byte *c = emit_get_cur_to_write_bytecode(emit, 3); - c[0] = b; - c[1] = qst; - c[2] = qst >> 8; - - - -} - -static void emit_write_bytecode_byte_obj(emit_t *emit, byte b, mp_obj_t obj) { - - emit_write_bytecode_byte_const(emit, b, - emit->scope->num_pos_args + emit->scope->num_kwonly_args - + emit->ct_cur_obj++, (mp_uint_t)obj); -# 263 "user/mpy/py/emitbc.c" -} - -static void emit_write_bytecode_byte_raw_code(emit_t *emit, byte b, mp_raw_code_t *rc) { - - emit_write_bytecode_byte_const(emit, b, - emit->scope->num_pos_args + emit->scope->num_kwonly_args - + emit->ct_num_obj + emit->ct_cur_raw_code++, (mp_uint_t)(uintptr_t)rc); -# 279 "user/mpy/py/emitbc.c" -} - - -static void emit_write_bytecode_byte_unsigned_label(emit_t *emit, byte b1, mp_uint_t label) { - mp_uint_t bytecode_offset; - if (emit->pass < MP_PASS_EMIT) { - bytecode_offset = 0; - } else { - bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3; - } - byte *c = emit_get_cur_to_write_bytecode(emit, 3); - c[0] = b1; - c[1] = bytecode_offset; - c[2] = bytecode_offset >> 8; -} - - -static void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint_t label) { - int bytecode_offset; - if (emit->pass < MP_PASS_EMIT) { - bytecode_offset = 0; - } else { - bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3 + 0x8000; - } - byte *c = emit_get_cur_to_write_bytecode(emit, 3); - c[0] = b1; - c[1] = bytecode_offset; - c[2] = bytecode_offset >> 8; -} - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { - emit->pass = pass; - emit->stack_size = 0; - emit->last_emit_was_return_value = -# 312 "user/mpy/py/emitbc.c" 3 4 - 0 -# 312 "user/mpy/py/emitbc.c" - ; - emit->scope = scope; - emit->last_source_line_offset = 0; - emit->last_source_line = 1; - if (pass < MP_PASS_EMIT) { - memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(mp_uint_t)); - } - emit->bytecode_offset = 0; - emit->code_info_offset = 0; - - - { - mp_uint_t n_state = scope->num_locals + scope->stack_size; - if (n_state == 0) { - - - - n_state = 1; - } - emit_write_code_info_uint(emit, n_state); - emit_write_code_info_uint(emit, scope->exc_stack_size); - } - - - - emit_write_code_info_byte(emit, emit->scope->scope_flags); - emit_write_code_info_byte(emit, emit->scope->num_pos_args); - emit_write_code_info_byte(emit, emit->scope->num_kwonly_args); - emit_write_code_info_byte(emit, emit->scope->num_def_pos_args); - - - - - if (pass == MP_PASS_EMIT) { - emit_write_code_info_uint(emit, emit->code_info_size - emit->code_info_offset); - } else { - emit_get_cur_to_write_code_info(emit, 2); - } - - - emit_write_code_info_qstr(emit, scope->simple_name); - emit_write_code_info_qstr(emit, scope->source_file); - - - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL) { - -# 359 "user/mpy/py/emitbc.c" 3 - (( -# 359 "user/mpy/py/emitbc.c" - id->local_num < 255 -# 359 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 359, __func__, -# 359 "user/mpy/py/emitbc.c" - "id->local_num < 255" -# 359 "user/mpy/py/emitbc.c" 3 - )) -# 359 "user/mpy/py/emitbc.c" - ; - emit_write_bytecode_byte(emit, id->local_num); - } - } - emit_write_bytecode_byte(emit, 255); - - - emit->ct_cur_obj = 0; - emit->ct_cur_raw_code = 0; - - - if (pass == MP_PASS_EMIT) { -# 386 "user/mpy/py/emitbc.c" - for (int i = 0; i < scope->num_pos_args + scope->num_kwonly_args; i++) { - qstr qst = MP_QSTR__star_; - for (int j = 0; j < scope->id_info_len; ++j) { - id_info_t *id = &scope->id_info[j]; - if ((id->flags & ID_FLAG_IS_PARAM) && id->local_num == i) { - qst = id->qst; - break; - } - } - emit->const_table[i] = (mp_uint_t)((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)); - } - } -} - -void mp_emit_bc_end_pass(emit_t *emit) { - if (emit->pass == MP_PASS_SCOPE) { - return; - } - - - -# 406 "user/mpy/py/emitbc.c" 3 - (( -# 406 "user/mpy/py/emitbc.c" - emit->stack_size == 0 -# 406 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 406, __func__, -# 406 "user/mpy/py/emitbc.c" - "emit->stack_size == 0" -# 406 "user/mpy/py/emitbc.c" 3 - )) -# 406 "user/mpy/py/emitbc.c" - ; - - emit_write_code_info_byte(emit, 0); - - - -# 411 "user/mpy/py/emitbc.c" 3 - (( -# 411 "user/mpy/py/emitbc.c" - emit->pass <= MP_PASS_STACK_SIZE || (emit->ct_num_obj == emit->ct_cur_obj) -# 411 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 411, __func__, -# 411 "user/mpy/py/emitbc.c" - "emit->pass <= MP_PASS_STACK_SIZE || (emit->ct_num_obj == emit->ct_cur_obj)" -# 411 "user/mpy/py/emitbc.c" 3 - )) -# 411 "user/mpy/py/emitbc.c" - ; - emit->ct_num_obj = emit->ct_cur_obj; - - - if (emit->pass == MP_PASS_CODE_SIZE) { - - - - - - - emit->code_info_size = emit->code_info_offset; - emit->bytecode_size = emit->bytecode_offset; - emit->code_base = ((byte*)(m_malloc0(sizeof(byte) * (emit->code_info_size + emit->bytecode_size)))); - - - emit->const_table = ((mp_uint_t*)(m_malloc0(sizeof(mp_uint_t) * (emit->scope->num_pos_args + emit->scope->num_kwonly_args + emit->ct_cur_obj + emit->ct_cur_raw_code)))) - - ; - - - - - - } else if (emit->pass == MP_PASS_EMIT) { - mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base, - emit->code_info_size + emit->bytecode_size, - emit->const_table, - - - - emit->scope->scope_flags); - } -} - - -# 446 "user/mpy/py/emitbc.c" 3 4 -_Bool -# 446 "user/mpy/py/emitbc.c" - mp_emit_bc_last_emit_was_return_value(emit_t *emit) { - return emit->last_emit_was_return_value; -} - -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta) { - if (emit->pass == MP_PASS_SCOPE) { - return; - } - -# 454 "user/mpy/py/emitbc.c" 3 - (( -# 454 "user/mpy/py/emitbc.c" - (mp_int_t)emit->stack_size + delta >= 0 -# 454 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 454, __func__, -# 454 "user/mpy/py/emitbc.c" - "(mp_int_t)emit->stack_size + delta >= 0" -# 454 "user/mpy/py/emitbc.c" 3 - )) -# 454 "user/mpy/py/emitbc.c" - ; - emit->stack_size += delta; - if (emit->stack_size > emit->scope->stack_size) { - emit->scope->stack_size = emit->stack_size; - } - emit->last_emit_was_return_value = -# 459 "user/mpy/py/emitbc.c" 3 4 - 0 -# 459 "user/mpy/py/emitbc.c" - ; -} - -static inline void emit_bc_pre(emit_t *emit, mp_int_t stack_size_delta) { - mp_emit_bc_adjust_stack_size(emit, stack_size_delta); -} - -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) { -# 481 "user/mpy/py/emitbc.c" - (void)emit; - (void)source_line; - -} - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) { - emit_bc_pre(emit, 0); - if (emit->pass == MP_PASS_SCOPE) { - return; - } - -# 491 "user/mpy/py/emitbc.c" 3 - (( -# 491 "user/mpy/py/emitbc.c" - l < emit->max_num_labels -# 491 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 491, __func__, -# 491 "user/mpy/py/emitbc.c" - "l < emit->max_num_labels" -# 491 "user/mpy/py/emitbc.c" 3 - )) -# 491 "user/mpy/py/emitbc.c" - ; - if (emit->pass < MP_PASS_EMIT) { - - -# 494 "user/mpy/py/emitbc.c" 3 - (( -# 494 "user/mpy/py/emitbc.c" - emit->label_offsets[l] == (mp_uint_t)-1 -# 494 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 494, __func__, -# 494 "user/mpy/py/emitbc.c" - "emit->label_offsets[l] == (mp_uint_t)-1" -# 494 "user/mpy/py/emitbc.c" 3 - )) -# 494 "user/mpy/py/emitbc.c" - ; - emit->label_offsets[l] = emit->bytecode_offset; - } else { - - - -# 499 "user/mpy/py/emitbc.c" 3 - (( -# 499 "user/mpy/py/emitbc.c" - emit->label_offsets[l] == emit->bytecode_offset -# 499 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 499, __func__, -# 499 "user/mpy/py/emitbc.c" - "emit->label_offsets[l] == emit->bytecode_offset" -# 499 "user/mpy/py/emitbc.c" 3 - )) -# 499 "user/mpy/py/emitbc.c" - ; - } -} - -void mp_emit_bc_import_name(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_qstr(emit, (0x68), qst); -} - -void mp_emit_bc_import_from(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, (0x69), qst); -} - -void mp_emit_bc_import_star(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, (0x6a)); -} - -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { - emit_bc_pre(emit, 1); - switch (tok) { - case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, (0x10)); break; - case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, (0x11)); break; - case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, (0x12)); break; - default: - -# 525 "user/mpy/py/emitbc.c" 3 - (( -# 525 "user/mpy/py/emitbc.c" - tok == MP_TOKEN_ELLIPSIS -# 525 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 525, __func__, -# 525 "user/mpy/py/emitbc.c" - "tok == MP_TOKEN_ELLIPSIS" -# 525 "user/mpy/py/emitbc.c" 3 - )) -# 525 "user/mpy/py/emitbc.c" - ; - emit_write_bytecode_byte_obj(emit, (0x17), ((mp_obj_t)&mp_const_ellipsis_obj)); - break; - } -} - -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) { - emit_bc_pre(emit, 1); - if (-16 <= arg && arg <= 47) { - emit_write_bytecode_byte(emit, (0x70) + 16 + arg); - } else { - emit_write_bytecode_byte_int(emit, (0x14), arg); - } -} - -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, (0x16), qst); -} - -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_obj(emit, (0x17), obj); -} - -void mp_emit_bc_load_null(emit_t *emit) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte(emit, (0x18)); -}; - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, 1); - if (local_num <= 15) { - emit_write_bytecode_byte(emit, (0xb0) + local_num); - } else { - emit_write_bytecode_byte_uint(emit, (0x19), local_num); - } -} - -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_uint(emit, (0x1a), local_num); -} - -void mp_emit_bc_load_name(emit_t *emit, qstr qst) { - (void)qst; - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, (0x1b), qst); - if ((0)) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_load_global(emit_t *emit, qstr qst) { - (void)qst; - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, (0x1c), qst); - if ((0)) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_load_attr(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_qstr(emit, (0x1d), qst); - if ((0)) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 597 "user/mpy/py/emitbc.c" 3 4 - _Bool -# 597 "user/mpy/py/emitbc.c" - is_super) { - emit_bc_pre(emit, 1 - 2 * is_super); - emit_write_bytecode_byte_qstr(emit, is_super ? (0x1f) : (0x1e), qst); -} - -void mp_emit_bc_load_build_class(emit_t *emit) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte(emit, (0x20)); -} - -void mp_emit_bc_load_subscr(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, (0x21)); -} - -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, -1); - if (local_num <= 15) { - emit_write_bytecode_byte(emit, (0xc0) + local_num); - } else { - emit_write_bytecode_byte_uint(emit, (0x22), local_num); - } -} - -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_uint(emit, (0x23), local_num); -} - -void mp_emit_bc_store_name(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_qstr(emit, (0x24), qst); -} - -void mp_emit_bc_store_global(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_qstr(emit, (0x25), qst); -} - -void mp_emit_bc_store_attr(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -2); - emit_write_bytecode_byte_qstr(emit, (0x26), qst); - if ((0)) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_store_subscr(emit_t *emit) { - emit_bc_pre(emit, -3); - emit_write_bytecode_byte(emit, (0x27)); -} - -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_write_bytecode_byte_uint(emit, (0x28), local_num); -} - -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_write_bytecode_byte_uint(emit, (0x29), local_num); -} - -void mp_emit_bc_delete_name(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_qstr(emit, (0x2a), qst); -} - -void mp_emit_bc_delete_global(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_qstr(emit, (0x2b), qst); -} - -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst) { - mp_emit_bc_load_null(emit); - mp_emit_bc_rot_two(emit); - mp_emit_bc_store_attr(emit, qst); -} - -void mp_emit_bc_delete_subscr(emit_t *emit) { - mp_emit_bc_load_null(emit); - mp_emit_bc_rot_three(emit); - mp_emit_bc_store_subscr(emit); -} - -void mp_emit_bc_dup_top(emit_t *emit) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte(emit, (0x30)); -} - -void mp_emit_bc_dup_top_two(emit_t *emit) { - emit_bc_pre(emit, 2); - emit_write_bytecode_byte(emit, (0x31)); -} - -void mp_emit_bc_pop_top(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, (0x32)); -} - -void mp_emit_bc_rot_two(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, (0x33)); -} - -void mp_emit_bc_rot_three(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, (0x34)); -} - -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_signed_label(emit, (0x35), label); -} - -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 713 "user/mpy/py/emitbc.c" 3 4 - _Bool -# 713 "user/mpy/py/emitbc.c" - cond, mp_uint_t label) { - emit_bc_pre(emit, -1); - if (cond) { - emit_write_bytecode_byte_signed_label(emit, (0x36), label); - } else { - emit_write_bytecode_byte_signed_label(emit, (0x37), label); - } -} - -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 722 "user/mpy/py/emitbc.c" 3 4 - _Bool -# 722 "user/mpy/py/emitbc.c" - cond, mp_uint_t label) { - emit_bc_pre(emit, -1); - if (cond) { - emit_write_bytecode_byte_signed_label(emit, (0x38), label); - } else { - emit_write_bytecode_byte_signed_label(emit, (0x39), label); - } -} - -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { - if (except_depth == 0) { - emit_bc_pre(emit, 0); - if (label & (0x8000)) { - - emit_write_bytecode_byte(emit, (0x32)); - - for (size_t i = 0; i < ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) - 1; ++i) { - emit_write_bytecode_byte(emit, (0x32)); - } - } - emit_write_bytecode_byte_signed_label(emit, (0x35), label & ~(0x8000)); - } else { - emit_write_bytecode_byte_signed_label(emit, (0x46), label & ~(0x8000)); - emit_write_bytecode_byte(emit, ((label & (0x8000)) ? 0x80 : 0) | except_depth); - } -} - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label) { - - - emit_bc_pre(emit, 2); - emit_write_bytecode_byte_unsigned_label(emit, (0x3d), label); -} - -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label) { - mp_emit_bc_pop_block(emit); - mp_emit_bc_load_const_tok(emit, MP_TOKEN_KW_NONE); - mp_emit_bc_label_assign(emit, label); - emit_bc_pre(emit, 2); - emit_write_bytecode_byte(emit, (0x3e)); - emit_bc_pre(emit, -4); -} - -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_unsigned_label(emit, (0x3f), label); -} - -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_unsigned_label(emit, (0x40), label); -} - -void mp_emit_bc_end_finally(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, (0x41)); -} - -void mp_emit_bc_get_iter(emit_t *emit, -# 780 "user/mpy/py/emitbc.c" 3 4 - _Bool -# 780 "user/mpy/py/emitbc.c" - use_stack) { - emit_bc_pre(emit, use_stack ? ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) - 1 : 0); - emit_write_bytecode_byte(emit, use_stack ? (0x47) : (0x42)); -} - -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_unsigned_label(emit, (0x43), label); -} - -void mp_emit_bc_for_iter_end(emit_t *emit) { - emit_bc_pre(emit, -((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t))); -} - -void mp_emit_bc_pop_block(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, (0x44)); -} - -void mp_emit_bc_pop_except(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, (0x45)); -} - -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, (0xd0) + op); -} - -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op) { - -# 810 "user/mpy/py/emitbc.c" 3 4 - _Bool -# 810 "user/mpy/py/emitbc.c" - invert = -# 810 "user/mpy/py/emitbc.c" 3 4 - 0 -# 810 "user/mpy/py/emitbc.c" - ; - if (op == MP_BINARY_OP_NOT_IN) { - invert = -# 812 "user/mpy/py/emitbc.c" 3 4 - 1 -# 812 "user/mpy/py/emitbc.c" - ; - op = MP_BINARY_OP_IN; - } else if (op == MP_BINARY_OP_IS_NOT) { - invert = -# 815 "user/mpy/py/emitbc.c" 3 4 - 1 -# 815 "user/mpy/py/emitbc.c" - ; - op = MP_BINARY_OP_IS; - } - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, (0xd7) + op); - if (invert) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, (0xd0) + MP_UNARY_OP_NOT); - } -} - -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1 - n_args); - emit_write_bytecode_byte_uint(emit, (0x50), n_args); -} - -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1 - n_args); - emit_write_bytecode_byte_uint(emit, (0x51), n_args); -} - -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_uint(emit, (0x53), n_args); -} - -void mp_emit_bc_store_map(emit_t *emit) { - emit_bc_pre(emit, -2); - emit_write_bytecode_byte(emit, (0x54)); -} -# 860 "user/mpy/py/emitbc.c" -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_stack_index) { - int t; - int n; - if (kind == SCOPE_LIST_COMP) { - n = 0; - t = 0; - } else if (!(0) || kind == SCOPE_DICT_COMP) { - n = 1; - t = 1; - } else if ((0)) { - n = 0; - t = 2; - } - emit_bc_pre(emit, -1 - n); - - emit_write_bytecode_byte_uint(emit, (0x57), ((collection_stack_index + n) << 2) | t); -} - -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, -1 + n_args); - emit_write_bytecode_byte_uint(emit, (0x59), n_args); -} - -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) { - emit_bc_pre(emit, -1 + n_left + n_right + 1); - emit_write_bytecode_byte_uint(emit, (0x5a), n_left | (n_right << 8)); -} - -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { - if (n_pos_defaults == 0 && n_kw_defaults == 0) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_raw_code(emit, (0x60), scope->raw_code); - } else { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_raw_code(emit, (0x61), scope->raw_code); - } -} - -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { - if (n_pos_defaults == 0 && n_kw_defaults == 0) { - emit_bc_pre(emit, -n_closed_over + 1); - emit_write_bytecode_byte_raw_code(emit, (0x62), scope->raw_code); - emit_write_bytecode_byte(emit, n_closed_over); - } else { - -# 904 "user/mpy/py/emitbc.c" 3 - (( -# 904 "user/mpy/py/emitbc.c" - n_closed_over <= 255 -# 904 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 904, __func__, -# 904 "user/mpy/py/emitbc.c" - "n_closed_over <= 255" -# 904 "user/mpy/py/emitbc.c" 3 - )) -# 904 "user/mpy/py/emitbc.c" - ; - emit_bc_pre(emit, -2 - (mp_int_t)n_closed_over + 1); - emit_write_bytecode_byte_raw_code(emit, (0x63), scope->raw_code); - emit_write_bytecode_byte(emit, n_closed_over); - } -} - -static void emit_bc_call_function_method_helper(emit_t *emit, mp_int_t stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - if (star_flags) { - emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword - 2); - emit_write_bytecode_byte_uint(emit, bytecode_base + 1, (n_keyword << 8) | n_positional); - } else { - emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword); - emit_write_bytecode_byte_uint(emit, bytecode_base, (n_keyword << 8) | n_positional); - } -} - -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - emit_bc_call_function_method_helper(emit, 0, (0x64), n_positional, n_keyword, star_flags); -} - -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - emit_bc_call_function_method_helper(emit, -1, (0x66), n_positional, n_keyword, star_flags); -} - -void mp_emit_bc_return_value(emit_t *emit) { - emit_bc_pre(emit, -1); - emit->last_emit_was_return_value = -# 931 "user/mpy/py/emitbc.c" 3 4 - 1 -# 931 "user/mpy/py/emitbc.c" - ; - emit_write_bytecode_byte(emit, (0x5b)); -} - -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args) { - -# 936 "user/mpy/py/emitbc.c" 3 - (( -# 936 "user/mpy/py/emitbc.c" - n_args <= 2 -# 936 "user/mpy/py/emitbc.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitbc.c", 936, __func__, -# 936 "user/mpy/py/emitbc.c" - "n_args <= 2" -# 936 "user/mpy/py/emitbc.c" 3 - )) -# 936 "user/mpy/py/emitbc.c" - ; - emit_bc_pre(emit, -n_args); - emit_write_bytecode_byte_byte(emit, (0x5c), n_args); -} - -void mp_emit_bc_yield_value(emit_t *emit) { - emit_bc_pre(emit, 0); - emit->scope->scope_flags |= (0x04); - emit_write_bytecode_byte(emit, (0x5d)); -} - -void mp_emit_bc_yield_from(emit_t *emit) { - emit_bc_pre(emit, -1); - emit->scope->scope_flags |= (0x04); - emit_write_bytecode_byte(emit, (0x5e)); -} - -void mp_emit_bc_start_except_handler(emit_t *emit) { - mp_emit_bc_adjust_stack_size(emit, 4); -} - -void mp_emit_bc_end_except_handler(emit_t *emit) { - mp_emit_bc_adjust_stack_size(emit, -3); -} -# 1054 "user/mpy/py/emitbc.c" -const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops = { - mp_emit_bc_load_fast, - mp_emit_bc_load_deref, - mp_emit_bc_load_name, - mp_emit_bc_load_global, -}; - -const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops = { - mp_emit_bc_store_fast, - mp_emit_bc_store_deref, - mp_emit_bc_store_name, - mp_emit_bc_store_global, -}; - -const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops = { - mp_emit_bc_delete_fast, - mp_emit_bc_delete_deref, - mp_emit_bc_delete_name, - mp_emit_bc_delete_global, -}; -# 1 "user/mpy/py/asmbase.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/asmbase.c" -# 27 "user/mpy/py/asmbase.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/asmbase.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/asmbase.c" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 31 "user/mpy/py/asmbase.c" 2 - -# 1 "user/mpy/py/asmbase.h" 1 -# 35 "user/mpy/py/asmbase.h" -typedef struct _mp_asm_base_t { - int pass; - size_t code_offset; - size_t code_size; - uint8_t *code_base; - - size_t max_num_labels; - size_t *label_offsets; -} mp_asm_base_t; - -void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); -void mp_asm_base_deinit(mp_asm_base_t *as, -# 46 "user/mpy/py/asmbase.h" 3 4 - _Bool -# 46 "user/mpy/py/asmbase.h" - free_code); -void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); -uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); -void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); -void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); -void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); - -static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { - return as->code_offset; -} - -static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { - return as->code_size; -} - -static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { - - - - return as->code_base; - -} -# 33 "user/mpy/py/asmbase.c" 2 -# 1 "user/mpy/py/asmx64.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/asmx64.c" -# 27 "user/mpy/py/asmx64.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/asmx64.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/asmx64.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/asmx64.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/asmx64.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 33 "user/mpy/py/asmx64.c" 2 -# 1 "user/mpy/py/asmx86.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/asmx86.c" -# 27 "user/mpy/py/asmx86.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/asmx86.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/asmx86.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/asmx86.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/asmx86.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 33 "user/mpy/py/asmx86.c" 2 -# 1 "user/mpy/py/asmthumb.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/asmthumb.c" -# 27 "user/mpy/py/asmthumb.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/asmthumb.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/asmthumb.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/asmthumb.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/asmthumb.c" 2 -# 1 "user/mpy/py/emitinlinethumb.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/emitinlinethumb.c" -# 27 "user/mpy/py/emitinlinethumb.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/emitinlinethumb.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/emitinlinethumb.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/emitinlinethumb.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 31 "user/mpy/py/emitinlinethumb.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/emitinlinethumb.c" 2 - -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 31 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 31 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 34 "user/mpy/py/emitinlinethumb.c" 2 -# 1 "user/mpy/py/asmthumb.h" 1 -# 30 "user/mpy/py/asmthumb.h" -# 1 "user/mpy/py/asmbase.h" 1 -# 35 "user/mpy/py/asmbase.h" -typedef struct _mp_asm_base_t { - int pass; - size_t code_offset; - size_t code_size; - uint8_t *code_base; - - size_t max_num_labels; - size_t *label_offsets; -} mp_asm_base_t; - -void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); -void mp_asm_base_deinit(mp_asm_base_t *as, -# 46 "user/mpy/py/asmbase.h" 3 4 - _Bool -# 46 "user/mpy/py/asmbase.h" - free_code); -void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); -uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); -void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); -void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); -void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); - -static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { - return as->code_offset; -} - -static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { - return as->code_size; -} - -static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { - - - - return as->code_base; - -} -# 31 "user/mpy/py/asmthumb.h" 2 -# 65 "user/mpy/py/asmthumb.h" -typedef struct _asm_thumb_t { - mp_asm_base_t base; - uint32_t push_reglist; - uint32_t stack_adjust; -} asm_thumb_t; - -void asm_thumb_end_pass(asm_thumb_t *as); - -void asm_thumb_entry(asm_thumb_t *as, int num_locals); -void asm_thumb_exit(asm_thumb_t *as); -# 93 "user/mpy/py/asmthumb.h" -void asm_thumb_op16(asm_thumb_t *as, uint op); -void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2); - -static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask) - { asm_thumb_op16(as, (0xbf00) | (cc << 4) | mask); } -# 108 "user/mpy/py/asmthumb.h" -static inline void asm_thumb_format_1(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, uint offset) { - -# 109 "user/mpy/py/asmthumb.h" 3 - (( -# 109 "user/mpy/py/asmthumb.h" - rlo_dest < (8) -# 109 "user/mpy/py/asmthumb.h" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 109, __func__, -# 109 "user/mpy/py/asmthumb.h" - "rlo_dest < ASM_THUMB_REG_R8" -# 109 "user/mpy/py/asmthumb.h" 3 - )) -# 109 "user/mpy/py/asmthumb.h" - ; - -# 110 "user/mpy/py/asmthumb.h" 3 - (( -# 110 "user/mpy/py/asmthumb.h" - rlo_src < (8) -# 110 "user/mpy/py/asmthumb.h" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 110, __func__, -# 110 "user/mpy/py/asmthumb.h" - "rlo_src < ASM_THUMB_REG_R8" -# 110 "user/mpy/py/asmthumb.h" 3 - )) -# 110 "user/mpy/py/asmthumb.h" - ; - asm_thumb_op16(as, ((op) | ((offset) << 6) | ((rlo_src) << 3) | (rlo_dest))); -} -# 124 "user/mpy/py/asmthumb.h" -static inline void asm_thumb_format_2(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, int src_b) { - -# 125 "user/mpy/py/asmthumb.h" 3 - (( -# 125 "user/mpy/py/asmthumb.h" - rlo_dest < (8) -# 125 "user/mpy/py/asmthumb.h" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 125, __func__, -# 125 "user/mpy/py/asmthumb.h" - "rlo_dest < ASM_THUMB_REG_R8" -# 125 "user/mpy/py/asmthumb.h" 3 - )) -# 125 "user/mpy/py/asmthumb.h" - ; - -# 126 "user/mpy/py/asmthumb.h" 3 - (( -# 126 "user/mpy/py/asmthumb.h" - rlo_src < (8) -# 126 "user/mpy/py/asmthumb.h" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 126, __func__, -# 126 "user/mpy/py/asmthumb.h" - "rlo_src < ASM_THUMB_REG_R8" -# 126 "user/mpy/py/asmthumb.h" 3 - )) -# 126 "user/mpy/py/asmthumb.h" - ; - asm_thumb_op16(as, ((op) | ((src_b) << 6) | ((rlo_src) << 3) | (rlo_dest))); -} - -static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) - { asm_thumb_format_2(as, (0x1800) | (0x0000), rlo_dest, rlo_src_a, rlo_src_b); } -static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) - { asm_thumb_format_2(as, (0x1800) | (0x0400), rlo_dest, rlo_src_a, i3_src); } -static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) - { asm_thumb_format_2(as, (0x1a00) | (0x0000), rlo_dest, rlo_src_a, rlo_src_b); } -static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) - { asm_thumb_format_2(as, (0x1a00) | (0x0400), rlo_dest, rlo_src_a, i3_src); } -# 149 "user/mpy/py/asmthumb.h" -static inline void asm_thumb_format_3(asm_thumb_t *as, uint op, uint rlo, int i8) { - -# 150 "user/mpy/py/asmthumb.h" 3 - (( -# 150 "user/mpy/py/asmthumb.h" - rlo < (8) -# 150 "user/mpy/py/asmthumb.h" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/asmthumb.h", 150, __func__, -# 150 "user/mpy/py/asmthumb.h" - "rlo < ASM_THUMB_REG_R8" -# 150 "user/mpy/py/asmthumb.h" 3 - )) -# 150 "user/mpy/py/asmthumb.h" - ; - asm_thumb_op16(as, ((op) | ((rlo) << 8) | (i8))); -} - -static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x2000), rlo, i8); } -static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x2800), rlo, i8); } -static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x3000), rlo, i8); } -static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, (0x3800), rlo, i8); } -# 178 "user/mpy/py/asmthumb.h" -void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src); - -static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src) { asm_thumb_format_4(as, (0x4280), rlo_dest, rlo_src); } -# 200 "user/mpy/py/asmthumb.h" -static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_base, uint offset) - { asm_thumb_op16(as, ((op) | (((offset) << 6) & 0x07c0) | ((rlo_base) << 3) | (rlo_dest))); } - -static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint word_offset) - { asm_thumb_format_9_10(as, (0x6000) | (0x0000), rlo_src, rlo_base, word_offset); } -static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, (0x6000) | (0x1000), rlo_src, rlo_base, byte_offset); } -static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, (0x8000), rlo_src, rlo_base, byte_offset); } -static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint word_offset) - { asm_thumb_format_9_10(as, (0x6800) | (0x0000), rlo_dest, rlo_base, word_offset); } -static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, (0x6800) | (0x1000) , rlo_dest, rlo_base, byte_offset); } -static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, (0x8800), rlo_dest, rlo_base, byte_offset); } - - - - - - -void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src); -void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src); - - - -# 225 "user/mpy/py/asmthumb.h" 3 4 -_Bool -# 225 "user/mpy/py/asmthumb.h" - asm_thumb_b_n_label(asm_thumb_t *as, uint label); - -# 226 "user/mpy/py/asmthumb.h" 3 4 -_Bool -# 226 "user/mpy/py/asmthumb.h" - asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, -# 226 "user/mpy/py/asmthumb.h" 3 4 - _Bool -# 226 "user/mpy/py/asmthumb.h" - wide); - -# 227 "user/mpy/py/asmthumb.h" 3 4 -_Bool -# 227 "user/mpy/py/asmthumb.h" - asm_thumb_bl_label(asm_thumb_t *as, uint label); - -void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32_src); -void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32_src); -void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32); -void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num_dest, uint rlo_src); -void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num); -void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num); - -void asm_thumb_b_label(asm_thumb_t *as, uint label); -void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); -void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); -# 35 "user/mpy/py/emitinlinethumb.c" 2 -# 1 "user/mpy/py/asmarm.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/asmarm.c" -# 28 "user/mpy/py/asmarm.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/asmarm.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/asmarm.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/asmarm.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 33 "user/mpy/py/asmarm.c" 2 -# 1 "user/mpy/py/asmxtensa.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/asmxtensa.c" -# 27 "user/mpy/py/asmxtensa.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/asmxtensa.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/asmxtensa.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 31 "user/mpy/py/asmxtensa.c" 2 -# 1 "user/mpy/py/emitinlinextensa.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/emitinlinextensa.c" -# 27 "user/mpy/py/emitinlinextensa.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/emitinlinextensa.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/emitinlinextensa.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/emitinlinextensa.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 31 "user/mpy/py/emitinlinextensa.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/emitinlinextensa.c" 2 - -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 31 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 31 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 34 "user/mpy/py/emitinlinextensa.c" 2 -# 1 "user/mpy/py/asmxtensa.h" 1 -# 29 "user/mpy/py/asmxtensa.h" -# 1 "user/mpy/py/asmbase.h" 1 -# 35 "user/mpy/py/asmbase.h" -typedef struct _mp_asm_base_t { - int pass; - size_t code_offset; - size_t code_size; - uint8_t *code_base; - - size_t max_num_labels; - size_t *label_offsets; -} mp_asm_base_t; - -void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); -void mp_asm_base_deinit(mp_asm_base_t *as, -# 46 "user/mpy/py/asmbase.h" 3 4 - _Bool -# 46 "user/mpy/py/asmbase.h" - free_code); -void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); -uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); -void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); -void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); -void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); - -static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { - return as->code_offset; -} - -static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { - return as->code_size; -} - -static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { - - - - return as->code_base; - -} -# 30 "user/mpy/py/asmxtensa.h" 2 -# 98 "user/mpy/py/asmxtensa.h" -typedef struct _asm_xtensa_t { - mp_asm_base_t base; - uint32_t cur_const; - uint32_t num_const; - uint32_t *const_table; - uint32_t stack_adjust; -} asm_xtensa_t; - -void asm_xtensa_end_pass(asm_xtensa_t *as); - -void asm_xtensa_entry(asm_xtensa_t *as, int num_locals); -void asm_xtensa_exit(asm_xtensa_t *as); - -void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op); -void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op); - - - -static inline void asm_xtensa_op_add(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ((((uint32_t)8) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); -} - -static inline void asm_xtensa_op_addi(asm_xtensa_t *as, uint reg_dest, uint reg_src, int imm8) { - asm_xtensa_op24(as, ((((uint32_t)imm8 & 0xff) << 16) | ((12) << 12) | ((reg_dest) << 8) | ((reg_src) << 4) | (2))); -} - -static inline void asm_xtensa_op_and(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ((((uint32_t)1) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); -} - -static inline void asm_xtensa_op_bcc(asm_xtensa_t *as, uint cond, uint reg_src1, uint reg_src2, int32_t rel8) { - asm_xtensa_op24(as, ((((uint32_t)rel8 & 0xff) << 16) | ((cond) << 12) | ((reg_src1) << 8) | ((reg_src2) << 4) | (7))); -} - -static inline void asm_xtensa_op_bccz(asm_xtensa_t *as, uint cond, uint reg_src, int32_t rel12) { - asm_xtensa_op24(as, (((rel12 & 0xfff) << 12) | ((reg_src) << 8) | ((cond) << 6) | ((1) << 4) | (6))); -} - -static inline void asm_xtensa_op_callx0(asm_xtensa_t *as, uint reg) { - asm_xtensa_op24(as, ((((uint32_t)0) << 20) | (((uint32_t)0) << 16) | ((0) << 12) | ((reg) << 8) | ((3) << 6) | ((0) << 4) | (0))); -} - -static inline void asm_xtensa_op_j(asm_xtensa_t *as, int32_t rel18) { - asm_xtensa_op24(as, (((rel18 & 0x3ffff) << 6) | ((0) << 4) | (6))); -} - -static inline void asm_xtensa_op_jx(asm_xtensa_t *as, uint reg) { - asm_xtensa_op24(as, ((((uint32_t)0) << 20) | (((uint32_t)0) << 16) | ((0) << 12) | ((reg) << 8) | ((2) << 6) | ((2) << 4) | (0))); -} - -static inline void asm_xtensa_op_l8ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint byte_offset) { - asm_xtensa_op24(as, ((((uint32_t)byte_offset & 0xff) << 16) | ((0) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (2))); -} - -static inline void asm_xtensa_op_l16ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint half_word_offset) { - asm_xtensa_op24(as, ((((uint32_t)half_word_offset & 0xff) << 16) | ((1) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (2))); -} - -static inline void asm_xtensa_op_l32i(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { - asm_xtensa_op24(as, ((((uint32_t)word_offset & 0xff) << 16) | ((2) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (2))); -} - -static inline void asm_xtensa_op_l32i_n(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { - asm_xtensa_op16(as, (((word_offset & 0xf) << 12) | ((reg_base) << 8) | ((reg_dest) << 4) | (8))); -} - -static inline void asm_xtensa_op_l32r(asm_xtensa_t *as, uint reg_dest, uint32_t op_off, uint32_t dest_off) { - asm_xtensa_op24(as, (((((dest_off - ((op_off + 3) & ~3)) >> 2) & 0xffff) << 8) | ((reg_dest) << 4) | (1))); -} - -static inline void asm_xtensa_op_mov_n(asm_xtensa_t *as, uint reg_dest, uint reg_src) { - asm_xtensa_op16(as, (((0) << 12) | ((reg_src) << 8) | ((reg_dest) << 4) | (13))); -} - -static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t imm12) { - asm_xtensa_op24(as, ((((uint32_t)imm12 & 0xff) << 16) | ((10) << 12) | (((imm12 >> 8) & 0xf) << 8) | ((reg_dest) << 4) | (2))); -} - -static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) { - asm_xtensa_op16(as, ((((imm4) & 0xf) << 12) | ((reg_dest) << 8) | ((imm4) & 0x70) | (12))); -} - -static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ((((uint32_t)8) << 20) | (((uint32_t)2) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); -} - -static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ((((uint32_t)2) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); -} - -static inline void asm_xtensa_op_ret_n(asm_xtensa_t *as) { - asm_xtensa_op16(as, (((15) << 12) | ((0) << 8) | ((0) << 4) | (13))); -} - -static inline void asm_xtensa_op_s8i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint byte_offset) { - asm_xtensa_op24(as, ((((uint32_t)byte_offset & 0xff) << 16) | ((4) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (2))); -} - -static inline void asm_xtensa_op_s16i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint half_word_offset) { - asm_xtensa_op24(as, ((((uint32_t)half_word_offset & 0xff) << 16) | ((5) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (2))); -} - -static inline void asm_xtensa_op_s32i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { - asm_xtensa_op24(as, ((((uint32_t)word_offset & 0xff) << 16) | ((6) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (2))); -} - -static inline void asm_xtensa_op_s32i_n(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { - asm_xtensa_op16(as, (((word_offset & 0xf) << 12) | ((reg_base) << 8) | ((reg_src) << 4) | (9))); -} - -static inline void asm_xtensa_op_sll(asm_xtensa_t *as, uint reg_dest, uint reg_src) { - asm_xtensa_op24(as, ((((uint32_t)10) << 20) | (((uint32_t)1) << 16) | ((reg_dest) << 12) | ((reg_src) << 8) | ((0) << 4) | (0))); -} - -static inline void asm_xtensa_op_sra(asm_xtensa_t *as, uint reg_dest, uint reg_src) { - asm_xtensa_op24(as, ((((uint32_t)11) << 20) | (((uint32_t)1) << 16) | ((reg_dest) << 12) | ((0) << 8) | ((reg_src) << 4) | (0))); -} - -static inline void asm_xtensa_op_ssl(asm_xtensa_t *as, uint reg_src) { - asm_xtensa_op24(as, ((((uint32_t)4) << 20) | (((uint32_t)0) << 16) | ((1) << 12) | ((reg_src) << 8) | ((0) << 4) | (0))); -} - -static inline void asm_xtensa_op_ssr(asm_xtensa_t *as, uint reg_src) { - asm_xtensa_op24(as, ((((uint32_t)4) << 20) | (((uint32_t)0) << 16) | ((0) << 12) | ((reg_src) << 8) | ((0) << 4) | (0))); -} - -static inline void asm_xtensa_op_sub(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ((((uint32_t)12) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); -} - -static inline void asm_xtensa_op_xor(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ((((uint32_t)3) << 20) | (((uint32_t)0) << 16) | ((reg_dest) << 12) | ((reg_src_a) << 8) | ((reg_src_b) << 4) | (0))); -} - - -void asm_xtensa_j_label(asm_xtensa_t *as, uint label); -void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label); -void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label); -void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2); -void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32); -void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src); -void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num); -void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num); -# 35 "user/mpy/py/emitinlinextensa.c" 2 -# 1 "user/mpy/py/formatfloat.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/formatfloat.c" -# 27 "user/mpy/py/formatfloat.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/formatfloat.c" 2 -# 1 "user/mpy/py/parsenumbase.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/parsenumbase.c" -# 27 "user/mpy/py/parsenumbase.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/parsenumbase.c" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 29 "user/mpy/py/parsenumbase.c" 2 -# 1 "user/mpy/py/parsenumbase.h" 1 -# 31 "user/mpy/py/parsenumbase.h" -size_t mp_parse_num_base(const char *str, size_t len, int *base); -# 30 "user/mpy/py/parsenumbase.c" 2 - - - -size_t mp_parse_num_base(const char *str, size_t len, int *base) { - const byte *p = (const byte*)str; - if (len <= 1) { - goto no_prefix; - } - unichar c = *(p++); - if ((*base == 0 || *base == 16) && c == '0') { - c = *(p++); - if ((c | 32) == 'x') { - *base = 16; - } else if (*base == 0 && (c | 32) == 'o') { - *base = 8; - } else if (*base == 0 && (c | 32) == 'b') { - *base = 2; - } else { - if (*base == 0) { - *base = 10; - } - p -= 2; - } - } else if (*base == 8 && c == '0') { - c = *(p++); - if ((c | 32) != 'o') { - p -= 2; - } - } else if (*base == 2 && c == '0') { - c = *(p++); - if ((c | 32) != 'b') { - p -= 2; - } - } else { - p--; - no_prefix: - if (*base == 0) { - *base = 10; - } - } - return p - (const byte*)str; -} -# 1 "user/mpy/py/parsenum.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/parsenum.c" -# 27 "user/mpy/py/parsenum.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 28 "user/mpy/py/parsenum.c" 2 -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 29 "user/mpy/py/parsenum.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 35 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/parsenum.c" 2 -# 1 "user/mpy/py/parsenumbase.h" 1 -# 31 "user/mpy/py/parsenumbase.h" -size_t mp_parse_num_base(const char *str, size_t len, int *base); -# 32 "user/mpy/py/parsenum.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 33 "user/mpy/py/parsenum.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 34 "user/mpy/py/parsenum.c" 2 - - - - - -static __attribute__((noreturn)) void raise_exc(mp_obj_t exc, mp_lexer_t *lex) { - - - if (lex != -# 42 "user/mpy/py/parsenum.c" 3 4 - ((void *)0) -# 42 "user/mpy/py/parsenum.c" - ) { - ((mp_obj_base_t*)((void*)exc))->type = &mp_type_SyntaxError; - mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); - } - nlr_jump(((void*)exc)); -} - -mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, mp_lexer_t *lex) { - const byte *restrict str = (const byte *)str_; - const byte *restrict top = str + len; - -# 52 "user/mpy/py/parsenum.c" 3 4 - _Bool -# 52 "user/mpy/py/parsenum.c" - neg = -# 52 "user/mpy/py/parsenum.c" 3 4 - 0 -# 52 "user/mpy/py/parsenum.c" - ; - mp_obj_t ret_val; - - - if ((base != 0 && base < 2) || base > 36) { - - mp_raise_ValueError("int() arg 2 must be >= 2 and <= 36"); - } - - - for (; str < top && unichar_isspace(*str); str++) { - } - - - if (str < top) { - if (*str == '+') { - str++; - } else if (*str == '-') { - str++; - neg = -# 71 "user/mpy/py/parsenum.c" 3 4 - 1 -# 71 "user/mpy/py/parsenum.c" - ; - } - } - - - str += mp_parse_num_base((const char*)str, top - str, &base); - - - mp_int_t int_val = 0; - const byte *restrict str_val_start = str; - for (; str < top; str++) { - - mp_uint_t dig = *str; - if ('0' <= dig && dig <= '9') { - dig -= '0'; - } else { - dig |= 0x20; - if ('a' <= dig && dig <= 'z') { - dig -= 'a' - 10; - } else { - - break; - } - } - if (dig >= (mp_uint_t)base) { - break; - } - - - if (mp_small_int_mul_overflow(int_val, base)) { - goto overflow; - } - int_val = int_val * base + dig; - if (!((((int_val) ^ ((int_val) << 1)) & (((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) == 0)) { - goto overflow; - } - } - - - if (neg) { - int_val = -int_val; - } - - - ret_val = ((mp_obj_t)((((mp_uint_t)(int_val)) << 1) | 1)); - -have_ret_val: - - if (str == str_val_start) { - goto value_error; - } - - - for (; str < top && unichar_isspace(*str); str++) { - } - - - if (str != top) { - goto value_error; - } - - - return ret_val; - -overflow: - - { - const char *s2 = (const char*)str_val_start; - ret_val = mp_obj_new_int_from_str_len(&s2, top - str_val_start, neg, base); - str = (const byte*)s2; - goto have_ret_val; - } - -value_error: - if (((1)) == (1)) { - mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_ValueError, - "invalid syntax for integer"); - raise_exc(exc, lex); - } else if (((1)) == (2)) { - mp_obj_t exc = mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "invalid syntax for integer with base %d", base); - raise_exc(exc, lex); - } else { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 50, &print); - mp_printf(&print, "invalid syntax for integer with base %d: ", base); - mp_str_print_quoted(&print, str_val_start, top - str_val_start, -# 158 "user/mpy/py/parsenum.c" 3 4 - 1 -# 158 "user/mpy/py/parsenum.c" - ); - mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_ValueError, - mp_obj_new_str_from_vstr(&mp_type_str, &vstr)); - raise_exc(exc, lex); - } -} - -typedef enum { - PARSE_DEC_IN_INTG, - PARSE_DEC_IN_FRAC, - PARSE_DEC_IN_EXP, -} parse_dec_in_t; - -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 171 "user/mpy/py/parsenum.c" 3 4 - _Bool -# 171 "user/mpy/py/parsenum.c" - allow_imag, -# 171 "user/mpy/py/parsenum.c" 3 4 - _Bool -# 171 "user/mpy/py/parsenum.c" - force_complex, mp_lexer_t *lex) { -# 304 "user/mpy/py/parsenum.c" - raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "decimal numbers not supported"), lex); - -} -# 1 "user/mpy/py/emitglue.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/emitglue.c" -# 29 "user/mpy/py/emitglue.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/emitglue.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 31 "user/mpy/py/emitglue.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 32 "user/mpy/py/emitglue.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 33 "user/mpy/py/emitglue.c" 2 - -# 1 "user/mpy/py/emitglue.h" 1 -# 29 "user/mpy/py/emitglue.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/emitglue.h" 2 - - - -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 35 "user/mpy/py/emitglue.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 36 "user/mpy/py/emitglue.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 29 "user/mpy/py/bc.h" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/bc.h" 2 - -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 37 "user/mpy/py/emitglue.c" 2 -# 52 "user/mpy/py/emitglue.c" -mp_raw_code_t *mp_emit_glue_new_raw_code(void) { - mp_raw_code_t *rc = ((mp_raw_code_t*)(m_malloc0(sizeof(mp_raw_code_t) * (1)))); - rc->kind = MP_CODE_RESERVED; - return rc; -} - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags) { - - rc->kind = MP_CODE_BYTECODE; - rc->scope_flags = scope_flags; - rc->data.u_byte.bytecode = code; - rc->data.u_byte.const_table = const_table; -# 83 "user/mpy/py/emitglue.c" -} -# 116 "user/mpy/py/emitglue.c" -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args) { - (void)0; - -# 118 "user/mpy/py/emitglue.c" 3 - (( -# 118 "user/mpy/py/emitglue.c" - rc != -# 118 "user/mpy/py/emitglue.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 118, __func__, -# 118 "user/mpy/py/emitglue.c" - "rc != NULL" -# 118 "user/mpy/py/emitglue.c" 3 - )) -# 118 "user/mpy/py/emitglue.c" - ; - - - -# 121 "user/mpy/py/emitglue.c" 3 - (( -# 121 "user/mpy/py/emitglue.c" - def_args == (((mp_obj_t)(void*)0)) || (MP_OBJ_IS_OBJ(def_args) && (((mp_obj_base_t*)((void*)def_args))->type == (&mp_type_tuple))) -# 121 "user/mpy/py/emitglue.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 121, __func__, -# 121 "user/mpy/py/emitglue.c" - "def_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_args, &mp_type_tuple)" -# 121 "user/mpy/py/emitglue.c" 3 - )) -# 121 "user/mpy/py/emitglue.c" - ; - - - -# 124 "user/mpy/py/emitglue.c" 3 - (( -# 124 "user/mpy/py/emitglue.c" - def_kw_args == (((mp_obj_t)(void*)0)) || (MP_OBJ_IS_OBJ(def_kw_args) && (((mp_obj_base_t*)((void*)def_kw_args))->type == (&mp_type_dict))) -# 124 "user/mpy/py/emitglue.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 124, __func__, -# 124 "user/mpy/py/emitglue.c" - "def_kw_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_kw_args, &mp_type_dict)" -# 124 "user/mpy/py/emitglue.c" 3 - )) -# 124 "user/mpy/py/emitglue.c" - ; - - - mp_obj_t fun; - switch (rc->kind) { -# 142 "user/mpy/py/emitglue.c" - default: - - -# 144 "user/mpy/py/emitglue.c" 3 - (( -# 144 "user/mpy/py/emitglue.c" - rc->kind == MP_CODE_BYTECODE -# 144 "user/mpy/py/emitglue.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/emitglue.c", 144, __func__, -# 144 "user/mpy/py/emitglue.c" - "rc->kind == MP_CODE_BYTECODE" -# 144 "user/mpy/py/emitglue.c" 3 - )) -# 144 "user/mpy/py/emitglue.c" - ; - fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table); - break; - } - - - if ((rc->scope_flags & (0x04)) != 0) { - fun = mp_obj_new_gen_wrap(fun); - } - - return fun; -} - -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args) { - (void)0; - - mp_obj_t ffun; - if (n_closed_over & 0x100) { - - ffun = mp_make_function_from_raw_code(rc, args[0], args[1]); - } else { - - ffun = mp_make_function_from_raw_code(rc, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))); - } - - return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2)); -} -# 1 "user/mpy/py/persistentcode.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/persistentcode.c" -# 27 "user/mpy/py/persistentcode.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/persistentcode.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/persistentcode.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/persistentcode.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/persistentcode.c" 2 - -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 33 "user/mpy/py/persistentcode.c" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 34 "user/mpy/py/persistentcode.c" 2 -# 1 "user/mpy/py/persistentcode.h" 1 -# 33 "user/mpy/py/persistentcode.h" -mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader); -mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len); -mp_raw_code_t *mp_raw_code_load_file(const char *filename); - -void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print); -void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename); -# 35 "user/mpy/py/persistentcode.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 29 "user/mpy/py/bc.h" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/bc.h" 2 - -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 36 "user/mpy/py/persistentcode.c" 2 -# 1 "user/mpy/py/runtime.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/runtime.c" -# 27 "user/mpy/py/runtime.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/runtime.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/runtime.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/runtime.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 32 "user/mpy/py/runtime.c" 2 - -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 34 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/compile.h" 1 -# 30 "user/mpy/py/compile.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 31 "user/mpy/py/compile.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 32 "user/mpy/py/compile.h" 2 - - -enum { - MP_EMIT_OPT_NONE, - MP_EMIT_OPT_BYTECODE, - MP_EMIT_OPT_NATIVE_PYTHON, - MP_EMIT_OPT_VIPER, - MP_EMIT_OPT_ASM, -}; - - - -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, -# 44 "user/mpy/py/compile.h" 3 4 - _Bool -# 44 "user/mpy/py/compile.h" - is_repl); - - - - - - - -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); -# 35 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 36 "user/mpy/py/runtime.c" 2 - - -# 1 "user/mpy/py/objmodule.h" 1 -# 31 "user/mpy/py/objmodule.h" -extern const mp_map_t mp_builtin_module_map; -extern const mp_map_t mp_builtin_module_weak_links_map; - -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); -# 39 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/objgenerator.h" 1 -# 30 "user/mpy/py/objgenerator.h" -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objgenerator.h" 2 - -mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); -# 40 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 41 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 42 "user/mpy/py/runtime.c" 2 - -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 44 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 45 "user/mpy/py/runtime.c" 2 -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 46 "user/mpy/py/runtime.c" 2 -# 56 "user/mpy/py/runtime.c" -const mp_obj_module_t mp_module___main__ = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&(mp_state_ctx.vm.dict_main), -}; - -void mp_init(void) { - qstr_init(); - - - (mp_state_ctx.vm.mp_pending_exception) = (((mp_obj_t)(void*)0)); -# 90 "user/mpy/py/runtime.c" - (mp_state_ctx.vm.mp_optimise_value) = 0; - - - mp_obj_dict_init(&(mp_state_ctx.vm.mp_loaded_modules_dict), 3); - - - mp_obj_dict_init(&(mp_state_ctx.vm.dict_main), 1); - mp_obj_dict_store(((mp_obj_t)&(mp_state_ctx.vm.dict_main)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___main__)) << 2) | 2))); - - - mp_locals_set(&(mp_state_ctx.vm.dict_main)); - mp_globals_set(&(mp_state_ctx.vm.dict_main)); -# 123 "user/mpy/py/runtime.c" - ; -} - -void mp_deinit(void) { - - - - - - - -} - -mp_obj_t mp_load_name(qstr qst) { - - (void)0; - - if (mp_locals_get() != mp_globals_get()) { - mp_map_elem_t *elem = mp_map_lookup(&mp_locals_get()->map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 142 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 142 "user/mpy/py/runtime.c" - ) { - return elem->value; - } - } - return mp_load_global(qst); -} - -mp_obj_t mp_load_global(qstr qst) { - - (void)0; - mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem == -# 153 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 153 "user/mpy/py/runtime.c" - ) { -# 163 "user/mpy/py/runtime.c" - elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem == -# 164 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 164 "user/mpy/py/runtime.c" - ) { - if (((1)) == (1)) { - mp_raise_msg(&mp_type_NameError, "name not defined"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_NameError, "name '%q' is not defined", qst))) - ; - } - } - } - return elem->value; -} - -mp_obj_t mp_load_build_class(void) { - (void)0; -# 187 "user/mpy/py/runtime.c" - return ((mp_obj_t)&mp_builtin___build_class___obj); -} - -void mp_store_name(qstr qst, mp_obj_t obj) { - (void)0; - mp_obj_dict_store(((mp_obj_t)mp_locals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), obj); -} - -void mp_delete_name(qstr qst) { - (void)0; - - mp_obj_dict_delete(((mp_obj_t)mp_locals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))); -} - -void mp_store_global(qstr qst, mp_obj_t obj) { - (void)0; - mp_obj_dict_store(((mp_obj_t)mp_globals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), obj); -} - -void mp_delete_global(qstr qst) { - (void)0; - - mp_obj_dict_delete(((mp_obj_t)mp_globals_get()), ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))); -} - -mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) { - (void)0; - - if (op == MP_UNARY_OP_NOT) { - - return mp_obj_new_bool(mp_obj_is_true(arg) == 0); - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - mp_int_t val = (((mp_int_t)(arg)) >> 1); - switch (op) { - case MP_UNARY_OP_BOOL: - return mp_obj_new_bool(val != 0); - case MP_UNARY_OP_HASH: - return arg; - case MP_UNARY_OP_POSITIVE: - return arg; - case MP_UNARY_OP_NEGATIVE: - - if (val == ((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))) { - return mp_obj_new_int(-val); - } else { - return ((mp_obj_t)((((mp_uint_t)(-val)) << 1) | 1)); - } - default: - -# 235 "user/mpy/py/runtime.c" 3 - (( -# 235 "user/mpy/py/runtime.c" - op == MP_UNARY_OP_INVERT -# 235 "user/mpy/py/runtime.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 235, __func__, -# 235 "user/mpy/py/runtime.c" - "op == MP_UNARY_OP_INVERT" -# 235 "user/mpy/py/runtime.c" 3 - )) -# 235 "user/mpy/py/runtime.c" - ; - return ((mp_obj_t)((((mp_uint_t)(~val)) << 1) | 1)); - } - } else if (op == MP_UNARY_OP_HASH && (MP_OBJ_IS_QSTR(arg) || (MP_OBJ_IS_OBJ(arg) && ((mp_obj_base_t*)((void*)arg))->type->binary_op == mp_obj_str_binary_op))) { - - mp_uint_t h; if (MP_OBJ_IS_QSTR(arg)) { h = qstr_hash((((mp_uint_t)(arg)) >> 2)); } else { h = ((mp_obj_str_t*)((void*)arg))->hash; }; - if (h == 0) { - const byte *data; size_t len; if (MP_OBJ_IS_QSTR(arg)) { data = qstr_data((((mp_uint_t)(arg)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)arg))->len; data = ((mp_obj_str_t*)((void*)arg))->data; }; - h = qstr_compute_hash(data, len); - } - return ((mp_obj_t)((((mp_uint_t)(h)) << 1) | 1)); - } else { - mp_obj_type_t *type = mp_obj_get_type(arg); - if (type->unary_op != -# 248 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 248 "user/mpy/py/runtime.c" - ) { - mp_obj_t result = type->unary_op(op, arg); - if (result != (((mp_obj_t)(void*)0))) { - return result; - } - } - if (((1)) == (1)) { - mp_raise_TypeError("unsupported type for operator"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported type for %q: '%s'", mp_unary_op_method_name[op], mp_obj_get_type_str(arg)))) - - ; - } - } -} - -mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - (void)0; -# 277 "user/mpy/py/runtime.c" - if (op == MP_BINARY_OP_IS) { - return mp_obj_new_bool(lhs == rhs); - } - - - if (op == MP_BINARY_OP_EQUAL || op == MP_BINARY_OP_NOT_EQUAL) { - if (mp_obj_equal(lhs, rhs)) { - if (op == MP_BINARY_OP_EQUAL) { - return (((mp_obj_t)&mp_const_true_obj)); - } else { - return (((mp_obj_t)&mp_const_false_obj)); - } - } else { - if (op == MP_BINARY_OP_EQUAL) { - return (((mp_obj_t)&mp_const_false_obj)); - } else { - return (((mp_obj_t)&mp_const_true_obj)); - } - } - } - - - if (op == MP_BINARY_OP_EXCEPTION_MATCH) { - - if (mp_obj_is_exception_type(rhs)) { - if (mp_obj_exception_match(lhs, rhs)) { - return (((mp_obj_t)&mp_const_true_obj)); - } else { - return (((mp_obj_t)&mp_const_false_obj)); - } - } else if ((MP_OBJ_IS_OBJ(rhs) && (((mp_obj_base_t*)((void*)rhs))->type == (&mp_type_tuple)))) { - mp_obj_tuple_t *tuple = ((void*)rhs); - for (size_t i = 0; i < tuple->len; i++) { - rhs = tuple->items[i]; - if (!mp_obj_is_exception_type(rhs)) { - goto unsupported_op; - } - if (mp_obj_exception_match(lhs, rhs)) { - return (((mp_obj_t)&mp_const_true_obj)); - } - } - return (((mp_obj_t)&mp_const_false_obj)); - } - goto unsupported_op; - } - - if (MP_OBJ_IS_SMALL_INT(lhs)) { - mp_int_t lhs_val = (((mp_int_t)(lhs)) >> 1); - if (MP_OBJ_IS_SMALL_INT(rhs)) { - mp_int_t rhs_val = (((mp_int_t)(rhs)) >> 1); -# 336 "user/mpy/py/runtime.c" - switch (op) { - case MP_BINARY_OP_OR: - case MP_BINARY_OP_INPLACE_OR: lhs_val |= rhs_val; break; - case MP_BINARY_OP_XOR: - case MP_BINARY_OP_INPLACE_XOR: lhs_val ^= rhs_val; break; - case MP_BINARY_OP_AND: - case MP_BINARY_OP_INPLACE_AND: lhs_val &= rhs_val; break; - case MP_BINARY_OP_LSHIFT: - case MP_BINARY_OP_INPLACE_LSHIFT: { - if (rhs_val < 0) { - - mp_raise_ValueError("negative shift count"); - } else if (rhs_val >= (mp_int_t)((8) * (sizeof(mp_uint_t))) || lhs_val > (((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))))) >> rhs_val) || lhs_val < (((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) >> rhs_val)) { - - lhs = mp_obj_new_int_from_ll(lhs_val); - goto generic_binary_op; - } else { - - lhs_val <<= rhs_val; - } - break; - } - case MP_BINARY_OP_RSHIFT: - case MP_BINARY_OP_INPLACE_RSHIFT: - if (rhs_val < 0) { - - mp_raise_ValueError("negative shift count"); - } else { - - if (rhs_val >= (mp_int_t)((8) * (sizeof(mp_uint_t)))) { - - - rhs_val = ((8) * (sizeof(mp_uint_t))) - 1; - } - lhs_val >>= rhs_val; - } - break; - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break; - case MP_BINARY_OP_SUBTRACT: - case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break; - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: { -# 395 "user/mpy/py/runtime.c" - if (mp_small_int_mul_overflow(lhs_val, rhs_val)) { - - lhs = mp_obj_new_int_from_ll(lhs_val); - goto generic_binary_op; - } else { - - return ((mp_obj_t)((((mp_uint_t)(lhs_val * rhs_val)) << 1) | 1)); - } - break; - } - case MP_BINARY_OP_FLOOR_DIVIDE: - case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: - if (rhs_val == 0) { - goto zero_division; - } - lhs_val = mp_small_int_floor_divide(lhs_val, rhs_val); - break; -# 422 "user/mpy/py/runtime.c" - case MP_BINARY_OP_MODULO: - case MP_BINARY_OP_INPLACE_MODULO: { - if (rhs_val == 0) { - goto zero_division; - } - lhs_val = mp_small_int_modulo(lhs_val, rhs_val); - break; - } - - case MP_BINARY_OP_POWER: - case MP_BINARY_OP_INPLACE_POWER: - if (rhs_val < 0) { - - - - - mp_raise_ValueError("negative power with no float support"); - - } else { - mp_int_t ans = 1; - while (rhs_val > 0) { - if (rhs_val & 1) { - if (mp_small_int_mul_overflow(ans, lhs_val)) { - goto power_overflow; - } - ans *= lhs_val; - } - if (rhs_val == 1) { - break; - } - rhs_val /= 2; - if (mp_small_int_mul_overflow(lhs_val, lhs_val)) { - goto power_overflow; - } - lhs_val *= lhs_val; - } - lhs_val = ans; - } - break; - - power_overflow: - - lhs = mp_obj_new_int_from_ll((((mp_int_t)(lhs)) >> 1)); - goto generic_binary_op; - - case MP_BINARY_OP_DIVMOD: { - if (rhs_val == 0) { - goto zero_division; - } - - mp_obj_tuple_t *tuple = ((void*)mp_obj_new_tuple(2, -# 472 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 472 "user/mpy/py/runtime.c" - )); - tuple->items[0] = ((mp_obj_t)((((mp_uint_t)(mp_small_int_floor_divide(lhs_val, rhs_val))) << 1) | 1)); - tuple->items[1] = ((mp_obj_t)((((mp_uint_t)(mp_small_int_modulo(lhs_val, rhs_val))) << 1) | 1)); - return ((mp_obj_t)tuple); - } - - case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val); break; - case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val); break; - case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val); break; - case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val); break; - - default: - goto unsupported_op; - } - - if (((((lhs_val) ^ ((lhs_val) << 1)) & (((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) == 0)) { - return ((mp_obj_t)((((mp_uint_t)(lhs_val)) << 1) | 1)); - } else { - return mp_obj_new_int(lhs_val); - } -# 510 "user/mpy/py/runtime.c" - } - } - - - - - - - if (op == MP_BINARY_OP_IN) { - mp_obj_type_t *type = mp_obj_get_type(rhs); - if (type->binary_op != -# 520 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 520 "user/mpy/py/runtime.c" - ) { - mp_obj_t res = type->binary_op(op, rhs, lhs); - if (res != (((mp_obj_t)(void*)0))) { - return res; - } - } - if (type->getiter != -# 526 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 526 "user/mpy/py/runtime.c" - ) { - - mp_obj_iter_buf_t iter_buf; - mp_obj_t iter = mp_getiter(rhs, &iter_buf); - mp_obj_t next; - while ((next = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { - if (mp_obj_equal(next, lhs)) { - return (((mp_obj_t)&mp_const_true_obj)); - } - } - return (((mp_obj_t)&mp_const_false_obj)); - } - - if (((1)) == (1)) { - mp_raise_TypeError("object not iterable"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not iterable", mp_obj_get_type_str(rhs)))) - ; - } - } - - - mp_obj_type_t *type; -generic_binary_op: - type = mp_obj_get_type(lhs); - if (type->binary_op != -# 551 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 551 "user/mpy/py/runtime.c" - ) { - mp_obj_t result = type->binary_op(op, lhs, rhs); - if (result != (((mp_obj_t)(void*)0))) { - return result; - } - } - - - -unsupported_op: - if (((1)) == (1)) { - mp_raise_TypeError("unsupported type for operator"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported types for %q: '%s', '%s'", mp_binary_op_method_name[op], mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs)))) - - ; - } - -zero_division: - mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); -} - -mp_obj_t mp_call_function_0(mp_obj_t fun) { - return mp_call_function_n_kw(fun, 0, 0, -# 574 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 574 "user/mpy/py/runtime.c" - ); -} - -mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg) { - return mp_call_function_n_kw(fun, 1, 0, &arg); -} - -mp_obj_t mp_call_function_2(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { - mp_obj_t args[2]; - args[0] = arg1; - args[1] = arg2; - return mp_call_function_n_kw(fun, 2, 0, args); -} - - -mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - - - - (void)0; - - - mp_obj_type_t *type = mp_obj_get_type(fun_in); - - - if (type->call != -# 599 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 599 "user/mpy/py/runtime.c" - ) { - return type->call(fun_in, n_args, n_kw, args); - } - - if (((1)) == (1)) { - mp_raise_TypeError("object not callable"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not callable", mp_obj_get_type_str(fun_in)))) - ; - } -} - - - -mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)0; - int adjust = (args[1] == (((mp_obj_t)(void*)0))) ? 0 : 1; - return mp_call_function_n_kw(args[0], n_args + adjust, n_kw, args + 2 - adjust); -} - - - -static - -void mp_call_prepare_args_n_kw_var( -# 623 "user/mpy/py/runtime.c" 3 4 - _Bool -# 623 "user/mpy/py/runtime.c" - have_self, size_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args) { - mp_obj_t fun = *args++; - mp_obj_t self = (((mp_obj_t)(void*)0)); - if (have_self) { - self = *args++; - } - uint n_args = n_args_n_kw & 0xff; - uint n_kw = (n_args_n_kw >> 8) & 0xff; - mp_obj_t pos_seq = args[n_args + 2 * n_kw]; - mp_obj_t kw_dict = args[n_args + 2 * n_kw + 1]; - - (void)0; - - - - - - - mp_obj_t *args2; - uint args2_alloc; - uint args2_len = 0; - - - uint kw_dict_len = 0; - if (kw_dict != (((mp_obj_t)(void*)0)) && (MP_OBJ_IS_OBJ(kw_dict) && (((mp_obj_base_t*)((void*)kw_dict))->type == (&mp_type_dict)))) { - kw_dict_len = mp_obj_dict_len(kw_dict); - } - - - - if (pos_seq == (((mp_obj_t)(void*)0))) { - - - - args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len); - args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (args2_alloc)))); - - - if (self != (((mp_obj_t)(void*)0))) { - args2[args2_len++] = self; - } - - - memcpy(args2 + args2_len, args, n_args * sizeof(mp_obj_t)); - args2_len += n_args; - - } else if ((MP_OBJ_IS_OBJ(pos_seq) && (((mp_obj_base_t*)((void*)pos_seq))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(pos_seq) && (((mp_obj_base_t*)((void*)pos_seq))->type == (&mp_type_list)))) { - - - - size_t len; - mp_obj_t *items; - mp_obj_get_array(pos_seq, &len, &items); - - - args2_alloc = 1 + n_args + len + 2 * (n_kw + kw_dict_len); - args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (args2_alloc)))); - - - if (self != (((mp_obj_t)(void*)0))) { - args2[args2_len++] = self; - } - - - { memcpy(args2 + args2_len, args, (n_args) * sizeof(mp_obj_t)); memcpy(args2 + args2_len + (n_args), items, (len) * sizeof(mp_obj_t)); }; - args2_len += n_args + len; - - } else { - - - - args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len) + 3; - args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (args2_alloc)))); - - - if (self != (((mp_obj_t)(void*)0))) { - args2[args2_len++] = self; - } - - - memcpy(args2 + args2_len, args, n_args * sizeof(mp_obj_t)); - args2_len += n_args; - - - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(pos_seq, &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - if (args2_len >= args2_alloc) { - args2 = ((mp_obj_t*)(m_realloc((args2), sizeof(mp_obj_t) * (args2_alloc * 2)))); - args2_alloc *= 2; - } - args2[args2_len++] = item; - } - } - - - uint pos_args_len = args2_len; - - - memcpy(args2 + args2_len, args + n_args, 2 * n_kw * sizeof(mp_obj_t)); - args2_len += 2 * n_kw; - - - - if (kw_dict == (((mp_obj_t)(void*)0))) { - - } else if ((MP_OBJ_IS_OBJ(kw_dict) && (((mp_obj_base_t*)((void*)kw_dict))->type == (&mp_type_dict)))) { - - mp_map_t *map = mp_obj_dict_get_map(kw_dict); - -# 733 "user/mpy/py/runtime.c" 3 - (( -# 733 "user/mpy/py/runtime.c" - args2_len + 2 * map->used <= args2_alloc -# 733 "user/mpy/py/runtime.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 733, __func__, -# 733 "user/mpy/py/runtime.c" - "args2_len + 2 * map->used <= args2_alloc" -# 733 "user/mpy/py/runtime.c" 3 - )) -# 733 "user/mpy/py/runtime.c" - ; - for (size_t i = 0; i < map->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - - mp_obj_t key = map->table[i].key; - if ((MP_OBJ_IS_OBJ(key) && (((mp_obj_base_t*)((void*)key))->type == (&mp_type_str)))) { - key = mp_obj_str_intern(key); - } - args2[args2_len++] = key; - args2[args2_len++] = map->table[i].value; - } - } - } else { - - - - - - mp_obj_t dest[3]; - mp_load_method(kw_dict, MP_QSTR_keys, dest); - mp_obj_t iterable = mp_getiter(mp_call_method_n_kw(0, 0, dest), -# 753 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 753 "user/mpy/py/runtime.c" - ); - - mp_obj_t key; - while ((key = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - - if (args2_len + 1 >= args2_alloc) { - uint new_alloc = args2_alloc * 2; - if (new_alloc < 4) { - new_alloc = 4; - } - args2 = ((mp_obj_t*)(m_realloc((args2), sizeof(mp_obj_t) * (new_alloc)))); - args2_alloc = new_alloc; - } - - - if ((MP_OBJ_IS_OBJ(key) && (((mp_obj_base_t*)((void*)key))->type == (&mp_type_str)))) { - key = mp_obj_str_intern(key); - } - - - mp_load_method(kw_dict, MP_QSTR___getitem__, dest); - dest[2] = key; - mp_obj_t value = mp_call_method_n_kw(1, 0, dest); - - - args2[args2_len++] = key; - args2[args2_len++] = value; - } - } - - out_args->fun = fun; - out_args->args = args2; - out_args->n_args = pos_args_len; - out_args->n_kw = (args2_len - pos_args_len) / 2; - out_args->n_alloc = args2_alloc; -} - -mp_obj_t mp_call_method_n_kw_var( -# 790 "user/mpy/py/runtime.c" 3 4 - _Bool -# 790 "user/mpy/py/runtime.c" - have_self, size_t n_args_n_kw, const mp_obj_t *args) { - mp_call_args_t out_args; - mp_call_prepare_args_n_kw_var(have_self, n_args_n_kw, args, &out_args); - - mp_obj_t res = mp_call_function_n_kw(out_args.fun, out_args.n_args, out_args.n_kw, out_args.args); - ((void)(out_args.n_alloc), m_free(out_args.args)); - - return res; -} - - -void mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) { - size_t seq_len; - if ((MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_list)))) { - mp_obj_t *seq_items; - mp_obj_get_array(seq_in, &seq_len, &seq_items); - if (seq_len < num) { - goto too_short; - } else if (seq_len > num) { - goto too_long; - } - for (size_t i = 0; i < num; i++) { - items[i] = seq_items[num - 1 - i]; - } - } else { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(seq_in, &iter_buf); - - for (seq_len = 0; seq_len < num; seq_len++) { - mp_obj_t el = mp_iternext(iterable); - if (el == (((mp_obj_t)(void*)4))) { - goto too_short; - } - items[num - 1 - seq_len] = el; - } - if (mp_iternext(iterable) != (((mp_obj_t)(void*)4))) { - goto too_long; - } - } - return; - -too_short: - if (((1)) == (1)) { - mp_raise_ValueError("wrong number of values to unpack"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "need more than %d values to unpack", (int)seq_len))) - ; - } -too_long: - if (((1)) == (1)) { - mp_raise_ValueError("wrong number of values to unpack"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "too many values to unpack (expected %d)", (int)num))) - ; - } -} - - -void mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) { - size_t num_left = num_in & 0xff; - size_t num_right = (num_in >> 8) & 0xff; - (void)0; - size_t seq_len; - if ((MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(seq_in) && (((mp_obj_base_t*)((void*)seq_in))->type == (&mp_type_list)))) { - mp_obj_t *seq_items; - mp_obj_get_array(seq_in, &seq_len, &seq_items); - if (seq_len < num_left + num_right) { - goto too_short; - } - for (size_t i = 0; i < num_right; i++) { - items[i] = seq_items[seq_len - 1 - i]; - } - items[num_right] = mp_obj_new_list(seq_len - num_left - num_right, seq_items + num_left); - for (size_t i = 0; i < num_left; i++) { - items[num_right + 1 + i] = seq_items[num_left - 1 - i]; - } - } else { - - - - - mp_obj_t iterable = mp_getiter(seq_in, -# 871 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 871 "user/mpy/py/runtime.c" - ); - mp_obj_t item; - for (seq_len = 0; seq_len < num_left; seq_len++) { - item = mp_iternext(iterable); - if (item == (((mp_obj_t)(void*)4))) { - goto too_short; - } - items[num_left + num_right + 1 - 1 - seq_len] = item; - } - mp_obj_list_t *rest = ((void*)mp_obj_new_list(0, -# 880 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 880 "user/mpy/py/runtime.c" - )); - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - mp_obj_list_append(((mp_obj_t)rest), item); - } - if (rest->len < num_right) { - goto too_short; - } - items[num_right] = ((mp_obj_t)rest); - for (size_t i = 0; i < num_right; i++) { - items[num_right - 1 - i] = rest->items[rest->len - num_right + i]; - } - mp_obj_list_set_len(((mp_obj_t)rest), rest->len - num_right); - } - return; - -too_short: - if (((1)) == (1)) { - mp_raise_ValueError("wrong number of values to unpack"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "need more than %d values to unpack", (int)seq_len))) - ; - } -} - -mp_obj_t mp_load_attr(mp_obj_t base, qstr attr) { - (void)0; - - mp_obj_t dest[2]; - mp_load_method(base, attr, dest); - if (dest[1] == (((mp_obj_t)(void*)0))) { - - return dest[0]; - } else { - - return mp_obj_new_bound_meth(dest[0], dest[1]); - } -} -# 966 "user/mpy/py/runtime.c" -void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest) { - if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type == (&mp_type_staticmethod)))) { - - dest[0] = ((mp_obj_static_class_method_t*)((void*)member))->fun; - } else if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type == (&mp_type_classmethod)))) { - - - - if (self != (((mp_obj_t)(void*)0))) { - type = mp_obj_get_type(self); - } - dest[0] = ((mp_obj_static_class_method_t*)((void*)member))->fun; - dest[1] = ((mp_obj_t)type); - } else if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type == (&mp_type_type)))) { - - dest[0] = member; - } else if ((MP_OBJ_IS_OBJ(member) && (((mp_obj_base_t*)((void*)member))->type->name == MP_QSTR_function)) - || (MP_OBJ_IS_OBJ(member) - && (((mp_obj_base_t*)((void*)member))->type->name == MP_QSTR_closure - || ((mp_obj_base_t*)((void*)member))->type->name == MP_QSTR_generator))) { -# 1000 "user/mpy/py/runtime.c" - { - - dest[0] = member; - dest[1] = self; - } - } else { - - dest[0] = member; - } -} - - - - -void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { - - dest[0] = (((mp_obj_t)(void*)0)); - dest[1] = (((mp_obj_t)(void*)0)); - - - mp_obj_type_t *type = mp_obj_get_type(obj); - - - if (0) { - - - - - - - } else if (attr == MP_QSTR___next__ && type->iternext != -# 1030 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1030 "user/mpy/py/runtime.c" - ) { - dest[0] = ((mp_obj_t)&mp_builtin_next_obj); - dest[1] = obj; - - } else if (type->attr != -# 1034 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1034 "user/mpy/py/runtime.c" - ) { - - type->attr(obj, attr, dest); - - } else if (type->locals_dict != -# 1038 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1038 "user/mpy/py/runtime.c" - ) { - - - -# 1041 "user/mpy/py/runtime.c" 3 - (( -# 1041 "user/mpy/py/runtime.c" - type->locals_dict->base.type == &mp_type_dict -# 1041 "user/mpy/py/runtime.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1041, __func__, -# 1041 "user/mpy/py/runtime.c" - "type->locals_dict->base.type == &mp_type_dict" -# 1041 "user/mpy/py/runtime.c" 3 - )) -# 1041 "user/mpy/py/runtime.c" - ; - mp_map_t *locals_map = &type->locals_dict->map; - mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 1044 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1044 "user/mpy/py/runtime.c" - ) { - mp_convert_member_lookup(obj, type, elem->value, dest); - } - } -} - -void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { - (void)0; - - mp_load_method_maybe(base, attr, dest); - - if (dest[0] == (((mp_obj_t)(void*)0))) { - - if (((1)) == (1)) { - mp_raise_msg(&mp_type_AttributeError, "no such attribute"); - } else { - - if ((MP_OBJ_IS_OBJ(base) && (((mp_obj_base_t*)((void*)base))->type == (&mp_type_type)))) { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_AttributeError, "type object '%q' has no attribute '%q'", ((mp_obj_type_t*)((void*)base))->name, attr))) - - ; - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_AttributeError, "'%s' object has no attribute '%q'", mp_obj_get_type_str(base), attr))) - - ; - } - } - } -} - -void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { - (void)0; - mp_obj_type_t *type = mp_obj_get_type(base); - if (type->attr != -# 1077 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1077 "user/mpy/py/runtime.c" - ) { - mp_obj_t dest[2] = {(((mp_obj_t)(void*)8)), value}; - type->attr(base, attr, dest); - if (dest[0] == (((mp_obj_t)(void*)0))) { - - return; - } - } - if (((1)) == (1)) { - mp_raise_msg(&mp_type_AttributeError, "no such attribute"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_AttributeError, "'%s' object has no attribute '%q'", mp_obj_get_type_str(base), attr))) - - ; - } -} - -mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - -# 1095 "user/mpy/py/runtime.c" 3 - (( -# 1095 "user/mpy/py/runtime.c" - o_in -# 1095 "user/mpy/py/runtime.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1095, __func__, -# 1095 "user/mpy/py/runtime.c" - "o_in" -# 1095 "user/mpy/py/runtime.c" 3 - )) -# 1095 "user/mpy/py/runtime.c" - ; - mp_obj_type_t *type = mp_obj_get_type(o_in); - - - - if (type->getiter == mp_identity_getiter) { - return o_in; - } - - - if (iter_buf == -# 1105 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1105 "user/mpy/py/runtime.c" - ) { - iter_buf = (((mp_obj_iter_buf_t*)(m_malloc(sizeof(mp_obj_iter_buf_t) * (1))))); - } - - - if (type->getiter != -# 1110 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1110 "user/mpy/py/runtime.c" - ) { - mp_obj_t iter = type->getiter(o_in, iter_buf); - if (iter != (((mp_obj_t)(void*)0))) { - return iter; - } - } - - - mp_obj_t dest[2]; - mp_load_method_maybe(o_in, MP_QSTR___getitem__, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - - return mp_obj_new_getitem_iter(dest, iter_buf); - } - - - if (((1)) == (1)) { - mp_raise_TypeError("object not iterable"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not iterable", mp_obj_get_type_str(o_in)))) - ; - } -} - - - -mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->iternext != -# 1138 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1138 "user/mpy/py/runtime.c" - ) { - return type->iternext(o_in); - } else { - - mp_obj_t dest[2]; - mp_load_method_maybe(o_in, MP_QSTR___next__, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - - return mp_call_method_n_kw(0, 0, dest); - } else { - if (((1)) == (1)) { - mp_raise_TypeError("object not an iterator"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not an iterator", mp_obj_get_type_str(o_in)))) - ; - } - } - } -} - - - -mp_obj_t mp_iternext(mp_obj_t o_in) { - ; - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->iternext != -# 1163 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1163 "user/mpy/py/runtime.c" - ) { - return type->iternext(o_in); - } else { - - mp_obj_t dest[2]; - mp_load_method_maybe(o_in, MP_QSTR___next__, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t ret = mp_call_method_n_kw(0, 0, dest); - nlr_pop(); - return ret; - } else { - if (mp_obj_is_subclass_fast(((mp_obj_t)((mp_obj_base_t*)nlr.ret_val)->type), ((mp_obj_t)&mp_type_StopIteration))) { - return (((mp_obj_t)(void*)4)); - } else { - nlr_jump(nlr.ret_val); - } - } - } else { - if (((1)) == (1)) { - mp_raise_TypeError("object not an iterator"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not an iterator", mp_obj_get_type_str(o_in)))) - ; - } - } - } -} - - -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) { - -# 1196 "user/mpy/py/runtime.c" 3 - (( -# 1196 "user/mpy/py/runtime.c" - (send_value != (((mp_obj_t)(void*)0))) ^ (throw_value != (((mp_obj_t)(void*)0))) -# 1196 "user/mpy/py/runtime.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1196, __func__, -# 1196 "user/mpy/py/runtime.c" - "(send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL)" -# 1196 "user/mpy/py/runtime.c" 3 - )) -# 1196 "user/mpy/py/runtime.c" - ; - mp_obj_type_t *type = mp_obj_get_type(self_in); - - if (type == &mp_type_gen_instance) { - return mp_obj_gen_resume(self_in, send_value, throw_value, ret_val); - } - - if (type->iternext != -# 1203 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1203 "user/mpy/py/runtime.c" - && send_value == (((mp_obj_t)&mp_const_none_obj))) { - mp_obj_t ret = type->iternext(self_in); - if (ret != (((mp_obj_t)(void*)4))) { - *ret_val = ret; - return MP_VM_RETURN_YIELD; - } else { - - - *ret_val = (((mp_obj_t)(void*)0)); - return MP_VM_RETURN_NORMAL; - } - } - - mp_obj_t dest[3]; - - - if (send_value == (((mp_obj_t)&mp_const_none_obj))) { - mp_load_method_maybe(self_in, MP_QSTR___next__, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - *ret_val = mp_call_method_n_kw(0, 0, dest); - nlr_pop(); - return MP_VM_RETURN_YIELD; - } else { - *ret_val = ((mp_obj_t)nlr.ret_val); - return MP_VM_RETURN_EXCEPTION; - } - } - } - - - - if (send_value != (((mp_obj_t)(void*)0))) { - mp_load_method(self_in, MP_QSTR_send, dest); - dest[2] = send_value; - - - - - *ret_val = mp_call_method_n_kw(1, 0, dest); - return MP_VM_RETURN_YIELD; - } - - -# 1247 "user/mpy/py/runtime.c" 3 - (( -# 1247 "user/mpy/py/runtime.c" - throw_value != (((mp_obj_t)(void*)0)) -# 1247 "user/mpy/py/runtime.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/runtime.c", 1247, __func__, -# 1247 "user/mpy/py/runtime.c" - "throw_value != MP_OBJ_NULL" -# 1247 "user/mpy/py/runtime.c" 3 - )) -# 1247 "user/mpy/py/runtime.c" - ; - { - if (mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(throw_value)), ((mp_obj_t)&mp_type_GeneratorExit))) { - mp_load_method_maybe(self_in, MP_QSTR_close, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - - - *ret_val = mp_call_method_n_kw(0, 0, dest); - - return MP_VM_RETURN_NORMAL; - } - } else { - mp_load_method_maybe(self_in, MP_QSTR_throw, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - dest[2] = throw_value; - *ret_val = mp_call_method_n_kw(1, 0, dest); - - - return MP_VM_RETURN_YIELD; - } - } - - - - - - *ret_val = throw_value; - return MP_VM_RETURN_EXCEPTION; - } -} - -mp_obj_t mp_make_raise_obj(mp_obj_t o) { - (void)0; - if (mp_obj_is_exception_type(o)) { - - - - - return mp_call_function_n_kw(o, 0, 0, -# 1285 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1285 "user/mpy/py/runtime.c" - ); - } else if (mp_obj_is_exception_instance(o)) { - - return o; - } else { - - return mp_obj_new_exception_msg(&mp_type_TypeError, "exceptions must derive from BaseException"); - } -} - -mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level) { - (void)0; - - - mp_obj_t args[5]; - args[0] = ((mp_obj_t)((((mp_uint_t)(name)) << 2) | 2)); - args[1] = (((mp_obj_t)&mp_const_none_obj)); - args[2] = (((mp_obj_t)&mp_const_none_obj)); - args[3] = fromlist; - args[4] = level; - - - return mp_builtin___import__(5, args); -} - -mp_obj_t mp_import_from(mp_obj_t module, qstr name) { - (void)0; - - mp_obj_t dest[2]; - - mp_load_method_maybe(module, name, dest); - - if (dest[1] != (((mp_obj_t)(void*)0))) { - -import_error: - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ImportError, "cannot import name %q", name))); - } - - if (dest[0] != (((mp_obj_t)(void*)0))) { - return dest[0]; - } - - - if (!mp_obj_is_package(module)) { - goto import_error; - } - - mp_load_method_maybe(module, MP_QSTR___name__, dest); - size_t pkg_name_len; - const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len); - - const uint dot_name_len = pkg_name_len + 1 + qstr_len(name); - char *dot_name = -# 1337 "user/mpy/py/runtime.c" 3 - __builtin_alloca( -# 1337 "user/mpy/py/runtime.c" - dot_name_len -# 1337 "user/mpy/py/runtime.c" 3 - ) -# 1337 "user/mpy/py/runtime.c" - ; - memcpy(dot_name, pkg_name, pkg_name_len); - dot_name[pkg_name_len] = '.'; - memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name)); - qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len); - - mp_obj_t args[5]; - args[0] = ((mp_obj_t)((((mp_uint_t)(dot_name_q)) << 2) | 2)); - args[1] = (((mp_obj_t)&mp_const_none_obj)); - args[2] = (((mp_obj_t)&mp_const_none_obj)); - args[3] = (((mp_obj_t)&mp_const_true_obj)); - args[4] = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); - - - return mp_builtin___import__(5, args); -} - -void mp_import_all(mp_obj_t module) { - (void)0; - - - mp_map_t *map = mp_obj_dict_get_map(((mp_obj_t)mp_obj_module_get_globals(module))); - for (size_t i = 0; i < map->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - qstr name = (((mp_uint_t)(map->table[i].key)) >> 2); - if (*qstr_str(name) != '_') { - mp_store_name(name, map->table[i].value); - } - } - } -} - - - - -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { - - mp_obj_dict_t *volatile old_globals = mp_globals_get(); - mp_obj_dict_t *volatile old_locals = mp_locals_get(); - - - mp_globals_set(globals); - mp_locals_set(locals); - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - qstr source_name = lex->source_name; - mp_parse_tree_t parse_tree = mp_parse(lex, parse_input_kind); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, -# 1385 "user/mpy/py/runtime.c" 3 4 - 0 -# 1385 "user/mpy/py/runtime.c" - ); - - mp_obj_t ret; - if ((0) && globals == -# 1388 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1388 "user/mpy/py/runtime.c" - ) { - - ret = module_fun; - } else { - - ret = mp_call_function_0(module_fun); - } - - - nlr_pop(); - mp_globals_set(old_globals); - mp_locals_set(old_locals); - return ret; - } else { - - mp_globals_set(old_globals); - mp_locals_set(old_locals); - nlr_jump(nlr.ret_val); - } -} - - - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes) { - (void)0; - - if (gc_is_locked()) { - mp_raise_msg(&mp_type_MemoryError, "memory allocation failed, heap is locked"); - } - - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_MemoryError, "memory allocation failed, allocating %u bytes", (uint)num_bytes))) - ; -} - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) { - if (msg == -# 1423 "user/mpy/py/runtime.c" 3 4 - ((void *)0) -# 1423 "user/mpy/py/runtime.c" - ) { - nlr_jump(((void*)mp_obj_new_exception(exc_type))); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg(exc_type, msg))); - } -} - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg) { - mp_raise_msg(&mp_type_ValueError, msg); -} - -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg) { - mp_raise_msg(&mp_type_TypeError, msg); -} - -__attribute__((noreturn)) void mp_raise_OSError(int errno_) { - nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_OSError, ((mp_obj_t)((((mp_uint_t)(errno_)) << 1) | 1))))); -} - -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg) { - mp_raise_msg(&mp_type_NotImplementedError, msg); -} -# 1 "user/mpy/py/runtime_utils.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/runtime_utils.c" -# 28 "user/mpy/py/runtime_utils.c" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 29 "user/mpy/py/runtime_utils.c" 2 - - - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_call_function_1(fun, arg); - nlr_pop(); - } else { - mp_obj_print_exception(&mp_plat_print, ((mp_obj_t)nlr.ret_val)); - } -} - -void mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_call_function_2(fun, arg1, arg2); - nlr_pop(); - } else { - mp_obj_print_exception(&mp_plat_print, ((mp_obj_t)nlr.ret_val)); - } -} -# 1 "user/mpy/py/scheduler.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/scheduler.c" -# 27 "user/mpy/py/scheduler.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/scheduler.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/scheduler.c" 2 -# 109 "user/mpy/py/scheduler.c" -void mp_handle_pending(void) { - if ((mp_state_ctx.vm.mp_pending_exception) != (((mp_obj_t)(void*)0))) { - mp_obj_t obj = (mp_state_ctx.vm.mp_pending_exception); - (mp_state_ctx.vm.mp_pending_exception) = (((mp_obj_t)(void*)0)); - nlr_jump(((void*)obj)); - } -} -# 1 "user/mpy/py/nativeglue.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/nativeglue.c" -# 27 "user/mpy/py/nativeglue.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/nativeglue.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/nativeglue.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/nativeglue.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/nativeglue.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/nativeglue.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/nativeglue.c" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 35 "user/mpy/py/nativeglue.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 31 "user/mpy/py/bc.h" -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 36 "user/mpy/py/nativeglue.c" 2 -# 1 "user/mpy/py/stackctrl.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/stackctrl.c" -# 27 "user/mpy/py/stackctrl.c" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 28 "user/mpy/py/stackctrl.c" 2 - - -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/stackctrl.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 32 "user/mpy/py/stackctrl.c" 2 - -void mp_stack_ctrl_init(void) { - volatile int stack_dummy; - (mp_state_ctx.thread.stack_top) = (char*)&stack_dummy; -} - -void mp_stack_set_top(void *top) { - (mp_state_ctx.thread.stack_top) = top; -} - -mp_uint_t mp_stack_usage(void) { - - volatile int stack_dummy; - return (mp_state_ctx.thread.stack_top) - (char*)&stack_dummy; -} -# 1 "user/mpy/py/argcheck.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/argcheck.c" -# 27 "user/mpy/py/argcheck.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/argcheck.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/argcheck.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/argcheck.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/argcheck.c" 2 - -void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 33 "user/mpy/py/argcheck.c" 3 4 - _Bool -# 33 "user/mpy/py/argcheck.c" - takes_kw) { - - - if (n_kw && !takes_kw) { - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - mp_raise_TypeError("function does not take keyword arguments"); - } - } - - if (n_args_min == n_args_max) { - if (n_args != n_args_min) { - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function takes %d positional arguments but %d were given", n_args_min, n_args))) - - ; - } - } - } else { - if (n_args < n_args_min) { - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function missing %d required positional arguments", n_args_min - n_args))) - - ; - } - } else if (n_args > n_args_max) { - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function expected at most %d arguments, got %d", n_args_max, n_args))) - - ; - } - } - } -} - -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) { - size_t pos_found = 0, kws_found = 0; - for (size_t i = 0; i < n_allowed; i++) { - mp_obj_t given_arg; - if (i < n_pos) { - if (allowed[i].flags & MP_ARG_KW_ONLY) { - goto extra_positional; - } - pos_found++; - given_arg = pos[i]; - } else { - mp_map_elem_t *kw = mp_map_lookup(kws, ((mp_obj_t)((((mp_uint_t)(allowed[i].qst)) << 2) | 2)), MP_MAP_LOOKUP); - if (kw == -# 87 "user/mpy/py/argcheck.c" 3 4 - ((void *)0) -# 87 "user/mpy/py/argcheck.c" - ) { - if (allowed[i].flags & MP_ARG_REQUIRED) { - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%q' argument required", allowed[i].qst))) - ; - } - } - out_vals[i] = allowed[i].defval; - continue; - } else { - kws_found++; - given_arg = kw->value; - } - } - if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_BOOL) { - out_vals[i].u_bool = mp_obj_is_true(given_arg); - } else if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_INT) { - out_vals[i].u_int = mp_obj_get_int(given_arg); - } else { - -# 108 "user/mpy/py/argcheck.c" 3 - (( -# 108 "user/mpy/py/argcheck.c" - (allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_OBJ -# 108 "user/mpy/py/argcheck.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/argcheck.c", 108, __func__, -# 108 "user/mpy/py/argcheck.c" - "(allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_OBJ" -# 108 "user/mpy/py/argcheck.c" 3 - )) -# 108 "user/mpy/py/argcheck.c" - ; - out_vals[i].u_obj = given_arg; - } - } - if (pos_found < n_pos) { - extra_positional: - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - - mp_raise_TypeError("extra positional arguments given"); - } - } - if (kws_found < kws->used) { - if (((1)) == (1)) { - mp_arg_error_terse_mismatch(); - } else { - - mp_raise_TypeError("extra keyword arguments given"); - } - } -} - -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) { - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, args + n_pos); - mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals); -} - - -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void) { - mp_raise_TypeError("argument num/types mismatch"); -} -# 1 "user/mpy/py/warning.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/warning.c" -# 27 "user/mpy/py/warning.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 - -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 28 "user/mpy/py/warning.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/warning.c" 2 - -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 29 "user/mpy/py/lexer.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/lexer.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 31 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 31 "user/mpy/py/warning.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/warning.c" 2 -# 1 "user/mpy/py/map.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/map.c" -# 27 "user/mpy/py/map.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/map.c" 2 -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 29 "user/mpy/py/map.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/map.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/map.c" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 33 "user/mpy/py/map.c" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/map.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/map.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 36 "user/mpy/py/map.c" 2 - - - -const mp_map_t mp_const_empty_map = { - .all_keys_are_qstrs = 0, - .is_fixed = 1, - .is_ordered = 1, - .used = 0, - .alloc = 0, - .table = -# 45 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 45 "user/mpy/py/map.c" - , -}; - - - - - -static const uint16_t hash_allocation_sizes[] = { - 0, 2, 4, 6, 8, 10, 12, - 17, 23, 29, 37, 47, 59, 73, - 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, - 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, -}; - -static size_t get_hash_alloc_greater_or_equal_to(size_t x) { - for (size_t i = 0; i < (sizeof(hash_allocation_sizes) / sizeof((hash_allocation_sizes)[0])); i++) { - if (hash_allocation_sizes[i] >= x) { - return hash_allocation_sizes[i]; - } - } - - - return (x + x / 2) | 1; -} - - - - -void mp_map_init(mp_map_t *map, size_t n) { - if (n == 0) { - map->alloc = 0; - map->table = -# 76 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 76 "user/mpy/py/map.c" - ; - } else { - map->alloc = n; - map->table = ((mp_map_elem_t*)(m_malloc0(sizeof(mp_map_elem_t) * (map->alloc)))); - } - map->used = 0; - map->all_keys_are_qstrs = 1; - map->is_fixed = 0; - map->is_ordered = 0; -} - -void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table) { - map->alloc = n; - map->used = n; - map->all_keys_are_qstrs = 1; - map->is_fixed = 1; - map->is_ordered = 1; - map->table = (mp_map_elem_t*)table; -} - -mp_map_t *mp_map_new(size_t n) { - mp_map_t *map = ((mp_map_t*)(m_malloc(sizeof(mp_map_t) * (1)))); - mp_map_init(map, n); - return map; -} - - -void mp_map_deinit(mp_map_t *map) { - if (!map->is_fixed) { - ((void)(map->alloc), m_free(map->table)); - } - map->used = map->alloc = 0; -} - -void mp_map_free(mp_map_t *map) { - mp_map_deinit(map); - (((void)(1), m_free(map))); -} - -void mp_map_clear(mp_map_t *map) { - if (!map->is_fixed) { - ((void)(map->alloc), m_free(map->table)); - } - map->alloc = 0; - map->used = 0; - map->all_keys_are_qstrs = 1; - map->is_fixed = 0; - map->table = -# 123 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 123 "user/mpy/py/map.c" - ; -} - -static void mp_map_rehash(mp_map_t *map) { - size_t old_alloc = map->alloc; - size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1); - mp_map_elem_t *old_table = map->table; - mp_map_elem_t *new_table = ((mp_map_elem_t*)(m_malloc0(sizeof(mp_map_elem_t) * (new_alloc)))); - - map->alloc = new_alloc; - map->used = 0; - map->all_keys_are_qstrs = 1; - map->table = new_table; - for (size_t i = 0; i < old_alloc; i++) { - if (old_table[i].key != (((mp_obj_t)(void*)0)) && old_table[i].key != (((mp_obj_t)(void*)8))) { - mp_map_lookup(map, old_table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = old_table[i].value; - } - } - ((void)(old_alloc), m_free(old_table)); -} - - - - - - - -mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { - - if (map->is_fixed && lookup_kind != MP_MAP_LOOKUP) { - - return -# 154 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 154 "user/mpy/py/map.c" - ; - } - - - -# 158 "user/mpy/py/map.c" 3 4 - _Bool -# 158 "user/mpy/py/map.c" - compare_only_ptrs = map->all_keys_are_qstrs; - if (compare_only_ptrs) { - if (MP_OBJ_IS_QSTR(index)) { - - } else if ((MP_OBJ_IS_OBJ(index) && (((mp_obj_base_t*)((void*)index))->type == (&mp_type_str)))) { - - - - - - compare_only_ptrs = -# 168 "user/mpy/py/map.c" 3 4 - 0 -# 168 "user/mpy/py/map.c" - ; - } else if (lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - - - return -# 172 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 172 "user/mpy/py/map.c" - ; - } - } - - - if (map->is_ordered) { - for (mp_map_elem_t *elem = &map->table[0], *top = &map->table[map->used]; elem < top; elem++) { - if (elem->key == index || (!compare_only_ptrs && mp_obj_equal(elem->key, index))) { - if (__builtin_expect((lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND), 0)) { - - mp_obj_t value = elem->value; - --map->used; - memmove(elem, elem + 1, (top - elem - 1) * sizeof(*elem)); - - elem = &map->table[map->used]; - elem->key = (((mp_obj_t)(void*)0)); - elem->value = value; - } - return elem; - } - } - if (__builtin_expect((lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND), 1)) { - return -# 194 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 194 "user/mpy/py/map.c" - ; - } - if (map->used == map->alloc) { - - map->alloc += 4; - map->table = ((mp_map_elem_t*)(m_realloc((map->table), sizeof(mp_map_elem_t) * (map->alloc)))); - memset((byte*)(map->table) + (map->used) * (sizeof(*map->table)), 0, ((map->alloc) - (map->used)) * (sizeof(*map->table))); - } - mp_map_elem_t *elem = map->table + map->used++; - elem->key = index; - if (!MP_OBJ_IS_QSTR(index)) { - map->all_keys_are_qstrs = 0; - } - return elem; - } - - - - if (map->alloc == 0) { - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - mp_map_rehash(map); - } else { - return -# 216 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 216 "user/mpy/py/map.c" - ; - } - } - - - mp_uint_t hash; - if (MP_OBJ_IS_QSTR(index)) { - hash = qstr_hash((((mp_uint_t)(index)) >> 2)); - } else { - hash = (((mp_int_t)(mp_unary_op(MP_UNARY_OP_HASH, index))) >> 1); - } - - size_t pos = hash % map->alloc; - size_t start_pos = pos; - mp_map_elem_t *avail_slot = -# 230 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 230 "user/mpy/py/map.c" - ; - for (;;) { - mp_map_elem_t *slot = &map->table[pos]; - if (slot->key == (((mp_obj_t)(void*)0))) { - - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - map->used += 1; - if (avail_slot == -# 237 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 237 "user/mpy/py/map.c" - ) { - avail_slot = slot; - } - avail_slot->key = index; - avail_slot->value = (((mp_obj_t)(void*)0)); - if (!MP_OBJ_IS_QSTR(index)) { - map->all_keys_are_qstrs = 0; - } - return avail_slot; - } else { - return -# 247 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 247 "user/mpy/py/map.c" - ; - } - } else if (slot->key == (((mp_obj_t)(void*)8))) { - - if (avail_slot == -# 251 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 251 "user/mpy/py/map.c" - ) { - avail_slot = slot; - } - } else if (slot->key == index || (!compare_only_ptrs && mp_obj_equal(slot->key, index))) { - - - if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - - map->used--; - if (map->table[(pos + 1) % map->alloc].key == (((mp_obj_t)(void*)0))) { - - slot->key = (((mp_obj_t)(void*)0)); - } else { - slot->key = (((mp_obj_t)(void*)8)); - } - - } - return slot; - } - - - pos = (pos + 1) % map->alloc; - - if (pos == start_pos) { - - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - if (avail_slot != -# 277 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 277 "user/mpy/py/map.c" - ) { - - map->used++; - avail_slot->key = index; - avail_slot->value = (((mp_obj_t)(void*)0)); - if (!MP_OBJ_IS_QSTR(index)) { - map->all_keys_are_qstrs = 0; - } - return avail_slot; - } else { - - mp_map_rehash(map); - - start_pos = pos = hash % map->alloc; - } - } else { - return -# 293 "user/mpy/py/map.c" 3 4 - ((void *)0) -# 293 "user/mpy/py/map.c" - ; - } - } - } -} -# 1 "user/mpy/py/obj.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/obj.c" -# 27 "user/mpy/py/obj.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/obj.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/obj.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 30 "user/mpy/py/obj.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/obj.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 33 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 34 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/objtype.h" 1 -# 33 "user/mpy/py/objtype.h" -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 35 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 - - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 36 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 37 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 38 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 39 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 40 "user/mpy/py/obj.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 41 "user/mpy/py/obj.c" 2 - -mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { - if (MP_OBJ_IS_SMALL_INT(o_in)) { - return (mp_obj_type_t*)&mp_type_int; - } else if (MP_OBJ_IS_QSTR(o_in)) { - return (mp_obj_type_t*)&mp_type_str; - - - - - } else { - const mp_obj_base_t *o = ((void*)o_in); - return (mp_obj_type_t*)o->type; - } -} - -const char *mp_obj_get_type_str(mp_const_obj_t o_in) { - return qstr_str(mp_obj_get_type(o_in)->name); -} - -void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - - ; - - if (o_in == (((mp_obj_t)(void*)0))) { - mp_print_str(print, "(nil)"); - return; - } - - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->print != -# 71 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 71 "user/mpy/py/obj.c" - ) { - type->print((mp_print_t*)print, o_in, kind); - } else { - mp_printf(print, "<%q>", type->name); - } -} - -void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_print_helper(&mp_plat_print, o_in, kind); -} - - -void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { - if (mp_obj_is_exception_instance(exc)) { - size_t n, *values; - mp_obj_exception_get_traceback(exc, &n, &values); - if (n > 0) { - -# 88 "user/mpy/py/obj.c" 3 - (( -# 88 "user/mpy/py/obj.c" - n % 3 == 0 -# 88 "user/mpy/py/obj.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/obj.c", 88, __func__, -# 88 "user/mpy/py/obj.c" - "n % 3 == 0" -# 88 "user/mpy/py/obj.c" 3 - )) -# 88 "user/mpy/py/obj.c" - ; - mp_print_str(print, "Traceback (most recent call last):\n"); - for (int i = n - 3; i >= 0; i -= 3) { - - - - mp_printf(print, " File \"%q\"", values[i]); - - - qstr block = values[i + 2]; - if (block == MP_QSTR_NULL) { - mp_print_str(print, "\n"); - } else { - mp_printf(print, ", in %q\n", block); - } - } - } - } - mp_obj_print_helper(print, exc, PRINT_EXC); - mp_print_str(print, "\n"); -} - - -# 110 "user/mpy/py/obj.c" 3 4 -_Bool -# 110 "user/mpy/py/obj.c" - mp_obj_is_true(mp_obj_t arg) { - if (arg == (((mp_obj_t)&mp_const_false_obj))) { - return 0; - } else if (arg == (((mp_obj_t)&mp_const_true_obj))) { - return 1; - } else if (arg == (((mp_obj_t)&mp_const_none_obj))) { - return 0; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - if ((((mp_int_t)(arg)) >> 1) == 0) { - return 0; - } else { - return 1; - } - } else { - mp_obj_type_t *type = mp_obj_get_type(arg); - if (type->unary_op != -# 125 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 125 "user/mpy/py/obj.c" - ) { - mp_obj_t result = type->unary_op(MP_UNARY_OP_BOOL, arg); - if (result != (((mp_obj_t)(void*)0))) { - return result == (((mp_obj_t)&mp_const_true_obj)); - } - } - - mp_obj_t len = mp_obj_len_maybe(arg); - if (len != (((mp_obj_t)(void*)0))) { - - return len != ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); - } else { - - return 1; - } - } -} - - -# 143 "user/mpy/py/obj.c" 3 4 -_Bool -# 143 "user/mpy/py/obj.c" - mp_obj_is_callable(mp_obj_t o_in) { - mp_call_fun_t call = mp_obj_get_type(o_in)->call; - if (call != mp_obj_instance_call) { - return call != -# 146 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 146 "user/mpy/py/obj.c" - ; - } - return mp_obj_instance_is_callable(o_in); -} -# 164 "user/mpy/py/obj.c" - -# 164 "user/mpy/py/obj.c" 3 4 -_Bool -# 164 "user/mpy/py/obj.c" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2) { - if (o1 == o2) { - return -# 166 "user/mpy/py/obj.c" 3 4 - 1 -# 166 "user/mpy/py/obj.c" - ; - } - if (o1 == (((mp_obj_t)&mp_const_none_obj)) || o2 == (((mp_obj_t)&mp_const_none_obj))) { - return -# 169 "user/mpy/py/obj.c" 3 4 - 0 -# 169 "user/mpy/py/obj.c" - ; - } - - - if (MP_OBJ_IS_SMALL_INT(o1)) { - if (MP_OBJ_IS_SMALL_INT(o2)) { - - return -# 176 "user/mpy/py/obj.c" 3 4 - 0 -# 176 "user/mpy/py/obj.c" - ; - } else { - mp_obj_t temp = o2; o2 = o1; o1 = temp; - - - } - } - - - if ((MP_OBJ_IS_QSTR(o1) || (MP_OBJ_IS_OBJ(o1) && (((mp_obj_base_t*)((void*)o1))->type == (&mp_type_str))))) { - if ((MP_OBJ_IS_QSTR(o2) || (MP_OBJ_IS_OBJ(o2) && (((mp_obj_base_t*)((void*)o2))->type == (&mp_type_str))))) { - - return mp_obj_str_equal(o1, o2); - } else { - - goto str_cmp_err; - } - } else if ((MP_OBJ_IS_QSTR(o2) || (MP_OBJ_IS_OBJ(o2) && (((mp_obj_base_t*)((void*)o2))->type == (&mp_type_str))))) { - - str_cmp_err: - - - - - - return -# 201 "user/mpy/py/obj.c" 3 4 - 0 -# 201 "user/mpy/py/obj.c" - ; - } - - - mp_obj_type_t *type = mp_obj_get_type(o1); - if (type->binary_op != -# 206 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 206 "user/mpy/py/obj.c" - ) { - mp_obj_t r = type->binary_op(MP_BINARY_OP_EQUAL, o1, o2); - if (r != (((mp_obj_t)(void*)0))) { - return r == (((mp_obj_t)&mp_const_true_obj)) ? -# 209 "user/mpy/py/obj.c" 3 4 - 1 -# 209 "user/mpy/py/obj.c" - : -# 209 "user/mpy/py/obj.c" 3 4 - 0 -# 209 "user/mpy/py/obj.c" - ; - } - } - - - - return -# 215 "user/mpy/py/obj.c" 3 4 - 0 -# 215 "user/mpy/py/obj.c" - ; -} - -mp_int_t mp_obj_get_int(mp_const_obj_t arg) { - - - - if (arg == (((mp_obj_t)&mp_const_false_obj))) { - return 0; - } else if (arg == (((mp_obj_t)&mp_const_true_obj))) { - return 1; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - return (((mp_int_t)(arg)) >> 1); - } else if ((MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int)))) { - return mp_obj_int_get_checked(arg); - } else { - if (((1)) == (1)) { - mp_raise_TypeError("can't convert to int"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't convert %s to int", mp_obj_get_type_str(arg)))) - ; - } - } -} - -mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg) { - if ((MP_OBJ_IS_SMALL_INT(arg) || (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int))))) { - return mp_obj_int_get_truncated(arg); - } else { - return mp_obj_get_int(arg); - } -} - - - - - -# 251 "user/mpy/py/obj.c" 3 4 -_Bool -# 251 "user/mpy/py/obj.c" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value) { - if (arg == (((mp_obj_t)&mp_const_false_obj))) { - *value = 0; - } else if (arg == (((mp_obj_t)&mp_const_true_obj))) { - *value = 1; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - *value = (((mp_int_t)(arg)) >> 1); - } else if ((MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int)))) { - *value = mp_obj_int_get_checked(arg); - } else { - return -# 261 "user/mpy/py/obj.c" 3 4 - 0 -# 261 "user/mpy/py/obj.c" - ; - } - return -# 263 "user/mpy/py/obj.c" 3 4 - 1 -# 263 "user/mpy/py/obj.c" - ; -} -# 324 "user/mpy/py/obj.c" -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) { - if ((MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_tuple)))) { - mp_obj_tuple_get(o, len, items); - } else if ((MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_list)))) { - mp_obj_list_get(o, len, items); - } else { - if (((1)) == (1)) { - mp_raise_TypeError("expected tuple/list"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "object '%s' is not a tuple or list", mp_obj_get_type_str(o)))) - ; - } - } -} - - -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) { - size_t seq_len; - mp_obj_get_array(o, &seq_len, items); - if (seq_len != len) { - if (((1)) == (1)) { - mp_raise_ValueError("tuple/list has wrong length"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "requested length %d but object has length %d", (int)len, (int)seq_len))) - ; - } - } -} - - -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 354 "user/mpy/py/obj.c" 3 4 - _Bool -# 354 "user/mpy/py/obj.c" - is_slice) { - mp_int_t i; - if (MP_OBJ_IS_SMALL_INT(index)) { - i = (((mp_int_t)(index)) >> 1); - } else if (!mp_obj_get_int_maybe(index, &i)) { - if (((1)) == (1)) { - mp_raise_TypeError("indices must be integers"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "%q indices must be integers, not %s", type->name, mp_obj_get_type_str(index)))) - - ; - } - } - - if (i < 0) { - i += len; - } - if (is_slice) { - if (i < 0) { - i = 0; - } else if ((mp_uint_t)i > len) { - i = len; - } - } else { - if (i < 0 || (mp_uint_t)i >= len) { - if (((1)) == (1)) { - mp_raise_msg(&mp_type_IndexError, "index out of range"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_IndexError, "%q index out of range", type->name))) - ; - } - } - } - - - return (size_t)i; -} - -mp_obj_t mp_obj_id(mp_obj_t o_in) { - mp_int_t id = (mp_int_t)o_in; - if (!MP_OBJ_IS_OBJ(o_in)) { - return mp_obj_new_int(id); - } else if (id >= 0) { - - - - - return ((mp_obj_t)((((mp_uint_t)(id)) << 1) | 1)); - } else { - - - - return mp_obj_new_int_from_uint((mp_uint_t)id); - } -} - - -mp_obj_t mp_obj_len(mp_obj_t o_in) { - mp_obj_t len = mp_obj_len_maybe(o_in); - if (len == (((mp_obj_t)(void*)0))) { - if (((1)) == (1)) { - mp_raise_TypeError("object has no len"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "object of type '%s' has no len()", mp_obj_get_type_str(o_in)))) - ; - } - } else { - return len; - } -} - - -mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { - if ( - - - (MP_OBJ_IS_QSTR(o_in) || (MP_OBJ_IS_OBJ(o_in) && (((mp_obj_base_t*)((void*)o_in))->type == (&mp_type_str)))) || - - (MP_OBJ_IS_OBJ(o_in) && (((mp_obj_base_t*)((void*)o_in))->type == (&mp_type_bytes)))) { - size_t l; if (MP_OBJ_IS_QSTR(o_in)) { l = qstr_len((((mp_uint_t)(o_in)) >> 2)); } else { l = ((mp_obj_str_t*)((void*)o_in))->len; }; - return ((mp_obj_t)((((mp_uint_t)(l)) << 1) | 1)); - } else { - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->unary_op != -# 437 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 437 "user/mpy/py/obj.c" - ) { - return type->unary_op(MP_UNARY_OP_LEN, o_in); - } else { - return (((mp_obj_t)(void*)0)); - } - } -} - -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { - mp_obj_type_t *type = mp_obj_get_type(base); - if (type->subscr != -# 447 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 447 "user/mpy/py/obj.c" - ) { - mp_obj_t ret = type->subscr(base, index, value); - if (ret != (((mp_obj_t)(void*)0))) { - return ret; - } - - } - if (value == (((mp_obj_t)(void*)0))) { - if (((1)) == (1)) { - mp_raise_TypeError("object does not support item deletion"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object does not support item deletion", mp_obj_get_type_str(base)))) - ; - } - } else if (value == (((mp_obj_t)(void*)8))) { - if (((1)) == (1)) { - mp_raise_TypeError("object is not subscriptable"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not subscriptable", mp_obj_get_type_str(base)))) - ; - } - } else { - if (((1)) == (1)) { - mp_raise_TypeError("object does not support item assignment"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object does not support item assignment", mp_obj_get_type_str(base)))) - ; - } - } -} - - - -mp_obj_t mp_identity(mp_obj_t self) { - return self; -} -const mp_obj_fun_builtin_fixed_t mp_identity_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_identity}; - -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf) { - (void)iter_buf; - return self; -} - - -# 490 "user/mpy/py/obj.c" 3 4 -_Bool -# 490 "user/mpy/py/obj.c" - mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - mp_obj_type_t *type = mp_obj_get_type(obj); - if (type->buffer_p.get_buffer == -# 492 "user/mpy/py/obj.c" 3 4 - ((void *)0) -# 492 "user/mpy/py/obj.c" - ) { - return -# 493 "user/mpy/py/obj.c" 3 4 - 0 -# 493 "user/mpy/py/obj.c" - ; - } - int ret = type->buffer_p.get_buffer(obj, bufinfo, flags); - if (ret != 0) { - return -# 497 "user/mpy/py/obj.c" 3 4 - 0 -# 497 "user/mpy/py/obj.c" - ; - } - return -# 499 "user/mpy/py/obj.c" 3 4 - 1 -# 499 "user/mpy/py/obj.c" - ; -} - -void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - if (!mp_get_buffer(obj, bufinfo, flags)) { - mp_raise_TypeError("object with buffer protocol required"); - } -} - -mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in) { - switch (op) { - case MP_UNARY_OP_HASH: return ((mp_obj_t)((((mp_uint_t)((mp_uint_t)o_in)) << 1) | 1)); - default: return (((mp_obj_t)(void*)0)); - } -} -# 1 "user/mpy/py/objarray.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objarray.c" -# 28 "user/mpy/py/objarray.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/objarray.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objarray.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 31 "user/mpy/py/objarray.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 33 "user/mpy/py/objarray.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 34 "user/mpy/py/objarray.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 35 "user/mpy/py/objarray.c" 2 -# 1 "user/mpy/py/binary.h" 1 -# 35 "user/mpy/py/binary.h" -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 36 "user/mpy/py/objarray.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 37 "user/mpy/py/objarray.c" 2 -# 1 "user/mpy/py/objarray.h" 1 -# 32 "user/mpy/py/objarray.h" -typedef struct _mp_obj_array_t { - mp_obj_base_t base; - size_t typecode : 8; - - - size_t free : (8 * sizeof(size_t) - 8); - size_t len; - void *items; -} mp_obj_array_t; -# 38 "user/mpy/py/objarray.c" 2 -# 1 "user/mpy/py/objattrtuple.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objattrtuple.c" -# 27 "user/mpy/py/objattrtuple.c" -# 1 "user/mpy/py/objtuple.h" 1 -# 29 "user/mpy/py/objtuple.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtuple.h" 2 - -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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 28 "user/mpy/py/objattrtuple.c" 2 -# 1 "user/mpy/py/objbool.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objbool.c" -# 27 "user/mpy/py/objbool.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objbool.c" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objbool.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 31 "user/mpy/py/objbool.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/objbool.c" 2 - -typedef struct _mp_obj_bool_t { - mp_obj_base_t base; - -# 35 "user/mpy/py/objbool.c" 3 4 - _Bool -# 35 "user/mpy/py/objbool.c" - value; -} mp_obj_bool_t; - -static void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_bool_t *self = ((void*)self_in); - if ((0) && kind == PRINT_JSON) { - if (self->value) { - mp_print_str(print, "true"); - } else { - mp_print_str(print, "false"); - } - } else { - if (self->value) { - mp_print_str(print, "True"); - } else { - mp_print_str(print, "False"); - } - } -} - -static mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 1, -# 57 "user/mpy/py/objbool.c" 3 4 - 0 -# 57 "user/mpy/py/objbool.c" - ); - - if (n_args == 0) { - return (((mp_obj_t)&mp_const_false_obj)); - } else { - return mp_obj_new_bool(mp_obj_is_true(args[0])); - } -} - -static mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { - if (op == MP_UNARY_OP_LEN) { - return (((mp_obj_t)(void*)0)); - } - mp_obj_bool_t *self = ((void*)o_in); - return mp_unary_op(op, ((mp_obj_t)((((mp_uint_t)(self->value)) << 1) | 1))); -} - -static mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_bool_t *self = ((void*)lhs_in); - return mp_binary_op(op, ((mp_obj_t)((((mp_uint_t)(self->value)) << 1) | 1)), rhs_in); -} - -const mp_obj_type_t mp_type_bool = { - { &mp_type_type }, - .name = MP_QSTR_bool, - .print = bool_print, - .make_new = bool_make_new, - .unary_op = bool_unary_op, - .binary_op = bool_binary_op, -}; - -const mp_obj_bool_t mp_const_false_obj = {{&mp_type_bool}, -# 88 "user/mpy/py/objbool.c" 3 4 - 0 -# 88 "user/mpy/py/objbool.c" - }; -const mp_obj_bool_t mp_const_true_obj = {{&mp_type_bool}, -# 89 "user/mpy/py/objbool.c" 3 4 - 1 -# 89 "user/mpy/py/objbool.c" - }; -# 1 "user/mpy/py/objboundmeth.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objboundmeth.c" -# 27 "user/mpy/py/objboundmeth.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objboundmeth.c" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objboundmeth.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objboundmeth.c" 2 - -typedef struct _mp_obj_bound_meth_t { - mp_obj_base_t base; - mp_obj_t meth; - mp_obj_t self; -} mp_obj_bound_meth_t; -# 50 "user/mpy/py/objboundmeth.c" -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) { - - size_t n_total = n_args + 2 * n_kw; - mp_obj_t *args2 = -# 53 "user/mpy/py/objboundmeth.c" 3 4 - ((void *)0) -# 53 "user/mpy/py/objboundmeth.c" - ; - mp_obj_t *free_args2 = -# 54 "user/mpy/py/objboundmeth.c" 3 4 - ((void *)0) -# 54 "user/mpy/py/objboundmeth.c" - ; - if (n_total > 4) { - - args2 = ((mp_obj_t*)(m_malloc_maybe(sizeof(mp_obj_t) * (1 + n_total)))); - free_args2 = args2; - } - if (args2 == -# 60 "user/mpy/py/objboundmeth.c" 3 4 - ((void *)0) -# 60 "user/mpy/py/objboundmeth.c" - ) { - - args2 = -# 62 "user/mpy/py/objboundmeth.c" 3 - __builtin_alloca( -# 62 "user/mpy/py/objboundmeth.c" - sizeof(mp_obj_t) * (1 + n_total) -# 62 "user/mpy/py/objboundmeth.c" 3 - ) -# 62 "user/mpy/py/objboundmeth.c" - ; - } - args2[0] = self; - memcpy(args2 + 1, args, n_total * sizeof(mp_obj_t)); - mp_obj_t res = mp_call_function_n_kw(meth, n_args + 1, n_kw, args2); - if (free_args2 != -# 67 "user/mpy/py/objboundmeth.c" 3 4 - ((void *)0) -# 67 "user/mpy/py/objboundmeth.c" - ) { - ((void)(1 + n_total), m_free(free_args2)); - } - return res; -} - -static mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_bound_meth_t *self = ((void*)self_in); - return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args); -} -# 91 "user/mpy/py/objboundmeth.c" -static const mp_obj_type_t mp_type_bound_meth = { - { &mp_type_type }, - .name = MP_QSTR_bound_method, - - - - .call = bound_meth_call, - - - -}; - -mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) { - mp_obj_bound_meth_t *o = (((mp_obj_bound_meth_t*)(m_malloc(sizeof(mp_obj_bound_meth_t) * (1))))); - o->base.type = &mp_type_bound_meth; - o->meth = meth; - o->self = self; - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objcell.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objcell.c" -# 27 "user/mpy/py/objcell.c" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 28 "user/mpy/py/objcell.c" 2 - -typedef struct _mp_obj_cell_t { - mp_obj_base_t base; - mp_obj_t obj; -} mp_obj_cell_t; - -mp_obj_t mp_obj_cell_get(mp_obj_t self_in) { - mp_obj_cell_t *self = ((void*)self_in); - return self->obj; -} - -void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) { - mp_obj_cell_t *self = ((void*)self_in); - self->obj = obj; -} -# 58 "user/mpy/py/objcell.c" -static const mp_obj_type_t mp_type_cell = { - { &mp_type_type }, - .name = MP_QSTR_, - - - -}; - -mp_obj_t mp_obj_new_cell(mp_obj_t obj) { - mp_obj_cell_t *o = (((mp_obj_cell_t*)(m_malloc(sizeof(mp_obj_cell_t) * (1))))); - o->base.type = &mp_type_cell; - o->obj = obj; - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objclosure.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objclosure.c" -# 27 "user/mpy/py/objclosure.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objclosure.c" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objclosure.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objclosure.c" 2 - -typedef struct _mp_obj_closure_t { - mp_obj_base_t base; - mp_obj_t fun; - size_t n_closed; - mp_obj_t closed[]; -} mp_obj_closure_t; - -static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_closure_t *self = ((void*)self_in); - - - - size_t n_total = self->n_closed + n_args + 2 * n_kw; - if (n_total <= 5) { - - mp_obj_t args2[5]; - memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); - memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - return mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); - } else { - - mp_obj_t *args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (n_total)))); - memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); - memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - mp_obj_t res = mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); - ((void)(n_total), m_free(args2)); - return res; - } -} -# 81 "user/mpy/py/objclosure.c" -const mp_obj_type_t closure_type = { - { &mp_type_type }, - .name = MP_QSTR_closure, - - - - .call = closure_call, -}; - -mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) { - mp_obj_closure_t *o = ((mp_obj_closure_t*)m_malloc(sizeof(mp_obj_closure_t) + sizeof(mp_obj_t) * (n_closed_over))); - o->base.type = &closure_type; - o->fun = fun; - o->n_closed = n_closed_over; - memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t)); - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objcomplex.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objcomplex.c" -# 27 "user/mpy/py/objcomplex.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objcomplex.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 61 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/objcomplex.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objcomplex.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objcomplex.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 33 "user/mpy/py/objcomplex.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 34 "user/mpy/py/objcomplex.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/objcomplex.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 36 "user/mpy/py/objcomplex.c" 2 -# 1 "user/mpy/py/objdict.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objdict.c" -# 27 "user/mpy/py/objdict.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objdict.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objdict.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objdict.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 32 "user/mpy/py/objdict.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/objdict.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/objdict.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 35 "user/mpy/py/objdict.c" 2 -# 1 "user/mpy/py/objtype.h" 1 -# 33 "user/mpy/py/objtype.h" -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 36 "user/mpy/py/objdict.c" 2 - - - -static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); - - - - -static mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) { - size_t max = dict->map.alloc; - mp_map_t *map = &dict->map; - - for (size_t i = *cur; i < max; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - *cur = i + 1; - return &(map->table[i]); - } - } - - return -# 55 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 55 "user/mpy/py/objdict.c" - ; -} - -static void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_dict_t *self = ((void*)self_in); - -# 60 "user/mpy/py/objdict.c" 3 4 - _Bool -# 60 "user/mpy/py/objdict.c" - first = -# 60 "user/mpy/py/objdict.c" 3 4 - 1 -# 60 "user/mpy/py/objdict.c" - ; - if (!((0) && kind == PRINT_JSON)) { - kind = PRINT_REPR; - } - if ((0) && self->base.type != &mp_type_dict) { - mp_printf(print, "%q(", self->base.type->name); - } - mp_print_str(print, "{"); - size_t cur = 0; - mp_map_elem_t *next = -# 69 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 69 "user/mpy/py/objdict.c" - ; - while ((next = dict_iter_next(self, &cur)) != -# 70 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 70 "user/mpy/py/objdict.c" - ) { - if (!first) { - mp_print_str(print, ", "); - } - first = -# 74 "user/mpy/py/objdict.c" 3 4 - 0 -# 74 "user/mpy/py/objdict.c" - ; - mp_obj_print_helper(print, next->key, kind); - mp_print_str(print, ": "); - mp_obj_print_helper(print, next->value, kind); - } - mp_print_str(print, "}"); - if ((0) && self->base.type != &mp_type_dict) { - mp_print_str(print, ")"); - } -} - -static mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_t dict_out = mp_obj_new_dict(0); - mp_obj_dict_t *dict = ((void*)dict_out); - dict->base.type = type; - - - - - - if (n_args > 0 || n_kw > 0) { - mp_obj_t args2[2] = {dict_out, args[0]}; - mp_map_t kwargs; - mp_map_init_fixed_table(&kwargs, n_kw, args + n_args); - dict_update(n_args + 1, args2, &kwargs); - } - return dict_out; -} - -static mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_dict_t *self = ((void*)self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0); - case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(self->map.used)) << 1) | 1)); - - - - - - - default: return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_dict_t *o = ((void*)lhs_in); - switch (op) { - case MP_BINARY_OP_IN: { - mp_map_elem_t *elem = mp_map_lookup(&o->map, rhs_in, MP_MAP_LOOKUP); - return mp_obj_new_bool(elem != -# 123 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 123 "user/mpy/py/objdict.c" - ); - } - case MP_BINARY_OP_EQUAL: { -# 140 "user/mpy/py/objdict.c" - if ((MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_dict)))) { - mp_obj_dict_t *rhs = ((void*)rhs_in); - if (o->map.used != rhs->map.used) { - return (((mp_obj_t)&mp_const_false_obj)); - } - - size_t cur = 0; - mp_map_elem_t *next = -# 147 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 147 "user/mpy/py/objdict.c" - ; - while ((next = dict_iter_next(o, &cur)) != -# 148 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 148 "user/mpy/py/objdict.c" - ) { - mp_map_elem_t *elem = mp_map_lookup(&rhs->map, next->key, MP_MAP_LOOKUP); - if (elem == -# 150 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 150 "user/mpy/py/objdict.c" - || !mp_obj_equal(next->value, elem->value)) { - return (((mp_obj_t)&mp_const_false_obj)); - } - } - return (((mp_obj_t)&mp_const_true_obj)); - } else { - - return (((mp_obj_t)&mp_const_false_obj)); - } - } - default: - - return (((mp_obj_t)(void*)0)); - } -} - - -mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { - mp_obj_dict_t *self = ((void*)self_in); - mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); - if (elem == -# 170 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 170 "user/mpy/py/objdict.c" - ) { - nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, index))); - } else { - return elem->value; - } -} - -static mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == (((mp_obj_t)(void*)0))) { - - mp_obj_dict_delete(self_in, index); - return (((mp_obj_t)&mp_const_none_obj)); - } else if (value == (((mp_obj_t)(void*)8))) { - - mp_obj_dict_t *self = ((void*)self_in); - mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); - if (elem == -# 186 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 186 "user/mpy/py/objdict.c" - ) { - nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, index))); - } else { - return elem->value; - } - } else { - - mp_obj_dict_store(self_in, index, value); - return (((mp_obj_t)&mp_const_none_obj)); - } -} - - - - -typedef struct _mp_obj_dict_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t dict; - size_t cur; -} mp_obj_dict_it_t; - -static mp_obj_t dict_it_iternext(mp_obj_t self_in) { - mp_obj_dict_it_t *self = ((void*)self_in); - mp_map_elem_t *next = dict_iter_next(((void*)self->dict), &self->cur); - - if (next == -# 212 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 212 "user/mpy/py/objdict.c" - ) { - return (((mp_obj_t)(void*)4)); - } else { - return next->key; - } -} - -static mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { - -# 220 "user/mpy/py/objdict.c" 3 - (( -# 220 "user/mpy/py/objdict.c" - sizeof(mp_obj_dict_it_t) <= sizeof(mp_obj_iter_buf_t) -# 220 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 220, __func__, -# 220 "user/mpy/py/objdict.c" - "sizeof(mp_obj_dict_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 220 "user/mpy/py/objdict.c" 3 - )) -# 220 "user/mpy/py/objdict.c" - ; - mp_obj_dict_it_t *o = (mp_obj_dict_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = dict_it_iternext; - o->dict = self_in; - o->cur = 0; - return ((mp_obj_t)o); -} - - - - -static mp_obj_t dict_clear(mp_obj_t self_in) { - -# 233 "user/mpy/py/objdict.c" 3 - (( -# 233 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) -# 233 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 233, __func__, -# 233 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" -# 233 "user/mpy/py/objdict.c" 3 - )) -# 233 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)self_in); - - mp_map_clear(&self->map); - - return (((mp_obj_t)&mp_const_none_obj)); -} -static const mp_obj_fun_builtin_fixed_t dict_clear_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_clear}; - -static mp_obj_t dict_copy(mp_obj_t self_in) { - -# 243 "user/mpy/py/objdict.c" 3 - (( -# 243 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) -# 243 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 243, __func__, -# 243 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" -# 243 "user/mpy/py/objdict.c" 3 - )) -# 243 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)self_in); - mp_obj_t other_out = mp_obj_new_dict(self->map.alloc); - mp_obj_dict_t *other = ((void*)other_out); - other->base.type = self->base.type; - other->map.used = self->map.used; - other->map.all_keys_are_qstrs = self->map.all_keys_are_qstrs; - other->map.is_fixed = 0; - other->map.is_ordered = self->map.is_ordered; - memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t)); - return other_out; -} -static const mp_obj_fun_builtin_fixed_t dict_copy_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_copy}; - - -static mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) { - mp_obj_t iter = mp_getiter(args[1], -# 259 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 259 "user/mpy/py/objdict.c" - ); - mp_obj_t value = (((mp_obj_t)&mp_const_none_obj)); - mp_obj_t next = (((mp_obj_t)(void*)0)); - - if (n_args > 2) { - value = args[2]; - } - - - mp_obj_t self_out; - mp_obj_t len = mp_obj_len_maybe(args[1]); - if (len == (((mp_obj_t)(void*)0))) { - - self_out = mp_obj_new_dict(0); - } else { - self_out = mp_obj_new_dict((((mp_int_t)(len)) >> 1)); - } - - mp_obj_dict_t *self = ((void*)self_out); - while ((next = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { - mp_map_lookup(&self->map, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - } - - return self_out; -} -static const mp_obj_fun_builtin_var_t dict_fromkeys_fun_obj = {{&mp_type_fun_builtin_var}, -# 284 "user/mpy/py/objdict.c" 3 4 - 0 -# 284 "user/mpy/py/objdict.c" - , 2, 3, .fun.var = dict_fromkeys}; -static const mp_rom_obj_static_class_method_t dict_fromkeys_obj = {{&mp_type_classmethod}, (&dict_fromkeys_fun_obj)}; - -static mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) { - -# 288 "user/mpy/py/objdict.c" 3 - (( -# 288 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new) -# 288 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 288, __func__, -# 288 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new)" -# 288 "user/mpy/py/objdict.c" 3 - )) -# 288 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)args[0]); - mp_map_elem_t *elem = mp_map_lookup(&self->map, args[1], lookup_kind); - mp_obj_t value; - if (elem == -# 292 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 292 "user/mpy/py/objdict.c" - || elem->value == (((mp_obj_t)(void*)0))) { - if (n_args == 2) { - if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, args[1]))); - } else { - value = (((mp_obj_t)&mp_const_none_obj)); - } - } else { - value = args[2]; - } - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - elem->value = value; - } - } else { - value = elem->value; - if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - elem->value = (((mp_obj_t)(void*)0)); - } - } - return value; -} - -static mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) { - return dict_get_helper(n_args, args, MP_MAP_LOOKUP); -} -static const mp_obj_fun_builtin_var_t dict_get_obj = {{&mp_type_fun_builtin_var}, -# 317 "user/mpy/py/objdict.c" 3 4 - 0 -# 317 "user/mpy/py/objdict.c" - , 2, 3, .fun.var = dict_get}; - -static mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) { - return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); -} -static const mp_obj_fun_builtin_var_t dict_pop_obj = {{&mp_type_fun_builtin_var}, -# 322 "user/mpy/py/objdict.c" 3 4 - 0 -# 322 "user/mpy/py/objdict.c" - , 2, 3, .fun.var = dict_pop}; - -static mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) { - return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); -} -static const mp_obj_fun_builtin_var_t dict_setdefault_obj = {{&mp_type_fun_builtin_var}, -# 327 "user/mpy/py/objdict.c" 3 4 - 0 -# 327 "user/mpy/py/objdict.c" - , 2, 3, .fun.var = dict_setdefault}; - -static mp_obj_t dict_popitem(mp_obj_t self_in) { - -# 330 "user/mpy/py/objdict.c" 3 - (( -# 330 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) -# 330 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 330, __func__, -# 330 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" -# 330 "user/mpy/py/objdict.c" 3 - )) -# 330 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)self_in); - size_t cur = 0; - mp_map_elem_t *next = dict_iter_next(self, &cur); - if (next == -# 334 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 334 "user/mpy/py/objdict.c" - ) { - mp_raise_msg(&mp_type_KeyError, "popitem(): dictionary is empty"); - } - self->map.used--; - mp_obj_t items[] = {next->key, next->value}; - next->key = (((mp_obj_t)(void*)8)); - next->value = (((mp_obj_t)(void*)0)); - mp_obj_t tuple = mp_obj_new_tuple(2, items); - - return tuple; -} -static const mp_obj_fun_builtin_fixed_t dict_popitem_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_popitem}; - -static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - -# 348 "user/mpy/py/objdict.c" 3 - (( -# 348 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new) -# 348 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 348, __func__, -# 348 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->make_new == dict_make_new)" -# 348 "user/mpy/py/objdict.c" 3 - )) -# 348 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)args[0]); - - mp_arg_check_num(n_args, kwargs->used, 1, 2, -# 351 "user/mpy/py/objdict.c" 3 4 - 1 -# 351 "user/mpy/py/objdict.c" - ); - - if (n_args == 2) { - - - if ((MP_OBJ_IS_OBJ(args[1]) && ((mp_obj_base_t*)((void*)args[1]))->type->make_new == dict_make_new)) { - - if (args[1] != args[0]) { - size_t cur = 0; - mp_map_elem_t *elem = -# 360 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 360 "user/mpy/py/objdict.c" - ; - while ((elem = dict_iter_next((mp_obj_dict_t*)((void*)args[1]), &cur)) != -# 361 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 361 "user/mpy/py/objdict.c" - ) { - mp_map_lookup(&self->map, elem->key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = elem->value; - } - } - } else { - - mp_obj_t iter = mp_getiter(args[1], -# 367 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 367 "user/mpy/py/objdict.c" - ); - mp_obj_t next = (((mp_obj_t)(void*)0)); - while ((next = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { - mp_obj_t inneriter = mp_getiter(next, -# 370 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 370 "user/mpy/py/objdict.c" - ); - mp_obj_t key = mp_iternext(inneriter); - mp_obj_t value = mp_iternext(inneriter); - mp_obj_t stop = mp_iternext(inneriter); - if (key == (((mp_obj_t)(void*)4)) - || value == (((mp_obj_t)(void*)4)) - || stop != (((mp_obj_t)(void*)4))) { - mp_raise_ValueError("dict update sequence has wrong length"); - } else { - mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - } - } - } - } - - - for (size_t i = 0; i < kwargs->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) { - mp_map_lookup(&self->map, kwargs->table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = kwargs->table[i].value; - } - } - - return (((mp_obj_t)&mp_const_none_obj)); -} -static const mp_obj_fun_builtin_var_t dict_update_obj = {{&mp_type_fun_builtin_var}, -# 394 "user/mpy/py/objdict.c" 3 4 - 1 -# 394 "user/mpy/py/objdict.c" - , 1, (0xffff), .fun.kw = dict_update}; - - - - - -static const mp_obj_type_t dict_view_type; -static const mp_obj_type_t dict_view_it_type; - -typedef enum _mp_dict_view_kind_t { - MP_DICT_VIEW_ITEMS, - MP_DICT_VIEW_KEYS, - MP_DICT_VIEW_VALUES, -} mp_dict_view_kind_t; - -static const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"}; - -typedef struct _mp_obj_dict_view_it_t { - mp_obj_base_t base; - mp_dict_view_kind_t kind; - mp_obj_t dict; - size_t cur; -} mp_obj_dict_view_it_t; - -typedef struct _mp_obj_dict_view_t { - mp_obj_base_t base; - mp_obj_t dict; - mp_dict_view_kind_t kind; -} mp_obj_dict_view_t; - -static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) { - -# 425 "user/mpy/py/objdict.c" 3 - (( -# 425 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_it_type))) -# 425 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 425, __func__, -# 425 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_it_type)))" -# 425 "user/mpy/py/objdict.c" 3 - )) -# 425 "user/mpy/py/objdict.c" - ; - mp_obj_dict_view_it_t *self = ((void*)self_in); - mp_map_elem_t *next = dict_iter_next(((void*)self->dict), &self->cur); - - if (next == -# 429 "user/mpy/py/objdict.c" 3 4 - ((void *)0) -# 429 "user/mpy/py/objdict.c" - ) { - return (((mp_obj_t)(void*)4)); - } else { - switch (self->kind) { - case MP_DICT_VIEW_ITEMS: - default: { - mp_obj_t items[] = {next->key, next->value}; - return mp_obj_new_tuple(2, items); - } - case MP_DICT_VIEW_KEYS: - return next->key; - case MP_DICT_VIEW_VALUES: - return next->value; - } - } -} - -static const mp_obj_type_t dict_view_it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = dict_view_it_iternext, -}; - -static mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) { - -# 454 "user/mpy/py/objdict.c" 3 - (( -# 454 "user/mpy/py/objdict.c" - sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t) -# 454 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 454, __func__, -# 454 "user/mpy/py/objdict.c" - "sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 454 "user/mpy/py/objdict.c" 3 - )) -# 454 "user/mpy/py/objdict.c" - ; - -# 455 "user/mpy/py/objdict.c" 3 - (( -# 455 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(view_in) && (((mp_obj_base_t*)((void*)view_in))->type == (&dict_view_type))) -# 455 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 455, __func__, -# 455 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(view_in) && (((mp_obj_base_t*)((void*)view_in))->type == (&dict_view_type)))" -# 455 "user/mpy/py/objdict.c" 3 - )) -# 455 "user/mpy/py/objdict.c" - ; - mp_obj_dict_view_t *view = ((void*)view_in); - mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t*)iter_buf; - o->base.type = &dict_view_it_type; - o->kind = view->kind; - o->dict = view->dict; - o->cur = 0; - return ((mp_obj_t)o); -} - -static void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - -# 467 "user/mpy/py/objdict.c" 3 - (( -# 467 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_type))) -# 467 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 467, __func__, -# 467 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&dict_view_type)))" -# 467 "user/mpy/py/objdict.c" 3 - )) -# 467 "user/mpy/py/objdict.c" - ; - mp_obj_dict_view_t *self = ((void*)self_in); - -# 469 "user/mpy/py/objdict.c" 3 4 - _Bool -# 469 "user/mpy/py/objdict.c" - first = -# 469 "user/mpy/py/objdict.c" 3 4 - 1 -# 469 "user/mpy/py/objdict.c" - ; - mp_print_str(print, mp_dict_view_names[self->kind]); - mp_print_str(print, "(["); - mp_obj_iter_buf_t iter_buf; - mp_obj_t self_iter = dict_view_getiter(self_in, &iter_buf); - mp_obj_t next = (((mp_obj_t)(void*)0)); - while ((next = dict_view_it_iternext(self_iter)) != (((mp_obj_t)(void*)4))) { - if (!first) { - mp_print_str(print, ", "); - } - first = -# 479 "user/mpy/py/objdict.c" 3 4 - 0 -# 479 "user/mpy/py/objdict.c" - ; - mp_obj_print_helper(print, next, PRINT_REPR); - } - mp_print_str(print, "])"); -} - -static mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - - mp_obj_dict_view_t *o = ((void*)lhs_in); - if (o->kind != MP_DICT_VIEW_KEYS) { - return (((mp_obj_t)(void*)0)); - } - if (op != MP_BINARY_OP_IN) { - return (((mp_obj_t)(void*)0)); - } - return dict_binary_op(op, o->dict, rhs_in); -} - -static const mp_obj_type_t dict_view_type = { - { &mp_type_type }, - .name = MP_QSTR_dict_view, - .print = dict_view_print, - .binary_op = dict_view_binary_op, - .getiter = dict_view_getiter, -}; - -static mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) { - mp_obj_dict_view_t *o = (((mp_obj_dict_view_t*)(m_malloc(sizeof(mp_obj_dict_view_t) * (1))))); - o->base.type = &dict_view_type; - o->dict = dict; - o->kind = kind; - return ((mp_obj_t)o); -} - -static mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) { - -# 514 "user/mpy/py/objdict.c" 3 - (( -# 514 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) -# 514 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 514, __func__, -# 514 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" -# 514 "user/mpy/py/objdict.c" 3 - )) -# 514 "user/mpy/py/objdict.c" - ; - return mp_obj_new_dict_view(self_in, kind); -} - -static mp_obj_t dict_items(mp_obj_t self_in) { - return dict_view(self_in, MP_DICT_VIEW_ITEMS); -} -static const mp_obj_fun_builtin_fixed_t dict_items_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_items}; - -static mp_obj_t dict_keys(mp_obj_t self_in) { - return dict_view(self_in, MP_DICT_VIEW_KEYS); -} -static const mp_obj_fun_builtin_fixed_t dict_keys_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_keys}; - -static mp_obj_t dict_values(mp_obj_t self_in) { - return dict_view(self_in, MP_DICT_VIEW_VALUES); -} -static const mp_obj_fun_builtin_fixed_t dict_values_obj = {{&mp_type_fun_builtin_1}, .fun._1 = dict_values}; - - - - -static const mp_rom_map_elem_t dict_locals_dict_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_clear)) << 2) | 2)), (&dict_clear_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_copy)) << 2) | 2)), (&dict_copy_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_fromkeys)) << 2) | 2)), (&dict_fromkeys_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_get)) << 2) | 2)), (&dict_get_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_items)) << 2) | 2)), (&dict_items_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_keys)) << 2) | 2)), (&dict_keys_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_pop)) << 2) | 2)), (&dict_pop_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_popitem)) << 2) | 2)), (&dict_popitem_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_setdefault)) << 2) | 2)), (&dict_setdefault_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_update)) << 2) | 2)), (&dict_update_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_values)) << 2) | 2)), (&dict_values_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___getitem__)) << 2) | 2)), (&mp_op_getitem_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___setitem__)) << 2) | 2)), (&mp_op_setitem_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___delitem__)) << 2) | 2)), (&mp_op_delitem_obj) }, -}; - -static const mp_obj_dict_t dict_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(dict_locals_dict_table) / sizeof((dict_locals_dict_table)[0])), .alloc = (sizeof(dict_locals_dict_table) / sizeof((dict_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)dict_locals_dict_table, }, }; - -const mp_obj_type_t mp_type_dict = { - { &mp_type_type }, - .name = MP_QSTR_dict, - .print = dict_print, - .make_new = dict_make_new, - .unary_op = dict_unary_op, - .binary_op = dict_binary_op, - .subscr = dict_subscr, - .getiter = dict_getiter, - .locals_dict = (mp_obj_dict_t*)&dict_locals_dict, -}; -# 582 "user/mpy/py/objdict.c" -void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args) { - dict->base.type = &mp_type_dict; - mp_map_init(&dict->map, n_args); -} - -mp_obj_t mp_obj_new_dict(size_t n_args) { - mp_obj_dict_t *o = (((mp_obj_dict_t*)(m_malloc(sizeof(mp_obj_dict_t) * (1))))); - mp_obj_dict_init(o, n_args); - return ((mp_obj_t)o); -} - -size_t mp_obj_dict_len(mp_obj_t self_in) { - mp_obj_dict_t *self = ((void*)self_in); - return self->map.used; -} - -mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) { - -# 599 "user/mpy/py/objdict.c" 3 - (( -# 599 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) -# 599 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 599, __func__, -# 599 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" -# 599 "user/mpy/py/objdict.c" 3 - )) -# 599 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)self_in); - mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - return self_in; -} - -mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key) { - mp_obj_t args[2] = {self_in, key}; - dict_get_helper(2, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); - return self_in; -} - -mp_map_t *mp_obj_dict_get_map(mp_obj_t self_in) { - -# 612 "user/mpy/py/objdict.c" 3 - (( -# 612 "user/mpy/py/objdict.c" - (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new) -# 612 "user/mpy/py/objdict.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objdict.c", 612, __func__, -# 612 "user/mpy/py/objdict.c" - "(MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->make_new == dict_make_new)" -# 612 "user/mpy/py/objdict.c" 3 - )) -# 612 "user/mpy/py/objdict.c" - ; - mp_obj_dict_t *self = ((void*)self_in); - return &self->map; -} -# 1 "user/mpy/py/objenumerate.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objenumerate.c" -# 27 "user/mpy/py/objenumerate.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objenumerate.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objenumerate.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objenumerate.c" 2 -# 1 "user/mpy/py/objexcept.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objexcept.c" -# 27 "user/mpy/py/objexcept.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objexcept.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 29 "user/mpy/py/objexcept.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objexcept.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 61 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 31 "user/mpy/py/objexcept.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 33 "user/mpy/py/objexcept.c" 2 - -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 35 "user/mpy/py/objexcept.c" 2 - -# 1 "user/mpy/py/objtype.h" 1 -# 33 "user/mpy/py/objtype.h" -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 37 "user/mpy/py/objexcept.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 38 "user/mpy/py/objexcept.c" 2 -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 39 "user/mpy/py/objexcept.c" 2 -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 40 "user/mpy/py/objexcept.c" 2 - - - -# 42 "user/mpy/py/objexcept.c" -const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, 0, 0, -# 42 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 42 "user/mpy/py/objexcept.c" - , (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; -# 92 "user/mpy/py/objexcept.c" -const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, -# 92 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 92 "user/mpy/py/objexcept.c" - , (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; - -static void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_exception_t *o = ((void*)o_in); - mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; - -# 97 "user/mpy/py/objexcept.c" 3 4 - _Bool -# 97 "user/mpy/py/objexcept.c" - is_subclass = kind & PRINT_EXC_SUBCLASS; - if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) { - mp_print_str(print, qstr_str(o->base.type->name)); - } - - if (k == PRINT_EXC) { - mp_print_str(print, ": "); - } - - if (k == PRINT_STR || k == PRINT_EXC) { - if (o->args == -# 107 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 107 "user/mpy/py/objexcept.c" - || o->args->len == 0) { - mp_print_str(print, ""); - return; - } else if (o->args->len == 1) { -# 121 "user/mpy/py/objexcept.c" - mp_obj_print_helper(print, o->args->items[0], PRINT_STR); - return; - } - } - mp_obj_tuple_print(print, ((mp_obj_t)o->args), kind); -} - -mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, (0xffff), -# 129 "user/mpy/py/objexcept.c" 3 4 - 0 -# 129 "user/mpy/py/objexcept.c" - ); - mp_obj_exception_t *o = ((mp_obj_exception_t*)m_malloc_maybe(sizeof(mp_obj_exception_t) + sizeof(mp_obj_t) * (0))); - if (o == -# 131 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 131 "user/mpy/py/objexcept.c" - ) { - - o = &(mp_state_ctx.vm.mp_emergency_exception_obj); - - o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; - } else { - o->args = ((void*)mp_obj_new_tuple(n_args, args)); - } - o->base.type = type; - o->traceback_data = -# 140 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 140 "user/mpy/py/objexcept.c" - ; - return ((mp_obj_t)o); -} - - -mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) { - mp_obj_exception_t *self = ((void*)self_in); - if (self->args->len == 0) { - return (((mp_obj_t)&mp_const_none_obj)); - } else { - return self->args->items[0]; - } -} - -static void exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - mp_obj_exception_t *self = ((void*)self_in); - if (dest[0] != (((mp_obj_t)(void*)0))) { - - if (attr == MP_QSTR___traceback__ && dest[1] == (((mp_obj_t)&mp_const_none_obj))) { - - - - - - - self->traceback_len = 0; - dest[0] = (((mp_obj_t)(void*)0)); - } - return; - } - if (attr == MP_QSTR_args) { - dest[0] = ((mp_obj_t)self->args); - } else if (self->base.type == &mp_type_StopIteration && attr == MP_QSTR_value) { - dest[0] = mp_obj_exception_get_value(self_in); - } -} - -static mp_obj_t exc___init__(size_t n_args, const mp_obj_t *args) { - mp_obj_exception_t *self = ((void*)args[0]); - mp_obj_t argst = mp_obj_new_tuple(n_args - 1, args + 1); - self->args = ((void*)argst); - return (((mp_obj_t)&mp_const_none_obj)); -} -static const mp_obj_fun_builtin_var_t exc___init___obj = {{&mp_type_fun_builtin_var}, -# 183 "user/mpy/py/objexcept.c" 3 4 - 0 -# 183 "user/mpy/py/objexcept.c" - , 1, (0xffff), .fun.var = exc___init__}; - -static const mp_rom_map_elem_t exc_locals_dict_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___init__)) << 2) | 2)), (&exc___init___obj) }, -}; - -static const mp_obj_dict_t exc_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(exc_locals_dict_table) / sizeof((exc_locals_dict_table)[0])), .alloc = (sizeof(exc_locals_dict_table) / sizeof((exc_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)exc_locals_dict_table, }, }; - -const mp_obj_type_t mp_type_BaseException = { - { &mp_type_type }, - .name = MP_QSTR_BaseException, - .print = mp_obj_exception_print, - .make_new = mp_obj_exception_make_new, - .attr = exception_attr, - .locals_dict = (mp_obj_dict_t*)&exc_locals_dict, -}; -# 212 "user/mpy/py/objexcept.c" -const mp_obj_type_t mp_type_SystemExit = { { &mp_type_type }, .name = MP_QSTR_SystemExit, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; -const mp_obj_type_t mp_type_KeyboardInterrupt = { { &mp_type_type }, .name = MP_QSTR_KeyboardInterrupt, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; -const mp_obj_type_t mp_type_GeneratorExit = { { &mp_type_type }, .name = MP_QSTR_GeneratorExit, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; -const mp_obj_type_t mp_type_Exception = { { &mp_type_type }, .name = MP_QSTR_Exception, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_BaseException, }; - - - - const mp_obj_type_t mp_type_StopIteration = { { &mp_type_type }, .name = MP_QSTR_StopIteration, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_ArithmeticError = { { &mp_type_type }, .name = MP_QSTR_ArithmeticError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - - const mp_obj_type_t mp_type_OverflowError = { { &mp_type_type }, .name = MP_QSTR_OverflowError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_ArithmeticError, }; - const mp_obj_type_t mp_type_ZeroDivisionError = { { &mp_type_type }, .name = MP_QSTR_ZeroDivisionError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_ArithmeticError, }; - const mp_obj_type_t mp_type_AssertionError = { { &mp_type_type }, .name = MP_QSTR_AssertionError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_AttributeError = { { &mp_type_type }, .name = MP_QSTR_AttributeError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - - - const mp_obj_type_t mp_type_EOFError = { { &mp_type_type }, .name = MP_QSTR_EOFError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_ImportError = { { &mp_type_type }, .name = MP_QSTR_ImportError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - - const mp_obj_type_t mp_type_LookupError = { { &mp_type_type }, .name = MP_QSTR_LookupError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_IndexError = { { &mp_type_type }, .name = MP_QSTR_IndexError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_LookupError, }; - const mp_obj_type_t mp_type_KeyError = { { &mp_type_type }, .name = MP_QSTR_KeyError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_LookupError, }; - const mp_obj_type_t mp_type_MemoryError = { { &mp_type_type }, .name = MP_QSTR_MemoryError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_NameError = { { &mp_type_type }, .name = MP_QSTR_NameError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - - - - const mp_obj_type_t mp_type_OSError = { { &mp_type_type }, .name = MP_QSTR_OSError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; -# 260 "user/mpy/py/objexcept.c" - const mp_obj_type_t mp_type_RuntimeError = { { &mp_type_type }, .name = MP_QSTR_RuntimeError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_NotImplementedError = { { &mp_type_type }, .name = MP_QSTR_NotImplementedError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_RuntimeError, }; - const mp_obj_type_t mp_type_SyntaxError = { { &mp_type_type }, .name = MP_QSTR_SyntaxError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - const mp_obj_type_t mp_type_IndentationError = { { &mp_type_type }, .name = MP_QSTR_IndentationError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_SyntaxError, }; - - - - - const mp_obj_type_t mp_type_TypeError = { { &mp_type_type }, .name = MP_QSTR_TypeError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; - - - - const mp_obj_type_t mp_type_ValueError = { { &mp_type_type }, .name = MP_QSTR_ValueError, .print = mp_obj_exception_print, .make_new = mp_obj_exception_make_new, .attr = exception_attr, .parent = &mp_type_Exception, }; -# 291 "user/mpy/py/objexcept.c" -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) { - return mp_obj_new_exception_args(exc_type, 0, -# 292 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 292 "user/mpy/py/objexcept.c" - ); -} - - -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { - return mp_obj_new_exception_args(exc_type, 1, &arg); -} - -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args) { - -# 301 "user/mpy/py/objexcept.c" 3 - (( -# 301 "user/mpy/py/objexcept.c" - exc_type->make_new == mp_obj_exception_make_new -# 301 "user/mpy/py/objexcept.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 301, __func__, -# 301 "user/mpy/py/objexcept.c" - "exc_type->make_new == mp_obj_exception_make_new" -# 301 "user/mpy/py/objexcept.c" 3 - )) -# 301 "user/mpy/py/objexcept.c" - ; - return exc_type->make_new(exc_type, n_args, 0, args); -} - -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg) { - return mp_obj_new_exception_msg_varg(exc_type, msg); -} - -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...) { - - -# 311 "user/mpy/py/objexcept.c" 3 - (( -# 311 "user/mpy/py/objexcept.c" - exc_type->make_new == mp_obj_exception_make_new -# 311 "user/mpy/py/objexcept.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 311, __func__, -# 311 "user/mpy/py/objexcept.c" - "exc_type->make_new == mp_obj_exception_make_new" -# 311 "user/mpy/py/objexcept.c" 3 - )) -# 311 "user/mpy/py/objexcept.c" - ; - - - mp_obj_exception_t *o = ((mp_obj_exception_t*)m_malloc_maybe(sizeof(mp_obj_exception_t) + sizeof(mp_obj_t) * (0))); - if (o == -# 315 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 315 "user/mpy/py/objexcept.c" - ) { - - - o = &(mp_state_ctx.vm.mp_emergency_exception_obj); - o->base.type = exc_type; - o->traceback_data = -# 320 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 320 "user/mpy/py/objexcept.c" - ; - o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; -# 366 "user/mpy/py/objexcept.c" - } else { - o->base.type = exc_type; - o->traceback_data = -# 368 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 368 "user/mpy/py/objexcept.c" - ; - o->args = ((void*)mp_obj_new_tuple(1, -# 369 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 369 "user/mpy/py/objexcept.c" - )); - - -# 371 "user/mpy/py/objexcept.c" 3 - (( -# 371 "user/mpy/py/objexcept.c" - fmt != -# 371 "user/mpy/py/objexcept.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 371, __func__, -# 371 "user/mpy/py/objexcept.c" - "fmt != NULL" -# 371 "user/mpy/py/objexcept.c" 3 - )) -# 371 "user/mpy/py/objexcept.c" - ; - { - if (strchr(fmt, '%') == -# 373 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 373 "user/mpy/py/objexcept.c" - ) { - - o->args->items[0] = mp_obj_new_str(fmt, strlen(fmt), -# 375 "user/mpy/py/objexcept.c" 3 4 - 0 -# 375 "user/mpy/py/objexcept.c" - ); - } else { - - va_list ap; - vstr_t vstr; - vstr_init(&vstr, 16); - -# 381 "user/mpy/py/objexcept.c" 3 4 - __builtin_va_start( -# 381 "user/mpy/py/objexcept.c" - ap -# 381 "user/mpy/py/objexcept.c" 3 4 - , -# 381 "user/mpy/py/objexcept.c" - fmt -# 381 "user/mpy/py/objexcept.c" 3 4 - ) -# 381 "user/mpy/py/objexcept.c" - ; - vstr_vprintf(&vstr, fmt, ap); - -# 383 "user/mpy/py/objexcept.c" 3 4 - __builtin_va_end( -# 383 "user/mpy/py/objexcept.c" - ap -# 383 "user/mpy/py/objexcept.c" 3 4 - ) -# 383 "user/mpy/py/objexcept.c" - ; - o->args->items[0] = mp_obj_new_str_from_vstr(&mp_type_str, &vstr); - } - } - } - - return ((mp_obj_t)o); -} - - - -# 393 "user/mpy/py/objexcept.c" 3 4 -_Bool -# 393 "user/mpy/py/objexcept.c" - mp_obj_is_exception_type(mp_obj_t self_in) { - if ((MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_type)))) { - - mp_obj_type_t *self = ((void*)self_in); - if (self->make_new == mp_obj_exception_make_new) { - return -# 398 "user/mpy/py/objexcept.c" 3 4 - 1 -# 398 "user/mpy/py/objexcept.c" - ; - } - } - return mp_obj_is_subclass_fast(self_in, ((mp_obj_t)&mp_type_BaseException)); -} - - - -# 405 "user/mpy/py/objexcept.c" 3 4 -_Bool -# 405 "user/mpy/py/objexcept.c" - mp_obj_is_exception_instance(mp_obj_t self_in) { - return mp_obj_is_exception_type(((mp_obj_t)mp_obj_get_type(self_in))); -} - - - - - -# 412 "user/mpy/py/objexcept.c" 3 4 -_Bool -# 412 "user/mpy/py/objexcept.c" - mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { - - if (mp_obj_is_exception_instance(exc)) { - exc = ((mp_obj_t)mp_obj_get_type(exc)); - } - return mp_obj_is_subclass_fast(exc, exc_type); -} -# 432 "user/mpy/py/objexcept.c" -void mp_obj_exception_clear_traceback(mp_obj_t self_in) { - -# 433 "user/mpy/py/objexcept.c" 3 - (( -# 433 "user/mpy/py/objexcept.c" - mp_obj_is_exception_instance(self_in) -# 433 "user/mpy/py/objexcept.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 433, __func__, -# 433 "user/mpy/py/objexcept.c" - "mp_obj_is_exception_instance(self_in)" -# 433 "user/mpy/py/objexcept.c" 3 - )) -# 433 "user/mpy/py/objexcept.c" - ; mp_obj_exception_t *self; if ((mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new)) { self = ((void*)self_in); } else { self = ((void*)((mp_obj_instance_t*)((void*)self_in))->subobj[0]); }; - - - self->traceback_data = -# 436 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 436 "user/mpy/py/objexcept.c" - ; -} - -void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { - -# 440 "user/mpy/py/objexcept.c" 3 - (( -# 440 "user/mpy/py/objexcept.c" - mp_obj_is_exception_instance(self_in) -# 440 "user/mpy/py/objexcept.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 440, __func__, -# 440 "user/mpy/py/objexcept.c" - "mp_obj_is_exception_instance(self_in)" -# 440 "user/mpy/py/objexcept.c" 3 - )) -# 440 "user/mpy/py/objexcept.c" - ; mp_obj_exception_t *self; if ((mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new)) { self = ((void*)self_in); } else { self = ((void*)((mp_obj_instance_t*)((void*)self_in))->subobj[0]); }; - - - - - if (self->traceback_data == -# 445 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 445 "user/mpy/py/objexcept.c" - ) { - self->traceback_data = ((size_t*)(m_malloc_maybe(sizeof(size_t) * (3)))); - if (self->traceback_data == -# 447 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 447 "user/mpy/py/objexcept.c" - ) { - return; - } - self->traceback_alloc = 3; - self->traceback_len = 0; - } else if (self->traceback_len + 3 > self->traceback_alloc) { - - size_t *tb_data = ((size_t*)(m_realloc_maybe((self->traceback_data), sizeof(size_t) * (self->traceback_alloc + 3), ( -# 454 "user/mpy/py/objexcept.c" 3 4 - 1 -# 454 "user/mpy/py/objexcept.c" - )))); - if (tb_data == -# 455 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 455 "user/mpy/py/objexcept.c" - ) { - return; - } - self->traceback_data = tb_data; - self->traceback_alloc += 3; - } - - size_t *tb_data = &self->traceback_data[self->traceback_len]; - self->traceback_len += 3; - tb_data[0] = file; - tb_data[1] = line; - tb_data[2] = block; -} - -void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values) { - -# 470 "user/mpy/py/objexcept.c" 3 - (( -# 470 "user/mpy/py/objexcept.c" - mp_obj_is_exception_instance(self_in) -# 470 "user/mpy/py/objexcept.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objexcept.c", 470, __func__, -# 470 "user/mpy/py/objexcept.c" - "mp_obj_is_exception_instance(self_in)" -# 470 "user/mpy/py/objexcept.c" 3 - )) -# 470 "user/mpy/py/objexcept.c" - ; mp_obj_exception_t *self; if ((mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new)) { self = ((void*)self_in); } else { self = ((void*)((mp_obj_instance_t*)((void*)self_in))->subobj[0]); }; - - if (self->traceback_data == -# 472 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 472 "user/mpy/py/objexcept.c" - ) { - *n = 0; - *values = -# 474 "user/mpy/py/objexcept.c" 3 4 - ((void *)0) -# 474 "user/mpy/py/objexcept.c" - ; - } else { - *n = self->traceback_len; - *values = self->traceback_data; - } -} -# 1 "user/mpy/py/objfilter.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objfilter.c" -# 27 "user/mpy/py/objfilter.c" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 28 "user/mpy/py/objfilter.c" 2 -# 1 "user/mpy/py/objfloat.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objfloat.c" -# 27 "user/mpy/py/objfloat.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objfloat.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 61 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/objfloat.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/objfloat.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/objfloat.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 33 "user/mpy/py/objfloat.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 32 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 34 "user/mpy/py/objfloat.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/objfloat.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 36 "user/mpy/py/objfloat.c" 2 -# 1 "user/mpy/py/objfun.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objfun.c" -# 28 "user/mpy/py/objfun.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/objfun.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objfun.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objfun.c" 2 -# 1 "user/mpy/py/objtuple.h" 1 -# 29 "user/mpy/py/objtuple.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtuple.h" 2 - -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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 33 "user/mpy/py/objfun.c" 2 -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 34 "user/mpy/py/objfun.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/objfun.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 32 "user/mpy/py/objexcept.h" -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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 36 "user/mpy/py/objfun.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 37 "user/mpy/py/objfun.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 38 "user/mpy/py/objfun.c" 2 -# 53 "user/mpy/py/objfun.c" -static mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)args; - -# 55 "user/mpy/py/objfun.c" 3 - (( -# 55 "user/mpy/py/objfun.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_0))) -# 55 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 55, __func__, -# 55 "user/mpy/py/objfun.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_0)" -# 55 "user/mpy/py/objfun.c" 3 - )) -# 55 "user/mpy/py/objfun.c" - ; - mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); - mp_arg_check_num(n_args, n_kw, 0, 0, -# 57 "user/mpy/py/objfun.c" 3 4 - 0 -# 57 "user/mpy/py/objfun.c" - ); - return self->fun._0(); -} - -const mp_obj_type_t mp_type_fun_builtin_0 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_0_call, - .unary_op = mp_generic_unary_op, -}; - -static mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - -# 69 "user/mpy/py/objfun.c" 3 - (( -# 69 "user/mpy/py/objfun.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_1))) -# 69 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 69, __func__, -# 69 "user/mpy/py/objfun.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_1)" -# 69 "user/mpy/py/objfun.c" 3 - )) -# 69 "user/mpy/py/objfun.c" - ; - mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); - mp_arg_check_num(n_args, n_kw, 1, 1, -# 71 "user/mpy/py/objfun.c" 3 4 - 0 -# 71 "user/mpy/py/objfun.c" - ); - return self->fun._1(args[0]); -} - -const mp_obj_type_t mp_type_fun_builtin_1 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_1_call, - .unary_op = mp_generic_unary_op, -}; - -static mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - -# 83 "user/mpy/py/objfun.c" 3 - (( -# 83 "user/mpy/py/objfun.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_2))) -# 83 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 83, __func__, -# 83 "user/mpy/py/objfun.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_2)" -# 83 "user/mpy/py/objfun.c" 3 - )) -# 83 "user/mpy/py/objfun.c" - ; - mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); - mp_arg_check_num(n_args, n_kw, 2, 2, -# 85 "user/mpy/py/objfun.c" 3 4 - 0 -# 85 "user/mpy/py/objfun.c" - ); - return self->fun._2(args[0], args[1]); -} - -const mp_obj_type_t mp_type_fun_builtin_2 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_2_call, - .unary_op = mp_generic_unary_op, -}; - -static mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - -# 97 "user/mpy/py/objfun.c" 3 - (( -# 97 "user/mpy/py/objfun.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_3))) -# 97 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 97, __func__, -# 97 "user/mpy/py/objfun.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_3)" -# 97 "user/mpy/py/objfun.c" 3 - )) -# 97 "user/mpy/py/objfun.c" - ; - mp_obj_fun_builtin_fixed_t *self = ((void*)self_in); - mp_arg_check_num(n_args, n_kw, 3, 3, -# 99 "user/mpy/py/objfun.c" 3 4 - 0 -# 99 "user/mpy/py/objfun.c" - ); - return self->fun._3(args[0], args[1], args[2]); -} - -const mp_obj_type_t mp_type_fun_builtin_3 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_3_call, - .unary_op = mp_generic_unary_op, -}; - -static mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - -# 111 "user/mpy/py/objfun.c" 3 - (( -# 111 "user/mpy/py/objfun.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_fun_builtin_var))) -# 111 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 111, __func__, -# 111 "user/mpy/py/objfun.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_var)" -# 111 "user/mpy/py/objfun.c" 3 - )) -# 111 "user/mpy/py/objfun.c" - ; - mp_obj_fun_builtin_var_t *self = ((void*)self_in); - - - mp_arg_check_num(n_args, n_kw, self->n_args_min, self->n_args_max, self->is_kw); - - if (self->is_kw) { - - - - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); - - return self->fun.kw(n_args, args, &kw_args); - - } else { - - - return self->fun.var(n_args, args); - } -} - -const mp_obj_type_t mp_type_fun_builtin_var = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_var_call, - .unary_op = mp_generic_unary_op, -}; - - - - -qstr mp_obj_code_get_name(const byte *code_info) { - code_info = mp_decode_uint_skip(code_info); - - return code_info[0] | (code_info[1] << 8); - - - -} - - - - - -qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) { - const mp_obj_fun_bc_t *fun = ((void*)fun_in); - - - - - - - - const byte *bc = fun->bytecode; - bc = mp_decode_uint_skip(bc); - bc = mp_decode_uint_skip(bc); - bc++; - bc++; - bc++; - bc++; - return mp_obj_code_get_name(bc); -} -# 232 "user/mpy/py/objfun.c" -static mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - ; - - (void)0; - (void)0; - (void)0; - (void)0; - (void)0; - mp_obj_fun_bc_t *self = ((void*)self_in); - (void)0; - - - size_t n_state = mp_decode_uint_value(self->bytecode); - size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode)); - - - - - - - size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t); - mp_code_state_t *code_state = -# 253 "user/mpy/py/objfun.c" 3 4 - ((void *)0) -# 253 "user/mpy/py/objfun.c" - ; - if (state_size > (11 * sizeof(mp_uint_t))) { - code_state = ((mp_code_state_t*)m_malloc_maybe(sizeof(mp_code_state_t) + sizeof(byte) * (state_size))); - } - if (code_state == -# 257 "user/mpy/py/objfun.c" 3 4 - ((void *)0) -# 257 "user/mpy/py/objfun.c" - ) { - code_state = -# 258 "user/mpy/py/objfun.c" 3 - __builtin_alloca( -# 258 "user/mpy/py/objfun.c" - sizeof(mp_code_state_t) + state_size -# 258 "user/mpy/py/objfun.c" 3 - ) -# 258 "user/mpy/py/objfun.c" - ; - state_size = 0; - } - - code_state->fun_bc = self; - code_state->ip = 0; - mp_setup_code_state(code_state, n_args, n_kw, args); - - - code_state->old_globals = mp_globals_get(); - mp_globals_set(self->globals); - mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode(code_state, (((mp_obj_t)(void*)0))); - mp_globals_set(code_state->old_globals); -# 298 "user/mpy/py/objfun.c" - mp_obj_t result; - if (vm_return_kind == MP_VM_RETURN_NORMAL) { - - result = *code_state->sp; - } else { - - -# 304 "user/mpy/py/objfun.c" 3 - (( -# 304 "user/mpy/py/objfun.c" - vm_return_kind == MP_VM_RETURN_EXCEPTION -# 304 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 304, __func__, -# 304 "user/mpy/py/objfun.c" - "vm_return_kind == MP_VM_RETURN_EXCEPTION" -# 304 "user/mpy/py/objfun.c" 3 - )) -# 304 "user/mpy/py/objfun.c" - ; - - result = code_state->state[n_state - 1]; - } - - - if (state_size != 0) { - ((void)(state_size), m_free(code_state)); - } - - if (vm_return_kind == MP_VM_RETURN_NORMAL) { - return result; - } else { - nlr_jump(((void*)result)); - } -} -# 333 "user/mpy/py/objfun.c" -const mp_obj_type_t mp_type_fun_bc = { - { &mp_type_type }, - .name = MP_QSTR_function, - - - - .call = fun_bc_call, - .unary_op = mp_generic_unary_op, - - - -}; - -mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) { - size_t n_def_args = 0; - size_t n_extra_args = 0; - mp_obj_tuple_t *def_args = ((void*)def_args_in); - if (def_args_in != (((mp_obj_t)(void*)0))) { - -# 351 "user/mpy/py/objfun.c" 3 - (( -# 351 "user/mpy/py/objfun.c" - (MP_OBJ_IS_OBJ(def_args_in) && (((mp_obj_base_t*)((void*)def_args_in))->type == (&mp_type_tuple))) -# 351 "user/mpy/py/objfun.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objfun.c", 351, __func__, -# 351 "user/mpy/py/objfun.c" - "MP_OBJ_IS_TYPE(def_args_in, &mp_type_tuple)" -# 351 "user/mpy/py/objfun.c" 3 - )) -# 351 "user/mpy/py/objfun.c" - ; - n_def_args = def_args->len; - n_extra_args = def_args->len; - } - if (def_kw_args != (((mp_obj_t)(void*)0))) { - n_extra_args += 1; - } - mp_obj_fun_bc_t *o = ((mp_obj_fun_bc_t*)m_malloc(sizeof(mp_obj_fun_bc_t) + sizeof(mp_obj_t) * (n_extra_args))); - o->base.type = &mp_type_fun_bc; - o->globals = mp_globals_get(); - o->bytecode = code; - o->const_table = const_table; - if (def_args != -# 363 "user/mpy/py/objfun.c" 3 4 - ((void *)0) -# 363 "user/mpy/py/objfun.c" - ) { - memcpy(o->extra_args, def_args->items, n_def_args * sizeof(mp_obj_t)); - } - if (def_kw_args != (((mp_obj_t)(void*)0))) { - o->extra_args[n_def_args] = def_kw_args; - } - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objgenerator.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objgenerator.c" -# 28 "user/mpy/py/objgenerator.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 29 "user/mpy/py/objgenerator.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objgenerator.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objgenerator.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 33 "user/mpy/py/objgenerator.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/objgenerator.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 31 "user/mpy/py/bc.h" -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 35 "user/mpy/py/objgenerator.c" 2 -# 1 "user/mpy/py/objgenerator.h" 1 -# 32 "user/mpy/py/objgenerator.h" -mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); -# 36 "user/mpy/py/objgenerator.c" 2 - - - - - -typedef struct _mp_obj_gen_wrap_t { - mp_obj_base_t base; - mp_obj_t *fun; -} mp_obj_gen_wrap_t; - -typedef struct _mp_obj_gen_instance_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - mp_code_state_t code_state; -} mp_obj_gen_instance_t; - -static mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_gen_wrap_t *self = ((void*)self_in); - mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun; - -# 55 "user/mpy/py/objgenerator.c" 3 - (( -# 55 "user/mpy/py/objgenerator.c" - self_fun->base.type == &mp_type_fun_bc -# 55 "user/mpy/py/objgenerator.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objgenerator.c", 55, __func__, -# 55 "user/mpy/py/objgenerator.c" - "self_fun->base.type == &mp_type_fun_bc" -# 55 "user/mpy/py/objgenerator.c" 3 - )) -# 55 "user/mpy/py/objgenerator.c" - ; - - - size_t n_state = mp_decode_uint_value(self_fun->bytecode); - size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode)); - - - mp_obj_gen_instance_t *o = ((mp_obj_gen_instance_t*)m_malloc(sizeof(mp_obj_gen_instance_t) + sizeof(byte) * (n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t)))) - ; - o->base.type = &mp_type_gen_instance; - - o->globals = self_fun->globals; - o->code_state.fun_bc = self_fun; - o->code_state.ip = 0; - mp_setup_code_state(&o->code_state, n_args, n_kw, args); - return ((mp_obj_t)o); -} - -const mp_obj_type_t mp_type_gen_wrap = { - { &mp_type_type }, - .name = MP_QSTR_generator, - .call = gen_wrap_call, - .unary_op = mp_generic_unary_op, -}; - -mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) { - mp_obj_gen_wrap_t *o = (((mp_obj_gen_wrap_t*)(m_malloc(sizeof(mp_obj_gen_wrap_t) * (1))))); - o->base.type = &mp_type_gen_wrap; - o->fun = ((void*)fun); - return ((mp_obj_t)o); -} - - - - -static void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_gen_instance_t *self = ((void*)self_in); - mp_printf(print, "", mp_obj_fun_get_name(((mp_obj_t)self->code_state.fun_bc)), self); -} - -mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) { - -# 97 "user/mpy/py/objgenerator.c" 3 - (( -# 97 "user/mpy/py/objgenerator.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_gen_instance))) -# 97 "user/mpy/py/objgenerator.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objgenerator.c", 97, __func__, -# 97 "user/mpy/py/objgenerator.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_gen_instance)))" -# 97 "user/mpy/py/objgenerator.c" 3 - )) -# 97 "user/mpy/py/objgenerator.c" - ; - mp_obj_gen_instance_t *self = ((void*)self_in); - if (self->code_state.ip == 0) { - - *ret_val = (((mp_obj_t)(void*)4)); - return MP_VM_RETURN_NORMAL; - } - if (self->code_state.sp == self->code_state.state - 1) { - if (send_value != (((mp_obj_t)&mp_const_none_obj))) { - mp_raise_TypeError("can't send non-None value to a just-started generator"); - } - } else { - *self->code_state.sp = send_value; - } - mp_obj_dict_t *old_globals = mp_globals_get(); - mp_globals_set(self->globals); - mp_vm_return_kind_t ret_kind = mp_execute_bytecode(&self->code_state, throw_value); - mp_globals_set(old_globals); - - switch (ret_kind) { - case MP_VM_RETURN_NORMAL: - default: - - - - - - self->code_state.ip = 0; - *ret_val = *self->code_state.sp; - break; - - case MP_VM_RETURN_YIELD: - *ret_val = *self->code_state.sp; - if (*ret_val == (((mp_obj_t)(void*)4))) { - self->code_state.ip = 0; - } - break; - - case MP_VM_RETURN_EXCEPTION: { - size_t n_state = mp_decode_uint_value(self->code_state.fun_bc->bytecode); - self->code_state.ip = 0; - *ret_val = self->code_state.state[n_state - 1]; - break; - } - } - - return ret_kind; -} - -static mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value) { - mp_obj_t ret; - switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) { - case MP_VM_RETURN_NORMAL: - default: - - if (ret == (((mp_obj_t)&mp_const_none_obj)) || ret == (((mp_obj_t)(void*)4))) { - return (((mp_obj_t)(void*)4)); - } else { - nlr_jump(((void*)mp_obj_new_exception_args(&mp_type_StopIteration, 1, &ret))); - } - - case MP_VM_RETURN_YIELD: - return ret; - - case MP_VM_RETURN_EXCEPTION: - - - - if (mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(ret)), ((mp_obj_t)&mp_type_StopIteration))) { - mp_obj_t val = mp_obj_exception_get_value(ret); - if (val == (((mp_obj_t)&mp_const_none_obj))) { - return (((mp_obj_t)(void*)4)); - } - } - nlr_jump(((void*)ret)); - } -} - -static mp_obj_t gen_instance_iternext(mp_obj_t self_in) { - return gen_resume_and_raise(self_in, (((mp_obj_t)&mp_const_none_obj)), (((mp_obj_t)(void*)0))); -} - -static mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) { - mp_obj_t ret = gen_resume_and_raise(self_in, send_value, (((mp_obj_t)(void*)0))); - if (ret == (((mp_obj_t)(void*)4))) { - nlr_jump(((void*)mp_obj_new_exception(&mp_type_StopIteration))); - } else { - return ret; - } -} - -static const mp_obj_fun_builtin_fixed_t gen_instance_send_obj = {{&mp_type_fun_builtin_2}, .fun._2 = gen_instance_send}; - -static mp_obj_t gen_instance_close(mp_obj_t self_in); -static mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) { - mp_obj_t exc = (n_args == 2) ? args[1] : args[2]; - - mp_obj_t ret = gen_resume_and_raise(args[0], (((mp_obj_t)&mp_const_none_obj)), exc); - if (ret == (((mp_obj_t)(void*)4))) { - nlr_jump(((void*)mp_obj_new_exception(&mp_type_StopIteration))); - } else { - return ret; - } -} - -static const mp_obj_fun_builtin_var_t gen_instance_throw_obj = {{&mp_type_fun_builtin_var}, -# 202 "user/mpy/py/objgenerator.c" 3 4 - 0 -# 202 "user/mpy/py/objgenerator.c" - , 2, 4, .fun.var = gen_instance_throw}; - -static mp_obj_t gen_instance_close(mp_obj_t self_in) { - mp_obj_t ret; - switch (mp_obj_gen_resume(self_in, (((mp_obj_t)&mp_const_none_obj)), ((mp_obj_t)&mp_const_GeneratorExit_obj), &ret)) { - case MP_VM_RETURN_YIELD: - mp_raise_msg(&mp_type_RuntimeError, "generator ignored GeneratorExit"); - - - case MP_VM_RETURN_EXCEPTION: - - if (mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(ret)), ((mp_obj_t)&mp_type_GeneratorExit)) || - mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(ret)), ((mp_obj_t)&mp_type_StopIteration))) { - return (((mp_obj_t)&mp_const_none_obj)); - } - nlr_jump(((void*)ret)); - - default: - - return (((mp_obj_t)&mp_const_none_obj)); - } -} - -static const mp_obj_fun_builtin_fixed_t gen_instance_close_obj = {{&mp_type_fun_builtin_1}, .fun._1 = gen_instance_close}; - -static const mp_rom_map_elem_t gen_instance_locals_dict_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_close)) << 2) | 2)), (&gen_instance_close_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_send)) << 2) | 2)), (&gen_instance_send_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_throw)) << 2) | 2)), (&gen_instance_throw_obj) }, -}; - -static const mp_obj_dict_t gen_instance_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(gen_instance_locals_dict_table) / sizeof((gen_instance_locals_dict_table)[0])), .alloc = (sizeof(gen_instance_locals_dict_table) / sizeof((gen_instance_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)gen_instance_locals_dict_table, }, }; - -const mp_obj_type_t mp_type_gen_instance = { - { &mp_type_type }, - .name = MP_QSTR_generator, - .print = gen_instance_print, - .unary_op = mp_generic_unary_op, - .getiter = mp_identity_getiter, - .iternext = gen_instance_iternext, - .locals_dict = (mp_obj_dict_t*)&gen_instance_locals_dict, -}; -# 1 "user/mpy/py/objgetitemiter.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objgetitemiter.c" -# 27 "user/mpy/py/objgetitemiter.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objgetitemiter.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 30 "user/mpy/py/objgetitemiter.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objgetitemiter.c" 2 - - - -typedef struct _mp_obj_getitem_iter_t { - mp_obj_base_t base; - mp_obj_t args[3]; -} mp_obj_getitem_iter_t; - -static mp_obj_t it_iternext(mp_obj_t self_in) { - mp_obj_getitem_iter_t *self = ((void*)self_in); - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - - mp_obj_t value = mp_call_method_n_kw(1, 0, self->args); - self->args[2] = ((mp_obj_t)((((mp_uint_t)((((mp_int_t)(self->args[2])) >> 1) + 1)) << 1) | 1)); - nlr_pop(); - return value; - } else { - - mp_obj_type_t *t = (mp_obj_type_t*)((mp_obj_base_t*)nlr.ret_val)->type; - if (t == &mp_type_StopIteration || t == &mp_type_IndexError) { - - return (((mp_obj_t)(void*)4)); - } else { - - nlr_jump(nlr.ret_val); - } - } -} - -static const mp_obj_type_t it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = it_iternext, -}; - - -mp_obj_t mp_obj_new_getitem_iter(mp_obj_t *args, mp_obj_iter_buf_t *iter_buf) { - -# 70 "user/mpy/py/objgetitemiter.c" 3 - (( -# 70 "user/mpy/py/objgetitemiter.c" - sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t) -# 70 "user/mpy/py/objgetitemiter.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objgetitemiter.c", 70, __func__, -# 70 "user/mpy/py/objgetitemiter.c" - "sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t)" -# 70 "user/mpy/py/objgetitemiter.c" 3 - )) -# 70 "user/mpy/py/objgetitemiter.c" - ; - mp_obj_getitem_iter_t *o = (mp_obj_getitem_iter_t*)iter_buf; - o->base.type = &it_type; - o->args[0] = args[0]; - o->args[1] = args[1]; - o->args[2] = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objint.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objint.c" -# 27 "user/mpy/py/objint.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objint.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objint.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/objint.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 32 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 33 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 34 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 - - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 35 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 36 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 37 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 38 "user/mpy/py/objint.c" 2 -# 1 "user/mpy/py/binary.h" 1 -# 35 "user/mpy/py/binary.h" -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 39 "user/mpy/py/objint.c" 2 - - - - - - -static mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 2, -# 47 "user/mpy/py/objint.c" 3 4 - 0 -# 47 "user/mpy/py/objint.c" - ); - - switch (n_args) { - case 0: - return ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); - - case 1: - if ((MP_OBJ_IS_SMALL_INT(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_int))))) { - - return args[0]; - } else if ((MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))) { - - size_t l; - const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_integer(s, l, 0, -# 61 "user/mpy/py/objint.c" 3 4 - ((void *)0) -# 61 "user/mpy/py/objint.c" - ); - - - - - } else { - - return ((mp_obj_t)((((mp_uint_t)(mp_obj_get_int(args[0]))) << 1) | 1)); - } - - case 2: - default: { - - - size_t l; - const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]), -# 77 "user/mpy/py/objint.c" 3 4 - ((void *)0) -# 77 "user/mpy/py/objint.c" - ); - } - } -} -# 175 "user/mpy/py/objint.c" -typedef mp_int_t fmt_int_t; -typedef mp_uint_t fmt_uint_t; - - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - - - char stack_buf[sizeof(fmt_int_t) * 4]; - char *buf = stack_buf; - size_t buf_size = sizeof(stack_buf); - size_t fmt_size; - - char *str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, self_in, 10, -# 188 "user/mpy/py/objint.c" 3 4 - ((void *)0) -# 188 "user/mpy/py/objint.c" - , '\0', '\0'); - mp_print_str(print, str); - - if (buf != stack_buf) { - ((void)(buf_size), m_free(buf)); - } -} - -static const uint8_t log_base2_floor[] = { - 0, 1, 1, 2, - 2, 2, 2, 3, - 3, 3, 3, 3, - 3, 3, 3, 4, - - - - - - -}; - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma) { - -# 210 "user/mpy/py/objint.c" 3 - (( -# 210 "user/mpy/py/objint.c" - 2 <= base && base <= 16 -# 210 "user/mpy/py/objint.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objint.c", 210, __func__, -# 210 "user/mpy/py/objint.c" - "2 <= base && base <= 16" -# 210 "user/mpy/py/objint.c" 3 - )) -# 210 "user/mpy/py/objint.c" - ; - size_t num_digits = num_bits / log_base2_floor[base - 1] + 1; - size_t num_commas = comma ? num_digits / 3 : 0; - size_t prefix_len = prefix ? strlen(prefix) : 0; - return num_digits + num_commas + prefix_len + 2; -} -# 224 "user/mpy/py/objint.c" -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma) { - fmt_int_t num; - if (MP_OBJ_IS_SMALL_INT(self_in)) { - - num = (((mp_int_t)(self_in)) >> 1); -# 242 "user/mpy/py/objint.c" - } else { - - **buf = '\0'; - *fmt_size = 0; - return *buf; - } - - char sign = '\0'; - if (num < 0) { - num = -num; - sign = '-'; - } - - size_t needed_size = mp_int_format_size(sizeof(fmt_int_t) * 8, base, prefix, comma); - if (needed_size > *buf_size) { - *buf = ((char*)(m_malloc(sizeof(char) * (needed_size)))); - *buf_size = needed_size; - } - char *str = *buf; - - char *b = str + needed_size; - *(--b) = '\0'; - char *last_comma = b; - - if (num == 0) { - *(--b) = '0'; - } else { - do { - - int c = (fmt_uint_t)num % base; - num = (fmt_uint_t)num / base; - if (c >= 10) { - c += base_char - 10; - } else { - c += '0'; - } - *(--b) = c; - if (comma && num != 0 && b > str && (last_comma - b) == 3) { - *(--b) = comma; - last_comma = b; - } - } - while (b > str && num != 0); - } - if (prefix) { - size_t prefix_len = strlen(prefix); - char *p = b - prefix_len; - if (p > str) { - b = p; - while (*prefix) { - *p++ = *prefix++; - } - } - } - if (sign && b > str) { - *(--b) = sign; - } - *fmt_size = *buf + needed_size - b - 1; - - return b; -} - - - -int mp_obj_int_sign(mp_obj_t self_in) { - mp_int_t val = mp_obj_get_int(self_in); - if (val < 0) { - return -1; - } else if (val > 0) { - return 1; - } else { - return 0; - } -} - - - -mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { - mp_int_t val = mp_obj_get_int(self_in); - if (val < 0) { - val = -val; - } - return ((mp_obj_t)((((mp_uint_t)(val)) << 1) | 1)); -} - - -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { - return (((mp_obj_t)(void*)0)); -} - - -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); -} - - -mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, -# 338 "user/mpy/py/objint.c" 3 4 - _Bool -# 338 "user/mpy/py/objint.c" - neg, unsigned int base) { - mp_raise_msg(&mp_type_OverflowError, "long int not supported in this build"); - return (((mp_obj_t)&mp_const_none_obj)); -} - - -mp_obj_t mp_obj_new_int_from_ll(long long val) { - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return (((mp_obj_t)&mp_const_none_obj)); -} - - -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return (((mp_obj_t)&mp_const_none_obj)); -} - -mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { - - - if ((value & ~~((((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1)) | ((((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1)) >> 1))) == 0) { - return ((mp_obj_t)((((mp_uint_t)(value)) << 1) | 1)); - } - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return (((mp_obj_t)&mp_const_none_obj)); -} - -mp_obj_t mp_obj_new_int(mp_int_t value) { - if (((((value) ^ ((value) << 1)) & (((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) == 0)) { - return ((mp_obj_t)((((mp_uint_t)(value)) << 1) | 1)); - } - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return (((mp_obj_t)&mp_const_none_obj)); -} - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { - return (((mp_int_t)(self_in)) >> 1); -} - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { - return (((mp_int_t)(self_in)) >> 1); -} - - - - - -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - if (rhs_in == (((mp_obj_t)&mp_const_false_obj))) { - - return mp_binary_op(op, lhs_in, ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1))); - } else if (rhs_in == (((mp_obj_t)&mp_const_true_obj))) { - - return mp_binary_op(op, lhs_in, ((mp_obj_t)((((mp_uint_t)(1)) << 1) | 1))); - } else if (op == MP_BINARY_OP_MULTIPLY) { - if ((MP_OBJ_IS_QSTR(rhs_in) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_str)))) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_bytes))) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_tuple))) || (MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_list)))) { - - return mp_binary_op(op, rhs_in, lhs_in); - } - } - return (((mp_obj_t)(void*)0)); -} - - -static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) { - - (void)n_args; - - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, (1)); - - const byte* buf = (const byte*)bufinfo.buf; - int delta = 1; - if (args[2] == ((mp_obj_t)((((mp_uint_t)(MP_QSTR_little)) << 2) | 2))) { - buf += bufinfo.len - 1; - delta = -1; - } - - mp_uint_t value = 0; - size_t len = bufinfo.len; - for (; len--; buf += delta) { - - - - - - - value = (value << 8) | *buf; - } - return mp_obj_new_int_from_uint(value); -} - -static const mp_obj_fun_builtin_var_t int_from_bytes_fun_obj = {{&mp_type_fun_builtin_var}, -# 431 "user/mpy/py/objint.c" 3 4 - 0 -# 431 "user/mpy/py/objint.c" - , 3, 4, .fun.var = int_from_bytes}; -static const mp_rom_obj_static_class_method_t int_from_bytes_obj = {{&mp_type_classmethod}, (&int_from_bytes_fun_obj)}; - -static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) { - - (void)n_args; - - mp_int_t len = mp_obj_get_int(args[1]); - if (len < 0) { - mp_raise_ValueError( -# 440 "user/mpy/py/objint.c" 3 4 - ((void *)0) -# 440 "user/mpy/py/objint.c" - ); - } - -# 442 "user/mpy/py/objint.c" 3 4 - _Bool -# 442 "user/mpy/py/objint.c" - big_endian = args[2] != ((mp_obj_t)((((mp_uint_t)(MP_QSTR_little)) << 2) | 2)); - - vstr_t vstr; - vstr_init_len(&vstr, len); - byte *data = (byte*)vstr.buf; - memset(data, 0, len); - - - - - - - { - mp_int_t val = (((mp_int_t)(args[0])) >> 1); - size_t l = (((size_t)len) < (sizeof(val)) ? ((size_t)len) : (sizeof(val))); - mp_binary_set_int(l, big_endian, data + (big_endian ? (len - l) : 0), val); - } - - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -static const mp_obj_fun_builtin_var_t int_to_bytes_obj = {{&mp_type_fun_builtin_var}, -# 462 "user/mpy/py/objint.c" 3 4 - 0 -# 462 "user/mpy/py/objint.c" - , 3, 4, .fun.var = int_to_bytes}; - -static const mp_rom_map_elem_t int_locals_dict_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_from_bytes)) << 2) | 2)), (&int_from_bytes_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_to_bytes)) << 2) | 2)), (&int_to_bytes_obj) }, -}; - -static const mp_obj_dict_t int_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(int_locals_dict_table) / sizeof((int_locals_dict_table)[0])), .alloc = (sizeof(int_locals_dict_table) / sizeof((int_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)int_locals_dict_table, }, }; - -const mp_obj_type_t mp_type_int = { - { &mp_type_type }, - .name = MP_QSTR_int, - .print = mp_obj_int_print, - .make_new = mp_obj_int_make_new, - .unary_op = mp_obj_int_unary_op, - .binary_op = mp_obj_int_binary_op, - .locals_dict = (mp_obj_dict_t*)&int_locals_dict, -}; -# 1 "user/mpy/py/objint_longlong.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objint_longlong.c" -# 28 "user/mpy/py/objint_longlong.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 29 "user/mpy/py/objint_longlong.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/objint_longlong.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objint_longlong.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 30 "user/mpy/py/smallint.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/smallint.h" 2 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 33 "user/mpy/py/objint_longlong.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 31 "user/mpy/py/objint.h" 2 - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 34 "user/mpy/py/objint_longlong.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/objint_longlong.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 36 "user/mpy/py/objint_longlong.c" 2 -# 1 "user/mpy/py/objint_mpz.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objint_mpz.c" -# 27 "user/mpy/py/objint_mpz.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objint_mpz.c" 2 -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 61 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/objint_mpz.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objint_mpz.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objint_mpz.c" 2 -# 1 "user/mpy/py/parsenumbase.h" 1 -# 31 "user/mpy/py/parsenumbase.h" -size_t mp_parse_num_base(const char *str, size_t len, int *base); -# 33 "user/mpy/py/objint_mpz.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 30 "user/mpy/py/smallint.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/smallint.h" 2 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 34 "user/mpy/py/objint_mpz.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 31 "user/mpy/py/objint.h" 2 - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 35 "user/mpy/py/objint_mpz.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 36 "user/mpy/py/objint_mpz.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/objint_mpz.c" 2 -# 1 "user/mpy/py/objlist.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objlist.c" -# 27 "user/mpy/py/objlist.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objlist.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objlist.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objlist.c" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 29 "user/mpy/py/objlist.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objlist.h" 2 - -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; -# 32 "user/mpy/py/objlist.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/objlist.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - - -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/objlist.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 35 "user/mpy/py/objlist.c" 2 - -static mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf); -static mp_obj_list_t *list_new(size_t n); -static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in); -static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); - - - - - - - -static void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_list_t *o = ((void*)o_in); - if (!((0) && kind == PRINT_JSON)) { - kind = PRINT_REPR; - } - mp_print_str(print, "["); - for (size_t i = 0; i < o->len; i++) { - if (i > 0) { - mp_print_str(print, ", "); - } - mp_obj_print_helper(print, o->items[i], kind); - } - mp_print_str(print, "]"); -} - -static mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) { - mp_obj_t iter = mp_getiter(iterable, -# 63 "user/mpy/py/objlist.c" 3 4 - ((void *)0) -# 63 "user/mpy/py/objlist.c" - ); - mp_obj_t item; - while ((item = mp_iternext(iter)) != (((mp_obj_t)(void*)4))) { - mp_obj_list_append(list, item); - } - return list; -} - -static mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 1, -# 73 "user/mpy/py/objlist.c" 3 4 - 0 -# 73 "user/mpy/py/objlist.c" - ); - - switch (n_args) { - case 0: - - return mp_obj_new_list(0, -# 78 "user/mpy/py/objlist.c" 3 4 - ((void *)0) -# 78 "user/mpy/py/objlist.c" - ); - - case 1: - default: { - - - mp_obj_t list = mp_obj_new_list(0, -# 84 "user/mpy/py/objlist.c" 3 4 - ((void *)0) -# 84 "user/mpy/py/objlist.c" - ); - return list_extend_from_iter(list, args[0]); - } - } -} - - -static -# 91 "user/mpy/py/objlist.c" 3 4 - _Bool -# 91 "user/mpy/py/objlist.c" - list_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { - -# 92 "user/mpy/py/objlist.c" 3 - (( -# 92 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 92 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 92, __func__, -# 92 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 92 "user/mpy/py/objlist.c" 3 - )) -# 92 "user/mpy/py/objlist.c" - ; - if (!(MP_OBJ_IS_OBJ(another_in) && (((mp_obj_base_t*)((void*)another_in))->type == (&mp_type_list)))) { - return -# 94 "user/mpy/py/objlist.c" 3 4 - 0 -# 94 "user/mpy/py/objlist.c" - ; - } - mp_obj_list_t *self = ((void*)self_in); - mp_obj_list_t *another = ((void*)another_in); - - return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); -} - -static mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_list_t *self = ((void*)self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); - case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(self->len)) << 1) | 1)); - - - - - - - default: return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t list_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - mp_obj_list_t *o = ((void*)lhs); - switch (op) { - case MP_BINARY_OP_ADD: { - if (!(MP_OBJ_IS_OBJ(rhs) && (((mp_obj_base_t*)((void*)rhs))->type == (&mp_type_list)))) { - return (((mp_obj_t)(void*)0)); - } - mp_obj_list_t *p = ((void*)rhs); - mp_obj_list_t *s = list_new(o->len + p->len); - { memcpy(s->items, o->items, (o->len) * sizeof(mp_obj_t)); memcpy(s->items + (o->len), p->items, (p->len) * sizeof(mp_obj_t)); }; - return ((mp_obj_t)s); - } - case MP_BINARY_OP_INPLACE_ADD: { - list_extend(lhs, rhs); - return lhs; - } - case MP_BINARY_OP_MULTIPLY: { - mp_int_t n; - if (!mp_obj_get_int_maybe(rhs, &n)) { - return (((mp_obj_t)(void*)0)); - } - if (n < 0) { - n = 0; - } - mp_obj_list_t *s = list_new(o->len * n); - mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); - return ((mp_obj_t)s); - } - case MP_BINARY_OP_EQUAL: - case MP_BINARY_OP_LESS: - case MP_BINARY_OP_LESS_EQUAL: - case MP_BINARY_OP_MORE: - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(list_cmp_helper(op, lhs, rhs)); - - default: - return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == (((mp_obj_t)(void*)0))) { -# 178 "user/mpy/py/objlist.c" - mp_obj_t args[2] = {self_in, index}; - list_pop(2, args); - return (((mp_obj_t)&mp_const_none_obj)); - } else if (value == (((mp_obj_t)(void*)8))) { - - mp_obj_list_t *self = ((void*)self_in); -# 195 "user/mpy/py/objlist.c" - size_t index_val = mp_get_index(self->base.type, self->len, index, -# 195 "user/mpy/py/objlist.c" 3 4 - 0 -# 195 "user/mpy/py/objlist.c" - ); - return self->items[index_val]; - } else { -# 229 "user/mpy/py/objlist.c" - mp_obj_list_store(self_in, index, value); - return (((mp_obj_t)&mp_const_none_obj)); - } -} - -static mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - return mp_obj_new_list_iterator(o_in, 0, iter_buf); -} - -mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) { - -# 239 "user/mpy/py/objlist.c" 3 - (( -# 239 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 239 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 239, __func__, -# 239 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 239 "user/mpy/py/objlist.c" 3 - )) -# 239 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)self_in); - if (self->len >= self->alloc) { - self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (self->alloc * 2)))); - self->alloc *= 2; - memset((byte*)(self->items) + (self->len + 1) * (sizeof(*self->items)), 0, ((self->alloc) - (self->len + 1)) * (sizeof(*self->items))); - } - self->items[self->len++] = arg; - return (((mp_obj_t)&mp_const_none_obj)); -} - -static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { - -# 251 "user/mpy/py/objlist.c" 3 - (( -# 251 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 251 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 251, __func__, -# 251 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 251 "user/mpy/py/objlist.c" 3 - )) -# 251 "user/mpy/py/objlist.c" - ; - if ((MP_OBJ_IS_OBJ(arg_in) && (((mp_obj_base_t*)((void*)arg_in))->type == (&mp_type_list)))) { - mp_obj_list_t *self = ((void*)self_in); - mp_obj_list_t *arg = ((void*)arg_in); - - if (self->len + arg->len > self->alloc) { - - self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (self->len + arg->len + 4)))); - self->alloc = self->len + arg->len + 4; - memset((byte*)(self->items) + (self->len + arg->len) * (sizeof(*self->items)), 0, ((self->alloc) - (self->len + arg->len)) * (sizeof(*self->items))); - } - - memcpy(self->items + self->len, arg->items, sizeof(mp_obj_t) * arg->len); - self->len += arg->len; - } else { - list_extend_from_iter(self_in, arg_in); - } - return (((mp_obj_t)&mp_const_none_obj)); -} - -static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) { - -# 272 "user/mpy/py/objlist.c" 3 - (( -# 272 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list))) -# 272 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 272, __func__, -# 272 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list)))" -# 272 "user/mpy/py/objlist.c" 3 - )) -# 272 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)args[0]); - if (self->len == 0) { - mp_raise_msg(&mp_type_IndexError, "pop from empty list"); - } - size_t index = mp_get_index(self->base.type, self->len, n_args == 1 ? ((mp_obj_t)((((mp_uint_t)(-1)) << 1) | 1)) : args[1], -# 277 "user/mpy/py/objlist.c" 3 4 - 0 -# 277 "user/mpy/py/objlist.c" - ); - mp_obj_t ret = self->items[index]; - self->len -= 1; - memmove(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t)); - - self->items[self->len] = (((mp_obj_t)(void*)0)); - if (self->alloc > 4 && self->alloc > 2 * self->len) { - self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (self->alloc/2)))); - self->alloc /= 2; - } - return ret; -} - -static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) { - ; - while (head < tail) { - mp_obj_t *h = head - 1; - mp_obj_t *t = tail; - mp_obj_t v = key_fn == (((mp_obj_t)(void*)0)) ? tail[0] : mp_call_function_1(key_fn, tail[0]); - for (;;) { - do ++h; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, key_fn == (((mp_obj_t)(void*)0)) ? h[0] : mp_call_function_1(key_fn, h[0]), v) == binop_less_result); - do --t; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, v, key_fn == (((mp_obj_t)(void*)0)) ? t[0] : mp_call_function_1(key_fn, t[0])) == binop_less_result); - if (h >= t) break; - mp_obj_t x = h[0]; - h[0] = t[0]; - t[0] = x; - } - mp_obj_t x = h[0]; - h[0] = tail[0]; - tail[0] = x; - - if (t - head < tail - h - 1) { - mp_quicksort(head, t, key_fn, binop_less_result); - head = h + 1; - } else { - mp_quicksort(h + 1, tail, key_fn, binop_less_result); - tail = t; - } - } -} - - -mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - static const mp_arg_t allowed_args[] = { - { MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = (&mp_const_none_obj)} }, - { MP_QSTR_reverse, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = -# 322 "user/mpy/py/objlist.c" 3 4 - 0 -# 322 "user/mpy/py/objlist.c" - } }, - }; - - - struct { - mp_arg_val_t key, reverse; - } args; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - (sizeof(allowed_args) / sizeof((allowed_args)[0])), allowed_args, (mp_arg_val_t*)&args); - - -# 332 "user/mpy/py/objlist.c" 3 - (( -# 332 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(pos_args[0]) && (((mp_obj_base_t*)((void*)pos_args[0]))->type == (&mp_type_list))) -# 332 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 332, __func__, -# 332 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(pos_args[0]) && (((mp_obj_base_t*)((void*)pos_args[0]))->type == (&mp_type_list)))" -# 332 "user/mpy/py/objlist.c" 3 - )) -# 332 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)pos_args[0]); - - if (self->len > 1) { - mp_quicksort(self->items, self->items + self->len - 1, - args.key.u_obj == (((mp_obj_t)&mp_const_none_obj)) ? (((mp_obj_t)(void*)0)) : args.key.u_obj, - args.reverse.u_bool ? (((mp_obj_t)&mp_const_false_obj)) : (((mp_obj_t)&mp_const_true_obj))); - } - - return (((mp_obj_t)&mp_const_none_obj)); -} - -static mp_obj_t list_clear(mp_obj_t self_in) { - -# 345 "user/mpy/py/objlist.c" 3 - (( -# 345 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 345 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 345, __func__, -# 345 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 345 "user/mpy/py/objlist.c" 3 - )) -# 345 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)self_in); - self->len = 0; - self->items = ((mp_obj_t*)(m_realloc((self->items), sizeof(mp_obj_t) * (4)))); - self->alloc = 4; - memset((byte*)(self->items) + (0) * (sizeof(*self->items)), 0, ((self->alloc) - (0)) * (sizeof(*self->items))); - return (((mp_obj_t)&mp_const_none_obj)); -} - -static mp_obj_t list_copy(mp_obj_t self_in) { - -# 355 "user/mpy/py/objlist.c" 3 - (( -# 355 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 355 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 355, __func__, -# 355 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 355 "user/mpy/py/objlist.c" 3 - )) -# 355 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)self_in); - return mp_obj_new_list(self->len, self->items); -} - -static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { - -# 361 "user/mpy/py/objlist.c" 3 - (( -# 361 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 361 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 361, __func__, -# 361 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 361 "user/mpy/py/objlist.c" 3 - )) -# 361 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)self_in); - return mp_seq_count_obj(self->items, self->len, value); -} - -static mp_obj_t list_index(size_t n_args, const mp_obj_t *args) { - -# 367 "user/mpy/py/objlist.c" 3 - (( -# 367 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list))) -# 367 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 367, __func__, -# 367 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_list)))" -# 367 "user/mpy/py/objlist.c" 3 - )) -# 367 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)args[0]); - return mp_seq_index_obj(self->items, self->len, n_args, args); -} - -static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) { - -# 373 "user/mpy/py/objlist.c" 3 - (( -# 373 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 373 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 373, __func__, -# 373 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 373 "user/mpy/py/objlist.c" 3 - )) -# 373 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)self_in); - - mp_int_t index = (((mp_int_t)(idx)) >> 1); - if (index < 0) { - index += self->len; - } - if (index < 0) { - index = 0; - } - if ((size_t)index > self->len) { - index = self->len; - } - - mp_obj_list_append(self_in, (((mp_obj_t)&mp_const_none_obj))); - - for (mp_int_t i = self->len-1; i > index; i--) { - self->items[i] = self->items[i-1]; - } - self->items[index] = obj; - - return (((mp_obj_t)&mp_const_none_obj)); -} - -mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) { - -# 398 "user/mpy/py/objlist.c" 3 - (( -# 398 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 398 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 398, __func__, -# 398 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 398 "user/mpy/py/objlist.c" 3 - )) -# 398 "user/mpy/py/objlist.c" - ; - mp_obj_t args[] = {self_in, value}; - args[1] = list_index(2, args); - list_pop(2, args); - - return (((mp_obj_t)&mp_const_none_obj)); -} - -static mp_obj_t list_reverse(mp_obj_t self_in) { - -# 407 "user/mpy/py/objlist.c" 3 - (( -# 407 "user/mpy/py/objlist.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list))) -# 407 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 407, __func__, -# 407 "user/mpy/py/objlist.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_list)))" -# 407 "user/mpy/py/objlist.c" 3 - )) -# 407 "user/mpy/py/objlist.c" - ; - mp_obj_list_t *self = ((void*)self_in); - - mp_int_t len = self->len; - for (mp_int_t i = 0; i < len/2; i++) { - mp_obj_t a = self->items[i]; - self->items[i] = self->items[len-i-1]; - self->items[len-i-1] = a; - } - - return (((mp_obj_t)&mp_const_none_obj)); -} - -static const mp_obj_fun_builtin_fixed_t list_append_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_obj_list_append}; -static const mp_obj_fun_builtin_fixed_t list_extend_obj = {{&mp_type_fun_builtin_2}, .fun._2 = list_extend}; -static const mp_obj_fun_builtin_fixed_t list_clear_obj = {{&mp_type_fun_builtin_1}, .fun._1 = list_clear}; -static const mp_obj_fun_builtin_fixed_t list_copy_obj = {{&mp_type_fun_builtin_1}, .fun._1 = list_copy}; -static const mp_obj_fun_builtin_fixed_t list_count_obj = {{&mp_type_fun_builtin_2}, .fun._2 = list_count}; -static const mp_obj_fun_builtin_var_t list_index_obj = {{&mp_type_fun_builtin_var}, -# 425 "user/mpy/py/objlist.c" 3 4 - 0 -# 425 "user/mpy/py/objlist.c" - , 2, 4, .fun.var = list_index}; -static const mp_obj_fun_builtin_fixed_t list_insert_obj = {{&mp_type_fun_builtin_3}, .fun._3 = list_insert}; -static const mp_obj_fun_builtin_var_t list_pop_obj = {{&mp_type_fun_builtin_var}, -# 427 "user/mpy/py/objlist.c" 3 4 - 0 -# 427 "user/mpy/py/objlist.c" - , 1, 2, .fun.var = list_pop}; -static const mp_obj_fun_builtin_fixed_t list_remove_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_obj_list_remove}; -static const mp_obj_fun_builtin_fixed_t list_reverse_obj = {{&mp_type_fun_builtin_1}, .fun._1 = list_reverse}; -static const mp_obj_fun_builtin_var_t list_sort_obj = {{&mp_type_fun_builtin_var}, -# 430 "user/mpy/py/objlist.c" 3 4 - 1 -# 430 "user/mpy/py/objlist.c" - , 1, (0xffff), .fun.kw = mp_obj_list_sort}; - -static const mp_rom_map_elem_t list_locals_dict_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_append)) << 2) | 2)), (&list_append_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_clear)) << 2) | 2)), (&list_clear_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_copy)) << 2) | 2)), (&list_copy_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_count)) << 2) | 2)), (&list_count_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_extend)) << 2) | 2)), (&list_extend_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_index)) << 2) | 2)), (&list_index_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_insert)) << 2) | 2)), (&list_insert_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_pop)) << 2) | 2)), (&list_pop_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_remove)) << 2) | 2)), (&list_remove_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_reverse)) << 2) | 2)), (&list_reverse_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sort)) << 2) | 2)), (&list_sort_obj) }, -}; - -static const mp_obj_dict_t list_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(list_locals_dict_table) / sizeof((list_locals_dict_table)[0])), .alloc = (sizeof(list_locals_dict_table) / sizeof((list_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)list_locals_dict_table, }, }; - -const mp_obj_type_t mp_type_list = { - { &mp_type_type }, - .name = MP_QSTR_list, - .print = list_print, - .make_new = list_make_new, - .unary_op = list_unary_op, - .binary_op = list_binary_op, - .subscr = list_subscr, - .getiter = list_getiter, - .locals_dict = (mp_obj_dict_t*)&list_locals_dict, -}; - -void mp_obj_list_init(mp_obj_list_t *o, size_t n) { - o->base.type = &mp_type_list; - o->alloc = n < 4 ? 4 : n; - o->len = n; - o->items = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (o->alloc)))); - memset((byte*)(o->items) + (n) * (sizeof(*o->items)), 0, ((o->alloc) - (n)) * (sizeof(*o->items))); -} - -static mp_obj_list_t *list_new(size_t n) { - mp_obj_list_t *o = (((mp_obj_list_t*)(m_malloc(sizeof(mp_obj_list_t) * (1))))); - mp_obj_list_init(o, n); - return o; -} - -mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items) { - mp_obj_list_t *o = list_new(n); - if (items != -# 476 "user/mpy/py/objlist.c" 3 4 - ((void *)0) -# 476 "user/mpy/py/objlist.c" - ) { - for (size_t i = 0; i < n; i++) { - o->items[i] = items[i]; - } - } - return ((mp_obj_t)o); -} - -void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { - mp_obj_list_t *self = ((void*)self_in); - *len = self->len; - *items = self->items; -} - -void mp_obj_list_set_len(mp_obj_t self_in, size_t len) { - - - mp_obj_list_t *self = ((void*)self_in); - self->len = len; -} - -void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_list_t *self = ((void*)self_in); - size_t i = mp_get_index(self->base.type, self->len, index, -# 499 "user/mpy/py/objlist.c" 3 4 - 0 -# 499 "user/mpy/py/objlist.c" - ); - self->items[i] = value; -} - - - - -typedef struct _mp_obj_list_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t list; - size_t cur; -} mp_obj_list_it_t; - -static mp_obj_t list_it_iternext(mp_obj_t self_in) { - mp_obj_list_it_t *self = ((void*)self_in); - mp_obj_list_t *list = ((void*)self->list); - if (self->cur < list->len) { - mp_obj_t o_out = list->items[self->cur]; - self->cur += 1; - return o_out; - } else { - return (((mp_obj_t)(void*)4)); - } -} - -mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf) { - -# 526 "user/mpy/py/objlist.c" 3 - (( -# 526 "user/mpy/py/objlist.c" - sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t) -# 526 "user/mpy/py/objlist.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objlist.c", 526, __func__, -# 526 "user/mpy/py/objlist.c" - "sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 526 "user/mpy/py/objlist.c" 3 - )) -# 526 "user/mpy/py/objlist.c" - ; - mp_obj_list_it_t *o = (mp_obj_list_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = list_it_iternext; - o->list = list; - o->cur = cur; - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objmap.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objmap.c" -# 27 "user/mpy/py/objmap.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objmap.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objmap.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objmap.c" 2 - -typedef struct _mp_obj_map_t { - mp_obj_base_t base; - size_t n_iters; - mp_obj_t fun; - mp_obj_t iters[]; -} mp_obj_map_t; - -static mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, (0xffff), -# 40 "user/mpy/py/objmap.c" 3 4 - 0 -# 40 "user/mpy/py/objmap.c" - ); - mp_obj_map_t *o = ((mp_obj_map_t*)m_malloc(sizeof(mp_obj_map_t) + sizeof(mp_obj_t) * (n_args - 1))); - o->base.type = type; - o->n_iters = n_args - 1; - o->fun = args[0]; - for (size_t i = 0; i < n_args - 1; i++) { - o->iters[i] = mp_getiter(args[i + 1], -# 46 "user/mpy/py/objmap.c" 3 4 - ((void *)0) -# 46 "user/mpy/py/objmap.c" - ); - } - return ((mp_obj_t)o); -} - -static mp_obj_t map_iternext(mp_obj_t self_in) { - -# 52 "user/mpy/py/objmap.c" 3 - (( -# 52 "user/mpy/py/objmap.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_map))) -# 52 "user/mpy/py/objmap.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objmap.c", 52, __func__, -# 52 "user/mpy/py/objmap.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_map)))" -# 52 "user/mpy/py/objmap.c" 3 - )) -# 52 "user/mpy/py/objmap.c" - ; - mp_obj_map_t *self = ((void*)self_in); - mp_obj_t *nextses = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (self->n_iters)))); - - for (size_t i = 0; i < self->n_iters; i++) { - mp_obj_t next = mp_iternext(self->iters[i]); - if (next == (((mp_obj_t)(void*)4))) { - ((void)(self->n_iters), m_free(nextses)); - return (((mp_obj_t)(void*)4)); - } - nextses[i] = next; - } - return mp_call_function_n_kw(self->fun, self->n_iters, 0, nextses); -} - -const mp_obj_type_t mp_type_map = { - { &mp_type_type }, - .name = MP_QSTR_map, - .make_new = map_make_new, - .getiter = mp_identity_getiter, - .iternext = map_iternext, -}; -# 1 "user/mpy/py/objmodule.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objmodule.c" -# 27 "user/mpy/py/objmodule.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objmodule.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objmodule.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 31 "user/mpy/py/objmodule.c" 2 - -# 1 "user/mpy/py/objmodule.h" 1 -# 31 "user/mpy/py/objmodule.h" -extern const mp_map_t mp_builtin_module_map; -extern const mp_map_t mp_builtin_module_weak_links_map; - -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); -# 33 "user/mpy/py/objmodule.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/objmodule.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 35 "user/mpy/py/objmodule.c" 2 - -static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_module_t *self = ((void*)self_in); - - const char *module_name = ""; - mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 42 "user/mpy/py/objmodule.c" 3 4 - ((void *)0) -# 42 "user/mpy/py/objmodule.c" - ) { - module_name = mp_obj_str_get_str(elem->value); - } -# 56 "user/mpy/py/objmodule.c" - mp_printf(print, "", module_name); -} - -static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - mp_obj_module_t *self = ((void*)self_in); - if (dest[0] == (((mp_obj_t)(void*)0))) { - - mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 64 "user/mpy/py/objmodule.c" 3 4 - ((void *)0) -# 64 "user/mpy/py/objmodule.c" - ) { - dest[0] = elem->value; - } - } else { - - mp_obj_dict_t *dict = self->globals; - if (dict->map.is_fixed) { -# 79 "user/mpy/py/objmodule.c" - { - - return; - } - } - if (dest[1] == (((mp_obj_t)(void*)0))) { - - mp_obj_dict_delete(((mp_obj_t)dict), ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2))); - } else { - - - mp_obj_dict_store(((mp_obj_t)dict), ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), dest[1]); - } - dest[0] = (((mp_obj_t)(void*)0)); - } -} - -const mp_obj_type_t mp_type_module = { - { &mp_type_type }, - .name = MP_QSTR_module, - .print = module_print, - .attr = module_attr, -}; - -mp_obj_t mp_obj_new_module(qstr module_name) { - mp_map_t *mp_loaded_modules_map = &(mp_state_ctx.vm.mp_loaded_modules_dict).map; - mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - - - if (el->value != (((mp_obj_t)(void*)0))) { - return el->value; - } - - - mp_obj_module_t *o = (((mp_obj_module_t*)(m_malloc(sizeof(mp_obj_module_t) * (1))))); - o->base.type = &mp_type_module; - o->globals = ((void*)mp_obj_new_dict((1))); - - - mp_obj_dict_store(((mp_obj_t)o->globals), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2))); - - - el->value = ((mp_obj_t)o); - - - return ((mp_obj_t)o); -} - -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) { - -# 128 "user/mpy/py/objmodule.c" 3 - (( -# 128 "user/mpy/py/objmodule.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_module))) -# 128 "user/mpy/py/objmodule.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objmodule.c", 128, __func__, -# 128 "user/mpy/py/objmodule.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_module)" -# 128 "user/mpy/py/objmodule.c" 3 - )) -# 128 "user/mpy/py/objmodule.c" - ; - mp_obj_module_t *self = ((void*)self_in); - return self->globals; -} - - - - -static const mp_rom_map_elem_t mp_builtin_module_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___main__)) << 2) | 2)), (&mp_module___main__) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_builtins)) << 2) | 2)), (&mp_module_builtins) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_micropython)) << 2) | 2)), (&mp_module_micropython) }, -# 227 "user/mpy/py/objmodule.c" - -}; - -const mp_map_t mp_builtin_module_map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(mp_builtin_module_table) / sizeof((mp_builtin_module_table)[0])), .alloc = (sizeof(mp_builtin_module_table) / sizeof((mp_builtin_module_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)mp_builtin_module_table, }; -# 241 "user/mpy/py/objmodule.c" -mp_obj_t mp_module_get(qstr module_name) { - mp_map_t *mp_loaded_modules_map = &(mp_state_ctx.vm.mp_loaded_modules_dict).map; - - mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2)), MP_MAP_LOOKUP); - - if (el == -# 246 "user/mpy/py/objmodule.c" 3 4 - ((void *)0) -# 246 "user/mpy/py/objmodule.c" - ) { - - el = mp_map_lookup((mp_map_t*)&mp_builtin_module_map, ((mp_obj_t)((((mp_uint_t)(module_name)) << 2) | 2)), MP_MAP_LOOKUP); - if (el == -# 249 "user/mpy/py/objmodule.c" 3 4 - ((void *)0) -# 249 "user/mpy/py/objmodule.c" - ) { - return (((mp_obj_t)(void*)0)); - } - - if ((0)) { - - mp_obj_t dest[2]; - mp_load_method_maybe(el->value, MP_QSTR___init__, dest); - if (dest[0] != (((mp_obj_t)(void*)0))) { - mp_call_method_n_kw(0, 0, dest); - - mp_module_register(module_name, el->value); - } - } - } - - - return el->value; -} - -void mp_module_register(qstr qst, mp_obj_t module) { - mp_map_t *mp_loaded_modules_map = &(mp_state_ctx.vm.mp_loaded_modules_dict).map; - mp_map_lookup(mp_loaded_modules_map, ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; -} -# 1 "user/mpy/py/objobject.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objobject.c" -# 27 "user/mpy/py/objobject.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objobject.c" 2 - -# 1 "user/mpy/py/objtype.h" 1 -# 29 "user/mpy/py/objtype.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtype.h" 2 - - - -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 30 "user/mpy/py/objobject.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objobject.c" 2 - -typedef struct _mp_obj_object_t { - mp_obj_base_t base; -} mp_obj_object_t; - -static mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)args; - mp_arg_check_num(n_args, n_kw, 0, 0, -# 38 "user/mpy/py/objobject.c" 3 4 - 0 -# 38 "user/mpy/py/objobject.c" - ); - mp_obj_object_t *o = (((mp_obj_object_t*)(m_malloc(sizeof(mp_obj_object_t) * (1))))); - o->base.type = type; - return ((mp_obj_t)o); -} -# 74 "user/mpy/py/objobject.c" -const mp_obj_type_t mp_type_object = { - { &mp_type_type }, - .name = MP_QSTR_object, - .make_new = object_make_new, - - - -}; -# 1 "user/mpy/py/objpolyiter.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objpolyiter.c" -# 27 "user/mpy/py/objpolyiter.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objpolyiter.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 30 "user/mpy/py/objpolyiter.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/objpolyiter.c" 2 - - - - - - - -typedef struct _mp_obj_polymorph_iter_t { - mp_obj_base_t base; - mp_fun_1_t iternext; -} mp_obj_polymorph_iter_t; - -static mp_obj_t polymorph_it_iternext(mp_obj_t self_in) { - mp_obj_polymorph_iter_t *self = ((void*)self_in); - - return self->iternext(self_in); -} - -const mp_obj_type_t mp_type_polymorph_iter = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = polymorph_it_iternext, -}; -# 1 "user/mpy/py/objproperty.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objproperty.c" -# 27 "user/mpy/py/objproperty.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objproperty.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objproperty.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objproperty.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/objproperty.c" 2 -# 1 "user/mpy/py/objnone.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objnone.c" -# 27 "user/mpy/py/objnone.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objnone.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 30 "user/mpy/py/objnone.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 31 "user/mpy/py/objnone.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/objnone.c" 2 - -typedef struct _mp_obj_none_t { - mp_obj_base_t base; -} mp_obj_none_t; - -static void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)self_in; - if ((0) && kind == PRINT_JSON) { - mp_print_str(print, "null"); - } else { - mp_print_str(print, "None"); - } -} - -const mp_obj_type_t mp_type_NoneType = { - { &mp_type_type }, - .name = MP_QSTR_NoneType, - .print = none_print, - .unary_op = mp_generic_unary_op, -}; - -const mp_obj_none_t mp_const_none_obj = {{&mp_type_NoneType}}; -# 1 "user/mpy/py/objnamedtuple.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objnamedtuple.c" -# 28 "user/mpy/py/objnamedtuple.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/objnamedtuple.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objnamedtuple.c" 2 -# 1 "user/mpy/py/objtuple.h" 1 -# 29 "user/mpy/py/objtuple.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtuple.h" 2 - -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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 32 "user/mpy/py/objnamedtuple.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 32 "user/mpy/py/objexcept.h" -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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/objnamedtuple.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 34 "user/mpy/py/objnamedtuple.c" 2 -# 1 "user/mpy/py/objrange.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objrange.c" -# 27 "user/mpy/py/objrange.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objrange.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 30 "user/mpy/py/objrange.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 31 "user/mpy/py/objrange.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/objrange.c" 2 - - - - -typedef struct _mp_obj_range_it_t { - mp_obj_base_t base; - - mp_int_t cur; - mp_int_t stop; - mp_int_t step; -} mp_obj_range_it_t; - -static mp_obj_t range_it_iternext(mp_obj_t o_in) { - mp_obj_range_it_t *o = ((void*)o_in); - if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) { - mp_obj_t o_out = ((mp_obj_t)((((mp_uint_t)(o->cur)) << 1) | 1)); - o->cur += o->step; - return o_out; - } else { - return (((mp_obj_t)(void*)4)); - } -} - -static const mp_obj_type_t range_it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = range_it_iternext, -}; - -static mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) { - -# 63 "user/mpy/py/objrange.c" 3 - (( -# 63 "user/mpy/py/objrange.c" - sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t) -# 63 "user/mpy/py/objrange.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objrange.c", 63, __func__, -# 63 "user/mpy/py/objrange.c" - "sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 63 "user/mpy/py/objrange.c" 3 - )) -# 63 "user/mpy/py/objrange.c" - ; - mp_obj_range_it_t *o = (mp_obj_range_it_t*)iter_buf; - o->base.type = &range_it_type; - o->cur = cur; - o->stop = stop; - o->step = step; - return ((mp_obj_t)o); -} - - - - -typedef struct _mp_obj_range_t { - mp_obj_base_t base; - - mp_int_t start; - mp_int_t stop; - mp_int_t step; -} mp_obj_range_t; - -static void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_range_t *self = ((void*)self_in); - mp_printf(print, "range(" "%d" ", " "%d" "", self->start, self->stop); - if (self->step == 1) { - mp_print_str(print, ")"); - } else { - mp_printf(print, ", " "%d" ")", self->step); - } -} - -static mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 3, -# 95 "user/mpy/py/objrange.c" 3 4 - 0 -# 95 "user/mpy/py/objrange.c" - ); - - mp_obj_range_t *o = (((mp_obj_range_t*)(m_malloc(sizeof(mp_obj_range_t) * (1))))); - o->base.type = type; - o->start = 0; - o->step = 1; - - if (n_args == 1) { - o->stop = mp_obj_get_int(args[0]); - } else { - o->start = mp_obj_get_int(args[0]); - o->stop = mp_obj_get_int(args[1]); - if (n_args == 3) { - o->step = mp_obj_get_int(args[2]); - if (o->step == 0) { - mp_raise_ValueError("zero step"); - } - } - } - - return ((mp_obj_t)o); -} - -static mp_int_t range_len(mp_obj_range_t *self) { - - mp_int_t len = self->stop - self->start + self->step; - if (self->step > 0) { - len -= 1; - } else { - len += 1; - } - len = len / self->step; - if (len < 0) { - len = 0; - } - return len; -} - -static mp_obj_t range_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_range_t *self = ((void*)self_in); - mp_int_t len = range_len(self); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len > 0); - case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(len)) << 1) | 1)); - default: return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == (((mp_obj_t)(void*)8))) { - - mp_obj_range_t *self = ((void*)self_in); - mp_int_t len = range_len(self); -# 164 "user/mpy/py/objrange.c" - size_t index_val = mp_get_index(self->base.type, len, index, -# 164 "user/mpy/py/objrange.c" 3 4 - 0 -# 164 "user/mpy/py/objrange.c" - ); - return ((mp_obj_t)((((mp_uint_t)(self->start + index_val * self->step)) << 1) | 1)); - } else { - return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - mp_obj_range_t *o = ((void*)o_in); - return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf); -} - - - -static void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != (((mp_obj_t)(void*)0))) { - - return; - } - mp_obj_range_t *o = ((void*)o_in); - if (attr == MP_QSTR_start) { - dest[0] = mp_obj_new_int(o->start); - } else if (attr == MP_QSTR_stop) { - dest[0] = mp_obj_new_int(o->stop); - } else if (attr == MP_QSTR_step) { - dest[0] = mp_obj_new_int(o->step); - } -} - - -const mp_obj_type_t mp_type_range = { - { &mp_type_type }, - .name = MP_QSTR_range, - .print = range_print, - .make_new = range_make_new, - .unary_op = range_unary_op, - .subscr = range_subscr, - .getiter = range_getiter, - - .attr = range_attr, - -}; -# 1 "user/mpy/py/objreversed.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objreversed.c" -# 27 "user/mpy/py/objreversed.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objreversed.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objreversed.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objreversed.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/objreversed.c" 2 -# 1 "user/mpy/py/objset.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objset.c" -# 27 "user/mpy/py/objset.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 28 "user/mpy/py/objset.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/objset.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objset.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objset.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 35 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/objset.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 34 "user/mpy/py/objset.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 35 "user/mpy/py/objset.c" 2 -# 1 "user/mpy/py/objsingleton.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objsingleton.c" -# 27 "user/mpy/py/objsingleton.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objsingleton.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objsingleton.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objsingleton.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 32 "user/mpy/py/objsingleton.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/objsingleton.c" 2 - - - - -typedef struct _mp_obj_singleton_t { - mp_obj_base_t base; - qstr name; -} mp_obj_singleton_t; - -static void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_singleton_t *self = ((void*)self_in); - mp_printf(print, "%q", self->name); -} - -const mp_obj_type_t mp_type_singleton = { - { &mp_type_type }, - .name = MP_QSTR_, - .print = singleton_print, -}; - -const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis}; -# 1 "user/mpy/py/objslice.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objslice.c" -# 27 "user/mpy/py/objslice.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objslice.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objslice.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objslice.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 32 "user/mpy/py/objslice.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/objslice.c" 2 -# 1 "user/mpy/py/objstr.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objstr.c" -# 28 "user/mpy/py/objstr.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/objstr.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objstr.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objstr.c" 2 -# 1 "user/mpy/py/unicode.h" 1 -# 30 "user/mpy/py/unicode.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/unicode.h" 2 - -mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); -# 33 "user/mpy/py/objstr.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 29 "user/mpy/py/objstr.h" -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objstr.h" 2 - -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 34 "user/mpy/py/objstr.c" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 35 "user/mpy/py/objstr.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 36 "user/mpy/py/objstr.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - - -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/objstr.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 38 "user/mpy/py/objstr.c" 2 - -static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict); - -static mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); -static __attribute__((noreturn)) void bad_implicit_conversion(mp_obj_t self_in); - - - - -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 47 "user/mpy/py/objstr.c" 3 4 - _Bool -# 47 "user/mpy/py/objstr.c" - is_bytes) { - - -# 49 "user/mpy/py/objstr.c" 3 4 - _Bool -# 49 "user/mpy/py/objstr.c" - has_single_quote = -# 49 "user/mpy/py/objstr.c" 3 4 - 0 -# 49 "user/mpy/py/objstr.c" - ; - -# 50 "user/mpy/py/objstr.c" 3 4 - _Bool -# 50 "user/mpy/py/objstr.c" - has_double_quote = -# 50 "user/mpy/py/objstr.c" 3 4 - 0 -# 50 "user/mpy/py/objstr.c" - ; - for (const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) { - if (*s == '\'') { - has_single_quote = -# 53 "user/mpy/py/objstr.c" 3 4 - 1 -# 53 "user/mpy/py/objstr.c" - ; - } else if (*s == '"') { - has_double_quote = -# 55 "user/mpy/py/objstr.c" 3 4 - 1 -# 55 "user/mpy/py/objstr.c" - ; - } - } - int quote_char = '\''; - if (has_single_quote && !has_double_quote) { - quote_char = '"'; - } - mp_printf(print, "%c", quote_char); - for (const byte *s = str_data, *top = str_data + str_len; s < top; s++) { - if (*s == quote_char) { - mp_printf(print, "\\%c", quote_char); - } else if (*s == '\\') { - mp_print_str(print, "\\\\"); - } else if (*s >= 0x20 && *s != 0x7f && (!is_bytes || *s < 0x80)) { - - - - mp_printf(print, "%c", *s); - } else if (*s == '\n') { - mp_print_str(print, "\\n"); - } else if (*s == '\r') { - mp_print_str(print, "\\r"); - } else if (*s == '\t') { - mp_print_str(print, "\\t"); - } else { - mp_printf(print, "\\x%02x", *s); - } - } - mp_printf(print, "%c", quote_char); -} -# 112 "user/mpy/py/objstr.c" -static void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(self_in)) { str_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)self_in))->len; str_data = ((mp_obj_str_t*)((void*)self_in))->data; }; - - - - - - - - -# 121 "user/mpy/py/objstr.c" 3 4 - _Bool -# 121 "user/mpy/py/objstr.c" - is_bytes = (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_bytes))); - - - - if (kind == PRINT_RAW || (!(0) && kind == PRINT_STR && !is_bytes)) { - mp_printf(print, "%.*s", str_len, str_data); - } else { - if (is_bytes) { - mp_print_str(print, "b"); - } - mp_str_print_quoted(print, str_data, str_len, is_bytes); - } -} - -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - - - - - - - mp_arg_check_num(n_args, n_kw, 0, 3, -# 142 "user/mpy/py/objstr.c" 3 4 - 0 -# 142 "user/mpy/py/objstr.c" - ); - - switch (n_args) { - case 0: - return ((mp_obj_t)((((mp_uint_t)(MP_QSTR_)) << 2) | 2)); - - case 1: { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - mp_obj_print_helper(&print, args[0], PRINT_STR); - return mp_obj_new_str_from_vstr(type, &vstr); - } - - default: - - if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_bytes)))) { - const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str_data = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str_data = ((mp_obj_str_t*)((void*)args[0]))->data; }; - mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(args[0])) { str_hash = qstr_hash((((mp_uint_t)(args[0])) >> 2)); } else { str_hash = ((mp_obj_str_t*)((void*)args[0]))->hash; }; - if (str_hash == 0) { - str_hash = qstr_compute_hash(str_data, str_len); - } - mp_obj_str_t *o = ((void*)mp_obj_new_str_of_type(type, -# 164 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 164 "user/mpy/py/objstr.c" - , str_len)); - o->data = str_data; - o->hash = str_hash; - return ((mp_obj_t)o); - } else { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, (1)); - return mp_obj_new_str(bufinfo.buf, bufinfo.len, -# 171 "user/mpy/py/objstr.c" 3 4 - 0 -# 171 "user/mpy/py/objstr.c" - ); - } - } -} - -static mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - - - - - - (void)n_kw; - - - if (n_args == 0) { - return (((mp_obj_t)&mp_const_empty_bytes_obj)); - } - - if ((MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_str))))) { - if (n_args < 2 || n_args > 3) { - goto wrong_args; - } - const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str_data = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str_data = ((mp_obj_str_t*)((void*)args[0]))->data; }; - mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(args[0])) { str_hash = qstr_hash((((mp_uint_t)(args[0])) >> 2)); } else { str_hash = ((mp_obj_str_t*)((void*)args[0]))->hash; }; - if (str_hash == 0) { - str_hash = qstr_compute_hash(str_data, str_len); - } - mp_obj_str_t *o = ((void*)mp_obj_new_str_of_type(&mp_type_bytes, -# 200 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 200 "user/mpy/py/objstr.c" - , str_len)); - o->data = str_data; - o->hash = str_hash; - return ((mp_obj_t)o); - } - - if (n_args > 1) { - goto wrong_args; - } - - if (MP_OBJ_IS_SMALL_INT(args[0])) { - uint len = (((mp_int_t)(args[0])) >> 1); - vstr_t vstr; - vstr_init_len(&vstr, len); - memset(vstr.buf, 0, len); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); - } - - - mp_buffer_info_t bufinfo; - if (mp_get_buffer(args[0], &bufinfo, (1))) { - return mp_obj_new_str_of_type(&mp_type_bytes, bufinfo.buf, bufinfo.len); - } - - vstr_t vstr; - - mp_obj_t len_in = mp_obj_len_maybe(args[0]); - if (len_in == (((mp_obj_t)(void*)0))) { - vstr_init(&vstr, 16); - } else { - mp_int_t len = (((mp_int_t)(len_in)) >> 1); - vstr_init(&vstr, len); - } - - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(args[0], &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - mp_int_t val = mp_obj_get_int(item); - - if (val < 0 || val > 255) { - mp_raise_ValueError("bytes value out of range"); - } - - vstr_add_byte(&vstr, val); - } - - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); - -wrong_args: - mp_raise_TypeError("wrong number of arguments"); -} - - - -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction) { - if (hlen >= nlen) { - size_t str_index, str_index_end; - if (direction > 0) { - str_index = 0; - str_index_end = hlen - nlen; - } else { - str_index = hlen - nlen; - str_index_end = 0; - } - for (;;) { - if (memcmp(&haystack[str_index], needle, nlen) == 0) { - - return haystack + str_index; - } - if (str_index == str_index_end) { - - break; - } - str_index += direction; - } - } - return -# 277 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 277 "user/mpy/py/objstr.c" - ; -} - - - - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - - if (op == MP_BINARY_OP_MODULO) { - mp_obj_t *args = &rhs_in; - size_t n_args = 1; - mp_obj_t dict = (((mp_obj_t)(void*)0)); - if ((MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_tuple)))) { - - mp_obj_tuple_get(rhs_in, &n_args, &args); - } else if ((MP_OBJ_IS_OBJ(rhs_in) && (((mp_obj_base_t*)((void*)rhs_in))->type == (&mp_type_dict)))) { - dict = rhs_in; - } - return str_modulo_format(lhs_in, n_args, args, dict); - } - - - mp_obj_type_t *lhs_type = mp_obj_get_type(lhs_in); - const byte *lhs_data; size_t lhs_len; if (MP_OBJ_IS_QSTR(lhs_in)) { lhs_data = qstr_data((((mp_uint_t)(lhs_in)) >> 2), &lhs_len); } else { lhs_len = ((mp_obj_str_t*)((void*)lhs_in))->len; lhs_data = ((mp_obj_str_t*)((void*)lhs_in))->data; }; - - - if (op == MP_BINARY_OP_MULTIPLY) { - mp_int_t n; - if (!mp_obj_get_int_maybe(rhs_in, &n)) { - return (((mp_obj_t)(void*)0)); - } - if (n <= 0) { - if (lhs_type == &mp_type_str) { - return ((mp_obj_t)((((mp_uint_t)(MP_QSTR_)) << 2) | 2)); - } else { - return (((mp_obj_t)&mp_const_empty_bytes_obj)); - } - } - vstr_t vstr; - vstr_init_len(&vstr, lhs_len * n); - mp_seq_multiply(lhs_data, sizeof(*lhs_data), lhs_len, n, vstr.buf); - return mp_obj_new_str_from_vstr(lhs_type, &vstr); - } -# 336 "user/mpy/py/objstr.c" - const byte *rhs_data; - size_t rhs_len; - if (lhs_type == mp_obj_get_type(rhs_in)) { - const byte *rhs_data_; size_t rhs_len_; if (MP_OBJ_IS_QSTR(rhs_in)) { rhs_data_ = qstr_data((((mp_uint_t)(rhs_in)) >> 2), &rhs_len_); } else { rhs_len_ = ((mp_obj_str_t*)((void*)rhs_in))->len; rhs_data_ = ((mp_obj_str_t*)((void*)rhs_in))->data; }; - rhs_data = rhs_data_; - rhs_len = rhs_len_; - } else if (lhs_type == &mp_type_bytes) { - mp_buffer_info_t bufinfo; - if (!mp_get_buffer(rhs_in, &bufinfo, (1))) { - return (((mp_obj_t)(void*)0)); - } - rhs_data = bufinfo.buf; - rhs_len = bufinfo.len; - } else { - - - bad_implicit_conversion(rhs_in); - } - - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: { - if (lhs_len == 0 && mp_obj_get_type(rhs_in) == lhs_type) { - return rhs_in; - } - if (rhs_len == 0) { - return lhs_in; - } - - vstr_t vstr; - vstr_init_len(&vstr, lhs_len + rhs_len); - memcpy(vstr.buf, lhs_data, lhs_len); - memcpy(vstr.buf + lhs_len, rhs_data, rhs_len); - return mp_obj_new_str_from_vstr(lhs_type, &vstr); - } - - case MP_BINARY_OP_IN: - - return mp_obj_new_bool(find_subbytes(lhs_data, lhs_len, rhs_data, rhs_len, 1) != -# 374 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 374 "user/mpy/py/objstr.c" - ); - - - case MP_BINARY_OP_EQUAL: - case MP_BINARY_OP_LESS: - case MP_BINARY_OP_LESS_EQUAL: - case MP_BINARY_OP_MORE: - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_data, lhs_len, rhs_data, rhs_len)); - } - - return (((mp_obj_t)(void*)0)); -} - - - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 391 "user/mpy/py/objstr.c" 3 4 - _Bool -# 391 "user/mpy/py/objstr.c" - is_slice) { - size_t index_val = mp_get_index(type, self_len, index, is_slice); - return self_data + index_val; -} - - - -static mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - const byte *self_data; size_t self_len; if (MP_OBJ_IS_QSTR(self_in)) { self_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &self_len); } else { self_len = ((mp_obj_str_t*)((void*)self_in))->len; self_data = ((mp_obj_str_t*)((void*)self_in))->data; }; - if (value == (((mp_obj_t)(void*)8))) { -# 412 "user/mpy/py/objstr.c" - size_t index_val = mp_get_index(type, self_len, index, -# 412 "user/mpy/py/objstr.c" 3 4 - 0 -# 412 "user/mpy/py/objstr.c" - ); - - if ((0) || type == &mp_type_bytes) { - return ((mp_obj_t)((((mp_uint_t)(self_data[index_val])) << 1) | 1)); - } else { - return mp_obj_new_str((char*)&self_data[index_val], 1, -# 417 "user/mpy/py/objstr.c" 3 4 - 1 -# 417 "user/mpy/py/objstr.c" - ); - } - } else { - return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { - -# 425 "user/mpy/py/objstr.c" 3 - (( -# 425 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op)) -# 425 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 425, __func__, -# 425 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op))" -# 425 "user/mpy/py/objstr.c" 3 - )) -# 425 "user/mpy/py/objstr.c" - ; - const mp_obj_type_t *self_type = mp_obj_get_type(self_in); - - - const byte *sep_str; size_t sep_len; if (MP_OBJ_IS_QSTR(self_in)) { sep_str = qstr_data((((mp_uint_t)(self_in)) >> 2), &sep_len); } else { sep_len = ((mp_obj_str_t*)((void*)self_in))->len; sep_str = ((mp_obj_str_t*)((void*)self_in))->data; }; - - - size_t seq_len; - mp_obj_t *seq_items; - - if (!(MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_list))) && !(MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_tuple)))) { - - - arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); - } - mp_obj_get_array(arg, &seq_len, &seq_items); - - - size_t required_len = 0; - for (size_t i = 0; i < seq_len; i++) { - if (mp_obj_get_type(seq_items[i]) != self_type) { - mp_raise_TypeError( - "join expects a list of str/bytes objects consistent with self object"); - } - if (i > 0) { - required_len += sep_len; - } - size_t l; if (MP_OBJ_IS_QSTR(seq_items[i])) { l = qstr_len((((mp_uint_t)(seq_items[i])) >> 2)); } else { l = ((mp_obj_str_t*)((void*)seq_items[i]))->len; }; - required_len += l; - } - - - vstr_t vstr; - vstr_init_len(&vstr, required_len); - byte *data = (byte*)vstr.buf; - for (size_t i = 0; i < seq_len; i++) { - if (i > 0) { - memcpy(data, sep_str, sep_len); - data += sep_len; - } - const byte *s; size_t l; if (MP_OBJ_IS_QSTR(seq_items[i])) { s = qstr_data((((mp_uint_t)(seq_items[i])) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)seq_items[i]))->len; s = ((mp_obj_str_t*)((void*)seq_items[i]))->data; }; - memcpy(data, s, l); - data += l; - } - - - return mp_obj_new_str_from_vstr(self_type, &vstr); -} -const mp_obj_fun_builtin_fixed_t str_join_obj = {{&mp_type_fun_builtin_2}, .fun._2 = str_join}; - -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - mp_int_t splits = -1; - mp_obj_t sep = (((mp_obj_t)&mp_const_none_obj)); - if (n_args > 1) { - sep = args[1]; - if (n_args > 2) { - splits = mp_obj_get_int(args[2]); - } - } - - mp_obj_t res = mp_obj_new_list(0, -# 486 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 486 "user/mpy/py/objstr.c" - ); - const byte *s; size_t len; if (MP_OBJ_IS_QSTR(args[0])) { s = qstr_data((((mp_uint_t)(args[0])) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)args[0]))->len; s = ((mp_obj_str_t*)((void*)args[0]))->data; }; - const byte *top = s + len; - - if (sep == (((mp_obj_t)&mp_const_none_obj))) { - - - - while (s < top && unichar_isspace(*s)) s++; - while (s < top && splits != 0) { - const byte *start = s; - while (s < top && !unichar_isspace(*s)) s++; - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); - if (s >= top) { - break; - } - while (s < top && unichar_isspace(*s)) s++; - if (splits > 0) { - splits--; - } - } - - if (s < top) { - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, s, top - s)); - } - - } else { - - if (mp_obj_get_type(sep) != self_type) { - bad_implicit_conversion(sep); - } - - size_t sep_len; - const char *sep_str = mp_obj_str_get_data(sep, &sep_len); - - if (sep_len == 0) { - mp_raise_ValueError("empty separator"); - } - - for (;;) { - const byte *start = s; - for (;;) { - if (splits == 0 || s + sep_len > top) { - s = top; - break; - } else if (memcmp(s, sep_str, sep_len) == 0) { - break; - } - s++; - } - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); - if (s >= top) { - break; - } - s += sep_len; - if (splits > 0) { - splits--; - } - } - } - - return res; -} -const mp_obj_fun_builtin_var_t str_split_obj = {{&mp_type_fun_builtin_var}, -# 549 "user/mpy/py/objstr.c" 3 4 -0 -# 549 "user/mpy/py/objstr.c" -, 1, 3, .fun.var = mp_obj_str_split}; -# 598 "user/mpy/py/objstr.c" -static mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) { - if (n_args < 3) { - - - return mp_obj_str_split(n_args, args); - } - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - mp_obj_t sep = args[1]; - const byte *s; size_t len; if (MP_OBJ_IS_QSTR(args[0])) { s = qstr_data((((mp_uint_t)(args[0])) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)args[0]))->len; s = ((mp_obj_str_t*)((void*)args[0]))->data; }; - - mp_int_t splits = mp_obj_get_int(args[2]); - if (splits < 0) { - - return mp_obj_str_split(n_args, args); - } - - mp_int_t org_splits = splits; - - - mp_obj_list_t *res = ((void*)mp_obj_new_list(splits + 1, -# 617 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 617 "user/mpy/py/objstr.c" - )); - mp_int_t idx = splits; - - if (sep == (((mp_obj_t)&mp_const_none_obj))) { - mp_raise_NotImplementedError("rsplit(None,n)"); - } else { - size_t sep_len; - const char *sep_str = mp_obj_str_get_data(sep, &sep_len); - - if (sep_len == 0) { - mp_raise_ValueError("empty separator"); - } - - const byte *beg = s; - const byte *last = s + len; - for (;;) { - s = last - sep_len; - for (;;) { - if (splits == 0 || s < beg) { - break; - } else if (memcmp(s, sep_str, sep_len) == 0) { - break; - } - s--; - } - if (s < beg || splits == 0) { - res->items[idx] = mp_obj_new_str_of_type(self_type, beg, last - beg); - break; - } - res->items[idx--] = mp_obj_new_str_of_type(self_type, s + sep_len, last - s - sep_len); - last = s; - if (splits > 0) { - splits--; - } - } - if (idx != 0) { - - size_t used = org_splits + 1 - idx; - memmove(res->items, &res->items[idx], used * sizeof(mp_obj_t)); - memset((byte*)(res->items) + (used) * (sizeof(*res->items)), 0, ((res->alloc) - (used)) * (sizeof(*res->items))); - res->len = used; - } - } - - return ((mp_obj_t)res); -} -const mp_obj_fun_builtin_var_t str_rsplit_obj = {{&mp_type_fun_builtin_var}, -# 663 "user/mpy/py/objstr.c" 3 4 -0 -# 663 "user/mpy/py/objstr.c" -, 1, 3, .fun.var = str_rsplit}; - -static mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, -# 665 "user/mpy/py/objstr.c" 3 4 - _Bool -# 665 "user/mpy/py/objstr.c" - is_index) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - -# 667 "user/mpy/py/objstr.c" 3 - (( -# 667 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) -# 667 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 667, __func__, -# 667 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" -# 667 "user/mpy/py/objstr.c" 3 - )) -# 667 "user/mpy/py/objstr.c" - ; - - - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - - const byte *haystack; size_t haystack_len; if (MP_OBJ_IS_QSTR(args[0])) { haystack = qstr_data((((mp_uint_t)(args[0])) >> 2), &haystack_len); } else { haystack_len = ((mp_obj_str_t*)((void*)args[0]))->len; haystack = ((mp_obj_str_t*)((void*)args[0]))->data; }; - const byte *needle; size_t needle_len; if (MP_OBJ_IS_QSTR(args[1])) { needle = qstr_data((((mp_uint_t)(args[1])) >> 2), &needle_len); } else { needle_len = ((mp_obj_str_t*)((void*)args[1]))->len; needle = ((mp_obj_str_t*)((void*)args[1]))->data; }; - - const byte *start = haystack; - const byte *end = haystack + haystack_len; - if (n_args >= 3 && args[2] != (((mp_obj_t)&mp_const_none_obj))) { - start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], -# 680 "user/mpy/py/objstr.c" 3 4 - 1 -# 680 "user/mpy/py/objstr.c" - ); - } - if (n_args >= 4 && args[3] != (((mp_obj_t)&mp_const_none_obj))) { - end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], -# 683 "user/mpy/py/objstr.c" 3 4 - 1 -# 683 "user/mpy/py/objstr.c" - ); - } - - const byte *p = find_subbytes(start, end - start, needle, needle_len, direction); - if (p == -# 687 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 687 "user/mpy/py/objstr.c" - ) { - - if (is_index) { - mp_raise_ValueError("substring not found"); - } else { - return ((mp_obj_t)((((mp_uint_t)(-1)) << 1) | 1)); - } - } else { - - - - - - - return ((mp_obj_t)((((mp_uint_t)(p - haystack)) << 1) | 1)); - } -} - -static mp_obj_t str_find(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, 1, -# 706 "user/mpy/py/objstr.c" 3 4 - 0 -# 706 "user/mpy/py/objstr.c" - ); -} -const mp_obj_fun_builtin_var_t str_find_obj = {{&mp_type_fun_builtin_var}, -# 708 "user/mpy/py/objstr.c" 3 4 -0 -# 708 "user/mpy/py/objstr.c" -, 2, 4, .fun.var = str_find}; - -static mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, -1, -# 711 "user/mpy/py/objstr.c" 3 4 - 0 -# 711 "user/mpy/py/objstr.c" - ); -} -const mp_obj_fun_builtin_var_t str_rfind_obj = {{&mp_type_fun_builtin_var}, -# 713 "user/mpy/py/objstr.c" 3 4 -0 -# 713 "user/mpy/py/objstr.c" -, 2, 4, .fun.var = str_rfind}; - -static mp_obj_t str_index(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, 1, -# 716 "user/mpy/py/objstr.c" 3 4 - 1 -# 716 "user/mpy/py/objstr.c" - ); -} -const mp_obj_fun_builtin_var_t str_index_obj = {{&mp_type_fun_builtin_var}, -# 718 "user/mpy/py/objstr.c" 3 4 -0 -# 718 "user/mpy/py/objstr.c" -, 2, 4, .fun.var = str_index}; - -static mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, -1, -# 721 "user/mpy/py/objstr.c" 3 4 - 1 -# 721 "user/mpy/py/objstr.c" - ); -} -const mp_obj_fun_builtin_var_t str_rindex_obj = {{&mp_type_fun_builtin_var}, -# 723 "user/mpy/py/objstr.c" 3 4 -0 -# 723 "user/mpy/py/objstr.c" -, 2, 4, .fun.var = str_rindex}; - - -static mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - const byte *str; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; - const byte *prefix; size_t prefix_len; if (MP_OBJ_IS_QSTR(args[1])) { prefix = qstr_data((((mp_uint_t)(args[1])) >> 2), &prefix_len); } else { prefix_len = ((mp_obj_str_t*)((void*)args[1]))->len; prefix = ((mp_obj_str_t*)((void*)args[1]))->data; }; - const byte *start = str; - if (n_args > 2) { - start = str_index_to_ptr(self_type, str, str_len, args[2], -# 732 "user/mpy/py/objstr.c" 3 4 - 1 -# 732 "user/mpy/py/objstr.c" - ); - } - if (prefix_len + (start - str) > str_len) { - return (((mp_obj_t)&mp_const_false_obj)); - } - return mp_obj_new_bool(memcmp(start, prefix, prefix_len) == 0); -} -const mp_obj_fun_builtin_var_t str_startswith_obj = {{&mp_type_fun_builtin_var}, -# 739 "user/mpy/py/objstr.c" 3 4 -0 -# 739 "user/mpy/py/objstr.c" -, 2, 3, .fun.var = str_startswith}; - -static mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) { - const byte *str; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; - const byte *suffix; size_t suffix_len; if (MP_OBJ_IS_QSTR(args[1])) { suffix = qstr_data((((mp_uint_t)(args[1])) >> 2), &suffix_len); } else { suffix_len = ((mp_obj_str_t*)((void*)args[1]))->len; suffix = ((mp_obj_str_t*)((void*)args[1]))->data; }; - if (n_args > 2) { - mp_raise_NotImplementedError("start/end indices"); - } - - if (suffix_len > str_len) { - return (((mp_obj_t)&mp_const_false_obj)); - } - return mp_obj_new_bool(memcmp(str + (str_len - suffix_len), suffix, suffix_len) == 0); -} -const mp_obj_fun_builtin_var_t str_endswith_obj = {{&mp_type_fun_builtin_var}, -# 753 "user/mpy/py/objstr.c" 3 4 -0 -# 753 "user/mpy/py/objstr.c" -, 2, 3, .fun.var = str_endswith}; - -enum { LSTRIP, RSTRIP, STRIP }; - -static mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) { - -# 758 "user/mpy/py/objstr.c" 3 - (( -# 758 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) -# 758 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 758, __func__, -# 758 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" -# 758 "user/mpy/py/objstr.c" 3 - )) -# 758 "user/mpy/py/objstr.c" - ; - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - - const byte *chars_to_del; - uint chars_to_del_len; - static const byte whitespace[] = " \t\n\r\v\f"; - - if (n_args == 1) { - chars_to_del = whitespace; - chars_to_del_len = sizeof(whitespace); - } else { - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - const byte *s; size_t l; if (MP_OBJ_IS_QSTR(args[1])) { s = qstr_data((((mp_uint_t)(args[1])) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)args[1]))->len; s = ((mp_obj_str_t*)((void*)args[1]))->data; }; - chars_to_del = s; - chars_to_del_len = l; - } - - const byte *orig_str; size_t orig_str_len; if (MP_OBJ_IS_QSTR(args[0])) { orig_str = qstr_data((((mp_uint_t)(args[0])) >> 2), &orig_str_len); } else { orig_str_len = ((mp_obj_str_t*)((void*)args[0]))->len; orig_str = ((mp_obj_str_t*)((void*)args[0]))->data; }; - - size_t first_good_char_pos = 0; - -# 780 "user/mpy/py/objstr.c" 3 4 - _Bool -# 780 "user/mpy/py/objstr.c" - first_good_char_pos_set = -# 780 "user/mpy/py/objstr.c" 3 4 - 0 -# 780 "user/mpy/py/objstr.c" - ; - size_t last_good_char_pos = 0; - size_t i = 0; - int delta = 1; - if (type == RSTRIP) { - i = orig_str_len - 1; - delta = -1; - } - for (size_t len = orig_str_len; len > 0; len--) { - if (find_subbytes(chars_to_del, chars_to_del_len, &orig_str[i], 1, 1) == -# 789 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 789 "user/mpy/py/objstr.c" - ) { - if (!first_good_char_pos_set) { - first_good_char_pos_set = -# 791 "user/mpy/py/objstr.c" 3 4 - 1 -# 791 "user/mpy/py/objstr.c" - ; - first_good_char_pos = i; - if (type == LSTRIP) { - last_good_char_pos = orig_str_len - 1; - break; - } else if (type == RSTRIP) { - first_good_char_pos = 0; - last_good_char_pos = i; - break; - } - } - last_good_char_pos = i; - } - i += delta; - } - - if (!first_good_char_pos_set) { - - if (self_type == &mp_type_str) { - return ((mp_obj_t)((((mp_uint_t)(MP_QSTR_)) << 2) | 2)); - } else { - return (((mp_obj_t)&mp_const_empty_bytes_obj)); - } - } - - -# 816 "user/mpy/py/objstr.c" 3 - (( -# 816 "user/mpy/py/objstr.c" - last_good_char_pos >= first_good_char_pos -# 816 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 816, __func__, -# 816 "user/mpy/py/objstr.c" - "last_good_char_pos >= first_good_char_pos" -# 816 "user/mpy/py/objstr.c" 3 - )) -# 816 "user/mpy/py/objstr.c" - ; - - size_t stripped_len = last_good_char_pos - first_good_char_pos + 1; - if (stripped_len == orig_str_len) { - - - -# 822 "user/mpy/py/objstr.c" 3 - (( -# 822 "user/mpy/py/objstr.c" - first_good_char_pos == 0 -# 822 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 822, __func__, -# 822 "user/mpy/py/objstr.c" - "first_good_char_pos == 0" -# 822 "user/mpy/py/objstr.c" 3 - )) -# 822 "user/mpy/py/objstr.c" - ; - return args[0]; - } - return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len); -} - -static mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) { - return str_uni_strip(STRIP, n_args, args); -} -const mp_obj_fun_builtin_var_t str_strip_obj = {{&mp_type_fun_builtin_var}, -# 831 "user/mpy/py/objstr.c" 3 4 -0 -# 831 "user/mpy/py/objstr.c" -, 1, 2, .fun.var = str_strip}; - -static mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) { - return str_uni_strip(LSTRIP, n_args, args); -} -const mp_obj_fun_builtin_var_t str_lstrip_obj = {{&mp_type_fun_builtin_var}, -# 836 "user/mpy/py/objstr.c" 3 4 -0 -# 836 "user/mpy/py/objstr.c" -, 1, 2, .fun.var = str_lstrip}; - -static mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) { - return str_uni_strip(RSTRIP, n_args, args); -} -const mp_obj_fun_builtin_var_t str_rstrip_obj = {{&mp_type_fun_builtin_var}, -# 841 "user/mpy/py/objstr.c" 3 4 -0 -# 841 "user/mpy/py/objstr.c" -, 1, 2, .fun.var = str_rstrip}; -# 863 "user/mpy/py/objstr.c" -static const char *str_to_int(const char *str, const char *top, int *num) { - if (str < top && '0' <= *str && *str <= '9') { - *num = 0; - do { - *num = *num * 10 + (*str - '0'); - str++; - } - while (str < top && '0' <= *str && *str <= '9'); - } - return str; -} - -static -# 875 "user/mpy/py/objstr.c" 3 4 - _Bool -# 875 "user/mpy/py/objstr.c" - isalignment(char ch) { - return ch && strchr("<>=^", ch) != -# 876 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 876 "user/mpy/py/objstr.c" - ; -} - -static -# 879 "user/mpy/py/objstr.c" 3 4 - _Bool -# 879 "user/mpy/py/objstr.c" - istype(char ch) { - return ch && strchr("bcdeEfFgGnosxX%", ch) != -# 880 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 880 "user/mpy/py/objstr.c" - ; -} - -static -# 883 "user/mpy/py/objstr.c" 3 4 - _Bool -# 883 "user/mpy/py/objstr.c" - arg_looks_integer(mp_obj_t arg) { - return (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_bool))) || (MP_OBJ_IS_SMALL_INT(arg) || (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_int)))); -} - -static -# 887 "user/mpy/py/objstr.c" 3 4 - _Bool -# 887 "user/mpy/py/objstr.c" - arg_looks_numeric(mp_obj_t arg) { - return arg_looks_integer(arg) - - - - ; -} - -static mp_obj_t arg_as_int(mp_obj_t arg) { - - - - - - return arg; -} - - -static __attribute__((noreturn)) void terse_str_format_value_error(void) { - mp_raise_ValueError("bad format string"); -} - - - - - -static vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - - for (; str < top; str++) { - if (*str == '}') { - str++; - if (str < top && *str == '}') { - vstr_add_byte(&vstr, '}'); - continue; - } - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("single '}' encountered in format string"); - } - } - if (*str != '{') { - vstr_add_byte(&vstr, *str); - continue; - } - - str++; - if (str < top && *str == '{') { - vstr_add_byte(&vstr, '{'); - continue; - } - - - - const char *field_name = -# 944 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 944 "user/mpy/py/objstr.c" - ; - const char *field_name_top = -# 945 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 945 "user/mpy/py/objstr.c" - ; - char conversion = '\0'; - const char *format_spec = -# 947 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 947 "user/mpy/py/objstr.c" - ; - - if (str < top && *str != '}' && *str != '!' && *str != ':') { - field_name = (const char *)str; - while (str < top && *str != '}' && *str != '!' && *str != ':') { - ++str; - } - field_name_top = (const char *)str; - } - - - - if (str < top && *str == '!') { - str++; - if (str < top && (*str == 'r' || *str == 's')) { - conversion = *str++; - } else { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else if (((1)) == (2)) { - mp_raise_ValueError("bad conversion specifier"); - } else { - if (str >= top) { - mp_raise_ValueError( - "end of format while looking for conversion specifier"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown conversion specifier %c", *str))) - ; - } - } - } - } - - if (str < top && *str == ':') { - str++; - - - - - - if (*str != '}') { - format_spec = str; - for (int nest = 1; str < top;) { - if (*str == '{') { - ++nest; - } else if (*str == '}') { - if (--nest == 0) { - break; - } - } - ++str; - } - } - } - if (str >= top) { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("unmatched '{' in format"); - } - } - if (*str != '}') { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("expected ':' after format specifier"); - } - } - - mp_obj_t arg = (((mp_obj_t)&mp_const_none_obj)); - - if (field_name) { - int index = 0; - if (__builtin_expect((unichar_isdigit(*field_name)), 1)) { - if (*arg_i > 0) { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "can't switch from automatic field numbering to manual field specification"); - } - } - field_name = str_to_int(field_name, field_name_top, &index); - if ((uint)index >= n_args - 1) { - mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); - } - arg = args[index + 1]; - *arg_i = -1; - } else { - const char *lookup; - for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++); - mp_obj_t field_q = mp_obj_new_str(field_name, lookup - field_name, -# 1038 "user/mpy/py/objstr.c" 3 4 - 1 -# 1038 "user/mpy/py/objstr.c" - ); - field_name = lookup; - mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP); - if (key_elem == -# 1041 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1041 "user/mpy/py/objstr.c" - ) { - nlr_jump(((void*)mp_obj_new_exception_arg1(&mp_type_KeyError, field_q))); - } - arg = key_elem->value; - } - if (field_name < field_name_top) { - mp_raise_NotImplementedError("attributes not supported yet"); - } - } else { - if (*arg_i < 0) { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "can't switch from manual field specification to automatic field numbering"); - } - } - if ((uint)*arg_i >= n_args - 1) { - mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); - } - arg = args[(*arg_i) + 1]; - (*arg_i)++; - } - if (!format_spec && !conversion) { - conversion = 's'; - } - if (conversion) { - mp_print_kind_t print_kind; - if (conversion == 's') { - print_kind = PRINT_STR; - } else { - -# 1072 "user/mpy/py/objstr.c" 3 - (( -# 1072 "user/mpy/py/objstr.c" - conversion == 'r' -# 1072 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1072, __func__, -# 1072 "user/mpy/py/objstr.c" - "conversion == 'r'" -# 1072 "user/mpy/py/objstr.c" 3 - )) -# 1072 "user/mpy/py/objstr.c" - ; - print_kind = PRINT_REPR; - } - vstr_t arg_vstr; - mp_print_t arg_print; - vstr_init_print(&arg_vstr, 16, &arg_print); - mp_obj_print_helper(&arg_print, arg, print_kind); - arg = mp_obj_new_str_from_vstr(&mp_type_str, &arg_vstr); - } - - char fill = '\0'; - char align = '\0'; - int width = -1; - int precision = -1; - char type = '\0'; - int flags = 0; - - if (format_spec) { -# 1101 "user/mpy/py/objstr.c" - ; - vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs); - const char *s = vstr_null_terminated_str(&format_spec_vstr); - const char *stop = s + format_spec_vstr.len; - if (isalignment(*s)) { - align = *s++; - } else if (*s && isalignment(s[1])) { - fill = *s++; - align = *s++; - } - if (*s == '+' || *s == '-' || *s == ' ') { - if (*s == '+') { - flags |= (0x002); - } else if (*s == ' ') { - flags |= (0x004); - } - s++; - } - if (*s == '#') { - flags |= (0x010); - s++; - } - if (*s == '0') { - if (!align) { - align = '='; - } - if (!fill) { - fill = '0'; - } - } - s = str_to_int(s, stop, &width); - if (*s == ',') { - flags |= (0x020); - s++; - } - if (*s == '.') { - s++; - s = str_to_int(s, stop, &precision); - } - if (istype(*s)) { - type = *s++; - } - if (*s) { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("invalid format specifier"); - } - } - vstr_clear(&format_spec_vstr); - } - if (!align) { - if (arg_looks_numeric(arg)) { - align = '>'; - } else { - align = '<'; - } - } - if (!fill) { - fill = ' '; - } - - if (flags & ((0x002) | (0x004))) { - if (type == 's') { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("sign not allowed in string format specifier"); - } - } - if (type == 'c') { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "sign not allowed with integer format specifier 'c'"); - } - } - } - - switch (align) { - case '<': flags |= (0x001); break; - case '=': flags |= (0x040); break; - case '^': flags |= (0x080); break; - } - - if (arg_looks_integer(arg)) { - switch (type) { - case 'b': - mp_print_mp_int(&print, arg, 2, 'a', flags, fill, width, 0); - continue; - - case 'c': - { - char ch = mp_obj_get_int(arg); - mp_print_strn(&print, &ch, 1, flags, fill, width); - continue; - } - - case '\0': - case 'n': - case 'd': - mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0); - continue; - - case 'o': - if (flags & (0x010)) { - flags |= (0x200); - } - - mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, 0); - continue; - - case 'X': - case 'x': - mp_print_mp_int(&print, arg, 16, type - ('X' - 'A'), flags, fill, width, 0); - continue; - - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - case '%': - - - break; - - default: - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown format code '%c' for object of type '%s'", type, mp_obj_get_type_str(arg)))) - - ; - } - } - } - - - - if (arg_looks_numeric(arg)) { - if (!type) { -# 1273 "user/mpy/py/objstr.c" - type = 'g'; - } - if (type == 'n') { - type = 'g'; - } - - switch (type) { -# 1302 "user/mpy/py/objstr.c" - default: - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown format code '%c' for object of type 'float'", type, mp_obj_get_type_str(arg)))) - - ; - } - } - } else { - - - if (align == '=') { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "'=' alignment not allowed in string format specifier"); - } - } - - switch (type) { - case '\0': - case 's': { - size_t slen; - const char *s = mp_obj_str_get_data(arg, &slen); - if (precision < 0) { - precision = slen; - } - if (slen > (size_t)precision) { - slen = precision; - } - mp_print_strn(&print, s, slen, flags, fill, width); - break; - } - - default: - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown format code '%c' for object of type 'str'", type, mp_obj_get_type_str(arg)))) - - ; - } - } - } - } - - return vstr; -} - -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - -# 1354 "user/mpy/py/objstr.c" 3 - (( -# 1354 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) -# 1354 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1354, __func__, -# 1354 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" -# 1354 "user/mpy/py/objstr.c" 3 - )) -# 1354 "user/mpy/py/objstr.c" - ; - - const byte *str; size_t len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; - int arg_i = 0; - vstr_t vstr = mp_obj_str_format_helper((const char*)str, (const char*)str + len, &arg_i, n_args, args, kwargs); - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); -} -const mp_obj_fun_builtin_var_t str_format_obj = {{&mp_type_fun_builtin_var}, -# 1361 "user/mpy/py/objstr.c" 3 4 -1 -# 1361 "user/mpy/py/objstr.c" -, 1, (0xffff), .fun.kw = mp_obj_str_format}; - -static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) { - -# 1364 "user/mpy/py/objstr.c" 3 - (( -# 1364 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(pattern) || (MP_OBJ_IS_OBJ(pattern) && ((mp_obj_base_t*)((void*)pattern))->type->binary_op == mp_obj_str_binary_op)) -# 1364 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1364, __func__, -# 1364 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(pattern) || (MP_OBJ_IS_OBJ(pattern) && ((mp_obj_base_t*)((void*)pattern))->type->binary_op == mp_obj_str_binary_op))" -# 1364 "user/mpy/py/objstr.c" 3 - )) -# 1364 "user/mpy/py/objstr.c" - ; - - const byte *str; size_t len; if (MP_OBJ_IS_QSTR(pattern)) { str = qstr_data((((mp_uint_t)(pattern)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)pattern))->len; str = ((mp_obj_str_t*)((void*)pattern))->data; }; - const byte *start_str = str; - -# 1368 "user/mpy/py/objstr.c" 3 4 - _Bool -# 1368 "user/mpy/py/objstr.c" - is_bytes = (MP_OBJ_IS_OBJ(pattern) && (((mp_obj_base_t*)((void*)pattern))->type == (&mp_type_bytes))); - size_t arg_i = 0; - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - - for (const byte *top = str + len; str < top; str++) { - mp_obj_t arg = (((mp_obj_t)(void*)0)); - if (*str != '%') { - vstr_add_byte(&vstr, *str); - continue; - } - if (++str >= top) { - goto incomplete_format; - } - if (*str == '%') { - vstr_add_byte(&vstr, '%'); - continue; - } - - - if (*str == '(') { - if (dict == (((mp_obj_t)(void*)0))) { - mp_raise_TypeError("format requires a dict"); - } - arg_i = 1; - const byte *key = ++str; - while (*str != ')') { - if (str >= top) { - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("incomplete format key"); - } - } - ++str; - } - mp_obj_t k_obj = mp_obj_new_str((const char*)key, str - key, -# 1405 "user/mpy/py/objstr.c" 3 4 - 1 -# 1405 "user/mpy/py/objstr.c" - ); - arg = mp_obj_dict_get(dict, k_obj); - str++; - } - - int flags = 0; - char fill = ' '; - int alt = 0; - while (str < top) { - if (*str == '-') flags |= (0x001); - else if (*str == '+') flags |= (0x002); - else if (*str == ' ') flags |= (0x004); - else if (*str == '#') alt = (0x010); - else if (*str == '0') { - flags |= (0x040); - fill = '0'; - } else break; - str++; - } - - int width = 0; - if (str < top) { - if (*str == '*') { - if (arg_i >= n_args) { - goto not_enough_args; - } - width = mp_obj_get_int(args[arg_i++]); - str++; - } else { - str = (const byte*)str_to_int((const char*)str, (const char*)top, &width); - } - } - int prec = -1; - if (str < top && *str == '.') { - if (++str < top) { - if (*str == '*') { - if (arg_i >= n_args) { - goto not_enough_args; - } - prec = mp_obj_get_int(args[arg_i++]); - str++; - } else { - prec = 0; - str = (const byte*)str_to_int((const char*)str, (const char*)top, &prec); - } - } - } - - if (str >= top) { -incomplete_format: - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("incomplete format"); - } - } - - - if (arg == (((mp_obj_t)(void*)0))) { - if (arg_i >= n_args) { -not_enough_args: - mp_raise_TypeError("not enough arguments for format string"); - } - arg = args[arg_i++]; - } - switch (*str) { - case 'c': - if ((MP_OBJ_IS_QSTR(arg) || (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_str))))) { - size_t slen; - const char *s = mp_obj_str_get_data(arg, &slen); - if (slen != 1) { - mp_raise_TypeError("%%c requires int or char"); - } - mp_print_strn(&print, s, 1, flags, ' ', width); - } else if (arg_looks_integer(arg)) { - char ch = mp_obj_get_int(arg); - mp_print_strn(&print, &ch, 1, flags, ' ', width); - } else { - mp_raise_TypeError("integer required"); - } - break; - - case 'd': - case 'i': - case 'u': - mp_print_mp_int(&print, arg_as_int(arg), 10, 'a', flags, fill, width, prec); - break; -# 1504 "user/mpy/py/objstr.c" - case 'o': - if (alt) { - flags |= ((0x010) | (0x200)); - } - mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, prec); - break; - - case 'r': - case 's': - { - vstr_t arg_vstr; - mp_print_t arg_print; - vstr_init_print(&arg_vstr, 16, &arg_print); - mp_print_kind_t print_kind = (*str == 'r' ? PRINT_REPR : PRINT_STR); - if (print_kind == PRINT_STR && is_bytes && (MP_OBJ_IS_OBJ(arg) && (((mp_obj_base_t*)((void*)arg))->type == (&mp_type_bytes)))) { - - - print_kind = PRINT_RAW; - } - mp_obj_print_helper(&arg_print, arg, print_kind); - uint vlen = arg_vstr.len; - if (prec < 0) { - prec = vlen; - } - if (vlen > (uint)prec) { - vlen = prec; - } - mp_print_strn(&print, arg_vstr.buf, vlen, flags, ' ', width); - vstr_clear(&arg_vstr); - break; - } - - case 'X': - case 'x': - mp_print_mp_int(&print, arg, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec); - break; - - default: - if (((1)) == (1)) { - terse_str_format_value_error(); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unsupported format character '%c' (0x%x) at index %d", *str, *str, str - start_str))) - - ; - } - } - } - - if (arg_i != n_args) { - mp_raise_TypeError("not all arguments converted during string formatting"); - } - - return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr); -} - - - -static mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) { - -# 1562 "user/mpy/py/objstr.c" 3 - (( -# 1562 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) -# 1562 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1562, __func__, -# 1562 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" -# 1562 "user/mpy/py/objstr.c" 3 - )) -# 1562 "user/mpy/py/objstr.c" - ; - - mp_int_t max_rep = -1; - if (n_args == 4) { - max_rep = mp_obj_get_int(args[3]); - if (max_rep == 0) { - return args[0]; - } else if (max_rep < 0) { - max_rep = -1; - } - } - - - - - - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - - if (mp_obj_get_type(args[2]) != self_type) { - bad_implicit_conversion(args[2]); - } - - - - const byte *str; size_t str_len; if (MP_OBJ_IS_QSTR(args[0])) { str = qstr_data((((mp_uint_t)(args[0])) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)args[0]))->len; str = ((mp_obj_str_t*)((void*)args[0]))->data; }; - const byte *old; size_t old_len; if (MP_OBJ_IS_QSTR(args[1])) { old = qstr_data((((mp_uint_t)(args[1])) >> 2), &old_len); } else { old_len = ((mp_obj_str_t*)((void*)args[1]))->len; old = ((mp_obj_str_t*)((void*)args[1]))->data; }; - const byte *new; size_t new_len; if (MP_OBJ_IS_QSTR(args[2])) { new = qstr_data((((mp_uint_t)(args[2])) >> 2), &new_len); } else { new_len = ((mp_obj_str_t*)((void*)args[2]))->len; new = ((mp_obj_str_t*)((void*)args[2]))->data; }; - - - if (old_len > str_len) { - return args[0]; - } - - - byte *data = -# 1600 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1600 "user/mpy/py/objstr.c" - ; - vstr_t vstr; - - - - - for (;;) { - size_t replaced_str_index = 0; - size_t num_replacements_done = 0; - const byte *old_occurrence; - const byte *offset_ptr = str; - size_t str_len_remain = str_len; - if (old_len == 0) { - - - if (data != -# 1615 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1615 "user/mpy/py/objstr.c" - ) { - memcpy(data, new, new_len); - } - replaced_str_index += new_len; - num_replacements_done++; - } - while (num_replacements_done != (size_t)max_rep && str_len_remain > 0 && (old_occurrence = find_subbytes(offset_ptr, str_len_remain, old, old_len, 1)) != -# 1621 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1621 "user/mpy/py/objstr.c" - ) { - if (old_len == 0) { - old_occurrence += 1; - } - - if (data != -# 1626 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1626 "user/mpy/py/objstr.c" - ) { - memcpy(data + replaced_str_index, offset_ptr, old_occurrence - offset_ptr); - } - replaced_str_index += old_occurrence - offset_ptr; - - if (data != -# 1631 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1631 "user/mpy/py/objstr.c" - ) { - memcpy(data + replaced_str_index, new, new_len); - } - replaced_str_index += new_len; - offset_ptr = old_occurrence + old_len; - str_len_remain = str + str_len - offset_ptr; - num_replacements_done++; - } - - - if (data != -# 1641 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1641 "user/mpy/py/objstr.c" - ) { - memcpy(data + replaced_str_index, offset_ptr, str_len_remain); - } - replaced_str_index += str_len_remain; - - if (data == -# 1646 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1646 "user/mpy/py/objstr.c" - ) { - - if (num_replacements_done == 0) { - - return args[0]; - } else { - - vstr_init_len(&vstr, replaced_str_index); - data = (byte*)vstr.buf; - -# 1655 "user/mpy/py/objstr.c" 3 - (( -# 1655 "user/mpy/py/objstr.c" - data != -# 1655 "user/mpy/py/objstr.c" 3 4 - ((void *)0)) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1655, __func__, -# 1655 "user/mpy/py/objstr.c" - "data != NULL" -# 1655 "user/mpy/py/objstr.c" 3 - )) -# 1655 "user/mpy/py/objstr.c" - ; - } - } else { - - break; - } - } - - return mp_obj_new_str_from_vstr(self_type, &vstr); -} -const mp_obj_fun_builtin_var_t str_replace_obj = {{&mp_type_fun_builtin_var}, -# 1665 "user/mpy/py/objstr.c" 3 4 -0 -# 1665 "user/mpy/py/objstr.c" -, 3, 4, .fun.var = str_replace}; - -static mp_obj_t str_count(size_t n_args, const mp_obj_t *args) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - -# 1669 "user/mpy/py/objstr.c" 3 - (( -# 1669 "user/mpy/py/objstr.c" - (MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op)) -# 1669 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 1669, __func__, -# 1669 "user/mpy/py/objstr.c" - "(MP_OBJ_IS_QSTR(args[0]) || (MP_OBJ_IS_OBJ(args[0]) && ((mp_obj_base_t*)((void*)args[0]))->type->binary_op == mp_obj_str_binary_op))" -# 1669 "user/mpy/py/objstr.c" 3 - )) -# 1669 "user/mpy/py/objstr.c" - ; - - - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - - const byte *haystack; size_t haystack_len; if (MP_OBJ_IS_QSTR(args[0])) { haystack = qstr_data((((mp_uint_t)(args[0])) >> 2), &haystack_len); } else { haystack_len = ((mp_obj_str_t*)((void*)args[0]))->len; haystack = ((mp_obj_str_t*)((void*)args[0]))->data; }; - const byte *needle; size_t needle_len; if (MP_OBJ_IS_QSTR(args[1])) { needle = qstr_data((((mp_uint_t)(args[1])) >> 2), &needle_len); } else { needle_len = ((mp_obj_str_t*)((void*)args[1]))->len; needle = ((mp_obj_str_t*)((void*)args[1]))->data; }; - - const byte *start = haystack; - const byte *end = haystack + haystack_len; - if (n_args >= 3 && args[2] != (((mp_obj_t)&mp_const_none_obj))) { - start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], -# 1682 "user/mpy/py/objstr.c" 3 4 - 1 -# 1682 "user/mpy/py/objstr.c" - ); - } - if (n_args >= 4 && args[3] != (((mp_obj_t)&mp_const_none_obj))) { - end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], -# 1685 "user/mpy/py/objstr.c" 3 4 - 1 -# 1685 "user/mpy/py/objstr.c" - ); - } - - - if (needle_len == 0) { - return ((mp_obj_t)((((mp_uint_t)(unichar_charlen((const char*)start, end - start) + 1)) << 1) | 1)); - } - - - mp_int_t num_occurrences = 0; - for (const byte *haystack_ptr = start; haystack_ptr + needle_len <= end;) { - if (memcmp(haystack_ptr, needle, needle_len) == 0) { - num_occurrences++; - haystack_ptr += needle_len; - } else { - haystack_ptr = utf8_next_char(haystack_ptr); - } - } - - return ((mp_obj_t)((((mp_uint_t)(num_occurrences)) << 1) | 1)); -} -const mp_obj_fun_builtin_var_t str_count_obj = {{&mp_type_fun_builtin_var}, -# 1706 "user/mpy/py/objstr.c" 3 4 -0 -# 1706 "user/mpy/py/objstr.c" -, 2, 4, .fun.var = str_count}; -# 1763 "user/mpy/py/objstr.c" -static mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) { - const byte *self_data; size_t self_len; if (MP_OBJ_IS_QSTR(self_in)) { self_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &self_len); } else { self_len = ((mp_obj_str_t*)((void*)self_in))->len; self_data = ((mp_obj_str_t*)((void*)self_in))->data; }; - vstr_t vstr; - vstr_init_len(&vstr, self_len); - byte *data = (byte*)vstr.buf; - for (size_t i = 0; i < self_len; i++) { - *data++ = op(*self_data++); - } - return mp_obj_new_str_from_vstr(mp_obj_get_type(self_in), &vstr); -} - -static mp_obj_t str_lower(mp_obj_t self_in) { - return str_caseconv(unichar_tolower, self_in); -} -const mp_obj_fun_builtin_fixed_t str_lower_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_lower}; - -static mp_obj_t str_upper(mp_obj_t self_in) { - return str_caseconv(unichar_toupper, self_in); -} -const mp_obj_fun_builtin_fixed_t str_upper_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_upper}; - -static mp_obj_t str_uni_istype( -# 1784 "user/mpy/py/objstr.c" 3 4 - _Bool -# 1784 "user/mpy/py/objstr.c" - (*f)(unichar), mp_obj_t self_in) { - const byte *self_data; size_t self_len; if (MP_OBJ_IS_QSTR(self_in)) { self_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &self_len); } else { self_len = ((mp_obj_str_t*)((void*)self_in))->len; self_data = ((mp_obj_str_t*)((void*)self_in))->data; }; - - if (self_len == 0) { - return (((mp_obj_t)&mp_const_false_obj)); - } - - if (f != unichar_isupper && f != unichar_islower) { - for (size_t i = 0; i < self_len; i++) { - if (!f(*self_data++)) { - return (((mp_obj_t)&mp_const_false_obj)); - } - } - } else { - -# 1798 "user/mpy/py/objstr.c" 3 4 - _Bool -# 1798 "user/mpy/py/objstr.c" - contains_alpha = -# 1798 "user/mpy/py/objstr.c" 3 4 - 0 -# 1798 "user/mpy/py/objstr.c" - ; - - for (size_t i = 0; i < self_len; i++) { - if (unichar_isalpha(*self_data++)) { - contains_alpha = -# 1802 "user/mpy/py/objstr.c" 3 4 - 1 -# 1802 "user/mpy/py/objstr.c" - ; - if (!f(*(self_data - 1))) { - return (((mp_obj_t)&mp_const_false_obj)); - } - } - } - - if (!contains_alpha) { - return (((mp_obj_t)&mp_const_false_obj)); - } - } - - return (((mp_obj_t)&mp_const_true_obj)); -} - -static mp_obj_t str_isspace(mp_obj_t self_in) { - return str_uni_istype(unichar_isspace, self_in); -} -const mp_obj_fun_builtin_fixed_t str_isspace_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isspace}; - -static mp_obj_t str_isalpha(mp_obj_t self_in) { - return str_uni_istype(unichar_isalpha, self_in); -} -const mp_obj_fun_builtin_fixed_t str_isalpha_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isalpha}; - -static mp_obj_t str_isdigit(mp_obj_t self_in) { - return str_uni_istype(unichar_isdigit, self_in); -} -const mp_obj_fun_builtin_fixed_t str_isdigit_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isdigit}; - -static mp_obj_t str_isupper(mp_obj_t self_in) { - return str_uni_istype(unichar_isupper, self_in); -} -const mp_obj_fun_builtin_fixed_t str_isupper_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_isupper}; - -static mp_obj_t str_islower(mp_obj_t self_in) { - return str_uni_istype(unichar_islower, self_in); -} -const mp_obj_fun_builtin_fixed_t str_islower_obj = {{&mp_type_fun_builtin_1}, .fun._1 = str_islower}; -# 1872 "user/mpy/py/objstr.c" -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - if (flags == (1)) { - const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(self_in)) { str_data = qstr_data((((mp_uint_t)(self_in)) >> 2), &str_len); } else { str_len = ((mp_obj_str_t*)((void*)self_in))->len; str_data = ((mp_obj_str_t*)((void*)self_in))->data; }; - bufinfo->buf = (void*)str_data; - bufinfo->len = str_len; - bufinfo->typecode = 'B'; - return 0; - } else { - - bufinfo->buf = -# 1881 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1881 "user/mpy/py/objstr.c" - ; - bufinfo->len = 0; - bufinfo->typecode = -1; - return 1; - } -} - -static const mp_rom_map_elem_t str8_locals_dict_table[] = { -# 1900 "user/mpy/py/objstr.c" - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_find)) << 2) | 2)), (&str_find_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rfind)) << 2) | 2)), (&str_rfind_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_index)) << 2) | 2)), (&str_index_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rindex)) << 2) | 2)), (&str_rindex_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_join)) << 2) | 2)), (&str_join_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_split)) << 2) | 2)), (&str_split_obj) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rsplit)) << 2) | 2)), (&str_rsplit_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_startswith)) << 2) | 2)), (&str_startswith_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_endswith)) << 2) | 2)), (&str_endswith_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_strip)) << 2) | 2)), (&str_strip_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_lstrip)) << 2) | 2)), (&str_lstrip_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_rstrip)) << 2) | 2)), (&str_rstrip_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_format)) << 2) | 2)), (&str_format_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_replace)) << 2) | 2)), (&str_replace_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_count)) << 2) | 2)), (&str_count_obj) }, - - - - - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_lower)) << 2) | 2)), (&str_lower_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_upper)) << 2) | 2)), (&str_upper_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isspace)) << 2) | 2)), (&str_isspace_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isalpha)) << 2) | 2)), (&str_isalpha_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isdigit)) << 2) | 2)), (&str_isdigit_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isupper)) << 2) | 2)), (&str_isupper_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_islower)) << 2) | 2)), (&str_islower_obj) }, -}; - -static const mp_obj_dict_t str8_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(str8_locals_dict_table) / sizeof((str8_locals_dict_table)[0])), .alloc = (sizeof(str8_locals_dict_table) / sizeof((str8_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)str8_locals_dict_table, }, }; - - -static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); - -const mp_obj_type_t mp_type_str = { - { &mp_type_type }, - .name = MP_QSTR_str, - .print = str_print, - .make_new = mp_obj_str_make_new, - .binary_op = mp_obj_str_binary_op, - .subscr = bytes_subscr, - .getiter = mp_obj_new_str_iterator, - .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, -}; - - - -const mp_obj_type_t mp_type_bytes = { - { &mp_type_type }, - .name = MP_QSTR_bytes, - .print = str_print, - .make_new = bytes_make_new, - .binary_op = mp_obj_str_binary_op, - .subscr = bytes_subscr, - .getiter = mp_obj_new_bytes_iterator, - .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, -}; - - -const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, -# 1966 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 1966 "user/mpy/py/objstr.c" - }; - - - -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len) { - mp_obj_str_t *o = (((mp_obj_str_t*)(m_malloc(sizeof(mp_obj_str_t) * (1))))); - o->base.type = type; - o->len = len; - if (data) { - o->hash = qstr_compute_hash(data, len); - byte *p = ((byte*)(m_malloc(sizeof(byte) * (len + 1)))); - o->data = p; - memcpy(p, data, len * sizeof(byte)); - p[len] = '\0'; - } - return ((mp_obj_t)o); -} - - - - -mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) { - - if (type == &mp_type_str) { - qstr q = qstr_find_strn(vstr->buf, vstr->len); - if (q != MP_QSTR_NULL) { - vstr_clear(vstr); - vstr->alloc = 0; - return ((mp_obj_t)((((mp_uint_t)(q)) << 2) | 2)); - } - } - - - mp_obj_str_t *o = (((mp_obj_str_t*)(m_malloc(sizeof(mp_obj_str_t) * (1))))); - o->base.type = type; - o->len = vstr->len; - o->hash = qstr_compute_hash((byte*)vstr->buf, vstr->len); - if (vstr->len + 1 == vstr->alloc) { - o->data = (byte*)vstr->buf; - } else { - o->data = (byte*)((char*)(m_realloc((vstr->buf), sizeof(char) * (vstr->len + 1)))); - } - ((byte*)o->data)[o->len] = '\0'; - vstr->buf = -# 2009 "user/mpy/py/objstr.c" 3 4 - ((void *)0) -# 2009 "user/mpy/py/objstr.c" - ; - vstr->alloc = 0; - return ((mp_obj_t)o); -} - -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 2014 "user/mpy/py/objstr.c" 3 4 - _Bool -# 2014 "user/mpy/py/objstr.c" - make_qstr_if_not_already) { - if (make_qstr_if_not_already) { - - return ((mp_obj_t)((((mp_uint_t)(qstr_from_strn(data, len))) << 2) | 2)); - } else { - qstr q = qstr_find_strn(data, len); - if (q != MP_QSTR_NULL) { - - return ((mp_obj_t)((((mp_uint_t)(q)) << 2) | 2)); - } else { - - return mp_obj_new_str_of_type(&mp_type_str, (const byte*)data, len); - } - } -} - -mp_obj_t mp_obj_str_intern(mp_obj_t str) { - const byte *data; size_t len; if (MP_OBJ_IS_QSTR(str)) { data = qstr_data((((mp_uint_t)(str)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)str))->len; data = ((mp_obj_str_t*)((void*)str))->data; }; - return ((mp_obj_t)((((mp_uint_t)(qstr_from_strn((const char*)data, len))) << 2) | 2)); -} - -mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) { - return mp_obj_new_str_of_type(&mp_type_bytes, data, len); -} - - -# 2039 "user/mpy/py/objstr.c" 3 4 -_Bool -# 2039 "user/mpy/py/objstr.c" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { - if (MP_OBJ_IS_QSTR(s1) && MP_OBJ_IS_QSTR(s2)) { - return s1 == s2; - } else { - mp_uint_t h1; if (MP_OBJ_IS_QSTR(s1)) { h1 = qstr_hash((((mp_uint_t)(s1)) >> 2)); } else { h1 = ((mp_obj_str_t*)((void*)s1))->hash; }; - mp_uint_t h2; if (MP_OBJ_IS_QSTR(s2)) { h2 = qstr_hash((((mp_uint_t)(s2)) >> 2)); } else { h2 = ((mp_obj_str_t*)((void*)s2))->hash; }; - - if (h1 != 0 && h2 != 0 && h1 != h2) { - return -# 2047 "user/mpy/py/objstr.c" 3 4 - 0 -# 2047 "user/mpy/py/objstr.c" - ; - } - const byte *d1; size_t l1; if (MP_OBJ_IS_QSTR(s1)) { d1 = qstr_data((((mp_uint_t)(s1)) >> 2), &l1); } else { l1 = ((mp_obj_str_t*)((void*)s1))->len; d1 = ((mp_obj_str_t*)((void*)s1))->data; }; - const byte *d2; size_t l2; if (MP_OBJ_IS_QSTR(s2)) { d2 = qstr_data((((mp_uint_t)(s2)) >> 2), &l2); } else { l2 = ((mp_obj_str_t*)((void*)s2))->len; d2 = ((mp_obj_str_t*)((void*)s2))->data; }; - if (l1 != l2) { - return -# 2052 "user/mpy/py/objstr.c" 3 4 - 0 -# 2052 "user/mpy/py/objstr.c" - ; - } - return memcmp(d1, d2, l1) == 0; - } -} - -static void bad_implicit_conversion(mp_obj_t self_in) { - if (((1)) == (1)) { - mp_raise_TypeError("can't convert to str implicitly"); - } else { - const qstr src_name = mp_obj_get_type(self_in)->name; - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't convert '%q' object to %q implicitly", src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str))) - - ; - } -} - - - -qstr mp_obj_str_get_qstr(mp_obj_t self_in) { - if (MP_OBJ_IS_QSTR(self_in)) { - return (((mp_uint_t)(self_in)) >> 2); - } else if ((MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_str)))) { - mp_obj_str_t *self = ((void*)self_in); - return qstr_from_strn((char*)self->data, self->len); - } else { - bad_implicit_conversion(self_in); - } -} - - - -const char *mp_obj_str_get_str(mp_obj_t self_in) { - if ((MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op))) { - const byte *s; size_t l; if (MP_OBJ_IS_QSTR(self_in)) { s = qstr_data((((mp_uint_t)(self_in)) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)self_in))->len; s = ((mp_obj_str_t*)((void*)self_in))->data; }; - (void)l; - return (const char*)s; - } else { - bad_implicit_conversion(self_in); - } -} - -const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len) { - if ((MP_OBJ_IS_QSTR(self_in) || (MP_OBJ_IS_OBJ(self_in) && ((mp_obj_base_t*)((void*)self_in))->type->binary_op == mp_obj_str_binary_op))) { - const byte *s; size_t l; if (MP_OBJ_IS_QSTR(self_in)) { s = qstr_data((((mp_uint_t)(self_in)) >> 2), &l); } else { l = ((mp_obj_str_t*)((void*)self_in))->len; s = ((mp_obj_str_t*)((void*)self_in))->data; }; - *len = l; - return (const char*)s; - } else { - bad_implicit_conversion(self_in); - } -} -# 2118 "user/mpy/py/objstr.c" -typedef struct _mp_obj_str8_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t str; - size_t cur; -} mp_obj_str8_it_t; - - -static mp_obj_t str_it_iternext(mp_obj_t self_in) { - mp_obj_str8_it_t *self = ((void*)self_in); - const byte *str; size_t len; if (MP_OBJ_IS_QSTR(self->str)) { str = qstr_data((((mp_uint_t)(self->str)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)self->str))->len; str = ((mp_obj_str_t*)((void*)self->str))->data; }; - if (self->cur < len) { - mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, -# 2130 "user/mpy/py/objstr.c" 3 4 - 1 -# 2130 "user/mpy/py/objstr.c" - ); - self->cur += 1; - return o_out; - } else { - return (((mp_obj_t)(void*)4)); - } -} - -static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { - -# 2139 "user/mpy/py/objstr.c" 3 - (( -# 2139 "user/mpy/py/objstr.c" - sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t) -# 2139 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 2139, __func__, -# 2139 "user/mpy/py/objstr.c" - "sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 2139 "user/mpy/py/objstr.c" 3 - )) -# 2139 "user/mpy/py/objstr.c" - ; - mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = str_it_iternext; - o->str = str; - o->cur = 0; - return ((mp_obj_t)o); -} - - -static mp_obj_t bytes_it_iternext(mp_obj_t self_in) { - mp_obj_str8_it_t *self = ((void*)self_in); - const byte *str; size_t len; if (MP_OBJ_IS_QSTR(self->str)) { str = qstr_data((((mp_uint_t)(self->str)) >> 2), &len); } else { len = ((mp_obj_str_t*)((void*)self->str))->len; str = ((mp_obj_str_t*)((void*)self->str))->data; }; - if (self->cur < len) { - mp_obj_t o_out = ((mp_obj_t)((((mp_uint_t)(str[self->cur])) << 1) | 1)); - self->cur += 1; - return o_out; - } else { - return (((mp_obj_t)(void*)4)); - } -} - -mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { - -# 2162 "user/mpy/py/objstr.c" 3 - (( -# 2162 "user/mpy/py/objstr.c" - sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t) -# 2162 "user/mpy/py/objstr.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objstr.c", 2162, __func__, -# 2162 "user/mpy/py/objstr.c" - "sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 2162 "user/mpy/py/objstr.c" 3 - )) -# 2162 "user/mpy/py/objstr.c" - ; - mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = bytes_it_iternext; - o->str = str; - o->cur = 0; - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objstrunicode.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objstrunicode.c" -# 28 "user/mpy/py/objstrunicode.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/objstrunicode.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 30 "user/mpy/py/objstrunicode.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objstrunicode.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 29 "user/mpy/py/objstr.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objstr.h" 2 - -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 33 "user/mpy/py/objstrunicode.c" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 34 "user/mpy/py/objstrunicode.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/objstrunicode.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - - -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 36 "user/mpy/py/objstrunicode.c" 2 -# 1 "user/mpy/py/objstringio.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objstringio.c" -# 28 "user/mpy/py/objstringio.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/objstringio.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/objstringio.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/objstringio.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 29 "user/mpy/py/objstr.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objstr.h" 2 - -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 33 "user/mpy/py/objstringio.c" 2 -# 1 "user/mpy/py/objstringio.h" 1 -# 31 "user/mpy/py/objstringio.h" -typedef struct _mp_obj_stringio_t { - mp_obj_base_t base; - vstr_t *vstr; - - mp_uint_t pos; - - mp_obj_t ref_obj; -} mp_obj_stringio_t; -# 34 "user/mpy/py/objstringio.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 35 "user/mpy/py/objstringio.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 36 "user/mpy/py/objstringio.c" 2 -# 1 "user/mpy/py/objtuple.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objtuple.c" -# 27 "user/mpy/py/objtuple.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/objtuple.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objtuple.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/objtuple.c" 2 -# 1 "user/mpy/py/objtuple.h" 1 -# 29 "user/mpy/py/objtuple.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtuple.h" 2 - -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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 32 "user/mpy/py/objtuple.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/objtuple.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 32 "user/mpy/py/objexcept.h" -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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/objtuple.c" 2 - - - - -void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_tuple_t *o = ((void*)o_in); - if ((0) && kind == PRINT_JSON) { - mp_print_str(print, "["); - } else { - mp_print_str(print, "("); - kind = PRINT_REPR; - } - for (size_t i = 0; i < o->len; i++) { - if (i > 0) { - mp_print_str(print, ", "); - } - mp_obj_print_helper(print, o->items[i], kind); - } - if ((0) && kind == PRINT_JSON) { - mp_print_str(print, "]"); - } else { - if (o->len == 1) { - mp_print_str(print, ","); - } - mp_print_str(print, ")"); - } -} - -static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - mp_arg_check_num(n_args, n_kw, 0, 1, -# 65 "user/mpy/py/objtuple.c" 3 4 - 0 -# 65 "user/mpy/py/objtuple.c" - ); - - switch (n_args) { - case 0: - - return (((mp_obj_t)&mp_const_empty_tuple_obj)); - - case 1: - default: { - - if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_tuple)))) { - return args[0]; - } - - - - size_t alloc = 4; - size_t len = 0; - mp_obj_t *items = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (alloc)))); - - mp_obj_t iterable = mp_getiter(args[0], -# 85 "user/mpy/py/objtuple.c" 3 4 - ((void *)0) -# 85 "user/mpy/py/objtuple.c" - ); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - if (len >= alloc) { - items = ((mp_obj_t*)(m_realloc((items), sizeof(mp_obj_t) * (alloc * 2)))); - alloc *= 2; - } - items[len++] = item; - } - - mp_obj_t tuple = mp_obj_new_tuple(len, items); - ((void)(alloc), m_free(items)); - - return tuple; - } - } -} - - -static -# 104 "user/mpy/py/objtuple.c" 3 4 - _Bool -# 104 "user/mpy/py/objtuple.c" - tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { - - -# 106 "user/mpy/py/objtuple.c" 3 - (( -# 106 "user/mpy/py/objtuple.c" - mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter -# 106 "user/mpy/py/objtuple.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 106, __func__, -# 106 "user/mpy/py/objtuple.c" - "mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter" -# 106 "user/mpy/py/objtuple.c" 3 - )) -# 106 "user/mpy/py/objtuple.c" - ; - mp_obj_type_t *another_type = mp_obj_get_type(another_in); - mp_obj_tuple_t *self = ((void*)self_in); - if (another_type->getiter != mp_obj_tuple_getiter) { - - another_in = mp_instance_cast_to_native_base(another_in, ((mp_obj_t)&mp_type_tuple)); - if (another_in == (((mp_obj_t)(void*)0))) { - return -# 113 "user/mpy/py/objtuple.c" 3 4 - 0 -# 113 "user/mpy/py/objtuple.c" - ; - } - } - mp_obj_tuple_t *another = ((void*)another_in); - - return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); -} - -mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_tuple_t *self = ((void*)self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); - case MP_UNARY_OP_HASH: { - - mp_int_t hash = (mp_int_t)(((mp_obj_t)&mp_const_empty_tuple_obj)); - for (size_t i = 0; i < self->len; i++) { - hash += (((mp_int_t)(mp_unary_op(MP_UNARY_OP_HASH, self->items[i]))) >> 1); - } - return ((mp_obj_t)((((mp_uint_t)(hash)) << 1) | 1)); - } - case MP_UNARY_OP_LEN: return ((mp_obj_t)((((mp_uint_t)(self->len)) << 1) | 1)); - default: return (((mp_obj_t)(void*)0)); - } -} - -mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - mp_obj_tuple_t *o = ((void*)lhs); - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: { - if (!mp_obj_is_subclass_fast(((mp_obj_t)mp_obj_get_type(rhs)), ((mp_obj_t)&mp_type_tuple))) { - return (((mp_obj_t)(void*)0)); - } - mp_obj_tuple_t *p = ((void*)rhs); - mp_obj_tuple_t *s = ((void*)mp_obj_new_tuple(o->len + p->len, -# 147 "user/mpy/py/objtuple.c" 3 4 - ((void *)0) -# 147 "user/mpy/py/objtuple.c" - )); - { memcpy(s->items, o->items, (o->len) * sizeof(mp_obj_t)); memcpy(s->items + (o->len), p->items, (p->len) * sizeof(mp_obj_t)); }; - return ((mp_obj_t)s); - } - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: { - mp_int_t n; - if (!mp_obj_get_int_maybe(rhs, &n)) { - return (((mp_obj_t)(void*)0)); - } - if (n <= 0) { - return (((mp_obj_t)&mp_const_empty_tuple_obj)); - } - mp_obj_tuple_t *s = ((void*)mp_obj_new_tuple(o->len * n, -# 160 "user/mpy/py/objtuple.c" 3 4 - ((void *)0) -# 160 "user/mpy/py/objtuple.c" - )); - mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); - return ((mp_obj_t)s); - } - case MP_BINARY_OP_EQUAL: - case MP_BINARY_OP_LESS: - case MP_BINARY_OP_LESS_EQUAL: - case MP_BINARY_OP_MORE: - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(tuple_cmp_helper(op, lhs, rhs)); - - default: - return (((mp_obj_t)(void*)0)); - } -} - -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == (((mp_obj_t)(void*)8))) { - - mp_obj_tuple_t *self = ((void*)self_in); -# 191 "user/mpy/py/objtuple.c" - size_t index_value = mp_get_index(self->base.type, self->len, index, -# 191 "user/mpy/py/objtuple.c" 3 4 - 0 -# 191 "user/mpy/py/objtuple.c" - ); - return self->items[index_value]; - } else { - return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) { - -# 199 "user/mpy/py/objtuple.c" 3 - (( -# 199 "user/mpy/py/objtuple.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple))) -# 199 "user/mpy/py/objtuple.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 199, __func__, -# 199 "user/mpy/py/objtuple.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple)))" -# 199 "user/mpy/py/objtuple.c" 3 - )) -# 199 "user/mpy/py/objtuple.c" - ; - mp_obj_tuple_t *self = ((void*)self_in); - return mp_seq_count_obj(self->items, self->len, value); -} -static const mp_obj_fun_builtin_fixed_t tuple_count_obj = {{&mp_type_fun_builtin_2}, .fun._2 = tuple_count}; - -static mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) { - -# 206 "user/mpy/py/objtuple.c" 3 - (( -# 206 "user/mpy/py/objtuple.c" - (MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_tuple))) -# 206 "user/mpy/py/objtuple.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 206, __func__, -# 206 "user/mpy/py/objtuple.c" - "(MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_tuple)))" -# 206 "user/mpy/py/objtuple.c" 3 - )) -# 206 "user/mpy/py/objtuple.c" - ; - mp_obj_tuple_t *self = ((void*)args[0]); - return mp_seq_index_obj(self->items, self->len, n_args, args); -} -static const mp_obj_fun_builtin_var_t tuple_index_obj = {{&mp_type_fun_builtin_var}, -# 210 "user/mpy/py/objtuple.c" 3 4 - 0 -# 210 "user/mpy/py/objtuple.c" - , 2, 4, .fun.var = tuple_index}; - -static const mp_rom_map_elem_t tuple_locals_dict_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_count)) << 2) | 2)), (&tuple_count_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_index)) << 2) | 2)), (&tuple_index_obj) }, -}; - -static const mp_obj_dict_t tuple_locals_dict = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(tuple_locals_dict_table) / sizeof((tuple_locals_dict_table)[0])), .alloc = (sizeof(tuple_locals_dict_table) / sizeof((tuple_locals_dict_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)tuple_locals_dict_table, }, }; - -const mp_obj_type_t mp_type_tuple = { - { &mp_type_type }, - .name = MP_QSTR_tuple, - .print = mp_obj_tuple_print, - .make_new = mp_obj_tuple_make_new, - .unary_op = mp_obj_tuple_unary_op, - .binary_op = mp_obj_tuple_binary_op, - .subscr = mp_obj_tuple_subscr, - .getiter = mp_obj_tuple_getiter, - .locals_dict = (mp_obj_dict_t*)&tuple_locals_dict, -}; - - -const mp_obj_tuple_t mp_const_empty_tuple_obj = {{&mp_type_tuple}, 0}; - -mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) { - if (n == 0) { - return (((mp_obj_t)&mp_const_empty_tuple_obj)); - } - mp_obj_tuple_t *o = ((mp_obj_tuple_t*)m_malloc(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t) * (n))); - o->base.type = &mp_type_tuple; - o->len = n; - if (items) { - for (size_t i = 0; i < n; i++) { - o->items[i] = items[i]; - } - } - return ((mp_obj_t)o); -} - -void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { - -# 250 "user/mpy/py/objtuple.c" 3 - (( -# 250 "user/mpy/py/objtuple.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple))) -# 250 "user/mpy/py/objtuple.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 250, __func__, -# 250 "user/mpy/py/objtuple.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)" -# 250 "user/mpy/py/objtuple.c" 3 - )) -# 250 "user/mpy/py/objtuple.c" - ; - mp_obj_tuple_t *self = ((void*)self_in); - *len = self->len; - *items = &self->items[0]; -} - -void mp_obj_tuple_del(mp_obj_t self_in) { - -# 257 "user/mpy/py/objtuple.c" 3 - (( -# 257 "user/mpy/py/objtuple.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_tuple))) -# 257 "user/mpy/py/objtuple.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 257, __func__, -# 257 "user/mpy/py/objtuple.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)" -# 257 "user/mpy/py/objtuple.c" 3 - )) -# 257 "user/mpy/py/objtuple.c" - ; - mp_obj_tuple_t *self = ((void*)self_in); - ((void)(self->len), m_free(self)); -} - - - - -typedef struct _mp_obj_tuple_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_tuple_t *tuple; - size_t cur; -} mp_obj_tuple_it_t; - -static mp_obj_t tuple_it_iternext(mp_obj_t self_in) { - mp_obj_tuple_it_t *self = ((void*)self_in); - if (self->cur < self->tuple->len) { - mp_obj_t o_out = self->tuple->items[self->cur]; - self->cur += 1; - return o_out; - } else { - return (((mp_obj_t)(void*)4)); - } -} - -mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - -# 284 "user/mpy/py/objtuple.c" 3 - (( -# 284 "user/mpy/py/objtuple.c" - sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t) -# 284 "user/mpy/py/objtuple.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtuple.c", 284, __func__, -# 284 "user/mpy/py/objtuple.c" - "sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t)" -# 284 "user/mpy/py/objtuple.c" 3 - )) -# 284 "user/mpy/py/objtuple.c" - ; - mp_obj_tuple_it_t *o = (mp_obj_tuple_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = tuple_it_iternext; - o->tuple = ((void*)o_in); - o->cur = 0; - return ((mp_obj_t)o); -} -# 1 "user/mpy/py/objtype.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objtype.c" -# 28 "user/mpy/py/objtype.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/objtype.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/objtype.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/objtype.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/objtype.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 34 "user/mpy/py/objtype.c" 2 -# 1 "user/mpy/py/objtype.h" 1 -# 29 "user/mpy/py/objtype.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtype.h" 2 - - - -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 35 "user/mpy/py/objtype.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 36 "user/mpy/py/objtype.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/objtype.c" 2 -# 46 "user/mpy/py/objtype.c" -static mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -static mp_obj_t mp_obj_new_instance(const mp_obj_type_t *class, size_t subobjs) { - mp_obj_instance_t *o = ((mp_obj_instance_t*)m_malloc(sizeof(mp_obj_instance_t) + sizeof(mp_obj_t) * (subobjs))); - o->base.type = class; - mp_map_init(&o->members, 0); - memset((byte*)(o->subobj) + (0) * (sizeof(*o->subobj)), 0, ((subobjs) - (0)) * (sizeof(*o->subobj))); - return ((mp_obj_t)o); -} - -static int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) { - int count = 0; - for (;;) { - if (type == &mp_type_object) { - - return count; - } else if (((type)->make_new != mp_obj_instance_make_new)) { - - *last_native_base = type; - return count + 1; - } else if (type->parent == -# 69 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 69 "user/mpy/py/objtype.c" - ) { - - return count; - } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { - - const mp_obj_tuple_t *parent_tuple = type->parent; - const mp_obj_t *item = parent_tuple->items; - const mp_obj_t *top = item + parent_tuple->len; - for (; item < top; ++item) { - -# 78 "user/mpy/py/objtype.c" 3 - (( -# 78 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(*item) && (((mp_obj_base_t*)((void*)*item))->type == (&mp_type_type))) -# 78 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 78, __func__, -# 78 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(*item, &mp_type_type)" -# 78 "user/mpy/py/objtype.c" 3 - )) -# 78 "user/mpy/py/objtype.c" - ; - const mp_obj_type_t *bt = (const mp_obj_type_t *)((void*)*item); - count += instance_count_native_bases(bt, last_native_base); - } - return count; - } else { - - type = type->parent; - } - } -} -# 104 "user/mpy/py/objtype.c" -struct class_lookup_data { - mp_obj_instance_t *obj; - qstr attr; - size_t meth_offset; - mp_obj_t *dest; - -# 109 "user/mpy/py/objtype.c" 3 4 - _Bool -# 109 "user/mpy/py/objtype.c" - is_type; -}; - -static void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) { - -# 113 "user/mpy/py/objtype.c" 3 - (( -# 113 "user/mpy/py/objtype.c" - lookup->dest[0] == (((mp_obj_t)(void*)0)) -# 113 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 113, __func__, -# 113 "user/mpy/py/objtype.c" - "lookup->dest[0] == MP_OBJ_NULL" -# 113 "user/mpy/py/objtype.c" 3 - )) -# 113 "user/mpy/py/objtype.c" - ; - -# 114 "user/mpy/py/objtype.c" 3 - (( -# 114 "user/mpy/py/objtype.c" - lookup->dest[1] == (((mp_obj_t)(void*)0)) -# 114 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 114, __func__, -# 114 "user/mpy/py/objtype.c" - "lookup->dest[1] == MP_OBJ_NULL" -# 114 "user/mpy/py/objtype.c" 3 - )) -# 114 "user/mpy/py/objtype.c" - ; - for (;;) { - - - - - if (lookup->meth_offset != 0 && ((type)->make_new != mp_obj_instance_make_new)) { - if (*(void**)((char*)type + lookup->meth_offset) != -# 121 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 121 "user/mpy/py/objtype.c" - ) { - (void)0; - lookup->dest[0] = (((mp_obj_t)(void*)8)); - return; - } - } - - if (type->locals_dict != -# 128 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 128 "user/mpy/py/objtype.c" - ) { - - -# 130 "user/mpy/py/objtype.c" 3 - (( -# 130 "user/mpy/py/objtype.c" - type->locals_dict->base.type == &mp_type_dict -# 130 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 130, __func__, -# 130 "user/mpy/py/objtype.c" - "type->locals_dict->base.type == &mp_type_dict" -# 130 "user/mpy/py/objtype.c" 3 - )) -# 130 "user/mpy/py/objtype.c" - ; - mp_map_t *locals_map = &type->locals_dict->map; - mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(lookup->attr)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 133 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 133 "user/mpy/py/objtype.c" - ) { - if (lookup->is_type) { - - - const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj; - mp_convert_member_lookup((((mp_obj_t)(void*)0)), org_type, elem->value, lookup->dest); - } else { - mp_obj_instance_t *obj = lookup->obj; - mp_obj_t obj_obj; - if (obj != -# 142 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 142 "user/mpy/py/objtype.c" - && ((type)->make_new != mp_obj_instance_make_new) && type != &mp_type_object ) { - - obj_obj = obj->subobj[0]; - } else { - obj_obj = ((mp_obj_t)obj); - } - mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest); - } - - - - - - return; - } - } - - - - - if (lookup->obj != -# 162 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 162 "user/mpy/py/objtype.c" - && !lookup->is_type && ((type)->make_new != mp_obj_instance_make_new) && type != &mp_type_object ) { - mp_load_method_maybe(lookup->obj->subobj[0], lookup->attr, lookup->dest); - if (lookup->dest[0] != (((mp_obj_t)(void*)0))) { - return; - } - } - - - - if (type->parent == -# 171 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 171 "user/mpy/py/objtype.c" - ) { - return; - } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { - const mp_obj_tuple_t *parent_tuple = type->parent; - const mp_obj_t *item = parent_tuple->items; - const mp_obj_t *top = item + parent_tuple->len - 1; - for (; item < top; ++item) { - -# 178 "user/mpy/py/objtype.c" 3 - (( -# 178 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(*item) && (((mp_obj_base_t*)((void*)*item))->type == (&mp_type_type))) -# 178 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 178, __func__, -# 178 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(*item, &mp_type_type)" -# 178 "user/mpy/py/objtype.c" 3 - )) -# 178 "user/mpy/py/objtype.c" - ; - mp_obj_type_t *bt = (mp_obj_type_t*)((void*)*item); - if (bt == &mp_type_object) { - - continue; - } - mp_obj_class_lookup(lookup, bt); - if (lookup->dest[0] != (((mp_obj_t)(void*)0))) { - return; - } - } - - - -# 191 "user/mpy/py/objtype.c" 3 - (( -# 191 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(*item) && (((mp_obj_base_t*)((void*)*item))->type == (&mp_type_type))) -# 191 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 191, __func__, -# 191 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(*item, &mp_type_type)" -# 191 "user/mpy/py/objtype.c" 3 - )) -# 191 "user/mpy/py/objtype.c" - ; - type = (mp_obj_type_t*)((void*)*item); - } else { - type = type->parent; - } - if (type == &mp_type_object) { - - return; - } - } -} - -static void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_instance_t *self = ((void*)self_in); - qstr meth = (kind == PRINT_STR) ? MP_QSTR___str__ : MP_QSTR___repr__; - mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = self, - .attr = meth, - .meth_offset = -# 210 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 210 "user/mpy/py/objtype.c" - mp_obj_type_t -# 210 "user/mpy/py/objtype.c" 3 4 - , -# 210 "user/mpy/py/objtype.c" - print -# 210 "user/mpy/py/objtype.c" 3 4 - ) -# 210 "user/mpy/py/objtype.c" - , - .dest = member, - .is_type = -# 212 "user/mpy/py/objtype.c" 3 4 - 0 -# 212 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == (((mp_obj_t)(void*)0)) && kind == PRINT_STR) { - - lookup.attr = MP_QSTR___repr__; - lookup.meth_offset = 0; - mp_obj_class_lookup(&lookup, self->base.type); - } - - if (member[0] == (((mp_obj_t)(void*)8))) { - - if ((mp_obj_get_type(self->subobj[0])->make_new == mp_obj_exception_make_new)) { - if (kind != PRINT_STR) { - mp_print_str(print, qstr_str(self->base.type->name)); - } - mp_obj_print_helper(print, self->subobj[0], kind | PRINT_EXC_SUBCLASS); - } else { - mp_obj_print_helper(print, self->subobj[0], kind); - } - return; - } - - if (member[0] != (((mp_obj_t)(void*)0))) { - mp_obj_t r = mp_call_function_1(member[0], self_in); - mp_obj_print_helper(print, r, PRINT_STR); - return; - } - - - mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self); -} - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { - -# 246 "user/mpy/py/objtype.c" 3 - (( -# 246 "user/mpy/py/objtype.c" - ((self)->make_new == mp_obj_instance_make_new) -# 246 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 246, __func__, -# 246 "user/mpy/py/objtype.c" - "mp_obj_is_instance_type(self)" -# 246 "user/mpy/py/objtype.c" 3 - )) -# 246 "user/mpy/py/objtype.c" - ; - - const mp_obj_type_t *native_base; - size_t num_native_bases = instance_count_native_bases(self, &native_base); - -# 250 "user/mpy/py/objtype.c" 3 - (( -# 250 "user/mpy/py/objtype.c" - num_native_bases < 2 -# 250 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 250, __func__, -# 250 "user/mpy/py/objtype.c" - "num_native_bases < 2" -# 250 "user/mpy/py/objtype.c" 3 - )) -# 250 "user/mpy/py/objtype.c" - ; - - mp_obj_instance_t *o = ((void*)mp_obj_new_instance(self, num_native_bases)); - - - - - - if (n_args == 1 && *args == (((mp_obj_t)(void*)8))) { - return ((mp_obj_t)o); - } - - - mp_obj_t init_fn[2] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = -# 265 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 265 "user/mpy/py/objtype.c" - , - .attr = MP_QSTR___new__, - .meth_offset = -# 267 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 267 "user/mpy/py/objtype.c" - mp_obj_type_t -# 267 "user/mpy/py/objtype.c" 3 4 - , -# 267 "user/mpy/py/objtype.c" - make_new -# 267 "user/mpy/py/objtype.c" 3 4 - ) -# 267 "user/mpy/py/objtype.c" - , - .dest = init_fn, - .is_type = -# 269 "user/mpy/py/objtype.c" 3 4 - 0 -# 269 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self); - - mp_obj_t new_ret = ((mp_obj_t)o); - if (init_fn[0] == (((mp_obj_t)(void*)8))) { - - - o->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args); - } else if (init_fn[0] != (((mp_obj_t)(void*)0))) { - - if (n_args == 0 && n_kw == 0) { - mp_obj_t args2[1] = {((mp_obj_t)self)}; - new_ret = mp_call_function_n_kw(init_fn[0], 1, 0, args2); - } else { - mp_obj_t *args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (1 + n_args + 2 * n_kw)))); - args2[0] = ((mp_obj_t)self); - memcpy(args2 + 1, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - new_ret = mp_call_function_n_kw(init_fn[0], n_args + 1, n_kw, args2); - ((void)(1 + n_args + 2 * n_kw), m_free(args2)); - } - - } - - - - if (mp_obj_get_type(new_ret) != self) { - return new_ret; - } - - o = ((void*)new_ret); - - - init_fn[0] = init_fn[1] = (((mp_obj_t)(void*)0)); - lookup.obj = o; - lookup.attr = MP_QSTR___init__; - lookup.meth_offset = 0; - mp_obj_class_lookup(&lookup, self); - if (init_fn[0] != (((mp_obj_t)(void*)0))) { - mp_obj_t init_ret; - if (n_args == 0 && n_kw == 0) { - init_ret = mp_call_method_n_kw(0, 0, init_fn); - } else { - mp_obj_t *args2 = ((mp_obj_t*)(m_malloc(sizeof(mp_obj_t) * (2 + n_args + 2 * n_kw)))); - args2[0] = init_fn[0]; - args2[1] = init_fn[1]; - memcpy(args2 + 2, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - init_ret = mp_call_method_n_kw(n_args, n_kw, args2); - ((void)(2 + n_args + 2 * n_kw), m_free(args2)); - } - if (init_ret != (((mp_obj_t)&mp_const_none_obj))) { - if (((1)) == (1)) { - mp_raise_TypeError("__init__() should return None"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "__init__() should return None, not '%s'", mp_obj_get_type_str(init_ret)))) - ; - } - } - - } - - return ((mp_obj_t)o); -} - -const qstr mp_unary_op_method_name[] = { - [MP_UNARY_OP_BOOL] = MP_QSTR___bool__, - [MP_UNARY_OP_LEN] = MP_QSTR___len__, - [MP_UNARY_OP_HASH] = MP_QSTR___hash__, -# 345 "user/mpy/py/objtype.c" - [MP_UNARY_OP_NOT] = MP_QSTR_, -}; - -static mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_instance_t *self = ((void*)self_in); -# 363 "user/mpy/py/objtype.c" - qstr op_name = mp_unary_op_method_name[op]; - - - - - - mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = self, - .attr = op_name, - .meth_offset = -# 373 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 373 "user/mpy/py/objtype.c" - mp_obj_type_t -# 373 "user/mpy/py/objtype.c" 3 4 - , -# 373 "user/mpy/py/objtype.c" - unary_op -# 373 "user/mpy/py/objtype.c" 3 4 - ) -# 373 "user/mpy/py/objtype.c" - , - .dest = member, - .is_type = -# 375 "user/mpy/py/objtype.c" 3 4 - 0 -# 375 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == (((mp_obj_t)(void*)8))) { - return mp_unary_op(op, self->subobj[0]); - } else if (member[0] != (((mp_obj_t)(void*)0))) { - mp_obj_t val = mp_call_function_1(member[0], self_in); - - if (op == MP_UNARY_OP_HASH) { - val = ((mp_obj_t)((((mp_uint_t)(mp_obj_get_int_truncated(val))) << 1) | 1)); - } - return val; - } else { - if (op == MP_UNARY_OP_HASH) { - lookup.attr = MP_QSTR___eq__; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == (((mp_obj_t)(void*)0))) { - - - - - - return ((mp_obj_t)((((mp_uint_t)((mp_uint_t)self_in)) << 1) | 1)); - } - - - } - - return (((mp_obj_t)(void*)0)); - } -} - -const qstr mp_binary_op_method_name[] = { - - - - - - - - [MP_BINARY_OP_ADD] = MP_QSTR___add__, - [MP_BINARY_OP_SUBTRACT] = MP_QSTR___sub__, -# 440 "user/mpy/py/objtype.c" - [MP_BINARY_OP_LESS] = MP_QSTR___lt__, - [MP_BINARY_OP_MORE] = MP_QSTR___gt__, - [MP_BINARY_OP_EQUAL] = MP_QSTR___eq__, - [MP_BINARY_OP_LESS_EQUAL] = MP_QSTR___le__, - [MP_BINARY_OP_MORE_EQUAL] = MP_QSTR___ge__, - - - - [MP_BINARY_OP_IN] = MP_QSTR___contains__, - - - - [MP_BINARY_OP_EXCEPTION_MATCH] = MP_QSTR_, -}; - -static mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - - - mp_obj_instance_t *lhs = ((void*)lhs_in); - qstr op_name = mp_binary_op_method_name[op]; - - - - - - mp_obj_t dest[3] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = lhs, - .attr = op_name, - .meth_offset = -# 469 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 469 "user/mpy/py/objtype.c" - mp_obj_type_t -# 469 "user/mpy/py/objtype.c" 3 4 - , -# 469 "user/mpy/py/objtype.c" - binary_op -# 469 "user/mpy/py/objtype.c" 3 4 - ) -# 469 "user/mpy/py/objtype.c" - , - .dest = dest, - .is_type = -# 471 "user/mpy/py/objtype.c" 3 4 - 0 -# 471 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, lhs->base.type); - if (dest[0] == (((mp_obj_t)(void*)8))) { - return mp_binary_op(op, lhs->subobj[0], rhs_in); - } else if (dest[0] != (((mp_obj_t)(void*)0))) { - dest[2] = rhs_in; - return mp_call_method_n_kw(1, 0, dest); - } else { - return (((mp_obj_t)(void*)0)); - } -} - -static void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - - -# 486 "user/mpy/py/objtype.c" 3 - (( -# 486 "user/mpy/py/objtype.c" - ((mp_obj_get_type(self_in))->make_new == mp_obj_instance_make_new) -# 486 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 486, __func__, -# 486 "user/mpy/py/objtype.c" - "mp_obj_is_instance_type(mp_obj_get_type(self_in))" -# 486 "user/mpy/py/objtype.c" 3 - )) -# 486 "user/mpy/py/objtype.c" - ; - mp_obj_instance_t *self = ((void*)self_in); - - mp_map_elem_t *elem = mp_map_lookup(&self->members, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 490 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 490 "user/mpy/py/objtype.c" - ) { - - - dest[0] = elem->value; - return; - } -# 512 "user/mpy/py/objtype.c" - struct class_lookup_data lookup = { - .obj = self, - .attr = attr, - .meth_offset = 0, - .dest = dest, - .is_type = -# 517 "user/mpy/py/objtype.c" 3 4 - 0 -# 517 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self->base.type); - mp_obj_t member = dest[0]; - if (member != (((mp_obj_t)(void*)0))) { -# 554 "user/mpy/py/objtype.c" - return; - } - - - if (attr != MP_QSTR___getattr__) { -# 568 "user/mpy/py/objtype.c" - mp_obj_t dest2[3]; - mp_load_method_maybe(self_in, MP_QSTR___getattr__, dest2); - if (dest2[0] != (((mp_obj_t)(void*)0))) { - - - dest2[2] = ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)); - dest[0] = mp_call_method_n_kw(1, 0, dest2); - return; - } - } -} - -static -# 580 "user/mpy/py/objtype.c" 3 4 - _Bool -# 580 "user/mpy/py/objtype.c" - mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) { - mp_obj_instance_t *self = ((void*)self_in); -# 659 "user/mpy/py/objtype.c" - if (value == (((mp_obj_t)(void*)0))) { -# 673 "user/mpy/py/objtype.c" - mp_map_elem_t *elem = mp_map_lookup(&self->members, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_REMOVE_IF_FOUND); - return elem != -# 674 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 674 "user/mpy/py/objtype.c" - ; - } else { -# 690 "user/mpy/py/objtype.c" - mp_map_lookup(&self->members, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - return -# 691 "user/mpy/py/objtype.c" 3 4 - 1 -# 691 "user/mpy/py/objtype.c" - ; - } -} - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] == (((mp_obj_t)(void*)0))) { - mp_obj_instance_load_attr(self_in, attr, dest); - } else { - if (mp_obj_instance_store_attr(self_in, attr, dest[1])) { - dest[0] = (((mp_obj_t)(void*)0)); - } - } -} - -static mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_instance_t *self = ((void*)self_in); - mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = self, - .meth_offset = -# 710 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 710 "user/mpy/py/objtype.c" - mp_obj_type_t -# 710 "user/mpy/py/objtype.c" 3 4 - , -# 710 "user/mpy/py/objtype.c" - subscr -# 710 "user/mpy/py/objtype.c" 3 4 - ) -# 710 "user/mpy/py/objtype.c" - , - .dest = member, - .is_type = -# 712 "user/mpy/py/objtype.c" 3 4 - 0 -# 712 "user/mpy/py/objtype.c" - , - }; - size_t meth_args; - if (value == (((mp_obj_t)(void*)0))) { - - lookup.attr = MP_QSTR___delitem__; - mp_obj_class_lookup(&lookup, self->base.type); - meth_args = 2; - } else if (value == (((mp_obj_t)(void*)8))) { - - lookup.attr = MP_QSTR___getitem__; - mp_obj_class_lookup(&lookup, self->base.type); - meth_args = 2; - } else { - - lookup.attr = MP_QSTR___setitem__; - mp_obj_class_lookup(&lookup, self->base.type); - meth_args = 3; - } - if (member[0] == (((mp_obj_t)(void*)8))) { - return mp_obj_subscr(self->subobj[0], index, value); - } else if (member[0] != (((mp_obj_t)(void*)0))) { - mp_obj_t args[3] = {self_in, index, value}; - - mp_obj_t ret = mp_call_function_n_kw(member[0], meth_args, 0, args); - if (value == (((mp_obj_t)(void*)8))) { - return ret; - } else { - return (((mp_obj_t)&mp_const_none_obj)); - } - } else { - return (((mp_obj_t)(void*)0)); - } -} - -static mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) { - mp_obj_instance_t *self = ((void*)self_in); - struct class_lookup_data lookup = { - .obj = self, - .attr = MP_QSTR___call__, - .meth_offset = -# 752 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 752 "user/mpy/py/objtype.c" - mp_obj_type_t -# 752 "user/mpy/py/objtype.c" 3 4 - , -# 752 "user/mpy/py/objtype.c" - call -# 752 "user/mpy/py/objtype.c" 3 4 - ) -# 752 "user/mpy/py/objtype.c" - , - .dest = member, - .is_type = -# 754 "user/mpy/py/objtype.c" 3 4 - 0 -# 754 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self->base.type); - return member[0]; -} - - -# 760 "user/mpy/py/objtype.c" 3 4 -_Bool -# 760 "user/mpy/py/objtype.c" - mp_obj_instance_is_callable(mp_obj_t self_in) { - mp_obj_t member[2] = {(((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))}; - return mp_obj_instance_get_call(self_in, member) != (((mp_obj_t)(void*)0)); -} - -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_t member[2] = {(((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))}; - mp_obj_t call = mp_obj_instance_get_call(self_in, member); - if (call == (((mp_obj_t)(void*)0))) { - if (((1)) == (1)) { - mp_raise_TypeError("object not callable"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'%s' object is not callable", mp_obj_get_type_str(self_in)))) - ; - } - } - mp_obj_instance_t *self = ((void*)self_in); - if (call == (((mp_obj_t)(void*)8))) { - return mp_call_function_n_kw(self->subobj[0], n_args, n_kw, args); - } - - return mp_call_method_self_n_kw(member[0], member[1], n_args, n_kw, args); -} - -static mp_obj_t instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { - mp_obj_instance_t *self = ((void*)self_in); - mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = self, - .attr = MP_QSTR___iter__, - .meth_offset = -# 790 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 790 "user/mpy/py/objtype.c" - mp_obj_type_t -# 790 "user/mpy/py/objtype.c" 3 4 - , -# 790 "user/mpy/py/objtype.c" - getiter -# 790 "user/mpy/py/objtype.c" 3 4 - ) -# 790 "user/mpy/py/objtype.c" - , - .dest = member, - .is_type = -# 792 "user/mpy/py/objtype.c" 3 4 - 0 -# 792 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == (((mp_obj_t)(void*)0))) { - return (((mp_obj_t)(void*)0)); - } else if (member[0] == (((mp_obj_t)(void*)8))) { - mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); - return type->getiter(self->subobj[0], iter_buf); - } else { - return mp_call_method_n_kw(0, 0, member); - } -} - -static mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - mp_obj_instance_t *self = ((void*)self_in); - mp_obj_t member[2] = {(((mp_obj_t)(void*)0))}; - struct class_lookup_data lookup = { - .obj = self, - .attr = MP_QSTR_, - .meth_offset = -# 811 "user/mpy/py/objtype.c" 3 4 - __builtin_offsetof ( -# 811 "user/mpy/py/objtype.c" - mp_obj_type_t -# 811 "user/mpy/py/objtype.c" 3 4 - , -# 811 "user/mpy/py/objtype.c" - buffer_p.get_buffer -# 811 "user/mpy/py/objtype.c" 3 4 - ) -# 811 "user/mpy/py/objtype.c" - , - .dest = member, - .is_type = -# 813 "user/mpy/py/objtype.c" 3 4 - 0 -# 813 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == (((mp_obj_t)(void*)8))) { - mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); - return type->buffer_p.get_buffer(self->subobj[0], bufinfo, flags); - } else { - return 1; - } -} - - - - - - - -static void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_type_t *self = ((void*)self_in); - mp_printf(print, "", self->name); -} - -static mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - mp_arg_check_num(n_args, n_kw, 1, 3, -# 839 "user/mpy/py/objtype.c" 3 4 - 0 -# 839 "user/mpy/py/objtype.c" - ); - - switch (n_args) { - case 1: - return ((mp_obj_t)mp_obj_get_type(args[0])); - - case 3: - - - - return mp_obj_new_type(mp_obj_str_get_qstr(args[0]), args[1], args[2]); - - default: - mp_raise_TypeError("type takes 1 or 3 arguments"); - } -} - -static mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - - - mp_obj_type_t *self = ((void*)self_in); - - if (self->make_new == -# 861 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 861 "user/mpy/py/objtype.c" - ) { - if (((1)) == (1)) { - mp_raise_TypeError("cannot create instance"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "cannot create '%q' instances", self->name))) - ; - } - } - - - mp_obj_t o = self->make_new(self, n_args, n_kw, args); - - - return o; -} - -static void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - -# 878 "user/mpy/py/objtype.c" 3 - (( -# 878 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_type))) -# 878 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 878, __func__, -# 878 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_type)" -# 878 "user/mpy/py/objtype.c" 3 - )) -# 878 "user/mpy/py/objtype.c" - ; - mp_obj_type_t *self = ((void*)self_in); - - if (dest[0] == (((mp_obj_t)(void*)0))) { - - - - - - - - struct class_lookup_data lookup = { - .obj = (mp_obj_instance_t*)self, - .attr = attr, - .meth_offset = 0, - .dest = dest, - .is_type = -# 894 "user/mpy/py/objtype.c" 3 4 - 1 -# 894 "user/mpy/py/objtype.c" - , - }; - mp_obj_class_lookup(&lookup, self); - } else { - - - - - if (self->locals_dict != -# 902 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 902 "user/mpy/py/objtype.c" - ) { - -# 903 "user/mpy/py/objtype.c" 3 - (( -# 903 "user/mpy/py/objtype.c" - self->locals_dict->base.type == &mp_type_dict -# 903 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 903, __func__, -# 903 "user/mpy/py/objtype.c" - "self->locals_dict->base.type == &mp_type_dict" -# 903 "user/mpy/py/objtype.c" 3 - )) -# 903 "user/mpy/py/objtype.c" - ; - mp_map_t *locals_map = &self->locals_dict->map; - if (dest[1] == (((mp_obj_t)(void*)0))) { - - mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_REMOVE_IF_FOUND); - - if (elem != -# 909 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 909 "user/mpy/py/objtype.c" - ) { - dest[0] = (((mp_obj_t)(void*)0)); - } - } else { - - mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(attr)) << 2) | 2)), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - - if (elem != -# 916 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 916 "user/mpy/py/objtype.c" - ) { - elem->value = dest[1]; - dest[0] = (((mp_obj_t)(void*)0)); - } - } - } - } -} - -const mp_obj_type_t mp_type_type = { - { &mp_type_type }, - .name = MP_QSTR_type, - .print = type_print, - .make_new = type_make_new, - .call = type_call, - .unary_op = mp_generic_unary_op, - .attr = type_attr, -}; - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) { - -# 936 "user/mpy/py/objtype.c" 3 - (( -# 936 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(bases_tuple) && (((mp_obj_base_t*)((void*)bases_tuple))->type == (&mp_type_tuple))) -# 936 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 936, __func__, -# 936 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(bases_tuple, &mp_type_tuple)" -# 936 "user/mpy/py/objtype.c" 3 - )) -# 936 "user/mpy/py/objtype.c" - ; - -# 937 "user/mpy/py/objtype.c" 3 - (( -# 937 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(locals_dict) && (((mp_obj_base_t*)((void*)locals_dict))->type == (&mp_type_dict))) -# 937 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 937, __func__, -# 937 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(locals_dict, &mp_type_dict)" -# 937 "user/mpy/py/objtype.c" 3 - )) -# 937 "user/mpy/py/objtype.c" - ; - - - - - size_t len; - mp_obj_t *items; - mp_obj_tuple_get(bases_tuple, &len, &items); - for (size_t i = 0; i < len; i++) { - -# 946 "user/mpy/py/objtype.c" 3 - (( -# 946 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(items[i]) && (((mp_obj_base_t*)((void*)items[i]))->type == (&mp_type_type))) -# 946 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 946, __func__, -# 946 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(items[i], &mp_type_type)" -# 946 "user/mpy/py/objtype.c" 3 - )) -# 946 "user/mpy/py/objtype.c" - ; - mp_obj_type_t *t = ((void*)items[i]); - - if (t->make_new == -# 949 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 949 "user/mpy/py/objtype.c" - ) { - if (((1)) == (1)) { - mp_raise_TypeError("type is not an acceptable base type"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "type '%q' is not an acceptable base type", t->name))) - ; - } - } - } - - mp_obj_type_t *o = ((mp_obj_type_t*)(m_malloc0(sizeof(mp_obj_type_t) * (1)))); - o->base.type = &mp_type_type; - o->name = name; - o->print = instance_print; - o->make_new = mp_obj_instance_make_new; - o->call = mp_obj_instance_call; - o->unary_op = instance_unary_op; - o->binary_op = instance_binary_op; - o->attr = mp_obj_instance_attr; - o->subscr = instance_subscr; - o->getiter = instance_getiter; - - o->buffer_p.get_buffer = instance_get_buffer; - - if (len > 0) { - - - - - o->protocol = ((mp_obj_type_t*)((void*)items[0]))->protocol; - - if (len >= 2) { - o->parent = ((void*)bases_tuple); - } else { - o->parent = ((void*)items[0]); - } - } - - o->locals_dict = ((void*)locals_dict); - - const mp_obj_type_t *native_base; - size_t num_native_bases = instance_count_native_bases(o, &native_base); - if (num_native_bases > 1) { - mp_raise_TypeError("multiple bases have instance lay-out conflict"); - } - - mp_map_t *locals_map = &o->locals_dict->map; - mp_map_elem_t *elem = mp_map_lookup(locals_map, ((mp_obj_t)((((mp_uint_t)(MP_QSTR___new__)) << 2) | 2)), MP_MAP_LOOKUP); - if (elem != -# 997 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 997 "user/mpy/py/objtype.c" - ) { - - if ((MP_OBJ_IS_OBJ(elem->value) && (((mp_obj_base_t*)((void*)elem->value))->type->name == MP_QSTR_function))) { - - elem->value = static_class_method_make_new(&mp_type_staticmethod, 1, 0, &elem->value); - } - } - - return ((mp_obj_t)o); -} - - - - -typedef struct _mp_obj_super_t { - mp_obj_base_t base; - mp_obj_t type; - mp_obj_t obj; -} mp_obj_super_t; - -static void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_super_t *self = ((void*)self_in); - mp_print_str(print, "type, PRINT_STR); - mp_print_str(print, ", "); - mp_obj_print_helper(print, self->obj, PRINT_STR); - mp_print_str(print, ">"); -} - -static mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - - mp_arg_check_num(n_args, n_kw, 2, 2, -# 1031 "user/mpy/py/objtype.c" 3 4 - 0 -# 1031 "user/mpy/py/objtype.c" - ); - mp_obj_super_t *o = (((mp_obj_super_t*)(m_malloc(sizeof(mp_obj_super_t) * (1))))); - *o = (mp_obj_super_t){{type_in}, args[0], args[1]}; - return ((mp_obj_t)o); -} - -static void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != (((mp_obj_t)(void*)0))) { - - return; - } - - -# 1043 "user/mpy/py/objtype.c" 3 - (( -# 1043 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_super))) -# 1043 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1043, __func__, -# 1043 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(self_in, &mp_type_super)" -# 1043 "user/mpy/py/objtype.c" 3 - )) -# 1043 "user/mpy/py/objtype.c" - ; - mp_obj_super_t *self = ((void*)self_in); - - -# 1046 "user/mpy/py/objtype.c" 3 - (( -# 1046 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(self->type) && (((mp_obj_base_t*)((void*)self->type))->type == (&mp_type_type))) -# 1046 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1046, __func__, -# 1046 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(self->type, &mp_type_type)" -# 1046 "user/mpy/py/objtype.c" 3 - )) -# 1046 "user/mpy/py/objtype.c" - ; - - mp_obj_type_t *type = ((void*)self->type); - - struct class_lookup_data lookup = { - .obj = ((void*)self->obj), - .attr = attr, - .meth_offset = 0, - .dest = dest, - .is_type = -# 1055 "user/mpy/py/objtype.c" 3 4 - 0 -# 1055 "user/mpy/py/objtype.c" - , - }; - - if (type->parent == -# 1058 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 1058 "user/mpy/py/objtype.c" - ) { - - } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { - const mp_obj_tuple_t *parent_tuple = type->parent; - size_t len = parent_tuple->len; - const mp_obj_t *items = parent_tuple->items; - for (size_t i = 0; i < len; i++) { - -# 1065 "user/mpy/py/objtype.c" 3 - (( -# 1065 "user/mpy/py/objtype.c" - (MP_OBJ_IS_OBJ(items[i]) && (((mp_obj_base_t*)((void*)items[i]))->type == (&mp_type_type))) -# 1065 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1065, __func__, -# 1065 "user/mpy/py/objtype.c" - "MP_OBJ_IS_TYPE(items[i], &mp_type_type)" -# 1065 "user/mpy/py/objtype.c" 3 - )) -# 1065 "user/mpy/py/objtype.c" - ; - mp_obj_class_lookup(&lookup, (mp_obj_type_t*)((void*)items[i])); - if (dest[0] != (((mp_obj_t)(void*)0))) { - return; - } - } - } else { - mp_obj_class_lookup(&lookup, type->parent); - if (dest[0] != (((mp_obj_t)(void*)0))) { - return; - } - } - - mp_obj_class_lookup(&lookup, &mp_type_object); -} - -const mp_obj_type_t mp_type_super = { - { &mp_type_type }, - .name = MP_QSTR_super, - .print = super_print, - .make_new = super_make_new, - .attr = super_attr, -}; - -void mp_load_super_method(qstr attr, mp_obj_t *dest) { - mp_obj_super_t super = {{&mp_type_super}, dest[1], dest[2]}; - mp_load_method(((mp_obj_t)&super), attr, dest); -} - - - - - - - -# 1099 "user/mpy/py/objtype.c" 3 4 -_Bool -# 1099 "user/mpy/py/objtype.c" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) { - for (;;) { - if (object == classinfo) { - return -# 1102 "user/mpy/py/objtype.c" 3 4 - 1 -# 1102 "user/mpy/py/objtype.c" - ; - } - - - - - if (!(MP_OBJ_IS_OBJ(object) && (((mp_obj_base_t*)((void*)object))->type == (&mp_type_type)))) { - return -# 1109 "user/mpy/py/objtype.c" 3 4 - 0 -# 1109 "user/mpy/py/objtype.c" - ; - } - - const mp_obj_type_t *self = ((void*)object); - - if (self->parent == -# 1114 "user/mpy/py/objtype.c" 3 4 - ((void *)0) -# 1114 "user/mpy/py/objtype.c" - ) { - - return -# 1116 "user/mpy/py/objtype.c" 3 4 - 0 -# 1116 "user/mpy/py/objtype.c" - ; - } else if (((mp_obj_base_t*)self->parent)->type == &mp_type_tuple) { - - const mp_obj_tuple_t *parent_tuple = self->parent; - const mp_obj_t *item = parent_tuple->items; - const mp_obj_t *top = item + parent_tuple->len - 1; - - - for (; item < top; ++item) { - if (mp_obj_is_subclass_fast(*item, classinfo)) { - return -# 1126 "user/mpy/py/objtype.c" 3 4 - 1 -# 1126 "user/mpy/py/objtype.c" - ; - } - } - - - object = *item; - } else { - - object = ((mp_obj_t)self->parent); - } - } -} - -static mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) { - size_t len; - mp_obj_t *items; - if ((MP_OBJ_IS_OBJ(classinfo) && (((mp_obj_base_t*)((void*)classinfo))->type == (&mp_type_type)))) { - len = 1; - items = &classinfo; - } else if ((MP_OBJ_IS_OBJ(classinfo) && (((mp_obj_base_t*)((void*)classinfo))->type == (&mp_type_tuple)))) { - mp_obj_tuple_get(classinfo, &len, &items); - } else { - mp_raise_TypeError("issubclass() arg 2 must be a class or a tuple of classes"); - } - - for (size_t i = 0; i < len; i++) { - - if (items[i] == ((mp_obj_t)&mp_type_object) || mp_obj_is_subclass_fast(object, items[i])) { - return (((mp_obj_t)&mp_const_true_obj)); - } - } - return (((mp_obj_t)&mp_const_false_obj)); -} - -static mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) { - if (!(MP_OBJ_IS_OBJ(object) && (((mp_obj_base_t*)((void*)object))->type == (&mp_type_type)))) { - mp_raise_TypeError("issubclass() arg 1 must be a class"); - } - return mp_obj_is_subclass(object, classinfo); -} - -const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_issubclass}; - -static mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) { - return mp_obj_is_subclass(((mp_obj_t)mp_obj_get_type(object)), classinfo); -} - -const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_isinstance}; - -mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t native_type) { - mp_obj_type_t *self_type = mp_obj_get_type(self_in); - if (!mp_obj_is_subclass_fast(((mp_obj_t)self_type), native_type)) { - return (((mp_obj_t)(void*)0)); - } - mp_obj_instance_t *self = (mp_obj_instance_t*)((void*)self_in); - return self->subobj[0]; -} - - - - -static mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { - -# 1188 "user/mpy/py/objtype.c" 3 - (( -# 1188 "user/mpy/py/objtype.c" - self == &mp_type_staticmethod || self == &mp_type_classmethod -# 1188 "user/mpy/py/objtype.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objtype.c", 1188, __func__, -# 1188 "user/mpy/py/objtype.c" - "self == &mp_type_staticmethod || self == &mp_type_classmethod" -# 1188 "user/mpy/py/objtype.c" 3 - )) -# 1188 "user/mpy/py/objtype.c" - ; - - mp_arg_check_num(n_args, n_kw, 1, 1, -# 1190 "user/mpy/py/objtype.c" 3 4 - 0 -# 1190 "user/mpy/py/objtype.c" - ); - - mp_obj_static_class_method_t *o = (((mp_obj_static_class_method_t*)(m_malloc(sizeof(mp_obj_static_class_method_t) * (1))))); - *o = (mp_obj_static_class_method_t){{self}, args[0]}; - return ((mp_obj_t)o); -} - -const mp_obj_type_t mp_type_staticmethod = { - { &mp_type_type }, - .name = MP_QSTR_staticmethod, - .make_new = static_class_method_make_new, -}; - -const mp_obj_type_t mp_type_classmethod = { - { &mp_type_type }, - .name = MP_QSTR_classmethod, - .make_new = static_class_method_make_new, -}; -# 1 "user/mpy/py/objzip.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/objzip.c" -# 27 "user/mpy/py/objzip.c" -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 28 "user/mpy/py/objzip.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/objzip.c" 2 - -# 1 "user/mpy/py/objtuple.h" 1 -# 29 "user/mpy/py/objtuple.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objtuple.h" 2 - -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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/py/objzip.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 32 "user/mpy/py/objexcept.h" -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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/objzip.c" 2 - -typedef struct _mp_obj_zip_t { - mp_obj_base_t base; - size_t n_iters; - mp_obj_t iters[]; -} mp_obj_zip_t; - -static mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, (0xffff), -# 40 "user/mpy/py/objzip.c" 3 4 - 0 -# 40 "user/mpy/py/objzip.c" - ); - - mp_obj_zip_t *o = ((mp_obj_zip_t*)m_malloc(sizeof(mp_obj_zip_t) + sizeof(mp_obj_t) * (n_args))); - o->base.type = type; - o->n_iters = n_args; - for (size_t i = 0; i < n_args; i++) { - o->iters[i] = mp_getiter(args[i], -# 46 "user/mpy/py/objzip.c" 3 4 - ((void *)0) -# 46 "user/mpy/py/objzip.c" - ); - } - return ((mp_obj_t)o); -} - -static mp_obj_t zip_iternext(mp_obj_t self_in) { - -# 52 "user/mpy/py/objzip.c" 3 - (( -# 52 "user/mpy/py/objzip.c" - (MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_zip))) -# 52 "user/mpy/py/objzip.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/objzip.c", 52, __func__, -# 52 "user/mpy/py/objzip.c" - "(MP_OBJ_IS_OBJ(self_in) && (((mp_obj_base_t*)((void*)self_in))->type == (&mp_type_zip)))" -# 52 "user/mpy/py/objzip.c" 3 - )) -# 52 "user/mpy/py/objzip.c" - ; - mp_obj_zip_t *self = ((void*)self_in); - if (self->n_iters == 0) { - return (((mp_obj_t)(void*)4)); - } - mp_obj_tuple_t *tuple = ((void*)mp_obj_new_tuple(self->n_iters, -# 57 "user/mpy/py/objzip.c" 3 4 - ((void *)0) -# 57 "user/mpy/py/objzip.c" - )); - - for (size_t i = 0; i < self->n_iters; i++) { - mp_obj_t next = mp_iternext(self->iters[i]); - if (next == (((mp_obj_t)(void*)4))) { - mp_obj_tuple_del(((mp_obj_t)tuple)); - return (((mp_obj_t)(void*)4)); - } - tuple->items[i] = next; - } - return ((mp_obj_t)tuple); -} - -const mp_obj_type_t mp_type_zip = { - { &mp_type_type }, - .name = MP_QSTR_zip, - .make_new = zip_make_new, - .getiter = mp_identity_getiter, - .iternext = zip_iternext, -}; -# 1 "user/mpy/py/opmethods.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/opmethods.c" -# 27 "user/mpy/py/opmethods.c" -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 28 "user/mpy/py/opmethods.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 29 "user/mpy/py/builtin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/builtin.h" 2 - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 29 "user/mpy/py/opmethods.c" 2 - -static mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, (((mp_obj_t)(void*)8))); -} -const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj = {{&mp_type_fun_builtin_2}, .fun._2 = op_getitem}; - -static mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in); -} -const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj = {{&mp_type_fun_builtin_3}, .fun._3 = op_setitem}; - -static mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, (((mp_obj_t)(void*)0))); -} -const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj = {{&mp_type_fun_builtin_2}, .fun._2 = op_delitem}; - -static mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_type_t *type = mp_obj_get_type(lhs_in); - return type->binary_op(MP_BINARY_OP_IN, lhs_in, rhs_in); -} -const mp_obj_fun_builtin_fixed_t mp_op_contains_obj = {{&mp_type_fun_builtin_2}, .fun._2 = op_contains}; -# 1 "user/mpy/py/sequence.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/sequence.c" -# 28 "user/mpy/py/sequence.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/sequence.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/sequence.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 32 "user/mpy/py/sequence.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/sequence.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/sequence.c" 2 - - - - - - - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest) { - for (size_t i = 0; i < times; i++) { - size_t copy_sz = item_sz * len; - memcpy(dest, items, copy_sz); - dest = (char*)dest + copy_sz; - } -} -# 129 "user/mpy/py/sequence.c" -mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) { - (void)len; - - mp_int_t start = indexes->start, stop = indexes->stop; - mp_int_t step = indexes->step; - - mp_obj_t res = mp_obj_new_list(0, -# 135 "user/mpy/py/sequence.c" 3 4 - ((void *)0) -# 135 "user/mpy/py/sequence.c" - ); - - if (step < 0) { - while (start >= stop) { - mp_obj_list_append(res, seq[start]); - start += step; - } - } else { - while (start < stop) { - mp_obj_list_append(res, seq[start]); - start += step; - } - } - return res; -} - - - - -# 153 "user/mpy/py/sequence.c" 3 4 -_Bool -# 153 "user/mpy/py/sequence.c" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2) { - if (op == MP_BINARY_OP_EQUAL && len1 != len2) { - return -# 155 "user/mpy/py/sequence.c" 3 4 - 0 -# 155 "user/mpy/py/sequence.c" - ; - } - - - if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { - { const byte* t = data2; data2 = data1; data1 = t; }; - { size_t t = len2; len2 = len1; len1 = t; }; - if (op == MP_BINARY_OP_LESS) { - op = MP_BINARY_OP_MORE; - } else { - op = MP_BINARY_OP_MORE_EQUAL; - } - } - size_t min_len = len1 < len2 ? len1 : len2; - int res = memcmp(data1, data2, min_len); - if (op == MP_BINARY_OP_EQUAL) { - - return res == 0; - } - if (res < 0) { - return -# 175 "user/mpy/py/sequence.c" 3 4 - 0 -# 175 "user/mpy/py/sequence.c" - ; - } - if (res > 0) { - return -# 178 "user/mpy/py/sequence.c" 3 4 - 1 -# 178 "user/mpy/py/sequence.c" - ; - } - - - - if (len1 != len2) { - if (len1 < len2) { - - return -# 186 "user/mpy/py/sequence.c" 3 4 - 0 -# 186 "user/mpy/py/sequence.c" - ; - } - } else if (op == MP_BINARY_OP_MORE) { - - return -# 190 "user/mpy/py/sequence.c" 3 4 - 0 -# 190 "user/mpy/py/sequence.c" - ; - } - return -# 192 "user/mpy/py/sequence.c" 3 4 - 1 -# 192 "user/mpy/py/sequence.c" - ; -} - - - - -# 197 "user/mpy/py/sequence.c" 3 4 -_Bool -# 197 "user/mpy/py/sequence.c" - mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, size_t len1, const mp_obj_t *items2, size_t len2) { - if (op == MP_BINARY_OP_EQUAL && len1 != len2) { - return -# 199 "user/mpy/py/sequence.c" 3 4 - 0 -# 199 "user/mpy/py/sequence.c" - ; - } - - - if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { - { const mp_obj_t * t = items2; items2 = items1; items1 = t; }; - { size_t t = len2; len2 = len1; len1 = t; }; - if (op == MP_BINARY_OP_LESS) { - op = MP_BINARY_OP_MORE; - } else { - op = MP_BINARY_OP_MORE_EQUAL; - } - } - - size_t len = len1 < len2 ? len1 : len2; - for (size_t i = 0; i < len; i++) { - - if (mp_obj_equal(items1[i], items2[i])) { - continue; - } - - - if (op == MP_BINARY_OP_EQUAL) { - - return -# 223 "user/mpy/py/sequence.c" 3 4 - 0 -# 223 "user/mpy/py/sequence.c" - ; - } - - - return (mp_binary_op(op, items1[i], items2[i]) == (((mp_obj_t)&mp_const_true_obj))); - } - - - - if (len1 != len2) { - if (len1 < len2) { - - return -# 235 "user/mpy/py/sequence.c" 3 4 - 0 -# 235 "user/mpy/py/sequence.c" - ; - } - } else if (op == MP_BINARY_OP_MORE) { - - return -# 239 "user/mpy/py/sequence.c" 3 4 - 0 -# 239 "user/mpy/py/sequence.c" - ; - } - - return -# 242 "user/mpy/py/sequence.c" 3 4 - 1 -# 242 "user/mpy/py/sequence.c" - ; -} - - -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_type_t *type = mp_obj_get_type(args[0]); - mp_obj_t value = args[1]; - size_t start = 0; - size_t stop = len; - - if (n_args >= 3) { - start = mp_get_index(type, len, args[2], -# 253 "user/mpy/py/sequence.c" 3 4 - 1 -# 253 "user/mpy/py/sequence.c" - ); - if (n_args >= 4) { - stop = mp_get_index(type, len, args[3], -# 255 "user/mpy/py/sequence.c" 3 4 - 1 -# 255 "user/mpy/py/sequence.c" - ); - } - } - - for (size_t i = start; i < stop; i++) { - if (mp_obj_equal(items[i], value)) { - - return ((mp_obj_t)((((mp_uint_t)(i)) << 1) | 1)); - } - } - - mp_raise_ValueError("object not in sequence"); -} - -mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) { - size_t count = 0; - for (size_t i = 0; i < len; i++) { - if (mp_obj_equal(items[i], value)) { - count++; - } - } - - - return ((mp_obj_t)((((mp_uint_t)(count)) << 1) | 1)); -} -# 1 "user/mpy/py/stream.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/stream.c" -# 28 "user/mpy/py/stream.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/stream.c" 2 -# 1 "/usr/arm-none-eabi/include/unistd.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/sys/unistd.h" 1 3 -# 12 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 13 "/usr/arm-none-eabi/include/sys/unistd.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/unistd.h" 2 3 - -extern char **environ; - -void _exit (int __status ) __attribute__ ((__noreturn__)); - -int access (const char *__path, int __amode ); -unsigned alarm (unsigned __secs ); -int chdir (const char *__path ); -int chmod (const char *__path, mode_t __mode ); - -int chown (const char *__path, uid_t __owner, gid_t __group ); - - - - -int close (int __fildes ); -# 46 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int dup (int __fildes ); -int dup2 (int __fildes, int __fildes2 ); -# 61 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int execl (const char *__path, const char *, ... ); -int execle (const char *__path, const char *, ... ); -int execlp (const char *__file, const char *, ... ); - - - -int execv (const char *__path, char * const __argv[] ); -int execve (const char *__path, char * const __argv[], char * const __envp[] ); -int execvp (const char *__file, char * const __argv[] ); -# 79 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int fchmod (int __fildes, mode_t __mode ); - -int fchown (int __fildes, uid_t __owner, gid_t __group ); - - - - - - - -pid_t fork (void ); -long fpathconf (int __fd, int __name ); -int fsync (int __fd); -int fdatasync (int __fd); - - - -char * getcwd (char *__buf, size_t __size ); - - - - - - - -gid_t getegid (void ); -uid_t geteuid (void ); -gid_t getgid (void ); - -int getgroups (int __gidsetsize, gid_t __grouplist[] ); - - - -char * getlogin (void ); - - - -char * getpass (const char *__prompt); -int getpagesize (void); - - - -pid_t getpgid (pid_t); -pid_t getpgrp (void ); -pid_t getpid (void ); -pid_t getppid (void ); - - - - -uid_t getuid (void ); -# 140 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int isatty (int __fildes ); - - - - -int lchown (const char *__path, uid_t __owner, gid_t __group ); - -int link (const char *__path1, const char *__path2 ); - - - -int nice (int __nice_value ); - -off_t lseek (int __fildes, off_t __offset, int __whence ); -# 162 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -long pathconf (const char *__path, int __name ); -int pause (void ); - - - -int pipe (int __fildes[2] ); - - - -ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset); -ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t __offset); -int read (int __fd, void *__buf, size_t __nbyte ); - - - - -int rmdir (const char *__path ); - - - -void * sbrk (ptrdiff_t __incr); - - - - - -int setgid (gid_t __gid ); - - - - - - - -int setpgid (pid_t __pid, pid_t __pgid ); -int setpgrp (void ); - - - - -pid_t setsid (void ); - -int setuid (uid_t __uid ); - - - - -unsigned sleep (unsigned int __seconds ); -void swab (const void *restrict, void *restrict, ssize_t); -long sysconf (int __name ); -pid_t tcgetpgrp (int __fildes ); -int tcsetpgrp (int __fildes, pid_t __pgrp_id ); -char * ttyname (int __fildes ); -int ttyname_r (int, char *, size_t); -int unlink (const char *__path ); -int usleep (useconds_t __useconds); -int vhangup (void ); -int write (int __fd, const void *__buf, size_t __nbyte ); - - - - - - -extern char *optarg; -extern int optind, opterr, optopt; -int getopt(int, char * const [], const char *); -extern int optreset; -# 257 "/usr/arm-none-eabi/include/sys/unistd.h" 3 -int ftruncate (int __fd, off_t __length); -int truncate (const char *, off_t __length); -# 5 "/usr/arm-none-eabi/include/unistd.h" 2 3 -# 30 "user/mpy/py/stream.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/stream.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 29 "user/mpy/py/objstr.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objstr.h" 2 - -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 33 "user/mpy/py/stream.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 34 "user/mpy/py/stream.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 35 "user/mpy/py/stream.c" 2 -# 49 "user/mpy/py/stream.c" -static mp_obj_t stream_readall(mp_obj_t self_in); - - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode, byte flags) { - byte *buf = buf_; - mp_obj_base_t* s = (mp_obj_base_t*)((void*)stream); - typedef mp_uint_t (*io_func_t)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - io_func_t io_func; - const mp_stream_p_t *stream_p = s->type->protocol; - if (flags & 2) { - io_func = (io_func_t)stream_p->write; - } else { - io_func = stream_p->read; - } - - *errcode = 0; - mp_uint_t done = 0; - while (size > 0) { - mp_uint_t out_sz = io_func(stream, buf, size, errcode); - - - - if (out_sz == 0) { - return done; - } - if (out_sz == ((mp_uint_t)-1)) { - - if ((0) && done != 0) { - *errcode = 0; - } - return done; - } - if (flags & 1) { - return out_sz; - } - - buf += out_sz; - size -= out_sz; - done += out_sz; - } - return done; -} - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - const mp_stream_p_t *stream_p = type->protocol; - if (stream_p == -# 99 "user/mpy/py/stream.c" 3 4 - ((void *)0) - -# 100 "user/mpy/py/stream.c" - || ((flags & (1)) && stream_p->read == -# 100 "user/mpy/py/stream.c" 3 4 - ((void *)0) -# 100 "user/mpy/py/stream.c" - ) - || ((flags & (2)) && stream_p->write == -# 101 "user/mpy/py/stream.c" 3 4 - ((void *)0) -# 101 "user/mpy/py/stream.c" - ) - || ((flags & (4)) && stream_p->ioctl == -# 102 "user/mpy/py/stream.c" 3 4 - ((void *)0) -# 102 "user/mpy/py/stream.c" - )) { - - mp_raise_msg(&mp_type_OSError, "stream operation not supported"); - } - return stream_p; -} - -mp_obj_t mp_stream_close(mp_obj_t stream) { - - mp_obj_t dest[2]; - mp_load_method(stream, MP_QSTR_close, dest); - return mp_call_method_n_kw(0, 0, dest); -} - -static mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (1)); - - - - - mp_int_t sz; - if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) { - return stream_readall(args[0]); - } -# 216 "user/mpy/py/stream.c" - vstr_t vstr; - vstr_init_len(&vstr, sz); - int error; - mp_uint_t out_sz = mp_stream_rw(args[0], vstr.buf, sz, &error, flags); - if (error != 0) { - vstr_clear(&vstr); - if ((0)) { - - - - - - return (((mp_obj_t)&mp_const_none_obj)); - } - mp_raise_OSError(error); - } else { - vstr.len = out_sz; - return mp_obj_new_str_from_vstr((((stream_p)->is_text) ? &mp_type_str : &mp_type_bytes), &vstr); - } -} - -static mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) { - return stream_read_generic(n_args, args, 0); -} -const mp_obj_fun_builtin_var_t mp_stream_read_obj = {{&mp_type_fun_builtin_var}, -# 240 "user/mpy/py/stream.c" 3 4 -0 -# 240 "user/mpy/py/stream.c" -, 1, 2, .fun.var = stream_read}; - -static mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) { - return stream_read_generic(n_args, args, 0 | 1); -} -const mp_obj_fun_builtin_var_t mp_stream_read1_obj = {{&mp_type_fun_builtin_var}, -# 245 "user/mpy/py/stream.c" 3 4 -0 -# 245 "user/mpy/py/stream.c" -, 1, 2, .fun.var = stream_read1}; - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags) { - mp_get_stream_raise(self_in, (2)); - - int error; - mp_uint_t out_sz = mp_stream_rw(self_in, (void*)buf, len, &error, flags); - if (error != 0) { - if ((0)) { - - - - return (((mp_obj_t)&mp_const_none_obj)); - } - mp_raise_OSError(error); - } else { - return ((mp_obj_t)((((mp_uint_t)(out_sz)) << 1) | 1)); - } -} - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len) { - mp_stream_write(((mp_obj_t)self), buf, len, 2); -} - -static mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, (1)); - size_t max_len = (size_t)-1; - size_t off = 0; - if (n_args == 3) { - max_len = mp_obj_get_int_truncated(args[2]); - } else if (n_args == 4) { - off = mp_obj_get_int_truncated(args[2]); - max_len = mp_obj_get_int_truncated(args[3]); - if (off > bufinfo.len) { - off = bufinfo.len; - } - } - bufinfo.len -= off; - return mp_stream_write(args[0], (byte*)bufinfo.buf + off, ((bufinfo.len) < (max_len) ? (bufinfo.len) : (max_len)), 2); -} -const mp_obj_fun_builtin_var_t mp_stream_write_obj = {{&mp_type_fun_builtin_var}, -# 287 "user/mpy/py/stream.c" 3 4 -0 -# 287 "user/mpy/py/stream.c" -, 2, 4, .fun.var = stream_write_method}; - -static mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(arg, &bufinfo, (1)); - return mp_stream_write(self_in, bufinfo.buf, bufinfo.len, 2 | 1); -} -const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj = {{&mp_type_fun_builtin_2}, .fun._2 = stream_write1_method}; - -static mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) { - mp_get_stream_raise(args[0], (1)); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, (2)); - - - - - mp_uint_t len = bufinfo.len; - if (n_args > 2) { - len = mp_obj_get_int(args[2]); - if (len > bufinfo.len) { - len = bufinfo.len; - } - } - - int error; - mp_uint_t out_sz = mp_stream_rw(args[0], bufinfo.buf, len, &error, 0); - if (error != 0) { - if ((0)) { - return (((mp_obj_t)&mp_const_none_obj)); - } - mp_raise_OSError(error); - } else { - return ((mp_obj_t)((((mp_uint_t)(out_sz)) << 1) | 1)); - } -} -const mp_obj_fun_builtin_var_t mp_stream_readinto_obj = {{&mp_type_fun_builtin_var}, -# 323 "user/mpy/py/stream.c" 3 4 -0 -# 323 "user/mpy/py/stream.c" -, 2, 3, .fun.var = stream_readinto}; - -static mp_obj_t stream_readall(mp_obj_t self_in) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(self_in, (1)); - - mp_uint_t total_size = 0; - vstr_t vstr; - vstr_init(&vstr, 256); - char *p = vstr.buf; - mp_uint_t current_read = 256; - while ( -# 333 "user/mpy/py/stream.c" 3 4 - 1 -# 333 "user/mpy/py/stream.c" - ) { - int error; - mp_uint_t out_sz = stream_p->read(self_in, p, current_read, &error); - if (out_sz == ((mp_uint_t)-1)) { - if ((0)) { - - - - if (total_size == 0) { - return (((mp_obj_t)&mp_const_none_obj)); - } - break; - } - mp_raise_OSError(error); - } - if (out_sz == 0) { - break; - } - total_size += out_sz; - if (out_sz < current_read) { - current_read -= out_sz; - p += out_sz; - } else { - p = vstr_extend(&vstr, 256); - current_read = 256; - } - } - - vstr.len = total_size; - return mp_obj_new_str_from_vstr((((stream_p)->is_text) ? &mp_type_str : &mp_type_bytes), &vstr); -} - - -static mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (1)); - - mp_int_t max_size = -1; - if (n_args > 1) { - max_size = (((mp_int_t)(args[1])) >> 1); - } - - vstr_t vstr; - if (max_size != -1) { - vstr_init(&vstr, max_size); - } else { - vstr_init(&vstr, 16); - } - - while (max_size == -1 || max_size-- != 0) { - char *p = vstr_add_len(&vstr, 1); - if (p == -# 383 "user/mpy/py/stream.c" 3 4 - ((void *)0) -# 383 "user/mpy/py/stream.c" - ) { - mp_raise_msg(&mp_type_MemoryError, "out of memory"); - } - - int error; - mp_uint_t out_sz = stream_p->read(args[0], p, 1, &error); - if (out_sz == ((mp_uint_t)-1)) { - if ((0)) { - if (vstr.len == 1) { - - - - - - - vstr_clear(&vstr); - return (((mp_obj_t)&mp_const_none_obj)); - } else { - goto done; - } - } - mp_raise_OSError(error); - } - if (out_sz == 0) { -done: - - - - vstr_cut_tail_bytes(&vstr, 1); - break; - } - if (*p == '\n') { - break; - } - } - - return mp_obj_new_str_from_vstr((((stream_p)->is_text) ? &mp_type_str : &mp_type_bytes), &vstr); -} -const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj = {{&mp_type_fun_builtin_var}, -# 421 "user/mpy/py/stream.c" 3 4 -0 -# 421 "user/mpy/py/stream.c" -, 1, 2, .fun.var = stream_unbuffered_readline}; - - -static mp_obj_t stream_unbuffered_readlines(mp_obj_t self) { - mp_obj_t lines = mp_obj_new_list(0, -# 425 "user/mpy/py/stream.c" 3 4 - ((void *)0) -# 425 "user/mpy/py/stream.c" - ); - for (;;) { - mp_obj_t line = stream_unbuffered_readline(1, &self); - if (!mp_obj_is_true(line)) { - break; - } - mp_obj_list_append(lines, line); - } - return lines; -} -const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj = {{&mp_type_fun_builtin_1}, .fun._1 = stream_unbuffered_readlines}; - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self) { - mp_obj_t l_in = stream_unbuffered_readline(1, &self); - if (mp_obj_is_true(l_in)) { - return l_in; - } - return (((mp_obj_t)(void*)4)); -} - -static mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (4)); - - struct mp_stream_seek_t seek_s; - - seek_s.offset = mp_obj_get_int(args[1]); - seek_s.whence = 0; - if (n_args == 3) { - seek_s.whence = mp_obj_get_int(args[2]); - } - - int error; - mp_uint_t res = stream_p->ioctl(args[0], (2), (mp_uint_t)(uintptr_t)&seek_s, &error); - if (res == ((mp_uint_t)-1)) { - mp_raise_OSError(error); - } - - - return mp_obj_new_int_from_uint(seek_s.offset); -} -const mp_obj_fun_builtin_var_t mp_stream_seek_obj = {{&mp_type_fun_builtin_var}, -# 465 "user/mpy/py/stream.c" 3 4 -0 -# 465 "user/mpy/py/stream.c" -, 2, 3, .fun.var = stream_seek}; - -static mp_obj_t stream_tell(mp_obj_t self) { - mp_obj_t offset = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); - mp_obj_t whence = ((mp_obj_t)((((mp_uint_t)( -# 469 "user/mpy/py/stream.c" 3 - 1 -# 469 "user/mpy/py/stream.c" - )) << 1) | 1)); - const mp_obj_t args[3] = {self, offset, whence}; - return stream_seek(3, args); -} -const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj = {{&mp_type_fun_builtin_1}, .fun._1 = stream_tell}; - -static mp_obj_t stream_flush(mp_obj_t self) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(self, (4)); - int error; - mp_uint_t res = stream_p->ioctl(self, (1), 0, &error); - if (res == ((mp_uint_t)-1)) { - mp_raise_OSError(error); - } - return (((mp_obj_t)&mp_const_none_obj)); -} -const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj = {{&mp_type_fun_builtin_1}, .fun._1 = stream_flush}; - -static mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], (4)); - - mp_buffer_info_t bufinfo; - uintptr_t val = 0; - if (n_args > 2) { - if (mp_get_buffer(args[2], &bufinfo, (2))) { - val = (uintptr_t)bufinfo.buf; - } else { - val = mp_obj_get_int_truncated(args[2]); - } - } - - int error; - mp_uint_t res = stream_p->ioctl(args[0], mp_obj_get_int(args[1]), val, &error); - if (res == ((mp_uint_t)-1)) { - mp_raise_OSError(error); - } - - return mp_obj_new_int(res); -} -const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj = {{&mp_type_fun_builtin_var}, -# 507 "user/mpy/py/stream.c" 3 4 -0 -# 507 "user/mpy/py/stream.c" -, 2, 3, .fun.var = stream_ioctl}; -# 1 "user/mpy/py/binary.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/binary.c" -# 27 "user/mpy/py/binary.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/binary.c" 2 -# 1 "/usr/arm-none-eabi/include/stdlib.h" 1 3 -# 10 "/usr/arm-none-eabi/include/stdlib.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 11 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 12 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 17 "/usr/arm-none-eabi/include/stdlib.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 19 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 20 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/stdlib.h" 1 3 -# 21 "/usr/arm-none-eabi/include/stdlib.h" 2 3 -# 33 "/usr/arm-none-eabi/include/stdlib.h" 3 - - -typedef struct -{ - int quot; - int rem; -} div_t; - -typedef struct -{ - long quot; - long rem; -} ldiv_t; - - -typedef struct -{ - long long int quot; - long long int rem; -} lldiv_t; - - - - -typedef int (*__compar_fn_t) (const void *, const void *); - - - - - - - -int __locale_mb_cur_max (void); - - - -void abort (void) __attribute__ ((__noreturn__)); -int abs (int); - - - - - -int atexit (void (*__func)(void)); -double atof (const char *__nptr); - - - -int atoi (const char *__nptr); -int _atoi_r (struct _reent *, const char *__nptr); -long atol (const char *__nptr); -long _atol_r (struct _reent *, const char *__nptr); -void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) - - - - ; -void * calloc (size_t __nmemb, size_t __size) ; -div_t div (int __numer, int __denom); -void exit (int __status) __attribute__ ((__noreturn__)); -void free (void *) ; -char * getenv (const char *__string); -char * _getenv_r (struct _reent *, const char *__string); -char * _findenv (const char *, int *); -char * _findenv_r (struct _reent *, const char *, int *); - - - - -long labs (long); -ldiv_t ldiv (long __numer, long __denom); -void * malloc (size_t __size) ; -int mblen (const char *, size_t); -int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); -int mbtowc (wchar_t *restrict, const char *restrict, size_t); -int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -int wctomb (char *, wchar_t); -int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); -size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t); -size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *); -size_t wcstombs (char *restrict, const wchar_t *restrict, size_t); -size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *); -# 133 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * _mkdtemp_r (struct _reent *, char *); -int _mkostemp_r (struct _reent *, char *, int); -int _mkostemps_r (struct _reent *, char *, int, int); -int _mkstemp_r (struct _reent *, char *); -int _mkstemps_r (struct _reent *, char *, int); -char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))); -void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); -int rand (void); -void * realloc (void * __r, size_t __size) ; -# 156 "/usr/arm-none-eabi/include/stdlib.h" 3 -void srand (unsigned __seed); -double strtod (const char *restrict __n, char **restrict __end_PTR); -double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR); - -float strtof (const char *restrict __n, char **restrict __end_PTR); - - - - - - - -long strtol (const char *restrict __n, char **restrict __end_PTR, int __base); -long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base); -unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base); -# 188 "/usr/arm-none-eabi/include/stdlib.h" 3 -int system (const char *__string); -# 199 "/usr/arm-none-eabi/include/stdlib.h" 3 -void _Exit (int __status) __attribute__ ((__noreturn__)); - - - - -int _putenv_r (struct _reent *, char *__string); -void * _reallocf_r (struct _reent *, void *, size_t); - - - -int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); -# 221 "/usr/arm-none-eabi/include/stdlib.h" 3 -char * __itoa (int, char *, int); -char * __utoa (unsigned, char *, int); -# 260 "/usr/arm-none-eabi/include/stdlib.h" 3 -long long atoll (const char *__nptr); - -long long _atoll_r (struct _reent *, const char *__nptr); - -long long llabs (long long); -lldiv_t lldiv (long long __numer, long long __denom); -long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base); - -long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base); - -unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base); -# 281 "/usr/arm-none-eabi/include/stdlib.h" 3 -int _unsetenv_r (struct _reent *, const char *__string); - - - - - - -char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); - -void * _malloc_r (struct _reent *, size_t) ; -void * _calloc_r (struct _reent *, size_t, size_t) ; -void _free_r (struct _reent *, void *) ; -void * _realloc_r (struct _reent *, void *, size_t) ; -void _mstats_r (struct _reent *, char *); - -int _system_r (struct _reent *, const char *); - -void __eprintf (const char *, const char *, unsigned int, const char *); -# 318 "/usr/arm-none-eabi/include/stdlib.h" 3 -extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict); - -extern long double strtold (const char *restrict, char **restrict); -# 335 "/usr/arm-none-eabi/include/stdlib.h" 3 - -# 29 "user/mpy/py/binary.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/binary.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 31 "user/mpy/py/binary.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 32 "user/mpy/py/binary.c" 2 - -# 1 "user/mpy/py/binary.h" 1 -# 29 "user/mpy/py/binary.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/binary.h" 2 - - - - - -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 34 "user/mpy/py/binary.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 35 "user/mpy/py/binary.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 - - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 36 "user/mpy/py/binary.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/binary.c" 2 - - - - - - - -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) { - size_t size = 0; - int align = 1; - switch (struct_type) { - case '<': case '>': - switch (val_type) { - case 'b': case 'B': - size = 1; break; - case 'h': case 'H': - size = 2; break; - case 'i': case 'I': - size = 4; break; - case 'l': case 'L': - size = 4; break; - case 'q': case 'Q': - size = 8; break; - case 'P': case 'O': case 'S': - size = sizeof(void*); break; - case 'f': - size = sizeof(float); break; - case 'd': - size = sizeof(double); break; - } - break; - case '@': { - - - - - - - - switch (val_type) { - case 0: - case 'b': case 'B': - align = size = 1; break; - case 'h': case 'H': - align = -# 81 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 81 "user/mpy/py/binary.c" - struct { char c; short t; } -# 81 "user/mpy/py/binary.c" 3 4 - , -# 81 "user/mpy/py/binary.c" - t -# 81 "user/mpy/py/binary.c" 3 4 - ) -# 81 "user/mpy/py/binary.c" - ; - size = sizeof(short); break; - case 'i': case 'I': - align = -# 84 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 84 "user/mpy/py/binary.c" - struct { char c; int t; } -# 84 "user/mpy/py/binary.c" 3 4 - , -# 84 "user/mpy/py/binary.c" - t -# 84 "user/mpy/py/binary.c" 3 4 - ) -# 84 "user/mpy/py/binary.c" - ; - size = sizeof(int); break; - case 'l': case 'L': - align = -# 87 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 87 "user/mpy/py/binary.c" - struct { char c; long t; } -# 87 "user/mpy/py/binary.c" 3 4 - , -# 87 "user/mpy/py/binary.c" - t -# 87 "user/mpy/py/binary.c" 3 4 - ) -# 87 "user/mpy/py/binary.c" - ; - size = sizeof(long); break; - case 'q': case 'Q': - align = -# 90 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 90 "user/mpy/py/binary.c" - struct { char c; long long t; } -# 90 "user/mpy/py/binary.c" 3 4 - , -# 90 "user/mpy/py/binary.c" - t -# 90 "user/mpy/py/binary.c" 3 4 - ) -# 90 "user/mpy/py/binary.c" - ; - size = sizeof(long long); break; - case 'P': case 'O': case 'S': - align = -# 93 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 93 "user/mpy/py/binary.c" - struct { char c; void* t; } -# 93 "user/mpy/py/binary.c" 3 4 - , -# 93 "user/mpy/py/binary.c" - t -# 93 "user/mpy/py/binary.c" 3 4 - ) -# 93 "user/mpy/py/binary.c" - ; - size = sizeof(void*); break; - case 'f': - align = -# 96 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 96 "user/mpy/py/binary.c" - struct { char c; float t; } -# 96 "user/mpy/py/binary.c" 3 4 - , -# 96 "user/mpy/py/binary.c" - t -# 96 "user/mpy/py/binary.c" 3 4 - ) -# 96 "user/mpy/py/binary.c" - ; - size = sizeof(float); break; - case 'd': - align = -# 99 "user/mpy/py/binary.c" 3 4 - __builtin_offsetof ( -# 99 "user/mpy/py/binary.c" - struct { char c; double t; } -# 99 "user/mpy/py/binary.c" 3 4 - , -# 99 "user/mpy/py/binary.c" - t -# 99 "user/mpy/py/binary.c" 3 4 - ) -# 99 "user/mpy/py/binary.c" - ; - size = sizeof(double); break; - } - } - } - - if (size == 0) { - mp_raise_ValueError("bad typecode"); - } - - if (palign != -# 109 "user/mpy/py/binary.c" 3 4 - ((void *)0) -# 109 "user/mpy/py/binary.c" - ) { - *palign = align; - } - return size; -} - -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { - mp_int_t val = 0; - switch (typecode) { - case 'b': - val = ((signed char*)p)[index]; - break; - case 0: - case 'B': - val = ((unsigned char*)p)[index]; - break; - case 'h': - val = ((short*)p)[index]; - break; - case 'H': - val = ((unsigned short*)p)[index]; - break; - case 'i': - return mp_obj_new_int(((int*)p)[index]); - case 'I': - return mp_obj_new_int_from_uint(((unsigned int*)p)[index]); - case 'l': - return mp_obj_new_int(((long*)p)[index]); - case 'L': - return mp_obj_new_int_from_uint(((unsigned long*)p)[index]); -# 152 "user/mpy/py/binary.c" - case 'O': - return ((mp_obj_t*)p)[index]; - - case 'P': - return mp_obj_new_int((mp_int_t)(uintptr_t)((void**)p)[index]); - } - return ((mp_obj_t)((((mp_uint_t)(val)) << 1) | 1)); -} - - - - -long long mp_binary_get_int(mp_uint_t size, -# 164 "user/mpy/py/binary.c" 3 4 - _Bool -# 164 "user/mpy/py/binary.c" - is_signed, -# 164 "user/mpy/py/binary.c" 3 4 - _Bool -# 164 "user/mpy/py/binary.c" - big_endian, const byte *src) { - int delta; - if (!big_endian) { - delta = -1; - src += size - 1; - } else { - delta = 1; - } - - long long val = 0; - if (is_signed && *src & 0x80) { - val = -1; - } - for (uint i = 0; i < size; i++) { - val <<= 8; - val |= *src; - src += delta; - } - - return val; -} - - -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) { - byte *p = *ptr; - mp_uint_t align; - - size_t size = mp_binary_get_size(struct_type, val_type, &align); - if (struct_type == '@') { - - p = (byte*)(void*)(((uintptr_t)(p) + (((size_t)align) - 1)) & ~(((size_t)align) - 1)); - - struct_type = '<'; - - - - } - *ptr = p + size; - - long long val = mp_binary_get_int(size, (val_type > 'Z'), (struct_type == '>'), p); - - if (val_type == 'O') { - return (mp_obj_t)(mp_uint_t)val; - } else if (val_type == 'S') { - const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val; - return mp_obj_new_str(s_val, strlen(s_val), -# 209 "user/mpy/py/binary.c" 3 4 - 0 -# 209 "user/mpy/py/binary.c" - ); -# 218 "user/mpy/py/binary.c" - } else if ((val_type > 'Z')) { - if ((long long)((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) <= val && val <= (long long)((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)))))) { - return mp_obj_new_int((mp_int_t)val); - } else { - return mp_obj_new_int_from_ll(val); - } - } else { - if ((unsigned long long)val <= (unsigned long long)((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)))))) { - return mp_obj_new_int_from_uint((mp_uint_t)val); - } else { - return mp_obj_new_int_from_ull(val); - } - } -} - -void mp_binary_set_int(mp_uint_t val_sz, -# 233 "user/mpy/py/binary.c" 3 4 - _Bool -# 233 "user/mpy/py/binary.c" - big_endian, byte *dest, mp_uint_t val) { - if ((1) && !big_endian) { - memcpy(dest, &val, val_sz); - } else if ((!(1)) && big_endian) { - - memcpy(dest, (byte*)&val + sizeof(mp_uint_t) - val_sz, val_sz); - } else { - const byte *src; - if ((1)) { - src = (const byte*)&val + val_sz; - } else { - src = (const byte*)&val + sizeof(mp_uint_t); - } - while (val_sz--) { - *dest++ = *--src; - } - } -} - -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr) { - byte *p = *ptr; - mp_uint_t align; - - size_t size = mp_binary_get_size(struct_type, val_type, &align); - if (struct_type == '@') { - - p = (byte*)(void*)(((uintptr_t)(p) + (((size_t)align) - 1)) & ~(((size_t)align) - 1)); - if ((1)) { - struct_type = '<'; - } else { - struct_type = '>'; - } - } - *ptr = p + size; - - mp_uint_t val; - switch (val_type) { - case 'O': - val = (mp_uint_t)val_in; - break; -# 294 "user/mpy/py/binary.c" - default: - - - - - - - { - val = mp_obj_get_int(val_in); - - if ((sizeof(mp_uint_t)) < 8 && size > sizeof(val)) { - int c = ((val_type > 'Z') && (mp_int_t)val < 0) ? 0xff : 0x00; - memset(p, c, size); - if (struct_type == '>') { - p += size - sizeof(val); - } - } - } - } - - mp_binary_set_int((((size_t)size) < (sizeof(val)) ? ((size_t)size) : (sizeof(val))), struct_type == '>', p, val); -} - -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) { - switch (typecode) { -# 328 "user/mpy/py/binary.c" - case 'O': - ((mp_obj_t*)p)[index] = val_in; - break; - default: -# 340 "user/mpy/py/binary.c" - mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in)); - } -} - -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val) { - switch (typecode) { - case 'b': - ((signed char*)p)[index] = val; - break; - case 0: - case 'B': - ((unsigned char*)p)[index] = val; - break; - case 'h': - ((short*)p)[index] = val; - break; - case 'H': - ((unsigned short*)p)[index] = val; - break; - case 'i': - ((int*)p)[index] = val; - break; - case 'I': - ((unsigned int*)p)[index] = val; - break; - case 'l': - ((long*)p)[index] = val; - break; - case 'L': - ((unsigned long*)p)[index] = val; - break; -# 388 "user/mpy/py/binary.c" - case 'P': - ((void**)p)[index] = (void*)(uintptr_t)val; - break; - } -} -# 1 "user/mpy/py/builtinimport.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/builtinimport.c" -# 28 "user/mpy/py/builtinimport.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/builtinimport.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/builtinimport.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/builtinimport.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 33 "user/mpy/py/builtinimport.c" 2 -# 1 "user/mpy/py/compile.h" 1 -# 29 "user/mpy/py/compile.h" -# 1 "user/mpy/py/lexer.h" 1 -# 32 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/compile.h" 2 -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 31 "user/mpy/py/compile.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 32 "user/mpy/py/compile.h" 2 - - -enum { - MP_EMIT_OPT_NONE, - MP_EMIT_OPT_BYTECODE, - MP_EMIT_OPT_NATIVE_PYTHON, - MP_EMIT_OPT_VIPER, - MP_EMIT_OPT_ASM, -}; - - - -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, -# 44 "user/mpy/py/compile.h" 3 4 - _Bool -# 44 "user/mpy/py/compile.h" - is_repl); - - - - - - - -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); -# 34 "user/mpy/py/builtinimport.c" 2 -# 1 "user/mpy/py/objmodule.h" 1 -# 31 "user/mpy/py/objmodule.h" -extern const mp_map_t mp_builtin_module_map; -extern const mp_map_t mp_builtin_module_weak_links_map; - -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); -# 35 "user/mpy/py/builtinimport.c" 2 -# 1 "user/mpy/py/persistentcode.h" 1 -# 33 "user/mpy/py/persistentcode.h" -mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader); -mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len); -mp_raw_code_t *mp_raw_code_load_file(const char *filename); - -void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print); -void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename); -# 36 "user/mpy/py/builtinimport.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/builtinimport.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 38 "user/mpy/py/builtinimport.c" 2 -# 1 "user/mpy/py/frozenmod.h" 1 -# 31 "user/mpy/py/frozenmod.h" -enum { - MP_FROZEN_NONE, - MP_FROZEN_STR, - MP_FROZEN_MPY, -}; - -int mp_find_frozen_module(const char *str, size_t len, void **data); -const char *mp_find_frozen_str(const char *str, size_t *len); -mp_import_stat_t mp_frozen_stat(const char *str); -# 39 "user/mpy/py/builtinimport.c" 2 -# 50 "user/mpy/py/builtinimport.c" - -# 50 "user/mpy/py/builtinimport.c" 3 4 -_Bool -# 50 "user/mpy/py/builtinimport.c" - mp_obj_is_package(mp_obj_t module) { - mp_obj_t dest[2]; - mp_load_method_maybe(module, MP_QSTR___path__, dest); - return dest[0] != (((mp_obj_t)(void*)0)); -} - - - -static mp_import_stat_t mp_import_stat_any(const char *path) { - - mp_import_stat_t st = mp_frozen_stat(path); - if (st != MP_IMPORT_STAT_NO_EXIST) { - return st; - } - - return mp_import_stat(path); -} - -static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); - if (stat == MP_IMPORT_STAT_FILE) { - return stat; - } -# 82 "user/mpy/py/builtinimport.c" - return MP_IMPORT_STAT_NO_EXIST; -} - -static mp_import_stat_t stat_dir_or_file(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); - (void)0; - if (stat == MP_IMPORT_STAT_DIR) { - return stat; - } - - - vstr_add_str(path, ".py"); - return stat_file_py_or_mpy(path); -} - -static mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { -# 107 "user/mpy/py/builtinimport.c" - vstr_add_strn(dest, file_str, file_len); - return stat_dir_or_file(dest); -# 131 "user/mpy/py/builtinimport.c" -} - - -static void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) { - - - - - - - mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); - mp_parse_compile_execute(lex, MP_PARSE_FILE_INPUT, mod_globals, mod_globals); -} - - - -static void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code) { - - - - - - - - mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); - - - mp_obj_dict_t *volatile old_globals = mp_globals_get(); - mp_obj_dict_t *volatile old_locals = mp_locals_get(); - - - mp_globals_set(mod_globals); - mp_locals_set(mod_globals); - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t module_fun = mp_make_function_from_raw_code(raw_code, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0))); - mp_call_function_0(module_fun); - - - nlr_pop(); - mp_globals_set(old_globals); - mp_locals_set(old_locals); - } else { - - mp_globals_set(old_globals); - mp_locals_set(old_locals); - nlr_jump(nlr.ret_val); - } -} - - -static void do_load(mp_obj_t module_obj, vstr_t *file) { - - char *file_str = vstr_null_terminated_str(file); - - - - - - void *modref; - int frozen_type = mp_find_frozen_module(file_str, file->len, &modref); -# 207 "user/mpy/py/builtinimport.c" - if (frozen_type == MP_FROZEN_MPY) { - do_execute_raw_code(module_obj, modref); - return; - } -# 225 "user/mpy/py/builtinimport.c" - { - mp_lexer_t *lex = mp_lexer_new_from_file(file_str); - do_load_from_lexer(module_obj, lex); - return; - } - - - - - -} - -static void chop_component(const char *start, const char **end) { - const char *p = *end; - while (p > start) { - if (*--p == '.') { - *end = p; - return; - } - } - *end = p; -} - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { -# 258 "user/mpy/py/builtinimport.c" - mp_obj_t module_name = args[0]; - mp_obj_t fromtuple = (((mp_obj_t)&mp_const_none_obj)); - mp_int_t level = 0; - if (n_args >= 4) { - fromtuple = args[3]; - if (n_args >= 5) { - level = (((mp_int_t)(args[4])) >> 1); - if (level < 0) { - mp_raise_ValueError( -# 266 "user/mpy/py/builtinimport.c" 3 4 - ((void *)0) -# 266 "user/mpy/py/builtinimport.c" - ); - } - } - } - - size_t mod_len; - const char *mod_str = mp_obj_str_get_data(module_name, &mod_len); - - if (level != 0) { - - - - - - - - level--; - mp_obj_t this_name_q = mp_obj_dict_get(((mp_obj_t)mp_globals_get()), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2))); - -# 284 "user/mpy/py/builtinimport.c" 3 - (( -# 284 "user/mpy/py/builtinimport.c" - this_name_q != (((mp_obj_t)(void*)0)) -# 284 "user/mpy/py/builtinimport.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/builtinimport.c", 284, __func__, -# 284 "user/mpy/py/builtinimport.c" - "this_name_q != MP_OBJ_NULL" -# 284 "user/mpy/py/builtinimport.c" 3 - )) -# 284 "user/mpy/py/builtinimport.c" - ; - - - - - - - mp_map_t *globals_map = &mp_globals_get()->map; - mp_map_elem_t *elem = mp_map_lookup(globals_map, ((mp_obj_t)((((mp_uint_t)(MP_QSTR___path__)) << 2) | 2)), MP_MAP_LOOKUP); - -# 293 "user/mpy/py/builtinimport.c" 3 4 - _Bool -# 293 "user/mpy/py/builtinimport.c" - is_pkg = (elem != -# 293 "user/mpy/py/builtinimport.c" 3 4 - ((void *)0) -# 293 "user/mpy/py/builtinimport.c" - ); -# 302 "user/mpy/py/builtinimport.c" - size_t this_name_l; - const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l); - - const char *p = this_name + this_name_l; - if (!is_pkg) { - - - chop_component(this_name, &p); - } - - while (level--) { - chop_component(this_name, &p); - } - - - if (p == this_name) { - mp_raise_ValueError("cannot perform relative import"); - } - - uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); - char *new_mod = -# 322 "user/mpy/py/builtinimport.c" 3 - __builtin_alloca( -# 322 "user/mpy/py/builtinimport.c" - new_mod_l -# 322 "user/mpy/py/builtinimport.c" 3 - ) -# 322 "user/mpy/py/builtinimport.c" - ; - memcpy(new_mod, this_name, p - this_name); - if (mod_len != 0) { - new_mod[p - this_name] = '.'; - memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len); - } - - qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); - (void)0; - module_name = ((mp_obj_t)((((mp_uint_t)(new_mod_q)) << 2) | 2)); - mod_str = new_mod; - mod_len = new_mod_l; - } - - - qstr module_name_qstr = mp_obj_str_get_qstr(module_name); - mp_obj_t module_obj = mp_module_get(module_name_qstr); - if (module_obj != (((mp_obj_t)(void*)0))) { - (void)0; - - char *p = strchr(mod_str, '.'); - if (p == -# 343 "user/mpy/py/builtinimport.c" 3 4 - ((void *)0) -# 343 "user/mpy/py/builtinimport.c" - ) { - return module_obj; - } - - if (fromtuple != (((mp_obj_t)&mp_const_none_obj))) { - return module_obj; - } - - qstr pkg_name = qstr_from_strn(mod_str, p - mod_str); - return mp_module_get(pkg_name); - } - (void)0; - - uint last = 0; - vstr_t path; char path_buf[((256))]; vstr_init_fixed_buf(&path, ((256)), path_buf); - module_obj = (((mp_obj_t)(void*)0)); - mp_obj_t top_module_obj = (((mp_obj_t)(void*)0)); - mp_obj_t outer_module_obj = (((mp_obj_t)(void*)0)); - uint i; - for (i = 1; i <= mod_len; i++) { - if (i == mod_len || mod_str[i] == '.') { - - qstr mod_name = qstr_from_strn(mod_str, i); - (void)0; - (void)0; - - - mp_import_stat_t stat; - if (vstr_len(&path) == 0) { - - stat = find_file(mod_str, i, &path); - } else { - - vstr_add_char(&path, '/'); - vstr_add_strn(&path, mod_str + last, i - last); - stat = stat_dir_or_file(&path); - } - (void)0; - - if (stat == MP_IMPORT_STAT_NO_EXIST) { -# 395 "user/mpy/py/builtinimport.c" - { - - - if (((1)) == (1)) { - mp_raise_msg(&mp_type_ImportError, "module not found"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_ImportError, "no module named '%q'", mod_name))) - ; - } - } - } else { - - module_obj = mp_module_get(mod_name); - } - - if (module_obj == (((mp_obj_t)(void*)0))) { - - - module_obj = mp_obj_new_module(mod_name); -# 423 "user/mpy/py/builtinimport.c" - if (i == mod_len && fromtuple == (((mp_obj_t)&mp_const_false_obj)) && stat != MP_IMPORT_STAT_DIR) { - mp_obj_module_t *o = ((void*)module_obj); - mp_obj_dict_store(((mp_obj_t)o->globals), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR___main__)) << 2) | 2))); - - - - - - - } - - if (stat == MP_IMPORT_STAT_DIR) { - (void)0; - - - mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(&path), vstr_len(&path), -# 438 "user/mpy/py/builtinimport.c" 3 4 - 0 -# 438 "user/mpy/py/builtinimport.c" - )); - size_t orig_path_len = path.len; - vstr_add_char(&path, '/'); - vstr_add_str(&path, "__init__.py"); - if (stat_file_py_or_mpy(&path) != MP_IMPORT_STAT_FILE) { - - } else { - do_load(module_obj, &path); - } - path.len = orig_path_len; - } else { - do_load(module_obj, &path); - - - - - } - } - if (outer_module_obj != (((mp_obj_t)(void*)0))) { - qstr s = qstr_from_strn(mod_str + last, i - last); - mp_store_attr(outer_module_obj, s, module_obj); - } - outer_module_obj = module_obj; - if (top_module_obj == (((mp_obj_t)(void*)0))) { - top_module_obj = module_obj; - } - last = i + 1; - } - } - - - if (fromtuple != (((mp_obj_t)&mp_const_none_obj))) { - return module_obj; - } - - return top_module_obj; -} -const mp_obj_fun_builtin_var_t mp_builtin___import___obj = {{&mp_type_fun_builtin_var}, -# 475 "user/mpy/py/builtinimport.c" 3 4 -0 -# 475 "user/mpy/py/builtinimport.c" -, 1, 5, .fun.var = mp_builtin___import__}; -# 1 "user/mpy/py/builtinevex.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/builtinevex.c" -# 27 "user/mpy/py/builtinevex.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/builtinevex.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 4 -# 5 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 9 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 - -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 30 "user/mpy/py/builtinevex.c" 2 -# 1 "user/mpy/py/objfun.h" 1 -# 29 "user/mpy/py/objfun.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objfun.h" 2 - -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 31 "user/mpy/py/builtinevex.c" 2 -# 1 "user/mpy/py/compile.h" 1 -# 29 "user/mpy/py/compile.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/compile.h" 2 -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 31 "user/mpy/py/compile.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 32 "user/mpy/py/compile.h" 2 - - -enum { - MP_EMIT_OPT_NONE, - MP_EMIT_OPT_BYTECODE, - MP_EMIT_OPT_NATIVE_PYTHON, - MP_EMIT_OPT_VIPER, - MP_EMIT_OPT_ASM, -}; - - - -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, -# 44 "user/mpy/py/compile.h" 3 4 - _Bool -# 44 "user/mpy/py/compile.h" - is_repl); - - - - - - - -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); -# 32 "user/mpy/py/builtinevex.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/builtinevex.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 34 "user/mpy/py/builtinevex.c" 2 -# 112 "user/mpy/py/builtinevex.c" -static mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) { - - mp_obj_dict_t *globals = mp_globals_get(); - mp_obj_dict_t *locals = mp_locals_get(); - for (size_t i = 1; i < 3 && i < n_args; ++i) { - if (args[i] != (((mp_obj_t)&mp_const_none_obj))) { - if (!(MP_OBJ_IS_OBJ(args[i]) && (((mp_obj_base_t*)((void*)args[i]))->type == (&mp_type_dict)))) { - mp_raise_TypeError( -# 119 "user/mpy/py/builtinevex.c" 3 4 - ((void *)0) -# 119 "user/mpy/py/builtinevex.c" - ); - } - locals = ((void*)args[i]); - if (i == 1) { - globals = locals; - } - } - } - - - - - - - - size_t str_len; - const char *str = mp_obj_str_get_data(args[0], &str_len); - - - - mp_lexer_t *lex; - if ((0) && parse_input_kind == MP_PARSE_SINGLE_INPUT) { - lex = mp_lexer_new_from_file(str); - parse_input_kind = MP_PARSE_FILE_INPUT; - } else { - lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0); - } - - return mp_parse_compile_execute(lex, parse_input_kind, globals, locals); -} - -static mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) { - return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT); -} -const mp_obj_fun_builtin_var_t mp_builtin_eval_obj = {{&mp_type_fun_builtin_var}, -# 153 "user/mpy/py/builtinevex.c" 3 4 -0 -# 153 "user/mpy/py/builtinevex.c" -, 1, 3, .fun.var = mp_builtin_eval}; - -static mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) { - return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT); -} -const mp_obj_fun_builtin_var_t mp_builtin_exec_obj = {{&mp_type_fun_builtin_var}, -# 158 "user/mpy/py/builtinevex.c" 3 4 -0 -# 158 "user/mpy/py/builtinevex.c" -, 1, 3, .fun.var = mp_builtin_exec}; -# 1 "user/mpy/py/builtinhelp.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/builtinhelp.c" -# 27 "user/mpy/py/builtinhelp.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/builtinhelp.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/builtinhelp.c" 2 - -# 1 "user/mpy/py/builtin.h" 1 -# 29 "user/mpy/py/builtin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/builtin.h" 2 - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 31 "user/mpy/py/builtinhelp.c" 2 -# 1 "user/mpy/py/objmodule.h" 1 -# 31 "user/mpy/py/objmodule.h" -extern const mp_map_t mp_builtin_module_map; -extern const mp_map_t mp_builtin_module_weak_links_map; - -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); -# 32 "user/mpy/py/builtinhelp.c" 2 -# 1 "user/mpy/py/modarray.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modarray.c" -# 27 "user/mpy/py/modarray.c" -# 1 "user/mpy/py/builtin.h" 1 -# 29 "user/mpy/py/builtin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/builtin.h" 2 - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 28 "user/mpy/py/modarray.c" 2 -# 1 "user/mpy/py/modbuiltins.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modbuiltins.c" -# 27 "user/mpy/py/modbuiltins.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/modbuiltins.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/modbuiltins.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 30 "user/mpy/py/smallint.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/smallint.h" 2 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 32 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 31 "user/mpy/py/objint.h" 2 - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 33 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 34 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/objtype.h" 1 -# 33 "user/mpy/py/objtype.h" -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 35 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 36 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 38 "user/mpy/py/modbuiltins.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 39 "user/mpy/py/modbuiltins.c" 2 -# 51 "user/mpy/py/modbuiltins.c" -static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) { - -# 52 "user/mpy/py/modbuiltins.c" 3 - (( -# 52 "user/mpy/py/modbuiltins.c" - 2 <= n_args -# 52 "user/mpy/py/modbuiltins.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/modbuiltins.c", 52, __func__, -# 52 "user/mpy/py/modbuiltins.c" - "2 <= n_args" -# 52 "user/mpy/py/modbuiltins.c" 3 - )) -# 52 "user/mpy/py/modbuiltins.c" - ; - - - mp_obj_dict_t *old_locals = mp_locals_get(); - mp_obj_t class_locals = mp_obj_new_dict(0); - mp_locals_set(((void*)class_locals)); - - - mp_obj_t cell = mp_call_function_0(args[0]); - - - mp_locals_set(old_locals); - - - mp_obj_t meta; - if (n_args == 2) { - - meta = ((mp_obj_t)&mp_type_type); - } else { - - meta = ((mp_obj_t)mp_obj_get_type(args[2])); - } - - - - - mp_obj_t meta_args[3]; - meta_args[0] = args[1]; - meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); - meta_args[2] = class_locals; - mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args); - - - if (cell != (((mp_obj_t)&mp_const_none_obj))) { - mp_obj_cell_set(cell, new_class); - } - - return new_class; -} -const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj = {{&mp_type_fun_builtin_var}, -# 91 "user/mpy/py/modbuiltins.c" 3 4 -0 -# 91 "user/mpy/py/modbuiltins.c" -, 2, (0xffff), .fun.var = mp_builtin___build_class__}; - -static mp_obj_t mp_builtin_abs(mp_obj_t o_in) { -# 113 "user/mpy/py/modbuiltins.c" - return mp_obj_int_abs(o_in); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_abs}; - -static mp_obj_t mp_builtin_all(mp_obj_t o_in) { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(o_in, &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - if (!mp_obj_is_true(item)) { - return (((mp_obj_t)&mp_const_false_obj)); - } - } - return (((mp_obj_t)&mp_const_true_obj)); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_all}; - -static mp_obj_t mp_builtin_any(mp_obj_t o_in) { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(o_in, &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - if (mp_obj_is_true(item)) { - return (((mp_obj_t)&mp_const_true_obj)); - } - } - return (((mp_obj_t)&mp_const_false_obj)); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_any}; - -static mp_obj_t mp_builtin_bin(mp_obj_t o_in) { - mp_obj_t args[] = { ((mp_obj_t)((((mp_uint_t)(MP_QSTR__brace_open__colon__hash_b_brace_close_)) << 2) | 2)), o_in }; - return mp_obj_str_format((sizeof(args) / sizeof((args)[0])), args, -# 145 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 145 "user/mpy/py/modbuiltins.c" - ); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_bin}; - -static mp_obj_t mp_builtin_callable(mp_obj_t o_in) { - if (mp_obj_is_callable(o_in)) { - return (((mp_obj_t)&mp_const_true_obj)); - } else { - return (((mp_obj_t)&mp_const_false_obj)); - } -} -const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_callable}; - -static mp_obj_t mp_builtin_chr(mp_obj_t o_in) { -# 185 "user/mpy/py/modbuiltins.c" - mp_int_t ord = mp_obj_get_int(o_in); - if (0 <= ord && ord <= 0xff) { - char str[1] = {ord}; - return mp_obj_new_str(str, 1, -# 188 "user/mpy/py/modbuiltins.c" 3 4 - 1 -# 188 "user/mpy/py/modbuiltins.c" - ); - } else { - mp_raise_ValueError("chr() arg not in range(256)"); - } - -} -const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_chr}; - -static mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { - - - mp_obj_dict_t *dict = -# 199 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 199 "user/mpy/py/modbuiltins.c" - ; - mp_map_t *members = -# 200 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 200 "user/mpy/py/modbuiltins.c" - ; - if (n_args == 0) { - - dict = mp_locals_get(); - } else { - - if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_module)))) { - dict = mp_obj_module_get_globals(args[0]); - } else { - mp_obj_type_t *type; - if ((MP_OBJ_IS_OBJ(args[0]) && (((mp_obj_base_t*)((void*)args[0]))->type == (&mp_type_type)))) { - type = ((void*)args[0]); - } else { - type = mp_obj_get_type(args[0]); - } - if (type->locals_dict != -# 215 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 215 "user/mpy/py/modbuiltins.c" - && type->locals_dict->base.type == &mp_type_dict) { - dict = type->locals_dict; - } - } - if (((mp_obj_get_type(args[0]))->make_new == mp_obj_instance_make_new)) { - mp_obj_instance_t *inst = ((void*)args[0]); - members = &inst->members; - } - } - - mp_obj_t dir = mp_obj_new_list(0, -# 225 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 225 "user/mpy/py/modbuiltins.c" - ); - if (dict != -# 226 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 226 "user/mpy/py/modbuiltins.c" - ) { - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - mp_obj_list_append(dir, dict->map.table[i].key); - } - } - } - if (members != -# 233 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 233 "user/mpy/py/modbuiltins.c" - ) { - for (size_t i = 0; i < members->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(members, i)) { - mp_obj_list_append(dir, members->table[i].key); - } - } - } - return dir; -} -const mp_obj_fun_builtin_var_t mp_builtin_dir_obj = {{&mp_type_fun_builtin_var}, -# 242 "user/mpy/py/modbuiltins.c" 3 4 -0 -# 242 "user/mpy/py/modbuiltins.c" -, 0, 1, .fun.var = mp_builtin_dir}; - -static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) { - return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_divmod}; - -static mp_obj_t mp_builtin_hash(mp_obj_t o_in) { - - return mp_unary_op(MP_UNARY_OP_HASH, o_in); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_hash}; - -static mp_obj_t mp_builtin_hex(mp_obj_t o_in) { - return mp_binary_op(MP_BINARY_OP_MODULO, ((mp_obj_t)((((mp_uint_t)(MP_QSTR__percent__hash_x)) << 2) | 2)), o_in); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_hex}; -# 289 "user/mpy/py/modbuiltins.c" -static mp_obj_t mp_builtin_iter(mp_obj_t o_in) { - return mp_getiter(o_in, -# 290 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 290 "user/mpy/py/modbuiltins.c" - ); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_iter}; -# 350 "user/mpy/py/modbuiltins.c" -static mp_obj_t mp_builtin_next(mp_obj_t o) { - mp_obj_t ret = mp_iternext_allow_raise(o); - if (ret == (((mp_obj_t)(void*)4))) { - nlr_jump(((void*)mp_obj_new_exception(&mp_type_StopIteration))); - } else { - return ret; - } -} -const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_next}; - -static mp_obj_t mp_builtin_oct(mp_obj_t o_in) { - return mp_binary_op(MP_BINARY_OP_MODULO, ((mp_obj_t)((((mp_uint_t)(MP_QSTR__percent__hash_o)) << 2) | 2)), o_in); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_oct}; - -static mp_obj_t mp_builtin_ord(mp_obj_t o_in) { - size_t len; - const char *str = mp_obj_str_get_data(o_in, &len); -# 392 "user/mpy/py/modbuiltins.c" - if (len == 1) { - - return mp_obj_new_int(((const byte*)str)[0]); - } - - - if (((1)) == (1)) { - mp_raise_TypeError("ord expects a character"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "ord() expected a character, but string of length %d found", (int)len))) - ; - } -} -const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_ord}; - -static mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) { - switch (n_args) { - case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]); - default: - - mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported"); - - - - - - } -} -const mp_obj_fun_builtin_var_t mp_builtin_pow_obj = {{&mp_type_fun_builtin_var}, -# 420 "user/mpy/py/modbuiltins.c" 3 4 -0 -# 420 "user/mpy/py/modbuiltins.c" -, 2, 3, .fun.var = mp_builtin_pow}; - -static mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sep)) << 2) | 2)), MP_MAP_LOOKUP); - mp_map_elem_t *end_elem = mp_map_lookup(kwargs, ((mp_obj_t)((((mp_uint_t)(MP_QSTR_end)) << 2) | 2)), MP_MAP_LOOKUP); - const char *sep_data = " "; - size_t sep_len = 1; - const char *end_data = "\n"; - size_t end_len = 1; - if (sep_elem != -# 429 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 429 "user/mpy/py/modbuiltins.c" - && sep_elem->value != (((mp_obj_t)&mp_const_none_obj))) { - sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len); - } - if (end_elem != -# 432 "user/mpy/py/modbuiltins.c" 3 4 - ((void *)0) -# 432 "user/mpy/py/modbuiltins.c" - && end_elem->value != (((mp_obj_t)&mp_const_none_obj))) { - end_data = mp_obj_str_get_data(end_elem->value, &end_len); - } -# 444 "user/mpy/py/modbuiltins.c" - for (size_t i = 0; i < n_args; i++) { - if (i > 0) { - - - - mp_print_strn(&mp_plat_print, sep_data, sep_len, 0, 0, 0); - - } - - - - mp_obj_print_helper(&mp_plat_print, args[i], PRINT_STR); - - } - - - - mp_print_strn(&mp_plat_print, end_data, end_len, 0, 0, 0); - - return (((mp_obj_t)&mp_const_none_obj)); -} -const mp_obj_fun_builtin_var_t mp_builtin_print_obj = {{&mp_type_fun_builtin_var}, -# 465 "user/mpy/py/modbuiltins.c" 3 4 -1 -# 465 "user/mpy/py/modbuiltins.c" -, 0, (0xffff), .fun.kw = mp_builtin_print}; - -static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { - if (o != (((mp_obj_t)&mp_const_none_obj))) { - mp_obj_print_helper(&mp_plat_print, o, PRINT_REPR); - mp_print_str(&mp_plat_print, "\n"); - - - - - - } - return (((mp_obj_t)&mp_const_none_obj)); -} -const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin___repl_print__}; - -static mp_obj_t mp_builtin_repr(mp_obj_t o_in) { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - mp_obj_print_helper(&print, o_in, PRINT_REPR); - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_builtin_repr}; - -static mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) { - mp_obj_t o_in = args[0]; - if ((MP_OBJ_IS_SMALL_INT(o_in) || (MP_OBJ_IS_OBJ(o_in) && (((mp_obj_base_t*)((void*)o_in))->type == (&mp_type_int))))) { - return o_in; - } -# 509 "user/mpy/py/modbuiltins.c" - mp_int_t r = mp_obj_get_int(o_in); - return mp_obj_new_int(r); - -} -const mp_obj_fun_builtin_var_t mp_builtin_round_obj = {{&mp_type_fun_builtin_var}, -# 513 "user/mpy/py/modbuiltins.c" 3 4 -0 -# 513 "user/mpy/py/modbuiltins.c" -, 1, 2, .fun.var = mp_builtin_round}; - -static mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) { - mp_obj_t value; - switch (n_args) { - case 1: value = ((mp_obj_t)((((mp_uint_t)(0)) << 1) | 1)); break; - default: value = args[1]; break; - } - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(args[0], &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != (((mp_obj_t)(void*)4))) { - value = mp_binary_op(MP_BINARY_OP_ADD, value, item); - } - return value; -} -const mp_obj_fun_builtin_var_t mp_builtin_sum_obj = {{&mp_type_fun_builtin_var}, -# 529 "user/mpy/py/modbuiltins.c" 3 4 -0 -# 529 "user/mpy/py/modbuiltins.c" -, 1, 2, .fun.var = mp_builtin_sum}; - -static mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - if (n_args > 1) { - mp_raise_TypeError("must use keyword argument for key function"); - } - mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); - mp_obj_list_sort(1, &self, kwargs); - - return self; -} -const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj = {{&mp_type_fun_builtin_var}, -# 540 "user/mpy/py/modbuiltins.c" 3 4 -1 -# 540 "user/mpy/py/modbuiltins.c" -, 1, (0xffff), .fun.kw = mp_builtin_sorted}; - - -static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t defval) { - mp_obj_t dest[2]; - - ((defval == (((mp_obj_t)(void*)0))) ? mp_load_method : mp_load_method_maybe)(base, attr, dest); - if (dest[0] == (((mp_obj_t)(void*)0))) { - return defval; - } else if (dest[1] == (((mp_obj_t)(void*)0))) { - - return dest[0]; - } else { - - return mp_obj_new_bound_meth(dest[0], dest[1]); - } -} - -static mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) { - mp_obj_t defval = (((mp_obj_t)(void*)0)); - if (n_args > 2) { - defval = args[2]; - } - return mp_load_attr_default(args[0], mp_obj_str_get_qstr(args[1]), defval); -} -const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj = {{&mp_type_fun_builtin_var}, -# 565 "user/mpy/py/modbuiltins.c" 3 4 -0 -# 565 "user/mpy/py/modbuiltins.c" -, 2, 3, .fun.var = mp_builtin_getattr}; - -static mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) { - mp_store_attr(base, mp_obj_str_get_qstr(attr), value); - return (((mp_obj_t)&mp_const_none_obj)); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj = {{&mp_type_fun_builtin_3}, .fun._3 = mp_builtin_setattr}; -# 580 "user/mpy/py/modbuiltins.c" -static mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { - qstr attr = mp_obj_str_get_qstr(attr_in); - - mp_obj_t dest[2]; - - - - - mp_load_method_maybe(object_in, attr, dest); - - return mp_obj_new_bool(dest[0] != (((mp_obj_t)(void*)0))); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj = {{&mp_type_fun_builtin_2}, .fun._2 = mp_builtin_hasattr}; - -static mp_obj_t mp_builtin_globals(void) { - return ((mp_obj_t)mp_globals_get()); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_builtin_globals}; - -static mp_obj_t mp_builtin_locals(void) { - return ((mp_obj_t)mp_locals_get()); -} -const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_builtin_locals}; - - -const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_obj_id}; -const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mp_obj_len}; - -static const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR_builtins)) << 2) | 2)) }, - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___build_class__)) << 2) | 2)), (&mp_builtin___build_class___obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___import__)) << 2) | 2)), (&mp_builtin___import___obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___repl_print__)) << 2) | 2)), (&mp_builtin___repl_print___obj) }, - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_bool)) << 2) | 2)), (&mp_type_bool) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_bytes)) << 2) | 2)), (&mp_type_bytes) }, - - - - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_dict)) << 2) | 2)), (&mp_type_dict) }, -# 638 "user/mpy/py/modbuiltins.c" - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_int)) << 2) | 2)), (&mp_type_int) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_list)) << 2) | 2)), (&mp_type_list) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_map)) << 2) | 2)), (&mp_type_map) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_object)) << 2) | 2)), (&mp_type_object) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_range)) << 2) | 2)), (&mp_type_range) }, -# 658 "user/mpy/py/modbuiltins.c" - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_str)) << 2) | 2)), (&mp_type_str) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_super)) << 2) | 2)), (&mp_type_super) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_tuple)) << 2) | 2)), (&mp_type_tuple) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_type)) << 2) | 2)), (&mp_type_type) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_zip)) << 2) | 2)), (&mp_type_zip) }, - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_classmethod)) << 2) | 2)), (&mp_type_classmethod) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_staticmethod)) << 2) | 2)), (&mp_type_staticmethod) }, - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_Ellipsis)) << 2) | 2)), (&mp_const_ellipsis_obj) }, - - - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_abs)) << 2) | 2)), (&mp_builtin_abs_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_all)) << 2) | 2)), (&mp_builtin_all_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_any)) << 2) | 2)), (&mp_builtin_any_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_bin)) << 2) | 2)), (&mp_builtin_bin_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_callable)) << 2) | 2)), (&mp_builtin_callable_obj) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_chr)) << 2) | 2)), (&mp_builtin_chr_obj) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_dir)) << 2) | 2)), (&mp_builtin_dir_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_divmod)) << 2) | 2)), (&mp_builtin_divmod_obj) }, - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_eval)) << 2) | 2)), (&mp_builtin_eval_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_exec)) << 2) | 2)), (&mp_builtin_exec_obj) }, - - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_getattr)) << 2) | 2)), (&mp_builtin_getattr_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_setattr)) << 2) | 2)), (&mp_builtin_setattr_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_globals)) << 2) | 2)), (&mp_builtin_globals_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_hasattr)) << 2) | 2)), (&mp_builtin_hasattr_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_hash)) << 2) | 2)), (&mp_builtin_hash_obj) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_hex)) << 2) | 2)), (&mp_builtin_hex_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_id)) << 2) | 2)), (&mp_builtin_id_obj) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_isinstance)) << 2) | 2)), (&mp_builtin_isinstance_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_issubclass)) << 2) | 2)), (&mp_builtin_issubclass_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_iter)) << 2) | 2)), (&mp_builtin_iter_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_len)) << 2) | 2)), (&mp_builtin_len_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_locals)) << 2) | 2)), (&mp_builtin_locals_obj) }, - - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_next)) << 2) | 2)), (&mp_builtin_next_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_oct)) << 2) | 2)), (&mp_builtin_oct_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ord)) << 2) | 2)), (&mp_builtin_ord_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_pow)) << 2) | 2)), (&mp_builtin_pow_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_print)) << 2) | 2)), (&mp_builtin_print_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_repr)) << 2) | 2)), (&mp_builtin_repr_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_round)) << 2) | 2)), (&mp_builtin_round_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sorted)) << 2) | 2)), (&mp_builtin_sorted_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_sum)) << 2) | 2)), (&mp_builtin_sum_obj) }, - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_BaseException)) << 2) | 2)), (&mp_type_BaseException) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ArithmeticError)) << 2) | 2)), (&mp_type_ArithmeticError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_AssertionError)) << 2) | 2)), (&mp_type_AssertionError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_AttributeError)) << 2) | 2)), (&mp_type_AttributeError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_EOFError)) << 2) | 2)), (&mp_type_EOFError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_Exception)) << 2) | 2)), (&mp_type_Exception) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_GeneratorExit)) << 2) | 2)), (&mp_type_GeneratorExit) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ImportError)) << 2) | 2)), (&mp_type_ImportError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_IndentationError)) << 2) | 2)), (&mp_type_IndentationError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_IndexError)) << 2) | 2)), (&mp_type_IndexError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_KeyboardInterrupt)) << 2) | 2)), (&mp_type_KeyboardInterrupt) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_KeyError)) << 2) | 2)), (&mp_type_KeyError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_LookupError)) << 2) | 2)), (&mp_type_LookupError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_MemoryError)) << 2) | 2)), (&mp_type_MemoryError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_NameError)) << 2) | 2)), (&mp_type_NameError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_NotImplementedError)) << 2) | 2)), (&mp_type_NotImplementedError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_OSError)) << 2) | 2)), (&mp_type_OSError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_OverflowError)) << 2) | 2)), (&mp_type_OverflowError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_RuntimeError)) << 2) | 2)), (&mp_type_RuntimeError) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_StopIteration)) << 2) | 2)), (&mp_type_StopIteration) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_SyntaxError)) << 2) | 2)), (&mp_type_SyntaxError) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_SystemExit)) << 2) | 2)), (&mp_type_SystemExit) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_TypeError)) << 2) | 2)), (&mp_type_TypeError) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ValueError)) << 2) | 2)), (&mp_type_ValueError) }, - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_ZeroDivisionError)) << 2) | 2)), (&mp_type_ZeroDivisionError) }, - - - - - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_open)) << 2) | 2)), (mp_obj_t)&mp_builtin_open_obj }, -}; - -const mp_obj_dict_t mp_module_builtins_globals = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(mp_module_builtins_globals_table) / sizeof((mp_module_builtins_globals_table)[0])), .alloc = (sizeof(mp_module_builtins_globals_table) / sizeof((mp_module_builtins_globals_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)mp_module_builtins_globals_table, }, }; - -const mp_obj_module_t mp_module_builtins = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_builtins_globals, -}; -# 1 "user/mpy/py/modcollections.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modcollections.c" -# 27 "user/mpy/py/modcollections.c" -# 1 "user/mpy/py/builtin.h" 1 -# 29 "user/mpy/py/builtin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/builtin.h" 2 - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 28 "user/mpy/py/modcollections.c" 2 -# 1 "user/mpy/py/modgc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modgc.c" -# 27 "user/mpy/py/modgc.c" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 28 "user/mpy/py/modgc.c" 2 - -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 30 "user/mpy/py/modgc.c" 2 -# 1 "user/mpy/py/modio.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modio.c" -# 27 "user/mpy/py/modio.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/modio.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/modio.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/modio.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 32 "user/mpy/py/modio.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 33 "user/mpy/py/modio.c" 2 -# 1 "user/mpy/py/objstringio.h" 1 -# 31 "user/mpy/py/objstringio.h" -typedef struct _mp_obj_stringio_t { - mp_obj_base_t base; - vstr_t *vstr; - - mp_uint_t pos; - - mp_obj_t ref_obj; -} mp_obj_stringio_t; -# 34 "user/mpy/py/modio.c" 2 -# 1 "user/mpy/py/frozenmod.h" 1 -# 29 "user/mpy/py/frozenmod.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/frozenmod.h" 2 - -enum { - MP_FROZEN_NONE, - MP_FROZEN_STR, - MP_FROZEN_MPY, -}; - -int mp_find_frozen_module(const char *str, size_t len, void **data); -const char *mp_find_frozen_str(const char *str, size_t *len); -mp_import_stat_t mp_frozen_stat(const char *str); -# 35 "user/mpy/py/modio.c" 2 -# 1 "user/mpy/py/modmath.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modmath.c" -# 27 "user/mpy/py/modmath.c" -# 1 "user/mpy/py/builtin.h" 1 -# 29 "user/mpy/py/builtin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/builtin.h" 2 - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 28 "user/mpy/py/modmath.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 29 "user/mpy/py/modmath.c" 2 -# 1 "user/mpy/py/modcmath.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modcmath.c" -# 27 "user/mpy/py/modcmath.c" -# 1 "user/mpy/py/builtin.h" 1 -# 29 "user/mpy/py/builtin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/builtin.h" 2 - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 28 "user/mpy/py/modcmath.c" 2 -# 1 "user/mpy/py/modmicropython.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modmicropython.c" -# 27 "user/mpy/py/modmicropython.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/modmicropython.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/py/modmicropython.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 31 "user/mpy/py/modmicropython.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 32 "user/mpy/py/modmicropython.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/modmicropython.c" 2 -# 1 "user/mpy/py/gc.h" 1 -# 34 "user/mpy/py/gc.h" -void gc_init(void *start, void *end); - - - -void gc_lock(void); -void gc_unlock(void); - -# 40 "user/mpy/py/gc.h" 3 4 -_Bool -# 40 "user/mpy/py/gc.h" - gc_is_locked(void); - - -void gc_collect(void); -void gc_collect_start(void); -void gc_collect_root(void **ptrs, size_t len); -void gc_collect_end(void); - -void *gc_alloc(size_t n_bytes, -# 48 "user/mpy/py/gc.h" 3 4 - _Bool -# 48 "user/mpy/py/gc.h" - has_finaliser); -void gc_free(void *ptr); -size_t gc_nbytes(const void *ptr); -void *gc_realloc(void *ptr, size_t n_bytes, -# 51 "user/mpy/py/gc.h" 3 4 - _Bool -# 51 "user/mpy/py/gc.h" - 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); -# 34 "user/mpy/py/modmicropython.c" 2 -# 1 "user/mpy/py/mphal.h" 1 -# 34 "user/mpy/py/mphal.h" -# 1 "user/mpy/mphalport.h" 1 -# 35 "user/mpy/py/mphal.h" 2 - - - -int mp_hal_stdin_rx_chr(void); - - - - - - - -void mp_hal_stdout_tx_strn(const char *str, size_t len); - - - - - - - -void mp_hal_delay_ms(mp_uint_t ms); - - - -void mp_hal_delay_us(mp_uint_t us); - - - - - - - -mp_uint_t mp_hal_ticks_us(void); - - - -mp_uint_t mp_hal_ticks_cpu(void); -# 80 "user/mpy/py/mphal.h" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 37 "user/mpy/extmod/virtpin.h" -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 81 "user/mpy/py/mphal.h" 2 -# 35 "user/mpy/py/modmicropython.c" 2 - - - - -static mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) { - if (n_args == 0) { - return ((mp_obj_t)((((mp_uint_t)((mp_state_ctx.vm.mp_optimise_value))) << 1) | 1)); - } else { - (mp_state_ctx.vm.mp_optimise_value) = mp_obj_get_int(args[0]); - return (((mp_obj_t)&mp_const_none_obj)); - } -} -static const mp_obj_fun_builtin_var_t mp_micropython_opt_level_obj = {{&mp_type_fun_builtin_var}, -# 47 "user/mpy/py/modmicropython.c" 3 4 - 0 -# 47 "user/mpy/py/modmicropython.c" - , 0, 1, .fun.var = mp_micropython_opt_level}; -# 117 "user/mpy/py/modmicropython.c" -static mp_obj_t mp_micropython_heap_lock(void) { - gc_lock(); - return (((mp_obj_t)&mp_const_none_obj)); -} -static const mp_obj_fun_builtin_fixed_t mp_micropython_heap_lock_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_micropython_heap_lock}; - -static mp_obj_t mp_micropython_heap_unlock(void) { - gc_unlock(); - return (((mp_obj_t)&mp_const_none_obj)); -} -static const mp_obj_fun_builtin_fixed_t mp_micropython_heap_unlock_obj = {{&mp_type_fun_builtin_0}, .fun._0 = mp_micropython_heap_unlock}; -# 152 "user/mpy/py/modmicropython.c" -static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = { - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR___name__)) << 2) | 2)), ((mp_obj_t)((((mp_uint_t)(MP_QSTR_micropython)) << 2) | 2)) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_const)) << 2) | 2)), (&mp_identity_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_opt_level)) << 2) | 2)), (&mp_micropython_opt_level_obj) }, -# 172 "user/mpy/py/modmicropython.c" - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_heap_lock)) << 2) | 2)), (&mp_micropython_heap_lock_obj) }, - { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_heap_unlock)) << 2) | 2)), (&mp_micropython_heap_unlock_obj) }, - - - - - - - -}; - -static const mp_obj_dict_t mp_module_micropython_globals = { .base = {&mp_type_dict}, .map = { .all_keys_are_qstrs = 1, .is_fixed = 1, .is_ordered = 1, .used = (sizeof(mp_module_micropython_globals_table) / sizeof((mp_module_micropython_globals_table)[0])), .alloc = (sizeof(mp_module_micropython_globals_table) / sizeof((mp_module_micropython_globals_table)[0])), .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)mp_module_micropython_globals_table, }, }; - -const mp_obj_module_t mp_module_micropython = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_micropython_globals, -}; -# 1 "user/mpy/py/modstruct.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modstruct.c" -# 28 "user/mpy/py/modstruct.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/modstruct.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/modstruct.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/modstruct.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 33 "user/mpy/py/modstruct.c" 2 - -# 1 "user/mpy/py/binary.h" 1 -# 35 "user/mpy/py/binary.h" -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 35 "user/mpy/py/modstruct.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 36 "user/mpy/py/modstruct.c" 2 -# 1 "user/mpy/py/modsys.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modsys.c" -# 28 "user/mpy/py/modsys.c" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 29 "user/mpy/py/modsys.c" 2 - -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 31 "user/mpy/py/modsys.c" 2 - - -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 34 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/objint.h" 1 -# 29 "user/mpy/py/objint.h" -# 1 "user/mpy/py/mpz.h" 1 -# 62 "user/mpy/py/mpz.h" -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -# 89 "user/mpy/py/mpz.h" -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - - - - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, -# 107 "user/mpy/py/mpz.h" 3 4 - _Bool -# 107 "user/mpy/py/mpz.h" - is_signed); - - - -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, -# 111 "user/mpy/py/mpz.h" 3 4 - _Bool -# 111 "user/mpy/py/mpz.h" - neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, -# 112 "user/mpy/py/mpz.h" 3 4 - _Bool -# 112 "user/mpy/py/mpz.h" - big_endian, size_t len, const byte *buf); - -static inline -# 114 "user/mpy/py/mpz.h" 3 4 - _Bool -# 114 "user/mpy/py/mpz.h" - mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline -# 115 "user/mpy/py/mpz.h" 3 4 - _Bool -# 115 "user/mpy/py/mpz.h" - mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * (16); } -mp_int_t mpz_hash(const mpz_t *z); - -# 135 "user/mpy/py/mpz.h" 3 4 -_Bool -# 135 "user/mpy/py/mpz.h" - mpz_as_int_checked(const mpz_t *z, mp_int_t *value); - -# 136 "user/mpy/py/mpz.h" 3 4 -_Bool -# 136 "user/mpy/py/mpz.h" - mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, -# 137 "user/mpy/py/mpz.h" 3 4 - _Bool -# 137 "user/mpy/py/mpz.h" - big_endian, size_t len, byte *buf); - - - -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); -# 30 "user/mpy/py/objint.h" 2 - - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; - - - - - -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - - - - - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl( -# 57 "user/mpy/py/objint.h" 3 4 - _Bool -# 57 "user/mpy/py/objint.h" - big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, -# 58 "user/mpy/py/objint.h" 3 4 - _Bool -# 58 "user/mpy/py/objint.h" - big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); -# 35 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/objtype.h" 1 -# 33 "user/mpy/py/objtype.h" -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 36 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 37 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 38 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 39 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 40 "user/mpy/py/modsys.c" 2 -# 1 "user/mpy/py/moduerrno.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/moduerrno.c" -# 27 "user/mpy/py/moduerrno.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/moduerrno.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/moduerrno.c" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 31 "user/mpy/py/moduerrno.c" 2 -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 32 "user/mpy/py/moduerrno.c" 2 -# 1 "user/mpy/py/modthread.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/modthread.c" -# 27 "user/mpy/py/modthread.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/modthread.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/modthread.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/modthread.c" 2 -# 1 "user/mpy/py/stackctrl.h" 1 -# 31 "user/mpy/py/stackctrl.h" -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); -# 32 "user/mpy/py/modthread.c" 2 -# 1 "user/mpy/py/vm.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/vm.c" -# 28 "user/mpy/py/vm.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 29 "user/mpy/py/vm.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/vm.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/vm.c" 2 - -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 33 "user/mpy/py/vm.c" 2 - -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 35 "user/mpy/py/vm.c" 2 -# 1 "user/mpy/py/objtype.h" 1 -# 33 "user/mpy/py/objtype.h" -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - -} mp_obj_instance_t; - - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - - - -# 44 "user/mpy/py/objtype.h" 3 4 -_Bool -# 44 "user/mpy/py/objtype.h" - mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - - - - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 36 "user/mpy/py/vm.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 32 "user/mpy/py/runtime.h" -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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 37 "user/mpy/py/vm.c" 2 -# 1 "user/mpy/py/bc0.h" 1 -# 38 "user/mpy/py/vm.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 31 "user/mpy/py/bc.h" -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 39 "user/mpy/py/vm.c" 2 -# 56 "user/mpy/py/vm.c" -typedef enum { - UNWIND_RETURN = 1, - UNWIND_JUMP, -} mp_unwind_reason_t; -# 129 "user/mpy/py/vm.c" -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { -# 165 "user/mpy/py/vm.c" - mp_obj_t * fastn; - mp_exc_stack_t * exc_stack; - { - size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); - fastn = &code_state->state[n_state - 1]; - exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); - } - - - volatile -# 174 "user/mpy/py/vm.c" 3 4 - _Bool -# 174 "user/mpy/py/vm.c" - currently_in_except_block = ((uintptr_t)(code_state->exc_sp) & 1); - mp_exc_stack_t *volatile exc_sp = ((void*)((uintptr_t)(code_state->exc_sp) & ~((uintptr_t)3))); -# 184 "user/mpy/py/vm.c" - for (;;) { - nlr_buf_t nlr; -outer_dispatch_loop: - if (nlr_push(&nlr) == 0) { - - const byte *ip = code_state->ip; - mp_obj_t *sp = code_state->sp; - mp_obj_t obj_shared; - - - - - - - - if (inject_exc != (((mp_obj_t)(void*)0)) && *ip != (0x5e)) { - mp_obj_t exc = inject_exc; - inject_exc = (((mp_obj_t)(void*)0)); - exc = mp_make_raise_obj(exc); - do { nlr_pop(); nlr.ret_val = ((void*)exc); goto exception_handler; } while (0); - } - - - for (;;) { -dispatch_loop: - - - - ; - { code_state->ip = ip; }; - switch (*ip++) { - - - case (0x10): - *++sp = ((((mp_obj_t)&mp_const_false_obj))); - break; - - case (0x11): - *++sp = ((((mp_obj_t)&mp_const_none_obj))); - break; - - case (0x12): - *++sp = ((((mp_obj_t)&mp_const_true_obj))); - break; - - case (0x14): { - mp_int_t num = 0; - if ((ip[0] & 0x40) != 0) { - - num--; - } - do { - num = (num << 7) | (*ip & 0x7f); - } while ((*ip++ & 0x80) != 0); - *++sp = (((mp_obj_t)((((mp_uint_t)(num)) << 1) | 1))); - break; - } - - case (0x16): { - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - *++sp = (((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))); - break; - } - - case (0x17): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); mp_obj_t obj = (mp_obj_t)code_state->fun_bc->const_table[unum]; - *++sp = (obj); - break; - } - - case (0x18): - *++sp = ((((mp_obj_t)(void*)0))); - break; - - case (0x19): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - obj_shared = fastn[-unum]; - load_check: - if (obj_shared == (((mp_obj_t)(void*)0))) { - local_name_error: { - ; - mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NameError, "local variable referenced before assignment"); - do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); - } - } - *++sp = (obj_shared); - break; - } - - case (0x1a): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - obj_shared = mp_obj_cell_get(fastn[-unum]); - goto load_check; - } - - - case (0x1b): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - *++sp = (mp_load_name(qst)); - break; - } -# 309 "user/mpy/py/vm.c" - case (0x1c): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - *++sp = (mp_load_global(qst)); - break; - } -# 338 "user/mpy/py/vm.c" - case (0x1d): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - *sp = (mp_load_attr((*sp), qst)); - break; - } -# 375 "user/mpy/py/vm.c" - case (0x1e): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_load_method(*sp, qst, sp); - sp += 1; - break; - } - - case (0x1f): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - sp -= 1; - mp_load_super_method(qst, sp - 1); - break; - } - - case (0x20): - ; - *++sp = (mp_load_build_class()); - break; - - case (0x21): { - ; - mp_obj_t index = (*sp--); - *sp = (mp_obj_subscr((*sp), index, (((mp_obj_t)(void*)8)))); - break; - } - - case (0x22): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - fastn[-unum] = (*sp--); - break; - } - - case (0x23): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - mp_obj_cell_set(fastn[-unum], (*sp--)); - break; - } - - case (0x24): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_store_name(qst, (*sp--)); - break; - } - - case (0x25): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_store_global(qst, (*sp--)); - break; - } - - - case (0x26): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_store_attr(sp[0], qst, sp[-1]); - sp -= 2; - break; - } -# 475 "user/mpy/py/vm.c" - case (0x27): - ; - mp_obj_subscr(sp[-1], sp[0], sp[-2]); - sp -= 3; - break; - - case (0x28): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - if (fastn[-unum] == (((mp_obj_t)(void*)0))) { - goto local_name_error; - } - fastn[-unum] = (((mp_obj_t)(void*)0)); - break; - } - - case (0x29): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - if (mp_obj_cell_get(fastn[-unum]) == (((mp_obj_t)(void*)0))) { - goto local_name_error; - } - mp_obj_cell_set(fastn[-unum], (((mp_obj_t)(void*)0))); - break; - } - - case (0x2a): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_delete_name(qst); - break; - } - - case (0x2b): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_delete_global(qst); - break; - } - - case (0x30): { - mp_obj_t top = (*sp); - *++sp = (top); - break; - } - - case (0x31): - sp += 2; - sp[0] = sp[-2]; - sp[-1] = sp[-3]; - break; - - case (0x32): - sp -= 1; - break; - - case (0x33): { - mp_obj_t top = sp[0]; - sp[0] = sp[-1]; - sp[-1] = top; - break; - } - - case (0x34): { - mp_obj_t top = sp[0]; - sp[0] = sp[-1]; - sp[-1] = sp[-2]; - sp[-2] = top; - break; - } - - case (0x35): { - size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; - ip += slab; - goto pending_exception_check; - } - - case (0x36): { - size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; - if (mp_obj_is_true((*sp--))) { - ip += slab; - } - goto pending_exception_check; - } - - case (0x37): { - size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; - if (!mp_obj_is_true((*sp--))) { - ip += slab; - } - goto pending_exception_check; - } - - case (0x38): { - size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; - if (mp_obj_is_true((*sp))) { - ip += slab; - } else { - sp--; - } - goto pending_exception_check; - } - - case (0x39): { - size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; - if (mp_obj_is_true((*sp))) { - sp--; - } else { - ip += slab; - } - goto pending_exception_check; - } - - case (0x3d): { - ; - - mp_obj_t obj = (*sp); - mp_load_method(obj, MP_QSTR___exit__, sp); - mp_load_method(obj, MP_QSTR___enter__, sp + 2); - mp_obj_t ret = mp_call_method_n_kw(0, 0, sp + 2); - sp += 1; - do { size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; ++exc_sp; exc_sp->handler = ip + ulab; exc_sp->val_sp = ((void*)((uintptr_t)(sp) | (((1) << 1) | currently_in_except_block))); exc_sp->prev_exc = -# 596 "user/mpy/py/vm.c" 3 4 - ((void *)0) -# 596 "user/mpy/py/vm.c" - ; currently_in_except_block = 0; } while (0); - *++sp = (ret); - - break; - } - - case (0x3e): { - ; - - - - - - - if ((*sp) == (((mp_obj_t)&mp_const_none_obj))) { - - sp[1] = (((mp_obj_t)&mp_const_none_obj)); - sp[2] = (((mp_obj_t)&mp_const_none_obj)); - sp -= 2; - mp_call_method_n_kw(3, 0, sp); - *sp = ((((mp_obj_t)&mp_const_none_obj))); - } else if (MP_OBJ_IS_SMALL_INT((*sp))) { - mp_int_t cause_val = (((mp_int_t)((*sp))) >> 1); - if (cause_val == UNWIND_RETURN) { - - mp_obj_t ret_val = sp[-1]; - sp[-1] = (((mp_obj_t)&mp_const_none_obj)); - sp[0] = (((mp_obj_t)&mp_const_none_obj)); - sp[1] = (((mp_obj_t)&mp_const_none_obj)); - mp_call_method_n_kw(3, 0, sp - 3); - sp[-3] = ret_val; - sp[-2] = ((mp_obj_t)((((mp_uint_t)(UNWIND_RETURN)) << 1) | 1)); - } else { - -# 629 "user/mpy/py/vm.c" 3 - (( -# 629 "user/mpy/py/vm.c" - cause_val == UNWIND_JUMP -# 629 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 629, __func__, -# 629 "user/mpy/py/vm.c" - "cause_val == UNWIND_JUMP" -# 629 "user/mpy/py/vm.c" 3 - )) -# 629 "user/mpy/py/vm.c" - ; - - mp_obj_t dest_ip = sp[-2]; - mp_obj_t num_exc = sp[-1]; - sp[-2] = (((mp_obj_t)&mp_const_none_obj)); - sp[-1] = (((mp_obj_t)&mp_const_none_obj)); - sp[0] = (((mp_obj_t)&mp_const_none_obj)); - mp_call_method_n_kw(3, 0, sp - 4); - sp[-4] = dest_ip; - sp[-3] = num_exc; - sp[-2] = ((mp_obj_t)((((mp_uint_t)(UNWIND_JUMP)) << 1) | 1)); - } - sp -= 2; - } else { - -# 643 "user/mpy/py/vm.c" 3 - (( -# 643 "user/mpy/py/vm.c" - mp_obj_is_exception_instance((*sp)) -# 643 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 643, __func__, -# 643 "user/mpy/py/vm.c" - "mp_obj_is_exception_instance(TOP())" -# 643 "user/mpy/py/vm.c" 3 - )) -# 643 "user/mpy/py/vm.c" - ; - - - sp[1] = sp[0]; - sp[0] = ((mp_obj_t)mp_obj_get_type(sp[0])); - sp[2] = (((mp_obj_t)&mp_const_none_obj)); - sp -= 2; - mp_obj_t ret_value = mp_call_method_n_kw(3, 0, sp); - if (mp_obj_is_true(ret_value)) { - - - - - *sp = ((((mp_obj_t)&mp_const_none_obj))); - -# 657 "user/mpy/py/vm.c" 3 - (( -# 657 "user/mpy/py/vm.c" - exc_sp >= exc_stack -# 657 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 657, __func__, -# 657 "user/mpy/py/vm.c" - "exc_sp >= exc_stack" -# 657 "user/mpy/py/vm.c" 3 - )) -# 657 "user/mpy/py/vm.c" - ; - currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; - } else { - - - sp[0] = sp[3]; - } - } - break; - } - - case (0x46): { - ; - size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; - *++sp = ((mp_obj_t)(mp_uint_t)(uintptr_t)(ip + slab)); - *++sp = ((mp_obj_t)(mp_uint_t)(*ip)); -unwind_jump:; - mp_uint_t unum = (mp_uint_t)(*sp--); - while ((unum & 0x7f) > 0) { - unum -= 1; - -# 677 "user/mpy/py/vm.c" 3 - (( -# 677 "user/mpy/py/vm.c" - exc_sp >= exc_stack -# 677 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 677, __func__, -# 677 "user/mpy/py/vm.c" - "exc_sp >= exc_stack" -# 677 "user/mpy/py/vm.c" 3 - )) -# 677 "user/mpy/py/vm.c" - ; - if (((uintptr_t)(exc_sp->val_sp) & 2)) { -# 687 "user/mpy/py/vm.c" - *++sp = ((mp_obj_t)unum); - *++sp = (((mp_obj_t)((((mp_uint_t)(UNWIND_JUMP)) << 1) | 1))); - ip = exc_sp->handler; - exc_sp--; - goto dispatch_loop; - } - currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; - } - ip = (const byte*)((void*)(*sp--)); - if (unum != 0) { - - sp -= ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)); - } - goto pending_exception_check; - } - - - case (0x3f): - case (0x40): { - ; - - - - do { size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; ++exc_sp; exc_sp->handler = ip + ulab; exc_sp->val_sp = ((void*)((uintptr_t)(sp) | ((((code_state->ip[0] == (0x40)) ? 1 : 0) << 1) | currently_in_except_block))); exc_sp->prev_exc = -# 710 "user/mpy/py/vm.c" 3 4 - ((void *)0) -# 710 "user/mpy/py/vm.c" - ; currently_in_except_block = 0; } while (0); - - break; - } - - case (0x41): - ; - - - - if ((*sp) == (((mp_obj_t)&mp_const_none_obj))) { - sp--; - } else if (MP_OBJ_IS_SMALL_INT((*sp))) { - - - mp_unwind_reason_t reason = (((mp_int_t)((*sp--))) >> 1); - if (reason == UNWIND_RETURN) { - goto unwind_return; - } else { - -# 729 "user/mpy/py/vm.c" 3 - (( -# 729 "user/mpy/py/vm.c" - reason == UNWIND_JUMP -# 729 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 729, __func__, -# 729 "user/mpy/py/vm.c" - "reason == UNWIND_JUMP" -# 729 "user/mpy/py/vm.c" 3 - )) -# 729 "user/mpy/py/vm.c" - ; - goto unwind_jump; - } - } else { - -# 733 "user/mpy/py/vm.c" 3 - (( -# 733 "user/mpy/py/vm.c" - mp_obj_is_exception_instance((*sp)) -# 733 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 733, __func__, -# 733 "user/mpy/py/vm.c" - "mp_obj_is_exception_instance(TOP())" -# 733 "user/mpy/py/vm.c" 3 - )) -# 733 "user/mpy/py/vm.c" - ; - do { nlr_pop(); nlr.ret_val = ((void*)(*sp)); goto exception_handler; } while (0); - } - break; - - case (0x42): - ; - *sp = (mp_getiter((*sp), -# 740 "user/mpy/py/vm.c" 3 4 - ((void *)0) -# 740 "user/mpy/py/vm.c" - )); - break; - - - - - - case (0x47): { - ; - mp_obj_t obj = (*sp); - mp_obj_iter_buf_t *iter_buf = (mp_obj_iter_buf_t*)sp; - sp += ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) - 1; - obj = mp_getiter(obj, iter_buf); - if (obj != ((mp_obj_t)iter_buf)) { - - sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 1] = (((mp_obj_t)(void*)0)); - sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 2] = obj; - } - break; - } - - case (0x43): { - ; - size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; - code_state->sp = sp; - mp_obj_t obj; - if (sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 1] == (((mp_obj_t)(void*)0))) { - obj = sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 2]; - } else { - obj = ((mp_obj_t)&sp[-((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + 1]); - } - mp_obj_t value = mp_iternext_allow_raise(obj); - if (value == (((mp_obj_t)(void*)4))) { - sp -= ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)); - ip += ulab; - } else { - *++sp = (value); - } - break; - } - - - case (0x44): - - -# 784 "user/mpy/py/vm.c" 3 - (( -# 784 "user/mpy/py/vm.c" - exc_sp >= exc_stack -# 784 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 784, __func__, -# 784 "user/mpy/py/vm.c" - "exc_sp >= exc_stack" -# 784 "user/mpy/py/vm.c" 3 - )) -# 784 "user/mpy/py/vm.c" - ; - currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; - break; - - - case (0x45): - -# 790 "user/mpy/py/vm.c" 3 - (( -# 790 "user/mpy/py/vm.c" - exc_sp >= exc_stack -# 790 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 790, __func__, -# 790 "user/mpy/py/vm.c" - "exc_sp >= exc_stack" -# 790 "user/mpy/py/vm.c" 3 - )) -# 790 "user/mpy/py/vm.c" - ; - -# 791 "user/mpy/py/vm.c" 3 - (( -# 791 "user/mpy/py/vm.c" - currently_in_except_block -# 791 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 791, __func__, -# 791 "user/mpy/py/vm.c" - "currently_in_except_block" -# 791 "user/mpy/py/vm.c" 3 - )) -# 791 "user/mpy/py/vm.c" - ; - currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; - break; - - case (0x50): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - sp -= unum - 1; - *sp = (mp_obj_new_tuple(unum, sp)); - break; - } - - case (0x51): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - sp -= unum - 1; - *sp = (mp_obj_new_list(unum, sp)); - break; - } - - case (0x53): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - *++sp = (mp_obj_new_dict(unum)); - break; - } - - case (0x54): - ; - sp -= 2; - mp_obj_dict_store(sp[0], sp[2], sp[1]); - break; -# 852 "user/mpy/py/vm.c" - case (0x57): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - mp_obj_t obj = sp[-(unum >> 2)]; - if ((unum & 3) == 0) { - mp_obj_list_append(obj, sp[0]); - sp--; - } else if (!(0) || (unum & 3) == 1) { - mp_obj_dict_store(obj, sp[0], sp[-1]); - sp -= 2; - - - - - - } - break; - } - - case (0x59): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - mp_unpack_sequence(sp[0], unum, sp); - sp += unum - 1; - break; - } - - case (0x5a): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - mp_unpack_ex(sp[0], unum, sp); - sp += (unum & 0xff) + ((unum >> 8) & 0xff); - break; - } - - case (0x60): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; - *++sp = (mp_make_function_from_raw_code(ptr, (((mp_obj_t)(void*)0)), (((mp_obj_t)(void*)0)))); - break; - } - - case (0x61): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; - - mp_obj_t def_dict = (*sp--); - *sp = (mp_make_function_from_raw_code(ptr, (*sp), def_dict)); - break; - } - - case (0x62): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; - size_t n_closed_over = *ip++; - - sp -= n_closed_over - 1; - *sp = (mp_make_closure_from_raw_code(ptr, n_closed_over, sp)); - break; - } - - case (0x63): { - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum]; - size_t n_closed_over = *ip++; - - sp -= 2 + n_closed_over - 1; - *sp = (mp_make_closure_from_raw_code(ptr, 0x100 | n_closed_over, sp)); - break; - } - - case (0x64): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - - - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe); -# 945 "user/mpy/py/vm.c" - *sp = (mp_call_function_n_kw(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1)); - break; - } - - case (0x65): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - - - - - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 2; -# 982 "user/mpy/py/vm.c" - *sp = (mp_call_method_n_kw_var( -# 982 "user/mpy/py/vm.c" 3 4 - 0 -# 982 "user/mpy/py/vm.c" - , unum, sp)); - break; - } - - case (0x66): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - - - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 1; -# 1016 "user/mpy/py/vm.c" - *sp = (mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp)); - break; - } - - case (0x67): { - ; - mp_uint_t unum = 0; do { unum = (unum << 7) + (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); - - - - - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 3; -# 1053 "user/mpy/py/vm.c" - *sp = (mp_call_method_n_kw_var( -# 1053 "user/mpy/py/vm.c" 3 4 - 1 -# 1053 "user/mpy/py/vm.c" - , unum, sp)); - break; - } - - case (0x5b): - ; - - - - - - if (currently_in_except_block) { - currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; - } -unwind_return: - while (exc_sp >= exc_stack) { - if (((uintptr_t)(exc_sp->val_sp) & 2)) { -# 1079 "user/mpy/py/vm.c" - mp_obj_t *finally_sp = ((void*)((uintptr_t)(exc_sp->val_sp) & ~((uintptr_t)3))); - finally_sp[1] = sp[0]; - sp = &finally_sp[1]; - - - - - *++sp = (((mp_obj_t)((((mp_uint_t)(UNWIND_RETURN)) << 1) | 1))); - ip = exc_sp->handler; - exc_sp--; - goto dispatch_loop; - } - exc_sp--; - } - nlr_pop(); - code_state->sp = sp; - -# 1095 "user/mpy/py/vm.c" 3 - (( -# 1095 "user/mpy/py/vm.c" - exc_sp == exc_stack - 1 -# 1095 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 1095, __func__, -# 1095 "user/mpy/py/vm.c" - "exc_sp == exc_stack - 1" -# 1095 "user/mpy/py/vm.c" 3 - )) -# 1095 "user/mpy/py/vm.c" - ; - -# 1106 "user/mpy/py/vm.c" - return MP_VM_RETURN_NORMAL; - - case (0x5c): { - ; - mp_uint_t unum = *ip++; - mp_obj_t obj; - if (unum == 2) { - ; - - sp--; - } - if (unum == 0) { - - obj = (((mp_obj_t)(void*)0)); - for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; e--) { - if (e->prev_exc != -# 1121 "user/mpy/py/vm.c" 3 4 - ((void *)0) -# 1121 "user/mpy/py/vm.c" - ) { - obj = ((mp_obj_t)e->prev_exc); - break; - } - } - if (obj == (((mp_obj_t)(void*)0))) { - obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, "No active exception to reraise"); - do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); - } - } else { - obj = (*sp--); - } - obj = mp_make_raise_obj(obj); - do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); - } - - case (0x5d): -yield: - nlr_pop(); - code_state->ip = ip; - code_state->sp = sp; - code_state->exc_sp = ((void*)((uintptr_t)(exc_sp) | (currently_in_except_block))); - return MP_VM_RETURN_YIELD; - - case (0x5e): { - ; - - - - mp_vm_return_kind_t ret_kind; - mp_obj_t send_value = (*sp--); - mp_obj_t t_exc = (((mp_obj_t)(void*)0)); - mp_obj_t ret_value; - if (inject_exc != (((mp_obj_t)(void*)0))) { - t_exc = inject_exc; - inject_exc = (((mp_obj_t)(void*)0)); - ret_kind = mp_resume((*sp), (((mp_obj_t)(void*)0)), t_exc, &ret_value); - } else { - ret_kind = mp_resume((*sp), send_value, (((mp_obj_t)(void*)0)), &ret_value); - } - - if (ret_kind == MP_VM_RETURN_YIELD) { - ip--; - *++sp = (ret_value); - goto yield; - } else if (ret_kind == MP_VM_RETURN_NORMAL) { - - sp--; - - if (ret_value == (((mp_obj_t)(void*)0)) || ret_value == (((mp_obj_t)(void*)4))) { - - - *++sp = ((((mp_obj_t)&mp_const_none_obj))); - } else { - *++sp = (ret_value); - } - - - - if (t_exc != (((mp_obj_t)(void*)0)) && mp_obj_exception_match(t_exc, ((mp_obj_t)&mp_type_GeneratorExit))) { do { nlr_pop(); nlr.ret_val = ((void*)t_exc); goto exception_handler; } while (0); }; - break; - } else { - -# 1183 "user/mpy/py/vm.c" 3 - (( -# 1183 "user/mpy/py/vm.c" - ret_kind == MP_VM_RETURN_EXCEPTION -# 1183 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 1183, __func__, -# 1183 "user/mpy/py/vm.c" - "ret_kind == MP_VM_RETURN_EXCEPTION" -# 1183 "user/mpy/py/vm.c" 3 - )) -# 1183 "user/mpy/py/vm.c" - ; - - sp--; - if (mp_obj_exception_match(ret_value, ((mp_obj_t)&mp_type_StopIteration))) { - *++sp = (mp_obj_exception_get_value(ret_value)); - - - if (t_exc != (((mp_obj_t)(void*)0)) && mp_obj_exception_match(t_exc, ((mp_obj_t)&mp_type_GeneratorExit))) { do { nlr_pop(); nlr.ret_val = ((void*)t_exc); goto exception_handler; } while (0); }; - break; - } else { - do { nlr_pop(); nlr.ret_val = ((void*)ret_value); goto exception_handler; } while (0); - } - } - } - - case (0x68): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_obj_t obj = (*sp--); - *sp = (mp_import_name(qst, obj, (*sp))); - break; - } - - case (0x69): { - ; - qstr qst = ip[0] | ip[1] << 8; ip += 2;; - mp_obj_t obj = mp_import_from((*sp), qst); - *++sp = (obj); - break; - } - - case (0x6a): - ; - mp_import_all((*sp--)); - break; -# 1248 "user/mpy/py/vm.c" - default: - if (ip[-1] < (0x70) + 64) { - *++sp = (((mp_obj_t)((((mp_uint_t)((mp_int_t)ip[-1] - (0x70) - 16)) << 1) | 1))); - break; - } else if (ip[-1] < (0xb0) + 16) { - obj_shared = fastn[(0xb0) - (mp_int_t)ip[-1]]; - goto load_check; - } else if (ip[-1] < (0xc0) + 16) { - fastn[(0xc0) - (mp_int_t)ip[-1]] = (*sp--); - break; - } else if (ip[-1] < (0xd0) + 7) { - *sp = (mp_unary_op(ip[-1] - (0xd0), (*sp))); - break; - } else if (ip[-1] < (0xd7) + 36) { - mp_obj_t rhs = (*sp--); - mp_obj_t lhs = (*sp); - *sp = (mp_binary_op(ip[-1] - (0xd7), lhs, rhs)); - break; - } else - - { - mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NotImplementedError, "byte code not implemented"); - nlr_pop(); - fastn[0] = obj; - return MP_VM_RETURN_EXCEPTION; - } - - - } - - -pending_exception_check: - -# 1300 "user/mpy/py/vm.c" - if ((mp_state_ctx.vm.mp_pending_exception) != (((mp_obj_t)(void*)0))) { - ; - mp_obj_t obj = (mp_state_ctx.vm.mp_pending_exception); - (mp_state_ctx.vm.mp_pending_exception) = (((mp_obj_t)(void*)0)); - do { nlr_pop(); nlr.ret_val = ((void*)obj); goto exception_handler; } while (0); - } -# 1326 "user/mpy/py/vm.c" - } - - } else { -exception_handler: -# 1341 "user/mpy/py/vm.c" - if (mp_obj_is_subclass_fast(((mp_obj_t)((mp_obj_base_t*)nlr.ret_val)->type), ((mp_obj_t)&mp_type_StopIteration))) { - if (code_state->ip) { - - if (*code_state->ip == (0x43)) { - const byte *ip = code_state->ip + 1; - size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2; - code_state->ip = ip + ulab; - code_state->sp -= ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)); - goto outer_dispatch_loop; - } else if (*code_state->ip == (0x5e)) { - - - *++code_state->sp = mp_obj_exception_get_value(((mp_obj_t)nlr.ret_val)); - code_state->ip++; - goto outer_dispatch_loop; - } - } - } -# 1367 "user/mpy/py/vm.c" - if (nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) { - const byte *ip = code_state->fun_bc->bytecode; - ip = mp_decode_uint_skip(ip); - ip = mp_decode_uint_skip(ip); - ip++; - ip++; - ip++; - ip++; - size_t bc = code_state->ip - ip; - size_t code_info_size = mp_decode_uint_value(ip); - ip = mp_decode_uint_skip(ip); - bc -= code_info_size; - - qstr block_name = ip[0] | (ip[1] << 8); - qstr source_file = ip[2] | (ip[3] << 8); - ip += 4; - - - - - - - size_t source_line = 1; - size_t c; - while ((c = *ip)) { - size_t b, l; - if ((c & 0x80) == 0) { - - b = c & 0x1f; - l = c >> 5; - ip += 1; - } else { - - b = c & 0xf; - l = ((c << 4) & 0x700) | ip[1]; - ip += 2; - } - if (bc >= b) { - bc -= b; - source_line += l; - } else { - - break; - } - } - mp_obj_exception_add_traceback(((mp_obj_t)nlr.ret_val), source_file, source_line, block_name); - } - - while (currently_in_except_block) { - - - -# 1418 "user/mpy/py/vm.c" 3 - (( -# 1418 "user/mpy/py/vm.c" - exc_sp >= exc_stack -# 1418 "user/mpy/py/vm.c" 3 - ) ? (void)0 : __assert_func ("user/mpy/py/vm.c", 1418, __func__, -# 1418 "user/mpy/py/vm.c" - "exc_sp >= exc_stack" -# 1418 "user/mpy/py/vm.c" 3 - )) -# 1418 "user/mpy/py/vm.c" - ; - - - - - - currently_in_except_block = ((uintptr_t)(exc_sp->val_sp) & 1); exc_sp--; ; - } - - if (exc_sp >= exc_stack) { - - currently_in_except_block = 1; - - - code_state->ip = exc_sp->handler; - mp_obj_t *sp = ((void*)((uintptr_t)(exc_sp->val_sp) & ~((uintptr_t)3))); - - exc_sp->prev_exc = nlr.ret_val; - - *++sp = (((mp_obj_t)nlr.ret_val)); - code_state->sp = sp; -# 1453 "user/mpy/py/vm.c" - } else { - - - fastn[0] = ((mp_obj_t)nlr.ret_val); - return MP_VM_RETURN_EXCEPTION; - } - } - } -} -# 1 "user/mpy/py/bc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/bc.c" -# 28 "user/mpy/py/bc.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 29 "user/mpy/py/bc.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/bc.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 31 "user/mpy/py/bc.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 33 "user/mpy/py/bc.c" 2 -# 1 "user/mpy/py/objfun.h" 1 -# 29 "user/mpy/py/objfun.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 35 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objfun.h" 2 - -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 34 "user/mpy/py/bc.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 35 "user/mpy/py/bc.c" 2 -# 1 "user/mpy/py/bc0.h" 1 -# 36 "user/mpy/py/bc.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 29 "user/mpy/py/bc.h" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 37 "user/mpy/py/bc.c" 2 -# 45 "user/mpy/py/bc.c" -mp_uint_t mp_decode_uint(const byte **ptr) { - mp_uint_t unum = 0; - byte val; - const byte *p = *ptr; - do { - val = *p++; - unum = (unum << 7) | (val & 0x7f); - } while ((val & 0x80) != 0); - *ptr = p; - return unum; -} - - - - - - - -mp_uint_t mp_decode_uint_value(const byte *ptr) { - return mp_decode_uint(&ptr); -} - - - -const byte *mp_decode_uint_skip(const byte *ptr) { - while ((*ptr++) & 0x80) { - } - return ptr; -} - -static __attribute__((noreturn)) void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) { - - - (void)f; - (void)expected; - (void)given; - mp_arg_error_terse_mismatch(); -# 91 "user/mpy/py/bc.c" -} -# 110 "user/mpy/py/bc.c" -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) { - - - - - mp_obj_fun_bc_t *self = code_state->fun_bc; - - - code_state->ip = self->bytecode + (size_t)code_state->ip; - - - - - - - size_t n_state = mp_decode_uint(&code_state->ip); - code_state->ip = mp_decode_uint_skip(code_state->ip); - size_t scope_flags = *code_state->ip++; - size_t n_pos_args = *code_state->ip++; - size_t n_kwonly_args = *code_state->ip++; - size_t n_def_pos_args = *code_state->ip++; - - code_state->sp = &code_state->state[0] - 1; - code_state->exc_sp = (mp_exc_stack_t*)(code_state->state + n_state) - 1; - - - memset(code_state->state, 0, n_state * sizeof(*code_state->state)); - - const mp_obj_t *kwargs = args + n_args; - - - mp_obj_t *var_pos_kw_args = &code_state->state[n_state - 1 - n_pos_args - n_kwonly_args]; - - - - if (n_args > n_pos_args) { - - if ((scope_flags & (0x01)) == 0) { - fun_pos_args_mismatch(self, n_pos_args, n_args); - } - - *var_pos_kw_args-- = mp_obj_new_tuple(n_args - n_pos_args, args + n_pos_args); - n_args = n_pos_args; - } else { - if ((scope_flags & (0x01)) != 0) { - (void)0; - *var_pos_kw_args-- = (((mp_obj_t)&mp_const_empty_tuple_obj)); - } - - - if (n_kw == 0 && (scope_flags & (0x08)) == 0) { - if (n_args >= (size_t)(n_pos_args - n_def_pos_args)) { - - for (size_t i = n_args; i < n_pos_args; i++) { - code_state->state[n_state - 1 - i] = self->extra_args[i - (n_pos_args - n_def_pos_args)]; - } - } else { - fun_pos_args_mismatch(self, n_pos_args - n_def_pos_args, n_args); - } - } - } - - - for (size_t i = 0; i < n_args; i++) { - code_state->state[n_state - 1 - i] = args[i]; - } - - - - if (n_kw != 0 || (scope_flags & (0x08)) != 0) { - (void)0; - (void)0; - - mp_obj_t dict = (((mp_obj_t)(void*)0)); - if ((scope_flags & (0x02)) != 0) { - dict = mp_obj_new_dict(n_kw); - *var_pos_kw_args = dict; - } - - - const mp_obj_t *arg_names = (const mp_obj_t*)self->const_table; - - for (size_t i = 0; i < n_kw; i++) { - - mp_obj_t wanted_arg_name = kwargs[2 * i]; - for (size_t j = 0; j < n_pos_args + n_kwonly_args; j++) { - if (wanted_arg_name == arg_names[j]) { - if (code_state->state[n_state - 1 - j] != (((mp_obj_t)(void*)0))) { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function got multiple values for argument '%q'", (((mp_uint_t)(wanted_arg_name)) >> 2)))) - ; - } - code_state->state[n_state - 1 - j] = kwargs[2 * i + 1]; - goto continue2; - } - } - - if ((scope_flags & (0x02)) == 0) { - if (((1)) == (1)) { - mp_raise_TypeError("unexpected keyword argument"); - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unexpected keyword argument '%q'", (((mp_uint_t)(wanted_arg_name)) >> 2)))) - ; - } - } - mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]); -continue2:; - } - - (void)0; - (void)0; - - - mp_obj_t *d = &code_state->state[n_state - n_pos_args]; - mp_obj_t *s = &self->extra_args[n_def_pos_args - 1]; - for (size_t i = n_def_pos_args; i > 0; i--, d++, s--) { - if (*d == (((mp_obj_t)(void*)0))) { - *d = *s; - } - } - - (void)0; - (void)0; - - - while (d < &code_state->state[n_state]) { - if (*d++ == (((mp_obj_t)(void*)0))) { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function missing required positional argument #%d", &code_state->state[n_state] - d))) - ; - } - } - - - - for (size_t i = 0; i < n_kwonly_args; i++) { - if (code_state->state[n_state - 1 - n_pos_args - i] == (((mp_obj_t)(void*)0))) { - mp_map_elem_t *elem = -# 245 "user/mpy/py/bc.c" 3 4 - ((void *)0) -# 245 "user/mpy/py/bc.c" - ; - if ((scope_flags & (0x08)) != 0) { - elem = mp_map_lookup(&((mp_obj_dict_t*)((void*)self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP); - } - if (elem != -# 249 "user/mpy/py/bc.c" 3 4 - ((void *)0) -# 249 "user/mpy/py/bc.c" - ) { - code_state->state[n_state - 1 - n_pos_args - i] = elem->value; - } else { - nlr_jump(((void*)mp_obj_new_exception_msg_varg(&mp_type_TypeError, "function missing required keyword argument '%q'", (((mp_uint_t)(arg_names[n_pos_args + i])) >> 2)))) - ; - } - } - } - - } else { - - if (n_kwonly_args != 0) { - mp_raise_TypeError("function missing keyword-only argument"); - } - if ((scope_flags & (0x02)) != 0) { - *var_pos_kw_args = mp_obj_new_dict(0); - } - } - - - const byte *ip = code_state->ip; - - - ip += mp_decode_uint_value(ip); - - - size_t local_num; - while ((local_num = *ip++) != 255) { - code_state->state[n_state - 1 - local_num] = - mp_obj_new_cell(code_state->state[n_state - 1 - local_num]); - } - - - code_state->ip = ip; - - (void)0; - (void)0; - (void)0; -} -# 1 "user/mpy/py/showbc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/showbc.c" -# 27 "user/mpy/py/showbc.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/showbc.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/showbc.c" 2 - -# 1 "user/mpy/py/bc0.h" 1 -# 31 "user/mpy/py/showbc.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 29 "user/mpy/py/bc.h" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/bc.h" 2 - -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 32 "user/mpy/py/showbc.c" 2 -# 1 "user/mpy/py/repl.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/repl.c" -# 27 "user/mpy/py/repl.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/repl.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 29 "user/mpy/py/repl.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/repl.c" 2 -# 1 "user/mpy/py/repl.h" 1 -# 34 "user/mpy/py/repl.h" - -# 34 "user/mpy/py/repl.h" 3 4 -_Bool -# 34 "user/mpy/py/repl.h" - mp_repl_continue_with_input(const char *input); -size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str); -# 31 "user/mpy/py/repl.c" 2 - - - -static -# 34 "user/mpy/py/repl.c" 3 4 - _Bool -# 34 "user/mpy/py/repl.c" - str_startswith_word(const char *str, const char *head) { - size_t i; - for (i = 0; str[i] && head[i]; i++) { - if (str[i] != head[i]) { - return -# 38 "user/mpy/py/repl.c" 3 4 - 0 -# 38 "user/mpy/py/repl.c" - ; - } - } - return head[i] == '\0' && (str[i] == '\0' || !unichar_isident(str[i])); -} - - -# 44 "user/mpy/py/repl.c" 3 4 -_Bool -# 44 "user/mpy/py/repl.c" - mp_repl_continue_with_input(const char *input) { - - if (input[0] == '\0') { - return -# 47 "user/mpy/py/repl.c" 3 4 - 0 -# 47 "user/mpy/py/repl.c" - ; - } - - - -# 51 "user/mpy/py/repl.c" 3 4 - _Bool -# 51 "user/mpy/py/repl.c" - starts_with_compound_keyword = - input[0] == '@' - || str_startswith_word(input, "if") - || str_startswith_word(input, "while") - || str_startswith_word(input, "for") - || str_startswith_word(input, "try") - || str_startswith_word(input, "with") - || str_startswith_word(input, "def") - || str_startswith_word(input, "class") - - - - ; - - - - - - - - int n_paren = 0; - int n_brack = 0; - int n_brace = 0; - int in_quote = (0); - const char *i; - for (i = input; *i; i++) { - if (*i == '\'') { - if ((in_quote == (0) || in_quote == (3)) && i[1] == '\'' && i[2] == '\'') { - i += 2; - in_quote = (3) - in_quote; - } else if (in_quote == (0) || in_quote == (1)) { - in_quote = (1) - in_quote; - } - } else if (*i == '"') { - if ((in_quote == (0) || in_quote == (4)) && i[1] == '"' && i[2] == '"') { - i += 2; - in_quote = (4) - in_quote; - } else if (in_quote == (0) || in_quote == (2)) { - in_quote = (2) - in_quote; - } - } else if (*i == '\\' && (i[1] == '\'' || i[1] == '"' || i[1] == '\\')) { - if (in_quote != (0)) { - i++; - } - } else if (in_quote == (0)) { - switch (*i) { - case '(': n_paren += 1; break; - case ')': n_paren -= 1; break; - case '[': n_brack += 1; break; - case ']': n_brack -= 1; break; - case '{': n_brace += 1; break; - case '}': n_brace -= 1; break; - default: break; - } - } - } - - - if (n_paren > 0 || n_brack > 0 || n_brace > 0 || in_quote == (3) || in_quote == (4)) { - return -# 110 "user/mpy/py/repl.c" 3 4 - 1 -# 110 "user/mpy/py/repl.c" - ; - } - - - if (i[-1] == '\\') { - return -# 115 "user/mpy/py/repl.c" 3 4 - 1 -# 115 "user/mpy/py/repl.c" - ; - } - - - if (starts_with_compound_keyword && i[-1] != '\n') { - return -# 120 "user/mpy/py/repl.c" 3 4 - 1 -# 120 "user/mpy/py/repl.c" - ; - } - - - return -# 124 "user/mpy/py/repl.c" 3 4 - 0 -# 124 "user/mpy/py/repl.c" - ; -} - -size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str) { - - const char *org_str = str; - const char *top = str + len; - for (const char *s = top; --s >= str;) { - if (!(unichar_isalpha(*s) || unichar_isdigit(*s) || *s == '_' || *s == '.')) { - ++s; - str = s; - break; - } - } - - - mp_obj_dict_t *dict = mp_locals_get(); - - for (;;) { - - const char *s_start = str; - while (str < top && *str != '.') { - ++str; - } - size_t s_len = str - s_start; - - if (str < top) { - - - mp_obj_t obj = (((mp_obj_t)(void*)0)); - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - size_t d_len; - const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); - if (s_len == d_len && strncmp(s_start, d_str, d_len) == 0) { - obj = dict->map.table[i].value; - break; - } - } - } - - if (obj == (((mp_obj_t)(void*)0))) { - - return 0; - } - - - if ((MP_OBJ_IS_OBJ(obj) && (((mp_obj_base_t*)((void*)obj))->type == (&mp_type_module)))) { - dict = mp_obj_module_get_globals(obj); - } else { - mp_obj_type_t *type; - if ((MP_OBJ_IS_OBJ(obj) && (((mp_obj_base_t*)((void*)obj))->type == (&mp_type_type)))) { - type = ((void*)obj); - } else { - type = mp_obj_get_type(obj); - } - if (type->locals_dict != -# 180 "user/mpy/py/repl.c" 3 4 - ((void *)0) -# 180 "user/mpy/py/repl.c" - && type->locals_dict->base.type == &mp_type_dict) { - dict = type->locals_dict; - } else { - - return 0; - } - } - - - ++str; - - } else { - - - - int n_found = 0; - const char *match_str = -# 196 "user/mpy/py/repl.c" 3 4 - ((void *)0) -# 196 "user/mpy/py/repl.c" - ; - size_t match_len = 0; - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - size_t d_len; - const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); - if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { - if (match_str == -# 203 "user/mpy/py/repl.c" 3 4 - ((void *)0) -# 203 "user/mpy/py/repl.c" - ) { - match_str = d_str; - match_len = d_len; - } else { - - - for (size_t j = s_len; j <= match_len && j <= d_len; ++j) { - if (match_str[j] != d_str[j]) { - match_len = j; - break; - } - } - } - ++n_found; - } - } - } - - - if (n_found == 0) { - - - if (s_start == org_str) { - static const char import_str[] = "import "; - if (memcmp(s_start, import_str, s_len) == 0) { - *compl_str = import_str + s_len; - return sizeof(import_str) - 1 - s_len; - } - } - - return 0; - } - - - if (n_found == 1 || match_len > s_len) { - *compl_str = match_str + s_len; - return match_len - s_len; - } - - - - - - - int line_len = (4 * (16)); - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - size_t d_len; - const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); - if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { - int gap = (line_len + (16) - 1) / (16) * (16) - line_len; - if (gap < 2) { - gap += (16); - } - if (line_len + gap + d_len <= (4 * (16))) { - - for (int j = 0; j < gap; ++j) { - mp_print_str(print, " "); - } - mp_print_str(print, d_str); - line_len += gap + d_len; - } else { - mp_printf(print, "\n%s", d_str); - line_len = d_len; - } - } - } - } - mp_print_str(print, "\n"); - - return (size_t)(-1); - } - } -} -# 1 "user/mpy/py/smallint.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/smallint.c" -# 27 "user/mpy/py/smallint.c" -# 1 "user/mpy/py/smallint.h" 1 -# 29 "user/mpy/py/smallint.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/smallint.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/smallint.h" 2 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 28 "user/mpy/py/smallint.c" 2 - - -# 29 "user/mpy/py/smallint.c" 3 4 -_Bool -# 29 "user/mpy/py/smallint.c" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y) { - - if (x > 0) { - if (y > 0) { - if (x > (((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))))) / y)) { - return -# 34 "user/mpy/py/smallint.c" 3 4 - 1 -# 34 "user/mpy/py/smallint.c" - ; - } - } else { - if (y < (((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) / x)) { - return -# 38 "user/mpy/py/smallint.c" 3 4 - 1 -# 38 "user/mpy/py/smallint.c" - ; - } - } - } else { - if (y > 0) { - if (x < (((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1)) / y)) { - return -# 44 "user/mpy/py/smallint.c" 3 4 - 1 -# 44 "user/mpy/py/smallint.c" - ; - } - } else { - if (x != 0 && y < (((mp_int_t)(~(((mp_int_t)(((mp_int_t)(((mp_uint_t)1) << ((sizeof(mp_uint_t)) * 8 - 1))) >> 1))))) / x)) { - return -# 48 "user/mpy/py/smallint.c" 3 4 - 1 -# 48 "user/mpy/py/smallint.c" - ; - } - } - } - return -# 52 "user/mpy/py/smallint.c" 3 4 - 0 -# 52 "user/mpy/py/smallint.c" - ; -} - -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor) { - - dividend %= divisor; - if ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0)) { - dividend += divisor; - } - return dividend; -} - -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom) { - if (num >= 0) { - if (denom < 0) { - num += -denom - 1; - } - } else { - if (denom >= 0) { - num += -denom + 1; - } - } - return num / denom; -} -# 1 "user/mpy/py/frozenmod.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/frozenmod.c" -# 28 "user/mpy/py/frozenmod.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/frozenmod.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/frozenmod.c" 2 - -# 1 "user/mpy/py/lexer.h" 1 -# 31 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 32 "user/mpy/py/frozenmod.c" 2 -# 1 "user/mpy/py/frozenmod.h" 1 -# 31 "user/mpy/py/frozenmod.h" -enum { - MP_FROZEN_NONE, - MP_FROZEN_STR, - MP_FROZEN_MPY, -}; - -int mp_find_frozen_module(const char *str, size_t len, void **data); -const char *mp_find_frozen_str(const char *str, size_t *len); -mp_import_stat_t mp_frozen_stat(const char *str); -# 33 "user/mpy/py/frozenmod.c" 2 -# 80 "user/mpy/py/frozenmod.c" -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 81 "user/mpy/py/frozenmod.c" 2 - -extern const char mp_frozen_mpy_names[]; -extern const mp_raw_code_t *const mp_frozen_mpy_content[]; - -static const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t len) { - const char *name = mp_frozen_mpy_names; - for (size_t i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == len && !memcmp(str, name, l)) { - return mp_frozen_mpy_content[i]; - } - name += l + 1; - } - return -# 94 "user/mpy/py/frozenmod.c" 3 4 - ((void *)0) -# 94 "user/mpy/py/frozenmod.c" - ; -} - - - - - -static mp_import_stat_t mp_frozen_stat_helper(const char *name, const char *str) { - size_t len = strlen(str); - - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l >= len && !memcmp(str, name, len)) { - if (name[len] == 0) { - return MP_IMPORT_STAT_FILE; - } else if (name[len] == '/') { - return MP_IMPORT_STAT_DIR; - } - } - name += l + 1; - } - return MP_IMPORT_STAT_NO_EXIST; -} - -mp_import_stat_t mp_frozen_stat(const char *str) { - mp_import_stat_t stat; -# 129 "user/mpy/py/frozenmod.c" - stat = mp_frozen_stat_helper(mp_frozen_mpy_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - - - return MP_IMPORT_STAT_NO_EXIST; -} - -int mp_find_frozen_module(const char *str, size_t len, void **data) { -# 147 "user/mpy/py/frozenmod.c" - const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len); - if (rc != -# 148 "user/mpy/py/frozenmod.c" 3 4 - ((void *)0) -# 148 "user/mpy/py/frozenmod.c" - ) { - *data = (void*)rc; - return MP_FROZEN_MPY; - } - - return MP_FROZEN_NONE; -} -# 1 "user/mpy/py/../extmod/moductypes.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/moductypes.c" -# 27 "user/mpy/py/../extmod/moductypes.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/../extmod/moductypes.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/moductypes.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/../extmod/moductypes.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/../extmod/moductypes.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/../extmod/moductypes.c" 2 - -# 1 "user/mpy/py/binary.h" 1 -# 35 "user/mpy/py/binary.h" -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 35 "user/mpy/py/../extmod/moductypes.c" 2 -# 1 "user/mpy/py/../extmod/modujson.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modujson.c" -# 27 "user/mpy/py/../extmod/modujson.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modujson.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 30 "user/mpy/py/../extmod/modujson.c" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 29 "user/mpy/py/objlist.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objlist.h" 2 - -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; -# 31 "user/mpy/py/../extmod/modujson.c" 2 -# 1 "user/mpy/py/objstringio.h" 1 -# 31 "user/mpy/py/objstringio.h" -typedef struct _mp_obj_stringio_t { - mp_obj_base_t base; - vstr_t *vstr; - - mp_uint_t pos; - - mp_obj_t ref_obj; -} mp_obj_stringio_t; -# 32 "user/mpy/py/../extmod/modujson.c" 2 -# 1 "user/mpy/py/parsenum.h" 1 -# 30 "user/mpy/py/parsenum.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 31 "user/mpy/py/parsenum.h" 2 - - - -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - allow_imag, -# 35 "user/mpy/py/parsenum.h" 3 4 - _Bool -# 35 "user/mpy/py/parsenum.h" - force_complex, mp_lexer_t *lex); -# 33 "user/mpy/py/../extmod/modujson.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - - -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/../extmod/modujson.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 35 "user/mpy/py/../extmod/modujson.c" 2 -# 1 "user/mpy/py/../extmod/modure.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modure.c" -# 27 "user/mpy/py/../extmod/modure.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modure.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/../extmod/modure.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/../extmod/modure.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/../extmod/modure.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/../extmod/modure.c" 2 -# 1 "user/mpy/py/binary.h" 1 -# 35 "user/mpy/py/binary.h" -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 34 "user/mpy/py/../extmod/modure.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 35 "user/mpy/py/../extmod/modure.c" 2 -# 1 "user/mpy/py/../extmod/moduzlib.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/moduzlib.c" -# 27 "user/mpy/py/../extmod/moduzlib.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/moduzlib.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/moduzlib.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/../extmod/moduzlib.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/../extmod/moduzlib.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 33 "user/mpy/py/../extmod/moduzlib.c" 2 -# 1 "user/mpy/py/../extmod/moduheapq.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/moduheapq.c" -# 27 "user/mpy/py/../extmod/moduheapq.c" -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 4 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 4 -# 5 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 9 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 - -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 28 "user/mpy/py/../extmod/moduheapq.c" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 29 "user/mpy/py/objlist.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objlist.h" 2 - -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; -# 29 "user/mpy/py/../extmod/moduheapq.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 30 "user/mpy/py/../extmod/moduheapq.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - - -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/../extmod/moduheapq.c" 2 -# 1 "user/mpy/py/../extmod/modutimeq.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modutimeq.c" -# 28 "user/mpy/py/../extmod/modutimeq.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/modutimeq.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/../extmod/modutimeq.c" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 29 "user/mpy/py/objlist.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/objlist.h" 2 - -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; -# 32 "user/mpy/py/../extmod/modutimeq.c" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 33 "user/mpy/py/../extmod/modutimeq.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - - -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/../extmod/modutimeq.c" 2 -# 1 "user/mpy/py/smallint.h" 1 -# 64 "user/mpy/py/smallint.h" - -# 64 "user/mpy/py/smallint.h" 3 4 -_Bool -# 64 "user/mpy/py/smallint.h" - mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); -# 35 "user/mpy/py/../extmod/modutimeq.c" 2 -# 1 "user/mpy/py/../extmod/moduhashlib.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/moduhashlib.c" -# 27 "user/mpy/py/../extmod/moduhashlib.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/../extmod/moduhashlib.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/moduhashlib.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/../extmod/moduhashlib.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/../extmod/moduhashlib.c" 2 -# 1 "user/mpy/py/../extmod/modubinascii.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modubinascii.c" -# 27 "user/mpy/py/../extmod/modubinascii.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modubinascii.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 29 "user/mpy/py/../extmod/modubinascii.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/../extmod/modubinascii.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/../extmod/modubinascii.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/../extmod/modubinascii.c" 2 -# 1 "user/mpy/py/binary.h" 1 -# 35 "user/mpy/py/binary.h" -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - is_signed, -# 41 "user/mpy/py/binary.h" 3 4 - _Bool -# 41 "user/mpy/py/binary.h" - big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, -# 42 "user/mpy/py/binary.h" 3 4 - _Bool -# 42 "user/mpy/py/binary.h" - big_endian, byte *dest, mp_uint_t val); -# 34 "user/mpy/py/../extmod/modubinascii.c" 2 -# 1 "user/mpy/extmod/modubinascii.h" 1 -# 29 "user/mpy/extmod/modubinascii.h" -extern mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args); -extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data); -extern mp_obj_t mod_binascii_a2b_base64(mp_obj_t data); -extern mp_obj_t mod_binascii_b2a_base64(mp_obj_t data); -extern mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mod_binascii_hexlify_obj; -extern const mp_obj_fun_builtin_fixed_t mod_binascii_unhexlify_obj; -extern const mp_obj_fun_builtin_fixed_t mod_binascii_a2b_base64_obj; -extern const mp_obj_fun_builtin_fixed_t mod_binascii_b2a_base64_obj; -extern const mp_obj_fun_builtin_var_t mod_binascii_crc32_obj; -# 35 "user/mpy/py/../extmod/modubinascii.c" 2 - -# 1 "user/mpy/py/../extmod/uzlib/tinf.h" 1 -# 44 "user/mpy/py/../extmod/uzlib/tinf.h" -typedef struct { - unsigned short table[16]; - unsigned short trans[288]; -} TINF_TREE; - -struct TINF_DATA; -typedef struct TINF_DATA { - const unsigned char *source; - - - unsigned char (*readSource)(struct TINF_DATA *data); - - unsigned int tag; - unsigned int bitcount; - - - unsigned char *destStart; - - unsigned int destSize; - - unsigned char *dest; - - unsigned int destRemaining; - - - unsigned int checksum; - char checksum_type; - - int btype; - int bfinal; - unsigned int curlen; - int lzOff; - unsigned char *dict_ring; - unsigned int dict_size; - unsigned int dict_idx; - - TINF_TREE ltree; - TINF_TREE dtree; -} TINF_DATA; - - - - - - - -unsigned char uzlib_get_byte(TINF_DATA *d); - - - -void uzlib_init(void); -void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen); -int uzlib_uncompress(TINF_DATA *d); -int uzlib_uncompress_chksum(TINF_DATA *d); - -int uzlib_zlib_parse_header(TINF_DATA *d); -int uzlib_gzip_parse_header(TINF_DATA *d); - - - -void uzlib_compress(void *data, const uint8_t *src, unsigned slen); - - - - -uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum); - -uint32_t uzlib_crc32(const void *data, unsigned int length, uint32_t crc); -# 37 "user/mpy/py/../extmod/modubinascii.c" 2 - -mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { - - - const char *sep = -# 41 "user/mpy/py/../extmod/modubinascii.c" 3 4 - ((void *)0) -# 41 "user/mpy/py/../extmod/modubinascii.c" - ; - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, (1)); - - - - if (bufinfo.len == 0) { - return (((mp_obj_t)&mp_const_empty_bytes_obj)); - } - - vstr_t vstr; - size_t out_len = bufinfo.len * 2; - if (n_args > 1) { - - out_len += bufinfo.len - 1; - sep = mp_obj_str_get_str(args[1]); - } - vstr_init_len(&vstr, out_len); - byte *in = bufinfo.buf, *out = (byte*)vstr.buf; - for (mp_uint_t i = bufinfo.len; i--;) { - byte d = (*in >> 4); - if (d > 9) { - d += 'a' - '9' - 1; - } - *out++ = d + '0'; - d = (*in++ & 0xf); - if (d > 9) { - d += 'a' - '9' - 1; - } - *out++ = d + '0'; - if (sep != -# 71 "user/mpy/py/../extmod/modubinascii.c" 3 4 - ((void *)0) -# 71 "user/mpy/py/../extmod/modubinascii.c" - && i != 0) { - *out++ = *sep; - } - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -const mp_obj_fun_builtin_var_t mod_binascii_hexlify_obj = {{&mp_type_fun_builtin_var}, -# 77 "user/mpy/py/../extmod/modubinascii.c" 3 4 -0 -# 77 "user/mpy/py/../extmod/modubinascii.c" -, 1, 2, .fun.var = mod_binascii_hexlify}; - -mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, (1)); - - if ((bufinfo.len & 1) != 0) { - mp_raise_ValueError("odd-length string"); - } - vstr_t vstr; - vstr_init_len(&vstr, bufinfo.len / 2); - byte *in = bufinfo.buf, *out = (byte*)vstr.buf; - byte hex_byte = 0; - for (mp_uint_t i = bufinfo.len; i--;) { - byte hex_ch = *in++; - if (unichar_isxdigit(hex_ch)) { - hex_byte += unichar_xdigit_value(hex_ch); - } else { - mp_raise_ValueError("non-hex digit found"); - } - if (i & 1) { - hex_byte <<= 4; - } else { - *out++ = hex_byte; - hex_byte = 0; - } - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -const mp_obj_fun_builtin_fixed_t mod_binascii_unhexlify_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mod_binascii_unhexlify}; - -mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, (1)); - if (bufinfo.len % 4 != 0) { - mp_raise_ValueError("incorrect padding"); - } - - vstr_t vstr; - byte *in = bufinfo.buf; - if (bufinfo.len == 0) { - vstr_init_len(&vstr, 0); - } - else { - vstr_init_len(&vstr, ((bufinfo.len / 4) * 3) - ((in[bufinfo.len-1] == '=') ? ((in[bufinfo.len-2] == '=') ? 2 : 1 ) : 0)); - } - byte *out = (byte*)vstr.buf; - for (mp_uint_t i = bufinfo.len; i; i -= 4) { - char hold[4]; - for (int j = 4; j--;) { - if (in[j] >= 'A' && in[j] <= 'Z') { - hold[j] = in[j] - 'A'; - } else if (in[j] >= 'a' && in[j] <= 'z') { - hold[j] = in[j] - 'a' + 26; - } else if (in[j] >= '0' && in[j] <= '9') { - hold[j] = in[j] - '0' + 52; - } else if (in[j] == '+') { - hold[j] = 62; - } else if (in[j] == '/') { - hold[j] = 63; - } else if (in[j] == '=') { - if (j < 2 || i > 4) { - mp_raise_ValueError("incorrect padding"); - } - hold[j] = 64; - } else { - mp_raise_ValueError("invalid character"); - } - } - in += 4; - - *out++ = (hold[0]) << 2 | (hold[1]) >> 4; - if (hold[2] != 64) { - *out++ = (hold[1] & 0x0F) << 4 | hold[2] >> 2; - if (hold[3] != 64) { - *out++ = (hold[2] & 0x03) << 6 | hold[3]; - } - } - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -const mp_obj_fun_builtin_fixed_t mod_binascii_a2b_base64_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mod_binascii_a2b_base64}; - -mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, (1)); - - vstr_t vstr; - vstr_init_len(&vstr, ((bufinfo.len != 0) ? (((bufinfo.len - 1) / 3) + 1) * 4 : 0) + 1); - - - byte *in = bufinfo.buf, *out = (byte*)vstr.buf; - mp_uint_t i; - for (i = bufinfo.len; i >= 3; i -= 3) { - *out++ = (in[0] & 0xFC) >> 2; - *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; - *out++ = (in[1] & 0x0F) << 2 | (in[2] & 0xC0) >> 6; - *out++ = in[2] & 0x3F; - in += 3; - } - if (i != 0) { - *out++ = (in[0] & 0xFC) >> 2; - if (i == 2) { - *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; - *out++ = (in[1] & 0x0F) << 2; - } - else { - *out++ = (in[0] & 0x03) << 4; - *out++ = 64; - } - *out++ = 64; - } - - - out = (byte*)vstr.buf; - for (mp_uint_t j = vstr.len - 1; j--;) { - if (*out < 26) { - *out += 'A'; - } else if (*out < 52) { - *out += 'a' - 26; - } else if (*out < 62) { - *out += '0' - 52; - } else if (*out == 62) { - *out ='+'; - } else if (*out == 63) { - *out = '/'; - } else { - *out = '='; - } - out++; - } - *out = '\n'; - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -const mp_obj_fun_builtin_fixed_t mod_binascii_b2a_base64_obj = {{&mp_type_fun_builtin_1}, .fun._1 = mod_binascii_b2a_base64}; -# 1 "user/mpy/py/../extmod/virtpin.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/virtpin.c" -# 27 "user/mpy/py/../extmod/virtpin.c" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 29 "user/mpy/extmod/virtpin.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/extmod/virtpin.h" 2 - - - - - - - -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 28 "user/mpy/py/../extmod/virtpin.c" 2 - -int mp_virtual_pin_read(mp_obj_t pin) { - mp_obj_base_t* s = (mp_obj_base_t*)((void*)pin); - mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; - return pin_p->ioctl(pin, (1), 0, -# 32 "user/mpy/py/../extmod/virtpin.c" 3 4 - ((void *)0) -# 32 "user/mpy/py/../extmod/virtpin.c" - ); -} - -void mp_virtual_pin_write(mp_obj_t pin, int value) { - mp_obj_base_t* s = (mp_obj_base_t*)((void*)pin); - mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; - pin_p->ioctl(pin, (2), value, -# 38 "user/mpy/py/../extmod/virtpin.c" 3 4 - ((void *)0) -# 38 "user/mpy/py/../extmod/virtpin.c" - ); -} -# 1 "user/mpy/py/../extmod/machine_mem.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/machine_mem.c" -# 27 "user/mpy/py/../extmod/machine_mem.c" -# 1 "user/mpy/extmod/machine_mem.h" 1 -# 29 "user/mpy/extmod/machine_mem.h" -# 1 "user/mpy/py/obj.h" 1 -# 29 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/extmod/machine_mem.h" 2 - -typedef struct _machine_mem_obj_t { - mp_obj_base_t base; - unsigned elem_size; -} machine_mem_obj_t; - -extern const mp_obj_type_t machine_mem_type; - -extern const machine_mem_obj_t machine_mem8_obj; -extern const machine_mem_obj_t machine_mem16_obj; -extern const machine_mem_obj_t machine_mem32_obj; -# 28 "user/mpy/py/../extmod/machine_mem.c" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 29 "user/mpy/py/../extmod/machine_mem.c" 2 -# 1 "user/mpy/py/../extmod/machine_pinbase.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/machine_pinbase.c" -# 27 "user/mpy/py/../extmod/machine_pinbase.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../extmod/machine_pinbase.c" 2 -# 1 "user/mpy/py/../extmod/machine_signal.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/machine_signal.c" -# 27 "user/mpy/py/../extmod/machine_signal.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../extmod/machine_signal.c" 2 -# 1 "user/mpy/py/../extmod/machine_pulse.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/machine_pulse.c" -# 27 "user/mpy/py/../extmod/machine_pulse.c" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 28 "user/mpy/py/../extmod/machine_pulse.c" 2 -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 29 "user/mpy/py/../extmod/machine_pulse.c" 2 -# 1 "user/mpy/extmod/machine_pulse.h" 1 -# 30 "user/mpy/extmod/machine_pulse.h" -# 1 "user/mpy/py/mphal.h" 1 -# 34 "user/mpy/py/mphal.h" -# 1 "user/mpy/mphalport.h" 1 -# 35 "user/mpy/py/mphal.h" 2 - - - - -# 38 "user/mpy/py/mphal.h" -int mp_hal_stdin_rx_chr(void); - - - - - - - -void mp_hal_stdout_tx_strn(const char *str, size_t len); - - - - - - - -void mp_hal_delay_ms(mp_uint_t ms); - - - -void mp_hal_delay_us(mp_uint_t us); - - - - - - - -mp_uint_t mp_hal_ticks_us(void); - - - -mp_uint_t mp_hal_ticks_cpu(void); -# 80 "user/mpy/py/mphal.h" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 37 "user/mpy/extmod/virtpin.h" -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 81 "user/mpy/py/mphal.h" 2 -# 31 "user/mpy/extmod/machine_pulse.h" 2 - -mp_uint_t machine_time_pulse_us(mp_obj_t pin, int pulse_level, mp_uint_t timeout_us); - -extern const mp_obj_fun_builtin_var_t machine_time_pulse_us_obj; -# 30 "user/mpy/py/../extmod/machine_pulse.c" 2 -# 1 "user/mpy/py/../extmod/machine_i2c.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/machine_i2c.c" -# 27 "user/mpy/py/../extmod/machine_i2c.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/machine_i2c.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 29 "user/mpy/py/../extmod/machine_i2c.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/../extmod/machine_i2c.c" 2 - -# 1 "user/mpy/py/mperrno.h" 1 -# 29 "user/mpy/py/mperrno.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 30 "user/mpy/py/mperrno.h" 2 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 32 "user/mpy/py/../extmod/machine_i2c.c" 2 -# 1 "user/mpy/py/mphal.h" 1 -# 34 "user/mpy/py/mphal.h" -# 1 "user/mpy/mphalport.h" 1 -# 35 "user/mpy/py/mphal.h" 2 - - - - -# 38 "user/mpy/py/mphal.h" -int mp_hal_stdin_rx_chr(void); - - - - - - - -void mp_hal_stdout_tx_strn(const char *str, size_t len); - - - - - - - -void mp_hal_delay_ms(mp_uint_t ms); - - - -void mp_hal_delay_us(mp_uint_t us); - - - - - - - -mp_uint_t mp_hal_ticks_us(void); - - - -mp_uint_t mp_hal_ticks_cpu(void); -# 80 "user/mpy/py/mphal.h" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 29 "user/mpy/extmod/virtpin.h" -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/extmod/virtpin.h" 2 - - - - - - - -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 81 "user/mpy/py/mphal.h" 2 -# 33 "user/mpy/py/../extmod/machine_i2c.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/../extmod/machine_i2c.c" 2 -# 1 "user/mpy/extmod/machine_i2c.h" 1 -# 33 "user/mpy/extmod/machine_i2c.h" -typedef struct _mp_machine_i2c_p_t { - int (*start)(mp_obj_base_t *obj); - int (*stop)(mp_obj_base_t *obj); - int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, -# 36 "user/mpy/extmod/machine_i2c.h" 3 4 - _Bool -# 36 "user/mpy/extmod/machine_i2c.h" - nack); - int (*write)(mp_obj_base_t *obj, const uint8_t *src, size_t len); - int (*readfrom)(mp_obj_base_t *obj, uint16_t addr, uint8_t *dest, size_t len, -# 38 "user/mpy/extmod/machine_i2c.h" 3 4 - _Bool -# 38 "user/mpy/extmod/machine_i2c.h" - stop); - int (*writeto)(mp_obj_base_t *obj, uint16_t addr, const uint8_t *src, size_t len, -# 39 "user/mpy/extmod/machine_i2c.h" 3 4 - _Bool -# 39 "user/mpy/extmod/machine_i2c.h" - stop); -} mp_machine_i2c_p_t; - -typedef struct _mp_machine_soft_i2c_obj_t { - mp_obj_base_t base; - uint32_t us_delay; - uint32_t us_timeout; - mp_obj_t scl; - mp_obj_t sda; -} mp_machine_soft_i2c_obj_t; - -extern const mp_obj_type_t machine_i2c_type; -extern const mp_obj_dict_t mp_machine_soft_i2c_locals_dict; - -int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, -# 53 "user/mpy/extmod/machine_i2c.h" 3 4 - _Bool -# 53 "user/mpy/extmod/machine_i2c.h" - stop); -int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, -# 54 "user/mpy/extmod/machine_i2c.h" 3 4 - _Bool -# 54 "user/mpy/extmod/machine_i2c.h" - stop); -# 35 "user/mpy/py/../extmod/machine_i2c.c" 2 -# 1 "user/mpy/py/../extmod/machine_spi.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/machine_spi.c" -# 27 "user/mpy/py/../extmod/machine_spi.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/machine_spi.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/machine_spi.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/../extmod/machine_spi.c" 2 -# 1 "user/mpy/extmod/machine_spi.h" 1 -# 30 "user/mpy/extmod/machine_spi.h" -# 1 "user/mpy/py/mphal.h" 1 -# 34 "user/mpy/py/mphal.h" -# 1 "user/mpy/mphalport.h" 1 -# 35 "user/mpy/py/mphal.h" 2 - - - -int mp_hal_stdin_rx_chr(void); - - - - - - - -void mp_hal_stdout_tx_strn(const char *str, size_t len); - - - - - - - -void mp_hal_delay_ms(mp_uint_t ms); - - - -void mp_hal_delay_us(mp_uint_t us); - - - - - - - -mp_uint_t mp_hal_ticks_us(void); - - - -mp_uint_t mp_hal_ticks_cpu(void); -# 80 "user/mpy/py/mphal.h" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 37 "user/mpy/extmod/virtpin.h" -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 81 "user/mpy/py/mphal.h" 2 -# 31 "user/mpy/extmod/machine_spi.h" 2 - - -typedef struct _mp_machine_spi_p_t { - void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); - void (*deinit)(mp_obj_base_t *obj); - void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); -} mp_machine_spi_p_t; - -typedef struct _mp_machine_soft_spi_obj_t { - mp_obj_base_t base; - uint32_t delay_half; - uint8_t polarity; - uint8_t phase; - mp_obj_t sck; - mp_obj_t mosi; - mp_obj_t miso; -} mp_machine_soft_spi_obj_t; - -extern const mp_obj_type_t mp_machine_soft_spi_type; -extern const mp_obj_dict_t mp_machine_spi_locals_dict; - -void mp_machine_soft_spi_transfer(mp_obj_base_t *self, size_t len, const uint8_t *src, uint8_t *dest); - -mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_machine_spi_read_obj; -extern const mp_obj_fun_builtin_var_t mp_machine_spi_readinto_obj; -extern const mp_obj_fun_builtin_fixed_t mp_machine_spi_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_machine_spi_write_readinto_obj; -# 32 "user/mpy/py/../extmod/machine_spi.c" 2 -# 1 "user/mpy/py/../extmod/modussl_axtls.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modussl_axtls.c" -# 27 "user/mpy/py/../extmod/modussl_axtls.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modussl_axtls.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/modussl_axtls.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/../extmod/modussl_axtls.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/../extmod/modussl_axtls.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 33 "user/mpy/py/../extmod/modussl_axtls.c" 2 -# 1 "user/mpy/py/../extmod/modussl_mbedtls.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modussl_mbedtls.c" -# 27 "user/mpy/py/../extmod/modussl_mbedtls.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../extmod/modussl_mbedtls.c" 2 -# 1 "user/mpy/py/../extmod/modurandom.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modurandom.c" -# 27 "user/mpy/py/../extmod/modurandom.c" -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 9 "/usr/arm-none-eabi/include/assert.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 10 "/usr/arm-none-eabi/include/assert.h" 2 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 - -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 28 "user/mpy/py/../extmod/modurandom.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 11 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/modurandom.c" 2 - - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/../extmod/modurandom.c" 2 -# 1 "user/mpy/py/../extmod/moduselect.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/moduselect.c" -# 27 "user/mpy/py/../extmod/moduselect.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../extmod/moduselect.c" 2 -# 1 "user/mpy/py/../extmod/modwebsocket.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modwebsocket.c" -# 27 "user/mpy/py/../extmod/modwebsocket.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 29 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/../extmod/modwebsocket.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 33 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 35 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "user/mpy/extmod/modwebsocket.h" 1 - - - - -enum { - FRAME_CONT, FRAME_TXT, FRAME_BIN, - FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG -}; -# 36 "user/mpy/py/../extmod/modwebsocket.c" 2 -# 1 "user/mpy/py/../extmod/modwebrepl.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modwebrepl.c" -# 27 "user/mpy/py/../extmod/modwebrepl.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 29 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 30 "user/mpy/py/../extmod/modwebrepl.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 32 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 33 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 34 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 35 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "user/mpy/py/builtin.h" 1 -# 31 "user/mpy/py/builtin.h" -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -extern const mp_obj_fun_builtin_var_t mp_builtin___build_class___obj; -extern const mp_obj_fun_builtin_var_t mp_builtin___import___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin___repl_print___obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_abs_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_all_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_any_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_bin_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_callable_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_compile_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_chr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_delattr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_dir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_divmod_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_eval_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_exec_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_execfile_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_getattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_setattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_globals_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hasattr_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hash_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_help_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_hex_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_id_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_isinstance_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_issubclass_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_iter_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_len_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_locals_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_max_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_min_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_next_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_oct_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_ord_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_pow_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_print_obj; -extern const mp_obj_fun_builtin_fixed_t mp_builtin_repr_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_round_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sorted_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_sum_obj; - -extern const mp_obj_fun_builtin_var_t mp_builtin_input_obj; -extern const mp_obj_fun_builtin_var_t mp_builtin_open_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_namedtuple_obj; - -extern const mp_obj_fun_builtin_fixed_t mp_op_contains_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_getitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_setitem_obj; -extern const mp_obj_fun_builtin_fixed_t mp_op_delitem_obj; - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - - -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *mp_help_default_text; -# 36 "user/mpy/py/../extmod/modwebrepl.c" 2 - - - -# 1 "user/mpy/extmod/modwebsocket.h" 1 - - - - -enum { - FRAME_CONT, FRAME_TXT, FRAME_BIN, - FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG -}; -# 40 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "user/mpy/build/genhdr/mpversion.h" 1 -# 41 "user/mpy/py/../extmod/modwebrepl.c" 2 -# 1 "user/mpy/py/../extmod/modframebuf.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/modframebuf.c" -# 27 "user/mpy/py/../extmod/modframebuf.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/modframebuf.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/modframebuf.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/../extmod/modframebuf.c" 2 -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 32 "user/mpy/py/../extmod/modframebuf.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 33 "user/mpy/py/../extmod/modframebuf.c" 2 -# 1 "user/mpy/py/../extmod/vfs.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/vfs.c" -# 27 "user/mpy/py/../extmod/vfs.c" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 28 "user/mpy/py/../extmod/vfs.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/vfs.c" 2 - -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" - -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 31 "user/mpy/py/../extmod/vfs.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 31 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/../extmod/vfs.c" 2 -# 1 "user/mpy/py/objstr.h" 1 -# 31 "user/mpy/py/objstr.h" -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - - size_t len; - const byte *data; -} mp_obj_str_t; -# 64 "user/mpy/py/objstr.h" -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, -# 74 "user/mpy/py/objstr.h" 3 4 - _Bool -# 74 "user/mpy/py/objstr.h" - is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -extern const mp_obj_fun_builtin_var_t str_encode_obj; -extern const mp_obj_fun_builtin_var_t str_find_obj; -extern const mp_obj_fun_builtin_var_t str_rfind_obj; -extern const mp_obj_fun_builtin_var_t str_index_obj; -extern const mp_obj_fun_builtin_var_t str_rindex_obj; -extern const mp_obj_fun_builtin_fixed_t str_join_obj; -extern const mp_obj_fun_builtin_var_t str_split_obj; -extern const mp_obj_fun_builtin_var_t str_splitlines_obj; -extern const mp_obj_fun_builtin_var_t str_rsplit_obj; -extern const mp_obj_fun_builtin_var_t str_startswith_obj; -extern const mp_obj_fun_builtin_var_t str_endswith_obj; -extern const mp_obj_fun_builtin_var_t str_strip_obj; -extern const mp_obj_fun_builtin_var_t str_lstrip_obj; -extern const mp_obj_fun_builtin_var_t str_rstrip_obj; -extern const mp_obj_fun_builtin_var_t str_format_obj; -extern const mp_obj_fun_builtin_var_t str_replace_obj; -extern const mp_obj_fun_builtin_var_t str_count_obj; -extern const mp_obj_fun_builtin_fixed_t str_partition_obj; -extern const mp_obj_fun_builtin_fixed_t str_rpartition_obj; -extern const mp_obj_fun_builtin_fixed_t str_center_obj; -extern const mp_obj_fun_builtin_fixed_t str_lower_obj; -extern const mp_obj_fun_builtin_fixed_t str_upper_obj; -extern const mp_obj_fun_builtin_fixed_t str_isspace_obj; -extern const mp_obj_fun_builtin_fixed_t str_isalpha_obj; -extern const mp_obj_fun_builtin_fixed_t str_isdigit_obj; -extern const mp_obj_fun_builtin_fixed_t str_isupper_obj; -extern const mp_obj_fun_builtin_fixed_t str_islower_obj; -# 33 "user/mpy/py/../extmod/vfs.c" 2 -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 34 "user/mpy/py/../extmod/vfs.c" 2 -# 1 "user/mpy/extmod/vfs.h" 1 -# 29 "user/mpy/extmod/vfs.h" -# 1 "user/mpy/py/lexer.h" 1 -# 33 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" - -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/extmod/vfs.h" 2 -# 48 "user/mpy/extmod/vfs.h" -typedef struct _mp_vfs_mount_t { - const char *str; - size_t len; - mp_obj_t obj; - struct _mp_vfs_mount_t *next; -} mp_vfs_mount_t; - -mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); -mp_import_stat_t mp_vfs_import_stat(const char *path); -mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -mp_obj_t mp_vfs_umount(mp_obj_t mnt_in); -mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -mp_obj_t mp_vfs_chdir(mp_obj_t path_in); -mp_obj_t mp_vfs_getcwd(void); -mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_vfs_mkdir(mp_obj_t path_in); -mp_obj_t mp_vfs_remove(mp_obj_t path_in); -mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in); -mp_obj_t mp_vfs_rmdir(mp_obj_t path_in); -mp_obj_t mp_vfs_stat(mp_obj_t path_in); -mp_obj_t mp_vfs_statvfs(mp_obj_t path_in); - -extern const mp_obj_fun_builtin_var_t mp_vfs_mount_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_umount_obj; -extern const mp_obj_fun_builtin_var_t mp_vfs_open_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_chdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_getcwd_obj; -extern const mp_obj_fun_builtin_var_t mp_vfs_ilistdir_obj; -extern const mp_obj_fun_builtin_var_t mp_vfs_listdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_mkdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_remove_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_rename_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_rmdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_stat_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_statvfs_obj; -# 35 "user/mpy/py/../extmod/vfs.c" 2 -# 1 "user/mpy/py/../extmod/vfs_reader.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/vfs_reader.c" -# 27 "user/mpy/py/../extmod/vfs_reader.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 28 "user/mpy/py/../extmod/vfs_reader.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 29 "user/mpy/py/../extmod/vfs_reader.c" 2 - -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 31 "user/mpy/py/../extmod/vfs_reader.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 32 "user/mpy/py/../extmod/vfs_reader.c" 2 -# 1 "user/mpy/py/reader.h" 1 -# 36 "user/mpy/py/reader.h" -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 33 "user/mpy/py/../extmod/vfs_reader.c" 2 -# 1 "user/mpy/extmod/vfs.h" 1 -# 29 "user/mpy/extmod/vfs.h" -# 1 "user/mpy/py/lexer.h" 1 -# 41 "user/mpy/py/lexer.h" -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/extmod/vfs.h" 2 -# 48 "user/mpy/extmod/vfs.h" -typedef struct _mp_vfs_mount_t { - const char *str; - size_t len; - mp_obj_t obj; - struct _mp_vfs_mount_t *next; -} mp_vfs_mount_t; - -mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); -mp_import_stat_t mp_vfs_import_stat(const char *path); -mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -mp_obj_t mp_vfs_umount(mp_obj_t mnt_in); -mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -mp_obj_t mp_vfs_chdir(mp_obj_t path_in); -mp_obj_t mp_vfs_getcwd(void); -mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_vfs_mkdir(mp_obj_t path_in); -mp_obj_t mp_vfs_remove(mp_obj_t path_in); -mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in); -mp_obj_t mp_vfs_rmdir(mp_obj_t path_in); -mp_obj_t mp_vfs_stat(mp_obj_t path_in); -mp_obj_t mp_vfs_statvfs(mp_obj_t path_in); - -extern const mp_obj_fun_builtin_var_t mp_vfs_mount_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_umount_obj; -extern const mp_obj_fun_builtin_var_t mp_vfs_open_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_chdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_getcwd_obj; -extern const mp_obj_fun_builtin_var_t mp_vfs_ilistdir_obj; -extern const mp_obj_fun_builtin_var_t mp_vfs_listdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_mkdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_remove_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_rename_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_rmdir_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_stat_obj; -extern const mp_obj_fun_builtin_fixed_t mp_vfs_statvfs_obj; -# 34 "user/mpy/py/../extmod/vfs_reader.c" 2 -# 1 "user/mpy/py/../extmod/vfs_fat.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/vfs_fat.c" -# 28 "user/mpy/py/../extmod/vfs_fat.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 29 "user/mpy/py/../extmod/vfs_fat.c" 2 -# 1 "user/mpy/py/../extmod/vfs_fat_diskio.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/vfs_fat_diskio.c" -# 30 "user/mpy/py/../extmod/vfs_fat_diskio.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 31 "user/mpy/py/../extmod/vfs_fat_diskio.c" 2 -# 1 "user/mpy/py/../extmod/vfs_fat_file.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/vfs_fat_file.c" -# 27 "user/mpy/py/../extmod/vfs_fat_file.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../extmod/vfs_fat_file.c" 2 -# 1 "user/mpy/py/../extmod/vfs_fat_misc.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/vfs_fat_misc.c" -# 27 "user/mpy/py/../extmod/vfs_fat_misc.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../extmod/vfs_fat_misc.c" 2 -# 1 "user/mpy/py/../extmod/utime_mphal.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/utime_mphal.c" -# 28 "user/mpy/py/../extmod/utime_mphal.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 29 "user/mpy/py/../extmod/utime_mphal.c" 2 -# 1 "user/mpy/py/../extmod/uos_dupterm.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../extmod/uos_dupterm.c" -# 27 "user/mpy/py/../extmod/uos_dupterm.c" -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 10 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 - - - - - - -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 8 "/usr/arm-none-eabi/include/machine/_types.h" 2 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/string.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 28 "user/mpy/py/../extmod/uos_dupterm.c" 2 -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 29 "user/mpy/py/../extmod/uos_dupterm.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 31 "user/mpy/py/../extmod/uos_dupterm.c" 2 -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 32 "user/mpy/py/../extmod/uos_dupterm.c" 2 - -# 1 "user/mpy/py/objarray.h" 1 -# 32 "user/mpy/py/objarray.h" -typedef struct _mp_obj_array_t { - mp_obj_base_t base; - size_t typecode : 8; - - - size_t free : (8 * sizeof(size_t) - 8); - size_t len; - void *items; -} mp_obj_array_t; -# 34 "user/mpy/py/../extmod/uos_dupterm.c" 2 -# 1 "user/mpy/py/stream.h" 1 -# 30 "user/mpy/py/stream.h" -# 1 "user/mpy/py/mperrno.h" 1 -# 89 "user/mpy/py/mperrno.h" -# 1 "/usr/arm-none-eabi/include/errno.h" 1 3 - - - - - -# 5 "/usr/arm-none-eabi/include/errno.h" 3 -typedef int error_t; - - - -# 1 "/usr/arm-none-eabi/include/sys/errno.h" 1 3 -# 15 "/usr/arm-none-eabi/include/sys/errno.h" 3 -extern int *__errno (void); - - - - -extern const char * const _sys_errlist[]; -extern int _sys_nerr; -# 10 "/usr/arm-none-eabi/include/errno.h" 2 3 -# 90 "user/mpy/py/mperrno.h" 2 -# 31 "user/mpy/py/stream.h" 2 -# 52 "user/mpy/py/stream.h" - -# 52 "user/mpy/py/stream.h" -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -extern const mp_obj_fun_builtin_var_t mp_stream_read_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_read1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_readinto_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_unbuffered_readline_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_unbuffered_readlines_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_write_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_write1_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_seek_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_tell_obj; -extern const mp_obj_fun_builtin_fixed_t mp_stream_flush_obj; -extern const mp_obj_fun_builtin_var_t mp_stream_ioctl_obj; - - - - - - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - - - - - -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); - - - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); -# 35 "user/mpy/py/../extmod/uos_dupterm.c" 2 -# 1 "user/mpy/py/../lib/embed/abort_.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../lib/embed/abort_.c" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 29 "user/mpy/py/mpstate.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 30 "user/mpy/py/mpstate.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 32 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 34 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 4 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 4 -# 6 "/usr/arm-none-eabi/include/limits.h" 2 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - - - - -# 38 "user/mpy/py/nlr.h" -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 35 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/obj.h" 1 -# 31 "user/mpy/py/obj.h" -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 2 "user/mpy/py/../lib/embed/abort_.c" 2 - -__attribute__((noreturn)) void abort_(void); - -__attribute__((noreturn)) void abort_(void) { - nlr_jump(((void*)mp_obj_new_exception_msg(&mp_type_RuntimeError, "abort() called"))); -} -# 1 "user/mpy/py/../lib/utils/printf.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/../lib/utils/printf.c" -# 27 "user/mpy/py/../lib/utils/printf.c" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "user/mpy/py/../lib/utils/printf.c" 2 - - - - -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 12 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 13 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 33 "user/mpy/py/../lib/utils/printf.c" 2 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 99 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __gnuc_va_list va_list; -# 34 "user/mpy/py/../lib/utils/printf.c" 2 - -# 1 "user/mpy/py/obj.h" 1 -# 30 "user/mpy/py/obj.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - - -# 37 "user/mpy/py/misc.h" -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 191 "user/mpy/py/misc.h" -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); - - - -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/qstr.h" 1 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 32 "user/mpy/py/obj.h" 2 -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 36 "user/mpy/py/../lib/utils/printf.c" 2 -# 1 "user/mpy/py/mphal.h" 1 -# 34 "user/mpy/py/mphal.h" -# 1 "user/mpy/mphalport.h" 1 -# 35 "user/mpy/py/mphal.h" 2 - - - -int mp_hal_stdin_rx_chr(void); - - - - - - - -void mp_hal_stdout_tx_strn(const char *str, size_t len); - - - - - - - -void mp_hal_delay_ms(mp_uint_t ms); - - - -void mp_hal_delay_us(mp_uint_t us); - - - - - - - -mp_uint_t mp_hal_ticks_us(void); - - - -mp_uint_t mp_hal_ticks_cpu(void); -# 80 "user/mpy/py/mphal.h" -# 1 "user/mpy/extmod/virtpin.h" 1 -# 37 "user/mpy/extmod/virtpin.h" -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - - -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); -# 81 "user/mpy/py/mphal.h" 2 -# 37 "user/mpy/py/../lib/utils/printf.c" 2 - - - - - - -int printf(const char *fmt, ...); -int vprintf(const char *fmt, va_list ap); -int putchar(int c); -int puts(const char *s); -int vsnprintf(char *str, size_t size, const char *fmt, va_list ap); -int snprintf(char *str, size_t size, const char *fmt, ...); - -int printf(const char *fmt, ...) { - va_list ap; - -# 52 "user/mpy/py/../lib/utils/printf.c" 3 4 - __builtin_va_start( -# 52 "user/mpy/py/../lib/utils/printf.c" - ap -# 52 "user/mpy/py/../lib/utils/printf.c" 3 4 - , -# 52 "user/mpy/py/../lib/utils/printf.c" - fmt -# 52 "user/mpy/py/../lib/utils/printf.c" 3 4 - ) -# 52 "user/mpy/py/../lib/utils/printf.c" - ; - int ret = mp_vprintf(&mp_plat_print, fmt, ap); - -# 54 "user/mpy/py/../lib/utils/printf.c" 3 4 - __builtin_va_end( -# 54 "user/mpy/py/../lib/utils/printf.c" - ap -# 54 "user/mpy/py/../lib/utils/printf.c" 3 4 - ) -# 54 "user/mpy/py/../lib/utils/printf.c" - ; - return ret; -} - -int vprintf(const char *fmt, va_list ap) { - return mp_vprintf(&mp_plat_print, fmt, ap); -} -# 77 "user/mpy/py/../lib/utils/printf.c" -int putchar(int c) { - char chr = c; - printk(&chr);; - return chr; -} - - -int puts(const char *s) { - printk(s);; - char chr = '\n'; - printk(&chr);; - return 1; -} - -typedef struct _strn_print_env_t { - char *cur; - size_t remain; -} strn_print_env_t; - -static void strn_print_strn(void *data, const char *str, size_t len) { - strn_print_env_t *strn_print_env = data; - if (len > strn_print_env->remain) { - len = strn_print_env->remain; - } - memcpy(strn_print_env->cur, str, len); - strn_print_env->cur += len; - strn_print_env->remain -= len; -} - - - - -int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias ("vsnprintf"))); - - -int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { - strn_print_env_t strn_print_env = {str, size}; - mp_print_t print = {&strn_print_env, strn_print_strn}; - int len = mp_vprintf(&print, fmt, ap); - - if (size > 0) { - if (strn_print_env.remain == 0) { - strn_print_env.cur[-1] = 0; - } else { - strn_print_env.cur[0] = 0; - } - } - return len; -} - -int snprintf(char *str, size_t size, const char *fmt, ...) { - va_list ap; - -# 129 "user/mpy/py/../lib/utils/printf.c" 3 4 - __builtin_va_start( -# 129 "user/mpy/py/../lib/utils/printf.c" - ap -# 129 "user/mpy/py/../lib/utils/printf.c" 3 4 - , -# 129 "user/mpy/py/../lib/utils/printf.c" - fmt -# 129 "user/mpy/py/../lib/utils/printf.c" 3 4 - ) -# 129 "user/mpy/py/../lib/utils/printf.c" - ; - int ret = vsnprintf(str, size, fmt, ap); - -# 131 "user/mpy/py/../lib/utils/printf.c" 3 4 - __builtin_va_end( -# 131 "user/mpy/py/../lib/utils/printf.c" - ap -# 131 "user/mpy/py/../lib/utils/printf.c" 3 4 - ) -# 131 "user/mpy/py/../lib/utils/printf.c" - ; - return ret; -} -# 1 "user/mpy/py/emitnative.c" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "user/mpy/py/emitnative.c" -# 45 "user/mpy/py/emitnative.c" -# 1 "/usr/arm-none-eabi/include/stdio.h" 1 3 -# 29 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 14 "/usr/arm-none-eabi/include/newlib.h" 3 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 -# 15 "/usr/arm-none-eabi/include/newlib.h" 2 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 -# 6 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 30 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - - -# 1 "/usr/arm-none-eabi/include/sys/cdefs.h" 1 3 -# 43 "/usr/arm-none-eabi/include/sys/cdefs.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 44 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 46 "/usr/arm-none-eabi/include/sys/cdefs.h" 2 3 -# 36 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 37 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 1 3 4 -# 40 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdarg.h" 3 4 -typedef __builtin_va_list __gnuc_va_list; -# 41 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 60 "/usr/arm-none-eabi/include/stdio.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - -typedef __builtin_va_list __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 61 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/types.h" 1 3 -# 28 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __uint8_t u_int8_t; - - -typedef __uint16_t u_int16_t; - - -typedef __uint32_t u_int32_t; - - -typedef __uint64_t u_int64_t; - -typedef int register_t; -# 62 "/usr/arm-none-eabi/include/sys/types.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 63 "/usr/arm-none-eabi/include/sys/types.h" 2 3 - -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 65 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 113 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __blkcnt_t blkcnt_t; - - - - -typedef __blksize_t blksize_t; - - - - -typedef unsigned long clock_t; - - - - - -typedef long time_t; - - - - - -typedef long daddr_t; - - - -typedef char * caddr_t; - - - - -typedef __fsblkcnt_t fsblkcnt_t; -typedef __fsfilcnt_t fsfilcnt_t; - - - - -typedef __id_t id_t; - - - - -typedef __ino_t ino_t; -# 173 "/usr/arm-none-eabi/include/sys/types.h" 3 -typedef __off_t off_t; - - - -typedef __dev_t dev_t; - - - -typedef __uid_t uid_t; - - - -typedef __gid_t gid_t; - - - - -typedef __pid_t pid_t; - - - - -typedef __key_t key_t; - - - - -typedef _ssize_t ssize_t; - - - - -typedef __mode_t mode_t; - - - - -typedef __nlink_t nlink_t; - - - - -typedef __clockid_t clockid_t; - - - - - -typedef __timer_t timer_t; - - - - - -typedef __useconds_t useconds_t; - - - - -typedef __suseconds_t suseconds_t; - - - -typedef __int64_t sbintime_t; - - -# 1 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3 -# 23 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/sched.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/sched.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/_timespec.h" 1 3 -# 45 "/usr/arm-none-eabi/include/sys/_timespec.h" 3 -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -# 25 "/usr/arm-none-eabi/include/sys/sched.h" 2 3 -# 48 "/usr/arm-none-eabi/include/sys/sched.h" 3 -struct sched_param { - int sched_priority; -# 61 "/usr/arm-none-eabi/include/sys/sched.h" 3 -}; -# 24 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 2 3 -# 32 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_t; -# 61 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef struct { - int is_initialized; - void *stackaddr; - int stacksize; - int contentionscope; - int inheritsched; - int schedpolicy; - struct sched_param schedparam; - - - - - - int detachstate; -} pthread_attr_t; -# 154 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 -typedef __uint32_t pthread_mutex_t; - -typedef struct { - int is_initialized; -# 168 "/usr/arm-none-eabi/include/sys/_pthreadtypes.h" 3 - int recursive; -} pthread_mutexattr_t; - - - - - - -typedef __uint32_t pthread_cond_t; - - - -typedef struct { - int is_initialized; - clock_t clock; - - - -} pthread_condattr_t; - - - -typedef __uint32_t pthread_key_t; - -typedef struct { - int is_initialized; - int init_executed; -} pthread_once_t; -# 240 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/machine/types.h" 1 3 -# 241 "/usr/arm-none-eabi/include/sys/types.h" 2 3 -# 62 "/usr/arm-none-eabi/include/stdio.h" 2 3 - - - - -typedef __FILE FILE; - - - - - - -typedef _fpos_t fpos_t; - - - - - -# 1 "/usr/arm-none-eabi/include/sys/stdio.h" 1 3 -# 80 "/usr/arm-none-eabi/include/stdio.h" 2 3 -# 186 "/usr/arm-none-eabi/include/stdio.h" 3 -FILE * tmpfile (void); -char * tmpnam (char *); - - - -int fclose (FILE *); -int fflush (FILE *); -FILE * freopen (const char *restrict, const char *restrict, FILE *restrict); -void setbuf (FILE *restrict, char *restrict); -int setvbuf (FILE *restrict, char *restrict, int, size_t); -int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2))) - ; -int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2))) - ; -int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0))) - ; -int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int fgetc (FILE *); -char * fgets (char *restrict, int, FILE *restrict); -int fputc (int, FILE *); -int fputs (const char *restrict, FILE *restrict); -int getc (FILE *); -int getchar (void); -char * gets (char *); -int putc (int, FILE *); -int putchar (int); -int puts (const char *); -int ungetc (int, FILE *); -size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *); - - - -int fgetpos (FILE *restrict, fpos_t *restrict); - -int fseek (FILE *, long, int); - - - -int fsetpos (FILE *, const fpos_t *); - -long ftell ( FILE *); -void rewind (FILE *); -void clearerr (FILE *); -int feof (FILE *); -int ferror (FILE *); -void perror (const char *); - -FILE * fopen (const char *restrict _name, const char *restrict _type); -int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int remove (const char *); -int rename (const char *, const char *); -# 266 "/usr/arm-none-eabi/include/stdio.h" 3 -int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0))) - ; -int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -# 393 "/usr/arm-none-eabi/include/stdio.h" 3 -int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fclose_r (struct _reent *, FILE *); -int _fcloseall_r (struct _reent *); -FILE * _fdopen_r (struct _reent *, int, const char *); -int _fflush_r (struct _reent *, FILE *); -int _fgetc_r (struct _reent *, FILE *); -int _fgetc_unlocked_r (struct _reent *, FILE *); -char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict); -char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict); - - - - -int _fgetpos_r (struct _reent *, FILE *, fpos_t *); -int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); - -int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict); -FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict); -FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict); -int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _fpurge_r (struct _reent *, FILE *); -int _fputc_r (struct _reent *, int, FILE *); -int _fputc_unlocked_r (struct _reent *, int, FILE *); -int _fputs_r (struct _reent *, const char *restrict, FILE *restrict); -int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict); -size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict); -int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _fseek_r (struct _reent *, FILE *, long, int); -int _fseeko_r (struct _reent *, FILE *, _off_t, int); -long _ftell_r (struct _reent *, FILE *); -_off_t _ftello_r (struct _reent *, FILE *); -void _rewind_r (struct _reent *, FILE *); -size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict); -int _getc_r (struct _reent *, FILE *); -int _getc_unlocked_r (struct _reent *, FILE *); -int _getchar_r (struct _reent *); -int _getchar_unlocked_r (struct _reent *); -char * _gets_r (struct _reent *, char *); -int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -FILE * _open_memstream_r (struct _reent *, char **, size_t *); -void _perror_r (struct _reent *, const char *); -int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3))) - ; -int _putc_r (struct _reent *, int, FILE *); -int _putc_unlocked_r (struct _reent *, int, FILE *); -int _putchar_unlocked_r (struct _reent *, int); -int _putchar_r (struct _reent *, int); -int _puts_r (struct _reent *, const char *); -int _remove_r (struct _reent *, const char *); -int _rename_r (struct _reent *, const char *_old, const char *_new) - ; -int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3))) - ; -int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5))) - ; -int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4))) - ; -int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4))) - ; -char * _tempnam_r (struct _reent *, const char *, const char *); -FILE * _tmpfile_r (struct _reent *); -char * _tmpnam_r (struct _reent *, char *); -int _ungetc_r (struct _reent *, int, FILE *); -int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0))) - ; -int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0))) - ; -int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; -int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0))) - ; -int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0))) - ; -int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0))) - ; - - - -int fpurge (FILE *); -ssize_t __getdelim (char **, size_t *, int, FILE *); -ssize_t __getline (char **, size_t *, FILE *); -# 574 "/usr/arm-none-eabi/include/stdio.h" 3 -int __srget_r (struct _reent *, FILE *); -int __swbuf_r (struct _reent *, int, FILE *); -# 684 "/usr/arm-none-eabi/include/stdio.h" 3 -static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { - - - - - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf_r(_ptr, _c, _p)); -} -# 767 "/usr/arm-none-eabi/include/stdio.h" 3 - -# 46 "user/mpy/py/emitnative.c" 2 -# 1 "/usr/arm-none-eabi/include/string.h" 1 3 -# 17 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 18 "/usr/arm-none-eabi/include/string.h" 2 3 - - - - - - - -void * memchr (const void *, int, size_t); -int memcmp (const void *, const void *, size_t); -void * memcpy (void * restrict, const void * restrict, size_t); -void * memmove (void *, const void *, size_t); -void * memset (void *, int, size_t); -char *strcat (char *restrict, const char *restrict); -char *strchr (const char *, int); -int strcmp (const char *, const char *); -int strcoll (const char *, const char *); -char *strcpy (char *restrict, const char *restrict); -size_t strcspn (const char *, const char *); -char *strerror (int); -size_t strlen (const char *); -char *strncat (char *restrict, const char *restrict, size_t); -int strncmp (const char *, const char *, size_t); -char *strncpy (char *restrict, const char *restrict, size_t); -char *strpbrk (const char *, const char *); -char *strrchr (const char *, int); -size_t strspn (const char *, const char *); -char *strstr (const char *, const char *); - -char *strtok (char *restrict, const char *restrict); - -size_t strxfrm (char *restrict, const char *restrict, size_t); -# 102 "/usr/arm-none-eabi/include/string.h" 3 -char *_strdup_r (struct _reent *, const char *); - - - -char *_strndup_r (struct _reent *, const char *, size_t); -# 133 "/usr/arm-none-eabi/include/string.h" 3 -char * _strerror_r (struct _reent *, int, int, int *); -# 155 "/usr/arm-none-eabi/include/string.h" 3 -char *strsignal (int __signo); -# 192 "/usr/arm-none-eabi/include/string.h" 3 -# 1 "/usr/arm-none-eabi/include/sys/string.h" 1 3 -# 193 "/usr/arm-none-eabi/include/string.h" 2 3 - - -# 47 "user/mpy/py/emitnative.c" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 48 "user/mpy/py/emitnative.c" 2 - -# 1 "user/mpy/py/nlr.h" 1 -# 32 "user/mpy/py/nlr.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 34 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 1 3 4 - - - - - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 1 3 4 -# 194 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 3 4 -# 1 "/usr/arm-none-eabi/include/limits.h" 1 3 4 -# 195 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 8 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/syslimits.h" 2 3 4 -# 35 "/usr/lib/gcc/arm-none-eabi/7.1.0/include-fixed/limits.h" 2 3 4 -# 33 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/setjmp.h" 1 3 -# 10 "/usr/arm-none-eabi/include/setjmp.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/setjmp.h" 1 3 - - -# 365 "/usr/arm-none-eabi/include/machine/setjmp.h" 3 -typedef int jmp_buf[23]; - - - - -# 11 "/usr/arm-none-eabi/include/setjmp.h" 2 3 - - - - -void longjmp (jmp_buf __jmpb, int __retval) - __attribute__ ((__noreturn__)); - - - -int setjmp (jmp_buf __jmpb); - - -# 34 "user/mpy/py/nlr.h" 2 -# 1 "/usr/arm-none-eabi/include/assert.h" 1 3 -# 39 "/usr/arm-none-eabi/include/assert.h" 3 -void __assert (const char *, int, const char *) __attribute__ ((__noreturn__)) - ; -void __assert_func (const char *, int, const char *, const char *) __attribute__ ((__noreturn__)) - ; -# 35 "user/mpy/py/nlr.h" 2 - -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 13 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 37 "user/mpy/py/nlr.h" 2 - -typedef struct _nlr_buf_t nlr_buf_t; -struct _nlr_buf_t { - - nlr_buf_t *prev; - void *ret_val; -# 53 "user/mpy/py/nlr.h" - void *regs[10]; -# 65 "user/mpy/py/nlr.h" -}; -# 77 "user/mpy/py/nlr.h" -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -__attribute__((noreturn)) void nlr_jump(void *val); - - - - - -__attribute__((noreturn)) void nlr_jump_fail(void *val); -# 50 "user/mpy/py/emitnative.c" 2 -# 1 "user/mpy/py/emit.h" 1 -# 29 "user/mpy/py/emit.h" -# 1 "user/mpy/py/lexer.h" 1 -# 32 "user/mpy/py/lexer.h" -# 1 "user/mpy/py/qstr.h" 1 -# 30 "user/mpy/py/qstr.h" -# 1 "user/mpy/py/misc.h" 1 -# 33 "user/mpy/py/misc.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdbool.h" 1 3 4 -# 34 "user/mpy/py/misc.h" 2 - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 36 "user/mpy/py/misc.h" 2 - -typedef unsigned char byte; -typedef unsigned int uint; -# 82 "user/mpy/py/misc.h" -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); - - - - - -void *m_realloc(void *ptr, size_t new_num_bytes); -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, -# 92 "user/mpy/py/misc.h" 3 4 - _Bool -# 92 "user/mpy/py/misc.h" - allow_move); -void m_free(void *ptr); - -__attribute__((noreturn)) void *m_malloc_fail(size_t num_bytes); -# 119 "user/mpy/py/misc.h" -typedef uint unichar; - - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - - -# 125 "user/mpy/py/misc.h" 3 4 -_Bool -# 125 "user/mpy/py/misc.h" - unichar_isspace(unichar c); - -# 126 "user/mpy/py/misc.h" 3 4 -_Bool -# 126 "user/mpy/py/misc.h" - unichar_isalpha(unichar c); - -# 127 "user/mpy/py/misc.h" 3 4 -_Bool -# 127 "user/mpy/py/misc.h" - unichar_isprint(unichar c); - -# 128 "user/mpy/py/misc.h" 3 4 -_Bool -# 128 "user/mpy/py/misc.h" - unichar_isdigit(unichar c); - -# 129 "user/mpy/py/misc.h" 3 4 -_Bool -# 129 "user/mpy/py/misc.h" - unichar_isxdigit(unichar c); - -# 130 "user/mpy/py/misc.h" 3 4 -_Bool -# 130 "user/mpy/py/misc.h" - unichar_isident(unichar c); - -# 131 "user/mpy/py/misc.h" 3 4 -_Bool -# 131 "user/mpy/py/misc.h" - unichar_isupper(unichar c); - -# 132 "user/mpy/py/misc.h" 3 4 -_Bool -# 132 "user/mpy/py/misc.h" - unichar_islower(unichar c); -unichar unichar_tolower(unichar c); -unichar unichar_toupper(unichar c); -mp_uint_t unichar_xdigit_value(unichar c); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); - - - - - -typedef struct _vstr_t { - size_t alloc; - size_t len; - char *buf; - -# 146 "user/mpy/py/misc.h" 3 4 - _Bool -# 146 "user/mpy/py/misc.h" - fixed_buf : 1; -} vstr_t; - - - - -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, ...); -# 195 "user/mpy/py/misc.h" -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - - - - - - -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -# 31 "user/mpy/py/qstr.h" 2 -# 39 "user/mpy/py/qstr.h" -enum { - - - - - - MP_QSTRnumber_of, -}; - -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; - - - -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); - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); -# 33 "user/mpy/py/lexer.h" 2 -# 1 "user/mpy/py/reader.h" 1 -# 29 "user/mpy/py/reader.h" -# 1 "user/mpy/py/obj.h" 1 -# 32 "user/mpy/py/obj.h" -# 1 "user/mpy/py/mpprint.h" 1 -# 48 "user/mpy/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; - - - -extern const mp_print_t mp_plat_print; - - - - - -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); - - - - -int mp_printf(const mp_print_t *print, const char *fmt, ...); -# 33 "user/mpy/py/obj.h" 2 -# 41 "user/mpy/py/obj.h" -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; - - - - -typedef struct _mp_obj_type_t mp_obj_type_t; - - - -struct _mp_obj_base_t { - const mp_obj_type_t *type ; -}; -typedef struct _mp_obj_base_t mp_obj_base_t; -# 83 "user/mpy/py/obj.h" -static inline -# 83 "user/mpy/py/obj.h" 3 4 - _Bool -# 83 "user/mpy/py/obj.h" - MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) != 0); } - - - -static inline -# 88 "user/mpy/py/obj.h" 3 4 - _Bool -# 88 "user/mpy/py/obj.h" - MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 2); } -# 104 "user/mpy/py/obj.h" -static inline -# 104 "user/mpy/py/obj.h" 3 4 - _Bool -# 104 "user/mpy/py/obj.h" - MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } -# 238 "user/mpy/py/obj.h" -typedef mp_const_obj_t mp_rom_obj_t; -# 264 "user/mpy/py/obj.h" -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline -# 266 "user/mpy/py/obj.h" 3 4 - _Bool -# 266 "user/mpy/py/obj.h" - mp_obj_is_integer(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_int)))) || (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)((void*)o))->type == (&mp_type_bool))); } -# 340 "user/mpy/py/obj.h" -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; - size_t is_ordered : 1; - size_t used : (8 * sizeof(size_t) - 3); - size_t alloc; - mp_map_elem_t *table; -} mp_map_t; - - -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, -} mp_map_lookup_kind_t; - -extern const mp_map_t mp_const_empty_map; - -static inline -# 374 "user/mpy/py/obj.h" 3 4 - _Bool -# 374 "user/mpy/py/obj.h" - MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != (((mp_obj_t)(void*)0)) && (map)->table[pos].key != (((mp_obj_t)(void*)8))); } - -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); - - - -typedef struct _mp_set_t { - size_t alloc; - size_t used; - mp_obj_t *table; -} mp_set_t; - -static inline -# 393 "user/mpy/py/obj.h" 3 4 - _Bool -# 393 "user/mpy/py/obj.h" - MP_SET_SLOT_IS_FILLED(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != (((mp_obj_t)(void*)0)) && (set)->table[pos] != (((mp_obj_t)(void*)8))); } - -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); - - - -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 *); - - -typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); - -typedef enum { - PRINT_STR = 0, - PRINT_REPR = 1, - PRINT_EXC = 2, - PRINT_JSON = 3, - PRINT_RAW = 4, - PRINT_EXC_SUBCLASS = 0x80, -} 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; - - - - - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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); - - -typedef struct _mp_buffer_info_t { - - - - - - void *buf; - size_t len; - int typecode; - - - - -} mp_buffer_info_t; - - - -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; - -# 459 "user/mpy/py/obj.h" 3 4 -_Bool -# 459 "user/mpy/py/obj.h" - 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); - - -typedef struct _mp_stream_p_t { - - - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; -} mp_stream_p_t; - -struct _mp_obj_type_t { - - mp_obj_base_t base; - - - qstr name; - - - mp_print_fun_t print; - - - mp_make_new_fun_t make_new; - - - mp_call_fun_t call; - - - - mp_unary_op_fun_t unary_op; - mp_binary_op_fun_t binary_op; -# 504 "user/mpy/py/obj.h" - mp_attr_fun_t attr; - - - - - - - mp_subscr_fun_t subscr; - - - - - mp_getiter_fun_t getiter; - - - - mp_fun_1_t iternext; - - - mp_buffer_p_t buffer_p; - - - const void *protocol; - - - - - - const void *parent; - - - struct _mp_obj_dict_t *locals_dict; -}; - - -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; -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_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_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; - - -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_TimeoutError; -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; -# 618 "user/mpy/py/obj.h" -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - - - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? (((mp_obj_t)&mp_const_true_obj)) : (((mp_obj_t)&mp_const_false_obj)); } -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, -# 636 "user/mpy/py/obj.h" 3 4 - _Bool -# 636 "user/mpy/py/obj.h" - neg, unsigned int base); -mp_obj_t mp_obj_new_int_from_ll(long long val); -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); -mp_obj_t mp_obj_new_str(const char* data, size_t len, -# 639 "user/mpy/py/obj.h" 3 4 - _Bool -# 639 "user/mpy/py/obj.h" - make_qstr_if_not_already); -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); - - - - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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); - -# 671 "user/mpy/py/obj.h" 3 4 -_Bool -# 671 "user/mpy/py/obj.h" - mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); -mp_obj_t mp_instance_cast_to_native_base(mp_const_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); - - -# 678 "user/mpy/py/obj.h" 3 4 -_Bool -# 678 "user/mpy/py/obj.h" - mp_obj_is_true(mp_obj_t arg); - -# 679 "user/mpy/py/obj.h" 3 4 -_Bool -# 679 "user/mpy/py/obj.h" - mp_obj_is_callable(mp_obj_t o_in); - -# 680 "user/mpy/py/obj.h" 3 4 -_Bool -# 680 "user/mpy/py/obj.h" - mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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); - -# 684 "user/mpy/py/obj.h" 3 4 -_Bool -# 684 "user/mpy/py/obj.h" - mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); - - - - - -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, -# 692 "user/mpy/py/obj.h" 3 4 - _Bool -# 692 "user/mpy/py/obj.h" - 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); -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_uint_t op, mp_obj_t o_in); - - -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); - - - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in); - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in); - - - - -# 711 "user/mpy/py/obj.h" 3 4 -_Bool -# 711 "user/mpy/py/obj.h" - mp_obj_is_exception_type(mp_obj_t self_in); - -# 712 "user/mpy/py/obj.h" 3 4 -_Bool -# 712 "user/mpy/py/obj.h" - mp_obj_is_exception_instance(mp_obj_t self_in); - -# 713 "user/mpy/py/obj.h" 3 4 -_Bool -# 713 "user/mpy/py/obj.h" - 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); - - - -# 723 "user/mpy/py/obj.h" 3 4 -_Bool -# 723 "user/mpy/py/obj.h" - mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); -qstr mp_obj_str_get_qstr(mp_obj_t self_in); -const char *mp_obj_str_get_str(mp_obj_t self_in); -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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, -# 728 "user/mpy/py/obj.h" 3 4 - _Bool -# 728 "user/mpy/py/obj.h" - is_bytes); -# 747 "user/mpy/py/obj.h" -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); - - -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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); - - -typedef struct _mp_obj_dict_t { - mp_obj_base_t base; - mp_map_t map; -} mp_obj_dict_t; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - - - -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; - -# 794 "user/mpy/py/obj.h" 3 4 - _Bool -# 794 "user/mpy/py/obj.h" - is_kw : 1; - mp_uint_t n_args_min : 15; - mp_uint_t n_args_max : 16; - 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); -extern const mp_obj_fun_builtin_fixed_t mp_identity_obj; -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); - - -typedef struct _mp_obj_module_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; -} mp_obj_module_t; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); - - -# 817 "user/mpy/py/obj.h" 3 4 -_Bool -# 817 "user/mpy/py/obj.h" - mp_obj_is_package(mp_obj_t module); - - - -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; - - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in); - - - - -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); - - - - - - -# 848 "user/mpy/py/obj.h" 3 4 -_Bool -# 848 "user/mpy/py/obj.h" - mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2); - -# 849 "user/mpy/py/obj.h" 3 4 -_Bool -# 849 "user/mpy/py/obj.h" - 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); -# 30 "user/mpy/py/reader.h" 2 - - - - - - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, -# 44 "user/mpy/py/reader.h" 3 4 - _Bool -# 44 "user/mpy/py/reader.h" - close_fd); -# 34 "user/mpy/py/lexer.h" 2 - - - - - - - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - - - - - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - - - -typedef struct _mp_lexer_t { - qstr source_name; - mp_reader_t reader; - - unichar chr0, chr1, chr2; - - size_t line; - size_t column; - - mp_int_t emit_dent; - mp_int_t nested_bracket_level; - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; - size_t tok_column; - mp_token_kind_t tok_kind; - vstr_t vstr; -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - - - - - - - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); -# 30 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/scope.h" 1 -# 29 "user/mpy/py/scope.h" -# 1 "user/mpy/py/parse.h" 1 -# 29 "user/mpy/py/parse.h" -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 30 "user/mpy/py/parse.h" 2 - - - - -struct _mp_lexer_t; -# 52 "user/mpy/py/parse.h" -typedef uintptr_t mp_parse_node_t; - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; - uint32_t kind_num_nodes; - mp_parse_node_t nodes[]; -} mp_parse_node_struct_t; -# 79 "user/mpy/py/parse.h" -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)((0x1) | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} - -# 85 "user/mpy/py/parse.h" 3 4 -_Bool -# 85 "user/mpy/py/parse.h" - mp_parse_node_is_const_false(mp_parse_node_t pn); - -# 86 "user/mpy/py/parse.h" 3 4 -_Bool -# 86 "user/mpy/py/parse.h" - mp_parse_node_is_const_true(mp_parse_node_t pn); - -# 87 "user/mpy/py/parse.h" 3 4 -_Bool -# 87 "user/mpy/py/parse.h" - mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - - - -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); -# 30 "user/mpy/py/scope.h" 2 -# 1 "user/mpy/py/emitglue.h" 1 -# 33 "user/mpy/py/emitglue.h" -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - - - - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); -# 31 "user/mpy/py/scope.h" 2 - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, - ID_INFO_KIND_CELL, - ID_INFO_KIND_FREE, -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - - - uint16_t local_num; - qstr qst; -} id_info_t; - - - - -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; - uint16_t simple_name; - mp_raw_code_t *raw_code; - uint8_t scope_flags; - uint8_t emit_options; - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; - uint16_t exc_stack_size; - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, -# 92 "user/mpy/py/scope.h" 3 4 - _Bool -# 92 "user/mpy/py/scope.h" - *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); -# 31 "user/mpy/py/emit.h" 2 -# 1 "user/mpy/py/runtime0.h" 1 -# 45 "user/mpy/py/runtime0.h" -typedef enum { - MP_UNARY_OP_BOOL, - MP_UNARY_OP_LEN, - MP_UNARY_OP_HASH, - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - - 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, - - MP_BINARY_OP_NOT_IN, - MP_BINARY_OP_IS_NOT, -} mp_binary_op_t; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, - - - - - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, - - - - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; -# 32 "user/mpy/py/emit.h" 2 -# 43 "user/mpy/py/emit.h" -typedef enum { - MP_PASS_SCOPE = 1, - MP_PASS_STACK_SIZE = 2, - MP_PASS_CODE_SIZE = 3, - MP_PASS_EMIT = 4, -} pass_kind_t; -# 59 "user/mpy/py/emit.h" -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - -# 72 "user/mpy/py/emit.h" 3 4 - _Bool -# 72 "user/mpy/py/emit.h" - (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, -# 90 "user/mpy/py/emit.h" 3 4 - _Bool -# 90 "user/mpy/py/emit.h" - is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, -# 103 "user/mpy/py/emit.h" 3 4 - _Bool -# 103 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, -# 104 "user/mpy/py/emit.h" 3 4 - _Bool -# 104 "user/mpy/py/emit.h" - cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, -# 112 "user/mpy/py/emit.h" 3 4 - _Bool -# 112 "user/mpy/py/emit.h" - use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - - - - - - - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - - - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); - -# 180 "user/mpy/py/emit.h" 3 4 -_Bool -# 180 "user/mpy/py/emit.h" - mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, -# 207 "user/mpy/py/emit.h" 3 4 - _Bool -# 207 "user/mpy/py/emit.h" - is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, -# 220 "user/mpy/py/emit.h" 3 4 - _Bool -# 220 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, -# 221 "user/mpy/py/emit.h" 3 4 - _Bool -# 221 "user/mpy/py/emit.h" - cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, -# 230 "user/mpy/py/emit.h" 3 4 - _Bool -# 230 "user/mpy/py/emit.h" - use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); - - - - - - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - -# 267 "user/mpy/py/emit.h" 3 4 - _Bool -# 267 "user/mpy/py/emit.h" - (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); -# 51 "user/mpy/py/emitnative.c" 2 -# 1 "user/mpy/py/bc.h" 1 -# 29 "user/mpy/py/bc.h" -# 1 "user/mpy/py/runtime.h" 1 -# 29 "user/mpy/py/runtime.h" -# 1 "user/mpy/py/mpstate.h" 1 -# 32 "user/mpy/py/mpstate.h" -# 1 "user/mpy/py/mpthread.h" 1 -# 33 "user/mpy/py/mpstate.h" 2 - - - -# 1 "user/mpy/py/objlist.h" 1 -# 31 "user/mpy/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; -# 37 "user/mpy/py/mpstate.h" 2 -# 1 "user/mpy/py/objexcept.h" 1 -# 30 "user/mpy/py/objexcept.h" -# 1 "user/mpy/py/objtuple.h" 1 -# 31 "user/mpy/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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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; -# 62 "user/mpy/py/objtuple.h" -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); -# 31 "user/mpy/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; -# 38 "user/mpy/py/mpstate.h" 2 -# 58 "user/mpy/py/mpstate.h" -typedef struct _mp_sched_item_t { - mp_obj_t func; - mp_obj_t arg; -} mp_sched_item_t; - - -typedef struct _mp_state_mem_t { - - - - - - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - - - - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[(64)]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - - - - uint16_t gc_auto_collect_enabled; - - - - - - - size_t gc_last_free_atb_index; -# 104 "user/mpy/py/mpstate.h" -} mp_state_mem_t; - - - -typedef struct _mp_state_vm_t { - - - - - - - qstr_pool_t *last_pool; - - - mp_obj_exception_t mp_emergency_exception_obj; -# 137 "user/mpy/py/mpstate.h" - mp_obj_dict_t mp_loaded_modules_dict; - - - volatile mp_obj_t mp_pending_exception; -# 154 "user/mpy/py/mpstate.h" - mp_obj_dict_t dict_main; - - - mp_obj_list_t mp_sys_path_obj; - mp_obj_list_t mp_sys_argv_obj; - - - - - - - - const char *readline_hist[8]; -# 190 "user/mpy/py/mpstate.h" - byte *qstr_last_chunk; - size_t qstr_last_alloc; - size_t qstr_last_used; - - - - - - - mp_uint_t mp_optimise_value; -# 210 "user/mpy/py/mpstate.h" -} mp_state_vm_t; - - - -typedef struct _mp_state_thread_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - - nlr_buf_t *nlr_top; - - - char *stack_top; - - - - -} mp_state_thread_t; - - - - - -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; -# 30 "user/mpy/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 { - -# 48 "user/mpy/py/runtime.h" 3 4 - _Bool -# 48 "user/mpy/py/runtime.h" - 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; - - -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); -# 78 "user/mpy/py/runtime.h" -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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, -# 80 "user/mpy/py/runtime.h" 3 4 - _Bool -# 80 "user/mpy/py/runtime.h" - 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); -__attribute__((noreturn)) void mp_arg_error_terse_mismatch(void); -__attribute__((noreturn)) void mp_arg_error_unimpl_kw(void); - -static inline mp_obj_dict_t *mp_locals_get(void) { return (mp_state_ctx.thread.dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { (mp_state_ctx.thread.dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return (mp_state_ctx.thread.dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { (mp_state_ctx.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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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( -# 107 "user/mpy/py/runtime.h" 3 4 - _Bool -# 107 "user/mpy/py/runtime.h" - 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); - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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; -# 127 "user/mpy/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_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); -mp_obj_t mp_iternext(mp_obj_t o); -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); - -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); - -__attribute__((noreturn)) void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); - -__attribute__((noreturn)) void mp_raise_ValueError(const char *msg); -__attribute__((noreturn)) void mp_raise_TypeError(const char *msg); -__attribute__((noreturn)) void mp_raise_NotImplementedError(const char *msg); -__attribute__((noreturn)) void mp_raise_OSError(int errno_); -__attribute__((noreturn)) void mp_exc_recursion_depth(void); -# 167 "user/mpy/py/runtime.h" -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); -# 30 "user/mpy/py/bc.h" 2 - -# 1 "user/mpy/py/objfun.h" 1 -# 31 "user/mpy/py/objfun.h" -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - const byte *bytecode; - const mp_uint_t *const_table; - - - - - - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; -# 32 "user/mpy/py/bc.h" 2 -# 64 "user/mpy/py/bc.h" -typedef struct _mp_exc_stack_t { - const byte *handler; - - - mp_obj_t *val_sp; - - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - - - - - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - - - - - mp_obj_t state[0]; - - -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -# 52 "user/mpy/py/emitnative.c" 2 diff --git a/user/mpy/build/genhdr/qstr.split b/user/mpy/build/genhdr/qstr.split deleted file mode 100644 index e69de29..0000000 diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr deleted file mode 100644 index 18a2b0b..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__builtinevex.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(_lt_string_gt_) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr deleted file mode 100644 index 9f4b09f..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__builtinimport.c.qstr +++ /dev/null @@ -1,6 +0,0 @@ -Q(__path__) -Q(__name__) -Q(__path__) -Q(__name__) -Q(__main__) -Q(__path__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr deleted file mode 100644 index 6d5f3c7..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__compile.c.qstr +++ /dev/null @@ -1,15 +0,0 @@ -Q(micropython) -Q(bytecode) -Q(_star_) -Q(AssertionError) -Q(range) -Q(__repl_print__) -Q(super) -Q(__class__) -Q(__class__) -Q(__name__) -Q(__module__) -Q(__qualname__) -Q(__class__) -Q(__class__) -Q(__class__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr deleted file mode 100644 index 0a6805e..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__emitbc.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(_star_) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr deleted file mode 100644 index 38b4956..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__modbuiltins.c.qstr +++ /dev/null @@ -1,83 +0,0 @@ -Q(_brace_open__colon__hash_b_brace_close_) -Q(_percent__hash_x) -Q(_percent__hash_o) -Q(sep) -Q(end) -Q(__name__) -Q(builtins) -Q(__build_class__) -Q(__import__) -Q(__repl_print__) -Q(bool) -Q(bytes) -Q(dict) -Q(int) -Q(list) -Q(map) -Q(object) -Q(range) -Q(str) -Q(super) -Q(tuple) -Q(type) -Q(zip) -Q(classmethod) -Q(staticmethod) -Q(Ellipsis) -Q(abs) -Q(all) -Q(any) -Q(bin) -Q(callable) -Q(chr) -Q(dir) -Q(divmod) -Q(eval) -Q(exec) -Q(getattr) -Q(setattr) -Q(globals) -Q(hasattr) -Q(hash) -Q(hex) -Q(id) -Q(isinstance) -Q(issubclass) -Q(iter) -Q(len) -Q(locals) -Q(next) -Q(oct) -Q(ord) -Q(pow) -Q(print) -Q(repr) -Q(round) -Q(sorted) -Q(sum) -Q(BaseException) -Q(ArithmeticError) -Q(AssertionError) -Q(AttributeError) -Q(EOFError) -Q(Exception) -Q(GeneratorExit) -Q(ImportError) -Q(IndentationError) -Q(IndexError) -Q(KeyboardInterrupt) -Q(KeyError) -Q(LookupError) -Q(MemoryError) -Q(NameError) -Q(NotImplementedError) -Q(OSError) -Q(OverflowError) -Q(RuntimeError) -Q(StopIteration) -Q(SyntaxError) -Q(SystemExit) -Q(TypeError) -Q(ValueError) -Q(ZeroDivisionError) -Q(open) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr deleted file mode 100644 index a39383a..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__modmicropython.c.qstr +++ /dev/null @@ -1,6 +0,0 @@ -Q(__name__) -Q(micropython) -Q(const) -Q(opt_level) -Q(heap_lock) -Q(heap_unlock) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr deleted file mode 100644 index b293a1a..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objbool.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(bool) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr deleted file mode 100644 index 7ef4862..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objboundmeth.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(bound_method) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr deleted file mode 100644 index 60ff1c1..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objclosure.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(closure) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr deleted file mode 100644 index acc0b3a..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objdict.c.qstr +++ /dev/null @@ -1,17 +0,0 @@ -Q(iterator) -Q(dict_view) -Q(clear) -Q(copy) -Q(fromkeys) -Q(get) -Q(items) -Q(keys) -Q(pop) -Q(popitem) -Q(setdefault) -Q(update) -Q(values) -Q(__getitem__) -Q(__setitem__) -Q(__delitem__) -Q(dict) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr deleted file mode 100644 index 42b1066..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objexcept.c.qstr +++ /dev/null @@ -1,29 +0,0 @@ -Q(__traceback__) -Q(args) -Q(value) -Q(__init__) -Q(BaseException) -Q(SystemExit) -Q(KeyboardInterrupt) -Q(GeneratorExit) -Q(Exception) -Q(StopIteration) -Q(ArithmeticError) -Q(OverflowError) -Q(ZeroDivisionError) -Q(AssertionError) -Q(AttributeError) -Q(EOFError) -Q(ImportError) -Q(LookupError) -Q(IndexError) -Q(KeyError) -Q(MemoryError) -Q(NameError) -Q(OSError) -Q(RuntimeError) -Q(NotImplementedError) -Q(SyntaxError) -Q(IndentationError) -Q(TypeError) -Q(ValueError) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr deleted file mode 100644 index 0c3de3e..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objfun.c.qstr +++ /dev/null @@ -1,6 +0,0 @@ -Q(function) -Q(function) -Q(function) -Q(function) -Q(function) -Q(function) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr deleted file mode 100644 index 451d0ca..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objgenerator.c.qstr +++ /dev/null @@ -1,5 +0,0 @@ -Q(generator) -Q(close) -Q(send) -Q(throw) -Q(generator) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr deleted file mode 100644 index 5bd02f4..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objgetitemiter.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(iterator) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr deleted file mode 100644 index 20c96a7..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objint.c.qstr +++ /dev/null @@ -1,5 +0,0 @@ -Q(little) -Q(little) -Q(from_bytes) -Q(to_bytes) -Q(int) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr deleted file mode 100644 index d1b1f6d..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objlist.c.qstr +++ /dev/null @@ -1,14 +0,0 @@ -Q(key) -Q(reverse) -Q(append) -Q(clear) -Q(copy) -Q(count) -Q(extend) -Q(index) -Q(insert) -Q(pop) -Q(remove) -Q(reverse) -Q(sort) -Q(list) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr deleted file mode 100644 index 90548b5..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objmap.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(map) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr deleted file mode 100644 index e4113ea..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objmodule.c.qstr +++ /dev/null @@ -1,7 +0,0 @@ -Q(__name__) -Q(module) -Q(__name__) -Q(__main__) -Q(builtins) -Q(micropython) -Q(__init__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr deleted file mode 100644 index 8efc009..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objnone.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(NoneType) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr deleted file mode 100644 index fbeb75f..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objobject.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(object) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr deleted file mode 100644 index 5bd02f4..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objpolyiter.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(iterator) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr deleted file mode 100644 index 470b232..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objrange.c.qstr +++ /dev/null @@ -1,5 +0,0 @@ -Q(iterator) -Q(start) -Q(stop) -Q(step) -Q(range) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr deleted file mode 100644 index 177e65a..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objsingleton.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(Ellipsis) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr deleted file mode 100644 index 36ce57b..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objstr.c.qstr +++ /dev/null @@ -1,27 +0,0 @@ -Q(find) -Q(rfind) -Q(index) -Q(rindex) -Q(join) -Q(split) -Q(rsplit) -Q(startswith) -Q(endswith) -Q(strip) -Q(lstrip) -Q(rstrip) -Q(format) -Q(replace) -Q(count) -Q(lower) -Q(upper) -Q(isspace) -Q(isalpha) -Q(isdigit) -Q(isupper) -Q(islower) -Q(str) -Q(bytes) -Q(str) -Q(bytes) -Q(str) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr deleted file mode 100644 index 78c28c3..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objtuple.c.qstr +++ /dev/null @@ -1,3 +0,0 @@ -Q(count) -Q(index) -Q(tuple) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr deleted file mode 100644 index 9929a26..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objtype.c.qstr +++ /dev/null @@ -1,30 +0,0 @@ -Q(__str__) -Q(__repr__) -Q(__repr__) -Q(__new__) -Q(__init__) -Q(__bool__) -Q(__len__) -Q(__hash__) -Q(__eq__) -Q(__add__) -Q(__sub__) -Q(__lt__) -Q(__gt__) -Q(__eq__) -Q(__le__) -Q(__ge__) -Q(__contains__) -Q(__getattr__) -Q(__getattr__) -Q(__delitem__) -Q(__getitem__) -Q(__setitem__) -Q(__call__) -Q(__iter__) -Q(type) -Q(__new__) -Q(function) -Q(super) -Q(staticmethod) -Q(classmethod) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr deleted file mode 100644 index 87119c4..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__objzip.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(zip) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr deleted file mode 100644 index 922ead4..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__runtime.c.qstr +++ /dev/null @@ -1,16 +0,0 @@ -Q(__name__) -Q(__main__) -Q(keys) -Q(__getitem__) -Q(function) -Q(closure) -Q(generator) -Q(__next__) -Q(__getitem__) -Q(__next__) -Q(__next__) -Q(__next__) -Q(send) -Q(close) -Q(throw) -Q(__name__) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr deleted file mode 100644 index 5317711..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__scope.c.qstr +++ /dev/null @@ -1,6 +0,0 @@ -Q(_lt_module_gt_) -Q(_lt_lambda_gt_) -Q(_lt_listcomp_gt_) -Q(_lt_dictcomp_gt_) -Q(_lt_setcomp_gt_) -Q(_lt_genexpr_gt_) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr deleted file mode 100644 index abbac45..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__stream.c.qstr +++ /dev/null @@ -1 +0,0 @@ -Q(close) diff --git a/user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr b/user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr deleted file mode 100644 index 5b6ae33..0000000 --- a/user/mpy/build/genhdr/qstr/user__mpy__py__vm.c.qstr +++ /dev/null @@ -1,2 +0,0 @@ -Q(__exit__) -Q(__enter__) diff --git a/user/mpy/build/genhdr/qstrdefs.collected.h b/user/mpy/build/genhdr/qstrdefs.collected.h deleted file mode 100644 index 9727df5..0000000 --- a/user/mpy/build/genhdr/qstrdefs.collected.h +++ /dev/null @@ -1,589 +0,0 @@ -Q(ArithmeticError) - -Q(ArithmeticError) - -Q(AssertionError) - -Q(AssertionError) - -Q(AssertionError) - -Q(AttributeError) - -Q(AttributeError) - -Q(BaseException) - -Q(BaseException) - -Q(EOFError) - -Q(EOFError) - -Q(Ellipsis) - -Q(Ellipsis) - -Q(Exception) - -Q(Exception) - -Q(GeneratorExit) - -Q(GeneratorExit) - -Q(ImportError) - -Q(ImportError) - -Q(IndentationError) - -Q(IndentationError) - -Q(IndexError) - -Q(IndexError) - -Q(KeyError) - -Q(KeyError) - -Q(KeyboardInterrupt) - -Q(KeyboardInterrupt) - -Q(LookupError) - -Q(LookupError) - -Q(MemoryError) - -Q(MemoryError) - -Q(NameError) - -Q(NameError) - -Q(NoneType) - -Q(NotImplementedError) - -Q(NotImplementedError) - -Q(OSError) - -Q(OSError) - -Q(OverflowError) - -Q(OverflowError) - -Q(RuntimeError) - -Q(RuntimeError) - -Q(StopIteration) - -Q(StopIteration) - -Q(SyntaxError) - -Q(SyntaxError) - -Q(SystemExit) - -Q(SystemExit) - -Q(TypeError) - -Q(TypeError) - -Q(ValueError) - -Q(ValueError) - -Q(ZeroDivisionError) - -Q(ZeroDivisionError) - -Q(__add__) - -Q(__bool__) - -Q(__build_class__) - -Q(__call__) - -Q(__class__) - -Q(__class__) - -Q(__class__) - -Q(__class__) - -Q(__class__) - -Q(__contains__) - -Q(__delitem__) - -Q(__delitem__) - -Q(__enter__) - -Q(__eq__) - -Q(__eq__) - -Q(__exit__) - -Q(__ge__) - -Q(__getattr__) - -Q(__getattr__) - -Q(__getitem__) - -Q(__getitem__) - -Q(__getitem__) - -Q(__getitem__) - -Q(__gt__) - -Q(__hash__) - -Q(__import__) - -Q(__init__) - -Q(__init__) - -Q(__init__) - -Q(__iter__) - -Q(__le__) - -Q(__len__) - -Q(__lt__) - -Q(__main__) - -Q(__main__) - -Q(__main__) - -Q(__module__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__new__) - -Q(__new__) - -Q(__next__) - -Q(__next__) - -Q(__next__) - -Q(__next__) - -Q(__path__) - -Q(__path__) - -Q(__path__) - -Q(__qualname__) - -Q(__repl_print__) - -Q(__repl_print__) - -Q(__repr__) - -Q(__repr__) - -Q(__setitem__) - -Q(__setitem__) - -Q(__str__) - -Q(__sub__) - -Q(__traceback__) - -Q(_brace_open__colon__hash_b_brace_close_) - -Q(_lt_dictcomp_gt_) - -Q(_lt_genexpr_gt_) - -Q(_lt_lambda_gt_) - -Q(_lt_listcomp_gt_) - -Q(_lt_module_gt_) - -Q(_lt_setcomp_gt_) - -Q(_lt_string_gt_) - -Q(_percent__hash_o) - -Q(_percent__hash_x) - -Q(_star_) - -Q(_star_) - -Q(abs) - -Q(all) - -Q(any) - -Q(append) - -Q(args) - -Q(bin) - -Q(bool) - -Q(bool) - -Q(bound_method) - -Q(builtins) - -Q(builtins) - -Q(bytecode) - -Q(bytes) - -Q(bytes) - -Q(bytes) - -Q(callable) - -Q(chr) - -Q(classmethod) - -Q(classmethod) - -Q(clear) - -Q(clear) - -Q(close) - -Q(close) - -Q(close) - -Q(closure) - -Q(closure) - -Q(const) - -Q(copy) - -Q(copy) - -Q(count) - -Q(count) - -Q(count) - -Q(dict) - -Q(dict) - -Q(dict_view) - -Q(dir) - -Q(divmod) - -Q(end) - -Q(endswith) - -Q(eval) - -Q(exec) - -Q(extend) - -Q(find) - -Q(format) - -Q(from_bytes) - -Q(fromkeys) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(generator) - -Q(generator) - -Q(generator) - -Q(get) - -Q(getattr) - -Q(globals) - -Q(hasattr) - -Q(hash) - -Q(heap_lock) - -Q(heap_unlock) - -Q(hex) - -Q(id) - -Q(index) - -Q(index) - -Q(index) - -Q(insert) - -Q(int) - -Q(int) - -Q(isalpha) - -Q(isdigit) - -Q(isinstance) - -Q(islower) - -Q(isspace) - -Q(issubclass) - -Q(isupper) - -Q(items) - -Q(iter) - -Q(iterator) - -Q(iterator) - -Q(iterator) - -Q(iterator) - -Q(join) - -Q(key) - -Q(keys) - -Q(keys) - -Q(len) - -Q(list) - -Q(list) - -Q(little) - -Q(little) - -Q(locals) - -Q(lower) - -Q(lstrip) - -Q(map) - -Q(map) - -Q(micropython) - -Q(micropython) - -Q(micropython) - -Q(module) - -Q(next) - -Q(object) - -Q(object) - -Q(oct) - -Q(open) - -Q(opt_level) - -Q(ord) - -Q(pop) - -Q(pop) - -Q(popitem) - -Q(pow) - -Q(print) - -Q(range) - -Q(range) - -Q(range) - -Q(remove) - -Q(replace) - -Q(repr) - -Q(reverse) - -Q(reverse) - -Q(rfind) - -Q(rindex) - -Q(round) - -Q(rsplit) - -Q(rstrip) - -Q(send) - -Q(send) - -Q(sep) - -Q(setattr) - -Q(setdefault) - -Q(sort) - -Q(sorted) - -Q(split) - -Q(start) - -Q(startswith) - -Q(staticmethod) - -Q(staticmethod) - -Q(step) - -Q(stop) - -Q(str) - -Q(str) - -Q(str) - -Q(str) - -Q(strip) - -Q(sum) - -Q(super) - -Q(super) - -Q(super) - -Q(throw) - -Q(throw) - -Q(to_bytes) - -Q(tuple) - -Q(tuple) - -Q(type) - -Q(type) - -Q(update) - -Q(upper) - -Q(value) - -Q(values) - -Q(zip) - -Q(zip) diff --git a/user/mpy/build/genhdr/qstrdefs.collected.h.hash b/user/mpy/build/genhdr/qstrdefs.collected.h.hash deleted file mode 100644 index 25fee4f..0000000 --- a/user/mpy/build/genhdr/qstrdefs.collected.h.hash +++ /dev/null @@ -1 +0,0 @@ -8aecabe383bd222126dadade55becad1 \ No newline at end of file diff --git a/user/mpy/build/genhdr/qstrdefs.generated.h b/user/mpy/build/genhdr/qstrdefs.generated.h deleted file mode 100644 index a8a9128..0000000 --- a/user/mpy/build/genhdr/qstrdefs.generated.h +++ /dev/null @@ -1,202 +0,0 @@ -// This file was automatically generated by makeqstrdata.py - -QDEF(MP_QSTR_NULL, (const byte*)"\x00\x00" "") -QDEF(MP_QSTR_, (const byte*)"\x05\x00" "") -QDEF(MP_QSTR__star_, (const byte*)"\x8f\x01" "*") -QDEF(MP_QSTR__, (const byte*)"\xfa\x01" "_") -QDEF(MP_QSTR__slash_, (const byte*)"\x8a\x01" "/") -QDEF(MP_QSTR__percent__hash_o, (const byte*)"\x6c\x03" "%#o") -QDEF(MP_QSTR__percent__hash_x, (const byte*)"\x7b\x03" "%#x") -QDEF(MP_QSTR__brace_open__colon__hash_b_brace_close_, (const byte*)"\x58\x05" "{:#b}") -QDEF(MP_QSTR__0x0a_, (const byte*)"\xaf\x01" "\x0a") -QDEF(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, (const byte*)"\x73\x20" "maximum recursion depth exceeded") -QDEF(MP_QSTR__lt_module_gt_, (const byte*)"\xbd\x08" "") -QDEF(MP_QSTR__lt_lambda_gt_, (const byte*)"\x80\x08" "") -QDEF(MP_QSTR__lt_listcomp_gt_, (const byte*)"\xd4\x0a" "") -QDEF(MP_QSTR__lt_dictcomp_gt_, (const byte*)"\xcc\x0a" "") -QDEF(MP_QSTR__lt_setcomp_gt_, (const byte*)"\x54\x09" "") -QDEF(MP_QSTR__lt_genexpr_gt_, (const byte*)"\x34\x09" "") -QDEF(MP_QSTR__lt_string_gt_, (const byte*)"\x52\x08" "") -QDEF(MP_QSTR__lt_stdin_gt_, (const byte*)"\xe3\x07" "") -QDEF(MP_QSTR_utf_hyphen_8, (const byte*)"\xb7\x05" "utf-8") -QDEF(MP_QSTR___locals__, (const byte*)"\x7b\x0a" "__locals__") -QDEF(MP_QSTR_BufferError, (const byte*)"\x1d\x0b" "BufferError") -QDEF(MP_QSTR_FileExistsError, (const byte*)"\x5b\x0f" "FileExistsError") -QDEF(MP_QSTR_FileNotFoundError, (const byte*)"\x78\x11" "FileNotFoundError") -QDEF(MP_QSTR_FloatingPointError, (const byte*)"\x01\x12" "FloatingPointError") -QDEF(MP_QSTR_UnboundLocalError, (const byte*)"\x99\x11" "UnboundLocalError") -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___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___call__, (const byte*)"\xa7\x08" "__call__") -QDEF(MP_QSTR___class__, (const byte*)"\x2b\x09" "__class__") -QDEF(MP_QSTR___contains__, (const byte*)"\xc6\x0c" "__contains__") -QDEF(MP_QSTR___delitem__, (const byte*)"\xfd\x0b" "__delitem__") -QDEF(MP_QSTR___enter__, (const byte*)"\x6d\x09" "__enter__") -QDEF(MP_QSTR___eq__, (const byte*)"\x71\x06" "__eq__") -QDEF(MP_QSTR___exit__, (const byte*)"\x45\x08" "__exit__") -QDEF(MP_QSTR___ge__, (const byte*)"\xa7\x06" "__ge__") -QDEF(MP_QSTR___getattr__, (const byte*)"\x40\x0b" "__getattr__") -QDEF(MP_QSTR___getitem__, (const byte*)"\x26\x0b" "__getitem__") -QDEF(MP_QSTR___gt__, (const byte*)"\xb6\x06" "__gt__") -QDEF(MP_QSTR___hash__, (const byte*)"\xf7\x08" "__hash__") -QDEF(MP_QSTR___import__, (const byte*)"\x38\x0a" "__import__") -QDEF(MP_QSTR___init__, (const byte*)"\x5f\x08" "__init__") -QDEF(MP_QSTR___iter__, (const byte*)"\xcf\x08" "__iter__") -QDEF(MP_QSTR___le__, (const byte*)"\xcc\x06" "__le__") -QDEF(MP_QSTR___len__, (const byte*)"\xe2\x07" "__len__") -QDEF(MP_QSTR___lt__, (const byte*)"\x5d\x06" "__lt__") -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___path__, (const byte*)"\xc8\x08" "__path__") -QDEF(MP_QSTR___qualname__, (const byte*)"\x6b\x0c" "__qualname__") -QDEF(MP_QSTR___repl_print__, (const byte*)"\x01\x0e" "__repl_print__") -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___sub__, (const byte*)"\x21\x07" "__sub__") -QDEF(MP_QSTR___traceback__, (const byte*)"\x4f\x0d" "__traceback__") -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_bin, (const byte*)"\xe0\x03" "bin") -QDEF(MP_QSTR_bool, (const byte*)"\xeb\x04" "bool") -QDEF(MP_QSTR_bound_method, (const byte*)"\x97\x0c" "bound_method") -QDEF(MP_QSTR_builtins, (const byte*)"\xf7\x08" "builtins") -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_closure, (const byte*)"\x74\x07" "closure") -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_dict_view, (const byte*)"\x2d\x09" "dict_view") -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_fromkeys, (const byte*)"\x37\x08" "fromkeys") -QDEF(MP_QSTR_function, (const byte*)"\x27\x08" "function") -QDEF(MP_QSTR_generator, (const byte*)"\x96\x09" "generator") -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_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_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_iterator, (const byte*)"\x47\x08" "iterator") -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_map, (const byte*)"\xb9\x03" "map") -QDEF(MP_QSTR_micropython, (const byte*)"\x0b\x0b" "micropython") -QDEF(MP_QSTR_module, (const byte*)"\xbf\x06" "module") -QDEF(MP_QSTR_next, (const byte*)"\x42\x04" "next") -QDEF(MP_QSTR_object, (const byte*)"\x90\x06" "object") -QDEF(MP_QSTR_oct, (const byte*)"\xfd\x03" "oct") -QDEF(MP_QSTR_open, (const byte*)"\xd1\x04" "open") -QDEF(MP_QSTR_opt_level, (const byte*)"\x87\x09" "opt_level") -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_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_send, (const byte*)"\xb9\x04" "send") -QDEF(MP_QSTR_sep, (const byte*)"\x23\x03" "sep") -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_value, (const byte*)"\x4e\x05" "value") -QDEF(MP_QSTR_values, (const byte*)"\x7d\x06" "values") -QDEF(MP_QSTR_zip, (const byte*)"\xe6\x03" "zip") diff --git a/user/mpy/build/genhdr/qstrdefs.preprocessed.h b/user/mpy/build/genhdr/qstrdefs.preprocessed.h deleted file mode 100644 index ddbba1d..0000000 --- a/user/mpy/build/genhdr/qstrdefs.preprocessed.h +++ /dev/null @@ -1,1243 +0,0 @@ -# 1 "" -# 1 "/home/grd/kernel/pikoRT//" -# 1 "" -# 1 "" -# 1 "" -# 27 "" -# 1 "user/mpy/py/mpconfig.h" 1 -# 45 "user/mpy/py/mpconfig.h" -# 1 "user/mpy/mpconfigport.h" 1 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 1 3 4 -# 9 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/stdint.h" 1 3 4 -# 12 "/usr/arm-none-eabi/include/stdint.h" 3 4 -# 1 "/usr/arm-none-eabi/include/machine/_default_types.h" 1 3 4 - - - - - - - -# 1 "/usr/arm-none-eabi/include/sys/features.h" 1 3 4 -# 28 "/usr/arm-none-eabi/include/sys/features.h" 3 4 -# 1 "/usr/arm-none-eabi/include/_newlib_version.h" 1 3 4 -# 29 "/usr/arm-none-eabi/include/sys/features.h" 2 3 4 -# 9 "/usr/arm-none-eabi/include/machine/_default_types.h" 2 3 4 -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 - -# 41 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int8_t; - -typedef unsigned char __uint8_t; -# 55 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int16_t; - -typedef short unsigned int __uint16_t; -# 77 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int32_t; - -typedef long unsigned int __uint32_t; -# 103 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int64_t; - -typedef long long unsigned int __uint64_t; -# 134 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef signed char __int_least8_t; - -typedef unsigned char __uint_least8_t; -# 160 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef short int __int_least16_t; - -typedef short unsigned int __uint_least16_t; -# 182 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long int __int_least32_t; - -typedef long unsigned int __uint_least32_t; -# 200 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __int_least64_t; - -typedef long long unsigned int __uint_least64_t; -# 214 "/usr/arm-none-eabi/include/machine/_default_types.h" 3 4 -typedef long long int __intmax_t; - - - - - - - -typedef long long unsigned int __uintmax_t; - - - - - - - -typedef int __intptr_t; - -typedef unsigned int __uintptr_t; -# 13 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_intsup.h" 1 3 4 -# 35 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 187 "/usr/arm-none-eabi/include/sys/_intsup.h" 3 4 - - - - - - - -# 14 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 -# 1 "/usr/arm-none-eabi/include/sys/_stdint.h" 1 3 4 -# 20 "/usr/arm-none-eabi/include/sys/_stdint.h" 3 4 -typedef __int8_t int8_t ; - - - -typedef __uint8_t uint8_t ; - - - - - - - -typedef __int16_t int16_t ; - - - -typedef __uint16_t uint16_t ; - - - - - - - -typedef __int32_t int32_t ; - - - -typedef __uint32_t uint32_t ; - - - - - - - -typedef __int64_t int64_t ; - - - -typedef __uint64_t uint64_t ; - - - - - - -typedef __intmax_t intmax_t; - - - - -typedef __uintmax_t uintmax_t; - - - - -typedef __intptr_t intptr_t; - - - - -typedef __uintptr_t uintptr_t; -# 15 "/usr/arm-none-eabi/include/stdint.h" 2 3 4 - - - - - - -typedef __int_least8_t int_least8_t; -typedef __uint_least8_t uint_least8_t; - - - - -typedef __int_least16_t int_least16_t; -typedef __uint_least16_t uint_least16_t; - - - - -typedef __int_least32_t int_least32_t; -typedef __uint_least32_t uint_least32_t; - - - - -typedef __int_least64_t int_least64_t; -typedef __uint_least64_t uint_least64_t; -# 51 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast8_t; - typedef unsigned int uint_fast8_t; -# 61 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast16_t; - typedef unsigned int uint_fast16_t; -# 71 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef int int_fast32_t; - typedef unsigned int uint_fast32_t; -# 81 "/usr/arm-none-eabi/include/stdint.h" 3 4 - typedef long long int int_fast64_t; - typedef long long unsigned int uint_fast64_t; -# 10 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stdint.h" 2 3 4 -# 2 "user/mpy/mpconfigport.h" 2 -# 68 "user/mpy/mpconfigport.h" - -# 68 "user/mpy/mpconfigport.h" -typedef int mp_int_t; -typedef unsigned mp_uint_t; - -typedef long mp_off_t; -# 80 "user/mpy/mpconfigport.h" -# 1 "/usr/arm-none-eabi/include/alloca.h" 1 3 -# 10 "/usr/arm-none-eabi/include/alloca.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 15 "/usr/arm-none-eabi/include/_ansi.h" 3 -# 1 "/usr/arm-none-eabi/include/newlib.h" 1 3 -# 16 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/config.h" 1 3 - - - -# 1 "/usr/arm-none-eabi/include/machine/ieeefp.h" 1 3 -# 5 "/usr/arm-none-eabi/include/sys/config.h" 2 3 -# 17 "/usr/arm-none-eabi/include/_ansi.h" 2 3 -# 11 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/reent.h" 1 3 -# 13 "/usr/arm-none-eabi/include/sys/reent.h" 3 -# 1 "/usr/arm-none-eabi/include/_ansi.h" 1 3 -# 14 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 - -# 149 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef int ptrdiff_t; -# 216 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int size_t; -# 328 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wchar_t; -# 15 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/_types.h" 1 3 -# 24 "/usr/arm-none-eabi/include/sys/_types.h" 3 -# 1 "/usr/arm-none-eabi/include/machine/_types.h" 1 3 -# 25 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 -# 1 "/usr/arm-none-eabi/include/sys/lock.h" 1 3 -# 11 "/usr/arm-none-eabi/include/sys/lock.h" 3 -typedef int _LOCK_T; -typedef int _LOCK_RECURSIVE_T; -# 26 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - -typedef long __blkcnt_t; - - - -typedef long __blksize_t; - - - -typedef __uint64_t __fsblkcnt_t; - - - -typedef __uint32_t __fsfilcnt_t; - - - -typedef long _off_t; - - - - - -typedef int __pid_t; - - - -typedef short __dev_t; - - - -typedef unsigned short __uid_t; - - -typedef unsigned short __gid_t; - - - -typedef __uint32_t __id_t; - - - - - - - -typedef unsigned short __ino_t; -# 88 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef __uint32_t __mode_t; - - - - - -__extension__ typedef long long _off64_t; - - - - - -typedef _off_t __off_t; - - -typedef _off64_t __loff_t; - - -typedef long __key_t; - - - - - - - -typedef long _fpos_t; -# 129 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef unsigned int __size_t; -# 145 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef signed int _ssize_t; -# 156 "/usr/arm-none-eabi/include/sys/_types.h" 3 -typedef _ssize_t __ssize_t; - - -# 1 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 1 3 4 -# 357 "/usr/lib/gcc/arm-none-eabi/7.1.0/include/stddef.h" 3 4 -typedef unsigned int wint_t; -# 160 "/usr/arm-none-eabi/include/sys/_types.h" 2 3 - - - -typedef struct -{ - int __count; - union - { - wint_t __wch; - unsigned char __wchb[4]; - } __value; -} _mbstate_t; - - - -typedef _LOCK_RECURSIVE_T _flock_t; - - - - -typedef void *_iconv_t; - - - -typedef unsigned long __clock_t; - - -typedef long __time_t; - - -typedef unsigned long __clockid_t; - - -typedef unsigned long __timer_t; - - -typedef __uint8_t __sa_family_t; - - - -typedef __uint32_t __socklen_t; - - -typedef unsigned short __nlink_t; -typedef long __suseconds_t; -typedef unsigned long __useconds_t; - - - - -typedef char * __va_list; -# 16 "/usr/arm-none-eabi/include/sys/reent.h" 2 3 - - - - - - -typedef unsigned long __ULong; -# 38 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent; - -struct __locale_t; - - - - - - -struct _Bigint -{ - struct _Bigint *_next; - int _k, _maxwds, _sign, _wds; - __ULong _x[1]; -}; - - -struct __tm -{ - int __tm_sec; - int __tm_min; - int __tm_hour; - int __tm_mday; - int __tm_mon; - int __tm_year; - int __tm_wday; - int __tm_yday; - int __tm_isdst; -}; - - - - - - - -struct _on_exit_args { - void * _fnargs[32]; - void * _dso_handle[32]; - - __ULong _fntypes; - - - __ULong _is_cxa; -}; -# 93 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _atexit { - struct _atexit *_next; - int _ind; - - void (*_fns[32])(void); - struct _on_exit_args _on_exit_args; -}; -# 117 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sbuf { - unsigned char *_base; - int _size; -}; -# 181 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - - - - - void * _cookie; - - int (* _read) (struct _reent *, void *, char *, int) - ; - int (* _write) (struct _reent *, void *, const char *, int) - - ; - _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); - int (* _close) (struct _reent *, void *); - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - _off_t _offset; - - - struct _reent *_data; - - - - _flock_t _lock; - - _mbstate_t _mbstate; - int _flags2; -}; -# 287 "/usr/arm-none-eabi/include/sys/reent.h" 3 -typedef struct __sFILE __FILE; - - - -struct _glue -{ - struct _glue *_next; - int _niobs; - __FILE *_iobs; -}; -# 319 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _rand48 { - unsigned short _seed[3]; - unsigned short _mult[3]; - unsigned short _add; - - - - -}; -# 569 "/usr/arm-none-eabi/include/sys/reent.h" 3 -struct _reent -{ - int _errno; - - - - - __FILE *_stdin, *_stdout, *_stderr; - - int _inc; - char _emergency[25]; - - - int _unspecified_locale_info; - struct __locale_t *_locale; - - int __sdidinit; - - void (* __cleanup) (struct _reent *); - - - struct _Bigint *_result; - int _result_k; - struct _Bigint *_p5s; - struct _Bigint **_freelist; - - - int _cvtlen; - char *_cvtbuf; - - union - { - struct - { - unsigned int _unused_rand; - char * _strtok_last; - char _asctime_buf[26]; - struct __tm _localtime_buf; - int _gamma_signgam; - __extension__ unsigned long long _rand_next; - struct _rand48 _r48; - _mbstate_t _mblen_state; - _mbstate_t _mbtowc_state; - _mbstate_t _wctomb_state; - char _l64a_buf[8]; - char _signal_buf[24]; - int _getdate_err; - _mbstate_t _mbrlen_state; - _mbstate_t _mbrtowc_state; - _mbstate_t _mbsrtowcs_state; - _mbstate_t _wcrtomb_state; - _mbstate_t _wcsrtombs_state; - int _h_errno; - } _reent; - - - - struct - { - - unsigned char * _nextf[30]; - unsigned int _nmalloc[30]; - } _unused; - } _new; - - - - struct _atexit *_atexit; - struct _atexit _atexit0; - - - - void (**(_sig_func))(int); - - - - - struct _glue __sglue; - __FILE __sf[3]; -}; -# 766 "/usr/arm-none-eabi/include/sys/reent.h" 3 -extern struct _reent *_impure_ptr ; -extern struct _reent *const _global_impure_ptr ; - -void _reclaim_reent (struct _reent *); -# 12 "/usr/arm-none-eabi/include/alloca.h" 2 3 -# 81 "user/mpy/mpconfigport.h" 2 -# 46 "user/mpy/py/mpconfig.h" 2 -# 28 "" 2 - - - - - - -# 33 "" -QCFG(BYTES_IN_LEN, (1)) -QCFG(BYTES_IN_HASH, (1)) - -Q() -Q(*) -Q(_) -Q(/) -Q(%#o) -Q(%#x) -Q({:#b}) -Q(\n) -Q(maximum recursion depth exceeded) -Q() -Q() -Q() -Q() -Q() -Q() -Q() -Q() -Q(utf-8) - - -Q(__locals__) -Q(BufferError) -Q(FileExistsError) -Q(FileNotFoundError) -Q(FloatingPointError) -Q(UnboundLocalError) -Q(ArithmeticError) - -Q(ArithmeticError) - -Q(AssertionError) - -Q(AssertionError) - -Q(AssertionError) - -Q(AttributeError) - -Q(AttributeError) - -Q(BaseException) - -Q(BaseException) - -Q(EOFError) - -Q(EOFError) - -Q(Ellipsis) - -Q(Ellipsis) - -Q(Exception) - -Q(Exception) - -Q(GeneratorExit) - -Q(GeneratorExit) - -Q(ImportError) - -Q(ImportError) - -Q(IndentationError) - -Q(IndentationError) - -Q(IndexError) - -Q(IndexError) - -Q(KeyError) - -Q(KeyError) - -Q(KeyboardInterrupt) - -Q(KeyboardInterrupt) - -Q(LookupError) - -Q(LookupError) - -Q(MemoryError) - -Q(MemoryError) - -Q(NameError) - -Q(NameError) - -Q(NoneType) - -Q(NotImplementedError) - -Q(NotImplementedError) - -Q(OSError) - -Q(OSError) - -Q(OverflowError) - -Q(OverflowError) - -Q(RuntimeError) - -Q(RuntimeError) - -Q(StopIteration) - -Q(StopIteration) - -Q(SyntaxError) - -Q(SyntaxError) - -Q(SystemExit) - -Q(SystemExit) - -Q(TypeError) - -Q(TypeError) - -Q(ValueError) - -Q(ValueError) - -Q(ZeroDivisionError) - -Q(ZeroDivisionError) - -Q(__add__) - -Q(__bool__) - -Q(__build_class__) - -Q(__call__) - -Q(__class__) - -Q(__class__) - -Q(__class__) - -Q(__class__) - -Q(__class__) - -Q(__contains__) - -Q(__delitem__) - -Q(__delitem__) - -Q(__enter__) - -Q(__eq__) - -Q(__eq__) - -Q(__exit__) - -Q(__ge__) - -Q(__getattr__) - -Q(__getattr__) - -Q(__getitem__) - -Q(__getitem__) - -Q(__getitem__) - -Q(__getitem__) - -Q(__gt__) - -Q(__hash__) - -Q(__import__) - -Q(__init__) - -Q(__init__) - -Q(__init__) - -Q(__iter__) - -Q(__le__) - -Q(__len__) - -Q(__lt__) - -Q(__main__) - -Q(__main__) - -Q(__main__) - -Q(__module__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__name__) - -Q(__new__) - -Q(__new__) - -Q(__next__) - -Q(__next__) - -Q(__next__) - -Q(__next__) - -Q(__path__) - -Q(__path__) - -Q(__path__) - -Q(__qualname__) - -Q(__repl_print__) - -Q(__repl_print__) - -Q(__repr__) - -Q(__repr__) - -Q(__setitem__) - -Q(__setitem__) - -Q(__str__) - -Q(__sub__) - -Q(__traceback__) - -Q(_brace_open__colon__hash_b_brace_close_) - -Q(_lt_dictcomp_gt_) - -Q(_lt_genexpr_gt_) - -Q(_lt_lambda_gt_) - -Q(_lt_listcomp_gt_) - -Q(_lt_module_gt_) - -Q(_lt_setcomp_gt_) - -Q(_lt_string_gt_) - -Q(_percent__hash_o) - -Q(_percent__hash_x) - -Q(_star_) - -Q(_star_) - -Q(abs) - -Q(all) - -Q(any) - -Q(append) - -Q(args) - -Q(bin) - -Q(bool) - -Q(bool) - -Q(bound_method) - -Q(builtins) - -Q(builtins) - -Q(bytecode) - -Q(bytes) - -Q(bytes) - -Q(bytes) - -Q(callable) - -Q(chr) - -Q(classmethod) - -Q(classmethod) - -Q(clear) - -Q(clear) - -Q(close) - -Q(close) - -Q(close) - -Q(closure) - -Q(closure) - -Q(const) - -Q(copy) - -Q(copy) - -Q(count) - -Q(count) - -Q(count) - -Q(dict) - -Q(dict) - -Q(dict_view) - -Q(dir) - -Q(divmod) - -Q(end) - -Q(endswith) - -Q(eval) - -Q(exec) - -Q(extend) - -Q(find) - -Q(format) - -Q(from_bytes) - -Q(fromkeys) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(function) - -Q(generator) - -Q(generator) - -Q(generator) - -Q(get) - -Q(getattr) - -Q(globals) - -Q(hasattr) - -Q(hash) - -Q(heap_lock) - -Q(heap_unlock) - -Q(hex) - -Q(id) - -Q(index) - -Q(index) - -Q(index) - -Q(insert) - -Q(int) - -Q(int) - -Q(isalpha) - -Q(isdigit) - -Q(isinstance) - -Q(islower) - -Q(isspace) - -Q(issubclass) - -Q(isupper) - -Q(items) - -Q(iter) - -Q(iterator) - -Q(iterator) - -Q(iterator) - -Q(iterator) - -Q(join) - -Q(key) - -Q(keys) - -Q(keys) - -Q(len) - -Q(list) - -Q(list) - -Q(little) - -Q(little) - -Q(locals) - -Q(lower) - -Q(lstrip) - -Q(map) - -Q(map) - -Q(micropython) - -Q(micropython) - -Q(micropython) - -Q(module) - -Q(next) - -Q(object) - -Q(object) - -Q(oct) - -Q(open) - -Q(opt_level) - -Q(ord) - -Q(pop) - -Q(pop) - -Q(popitem) - -Q(pow) - -Q(print) - -Q(range) - -Q(range) - -Q(range) - -Q(remove) - -Q(replace) - -Q(repr) - -Q(reverse) - -Q(reverse) - -Q(rfind) - -Q(rindex) - -Q(round) - -Q(rsplit) - -Q(rstrip) - -Q(send) - -Q(send) - -Q(sep) - -Q(setattr) - -Q(setdefault) - -Q(sort) - -Q(sorted) - -Q(split) - -Q(start) - -Q(startswith) - -Q(staticmethod) - -Q(staticmethod) - -Q(step) - -Q(stop) - -Q(str) - -Q(str) - -Q(str) - -Q(str) - -Q(strip) - -Q(sum) - -Q(super) - -Q(super) - -Q(super) - -Q(throw) - -Q(throw) - -Q(to_bytes) - -Q(tuple) - -Q(tuple) - -Q(type) - -Q(type) - -Q(update) - -Q(upper) - -Q(value) - -Q(values) - -Q(zip) - -Q(zip) diff --git a/user/mpy/extmod/crypto-algorithms/sha256.c b/user/mpy/extmod/crypto-algorithms/sha256.c deleted file mode 100644 index 276611c..0000000 --- a/user/mpy/extmod/crypto-algorithms/sha256.c +++ /dev/null @@ -1,157 +0,0 @@ -/********************************************************************* -* Filename: sha256.c -* Author: Brad Conte (brad AT bradconte.com) -* Copyright: -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: Implementation of the SHA-256 hashing algorithm. - SHA-256 is one of the three algorithms in the SHA2 - specification. The others, SHA-384 and SHA-512, are not - offered in this implementation. - Algorithm specification can be found here: - * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf - This implementation uses little endian byte order. -*********************************************************************/ - -/*************************** HEADER FILES ***************************/ -#include -#include "sha256.h" - -/****************************** MACROS ******************************/ -#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b)))) -#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b)))) - -#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z))) -#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) -#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22)) -#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25)) -#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3)) -#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10)) - -/**************************** VARIABLES *****************************/ -static const WORD k[64] = { - 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5, - 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174, - 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da, - 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967, - 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85, - 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070, - 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3, - 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 -}; - -/*********************** FUNCTION DEFINITIONS ***********************/ -static void sha256_transform(CRYAL_SHA256_CTX *ctx, const BYTE data[]) -{ - WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64]; - - for (i = 0, j = 0; i < 16; ++i, j += 4) - m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]); - for ( ; i < 64; ++i) - m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16]; - - a = ctx->state[0]; - b = ctx->state[1]; - c = ctx->state[2]; - d = ctx->state[3]; - e = ctx->state[4]; - f = ctx->state[5]; - g = ctx->state[6]; - h = ctx->state[7]; - - for (i = 0; i < 64; ++i) { - t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i]; - t2 = EP0(a) + MAJ(a,b,c); - h = g; - g = f; - f = e; - e = d + t1; - d = c; - c = b; - b = a; - a = t1 + t2; - } - - ctx->state[0] += a; - ctx->state[1] += b; - ctx->state[2] += c; - ctx->state[3] += d; - ctx->state[4] += e; - ctx->state[5] += f; - ctx->state[6] += g; - ctx->state[7] += h; -} - -void sha256_init(CRYAL_SHA256_CTX *ctx) -{ - ctx->datalen = 0; - ctx->bitlen = 0; - ctx->state[0] = 0x6a09e667; - ctx->state[1] = 0xbb67ae85; - ctx->state[2] = 0x3c6ef372; - ctx->state[3] = 0xa54ff53a; - ctx->state[4] = 0x510e527f; - ctx->state[5] = 0x9b05688c; - ctx->state[6] = 0x1f83d9ab; - ctx->state[7] = 0x5be0cd19; -} - -void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len) -{ - WORD i; - - for (i = 0; i < len; ++i) { - ctx->data[ctx->datalen] = data[i]; - ctx->datalen++; - if (ctx->datalen == 64) { - sha256_transform(ctx, ctx->data); - ctx->bitlen += 512; - ctx->datalen = 0; - } - } -} - -void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]) -{ - WORD i; - - i = ctx->datalen; - - // Pad whatever data is left in the buffer. - if (ctx->datalen < 56) { - ctx->data[i++] = 0x80; - while (i < 56) - ctx->data[i++] = 0x00; - } - else { - ctx->data[i++] = 0x80; - while (i < 64) - ctx->data[i++] = 0x00; - sha256_transform(ctx, ctx->data); - memset(ctx->data, 0, 56); - } - - // Append to the padding the total message's length in bits and transform. - ctx->bitlen += ctx->datalen * 8; - ctx->data[63] = ctx->bitlen; - ctx->data[62] = ctx->bitlen >> 8; - ctx->data[61] = ctx->bitlen >> 16; - ctx->data[60] = ctx->bitlen >> 24; - ctx->data[59] = ctx->bitlen >> 32; - ctx->data[58] = ctx->bitlen >> 40; - ctx->data[57] = ctx->bitlen >> 48; - ctx->data[56] = ctx->bitlen >> 56; - sha256_transform(ctx, ctx->data); - - // Since this implementation uses little endian byte ordering and SHA uses big endian, - // reverse all the bytes when copying the final state to the output hash. - for (i = 0; i < 4; ++i) { - hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff; - hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff; - hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff; - hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff; - hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff; - hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff; - hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff; - hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff; - } -} diff --git a/user/mpy/extmod/crypto-algorithms/sha256.h b/user/mpy/extmod/crypto-algorithms/sha256.h deleted file mode 100644 index caa1f81..0000000 --- a/user/mpy/extmod/crypto-algorithms/sha256.h +++ /dev/null @@ -1,34 +0,0 @@ -/********************************************************************* -* Filename: sha256.h -* Author: Brad Conte (brad AT bradconte.com) -* Copyright: -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: Defines the API for the corresponding SHA1 implementation. -*********************************************************************/ - -#ifndef SHA256_H -#define SHA256_H - -/*************************** HEADER FILES ***************************/ -#include - -/****************************** MACROS ******************************/ -#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest - -/**************************** DATA TYPES ****************************/ -typedef unsigned char BYTE; // 8-bit byte -typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines - -typedef struct { - BYTE data[64]; - WORD datalen; - unsigned long long bitlen; - WORD state[8]; -} CRYAL_SHA256_CTX; - -/*********************** FUNCTION DECLARATIONS **********************/ -void sha256_init(CRYAL_SHA256_CTX *ctx); -void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len); -void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]); - -#endif // SHA256_H diff --git a/user/mpy/extmod/lwip-include/arch/cc.h b/user/mpy/extmod/lwip-include/arch/cc.h deleted file mode 100644 index 400dc6e..0000000 --- a/user/mpy/extmod/lwip-include/arch/cc.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H -#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H - -#include - -// Generate lwip's internal types from stdint - -typedef uint8_t u8_t; -typedef int8_t s8_t; -typedef uint16_t u16_t; -typedef int16_t s16_t; -typedef uint32_t u32_t; -typedef int32_t s32_t; - -typedef u32_t mem_ptr_t; - -#define U16_F "hu" -#define S16_F "hd" -#define X16_F "hx" -#define U32_F "u" -#define S32_F "d" -#define X32_F "x" - -#define X8_F "02x" -#define SZT_F "u" - -#define BYTE_ORDER LITTLE_ENDIAN - -#define LWIP_CHKSUM_ALGORITHM 2 - -#include -#define LWIP_PLATFORM_DIAG(x) -#define LWIP_PLATFORM_ASSERT(x) { assert(1); } - -//#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) -#define PACK_STRUCT_FIELD(x) x -#define PACK_STRUCT_STRUCT __attribute__((packed)) -#define PACK_STRUCT_BEGIN -#define PACK_STRUCT_END - -#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H diff --git a/user/mpy/extmod/lwip-include/arch/perf.h b/user/mpy/extmod/lwip-include/arch/perf.h deleted file mode 100644 index d310fc3..0000000 --- a/user/mpy/extmod/lwip-include/arch/perf.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H -#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H - -#define PERF_START /* null definition */ -#define PERF_STOP(x) /* null definition */ - -#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H diff --git a/user/mpy/extmod/lwip-include/lwipopts.h b/user/mpy/extmod/lwip-include/lwipopts.h deleted file mode 100644 index 2122f30..0000000 --- a/user/mpy/extmod/lwip-include/lwipopts.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H -#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H - -#include -#include -#include - -// We're running without an OS for this port. We don't provide any services except light protection. -#define NO_SYS 1 - -#define SYS_LIGHTWEIGHT_PROT 1 -#include -typedef uint32_t sys_prot_t; - -#define TCP_LISTEN_BACKLOG 1 - -// We'll put these into a proper ifdef once somebody implements an ethernet driver -#define LWIP_ARP 0 -#define LWIP_ETHERNET 0 - -#define LWIP_DNS 1 - -#define LWIP_NETCONN 0 -#define LWIP_SOCKET 0 - -#ifdef MICROPY_PY_LWIP_SLIP -#define LWIP_HAVE_SLIPIF 1 -#endif - -// For now, we can simply define this as a macro for the timer code. But this function isn't -// universal and other ports will need to do something else. It may be necessary to move -// things like this into a port-provided header file. -#define sys_now mp_hal_ticks_ms - -#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H diff --git a/user/mpy/extmod/machine_i2c.c b/user/mpy/extmod/machine_i2c.c deleted file mode 100644 index c0a51a6..0000000 --- a/user/mpy/extmod/machine_i2c.c +++ /dev/null @@ -1,640 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include -#include - -#include "py/mperrno.h" -#include "py/mphal.h" -#include "py/runtime.h" -#include "extmod/machine_i2c.h" - -#if MICROPY_PY_MACHINE_I2C - -typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t; - -STATIC void mp_hal_i2c_delay(machine_i2c_obj_t *self) { - // We need to use an accurate delay to get acceptable I2C - // speeds (eg 1us should be not much more than 1us). - mp_hal_delay_us_fast(self->us_delay); -} - -STATIC void mp_hal_i2c_scl_low(machine_i2c_obj_t *self) { - mp_hal_pin_od_low(self->scl); -} - -STATIC int mp_hal_i2c_scl_release(machine_i2c_obj_t *self) { - uint32_t count = self->us_timeout; - - mp_hal_pin_od_high(self->scl); - mp_hal_i2c_delay(self); - // For clock stretching, wait for the SCL pin to be released, with timeout. - for (; mp_hal_pin_read(self->scl) == 0 && count; --count) { - mp_hal_delay_us_fast(1); - } - if (count == 0) { - return -MP_ETIMEDOUT; - } - return 0; // success -} - -STATIC void mp_hal_i2c_sda_low(machine_i2c_obj_t *self) { - mp_hal_pin_od_low(self->sda); -} - -STATIC void mp_hal_i2c_sda_release(machine_i2c_obj_t *self) { - mp_hal_pin_od_high(self->sda); -} - -STATIC int mp_hal_i2c_sda_read(machine_i2c_obj_t *self) { - return mp_hal_pin_read(self->sda); -} - -STATIC int mp_hal_i2c_start(machine_i2c_obj_t *self) { - mp_hal_i2c_sda_release(self); - mp_hal_i2c_delay(self); - int ret = mp_hal_i2c_scl_release(self); - if (ret != 0) { - return ret; - } - mp_hal_i2c_sda_low(self); - mp_hal_i2c_delay(self); - return 0; // success -} - -STATIC int mp_hal_i2c_stop(machine_i2c_obj_t *self) { - mp_hal_i2c_delay(self); - mp_hal_i2c_sda_low(self); - mp_hal_i2c_delay(self); - int ret = mp_hal_i2c_scl_release(self); - mp_hal_i2c_sda_release(self); - mp_hal_i2c_delay(self); - return ret; -} - -STATIC void mp_hal_i2c_init(machine_i2c_obj_t *self, uint32_t freq) { - self->us_delay = 500000 / freq; - if (self->us_delay == 0) { - self->us_delay = 1; - } - mp_hal_pin_open_drain(self->scl); - mp_hal_pin_open_drain(self->sda); - mp_hal_i2c_stop(self); // ignore error -} - -// return value: -// 0 - byte written and ack received -// 1 - byte written and nack received -// <0 - error, with errno being the negative of the return value -STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) { - mp_hal_i2c_delay(self); - mp_hal_i2c_scl_low(self); - - for (int i = 7; i >= 0; i--) { - if ((val >> i) & 1) { - mp_hal_i2c_sda_release(self); - } else { - mp_hal_i2c_sda_low(self); - } - mp_hal_i2c_delay(self); - int ret = mp_hal_i2c_scl_release(self); - if (ret != 0) { - mp_hal_i2c_sda_release(self); - return ret; - } - mp_hal_i2c_scl_low(self); - } - - mp_hal_i2c_sda_release(self); - mp_hal_i2c_delay(self); - int ret = mp_hal_i2c_scl_release(self); - if (ret != 0) { - return ret; - } - - int ack = mp_hal_i2c_sda_read(self); - mp_hal_i2c_delay(self); - mp_hal_i2c_scl_low(self); - - return ack; -} - -// return value: -// 0 - success -// <0 - error, with errno being the negative of the return value -STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack) { - mp_hal_i2c_delay(self); - mp_hal_i2c_scl_low(self); - mp_hal_i2c_delay(self); - - uint8_t data = 0; - for (int i = 7; i >= 0; i--) { - int ret = mp_hal_i2c_scl_release(self); - if (ret != 0) { - return ret; - } - data = (data << 1) | mp_hal_i2c_sda_read(self); - mp_hal_i2c_scl_low(self); - mp_hal_i2c_delay(self); - } - *val = data; - - // send ack/nack bit - if (!nack) { - mp_hal_i2c_sda_low(self); - } - mp_hal_i2c_delay(self); - int ret = mp_hal_i2c_scl_release(self); - if (ret != 0) { - mp_hal_i2c_sda_release(self); - return ret; - } - mp_hal_i2c_scl_low(self); - mp_hal_i2c_sda_release(self); - - return 0; // success -} - -// return value: -// >=0 - number of acks received -// <0 - error, with errno being the negative of the return value -int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop) { - machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; - - // start the I2C transaction - int ret = mp_hal_i2c_start(self); - if (ret != 0) { - return ret; - } - - // write the slave address - ret = mp_hal_i2c_write_byte(self, addr << 1); - if (ret < 0) { - return ret; - } else if (ret != 0) { - // nack received, release the bus cleanly - mp_hal_i2c_stop(self); - return -MP_ENODEV; - } - - // write the buffer to the I2C memory - int num_acks = 0; - while (len--) { - ret = mp_hal_i2c_write_byte(self, *src++); - if (ret < 0) { - return ret; - } else if (ret != 0) { - // nack received, stop sending - break; - } - ++num_acks; - } - - // finish the I2C transaction - if (stop) { - ret = mp_hal_i2c_stop(self); - if (ret != 0) { - return ret; - } - } - - return num_acks; -} - -// return value: -// 0 - success -// <0 - error, with errno being the negative of the return value -int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) { - machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; - - // start the I2C transaction - int ret = mp_hal_i2c_start(self); - if (ret != 0) { - return ret; - } - - // write the slave address - ret = mp_hal_i2c_write_byte(self, (addr << 1) | 1); - if (ret < 0) { - return ret; - } else if (ret != 0) { - // nack received, release the bus cleanly - mp_hal_i2c_stop(self); - return -MP_ENODEV; - } - - // read the bytes from the slave - while (len--) { - ret = mp_hal_i2c_read_byte(self, dest++, len == 0); - if (ret != 0) { - return ret; - } - } - - // finish the I2C transaction - if (stop) { - ret = mp_hal_i2c_stop(self); - if (ret != 0) { - return ret; - } - } - - return 0; // success -} - -/******************************************************************************/ -// MicroPython bindings for I2C - -STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_scl, ARG_sda, ARG_freq, ARG_timeout }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_sda, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_freq, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 400000} }, - { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 255} }, - }; - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - self->scl = mp_hal_get_pin_obj(args[ARG_scl].u_obj); - self->sda = mp_hal_get_pin_obj(args[ARG_sda].u_obj); - self->us_timeout = args[ARG_timeout].u_int; - mp_hal_i2c_init(self, args[ARG_freq].u_int); -} - -STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - // check the id argument, if given - if (n_args > 0) { - if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) { - #if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW) - // dispatch to port-specific constructor - extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); - return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args); - #else - mp_raise_ValueError("invalid I2C peripheral"); - #endif - } - --n_args; - ++args; - } - - // create new soft I2C object - machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t); - self->base.type = &machine_i2c_type; - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); - machine_i2c_obj_init_helper(self, n_args, args, &kw_args); - return (mp_obj_t)self; -} - -STATIC mp_obj_t machine_i2c_obj_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - machine_i2c_obj_init_helper(args[0], n_args - 1, args + 1, kw_args); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init); - -STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) { - mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - mp_obj_t list = mp_obj_new_list(0, NULL); - // 7-bit addresses 0b0000xxx and 0b1111xxx are reserved - for (int addr = 0x08; addr < 0x78; ++addr) { - int ret = i2c_p->writeto(self, addr, NULL, 0, true); - if (ret == 0) { - mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr)); - } - } - return list; -} -MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan); - -STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - if (i2c_p->start == NULL) { - mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); - } - int ret = i2c_p->start(self); - if (ret != 0) { - mp_raise_OSError(-ret); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start); - -STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - if (i2c_p->stop == NULL) { - mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); - } - int ret = i2c_p->stop(self); - if (ret != 0) { - mp_raise_OSError(-ret); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop); - -STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - if (i2c_p->read == NULL) { - mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); - } - - // get the buffer to read into - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); - - // work out if we want to send a nack at the end - bool nack = (n_args == 2) ? true : mp_obj_is_true(args[2]); - - // do the read - int ret = i2c_p->read(self, bufinfo.buf, bufinfo.len, nack); - if (ret != 0) { - mp_raise_OSError(-ret); - } - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_readinto); - -STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - if (i2c_p->write == NULL) { - mp_raise_msg(&mp_type_OSError, "I2C operation not supported"); - } - - // get the buffer to write from - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); - - // do the write - int ret = i2c_p->write(self, bufinfo.buf, bufinfo.len); - if (ret < 0) { - mp_raise_OSError(-ret); - } - - // return number of acks received - return MP_OBJ_NEW_SMALL_INT(ret); -} -MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write); - -STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - mp_int_t addr = mp_obj_get_int(args[1]); - vstr_t vstr; - vstr_init_len(&vstr, mp_obj_get_int(args[2])); - bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]); - int ret = i2c_p->readfrom(self, addr, (uint8_t*)vstr.buf, vstr.len, stop); - if (ret < 0) { - mp_raise_OSError(-ret); - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_readfrom); - -STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - mp_int_t addr = mp_obj_get_int(args[1]); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE); - bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]); - int ret = i2c_p->readfrom(self, addr, bufinfo.buf, bufinfo.len, stop); - if (ret < 0) { - mp_raise_OSError(-ret); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine_i2c_readfrom_into); - -STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - mp_int_t addr = mp_obj_get_int(args[1]); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); - bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]); - int ret = i2c_p->writeto(self, addr, bufinfo.buf, bufinfo.len, stop); - if (ret < 0) { - mp_raise_OSError(-ret); - } - // return number of acks received - return MP_OBJ_NEW_SMALL_INT(ret); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machine_i2c_writeto); - -STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - uint8_t memaddr_buf[4]; - size_t memaddr_len = 0; - for (int16_t i = addrsize - 8; i >= 0; i -= 8) { - memaddr_buf[memaddr_len++] = memaddr >> i; - } - int ret = i2c_p->writeto(self, addr, memaddr_buf, memaddr_len, false); - if (ret != memaddr_len) { - // must generate STOP - i2c_p->writeto(self, addr, NULL, 0, true); - return ret; - } - return i2c_p->readfrom(self, addr, buf, len, true); -} - -#define MAX_MEMADDR_SIZE (4) -#define BUF_STACK_SIZE (12) - -STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) { - mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; - - // need some memory to create the buffer to send; try to use stack if possible - uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE]; - uint8_t *buf2; - size_t buf2_alloc = 0; - if (len <= BUF_STACK_SIZE) { - buf2 = buf2_stack; - } else { - buf2_alloc = MAX_MEMADDR_SIZE + len; - buf2 = m_new(uint8_t, buf2_alloc); - } - - // create the buffer to send - size_t memaddr_len = 0; - for (int16_t i = addrsize - 8; i >= 0; i -= 8) { - buf2[memaddr_len++] = memaddr >> i; - } - memcpy(buf2 + memaddr_len, buf, len); - - int ret = i2c_p->writeto(self, addr, buf2, memaddr_len + len, true); - if (buf2_alloc != 0) { - m_del(uint8_t, buf2, buf2_alloc); - } - return ret; -} - -STATIC const mp_arg_t machine_i2c_mem_allowed_args[] = { - { MP_QSTR_addr, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_memaddr, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_arg, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_addrsize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} }, -}; - -STATIC mp_obj_t machine_i2c_readfrom_mem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_addr, ARG_memaddr, ARG_n, ARG_addrsize }; - mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args); - - // create the buffer to store data into - vstr_t vstr; - vstr_init_len(&vstr, mp_obj_get_int(args[ARG_n].u_obj)); - - // do the transfer - int ret = read_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int, - args[ARG_addrsize].u_int, (uint8_t*)vstr.buf, vstr.len); - if (ret < 0) { - mp_raise_OSError(-ret); - } - - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_readfrom_mem_obj, 1, machine_i2c_readfrom_mem); - - -STATIC mp_obj_t machine_i2c_readfrom_mem_into(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_addr, ARG_memaddr, ARG_buf, ARG_addrsize }; - mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args); - - // get the buffer to store data into - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_WRITE); - - // do the transfer - int ret = read_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int, - args[ARG_addrsize].u_int, bufinfo.buf, bufinfo.len); - if (ret < 0) { - mp_raise_OSError(-ret); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_readfrom_mem_into_obj, 1, machine_i2c_readfrom_mem_into); - -STATIC mp_obj_t machine_i2c_writeto_mem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_addr, ARG_memaddr, ARG_buf, ARG_addrsize }; - mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args); - - // get the buffer to write the data from - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_READ); - - // do the transfer - int ret = write_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int, - args[ARG_addrsize].u_int, bufinfo.buf, bufinfo.len); - if (ret < 0) { - mp_raise_OSError(-ret); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_writeto_mem_obj, 1, machine_i2c_writeto_mem); - -STATIC const mp_rom_map_elem_t machine_i2c_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_i2c_init_obj) }, - { MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&machine_i2c_scan_obj) }, - - // primitive I2C operations - { MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&machine_i2c_start_obj) }, - { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&machine_i2c_stop_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&machine_i2c_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&machine_i2c_write_obj) }, - - // standard bus operations - { MP_ROM_QSTR(MP_QSTR_readfrom), MP_ROM_PTR(&machine_i2c_readfrom_obj) }, - { MP_ROM_QSTR(MP_QSTR_readfrom_into), MP_ROM_PTR(&machine_i2c_readfrom_into_obj) }, - { MP_ROM_QSTR(MP_QSTR_writeto), MP_ROM_PTR(&machine_i2c_writeto_obj) }, - - // memory operations - { MP_ROM_QSTR(MP_QSTR_readfrom_mem), MP_ROM_PTR(&machine_i2c_readfrom_mem_obj) }, - { MP_ROM_QSTR(MP_QSTR_readfrom_mem_into), MP_ROM_PTR(&machine_i2c_readfrom_mem_into_obj) }, - { MP_ROM_QSTR(MP_QSTR_writeto_mem), MP_ROM_PTR(&machine_i2c_writeto_mem_obj) }, -}; - -MP_DEFINE_CONST_DICT(mp_machine_soft_i2c_locals_dict, machine_i2c_locals_dict_table); - -int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size_t len, bool nack) { - machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; - while (len--) { - int ret = mp_hal_i2c_read_byte(self, dest++, nack && (len == 0)); - if (ret != 0) { - return ret; - } - } - return 0; // success -} - -int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t len) { - machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; - int num_acks = 0; - while (len--) { - int ret = mp_hal_i2c_write_byte(self, *src++); - if (ret < 0) { - return ret; - } else if (ret != 0) { - // nack received, stop sending - break; - } - ++num_acks; - } - return num_acks; -} - -STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = { - .start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start, - .stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop, - .read = mp_machine_soft_i2c_read, - .write = mp_machine_soft_i2c_write, - .readfrom = mp_machine_soft_i2c_readfrom, - .writeto = mp_machine_soft_i2c_writeto, -}; - -const mp_obj_type_t machine_i2c_type = { - { &mp_type_type }, - .name = MP_QSTR_I2C, - .make_new = machine_i2c_make_new, - .protocol = &mp_machine_soft_i2c_p, - .locals_dict = (mp_obj_dict_t*)&mp_machine_soft_i2c_locals_dict, -}; - -#endif // MICROPY_PY_MACHINE_I2C diff --git a/user/mpy/extmod/machine_i2c.h b/user/mpy/extmod/machine_i2c.h deleted file mode 100644 index f5af665..0000000 --- a/user/mpy/extmod/machine_i2c.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_EXTMOD_MACHINE_I2C_H -#define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H - -#include "py/obj.h" - -// I2C protocol -// the first 4 methods can be NULL, meaning operation is not supported -typedef struct _mp_machine_i2c_p_t { - int (*start)(mp_obj_base_t *obj); - int (*stop)(mp_obj_base_t *obj); - int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack); - int (*write)(mp_obj_base_t *obj, const uint8_t *src, size_t len); - int (*readfrom)(mp_obj_base_t *obj, uint16_t addr, uint8_t *dest, size_t len, bool stop); - int (*writeto)(mp_obj_base_t *obj, uint16_t addr, const uint8_t *src, size_t len, bool stop); -} mp_machine_i2c_p_t; - -typedef struct _mp_machine_soft_i2c_obj_t { - mp_obj_base_t base; - uint32_t us_delay; - uint32_t us_timeout; - mp_hal_pin_obj_t scl; - mp_hal_pin_obj_t sda; -} mp_machine_soft_i2c_obj_t; - -extern const mp_obj_type_t machine_i2c_type; -extern const mp_obj_dict_t mp_machine_soft_i2c_locals_dict; - -int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop); -int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop); - -#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H diff --git a/user/mpy/extmod/machine_mem.c b/user/mpy/extmod/machine_mem.c deleted file mode 100644 index af987cb..0000000 --- a/user/mpy/extmod/machine_mem.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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. - */ - -#include "extmod/machine_mem.h" -#include "py/nlr.h" - -#if MICROPY_PY_MACHINE - -// If you wish to override the functions for mapping the machine_mem read/write -// address, then add a #define for MICROPY_MACHINE_MEM_GET_READ_ADDR and/or -// MICROPY_MACHINE_MEM_GET_WRITE_ADDR in your mpconfigport.h. Since the -// prototypes are identical, it is allowable for both of the macros to evaluate -// the to same function. -// -// It is expected that the modmachine.c file for a given port will provide the -// implementations, if the default implementation isn't used. - -#if !defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) || !defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR) -STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) { - uintptr_t addr = mp_obj_int_get_truncated(addr_o); - if ((addr & (align - 1)) != 0) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "address %08x is not aligned to %d bytes", addr, align)); - } - return addr; -} -#if !defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) -#define MICROPY_MACHINE_MEM_GET_READ_ADDR machine_mem_get_addr -#endif -#if !defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR) -#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR machine_mem_get_addr -#endif -#endif - -STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); -} - -STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - // TODO support slice index to read/write multiple values at once - machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); - if (value == MP_OBJ_NULL) { - // delete - return MP_OBJ_NULL; // op not supported - } else if (value == MP_OBJ_SENTINEL) { - // load - uintptr_t addr = MICROPY_MACHINE_MEM_GET_READ_ADDR(index, self->elem_size); - uint32_t val; - switch (self->elem_size) { - case 1: val = (*(uint8_t*)addr); break; - case 2: val = (*(uint16_t*)addr); break; - default: val = (*(uint32_t*)addr); break; - } - return mp_obj_new_int(val); - } else { - // store - uintptr_t addr = MICROPY_MACHINE_MEM_GET_WRITE_ADDR(index, self->elem_size); - uint32_t val = mp_obj_get_int_truncated(value); - switch (self->elem_size) { - case 1: (*(uint8_t*)addr) = val; break; - case 2: (*(uint16_t*)addr) = val; break; - default: (*(uint32_t*)addr) = val; break; - } - return mp_const_none; - } -} - -const mp_obj_type_t machine_mem_type = { - { &mp_type_type }, - .name = MP_QSTR_mem, - .print = machine_mem_print, - .subscr = machine_mem_subscr, -}; - -const machine_mem_obj_t machine_mem8_obj = {{&machine_mem_type}, 1}; -const machine_mem_obj_t machine_mem16_obj = {{&machine_mem_type}, 2}; -const machine_mem_obj_t machine_mem32_obj = {{&machine_mem_type}, 4}; - -#endif // MICROPY_PY_MACHINE diff --git a/user/mpy/extmod/machine_mem.h b/user/mpy/extmod/machine_mem.h deleted file mode 100644 index a48a52c..0000000 --- a/user/mpy/extmod/machine_mem.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 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_EXTMOD_MACHINE_MEM_H -#define MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H - -#include "py/obj.h" - -typedef struct _machine_mem_obj_t { - mp_obj_base_t base; - unsigned elem_size; // in bytes -} machine_mem_obj_t; - -extern const mp_obj_type_t machine_mem_type; - -extern const machine_mem_obj_t machine_mem8_obj; -extern const machine_mem_obj_t machine_mem16_obj; -extern const machine_mem_obj_t machine_mem32_obj; - -#if defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) -uintptr_t MICROPY_MACHINE_MEM_GET_READ_ADDR(mp_obj_t addr_o, uint align); -#endif -#if defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR) -uintptr_t MICROPY_MACHINE_MEM_GET_WRITE_ADDR(mp_obj_t addr_o, uint align); -#endif - -#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H diff --git a/user/mpy/extmod/machine_pinbase.c b/user/mpy/extmod/machine_pinbase.c deleted file mode 100644 index 3c1f094..0000000 --- a/user/mpy/extmod/machine_pinbase.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_PY_MACHINE - -#include "py/obj.h" -#include "py/runtime.h" -#include "extmod/virtpin.h" - -// PinBase class - -// As this is abstract class, its instance is null. -// But there should be an instance, as the rest of instance code -// expects that there will be concrete object for inheritance. -typedef struct _mp_pinbase_t { - mp_obj_base_t base; -} mp_pinbase_t; - -STATIC const mp_obj_type_t pinbase_type; - -STATIC mp_pinbase_t pinbase_singleton = { - .base = { &pinbase_type }, -}; - -STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type; - (void)n_args; - (void)n_kw; - (void)args; - return MP_OBJ_FROM_PTR(&pinbase_singleton); -} - -mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) { - (void)errcode; - switch (request) { - case MP_PIN_READ: { - mp_obj_t dest[2]; - mp_load_method(obj, MP_QSTR_value, dest); - return mp_obj_get_int(mp_call_method_n_kw(0, 0, dest)); - } - case MP_PIN_WRITE: { - mp_obj_t dest[3]; - mp_load_method(obj, MP_QSTR_value, dest); - dest[2] = (arg == 0 ? mp_const_false : mp_const_true); - mp_call_method_n_kw(1, 0, dest); - return 0; - } - } - return -1; -} - -STATIC const mp_pin_p_t pinbase_pin_p = { - .ioctl = pinbase_ioctl, -}; - -const mp_obj_type_t machine_pinbase_type = { - { &mp_type_type }, - .name = MP_QSTR_PinBase, - .make_new = pinbase_make_new, - .protocol = &pinbase_pin_p, -}; - -#endif // MICROPY_PY_MACHINE diff --git a/user/mpy/extmod/machine_pinbase.h b/user/mpy/extmod/machine_pinbase.h deleted file mode 100644 index c96abbc..0000000 --- a/user/mpy/extmod/machine_pinbase.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H -#define MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H - -#include "py/obj.h" - -extern const mp_obj_type_t machine_pinbase_type; - -#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H diff --git a/user/mpy/extmod/machine_pulse.c b/user/mpy/extmod/machine_pulse.c deleted file mode 100644 index 5f83747..0000000 --- a/user/mpy/extmod/machine_pulse.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include "py/runtime.h" -#include "py/mperrno.h" -#include "extmod/machine_pulse.h" - -#if MICROPY_PY_MACHINE_PULSE - -mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) { - mp_uint_t start = mp_hal_ticks_us(); - while (mp_hal_pin_read(pin) != pulse_level) { - if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) { - return (mp_uint_t)-2; - } - } - start = mp_hal_ticks_us(); - while (mp_hal_pin_read(pin) == pulse_level) { - if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) { - return (mp_uint_t)-1; - } - } - return mp_hal_ticks_us() - start; -} - -STATIC mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *args) { - mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(args[0]); - int level = 0; - if (mp_obj_is_true(args[1])) { - level = 1; - } - mp_uint_t timeout_us = 1000000; - if (n_args > 2) { - timeout_us = mp_obj_get_int(args[2]); - } - mp_uint_t us = machine_time_pulse_us(pin, level, timeout_us); - // May return -1 or -2 in case of timeout - return mp_obj_new_int(us); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj, 2, 3, machine_time_pulse_us_); - -#endif diff --git a/user/mpy/extmod/machine_pulse.h b/user/mpy/extmod/machine_pulse.h deleted file mode 100644 index e303dca..0000000 --- a/user/mpy/extmod/machine_pulse.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_EXTMOD_MACHINE_PULSE_H -#define MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H - -#include "py/obj.h" -#include "py/mphal.h" - -mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us); - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj); - -#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H diff --git a/user/mpy/extmod/machine_signal.c b/user/mpy/extmod/machine_signal.c deleted file mode 100644 index 78d0c3f..0000000 --- a/user/mpy/extmod/machine_signal.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_PY_MACHINE - -#include - -#include "py/obj.h" -#include "py/runtime.h" -#include "extmod/virtpin.h" -#include "extmod/machine_signal.h" - -// Signal class - -typedef struct _machine_signal_t { - mp_obj_base_t base; - mp_obj_t pin; - bool invert; -} machine_signal_t; - -STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_t pin = args[0]; - bool invert = false; - - #if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW) - mp_pin_p_t *pin_p = NULL; - - if (MP_OBJ_IS_OBJ(pin)) { - mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - pin_p = (mp_pin_p_t*)pin_base->type->protocol; - } - - if (pin_p == NULL) { - // If first argument isn't a Pin-like object, we filter out "invert" - // from keyword arguments and pass them all to the exported Pin - // constructor to create one. - mp_obj_t pin_args[n_args + n_kw * 2]; - memcpy(pin_args, args, n_args * sizeof(mp_obj_t)); - const mp_obj_t *src = args + n_args; - mp_obj_t *dst = pin_args + n_args; - mp_obj_t *sig_value = NULL; - for (size_t cnt = n_kw; cnt; cnt--) { - if (*src == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) { - invert = mp_obj_is_true(src[1]); - n_kw--; - } else { - *dst++ = *src; - *dst++ = src[1]; - } - if (*src == MP_OBJ_NEW_QSTR(MP_QSTR_value)) { - // Value is pertained to Signal, so we should invert - // it for Pin if needed, and we should do it only when - // inversion status is guaranteedly known. - sig_value = dst - 1; - } - src += 2; - } - - if (invert && sig_value != NULL) { - *sig_value = mp_obj_is_true(*sig_value) ? MP_OBJ_NEW_SMALL_INT(0) : MP_OBJ_NEW_SMALL_INT(1); - } - - // Here we pass NULL as a type, hoping that mp_pin_make_new() - // will just ignore it as set a concrete type. If not, we'd need - // to expose port's "default" pin type too. - pin = MICROPY_PY_MACHINE_PIN_MAKE_NEW(NULL, n_args, n_kw, pin_args); - } - else - #endif - // Otherwise there should be 1 or 2 args - { - if (n_args == 1) { - if (n_kw == 0) { - } else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) { - invert = mp_obj_is_true(args[2]); - } else { - goto error; - } - } else { - error: - mp_raise_TypeError(NULL); - } - } - - machine_signal_t *o = m_new_obj(machine_signal_t); - o->base.type = type; - o->pin = pin; - o->invert = invert; - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { - (void)errcode; - machine_signal_t *self = MP_OBJ_TO_PTR(self_in); - - switch (request) { - case MP_PIN_READ: { - return mp_virtual_pin_read(self->pin) ^ self->invert; - } - case MP_PIN_WRITE: { - mp_virtual_pin_write(self->pin, arg ^ self->invert); - return 0; - } - } - return -1; -} - -// fast method for getting/setting signal value -STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); - if (n_args == 0) { - // get pin - return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in)); - } else { - // set pin - mp_virtual_pin_write(self_in, mp_obj_is_true(args[0])); - return mp_const_none; - } -} - -STATIC mp_obj_t signal_value(size_t n_args, const mp_obj_t *args) { - return signal_call(args[0], n_args - 1, 0, args + 1); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(signal_value_obj, 1, 2, signal_value); - -STATIC mp_obj_t signal_on(mp_obj_t self_in) { - mp_virtual_pin_write(self_in, 1); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_on_obj, signal_on); - -STATIC mp_obj_t signal_off(mp_obj_t self_in) { - mp_virtual_pin_write(self_in, 0); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_off_obj, signal_off); - -STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&signal_value_obj) }, - { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&signal_on_obj) }, - { MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&signal_off_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table); - -STATIC const mp_pin_p_t signal_pin_p = { - .ioctl = signal_ioctl, -}; - -const mp_obj_type_t machine_signal_type = { - { &mp_type_type }, - .name = MP_QSTR_Signal, - .make_new = signal_make_new, - .call = signal_call, - .protocol = &signal_pin_p, - .locals_dict = (void*)&signal_locals_dict, -}; - -#endif // MICROPY_PY_MACHINE diff --git a/user/mpy/extmod/machine_signal.h b/user/mpy/extmod/machine_signal.h deleted file mode 100644 index df1c3e2..0000000 --- a/user/mpy/extmod/machine_signal.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 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. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H -#define MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H - -#include "py/obj.h" - -extern const mp_obj_type_t machine_signal_type; - -#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H diff --git a/user/mpy/extmod/machine_spi.c b/user/mpy/extmod/machine_spi.c deleted file mode 100644 index a67d294..0000000 --- a/user/mpy/extmod/machine_spi.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include - -#include "py/runtime.h" -#include "extmod/machine_spi.h" - -#if MICROPY_PY_MACHINE_SPI - -// if a port didn't define MSB/LSB constants then provide them -#ifndef MICROPY_PY_MACHINE_SPI_MSB -#define MICROPY_PY_MACHINE_SPI_MSB (0) -#define MICROPY_PY_MACHINE_SPI_LSB (1) -#endif - -void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) { - mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in; - uint32_t delay_half = self->delay_half; - - // only MSB transfer is implemented - - // If a port defines MICROPY_PY_MACHINE_SPI_MIN_DELAY, and the configured - // delay_half is equal to this value, then the software SPI implementation - // will run as fast as possible, limited only by CPU speed and GPIO time. - #ifdef MICROPY_PY_MACHINE_SPI_MIN_DELAY - if (delay_half == MICROPY_PY_MACHINE_SPI_MIN_DELAY) { - for (size_t i = 0; i < len; ++i) { - uint8_t data_out = src[i]; - uint8_t data_in = 0; - for (int j = 0; j < 8; ++j, data_out <<= 1) { - mp_hal_pin_write(self->mosi, (data_out >> 7) & 1); - mp_hal_pin_write(self->sck, 1 - self->polarity); - data_in = (data_in << 1) | mp_hal_pin_read(self->miso); - mp_hal_pin_write(self->sck, self->polarity); - } - if (dest != NULL) { - dest[i] = data_in; - } - } - return; - } - #endif - - for (size_t i = 0; i < len; ++i) { - uint8_t data_out = src[i]; - uint8_t data_in = 0; - for (int j = 0; j < 8; ++j, data_out <<= 1) { - mp_hal_pin_write(self->mosi, (data_out >> 7) & 1); - if (self->phase == 0) { - mp_hal_delay_us_fast(delay_half); - mp_hal_pin_write(self->sck, 1 - self->polarity); - } else { - mp_hal_pin_write(self->sck, 1 - self->polarity); - mp_hal_delay_us_fast(delay_half); - } - data_in = (data_in << 1) | mp_hal_pin_read(self->miso); - if (self->phase == 0) { - mp_hal_delay_us_fast(delay_half); - mp_hal_pin_write(self->sck, self->polarity); - } else { - mp_hal_pin_write(self->sck, self->polarity); - mp_hal_delay_us_fast(delay_half); - } - } - if (dest != NULL) { - dest[i] = data_in; - } - } -} - -/******************************************************************************/ -// MicroPython bindings for generic machine.SPI - -STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); - -mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - // check the id argument, if given - if (n_args > 0) { - if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) { - #if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW) - // dispatch to port-specific constructor - extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); - return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args); - #else - mp_raise_ValueError("invalid SPI peripheral"); - #endif - } - --n_args; - ++args; - } - - // software SPI - return mp_machine_soft_spi_make_new(type, n_args, n_kw, args); -} - -STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; - spi_p->init(s, n_args - 1, args + 1, kw_args); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init); - -STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) { - mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); - mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; - if (spi_p->deinit != NULL) { - spi_p->deinit(s); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit); - -STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) { - mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); - mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; - spi_p->transfer(s, len, src, dest); -} - -STATIC mp_obj_t mp_machine_spi_read(size_t n_args, const mp_obj_t *args) { - vstr_t vstr; - vstr_init_len(&vstr, mp_obj_get_int(args[1])); - memset(vstr.buf, n_args == 3 ? mp_obj_get_int(args[2]) : 0, vstr.len); - mp_machine_spi_transfer(args[0], vstr.len, vstr.buf, vstr.buf); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj, 2, 3, mp_machine_spi_read); - -STATIC mp_obj_t mp_machine_spi_readinto(size_t n_args, const mp_obj_t *args) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); - memset(bufinfo.buf, n_args == 3 ? mp_obj_get_int(args[2]) : 0, bufinfo.len); - mp_machine_spi_transfer(args[0], bufinfo.len, bufinfo.buf, bufinfo.buf); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj, 2, 3, mp_machine_spi_readinto); - -STATIC mp_obj_t mp_machine_spi_write(mp_obj_t self, mp_obj_t wr_buf) { - mp_buffer_info_t src; - mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ); - mp_machine_spi_transfer(self, src.len, (const uint8_t*)src.buf, NULL); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj, mp_machine_spi_write); - -STATIC mp_obj_t mp_machine_spi_write_readinto(mp_obj_t self, mp_obj_t wr_buf, mp_obj_t rd_buf) { - mp_buffer_info_t src; - mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ); - mp_buffer_info_t dest; - mp_get_buffer_raise(rd_buf, &dest, MP_BUFFER_WRITE); - if (src.len != dest.len) { - mp_raise_ValueError("buffers must be the same length"); - } - mp_machine_spi_transfer(self, src.len, src.buf, dest.buf); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_3(mp_machine_spi_write_readinto_obj, mp_machine_spi_write_readinto); - -STATIC const mp_rom_map_elem_t machine_spi_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_spi_init_obj) }, - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_spi_deinit_obj) }, - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_machine_spi_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_machine_spi_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_machine_spi_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&mp_machine_spi_write_readinto_obj) }, - - { MP_ROM_QSTR(MP_QSTR_MSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_MSB) }, - { MP_ROM_QSTR(MP_QSTR_LSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_LSB) }, -}; - -MP_DEFINE_CONST_DICT(mp_machine_spi_locals_dict, machine_spi_locals_dict_table); - -/******************************************************************************/ -// Implementation of soft SPI - -STATIC uint32_t baudrate_from_delay_half(uint32_t delay_half) { - #ifdef MICROPY_PY_MACHINE_SPI_MIN_DELAY - if (delay_half == MICROPY_PY_MACHINE_SPI_MIN_DELAY) { - return MICROPY_PY_MACHINE_SPI_MAX_BAUDRATE; - } else - #endif - { - return 500000 / delay_half; - } -} - -STATIC uint32_t baudrate_to_delay_half(uint32_t baudrate) { - #ifdef MICROPY_PY_MACHINE_SPI_MIN_DELAY - if (baudrate >= MICROPY_PY_MACHINE_SPI_MAX_BAUDRATE) { - return MICROPY_PY_MACHINE_SPI_MIN_DELAY; - } else - #endif - { - uint32_t delay_half = 500000 / baudrate; - // round delay_half up so that: actual_baudrate <= requested_baudrate - if (500000 % baudrate != 0) { - delay_half += 1; - } - return delay_half; - } -} - -STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_machine_soft_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "SoftSPI(baudrate=%u, polarity=%u, phase=%u," - " sck=" MP_HAL_PIN_FMT ", mosi=" MP_HAL_PIN_FMT ", miso=" MP_HAL_PIN_FMT ")", - baudrate_from_delay_half(self->delay_half), self->polarity, self->phase, - mp_hal_pin_name(self->sck), mp_hal_pin_name(self->mosi), mp_hal_pin_name(self->miso)); -} - -STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} }, - { MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} }, - { MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = MICROPY_PY_MACHINE_SPI_MSB} }, - { MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - }; - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - // create new object - mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t); - self->base.type = &mp_machine_soft_spi_type; - - // set parameters - self->delay_half = baudrate_to_delay_half(args[ARG_baudrate].u_int); - self->polarity = args[ARG_polarity].u_int; - self->phase = args[ARG_phase].u_int; - if (args[ARG_bits].u_int != 8) { - mp_raise_ValueError("bits must be 8"); - } - if (args[ARG_firstbit].u_int != MICROPY_PY_MACHINE_SPI_MSB) { - mp_raise_ValueError("firstbit must be MSB"); - } - if (args[ARG_sck].u_obj == MP_OBJ_NULL - || args[ARG_mosi].u_obj == MP_OBJ_NULL - || args[ARG_miso].u_obj == MP_OBJ_NULL) { - mp_raise_ValueError("must specify all of sck/mosi/miso"); - } - self->sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj); - self->mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj); - self->miso = mp_hal_get_pin_obj(args[ARG_miso].u_obj); - - // configure pins - mp_hal_pin_write(self->sck, self->polarity); - mp_hal_pin_output(self->sck); - mp_hal_pin_output(self->mosi); - mp_hal_pin_input(self->miso); - - return MP_OBJ_FROM_PTR(self); -} - -STATIC void mp_machine_soft_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in; - - enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_sck, ARG_mosi, ARG_miso }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = -1} }, - { MP_QSTR_polarity, MP_ARG_INT, {.u_int = -1} }, - { MP_QSTR_phase, MP_ARG_INT, {.u_int = -1} }, - { MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - }; - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - if (args[ARG_baudrate].u_int != -1) { - self->delay_half = baudrate_to_delay_half(args[ARG_baudrate].u_int); - } - if (args[ARG_polarity].u_int != -1) { - self->polarity = args[ARG_polarity].u_int; - } - if (args[ARG_phase].u_int != -1) { - self->phase = args[ARG_phase].u_int; - } - if (args[ARG_sck].u_obj != MP_OBJ_NULL) { - self->sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj); - } - if (args[ARG_mosi].u_obj != MP_OBJ_NULL) { - self->mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj); - } - if (args[ARG_miso].u_obj != MP_OBJ_NULL) { - self->miso = mp_hal_get_pin_obj(args[ARG_miso].u_obj); - } - - // configure pins - mp_hal_pin_write(self->sck, self->polarity); - mp_hal_pin_output(self->sck); - mp_hal_pin_output(self->mosi); - mp_hal_pin_input(self->miso); -} - -STATIC const mp_machine_spi_p_t mp_machine_soft_spi_p = { - .init = mp_machine_soft_spi_init, - .deinit = NULL, - .transfer = mp_machine_soft_spi_transfer, -}; - -const mp_obj_type_t mp_machine_soft_spi_type = { - { &mp_type_type }, - .name = MP_QSTR_SoftSPI, - .print = mp_machine_soft_spi_print, - .make_new = mp_machine_spi_make_new, // delegate to master constructor - .protocol = &mp_machine_soft_spi_p, - .locals_dict = (mp_obj_dict_t*)&mp_machine_spi_locals_dict, -}; - -#endif // MICROPY_PY_MACHINE_SPI diff --git a/user/mpy/extmod/machine_spi.h b/user/mpy/extmod/machine_spi.h deleted file mode 100644 index e24e41e..0000000 --- a/user/mpy/extmod/machine_spi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_EXTMOD_MACHINE_SPI_H -#define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H - -#include "py/obj.h" -#include "py/mphal.h" - -// SPI protocol -typedef struct _mp_machine_spi_p_t { - void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); - void (*deinit)(mp_obj_base_t *obj); // can be NULL - void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); -} mp_machine_spi_p_t; - -typedef struct _mp_machine_soft_spi_obj_t { - mp_obj_base_t base; - uint32_t delay_half; // microsecond delay for half SCK period - uint8_t polarity; - uint8_t phase; - mp_hal_pin_obj_t sck; - mp_hal_pin_obj_t mosi; - mp_hal_pin_obj_t miso; -} mp_machine_soft_spi_obj_t; - -extern const mp_obj_type_t mp_machine_soft_spi_type; -extern const mp_obj_dict_t mp_machine_spi_locals_dict; - -void mp_machine_soft_spi_transfer(mp_obj_base_t *self, size_t len, const uint8_t *src, uint8_t *dest); - -mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj); -MP_DECLARE_CONST_FUN_OBJ_3(mp_machine_spi_write_readinto_obj); - -#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H diff --git a/user/mpy/extmod/misc.h b/user/mpy/extmod/misc.h deleted file mode 100644 index 6c13592..0000000 --- a/user/mpy/extmod/misc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Damien P. George - * Copyright (c) 2016 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. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_MISC_H -#define MICROPY_INCLUDED_EXTMOD_MISC_H - -// This file contains cumulative declarations for extmod/ . - -#include -#include "py/runtime.h" - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj); - -#if MICROPY_PY_OS_DUPTERM -void mp_uos_dupterm_tx_strn(const char *str, size_t len); -void mp_uos_deactivate(const char *msg, mp_obj_t exc); -#else -#define mp_uos_dupterm_tx_strn(s, l) -#endif - -#endif // MICROPY_INCLUDED_EXTMOD_MISC_H diff --git a/user/mpy/extmod/modbtree.c b/user/mpy/extmod/modbtree.c deleted file mode 100644 index 229daaf..0000000 --- a/user/mpy/extmod/modbtree.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include -#include // for declaration of global errno variable -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/runtime0.h" -#include "py/stream.h" - -#if MICROPY_PY_BTREE - -#include -#include <../../btree/btree.h> - -typedef struct _mp_obj_btree_t { - mp_obj_base_t base; - DB *db; - mp_obj_t start_key; - mp_obj_t end_key; - #define FLAG_END_KEY_INCL 1 - #define FLAG_DESC 2 - #define FLAG_ITER_TYPE_MASK 0xc0 - #define FLAG_ITER_KEYS 0x40 - #define FLAG_ITER_VALUES 0x80 - #define FLAG_ITER_ITEMS 0xc0 - byte flags; - byte next_flags; -} mp_obj_btree_t; - -STATIC const mp_obj_type_t btree_type; - -#define CHECK_ERROR(res) \ - if (res == RET_ERROR) { \ - mp_raise_OSError(errno); \ - } - -void __dbpanic(DB *db) { - printf("__dbpanic(%p)\n", db); -} - -STATIC mp_obj_btree_t *btree_new(DB *db) { - mp_obj_btree_t *o = m_new_obj(mp_obj_btree_t); - o->base.type = &btree_type; - o->db = db; - o->start_key = mp_const_none; - o->end_key = mp_const_none; - o->next_flags = 0; - return o; -} - -STATIC void btree_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "", self->db); -} - -STATIC mp_obj_t btree_flush(mp_obj_t self_in) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_NEW_SMALL_INT(__bt_sync(self->db, 0)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(btree_flush_obj, btree_flush); - -STATIC mp_obj_t btree_close(mp_obj_t self_in) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_NEW_SMALL_INT(__bt_close(self->db)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(btree_close_obj, btree_close); - -STATIC mp_obj_t btree_put(size_t n_args, const mp_obj_t *args) { - (void)n_args; - mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); - DBT key, val; - key.data = (void*)mp_obj_str_get_data(args[1], &key.size); - val.data = (void*)mp_obj_str_get_data(args[2], &val.size); - return MP_OBJ_NEW_SMALL_INT(__bt_put(self->db, &key, &val, 0)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_put_obj, 3, 4, btree_put); - -STATIC mp_obj_t btree_get(size_t n_args, const mp_obj_t *args) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); - DBT key, val; - key.data = (void*)mp_obj_str_get_data(args[1], &key.size); - int res = __bt_get(self->db, &key, &val, 0); - if (res == RET_SPECIAL) { - if (n_args > 2) { - return args[2]; - } else { - return mp_const_none; - } - } - CHECK_ERROR(res); - return mp_obj_new_bytes(val.data, val.size); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_get_obj, 2, 3, btree_get); - -STATIC mp_obj_t btree_seq(size_t n_args, const mp_obj_t *args) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); - int flags = MP_OBJ_SMALL_INT_VALUE(args[1]); - DBT key, val; - if (n_args > 2) { - key.data = (void*)mp_obj_str_get_data(args[2], &key.size); - } - - int res = __bt_seq(self->db, &key, &val, flags); - CHECK_ERROR(res); - if (res == RET_SPECIAL) { - return mp_const_none; - } - - mp_obj_t pair_o = mp_obj_new_tuple(2, NULL); - mp_obj_tuple_t *pair = MP_OBJ_TO_PTR(pair_o); - pair->items[0] = mp_obj_new_bytes(key.data, key.size); - pair->items[1] = mp_obj_new_bytes(val.data, val.size); - return pair_o; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_seq_obj, 2, 4, btree_seq); - -STATIC mp_obj_t btree_init_iter(size_t n_args, const mp_obj_t *args, byte type) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(args[0]); - self->next_flags = type; - self->start_key = mp_const_none; - self->end_key = mp_const_none; - if (n_args > 1) { - self->start_key = args[1]; - if (n_args > 2) { - self->end_key = args[2]; - if (n_args > 3) { - self->next_flags = type | MP_OBJ_SMALL_INT_VALUE(args[3]); - } - } - } - return args[0]; -} - -STATIC mp_obj_t btree_keys(size_t n_args, const mp_obj_t *args) { - return btree_init_iter(n_args, args, FLAG_ITER_KEYS); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_keys_obj, 1, 4, btree_keys); - -STATIC mp_obj_t btree_values(size_t n_args, const mp_obj_t *args) { - return btree_init_iter(n_args, args, FLAG_ITER_VALUES); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_values_obj, 1, 4, btree_values); - -STATIC mp_obj_t btree_items(size_t n_args, const mp_obj_t *args) { - return btree_init_iter(n_args, args, FLAG_ITER_ITEMS); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_items_obj, 1, 4, btree_items); - -STATIC mp_obj_t btree_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { - (void)iter_buf; - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); - if (self->next_flags != 0) { - // If we're called immediately after keys(), values(), or items(), - // use their setup for iteration. - self->flags = self->next_flags; - self->next_flags = 0; - } else { - // Otherwise, iterate over all keys. - self->flags = FLAG_ITER_KEYS; - self->start_key = mp_const_none; - self->end_key = mp_const_none; - } - - return self_in; -} - -STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); - DBT key, val; - int res; - bool desc = self->flags & FLAG_DESC; - if (self->start_key != MP_OBJ_NULL) { - int flags = R_FIRST; - if (self->start_key != mp_const_none) { - key.data = (void*)mp_obj_str_get_data(self->start_key, &key.size); - flags = R_CURSOR; - } else if (desc) { - flags = R_LAST; - } - res = __bt_seq(self->db, &key, &val, flags); - self->start_key = MP_OBJ_NULL; - } else { - res = __bt_seq(self->db, &key, &val, desc ? R_PREV : R_NEXT); - } - - if (res == RET_SPECIAL) { - return MP_OBJ_STOP_ITERATION; - } - CHECK_ERROR(res); - - if (self->end_key != mp_const_none) { - DBT end_key; - end_key.data = (void*)mp_obj_str_get_data(self->end_key, &end_key.size); - BTREE *t = self->db->internal; - int cmp = t->bt_cmp(&key, &end_key); - if (desc) { - cmp = -cmp; - } - if (self->flags & FLAG_END_KEY_INCL) { - cmp--; - } - if (cmp >= 0) { - self->end_key = MP_OBJ_NULL; - return MP_OBJ_STOP_ITERATION; - } - } - - switch (self->flags & FLAG_ITER_TYPE_MASK) { - case FLAG_ITER_KEYS: - return mp_obj_new_bytes(key.data, key.size); - case FLAG_ITER_VALUES: - return mp_obj_new_bytes(val.data, val.size); - default: { - mp_obj_t pair_o = mp_obj_new_tuple(2, NULL); - mp_obj_tuple_t *pair = MP_OBJ_TO_PTR(pair_o); - pair->items[0] = mp_obj_new_bytes(key.data, key.size); - pair->items[1] = mp_obj_new_bytes(val.data, val.size); - return pair_o; - } - } -} - -STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); - if (value == MP_OBJ_NULL) { - // delete - DBT key; - key.data = (void*)mp_obj_str_get_data(index, &key.size); - int res = __bt_delete(self->db, &key, 0); - if (res == RET_SPECIAL) { - nlr_raise(mp_obj_new_exception(&mp_type_KeyError)); - } - CHECK_ERROR(res); - return mp_const_none; - } else if (value == MP_OBJ_SENTINEL) { - // load - DBT key, val; - key.data = (void*)mp_obj_str_get_data(index, &key.size); - int res = __bt_get(self->db, &key, &val, 0); - if (res == RET_SPECIAL) { - nlr_raise(mp_obj_new_exception(&mp_type_KeyError)); - } - CHECK_ERROR(res); - return mp_obj_new_bytes(val.data, val.size); - } else { - // store - DBT key, val; - key.data = (void*)mp_obj_str_get_data(index, &key.size); - val.data = (void*)mp_obj_str_get_data(value, &val.size); - int res = __bt_put(self->db, &key, &val, 0); - CHECK_ERROR(res); - return mp_const_none; - } -} - -STATIC mp_obj_t btree_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(lhs_in); - switch (op) { - case MP_BINARY_OP_IN: { - DBT key, val; - key.data = (void*)mp_obj_str_get_data(rhs_in, &key.size); - int res = __bt_get(self->db, &key, &val, 0); - CHECK_ERROR(res); - return mp_obj_new_bool(res != RET_SPECIAL); - } - default: - // op not supported - return MP_OBJ_NULL; - } -} - -STATIC const mp_rom_map_elem_t btree_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&btree_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&btree_flush_obj) }, - { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&btree_get_obj) }, - { MP_ROM_QSTR(MP_QSTR_put), MP_ROM_PTR(&btree_put_obj) }, - { MP_ROM_QSTR(MP_QSTR_seq), MP_ROM_PTR(&btree_seq_obj) }, - { MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&btree_keys_obj) }, - { MP_ROM_QSTR(MP_QSTR_values), MP_ROM_PTR(&btree_values_obj) }, - { MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&btree_items_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(btree_locals_dict, btree_locals_dict_table); - -STATIC const mp_obj_type_t btree_type = { - { &mp_type_type }, - // Save on qstr's, reuse same as for module - .name = MP_QSTR_btree, - .print = btree_print, - .getiter = btree_getiter, - .iternext = btree_iternext, - .binary_op = btree_binary_op, - .subscr = btree_subscr, - .locals_dict = (void*)&btree_locals_dict, -}; - -STATIC FILEVTABLE btree_stream_fvtable = { - mp_stream_posix_read, - mp_stream_posix_write, - mp_stream_posix_lseek, - mp_stream_posix_fsync -}; - -STATIC mp_obj_t mod_btree_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - static const mp_arg_t allowed_args[] = { - { MP_QSTR_flags, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_cachesize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_pagesize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_minkeypage, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - }; - - // Make sure we got a stream object - mp_get_stream_raise(pos_args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); - - struct { - mp_arg_val_t flags; - mp_arg_val_t cachesize; - mp_arg_val_t pagesize; - mp_arg_val_t minkeypage; - } args; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); - BTREEINFO openinfo = {0}; - openinfo.flags = args.flags.u_int; - openinfo.cachesize = args.cachesize.u_int; - openinfo.psize = args.pagesize.u_int; - openinfo.minkeypage = args.minkeypage.u_int; - - DB *db = __bt_open(pos_args[0], &btree_stream_fvtable, &openinfo, /*dflags*/0); - if (db == NULL) { - mp_raise_OSError(errno); - } - return MP_OBJ_FROM_PTR(btree_new(db)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_btree_open_obj, 1, mod_btree_open); - -STATIC const mp_rom_map_elem_t mp_module_btree_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_btree) }, - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mod_btree_open_obj) }, - { MP_ROM_QSTR(MP_QSTR_INCL), MP_ROM_INT(FLAG_END_KEY_INCL) }, - { MP_ROM_QSTR(MP_QSTR_DESC), MP_ROM_INT(FLAG_DESC) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_btree_globals, mp_module_btree_globals_table); - -const mp_obj_module_t mp_module_btree = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_btree_globals, -}; - -#endif // MICROPY_PY_BTREE diff --git a/user/mpy/extmod/modframebuf.c b/user/mpy/extmod/modframebuf.c deleted file mode 100644 index f4e8571..0000000 --- a/user/mpy/extmod/modframebuf.c +++ /dev/null @@ -1,596 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime.h" - -#if MICROPY_PY_FRAMEBUF - -#include "stmhal/font_petme128_8x8.h" - -typedef struct _mp_obj_framebuf_t { - mp_obj_base_t base; - mp_obj_t buf_obj; // need to store this to prevent GC from reclaiming buf - void *buf; - uint16_t width, height, stride; - uint8_t format; -} mp_obj_framebuf_t; - -typedef void (*setpixel_t)(const mp_obj_framebuf_t*, int, int, uint32_t); -typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int); -typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t); - -typedef struct _mp_framebuf_p_t { - setpixel_t setpixel; - getpixel_t getpixel; - fill_rect_t fill_rect; -} mp_framebuf_p_t; - -// constants for formats -#define FRAMEBUF_MVLSB (0) -#define FRAMEBUF_RGB565 (1) -#define FRAMEBUF_GS4_HMSB (2) -#define FRAMEBUF_MHLSB (3) -#define FRAMEBUF_MHMSB (4) - -// Functions for MHLSB and MHMSB - -STATIC void mono_horiz_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { - size_t index = (x + y * fb->stride) >> 3; - int offset = fb->format == FRAMEBUF_MHMSB ? x & 0x07 : 7 - (x & 0x07); - ((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((col != 0) << offset); -} - -STATIC uint32_t mono_horiz_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { - size_t index = (x + y * fb->stride) >> 3; - int offset = fb->format == FRAMEBUF_MHMSB ? x & 0x07 : 7 - (x & 0x07); - return (((uint8_t*)fb->buf)[index] >> (offset)) & 0x01; -} - -STATIC void mono_horiz_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { - int reverse = fb->format == FRAMEBUF_MHMSB; - int advance = fb->stride >> 3; - while (w--) { - uint8_t *b = &((uint8_t*)fb->buf)[(x >> 3) + y * advance]; - int offset = reverse ? x & 7 : 7 - (x & 7); - for (int hh = h; hh; --hh) { - *b = (*b & ~(0x01 << offset)) | ((col != 0) << offset); - b += advance; - } - ++x; - } -} - -// Functions for MVLSB format - -STATIC void mvlsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { - size_t index = (y >> 3) * fb->stride + x; - uint8_t offset = y & 0x07; - ((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((col != 0) << offset); -} - -STATIC uint32_t mvlsb_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { - return (((uint8_t*)fb->buf)[(y >> 3) * fb->stride + x] >> (y & 0x07)) & 0x01; -} - -STATIC void mvlsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { - while (h--) { - uint8_t *b = &((uint8_t*)fb->buf)[(y >> 3) * fb->stride + x]; - uint8_t offset = y & 0x07; - for (int ww = w; ww; --ww) { - *b = (*b & ~(0x01 << offset)) | ((col != 0) << offset); - ++b; - } - ++y; - } -} - -// Functions for RGB565 format - -STATIC void rgb565_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { - ((uint16_t*)fb->buf)[x + y * fb->stride] = col; -} - -STATIC uint32_t rgb565_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { - return ((uint16_t*)fb->buf)[x + y * fb->stride]; -} - -STATIC void rgb565_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { - uint16_t *b = &((uint16_t*)fb->buf)[x + y * fb->stride]; - while (h--) { - for (int ww = w; ww; --ww) { - *b++ = col; - } - b += fb->stride - w; - } -} - -// Functions for GS4_HMSB format - -STATIC void gs4_hmsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { - uint8_t *pixel = &((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1]; - - if (x % 2) { - *pixel = ((uint8_t)col & 0x0f) | (*pixel & 0xf0); - } else { - *pixel = ((uint8_t)col << 4) | (*pixel & 0x0f); - } -} - -STATIC uint32_t gs4_hmsb_getpixel(const mp_obj_framebuf_t *fb, int x, int y) { - if (x % 2) { - return ((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1] & 0x0f; - } - - return ((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1] >> 4; -} - -STATIC void gs4_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { - col &= 0x0f; - uint8_t *pixel_pair = &((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1]; - uint8_t col_shifted_left = col << 4; - uint8_t col_pixel_pair = col_shifted_left | col; - int pixel_count_till_next_line = (fb->stride - w) >> 1; - bool odd_x = (x % 2 == 1); - - while (h--) { - int ww = w; - - if (odd_x && ww > 0) { - *pixel_pair = (*pixel_pair & 0xf0) | col; - pixel_pair++; - ww--; - } - - memset(pixel_pair, col_pixel_pair, ww >> 1); - pixel_pair += ww >> 1; - - if (ww % 2) { - *pixel_pair = col_shifted_left | (*pixel_pair & 0x0f); - if (!odd_x) { - pixel_pair++; - } - } - - pixel_pair += pixel_count_till_next_line; - } -} - -STATIC mp_framebuf_p_t formats[] = { - [FRAMEBUF_MVLSB] = {mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect}, - [FRAMEBUF_RGB565] = {rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect}, - [FRAMEBUF_GS4_HMSB] = {gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect}, - [FRAMEBUF_MHLSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, - [FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, -}; - -static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { - formats[fb->format].setpixel(fb, x, y, col); -} - -static inline uint32_t getpixel(const mp_obj_framebuf_t *fb, int x, int y) { - return formats[fb->format].getpixel(fb, x, y); -} - -STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) { - if (h < 1 || w < 1 || x + w <= 0 || y + h <= 0 || y >= fb->height || x >= fb->width) { - // No operation needed. - return; - } - - // clip to the framebuffer - int xend = MIN(fb->width, x + w); - int yend = MIN(fb->height, y + h); - x = MAX(x, 0); - y = MAX(y, 0); - - formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col); -} - -STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 4, 5, false); - - mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t); - o->base.type = type; - o->buf_obj = args[0]; - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_WRITE); - o->buf = bufinfo.buf; - - o->width = mp_obj_get_int(args[1]); - o->height = mp_obj_get_int(args[2]); - o->format = mp_obj_get_int(args[3]); - if (n_args >= 5) { - o->stride = mp_obj_get_int(args[4]); - } else { - o->stride = o->width; - } - - switch (o->format) { - case FRAMEBUF_MVLSB: - case FRAMEBUF_RGB565: - break; - case FRAMEBUF_MHLSB: - case FRAMEBUF_MHMSB: - o->stride = (o->stride + 7) & ~7; - break; - case FRAMEBUF_GS4_HMSB: - o->stride = (o->stride + 1) & ~1; - break; - default: - mp_raise_ValueError("invalid format"); - } - - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - (void)flags; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); - bufinfo->buf = self->buf; - bufinfo->len = self->stride * self->height * (self->format == FRAMEBUF_RGB565 ? 2 : 1); - bufinfo->typecode = 'B'; // view framebuf as bytes - return 0; -} - -STATIC mp_obj_t framebuf_fill(mp_obj_t self_in, mp_obj_t col_in) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t col = mp_obj_get_int(col_in); - formats[self->format].fill_rect(self, 0, 0, self->width, self->height, col); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(framebuf_fill_obj, framebuf_fill); - -STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) { - (void)n_args; - - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t x = mp_obj_get_int(args[1]); - mp_int_t y = mp_obj_get_int(args[2]); - mp_int_t width = mp_obj_get_int(args[3]); - mp_int_t height = mp_obj_get_int(args[4]); - mp_int_t col = mp_obj_get_int(args[5]); - - fill_rect(self, x, y, width, height, col); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_fill_rect_obj, 6, 6, framebuf_fill_rect); - -STATIC mp_obj_t framebuf_pixel(size_t n_args, const mp_obj_t *args) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t x = mp_obj_get_int(args[1]); - mp_int_t y = mp_obj_get_int(args[2]); - if (0 <= x && x < self->width && 0 <= y && y < self->height) { - if (n_args == 3) { - // get - return MP_OBJ_NEW_SMALL_INT(getpixel(self, x, y)); - } else { - // set - setpixel(self, x, y, mp_obj_get_int(args[3])); - } - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_pixel_obj, 3, 4, framebuf_pixel); - -STATIC mp_obj_t framebuf_hline(size_t n_args, const mp_obj_t *args) { - (void)n_args; - - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t x = mp_obj_get_int(args[1]); - mp_int_t y = mp_obj_get_int(args[2]); - mp_int_t w = mp_obj_get_int(args[3]); - mp_int_t col = mp_obj_get_int(args[4]); - - fill_rect(self, x, y, w, 1, col); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_hline_obj, 5, 5, framebuf_hline); - -STATIC mp_obj_t framebuf_vline(size_t n_args, const mp_obj_t *args) { - (void)n_args; - - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t x = mp_obj_get_int(args[1]); - mp_int_t y = mp_obj_get_int(args[2]); - mp_int_t h = mp_obj_get_int(args[3]); - mp_int_t col = mp_obj_get_int(args[4]); - - fill_rect(self, x, y, 1, h, col); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_vline_obj, 5, 5, framebuf_vline); - -STATIC mp_obj_t framebuf_rect(size_t n_args, const mp_obj_t *args) { - (void)n_args; - - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t x = mp_obj_get_int(args[1]); - mp_int_t y = mp_obj_get_int(args[2]); - mp_int_t w = mp_obj_get_int(args[3]); - mp_int_t h = mp_obj_get_int(args[4]); - mp_int_t col = mp_obj_get_int(args[5]); - - fill_rect(self, x, y, w, 1, col); - fill_rect(self, x, y + h- 1, w, 1, col); - fill_rect(self, x, y, 1, h, col); - fill_rect(self, x + w- 1, y, 1, h, col); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_rect_obj, 6, 6, framebuf_rect); - -STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) { - (void)n_args; - - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t x1 = mp_obj_get_int(args[1]); - mp_int_t y1 = mp_obj_get_int(args[2]); - mp_int_t x2 = mp_obj_get_int(args[3]); - mp_int_t y2 = mp_obj_get_int(args[4]); - mp_int_t col = mp_obj_get_int(args[5]); - - mp_int_t dx = x2 - x1; - mp_int_t sx; - if (dx > 0) { - sx = 1; - } else { - dx = -dx; - sx = -1; - } - - mp_int_t dy = y2 - y1; - mp_int_t sy; - if (dy > 0) { - sy = 1; - } else { - dy = -dy; - sy = -1; - } - - bool steep; - if (dy > dx) { - mp_int_t temp; - temp = x1; x1 = y1; y1 = temp; - temp = dx; dx = dy; dy = temp; - temp = sx; sx = sy; sy = temp; - steep = true; - } else { - steep = false; - } - - mp_int_t e = 2 * dy - dx; - for (mp_int_t i = 0; i < dx; ++i) { - if (steep) { - if (0 <= y1 && y1 < self->width && 0 <= x1 && x1 < self->height) { - setpixel(self, y1, x1, col); - } - } else { - if (0 <= x1 && x1 < self->width && 0 <= y1 && y1 < self->height) { - setpixel(self, x1, y1, col); - } - } - while (e >= 0) { - y1 += sy; - e -= 2 * dx; - } - x1 += sx; - e += 2 * dy; - } - - if (0 <= x2 && x2 < self->width && 0 <= y2 && y2 < self->height) { - setpixel(self, x2, y2, col); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_line_obj, 6, 6, framebuf_line); - -STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_obj_framebuf_t *source = MP_OBJ_TO_PTR(args[1]); - mp_int_t x = mp_obj_get_int(args[2]); - mp_int_t y = mp_obj_get_int(args[3]); - mp_int_t key = -1; - if (n_args > 4) { - key = mp_obj_get_int(args[4]); - } - - if ( - (x >= self->width) || - (y >= self->height) || - (-x >= source->width) || - (-y >= source->height) - ) { - // Out of bounds, no-op. - return mp_const_none; - } - - // Clip. - int x0 = MAX(0, x); - int y0 = MAX(0, y); - int x1 = MAX(0, -x); - int y1 = MAX(0, -y); - int x0end = MIN(self->width, x + source->width); - int y0end = MIN(self->height, y + source->height); - - for (; y0 < y0end; ++y0) { - int cx1 = x1; - for (int cx0 = x0; cx0 < x0end; ++cx0) { - uint32_t col = getpixel(source, cx1, y1); - if (col != (uint32_t)key) { - setpixel(self, cx0, y0, col); - } - ++cx1; - } - ++y1; - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 5, framebuf_blit); - -STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t xstep = mp_obj_get_int(xstep_in); - mp_int_t ystep = mp_obj_get_int(ystep_in); - int sx, y, xend, yend, dx, dy; - if (xstep < 0) { - sx = 0; - xend = self->width + xstep; - dx = 1; - } else { - sx = self->width - 1; - xend = xstep - 1; - dx = -1; - } - if (ystep < 0) { - y = 0; - yend = self->height + ystep; - dy = 1; - } else { - y = self->height - 1; - yend = ystep - 1; - dy = -1; - } - for (; y != yend; y += dy) { - for (int x = sx; x != xend; x += dx) { - setpixel(self, x, y, getpixel(self, x - xstep, y - ystep)); - } - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(framebuf_scroll_obj, framebuf_scroll); - -STATIC mp_obj_t framebuf_text(size_t n_args, const mp_obj_t *args) { - // extract arguments - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - const char *str = mp_obj_str_get_str(args[1]); - mp_int_t x0 = mp_obj_get_int(args[2]); - mp_int_t y0 = mp_obj_get_int(args[3]); - mp_int_t col = 1; - if (n_args >= 5) { - col = mp_obj_get_int(args[4]); - } - - // loop over chars - for (; *str; ++str) { - // get char and make sure its in range of font - int chr = *(uint8_t*)str; - if (chr < 32 || chr > 127) { - chr = 127; - } - // get char data - const uint8_t *chr_data = &font_petme128_8x8[(chr - 32) * 8]; - // loop over char data - for (int j = 0; j < 8; j++, x0++) { - if (0 <= x0 && x0 < self->width) { // clip x - uint vline_data = chr_data[j]; // each byte is a column of 8 pixels, LSB at top - for (int y = y0; vline_data; vline_data >>= 1, y++) { // scan over vertical column - if (vline_data & 1) { // only draw if pixel set - if (0 <= y && y < self->height) { // clip y - setpixel(self, x0, y, col); - } - } - } - } - } - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_text_obj, 4, 5, framebuf_text); - -STATIC const mp_rom_map_elem_t framebuf_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&framebuf_fill_obj) }, - { MP_ROM_QSTR(MP_QSTR_fill_rect), MP_ROM_PTR(&framebuf_fill_rect_obj) }, - { MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&framebuf_pixel_obj) }, - { MP_ROM_QSTR(MP_QSTR_hline), MP_ROM_PTR(&framebuf_hline_obj) }, - { MP_ROM_QSTR(MP_QSTR_vline), MP_ROM_PTR(&framebuf_vline_obj) }, - { MP_ROM_QSTR(MP_QSTR_rect), MP_ROM_PTR(&framebuf_rect_obj) }, - { MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&framebuf_line_obj) }, - { MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&framebuf_blit_obj) }, - { MP_ROM_QSTR(MP_QSTR_scroll), MP_ROM_PTR(&framebuf_scroll_obj) }, - { MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&framebuf_text_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(framebuf_locals_dict, framebuf_locals_dict_table); - -STATIC const mp_obj_type_t mp_type_framebuf = { - { &mp_type_type }, - .name = MP_QSTR_FrameBuffer, - .make_new = framebuf_make_new, - .buffer_p = { .get_buffer = framebuf_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&framebuf_locals_dict, -}; - -// this factory function is provided for backwards compatibility with old FrameBuffer1 class -STATIC mp_obj_t legacy_framebuffer1(size_t n_args, const mp_obj_t *args) { - mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t); - o->base.type = &mp_type_framebuf; - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_WRITE); - o->buf = bufinfo.buf; - - o->width = mp_obj_get_int(args[1]); - o->height = mp_obj_get_int(args[2]); - o->format = FRAMEBUF_MVLSB; - if (n_args >= 4) { - o->stride = mp_obj_get_int(args[3]); - } else { - o->stride = o->width; - } - - return MP_OBJ_FROM_PTR(o); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(legacy_framebuffer1_obj, 3, 4, legacy_framebuffer1); - -STATIC const mp_rom_map_elem_t framebuf_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_framebuf) }, - { MP_ROM_QSTR(MP_QSTR_FrameBuffer), MP_ROM_PTR(&mp_type_framebuf) }, - { MP_ROM_QSTR(MP_QSTR_FrameBuffer1), MP_ROM_PTR(&legacy_framebuffer1_obj) }, - { MP_ROM_QSTR(MP_QSTR_MVLSB), MP_ROM_INT(FRAMEBUF_MVLSB) }, - { MP_ROM_QSTR(MP_QSTR_MONO_VLSB), MP_ROM_INT(FRAMEBUF_MVLSB) }, - { MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_INT(FRAMEBUF_RGB565) }, - { MP_ROM_QSTR(MP_QSTR_GS4_HMSB), MP_ROM_INT(FRAMEBUF_GS4_HMSB) }, - { MP_ROM_QSTR(MP_QSTR_MONO_HLSB), MP_ROM_INT(FRAMEBUF_MHLSB) }, - { MP_ROM_QSTR(MP_QSTR_MONO_HMSB), MP_ROM_INT(FRAMEBUF_MHMSB) }, -}; - -STATIC MP_DEFINE_CONST_DICT(framebuf_module_globals, framebuf_module_globals_table); - -const mp_obj_module_t mp_module_framebuf = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&framebuf_module_globals, -}; - -#endif // MICROPY_PY_FRAMEBUF diff --git a/user/mpy/extmod/modlwip.c b/user/mpy/extmod/modlwip.c deleted file mode 100644 index cc10523..0000000 --- a/user/mpy/extmod/modlwip.c +++ /dev/null @@ -1,1380 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Galen Hazelwood - * Copyright (c) 2015-2017 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objlist.h" -#include "py/runtime.h" -#include "py/stream.h" -#include "py/mperrno.h" -#include "py/mphal.h" - -#include "lib/netutils/netutils.h" - -#include "lwip/init.h" -#include "lwip/timers.h" -#include "lwip/tcp.h" -#include "lwip/udp.h" -//#include "lwip/raw.h" -#include "lwip/dns.h" -#include "lwip/tcp_impl.h" -#include "lwip/igmp.h" - -#if 0 // print debugging info -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -// All socket options should be globally distinct, -// because we ignore option levels for efficiency. -#define IP_ADD_MEMBERSHIP 0x400 - -// For compatibilily with older lwIP versions. -#ifndef ip_set_option -#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) -#endif -#ifndef ip_reset_option -#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt)) -#endif - -#ifdef MICROPY_PY_LWIP_SLIP -#include "netif/slipif.h" -#include "lwip/sio.h" -#endif - -#ifdef MICROPY_PY_LWIP_SLIP -/******************************************************************************/ -// Slip object for modlwip. Requires a serial driver for the port that supports -// the lwip serial callback functions. - -typedef struct _lwip_slip_obj_t { - mp_obj_base_t base; - struct netif lwip_netif; -} lwip_slip_obj_t; - -// Slip object is unique for now. Possibly can fix this later. FIXME -STATIC lwip_slip_obj_t lwip_slip_obj; - -// Declare these early. -void mod_lwip_register_poll(void (*poll)(void *arg), void *poll_arg); -void mod_lwip_deregister_poll(void (*poll)(void *arg), void *poll_arg); - -STATIC void slip_lwip_poll(void *netif) { - slipif_poll((struct netif*)netif); -} - -STATIC const mp_obj_type_t lwip_slip_type; - -// lwIP SLIP callback functions -sio_fd_t sio_open(u8_t dvnum) { - // We support singleton SLIP interface, so just return any truish value. - return (sio_fd_t)1; -} - -void sio_send(u8_t c, sio_fd_t fd) { - mp_obj_type_t *type = mp_obj_get_type(MP_STATE_VM(lwip_slip_stream)); - int error; - type->stream_p->write(MP_STATE_VM(lwip_slip_stream), &c, 1, &error); -} - -u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len) { - mp_obj_type_t *type = mp_obj_get_type(MP_STATE_VM(lwip_slip_stream)); - int error; - mp_uint_t out_sz = type->stream_p->read(MP_STATE_VM(lwip_slip_stream), data, len, &error); - if (out_sz == MP_STREAM_ERROR) { - if (mp_is_nonblocking_error(error)) { - return 0; - } - // Can't do much else, can we? - return 0; - } - return out_sz; -} - -// constructor lwip.slip(device=integer, iplocal=string, ipremote=string) -STATIC mp_obj_t lwip_slip_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 3, 3, false); - - lwip_slip_obj.base.type = &lwip_slip_type; - - MP_STATE_VM(lwip_slip_stream) = args[0]; - - ip_addr_t iplocal, ipremote; - if (!ipaddr_aton(mp_obj_str_get_str(args[1]), &iplocal)) { - mp_raise_ValueError("not a valid local IP"); - } - if (!ipaddr_aton(mp_obj_str_get_str(args[2]), &ipremote)) { - mp_raise_ValueError("not a valid remote IP"); - } - - struct netif *n = &lwip_slip_obj.lwip_netif; - if (netif_add(n, &iplocal, IP_ADDR_BROADCAST, &ipremote, NULL, slipif_init, ip_input) == NULL) { - mp_raise_ValueError("out of memory"); - } - netif_set_up(n); - netif_set_default(n); - mod_lwip_register_poll(slip_lwip_poll, n); - - return (mp_obj_t)&lwip_slip_obj; -} - -STATIC mp_obj_t lwip_slip_status(mp_obj_t self_in) { - // Null function for now. - return mp_const_none; -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_1(lwip_slip_status_obj, lwip_slip_status); - -STATIC const mp_rom_map_elem_t lwip_slip_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_status), MP_ROM_PTR(&lwip_slip_status_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(lwip_slip_locals_dict, lwip_slip_locals_dict_table); - -STATIC const mp_obj_type_t lwip_slip_type = { - { &mp_type_type }, - .name = MP_QSTR_slip, - .make_new = lwip_slip_make_new, - .locals_dict = (mp_obj_dict_t*)&lwip_slip_locals_dict, -}; - -#endif // MICROPY_PY_LWIP_SLIP - -/******************************************************************************/ -// Table to convert lwIP err_t codes to socket errno codes, from the lwIP -// socket API. - -// Extension to lwIP error codes -#define _ERR_BADF -16 -// TODO: We just know that change happened somewhere between 1.4.0 and 1.4.1, -// investigate in more detail. -#if LWIP_VERSION < 0x01040100 -static const int error_lookup_table[] = { - 0, /* ERR_OK 0 No error, everything OK. */ - MP_ENOMEM, /* ERR_MEM -1 Out of memory error. */ - MP_ENOBUFS, /* ERR_BUF -2 Buffer error. */ - MP_EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */ - MP_EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ - MP_EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ - MP_EINVAL, /* ERR_VAL -6 Illegal value. */ - MP_EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ - - MP_ECONNABORTED, /* ERR_ABRT -8 Connection aborted. */ - MP_ECONNRESET, /* ERR_RST -9 Connection reset. */ - MP_ENOTCONN, /* ERR_CLSD -10 Connection closed. */ - MP_ENOTCONN, /* ERR_CONN -11 Not connected. */ - MP_EIO, /* ERR_ARG -12 Illegal argument. */ - MP_EADDRINUSE, /* ERR_USE -13 Address in use. */ - -1, /* ERR_IF -14 Low-level netif error */ - MP_EALREADY, /* ERR_ISCONN -15 Already connected. */ - MP_EBADF, /* _ERR_BADF -16 Closed socket (null pcb) */ -}; -#else -static const int error_lookup_table[] = { - 0, /* ERR_OK 0 No error, everything OK. */ - MP_ENOMEM, /* ERR_MEM -1 Out of memory error. */ - MP_ENOBUFS, /* ERR_BUF -2 Buffer error. */ - MP_EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */ - MP_EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ - MP_EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ - MP_EINVAL, /* ERR_VAL -6 Illegal value. */ - MP_EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ - - MP_EADDRINUSE, /* ERR_USE -8 Address in use. */ - MP_EALREADY, /* ERR_ISCONN -9 Already connected. */ - MP_ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */ - MP_ECONNRESET, /* ERR_RST -11 Connection reset. */ - MP_ENOTCONN, /* ERR_CLSD -12 Connection closed. */ - MP_ENOTCONN, /* ERR_CONN -13 Not connected. */ - MP_EIO, /* ERR_ARG -14 Illegal argument. */ - -1, /* ERR_IF -15 Low-level netif error */ - MP_EBADF, /* _ERR_BADF -16 Closed socket (null pcb) */ -}; -#endif - -/*******************************************************************************/ -// The socket object provided by lwip.socket. - -#define MOD_NETWORK_AF_INET (2) -#define MOD_NETWORK_AF_INET6 (10) - -#define MOD_NETWORK_SOCK_STREAM (1) -#define MOD_NETWORK_SOCK_DGRAM (2) -#define MOD_NETWORK_SOCK_RAW (3) - -typedef struct _lwip_socket_obj_t { - mp_obj_base_t base; - - volatile union { - struct tcp_pcb *tcp; - struct udp_pcb *udp; - } pcb; - volatile union { - struct pbuf *pbuf; - struct tcp_pcb *connection; - } incoming; - mp_obj_t callback; - byte peer[4]; - mp_uint_t peer_port; - mp_uint_t timeout; - uint16_t recv_offset; - - uint8_t domain; - uint8_t type; - - #define STATE_NEW 0 - #define STATE_CONNECTING 1 - #define STATE_CONNECTED 2 - #define STATE_PEER_CLOSED 3 - // Negative value is lwIP error - int8_t state; -} lwip_socket_obj_t; - -static inline void poll_sockets(void) { -#ifdef MICROPY_EVENT_POLL_HOOK - MICROPY_EVENT_POLL_HOOK; -#else - mp_hal_delay_ms(1); -#endif -} - -/*******************************************************************************/ -// Callback functions for the lwIP raw API. - -static inline void exec_user_callback(lwip_socket_obj_t *socket) { - if (socket->callback != MP_OBJ_NULL) { - mp_call_function_1_protected(socket->callback, socket); - } -} - -// Callback for incoming UDP packets. We simply stash the packet and the source address, -// in case we need it for recvfrom. -STATIC void _lwip_udp_incoming(void *arg, struct udp_pcb *upcb, struct pbuf *p, ip_addr_t *addr, u16_t port) { - lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; - - if (socket->incoming.pbuf != NULL) { - // That's why they call it "unreliable". No room in the inn, drop the packet. - pbuf_free(p); - } else { - socket->incoming.pbuf = p; - socket->peer_port = (mp_uint_t)port; - memcpy(&socket->peer, addr, sizeof(socket->peer)); - } -} - -// Callback for general tcp errors. -STATIC void _lwip_tcp_error(void *arg, err_t err) { - lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; - - // Pass the error code back via the connection variable. - socket->state = err; - // If we got here, the lwIP stack either has deallocated or will deallocate the pcb. - socket->pcb.tcp = NULL; -} - -// Callback for tcp connection requests. Error code err is unused. (See tcp.h) -STATIC err_t _lwip_tcp_connected(void *arg, struct tcp_pcb *tpcb, err_t err) { - lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; - - socket->state = STATE_CONNECTED; - return ERR_OK; -} - -// By default, a child socket of listen socket is created with recv -// handler which discards incoming pbuf's. We don't want to do that, -// so set this handler which requests lwIP to keep pbuf's and deliver -// them later. We cannot cache pbufs in child socket on Python side, -// until it is created in accept(). -STATIC err_t _lwip_tcp_recv_unaccepted(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { - return ERR_BUF; -} - -// "Poll" (idle) callback to be called ASAP after accept callback -// to execute Python callback function, as it can't be executed -// from accept callback itself. -STATIC err_t _lwip_tcp_accept_finished(void *arg, struct tcp_pcb *pcb) -{ - lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; - tcp_poll(pcb, NULL, 0); - exec_user_callback(socket); - return ERR_OK; -} - -// Callback for incoming tcp connections. -STATIC err_t _lwip_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err) { - lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; - tcp_recv(newpcb, _lwip_tcp_recv_unaccepted); - - if (socket->incoming.connection != NULL) { - DEBUG_printf("_lwip_tcp_accept: Tried to queue >1 pcb waiting for accept\n"); - // We need to handle this better. This single-level structure makes the - // backlog setting kind of pointless. FIXME - return ERR_BUF; - } else { - socket->incoming.connection = newpcb; - if (socket->callback != MP_OBJ_NULL) { - // Schedule accept callback to be called when lwIP is done - // with processing this incoming connection on its side and - // is idle. - tcp_poll(newpcb, _lwip_tcp_accept_finished, 1); - } - return ERR_OK; - } -} - -// Callback for inbound tcp packets. -STATIC err_t _lwip_tcp_recv(void *arg, struct tcp_pcb *tcpb, struct pbuf *p, err_t err) { - lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg; - - if (p == NULL) { - // Other side has closed connection. - DEBUG_printf("_lwip_tcp_recv[%p]: other side closed connection\n", socket); - socket->state = STATE_PEER_CLOSED; - exec_user_callback(socket); - return ERR_OK; - } - - if (socket->incoming.pbuf == NULL) { - socket->incoming.pbuf = p; - } else { - #ifdef SOCKET_SINGLE_PBUF - return ERR_BUF; - #else - pbuf_cat(socket->incoming.pbuf, p); - #endif - } - - exec_user_callback(socket); - - return ERR_OK; -} - -/*******************************************************************************/ -// Functions for socket send/receive operations. Socket send/recv and friends call -// these to do the work. - -// Helper function for send/sendto to handle UDP packets. -STATIC mp_uint_t lwip_udp_send(lwip_socket_obj_t *socket, const byte *buf, mp_uint_t len, byte *ip, mp_uint_t port, int *_errno) { - if (len > 0xffff) { - // Any packet that big is probably going to fail the pbuf_alloc anyway, but may as well try - len = 0xffff; - } - - // FIXME: maybe PBUF_ROM? - struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM); - if (p == NULL) { - *_errno = MP_ENOMEM; - return -1; - } - - memcpy(p->payload, buf, len); - - err_t err; - if (ip == NULL) { - err = udp_send(socket->pcb.udp, p); - } else { - ip_addr_t dest; - IP4_ADDR(&dest, ip[0], ip[1], ip[2], ip[3]); - err = udp_sendto(socket->pcb.udp, p, &dest, port); - } - - pbuf_free(p); - - // udp_sendto can return 1 on occasion for ESP8266 port. It's not known why - // but it seems that the send actually goes through without error in this case. - // So we treat such cases as a success until further investigation. - if (err != ERR_OK && err != 1) { - *_errno = error_lookup_table[-err]; - return -1; - } - - return len; -} - -// Helper function for recv/recvfrom to handle UDP packets -STATIC mp_uint_t lwip_udp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_t len, byte *ip, mp_uint_t *port, int *_errno) { - - if (socket->incoming.pbuf == NULL) { - if (socket->timeout != -1) { - for (mp_uint_t retries = socket->timeout / 100; retries--;) { - mp_hal_delay_ms(100); - if (socket->incoming.pbuf != NULL) break; - } - if (socket->incoming.pbuf == NULL) { - *_errno = MP_ETIMEDOUT; - return -1; - } - } else { - while (socket->incoming.pbuf == NULL) { - poll_sockets(); - } - } - } - - if (ip != NULL) { - memcpy(ip, &socket->peer, sizeof(socket->peer)); - *port = socket->peer_port; - } - - struct pbuf *p = socket->incoming.pbuf; - - u16_t result = pbuf_copy_partial(p, buf, ((p->tot_len > len) ? len : p->tot_len), 0); - pbuf_free(p); - socket->incoming.pbuf = NULL; - - return (mp_uint_t) result; -} - -// For use in stream virtual methods -#define STREAM_ERROR_CHECK(socket) \ - if (socket->state < 0) { \ - *_errno = error_lookup_table[-socket->state]; \ - return MP_STREAM_ERROR; \ - } \ - assert(socket->pcb.tcp); - - -// Helper function for send/sendto to handle TCP packets -STATIC mp_uint_t lwip_tcp_send(lwip_socket_obj_t *socket, const byte *buf, mp_uint_t len, int *_errno) { - // Check for any pending errors - STREAM_ERROR_CHECK(socket); - - u16_t available = tcp_sndbuf(socket->pcb.tcp); - - if (available == 0) { - // Non-blocking socket - if (socket->timeout == 0) { - *_errno = MP_EAGAIN; - return MP_STREAM_ERROR; - } - - mp_uint_t start = mp_hal_ticks_ms(); - // Assume that STATE_PEER_CLOSED may mean half-closed connection, where peer closed it - // sending direction, but not receiving. Consequently, check for both STATE_CONNECTED - // and STATE_PEER_CLOSED as normal conditions and still waiting for buffers to be sent. - // If peer fully closed socket, we would have socket->state set to ERR_RST (connection - // reset) by error callback. - // Avoid sending too small packets, so wait until at least 16 bytes available - while (socket->state >= STATE_CONNECTED && (available = tcp_sndbuf(socket->pcb.tcp)) < 16) { - if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) { - *_errno = MP_ETIMEDOUT; - return MP_STREAM_ERROR; - } - poll_sockets(); - } - - // While we waited, something could happen - STREAM_ERROR_CHECK(socket); - } - - u16_t write_len = MIN(available, len); - - err_t err = tcp_write(socket->pcb.tcp, buf, write_len, TCP_WRITE_FLAG_COPY); - - if (err != ERR_OK) { - *_errno = error_lookup_table[-err]; - return MP_STREAM_ERROR; - } - - return write_len; -} - -// Helper function for recv/recvfrom to handle TCP packets -STATIC mp_uint_t lwip_tcp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_t len, int *_errno) { - // Check for any pending errors - STREAM_ERROR_CHECK(socket); - - if (socket->incoming.pbuf == NULL) { - - // Non-blocking socket - if (socket->timeout == 0) { - if (socket->state == STATE_PEER_CLOSED) { - return 0; - } - *_errno = MP_EAGAIN; - return -1; - } - - mp_uint_t start = mp_hal_ticks_ms(); - while (socket->state == STATE_CONNECTED && socket->incoming.pbuf == NULL) { - if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) { - *_errno = MP_ETIMEDOUT; - return -1; - } - poll_sockets(); - } - - if (socket->state == STATE_PEER_CLOSED) { - if (socket->incoming.pbuf == NULL) { - // socket closed and no data left in buffer - return 0; - } - } else if (socket->state != STATE_CONNECTED) { - assert(socket->state < 0); - *_errno = error_lookup_table[-socket->state]; - return -1; - } - } - - assert(socket->pcb.tcp != NULL); - - struct pbuf *p = socket->incoming.pbuf; - - mp_uint_t remaining = p->len - socket->recv_offset; - if (len > remaining) { - len = remaining; - } - - memcpy(buf, (byte*)p->payload + socket->recv_offset, len); - - remaining -= len; - if (remaining == 0) { - socket->incoming.pbuf = p->next; - // If we don't ref here, free() will free the entire chain, - // if we ref, it does what we need: frees 1st buf, and decrements - // next buf's refcount back to 1. - pbuf_ref(p->next); - pbuf_free(p); - socket->recv_offset = 0; - } else { - socket->recv_offset += len; - } - tcp_recved(socket->pcb.tcp, len); - - return len; -} - -/*******************************************************************************/ -// The socket functions provided by lwip.socket. - -STATIC const mp_obj_type_t lwip_socket_type; - -STATIC void lwip_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - lwip_socket_obj_t *self = self_in; - mp_printf(print, "", self->state, self->timeout, - self->incoming.pbuf, self->recv_offset); -} - -// FIXME: Only supports two arguments at present -STATIC mp_obj_t lwip_socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 4, false); - - lwip_socket_obj_t *socket = m_new_obj_with_finaliser(lwip_socket_obj_t); - socket->base.type = (mp_obj_t)&lwip_socket_type; - socket->domain = MOD_NETWORK_AF_INET; - socket->type = MOD_NETWORK_SOCK_STREAM; - socket->callback = MP_OBJ_NULL; - if (n_args >= 1) { - socket->domain = mp_obj_get_int(args[0]); - if (n_args >= 2) { - socket->type = mp_obj_get_int(args[1]); - } - } - - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: socket->pcb.tcp = tcp_new(); break; - case MOD_NETWORK_SOCK_DGRAM: socket->pcb.udp = udp_new(); break; - //case MOD_NETWORK_SOCK_RAW: socket->pcb.raw = raw_new(); break; - default: mp_raise_OSError(MP_EINVAL); - } - - if (socket->pcb.tcp == NULL) { - mp_raise_OSError(MP_ENOMEM); - } - - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - // Register the socket object as our callback argument. - tcp_arg(socket->pcb.tcp, (void*)socket); - // Register our error callback. - tcp_err(socket->pcb.tcp, _lwip_tcp_error); - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - // Register our receive callback now. Since UDP sockets don't require binding or connection - // before use, there's no other good time to do it. - udp_recv(socket->pcb.udp, _lwip_udp_incoming, (void*)socket); - break; - } - } - - socket->incoming.pbuf = NULL; - socket->timeout = -1; - socket->state = STATE_NEW; - socket->recv_offset = 0; - return socket; -} - -STATIC mp_obj_t lwip_socket_close(mp_obj_t self_in) { - lwip_socket_obj_t *socket = self_in; - bool socket_is_listener = false; - - if (socket->pcb.tcp == NULL) { - return mp_const_none; - } - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - if (socket->pcb.tcp->state == LISTEN) { - socket_is_listener = true; - } - if (tcp_close(socket->pcb.tcp) != ERR_OK) { - DEBUG_printf("lwip_close: had to call tcp_abort()\n"); - tcp_abort(socket->pcb.tcp); - } - break; - } - case MOD_NETWORK_SOCK_DGRAM: udp_remove(socket->pcb.udp); break; - //case MOD_NETWORK_SOCK_RAW: raw_remove(socket->pcb.raw); break; - } - socket->pcb.tcp = NULL; - socket->state = _ERR_BADF; - if (socket->incoming.pbuf != NULL) { - if (!socket_is_listener) { - pbuf_free(socket->incoming.pbuf); - } else { - tcp_abort(socket->incoming.connection); - } - socket->incoming.pbuf = NULL; - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(lwip_socket_close_obj, lwip_socket_close); - -STATIC mp_obj_t lwip_socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { - lwip_socket_obj_t *socket = self_in; - - uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; - mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); - - ip_addr_t bind_addr; - IP4_ADDR(&bind_addr, ip[0], ip[1], ip[2], ip[3]); - - err_t err = ERR_ARG; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - err = tcp_bind(socket->pcb.tcp, &bind_addr, port); - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - err = udp_bind(socket->pcb.udp, &bind_addr, port); - break; - } - } - - if (err != ERR_OK) { - mp_raise_OSError(error_lookup_table[-err]); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_bind_obj, lwip_socket_bind); - -STATIC mp_obj_t lwip_socket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { - lwip_socket_obj_t *socket = self_in; - mp_int_t backlog = mp_obj_get_int(backlog_in); - - if (socket->pcb.tcp == NULL) { - mp_raise_OSError(MP_EBADF); - } - if (socket->type != MOD_NETWORK_SOCK_STREAM) { - mp_raise_OSError(MP_EOPNOTSUPP); - } - - struct tcp_pcb *new_pcb = tcp_listen_with_backlog(socket->pcb.tcp, (u8_t)backlog); - if (new_pcb == NULL) { - mp_raise_OSError(MP_ENOMEM); - } - socket->pcb.tcp = new_pcb; - tcp_accept(new_pcb, _lwip_tcp_accept); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_listen_obj, lwip_socket_listen); - -STATIC mp_obj_t lwip_socket_accept(mp_obj_t self_in) { - lwip_socket_obj_t *socket = self_in; - - if (socket->pcb.tcp == NULL) { - mp_raise_OSError(MP_EBADF); - } - if (socket->type != MOD_NETWORK_SOCK_STREAM) { - mp_raise_OSError(MP_EOPNOTSUPP); - } - // I need to do this because "tcp_accepted", later, is a macro. - struct tcp_pcb *listener = socket->pcb.tcp; - if (listener->state != LISTEN) { - mp_raise_OSError(MP_EINVAL); - } - - // accept incoming connection - if (socket->incoming.connection == NULL) { - if (socket->timeout == 0) { - mp_raise_OSError(MP_EAGAIN); - } else if (socket->timeout != -1) { - for (mp_uint_t retries = socket->timeout / 100; retries--;) { - mp_hal_delay_ms(100); - if (socket->incoming.connection != NULL) break; - } - if (socket->incoming.connection == NULL) { - mp_raise_OSError(MP_ETIMEDOUT); - } - } else { - while (socket->incoming.connection == NULL) { - poll_sockets(); - } - } - } - - // create new socket object - lwip_socket_obj_t *socket2 = m_new_obj_with_finaliser(lwip_socket_obj_t); - socket2->base.type = (mp_obj_t)&lwip_socket_type; - - // We get a new pcb handle... - socket2->pcb.tcp = socket->incoming.connection; - socket->incoming.connection = NULL; - - // ...and set up the new socket for it. - socket2->domain = MOD_NETWORK_AF_INET; - socket2->type = MOD_NETWORK_SOCK_STREAM; - socket2->incoming.pbuf = NULL; - socket2->timeout = socket->timeout; - socket2->state = STATE_CONNECTED; - socket2->recv_offset = 0; - socket2->callback = MP_OBJ_NULL; - tcp_arg(socket2->pcb.tcp, (void*)socket2); - tcp_err(socket2->pcb.tcp, _lwip_tcp_error); - tcp_recv(socket2->pcb.tcp, _lwip_tcp_recv); - - tcp_accepted(listener); - - // make the return value - uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; - memcpy(ip, &(socket2->pcb.tcp->remote_ip), sizeof(ip)); - mp_uint_t port = (mp_uint_t)socket2->pcb.tcp->remote_port; - mp_obj_tuple_t *client = mp_obj_new_tuple(2, NULL); - client->items[0] = socket2; - client->items[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); - - return client; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(lwip_socket_accept_obj, lwip_socket_accept); - -STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { - lwip_socket_obj_t *socket = self_in; - - if (socket->pcb.tcp == NULL) { - mp_raise_OSError(MP_EBADF); - } - - // get address - uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; - mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); - - ip_addr_t dest; - IP4_ADDR(&dest, ip[0], ip[1], ip[2], ip[3]); - - err_t err = ERR_ARG; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - if (socket->state != STATE_NEW) { - if (socket->state == STATE_CONNECTED) { - mp_raise_OSError(MP_EISCONN); - } else { - mp_raise_OSError(MP_EALREADY); - } - } - // Register our receive callback. - tcp_recv(socket->pcb.tcp, _lwip_tcp_recv); - socket->state = STATE_CONNECTING; - err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected); - if (err != ERR_OK) { - socket->state = STATE_NEW; - mp_raise_OSError(error_lookup_table[-err]); - } - socket->peer_port = (mp_uint_t)port; - memcpy(socket->peer, &dest, sizeof(socket->peer)); - // And now we wait... - if (socket->timeout != -1) { - for (mp_uint_t retries = socket->timeout / 100; retries--;) { - mp_hal_delay_ms(100); - if (socket->state != STATE_CONNECTING) break; - } - if (socket->state == STATE_CONNECTING) { - mp_raise_OSError(MP_EINPROGRESS); - } - } else { - while (socket->state == STATE_CONNECTING) { - poll_sockets(); - } - } - if (socket->state == STATE_CONNECTED) { - err = ERR_OK; - } else { - err = socket->state; - } - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - err = udp_connect(socket->pcb.udp, &dest, port); - break; - } - } - - if (err != ERR_OK) { - mp_raise_OSError(error_lookup_table[-err]); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_connect_obj, lwip_socket_connect); - -STATIC void lwip_socket_check_connected(lwip_socket_obj_t *socket) { - if (socket->pcb.tcp == NULL) { - // not connected - int _errno = error_lookup_table[-socket->state]; - socket->state = _ERR_BADF; - mp_raise_OSError(_errno); - } -} - -STATIC mp_obj_t lwip_socket_send(mp_obj_t self_in, mp_obj_t buf_in) { - lwip_socket_obj_t *socket = self_in; - int _errno; - - lwip_socket_check_connected(socket); - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); - - mp_uint_t ret = 0; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - ret = lwip_tcp_send(socket, bufinfo.buf, bufinfo.len, &_errno); - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - ret = lwip_udp_send(socket, bufinfo.buf, bufinfo.len, NULL, 0, &_errno); - break; - } - } - if (ret == -1) { - mp_raise_OSError(_errno); - } - - return mp_obj_new_int_from_uint(ret); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_send_obj, lwip_socket_send); - -STATIC mp_obj_t lwip_socket_recv(mp_obj_t self_in, mp_obj_t len_in) { - lwip_socket_obj_t *socket = self_in; - int _errno; - - lwip_socket_check_connected(socket); - - mp_int_t len = mp_obj_get_int(len_in); - vstr_t vstr; - vstr_init_len(&vstr, len); - - mp_uint_t ret = 0; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - ret = lwip_tcp_receive(socket, (byte*)vstr.buf, len, &_errno); - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - ret = lwip_udp_receive(socket, (byte*)vstr.buf, len, NULL, NULL, &_errno); - break; - } - } - if (ret == -1) { - mp_raise_OSError(_errno); - } - - if (ret == 0) { - return mp_const_empty_bytes; - } - vstr.len = ret; - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_recv_obj, lwip_socket_recv); - -STATIC mp_obj_t lwip_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { - lwip_socket_obj_t *socket = self_in; - int _errno; - - lwip_socket_check_connected(socket); - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_READ); - - uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE]; - mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); - - mp_uint_t ret = 0; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - ret = lwip_tcp_send(socket, bufinfo.buf, bufinfo.len, &_errno); - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - ret = lwip_udp_send(socket, bufinfo.buf, bufinfo.len, ip, port, &_errno); - break; - } - } - if (ret == -1) { - mp_raise_OSError(_errno); - } - - return mp_obj_new_int_from_uint(ret); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(lwip_socket_sendto_obj, lwip_socket_sendto); - -STATIC mp_obj_t lwip_socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) { - lwip_socket_obj_t *socket = self_in; - int _errno; - - lwip_socket_check_connected(socket); - - mp_int_t len = mp_obj_get_int(len_in); - vstr_t vstr; - vstr_init_len(&vstr, len); - byte ip[4]; - mp_uint_t port; - - mp_uint_t ret = 0; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - memcpy(ip, &socket->peer, sizeof(socket->peer)); - port = (mp_uint_t) socket->peer_port; - ret = lwip_tcp_receive(socket, (byte*)vstr.buf, len, &_errno); - break; - } - case MOD_NETWORK_SOCK_DGRAM: { - ret = lwip_udp_receive(socket, (byte*)vstr.buf, len, ip, &port, &_errno); - break; - } - } - if (ret == -1) { - mp_raise_OSError(_errno); - } - - mp_obj_t tuple[2]; - if (ret == 0) { - tuple[0] = mp_const_empty_bytes; - } else { - vstr.len = ret; - tuple[0] = mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); - } - tuple[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); - return mp_obj_new_tuple(2, tuple); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_recvfrom_obj, lwip_socket_recvfrom); - -STATIC mp_obj_t lwip_socket_sendall(mp_obj_t self_in, mp_obj_t buf_in) { - lwip_socket_obj_t *socket = self_in; - lwip_socket_check_connected(socket); - - int _errno; - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); - - mp_uint_t ret = 0; - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: { - if (socket->timeout == 0) { - // Behavior of sendall() for non-blocking sockets isn't explicitly specified. - // But it's specified that "On error, an exception is raised, there is no - // way to determine how much data, if any, was successfully sent." Then, the - // most useful behavior is: check whether we will be able to send all of input - // data without EAGAIN, and if won't be, raise it without sending any. - if (bufinfo.len > tcp_sndbuf(socket->pcb.tcp)) { - mp_raise_OSError(MP_EAGAIN); - } - } - // TODO: In CPython3.5, socket timeout should apply to the - // entire sendall() operation, not to individual send() chunks. - while (bufinfo.len != 0) { - ret = lwip_tcp_send(socket, bufinfo.buf, bufinfo.len, &_errno); - if (ret == -1) { - mp_raise_OSError(_errno); - } - bufinfo.len -= ret; - bufinfo.buf = (char*)bufinfo.buf + ret; - } - break; - } - case MOD_NETWORK_SOCK_DGRAM: - mp_raise_NotImplementedError(""); - break; - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_sendall_obj, lwip_socket_sendall); - -STATIC mp_obj_t lwip_socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { - lwip_socket_obj_t *socket = self_in; - mp_uint_t timeout; - if (timeout_in == mp_const_none) { - timeout = -1; - } else { - #if MICROPY_PY_BUILTINS_FLOAT - timeout = 1000 * mp_obj_get_float(timeout_in); - #else - timeout = 1000 * mp_obj_get_int(timeout_in); - #endif - } - socket->timeout = timeout; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_settimeout_obj, lwip_socket_settimeout); - -STATIC mp_obj_t lwip_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { - lwip_socket_obj_t *socket = self_in; - bool val = mp_obj_is_true(flag_in); - if (val) { - socket->timeout = -1; - } else { - socket->timeout = 0; - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_setblocking_obj, lwip_socket_setblocking); - -STATIC mp_obj_t lwip_socket_setsockopt(mp_uint_t n_args, const mp_obj_t *args) { - (void)n_args; // always 4 - lwip_socket_obj_t *socket = args[0]; - - int opt = mp_obj_get_int(args[2]); - if (opt == 20) { - if (args[3] == mp_const_none) { - socket->callback = MP_OBJ_NULL; - } else { - socket->callback = args[3]; - } - return mp_const_none; - } - - switch (opt) { - // level: SOL_SOCKET - case SOF_REUSEADDR: { - mp_int_t val = mp_obj_get_int(args[3]); - // Options are common for UDP and TCP pcb's. - if (val) { - ip_set_option(socket->pcb.tcp, SOF_REUSEADDR); - } else { - ip_reset_option(socket->pcb.tcp, SOF_REUSEADDR); - } - break; - } - - // level: IPPROTO_IP - case IP_ADD_MEMBERSHIP: { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); - if (bufinfo.len != sizeof(ip_addr_t) * 2) { - mp_raise_ValueError(NULL); - } - - // POSIX setsockopt has order: group addr, if addr, lwIP has it vice-versa - err_t err = igmp_joingroup((ip_addr_t*)bufinfo.buf + 1, bufinfo.buf); - if (err != ERR_OK) { - mp_raise_OSError(error_lookup_table[-err]); - } - break; - } - - default: - printf("Warning: lwip.setsockopt() not implemented\n"); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_socket_setsockopt_obj, 4, 4, lwip_socket_setsockopt); - -STATIC mp_obj_t lwip_socket_makefile(mp_uint_t n_args, const mp_obj_t *args) { - (void)n_args; - return args[0]; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_socket_makefile_obj, 1, 3, lwip_socket_makefile); - -STATIC mp_uint_t lwip_socket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - lwip_socket_obj_t *socket = self_in; - - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: - return lwip_tcp_receive(socket, buf, size, errcode); - case MOD_NETWORK_SOCK_DGRAM: - return lwip_udp_receive(socket, buf, size, NULL, NULL, errcode); - } - // Unreachable - return MP_STREAM_ERROR; -} - -STATIC mp_uint_t lwip_socket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - lwip_socket_obj_t *socket = self_in; - - switch (socket->type) { - case MOD_NETWORK_SOCK_STREAM: - return lwip_tcp_send(socket, buf, size, errcode); - case MOD_NETWORK_SOCK_DGRAM: - return lwip_udp_send(socket, buf, size, NULL, 0, errcode); - } - // Unreachable - return MP_STREAM_ERROR; -} - -STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { - lwip_socket_obj_t *socket = self_in; - mp_uint_t ret; - - if (request == MP_STREAM_POLL) { - uintptr_t flags = arg; - ret = 0; - - if (flags & MP_STREAM_POLL_RD && socket->incoming.pbuf != NULL) { - ret |= MP_STREAM_POLL_RD; - } - - if (flags & MP_STREAM_POLL_WR && tcp_sndbuf(socket->pcb.tcp) > 0) { - ret |= MP_STREAM_POLL_WR; - } - - if (socket->state == STATE_PEER_CLOSED) { - // Peer-closed socket is both readable and writable: read will - // return EOF, write - error. Without this poll will hang on a - // socket which was closed by peer. - ret |= flags & (MP_STREAM_POLL_RD | MP_STREAM_POLL_WR); - } - - } else { - *errcode = MP_EINVAL; - ret = MP_STREAM_ERROR; - } - - return ret; -} - -STATIC const mp_rom_map_elem_t lwip_socket_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&lwip_socket_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&lwip_socket_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&lwip_socket_bind_obj) }, - { MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&lwip_socket_listen_obj) }, - { MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&lwip_socket_accept_obj) }, - { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&lwip_socket_connect_obj) }, - { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&lwip_socket_send_obj) }, - { MP_ROM_QSTR(MP_QSTR_recv), MP_ROM_PTR(&lwip_socket_recv_obj) }, - { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&lwip_socket_sendto_obj) }, - { MP_ROM_QSTR(MP_QSTR_recvfrom), MP_ROM_PTR(&lwip_socket_recvfrom_obj) }, - { MP_ROM_QSTR(MP_QSTR_sendall), MP_ROM_PTR(&lwip_socket_sendall_obj) }, - { MP_ROM_QSTR(MP_QSTR_settimeout), MP_ROM_PTR(&lwip_socket_settimeout_obj) }, - { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&lwip_socket_setblocking_obj) }, - { MP_ROM_QSTR(MP_QSTR_setsockopt), MP_ROM_PTR(&lwip_socket_setsockopt_obj) }, - { MP_ROM_QSTR(MP_QSTR_makefile), MP_ROM_PTR(&lwip_socket_makefile_obj) }, - - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table); - -STATIC const mp_stream_p_t lwip_socket_stream_p = { - .read = lwip_socket_read, - .write = lwip_socket_write, - .ioctl = lwip_socket_ioctl, -}; - -STATIC const mp_obj_type_t lwip_socket_type = { - { &mp_type_type }, - .name = MP_QSTR_socket, - .print = lwip_socket_print, - .make_new = lwip_socket_make_new, - .protocol = &lwip_socket_stream_p, - .locals_dict = (mp_obj_dict_t*)&lwip_socket_locals_dict, -}; - -/******************************************************************************/ -// Support functions for memory protection. lwIP has its own memory management -// routines for its internal structures, and since they might be called in -// interrupt handlers, they need some protection. -sys_prot_t sys_arch_protect() { - return (sys_prot_t)MICROPY_BEGIN_ATOMIC_SECTION(); -} - -void sys_arch_unprotect(sys_prot_t state) { - MICROPY_END_ATOMIC_SECTION((mp_uint_t)state); -} - -/******************************************************************************/ -// Polling callbacks for the interfaces connected to lwIP. Right now it calls -// itself a "list" but isn't; we only support a single interface. - -typedef struct nic_poll { - void (* poll)(void *arg); - void *poll_arg; -} nic_poll_t; - -STATIC nic_poll_t lwip_poll_list; - -void mod_lwip_register_poll(void (* poll)(void *arg), void *poll_arg) { - lwip_poll_list.poll = poll; - lwip_poll_list.poll_arg = poll_arg; -} - -void mod_lwip_deregister_poll(void (* poll)(void *arg), void *poll_arg) { - lwip_poll_list.poll = NULL; -} - -/******************************************************************************/ -// The lwip global functions. - -STATIC mp_obj_t mod_lwip_reset() { - lwip_init(); - lwip_poll_list.poll = NULL; - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_0(mod_lwip_reset_obj, mod_lwip_reset); - -STATIC mp_obj_t mod_lwip_callback() { - if (lwip_poll_list.poll != NULL) { - lwip_poll_list.poll(lwip_poll_list.poll_arg); - } - sys_check_timeouts(); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_0(mod_lwip_callback_obj, mod_lwip_callback); - -typedef struct _getaddrinfo_state_t { - volatile int status; - volatile ip_addr_t ipaddr; -} getaddrinfo_state_t; - -// Callback for incoming DNS requests. -STATIC void lwip_getaddrinfo_cb(const char *name, ip_addr_t *ipaddr, void *arg) { - getaddrinfo_state_t *state = arg; - if (ipaddr != NULL) { - state->status = 1; - state->ipaddr = *ipaddr; - } else { - // error - state->status = -2; - } -} - -// lwip.getaddrinfo -STATIC mp_obj_t lwip_getaddrinfo(size_t n_args, const mp_obj_t *args) { - if (n_args > 2) { - mp_warning("getaddrinfo constraints not supported"); - } - - mp_obj_t host_in = args[0], port_in = args[1]; - const char *host = mp_obj_str_get_str(host_in); - mp_int_t port = mp_obj_get_int(port_in); - - getaddrinfo_state_t state; - state.status = 0; - - err_t ret = dns_gethostbyname(host, (ip_addr_t*)&state.ipaddr, lwip_getaddrinfo_cb, &state); - switch (ret) { - case ERR_OK: - // cached - state.status = 1; - break; - case ERR_INPROGRESS: - while (state.status == 0) { - poll_sockets(); - } - break; - default: - state.status = ret; - } - - if (state.status < 0) { - // TODO: CPython raises gaierror, we raise with native lwIP negative error - // values, to differentiate from normal errno's at least in such way. - mp_raise_OSError(state.status); - } - - mp_obj_tuple_t *tuple = mp_obj_new_tuple(5, NULL); - tuple->items[0] = MP_OBJ_NEW_SMALL_INT(MOD_NETWORK_AF_INET); - tuple->items[1] = MP_OBJ_NEW_SMALL_INT(MOD_NETWORK_SOCK_STREAM); - tuple->items[2] = MP_OBJ_NEW_SMALL_INT(0); - tuple->items[3] = MP_OBJ_NEW_QSTR(MP_QSTR_); - tuple->items[4] = netutils_format_inet_addr((uint8_t*)&state.ipaddr, port, NETUTILS_BIG); - return mp_obj_new_list(1, (mp_obj_t*)&tuple); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_getaddrinfo_obj, 2, 6, lwip_getaddrinfo); - -// Debug functions - -STATIC mp_obj_t lwip_print_pcbs() { - tcp_debug_print_pcbs(); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_0(lwip_print_pcbs_obj, lwip_print_pcbs); - -#ifdef MICROPY_PY_LWIP - -STATIC const mp_rom_map_elem_t mp_module_lwip_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_lwip) }, - { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mod_lwip_reset_obj) }, - { MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&mod_lwip_callback_obj) }, - { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&lwip_getaddrinfo_obj) }, - { MP_ROM_QSTR(MP_QSTR_print_pcbs), MP_ROM_PTR(&lwip_print_pcbs_obj) }, - // objects - { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&lwip_socket_type) }, -#ifdef MICROPY_PY_LWIP_SLIP - { MP_ROM_QSTR(MP_QSTR_slip), MP_ROM_PTR(&lwip_slip_type) }, -#endif - // class constants - { MP_ROM_QSTR(MP_QSTR_AF_INET), MP_ROM_INT(MOD_NETWORK_AF_INET) }, - { MP_ROM_QSTR(MP_QSTR_AF_INET6), MP_ROM_INT(MOD_NETWORK_AF_INET6) }, - - { MP_ROM_QSTR(MP_QSTR_SOCK_STREAM), MP_ROM_INT(MOD_NETWORK_SOCK_STREAM) }, - { MP_ROM_QSTR(MP_QSTR_SOCK_DGRAM), MP_ROM_INT(MOD_NETWORK_SOCK_DGRAM) }, - { MP_ROM_QSTR(MP_QSTR_SOCK_RAW), MP_ROM_INT(MOD_NETWORK_SOCK_RAW) }, - - { MP_ROM_QSTR(MP_QSTR_SOL_SOCKET), MP_ROM_INT(1) }, - { MP_ROM_QSTR(MP_QSTR_SO_REUSEADDR), MP_ROM_INT(SOF_REUSEADDR) }, - - { MP_ROM_QSTR(MP_QSTR_IPPROTO_IP), MP_ROM_INT(0) }, - { MP_ROM_QSTR(MP_QSTR_IP_ADD_MEMBERSHIP), MP_ROM_INT(IP_ADD_MEMBERSHIP) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_lwip_globals, mp_module_lwip_globals_table); - -const mp_obj_module_t mp_module_lwip = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_lwip_globals, -}; - -#endif // MICROPY_PY_LWIP diff --git a/user/mpy/extmod/modonewire.c b/user/mpy/extmod/modonewire.c deleted file mode 100644 index 53c9456..0000000 --- a/user/mpy/extmod/modonewire.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015-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. - */ - -#include -#include - -#include "py/obj.h" -#include "py/mphal.h" - -/******************************************************************************/ -// Low-level 1-Wire routines - -#define TIMING_RESET1 (480) -#define TIMING_RESET2 (40) -#define TIMING_RESET3 (420) -#define TIMING_READ1 (5) -#define TIMING_READ2 (5) -#define TIMING_READ3 (40) -#define TIMING_WRITE1 (10) -#define TIMING_WRITE2 (50) -#define TIMING_WRITE3 (10) - -STATIC int onewire_bus_reset(mp_hal_pin_obj_t pin) { - mp_hal_pin_write(pin, 0); - mp_hal_delay_us(TIMING_RESET1); - uint32_t i = mp_hal_quiet_timing_enter(); - mp_hal_pin_write(pin, 1); - mp_hal_delay_us_fast(TIMING_RESET2); - int status = !mp_hal_pin_read(pin); - mp_hal_quiet_timing_exit(i); - mp_hal_delay_us(TIMING_RESET3); - return status; -} - -STATIC int onewire_bus_readbit(mp_hal_pin_obj_t pin) { - mp_hal_pin_write(pin, 1); - uint32_t i = mp_hal_quiet_timing_enter(); - mp_hal_pin_write(pin, 0); - mp_hal_delay_us_fast(TIMING_READ1); - mp_hal_pin_write(pin, 1); - mp_hal_delay_us_fast(TIMING_READ2); - int value = mp_hal_pin_read(pin); - mp_hal_quiet_timing_exit(i); - mp_hal_delay_us_fast(TIMING_READ3); - return value; -} - -STATIC void onewire_bus_writebit(mp_hal_pin_obj_t pin, int value) { - uint32_t i = mp_hal_quiet_timing_enter(); - mp_hal_pin_write(pin, 0); - mp_hal_delay_us_fast(TIMING_WRITE1); - if (value) { - mp_hal_pin_write(pin, 1); - } - mp_hal_delay_us_fast(TIMING_WRITE2); - mp_hal_pin_write(pin, 1); - mp_hal_delay_us_fast(TIMING_WRITE3); - mp_hal_quiet_timing_exit(i); -} - -/******************************************************************************/ -// MicroPython bindings - -STATIC mp_obj_t onewire_reset(mp_obj_t pin_in) { - return mp_obj_new_bool(onewire_bus_reset(mp_hal_get_pin_obj(pin_in))); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_reset_obj, onewire_reset); - -STATIC mp_obj_t onewire_readbit(mp_obj_t pin_in) { - return MP_OBJ_NEW_SMALL_INT(onewire_bus_readbit(mp_hal_get_pin_obj(pin_in))); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_readbit_obj, onewire_readbit); - -STATIC mp_obj_t onewire_readbyte(mp_obj_t pin_in) { - mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(pin_in); - uint8_t value = 0; - for (int i = 0; i < 8; ++i) { - value |= onewire_bus_readbit(pin) << i; - } - return MP_OBJ_NEW_SMALL_INT(value); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_readbyte_obj, onewire_readbyte); - -STATIC mp_obj_t onewire_writebit(mp_obj_t pin_in, mp_obj_t value_in) { - onewire_bus_writebit(mp_hal_get_pin_obj(pin_in), mp_obj_get_int(value_in)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(onewire_writebit_obj, onewire_writebit); - -STATIC mp_obj_t onewire_writebyte(mp_obj_t pin_in, mp_obj_t value_in) { - mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(pin_in); - int value = mp_obj_get_int(value_in); - for (int i = 0; i < 8; ++i) { - onewire_bus_writebit(pin, value & 1); - value >>= 1; - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(onewire_writebyte_obj, onewire_writebyte); - -STATIC mp_obj_t onewire_crc8(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); - uint8_t crc = 0; - for (size_t i = 0; i < bufinfo.len; ++i) { - uint8_t byte = ((uint8_t*)bufinfo.buf)[i]; - for (int b = 0; b < 8; ++b) { - uint8_t fb_bit = (crc ^ byte) & 0x01; - if (fb_bit == 0x01) { - crc = crc ^ 0x18; - } - crc = (crc >> 1) & 0x7f; - if (fb_bit == 0x01) { - crc = crc | 0x80; - } - byte = byte >> 1; - } - } - return MP_OBJ_NEW_SMALL_INT(crc); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewire_crc8_obj, onewire_crc8); - -STATIC const mp_rom_map_elem_t onewire_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_onewire) }, - - { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&onewire_reset_obj) }, - { MP_ROM_QSTR(MP_QSTR_readbit), MP_ROM_PTR(&onewire_readbit_obj) }, - { MP_ROM_QSTR(MP_QSTR_readbyte), MP_ROM_PTR(&onewire_readbyte_obj) }, - { MP_ROM_QSTR(MP_QSTR_writebit), MP_ROM_PTR(&onewire_writebit_obj) }, - { MP_ROM_QSTR(MP_QSTR_writebyte), MP_ROM_PTR(&onewire_writebyte_obj) }, - { MP_ROM_QSTR(MP_QSTR_crc8), MP_ROM_PTR(&onewire_crc8_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(onewire_module_globals, onewire_module_globals_table); - -const mp_obj_module_t mp_module_onewire = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&onewire_module_globals, -}; diff --git a/user/mpy/extmod/modubinascii.c b/user/mpy/extmod/modubinascii.c deleted file mode 100644 index d3092a4..0000000 --- a/user/mpy/extmod/modubinascii.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/binary.h" -#include "extmod/modubinascii.h" - -#include "uzlib/tinf.h" - -mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { - // Second argument is for an extension to allow a separator to be used - // between values. - const char *sep = NULL; - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); - - // Code below assumes non-zero buffer length when computing size with - // separator, so handle the zero-length case here. - if (bufinfo.len == 0) { - return mp_const_empty_bytes; - } - - vstr_t vstr; - size_t out_len = bufinfo.len * 2; - if (n_args > 1) { - // 1-char separator between hex numbers - out_len += bufinfo.len - 1; - sep = mp_obj_str_get_str(args[1]); - } - vstr_init_len(&vstr, out_len); - byte *in = bufinfo.buf, *out = (byte*)vstr.buf; - for (mp_uint_t i = bufinfo.len; i--;) { - byte d = (*in >> 4); - if (d > 9) { - d += 'a' - '9' - 1; - } - *out++ = d + '0'; - d = (*in++ & 0xf); - if (d > 9) { - d += 'a' - '9' - 1; - } - *out++ = d + '0'; - if (sep != NULL && i != 0) { - *out++ = *sep; - } - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj, 1, 2, mod_binascii_hexlify); - -mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); - - if ((bufinfo.len & 1) != 0) { - mp_raise_ValueError("odd-length string"); - } - vstr_t vstr; - vstr_init_len(&vstr, bufinfo.len / 2); - byte *in = bufinfo.buf, *out = (byte*)vstr.buf; - byte hex_byte = 0; - for (mp_uint_t i = bufinfo.len; i--;) { - byte hex_ch = *in++; - if (unichar_isxdigit(hex_ch)) { - hex_byte += unichar_xdigit_value(hex_ch); - } else { - mp_raise_ValueError("non-hex digit found"); - } - if (i & 1) { - hex_byte <<= 4; - } else { - *out++ = hex_byte; - hex_byte = 0; - } - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj, mod_binascii_unhexlify); - -mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); - if (bufinfo.len % 4 != 0) { - mp_raise_ValueError("incorrect padding"); - } - - vstr_t vstr; - byte *in = bufinfo.buf; - if (bufinfo.len == 0) { - vstr_init_len(&vstr, 0); - } - else { - vstr_init_len(&vstr, ((bufinfo.len / 4) * 3) - ((in[bufinfo.len-1] == '=') ? ((in[bufinfo.len-2] == '=') ? 2 : 1 ) : 0)); - } - byte *out = (byte*)vstr.buf; - for (mp_uint_t i = bufinfo.len; i; i -= 4) { - char hold[4]; - for (int j = 4; j--;) { - if (in[j] >= 'A' && in[j] <= 'Z') { - hold[j] = in[j] - 'A'; - } else if (in[j] >= 'a' && in[j] <= 'z') { - hold[j] = in[j] - 'a' + 26; - } else if (in[j] >= '0' && in[j] <= '9') { - hold[j] = in[j] - '0' + 52; - } else if (in[j] == '+') { - hold[j] = 62; - } else if (in[j] == '/') { - hold[j] = 63; - } else if (in[j] == '=') { - if (j < 2 || i > 4) { - mp_raise_ValueError("incorrect padding"); - } - hold[j] = 64; - } else { - mp_raise_ValueError("invalid character"); - } - } - in += 4; - - *out++ = (hold[0]) << 2 | (hold[1]) >> 4; - if (hold[2] != 64) { - *out++ = (hold[1] & 0x0F) << 4 | hold[2] >> 2; - if (hold[3] != 64) { - *out++ = (hold[2] & 0x03) << 6 | hold[3]; - } - } - } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj, mod_binascii_a2b_base64); - -mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); - - vstr_t vstr; - vstr_init_len(&vstr, ((bufinfo.len != 0) ? (((bufinfo.len - 1) / 3) + 1) * 4 : 0) + 1); - - // First pass, we convert input buffer to numeric base 64 values - byte *in = bufinfo.buf, *out = (byte*)vstr.buf; - mp_uint_t i; - for (i = bufinfo.len; i >= 3; i -= 3) { - *out++ = (in[0] & 0xFC) >> 2; - *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; - *out++ = (in[1] & 0x0F) << 2 | (in[2] & 0xC0) >> 6; - *out++ = in[2] & 0x3F; - in += 3; - } - if (i != 0) { - *out++ = (in[0] & 0xFC) >> 2; - if (i == 2) { - *out++ = (in[0] & 0x03) << 4 | (in[1] & 0xF0) >> 4; - *out++ = (in[1] & 0x0F) << 2; - } - else { - *out++ = (in[0] & 0x03) << 4; - *out++ = 64; - } - *out++ = 64; - } - - // Second pass, we convert number base 64 values to actual base64 ascii encoding - out = (byte*)vstr.buf; - for (mp_uint_t j = vstr.len - 1; j--;) { - if (*out < 26) { - *out += 'A'; - } else if (*out < 52) { - *out += 'a' - 26; - } else if (*out < 62) { - *out += '0' - 52; - } else if (*out == 62) { - *out ='+'; - } else if (*out == 63) { - *out = '/'; - } else { - *out = '='; - } - out++; - } - *out = '\n'; - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64); - -#if MICROPY_PY_UBINASCII_CRC32 -mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); - uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0; - crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); - return mp_obj_new_int_from_uint(crc ^ 0xffffffff); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32); -#endif - -#if MICROPY_PY_UBINASCII - -STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubinascii) }, - { MP_ROM_QSTR(MP_QSTR_hexlify), MP_ROM_PTR(&mod_binascii_hexlify_obj) }, - { MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&mod_binascii_unhexlify_obj) }, - { MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) }, - { MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) }, - #if MICROPY_PY_UBINASCII_CRC32 - { MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); - -const mp_obj_module_t mp_module_ubinascii = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_binascii_globals, -}; - -#endif //MICROPY_PY_UBINASCII diff --git a/user/mpy/extmod/modubinascii.h b/user/mpy/extmod/modubinascii.h deleted file mode 100644 index fb31692..0000000 --- a/user/mpy/extmod/modubinascii.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H -#define MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H - -extern mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args); -extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data); -extern mp_obj_t mod_binascii_a2b_base64(mp_obj_t data); -extern mp_obj_t mod_binascii_b2a_base64(mp_obj_t data); -extern mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args); - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj); - -#endif // MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H diff --git a/user/mpy/extmod/moductypes.c b/user/mpy/extmod/moductypes.c deleted file mode 100644 index dc03f6d..0000000 --- a/user/mpy/extmod/moductypes.c +++ /dev/null @@ -1,716 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/objtuple.h" -#include "py/binary.h" - -#if MICROPY_PY_UCTYPES - -/// \module uctypes - Access data structures in memory -/// -/// The module allows to define layout of raw data structure (using terms -/// of C language), and then access memory buffers using this definition. -/// The module also provides convenience functions to access memory buffers -/// contained in Python objects or wrap memory buffers in Python objects. -/// \constant UINT8_1 - uint8_t value type - -/// \class struct - C-like structure -/// -/// Encapsulalation of in-memory data structure. This class doesn't define -/// any methods, only attribute access (for structure fields) and -/// indexing (for pointer and array fields). -/// -/// Usage: -/// -/// # Define layout of a structure with 2 fields -/// # 0 and 4 are byte offsets of fields from the beginning of struct -/// # they are logically ORed with field type -/// FOO_STRUCT = {"a": 0 | uctypes.UINT32, "b": 4 | uctypes.UINT8} -/// -/// # Example memory buffer to access (contained in bytes object) -/// buf = b"\x64\0\0\0\0x14" -/// -/// # Create structure object referring to address of -/// # the data in the buffer above -/// s = uctypes.struct(FOO_STRUCT, uctypes.addressof(buf)) -/// -/// # Access fields -/// print(s.a, s.b) -/// # Result: -/// # 100, 20 - -#define LAYOUT_LITTLE_ENDIAN (0) -#define LAYOUT_BIG_ENDIAN (1) -#define LAYOUT_NATIVE (2) - -#define VAL_TYPE_BITS 4 -#define BITF_LEN_BITS 5 -#define BITF_OFF_BITS 5 -#define OFFSET_BITS 17 -#if VAL_TYPE_BITS + BITF_LEN_BITS + BITF_OFF_BITS + OFFSET_BITS != 31 -#error Invalid encoding field length -#endif - -enum { - UINT8, INT8, UINT16, INT16, - UINT32, INT32, UINT64, INT64, - - BFUINT8, BFINT8, BFUINT16, BFINT16, - BFUINT32, BFINT32, - - FLOAT32, FLOAT64, -}; - -#define AGG_TYPE_BITS 2 - -enum { - STRUCT, PTR, ARRAY, BITFIELD, -}; - -// Here we need to set sign bit right -#define TYPE2SMALLINT(x, nbits) ((((int)x) << (32 - nbits)) >> 1) -#define GET_TYPE(x, nbits) (((x) >> (31 - nbits)) & ((1 << nbits) - 1)) -// Bit 0 is "is_signed" -#define GET_SCALAR_SIZE(val_type) (1 << ((val_type) >> 1)) -#define VALUE_MASK(type_nbits) ~((int)0x80000000 >> type_nbits) - -#define IS_SCALAR_ARRAY(tuple_desc) ((tuple_desc)->len == 2) -// We cannot apply the below to INT8, as their range [-128, 127] -#define IS_SCALAR_ARRAY_OF_BYTES(tuple_desc) (GET_TYPE(MP_OBJ_SMALL_INT_VALUE((tuple_desc)->items[1]), VAL_TYPE_BITS) == UINT8) - -// "struct" in uctypes context means "structural", i.e. aggregate, type. -STATIC const mp_obj_type_t uctypes_struct_type; - -typedef struct _mp_obj_uctypes_struct_t { - mp_obj_base_t base; - mp_obj_t desc; - byte *addr; - uint32_t flags; -} mp_obj_uctypes_struct_t; - -STATIC NORETURN void syntax_error(void) { - mp_raise_TypeError("syntax error in uctypes descriptor"); -} - -STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, 3, false); - mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); - o->base.type = type; - o->addr = (void*)(uintptr_t)mp_obj_int_get_truncated(args[0]); - o->desc = args[1]; - o->flags = LAYOUT_NATIVE; - if (n_args == 3) { - o->flags = mp_obj_get_int(args[2]); - } - return MP_OBJ_FROM_PTR(o); -} - -STATIC void uctypes_struct_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); - const char *typen = "unk"; - if (MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) { - typen = "STRUCT"; - } else if (MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) { - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc); - mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]); - uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS); - switch (agg_type) { - case PTR: typen = "PTR"; break; - case ARRAY: typen = "ARRAY"; break; - } - } else { - typen = "ERROR"; - } - mp_printf(print, "", typen, self->addr); -} - -// Get size of any type descriptor -STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_t *max_field_size); - -// Get size of scalar type descriptor -static inline mp_uint_t uctypes_struct_scalar_size(int val_type) { - if (val_type == FLOAT32) { - return 4; - } else { - return GET_SCALAR_SIZE(val_type & 7); - } -} - -// Get size of aggregate type descriptor -STATIC mp_uint_t uctypes_struct_agg_size(mp_obj_tuple_t *t, int layout_type, mp_uint_t *max_field_size) { - mp_uint_t total_size = 0; - - mp_int_t offset_ = MP_OBJ_SMALL_INT_VALUE(t->items[0]); - mp_uint_t agg_type = GET_TYPE(offset_, AGG_TYPE_BITS); - - switch (agg_type) { - case STRUCT: - return uctypes_struct_size(t->items[1], layout_type, max_field_size); - case PTR: - if (sizeof(void*) > *max_field_size) { - *max_field_size = sizeof(void*); - } - return sizeof(void*); - case ARRAY: { - mp_int_t arr_sz = MP_OBJ_SMALL_INT_VALUE(t->items[1]); - uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS); - arr_sz &= VALUE_MASK(VAL_TYPE_BITS); - mp_uint_t item_s; - if (t->len == 2) { - // Elements of array are scalar - item_s = GET_SCALAR_SIZE(val_type); - if (item_s > *max_field_size) { - *max_field_size = item_s; - } - } else { - // Elements of array are aggregates - item_s = uctypes_struct_size(t->items[2], layout_type, max_field_size); - } - - return item_s * arr_sz; - } - default: - assert(0); - } - - return total_size; -} - -STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_t *max_field_size) { - if (!MP_OBJ_IS_TYPE(desc_in, &mp_type_dict)) { - if (MP_OBJ_IS_TYPE(desc_in, &mp_type_tuple)) { - return uctypes_struct_agg_size((mp_obj_tuple_t*)MP_OBJ_TO_PTR(desc_in), layout_type, max_field_size); - } else if (MP_OBJ_IS_SMALL_INT(desc_in)) { - // We allow sizeof on both type definitions and structures/structure fields, - // but scalar structure field is lowered into native Python int, so all - // type info is lost. So, we cannot say if it's scalar type description, - // or such lowered scalar. - mp_raise_TypeError("Cannot unambiguously get sizeof scalar"); - } - syntax_error(); - } - - mp_obj_dict_t *d = MP_OBJ_TO_PTR(desc_in); - mp_uint_t total_size = 0; - - for (mp_uint_t i = 0; i < d->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&d->map, i)) { - mp_obj_t v = d->map.table[i].value; - if (MP_OBJ_IS_SMALL_INT(v)) { - mp_uint_t offset = MP_OBJ_SMALL_INT_VALUE(v); - mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS); - offset &= VALUE_MASK(VAL_TYPE_BITS); - if (val_type >= BFUINT8 && val_type <= BFINT32) { - offset &= (1 << OFFSET_BITS) - 1; - } - mp_uint_t s = uctypes_struct_scalar_size(val_type); - if (s > *max_field_size) { - *max_field_size = s; - } - if (offset + s > total_size) { - total_size = offset + s; - } - } else { - if (!MP_OBJ_IS_TYPE(v, &mp_type_tuple)) { - syntax_error(); - } - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(v); - mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]); - offset &= VALUE_MASK(AGG_TYPE_BITS); - mp_uint_t s = uctypes_struct_agg_size(t, layout_type, max_field_size); - if (offset + s > total_size) { - total_size = offset + s; - } - } - } - } - - // Round size up to alignment of biggest field - if (layout_type == LAYOUT_NATIVE) { - total_size = (total_size + *max_field_size - 1) & ~(*max_field_size - 1); - } - return total_size; -} - -STATIC mp_obj_t uctypes_struct_sizeof(mp_obj_t obj_in) { - mp_uint_t max_field_size = 0; - if (MP_OBJ_IS_TYPE(obj_in, &mp_type_bytearray)) { - return mp_obj_len(obj_in); - } - int layout_type = LAYOUT_NATIVE; - // We can apply sizeof either to structure definition (a dict) - // or to instantiated structure - if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) { - // Extract structure definition - mp_obj_uctypes_struct_t *obj = MP_OBJ_TO_PTR(obj_in); - obj_in = obj->desc; - layout_type = obj->flags; - } - mp_uint_t size = uctypes_struct_size(obj_in, layout_type, &max_field_size); - return MP_OBJ_NEW_SMALL_INT(size); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(uctypes_struct_sizeof_obj, uctypes_struct_sizeof); - -static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_endian) { - char struct_type = big_endian ? '>' : '<'; - static const char type2char[16] = "BbHhIiQq------fd"; - return mp_binary_get_val(struct_type, type2char[val_type], &p); -} - -static inline void set_unaligned(uint val_type, byte *p, int big_endian, mp_obj_t val) { - char struct_type = big_endian ? '>' : '<'; - static const char type2char[16] = "BbHhIiQq------fd"; - mp_binary_set_val(struct_type, type2char[val_type], val, &p); -} - -static inline mp_uint_t get_aligned_basic(uint val_type, void *p) { - switch (val_type) { - case UINT8: - return *(uint8_t*)p; - case UINT16: - return *(uint16_t*)p; - case UINT32: - return *(uint32_t*)p; - } - assert(0); - return 0; -} - -static inline void set_aligned_basic(uint val_type, void *p, mp_uint_t v) { - switch (val_type) { - case UINT8: - *(uint8_t*)p = (uint8_t)v; return; - case UINT16: - *(uint16_t*)p = (uint16_t)v; return; - case UINT32: - *(uint32_t*)p = (uint32_t)v; return; - } - assert(0); -} - -STATIC mp_obj_t get_aligned(uint val_type, void *p, mp_int_t index) { - switch (val_type) { - case UINT8: - return MP_OBJ_NEW_SMALL_INT(((uint8_t*)p)[index]); - case INT8: - return MP_OBJ_NEW_SMALL_INT(((int8_t*)p)[index]); - case UINT16: - return MP_OBJ_NEW_SMALL_INT(((uint16_t*)p)[index]); - case INT16: - return MP_OBJ_NEW_SMALL_INT(((int16_t*)p)[index]); - case UINT32: - return mp_obj_new_int_from_uint(((uint32_t*)p)[index]); - case INT32: - return mp_obj_new_int(((int32_t*)p)[index]); - case UINT64: - return mp_obj_new_int_from_ull(((uint64_t*)p)[index]); - case INT64: - return mp_obj_new_int_from_ll(((int64_t*)p)[index]); - #if MICROPY_PY_BUILTINS_FLOAT - case FLOAT32: - return mp_obj_new_float(((float*)p)[index]); - case FLOAT64: - return mp_obj_new_float(((double*)p)[index]); - #endif - default: - assert(0); - return MP_OBJ_NULL; - } -} - -STATIC void set_aligned(uint val_type, void *p, mp_int_t index, mp_obj_t val) { - #if MICROPY_PY_BUILTINS_FLOAT - if (val_type == FLOAT32 || val_type == FLOAT64) { - mp_float_t v = mp_obj_get_float(val); - if (val_type == FLOAT32) { - ((float*)p)[index] = v; - } else { - ((double*)p)[index] = v; - } - return; - } - #endif - mp_int_t v = mp_obj_get_int_truncated(val); - switch (val_type) { - case UINT8: - ((uint8_t*)p)[index] = (uint8_t)v; return; - case INT8: - ((int8_t*)p)[index] = (int8_t)v; return; - case UINT16: - ((uint16_t*)p)[index] = (uint16_t)v; return; - case INT16: - ((int16_t*)p)[index] = (int16_t)v; return; - case UINT32: - ((uint32_t*)p)[index] = (uint32_t)v; return; - case INT32: - ((int32_t*)p)[index] = (int32_t)v; return; - case INT64: - case UINT64: - if (sizeof(mp_int_t) == 8) { - ((uint64_t*)p)[index] = (uint64_t)v; - } else { - // TODO: Doesn't offer atomic store semantics, but should at least try - set_unaligned(val_type, p, MP_ENDIANNESS_BIG, val); - } - return; - default: - assert(0); - } -} - -STATIC mp_obj_t uctypes_struct_attr_op(mp_obj_t self_in, qstr attr, mp_obj_t set_val) { - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); - - // TODO: Support at least OrderedDict in addition - if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) { - mp_raise_TypeError("struct: no fields"); - } - - mp_obj_t deref = mp_obj_dict_get(self->desc, MP_OBJ_NEW_QSTR(attr)); - if (MP_OBJ_IS_SMALL_INT(deref)) { - mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(deref); - mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS); - offset &= VALUE_MASK(VAL_TYPE_BITS); -//printf("scalar type=%d offset=%x\n", val_type, offset); - - if (val_type <= INT64 || val_type == FLOAT32 || val_type == FLOAT64) { -// printf("size=%d\n", GET_SCALAR_SIZE(val_type)); - if (self->flags == LAYOUT_NATIVE) { - if (set_val == MP_OBJ_NULL) { - return get_aligned(val_type, self->addr + offset, 0); - } else { - set_aligned(val_type, self->addr + offset, 0, set_val); - return set_val; // just !MP_OBJ_NULL - } - } else { - if (set_val == MP_OBJ_NULL) { - return get_unaligned(val_type, self->addr + offset, self->flags); - } else { - set_unaligned(val_type, self->addr + offset, self->flags, set_val); - return set_val; // just !MP_OBJ_NULL - } - } - } else if (val_type >= BFUINT8 && val_type <= BFINT32) { - uint bit_offset = (offset >> 17) & 31; - uint bit_len = (offset >> 22) & 31; - offset &= (1 << 17) - 1; - mp_uint_t val; - if (self->flags == LAYOUT_NATIVE) { - val = get_aligned_basic(val_type & 6, self->addr + offset); - } else { - val = mp_binary_get_int(GET_SCALAR_SIZE(val_type & 7), val_type & 1, self->flags, self->addr + offset); - } - if (set_val == MP_OBJ_NULL) { - val >>= bit_offset; - val &= (1 << bit_len) - 1; - // TODO: signed - assert((val_type & 1) == 0); - return mp_obj_new_int(val); - } else { - mp_uint_t set_val_int = (mp_uint_t)mp_obj_get_int(set_val); - mp_uint_t mask = (1 << bit_len) - 1; - set_val_int &= mask; - set_val_int <<= bit_offset; - mask <<= bit_offset; - val = (val & ~mask) | set_val_int; - - if (self->flags == LAYOUT_NATIVE) { - set_aligned_basic(val_type & 6, self->addr + offset, val); - } else { - mp_binary_set_int(GET_SCALAR_SIZE(val_type & 7), self->flags == LAYOUT_BIG_ENDIAN, - self->addr + offset, val); - } - return set_val; // just !MP_OBJ_NULL - } - } - - assert(0); - return MP_OBJ_NULL; - } - - if (!MP_OBJ_IS_TYPE(deref, &mp_type_tuple)) { - syntax_error(); - } - - if (set_val != MP_OBJ_NULL) { - // Cannot assign to aggregate - syntax_error(); - } - - mp_obj_tuple_t *sub = MP_OBJ_TO_PTR(deref); - mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(sub->items[0]); - mp_uint_t agg_type = GET_TYPE(offset, AGG_TYPE_BITS); - offset &= VALUE_MASK(AGG_TYPE_BITS); -//printf("agg type=%d offset=%x\n", agg_type, offset); - - switch (agg_type) { - case STRUCT: { - mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); - o->base.type = &uctypes_struct_type; - o->desc = sub->items[1]; - o->addr = self->addr + offset; - o->flags = self->flags; - return MP_OBJ_FROM_PTR(o); - } - case ARRAY: { - mp_uint_t dummy; - if (IS_SCALAR_ARRAY(sub) && IS_SCALAR_ARRAY_OF_BYTES(sub)) { - return mp_obj_new_bytearray_by_ref(uctypes_struct_agg_size(sub, self->flags, &dummy), self->addr + offset); - } - // Fall thru to return uctypes struct object - } - case PTR: { - mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); - o->base.type = &uctypes_struct_type; - o->desc = MP_OBJ_FROM_PTR(sub); - o->addr = self->addr + offset; - o->flags = self->flags; -//printf("PTR/ARR base addr=%p\n", o->addr); - return MP_OBJ_FROM_PTR(o); - } - } - - // Should be unreachable once all cases are handled - return MP_OBJ_NULL; -} - -STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] == MP_OBJ_NULL) { - // load attribute - mp_obj_t val = uctypes_struct_attr_op(self_in, attr, MP_OBJ_NULL); - dest[0] = val; - } else { - // delete/store attribute - if (uctypes_struct_attr_op(self_in, attr, dest[1]) != MP_OBJ_NULL) { - dest[0] = MP_OBJ_NULL; // indicate success - } - } -} - -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); - - if (value == MP_OBJ_NULL) { - // delete - return MP_OBJ_NULL; // op not supported - } else { - // load / store - if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) { - mp_raise_TypeError("struct: cannot index"); - } - - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc); - mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]); - uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS); - - mp_int_t index = MP_OBJ_SMALL_INT_VALUE(index_in); - - if (agg_type == ARRAY) { - mp_int_t arr_sz = MP_OBJ_SMALL_INT_VALUE(t->items[1]); - uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS); - arr_sz &= VALUE_MASK(VAL_TYPE_BITS); - if (index >= arr_sz) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "struct: index out of range")); - } - - if (t->len == 2) { - // array of scalars - if (self->flags == LAYOUT_NATIVE) { - if (value == MP_OBJ_SENTINEL) { - return get_aligned(val_type, self->addr, index); - } else { - set_aligned(val_type, self->addr, index, value); - return value; // just !MP_OBJ_NULL - } - } else { - byte *p = self->addr + GET_SCALAR_SIZE(val_type) * index; - if (value == MP_OBJ_SENTINEL) { - return get_unaligned(val_type, p, self->flags); - } else { - set_unaligned(val_type, p, self->flags, value); - return value; // just !MP_OBJ_NULL - } - } - } else if (value == MP_OBJ_SENTINEL) { - mp_uint_t dummy = 0; - mp_uint_t size = uctypes_struct_size(t->items[2], self->flags, &dummy); - mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); - o->base.type = &uctypes_struct_type; - o->desc = t->items[2]; - o->addr = self->addr + size * index; - o->flags = self->flags; - return MP_OBJ_FROM_PTR(o); - } else { - return MP_OBJ_NULL; // op not supported - } - - } else if (agg_type == PTR) { - byte *p = *(void**)self->addr; - if (MP_OBJ_IS_SMALL_INT(t->items[1])) { - uint val_type = GET_TYPE(MP_OBJ_SMALL_INT_VALUE(t->items[1]), VAL_TYPE_BITS); - return get_aligned(val_type, p, index); - } else { - mp_uint_t dummy = 0; - mp_uint_t size = uctypes_struct_size(t->items[1], self->flags, &dummy); - mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); - o->base.type = &uctypes_struct_type; - o->desc = t->items[1]; - o->addr = p + size * index; - o->flags = self->flags; - return MP_OBJ_FROM_PTR(o); - } - } - - assert(0); - return MP_OBJ_NULL; - } -} - -STATIC mp_int_t uctypes_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - (void)flags; - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); - mp_uint_t max_field_size = 0; - mp_uint_t size = uctypes_struct_size(self->desc, self->flags, &max_field_size); - - bufinfo->buf = self->addr; - bufinfo->len = size; - bufinfo->typecode = BYTEARRAY_TYPECODE; - return 0; -} - -/// \function addressof() -/// Return address of object's data (applies to object providing buffer -/// interface). -STATIC mp_obj_t uctypes_struct_addressof(mp_obj_t buf) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); - return mp_obj_new_int((mp_int_t)(uintptr_t)bufinfo.buf); -} -MP_DEFINE_CONST_FUN_OBJ_1(uctypes_struct_addressof_obj, uctypes_struct_addressof); - -/// \function bytearray_at() -/// Capture memory at given address of given size as bytearray. Memory is -/// captured by reference (and thus memory pointed by bytearray may change -/// or become invalid at later time). Use bytes_at() to capture by value. -STATIC mp_obj_t uctypes_struct_bytearray_at(mp_obj_t ptr, mp_obj_t size) { - return mp_obj_new_bytearray_by_ref(mp_obj_int_get_truncated(size), (void*)(uintptr_t)mp_obj_int_get_truncated(ptr)); -} -MP_DEFINE_CONST_FUN_OBJ_2(uctypes_struct_bytearray_at_obj, uctypes_struct_bytearray_at); - -/// \function bytes_at() -/// Capture memory at given address of given size as bytes. Memory is -/// captured by value, i.e. copied. Use bytearray_at() to capture by reference -/// ("zero copy"). -STATIC mp_obj_t uctypes_struct_bytes_at(mp_obj_t ptr, mp_obj_t size) { - return mp_obj_new_bytes((void*)(uintptr_t)mp_obj_int_get_truncated(ptr), mp_obj_int_get_truncated(size)); -} -MP_DEFINE_CONST_FUN_OBJ_2(uctypes_struct_bytes_at_obj, uctypes_struct_bytes_at); - - -STATIC const mp_obj_type_t uctypes_struct_type = { - { &mp_type_type }, - .name = MP_QSTR_struct, - .print = uctypes_struct_print, - .make_new = uctypes_struct_make_new, - .attr = uctypes_struct_attr, - .subscr = uctypes_struct_subscr, - .buffer_p = { .get_buffer = uctypes_get_buffer }, -}; - -STATIC const mp_rom_map_elem_t mp_module_uctypes_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uctypes) }, - { MP_ROM_QSTR(MP_QSTR_struct), MP_ROM_PTR(&uctypes_struct_type) }, - { MP_ROM_QSTR(MP_QSTR_sizeof), MP_ROM_PTR(&uctypes_struct_sizeof_obj) }, - { MP_ROM_QSTR(MP_QSTR_addressof), MP_ROM_PTR(&uctypes_struct_addressof_obj) }, - { MP_ROM_QSTR(MP_QSTR_bytes_at), MP_ROM_PTR(&uctypes_struct_bytes_at_obj) }, - { MP_ROM_QSTR(MP_QSTR_bytearray_at), MP_ROM_PTR(&uctypes_struct_bytearray_at_obj) }, - - /// \moduleref uctypes - - /// \constant NATIVE - Native structure layout - native endianness, - /// platform-specific field alignment - { MP_ROM_QSTR(MP_QSTR_NATIVE), MP_ROM_INT(LAYOUT_NATIVE) }, - /// \constant LITTLE_ENDIAN - Little-endian structure layout, tightly packed - /// (no alignment constraints) - { MP_ROM_QSTR(MP_QSTR_LITTLE_ENDIAN), MP_ROM_INT(LAYOUT_LITTLE_ENDIAN) }, - /// \constant BIG_ENDIAN - Big-endian structure layout, tightly packed - /// (no alignment constraints) - { MP_ROM_QSTR(MP_QSTR_BIG_ENDIAN), MP_ROM_INT(LAYOUT_BIG_ENDIAN) }, - - /// \constant VOID - void value type, may be used only as pointer target type. - { MP_ROM_QSTR(MP_QSTR_VOID), MP_ROM_INT(TYPE2SMALLINT(UINT8, VAL_TYPE_BITS)) }, - - /// \constant UINT8 - uint8_t value type - { MP_ROM_QSTR(MP_QSTR_UINT8), MP_ROM_INT(TYPE2SMALLINT(UINT8, 4)) }, - /// \constant INT8 - int8_t value type - { MP_ROM_QSTR(MP_QSTR_INT8), MP_ROM_INT(TYPE2SMALLINT(INT8, 4)) }, - /// \constant UINT16 - uint16_t value type - { MP_ROM_QSTR(MP_QSTR_UINT16), MP_ROM_INT(TYPE2SMALLINT(UINT16, 4)) }, - /// \constant INT16 - int16_t value type - { MP_ROM_QSTR(MP_QSTR_INT16), MP_ROM_INT(TYPE2SMALLINT(INT16, 4)) }, - /// \constant UINT32 - uint32_t value type - { MP_ROM_QSTR(MP_QSTR_UINT32), MP_ROM_INT(TYPE2SMALLINT(UINT32, 4)) }, - /// \constant INT32 - int32_t value type - { MP_ROM_QSTR(MP_QSTR_INT32), MP_ROM_INT(TYPE2SMALLINT(INT32, 4)) }, - /// \constant UINT64 - uint64_t value type - { MP_ROM_QSTR(MP_QSTR_UINT64), MP_ROM_INT(TYPE2SMALLINT(UINT64, 4)) }, - /// \constant INT64 - int64_t value type - { MP_ROM_QSTR(MP_QSTR_INT64), MP_ROM_INT(TYPE2SMALLINT(INT64, 4)) }, - - { MP_ROM_QSTR(MP_QSTR_BFUINT8), MP_ROM_INT(TYPE2SMALLINT(BFUINT8, 4)) }, - { MP_ROM_QSTR(MP_QSTR_BFINT8), MP_ROM_INT(TYPE2SMALLINT(BFINT8, 4)) }, - { MP_ROM_QSTR(MP_QSTR_BFUINT16), MP_ROM_INT(TYPE2SMALLINT(BFUINT16, 4)) }, - { MP_ROM_QSTR(MP_QSTR_BFINT16), MP_ROM_INT(TYPE2SMALLINT(BFINT16, 4)) }, - { MP_ROM_QSTR(MP_QSTR_BFUINT32), MP_ROM_INT(TYPE2SMALLINT(BFUINT32, 4)) }, - { MP_ROM_QSTR(MP_QSTR_BFINT32), MP_ROM_INT(TYPE2SMALLINT(BFINT32, 4)) }, - - { MP_ROM_QSTR(MP_QSTR_BF_POS), MP_ROM_INT(17) }, - { MP_ROM_QSTR(MP_QSTR_BF_LEN), MP_ROM_INT(22) }, - - #if MICROPY_PY_BUILTINS_FLOAT - { MP_ROM_QSTR(MP_QSTR_FLOAT32), MP_ROM_INT(TYPE2SMALLINT(FLOAT32, 4)) }, - { MP_ROM_QSTR(MP_QSTR_FLOAT64), MP_ROM_INT(TYPE2SMALLINT(FLOAT64, 4)) }, - #endif - - { MP_ROM_QSTR(MP_QSTR_PTR), MP_ROM_INT(TYPE2SMALLINT(PTR, AGG_TYPE_BITS)) }, - { MP_ROM_QSTR(MP_QSTR_ARRAY), MP_ROM_INT(TYPE2SMALLINT(ARRAY, AGG_TYPE_BITS)) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_uctypes_globals, mp_module_uctypes_globals_table); - -const mp_obj_module_t mp_module_uctypes = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_uctypes_globals, -}; - -#endif diff --git a/user/mpy/extmod/moduhashlib.c b/user/mpy/extmod/moduhashlib.c deleted file mode 100644 index f3beb39..0000000 --- a/user/mpy/extmod/moduhashlib.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" - -#if MICROPY_PY_UHASHLIB - -#include "crypto-algorithms/sha256.h" -#if MICROPY_PY_UHASHLIB_SHA1 -#include "lib/axtls/crypto/crypto.h" -#endif - -typedef struct _mp_obj_hash_t { - mp_obj_base_t base; - char state[0]; -} mp_obj_hash_t; - -STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg); - -STATIC mp_obj_t hash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); - mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX)); - o->base.type = type; - sha256_init((CRYAL_SHA256_CTX*)o->state); - if (n_args == 1) { - hash_update(MP_OBJ_FROM_PTR(o), args[0]); - } - return MP_OBJ_FROM_PTR(o); -} - -#if MICROPY_PY_UHASHLIB_SHA1 -STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg); - -STATIC mp_obj_t sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); - mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(SHA1_CTX)); - o->base.type = type; - SHA1_Init((SHA1_CTX*)o->state); - if (n_args == 1) { - sha1_update(MP_OBJ_FROM_PTR(o), args[0]); - } - return MP_OBJ_FROM_PTR(o); -} -#endif - -STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg) { - mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); - sha256_update((CRYAL_SHA256_CTX*)self->state, bufinfo.buf, bufinfo.len); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_2(hash_update_obj, hash_update); - -#if MICROPY_PY_UHASHLIB_SHA1 -STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg) { - mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); - SHA1_Update((SHA1_CTX*)self->state, bufinfo.buf, bufinfo.len); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_2(sha1_update_obj, sha1_update); -#endif - -STATIC mp_obj_t hash_digest(mp_obj_t self_in) { - mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - vstr_t vstr; - vstr_init_len(&vstr, SHA256_BLOCK_SIZE); - sha256_final((CRYAL_SHA256_CTX*)self->state, (byte*)vstr.buf); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_1(hash_digest_obj, hash_digest); - -#if MICROPY_PY_UHASHLIB_SHA1 -STATIC mp_obj_t sha1_digest(mp_obj_t self_in) { - mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - vstr_t vstr; - vstr_init_len(&vstr, SHA1_SIZE); - SHA1_Final((byte*)vstr.buf, (SHA1_CTX*)self->state); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_1(sha1_digest_obj, sha1_digest); -#endif - -STATIC const mp_rom_map_elem_t hash_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&hash_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&hash_digest_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(hash_locals_dict, hash_locals_dict_table); - -STATIC const mp_obj_type_t sha256_type = { - { &mp_type_type }, - .name = MP_QSTR_sha256, - .make_new = hash_make_new, - .locals_dict = (void*)&hash_locals_dict, -}; - -#if MICROPY_PY_UHASHLIB_SHA1 -STATIC const mp_rom_map_elem_t sha1_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&sha1_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&sha1_digest_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(sha1_locals_dict, sha1_locals_dict_table); - -STATIC const mp_obj_type_t sha1_type = { - { &mp_type_type }, - .name = MP_QSTR_sha1, - .make_new = sha1_make_new, - .locals_dict = (void*)&sha1_locals_dict, -}; -#endif - -STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) }, - { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&sha256_type) }, - #if MICROPY_PY_UHASHLIB_SHA1 - { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&sha1_type) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table); - -const mp_obj_module_t mp_module_uhashlib = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_hashlib_globals, -}; - -#include "crypto-algorithms/sha256.c" - -#endif //MICROPY_PY_UHASHLIB diff --git a/user/mpy/extmod/moduheapq.c b/user/mpy/extmod/moduheapq.c deleted file mode 100644 index 4a620ba..0000000 --- a/user/mpy/extmod/moduheapq.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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. - */ - -#include "py/nlr.h" -#include "py/objlist.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_UHEAPQ - -// the algorithm here is modelled on CPython's heapq.py - -STATIC mp_obj_list_t *get_heap(mp_obj_t heap_in) { - if (!MP_OBJ_IS_TYPE(heap_in, &mp_type_list)) { - mp_raise_TypeError("heap must be a list"); - } - return MP_OBJ_TO_PTR(heap_in); -} - -STATIC void heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) { - mp_obj_t item = heap->items[pos]; - while (pos > start_pos) { - mp_uint_t parent_pos = (pos - 1) >> 1; - mp_obj_t parent = heap->items[parent_pos]; - if (mp_binary_op(MP_BINARY_OP_LESS, item, parent) == mp_const_true) { - heap->items[pos] = parent; - pos = parent_pos; - } else { - break; - } - } - heap->items[pos] = item; -} - -STATIC void heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) { - mp_uint_t start_pos = pos; - mp_uint_t end_pos = heap->len; - mp_obj_t item = heap->items[pos]; - for (mp_uint_t child_pos = 2 * pos + 1; child_pos < end_pos; child_pos = 2 * pos + 1) { - // choose right child if it's <= left child - if (child_pos + 1 < end_pos && mp_binary_op(MP_BINARY_OP_LESS, heap->items[child_pos], heap->items[child_pos + 1]) == mp_const_false) { - child_pos += 1; - } - // bubble up the smaller child - heap->items[pos] = heap->items[child_pos]; - pos = child_pos; - } - heap->items[pos] = item; - heap_siftdown(heap, start_pos, pos); -} - -STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) { - mp_obj_list_t *heap = get_heap(heap_in); - mp_obj_list_append(heap_in, item); - heap_siftdown(heap, 0, heap->len - 1); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush); - -STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) { - mp_obj_list_t *heap = get_heap(heap_in); - if (heap->len == 0) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap")); - } - mp_obj_t item = heap->items[0]; - heap->len -= 1; - heap->items[0] = heap->items[heap->len]; - heap->items[heap->len] = MP_OBJ_NULL; // so we don't retain a pointer - if (heap->len) { - heap_siftup(heap, 0); - } - return item; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heappop_obj, mod_uheapq_heappop); - -STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) { - mp_obj_list_t *heap = get_heap(heap_in); - for (mp_uint_t i = heap->len / 2; i > 0;) { - heap_siftup(heap, --i); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heapify_obj, mod_uheapq_heapify); - -STATIC const mp_rom_map_elem_t mp_module_uheapq_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uheapq) }, - { MP_ROM_QSTR(MP_QSTR_heappush), MP_ROM_PTR(&mod_uheapq_heappush_obj) }, - { MP_ROM_QSTR(MP_QSTR_heappop), MP_ROM_PTR(&mod_uheapq_heappop_obj) }, - { MP_ROM_QSTR(MP_QSTR_heapify), MP_ROM_PTR(&mod_uheapq_heapify_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_uheapq_globals, mp_module_uheapq_globals_table); - -const mp_obj_module_t mp_module_uheapq = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_uheapq_globals, -}; - -#endif //MICROPY_PY_UHEAPQ diff --git a/user/mpy/extmod/modujson.c b/user/mpy/extmod/modujson.c deleted file mode 100644 index 6c4aa16..0000000 --- a/user/mpy/extmod/modujson.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 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. - */ - -#include - -#include "py/nlr.h" -#include "py/objlist.h" -#include "py/objstringio.h" -#include "py/parsenum.h" -#include "py/runtime.h" -#include "py/stream.h" - -#if MICROPY_PY_UJSON - -STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 8, &print); - mp_obj_print_helper(&print, obj, PRINT_JSON); - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps); - -// The function below implements a simple non-recursive JSON parser. -// -// The JSON specification is at http://www.ietf.org/rfc/rfc4627.txt -// The parser here will parse any valid JSON and return the correct -// corresponding Python object. It allows through a superset of JSON, since -// it treats commas and colons as "whitespace", and doesn't care if -// brackets/braces are correctly paired. It will raise a ValueError if the -// input is outside it's specs. -// -// Most of the work is parsing the primitives (null, false, true, numbers, -// strings). It does 1 pass over the input stream. It tries to be fast and -// small in code size, while not using more RAM than necessary. - -typedef struct _ujson_stream_t { - mp_obj_t stream_obj; - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - int errcode; - byte cur; -} ujson_stream_t; - -#define S_EOF (0) // null is not allowed in json stream so is ok as EOF marker -#define S_END(s) ((s).cur == S_EOF) -#define S_CUR(s) ((s).cur) -#define S_NEXT(s) (ujson_stream_next(&(s))) - -STATIC byte ujson_stream_next(ujson_stream_t *s) { - mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode); - if (s->errcode != 0) { - mp_raise_OSError(s->errcode); - } - if (ret == 0) { - s->cur = S_EOF; - } - return s->cur; -} - -STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ); - ujson_stream_t s = {stream_obj, stream_p->read, 0, 0}; - vstr_t vstr; - vstr_init(&vstr, 8); - mp_obj_list_t stack; // we use a list as a simple stack for nested JSON - stack.len = 0; - stack.items = NULL; - mp_obj_t stack_top = MP_OBJ_NULL; - mp_obj_type_t *stack_top_type = NULL; - mp_obj_t stack_key = MP_OBJ_NULL; - S_NEXT(s); - for (;;) { - cont: - if (S_END(s)) { - break; - } - mp_obj_t next = MP_OBJ_NULL; - bool enter = false; - byte cur = S_CUR(s); - S_NEXT(s); - switch (cur) { - case ',': - case ':': - case ' ': - case '\t': - case '\n': - case '\r': - goto cont; - case 'n': - if (S_CUR(s) == 'u' && S_NEXT(s) == 'l' && S_NEXT(s) == 'l') { - S_NEXT(s); - next = mp_const_none; - } else { - goto fail; - } - break; - case 'f': - if (S_CUR(s) == 'a' && S_NEXT(s) == 'l' && S_NEXT(s) == 's' && S_NEXT(s) == 'e') { - S_NEXT(s); - next = mp_const_false; - } else { - goto fail; - } - break; - case 't': - if (S_CUR(s) == 'r' && S_NEXT(s) == 'u' && S_NEXT(s) == 'e') { - S_NEXT(s); - next = mp_const_true; - } else { - goto fail; - } - break; - case '"': - vstr_reset(&vstr); - for (; !S_END(s) && S_CUR(s) != '"';) { - byte c = S_CUR(s); - if (c == '\\') { - c = S_NEXT(s); - switch (c) { - case 'b': c = 0x08; break; - case 'f': c = 0x0c; break; - case 'n': c = 0x0a; break; - case 'r': c = 0x0d; break; - case 't': c = 0x09; break; - case 'u': { - mp_uint_t num = 0; - for (int i = 0; i < 4; i++) { - c = (S_NEXT(s) | 0x20) - '0'; - if (c > 9) { - c -= ('a' - ('9' + 1)); - } - num = (num << 4) | c; - } - vstr_add_char(&vstr, num); - goto str_cont; - } - } - } - vstr_add_byte(&vstr, c); - str_cont: - S_NEXT(s); - } - if (S_END(s)) { - goto fail; - } - S_NEXT(s); - next = mp_obj_new_str(vstr.buf, vstr.len, false); - break; - case '-': - case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { - bool flt = false; - vstr_reset(&vstr); - for (;;) { - vstr_add_byte(&vstr, cur); - cur = S_CUR(s); - if (cur == '.' || cur == 'E' || cur == 'e') { - flt = true; - } else if (cur == '-' || unichar_isdigit(cur)) { - // pass - } else { - break; - } - S_NEXT(s); - } - if (flt) { - next = mp_parse_num_decimal(vstr.buf, vstr.len, false, false, NULL); - } else { - next = mp_parse_num_integer(vstr.buf, vstr.len, 10, NULL); - } - break; - } - case '[': - next = mp_obj_new_list(0, NULL); - enter = true; - break; - case '{': - next = mp_obj_new_dict(0); - enter = true; - break; - case '}': - case ']': { - if (stack_top == MP_OBJ_NULL) { - // no object at all - goto fail; - } - if (stack.len == 0) { - // finished; compound object - goto success; - } - stack.len -= 1; - stack_top = stack.items[stack.len]; - stack_top_type = mp_obj_get_type(stack_top); - goto cont; - } - default: - goto fail; - } - if (stack_top == MP_OBJ_NULL) { - stack_top = next; - stack_top_type = mp_obj_get_type(stack_top); - if (!enter) { - // finished; single primitive only - goto success; - } - } else { - // append to list or dict - if (stack_top_type == &mp_type_list) { - mp_obj_list_append(stack_top, next); - } else { - if (stack_key == MP_OBJ_NULL) { - stack_key = next; - if (enter) { - goto fail; - } - } else { - mp_obj_dict_store(stack_top, stack_key, next); - stack_key = MP_OBJ_NULL; - } - } - if (enter) { - if (stack.items == NULL) { - mp_obj_list_init(&stack, 1); - stack.items[0] = stack_top; - } else { - mp_obj_list_append(MP_OBJ_FROM_PTR(&stack), stack_top); - } - stack_top = next; - stack_top_type = mp_obj_get_type(stack_top); - } - } - } - success: - // eat trailing whitespace - while (unichar_isspace(S_CUR(s))) { - S_NEXT(s); - } - if (!S_END(s)) { - // unexpected chars - goto fail; - } - if (stack_top == MP_OBJ_NULL || stack.len != 0) { - // not exactly 1 object - goto fail; - } - vstr_clear(&vstr); - return stack_top; - - fail: - mp_raise_ValueError("syntax error in JSON"); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load); - -STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { - size_t len; - const char *buf = mp_obj_str_get_data(obj, &len); - vstr_t vstr = {len, len, (char*)buf, true}; - mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL}; - return mod_ujson_load(MP_OBJ_FROM_PTR(&sio)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads); - -STATIC const mp_rom_map_elem_t mp_module_ujson_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ujson) }, - { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_ujson_dumps_obj) }, - { MP_ROM_QSTR(MP_QSTR_load), MP_ROM_PTR(&mod_ujson_load_obj) }, - { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_ujson_loads_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_ujson_globals, mp_module_ujson_globals_table); - -const mp_obj_module_t mp_module_ujson = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_ujson_globals, -}; - -#endif //MICROPY_PY_UJSON diff --git a/user/mpy/extmod/modurandom.c b/user/mpy/extmod/modurandom.c deleted file mode 100644 index 4b63dac..0000000 --- a/user/mpy/extmod/modurandom.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include - -//#include "py/nlr.h" -#include "py/runtime.h" - -#if MICROPY_PY_URANDOM - -// Yasmarang random number generator -// by Ilya Levin -// http://www.literatecode.com/yasmarang -// Public Domain - -STATIC uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233; -STATIC uint8_t yasmarang_dat = 0; - -STATIC uint32_t yasmarang(void) -{ - yasmarang_pad += yasmarang_dat + yasmarang_d * yasmarang_n; - yasmarang_pad = (yasmarang_pad<<3) + (yasmarang_pad>>29); - yasmarang_n = yasmarang_pad | 2; - yasmarang_d ^= (yasmarang_pad<<31) + (yasmarang_pad>>1); - yasmarang_dat ^= (char) yasmarang_pad ^ (yasmarang_d>>8) ^ 1; - - return (yasmarang_pad^(yasmarang_d<<5)^(yasmarang_pad>>18)^(yasmarang_dat<<1)); -} /* yasmarang */ - -// End of Yasmarang - -#if MICROPY_PY_URANDOM_EXTRA_FUNCS - -// returns an unsigned integer below the given argument -// n must not be zero -STATIC uint32_t yasmarang_randbelow(uint32_t n) { - uint32_t mask = 1; - while ((n & mask) < n) { - mask = (mask << 1) | 1; - } - uint32_t r; - do { - r = yasmarang() & mask; - } while (r >= n); - return r; -} - -#endif - -STATIC mp_obj_t mod_urandom_getrandbits(mp_obj_t num_in) { - int n = mp_obj_get_int(num_in); - if (n > 32 || n == 0) { - mp_raise_ValueError(NULL); - } - uint32_t mask = ~0; - // Beware of C undefined behavior when shifting by >= than bit size - mask >>= (32 - n); - return mp_obj_new_int_from_uint(yasmarang() & mask); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_getrandbits_obj, mod_urandom_getrandbits); - -STATIC mp_obj_t mod_urandom_seed(mp_obj_t seed_in) { - mp_uint_t seed = mp_obj_get_int_truncated(seed_in); - yasmarang_pad = seed; - yasmarang_n = 69; - yasmarang_d = 233; - yasmarang_dat = 0; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_seed_obj, mod_urandom_seed); - -#if MICROPY_PY_URANDOM_EXTRA_FUNCS - -STATIC mp_obj_t mod_urandom_randrange(size_t n_args, const mp_obj_t *args) { - mp_int_t start = mp_obj_get_int(args[0]); - if (n_args == 1) { - // range(stop) - if (start > 0) { - return mp_obj_new_int(yasmarang_randbelow(start)); - } else { - goto error; - } - } else { - mp_int_t stop = mp_obj_get_int(args[1]); - if (n_args == 2) { - // range(start, stop) - if (start < stop) { - return mp_obj_new_int(start + yasmarang_randbelow(stop - start)); - } else { - goto error; - } - } else { - // range(start, stop, step) - mp_int_t step = mp_obj_get_int(args[2]); - mp_int_t n; - if (step > 0) { - n = (stop - start + step - 1) / step; - } else if (step < 0) { - n = (stop - start + step + 1) / step; - } else { - goto error; - } - if (n > 0) { - return mp_obj_new_int(start + step * yasmarang_randbelow(n)); - } else { - goto error; - } - } - } - -error: - mp_raise_ValueError(NULL); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_urandom_randrange_obj, 1, 3, mod_urandom_randrange); - -STATIC mp_obj_t mod_urandom_randint(mp_obj_t a_in, mp_obj_t b_in) { - mp_int_t a = mp_obj_get_int(a_in); - mp_int_t b = mp_obj_get_int(b_in); - if (a <= b) { - return mp_obj_new_int(a + yasmarang_randbelow(b - a + 1)); - } else { - mp_raise_ValueError(NULL); - } -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); - -STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { - mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); - if (len > 0) { - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); - } else { - nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); - } -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_choice_obj, mod_urandom_choice); - -#if MICROPY_PY_BUILTINS_FLOAT - -// returns a number in the range [0..1) using Yasmarang to fill in the fraction bits -STATIC mp_float_t yasmarang_float(void) { - #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE - typedef uint64_t mp_float_int_t; - #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - typedef uint32_t mp_float_int_t; - #endif - union { - mp_float_t f; - #if MP_ENDIANNESS_LITTLE - struct { mp_float_int_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; - #else - struct { mp_float_int_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; - #endif - } u; - u.p.sgn = 0; - u.p.exp = (1 << (MP_FLOAT_EXP_BITS - 1)) - 1; - if (MP_FLOAT_FRAC_BITS <= 32) { - u.p.frc = yasmarang(); - } else { - u.p.frc = ((uint64_t)yasmarang() << 32) | (uint64_t)yasmarang(); - } - return u.f - 1; -} - -STATIC mp_obj_t mod_urandom_random(void) { - return mp_obj_new_float(yasmarang_float()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_urandom_random_obj, mod_urandom_random); - -STATIC mp_obj_t mod_urandom_uniform(mp_obj_t a_in, mp_obj_t b_in) { - mp_float_t a = mp_obj_get_float(a_in); - mp_float_t b = mp_obj_get_float(b_in); - return mp_obj_new_float(a + (b - a) * yasmarang_float()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_uniform_obj, mod_urandom_uniform); - -#endif - -#endif // MICROPY_PY_URANDOM_EXTRA_FUNCS - -STATIC const mp_rom_map_elem_t mp_module_urandom_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_urandom) }, - { MP_ROM_QSTR(MP_QSTR_getrandbits), MP_ROM_PTR(&mod_urandom_getrandbits_obj) }, - { MP_ROM_QSTR(MP_QSTR_seed), MP_ROM_PTR(&mod_urandom_seed_obj) }, - #if MICROPY_PY_URANDOM_EXTRA_FUNCS - { MP_ROM_QSTR(MP_QSTR_randrange), MP_ROM_PTR(&mod_urandom_randrange_obj) }, - { MP_ROM_QSTR(MP_QSTR_randint), MP_ROM_PTR(&mod_urandom_randint_obj) }, - { MP_ROM_QSTR(MP_QSTR_choice), MP_ROM_PTR(&mod_urandom_choice_obj) }, - #if MICROPY_PY_BUILTINS_FLOAT - { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mod_urandom_random_obj) }, - { MP_ROM_QSTR(MP_QSTR_uniform), MP_ROM_PTR(&mod_urandom_uniform_obj) }, - #endif - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_urandom_globals, mp_module_urandom_globals_table); - -const mp_obj_module_t mp_module_urandom = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_urandom_globals, -}; - -#endif //MICROPY_PY_URANDOM diff --git a/user/mpy/extmod/modure.c b/user/mpy/extmod/modure.c deleted file mode 100644 index 2baebde..0000000 --- a/user/mpy/extmod/modure.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/binary.h" -#include "py/objstr.h" - -#if MICROPY_PY_URE - -#include "re1.5/re1.5.h" - -#define FLAG_DEBUG 0x1000 - -typedef struct _mp_obj_re_t { - mp_obj_base_t base; - ByteProg re; -} mp_obj_re_t; - -typedef struct _mp_obj_match_t { - mp_obj_base_t base; - int num_matches; - mp_obj_t str; - const char *caps[0]; -} mp_obj_match_t; - - -STATIC void match_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "", self->num_matches); -} - -STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) { - mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t no = mp_obj_get_int(no_in); - if (no < 0 || no >= self->num_matches) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, no_in)); - } - - const char *start = self->caps[no * 2]; - if (start == NULL) { - // no match for this group - return mp_const_none; - } - return mp_obj_new_str_of_type(mp_obj_get_type(self->str), - (const byte*)start, self->caps[no * 2 + 1] - start); -} -MP_DEFINE_CONST_FUN_OBJ_2(match_group_obj, match_group); - -STATIC const mp_rom_map_elem_t match_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_group), MP_ROM_PTR(&match_group_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(match_locals_dict, match_locals_dict_table); - -STATIC const mp_obj_type_t match_type = { - { &mp_type_type }, - .name = MP_QSTR_match, - .print = match_print, - .locals_dict = (void*)&match_locals_dict, -}; - -STATIC void re_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_re_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "", self); -} - -STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { - (void)n_args; - mp_obj_re_t *self = MP_OBJ_TO_PTR(args[0]); - Subject subj; - size_t len; - subj.begin = mp_obj_str_get_data(args[1], &len); - subj.end = subj.begin + len; - int caps_num = (self->re.sub + 1) * 2; - mp_obj_match_t *match = m_new_obj_var(mp_obj_match_t, char*, caps_num); - // cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char - memset((char*)match->caps, 0, caps_num * sizeof(char*)); - int res = re1_5_recursiveloopprog(&self->re, &subj, match->caps, caps_num, is_anchored); - if (res == 0) { - m_del_var(mp_obj_match_t, char*, caps_num, match); - return mp_const_none; - } - - match->base.type = &match_type; - match->num_matches = caps_num / 2; // caps_num counts start and end pointers - match->str = args[1]; - return MP_OBJ_FROM_PTR(match); -} - -STATIC mp_obj_t re_match(size_t n_args, const mp_obj_t *args) { - return ure_exec(true, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_match_obj, 2, 4, re_match); - -STATIC mp_obj_t re_search(size_t n_args, const mp_obj_t *args) { - return ure_exec(false, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_search_obj, 2, 4, re_search); - -STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) { - mp_obj_re_t *self = MP_OBJ_TO_PTR(args[0]); - Subject subj; - size_t len; - const mp_obj_type_t *str_type = mp_obj_get_type(args[1]); - subj.begin = mp_obj_str_get_data(args[1], &len); - subj.end = subj.begin + len; - int caps_num = (self->re.sub + 1) * 2; - - int maxsplit = 0; - if (n_args > 2) { - maxsplit = mp_obj_get_int(args[2]); - } - - mp_obj_t retval = mp_obj_new_list(0, NULL); - const char **caps = alloca(caps_num * sizeof(char*)); - while (true) { - // cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char - memset((char**)caps, 0, caps_num * sizeof(char*)); - int res = re1_5_recursiveloopprog(&self->re, &subj, caps, caps_num, false); - - // if we didn't have a match, or had an empty match, it's time to stop - if (!res || caps[0] == caps[1]) { - break; - } - - mp_obj_t s = mp_obj_new_str_of_type(str_type, (const byte*)subj.begin, caps[0] - subj.begin); - mp_obj_list_append(retval, s); - if (self->re.sub > 0) { - mp_raise_NotImplementedError("Splitting with sub-captures"); - } - subj.begin = caps[1]; - if (maxsplit > 0 && --maxsplit == 0) { - break; - } - } - - mp_obj_t s = mp_obj_new_str_of_type(str_type, (const byte*)subj.begin, subj.end - subj.begin); - mp_obj_list_append(retval, s); - return retval; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_split_obj, 2, 3, re_split); - -STATIC const mp_rom_map_elem_t re_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&re_match_obj) }, - { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&re_search_obj) }, - { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&re_split_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(re_locals_dict, re_locals_dict_table); - -STATIC const mp_obj_type_t re_type = { - { &mp_type_type }, - .name = MP_QSTR_ure, - .print = re_print, - .locals_dict = (void*)&re_locals_dict, -}; - -STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) { - const char *re_str = mp_obj_str_get_str(args[0]); - int size = re1_5_sizecode(re_str); - if (size == -1) { - goto error; - } - mp_obj_re_t *o = m_new_obj_var(mp_obj_re_t, char, size); - o->base.type = &re_type; - int flags = 0; - if (n_args > 1) { - flags = mp_obj_get_int(args[1]); - } - int error = re1_5_compilecode(&o->re, re_str); - if (error != 0) { -error: - mp_raise_ValueError("Error in regex"); - } - if (flags & FLAG_DEBUG) { - re1_5_dumpcode(&o->re); - } - return MP_OBJ_FROM_PTR(o); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile); - -STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { - (void)n_args; - mp_obj_t self = mod_re_compile(1, args); - - const mp_obj_t args2[] = {self, args[1]}; - mp_obj_t match = ure_exec(is_anchored, 2, args2); - return match; -} - -STATIC mp_obj_t mod_re_match(size_t n_args, const mp_obj_t *args) { - return mod_re_exec(true, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_match_obj, 2, 4, mod_re_match); - -STATIC mp_obj_t mod_re_search(size_t n_args, const mp_obj_t *args) { - return mod_re_exec(false, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_search_obj, 2, 4, mod_re_search); - -STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ure) }, - { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mod_re_compile_obj) }, - { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&mod_re_match_obj) }, - { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&mod_re_search_obj) }, - { MP_ROM_QSTR(MP_QSTR_DEBUG), MP_ROM_INT(FLAG_DEBUG) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table); - -const mp_obj_module_t mp_module_ure = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_re_globals, -}; - -// Source files #include'd here to make sure they're compiled in -// only if module is enabled by config setting. - -#define re1_5_fatal(x) assert(!x) -#include "re1.5/compilecode.c" -#include "re1.5/dumpcode.c" -#include "re1.5/recursiveloop.c" -#include "re1.5/charclass.c" - -#endif //MICROPY_PY_URE diff --git a/user/mpy/extmod/moduselect.c b/user/mpy/extmod/moduselect.c deleted file mode 100644 index a9f25c1..0000000 --- a/user/mpy/extmod/moduselect.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_PY_USELECT - -#include - -#include "py/runtime.h" -#include "py/obj.h" -#include "py/objlist.h" -#include "py/stream.h" -#include "py/mperrno.h" -#include "py/mphal.h" - -// Flags for poll() -#define FLAG_ONESHOT (1) - -/// \module select - Provides select function to wait for events on a stream -/// -/// This module provides the select function. - -typedef struct _poll_obj_t { - mp_obj_t obj; - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, mp_uint_t arg, int *errcode); - mp_uint_t flags; - mp_uint_t flags_ret; -} poll_obj_t; - -STATIC void poll_map_add(mp_map_t *poll_map, const mp_obj_t *obj, mp_uint_t obj_len, mp_uint_t flags, bool or_flags) { - for (mp_uint_t i = 0; i < obj_len; i++) { - mp_map_elem_t *elem = mp_map_lookup(poll_map, mp_obj_id(obj[i]), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - if (elem->value == NULL) { - // object not found; get its ioctl and add it to the poll list - const mp_stream_p_t *stream_p = mp_get_stream_raise(obj[i], MP_STREAM_OP_IOCTL); - poll_obj_t *poll_obj = m_new_obj(poll_obj_t); - poll_obj->obj = obj[i]; - poll_obj->ioctl = stream_p->ioctl; - poll_obj->flags = flags; - poll_obj->flags_ret = 0; - elem->value = poll_obj; - } else { - // object exists; update its flags - if (or_flags) { - ((poll_obj_t*)elem->value)->flags |= flags; - } else { - ((poll_obj_t*)elem->value)->flags = flags; - } - } - } -} - -// poll each object in the map -STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, mp_uint_t *rwx_num) { - mp_uint_t n_ready = 0; - for (mp_uint_t i = 0; i < poll_map->alloc; ++i) { - if (!MP_MAP_SLOT_IS_FILLED(poll_map, i)) { - continue; - } - - poll_obj_t *poll_obj = (poll_obj_t*)poll_map->table[i].value; - int errcode; - mp_int_t ret = poll_obj->ioctl(poll_obj->obj, MP_STREAM_POLL, poll_obj->flags, &errcode); - poll_obj->flags_ret = ret; - - if (ret == -1) { - // error doing ioctl - mp_raise_OSError(errcode); - } - - if (ret != 0) { - // object is ready - n_ready += 1; - if (rwx_num != NULL) { - if (ret & MP_STREAM_POLL_RD) { - rwx_num[0] += 1; - } - if (ret & MP_STREAM_POLL_WR) { - rwx_num[1] += 1; - } - if ((ret & ~(MP_STREAM_POLL_RD | MP_STREAM_POLL_WR)) != 0) { - rwx_num[2] += 1; - } - } - } - } - return n_ready; -} - -/// \function select(rlist, wlist, xlist[, timeout]) -STATIC mp_obj_t select_select(uint n_args, const mp_obj_t *args) { - // get array data from tuple/list arguments - size_t rwx_len[3]; - mp_obj_t *r_array, *w_array, *x_array; - mp_obj_get_array(args[0], &rwx_len[0], &r_array); - mp_obj_get_array(args[1], &rwx_len[1], &w_array); - mp_obj_get_array(args[2], &rwx_len[2], &x_array); - - // get timeout - mp_uint_t timeout = -1; - if (n_args == 4) { - if (args[3] != mp_const_none) { - #if MICROPY_PY_BUILTINS_FLOAT - float timeout_f = mp_obj_get_float(args[3]); - if (timeout_f >= 0) { - timeout = (mp_uint_t)(timeout_f * 1000); - } - #else - timeout = mp_obj_get_int(args[3]) * 1000; - #endif - } - } - - // merge separate lists and get the ioctl function for each object - mp_map_t poll_map; - mp_map_init(&poll_map, rwx_len[0] + rwx_len[1] + rwx_len[2]); - poll_map_add(&poll_map, r_array, rwx_len[0], MP_STREAM_POLL_RD, true); - poll_map_add(&poll_map, w_array, rwx_len[1], MP_STREAM_POLL_WR, true); - poll_map_add(&poll_map, x_array, rwx_len[2], MP_STREAM_POLL_ERR | MP_STREAM_POLL_HUP, true); - - mp_uint_t start_tick = mp_hal_ticks_ms(); - rwx_len[0] = rwx_len[1] = rwx_len[2] = 0; - for (;;) { - // poll the objects - mp_uint_t n_ready = poll_map_poll(&poll_map, rwx_len); - - if (n_ready > 0 || (timeout != -1 && mp_hal_ticks_ms() - start_tick >= timeout)) { - // one or more objects are ready, or we had a timeout - mp_obj_t list_array[3]; - list_array[0] = mp_obj_new_list(rwx_len[0], NULL); - list_array[1] = mp_obj_new_list(rwx_len[1], NULL); - list_array[2] = mp_obj_new_list(rwx_len[2], NULL); - rwx_len[0] = rwx_len[1] = rwx_len[2] = 0; - for (mp_uint_t i = 0; i < poll_map.alloc; ++i) { - if (!MP_MAP_SLOT_IS_FILLED(&poll_map, i)) { - continue; - } - poll_obj_t *poll_obj = (poll_obj_t*)poll_map.table[i].value; - if (poll_obj->flags_ret & MP_STREAM_POLL_RD) { - ((mp_obj_list_t*)list_array[0])->items[rwx_len[0]++] = poll_obj->obj; - } - if (poll_obj->flags_ret & MP_STREAM_POLL_WR) { - ((mp_obj_list_t*)list_array[1])->items[rwx_len[1]++] = poll_obj->obj; - } - if ((poll_obj->flags_ret & ~(MP_STREAM_POLL_RD | MP_STREAM_POLL_WR)) != 0) { - ((mp_obj_list_t*)list_array[2])->items[rwx_len[2]++] = poll_obj->obj; - } - } - mp_map_deinit(&poll_map); - return mp_obj_new_tuple(3, list_array); - } - MICROPY_EVENT_POLL_HOOK - } -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); - -/// \class Poll - poll class - -typedef struct _mp_obj_poll_t { - mp_obj_base_t base; - mp_map_t poll_map; - short iter_cnt; - short iter_idx; - int flags; - // callee-owned tuple - mp_obj_t ret_tuple; -} mp_obj_poll_t; - -/// \method register(obj[, eventmask]) -STATIC mp_obj_t poll_register(uint n_args, const mp_obj_t *args) { - mp_obj_poll_t *self = args[0]; - mp_uint_t flags; - if (n_args == 3) { - flags = mp_obj_get_int(args[2]); - } else { - flags = MP_STREAM_POLL_RD | MP_STREAM_POLL_WR; - } - poll_map_add(&self->poll_map, &args[1], 1, flags, false); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_register_obj, 2, 3, poll_register); - -/// \method unregister(obj) -STATIC mp_obj_t poll_unregister(mp_obj_t self_in, mp_obj_t obj_in) { - mp_obj_poll_t *self = self_in; - mp_map_lookup(&self->poll_map, mp_obj_id(obj_in), MP_MAP_LOOKUP_REMOVE_IF_FOUND); - // TODO raise KeyError if obj didn't exist in map - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_2(poll_unregister_obj, poll_unregister); - -/// \method modify(obj, eventmask) -STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t eventmask_in) { - mp_obj_poll_t *self = self_in; - mp_map_elem_t *elem = mp_map_lookup(&self->poll_map, mp_obj_id(obj_in), MP_MAP_LOOKUP); - if (elem == NULL) { - mp_raise_OSError(MP_ENOENT); - } - ((poll_obj_t*)elem->value)->flags = mp_obj_get_int(eventmask_in); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_3(poll_modify_obj, poll_modify); - -STATIC mp_uint_t poll_poll_internal(uint n_args, const mp_obj_t *args) { - mp_obj_poll_t *self = args[0]; - - // work out timeout (its given already in ms) - mp_uint_t timeout = -1; - int flags = 0; - if (n_args >= 2) { - if (args[1] != mp_const_none) { - mp_int_t timeout_i = mp_obj_get_int(args[1]); - if (timeout_i >= 0) { - timeout = timeout_i; - } - } - if (n_args >= 3) { - flags = mp_obj_get_int(args[2]); - } - } - - self->flags = flags; - - mp_uint_t start_tick = mp_hal_ticks_ms(); - mp_uint_t n_ready; - for (;;) { - // poll the objects - n_ready = poll_map_poll(&self->poll_map, NULL); - if (n_ready > 0 || (timeout != -1 && mp_hal_ticks_ms() - start_tick >= timeout)) { - break; - } - MICROPY_EVENT_POLL_HOOK - } - - return n_ready; -} - -STATIC mp_obj_t poll_poll(uint n_args, const mp_obj_t *args) { - mp_obj_poll_t *self = args[0]; - mp_uint_t n_ready = poll_poll_internal(n_args, args); - - // one or more objects are ready, or we had a timeout - mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL); - n_ready = 0; - for (mp_uint_t i = 0; i < self->poll_map.alloc; ++i) { - if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) { - continue; - } - poll_obj_t *poll_obj = (poll_obj_t*)self->poll_map.table[i].value; - if (poll_obj->flags_ret != 0) { - mp_obj_t tuple[2] = {poll_obj->obj, MP_OBJ_NEW_SMALL_INT(poll_obj->flags_ret)}; - ret_list->items[n_ready++] = mp_obj_new_tuple(2, tuple); - if (self->flags & FLAG_ONESHOT) { - // Don't poll next time, until new event flags will be set explicitly - poll_obj->flags = 0; - } - } - } - return ret_list; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_poll_obj, 1, 3, poll_poll); - -STATIC mp_obj_t poll_ipoll(size_t n_args, const mp_obj_t *args) { - mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]); - - if (self->ret_tuple == MP_OBJ_NULL) { - self->ret_tuple = mp_obj_new_tuple(2, NULL); - } - - int n_ready = poll_poll_internal(n_args, args); - self->iter_cnt = n_ready; - self->iter_idx = 0; - - return args[0]; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_ipoll_obj, 1, 3, poll_ipoll); - -STATIC mp_obj_t poll_iternext(mp_obj_t self_in) { - mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in); - - if (self->iter_cnt == 0) { - return MP_OBJ_STOP_ITERATION; - } - - self->iter_cnt--; - - for (mp_uint_t i = self->iter_idx; i < self->poll_map.alloc; ++i) { - self->iter_idx++; - if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) { - continue; - } - poll_obj_t *poll_obj = (poll_obj_t*)self->poll_map.table[i].value; - if (poll_obj->flags_ret != 0) { - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->ret_tuple); - t->items[0] = poll_obj->obj; - t->items[1] = MP_OBJ_NEW_SMALL_INT(poll_obj->flags_ret); - if (self->flags & FLAG_ONESHOT) { - // Don't poll next time, until new event flags will be set explicitly - poll_obj->flags = 0; - } - return MP_OBJ_FROM_PTR(t); - } - } - - assert(!"inconsistent number of poll active entries"); - self->iter_cnt = 0; - return MP_OBJ_STOP_ITERATION; -} - -STATIC const mp_rom_map_elem_t poll_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(&poll_register_obj) }, - { MP_ROM_QSTR(MP_QSTR_unregister), MP_ROM_PTR(&poll_unregister_obj) }, - { MP_ROM_QSTR(MP_QSTR_modify), MP_ROM_PTR(&poll_modify_obj) }, - { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&poll_poll_obj) }, - { MP_ROM_QSTR(MP_QSTR_ipoll), MP_ROM_PTR(&poll_ipoll_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table); - -STATIC const mp_obj_type_t mp_type_poll = { - { &mp_type_type }, - .name = MP_QSTR_poll, - .getiter = mp_identity_getiter, - .iternext = poll_iternext, - .locals_dict = (void*)&poll_locals_dict, -}; - -/// \function poll() -STATIC mp_obj_t select_poll(void) { - mp_obj_poll_t *poll = m_new_obj(mp_obj_poll_t); - poll->base.type = &mp_type_poll; - mp_map_init(&poll->poll_map, 0); - poll->iter_cnt = 0; - poll->ret_tuple = MP_OBJ_NULL; - return poll; -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll); - -STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) }, - { MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) }, - { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) }, - { MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(MP_STREAM_POLL_RD) }, - { MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(MP_STREAM_POLL_WR) }, - { MP_ROM_QSTR(MP_QSTR_POLLERR), MP_ROM_INT(MP_STREAM_POLL_ERR) }, - { MP_ROM_QSTR(MP_QSTR_POLLHUP), MP_ROM_INT(MP_STREAM_POLL_HUP) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table); - -const mp_obj_module_t mp_module_uselect = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_select_globals, -}; - -#endif // MICROPY_PY_USELECT diff --git a/user/mpy/extmod/modussl_axtls.c b/user/mpy/extmod/modussl_axtls.c deleted file mode 100644 index b5d2412..0000000 --- a/user/mpy/extmod/modussl_axtls.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015-2017 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/stream.h" - -#if MICROPY_PY_USSL && MICROPY_SSL_AXTLS - -#include "ssl.h" - -typedef struct _mp_obj_ssl_socket_t { - mp_obj_base_t base; - mp_obj_t sock; - SSL_CTX *ssl_ctx; - SSL *ssl_sock; - byte *buf; - uint32_t bytes_left; -} mp_obj_ssl_socket_t; - -struct ssl_args { - mp_arg_val_t server_side; - mp_arg_val_t server_hostname; -}; - -STATIC const mp_obj_type_t ussl_socket_type; - -STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { - mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); - o->base.type = &ussl_socket_type; - o->buf = NULL; - o->bytes_left = 0; - o->sock = sock; - - uint32_t options = SSL_SERVER_VERIFY_LATER; - if ((o->ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_CLNT_SESS)) == NULL) { - mp_raise_OSError(MP_EINVAL); - } - - if (args->server_side.u_bool) { - o->ssl_sock = ssl_server_new(o->ssl_ctx, (long)sock); - } else { - SSL_EXTENSIONS *ext = ssl_ext_new(); - - if (args->server_hostname.u_obj != mp_const_none) { - ext->host_name = (char*)mp_obj_str_get_str(args->server_hostname.u_obj); - } - - o->ssl_sock = ssl_client_new(o->ssl_ctx, (long)sock, NULL, 0, ext); - - int res = ssl_handshake_status(o->ssl_sock); - // Pointer to SSL_EXTENSIONS as being passed to ssl_client_new() - // is saved in ssl_sock->extensions. - // As of axTLS 2.1.3, extensions aren't used beyond the initial - // handshake, and that's pretty much how it's expected to be. So - // we allocate them on stack and reset the pointer after handshake. - - if (res != SSL_OK) { - printf("ssl_handshake_status: %d\n", res); - ssl_display_error(res); - mp_raise_OSError(MP_EIO); - } - - } - - return o; -} - -STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "<_SSLSocket %p>", self->ssl_sock); -} - -STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { - mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); - - if (o->ssl_sock == NULL) { - *errcode = EBADF; - return MP_STREAM_ERROR; - } - - while (o->bytes_left == 0) { - mp_int_t r = ssl_read(o->ssl_sock, &o->buf); - if (r == SSL_OK) { - // SSL_OK from ssl_read() means "everything is ok, but there's - // not user data yet. So, we just keep reading. - continue; - } - if (r < 0) { - if (r == SSL_CLOSE_NOTIFY || r == SSL_ERROR_CONN_LOST) { - // EOF - return 0; - } - *errcode = r; - return MP_STREAM_ERROR; - } - o->bytes_left = r; - } - - if (size > o->bytes_left) { - size = o->bytes_left; - } - memcpy(buf, o->buf, size); - o->buf += size; - o->bytes_left -= size; - return size; -} - -STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { - mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); - - if (o->ssl_sock == NULL) { - *errcode = EBADF; - return MP_STREAM_ERROR; - } - - mp_int_t r = ssl_write(o->ssl_sock, buf, size); - if (r < 0) { - *errcode = r; - return MP_STREAM_ERROR; - } - return r; -} - -STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { - // Currently supports only blocking mode - (void)self_in; - if (!mp_obj_is_true(flag_in)) { - mp_raise_NotImplementedError(""); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking); - -STATIC mp_obj_t socket_close(mp_obj_t self_in) { - mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); - if (self->ssl_sock != NULL) { - ssl_free(self->ssl_sock); - ssl_ctx_free(self->ssl_ctx); - self->ssl_sock = NULL; - return mp_stream_close(self->sock); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close); - -STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socket_close_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); - -STATIC const mp_stream_p_t ussl_socket_stream_p = { - .read = socket_read, - .write = socket_write, -}; - -STATIC const mp_obj_type_t ussl_socket_type = { - { &mp_type_type }, - // Save on qstr's, reuse same as for module - .name = MP_QSTR_ussl, - .print = socket_print, - .getiter = NULL, - .iternext = NULL, - .protocol = &ussl_socket_stream_p, - .locals_dict = (void*)&ussl_socket_locals_dict, -}; - -STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - // TODO: Implement more args - static const mp_arg_t allowed_args[] = { - { MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - }; - - // TODO: Check that sock implements stream protocol - mp_obj_t sock = pos_args[0]; - - struct ssl_args args; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); - - return MP_OBJ_FROM_PTR(socket_new(sock, &args)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); - -STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, - { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); - -const mp_obj_module_t mp_module_ussl = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_ssl_globals, -}; - -#endif // MICROPY_PY_USSL diff --git a/user/mpy/extmod/modussl_mbedtls.c b/user/mpy/extmod/modussl_mbedtls.c deleted file mode 100644 index 597eaee..0000000 --- a/user/mpy/extmod/modussl_mbedtls.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Linaro 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS - -#include -#include -#include // needed because mp_is_nonblocking_error uses system error codes - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/stream.h" - -// mbedtls_time_t -#include "mbedtls/platform.h" -#include "mbedtls/net.h" -#include "mbedtls/ssl.h" -#include "mbedtls/x509_crt.h" -#include "mbedtls/pk.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/debug.h" - -typedef struct _mp_obj_ssl_socket_t { - mp_obj_base_t base; - mp_obj_t sock; - mbedtls_entropy_context entropy; - mbedtls_ctr_drbg_context ctr_drbg; - mbedtls_ssl_context ssl; - mbedtls_ssl_config conf; - mbedtls_x509_crt cacert; - mbedtls_x509_crt cert; - mbedtls_pk_context pkey; -} mp_obj_ssl_socket_t; - -struct ssl_args { - mp_arg_val_t key; - mp_arg_val_t cert; - mp_arg_val_t server_side; - mp_arg_val_t server_hostname; -}; - -STATIC const mp_obj_type_t ussl_socket_type; - -static void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) { - printf("DBG:%s:%04d: %s\n", file, line, str); -} - -// TODO: FIXME! -int null_entropy_func(void *data, unsigned char *output, size_t len) { - // enjoy random bytes - return 0; -} - -int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) { - mp_obj_t sock = *(mp_obj_t*)ctx; - - const mp_stream_p_t *sock_stream = mp_get_stream_raise(sock, MP_STREAM_OP_WRITE); - int err; - - int out_sz = sock_stream->write(sock, buf, len, &err); - if (out_sz == MP_STREAM_ERROR) { - if (mp_is_nonblocking_error(err)) { - return MBEDTLS_ERR_SSL_WANT_WRITE; - } - return -err; - } else { - return out_sz; - } -} - -int _mbedtls_ssl_recv(void *ctx, byte *buf, size_t len) { - mp_obj_t sock = *(mp_obj_t*)ctx; - - const mp_stream_p_t *sock_stream = mp_get_stream_raise(sock, MP_STREAM_OP_READ); - int err; - - int out_sz = sock_stream->read(sock, buf, len, &err); - if (out_sz == MP_STREAM_ERROR) { - if (mp_is_nonblocking_error(err)) { - return MBEDTLS_ERR_SSL_WANT_READ; - } - return -err; - } else { - return out_sz; - } -} - - -STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { - mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); - o->base.type = &ussl_socket_type; - - int ret; - mbedtls_ssl_init(&o->ssl); - mbedtls_ssl_config_init(&o->conf); - mbedtls_x509_crt_init(&o->cacert); - mbedtls_x509_crt_init(&o->cert); - mbedtls_pk_init(&o->pkey); - mbedtls_ctr_drbg_init(&o->ctr_drbg); - // Debug level (0-4) - mbedtls_debug_set_threshold(0); - - mbedtls_entropy_init(&o->entropy); - const byte seed[] = "upy"; - ret = mbedtls_ctr_drbg_seed(&o->ctr_drbg, null_entropy_func/*mbedtls_entropy_func*/, &o->entropy, seed, sizeof(seed)); - if (ret != 0) { - printf("ret=%d\n", ret); - assert(0); - } - - ret = mbedtls_ssl_config_defaults(&o->conf, - args->server_side.u_bool ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT, - MBEDTLS_SSL_TRANSPORT_STREAM, - MBEDTLS_SSL_PRESET_DEFAULT); - if (ret != 0) { - assert(0); - } - - mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_NONE); - mbedtls_ssl_conf_rng(&o->conf, mbedtls_ctr_drbg_random, &o->ctr_drbg); - mbedtls_ssl_conf_dbg(&o->conf, mbedtls_debug, NULL); - - ret = mbedtls_ssl_setup(&o->ssl, &o->conf); - if (ret != 0) { - assert(0); - } - - if (args->server_hostname.u_obj != mp_const_none) { - const char *sni = mp_obj_str_get_str(args->server_hostname.u_obj); - ret = mbedtls_ssl_set_hostname(&o->ssl, sni); - if (ret != 0) { - assert(0); - } - } - - o->sock = sock; - mbedtls_ssl_set_bio(&o->ssl, &o->sock, _mbedtls_ssl_send, _mbedtls_ssl_recv, NULL); - - if (args->key.u_obj != MP_OBJ_NULL) { - size_t key_len; - const byte *key = (const byte*)mp_obj_str_get_data(args->key.u_obj, &key_len); - // len should include terminating null - ret = mbedtls_pk_parse_key(&o->pkey, key, key_len + 1, NULL, 0); - assert(ret == 0); - - size_t cert_len; - const byte *cert = (const byte*)mp_obj_str_get_data(args->cert.u_obj, &cert_len); - // len should include terminating null - ret = mbedtls_x509_crt_parse(&o->cert, cert, cert_len + 1); - assert(ret == 0); - - ret = mbedtls_ssl_conf_own_cert(&o->conf, &o->cert, &o->pkey); - assert(ret == 0); - } - - while ((ret = mbedtls_ssl_handshake(&o->ssl)) != 0) { - if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { - //assert(0); - printf("mbedtls_ssl_handshake error: -%x\n", -ret); - mp_raise_OSError(MP_EIO); - } - } - - return o; -} - -STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "<_SSLSocket %p>", self); -} - -STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { - mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); - - int ret = mbedtls_ssl_read(&o->ssl, buf, size); - if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { - // end of stream - return 0; - } - if (ret >= 0) { - return ret; - } - if (ret == MBEDTLS_ERR_SSL_WANT_READ) { - ret = MP_EWOULDBLOCK; - } - *errcode = ret; - return MP_STREAM_ERROR; -} - -STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { - mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); - - int ret = mbedtls_ssl_write(&o->ssl, buf, size); - if (ret >= 0) { - return ret; - } - if (ret == MBEDTLS_ERR_SSL_WANT_WRITE) { - ret = MP_EWOULDBLOCK; - } - *errcode = ret; - return MP_STREAM_ERROR; -} - -STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { - mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(self_in); - mp_obj_t sock = o->sock; - mp_obj_t dest[3]; - mp_load_method(sock, MP_QSTR_setblocking, dest); - dest[2] = flag_in; - return mp_call_method_n_kw(1, 0, dest); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking); - -STATIC mp_obj_t socket_close(mp_obj_t self_in) { - mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); - - mbedtls_pk_free(&self->pkey); - mbedtls_x509_crt_free(&self->cert); - mbedtls_x509_crt_free(&self->cacert); - mbedtls_ssl_free(&self->ssl); - mbedtls_ssl_config_free(&self->conf); - mbedtls_ctr_drbg_free(&self->ctr_drbg); - mbedtls_entropy_free(&self->entropy); - - return mp_stream_close(self->sock); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close); - -STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socket_close_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); - -STATIC const mp_stream_p_t ussl_socket_stream_p = { - .read = socket_read, - .write = socket_write, -}; - -STATIC const mp_obj_type_t ussl_socket_type = { - { &mp_type_type }, - // Save on qstr's, reuse same as for module - .name = MP_QSTR_ussl, - .print = socket_print, - .getiter = NULL, - .iternext = NULL, - .protocol = &ussl_socket_stream_p, - .locals_dict = (void*)&ussl_socket_locals_dict, -}; - -STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - // TODO: Implement more args - static const mp_arg_t allowed_args[] = { - { MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - }; - - // TODO: Check that sock implements stream protocol - mp_obj_t sock = pos_args[0]; - - struct ssl_args args; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); - - return MP_OBJ_FROM_PTR(socket_new(sock, &args)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); - -STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, - { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); - -const mp_obj_module_t mp_module_ussl = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_ssl_globals, -}; - -#endif // MICROPY_PY_USSL diff --git a/user/mpy/extmod/modutimeq.c b/user/mpy/extmod/modutimeq.c deleted file mode 100644 index a19b3fd..0000000 --- a/user/mpy/extmod/modutimeq.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Damien P. George - * Copyright (c) 2016-2017 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. - */ - -#include - -#include "py/nlr.h" -#include "py/objlist.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/smallint.h" - -#if MICROPY_PY_UTIMEQ - -#define MODULO MICROPY_PY_UTIME_TICKS_PERIOD - -#define DEBUG 0 - -// the algorithm here is modelled on CPython's heapq.py - -struct qentry { - mp_uint_t time; - mp_uint_t id; - mp_obj_t callback; - mp_obj_t args; -}; - -typedef struct _mp_obj_utimeq_t { - mp_obj_base_t base; - mp_uint_t alloc; - mp_uint_t len; - struct qentry items[]; -} mp_obj_utimeq_t; - -STATIC mp_uint_t utimeq_id; - -STATIC mp_obj_utimeq_t *get_heap(mp_obj_t heap_in) { - return MP_OBJ_TO_PTR(heap_in); -} - -STATIC bool time_less_than(struct qentry *item, struct qentry *parent) { - mp_uint_t item_tm = item->time; - mp_uint_t parent_tm = parent->time; - mp_uint_t res = parent_tm - item_tm; - if (res == 0) { - // TODO: This actually should use the same "ring" logic - // as for time, to avoid artifacts when id's overflow. - return item->id < parent->id; - } - if ((mp_int_t)res < 0) { - res += MODULO; - } - return res && res < (MODULO / 2); -} - -STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 1, false); - mp_uint_t alloc = mp_obj_get_int(args[0]); - mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc); - o->base.type = type; - memset(o->items, 0, sizeof(*o->items) * alloc); - o->alloc = alloc; - o->len = 0; - return MP_OBJ_FROM_PTR(o); -} - -STATIC void heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) { - struct qentry item = heap->items[pos]; - while (pos > start_pos) { - mp_uint_t parent_pos = (pos - 1) >> 1; - struct qentry *parent = &heap->items[parent_pos]; - bool lessthan = time_less_than(&item, parent); - if (lessthan) { - heap->items[pos] = *parent; - pos = parent_pos; - } else { - break; - } - } - heap->items[pos] = item; -} - -STATIC void heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) { - mp_uint_t start_pos = pos; - mp_uint_t end_pos = heap->len; - struct qentry item = heap->items[pos]; - for (mp_uint_t child_pos = 2 * pos + 1; child_pos < end_pos; child_pos = 2 * pos + 1) { - // choose right child if it's <= left child - if (child_pos + 1 < end_pos) { - bool lessthan = time_less_than(&heap->items[child_pos], &heap->items[child_pos + 1]); - if (!lessthan) { - child_pos += 1; - } - } - // bubble up the smaller child - heap->items[pos] = heap->items[child_pos]; - pos = child_pos; - } - heap->items[pos] = item; - heap_siftdown(heap, start_pos, pos); -} - -STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) { - (void)n_args; - mp_obj_t heap_in = args[0]; - mp_obj_utimeq_t *heap = get_heap(heap_in); - if (heap->len == heap->alloc) { - mp_raise_msg(&mp_type_IndexError, "queue overflow"); - } - mp_uint_t l = heap->len; - heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]); - heap->items[l].id = utimeq_id++; - heap->items[l].callback = args[2]; - heap->items[l].args = args[3]; - heap_siftdown(heap, 0, heap->len); - heap->len++; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush); - -STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) { - mp_obj_utimeq_t *heap = get_heap(heap_in); - if (heap->len == 0) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap")); - } - mp_obj_list_t *ret = MP_OBJ_TO_PTR(list_ref); - if (!MP_OBJ_IS_TYPE(list_ref, &mp_type_list) || ret->len < 3) { - mp_raise_TypeError(""); - } - - struct qentry *item = &heap->items[0]; - ret->items[0] = MP_OBJ_NEW_SMALL_INT(item->time); - ret->items[1] = item->callback; - ret->items[2] = item->args; - heap->len -= 1; - heap->items[0] = heap->items[heap->len]; - heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer - heap->items[heap->len].args = MP_OBJ_NULL; - if (heap->len) { - heap_siftup(heap, 0); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop); - -STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) { - mp_obj_utimeq_t *heap = get_heap(heap_in); - if (heap->len == 0) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap")); - } - - struct qentry *item = &heap->items[0]; - return MP_OBJ_NEW_SMALL_INT(item->time); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime); - -#if DEBUG -STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) { - mp_obj_utimeq_t *heap = get_heap(heap_in); - for (int i = 0; i < heap->len; i++) { - printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time, - MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args)); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_dump_obj, mod_utimeq_dump); -#endif - -STATIC mp_obj_t utimeq_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_utimeq_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC const mp_rom_map_elem_t utimeq_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_push), MP_ROM_PTR(&mod_utimeq_heappush_obj) }, - { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&mod_utimeq_heappop_obj) }, - { MP_ROM_QSTR(MP_QSTR_peektime), MP_ROM_PTR(&mod_utimeq_peektime_obj) }, - #if DEBUG - { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_utimeq_dump_obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table); - -STATIC const mp_obj_type_t utimeq_type = { - { &mp_type_type }, - .name = MP_QSTR_utimeq, - .make_new = utimeq_make_new, - .unary_op = utimeq_unary_op, - .locals_dict = (void*)&utimeq_locals_dict, -}; - -STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utimeq) }, - { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&utimeq_type) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_utimeq_globals, mp_module_utimeq_globals_table); - -const mp_obj_module_t mp_module_utimeq = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_utimeq_globals, -}; - -#endif //MICROPY_PY_UTIMEQ diff --git a/user/mpy/extmod/moduzlib.c b/user/mpy/extmod/moduzlib.c deleted file mode 100644 index b446dba..0000000 --- a/user/mpy/extmod/moduzlib.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/stream.h" -#include "py/mperrno.h" - -#if MICROPY_PY_UZLIB - -#include "uzlib/tinf.h" - -#if 0 // print debugging info -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -typedef struct _mp_obj_decompio_t { - mp_obj_base_t base; - mp_obj_t src_stream; - TINF_DATA decomp; - bool eof; -} mp_obj_decompio_t; - -STATIC unsigned char read_src_stream(TINF_DATA *data) { - byte *p = (void*)data; - p -= offsetof(mp_obj_decompio_t, decomp); - mp_obj_decompio_t *self = (mp_obj_decompio_t*)p; - - const mp_stream_p_t *stream = mp_get_stream_raise(self->src_stream, MP_STREAM_OP_READ); - int err; - byte c; - mp_uint_t out_sz = stream->read(self->src_stream, &c, 1, &err); - if (out_sz == MP_STREAM_ERROR) { - mp_raise_OSError(err); - } - if (out_sz == 0) { - nlr_raise(mp_obj_new_exception(&mp_type_EOFError)); - } - return c; -} - -STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 2, false); - mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t); - o->base.type = type; - memset(&o->decomp, 0, sizeof(o->decomp)); - o->decomp.readSource = read_src_stream; - o->src_stream = args[0]; - o->eof = false; - - mp_int_t dict_opt = 0; - int dict_sz; - if (n_args > 1) { - dict_opt = mp_obj_get_int(args[1]); - } - - if (dict_opt >= 16) { - int st = uzlib_gzip_parse_header(&o->decomp); - if (st != TINF_OK) { - goto header_error; - } - dict_sz = 1 << (dict_opt - 16); - } else if (dict_opt >= 0) { - dict_opt = uzlib_zlib_parse_header(&o->decomp); - if (dict_opt < 0) { -header_error: - mp_raise_ValueError("compression header"); - } - dict_sz = 1 << dict_opt; - } else { - dict_sz = 1 << -dict_opt; - } - - uzlib_uncompress_init(&o->decomp, m_new(byte, dict_sz), dict_sz); - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_uint_t decompio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { - mp_obj_decompio_t *o = MP_OBJ_TO_PTR(o_in); - if (o->eof) { - return 0; - } - - o->decomp.dest = buf; - o->decomp.destSize = size; - int st = uzlib_uncompress_chksum(&o->decomp); - if (st == TINF_DONE) { - o->eof = true; - } - if (st < 0) { - *errcode = MP_EINVAL; - return MP_STREAM_ERROR; - } - return o->decomp.dest - (byte*)buf; -} - -STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); - -STATIC const mp_stream_p_t decompio_stream_p = { - .read = decompio_read, -}; - -STATIC const mp_obj_type_t decompio_type = { - { &mp_type_type }, - .name = MP_QSTR_DecompIO, - .make_new = decompio_make_new, - .protocol = &decompio_stream_p, - .locals_dict = (void*)&decompio_locals_dict, -}; - -STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { - mp_obj_t data = args[0]; - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); - - TINF_DATA *decomp = m_new_obj(TINF_DATA); - memset(decomp, 0, sizeof(*decomp)); - DEBUG_printf("sizeof(TINF_DATA)=" UINT_FMT "\n", sizeof(*decomp)); - uzlib_uncompress_init(decomp, NULL, 0); - mp_uint_t dest_buf_size = (bufinfo.len + 15) & ~15; - byte *dest_buf = m_new(byte, dest_buf_size); - - decomp->dest = dest_buf; - decomp->destSize = dest_buf_size; - DEBUG_printf("uzlib: Initial out buffer: " UINT_FMT " bytes\n", decomp->destSize); - decomp->source = bufinfo.buf; - - int st; - bool is_zlib = true; - - if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) { - is_zlib = false; - } - - if (is_zlib) { - st = uzlib_zlib_parse_header(decomp); - if (st < 0) { - goto error; - } - } - - while (1) { - st = uzlib_uncompress_chksum(decomp); - if (st < 0) { - goto error; - } - if (st == TINF_DONE) { - break; - } - size_t offset = decomp->dest - dest_buf; - dest_buf = m_renew(byte, dest_buf, dest_buf_size, dest_buf_size + 256); - dest_buf_size += 256; - decomp->dest = dest_buf + offset; - decomp->destSize = 256; - } - - mp_uint_t final_sz = decomp->dest - dest_buf; - DEBUG_printf("uzlib: Resizing from " UINT_FMT " to final size: " UINT_FMT " bytes\n", dest_buf_size, final_sz); - dest_buf = (byte*)m_renew(byte, dest_buf, dest_buf_size, final_sz); - mp_obj_t res = mp_obj_new_bytearray_by_ref(final_sz, dest_buf); - m_del_obj(TINF_DATA, decomp); - return res; - -error: - nlr_raise(mp_obj_new_exception_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st))); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress); - -STATIC const mp_rom_map_elem_t mp_module_uzlib_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uzlib) }, - { MP_ROM_QSTR(MP_QSTR_decompress), MP_ROM_PTR(&mod_uzlib_decompress_obj) }, - { MP_ROM_QSTR(MP_QSTR_DecompIO), MP_ROM_PTR(&decompio_type) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_uzlib_globals, mp_module_uzlib_globals_table); - -const mp_obj_module_t mp_module_uzlib = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_uzlib_globals, -}; - -// Source files #include'd here to make sure they're compiled in -// only if module is enabled by config setting. - -#include "uzlib/tinflate.c" -#include "uzlib/tinfzlib.c" -#include "uzlib/tinfgzip.c" -#include "uzlib/adler32.c" -#include "uzlib/crc32.c" - -#endif // MICROPY_PY_UZLIB diff --git a/user/mpy/extmod/modwebrepl.c b/user/mpy/extmod/modwebrepl.c deleted file mode 100644 index d618f53..0000000 --- a/user/mpy/extmod/modwebrepl.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "py/stream.h" -#include "py/builtin.h" -#ifdef MICROPY_PY_WEBREPL_DELAY -#include "py/mphal.h" -#endif -#include "extmod/modwebsocket.h" -#include "genhdr/mpversion.h" - -#if MICROPY_PY_WEBREPL - -#if 0 // print debugging info -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -struct webrepl_file { - char sig[2]; - char type; - char flags; - uint64_t offset; - uint32_t size; - uint16_t fname_len; - char fname[64]; -} __attribute__((packed)); - -enum { PUT_FILE = 1, GET_FILE, GET_VER }; -enum { STATE_PASSWD, STATE_NORMAL }; - -typedef struct _mp_obj_webrepl_t { - mp_obj_base_t base; - mp_obj_t sock; - byte state; - byte hdr_to_recv; - uint32_t data_to_recv; - struct webrepl_file hdr; - mp_obj_t cur_file; -} mp_obj_webrepl_t; - -// These get passed to functions which aren't force-l32, so can't be const -STATIC char passwd_prompt[] = "Password: "; -STATIC char connected_prompt[] = "\r\nWebREPL connected\r\n>>> "; -STATIC char denied_prompt[] = "\r\nAccess denied\r\n"; - -STATIC char webrepl_passwd[10]; - -STATIC void write_webrepl(mp_obj_t websock, const void *buf, size_t len) { - const mp_stream_p_t *sock_stream = mp_get_stream_raise(websock, MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); - int err; - int old_opts = sock_stream->ioctl(websock, MP_STREAM_SET_DATA_OPTS, FRAME_BIN, &err); - sock_stream->write(websock, buf, len, &err); - sock_stream->ioctl(websock, MP_STREAM_SET_DATA_OPTS, old_opts, &err); -} - -#define SSTR(s) s, sizeof(s) - 1 -STATIC void write_webrepl_str(mp_obj_t websock, const char *str, int sz) { - int err; - const mp_stream_p_t *sock_stream = mp_get_stream_raise(websock, MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); - sock_stream->write(websock, str, sz, &err); -} - -STATIC void write_webrepl_resp(mp_obj_t websock, uint16_t code) { - char buf[4] = {'W', 'B', code & 0xff, code >> 8}; - write_webrepl(websock, buf, sizeof(buf)); -} - -STATIC mp_obj_t webrepl_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 2, false); - mp_get_stream_raise(args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); - DEBUG_printf("sizeof(struct webrepl_file) = %lu\n", sizeof(struct webrepl_file)); - mp_obj_webrepl_t *o = m_new_obj(mp_obj_webrepl_t); - o->base.type = type; - o->sock = args[0]; - o->hdr_to_recv = sizeof(struct webrepl_file); - o->data_to_recv = 0; - o->state = STATE_PASSWD; - write_webrepl_str(args[0], SSTR(passwd_prompt)); - return o; -} - -STATIC int write_file_chunk(mp_obj_webrepl_t *self) { - const mp_stream_p_t *file_stream = - mp_get_stream_raise(self->cur_file, MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); - byte readbuf[2 + 256]; - int err; - mp_uint_t out_sz = file_stream->read(self->cur_file, readbuf + 2, sizeof(readbuf) - 2, &err); - if (out_sz == MP_STREAM_ERROR) { - return out_sz; - } - readbuf[0] = out_sz; - readbuf[1] = out_sz >> 8; - DEBUG_printf("webrepl: Sending %d bytes of file\n", out_sz); - write_webrepl(self->sock, readbuf, 2 + out_sz); - return out_sz; -} - -STATIC void handle_op(mp_obj_webrepl_t *self) { - - // Handle operations not requiring opened file - - switch (self->hdr.type) { - case GET_VER: { - static char ver[] = {MICROPY_VERSION_MAJOR, MICROPY_VERSION_MINOR, MICROPY_VERSION_MICRO}; - write_webrepl(self->sock, ver, sizeof(ver)); - self->hdr_to_recv = sizeof(struct webrepl_file); - return; - } - } - - // Handle operations requiring opened file - - mp_obj_t open_args[2] = { - mp_obj_new_str(self->hdr.fname, strlen(self->hdr.fname), false), - MP_OBJ_NEW_QSTR(MP_QSTR_rb) - }; - - if (self->hdr.type == PUT_FILE) { - open_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_wb); - } - - self->cur_file = mp_builtin_open(2, open_args, (mp_map_t*)&mp_const_empty_map); - - #if 0 - struct mp_stream_seek_t seek = { .offset = self->hdr.offset, .whence = 0 }; - int err; - mp_uint_t res = file_stream->ioctl(self->cur_file, MP_STREAM_SEEK, (uintptr_t)&seek, &err); - assert(res != MP_STREAM_ERROR); - #endif - - write_webrepl_resp(self->sock, 0); - - if (self->hdr.type == PUT_FILE) { - self->data_to_recv = self->hdr.size; - } else if (self->hdr.type == GET_FILE) { - self->data_to_recv = 1; - } -} - -STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode); - -STATIC mp_uint_t webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - mp_uint_t out_sz; - do { - out_sz = _webrepl_read(self_in, buf, size, errcode); - } while (out_sz == -2); - return out_sz; -} - -STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - // We know that os.dupterm always calls with size = 1 - assert(size == 1); - mp_obj_webrepl_t *self = self_in; - const mp_stream_p_t *sock_stream = mp_get_stream_raise(self->sock, MP_STREAM_OP_READ); - mp_uint_t out_sz = sock_stream->read(self->sock, buf, size, errcode); - //DEBUG_printf("webrepl: Read %d initial bytes from websocket\n", out_sz); - if (out_sz == 0 || out_sz == MP_STREAM_ERROR) { - return out_sz; - } - - if (self->state == STATE_PASSWD) { - char c = *(char*)buf; - if (c == '\r' || c == '\n') { - self->hdr.fname[self->data_to_recv] = 0; - DEBUG_printf("webrepl: entered password: %s\n", self->hdr.fname); - - if (strcmp(self->hdr.fname, webrepl_passwd) != 0) { - write_webrepl_str(self->sock, SSTR(denied_prompt)); - return 0; - } - - self->state = STATE_NORMAL; - self->data_to_recv = 0; - write_webrepl_str(self->sock, SSTR(connected_prompt)); - } else if (self->data_to_recv < 10) { - self->hdr.fname[self->data_to_recv++] = c; - } - return -2; - } - - // If last read data belonged to text record (== REPL) - int err; - if (sock_stream->ioctl(self->sock, MP_STREAM_GET_DATA_OPTS, 0, &err) == 1) { - return out_sz; - } - - DEBUG_printf("webrepl: received bin data, hdr_to_recv: %d, data_to_recv=%d\n", self->hdr_to_recv, self->data_to_recv); - - if (self->hdr_to_recv != 0) { - char *p = (char*)&self->hdr + sizeof(self->hdr) - self->hdr_to_recv; - *p++ = *(char*)buf; - if (--self->hdr_to_recv != 0) { - mp_uint_t hdr_sz = sock_stream->read(self->sock, p, self->hdr_to_recv, errcode); - if (hdr_sz == MP_STREAM_ERROR) { - return hdr_sz; - } - self->hdr_to_recv -= hdr_sz; - if (self->hdr_to_recv != 0) { - return -2; - } - } - - DEBUG_printf("webrepl: op: %d, file: %s, chunk @%x, sz=%d\n", self->hdr.type, self->hdr.fname, (uint32_t)self->hdr.offset, self->hdr.size); - - handle_op(self); - - return -2; - } - - if (self->data_to_recv != 0) { - static byte filebuf[512]; - filebuf[0] = *(byte*)buf; - mp_uint_t buf_sz = 1; - if (--self->data_to_recv != 0) { - size_t to_read = MIN(sizeof(filebuf) - 1, self->data_to_recv); - mp_uint_t sz = sock_stream->read(self->sock, filebuf + 1, to_read, errcode); - if (sz == MP_STREAM_ERROR) { - return sz; - } - self->data_to_recv -= sz; - buf_sz += sz; - } - - if (self->hdr.type == PUT_FILE) { - DEBUG_printf("webrepl: Writing %lu bytes to file\n", buf_sz); - int err; - mp_uint_t res = mp_stream_write_exactly(self->cur_file, filebuf, buf_sz, &err); - if (err != 0 || res != buf_sz) { - assert(0); - } - } else if (self->hdr.type == GET_FILE) { - assert(buf_sz == 1); - assert(self->data_to_recv == 0); - assert(filebuf[0] == 0); - mp_uint_t out_sz = write_file_chunk(self); - if (out_sz != 0) { - self->data_to_recv = 1; - } - } - - if (self->data_to_recv == 0) { - mp_stream_close(self->cur_file); - self->hdr_to_recv = sizeof(struct webrepl_file); - DEBUG_printf("webrepl: Finished file operation %d\n", self->hdr.type); - write_webrepl_resp(self->sock, 0); - } - - #ifdef MICROPY_PY_WEBREPL_DELAY - // Some platforms may have broken drivers and easily gets - // overloaded with modest traffic WebREPL file transfers - // generate. The basic workaround is a crude rate control - // done in such way. - mp_hal_delay_ms(MICROPY_PY_WEBREPL_DELAY); - #endif - } - - return -2; -} - -STATIC mp_uint_t webrepl_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - mp_obj_webrepl_t *self = self_in; - if (self->state == STATE_PASSWD) { - // Don't forward output until passwd is entered - return size; - } - const mp_stream_p_t *stream_p = mp_get_stream_raise(self->sock, MP_STREAM_OP_WRITE); - return stream_p->write(self->sock, buf, size, errcode); -} - -STATIC mp_obj_t webrepl_close(mp_obj_t self_in) { - mp_obj_webrepl_t *self = MP_OBJ_TO_PTR(self_in); - // TODO: This is a place to do cleanup - return mp_stream_close(self->sock); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(webrepl_close_obj, webrepl_close); - -STATIC mp_obj_t webrepl_set_password(mp_obj_t passwd_in) { - size_t len; - const char *passwd = mp_obj_str_get_data(passwd_in, &len); - if (len > sizeof(webrepl_passwd) - 1) { - mp_raise_ValueError(""); - } - strcpy(webrepl_passwd, passwd); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(webrepl_set_password_obj, webrepl_set_password); - -STATIC const mp_rom_map_elem_t webrepl_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&webrepl_close_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table); - -STATIC const mp_stream_p_t webrepl_stream_p = { - .read = webrepl_read, - .write = webrepl_write, -}; - -STATIC const mp_obj_type_t webrepl_type = { - { &mp_type_type }, - .name = MP_QSTR__webrepl, - .make_new = webrepl_make_new, - .protocol = &webrepl_stream_p, - .locals_dict = (mp_obj_dict_t*)&webrepl_locals_dict, -}; - -STATIC const mp_rom_map_elem_t webrepl_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__webrepl) }, - { MP_ROM_QSTR(MP_QSTR__webrepl), MP_ROM_PTR(&webrepl_type) }, - { MP_ROM_QSTR(MP_QSTR_password), MP_ROM_PTR(&webrepl_set_password_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(webrepl_module_globals, webrepl_module_globals_table); - -const mp_obj_module_t mp_module_webrepl = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&webrepl_module_globals, -}; - -#endif // MICROPY_PY_WEBREPL diff --git a/user/mpy/extmod/modwebsocket.c b/user/mpy/extmod/modwebsocket.c deleted file mode 100644 index 6c6e32c..0000000 --- a/user/mpy/extmod/modwebsocket.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "py/stream.h" -#include "extmod/modwebsocket.h" - -#if MICROPY_PY_WEBSOCKET - -enum { FRAME_HEADER, FRAME_OPT, PAYLOAD, CONTROL }; - -enum { BLOCKING_WRITE = 0x80 }; - -typedef struct _mp_obj_websocket_t { - mp_obj_base_t base; - mp_obj_t sock; - uint32_t msg_sz; - byte mask[4]; - byte state; - byte to_recv; - byte mask_pos; - byte buf_pos; - byte buf[6]; - byte opts; - // Copy of last data frame flags - byte ws_flags; - // Copy of current frame flags - byte last_flags; -} mp_obj_websocket_t; - -STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode); - -STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 2, false); - mp_obj_websocket_t *o = m_new_obj(mp_obj_websocket_t); - o->base.type = type; - o->sock = args[0]; - o->state = FRAME_HEADER; - o->to_recv = 2; - o->mask_pos = 0; - o->buf_pos = 0; - o->opts = FRAME_TXT; - if (n_args > 1 && args[1] == mp_const_true) { - o->opts |= BLOCKING_WRITE; - } - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); - const mp_stream_p_t *stream_p = mp_get_stream_raise(self->sock, MP_STREAM_OP_READ); - while (1) { - if (self->to_recv != 0) { - mp_uint_t out_sz = stream_p->read(self->sock, self->buf + self->buf_pos, self->to_recv, errcode); - if (out_sz == 0 || out_sz == MP_STREAM_ERROR) { - return out_sz; - } - self->buf_pos += out_sz; - self->to_recv -= out_sz; - if (self->to_recv != 0) { - *errcode = MP_EAGAIN; - return MP_STREAM_ERROR; - } - } - - switch (self->state) { - case FRAME_HEADER: { - // TODO: Split frame handling below is untested so far, so conservatively disable it - assert(self->buf[0] & 0x80); - - // "Control frames MAY be injected in the middle of a fragmented message." - // So, they must be processed before data frames (and not alter - // self->ws_flags) - byte frame_type = self->buf[0]; - self->last_flags = frame_type; - frame_type &= FRAME_OPCODE_MASK; - - if ((self->buf[0] & FRAME_OPCODE_MASK) == FRAME_CONT) { - // Preserve previous frame type - self->ws_flags = (self->ws_flags & FRAME_OPCODE_MASK) | (self->buf[0] & ~FRAME_OPCODE_MASK); - } else { - self->ws_flags = self->buf[0]; - } - - // Reset mask in case someone will use "simplified" protocol - // without masks. - memset(self->mask, 0, sizeof(self->mask)); - - int to_recv = 0; - size_t sz = self->buf[1] & 0x7f; - if (sz == 126) { - // Msg size is next 2 bytes - to_recv += 2; - } else if (sz == 127) { - // Msg size is next 8 bytes - assert(0); - } - if (self->buf[1] & 0x80) { - // Next 4 bytes is mask - to_recv += 4; - } - - self->buf_pos = 0; - self->to_recv = to_recv; - self->msg_sz = sz; // May be overridden by FRAME_OPT - if (to_recv != 0) { - self->state = FRAME_OPT; - } else { - if (frame_type >= FRAME_CLOSE) { - self->state = CONTROL; - } else { - self->state = PAYLOAD; - } - } - continue; - } - - case FRAME_OPT: { - if ((self->buf_pos & 3) == 2) { - // First two bytes are message length - self->msg_sz = (self->buf[0] << 8) | self->buf[1]; - } - if (self->buf_pos >= 4) { - // Last 4 bytes is mask - memcpy(self->mask, self->buf + self->buf_pos - 4, 4); - } - self->buf_pos = 0; - if ((self->last_flags & FRAME_OPCODE_MASK) >= FRAME_CLOSE) { - self->state = CONTROL; - } else { - self->state = PAYLOAD; - } - continue; - } - - case PAYLOAD: - case CONTROL: { - mp_uint_t out_sz = 0; - if (self->msg_sz == 0) { - // In case message had zero payload - goto no_payload; - } - - size_t sz = MIN(size, self->msg_sz); - out_sz = stream_p->read(self->sock, buf, sz, errcode); - if (out_sz == 0 || out_sz == MP_STREAM_ERROR) { - return out_sz; - } - - sz = out_sz; - for (byte *p = buf; sz--; p++) { - *p ^= self->mask[self->mask_pos++ & 3]; - } - - self->msg_sz -= out_sz; - if (self->msg_sz == 0) { - byte last_state; -no_payload: - last_state = self->state; - self->state = FRAME_HEADER; - self->to_recv = 2; - self->mask_pos = 0; - self->buf_pos = 0; - - // Handle control frame - if (last_state == CONTROL) { - byte frame_type = self->last_flags & FRAME_OPCODE_MASK; - if (frame_type == FRAME_CLOSE) { - static char close_resp[2] = {0x88, 0}; - int err; - websocket_write(self_in, close_resp, sizeof(close_resp), &err); - return 0; - } - - //DEBUG_printf("Finished receiving ctrl message %x, ignoring\n", self->last_flags); - continue; - } - } - - if (out_sz != 0) { - return out_sz; - } - // Empty (data) frame received is not EOF - continue; - } - - } - } -} - -STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); - assert(size < 0x10000); - byte header[4] = {0x80 | (self->opts & FRAME_OPCODE_MASK)}; - int hdr_sz; - if (size < 126) { - header[1] = size; - hdr_sz = 2; - } else { - header[1] = 126; - header[2] = size >> 8; - header[3] = size & 0xff; - hdr_sz = 4; - } - - mp_obj_t dest[3]; - if (self->opts & BLOCKING_WRITE) { - mp_load_method(self->sock, MP_QSTR_setblocking, dest); - dest[2] = mp_const_true; - mp_call_method_n_kw(1, 0, dest); - } - - mp_uint_t out_sz = mp_stream_write_exactly(self->sock, header, hdr_sz, errcode); - if (*errcode == 0) { - out_sz = mp_stream_write_exactly(self->sock, buf, size, errcode); - } - - if (self->opts & BLOCKING_WRITE) { - dest[2] = mp_const_false; - mp_call_method_n_kw(1, 0, dest); - } - - if (*errcode != 0) { - return MP_STREAM_ERROR; - } - return out_sz; -} - -STATIC mp_uint_t websocket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { - mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); - switch (request) { - case MP_STREAM_GET_DATA_OPTS: - return self->ws_flags & FRAME_OPCODE_MASK; - case MP_STREAM_SET_DATA_OPTS: { - int cur = self->opts & FRAME_OPCODE_MASK; - self->opts = (self->opts & ~FRAME_OPCODE_MASK) | (arg & FRAME_OPCODE_MASK); - return cur; - } - default: - *errcode = MP_EINVAL; - return MP_STREAM_ERROR; - } -} - -STATIC mp_obj_t websocket_close(mp_obj_t self_in) { - mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in); - // TODO: Send close signaling to the other side, otherwise it's - // abrupt close (connection abort). - return mp_stream_close(self->sock); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(websocket_close_obj, websocket_close); - -STATIC const mp_rom_map_elem_t websocket_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&mp_stream_ioctl_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&websocket_close_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table); - -STATIC const mp_stream_p_t websocket_stream_p = { - .read = websocket_read, - .write = websocket_write, - .ioctl = websocket_ioctl, -}; - -STATIC const mp_obj_type_t websocket_type = { - { &mp_type_type }, - .name = MP_QSTR_websocket, - .make_new = websocket_make_new, - .protocol = &websocket_stream_p, - .locals_dict = (void*)&websocket_locals_dict, -}; - -STATIC const mp_rom_map_elem_t websocket_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_websocket) }, - { MP_ROM_QSTR(MP_QSTR_websocket), MP_ROM_PTR(&websocket_type) }, -}; - -STATIC MP_DEFINE_CONST_DICT(websocket_module_globals, websocket_module_globals_table); - -const mp_obj_module_t mp_module_websocket = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&websocket_module_globals, -}; - -#endif // MICROPY_PY_WEBSOCKET diff --git a/user/mpy/extmod/modwebsocket.h b/user/mpy/extmod/modwebsocket.h deleted file mode 100644 index 2720147..0000000 --- a/user/mpy/extmod/modwebsocket.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H -#define MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H - -#define FRAME_OPCODE_MASK 0x0f -enum { - FRAME_CONT, FRAME_TXT, FRAME_BIN, - FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG -}; - -#endif // MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H diff --git a/user/mpy/extmod/re1.5/charclass.c b/user/mpy/extmod/re1.5/charclass.c deleted file mode 100644 index 7f6388c..0000000 --- a/user/mpy/extmod/re1.5/charclass.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "re1.5.h" - -int _re1_5_classmatch(const char *pc, const char *sp) -{ - // pc points to "cnt" byte after opcode - int is_positive = (pc[-1] == Class); - int cnt = *pc++; - while (cnt--) { - if (*sp >= *pc && *sp <= pc[1]) return is_positive; - pc += 2; - } - return !is_positive; -} - -int _re1_5_namedclassmatch(const char *pc, const char *sp) -{ - // pc points to name of class - int off = (*pc >> 5) & 1; - if ((*pc | 0x20) == 'd') { - if (!(*sp >= '0' && *sp <= '9')) { - off ^= 1; - } - } else if ((*pc | 0x20) == 's') { - if (!(*sp == ' ' || (*sp >= '\t' && *sp <= '\r'))) { - off ^= 1; - } - } else { // w - if (!((*sp >= 'A' && *sp <= 'Z') || (*sp >= 'a' && *sp <= 'z') || (*sp >= '0' && *sp <= '9') || *sp == '_')) { - off ^= 1; - } - } - return off; -} diff --git a/user/mpy/extmod/re1.5/compilecode.c b/user/mpy/extmod/re1.5/compilecode.c deleted file mode 100644 index e4635f0..0000000 --- a/user/mpy/extmod/re1.5/compilecode.c +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2014 Paul Sokolovsky. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "re1.5.h" - -#define INSERT_CODE(at, num, pc) \ - ((code ? memmove(code + at + num, code + at, pc - at) : (void)0), pc += num) -#define REL(at, to) (to - at - 2) -#define EMIT(at, byte) (code ? (code[at] = byte) : (void)(at)) -#define PC (prog->bytelen) - -static const char *_compilecode(const char *re, ByteProg *prog, int sizecode) -{ - char *code = sizecode ? NULL : prog->insts; - int start = PC; - int term = PC; - int alt_label = 0; - - for (; *re && *re != ')'; re++) { - switch (*re) { - case '\\': - re++; - if (!*re) return NULL; // Trailing backslash - if ((*re | 0x20) == 'd' || (*re | 0x20) == 's' || (*re | 0x20) == 'w') { - term = PC; - EMIT(PC++, NamedClass); - EMIT(PC++, *re); - prog->len++; - break; - } - default: - term = PC; - EMIT(PC++, Char); - EMIT(PC++, *re); - prog->len++; - break; - case '.': - term = PC; - EMIT(PC++, Any); - prog->len++; - break; - case '[': { - int cnt; - term = PC; - re++; - if (*re == '^') { - EMIT(PC++, ClassNot); - re++; - } else { - EMIT(PC++, Class); - } - PC++; // Skip # of pair byte - prog->len++; - for (cnt = 0; *re != ']'; re++, cnt++) { - if (!*re) return NULL; - EMIT(PC++, *re); - if (re[1] == '-') { - re += 2; - } - EMIT(PC++, *re); - } - EMIT(term + 1, cnt); - break; - } - case '(': { - term = PC; - int sub = 0; - int capture = re[1] != '?' || re[2] != ':'; - - if (capture) { - sub = ++prog->sub; - EMIT(PC++, Save); - EMIT(PC++, 2 * sub); - prog->len++; - } else { - re += 2; - } - - re = _compilecode(re + 1, prog, sizecode); - if (re == NULL || *re != ')') return NULL; // error, or no matching paren - - if (capture) { - EMIT(PC++, Save); - EMIT(PC++, 2 * sub + 1); - prog->len++; - } - - break; - } - case '?': - if (PC == term) return NULL; // nothing to repeat - INSERT_CODE(term, 2, PC); - if (re[1] == '?') { - EMIT(term, RSplit); - re++; - } else { - EMIT(term, Split); - } - EMIT(term + 1, REL(term, PC)); - prog->len++; - term = PC; - break; - case '*': - if (PC == term) return NULL; // nothing to repeat - INSERT_CODE(term, 2, PC); - EMIT(PC, Jmp); - EMIT(PC + 1, REL(PC, term)); - PC += 2; - if (re[1] == '?') { - EMIT(term, RSplit); - re++; - } else { - EMIT(term, Split); - } - EMIT(term + 1, REL(term, PC)); - prog->len += 2; - term = PC; - break; - case '+': - if (PC == term) return NULL; // nothing to repeat - if (re[1] == '?') { - EMIT(PC, Split); - re++; - } else { - EMIT(PC, RSplit); - } - EMIT(PC + 1, REL(PC, term)); - PC += 2; - prog->len++; - term = PC; - break; - case '|': - if (alt_label) { - EMIT(alt_label, REL(alt_label, PC) + 1); - } - INSERT_CODE(start, 2, PC); - EMIT(PC++, Jmp); - alt_label = PC++; - EMIT(start, Split); - EMIT(start + 1, REL(start, PC)); - prog->len += 2; - term = PC; - break; - case '^': - EMIT(PC++, Bol); - prog->len++; - term = PC; - break; - case '$': - EMIT(PC++, Eol); - prog->len++; - term = PC; - break; - } - } - - if (alt_label) { - EMIT(alt_label, REL(alt_label, PC) + 1); - } - return re; -} - -int re1_5_sizecode(const char *re) -{ - ByteProg dummyprog = { - // Save 0, Save 1, Match; more bytes for "search" (vs "match") prefix code - .bytelen = 5 + NON_ANCHORED_PREFIX - }; - - if (_compilecode(re, &dummyprog, /*sizecode*/1) == NULL) return -1; - - return dummyprog.bytelen; -} - -int re1_5_compilecode(ByteProg *prog, const char *re) -{ - prog->len = 0; - prog->bytelen = 0; - prog->sub = 0; - - // Add code to implement non-anchored operation ("search"), - // for anchored operation ("match"), this code will be just skipped. - // TODO: Implement search in much more efficient manner - prog->insts[prog->bytelen++] = RSplit; - prog->insts[prog->bytelen++] = 3; - prog->insts[prog->bytelen++] = Any; - prog->insts[prog->bytelen++] = Jmp; - prog->insts[prog->bytelen++] = -5; - prog->len += 3; - - prog->insts[prog->bytelen++] = Save; - prog->insts[prog->bytelen++] = 0; - prog->len++; - - re = _compilecode(re, prog, /*sizecode*/0); - if (re == NULL || *re) return 1; - - prog->insts[prog->bytelen++] = Save; - prog->insts[prog->bytelen++] = 1; - prog->len++; - - prog->insts[prog->bytelen++] = Match; - prog->len++; - - return 0; -} - -#if 0 -int main(int argc, char *argv[]) -{ - int pc = 0; - ByteProg *code = re1_5_compilecode(argv[1]); - re1_5_dumpcode(code); -} -#endif diff --git a/user/mpy/extmod/re1.5/dumpcode.c b/user/mpy/extmod/re1.5/dumpcode.c deleted file mode 100644 index d7781d8..0000000 --- a/user/mpy/extmod/re1.5/dumpcode.c +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 Paul Sokolovsky. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "re1.5.h" - -void re1_5_dumpcode(ByteProg *prog) -{ - int pc = 0; - char *code = prog->insts; - while (pc < prog->bytelen) { - printf("%2d: ", pc); - switch(code[pc++]) { - default: - assert(0); -// re1_5_fatal("printprog"); - case Split: - printf("split %d (%d)\n", pc + (signed char)code[pc] + 1, (signed char)code[pc]); - pc++; - break; - case RSplit: - printf("rsplit %d (%d)\n", pc + (signed char)code[pc] + 1, (signed char)code[pc]); - pc++; - break; - case Jmp: - printf("jmp %d (%d)\n", pc + (signed char)code[pc] + 1, (signed char)code[pc]); - pc++; - break; - case Char: - printf("char %c\n", code[pc++]); - break; - case Any: - printf("any\n"); - break; - case Class: - case ClassNot: { - int num = code[pc]; - printf("class%s %d", (code[pc - 1] == ClassNot ? "not" : ""), num); - pc++; - while (num--) { - printf(" 0x%02x-0x%02x", code[pc], code[pc + 1]); - pc += 2; - } - printf("\n"); - break; - } - case NamedClass: - printf("namedclass %c\n", code[pc++]); - break; - case Match: - printf("match\n"); - break; - case Save: - printf("save %d\n", (unsigned char)code[pc++]); - break; - case Bol: - printf("assert bol\n"); - break; - case Eol: - printf("assert eol\n"); - break; - } - } - printf("Bytes: %d, insts: %d\n", prog->bytelen, prog->len); -} diff --git a/user/mpy/extmod/re1.5/re1.5.h b/user/mpy/extmod/re1.5/re1.5.h deleted file mode 100644 index 815c5d3..0000000 --- a/user/mpy/extmod/re1.5/re1.5.h +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2007-2009 Russ Cox. All Rights Reserved. -// Copyright 2014 Paul Sokolovsky. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#ifndef _RE1_5_REGEXP__H -#define _RE1_5_REGEXP__H - -#include -#include -#include -#include -#include - -#define nil ((void*)0) -#define nelem(x) (sizeof(x)/sizeof((x)[0])) - -typedef struct Regexp Regexp; -typedef struct Prog Prog; -typedef struct ByteProg ByteProg; -typedef struct Inst Inst; -typedef struct Subject Subject; - -struct Regexp -{ - int type; - int n; - int ch; - Regexp *left; - Regexp *right; -}; - -enum /* Regexp.type */ -{ - Alt = 1, - Cat, - Lit, - Dot, - Paren, - Quest, - Star, - Plus, -}; - -Regexp *parse(char*); -Regexp *reg(int type, Regexp *left, Regexp *right); -void printre(Regexp*); -#ifndef re1_5_fatal -void re1_5_fatal(char*); -#endif -void *mal(int); - -struct Prog -{ - Inst *start; - int len; -}; - -struct ByteProg -{ - int bytelen; - int len; - int sub; - char insts[0]; -}; - -struct Inst -{ - int opcode; - int c; - int n; - Inst *x; - Inst *y; - int gen; // global state, oooh! -}; - -enum /* Inst.opcode */ -{ - // Instructions which consume input bytes (and thus fail if none left) - CONSUMERS = 1, - Char = CONSUMERS, - Any, - Class, - ClassNot, - NamedClass, - - ASSERTS = 0x50, - Bol = ASSERTS, - Eol, - - // Instructions which take relative offset as arg - JUMPS = 0x60, - Jmp = JUMPS, - Split, - RSplit, - - // Other (special) instructions - Save = 0x7e, - Match = 0x7f, -}; - -#define inst_is_consumer(inst) ((inst) < ASSERTS) -#define inst_is_jump(inst) ((inst) & 0x70 == JUMPS) - -Prog *compile(Regexp*); -void printprog(Prog*); - -extern int gen; - -enum { - MAXSUB = 20 -}; - -typedef struct Sub Sub; - -struct Sub -{ - int ref; - int nsub; - const char *sub[MAXSUB]; -}; - -Sub *newsub(int n); -Sub *incref(Sub*); -Sub *copy(Sub*); -Sub *update(Sub*, int, const char*); -void decref(Sub*); - -struct Subject { - const char *begin; - const char *end; -}; - - -#define NON_ANCHORED_PREFIX 5 -#define HANDLE_ANCHORED(bytecode, is_anchored) ((is_anchored) ? (bytecode) + NON_ANCHORED_PREFIX : (bytecode)) - -int re1_5_backtrack(ByteProg*, Subject*, const char**, int, int); -int re1_5_pikevm(ByteProg*, Subject*, const char**, int, int); -int re1_5_recursiveloopprog(ByteProg*, Subject*, const char**, int, int); -int re1_5_recursiveprog(ByteProg*, Subject*, const char**, int, int); -int re1_5_thompsonvm(ByteProg*, Subject*, const char**, int, int); - -int re1_5_sizecode(const char *re); -int re1_5_compilecode(ByteProg *prog, const char *re); -void re1_5_dumpcode(ByteProg *prog); -void cleanmarks(ByteProg *prog); -int _re1_5_classmatch(const char *pc, const char *sp); -int _re1_5_namedclassmatch(const char *pc, const char *sp); - -#endif /*_RE1_5_REGEXP__H*/ diff --git a/user/mpy/extmod/re1.5/recursiveloop.c b/user/mpy/extmod/re1.5/recursiveloop.c deleted file mode 100644 index e8fef03..0000000 --- a/user/mpy/extmod/re1.5/recursiveloop.c +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2007-2009 Russ Cox. All Rights Reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "re1.5.h" - -static int -recursiveloop(char *pc, const char *sp, Subject *input, const char **subp, int nsubp) -{ - const char *old; - int off; - - for(;;) { - if(inst_is_consumer(*pc)) { - // If we need to match a character, but there's none left, it's fail - if(sp >= input->end) - return 0; - } - switch(*pc++) { - case Char: - if(*sp != *pc++) - return 0; - case Any: - sp++; - continue; - case Class: - case ClassNot: - if (!_re1_5_classmatch(pc, sp)) - return 0; - pc += *(unsigned char*)pc * 2 + 1; - sp++; - continue; - case NamedClass: - if (!_re1_5_namedclassmatch(pc, sp)) - return 0; - pc++; - sp++; - continue; - case Match: - return 1; - case Jmp: - off = (signed char)*pc++; - pc = pc + off; - continue; - case Split: - off = (signed char)*pc++; - if(recursiveloop(pc, sp, input, subp, nsubp)) - return 1; - pc = pc + off; - continue; - case RSplit: - off = (signed char)*pc++; - if(recursiveloop(pc + off, sp, input, subp, nsubp)) - return 1; - continue; - case Save: - off = (unsigned char)*pc++; - if(off >= nsubp) { - continue; - } - old = subp[off]; - subp[off] = sp; - if(recursiveloop(pc, sp, input, subp, nsubp)) - return 1; - subp[off] = old; - return 0; - case Bol: - if(sp != input->begin) - return 0; - continue; - case Eol: - if(sp != input->end) - return 0; - continue; - } - re1_5_fatal("recursiveloop"); - } -} - -int -re1_5_recursiveloopprog(ByteProg *prog, Subject *input, const char **subp, int nsubp, int is_anchored) -{ - return recursiveloop(HANDLE_ANCHORED(prog->insts, is_anchored), input->begin, input, subp, nsubp); -} diff --git a/user/mpy/extmod/uos_dupterm.c b/user/mpy/extmod/uos_dupterm.c deleted file mode 100644 index 29a62ab..0000000 --- a/user/mpy/extmod/uos_dupterm.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include "py/mpconfig.h" - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/objtuple.h" -#include "py/objarray.h" -#include "py/stream.h" - -#if MICROPY_PY_OS_DUPTERM - -void mp_uos_deactivate(const char *msg, mp_obj_t exc) { - mp_obj_t term = MP_STATE_PORT(term_obj); - MP_STATE_PORT(term_obj) = NULL; - mp_printf(&mp_plat_print, msg); - if (exc != MP_OBJ_NULL) { - mp_obj_print_exception(&mp_plat_print, exc); - } - mp_stream_close(term); -} - -void mp_uos_dupterm_tx_strn(const char *str, size_t len) { - if (MP_STATE_PORT(term_obj) != MP_OBJ_NULL) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t write_m[3]; - mp_load_method(MP_STATE_PORT(term_obj), MP_QSTR_write, write_m); - - mp_obj_array_t *arr = MP_OBJ_TO_PTR(MP_STATE_PORT(dupterm_arr_obj)); - void *org_items = arr->items; - arr->items = (void*)str; - arr->len = len; - write_m[2] = MP_STATE_PORT(dupterm_arr_obj); - mp_call_method_n_kw(1, 0, write_m); - arr = MP_OBJ_TO_PTR(MP_STATE_PORT(dupterm_arr_obj)); - arr->items = org_items; - arr->len = 1; - nlr_pop(); - } else { - mp_uos_deactivate("dupterm: Exception in write() method, deactivating: ", nlr.ret_val); - } - } -} - -STATIC mp_obj_t mp_uos_dupterm(mp_uint_t n_args, const mp_obj_t *args) { - if (n_args == 0) { - if (MP_STATE_PORT(term_obj) == MP_OBJ_NULL) { - return mp_const_none; - } else { - return MP_STATE_PORT(term_obj); - } - } else { - if (args[0] == mp_const_none) { - MP_STATE_PORT(term_obj) = MP_OBJ_NULL; - } else { - MP_STATE_PORT(term_obj) = args[0]; - if (MP_STATE_PORT(dupterm_arr_obj) == MP_OBJ_NULL) { - MP_STATE_PORT(dupterm_arr_obj) = mp_obj_new_bytearray(1, ""); - } - } - return mp_const_none; - } -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj, 0, 1, mp_uos_dupterm); - -#endif diff --git a/user/mpy/extmod/utime_mphal.c b/user/mpy/extmod/utime_mphal.c deleted file mode 100644 index 0fe3a3b..0000000 --- a/user/mpy/extmod/utime_mphal.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 Damien P. George - * Copyright (c) 2016 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_PY_UTIME_MP_HAL - -#include - -#include "py/obj.h" -#include "py/mphal.h" -#include "py/smallint.h" -#include "py/runtime.h" -#include "extmod/utime_mphal.h" - -STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { - #if MICROPY_PY_BUILTINS_FLOAT - mp_hal_delay_ms((mp_uint_t)(1000 * mp_obj_get_float(seconds_o))); - #else - mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o)); - #endif - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep); - -STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) { - mp_int_t ms = mp_obj_get_int(arg); - if (ms > 0) { - mp_hal_delay_ms(ms); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms); - -STATIC mp_obj_t time_sleep_us(mp_obj_t arg) { - mp_int_t us = mp_obj_get_int(arg); - if (us > 0) { - mp_hal_delay_us(us); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj, time_sleep_us); - -STATIC mp_obj_t time_ticks_ms(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj, time_ticks_ms); - -STATIC mp_obj_t time_ticks_us(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj, time_ticks_us); - -STATIC mp_obj_t time_ticks_cpu(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj, time_ticks_cpu); - -STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) { - // we assume that the arguments come from ticks_xx so are small ints - mp_uint_t start = MP_OBJ_SMALL_INT_VALUE(start_in); - mp_uint_t end = MP_OBJ_SMALL_INT_VALUE(end_in); - // Optimized formula avoiding if conditions. We adjust difference "forward", - // wrap it around and adjust back. - mp_int_t diff = ((end - start + MICROPY_PY_UTIME_TICKS_PERIOD / 2) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)) - - MICROPY_PY_UTIME_TICKS_PERIOD / 2; - return MP_OBJ_NEW_SMALL_INT(diff); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_diff_obj, time_ticks_diff); - -STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) { - // we assume that first argument come from ticks_xx so is small int - mp_uint_t ticks = MP_OBJ_SMALL_INT_VALUE(ticks_in); - mp_uint_t delta = mp_obj_get_int(delta_in); - return MP_OBJ_NEW_SMALL_INT((ticks + delta) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj, time_ticks_add); - -#endif // MICROPY_PY_UTIME_MP_HAL diff --git a/user/mpy/extmod/utime_mphal.h b/user/mpy/extmod/utime_mphal.h deleted file mode 100644 index 88a9ed4..0000000 --- a/user/mpy/extmod/utime_mphal.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 Damien P. George - * Copyright (c) 2016 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. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H -#define MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H - -#include "py/obj.h" - -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_utime_ticks_diff_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj); - -#endif // MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H diff --git a/user/mpy/extmod/uzlib/adler32.c b/user/mpy/extmod/uzlib/adler32.c deleted file mode 100644 index 1f17594..0000000 --- a/user/mpy/extmod/uzlib/adler32.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Adler-32 checksum - * - * Copyright (c) 2003 by Joergen Ibsen / Jibz - * All Rights Reserved - * - * http://www.ibsensoftware.com/ - * - * This software is provided 'as-is', without any express - * or implied warranty. In no event will the authors be - * held liable for any damages arising from the use of - * this software. - * - * Permission is granted to anyone to use this software - * for any purpose, including commercial applications, - * and to alter it and redistribute it freely, subject to - * the following restrictions: - * - * 1. The origin of this software must not be - * misrepresented; you must not claim that you - * wrote the original software. If you use this - * software in a product, an acknowledgment in - * the product documentation would be appreciated - * but is not required. - * - * 2. Altered source versions must be plainly marked - * as such, and must not be misrepresented as - * being the original software. - * - * 3. This notice may not be removed or altered from - * any source distribution. - */ - -/* - * Adler-32 algorithm taken from the zlib source, which is - * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler - */ - -#include "tinf.h" - -#define A32_BASE 65521 -#define A32_NMAX 5552 - -uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum /* 1 */) -{ - const unsigned char *buf = (const unsigned char *)data; - - unsigned int s1 = prev_sum & 0xffff; - unsigned int s2 = prev_sum >> 16; - - while (length > 0) - { - int k = length < A32_NMAX ? length : A32_NMAX; - int i; - - for (i = k / 16; i; --i, buf += 16) - { - s1 += buf[0]; s2 += s1; s1 += buf[1]; s2 += s1; - s1 += buf[2]; s2 += s1; s1 += buf[3]; s2 += s1; - s1 += buf[4]; s2 += s1; s1 += buf[5]; s2 += s1; - s1 += buf[6]; s2 += s1; s1 += buf[7]; s2 += s1; - - s1 += buf[8]; s2 += s1; s1 += buf[9]; s2 += s1; - s1 += buf[10]; s2 += s1; s1 += buf[11]; s2 += s1; - s1 += buf[12]; s2 += s1; s1 += buf[13]; s2 += s1; - s1 += buf[14]; s2 += s1; s1 += buf[15]; s2 += s1; - } - - for (i = k % 16; i; --i) { s1 += *buf++; s2 += s1; } - - s1 %= A32_BASE; - s2 %= A32_BASE; - - length -= k; - } - - return (s2 << 16) | s1; -} diff --git a/user/mpy/extmod/uzlib/crc32.c b/user/mpy/extmod/uzlib/crc32.c deleted file mode 100644 index e24c643..0000000 --- a/user/mpy/extmod/uzlib/crc32.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CRC32 checksum - * - * Copyright (c) 1998-2003 by Joergen Ibsen / Jibz - * All Rights Reserved - * - * http://www.ibsensoftware.com/ - * - * This software is provided 'as-is', without any express - * or implied warranty. In no event will the authors be - * held liable for any damages arising from the use of - * this software. - * - * Permission is granted to anyone to use this software - * for any purpose, including commercial applications, - * and to alter it and redistribute it freely, subject to - * the following restrictions: - * - * 1. The origin of this software must not be - * misrepresented; you must not claim that you - * wrote the original software. If you use this - * software in a product, an acknowledgment in - * the product documentation would be appreciated - * but is not required. - * - * 2. Altered source versions must be plainly marked - * as such, and must not be misrepresented as - * being the original software. - * - * 3. This notice may not be removed or altered from - * any source distribution. - */ - -/* - * CRC32 algorithm taken from the zlib source, which is - * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler - */ - -#include "tinf.h" - -static const unsigned int tinf_crc32tab[16] = { - 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, - 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, - 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, - 0xbdbdf21c -}; - -/* crc is previous value for incremental computation, 0xffffffff initially */ -uint32_t uzlib_crc32(const void *data, unsigned int length, uint32_t crc) -{ - const unsigned char *buf = (const unsigned char *)data; - unsigned int i; - - for (i = 0; i < length; ++i) - { - crc ^= buf[i]; - crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); - crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); - } - - // return value suitable for passing in next time, for final value invert it - return crc/* ^ 0xffffffff*/; -} diff --git a/user/mpy/extmod/uzlib/tinf.h b/user/mpy/extmod/uzlib/tinf.h deleted file mode 100644 index 106203a..0000000 --- a/user/mpy/extmod/uzlib/tinf.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) - * - * Copyright (c) 2003 by Joergen Ibsen / Jibz - * All Rights Reserved - * http://www.ibsensoftware.com/ - * - * Copyright (c) 2014-2016 by Paul Sokolovsky - */ - -#ifndef TINF_H_INCLUDED -#define TINF_H_INCLUDED - -#include - -/* calling convention */ -#ifndef TINFCC - #ifdef __WATCOMC__ - #define TINFCC __cdecl - #else - #define TINFCC - #endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* ok status, more data produced */ -#define TINF_OK 0 -/* end of compressed stream reached */ -#define TINF_DONE 1 -#define TINF_DATA_ERROR (-3) -#define TINF_CHKSUM_ERROR (-4) -#define TINF_DICT_ERROR (-5) - -/* checksum types */ -#define TINF_CHKSUM_NONE 0 -#define TINF_CHKSUM_ADLER 1 -#define TINF_CHKSUM_CRC 2 - -/* data structures */ - -typedef struct { - unsigned short table[16]; /* table of code length counts */ - unsigned short trans[288]; /* code -> symbol translation table */ -} TINF_TREE; - -struct TINF_DATA; -typedef struct TINF_DATA { - const unsigned char *source; - /* If source above is NULL, this function will be used to read - next byte from source stream */ - unsigned char (*readSource)(struct TINF_DATA *data); - - unsigned int tag; - unsigned int bitcount; - - /* Buffer start */ - unsigned char *destStart; - /* Buffer total size */ - unsigned int destSize; - /* Current pointer in buffer */ - unsigned char *dest; - /* Remaining bytes in buffer */ - unsigned int destRemaining; - - /* Accumulating checksum */ - unsigned int checksum; - char checksum_type; - - int btype; - int bfinal; - unsigned int curlen; - int lzOff; - unsigned char *dict_ring; - unsigned int dict_size; - unsigned int dict_idx; - - TINF_TREE ltree; /* dynamic length/symbol tree */ - TINF_TREE dtree; /* dynamic distance tree */ -} TINF_DATA; - -#define TINF_PUT(d, c) \ - { \ - *d->dest++ = c; \ - if (d->dict_ring) { d->dict_ring[d->dict_idx++] = c; if (d->dict_idx == d->dict_size) d->dict_idx = 0; } \ - } - -unsigned char TINFCC uzlib_get_byte(TINF_DATA *d); - -/* Decompression API */ - -void TINFCC uzlib_init(void); -void TINFCC uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen); -int TINFCC uzlib_uncompress(TINF_DATA *d); -int TINFCC uzlib_uncompress_chksum(TINF_DATA *d); - -int TINFCC uzlib_zlib_parse_header(TINF_DATA *d); -int TINFCC uzlib_gzip_parse_header(TINF_DATA *d); - -/* Compression API */ - -void TINFCC uzlib_compress(void *data, const uint8_t *src, unsigned slen); - -/* Checksum API */ - -/* prev_sum is previous value for incremental computation, 1 initially */ -uint32_t TINFCC uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum); -/* crc is previous value for incremental computation, 0xffffffff initially */ -uint32_t TINFCC uzlib_crc32(const void *data, unsigned int length, uint32_t crc); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* TINF_H_INCLUDED */ diff --git a/user/mpy/extmod/uzlib/tinfgzip.c b/user/mpy/extmod/uzlib/tinfgzip.c deleted file mode 100644 index f1afdd0..0000000 --- a/user/mpy/extmod/uzlib/tinfgzip.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * tinfgzip - tiny gzip decompressor - * - * Copyright (c) 2003 by Joergen Ibsen / Jibz - * All Rights Reserved - * - * http://www.ibsensoftware.com/ - * - * Copyright (c) 2014-2016 by Paul Sokolovsky - * - * This software is provided 'as-is', without any express - * or implied warranty. In no event will the authors be - * held liable for any damages arising from the use of - * this software. - * - * Permission is granted to anyone to use this software - * for any purpose, including commercial applications, - * and to alter it and redistribute it freely, subject to - * the following restrictions: - * - * 1. The origin of this software must not be - * misrepresented; you must not claim that you - * wrote the original software. If you use this - * software in a product, an acknowledgment in - * the product documentation would be appreciated - * but is not required. - * - * 2. Altered source versions must be plainly marked - * as such, and must not be misrepresented as - * being the original software. - * - * 3. This notice may not be removed or altered from - * any source distribution. - */ - -#include "tinf.h" - -#define FTEXT 1 -#define FHCRC 2 -#define FEXTRA 4 -#define FNAME 8 -#define FCOMMENT 16 - -void tinf_skip_bytes(TINF_DATA *d, int num); -uint16_t tinf_get_uint16(TINF_DATA *d); - -void tinf_skip_bytes(TINF_DATA *d, int num) -{ - while (num--) uzlib_get_byte(d); -} - -uint16_t tinf_get_uint16(TINF_DATA *d) -{ - unsigned int v = uzlib_get_byte(d); - v = (uzlib_get_byte(d) << 8) | v; - return v; -} - -int uzlib_gzip_parse_header(TINF_DATA *d) -{ - unsigned char flg; - - /* -- check format -- */ - - /* check id bytes */ - if (uzlib_get_byte(d) != 0x1f || uzlib_get_byte(d) != 0x8b) return TINF_DATA_ERROR; - - /* check method is deflate */ - if (uzlib_get_byte(d) != 8) return TINF_DATA_ERROR; - - /* get flag byte */ - flg = uzlib_get_byte(d); - - /* check that reserved bits are zero */ - if (flg & 0xe0) return TINF_DATA_ERROR; - - /* -- find start of compressed data -- */ - - /* skip rest of base header of 10 bytes */ - tinf_skip_bytes(d, 6); - - /* skip extra data if present */ - if (flg & FEXTRA) - { - unsigned int xlen = tinf_get_uint16(d); - tinf_skip_bytes(d, xlen); - } - - /* skip file name if present */ - if (flg & FNAME) { while (uzlib_get_byte(d)); } - - /* skip file comment if present */ - if (flg & FCOMMENT) { while (uzlib_get_byte(d)); } - - /* check header crc if present */ - if (flg & FHCRC) - { - /*unsigned int hcrc =*/ tinf_get_uint16(d); - - // TODO: Check! -// if (hcrc != (tinf_crc32(src, start - src) & 0x0000ffff)) -// return TINF_DATA_ERROR; - } - - /* initialize for crc32 checksum */ - d->checksum_type = TINF_CHKSUM_CRC; - d->checksum = ~0; - - return TINF_OK; -} diff --git a/user/mpy/extmod/uzlib/tinflate.c b/user/mpy/extmod/uzlib/tinflate.c deleted file mode 100644 index 58850eb..0000000 --- a/user/mpy/extmod/uzlib/tinflate.c +++ /dev/null @@ -1,551 +0,0 @@ -/* - * tinflate - tiny inflate - * - * Copyright (c) 2003 by Joergen Ibsen / Jibz - * All Rights Reserved - * http://www.ibsensoftware.com/ - * - * Copyright (c) 2014-2016 by Paul Sokolovsky - * - * This software is provided 'as-is', without any express - * or implied warranty. In no event will the authors be - * held liable for any damages arising from the use of - * this software. - * - * Permission is granted to anyone to use this software - * for any purpose, including commercial applications, - * and to alter it and redistribute it freely, subject to - * the following restrictions: - * - * 1. The origin of this software must not be - * misrepresented; you must not claim that you - * wrote the original software. If you use this - * software in a product, an acknowledgment in - * the product documentation would be appreciated - * but is not required. - * - * 2. Altered source versions must be plainly marked - * as such, and must not be misrepresented as - * being the original software. - * - * 3. This notice may not be removed or altered from - * any source distribution. - */ - -#include -#include "tinf.h" - -uint32_t tinf_get_le_uint32(TINF_DATA *d); -uint32_t tinf_get_be_uint32(TINF_DATA *d); - -/* --------------------------------------------------- * - * -- uninitialized global data (static structures) -- * - * --------------------------------------------------- */ - -#ifdef RUNTIME_BITS_TABLES - -/* extra bits and base tables for length codes */ -unsigned char length_bits[30]; -unsigned short length_base[30]; - -/* extra bits and base tables for distance codes */ -unsigned char dist_bits[30]; -unsigned short dist_base[30]; - -#else - -const unsigned char length_bits[30] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, - 5, 5, 5, 5 -}; -const unsigned short length_base[30] = { - 3, 4, 5, 6, 7, 8, 9, 10, - 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, - 131, 163, 195, 227, 258 -}; - -const unsigned char dist_bits[30] = { - 0, 0, 0, 0, 1, 1, 2, 2, - 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, - 11, 11, 12, 12, 13, 13 -}; -const unsigned short dist_base[30] = { - 1, 2, 3, 4, 5, 7, 9, 13, - 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, - 4097, 6145, 8193, 12289, 16385, 24577 -}; - -#endif - -/* special ordering of code length codes */ -const unsigned char clcidx[] = { - 16, 17, 18, 0, 8, 7, 9, 6, - 10, 5, 11, 4, 12, 3, 13, 2, - 14, 1, 15 -}; - -/* ----------------------- * - * -- utility functions -- * - * ----------------------- */ - -#ifdef RUNTIME_BITS_TABLES -/* build extra bits and base tables */ -static void tinf_build_bits_base(unsigned char *bits, unsigned short *base, int delta, int first) -{ - int i, sum; - - /* build bits table */ - for (i = 0; i < delta; ++i) bits[i] = 0; - for (i = 0; i < 30 - delta; ++i) bits[i + delta] = i / delta; - - /* build base table */ - for (sum = first, i = 0; i < 30; ++i) - { - base[i] = sum; - sum += 1 << bits[i]; - } -} -#endif - -/* build the fixed huffman trees */ -static void tinf_build_fixed_trees(TINF_TREE *lt, TINF_TREE *dt) -{ - int i; - - /* build fixed length tree */ - for (i = 0; i < 7; ++i) lt->table[i] = 0; - - lt->table[7] = 24; - lt->table[8] = 152; - lt->table[9] = 112; - - for (i = 0; i < 24; ++i) lt->trans[i] = 256 + i; - for (i = 0; i < 144; ++i) lt->trans[24 + i] = i; - for (i = 0; i < 8; ++i) lt->trans[24 + 144 + i] = 280 + i; - for (i = 0; i < 112; ++i) lt->trans[24 + 144 + 8 + i] = 144 + i; - - /* build fixed distance tree */ - for (i = 0; i < 5; ++i) dt->table[i] = 0; - - dt->table[5] = 32; - - for (i = 0; i < 32; ++i) dt->trans[i] = i; -} - -/* given an array of code lengths, build a tree */ -static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, unsigned int num) -{ - unsigned short offs[16]; - unsigned int i, sum; - - /* clear code length count table */ - for (i = 0; i < 16; ++i) t->table[i] = 0; - - /* scan symbol lengths, and sum code length counts */ - for (i = 0; i < num; ++i) t->table[lengths[i]]++; - - t->table[0] = 0; - - /* compute offset table for distribution sort */ - for (sum = 0, i = 0; i < 16; ++i) - { - offs[i] = sum; - sum += t->table[i]; - } - - /* create code->symbol translation table (symbols sorted by code) */ - for (i = 0; i < num; ++i) - { - if (lengths[i]) t->trans[offs[lengths[i]]++] = i; - } -} - -/* ---------------------- * - * -- decode functions -- * - * ---------------------- */ - -unsigned char uzlib_get_byte(TINF_DATA *d) -{ - if (d->source) { - return *d->source++; - } - return d->readSource(d); -} - -uint32_t tinf_get_le_uint32(TINF_DATA *d) -{ - uint32_t val = 0; - int i; - for (i = 4; i--;) { - val = val >> 8 | uzlib_get_byte(d) << 24; - } - return val; -} - -uint32_t tinf_get_be_uint32(TINF_DATA *d) -{ - uint32_t val = 0; - int i; - for (i = 4; i--;) { - val = val << 8 | uzlib_get_byte(d); - } - return val; -} - -/* get one bit from source stream */ -static int tinf_getbit(TINF_DATA *d) -{ - unsigned int bit; - - /* check if tag is empty */ - if (!d->bitcount--) - { - /* load next tag */ - d->tag = uzlib_get_byte(d); - d->bitcount = 7; - } - - /* shift bit out of tag */ - bit = d->tag & 0x01; - d->tag >>= 1; - - return bit; -} - -/* read a num bit value from a stream and add base */ -static unsigned int tinf_read_bits(TINF_DATA *d, int num, int base) -{ - unsigned int val = 0; - - /* read num bits */ - if (num) - { - unsigned int limit = 1 << (num); - unsigned int mask; - - for (mask = 1; mask < limit; mask *= 2) - if (tinf_getbit(d)) val += mask; - } - - return val + base; -} - -/* given a data stream and a tree, decode a symbol */ -static int tinf_decode_symbol(TINF_DATA *d, TINF_TREE *t) -{ - int sum = 0, cur = 0, len = 0; - - /* get more bits while code value is above sum */ - do { - - cur = 2*cur + tinf_getbit(d); - - ++len; - - sum += t->table[len]; - cur -= t->table[len]; - - } while (cur >= 0); - - return t->trans[sum + cur]; -} - -/* given a data stream, decode dynamic trees from it */ -static void tinf_decode_trees(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) -{ - unsigned char lengths[288+32]; - unsigned int hlit, hdist, hclen; - unsigned int i, num, length; - - /* get 5 bits HLIT (257-286) */ - hlit = tinf_read_bits(d, 5, 257); - - /* get 5 bits HDIST (1-32) */ - hdist = tinf_read_bits(d, 5, 1); - - /* get 4 bits HCLEN (4-19) */ - hclen = tinf_read_bits(d, 4, 4); - - for (i = 0; i < 19; ++i) lengths[i] = 0; - - /* read code lengths for code length alphabet */ - for (i = 0; i < hclen; ++i) - { - /* get 3 bits code length (0-7) */ - unsigned int clen = tinf_read_bits(d, 3, 0); - - lengths[clcidx[i]] = clen; - } - - /* build code length tree, temporarily use length tree */ - tinf_build_tree(lt, lengths, 19); - - /* decode code lengths for the dynamic trees */ - for (num = 0; num < hlit + hdist; ) - { - int sym = tinf_decode_symbol(d, lt); - - switch (sym) - { - case 16: - /* copy previous code length 3-6 times (read 2 bits) */ - { - unsigned char prev = lengths[num - 1]; - for (length = tinf_read_bits(d, 2, 3); length; --length) - { - lengths[num++] = prev; - } - } - break; - case 17: - /* repeat code length 0 for 3-10 times (read 3 bits) */ - for (length = tinf_read_bits(d, 3, 3); length; --length) - { - lengths[num++] = 0; - } - break; - case 18: - /* repeat code length 0 for 11-138 times (read 7 bits) */ - for (length = tinf_read_bits(d, 7, 11); length; --length) - { - lengths[num++] = 0; - } - break; - default: - /* values 0-15 represent the actual code lengths */ - lengths[num++] = sym; - break; - } - } - - /* build dynamic trees */ - tinf_build_tree(lt, lengths, hlit); - tinf_build_tree(dt, lengths + hlit, hdist); -} - -/* ----------------------------- * - * -- block inflate functions -- * - * ----------------------------- */ - -/* given a stream and two trees, inflate a block of data */ -static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) -{ - if (d->curlen == 0) { - unsigned int offs; - int dist; - int sym = tinf_decode_symbol(d, lt); - //printf("huff sym: %02x\n", sym); - - /* literal byte */ - if (sym < 256) { - TINF_PUT(d, sym); - return TINF_OK; - } - - /* end of block */ - if (sym == 256) { - return TINF_DONE; - } - - /* substring from sliding dictionary */ - sym -= 257; - /* possibly get more bits from length code */ - d->curlen = tinf_read_bits(d, length_bits[sym], length_base[sym]); - - dist = tinf_decode_symbol(d, dt); - /* possibly get more bits from distance code */ - offs = tinf_read_bits(d, dist_bits[dist], dist_base[dist]); - if (d->dict_ring) { - if (offs > d->dict_size) { - return TINF_DICT_ERROR; - } - d->lzOff = d->dict_idx - offs; - if (d->lzOff < 0) { - d->lzOff += d->dict_size; - } - } else { - d->lzOff = -offs; - } - } - - /* copy next byte from dict substring */ - if (d->dict_ring) { - TINF_PUT(d, d->dict_ring[d->lzOff]); - if ((unsigned)++d->lzOff == d->dict_size) { - d->lzOff = 0; - } - } else { - d->dest[0] = d->dest[d->lzOff]; - d->dest++; - } - d->curlen--; - return TINF_OK; -} - -/* inflate an uncompressed block of data */ -static int tinf_inflate_uncompressed_block(TINF_DATA *d) -{ - if (d->curlen == 0) { - unsigned int length, invlength; - - /* get length */ - length = uzlib_get_byte(d) + 256 * uzlib_get_byte(d); - /* get one's complement of length */ - invlength = uzlib_get_byte(d) + 256 * uzlib_get_byte(d); - /* check length */ - if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR; - - /* increment length to properly return TINF_DONE below, without - producing data at the same time */ - d->curlen = length + 1; - - /* make sure we start next block on a byte boundary */ - d->bitcount = 0; - } - - if (--d->curlen == 0) { - return TINF_DONE; - } - - unsigned char c = uzlib_get_byte(d); - TINF_PUT(d, c); - return TINF_OK; -} - -/* ---------------------- * - * -- public functions -- * - * ---------------------- */ - -/* initialize global (static) data */ -void uzlib_init(void) -{ -#ifdef RUNTIME_BITS_TABLES - /* build extra bits and base tables */ - tinf_build_bits_base(length_bits, length_base, 4, 3); - tinf_build_bits_base(dist_bits, dist_base, 2, 1); - - /* fix a special case */ - length_bits[28] = 0; - length_base[28] = 258; -#endif -} - -/* initialize decompression structure */ -void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen) -{ - d->bitcount = 0; - d->bfinal = 0; - d->btype = -1; - d->dict_size = dictLen; - d->dict_ring = dict; - d->dict_idx = 0; - d->curlen = 0; -} - -/* inflate next byte of compressed stream */ -int uzlib_uncompress(TINF_DATA *d) -{ - do { - int res; - - /* start a new block */ - if (d->btype == -1) { -next_blk: - /* read final block flag */ - d->bfinal = tinf_getbit(d); - /* read block type (2 bits) */ - d->btype = tinf_read_bits(d, 2, 0); - - //printf("Started new block: type=%d final=%d\n", d->btype, d->bfinal); - - if (d->btype == 1) { - /* build fixed huffman trees */ - tinf_build_fixed_trees(&d->ltree, &d->dtree); - } else if (d->btype == 2) { - /* decode trees from stream */ - tinf_decode_trees(d, &d->ltree, &d->dtree); - } - } - - /* process current block */ - switch (d->btype) - { - case 0: - /* decompress uncompressed block */ - res = tinf_inflate_uncompressed_block(d); - break; - case 1: - case 2: - /* decompress block with fixed/dyanamic huffman trees */ - /* trees were decoded previously, so it's the same routine for both */ - res = tinf_inflate_block_data(d, &d->ltree, &d->dtree); - break; - default: - return TINF_DATA_ERROR; - } - - if (res == TINF_DONE && !d->bfinal) { - /* the block has ended (without producing more data), but we - can't return without data, so start procesing next block */ - goto next_blk; - } - - if (res != TINF_OK) { - return res; - } - - } while (--d->destSize); - - return TINF_OK; -} - -int uzlib_uncompress_chksum(TINF_DATA *d) -{ - int res; - unsigned char *data = d->dest; - - res = uzlib_uncompress(d); - - if (res < 0) return res; - - switch (d->checksum_type) { - - case TINF_CHKSUM_ADLER: - d->checksum = uzlib_adler32(data, d->dest - data, d->checksum); - break; - - case TINF_CHKSUM_CRC: - d->checksum = uzlib_crc32(data, d->dest - data, d->checksum); - break; - } - - if (res == TINF_DONE) { - unsigned int val; - - switch (d->checksum_type) { - - case TINF_CHKSUM_ADLER: - val = tinf_get_be_uint32(d); - if (d->checksum != val) { - return TINF_CHKSUM_ERROR; - } - break; - - case TINF_CHKSUM_CRC: - val = tinf_get_le_uint32(d); - if (~d->checksum != val) { - return TINF_CHKSUM_ERROR; - } - // Uncompressed size. TODO: Check - val = tinf_get_le_uint32(d); - break; - } - } - - return res; -} diff --git a/user/mpy/extmod/uzlib/tinfzlib.c b/user/mpy/extmod/uzlib/tinfzlib.c deleted file mode 100644 index 74fade3..0000000 --- a/user/mpy/extmod/uzlib/tinfzlib.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * tinfzlib - tiny zlib decompressor - * - * Copyright (c) 2003 by Joergen Ibsen / Jibz - * All Rights Reserved - * - * http://www.ibsensoftware.com/ - * - * Copyright (c) 2014-2016 by Paul Sokolovsky - * - * This software is provided 'as-is', without any express - * or implied warranty. In no event will the authors be - * held liable for any damages arising from the use of - * this software. - * - * Permission is granted to anyone to use this software - * for any purpose, including commercial applications, - * and to alter it and redistribute it freely, subject to - * the following restrictions: - * - * 1. The origin of this software must not be - * misrepresented; you must not claim that you - * wrote the original software. If you use this - * software in a product, an acknowledgment in - * the product documentation would be appreciated - * but is not required. - * - * 2. Altered source versions must be plainly marked - * as such, and must not be misrepresented as - * being the original software. - * - * 3. This notice may not be removed or altered from - * any source distribution. - */ - -#include "tinf.h" - -int uzlib_zlib_parse_header(TINF_DATA *d) -{ - unsigned char cmf, flg; - - /* -- get header bytes -- */ - - cmf = uzlib_get_byte(d); - flg = uzlib_get_byte(d); - - /* -- check format -- */ - - /* check checksum */ - if ((256*cmf + flg) % 31) return TINF_DATA_ERROR; - - /* check method is deflate */ - if ((cmf & 0x0f) != 8) return TINF_DATA_ERROR; - - /* check window size is valid */ - if ((cmf >> 4) > 7) return TINF_DATA_ERROR; - - /* check there is no preset dictionary */ - if (flg & 0x20) return TINF_DATA_ERROR; - - /* initialize for adler32 checksum */ - d->checksum_type = TINF_CHKSUM_ADLER; - d->checksum = 1; - - return cmf >> 4; -} diff --git a/user/mpy/extmod/vfs.c b/user/mpy/extmod/vfs.c deleted file mode 100644 index 3bdce80..0000000 --- a/user/mpy/extmod/vfs.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/objstr.h" -#include "py/mperrno.h" -#include "extmod/vfs.h" - -#if MICROPY_VFS - -#if MICROPY_VFS_FAT -#include "extmod/vfs_fat.h" -#endif - -// path is the path to lookup and *path_out holds the path within the VFS -// object (starts with / if an absolute path). -// Returns MP_VFS_ROOT for root dir (and then path_out is undefined) and -// MP_VFS_NONE for path not found. -mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out) { - if (*path == '/' || MP_STATE_VM(vfs_cur) == MP_VFS_ROOT) { - // an absolute path, or the current volume is root, so search root dir - bool is_abs = 0; - if (*path == '/') { - ++path; - is_abs = 1; - } - if (*path == '\0') { - // path is "" or "/" so return virtual root - return MP_VFS_ROOT; - } - for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { - size_t len = vfs->len - 1; - if (len == 0) { - *path_out = path - is_abs; - return vfs; - } - if (strncmp(path, vfs->str + 1, len) == 0) { - if (path[len] == '/') { - *path_out = path + len; - return vfs; - } else if (path[len] == '\0') { - *path_out = "/"; - return vfs; - } - } - } - - // if we get here then there's nothing mounted on / - - if (is_abs) { - // path began with / and was not found - return MP_VFS_NONE; - } - } - - // a relative path within a mounted device - *path_out = path; - return MP_STATE_VM(vfs_cur); -} - -// Version of mp_vfs_lookup_path that takes and returns uPy string objects. -STATIC mp_vfs_mount_t *lookup_path(mp_obj_t path_in, mp_obj_t *path_out) { - const char *path = mp_obj_str_get_str(path_in); - const char *p_out; - mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &p_out); - if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) { - *path_out = mp_obj_new_str_of_type(mp_obj_get_type(path_in), - (const byte*)p_out, strlen(p_out)); - } - return vfs; -} - -STATIC mp_obj_t mp_vfs_proxy_call(mp_vfs_mount_t *vfs, qstr meth_name, size_t n_args, const mp_obj_t *args) { - if (vfs == MP_VFS_NONE) { - // mount point not found - mp_raise_OSError(MP_ENODEV); - } - if (vfs == MP_VFS_ROOT) { - // can't do operation on root dir - mp_raise_OSError(MP_EPERM); - } - mp_obj_t meth[n_args + 2]; - mp_load_method(vfs->obj, meth_name, meth); - if (args != NULL) { - memcpy(meth + 2, args, n_args * sizeof(*args)); - } - return mp_call_method_n_kw(n_args, 0, meth); -} - -mp_import_stat_t mp_vfs_import_stat(const char *path) { - const char *path_out; - mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &path_out); - if (vfs == MP_VFS_NONE || vfs == MP_VFS_ROOT) { - return MP_IMPORT_STAT_NO_EXIST; - } - #if MICROPY_VFS_FAT - // fast paths for known VFS types - if (mp_obj_get_type(vfs->obj) == &mp_fat_vfs_type) { - return fat_vfs_import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out); - } - #endif - // TODO delegate to vfs.stat() method - return MP_IMPORT_STAT_NO_EXIST; -} - -mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_readonly, ARG_mkfs }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_false} }, - { MP_QSTR_mkfs, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_false} }, - }; - - // parse args - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - // get the mount point - size_t mnt_len; - const char *mnt_str = mp_obj_str_get_data(pos_args[1], &mnt_len); - - // see if we need to auto-detect and create the filesystem - mp_obj_t vfs_obj = pos_args[0]; - mp_obj_t dest[2]; - mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest); - if (dest[0] == MP_OBJ_NULL) { - // Input object has no mount method, assume it's a block device and try to - // auto-detect the filesystem and create the corresponding VFS entity. - // (At the moment we only support FAT filesystems.) - #if MICROPY_VFS_FAT - vfs_obj = mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &vfs_obj); - #endif - } - - // create new object - mp_vfs_mount_t *vfs = m_new_obj(mp_vfs_mount_t); - vfs->str = mnt_str; - vfs->len = mnt_len; - vfs->obj = vfs_obj; - vfs->next = NULL; - - // call the underlying object to do any mounting operation - mp_vfs_proxy_call(vfs, MP_QSTR_mount, 2, (mp_obj_t*)&args); - - // check that the destination mount point is unused - const char *path_out; - mp_vfs_mount_t *existing_mount = mp_vfs_lookup_path(mp_obj_str_get_str(pos_args[1]), &path_out); - if (existing_mount != MP_VFS_NONE && existing_mount != MP_VFS_ROOT) { - if (vfs->len != 1 && existing_mount->len == 1) { - // if root dir is mounted, still allow to mount something within a subdir of root - } else { - // mount point in use - mp_raise_OSError(MP_EPERM); - } - } - - // insert the vfs into the mount table - mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); - while (*vfsp != NULL) { - if ((*vfsp)->len == 1) { - // make sure anything mounted at the root stays at the end of the list - vfs->next = *vfsp; - break; - } - vfsp = &(*vfsp)->next; - } - *vfsp = vfs; - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_mount_obj, 2, mp_vfs_mount); - -mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) { - // remove vfs from the mount table - mp_vfs_mount_t *vfs = NULL; - size_t mnt_len; - const char *mnt_str = NULL; - if (MP_OBJ_IS_STR(mnt_in)) { - mnt_str = mp_obj_str_get_data(mnt_in, &mnt_len); - } - for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) { - if ((mnt_str != NULL && !memcmp(mnt_str, (*vfsp)->str, mnt_len + 1)) || (*vfsp)->obj == mnt_in) { - vfs = *vfsp; - *vfsp = (*vfsp)->next; - break; - } - } - - if (vfs == NULL) { - mp_raise_OSError(MP_EINVAL); - } - - // if we unmounted the current device then set current to root - if (MP_STATE_VM(vfs_cur) == vfs) { - MP_STATE_VM(vfs_cur) = MP_VFS_ROOT; - } - - // call the underlying object to do any unmounting operation - mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL); - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_umount_obj, mp_vfs_umount); - -// Note: buffering and encoding args are currently ignored -mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_file, ARG_mode, ARG_encoding }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - { MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} }, - { MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} }, - { MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - }; - - // parse args - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - mp_vfs_mount_t *vfs = lookup_path((mp_obj_t)args[ARG_file].u_rom_obj, &args[ARG_file].u_obj); - return mp_vfs_proxy_call(vfs, MP_QSTR_open, 2, (mp_obj_t*)&args); -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_open_obj, 0, mp_vfs_open); - -mp_obj_t mp_vfs_chdir(mp_obj_t path_in) { - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - MP_STATE_VM(vfs_cur) = vfs; - if (vfs == MP_VFS_ROOT) { - // If we change to the root dir and a VFS is mounted at the root then - // we must change that VFS's current dir to the root dir so that any - // subsequent relative paths begin at the root of that VFS. - for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { - if (vfs->len == 1) { - mp_obj_t root = mp_obj_new_str("/", 1, false); - mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &root); - break; - } - } - } else { - mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &path_out); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj, mp_vfs_chdir); - -mp_obj_t mp_vfs_getcwd(void) { - if (MP_STATE_VM(vfs_cur) == MP_VFS_ROOT) { - return MP_OBJ_NEW_QSTR(MP_QSTR__slash_); - } - mp_obj_t cwd_o = mp_vfs_proxy_call(MP_STATE_VM(vfs_cur), MP_QSTR_getcwd, 0, NULL); - if (MP_STATE_VM(vfs_cur)->len == 1) { - // don't prepend "/" for vfs mounted at root - return cwd_o; - } - const char *cwd = mp_obj_str_get_str(cwd_o); - vstr_t vstr; - vstr_init(&vstr, MP_STATE_VM(vfs_cur)->len + strlen(cwd) + 1); - vstr_add_strn(&vstr, MP_STATE_VM(vfs_cur)->str, MP_STATE_VM(vfs_cur)->len); - if (!(cwd[0] == '/' && cwd[1] == 0)) { - vstr_add_str(&vstr, cwd); - } - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd); - -typedef struct _mp_vfs_ilistdir_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - union { - mp_vfs_mount_t *vfs; - mp_obj_t iter; - } cur; - bool is_str; - bool is_iter; -} mp_vfs_ilistdir_it_t; - -STATIC mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) { - mp_vfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); - if (self->is_iter) { - // continue delegating to root dir - return mp_iternext(self->cur.iter); - } else if (self->cur.vfs == NULL) { - // finished iterating mount points and no root dir is mounted - return MP_OBJ_STOP_ITERATION; - } else { - // continue iterating mount points - mp_vfs_mount_t *vfs = self->cur.vfs; - self->cur.vfs = vfs->next; - if (vfs->len == 1) { - // vfs is mounted at root dir, delegate to it - mp_obj_t root = mp_obj_new_str("/", 1, false); - self->is_iter = true; - self->cur.iter = mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &root); - return mp_iternext(self->cur.iter); - } else { - // a mounted directory - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); - t->items[0] = mp_obj_new_str_of_type( - self->is_str ? &mp_type_str : &mp_type_bytes, - (const byte*)vfs->str + 1, vfs->len - 1); - t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); - t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number - return MP_OBJ_FROM_PTR(t); - } - } -} - -mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args) { - mp_obj_t path_in; - if (n_args == 1) { - path_in = args[0]; - } else { - path_in = MP_OBJ_NEW_QSTR(MP_QSTR_); - } - - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - - if (vfs == MP_VFS_ROOT) { - // list the root directory - mp_vfs_ilistdir_it_t *iter = m_new_obj(mp_vfs_ilistdir_it_t); - iter->base.type = &mp_type_polymorph_iter; - iter->iternext = mp_vfs_ilistdir_it_iternext; - iter->cur.vfs = MP_STATE_VM(vfs_mount_table); - iter->is_str = mp_obj_get_type(path_in) == &mp_type_str; - iter->is_iter = false; - return MP_OBJ_FROM_PTR(iter); - } - - return mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &path_out); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj, 0, 1, mp_vfs_ilistdir); - -mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { - mp_obj_t iter = mp_vfs_ilistdir(n_args, args); - mp_obj_t dir_list = mp_obj_new_list(0, NULL); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_t *items; - mp_obj_get_array_fixed_n(next, 3, &items); - mp_obj_list_append(dir_list, items[0]); - } - return dir_list; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj, 0, 1, mp_vfs_listdir); - -mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) { - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - if (vfs == MP_VFS_ROOT || (vfs != MP_VFS_NONE && !strcmp(mp_obj_str_get_str(path_out), "/"))) { - mp_raise_OSError(MP_EEXIST); - } - return mp_vfs_proxy_call(vfs, MP_QSTR_mkdir, 1, &path_out); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj, mp_vfs_mkdir); - -mp_obj_t mp_vfs_remove(mp_obj_t path_in) { - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - return mp_vfs_proxy_call(vfs, MP_QSTR_remove, 1, &path_out); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_remove_obj, mp_vfs_remove); - -mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { - mp_obj_t args[2]; - mp_vfs_mount_t *old_vfs = lookup_path(old_path_in, &args[0]); - mp_vfs_mount_t *new_vfs = lookup_path(new_path_in, &args[1]); - if (old_vfs != new_vfs) { - // can't rename across filesystems - mp_raise_OSError(MP_EPERM); - } - return mp_vfs_proxy_call(old_vfs, MP_QSTR_rename, 2, args); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_vfs_rename_obj, mp_vfs_rename); - -mp_obj_t mp_vfs_rmdir(mp_obj_t path_in) { - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - return mp_vfs_proxy_call(vfs, MP_QSTR_rmdir, 1, &path_out); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj, mp_vfs_rmdir); - -mp_obj_t mp_vfs_stat(mp_obj_t path_in) { - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - if (vfs == MP_VFS_ROOT) { - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); - t->items[0] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); // st_mode - for (int i = 1; i <= 9; ++i) { - t->items[i] = MP_OBJ_NEW_SMALL_INT(0); // dev, nlink, uid, gid, size, atime, mtime, ctime - } - return MP_OBJ_FROM_PTR(t); - } - return mp_vfs_proxy_call(vfs, MP_QSTR_stat, 1, &path_out); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_stat_obj, mp_vfs_stat); - -mp_obj_t mp_vfs_statvfs(mp_obj_t path_in) { - mp_obj_t path_out; - mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - if (vfs == MP_VFS_ROOT) { - // statvfs called on the root directory, see if there's anything mounted there - for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { - if (vfs->len == 1) { - break; - } - } - - // If there's nothing mounted at root then return a mostly-empty tuple - if (vfs == NULL) { - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); - - // fill in: bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flags - for (int i = 0; i <= 8; ++i) { - t->items[i] = MP_OBJ_NEW_SMALL_INT(0); - } - - // Put something sensible in f_namemax - t->items[9] = MP_OBJ_NEW_SMALL_INT(MICROPY_ALLOC_PATH_MAX); - - return MP_OBJ_FROM_PTR(t); - } - - // VFS mounted at root so delegate the call to it - path_out = MP_OBJ_NEW_QSTR(MP_QSTR__slash_); - } - return mp_vfs_proxy_call(vfs, MP_QSTR_statvfs, 1, &path_out); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj, mp_vfs_statvfs); - -#endif // MICROPY_VFS diff --git a/user/mpy/extmod/vfs.h b/user/mpy/extmod/vfs.h deleted file mode 100644 index f2efdbe..0000000 --- a/user/mpy/extmod/vfs.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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_EXTMOD_VFS_H -#define MICROPY_INCLUDED_EXTMOD_VFS_H - -#include "py/lexer.h" -#include "py/obj.h" - -// return values of mp_vfs_lookup_path -// ROOT is 0 so that the default current directory is the root directory -#define MP_VFS_NONE ((mp_vfs_mount_t*)1) -#define MP_VFS_ROOT ((mp_vfs_mount_t*)0) - -// MicroPython's port-standardized versions of stat constants -#define MP_S_IFDIR (0x4000) -#define MP_S_IFREG (0x8000) - -// constants for block protocol ioctl -#define BP_IOCTL_INIT (1) -#define BP_IOCTL_DEINIT (2) -#define BP_IOCTL_SYNC (3) -#define BP_IOCTL_SEC_COUNT (4) -#define BP_IOCTL_SEC_SIZE (5) - -typedef struct _mp_vfs_mount_t { - const char *str; // mount point with leading / - size_t len; - mp_obj_t obj; - struct _mp_vfs_mount_t *next; -} mp_vfs_mount_t; - -mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); -mp_import_stat_t mp_vfs_import_stat(const char *path); -mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -mp_obj_t mp_vfs_umount(mp_obj_t mnt_in); -mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -mp_obj_t mp_vfs_chdir(mp_obj_t path_in); -mp_obj_t mp_vfs_getcwd(void); -mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_vfs_mkdir(mp_obj_t path_in); -mp_obj_t mp_vfs_remove(mp_obj_t path_in); -mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in); -mp_obj_t mp_vfs_rmdir(mp_obj_t path_in); -mp_obj_t mp_vfs_stat(mp_obj_t path_in); -mp_obj_t mp_vfs_statvfs(mp_obj_t path_in); - -MP_DECLARE_CONST_FUN_OBJ_KW(mp_vfs_mount_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_umount_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_vfs_open_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_remove_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_vfs_rename_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_stat_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj); - -#endif // MICROPY_INCLUDED_EXTMOD_VFS_H diff --git a/user/mpy/extmod/vfs_fat.c b/user/mpy/extmod/vfs_fat.c deleted file mode 100644 index 0ec3fe6..0000000 --- a/user/mpy/extmod/vfs_fat.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Damien P. George - * Copyright (c) 2016 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_VFS_FAT - -#if !MICROPY_VFS -#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS" -#endif - -#include -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/mperrno.h" -#include "lib/oofatfs/ff.h" -#include "extmod/vfs_fat.h" -#include "lib/timeutils/timeutils.h" - -#if _MAX_SS == _MIN_SS -#define SECSIZE(fs) (_MIN_SS) -#else -#define SECSIZE(fs) ((fs)->ssize) -#endif - -#define mp_obj_fat_vfs_t fs_user_mount_t - -STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 1, false); - - // create new object - fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t); - vfs->base.type = type; - vfs->flags = FSUSER_FREE_OBJ; - vfs->fatfs.drv = vfs; - - // load block protocol methods - mp_load_method(args[0], MP_QSTR_readblocks, vfs->readblocks); - mp_load_method_maybe(args[0], MP_QSTR_writeblocks, vfs->writeblocks); - mp_load_method_maybe(args[0], MP_QSTR_ioctl, vfs->u.ioctl); - if (vfs->u.ioctl[0] != MP_OBJ_NULL) { - // device supports new block protocol, so indicate it - vfs->flags |= FSUSER_HAVE_IOCTL; - } else { - // no ioctl method, so assume the device uses the old block protocol - mp_load_method_maybe(args[0], MP_QSTR_sync, vfs->u.old.sync); - mp_load_method(args[0], MP_QSTR_count, vfs->u.old.count); - } - - return MP_OBJ_FROM_PTR(vfs); -} - -STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) { - // create new object - fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, 0, &bdev_in)); - - // make the filesystem - uint8_t working_buf[_MAX_SS]; - FRESULT res = f_mkfs(&vfs->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_mkfs_fun_obj, fat_vfs_mkfs); -STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(fat_vfs_mkfs_obj, MP_ROM_PTR(&fat_vfs_mkfs_fun_obj)); - -STATIC MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_open_obj, fatfs_builtin_open_self); - -STATIC mp_obj_t fat_vfs_ilistdir_func(size_t n_args, const mp_obj_t *args) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(args[0]); - bool is_str_type = true; - const char *path; - if (n_args == 2) { - if (mp_obj_get_type(args[1]) == &mp_type_bytes) { - is_str_type = false; - } - path = mp_obj_str_get_str(args[1]); - } else { - path = ""; - } - - return fat_vfs_ilistdir2(self, path, is_str_type); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fat_vfs_ilistdir_obj, 1, 2, fat_vfs_ilistdir_func); - -STATIC mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp_int_t attr) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - const char *path = mp_obj_str_get_str(path_in); - - FILINFO fno; - FRESULT res = f_stat(&self->fatfs, path, &fno); - - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - - // check if path is a file or directory - if ((fno.fattrib & AM_DIR) == attr) { - res = f_unlink(&self->fatfs, path); - - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - return mp_const_none; - } else { - mp_raise_OSError(attr ? MP_ENOTDIR : MP_EISDIR); - } -} - -STATIC mp_obj_t fat_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) { - return fat_vfs_remove_internal(vfs_in, path_in, 0); // 0 == file attribute -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_remove_obj, fat_vfs_remove); - -STATIC mp_obj_t fat_vfs_rmdir(mp_obj_t vfs_in, mp_obj_t path_in) { - return fat_vfs_remove_internal(vfs_in, path_in, AM_DIR); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_rmdir_obj, fat_vfs_rmdir); - -STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - const char *old_path = mp_obj_str_get_str(path_in); - const char *new_path = mp_obj_str_get_str(path_out); - FRESULT res = f_rename(&self->fatfs, old_path, new_path); - if (res == FR_EXIST) { - // if new_path exists then try removing it (but only if it's a file) - fat_vfs_remove_internal(vfs_in, path_out, 0); // 0 == file attribute - // try to rename again - res = f_rename(&self->fatfs, old_path, new_path); - } - if (res == FR_OK) { - return mp_const_none; - } else { - mp_raise_OSError(fresult_to_errno_table[res]); - } - -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_rename_obj, fat_vfs_rename); - -STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - const char *path = mp_obj_str_get_str(path_o); - FRESULT res = f_mkdir(&self->fatfs, path); - if (res == FR_OK) { - return mp_const_none; - } else { - mp_raise_OSError(fresult_to_errno_table[res]); - } -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_mkdir_obj, fat_vfs_mkdir); - -/// Change current directory. -STATIC mp_obj_t fat_vfs_chdir(mp_obj_t vfs_in, mp_obj_t path_in) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - const char *path; - path = mp_obj_str_get_str(path_in); - - FRESULT res = f_chdir(&self->fatfs, path); - - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_chdir_obj, fat_vfs_chdir); - -/// Get the current directory. -STATIC mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - char buf[MICROPY_ALLOC_PATH_MAX + 1]; - FRESULT res = f_getcwd(&self->fatfs, buf, sizeof(buf)); - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - return mp_obj_new_str(buf, strlen(buf), false); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getcwd_obj, fat_vfs_getcwd); - -/// \function stat(path) -/// Get the status of a file or directory. -STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - const char *path = mp_obj_str_get_str(path_in); - - FILINFO fno; - if (path[0] == 0 || (path[0] == '/' && path[1] == 0)) { - // stat root directory - fno.fsize = 0; - fno.fdate = 0x2821; // Jan 1, 2000 - fno.ftime = 0; - fno.fattrib = AM_DIR; - } else { - FRESULT res = f_stat(&self->fatfs, path, &fno); - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - } - - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); - mp_int_t mode = 0; - if (fno.fattrib & AM_DIR) { - mode |= MP_S_IFDIR; - } else { - mode |= MP_S_IFREG; - } - mp_int_t seconds = timeutils_seconds_since_2000( - 1980 + ((fno.fdate >> 9) & 0x7f), - (fno.fdate >> 5) & 0x0f, - fno.fdate & 0x1f, - (fno.ftime >> 11) & 0x1f, - (fno.ftime >> 5) & 0x3f, - 2 * (fno.ftime & 0x1f) - ); - t->items[0] = MP_OBJ_NEW_SMALL_INT(mode); // st_mode - t->items[1] = MP_OBJ_NEW_SMALL_INT(0); // st_ino - t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // st_dev - t->items[3] = MP_OBJ_NEW_SMALL_INT(0); // st_nlink - t->items[4] = MP_OBJ_NEW_SMALL_INT(0); // st_uid - t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // st_gid - t->items[6] = MP_OBJ_NEW_SMALL_INT(fno.fsize); // st_size - t->items[7] = MP_OBJ_NEW_SMALL_INT(seconds); // st_atime - t->items[8] = MP_OBJ_NEW_SMALL_INT(seconds); // st_mtime - t->items[9] = MP_OBJ_NEW_SMALL_INT(seconds); // st_ctime - - return MP_OBJ_FROM_PTR(t); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_stat_obj, fat_vfs_stat); - -// Get the status of a VFS. -STATIC mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) { - mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); - (void)path_in; - - DWORD nclst; - FATFS *fatfs = &self->fatfs; - FRESULT res = f_getfree(fatfs, &nclst); - if (FR_OK != res) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); - - t->items[0] = MP_OBJ_NEW_SMALL_INT(fatfs->csize * SECSIZE(fatfs)); // f_bsize - t->items[1] = t->items[0]; // f_frsize - t->items[2] = MP_OBJ_NEW_SMALL_INT((fatfs->n_fatent - 2)); // f_blocks - t->items[3] = MP_OBJ_NEW_SMALL_INT(nclst); // f_bfree - t->items[4] = t->items[3]; // f_bavail - t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // f_files - t->items[6] = MP_OBJ_NEW_SMALL_INT(0); // f_ffree - t->items[7] = MP_OBJ_NEW_SMALL_INT(0); // f_favail - t->items[8] = MP_OBJ_NEW_SMALL_INT(0); // f_flags - t->items[9] = MP_OBJ_NEW_SMALL_INT(_MAX_LFN); // f_namemax - - return MP_OBJ_FROM_PTR(t); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_statvfs_obj, fat_vfs_statvfs); - -STATIC mp_obj_t vfs_fat_mount(mp_obj_t self_in, mp_obj_t readonly, mp_obj_t mkfs) { - fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); - - // Read-only device indicated by writeblocks[0] == MP_OBJ_NULL. - // User can specify read-only device by: - // 1. readonly=True keyword argument - // 2. nonexistent writeblocks method (then writeblocks[0] == MP_OBJ_NULL already) - if (mp_obj_is_true(readonly)) { - self->writeblocks[0] = MP_OBJ_NULL; - } - - // mount the block device - FRESULT res = f_mount(&self->fatfs); - - // check if we need to make the filesystem - if (res == FR_NO_FILESYSTEM && mp_obj_is_true(mkfs)) { - uint8_t working_buf[_MAX_SS]; - res = f_mkfs(&self->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); - } - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(vfs_fat_mount_obj, vfs_fat_mount); - -STATIC mp_obj_t vfs_fat_umount(mp_obj_t self_in) { - fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); - FRESULT res = f_umount(&self->fatfs); - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_umount_obj, vfs_fat_umount); - -STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_mkfs), MP_ROM_PTR(&fat_vfs_mkfs_obj) }, - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&fat_vfs_open_obj) }, - { MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&fat_vfs_ilistdir_obj) }, - { MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&fat_vfs_mkdir_obj) }, - { MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&fat_vfs_rmdir_obj) }, - { MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&fat_vfs_chdir_obj) }, - { MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&fat_vfs_getcwd_obj) }, - { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&fat_vfs_remove_obj) }, - { MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&fat_vfs_rename_obj) }, - { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&fat_vfs_stat_obj) }, - { MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&fat_vfs_statvfs_obj) }, - { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&vfs_fat_mount_obj) }, - { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&fat_vfs_umount_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table); - -const mp_obj_type_t mp_fat_vfs_type = { - { &mp_type_type }, - .name = MP_QSTR_VfsFat, - .make_new = fat_vfs_make_new, - .locals_dict = (mp_obj_dict_t*)&fat_vfs_locals_dict, -}; - -#endif // MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_fat.h b/user/mpy/extmod/vfs_fat.h deleted file mode 100644 index 443e4ed..0000000 --- a/user/mpy/extmod/vfs_fat.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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_EXTMOD_VFS_FAT_H -#define MICROPY_INCLUDED_EXTMOD_VFS_FAT_H - -#include "py/lexer.h" -#include "py/obj.h" -#include "lib/oofatfs/ff.h" -#include "extmod/vfs.h" - -// these are the values for fs_user_mount_t.flags -#define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func -#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount -#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl - -typedef struct _fs_user_mount_t { - mp_obj_base_t base; - uint16_t flags; - mp_obj_t readblocks[4]; - mp_obj_t writeblocks[4]; - // new protocol uses just ioctl, old uses sync (optional) and count - union { - mp_obj_t ioctl[4]; - struct { - mp_obj_t sync[2]; - mp_obj_t count[2]; - } old; - } u; - FATFS fatfs; -} fs_user_mount_t; - -extern const byte fresult_to_errno_table[20]; -extern const mp_obj_type_t mp_fat_vfs_type; - -mp_import_stat_t fat_vfs_import_stat(struct _fs_user_mount_t *vfs, const char *path); -mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj); - -mp_obj_t fat_vfs_ilistdir2(struct _fs_user_mount_t *vfs, const char *path, bool is_str_type); - -#endif // MICROPY_INCLUDED_EXTMOD_VFS_FAT_H diff --git a/user/mpy/extmod/vfs_fat_diskio.c b/user/mpy/extmod/vfs_fat_diskio.c deleted file mode 100644 index ff23c6b..0000000 --- a/user/mpy/extmod/vfs_fat_diskio.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * Original template for this file comes from: - * Low level disk I/O module skeleton for FatFs, (C)ChaN, 2013 - * - * 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_VFS && MICROPY_VFS_FAT - -#include -#include - -#include "py/mphal.h" - -#include "py/runtime.h" -#include "lib/oofatfs/ff.h" -#include "lib/oofatfs/diskio.h" -#include "extmod/vfs_fat.h" - -#if _MAX_SS == _MIN_SS -#define SECSIZE(fs) (_MIN_SS) -#else -#define SECSIZE(fs) ((fs)->ssize) -#endif - -typedef void *bdev_t; -STATIC fs_user_mount_t *disk_get_device(void *bdev) { - return (fs_user_mount_t*)bdev; -} - -/*-----------------------------------------------------------------------*/ -/* Initialize a Drive */ -/*-----------------------------------------------------------------------*/ - -STATIC -DSTATUS disk_initialize ( - bdev_t pdrv /* Physical drive nmuber (0..) */ -) -{ - fs_user_mount_t *vfs = disk_get_device(pdrv); - if (vfs == NULL) { - return STA_NOINIT; - } - - if (vfs->flags & FSUSER_HAVE_IOCTL) { - // new protocol with ioctl; call ioctl(INIT, 0) - vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_INIT); - vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused - mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); - if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) { - // error initialising - return STA_NOINIT; - } - } - - if (vfs->writeblocks[0] == MP_OBJ_NULL) { - return STA_PROTECT; - } else { - return 0; - } -} - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -STATIC -DSTATUS disk_status ( - bdev_t pdrv /* Physical drive nmuber (0..) */ -) -{ - fs_user_mount_t *vfs = disk_get_device(pdrv); - if (vfs == NULL) { - return STA_NOINIT; - } - - if (vfs->writeblocks[0] == MP_OBJ_NULL) { - return STA_PROTECT; - } else { - return 0; - } -} - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - bdev_t pdrv, /* Physical drive nmuber (0..) */ - BYTE *buff, /* Data buffer to store read data */ - DWORD sector, /* Sector address (LBA) */ - UINT count /* Number of sectors to read (1..128) */ -) -{ - fs_user_mount_t *vfs = disk_get_device(pdrv); - if (vfs == NULL) { - return RES_PARERR; - } - - if (vfs->flags & FSUSER_NATIVE) { - mp_uint_t (*f)(uint8_t*, uint32_t, uint32_t) = (void*)(uintptr_t)vfs->readblocks[2]; - if (f(buff, sector, count) != 0) { - return RES_ERROR; - } - } else { - vfs->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); - vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), buff); - mp_call_method_n_kw(2, 0, vfs->readblocks); - // TODO handle error return - } - - return RES_OK; -} - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_write ( - bdev_t pdrv, /* Physical drive nmuber (0..) */ - const BYTE *buff, /* Data to be written */ - DWORD sector, /* Sector address (LBA) */ - UINT count /* Number of sectors to write (1..128) */ -) -{ - fs_user_mount_t *vfs = disk_get_device(pdrv); - if (vfs == NULL) { - return RES_PARERR; - } - - if (vfs->writeblocks[0] == MP_OBJ_NULL) { - // read-only block device - return RES_WRPRT; - } - - if (vfs->flags & FSUSER_NATIVE) { - mp_uint_t (*f)(const uint8_t*, uint32_t, uint32_t) = (void*)(uintptr_t)vfs->writeblocks[2]; - if (f(buff, sector, count) != 0) { - return RES_ERROR; - } - } else { - vfs->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); - vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), (void*)buff); - mp_call_method_n_kw(2, 0, vfs->writeblocks); - // TODO handle error return - } - - return RES_OK; -} - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_ioctl ( - bdev_t pdrv, /* Physical drive nmuber (0..) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - fs_user_mount_t *vfs = disk_get_device(pdrv); - if (vfs == NULL) { - return RES_PARERR; - } - - if (vfs->flags & FSUSER_HAVE_IOCTL) { - // new protocol with ioctl - switch (cmd) { - case CTRL_SYNC: - vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SYNC); - vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused - mp_call_method_n_kw(2, 0, vfs->u.ioctl); - return RES_OK; - - case GET_SECTOR_COUNT: { - vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SEC_COUNT); - vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused - mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); - *((DWORD*)buff) = mp_obj_get_int(ret); - return RES_OK; - } - - case GET_SECTOR_SIZE: { - vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SEC_SIZE); - vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused - mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); - if (ret == mp_const_none) { - // Default sector size - *((WORD*)buff) = 512; - } else { - *((WORD*)buff) = mp_obj_get_int(ret); - } - #if _MAX_SS != _MIN_SS - // need to store ssize because we use it in disk_read/disk_write - vfs->fatfs.ssize = *((WORD*)buff); - #endif - return RES_OK; - } - - case GET_BLOCK_SIZE: - *((DWORD*)buff) = 1; // erase block size in units of sector size - return RES_OK; - - case IOCTL_INIT: - *((DSTATUS*)buff) = disk_initialize(pdrv); - return RES_OK; - - case IOCTL_STATUS: - *((DSTATUS*)buff) = disk_status(pdrv); - return RES_OK; - - default: - return RES_PARERR; - } - } else { - // old protocol with sync and count - switch (cmd) { - case CTRL_SYNC: - if (vfs->u.old.sync[0] != MP_OBJ_NULL) { - mp_call_method_n_kw(0, 0, vfs->u.old.sync); - } - return RES_OK; - - case GET_SECTOR_COUNT: { - mp_obj_t ret = mp_call_method_n_kw(0, 0, vfs->u.old.count); - *((DWORD*)buff) = mp_obj_get_int(ret); - return RES_OK; - } - - case GET_SECTOR_SIZE: - *((WORD*)buff) = 512; // old protocol had fixed sector size - #if _MAX_SS != _MIN_SS - // need to store ssize because we use it in disk_read/disk_write - vfs->fatfs.ssize = 512; - #endif - return RES_OK; - - case GET_BLOCK_SIZE: - *((DWORD*)buff) = 1; // erase block size in units of sector size - return RES_OK; - - case IOCTL_INIT: - *((DSTATUS*)buff) = disk_initialize(pdrv); - return RES_OK; - - case IOCTL_STATUS: - *((DSTATUS*)buff) = disk_status(pdrv); - return RES_OK; - - default: - return RES_PARERR; - } - } -} - -#endif // MICROPY_VFS && MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_fat_file.c b/user/mpy/extmod/vfs_fat_file.c deleted file mode 100644 index 8fb48f0..0000000 --- a/user/mpy/extmod/vfs_fat_file.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_VFS && MICROPY_VFS_FAT - -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/stream.h" -#include "py/mperrno.h" -#include "lib/oofatfs/ff.h" -#include "extmod/vfs_fat.h" - -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio - -extern const mp_obj_type_t mp_type_fileio; -extern const mp_obj_type_t mp_type_textio; - -// this table converts from FRESULT to POSIX errno -const byte fresult_to_errno_table[20] = { - [FR_OK] = 0, - [FR_DISK_ERR] = MP_EIO, - [FR_INT_ERR] = MP_EIO, - [FR_NOT_READY] = MP_EBUSY, - [FR_NO_FILE] = MP_ENOENT, - [FR_NO_PATH] = MP_ENOENT, - [FR_INVALID_NAME] = MP_EINVAL, - [FR_DENIED] = MP_EACCES, - [FR_EXIST] = MP_EEXIST, - [FR_INVALID_OBJECT] = MP_EINVAL, - [FR_WRITE_PROTECTED] = MP_EROFS, - [FR_INVALID_DRIVE] = MP_ENODEV, - [FR_NOT_ENABLED] = MP_ENODEV, - [FR_NO_FILESYSTEM] = MP_ENODEV, - [FR_MKFS_ABORTED] = MP_EIO, - [FR_TIMEOUT] = MP_EIO, - [FR_LOCKED] = MP_EIO, - [FR_NOT_ENOUGH_CORE] = MP_ENOMEM, - [FR_TOO_MANY_OPEN_FILES] = MP_EMFILE, - [FR_INVALID_PARAMETER] = MP_EINVAL, -}; - -typedef struct _pyb_file_obj_t { - mp_obj_base_t base; - FIL fp; -} pyb_file_obj_t; - -STATIC void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_printf(print, "", mp_obj_get_type_str(self_in), MP_OBJ_TO_PTR(self_in)); -} - -STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - UINT sz_out; - FRESULT res = f_read(&self->fp, buf, size, &sz_out); - if (res != FR_OK) { - *errcode = fresult_to_errno_table[res]; - return MP_STREAM_ERROR; - } - return sz_out; -} - -STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - UINT sz_out; - FRESULT res = f_write(&self->fp, buf, size, &sz_out); - if (res != FR_OK) { - *errcode = fresult_to_errno_table[res]; - return MP_STREAM_ERROR; - } - if (sz_out != size) { - // The FatFS documentation says that this means disk full. - *errcode = MP_ENOSPC; - return MP_STREAM_ERROR; - } - return sz_out; -} - - -STATIC mp_obj_t file_obj_close(mp_obj_t self_in) { - pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - // if fs==NULL then the file is closed and in that case this method is a no-op - if (self->fp.obj.fs != NULL) { - FRESULT res = f_close(&self->fp); - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(file_obj_close_obj, file_obj_close); - -STATIC mp_obj_t file_obj___exit__(size_t n_args, const mp_obj_t *args) { - (void)n_args; - return file_obj_close(args[0]); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(file_obj___exit___obj, 4, 4, file_obj___exit__); - -STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { - pyb_file_obj_t *self = MP_OBJ_TO_PTR(o_in); - - if (request == MP_STREAM_SEEK) { - struct mp_stream_seek_t *s = (struct mp_stream_seek_t*)(uintptr_t)arg; - - switch (s->whence) { - case 0: // SEEK_SET - f_lseek(&self->fp, s->offset); - break; - - case 1: // SEEK_CUR - if (s->offset != 0) { - *errcode = MP_EOPNOTSUPP; - return MP_STREAM_ERROR; - } - // no-operation - break; - - case 2: // SEEK_END - f_lseek(&self->fp, f_size(&self->fp) + s->offset); - break; - } - - s->offset = f_tell(&self->fp); - return 0; - - } else if (request == MP_STREAM_FLUSH) { - FRESULT res = f_sync(&self->fp); - if (res != FR_OK) { - *errcode = fresult_to_errno_table[res]; - return MP_STREAM_ERROR; - } - return 0; - - } else { - *errcode = MP_EINVAL; - return MP_STREAM_ERROR; - } -} - -// Note: encoding is ignored for now; it's also not a valid kwarg for CPython's FileIO, -// but by adding it here we can use one single mp_arg_t array for open() and FileIO's constructor -STATIC const mp_arg_t file_open_args[] = { - { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - { MP_QSTR_mode, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_r)} }, - { MP_QSTR_encoding, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, -}; -#define FILE_OPEN_NUM_ARGS MP_ARRAY_SIZE(file_open_args) - -STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_arg_val_t *args) { - int mode = 0; - const char *mode_s = mp_obj_str_get_str(args[1].u_obj); - // TODO make sure only one of r, w, x, a, and b, t are specified - while (*mode_s) { - switch (*mode_s++) { - case 'r': - mode |= FA_READ; - break; - case 'w': - mode |= FA_WRITE | FA_CREATE_ALWAYS; - break; - case 'x': - mode |= FA_WRITE | FA_CREATE_NEW; - break; - case 'a': - mode |= FA_WRITE | FA_OPEN_ALWAYS; - break; - case '+': - mode |= FA_READ | FA_WRITE; - break; - #if MICROPY_PY_IO_FILEIO - case 'b': - type = &mp_type_fileio; - break; - #endif - case 't': - type = &mp_type_textio; - break; - } - } - - pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); - o->base.type = type; - - const char *fname = mp_obj_str_get_str(args[0].u_obj); - assert(vfs != NULL); - FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); - if (res != FR_OK) { - m_del_obj(pyb_file_obj_t, o); - mp_raise_OSError(fresult_to_errno_table[res]); - } - - // for 'a' mode, we must begin at the end of the file - if ((mode & FA_OPEN_ALWAYS) != 0) { - f_lseek(&o->fp, f_size(&o->fp)); - } - - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; - mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals); - return file_open(NULL, type, arg_vals); -} - -// TODO gc hook to close the file if not already closed - -STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, - { MP_ROM_QSTR(MP_QSTR_readlines), MP_ROM_PTR(&mp_stream_unbuffered_readlines_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&file_obj_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) }, - { MP_ROM_QSTR(MP_QSTR_tell), MP_ROM_PTR(&mp_stream_tell_obj) }, - { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&file_obj_close_obj) }, - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&file_obj___exit___obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); - -#if MICROPY_PY_IO_FILEIO -STATIC const mp_stream_p_t fileio_stream_p = { - .read = file_obj_read, - .write = file_obj_write, - .ioctl = file_obj_ioctl, -}; - -const mp_obj_type_t mp_type_fileio = { - { &mp_type_type }, - .name = MP_QSTR_FileIO, - .print = file_obj_print, - .make_new = file_obj_make_new, - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &fileio_stream_p, - .locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict, -}; -#endif - -STATIC const mp_stream_p_t textio_stream_p = { - .read = file_obj_read, - .write = file_obj_write, - .ioctl = file_obj_ioctl, - .is_text = true, -}; - -const mp_obj_type_t mp_type_textio = { - { &mp_type_type }, - .name = MP_QSTR_TextIOWrapper, - .print = file_obj_print, - .make_new = file_obj_make_new, - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &textio_stream_p, - .locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict, -}; - -// Factory function for I/O stream classes -mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode) { - // TODO: analyze buffering args and instantiate appropriate type - fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; - arg_vals[0].u_obj = path; - arg_vals[1].u_obj = mode; - arg_vals[2].u_obj = mp_const_none; - return file_open(self, &mp_type_textio, arg_vals); -} - -#endif // MICROPY_VFS && MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_fat_misc.c b/user/mpy/extmod/vfs_fat_misc.c deleted file mode 100644 index 7c16db7..0000000 --- a/user/mpy/extmod/vfs_fat_misc.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_VFS_FAT - -#include -#include "py/nlr.h" -#include "py/runtime.h" -#include "lib/oofatfs/ff.h" -#include "extmod/vfs_fat.h" -#include "py/lexer.h" - -typedef struct _mp_vfs_fat_ilistdir_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - bool is_str; - FF_DIR dir; -} mp_vfs_fat_ilistdir_it_t; - -STATIC mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) { - mp_vfs_fat_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); - - for (;;) { - FILINFO fno; - FRESULT res = f_readdir(&self->dir, &fno); - char *fn = fno.fname; - if (res != FR_OK || fn[0] == 0) { - // stop on error or end of dir - break; - } - - // Note that FatFS already filters . and .., so we don't need to - - // make 3-tuple with info about this entry - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); - if (self->is_str) { - t->items[0] = mp_obj_new_str(fn, strlen(fn), false); - } else { - t->items[0] = mp_obj_new_bytes((const byte*)fn, strlen(fn)); - } - if (fno.fattrib & AM_DIR) { - // dir - t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); - } else { - // file - t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFREG); - } - t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number - - return MP_OBJ_FROM_PTR(t); - } - - // ignore error because we may be closing a second time - f_closedir(&self->dir); - - return MP_OBJ_STOP_ITERATION; -} - -mp_obj_t fat_vfs_ilistdir2(fs_user_mount_t *vfs, const char *path, bool is_str_type) { - mp_vfs_fat_ilistdir_it_t *iter = m_new_obj(mp_vfs_fat_ilistdir_it_t); - iter->base.type = &mp_type_polymorph_iter; - iter->iternext = mp_vfs_fat_ilistdir_it_iternext; - iter->is_str = is_str_type; - FRESULT res = f_opendir(&vfs->fatfs, &iter->dir, path); - if (res != FR_OK) { - mp_raise_OSError(fresult_to_errno_table[res]); - } - return MP_OBJ_FROM_PTR(iter); -} - -mp_import_stat_t fat_vfs_import_stat(fs_user_mount_t *vfs, const char *path) { - FILINFO fno; - assert(vfs != NULL); - FRESULT res = f_stat(&vfs->fatfs, path, &fno); - if (res == FR_OK) { - if ((fno.fattrib & AM_DIR) != 0) { - return MP_IMPORT_STAT_DIR; - } else { - return MP_IMPORT_STAT_FILE; - } - } - return MP_IMPORT_STAT_NO_EXIST; -} - -#endif // MICROPY_VFS_FAT diff --git a/user/mpy/extmod/vfs_reader.c b/user/mpy/extmod/vfs_reader.c deleted file mode 100644 index 891098a..0000000 --- a/user/mpy/extmod/vfs_reader.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-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. - */ - -#include -#include - -#include "py/runtime.h" -#include "py/stream.h" -#include "py/reader.h" -#include "extmod/vfs.h" - -#if MICROPY_READER_VFS - -typedef struct _mp_reader_vfs_t { - mp_obj_t file; - uint16_t len; - uint16_t pos; - byte buf[24]; -} mp_reader_vfs_t; - -STATIC mp_uint_t mp_reader_vfs_readbyte(void *data) { - mp_reader_vfs_t *reader = (mp_reader_vfs_t*)data; - if (reader->pos >= reader->len) { - if (reader->len < sizeof(reader->buf)) { - return MP_READER_EOF; - } else { - int errcode; - reader->len = mp_stream_rw(reader->file, reader->buf, sizeof(reader->buf), - &errcode, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); - if (errcode != 0) { - // TODO handle errors properly - return MP_READER_EOF; - } - if (reader->len == 0) { - return MP_READER_EOF; - } - reader->pos = 0; - } - } - return reader->buf[reader->pos++]; -} - -STATIC void mp_reader_vfs_close(void *data) { - mp_reader_vfs_t *reader = (mp_reader_vfs_t*)data; - mp_stream_close(reader->file); - m_del_obj(mp_reader_vfs_t, reader); -} - -void mp_reader_new_file(mp_reader_t *reader, const char *filename) { - mp_reader_vfs_t *rf = m_new_obj(mp_reader_vfs_t); - mp_obj_t arg = mp_obj_new_str(filename, strlen(filename), false); - rf->file = mp_vfs_open(1, &arg, (mp_map_t*)&mp_const_empty_map); - int errcode; - rf->len = mp_stream_rw(rf->file, rf->buf, sizeof(rf->buf), &errcode, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); - if (errcode != 0) { - mp_raise_OSError(errcode); - } - rf->pos = 0; - reader->data = rf; - reader->readbyte = mp_reader_vfs_readbyte; - reader->close = mp_reader_vfs_close; -} - -#endif // MICROPY_READER_VFS diff --git a/user/mpy/extmod/virtpin.c b/user/mpy/extmod/virtpin.c deleted file mode 100644 index dbfa21d..0000000 --- a/user/mpy/extmod/virtpin.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include "extmod/virtpin.h" - -int mp_virtual_pin_read(mp_obj_t pin) { - mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); - mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; - return pin_p->ioctl(pin, MP_PIN_READ, 0, NULL); -} - -void mp_virtual_pin_write(mp_obj_t pin, int value) { - mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); - mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; - pin_p->ioctl(pin, MP_PIN_WRITE, value, NULL); -} diff --git a/user/mpy/extmod/virtpin.h b/user/mpy/extmod/virtpin.h deleted file mode 100644 index 706affc..0000000 --- a/user/mpy/extmod/virtpin.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_VIRTPIN_H -#define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H - -#include "py/obj.h" - -#define MP_PIN_READ (1) -#define MP_PIN_WRITE (2) -#define MP_PIN_INPUT (3) -#define MP_PIN_OUTPUT (4) - -// Pin protocol -typedef struct _mp_pin_p_t { - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); -} mp_pin_p_t; - -int mp_virtual_pin_read(mp_obj_t pin); -void mp_virtual_pin_write(mp_obj_t pin, int value); - -// If a port exposes a Pin object, it's constructor should be like this -mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); - -#endif // MICROPY_INCLUDED_EXTMOD_VIRTPIN_H diff --git a/user/mpy/lib/README.md b/user/mpy/lib/README.md deleted file mode 100644 index e719821..0000000 --- a/user/mpy/lib/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains standard, low-level C libraries with emphasis on -being independent and efficient. They can be used by any port. diff --git a/user/mpy/lib/axtls/.gitignore b/user/mpy/lib/axtls/.gitignore deleted file mode 100644 index f2e3408..0000000 --- a/user/mpy/lib/axtls/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -*.o -_stage -.depend -.config* -config/config.h -config/scripts/config/conf -config/scripts/config/lex.zconf.c -config/scripts/config/lkc_defs.h -config/scripts/config/zconf.tab.c -config/scripts/config/zconf.tab.h -ssl/version.h diff --git a/user/mpy/lib/axtls/Makefile b/user/mpy/lib/axtls/Makefile deleted file mode 100644 index 045e34f..0000000 --- a/user/mpy/lib/axtls/Makefile +++ /dev/null @@ -1,185 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - --include config/.config - -ifneq ($(strip $(HAVE_DOT_CONFIG)),y) -all: menuconfig -else -all: target -endif - -include config/makefile.conf - -target : $(STAGE) $(TARGET) - -# VERSION has to come from the command line -RELEASE=axTLS-$(VERSION) - -# standard version -target: - $(MAKE) -C crypto - $(MAKE) -C ssl -ifdef CONFIG_AXHTTPD - $(MAKE) -C httpd -endif -ifdef CONFIG_AXTLSWRAP - $(MAKE) -C axtlswrap -endif -ifdef CONFIG_BINDINGS - $(MAKE) -C bindings -endif -ifdef CONFIG_SAMPLES - $(MAKE) -C samples -endif - -$(STAGE) : ssl/version.h - @mkdir -p $(STAGE) - -# create a version file with something in it. -ssl/version.h: - @echo "#define AXTLS_VERSION \"(no version)\"" > ssl/version.h - -$(PREFIX) : - @mkdir -p $(PREFIX)/lib - @mkdir -p $(PREFIX)/bin - -release: - $(MAKE) -C config/scripts/config clean - -$(MAKE) clean - -@rm config/*.msi config/*.back.aip config/config.h config/.config* - -@rm www/index.20* - -@rm -fr $(STAGE) - @echo "#define AXTLS_VERSION \"$(VERSION)\"" > ssl/version.h - cd ../; tar cvfz $(RELEASE).tar.gz --wildcards-match-slash --exclude .svn axtls-code; cd -; - -docs: - $(MAKE) -C docsrc doco - -# build the Win32 demo release version -win32_demo: - @echo "#define AXTLS_VERSION \"$(VERSION)\"" > ssl/version.h - $(MAKE) win32releaseconf - -install: $(PREFIX) all - cp --no-dereference $(STAGE)/libax* $(PREFIX)/lib - chmod 755 $(PREFIX)/lib/libax* -ifdef CONFIG_SAMPLES - install -m 755 $(STAGE)/ax* $(PREFIX)/bin -endif -ifdef CONFIG_HTTP_HAS_AUTHORIZATION - install -m 755 $(STAGE)/htpasswd $(PREFIX)/bin -endif -ifdef CONFIG_PLATFORM_CYGWIN - install -m 755 $(STAGE)/cygaxtls.dll $(PREFIX)/bin -endif -ifdef CONFIG_PERL_BINDINGS - install -m 755 $(STAGE)/axtlsp.pm `perl -e 'use Config; print $$Config{installarchlib};'` -endif - @mkdir -p -m 755 $(PREFIX)/include/axTLS - install -m 644 crypto/*.h $(PREFIX)/include/axTLS - install -m 644 ssl/*.h $(PREFIX)/include/axTLS - -rm $(PREFIX)/include/axTLS/cert.h - -rm $(PREFIX)/include/axTLS/private_key.h - install -m 644 config/config.h $(PREFIX)/include/axTLS - -installclean: - -@rm $(PREFIX)/lib/libax* > /dev/null 2>&1 - -@rm $(PREFIX)/bin/ax* > /dev/null 2>&1 - -@rm $(PREFIX)/bin/axhttpd* > /dev/null 2>&1 - -@rm `perl -e 'use Config; print $$Config{installarchlib};'`/axtlsp.pm > /dev/null 2>&1 - -test: - cd $(STAGE); ssltest; ../ssl/test/test_axssl.sh; cd -; - -# tidy up things -clean:: - @cd crypto; $(MAKE) clean - @cd ssl; $(MAKE) clean - @cd httpd; $(MAKE) clean - @cd axtlswrap; $(MAKE) clean - @cd samples; $(MAKE) clean - @cd docsrc; $(MAKE) clean - @cd bindings; $(MAKE) clean - -# --------------------------------------------------------------------------- -# mconf stuff -# --------------------------------------------------------------------------- - -CONFIG_CONFIG_IN = config/Config.in -CONFIG_DEFCONFIG = config/defconfig - -config/scripts/config/conf: config/scripts/config/Makefile - $(MAKE) -C config/scripts/config conf - -@if [ ! -f config/.config ] ; then \ - cp $(CONFIG_DEFCONFIG) config/.config; \ - fi - -config/scripts/config/mconf: config/scripts/config/Makefile - $(MAKE) -C config/scripts/config ncurses conf mconf - -@if [ ! -f config/.config ] ; then \ - cp $(CONFIG_DEFCONFIG) .config; \ - fi - -cleanconf: - $(MAKE) -C config/scripts/config clean - @rm -f config/.config - -menuconfig: config/scripts/config/mconf - @./config/scripts/config/mconf $(CONFIG_CONFIG_IN) - -config: config/scripts/config/conf - @./config/scripts/config/conf $(CONFIG_CONFIG_IN) - -oldconfig: config/scripts/config/conf - @./config/scripts/config/conf -o $(CONFIG_CONFIG_IN) - -default: config/scripts/config/conf - @./config/scripts/config/conf -d $(CONFIG_CONFIG_IN) > /dev/null - $(MAKE) - -randconfig: config/scripts/config/conf - @./config/scripts/config/conf -r $(CONFIG_CONFIG_IN) - -allnoconfig: config/scripts/config/conf - @./config/scripts/config/conf -n $(CONFIG_CONFIG_IN) - -allyesconfig: config/scripts/config/conf - @./config/scripts/config/conf -y $(CONFIG_CONFIG_IN) - -# The special win32 release configuration -win32releaseconf: config/scripts/config/conf - @./config/scripts/config/conf -D config/win32config $(CONFIG_CONFIG_IN) > /dev/null - $(MAKE) - -# The special linux release configuration -linuxconf: config/scripts/config/conf - @./config/scripts/config/conf -D config/linuxconfig $(CONFIG_CONFIG_IN) > /dev/null - $(MAKE) diff --git a/user/mpy/lib/axtls/README b/user/mpy/lib/axtls/README deleted file mode 100644 index c8926d9..0000000 --- a/user/mpy/lib/axtls/README +++ /dev/null @@ -1,3 +0,0 @@ - -See www/index.html for the README, CHANGELOG, LICENSE and other notes. - diff --git a/user/mpy/lib/axtls/axtlswrap/Makefile b/user/mpy/lib/axtls/axtlswrap/Makefile deleted file mode 100755 index b14825a..0000000 --- a/user/mpy/lib/axtls/axtlswrap/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 2009, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -all : sslwrap - -AXTLS_HOME=.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -ifdef CONFIG_PLATFORM_CYGWIN -TARGET=$(AXTLS_HOME)/$(STAGE)/axtlswrap.exe -else # linux -TARGET=$(AXTLS_HOME)/$(STAGE)/axtlswrap -endif - -ifdef CONFIG_HTTP_STATIC_BUILD -LIBS=$(AXTLS_HOME)/$(STAGE)/libaxtls.a -else -LIBS=-L$(AXTLS_HOME)/$(STAGE) -laxtls -endif - -ifndef CONFIG_AXTLSWRAP -sslwrap: -else -sslwrap : $(TARGET) - -OBJ= axtlswrap.o -include $(AXTLS_HOME)/config/makefile.post - -$(TARGET): $(OBJ) $(AXTLS_HOME)/$(STAGE)/libaxtls.a - $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) -ifdef CONFIG_STRIP_UNWANTED_SECTIONS - $(STRIP) --remove-section=.comment $(TARGET) -endif - -endif # CONFIG_AXTLSWRAP - -clean:: - -@rm -f $(TARGET)* - diff --git a/user/mpy/lib/axtls/axtlswrap/axtlswrap.c b/user/mpy/lib/axtls/axtlswrap/axtlswrap.c deleted file mode 100755 index 43b448e..0000000 --- a/user/mpy/lib/axtls/axtlswrap/axtlswrap.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 2009, Steve Bennett - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * sslwrap re-implemented with axTLS - a way to wrap an existing webserver - * with axTLS. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -/* If nothing is received or sent in this many seconds, give up */ -static int opt_timeout = 60; - -static int opt_verbose = 0; - -int main(int argc, char *argv[]) -{ - int log_opts = LOG_PERROR; - int fd[2]; /* output from child */ - int df[2]; /* input to child */ - int pid; - unsigned char *readbuf; - int readlen; - - SSL_CTX *ssl_ctx; - SSL *ssl; - - /* This relies on stdin and stdout being one and the same */ - int sslfd = fileno(stdin); - - while (argc > 2 && argv[1][0] == '-') - { - if (argc > 3 && strcmp(argv[1], "-t") == 0) - { - opt_timeout = atoi(argv[2]); - argv += 2; - argc -= 2; - continue; - } - - if (strcmp(argv[1], "-q") == 0) - { - log_opts = 0; - argv++; - argc--; - continue; - } - - if (strcmp(argv[1], "-v") == 0) - { - opt_verbose++; - argv++; - argc--; - continue; - } - } - - if (argc < 2) - { - fprintf(stderr, "Usage: axtlswrap [-v] [-q] " - "[-t timeout] command ...\n"); - return 1; - } - - if (access(argv[1], X_OK) != 0) - { - fprintf(stderr, "Not an executabled: %s\n", argv[1]); - return 1; - } - - openlog("axtlswrap", LOG_PID | log_opts, LOG_DAEMON); - - /* Create an SSL context with the required options */ - ssl_ctx = ssl_ctx_new(opt_verbose > 1 ? - SSL_DISPLAY_STATES | SSL_DISPLAY_CERTS : 0, 1); - - if (ssl_ctx == NULL) - { - syslog(LOG_ERR, "Failed to create SSL ctx"); - return 1; - } - - /* And create an ssl session attached to sslfd */ - ssl = ssl_server_new(ssl_ctx, sslfd); - if (ssl == NULL) - { - syslog(LOG_ERR, "Failed to create SSL connection"); - return 1; - } - - /* Get past the handshaking */ - while ((readlen = ssl_read(ssl, &readbuf)) == SSL_OK) - { - /* Still handshaking */ - } - - if (readlen < 0) - { - syslog(LOG_ERR, "SSL handshake failed: %d", readlen); - return 1; - } - - if (opt_verbose) - { - syslog(LOG_INFO, "SSL handshake OK"); - } - - /* Looks OK, we have data, so fork the child and start */ - if (pipe(fd) < 0 || pipe(df) < 0) - { - syslog(LOG_ERR, "pipe failed: %m"); - return 1; - } - - /* Give some indication to the child that we are running SSL - * It would be possible to provide other details - * too. Perhaps as in: http://httpd.apache.org/docs/2.0/mod/mod_ssl.html - */ - setenv("SSL_PROTOCOL", "TLSv1", 1); - -#ifndef NOMMU - if (opt_verbose) - { - pid = fork(); - } - else -#endif - pid = vfork(); - if (pid < 0) - { - syslog(LOG_ERR, "vfork failed: %m"); - return 1; - } - - if (pid > 0) - { - /* This is the parent */ - unsigned char writebuf[4096]; - int writelen = 0; - struct pollfd pfd[3]; - int timeout_count = 0; - - int cwfd = df[1]; /* write to child */ - int crfd = fd[0]; /* read from child */ - - int child_alive = 1; - - /* Don't die on SIGPIPE */ - signal(SIGPIPE, SIG_IGN); - - close(df[0]); - close(fd[1]); - - pfd[0].fd = sslfd; - pfd[1].fd = cwfd; - pfd[2].fd = crfd; - - /* While the child is alive or there is something to return... */ - while (child_alive || writelen > 0) - { - /* Work out what to read and what to write */ - int ret; - - pfd[0].events = 0; - pfd[0].revents = 0; - - /* Only want to read ssl data if there is nothing else to do */ - if (readlen == 0) - { - /* can read ssl data */ - pfd[0].events |= POLLIN; - } - - if (writelen > 0) - { - /* can write ssl data - will block to do this */ - pfd[0].events |= POLLOUT; - } - - pfd[1].events = 0; - pfd[1].revents = 0; - - if (child_alive && readlen > 0) - { - pfd[1].events |= POLLOUT; - } - - pfd[2].events = 0; - pfd[2].revents = 0; - - if (child_alive && writelen == 0) - { - pfd[2].events |= POLLIN; - } - - /* Timeout after 1 second so we can increment timeout_count */ - ret = poll(pfd, 3, 1000); - - if (ret < 0) - { - if (errno != EAGAIN) - { - /* Kill off the child */ - kill(pid, SIGTERM); - break; - } - - continue; - } - - if (ret == 0) - { - if (++timeout_count >= opt_timeout) - { - /* Kill off the child */ - kill(pid, SIGTERM); - break; - } - - continue; - } - - timeout_count = 0; - - if (pfd[2].revents & POLLNVAL) - { - /* REVISIT: This can probably be removed */ - syslog(LOG_ERR, "Child closed output pipe"); - child_alive = 0; - } - else if (pfd[2].revents & POLLIN) - { - /* Can read from (3) */ - writelen = read(crfd, writebuf, sizeof(writebuf)); - if (writelen <= 0) - { - if (writelen < 0) - { - syslog(LOG_WARNING, "Failed to read from child: len=%d", - writelen); - } - break; - } - } - else if ((pfd[2].revents & POLLHUP) && kill(pid, 0) == 0) - { - if (opt_verbose) - { - syslog(LOG_INFO, "Child died and pipe gave POLLHUP"); - } - - child_alive = 0; - } - - if (writelen > 0) - { - const unsigned char *pt = writebuf; - while (writelen > 0) - { - ret = ssl_write(ssl, pt, writelen); - if (ret <= 0) - { - syslog(LOG_WARNING, "Failed to write ssl: ret=%d", ret); - /* Kill off the child now */ - kill(pid, SIGTERM); - writelen = -1; - break; - } - else - { - pt += ret; - writelen -= ret; - } - } - if (writelen < 0) - { - break; - } - } - else if (pfd[0].revents & POLLIN) - { - readlen = ssl_read(ssl, &readbuf); - if (readlen <= 0 && opt_verbose) - { - syslog(LOG_INFO, "ssl_read() returned %d", readlen); - } - - if (readlen < 0) - { - /* Kill off the child */ - kill(pid, SIGTERM); - break; - } - } - - if (pfd[1].revents & POLLNVAL) - { - /* REVISIT: This can probably be removed */ - syslog(LOG_ERR, "Child closed input pipe"); - readlen = -1; - child_alive = 0; - } - else if (pfd[1].revents & POLLOUT) - { - const unsigned char *pt = readbuf; - while (readlen > 0) - { - int len = write(cwfd, pt, readlen); - if (len <= 0) - { - syslog(LOG_WARNING, "Failed to write to child: len=%d", - len); - break; - } - - readlen -= len; - pt += len; - } - } - - } - - ssl_free(ssl); -#if 0 - fprintf(stderr, "[%d] SSL done: timeout_count=%d, readlen=%d, writelen=%d, child_alive=%d\n", - getpid(), timeout_count, readlen, writelen, child_alive); -#endif - return 0; - } - - /* Child */ - close(df[1]); - close(fd[0]); - - dup2(df[0],0); - dup2(fd[1],1); - - close(df[0]); - close(fd[1]); - - execv(argv[1], argv + 1); - _exit(1); -} diff --git a/user/mpy/lib/axtls/bindings/Config.in b/user/mpy/lib/axtls/bindings/Config.in deleted file mode 100644 index 443fc1a..0000000 --- a/user/mpy/lib/axtls/bindings/Config.in +++ /dev/null @@ -1,105 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see scripts/config/Kconfig-language.txt -# -menu "Language Bindings" - -config CONFIG_BINDINGS - bool "Create language bindings" - default n - help - axTLS supports language bindings in C#, VB.NET, Java and Perl. - - Select Y here if you want to build the various language bindings. - -config CONFIG_CSHARP_BINDINGS - bool "Create C# bindings" - default n - depends on CONFIG_BINDINGS - help - Build C# bindings. - - This requires .NET to be installed on Win32 platforms and mono to be - installed on all other platforms. - -config CONFIG_VBNET_BINDINGS - bool "Create VB.NET bindings" - default n - depends on CONFIG_BINDINGS - help - Build VB.NET bindings. - - This requires the .NET to be installed and is only built under Win32 - platforms. - -menu ".Net Framework" -depends on CONFIG_CSHARP_BINDINGS || CONFIG_VBNET_BINDINGS -config CONFIG_DOT_NET_FRAMEWORK_BASE - string "Location of .NET Framework" - default "c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727" -endmenu - -config CONFIG_JAVA_BINDINGS - bool "Create Java bindings" - default n - depends on CONFIG_BINDINGS - help - Build Java bindings. - - Current Issues (see README): - * Needs Java 1.4 or better. - * If building under Win32 it will use the Win32 JDK. - -menu "Java Home" -depends on CONFIG_JAVA_BINDINGS -config CONFIG_JAVA_HOME - string "Location of JDK" - default "c:\\Program Files\\Java\\jdk1.5.0_06" if CONFIG_PLATFORM_WIN32 || CONFIG_PLATFORM_CYGWIN - default "/usr/lib/jvm/java-7-openjdk-amd64" if !CONFIG_PLATFORM_WIN32 && !CONFIG_PLATFORM_CYGWIN - depends on CONFIG_JAVA_BINDINGS - help - The location of Sun's JDK. -endmenu - -config CONFIG_PERL_BINDINGS - bool "Create Perl bindings" - default n - depends on CONFIG_BINDINGS - help - Build Perl bindings. - - Current Issues (see README): - * 64 bit versions don't work at present. - * libperl.so needs to be in the shared library path. - -menu "Perl Home" -depends on CONFIG_PERL_BINDINGS && CONFIG_PLATFORM_WIN32 -config CONFIG_PERL_CORE - string "Location of Perl CORE" - default "c:\\perl\\lib\\CORE" - help: - works with ActiveState - "http://www.activestate.com/Products/ActivePerl" - -config CONFIG_PERL_LIB - string "Name of Perl Library" - default "perl58.lib" -endmenu - -config CONFIG_LUA_BINDINGS - bool "Create Lua bindings" - default n - depends on CONFIG_BINDINGS && !CONFIG_PLATFORM_WIN32 - help - Build Lua bindings (see www.lua.org). - -menu "Lua Home" -depends on CONFIG_LUA_BINDINGS -config CONFIG_LUA_CORE - string "Location of Lua CORE" - default "/usr/local" - help: - If the Lua exists on another directory then this needs to be changed -endmenu - -endmenu diff --git a/user/mpy/lib/axtls/bindings/Makefile b/user/mpy/lib/axtls/bindings/Makefile deleted file mode 100644 index 7654fbb..0000000 --- a/user/mpy/lib/axtls/bindings/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -all: - -include ../config/.config -include ../config/makefile.conf - -ifdef CONFIG_CSHARP_BINDINGS -all: csharp/axInterface.cs -endif - -ifdef CONFIG_VBNET_BINDINGS -all: vbnet/axInterface.vb -endif - -ifdef CONFIG_JAVA_BINDINGS -all: java/axtlsj.java -endif - -ifdef CONFIG_PERL_BINDINGS -all: perl/axTLSp_wrap.c -endif - -ifdef CONFIG_LUA_BINDINGS -all: lua/axTLSl_wrap.c -endif - -csharp/axInterface.cs: ../ssl/ssl.h - @perl ./generate_interface.pl -csharp - -vbnet/axInterface.vb: ../ssl/ssl.h - @perl ./generate_interface.pl -vbnet - -java/axTLSj.i: ../ssl/ssl.h - @perl ./generate_SWIG_interface.pl -java - -java/axtlsj.java: java/axTLSj.i $(wildcard java/SSL*.java) - @cd java; swig -java -package axTLSj axTLSj.i; $(MAKE) - -perl/axTLSp.i: ../ssl/ssl.h - @perl ./generate_SWIG_interface.pl -perl - -perl/axTLSp_wrap.c: perl/axTLSp.i - @cd perl; swig -perl5 axTLSp.i; $(MAKE) - -lua/axTLSl.i: ../ssl/ssl.h - @perl ./generate_SWIG_interface.pl -lua - -lua/axTLSl_wrap.c: lua/axTLSl.i - @cd lua; swig -lua axTLSl.i; $(MAKE) - -clean:: - $(MAKE) -C csharp clean - $(MAKE) -C vbnet clean - $(MAKE) -C java clean - $(MAKE) -C perl clean - $(MAKE) -C lua clean - diff --git a/user/mpy/lib/axtls/bindings/README b/user/mpy/lib/axtls/bindings/README deleted file mode 100644 index 8bc3109..0000000 --- a/user/mpy/lib/axtls/bindings/README +++ /dev/null @@ -1,43 +0,0 @@ -=============================================================================== -= Language Bindings = -=============================================================================== - -The tools to generate the various language bindings are done here. -SWIG 1.3.24 or better is required for creating the Java and Perl bindings. - -Perl scripts are used to parse ssl.h and automagically give the appropriate -bindings. - -At present, the four languages supported are: - -* C# -* VB.NET -* Java -* Perl - -To generate each binding run the following: - -C#: -> generate_interface.pl -csharp - -VB.NET: -> generate_interface.pl -vbnet - - -Java: -> generate_SWIG_interface.pl -java -> cd java; swig -java -package axTLSj -noextern axTLSj.i - -Perl: -> generate_SWIG_interface.pl -perl -> cd perl; swig -noextern -perl axTLSp.i - -Java and Perl both create a library each called libaxtlsj.so and libaxtlsp.so -(or axtlsj.dll and atlsp.dll on Win32 platforms). - -Note: the "-noextern" is deprecated in swig 1.3.27 and newer. The "-noextern" -option was required to get Win32 bindings to work (which is why is has probably -been deprecated). - -Each binding (except for Perl) has an extra helper interface to make life -easier. diff --git a/user/mpy/lib/axtls/bindings/csharp/Makefile b/user/mpy/lib/axtls/bindings/csharp/Makefile deleted file mode 100644 index 3414f85..0000000 --- a/user/mpy/lib/axtls/bindings/csharp/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf - -clean:: - @rm -f axssl* axInterface.cs diff --git a/user/mpy/lib/axtls/bindings/csharp/axTLS.cs b/user/mpy/lib/axtls/bindings/csharp/axTLS.cs deleted file mode 100644 index 6a2f6b0..0000000 --- a/user/mpy/lib/axtls/bindings/csharp/axTLS.cs +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * A wrapper around the unmanaged interface to give a semi-decent C# API - */ - -using System; -using System.Runtime.InteropServices; -using System.Net.Sockets; - -/** - * @defgroup csharp_api C# API. - * - * Ensure that the appropriate Dispose() methods are called when finished with - * various objects - otherwise memory leaks will result. - * @{ - */ -namespace axTLS -{ - /** - * @class SSL - * @ingroup csharp_api - * @brief A representation of an SSL connection. - */ - public class SSL - { - public IntPtr m_ssl; /**< A pointer to the real SSL type */ - - /** - * @brief Store the reference to an SSL context. - * @param ip [in] A reference to an SSL object. - */ - public SSL(IntPtr ip) - { - m_ssl = ip; - } - - /** - * @brief Free any used resources on this connection. - * - * A "Close Notify" message is sent on this connection (if possible). - * It is up to the application to close the socket. - */ - public void Dispose() - { - axtls.ssl_free(m_ssl); - } - - /** - * @brief Return the result of a handshake. - * @return SSL_OK if the handshake is complete and ok. - * @see ssl.h for the error code list. - */ - public int HandshakeStatus() - { - return axtls.ssl_handshake_status(m_ssl); - } - - /** - * @brief Return the SSL cipher id. - * @return The cipher id which is one of: - * - SSL_AES128_SHA (0x2f) - * - SSL_AES256_SHA (0x35) - * - SSL_AES128_SHA256 (0x3c) - * - SSL_AES256_SHA256 (0x3d) - */ - public byte GetCipherId() - { - return axtls.ssl_get_cipher_id(m_ssl); - } - - /** - * @brief Get the session id for a handshake. - * - * This will be a 32 byte sequence and is available after the first - * handshaking messages are sent. - * @return The session id as a 32 byte sequence. - * @note A SSLv23 handshake may have only 16 valid bytes. - */ - public byte[] GetSessionId() - { - IntPtr ptr = axtls.ssl_get_session_id(m_ssl); - byte sess_id_size = axtls.ssl_get_session_id_size(m_ssl); - byte[] result = new byte[sess_id_size]; - Marshal.Copy(ptr, result, 0, sess_id_size); - return result; - } - - /** - * @brief Retrieve an X.509 distinguished name component. - * - * When a handshake is complete and a certificate has been exchanged, - * then the details of the remote certificate can be retrieved. - * - * This will usually be used by a client to check that the server's - * common name matches the URL. - * - * A full handshake needs to occur for this call to work. - * - * @param component [in] one of: - * - SSL_X509_CERT_COMMON_NAME - * - SSL_X509_CERT_ORGANIZATION - * - SSL_X509_CERT_ORGANIZATIONAL_NAME - * - SSL_X509_CA_CERT_COMMON_NAME - * - SSL_X509_CA_CERT_ORGANIZATION - * - SSL_X509_CA_CERT_ORGANIZATIONAL_NAME - * @return The appropriate string (or null if not defined) - */ - public string GetCertificateDN(int component) - { - return axtls.ssl_get_cert_dn(m_ssl, component); - } - } - - /** - * @class SSLUtil - * @ingroup csharp_api - * @brief Some global helper functions. - */ - public class SSLUtil - { - - /** - * @brief Return the build mode of the axTLS project. - * @return The build mode is one of: - * - SSL_BUILD_SERVER_ONLY - * - SSL_BUILD_ENABLE_VERIFICATION - * - SSL_BUILD_ENABLE_CLIENT - * - SSL_BUILD_FULL_MODE - */ - public static int BuildMode() - { - return axtls.ssl_get_config(axtls.SSL_BUILD_MODE); - } - - /** - * @brief Return the number of chained certificates that the - * client/server supports. - * @return The number of supported server certificates. - */ - public static int MaxCerts() - { - return axtls.ssl_get_config(axtls.SSL_MAX_CERT_CFG_OFFSET); - } - - /** - * @brief Return the number of CA certificates that the client/server - * supports. - * @return The number of supported CA certificates. - */ - public static int MaxCACerts() - { - return axtls.ssl_get_config(axtls.SSL_MAX_CA_CERT_CFG_OFFSET); - } - - /** - * @brief Indicate if PEM is supported. - * @return true if PEM supported. - */ - public static bool HasPEM() - { - return axtls.ssl_get_config(axtls.SSL_HAS_PEM) > 0 ? true : false; - } - - /** - * @brief Display the text string of the error. - * @param error_code [in] The integer error code. - */ - public static void DisplayError(int error_code) - { - axtls.ssl_display_error(error_code); - } - - /** - * @brief Return the version of the axTLS project. - */ - public static string Version() - { - return axtls.ssl_version(); - } - } - - /** - * @class SSLCTX - * @ingroup csharp_api - * @brief A base object for SSLServer/SSLClient. - */ - public class SSLCTX - { - /** - * @brief A reference to the real client/server context. - */ - protected IntPtr m_ctx; - - /** - * @brief Establish a new client/server context. - * - * This function is called before any client/server SSL connections are - * made. If multiple threads are used, then each thread will have its - * own SSLCTX context. Any number of connections may be made with a - * single context. - * - * Each new connection will use the this context's private key and - * certificate chain. If a different certificate chain is required, - * then a different context needs to be be used. - * - * @param options [in] Any particular options. At present the options - * supported are: - * - SSL_SERVER_VERIFY_LATER (client only): Don't stop a handshake if - * the server authentication fails. The certificate can be - * authenticated later with a call to VerifyCert(). - * - SSL_CLIENT_AUTHENTICATION (server only): Enforce client - * authentication i.e. each handshake will include a "certificate - * request" message from the server. - * - SSL_DISPLAY_BYTES (full mode build only): Display the byte - * sequences during the handshake. - * - SSL_DISPLAY_STATES (full mode build only): Display the state - * changes during the handshake. - * - SSL_DISPLAY_CERTS (full mode build only): Display the - * certificates that are passed during a handshake. - * - SSL_DISPLAY_RSA (full mode build only): Display the RSA key - * details that are passed during a handshake. - * @param num_sessions [in] The number of sessions to be used for - * session caching. If this value is 0, then there is no session - * caching. - * @return A client/server context. - */ - protected SSLCTX(uint options, int num_sessions) - { - m_ctx = axtls.ssl_ctx_new(options, num_sessions); - } - - /** - * @brief Remove a client/server context. - * - * Frees any used resources used by this context. Each connection will - * be sent a "Close Notify" alert (if possible). - */ - public void Dispose() - { - axtls.ssl_ctx_free(m_ctx); - } - - /** - * @brief Read the SSL data stream. - * @param ssl [in] An SSL object reference. - * @param in_data [out] After a successful read, the decrypted data - * will be here. It will be null otherwise. - * @return The number of decrypted bytes: - * - if > 0, then the handshaking is complete and we are returning the - * number of decrypted bytes. - * - SSL_OK if the handshaking stage is successful (but not yet - * complete). - * - < 0 if an error. - * @see ssl.h for the error code list. - * @note Use in_data before doing any successive ssl calls. - */ - public int Read(SSL ssl, out byte[] in_data) - { - IntPtr ptr = IntPtr.Zero; - int ret = axtls.ssl_read(ssl.m_ssl, ref ptr); - - if (ret > axtls.SSL_OK) - { - in_data = new byte[ret]; - Marshal.Copy(ptr, in_data, 0, ret); - } - else - { - in_data = null; - } - - return ret; - } - - /** - * @brief Write to the SSL data stream. - * @param ssl [in] An SSL obect reference. - * @param out_data [in] The data to be written - * @return The number of bytes sent, or if < 0 if an error. - * @see ssl.h for the error code list. - */ - public int Write(SSL ssl, byte[] out_data) - { - return axtls.ssl_write(ssl.m_ssl, out_data, out_data.Length); - } - - /** - * @brief Write to the SSL data stream. - * @param ssl [in] An SSL obect reference. - * @param out_data [in] The data to be written - * @param out_len [in] The number of bytes to be written - * @return The number of bytes sent, or if < 0 if an error. - * @see ssl.h for the error code list. - */ - public int Write(SSL ssl, byte[] out_data, int out_len) - { - return axtls.ssl_write(ssl.m_ssl, out_data, out_len); - } - - /** - * @brief Find an ssl object based on a Socket reference. - * - * Goes through the list of SSL objects maintained in a client/server - * context to look for a socket match. - * @param s [in] A reference to a Socket object. - * @return A reference to the SSL object. Returns null if the object - * could not be found. - */ - public SSL Find(Socket s) - { - int client_fd = s.Handle.ToInt32(); - return new SSL(axtls. ssl_find(m_ctx, client_fd)); - } - - /** - * @brief Authenticate a received certificate. - * - * This call is usually made by a client after a handshake is complete - * and the context is in SSL_SERVER_VERIFY_LATER mode. - * @param ssl [in] An SSL object reference. - * @return SSL_OK if the certificate is verified. - */ - public int VerifyCert(SSL ssl) - { - return axtls.ssl_verify_cert(ssl.m_ssl); - } - - /** - * @brief Force the client to perform its handshake again. - * - * For a client this involves sending another "client hello" message. - * For the server is means sending a "hello request" message. - * - * This is a blocking call on the client (until the handshake - * completes). - * @param ssl [in] An SSL object reference. - * @return SSL_OK if renegotiation instantiation was ok - */ - public int Renegotiate(SSL ssl) - { - return axtls.ssl_renegotiate(ssl.m_ssl); - } - - /** - * @brief Load a file into memory that is in binary DER or ASCII PEM - * format. - * - * These are temporary objects that are used to load private keys, - * certificates etc into memory. - * @param obj_type [in] The format of the file. Can be one of: - * - SSL_OBJ_X509_CERT (no password required) - * - SSL_OBJ_X509_CACERT (no password required) - * - SSL_OBJ_RSA_KEY (AES128/AES256 PEM encryption supported) - * - SSL_OBJ_P8 (RC4-128 encrypted data supported) - * - SSL_OBJ_P12 (RC4-128 encrypted data supported) - * - * PEM files are automatically detected (if supported). - * @param filename [in] The location of a file in DER/PEM format. - * @param password [in] The password used. Can be null if not required. - * @return SSL_OK if all ok - */ - public int ObjLoad(int obj_type, string filename, string password) - { - return axtls.ssl_obj_load(m_ctx, obj_type, filename, password); - } - - /** - * @brief Transfer binary data into the object loader. - * - * These are temporary objects that are used to load private keys, - * certificates etc into memory. - * @param obj_type [in] The format of the memory data. - * @param data [in] The binary data to be loaded. - * @param len [in] The amount of data to be loaded. - * @param password [in] The password used. Can be null if not required. - * @return SSL_OK if all ok - */ - public int ObjLoad(int obj_type, byte[] data, int len, string password) - { - return axtls.ssl_obj_memory_load(m_ctx, obj_type, - data, len, password); - } - } - - /** - * @class SSLServer - * @ingroup csharp_api - * @brief The server context. - * - * All server connections are started within a server context. - */ - public class SSLServer : SSLCTX - { - /** - * @brief Start a new server context. - * - * @see SSLCTX for details. - */ - public SSLServer(uint options, int num_sessions) : - base(options, num_sessions) {} - - /** - * @brief Establish a new SSL connection to an SSL client. - * - * It is up to the application to establish the initial socket - * connection. - * - * Call Dispose() when the connection is to be removed. - * @param s [in] A reference to a Socket object. - * @return An SSL object reference. - */ - public SSL Connect(Socket s) - { - int client_fd = s.Handle.ToInt32(); - return new SSL(axtls.ssl_server_new(m_ctx, client_fd)); - } - } - - /** - * @class SSLClient - * @ingroup csharp_api - * @brief The client context. - * - * All client connections are started within a client context. - */ - public class SSLClient : SSLCTX - { - /** - * @brief Start a new client context. - * - * @see SSLCTX for details. - */ - public SSLClient(uint options, int num_sessions) : - base(options, num_sessions) {} - - /** - * @brief Establish a new SSL connection to an SSL server. - * - * It is up to the application to establish the initial socket - * connection. - * - * This is a blocking call - it will finish when the handshake is - * complete (or has failed). - * - * Call Dispose() when the connection is to be removed. - * @param s [in] A reference to a Socket object. - * @param session_id [in] A 32 byte session id for session resumption. - * This can be null if no session resumption is not required. - * @return An SSL object reference. Use SSL.handshakeStatus() to check - * if a handshake succeeded. - */ - public SSL Connect(Socket s, byte[] session_id) - { - int client_fd = s.Handle.ToInt32(); - byte sess_id_size = (byte)(session_id != null ? - session_id.Length : 0); - return new SSL(axtls.ssl_client_new(m_ctx, client_fd, session_id, - sess_id_size)); - } - } -} -/** @} */ diff --git a/user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl b/user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl deleted file mode 100755 index 90c4ba3..0000000 --- a/user/mpy/lib/axtls/bindings/generate_SWIG_interface.pl +++ /dev/null @@ -1,392 +0,0 @@ -#!/usr/bin/perl - -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -#=============================================================== -# Transforms function signature into SWIG format -sub transformSignature -{ - foreach $item (@_) - { - $line =~ s/STDCALL //g; - $line =~ s/EXP_FUNC/extern/g; - - # make API Java more 'byte' friendly - $line =~ s/uint32_t/int/g; - $line =~ s/const uint8_t \* /const unsigned char \* /g; - $line =~ s/\(void\)/()/g; - if ($ARGV[0] eq "-java") - { - $line =~ s/.*ssl_read.*//g; - $line =~ s/const uint8_t \*(\w+)/const signed char $1\[\]/g; - $line =~ s/uint8_t/signed char/g; - } - elsif ($ARGV[0] eq "-perl") - { - $line =~ s/const uint8_t \*(\w+)/const unsigned char $1\[\]/g; - $line =~ s/uint8_t/unsigned char/g; - } - else # lua - { - $line =~ s/const uint8_t \*session_id/const unsigned char session_id\[\]/g; - $line =~ s/const uint8_t \*\w+/unsigned char *INPUT/g; - $line =~ s/uint8_t/unsigned char/g; - } - } - - return $line; -} - -# Parse input file -sub parseFile -{ - foreach $line (@_) - { - next if $line =~ /ssl_x509_create/; # ignore for now - - # test for a #define - if (!$skip && $line =~ m/^#define/) - { - $splitDefine = 1 if $line =~ m/\\$/; - print DATA_OUT $line; - - # check line is not split - next if $splitDefine == 1; - } - - # pick up second line of #define statement - if ($splitDefine) - { - print DATA_OUT $line; - - # check line is not split - $splitDefine = ($line =~ m/\\$/); - next; - } - - # test for function declaration - if (!$skip && $line =~ /EXP_FUNC/ && $line !~/\/\*/) - { - $line = transformSignature($line); - $splitFunctionDeclaration = $line !~ /;/; - print DATA_OUT $line; - next; - } - - if ($splitFunctionDeclaration) - { - $line = transformSignature($line); - $splitFunctionDeclaration = $line !~ /;/; - print DATA_OUT $line; - next; - } - } -} - -#=============================================================== - -# Determine which module to build from cammand-line options -use strict; -use Getopt::Std; - -my $module; -my $interfaceFile; -my $data_file; -my $skip; -my $splitLine; -my @raw_data; - -if (not defined $ARGV[0]) -{ - die "Usage: $0 [-java | -perl | -lua]\n"; -} - -if ($ARGV[0] eq "-java") -{ - print "Generating Java interface file\n"; - $module = "axtlsj"; - $interfaceFile = "java/axTLSj.i"; -} -elsif ($ARGV[0] eq "-perl") -{ - print "Generating Perl interface file\n"; - $module = "axtlsp"; - $interfaceFile = "perl/axTLSp.i"; -} -elsif ($ARGV[0] eq "-lua") -{ - print "Generating lua interface file\n"; - $module = "axtlsl"; - $interfaceFile = "lua/axTLSl.i"; -} -else -{ - die "Usage: $0 [-java | -perl | -lua]\n"; -} - -# Input file required to generate SWIG interface file. -$data_file = "../ssl/ssl.h"; - -# Open input files -open(DATA_IN, $data_file) || die("Could not open file ($data_file)!"); -@raw_data = ; - -# Open output file -open(DATA_OUT, ">$interfaceFile") || die("Cannot Open File"); - -# -# I wish I could say it was easy to generate the Perl/Java/Lua bindings, -# but each had their own set of challenges... :-(. -# -print DATA_OUT << "END"; -%module $module\n - -/* include our own header */ -%inline %{ -#include "ssl.h" -%} - -%include "typemaps.i" -/* Some SWIG magic to make the API a bit more Java friendly */ -#ifdef SWIGJAVA - -%apply long { SSL * }; -%apply long { SSL_CTX * }; -%apply long { SSLObjLoader * }; - -/* allow "unsigned char []" to become "byte[]" */ -%include "arrays_java.i" - -/* convert these pointers to use long */ -%apply signed char[] {unsigned char *}; -%apply signed char[] {signed char *}; - -/* allow ssl_get_session_id() to return "byte[]" */ -%typemap(out) unsigned char * ssl_get_session_id \"if (result) jresult = SWIG_JavaArrayOutSchar(jenv, result, ssl_get_session_id_size((SSL const *)arg1));\" - -/* allow ssl_client_new() to have a null session_id input */ -%typemap(in) const signed char session_id[] (jbyte *jarr) { - if (jarg3 == NULL) - { - jresult = (jint)ssl_client_new(arg1,arg2,NULL,0); - return jresult; - } - - if (!SWIG_JavaArrayInSchar(jenv, &jarr, &arg3, jarg3)) return 0; -} - -/* Lot's of work required for an ssl_read() due to its various custom - * requirements. - */ -%native (ssl_read) int ssl_read(SSL *ssl, jobject in_data); -%{ -JNIEXPORT jint JNICALL Java_axTLSj_axtlsjJNI_ssl_1read(JNIEnv *jenv, jclass jcls, jint jarg1, jobject jarg2) { - jint jresult = 0 ; - SSL *arg1; - unsigned char *arg2; - jbyte *jarr; - int result; - JNIEnv e = *jenv; - jclass holder_class; - jfieldID fid; - - arg1 = (SSL *)jarg1; - result = (int)ssl_read(arg1, &arg2); - - /* find the "m_buf" entry in the SSLReadHolder class */ - if (!(holder_class = e->GetObjectClass(jenv,jarg2)) || - !(fid = e->GetFieldID(jenv,holder_class, "m_buf", "[B"))) - return SSL_NOT_OK; - - if (result > SSL_OK) - { - int i; - - /* create a new byte array to hold the read data */ - jbyteArray jarray = e->NewByteArray(jenv, result); - - /* copy the bytes across to the java byte array */ - jarr = e->GetByteArrayElements(jenv, jarray, 0); - for (i = 0; i < result; i++) - jarr[i] = (jbyte)arg2[i]; - - /* clean up and set the new m_buf object */ - e->ReleaseByteArrayElements(jenv, jarray, jarr, 0); - e->SetObjectField(jenv, jarg2, fid, jarray); - } - else /* set to null */ - e->SetObjectField(jenv, jarg2, fid, NULL); - - jresult = (jint)result; - return jresult; -} -%} - -/* Big hack to get hold of a socket's file descriptor */ -%typemap (jtype) long "Object" -%typemap (jstype) long "Object" -%native (getFd) int getFd(long sock); -%{ -JNIEXPORT jint JNICALL Java_axTLSj_axtlsjJNI_getFd(JNIEnv *env, jclass jcls, jobject sock) -{ - JNIEnv e = *env; - jfieldID fid; - jobject impl; - jobject fdesc; - - /* get the SocketImpl from the Socket */ - if (!(jcls = e->GetObjectClass(env,sock)) || - !(fid = e->GetFieldID(env,jcls,"impl","Ljava/net/SocketImpl;")) || - !(impl = e->GetObjectField(env,sock,fid))) return -1; - - /* get the FileDescriptor from the SocketImpl */ - if (!(jcls = e->GetObjectClass(env,impl)) || - !(fid = e->GetFieldID(env,jcls,"fd","Ljava/io/FileDescriptor;")) || - !(fdesc = e->GetObjectField(env,impl,fid))) return -1; - - /* get the fd from the FileDescriptor */ - if (!(jcls = e->GetObjectClass(env,fdesc)) || - !(fid = e->GetFieldID(env,jcls,"fd","I"))) return -1; - - /* return the descriptor */ - return e->GetIntField(env,fdesc,fid); -} -%} - -#endif - -/* Some SWIG magic to make the API a bit more Perl friendly */ -#ifdef SWIGPERL - -/* for ssl_session_id() */ -%typemap(out) const unsigned char * { - SV *svs = newSVpv((unsigned char *)\$1, ssl_get_session_id_size((SSL const *)arg1)); - \$result = newRV(svs); - sv_2mortal(\$result); - argvi++; -} - -/* for ssl_write() */ -%typemap(in) const unsigned char out_data[] { - SV* tempsv; - if (!SvROK(\$input)) - croak("Argument \$argnum is not a reference."); - tempsv = SvRV(\$input); - if (SvTYPE(tempsv) != SVt_PV) - croak("Argument \$argnum is not an string."); - \$1 = (unsigned char *)SvPV(tempsv, PL_na); -} - -/* for ssl_read() */ -%typemap(in) unsigned char **in_data (unsigned char *buf) { - \$1 = &buf; -} - -%typemap(argout) unsigned char **in_data { - if (result > SSL_OK) { - SV *svs = newSVpv(*\$1, result); - \$result = newRV(svs); - sv_2mortal(\$result); - argvi++; - } -} - -/* for ssl_client_new() */ -%typemap(in) const unsigned char session_id[] { - /* check for a reference */ - if (SvOK(\$input) && SvROK(\$input)) { - SV* tempsv = SvRV(\$input); - if (SvTYPE(tempsv) != SVt_PV) - croak("Argument \$argnum is not an string."); - \$1 = (unsigned char *)SvPV(tempsv, PL_na); - } - else - \$1 = NULL; -} - -#endif - -/* Some SWIG magic to make the API a bit more Lua friendly */ -#ifdef SWIGLUA -SWIG_NUMBER_TYPEMAP(unsigned char); -SWIG_TYPEMAP_NUM_ARR(uchar,unsigned char); - -/* for ssl_session_id() */ -%typemap(out) const unsigned char * { - int i; - lua_newtable(L); - for (i = 0; i < ssl_get_session_id_size((SSL const *)arg1); i++){ - lua_pushnumber(L,(lua_Number)result[i]); - lua_rawseti(L,-2,i+1); /* -1 is the number, -2 is the table */ - } - SWIG_arg++; -} - -/* for ssl_read() */ -%typemap(in) unsigned char **in_data (unsigned char *buf) { - \$1 = &buf; -} - -%typemap(argout) unsigned char **in_data { - if (result > SSL_OK) { - int i; - lua_newtable(L); - for (i = 0; i < result; i++){ - lua_pushnumber(L,(lua_Number)buf2[i]); - lua_rawseti(L,-2,i+1); /* -1 is the number, -2 is the table */ - } - SWIG_arg++; - } -} - -/* for ssl_client_new() */ -%typemap(in) const unsigned char session_id[] { - if (lua_isnil(L,\$input)) - \$1 = NULL; - else - \$1 = SWIG_get_uchar_num_array_fixed(L,\$input, ssl_get_session_id((SSL const *)\$1)); -} - -#endif - -END - -# Initialise loop variables -$skip = 1; -$splitLine = 0; - -parseFile(@raw_data); - -close(DATA_IN); -close(DATA_OUT); - -#=============================================================== - diff --git a/user/mpy/lib/axtls/bindings/generate_interface.pl b/user/mpy/lib/axtls/bindings/generate_interface.pl deleted file mode 100755 index c24bff9..0000000 --- a/user/mpy/lib/axtls/bindings/generate_interface.pl +++ /dev/null @@ -1,322 +0,0 @@ -#!/usr/bin/perl -w - -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -#=============================================================== -# This application transforms ssl.h into interfaces that can be used by -# other language bindings. It is "SWIG"-like in nature in that various -# files are generated based on the axTLS API. -# -# The file produced is axInterface.? (depending on the file extension). -# -#=============================================================== - -use strict; - -my $CSHARP = 0; -my $VBNET = 1; - -my $binding; -my $skip = 0; -my $signature_ret_type; - -# Transforms function signature into an Interface format -sub transformSignature -{ - my $item; - my ($line) = @_; - - foreach $item ($line) - { - # our very basic preprocessor - if ($binding == $CSHARP) - { - $line =~ s/STDCALL //; - $line =~ s/EXP_FUNC/ [DllImport ("axtls")]\n public static extern/; - $line =~ s/uint32_t/uint/g; - $line =~ s/uint8_t \*\*/ref IntPtr /g; - $line =~ s/const uint8_t \* /IntPtr /g; - $line =~ s/const uint8_t \*/byte[] /g; # note: subtle diff - $line =~ s/uint8_t \* ?/byte[] /g; - $line =~ s/uint8_t ?/byte /g; - $line =~ s/const char \* ?/string /g; - $line =~ s/const SSL_CTX \* ?/IntPtr /g; - $line =~ s/SSL_CTX \* ?/IntPtr /g; - $line =~ s/SSLObjLoader \* ?/IntPtr /g; - $line =~ s/const SSL \* ?/IntPtr /g; - $line =~ s/SSL \* ?/IntPtr /g; - $line =~ s/\(void\)/()/g; - } - elsif ($binding == $VBNET) - { - if ($line =~ /EXP_FUNC/) - { - # Procedure or function? - my $invariant = $line =~ /void /; - - my $proc = $invariant ? "Sub" : "Function"; - ($signature_ret_type) = $line =~ /EXP_FUNC (.*) STDCALL/; - $line =~ s/EXP_FUNC .* STDCALL / Public Shared $proc _\n /; - - $signature_ret_type =~ s/const uint8_t \*/As IntPtr/; - $signature_ret_type =~ s/const char \*/As String/; - $signature_ret_type =~ s/SSL_CTX \*/As IntPtr/; - $signature_ret_type =~ s/SSLObjLoader \*/As IntPtr/; - $signature_ret_type =~ s/SSL \*/As IntPtr/; - $signature_ret_type =~ s/uint8_t/As Byte/; - $signature_ret_type =~ s/int/As Integer/; - $signature_ret_type =~ s/void//; - $signature_ret_type .= "\n End $proc\n\n"; - } - - $line =~ s/uint32_t (\w+)/ByVal $1 As Integer/g; - $line =~ s/int (\w+)/ByVal $1 As Integer/g; - $line =~ s/uint8_t \*\* ?(\w+)/ByRef $1 As IntPtr/g; - $line =~ s/const uint8_t \* ?(\w+)/ByVal $1() As Byte/g; - $line =~ s/uint8_t \* ?(\w+)/ByVal $1() As Byte/g; - $line =~ s/uint8_t ?(\w+)/ByVal $1 As Byte/g; - $line =~ s/const char \* ?(\w+)/ByVal $1 As String/g; - $line =~ s/const SSL_CTX \* ?(\w+)/ByVal $1 As IntPtr/g; - $line =~ s/SSL_CTX \* ?(\w+)/ByVal $1 As IntPtr/g; - $line =~ s/SSLObjLoader \* ?(\w+)/ByVal $1 As IntPtr/g; - $line =~ s/const SSL \* ?(\w+)/ByVal $1 As IntPtr/g; - $line =~ s/SSL \* ?(\w+)/ByVal $1 As IntPtr/g; - $line =~ s/void \* ?(\w+)/Byval $1 As IntPtr/g; - $line =~ s/\(void\)/()/g; - $line =~ s/void//g; - $line =~ s/;\n/ $signature_ret_type;/; - } - } - - return $line; -} - -# Parse input file -sub parseFile -{ - my (@file) = @_; - my $line; - my $splitDefine = 0; - my $splitFunctionDeclaration; - my $vb_hack = " "; - my $vb_line_hack = 0; - - $skip = 0; - - foreach $line (@file) - { - next if $line =~ /sl_x509_create/; # ignore for now - - # test for a #define - if (!$skip && $line =~ m/^#define/) - { - $splitDefine = 1 if $line =~ m/\\$/; - - if ($binding == $VBNET) - { - $line =~ s/\|/Or/g; - $line =~ s/ 0x/ &H/; - } - - my ($name, $value) = $line =~ /#define (\w+) +([^\\]*)[\\]?\n/; - - if (defined $name && defined $value) - { - # C# constant translation - if ($binding == $CSHARP) - { - $line = " public const int $name = $value"; - } - # VB.NET constant translation - elsif ($binding == $VBNET) - { - $line = " Public Const $name As Integer = $value"; - } - } - - next if $line =~ /#define/; # ignore any other defines - - print DATA_OUT $line; - - # check line is not split - next if $splitDefine == 1; - print DATA_OUT ";" if $binding == $CSHARP; - print DATA_OUT "\n"; - } - - # pick up second line of #define statement - if ($splitDefine) - { - if ($line !~ /\\$/) - { - $line =~ s/$/;/ if $binding == $CSHARP; # add the ";" - } - - $line =~ s/ ?\| ?/ Or /g - if ($binding == $VBNET); - - # check line is not split - $splitDefine = ($line =~ m/\\$/); - - # ignore trailing "\" - $line =~ s/\\$// if $binding == $CSHARP; - $line =~ s/\\$/_/ if $binding == $VBNET; - print DATA_OUT $line; - next; - } - - # test for function declaration - if (!$skip && $line =~ /EXP_FUNC/ && $line !~ /\/\*/) - { - $line = transformSignature($line); - $splitFunctionDeclaration = $line !~ /;/; - $line =~ s/;// if ($binding == $VBNET); - $line =~ s/\n$/ _\n/ if ($binding == $VBNET) && - $splitFunctionDeclaration; - print DATA_OUT $line; - next; - } - - if ($splitFunctionDeclaration) - { - $line = transformSignature($line); - $splitFunctionDeclaration = $line !~ /;/; - $line =~ s/;// if ($binding == $VBNET); - $line =~ s/\n/ _\n/ if ($binding == $VBNET) && - $splitFunctionDeclaration == 1; - print DATA_OUT $line; - next; - } - } -} - -#=============================================================== - -# Determine which module to build from command-line options -use strict; -use Getopt::Std; - -my $binding_prefix; -my $binding_suffix; -my $data_file; -my @raw_data; - -if (not defined $ARGV[0]) -{ - goto ouch; -} - -if ($ARGV[0] eq "-csharp") -{ - print "Generating C# interface file\n"; - $binding_prefix = "csharp"; - $binding_suffix = "cs"; - $binding = $CSHARP; -} -elsif ($ARGV[0] eq "-vbnet") -{ - print "Generating VB.NET interface file\n"; - $binding_prefix = "vbnet"; - $binding_suffix = "vb"; - $binding = $VBNET; -} -else -{ -ouch: - die "Usage: $0 [-csharp | -vbnet]\n"; -} - -my $interfaceFile = "$binding_prefix/axInterface.$binding_suffix"; - -# Input file required to generate interface file. -$data_file = "../ssl/ssl.h"; - -# Open input files -open(DATA_IN, $data_file) || die("Could not open file ($data_file)!"); -@raw_data = ; - - -# Open output file -if ($binding == $CSHARP || $binding == $VBNET) -{ - open(DATA_OUT, ">$interfaceFile") || die("Cannot Open File"); -} - -# SPEC interface file header -if ($binding == $CSHARP) -{ - # generate the C#/C interface file - print DATA_OUT << "END"; -// The C# to C interface definition file for the axTLS project -// Do not modify - this file is generated - -using System; -using System.Runtime.InteropServices; - -namespace axTLS -{ - public class axtls - { -END -} -elsif ($binding == $VBNET) -{ - # generate the VB.NET/C interface file - print DATA_OUT << "END"; -' The VB.NET to C interface definition file for the axTLS project -' Do not modify - this file is generated - -Imports System -Imports System.Runtime.InteropServices - -Namespace axTLSvb - Public Class axtls -END -} - -parseFile(@raw_data); - -# finish up -if ($binding == $CSHARP) -{ - print DATA_OUT " };\n"; - print DATA_OUT "};\n"; -} -elsif ($binding == $VBNET) -{ - print DATA_OUT " End Class\nEnd Namespace\n"; -} - -close(DATA_IN); -close(DATA_OUT); - -#=============================================================== - diff --git a/user/mpy/lib/axtls/bindings/java/Makefile b/user/mpy/lib/axtls/bindings/java/Makefile deleted file mode 100644 index 8df1d0a..0000000 --- a/user/mpy/lib/axtls/bindings/java/Makefile +++ /dev/null @@ -1,94 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -AXTLS_HOME=../.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf -include $(AXTLS_HOME)/config/makefile.java.conf - -all: lib jar - -JAR=$(AXTLS_HOME)/$(STAGE)/axtls.jar - -ifdef CONFIG_PLATFORM_WIN32 -TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsj.dll -else -TARGET=$(AXTLS_HOME)/$(STAGE)/libaxtlsj.so -endif - -lib: $(TARGET) -axTLSj_wrap.o : axTLSj_wrap.c - -JAVA_FILES= \ - axtlsjJNI.java \ - axtlsjConstants.java \ - axtlsj.java \ - SSLReadHolder.java \ - SSL.java \ - SSLUtil.java \ - SSLCTX.java \ - SSLServer.java \ - SSLClient.java - -OBJ=axTLSj_wrap.o - -JAVA_CLASSES:=$(JAVA_FILES:%.java=classes/axTLSj/%.class) - -ifdef CONFIG_PLATFORM_WIN32 -LDFLAGS += axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)" - -include $(AXTLS_HOME)/config/makefile.post - -$(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ) -else # Not Win32 - -$(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) -L $(AXTLS_HOME)/$(STAGE) $(LDSHARED) -o $@ $(OBJ) -laxtls -endif - -jar: $(OBJ) $(JAR) - -# if we are doing the samples then defer creating the jar until then -$(JAR): $(JAVA_CLASSES) -ifndef CONFIG_JAVA_SAMPLES - jar cvf $@ -C classes axTLSj -else - @if [ ! -f $(JAR) ]; then touch $(JAR); fi -endif - -classes/axTLSj/%.class : %.java - javac -d classes -classpath classes $^ - -clean:: - @rm -f $(JAR) $(TARGET) SWIG* axtls* *.i *.c - @rm -fr classes/* - diff --git a/user/mpy/lib/axtls/bindings/java/SSL.java b/user/mpy/lib/axtls/bindings/java/SSL.java deleted file mode 100644 index e0400b6..0000000 --- a/user/mpy/lib/axtls/bindings/java/SSL.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * A wrapper around the unmanaged interface to give a semi-decent Java API - */ - -package axTLSj; - -import java.io.*; -import java.util.*; - -/** - * @defgroup java_api Java API. - * - * Ensure that the appropriate dispose() methods are called when finished with - * various objects - otherwise memory leaks will result. - */ - -/** - * @class SSL - * @ingroup java_api - * @brief A representation of an SSL connection. - * - */ -public class SSL -{ - public int m_ssl; /**< A pointer to the real SSL type */ - - /** - * @brief Store the reference to an SSL context. - * @param ip [in] A reference to an SSL object. - */ - public SSL(int ip) - { - m_ssl = ip; - } - - /** - * @brief Free any used resources on this connection. - * - * A "Close Notify" message is sent on this connection (if possible). It - * is up to the application to close the socket. - */ - public void dispose() - { - axtlsj.ssl_free(m_ssl); - } - - /** - * @brief Return the result of a handshake. - * @return SSL_OK if the handshake is complete and ok. - * @see ssl.h for the error code list. - */ - public int handshakeStatus() - { - return axtlsj.ssl_handshake_status(m_ssl); - } - - /** - * @brief Return the SSL cipher id. - * @return The cipher id which is one of: - * - SSL_AES128_SHA (0x2f) - * - SSL_AES256_SHA (0x35) - * - SSL_AES128_SHA256 (0x3c) - * - SSL_AES256_SHA256 (0x3d) - */ - public byte getCipherId() - { - return axtlsj.ssl_get_cipher_id(m_ssl); - } - - /** - * @brief Get the session id for a handshake. - * - * This will be a 32 byte sequence and is available after the first - * handshaking messages are sent. - * @return The session id as a 32 byte sequence. - * @note A SSLv23 handshake may have only 16 valid bytes. - */ - public byte[] getSessionId() - { - return axtlsj.ssl_get_session_id(m_ssl); - } - - /** - * @brief Retrieve an X.509 distinguished name component. - * - * When a handshake is complete and a certificate has been exchanged, - * then the details of the remote certificate can be retrieved. - * - * This will usually be used by a client to check that the server's common - * name matches the URL. - * - * A full handshake needs to occur for this call to work. - * - * @param component [in] one of: - * - SSL_X509_CERT_COMMON_NAME - * - SSL_X509_CERT_ORGANIZATION - * - SSL_X509_CERT_ORGANIZATIONAL_NAME - * - SSL_X509_CA_CERT_COMMON_NAME - * - SSL_X509_CA_CERT_ORGANIZATION - * - SSL_X509_CA_CERT_ORGANIZATIONAL_NAME - * @return The appropriate string (or null if not defined) - */ - public String getCertificateDN(int component) - { - return axtlsj.ssl_get_cert_dn(m_ssl, component); - } -} diff --git a/user/mpy/lib/axtls/bindings/java/SSLCTX.java b/user/mpy/lib/axtls/bindings/java/SSLCTX.java deleted file mode 100644 index 1cd3e03..0000000 --- a/user/mpy/lib/axtls/bindings/java/SSLCTX.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * A wrapper around the unmanaged interface to give a semi-decent Java API - */ - -package axTLSj; - -import java.net.*; - -/** - * @class SSLCTX - * @ingroup java_api - * @brief A base object for SSLServer/SSLClient. - */ -public class SSLCTX -{ - /** - * A reference to the real client/server context. - */ - protected int m_ctx; - - /** - * @brief Establish a new client/server context. - * - * This function is called before any client/server SSL connections are - * made. If multiple threads are used, then each thread will have its - * own SSLCTX context. Any number of connections may be made with a single - * context. - * - * Each new connection will use the this context's private key and - * certificate chain. If a different certificate chain is required, then a - * different context needs to be be used. - * - * @param options [in] Any particular options. At present the options - * supported are: - * - SSL_SERVER_VERIFY_LATER (client only): Don't stop a handshake if the - * server authentication fails. The certificate can be authenticated later - * with a call to verifyCert(). - * - SSL_CLIENT_AUTHENTICATION (server only): Enforce client authentication - * i.e. each handshake will include a "certificate request" message from - * the server. - * - SSL_DISPLAY_BYTES (full mode build only): Display the byte sequences - * during the handshake. - * - SSL_DISPLAY_STATES (full mode build only): Display the state changes - * during the handshake. - * - SSL_DISPLAY_CERTS (full mode build only): Display the certificates that - * are passed during a handshake. - * - SSL_DISPLAY_RSA (full mode build only): Display the RSA key details - * that are passed during a handshake. - * - * @param num_sessions [in] The number of sessions to be used for session - * caching. If this value is 0, then there is no session caching. - * - * If this option is null, then the default internal private key/ - * certificate pair is used (if CONFIG_SSL_USE_DEFAULT_KEY is set). - * - * The resources used by this object are automatically freed. - * @return A client/server context. - */ - protected SSLCTX(int options, int num_sessions) - { - m_ctx = axtlsj.ssl_ctx_new(options, num_sessions); - } - - /** - * @brief Remove a client/server context. - * - * Frees any used resources used by this context. Each connection will be - * sent a "Close Notify" alert (if possible). - */ - public void dispose() - { - axtlsj.ssl_ctx_free(m_ctx); - } - - /** - * @brief Read the SSL data stream. - * @param ssl [in] An SSL object reference. - * @param rh [out] After a successful read, the decrypted data can be - * retrieved with rh.getData(). It will be null otherwise. - * @return The number of decrypted bytes: - * - if > 0, then the handshaking is complete and we are returning the - * number of decrypted bytes. - * - SSL_OK if the handshaking stage is successful (but not yet complete). - * - < 0 if an error. - * @see ssl.h for the error code list. - * @note Use rh before doing any successive ssl calls. - */ - public int read(SSL ssl, SSLReadHolder rh) - { - return axtlsj.ssl_read(ssl.m_ssl, rh); - } - - /** - * @brief Write to the SSL data stream. - * @param ssl [in] An SSL obect reference. - * @param out_data [in] The data to be written - * @return The number of bytes sent, or if < 0 if an error. - * @see ssl.h for the error code list. - */ - public int write(SSL ssl, byte[] out_data) - { - return axtlsj.ssl_write(ssl.m_ssl, out_data, out_data.length); - } - - /** - * @brief Write to the SSL data stream. - * @param ssl [in] An SSL obect reference. - * @param out_data [in] The data to be written - * @param out_len [in] The number of bytes to be written - * @return The number of bytes sent, or if < 0 if an error. - * @see ssl.h for the error code list. - */ - public int write(SSL ssl, byte[] out_data, int out_len) - { - return axtlsj.ssl_write(ssl.m_ssl, out_data, out_len); - } - - /** - * @brief Find an ssl object based on a Socket reference. - * - * Goes through the list of SSL objects maintained in a client/server - * context to look for a socket match. - * @param s [in] A reference to a Socket object. - * @return A reference to the SSL object. Returns null if the object - * could not be found. - */ - public SSL find(Socket s) - { - int client_fd = axtlsj.getFd(s); - return new SSL(axtlsj.ssl_find(m_ctx, client_fd)); - } - - /** - * @brief Authenticate a received certificate. - * - * This call is usually made by a client after a handshake is complete - * and the context is in SSL_SERVER_VERIFY_LATER mode. - * @param ssl [in] An SSL object reference. - * @return SSL_OK if the certificate is verified. - */ - public int verifyCert(SSL ssl) - { - return axtlsj.ssl_verify_cert(ssl.m_ssl); - } - - /** - * @brief Force the client to perform its handshake again. - * - * For a client this involves sending another "client hello" message. - * For the server is means sending a "hello request" message. - * - * This is a blocking call on the client (until the handshake completes). - * @param ssl [in] An SSL object reference. - * @return SSL_OK if renegotiation instantiation was ok - */ - public int renegotiate(SSL ssl) - { - return axtlsj.ssl_renegotiate(ssl.m_ssl); - } - - /** - * @brief Load a file into memory that is in binary DER or ASCII PEM format. - * - * These are temporary objects that are used to load private keys, - * certificates etc into memory. - * @param obj_type [in] The format of the file. Can be one of: - * - SSL_OBJ_X509_CERT (no password required) - * - SSL_OBJ_X509_CACERT (no password required) - * - SSL_OBJ_RSA_KEY (AES128/AES256 PEM encryption supported) - * - SSL_OBJ_P8 (RC4-128 encrypted data supported) - * - SSL_OBJ_P12 (RC4-128 encrypted data supported) - * - * PEM files are automatically detected (if supported). - * @param filename [in] The location of a file in DER/PEM format. - * @param password [in] The password used. Can be null if not required. - * @return SSL_OK if all ok - */ - public int objLoad(int obj_type, String filename, String password) - { - return axtlsj.ssl_obj_load(m_ctx, obj_type, filename, password); - } - - /** - * @brief Transfer binary data into the object loader. - * - * These are temporary objects that are used to load private keys, - * certificates etc into memory. - * @param obj_type [in] The format of the memory data. - * @param data [in] The binary data to be loaded. - * @param len [in] The amount of data to be loaded. - * @param password [in] The password used. Can be null if not required. - * @return SSL_OK if all ok - */ - - public int objLoad(int obj_type, byte[] data, int len, String password) - { - return axtlsj.ssl_obj_memory_load(m_ctx, obj_type, data, len, password); - } -} diff --git a/user/mpy/lib/axtls/bindings/java/SSLClient.java b/user/mpy/lib/axtls/bindings/java/SSLClient.java deleted file mode 100644 index f65fe9c..0000000 --- a/user/mpy/lib/axtls/bindings/java/SSLClient.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * A wrapper around the unmanaged interface to give a semi-decent Java API - */ - -package axTLSj; - -import java.net.*; - -/** - * @class SSLClient - * @ingroup java_api - * @brief The client context. - * - * All client connections are started within a client context. - */ -public class SSLClient extends SSLCTX -{ - /** - * @brief Start a new client context. - * - * @see SSLCTX for details. - */ - public SSLClient(int options, int num_sessions) - { - super(options, num_sessions); - } - - /** - * @brief Establish a new SSL connection to an SSL server. - * - * It is up to the application to establish the initial socket connection. - * - * This is a blocking call - it will finish when the handshake is - * complete (or has failed). - * - * Call dispose() when the connection is to be removed. - * @param s [in] A reference to a Socket object. - * @param session_id [in] A 32 byte session id for session resumption. This - * can be null if no session resumption is not required. - * @return An SSL object reference. Use SSL.handshakeStatus() to check - * if a handshake succeeded. - */ - public SSL connect(Socket s, byte[] session_id) - { - int client_fd = axtlsj.getFd(s); - byte sess_id_size = (byte)(session_id != null ? - session_id.length : 0); - return new SSL(axtlsj.ssl_client_new(m_ctx, client_fd, session_id, - sess_id_size)); - } -} diff --git a/user/mpy/lib/axtls/bindings/java/SSLReadHolder.java b/user/mpy/lib/axtls/bindings/java/SSLReadHolder.java deleted file mode 100644 index 91fd76b..0000000 --- a/user/mpy/lib/axtls/bindings/java/SSLReadHolder.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * A wrapper around the unmanaged interface to give a semi-decent Java API - */ - -package axTLSj; - -/** - * @class SSLReadHolder - * @ingroup java_api - * @brief A holder for data read in an SSL read. - */ -public class SSLReadHolder -{ - /** - * @brief Contruct a new read holder object. - */ - public SSLReadHolder() - { - m_buf = null; - } - - /** - * @brief Retrieve the reference to the read data. - */ - public byte[] getData() - { - return m_buf; - } - - private byte[] m_buf; -} diff --git a/user/mpy/lib/axtls/bindings/java/SSLServer.java b/user/mpy/lib/axtls/bindings/java/SSLServer.java deleted file mode 100644 index 514ccb0..0000000 --- a/user/mpy/lib/axtls/bindings/java/SSLServer.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * A wrapper around the unmanaged interface to give a semi-decent Java API - */ - -package axTLSj; - -import java.net.*; - -/** - * @class SSLServer - * @ingroup java_api - * @brief The server context. - * - * All server connections are started within a server context. - */ -public class SSLServer extends SSLCTX -{ - /** - * @brief Start a new server context. - * - * @see SSLCTX for details. - */ - public SSLServer(int options, int num_sessions) - { - super(options, num_sessions); - } - - /** - * @brief Establish a new SSL connection to an SSL client. - * - * It is up to the application to establish the initial socket connection. - * - * Call dispose() when the connection is to be removed. - * @param s [in] A reference to a Socket object. - * @return An SSL object reference. - */ - public SSL connect(Socket s) - { - int client_fd = axtlsj.getFd(s); - return new SSL(axtlsj.ssl_server_new(m_ctx, client_fd)); - } -} diff --git a/user/mpy/lib/axtls/bindings/java/SSLUtil.java b/user/mpy/lib/axtls/bindings/java/SSLUtil.java deleted file mode 100644 index 3d53de5..0000000 --- a/user/mpy/lib/axtls/bindings/java/SSLUtil.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * A wrapper around the unmanaged interface to give a semi-decent Java API - */ - -package axTLSj; - -import java.io.*; -import java.util.*; - -/** - * @class SSLUtil - * @ingroup java_api - * @brief Some global helper functions. - * - */ -public class SSLUtil -{ - /** - * @brief Load up the ddl/shared library - */ - static - { - System.loadLibrary("axtlsj"); - } - - /** - * @brief Return the build mode of the axTLS project. - * @return The build mode is one of: - * - SSL_BUILD_SERVER_ONLY - * - SSL_BUILD_ENABLE_VERIFICATION - * - SSL_BUILD_ENABLE_CLIENT - * - SSL_BUILD_FULL_MODE - */ - public static int buildMode() - { - return axtlsj.ssl_get_config(axtlsj.SSL_BUILD_MODE); - } - - /** - * @brief Return the number of chained certificates that the client/server - * supports. - * @return The number of supported client/server certificates. - */ - public static int maxCerts() - { - return axtlsj.ssl_get_config(axtlsj.SSL_MAX_CERT_CFG_OFFSET); - } - - /** - * @brief Return the number of CA certificates that the client/server - * supports. - * @return The number of supported CA certificates. - */ - public static int maxCACerts() - { - return axtlsj.ssl_get_config(axtlsj.SSL_MAX_CA_CERT_CFG_OFFSET); - } - - /** - * @brief Indicate if PEM is supported. - * @return true if PEM supported. - */ - public static boolean hasPEM() - { - return axtlsj.ssl_get_config(axtlsj.SSL_HAS_PEM) > 0 ? true : false; - } - - /** - * @brief Display the text string of the error. - * @param error_code [in] The integer error code. - * @see ssl.h for the error code list. - */ - public static void displayError(int error_code) - { - axtlsj.ssl_display_error(error_code); - } - - /** - * @brief Return the version of the axTLS project. - */ - public static String version() - { - return axtlsj.ssl_version(); - } -} - diff --git a/user/mpy/lib/axtls/bindings/lua/Makefile b/user/mpy/lib/axtls/bindings/lua/Makefile deleted file mode 100644 index daacf92..0000000 --- a/user/mpy/lib/axtls/bindings/lua/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -AXTLS_HOME=../.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -all: lib - - -ifdef CONFIG_PLATFORM_WIN32 -TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsl.dll -else -TARGET=$(CONFIG_LUA_CORE)/lib/lua/5.1/axtlsl.so -endif - -ifneq ($(MAKECMDGOALS), clean) - -lib: $(TARGET) -OBJ:=axTLSl_wrap.o -include $(AXTLS_HOME)/config/makefile.post - -# there are a few static functions that aren't used -CFLAGS += -funit-at-a-time - -$(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) $(LDSHARED) -o $@ $^ -L$(AXTLS_HOME)/$(STAGE) -L$(CONFIG_LUA_CORE)/lib -laxtls -llua - -CFLAGS += -I $(CONFIG_LUA_CORE)/include -else -CFLAGS += /I"`cygpath -w $(CONFIG_LUA_CORE)/include`" -LDFLAGS += axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)" - -$(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ) -endif # WIN32 - -clean:: - @rm -f $(TARGET) *.i axTLSl* .depend diff --git a/user/mpy/lib/axtls/bindings/perl/Makefile b/user/mpy/lib/axtls/bindings/perl/Makefile deleted file mode 100644 index 92fd3c5..0000000 --- a/user/mpy/lib/axtls/bindings/perl/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -AXTLS_HOME=../.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -all: lib - -ifdef CONFIG_PLATFORM_WIN32 -TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsp.dll -else -TARGET=$(AXTLS_HOME)/$(STAGE)/libaxtlsp.so -endif - -ifneq ($(MAKECMDGOALS), clean) - -ifdef CONFIG_PLATFORM_WIN32 -PERL5_CORE:=$(shell cygpath -w "$(CONFIG_PERL_CORE)") -else -PERL5_CORE= $(shell perl -e 'use Config; print $$Config{archlib};')/CORE -endif - -all: test_perl - -test_perl: - @if ! [ -d "$(PERL5_CORE)" ]; then \ - echo "*** Error: Perl not installed at $(CONFIG_PERL_CORE) - go to " \ - "http://www.cpan.org/authors/id/G/GR/GRAHAMC/SiePerl-5.8.0-bin-1.0-Win32.INSTALL.exe" && exit 1; \ - fi - -endif - -lib: $(TARGET) -OBJ:=axTLSp_wrap.o -include $(AXTLS_HOME)/config/makefile.post - -ifndef CONFIG_PLATFORM_WIN32 # Linux/Unix/Cygwin - -# -# Could have used libperl.a, but it increases the library to over 1MB, so just -# use libperl.so. But this needs to be in the shared library path for things to -# work. -# -$(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) -L$(AXTLS_HOME)/$(STAGE) -L$(PERL5_CORE) $(LDSHARED) -o $@ $(OBJ) -laxtls -lperl -ifdef CONFIG_PLATFORM_CYGWIN - cd $(AXTLS_HOME)/$(STAGE); ln -sf $(notdir $@) axtlsp.dll -endif - @install axtlsp.pm $(AXTLS_HOME)/$(STAGE) - -CFLAGS += -D_GNU_SOURCE -I$(PERL5_CORE) -else -CFLAGS += /I"$(PERL5_CORE)" -LDFLAGS += $(CONFIG_PERL_LIB) /libpath:"$(PERL5_CORE)" axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)" - -$(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ) - install axtlsp.pm $(AXTLS_HOME)/$(STAGE) -endif # WIN32 - -clean:: - @rm -f $(TARGET) axtls* *.i axTLSp* *.c .depend $(AXTLS_HOME)/$(STAGE)/axtlsp.pm diff --git a/user/mpy/lib/axtls/bindings/vbnet/Makefile b/user/mpy/lib/axtls/bindings/vbnet/Makefile deleted file mode 100644 index 7da60d0..0000000 --- a/user/mpy/lib/axtls/bindings/vbnet/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf - -clean:: - @rm -f axssl* axInterface.vb diff --git a/user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb b/user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb deleted file mode 100644 index 9388273..0000000 --- a/user/mpy/lib/axtls/bindings/vbnet/axTLSvb.vb +++ /dev/null @@ -1,200 +0,0 @@ -' -' Copyright (c) 2007, Cameron Rich -' -' All rights reserved. -' -' Redistribution and use in source and binary forms, with or without -' modification, are permitted provided that the following conditions are met: -' -' * Redistributions of source code must retain the above copyright notice, -' this list of conditions and the following disclaimer. -' * Redistributions in binary form must reproduce the above copyright -' notice, this list of conditions and the following disclaimer in the -' documentation and/or other materials provided with the distribution. -' * Neither the name of the axTLS project nor the names of its -' contributors may be used to endorse or promote products derived -' from this software without specific prior written permission. -' -' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -' CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -' TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -' OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -' NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -' THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -' - -' -' A wrapper around the unmanaged Integererface to give a semi-decent VB.NET API -' - -Imports System -Imports System.Runtime.InteropServices -Imports System.Net.Sockets -Imports axTLSvb - -Namespace axTLSvb - Public Class SSL - Public m_ssl As IntPtr - - Public Sub New(ByRef ip As IntPtr) - m_ssl = ip - End Sub - - Public Sub Dispose() - axtls.ssl_free(m_ssl) - End Sub - - Public Function HandshakeStatus() As Integer - Return axtls.ssl_handshake_status(m_ssl) - End Function - - Public Function GetCipherId() As Byte - Return axtls.ssl_get_cipher_id(m_ssl) - End Function - - Public Function GetSessionId() As Byte() - Dim ptr As IntPtr = axtls.ssl_get_session_id(m_ssl) - Dim sess_id_size As Integer = axtls.ssl_get_session_id_size(m_ssl) - Dim result(sess_id_size-1) As Byte - Marshal.Copy(ptr, result, 0, sess_id_size) - Return result - End Function - - Public Function GetCertificateDN(component As Integer) As String - Return axtls.ssl_get_cert_dn(m_ssl, component) - End Function - End Class - - Public Class SSLUtil - Private dummy As Integer ' need something here - - Public Shared Function BuildMode() As Integer - Return axtls.ssl_get_config(axtls.SSL_BUILD_MODE) - End Function - - Public Shared Function MaxCerts() As Integer - Return axtls.ssl_get_config(axtls.SSL_MAX_CERT_CFG_OFFSET) - End Function - - Public Shared Function MaxCACerts() As Integer - Return axtls.ssl_get_config(axtls.SSL_MAX_CA_CERT_CFG_OFFSET) - End Function - - Public Shared Function HasPEM() As Boolean - If axtls.ssl_get_config(axtls.SSL_HAS_PEM) > 0 Then - Return True - Else - Return False - End If - End Function - - Public Shared Sub DisplayError(ByVal error_code As Integer) - axtls.ssl_display_error(error_code) - End Sub - - Public Shared Function Version() As String - Return axtls.ssl_version() - End Function - End Class - - Public Class SSLCTX - Protected m_ctx As IntPtr - - Protected Sub New(ByVal options As Integer, _ - ByVal num_sessions As Integer) - m_ctx = axtls.ssl_ctx_new(options, num_sessions) - End Sub - - Public Sub Dispose() - axtls.ssl_ctx_free(m_ctx) - End Sub - - Public Function Read(ByVal ssl As SSL, ByRef in_data As Byte()) As Integer - Dim ptr As IntPtr = IntPtr.Zero - Dim ret as Integer = axtls.ssl_read(ssl.m_ssl, ptr) - - If ret > axtls.SSL_OK Then - ReDim in_data(ret) - Marshal.Copy(ptr, in_data, 0, ret) - Else - in_data = Nothing - End If - - Return ret - End Function - - Public Function Write(ByVal ssl As SSL, _ - ByVal data As Byte(), len As Integer) As Integer - Return axtls.ssl_write(ssl.m_ssl, data, len) - End Function - - Public Function Find(ByVal s As Socket) As SSL - Dim client_fd As Integer = s.Handle.ToInt32() - Return New SSL(axtls.ssl_find(m_ctx, client_fd)) - End Function - - Public Function VerifyCert(ByVal ssl As SSL) As Integer - Return axtls.ssl_verify_cert(ssl.m_ssl) - End Function - - Public Function Renegotiate(ByVal ssl As SSL) As Integer - Return axtls.ssl_renegotiate(ssl.m_ssl) - End Function - - Public Function ObjLoad(ByVal obj_type As Integer, _ - ByVal filename As String, _ - password As String) As Integer - Return axtls.ssl_obj_load(m_ctx, obj_type, filename, password) - End Function - - Public Function ObjLoad(ByVal obj_type As Integer, _ - ByVal data As Byte(), ByVal len As Integer, _ - password As String) As Integer - Return axtls.ssl_obj_memory_load( _ - m_ctx, obj_type, data, len, password) - End Function - End Class - - Public Class SSLServer - Inherits SSLCTX - - Public Sub New(ByVal options As Integer, _ - ByVal num_sessions As Integer) - MyBase.New(options, num_sessions) - End Sub - - Public Function Connect(ByVal s As Socket) As SSL - Dim client_fd As Integer = s.Handle.ToInt32() - Return New SSL(axtls.ssl_server_new(m_ctx, client_fd)) - End Function - End Class - - Public Class SSLClient - Inherits SSLCTX - - Public Sub New(ByVal options As Integer, _ - ByVal num_sessions As Integer) - MyBase.New(options, num_sessions) - End Sub - - Public Function Connect(ByVal s As Socket, _ - ByVal session_id As Byte()) As SSL - Dim client_fd As Integer = s.Handle.ToInt32() - Dim sess_id_size As Byte - If session_id is Nothing Then - sess_id_size = 0 - Else - sess_id_size = session_id.Length - End If - - Return New SSL(axtls.ssl_client_new(m_ctx, client_fd, session_id, _ - sess_id_size)) - End Function - - End Class -End Namespace diff --git a/user/mpy/lib/axtls/config/Config.in b/user/mpy/lib/axtls/config/Config.in deleted file mode 100644 index c42bcef..0000000 --- a/user/mpy/lib/axtls/config/Config.in +++ /dev/null @@ -1,130 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see scripts/config/Kconfig-language.txt -# - -mainmenu "axTLS Configuration" - -config HAVE_DOT_CONFIG - bool - default y - -choice - prompt "Platform" - default CONFIG_PLATFORM_LINUX - -config CONFIG_PLATFORM_LINUX - bool "Linux" - -config CONFIG_PLATFORM_CYGWIN - bool "Cygwin" - -config CONFIG_PLATFORM_WIN32 - bool "Win32" - -endchoice - -menu "General Configuration" - -config PREFIX - string "axTLS installation prefix" - depends on !CONFIG_PLATFORM_WIN32 - default "/usr/local" - help - Define your directory to install axTLS files/subdirs in. - -config CONFIG_DEBUG - bool "Build axTLS with Debugging symbols" - default n - help - Say Y here if you wish to compile axTLS with debugging symbols. - This will allow you to use a debugger to examine axTLS internals. - This increases the size of the binary considerably and should only be - used when doing development. - If you are doing development and want to debug axTLS, answer Y. - - Most people should answer N. - -config CONFIG_STRIP_UNWANTED_SECTIONS - depends on !CONFIG_PLATFORM_WIN32 && !CONFIG_DEBUG - bool "Strip unwanted sections from elf binaries" - default y - help - Strip unwanted sections from the resulting binaries - -menu "Microsoft Compiler Options" -depends on CONFIG_PLATFORM_WIN32 - -choice - prompt "Compiler" - depends on CONFIG_PLATFORM_WIN32 - default CONFIG_VISUAL_STUDIO_10_0 - -config CONFIG_VISUAL_STUDIO_7_0 - bool "Visual Studio 7.0 (2003)" - help - Use Microsoft's Visual Studio 2003 platform. - -config CONFIG_VISUAL_STUDIO_8_0 - bool "Visual Studio 8.0 (2005)" - help - Use Microsoft's Visual Studio 2005 platform. - -config CONFIG_VISUAL_STUDIO_10_0 - bool "Visual Studio 10.0 (2010)" - help - Use Microsoft's Visual Studio 2010 platform. -endchoice - -config CONFIG_VISUAL_STUDIO_7_0_BASE - string "Base" - depends on CONFIG_VISUAL_STUDIO_7_0 - default "c:\\Program Files\\Microsoft Visual Studio .NET 2003" - -config CONFIG_VISUAL_STUDIO_8_0_BASE - string "Base" - depends on CONFIG_VISUAL_STUDIO_8_0 - default "c:\\Program Files\\Microsoft Visual Studio 8" - -config CONFIG_VISUAL_STUDIO_10_0_BASE - string "Base" - depends on CONFIG_VISUAL_STUDIO_10_0 - default "c:\\Program Files\\Microsoft Visual Studio 10.0" -endmenu - -config CONFIG_EXTRA_CFLAGS_OPTIONS - string "Any extra CFLAGS options for the compiler?" - help - Do you want to pass any extra CFLAGS options to the compiler as - you build axTLS? If so, this is the option for you... For - example, if you want to add some simple compiler switches (like - -march=i686), or check for warnings using -Werror, just those - options here. - -config CONFIG_EXTRA_LDFLAGS_OPTIONS - string "Any extra LDFLAGS options for the compiler?" - help - Do you want to pass any extra LDFLAGS options to the compiler? - -endmenu - -source ssl/Config.in -config CONFIG_AXTLSWRAP - depends on !CONFIG_PLATFORM_WIN32 - bool "Enable axtlswrap" - default n - help - axtlswrap is similar to sslwrap - http://www.rickk.com/sslwrap. - It enables SSL for processes that don't have native SSL support. - -config CONFIG_AXHTTPD - bool "Enable HTTP/HTTPS Web Server" - default y - help - Build the AXHTTPD web server - -source httpd/Config.in -source bindings/Config.in -source samples/Config.in -source ssl/BigIntConfig.in - diff --git a/user/mpy/lib/axtls/config/JMeter.jmx b/user/mpy/lib/axtls/config/JMeter.jmx deleted file mode 100755 index f62c03f..0000000 --- a/user/mpy/lib/axtls/config/JMeter.jmx +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - true - false - - - - - 1152004173000 - - - 16 - false - - 10 - false - - 1152004173000 - stopthread - 0 - - - - /index.html - GET - true - - true - 80 - - - - - - false - 127.0.0.1 - - false - - - - - 1152004173000 - - - 16 - false - - 10 - false - - 1152004173000 - stopthread - 0 - - - - /index.html - GET - true - HTTPS - true - 443 - - - - - - false - 127.0.0.1 - - false - - - - - 1152004173000 - - - 16 - false - - 10 - false - - 1152004173000 - stopthread - 0 - - - - /index.html - GET - true - HTTPS - true - 2443 - - - - - - false - 127.0.0.1 - - false - - - - - 1152004173000 - - - 16 - false - - 10 - false - - 1152004173000 - stopthread - 0 - - - - /index.html - GET - true - HTTPS - true - 3443 - - - - - - false - 127.0.0.1 - - false - - - - - 1152004173000 - - - 16 - false - - 10 - false - - 1152004173000 - stopthread - 0 - - - - /index.html - GET - true - HTTPS - true - 1443 - - - - - - false - 127.0.0.1 - - false - - - - - - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - false - false - false - false - false - 0 - - saveConfig - - - false - - - - - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - false - false - false - false - false - 0 - - saveConfig - - - false - - - - - diff --git a/user/mpy/lib/axtls/config/Rules.mak b/user/mpy/lib/axtls/config/Rules.mak deleted file mode 100644 index 7b6f2b3..0000000 --- a/user/mpy/lib/axtls/config/Rules.mak +++ /dev/null @@ -1,221 +0,0 @@ -# Rules.make for busybox -# -# Copyright (C) 1999-2005 by Erik Andersen -# -# Licensed under GPLv2, see the file LICENSE in this tarball for details. -# - -# Pull in the user's busybox configuration -ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) --include $(top_builddir)/.config -endif - -#-------------------------------------------------------- -PROG := busybox -MAJOR_VERSION :=1 -MINOR_VERSION :=1 -SUBLEVEL_VERSION:=0 -EXTRAVERSION := -VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION) -BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") - - -#-------------------------------------------------------- -# With a modern GNU make(1) (highly recommended, that's what all the -# developers use), all of the following configuration values can be -# overridden at the command line. For example: -# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app -#-------------------------------------------------------- - -# If you are running a cross compiler, you will want to set 'CROSS' -# to something more interesting... Target architecture is determined -# by asking the CC compiler what arch it compiles things for, so unless -# your compiler is broken, you should not need to specify TARGET_ARCH -CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) -CC = $(CROSS)gcc -AR = $(CROSS)ar -AS = $(CROSS)as -LD = $(CROSS)ld -NM = $(CROSS)nm -STRIP = $(CROSS)strip -CPP = $(CC) -E -# MAKEFILES = $(top_builddir)/.config -RM = rm -RM_F = $(RM) -f -LN = ln -LN_S = $(LN) -s -MKDIR = mkdir -MKDIR_P = $(MKDIR) -p -MV = mv -CP = cp - - -# What OS are you compiling busybox for? This allows you to include -# OS specific things, syscall overrides, etc. -TARGET_OS=linux - -# Select the compiler needed to build binaries for your development system -HOSTCC = gcc -HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer - -# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. -LC_ALL:= C - -# If you want to add some simple compiler switches (like -march=i686), -# especially from the command line, use this instead of CFLAGS directly. -# For optimization overrides, it's better still to set OPTIMIZATION. -CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS))) - -# To compile vs some other alternative libc, you may need to use/adjust -# the following lines to meet your needs... -# -# If you are using Red Hat 6.x with the compatible RPMs (for developing under -# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about -# using the compatible RPMs (compat-*) at http://www.redhat.com ! -#LIBCDIR:=/usr/i386-glibc20-linux -# -# For other libraries, you are on your own. But these may (or may not) help... -#LDFLAGS+=-nostdlib -#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc -#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char -#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") - -WARNINGS=-Wall -Wstrict-prototypes -Wshadow -CFLAGS=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) -ARFLAGS=cru - - -# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest -# get the CC MAJOR/MINOR version -CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) -CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1)) - -#-------------------------------------------------------- -export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP -ifeq ($(strip $(TARGET_ARCH)),) -TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ - -e 's/i.86/i386/' \ - -e 's/sparc.*/sparc/' \ - -e 's/arm.*/arm/g' \ - -e 's/m68k.*/m68k/' \ - -e 's/ppc/powerpc/g' \ - -e 's/v850.*/v850/g' \ - -e 's/sh[234]/sh/' \ - -e 's/mips-.*/mips/' \ - -e 's/mipsel-.*/mipsel/' \ - -e 's/cris.*/cris/' \ - ) -endif - -# A nifty macro to make testing gcc features easier -check_gcc=$(shell \ - if [ "$(1)" != "" ]; then \ - if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ - then echo "$(1)"; else echo "$(2)"; fi \ - fi) - -# Setup some shortcuts so that silent mode is silent like it should be -ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS)) -export MAKE_IS_SILENT=n -SECHO=@echo -else -export MAKE_IS_SILENT=y -SECHO=-@false -endif - -CFLAGS+=$(call check_gcc,-funsigned-char,) - -#-------------------------------------------------------- -# Arch specific compiler optimization stuff should go here. -# Unless you want to override the defaults, do not set anything -# for OPTIMIZATION... - -# use '-Os' optimization if available, else use -O2 -OPTIMIZATION:=$(call check_gcc,-Os,-O2) - -# Some nice architecture specific optimizations -ifeq ($(strip $(TARGET_ARCH)),arm) - OPTIMIZATION+=-fstrict-aliasing -endif -ifeq ($(strip $(TARGET_ARCH)),i386) - OPTIMIZATION+=$(call check_gcc,-march=i386,) - OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,) - OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\ - -malign-functions=0 -malign-jumps=0 -malign-loops=0) -endif -OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer - -# -#-------------------------------------------------------- -# If you're going to do a lot of builds with a non-vanilla configuration, -# it makes sense to adjust parameters above, so you can type "make" -# by itself, instead of following it by the same half-dozen overrides -# every time. The stuff below, on the other hand, is probably less -# prone to casual user adjustment. -# - -ifeq ($(strip $(CONFIG_LFS)),y) - # For large file summit support - CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -endif -ifeq ($(strip $(CONFIG_DMALLOC)),y) - # For testing mem leaks with dmalloc - CFLAGS+=-DDMALLOC - LIBRARIES:=-ldmalloc -else - ifeq ($(strip $(CONFIG_EFENCE)),y) - LIBRARIES:=-lefence - endif -endif -ifeq ($(strip $(CONFIG_DEBUG)),y) - CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE - LDFLAGS +=-Wl,-warn-common - STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging -else - CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG - LDFLAGS += -Wl,-warn-common - STRIPCMD:=echo - #$(STRIP) -s --remove-section=.note --remove-section=.comment -endif -ifeq ($(strip $(CONFIG_STATIC)),y) - LDFLAGS += --static -endif - -ifeq ($(strip $(CONFIG_SELINUX)),y) - LIBRARIES += -lselinux -endif - -ifeq ($(strip $(PREFIX)),) - PREFIX:=`pwd`/_install -endif - -# Additional complications due to support for pristine source dir. -# Include files in the build directory should take precedence over -# the copy in top_srcdir, both during the compilation phase and the -# shell script that finds the list of object files. -# Work in progress by . - - -OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o -CFLAGS += $(CROSS_CFLAGS) -ifdef BB_INIT_SCRIPT - CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' -endif - -# Put user-supplied flags at the end, where they -# have a chance of winning. -CFLAGS += $(CFLAGS_EXTRA) - -#------------------------------------------------------------ -# Installation options -ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y) -INSTALL_OPTS=--hardlinks -endif -ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y) -INSTALL_OPTS=--symlinks -endif -ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y) -INSTALL_OPTS= -endif - -.PHONY: dummy diff --git a/user/mpy/lib/axtls/config/axhttpd.aip b/user/mpy/lib/axtls/config/axhttpd.aip deleted file mode 100755 index 412fe3b..0000000 --- a/user/mpy/lib/axtls/config/axhttpd.aip +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/user/mpy/lib/axtls/config/axtls.RES b/user/mpy/lib/axtls/config/axtls.RES deleted file mode 100644 index 2929b3b679fddfb78bb58ebbccc5c0c4a9eb37d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22748 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 /dev/null 2>&1; then \ - echo "Mono not installed! - go " \ - "to http://www.mono-project.com/Main_Page" && exit 1; \ - fi - -endif # Linux - -endif # not 'clean' diff --git a/user/mpy/lib/axtls/config/makefile.java.conf b/user/mpy/lib/axtls/config/makefile.java.conf deleted file mode 100644 index 9b22462..0000000 --- a/user/mpy/lib/axtls/config/makefile.java.conf +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -ifneq ($(MAKECMDGOALS), clean) - -ifdef CONFIG_PLATFORM_CYGWIN -CFLAGS += -I"$(CONFIG_JAVA_HOME)/include" -CFLAGS += -I"$(CONFIG_JAVA_HOME)/include/win32" -JAVA_BIN:=$(CONFIG_JAVA_HOME)/bin -else - -ifdef CONFIG_PLATFORM_WIN32 -CFLAGS += /I"$(shell cygpath -w $(CONFIG_JAVA_HOME)/include)" -CFLAGS += /I"$(shell cygpath -w $(CONFIG_JAVA_HOME)/include/win32)" -JAVA_BIN:=$(shell cygpath -u $(CONFIG_JAVA_HOME)/bin) -else # Linux -CFLAGS += -I$(CONFIG_JAVA_HOME)/include - -ifdef CONFIG_PLATFORM_SOLARIS -CFLAGS += -I$(CONFIG_JAVA_HOME)/include/solaris -else -CFLAGS += -I$(CONFIG_JAVA_HOME)/include/linux -endif - -JAVA_BIN:=$(CONFIG_JAVA_HOME)/bin -endif -endif - -PATH:=$(JAVA_BIN):$(PATH) - -endif # not 'clean' diff --git a/user/mpy/lib/axtls/config/makefile.post b/user/mpy/lib/axtls/config/makefile.post deleted file mode 100644 index 033981c..0000000 --- a/user/mpy/lib/axtls/config/makefile.post +++ /dev/null @@ -1,19 +0,0 @@ - -ifneq ($(MAKECMDGOALS), clean) -ifndef CONFIG_PLATFORM_WIN32 -ifndef CONFIG_PLATFORM_SOLARIS -# do dependencies --include .depend -all : .depend -.depend: $(wildcard *.c) - @$(CC) $(CFLAGS) -MM $^ > $@ -endif # 'not' solaris -endif # 'not' win32 - -ifdef CONFIG_PLATFORM_WIN32 -OBJ:=$(OBJ:.o=.obj) -%.obj : %.c - $(CC) $(CFLAGS) $< -endif # win32 - -endif # end of 'not' clean diff --git a/user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt b/user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt deleted file mode 100644 index 493749b..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/Kconfig-language.txt +++ /dev/null @@ -1,255 +0,0 @@ -Introduction ------------- - -The configuration database is collection of configuration options -organized in a tree structure: - - +- Code maturity level options - | +- Prompt for development and/or incomplete code/drivers - +- General setup - | +- Networking support - | +- System V IPC - | +- BSD Process Accounting - | +- Sysctl support - +- Loadable module support - | +- Enable loadable module support - | +- Set version information on all module symbols - | +- Kernel module loader - +- ... - -Every entry has its own dependencies. These dependencies are used -to determine the visible of an entry. Any child entry is only -visible if its parent entry is also visible. - -Menu entries ------------- - -Most entries define a config option, all other entries help to organize -them. A single configuration option is defined like this: - -config MODVERSIONS - bool "Set version information on all module symbols" - depends MODULES - help - Usually, modules have to be recompiled whenever you switch to a new - kernel. ... - -Every line starts with a key word and can be followed by multiple -arguments. "config" starts a new config entry. The following lines -define attributes for this config option. Attributes can be the type of -the config option, input prompt, dependencies, help text and default -values. A config option can be defined multiple times with the same -name, but every definition can have only a single input prompt and the -type must not conflict. - -Menu attributes ---------------- - -A menu entry can have a number of attributes. Not all of them are -applicable everywhere (see syntax). - -- type definition: "bool"/"tristate"/"string"/"hex"/"integer" - Every config option must have a type. There are only two basic types: - tristate and string, the other types base on these two. The type - definition optionally accepts an input prompt, so these two examples - are equivalent: - - bool "Networking support" - and - bool - prompt "Networking support" - -- input prompt: "prompt" ["if" ] - Every menu entry can have at most one prompt, which is used to display - to the user. Optionally dependencies only for this prompt can be added - with "if". - -- default value: "default" ["if" ] - A config option can have any number of default values. If multiple - default values are visible, only the first defined one is active. - Default values are not limited to the menu entry, where they are - defined, this means the default can be defined somewhere else or be - overriden by an earlier definition. - The default value is only assigned to the config symbol if no other - value was set by the user (via the input prompt above). If an input - prompt is visible the default value is presented to the user and can - be overridden by him. - Optionally dependencies only for this default value can be added with - "if". - -- dependencies: "depends on"/"requires" - This defines a dependency for this menu entry. If multiple - dependencies are defined they are connected with '&&'. Dependencies - are applied to all other options within this menu entry (which also - accept "if" expression), so these two examples are equivalent: - - bool "foo" if BAR - default y if BAR - and - depends on BAR - bool "foo" - default y - -- help text: "help" - This defines a help text. The end of the help text is determined by - the level indentation, this means it ends at the first line which has - a smaller indentation than the first line of the help text. - - -Menu dependencies ------------------ - -Dependencies define the visibility of a menu entry and can also reduce -the input range of tristate symbols. The tristate logic used in the -expressions uses one more state than normal boolean logic to express the -module state. Dependency expressions have the following syntax: - - ::= (1) - '=' (2) - '!=' (3) - '(' ')' (4) - '!' (5) - '||' (6) - '&&' (7) - -Expressions are listed in decreasing order of precedence. - -(1) Convert the symbol into an expression. Boolean and tristate symbols - are simply converted into the respective expression values. All - other symbol types result in 'n'. -(2) If the values of both symbols are equal, it returns 'y', - otherwise 'n'. -(3) If the values of both symbols are equal, it returns 'n', - otherwise 'y'. -(4) Returns the value of the expression. Used to override precedence. -(5) Returns the result of (2-/expr/). -(6) Returns the result of min(/expr/, /expr/). -(7) Returns the result of max(/expr/, /expr/). - -An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 -respectively for calculations). A menu entry becomes visible when it's -expression evaluates to 'm' or 'y'. - -There are two type of symbols: constant and nonconstant symbols. -Nonconstant symbols are the most common ones and are defined with the -'config' statement. Nonconstant symbols consist entirely of alphanumeric -characters or underscores. -Constant symbols are only part of expressions. Constant symbols are -always surrounded by single or double quotes. Within the quote any -other character is allowed and the quotes can be escaped using '\'. - -Menu structure --------------- - -The position of a menu entry in the tree is determined in two ways. First -it can be specified explicitely: - -menu "Network device support" - depends NET - -config NETDEVICES - ... - -endmenu - -All entries within the "menu" ... "endmenu" block become a submenu of -"Network device support". All subentries inherit the dependencies from -the menu entry, e.g. this means the dependency "NET" is added to the -dependency list of the config option NETDEVICES. - -The other way to generate the menu structure is done by analyzing the -dependencies. If a menu entry somehow depends on the previous entry, it -can be made a submenu of it. First the the previous (parent) symbol must -be part of the dependency list and then one of these two condititions -must be true: -- the child entry must become invisible, if the parent is set to 'n' -- the child entry must only be visible, if the parent is visible - -config MODULES - bool "Enable loadable module support" - -config MODVERSIONS - bool "Set version information on all module symbols" - depends MODULES - -comment "module support disabled" - depends !MODULES - -MODVERSIONS directly depends on MODULES, this means it's only visible if -MODULES is different from 'n'. The comment on the other hand is always -visible when MODULES it's visible (the (empty) dependency of MODULES is -also part of the comment dependencies). - - -Kconfig syntax --------------- - -The configuration file describes a series of menu entries, where every -line starts with a keyword (except help texts). The following keywords -end a menu entry: -- config -- choice/endchoice -- comment -- menu/endmenu -- if/endif -- source -The first four also start the definition of a menu entry. - -config: - - "config" - - -This defines a config symbol and accepts any of above -attributes as options. - -choices: - - "choice" - - - "endchoice" - -This defines a choice group and accepts any of above attributes as -options. A choice can only be of type bool or tristate, while a boolean -choice only allows a single config entry to be selected, a tristate -choice also allows any number of config entries to be set to 'm'. This -can be used if multiple drivers for a single hardware exists and only a -single driver can be compiled/loaded into the kernel, but all drivers -can be compiled as modules. -A choice accepts another option "optional", which allows to set the -choice to 'n' and no entry needs to be selected. - -comment: - - "comment" - - -This defines a comment which is displayed to the user during the -configuration process and is also echoed to the output files. The only -possible options are dependencies. - -menu: - - "menu" -

- - "endmenu" - -This defines a menu block, see "Menu structure" above for more -information. The only possible options are dependencies. - -if: - - "if" - - "endif" - -This defines an if block. The dependency expression is appended -to all enclosed menu entries. - -source: - - "source" - -This reads the specified configuration file. This file is always parsed. diff --git a/user/mpy/lib/axtls/config/scripts/config/Makefile b/user/mpy/lib/axtls/config/scripts/config/Makefile deleted file mode 100644 index 7399501..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/Makefile +++ /dev/null @@ -1,121 +0,0 @@ -# Makefile for axTLS -# -# Copyright (C) 2002 Erik Andersen - -top_srcdir=../.. -top_builddir=../.. -srcdir=$(top_srcdir)/scripts/config -include $(top_srcdir)/Rules.mak - -all: ncurses conf mconf - -ifeq ($(shell uname),SunOS) -LIBS = -lcurses -else -LIBS = -lncurses -endif -ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) - HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="" -else -ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) - HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="" -else -ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h)) - HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="" -else -ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h)) - HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="" -else -ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) - HOSTNCURSES += -DCURSES_LOC="" -else - HOSTNCURSES += -DCURSES_LOC="" -endif -endif -endif -endif -endif - -CONF_SRC = conf.c -MCONF_SRC = mconf.c -LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \ - lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \ - lxdialog/msgbox.c - -SHARED_SRC = zconf.tab.c -SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ - lkc_defs.h $(srcdir)/expr.h zconf.tab.h -CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC)) -MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC)) -SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC)) - -conf: $(CONF_OBJS) $(SHARED_OBJS) - $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ - -mconf: $(MCONF_OBJS) $(SHARED_OBJS) - $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS) - -$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS) - $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@ - -$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS) - @[ -d $(@D) ] || mkdir -v $(@D) - $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@ - -lkc_defs.h: $(srcdir)/lkc_proto.h - @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' - -### -# The following requires flex/bison -# By default we use the _shipped versions, uncomment the -# following line if you are modifying the flex/bison src. -#LKC_GENPARSER := 1 - -ifdef LKC_GENPARSER - -%.tab.c %.tab.h: $(srcdir)/%.y - bison -t -d -v -b $* -p $(notdir $*) $< - -lex.%.c: $(srcdir)/%.l - flex -P$(notdir $*) -o$@ $< -else - -lex.zconf.o: lex.zconf.c $(SHARED_DEPS) - $(HOSTCC) $(HOSTCFLAGS) -I$(srcdir) -c $< -o $@ - -lex.zconf.c: $(srcdir)/lex.zconf.c_shipped - cp $< $@ - -zconf.tab.c: $(srcdir)/zconf.tab.c_shipped - cp $< $@ - -zconf.tab.h: $(srcdir)/zconf.tab.h_shipped - cp $< $@ -endif - -zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \ - $(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS) - $(HOSTCC) $(HOSTCFLAGS) -I$(srcdir) -I. -c $< -o $@ - -.PHONY: ncurses - -ncurses: - @echo "main() {}" > lxtemp.c - @if $(HOSTCC) lxtemp.c $(LIBS) ; then \ - rm -f lxtemp.c a.out; \ - else \ - rm -f lxtemp.c; \ - echo -e "\007" ;\ - echo ">> Unable to find the Ncurses libraries." ;\ - echo ">>" ;\ - echo ">> You must have Ncurses installed in order" ;\ - echo ">> to use 'make menuconfig'" ;\ - echo ;\ - exit 1 ;\ - fi - -clean: - rm -f *.o *~ ../../*~ core *.exe $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) - rm -f conf conf.exe mconf mconf.exe zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h - rm -f ../..config.h - diff --git a/user/mpy/lib/axtls/config/scripts/config/conf.c b/user/mpy/lib/axtls/config/scripts/config/conf.c deleted file mode 100644 index 1524467..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/conf.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -static void conf(struct menu *menu); -static void check_conf(struct menu *menu); - -enum { - ask_all, - ask_new, - ask_silent, - set_default, - set_yes, - set_mod, - set_no, - set_random -} input_mode = ask_all; -char *defconfig_file; - -static int indent = 1; -static int valid_stdin = 1; -static int conf_cnt; -static char line[128]; -static struct menu *rootEntry; - -static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; - -static void strip(char *str) -{ - char *p = str; - int l; - - while ((isspace(*p))) - p++; - l = strlen(p); - if (p != str) - memmove(str, p, l + 1); - if (!l) - return; - p = str + l - 1; - while ((isspace(*p))) - *p-- = 0; -} - -static void check_stdin(void) -{ - if (!valid_stdin && input_mode == ask_silent) { - printf("aborted!\n\n"); - printf("Console input/output is redirected. "); - printf("Run 'make oldconfig' to update configuration.\n\n"); - exit(1); - } -} - -static void conf_askvalue(struct symbol *sym, const char *def) -{ - enum symbol_type type = sym_get_type(sym); - tristate val; - - if (!sym_has_value(sym)) - printf("(NEW) "); - - line[0] = '\n'; - line[1] = 0; - - if (!sym_is_changable(sym)) { - printf("%s\n", def); - line[0] = '\n'; - line[1] = 0; - return; - } - - switch (input_mode) { - case ask_new: - case ask_silent: - if (sym_has_value(sym)) { - printf("%s\n", def); - return; - } - check_stdin(); - case ask_all: - fflush(stdout); - fgets(line, 128, stdin); - return; - case set_default: - printf("%s\n", def); - return; - default: - break; - } - - switch (type) { - case S_INT: - case S_HEX: - case S_STRING: - printf("%s\n", def); - return; - default: - ; - } - switch (input_mode) { - case set_yes: - if (sym_tristate_within_range(sym, yes)) { - line[0] = 'y'; - line[1] = '\n'; - line[2] = 0; - break; - } - case set_mod: - if (type == S_TRISTATE) { - if (sym_tristate_within_range(sym, mod)) { - line[0] = 'm'; - line[1] = '\n'; - line[2] = 0; - break; - } - } else { - if (sym_tristate_within_range(sym, yes)) { - line[0] = 'y'; - line[1] = '\n'; - line[2] = 0; - break; - } - } - case set_no: - if (sym_tristate_within_range(sym, no)) { - line[0] = 'n'; - line[1] = '\n'; - line[2] = 0; - break; - } - case set_random: - do { - val = (tristate)(random() % 3); - } while (!sym_tristate_within_range(sym, val)); - switch (val) { - case no: line[0] = 'n'; break; - case mod: line[0] = 'm'; break; - case yes: line[0] = 'y'; break; - } - line[1] = '\n'; - line[2] = 0; - break; - default: - break; - } - printf("%s", line); -} - -int conf_string(struct menu *menu) -{ - struct symbol *sym = menu->sym; - const char *def, *help; - - while (1) { - printf("%*s%s ", indent - 1, "", menu->prompt->text); - printf("(%s) ", sym->name); - def = sym_get_string_value(sym); - if (sym_get_string_value(sym)) - printf("[%s] ", def); - conf_askvalue(sym, def); - switch (line[0]) { - case '\n': - break; - case '?': - /* print help */ - if (line[1] == '\n') { - help = nohelp_text; - if (menu->sym->help) - help = menu->sym->help; - printf("\n%s\n", menu->sym->help); - def = NULL; - break; - } - default: - line[strlen(line)-1] = 0; - def = line; - } - if (def && sym_set_string_value(sym, def)) - return 0; - } -} - -static int conf_sym(struct menu *menu) -{ - struct symbol *sym = menu->sym; - int type; - tristate oldval, newval; - const char *help; - - while (1) { - printf("%*s%s ", indent - 1, "", menu->prompt->text); - if (sym->name) - printf("(%s) ", sym->name); - type = sym_get_type(sym); - putchar('['); - oldval = sym_get_tristate_value(sym); - switch (oldval) { - case no: - putchar('N'); - break; - case mod: - putchar('M'); - break; - case yes: - putchar('Y'); - break; - } - if (oldval != no && sym_tristate_within_range(sym, no)) - printf("/n"); - if (oldval != mod && sym_tristate_within_range(sym, mod)) - printf("/m"); - if (oldval != yes && sym_tristate_within_range(sym, yes)) - printf("/y"); - if (sym->help) - printf("/?"); - printf("] "); - conf_askvalue(sym, sym_get_string_value(sym)); - strip(line); - - switch (line[0]) { - case 'n': - case 'N': - newval = no; - if (!line[1] || !strcmp(&line[1], "o")) - break; - continue; - case 'm': - case 'M': - newval = mod; - if (!line[1]) - break; - continue; - case 'y': - case 'Y': - newval = yes; - if (!line[1] || !strcmp(&line[1], "es")) - break; - continue; - case 0: - newval = oldval; - break; - case '?': - goto help; - default: - continue; - } - if (sym_set_tristate_value(sym, newval)) - return 0; -help: - help = nohelp_text; - if (sym->help) - help = sym->help; - printf("\n%s\n", help); - } -} - -static int conf_choice(struct menu *menu) -{ - struct symbol *sym, *def_sym; - struct menu *child; - int type; - bool is_new; - - sym = menu->sym; - type = sym_get_type(sym); - is_new = !sym_has_value(sym); - if (sym_is_changable(sym)) { - conf_sym(menu); - sym_calc_value(sym); - switch (sym_get_tristate_value(sym)) { - case no: - return 1; - case mod: - return 0; - case yes: - break; - } - } else { - switch (sym_get_tristate_value(sym)) { - case no: - return 1; - case mod: - printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); - return 0; - case yes: - break; - } - } - - while (1) { - int cnt, def; - - printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); - def_sym = sym_get_choice_value(sym); - cnt = def = 0; - line[0] = '0'; - line[1] = 0; - for (child = menu->list; child; child = child->next) { - if (!menu_is_visible(child)) - continue; - if (!child->sym) { - printf("%*c %s\n", indent, '*', menu_get_prompt(child)); - continue; - } - cnt++; - if (child->sym == def_sym) { - def = cnt; - printf("%*c", indent, '>'); - } else - printf("%*c", indent, ' '); - printf(" %d. %s", cnt, menu_get_prompt(child)); - if (child->sym->name) - printf(" (%s)", child->sym->name); - if (!sym_has_value(child->sym)) - printf(" (NEW)"); - printf("\n"); - } - printf("%*schoice", indent - 1, ""); - if (cnt == 1) { - printf("[1]: 1\n"); - goto conf_childs; - } - printf("[1-%d", cnt); - if (sym->help) - printf("?"); - printf("]: "); - switch (input_mode) { - case ask_new: - case ask_silent: - if (!is_new) { - cnt = def; - printf("%d\n", cnt); - break; - } - check_stdin(); - case ask_all: - fflush(stdout); - fgets(line, 128, stdin); - strip(line); - if (line[0] == '?') { - printf("\n%s\n", menu->sym->help ? - menu->sym->help : nohelp_text); - continue; - } - if (!line[0]) - cnt = def; - else if (isdigit(line[0])) - cnt = atoi(line); - else - continue; - break; - case set_random: - def = (random() % cnt) + 1; - case set_default: - case set_yes: - case set_mod: - case set_no: - cnt = def; - printf("%d\n", cnt); - break; - } - - conf_childs: - for (child = menu->list; child; child = child->next) { - if (!child->sym || !menu_is_visible(child)) - continue; - if (!--cnt) - break; - } - if (!child) - continue; - if (line[strlen(line) - 1] == '?') { - printf("\n%s\n", child->sym->help ? - child->sym->help : nohelp_text); - continue; - } - sym_set_choice_value(sym, child->sym); - if (child->list) { - indent += 2; - conf(child->list); - indent -= 2; - } - return 1; - } -} - -static void conf(struct menu *menu) -{ - struct symbol *sym; - struct property *prop; - struct menu *child; - - if (!menu_is_visible(menu)) - return; - - sym = menu->sym; - prop = menu->prompt; - if (prop) { - const char *prompt; - - switch (prop->type) { - case P_MENU: - if (input_mode == ask_silent && rootEntry != menu) { - check_conf(menu); - return; - } - case P_COMMENT: - prompt = menu_get_prompt(menu); - if (prompt) - printf("%*c\n%*c %s\n%*c\n", - indent, '*', - indent, '*', prompt, - indent, '*'); - default: - ; - } - } - - if (!sym) - goto conf_childs; - - if (sym_is_choice(sym)) { - conf_choice(menu); - if (sym->curr.tri != mod) - return; - goto conf_childs; - } - - switch (sym->type) { - case S_INT: - case S_HEX: - case S_STRING: - conf_string(menu); - break; - default: - conf_sym(menu); - break; - } - -conf_childs: - if (sym) - indent += 2; - for (child = menu->list; child; child = child->next) - conf(child); - if (sym) - indent -= 2; -} - -static void check_conf(struct menu *menu) -{ - struct symbol *sym; - struct menu *child; - - if (!menu_is_visible(menu)) - return; - - sym = menu->sym; - if (sym) { - if (sym_is_changable(sym) && !sym_has_value(sym)) { - if (!conf_cnt++) - printf("*\n* Restart config...\n*\n"); - rootEntry = menu_get_parent_menu(menu); - conf(rootEntry); - } - if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod) - return; - } - - for (child = menu->list; child; child = child->next) - check_conf(child); -} - -int main(int ac, char **av) -{ - int i = 1; - const char *name; - struct stat tmpstat; - - if (ac > i && av[i][0] == '-') { - switch (av[i++][1]) { - case 'o': - input_mode = ask_new; - break; - case 's': - input_mode = ask_silent; - valid_stdin = isatty(0) && isatty(1) && isatty(2); - break; - case 'd': - input_mode = set_default; - break; - case 'D': - input_mode = set_default; - defconfig_file = av[i++]; - if (!defconfig_file) { - printf("%s: No default config file specified\n", - av[0]); - exit(1); - } - break; - case 'n': - input_mode = set_no; - break; - case 'm': - input_mode = set_mod; - break; - case 'y': - input_mode = set_yes; - break; - case 'r': - input_mode = set_random; - srandom(time(NULL)); - break; - case 'h': - case '?': - printf("%s [-o|-s] config\n", av[0]); - exit(0); - } - } - name = av[i]; - if (!name) { - printf("%s: configuration file missing\n", av[0]); - } - conf_parse(name); - //zconfdump(stdout); - switch (input_mode) { - case set_default: - if (!defconfig_file) - defconfig_file = conf_get_default_confname(); - if (conf_read(defconfig_file)) { - printf("***\n" - "*** Can't find default configuration \"%s\"!\n" - "***\n", defconfig_file); - exit(1); - } - break; - case ask_silent: - if (stat(".config", &tmpstat)) { - printf("***\n" - "*** You have not yet configured axTLS!\n" - "***\n" - "*** Please run some configurator (e.g. \"make oldconfig\" or\n" - "*** \"make menuconfig\" or \"make config\").\n" - "***\n"); - exit(1); - } - case ask_all: - case ask_new: - conf_read(NULL); - break; - default: - break; - } - - if (input_mode != ask_silent) { - rootEntry = &rootmenu; - conf(&rootmenu); - if (input_mode == ask_all) { - input_mode = ask_silent; - valid_stdin = 1; - } - } - do { - conf_cnt = 0; - check_conf(&rootmenu); - } while (conf_cnt); - if (conf_write(NULL)) { - fprintf(stderr, "\n*** Error during writing of the axTLS configuration.\n\n"); - return 1; - } - return 0; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/confdata.c b/user/mpy/lib/axtls/config/scripts/config/confdata.c deleted file mode 100644 index a59e245..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/confdata.c +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -const char conf_def_filename[] = "config/.config"; - -const char conf_defname[] = "config/defconfig"; - -const char *conf_confnames[] = { - "config/.config", - conf_defname, - NULL, -}; - -static char *conf_expand_value(const char *in) -{ - struct symbol *sym; - const char *src; - static char res_value[SYMBOL_MAXLENGTH]; - char *dst, name[SYMBOL_MAXLENGTH]; - - res_value[0] = 0; - dst = name; - while ((src = strchr(in, '$'))) { - strncat(res_value, in, src - in); - src++; - dst = name; - while (isalnum(*src) || *src == '_') - *dst++ = *src++; - *dst = 0; - sym = sym_lookup(name, 0); - sym_calc_value(sym); - strcat(res_value, sym_get_string_value(sym)); - in = src; - } - strcat(res_value, in); - - return res_value; -} - -char *conf_get_default_confname(void) -{ - struct stat buf; - static char fullname[PATH_MAX+1]; - char *env, *name; - - name = conf_expand_value(conf_defname); - env = getenv(SRCTREE); - if (env) { - sprintf(fullname, "%s/%s", env, name); - if (!stat(fullname, &buf)) - return fullname; - } - return name; -} - -int conf_read(const char *name) -{ - FILE *in = NULL; - char line[1024]; - char *p, *p2; - int lineno = 0; - struct symbol *sym; - struct property *prop; - struct expr *e; - int i; - - if (name) { - in = zconf_fopen(name); - } else { - const char **names = conf_confnames; - while ((name = *names++)) { - name = conf_expand_value(name); - in = zconf_fopen(name); - if (in) { - printf("#\n" - "# using defaults found in %s\n" - "#\n", name); - break; - } - } - } - - if (!in) - return 1; - - for_all_symbols(i, sym) { - sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; - sym->flags &= ~SYMBOL_VALID; - switch (sym->type) { - case S_INT: - case S_HEX: - case S_STRING: - if (sym->user.val) - free(sym->user.val); - default: - sym->user.val = NULL; - sym->user.tri = no; - } - } - - while (fgets(line, sizeof(line), in)) { - lineno++; - sym = NULL; - switch (line[0]) { - case '#': - if (line[1]!=' ') - continue; - p = strchr(line + 2, ' '); - if (!p) - continue; - *p++ = 0; - if (strncmp(p, "is not set", 10)) - continue; - sym = sym_find(line + 2); - if (!sym) { - fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2); - break; - } - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - sym->user.tri = no; - sym->flags &= ~SYMBOL_NEW; - break; - default: - ; - } - break; - - case 'A' ... 'Z': - p = strchr(line, '='); - if (!p) - continue; - *p++ = 0; - p2 = strchr(p, '\n'); - if (p2) - *p2 = 0; - sym = sym_find(line); - if (!sym) { - fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); - break; - } - switch (sym->type) { - case S_TRISTATE: - if (p[0] == 'm') { - sym->user.tri = mod; - sym->flags &= ~SYMBOL_NEW; - break; - } - case S_BOOLEAN: - if (p[0] == 'y') { - sym->user.tri = yes; - sym->flags &= ~SYMBOL_NEW; - break; - } - if (p[0] == 'n') { - sym->user.tri = no; - sym->flags &= ~SYMBOL_NEW; - break; - } - break; - case S_STRING: - if (*p++ != '"') - break; - for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { - if (*p2 == '"') { - *p2 = 0; - break; - } - memmove(p2, p2 + 1, strlen(p2)); - } - if (!p2) { - fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); - exit(1); - } - case S_INT: - case S_HEX: - if (sym_string_valid(sym, p)) { - sym->user.val = strdup(p); - sym->flags &= ~SYMBOL_NEW; - } else { - fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); - exit(1); - } - break; - default: - ; - } - break; - case '\n': - break; - default: - continue; - } - if (sym && sym_is_choice_value(sym)) { - struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); - switch (sym->user.tri) { - case no: - break; - case mod: - if (cs->user.tri == yes) - /* warn? */; - break; - case yes: - if (cs->user.tri != no) - /* warn? */; - cs->user.val = sym; - break; - } - cs->user.tri = E_OR(cs->user.tri, sym->user.tri); - cs->flags &= ~SYMBOL_NEW; - } - } - fclose(in); - - if (modules_sym) - sym_calc_value(modules_sym); - for_all_symbols(i, sym) { - sym_calc_value(sym); - if (sym_has_value(sym) && !sym_is_choice_value(sym)) { - if (sym->visible == no) - sym->flags |= SYMBOL_NEW; - switch (sym->type) { - case S_STRING: - case S_INT: - case S_HEX: - if (!sym_string_within_range(sym, sym->user.val)) - sym->flags |= SYMBOL_NEW; - default: - break; - } - } - if (!sym_is_choice(sym)) - continue; - prop = sym_get_choice_prop(sym); - for (e = prop->expr; e; e = e->left.expr) - if (e->right.sym->visible != no) - sym->flags |= e->right.sym->flags & SYMBOL_NEW; - } - - sym_change_count = 1; - - return 0; -} - -struct menu *next_menu(struct menu *menu) -{ - if (menu->list) return menu->list; - do { - if (menu->next) { - menu = menu->next; - break; - } - } while ((menu = menu->parent)); - - return menu; -} - -#define SYMBOL_FORCEWRITE (1<<31) - -int conf_write(const char *name) -{ - FILE *out, *out_h; - struct symbol *sym; - struct menu *menu; - const char *basename; - char dirname[128], tmpname[128], newname[128]; - int type, l; - const char *str; - - dirname[0] = 0; - if (name && name[0]) { - struct stat st; - char *slash; - - if (!stat(name, &st) && S_ISDIR(st.st_mode)) { - strcpy(dirname, name); - strcat(dirname, "/"); - basename = conf_def_filename; - } else if ((slash = strrchr(name, '/'))) { - int size = slash - name + 1; - memcpy(dirname, name, size); - dirname[size] = 0; - if (slash[1]) - basename = slash + 1; - else - basename = conf_def_filename; - } else - basename = name; - } else - basename = conf_def_filename; - - sprintf(newname, "config/%s.tmpconfig.%d", dirname, (int)getpid()); - out = fopen(newname, "w"); - if (!out) - return 1; - out_h = NULL; - if (!name) { - out_h = fopen("config/.tmpconfig.h", "w"); - if (!out_h) - return 1; - } - fprintf(out, "#\n" - "# Automatically generated make config: don't edit\n" - "#\n"); - if (out_h) { - fprintf(out_h, "/*\n" - " * Automatically generated header file: don't edit\n" - " */\n\n"); -#if 0 - "/* Version Number */\n" - "#define BB_VER \"%s\"\n" - "#define BB_BT \"%s\"\n", - getenv("VERSION"), - getenv("BUILDTIME")); - if (getenv("EXTRA_VERSION")) - fprintf(out_h, "#define BB_EXTRA_VERSION \"%s\"\n", - getenv("EXTRA_VERSION")); - fprintf(out_h, "\n"); -#endif - } - - if (!sym_change_count) - sym_clear_all_valid(); - - /* Force write of all non-duplicate symbols. */ - - /* Write out everything by default. */ - for(menu = rootmenu.list; menu; menu = next_menu(menu)) - if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE; - - menu = rootmenu.list; - while (menu) { - sym = menu->sym; - if (!sym) { - if (!menu_is_visible(menu)) - goto next; - str = menu_get_prompt(menu); - fprintf(out, "\n" - "#\n" - "# %s\n" - "#\n", str); - if (out_h) - fprintf(out_h, "\n" - "/*\n" - " * %s\n" - " */\n", str); - } else if (!(sym->flags & SYMBOL_CHOICE)) { - sym_calc_value(sym); - if (!(sym->flags & SYMBOL_FORCEWRITE)) - goto next; - - sym->flags &= ~SYMBOL_FORCEWRITE; - type = sym->type; - if (type == S_TRISTATE) { - sym_calc_value(modules_sym); - if (modules_sym->curr.tri == no) - type = S_BOOLEAN; - } - switch (type) { - case S_BOOLEAN: - case S_TRISTATE: - switch (sym_get_tristate_value(sym)) { - case no: - fprintf(out, "# %s is not set\n", sym->name); - if (out_h) - fprintf(out_h, "#undef %s\n", sym->name); - break; - case mod: -#if 0 - fprintf(out, "%s=m\n", sym->name); - if (out_h) - fprintf(out_h, "#define %s_MODULE 1\n", sym->name); -#endif - break; - case yes: - fprintf(out, "%s=y\n", sym->name); - if (out_h) - fprintf(out_h, "#define %s 1\n", sym->name); - break; - } - break; - case S_STRING: - // fix me - str = sym_get_string_value(sym); - fprintf(out, "%s=\"", sym->name); - if (out_h) - fprintf(out_h, "#define %s \"", sym->name); - do { - l = strcspn(str, "\"\\"); - if (l) { - fwrite(str, l, 1, out); - if (out_h) - fwrite(str, l, 1, out_h); - } - str += l; - while (*str == '\\' || *str == '"') { - fprintf(out, "\\%c", *str); - if (out_h) - fprintf(out_h, "\\%c", *str); - str++; - } - } while (*str); - fputs("\"\n", out); - if (out_h) - fputs("\"\n", out_h); - break; - case S_HEX: - str = sym_get_string_value(sym); - if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); - if (out_h) - fprintf(out_h, "#define %s 0x%s\n", sym->name, str); - break; - } - case S_INT: - str = sym_get_string_value(sym); - fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); - if (out_h) - fprintf(out_h, "#define %s %s\n", sym->name, str); - break; - } - } -next: - menu = next_menu(menu); - } - fclose(out); - if (out_h) { - fclose(out_h); - rename("config/.tmpconfig.h", "config/config.h"); - file_write_dep(NULL); - } - if (!name || basename != conf_def_filename) { - if (!name) - name = conf_def_filename; - sprintf(tmpname, "%s.old", name); - rename(name, tmpname); - } - sprintf(tmpname, "%s%s", dirname, basename); - if (rename(newname, tmpname)) - return 1; - - sym_change_count = 0; - - return 0; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/expr.c b/user/mpy/lib/axtls/config/scripts/config/expr.c deleted file mode 100644 index 30e4f9d..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/expr.c +++ /dev/null @@ -1,1099 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -#define DEBUG_EXPR 0 - -struct expr *expr_alloc_symbol(struct symbol *sym) -{ - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); - e->type = E_SYMBOL; - e->left.sym = sym; - return e; -} - -struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) -{ - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); - e->type = type; - e->left.expr = ce; - return e; -} - -struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) -{ - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); - e->type = type; - e->left.expr = e1; - e->right.expr = e2; - return e; -} - -struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) -{ - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); - e->type = type; - e->left.sym = s1; - e->right.sym = s2; - return e; -} - -struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) -{ - if (!e1) - return e2; - return e2 ? expr_alloc_two(E_AND, e1, e2) : e1; -} - -struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) -{ - if (!e1) - return e2; - return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; -} - -struct expr *expr_copy(struct expr *org) -{ - struct expr *e; - - if (!org) - return NULL; - - e = malloc(sizeof(*org)); - memcpy(e, org, sizeof(*org)); - switch (org->type) { - case E_SYMBOL: - e->left = org->left; - break; - case E_NOT: - e->left.expr = expr_copy(org->left.expr); - break; - case E_EQUAL: - case E_UNEQUAL: - e->left.sym = org->left.sym; - e->right.sym = org->right.sym; - break; - case E_AND: - case E_OR: - case E_CHOICE: - e->left.expr = expr_copy(org->left.expr); - e->right.expr = expr_copy(org->right.expr); - break; - default: - printf("can't copy type %d\n", e->type); - free(e); - e = NULL; - break; - } - - return e; -} - -void expr_free(struct expr *e) -{ - if (!e) - return; - - switch (e->type) { - case E_SYMBOL: - break; - case E_NOT: - expr_free(e->left.expr); - return; - case E_EQUAL: - case E_UNEQUAL: - break; - case E_OR: - case E_AND: - expr_free(e->left.expr); - expr_free(e->right.expr); - break; - default: - printf("how to free type %d?\n", e->type); - break; - } - free(e); -} - -static int trans_count; - -#define e1 (*ep1) -#define e2 (*ep2) - -static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) -{ - if (e1->type == type) { - __expr_eliminate_eq(type, &e1->left.expr, &e2); - __expr_eliminate_eq(type, &e1->right.expr, &e2); - return; - } - if (e2->type == type) { - __expr_eliminate_eq(type, &e1, &e2->left.expr); - __expr_eliminate_eq(type, &e1, &e2->right.expr); - return; - } - if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && - e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO))) - return; - if (!expr_eq(e1, e2)) - return; - trans_count++; - expr_free(e1); expr_free(e2); - switch (type) { - case E_OR: - e1 = expr_alloc_symbol(&symbol_no); - e2 = expr_alloc_symbol(&symbol_no); - break; - case E_AND: - e1 = expr_alloc_symbol(&symbol_yes); - e2 = expr_alloc_symbol(&symbol_yes); - break; - default: - ; - } -} - -void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) -{ - if (!e1 || !e2) - return; - switch (e1->type) { - case E_OR: - case E_AND: - __expr_eliminate_eq(e1->type, ep1, ep2); - default: - ; - } - if (e1->type != e2->type) switch (e2->type) { - case E_OR: - case E_AND: - __expr_eliminate_eq(e2->type, ep1, ep2); - default: - ; - } - e1 = expr_eliminate_yn(e1); - e2 = expr_eliminate_yn(e2); -} - -#undef e1 -#undef e2 - -int expr_eq(struct expr *e1, struct expr *e2) -{ - int res, old_count; - - if (e1->type != e2->type) - return 0; - switch (e1->type) { - case E_EQUAL: - case E_UNEQUAL: - return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; - case E_SYMBOL: - return e1->left.sym == e2->left.sym; - case E_NOT: - return expr_eq(e1->left.expr, e2->left.expr); - case E_AND: - case E_OR: - e1 = expr_copy(e1); - e2 = expr_copy(e2); - old_count = trans_count; - expr_eliminate_eq(&e1, &e2); - res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && - e1->left.sym == e2->left.sym); - expr_free(e1); - expr_free(e2); - trans_count = old_count; - return res; - case E_CHOICE: - case E_RANGE: - case E_NONE: - /* panic */; - } - - if (DEBUG_EXPR) { - expr_fprint(e1, stdout); - printf(" = "); - expr_fprint(e2, stdout); - printf(" ?\n"); - } - - return 0; -} - -struct expr *expr_eliminate_yn(struct expr *e) -{ - struct expr *tmp; - - if (e) switch (e->type) { - case E_AND: - e->left.expr = expr_eliminate_yn(e->left.expr); - e->right.expr = expr_eliminate_yn(e->right.expr); - if (e->left.expr->type == E_SYMBOL) { - if (e->left.expr->left.sym == &symbol_no) { - expr_free(e->left.expr); - expr_free(e->right.expr); - e->type = E_SYMBOL; - e->left.sym = &symbol_no; - e->right.expr = NULL; - return e; - } else if (e->left.expr->left.sym == &symbol_yes) { - free(e->left.expr); - tmp = e->right.expr; - *e = *(e->right.expr); - free(tmp); - return e; - } - } - if (e->right.expr->type == E_SYMBOL) { - if (e->right.expr->left.sym == &symbol_no) { - expr_free(e->left.expr); - expr_free(e->right.expr); - e->type = E_SYMBOL; - e->left.sym = &symbol_no; - e->right.expr = NULL; - return e; - } else if (e->right.expr->left.sym == &symbol_yes) { - free(e->right.expr); - tmp = e->left.expr; - *e = *(e->left.expr); - free(tmp); - return e; - } - } - break; - case E_OR: - e->left.expr = expr_eliminate_yn(e->left.expr); - e->right.expr = expr_eliminate_yn(e->right.expr); - if (e->left.expr->type == E_SYMBOL) { - if (e->left.expr->left.sym == &symbol_no) { - free(e->left.expr); - tmp = e->right.expr; - *e = *(e->right.expr); - free(tmp); - return e; - } else if (e->left.expr->left.sym == &symbol_yes) { - expr_free(e->left.expr); - expr_free(e->right.expr); - e->type = E_SYMBOL; - e->left.sym = &symbol_yes; - e->right.expr = NULL; - return e; - } - } - if (e->right.expr->type == E_SYMBOL) { - if (e->right.expr->left.sym == &symbol_no) { - free(e->right.expr); - tmp = e->left.expr; - *e = *(e->left.expr); - free(tmp); - return e; - } else if (e->right.expr->left.sym == &symbol_yes) { - expr_free(e->left.expr); - expr_free(e->right.expr); - e->type = E_SYMBOL; - e->left.sym = &symbol_yes; - e->right.expr = NULL; - return e; - } - } - break; - default: - ; - } - return e; -} - -/* - * bool FOO!=n => FOO - */ -struct expr *expr_trans_bool(struct expr *e) -{ - if (!e) - return NULL; - switch (e->type) { - case E_AND: - case E_OR: - case E_NOT: - e->left.expr = expr_trans_bool(e->left.expr); - e->right.expr = expr_trans_bool(e->right.expr); - break; - case E_UNEQUAL: - // FOO!=n -> FOO - if (e->left.sym->type == S_TRISTATE) { - if (e->right.sym == &symbol_no) { - e->type = E_SYMBOL; - e->right.sym = NULL; - } - } - break; - default: - ; - } - return e; -} - -/* - * e1 || e2 -> ? - */ -struct expr *expr_join_or(struct expr *e1, struct expr *e2) -{ - struct expr *tmp; - struct symbol *sym1, *sym2; - - if (expr_eq(e1, e2)) - return expr_copy(e1); - if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) - return NULL; - if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) - return NULL; - if (e1->type == E_NOT) { - tmp = e1->left.expr; - if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) - return NULL; - sym1 = tmp->left.sym; - } else - sym1 = e1->left.sym; - if (e2->type == E_NOT) { - if (e2->left.expr->type != E_SYMBOL) - return NULL; - sym2 = e2->left.expr->left.sym; - } else - sym2 = e2->left.sym; - if (sym1 != sym2) - return NULL; - if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) - return NULL; - if (sym1->type == S_TRISTATE) { - if (e1->type == E_EQUAL && e2->type == E_EQUAL && - ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || - (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { - // (a='y') || (a='m') -> (a!='n') - return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no); - } - if (e1->type == E_EQUAL && e2->type == E_EQUAL && - ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || - (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { - // (a='y') || (a='n') -> (a!='m') - return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod); - } - if (e1->type == E_EQUAL && e2->type == E_EQUAL && - ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || - (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { - // (a='m') || (a='n') -> (a!='y') - return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes); - } - } - if (sym1->type == S_BOOLEAN && sym1 == sym2) { - if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || - (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) - return expr_alloc_symbol(&symbol_yes); - } - - if (DEBUG_EXPR) { - printf("optimize ("); - expr_fprint(e1, stdout); - printf(") || ("); - expr_fprint(e2, stdout); - printf(")?\n"); - } - return NULL; -} - -struct expr *expr_join_and(struct expr *e1, struct expr *e2) -{ - struct expr *tmp; - struct symbol *sym1, *sym2; - - if (expr_eq(e1, e2)) - return expr_copy(e1); - if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) - return NULL; - if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) - return NULL; - if (e1->type == E_NOT) { - tmp = e1->left.expr; - if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) - return NULL; - sym1 = tmp->left.sym; - } else - sym1 = e1->left.sym; - if (e2->type == E_NOT) { - if (e2->left.expr->type != E_SYMBOL) - return NULL; - sym2 = e2->left.expr->left.sym; - } else - sym2 = e2->left.sym; - if (sym1 != sym2) - return NULL; - if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) - return NULL; - - if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || - (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) - // (a) && (a='y') -> (a='y') - return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); - - if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || - (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) - // (a) && (a!='n') -> (a) - return expr_alloc_symbol(sym1); - - if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) || - (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod)) - // (a) && (a!='m') -> (a='y') - return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); - - if (sym1->type == S_TRISTATE) { - if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { - // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' - sym2 = e1->right.sym; - if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) - return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) - : expr_alloc_symbol(&symbol_no); - } - if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { - // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' - sym2 = e2->right.sym; - if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) - return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) - : expr_alloc_symbol(&symbol_no); - } - if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && - ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || - (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) - // (a!='y') && (a!='n') -> (a='m') - return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod); - - if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && - ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || - (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) - // (a!='y') && (a!='m') -> (a='n') - return expr_alloc_comp(E_EQUAL, sym1, &symbol_no); - - if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && - ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || - (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) - // (a!='m') && (a!='n') -> (a='m') - return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); - - if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || - (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || - (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || - (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) - return NULL; - } - - if (DEBUG_EXPR) { - printf("optimize ("); - expr_fprint(e1, stdout); - printf(") && ("); - expr_fprint(e2, stdout); - printf(")?\n"); - } - return NULL; -} - -static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) -{ -#define e1 (*ep1) -#define e2 (*ep2) - struct expr *tmp; - - if (e1->type == type) { - expr_eliminate_dups1(type, &e1->left.expr, &e2); - expr_eliminate_dups1(type, &e1->right.expr, &e2); - return; - } - if (e2->type == type) { - expr_eliminate_dups1(type, &e1, &e2->left.expr); - expr_eliminate_dups1(type, &e1, &e2->right.expr); - return; - } - if (e1 == e2) - return; - - switch (e1->type) { - case E_OR: case E_AND: - expr_eliminate_dups1(e1->type, &e1, &e1); - default: - ; - } - - switch (type) { - case E_OR: - tmp = expr_join_or(e1, e2); - if (tmp) { - expr_free(e1); expr_free(e2); - e1 = expr_alloc_symbol(&symbol_no); - e2 = tmp; - trans_count++; - } - break; - case E_AND: - tmp = expr_join_and(e1, e2); - if (tmp) { - expr_free(e1); expr_free(e2); - e1 = expr_alloc_symbol(&symbol_yes); - e2 = tmp; - trans_count++; - } - break; - default: - ; - } -#undef e1 -#undef e2 -} - -static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) -{ -#define e1 (*ep1) -#define e2 (*ep2) - struct expr *tmp, *tmp1, *tmp2; - - if (e1->type == type) { - expr_eliminate_dups2(type, &e1->left.expr, &e2); - expr_eliminate_dups2(type, &e1->right.expr, &e2); - return; - } - if (e2->type == type) { - expr_eliminate_dups2(type, &e1, &e2->left.expr); - expr_eliminate_dups2(type, &e1, &e2->right.expr); - } - if (e1 == e2) - return; - - switch (e1->type) { - case E_OR: - expr_eliminate_dups2(e1->type, &e1, &e1); - // (FOO || BAR) && (!FOO && !BAR) -> n - tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); - tmp2 = expr_copy(e2); - tmp = expr_extract_eq_and(&tmp1, &tmp2); - if (expr_is_yes(tmp1)) { - expr_free(e1); - e1 = expr_alloc_symbol(&symbol_no); - trans_count++; - } - expr_free(tmp2); - expr_free(tmp1); - expr_free(tmp); - break; - case E_AND: - expr_eliminate_dups2(e1->type, &e1, &e1); - // (FOO && BAR) || (!FOO || !BAR) -> y - tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); - tmp2 = expr_copy(e2); - tmp = expr_extract_eq_or(&tmp1, &tmp2); - if (expr_is_no(tmp1)) { - expr_free(e1); - e1 = expr_alloc_symbol(&symbol_yes); - trans_count++; - } - expr_free(tmp2); - expr_free(tmp1); - expr_free(tmp); - break; - default: - ; - } -#undef e1 -#undef e2 -} - -struct expr *expr_eliminate_dups(struct expr *e) -{ - int oldcount; - if (!e) - return e; - - oldcount = trans_count; - while (1) { - trans_count = 0; - switch (e->type) { - case E_OR: case E_AND: - expr_eliminate_dups1(e->type, &e, &e); - expr_eliminate_dups2(e->type, &e, &e); - default: - ; - } - if (!trans_count) - break; - e = expr_eliminate_yn(e); - } - trans_count = oldcount; - return e; -} - -struct expr *expr_transform(struct expr *e) -{ - struct expr *tmp; - - if (!e) - return NULL; - switch (e->type) { - case E_EQUAL: - case E_UNEQUAL: - case E_SYMBOL: - case E_CHOICE: - break; - default: - e->left.expr = expr_transform(e->left.expr); - e->right.expr = expr_transform(e->right.expr); - } - - switch (e->type) { - case E_EQUAL: - if (e->left.sym->type != S_BOOLEAN) - break; - if (e->right.sym == &symbol_no) { - e->type = E_NOT; - e->left.expr = expr_alloc_symbol(e->left.sym); - e->right.sym = NULL; - break; - } - if (e->right.sym == &symbol_mod) { - printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); - e->type = E_SYMBOL; - e->left.sym = &symbol_no; - e->right.sym = NULL; - break; - } - if (e->right.sym == &symbol_yes) { - e->type = E_SYMBOL; - e->right.sym = NULL; - break; - } - break; - case E_UNEQUAL: - if (e->left.sym->type != S_BOOLEAN) - break; - if (e->right.sym == &symbol_no) { - e->type = E_SYMBOL; - e->right.sym = NULL; - break; - } - if (e->right.sym == &symbol_mod) { - printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); - e->type = E_SYMBOL; - e->left.sym = &symbol_yes; - e->right.sym = NULL; - break; - } - if (e->right.sym == &symbol_yes) { - e->type = E_NOT; - e->left.expr = expr_alloc_symbol(e->left.sym); - e->right.sym = NULL; - break; - } - break; - case E_NOT: - switch (e->left.expr->type) { - case E_NOT: - // !!a -> a - tmp = e->left.expr->left.expr; - free(e->left.expr); - free(e); - e = tmp; - e = expr_transform(e); - break; - case E_EQUAL: - case E_UNEQUAL: - // !a='x' -> a!='x' - tmp = e->left.expr; - free(e); - e = tmp; - e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; - break; - case E_OR: - // !(a || b) -> !a && !b - tmp = e->left.expr; - e->type = E_AND; - e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); - tmp->type = E_NOT; - tmp->right.expr = NULL; - e = expr_transform(e); - break; - case E_AND: - // !(a && b) -> !a || !b - tmp = e->left.expr; - e->type = E_OR; - e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); - tmp->type = E_NOT; - tmp->right.expr = NULL; - e = expr_transform(e); - break; - case E_SYMBOL: - if (e->left.expr->left.sym == &symbol_yes) { - // !'y' -> 'n' - tmp = e->left.expr; - free(e); - e = tmp; - e->type = E_SYMBOL; - e->left.sym = &symbol_no; - break; - } - if (e->left.expr->left.sym == &symbol_mod) { - // !'m' -> 'm' - tmp = e->left.expr; - free(e); - e = tmp; - e->type = E_SYMBOL; - e->left.sym = &symbol_mod; - break; - } - if (e->left.expr->left.sym == &symbol_no) { - // !'n' -> 'y' - tmp = e->left.expr; - free(e); - e = tmp; - e->type = E_SYMBOL; - e->left.sym = &symbol_yes; - break; - } - break; - default: - ; - } - break; - default: - ; - } - return e; -} - -int expr_contains_symbol(struct expr *dep, struct symbol *sym) -{ - if (!dep) - return 0; - - switch (dep->type) { - case E_AND: - case E_OR: - return expr_contains_symbol(dep->left.expr, sym) || - expr_contains_symbol(dep->right.expr, sym); - case E_SYMBOL: - return dep->left.sym == sym; - case E_EQUAL: - case E_UNEQUAL: - return dep->left.sym == sym || - dep->right.sym == sym; - case E_NOT: - return expr_contains_symbol(dep->left.expr, sym); - default: - ; - } - return 0; -} - -bool expr_depends_symbol(struct expr *dep, struct symbol *sym) -{ - if (!dep) - return false; - - switch (dep->type) { - case E_AND: - return expr_depends_symbol(dep->left.expr, sym) || - expr_depends_symbol(dep->right.expr, sym); - case E_SYMBOL: - return dep->left.sym == sym; - case E_EQUAL: - if (dep->left.sym == sym) { - if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) - return true; - } - break; - case E_UNEQUAL: - if (dep->left.sym == sym) { - if (dep->right.sym == &symbol_no) - return true; - } - break; - default: - ; - } - return false; -} - -struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) -{ - struct expr *tmp = NULL; - expr_extract_eq(E_AND, &tmp, ep1, ep2); - if (tmp) { - *ep1 = expr_eliminate_yn(*ep1); - *ep2 = expr_eliminate_yn(*ep2); - } - return tmp; -} - -struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) -{ - struct expr *tmp = NULL; - expr_extract_eq(E_OR, &tmp, ep1, ep2); - if (tmp) { - *ep1 = expr_eliminate_yn(*ep1); - *ep2 = expr_eliminate_yn(*ep2); - } - return tmp; -} - -void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) -{ -#define e1 (*ep1) -#define e2 (*ep2) - if (e1->type == type) { - expr_extract_eq(type, ep, &e1->left.expr, &e2); - expr_extract_eq(type, ep, &e1->right.expr, &e2); - return; - } - if (e2->type == type) { - expr_extract_eq(type, ep, ep1, &e2->left.expr); - expr_extract_eq(type, ep, ep1, &e2->right.expr); - return; - } - if (expr_eq(e1, e2)) { - *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1; - expr_free(e2); - if (type == E_AND) { - e1 = expr_alloc_symbol(&symbol_yes); - e2 = expr_alloc_symbol(&symbol_yes); - } else if (type == E_OR) { - e1 = expr_alloc_symbol(&symbol_no); - e2 = expr_alloc_symbol(&symbol_no); - } - } -#undef e1 -#undef e2 -} - -struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) -{ - struct expr *e1, *e2; - - if (!e) { - e = expr_alloc_symbol(sym); - if (type == E_UNEQUAL) - e = expr_alloc_one(E_NOT, e); - return e; - } - switch (e->type) { - case E_AND: - e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); - e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); - if (sym == &symbol_yes) - e = expr_alloc_two(E_AND, e1, e2); - if (sym == &symbol_no) - e = expr_alloc_two(E_OR, e1, e2); - if (type == E_UNEQUAL) - e = expr_alloc_one(E_NOT, e); - return e; - case E_OR: - e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); - e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); - if (sym == &symbol_yes) - e = expr_alloc_two(E_OR, e1, e2); - if (sym == &symbol_no) - e = expr_alloc_two(E_AND, e1, e2); - if (type == E_UNEQUAL) - e = expr_alloc_one(E_NOT, e); - return e; - case E_NOT: - return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); - case E_UNEQUAL: - case E_EQUAL: - if (type == E_EQUAL) { - if (sym == &symbol_yes) - return expr_copy(e); - if (sym == &symbol_mod) - return expr_alloc_symbol(&symbol_no); - if (sym == &symbol_no) - return expr_alloc_one(E_NOT, expr_copy(e)); - } else { - if (sym == &symbol_yes) - return expr_alloc_one(E_NOT, expr_copy(e)); - if (sym == &symbol_mod) - return expr_alloc_symbol(&symbol_yes); - if (sym == &symbol_no) - return expr_copy(e); - } - break; - case E_SYMBOL: - return expr_alloc_comp(type, e->left.sym, sym); - case E_CHOICE: - case E_RANGE: - case E_NONE: - /* panic */; - } - return NULL; -} - -tristate expr_calc_value(struct expr *e) -{ - tristate val1, val2; - const char *str1, *str2; - - if (!e) - return yes; - - switch (e->type) { - case E_SYMBOL: - sym_calc_value(e->left.sym); - return e->left.sym->curr.tri; - case E_AND: - val1 = expr_calc_value(e->left.expr); - val2 = expr_calc_value(e->right.expr); - return E_AND(val1, val2); - case E_OR: - val1 = expr_calc_value(e->left.expr); - val2 = expr_calc_value(e->right.expr); - return E_OR(val1, val2); - case E_NOT: - val1 = expr_calc_value(e->left.expr); - return E_NOT(val1); - case E_EQUAL: - sym_calc_value(e->left.sym); - sym_calc_value(e->right.sym); - str1 = sym_get_string_value(e->left.sym); - str2 = sym_get_string_value(e->right.sym); - return !strcmp(str1, str2) ? yes : no; - case E_UNEQUAL: - sym_calc_value(e->left.sym); - sym_calc_value(e->right.sym); - str1 = sym_get_string_value(e->left.sym); - str2 = sym_get_string_value(e->right.sym); - return !strcmp(str1, str2) ? no : yes; - default: - printf("expr_calc_value: %d?\n", e->type); - return no; - } -} - -int expr_compare_type(enum expr_type t1, enum expr_type t2) -{ -#if 0 - return 1; -#else - if (t1 == t2) - return 0; - switch (t1) { - case E_EQUAL: - case E_UNEQUAL: - if (t2 == E_NOT) - return 1; - case E_NOT: - if (t2 == E_AND) - return 1; - case E_AND: - if (t2 == E_OR) - return 1; - case E_OR: - if (t2 == E_CHOICE) - return 1; - case E_CHOICE: - if (t2 == 0) - return 1; - default: - return -1; - } - printf("[%dgt%d?]", t1, t2); - return 0; -#endif -} - -void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken) -{ - if (!e) { - fn(data, "y"); - return; - } - - if (expr_compare_type(prevtoken, e->type) > 0) - fn(data, "("); - switch (e->type) { - case E_SYMBOL: - if (e->left.sym->name) - fn(data, e->left.sym->name); - else - fn(data, ""); - break; - case E_NOT: - fn(data, "!"); - expr_print(e->left.expr, fn, data, E_NOT); - break; - case E_EQUAL: - fn(data, e->left.sym->name); - fn(data, "="); - fn(data, e->right.sym->name); - break; - case E_UNEQUAL: - fn(data, e->left.sym->name); - fn(data, "!="); - fn(data, e->right.sym->name); - break; - case E_OR: - expr_print(e->left.expr, fn, data, E_OR); - fn(data, " || "); - expr_print(e->right.expr, fn, data, E_OR); - break; - case E_AND: - expr_print(e->left.expr, fn, data, E_AND); - fn(data, " && "); - expr_print(e->right.expr, fn, data, E_AND); - break; - case E_CHOICE: - fn(data, e->right.sym->name); - if (e->left.expr) { - fn(data, " ^ "); - expr_print(e->left.expr, fn, data, E_CHOICE); - } - break; - case E_RANGE: - fn(data, "["); - fn(data, e->left.sym->name); - fn(data, " "); - fn(data, e->right.sym->name); - fn(data, "]"); - break; - default: - { - char buf[32]; - sprintf(buf, "", e->type); - fn(data, buf); - break; - } - } - if (expr_compare_type(prevtoken, e->type) > 0) - fn(data, ")"); -} - -static void expr_print_file_helper(void *data, const char *str) -{ - fwrite(str, strlen(str), 1, data); -} - -void expr_fprint(struct expr *e, FILE *out) -{ - expr_print(e, expr_print_file_helper, out, E_NONE); -} - -static void expr_print_gstr_helper(void *data, const char *str) -{ - str_append((struct gstr*)data, str); -} - -void expr_gstr_print(struct expr *e, struct gstr *gs) -{ - expr_print(e, expr_print_gstr_helper, gs, E_NONE); -} diff --git a/user/mpy/lib/axtls/config/scripts/config/expr.h b/user/mpy/lib/axtls/config/scripts/config/expr.h deleted file mode 100644 index 7d39ff4..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/expr.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#ifndef EXPR_H -#define EXPR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#ifndef __cplusplus -#include -#endif - -struct file { - struct file *next; - struct file *parent; - char *name; - int lineno; - int flags; -}; - -#define FILE_BUSY 0x0001 -#define FILE_SCANNED 0x0002 -#define FILE_PRINTED 0x0004 - -typedef enum tristate { - no, mod, yes -} tristate; - -enum expr_type { - E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE -}; - -union expr_data { - struct expr *expr; - struct symbol *sym; -}; - -struct expr { - enum expr_type type; - union expr_data left, right; -}; - -#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) -#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) -#define E_NOT(dep) (2-(dep)) - -struct expr_value { - struct expr *expr; - tristate tri; -}; - -struct symbol_value { - void *val; - tristate tri; -}; - -enum symbol_type { - S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER -}; - -struct symbol { - struct symbol *next; - char *name; - char *help; - enum symbol_type type; - struct symbol_value curr, user; - tristate visible; - int flags; - struct property *prop; - struct expr *dep, *dep2; - struct expr_value rev_dep; -}; - -#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) - -#define SYMBOL_YES 0x0001 -#define SYMBOL_MOD 0x0002 -#define SYMBOL_NO 0x0004 -#define SYMBOL_CONST 0x0007 -#define SYMBOL_CHECK 0x0008 -#define SYMBOL_CHOICE 0x0010 -#define SYMBOL_CHOICEVAL 0x0020 -#define SYMBOL_PRINTED 0x0040 -#define SYMBOL_VALID 0x0080 -#define SYMBOL_OPTIONAL 0x0100 -#define SYMBOL_WRITE 0x0200 -#define SYMBOL_CHANGED 0x0400 -#define SYMBOL_NEW 0x0800 -#define SYMBOL_AUTO 0x1000 -#define SYMBOL_CHECKED 0x2000 -#define SYMBOL_CHECK_DONE 0x4000 -#define SYMBOL_WARNED 0x8000 - -#define SYMBOL_MAXLENGTH 256 -#define SYMBOL_HASHSIZE 257 -#define SYMBOL_HASHMASK 0xff - -enum prop_type { - P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE -}; - -struct property { - struct property *next; - struct symbol *sym; - enum prop_type type; - const char *text; - struct expr_value visible; - struct expr *expr; - struct menu *menu; - struct file *file; - int lineno; -}; - -#define for_all_properties(sym, st, tok) \ - for (st = sym->prop; st; st = st->next) \ - if (st->type == (tok)) -#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) -#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) -#define for_all_prompts(sym, st) \ - for (st = sym->prop; st; st = st->next) \ - if (st->text) - -struct menu { - struct menu *next; - struct menu *parent; - struct menu *list; - struct symbol *sym; - struct property *prompt; - struct expr *dep; - unsigned int flags; - //char *help; - struct file *file; - int lineno; - void *data; -}; - -#define MENU_CHANGED 0x0001 -#define MENU_ROOT 0x0002 - -#ifndef SWIG - -extern struct file *file_list; -extern struct file *current_file; -struct file *lookup_file(const char *name); - -extern struct symbol symbol_yes, symbol_no, symbol_mod; -extern struct symbol *modules_sym; -extern int cdebug; -struct expr *expr_alloc_symbol(struct symbol *sym); -struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); -struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); -struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); -struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); -struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); -struct expr *expr_copy(struct expr *org); -void expr_free(struct expr *e); -int expr_eq(struct expr *e1, struct expr *e2); -void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); -tristate expr_calc_value(struct expr *e); -struct expr *expr_eliminate_yn(struct expr *e); -struct expr *expr_trans_bool(struct expr *e); -struct expr *expr_eliminate_dups(struct expr *e); -struct expr *expr_transform(struct expr *e); -int expr_contains_symbol(struct expr *dep, struct symbol *sym); -bool expr_depends_symbol(struct expr *dep, struct symbol *sym); -struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); -struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); -void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); -struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); - -void expr_fprint(struct expr *e, FILE *out); -struct gstr; /* forward */ -void expr_gstr_print(struct expr *e, struct gstr *gs); - -static inline int expr_is_yes(struct expr *e) -{ - return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); -} - -static inline int expr_is_no(struct expr *e) -{ - return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); -} -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* EXPR_H */ diff --git a/user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped b/user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped deleted file mode 100644 index b877bb6..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lex.zconf.c_shipped +++ /dev/null @@ -1,3688 +0,0 @@ - -#line 3 "lex.zconf.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 31 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE zconfrestart(zconfin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int zconfleng; - -extern FILE *zconfin, *zconfout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up zconftext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via zconfrestart()), so that the user can continue scanning by - * just pointing zconfin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when zconftext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int zconfleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow zconfwrap()'s to do buffer switches - * instead of setting up a fresh zconfin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void zconfrestart (FILE *input_file ); -void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); -void zconf_delete_buffer (YY_BUFFER_STATE b ); -void zconf_flush_buffer (YY_BUFFER_STATE b ); -void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void zconfpop_buffer_state (void ); - -static void zconfensure_buffer_stack (void ); -static void zconf_load_buffer_state (void ); -static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); - -void *zconfalloc (yy_size_t ); -void *zconfrealloc (void *,yy_size_t ); -void zconffree (void * ); - -#define yy_new_buffer zconf_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - zconfensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - zconfensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define zconfwrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; - -typedef int yy_state_type; - -extern int zconflineno; - -int zconflineno = 1; - -extern char *zconftext; -#define yytext_ptr zconftext -static yyconst flex_int16_t yy_nxt[][38] = - { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }, - - { - 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12 - }, - - { - 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12 - }, - - { - 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, - 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, - 27, 18, 28, 29, 30, 18, 18, 16 - }, - - { - 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 18, 16, 16, 18, 18, 19, 20, - 21, 22, 18, 18, 23, 24, 18, 25, 18, 26, - 27, 18, 28, 29, 30, 18, 18, 16 - - }, - - { - 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31 - }, - - { - 11, 31, 32, 33, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31 - }, - - { - 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, - 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, - - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34 - }, - - { - 11, 34, 34, 35, 34, 36, 34, 34, 36, 34, - 34, 34, 34, 34, 34, 37, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34 - }, - - { - 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, - 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, - 47, 47, 47, 47, 47, 47, 47, 52 - - }, - - { - 11, 38, 38, 39, 40, 41, 42, 43, 41, 44, - 45, 46, 47, 47, 48, 49, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 50, 47, 47, 47, 51, - 47, 47, 47, 47, 47, 47, 47, 52 - }, - - { - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11 - }, - - { - 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - - -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12 - }, - - { - 11, -13, 53, 54, -13, -13, 55, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13 - }, - - { - 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14 - - }, - - { - 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56 - }, - - { - 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16 - }, - - { - 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - - -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17 - }, - - { - 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, 58, -18, -18, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -18 - }, - - { - 11, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, 58, -19, -19, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 59, - 58, 58, 58, 58, 58, 58, 58, -19 - - }, - - { - 11, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, 58, -20, -20, 58, 58, 58, 58, - 58, 58, 58, 58, 60, 58, 58, 58, 58, 61, - 58, 58, 58, 58, 58, 58, 58, -20 - }, - - { - 11, -21, -21, -21, -21, -21, -21, -21, -21, -21, - -21, -21, -21, 58, -21, -21, 58, 58, 58, 58, - 58, 62, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -21 - }, - - { - 11, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, 58, -22, -22, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 63, 58, - 58, 58, 58, 58, 58, 58, 58, -22 - }, - - { - 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, 58, -23, -23, 58, 58, 58, 58, - 58, 64, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -23 - }, - - { - 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, 58, -24, -24, 58, 58, 58, 58, - 58, 58, 65, 58, 58, 58, 58, 58, 66, 58, - 58, 58, 58, 58, 58, 58, 58, -24 - - }, - - { - 11, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, 58, -25, -25, 58, 67, 58, 58, - 58, 68, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -25 - }, - - { - 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, 58, -26, -26, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 69, 58, 58, 58, 58, 58, 58, -26 - }, - - { - 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -27, -27, -27, 58, -27, -27, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 70, 58, 58, 58, 58, -27 - }, - - { - 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, 58, -28, -28, 58, 71, 58, 58, - 58, 72, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -28 - }, - - { - 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, 58, -29, -29, 58, 58, 58, 58, - 58, 73, 58, 58, 58, 58, 58, 58, 58, 74, - 58, 58, 58, 58, 75, 58, 58, -29 - - }, - - { - 11, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, 58, -30, -30, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 76, 58, 58, 58, 58, -30 - }, - - { - 11, 77, 77, -31, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77 - }, - - { - 11, -32, 78, 79, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - - -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32 - }, - - { - 11, 80, -33, -33, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80 - }, - - { - 11, 81, 81, 82, 81, -34, 81, 81, -34, 81, - 81, 81, 81, 81, 81, -34, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81 - - }, - - { - 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, -35, -35, -35, -35, -35 - }, - - { - 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, -36, -36, -36, -36 - }, - - { - 11, 83, 83, 84, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83 - }, - - { - 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, -38, -38, -38 - }, - - { - 11, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39 - - }, - - { - 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, 85, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40 - }, - - { - 11, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41 - }, - - { - 11, 86, 86, -42, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - - 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 86 - }, - - { - 11, -43, -43, -43, -43, -43, -43, 87, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43 - }, - - { - 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44 - - }, - - { - 11, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45 - }, - - { - 11, -46, -46, -46, -46, -46, -46, -46, -46, -46, - -46, 88, 89, 89, -46, -46, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -46 - }, - - { - 11, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, 89, 89, 89, -47, -47, 89, 89, 89, 89, - - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -47 - }, - - { - 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48 - }, - - { - 11, -49, -49, 90, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - -49, -49, -49, -49, -49, -49, -49, -49 - - }, - - { - 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, 89, 89, 89, -50, -50, 89, 89, 89, 89, - 89, 89, 91, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -50 - }, - - { - 11, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, 89, 89, 89, -51, -51, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 92, 89, - 89, 89, 89, 89, 89, 89, 89, -51 - }, - - { - 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - - -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, 93 - }, - - { - 11, -53, 53, 54, -53, -53, 55, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53 - }, - - { - 11, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54 - - }, - - { - 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56 - }, - - { - 11, 56, 56, 57, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56 - }, - - { - 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - - -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, - -57, -57, -57, -57, -57, -57, -57, -57 - }, - - { - 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, 58, -58, -58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -58 - }, - - { - 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, 58, -59, -59, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, - 58, 58, 58, 58, 58, 58, 58, -59 - - }, - - { - 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, 58, -60, -60, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 95, - 58, 58, 58, 58, 58, 58, 58, -60 - }, - - { - 11, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, 58, -61, -61, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 96, 97, 58, - 58, 58, 58, 58, 58, 58, 58, -61 - }, - - { - 11, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, 58, -62, -62, 58, 58, 58, 58, - - 58, 58, 98, 58, 58, 58, 58, 58, 58, 58, - 99, 58, 58, 58, 58, 58, 58, -62 - }, - - { - 11, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, 58, -63, -63, 58, 100, 58, 58, - 101, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -63 - }, - - { - 11, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, 58, -64, -64, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 102, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 103, -64 - - }, - - { - 11, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, 58, -65, -65, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -65 - }, - - { - 11, -66, -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, 58, -66, -66, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 104, 58, 58, -66 - }, - - { - 11, -67, -67, -67, -67, -67, -67, -67, -67, -67, - -67, -67, -67, 58, -67, -67, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 105, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -67 - }, - - { - 11, -68, -68, -68, -68, -68, -68, -68, -68, -68, - -68, -68, -68, 58, -68, -68, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 106, 58, - 58, 58, 58, 58, 58, 58, 58, -68 - }, - - { - 11, -69, -69, -69, -69, -69, -69, -69, -69, -69, - -69, -69, -69, 58, -69, -69, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 107, 58, 58, -69 - - }, - - { - 11, -70, -70, -70, -70, -70, -70, -70, -70, -70, - -70, -70, -70, 58, -70, -70, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 108, - 58, 58, 58, 58, 58, 58, 58, -70 - }, - - { - 11, -71, -71, -71, -71, -71, -71, -71, -71, -71, - -71, -71, -71, 58, -71, -71, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 109, 58, - 58, 58, 58, 58, 58, 58, 58, -71 - }, - - { - 11, -72, -72, -72, -72, -72, -72, -72, -72, -72, - -72, -72, -72, 58, -72, -72, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 110, 58, 58, 58, 58, 58, -72 - }, - - { - 11, -73, -73, -73, -73, -73, -73, -73, -73, -73, - -73, -73, -73, 58, -73, -73, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 111, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -73 - }, - - { - 11, -74, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, 58, -74, -74, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 112, 58, -74 - - }, - - { - 11, -75, -75, -75, -75, -75, -75, -75, -75, -75, - -75, -75, -75, 58, -75, -75, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 113, 58, 58, 58, 58, -75 - }, - - { - 11, -76, -76, -76, -76, -76, -76, -76, -76, -76, - -76, -76, -76, 58, -76, -76, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 114, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -76 - }, - - { - 11, 77, 77, -77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77 - }, - - { - 11, -78, 78, 79, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, -78, -78, -78 - }, - - { - 11, 80, -79, -79, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80 - - }, - - { - 11, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, - -80, -80, -80, -80, -80, -80, -80, -80 - }, - - { - 11, 81, 81, 82, 81, -81, 81, 81, -81, 81, - 81, 81, 81, 81, 81, -81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81 - }, - - { - 11, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - - -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, - -82, -82, -82, -82, -82, -82, -82, -82 - }, - - { - 11, -83, -83, 84, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, - -83, -83, -83, -83, -83, -83, -83, -83 - }, - - { - 11, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, - -84, -84, -84, -84, -84, -84, -84, -84 - - }, - - { - 11, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, - -85, -85, -85, -85, -85, -85, -85, -85 - }, - - { - 11, 86, 86, -86, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 86 - }, - - { - 11, -87, -87, -87, -87, -87, -87, -87, -87, -87, - -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, - - -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, - -87, -87, -87, -87, -87, -87, -87, -87 - }, - - { - 11, -88, -88, -88, -88, -88, -88, -88, -88, -88, - -88, 115, 89, 89, -88, -88, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -88 - }, - - { - 11, -89, -89, -89, -89, -89, -89, -89, -89, -89, - -89, 89, 89, 89, -89, -89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -89 - - }, - - { - 11, -90, -90, -90, -90, -90, -90, -90, -90, -90, - -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, - -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, - -90, -90, -90, -90, -90, -90, -90, -90 - }, - - { - 11, -91, -91, -91, -91, -91, -91, -91, -91, -91, - -91, 89, 89, 89, -91, -91, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -91 - }, - - { - 11, -92, -92, -92, -92, -92, -92, -92, -92, -92, - -92, 89, 89, 89, -92, -92, 89, 89, 89, 89, - - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -92 - }, - - { - 11, -93, -93, -93, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93, -93, -93, -93, -93 - }, - - { - 11, -94, -94, -94, -94, -94, -94, -94, -94, -94, - -94, -94, -94, 58, -94, -94, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 116, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -94 - - }, - - { - 11, -95, -95, -95, -95, -95, -95, -95, -95, -95, - -95, -95, -95, 58, -95, -95, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 117, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -95 - }, - - { - 11, -96, -96, -96, -96, -96, -96, -96, -96, -96, - -96, -96, -96, 58, -96, -96, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 118, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -96 - }, - - { - 11, -97, -97, -97, -97, -97, -97, -97, -97, -97, - -97, -97, -97, 58, -97, -97, 58, 58, 58, 58, - - 58, 58, 119, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -97 - }, - - { - 11, -98, -98, -98, -98, -98, -98, -98, -98, -98, - -98, -98, -98, 58, -98, -98, 120, 121, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -98 - }, - - { - 11, -99, -99, -99, -99, -99, -99, -99, -99, -99, - -99, -99, -99, 58, -99, -99, 58, 58, 58, 58, - 58, 122, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -99 - - }, - - { - 11, -100, -100, -100, -100, -100, -100, -100, -100, -100, - -100, -100, -100, 58, -100, -100, 58, 58, 123, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -100 - }, - - { - 11, -101, -101, -101, -101, -101, -101, -101, -101, -101, - -101, -101, -101, 58, -101, -101, 58, 58, 58, 124, - 58, 58, 58, 58, 58, 125, 58, 126, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -101 - }, - - { - 11, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, 58, -102, -102, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 127, 58, 58, 58, 58, 58, 58, -102 - }, - - { - 11, -103, -103, -103, -103, -103, -103, -103, -103, -103, - -103, -103, -103, 58, -103, -103, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -103 - }, - - { - 11, -104, -104, -104, -104, -104, -104, -104, -104, -104, - -104, -104, -104, 58, -104, -104, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -104 - - }, - - { - 11, -105, -105, -105, -105, -105, -105, -105, -105, -105, - -105, -105, -105, 58, -105, -105, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 128, 58, - 58, 58, 58, 58, 58, 58, 58, -105 - }, - - { - 11, -106, -106, -106, -106, -106, -106, -106, -106, -106, - -106, -106, -106, 58, -106, -106, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 129, 58, -106 - }, - - { - 11, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, 58, -107, -107, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 130, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -107 - }, - - { - 11, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, -108, 58, -108, -108, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 131, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -108 - }, - - { - 11, -109, -109, -109, -109, -109, -109, -109, -109, -109, - -109, -109, -109, 58, -109, -109, 58, 58, 58, 58, - 58, 58, 58, 132, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -109 - - }, - - { - 11, -110, -110, -110, -110, -110, -110, -110, -110, -110, - -110, -110, -110, 58, -110, -110, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 133, 58, -110 - }, - - { - 11, -111, -111, -111, -111, -111, -111, -111, -111, -111, - -111, -111, -111, 58, -111, -111, 58, 58, 58, 58, - 58, 134, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -111 - }, - - { - 11, -112, -112, -112, -112, -112, -112, -112, -112, -112, - -112, -112, -112, 58, -112, -112, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 135, 58, 58, 58, 58, -112 - }, - - { - 11, -113, -113, -113, -113, -113, -113, -113, -113, -113, - -113, -113, -113, 58, -113, -113, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 136, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -113 - }, - - { - 11, -114, -114, -114, -114, -114, -114, -114, -114, -114, - -114, -114, -114, 58, -114, -114, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 137, 58, 58, 58, -114 - - }, - - { - 11, -115, -115, -115, -115, -115, -115, -115, -115, -115, - -115, 89, 89, 89, -115, -115, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, -115 - }, - - { - 11, -116, -116, -116, -116, -116, -116, -116, -116, -116, - -116, -116, -116, 58, -116, -116, 58, 58, 58, 58, - 58, 138, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -116 - }, - - { - 11, -117, -117, -117, -117, -117, -117, -117, -117, -117, - -117, -117, -117, 58, -117, -117, 58, 58, 58, 139, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -117 - }, - - { - 11, -118, -118, -118, -118, -118, -118, -118, -118, -118, - -118, -118, -118, 58, -118, -118, 58, 58, 58, 58, - 58, 140, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -118 - }, - - { - 11, -119, -119, -119, -119, -119, -119, -119, -119, -119, - -119, -119, -119, 58, -119, -119, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 141, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -119 - - }, - - { - 11, -120, -120, -120, -120, -120, -120, -120, -120, -120, - -120, -120, -120, 58, -120, -120, 58, 58, 142, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 143, 58, 58, -120 - }, - - { - 11, -121, -121, -121, -121, -121, -121, -121, -121, -121, - -121, -121, -121, 58, -121, -121, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 144, 58, -121 - }, - - { - 11, -122, -122, -122, -122, -122, -122, -122, -122, -122, - -122, -122, -122, 58, -122, -122, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 145, 58, - 58, 58, 58, 58, 58, 58, 58, -122 - }, - - { - 11, -123, -123, -123, -123, -123, -123, -123, -123, -123, - -123, -123, -123, 58, -123, -123, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 146, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -123 - }, - - { - 11, -124, -124, -124, -124, -124, -124, -124, -124, -124, - -124, -124, -124, 58, -124, -124, 58, 58, 58, 58, - 58, 58, 58, 58, 147, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -124 - - }, - - { - 11, -125, -125, -125, -125, -125, -125, -125, -125, -125, - -125, -125, -125, 58, -125, -125, 58, 58, 58, 58, - 58, 58, 148, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -125 - }, - - { - 11, -126, -126, -126, -126, -126, -126, -126, -126, -126, - -126, -126, -126, 58, -126, -126, 58, 58, 58, 58, - 58, 149, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -126 - }, - - { - 11, -127, -127, -127, -127, -127, -127, -127, -127, -127, - -127, -127, -127, 58, -127, -127, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -127 - }, - - { - 11, -128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, -128, 58, -128, -128, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 150, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -128 - }, - - { - 11, -129, -129, -129, -129, -129, -129, -129, -129, -129, - -129, -129, -129, 58, -129, -129, 58, 58, 58, 151, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -129 - - }, - - { - 11, -130, -130, -130, -130, -130, -130, -130, -130, -130, - -130, -130, -130, 58, -130, -130, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 152, - 58, 58, 58, 58, 58, 58, 58, -130 - }, - - { - 11, -131, -131, -131, -131, -131, -131, -131, -131, -131, - -131, -131, -131, 58, -131, -131, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 153, 58, 58, 58, 58, 58, 58, -131 - }, - - { - 11, -132, -132, -132, -132, -132, -132, -132, -132, -132, - -132, -132, -132, 58, -132, -132, 58, 58, 58, 58, - - 58, 154, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -132 - }, - - { - 11, -133, -133, -133, -133, -133, -133, -133, -133, -133, - -133, -133, -133, 58, -133, -133, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 155, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -133 - }, - - { - 11, -134, -134, -134, -134, -134, -134, -134, -134, -134, - -134, -134, -134, 58, -134, -134, 58, 58, 58, 156, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -134 - - }, - - { - 11, -135, -135, -135, -135, -135, -135, -135, -135, -135, - -135, -135, -135, 58, -135, -135, 58, 58, 58, 157, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -135 - }, - - { - 11, -136, -136, -136, -136, -136, -136, -136, -136, -136, - -136, -136, -136, 58, -136, -136, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 158, 58, - 58, 58, 58, 58, 58, 58, 58, -136 - }, - - { - 11, -137, -137, -137, -137, -137, -137, -137, -137, -137, - -137, -137, -137, 58, -137, -137, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 159, 58, 58, -137 - }, - - { - 11, -138, -138, -138, -138, -138, -138, -138, -138, -138, - -138, -138, -138, 58, -138, -138, 58, 160, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -138 - }, - - { - 11, -139, -139, -139, -139, -139, -139, -139, -139, -139, - -139, -139, -139, 58, -139, -139, 58, 58, 58, 58, - 58, 161, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -139 - - }, - - { - 11, -140, -140, -140, -140, -140, -140, -140, -140, -140, - -140, -140, -140, 58, -140, -140, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 162, 58, - 58, 58, 58, 58, 58, 58, 58, -140 - }, - - { - 11, -141, -141, -141, -141, -141, -141, -141, -141, -141, - -141, -141, -141, 58, -141, -141, 58, 58, 58, 58, - 58, 58, 58, 163, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -141 - }, - - { - 11, -142, -142, -142, -142, -142, -142, -142, -142, -142, - -142, -142, -142, 58, -142, -142, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 164, - 58, 58, 58, 58, 58, 58, 58, -142 - }, - - { - 11, -143, -143, -143, -143, -143, -143, -143, -143, -143, - -143, -143, -143, 58, -143, -143, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 165, 58, 58, 58, 58, -143 - }, - - { - 11, -144, -144, -144, -144, -144, -144, -144, -144, -144, - -144, -144, -144, 58, -144, -144, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 166, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -144 - - }, - - { - 11, -145, -145, -145, -145, -145, -145, -145, -145, -145, - -145, -145, -145, 58, -145, -145, 58, 58, 58, 58, - 167, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -145 - }, - - { - 11, -146, -146, -146, -146, -146, -146, -146, -146, -146, - -146, -146, -146, 58, -146, -146, 58, 58, 58, 58, - 58, 168, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -146 - }, - - { - 11, -147, -147, -147, -147, -147, -147, -147, -147, -147, - -147, -147, -147, 58, -147, -147, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 169, - 58, 58, 58, 58, 58, 58, 58, -147 - }, - - { - 11, -148, -148, -148, -148, -148, -148, -148, -148, -148, - -148, -148, -148, 58, -148, -148, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -148 - }, - - { - 11, -149, -149, -149, -149, -149, -149, -149, -149, -149, - -149, -149, -149, 58, -149, -149, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 170, 58, - 58, 58, 58, 58, 58, 58, 58, -149 - - }, - - { - 11, -150, -150, -150, -150, -150, -150, -150, -150, -150, - -150, -150, -150, 58, -150, -150, 58, 58, 58, 58, - 58, 171, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -150 - }, - - { - 11, -151, -151, -151, -151, -151, -151, -151, -151, -151, - -151, -151, -151, 58, -151, -151, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 172, - 58, 58, 58, 58, 58, 58, 58, -151 - }, - - { - 11, -152, -152, -152, -152, -152, -152, -152, -152, -152, - -152, -152, -152, 58, -152, -152, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 173, 58, - 58, 58, 58, 58, 58, 58, 58, -152 - }, - - { - 11, -153, -153, -153, -153, -153, -153, -153, -153, -153, - -153, -153, -153, 58, -153, -153, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 174, 58, 58, -153 - }, - - { - 11, -154, -154, -154, -154, -154, -154, -154, -154, -154, - -154, -154, -154, 58, -154, -154, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -154 - - }, - - { - 11, -155, -155, -155, -155, -155, -155, -155, -155, -155, - -155, -155, -155, 58, -155, -155, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 175, 58, 58, 58, 58, -155 - }, - - { - 11, -156, -156, -156, -156, -156, -156, -156, -156, -156, - -156, -156, -156, 58, -156, -156, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 176, 58, 58, -156 - }, - - { - 11, -157, -157, -157, -157, -157, -157, -157, -157, -157, - -157, -157, -157, 58, -157, -157, 58, 58, 58, 58, - - 58, 177, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -157 - }, - - { - 11, -158, -158, -158, -158, -158, -158, -158, -158, -158, - -158, -158, -158, 58, -158, -158, 58, 58, 58, 58, - 58, 58, 58, 178, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -158 - }, - - { - 11, -159, -159, -159, -159, -159, -159, -159, -159, -159, - -159, -159, -159, 58, -159, -159, 58, 179, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -159 - - }, - - { - 11, -160, -160, -160, -160, -160, -160, -160, -160, -160, - -160, -160, -160, 58, -160, -160, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 180, 58, - 58, 58, 58, 58, 58, 58, 58, -160 - }, - - { - 11, -161, -161, -161, -161, -161, -161, -161, -161, -161, - -161, -161, -161, 58, -161, -161, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -161 - }, - - { - 11, -162, -162, -162, -162, -162, -162, -162, -162, -162, - -162, -162, -162, 58, -162, -162, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 181, 58, 58, -162 - }, - - { - 11, -163, -163, -163, -163, -163, -163, -163, -163, -163, - -163, -163, -163, 58, -163, -163, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -163 - }, - - { - 11, -164, -164, -164, -164, -164, -164, -164, -164, -164, - -164, -164, -164, 58, -164, -164, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 182, - 58, 58, 58, 58, 58, 58, 58, -164 - - }, - - { - 11, -165, -165, -165, -165, -165, -165, -165, -165, -165, - -165, -165, -165, 58, -165, -165, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 183, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -165 - }, - - { - 11, -166, -166, -166, -166, -166, -166, -166, -166, -166, - -166, -166, -166, 58, -166, -166, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 184, 58, 58, -166 - }, - - { - 11, -167, -167, -167, -167, -167, -167, -167, -167, -167, - -167, -167, -167, 58, -167, -167, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 185, 58, 58, 58, -167 - }, - - { - 11, -168, -168, -168, -168, -168, -168, -168, -168, -168, - -168, -168, -168, 58, -168, -168, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -168 - }, - - { - 11, -169, -169, -169, -169, -169, -169, -169, -169, -169, - -169, -169, -169, 58, -169, -169, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 186, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -169 - - }, - - { - 11, -170, -170, -170, -170, -170, -170, -170, -170, -170, - -170, -170, -170, 58, -170, -170, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 187, 58, -170 - }, - - { - 11, -171, -171, -171, -171, -171, -171, -171, -171, -171, - -171, -171, -171, 58, -171, -171, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 188, 58, - 58, 58, 58, 58, 58, 58, 58, -171 - }, - - { - 11, -172, -172, -172, -172, -172, -172, -172, -172, -172, - -172, -172, -172, 58, -172, -172, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 189, 58, - 58, 58, 58, 58, 58, 58, 58, -172 - }, - - { - 11, -173, -173, -173, -173, -173, -173, -173, -173, -173, - -173, -173, -173, 58, -173, -173, 58, 190, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -173 - }, - - { - 11, -174, -174, -174, -174, -174, -174, -174, -174, -174, - -174, -174, -174, 58, -174, -174, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -174 - - }, - - { - 11, -175, -175, -175, -175, -175, -175, -175, -175, -175, - -175, -175, -175, 58, -175, -175, 58, 58, 58, 58, - 58, 191, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -175 - }, - - { - 11, -176, -176, -176, -176, -176, -176, -176, -176, -176, - -176, -176, -176, 58, -176, -176, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -176 - }, - - { - 11, -177, -177, -177, -177, -177, -177, -177, -177, -177, - -177, -177, -177, 58, -177, -177, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -177 - }, - - { - 11, -178, -178, -178, -178, -178, -178, -178, -178, -178, - -178, -178, -178, 58, -178, -178, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -178 - }, - - { - 11, -179, -179, -179, -179, -179, -179, -179, -179, -179, - -179, -179, -179, 58, -179, -179, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 192, 58, 58, -179 - - }, - - { - 11, -180, -180, -180, -180, -180, -180, -180, -180, -180, - -180, -180, -180, 58, -180, -180, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -180 - }, - - { - 11, -181, -181, -181, -181, -181, -181, -181, -181, -181, - -181, -181, -181, 58, -181, -181, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -181 - }, - - { - 11, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -182, 58, -182, -182, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 193, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -182 - }, - - { - 11, -183, -183, -183, -183, -183, -183, -183, -183, -183, - -183, -183, -183, 58, -183, -183, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 194, 58, 58, 58, -183 - }, - - { - 11, -184, -184, -184, -184, -184, -184, -184, -184, -184, - -184, -184, -184, 58, -184, -184, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -184 - - }, - - { - 11, -185, -185, -185, -185, -185, -185, -185, -185, -185, - -185, -185, -185, 58, -185, -185, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -185 - }, - - { - 11, -186, -186, -186, -186, -186, -186, -186, -186, -186, - -186, -186, -186, 58, -186, -186, 58, 58, 58, 195, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -186 - }, - - { - 11, -187, -187, -187, -187, -187, -187, -187, -187, -187, - -187, -187, -187, 58, -187, -187, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -187 - }, - - { - 11, -188, -188, -188, -188, -188, -188, -188, -188, -188, - -188, -188, -188, 58, -188, -188, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 196, 58, -188 - }, - - { - 11, -189, -189, -189, -189, -189, -189, -189, -189, -189, - -189, -189, -189, 58, -189, -189, 58, 58, 58, 58, - 58, 58, 197, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -189 - - }, - - { - 11, -190, -190, -190, -190, -190, -190, -190, -190, -190, - -190, -190, -190, 58, -190, -190, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 198, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -190 - }, - - { - 11, -191, -191, -191, -191, -191, -191, -191, -191, -191, - -191, -191, -191, 58, -191, -191, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 199, 58, 58, 58, -191 - }, - - { - 11, -192, -192, -192, -192, -192, -192, -192, -192, -192, - -192, -192, -192, 58, -192, -192, 58, 58, 58, 58, - - 58, 200, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -192 - }, - - { - 11, -193, -193, -193, -193, -193, -193, -193, -193, -193, - -193, -193, -193, 58, -193, -193, 58, 58, 58, 58, - 58, 201, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -193 - }, - - { - 11, -194, -194, -194, -194, -194, -194, -194, -194, -194, - -194, -194, -194, 58, -194, -194, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 202, 58, 58, -194 - - }, - - { - 11, -195, -195, -195, -195, -195, -195, -195, -195, -195, - -195, -195, -195, 58, -195, -195, 58, 58, 58, 58, - 58, 203, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -195 - }, - - { - 11, -196, -196, -196, -196, -196, -196, -196, -196, -196, - -196, -196, -196, 58, -196, -196, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -196 - }, - - { - 11, -197, -197, -197, -197, -197, -197, -197, -197, -197, - -197, -197, -197, 58, -197, -197, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 204, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -197 - }, - - { - 11, -198, -198, -198, -198, -198, -198, -198, -198, -198, - -198, -198, -198, 58, -198, -198, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -198 - }, - - { - 11, -199, -199, -199, -199, -199, -199, -199, -199, -199, - -199, -199, -199, 58, -199, -199, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -199 - - }, - - { - 11, -200, -200, -200, -200, -200, -200, -200, -200, -200, - -200, -200, -200, 58, -200, -200, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -200 - }, - - { - 11, -201, -201, -201, -201, -201, -201, -201, -201, -201, - -201, -201, -201, 58, -201, -201, 58, 205, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -201 - }, - - { - 11, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, 58, -202, -202, 58, 206, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -202 - }, - - { - 11, -203, -203, -203, -203, -203, -203, -203, -203, -203, - -203, -203, -203, 58, -203, -203, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -203 - }, - - { - 11, -204, -204, -204, -204, -204, -204, -204, -204, -204, - -204, -204, -204, 58, -204, -204, 58, 58, 58, 58, - 58, 58, 58, 207, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -204 - - }, - - { - 11, -205, -205, -205, -205, -205, -205, -205, -205, -205, - -205, -205, -205, 58, -205, -205, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 208, 58, - 58, 58, 58, 58, 58, 58, 58, -205 - }, - - { - 11, -206, -206, -206, -206, -206, -206, -206, -206, -206, - -206, -206, -206, 58, -206, -206, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 209, 58, 58, -206 - }, - - { - 11, -207, -207, -207, -207, -207, -207, -207, -207, -207, - -207, -207, -207, 58, -207, -207, 58, 58, 58, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -207 - }, - - { - 11, -208, -208, -208, -208, -208, -208, -208, -208, -208, - -208, -208, -208, 58, -208, -208, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -208 - }, - - { - 11, -209, -209, -209, -209, -209, -209, -209, -209, -209, - -209, -209, -209, 58, -209, -209, 58, 58, 58, 58, - 58, 210, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -209 - - }, - - { - 11, -210, -210, -210, -210, -210, -210, -210, -210, -210, - -210, -210, -210, 58, -210, -210, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, -210 - }, - - } ; - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up zconftext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - zconfleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 64 -#define YY_END_OF_BUFFER 65 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[211] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 65, 5, 4, 3, 2, 36, 37, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 63, 60, 62, 55, 59, 58, 57, 53, 48, 42, - 47, 51, 53, 40, 41, 50, 50, 43, 53, 50, - 50, 53, 4, 3, 2, 2, 1, 35, 35, 35, - 35, 35, 35, 35, 16, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 63, 60, 62, 61, - 55, 54, 57, 56, 44, 51, 38, 50, 50, 52, - 45, 46, 39, 35, 35, 35, 35, 35, 35, 35, - - 35, 35, 30, 29, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 49, 25, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 15, 35, 7, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 17, 35, 35, - 35, 35, 35, 34, 35, 35, 35, 35, 35, 35, - 10, 35, 13, 35, 35, 35, 35, 33, 35, 35, - 35, 35, 35, 22, 35, 32, 9, 31, 35, 26, - 12, 35, 35, 21, 18, 35, 8, 35, 35, 35, - 35, 35, 27, 35, 35, 6, 35, 20, 19, 23, - - 35, 35, 11, 35, 35, 35, 14, 28, 35, 24 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, - 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, - 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 1, 15, 1, 1, 16, 1, 17, 18, 19, 20, - - 21, 22, 23, 24, 25, 13, 13, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 13, 13, 36, - 13, 13, 1, 37, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -extern int zconf_flex_debug; -int zconf_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *zconftext; - -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -#define START_STRSIZE 16 - -char *text; -static char *text_ptr; -static int text_size, text_asize; - -struct buffer { - struct buffer *parent; - YY_BUFFER_STATE state; -}; - -struct buffer *current_buf; - -static int last_ts, first_ts; - -static void zconf_endhelp(void); -static struct buffer *zconf_endfile(void); - -void new_string(void) -{ - text = malloc(START_STRSIZE); - text_asize = START_STRSIZE; - text_ptr = text; - text_size = 0; - *text_ptr = 0; -} - -void append_string(const char *str, int size) -{ - int new_size = text_size + size + 1; - if (new_size > text_asize) { - text = realloc(text, new_size); - text_asize = new_size; - text_ptr = text + text_size; - } - memcpy(text_ptr, str, size); - text_ptr += size; - text_size += size; - *text_ptr = 0; -} - -void alloc_string(const char *str, int size) -{ - text = malloc(size + 1); - memcpy(text, str, size); - text[size] = 0; -} - -#define INITIAL 0 -#define COMMAND 1 -#define HELP 2 -#define STRING 3 -#define PARAM 4 - -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int zconfwrap (void ); -#else -extern int zconfwrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - errno=0; \ - while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(zconfin); \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int zconflex (void); - -#define YY_DECL int zconflex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after zconftext and zconfleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - - int str = 0; - int ts, i; - - if ( (yy_init) ) - { - (yy_init) = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! zconfin ) - zconfin = stdin; - - if ( ! zconfout ) - zconfout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - zconfensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - zconf_create_buffer(zconfin,YY_BUF_SIZE ); - } - - zconf_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of zconftext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) - ++yy_cp; - - yy_current_state = -yy_current_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -/* rule 1 can match eol */ -YY_RULE_SETUP -current_file->lineno++; - YY_BREAK -case 2: -YY_RULE_SETUP - - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -current_file->lineno++; return T_EOL; - YY_BREAK -case 4: -YY_RULE_SETUP -{ - BEGIN(COMMAND); -} - YY_BREAK -case 5: -YY_RULE_SETUP -{ - unput(zconftext[0]); - BEGIN(COMMAND); -} - YY_BREAK - -case 6: -YY_RULE_SETUP -BEGIN(PARAM); return T_MAINMENU; - YY_BREAK -case 7: -YY_RULE_SETUP -BEGIN(PARAM); return T_MENU; - YY_BREAK -case 8: -YY_RULE_SETUP -BEGIN(PARAM); return T_ENDMENU; - YY_BREAK -case 9: -YY_RULE_SETUP -BEGIN(PARAM); return T_SOURCE; - YY_BREAK -case 10: -YY_RULE_SETUP -BEGIN(PARAM); return T_CHOICE; - YY_BREAK -case 11: -YY_RULE_SETUP -BEGIN(PARAM); return T_ENDCHOICE; - YY_BREAK -case 12: -YY_RULE_SETUP -BEGIN(PARAM); return T_COMMENT; - YY_BREAK -case 13: -YY_RULE_SETUP -BEGIN(PARAM); return T_CONFIG; - YY_BREAK -case 14: -YY_RULE_SETUP -BEGIN(PARAM); return T_MENUCONFIG; - YY_BREAK -case 15: -YY_RULE_SETUP -BEGIN(PARAM); return T_HELP; - YY_BREAK -case 16: -YY_RULE_SETUP -BEGIN(PARAM); return T_IF; - YY_BREAK -case 17: -YY_RULE_SETUP -BEGIN(PARAM); return T_ENDIF; - YY_BREAK -case 18: -YY_RULE_SETUP -BEGIN(PARAM); return T_DEPENDS; - YY_BREAK -case 19: -YY_RULE_SETUP -BEGIN(PARAM); return T_REQUIRES; - YY_BREAK -case 20: -YY_RULE_SETUP -BEGIN(PARAM); return T_OPTIONAL; - YY_BREAK -case 21: -YY_RULE_SETUP -BEGIN(PARAM); return T_DEFAULT; - YY_BREAK -case 22: -YY_RULE_SETUP -BEGIN(PARAM); return T_PROMPT; - YY_BREAK -case 23: -YY_RULE_SETUP -BEGIN(PARAM); return T_TRISTATE; - YY_BREAK -case 24: -YY_RULE_SETUP -BEGIN(PARAM); return T_DEF_TRISTATE; - YY_BREAK -case 25: -YY_RULE_SETUP -BEGIN(PARAM); return T_BOOLEAN; - YY_BREAK -case 26: -YY_RULE_SETUP -BEGIN(PARAM); return T_BOOLEAN; - YY_BREAK -case 27: -YY_RULE_SETUP -BEGIN(PARAM); return T_DEF_BOOLEAN; - YY_BREAK -case 28: -YY_RULE_SETUP -BEGIN(PARAM); return T_DEF_BOOLEAN; - YY_BREAK -case 29: -YY_RULE_SETUP -BEGIN(PARAM); return T_INT; - YY_BREAK -case 30: -YY_RULE_SETUP -BEGIN(PARAM); return T_HEX; - YY_BREAK -case 31: -YY_RULE_SETUP -BEGIN(PARAM); return T_STRING; - YY_BREAK -case 32: -YY_RULE_SETUP -BEGIN(PARAM); return T_SELECT; - YY_BREAK -case 33: -YY_RULE_SETUP -BEGIN(PARAM); return T_SELECT; - YY_BREAK -case 34: -YY_RULE_SETUP -BEGIN(PARAM); return T_RANGE; - YY_BREAK -case 35: -YY_RULE_SETUP -{ - alloc_string(zconftext, zconfleng); - zconflval.string = text; - return T_WORD; - } - YY_BREAK -case 36: -YY_RULE_SETUP - - YY_BREAK -case 37: -/* rule 37 can match eol */ -YY_RULE_SETUP -current_file->lineno++; BEGIN(INITIAL); - YY_BREAK - -case 38: -YY_RULE_SETUP -return T_AND; - YY_BREAK -case 39: -YY_RULE_SETUP -return T_OR; - YY_BREAK -case 40: -YY_RULE_SETUP -return T_OPEN_PAREN; - YY_BREAK -case 41: -YY_RULE_SETUP -return T_CLOSE_PAREN; - YY_BREAK -case 42: -YY_RULE_SETUP -return T_NOT; - YY_BREAK -case 43: -YY_RULE_SETUP -return T_EQUAL; - YY_BREAK -case 44: -YY_RULE_SETUP -return T_UNEQUAL; - YY_BREAK -case 45: -YY_RULE_SETUP -return T_IF; - YY_BREAK -case 46: -YY_RULE_SETUP -return T_ON; - YY_BREAK -case 47: -YY_RULE_SETUP -{ - str = zconftext[0]; - new_string(); - BEGIN(STRING); - } - YY_BREAK -case 48: -/* rule 48 can match eol */ -YY_RULE_SETUP -BEGIN(INITIAL); current_file->lineno++; return T_EOL; - YY_BREAK -case 49: -YY_RULE_SETUP -/* ignore */ - YY_BREAK -case 50: -YY_RULE_SETUP -{ - alloc_string(zconftext, zconfleng); - zconflval.string = text; - return T_WORD; - } - YY_BREAK -case 51: -YY_RULE_SETUP -/* comment */ - YY_BREAK -case 52: -/* rule 52 can match eol */ -YY_RULE_SETUP -current_file->lineno++; - YY_BREAK -case 53: -YY_RULE_SETUP - - YY_BREAK -case YY_STATE_EOF(PARAM): -{ - BEGIN(INITIAL); - } - YY_BREAK - -case 54: -/* rule 54 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up zconftext again */ -YY_RULE_SETUP -{ - append_string(zconftext, zconfleng); - zconflval.string = text; - return T_WORD_QUOTE; - } - YY_BREAK -case 55: -YY_RULE_SETUP -{ - append_string(zconftext, zconfleng); - } - YY_BREAK -case 56: -/* rule 56 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up zconftext again */ -YY_RULE_SETUP -{ - append_string(zconftext + 1, zconfleng - 1); - zconflval.string = text; - return T_WORD_QUOTE; - } - YY_BREAK -case 57: -YY_RULE_SETUP -{ - append_string(zconftext + 1, zconfleng - 1); - } - YY_BREAK -case 58: -YY_RULE_SETUP -{ - if (str == zconftext[0]) { - BEGIN(PARAM); - zconflval.string = text; - return T_WORD_QUOTE; - } else - append_string(zconftext, 1); - } - YY_BREAK -case 59: -/* rule 59 can match eol */ -YY_RULE_SETUP -{ - printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); - current_file->lineno++; - BEGIN(INITIAL); - return T_EOL; - } - YY_BREAK -case YY_STATE_EOF(STRING): -{ - BEGIN(INITIAL); - } - YY_BREAK - -case 60: -YY_RULE_SETUP -{ - ts = 0; - for (i = 0; i < zconfleng; i++) { - if (zconftext[i] == '\t') - ts = (ts & ~7) + 8; - else - ts++; - } - last_ts = ts; - if (first_ts) { - if (ts < first_ts) { - zconf_endhelp(); - return T_HELPTEXT; - } - ts -= first_ts; - while (ts > 8) { - append_string(" ", 8); - ts -= 8; - } - append_string(" ", ts); - } - } - YY_BREAK -case 61: -/* rule 61 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up zconftext again */ -YY_RULE_SETUP -{ - current_file->lineno++; - zconf_endhelp(); - return T_HELPTEXT; - } - YY_BREAK -case 62: -/* rule 62 can match eol */ -YY_RULE_SETUP -{ - current_file->lineno++; - append_string("\n", 1); - } - YY_BREAK -case 63: -YY_RULE_SETUP -{ - append_string(zconftext, zconfleng); - if (!first_ts) - first_ts = last_ts; - } - YY_BREAK -case YY_STATE_EOF(HELP): -{ - zconf_endhelp(); - return T_HELPTEXT; - } - YY_BREAK - -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(COMMAND): -{ - if (current_buf) { - zconf_endfile(); - return T_EOF; - } - fclose(zconfin); - yyterminate(); -} - YY_BREAK -case 64: -YY_RULE_SETUP -YY_FATAL_ERROR( "flex scanner jammed" ); - YY_BREAK - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed zconfin at a new source and called - * zconflex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( zconfwrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * zconftext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of zconflex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - zconfrestart(zconfin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - - yy_current_state = yy_nxt[yy_current_state][1]; - yy_is_jam = (yy_current_state <= 0); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up zconftext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - zconfrestart(zconfin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( zconfwrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve zconftext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void zconfrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - zconfensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - zconf_create_buffer(zconfin,YY_BUF_SIZE ); - } - - zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); - zconf_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * zconfpop_buffer_state(); - * zconfpush_buffer_state(new_buffer); - */ - zconfensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - zconf_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (zconfwrap()) processing, but the only time this flag - * is looked at is after zconfwrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void zconf_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - zconf_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with zconf_create_buffer() - * - */ - void zconf_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - zconffree((void *) b->yy_ch_buf ); - - zconffree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a zconfrestart() or at EOF. - */ - static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - zconf_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then zconf_init_buffer was _probably_ - * called from zconfrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void zconf_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - zconf_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - zconfensure_buffer_stack(); - - /* This block is copied from zconf_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from zconf_switch_to_buffer. */ - zconf_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void zconfpop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - zconf_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - zconf_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void zconfensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - zconf_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to zconflex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * zconf_scan_bytes() instead. - */ -YY_BUFFER_STATE zconf_scan_string (yyconst char * str ) -{ - - return zconf_scan_bytes(str,strlen(str) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) zconfalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = zconf_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up zconftext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - zconftext[zconfleng] = (yy_hold_char); \ - (yy_c_buf_p) = zconftext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - zconfleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int zconfget_lineno (void) -{ - - return zconflineno; -} - -/** Get the input stream. - * - */ -FILE *zconfget_in (void) -{ - return zconfin; -} - -/** Get the output stream. - * - */ -FILE *zconfget_out (void) -{ - return zconfout; -} - -/** Get the length of the current token. - * - */ -int zconfget_leng (void) -{ - return zconfleng; -} - -/** Get the current token. - * - */ - -char *zconfget_text (void) -{ - return zconftext; -} - -/** Set the current line number. - * @param line_number - * - */ -void zconfset_lineno (int line_number ) -{ - - zconflineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see zconf_switch_to_buffer - */ -void zconfset_in (FILE * in_str ) -{ - zconfin = in_str ; -} - -void zconfset_out (FILE * out_str ) -{ - zconfout = out_str ; -} - -int zconfget_debug (void) -{ - return zconf_flex_debug; -} - -void zconfset_debug (int bdebug ) -{ - zconf_flex_debug = bdebug ; -} - -/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ -int zconflex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - zconf_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - zconfpop_buffer_state(); - } - - /* Destroy the stack itself. */ - zconffree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *zconfalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *zconfrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void zconffree (void * ptr ) -{ - free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef yytext_ptr -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -void zconf_starthelp(void) -{ - new_string(); - last_ts = first_ts = 0; - BEGIN(HELP); -} - -static void zconf_endhelp(void) -{ - zconflval.string = text; - BEGIN(INITIAL); -} - -/* - * Try to open specified file with following names: - * ./name - * $(srctree)/name - * The latter is used when srctree is separate from objtree - * when compiling the kernel. - * Return NULL if file is not found. - */ -FILE *zconf_fopen(const char *name) -{ - char *env, fullname[PATH_MAX+1]; - FILE *f; - - f = fopen(name, "r"); - if (!f && name[0] != '/') { - env = getenv(SRCTREE); - if (env) { - sprintf(fullname, "%s/%s", env, name); - f = fopen(fullname, "r"); - } - } - return f; -} - -void zconf_initscan(const char *name) -{ - zconfin = zconf_fopen(name); - if (!zconfin) { - printf("can't find file %s\n", name); - exit(1); - } - - current_buf = malloc(sizeof(*current_buf)); - memset(current_buf, 0, sizeof(*current_buf)); - - current_file = file_lookup(name); - current_file->lineno = 1; - current_file->flags = FILE_BUSY; -} - -void zconf_nextfile(const char *name) -{ - struct file *file = file_lookup(name); - struct buffer *buf = malloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); - - current_buf->state = YY_CURRENT_BUFFER; - zconfin = zconf_fopen(name); - if (!zconfin) { - printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); - exit(1); - } - zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); - buf->parent = current_buf; - current_buf = buf; - - if (file->flags & FILE_BUSY) { - printf("recursive scan (%s)?\n", name); - exit(1); - } - if (file->flags & FILE_SCANNED) { - printf("file %s already scanned?\n", name); - exit(1); - } - file->flags |= FILE_BUSY; - file->lineno = 1; - file->parent = current_file; - current_file = file; -} - -static struct buffer *zconf_endfile(void) -{ - struct buffer *parent; - - current_file->flags |= FILE_SCANNED; - current_file->flags &= ~FILE_BUSY; - current_file = current_file->parent; - - parent = current_buf->parent; - if (parent) { - fclose(zconfin); - zconf_delete_buffer(YY_CURRENT_BUFFER); - zconf_switch_to_buffer(parent->state); - } - free(current_buf); - current_buf = parent; - - return parent; -} - -int zconf_lineno(void) -{ - if (current_buf) - return current_file->lineno - 1; - else - return 0; -} - -char *zconf_curname(void) -{ - if (current_buf) - return current_file->name; - else - return ""; -} - diff --git a/user/mpy/lib/axtls/config/scripts/config/lkc.h b/user/mpy/lib/axtls/config/scripts/config/lkc.h deleted file mode 100644 index b8a67fc..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lkc.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#ifndef LKC_H -#define LKC_H - -#include "expr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef LKC_DIRECT_LINK -#define P(name,type,arg) extern type name arg -#else -#include "lkc_defs.h" -#define P(name,type,arg) extern type (*name ## _p) arg -#endif -#include "lkc_proto.h" -#undef P - -#define SRCTREE "srctree" - -int zconfparse(void); -void zconfdump(FILE *out); - -extern int zconfdebug; -void zconf_starthelp(void); -FILE *zconf_fopen(const char *name); -void zconf_initscan(const char *name); -void zconf_nextfile(const char *name); -int zconf_lineno(void); -char *zconf_curname(void); - -/* confdata.c */ -extern const char conf_def_filename[]; -extern char conf_filename[]; - -char *conf_get_default_confname(void); - -/* kconfig_load.c */ -void kconfig_load(void); - -/* menu.c */ -void menu_init(void); -void menu_add_menu(void); -void menu_end_menu(void); -void menu_add_entry(struct symbol *sym); -void menu_end_entry(void); -void menu_add_dep(struct expr *dep); -struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); -void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); -void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); -void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_finalize(struct menu *parent); -void menu_set_type(int type); - -/* util.c */ -struct file *file_lookup(const char *name); -int file_write_dep(const char *name); - -struct gstr { - size_t len; - char *s; -}; -struct gstr str_new(void); -struct gstr str_assign(const char *s); -void str_free(struct gstr *gs); -void str_append(struct gstr *gs, const char *s); -void str_printf(struct gstr *gs, const char *fmt, ...); -const char *str_get(struct gstr *gs); - -/* symbol.c */ -void sym_init(void); -void sym_clear_all_valid(void); -void sym_set_changed(struct symbol *sym); -struct symbol *sym_check_deps(struct symbol *sym); -struct property *prop_alloc(enum prop_type type, struct symbol *sym); -struct symbol *prop_get_symbol(struct property *prop); - -static inline tristate sym_get_tristate_value(struct symbol *sym) -{ - return sym->curr.tri; -} - - -static inline struct symbol *sym_get_choice_value(struct symbol *sym) -{ - return (struct symbol *)sym->curr.val; -} - -static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) -{ - return sym_set_tristate_value(chval, yes); -} - -static inline bool sym_is_choice(struct symbol *sym) -{ - return sym->flags & SYMBOL_CHOICE ? true : false; -} - -static inline bool sym_is_choice_value(struct symbol *sym) -{ - return sym->flags & SYMBOL_CHOICEVAL ? true : false; -} - -static inline bool sym_is_optional(struct symbol *sym) -{ - return sym->flags & SYMBOL_OPTIONAL ? true : false; -} - -static inline bool sym_has_value(struct symbol *sym) -{ - return sym->flags & SYMBOL_NEW ? false : true; -} - -#ifdef __cplusplus -} -#endif - -#endif /* LKC_H */ diff --git a/user/mpy/lib/axtls/config/scripts/config/lkc_proto.h b/user/mpy/lib/axtls/config/scripts/config/lkc_proto.h deleted file mode 100644 index 6dc6d0c..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lkc_proto.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* confdata.c */ -P(conf_parse,void,(const char *name)); -P(conf_read,int,(const char *name)); -P(conf_write,int,(const char *name)); - -/* menu.c */ -P(rootmenu,struct menu,); - -P(menu_is_visible,bool,(struct menu *menu)); -P(menu_get_prompt,const char *,(struct menu *menu)); -P(menu_get_root_menu,struct menu *,(struct menu *menu)); -P(menu_get_parent_menu,struct menu *,(struct menu *menu)); - -/* symbol.c */ -P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); -P(sym_change_count,int,); - -P(sym_lookup,struct symbol *,(const char *name, int isconst)); -P(sym_find,struct symbol *,(const char *name)); -P(sym_re_search,struct symbol **,(const char *pattern)); -P(sym_type_name,const char *,(enum symbol_type type)); -P(sym_calc_value,void,(struct symbol *sym)); -P(sym_get_type,enum symbol_type,(struct symbol *sym)); -P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); -P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); -P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); -P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); -P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); -P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); -P(sym_is_changable,bool,(struct symbol *sym)); -P(sym_get_choice_prop,struct property *,(struct symbol *sym)); -P(sym_get_default_prop,struct property *,(struct symbol *sym)); -P(sym_get_string_value,const char *,(struct symbol *sym)); - -P(prop_get_type_name,const char *,(enum prop_type type)); - -/* expr.c */ -P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); -P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)); diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING b/user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING deleted file mode 100644 index a8999d8..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/BIG.FAT.WARNING +++ /dev/null @@ -1,4 +0,0 @@ -This is NOT the official version of dialog. This version has been -significantly modified from the original. It is for use by the Linux -kernel configuration script. Please do not bother Savio Lam with -questions about this program. diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c deleted file mode 100644 index 71de4a1..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/checklist.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * checklist.c -- implements the checklist box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension - * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -static int list_width, check_x, item_x, checkflag; - -/* - * Print list item - */ -static void -print_item (WINDOW * win, const char *item, int status, - int choice, int selected) -{ - int i; - - /* Clear 'residue' of last item */ - wattrset (win, menubox_attr); - wmove (win, choice, 0); - for (i = 0; i < list_width; i++) - waddch (win, ' '); - - wmove (win, choice, check_x); - wattrset (win, selected ? check_selected_attr : check_attr); - if (checkflag == FLAG_CHECK) - wprintw (win, "[%c]", status ? 'X' : ' '); - else - wprintw (win, "(%c)", status ? 'X' : ' '); - - wattrset (win, selected ? tag_selected_attr : tag_attr); - mvwaddch(win, choice, item_x, item[0]); - wattrset (win, selected ? item_selected_attr : item_attr); - waddstr (win, (char *)item+1); - if (selected) { - wmove (win, choice, check_x+1); - wrefresh (win); - } -} - -/* - * Print the scroll indicators. - */ -static void -print_arrows (WINDOW * win, int choice, int item_no, int scroll, - int y, int x, int height) -{ - wmove(win, y, x); - - if (scroll > 0) { - wattrset (win, uarrow_attr); - waddch (win, ACS_UARROW); - waddstr (win, "(-)"); - } - else { - wattrset (win, menubox_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } - - y = y + height + 1; - wmove(win, y, x); - - if ((height < item_no) && (scroll + choice < item_no - 1)) { - wattrset (win, darrow_attr); - waddch (win, ACS_DARROW); - waddstr (win, "(+)"); - } - else { - wattrset (win, menubox_border_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } -} - -/* - * Display the termination buttons - */ -static void -print_buttons( WINDOW *dialog, int height, int width, int selected) -{ - int x = width / 2 - 11; - int y = height - 2; - - print_button (dialog, "Select", y, x, selected == 0); - print_button (dialog, " Help ", y, x + 14, selected == 1); - - wmove(dialog, y, x+1 + 14*selected); - wrefresh (dialog); -} - -/* - * Display a dialog box with a list of options that can be turned on or off - * The `flag' parameter is used to select between radiolist and checklist. - */ -int -dialog_checklist (const char *title, const char *prompt, int height, int width, - int list_height, int item_no, struct dialog_list_item ** items, - int flag) - -{ - int i, x, y, box_x, box_y; - int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; - WINDOW *dialog, *list; - - checkflag = flag; - - /* Allocate space for storing item on/off status */ - if ((status = malloc (sizeof (int) * item_no)) == NULL) { - endwin (); - fprintf (stderr, - "\nCan't allocate memory in dialog_checklist().\n"); - exit (-1); - } - - /* Initializes status */ - for (i = 0; i < item_no; i++) { - status[i] = (items[i]->selected == 1); /* ON */ - if ((!choice && status[i]) || items[i]->selected == 2) /* SELECTED */ - choice = i + 1; - } - if (choice) - choice--; - - max_choice = MIN (list_height, item_no); - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - list_width = width - 6; - box_y = height - list_height - 5; - box_x = (width - list_width) / 2 - 1; - - /* create new window for the list */ - list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1); - - keypad (list, TRUE); - - /* draw a box around the list items */ - draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, - menubox_border_attr, menubox_attr); - - /* Find length of longest item in order to center checklist */ - check_x = 0; - for (i = 0; i < item_no; i++) - check_x = MAX (check_x, + strlen (items[i]->name) + 4); - - check_x = (list_width - check_x) / 2; - item_x = check_x + 4; - - if (choice >= list_height) { - scroll = choice - list_height + 1; - choice -= scroll; - } - - /* Print the list */ - for (i = 0; i < max_choice; i++) { - print_item (list, items[scroll + i]->name, - status[i+scroll], i, i == choice); - } - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - print_buttons(dialog, height, width, 0); - - wnoutrefresh (list); - wnoutrefresh (dialog); - doupdate (); - - while (key != ESC) { - key = wgetch (dialog); - - for (i = 0; i < max_choice; i++) - if (toupper(key) == toupper(items[scroll + i]->name[0])) - break; - - - if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || - key == '+' || key == '-' ) { - if (key == KEY_UP || key == '-') { - if (!choice) { - if (!scroll) - continue; - /* Scroll list down */ - if (list_height > 1) { - /* De-highlight current first item */ - print_item (list, items[scroll]->name, - status[scroll], 0, FALSE); - scrollok (list, TRUE); - wscrl (list, -1); - scrollok (list, FALSE); - } - scroll--; - print_item (list, items[scroll]->name, - status[scroll], 0, TRUE); - wnoutrefresh (list); - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - wrefresh (dialog); - - continue; /* wait for another key press */ - } else - i = choice - 1; - } else if (key == KEY_DOWN || key == '+') { - if (choice == max_choice - 1) { - if (scroll + choice >= item_no - 1) - continue; - /* Scroll list up */ - if (list_height > 1) { - /* De-highlight current last item before scrolling up */ - print_item (list, items[scroll + max_choice - 1]->name, - status[scroll + max_choice - 1], - max_choice - 1, FALSE); - scrollok (list, TRUE); - scroll (list); - scrollok (list, FALSE); - } - scroll++; - print_item (list, items[scroll + max_choice - 1]->name, - status[scroll + max_choice - 1], - max_choice - 1, TRUE); - wnoutrefresh (list); - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - wrefresh (dialog); - - continue; /* wait for another key press */ - } else - i = choice + 1; - } - if (i != choice) { - /* De-highlight current item */ - print_item (list, items[scroll + choice]->name, - status[scroll + choice], choice, FALSE); - /* Highlight new item */ - choice = i; - print_item (list, items[scroll + choice]->name, - status[scroll + choice], choice, TRUE); - wnoutrefresh (list); - wrefresh (dialog); - } - continue; /* wait for another key press */ - } - switch (key) { - case 'H': - case 'h': - case '?': - for (i = 0; i < item_no; i++) - items[i]->selected = 0; - items[scroll + choice]->selected = 1; - delwin (dialog); - free (status); - return 1; - case TAB: - case KEY_LEFT: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 1 : (button > 1 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh (dialog); - break; - case 'S': - case 's': - case ' ': - case '\n': - if (!button) { - if (flag == FLAG_CHECK) { - status[scroll + choice] = !status[scroll + choice]; - wmove (list, choice, check_x); - wattrset (list, check_selected_attr); - wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); - } else { - if (!status[scroll + choice]) { - for (i = 0; i < item_no; i++) - status[i] = 0; - status[scroll + choice] = 1; - for (i = 0; i < max_choice; i++) - print_item (list, items[scroll + i]->name, - status[scroll + i], i, i == choice); - } - } - wnoutrefresh (list); - wrefresh (dialog); - - for (i = 0; i < item_no; i++) { - items[i]->selected = status[i]; - } - } else { - for (i = 0; i < item_no; i++) - items[i]->selected = 0; - items[scroll + choice]->selected = 1; - } - delwin (dialog); - free (status); - return button; - case 'X': - case 'x': - key = ESC; - case ESC: - break; - } - - /* Now, update everything... */ - doupdate (); - } - - - delwin (dialog); - free (status); - return -1; /* ESC pressed */ -} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h b/user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h deleted file mode 100644 index d34dd37..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/colors.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * colors.h -- color attribute definitions - * - * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * Default color definitions - * - * *_FG = foreground - * *_BG = background - * *_HL = highlight? - */ -#define SCREEN_FG COLOR_CYAN -#define SCREEN_BG COLOR_BLUE -#define SCREEN_HL TRUE - -#define SHADOW_FG COLOR_BLACK -#define SHADOW_BG COLOR_BLACK -#define SHADOW_HL TRUE - -#define DIALOG_FG COLOR_BLACK -#define DIALOG_BG COLOR_WHITE -#define DIALOG_HL FALSE - -#define TITLE_FG COLOR_YELLOW -#define TITLE_BG COLOR_WHITE -#define TITLE_HL TRUE - -#define BORDER_FG COLOR_WHITE -#define BORDER_BG COLOR_WHITE -#define BORDER_HL TRUE - -#define BUTTON_ACTIVE_FG COLOR_WHITE -#define BUTTON_ACTIVE_BG COLOR_BLUE -#define BUTTON_ACTIVE_HL TRUE - -#define BUTTON_INACTIVE_FG COLOR_BLACK -#define BUTTON_INACTIVE_BG COLOR_WHITE -#define BUTTON_INACTIVE_HL FALSE - -#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE -#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE -#define BUTTON_KEY_ACTIVE_HL TRUE - -#define BUTTON_KEY_INACTIVE_FG COLOR_RED -#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE -#define BUTTON_KEY_INACTIVE_HL FALSE - -#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW -#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE -#define BUTTON_LABEL_ACTIVE_HL TRUE - -#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK -#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE -#define BUTTON_LABEL_INACTIVE_HL TRUE - -#define INPUTBOX_FG COLOR_BLACK -#define INPUTBOX_BG COLOR_WHITE -#define INPUTBOX_HL FALSE - -#define INPUTBOX_BORDER_FG COLOR_BLACK -#define INPUTBOX_BORDER_BG COLOR_WHITE -#define INPUTBOX_BORDER_HL FALSE - -#define SEARCHBOX_FG COLOR_BLACK -#define SEARCHBOX_BG COLOR_WHITE -#define SEARCHBOX_HL FALSE - -#define SEARCHBOX_TITLE_FG COLOR_YELLOW -#define SEARCHBOX_TITLE_BG COLOR_WHITE -#define SEARCHBOX_TITLE_HL TRUE - -#define SEARCHBOX_BORDER_FG COLOR_WHITE -#define SEARCHBOX_BORDER_BG COLOR_WHITE -#define SEARCHBOX_BORDER_HL TRUE - -#define POSITION_INDICATOR_FG COLOR_YELLOW -#define POSITION_INDICATOR_BG COLOR_WHITE -#define POSITION_INDICATOR_HL TRUE - -#define MENUBOX_FG COLOR_BLACK -#define MENUBOX_BG COLOR_WHITE -#define MENUBOX_HL FALSE - -#define MENUBOX_BORDER_FG COLOR_WHITE -#define MENUBOX_BORDER_BG COLOR_WHITE -#define MENUBOX_BORDER_HL TRUE - -#define ITEM_FG COLOR_BLACK -#define ITEM_BG COLOR_WHITE -#define ITEM_HL FALSE - -#define ITEM_SELECTED_FG COLOR_WHITE -#define ITEM_SELECTED_BG COLOR_BLUE -#define ITEM_SELECTED_HL TRUE - -#define TAG_FG COLOR_YELLOW -#define TAG_BG COLOR_WHITE -#define TAG_HL TRUE - -#define TAG_SELECTED_FG COLOR_YELLOW -#define TAG_SELECTED_BG COLOR_BLUE -#define TAG_SELECTED_HL TRUE - -#define TAG_KEY_FG COLOR_YELLOW -#define TAG_KEY_BG COLOR_WHITE -#define TAG_KEY_HL TRUE - -#define TAG_KEY_SELECTED_FG COLOR_YELLOW -#define TAG_KEY_SELECTED_BG COLOR_BLUE -#define TAG_KEY_SELECTED_HL TRUE - -#define CHECK_FG COLOR_BLACK -#define CHECK_BG COLOR_WHITE -#define CHECK_HL FALSE - -#define CHECK_SELECTED_FG COLOR_WHITE -#define CHECK_SELECTED_BG COLOR_BLUE -#define CHECK_SELECTED_HL TRUE - -#define UARROW_FG COLOR_GREEN -#define UARROW_BG COLOR_WHITE -#define UARROW_HL TRUE - -#define DARROW_FG COLOR_GREEN -#define DARROW_BG COLOR_WHITE -#define DARROW_HL TRUE - -/* End of default color definitions */ - -#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) -#define COLOR_NAME_LEN 10 -#define COLOR_COUNT 8 - -/* - * Global variables - */ - -typedef struct { - char name[COLOR_NAME_LEN]; - int value; -} color_names_st; - -extern color_names_st color_names[]; -extern int color_table[][3]; diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h b/user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h deleted file mode 100644 index 7bab3ad..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/dialog.h +++ /dev/null @@ -1,199 +0,0 @@ - -/* - * dialog.h -- common declarations for all dialog modules - * - * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include - -#ifdef CURSES_LOC -#ifdef __sun__ -#define CURS_MACROS -#endif -#include CURSES_LOC - -/* - * Colors in ncurses 1.9.9e do not work properly since foreground and - * background colors are OR'd rather than separately masked. This version - * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible - * with standard curses. The simplest fix (to make this work with standard - * curses) uses the wbkgdset() function, not used in the original hack. - * Turn it off if we're building with 1.9.9e, since it just confuses things. - */ -#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) -#define OLD_NCURSES 1 -#undef wbkgdset -#define wbkgdset(w,p) /*nothing*/ -#else -#define OLD_NCURSES 0 -#endif - -#define TR(params) _tracef params - -#define ESC 27 -#define TAB 9 -#define MAX_LEN 2048 -#define BUF_SIZE (10*1024) -#define MIN(x,y) (x < y ? x : y) -#define MAX(x,y) (x > y ? x : y) - - -#ifndef ACS_ULCORNER -#define ACS_ULCORNER '+' -#endif -#ifndef ACS_LLCORNER -#define ACS_LLCORNER '+' -#endif -#ifndef ACS_URCORNER -#define ACS_URCORNER '+' -#endif -#ifndef ACS_LRCORNER -#define ACS_LRCORNER '+' -#endif -#ifndef ACS_HLINE -#define ACS_HLINE '-' -#endif -#ifndef ACS_VLINE -#define ACS_VLINE '|' -#endif -#ifndef ACS_LTEE -#define ACS_LTEE '+' -#endif -#ifndef ACS_RTEE -#define ACS_RTEE '+' -#endif -#ifndef ACS_UARROW -#define ACS_UARROW '^' -#endif -#ifndef ACS_DARROW -#define ACS_DARROW 'v' -#endif - -/* - * Attribute names - */ -#define screen_attr attributes[0] -#define shadow_attr attributes[1] -#define dialog_attr attributes[2] -#define title_attr attributes[3] -#define border_attr attributes[4] -#define button_active_attr attributes[5] -#define button_inactive_attr attributes[6] -#define button_key_active_attr attributes[7] -#define button_key_inactive_attr attributes[8] -#define button_label_active_attr attributes[9] -#define button_label_inactive_attr attributes[10] -#define inputbox_attr attributes[11] -#define inputbox_border_attr attributes[12] -#define searchbox_attr attributes[13] -#define searchbox_title_attr attributes[14] -#define searchbox_border_attr attributes[15] -#define position_indicator_attr attributes[16] -#define menubox_attr attributes[17] -#define menubox_border_attr attributes[18] -#define item_attr attributes[19] -#define item_selected_attr attributes[20] -#define tag_attr attributes[21] -#define tag_selected_attr attributes[22] -#define tag_key_attr attributes[23] -#define tag_key_selected_attr attributes[24] -#define check_attr attributes[25] -#define check_selected_attr attributes[26] -#define uarrow_attr attributes[27] -#define darrow_attr attributes[28] - -/* number of attributes */ -#define ATTRIBUTE_COUNT 29 - -/* - * Global variables - */ -extern bool use_colors; - -extern chtype attributes[]; -#endif - -extern const char *backtitle; - -struct dialog_list_item { - char *name; - int namelen; - char *tag; - int selected; /* Set to 1 by dialog_*() function. */ -}; - -/* - * Function prototypes - */ - -void init_dialog (void); -void end_dialog (void); -void dialog_clear (void); -#ifdef CURSES_LOC -void attr_clear (WINDOW * win, int height, int width, chtype attr); -void color_setup (void); -void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); -void print_button (WINDOW * win, const char *label, int y, int x, int selected); -void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, - chtype border); -void draw_shadow (WINDOW * win, int y, int x, int height, int width); -#endif - -int first_alpha (const char *string, const char *exempt); -int dialog_yesno (const char *title, const char *prompt, int height, int width); -int dialog_msgbox (const char *title, const char *prompt, int height, - int width, int pause); -int dialog_textbox (const char *title, const char *file, int height, int width); -int dialog_menu (const char *title, const char *prompt, int height, int width, - int menu_height, const char *choice, int item_no, - struct dialog_list_item ** items); -int dialog_checklist (const char *title, const char *prompt, int height, - int width, int list_height, int item_no, - struct dialog_list_item ** items, int flag); -extern unsigned char dialog_input_result[]; -int dialog_inputbox (const char *title, const char *prompt, int height, - int width, const char *init); - -struct dialog_list_item *first_sel_item(int item_no, - struct dialog_list_item ** items); - -/* - * This is the base for fictitious keys, which activate - * the buttons. - * - * Mouse-generated keys are the following: - * -- the first 32 are used as numbers, in addition to '0'-'9' - * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') - * -- uppercase chars are used to invoke the button (M_EVENT + 'O') - */ -#ifdef CURSES_LOC -#define M_EVENT (KEY_MAX+1) -#endif - - -/* - * The `flag' parameter in checklist is used to select between - * radiolist and checklist - */ -#define FLAG_CHECK 1 -#define FLAG_RADIO 0 diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c deleted file mode 100644 index fa7bebc..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/inputbox.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * inputbox.c -- implements the input box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -unsigned char dialog_input_result[MAX_LEN + 1]; - -/* - * Print the termination buttons - */ -static void -print_buttons(WINDOW *dialog, int height, int width, int selected) -{ - int x = width / 2 - 11; - int y = height - 2; - - print_button (dialog, " Ok ", y, x, selected==0); - print_button (dialog, " Help ", y, x + 14, selected==1); - - wmove(dialog, y, x+1+14*selected); - wrefresh(dialog); -} - -/* - * Display a dialog box for inputing a string - */ -int -dialog_inputbox (const char *title, const char *prompt, int height, int width, - const char *init) -{ - int i, x, y, box_y, box_x, box_width; - int input_x = 0, scroll = 0, key = 0, button = -1; - unsigned char *instr = dialog_input_result; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - /* Draw the input field box */ - box_width = width - 6; - getyx (dialog, y, x); - box_y = y + 2; - box_x = (width - box_width) / 2; - draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, - border_attr, dialog_attr); - - print_buttons(dialog, height, width, 0); - - /* Set up the initial value */ - wmove (dialog, box_y, box_x); - wattrset (dialog, inputbox_attr); - - if (!init) - instr[0] = '\0'; - else - strcpy (instr, init); - - input_x = strlen (instr); - - if (input_x >= box_width) { - scroll = input_x - box_width + 1; - input_x = box_width - 1; - for (i = 0; i < box_width - 1; i++) - waddch (dialog, instr[scroll + i]); - } else - waddstr (dialog, instr); - - wmove (dialog, box_y, box_x + input_x); - - wrefresh (dialog); - - while (key != ESC) { - key = wgetch (dialog); - - if (button == -1) { /* Input box selected */ - switch (key) { - case TAB: - case KEY_UP: - case KEY_DOWN: - break; - case KEY_LEFT: - continue; - case KEY_RIGHT: - continue; - case KEY_BACKSPACE: - case 127: - if (input_x || scroll) { - wattrset (dialog, inputbox_attr); - if (!input_x) { - scroll = scroll < box_width - 1 ? - 0 : scroll - (box_width - 1); - wmove (dialog, box_y, box_x); - for (i = 0; i < box_width; i++) - waddch (dialog, instr[scroll + input_x + i] ? - instr[scroll + input_x + i] : ' '); - input_x = strlen (instr) - scroll; - } else - input_x--; - instr[scroll + input_x] = '\0'; - mvwaddch (dialog, box_y, input_x + box_x, ' '); - wmove (dialog, box_y, input_x + box_x); - wrefresh (dialog); - } - continue; - default: - if (key < 0x100 && isprint (key)) { - if (scroll + input_x < MAX_LEN) { - wattrset (dialog, inputbox_attr); - instr[scroll + input_x] = key; - instr[scroll + input_x + 1] = '\0'; - if (input_x == box_width - 1) { - scroll++; - wmove (dialog, box_y, box_x); - for (i = 0; i < box_width - 1; i++) - waddch (dialog, instr[scroll + i]); - } else { - wmove (dialog, box_y, input_x++ + box_x); - waddch (dialog, key); - } - wrefresh (dialog); - } else - flash (); /* Alarm user about overflow */ - continue; - } - } - } - switch (key) { - case 'O': - case 'o': - delwin (dialog); - return 0; - case 'H': - case 'h': - delwin (dialog); - return 1; - case KEY_UP: - case KEY_LEFT: - switch (button) { - case -1: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); - break; - case 0: - button = -1; /* Indicates input box is selected */ - print_buttons(dialog, height, width, 0); - wmove (dialog, box_y, box_x + input_x); - wrefresh (dialog); - break; - case 1: - button = 0; /* Indicates "OK" button is selected */ - print_buttons(dialog, height, width, 0); - break; - } - break; - case TAB: - case KEY_DOWN: - case KEY_RIGHT: - switch (button) { - case -1: - button = 0; /* Indicates "OK" button is selected */ - print_buttons(dialog, height, width, 0); - break; - case 0: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); - break; - case 1: - button = -1; /* Indicates input box is selected */ - print_buttons(dialog, height, width, 0); - wmove (dialog, box_y, box_x + input_x); - wrefresh (dialog); - break; - } - break; - case ' ': - case '\n': - delwin (dialog); - return (button == -1 ? 0 : button); - case 'X': - case 'x': - key = ESC; - case ESC: - break; - } - } - - delwin (dialog); - return -1; /* ESC pressed */ -} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c deleted file mode 100644 index 873dc58..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/menubox.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * menubox.c -- implements the menu box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * Changes by Clifford Wolf (god@clifford.at) - * - * [ 1998-06-13 ] - * - * *) A bugfix for the Page-Down problem - * - * *) Formerly when I used Page Down and Page Up, the cursor would be set - * to the first position in the menu box. Now lxdialog is a bit - * smarter and works more like other menu systems (just have a look at - * it). - * - * *) Formerly if I selected something my scrolling would be broken because - * lxdialog is re-invoked by the Menuconfig shell script, can't - * remember the last scrolling position, and just sets it so that the - * cursor is at the bottom of the box. Now it writes the temporary file - * lxdialog.scrltmp which contains this information. The file is - * deleted by lxdialog if the user leaves a submenu or enters a new - * one, but it would be nice if Menuconfig could make another "rm -f" - * just to be sure. Just try it out - you will recognise a difference! - * - * [ 1998-06-14 ] - * - * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files - * and menus change their size on the fly. - * - * *) If for some reason the last scrolling position is not saved by - * lxdialog, it sets the scrolling so that the selected item is in the - * middle of the menu box, not at the bottom. - * - * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) - * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. - * This fixes a bug in Menuconfig where using ' ' to descend into menus - * would leave mis-synchronized lxdialog.scrltmp files lying around, - * fscanf would read in 'scroll', and eventually that value would get used. - */ - -#include "dialog.h" - -static int menu_width, item_x; - -/* - * Print menu item - */ -static void -print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey) -{ - int j; - char menu_item[menu_width+1]; - - strncpy(menu_item, item, menu_width); - menu_item[menu_width] = 0; - j = first_alpha(menu_item, "YyNnMmHh"); - - /* Clear 'residue' of last item */ - wattrset (win, menubox_attr); - wmove (win, choice, 0); -#if OLD_NCURSES - { - int i; - for (i = 0; i < menu_width; i++) - waddch (win, ' '); - } -#else - wclrtoeol(win); -#endif - wattrset (win, selected ? item_selected_attr : item_attr); - mvwaddstr (win, choice, item_x, menu_item); - if (hotkey) { - wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); - mvwaddch(win, choice, item_x+j, menu_item[j]); - } - if (selected) { - wmove (win, choice, item_x+1); - wrefresh (win); - } -} - -/* - * Print the scroll indicators. - */ -static void -print_arrows (WINDOW * win, int item_no, int scroll, - int y, int x, int height) -{ - int cur_y, cur_x; - - getyx(win, cur_y, cur_x); - - wmove(win, y, x); - - if (scroll > 0) { - wattrset (win, uarrow_attr); - waddch (win, ACS_UARROW); - waddstr (win, "(-)"); - } - else { - wattrset (win, menubox_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } - - y = y + height + 1; - wmove(win, y, x); - - if ((height < item_no) && (scroll + height < item_no)) { - wattrset (win, darrow_attr); - waddch (win, ACS_DARROW); - waddstr (win, "(+)"); - } - else { - wattrset (win, menubox_border_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } - - wmove(win, cur_y, cur_x); -} - -/* - * Display the termination buttons. - */ -static void -print_buttons (WINDOW *win, int height, int width, int selected) -{ - int x = width / 2 - 16; - int y = height - 2; - - print_button (win, "Select", y, x, selected == 0); - print_button (win, " Exit ", y, x + 12, selected == 1); - print_button (win, " Help ", y, x + 24, selected == 2); - - wmove(win, y, x+1+12*selected); - wrefresh (win); -} - -/* - * Display a menu for choosing among a number of options - */ -int -dialog_menu (const char *title, const char *prompt, int height, int width, - int menu_height, const char *current, int item_no, - struct dialog_list_item ** items) -{ - int i, j, x, y, box_x, box_y; - int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice; - WINDOW *dialog, *menu; - FILE *f; - - max_choice = MIN (menu_height, item_no); - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - wbkgdset (dialog, dialog_attr & A_COLOR); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - menu_width = width - 6; - box_y = height - menu_height - 5; - box_x = (width - menu_width) / 2 - 1; - - /* create new window for the menu */ - menu = subwin (dialog, menu_height, menu_width, - y + box_y + 1, x + box_x + 1); - keypad (menu, TRUE); - - /* draw a box around the menu items */ - draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2, - menubox_border_attr, menubox_attr); - - /* - * Find length of longest item in order to center menu. - * Set 'choice' to default item. - */ - item_x = 0; - for (i = 0; i < item_no; i++) { - item_x = MAX (item_x, MIN(menu_width, strlen (items[i]->name) + 2)); - if (strcmp(current, items[i]->tag) == 0) choice = i; - } - - item_x = (menu_width - item_x) / 2; - - /* get the scroll info from the temp file */ - if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) { - if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) && - (scroll+max_choice > choice) && (scroll >= 0) && - (scroll+max_choice <= item_no) ) { - first_item = scroll; - choice = choice - scroll; - fclose(f); - } else { - scroll=0; - remove("lxdialog.scrltmp"); - fclose(f); - f=NULL; - } - } - if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { - if (choice >= item_no-max_choice/2) - scroll = first_item = item_no-max_choice; - else - scroll = first_item = choice - max_choice/2; - choice = choice - scroll; - } - - /* Print the menu */ - for (i=0; i < max_choice; i++) { - print_item (menu, items[first_item + i]->name, i, i == choice, - (items[first_item + i]->tag[0] != ':')); - } - - wnoutrefresh (menu); - - print_arrows(dialog, item_no, scroll, - box_y, box_x+item_x+1, menu_height); - - print_buttons (dialog, height, width, 0); - wmove (menu, choice, item_x+1); - wrefresh (menu); - - while (key != ESC) { - key = wgetch(menu); - - if (key < 256 && isalpha(key)) key = tolower(key); - - if (strchr("ynmh", key)) - i = max_choice; - else { - for (i = choice+1; i < max_choice; i++) { - j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); - if (key == tolower(items[scroll + i]->name[j])) - break; - } - if (i == max_choice) - for (i = 0; i < max_choice; i++) { - j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); - if (key == tolower(items[scroll + i]->name[j])) - break; - } - } - - if (i < max_choice || - key == KEY_UP || key == KEY_DOWN || - key == '-' || key == '+' || - key == KEY_PPAGE || key == KEY_NPAGE) { - - print_item (menu, items[scroll + choice]->name, choice, FALSE, - (items[scroll + choice]->tag[0] != ':')); - - if (key == KEY_UP || key == '-') { - if (choice < 2 && scroll) { - /* Scroll menu down */ - scrollok (menu, TRUE); - wscrl (menu, -1); - scrollok (menu, FALSE); - - scroll--; - - print_item (menu, items[scroll]->name, 0, FALSE, - (items[scroll]->tag[0] != ':')); - } else - choice = MAX(choice - 1, 0); - - } else if (key == KEY_DOWN || key == '+') { - - print_item (menu, items[scroll + choice]->name, choice, FALSE, - (items[scroll + choice]->tag[0] != ':')); - - if ((choice > max_choice-3) && - (scroll + max_choice < item_no) - ) { - /* Scroll menu up */ - scrollok (menu, TRUE); - scroll (menu); - scrollok (menu, FALSE); - - scroll++; - - print_item (menu, items[scroll + max_choice - 1]->name, - max_choice-1, FALSE, - (items[scroll + max_choice - 1]->tag[0] != ':')); - } else - choice = MIN(choice+1, max_choice-1); - - } else if (key == KEY_PPAGE) { - scrollok (menu, TRUE); - for (i=0; (i < max_choice); i++) { - if (scroll > 0) { - wscrl (menu, -1); - scroll--; - print_item (menu, items[scroll]->name, 0, FALSE, - (items[scroll]->tag[0] != ':')); - } else { - if (choice > 0) - choice--; - } - } - scrollok (menu, FALSE); - - } else if (key == KEY_NPAGE) { - for (i=0; (i < max_choice); i++) { - if (scroll+max_choice < item_no) { - scrollok (menu, TRUE); - scroll(menu); - scrollok (menu, FALSE); - scroll++; - print_item (menu, items[scroll + max_choice - 1]->name, - max_choice-1, FALSE, - (items[scroll + max_choice - 1]->tag[0] != ':')); - } else { - if (choice+1 < max_choice) - choice++; - } - } - - } else - choice = i; - - print_item (menu, items[scroll + choice]->name, choice, TRUE, - (items[scroll + choice]->tag[0] != ':')); - - print_arrows(dialog, item_no, scroll, - box_y, box_x+item_x+1, menu_height); - - wnoutrefresh (dialog); - wrefresh (menu); - - continue; /* wait for another key press */ - } - - switch (key) { - case KEY_LEFT: - case TAB: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 2 : (button > 2 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh (menu); - break; - case ' ': - case 's': - case 'y': - case 'n': - case 'm': - case '/': - /* save scroll info */ - if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { - fprintf(f,"%d\n",scroll); - fclose(f); - } - delwin (dialog); - items[scroll + choice]->selected = 1; - switch (key) { - case 's': return 3; - case 'y': return 3; - case 'n': return 4; - case 'm': return 5; - case ' ': return 6; - case '/': return 7; - } - return 0; - case 'h': - case '?': - button = 2; - case '\n': - delwin (dialog); - items[scroll + choice]->selected = 1; - - remove("lxdialog.scrltmp"); - return button; - case 'e': - case 'x': - key = ESC; - case ESC: - break; - } - } - - delwin (dialog); - remove("lxdialog.scrltmp"); - return -1; /* ESC pressed */ -} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c deleted file mode 100644 index 93692e1..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/msgbox.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * msgbox.c -- implements the message box and info box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -/* - * Display a message box. Program will pause and display an "OK" button - * if the parameter 'pause' is non-zero. - */ -int -dialog_msgbox (const char *title, const char *prompt, int height, int width, - int pause) -{ - int i, x, y, key = 0; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 2); - - if (pause) { - wattrset (dialog, border_attr); - mvwaddch (dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - print_button (dialog, " Ok ", - height - 2, width / 2 - 4, TRUE); - - wrefresh (dialog); - while (key != ESC && key != '\n' && key != ' ' && - key != 'O' && key != 'o' && key != 'X' && key != 'x') - key = wgetch (dialog); - } else { - key = '\n'; - wrefresh (dialog); - } - - delwin (dialog); - return key == ESC ? -1 : 0; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c deleted file mode 100644 index a5a460b..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/textbox.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - * textbox.c -- implements the text box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -static void back_lines (int n); -static void print_page (WINDOW * win, int height, int width); -static void print_line (WINDOW * win, int row, int width); -static char *get_line (void); -static void print_position (WINDOW * win, int height, int width); - -static int hscroll, fd, file_size, bytes_read; -static int begin_reached = 1, end_reached, page_length; -static char *buf, *page; - -/* - * Display text from a file in a dialog box. - */ -int -dialog_textbox (const char *title, const char *file, int height, int width) -{ - int i, x, y, cur_x, cur_y, fpos, key = 0; - int passed_end; - char search_term[MAX_LEN + 1]; - WINDOW *dialog, *text; - - search_term[0] = '\0'; /* no search term entered yet */ - - /* Open input file for reading */ - if ((fd = open (file, O_RDONLY)) == -1) { - endwin (); - fprintf (stderr, - "\nCan't open input file in dialog_textbox().\n"); - exit (-1); - } - /* Get file size. Actually, 'file_size' is the real file size - 1, - since it's only the last byte offset from the beginning */ - if ((file_size = lseek (fd, 0, SEEK_END)) == -1) { - endwin (); - fprintf (stderr, "\nError getting file size in dialog_textbox().\n"); - exit (-1); - } - /* Restore file pointer to beginning of file after getting file size */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - /* Allocate space for read buffer */ - if ((buf = malloc (BUF_SIZE + 1)) == NULL) { - endwin (); - fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n"); - exit (-1); - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in dialog_textbox().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; /* mark end of valid data */ - page = buf; /* page is pointer to start of page to be displayed */ - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - /* Create window for text region, used for scrolling text */ - text = subwin (dialog, height - 4, width - 2, y + 1, x + 1); - wattrset (text, dialog_attr); - wbkgdset (text, dialog_attr & A_COLOR); - - keypad (text, TRUE); - - /* register the new window, along with its borders */ - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - wbkgdset (dialog, dialog_attr & A_COLOR); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE); - wnoutrefresh (dialog); - getyx (dialog, cur_y, cur_x); /* Save cursor position */ - - /* Print first page of text */ - attr_clear (text, height - 4, width - 2, dialog_attr); - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - - while ((key != ESC) && (key != '\n')) { - key = wgetch (dialog); - switch (key) { - case 'E': /* Exit */ - case 'e': - case 'X': - case 'x': - delwin (dialog); - free (buf); - close (fd); - return 0; - case 'g': /* First page */ - case KEY_HOME: - if (!begin_reached) { - begin_reached = 1; - /* First page not in buffer? */ - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - if (fpos > bytes_read) { /* Yes, we have to read it in */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "dialog_textbox().\n"); - exit (-1); - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, - "\nError reading file in dialog_textbox().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } - page = buf; - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - } - break; - case 'G': /* Last page */ - case KEY_END: - - end_reached = 1; - /* Last page not in buffer? */ - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - if (fpos < file_size) { /* Yes, we have to read it in */ - if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, - "\nError reading file in dialog_textbox().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } - page = buf + bytes_read; - back_lines (height - 4); - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - break; - case 'K': /* Previous line */ - case 'k': - case KEY_UP: - if (!begin_reached) { - back_lines (page_length + 1); - - /* We don't call print_page() here but use scrolling to ensure - faster screen update. However, 'end_reached' and - 'page_length' should still be updated, and 'page' should - point to start of next page. This is done by calling - get_line() in the following 'for' loop. */ - scrollok (text, TRUE); - wscrl (text, -1); /* Scroll text region down one line */ - scrollok (text, FALSE); - page_length = 0; - passed_end = 0; - for (i = 0; i < height - 4; i++) { - if (!i) { - /* print first line of page */ - print_line (text, 0, width - 2); - wnoutrefresh (text); - } else - /* Called to update 'end_reached' and 'page' */ - get_line (); - if (!passed_end) - page_length++; - if (end_reached && !passed_end) - passed_end = 1; - } - - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - } - break; - case 'B': /* Previous page */ - case 'b': - case KEY_PPAGE: - if (begin_reached) - break; - back_lines (page_length + height - 4); - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case 'J': /* Next line */ - case 'j': - case KEY_DOWN: - if (!end_reached) { - begin_reached = 0; - scrollok (text, TRUE); - scroll (text); /* Scroll text region up one line */ - scrollok (text, FALSE); - print_line (text, height - 5, width - 2); - wnoutrefresh (text); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - } - break; - case KEY_NPAGE: /* Next page */ - case ' ': - if (end_reached) - break; - - begin_reached = 0; - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case '0': /* Beginning of line */ - case 'H': /* Scroll left */ - case 'h': - case KEY_LEFT: - if (hscroll <= 0) - break; - - if (key == '0') - hscroll = 0; - else - hscroll--; - /* Reprint current page to scroll horizontally */ - back_lines (page_length); - print_page (text, height - 4, width - 2); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case 'L': /* Scroll right */ - case 'l': - case KEY_RIGHT: - if (hscroll >= MAX_LEN) - break; - hscroll++; - /* Reprint current page to scroll horizontally */ - back_lines (page_length); - print_page (text, height - 4, width - 2); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case ESC: - break; - } - } - - delwin (dialog); - free (buf); - close (fd); - return 1; /* ESC pressed */ -} - -/* - * Go back 'n' lines in text file. Called by dialog_textbox(). - * 'page' will be updated to point to the desired line in 'buf'. - */ -static void -back_lines (int n) -{ - int i, fpos; - - begin_reached = 0; - /* We have to distinguish between end_reached and !end_reached - since at end of file, the line is not ended by a '\n'. - The code inside 'if' basically does a '--page' to move one - character backward so as to skip '\n' of the previous line */ - if (!end_reached) { - /* Either beginning of buffer or beginning of file reached? */ - if (page == buf) { - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "back_lines().\n"); - exit (-1); - } - if (fpos > bytes_read) { /* Not beginning of file yet */ - /* We've reached beginning of buffer, but not beginning of - file yet, so read previous part of file into buffer. - Note that we only move backward for BUF_SIZE/2 bytes, - but not BUF_SIZE bytes to avoid re-reading again in - print_page() later */ - /* Really possible to move backward BUF_SIZE/2 bytes? */ - if (fpos < BUF_SIZE / 2 + bytes_read) { - /* No, move less then */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "back_lines().\n"); - exit (-1); - } - page = buf + fpos - bytes_read; - } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) - == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer " - "in back_lines().\n"); - exit (-1); - } - page = buf + BUF_SIZE / 2; - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in back_lines().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } else { /* Beginning of file reached */ - begin_reached = 1; - return; - } - } - if (*(--page) != '\n') { /* '--page' here */ - /* Something's wrong... */ - endwin (); - fprintf (stderr, "\nInternal error in back_lines().\n"); - exit (-1); - } - } - /* Go back 'n' lines */ - for (i = 0; i < n; i++) - do { - if (page == buf) { - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in back_lines().\n"); - exit (-1); - } - if (fpos > bytes_read) { - /* Really possible to move backward BUF_SIZE/2 bytes? */ - if (fpos < BUF_SIZE / 2 + bytes_read) { - /* No, move less then */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer " - "in back_lines().\n"); - exit (-1); - } - page = buf + fpos - bytes_read; - } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), - SEEK_CUR) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer" - " in back_lines().\n"); - exit (-1); - } - page = buf + BUF_SIZE / 2; - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in " - "back_lines().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } else { /* Beginning of file reached */ - begin_reached = 1; - return; - } - } - } while (*(--page) != '\n'); - page++; -} - -/* - * Print a new page of text. Called by dialog_textbox(). - */ -static void -print_page (WINDOW * win, int height, int width) -{ - int i, passed_end = 0; - - page_length = 0; - for (i = 0; i < height; i++) { - print_line (win, i, width); - if (!passed_end) - page_length++; - if (end_reached && !passed_end) - passed_end = 1; - } - wnoutrefresh (win); -} - -/* - * Print a new line of text. Called by dialog_textbox() and print_page(). - */ -static void -print_line (WINDOW * win, int row, int width) -{ - int y, x; - char *line; - - line = get_line (); - line += MIN (strlen (line), hscroll); /* Scroll horizontally */ - wmove (win, row, 0); /* move cursor to correct line */ - waddch (win, ' '); - waddnstr (win, line, MIN (strlen (line), width - 2)); - - getyx (win, y, x); - /* Clear 'residue' of previous line */ -#if OLD_NCURSES - { - int i; - for (i = 0; i < width - x; i++) - waddch (win, ' '); - } -#else - wclrtoeol(win); -#endif -} - -/* - * Return current line of text. Called by dialog_textbox() and print_line(). - * 'page' should point to start of current line before calling, and will be - * updated to point to start of next line. - */ -static char * -get_line (void) -{ - int i = 0, fpos; - static char line[MAX_LEN + 1]; - - end_reached = 0; - while (*page != '\n') { - if (*page == '\0') { - /* Either end of file or end of buffer reached */ - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "get_line().\n"); - exit (-1); - } - if (fpos < file_size) { /* Not end of file yet */ - /* We've reached end of buffer, but not end of file yet, - so read next part of file into buffer */ - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in get_line().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - page = buf; - } else { - if (!end_reached) - end_reached = 1; - break; - } - } else if (i < MAX_LEN) - line[i++] = *(page++); - else { - /* Truncate lines longer than MAX_LEN characters */ - if (i == MAX_LEN) - line[i++] = '\0'; - page++; - } - } - if (i <= MAX_LEN) - line[i] = '\0'; - if (!end_reached) - page++; /* move pass '\n' */ - - return line; -} - -/* - * Print current position - */ -static void -print_position (WINDOW * win, int height, int width) -{ - int fpos, percent; - - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in print_position().\n"); - exit (-1); - } - wattrset (win, position_indicator_attr); - wbkgdset (win, position_indicator_attr & A_COLOR); - percent = !file_size ? - 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; - wmove (win, height - 3, width - 9); - wprintw (win, "(%3d%%)", percent); -} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c deleted file mode 100644 index 6f83951..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/util.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * util.c - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - - -/* use colors by default? */ -bool use_colors = 1; - -const char *backtitle = NULL; - -const char *dialog_result; - -/* - * Attribute values, default is for mono display - */ -chtype attributes[] = -{ - A_NORMAL, /* screen_attr */ - A_NORMAL, /* shadow_attr */ - A_NORMAL, /* dialog_attr */ - A_BOLD, /* title_attr */ - A_NORMAL, /* border_attr */ - A_REVERSE, /* button_active_attr */ - A_DIM, /* button_inactive_attr */ - A_REVERSE, /* button_key_active_attr */ - A_BOLD, /* button_key_inactive_attr */ - A_REVERSE, /* button_label_active_attr */ - A_NORMAL, /* button_label_inactive_attr */ - A_NORMAL, /* inputbox_attr */ - A_NORMAL, /* inputbox_border_attr */ - A_NORMAL, /* searchbox_attr */ - A_BOLD, /* searchbox_title_attr */ - A_NORMAL, /* searchbox_border_attr */ - A_BOLD, /* position_indicator_attr */ - A_NORMAL, /* menubox_attr */ - A_NORMAL, /* menubox_border_attr */ - A_NORMAL, /* item_attr */ - A_REVERSE, /* item_selected_attr */ - A_BOLD, /* tag_attr */ - A_REVERSE, /* tag_selected_attr */ - A_BOLD, /* tag_key_attr */ - A_REVERSE, /* tag_key_selected_attr */ - A_BOLD, /* check_attr */ - A_REVERSE, /* check_selected_attr */ - A_BOLD, /* uarrow_attr */ - A_BOLD /* darrow_attr */ -}; - - -#include "colors.h" - -/* - * Table of color values - */ -int color_table[][3] = -{ - {SCREEN_FG, SCREEN_BG, SCREEN_HL}, - {SHADOW_FG, SHADOW_BG, SHADOW_HL}, - {DIALOG_FG, DIALOG_BG, DIALOG_HL}, - {TITLE_FG, TITLE_BG, TITLE_HL}, - {BORDER_FG, BORDER_BG, BORDER_HL}, - {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, - {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, - {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, - {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, - {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, - {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, - BUTTON_LABEL_INACTIVE_HL}, - {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, - {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, - {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, - {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, - {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, - {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, - {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, - {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, - {ITEM_FG, ITEM_BG, ITEM_HL}, - {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, - {TAG_FG, TAG_BG, TAG_HL}, - {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, - {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, - {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, - {CHECK_FG, CHECK_BG, CHECK_HL}, - {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, - {UARROW_FG, UARROW_BG, UARROW_HL}, - {DARROW_FG, DARROW_BG, DARROW_HL}, -}; /* color_table */ - -/* - * Set window to attribute 'attr' - */ -void -attr_clear (WINDOW * win, int height, int width, chtype attr) -{ - int i, j; - - wattrset (win, attr); - for (i = 0; i < height; i++) { - wmove (win, i, 0); - for (j = 0; j < width; j++) - waddch (win, ' '); - } - touchwin (win); -} - -void dialog_clear (void) -{ - attr_clear (stdscr, LINES, COLS, screen_attr); - /* Display background title if it exists ... - SLH */ - if (backtitle != NULL) { - int i; - - wattrset (stdscr, screen_attr); - mvwaddstr (stdscr, 0, 1, (char *)backtitle); - wmove (stdscr, 1, 1); - for (i = 1; i < COLS - 1; i++) - waddch (stdscr, ACS_HLINE); - } - wnoutrefresh (stdscr); -} - -/* - * Do some initialization for dialog - */ -void -init_dialog (void) -{ - initscr (); /* Init curses */ - keypad (stdscr, TRUE); - cbreak (); - noecho (); - - - if (use_colors) /* Set up colors */ - color_setup (); - - - dialog_clear (); -} - -/* - * Setup for color display - */ -void -color_setup (void) -{ - int i; - - if (has_colors ()) { /* Terminal supports color? */ - start_color (); - - /* Initialize color pairs */ - for (i = 0; i < ATTRIBUTE_COUNT; i++) - init_pair (i + 1, color_table[i][0], color_table[i][1]); - - /* Setup color attributes */ - for (i = 0; i < ATTRIBUTE_COUNT; i++) - attributes[i] = C_ATTR (color_table[i][2], i + 1); - } -} - -/* - * End using dialog functions. - */ -void -end_dialog (void) -{ - endwin (); -} - - -/* - * Print a string of text in a window, automatically wrap around to the - * next line if the string is too long to fit on one line. Newline - * characters '\n' are replaced by spaces. We start on a new line - * if there is no room for at least 4 nonblanks following a double-space. - */ -void -print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) -{ - int newl, cur_x, cur_y; - int i, prompt_len, room, wlen; - char tempstr[MAX_LEN + 1], *word, *sp, *sp2; - - strcpy (tempstr, prompt); - - prompt_len = strlen(tempstr); - - /* - * Remove newlines - */ - for(i=0; i room || - (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room - && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { - cur_y++; - cur_x = x; - } - wmove (win, cur_y, cur_x); - waddstr (win, word); - getyx (win, cur_y, cur_x); - cur_x++; - if (sp && *sp == ' ') { - cur_x++; /* double space */ - while (*++sp == ' '); - newl = 1; - } else - newl = 0; - word = sp; - } - } -} - -/* - * Print a button - */ -void -print_button (WINDOW * win, const char *label, int y, int x, int selected) -{ - int i, temp; - - wmove (win, y, x); - wattrset (win, selected ? button_active_attr : button_inactive_attr); - waddstr (win, "<"); - temp = strspn (label, " "); - label += temp; - wattrset (win, selected ? button_label_active_attr - : button_label_inactive_attr); - for (i = 0; i < temp; i++) - waddch (win, ' '); - wattrset (win, selected ? button_key_active_attr - : button_key_inactive_attr); - waddch (win, label[0]); - wattrset (win, selected ? button_label_active_attr - : button_label_inactive_attr); - waddstr (win, (char *)label + 1); - wattrset (win, selected ? button_active_attr : button_inactive_attr); - waddstr (win, ">"); - wmove (win, y, x + temp + 1); -} - -/* - * Draw a rectangular box with line drawing characters - */ -void -draw_box (WINDOW * win, int y, int x, int height, int width, - chtype box, chtype border) -{ - int i, j; - - wattrset (win, 0); - for (i = 0; i < height; i++) { - wmove (win, y + i, x); - for (j = 0; j < width; j++) - if (!i && !j) - waddch (win, border | ACS_ULCORNER); - else if (i == height - 1 && !j) - waddch (win, border | ACS_LLCORNER); - else if (!i && j == width - 1) - waddch (win, box | ACS_URCORNER); - else if (i == height - 1 && j == width - 1) - waddch (win, box | ACS_LRCORNER); - else if (!i) - waddch (win, border | ACS_HLINE); - else if (i == height - 1) - waddch (win, box | ACS_HLINE); - else if (!j) - waddch (win, border | ACS_VLINE); - else if (j == width - 1) - waddch (win, box | ACS_VLINE); - else - waddch (win, box | ' '); - } -} - -/* - * Draw shadows along the right and bottom edge to give a more 3D look - * to the boxes - */ -void -draw_shadow (WINDOW * win, int y, int x, int height, int width) -{ - int i; - - if (has_colors ()) { /* Whether terminal supports color? */ - wattrset (win, shadow_attr); - wmove (win, y + height, x + 2); - for (i = 0; i < width; i++) - waddch (win, winch (win) & A_CHARTEXT); - for (i = y + 1; i < y + height + 1; i++) { - wmove (win, i, x + width); - waddch (win, winch (win) & A_CHARTEXT); - waddch (win, winch (win) & A_CHARTEXT); - } - wnoutrefresh (win); - } -} - -/* - * Return the position of the first alphabetic character in a string. - */ -int -first_alpha(const char *string, const char *exempt) -{ - int i, in_paren=0, c; - - for (i = 0; i < strlen(string); i++) { - c = tolower(string[i]); - - if (strchr("<[(", c)) ++in_paren; - if (strchr(">])", c) && in_paren > 0) --in_paren; - - if ((! in_paren) && isalpha(c) && - strchr(exempt, c) == 0) - return i; - } - - return 0; -} - -/* - * Get the first selected item in the dialog_list_item list. - */ -struct dialog_list_item * -first_sel_item(int item_no, struct dialog_list_item ** items) -{ - int i; - - for (i = 0; i < item_no; i++) { - if (items[i]->selected) - return items[i]; - } - - return NULL; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c b/user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c deleted file mode 100644 index 11fcc25..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/lxdialog/yesno.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * yesno.c -- implements the yes/no box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -/* - * Display termination buttons - */ -static void -print_buttons(WINDOW *dialog, int height, int width, int selected) -{ - int x = width / 2 - 10; - int y = height - 2; - - print_button (dialog, " Yes ", y, x, selected == 0); - print_button (dialog, " No ", y, x + 13, selected == 1); - - wmove(dialog, y, x+1 + 13*selected ); - wrefresh (dialog); -} - -/* - * Display a dialog box with two buttons - Yes and No - */ -int -dialog_yesno (const char *title, const char *prompt, int height, int width) -{ - int i, x, y, key = 0, button = 0; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - print_buttons(dialog, height, width, 0); - - while (key != ESC) { - key = wgetch (dialog); - switch (key) { - case 'Y': - case 'y': - delwin (dialog); - return 0; - case 'N': - case 'n': - delwin (dialog); - return 1; - - case TAB: - case KEY_LEFT: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 1 : (button > 1 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh (dialog); - break; - case ' ': - case '\n': - delwin (dialog); - return button; - case ESC: - break; - } - } - - delwin (dialog); - return -1; /* ESC pressed */ -} diff --git a/user/mpy/lib/axtls/config/scripts/config/mconf.c b/user/mpy/lib/axtls/config/scripts/config/mconf.c deleted file mode 100644 index 406eb29..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/mconf.c +++ /dev/null @@ -1,977 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - * - * Introduced single menu mode (show all sub-menus in one large tree). - * 2002-11-06 Petr Baudis - * - * Directly use liblxdialog library routines. - * 2002-11-14 Petr Baudis - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "lxdialog/dialog.h" - -#define LKC_DIRECT_LINK -#include "lkc.h" - -static char menu_backtitle[128]; -static const char mconf_readme[] = -"Overview\n" -"--------\n" -"Some features may be built directly into axTLS. Some features\n" -"may be completely removed altogether. There are also certain\n" -"parameters which are not really features, but must be\n" -"entered in as decimal or hexadecimal numbers or possibly text.\n" -"\n" -"Menu items beginning with [*] or [ ] represent features\n" -"configured to be built in or removed respectively.\n" -"\n" -"To change any of these features, highlight it with the cursor\n" -"keys and press to build it in or to removed it.\n" -"You may also press the to cycle\n" -"through the available options (ie. Y->N->Y).\n" -"\n" -"Some additional keyboard hints:\n" -"\n" -"Menus\n" -"----------\n" -"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" -" you wish to change or submenu wish to select and press .\n" -" Submenus are designated by \"--->\".\n" -"\n" -" Shortcut: Press the option's highlighted letter (hotkey).\n" -" Pressing a hotkey more than once will sequence\n" -" through all visible items which use that hotkey.\n" -"\n" -" You may also use the and keys to scroll\n" -" unseen options into view.\n" -"\n" -"o To exit a menu use the cursor keys to highlight the button\n" -" and press .\n" -"\n" -" Shortcut: Press or or if there is no hotkey\n" -" using those letters. You may press a single , but\n" -" there is a delayed response which you may find annoying.\n" -"\n" -" Also, the and cursor keys will cycle between and\n" -" \n" -"\n" -"\n" -"Data Entry\n" -"-----------\n" -"o Enter the requested information and press \n" -" If you are entering hexadecimal values, it is not necessary to\n" -" add the '0x' prefix to the entry.\n" -"\n" -"o For help, use the or cursor keys to highlight the help option\n" -" and press . You can try as well.\n" -"\n" -"\n" -"Text Box (Help Window)\n" -"--------\n" -"o Use the cursor keys to scroll up/down/left/right. The VI editor\n" -" keys h,j,k,l function here as do and for those\n" -" who are familiar with less and lynx.\n" -"\n" -"o Press , , or to exit.\n" -"\n" -"\n" -"Alternate Configuration Files\n" -"-----------------------------\n" -"Menuconfig supports the use of alternate configuration files for\n" -"those who, for various reasons, find it necessary to switch\n" -"between different configurations.\n" -"\n" -"At the end of the main menu you will find two options. One is\n" -"for saving the current configuration to a file of your choosing.\n" -"The other option is for loading a previously saved alternate\n" -"configuration.\n" -"\n" -"Even if you don't use alternate configuration files, but you\n" -"find during a Menuconfig session that you have completely messed\n" -"up your settings, you may use the \"Load Alternate...\" option to\n" -"restore your previously saved settings from \".config\" without\n" -"restarting Menuconfig.\n" -"\n" -"Other information\n" -"-----------------\n" -"If you use Menuconfig in an XTERM window make sure you have your\n" -"$TERM variable set to point to a xterm definition which supports color.\n" -"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n" -"display correctly in a RXVT window because rxvt displays only one\n" -"intensity of color, bright.\n" -"\n" -"Menuconfig will display larger menus on screens or xterms which are\n" -"set to display more than the standard 25 row by 80 column geometry.\n" -"In order for this to work, the \"stty size\" command must be able to\n" -"display the screen's current row and column geometry. I STRONGLY\n" -"RECOMMEND that you make sure you do NOT have the shell variables\n" -"LINES and COLUMNS exported into your environment. Some distributions\n" -"export those variables via /etc/profile. Some ncurses programs can\n" -"become confused when those variables (LINES & COLUMNS) don't reflect\n" -"the true screen size.\n" -"\n" -"Optional personality available\n" -"------------------------------\n" -"If you prefer to have all of the options listed in a single\n" -"menu, rather than the default multimenu hierarchy, run the menuconfig\n" -"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" -"\n" -"make MENUCONFIG_MODE=single_menu menuconfig\n" -"\n" -" will then unroll the appropriate category, or enfold it if it\n" -"is already unrolled.\n" -"\n" -"Note that this mode can eventually be a little more CPU expensive\n" -"(especially with a larger number of unrolled categories) than the\n" -"default mode.\n", -menu_instructions[] = - "Arrow keys navigate the menu. " - " selects submenus --->. " - "Highlighted letters are hotkeys. " - "Pressing selectes a feature, while will exclude a feature. " - "Press to exit, for Help, for Search. " - "Legend: [*] feature is selected [ ] feature is excluded", -radiolist_instructions[] = - "Use the arrow keys to navigate this window or " - "press the hotkey of the item you wish to select " - "followed by the . " - "Press for additional information about this option.", -inputbox_instructions_int[] = - "Please enter a decimal value. " - "Fractions will not be accepted. " - "Use the key to move from the input field to the buttons below it.", -inputbox_instructions_hex[] = - "Please enter a hexadecimal value. " - "Use the key to move from the input field to the buttons below it.", -inputbox_instructions_string[] = - "Please enter a string value. " - "Use the key to move from the input field to the buttons below it.", -setmod_text[] = - "This feature depends on another which has been configured as a module.\n" - "As a result, this feature will be built as a module.", -nohelp_text[] = - "There is no help available for this option.\n", -load_config_text[] = - "Enter the name of the configuration file you wish to load. " - "Accept the name shown to restore the configuration you " - "last retrieved. Leave blank to abort.", -load_config_help[] = - "\n" - "For various reasons, one may wish to keep several different axTLS\n" - "configurations available on a single machine.\n" - "\n" - "If you have saved a previous configuration in a file other than the\n" - "axTLS's default, entering the name of the file here will allow you\n" - "to modify that configuration.\n" - "\n" - "If you are uncertain, then you have probably never used alternate\n" - "configuration files. You should therefor leave this blank to abort.\n", -save_config_text[] = - "Enter a filename to which this configuration should be saved " - "as an alternate. Leave blank to abort.", -save_config_help[] = - "\n" - "For various reasons, one may wish to keep different axTLS\n" - "configurations available on a single machine.\n" - "\n" - "Entering a file name here will allow you to later retrieve, modify\n" - "and use the current configuration as an alternate to whatever\n" - "configuration options you have selected at that time.\n" - "\n" - "If you are uncertain what all this means then you should probably\n" - "leave this blank.\n", -search_help[] = - "\n" - "Search for CONFIG_ symbols and display their relations.\n" - "Example: search for \"^FOO\"\n" - "Result:\n" - "-----------------------------------------------------------------\n" - "Symbol: FOO [=m]\n" - "Prompt: Foo bus is used to drive the bar HW\n" - "Defined at drivers/pci/Kconfig:47\n" - "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" - "Location:\n" - " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" - " -> PCI support (PCI [=y])\n" - " -> PCI access mode ( [=y])\n" - "Selects: LIBCRC32\n" - "Selected by: BAR\n" - "-----------------------------------------------------------------\n" - "o The line 'Prompt:' shows the text used in the menu structure for\n" - " this CONFIG_ symbol\n" - "o The 'Defined at' line tell at what file / line number the symbol\n" - " is defined\n" - "o The 'Depends on:' line tell what symbols needs to be defined for\n" - " this symbol to be visible in the menu (selectable)\n" - "o The 'Location:' lines tell where in the menu structure this symbol\n" - " is located\n" - " A location followed by a [=y] indicate that this is a selectable\n" - " menu item - and current value is displayed inside brackets.\n" - "o The 'Selects:' line tell what symbol will be automatically\n" - " selected if this symbol is selected (y or m)\n" - "o The 'Selected by' line tell what symbol has selected this symbol\n" - "\n" - "Only relevant lines are shown.\n" - "\n\n" - "Search examples:\n" - "Examples: USB => find all CONFIG_ symbols containing USB\n" - " ^USB => find all CONFIG_ symbols starting with USB\n" - " USB$ => find all CONFIG_ symbols ending with USB\n" - "\n"; - -static char filename[PATH_MAX+1] = ".config"; -static int indent; -static struct termios ios_org; -static int rows = 0, cols = 0; -static struct menu *current_menu; -static int child_count; -static int single_menu_mode; - -static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */ -static int item_no; - -static void conf(struct menu *menu); -static void conf_choice(struct menu *menu); -static void conf_string(struct menu *menu); -static void conf_load(void); -static void conf_save(void); -static void show_textbox(const char *title, const char *text, int r, int c); -static void show_helptext(const char *title, const char *text); -static void show_help(struct menu *menu); -static void show_file(const char *filename, const char *title, int r, int c); - -static void init_wsize(void) -{ - struct winsize ws; - char *env; - - if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { - rows = ws.ws_row; - cols = ws.ws_col; - } - - if (!rows) { - env = getenv("LINES"); - if (env) - rows = atoi(env); - if (!rows) - rows = 24; - } - if (!cols) { - env = getenv("COLUMNS"); - if (env) - cols = atoi(env); - if (!cols) - cols = 80; - } - - if (rows < 19 || cols < 80) { - fprintf(stderr, "Your display is too small to run Menuconfig!\n"); - fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); - exit(1); - } - - rows -= 4; - cols -= 5; -} - -static void cinit(void) -{ - item_no = 0; -} - -static void cmake(void) -{ - items[item_no] = malloc(sizeof(struct dialog_list_item)); - memset(items[item_no], 0, sizeof(struct dialog_list_item)); - items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0; - items[item_no]->name = malloc(512); items[item_no]->name[0] = 0; - items[item_no]->namelen = 0; - item_no++; -} - -static int cprint_name(const char *fmt, ...) -{ - va_list ap; - int res; - - if (!item_no) - cmake(); - va_start(ap, fmt); - res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen, - 512 - items[item_no - 1]->namelen, fmt, ap); - if (res > 0) - items[item_no - 1]->namelen += res; - va_end(ap); - - return res; -} - -static int cprint_tag(const char *fmt, ...) -{ - va_list ap; - int res; - - if (!item_no) - cmake(); - va_start(ap, fmt); - res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap); - va_end(ap); - - return res; -} - -static void cdone(void) -{ - int i; - - for (i = 0; i < item_no; i++) { - free(items[i]->tag); - free(items[i]->name); - free(items[i]); - } - - item_no = 0; -} - -static void get_prompt_str(struct gstr *r, struct property *prop) -{ - int i, j; - struct menu *submenu[8], *menu; - - str_printf(r, "Prompt: %s\n", prop->text); - str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, - prop->menu->lineno); - if (!expr_is_yes(prop->visible.expr)) { - str_append(r, " Depends on: "); - expr_gstr_print(prop->visible.expr, r); - str_append(r, "\n"); - } - menu = prop->menu->parent; - for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) - submenu[i++] = menu; - if (i > 0) { - str_printf(r, " Location:\n"); - for (j = 4; --i >= 0; j += 2) { - menu = submenu[i]; - str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); - if (menu->sym) { - str_printf(r, " (%s [=%s])", menu->sym->name ? - menu->sym->name : "", - sym_get_string_value(menu->sym)); - } - str_append(r, "\n"); - } - } -} - -static void get_symbol_str(struct gstr *r, struct symbol *sym) -{ - bool hit; - struct property *prop; - - str_printf(r, "Symbol: %s [=%s]\n", sym->name, - sym_get_string_value(sym)); - for_all_prompts(sym, prop) - get_prompt_str(r, prop); - hit = false; - for_all_properties(sym, prop, P_SELECT) { - if (!hit) { - str_append(r, " Selects: "); - hit = true; - } else - str_printf(r, " && "); - expr_gstr_print(prop->expr, r); - } - if (hit) - str_append(r, "\n"); - if (sym->rev_dep.expr) { - str_append(r, " Selected by: "); - expr_gstr_print(sym->rev_dep.expr, r); - str_append(r, "\n"); - } - str_append(r, "\n\n"); -} - -static struct gstr get_relations_str(struct symbol **sym_arr) -{ - struct symbol *sym; - struct gstr res = str_new(); - int i; - - for (i = 0; sym_arr && (sym = sym_arr[i]); i++) - get_symbol_str(&res, sym); - if (!i) - str_append(&res, "No matches found.\n"); - return res; -} - -static void search_conf(void) -{ - struct symbol **sym_arr; - struct gstr res; - -again: - switch (dialog_inputbox("Search Configuration Parameter", - "Enter Keyword", 10, 75, - NULL)) { - case 0: - break; - case 1: - show_helptext("Search Configuration", search_help); - goto again; - default: - return; - } - - sym_arr = sym_re_search(dialog_input_result); - res = get_relations_str(sym_arr); - free(sym_arr); - show_textbox("Search Results", str_get(&res), 0, 0); - str_free(&res); -} - -static void build_conf(struct menu *menu) -{ - struct symbol *sym; - struct property *prop; - struct menu *child; - int type, tmp, doint = 2; - tristate val; - char ch; - - if (!menu_is_visible(menu)) - return; - - sym = menu->sym; - prop = menu->prompt; - if (!sym) { - if (prop && menu != current_menu) { - const char *prompt = menu_get_prompt(menu); - switch (prop->type) { - case P_MENU: - child_count++; - cmake(); - cprint_tag("m%p", menu); - - if (single_menu_mode) { - cprint_name("%s%*c%s", - menu->data ? "-->" : "++>", - indent + 1, ' ', prompt); - } else { - cprint_name(" %*c%s --->", indent + 1, ' ', prompt); - } - - if (single_menu_mode && menu->data) - goto conf_childs; - return; - default: - if (prompt) { - child_count++; - cmake(); - cprint_tag(":%p", menu); - cprint_name("---%*c%s", indent + 1, ' ', prompt); - } - } - } else - doint = 0; - goto conf_childs; - } - - cmake(); - type = sym_get_type(sym); - if (sym_is_choice(sym)) { - struct symbol *def_sym = sym_get_choice_value(sym); - struct menu *def_menu = NULL; - - child_count++; - for (child = menu->list; child; child = child->next) { - if (menu_is_visible(child) && child->sym == def_sym) - def_menu = child; - } - - val = sym_get_tristate_value(sym); - if (sym_is_changable(sym)) { - cprint_tag("t%p", menu); - switch (type) { - case S_BOOLEAN: - cprint_name("[%c]", val == no ? ' ' : '*'); - break; - case S_TRISTATE: - switch (val) { - case yes: ch = '*'; break; - case mod: ch = 'M'; break; - default: ch = ' '; break; - } - cprint_name("<%c>", ch); - break; - } - } else { - cprint_tag("%c%p", def_menu ? 't' : ':', menu); - cprint_name(" "); - } - - cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); - if (val == yes) { - if (def_menu) { - cprint_name(" (%s)", menu_get_prompt(def_menu)); - cprint_name(" --->"); - if (def_menu->list) { - indent += 2; - build_conf(def_menu); - indent -= 2; - } - } - return; - } - } else { - if (menu == current_menu) { - cprint_tag(":%p", menu); - cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); - goto conf_childs; - } - child_count++; - val = sym_get_tristate_value(sym); - if (sym_is_choice_value(sym) && val == yes) { - cprint_tag(":%p", menu); - cprint_name(" "); - } else { - switch (type) { - case S_BOOLEAN: - cprint_tag("t%p", menu); - if (sym_is_changable(sym)) - cprint_name("[%c]", val == no ? ' ' : '*'); - else - cprint_name("---"); - break; - case S_TRISTATE: - cprint_tag("t%p", menu); - switch (val) { - case yes: ch = '*'; break; - case mod: ch = 'M'; break; - default: ch = ' '; break; - } - if (sym_is_changable(sym)) - cprint_name("<%c>", ch); - else - cprint_name("---"); - break; - default: - cprint_tag("s%p", menu); - tmp = cprint_name("(%s)", sym_get_string_value(sym)); - tmp = indent - tmp + 4; - if (tmp < 0) - tmp = 0; - cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), - (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); - goto conf_childs; - } - } - cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), - (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); - if (menu->prompt->type == P_MENU) { - cprint_name(" --->"); - return; - } - } - -conf_childs: - indent += doint; - for (child = menu->list; child; child = child->next) - build_conf(child); - indent -= doint; -} - -static void conf(struct menu *menu) -{ - struct dialog_list_item *active_item = NULL; - struct menu *submenu; - const char *prompt = menu_get_prompt(menu); - struct symbol *sym; - char active_entry[40]; - int stat, type; - - unlink("lxdialog.scrltmp"); - active_entry[0] = 0; - while (1) { - indent = 0; - child_count = 0; - current_menu = menu; - cdone(); cinit(); - build_conf(menu); - if (!child_count) - break; - if (menu == &rootmenu) { - cmake(); cprint_tag(":"); cprint_name("--- "); - cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); - cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); - } - dialog_clear(); - stat = dialog_menu(prompt ? prompt : "Main Menu", - menu_instructions, rows, cols, rows - 10, - active_entry, item_no, items); - if (stat < 0) - return; - - if (stat == 1 || stat == 255) - break; - - active_item = first_sel_item(item_no, items); - if (!active_item) - continue; - active_item->selected = 0; - strncpy(active_entry, active_item->tag, sizeof(active_entry)); - active_entry[sizeof(active_entry)-1] = 0; - type = active_entry[0]; - if (!type) - continue; - - sym = NULL; - submenu = NULL; - if (sscanf(active_entry + 1, "%p", &submenu) == 1) - sym = submenu->sym; - - switch (stat) { - case 0: - switch (type) { - case 'm': - if (single_menu_mode) - submenu->data = (void *) (long) !submenu->data; - else - conf(submenu); - break; - case 't': - if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) - conf_choice(submenu); - else if (submenu->prompt->type == P_MENU) - conf(submenu); - break; - case 's': - conf_string(submenu); - break; - case 'L': - conf_load(); - break; - case 'S': - conf_save(); - break; - } - break; - case 2: - if (sym) - show_help(submenu); - else - show_helptext("README", mconf_readme); - break; - case 3: - if (type == 't') { - if (sym_set_tristate_value(sym, yes)) - break; - if (sym_set_tristate_value(sym, mod)) - show_textbox(NULL, setmod_text, 6, 74); - } - break; - case 4: - if (type == 't') - sym_set_tristate_value(sym, no); - break; - case 5: - if (type == 't') - sym_set_tristate_value(sym, mod); - break; - case 6: - if (type == 't') - sym_toggle_tristate_value(sym); - else if (type == 'm') - conf(submenu); - break; - case 7: - search_conf(); - break; - } - } -} - -static void show_textbox(const char *title, const char *text, int r, int c) -{ - int fd; - - fd = creat(".help.tmp", 0777); - write(fd, text, strlen(text)); - close(fd); - show_file(".help.tmp", title, r, c); - unlink(".help.tmp"); -} - -static void show_helptext(const char *title, const char *text) -{ - show_textbox(title, text, 0, 0); -} - -static void show_help(struct menu *menu) -{ - struct gstr help = str_new(); - struct symbol *sym = menu->sym; - - if (sym->help) - { - if (sym->name) { - str_printf(&help, "%s:\n\n", sym->name); - str_append(&help, sym->help); - str_append(&help, "\n"); - } - } else { - str_append(&help, nohelp_text); - } - get_symbol_str(&help, sym); - show_helptext(menu_get_prompt(menu), str_get(&help)); - str_free(&help); -} - -static void show_file(const char *filename, const char *title, int r, int c) -{ - while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) - ; -} - -static void conf_choice(struct menu *menu) -{ - const char *prompt = menu_get_prompt(menu); - struct menu *child; - struct symbol *active; - - active = sym_get_choice_value(menu->sym); - while (1) { - current_menu = menu; - cdone(); cinit(); - for (child = menu->list; child; child = child->next) { - if (!menu_is_visible(child)) - continue; - cmake(); - cprint_tag("%p", child); - cprint_name("%s", menu_get_prompt(child)); - if (child->sym == sym_get_choice_value(menu->sym)) - items[item_no - 1]->selected = 1; /* ON */ - else if (child->sym == active) - items[item_no - 1]->selected = 2; /* SELECTED */ - else - items[item_no - 1]->selected = 0; /* OFF */ - } - - switch (dialog_checklist(prompt ? prompt : "Main Menu", - radiolist_instructions, 15, 70, 6, - item_no, items, FLAG_RADIO)) { - case 0: - if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) != 1) - break; - sym_set_tristate_value(child->sym, yes); - return; - case 1: - if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) == 1) { - show_help(child); - active = child->sym; - } else - show_help(menu); - break; - case 255: - return; - } - } -} - -static void conf_string(struct menu *menu) -{ - const char *prompt = menu_get_prompt(menu); - - while (1) { - char *heading; - - switch (sym_get_type(menu->sym)) { - case S_INT: - heading = (char *) inputbox_instructions_int; - break; - case S_HEX: - heading = (char *) inputbox_instructions_hex; - break; - case S_STRING: - heading = (char *) inputbox_instructions_string; - break; - default: - heading = "Internal mconf error!"; - /* panic? */; - } - - switch (dialog_inputbox(prompt ? prompt : "Main Menu", - heading, 10, 75, - sym_get_string_value(menu->sym))) { - case 0: - if (sym_set_string_value(menu->sym, dialog_input_result)) - return; - show_textbox(NULL, "You have made an invalid entry.", 5, 43); - break; - case 1: - show_help(menu); - break; - case 255: - return; - } - } -} - -static void conf_load(void) -{ - while (1) { - switch (dialog_inputbox(NULL, load_config_text, 11, 55, - filename)) { - case 0: - if (!dialog_input_result[0]) - return; - if (!conf_read(dialog_input_result)) - return; - show_textbox(NULL, "File does not exist!", 5, 38); - break; - case 1: - show_helptext("Load Alternate Configuration", load_config_help); - break; - case 255: - return; - } - } -} - -static void conf_save(void) -{ - while (1) { - switch (dialog_inputbox(NULL, save_config_text, 11, 55, - filename)) { - case 0: - if (!dialog_input_result[0]) - return; - if (!conf_write(dialog_input_result)) - return; - show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); - break; - case 1: - show_helptext("Save Alternate Configuration", save_config_help); - break; - case 255: - return; - } - } -} - -static void conf_cleanup(void) -{ - tcsetattr(1, TCSAFLUSH, &ios_org); - unlink(".help.tmp"); -} - -static void winch_handler(int sig) -{ - struct winsize ws; - - if (ioctl(1, TIOCGWINSZ, &ws) == -1) { - rows = 24; - cols = 80; - } else { - rows = ws.ws_row; - cols = ws.ws_col; - } - - if (rows < 19 || cols < 80) { - end_dialog(); - fprintf(stderr, "Your display is too small to run Menuconfig!\n"); - fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); - exit(1); - } - - rows -= 4; - cols -= 5; - -} - -int main(int ac, char **av) -{ - struct symbol *sym; - char *mode; - int stat; - - conf_parse(av[1]); - conf_read(NULL); - - sym = sym_lookup("VERSION", 0); - sym_calc_value(sym); - snprintf(menu_backtitle, 128, "axTLS v%s Configuration", - sym_get_string_value(sym)); - - mode = getenv("MENUCONFIG_MODE"); - if (mode) { - if (!strcasecmp(mode, "single_menu")) - single_menu_mode = 1; - } - - tcgetattr(1, &ios_org); - atexit(conf_cleanup); - init_wsize(); - init_dialog(); - signal(SIGWINCH, winch_handler); - conf(&rootmenu); - end_dialog(); - - /* Restart dialog to act more like when lxdialog was still separate */ - init_dialog(); - do { - stat = dialog_yesno(NULL, - "Do you wish to save your new axTLS configuration?", 5, 60); - } while (stat < 0); - end_dialog(); - - if (stat == 0) { - conf_write(NULL); - printf("\n\n" - "*** End of axTLS configuration.\n" - "*** Check the top-level Makefile for additional configuration options.\n\n"); - } else - printf("\n\nYour axTLS configuration changes were NOT saved.\n\n"); - - return 0; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/menu.c b/user/mpy/lib/axtls/config/scripts/config/menu.c deleted file mode 100644 index 0c13156..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/menu.c +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -struct menu rootmenu; -static struct menu **last_entry_ptr; - -struct file *file_list; -struct file *current_file; - -static void menu_warn(struct menu *menu, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - -static void prop_warn(struct property *prop, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - -void menu_init(void) -{ - current_entry = current_menu = &rootmenu; - last_entry_ptr = &rootmenu.list; -} - -void menu_add_entry(struct symbol *sym) -{ - struct menu *menu; - - menu = malloc(sizeof(*menu)); - memset(menu, 0, sizeof(*menu)); - menu->sym = sym; - menu->parent = current_menu; - menu->file = current_file; - menu->lineno = zconf_lineno(); - - *last_entry_ptr = menu; - last_entry_ptr = &menu->next; - current_entry = menu; -} - -void menu_end_entry(void) -{ -} - -void menu_add_menu(void) -{ - current_menu = current_entry; - last_entry_ptr = ¤t_entry->list; -} - -void menu_end_menu(void) -{ - last_entry_ptr = ¤t_menu->next; - current_menu = current_menu->parent; -} - -struct expr *menu_check_dep(struct expr *e) -{ - if (!e) - return e; - - switch (e->type) { - case E_NOT: - e->left.expr = menu_check_dep(e->left.expr); - break; - case E_OR: - case E_AND: - e->left.expr = menu_check_dep(e->left.expr); - e->right.expr = menu_check_dep(e->right.expr); - break; - case E_SYMBOL: - /* change 'm' into 'm' && MODULES */ - if (e->left.sym == &symbol_mod) - return expr_alloc_and(e, expr_alloc_symbol(modules_sym)); - break; - default: - break; - } - return e; -} - -void menu_add_dep(struct expr *dep) -{ - current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); -} - -void menu_set_type(int type) -{ - struct symbol *sym = current_entry->sym; - - if (sym->type == type) - return; - if (sym->type == S_UNKNOWN) { - sym->type = type; - return; - } - menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'\n", - sym->name ? sym->name : "", - sym_type_name(sym->type), sym_type_name(type)); -} - -struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) -{ - struct property *prop = prop_alloc(type, current_entry->sym); - - prop->menu = current_entry; - prop->text = prompt; - prop->expr = expr; - prop->visible.expr = menu_check_dep(dep); - - if (prompt) { - if (current_entry->prompt) - menu_warn(current_entry, "prompt redefined\n"); - current_entry->prompt = prop; - } - - return prop; -} - -void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) -{ - menu_add_prop(type, prompt, NULL, dep); -} - -void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) -{ - menu_add_prop(type, NULL, expr, dep); -} - -void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) -{ - menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); -} - -void sym_check_prop(struct symbol *sym) -{ - struct property *prop; - struct symbol *sym2; - for (prop = sym->prop; prop; prop = prop->next) { - switch (prop->type) { - case P_DEFAULT: - if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && - prop->expr->type != E_SYMBOL) - prop_warn(prop, - "default for config symbol '%'" - " must be a single symbol", sym->name); - break; - case P_SELECT: - sym2 = prop_get_symbol(prop); - if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) - prop_warn(prop, - "config symbol '%s' uses select, but is " - "not boolean or tristate", sym->name); - else if (sym2->type == S_UNKNOWN) - prop_warn(prop, - "'select' used by config symbol '%s' " - "refer to undefined symbol '%s'", - sym->name, sym2->name); - else if (sym2->type != S_BOOLEAN && sym2->type != S_TRISTATE) - prop_warn(prop, - "'%s' has wrong type. 'select' only " - "accept arguments of boolean and " - "tristate type", sym2->name); - break; - case P_RANGE: - if (sym->type != S_INT && sym->type != S_HEX) - prop_warn(prop, "range is only allowed " - "for int or hex symbols"); - if (!sym_string_valid(sym, prop->expr->left.sym->name) || - !sym_string_valid(sym, prop->expr->right.sym->name)) - prop_warn(prop, "range is invalid"); - break; - default: - ; - } - } -} - -void menu_finalize(struct menu *parent) -{ - struct menu *menu, *last_menu; - struct symbol *sym; - struct property *prop; - struct expr *parentdep, *basedep, *dep, *dep2, **ep; - - sym = parent->sym; - if (parent->list) { - if (sym && sym_is_choice(sym)) { - /* find the first choice value and find out choice type */ - for (menu = parent->list; menu; menu = menu->next) { - if (menu->sym) { - current_entry = parent; - menu_set_type(menu->sym->type); - current_entry = menu; - menu_set_type(sym->type); - break; - } - } - parentdep = expr_alloc_symbol(sym); - } else if (parent->prompt) - parentdep = parent->prompt->visible.expr; - else - parentdep = parent->dep; - - for (menu = parent->list; menu; menu = menu->next) { - basedep = expr_transform(menu->dep); - basedep = expr_alloc_and(expr_copy(parentdep), basedep); - basedep = expr_eliminate_dups(basedep); - menu->dep = basedep; - if (menu->sym) - prop = menu->sym->prop; - else - prop = menu->prompt; - for (; prop; prop = prop->next) { - if (prop->menu != menu) - continue; - dep = expr_transform(prop->visible.expr); - dep = expr_alloc_and(expr_copy(basedep), dep); - dep = expr_eliminate_dups(dep); - if (menu->sym && menu->sym->type != S_TRISTATE) - dep = expr_trans_bool(dep); - prop->visible.expr = dep; - if (prop->type == P_SELECT) { - struct symbol *es = prop_get_symbol(prop); - es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, - expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); - } - } - } - for (menu = parent->list; menu; menu = menu->next) - menu_finalize(menu); - } else if (sym) { - basedep = parent->prompt ? parent->prompt->visible.expr : NULL; - basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); - basedep = expr_eliminate_dups(expr_transform(basedep)); - last_menu = NULL; - for (menu = parent->next; menu; menu = menu->next) { - dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; - if (!expr_contains_symbol(dep, sym)) - break; - if (expr_depends_symbol(dep, sym)) - goto next; - dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); - dep = expr_eliminate_dups(expr_transform(dep)); - dep2 = expr_copy(basedep); - expr_eliminate_eq(&dep, &dep2); - expr_free(dep); - if (!expr_is_yes(dep2)) { - expr_free(dep2); - break; - } - expr_free(dep2); - next: - menu_finalize(menu); - menu->parent = parent; - last_menu = menu; - } - if (last_menu) { - parent->list = parent->next; - parent->next = last_menu->next; - last_menu->next = NULL; - } - } - for (menu = parent->list; menu; menu = menu->next) { - if (sym && sym_is_choice(sym) && menu->sym) { - menu->sym->flags |= SYMBOL_CHOICEVAL; - if (!menu->prompt) - menu_warn(menu, "choice value must have a prompt"); - for (prop = menu->sym->prop; prop; prop = prop->next) { - if (prop->type == P_PROMPT && prop->menu != menu) { - prop_warn(prop, "choice values " - "currently only support a " - "single prompt"); - } - if (prop->type == P_DEFAULT) - prop_warn(prop, "defaults for choice " - "values not supported"); - } - current_entry = menu; - menu_set_type(sym->type); - menu_add_symbol(P_CHOICE, sym, NULL); - prop = sym_get_choice_prop(sym); - for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr) - ; - *ep = expr_alloc_one(E_CHOICE, NULL); - (*ep)->right.sym = menu->sym; - } - if (menu->list && (!menu->prompt || !menu->prompt->text)) { - for (last_menu = menu->list; ; last_menu = last_menu->next) { - last_menu->parent = parent; - if (!last_menu->next) - break; - } - last_menu->next = menu->next; - menu->next = menu->list; - menu->list = NULL; - } - } - - if (sym && !(sym->flags & SYMBOL_WARNED)) { - if (sym->type == S_UNKNOWN) - menu_warn(parent, "config symbol defined " - "without type\n"); - - if (sym_is_choice(sym) && !parent->prompt) - menu_warn(parent, "choice must have a prompt\n"); - - /* Check properties connected to this symbol */ - sym_check_prop(sym); - sym->flags |= SYMBOL_WARNED; - } - - if (sym && !sym_is_optional(sym) && parent->prompt) { - sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, - expr_alloc_and(parent->prompt->visible.expr, - expr_alloc_symbol(&symbol_mod))); - } -} - -bool menu_is_visible(struct menu *menu) -{ - struct menu *child; - struct symbol *sym; - tristate visible; - - if (!menu->prompt) - return false; - sym = menu->sym; - if (sym) { - sym_calc_value(sym); - visible = menu->prompt->visible.tri; - } else - visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); - - if (visible != no) - return true; - if (!sym || sym_get_tristate_value(menu->sym) == no) - return false; - - for (child = menu->list; child; child = child->next) - if (menu_is_visible(child)) - return true; - return false; -} - -const char *menu_get_prompt(struct menu *menu) -{ - if (menu->prompt) - return menu->prompt->text; - else if (menu->sym) - return menu->sym->name; - return NULL; -} - -struct menu *menu_get_root_menu(struct menu *menu) -{ - return &rootmenu; -} - -struct menu *menu_get_parent_menu(struct menu *menu) -{ - enum prop_type type; - - for (; menu != &rootmenu; menu = menu->parent) { - type = menu->prompt ? menu->prompt->type : 0; - if (type == P_MENU) - break; - } - return menu; -} - diff --git a/user/mpy/lib/axtls/config/scripts/config/mkconfigs b/user/mpy/lib/axtls/config/scripts/config/mkconfigs deleted file mode 100755 index 3cb7bb1..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/mkconfigs +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2002 Khalid Aziz -# Copyright (C) 2002 Randy Dunlap -# Copyright (C) 2002 Al Stone -# Copyright (C) 2002 Hewlett-Packard Company -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# Busybox version by Matteo Croce <3297627799 at wind.it> -# -# Rules to generate bbconfig.h from .config: -# - Retain lines that begin with "CONFIG_" -# - Retain lines that begin with "# CONFIG_" -# - lines that use double-quotes must \\-escape-quote them - -if [ $# -lt 1 ] -then - config=.config -else config=$1 -fi - -echo "#ifndef _BBCONFIG_H" -echo "#define _BBCONFIG_H" -echo \ -"/* - * busybox configuration options. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * - * This file is generated automatically by scripts/config/mkconfigs. - * Do not edit. - * - */" - -echo "static char const bbconfig_config[] =" -echo "\"CONFIG_BEGIN=n\\n\\" -echo "`sed 's/\"/\\\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{ print $0 "\\\\n\\\\" }' `" -echo "CONFIG_END=n\\n\";" -echo "#endif /* _BBCONFIG_H */" diff --git a/user/mpy/lib/axtls/config/scripts/config/symbol.c b/user/mpy/lib/axtls/config/scripts/config/symbol.c deleted file mode 100644 index ea62972..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/symbol.c +++ /dev/null @@ -1,809 +0,0 @@ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -struct symbol symbol_yes = { - .name = "y", - .curr = { "y", yes }, - .flags = SYMBOL_YES|SYMBOL_VALID, -}, symbol_mod = { - .name = "m", - .curr = { "m", mod }, - .flags = SYMBOL_MOD|SYMBOL_VALID, -}, symbol_no = { - .name = "n", - .curr = { "n", no }, - .flags = SYMBOL_NO|SYMBOL_VALID, -}, symbol_empty = { - .name = "", - .curr = { "", no }, - .flags = SYMBOL_VALID, -}; - -int sym_change_count; -struct symbol *modules_sym; -tristate modules_val; - -void sym_add_default(struct symbol *sym, const char *def) -{ - struct property *prop = prop_alloc(P_DEFAULT, sym); - - prop->expr = expr_alloc_symbol(sym_lookup(def, 1)); -} - -void sym_init(void) -{ - struct symbol *sym; - char *p; - static bool inited = false; - - if (inited) - return; - inited = true; - - sym = sym_lookup("VERSION", 0); - sym->type = S_STRING; - sym->flags |= SYMBOL_AUTO; - p = getenv("VERSION"); - if (p) - sym_add_default(sym, p); - - sym = sym_lookup("TARGET_ARCH", 0); - sym->type = S_STRING; - sym->flags |= SYMBOL_AUTO; - p = getenv("TARGET_ARCH"); - if (p) - sym_add_default(sym, p); - -} - -enum symbol_type sym_get_type(struct symbol *sym) -{ - enum symbol_type type = sym->type; - - if (type == S_TRISTATE) { - if (sym_is_choice_value(sym) && sym->visible == yes) - type = S_BOOLEAN; - else if (modules_val == no) - type = S_BOOLEAN; - } - return type; -} - -const char *sym_type_name(enum symbol_type type) -{ - switch (type) { - case S_BOOLEAN: - return "boolean"; - case S_TRISTATE: - return "tristate"; - case S_INT: - return "integer"; - case S_HEX: - return "hex"; - case S_STRING: - return "string"; - case S_UNKNOWN: - return "unknown"; - case S_OTHER: - break; - } - return "???"; -} - -struct property *sym_get_choice_prop(struct symbol *sym) -{ - struct property *prop; - - for_all_choices(sym, prop) - return prop; - return NULL; -} - -struct property *sym_get_default_prop(struct symbol *sym) -{ - struct property *prop; - - for_all_defaults(sym, prop) { - prop->visible.tri = expr_calc_value(prop->visible.expr); - if (prop->visible.tri != no) - return prop; - } - return NULL; -} - -struct property *sym_get_range_prop(struct symbol *sym) -{ - struct property *prop; - - for_all_properties(sym, prop, P_RANGE) { - prop->visible.tri = expr_calc_value(prop->visible.expr); - if (prop->visible.tri != no) - return prop; - } - return NULL; -} - -static void sym_calc_visibility(struct symbol *sym) -{ - struct property *prop; - tristate tri; - - /* any prompt visible? */ - tri = no; - for_all_prompts(sym, prop) { - prop->visible.tri = expr_calc_value(prop->visible.expr); - tri = E_OR(tri, prop->visible.tri); - } - if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) - tri = yes; - if (sym->visible != tri) { - sym->visible = tri; - sym_set_changed(sym); - } - if (sym_is_choice_value(sym)) - return; - tri = no; - if (sym->rev_dep.expr) - tri = expr_calc_value(sym->rev_dep.expr); - if (tri == mod && sym_get_type(sym) == S_BOOLEAN) - tri = yes; - if (sym->rev_dep.tri != tri) { - sym->rev_dep.tri = tri; - sym_set_changed(sym); - } -} - -static struct symbol *sym_calc_choice(struct symbol *sym) -{ - struct symbol *def_sym; - struct property *prop; - struct expr *e; - - /* is the user choice visible? */ - def_sym = sym->user.val; - if (def_sym) { - sym_calc_visibility(def_sym); - if (def_sym->visible != no) - return def_sym; - } - - /* any of the defaults visible? */ - for_all_defaults(sym, prop) { - prop->visible.tri = expr_calc_value(prop->visible.expr); - if (prop->visible.tri == no) - continue; - def_sym = prop_get_symbol(prop); - sym_calc_visibility(def_sym); - if (def_sym->visible != no) - return def_sym; - } - - /* just get the first visible value */ - prop = sym_get_choice_prop(sym); - for (e = prop->expr; e; e = e->left.expr) { - def_sym = e->right.sym; - sym_calc_visibility(def_sym); - if (def_sym->visible != no) - return def_sym; - } - - /* no choice? reset tristate value */ - sym->curr.tri = no; - return NULL; -} - -void sym_calc_value(struct symbol *sym) -{ - struct symbol_value newval, oldval; - struct property *prop; - struct expr *e; - - if (!sym) - return; - - if (sym->flags & SYMBOL_VALID) - return; - sym->flags |= SYMBOL_VALID; - - oldval = sym->curr; - - switch (sym->type) { - case S_INT: - case S_HEX: - case S_STRING: - newval = symbol_empty.curr; - break; - case S_BOOLEAN: - case S_TRISTATE: - newval = symbol_no.curr; - break; - default: - sym->curr.val = sym->name; - sym->curr.tri = no; - return; - } - if (!sym_is_choice_value(sym)) - sym->flags &= ~SYMBOL_WRITE; - - sym_calc_visibility(sym); - - /* set default if recursively called */ - sym->curr = newval; - - switch (sym_get_type(sym)) { - case S_BOOLEAN: - case S_TRISTATE: - if (sym_is_choice_value(sym) && sym->visible == yes) { - prop = sym_get_choice_prop(sym); - newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; - } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) { - sym->flags |= SYMBOL_WRITE; - if (sym_has_value(sym)) - newval.tri = sym->user.tri; - else if (!sym_is_choice(sym)) { - prop = sym_get_default_prop(sym); - if (prop) - newval.tri = expr_calc_value(prop->expr); - } - newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri); - } else if (!sym_is_choice(sym)) { - prop = sym_get_default_prop(sym); - if (prop) { - sym->flags |= SYMBOL_WRITE; - newval.tri = expr_calc_value(prop->expr); - } - } - if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) - newval.tri = yes; - break; - case S_STRING: - case S_HEX: - case S_INT: - if (sym->visible != no) { - sym->flags |= SYMBOL_WRITE; - if (sym_has_value(sym)) { - newval.val = sym->user.val; - break; - } - } - prop = sym_get_default_prop(sym); - if (prop) { - struct symbol *ds = prop_get_symbol(prop); - if (ds) { - sym->flags |= SYMBOL_WRITE; - sym_calc_value(ds); - newval.val = ds->curr.val; - } - } - break; - default: - ; - } - - sym->curr = newval; - if (sym_is_choice(sym) && newval.tri == yes) - sym->curr.val = sym_calc_choice(sym); - - if (memcmp(&oldval, &sym->curr, sizeof(oldval))) - sym_set_changed(sym); - if (modules_sym == sym) - modules_val = modules_sym->curr.tri; - - if (sym_is_choice(sym)) { - int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); - prop = sym_get_choice_prop(sym); - for (e = prop->expr; e; e = e->left.expr) { - e->right.sym->flags |= flags; - if (flags & SYMBOL_CHANGED) - sym_set_changed(e->right.sym); - } - } -} - -void sym_clear_all_valid(void) -{ - struct symbol *sym; - int i; - - for_all_symbols(i, sym) - sym->flags &= ~SYMBOL_VALID; - sym_change_count++; - if (modules_sym) - sym_calc_value(modules_sym); -} - -void sym_set_changed(struct symbol *sym) -{ - struct property *prop; - - sym->flags |= SYMBOL_CHANGED; - for (prop = sym->prop; prop; prop = prop->next) { - if (prop->menu) - prop->menu->flags |= MENU_CHANGED; - } -} - -void sym_set_all_changed(void) -{ - struct symbol *sym; - int i; - - for_all_symbols(i, sym) - sym_set_changed(sym); -} - -bool sym_tristate_within_range(struct symbol *sym, tristate val) -{ - int type = sym_get_type(sym); - - if (sym->visible == no) - return false; - - if (type != S_BOOLEAN && type != S_TRISTATE) - return false; - - if (type == S_BOOLEAN && val == mod) - return false; - if (sym->visible <= sym->rev_dep.tri) - return false; - if (sym_is_choice_value(sym) && sym->visible == yes) - return val == yes; - return val >= sym->rev_dep.tri && val <= sym->visible; -} - -bool sym_set_tristate_value(struct symbol *sym, tristate val) -{ - tristate oldval = sym_get_tristate_value(sym); - - if (oldval != val && !sym_tristate_within_range(sym, val)) - return false; - - if (sym->flags & SYMBOL_NEW) { - sym->flags &= ~SYMBOL_NEW; - sym_set_changed(sym); - } - if (sym_is_choice_value(sym) && val == yes) { - struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); - - cs->user.val = sym; - cs->flags &= ~SYMBOL_NEW; - } - - sym->user.tri = val; - if (oldval != val) { - sym_clear_all_valid(); - if (sym == modules_sym) - sym_set_all_changed(); - } - - return true; -} - -tristate sym_toggle_tristate_value(struct symbol *sym) -{ - tristate oldval, newval; - - oldval = newval = sym_get_tristate_value(sym); - do { - switch (newval) { - case no: - newval = mod; - break; - case mod: - newval = yes; - break; - case yes: - newval = no; - break; - } - if (sym_set_tristate_value(sym, newval)) - break; - } while (oldval != newval); - return newval; -} - -bool sym_string_valid(struct symbol *sym, const char *str) -{ - signed char ch; - - switch (sym->type) { - case S_STRING: - return true; - case S_INT: - ch = *str++; - if (ch == '-') - ch = *str++; - if (!isdigit(ch)) - return false; - if (ch == '0' && *str != 0) - return false; - while ((ch = *str++)) { - if (!isdigit(ch)) - return false; - } - return true; - case S_HEX: - if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) - str += 2; - ch = *str++; - do { - if (!isxdigit(ch)) - return false; - } while ((ch = *str++)); - return true; - case S_BOOLEAN: - case S_TRISTATE: - switch (str[0]) { - case 'y': case 'Y': - case 'm': case 'M': - case 'n': case 'N': - return true; - } - return false; - default: - return false; - } -} - -bool sym_string_within_range(struct symbol *sym, const char *str) -{ - struct property *prop; - int val; - - switch (sym->type) { - case S_STRING: - return sym_string_valid(sym, str); - case S_INT: - if (!sym_string_valid(sym, str)) - return false; - prop = sym_get_range_prop(sym); - if (!prop) - return true; - val = strtol(str, NULL, 10); - return val >= strtol(prop->expr->left.sym->name, NULL, 10) && - val <= strtol(prop->expr->right.sym->name, NULL, 10); - case S_HEX: - if (!sym_string_valid(sym, str)) - return false; - prop = sym_get_range_prop(sym); - if (!prop) - return true; - val = strtol(str, NULL, 16); - return val >= strtol(prop->expr->left.sym->name, NULL, 16) && - val <= strtol(prop->expr->right.sym->name, NULL, 16); - case S_BOOLEAN: - case S_TRISTATE: - switch (str[0]) { - case 'y': case 'Y': - return sym_tristate_within_range(sym, yes); - case 'm': case 'M': - return sym_tristate_within_range(sym, mod); - case 'n': case 'N': - return sym_tristate_within_range(sym, no); - } - return false; - default: - return false; - } -} - -bool sym_set_string_value(struct symbol *sym, const char *newval) -{ - const char *oldval; - char *val; - int size; - - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - switch (newval[0]) { - case 'y': case 'Y': - return sym_set_tristate_value(sym, yes); - case 'm': case 'M': - return sym_set_tristate_value(sym, mod); - case 'n': case 'N': - return sym_set_tristate_value(sym, no); - } - return false; - default: - ; - } - - if (!sym_string_within_range(sym, newval)) - return false; - - if (sym->flags & SYMBOL_NEW) { - sym->flags &= ~SYMBOL_NEW; - sym_set_changed(sym); - } - - oldval = sym->user.val; - size = strlen(newval) + 1; - if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { - size += 2; - sym->user.val = val = malloc(size); - *val++ = '0'; - *val++ = 'x'; - } else if (!oldval || strcmp(oldval, newval)) - sym->user.val = val = malloc(size); - else - return true; - - strcpy(val, newval); - free((void *)oldval); - sym_clear_all_valid(); - - return true; -} - -const char *sym_get_string_value(struct symbol *sym) -{ - tristate val; - - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - val = sym_get_tristate_value(sym); - switch (val) { - case no: - return "n"; - case mod: - return "m"; - case yes: - return "y"; - } - break; - default: - ; - } - return (const char *)sym->curr.val; -} - -bool sym_is_changable(struct symbol *sym) -{ - return sym->visible > sym->rev_dep.tri; -} - -struct symbol *sym_lookup(const char *name, int isconst) -{ - struct symbol *symbol; - const char *ptr; - char *new_name; - int hash = 0; - - if (name) { - if (name[0] && !name[1]) { - switch (name[0]) { - case 'y': return &symbol_yes; - case 'm': return &symbol_mod; - case 'n': return &symbol_no; - } - } - for (ptr = name; *ptr; ptr++) - hash += *ptr; - hash &= 0xff; - - for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { - if (!strcmp(symbol->name, name)) { - if ((isconst && symbol->flags & SYMBOL_CONST) || - (!isconst && !(symbol->flags & SYMBOL_CONST))) - return symbol; - } - } - new_name = strdup(name); - } else { - new_name = NULL; - hash = 256; - } - - symbol = malloc(sizeof(*symbol)); - memset(symbol, 0, sizeof(*symbol)); - symbol->name = new_name; - symbol->type = S_UNKNOWN; - symbol->flags = SYMBOL_NEW; - if (isconst) - symbol->flags |= SYMBOL_CONST; - - symbol->next = symbol_hash[hash]; - symbol_hash[hash] = symbol; - - return symbol; -} - -struct symbol *sym_find(const char *name) -{ - struct symbol *symbol = NULL; - const char *ptr; - int hash = 0; - - if (!name) - return NULL; - - if (name[0] && !name[1]) { - switch (name[0]) { - case 'y': return &symbol_yes; - case 'm': return &symbol_mod; - case 'n': return &symbol_no; - } - } - for (ptr = name; *ptr; ptr++) - hash += *ptr; - hash &= 0xff; - - for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { - if (!strcmp(symbol->name, name) && - !(symbol->flags & SYMBOL_CONST)) - break; - } - - return symbol; -} - -struct symbol **sym_re_search(const char *pattern) -{ - struct symbol *sym, **sym_arr = NULL; - int i, cnt, size; - regex_t re; - - cnt = size = 0; - /* Skip if empty */ - if (strlen(pattern) == 0) - return NULL; - if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) - return NULL; - - for_all_symbols(i, sym) { - if (sym->flags & SYMBOL_CONST || !sym->name) - continue; - if (regexec(&re, sym->name, 0, NULL, 0)) - continue; - if (cnt + 1 >= size) { - void *tmp = sym_arr; - size += 16; - sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); - if (!sym_arr) { - free(tmp); - return NULL; - } - } - sym_arr[cnt++] = sym; - } - if (sym_arr) - sym_arr[cnt] = NULL; - regfree(&re); - - return sym_arr; -} - - -struct symbol *sym_check_deps(struct symbol *sym); - -static struct symbol *sym_check_expr_deps(struct expr *e) -{ - struct symbol *sym; - - if (!e) - return NULL; - switch (e->type) { - case E_OR: - case E_AND: - sym = sym_check_expr_deps(e->left.expr); - if (sym) - return sym; - return sym_check_expr_deps(e->right.expr); - case E_NOT: - return sym_check_expr_deps(e->left.expr); - case E_EQUAL: - case E_UNEQUAL: - sym = sym_check_deps(e->left.sym); - if (sym) - return sym; - return sym_check_deps(e->right.sym); - case E_SYMBOL: - return sym_check_deps(e->left.sym); - default: - break; - } - printf("Oops! How to check %d?\n", e->type); - return NULL; -} - -struct symbol *sym_check_deps(struct symbol *sym) -{ - struct symbol *sym2; - struct property *prop; - - if (sym->flags & SYMBOL_CHECK_DONE) - return NULL; - if (sym->flags & SYMBOL_CHECK) { - printf("Warning! Found recursive dependency: %s", sym->name); - return sym; - } - - sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); - sym2 = sym_check_expr_deps(sym->rev_dep.expr); - if (sym2) - goto out; - - for (prop = sym->prop; prop; prop = prop->next) { - if (prop->type == P_CHOICE || prop->type == P_SELECT) - continue; - sym2 = sym_check_expr_deps(prop->visible.expr); - if (sym2) - goto out; - if (prop->type != P_DEFAULT || sym_is_choice(sym)) - continue; - sym2 = sym_check_expr_deps(prop->expr); - if (sym2) - goto out; - } -out: - if (sym2) - printf(" %s", sym->name); - sym->flags &= ~SYMBOL_CHECK; - return sym2; -} - -struct property *prop_alloc(enum prop_type type, struct symbol *sym) -{ - struct property *prop; - struct property **propp; - - prop = malloc(sizeof(*prop)); - memset(prop, 0, sizeof(*prop)); - prop->type = type; - prop->sym = sym; - prop->file = current_file; - prop->lineno = zconf_lineno(); - - /* append property to the prop list of symbol */ - if (sym) { - for (propp = &sym->prop; *propp; propp = &(*propp)->next) - ; - *propp = prop; - } - - return prop; -} - -struct symbol *prop_get_symbol(struct property *prop) -{ - if (prop->expr && (prop->expr->type == E_SYMBOL || - prop->expr->type == E_CHOICE)) - return prop->expr->left.sym; - return NULL; -} - -const char *prop_get_type_name(enum prop_type type) -{ - switch (type) { - case P_PROMPT: - return "prompt"; - case P_COMMENT: - return "comment"; - case P_MENU: - return "menu"; - case P_DEFAULT: - return "default"; - case P_CHOICE: - return "choice"; - case P_SELECT: - return "select"; - case P_RANGE: - return "range"; - case P_UNKNOWN: - break; - } - return "unknown"; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/util.c b/user/mpy/lib/axtls/config/scripts/config/util.c deleted file mode 100644 index 8fc95a2..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/util.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2002-2005 Roman Zippel - * Copyright (C) 2002-2005 Sam Ravnborg - * - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include "lkc.h" - -/* file already present in list? If not add it */ -struct file *file_lookup(const char *name) -{ - struct file *file; - - for (file = file_list; file; file = file->next) { - if (!strcmp(name, file->name)) - return file; - } - - file = malloc(sizeof(*file)); - memset(file, 0, sizeof(*file)); - file->name = strdup(name); - file->next = file_list; - file_list = file; - return file; -} - -/* write a dependency file as used by kbuild to track dependencies */ -int file_write_dep(const char *name) -{ - struct file *file; - FILE *out; - - if (!name) - name = "config/.config.cmd"; - out = fopen("config/.config.tmp", "w"); - if (!out) - return 1; - fprintf(out, "deps_config := \\\n"); - for (file = file_list; file; file = file->next) { - if (file->next) - fprintf(out, "\t%s \\\n", file->name); - else - fprintf(out, "\t%s\n", file->name); - } - fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); - fclose(out); - rename(".config.tmp", name); - return 0; -} - - -/* Allocate initial growable sting */ -struct gstr str_new(void) -{ - struct gstr gs; - gs.s = malloc(sizeof(char) * 64); - gs.len = 16; - strcpy(gs.s, "\0"); - return gs; -} - -/* Allocate and assign growable string */ -struct gstr str_assign(const char *s) -{ - struct gstr gs; - gs.s = strdup(s); - gs.len = strlen(s) + 1; - return gs; -} - -/* Free storage for growable string */ -void str_free(struct gstr *gs) -{ - if (gs->s) - free(gs->s); - gs->s = NULL; - gs->len = 0; -} - -/* Append to growable string */ -void str_append(struct gstr *gs, const char *s) -{ - size_t l = strlen(gs->s) + strlen(s) + 1; - if (l > gs->len) { - gs->s = realloc(gs->s, l); - gs->len = l; - } - strcat(gs->s, s); -} - -/* Append printf formatted string to growable string */ -void str_printf(struct gstr *gs, const char *fmt, ...) -{ - va_list ap; - char s[10000]; /* big enough... */ - va_start(ap, fmt); - vsnprintf(s, sizeof(s), fmt, ap); - str_append(gs, s); - va_end(ap); -} - -/* Retreive value of growable string */ -const char *str_get(struct gstr *gs) -{ - return gs->s; -} - diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.l b/user/mpy/lib/axtls/config/scripts/config/zconf.l deleted file mode 100644 index 55517b2..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/zconf.l +++ /dev/null @@ -1,366 +0,0 @@ -%option backup nostdinit noyywrap never-interactive full ecs -%option 8bit backup nodefault perf-report perf-report -%x COMMAND HELP STRING PARAM -%{ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include - -#define LKC_DIRECT_LINK -#include "lkc.h" - -#define START_STRSIZE 16 - -char *text; -static char *text_ptr; -static int text_size, text_asize; - -struct buffer { - struct buffer *parent; - YY_BUFFER_STATE state; -}; - -struct buffer *current_buf; - -static int last_ts, first_ts; - -static void zconf_endhelp(void); -static struct buffer *zconf_endfile(void); - -void new_string(void) -{ - text = malloc(START_STRSIZE); - text_asize = START_STRSIZE; - text_ptr = text; - text_size = 0; - *text_ptr = 0; -} - -void append_string(const char *str, int size) -{ - int new_size = text_size + size + 1; - if (new_size > text_asize) { - text = realloc(text, new_size); - text_asize = new_size; - text_ptr = text + text_size; - } - memcpy(text_ptr, str, size); - text_ptr += size; - text_size += size; - *text_ptr = 0; -} - -void alloc_string(const char *str, int size) -{ - text = malloc(size + 1); - memcpy(text, str, size); - text[size] = 0; -} -%} - -ws [ \n\t] -n [A-Za-z0-9_] - -%% - int str = 0; - int ts, i; - -[ \t]*#.*\n current_file->lineno++; -[ \t]*#.* - -[ \t]*\n current_file->lineno++; return T_EOL; - -[ \t]+ { - BEGIN(COMMAND); -} - -. { - unput(yytext[0]); - BEGIN(COMMAND); -} - - -{ - "mainmenu" BEGIN(PARAM); return T_MAINMENU; - "menu" BEGIN(PARAM); return T_MENU; - "endmenu" BEGIN(PARAM); return T_ENDMENU; - "source" BEGIN(PARAM); return T_SOURCE; - "choice" BEGIN(PARAM); return T_CHOICE; - "endchoice" BEGIN(PARAM); return T_ENDCHOICE; - "comment" BEGIN(PARAM); return T_COMMENT; - "config" BEGIN(PARAM); return T_CONFIG; - "menuconfig" BEGIN(PARAM); return T_MENUCONFIG; - "help" BEGIN(PARAM); return T_HELP; - "if" BEGIN(PARAM); return T_IF; - "endif" BEGIN(PARAM); return T_ENDIF; - "depends" BEGIN(PARAM); return T_DEPENDS; - "requires" BEGIN(PARAM); return T_REQUIRES; - "optional" BEGIN(PARAM); return T_OPTIONAL; - "default" BEGIN(PARAM); return T_DEFAULT; - "prompt" BEGIN(PARAM); return T_PROMPT; - "tristate" BEGIN(PARAM); return T_TRISTATE; - "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE; - "bool" BEGIN(PARAM); return T_BOOLEAN; - "boolean" BEGIN(PARAM); return T_BOOLEAN; - "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN; - "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN; - "int" BEGIN(PARAM); return T_INT; - "hex" BEGIN(PARAM); return T_HEX; - "string" BEGIN(PARAM); return T_STRING; - "select" BEGIN(PARAM); return T_SELECT; - "enable" BEGIN(PARAM); return T_SELECT; - "range" BEGIN(PARAM); return T_RANGE; - {n}+ { - alloc_string(yytext, yyleng); - zconflval.string = text; - return T_WORD; - } - . - \n current_file->lineno++; BEGIN(INITIAL); -} - -{ - "&&" return T_AND; - "||" return T_OR; - "(" return T_OPEN_PAREN; - ")" return T_CLOSE_PAREN; - "!" return T_NOT; - "=" return T_EQUAL; - "!=" return T_UNEQUAL; - "if" return T_IF; - "on" return T_ON; - \"|\' { - str = yytext[0]; - new_string(); - BEGIN(STRING); - } - \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; - --- /* ignore */ - ({n}|[-/.])+ { - alloc_string(yytext, yyleng); - zconflval.string = text; - return T_WORD; - } - #.* /* comment */ - \\\n current_file->lineno++; - . - <> { - BEGIN(INITIAL); - } -} - -{ - [^'"\\\n]+/\n { - append_string(yytext, yyleng); - zconflval.string = text; - return T_WORD_QUOTE; - } - [^'"\\\n]+ { - append_string(yytext, yyleng); - } - \\.?/\n { - append_string(yytext + 1, yyleng - 1); - zconflval.string = text; - return T_WORD_QUOTE; - } - \\.? { - append_string(yytext + 1, yyleng - 1); - } - \'|\" { - if (str == yytext[0]) { - BEGIN(PARAM); - zconflval.string = text; - return T_WORD_QUOTE; - } else - append_string(yytext, 1); - } - \n { - printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); - current_file->lineno++; - BEGIN(INITIAL); - return T_EOL; - } - <> { - BEGIN(INITIAL); - } -} - -{ - [ \t]+ { - ts = 0; - for (i = 0; i < yyleng; i++) { - if (yytext[i] == '\t') - ts = (ts & ~7) + 8; - else - ts++; - } - last_ts = ts; - if (first_ts) { - if (ts < first_ts) { - zconf_endhelp(); - return T_HELPTEXT; - } - ts -= first_ts; - while (ts > 8) { - append_string(" ", 8); - ts -= 8; - } - append_string(" ", ts); - } - } - [ \t]*\n/[^ \t\n] { - current_file->lineno++; - zconf_endhelp(); - return T_HELPTEXT; - } - [ \t]*\n { - current_file->lineno++; - append_string("\n", 1); - } - [^ \t\n].* { - append_string(yytext, yyleng); - if (!first_ts) - first_ts = last_ts; - } - <> { - zconf_endhelp(); - return T_HELPTEXT; - } -} - -<> { - if (current_buf) { - zconf_endfile(); - return T_EOF; - } - fclose(yyin); - yyterminate(); -} - -%% -void zconf_starthelp(void) -{ - new_string(); - last_ts = first_ts = 0; - BEGIN(HELP); -} - -static void zconf_endhelp(void) -{ - zconflval.string = text; - BEGIN(INITIAL); -} - - -/* - * Try to open specified file with following names: - * ./name - * $(srctree)/name - * The latter is used when srctree is separate from objtree - * when compiling the kernel. - * Return NULL if file is not found. - */ -FILE *zconf_fopen(const char *name) -{ - char *env, fullname[PATH_MAX+1]; - FILE *f; - - f = fopen(name, "r"); - if (!f && name[0] != '/') { - env = getenv(SRCTREE); - if (env) { - sprintf(fullname, "%s/%s", env, name); - f = fopen(fullname, "r"); - } - } - return f; -} - -void zconf_initscan(const char *name) -{ - yyin = zconf_fopen(name); - if (!yyin) { - printf("can't find file %s\n", name); - exit(1); - } - - current_buf = malloc(sizeof(*current_buf)); - memset(current_buf, 0, sizeof(*current_buf)); - - current_file = file_lookup(name); - current_file->lineno = 1; - current_file->flags = FILE_BUSY; -} - -void zconf_nextfile(const char *name) -{ - struct file *file = file_lookup(name); - struct buffer *buf = malloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); - - current_buf->state = YY_CURRENT_BUFFER; - yyin = zconf_fopen(name); - if (!yyin) { - printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); - exit(1); - } - yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); - buf->parent = current_buf; - current_buf = buf; - - if (file->flags & FILE_BUSY) { - printf("recursive scan (%s)?\n", name); - exit(1); - } - if (file->flags & FILE_SCANNED) { - printf("file %s already scanned?\n", name); - exit(1); - } - file->flags |= FILE_BUSY; - file->lineno = 1; - file->parent = current_file; - current_file = file; -} - -static struct buffer *zconf_endfile(void) -{ - struct buffer *parent; - - current_file->flags |= FILE_SCANNED; - current_file->flags &= ~FILE_BUSY; - current_file = current_file->parent; - - parent = current_buf->parent; - if (parent) { - fclose(yyin); - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer(parent->state); - } - free(current_buf); - current_buf = parent; - - return parent; -} - -int zconf_lineno(void) -{ - if (current_buf) - return current_file->lineno - 1; - else - return 0; -} - -char *zconf_curname(void) -{ - if (current_buf) - return current_file->name; - else - return ""; -} diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped b/user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped deleted file mode 100644 index cc68dcb..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/zconf.tab.c_shipped +++ /dev/null @@ -1,2130 +0,0 @@ -/* A Bison parser, made by GNU Bison 1.875a. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ -#define yyparse zconfparse -#define yylex zconflex -#define yyerror zconferror -#define yylval zconflval -#define yychar zconfchar -#define yydebug zconfdebug -#define yynerrs zconfnerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_MAINMENU = 258, - T_MENU = 259, - T_ENDMENU = 260, - T_SOURCE = 261, - T_CHOICE = 262, - T_ENDCHOICE = 263, - T_COMMENT = 264, - T_CONFIG = 265, - T_MENUCONFIG = 266, - T_HELP = 267, - T_HELPTEXT = 268, - T_IF = 269, - T_ENDIF = 270, - T_DEPENDS = 271, - T_REQUIRES = 272, - T_OPTIONAL = 273, - T_PROMPT = 274, - T_DEFAULT = 275, - T_TRISTATE = 276, - T_DEF_TRISTATE = 277, - T_BOOLEAN = 278, - T_DEF_BOOLEAN = 279, - T_STRING = 280, - T_INT = 281, - T_HEX = 282, - T_WORD = 283, - T_WORD_QUOTE = 284, - T_UNEQUAL = 285, - T_EOF = 286, - T_EOL = 287, - T_CLOSE_PAREN = 288, - T_OPEN_PAREN = 289, - T_ON = 290, - T_SELECT = 291, - T_RANGE = 292, - T_OR = 293, - T_AND = 294, - T_EQUAL = 295, - T_NOT = 296 - }; -#endif -#define T_MAINMENU 258 -#define T_MENU 259 -#define T_ENDMENU 260 -#define T_SOURCE 261 -#define T_CHOICE 262 -#define T_ENDCHOICE 263 -#define T_COMMENT 264 -#define T_CONFIG 265 -#define T_MENUCONFIG 266 -#define T_HELP 267 -#define T_HELPTEXT 268 -#define T_IF 269 -#define T_ENDIF 270 -#define T_DEPENDS 271 -#define T_REQUIRES 272 -#define T_OPTIONAL 273 -#define T_PROMPT 274 -#define T_DEFAULT 275 -#define T_TRISTATE 276 -#define T_DEF_TRISTATE 277 -#define T_BOOLEAN 278 -#define T_DEF_BOOLEAN 279 -#define T_STRING 280 -#define T_INT 281 -#define T_HEX 282 -#define T_WORD 283 -#define T_WORD_QUOTE 284 -#define T_UNEQUAL 285 -#define T_EOF 286 -#define T_EOL 287 -#define T_CLOSE_PAREN 288 -#define T_OPEN_PAREN 289 -#define T_ON 290 -#define T_SELECT 291 -#define T_RANGE 292 -#define T_OR 293 -#define T_AND 294 -#define T_EQUAL 295 -#define T_NOT 296 - - - - -/* Copy the first part of user declarations. */ - - -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include -#include - -#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) - -#define PRINTD 0x0001 -#define DEBUG_PARSE 0x0002 - -int cdebug = PRINTD; - -extern int zconflex(void); -static void zconfprint(const char *err, ...); -static void zconferror(const char *err); -static bool zconf_endtoken(int token, int starttoken, int endtoken); - -struct symbol *symbol_hash[257]; - -static struct menu *current_menu, *current_entry; - -#define YYERROR_VERBOSE - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) - -typedef union YYSTYPE { - int token; - char *string; - struct symbol *symbol; - struct expr *expr; - struct menu *menu; -} YYSTYPE; -/* Line 191 of yacc.c. */ - -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -#define LKC_DIRECT_LINK -#include "lkc.h" - - -/* Line 214 of yacc.c. */ - - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || (defined (_ALLOCA_H) && defined (__GNUC__)) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 2 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 201 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 42 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 41 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 104 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 182 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 296 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short yyprhs[] = -{ - 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, - 21, 23, 26, 28, 30, 32, 34, 36, 38, 42, - 45, 49, 52, 53, 56, 59, 62, 65, 69, 74, - 78, 83, 87, 91, 95, 100, 105, 110, 116, 119, - 122, 124, 128, 131, 132, 135, 138, 141, 144, 149, - 153, 157, 160, 165, 166, 169, 173, 175, 179, 182, - 183, 186, 189, 192, 196, 199, 201, 205, 208, 209, - 212, 215, 218, 222, 226, 228, 232, 235, 238, 241, - 242, 245, 248, 253, 257, 261, 262, 265, 267, 269, - 272, 275, 278, 280, 282, 283, 286, 288, 292, 296, - 300, 303, 307, 311, 313 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 43, 0, -1, -1, 43, 44, -1, 45, -1, 55, - -1, 66, -1, 3, 77, 79, -1, 5, -1, 15, - -1, 8, -1, 1, 79, -1, 61, -1, 71, -1, - 47, -1, 49, -1, 69, -1, 79, -1, 10, 28, - 32, -1, 46, 50, -1, 11, 28, 32, -1, 48, - 50, -1, -1, 50, 51, -1, 50, 75, -1, 50, - 73, -1, 50, 32, -1, 21, 76, 32, -1, 22, - 81, 80, 32, -1, 23, 76, 32, -1, 24, 81, - 80, 32, -1, 26, 76, 32, -1, 27, 76, 32, - -1, 25, 76, 32, -1, 19, 77, 80, 32, -1, - 20, 81, 80, 32, -1, 36, 28, 80, 32, -1, - 37, 82, 82, 80, 32, -1, 7, 32, -1, 52, - 56, -1, 78, -1, 53, 58, 54, -1, 53, 58, - -1, -1, 56, 57, -1, 56, 75, -1, 56, 73, - -1, 56, 32, -1, 19, 77, 80, 32, -1, 21, - 76, 32, -1, 23, 76, 32, -1, 18, 32, -1, - 20, 28, 80, 32, -1, -1, 58, 45, -1, 14, - 81, 32, -1, 78, -1, 59, 62, 60, -1, 59, - 62, -1, -1, 62, 45, -1, 62, 66, -1, 62, - 55, -1, 4, 77, 32, -1, 63, 74, -1, 78, - -1, 64, 67, 65, -1, 64, 67, -1, -1, 67, - 45, -1, 67, 66, -1, 67, 55, -1, 67, 1, - 32, -1, 6, 77, 32, -1, 68, -1, 9, 77, - 32, -1, 70, 74, -1, 12, 32, -1, 72, 13, - -1, -1, 74, 75, -1, 74, 32, -1, 16, 35, - 81, 32, -1, 16, 81, 32, -1, 17, 81, 32, - -1, -1, 77, 80, -1, 28, -1, 29, -1, 5, - 79, -1, 8, 79, -1, 15, 79, -1, 32, -1, - 31, -1, -1, 14, 81, -1, 82, -1, 82, 40, - 82, -1, 82, 30, 82, -1, 34, 81, 33, -1, - 41, 81, -1, 81, 38, 81, -1, 81, 39, 81, - -1, 28, -1, 29, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = -{ - 0, 94, 94, 95, 98, 99, 100, 101, 102, 103, - 104, 105, 109, 110, 111, 112, 113, 114, 120, 128, - 134, 142, 152, 154, 155, 156, 157, 160, 166, 173, - 179, 186, 192, 198, 204, 210, 216, 222, 230, 239, - 245, 254, 255, 261, 263, 264, 265, 266, 269, 275, - 281, 287, 293, 299, 301, 306, 315, 324, 325, 331, - 333, 334, 335, 340, 347, 353, 362, 363, 369, 371, - 372, 373, 374, 377, 383, 390, 397, 404, 410, 417, - 418, 419, 422, 427, 432, 440, 442, 447, 448, 451, - 452, 453, 457, 457, 459, 460, 463, 464, 465, 466, - 467, 468, 469, 472, 473 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", - "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", - "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", - "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", - "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT", - "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL", - "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR", - "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block", - "common_block", "config_entry_start", "config_stmt", - "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", - "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", - "choice_option_list", "choice_option", "choice_block", "if", "if_end", - "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", - "menu_block", "source", "source_stmt", "comment", "comment_stmt", - "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", - "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, - 44, 44, 45, 45, 45, 45, 45, 45, 46, 47, - 48, 49, 50, 50, 50, 50, 50, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, - 54, 55, 55, 56, 56, 56, 56, 56, 57, 57, - 57, 57, 57, 58, 58, 59, 60, 61, 61, 62, - 62, 62, 62, 63, 64, 65, 66, 66, 67, 67, - 67, 67, 67, 68, 69, 70, 71, 72, 73, 74, - 74, 74, 75, 75, 75, 76, 76, 77, 77, 78, - 78, 78, 79, 79, 80, 80, 81, 81, 81, 81, - 81, 81, 81, 82, 82 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, - 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, - 3, 2, 0, 2, 2, 2, 2, 3, 4, 3, - 4, 3, 3, 3, 4, 4, 4, 5, 2, 2, - 1, 3, 2, 0, 2, 2, 2, 2, 4, 3, - 3, 2, 4, 0, 2, 3, 1, 3, 2, 0, - 2, 2, 2, 3, 2, 1, 3, 2, 0, 2, - 2, 2, 3, 3, 1, 3, 2, 2, 2, 0, - 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, - 2, 2, 1, 1, 0, 2, 1, 3, 3, 3, - 2, 3, 3, 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 2, 0, 1, 0, 0, 0, 8, 0, 0, 10, - 0, 0, 0, 0, 9, 93, 92, 3, 4, 22, - 14, 22, 15, 43, 53, 5, 59, 12, 79, 68, - 6, 74, 16, 79, 13, 17, 11, 87, 88, 0, - 0, 0, 38, 0, 0, 0, 103, 104, 0, 0, - 0, 96, 19, 21, 39, 42, 58, 64, 0, 76, - 7, 63, 73, 75, 18, 20, 0, 100, 55, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, - 85, 0, 85, 85, 85, 26, 0, 0, 23, 0, - 25, 24, 0, 0, 0, 85, 85, 47, 44, 46, - 45, 0, 0, 0, 54, 41, 40, 60, 62, 57, - 61, 56, 81, 80, 0, 69, 71, 66, 70, 65, - 99, 101, 102, 98, 97, 77, 0, 0, 0, 94, - 94, 0, 94, 94, 0, 94, 0, 0, 0, 94, - 0, 78, 51, 94, 94, 0, 0, 89, 90, 91, - 72, 0, 83, 84, 0, 0, 0, 27, 86, 0, - 29, 0, 33, 31, 32, 0, 94, 0, 0, 49, - 50, 82, 95, 34, 35, 28, 30, 36, 0, 48, - 52, 37 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const short yydefgoto[] = -{ - -1, 1, 17, 18, 19, 20, 21, 22, 52, 88, - 23, 24, 105, 25, 54, 98, 55, 26, 109, 27, - 56, 28, 29, 117, 30, 58, 31, 32, 33, 34, - 89, 90, 57, 91, 131, 132, 106, 35, 155, 50, - 51 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -99 -static const short yypact[] = -{ - -99, 48, -99, 38, 46, 46, -99, 46, -29, -99, - 46, -17, -3, -11, -99, -99, -99, -99, -99, -99, - -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, - -99, -99, -99, -99, -99, -99, -99, -99, -99, 38, - 12, 15, -99, 18, 51, 62, -99, -99, -11, -11, - 4, -24, 138, 138, 160, 121, 110, -4, 81, -4, - -99, -99, -99, -99, -99, -99, -19, -99, -99, -11, - -11, 70, 70, 73, 32, -11, 46, -11, 46, -11, - 46, -11, 46, 46, 46, -99, 36, 70, -99, 95, - -99, -99, 96, 46, 106, 46, 46, -99, -99, -99, - -99, 38, 38, 38, -99, -99, -99, -99, -99, -99, - -99, -99, -99, -99, 112, -99, -99, -99, -99, -99, - -99, 117, -99, -99, -99, -99, -11, 33, 65, 131, - 1, 119, 131, 1, 136, 1, 153, 154, 155, 131, - 70, -99, -99, 131, 131, 156, 157, -99, -99, -99, - -99, 101, -99, -99, -11, 158, 159, -99, -99, 161, - -99, 162, -99, -99, -99, 163, 131, 164, 165, -99, - -99, -99, 99, -99, -99, -99, -99, -99, 166, -99, - -99, -99 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const short yypgoto[] = -{ - -99, -99, -99, 111, -99, -99, -99, -99, 178, -99, - -99, -99, -99, 91, -99, -99, -99, -99, -99, -99, - -99, -99, -99, -99, 115, -99, -99, -99, -99, -99, - -99, 146, 168, 89, 27, 0, 126, -1, -98, -48, - -63 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -68 -static const short yytable[] = -{ - 66, 67, 36, 42, 39, 40, 71, 41, 123, 124, - 43, 44, 74, 75, 120, 154, 72, 46, 47, 69, - 70, 121, 122, 48, 140, 45, 127, 128, 112, 130, - 49, 133, 156, 135, 158, 159, 68, 161, 60, 69, - 70, 165, 69, 70, 61, 167, 168, 62, 2, 3, - 63, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 46, 47, 13, 14, 139, 152, 48, 126, 178, 15, - 16, 69, 70, 49, 37, 38, 129, 166, 151, 15, - 16, -67, 114, 64, -67, 5, 101, 7, 8, 102, - 10, 11, 12, 143, 65, 13, 103, 153, 46, 47, - 147, 148, 149, 69, 70, 125, 172, 134, 141, 136, - 137, 138, 15, 16, 5, 101, 7, 8, 102, 10, - 11, 12, 145, 146, 13, 103, 101, 7, 142, 102, - 10, 11, 12, 171, 144, 13, 103, 69, 70, 69, - 70, 15, 16, 100, 150, 154, 113, 108, 113, 116, - 73, 157, 15, 16, 74, 75, 70, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 104, 107, 160, 115, - 85, 110, 73, 118, 86, 87, 74, 75, 92, 93, - 94, 95, 111, 96, 119, 162, 163, 164, 169, 170, - 173, 174, 97, 175, 176, 177, 179, 180, 181, 53, - 99, 59 -}; - -static const unsigned char yycheck[] = -{ - 48, 49, 3, 32, 4, 5, 30, 7, 71, 72, - 10, 28, 16, 17, 33, 14, 40, 28, 29, 38, - 39, 69, 70, 34, 87, 28, 74, 75, 32, 77, - 41, 79, 130, 81, 132, 133, 32, 135, 39, 38, - 39, 139, 38, 39, 32, 143, 144, 32, 0, 1, - 32, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 28, 29, 14, 15, 28, 32, 34, 35, 166, 31, - 32, 38, 39, 41, 28, 29, 76, 140, 126, 31, - 32, 0, 1, 32, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 93, 32, 14, 15, 32, 28, 29, - 101, 102, 103, 38, 39, 32, 154, 80, 13, 82, - 83, 84, 31, 32, 4, 5, 6, 7, 8, 9, - 10, 11, 95, 96, 14, 15, 5, 6, 32, 8, - 9, 10, 11, 32, 28, 14, 15, 38, 39, 38, - 39, 31, 32, 54, 32, 14, 57, 56, 59, 58, - 12, 32, 31, 32, 16, 17, 39, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 55, 56, 32, 58, - 32, 56, 12, 58, 36, 37, 16, 17, 18, 19, - 20, 21, 56, 23, 58, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 21, - 54, 33 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 43, 0, 1, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 14, 15, 31, 32, 44, 45, 46, - 47, 48, 49, 52, 53, 55, 59, 61, 63, 64, - 66, 68, 69, 70, 71, 79, 79, 28, 29, 77, - 77, 77, 32, 77, 28, 28, 28, 29, 34, 41, - 81, 82, 50, 50, 56, 58, 62, 74, 67, 74, - 79, 32, 32, 32, 32, 32, 81, 81, 32, 38, - 39, 30, 40, 12, 16, 17, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 32, 36, 37, 51, 72, - 73, 75, 18, 19, 20, 21, 23, 32, 57, 73, - 75, 5, 8, 15, 45, 54, 78, 45, 55, 60, - 66, 78, 32, 75, 1, 45, 55, 65, 66, 78, - 33, 81, 81, 82, 82, 32, 35, 81, 81, 77, - 81, 76, 77, 81, 76, 81, 76, 76, 76, 28, - 82, 13, 32, 77, 28, 76, 76, 79, 79, 79, - 32, 81, 32, 32, 14, 80, 80, 32, 80, 80, - 32, 80, 32, 32, 32, 80, 82, 80, 80, 32, - 32, 32, 81, 32, 32, 32, 32, 32, 80, 32, - 32, 32 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short *bottom, short *top) -#else -static void -yy_stack_print (bottom, top) - short *bottom; - short *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylineno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylineno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 8: - - { zconfprint("unexpected 'endmenu' statement"); ;} - break; - - case 9: - - { zconfprint("unexpected 'endif' statement"); ;} - break; - - case 10: - - { zconfprint("unexpected 'endchoice' statement"); ;} - break; - - case 11: - - { zconfprint("syntax error"); yyerrok; ;} - break; - - case 18: - - { - struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); -;} - break; - - case 19: - - { - menu_end_entry(); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 20: - - { - struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); -;} - break; - - case 21: - - { - if (current_entry->prompt) - current_entry->prompt->type = P_MENU; - else - zconfprint("warning: menuconfig statement without prompt"); - menu_end_entry(); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 27: - - { - menu_set_type(S_TRISTATE); - printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 28: - - { - menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); - menu_set_type(S_TRISTATE); - printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 29: - - { - menu_set_type(S_BOOLEAN); - printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 30: - - { - menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); - menu_set_type(S_BOOLEAN); - printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 31: - - { - menu_set_type(S_INT); - printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 32: - - { - menu_set_type(S_HEX); - printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 33: - - { - menu_set_type(S_STRING); - printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 34: - - { - menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 35: - - { - menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 36: - - { - menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 37: - - { - menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 38: - - { - struct symbol *sym = sym_lookup(NULL, 0); - sym->flags |= SYMBOL_CHOICE; - menu_add_entry(sym); - menu_add_expr(P_CHOICE, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 39: - - { - menu_end_entry(); - menu_add_menu(); -;} - break; - - case 40: - - { - if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); - } -;} - break; - - case 42: - - { - printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); - zconfnerrs++; -;} - break; - - case 48: - - { - menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 49: - - { - menu_set_type(S_TRISTATE); - printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 50: - - { - menu_set_type(S_BOOLEAN); - printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 51: - - { - current_entry->sym->flags |= SYMBOL_OPTIONAL; - printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 52: - - { - menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 55: - - { - printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); - menu_add_entry(NULL); - menu_add_dep(yyvsp[-1].expr); - menu_end_entry(); - menu_add_menu(); -;} - break; - - case 56: - - { - if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); - } -;} - break; - - case 58: - - { - printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); - zconfnerrs++; -;} - break; - - case 63: - - { - menu_add_entry(NULL); - menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 64: - - { - menu_end_entry(); - menu_add_menu(); -;} - break; - - case 65: - - { - if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); - } -;} - break; - - case 67: - - { - printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); - zconfnerrs++; -;} - break; - - case 72: - - { zconfprint("invalid menu option"); yyerrok; ;} - break; - - case 73: - - { - yyval.string = yyvsp[-1].string; - printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); -;} - break; - - case 74: - - { - zconf_nextfile(yyvsp[0].string); -;} - break; - - case 75: - - { - menu_add_entry(NULL); - menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 76: - - { - menu_end_entry(); -;} - break; - - case 77: - - { - printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); - zconf_starthelp(); -;} - break; - - case 78: - - { - current_entry->sym->help = yyvsp[0].string; -;} - break; - - case 82: - - { - menu_add_dep(yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 83: - - { - menu_add_dep(yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 84: - - { - menu_add_dep(yyvsp[-1].expr); - printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); -;} - break; - - case 86: - - { - menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); -;} - break; - - case 89: - - { yyval.token = T_ENDMENU; ;} - break; - - case 90: - - { yyval.token = T_ENDCHOICE; ;} - break; - - case 91: - - { yyval.token = T_ENDIF; ;} - break; - - case 94: - - { yyval.expr = NULL; ;} - break; - - case 95: - - { yyval.expr = yyvsp[0].expr; ;} - break; - - case 96: - - { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;} - break; - - case 97: - - { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} - break; - - case 98: - - { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} - break; - - case 99: - - { yyval.expr = yyvsp[-1].expr; ;} - break; - - case 100: - - { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;} - break; - - case 101: - - { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;} - break; - - case 102: - - { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;} - break; - - case 103: - - { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;} - break; - - case 104: - - { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;} - break; - - - } - -/* Line 999 of yacc.c. */ - - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - char *yymsg; - int yyx, yycount; - - yycount = 0; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("syntax error, unexpected ") + 1; - yysize += yystrlen (yytname[yytype]); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); - yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* Return failure if at end of input. */ - if (yychar == YYEOF) - { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyss < yyssp) - { - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - YYPOPSTACK; - } - YYABORT; - } - - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - - - - -void conf_parse(const char *name) -{ - struct symbol *sym; - int i; - - zconf_initscan(name); - - sym_init(); - menu_init(); - modules_sym = sym_lookup("MODULES", 0); - rootmenu.prompt = menu_add_prop(P_MENU, "axTLS Configuration", NULL, NULL); - - //zconfdebug = 1; - zconfparse(); - if (zconfnerrs) - exit(1); - menu_finalize(&rootmenu); - for_all_symbols(i, sym) { - if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) - printf("\n"); - else - sym->flags |= SYMBOL_CHECK_DONE; - } - - sym_change_count = 1; -} - -const char *zconf_tokenname(int token) -{ - switch (token) { - case T_MENU: return "menu"; - case T_ENDMENU: return "endmenu"; - case T_CHOICE: return "choice"; - case T_ENDCHOICE: return "endchoice"; - case T_IF: return "if"; - case T_ENDIF: return "endif"; - } - return ""; -} - -static bool zconf_endtoken(int token, int starttoken, int endtoken) -{ - if (token != endtoken) { - zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); - zconfnerrs++; - return false; - } - if (current_menu->file != current_file) { - zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); - zconfprint("location of the '%s'", zconf_tokenname(starttoken)); - zconfnerrs++; - return false; - } - return true; -} - -static void zconfprint(const char *err, ...) -{ - va_list ap; - - fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); - va_start(ap, err); - vfprintf(stderr, err, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static void zconferror(const char *err) -{ - fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -} - -void print_quoted_string(FILE *out, const char *str) -{ - const char *p; - int len; - - putc('"', out); - while ((p = strchr(str, '"'))) { - len = p - str; - if (len) - fprintf(out, "%.*s", len, str); - fputs("\\\"", out); - str = p + 1; - } - fputs(str, out); - putc('"', out); -} - -void print_symbol(FILE *out, struct menu *menu) -{ - struct symbol *sym = menu->sym; - struct property *prop; - - if (sym_is_choice(sym)) - fprintf(out, "choice\n"); - else - fprintf(out, "config %s\n", sym->name); - switch (sym->type) { - case S_BOOLEAN: - fputs(" boolean\n", out); - break; - case S_TRISTATE: - fputs(" tristate\n", out); - break; - case S_STRING: - fputs(" string\n", out); - break; - case S_INT: - fputs(" integer\n", out); - break; - case S_HEX: - fputs(" hex\n", out); - break; - default: - fputs(" ???\n", out); - break; - } - for (prop = sym->prop; prop; prop = prop->next) { - if (prop->menu != menu) - continue; - switch (prop->type) { - case P_PROMPT: - fputs(" prompt ", out); - print_quoted_string(out, prop->text); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_DEFAULT: - fputs( " default ", out); - expr_fprint(prop->expr, out); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_CHOICE: - fputs(" #choice value\n", out); - break; - default: - fprintf(out, " unknown prop %d!\n", prop->type); - break; - } - } - if (sym->help) { - int len = strlen(sym->help); - while (sym->help[--len] == '\n') - sym->help[len] = 0; - fprintf(out, " help\n%s\n", sym->help); - } - fputc('\n', out); -} - -void zconfdump(FILE *out) -{ - struct property *prop; - struct symbol *sym; - struct menu *menu; - - menu = rootmenu.list; - while (menu) { - if ((sym = menu->sym)) - print_symbol(out, menu); - else if ((prop = menu->prompt)) { - switch (prop->type) { - case P_COMMENT: - fputs("\ncomment ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - case P_MENU: - fputs("\nmenu ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - default: - ; - } - if (!expr_is_yes(prop->visible.expr)) { - fputs(" depends ", out); - expr_fprint(prop->visible.expr, out); - fputc('\n', out); - } - fputs("\n", out); - } - - if (menu->list) - menu = menu->list; - else if (menu->next) - menu = menu->next; - else while ((menu = menu->parent)) { - if (menu->prompt && menu->prompt->type == P_MENU) - fputs("\nendmenu\n", out); - if (menu->next) { - menu = menu->next; - break; - } - } - } -} - -#include "lex.zconf.c" -#include "util.c" -#include "confdata.c" -#include "expr.c" -#include "symbol.c" -#include "menu.c" - - diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped b/user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped deleted file mode 100644 index 3b191ef..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/zconf.tab.h_shipped +++ /dev/null @@ -1,125 +0,0 @@ -/* A Bison parser, made from zconf.y, by GNU bison 1.75. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -#ifndef BISON_ZCONF_TAB_H -# define BISON_ZCONF_TAB_H - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_MAINMENU = 258, - T_MENU = 259, - T_ENDMENU = 260, - T_SOURCE = 261, - T_CHOICE = 262, - T_ENDCHOICE = 263, - T_COMMENT = 264, - T_CONFIG = 265, - T_HELP = 266, - T_HELPTEXT = 267, - T_IF = 268, - T_ENDIF = 269, - T_DEPENDS = 270, - T_REQUIRES = 271, - T_OPTIONAL = 272, - T_PROMPT = 273, - T_DEFAULT = 274, - T_TRISTATE = 275, - T_BOOLEAN = 276, - T_INT = 277, - T_HEX = 278, - T_WORD = 279, - T_STRING = 280, - T_UNEQUAL = 281, - T_EOF = 282, - T_EOL = 283, - T_CLOSE_PAREN = 284, - T_OPEN_PAREN = 285, - T_ON = 286, - T_OR = 287, - T_AND = 288, - T_EQUAL = 289, - T_NOT = 290 - }; -#endif -#define T_MAINMENU 258 -#define T_MENU 259 -#define T_ENDMENU 260 -#define T_SOURCE 261 -#define T_CHOICE 262 -#define T_ENDCHOICE 263 -#define T_COMMENT 264 -#define T_CONFIG 265 -#define T_HELP 266 -#define T_HELPTEXT 267 -#define T_IF 268 -#define T_ENDIF 269 -#define T_DEPENDS 270 -#define T_REQUIRES 271 -#define T_OPTIONAL 272 -#define T_PROMPT 273 -#define T_DEFAULT 274 -#define T_TRISTATE 275 -#define T_BOOLEAN 276 -#define T_INT 277 -#define T_HEX 278 -#define T_WORD 279 -#define T_STRING 280 -#define T_UNEQUAL 281 -#define T_EOF 282 -#define T_EOL 283 -#define T_CLOSE_PAREN 284 -#define T_OPEN_PAREN 285 -#define T_ON 286 -#define T_OR 287 -#define T_AND 288 -#define T_EQUAL 289 -#define T_NOT 290 - - - - -#ifndef YYSTYPE -#line 33 "zconf.y" -typedef union { - int token; - char *string; - struct symbol *symbol; - struct expr *expr; - struct menu *menu; -} yystype; -/* Line 1281 of /usr/share/bison/yacc.c. */ -#line 118 "zconf.tab.h" -# define YYSTYPE yystype -#endif - -extern YYSTYPE zconflval; - - -#endif /* not BISON_ZCONF_TAB_H */ - diff --git a/user/mpy/lib/axtls/config/scripts/config/zconf.y b/user/mpy/lib/axtls/config/scripts/config/zconf.y deleted file mode 100644 index cf45da0..0000000 --- a/user/mpy/lib/axtls/config/scripts/config/zconf.y +++ /dev/null @@ -1,690 +0,0 @@ -%{ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include -#include - -#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) - -#define PRINTD 0x0001 -#define DEBUG_PARSE 0x0002 - -int cdebug = PRINTD; - -extern int zconflex(void); -static void zconfprint(const char *err, ...); -static void zconferror(const char *err); -static bool zconf_endtoken(int token, int starttoken, int endtoken); - -struct symbol *symbol_hash[257]; - -static struct menu *current_menu, *current_entry; - -#define YYERROR_VERBOSE -%} -%expect 40 - -%union -{ - int token; - char *string; - struct symbol *symbol; - struct expr *expr; - struct menu *menu; -} - -%token T_MAINMENU -%token T_MENU -%token T_ENDMENU -%token T_SOURCE -%token T_CHOICE -%token T_ENDCHOICE -%token T_COMMENT -%token T_CONFIG -%token T_MENUCONFIG -%token T_HELP -%token T_HELPTEXT -%token T_IF -%token T_ENDIF -%token T_DEPENDS -%token T_REQUIRES -%token T_OPTIONAL -%token T_PROMPT -%token T_DEFAULT -%token T_TRISTATE -%token T_DEF_TRISTATE -%token T_BOOLEAN -%token T_DEF_BOOLEAN -%token T_STRING -%token T_INT -%token T_HEX -%token T_WORD -%token T_WORD_QUOTE -%token T_UNEQUAL -%token T_EOF -%token T_EOL -%token T_CLOSE_PAREN -%token T_OPEN_PAREN -%token T_ON -%token T_SELECT -%token T_RANGE - -%left T_OR -%left T_AND -%left T_EQUAL T_UNEQUAL -%nonassoc T_NOT - -%type prompt -%type source -%type symbol -%type expr -%type if_expr -%type end - -%{ -#define LKC_DIRECT_LINK -#include "lkc.h" -%} -%% -input: /* empty */ - | input block -; - -block: common_block - | choice_stmt - | menu_stmt - | T_MAINMENU prompt nl_or_eof - | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); } - | T_ENDIF { zconfprint("unexpected 'endif' statement"); } - | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); } - | error nl_or_eof { zconfprint("syntax error"); yyerrok; } -; - -common_block: - if_stmt - | comment_stmt - | config_stmt - | menuconfig_stmt - | source_stmt - | nl_or_eof -; - - -/* config/menuconfig entry */ - -config_entry_start: T_CONFIG T_WORD T_EOL -{ - struct symbol *sym = sym_lookup($2, 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); -}; - -config_stmt: config_entry_start config_option_list -{ - menu_end_entry(); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); -}; - -menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL -{ - struct symbol *sym = sym_lookup($2, 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2); -}; - -menuconfig_stmt: menuconfig_entry_start config_option_list -{ - if (current_entry->prompt) - current_entry->prompt->type = P_MENU; - else - zconfprint("warning: menuconfig statement without prompt"); - menu_end_entry(); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); -}; - -config_option_list: - /* empty */ - | config_option_list config_option - | config_option_list depends - | config_option_list help - | config_option_list T_EOL -; - -config_option: T_TRISTATE prompt_stmt_opt T_EOL -{ - menu_set_type(S_TRISTATE); - printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_DEF_TRISTATE expr if_expr T_EOL -{ - menu_add_expr(P_DEFAULT, $2, $3); - menu_set_type(S_TRISTATE); - printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_BOOLEAN prompt_stmt_opt T_EOL -{ - menu_set_type(S_BOOLEAN); - printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_DEF_BOOLEAN expr if_expr T_EOL -{ - menu_add_expr(P_DEFAULT, $2, $3); - menu_set_type(S_BOOLEAN); - printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_INT prompt_stmt_opt T_EOL -{ - menu_set_type(S_INT); - printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_HEX prompt_stmt_opt T_EOL -{ - menu_set_type(S_HEX); - printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_STRING prompt_stmt_opt T_EOL -{ - menu_set_type(S_STRING); - printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_PROMPT prompt if_expr T_EOL -{ - menu_add_prompt(P_PROMPT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_DEFAULT expr if_expr T_EOL -{ - menu_add_expr(P_DEFAULT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_SELECT T_WORD if_expr T_EOL -{ - menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); - printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); -}; - -config_option: T_RANGE symbol symbol if_expr T_EOL -{ - menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); - printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); -}; - -/* choice entry */ - -choice: T_CHOICE T_EOL -{ - struct symbol *sym = sym_lookup(NULL, 0); - sym->flags |= SYMBOL_CHOICE; - menu_add_entry(sym); - menu_add_expr(P_CHOICE, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); -}; - -choice_entry: choice choice_option_list -{ - menu_end_entry(); - menu_add_menu(); -}; - -choice_end: end -{ - if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); - } -}; - -choice_stmt: - choice_entry choice_block choice_end - | choice_entry choice_block -{ - printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); - zconfnerrs++; -}; - -choice_option_list: - /* empty */ - | choice_option_list choice_option - | choice_option_list depends - | choice_option_list help - | choice_option_list T_EOL -; - -choice_option: T_PROMPT prompt if_expr T_EOL -{ - menu_add_prompt(P_PROMPT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); -}; - -choice_option: T_TRISTATE prompt_stmt_opt T_EOL -{ - menu_set_type(S_TRISTATE); - printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); -}; - -choice_option: T_BOOLEAN prompt_stmt_opt T_EOL -{ - menu_set_type(S_BOOLEAN); - printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); -}; - -choice_option: T_OPTIONAL T_EOL -{ - current_entry->sym->flags |= SYMBOL_OPTIONAL; - printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); -}; - -choice_option: T_DEFAULT T_WORD if_expr T_EOL -{ - menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); - printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); -}; - -choice_block: - /* empty */ - | choice_block common_block -; - -/* if entry */ - -if: T_IF expr T_EOL -{ - printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); - menu_add_entry(NULL); - menu_add_dep($2); - menu_end_entry(); - menu_add_menu(); -}; - -if_end: end -{ - if (zconf_endtoken($1, T_IF, T_ENDIF)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); - } -}; - -if_stmt: - if if_block if_end - | if if_block -{ - printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); - zconfnerrs++; -}; - -if_block: - /* empty */ - | if_block common_block - | if_block menu_stmt - | if_block choice_stmt -; - -/* menu entry */ - -menu: T_MENU prompt T_EOL -{ - menu_add_entry(NULL); - menu_add_prop(P_MENU, $2, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); -}; - -menu_entry: menu depends_list -{ - menu_end_entry(); - menu_add_menu(); -}; - -menu_end: end -{ - if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); - } -}; - -menu_stmt: - menu_entry menu_block menu_end - | menu_entry menu_block -{ - printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); - zconfnerrs++; -}; - -menu_block: - /* empty */ - | menu_block common_block - | menu_block menu_stmt - | menu_block choice_stmt - | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; } -; - -source: T_SOURCE prompt T_EOL -{ - $$ = $2; - printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); -}; - -source_stmt: source -{ - zconf_nextfile($1); -}; - -/* comment entry */ - -comment: T_COMMENT prompt T_EOL -{ - menu_add_entry(NULL); - menu_add_prop(P_COMMENT, $2, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); -}; - -comment_stmt: comment depends_list -{ - menu_end_entry(); -}; - -/* help option */ - -help_start: T_HELP T_EOL -{ - printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); - zconf_starthelp(); -}; - -help: help_start T_HELPTEXT -{ - current_entry->sym->help = $2; -}; - -/* depends option */ - -depends_list: /* empty */ - | depends_list depends - | depends_list T_EOL -; - -depends: T_DEPENDS T_ON expr T_EOL -{ - menu_add_dep($3); - printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); -} - | T_DEPENDS expr T_EOL -{ - menu_add_dep($2); - printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); -} - | T_REQUIRES expr T_EOL -{ - menu_add_dep($2); - printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); -}; - -/* prompt statement */ - -prompt_stmt_opt: - /* empty */ - | prompt if_expr -{ - menu_add_prop(P_PROMPT, $1, NULL, $2); -}; - -prompt: T_WORD - | T_WORD_QUOTE -; - -end: T_ENDMENU nl_or_eof { $$ = T_ENDMENU; } - | T_ENDCHOICE nl_or_eof { $$ = T_ENDCHOICE; } - | T_ENDIF nl_or_eof { $$ = T_ENDIF; } -; - -nl_or_eof: - T_EOL | T_EOF; - -if_expr: /* empty */ { $$ = NULL; } - | T_IF expr { $$ = $2; } -; - -expr: symbol { $$ = expr_alloc_symbol($1); } - | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } - | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } - | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } - | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } - | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } - | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } -; - -symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } - | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); } -; - -%% - -void conf_parse(const char *name) -{ - struct symbol *sym; - int i; - - zconf_initscan(name); - - sym_init(); - menu_init(); - modules_sym = sym_lookup("MODULES", 0); - rootmenu.prompt = menu_add_prop(P_MENU, "axTLS Configuration", NULL, NULL); - - //zconfdebug = 1; - zconfparse(); - if (zconfnerrs) - exit(1); - menu_finalize(&rootmenu); - for_all_symbols(i, sym) { - if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) - printf("\n"); - else - sym->flags |= SYMBOL_CHECK_DONE; - } - - sym_change_count = 1; -} - -const char *zconf_tokenname(int token) -{ - switch (token) { - case T_MENU: return "menu"; - case T_ENDMENU: return "endmenu"; - case T_CHOICE: return "choice"; - case T_ENDCHOICE: return "endchoice"; - case T_IF: return "if"; - case T_ENDIF: return "endif"; - } - return ""; -} - -static bool zconf_endtoken(int token, int starttoken, int endtoken) -{ - if (token != endtoken) { - zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); - zconfnerrs++; - return false; - } - if (current_menu->file != current_file) { - zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); - zconfprint("location of the '%s'", zconf_tokenname(starttoken)); - zconfnerrs++; - return false; - } - return true; -} - -static void zconfprint(const char *err, ...) -{ - va_list ap; - - fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); - va_start(ap, err); - vfprintf(stderr, err, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static void zconferror(const char *err) -{ - fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -} - -void print_quoted_string(FILE *out, const char *str) -{ - const char *p; - int len; - - putc('"', out); - while ((p = strchr(str, '"'))) { - len = p - str; - if (len) - fprintf(out, "%.*s", len, str); - fputs("\\\"", out); - str = p + 1; - } - fputs(str, out); - putc('"', out); -} - -void print_symbol(FILE *out, struct menu *menu) -{ - struct symbol *sym = menu->sym; - struct property *prop; - - if (sym_is_choice(sym)) - fprintf(out, "choice\n"); - else - fprintf(out, "config %s\n", sym->name); - switch (sym->type) { - case S_BOOLEAN: - fputs(" boolean\n", out); - break; - case S_TRISTATE: - fputs(" tristate\n", out); - break; - case S_STRING: - fputs(" string\n", out); - break; - case S_INT: - fputs(" integer\n", out); - break; - case S_HEX: - fputs(" hex\n", out); - break; - default: - fputs(" ???\n", out); - break; - } - for (prop = sym->prop; prop; prop = prop->next) { - if (prop->menu != menu) - continue; - switch (prop->type) { - case P_PROMPT: - fputs(" prompt ", out); - print_quoted_string(out, prop->text); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_DEFAULT: - fputs( " default ", out); - expr_fprint(prop->expr, out); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_CHOICE: - fputs(" #choice value\n", out); - break; - default: - fprintf(out, " unknown prop %d!\n", prop->type); - break; - } - } - if (sym->help) { - int len = strlen(sym->help); - while (sym->help[--len] == '\n') - sym->help[len] = 0; - fprintf(out, " help\n%s\n", sym->help); - } - fputc('\n', out); -} - -void zconfdump(FILE *out) -{ - struct property *prop; - struct symbol *sym; - struct menu *menu; - - menu = rootmenu.list; - while (menu) { - if ((sym = menu->sym)) - print_symbol(out, menu); - else if ((prop = menu->prompt)) { - switch (prop->type) { - case P_COMMENT: - fputs("\ncomment ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - case P_MENU: - fputs("\nmenu ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - default: - ; - } - if (!expr_is_yes(prop->visible.expr)) { - fputs(" depends ", out); - expr_fprint(prop->visible.expr, out); - fputc('\n', out); - } - fputs("\n", out); - } - - if (menu->list) - menu = menu->list; - else if (menu->next) - menu = menu->next; - else while ((menu = menu->parent)) { - if (menu->prompt && menu->prompt->type == P_MENU) - fputs("\nendmenu\n", out); - if (menu->next) { - menu = menu->next; - break; - } - } - } -} - -#include "lex.zconf.c" -#include "util.c" -#include "confdata.c" -#include "expr.c" -#include "symbol.c" -#include "menu.c" diff --git a/user/mpy/lib/axtls/config/upyconfig b/user/mpy/lib/axtls/config/upyconfig deleted file mode 100644 index f3a26f3..0000000 --- a/user/mpy/lib/axtls/config/upyconfig +++ /dev/null @@ -1,117 +0,0 @@ -# -# Automatically generated make config: don't edit -# -HAVE_DOT_CONFIG=y -CONFIG_PLATFORM_LINUX=y -# CONFIG_PLATFORM_CYGWIN is not set -# CONFIG_PLATFORM_WIN32 is not set - -# -# General Configuration -# -PREFIX="/usr/local" -# CONFIG_DEBUG is not set -# CONFIG_STRIP_UNWANTED_SECTIONS is not set -# CONFIG_VISUAL_STUDIO_7_0 is not set -# CONFIG_VISUAL_STUDIO_8_0 is not set -# CONFIG_VISUAL_STUDIO_10_0 is not set -CONFIG_VISUAL_STUDIO_7_0_BASE="" -CONFIG_VISUAL_STUDIO_8_0_BASE="" -CONFIG_VISUAL_STUDIO_10_0_BASE="" -CONFIG_EXTRA_CFLAGS_OPTIONS="" -CONFIG_EXTRA_LDFLAGS_OPTIONS="" - -# -# SSL Library -# -# CONFIG_SSL_SERVER_ONLY is not set -# CONFIG_SSL_CERT_VERIFICATION is not set -# CONFIG_SSL_FULL_MODE is not set -CONFIG_SSL_SKELETON_MODE=y -CONFIG_SSL_ENABLE_SERVER=y -CONFIG_SSL_ENABLE_CLIENT=y -# CONFIG_SSL_DIAGNOSTICS is not set -CONFIG_SSL_PROT_LOW=y -# CONFIG_SSL_PROT_MEDIUM is not set -# CONFIG_SSL_PROT_HIGH is not set -CONFIG_SSL_AES=y -CONFIG_SSL_USE_DEFAULT_KEY=y -CONFIG_SSL_PRIVATE_KEY_LOCATION="" -CONFIG_SSL_PRIVATE_KEY_PASSWORD="" -CONFIG_SSL_X509_CERT_LOCATION="" -# CONFIG_SSL_GENERATE_X509_CERT is not set -CONFIG_SSL_X509_COMMON_NAME="" -CONFIG_SSL_X509_ORGANIZATION_NAME="" -CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME="" -# CONFIG_SSL_ENABLE_V23_HANDSHAKE is not set -# CONFIG_SSL_HAS_PEM is not set -# CONFIG_SSL_USE_PKCS12 is not set -CONFIG_SSL_EXPIRY_TIME=0 -CONFIG_X509_MAX_CA_CERTS=0 -CONFIG_SSL_MAX_CERTS=3 -# CONFIG_SSL_CTX_MUTEXING is not set -# CONFIG_USE_DEV_URANDOM is not set -# CONFIG_WIN32_USE_CRYPTO_LIB is not set -# CONFIG_OPENSSL_COMPATIBLE is not set -# CONFIG_PERFORMANCE_TESTING is not set -# CONFIG_SSL_TEST is not set -# CONFIG_AXTLSWRAP is not set -# CONFIG_AXHTTPD is not set -# CONFIG_HTTP_STATIC_BUILD is not set -CONFIG_HTTP_PORT=0 -CONFIG_HTTP_HTTPS_PORT=0 -CONFIG_HTTP_SESSION_CACHE_SIZE=0 -CONFIG_HTTP_WEBROOT="" -CONFIG_HTTP_TIMEOUT=0 -# CONFIG_HTTP_HAS_CGI is not set -CONFIG_HTTP_CGI_EXTENSIONS="" -# CONFIG_HTTP_ENABLE_LUA is not set -CONFIG_HTTP_LUA_PREFIX="" -# CONFIG_HTTP_BUILD_LUA is not set -CONFIG_HTTP_CGI_LAUNCHER="" -# CONFIG_HTTP_DIRECTORIES is not set -# CONFIG_HTTP_HAS_AUTHORIZATION is not set -# CONFIG_HTTP_HAS_IPV6 is not set -# CONFIG_HTTP_ENABLE_DIFFERENT_USER is not set -CONFIG_HTTP_USER="" -# CONFIG_HTTP_VERBOSE is not set -# CONFIG_HTTP_IS_DAEMON is not set - -# -# Language Bindings -# -# CONFIG_BINDINGS is not set -# CONFIG_CSHARP_BINDINGS is not set -# CONFIG_VBNET_BINDINGS is not set -CONFIG_DOT_NET_FRAMEWORK_BASE="" -# CONFIG_JAVA_BINDINGS is not set -CONFIG_JAVA_HOME="" -# CONFIG_PERL_BINDINGS is not set -CONFIG_PERL_CORE="" -CONFIG_PERL_LIB="" -# CONFIG_LUA_BINDINGS is not set -CONFIG_LUA_CORE="" - -# -# Samples -# -# CONFIG_SAMPLES is not set -# CONFIG_C_SAMPLES is not set -# CONFIG_CSHARP_SAMPLES is not set -# CONFIG_VBNET_SAMPLES is not set -# CONFIG_JAVA_SAMPLES is not set -# CONFIG_PERL_SAMPLES is not set -# CONFIG_LUA_SAMPLES is not set -# CONFIG_BIGINT_CLASSICAL is not set -# CONFIG_BIGINT_MONTGOMERY is not set -# CONFIG_BIGINT_BARRETT is not set -# CONFIG_BIGINT_CRT is not set -# CONFIG_BIGINT_KARATSUBA is not set -MUL_KARATSUBA_THRESH=0 -SQU_KARATSUBA_THRESH=0 -# CONFIG_BIGINT_SLIDING_WINDOW is not set -# CONFIG_BIGINT_SQUARE is not set -# CONFIG_BIGINT_CHECK_ON is not set -# CONFIG_INTEGER_32BIT is not set -# CONFIG_INTEGER_16BIT is not set -# CONFIG_INTEGER_8BIT is not set diff --git a/user/mpy/lib/axtls/config/upyconfig.client b/user/mpy/lib/axtls/config/upyconfig.client deleted file mode 100644 index 6dffa19..0000000 --- a/user/mpy/lib/axtls/config/upyconfig.client +++ /dev/null @@ -1,116 +0,0 @@ -# -# Automatically generated make config: don't edit -# -HAVE_DOT_CONFIG=y -CONFIG_PLATFORM_LINUX=y -# CONFIG_PLATFORM_CYGWIN is not set -# CONFIG_PLATFORM_WIN32 is not set - -# -# General Configuration -# -PREFIX="/usr/local" -# CONFIG_DEBUG is not set -# CONFIG_STRIP_UNWANTED_SECTIONS is not set -# CONFIG_VISUAL_STUDIO_7_0 is not set -# CONFIG_VISUAL_STUDIO_8_0 is not set -# CONFIG_VISUAL_STUDIO_10_0 is not set -CONFIG_VISUAL_STUDIO_7_0_BASE="" -CONFIG_VISUAL_STUDIO_8_0_BASE="" -CONFIG_VISUAL_STUDIO_10_0_BASE="" -CONFIG_EXTRA_CFLAGS_OPTIONS="" -CONFIG_EXTRA_LDFLAGS_OPTIONS="" - -# -# SSL Library -# -# CONFIG_SSL_SERVER_ONLY is not set -# CONFIG_SSL_CERT_VERIFICATION is not set -# CONFIG_SSL_FULL_MODE is not set -CONFIG_SSL_SKELETON_MODE=y -CONFIG_SSL_ENABLE_CLIENT=y -# CONFIG_SSL_DIAGNOSTICS is not set -CONFIG_SSL_PROT_LOW=y -# CONFIG_SSL_PROT_MEDIUM is not set -# CONFIG_SSL_PROT_HIGH is not set -CONFIG_SSL_AES=y -# CONFIG_SSL_USE_DEFAULT_KEY is not set -CONFIG_SSL_PRIVATE_KEY_LOCATION="" -CONFIG_SSL_PRIVATE_KEY_PASSWORD="" -CONFIG_SSL_X509_CERT_LOCATION="" -# CONFIG_SSL_GENERATE_X509_CERT is not set -CONFIG_SSL_X509_COMMON_NAME="" -CONFIG_SSL_X509_ORGANIZATION_NAME="" -CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME="" -# CONFIG_SSL_ENABLE_V23_HANDSHAKE is not set -# CONFIG_SSL_HAS_PEM is not set -# CONFIG_SSL_USE_PKCS12 is not set -CONFIG_SSL_EXPIRY_TIME=0 -CONFIG_X509_MAX_CA_CERTS=0 -CONFIG_SSL_MAX_CERTS=3 -# CONFIG_SSL_CTX_MUTEXING is not set -# CONFIG_USE_DEV_URANDOM is not set -# CONFIG_WIN32_USE_CRYPTO_LIB is not set -# CONFIG_OPENSSL_COMPATIBLE is not set -# CONFIG_PERFORMANCE_TESTING is not set -# CONFIG_SSL_TEST is not set -# CONFIG_AXTLSWRAP is not set -# CONFIG_AXHTTPD is not set -# CONFIG_HTTP_STATIC_BUILD is not set -CONFIG_HTTP_PORT=0 -CONFIG_HTTP_HTTPS_PORT=0 -CONFIG_HTTP_SESSION_CACHE_SIZE=0 -CONFIG_HTTP_WEBROOT="" -CONFIG_HTTP_TIMEOUT=0 -# CONFIG_HTTP_HAS_CGI is not set -CONFIG_HTTP_CGI_EXTENSIONS="" -# CONFIG_HTTP_ENABLE_LUA is not set -CONFIG_HTTP_LUA_PREFIX="" -# CONFIG_HTTP_BUILD_LUA is not set -CONFIG_HTTP_CGI_LAUNCHER="" -# CONFIG_HTTP_DIRECTORIES is not set -# CONFIG_HTTP_HAS_AUTHORIZATION is not set -# CONFIG_HTTP_HAS_IPV6 is not set -# CONFIG_HTTP_ENABLE_DIFFERENT_USER is not set -CONFIG_HTTP_USER="" -# CONFIG_HTTP_VERBOSE is not set -# CONFIG_HTTP_IS_DAEMON is not set - -# -# Language Bindings -# -# CONFIG_BINDINGS is not set -# CONFIG_CSHARP_BINDINGS is not set -# CONFIG_VBNET_BINDINGS is not set -CONFIG_DOT_NET_FRAMEWORK_BASE="" -# CONFIG_JAVA_BINDINGS is not set -CONFIG_JAVA_HOME="" -# CONFIG_PERL_BINDINGS is not set -CONFIG_PERL_CORE="" -CONFIG_PERL_LIB="" -# CONFIG_LUA_BINDINGS is not set -CONFIG_LUA_CORE="" - -# -# Samples -# -# CONFIG_SAMPLES is not set -# CONFIG_C_SAMPLES is not set -# CONFIG_CSHARP_SAMPLES is not set -# CONFIG_VBNET_SAMPLES is not set -# CONFIG_JAVA_SAMPLES is not set -# CONFIG_PERL_SAMPLES is not set -# CONFIG_LUA_SAMPLES is not set -# CONFIG_BIGINT_CLASSICAL is not set -# CONFIG_BIGINT_MONTGOMERY is not set -# CONFIG_BIGINT_BARRETT is not set -# CONFIG_BIGINT_CRT is not set -# CONFIG_BIGINT_KARATSUBA is not set -MUL_KARATSUBA_THRESH=0 -SQU_KARATSUBA_THRESH=0 -# CONFIG_BIGINT_SLIDING_WINDOW is not set -# CONFIG_BIGINT_SQUARE is not set -# CONFIG_BIGINT_CHECK_ON is not set -# CONFIG_INTEGER_32BIT is not set -# CONFIG_INTEGER_16BIT is not set -# CONFIG_INTEGER_8BIT is not set diff --git a/user/mpy/lib/axtls/config/win32config b/user/mpy/lib/axtls/config/win32config deleted file mode 100644 index 6c8d607..0000000 --- a/user/mpy/lib/axtls/config/win32config +++ /dev/null @@ -1,119 +0,0 @@ -# -# Automatically generated make config: don't edit -# -HAVE_DOT_CONFIG=y -# CONFIG_PLATFORM_LINUX is not set -# CONFIG_PLATFORM_CYGWIN is not set -# CONFIG_PLATFORM_SOLARIS is not set -CONFIG_PLATFORM_WIN32=y - -# -# General Configuration -# -PREFIX="" -# CONFIG_DEBUG is not set -# CONFIG_STRIP_UNWANTED_SECTIONS is not set - -# -# Microsoft Compiler Options -# -# CONFIG_VISUAL_STUDIO_7_0 is not set -CONFIG_VISUAL_STUDIO_8_0=y -CONFIG_VISUAL_STUDIO_7_0_BASE="" -CONFIG_VISUAL_STUDIO_8_0_BASE="c:\\Program Files\\Microsoft Visual Studio 8" -CONFIG_EXTRA_CFLAGS_OPTIONS="" -CONFIG_EXTRA_LDFLAGS_OPTIONS="" - -# -# SSL Library -# -# CONFIG_SSL_SERVER_ONLY is not set -# CONFIG_SSL_CERT_VERIFICATION is not set -# CONFIG_SSL_ENABLE_CLIENT is not set -CONFIG_SSL_FULL_MODE=y -# CONFIG_SSL_SKELETON_MODE is not set -# CONFIG_SSL_PROT_LOW is not set -CONFIG_SSL_PROT_MEDIUM=y -# CONFIG_SSL_PROT_HIGH is not set -CONFIG_SSL_USE_DEFAULT_KEY=y -CONFIG_SSL_PRIVATE_KEY_LOCATION="" -CONFIG_SSL_PRIVATE_KEY_PASSWORD="" -CONFIG_SSL_X509_CERT_LOCATION="" -CONFIG_SSL_GENERATE_X509_CERT=y -CONFIG_SSL_X509_COMMON_NAME="" -CONFIG_SSL_X509_ORGANIZATION_NAME="" -CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME="" -CONFIG_SSL_ENABLE_V23_HANDSHAKE=y -CONFIG_SSL_HAS_PEM=y -CONFIG_SSL_USE_PKCS12=y -CONFIG_SSL_EXPIRY_TIME=24 -CONFIG_X509_MAX_CA_CERTS=4 -CONFIG_SSL_MAX_CERTS=2 -# CONFIG_SSL_CTX_MUTEXING is not set -# CONFIG_USE_DEV_URANDOM is not set -CONFIG_WIN32_USE_CRYPTO_LIB=y -# CONFIG_OPENSSL_COMPATIBLE is not set -# CONFIG_PERFORMANCE_TESTING is not set -# CONFIG_SSL_TEST is not set -CONFIG_AXHTTPD=y - -# -# Axhttpd Configuration -# -# CONFIG_HTTP_STATIC_BUILD is not set -CONFIG_HTTP_PORT=80 -CONFIG_HTTP_HTTPS_PORT=443 -CONFIG_HTTP_SESSION_CACHE_SIZE=5 -CONFIG_HTTP_WEBROOT="www" -CONFIG_HTTP_TIMEOUT=300 -# CONFIG_HTTP_HAS_CGI is not set -CONFIG_HTTP_CGI_EXTENSIONS="" -# CONFIG_HTTP_ENABLE_LUA is not set -CONFIG_HTTP_LUA_PREFIX="" -CONFIG_HTTP_LUA_CGI_LAUNCHER="" -# CONFIG_HTTP_BUILD_LUA is not set -CONFIG_HTTP_DIRECTORIES=y -CONFIG_HTTP_HAS_AUTHORIZATION=y -# CONFIG_HTTP_HAS_IPV6 is not set -CONFIG_HTTP_VERBOSE=y -# CONFIG_HTTP_IS_DAEMON is not set - -# -# Language Bindings -# -# CONFIG_BINDINGS is not set -# CONFIG_CSHARP_BINDINGS is not set -# CONFIG_VBNET_BINDINGS is not set -CONFIG_DOT_NET_FRAMEWORK_BASE="" -# CONFIG_JAVA_BINDINGS is not set -CONFIG_JAVA_HOME="" -# CONFIG_PERL_BINDINGS is not set -CONFIG_PERL_CORE="" -CONFIG_PERL_LIB="" -# CONFIG_LUA_BINDINGS is not set -CONFIG_LUA_CORE="" - -# -# Samples -# -CONFIG_SAMPLES=y -CONFIG_C_SAMPLES=y -# CONFIG_CSHARP_SAMPLES is not set -# CONFIG_VBNET_SAMPLES is not set -# CONFIG_JAVA_SAMPLES is not set -# CONFIG_PERL_SAMPLES is not set -# CONFIG_LUA_SAMPLES is not set - -# -# BigInt Options -# -# CONFIG_BIGINT_CLASSICAL is not set -# CONFIG_BIGINT_MONTGOMERY is not set -CONFIG_BIGINT_BARRETT=y -CONFIG_BIGINT_CRT=y -# CONFIG_BIGINT_KARATSUBA is not set -MUL_KARATSUBA_THRESH=0 -SQU_KARATSUBA_THRESH=0 -CONFIG_BIGINT_SLIDING_WINDOW=y -CONFIG_BIGINT_SQUARE=y -# CONFIG_BIGINT_CHECK_ON is not set diff --git a/user/mpy/lib/axtls/crypto/Makefile b/user/mpy/lib/axtls/crypto/Makefile deleted file mode 100644 index 126ae78..0000000 --- a/user/mpy/lib/axtls/crypto/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../config/.config -include ../config/makefile.conf - -AXTLS_HOME=.. - -OBJ=\ - aes.o \ - bigint.o \ - crypto_misc.o \ - hmac.o \ - md5.o \ - rc4.o \ - rsa.o \ - sha1.o \ - sha256.o \ - sha384.o \ - sha512.o - -include ../config/makefile.post - -all: $(OBJ) - diff --git a/user/mpy/lib/axtls/crypto/aes.c b/user/mpy/lib/axtls/crypto/aes.c deleted file mode 100644 index d573f77..0000000 --- a/user/mpy/lib/axtls/crypto/aes.c +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * AES implementation - this is a small code version. There are much faster - * versions around but they are much larger in size (i.e. they use large - * submix tables). - */ - -#include -#include "os_port.h" -#include "crypto.h" - -#define rot1(x) (((x) << 24) | ((x) >> 8)) -#define rot2(x) (((x) << 16) | ((x) >> 16)) -#define rot3(x) (((x) << 8) | ((x) >> 24)) - -/* - * This cute trick does 4 'mul by two' at once. Stolen from - * Dr B. R. Gladman but I'm sure the u-(u>>7) is - * a standard graphics trick - * The key to this is that we need to xor with 0x1b if the top bit is set. - * a 1xxx xxxx 0xxx 0xxx First we mask the 7bit, - * b 1000 0000 0000 0000 then we shift right by 7 putting the 7bit in 0bit, - * c 0000 0001 0000 0000 we then subtract (c) from (b) - * d 0111 1111 0000 0000 and now we and with our mask - * e 0001 1011 0000 0000 - */ -#define mt 0x80808080 -#define ml 0x7f7f7f7f -#define mh 0xfefefefe -#define mm 0x1b1b1b1b -#define mul2(x,t) ((t)=((x)&mt), \ - ((((x)+(x))&mh)^(((t)-((t)>>7))&mm))) - -#define inv_mix_col(x,f2,f4,f8,f9) (\ - (f2)=mul2(x,f2), \ - (f4)=mul2(f2,f4), \ - (f8)=mul2(f4,f8), \ - (f9)=(x)^(f8), \ - (f8)=((f2)^(f4)^(f8)), \ - (f2)^=(f9), \ - (f4)^=(f9), \ - (f8)^=rot3(f2), \ - (f8)^=rot2(f4), \ - (f8)^rot1(f9)) - -/* - * AES S-box - */ -static const uint8_t aes_sbox[256] = -{ - 0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5, - 0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76, - 0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0, - 0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0, - 0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC, - 0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15, - 0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A, - 0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75, - 0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0, - 0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84, - 0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B, - 0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF, - 0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85, - 0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8, - 0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5, - 0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2, - 0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17, - 0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73, - 0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88, - 0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB, - 0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C, - 0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79, - 0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9, - 0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08, - 0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6, - 0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A, - 0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E, - 0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E, - 0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94, - 0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF, - 0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68, - 0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16, -}; - -/* - * AES is-box - */ -static const uint8_t aes_isbox[256] = -{ - 0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38, - 0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb, - 0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87, - 0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb, - 0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d, - 0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e, - 0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2, - 0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25, - 0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16, - 0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92, - 0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda, - 0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84, - 0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a, - 0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06, - 0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02, - 0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b, - 0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea, - 0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73, - 0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85, - 0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e, - 0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89, - 0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b, - 0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20, - 0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4, - 0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31, - 0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f, - 0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d, - 0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef, - 0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0, - 0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61, - 0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26, - 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d -}; - -static const unsigned char Rcon[30]= -{ - 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, - 0x1b,0x36,0x6c,0xd8,0xab,0x4d,0x9a,0x2f, - 0x5e,0xbc,0x63,0xc6,0x97,0x35,0x6a,0xd4, - 0xb3,0x7d,0xfa,0xef,0xc5,0x91, -}; - -/* ----- static functions ----- */ -static void AES_encrypt(const AES_CTX *ctx, uint32_t *data); -static void AES_decrypt(const AES_CTX *ctx, uint32_t *data); - -/* Perform doubling in Galois Field GF(2^8) using the irreducible polynomial - x^8+x^4+x^3+x+1 */ -static unsigned char AES_xtime(uint32_t x) -{ - return (x&0x80) ? (x<<1)^0x1b : x<<1; -} - -/** - * Set up AES with the key/iv and cipher size. - */ -void AES_set_key(AES_CTX *ctx, const uint8_t *key, - const uint8_t *iv, AES_MODE mode) -{ - int i, ii; - uint32_t *W, tmp, tmp2; - const unsigned char *ip; - int words; - - switch (mode) - { - case AES_MODE_128: - i = 10; - words = 4; - break; - - case AES_MODE_256: - i = 14; - words = 8; - break; - - default: /* fail silently */ - return; - } - - ctx->rounds = i; - ctx->key_size = words; - W = ctx->ks; - for (i = 0; i < words; i+=2) - { - W[i+0]= ((uint32_t)key[ 0]<<24)| - ((uint32_t)key[ 1]<<16)| - ((uint32_t)key[ 2]<< 8)| - ((uint32_t)key[ 3] ); - W[i+1]= ((uint32_t)key[ 4]<<24)| - ((uint32_t)key[ 5]<<16)| - ((uint32_t)key[ 6]<< 8)| - ((uint32_t)key[ 7] ); - key += 8; - } - - ip = Rcon; - ii = 4 * (ctx->rounds+1); - for (i = words; i> 8)&0xff]<<16; - tmp2|=(uint32_t)aes_sbox[(tmp>>16)&0xff]<<24; - tmp2|=(uint32_t)aes_sbox[(tmp>>24) ]; - tmp=tmp2^(((unsigned int)*ip)<<24); - ip++; - } - - if ((words == 8) && ((i % words) == 4)) - { - tmp2 =(uint32_t)aes_sbox[(tmp )&0xff] ; - tmp2|=(uint32_t)aes_sbox[(tmp>> 8)&0xff]<< 8; - tmp2|=(uint32_t)aes_sbox[(tmp>>16)&0xff]<<16; - tmp2|=(uint32_t)aes_sbox[(tmp>>24) ]<<24; - tmp=tmp2; - } - - W[i]=W[i-words]^tmp; - } - - /* copy the iv across */ - memcpy(ctx->iv, iv, 16); -} - -/** - * Change a key for decryption. - */ -void AES_convert_key(AES_CTX *ctx) -{ - int i; - uint32_t *k,w,t1,t2,t3,t4; - - k = ctx->ks; - k += 4; - - for (i= ctx->rounds*4; i > 4; i--) - { - w= *k; - w = inv_mix_col(w,t1,t2,t3,t4); - *k++ =w; - } -} - -/** - * Encrypt a byte sequence (with a block size 16) using the AES cipher. - */ -void AES_cbc_encrypt(AES_CTX *ctx, const uint8_t *msg, uint8_t *out, int length) -{ - int i; - uint32_t tin[4], tout[4], iv[4]; - - memcpy(iv, ctx->iv, AES_IV_SIZE); - for (i = 0; i < 4; i++) - tout[i] = ntohl(iv[i]); - - for (length -= AES_BLOCKSIZE; length >= 0; length -= AES_BLOCKSIZE) - { - uint32_t msg_32[4]; - uint32_t out_32[4]; - memcpy(msg_32, msg, AES_BLOCKSIZE); - msg += AES_BLOCKSIZE; - - for (i = 0; i < 4; i++) - tin[i] = ntohl(msg_32[i])^tout[i]; - - AES_encrypt(ctx, tin); - - for (i = 0; i < 4; i++) - { - tout[i] = tin[i]; - out_32[i] = htonl(tout[i]); - } - - memcpy(out, out_32, AES_BLOCKSIZE); - out += AES_BLOCKSIZE; - } - - for (i = 0; i < 4; i++) - iv[i] = htonl(tout[i]); - memcpy(ctx->iv, iv, AES_IV_SIZE); -} - -/** - * Decrypt a byte sequence (with a block size 16) using the AES cipher. - */ -void AES_cbc_decrypt(AES_CTX *ctx, const uint8_t *msg, uint8_t *out, int length) -{ - int i; - uint32_t tin[4], xor[4], tout[4], data[4], iv[4]; - - memcpy(iv, ctx->iv, AES_IV_SIZE); - for (i = 0; i < 4; i++) - xor[i] = ntohl(iv[i]); - - for (length -= 16; length >= 0; length -= 16) - { - uint32_t msg_32[4]; - uint32_t out_32[4]; - memcpy(msg_32, msg, AES_BLOCKSIZE); - msg += AES_BLOCKSIZE; - - for (i = 0; i < 4; i++) - { - tin[i] = ntohl(msg_32[i]); - data[i] = tin[i]; - } - - AES_decrypt(ctx, data); - - for (i = 0; i < 4; i++) - { - tout[i] = data[i]^xor[i]; - xor[i] = tin[i]; - out_32[i] = htonl(tout[i]); - } - - memcpy(out, out_32, AES_BLOCKSIZE); - out += AES_BLOCKSIZE; - } - - for (i = 0; i < 4; i++) - iv[i] = htonl(xor[i]); - memcpy(ctx->iv, iv, AES_IV_SIZE); -} - -/** - * Encrypt a single block (16 bytes) of data - */ -static void AES_encrypt(const AES_CTX *ctx, uint32_t *data) -{ - /* To make this code smaller, generate the sbox entries on the fly. - * This will have a really heavy effect upon performance. - */ - uint32_t tmp[4]; - uint32_t tmp1, old_a0, a0, a1, a2, a3, row; - int curr_rnd; - int rounds = ctx->rounds; - const uint32_t *k = ctx->ks; - - /* Pre-round key addition */ - for (row = 0; row < 4; row++) - data[row] ^= *(k++); - - /* Encrypt one block. */ - for (curr_rnd = 0; curr_rnd < rounds; curr_rnd++) - { - /* Perform ByteSub and ShiftRow operations together */ - for (row = 0; row < 4; row++) - { - a0 = (uint32_t)aes_sbox[(data[row%4]>>24)&0xFF]; - a1 = (uint32_t)aes_sbox[(data[(row+1)%4]>>16)&0xFF]; - a2 = (uint32_t)aes_sbox[(data[(row+2)%4]>>8)&0xFF]; - a3 = (uint32_t)aes_sbox[(data[(row+3)%4])&0xFF]; - - /* Perform MixColumn iff not last round */ - if (curr_rnd < (rounds - 1)) - { - tmp1 = a0 ^ a1 ^ a2 ^ a3; - old_a0 = a0; - a0 ^= tmp1 ^ AES_xtime(a0 ^ a1); - a1 ^= tmp1 ^ AES_xtime(a1 ^ a2); - a2 ^= tmp1 ^ AES_xtime(a2 ^ a3); - a3 ^= tmp1 ^ AES_xtime(a3 ^ old_a0); - } - - tmp[row] = ((a0 << 24) | (a1 << 16) | (a2 << 8) | a3); - } - - /* KeyAddition - note that it is vital that this loop is separate from - the MixColumn operation, which must be atomic...*/ - for (row = 0; row < 4; row++) - data[row] = tmp[row] ^ *(k++); - } -} - -/** - * Decrypt a single block (16 bytes) of data - */ -static void AES_decrypt(const AES_CTX *ctx, uint32_t *data) -{ - uint32_t tmp[4]; - uint32_t xt0,xt1,xt2,xt3,xt4,xt5,xt6; - uint32_t a0, a1, a2, a3, row; - int curr_rnd; - int rounds = ctx->rounds; - const uint32_t *k = ctx->ks + ((rounds+1)*4); - - /* pre-round key addition */ - for (row=4; row > 0;row--) - data[row-1] ^= *(--k); - - /* Decrypt one block */ - for (curr_rnd = 0; curr_rnd < rounds; curr_rnd++) - { - /* Perform ByteSub and ShiftRow operations together */ - for (row = 4; row > 0; row--) - { - a0 = aes_isbox[(data[(row+3)%4]>>24)&0xFF]; - a1 = aes_isbox[(data[(row+2)%4]>>16)&0xFF]; - a2 = aes_isbox[(data[(row+1)%4]>>8)&0xFF]; - a3 = aes_isbox[(data[row%4])&0xFF]; - - /* Perform MixColumn iff not last round */ - if (curr_rnd<(rounds-1)) - { - /* The MDS cofefficients (0x09, 0x0B, 0x0D, 0x0E) - are quite large compared to encryption; this - operation slows decryption down noticeably. */ - xt0 = AES_xtime(a0^a1); - xt1 = AES_xtime(a1^a2); - xt2 = AES_xtime(a2^a3); - xt3 = AES_xtime(a3^a0); - xt4 = AES_xtime(xt0^xt1); - xt5 = AES_xtime(xt1^xt2); - xt6 = AES_xtime(xt4^xt5); - - xt0 ^= a1^a2^a3^xt4^xt6; - xt1 ^= a0^a2^a3^xt5^xt6; - xt2 ^= a0^a1^a3^xt4^xt6; - xt3 ^= a0^a1^a2^xt5^xt6; - tmp[row-1] = ((xt0<<24)|(xt1<<16)|(xt2<<8)|xt3); - } - else - tmp[row-1] = ((a0<<24)|(a1<<16)|(a2<<8)|a3); - } - - for (row = 4; row > 0; row--) - data[row-1] = tmp[row-1] ^ *(--k); - } -} diff --git a/user/mpy/lib/axtls/crypto/bigint.c b/user/mpy/lib/axtls/crypto/bigint.c deleted file mode 100644 index c8b9a6a..0000000 --- a/user/mpy/lib/axtls/crypto/bigint.c +++ /dev/null @@ -1,1516 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @defgroup bigint_api Big Integer API - * @brief The bigint implementation as used by the axTLS project. - * - * The bigint library is for RSA encryption/decryption as well as signing. - * This code tries to minimise use of malloc/free by maintaining a small - * cache. A bigint context may maintain state by being made "permanent". - * It be be later released with a bi_depermanent() and bi_free() call. - * - * It supports the following reduction techniques: - * - Classical - * - Barrett - * - Montgomery - * - * It also implements the following: - * - Karatsuba multiplication - * - Squaring - * - Sliding window exponentiation - * - Chinese Remainder Theorem (implemented in rsa.c). - * - * All the algorithms used are pretty standard, and designed for different - * data bus sizes. Negative numbers are not dealt with at all, so a subtraction - * may need to be tested for negativity. - * - * This library steals some ideas from Jef Poskanzer - * - * and GMP . It gets most of its implementation - * detail from "The Handbook of Applied Cryptography" - * - * @{ - */ - -#include -#include -#include -#include -#include -#include "os_port.h" -#include "bigint.h" - -#define V1 v->comps[v->size-1] /**< v1 for division */ -#define V2 v->comps[v->size-2] /**< v2 for division */ -#define U(j) tmp_u->comps[tmp_u->size-j-1] /**< uj for division */ -#define Q(j) quotient->comps[quotient->size-j-1] /**< qj for division */ - -static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bi, comp i); -static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom); -static bigint *alloc(BI_CTX *ctx, int size); -static bigint *trim(bigint *bi); -static void more_comps(bigint *bi, int n); -#if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \ - defined(CONFIG_BIGINT_MONTGOMERY) -static bigint *comp_right_shift(bigint *biR, int num_shifts); -static bigint *comp_left_shift(bigint *biR, int num_shifts); -#endif - -#ifdef CONFIG_BIGINT_CHECK_ON -static void check(const bigint *bi); -#else -#define check(A) /**< disappears in normal production mode */ -#endif - - -/** - * @brief Start a new bigint context. - * @return A bigint context. - */ -BI_CTX *bi_initialize(void) -{ - /* calloc() sets everything to zero */ - BI_CTX *ctx = (BI_CTX *)calloc(1, sizeof(BI_CTX)); - - /* the radix */ - ctx->bi_radix = alloc(ctx, 2); - ctx->bi_radix->comps[0] = 0; - ctx->bi_radix->comps[1] = 1; - bi_permanent(ctx->bi_radix); - return ctx; -} - -/** - * @brief Close the bigint context and free any resources. - * - * Free up any used memory - a check is done if all objects were not - * properly freed. - * @param ctx [in] The bigint session context. - */ -void bi_terminate(BI_CTX *ctx) -{ - bi_depermanent(ctx->bi_radix); - bi_free(ctx, ctx->bi_radix); - - if (ctx->active_count != 0) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("bi_terminate: there were %d un-freed bigints\n", - ctx->active_count); -#endif - abort(); - } - - bi_clear_cache(ctx); - free(ctx); -} - -/** - *@brief Clear the memory cache. - */ -void bi_clear_cache(BI_CTX *ctx) -{ - bigint *p, *pn; - - if (ctx->free_list == NULL) - return; - - for (p = ctx->free_list; p != NULL; p = pn) - { - pn = p->next; - free(p->comps); - free(p); - } - - ctx->free_count = 0; - ctx->free_list = NULL; -} - -/** - * @brief Increment the number of references to this object. - * It does not do a full copy. - * @param bi [in] The bigint to copy. - * @return A reference to the same bigint. - */ -bigint *bi_copy(bigint *bi) -{ - check(bi); - if (bi->refs != PERMANENT) - bi->refs++; - return bi; -} - -/** - * @brief Simply make a bigint object "unfreeable" if bi_free() is called on it. - * - * For this object to be freed, bi_depermanent() must be called. - * @param bi [in] The bigint to be made permanent. - */ -void bi_permanent(bigint *bi) -{ - check(bi); - if (bi->refs != 1) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("bi_permanent: refs was not 1\n"); -#endif - abort(); - } - - bi->refs = PERMANENT; -} - -/** - * @brief Take a permanent object and make it eligible for freedom. - * @param bi [in] The bigint to be made back to temporary. - */ -void bi_depermanent(bigint *bi) -{ - check(bi); - if (bi->refs != PERMANENT) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("bi_depermanent: bigint was not permanent\n"); -#endif - abort(); - } - - bi->refs = 1; -} - -/** - * @brief Free a bigint object so it can be used again. - * - * The memory itself it not actually freed, just tagged as being available - * @param ctx [in] The bigint session context. - * @param bi [in] The bigint to be freed. - */ -void bi_free(BI_CTX *ctx, bigint *bi) -{ - check(bi); - if (bi->refs == PERMANENT) - { - return; - } - - if (--bi->refs > 0) - { - return; - } - - bi->next = ctx->free_list; - ctx->free_list = bi; - ctx->free_count++; - - if (--ctx->active_count < 0) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("bi_free: active_count went negative " - "- double-freed bigint?\n"); -#endif - abort(); - } -} - -/** - * @brief Convert an (unsigned) integer into a bigint. - * @param ctx [in] The bigint session context. - * @param i [in] The (unsigned) integer to be converted. - * - */ -bigint *int_to_bi(BI_CTX *ctx, comp i) -{ - bigint *biR = alloc(ctx, 1); - biR->comps[0] = i; - return biR; -} - -/** - * @brief Do a full copy of the bigint object. - * @param ctx [in] The bigint session context. - * @param bi [in] The bigint object to be copied. - */ -bigint *bi_clone(BI_CTX *ctx, const bigint *bi) -{ - bigint *biR = alloc(ctx, bi->size); - check(bi); - memcpy(biR->comps, bi->comps, bi->size*COMP_BYTE_SIZE); - return biR; -} - -/** - * @brief Perform an addition operation between two bigints. - * @param ctx [in] The bigint session context. - * @param bia [in] A bigint. - * @param bib [in] Another bigint. - * @return The result of the addition. - */ -bigint *bi_add(BI_CTX *ctx, bigint *bia, bigint *bib) -{ - int n; - comp carry = 0; - comp *pa, *pb; - - check(bia); - check(bib); - - n = max(bia->size, bib->size); - more_comps(bia, n+1); - more_comps(bib, n); - pa = bia->comps; - pb = bib->comps; - - do - { - comp sl, rl, cy1; - sl = *pa + *pb++; - rl = sl + carry; - cy1 = sl < *pa; - carry = cy1 | (rl < sl); - *pa++ = rl; - } while (--n != 0); - - *pa = carry; /* do overflow */ - bi_free(ctx, bib); - return trim(bia); -} - -/** - * @brief Perform a subtraction operation between two bigints. - * @param ctx [in] The bigint session context. - * @param bia [in] A bigint. - * @param bib [in] Another bigint. - * @param is_negative [out] If defined, indicates that the result was negative. - * is_negative may be null. - * @return The result of the subtraction. The result is always positive. - */ -bigint *bi_subtract(BI_CTX *ctx, - bigint *bia, bigint *bib, int *is_negative) -{ - int n = bia->size; - comp *pa, *pb, carry = 0; - - check(bia); - check(bib); - - more_comps(bib, n); - pa = bia->comps; - pb = bib->comps; - - do - { - comp sl, rl, cy1; - sl = *pa - *pb++; - rl = sl - carry; - cy1 = sl > *pa; - carry = cy1 | (rl > sl); - *pa++ = rl; - } while (--n != 0); - - if (is_negative) /* indicate a negative result */ - { - *is_negative = carry; - } - - bi_free(ctx, trim(bib)); /* put bib back to the way it was */ - return trim(bia); -} - -/** - * Perform a multiply between a bigint an an (unsigned) integer - */ -static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bia, comp b) -{ - int j = 0, n = bia->size; - bigint *biR = alloc(ctx, n + 1); - comp carry = 0; - comp *r = biR->comps; - comp *a = bia->comps; - - check(bia); - - /* clear things to start with */ - memset(r, 0, ((n+1)*COMP_BYTE_SIZE)); - - do - { - long_comp tmp = *r + (long_comp)a[j]*b + carry; - *r++ = (comp)tmp; /* downsize */ - carry = (comp)(tmp >> COMP_BIT_SIZE); - } while (++j < n); - - *r = carry; - bi_free(ctx, bia); - return trim(biR); -} - -/** - * @brief Does both division and modulo calculations. - * - * Used extensively when doing classical reduction. - * @param ctx [in] The bigint session context. - * @param u [in] A bigint which is the numerator. - * @param v [in] Either the denominator or the modulus depending on the mode. - * @param is_mod [n] Determines if this is a normal division (0) or a reduction - * (1). - * @return The result of the division/reduction. - */ -bigint *bi_divide(BI_CTX *ctx, bigint *u, bigint *v, int is_mod) -{ - int n = v->size, m = u->size-n; - int j = 0, orig_u_size = u->size; - uint8_t mod_offset = ctx->mod_offset; - comp d; - bigint *quotient, *tmp_u; - comp q_dash; - - check(u); - check(v); - - /* if doing reduction and we are < mod, then return mod */ - if (is_mod && bi_compare(v, u) > 0) - { - bi_free(ctx, v); - return u; - } - - quotient = alloc(ctx, m+1); - tmp_u = alloc(ctx, n+1); - v = trim(v); /* make sure we have no leading 0's */ - d = (comp)((long_comp)COMP_RADIX/(V1+1)); - - /* clear things to start with */ - memset(quotient->comps, 0, ((quotient->size)*COMP_BYTE_SIZE)); - - /* normalise */ - if (d > 1) - { - u = bi_int_multiply(ctx, u, d); - - if (is_mod) - { - v = ctx->bi_normalised_mod[mod_offset]; - } - else - { - v = bi_int_multiply(ctx, v, d); - } - } - - if (orig_u_size == u->size) /* new digit position u0 */ - { - more_comps(u, orig_u_size + 1); - } - - do - { - /* get a temporary short version of u */ - memcpy(tmp_u->comps, &u->comps[u->size-n-1-j], (n+1)*COMP_BYTE_SIZE); - - /* calculate q' */ - if (U(0) == V1) - { - q_dash = COMP_RADIX-1; - } - else - { - q_dash = (comp)(((long_comp)U(0)*COMP_RADIX + U(1))/V1); - - if (v->size > 1 && V2) - { - /* we are implementing the following: - if (V2*q_dash > (((U(0)*COMP_RADIX + U(1) - - q_dash*V1)*COMP_RADIX) + U(2))) ... */ - comp inner = (comp)((long_comp)COMP_RADIX*U(0) + U(1) - - (long_comp)q_dash*V1); - if ((long_comp)V2*q_dash > (long_comp)inner*COMP_RADIX + U(2)) - { - q_dash--; - } - } - } - - /* multiply and subtract */ - if (q_dash) - { - int is_negative; - tmp_u = bi_subtract(ctx, tmp_u, - bi_int_multiply(ctx, bi_copy(v), q_dash), &is_negative); - more_comps(tmp_u, n+1); - - Q(j) = q_dash; - - /* add back */ - if (is_negative) - { - Q(j)--; - tmp_u = bi_add(ctx, tmp_u, bi_copy(v)); - - /* lop off the carry */ - tmp_u->size--; - v->size--; - } - } - else - { - Q(j) = 0; - } - - /* copy back to u */ - memcpy(&u->comps[u->size-n-1-j], tmp_u->comps, (n+1)*COMP_BYTE_SIZE); - } while (++j <= m); - - bi_free(ctx, tmp_u); - bi_free(ctx, v); - - if (is_mod) /* get the remainder */ - { - bi_free(ctx, quotient); - return bi_int_divide(ctx, trim(u), d); - } - else /* get the quotient */ - { - bi_free(ctx, u); - return trim(quotient); - } -} - -/* - * Perform an integer divide on a bigint. - */ -static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom) -{ - int i = biR->size - 1; - long_comp r = 0; - - check(biR); - - do - { - r = (r<comps[i]; - biR->comps[i] = (comp)(r / denom); - r %= denom; - } while (--i >= 0); - - return trim(biR); -} - -#ifdef CONFIG_BIGINT_MONTGOMERY -/** - * There is a need for the value of integer N' such that B^-1(B-1)-N^-1N'=1, - * where B^-1(B-1) mod N=1. Actually, only the least significant part of - * N' is needed, hence the definition N0'=N' mod b. We reproduce below the - * simple algorithm from an article by Dusse and Kaliski to efficiently - * find N0' from N0 and b */ -static comp modular_inverse(bigint *bim) -{ - int i; - comp t = 1; - comp two_2_i_minus_1 = 2; /* 2^(i-1) */ - long_comp two_2_i = 4; /* 2^i */ - comp N = bim->comps[0]; - - for (i = 2; i <= COMP_BIT_SIZE; i++) - { - if ((long_comp)N*t%two_2_i >= two_2_i_minus_1) - { - t += two_2_i_minus_1; - } - - two_2_i_minus_1 <<= 1; - two_2_i <<= 1; - } - - return (comp)(COMP_RADIX-t); -} -#endif - -#if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \ - defined(CONFIG_BIGINT_MONTGOMERY) -/** - * Take each component and shift down (in terms of components) - */ -static bigint *comp_right_shift(bigint *biR, int num_shifts) -{ - int i = biR->size-num_shifts; - comp *x = biR->comps; - comp *y = &biR->comps[num_shifts]; - - check(biR); - - if (i <= 0) /* have we completely right shifted? */ - { - biR->comps[0] = 0; /* return 0 */ - biR->size = 1; - return biR; - } - - do - { - *x++ = *y++; - } while (--i > 0); - - biR->size -= num_shifts; - return biR; -} - -/** - * Take each component and shift it up (in terms of components) - */ -static bigint *comp_left_shift(bigint *biR, int num_shifts) -{ - int i = biR->size-1; - comp *x, *y; - - check(biR); - - if (num_shifts <= 0) - { - return biR; - } - - more_comps(biR, biR->size + num_shifts); - - x = &biR->comps[i+num_shifts]; - y = &biR->comps[i]; - - do - { - *x-- = *y--; - } while (i--); - - memset(biR->comps, 0, num_shifts*COMP_BYTE_SIZE); /* zero LS comps */ - return biR; -} -#endif - -/** - * @brief Allow a binary sequence to be imported as a bigint. - * @param ctx [in] The bigint session context. - * @param data [in] The data to be converted. - * @param size [in] The number of bytes of data. - * @return A bigint representing this data. - */ -bigint *bi_import(BI_CTX *ctx, const uint8_t *data, int size) -{ - bigint *biR = alloc(ctx, (size+COMP_BYTE_SIZE-1)/COMP_BYTE_SIZE); - int i, j = 0, offset = 0; - - memset(biR->comps, 0, biR->size*COMP_BYTE_SIZE); - - for (i = size-1; i >= 0; i--) - { - biR->comps[offset] += data[i] << (j*8); - - if (++j == COMP_BYTE_SIZE) - { - j = 0; - offset ++; - } - } - - return trim(biR); -} - -#ifdef CONFIG_SSL_FULL_MODE -/** - * @brief The testharness uses this code to import text hex-streams and - * convert them into bigints. - * @param ctx [in] The bigint session context. - * @param data [in] A string consisting of hex characters. The characters must - * be in upper case. - * @return A bigint representing this data. - */ -bigint *bi_str_import(BI_CTX *ctx, const char *data) -{ - int size = strlen(data); - bigint *biR = alloc(ctx, (size+COMP_NUM_NIBBLES-1)/COMP_NUM_NIBBLES); - int i, j = 0, offset = 0; - memset(biR->comps, 0, biR->size*COMP_BYTE_SIZE); - - for (i = size-1; i >= 0; i--) - { - int num = (data[i] <= '9') ? (data[i] - '0') : (data[i] - 'A' + 10); - biR->comps[offset] += num << (j*4); - - if (++j == COMP_NUM_NIBBLES) - { - j = 0; - offset ++; - } - } - - return biR; -} - -void bi_print(const char *label, bigint *x) -{ - int i, j; - - if (x == NULL) - { - printf("%s: (null)\n", label); - return; - } - - printf("%s: (size %d)\n", label, x->size); - for (i = x->size-1; i >= 0; i--) - { - for (j = COMP_NUM_NIBBLES-1; j >= 0; j--) - { - comp mask = 0x0f << (j*4); - comp num = (x->comps[i] & mask) >> (j*4); - putc((num <= 9) ? (num + '0') : (num + 'A' - 10), stdout); - } - } - - printf("\n"); -} -#endif - -/** - * @brief Take a bigint and convert it into a byte sequence. - * - * This is useful after a decrypt operation. - * @param ctx [in] The bigint session context. - * @param x [in] The bigint to be converted. - * @param data [out] The converted data as a byte stream. - * @param size [in] The maximum size of the byte stream. Unused bytes will be - * zeroed. - */ -void bi_export(BI_CTX *ctx, bigint *x, uint8_t *data, int size) -{ - int i, j, k = size-1; - - check(x); - memset(data, 0, size); /* ensure all leading 0's are cleared */ - - for (i = 0; i < x->size; i++) - { - for (j = 0; j < COMP_BYTE_SIZE; j++) - { - comp mask = 0xff << (j*8); - int num = (x->comps[i] & mask) >> (j*8); - data[k--] = num; - - if (k < 0) - { - goto buf_done; - } - } - } -buf_done: - - bi_free(ctx, x); -} - -/** - * @brief Pre-calculate some of the expensive steps in reduction. - * - * This function should only be called once (normally when a session starts). - * When the session is over, bi_free_mod() should be called. bi_mod_power() - * relies on this function being called. - * @param ctx [in] The bigint session context. - * @param bim [in] The bigint modulus that will be used. - * @param mod_offset [in] There are three moduluii that can be stored - the - * standard modulus, and its two primes p and q. This offset refers to which - * modulus we are referring to. - * @see bi_free_mod(), bi_mod_power(). - */ -void bi_set_mod(BI_CTX *ctx, bigint *bim, int mod_offset) -{ - int k = bim->size; - comp d = (comp)((long_comp)COMP_RADIX/(bim->comps[k-1]+1)); -#ifdef CONFIG_BIGINT_MONTGOMERY - bigint *R, *R2; -#endif - - ctx->bi_mod[mod_offset] = bim; - bi_permanent(ctx->bi_mod[mod_offset]); - ctx->bi_normalised_mod[mod_offset] = bi_int_multiply(ctx, bim, d); - bi_permanent(ctx->bi_normalised_mod[mod_offset]); - -#if defined(CONFIG_BIGINT_MONTGOMERY) - /* set montgomery variables */ - R = comp_left_shift(bi_clone(ctx, ctx->bi_radix), k-1); /* R */ - R2 = comp_left_shift(bi_clone(ctx, ctx->bi_radix), k*2-1); /* R^2 */ - ctx->bi_RR_mod_m[mod_offset] = bi_mod(ctx, R2); /* R^2 mod m */ - ctx->bi_R_mod_m[mod_offset] = bi_mod(ctx, R); /* R mod m */ - - bi_permanent(ctx->bi_RR_mod_m[mod_offset]); - bi_permanent(ctx->bi_R_mod_m[mod_offset]); - - ctx->N0_dash[mod_offset] = modular_inverse(ctx->bi_mod[mod_offset]); - -#elif defined (CONFIG_BIGINT_BARRETT) - ctx->bi_mu[mod_offset] = - bi_divide(ctx, comp_left_shift( - bi_clone(ctx, ctx->bi_radix), k*2-1), ctx->bi_mod[mod_offset], 0); - bi_permanent(ctx->bi_mu[mod_offset]); -#endif -} - -/** - * @brief Used when cleaning various bigints at the end of a session. - * @param ctx [in] The bigint session context. - * @param mod_offset [in] The offset to use. - * @see bi_set_mod(). - */ -void bi_free_mod(BI_CTX *ctx, int mod_offset) -{ - bi_depermanent(ctx->bi_mod[mod_offset]); - bi_free(ctx, ctx->bi_mod[mod_offset]); -#if defined (CONFIG_BIGINT_MONTGOMERY) - bi_depermanent(ctx->bi_RR_mod_m[mod_offset]); - bi_depermanent(ctx->bi_R_mod_m[mod_offset]); - bi_free(ctx, ctx->bi_RR_mod_m[mod_offset]); - bi_free(ctx, ctx->bi_R_mod_m[mod_offset]); -#elif defined(CONFIG_BIGINT_BARRETT) - bi_depermanent(ctx->bi_mu[mod_offset]); - bi_free(ctx, ctx->bi_mu[mod_offset]); -#endif - bi_depermanent(ctx->bi_normalised_mod[mod_offset]); - bi_free(ctx, ctx->bi_normalised_mod[mod_offset]); -} - -/** - * Perform a standard multiplication between two bigints. - * - * Barrett reduction has no need for some parts of the product, so ignore bits - * of the multiply. This routine gives Barrett its big performance - * improvements over Classical/Montgomery reduction methods. - */ -static bigint *regular_multiply(BI_CTX *ctx, bigint *bia, bigint *bib, - int inner_partial, int outer_partial) -{ - int i = 0, j; - int n = bia->size; - int t = bib->size; - bigint *biR = alloc(ctx, n + t); - comp *sr = biR->comps; - comp *sa = bia->comps; - comp *sb = bib->comps; - - check(bia); - check(bib); - - /* clear things to start with */ - memset(biR->comps, 0, ((n+t)*COMP_BYTE_SIZE)); - - do - { - long_comp tmp; - comp carry = 0; - int r_index = i; - j = 0; - - if (outer_partial && outer_partial-i > 0 && outer_partial < n) - { - r_index = outer_partial-1; - j = outer_partial-i-1; - } - - do - { - if (inner_partial && r_index >= inner_partial) - { - break; - } - - tmp = sr[r_index] + ((long_comp)sa[j])*sb[i] + carry; - sr[r_index++] = (comp)tmp; /* downsize */ - carry = tmp >> COMP_BIT_SIZE; - } while (++j < n); - - sr[r_index] = carry; - } while (++i < t); - - bi_free(ctx, bia); - bi_free(ctx, bib); - return trim(biR); -} - -#ifdef CONFIG_BIGINT_KARATSUBA -/* - * Karatsuba improves on regular multiplication due to only 3 multiplications - * being done instead of 4. The additional additions/subtractions are O(N) - * rather than O(N^2) and so for big numbers it saves on a few operations - */ -static bigint *karatsuba(BI_CTX *ctx, bigint *bia, bigint *bib, int is_square) -{ - bigint *x0, *x1; - bigint *p0, *p1, *p2; - int m; - - if (is_square) - { - m = (bia->size + 1)/2; - } - else - { - m = (max(bia->size, bib->size) + 1)/2; - } - - x0 = bi_clone(ctx, bia); - x0->size = m; - x1 = bi_clone(ctx, bia); - comp_right_shift(x1, m); - bi_free(ctx, bia); - - /* work out the 3 partial products */ - if (is_square) - { - p0 = bi_square(ctx, bi_copy(x0)); - p2 = bi_square(ctx, bi_copy(x1)); - p1 = bi_square(ctx, bi_add(ctx, x0, x1)); - } - else /* normal multiply */ - { - bigint *y0, *y1; - y0 = bi_clone(ctx, bib); - y0->size = m; - y1 = bi_clone(ctx, bib); - comp_right_shift(y1, m); - bi_free(ctx, bib); - - p0 = bi_multiply(ctx, bi_copy(x0), bi_copy(y0)); - p2 = bi_multiply(ctx, bi_copy(x1), bi_copy(y1)); - p1 = bi_multiply(ctx, bi_add(ctx, x0, x1), bi_add(ctx, y0, y1)); - } - - p1 = bi_subtract(ctx, - bi_subtract(ctx, p1, bi_copy(p2), NULL), bi_copy(p0), NULL); - - comp_left_shift(p1, m); - comp_left_shift(p2, 2*m); - return bi_add(ctx, p1, bi_add(ctx, p0, p2)); -} -#endif - -/** - * @brief Perform a multiplication operation between two bigints. - * @param ctx [in] The bigint session context. - * @param bia [in] A bigint. - * @param bib [in] Another bigint. - * @return The result of the multiplication. - */ -bigint *bi_multiply(BI_CTX *ctx, bigint *bia, bigint *bib) -{ - check(bia); - check(bib); - -#ifdef CONFIG_BIGINT_KARATSUBA - if (min(bia->size, bib->size) < MUL_KARATSUBA_THRESH) - { - return regular_multiply(ctx, bia, bib, 0, 0); - } - - return karatsuba(ctx, bia, bib, 0); -#else - return regular_multiply(ctx, bia, bib, 0, 0); -#endif -} - -#ifdef CONFIG_BIGINT_SQUARE -/* - * Perform the actual square operion. It takes into account overflow. - */ -static bigint *regular_square(BI_CTX *ctx, bigint *bi) -{ - int t = bi->size; - int i = 0, j; - bigint *biR = alloc(ctx, t*2+1); - comp *w = biR->comps; - comp *x = bi->comps; - long_comp carry; - memset(w, 0, biR->size*COMP_BYTE_SIZE); - - do - { - long_comp tmp = w[2*i] + (long_comp)x[i]*x[i]; - w[2*i] = (comp)tmp; - carry = tmp >> COMP_BIT_SIZE; - - for (j = i+1; j < t; j++) - { - uint8_t c = 0; - long_comp xx = (long_comp)x[i]*x[j]; - if ((COMP_MAX-xx) < xx) - c = 1; - - tmp = (xx<<1); - - if ((COMP_MAX-tmp) < w[i+j]) - c = 1; - - tmp += w[i+j]; - - if ((COMP_MAX-tmp) < carry) - c = 1; - - tmp += carry; - w[i+j] = (comp)tmp; - carry = tmp >> COMP_BIT_SIZE; - - if (c) - carry += COMP_RADIX; - } - - tmp = w[i+t] + carry; - w[i+t] = (comp)tmp; - w[i+t+1] = tmp >> COMP_BIT_SIZE; - } while (++i < t); - - bi_free(ctx, bi); - return trim(biR); -} - -/** - * @brief Perform a square operation on a bigint. - * @param ctx [in] The bigint session context. - * @param bia [in] A bigint. - * @return The result of the multiplication. - */ -bigint *bi_square(BI_CTX *ctx, bigint *bia) -{ - check(bia); - -#ifdef CONFIG_BIGINT_KARATSUBA - if (bia->size < SQU_KARATSUBA_THRESH) - { - return regular_square(ctx, bia); - } - - return karatsuba(ctx, bia, NULL, 1); -#else - return regular_square(ctx, bia); -#endif -} -#endif - -/** - * @brief Compare two bigints. - * @param bia [in] A bigint. - * @param bib [in] Another bigint. - * @return -1 if smaller, 1 if larger and 0 if equal. - */ -int bi_compare(bigint *bia, bigint *bib) -{ - int r, i; - - check(bia); - check(bib); - - if (bia->size > bib->size) - r = 1; - else if (bia->size < bib->size) - r = -1; - else - { - comp *a = bia->comps; - comp *b = bib->comps; - - /* Same number of components. Compare starting from the high end - * and working down. */ - r = 0; - i = bia->size - 1; - - do - { - if (a[i] > b[i]) - { - r = 1; - break; - } - else if (a[i] < b[i]) - { - r = -1; - break; - } - } while (--i >= 0); - } - - return r; -} - -/* - * Allocate and zero more components. Does not consume bi. - */ -static void more_comps(bigint *bi, int n) -{ - if (n > bi->max_comps) - { - bi->max_comps = max(bi->max_comps * 2, n); - bi->comps = (comp*)realloc(bi->comps, bi->max_comps * COMP_BYTE_SIZE); - } - - if (n > bi->size) - { - memset(&bi->comps[bi->size], 0, (n-bi->size)*COMP_BYTE_SIZE); - } - - bi->size = n; -} - -/* - * Make a new empty bigint. It may just use an old one if one is available. - * Otherwise get one off the heap. - */ -static bigint *alloc(BI_CTX *ctx, int size) -{ - bigint *biR; - - /* Can we recycle an old bigint? */ - if (ctx->free_list != NULL) - { - biR = ctx->free_list; - ctx->free_list = biR->next; - ctx->free_count--; - - if (biR->refs != 0) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("alloc: refs was not 0\n"); -#endif - abort(); /* create a stack trace from a core dump */ - } - - more_comps(biR, size); - } - else - { - /* No free bigints available - create a new one. */ - biR = (bigint *)malloc(sizeof(bigint)); - biR->comps = (comp*)malloc(size * COMP_BYTE_SIZE); - biR->max_comps = size; /* give some space to spare */ - } - - biR->size = size; - biR->refs = 1; - biR->next = NULL; - ctx->active_count++; - return biR; -} - -/* - * Work out the highest '1' bit in an exponent. Used when doing sliding-window - * exponentiation. - */ -static int find_max_exp_index(bigint *biexp) -{ - int i = COMP_BIT_SIZE-1; - comp shift = COMP_RADIX/2; - comp test = biexp->comps[biexp->size-1]; /* assume no leading zeroes */ - - check(biexp); - - do - { - if (test & shift) - { - return i+(biexp->size-1)*COMP_BIT_SIZE; - } - - shift >>= 1; - } while (i-- != 0); - - return -1; /* error - must have been a leading 0 */ -} - -/* - * Is a particular bit is an exponent 1 or 0? Used when doing sliding-window - * exponentiation. - */ -static int exp_bit_is_one(bigint *biexp, int offset) -{ - comp test = biexp->comps[offset / COMP_BIT_SIZE]; - int num_shifts = offset % COMP_BIT_SIZE; - comp shift = 1; - int i; - - check(biexp); - - for (i = 0; i < num_shifts; i++) - { - shift <<= 1; - } - - return (test & shift) != 0; -} - -#ifdef CONFIG_BIGINT_CHECK_ON -/* - * Perform a sanity check on bi. - */ -static void check(const bigint *bi) -{ - if (bi->refs <= 0) - { - printf("check: zero or negative refs in bigint\n"); - abort(); - } - - if (bi->next != NULL) - { - printf("check: attempt to use a bigint from " - "the free list\n"); - abort(); - } -} -#endif - -/* - * Delete any leading 0's (and allow for 0). - */ -static bigint *trim(bigint *bi) -{ - check(bi); - - while (bi->comps[bi->size-1] == 0 && bi->size > 1) - { - bi->size--; - } - - return bi; -} - -#if defined(CONFIG_BIGINT_MONTGOMERY) -/** - * @brief Perform a single montgomery reduction. - * @param ctx [in] The bigint session context. - * @param bixy [in] A bigint. - * @return The result of the montgomery reduction. - */ -bigint *bi_mont(BI_CTX *ctx, bigint *bixy) -{ - int i = 0, n; - uint8_t mod_offset = ctx->mod_offset; - bigint *bim = ctx->bi_mod[mod_offset]; - comp mod_inv = ctx->N0_dash[mod_offset]; - - check(bixy); - - if (ctx->use_classical) /* just use classical instead */ - { - return bi_mod(ctx, bixy); - } - - n = bim->size; - - do - { - bixy = bi_add(ctx, bixy, comp_left_shift( - bi_int_multiply(ctx, bim, bixy->comps[i]*mod_inv), i)); - } while (++i < n); - - comp_right_shift(bixy, n); - - if (bi_compare(bixy, bim) >= 0) - { - bixy = bi_subtract(ctx, bixy, bim, NULL); - } - - return bixy; -} - -#elif defined(CONFIG_BIGINT_BARRETT) -/* - * Stomp on the most significant components to give the illusion of a "mod base - * radix" operation - */ -static bigint *comp_mod(bigint *bi, int mod) -{ - check(bi); - - if (bi->size > mod) - { - bi->size = mod; - } - - return bi; -} - -/** - * @brief Perform a single Barrett reduction. - * @param ctx [in] The bigint session context. - * @param bi [in] A bigint. - * @return The result of the Barrett reduction. - */ -bigint *bi_barrett(BI_CTX *ctx, bigint *bi) -{ - bigint *q1, *q2, *q3, *r1, *r2, *r; - uint8_t mod_offset = ctx->mod_offset; - bigint *bim = ctx->bi_mod[mod_offset]; - int k = bim->size; - - check(bi); - check(bim); - - /* use Classical method instead - Barrett cannot help here */ - if (bi->size > k*2) - { - return bi_mod(ctx, bi); - } - - q1 = comp_right_shift(bi_clone(ctx, bi), k-1); - - /* do outer partial multiply */ - q2 = regular_multiply(ctx, q1, ctx->bi_mu[mod_offset], 0, k-1); - q3 = comp_right_shift(q2, k+1); - r1 = comp_mod(bi, k+1); - - /* do inner partial multiply */ - r2 = comp_mod(regular_multiply(ctx, q3, bim, k+1, 0), k+1); - r = bi_subtract(ctx, r1, r2, NULL); - - /* if (r >= m) r = r - m; */ - if (bi_compare(r, bim) >= 0) - { - r = bi_subtract(ctx, r, bim, NULL); - } - - return r; -} -#endif /* CONFIG_BIGINT_BARRETT */ - -#ifdef CONFIG_BIGINT_SLIDING_WINDOW -/* - * Work out g1, g3, g5, g7... etc for the sliding-window algorithm - */ -static void precompute_slide_window(BI_CTX *ctx, int window, bigint *g1) -{ - int k = 1, i; - bigint *g2; - - for (i = 0; i < window-1; i++) /* compute 2^(window-1) */ - { - k <<= 1; - } - - ctx->g = (bigint **)malloc(k*sizeof(bigint *)); - ctx->g[0] = bi_clone(ctx, g1); - bi_permanent(ctx->g[0]); - g2 = bi_residue(ctx, bi_square(ctx, ctx->g[0])); /* g^2 */ - - for (i = 1; i < k; i++) - { - ctx->g[i] = bi_residue(ctx, bi_multiply(ctx, ctx->g[i-1], bi_copy(g2))); - bi_permanent(ctx->g[i]); - } - - bi_free(ctx, g2); - ctx->window = k; -} -#endif - -/** - * @brief Perform a modular exponentiation. - * - * This function requires bi_set_mod() to have been called previously. This is - * one of the optimisations used for performance. - * @param ctx [in] The bigint session context. - * @param bi [in] The bigint on which to perform the mod power operation. - * @param biexp [in] The bigint exponent. - * @return The result of the mod exponentiation operation - * @see bi_set_mod(). - */ -bigint *bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp) -{ - int i = find_max_exp_index(biexp), j, window_size = 1; - bigint *biR = int_to_bi(ctx, 1); - -#if defined(CONFIG_BIGINT_MONTGOMERY) - uint8_t mod_offset = ctx->mod_offset; - if (!ctx->use_classical) - { - /* preconvert */ - bi = bi_mont(ctx, - bi_multiply(ctx, bi, ctx->bi_RR_mod_m[mod_offset])); /* x' */ - bi_free(ctx, biR); - biR = ctx->bi_R_mod_m[mod_offset]; /* A */ - } -#endif - - check(bi); - check(biexp); - -#ifdef CONFIG_BIGINT_SLIDING_WINDOW - for (j = i; j > 32; j /= 5) /* work out an optimum size */ - window_size++; - - /* work out the slide constants */ - precompute_slide_window(ctx, window_size, bi); -#else /* just one constant */ - ctx->g = (bigint **)malloc(sizeof(bigint *)); - ctx->g[0] = bi_clone(ctx, bi); - ctx->window = 1; - bi_permanent(ctx->g[0]); -#endif - - /* if sliding-window is off, then only one bit will be done at a time and - * will reduce to standard left-to-right exponentiation */ - do - { -#ifdef __ets__ - void ets_loop_iter(void); - ets_loop_iter(); -#endif - if (exp_bit_is_one(biexp, i)) - { - int l = i-window_size+1; - int part_exp = 0; - - if (l < 0) /* LSB of exponent will always be 1 */ - l = 0; - else - { - while (exp_bit_is_one(biexp, l) == 0) - l++; /* go back up */ - } - - /* build up the section of the exponent */ - for (j = i; j >= l; j--) - { - biR = bi_residue(ctx, bi_square(ctx, biR)); - if (exp_bit_is_one(biexp, j)) - part_exp++; - - if (j != l) - part_exp <<= 1; - } - - part_exp = (part_exp-1)/2; /* adjust for array */ - biR = bi_residue(ctx, bi_multiply(ctx, biR, ctx->g[part_exp])); - i = l-1; - } - else /* square it */ - { - biR = bi_residue(ctx, bi_square(ctx, biR)); - i--; - } - } while (i >= 0); - - /* cleanup */ - for (i = 0; i < ctx->window; i++) - { - bi_depermanent(ctx->g[i]); - bi_free(ctx, ctx->g[i]); - } - - free(ctx->g); - bi_free(ctx, bi); - bi_free(ctx, biexp); -#if defined CONFIG_BIGINT_MONTGOMERY - return ctx->use_classical ? biR : bi_mont(ctx, biR); /* convert back */ -#else /* CONFIG_BIGINT_CLASSICAL or CONFIG_BIGINT_BARRETT */ - return biR; -#endif -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION -/** - * @brief Perform a modular exponentiation using a temporary modulus. - * - * We need this function to check the signatures of certificates. The modulus - * of this function is temporary as it's just used for authentication. - * @param ctx [in] The bigint session context. - * @param bi [in] The bigint to perform the exp/mod. - * @param bim [in] The temporary modulus. - * @param biexp [in] The bigint exponent. - * @return The result of the mod exponentiation operation - * @see bi_set_mod(). - */ -bigint *bi_mod_power2(BI_CTX *ctx, bigint *bi, bigint *bim, bigint *biexp) -{ - bigint *biR, *tmp_biR; - - /* Set up a temporary bigint context and transfer what we need between - * them. We need to do this since we want to keep the original modulus - * which is already in this context. This operation is only called when - * doing peer verification, and so is not expensive :-) */ - BI_CTX *tmp_ctx = bi_initialize(); - bi_set_mod(tmp_ctx, bi_clone(tmp_ctx, bim), BIGINT_M_OFFSET); - tmp_biR = bi_mod_power(tmp_ctx, - bi_clone(tmp_ctx, bi), - bi_clone(tmp_ctx, biexp)); - biR = bi_clone(ctx, tmp_biR); - bi_free(tmp_ctx, tmp_biR); - bi_free_mod(tmp_ctx, BIGINT_M_OFFSET); - bi_terminate(tmp_ctx); - - bi_free(ctx, bi); - bi_free(ctx, bim); - bi_free(ctx, biexp); - return biR; -} -#endif - -#ifdef CONFIG_BIGINT_CRT -/** - * @brief Use the Chinese Remainder Theorem to quickly perform RSA decrypts. - * - * @param ctx [in] The bigint session context. - * @param bi [in] The bigint to perform the exp/mod. - * @param dP [in] CRT's dP bigint - * @param dQ [in] CRT's dQ bigint - * @param p [in] CRT's p bigint - * @param q [in] CRT's q bigint - * @param qInv [in] CRT's qInv bigint - * @return The result of the CRT operation - */ -bigint *bi_crt(BI_CTX *ctx, bigint *bi, - bigint *dP, bigint *dQ, - bigint *p, bigint *q, bigint *qInv) -{ - bigint *m1, *m2, *h; - - /* Montgomery has a condition the 0 < x, y < m and these products violate - * that condition. So disable Montgomery when using CRT */ -#if defined(CONFIG_BIGINT_MONTGOMERY) - ctx->use_classical = 1; -#endif - ctx->mod_offset = BIGINT_P_OFFSET; - m1 = bi_mod_power(ctx, bi_copy(bi), dP); - - ctx->mod_offset = BIGINT_Q_OFFSET; - m2 = bi_mod_power(ctx, bi, dQ); - - h = bi_subtract(ctx, bi_add(ctx, m1, p), bi_copy(m2), NULL); - h = bi_multiply(ctx, h, qInv); - ctx->mod_offset = BIGINT_P_OFFSET; - h = bi_residue(ctx, h); -#if defined(CONFIG_BIGINT_MONTGOMERY) - ctx->use_classical = 0; /* reset for any further operation */ -#endif - return bi_add(ctx, m2, bi_multiply(ctx, q, h)); -} -#endif -/** @} */ diff --git a/user/mpy/lib/axtls/crypto/bigint.h b/user/mpy/lib/axtls/crypto/bigint.h deleted file mode 100644 index 2966a3e..0000000 --- a/user/mpy/lib/axtls/crypto/bigint.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BIGINT_HEADER -#define BIGINT_HEADER - -#include "crypto.h" - -BI_CTX *bi_initialize(void); -void bi_terminate(BI_CTX *ctx); -void bi_permanent(bigint *bi); -void bi_depermanent(bigint *bi); -void bi_clear_cache(BI_CTX *ctx); -void bi_free(BI_CTX *ctx, bigint *bi); -bigint *bi_copy(bigint *bi); -bigint *bi_clone(BI_CTX *ctx, const bigint *bi); -void bi_export(BI_CTX *ctx, bigint *bi, uint8_t *data, int size); -bigint *bi_import(BI_CTX *ctx, const uint8_t *data, int len); -bigint *int_to_bi(BI_CTX *ctx, comp i); - -/* the functions that actually do something interesting */ -bigint *bi_add(BI_CTX *ctx, bigint *bia, bigint *bib); -bigint *bi_subtract(BI_CTX *ctx, bigint *bia, - bigint *bib, int *is_negative); -bigint *bi_divide(BI_CTX *ctx, bigint *bia, bigint *bim, int is_mod); -bigint *bi_multiply(BI_CTX *ctx, bigint *bia, bigint *bib); -bigint *bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp); -bigint *bi_mod_power2(BI_CTX *ctx, bigint *bi, bigint *bim, bigint *biexp); -int bi_compare(bigint *bia, bigint *bib); -void bi_set_mod(BI_CTX *ctx, bigint *bim, int mod_offset); -void bi_free_mod(BI_CTX *ctx, int mod_offset); - -#ifdef CONFIG_SSL_FULL_MODE -void bi_print(const char *label, bigint *bi); -bigint *bi_str_import(BI_CTX *ctx, const char *data); -#endif - -/** - * @def bi_mod - * Find the residue of B. bi_set_mod() must be called before hand. - */ -#define bi_mod(A, B) bi_divide(A, B, ctx->bi_mod[ctx->mod_offset], 1) - -/** - * bi_residue() is technically the same as bi_mod(), but it uses the - * appropriate reduction technique (which is bi_mod() when doing classical - * reduction). - */ -#if defined(CONFIG_BIGINT_MONTGOMERY) -#define bi_residue(A, B) bi_mont(A, B) -bigint *bi_mont(BI_CTX *ctx, bigint *bixy); -#elif defined(CONFIG_BIGINT_BARRETT) -#define bi_residue(A, B) bi_barrett(A, B) -bigint *bi_barrett(BI_CTX *ctx, bigint *bi); -#else /* if defined(CONFIG_BIGINT_CLASSICAL) */ -#define bi_residue(A, B) bi_mod(A, B) -#endif - -#ifdef CONFIG_BIGINT_SQUARE -bigint *bi_square(BI_CTX *ctx, bigint *bi); -#else -#define bi_square(A, B) bi_multiply(A, bi_copy(B), B) -#endif - -#ifdef CONFIG_BIGINT_CRT -bigint *bi_crt(BI_CTX *ctx, bigint *bi, - bigint *dP, bigint *dQ, - bigint *p, bigint *q, - bigint *qInv); -#endif - -#endif diff --git a/user/mpy/lib/axtls/crypto/bigint_impl.h b/user/mpy/lib/axtls/crypto/bigint_impl.h deleted file mode 100644 index fef6e03..0000000 --- a/user/mpy/lib/axtls/crypto/bigint_impl.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BIGINT_IMPL_HEADER -#define BIGINT_IMPL_HEADER - -/* Maintain a number of precomputed variables when doing reduction */ -#define BIGINT_M_OFFSET 0 /**< Normal modulo offset. */ -#ifdef CONFIG_BIGINT_CRT -#define BIGINT_P_OFFSET 1 /**< p modulo offset. */ -#define BIGINT_Q_OFFSET 2 /**< q module offset. */ -#define BIGINT_NUM_MODS 3 /**< The number of modulus constants used. */ -#else -#define BIGINT_NUM_MODS 1 -#endif - -/* Architecture specific functions for big ints */ -#if defined(CONFIG_INTEGER_8BIT) -#define COMP_RADIX 256U /**< Max component + 1 */ -#define COMP_MAX 0xFFFFU/**< (Max dbl comp -1) */ -#define COMP_BIT_SIZE 8 /**< Number of bits in a component. */ -#define COMP_BYTE_SIZE 1 /**< Number of bytes in a component. */ -#define COMP_NUM_NIBBLES 2 /**< Used For diagnostics only. */ -typedef uint8_t comp; /**< A single precision component. */ -typedef uint16_t long_comp; /**< A double precision component. */ -typedef int16_t slong_comp; /**< A signed double precision component. */ -#elif defined(CONFIG_INTEGER_16BIT) -#define COMP_RADIX 65536U /**< Max component + 1 */ -#define COMP_MAX 0xFFFFFFFFU/**< (Max dbl comp -1) */ -#define COMP_BIT_SIZE 16 /**< Number of bits in a component. */ -#define COMP_BYTE_SIZE 2 /**< Number of bytes in a component. */ -#define COMP_NUM_NIBBLES 4 /**< Used For diagnostics only. */ -typedef uint16_t comp; /**< A single precision component. */ -typedef uint32_t long_comp; /**< A double precision component. */ -typedef int32_t slong_comp; /**< A signed double precision component. */ -#else /* regular 32 bit */ -#ifdef WIN32 -#define COMP_RADIX 4294967296i64 -#define COMP_MAX 0xFFFFFFFFFFFFFFFFui64 -#else -#define COMP_RADIX 4294967296ULL /**< Max component + 1 */ -#define COMP_MAX 0xFFFFFFFFFFFFFFFFULL/**< (Max dbl comp -1) */ -#endif -#define COMP_BIT_SIZE 32 /**< Number of bits in a component. */ -#define COMP_BYTE_SIZE 4 /**< Number of bytes in a component. */ -#define COMP_NUM_NIBBLES 8 /**< Used For diagnostics only. */ -typedef uint32_t comp; /**< A single precision component. */ -typedef uint64_t long_comp; /**< A double precision component. */ -typedef int64_t slong_comp; /**< A signed double precision component. */ -#endif - -/** - * @struct _bigint - * @brief A big integer basic object - */ -struct _bigint -{ - struct _bigint* next; /**< The next bigint in the cache. */ - short size; /**< The number of components in this bigint. */ - short max_comps; /**< The heapsize allocated for this bigint */ - int refs; /**< An internal reference count. */ - comp* comps; /**< A ptr to the actual component data */ -}; - -typedef struct _bigint bigint; /**< An alias for _bigint */ - -/** - * Maintains the state of the cache, and a number of variables used in - * reduction. - */ -typedef struct /**< A big integer "session" context. */ -{ - bigint *active_list; /**< Bigints currently used. */ - bigint *free_list; /**< Bigints not used. */ - bigint *bi_radix; /**< The radix used. */ - bigint *bi_mod[BIGINT_NUM_MODS]; /**< modulus */ - -#if defined(CONFIG_BIGINT_MONTGOMERY) - bigint *bi_RR_mod_m[BIGINT_NUM_MODS]; /**< R^2 mod m */ - bigint *bi_R_mod_m[BIGINT_NUM_MODS]; /**< R mod m */ - comp N0_dash[BIGINT_NUM_MODS]; -#elif defined(CONFIG_BIGINT_BARRETT) - bigint *bi_mu[BIGINT_NUM_MODS]; /**< Storage for mu */ -#endif - bigint *bi_normalised_mod[BIGINT_NUM_MODS]; /**< Normalised mod storage. */ - bigint **g; /**< Used by sliding-window. */ - int window; /**< The size of the sliding window */ - int active_count; /**< Number of active bigints. */ - int free_count; /**< Number of free bigints. */ - -#ifdef CONFIG_BIGINT_MONTGOMERY - uint8_t use_classical; /**< Use classical reduction. */ -#endif - uint8_t mod_offset; /**< The mod offset we are using */ -} BI_CTX; - -#ifndef WIN32 -#define max(a,b) ((a)>(b)?(a):(b)) /**< Find the maximum of 2 numbers. */ -#define min(a,b) ((a)<(b)?(a):(b)) /**< Find the minimum of 2 numbers. */ -#endif - -#define PERMANENT 0x7FFF55AA /**< A magic number for permanents. */ - -#endif diff --git a/user/mpy/lib/axtls/crypto/crypto.h b/user/mpy/lib/axtls/crypto/crypto.h deleted file mode 100644 index 0949e52..0000000 --- a/user/mpy/lib/axtls/crypto/crypto.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file crypto.h - */ - -#ifndef HEADER_CRYPTO_H -#define HEADER_CRYPTO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bigint_impl.h" -#include "bigint.h" - -#ifndef STDCALL -#define STDCALL -#endif -#ifndef EXP_FUNC -#define EXP_FUNC -#endif - - -/* enable features based on a 'super-set' capbaility. */ -#if 0 -#if defined(CONFIG_SSL_FULL_MODE) -#define CONFIG_SSL_ENABLE_CLIENT -#define CONFIG_SSL_CERT_VERIFICATION -#elif defined(CONFIG_SSL_ENABLE_CLIENT) -#define CONFIG_SSL_CERT_VERIFICATION -#endif -#endif - -/************************************************************************** - * AES declarations - **************************************************************************/ - -#define AES_MAXROUNDS 14 -#define AES_BLOCKSIZE 16 -#define AES_IV_SIZE 16 - -typedef struct aes_key_st -{ - uint16_t rounds; - uint16_t key_size; - uint32_t ks[(AES_MAXROUNDS+1)*8]; - uint8_t iv[AES_IV_SIZE]; -} AES_CTX; - -typedef enum -{ - AES_MODE_128, - AES_MODE_256 -} AES_MODE; - -void AES_set_key(AES_CTX *ctx, const uint8_t *key, - const uint8_t *iv, AES_MODE mode); -void AES_cbc_encrypt(AES_CTX *ctx, const uint8_t *msg, - uint8_t *out, int length); -void AES_cbc_decrypt(AES_CTX *ks, const uint8_t *in, uint8_t *out, int length); -void AES_convert_key(AES_CTX *ctx); - -/************************************************************************** - * RC4 declarations - **************************************************************************/ - -typedef struct -{ - uint8_t x, y, m[256]; -} RC4_CTX; - -void RC4_setup(RC4_CTX *s, const uint8_t *key, int length); -void RC4_crypt(RC4_CTX *s, const uint8_t *msg, uint8_t *data, int length); - -/************************************************************************** - * SHA1 declarations - **************************************************************************/ - -#define SHA1_SIZE 20 - -/* - * This structure will hold context information for the SHA-1 - * hashing operation - */ -typedef struct -{ - uint32_t Intermediate_Hash[SHA1_SIZE/4]; /* Message Digest */ - uint32_t Length_Low; /* Message length in bits */ - uint32_t Length_High; /* Message length in bits */ - uint16_t Message_Block_Index; /* Index into message block array */ - uint8_t Message_Block[64]; /* 512-bit message blocks */ -} SHA1_CTX; - -void SHA1_Init(SHA1_CTX *); -void SHA1_Update(SHA1_CTX *, const uint8_t * msg, int len); -void SHA1_Final(uint8_t *digest, SHA1_CTX *); - -/************************************************************************** - * SHA256 declarations - **************************************************************************/ - -#define SHA256_SIZE 32 - -#ifndef SHA256_CTX -#define SHA256_CTX SHA256_CTX -typedef struct -{ - uint32_t total[2]; - uint32_t state[8]; - uint8_t buffer[64]; -} SHA256_CTX; - -void SHA256_Init(SHA256_CTX *c); -void SHA256_Update(SHA256_CTX *, const uint8_t *input, int len); -void SHA256_Final(uint8_t *digest, SHA256_CTX *); -#endif - -/************************************************************************** - * SHA512 declarations - **************************************************************************/ - -#define SHA512_SIZE 64 - -typedef struct -{ - union - { - uint64_t h[8]; - uint8_t digest[64]; - } h_dig; - union - { - uint64_t w[80]; - uint8_t buffer[128]; - } w_buf; - size_t size; - uint64_t totalSize; -} SHA512_CTX; - -void SHA512_Init(SHA512_CTX *c); -void SHA512_Update(SHA512_CTX *, const uint8_t *input, int len); -void SHA512_Final(uint8_t *digest, SHA512_CTX *); - -/************************************************************************** - * SHA384 declarations - **************************************************************************/ - -#define SHA384_SIZE 48 - -typedef SHA512_CTX SHA384_CTX; -void SHA384_Init(SHA384_CTX *c); -void SHA384_Update(SHA384_CTX *, const uint8_t *input, int len); -void SHA384_Final(uint8_t *digest, SHA384_CTX *); - -/************************************************************************** - * MD5 declarations - **************************************************************************/ - -#define MD5_SIZE 16 - -typedef struct -{ - uint32_t state[4]; /* state (ABCD) */ - uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ - uint8_t buffer[64]; /* input buffer */ -} MD5_CTX; - -EXP_FUNC void STDCALL MD5_Init(MD5_CTX *); -EXP_FUNC void STDCALL MD5_Update(MD5_CTX *, const uint8_t *msg, int len); -EXP_FUNC void STDCALL MD5_Final(uint8_t *digest, MD5_CTX *); - -/************************************************************************** - * HMAC declarations - **************************************************************************/ -void ssl_hmac_md5(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest); -void ssl_hmac_sha1(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest); -void hmac_sha256(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest); - -/************************************************************************** - * RSA declarations - **************************************************************************/ - -typedef struct -{ - bigint *m; /* modulus */ - bigint *e; /* public exponent */ - bigint *d; /* private exponent */ -#ifdef CONFIG_BIGINT_CRT - bigint *p; /* p as in m = pq */ - bigint *q; /* q as in m = pq */ - bigint *dP; /* d mod (p-1) */ - bigint *dQ; /* d mod (q-1) */ - bigint *qInv; /* q^-1 mod p */ -#endif - int num_octets; - BI_CTX *bi_ctx; -} RSA_CTX; - -void RSA_priv_key_new(RSA_CTX **rsa_ctx, - const uint8_t *modulus, int mod_len, - const uint8_t *pub_exp, int pub_len, - const uint8_t *priv_exp, int priv_len -#ifdef CONFIG_BIGINT_CRT - , const uint8_t *p, int p_len, - const uint8_t *q, int q_len, - const uint8_t *dP, int dP_len, - const uint8_t *dQ, int dQ_len, - const uint8_t *qInv, int qInv_len -#endif - ); -void RSA_pub_key_new(RSA_CTX **rsa_ctx, - const uint8_t *modulus, int mod_len, - const uint8_t *pub_exp, int pub_len); -void RSA_free(RSA_CTX *ctx); -int RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint8_t *out_data, - int out_len, int is_decryption); -bigint *RSA_private(const RSA_CTX *c, bigint *bi_msg); -// Don't bother to ifdef prototypes, let them be -//#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_GENERATE_X509_CERT) -bigint *RSA_sign_verify(BI_CTX *ctx, const uint8_t *sig, int sig_len, - bigint *modulus, bigint *pub_exp); -bigint *RSA_public(const RSA_CTX * c, bigint *bi_msg); -int RSA_encrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint16_t in_len, - uint8_t *out_data, int is_signing); -void RSA_print(const RSA_CTX *ctx); -//#endif - -/************************************************************************** - * RNG declarations - **************************************************************************/ -EXP_FUNC void STDCALL RNG_initialize(void); -EXP_FUNC void STDCALL RNG_custom_init(const uint8_t *seed_buf, int size); -EXP_FUNC void STDCALL RNG_terminate(void); -EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data); -int get_random_NZ(int num_rand_bytes, uint8_t *rand_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/axtls/crypto/crypto_misc.c b/user/mpy/lib/axtls/crypto/crypto_misc.c deleted file mode 100644 index 2d7803f..0000000 --- a/user/mpy/lib/axtls/crypto/crypto_misc.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2007-2015, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Some misc. routines to help things out - */ - -#include -#include -#include -#include -#include "os_port.h" -#include "crypto_misc.h" -#ifdef CONFIG_WIN32_USE_CRYPTO_LIB -#include "wincrypt.h" -#endif - -#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) -static int rng_fd = -1; -#elif defined(CONFIG_WIN32_USE_CRYPTO_LIB) -static HCRYPTPROV gCryptProv; -#endif - -#if (!defined(CONFIG_USE_DEV_URANDOM) && !defined(CONFIG_WIN32_USE_CRYPTO_LIB)) -/* change to processor registers as appropriate */ -#define ENTROPY_POOL_SIZE 32 -#define ENTROPY_COUNTER1 ((((uint64_t)tv.tv_sec)<<32) | tv.tv_usec) -#define ENTROPY_COUNTER2 rand() -static uint8_t entropy_pool[ENTROPY_POOL_SIZE]; -#endif - -const char * const unsupported_str = "Error: Feature not supported\n"; - -#ifndef CONFIG_SSL_SKELETON_MODE -/** - * Retrieve a file and put it into memory - * @return The size of the file, or -1 on failure. - */ -int get_file(const char *filename, uint8_t **buf) -{ - int total_bytes = 0; - int bytes_read = 0; - int filesize; - FILE *stream = fopen(filename, "rb"); - - if (stream == NULL) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("file '%s' does not exist\n", filename); TTY_FLUSH(); -#endif - return -1; - } - - /* Win CE doesn't support stat() */ - fseek(stream, 0, SEEK_END); - filesize = ftell(stream); - *buf = (uint8_t *)malloc(filesize); - fseek(stream, 0, SEEK_SET); - - do - { - bytes_read = fread(*buf+total_bytes, 1, filesize-total_bytes, stream); - total_bytes += bytes_read; - } while (total_bytes < filesize && bytes_read > 0); - - fclose(stream); - return filesize; -} -#endif - -/** - * Initialise the Random Number Generator engine. - * - On Win32 use the platform SDK's crypto engine. - * - On Linux use /dev/urandom - * - If none of these work then use a custom RNG. - */ -EXP_FUNC void STDCALL RNG_initialize() -{ -#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) - rng_fd = open("/dev/urandom", O_RDONLY); -#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB) - if (!CryptAcquireContext(&gCryptProv, - NULL, NULL, PROV_RSA_FULL, 0)) - { - if (GetLastError() == NTE_BAD_KEYSET && - !CryptAcquireContext(&gCryptProv, - NULL, - NULL, - PROV_RSA_FULL, - CRYPT_NEWKEYSET)) - { - printf("CryptoLib: %x\n", unsupported_str, GetLastError()); - exit(1); - } - } -#elif !defined(__ets__) - /* start of with a stack to copy across */ - int i; - memcpy(entropy_pool, &i, ENTROPY_POOL_SIZE); - rand_r((unsigned int *)entropy_pool); -#endif -} - -/** - * If no /dev/urandom, then initialise the RNG with something interesting. - */ -EXP_FUNC void STDCALL RNG_custom_init(const uint8_t *seed_buf, int size) -{ -#if defined(WIN32) || defined(CONFIG_WIN32_USE_CRYPTO_LIB) - int i; - - for (i = 0; i < ENTROPY_POOL_SIZE && i < size; i++) - entropy_pool[i] ^= seed_buf[i]; -#endif -} - -/** - * Terminate the RNG engine. - */ -EXP_FUNC void STDCALL RNG_terminate(void) -{ -#if !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) - close(rng_fd); -#elif defined(CONFIG_WIN32_USE_CRYPTO_LIB) - CryptReleaseContext(gCryptProv, 0); -#endif -} - -/** - * Set a series of bytes with a random number. Individual bytes can be 0 - */ -EXP_FUNC int STDCALL get_random(int num_rand_bytes, uint8_t *rand_data) -{ -#ifdef __ets__ -// see http://esp8266-re.foogod.com/wiki/Random_Number_Generator -#define WDEV_HWRNG ((volatile uint32_t*)0x3ff20e44) - while (num_rand_bytes--) { - *rand_data++ = *WDEV_HWRNG; - } -#elif !defined(WIN32) && defined(CONFIG_USE_DEV_URANDOM) - /* use the Linux default - read from /dev/urandom */ - if (read(rng_fd, rand_data, num_rand_bytes) < 0) - return -1; -#elif defined(WIN32) && defined(CONFIG_WIN32_USE_CRYPTO_LIB) - /* use Microsoft Crypto Libraries */ - CryptGenRandom(gCryptProv, num_rand_bytes, rand_data); -#else /* nothing else to use, so use a custom RNG */ - /* The method we use when we've got nothing better. Use RC4, time - and a couple of random seeds to generate a random sequence */ - AES_CTX rng_ctx; - struct timeval tv; - MD5_CTX rng_digest_ctx; - uint8_t digest[MD5_SIZE]; - uint64_t *ep; - int i; - - /* A proper implementation would use counters etc for entropy */ - gettimeofday(&tv, NULL); - ep = (uint64_t *)entropy_pool; - ep[0] ^= ENTROPY_COUNTER1; - ep[1] ^= ENTROPY_COUNTER2; - - /* use a digested version of the entropy pool as a key */ - MD5_Init(&rng_digest_ctx); - MD5_Update(&rng_digest_ctx, entropy_pool, ENTROPY_POOL_SIZE); - MD5_Final(digest, &rng_digest_ctx); - - /* come up with the random sequence */ - AES_set_key(&rng_ctx, digest, (const uint8_t *)ep, AES_MODE_128); /* use as a key */ - memcpy(rand_data, entropy_pool, num_rand_bytes < ENTROPY_POOL_SIZE ? - num_rand_bytes : ENTROPY_POOL_SIZE); - AES_cbc_encrypt(&rng_ctx, rand_data, rand_data, num_rand_bytes); - - /* move things along */ - for (i = ENTROPY_POOL_SIZE-1; i >= MD5_SIZE ; i--) - entropy_pool[i] = entropy_pool[i-MD5_SIZE]; - - /* insert the digest at the start of the entropy pool */ - memcpy(entropy_pool, digest, MD5_SIZE); -#endif - return 0; -} - -/** - * Set a series of bytes with a random number. Individual bytes are not zero. - */ -int get_random_NZ(int num_rand_bytes, uint8_t *rand_data) -{ - int i; - if (get_random(num_rand_bytes, rand_data)) - return -1; - - for (i = 0; i < num_rand_bytes; i++) - { - while (rand_data[i] == 0) /* can't be 0 */ - rand_data[i] = (uint8_t)(rand()); - } - - return 0; -} - -/** - * Some useful diagnostic routines - */ -#if defined(CONFIG_SSL_DIAGNOSTICS) || defined(CONFIG_DEBUG) -int hex_finish; -int hex_index; - -static void print_hex_init(int finish) -{ - hex_finish = finish; - hex_index = 0; -} - -static void print_hex(uint8_t hex) -{ - static int column; - - if (hex_index == 0) - { - column = 0; - } - - printf("%02x ", hex); - if (++column == 8) - { - printf(": "); - } - else if (column >= 16) - { - printf("\n"); - column = 0; - } - - if (++hex_index >= hex_finish && column > 0) - { - printf("\n"); - } -} - -/** - * Spit out a blob of data for diagnostics. The data is is a nice column format - * for easy reading. - * - * @param format [in] The string (with possible embedded format characters) - * @param size [in] The number of numbers to print - * @param data [in] The start of data to use - * @param ... [in] Any additional arguments - */ -EXP_FUNC void STDCALL print_blob(const char *format, - const uint8_t *data, int size, ...) -{ - int i; - char tmp[80]; - va_list(ap); - - va_start(ap, size); - snprintf(tmp, sizeof(tmp), "%s\n", format); - vprintf(tmp, ap); - print_hex_init(size); - for (i = 0; i < size; i++) - { - print_hex(data[i]); - } - - va_end(ap); - TTY_FLUSH(); -} -#elif defined(WIN32) -/* VC6.0 doesn't handle variadic macros */ -EXP_FUNC void STDCALL print_blob(const char *format, const unsigned char *data, - int size, ...) {} -#endif - -#if defined(CONFIG_SSL_HAS_PEM) || defined(CONFIG_HTTP_HAS_AUTHORIZATION) -/* base64 to binary lookup table */ -static const uint8_t map[128] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, - 255, 254, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 255, 255, 255, 255, 255 -}; - -EXP_FUNC int STDCALL base64_decode(const char *in, int len, - uint8_t *out, int *outlen) -{ - int g, t, x, y, z; - uint8_t c; - int ret = -1; - - g = 3; - for (x = y = z = t = 0; x < len; x++) - { - if ((c = map[in[x]&0x7F]) == 0xff) - continue; - - if (c == 254) /* this is the end... */ - { - c = 0; - - if (--g < 0) - goto error; - } - else if (g != 3) /* only allow = at end */ - goto error; - - t = (t<<6) | c; - - if (++y == 4) - { - out[z++] = (uint8_t)((t>>16)&255); - - if (g > 1) - out[z++] = (uint8_t)((t>>8)&255); - - if (g > 2) - out[z++] = (uint8_t)(t&255); - - y = t = 0; - } - - /* check that we don't go past the output buffer */ - if (z > *outlen) - goto error; - } - - if (y != 0) - goto error; - - *outlen = z; - ret = 0; - -error: -#ifdef CONFIG_SSL_FULL_MODE - if (ret < 0) - printf("Error: Invalid base64\n"); TTY_FLUSH(); -#endif - TTY_FLUSH(); - return ret; - -} -#endif - diff --git a/user/mpy/lib/axtls/crypto/hmac.c b/user/mpy/lib/axtls/crypto/hmac.c deleted file mode 100644 index ac5bb18..0000000 --- a/user/mpy/lib/axtls/crypto/hmac.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * HMAC implementation - This code was originally taken from RFC2104 - * See http://www.ietf.org/rfc/rfc2104.txt and - * http://www.faqs.org/rfcs/rfc2202.html - */ - -#include -#include "os_port.h" -#include "crypto.h" - -/** - * Perform HMAC-MD5 - * NOTE: does not handle keys larger than the block size. - */ -void ssl_hmac_md5(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest) -{ - MD5_CTX context; - uint8_t k_pad[64]; - int i; - - memset(k_pad, 0, sizeof k_pad); - memcpy(k_pad, key, key_len); - for (i = 0; i < 64; i++) - { - k_pad[i] ^= 0x36; - } - - MD5_Init(&context); - MD5_Update(&context, k_pad, 64); - MD5_Update(&context, msg, length); - MD5_Final(digest, &context); - - memset(k_pad, 0, sizeof k_pad); - memcpy(k_pad, key, key_len); - for (i = 0; i < 64; i++) - { - k_pad[i] ^= 0x5c; - } - - MD5_Init(&context); - MD5_Update(&context, k_pad, 64); - MD5_Update(&context, digest, MD5_SIZE); - MD5_Final(digest, &context); -} - -/** - * Perform HMAC-SHA1 - * NOTE: does not handle keys larger than the block size. - */ -void ssl_hmac_sha1(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest) -{ - SHA1_CTX context; - uint8_t k_pad[64]; - int i; - - memset(k_pad, 0, sizeof k_pad); - memcpy(k_pad, key, key_len); - for (i = 0; i < 64; i++) - { - k_pad[i] ^= 0x36; - } - - SHA1_Init(&context); - SHA1_Update(&context, k_pad, 64); - SHA1_Update(&context, msg, length); - SHA1_Final(digest, &context); - - memset(k_pad, 0, sizeof k_pad); - memcpy(k_pad, key, key_len); - for (i = 0; i < 64; i++) - { - k_pad[i] ^= 0x5c; - } - - SHA1_Init(&context); - SHA1_Update(&context, k_pad, 64); - SHA1_Update(&context, digest, SHA1_SIZE); - SHA1_Final(digest, &context); -} - -/** - * Perform HMAC-SHA256 - * NOTE: does not handle keys larger than the block size. - */ -void hmac_sha256(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest) -{ - SHA256_CTX context; - uint8_t k_ipad[64]; - uint8_t k_opad[64]; - int i; - - memset(k_ipad, 0, sizeof k_ipad); - memset(k_opad, 0, sizeof k_opad); - memcpy(k_ipad, key, key_len); - memcpy(k_opad, key, key_len); - - for (i = 0; i < 64; i++) - { - k_ipad[i] ^= 0x36; - k_opad[i] ^= 0x5c; - } - - SHA256_Init(&context); - SHA256_Update(&context, k_ipad, 64); - SHA256_Update(&context, msg, length); - SHA256_Final(digest, &context); - SHA256_Init(&context); - SHA256_Update(&context, k_opad, 64); - SHA256_Update(&context, digest, SHA256_SIZE); - SHA256_Final(digest, &context); -} - diff --git a/user/mpy/lib/axtls/crypto/md5.c b/user/mpy/lib/axtls/crypto/md5.c deleted file mode 100644 index 86534c8..0000000 --- a/user/mpy/lib/axtls/crypto/md5.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * This file implements the MD5 algorithm as defined in RFC1321 - */ - -#include -#include "os_port.h" -#include "crypto.h" - -/* Constants for MD5Transform routine. - */ -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -/* ----- static functions ----- */ -static void MD5Transform(uint32_t state[4], const uint8_t block[64]); -static void Encode(uint8_t *output, uint32_t *input, uint32_t len); -static void Decode(uint32_t *output, const uint8_t *input, uint32_t len); - -static const uint8_t PADDING[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G, H and I are basic MD5 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* Versions for size-optimized code. */ -#define IDX(v) ((v) & 3) -#define F_(a, i) ((a[IDX(i + 1)] & a[IDX(i + 2)]) | (~a[IDX(i + 1)] & a[IDX(i + 3)])) -#define G_(a, i) ((a[IDX(i + 1)] & a[IDX(i + 3)]) | (a[IDX(i + 2)] & ~a[IDX(i + 3)])) -#define H_(a, i) (a[IDX(i + 1)] ^ a[IDX(i + 2)] ^ a[IDX(i + 3)]) -#define I_(a, i) (a[IDX(i + 2)] ^ (a[IDX(i + 1)] | ~a[IDX(i + 3)])) - -/* ROTATE_LEFT rotates x left n bits. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. - Rotation is separate from addition to prevent recomputation. */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -/** - * MD5 initialization - begins an MD5 operation, writing a new ctx. - */ -EXP_FUNC void STDCALL MD5_Init(MD5_CTX *ctx) -{ - ctx->count[0] = ctx->count[1] = 0; - - /* Load magic initialization constants. - */ - ctx->state[0] = 0x67452301; - ctx->state[1] = 0xefcdab89; - ctx->state[2] = 0x98badcfe; - ctx->state[3] = 0x10325476; -} - -/** - * Accepts an array of octets as the next portion of the message. - */ -EXP_FUNC void STDCALL MD5_Update(MD5_CTX *ctx, const uint8_t * msg, int len) -{ - uint32_t x; - int i, partLen; - - /* Compute number of bytes mod 64 */ - x = (uint32_t)((ctx->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((ctx->count[0] += ((uint32_t)len << 3)) < ((uint32_t)len << 3)) - ctx->count[1]++; - ctx->count[1] += ((uint32_t)len >> 29); - - partLen = 64 - x; - - /* Transform as many times as possible. */ - if (len >= partLen) - { - memcpy(&ctx->buffer[x], msg, partLen); - MD5Transform(ctx->state, ctx->buffer); - - for (i = partLen; i + 63 < len; i += 64) - MD5Transform(ctx->state, &msg[i]); - - x = 0; - } - else - i = 0; - - /* Buffer remaining input */ - memcpy(&ctx->buffer[x], &msg[i], len-i); -} - -/** - * Return the 128-bit message digest into the user's array - */ -EXP_FUNC void STDCALL MD5_Final(uint8_t *digest, MD5_CTX *ctx) -{ - uint8_t bits[8]; - uint32_t x, padLen; - - /* Save number of bits */ - Encode(bits, ctx->count, 8); - - /* Pad out to 56 mod 64. - */ - x = (uint32_t)((ctx->count[0] >> 3) & 0x3f); - padLen = (x < 56) ? (56 - x) : (120 - x); - MD5_Update(ctx, PADDING, padLen); - - /* Append length (before padding) */ - MD5_Update(ctx, bits, 8); - - /* Store state in digest */ - Encode(digest, ctx->state, MD5_SIZE); -} - -/** - * MD5 basic transformation. Transforms state based on block. - */ -#if OPTIMIZE_FOR_SPEED - -static void MD5Transform(uint32_t state[4], const uint8_t block[64]) -{ - uint32_t a = state[0], b = state[1], c = state[2], - d = state[3], x[MD5_SIZE]; - - Decode(x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; -} - -#else - -static void MD5Transform(uint32_t state[4], const uint8_t block[64]) -{ - uint32_t arr[4], x[MD5_SIZE]; - memcpy(arr, state, sizeof(arr)); - - Decode(x, block, 64); - - static const uint32_t round_ac[] = { - 0xd76aa478, /* 1 */ - 0xe8c7b756, /* 2 */ - 0x242070db, /* 3 */ - 0xc1bdceee, /* 4 */ - 0xf57c0faf, /* 5 */ - 0x4787c62a, /* 6 */ - 0xa8304613, /* 7 */ - 0xfd469501, /* 8 */ - 0x698098d8, /* 9 */ - 0x8b44f7af, /* 10 */ - 0xffff5bb1, /* 11 */ - 0x895cd7be, /* 12 */ - 0x6b901122, /* 13 */ - 0xfd987193, /* 14 */ - 0xa679438e, /* 15 */ - 0x49b40821, /* 16 */ - 0xf61e2562, /* 17 */ - 0xc040b340, /* 18 */ - 0x265e5a51, /* 19 */ - 0xe9b6c7aa, /* 20 */ - 0xd62f105d, /* 21 */ - 0x2441453, /* 22 */ - 0xd8a1e681, /* 23 */ - 0xe7d3fbc8, /* 24 */ - 0x21e1cde6, /* 25 */ - 0xc33707d6, /* 26 */ - 0xf4d50d87, /* 27 */ - 0x455a14ed, /* 28 */ - 0xa9e3e905, /* 29 */ - 0xfcefa3f8, /* 30 */ - 0x676f02d9, /* 31 */ - 0x8d2a4c8a, /* 32 */ - 0xfffa3942, /* 33 */ - 0x8771f681, /* 34 */ - 0x6d9d6122, /* 35 */ - 0xfde5380c, /* 36 */ - 0xa4beea44, /* 37 */ - 0x4bdecfa9, /* 38 */ - 0xf6bb4b60, /* 39 */ - 0xbebfbc70, /* 40 */ - 0x289b7ec6, /* 41 */ - 0xeaa127fa, /* 42 */ - 0xd4ef3085, /* 43 */ - 0x4881d05, /* 44 */ - 0xd9d4d039, /* 45 */ - 0xe6db99e5, /* 46 */ - 0x1fa27cf8, /* 47 */ - 0xc4ac5665, /* 48 */ - 0xf4292244, /* 49 */ - 0x432aff97, /* 50 */ - 0xab9423a7, /* 51 */ - 0xfc93a039, /* 52 */ - 0x655b59c3, /* 53 */ - 0x8f0ccc92, /* 54 */ - 0xffeff47d, /* 55 */ - 0x85845dd1, /* 56 */ - 0x6fa87e4f, /* 57 */ - 0xfe2ce6e0, /* 58 */ - 0xa3014314, /* 59 */ - 0x4e0811a1, /* 60 */ - 0xf7537e82, /* 61 */ - 0xbd3af235, /* 62 */ - 0x2ad7d2bb, /* 63 */ - 0xeb86d391, /* 64 */ - }; - - static const uint8_t round1_s[] = { - 7, 12, 17, 22, - 5, 9, 14, 20, - 4, 11, 16, 23, - 6, 10, 15, 21, - }; - - static const uint8_t round_order[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, - 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, - 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9, - }; - - unsigned i; - - const uint8_t *round_s = round1_s - 4; - for (i = 0; i < 64; i++) { - int off = IDX(4 - i); - uint32_t v; - - // Code size is bigger - //round_s = round1_s + (i >> 4) * 4; - if ((i & 15) == 0) { - round_s += 4; - } - - if (i < 32) { - if (i < 16) { - v = F_(arr, off); - } else { - v = G_(arr, off); - } - } else { - if (i < 48) { - v = H_(arr, off); - } else { - v = I_(arr, off); - } - } - v += arr[off]; - v += x[round_order[i]] + round_ac[i]; - v = ROTATE_LEFT(v, round_s[i & 3]); - v += arr[IDX(off + 1)]; - arr[off] = v; - } - - state[0] += arr[0]; - state[1] += arr[1]; - state[2] += arr[2]; - state[3] += arr[3]; -} -#endif // OPTIMIZE_FOR_SPEED - -/** - * Encodes input (uint32_t) into output (uint8_t). Assumes len is - * a multiple of 4. - */ -static void Encode(uint8_t *output, uint32_t *input, uint32_t len) -{ - uint32_t i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - { - output[j] = (uint8_t)(input[i] & 0xff); - output[j+1] = (uint8_t)((input[i] >> 8) & 0xff); - output[j+2] = (uint8_t)((input[i] >> 16) & 0xff); - output[j+3] = (uint8_t)((input[i] >> 24) & 0xff); - } -} - -/** - * Decodes input (uint8_t) into output (uint32_t). Assumes len is - * a multiple of 4. - */ -static void Decode(uint32_t *output, const uint8_t *input, uint32_t len) -{ - uint32_t i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | - (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); -} diff --git a/user/mpy/lib/axtls/crypto/os_int.h b/user/mpy/lib/axtls/crypto/os_int.h deleted file mode 100644 index a849e5b..0000000 --- a/user/mpy/lib/axtls/crypto/os_int.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2012-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file os_int.h - * - * Ensure a consistent bit size - */ - -#ifndef HEADER_OS_INT_H -#define HEADER_OS_INT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(WIN32) -typedef UINT8 uint8_t; -typedef INT8 int8_t; -typedef UINT16 uint16_t; -typedef INT16 int16_t; -typedef UINT32 uint32_t; -typedef INT32 int32_t; -typedef UINT64 uint64_t; -typedef INT64 int64_t; -#else /* Not Win32 */ - -#ifdef CONFIG_PLATFORM_SOLARIS -#include -#else -#include -#endif /* Not Solaris */ - -#endif /* Not Win32 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/axtls/crypto/rc4.c b/user/mpy/lib/axtls/crypto/rc4.c deleted file mode 100644 index edfb27a..0000000 --- a/user/mpy/lib/axtls/crypto/rc4.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * An implementation of the RC4/ARC4 algorithm. - * Originally written by Christophe Devine. - */ - -#include -#include "os_port.h" -#include "crypto.h" - -/* only used for PKCS12 now */ -#ifdef CONFIG_SSL_USE_PKCS12 - -/** - * Get ready for an encrypt/decrypt operation - */ -void RC4_setup(RC4_CTX *ctx, const uint8_t *key, int length) -{ - int i, j = 0, k = 0, a; - uint8_t *m; - - ctx->x = 0; - ctx->y = 0; - m = ctx->m; - - for (i = 0; i < 256; i++) - m[i] = i; - - for (i = 0; i < 256; i++) - { - a = m[i]; - j = (uint8_t)(j + a + key[k]); - m[i] = m[j]; - m[j] = a; - - if (++k >= length) - k = 0; - } -} - -/** - * Perform the encrypt/decrypt operation (can use it for either since - * this is a stream cipher). - * NOTE: *msg and *out must be the same pointer (performance tweak) - */ -void RC4_crypt(RC4_CTX *ctx, const uint8_t *msg, uint8_t *out, int length) -{ - int i; - uint8_t *m, x, y, a, b; - - x = ctx->x; - y = ctx->y; - m = ctx->m; - - for (i = 0; i < length; i++) - { - a = m[++x]; - y += a; - m[x] = b = m[y]; - m[y] = a; - out[i] ^= m[(uint8_t)(a + b)]; - } - - ctx->x = x; - ctx->y = y; -} - -#endif diff --git a/user/mpy/lib/axtls/crypto/rsa.c b/user/mpy/lib/axtls/crypto/rsa.c deleted file mode 100644 index 742cd71..0000000 --- a/user/mpy/lib/axtls/crypto/rsa.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2007-2014, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Implements the RSA public encryption algorithm. Uses the bigint library to - * perform its calculations. - */ - -#include -#include -#include -#include -#include "os_port.h" -#include "crypto.h" - -void RSA_priv_key_new(RSA_CTX **ctx, - const uint8_t *modulus, int mod_len, - const uint8_t *pub_exp, int pub_len, - const uint8_t *priv_exp, int priv_len -#if CONFIG_BIGINT_CRT - , const uint8_t *p, int p_len, - const uint8_t *q, int q_len, - const uint8_t *dP, int dP_len, - const uint8_t *dQ, int dQ_len, - const uint8_t *qInv, int qInv_len -#endif - ) -{ - RSA_CTX *rsa_ctx; - BI_CTX *bi_ctx; - RSA_pub_key_new(ctx, modulus, mod_len, pub_exp, pub_len); - rsa_ctx = *ctx; - bi_ctx = rsa_ctx->bi_ctx; - rsa_ctx->d = bi_import(bi_ctx, priv_exp, priv_len); - bi_permanent(rsa_ctx->d); - -#ifdef CONFIG_BIGINT_CRT - rsa_ctx->p = bi_import(bi_ctx, p, p_len); - rsa_ctx->q = bi_import(bi_ctx, q, q_len); - rsa_ctx->dP = bi_import(bi_ctx, dP, dP_len); - rsa_ctx->dQ = bi_import(bi_ctx, dQ, dQ_len); - rsa_ctx->qInv = bi_import(bi_ctx, qInv, qInv_len); - bi_permanent(rsa_ctx->dP); - bi_permanent(rsa_ctx->dQ); - bi_permanent(rsa_ctx->qInv); - bi_set_mod(bi_ctx, rsa_ctx->p, BIGINT_P_OFFSET); - bi_set_mod(bi_ctx, rsa_ctx->q, BIGINT_Q_OFFSET); -#endif -} - -void RSA_pub_key_new(RSA_CTX **ctx, - const uint8_t *modulus, int mod_len, - const uint8_t *pub_exp, int pub_len) -{ - RSA_CTX *rsa_ctx; - BI_CTX *bi_ctx; - - if (*ctx) /* if we load multiple certs, dump the old one */ - RSA_free(*ctx); - - bi_ctx = bi_initialize(); - *ctx = (RSA_CTX *)calloc(1, sizeof(RSA_CTX)); - rsa_ctx = *ctx; - rsa_ctx->bi_ctx = bi_ctx; - rsa_ctx->num_octets = mod_len; - rsa_ctx->m = bi_import(bi_ctx, modulus, mod_len); - bi_set_mod(bi_ctx, rsa_ctx->m, BIGINT_M_OFFSET); - rsa_ctx->e = bi_import(bi_ctx, pub_exp, pub_len); - bi_permanent(rsa_ctx->e); -} - -/** - * Free up any RSA context resources. - */ -void RSA_free(RSA_CTX *rsa_ctx) -{ - BI_CTX *bi_ctx; - if (rsa_ctx == NULL) /* deal with ptrs that are null */ - return; - - bi_ctx = rsa_ctx->bi_ctx; - - bi_depermanent(rsa_ctx->e); - bi_free(bi_ctx, rsa_ctx->e); - bi_free_mod(rsa_ctx->bi_ctx, BIGINT_M_OFFSET); - - if (rsa_ctx->d) - { - bi_depermanent(rsa_ctx->d); - bi_free(bi_ctx, rsa_ctx->d); -#ifdef CONFIG_BIGINT_CRT - bi_depermanent(rsa_ctx->dP); - bi_depermanent(rsa_ctx->dQ); - bi_depermanent(rsa_ctx->qInv); - bi_free(bi_ctx, rsa_ctx->dP); - bi_free(bi_ctx, rsa_ctx->dQ); - bi_free(bi_ctx, rsa_ctx->qInv); - bi_free_mod(rsa_ctx->bi_ctx, BIGINT_P_OFFSET); - bi_free_mod(rsa_ctx->bi_ctx, BIGINT_Q_OFFSET); -#endif - } - - bi_terminate(bi_ctx); - free(rsa_ctx); -} - -/** - * @brief Use PKCS1.5 for decryption/verification. - * @param ctx [in] The context - * @param in_data [in] The data to decrypt (must be < modulus size-11) - * @param out_data [out] The decrypted data. - * @param out_len [int] The size of the decrypted buffer in bytes - * @param is_decryption [in] Decryption or verify operation. - * @return The number of bytes that were originally encrypted. -1 on error. - * @see http://www.rsasecurity.com/rsalabs/node.asp?id=2125 - */ -int RSA_decrypt(const RSA_CTX *ctx, const uint8_t *in_data, - uint8_t *out_data, int out_len, int is_decryption) -{ - const int byte_size = ctx->num_octets; - int i = 0, size; - bigint *decrypted_bi, *dat_bi; - uint8_t *block = (uint8_t *)alloca(byte_size); - int pad_count = 0; - - if (out_len < byte_size) /* check output has enough size */ - return -1; - - memset(out_data, 0, out_len); /* initialise */ - - /* decrypt */ - dat_bi = bi_import(ctx->bi_ctx, in_data, byte_size); -#ifdef CONFIG_SSL_CERT_VERIFICATION - decrypted_bi = is_decryption ? /* decrypt or verify? */ - RSA_private(ctx, dat_bi) : RSA_public(ctx, dat_bi); -#else /* always a decryption */ - decrypted_bi = RSA_private(ctx, dat_bi); -#endif - - /* convert to a normal block */ - bi_export(ctx->bi_ctx, decrypted_bi, block, byte_size); - - if (block[i++] != 0) /* leading 0? */ - return -1; - -#ifdef CONFIG_SSL_CERT_VERIFICATION - if (is_decryption == 0) /* PKCS1.5 signing pads with "0xff"s */ - { - if (block[i++] != 0x01) /* BT correct? */ - return -1; - - while (block[i++] == 0xff && i < byte_size) - pad_count++; - } - else /* PKCS1.5 encryption padding is random */ -#endif - { - if (block[i++] != 0x02) /* BT correct? */ - return -1; - - while (block[i++] && i < byte_size) - pad_count++; - } - - /* check separator byte 0x00 - and padding must be 8 or more bytes */ - if (i == byte_size || pad_count < 8) - return -1; - - size = byte_size - i; - - /* get only the bit we want */ - memcpy(out_data, &block[i], size); - return size; -} - -/** - * Performs m = c^d mod n - */ -bigint *RSA_private(const RSA_CTX *c, bigint *bi_msg) -{ -#ifdef CONFIG_BIGINT_CRT - return bi_crt(c->bi_ctx, bi_msg, c->dP, c->dQ, c->p, c->q, c->qInv); -#else - BI_CTX *ctx = c->bi_ctx; - ctx->mod_offset = BIGINT_M_OFFSET; - return bi_mod_power(ctx, bi_msg, c->d); -#endif -} - -#ifdef CONFIG_SSL_FULL_MODE -/** - * Used for diagnostics. - */ -void RSA_print(const RSA_CTX *rsa_ctx) -{ - if (rsa_ctx == NULL) - return; - - printf("----------------- RSA DEBUG ----------------\n"); - printf("Size:\t%d\n", rsa_ctx->num_octets); - bi_print("Modulus", rsa_ctx->m); - bi_print("Public Key", rsa_ctx->e); - bi_print("Private Key", rsa_ctx->d); -} -#endif - -#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_GENERATE_X509_CERT) || (CONFIG_SSL_ENABLE_CLIENT) -/** - * Performs c = m^e mod n - */ -bigint *RSA_public(const RSA_CTX * c, bigint *bi_msg) -{ - c->bi_ctx->mod_offset = BIGINT_M_OFFSET; - return bi_mod_power(c->bi_ctx, bi_msg, c->e); -} - -/** - * Use PKCS1.5 for encryption/signing. - * see http://www.rsasecurity.com/rsalabs/node.asp?id=2125 - */ -int RSA_encrypt(const RSA_CTX *ctx, const uint8_t *in_data, uint16_t in_len, - uint8_t *out_data, int is_signing) -{ - int byte_size = ctx->num_octets; - int num_pads_needed = byte_size-in_len-3; - bigint *dat_bi, *encrypt_bi; - - /* note: in_len+11 must be > byte_size */ - out_data[0] = 0; /* ensure encryption block is < modulus */ - - if (is_signing) - { - out_data[1] = 1; /* PKCS1.5 signing pads with "0xff"'s */ - memset(&out_data[2], 0xff, num_pads_needed); - } - else /* randomize the encryption padding with non-zero bytes */ - { - out_data[1] = 2; - if (get_random_NZ(num_pads_needed, &out_data[2]) < 0) - return -1; - } - - out_data[2+num_pads_needed] = 0; - memcpy(&out_data[3+num_pads_needed], in_data, in_len); - - /* now encrypt it */ - dat_bi = bi_import(ctx->bi_ctx, out_data, byte_size); - encrypt_bi = is_signing ? RSA_private(ctx, dat_bi) : - RSA_public(ctx, dat_bi); - bi_export(ctx->bi_ctx, encrypt_bi, out_data, byte_size); - - /* save a few bytes of memory */ - bi_clear_cache(ctx->bi_ctx); - return byte_size; -} - -#endif /* CONFIG_SSL_CERT_VERIFICATION */ diff --git a/user/mpy/lib/axtls/crypto/sha1.c b/user/mpy/lib/axtls/crypto/sha1.c deleted file mode 100644 index 1082733..0000000 --- a/user/mpy/lib/axtls/crypto/sha1.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * SHA1 implementation - as defined in FIPS PUB 180-1 published April 17, 1995. - * This code was originally taken from RFC3174 - */ - -#include -#include "os_port.h" -#include "crypto.h" - -/* - * Define the SHA1 circular left shift macro - */ -#define SHA1CircularShift(bits,word) \ - (((word) << (bits)) | ((word) >> (32-(bits)))) - -/* ----- static functions ----- */ -static void SHA1PadMessage(SHA1_CTX *ctx); -static void SHA1ProcessMessageBlock(SHA1_CTX *ctx); - -/** - * Initialize the SHA1 context - */ -void SHA1_Init(SHA1_CTX *ctx) -{ - ctx->Length_Low = 0; - ctx->Length_High = 0; - ctx->Message_Block_Index = 0; - ctx->Intermediate_Hash[0] = 0x67452301; - ctx->Intermediate_Hash[1] = 0xEFCDAB89; - ctx->Intermediate_Hash[2] = 0x98BADCFE; - ctx->Intermediate_Hash[3] = 0x10325476; - ctx->Intermediate_Hash[4] = 0xC3D2E1F0; -} - -/** - * Accepts an array of octets as the next portion of the message. - */ -void SHA1_Update(SHA1_CTX *ctx, const uint8_t *msg, int len) -{ - while (len--) - { - ctx->Message_Block[ctx->Message_Block_Index++] = (*msg & 0xFF); - ctx->Length_Low += 8; - - if (ctx->Length_Low == 0) - ctx->Length_High++; - - if (ctx->Message_Block_Index == 64) - SHA1ProcessMessageBlock(ctx); - - msg++; - } -} - -/** - * Return the 160-bit message digest into the user's array - */ -void SHA1_Final(uint8_t *digest, SHA1_CTX *ctx) -{ - int i; - - SHA1PadMessage(ctx); - memset(ctx->Message_Block, 0, 64); - ctx->Length_Low = 0; /* and clear length */ - ctx->Length_High = 0; - - for (i = 0; i < SHA1_SIZE; i++) - { - digest[i] = ctx->Intermediate_Hash[i>>2] >> 8 * ( 3 - ( i & 0x03 ) ); - } -} - -/** - * Process the next 512 bits of the message stored in the array. - */ -static void SHA1ProcessMessageBlock(SHA1_CTX *ctx) -{ - const uint32_t K[] = { /* Constants defined in SHA-1 */ - 0x5A827999, - 0x6ED9EBA1, - 0x8F1BBCDC, - 0xCA62C1D6 - }; - int t; /* Loop counter */ - uint32_t temp; /* Temporary word value */ - uint32_t W[80]; /* Word sequence */ - uint32_t A, B, C, D, E; /* Word buffers */ - - /* - * Initialize the first 16 words in the array W - */ - for (t = 0; t < 16; t++) - { - W[t] = ctx->Message_Block[t * 4] << 24; - W[t] |= ctx->Message_Block[t * 4 + 1] << 16; - W[t] |= ctx->Message_Block[t * 4 + 2] << 8; - W[t] |= ctx->Message_Block[t * 4 + 3]; - } - - for (t = 16; t < 80; t++) - { - W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); - } - - A = ctx->Intermediate_Hash[0]; - B = ctx->Intermediate_Hash[1]; - C = ctx->Intermediate_Hash[2]; - D = ctx->Intermediate_Hash[3]; - E = ctx->Intermediate_Hash[4]; - - for (t = 0; t < 20; t++) - { - temp = SHA1CircularShift(5,A) + - ((B & C) | ((~B) & D)) + E + W[t] + K[0]; - E = D; - D = C; - C = SHA1CircularShift(30,B); - - B = A; - A = temp; - } - - for (t = 20; t < 40; t++) - { - temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - for (t = 40; t < 60; t++) - { - temp = SHA1CircularShift(5,A) + - ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - for (t = 60; t < 80; t++) - { - temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - ctx->Intermediate_Hash[0] += A; - ctx->Intermediate_Hash[1] += B; - ctx->Intermediate_Hash[2] += C; - ctx->Intermediate_Hash[3] += D; - ctx->Intermediate_Hash[4] += E; - ctx->Message_Block_Index = 0; -} - -/* - * According to the standard, the message must be padded to an even - * 512 bits. The first padding bit must be a '1'. The last 64 - * bits represent the length of the original message. All bits in - * between should be 0. This function will pad the message - * according to those rules by filling the Message_Block array - * accordingly. It will also call the ProcessMessageBlock function - * provided appropriately. When it returns, it can be assumed that - * the message digest has been computed. - * - * @param ctx [in, out] The SHA1 context - */ -static void SHA1PadMessage(SHA1_CTX *ctx) -{ - /* - * Check to see if the current message block is too small to hold - * the initial padding bits and length. If so, we will pad the - * block, process it, and then continue padding into a second - * block. - */ - if (ctx->Message_Block_Index > 55) - { - ctx->Message_Block[ctx->Message_Block_Index++] = 0x80; - while(ctx->Message_Block_Index < 64) - { - ctx->Message_Block[ctx->Message_Block_Index++] = 0; - } - - SHA1ProcessMessageBlock(ctx); - - while (ctx->Message_Block_Index < 56) - { - ctx->Message_Block[ctx->Message_Block_Index++] = 0; - } - } - else - { - ctx->Message_Block[ctx->Message_Block_Index++] = 0x80; - while(ctx->Message_Block_Index < 56) - { - - ctx->Message_Block[ctx->Message_Block_Index++] = 0; - } - } - - /* - * Store the message length as the last 8 octets - */ - ctx->Message_Block[56] = ctx->Length_High >> 24; - ctx->Message_Block[57] = ctx->Length_High >> 16; - ctx->Message_Block[58] = ctx->Length_High >> 8; - ctx->Message_Block[59] = ctx->Length_High; - ctx->Message_Block[60] = ctx->Length_Low >> 24; - ctx->Message_Block[61] = ctx->Length_Low >> 16; - ctx->Message_Block[62] = ctx->Length_Low >> 8; - ctx->Message_Block[63] = ctx->Length_Low; - SHA1ProcessMessageBlock(ctx); -} diff --git a/user/mpy/lib/axtls/crypto/sha256.c b/user/mpy/lib/axtls/crypto/sha256.c deleted file mode 100644 index e15e315..0000000 --- a/user/mpy/lib/axtls/crypto/sha256.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2015, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "os_port.h" -#include "crypto.h" - -#ifndef SHA256_CTX - -#define GET_UINT32(n,b,i) \ -{ \ - (n) = ((uint32_t) (b)[(i) ] << 24) \ - | ((uint32_t) (b)[(i) + 1] << 16) \ - | ((uint32_t) (b)[(i) + 2] << 8) \ - | ((uint32_t) (b)[(i) + 3] ); \ -} - -#define PUT_UINT32(n,b,i) \ -{ \ - (b)[(i) ] = (uint8_t) ((n) >> 24); \ - (b)[(i) + 1] = (uint8_t) ((n) >> 16); \ - (b)[(i) + 2] = (uint8_t) ((n) >> 8); \ - (b)[(i) + 3] = (uint8_t) ((n) ); \ -} - -static const uint8_t sha256_padding[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/** - * Initialize the SHA256 context - */ -void SHA256_Init(SHA256_CTX *ctx) -{ - ctx->total[0] = 0; - ctx->total[1] = 0; - - ctx->state[0] = 0x6A09E667; - ctx->state[1] = 0xBB67AE85; - ctx->state[2] = 0x3C6EF372; - ctx->state[3] = 0xA54FF53A; - ctx->state[4] = 0x510E527F; - ctx->state[5] = 0x9B05688C; - ctx->state[6] = 0x1F83D9AB; - ctx->state[7] = 0x5BE0CD19; -} - -static void SHA256_Process(const uint8_t digest[64], SHA256_CTX *ctx) -{ - uint32_t temp1, temp2, W[64]; - uint32_t A, B, C, D, E, F, G, H; - - GET_UINT32(W[0], digest, 0); - GET_UINT32(W[1], digest, 4); - GET_UINT32(W[2], digest, 8); - GET_UINT32(W[3], digest, 12); - GET_UINT32(W[4], digest, 16); - GET_UINT32(W[5], digest, 20); - GET_UINT32(W[6], digest, 24); - GET_UINT32(W[7], digest, 28); - GET_UINT32(W[8], digest, 32); - GET_UINT32(W[9], digest, 36); - GET_UINT32(W[10], digest, 40); - GET_UINT32(W[11], digest, 44); - GET_UINT32(W[12], digest, 48); - GET_UINT32(W[13], digest, 52); - GET_UINT32(W[14], digest, 56); - GET_UINT32(W[15], digest, 60); - -#define SHR(x,n) ((x & 0xFFFFFFFF) >> n) -#define ROTR(x,n) (SHR(x,n) | (x << (32 - n))) - -#define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3)) -#define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10)) - -#define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22)) -#define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25)) - -#define F0(x,y,z) ((x & y) | (z & (x | y))) -#define F1(x,y,z) (z ^ (x & (y ^ z))) - -#define R(t) \ -( \ - W[t] = S1(W[t - 2]) + W[t - 7] + \ - S0(W[t - 15]) + W[t - 16] \ -) - -#define P(a,b,c,d,e,f,g,h,x,K) \ -{ \ - temp1 = h + S3(e) + F1(e,f,g) + K + x; \ - temp2 = S2(a) + F0(a,b,c); \ - d += temp1; h = temp1 + temp2; \ -} - - A = ctx->state[0]; - B = ctx->state[1]; - C = ctx->state[2]; - D = ctx->state[3]; - E = ctx->state[4]; - F = ctx->state[5]; - G = ctx->state[6]; - H = ctx->state[7]; - - P(A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98); - P(H, A, B, C, D, E, F, G, W[ 1], 0x71374491); - P(G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF); - P(F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5); - P(E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B); - P(D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1); - P(C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4); - P(B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5); - P(A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98); - P(H, A, B, C, D, E, F, G, W[ 9], 0x12835B01); - P(G, H, A, B, C, D, E, F, W[10], 0x243185BE); - P(F, G, H, A, B, C, D, E, W[11], 0x550C7DC3); - P(E, F, G, H, A, B, C, D, W[12], 0x72BE5D74); - P(D, E, F, G, H, A, B, C, W[13], 0x80DEB1FE); - P(C, D, E, F, G, H, A, B, W[14], 0x9BDC06A7); - P(B, C, D, E, F, G, H, A, W[15], 0xC19BF174); - P(A, B, C, D, E, F, G, H, R(16), 0xE49B69C1); - P(H, A, B, C, D, E, F, G, R(17), 0xEFBE4786); - P(G, H, A, B, C, D, E, F, R(18), 0x0FC19DC6); - P(F, G, H, A, B, C, D, E, R(19), 0x240CA1CC); - P(E, F, G, H, A, B, C, D, R(20), 0x2DE92C6F); - P(D, E, F, G, H, A, B, C, R(21), 0x4A7484AA); - P(C, D, E, F, G, H, A, B, R(22), 0x5CB0A9DC); - P(B, C, D, E, F, G, H, A, R(23), 0x76F988DA); - P(A, B, C, D, E, F, G, H, R(24), 0x983E5152); - P(H, A, B, C, D, E, F, G, R(25), 0xA831C66D); - P(G, H, A, B, C, D, E, F, R(26), 0xB00327C8); - P(F, G, H, A, B, C, D, E, R(27), 0xBF597FC7); - P(E, F, G, H, A, B, C, D, R(28), 0xC6E00BF3); - P(D, E, F, G, H, A, B, C, R(29), 0xD5A79147); - P(C, D, E, F, G, H, A, B, R(30), 0x06CA6351); - P(B, C, D, E, F, G, H, A, R(31), 0x14292967); - P(A, B, C, D, E, F, G, H, R(32), 0x27B70A85); - P(H, A, B, C, D, E, F, G, R(33), 0x2E1B2138); - P(G, H, A, B, C, D, E, F, R(34), 0x4D2C6DFC); - P(F, G, H, A, B, C, D, E, R(35), 0x53380D13); - P(E, F, G, H, A, B, C, D, R(36), 0x650A7354); - P(D, E, F, G, H, A, B, C, R(37), 0x766A0ABB); - P(C, D, E, F, G, H, A, B, R(38), 0x81C2C92E); - P(B, C, D, E, F, G, H, A, R(39), 0x92722C85); - P(A, B, C, D, E, F, G, H, R(40), 0xA2BFE8A1); - P(H, A, B, C, D, E, F, G, R(41), 0xA81A664B); - P(G, H, A, B, C, D, E, F, R(42), 0xC24B8B70); - P(F, G, H, A, B, C, D, E, R(43), 0xC76C51A3); - P(E, F, G, H, A, B, C, D, R(44), 0xD192E819); - P(D, E, F, G, H, A, B, C, R(45), 0xD6990624); - P(C, D, E, F, G, H, A, B, R(46), 0xF40E3585); - P(B, C, D, E, F, G, H, A, R(47), 0x106AA070); - P(A, B, C, D, E, F, G, H, R(48), 0x19A4C116); - P(H, A, B, C, D, E, F, G, R(49), 0x1E376C08); - P(G, H, A, B, C, D, E, F, R(50), 0x2748774C); - P(F, G, H, A, B, C, D, E, R(51), 0x34B0BCB5); - P(E, F, G, H, A, B, C, D, R(52), 0x391C0CB3); - P(D, E, F, G, H, A, B, C, R(53), 0x4ED8AA4A); - P(C, D, E, F, G, H, A, B, R(54), 0x5B9CCA4F); - P(B, C, D, E, F, G, H, A, R(55), 0x682E6FF3); - P(A, B, C, D, E, F, G, H, R(56), 0x748F82EE); - P(H, A, B, C, D, E, F, G, R(57), 0x78A5636F); - P(G, H, A, B, C, D, E, F, R(58), 0x84C87814); - P(F, G, H, A, B, C, D, E, R(59), 0x8CC70208); - P(E, F, G, H, A, B, C, D, R(60), 0x90BEFFFA); - P(D, E, F, G, H, A, B, C, R(61), 0xA4506CEB); - P(C, D, E, F, G, H, A, B, R(62), 0xBEF9A3F7); - P(B, C, D, E, F, G, H, A, R(63), 0xC67178F2); - - ctx->state[0] += A; - ctx->state[1] += B; - ctx->state[2] += C; - ctx->state[3] += D; - ctx->state[4] += E; - ctx->state[5] += F; - ctx->state[6] += G; - ctx->state[7] += H; -} - -/** - * Accepts an array of octets as the next portion of the message. - */ -void SHA256_Update(SHA256_CTX *ctx, const uint8_t * msg, int len) -{ - uint32_t left = ctx->total[0] & 0x3F; - uint32_t fill = 64 - left; - - ctx->total[0] += len; - ctx->total[0] &= 0xFFFFFFFF; - - if (ctx->total[0] < len) - ctx->total[1]++; - - if (left && len >= fill) - { - memcpy((void *) (ctx->buffer + left), (void *)msg, fill); - SHA256_Process(ctx->buffer, ctx); - len -= fill; - msg += fill; - left = 0; - } - - while (len >= 64) - { - SHA256_Process(msg, ctx); - len -= 64; - msg += 64; - } - - if (len) - { - memcpy((void *) (ctx->buffer + left), (void *) msg, len); - } -} - -/** - * Return the 256-bit message digest into the user's array - */ -void SHA256_Final(uint8_t *digest, SHA256_CTX *ctx) -{ - uint32_t last, padn; - uint32_t high, low; - uint8_t msglen[8]; - - high = (ctx->total[0] >> 29) - | (ctx->total[1] << 3); - low = (ctx->total[0] << 3); - - PUT_UINT32(high, msglen, 0); - PUT_UINT32(low, msglen, 4); - - last = ctx->total[0] & 0x3F; - padn = (last < 56) ? (56 - last) : (120 - last); - - SHA256_Update(ctx, sha256_padding, padn); - SHA256_Update(ctx, msglen, 8); - - PUT_UINT32(ctx->state[0], digest, 0); - PUT_UINT32(ctx->state[1], digest, 4); - PUT_UINT32(ctx->state[2], digest, 8); - PUT_UINT32(ctx->state[3], digest, 12); - PUT_UINT32(ctx->state[4], digest, 16); - PUT_UINT32(ctx->state[5], digest, 20); - PUT_UINT32(ctx->state[6], digest, 24); - PUT_UINT32(ctx->state[7], digest, 28); -} - -#endif // SHA256_CTX diff --git a/user/mpy/lib/axtls/crypto/sha384.c b/user/mpy/lib/axtls/crypto/sha384.c deleted file mode 100644 index f1071be..0000000 --- a/user/mpy/lib/axtls/crypto/sha384.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "os_port.h" -#include "crypto.h" - -/** -* Initialize the SHA384 context -*/ - void SHA384_Init(SHA384_CTX *ctx) - { - //Set initial hash value - ctx->h_dig.h[0] = 0xCBBB9D5DC1059ED8LL; - ctx->h_dig.h[1] = 0x629A292A367CD507LL; - ctx->h_dig.h[2] = 0x9159015A3070DD17LL; - ctx->h_dig.h[3] = 0x152FECD8F70E5939LL; - ctx->h_dig.h[4] = 0x67332667FFC00B31LL; - ctx->h_dig.h[5] = 0x8EB44A8768581511LL; - ctx->h_dig.h[6] = 0xDB0C2E0D64F98FA7LL; - ctx->h_dig.h[7] = 0x47B5481DBEFA4FA4LL; - - // Number of bytes in the buffer - ctx->size = 0; - // Total length of the message - ctx->totalSize = 0; - } - -/** -* Accepts an array of octets as the next portion of the message. -*/ -void SHA384_Update(SHA384_CTX *ctx, const uint8_t * msg, int len) -{ - // The function is defined in the exact same manner as SHA-512 - SHA512_Update(ctx, msg, len); -} - -/** -* Return the 384-bit message digest into the user's array -*/ -void SHA384_Final(uint8_t *digest, SHA384_CTX *ctx) -{ - // The function is defined in the exact same manner as SHA-512 - SHA512_Final(NULL, ctx); - - // Copy the resulting digest - if (digest != NULL) - memcpy(digest, ctx->h_dig.digest, SHA384_SIZE); -} - diff --git a/user/mpy/lib/axtls/crypto/sha512.c b/user/mpy/lib/axtls/crypto/sha512.c deleted file mode 100644 index aa2f589..0000000 --- a/user/mpy/lib/axtls/crypto/sha512.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2015, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "os_port.h" -#include "crypto.h" - -#define SHR64(a, n) ((a) >> (n)) -#define ROR64(a, n) (((a) >> (n)) | ((a) << (64 - (n)))) -#define CH(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define MAJ(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) -#define SIGMA1(x) (ROR64(x, 28) ^ ROR64(x, 34) ^ ROR64(x, 39)) -#define SIGMA2(x) (ROR64(x, 14) ^ ROR64(x, 18) ^ ROR64(x, 41)) -#define SIGMA3(x) (ROR64(x, 1) ^ ROR64(x, 8) ^ SHR64(x, 7)) -#define SIGMA4(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ SHR64(x, 6)) -#define MIN(x, y) ((x) < (y) ? x : y) - -static const uint8_t padding[128] = -{ - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static const uint64_t k[80] = -{ - 0x428A2F98D728AE22LL, 0x7137449123EF65CDLL, 0xB5C0FBCFEC4D3B2FLL, 0xE9B5DBA58189DBBCLL, - 0x3956C25BF348B538LL, 0x59F111F1B605D019LL, 0x923F82A4AF194F9BLL, 0xAB1C5ED5DA6D8118LL, - 0xD807AA98A3030242LL, 0x12835B0145706FBELL, 0x243185BE4EE4B28CLL, 0x550C7DC3D5FFB4E2LL, - 0x72BE5D74F27B896FLL, 0x80DEB1FE3B1696B1LL, 0x9BDC06A725C71235LL, 0xC19BF174CF692694LL, - 0xE49B69C19EF14AD2LL, 0xEFBE4786384F25E3LL, 0x0FC19DC68B8CD5B5LL, 0x240CA1CC77AC9C65LL, - 0x2DE92C6F592B0275LL, 0x4A7484AA6EA6E483LL, 0x5CB0A9DCBD41FBD4LL, 0x76F988DA831153B5LL, - 0x983E5152EE66DFABLL, 0xA831C66D2DB43210LL, 0xB00327C898FB213FLL, 0xBF597FC7BEEF0EE4LL, - 0xC6E00BF33DA88FC2LL, 0xD5A79147930AA725LL, 0x06CA6351E003826FLL, 0x142929670A0E6E70LL, - 0x27B70A8546D22FFCLL, 0x2E1B21385C26C926LL, 0x4D2C6DFC5AC42AEDLL, 0x53380D139D95B3DFLL, - 0x650A73548BAF63DELL, 0x766A0ABB3C77B2A8LL, 0x81C2C92E47EDAEE6LL, 0x92722C851482353BLL, - 0xA2BFE8A14CF10364LL, 0xA81A664BBC423001LL, 0xC24B8B70D0F89791LL, 0xC76C51A30654BE30LL, - 0xD192E819D6EF5218LL, 0xD69906245565A910LL, 0xF40E35855771202ALL, 0x106AA07032BBD1B8LL, - 0x19A4C116B8D2D0C8LL, 0x1E376C085141AB53LL, 0x2748774CDF8EEB99LL, 0x34B0BCB5E19B48A8LL, - 0x391C0CB3C5C95A63LL, 0x4ED8AA4AE3418ACBLL, 0x5B9CCA4F7763E373LL, 0x682E6FF3D6B2B8A3LL, - 0x748F82EE5DEFB2FCLL, 0x78A5636F43172F60LL, 0x84C87814A1F0AB72LL, 0x8CC702081A6439ECLL, - 0x90BEFFFA23631E28LL, 0xA4506CEBDE82BDE9LL, 0xBEF9A3F7B2C67915LL, 0xC67178F2E372532BLL, - 0xCA273ECEEA26619CLL, 0xD186B8C721C0C207LL, 0xEADA7DD6CDE0EB1ELL, 0xF57D4F7FEE6ED178LL, - 0x06F067AA72176FBALL, 0x0A637DC5A2C898A6LL, 0x113F9804BEF90DAELL, 0x1B710B35131C471BLL, - 0x28DB77F523047D84LL, 0x32CAAB7B40C72493LL, 0x3C9EBE0A15C9BEBCLL, 0x431D67C49C100D4CLL, - 0x4CC5D4BECB3E42B6LL, 0x597F299CFC657E2ALL, 0x5FCB6FAB3AD6FAECLL, 0x6C44198C4A475817LL -}; - -/** -* Initialize the SHA512 context -*/ -void SHA512_Init(SHA512_CTX *ctx) -{ - ctx->h_dig.h[0] = 0x6A09E667F3BCC908LL; - ctx->h_dig.h[1] = 0xBB67AE8584CAA73BLL; - ctx->h_dig.h[2] = 0x3C6EF372FE94F82BLL; - ctx->h_dig.h[3] = 0xA54FF53A5F1D36F1LL; - ctx->h_dig.h[4] = 0x510E527FADE682D1LL; - ctx->h_dig.h[5] = 0x9B05688C2B3E6C1FLL; - ctx->h_dig.h[6] = 0x1F83D9ABFB41BD6BLL; - ctx->h_dig.h[7] = 0x5BE0CD19137E2179LL; - ctx->size = 0; - ctx->totalSize = 0; -} - -static void SHA512_Process(SHA512_CTX *ctx) -{ - int t; - uint64_t temp1; - uint64_t temp2; - - // Initialize the 8 working registers - uint64_t a = ctx->h_dig.h[0]; - uint64_t b = ctx->h_dig.h[1]; - uint64_t c = ctx->h_dig.h[2]; - uint64_t d = ctx->h_dig.h[3]; - uint64_t e = ctx->h_dig.h[4]; - uint64_t f = ctx->h_dig.h[5]; - uint64_t g = ctx->h_dig.h[6]; - uint64_t h = ctx->h_dig.h[7]; - - // Process message in 16-word blocks - uint64_t *w = ctx->w_buf.w; - - // Convert from big-endian byte order to host byte order - for (t = 0; t < 16; t++) - w[t] = be64toh(w[t]); - - // Prepare the message schedule - for (t = 16; t < 80; t++) - w[t] = SIGMA4(w[t - 2]) + w[t - 7] + SIGMA3(w[t - 15]) + w[t - 16]; - - // SHA-512 hash computation - for (t = 0; t < 80; t++) - { - // Calculate T1 and T2 - temp1 = h + SIGMA2(e) + CH(e, f, g) + k[t] + w[t]; - temp2 = SIGMA1(a) + MAJ(a, b, c); - - // Update the working registers - h = g; - g = f; - f = e; - e = d + temp1; - d = c; - c = b; - b = a; - a = temp1 + temp2; - } - - // Update the hash value - ctx->h_dig.h[0] += a; - ctx->h_dig.h[1] += b; - ctx->h_dig.h[2] += c; - ctx->h_dig.h[3] += d; - ctx->h_dig.h[4] += e; - ctx->h_dig.h[5] += f; - ctx->h_dig.h[6] += g; - ctx->h_dig.h[7] += h; - } - -/** -* Accepts an array of octets as the next portion of the message. -*/ -void SHA512_Update(SHA512_CTX *ctx, const uint8_t * msg, int len) -{ - // Process the incoming data - while (len > 0) - { - // The buffer can hold at most 128 bytes - size_t n = MIN(len, 128 - ctx->size); - - // Copy the data to the buffer - memcpy(ctx->w_buf.buffer + ctx->size, msg, n); - - // Update the SHA-512 ctx - ctx->size += n; - ctx->totalSize += n; - // Advance the data pointer - msg = (uint8_t *) msg + n; - // Remaining bytes to process - len -= n; - - // Process message in 16-word blocks - if (ctx->size == 128) - { - // Transform the 16-word block - SHA512_Process(ctx); - // Empty the buffer - ctx->size = 0; - } - } -} - -/** -* Return the 512-bit message digest into the user's array -*/ -void SHA512_Final(uint8_t *digest, SHA512_CTX *ctx) -{ - int i; - size_t paddingSize; - uint64_t totalSize; - - // Length of the original message (before padding) - totalSize = ctx->totalSize * 8; - - // Pad the message so that its length is congruent to 112 modulo 128 - paddingSize = (ctx->size < 112) ? (112 - ctx->size) : - (128 + 112 - ctx->size); - // Append padding - SHA512_Update(ctx, padding, paddingSize); - - // Append the length of the original message - ctx->w_buf.w[14] = 0; - ctx->w_buf.w[15] = be64toh(totalSize); - - // Calculate the message digest - SHA512_Process(ctx); - - // Convert from host byte order to big-endian byte order - for (i = 0; i < 8; i++) - ctx->h_dig.h[i] = be64toh(ctx->h_dig.h[i]); - - // Copy the resulting digest - if (digest != NULL) - memcpy(digest, ctx->h_dig.digest, SHA512_SIZE); - } - diff --git a/user/mpy/lib/axtls/docsrc/Makefile b/user/mpy/lib/axtls/docsrc/Makefile deleted file mode 100644 index 2826686..0000000 --- a/user/mpy/lib/axtls/docsrc/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../config/makefile.conf - -all: - -doco: - doxygen ./axTLS.dox - -clean:: - @-rm -fr html *~ diff --git a/user/mpy/lib/axtls/docsrc/axTLS.dox b/user/mpy/lib/axtls/docsrc/axTLS.dox deleted file mode 100644 index bca7d81..0000000 --- a/user/mpy/lib/axtls/docsrc/axTLS.dox +++ /dev/null @@ -1,1372 +0,0 @@ -# Doxyfile 1.5.5 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = axTLS - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, -# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, -# and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = NO - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = NO - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ../bindings/csharp/axTLS.cs \ - ../bindings/java/SSL.java \ - ../bindings/java/SSLUtil.java \ - ../bindings/java/SSLCTX.java \ - ../bindings/java/SSLServer.java \ - ../bindings/java/SSLClient.java \ - ../bindings/java/SSLReadHolder.java \ - ../ssl/ssl.h \ - ../crypto/bigint.c \ - ../crypto/bigint.h - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = images - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = doco_footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = YES - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = YES - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = YES - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = CONFIG_SSL_CERT_VERIFICATION \ - CONFIG_SSL_ENABLE_CLIENT \ - CONFIG_SSL_GENERATE_X509_CERT \ - CONFIG_BIGINT_MONTGOMERY \ - CONFIG_BIGINT_BARRETT \ - CONFIG_BIGINT_CRT \ - "EXP_FUNC=" \ - "STDCALL=" - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = NO - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = NO - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = NO - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = NO - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = NO - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = NO - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = NO - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is enabled by default, which results in a transparent -# background. Warning: Depending on the platform used, enabling this option -# may lead to badly anti-aliased labels on the edges of a graph (i.e. they -# become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/user/mpy/lib/axtls/docsrc/doco_footer.html b/user/mpy/lib/axtls/docsrc/doco_footer.html deleted file mode 100644 index 20c4e70..0000000 --- a/user/mpy/lib/axtls/docsrc/doco_footer.html +++ /dev/null @@ -1,3 +0,0 @@ -

-

-Copyright © 2007 Cameron Rich diff --git a/user/mpy/lib/axtls/docsrc/images/axolotl.jpg b/user/mpy/lib/axtls/docsrc/images/axolotl.jpg deleted file mode 100644 index 7352bbae836739e469c837a7fdb8114f786b2130..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3041 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 diff --git a/user/mpy/lib/axtls/httpd/Config.in b/user/mpy/lib/axtls/httpd/Config.in deleted file mode 100644 index 486ae80..0000000 --- a/user/mpy/lib/axtls/httpd/Config.in +++ /dev/null @@ -1,160 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see scripts/config/Kconfig-language.txt -# - -menu "Axhttpd Configuration" -depends on CONFIG_AXHTTPD - -config CONFIG_HTTP_STATIC_BUILD - bool "Static Build" - default n - help - Select y if you want axhttpd to be a static build (i.e. don't use the - axtls shared library or dll). - -config CONFIG_HTTP_PORT - int "HTTP port" - default 80 - help - The port number of the normal HTTP server. - - You must be a root user in order to use the default port. - -config CONFIG_HTTP_HTTPS_PORT - int "HTTPS port" - default 443 - help - The port number of the HTTPS server. - - You must be a root user in order to use the default port. - -config CONFIG_HTTP_SESSION_CACHE_SIZE - int "SSL session cache size" - default 5 - help - The size of the SSL session cache. - - This is not actually related to the number of concurrent users, but - for optimum performance they should be the same (with a penalty - in memory usage). - -config CONFIG_HTTP_WEBROOT - string "Web root location" - default "../www" if !CONFIG_PLATFORM_WIN32 - default "..\\www" if CONFIG_PLATFORM_WIN32 - help - The location of the web root in relation to axhttpd. This is - the directory where index.html lives. - -config CONFIG_HTTP_TIMEOUT - int "Timeout" - default 300 - help - Set the timeout of a connection in seconds. - -menu "CGI" -depends on !CONFIG_PLATFORM_WIN32 - -config CONFIG_HTTP_HAS_CGI - bool "Enable CGI" - default y - depends on !CONFIG_PLATFORM_WIN32 - help - Enable the CGI capability. Not available on Win32 platforms. - -config CONFIG_HTTP_CGI_EXTENSIONS - string "CGI File Extension(s)" - default ".lua,.lp,.php" - depends on CONFIG_HTTP_HAS_CGI - help - Tell axhhtpd what file extension(s) are used for CGI. - - This is a comma separated list - e.g. ".php,.pl" etc - -config CONFIG_HTTP_ENABLE_LUA - bool "Enable Lua" - default y - depends on CONFIG_HTTP_HAS_CGI - help - Lua is a powerful, fast, light-weight, embeddable scripting language. - - See http://www.lua.org for details. - -config CONFIG_HTTP_LUA_PREFIX - string "Lua's Installation Prefix" - default "/usr" - depends on CONFIG_HTTP_ENABLE_LUA - - help - The location of Lua's installation prefix. - -config CONFIG_HTTP_BUILD_LUA - bool "Build Lua" - default n - depends on CONFIG_HTTP_ENABLE_LUA - help - Build Lua and install in /usr/bin by default. - -config CONFIG_HTTP_CGI_LAUNCHER - string "CGI launcher location" - default "/usr/bin/cgi" - depends on CONFIG_HTTP_HAS_CGI - help - The location of the CGI launcher application (could be /usr/bin/php5). - The default is to use Lua's CGI launcher. -endmenu - -config CONFIG_HTTP_DIRECTORIES - bool "Enable Directory Listing" - default y - help - Enable directory listing. - -config CONFIG_HTTP_HAS_AUTHORIZATION - bool "Enable authorization" - default y - help - Pages/directories can have passwords associated with them. - -config CONFIG_HTTP_HAS_IPV6 - bool "Enable IPv6" - default n - depends on !CONFIG_PLATFORM_WIN32 - help - Use IPv6 instead of IPv4. - - Does not work under Win32 - -config CONFIG_HTTP_ENABLE_DIFFERENT_USER - bool "Enable different user" - default n - depends on !CONFIG_PLATFORM_WIN32 - help - Allow the web server to be run as a different user - -config CONFIG_HTTP_USER - string "As User" - default "nobody" - depends on CONFIG_HTTP_ENABLE_DIFFERENT_USER - help - The user name that will be used to run axhttpd. - -config CONFIG_HTTP_VERBOSE - bool "Verbose Mode" - default y if CONFIG_SSL_FULL_MODE - default n if !CONFIG_SSL_FULL_MODE - help - Enable extra statements used when using axhttpd. - -config CONFIG_HTTP_IS_DAEMON - bool "Run as a daemon" - default n - depends on !CONFIG_PLATFORM_WIN32 - help - Run axhttpd as a background process. - - Does not work under Win32 - -endmenu - diff --git a/user/mpy/lib/axtls/httpd/Makefile b/user/mpy/lib/axtls/httpd/Makefile deleted file mode 100644 index fbf2fae..0000000 --- a/user/mpy/lib/axtls/httpd/Makefile +++ /dev/null @@ -1,130 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -all : web_server lua - -AXTLS_HOME=.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -ifndef CONFIG_PLATFORM_WIN32 - -ifdef CONFIG_PLATFORM_CYGWIN -TARGET=$(AXTLS_HOME)/$(STAGE)/axhttpd.exe -TARGET2=$(AXTLS_HOME)/$(STAGE)/htpasswd.exe -else -TARGET=$(AXTLS_HOME)/$(STAGE)/axhttpd -TARGET2=$(AXTLS_HOME)/$(STAGE)/htpasswd -endif - -ifdef CONFIG_HTTP_STATIC_BUILD -LIBS=$(AXTLS_HOME)/$(STAGE)/libaxtls.a -else -LIBS=-L$(AXTLS_HOME)/$(STAGE) -laxtls -endif - -ifdef CONFIG_HTTP_BUILD_LUA -lua: kepler-1.1 - -kepler-1.1: - @tar xvfz kepler-1.1-snapshot-20070521-1825.tar.gz - @cat kepler.patch | patch -p0 - cd kepler-1.1; ./configure --prefix=$(CONFIG_HTTP_LUA_PREFIX) --launcher=cgi --lua-suffix= ; make install -else -lua: -endif - -else # win32 build -lua: - -TARGET=$(AXTLS_HOME)/$(STAGE)/axhttpd.exe -TARGET2=$(AXTLS_HOME)/$(STAGE)/htpasswd.exe - -ifdef CONFIG_HTTP_STATIC_BUILD -LIBS=$(AXTLS_HOME)/$(STAGE)/axtls.static.lib $(AXTLS_HOME)\\config\\axtls.res -else -LIBS=$(AXTLS_HOME)/$(STAGE)/axtls.lib $(AXTLS_HOME)\\config\\axtls.res -endif -endif - -ifndef CONFIG_AXHTTPD -web_server: -else - -web_server :: $(TARGET) - -ifdef CONFIG_HTTP_HAS_AUTHORIZATION -web_server :: $(TARGET2) -endif - -OBJ= \ - axhttpd.o \ - proc.o \ - tdate_parse.o - -include $(AXTLS_HOME)/config/makefile.post - -ifndef CONFIG_PLATFORM_WIN32 - -$(TARGET): $(OBJ) $(AXTLS_HOME)/$(STAGE)/libaxtls.a - $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) -ifdef CONFIG_STRIP_UNWANTED_SECTIONS - $(STRIP) --remove-section=.comment $(TARGET) -endif - -$(TARGET2): htpasswd.o $(AXTLS_HOME)/$(STAGE)/libaxtls.a - $(LD) $(LDFLAGS) -o $@ htpasswd.o $(LIBS) -ifdef CONFIG_STRIP_UNWANTED_SECTIONS - $(STRIP) --remove-section=.comment $(TARGET2) -endif - -else # Win32 - -OBJ:=$(OBJ:.o=.obj) -%.obj : %.c - $(CC) $(CFLAGS) $< - -htpasswd.obj : htpasswd.c - $(CC) $(CFLAGS) $? - -$(TARGET): $(OBJ) - $(LD) $(LDFLAGS) /out:$@ $(LIBS) $? - -$(TARGET2): htpasswd.obj - $(LD) $(LDFLAGS) /out:$@ $(LIBS) $? -endif - -endif # CONFIG_AXHTTPD - -clean:: - -@rm -f $(TARGET)* - -@rm -fr kepler-1.1 - diff --git a/user/mpy/lib/axtls/httpd/axhttp.h b/user/mpy/lib/axtls/httpd/axhttp.h deleted file mode 100644 index 3b4b5a5..0000000 --- a/user/mpy/lib/axtls/httpd/axhttp.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "os_port.h" -#include "ssl.h" - -#define BACKLOG 15 -#define VERSION "1.0.0" -#ifdef CONFIG_HTTP_HAS_IPV6 -#define HAVE_IPV6 -#endif - -#define MAXPOSTDATASIZE 30000 /* adjust for file upload - size*/ -#define MAXREQUESTLENGTH 256 -#define MAXREADLENGTH 8800 /* FF3=4096, IE7=8760 */ -#define BLOCKSIZE 4096 - -#define INITIAL_CONNECTION_SLOTS 10 -#define CONFIG_HTTP_DEFAULT_SSL_OPTIONS SSL_DISPLAY_CERTS - -#define STATE_WANT_TO_READ_HEAD 1 -#define STATE_WANT_TO_SEND_HEAD 2 -#define STATE_WANT_TO_READ_FILE 3 -#define STATE_WANT_TO_SEND_FILE 4 -#define STATE_DOING_DIR 5 - -enum -{ - TYPE_GET, - TYPE_HEAD, - TYPE_POST -}; - -struct connstruct -{ - struct connstruct *next; - int state; - int reqtype; - int networkdesc; - int filedesc; - SSL *ssl; - -#if defined(CONFIG_HTTP_DIRECTORIES) -#ifdef WIN32 - HANDLE dirp; - WIN32_FIND_DATA file_data; -#else - DIR *dirp; -#endif -#endif - - time_t timeout; - char actualfile[MAXREQUESTLENGTH]; - char filereq[MAXREQUESTLENGTH]; - char dirname[MAXREQUESTLENGTH]; - char server_name[MAXREQUESTLENGTH]; - int numbytes; - char databuf[BLOCKSIZE]; - uint8_t is_ssl; - uint8_t is_v1_0; - uint8_t close_when_done; - time_t if_modified_since; - -#if defined(CONFIG_HTTP_HAS_CGI) - uint8_t is_cgi; - char cgicontenttype[MAXREQUESTLENGTH]; - int content_length; - char remote_addr[MAXREQUESTLENGTH]; - char uri_request[MAXREQUESTLENGTH]; - char uri_path_info[MAXREQUESTLENGTH]; - char uri_query[MAXREQUESTLENGTH]; - char cookie[MAXREQUESTLENGTH]; -#endif -#if defined(CONFIG_HTTP_HAS_AUTHORIZATION) - char authorization[MAXREQUESTLENGTH]; -#endif - int post_read; - int post_state; - char *post_data; -}; - -struct serverstruct -{ - struct serverstruct *next; - int sd; - int is_ssl; - SSL_CTX *ssl_ctx; -}; - -#if defined(CONFIG_HTTP_HAS_CGI) -struct cgiextstruct -{ - struct cgiextstruct *next; - char *ext; -}; -#endif - -/* global prototypes */ -extern struct serverstruct *servers; -extern struct connstruct *usedconns; -extern struct connstruct *freeconns; -extern const char * const server_version; - -#if defined(CONFIG_HTTP_HAS_CGI) -extern struct cgiextstruct *cgiexts; -#endif - -/* conn.c prototypes */ -void removeconnection(struct connstruct *cn); - -/* proc.c prototypes */ -void procdodir(struct connstruct *cn); -void procreadhead(struct connstruct *cn); -void procsendhead(struct connstruct *cn); -void procreadfile(struct connstruct *cn); -void procsendfile(struct connstruct *cn); -#if defined(CONFIG_HTTP_HAS_CGI) -void read_post_data(struct connstruct *cn); -#endif - -/* misc.c prototypes */ -char *my_strncpy(char *dest, const char *src, size_t n); -int isdir(const char *name); - -/* tdate prototypes */ -void tdate_init(void); -time_t tdate_parse(const char* str); - diff --git a/user/mpy/lib/axtls/httpd/axhttpd.c b/user/mpy/lib/axtls/httpd/axhttpd.c deleted file mode 100644 index 6718dd3..0000000 --- a/user/mpy/lib/axtls/httpd/axhttpd.c +++ /dev/null @@ -1,713 +0,0 @@ -/* - * Copyright (c) Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#if !defined(WIN32) -#include -#endif -#include "axhttp.h" - -struct serverstruct *servers; -struct connstruct *usedconns; -struct connstruct *freeconns; -const char * const server_version = "axhttpd/"AXTLS_VERSION; -static const char *webroot = CONFIG_HTTP_WEBROOT; - -static void addtoservers(int sd); -static int openlistener(char *address, int port); -static void handlenewconnection(int listenfd, int is_ssl); -static void addconnection(int sd, char *ip, int is_ssl); -static void ax_chdir(void); - -#if defined(CONFIG_HTTP_HAS_CGI) -struct cgiextstruct *cgiexts; -static void addcgiext(const char *tp); - -#if !defined(WIN32) -static void reaper(int sigtype) -{ - while (wait3(NULL, WNOHANG, NULL) > 0) - continue; -} -#endif -#endif - -#ifdef CONFIG_HTTP_VERBOSE /* should really be in debug mode or something */ -/* clean up memory for valgrind */ -static void sigint_cleanup(int sig) -{ - struct serverstruct *sp; - struct connstruct *tp; - - while (servers != NULL) - { - if (servers->is_ssl) - ssl_ctx_free(servers->ssl_ctx); - - sp = servers->next; - free(servers); - servers = sp; - } - - while (freeconns != NULL) - { - tp = freeconns->next; - free(freeconns); - freeconns = tp; - } - - while (usedconns != NULL) - { - tp = usedconns->next; - free(usedconns); - usedconns = tp; - } - -#if defined(CONFIG_HTTP_HAS_CGI) - while (cgiexts) - { - struct cgiextstruct *cp = cgiexts->next; - if (cp == NULL) /* last entry */ - free(cgiexts->ext); - free(cgiexts); - cgiexts = cp; - } -#endif - - exit(0); -} - -static void die(int sigtype) -{ - exit(0); -} -#endif - -int main(int argc, char *argv[]) -{ - fd_set rfds, wfds; - struct connstruct *tp, *to; - struct serverstruct *sp; - int rnum, wnum, active; - int i = 1; - time_t currtime; - char *httpAddress = NULL; - int httpPort = CONFIG_HTTP_PORT; - char *httpsAddress = NULL; - int httpsPort = CONFIG_HTTP_HTTPS_PORT; - uint32_t options = CONFIG_HTTP_DEFAULT_SSL_OPTIONS; - char *portStr; - char *private_key = NULL; - char *cert = NULL; - -#ifdef WIN32 - WORD wVersionRequested = MAKEWORD(2, 2); - WSADATA wsaData; - WSAStartup(wVersionRequested,&wsaData); -#else - signal(SIGPIPE, SIG_IGN); -#if defined(CONFIG_HTTP_HAS_CGI) - signal(SIGCHLD, reaper); -#endif -#ifdef CONFIG_HTTP_VERBOSE - signal(SIGQUIT, die); -#endif -#endif - -#ifdef CONFIG_HTTP_VERBOSE - signal(SIGTERM, die); - signal(SIGINT, sigint_cleanup); -#endif - tdate_init(); - - /* get some command-line parameters */ - while (argv[i] != NULL) - { - if (strcmp(argv[i], "-p") == 0 && argv[i+1] != NULL) - { - if ((portStr = strchr(argv[i+1], ':')) != NULL) - { - httpAddress = argv[i+1]; - *portStr = 0; - httpPort = atoi(portStr + 1); - } - else - httpPort = atoi(argv[i+1]); - - i += 2; - continue; - } - - if (strcmp(argv[i], "-s") == 0 && argv[i+1] != NULL) - { - if ((portStr = strchr(argv[i+1], ':')) != NULL) - { - httpsAddress = argv[i+1]; - *portStr = 0; - httpsPort = atoi(portStr + 1); - } - else - httpsPort = atoi(argv[i+1]); - - i += 2; - continue; - } - - if (strcmp(argv[i], "-w") == 0 && argv[i+1] != NULL) - { - webroot = argv[i+1]; - i += 2; - continue; - } - - if (strcmp(argv[i], "-cert") == 0 && argv[i+1] != NULL) - { - cert = argv[i+1]; - i += 2; - continue; - } - - if (strcmp(argv[i], "-key") == 0 && argv[i+1] != NULL) - { - private_key = argv[i+1]; - i += 2; - continue; - } - printf("%s:\n" - " [-p [address:]httpport]\n" - " [-s [address:]httpsport]\n" - " [-key private_key]\n" - " [-cert cert]\n" - " [-w webroot]\n", argv[0]); - exit(1); - } - - for (i = 0; i < INITIAL_CONNECTION_SLOTS; i++) - { - tp = freeconns; - freeconns = (struct connstruct *)calloc(1, sizeof(struct connstruct)); - freeconns->next = tp; - } - - if ((active = openlistener(httpAddress, httpPort)) == -1) - { -#ifdef CONFIG_HTTP_VERBOSE - fprintf(stderr, "ERR: Couldn't bind to port %d\n", httpPort); -#endif - exit(1); - } - - addtoservers(active); - - if ((active = openlistener(httpsAddress, httpsPort)) == -1) - { -#ifdef CONFIG_HTTP_VERBOSE - fprintf(stderr, "ERR: Couldn't bind to port %d\n", httpsPort); -#endif - exit(1); - } - - addtoservers(active); - - if (cert != NULL && private_key != NULL) - options |= SSL_NO_DEFAULT_KEY; - - servers->ssl_ctx = ssl_ctx_new(options, CONFIG_HTTP_SESSION_CACHE_SIZE); - servers->is_ssl = 1; - - if (cert != NULL && private_key != NULL) - { - printf("YEAH\n"); - if (ssl_obj_load(servers->ssl_ctx, SSL_OBJ_RSA_KEY, private_key, - NULL)) - { -#ifdef CONFIG_HTTP_VERBOSE - fprintf(stderr, "ERR: Couldn't load private key %s\n", private_key); -#endif - exit(1); - } - - if (ssl_obj_load(servers->ssl_ctx, SSL_OBJ_X509_CERT, cert, - NULL)) - { -#ifdef CONFIG_HTTP_VERBOSE - fprintf(stderr, "ERR: Couldn't load cert %s\n", cert); -#endif - exit(1); - } - } - -#if defined(CONFIG_HTTP_HAS_CGI) - addcgiext(CONFIG_HTTP_CGI_EXTENSIONS); -#endif - -#if defined(CONFIG_HTTP_VERBOSE) -#if defined(CONFIG_HTTP_HAS_CGI) - printf("addcgiext %s\n", CONFIG_HTTP_CGI_EXTENSIONS); -#endif - printf("%s: listening on ports %d (http) and %d (https)\n", - server_version, httpPort, httpsPort); - TTY_FLUSH(); -#endif - - ax_chdir(); - -#ifdef CONFIG_HTTP_ENABLE_DIFFERENT_USER - { - struct passwd *pd = getpwnam(CONFIG_HTTP_USER); - - if (pd != NULL) - { - int res = setuid(pd->pw_uid); - res |= setgid(pd->pw_gid); - -#if defined(CONFIG_HTTP_VERBOSE) - if (res == 0) - { - printf("change to '%s' successful\n", CONFIG_HTTP_USER); - TTY_FLUSH(); - } -#endif - } - - } -#endif - -#ifndef WIN32 -#ifdef CONFIG_HTTP_IS_DAEMON - if (fork() > 0) /* parent will die */ - exit(0); - - setsid(); -#endif -#endif - - /* main loop */ - while (1) - { - struct timeval tv = { 10, 0 }; - FD_ZERO(&rfds); - FD_ZERO(&wfds); - rnum = wnum = -1; - sp = servers; - - while (sp != NULL) /* read each server port */ - { - FD_SET(sp->sd, &rfds); - - if (sp->sd > rnum) - rnum = sp->sd; - sp = sp->next; - } - - /* Add the established sockets */ - tp = usedconns; - currtime = time(NULL); - - while (tp != NULL) - { - if (currtime > tp->timeout) /* timed out? Kill it. */ - { - to = tp; - tp = tp->next; - removeconnection(to); - continue; - } - - if (tp->state == STATE_WANT_TO_READ_HEAD) - { - FD_SET(tp->networkdesc, &rfds); - if (tp->networkdesc > rnum) - rnum = tp->networkdesc; - } - - if (tp->state == STATE_WANT_TO_SEND_HEAD) - { - FD_SET(tp->networkdesc, &wfds); - if (tp->networkdesc > wnum) - wnum = tp->networkdesc; - } - - if (tp->state == STATE_WANT_TO_READ_FILE) - { - FD_SET(tp->filedesc, &rfds); - if (tp->filedesc > rnum) - rnum = tp->filedesc; - } - - if (tp->state == STATE_WANT_TO_SEND_FILE) - { - FD_SET(tp->networkdesc, &wfds); - if (tp->networkdesc > wnum) - wnum = tp->networkdesc; - } - -#if defined(CONFIG_HTTP_DIRECTORIES) - if (tp->state == STATE_DOING_DIR) - { - FD_SET(tp->networkdesc, &wfds); - if (tp->networkdesc > wnum) - wnum = tp->networkdesc; - } -#endif - tp = tp->next; - } - - active = select(wnum > rnum ? wnum+1 : rnum+1, - rnum != -1 ? &rfds : NULL, - wnum != -1 ? &wfds : NULL, - NULL, usedconns ? &tv : NULL); - - /* timeout? */ - if (active == 0) - continue; - - /* New connection? */ - sp = servers; - while (active > 0 && sp != NULL) - { - if (FD_ISSET(sp->sd, &rfds)) - { - handlenewconnection(sp->sd, sp->is_ssl); - active--; - } - - sp = sp->next; - } - - /* Handle the established sockets */ - tp = usedconns; - - while (active > 0 && tp != NULL) - { - to = tp; - tp = tp->next; - - if (to->state == STATE_WANT_TO_READ_HEAD && - FD_ISSET(to->networkdesc, &rfds)) - { - active--; -#if defined(CONFIG_HTTP_HAS_CGI) - if (to->post_state) - read_post_data(to); - else -#endif - procreadhead(to); - } - - if (to->state == STATE_WANT_TO_SEND_HEAD && - FD_ISSET(to->networkdesc, &wfds)) - { - active--; - procsendhead(to); - } - - if (to->state == STATE_WANT_TO_READ_FILE && - FD_ISSET(to->filedesc, &rfds)) - { - active--; - procreadfile(to); - } - - if (to->state == STATE_WANT_TO_SEND_FILE && - FD_ISSET(to->networkdesc, &wfds)) - { - active--; - procsendfile(to); - } - -#if defined(CONFIG_HTTP_DIRECTORIES) - if (to->state == STATE_DOING_DIR && - FD_ISSET(to->networkdesc, &wfds)) - { - active--; - procdodir(to); - } -#endif - } - } - - return 0; -} - -#if defined(CONFIG_HTTP_HAS_CGI) -static void addcgiext(const char *cgi_exts) -{ - char *cp = strdup(cgi_exts); - - /* extenstions are comma separated */ - do - { - struct cgiextstruct *ex = (struct cgiextstruct *) - malloc(sizeof(struct cgiextstruct)); - ex->ext = cp; - ex->next = cgiexts; - cgiexts = ex; - if ((cp = strchr(cp, ',')) != NULL) - *cp++ = 0; - } while (cp != NULL); -} -#endif - -static void addtoservers(int sd) -{ - struct serverstruct *tp = (struct serverstruct *) - calloc(1, sizeof(struct serverstruct)); - tp->next = servers; - tp->sd = sd; - servers = tp; -} - -#ifdef HAVE_IPV6 -static void handlenewconnection(int listenfd, int is_ssl) -{ - struct sockaddr_in6 their_addr; - socklen_t tp = sizeof(their_addr); - char ipbuf[100]; - int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp); - - if (tp == sizeof(struct sockaddr_in6)) - inet_ntop(AF_INET6, &their_addr.sin6_addr, ipbuf, sizeof(ipbuf)); - else if (tp == sizeof(struct sockaddr_in)) - inet_ntop(AF_INET, &(((struct sockaddr_in *)&their_addr)->sin_addr), - ipbuf, sizeof(ipbuf)); - else - *ipbuf = '\0'; - - if (connfd != -1) /* check for error condition */ - addconnection(connfd, ipbuf, is_ssl); -} - -#else -static void handlenewconnection(int listenfd, int is_ssl) -{ - struct sockaddr_in their_addr; - socklen_t tp = sizeof(struct sockaddr_in); - int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp); - addconnection(connfd, inet_ntoa(their_addr.sin_addr), is_ssl); -} -#endif - -static int openlistener(char *address, int port) -{ - int sd; -#ifdef WIN32 - char tp = 1; -#else - int tp = 1; -#endif -#ifndef HAVE_IPV6 - struct sockaddr_in my_addr; - - if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) - return -1; - - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_port = htons((short)port); - my_addr.sin_addr.s_addr = address == NULL ? - INADDR_ANY : inet_addr(address); -#else - struct sockaddr_in6 my_addr; - - if ((sd = socket(AF_INET6, SOCK_STREAM, 0)) == -1) - return -1; - - my_addr.sin6_family = AF_INET6; - my_addr.sin6_port = htons(port); - - if (address == NULL) - my_addr.sin6_addr = in6addr_any; - else - inet_pton(AF_INET6, address, &my_addr.sin6_addr); -#endif - - setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp)); - if (bind(sd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) - { - close(sd); - return -1; - } - - listen(sd, BACKLOG); - return sd; -} - -/* Wrapper function for strncpy() that guarantees - a null-terminated string. This is to avoid any possible - issues due to strncpy()'s behaviour. - */ -char *my_strncpy(char *dest, const char *src, size_t n) -{ - strncpy(dest, src, n); - dest[n-1] = '\0'; - return dest; -} - -int isdir(const char *tpbuf) -{ - struct stat st; - char path[MAXREQUESTLENGTH]; - strcpy(path, tpbuf); - -#ifdef WIN32 /* win32 stat() can't handle trailing '\' */ - if (path[strlen(path)-1] == '\\') - path[strlen(path)-1] = 0; -#endif - - if (stat(path, &st) == -1) - return 0; - - if ((st.st_mode & S_IFMT) == S_IFDIR) - return 1; - - return 0; -} - -static void addconnection(int sd, char *ip, int is_ssl) -{ - struct connstruct *tp; - - /* Get ourselves a connstruct */ - if (freeconns == NULL) - tp = (struct connstruct *)calloc(1, sizeof(struct connstruct)); - else - { - tp = freeconns; - freeconns = tp->next; - } - - /* Attach it to the used list */ - tp->next = usedconns; - usedconns = tp; - tp->networkdesc = sd; - - if (is_ssl) - tp->ssl = ssl_server_new(servers->ssl_ctx, sd); - - tp->is_ssl = is_ssl; - tp->filedesc = -1; -#if defined(CONFIG_HTTP_HAS_DIRECTORIES) - tp->dirp = NULL; -#endif - *tp->actualfile = '\0'; - *tp->filereq = '\0'; - tp->state = STATE_WANT_TO_READ_HEAD; - tp->reqtype = TYPE_GET; - tp->close_when_done = 0; - tp->timeout = time(NULL) + CONFIG_HTTP_TIMEOUT; -#if defined(CONFIG_HTTP_HAS_CGI) - strcpy(tp->remote_addr, ip); -#endif -} - -void removeconnection(struct connstruct *cn) -{ - struct connstruct *tp; - int shouldret = 0; - - tp = usedconns; - - if (tp == NULL || cn == NULL) - shouldret = 1; - else if (tp == cn) - usedconns = tp->next; - else - { - while (tp != NULL) - { - if (tp->next == cn) - { - tp->next = (tp->next)->next; - shouldret = 0; - break; - } - - tp = tp->next; - shouldret = 1; - } - } - - if (shouldret) - return; - - /* If we did, add it to the free list */ - cn->next = freeconns; - freeconns = cn; - - /* Close it all down */ - if (cn->networkdesc != -1) - { - if (cn->is_ssl) - { - ssl_free(cn->ssl); - cn->ssl = NULL; - } - -#ifndef WIN32 - shutdown(cn->networkdesc, SHUT_WR); -#endif - SOCKET_CLOSE(cn->networkdesc); - } - - if (cn->filedesc != -1) - close(cn->filedesc); - -#if defined(CONFIG_HTTP_HAS_DIRECTORIES) - if (cn->dirp != NULL) -#ifdef WIN32 - FindClose(cn->dirp); -#else - closedir(cn->dirp); -#endif -#endif -} - -/* - * Change directories one way or the other. - */ - -static void ax_chdir(void) -{ - if (chdir(webroot)) - { -#ifdef CONFIG_HTTP_VERBOSE - fprintf(stderr, "'%s' is not a directory\n", webroot); -#endif - exit(1); - } -} - diff --git a/user/mpy/lib/axtls/httpd/htpasswd.c b/user/mpy/lib/axtls/httpd/htpasswd.c deleted file mode 100644 index 91feea1..0000000 --- a/user/mpy/lib/axtls/httpd/htpasswd.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -int tfd; - -void base64_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen) -{ - static const char b64str[64] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - while (inlen && outlen) - { - *out++ = b64str[(in[0] >> 2) & 0x3f]; - if (!--outlen) - break; - - *out++ = b64str[((in[0] << 4) - + (--inlen ? in[1] >> 4 : 0)) & 0x3f]; - if (!--outlen) - break; - *out++ = (inlen - ? b64str[((in[1] << 2) - + (--inlen ? in[2] >> 6 : 0)) - & 0x3f] - : '='); - if (!--outlen) - break; - *out++ = inlen ? b64str[in[2] & 0x3f] : '='; - if (!--outlen) - break; - if (inlen) - inlen--; - if (inlen) - in += 3; - } - - if (outlen) - *out = '\0'; -} - -static void usage(void) -{ - fprintf(stderr,"Usage: htpasswd username\n"); - exit(1); -} - -#ifdef WIN32 -static char * getpass(const char *prompt) -{ - static char buf[127]; - FILE *fp = stdin; - - printf(prompt); TTY_FLUSH(); -#if 0 - fp = fopen("/dev/tty", "w"); - if (fp == NULL) - { - printf("null\n"); TTY_FLUSH(); - fp = stdin; - } -#endif - - fgets(buf, sizeof(buf), fp); - while (buf[strlen(buf)-1] < ' ') - buf[strlen(buf)-1] = '\0'; - - //if (fp != stdin) - // fclose(fp); - return buf; -} -#endif - -int main(int argc, char *argv[]) -{ - char* pw; - uint8_t md5_salt[MD5_SIZE], md5_pass[MD5_SIZE]; - char b64_salt[MD5_SIZE+10], b64_pass[MD5_SIZE+10]; - MD5_CTX ctx; - - if (argc != 2) - usage(); - - pw = strdup(getpass("New password:")); - if (strcmp(pw, getpass("Re-type new password:")) != 0) - { - fprintf(stderr, "They don't match, sorry.\n" ); - exit(1); - } - - RNG_initialize(); - if (get_random(MD5_SIZE, md5_salt) < 0) - { - fprintf(stderr, "Can't get random data\n" ); - exit(1); - } - - RNG_terminate(); - base64_encode(md5_salt, MD5_SIZE, b64_salt, sizeof(b64_salt)); - - MD5_Init(&ctx); - MD5_Update(&ctx, md5_salt, MD5_SIZE); - MD5_Update(&ctx, (uint8_t *)pw, strlen(pw)); - MD5_Final(md5_pass, &ctx); - base64_encode(md5_pass, MD5_SIZE, b64_pass, sizeof(b64_pass)); - - printf("Add the following to your '.htpasswd' file\n"); - printf("%s:%s$%s\n", argv[1], b64_salt, b64_pass); - return 0; -} diff --git a/user/mpy/lib/axtls/httpd/kepler-1.1-snapshot-20070521-1825.tar.gz b/user/mpy/lib/axtls/httpd/kepler-1.1-snapshot-20070521-1825.tar.gz deleted file mode 100755 index d1caec5a53f93f043a32ec04807dff259223c32c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768249 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 YXxC^qAC}G&Q`96+aR{7@ixnC?xYwp`@XY^ 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�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

2bm+X^54>e7*eCs3InBgzoH zX~a#~Hshu1huW7Doy+h1z3-e#_$iIzR$k@%?|#m|#ytJrJUV5Y`o<@25?@_vK$9w0 zto{K-mH3tzMPhhM4S>yGn9%+?ubH_{MP+)%P+)D!Qdx_msT|!2=snMM;UDnXu}Y}_ z{nY@GyPpPzWUIAeSUzlAP3*_t8Dz_UhgLrpPN%y&lbODxCLq8_ce5sr#Uv-7U+q)z zqr><<)A1QQjdXs>-MaBHU9BR4%ZiHSHnQ=V|Cm({;vzf0_dnA^XLyTAfdlW|?vKb5 zsQSnyL7_5#6Gf5%MQ7AdeoZwh)n@d9xT>^%n1eg_s$Yn1jkuDW&$D7oBmYp>+LoTi z;(D`jezTrtL7CM@R=?)8-k=cCUy|hBw8>_lo4Zi4RPM`E5b}~V5&F;c{~g9PBzQ-u zRC@6+8t`3dNUbQ+pY}o zq4`VwUEq9#9#uLm`+#?(lX5LQvee=~G-TI{cF)P4R<*+Y7L5(PkV(#qVN zp*x}BW_kCwB-lOkrI4xCC%5az= zerJ%J(=vZ{& z3oK}7*g(gbw+Hd&`W~?+UMXA_~@F<*jsYK^7PNGYU<8HrA68NPw*p?zV zavdhuA*$f<-<=zArDeYOg&aAPC&#SrwwzInosYO-f;m+Vw`?OfU!-Uh$`vXn=-i*9 z&V_lYU>^ii3kRC1TP)VcjO*!1YZy##v?U^2sO>!>-Wj*96{29|p&@1v4EB_sgXcn047#k)jp%)`hfnzFu>qYY_J6`YfXP;@a_B*B?!@ ztedDm3qfpXCsl`-Hz+sW$ph^0nhV!6Z6nKb&UZZvo}$UQ=sI?>b)Jt^Hnd(pHQM`C z`6)xG?f2yi%5DWYd*oSwQ3F`ZNDQ)uOcG}Q z*~Loo-tLJT|C&GvDkym2d`>M8P~L|st*)$tnTTJEZTbxOAf^m5FaNWSL^SMX%h8!R z?RD{et(#|;K^!9^OIIx8*SQdtFGLuWv{`ld$sml8oYP*(2 z{T%DgIFSh1RrhOJ%G-sFuW76o<0~X-tj8>cBKnWMIK4@c98}2J`znFsexcy==bf=> z_3E^uX9M)Nmu6sE3+tW*|Hu4B7iipP+og|n6%37}S;oD9u8h*P>6HD1`t;^Mr9D@}d)9aFaeO>n z4-ZHEdUq>AZgf37Vkkx2NqiuKhnun6U4ynG&UNuo884vO8# zUWhU!{Rw3_ReFpFDjkuz{ord(xH66P2Nns97q+=Lv28xtr*Pk6fc~vZ^66x&TNGkt zs7=<{MTkRgLAN2&ea{215^q^!3TYlc)T%bV4ZkqTNVyGsFyoud`P0x1!KfIIE&s&2 zK>s#!A*(@l`RnVUNA!Mn+0`8%YX2B>-V3+Qxmr|oN#O0Nuj`4$gACK>88uQ5j!M?m zx-Y$=pQ=JhmAL+Ia<6Jk$c9exsdRL6LeAe)i(SW?nkfFXD^DwTL2yh`U>eGppN2P~<+(i^AOXO{zd)UgXFH+2!N8vUg+1&imV47uiF` zL1_L1n(6|}9&rvja}y2Kqw!ujL%lADLurtTzP_;MDztmpv?8F#-<)41^7@f~C*15S z!tsgSeXRlKE)IrUUJTO=mZ*|7X{P5KbqZ;RpK2H?SnjKhZ%dlvvU`&64L;ZZAzgLE z5S+@OXKdZ)Tjuht*RocAm_vn+`5|S+vQLh@(``o+I=-T`H9qd=kx7SaYUQ8lqqld; zdRkYebt&$WiCoK#QnqlHtEE+195y-KlztFGPg1=_vM@OHw(O)AT*L)e_2Osf<9R`Knf1!LC8qVq%g66y_xY*i`McU18hhuHPl5X1I^Pn}HX581 zbnG9KqjR1R*xu53EB_cNg zUncG?bbj<4gCTcEW%S!q2NkUpz~$3P$7PFHvK#z*J)mm2*l4L|#>#95M28+D5udC=fic;k=S@(H7P z>%*OXgQTVnCeZMk;~TBl_4l)LSMkWWJ1v~jWz`>UD~Gt7vn1qB0_fOknNRBbg*O#!PU`z8zn@)jdrHmGzbDsr@6l1gkng(> z1=nh=;+3_@DDE zd(>b&v!0D}4dhw&Pb)_Oe|MRvovlkiQBw7I^#ibNWb%@#D3?m;^F*8A#<7)FKgpcW z(I3pN+)n+6m{m=txdw^+`+WWZZ251`r}CC}QMuB^9)k6KcF|sYY1gE$L|t+W){8%E zRXcL^x3PGjvt3>;Tgv3?*rWoKZi^2-xy$JO)r`I`95Nm-%+vUO)!}I6^*UK9y}f z*79%bQr$eo7iPyoVLGQLY0H5N7<#c}tBdnaGQ2L-+S?c~YWTpYwUC>1V#c#G{S6(b&`oKVOZm~8JM(1!!S~5# z$=&}-eHH~*=K@qXhzR(k5oT^~45t{&+&fYUfLYwFynryek416#y1qaXTC2Ua=^GxY z^54T1r3i19qi(CeGDK|E&{Glx-@LVX`&r`O&##BAGfer&a=HvRMjqP7enijue502Q zx3I^d&tLrXviBa}_+W!{8Oiy~pxP6UGF1jBoDOe6MOmtQf--JBJV;*|?4*{#{3+U+ zqH#kBq73%kr{}OyYRW0>*%Jj6jifiFP~g3W(#FLNz2p$ir6*d-b~q@Xb$B6g^*V$B z{PI6c-X8m!Kt-fTOAsl*Hw9FV#6eiRxbR8fMt#$`cb3UggCzmaegeg5;qaL(JgI{e zel;Q4DO0L&8+C)~vnJ>UI zglo{X#m-J-WgIKALY=V7_yt160o6brU!meQQ?qmE1T{qakV*JFtHDOn zZ|06%?quNnPol)EEaAUd3rvXM%v3op@T!)ZJeeXPQBPSRrwIT==&e99=3n@VQQWXKjezdZPF_o^mzZ9_ z0LbNecWWABYv<2fbvJ~QkUn!~vlnDnFHOx@6N3ianL;Ow2VmKkpi%>|n$zf<8?I^< z+Az|4wK3)m@;cj|m~eK(kW_nPs-aP!}>UGWsuifK>*TcFMm{0Y!s5^-|&WBP@KvG1gUnFTO;_%V?u`5OY)rGz4#^^6h?qvy0{NIeElE z9Y+9vo=biXDu$dTkboX%d$tQHhk5k`szSd2QzMx$J81;j8P`_Vt2ZA=AyLR%v|)T{ z`+FmgpJ?o>Eytt^%Q6?;)kU=20^_?$; zLgAt81qI>Vx16lJ$@N?lDc`A}GmKXO-k*rDeeI3tosfV`6d}*CR=HtnjZTAI9UIY| zKBfCB`ohxdV%YG&$&TXMd}6--K;6=|KNE_SAS2RvvRqj5Wuy~ zxvKpfMvgNIVaSHhJ1;z9BUy--msf;~1fMw`Y>TY3nv3B_Qy0g<+-I$;aJARfl)s0? z79fNyCCy2w-hjAT-RX5klP1))6?Kd?YB>BC-B`UF{07EV@6?L2iZP;E zTJ|AI3?)D-A|S4cXD?5W(But~P5@~F&W$827ATb1c^;+C%D5SP1K5!Hh@3UYM_Z#* zN3CgE9!<52|UM9mMF#dwT*P zuc#XtHlw+xUX5R#uO7;|yxZKojtxWClhjr&pl`LlI}t$gwl;R67(&P`+2H{YVm&}9 z%+d(!C4btOKIl;wEYC=X~v(yx|fr-8Z@BSytppd&P#}*?#E6 zI7@vahr5%_cI{Py$4&cKnmHM__SZWIqnj$hV$&33CKf9c|n>iHywCiw56Fc^ZiuOWEaqW|1p z{k&Vf=ZdcwUqcygcQ9_Z2GeRMNs!*&;g~F$w**k-_qSgKxuiBM0*M5J4bZh2J_;FN&{($UWC)AaukkGvzNk;T?KmVR82;bkMLID1#$1? zHf;=f2f_#UItXA{BJGl!-GqdMIHVlr2yKTxgo-MtfUvMUxK5%B(mpWh?Q$H#WlQwN zV*2fajxQQ3j&R*I2mp0RITwUl&n@XT>nMi)I|;_yOIYRg%6l#aNOcaP@aLz6^@M5S z78oeKeh79zE(LZ%8`D#V)AQo1Djeqa_rsKn<D+f4!Ph5y#69R|d03zE^%(Gs*V9}C-1ubEmtnMclB@f_j@ zG4-Tf3X>6PInylC>wM%4i>EACOasrIJH>pcWAq|(W!rE>sRIbwG{}S8X+nW@YnLx! z&Y0cm2p{kgDr5_}#%_U&b zr`;jltG1Nmz6b$?_4yVCIP17Ry>SYfo&nFF!*MmhVHj8swOwrnlRx9p=62LuZHBoa ziW9$+$0DKRfq8utp=G!Czfk#8Tt67h=6p0fi1KkYhlTOT|0KVQ>Keq$;mT^{=eA?s z5JmK>?do@`W%8YO^1~NPD4WwI`5VXQTQmO9R<&H`L5pi^v!FETmHaMxM8ns0^mb0N z5rjGqfX}-(f_gk)_jbzHe{*e&6_NJlQ%k1s@#?Zp3l{PANK(ZonUd4hQFR2;v^i@d ztxSC~ixuu1=>&2gOvG+**3T!2NK%ZGX+iaw_(MpCJ$SHVutsK=i3ioA_KyvJ?s8BL zTkxs2I6a7Vn?dAnIaG_gg}vndwKI?Xu+WE})R=Bk0odn9Ky zsOe;;LJ9hC^~77>dw^!CAzv$cQJTb}%2+yGl1ywQ5OM!4`+K;#M9`F(GRzSD2wwpB;`Jpd2%WL&xAH3d7k>pZ4x zHO_s!`3QX!j<(%FzG8`Dp$)IcK?Xqp?|P__*HBW`N+{K%w*rBwI;)!Ge)B^wq?>M< z1t2qMhs2YBpoSW!`2j`r#X>N_Fv2b#>$P0FTvF>9I)VlUvW**o@Kk&63Y+b*d@zc- zw>s}OyVKpv3OL=BG!v;kKL}C8=@?M3Cz_K6&LefMlSbhA?u)>Ilye?WM)kT)Oa9y$ z-zb(@Mm`}z+z717UM@IR1j=!4Y{7Lo-xgFgLY`M0`%iq33JG^I-H3Jhb5(DZ+aK&YUFgy3I!g@A^e>02+3iWa2$olQsbRZOlw^ zm3zo`XSLURF^Z%eDgFm3<0QhH2yL7^c2m7X?j)CIXAdRik2l)UuNkEmF_1Z|n8fSV zIP6ypP9Vr_q%eU2+&m@gm14#*rME+}h`j1IvvyGoDEB%jHUY*Ag=O(r7W}WJVLsQR=&0wg*W$eHM()ybfAQ=mUd*RB$l6mNMz*Hoe zIE$~>SQ$*wA9qzhnN9*b_&BWi=22HVF?DwMQ?OT^5AnJg4^yWYE5aWdlXf%KtXAi&(-BEJZk)NjizXmgTn z<{^8!na6{w@ZQLRsGhe5IsY^IwW5vdAl}2#eEeQH5m+p(x zqm$4Uof$agD9n=`9aVX z6gie99^f`Kjd(Ani4o6?dgpk~;wx*YL1otVV6Og?EJ~+v ziH!IAS^Ipn?D=SSI1kCl;^=pwi0pYsZrP+E6q^O8w^+f##O`BnVyb3qglG193`OLq z!EF;FtX$IzJ{|mdeTV8Yhz;$1`}iWV9jUxVJ?V?A2f8atxzT%an+!X1--eORL=sC! z2ZgOk%V%b@+!VCTErYVxmmBC6i#8`!I)qp&JlV2bm%!OAmiwY=qoI@)c^ANSHE zZyU|F;!L51$q}YF)Q$G{AtF^G3y1qb+6bAQ=@Z3_uAYH`m1kbkHt3OLjJx>32rqLX zrmKibW`la~47Wp66IY9i8aA4*)1O})e4~Yk<`Lvkj4qQp;q<;>O2r;*rCR96UfNXI zY)mV@mPpG3s@ZX1>JykDCKaM=vo_RHB|UIXc_{~*0HV*PHWj&D%F0yS_~Pe*F9)Rx zNWQE{@+n`+*8thu$i8tLt<|h4p^P;+w&YE-@dQlF5tE7VhRs!V$wqByr)8J}Hi6g# z>x$;eEsy1Y5X#?^_1{;|0C; z%#r-zs*F`h15P>5D20(?jxS$9ACoKmIke@dSP=O%W*qxI3MMR>CR=C+nJ6>tfa#uP z31DieC{jrzm(N)_7I=O#%(hV?XSI;jF{+NNly?7kOyU5@6Si|wH^6-|=Tl|z2HwZx z;5nyG0QGE^cXBUnVBHN(PF6c$g#+HuC8E@L*Z!l$i!jrQWTzI zxjWNJ&_7dLUO@EgBD1TCiBZbjCd9vmjgXcgvG@imo{8d)#mx^=&gPh?vRgg%>UvO& z^B|e95~O}k014!#orHlGydTM|r-TW664O>FlzJZW9x)bkOWP9ev8xW^CbceLz4!Sp zybJjN(})V^i4#(;orD9izVQUNq|pf{`0vP5+%~wx(omo?h&r&sH`N&0Q0mqZMfLRF zUYO)QI79B#fl)gr10?R(d%rqCDpa|zE>NnUB&K*4He0`W7&{3lSMGuUmv16Y-^UX3 zZ;<-(gB!@B7V%(3Jjlbr@E>ueiz81cVT}l^!iEXSI0)7S8A|b~r}gc+5z`0}@l)eo zo!xwrJnoBYjm+9w=Su|~fGx+lX!+_fWdh?v^_SD;s_wT4D><2$ znT!x1@7{oUwS~f$xSahYsK2o#jdjFUDXKeV4dgyC|JwH03fmE|F33skjECx0DGa;X zqshmwH~^&S!NytQ0$3hxn-_tfpC+~ss@K}$NeJs3jeF+_H;7ark8oGF{@=vv`jZfE zCinG}p$=`HX{xQ1*C9z!#?WnDja8z*1SLV5aKO7Xo+D=EA^06D(2RuRmtmQBxzuTJ z@;DsrjGX|I&Zaig_<9{Jg-6)k$`G@%~=W2-r~<(Y?48MUiEbQHaD zJ>89m8lYBp5Bvq-1v19{x=e;=4w!j38cpG22A@+}QrCg#r6dJz>}lComq8?>I)F@^ zG{S}|O?pv?ToEeXRCjxVkwtWgPX$o~fUew{+n!45xL!P&rvjKg?bn_?+pd{)yP&@@ z$)0bYV(Kaza04O>)K(P<1gzF!*etd4+`NOUrccNd48QJ;rxs@{9f5qX`cQ|nvZ~fC zTXpHJVt^sFv-m|4Jgm?2Xg!(7vk}@JWGnBvQEW)`v>|%KbX@kxc|tSZGXYHG{jXlF19ahfj@yG=Qb!vOGws@-dgf0f-eXN0DcRt+ZlRX-s4YGG`5t1^;NE2%} zeypD_*LiyaDIGUvai_D@SKk*7$l&5;MZ7lGs_12kF{zpaTrcZ=kn?=biHWzzX`NYg z%>z7V!z4=ubPkP?f|AcUcu=Df&ot@}Lnj0pzmBmpLecoSFbvAnaJYT4T*a^zuBLaA zWyUQ#ePC3vLm&NY_v=wV$S2y6tCL0rF0+-F^Xa8k?!IJe?fH!VyZxP=1`zVqhcrYxZVQ-rln$;L17YSb5d zL3Wa}hwY;lW_qyR^5g+^H~4z(aqi$GE6a{+U%@L|wR3DjHP1z?nHe})I9exldONm` z$zW!7wb6BvhHszvV!T}D)D)#~uSwK$4j;#3==%8Nq|cG+Dsm+fn^<>{S*$L*-&S0` za2CYWI93g5^-h&S9Uh=2$JFGjtv_$BYGBC3JbVRYAWe*kh=vSCsKfX@Nr_LmQRanD zByrN~$MsZlA%_ncYbBB(Vbib16}!QC0;F|seorA;F_>dEWsXf!ca z1UPcMlf^9uUP)t}i17Ao4YZ);Mp7uGNlw@1M~RvU5jOOC$bb})>RuS>3Q>mFZ&i`1 zXKmZn+B@+co%?9P&**WK=5SvG^$d#hz9IYFe)i;DK>ko>wj+ZLhkiLoH!v5c5S9JP zIU)a5t6=r_7rZJQHXiTwz6bw};pJ7N&xwht8uI%s$lDEuCuSTS$>I;s;Y0`;PoyRR z6P+(gw2cVT48nH6AU<){g5j`eiFGqW@q=a8w}i7C3{kY-GsQBW`2wA8;*>Syw9uIS zq?uSdZ6EsWcTA6Xd<2iDq$5MA#XyC?KmUpkq^Kvq^ON;829j@aaQzKso^Om6DszFg z9FI_+Ggd$oYFhC>h%#J}T^?Q(DPj#RJ8tKMyr`9Zts^C5 zSoOMGVKdldk#tZl8kP84u7k|z#%|dtVCe5DPt@J1l3(^|c~kJS@l&63ZG$S4bJVxQ zk<=!(dQ_f#WjuQ=c2}27bbUYdKq6%IV|G2U%xZl*C1kbbH1jhB-_V0V#*c{l4!O4 z>=M~$<|}2wyhf(De`nQJx0wS?e%Kth1nR|p-&E8e|N8Gdx6!Nbp6D&@g+z@VZ!0HF zY^td1^_5@XFc!WBgM)>)_vOb^E@k4#z7a&&gKZi#qW<_`{j+me#wX@bi-aQ;v7AE5 z<2fqb1^gnee*Lx=_78JK-qD2bp)Gwo1}j27Xsp%!lu)iUFr4pMI^!HR*Ow@klT-Np z!(h@tf-V;)v0R7R=X*V&v$)=Crk?jj>r~F!l>YcpZ(|j$vzKiK7V%04|F0z{7a3m$xFtRY9tc*H`adNRAZ@}>0u-XJ9`2AN`DmE z8=n^IdHg|fa%wzQ<)+))y=#TnSHfBVJE8Tb+nNL1J90z9Yrb8iZa#ddvFoU?QOY-| zuU^!Ei*m1AW1~e_!`ZoB57gkYWBWbGwZs!G(w^mN^X4G9~?98bw9+; z5dCQ7I<{hdWr^Wx!+hafrrjI&{??>F>8i+@vaug4MzQL?f0EnsE4=T9*9MJPc$Toe zaA@s+PRCyyygT?YF8O`;Pl+U&ccT5Q*k^#7N5Evi@If&lpTnomU^cI)npcK_l<5fF zpqx^-qKJSz!cygb&WsTU|7reI^G5QTo0^s{KP;&tgnCXTT79y=Yu{UC5Q};JN09S} zUZ`rqmU7ZR^}(F8l<_E0K)GY>2uEskxqafNhb_I8=JX`i?vgF4_48-BClBSNh%=o^8XU^nKuj9p zu=Dj?z9VuWBltr3B+}n0Q%6IKk+p{?&1y5fh#U5jHZ-CrRBmK9@1puY_j4%nb^Xwh zNY(%0w$d1E{cOdfC`f-#{HMX9R(#)N$LW86PPq_8*SxF2v(aNgkN%F$ejB9$>*=>W z4h+Qdh23UVvP7?-9DX)r$c&A+Y~ zREyYcPq;<9!6P&A*7@$;nOYS)9j_Uy(MCS*ze=n$$wV#pVTk<)qjh-kCEZAq6>&KE8QSZS-R9tA_nxd3vi2{DrN<=TVrur~W&WljC7ndA(V^scR+v z$}Y!)p}080zzlG-?3(a)-6M9xIvI9;DC+9u)2HGY>Mxr2-rFl*nPvEf`mn%qegm;a z$zBX~7u8KkqHB-uR#ZjIZyDwNw>`z-tgYc3ZFSpbKlxfdAJe407aS~~zGCD{?f%FY z*dhNY>JLLrTJ%WR{{d7$tG}$CbvU1&XK$kazLq($*j?Wx2wMRAFfA*orj9^N0QkQ?uKfmCxz&(zd{oxM$J_0>-|t38K-eSP3f zoW5fv#wmI>~ra&sUpmm|c zL!Fk*VbJzt$K;FRa;IH`9V1E$vmyTnwkmOA>3Un;4VQANuP{B2>*pD_L`Xr(D*Y4S zdKV;FtH^c5g$A!Ik)lT@OQ2#2DrwEj8RLs=ZKFQc;o2@JgD}Hl|8i+x+GN#S7mE@R zGcz;nnUcbjB0@#UW{Tl5AsVwTdAvvvd28~et2{y>X#y0^36}v1#4>2Bo=?IeX!p>d zBx~QPp*)RJXp)3*(E3#4n=SE*DzZBwBFHgS*9slJ$k8n{?(z5J#OnAv|Hy+wt#D#sY_N1C=U8 z<;1qc4mM1IPMtcXJa=xYex9#zO8L5dJ0&F-;m+N1t@hab`T_JNd43emeN*U{2+6$) z21_^(lL7s=oj4&3bgsF1Xm7}goyTiBY!AzUcwyjkTYXiNltITIpDPa=qs0{rQ!)uWc|s)iW1N?l}Ss_&Z`)AY5PJT^B`90 z@4RlRopZjc0S^D|=&Os1*)*Dkqhm+>B5mtE(~0-&5?qDW=3btUK%WV56P8Bnv3%y4 z`TP4XTej=`d8X*q;~h!oIZHO=&BkhLFHu#+84k*p?o4utxYU1W!W5{ear4Ht>(_gx zyJ*U$kZ&*7VHm|93C_55$?TvngefhOu_d&2rhFllC;cXC5*n2IiFs5~d{yzQvP1YK zR+Gi+*1vcux5r%MLmvALZbo#(LG$+&Nr`XuY$|icb@@G;9u^TXXfU)~O!&gySz7B# zV}c42Wp`J4eq|Xck(+_;xOn#MP8<=i%co_r3So}ZLwqH}mG}AFmsPgw%~M#|l<={= z+J4Q<%B&}rLIDLsg&!M;6`QWyJ$#~epeJr_>cqWxgZigUp93L@u##9#u`ncOY=D7! zL!8z!z7BPQ_#?I@dY|&1myY+OcL@6_I@XH#+uY3cd%4cW_}Yhf6^#doCG;&QYmU)sUSVcXz=TMV0}r z@!HlnmC5wD(BsE9H@W+F+h)6!x=ww*dc6n%3-zBm)!)7GZnjc#}3YTxjOVj zO2O0H?nS!`8q!5%w~I=u&7Z#ydA_~c{mzi6!kkozBKEO_GH7>{mm@K!Zj&BUUuj-K za#S&3%F4=O=v>IA6)!~z*zk2w8FP!Fn({4c=ePjj?B{CN!gma`_Z?=d5!#xU#qO$a zkddt!+%faC!P5va7HQ`3h1Yt({6dVW7xbCjsAnP#HIKGEIS^%UGSC9Fjr^WS@rX|e z`h?Wf{ckE(tveTZMS9{_8O;-o>Ra@y8XJr16jZz?*{HN;S7ffqcODPNA9zx>SbFbp z_g<~jHmMp%+wtpXzB#~l&1ri-FX@iM#6jvKp|Fa?^l?x@qQo4Tt6n8&&Ic}zhw!Ahd6Ef>=RVzj_of_| zc;55MntYCJY^b_tra{0tO4BVNoujcy@<-x&?&NdboFKi=bDVuiz2f#D5yX#fi-hoeVuMcLjK6OntFZYU( z$$pTaA5@X#30>;N8TmIYyRgim{BEl2#g=AC(=Rj@%k!x1lvln_GlxR!^OeFsIoy*f zPN zes!*2L0R+JRKnN(+Rj4B*;=K-BD>?`cS9#KFTCt+?VM-d@Zsb23c1C~&MtR@R=6Rx z3SYZA7M-7inK;oT;M}EE>R{6@8PzBKI~yiGKEnk5?Q;>)e%3i7wTq{jbr-IF{d{+o z=g?EH)GdP@T3ZInI5{#~#c~ZOVt#hVHZo%Gwge0)S(C10`&6`X^7kuQZyRj+Dp4KN zQ#5&@fktVzw{LBM?keIr3tO+Zw>F85gVMz($2?ai{HCGEXu5Uy@L@P{PhIXK&TE^J zhQd{8X^eGruSpO^(-7*rs^>H@Rc3eT0%DWa;uFBaNSVjSzmA(%CMl0Qn^72X za8I4;7N&SIcBm$2gP7v})VJ^Jw;fVnd(~w96RT*v{|gD)@_~R!LxWg$O$CZ78%3S>S8va6w!@?RfpwVB&OBzc(|R_M9M2 znew&v@{scxr9HF7hdZbbS+kT&skN7nSz3!mIo*0+88FVg+&g=X~nJwIA3p6hAD-M3*l*>hdO<(eQKgqHTB^_p>@@n z9u_+%5eS6tuQM7RC?81ozVS4}ee#5xO(oG)AM>;(mbi%%ut#-$OuuxgJ+OG{L5%bI%(aFZfgprLWu_i?j(1u70Fm)7#l- zs-f|)?A#2YM8z-%)-1BPxOler{hB=@vZ_E-c31R=)AoCfH+|mkcyhx0A~Ac$rq8|Sz3(rVGT1Bn4g`X0m}2jy3ZJDSF}A-gS)i{!@YvpT{N6cd z_P8AAnWF)}eU>Gf6v~oKSxnY3Uv^YGIA63+Oh_?Y(=es~wtRu%q7C@aQ0DO-D9q=b zQn;+FY+8DH)o{oWTh>IaL__COa%N=m$$AFhr>6$Hj5=2xSnP;&Kg)`ZQ26?;c!yVb zjLeFrHQs@~lT=+k&LZkvQBkqFKJXfMrl77SCrD`B(C5Ah+g~1!kpHmueWQ?Y*lc;{ zp3gNYTVsUy#XJ$8C_I2O9 z`D^oD(}wg_=OrS)8ZHgfp}qKAGL-k*%9*k&U9`UrRNU6}HK6HKi@eo*syHst;QpnO z`*-yZB^+vZ{GCK%FN#mt(H>C z4eIte=h9lXM9G-1@`=H}{kRN;+nK)l(sd$#WBQ>W?z z8#gt?5Ih*Gajv-j!i_yw7(?&x>_2f@MGJ!7Ldw$CZTf+MZ)a>gzT5-C*A@9L9@wkU zxaIl9;~yIgmnFnH)6SPh)W7s_VLb_^WgL4z8n&Cd)I&BtK7O_iT})Ea^CBhk*s)`} z?s1D|-BNn>>a~a{roU7DPWjc9t5=J{454XLmUq*tvXlZ!=O~cgwklz_mG0@#C0o_? zw)#6dsuCV$I7%ixpT1`Cfx_n<`A4BU{*T=~JnDB&o?Tg430VKQ_PxTp;SPsX&96A` zf9*Z+;ni>N-hE)dN&E02^Uy&Z=T+|I-UYZa$Yxq!i9uq^n=_rY)w&B8!V6L>_9-4$ zva(d3yW_BpL5A?_!Xp1$WipDVKp1)M9KGev{?(_rvVDPvA-g3~c$FvV33<&A7In%r zt?V=3f9S<@GfE6_LE77W`}$UGc1V4uE>hglk^eyCTK1fWuS4gjxL>B{ zg${fuKcaOTP?WYiV}+Sg$mi%;f3@|9Vh0# zCN0a5+UmgN_O0^V6dxBiZPu*d3geHrN=mrnOB0hf=r1)4$=c>Tp0G}F(W3T(&T9p4 zk~W?=c`~tlhoMQZY6JekZ|iSIIm(%C{sP1b-Tv*!{0O;%1d*DA>-pu;(b1A~^c zp8&ydJZY73=FIF#6Ea>nJsOvY-ML6Q$Aq0;wO&K!$qmgmdukHbdKG8hHH`X@#w!0S1*N>`DomL`t{PX9}U%q^K_wLPHlMobjLdx9PJs$|-ym|8$ELecWVqthGUV*dRAT|1PoV|&Dz`MiOuMdX_ ziR_eAFrhw#{q=Y0uIQ)Z>bveP-)@6qi zo2^yqdggIn+r_98Po6&2S+e9wRaN}KgZ-_KecnCGT4)y+8{5>3zIL2_WF^J4e#(`X zG@ifhQnK`vWVdEpTU#KvJ9g}djEpSaH)C8-&wbspd-uY7ySlsGvb=We-Me>PVpLR= zZbOho(23rVO{-V`7Gk+#5L5M{&23RjggK;|J27DW7TkgbsTmnLwH+66O5s*}=A>p) z3+gvFmrmZYWs8D>LPveHUF5_r5e?{N1OcMjinxSs^eZyk;FME-KTB~~BT+#(gf7`N z$v4Vdm8w3sGA*q}A!lQs@Ld$C4T{#v^ zU$h)C1QUGGBDp>Y17VRk2nF^EhVeuP*qX{@bNHna;Q16JfJR1){TRM1Qs4qi{A1@F z^!aQ8-p(@9eBHMHuIIo1==pydgMtM88+yN^uRnkOUsH35uI}%C|F8Y4|HpsiWu$0n zZ-JIMfl*q+4ld?41Pd6es;<6D%R*h<(%BMrRMUWo92SktQCG*?VbR7vSSp9( zXP~Yg7#OG)sHMha`KUWPsRyAGX`&+qhpKGeFf|H?f;Aai5?;_gh*tpK0%bo~6}Diq zm|PBxfxz}G^cS%}UL2S#ex*J$b})lXWic5{E*mDI-ImA*n^(cahD#c$B+s9ePGf9< zSqR-2%jN{r5jGV;I9NfCqVM45^S>X9xgG%^qFVq0phjl1vENnxR7cO%O)%m{z6gf| zqr+9vx@iH%qcsnl(H}s=f}cYhfBPx4AzBlh#YQ;BF3wh}dgv@8mF@+F?u{t40GLKG z#-f8sVBah(TGV9ZDgcebC3CRo>OWlbq%(b(*l(?u{%l+5cyS||uMbS3b5O8RWb?+u zY!(?^T=07z{yurln!s{DTNSN>ik2#+`Is01(lQx7eA*eQ3(kzxd7u5!cnZSTc{C;i zYw{1M&6}S81{*1=s*XVytf~sI_zjI{1@SR>Wsm}BJ|sR6fEzVO_5hABMqK(R7me<5 z8PgXT-Qu?nkt4T`UOv!K!0+WtYECkGXBBe8%<^*6dDHrV8K85o1;<5 zLS@K;e*pgsiAL(9R3E)QWN9ZU$G?fH2EMWm^rfi*Gb`oPZokNyJkel{_i?EB-S7AuMW4+x|K zCCgxspwEVX_H7>i_#d_IcgmEnc*htupw`jC+Ca-LM%Uq2(dO$zbmDJ15q!=s=fyWq zG&WkalE(HUamZAJ1$&X$z&tP+z|0Da1{>y3NgS9=V!&Pq%EG8`jd8YcP$xLR{Ca6@ zHJE@3Ji^BO%uten(PPm7e{h%#HH5-d-%Oz)K1`JU-uznIBsz*|HWLts1NZ=#9wP6U z#|b190t5!)h_Jj#WCZ5*aYrwW00H#P1~q^%wCEc6Zzcc>xF$Ym+Z3SA_+$86<`*h~ z!Ri4t3R<&M(3Oj4_0U?aXmK81nNhGK0h;)r!6OCxdEGbIXq7Y+3>L!nW1{qgM@&A` z4}}>Z(1$u^MhuM+z}$fFHv}-uA4x%lQ2+!$r4`yh2P{RW!yv+>BWQfXqdUy>1|RU( zKx^S)1ltT|a(U$8$tABZ$Y1eR)PqO?B!E+_i7WqL1leFFB#4BrEWjy>)KPBnW+4bb zhc_pX#6m`}#NQAbFdh5{OiusC&caGTN5uUZ+HSXlVD9fSv z0N{Y2ipP9`U{Vm?A#|o6ptit&0ZV8I7WqLkzFBN^oo`nA2k8(n{m9+u%xG0wU>twP z=wmd6H;etFrU2krp`WAc!G0iC{T{h1i7<)Z)diJDI-B`jv3cH#Bclbo8M~J;-UDwx zV?2ma?D4jQ79Qe{U;{Cy2ZKNVW}$@_t7-7*44C7uu_Br23ltD)ozQnxZ2+SaLPvlu zg0*=Fn@{uRu{p|fJYzUQ-UUCy$fzHLjve)d_;{euVKSY>W`B1VUqMqiqi!g`(Wn;+ zyD!#ICnA38Xg?eepp-cy_f!7ZBJw?b5`_Yk0Ek28FW_wgoTIfPDQE|-AD8^ActQ;& z2otdYMh(8j7==?)SKXErjKZn?_uvF7((m^mqJw{e84cJR#Al<+qN`dVUO!vaipFAd zU_Y)Gko^&nLppm&!8;|X-5H5XyANHCbjkHq4j`V{D`pR)f?g1Z&GOYnD23LHqKk*OFe zlMaLlzzbBmUoea2L*ew{sDKN_CwVZL)EX><1Z6AL^cpp}fVdU{w`-Gr|~`~+Zr*AnboWXCI3w^&cm4@@6OI;^Q>ps8t~r2)t$ zkg+i>!T65Y4>;oEtb~E1~-A^6A2@EouqlR(j^;$whHE@Z=3J8*Y^)QbC(7V`vG!|_naWR4f6k=YEek4Q2;}8z>n|eaI0z+a1j}RZFy@236i~+9# zrUJ$UIs^AQ~X!9-$a_l~6mV?X2@GTLV zqM4pu_PM0u#jzSYLo5-nxNQw0+(8JE5^L z-dq*~EQ#>O0MTJHc`KsCL9d{|o~POt5gVF>?a(wv&TB5f7HP#Ms%}5$vqcW+-^HPm~&1 z6)XkgSAr9mxXjGPhPM>j$I9M`2cLz#gPRk1K(}fco_7hXXJ&^nvv4NZ+o3o?yIwhgQykc(lk@1% zRRkg)2b(z&h$up=ob18$C_2Fi6lZoAFwPFop9MuVJcc6R7WCYOi2nwQCEm;i%tb^Y z02eSLH>>?LTlar1-}!wmj^CbRi6G;tr;Z+K8ffW)fB%_`C+1fJi2t8nf0Y0IE}r|x zYy6A)-&#M(|LSP|dj9u6^7{4s@2|A+ue9;6wDG?l|9?JhEa2{uMDgEy68u-T_*b_0 ze{;6@zy0ywv5)?YiU2zG_hRtFLyr861N#s2nly&Dnje>}%AzsVyjbd+Sxhg4#bK)Z z(ddgoBuDb&AS_L7H9yLKvG*k4QB+9>J`|=wWbr;}MuZ7WCX<8^jD|IkK%ybRB!FCo zPNtI#naqUg8DazkS4COzKo?mARCEzg@jyYr6Zu&|1Ox>ISCn7T1r`s)1908Hs@{8j z%uEu90rlVXrzGiqXT5s$s_NBIZtqtE07gH&>VQXO7d?h4W)kTKp>?u03JD!ysVa-1 zsvf&bDm*?bR;K$+jKKDCZ$&sLP9Bq0q2&{qaA_*-X_=%oxiV0TUGwpf_5-F8MwJz6 zD%GH`PD0&@Fh7)4{{%14DAaG63_7LUNOMK5i8G9@eP|e1C+jmO=aT!YvO;<$QqPhm2-_%AknF(V;k2*Tn10-1 zUM1$Ih07|@GLBmVvt|rSQP!P4M=PS4DJ8=;;|;=7ocj&ip6hnzm8!1>KKTqSJe*0o z2{gAk*G<(=fX%r}%2CNy4FIQVsPgtRw&z|8eq?G| zxEk>Sm%7RiRimoov{8YL*6X|>7W1SCYP>;M0sS+7#Vy@KXo^>+qW&J~0!y5U+sCi+%O1Iyx*|jq-D9;(}68Isj+yh9OQY)i^ZLT7=S(_-L9Wo z?emKZ0by>mZUrs7jESmQ>m>y$U?=TWT2V#!3IGyEW{Xi!A`@s~o{#(RiZURK!t54y z7Mk7CD*~1ID~G;OK#X5sAW6L*sIMQWE#(>2y&~8sTspF$g(nBC69-KIkkzuvfIiP! zPKnbSS`-}^ST%>$bZAwu8nVptvxb6UG?u3mk0p2I8BncL;&o)aLt+IoWIJpxkSHhz zD?3I@VHvCFcTBB{KTTkRCY&-$yvn}g|0bjW`it}%K~GBuh^oVf0}yX4(1Qa3FHoJO zkQL+?q&PL`CsSP?ac`1&fog+Fjj=j_cRn@52s6H6Hnn9wyllh!6LeDXdz7HZ*aFyM zlK~Dtbhy$;j%^{JRJx8?O<4nMfL5RZ;7i2;-Sx)2$2j0kt~i#PBIF4SBsM$8NIIV4 ztQsaAy6HXZ)WLo@%`mi(kAYr49;tKzg=(shd1#ykF!>RQ!v{t(F06%!AT+p$Y&_@^ z%U#{=q51#t!=c%TyHQO_W+EUaSWX zV29#|Ll<3X0Iz}X(C>)(P>lICt$iT zcgpM@o;!!t_!Pg+jzMR1ZO$2(YHtMw;Lv#^SSCb*P+g4|>5xJFcrRg%v9uw*2NO#u z;l7c{<|IVM2;3^-7jh2H>>65YSc$ZAFmF5*8@LARE#Hp^6u+ zLYQqrX;?!E${QjkjKm6p5u@9PN(PN2TPQi?tyYPx)dD`o_Zp3mtpW0XehD{}X~6`I zX1J!QK4?D1+2zUX>6Y%#42^9+sPmB!_)aQ#(=P+W_}`~607K6G|gm}Vu;bwJPwUf^0KT})+M z1h+@jnN5^WR4%|e^=*!JA$)W&N22aHQB^{}R?WPO%p;XVb*o51_JL%R8N(%CHXX8D z#bFi+BtxG0WwfC_$%PHWB0LnSXdK2j9&cETwo=jf7!?odW_8|}vttE*gH%dh&GPj) zq1pbYVT9T@xS%P1SkBQPf0KA)nor%;&n7Nu*Yzb>inz6?c=yh=5|23)l}N_$E>Kcg57kT7I*h0jOgnh4=c&{9R?F z9x3WCQ!iwNgTly~T4Yc(_sF;htEPZJ$tKItOP zr#|~nt0BcN>!T6>|CByyNfGv+X(?`Zi~Z-xcv|c~e{K8E76Z@|XaL$`|Jh>y*%CJ3 z7#jNjVhGA9kjd`T;`bgkfEMG=lVSXc!nSEiB8@zCZ5^5jYHE$b(j=fBzBVA!%rujO zr*2QBL~S$+-}PxxgQJ{u^#sS^7$KXR(AONkFw=uq0dzwlw4zM)ZRkZ&Wo*6% z4w|fitZ>osgK5I?nv2e6Md%Fppm+nWD@w_^TgR#x1E9O+sOxmDJ!97-9@brCGba6W ze1jcE%qqt1HrJ(Dhr+dGtRKBevXP_)g$k*(^*oc@GMZXy0(H}%xCc7a05=JrX zdb}YcHg4=N!Y)oJVuu8^;xoVBgC8D1VwcNx90)9~@FLNYqoagq3M^oQ>$jtxY&-igeAPgim_&Brgt=3rj@*{OuIMHpb;E8 zn+&vYPKKe5(BvwnCY`c~V9Zsv#y&J6Gl+cv1vQ~9wrpOQNhlojvyk7`ttc*^1py%p ziMdO4q{96wP|duC_*;YPNNUbwTgPmELCp<3XeD)(>u+WihogPL|C{v_;e6R07o)fa z-@qfr$Fvd97!MF>#w-~V(bxq#)o0`+GN?PBjv$c65gf}tn(O_!nCogXe^KrWYn61X z)i62^#By{z@^z^VB26g`qj`c$j&3sEbhdG0b9TQ4YeKCe4aeON5Q!pndS$#k^OC^? z5^6vxRnrut8v%At0pBQS4K*0c-W@Lx{5pRp>;{f!&&IrPZ5UXEw7$ljo)Uq~fU<$0 zM+7Mnjk4<(x<=Gl5Xr!ERyRG;oSxyk#f8Q&9w8<|SO5oVH62bC(-aOIhEm2!MyK8J z!z;q9y^+(3t|`S0Wh9&ofLK6a@i&Mue`XG@apdGtldLdtGJptLa{|Gk-x@azh~ZF7 zi*too7oX%ScHQD&KDTfWR8xzskleHPcIXaE-QXurUHgIcxRrpBV6|Ls?B)*BIa z3zzb{zlDps{{h%0HdEW;!CM{-=p6h0hn|T0pWg12v^Y7nna2_H`7gi!iMjslw`S|( z_}4!*sdw*|^*vO}6imRW9vkUumZ$Twkp;=nBXng=inA=13bB&IQ!EP@7lq5cm}C>bj!qFGTafpG3LC;dxL7}2GiMi zg`20PJGmB3{_*`48Aj!ZK>$c)Vf@IX3ZA?y=Ag-170TDv$9$VSJUQoVsn4|>&;kh+ zJP(y2Xv$%K$m=t^=U|WrpBhrF?U2L_t@QM$H2?`ziS*=VgXpdyv8|FBh7km{bc*<@ zT0*_bmQb&3U-67QRKuK%M?S7(Jd(amd5}&D$(j%mkX3fXG$V-TwTUIxPY9NWCDq8o z(pOIElb+HyJ;^PPt6+(Zh#8ieo8B-FV!pN+GLHr<+u0ktgkvpKDS)$T5~oaB9zqDK zL!^*8X-OSqY^>;UNW|q5zp6kngkd#zDkY%A8^+7L9CxR5;QM&8`$YlJ&}ul4yht`1 zn^2HuGm)G&sfrU24+EGufTYC7Pu2@ElK?17bQQK@bpUoERCgv}Yp_*$3G$q_*=)RD z-WvRc#n9SP|K#`joYwEck2-2n=%*8`bCjd~FznnQlx=uk`fyd22M43!kU5PN2E%3HyU`97X=1LASN^-iGeYu&t1FDtufKw<6>io#0uj`J{vCWd7f7GZT+@0#W4 zqg~a!+ZZ5J#9}{aYA7%Wz z7gmLHmqzDC^GlNpIiMFF%0OT%QWh04cCzWU#*oBSwuetdV}c-6 zs397MwStJ)z<+m2ri%^S=EpJ#1}6aqYxj|}Wu;Wb)?X1m7tGH{vAG2wsYgGh~y%X7A}^{$VvBak7KJR100$nCoJMtj9j< z@pCAEKGed!V&@}eVRUrtGq-AlGvaIEqN(dMDKWWwGf9Z?Z-l;xH<)G_os}pL0Nzv( zGo#h0l;0(U(lbR6t7Ri#fGn#F`>Ql3HW2pfau+3bAc>Dp(c_8&@en3k{wk2R!q@@C zrLM;Kn2}*;BDX!BPzam4F~e@x|9}-if)kIG1%)_?3l;O0j^|Yo3YN$lH>_yg3W9pn zyA|jriVsS-AX-)iBiQNhXy;|fNk$>Wl?>S}(UqKOg?LH&(M#ry7z@Yi@rBcaLOH1d zTR6cis@I2t6cGmmG!g)7l^Ri?LZQ4PBF}s!Fy2i4fRPY90d&t-s?-RZA|9-10t2By z5(n`8l`d$`6R371x!v({Klw8FS3huU^)4j`G8?v7_~Y5z1dT>9#?(zLjKN4FTD1Cu z;w&)@h{srVUVtu*&3@!I=98)`mQV`QPirU6h55k>HH^gx9hnn6)Ek>MHbo_f^N5@; z-D4Y*wH;%}4k!bATEr6Ih5ci#eTsm1xOq;5&LcGp+RE0{aNfa^57dFztS$Q>Ixd?G*s1&Fe zeRHu9=|vdthah30?4sM!Nve%&0|a)~s<-Lo^T`Cy(}{PCUv2 zw=A{0o+#;Vz=59Vo_tvJO5ocK1QRM7;qAs35nry~Iicswmoo6Qzlg@zzyQ zwQ#j+w8`{sGSg^c3($O^id)Ap)irB`uO9u8E~HE-60g4`!PY_jmIZJV>N-V=w^PN& zOG-l75sd|~zWPe@;fpn8vm-rfRfsi1#{>q?bcnC9@Ct=R1Fw+Th+#=7>#9^1HYsW$ zxFsZg)NiZ|v}XrMRLmv9dOb`P@E|su&IwtL-q_oR8R$EV-fR|x5XX?smXILWOuj7o z5oI|7d6+E$2p&~SuuI73GgV#G>_gBe8r}(-rw>E#7PScU(Yym=H8Y$J*{F6n8xXsl z=H6y_;ltFEOqNeHY-GJbBbboMGo!gjpu^-?ZbM}ec+iA2;z)xX<93lIMQAHVv7dOpB2yrjROah-hN z*}}UV1!YKwiXrV{5ewcuCl|lGe`@G>2Ed9r3=Yo^0;-dP?1U{n`L|IQ6l(+{x*{$T zQ;7#L(n@2p+S%>I7O0W!WKE{0Y0#ZF=m}7j;SQXuR(Y~8Oz-Pa_k@k z@XG?ON{GIsWRe1Y_sYFU|6mepfJZM;C&1cyQ3Gvbf;4gGq?O>y9Vyb#nQZD@5c>>+ zWKt1o6Ao-WXqAw3M7+iNm;f9K@;O*mC$vJ*ZS>BB3>_~`U-XGcunjHy&IH?dNosIm znDlC08G$YJuZ-NJrRmiy3j;(~KtMnL1=vjABEV*Ru>y=!3e%k9qd5>3D^u1@dBizD z!iNdiG##fIfcy-C+-Bc*iPvRMFz;|1tEnReXLKbL{PNxQd}fqCIw6qWuky&BVR48N)`kaqy$d@ zzOWGH^jfP*=Q~1t#IqxvA(}ctw@fgJ56ufC>)NTb92%|RaV{U;uHz-%#u&6 zI&*7bc6>?6iSFKL$CunUJ^30HvUc z@hK8hT}hI}L!6{bw(2SmNVy46(ZTD*GnA8TWi@gPv-21QeSSGXi+bNc6?`d4Wj3&b*#1vWj*S17+B+?+W&fXyCu0BOsuK;M4C85u?v%u&RP=01 zPD}6IC&IJML;%XtN5f8o9Y2~jTxrSLnP>o@SRHQl(S&QGW9{2t8zBE>Pt^Vw zSqPhv0cgbkD=8@@^88OtO6}9K|4+tqN!P?uuOCir*rw(3C^@0rpap@Tw?ZCsxzI>d zPl)&={*ubQl0-S%?8U)4?gP)#IbeWdBaLKUSaG>rcIpZk`LaqG_P*Xe{9XcM$r!7D z8f&~Q0p=lNEc}DP2jy=3?O2IxK%(oWCLKd<960_F3C$ybRh2=+!W(QI^Xn(M|7R zlHFJ{)bS`Z(a}ZCis8%M)|MB|M$c{^{jtcfa@BY!Tq-}{y#aTcO?Jc zCoQ>!|34{DbL;Jz!~d5xfZax!;gk!?oX!ca7-VT<7?YoFVfT0M*{_J@&`cw*d$L^WnZLn_AJz{pH@p2D72 zH_tS=O5&_DJT9|Qwz-_iWEBe1J7G1f_r}d9p%sx=$?}JgNYa?-Jr3>F>E6F8qwX!uT5Zo<4-;3KmOY+XFooT>HpG_lOxZ6;1^rY z|C8~cbt&EKnRDuiJnY#h1Ttd7`?8rqFUTmJ_{+7hCtDm|Nx9q=%OynY7L9BdxcKU`Vf!&Em zyxR>_{+LpRTQY4O-};;OKgJXXu&^vl%_#vkA^wv)C8yLSWnyHT_tbb}+ zpO*DM8Bc@jA8sB+(DAQ-pXB7!mi0dwPh;!PLu+WiBn?<2{9kHXTAFqJlim2ah5tJV z&##>S%f^#`<%N}jfO|!Rd%w3tUd@-uOOF)Ml$2f;81k%MmOZU!_o5y|GMnQ`^A)j7 zO-T2J)n!&+&hwTAG4i*FZjbj#LxO>dpi*5;>B|*=MOdj&o0RFx)SFA)|4b`hJ!B<0d8cOWdP`&ySaWzz{{sdeN)@ms67S>DT z(C06XDc@GT3vs*&vKnlFOj#(iRe%25F;?Waq>AX-`0E%OFva^feJ^KQequb+t##L*lx_MSd0dmM;{Xl8_A7j zYkG1lYbt6zw=%YEtRhR9RhiN+%Nqpn!+zztLjnLIc&(?nC=ZAz_`D@v4ughLLJ!%a zx4>L&%fdm;J3;l;QAAOe&_fBaP?J2}BE?T5bq`>**Mn`k8cGW-G&R0*)YBNwRnRIL zfnt!9N~T!B)_KD+ly<>q_Ejimxb}t0V8jO(i=bls?Xu`%*uynLEX+%#%he;Xhs(vy zAB>0laN9?Ru$l5$;l*&o&4#5q)wy4eNu@L^N_5!S2wvRO5p(fiwmjOckSJnl%z&OxJ#ql1m>mtd=SB z`+s`|0gEg}R+g!*WM*xhmgr7RboZqk0;%aqNhc_WKx7gDsZsgQIK-PSV>B%PB_*Y} zQzGTR^^Lx>x4i{RHH`27|IKhctf%dne7h^TbH zEi#~`t>2CeXiyPs+@K^PZ?c7cvDCM*4h(<UTC`r&qE(M0v3QfaC4hL035Hw`7`g#K(l?PRfUr`>aRd`)Jmn()X zmFih$pRvps*%YUj>Piy*n3qiuaV#nbxmdCRERe3A&(DjI)PebT$+;nzxF#EGg2!P4 zy%=O4`!Ps=Y~;`a;b0j^=n5Jd%A&5w+z51BY6=OUUkR_|fmoI(K@G;dmvhU>>4PQM z#uzd&+AsC`m7rH8*Dt*xEFy^;AWt_BV>-laY1&lU)-`5uE9OS&?XqD0i=mHWpp=Xd5@We*fdzvP?J(& zs6iZRpJN)T;z2CZvokBfiZG)gfoLYye7G4~)y|VDT9qq$PQ_Tq73);criMETRs+c} z_dzcjY`zrE97>O?2WK;Co9iAksE>(_kJwu%irY<#l*GoWFI0+K;8f~yER?Q;GiDSD zgv%=R9P1}~Qf|wn+!2#XPD;E=@yD1H=J{>_gWYm}5ai5g>`u%NOu&YEM>ix=S(>-L z&es58K%T$ih;-gIHZf&%TJu)0ti^I+pi~XQiIuAc!OIbxsMB`E*wm%+z$b zHK$K;pt`%lK4|iwuvb&GfKS0=g@QV>G^J4#vmW8kYWt1DcS_9ttulZinlW5&nXns= zMfG&%oThGK(8cV5Xv)=rplUH+XHH;}Y0r6mp+GtoNyslqC>oMEIH5QvGym$MD`O10 z%pwQ4qyd3ymgy7^j9S$P6j1G|pW!3mBtfdK_%sRuRVK0|^SO&dlP7b9^E{{tOG7Jo z8b0Q54kkV^$=%!D58olSPbDNP zr672QG2gK4M-{NfQvaY{6#n-Iq+p;94i&FTIc5gs4^8l4idl5Mf-|@rh;C42$2w)@ zvMS=F@qokLa;&UG>lg7T1ChdppaZdr3l5u%w1A0$cvmYWrCwg zZ-y$fn0;3G!%Q*3D<)Rd2%<7*NFI|$qd<i?z8O)P^@I`_SSS+U8+*mng|(P zLIW-ziA)~gPrN=hyHb#GYhALWi^W(>tMLZCLS-PJfkUQDMM4EjD8mxNL`)9R1ruy> ztU#pTm_Q&z-{(reT^7s-L;r>~Ha=2Jasw~Y_=!HfO!MnuX=p6HIawrC_$+DAw9g|~ zU<#HnOrDMrRHk_SWxg<_1H%a^H2}Ywpcj*E>j1*#fQbSoRI4n$kcc|Nc>zRL1Sud? zSkE8ovcSy>1%4xfbI=t#xU_l(Qj4NTvMPGy<5l!907hgtE-!ydi33{ zt8aqHch>YX;sJC==v=Oc1W2O{URHE705C)iR(myZ0f7*N$yHE}E02>Q3m_CSx)rLE z79KG~4Qc_u6evZO7S~6i6=A3c%~-Bf6io}1dFjH)vIr8L9GFZQs7Mj7VUMRyJSrvf zq;(gc1QJRnI^#6qh`>=;3oi#GrRGDJXdL66G)^Z*XYiK8aseU4Y0*a3DxJnH6};4F zcO%f9IFCe(exUj=QhyE5F^O+8F*+yP{{e&z^v^-0vA9>TewLYdF&$da4_&fbG}s_o zfO;Hfa+o#jHsN6Ku-wAw7R+Ti^&&R|r$iW3!dP7X2_#mSLa8b-xIy!M^<>9%-IR!(D zWhhaYnO{6YE*L0h=8urC&dtwqO4-*ADaByrEgS`Ge&C zP%porSkB8GoLdZy78l6aA#W--8|n>|24@!z$bmmI`{(B67LRbs19OY>vCVaKz|g$RLXc$(hZGcLL-$!yenEb2{=h=$C3|poez6OBg|6i6Vep4sl#`j4M_pwO zh0zz%_>2G?IR$xH*@Z4aGp7VA}q=N4rHT`9~hLVye`EP&<_oKOQ{mM=lQ z{A|_=f?Bq$2o%A;hZbcUW68?S%!9Uya0Ku|5`|mTnM|E&R&bF*^RlMvGaFE6{#Lb_ zjq3j*6$nk}qhbADvO6_7(*G~1PfPr#lk-d;l0WD)>3l@H({gjN3gPEe{J&jm_&0C# z_w(Z7Na4i~ z4x9Y^8tp;thA*opPCR;T_3~}QuBcuD{v&R2(iXj|~X!~@HJ82Q!tAAk2$ZKk`!&3~MeUQ_h%R{z=iQ~cEU&kI`R zB~6jW{`qiGT+!QI^5WiqYRrc9>*wry+TG)pB|pdA{D*dJ9{tbIp0no9pC4TLk1bnf z4t&)6)Eak(%y){XIMd(hQhD)^QKRP0o!hJP^vd2lS5$vk*?VMd?GFpDo_%WDwz=Kz zE$(?5Jg1*N=-|IU-#9m~`+fO~fCydQx9{8YE<5AyHw(hj^X|b_aUIrd+_>@9TW=jR zW=yxv-o0BFe*5{xHM?s%oI0Re=e29sUbCclVPW0gt(Ts2&g|t??{}X5KX1MD)}ce8 zv+qdNKF^E0vZ|_T@ZdWaE$T5RZ_~PUiwZSNHmg^!w%KgYKKrbqDBHGe+q-vf@AIq2 zj{RiOLpR>=&Ht_~?(xG}?=C)d-JXN*z4zYIQ7i!bb0yMKGa;0~>Cn%aLsT->UcUfMP;46Qzq)w$i7 z(xpjBTefcPJZ*R2wSTWzx$?Xvj_!{XE;)L1&@KJrJGS*zC;T%cb*#8{?E~FfbvXU> z*|TOXU$NqUYhHZ#VR_1wDc#W{w{MS|decp<(&s-l?1}ZBWs4Rq8o6}f4au--?c2AHi@W>H=T@v( zv20oY(oes+{^E--UN^N`wY14K;^^|LH^*vWDw9j0(e*O9vpI=0Kl>{dbxU1tPhI}T`|p3hZsx4<<6m8zvGJDn4=-JM;NYGOyLa#I+O=!n z3p>UQ898#_zI{?04EgETem=7I-9^tm_uQk8JW|v5!Zw*#E$kdOR#BeyzT3Uqspn3c zIB{aZL;c1S6|LD5+#5Rb`s;CVuW#6JM^3k0E43c!>F3}5<_ph1KYC?QT{G>poV(h# zX(Qjg!L#h=pKq+FsQ9ep;=9|fd1id;Prkivg>U5zKloF|ty`78dgt=lyC$Xl^RxBm z_MFvsR_k?}H-Ayncfo=M4=i&Bc3rV?3=o7{Zn@=-a}v|j(@#C+6z?00x9#gu@L=D| zF6+AHtX{o(wfj@2!&~+qI(YCPpzOMJ>!5JSjfeNFz2lrSrEI|UYoB@jo?!<{NUA6Gwp+nCvTXyi9Z$>;@x_0B-v;zkY%yga_cV#Eo0mau| zyKYZ#)>W#iE}TFAqbEl^7Z_W$1(so_HX6@QjrtLm- z=n$a!%$YNP{PB9vBsd{MU+sDYw%_@8etzJ*WJ!pSEU~8JNd}-4?R?p zle6x}d*;lU0~2V~suf^IpFVva4IKDr;j2Scj_P4)< z!r@kNPcB`Wk&$uPg?HU?#~sBzU%BDC#}_W#GdJ+6E%ToK3;Nc6Il7|ai^m4feLMNe z_fF}sX58|T`=2~_+U}h@cg~wP@6}iPxn{p~!*}EU_Q+pm*J>+2Ub5})6=%-Rf9mOv zzxrhCWj}AfB`veKXZVXv^Pvk*@|^XayPi4<+vw%muP%P%`L3O(&rJ*TyYZ(Vv!b*~sgjy>`Z-r`El;E~m?RrwoRD;c~lc_PjM~-D~!l zy)Sum`=QDyN0yAPDl7Z>{C7V1;I9upc-M@NCN$1W;7`5WX7hkM=Z27yltXR=X%igwS z!KFR#YxB<5t@qx4|BBMJf4=nU`{m*HwCd6(6OeOuVo66y`t$9#zZl+s_8n_SJ~MVT z9Ers}&r1IEqBG8FlL_>4ao`r^#V4-by460e`mApb512f8%_WyywWQb<_wbOf&y==o z+5`i9W6jO0%TvaTu6%6&JT>{b?{b4H?_ZqPIqtSK)9<|VmGPfWD_qi{efyi`%D>Mz z501yXyZrISAHP;Yp+oa7)8uyd=5%}D=QnR3I`gJhBd*)E;ZJ{B(W4-}XU`js93ABD zx6V`8y7jepoV~G~ZG8Lo+M;*w+&jjZkUQ{-g=e*IpD^pgoL0rdhiiQ=lx}@vPtew; z|GGE&KtbHH8aKVi~?%r|W!#l59xO4RM+3Sl}u3QTLwLN{;h~;lpz3=k-o;>~RJHL73 zR@di8rk&D$-kT-8gWa7obL4h~ONu*B_W5OyE8MNr#Yd-zURkOa>JiE)~-@o|kbyLs(Ak_E5&sX2P`okACZ+m*_h38$<_wp`h zP5)c>S6%LRo_*5y!u^{z%dKwDdSv1cU#|W8-|dfn2Q=)=v(J7C4z=(9wIgooV~;&{ z^=ubx#iz%-boOm)x<2Plo-LooVyA5Cpc&wEDnESfKNGx5c1-(lV5f7}rQdi(y7TQZRU^DrXB<5` z0tEE>mVC-M@9~){4y!R_|Dr{oH%E&A6!A=UcXH*^#41 zUwP#f`27Rl1VveJ+ih)^O(W$o(y`?h+vzMFFB-Ga?8t?H&IU!M8a z2f+c0if+&P>6MB9-0xoXN`>1QHrsi}@5ATD6;jiWEKHjlo`kSA^{#pH> zgo!(L?)2|^dB@hRg$sr}ylK&c{SI9J>77-l{U3W@9th>uKR&HDQreSBPZUPhk;+;U zN}{VxMbj{Y2{Rajl(Zr3t|aXx6|E{Q+_(|lZlq1xRZ5Fek`}`EobxR6%ox#od*9#t z{e7=Liu0WFIp=)NXFunBPPc~mgv(pzpG;yht0!+>JNRVk^w%p_?pilZ@qAO`Q-kbP zx5WM9S>20&*y3GSx4X951p((Yl=sKDzM|0 ze13TN;zf3x!s*UkyLtc(+Fi|U<@NU~9W@7;pMHHS)zxAiTQj*U!^maYp%PP5(_XP1 z8P^^?YJ7G%{>~lOBC{dw6C4JgKWeTPJE7meZ6OtouQpW}YPz`Ww6|xg7}pJpdw*%Y zt!4NrOR%WLC&vuxGvpn6UiOQ}7v|sUiS4&yL_Yz_|L|emF3V>gnUk<<*SlxWPAzE& zUolc|{F8}}j<3rv4W5>CEcrv14Kedo4o+WSIlwS7yXNivxo_X-7P!T5fXsaHx@4>U zhIsRLX?6Q2&AYJdPr<9dH-#HuDZ(GqHTTDAE+5FPE^HFxrqifd~*4K7gF0!j+ z{n~R)%AuJl77_PMFAuO(wNRULdhOsL?{dP@M{FzFcYUHx-v_0m-DckvH7%)mex+oN z_t2UO(}(A?iV6zmk5F8zGOFi5_r81g?(N||@bxs8RF+xYc!8j@V@kWO+eR1HJ&W(c zW}CaW+vHH2FruXC%cX{D57*!C)K)$8pJQLW-*c_b_-TC?M?`pfdfLx@zQI0ad0ANb zz5F!^y{l_o=d+kEt{$0tvOszA;|tbb8yn6P@6;P8if9OL+70$g1N9G7;_%_apFe+I^P;#knQImN@_KAj6P~pFbNG z6`kp+q1JVb>4L%)7FgGv`Qe#VFt{T)lb~n9&E9UGK!m3kV7M z1nifcRuT7Z-}d5gE^t|aW40$Jmjh|;s@sp%|E5DoNcq(rNz*bqt+dmy4BL3nS23+? zm*u&+4~F;px}`cd+1}tqk?6+FRqMhH))l`1#D0O zM(L6RtD-r_J?%T&9l3mhccrebF742vUv2hw-Mw$$Fkl2!6eg{z{v6$H;DZMbSS;3h zHOqT+KIQ{;aN~x~8NrSfbzzQVK?ryni1g%1ZYO|i|S$Q$cBqO|MKNaA79^Tsq<3xI&|m|w_~S;nh-d}nG61i)97Sl zQ(&N$)G0KyV5Qyg1RdqU;VYk41H%p|msd$|Usn#_IW}^ho15dFsTLL%z>A5=Q&3jk zuxiz{npNWrzvU?x7bb)yU(dNJ=#e?H$BU~8k>3Kxtl>p{8h#6ypPxR3xJR4Tbvzzk z`}*3oYZVn01qB5U9=LJeol8ud6%g=#OG8)H?E0#^oBBu2pD8+Rbf|suv0WCkzm09` zy{9P*X zq}XzgZrYZ6(z_x(edFa#GiIF6tO^O~&h<`q&HxOb?_qRevx(Y{_6H9hyyjPN;}0&& z++6(nqrtqxtjQ;)06Wj_m9XT9>=X;t6beNqIAgPilVx>o>7ff zLt^q?&DJVCr?%8@gJ1#r0qdue(6POBiVKhz{I|{@KFrg14-fJ9a8qS(@_E6d2Og_O z?LEDDNRI%;5-XDtmFxbTxc<8Ex~bxFY*oHTy6a)!r2&&1EG%$NfW=zW`DI|)b)O2| zk?R1#M>b@PvU*f@_EO1$u(Is?u7_8gJfS+JCu6_UmI>;CV+Qq#-RC_%F7fk?TNcKn zvqE^IMi1nN2fw_gv37sJ2DLp}gQA~AM|X~!II^+d?O%H+$qq37PI)Ad>R@4-gs1)D{DWOI!evz1kxeGfS`T>Quha}9hl zK0m5!Uk1b1_e4Tpg}^cUr*6sYsd(kvuDmB})1OWFGKEo9RTUT*_-AIatFFM`-}dxT z-}ZOz-sP_qT{4XF%_%T4#0IKtOd2stO*x_#h^r};-(HPwcjw-{_356=IAL7w1dU#n zBeo|u>~Hu*y@$%K#SuFUpXwFo=C&`nkT}8P^o@`97dQRIRTDBgUzagYo6t zP|NmRl(<7LELiYmPN(DE#osjSXWsD18R$|T&|`&lw{BwPZsMl;vcxy{5*F6#%=}!y zWrcs}c|W>(W?=>M-09Q3Ga@g%88qg&wyCLIeEk9w-5yFcVZS}$MD0)Ku~PZ`f&KKh zE;Dk{y+8U{kZDKja{J$!X15OrI$;*<)9J?1)%iCX>V@g9>^pY{2ZmTJ;ML9^H}1pd zvP7(#S?tQDm&qwx;)Tmpy|~HV_ujX?17D7L?Y@9i%`>yMW# z7-Q9VV{};`zL%k)Qre-fS)pZP0-q+#xcl31fl9+z&q>*diKR!~vkHp2zs>_frM~Xk z`Gf`Hi>z)*mh}lq_scK6^*lY_XX2#PaZ6lh#~qyR7%^~L(YS6ln(-N#D{U9Hi@$s; zbFE?L$jFcWU2iUnQD(26z+#LGOn183zGz>s`k;z1=YTubJsB%5T!Zy&LiafKoptn< z+c}ryu}U$XEA&p3Z85&|Z5U<-+kHAnvdM7yT(n0 zNg16jeLQVyKThB;=$qH%hVpc3);eO10oBoUCyT@aX&$?;p zm)xo69XC=BHnK~wyt7@25a6)_{D{J6#?Bcn4mBLXgOmgG@d{+L9D}Fcc zX<<^1@z-~62mATF6#Be8mikIh=k=S)fk)HAFa53n9Cz<@*EzLcy?QS_bEfF<>`x^n zi*F{gdRngd+_nF0jdRL*@8h)wA8<-|kX1U;%jEL?`%9hf+`sR&c1*^N+qWxTzfQ}D zun}^AhhS@)|7VxXGgsFQ^iDF?SeJkO*G2bPk=ddN7Y|iDy_0@v=+LqI_gRb%)Dz}K z&p!CbcfN{UVO_=}+x|=E9JyLpc=1Ge(3Q=m(P~de_6#_8FLA?o8}_-Cy}Lv=eJ!rf z4F2;@Ji~hamCX#L3%hG8OY6UU@rfM#x(2wtB_$c@Js*D9n8&f35VmD_?^>IbUg8X6 zAOl%0i)MSK&%3*Cq=`c9om$UbH+AQ|S)I~wU3tIt`dz!&?(T!ryd%3Tf3(nh=;ki# zY*H5|_|BX;%suTd<*`a9Pu~_~?n!5FGs>GY%P2J9xJB^9T`}p`-#pB^7F>2~iy0>} zvgz>Q!xa@??zIzb+_oP(bH?AML*|Pa`lb9bE5{p|i_Q!%wLFlX&KB9dE@j*6%?(*n z=<#N!WldScXxCEHG*$bLSFfIO&#H*{{LpoH`SMOzQ&Sb@&C3zzPT1?DHLR-Y3OFfhS9j{&&$hIw)a!m}e|lifo?U1C=Y~7{C3+TWePMn68uz%e zqM}@3_QE;SZ!r@Oef#$2w0~E(^xWQz_j$@G!t?o^7`JY{_bxI^jg4_EC@pe;hr-@biY)jOu3E5lqdN(aNv9d(*K+|ZpNdSPa@_)Eo>eBEw_N|8+sCxM~2 zZJYAi{tU+a5}jj(g*j`>79H8MckiO|0(MoI^LC^1(F6bZTvluq{xP&`fZwQ^{57Fd z`{(X+d38P6J~=tL_UzSBO)lzjtD3&mBve-?o{HGmK5NI}&Q_5VYk&>D=uRZkC>oF=RFMQVr6_l(^KeA6#~#rY>MI&xm-ElVveg^c0Zch(~$)WZ2$s4R})qe%DligG|t6|AWrMbOHNbnN)-*|Yhn9m6cDzI_er-@n7vu1QyqyUt`XD~q0X@*dgQzJJf2 zL;ENi?Yvy|(xM^y6kPVl{jyLRg7I=HV{q`F$>fdO2Y#qi( zaf#i2YlUJ*Yk-|QPx3}Iy82%S3UYDXE7sa`$7UWn#?Gm#tn|IM@K4R6l?L;EpQs*p zygogK^QAE9#F?^ePF?od*ywS83?8f2a3-f{^uhGEZ{BbXRW@(ld}oMJYUkfS-SeF> zW5ylxL0y)IRBaEfsn{G_(^=S0MajXgpi-D~{*S5RoHc9KSf5jN?6dU1ffqMYCJP^C zMs0Up9|ydd{Cr{Hxr#tPpOE$)X4~3k%{=zW$Wljl%RPmdsHlbE;g2%KS9b3&ycs`x z>hXpZ%9|ZyOt{^8bnHIJ_2ZXnC!sL-*bCL@=;)7U18pKxU)`IUI$bCJ^6^14$L!3_ z{dDG0<~;X@z86nc;Wq)76Ui z^fm6f8yK=CCM88h{^bSh>~?iGh-VrbR{~L&6`7O&`wPIeXIFIzadDZt`1hPwI^*3d z`gi6uYOcCep0aNrFzvD%>nfwWufBAxboAnKyN7S@uTxe#wdLvh+}oQ~dtO+-{?qDp zwI$^&ABQa)t;S(J_NAnJ{rdHY+qoOMJ#`XZ*VScT+F-7u6P}h9zHM97jvXB`_urhL zel&t;k2BOqZaK>iJEbudqk!h+PqM6oPO-)TRZlcPDKBL-4jUV1? zQhi;tz1^l&2Ygsb<5GJ0`Rl1DtyatHoeZ3?$X__{JyXC#li&0**=)jWGyg{|KwfXt^mA8-Nh3T%fcC_m@Rl84r zeK+9JcInown}R~p*%1EnrJS&UfT>N(mf0CknzC`u5q&1}Tx3&rMn>&c6JIxXcdaKW zb{+DLJ8I@-AM{X+pRN)(=0R>$SKy1EJb7};5OZhk#a2xhR{YY?(2y1SZj`6@p*75^ zm2qdBd&hO@2)9`O`pco;n!W=Dyn6D)NMXpR{Gvc0`ThO* zIADM9`TQwUipm;4jed6VL2QQsH%5*eIepfw(BR#MTjnIEbhySBp)PEWgTcI)WT zqrin2J$f`)gx+F@{D5=k zl>HhvpK6?X`WF7^#b3_M%nY-5q+?eCv!fB)Ur z{s`(KFZ#)(-}~pb-#@qg{{Kw+CQZAr18MsGC;3~OlfTi?D&c5|1qoM^=#;q@M_fl!C!=fWB|y6?ki~oaJ}>bfFOej=R6@2fDl5+pr;ZFup(32 z;hBrzbzXRP5>B5OVoS;H6t!uo$^86?C1GNm5DwoDF%+kjoJXyu_M4%3Eng1E=#!i#$VfIE}Q zf$IMs5$R16!4mj2Z##lZY+f2tUpbkzy!J(DOnJB;S%>eJm9=U1cpWC zcqbHGLYjep$fZD<6lyMkw=TLQ2|GgB#&D1hCy;MNO8(0D@vjNEpK=#ZK@WU`d z^XuYwO@nv=fbLP^HaJZ@8irp3hkx@0@OcYRgU^N6Oa=Owvw%wDNkXE!kp%`XLKEmF zuc88*!WSdFYVwLWBsDxmAqnU^a|I*%Npr>Lh7V8PyzoX)BMO9ol{o@rZnSZjG=luj zIB_bK42-%oFS&dTqqD^r>6k52}lfa||7R9dwg^;RHrX0p(WQy>YY$;Oy9z^`` z@50AHf=Vzu12AJy3g1>>BHsQk%5m-oT3G0b#2NWalsS!X+s^PFe!i_u1Da6&B=zAW zhD|bX#_*wn#&UWl@~A;2t00>zm&&o~gJ&U@Yonr%#A{gJH%M*JV&RnTNu&}F6$bfA zJI92GLY5!RM59@u`W7BRFcU8PNE*3#CHNRRWeQ1*PLUYVJ0{O~4e%2~cMX6030bbV zV$zqhFj7bXKCx#gw?(Yr^FydVBq&or> zaP#I1O?L`Hp+6CfC*Q$M92g@YMvD*3g~LaQnMhpny_ypu=>l+MXZ1adLtbnN;ga3i+;vMYc-kR&@2>Bfh3kd?4BZ*4Q%ttx0U>+_qmo_9W zlyBIA=WhjbTH)az3j^?{IfYpwLIMXxi#Q;4=f%gJ6x^@~g6f6v;3Uosv2e{D7EdaW z!-wlZV|dae0{B2P0B#o7Km=?V&>O@PQ^EwH(p3?V&>%oe2D~s&z!A_CM@>+Eu;!j7 zDLxRE>FfkOBw}?C;;B*7QkKEc6GFp6M4$iyoN0g%K1atP9+iXXoNx%{czQDl3JH&_ zjWP{)Bw)A=k8Z(a-h_1X68o70p@$$ydE2^l9%@PcNlT1YiP+!wJAwm!#I(UbuySik z0lCkRSOvUL8Xw_4F)b7TCl29}-V~@V&GSD8g>nNH{|*$Asr}`m5PfVb3SD^qK;q&< z2;+-_rBp@hi2N@_;P-Hcvi`S(JM>W|UWPOb_{AUo(yI8J#v@H+BmwBgEYekkLW4cX zN>jcF7aTD3iDU!eOVQ#RRAqc=q(vsNK$OhI-?OBJ$*77%?36=;%p{kW7(DzW6YBBd z2Q`P`FAqkuS>q%<9*Qp<2{51pT=Wn=k(3J`p$OBK4bn?aA)&;Eq`g3GxX8TgAOyAt zs7($?Dp=TTRB*ULe||7Z{w6bb+UQU;i%Srv7cPV)vycKnT3sY`*zmuLHCmM|V!`*U z4E!tI&iHW)V+Mlpqc#TKyahYshinX-s!2Pe?P{G;$$wL=qgRI@od1Mc|2NPL`HIN@ z^~`Cs$h71o2-ZI@LHw`!Y4Q9gASr{N)CWA}Ioiaeh4Y{2NBaDyk;y3d{;$bT>i@ex z|HsdNes}#*H0JO3@%{6^#>OV#oAmmRG8tv`&-vf~#E*fFqK=Nt(E?B)$uBION|?$s zJPOlp`}1E+01`sAqXk!i_TUGIiIXP8K^lEn37J1+US`Ru0ieEVrv*SgU_X3so1ZMl zxBDdx=rLDXDLv*WDVA52FaUk<02A#4;k(OJC)`n)(zZBSlG>Ej=|f@?PhAQJj;mf) z3rR~2WmK=Cj)9`029XXJn3F+40-?T-6|G1FkkG6MnLtuy$g7dAwNPXLw-#V2DE8v= zyfF5xNlwNrS|!|JmTuUrI{*mIw^^U?gP7`==O^OPK8gjvedkIyfV~N1dh_xW1p76I z3-_T!(#5o{1i*8m;SHXw*7s4T7jVR3fM#V1VH$kdGO%W#K+!-4n*h&B@h~lbUSw)& z;oD%;E;1(=riw-x=&3_`z-|RANMP5=nLTZ~i>-@`vx}kz7l%dy(`GXj)QO`vVgWjI zfii95CnN9(Gpwgh&5kxAJU;)gjK|(~y3MQ!)M#)(+5x&Erh?N9M@N|tY%~M~bvx48 zp?ZeBP#&nqLShu^Nv8ICxXiaZAV?q zhzTYJ+%Rnn*>k6Y4Hq(?Yt z7}bFR7735R1D|qhN_m|CCrG{%hdFU<5bQ}F=RmWPSup^;rR5@M%V#dj#AF1^omdr; z1rfHu7ba$Di9ud$wnj2bBw1lPn>9nSqCzt)OIjjgXc^5mkdjCj9^d2Q5rT!t=MQEM zYf!-wh%OR^{9t_=a_lAnuGT@c$wpPBFrPYxB?#d zh87vJ48U(50iEX0MdwHt&1 zj)1l!O9Yto$>}(acSQ5~d(&x4KQ5@FX~cmUHrY2-1OF~v10tKMFvAJ2K}Is=3|1Gz zBiZQ4yALM>zG4H|J0OS`!WW7~0Ll2M^%W6N7oImd{4I$B;-B#&p&np8y!;j-?w8cS ztzy_Aeoh^70{%P+8CT_n@u{*X|VLDFM z#WcN`l(k7J32oGFs3oQcZ6!)uVDuvr$Ymb~ucG*48b-K>kMBcBePN-y!{qrBv|9MF zRIo1aw1F;bx60c}UHfM}Ztr&?)MD927ljaZV(5-mwq1_MNeu%a!%pYrOAB2^tzh$Sk^T>1O@b5hD5nfsV4wqj zYK{~c4j_yoASnb~=(GZ|_C#VsLPJ#aN{0)L1<9Y#;bjL4;SB}K--Siu0OWz8%l(+P z5tE<^M>Z$O8=)T69Lm+R!W~jv781@WMFvnR%CalKKWK#_WYF6+gfqf``-dOy!Oy8e zdm7cGRmJCr*Mh}FSPhsm_+*(V(xGQW_|Ec{RwiPBra&$#MqgF>veG4`JOFs_`ji(= z7qXBh$mVd40$y0NDWYki57cBObCRACgdlwY7qhg&BLcMG8G@{Uz~Y}MxcK;}H3K*` zqL0|{XUtZ{QpZE`m=2mWq0+Q*3|OLbs`%kOJ$Us9tl&_2u_{{ks3oY(mJNEysI(uz z6pjnpD3CcXiz9k$g^JQrc8!f6dT5v1jHN|#c$!$0W|HoQc+^NfXGs_m)6~SMbw@a9 zks@R#ORb??h!91%pVbz`MaViChIG%ujzgT$_i7{V;5W7x(dut1i zNsN(IBt3I!I>x}C0{AzuO{ameLW`5!I3tR*@#qU~JZrK+sU0X~f~Gk3r9imY+RK6f zMRGuZ(iT8CI!%@Z0g5OPhAlLk=4{if9V~0Lq1_}qXW53Ztks4#6Puw66v>$@C~X16 zc*kaA21W9ECjKMnRwxMJ1<|i(%U%&i$uG#`j*?wnV$}({mJN2WNXioni089KK0?q9 z8Ggg1L~D%+=S$KEpElYBks$~sa&QRxR7cw$(C48xO=L(=y1K*=ZQe#gFieX6)#24& zIdy47BHaOg3tCPK8gX(AyES_|5RX*o?Kgg|RTze!ECk$gsXsMYBrj&_D0 zok?kSke}F$Aunah4W6Ku-`B`qxGrp2BNH|wgykXj0{?sHVmjbA(r<&%f$9ks20)7* z>IfqyMhHu|olNe)g8mKAc#weyLE+lOoVIxhfa?Q00@eb`AN~)+r$i)%xDZZ{*PsRf zE3LOM*2N^iQB!;bnxIq?RVNUJ^7mk%!Vm4C%Q&Ri-}Ol0VG#L3LbB8$LOvi}0E#UN zX5+zJ>CHl7^A# z;n6}SH5dSp910qPmWWJH(ZUEot)Dvr0FWF(Yv~DE8WYNU@N-9nK$7EXme!z!afre1 zKXnuUAUTHSnGRYQg!j)Lgtuf6ZOCoV(y)SlI_U<{Xje`qgO&!uX)eHjU?f!U975}Ts&bmZ&=GQ4r@85m|419sS8-~b*c zJINAR$e;-z4ibJ$Ci~mBs=8Y*1lW#;%-)NRA5yEjy1La}RsETTF#{BiTZQH7C>?L1qWhQ*D8mRXD`|Uq68E0r);MRqQ*< zD|coY^C6#`-y4Kef}=0RcuELDJT zp63DunVo>~^CVnJ2(Tdm!`Z|V9^DUvog;!A>WBam8gZC|_v0n3VqgihqT5NRa2H3+ zVu|B3DY*&y%f3*@;0pe!;Yd*ggL*oq8OgF@RR7G$r&W4oQ+jgtd z>ngqh^_TAHyDRG2IQ~apU&f~Kf0%omkK$ zveA{}Uxu4_f-*LZe~|X!@qe(3|F)fLpASm;wP{@D4p(>+2s`polwJwPv+_$xCP z^Q3-SVyQF_K7xInTfRS!@po}W>2@mJ68bDkKkubcKFm(x?@6P4 z+QmCS)^Cxf6K6>)RH9peBEpRb%^C7j(vDPoFL03IYs*DMdD(vg8#@ z+RUG+m$IQXblj#bz=UFgAS;M`{P*8D{!=&R^eg+==JB5o>;JjKSG)1QjVm<%@oN(g zICwM*a7R4n0Ep2yknp`V?C# z&=2Ac^no#6hUBD)8sI8~xCQR_b=tzp@!zSHt7o+*>0=wle>S%?|9^Fq-T8mo$`xE- zOmd^Uh(MhHr+AYBZ;`isUP*RLOS%7KKvDimYqqISh_DTT>DVI!)3K#GU(F35%er!I zG?8av8@^B$BJ3dA-#0|~xr#W?CS!sD7Gk+6V8WIR-GpxP zmNDL&^br7z*>k8tA)?S{yrSSrEd7z_6bkZ2$0UIA8Jj?B%rO=e28Od}Mr2+Cq9Hne zSK7QJZV*Hck}aM5iSjKun5W6O(tL{w?J<0NcByYY8vg%XEBQa~Bu`StCjOr}IttJK za=F7D|KG;7&-}p?U4CX7wz4nezzf@p*XUz-u^S2kA>tHz5Zc@q;4-dwI!=kfz@MXQ zH*JjGG_b>Ah%+b%Ih;@%eML~-db1M9D8MlDD^ND~S*r^Y11(2@%_!cSt_0I59`RtG zV4cqU(9&UGfjsg-YSYv$4Y!=mU{jRmR_Nd zlK#dsuc7TO${j4Bm1D^ZWXj2_cD(}k_&6M*{_Ge@u}74=(1E=swXr$Ghly#U8z42oSGcMSRL77gR3;G! z(xF|4x{j5gDF7evr2J=BY5z;^1iy9n-CbXKZQ%b;F#Es9`v21U-x2)m`2RMpt@3}p z@E+NAD*GP5@4@yxcmXBy$hgY_w;vG55w|!^4l-@r-`vEq)2*CfqUrlGQGFcZq3$9| z{;$tQH;jLn&wPCu8~lG~Gx@Op@57_~ZvTHP*Z#9K44Je&QWW!w{fcYMq7wrX7_tu( zUIK$pOs)ej#Pa@?sVIg%vY6VN-|-O0jPr#%YvGG?4x=`eN~u%`cMJ!;&Bcw|UqD6a zqx2~N*_fyANE|NepG1JEh_J;>^*WL;dJ5-=CI4}G1o`YBF`llIwMe3Uz6~P z6BDDOgf67&zNEN)*e<-i@C90jCr#dpNrS2OAD(vmhl}D5RW`9i)dY2KzL>HXI6Z$s z6ZaSXnfeP=Hi<_UZdqPgpx?TS0CJT8-^LKfY~jc_=d4}sy^gEYHs88m?yl`zEBU_z zGY3oObU;=iFCr|4Cw}Bn=eVM{_DZ-u z?hB5v=Ng!SJQC3tgj6VtR_Zf-L!+ z4!9)lxmD*_h1(Twr@`aaacc@_iJ4~3ZBZ1pgI5b5B)82lrUS+OM}P4T{wm2NcehQ- zh}25_(>-2!X)|A9vZlfC7_oRYz_~B53-8+%{`40(55qP3fZo3!9o_mv*n}sLf526s0mu zIsdp))5PQJhFm;@1Vu3Nz7eRb@QcVn zgI|Dj)ljHXRdyym&=TmXdSVYFMxVf_kim~5;Kg_nJ`a3lp$~pvZcA{EkI)BYEz}o< z_fvT0CB|uxc$~wuQg}KqCTb5AxdB?Q3gkE^=4h93?OGFf-@Kr{4# z!q7Mi)tI}nbFqp%DN!Qy6v7#3WjpA*LtV}tFu7idV<}jq8dd4Y5T6@cAC?khCZp^#+z+oe zPYbNt;z#1E^&V?=Shd!u^=hp5y540Mt!Owt+CzXDB^|SK%^Jntzd1(wmm9?$KTsJ6O z8Sc$Fb8D=KKnuRp&6twn;o=PpR~3=z%a<>{at?Sol=$TBayqsywQ*s&T0t7}er8;xheW>Sgfm2o+0TMM$+25TmA|GQG1F z7#mUqWV{3FllSOf z@q3}>Re3C8?DEH?goq&t&+SgD&C27kb<;NH6{>nwoP*c#9A-wsbalOt*>Lzq=|_IJ z2Cm1qF+c=u=T_S7l0Hruw}x`oYm_GDfIoD)mC{_NTjg2(gfSIOGEd_wEjn&)U`3XB zT<+G`xoz~%PAVS7ZYs4}zu}%O4MMaQ&TQfItLB`kE@nSKed-u<5!Q7LSWlayBP#-M z-z*WemL5MTsT5f^fBFl^7Z_m4(YNNp)8s}wH z-@EU+z1mq{EC9f(cYyz-%F?=^BuGRxNJO352Y$FIgEmf*qnU;FDkDuhR38+Y|7i|7 zqfxh40cuLND}+HY}NQgIpSc z1S-_?KO73m1<}-#D98T@`P>#AyE~q~aaUbYtwJ_}M_3B0hYT_r!Na+H=n7BcT(9au z?UZioyi=)_fJN7*z@(77$5jO+s6#;g%4A@d^a1lo*!$g_VW$XAZDEp-OH%hu!FzYb zaG%vcA&4kfc~)z5YY&hPLfk)6He^@I27!0IWQYKIyj;jWplo$O6%Ztr9qUA+@y}an}4OJdpy${J45LMM@v!Y(qZ*Plpy$Cbd;=E`L#zmN}6i2h)ikF(>laL-p z#g&bz)O+~h9OOOvR^hivv?J41DdT)O*I@%ph=LCPJv8fkvF93@4^yaJ!mae$&<4;B z8(L`ujWH{Zpp{0GqB$LZMVpMiqD@8*t6Rsg@6`uP-74yfdGT^GE5aazo{)oIrwBu# zI3L=@p?OvOZ8n5ogZ`+YLh)X7Z2lmp+TVJK?oYk^>%ZD!s*jBMQyu$ouZN%i$R8aX z?9P8|*}vr{RY+Tg@a+hsD_- zkxIKK1jpTbjmc}+&0M3SrrI1$QVB0;&jahmmcg7H#BV!`tE&{NJBUde4Dgsa1L;1M zG4A}pHzo!%#zflgFb%%=&@*Su!5HeeS%G-ay%iaMOf4rA$TA@;l7Uhi&)7;E5yaZo z=p;8MQ`Y%>h7lzP1(wUQt}#Oc{|uAt7MmS()n1`T8IC39%i%!=TL++LNMzb;O%4~)kO7saSD$k{X z&vS#H%^uK})M`R&x3e*jHD~%L>Jw=%wiWK3qx9VZm3>flG6I`Gf~oSzm`>)MBdzBV@awK-on+L%>#;miM$djI8lpa)H}nG~#*JxDX6sL^B#2Bi^LlME^9W091-j`;*`z zsnO2_USXZZw1>tR{tP~N+Zn*@7Qwx=2?e?fr5P|D?t*C!#()YWsX-YzQoVrLwDh9v zlY=Qb3f0F&B{xP3Mw4<=fBjJE(@no$bXyT^AqYvoS-Wukhs(H8G_D`b^%14 zK)^wSb;%NfKApk0u3T`L5W9`Dn22zH8&Au-Uo#)#aX%J9a^9?0TGbk)lOdLRJ~ipQ z6Yibg84j}-xL9cnR4=C}uGcBQgS^dtr2&MpelMmjm752l+E3sWC~ALj>q06fYE+Gcj2*pJTY4 zKQ>5wxJXHU&1PdEK@^{0eCd~xg~FsiBQYpL4J$k(&w0Js>$iKIFfeu4dA*8!ti%pp z9Uc`Ggk6F=({541Ip(ZkOot%-0Q~TvNDNSlUi8w)EeBJnl&|3BLN)u-r8eh5?FVOM zdRHiPVEzqYb3X3Q4BOU*MvT5r0A9uTyss~sKy(Q42*gi)dTr7sJ;t4T8qP#)aLQe6 zLhGlihI{{1MJR!q_#R?$g`WnjPff?vpv!>(p_of6bG)uMyS;L=Qez|ZvXs~(4)|Il zw{vLH>2)OTm;-q$7cbPRBd&g6zCAGvc&8T9)f}T4u5KFF2G@rC%8ji=%1G)4i;58O z;@c)<@1ZjuQv6T&OQh7svyAY6Mg&D;ZnP`CE_7`BccFoKu@4b5(kHYy>b=oOUL!jo zxJ39>py?1|T?OmarTm1Uj&1@`Po((CE>Y2_j$5q;yL@eesGqX*%hE}?(XG8qCj>D( z9csi)ZmsFxmr-nLs$=9g))e(sC;&MH$BzZjJ2W_)vDi)S6Y;0`y%9QNBY;vO6c`-> zK)fqZRxeteDjVF0OvL>VU%h_P2dy95AxI;A+%*XKhjHnf7}ml;jM>b~blm+w9*rD; zBa9k(n8F!Rj1Mn&yhQYGU#H}qi+YIowh2GM{%?{9HE1H(9*J;uI6t6BdjY24CtTD8 z`{I==!??g%C&n-`x|CEB!3u%3N?66Yr(c*-Nd$C!%>@^89;AW*JPC$yz{M%in81W2 z_T8lKpj)9#f(hk-65`^!O!}9#DcT+mAU6#gH(d-HNbhydy<~2CI&hOkx>)5!mAVei zDdl6P82$eEu5H;aj=f2Lf-eT4o=Ev+!QGK{gVk@NZZaKu^a=pzC?uML<&L@SaWdA1wkTd`Pke_F6`}rlw|0?xLj|9cHT z%Z{@zoDP`liPMs`+t_!O?X^CL?%W&56~mc%zuhSJPFkHa9%!@=6Bqu zRa8I)MC20$^;2XJ1Q);!P=6QP6>(tz#RWf56j0fr|2cPg@4h8TJ5vUiK6ul-_wGIS z-gD1A_uO;OJ*SNRmjOqM7t>dR=`)lPH^N-mEwxJSE*9j*1e_s?Np(Q^p=4~(Ncmip zAmW^PLd5wF$3r7bc0>XUua~AW@;1aJ{`F=?6ByIBn>Srg=kAhtBDFl7mtltNhLTeQ z@o--}v`#u3AJ&QweLd0M=$b?q%at#V6`-4jOG*ZEBIMzCtk+FN9(>!S)uA`9hPS~~ zfkpWA*O1%#T5A`+)gJV(KroHQ484_-s+5fHMoT@wyvB*1MEsC1s%Igo<6fHiJ;5;h zV3ey3r6(p?QKU1O3tB@jAt_;c%FM_dXq0d$&ov7-Mvb0&)|!(d3=O`J%<*kwn z9w&0+6By6e0?Vay6qj3CEcv#Ljk%Etv{24MqVwuG+!Q6-wbs$)ri=6uV@3j*2@`=9 zGF@V5wOiSA>+4Z6yLf?EazzH0w-pVlVTlRL!YNrwlerfSfnm}sQ|+JvlUj)jvs5Z( z)ijeQHgw%!Dl|OoX5)h`{U{<~9g7QDl}oTx!&oVj#i+IVZnD5nXUeF@5K2vzGiqKg zxHQUlODno<0cdlO#z-W_RM;0IcO_qhn)fo-2e`OkOED%*aIkcq;zODeiOa}5JY-ew zbbF+AiPUgxcx1Tx5F%IaI-JP*!u_FpumeHt z8Hyz%{iNZ2p=3yp=fH4<Ca?j*pSIg@ZA;`P30ItY+_X+Pyi`~OmSKqjRw)W z3K7>7b&#cKG6l#WBHwm1_F_;-t^lq?bd9`Y+0uBFuN=hDi6=>$DdYT{{kH_Mc&zu(sy~7utya}Unc}fP+!|x+n z#Gp@7WyqOTEzL4d<1m{*CLn3^2VnO>pIEeENS{r|G&WyIg0qHU>_rM=ipR8C1p*g3 zs20Ig1FBQ z;kOu3758w}FGVL6&Ev8PD{#Ylo{NbL*)RqHmi2AZw>l{<5?LTIi&06+^=@ilE67ml}n0*)LRxAJhFD`9#K*isofnr{bo_BfX$WHTV<- zY14~=>Pq}QMH3Ddowsy$61}`K%>+vJos>O4T6(UmMW*IH)MGn>b^d{u%_JiXYH_q1mX!i7 zU1AQFtQuZLbTQP{)eV{!!;HL9J;(wND>PwrHfTG;Ao_-e2rsL4 ze{do+^hXUs6Ih7NWc)ACMZUR-Gk8^D#m3%{>UM`2HMV_GlTR>PA{W(FlGS;YVPZkF zaa+NHGz4f}`FGPYj2ygXPik#9eYIsR7ILoHXs#kfbu+#|Z8Oo|3)n!F2YGaZ91vB~ z*~las4+uIeq68K}c;GoQ2onv#0r~82^GI;RuV_3KjfML9!jIi4g0d zhN;JTW6@Zgpk}YMKEa}?nutOq2_(GwsGxc~LJqr042_NAKsL8^Rt>Q0#@SW>RqV-n z?UEd{dWM#*X35+VG5KNb5SSciO{)w%rjzYd)*^P4{3)g?{kf7#-r?>HeHBgfH*N_B z0S-_xowU-BrW$8#WV=3)DpW#qI;w3IvPw;c^3i*&#!>ATDCN>L-=x58C$bwt8-i|Y zMPOa^;#!mdn{OyO`(Yd zLZ^?qL_pfQR4NYeH;f1hLzPK{G>c8qVA7^XhY78i zr8hB$QHYxhO|atydyFl!eLscG!P%&u2Vs!rdZx>AQdyVF%DodXxAqRFLcPPpP|!ez zP5yd__ONYzIs-Hc7A|}n+K^v>U5&KGtssUs4a7V%7k0>}pPjMlBrI@3;Tu%!Gc3e1 zr5rig&`EZ1F$o@+Gw)?9TV*=4Y8K1xbW^%cVzLw6DfO0eFiN4qEPN4$s?X#~8DgYUo{-j) zQ(qF_D`f})@obdZuCrZen?A-sDtIo2+57-zdei3W*lui-b3|%xtIUZjP6mle5s6$M zJ5Q~UI5T6Fyoa(Ki3Vkw=aXnyCOu>~I*qZ=qAz!8A%2paGd+UMf=JI ztxK?31e&gGZ6u^6BTFzOteKD667pdnNwYO1Bo~=5C7o!vC85Ojx(d}*yvBLNU`^PQ z&gIG8CI;`7mz3zqE~wl(AhN(3uVI1`bi`J$9O7D7Zj50d9*jO)OqbG=GFr)bb)&mI zu;;06`$9O8+b{*{wl3tOX1Zfrk=fhpP}2*+=3@ISjEy+0h-Nv~YFcb@c4(EYYlCBN ze^cG?#>V2tYHd@^%to}Y**)7DZdYS9sIgemRMn~zD;oS*)qsYKW!CMseOEQNW-G&u zWO$bt#Nt^Q$Jm>*=yoh7!9Uls$wuBtOXMl7Bb9cKgCu^=Y2Q7)(v)+4YjNq z3`;@Q264-M{w9EC>ypsmFMyrCBj=T?tY3zN^ssPtQLA{0X<{WYcX{4m(p&zOyr;GGh#(DrUXd9E`WceJW}-rNgzgQuXc4g(bncd2MCx7+WQ|X!}Jd zOBzU*OL$~T&eF5xH2xvTT#%!b+bRogEVP4?Xg$kaWuvutm6a~HIb$@UJ?jcogI${b zU{HrKjih9xTT=<{Do7DhSeBb&@s^$vKUVKC13E1=Ty3i1-W$jKWNWQ~Y_f}X*&b-w zM+hgVS z_0_dtEE54p(~|s}VScy7AvD(Cm|*bOQAs=|$%q+$@&i`n60ok!|*&WdA z?xv94D5+Ufup^q?yhyjCZ*nkOltx>y6l#~vSAOb~LPSvrU-kc0Es9g?+qNs-;qji2a(S z8I-S#^6s^7)7}{Al!HzX?*r(RrgWKq4o4J*(MZ(90%LT4PgCZHx8i9iNtihKOWe&9cctbco%*5%(G=G|sj|d2 z&k&xt7b?6K4->LXMZOm*B$JvXVFT5$0chSsT`BqKIRML-6%4ewWtQ#S+HEuKYZ})_ zz9<)5c?27D=fQkz$(k0Kb|?AFd~mtsaVb59t2f!`Z%gI=b4oJ0$}6j0X_z?mMUhIT z%RYo@p&M=7@PnvD^g=}3cY&asj15cC@Y--xcW{u;Z6RPz841TX429PXhoV5dVRu!! zG7zN;(#J!C($p~OlRQ$CKIX}zMsI}k=ktP5ugL(LA<$+(RjEaSx@V&c18yRN!jwl6 z?d1}3hWcO-2%igGupS?d;7G+lc_F}_E@j!*x6x2pzO7LWP4HJ-{LngTXo?N3HY2II znJRvzGb_2w7U(&sY_3d$AyIWR?gWEfAIi!aY@BX_sGGu|o5sl^BS{lkTM*xPj>A zmJ7U*(HQD|UA!Z@iBKQy8A&E%LnFh;P=qqwf_}DY<~Yx6;Q8A%Zbv#{k7XndNfebN z;o|)y7+KF+ZZg8w#iz#Yh9YdG7XGohxreQ^fakDu5-GPw9>a4_l+uAb&@+Kv+r~zF zCZNNmi@3~$0!x0n7|0Q?l)wtJR7{avWSeXZ2u?g4GmpZY`GBd(2caO_i52gox;Vnr zVHBgcOQ>{FDZ=<5qk^X$jv=QgqKsv;Drlrz6^zRliHOETK=KBvNO)BveDZF?0Ul1K z)~6_6cInx)G}A222HP|z7}l4#IwX!Wu$09`TWqkiJ|&qt($G#Lah(KGiI6yns2D~p z7?4M{u1OQQzAK$dvQbPN8ZTtc5Rv_4<2onDe9WlHow9og9zvcSyUz^6K#?>RF`*kHR0bgaUJr z$gM=2W|azw_=apA&nC*btuo+19B^ss(3JWIl()&5N?HG?jnTOgh?ZJkGaFe`mC>oC zF>;xZO$iBG+x!H8m}GNFU!HP zx+_crUW}tn9Opo*y|KZ;&`_U;FK9V#j7Fk{5k?o zbFlsq8e&=D*>{fC65ZuCu|}?5H?B#+DT^&y;H?pb%qZFAo>e`GhGWXUS_$sIn|fr; z)~uI7T{Ca>Gp7oiFZhU5b&Rt; zbg4*_c^Io*BGg%xK?qVM=LFfTajr6KPMJ?L*E+e&%=_aqLL|J5s48GSnBtDziR*6o z&Ap$ZV&1ToWOhCw`qY|cDkbJ&g13?FNa?3=>mMvPuxNsfL^2YMN)!c*8&9OS;;96> ztv0Sm1=Ii_m*AY)_OQ2pYL*qkbdc4Ki_W_i8Urj(!h|!KL)V_olj&{jCmoAIAOybe z6N*NALcMFGexOPg27t*0Q%IY(Q$I5l);$Pr479c}OJN+Y{I!e15E62aGrR}-fViiC zR&p%7!yw8Hl-LQIScQG0Dy&mLt|DqB)Q=Ey*dohC=p9^)bGk*lo6KaEM(cyTwH!0)&1Y4}>U*9$sy3aqx;L+6 zwiuh8&YpquD2e@mEoUJ%aMhPa|E-z~AakDB$7aM|oFwCVh8Ks0nG_QM0!M18J zy`xIG4C7-3t9R2%`l6{7m$_&|)-9C)t&n7_lEs+~7LH2EYnX<3*0NH>tD z1L4T(fut1liAr0-l37uBuqdZ3osqC8!)Bk+Z=i633wz0s-AryKS`m|acvEx?h6|O+ zUXYYo@v1q4zyyi3gS^jefx;&|)&rCfV{1HQIHz-Y>I`X|&4ZX(mxPFd9EK@$t`yFZ z*+ttv$*F}UWe%@YDUfvoFmy6UrAcUqt<1|VV*w;cq#n|SSrySZIt3WHDu>1-NkAri z&!%CmHkiwl6jd23vu|uw1sp=jR4|+mT9@m9j(1B51zX4=;+afnC1GD^=tpLGHJ8=c zlL|96Th@rXM@pdp2q7r)O6xRmTMFDsy*XeHWRfYO6bg+F6K=##2QDpBs~atkh+$JQ zvAx9@rhvn7MafFz6P(oI%xMU?$=2`fgPTRx7J)t;p>zFPUd(x%8bU95sTz_WX z9lM#fUjHD_Zek!rUUSJc)H9e`4H7%u_Zp5RJd1^VHg2NU$s9GZBxh+iRl_G~FKwJg zcmiS=L;<&6j72PMO_y>Csu~5(M%VFxGMGj3in4_uPJ^NX#bqXh7JDnF!6Gig zLOtPBG~A!;w7!lbyXZ8qL)vO`&coO>)(+>GFtO8;#)l>J7bn!Slws_+$?r2MoOm`? zK(%ab_PLN#+Z1MG;9>?!#g+`@wK2yiNW5E&udH}X#)fUM+Y?JBV}o-+FB@FDja_)X z8)%&qPDvH3_g^is}A}nrCsGS+gk@NawDj;luXdvyuq7*uX8x$}*XpGr3 zAEwJ*^ms(i<`6{jb^`_lE=S~Ju@HmuP%T4mWnlW^69t_MvuGAcA0}jxtm({zvky)U z#M(Ts8Je?6CTQ#|TqGJAnZ-p1g+?S~=zQdy9yZ?y^SF!w+zQA@X%w?`VVa2XUV2nS zR?B>j$|~4aBC(F<0f~?imds**Fw`OnJ!l&;kuItd&||L5YeSojSYd4@(*jJRAhAj6 znH8W_O|v+pnPafXa;8QL{;OF#iP33pyi!V|5R%r!3r&P^X+$DTC@M}%fEc>!(&Q>F zcwQPr50J%ptMo7x22{HVPN$R#9w5xakjqZfWlknt!3F|i>A6D8TvuMStS;(Ej0n)k zS(=ReX{C*L?5@tvx+OC-Yj*q683S!HaNw18(zku_bXj77W|QA$kE1#}jIHrX1JE5f zj@SYdd0k=Li}8>Nqe^Q#YGmw>rcn>X##x4%Oc73@jcMp)@|!MJhPC5fc-F&(mM^Py z%NLK&L))b9t?VYk4Kv$pF|~sk`O7o}q$6}?c%@GvU!m9?zqvru3HRoa5 z#cZhwpmT#cX0ax(!j)$yTbSzhMb*3}GA%vzi^lh$1RW;xL(h(-+xns>DoWv$iYbDa zCQ3Ipn!cc!p5VMbyv^nFNX`T)%4y@fp2VLpxt5>HBgwDrxw9X{NVbuwS&bDJtV*m0 zXcBUnx`gMNV^e0MX`g1{ZC&~gQXQe3RA}5Wu@kBov0!a&s82&Q{?T+g{V>0K$giX# zY!aAw?>bGhgXsmXYtl?Crho|6@N-`&J;f-GBv2WsNFPvdsy8%D=vRl#ei8@*Hm$_S z+|D*8cs-*^VVnV9y)K$cBsWCE9=#cMpWV{pbC7)2MiP-8;&QB(0rVi%(8^fN`RWRe zMXfim52{XpdM8i}TXJL7YIhCmJ)sOUp)!@uJoO&_YtW)qEpSh}@@!*IQmV;91Nh-M ztuX#?ybp%|a9=1H9*SWgA$$%+qrC%>XkR=$#NPDBLxW+-;+bB;ux{s6|JEmI5_oRfY+|30x>Wz>%U?r&-JwVC6;`&!!<;=k{W zt67NuKGBIT>f{ove05JSRU^Oeas28I4v9vKM{lJVw-((hsC11unLc zHxe@O-O4*6)L6n4f~7;5Kv~uNTv0WhG}C?cSVpFQb6A zm_=qTj~gJ9P)$6Nk}j2i(M)qt;cZ2-psb7&A|o|mM@>+1g6NYAXDHL!0hGLqR-II% zj%I0q4b0pO-K{o5DJAq118r6rHlRPS{zTnC7PpuvFSG3tgdd^1t7Exs&Cn}Ksi-hJ zHW}%!OfAI?@;JOS$#<-+KngVgnxu>#@T58_BoL*Xr{Nalv^!a-xk14M#|1 z_C1Lz&#V)(GW72_9!(;OK6)TeQl}?JmAooVqCG$KazS$pLxZpB-eD5SC=d!6w?t%8 zwY->wDlH3Ckx5t_jvt-^ciF^L#xkfKGEg+t{HmIAz^k>9eRQ!eoh|JhZD{VShn7cs z6hpB2tupT3taMa}%?H`JDt+`UU0u#nLCWK-~#5CtE2Go-#GWP~}m|Z`9&z&B0v85bI zxt6XX#FTr;#(nzh5phSP>8-a1Rv@WoI%y_ zYiIFY$0*rey}?Pk8ZB2LVl-_eq@eqXw)EhvozAnsjMmKcos}E1&e?@`w?rI^3Wb{w zXN#ZgymspYg`7{~TPxZ*B}z4Oa;#vY+u8d5U?#spZJ0xTUOHNv^8g!?y_1rRyKqfJLP`)lz;LX;x7 z7kDBY(6EGLyNI8TGD;(CFNq9}s+%8O)}+Ttoav8QQhtgECEY7COX*>Lz4yNt#Su{hB84iJI2fv8VW4>yq^9HQ* z%fx7|Q|FkGLav-k=b^7T6K1cgxqk>HV}qu6+9s(JPiArk$MH{hfDDJO2k7bl?K@^s zRa4Aq>NlZ_vfakUM%_;ol`VL6=p`H&6}gRm@hH=cHXn57ZR{N`cNyzLJ&BR;;o29u zk03u7!0Af>Ne7ozfM>;;6Pjg{Cf~2B28J&WL@)zs;Rp=bcc<&Dsz6v=w65Af=;6a` zRVb#@AYIgug_&*=FsQRYWN8~Rnqh#rA7cZWxX2Y6iJ;MP6D@)<1nC&$u9ReT6-Bqc zqUR8}FvDaQjmK(5a34C%ahdH5Om3RJ$8dWvycx} z4%;F^?7lN+PCD&d4iD*Uit;1lSYlj*;JcPxg3(DnoryFI3iFVdiq4icZsoh|VM%re z9t~;fkTmVN8LLKGf*YEFHOQo@Y#xi#Tg?*yU3Rd|d(OHO1>IawnoJjMrr}0mma}p2 z#FmPBnmIV@v2CnS-W*--==+iAC|K7r&Y!mRwcf?q{j1*opYYoY=-I6@YVZH~0=_ou z{$Ieiu>ZGru6-KzZIGnH$nXE#x1nJ%{5|Y2`s~`Lq2bWi!C&|-!F>`*zaRN_-oDi! zo=5&~IPX0A2mixY@XtN>+yifB$o~y9GxQJshp+IT*OJB^=t z0_`(PV1C9QPYW6F$IR2FXZk|o*=N`b;hDS;pJ!@+=lRX>ZOa$ySFb(h_KWy&iV36! z5e1l91F^4GRUPZrXFYwD=LXXwUIaD2MM^ks=B0+$&pg-gx|t^%_L=!De7dKh;at4W zYiL--Z^&|-`4+$PJdpp#0OxhjHSD|3OAQC?Gt+Qv!_04Ag7RM3hu$-E9Wr@XWt!=^Kp5H@q_cB~@y8>D-2f zCjn!>eFMGkdA)w~cliCKGa>zNh5M2 z{@)uHh{2{VmO4@Mg}!*`Da8UF4J|6D`PRZa>UJi?c0=3mrP6vd92!c6h=y)+&>GGAdF(bSn4K=(=SGKX2JM``v46P^elwrYy zR#1MQb_%?4-5`ldo1z*j=3#!BUq2?E2uJbY1p3j5jU**M>4eqP$JN?&DTn$X=r5BF zt*en;c!-&u70EFrmSX^DCJG60qa-22s&hgq!J1gKK;yP*T@GkviUyQl8trl*b#9|{ zoFZOoji|Teul1y4;|Wq}9$uN7k49L% zYwA|2Y2_MLzNWUz6&h74<=T1B#WiV8x>8n9JCGq~BXte*=(IGND+Dr9Q z?u#U)rOgh5I;2uibK?a(eGa%c_R+@8-P;{fpxq<2w|V@2_`4kL4xdMo{BXAjcN^Rt za4%w_B# z_d$WnTj6&rd8Xf5$Zv<#f(bhG8j3(|ZvfujVtnThYQG)k7km1=n*hx(e&Up2v8pJxd$Q0Lh^^jd;d6U_B_mH=C4{p^@s1~XeTGY4}oFGqgp zXLp;%IFV^m=E-qpqSyAIr67m+0y#0|ye+c^V8{>o925v^Vz6~?0L&GD{EpfHOt+cK zkOGXYaM1b0PjThLQUh?e(s{<`7cv?PqxfzWzPAgVLaHBRO=x3(eRQ_t8T=+|0n)6ko*j&amQIs($hEaOOoEBOf->Ez}& z)zHH312*qDAqRxt#`F$rVxN%7G+JuSH-=7`(`~L9peWEG05mURB-2#dw%h~^aJk&C zJ^Po7lNXE>e``=k>?a+hmk7@R-sBErI`%uDtpIqZ1Wc26ONR-739lW?g>L~?U_g84 zpiL5cuZ=7m>AL`%E`?`;65e4grovHj(3S*jN!zj9SR+Y9NkCWuuxC=CfR^4th+0h0 zVJbD)Vl1HDZvbEc=nn>k7eS$hG^3x)y#fHzU2_0C{3tn_i%$0)CG!HzI>I zm0-jfMR&wG&ea8PEqSQDeHP@|qOMqJu-$Cck?bsVcm}aMeOikEKl*i3qK}DOjkQQUoYs z7H4{y(}Ty&luDUEmCK`*F&BNo-7+*f8q<|+^&kLdjS%34?nxqBDF$3AJXKjx7GqG*kwkNi2+nQ)HnN0f6xA*@3=UkkdbFRAIRaL8M zt?GWOmI2Z*65Mztv68SuxR{6c81JSo5~Ez^E2H>^rx?d<6|g^d&AR!G{lwx8@eEJX z*d1y*D?O3o%Mmn_$%>`>pI=+J99Z#qHfx}omBNY-y^@vrIY2X}FOt|R6s>fAZKf41 zhJNSq^O8XOn^YuiLcDW+Vl_r8XD2`3q)bNF$izc*7lRU^)|7PeAibnqOMBk5z$(C0 zlA&E$C?qiBu;W^_%b70C1R51}|AM;BKa-Hka8)*BS$pERS9j9?{Zm%B`l07V!K;o3Dcd(CnB5;T|qLF zVf2K`jDrn=)?~J%h@G}|)CjARWM;ErsRpfQ2Qo}8EF826;Qd8mHYIwl;O3R#s_ZMp zg6O0@7W%vqL>g!pn>z7v`67f{xJf9uqR9%y$C+aWBl{pcc}BA5Yn`T6+-O9yV_XLw zv_7UC+y2!qjdIdFddVGYGK7SR%7-SqzYs2CSPSN z1ZM@l6-pU4lsGdt=@dUb30HP-5u{OyX2s?zl}9bwk!^FU!yZk+HP*{&?@8j;9HyjpEFHQgi!vKx zfBW7fD@qhzE~iJ%*`D)2C>5EG8R(wmq7l!S5OuQ5<&OKMMZR{pa2hc>m6fKD`lEG+6 zNpI+}F!eO7qCAJ;+JW3aIHMoFBE-59GuOsT!3NspoqUM;EK7K|qS#)EHGj18Cp@&N zE>M%4_cweL&#wc^SgTIdXF*a)cZLb8#YDy=>Y@<=n4c0ezlL#3n}Y?V7K-2#>D)gx z^M%VX5SXz$E(FM>^fgQ|GjMb;_S!>1mu%F|oTZmG>D?FS7$nm>ikA(Jw9V0w^O^T2 zIzwhZavr?%g4Hp1HM+QmBI!_`|MZ!`?N%JYq_)VBV?sKfVPaO7o4K4cLWfCYr;*)} zMM4Ia+1|7RgZ^^V<6m9JnfN8WEUAaHGJQ<*3tkNsp7;luVfWYAX zMB$|iiD-K+ilLan9*3K;06`;b{Kt8G*1+A`{Phg<^i&m3INYa*lw zB)B{!+&bNfS_K8&)>gdXAvK9=3;YrNUSjy8dR=A$d?D!RmhA`T9#Y8T0V=`BRrX)f zMzoImZJ=u|r-S)JVj3qdRx!5hvM=NF3K&%FfL^_L}2O$}U%*ZM@d~)<_HhUr2 zrR-62UcNyMl1GA`PAFr^En$aiND^wyuf@(Q01HB%RZ5{t^(t=vz&v}FJTlML2D!Ka`xMQH2DqF6 z!O(Gvf^cq^=q5rs)m2D*^f)K6G~_YO;)81LgOw4d9e-WesQ<#k<1QTcR%BXEc5LCF zHyIa$MEW&p0yG9EV$1>W`D9|8u_iNw(7``339s5=2zGWSPPo~8N#soyFlZ-Wc#WA- z9;p|as-|zeC{6xlu|e;@D=I3h44|P&K<9L$!ccxKn579{qh5wY+g-$k^Ic9%WTghV zq}S&>uv+1EZ%l7ZS8O!ei%!Eu$I_;|K*#OXX4n`stum!IY+a?-)a^(QJ|n|l8Vjpb zQgJ4iQU@Dcg=jRg?v>cNvYab}SzeV``_G@+(qLD9vI zt6P(0rF&9q^vj_=iK$;ZR6~j3Nqd%5)-;8;_3RoXU(z3NK2k75-`-CUj!o!*ixDA`W@&G7f!}Otu{y6pam^Zr3n%4UB zq@nRw=*GIm@H&2H)|TJ2|{~1o$8B68fbYO@KD^PlnG7luwKiKx|<|zgLwlzhVo26o|DJBQbQwV zHXETqsTq_OvK4EgI_H`jL@w+h5g^uUy+xx|aU2TgETblr0803@t>sEc-BOw;$}y_hp+fDI0SX78WNJH?B@=LoxVfI@p5|{86FNu2n9q? ze1O6Nq{yN`6H;+5Q4LEa(eTd4?aS0r*O5PkZ3pUH-JpJIkTC1DCb!J#=}UR|JWgRq ze#AV>=q~?`rpI)?#fx=5HcMeB>QWK5$EQ%XadANqQjr_zbzvZhB z3{$jl{*Ep4Y@)ZFPyGT*b!S}CK~yo^gVX>YR7>BhETy)$;q-S&Lo0Ntwm}vdL6sw8 z*jQa%`s7;^YkdC0)dY%mb)s2v%7?S+FViiq9%e^!T%s?r+wBidg|iv1Vr_ z>)neF!*6nx1f!G;dUlEyybQ4=H$qOH#cmnRiS1SFG-z^DugdwLj^R@4EUp=v(dx)Q z$b&mIq6@(cpe42;3}NE(`a?gJS+SI)Lz>!*m!yWtoW-PgG;y~JId)f?m5aI1f;@|; z?Q>eZ?|vHy=qZmveCh7nQY!ODCTt%dAh*PzznnffpkePQUMN&Un);MeM~{XOX|eob z1<5(d6QKw`D9VT{N`yF5N5Ez0218Q^8ku3cQt@5kaN>)}NsPp|J%0LvzpusE(((V< zQAGA2W8O9^U0+^1x+ET-9|WwR-6U=O4KIIa5fT9-TWotE!@5(vQTj zcI}b1-q|U|DuAY48?;KCM9C(`z}3OmMZfdauu?-IhYf;4C^pCZysRZNb)dDU<<^!} zaKRW+sK_iVKe0xZK@pWu&hb->9z3YUGtNkf(nZ@;YIPf^86g^qny^7bSRFJu-FW@H zN|H9@#>0i93ME*@v)mypj2*KmCL_6p7V(NhAen}>`ew!M@mW^4%51tKl6>f@0qg6} z@|(66F+5GRi`5`WL)+ygb;`+|GknG}KRp94BRgx7s z`}0;kmXFKnq+61LrGOs*8Z5?oCc#A-pC#M=(MyUdMv<&&Me^52`|+xtOgODgSL)pP zl5bxw!tI$0D|^Pvi7n6Oo8@SQyMvG}r~Q18ov(#|&gFt>^etxS+9CpETy~MS=0>E| z*g^1GzL&yFz{_(#uko!vuKR01@aLMx)2EWrAn<;#i&=FF=qfH0ozDZs ze%fwjNN&N+2Mef{2CKQ^%d8{d_z^)@cUb=bsI;?ZudAg z#uDX1mOd@6jO4KUaq-yf8*1B+BgwT>jt<_e0Q5|1~!uDxoNZs9+zKUa)k$Q_$eI;?dIhZ6zHr`pR<-@|!{ci(CbXDICpZFKq- z2rB`#9y)MbT9^(4$?at}I!SXkVd4UH(w4Q|EX5Ozg=9EZj=wbJ?7y;sB5A2bgp-Eg z)a+2US-Wje)h1_Kfz=!gXJ=ajtIM&*(Q%hFBB~vAH};R%s2X^6WL)}jwsk(o-|Jj=R@>&?%HU3pn zM+fT__-m=H<4EYH+|cj3?OyZ)diY87BO>e#8UE)ttoq&Vt9jr`xvA1r=F`W$qob{1 z=GTB1M=s#K>)YYc@u3%?h2M(d&2T<4m;V`T>pXqXZ|#6m+=F{(ZYd4#Jt;3iKcf8W zG|MW(-q*}+rlawNqhUM*YVKMQUyHZ>@j&tYB|?X% z^<2eiNARUbPvcL+&NmImPi)Q-&mXb8uRxD$ppouZA)bD&`uxH6l8c7+zZd)gs^A6Z z$fe&9^bCMJV87;|rjGEi2HAG_4)cS4kbuoQ-G}-@-9ZWO!2AOeAvZw!A1HkL5ce+6 zX?|e05kCKL5BAp#qt3)vCrj%4Auy?fF8~5oAIyJR5Oxqzy~2H|cG#S_|^V^K10pcnlPcWnT*({o55Bu*dV-&tY!hyQ8m#HajsdMBQLK@Jg? z|8xiU9A^A4?jO`>|6PgL#ebK7!WjI&E@BY>E-mH1lO8y968sD582;ZPjj{iOJ4?TH zS@J(5UH@-Id0qcMNmC)k4f=-@u}1$zh&E69FCWAY{>M;e*ng>={=Y=>{Y#|Be>Z1S zBFY8gAO16g5&j3EbZyMP<57bC)_8{HKLJO@3CNJ{QjJVrC{IxxbKTmV$}2J z3(iz~-G=|VS2v7?ZCfIPR6ESflFZbjD!-jl-JA9*_W5~eY`hGdo(*YZG8QO&R&QED zgKRlydas3UUxRra1c|QR{JBy4`qDkBStDRA(hGM}t<4W8^!VHwO@Uis{Cv#b{Iyx( zfxS}W-wVb6Ap9~{vOdY-dk_R|!}SeCnF`qF{&@d~DL+7I+c5(89p3Y1%Uvo+y^izK z{!hUE^yT<8s_^Y+M_E4@FuL)&5rpr(KO~^1gz@h-r!bw9=HH)|T%Tbd?&JN0K-4S4 z4B*C3A;N%`g8WU`}pfbq2BujbPK)-jwIbb zz6W;+GKqVh!(tWx`1&-Ayz4{R{Z7*TN7T&|)DnJi7rXdJ&c?c^+pn;TyRSzD4&DDp zmtVlbi#rZeoL_JJ^cE%w^9z|s#DNqwMD-&bbeUmV@pXTMz7ITopR z*ky4&Q@a(3($u?JH5k1K>67T6jHG9ot;SuBrS-^PaV*r~yxo|SG+5JQx|GZFTNX2* z6m)48xwN}-=T0?{*wty2s43diczJp`s4_}dF}u`@g~h_`WYT?>%aZx?=S)oo+ib!+ z0ro}p8gcO&xF-@xb`@s0@I-FEuf}`qXZ-_O`o$hQJlmo8LhP5!bY_kG2BKPN!#Xg_ zB;tRMu>)dO-PKj5E;{NiCg`%<3<6%I13{{Er|2%}->qC|sy+1>r^D(P&$Az#*a@fx zBXb>Km47&!mb;>#Lfm{DD}zl7 zL6@pl)`~Kh1r@1iO5_&G1m2Pv4mBkqgL_Qj8#~~|=7J$}x>FjfI7m|o=PChp%wOkY zn8sKf3M#=m8VO{P*vN@Sd$X3E<)ii`Pq3aZ8Ot!(D8jy@L ztFyex5$MUA55Y90jTDUB1F3zr|K6Megj&`$Gh=zukR<#)|ILnN6!^2F{S9jlc$;<& zLA&+9NQI_=@65h`W9x_nK@NPJ6ZWNwM_Jm$GNHXVyoI-E|?A zDN9(ArY9%|u6F*E7eAJAG80P5zzh4Eq*RwMDn3+oabZIFUYPsNgWaN;v*Cx42@P#o z^9Y=~Xps(yBEoM00@-q-_w~L9YzIqh7!zHyD%fiG68cMeO9Ij3nNBX+- zb9@U$1?+R|qtax=89HH%t0xz41LI~It39K>HL)AR_vT}u@c8VLHWcgc*R{3kpWhBy ze*)71Z)9zAmK4?cz|)U@9U$3t787ZvFR-J%6$0x$z)_FmkB}ygnuppsm4W+-kfCl( z7w|A4K;&~9f4!$Zva2|DIj;Vjt^F%>Huy9}fB*8g3%j5ArIX%uA>d}YvIZWcpuR!L zy;`^x!$mZBsl|GU$}ixLl*?S%K>DNMRyg$)@!bv}0~aQY6W83*Pu$YK zgUqQ!gsk8KZB%F~ABk84eclTI{XCy+cW{icz+UHBy6@M=h86fjAYc<9TRGnuWvWMvOlT@@3k#ZUFwh0>U9l2VICEiU$=k4 zZyof`GCSo!mWDmLsc<@l!5V?OL^VP=hlsia8Hu^D8>cHyUcM}q8Z@}71y#P{E)Vp7 zDUqk>j-e(}uDCZ_Crp)b3; z^)pB91>k+!v?B0ZDHdX1yhVS)CD5J$k6_YarDVJM6aD9&ct}0M&9qbP2Xg zs@elOC6tt7s#!(9rj*a7+SnrBK!75*QHd6;HIX)=Y8H3=4)&0 z`{({&i_iVO#?O7ej3}U~X9`bYn#@hzNVPpr+R&u$<5+cbr}Xl74l#uW|OfC6s|CE{A%hf zqw%6(&y`zr+cNtxH5d#=;cU<#c`h3MZ2un!(5X>lX31&yRfs(%}zUF z&&uUuc+s)2d{hakLssb!{AqE@fA9UC0|@$CDs74kzBM0q`6l#G%?Tu1pPEs_bw2}Q z87|lWPYoM^`*fO5s^d##s=+rJGAc$C12reAP2?GifNz2nMTe?QrLkWDvQ}1dGd9!F z>eU#f?2{t3Nfj=quqL53ip|i9?b}|>rPD*=B6%_<7q9Dn6{`y0vp7$a-T9rEV?r1 z38}X`8Cuhmp*e`pb%S!_vxe0CW-M9!AWEImTwOlCSO_@G7PhgE%Vw;lrzCYj$EAeA ztSDf}*4^gQ)wRQ#mCIrI@Hkmu7zQu=T znhMppZamCyNo`B7Mtwd>hgYBmf6IfTQ!pg4jWYIt*xGJvxp=<<}l{GT&+*uKjwOnML z9BpaY*;cTphgYShuh8WA7k7tN!n1G*c@lRO6ID&#dw7B-Hu*u8?5N?qg^O`qN=yqk z&W`%=Y6?RdH!Qvx(5t3-^F2+y{mhy8$x3(;Rb9m@s-KCqo-n?MfK!R#B*|qoAoiV> zVbnNm!zhm~GB{pxMot11?p+n94?B68WDtMdnU1+!@`F@IWYgwIz<${t6lMP_MgK3>N38z#l#>Y|nsbvB4M zd(Yl31&Q;JW|f|-<%!Bp?c(#DbaHO}0|a_taO#ARo{I6u0e4jS+i%LH+sJPh4K4HK zA(1erCm{(R^FiG&?KcaZ_+t!G>7jXiu)~HfhYfDl{KMnKAA8--Y$VXmk2_ECuPaqzXgDnk9{nyNMNUD{qM~R2b*N5Bwe&7 z0ktX2X)p4Odcunq;>Y7DW4G++$n6vPve+?3gIO=(5`Izu)B1BFs8D|WONU3h)^p<1 za^xrG=W0EVkAgh&><%{KAI89McDCAIFE4z}y3c|JHe%O%V7t*k#{$szxOyA-@r z3gLf-?!Eo`L;t#e@^L=&7Vy&GO^CKS7XXndQq;eRP0W~Vgu338F&E(VrYgw~Q{3BX ziS7IJ23=?Ck1&Oqu79$r{l`fhsYsYD=*N={dIphSnY4|ZBI#||4)^>SAU*6w~}bx@E?Wt z!@oa#OQV{Ecv7@NhYlw!HvnY=Z4>{!}2ATx0t7& ztWY_>F^jJV7OnOBQmvekjwx3LGQUX?U7Nk7jE5#yOOuB;BMwdWuQ_*mV|jj-Aq~B3 z6NI9l;NDW_sz8vQ@7lnK_&%BK_UDkR+kT$&HV6nn11vw0+o87^KEG{)!9M}_I{z_w zE&gV*kHlHoIYH0@A*T$mEc||mu+hJQ+o*XuvfjUA%$P^O9mbe@sKY(n<`iywh>&qv zO#y6byC#~(X*=yV8aVq<(*4q5&l_}IBpzCXB#AbuI>c*CJw(W8Ekk)nB#CQSSCmAz zl1)&-kc7$0h~P>jiWwrW2zv*%ArYeSxpA#8;4KRrL1p`M3RAWeIW#Oj7ha`2f z!%gB477yyAoM`tH931^A01r7(u{Ib8xia>yWu0`21|>&W$LZI*-ENp&sbXUqKx$QC z#Zk>J_}XlhpFHoL&R^2Qm3kH~T2VdX$g8*mnMO+RqM|;l&Zb2f4A3`=Dm5k4s4`Nq zVKSMw{Ha53_viwv4Y7~%#Kjm0YM5f~$qX~h_ig&vqxD>=CGc}uxu}DIQZ+QgxwH}? ziYR!5lIUPK?jfaaVM-Z3twbKRdQnCt3pz9(qyZa97EF94u5w>FBfvM}g{P5= z+zxSaC+tHU2PkED8%@Oc79GVppR`F8G)b-E0>oRmC6C*MpR$pbm#Qe1l^Z6bbZ&}( zJxS+r)r6qLLzDhpajifau9mW3K&BS!>=Eikka~y_ypZ3u8O{9mx)ni{E^$i|j#>DV+MyBn#8236p7Srk*(S7pXLpsYIu;*r6`JorHPgOX;^N(4YpbpkHFFOIFH z;k9$JD(5u$ji6j!6C&mGh@^8>*s-58vxp>Kz2Q~kovJbpWCiX|oL}$~u2p`(VulTo zz2l%&pcDvCWVwMtV}Ijoo@Y5dH5MVoqrb**j=n=hC9 z$^}*%c|3d18Cy5$W(^-hTZ>0qx~jivk_Fu0SH%p`!uQKjgO?3DL~dg%o4Hl7;XhKD=5bm*N9KyTpO%k=SK51l>i6k>t)(0afUNY<}ypeCAa? zS4ty~=kMIdov#!d%Kh~hE(x<1IfcQ#CUGJ!xFx8k;jYtIYWpfsJbqTcsj`skl9$o8{W>ti!kzYAqhScj=vEF|! z{=TgcgA~I&1aLJY)ufYH;ri*nVtoysfKL&DqF4h z0@`(bsW{N`)GkczDb&!jI-d~T%ze$Wow7e|Gp@oylPVz$%I!0tM-Y^nq8W{NC-CR< z)riGI<~bKE3g;|m9To0}j)08C#1?o)2*)#hL{CJGhW#RO{n5v259HD_AHjQna49h^ z1qN$>Vo`M3d|Fi`GJE1Qo|zTr?#6^U!9L%JwMLy#ooLsNGd$+pAh1bzG7%_iQms&VRrysHqFY(`#1|y*1?z0z%*AFkGis{=L)2S%Jor^=B7@)a z;kNK9Yu=PwFpXgu<_v-<7Ajmu@W58n8|U_EGdfu{i@^t}yAyr_Y{4~*h+OmUZJ*SA zC~)2Y%iA#D&UCESfuVl_r%?e#s9 zsCcqjKeQy-S|M!pDAP7J{-7vnFyDzk?E(?eyL42$SuZ$j)nn;W?_wVZ!ES7Kj`7pM z8ucAg@F0c-(q?hBY<38J!#q$+Ycm$Mg~lPL`=@CKM*Pc@#wm5Hc}zacI*b*_!SiqM z!SuEE*Z5Nf11hZB_Q|H!PCHx-$?LX|3AKk#vlK^I!w`(G{2?zVY1687AqOinyu9@AP^M=Bi(^CfEx8tISvu}Iu` zi8rIkdZp)jdh}fA&4p3bHPVr&vV@oSQoqP5!kcD;GsP1TsP)WI*o$dI7$qCu)kznJ zo=<|^g`=|)l!K&oqTbNGgl2dvXG_0V)22L(ydFccgrlK}(!kZxILvVU<|6ydu%o4S zj^R+SY>6bUq--QIP7y)>QCn3?X%Cp9H5(k|f>O#z`$!g$2s0$!Ww$Y3rqwCO4Z3e! zUPj>^LTZP>&UQ#b6$?Ux_7(M86s1a~v2F&t3DlY`+dP?LOS2*!J2E<0Xs+Dj5n?#W ziY6Tz{r&4gFENk`dkmuYNLATF`HOd6hp@P<0t+|v}lZ7c1uR+Pu zOIy3g)RWUChRlvQbyw1~G-+j)qu`uFbF!;ZH!(q0Rq2YA>WtC&llE$?ZF%$3AJPD- z?$9gq>E{~f1XpT|DY|8xW7BCN14#$pGu$FoMdD0g$4eK`TS`O(G2q3wBjF}!LzcS3 zOBKbczcRo0(o~t}m0$_;DkF}GR=PVB_vCJjYOvyJYy371nkS$qvk|j}HKym|QJVLn z+uUFDDau*1!o|0P`0Ms8V+XCVETHBf%%cx#uG>ylh_#HH#jMM&Tim7IOd-67Y8p&Y zZJioJs+kQZRVp*>wDc_&fg<@!#3Yt0!rd|JX0GdqgV*#~{&s>?KhWty_owzbrEde$qUG!;y& z#!gkzU7EZ;Hyc=_>*b~;xm+lSCU3Vc~W@oM~cNmNk>%HK<3P z?+UufRL1&Lr_RCHUGbyo!KGuCum;jz#gaMJVR=ZIx;V&{#rc(0H^fhP>Wa&%c1Gnd_MDW2Yr6)|AmhDn3(t?z(SIi5xszABo zBs+}lN#%)&KcCRp8EavxvE{&n9Tc{i8L^eIL3Z+Wpp{P}R30gFN>eBN@X~bLgjN?q zGmK4TQ7~N0OG@h;X_-YZRPQ!=!&=P@q!TJK6VmX&AQ2Y3BGE-R(EEgs(9N-jmd>S~ zZlvL=IfX<^lJ@1#=1lg?SwAM^05pZ?u8DCX%!)Oo^1S-6{K_?0f113S29h^KU{WLt z1DGdY#@}ax-N~D?DwjBB3dbZ0odq=ztBH*<;f+L;*U!(+%GTh92T1cyRcA?^^BXWh zh2yYnzv`W|x31`;CkD-K-94xdaJ+ihTTPF&T79?kBH50rA3`_>>15<12uY%MYyuxc zTSOvXyO#y*MM9x$qaQwGtCJ!?i2A?8k8CzPDDTHJx*BZ#e&!kyX2_QXl#DJ{a}JesQ}v51o)k?4Rh_?D>d)HXSkSuyW7?k|?)Cg#JiZaZmVs+*eg6nMrt zm)mIQO-KjnOVX0P1N=Wf&x?Re&3JX%rqUZ6Kh6O)-jPB6l=fgtx55vZDF% zl8q$EgQw{`9E#d18$07=knM`go$}k=och(x;~Ub;AZ^NZMB(;@xK0h_EL>+pO5@jj zLGMWvgec_BIdfoH;+&6*^$e}Wq1kee+|NSv=$Dlt1{-&!lKn*X{k9PiJr=KhMBmS& zzZ3hozUP0KHB6Q&7^W25a9k?AXMdb5#JB_vh8y0Ps|4s`7?e~VuW)*9$hB)K?zcdH z!k($T68Se}grY8WoKX2H&_LJ8L5P~{TWMPFUy%KkY^w_u;_-mNcc4^Hz-5_rX0Z^4 zwB5_x;Eg|K0gp~2s#KvSB&^hjX|-27;jOr>(@9y&m;Le4>cC%C;|waH z6!%lt>^@u74WRJ5SF+Xk3d^pKlR)_Og4!w`X{+hU1Za-xe+XA1Ov|YV#e0;?=>QwQ zv(qttyo*z<)4dBsaXMQ~@VyK7R`l7Yopr!~>xV8dlMOgZ&3U z=XP&1`R+>IOJT;oh60W5*j1 z`3-yS%a(Hual{x^0G!A9*i&AY{z~VysuB@xO^n=d3^5L?+Mhg6r`A~!mu+{%FN;gY zNlMDCs1n>yWdKG*&L0H*fiY?4K`?>(l|onKsG#7Fk*td6U$nm^oWq8Qjn&)$@iC}2 z2%jiA!Z<4F@1;dv5NO*`Qe2q)qf+yyC=!I$i(ZVXGr~Giz617*N?0rb0Tcxp(HE6a zi39jb$8CkfHMvvsFjqenVeL9#_(Ya%8@s3^1N%8ONzb`tP_-lsBkniR^20^FXyVGfSWX1|6hYv%= zakrUd{-kF1G)X1L5%uthWYRGW4bUAq>XB*OIX1R6kszNrWThmi>=eG&+pv5~r63hRVIjK9cOzc?pqh{3TDv z*fp0M#Ge{#hr}{aTruSDB}R+n;H``824VC@LbNOae8Zhhz9l7#NcwS4(G8MxLwIpG zwxte>S4Xvrf$RuxA{$PoFNrf_fuW)%IU6(SR%YQR>BO^ZFdXE)San&BMB7sKYkh#I zJ$k>6gd=&uVygBn5nF1>MQkPx3Mcr6QU@7?ilKhucZDeJU+^lHZy9=nxty9PDQ9p< zIvTDM)~`zhp4li2?PpQqug*gij~)K$sukfA5LXnbBty;Uzb z8OT2JK}h2GQ4_X5JY|SHnW-Mop6dVVkX?USa0EYJ9JZHPudV|AS^)R$Z*LjkkH0L@ zcEF0HNfEc3Ah(8FaKtb7PiD`30XF?Y_PkB zN%Gk0St7X;yp<5qyz_jSVr5lN5mWE}SF|&@Q&$^Do>T*hxx|nOF?5Ujqzj!W6%}tQ zY%uA98k#TJ<>yl6PXJ`*Jhx59@GEw;aRRZ`xAc`0S)PW-nrDYlFhP7S@Y6{LSh`+TQ68YNS&Cwhpl|9ma|*+~Xhc6K$KIq3?t~kR$v~d^1ea z_B!eKd&Y=gGMpsYyIr(Jz-??qfIAiy=y7tRlA3vh+eldlCkG{1XnP!t|( z`f+;VA;=Vb`vh~yz>lEB_bGSYF@Ye?g3;IciagBOvu_1??0^Jey=cds4OHN$XtP_q zTyeBOdI3qKY)`>U_5@XXH_9RGK+V~*Pz%gLUpz}me=iL8|0Y5C```&4SD{qoVU^a8 z>!p=R`jHQY6_#;?1R7T!LDWV{vM1NY?cm|rGw{`g4`Xjnq(b>}*f6u9)hvfIdbrmJI)geDcC>D9 z8j@TCD%cBtq(*~#qfbTSGm@g_ngJ)ev+_5G)g_~px~Q4s_ApR5H2$Tnc6ElGqC=R= zCa65)gk_y}z-1|bkQlN%SH-u6`FeA;GYwRC4({-64Fpdr)cx(ZtzXEG;SID1bMZF? z$V?0F={HURaAEX%`gw~zD{{6;cJSb5a~stG^<&}2IoBB6!YY|^+_`tV`a>5sVYT4G zhB?>5vlcN{g{ZajHJ*QlF6nMx@#idiW`eY5mCx`9<=9&Ju>7)QGtM#4D&RYNz9DuE zArZ+t_dwrmhgJYlU@DD2^?kmn%rWkYx=V+)738ah)j4~!yE9*gzi#oisr!4=SQ~yN z=(*zOk!e`yr}~FS>uJ+iL0NaBRUTH5)A(`-t)P|XPQG``_-ujlcMiNRLU>3_oBzSc zd+A=eQi@1G9@vb++KG8M6R8bOjbDW4kZ69;)@ZE*9 z65hoMcGiV>32QF!)~;!J5R2C=3EX=7u%mO#n0wuJV{I-Q&B$y72NE?z*NOo(fq}hl z<)~twG+)>FkgTmW+W<-%+Ns=Fhv%>Zsi05tC(B&u@X|gd=O({)+mcLf?PYK)pl1>S zlA-qZ^d)b?ptIJRC%M>y>BV2Q3N>E{Fee^Z@^H+tQY?$n9+@ z$EvS)I|s*N{jjo5L?hBzEGKufmAvx$#!`6|Hh~A>P!_~!+}!8OFMCOL>pFx?Nw`ZN zfuhW)9ngM&ber+j0#<~eK?@f6SL7SPDkZB_8&NH9-Ik5yGh|mt!vtc@t4-JjixFag zAKU`kyaA$-!G2VXD|DXF88`AeNOcscYnHEjp@kk4BxaDlq;X#z-)^(Jr~Ph5T)50g zh9IGn?1OV}To(;z489;ll6@O&KWvEA@*WQiA5{+nF$lsOBJt;Kp;}nugLPBw8Dcly zn)7NnWd&Bm?Hju-Z<0n^+Z6+g)rnv0E8aL~&8b2g>6LoiWj3ZmtD5+h+e#hmpi-do zDbg6#_On}LGv{#bQI0QSR&re5IT}QnlKya2os^vqE=65DASj2)vJLr)!HC=aVtVzx z*A7EPXM(%p9#Wva&S61*10rHtfddgPba!r#1Zg`flahGNVFBOP1^{|BoY2f<@8DqS z5{p~0Mo5%r=z-(k(zG))V#vp6vipN=2ebt(#E$-91~ft9uO(n!H-DBE>`5`q%s`_J zP?cxxJaPa-R`%Mw+HJ$38M@Tqd|@qGfyiZDBsM!GAKMW()jGO@5KY!h6EnX6>(54n z2r_%cFXr0F+`>6$`1F-eAV|W{DuNG{Sl>lua8W+&tpdWr16FjCyXJYx7ECF zwv}2CoS8s>+7`9F9QZh2ZAtMoM>ad*jQXr4O|zkT-nELbu#;k8U8FOv^@NLkU{U9@ z8f(FR`J12zs%_l9cRP3(%hVo0XI}WPqV>-#P&kDF>z37(5v(VR+TWY4#teOh^Mkwo z79g`VWKXWwwFQJN(+hy}u3?165}U8=1x#GvdIlVWH~F*N>~zaBz5EfD5#NIk9EA98 z&|7a_TZRQiuD>2UkOQ+&b9^_8Lomx$w5h!*<1AK~25NB}7qMCNjLTyNec+#mHd@B8XJ-a` z@~i=|+n81ksO_y1YSL@zvUM#+Kgull3rZ{`?XhY#3pYtC;SQH(&i-1opg3ZkpV7kQ zWY~v-eT?BP{g^xJPv5K!f`eIuW^l(i=FEQ1=H&8&uj&?v^mg7WS}e~W>v`JPB8lu} zNY78Vsg#$%r&NH}ZF}z-3wPIdfBB~A#NEn(Sl?d-$jQ#;X{p-2yUERRbIs7F!DjNf$|1J8YQwfci}Xw5}l1~6NX2>*7>TugI(}fJX@H+#>KEkxdw@Ja~YvK z3PB;}z7V{%YW<$&D|J=+GlKj#N=Q41Sz-p}M!m`b7X~4HeiKW2DDXk2BcDSV>soWe>NfMf$+C{{19riVN%QOXD!(xV|8DnH(DE-ExK(@U*5C782&=sT z7FT>Zu$H2D?|`!RuZHx`YXML7?;b01%Xc`dR5e6h8N`>>z)nF}uUI`P!}n-R7phwrGz}tZ6Myi-(Rkd5$|~zXmA_BsnT+3l+^3 z35cxLD{MG+mv0fyn|Nl`L3m^(d!NmlBRf_QM*8a6o_(|PCti6hgZTpYh=FZX-q-BY zUZgE&jfRj~&$X*I<_2EbvuHDNdQbJE^tDBV**vXf)~z0Q6UT9_w51zKf;5#?P+wjpM- zE4-t)s}q)3uypQ527?q=GYr^C7jlRU+pIXM{)U`DHKPwCT5ks`E-opmoUu{6Z*uzR z#&C)(;Py&$z2%cg0e`b}C6MM)eQW9$*XWB^H8u6Rk8?^q3QXzVj>75j5i8LlB zs|z$TN(afn=jjM9F>0g)sT;GmAOO@Q2}V3(s4_DMV^>4)+L^=Y$6s)&rEKGZ?EN1At3Xu0Tz*pBb}LiQC`z*Wb2VF><&3;K zNCBpy*KTT32d!-z+v;F0KycV`0Os_xQP_}*+?gX>+_3R6jU57H1ym85^r06pPfDWD zWZiJ^n+^fv-R-!=oCzpJNbdYho0f%IaFmcWct zN~c14OQ)Dd3W-(7;_`M=Phg{!u`v=W)g{F3bocl@Eb?!U-)(dgwqwC9=pI~k{Qps3 zt$SETZU2A%wzf8F{I|A+_%D0qYF_GCx>Sk~FYz$o3M3AS1ig*{P`vn!_y-n;BUfrg=!)-4|!4@H-Ol#g$dPz4`Z4x@}2~w#&Dw24h`n&a55F{?U9zcT;cV}@K7QW8%p)Y zhLZ7EG}RN0^{!dE)J+2;S5&!_O=Cb(8dAPeB(X?IOjVcP?RE=|=U`n@HL%iBw`-Pg zG0-yy+#e5zUBz;VG@JY#E6FnX)us1TU${Rq6iz`clHs^(40xD_gp8F-9%(Em=d*5U zlcP}#bqz_(QCKlaW7XOhp?O^-3I3A0=LLfdAgL)PLeNbsX^rVOE&3@w?a*6HMr$e> z=@|+Qh8gWUg$|+LzAKe;Xx4+A6;gk{sFRWRgoQlyY8Lph|cjJ@XAu1BdHO{+4Etk+3;1c?5eVF4H(#*2>qWH!*Oz zw6s#n!yAe$l!P!KIU`0k{@}CDG$6S($T>(($Vi+eRwD^hO~M3-QF+o5i!P0A!V)kz zOSzPn3kZw^K-a-jTBQ-I5|v_6DV6(SRAC@0_6-QE5b5&}4i^ufl1hYu<&VUp@X!~D zhkKLoBQfj&DtASP*Ty1!ZYaegEyj{r0AN~K!pJ05E@aWetX6d%6a{NbOUzE8tLg-i zC414OZMPKk1+d<%hkWMlNdV9RIh~bDs)--WrgsSM##Rl4Lw(_RD!e`w8S0No6Y4|` zOU1w5qIwpsQMHisBvmFep`~(>K4wg$P?;R1+##SP29UJUHXwr{NG(+rkS$u`u{E+> z#2$mhY;LPbUAx)+*yFJwc%xwq`@eB9)`17&uG;exw4v9H_}j4 z84nZT>ED8kpgZ=2l;$6u;@HKCA%(F}h)~zs!*{h@9)|Yzq1ZHM>>~h%dP1&CO_+B< z0t*i$9RSiLNwcC`@@b;E&#q@C)A_uTA*oqIGZ@vbu%s-JFIZiwz#!r4iqII80jqQd zO0@*jao}zB#xsbp zgijPbS+4DtRMsU3>-uq-G8YjAG`Y4iAu_Fz7L2kykV8@_r}I72Wm)xT%N^Q#(4U)aHm-$M!W2z_`xn4z7K6p=kh3k+SOY7XqOv> zV+_z{Ut|8YTFxZ$^*lQ6uby8|V+ZAwid>pb@GLeUgamf^S@^g?xjdm%sRaGz?lKR3 z%8S;fOF1IC&ldw|B*Q>b&l*Zkg4o);bbV7l6RIHWZEY!QZ~{`cA{Ap;)Rf zlniz1Lm4@mA#Y-&zdzC&2@fSxJ@7Le$HaTe^BAw^7^CA}<8-sdhJo<`fbDbRbWMb> zo0*l!(~zkdKf?+(UCEa_XT#NO8);&0jiV(wy@j$*y9tlh95O{yC3#%eux;E-!ZkK- z*B5F|k8vp}?eLKAC>y7^VC)gsGdu+m4d4?I8Tm_?hiOIO1DAIAH)vr>rBq?jWOHZitGcoy@$fno| zpQaTUmza<(BvX@wE77C|CMG7P{hreL-DBljhW3*gB&Fk0pHjqR_&t^8vjRNwc_FgitEGQ_hLcI#b0bn#3rxv-~sxmtg6D zWZ&4Q+G`gwc&Q*Mu3N~6XkkEGnj)0r}b$n7o=cZ^P?(ji#$z)H^~*3$74mgutuH^Z*$={5RiLA(bQn5 zcL1hEkBtV+gF9cCG7f8C;BWxUEp>M@o}3uz?F}aql+QQPN?<93cGsf*5DJ1Uo~nvA zZ6YZXv4=L0XjN>Akyc55sgpFb5lZRB@TSlhEWvGHT<}Ne2p%GKB3;PlMSAzHr+OMS;?w3vEq(vJCL+ex6;>}bkr^yLjHKc^4m8>Sxqe?!? zR%58qgQ*q18B~pghgY)L0ku`V1$j!)^|D>cYFS7*O9@yewU7w_>p&EW9;0&CqfZNL zt%4;2<}uqv^aQJsX8K^Ow%^g)}&wQ8lSYY6@`hstDeh3Pr>5q?oIy6#3H0aYAma zfPoz&L%q?FJ{Y!G8#*{FgU&^Xk@p>mIZZEBRFP@Hph#Eab^u*`m^OPbGMN*;6|%W8 zM{{$df&URU=Ug#Sp3JXYF{)&zS7HNfQ<-&WAUae{>Ri!GfURgIkQq!}FTzp*(aPf$ zIVYvhtmNR4h=(8o(Pk2*NF$42Y$=-y5;TZ$R9uQ#H;Wo~NQfH(uzn^s>dC-{u}rk< zY{1%t^K)U&wc$7+VxrhwT7*wztl|$;xSI1oiv~k$!qM2!YM0;RBXVrHRLB&kT{H`d z|5~O#SizX$$}WSvI~w>dWVm^jy+F zXs9n5mL>*Ce0h(gQJm?b+)JwDK^#b{N+AW3YzkwPRnNlIJNaTkpH7AIz5hF#{r^3U09Y^nr!Q!Z|J&|wU5Nj? zS1!)LQ`$U|8gOv7`dU|R;d<4t>f>LC$-IYU)EWP6twD4A-}ZpNePR6XjjL%MFGo|8 zg!8V1^Eq9ldGTGOEXmvCOa-+AwQrj$zm*y2W^9v1{mSDOl#Ar`i zg{3YqaIXV3a(QCof?GKf2=gguy9<_-^b1oLQ5{pGw(aZ$lt{5PPO|DFq8Lp8(nk>% zVyGkCj#`LDzWC$ML{9?`7$6pZmoSPf6pX!wA`vWrhBw3`s|S);O0QC!F6G82%95+s zjor}Fgt6wOHG~aGuvR>S=(|YHzA#IQm}bo&LPBc`RGAWz9oFpY#EPHc+_EOnpXgK{riXv!c|5nd{FfqCC5>Zdm z1C3?UhV&$*fInjsO$jOG7`jVuy#ezcQ|}2SaAGr)8z&MI7FPvaQC~Lhlu7H4hJV)K})TrGHI`Mz9{Hw4T**KdSau-){x%# z3A6A_q(EF?qV~rppq4OH%*++<2K*NEu_k;c0}HS&0A1N_Xff{twh%4k@@)6lm}{9- zz>RNHi+ELD?ewx6RVNybA%iD)Pp?z1M; zcXcrNDI?+dhEyUMj|{Cgq!qVxh$Iq*q={r|Fq|BS8NnJibu^hq8*6kQN88mk47c>8 ztdF=c4wj&CBYxbh_tqE@LC0Kf2_`PRbki;o2ZRy^Dyb8bw~27* z#7z?_WjnoCI+wOa6{QU5Oc$BZs6Bfmrk(_FL>a57*f6=U)#Y3h9*%}__c)Stl6G(0 zD7@Od+3moA%OTNWD(NqPA(Dw#GIMR6mOF$2gSG!IQo#08px)B;HhL^5Z7Om%7xneiMfE}RYr z{ozH7V?F=%H7NDh|0Q{R56h^h|MLf1Ec(CpwuSZo-nio7)#1KKvc=)pXx+fvq*?nj zWB*pKZ?nT}%HK^?_#>fIUnIV1leW}${_7L}!eu-DCzWiVc^=EaG2Y(VT3!F|GoSx! zY4f!~3;REN=Q@F^NO^A){ir{v zDM$k?L_ylt>2I@9kUEmx5)zBU!T07DxnSkcA6X5u&mep(rxqn~E^rJ+yCwd!m;TH+ z1_#)$2}cs`B>GtfSYwPi=reyBjP;>SA}KC~5|*ksP6!RdG!+iurd79;F5;3efFHlV-G}8Im;C zbFz?B5tAxfQd08(tASROp$0SsEm$kTP%uqF%hLcG%5yk+`=g=NiDifen8b(N@HaBl zo4~((#t!$BN31*j-4t2m;&_F`#uuUCIC%+z?Pw*J&$65V$=!*+2i%MRI83Y`{uX)) z7ed?cw1EUdMl7)&${mizHVl&0W+=Wooa}b`ecqt63t{yVh@>6(3%4g@L?H|nQ-tD8 zgOzD+QBe5DttkK+xrVLiyK(Ypkb7*wdDG;STR;mEhsZ$>-4(P5ZrI{oU zgeqsHCRnJdXK&iLNnB2D+PrBqdAG|KWdY;OB%xilbO7nE&zd-CZ(n^X(`alQg0srQOUpg zw8miuX@|`QLm~yQT3C=+ud4E&H!By_`6;8W{f|ZdZ*2`M?EmkTt7`ufHZVVB%zgdW z+S=k@SpV&ft9JjR3V+WHfa;C^_JGCyFW_5P|Lv7)zV{-iw;)C~bTx^K$<}6npxM_Z z`P(`J9i1($QdyaNmF#RLiAk-Ks3DP(z2sbx!=Wkr(b!&cmE<$snjJB2j_tOgirG#j zM8sSvAkmsswOA4DQf%{ZV-=IFN0I-0L&eoRBV8^S-0_e_QT1B%P z7%=n)e_Mn%eBX|(NS!uZgFBd+|Lxl9`}Vws!k&F-1UJv=E_}M^O;>QgobJ6_cJuX3 zY|7j?cY}PmEzK;P@FO0(U?ysLxiDUyaMJy00V*qVw_uXdSx%+1*%D7eo6W!spgC?g#}rFFp{Qj&$#5*rlAtP0e?O8S zsE7A>SdP3mS#Q86YOVnv>3qs9Ix$lzH)o_ki7>+oKm^+if@LjNhvECC9i+yJEaydTj|j#4<6o`S59Ip&xrP%+;T`W=@f*WS_UwJLDU#&4zqpP zEZAys%NIsRgi7FVO&d1dNKmVpX1>XIwF_{kLJ7qb^+=Q&g?en!1|uVx-hq*!HQ_#b z3eHK+wL-qw8fxijX}o53h!wyBCeVL@wFI|xPPgRK>tteeHZ`KnV)k9SLFp{>X@;V^ zBe%`hRZsq7)|PuD0M?QJ{H^BmUjZNfS&;ws!ZoifNtge0veDhewm17)n*FVke|cxH zz0u5lb7sL@S_e6) zjuTVAyu4M;n;>h3c?_f_Er)D(0D-*nNW|l*2`&g12$!3GrxcKd#YzjgcnP(RNi;Gf zSiw1?=$nQfCFY6sY7midFt!$^kz{xf1b|RH65SvaYBhBCdc7tfC7Otq$3DNt{Cuug zRsOGS*6n#2wfTRG-ybmRf7=4Bfd&4*H!kY`TT?$-9Di$MK=^p8nU62;^!p8bd}*`j z(|cNNMy^CWcnc1<(S>)`=!2Wc?y&wT%O&FnObaZoB-^~^Vz}{Bx>#aX;;Ky^;A?e# zgzNsm?Hq?2iej7J@D>}2C#j+63h*lCPDgj)3)j*zS$OE4b;wmt0mtid?2yQEu*>8i zioBGHrJRD!6lImUhr*28o${nyLia|J6dFd~jN!p>eDw|w`?}p!Vp-hio5=ImZz9#i?ezw-Vt2E7liaaroyOsEu%yb_RHc;L>rFHi zzMBmdVa%eruSF~OpmDQllcspz`)o!ld3X5?2T;G2sKnpv4J3u`X4^3DEchq&8@Tt` zCo6Y%xhKtT*FMS6K7&kQ-$-e0jg;&gNxhvQ43dtEpW-&0CXq>2e3;Mk?k-|P81=Ek zH@RL5%oxkIMT(YWH<7{fR~ZIGRMu(64^URMl zZV_pXL8tH@sYG^wn*7`wel(>oUw9yb3Fs9q9D!0P7b`S$jM+Cc>!qF?4LX8LII>PK z?MTgAS9R*UT0^l^Ppof)v+72dq?7! zc55|NwT?U8xT*Ji0>rjM$kNROhAhp9f6Qv-*=!{4 zeyIjvvoD+X-aM7gz-i?>43QorL&z$TL7OPvx<$GtoY_K&=3V^Vxg22tN!0Uc1^A2t z_1H>G0gwzQ)7dmSi&o*SRGCamTjjI7j+g|smd4U&$>>M8l$PYJIn@5<)UvW_ekx@% zquA~@SDjo;y>6G+JpSBO<{D$4n)jmjkcY8)D$Gj@7J}|fOad7j{J?^d`d}=CV+lJ( zWZfv=JvM|4h@Q{cXjbPf^KWL86{&Du9xHQ3r4-Bfp0Ox%Mn1=JpGgHCYeK0MxR-Do z4u&UUGJDcVFeDPv9O6B+5AT3DdgtR$lc4D5Lx zrG{*4<_ZU|Akt4w-Hd_^ zg^1H5M>+EoP0|q}TegfvtbqTaT{#@G@J|6oqpGG$)2m2p5DO$ZpG2r1F)F8$_j8#O zj7v7XL+5wV#)KitOl;*=t>9U)Op<7bJiD#3xdv=j3^SX<^Uhh#nGllso-I%7NMm*d z&U&V>&pg|y!lJHL_i%bJFTKBr&HEV8uxWnD>;5cp z2ZnFGRGVSAZRZ|~xSGuapFWI2E{iM2vfz$Fx>QO}b7g!P0Ax!lz9bB|M1z&4Ecrw zK@Z*K!Y1pb6tEcJmt{o(@vAT`hHa$&9bGxdc07IIt_uW1F6)T|#u}urcToP!hZe^cp9#pEN9i7M zke0?_m=rj%>v%RIX;zpyUTmjvrqz<*`XjB%WDO!D*X)EiN@s-tF^Cdx_YTMGW|V|n zMxH?z;PbOtXwPVts5DepXs8d$0lS*Bzf8dw12uaY5wTy#VVf*mj0pPJYiFqAa$2LK10 zF*3zaa%j~=XlGB?bVfoG!CJS))!pBI#Jp9+Dr^p(3?yOd=C?T_SS!i#(}=shUtH8- z)L4__ve9(nY<^ow0TaWXs(ojwz;3Q0ZP3Cra0b{Vva4E@y&E$xLlG%bdrVz$)CAXMBsfH{} zOwdJY(_JGKj!9A*+W}lk<;qH07`gZTsFXt-f=w8ONJak@FokAI(P=w6rGEdb7O{-HpPNEH&0h zX&&0yLsn!(>?K%aP}J}afzon(u|yUlID=`&O0*Ls{IH02E`%Qf(GPp@a~?o zJWh!?H_A?FVT5<{DHD43$^Iw{3kokBxL~QZEaG_%mYN@25RmGHNvfSK zU`eSly(yt2TIsWdqA|LV++yp_lN(YQlk2H8BWYt=qX9NcizbFPAT?WN-gaufYfdQ| z2D6lAyI7&eEGDxo3%B~TL9Av_%92v!MO(x&yGEAKYVk!fRk7RSnXCpwn5&u{lGtK% zK|+gdvS@qh)*jOL>{(j7y=kYX`kuE?D@yN%GEBRdn^FC)RGzwKD=f1ucVEb+ZD(nu9IBH4?O0 z)C-x6OI1TA(*oFt>Mk+3-?ANL*YK##QY;qOgu02g!;JGLPI9=M?xuU$V*(D4TYj9<`s$>7JH=XAB{zu{ZX)5 z+kfO)L(uq0G$|A(T&9l(lJYTn683b-b_2*Sl1>p%1*n#=bt0n) zk8a2y;M2;q>ICy)=sw|YxGc--&o`6MTVAT{v`rWxa01@LSA;nmGL0ml=xN@nBvw6o*fc4n>De?bE#=WT3PfJIGr=@-YL&)t$68PU zo^qqu7yQH*yI=vpb$u$UZI;(guW)ZkM)asP`-ASWunin)zNA`KLQ69QR7%4N-6gE$}8_MS^RjTp?EmVmJ%FX~b(qHOXBA(=?Up z*M0@e=!UlXE%;W^&fSg=2qheO1=&l_L+oDBfq5u;hj?^a zz=(dnf>R-WwbCYHz_5c%2XqnSoNPU2RApS_6qzgM5DaG^1_oAj-0KCJ36g5-;JaFs zGn^Ln`i;pns|Nx=n^7&`mMudSG3M6NvsW@77>=Wb~^#~m079>|y86)voS|TWoMXR2Y z)_RX*#6@ni)wIXoW#cr)PJU*>FI^u@!LnMW=eA{ZO9A|lhN-AQm%7Nk`!vZ#6iSfH zFpw@h7~KQULV(=9q-mw$D>~lMmMZ$R!U=iSq)YHBG{{6yMv6kH5#nAUpVf|~a%ZXB zsD~gFK=07jV!Ed(VcMbeLad|IN)fl|ppv80oI{B2Iv5I-Nf;qnLV18dKs?_Mvt1;G zhDk))R5G+C>~{g3I6=l4gocv9UB+(2H)P`l{=$e1(O*uTSqX&UbTqm>+Dgl|lmTwf zzzQ<*vATt6EP#~MNSy1^?I1?F!xeSHXz9qD*pjV_(s%`?(s4E}TZ98}`TO6e)+g&f^I3J?doWO$UuH~Nu)N?HYIN|F#;x;h%` z2}Ki;p}z2XnkTgy!}ma*)8Wq&qIWSGE!C_JLMT@4I|7VQ)s9+xE2^Zk8na@97WcVI z6iJrBJ(zjhu=C*0?x~aHJw`_QntkENeWkjPl;Xph>;qo>1=^(rGM@ ztzR-=@|s%^YN3S{9m}yjK32LLHx+%tW+DNgbs+BWBm3Y5k;B@ID{1wlemPKE2EenD zvV|lwQa<7Wt0mTmN{-yovfsl?(TIu^PQD9YOr`5AkZ)De5^ZE3#IiWsTF0N@>849m z7A=hm@+Iv(sya^L^4ub=(kFX)*=`cDIpAWNd4$;ve-gcfSv67x@~oydN-xKo#1S;O zBn@y2f)%%Dz)S)Xph8f-T-fSz3c<>qloVY;!tQSBcR_q5rP=_k?zCgs za$i?8V#h=UcNMc$PWU`JM52=z19q9GfZ_` z-3jv!9tYQyo?5eM%r?;%nY|mM5;Og-J`7WtyrRmsrri2GS%W)iHgSS&Kg$0UDwVEu zYjyTo6m{I9&lADUpOh=g!w3~fDof{#x*Gy~@1n|_Yh2;YW{HtNy3ME~XHDh$4T5!GI3dlx{7F>C?KT0mgsQf{<@3qcy~ z29NnK=7DZ_1RNw*j(P)^|MzF|8UZthcLwaS%^x=GZCSrAZ<@%OcUo#fQMRZi(k4xu z^BxJH1cB)SnJ%1p1jAUm5it;ptw}{giKH#J(Bu#fQyhhcL0Jc~wtS)r2UV6k4elAV zJ@8JxQ_02~eIh!C*=`S0OI&EgP+utC7x3}qiR4IsKP=mAHX1x+DN=pQL)5P$ime)R z0)g(@%m#pYlha%Q!-inh(uKTw(Y3Qu^^Auty-;nVZzr$>Mw0Zv+=Pi?G>)S0GE^Dz z6g030(k*J0y8c`2mg?I7>;?P3pgI00+W)jK*#GQ}iwWU_p~w&ox~$o>^o9FFBhh3^ z|71u-#P1quoy`@s)J#HdHUs8Lax+jNt?>`@kLsP=vd3lA8~-hSOZ>++--7+$Ub#+i zoIt%-!T%_TH5X(#OZP}nQ4<;t^$vss(r5*QBT1cxnR3!`g2Mp=4;SpHv!TO{%g-r# zcx1AeE;qG${lpNC%p-Xik&Cvoe4X81HLt)Lagi%AkcvizKmuOm>W$+0goImaD&Zkd zcmu%XZE^9|i7*kQqc4(3_C~{@p;R&yUmZ>+XeAjjgV2i1C<`wo zy=spCT2@hY{F8NKz>A{So|aKB{w2c2?%fk5I8`lX$iN%H%%EKYH)H5pZaCPf- zAhYOK@_8PFD&efwW!%86B3mG{7wGObycN3dmhG#G(7j}y-e zY23!f{Z`E6kY&1!LS;3eP z(~1)V&>oo={C*a8JlGuYN&fcEpuaQdGlU(V*Je1#s#PLBM!HFDb0yiSri(c*sTc7} z!VUbn}=_w@-J(-#Vbd{Pac z=;p&H)g;10Rw2^@trdKrukjT(;E`y0@3>rcZEyL zo|k5VqPA)o@pf>0P>le`m9hn`MzEb!Z%)5@advY%9Jw(xuOMfxVG?ygLb6BZqmRTlm@P*1@ENU(e*x(Quy@UuUH(jAcIk$8w_0$g)?<>qy!25BsBY|X#-d@1mM zazLy3RVV|Qe0yta)%8DICjK7`w6!)!t*=5|EZ2WI|F`siR>{ma4a~j&TYSO5LjUiL z%eMb3^UDTyqyJml{0sfRH?C^^pDSeLZC>=TyXR%pmjC^}mVib7+tRuq|L>J+#qoWy z-sFbiutfYR50CUjBfXNdskwPwu(!FnFWD!pA4m>HK@9gv2@s1i<>uz_kP`(ta!9+g zxp``8$~zVGDy8w}WW0GB0`g-{_7fxaK{ju;oOP~rtiX5pM^0x~5^-=vIakihE8|Fh zozftNAw#Vat__G8in^kirl6_wxxyCIhjcsD@^oHSCuF(olqO2@ShrXqO4!Aca)u0L zW8HwVy%|+?62YD&?}>=tT_O34?eFMd`1ha@k6zj4#da&=5p% zvKFUj(K-auxFR<>E~WEOO@d5`0Fl&ErrSwR-xmwxw7Jdcl`EQ|OuM3q|FxAXMswpU zS3uV(g>l+9E1KEUie~byTK=p|mvrd(ZKZ8@l8p3^wBmSJ^@-S!nwmu1q1bOkTOqwQ zH=d^8fsXvVcJK>oQ^^xd&fu{10d$F9!tPEfYWrL8%6%DFPeeo=%$ z@|yXmL637~g8ZFbo~$xeKwBN>%0BjMcKIeSXl-fQxpIL1m|d<6#uzC>6?^HAS>{6e zMMCYRKO|G*Rx~rLvlj+9lj%YwohN{R9LNJ^uHF$sh7)pyG9?Sr+Y#ZZM$JV4WaA3G zRIcn{zh;>+hyJee`7|$Cf0`u#cp;bMLI%cCoc|;ZmuxPA3A+!B<=Gc8nI^U^nkzEI zFR_}_-sp9mGjKJZ-YSc*6Zm3&Kodm)87J`92nbM0@;2LHWEN;=n-WmpF#A=5RBda@ z*lfO%9s|ZIdkb>8nQ>Z`2}#bC!}NuvLv1^OE(A}JV#m$*~Uk^LJE6&_?jMX!fdaG%$4??|hpX{}yAhcDuiPfVDU zPfi?<4q6SZ41H$dTkNnn@cKw87<5>flG0n#xja!S;*OS{Q=iMS!dzxoAw4Cg&}Tkl z=VsCc+(zVy={BOOR7x3{xc;YI2-BEjE`t|$-~bnZu6|5H8dgk0S}8InO)C}R1HYm| z+F62yx1+fNF(hs#aC_Jjg7!Gl(mI$+anH1fhw#`LF^*hiOwt=m$Zu4pp>Db7O(X#a zudPICYJ*X&*RW7cCZPDt=A}$Nt*SyQDp_XBnv}HG*xBr@v~gAQs%G4l-3%kT%(G=z zhO+4*(l(5XDW$Z99>dfrFq^Gag3nNb-`6~tF4+~*PY!SvE2DX|GN#!*q&!tD(8mgd zfAeOvXaWzSMH70AWHtqZ2lz#9yg&_K;>xI8f`&!pQbkSYbCYUjf<}N#DwB)TY23-^ zQl-_EoSIgZd>RK|FI(k}#8a9q1T`FdaOyO1Ivzc1Y}`YW5W{vy?1G z4^WEa*ehlyy8}vzg0K)ZR&Ojl3Tw1Q1=g?!ADQ(po;dG1Ub5zO1WeAXpHQR2+-^h9L1W83`inrJ+ zIU=z7Wa2YjhSK9OIqt2>w$SlHg_OoKHjfuMD_uPtrE6Oa$7syPqLVV^NLC@n-z*e~ zZ3(l|KsdI@a*=w^LM)bWF-MRt<;m(R3o=tKPn$IgOXVqD^+0_37IUSXrUzkdp?>eu zWe3--5fUjYBrFPT6Osk`C1kyiozHrlU<|`zO#o@K;GgOi$Vzo3Bn}=kBP8k$Ru+08 z#Nx6-DIQeH7RYOML;-yi!gq;ImZ%(|=eW6F+H?`nRV)#=uNpce8uAi)d{Sn9{Rq&K z#KapUMnoVGPDNAW81cj;Hm0`D3F;>jl#wfdYN(?e)zwk9S|mm_S-Avl&QirG>z}MP zTs5Um2}RrD%3iI_i?R7#FOgHoOF2+k%vl1fG@ zA{+yDP$bpJ0@bSu zDG@t|M~xjLCwH)Ez|6CRnW>!yvP_Snw=pxNGp+*tP}Dn@eS$S{K9Ag;IY2-Sy#rtI zR+X?8BytdNcM|KE#7r`^R;M3Fav&@vV*SZ=p?Fw|B&6YZY;B}3+$T9h33zsTq;-+x zKx`x_L5g^2D7it3^-H0l4bqy(P@hK%uOE)17yMY<5g8ngM#Aupx)_QKt(JNqANm%L zMg}8E0GfPhPc!uSfy3&H=r z$w+Jn+tC{vLT7nN4>U8L)UvLNB*Gpk6pthjBmME%pvQsugd8yf1o91qDHO!DWatt| zg3lv~um(`-3x}cr3;Jis(0{X0an41SA zhHC=r8elHi{moV%x1dK{&?ElG+Wi@aJ{Djc{tNbhv$Ox>@Wm$0a#W(t8q9ms907PT zxlBTbVCV((@IhSY&~wGiN{u$2Ia8)pF!rm?k+BG!E1T>P4Mv9qIe=Q$G@|Zx zDGP;R+%V#pC|4#3&!-FH6|5pB2;veDWHPzLv_l9CQ=-1D#15eI5=r2(QQ5&}0CY-O zLR%mx(!p1EtdgkFE#-)QS3*NUKtnG#Or)+-P@SS_e~6irMwN~gXwC&Jdy9-|S2UAH zN3kRqDOwfoNuFs@^|r985f}W)30f8dM}4huV7d<$oaHG{wUVP2KOH;IVligMI%Zjp%#6P2r= zKzNo*1z6~6o>x5%*4C1w6pit;F}v3hD-d0#QbHY)0G>xv5qi+$pbUWNI;lF5D?2f* z-m{v<(_v%BW)uM^2NJ~qjbf7%+%Yt2YSHL(nxaE=fm6&;^rwZ`SWIJVtEb1a?zmi` zL$n#lUR;cyP|S`s6=7;XGtdko7r43u|I$4IU6IC(PN@+aZo=>|8~3K` zSh>}=s}PVx`oTzw#ca&rmrc+e!=Gc}E&0qva%^lec zm{W-_RGCg!jDu_8?Ah$46!yBYQVvSt16pB^-+^ATMj1C5yhg);7D@xVMPpbimC z-D0R1Q-zFDkHlg-=oYRRM253Yx?NcSuD~V@L#P=y-GIr1K%{aagckB>5x{UrWImWI zrY2;9SX%$A%o~@bt;qm3ac=HrVZscKd?Gs1tbj$HRpSaOaXPP|M8_1}ULcO( zkWcDJ(-}OYeyptC6gr^!c-DrqM=Ip^_s01E$K_ac#To6k!D2{ zU5P)G?-#8kN@!PEMoF@h?93#J@@0~;#$-#DjD4Mjgrq1!vP_bY?Ae*IWZ(DQ*mq{e zVD@=`e*eMyd7gXUd+#~-IVa(oiS5lN@%n_bc7dh@DEHa>{F54~B_DHpe?BXH_8+*v zGsQTFTdDZIvksremAy;!z0^Bf5w1fX#v_QZq3{P5mWxz@hgcOxV}sGBtb^h^Hz&&m zURj`AstBJY+J~i2YsP==6{I)HDhUiYOX~DogLk#J+*T@Tpw;{_ldpdOD_Op&8S@}1 ztVwu}ig(&wS6lwOcrzjI#YY`8{%6@y z6OWI+z7dJf9i-GG$aa+9&nQ$qe=WWv@LJs)&N00TzMzw)mFYqjvctjUk1b`j{(f*x z9I*fE(0D^!(&}%!=)KxZ+e^lWeBF`3g^Mq5*nh$LIfTWQizQ*;(r|@fUqC)J66MNlKu@5G# zi?ujy`HG~c47#fdhLx_QDoJrZ-}qFt)03(_sbsh7Q8_$(Bhm0;idocC={e6EcPx(! z=!#G9bxlu6n;4aZb?OWGYGfM=q7(#VTr()%P9L_9+&Vh_%9eauyR=(E@bhiI^k@}q*c>Vqi~eso(%lm z)ax;V6|2RA)T5CN+ftdT@%o`UW->YS=!CoE3XXLnRWyAt%e@iJ%5opsg8a2v3@TR4 zbpQrN&;6yMPtmOfwjc+s`x*0@BT;IxI`--}ZubjB;a2C7b66tWcSvch0n@tBaN;7H z?^7)>D=RH{HMU-KP~eeA$Xv8rj;b)Nt9IuKFnyL`gW9y7^<|>)7Pa_3i39ZF^&&&C zlLd|3=RZq}DIe4JBKrksBgV@3r}q~uRe^=Tc6PvzIY0MvwpdO zgOAp3$H)L;anp>EXE+8MBme?^sM{0{V9_S}UV>hOfPvjw2zmyd0a6zr)mXtOKtpmc|N^s+wA`mHiHY&u30eC%y1EeNH^$nSC z1Q=vYQI%>)cQy+{bzz%V?)c2_wd;eg^gWY;)vf>4*{gsGDF?X# zg)li98DH2*?X6w=F*kw^Y8&ed8PY^EW*iFR@D^KY2Ms)rV8QEx1g%?M&Hd$#BwhZx zxlZY#=f3~y<&o@SR+2mn)%o#ZUup$nZl_@+83Dve$k#9(K$`58a=12qO@0|Ie9O7c ze0oi7t;XE;Nr+QW*6zeoH9w2mR>1Dc2!1){M41giw3UF+dznZpLAg(I+i06+Z5WQY zAFa2ru{J(DT$Y?(T=VhH`~v>*H8K$^^kfP(s#MK6dqlgkt~K`)EjuMrR?5yg|;Q4YFm66RcON3Y-*qb;BB zlXwMDEC!(tJ>xtILUk(|#s&6GnWrySZ!pGeeR`C~Y#GdnRma;n^h&f1zc%#+a55$& zBt$i+h~7&`HD+wk@&BQzk$n&B*U9FUr*sn*=aH3s`0T=X+ToUSY&tf&?nK zqtFoIUxzrD&`p5;vGi|Tk*~6)&s6SMu&B!U0d*`oqpxar3CiA&HJTk$ohEO>;DHA{ z3?!0Hh%=K)RML!PIU?xmkZA^W(OD?4kw+d&ofyLU?=DCi)4I-r0(U#~v9#zB0%W^) zp>2n{TmS-7BBn#6V8Oc0+Gr+Qxn6*^&sxsQs<^Wy@E+;glHAK=)zZ_GUyOD zc<@?`^=Qi?gmG^Ni#~3PIDi|<2~rKFmY!5HTGKUgBm>e{L%gyt$8#91(|i_$E(YqM z_oSh=WhX@7?`&Cn@+wks>A}qbvl#j`oq(7hhH&8pZKg*H>-u39kSI9dAH^C!;nUgrv394H&@L9Mwm@vAxTv{!dY*apa(j{=$tI(L zbqO;Nl2{25!BS_CxDZ;4vz`0>OE$CQl6{!gVyD}PgJ62HHnl5{q7U(_1;#n#5OjGQ zma&$flmt^FAPFJ(&xVoTBjf6K>$g@jQ1tbH`pwW}!9v>TnkIg~P_=&DDBZ@UC$AP8 zOzufQhriS&3k3L({kA(@CboWTq7ZFKwP_goh9NBY7=8YytSXY;+Wv0>9x}!5(+29& zdg!y>#2z<(*H?kgP{*EcZ#Q!<^5cCG#D+sKbovSmag;l6x_Yq>R~6I~rS;ihX$)34 zy*JT^QmL_!O#~;?hx4=(65wFvVWipUx)f-{vvGZSS71T4@D|JN1>>MFGP0Q;GEKhO zUhB1&mm16dw+bnW{rK_qY@PaNwcXON00Y8~5BNzPIYPj;in-eb;DOCedUMV!b%`us zyoCmuIde9}(&G?^Ie=VADad>3>T}&9uz2ySA;fpaF942Q7+zWF+d=oIW+2$v!|Huq zXy$Ap4E(oaRT{Nf4?k`;)=yljC}Q^kLL6^dCG(h>0GJb*ozZ-d?~Ww2ew+uv0!SzU z#MbmRmDtRstn4rxHO&es!S zY3uFzDzG_{cb=#T&@21gsmv@$&B1q`LdgEhqAtI$i|NG7$G493!h$z6+gKVvH-90Y z?PSP!3tnR}rp>)xVw|)NMF&qw3huDBWFz`!_f~Oi+WSR$OW);1{dz?NDSM1w@kcw) z8Sj==iQee62>|bRi6z&u!rU^VPQGN6#RSyt4L1td)*T3}YO|?}c*ZOR#U?whmggLv z@*?!`b237Vtq?6CSX#R@P-Qn#E*%i+o1;Z)5D05yu?9eLKDC1U>Pr|X1lc`B(I&pp zFVdj@tp!)D=i{t!>}q+$jt_*nyH9XeZX*vnY5V&8N4c^0gMF zl)z+n%fCML9Jytp&swa6;m%lW*#s24by@6m+B{~iFMwoyNa8B2UI`1pF`DB3=6J-g z_WgLFY^Ub#`)%p|{W|jC-Dy*SkK0-++5`inB(XsWSEpXSVLj0=0QPBU_|X-{^}66G zn3f0SWkC%WQJG{Yy`g*zyZsu@!G|Jp=7et{d)14WOA^f!TcFSx*g<15E?`%>5{hyo z1z>CU-?k7Y=~D@hv>D(p$TqTkI2A7x+p-z|9Gnu*rS6_)1EYw_G&&jBv)Z$qWH%)DeC^?5&as{@v7tF&y8?=&D zuW!q2^?}hC5Pb1&Z;8*Z9qqqb`;p0j7am_&e-Jo|i6*3MxpMpcG%+h8vjo!u()X8v%sc7%G$oa$FW=9TxLrt0#si8F~2UHO#b& zkUCTl!ez5t8m&p%j{=V~s(TynhI0lQ4@HsMfZEN%TDhvZV{^wL)JFac zL@AX5|1hf(Ojt%kNdG{<^6#!mFmb-pJ!H$-M!%l&IXMH^)U5;pm(5igK2h;w4Ez)3 zdK;#WvE0#Ap_$BdS|k?D62n5u;0GR8{e?NVq%TkJQ}KoLCBW8au~%tld;y79&L0cm zJDolTM2|`zJe(#rrOq-ZasU<5^9saizy}eUE?{_dCc`o%RaY2<1UBrcH6^z$w*a z8mk3{_LvLhk-r7@nU9#=i^6>89{SX_|O0C_xLwn-re>oY9IW8PM2ZtrBF2h@Z zc+?`ve8#usA{w&VB9VcqV$^a;2jI48j4{^os5L*n94`Pxk_Zs+QjM@%AGNzSmJj=P zWhpAW3m?)}o-<9F#r*diNa;fW{h%$2V88(icx~u|X0$4(6UeJOLH{U~MI!3)HP)zw zun_*L#Ug&F2l^m0CQg0HnNUYcG`FQquO1_)c`^F%)Fu8Yf?7L?x*?Ei9JoZmK{i_o z-1;=~vz+NY@STa8{RkiD$pF?t1l&fbmXVz^h4*3ylwm>$A;PoyayyKX)k5rk0{<*+ zs4u;2u@uT&E=yHaoi(YVZL90Ao*fK}5nwG@XJMH13jK_rg`WO8esl$TWnyUbFdLz$ z-Gq<_a7~spPIFm_p|#h)TwvW>y`3|LCL0Cx{CPf0Ybc~(!M@{$cQq(8#D!}CpvyI@ zU5WX8xMg(cNxWy9Z~$V`vHLL1 z&0Pi_VC0}iLQI%*xH~&If`dF$NsBnkZ|gg-;kdhs0ikbG55i+>R-x!Pn;|cz9T#e@ zK^2#`otPuC_khl3Vi9kQNwyuiA)tB$D;)Jz_@Yszi(?WXxax&UuA*Xkr4fv%= zAcI$XvlYbZ_ohuNuhZ(O-7~dv_ye;SrI4xvMx{TDLuhjfo)L6dH$?(pGCN*N%Rv_E zmcUt+GeL_VcPc7W>sKFslGV_RV-2cet+d$fG0mVU_UC8$U_?B;r5S>gr^Y=~iYAZU zlxG~QdQ?Z8rh=g019Tk7Yo{#L8j9Q?6S`(7=K&+@N>qp+V5y&DmI%O?{qlPmv!(np z+JxCH8-Ur;8kSk4MIx>&%T6SNv=Qr25yqTkRN9serIITLA50+VAcO&uzIAwZfA5L= zG;2ollx?NT27Rt=*>mN)K8EEtv<6^FGtq*xVCDTD3Pibh?OhBuWvXx;#>W*3sg)-lXq>c_%)K=$U z>+3$@gNjO#z21yu;0%q_@YHlQ*0<0UGd`D~*D{fK3o|!N|k&p?jXF9teT@zI0Za!2< zCZK35a0J6GhTlfJj%|KE=i|kwJ_PBYk+huy61VY^fA?M<$MmNA!N99-czS=uW>l{h zdEr+KRK0wiCsCFy#zxSsouy4J6$VHhFj_S!ka|NnUe(D2EsEms9dvY{hy~0Y;r1*{&IkVtouSMz8gA zdye{G>1#7Z)4s$uTl&zWL8&YxFBLj{0?%47_K zC4nM_a}>=m&(B3;D~0^Se3v`$=p_({-aiBdSbf&LYjw2mwUBC{bJgxq$kfy&U~Vx7 zq>Pw!fkRd0)ZY=JgUzrSzK_|cn%ynco?xDc7_CjwVZ71p}ox> zQDx5md7aE$ps~>G&Dt7F(C+6ff2LoT07PLcc!4A~itt|Vf>zoF?NU%_8Y=}hjGquK zBDlqGxg%;jz-6qj@AV{5y}HBf3h#1QtgN8@#80#TDJFw`$h>H&pD40&k!raHvm$X7 zQ4S=Jfr93Wz7goeY~em&ZS?NkMz}nEWq^Q|K@M{rB4Gj;Ep~R|6x3BMc>C)r2MEcK zwdq6B*%?`JA`nWo{*K0K=vajDMm=$l0WRNCUF}7{o!JARJ9UeRn{w8^GxZa?nEjbu zx{uimIiG^)#8F>Y+MKh}@~vR5O@3yK6(Uy}fsdC?jj{KC#PDn2idI(xsCe&TdRBU} z5pzok9_$M&4Kjd!|3+{Wh`kgrySI%5sBJ6YRW>g#JdhzirNUcOQ&LpCJ_zyE0(-`7 z)@8&Ysf{SSHpH-MmQo9`p^W;#)PuLgwuNz5pLsA2YgNfo6;v6_ibEf1t10h6E-h$c z&^x`GkP9KO=KJ_*IAA)N7{~4_kGchc`E3n9MNo^^bhx5kNHOj%y+wi%9|+xe7LFoR zy(E|pqqVM6rY97ANU8Fgd*3RBgV*k_PxaaoXgvun;|q*J7JXm7j+(e^BZ1ffCbKIF z7^qg(pf+XNhrMZwHw*M!$gdPS-Mp0sSG|+Qre*bMdjgsSE%!|rn3+BOS%AW&+9i*@ zB@wU#M7Jg9<38FDN6IjeW0xjN#8e6B2cE3biv-$;*I@%OqCYt{!y2wMw_y#I0hg=D zjfu0G;E<`;=-}mLiZ)`>!CXdthaRUD#Mpk__FThk($jI1O$cmDS4jC=VUV6#kq!dW z^U?GyX5e}iPa&E~ayGU=KA4{`Yx7{Wo9KUtOcDzDM>sXcZ*z2df7++7ej&Ot1KBUJ zpxSiqrr@~$knk=g9l~mCNXp4@30XT>E005?w|123`n0@;fCj`Qdu!MlgQV-u8sbUb zA{*bHTUqXH?Ipxw(nu|yYFY|^*OQF&q2LPoH}+WlIs;If`%nh6@_$yc>Hxd~kFhGI zujxZUUW0aqn-q8JFFFzL66tOaXQ=kXOSthNG;)kcsF zW9_{mA8kk#PfV598lI(-GWl}I0rE_8pY&`YlVAzd{>oPU;sHzyxpb00!Cs6NcM0-XCzAMEP~-!qQPp%{Jt!B5e-ii)2oq%|vRHS@l!5 z2{qJs26&&TpNwV;Q?P%7JH+upz&|br)#qM`tITJzMUY!4kF`&_e3Aj+y#iJrZTBFj zEWr(Z4d&IxDFFUU8lF-WA{RJ=*qvOE-34>DhB!d#(&vKK(m&wfAweUD`m^=ByP1cT zns$H#14MrS51K(^A{Pj3yo4NbGcqzVNhON>R#oeuXECm7I|?%W%+`NIF}b3khEZsZ z>3%&u;yF>vAJkknFfM3+csHZD_@D{pftEN4Ovpm4Gz{@_=~Fl^WPK*?0-!*w*GC89 z*Co;zyF7^p2bw!|We$sieVPZI32_LAWpgw&TM4(5afq4{K|s~=r;0vc@n>_Vyf&q$ z2S(dWnDV!ww?;;W$c+PBhf^yEcPJl(W-|{(R%%%C+SP3$aIM`$r6OSQVo4KBBv|oa zbfJ-pNiJc`dImF8*^h(S^F^<53-6^p-q{LQG3NwSu+CHOoxwk}G&1Uc?SE{;l?<0> zhTx0PbBTE!5?DZ7Sp_^RMBN-bgwsFfl|jSA%{Q~-PzXj#C2RW^1n_pyVrMy+Blo6q zaLY+i_!-Jxm;CJCeRw5;$e`e;TQw3WY~U$dd!vcqmVT7!}r|+(FhjVfdQc` zm=9w4@e9Zew<-KV0bHBfKB*51k=gbKp}S-O0u;j6?0C>4Q78zIatdp9SI8K()tDSG zsa;iGgFeSjfT9QkYyxOM!KU_bOs(G=G|a(Nk%kZTeeeMtbNW((G1+im%sywO58j78 z4_?p~e`Z5T*^krOHK;i>ZQDdG)gNM}rGAwLT`bB=9Ac*n(DL7>roz-1dBx;iE*SpE z>Fupmk?J**{VMAOhSvVD=^=K?eyp`MS)@%|?zALP3j|K|8u01yqlgvVN3++HqILkB z1O|1rLDr_?kLqmTCLN^Zj~@Uq^*OxmzuPZe_+o2*=|a$Z3lDg{(W8VrudNisUsykq z{0W-+Qk3-V*Tc!kUk_D4e-Rg+>Y1B-iYk83UHXSG|Dz$~9XI&#T^&cxqen5)#TWGU zj{ZR8hL-xgT$!B?@zEV9XsJA4x3|?RIrpZekQIGa)0CVZ^>t|Id-ukd>&HC<@~VA| zfDBcS0^0~*;73?>Q3h*w=^?{r*}`wMBvRA#l?iwE?-jn79LpE=0~7<{Yk zt)NA|jYyhXa{LY2wz%{k=M6au^Hc zUtLD^0^83?gNC$-2wjvXUr=Eik65xFrWEUt^D!BhzVF#02zB9As)bh(sT2l&`tyEw zOR0G;q0+dX_AAx<6K9BX&#&He&43y?IoWM9>$oa8!nOr!4hKOpmz;ZaceZAfi4+DF zOLZF9$Oim&sU(5-&!ib!bq+6ef|n!8FaokdpZthKj;&2oEIN21*F;I+z)c3385lOI zk^PdPHKw(#Du82nbPoxD0^`@46v##iy+wsn@b2NgN+;uV@8HRg0kIEJ4)5g-Z0p%0 zG59?O#z!nUqx=0-RZ%he`SY|#e$2%YKkcD(OG^-zGTRm4WY(AF;r(@7Zb!FdS8D90>u)kwKfHgY`kxD3VV+sZuYEg{%g1B!FI)~b4(x{uSITim+zWuR?V5g# zZBSm_TZBzMt92OouFJ*mK@?KBxin+aKRr$htdxs$r?Sh7pdc)XIT4M)1TOUF7s`LK z83;)Y8iSv)OvR@tnoW7`#MBF_Y%zX47@>rvV|c#>nq?16Gspj&V*HDa^W9cz3D}!) z;Sp%v|Jb8@Vk*UfU_Dxe(f0qxc9~d+Pd;%c?P_W|a)un?wu99lp+uP5sz;Cd32XXK zgP{qFXvT|UO30bPYz%1TfV49srVqF2CpQ)x#7$eTTAns5q*NHDR`J*I7g$&F zDZX=Q2n|0Eu63h+BuslAFpDob*gUlAo9r*G*A@)^*Lu@YOEshs*2AfqBm5Alx)W`O z92e#PGA2oMAc5q>& zAX>?}M+-vkSgmcz2;SP;45%KvqNJ3}Tqh6$FzIFo%+A4|wY7d%f;+V619tNM=&d#S zzIfj^nEFtbXlBr>rZ@T^qtw~0ac}yz7kRaB%$FQA!MrpgIXe08dN_=Hmo(F(uFONb9!se*Z{!V4q-Dnj(0v?1LcB zpCtqtj+ydD)gc!WYLtfHwc8awtG!o(T^=(eB|*O1B1F#Cq+~c`%gw_BteCUaEwL$4 zU|I2Jhdd+iPnbnAKS=xA;S9gk(ijE5 zMNU7-h%+18t2A#x6+8E(EY>EuPn0gF>Y57h?)c3$6mvkeOIbsw!{0eus#{jFq>aN*kUL%V}ib;=p)ja{JU*2cYe96e9RdYwD2~>iv+3=p&@};ZD%11 z0jr9zdKdbyo;daaosZ&GX41j6>Ysiv_p2@p=aV)*Hs76}Zw@&y9@*P!5lh|{7Vxfx z&3^jpOQ>pTX^T5dk-fEnp)$B(hSel(FjX*lRR)i)CH4|_{RA?qnXTB~ddBxdo0%6o zYoZ@nQ(-+tQMzxHjroNh+>qe+k!^9eEl@pkL!|Rh=e!W1RMQ9yt;dgkf4QF5#7$=)oN{BLJ%;Ya)v zo<+WixetFXjxk4Cdf4XGhZFz7sB2aP8MYp|cUt|>2eJ|axF#4T|GObxGT=aHFhx{- z?mdYpR^;G1Hk`dTl>MtLI9zerHtU*Ae4OA&sam?bTIh>w(E_Wx2KM%f4>cmAb4nI1 zV$;+|M!gqO=T5xcG4QCec~%-y@mQ=rdc$7cPJ*XoTxRqMcaGWDXP>%ub3SDE`ILG` zt}LA2SWh7I?k~H{d@VT3g9K9)QLe2ZF(6JMrIXZIhdoJpFA9V|U6vy8Doc4(EO1m_Td;C$mFRQ&sq?CB zE?x!AEBB#`b6oAbwOZ4Ezdh%y?RcOHa*xD&?pn>R9B96dJt+hB*b<#-Ok7*vx_fg; zO=9?*pWv}Z4dT<{}SCXpEb z-r!R6*^u3~v)u37{OZP*8#1pJ{LQEe$#uUiO^-Vw?hs$qZr;DyeEbNU8#lNY2GYQVETpA8;g713Mx$Q^3%?sjQn=<+eODD#Mh2$*z&#@}oC@xw$u)02*!QnjR+muEtlzY45?wc{^O#fr@a&<7E%@8G!!8fkYOI-asm5E0W4dei zv&uxLk5jL&A2*T?8~J%o?XsS_)U&W_RlhBt30?5#Jia@>5G=(X=p}fn!MB0;`k;OE z!y|8s#Qr7mHa|;gaC&Aml7bNZK5}`(+BH5Qjc|;8_c>=qg6pK@E19TBXye@@0jIbn ze_VJgf1y!K>)n?I>XYLwdZLxb?1Nukzj^7`mtp6`(1r5&yF4%CkH^q^KNAIge=*z^JG&^IZ?hBui{MqU6ma)y7&gnbA{0~ z$*T#A*|$Eo>3wI{`_GS7OIl*Zk&0e z_||dWejTXZ(?)I|mxmrMxA*Q13!vM>89IR{h!4sPj>2_D^u8Xw46o<5)G@ojoAW|E zy=7T3NdXlq^7?b=t}Kt)2S;o#U)wVkuUh3EcysmB z!v}s4;iKn98X(ua_d}&Eqrb#G7q-c^T<}sMUezZheGhFieA)5yV)*Kx(O^AyaUU=@4%Q3|pA3}3p*h)T0jq7pz-1gG`VV&%4Wv}+* zCI)BB73^o{T*9;i&`ha|8xa#nWH=ppLh@TU6$R!j?~g7pf7CuOj=PmVb;~#FOy=<| zr(&t`>LWf}?#e$Tn==#FE`Rkh@zo5KP=bZ;RB$V4yF15cb3D0n6#VWiCf-!Wdbl&; zJ&{KurtMlfEWZ4F-iu4g#m%!Ef27xRQ^v1*>#0QDx_sy3Zuk8O%R?p2m`?-O>@>qp zyw~Koas1OO-0@Tc#I1-&k7c44UP(S}b1Y44uQ1ljm%Ex3A9*Z1^l3cnf)nk&O)c6o zRc}1Djr{S;QzgagQ|A*f3q}vGs^hbRNB-k7{!IMR9Dc5(ML+Jw@KXzjRGIP>&$EEu znM?9#)(Y(l#&iNBJZ{?CU%S!^k>(N;8GW9hcFs-8Qp?q-gBqNhT4x5y(Uxwd0>pb}810(3vg$i7c3<$7RDFmqt>_nu{tyzu7kw}hRZ+Mv-$KF7ul*?)e895`d9r_^UW={&$TftWtWtfaAW-otFYjrmpRLCoWy9YE z6FW~rB_qF_>u}Rd8awgvO@CxOb;c(UyfD_cE{jEZjMxsmGA(_DyqOf2eFGW#?@otF z^kRES;$Tj+)umwb2)a@jbn#a7t+u?(F$)IOyokEi#)IA4}(1DRcS3Vrom z-nyFqO+lm>wffWO^|F7~`r&IjYI2qc{n+2}ulD4}T+1&C)%`sGm+wSGb1mz?wZ&Vn z&q^K zebYg)D`DTTHb7;|Md%$F$c6>(*ICwY=t%Zu3uL6?efV(Bo5_+XrZKeOyHm=OtKOfk zxLnUacQYr~(*TtbJ+ff{KBcyy7yC*)w_S<*nMJ&VV#$y2$p1_Z6gq_En;S646V)Mt zAN-Zw^p1SLaL%;%LHmiuOODGIEFXv!Ja(76%5g>Y^G8^GvbF2Np5){mx${v1J&ig=wza3GGI5j$@RTlJ(_e&pYXZ7==tBb;n_=9E9o(aGg# z)SmIp&4c1^u4d<7v?M+%KML2Aj=$OTD~>AZ5G5<~_B&4G`-AoNkq_vn>@k%pt%5sk zR!cxT8MD64#H%EK0PKdHZr?@Ar~cMIQK49X(=y3>bL0#)od{_-ugDzdj?4+Dd$xG_ zfm;;(PX5W&jjcZ(?^Nf(iah)cZ|we*zGz6f=Eql=8iCk;@VxlK^ks{5)eCnzr3PK? zz=@tH_L(#ZwE$mi_S4Qz89Q_JW-;lckFRu|=pA)Du63pOQWbvQSHI$6@O@4GRM9<& zbE&7!U3&v`RF!WCxrG7yE?0Kf@2r-Pb9&#@+m}AZUS{i$Z+73fX(n)r>K7=Uty?TQb7l$o zJ@;0{e`SX#cv3{kzI)eX==jCR{Apg-jS>CpZQoQ8 zb<*%-q$O;Z?C2Vc94I6Y6}}JxVjfX(GdRQ@TSd-P-;D63%6<4cfB;el^Z>9 zTDKancly-pCWBY$X#(f?^WC(rj+j`A_un&-%D=*?A8==+g{Hoy$}Gq`x-R1Dy0&4e z)ak)NVt<6YAa$4A^H6}c;C zA#4TyjgQ`)EU|LjQ4{`jakf`fGy&eg%mWwiBkoB|E5 z8p}zdkz){<*Qhn8)IoAk!vT#w@eBBqS6&#jML)VF$)WQiywAyS!OHy0qn4jLt}Q=j zWE0}wxWLc+7~Eu((L+A2yR?2eUG0J{Sao8IsF+`%fp#kwPQ2h@1CMrLm;n!7gIzb+NZllRN8ar+TlKd~N+!Lu4|Oo5wVpn0p&B_WoyP-Z|u5S5cL)*#gJ3olw&f zj~cd=E62k4A$iRE032nN_~rUZgreGyR=WhnjUytKoF=v35Bdd_f zMI4i9{)HqVIbyYb{IMYeIDxETGUIgcShib&p_;we>8d~ma7y3(`jbjl+7;s5Qyn*_ zh6Kl2vG&}mAM;+*BlQXlf!e}$V2RlVk>#|S1|AwElF+yhU;G(3BRNSRic82aY#1cZ zIeA`<4H(W*^9A1E7Np-Zqx#IW0pS_;SkAs-au;wK`8(5wefWa}Nd$+V)YS21)ceJz zE|hhveLZG0W)$1ngw-t`CA{W#Mg=_6HTJ5Ddoxt#YJD=y^8>GpnyF=C*}&>wu5`X& zW7U)b{^8sb^HW<%-yx165;sqvzK#FWyLp0;PgL#CF-uh&<)C~X=)epwb1G>w-RvX$ z4U7ts+(OePza0PVZJfVcUuz()EcGNz^;Mb*7xj7Ox!l6X@3^>^htp~%y>(#Xek$&~=!@+3+Dj#-Jey$n__RKk@!NAV!pBRM0^z_{uPd0R(i`f z&xsj=5l$_T0hO)Z7zZIc<~fcZ4L;s?I0pLvRAin^>mIZawugBLov?e7VD-SsSqw~g z-S#fVI?`@9zRFJSPTH$&@o`rXt>=GFTNVr`k(NZHVl$GXy1vwYdU#3f`b`LznnwIj zp#$!i!HZVMLQa=OAI+)N_`E;CoRfS1=cZ@|zvAgLkGg+*j{kXkH@JPU&$LA5Bpk zj=mI?(j zUVHGX%F77|_$7tc@se^MKbCq$^r7PE)ia`&t|vW}mbNAmjJ&ifUV45ldC59bY8?V$ zYoGs(r}(WL036Z%wy!y<#VMI{A&G*X?Wf*ao-dZ<(b^R>)u-!JAag zzh;bs*Ae^67nbj%;`8F3_|zYH;GlTqzQoZ!|=+dRtc z=i&$v3|r&XGavjO#`=>`cJ12r5)-jlnVVKcw`9C*&(=8>OR=o`JyOUXx|}B!yZ^yn zeQA_9RPB!c`b4I@ySU(bS_g73Mx*;2?UMOjyxpxTJ7-jB?4t?|$i(meetGqdhWoJd zjIz?Mz1l41K%3clmg&iB>~d=L%g?vKB9EmHRpi;}#Bg6len&R{GwS`rGz-N9hW2f7 zBSOFad+{ve{kZX)lll^wd;Fch6x5jK??irPx=0wl!A>K}tj7CP{;YXaB=Y8aa9E1+ z8O1nE9?>sZdi=MdNz=0I(vOmNEj3~u(9Ej$hA9Qu)dyD6f~tcG^9Ylu@xOM@kBx+0 z!1X_7c-5YHDGg#cUsKobpMQK`TsSZN<-^;qd2*6pZJs!rJ&eCs^7H$zpZ4jIWrkL) zG!5Q-ao*(Iky#8n^ys*$kmkrav--X9Y-P*?nJTSzla-!DD=rhBL$KcKZ_ym&82i!4 zabz+)Q?K*&l*&^7ko511b+_9{F%#B-BrNMFOq&z~)hvgayI~4Pz&1HKmrF}`Gmnnv zp6QS15liL#ON*k|O_Hvh(tEP1p2mdU7=KMS-AQIS&`FU8KbHE@qvzkJ3`d`1b2 zu=u4IVm8|nza;$kMygxsd4)5iPYEuAE%~99N+plS4&;)gB@PnqJ&FTCbybr?7LF`gBCrbk8J> z@4K?{l)7}oMuJV+7ps={d%@qhA0*1@f8Q&v#vl2O;mV(nt#!$;mCH>Jb#P|{lOX^r}nK1$XS_Nk5+4r zU*wf4X?cNA=6G-rBrhOIsj)mDCCEx3MnTv4qwe^8t~NWvpbbnCcc^(P#xd;k z8U0`IBi$R{bD5Zqei>W$tIzj+Gc^3|KQQy1)s?o#1tc3pk*Eaf{bW@SCOcYs>Pd2xC z&~sc!=h#u=wUIEV*E_Xl)sH;+J`_pVl)-221rTWwf+t9pVZHMLuTCo$`uVckzmaT; zc3G=UAqU%ifEAMMUTz8afpC)t$umTeK0vAnu!5mSU9iARTah<=tht7xLFAi6sP?da zsJ2YT(Su@34I+!RvJX&qJvysASmq)1LI7tC+UIaRf;oHK_J+OUf8%nvIfu2LvmX|o zK)&;aGO*io^GbR_S;&n=!L1!kaaN^!0O19} zF)p3?7w?P{s%KTB>*~weY_~yM+QH**J_Imyh^9Owp05RUAmd*h_b*~=(2`dnI{lDvqNkxeh&4yD+z;1sL z6c~e{FLqiEE$0frbVQ0yR^fAtY*R2JMSXphqx&o7tey&>rfnMg;c(Aj#&-MZ7*M3T zc=%FB`=yUo=Dt}3_!s2kd z7WIahl-muTg?nVhPs!kyIzC!__s$%DL*kk|m*PqI?10Aa^$qeIphl@q#SuM0X;sESF6W4vitFE~sQT(xZ5#h4e z&!75tX9@o%6`m5Ev+EB}lrh1RjTOZXpgvos2A-jxrWEhJOnTj%pT4-5p;|$^h#n92 z@$OGOj;#rq!mr=Ys5_xTfhoSU<1QSFIS2bD`_%Hh)b6rBI<7v3ww`LPc_M$pA%0?A z=TcMVm!(@qzg)a)1oad+dva4H54@^@w~V9qZa#zQRRiy&AJOuqoXIJ-X(g}U8y%0m zonyXyGa=q|-VI~SrI{FcG)C#v@8a6}T50KHysc@EKeQMqtoEGrL0LNWZlWFBxmUK{ z^lpO+{bg#jre{KEJLPrYh}Bws+}_AcYO*GM*9O?$X$-6TtTQ-LCnCZ+mGD(dH;6+l#%VbEB@R7-x7^-4Q4%Ghe*g)Ws~-_^g1_hI zKj257ICq)5C?1A&Sna=ysGH2}_oQAkv595gwb4mj$UEau6IQX?Cbr+YFF&1Udh4UWLOMr5~!24Vo#z&H8pUyb$W`9S{1@<p*Xi_sCdo z%LbR5U$%Um7uvM@oYg`6Z0=vVg5JBQIDkZ_K|8^W)LU~76L*FDf8{@2N_aDLNG7rD_j0!s=5@tn;ko7o=6~ zN2%nrQ*~(0JH(BzSvKWe#e1;~n00P<6JdAugaQKMRC(dx2?s@!dr z2}2Vy>OC*_WaHrD?O_r%wpabQ5?lm=FW>RwV&6Dq$vy78ug!Wf&QcR@1R0|(6W@>? zxc#Z?y4i=n`jioiI>F{qIritQ$Mxz(PEptyActIM33$ol=m(UDfG7K0nr-ii_|v17F z+alZjV|Uyg{h2$U4#AVyZ`z#Ld8&gahx?!pYtt4=HEsPptxbQgxZDo9d8(lXYNrskSY|=R( z5g+%gIQaw=&Nxpjb{6qr&tzGuzWRzs+=JTNUL0Gr2dif#FokmP-a$rj&pgBI%eaX6 zqG#=h5LfdqpJ2!UTId0HDi>C=i(50Im?yn=C$E-YAeBu=R(o?G{7*o%wdn^JEbx04 zW_MxQ7lDZKr*exyVqy8EXQw!Gw6-?g8&u3vf(a%g=8l0!khMsHDeW}QMQ`CzAw4U% z1Iz8s3wsJLoUKjAg+IVU9V-|+6<8SrBlyc`%S~qhndtGXtUiyuD45c=|E+g3TYgrv z6IJ;S+kCXVT#y=DUN(g}0r^@5p@;58Fmh$tppoqY>u?MFrl6}29)L>alBUz3$tGG` z`{6?1dTGMDULa6LkXUD$neDN-;L%0EFRiVA1@QtfF!p&D!$w5zSPB|4&ZQtX*jihC z`uAped~q3$g$tcG&A1Q!cJRu_7-xLI~D;(m|-uRGBKmzm*S+>mMN z7uW+{x%BNk6mhBGO-HqndQhM=aYN8%)mU%nW_~Lf86F3?bPF|!6l7oCEqET(XWY%2 zZB9Lk#PTrvNDS}XFC~Wk6HUd@;3Ef7GI@W)%A-6?&Ij)2g% zzN{B6H~fgL&zMcg_=?RQ#UugwILN z!B}X*dw6|w5sd?nhq11~0p96mb`2_$M%i>37O7;tlz$=jaMsBr&g2?HDOY$7Z>L*F z`VrGTjtQoli$Qf_ZDMV;-*9Q z_NFtXQX^nw?8Y$&PbwI&n(c>E4#ie{J$(-kj@<+i$`6Ym1;~v=P$bHQZ^`2FbgI0K z%|XPREw-?yYBm*dtc~ymA44r@5lrBL+ejxwZtD6`Zf41=sCAh*s9+NTZqO4GkddzV zB$pgHsKm8pxkT?sZuBhC&2mW27k*Dg(tYCNUbH7;TnNRUOn8jce+%WyT!g3+QX{B! z^Ny*Sv`)BcGm|7$60m%z<19+^zSGD|5uy;>)hrD*UI65nOuKMBtT&lYVu!3EdFK)0GC|q`TrhH;IjGt z6!#&OoSJPh}UIbuPLH>aUliN%Wh15fy8QLlC_Ml;43$1fDJ=TR9^JFCHyJ~uk zR~71+rIW-z4?2*={YjpTLIn1}p>4@{7@JP8wIsJ>defx*2IK!`50)unMxNn4E&{92 z`XJv;fvHOo`Lo_b){8m0ao-QUlR@CjcfLS(G%M#BE%=G$>zrZrHpfJ2^8YmtO+mSp zaFipASi(`UV9sCDzzUo|IwfK#>IyON=SdK{iJlEdfv6|TP@Pm%7m?DS4=T#XGE6cE zOe+?68iZ>m`3yS>+*rp{n#~@zYlXcuPEF28SKSnA52aM}bT)CV7^MQXp`V3k?w8Y* z3RPhn9|t~0P#5g?luphFVQl9{w!))sfJ6}#bSA)s*I-X|RRry=R1Y7zY{4Bx?gh~Q zd|o>1*A^_hMnwjpm~b4g!fQR|3ZV%Nqvm3)Y(n(3yd+ESVpqa@Mb1P<5~ac<1~^R< z7X?kyn$4r?pmriYw+AdqRzTm0q#XZNEhMhqgbdenaPuyG*Cod(MQy4S4qYP+lVZ15 z&cSBKdQ&`)a%eX9I>aG0=Ys16k=KQKM1sx0f@kyi?O|i=Az0&Y02_ZkYD^~i8q7HN zzskqT^!W6j*nw;ig?xmLRe9*SX>u?3r))o^QCYtCQUD)HJRm@=s9-({qk9t^8%Br? zhW&Lh>>M#{5bW>bHy8iS=3lof;~M-IkNYX(zn!&a{nx$x8vM7xe;fR_!G9b4x50n^ zHu$eXTQkge{(7-y2^iPm=*=ZyZuNCN6f9SLMTIqA%E-3TiOwrmia|aW3B)%j)t=MG ze-N=FS`o+7c)(ucgq6X-iVxk-LwRw?`4s;`pR&Z><2+a|6kB39UN)vF%tVp2M0~CQ z8^SAS(q4t@i1@YywZW%PGMGE!Be01PK?Ww!lGD#-_wIm4i4-}Jb3>3q4f?`{9Et!A z0~tKP#Zx!9f)QAsvoKFQ6beKsVHxfqqSFepW+!y4w!kGe2d7s!5h+6ih9(MKJOBfj zOv~Q_U{*W_(aRgL)F3Aj)NnbbX*%dy8TS!WaI2v^CVF_%LcIc;$V~}d!S=C5 z(-T~U@5Baph{5~oB~UlUfl!T`}^UIPJ=aW=p;vpJSnT{GWofoWcJgUo#`WG=&U8ep#Z<-fW3Up^1JRTxLLo$UQ#C>(*ObyG2W#f>Fp~&M@?K0DOoFSfb~6 z?i9}sBsU9>);^-MjUDq_3Oz>7?badAtP%JUONM`90;g2KYn&Rp-o5QCQ zhQaSIU6^{0gA4c@!6!sc5hH+U6`P?S^={p$;yQXL+L$b$T{br^RzCNNm>~CzS^zWQB4`heAdn_d z98CdrP*f0wp1Q+B>>-s3z<3Kf;fUKIPaIW;*qn_GDVQF1S`5BF;Z)aZ zOsxF7ZtIxGO9bkU?{KL7{?MnAZCyJZXof^i}U*;_t5TJ9fjzga%{Y5VZ!{y%Fh5pk0U zY2f=jrNy2=v;a>VDiTa+u`$RyexxebV0jYD%e^Lnd20yfJ#$u8oz*sidFyK%>zxM7 zYkoKQ&Bg!B;mIw^xCa00tUOz-#D80F&i}iYUxWWO_+PXBuUY@spnnbe*PwrQgZ}AH zASF1bxQg+Xi~q{RYv;eSA*l_<$CcGo2)qnIPnqkv{sNclu%MsEEjj~`M_xdo;}9)_ zVUqw~GD;^lJIqbknV#FQNPGfUgJ0DqB!0`60P%!xK~R*F&|r3m4?Q zK741h`a0377Fw*Mm*5z+tVN0NsB(Eef%f*XBTqg=fvYw?f<)@T1Dd-(^|ZzLs&VfabdyNKhC&jlxs{qjJ0*JEN&qx!1=Ba>iT`LRbT&;YzpS z*4U|DCN==VxU^8PA{^L)?wn`>6WTYMGCzoTfQ_4i)rY>$j?n9ZwK{{g9P<&X0B*p` zI2eOlAQaUdxWSdk(UEOXTunW2u{n$KGC@RNqNEqXQ;G+ghz}%yY77Beh8R$wxCI#! z!W*=OxN;2jGYCBqMF^MR^2B(`W0%ldxJ9gkmJ$LJk*sC#N6p$tDl>><0SYc~Ijfdt zh#S)RRWMSVhR`kYssQOF=DD#j>w@cIX&omXIny%7T!gC_t1%JDCWy!@cuU~?BT7&q zLK7}G71Oavxzb^G0s|u9aO_MGA`8rg0ns!HFf-I2+n7d3Koz=X2xNtq65do@j!IID zrvgu%G=Z;eHV8ng{-3=sfrs+@{vT2?T4<4|JftFH-zha1jAce+iwa{5Mq`GVu_f^- zl~7uwluF4*qD4i~MoEj(BBfH=q=-t1i2nC^W-*r3=llJ9KfnL)`}4fM-#%vMdG0;; z+;h)8=lz^}4wFNrko&=&{lG5rU=WrN#5M4D3|bg$`zhcBVTGC*NI63|29!k$Lqv?P z9(XI40`r6|fX-N&+`(B0I5!(+qA3io=&8dPOTYEg%MVAvq`z-j{m4Btqn1q~KX zjDa0Eo_awnd3Z&`yaJ;G{|#dLa$_$s@M{vF-hm_phr+rG{>m2)w5Iul(!k$rIlyK>d!#<43uSGCJE!(PDCqbH!KO) z8!T%@BoS~HcuOKreh5Se=j4n9pK%V*A{QL|3Ga#{@xwu#z}MDT5|-eM$2vilIP@YH ztUb7o1Ucg!i5LjC*wKDAp4+$u-Wl9Obb;^={l3INc!Gt!3tZ!k+oV0-0enB(g2z=X zmoY>P8Z;o>9b`dtz>zHQSbMz3Ah$zUOB^6*zz;yHxHy2vopB@wJOLgZ(cBgX21Z2V zfT1I}4NtHl4SZSy=7j~GWZ^<^a-NMvgoOZTfUx$~E)H0T=mcS1oQWhHGFYM$(h&jq z0u8#dAUe8}@YXiYV5FqpzAT6YC%h$&1gLR>z^#tp^K2}aNv=4&6XZxFff>N!oe=ht zaCle1FT6!BeMD|kI42C+5=$U*dv|drVFm4B&GGhlOTZMsakx1L9G=MKA_3gy3>enu zL4*){tOcG(K&T?Rpm8wUEQlo1Y+UcS!Ju56i12>|0@d5~AoM{%svK}m4n&P%$iENd zFAT*Zpua8;^w-hU(So#%;0Rt_{bA65`1)(t(D?rVB=BGAV`%(e$52ndAO5cce;CI9 z|A}jZBf)wsS`J>+WAQeYB=Fx@`2XUf;9vWtU(-=2jl*DLaE^G~9339vf_vOys@qV= zF^49TY}UpqE>uyPj$Megr0+YV7Oy6g*Y&Qa)<3c3bn(&R*u{&TlivDZ6P&T$iu>2? z5;Hd!ej|oG5*Vp=g(%8 z{0QwBFS254k43EKx*t**J6fBVl@mw*pG5+$u9aD=X{5g`TSlF)7qXN3&W>w_sJH z;z_ou)Fkcl6wR~YB{yVcU!~~SUdcVvJcoF;aqaYsJVvE4WsIV-+03|`exJ)X%71Qc zJ$LTh%IIi2TU(No)8)&Tw_B%BH|1~3nz;%mE^R(7hP17y;t7r;iaK#qO4M8n<@T(? zI6GxTu(=e9B-bt{QYJ1-5vAUUE!%sx1uh=}~?e0Z_-^XJ5b zgiDt%Pj9#w-SxG#m1UcA#piB-Uh=%w_)>50Byy6xyu7ZiZuj@^onPKfoHXfmLqm4e zyZfdKBlqmm+G9RnFs@G|qR6iVvJYN>;(j!zMX{+#1@ zEXjiWB{Vd&;r71v_I9GJty0{n!ooMNUt^Y@(V90eowVZW^zf9Fl-I9c*RE(f(kP)~ zS>4pu)6*kMIq!MQv(@k9w@Yg!{Z2lj8yM>AZ=5lIMd|91fk|qViE5W8%GG$@FmBiy zw|lqxg73jST_4!Qy?KZ7=!G7tsJEP5AA{?(DM~G8H6!2LTzn+e@rIOW($luOHDZni zQFy#W`QjJKs95dF8#f*ohvx3s;fBLqxu4_Ia5Jsy{{1pzK(5Iz&cmi^wM>im zBT(f5w|3>#{a6(f8L5vF-HZ}Pi9Yu`nRWbQAesEl&1*W*CO)F8nHK(ZyNxR4=Jc@) zF-eo)=L=n2suMLYsL1rZxV&Cp?p8kKs*JkFq=^&R?`!fm${RidoC5QRa`f_A;9Y{! ze(>>QaBj7Sv$LM>H7Wh^i)4;<(j7H@KVh@0#!fSGG?u+W?Cxwk%XxRNv#m+m{L`mT zpBru)%8m)ko8Y|CVr52(^y=lymnf_Vcy)A{zx2HcFUOVy`OiZ^s5q(e#g~m=*Sp-@ z)Ai_8a$WI?Hq6F#TII{`W{j4|I7few=kDO(fWFY!*!Z>OscCpi?arOD<%>N$9+$2e z-Tt92ru}Jnd(*=Y?;oAKyl$*h*_gyDtataa6fM@(w5giaOurJAjz+!Tq)-_d7}yvu zJ=4R(gT-b`N=j~@VL9UL#0o1qL0m(Vxy!8kb8YPeeCz&{MYbaE^RFAnTgXz>%O4jk z{}Ebm+nuUDUT%!s6I972vH7#s&6Qk3l9QE{m6I!`R-_geo1k`Tkyn>`OSR6*a$d=P zStgNNZ2}fVUS1x%p;F>PNXN$)85tQ{w@%0peIMMMz=S4yCtX<+s2Z>Rrnz}O>-Dv+ zmb1j{Dplg-DO0?PSR*O)@Oj=z9!rjd*PS;rJng)7B{hvzIX(Z_3{i@GYLV5ei~hu~ zGn46)PQ6GUQB#rqy8Ysh=+l{=kIrRy9NcXXboj`T=_Z^*gzV)30oQKdRxl0A+Zhxb z{PEMPtLicpJGCjk?$1uqoK~&sd3HWZLQ&Vha^8wB0fB*sOYXM?EJ?7;NOC&j0>zD+ zF|VWTq1VF)57w<;9~BjqxKFG-;?tEqU@6#Ue%elT58gelZWJm>8-LH=-%Dc5m+88G zsH|y}uF$GmV#l2V9A;Mmp|!BE7(2=$BBJBLktLa#nO$F-B@P`!n@xjCKw zK26s@?0wDM2M2S1~bhx>^=qe>DcuQxvJ zoiu%_&3fkZ^odH<4-E3$*`la8m8^9w{#c*c@7}$eI(4dMc($XVF zjj1`!R46wxF?n1EB)a9Pwzf7*dCbvV8}Xc6;*^x5bM)s)!4;%V$J9 z7tz$ze2ZV6JpIX-@#B+|lN+Xqmu}zgP_g5KR+^Z0u~zI?>%hRrsT$K~;cFO5PiK!* zWl5U9{rKYY+O=yn&wtr^?3gBsUUwn-Rr$vK`}c3zvPIYLW=%c?JQV2c>~5gXpTk=s~~-!>bE!{yv2X6qeqZaO;NGw6j>wjN6STlcjs_tvemN*cQ< z@wD#FyRTm_y>&fjh5;r{n|vr>J;NIt=3$0fTFg;ZR4je?&@Gi(UX$m3a_iQu7dji& zwq4g-^}XXlbk{1doKYX2uNe<3pkVdoZ_=0R?E=bMV&d$wva*^-!INI?!06^~Pgvmo z=Lvh4AI%47H(TPQZtpdAk|@!-aP*e7xajfMuboZDy(t#Y*qV}dA{bTj@ZsqT7iKss z-Dy5u=ecBw+D9|yvvVCC5h$q>f9gcG$@v>dEx4hxjat4_s#=7C!7t8KB>Yg8pd?98 zxG9zAdic(WdAf;*H_FVKwQ==!uki<@%u#u#PTdVbE%V0)=I@dsd3s(5dQuqm;k+RP zdDk2#0}1=~?ORAl$O#N3sk^&-^tfp|_w0!VS^(%-D;%y!?oh&Q$aZS^LUGsBKd&qA zNHs{^t}io1{+MUbkt0DtK?NR|NvKmEK3V~*SC8rLj2tifTwz9wyz~oytpKS&|Ff6O zj?`$*KUJD$&srZePwZrx$*M3yR2KgR^p{<*TR4evNLnHx74~H_q%m{->SJI=7@3M2+tq-%v@hbN1bH=s!T9>= z6D=U11FTCRToE76xA*v%TgH<{q2itw8Z2MYnb!Wyl=Z?~6@_{$u86vH_5N7soO22Z zrHd-NvR2c}?9CQy#;30j=2B4A3@NMlb)%}Dm#WR3yGu%GnZ@Mtcx|@F zLp`KV>KdR*fFe4OnYm{5>asub?gns7o)&?~vn=6BmTIH;AcAm6V~56$dRGZ9-D7a(=-{sXzw%mwZBI~t-_ zo>Eoazcr5PUW1K!gic{;YC0@h)SXXR8~3*C)t+ee@}2A|<|^IDFK@-I*^Uiiu|9@w z5r*X*FoV?9qhG9@@@2*RtQ090FkgVBx$U~Mr)SS4NzMBYAMQv^UAJ!CsF5R83EtGZ zRNqMp+G{KG^6bR%vQ1+9-WlYby&`EIuPxb-x`eUeTUVVwAzd~r$#xN>Wi@hS=;igt z0vR%28whD@jLLUvH)UY|$R^BhZpsa<71?uVL`p%jHe>nnii!#~4Gq5}b+EliwYHr7 z;9104E9Ijn*Z%&|#0e8vx97J5O1z3WIY8qBabI+Nd^5wP_QC80-Cw?bdbObPMzMXo zp}B|cyRoHaD5%^hYm(vyseQWs33D7gPIBHQtEK=O8KY@J)M(cT{r&e z6gctpevh6CFTc*tLfzt{3YXANjAMGfuNx~bOF4l7JNE58rocOS0oZh{qC#@a7(Ka- zV3{SGbsoZ0FfVq09Wj2MR=^#|J$3sU=hQSSi%m1smz@fDbtN$?E+RzZ{fG0DYi5Rx zaC|&r;>1G6)9;^NjYdb>k6HYFP1J{{AD@QL(UV({yM4v+@kZu0TaQ;i?r5zz4O(qZ zDa@@}HYe67ba`OlvzQ;<*SF0{R#*!Z7Huvx`ds zSX5U+feBdzl#qtUDHVPF$*9V7V>VDyg@uL1#l^GiQsXbXhXjr&ITq9XYR+J-M}~ZKPsJCY-l-z)mp3Y~^B_mFmX$_=q=Y z{*&G(Vow!ZXTQn&@p@Yfe(U%w!=25+D5+2LP^c24>~ts8Che`tN_o?hv~96lSDO8p zM|pGe%b&9)6&Jf-Out;$6V|ogf=JjYb=!D*y`QZ^dc^^?$|EU-*IByd0ng6eugc!H zs^^>b>g`4OD>=JHPB&W_QIV<+3;`0DkhRjB_SGOF5}(rg=j@Z!fufs5^kkRsk0vYPFP*4O zPc;bW`ihJ0k}I23wqlC-ts8THyjU-pmNpBAYqRx!0G80iIaas!?VF@f=N7Po;Bro5 zLP=rjJ8Ok#XP{~$KKabL-*CSD8IX>%pDRr#uTiNPlkQXI;EVPj!f0o_ay#s7aizCkL+p%LE>A@ZE8@G>vp|pnA)yqsunW?OJkeVbKt1Ru# zn5sW_MSF|&2+=P-N~jDO7in`>wV>tOq(wC~H#XZH_gL$Y^-AScrS!rt)ejyNk}t1& z|NcF&JB}Ye{{B7P{Mrd>g=PA-70rp`UDbBaH;ul%cPYNL=ta#{lukqIrL{AAKCZ`a z*nr(6yXa#_cY8xj*OU2c*G`U$*r4lr$NN%T$Fj3C?!JqcT3_PFn4r8!W&cXNc)6@m zyULqN36cB7M<3fW*VlpzxD7yKUAuNI$0xaX<2U0=Rr8qVmFrIcet zMAqFlTcXAEJP<6QGS8AW=fWJZ#E;wj_de=*mz@?Tt1?o4?5+=InXec8C~{Q4885DY z^K$C65O;BLseki^uv6;~se3QR1^bK*{c=0!?%@v9sPQwVO`Mon9az18Ut`Q#?WT=} zYTclOVLHxdLyjZ7v>NJva?LCqLe6_F??J%Xl_kiVe`wav*fiOJQ)*c*m8fQx0%^4z&|^@M7~E( z@U}lr#%t7Hyd*oPg5LW2?HfO1UEO_BWI2(f(9z?TPBXx)ytcW=d}DZX#+&HQFFCon zreKi+8~#3rg|4AZK{=90Tlenm0WQY0`74|w3QA_LNEnq(+-D%S@lx%dH*Xb6ol$;~ zknkqU&QJuZG+l09+$H&<6bDiv#;#?UyjzqGVeRaLd1pkTp|?`&6B8AWAf zWy|I(-Ho}&fT0Ey_n$QnCq0f&``+j#pFBfdxh!~1eRPsGh4T~4R76%_V$c6L5~{P^{2--4#=GeuSM z%CBC9w>aSBXv=K`PMGPc??$LEAL_hvtM{5kcY=jK-mD|T^O)O4Pn+(gTR%SZ+SgUJ zZrsTryX!-?Bx-|F-M0Gmcg^XM@tEn%7EZ-Mx#w zyng+n8+)eDxme~>R$e}Cs!rJ^L!-#dC{>$xM+*yG?<~x&db+Bs`D(I4aza8e@O!84 zSYUo=e`(6D&eHmdHgQ_9uf+!w?=ea46DO{@y?5E4cR83iqmlb9@DqAotgrp{xk~$i zZh6qrmBvb!e%#NYVzHh{Aul-Wg!$I@Ocah+xp?m$=Q5@dutK z*okHn(ho5(&s4@e34dnH`No>8_*gzE`bos=>)SH*(iRMmNR=8Q#BtAGk_mrkmWa{0MzXIdEWI zN{WkBW|kXCO9Goxc+{O;_wq`PQd;hEF~>rJ$KyFylcy|en)v3~v)6$1)mMxeqNeY2 zs_zlxU)^6MncyKcY0|-T_245PN1)VPry0oY7TK^xlgtu)4HM_s z+S!$^o!7Vtm0(W`Psynwyifg69GczOBrm>Yh0?CtiBcl-WD>_*tm!-^X+QfBc~(K< z!F|!GBaa&Xu{c8-xgI@wbhPuswB2D7(=qrOpZ#8|B1bK}y!cq;8B47-@t5M7>^4tn z0JP0S6`BT2rJx?SHQg>Oa9_Lk#TVSmijIyBV4<%`eBHW9!rNfCy!_MK*-zEJe7?Q5 z;kKL7!R90Nn#V_=<`7+%5~n0AT(snghoj@@h41~!jJ@-UI5|Miiypte>Ztd}=cTT> z1^f4xzB{HNkrBK%Jw1K=g70^Z`mM2`pkkR9Z;i@OsyI1kQLRV|>R@-5rfzv{p2O|V zKW19n1}@(yYqu#{{L#lJO!m^YjE@cR@$vN)I}*S9TfdDMy|jpR1-P;YLy7`t;?Lw< zKNr=W^{jpYszlb>hTXFC+aDv`N{*zwMAKVGqDng3{DYLF!dFVihTYzKsk74{WYSqt z^Y~Klw+XUyJ$7v0je_KfR)6Wrd2ARTB23P;rz**_6Ux?C%)StzC!d2|wCnA5G?uiDld6k~ zjGR1al9A87r{hquBSwz{3f#)lvS!wU8hy37fghF2;y-_#h6vlZ~f1&8lOv^6yZY1t%wS~rRv9jzNXHP$nf^y174k|6+xrm>nr<=bN#LsQ5n?*@|c>dMdHc zoICfduv{9oMOh(4mSYgHFfQKN)nJYMzA5GDpRZlBnPu$u^u!3!w{0t=6Pk2RNh_ib z9WyjuoX0S5Jb=d0a=m6(8Xv0hb~}u{|8O@7byh0ieyMX<{h5;UGoZuFzyc4$pt$c( zYU%HqQ8C0VR14d)R~*C&HY^xP*&9A*v7=ogPI+R)gC4oy(<3l4c6N4&l(7U;@1!M1 z=7(?Y(TON6EqS9CzFi?CNcT>B~kbC7q)Ao}_Dm)T9u%2vXDKMyA-A zCnBTPym+x*VVs17NN~dwr<>UMIiuJpW%E{QQQAG%Sy`9dbss&*yY*mQuAKOv_TWqQ zNzY?r$BvDU7at?>$x!xG`V#od$2pA)TgGB*T~$9c9lHn&m#}!&oOKCuW}7Tej!4=v z;ro3HJ*iJnetx$?v>qjdUxYioJ(0<-;rmqjd} zg)I*VxD(Uuc4K;YS^1T=w)ThQB+H`MW??QauM;`>um zQ=PI24*SfeADutK#IdZb=!L8FD{;jmsb3C_M^P+urcIgB@uZG`iUk{Eb#Ah$oIma) z`SNP7sAdC{5&O^9SINn_TJch%<@R3n!qQ8G~ zsEdgiML8cOCw{rW)y`y6qfrBp8C&Tpuk!bYy`H2Te`+|cyKsE>C?oQuq{K-QhE9_e zj=FrZtS3}`zD?|Sn`zp%0>2o)WXTa6ZtS;j1(PQ`yo3rCAKJICWjC|sY;z$tDQ*69 zTWxnxqDrEQSDiaiab;=~dex(+6I^4i@6^{h z@k8N<(ONb^Jdmz;v8VIGMtSz~Ko8Y=lj$2awS0bmGIIxJDmmZrNb0%P8$m$m6S9|G zlteA|&UiL9LG0A2Q{G9_aW}^KonSmQk)F`#aeEX>e0=*^36jH8k#g~p6xIQsn7|cX*aw{o&TxK?Zd?w%iLKgEg#FB$BredV=Bjf{207o zWeMqSvA zQ_LtUgWObDNzJF0KPQcuJYGypEPkiV!*%1tP!bZ@!u0mtoGHPTB6@YJq8gtti71r0 zoH++IZU5J;*mT`WYV4ashs5OZCVM3*V;1_)j6Iv$_+2S^lJ;E{J-ta3d)3hMBTy)% znIpjeP$s@R&WkHadmg*n@wRQ1I87xe^OQ^K5?NglEibQVI{o8BqW!Y-of^a_OVq-d zO5YD;cEv6~ri{`mmy?$tDc5XN^tw1)40Zkb^_O8I4drCA?6bG68$VtZlUKHwo%#Oe zGLcGbDiv&<_4TGJBWl%8i_K9M!EwCor;x=UMP4tZ795%;K#$M##SadNUaal-cK z*$YqGR(t#)DT<;x9v6gVccWc`U)tQ+cm&Ygj`=zF&8h9M>LrtZ4C(WK?9eFKA z_T-r9awaPyR8Bp_hddrLVxgz!-jC%*CNieuh^IY{_}|_eM5BdNkv?{xZLt;G{4`?S zS;^Xi=R`ilzzJG~N$D zCC(8^5LZOymC=g6oy@Vh80)Dybxc@G@>g4p?yfH4-f6E=R+g5Uy>wc%XqnTt$rQZh za@DcQ8&He4Ztc9JiB6GkzB-Raat;jKN%^$lYm0N%;p!;|YQpP93dq+sD~=pF(lxhw zWA&1c-B%K==Z*-jo73PL>*vl`WL~heJ4B<#RX>+ZG z6?U3WWq?E-#y`P2ZNse;m-tj2sNJx1Ys%Fv%F>Bh#ztp801fxF&@677q^Xw6r!-B^ zd7?|jyq{zR7nLpIgr8~aaEU2W%iPqdX*9i# zqK0w}&+lW+O;Ax=Qa*oeQ>vifNZCoN8dbC?GKKyw*KLW$Qk5;rAI_aSoRstuzwN*+ zKVxmIyrZo!a842geqe26@;A96I*WKq~)xRJ-R~l|vgh zHZL!@H(9MkcD~8?-AvZu!@CMRbOIco*A{I!>3{VdhZG&X+f(yhn@#q%y{lGy@A{xX zqvgwPoc&~}QTa~Nw@3b0(b=nW?H4P4q}N?|>aAtJcb@y6yQ{`F&bvM_Y~Q=X9#m+W zT&7iY#MitUv1UCf^C!CTkq{PTV}knBe2v@+bSu|@Aixnp-nLxSl13TCM{lMOSpG^ z+hpJ~b)T-&m^Sas#YY%QlAc^^E!)&JuSWBR1{7y}T6y-@1(B?@QposLncD?=P*C*e zTZSLbyxR2X)zz~~vDwvC)%nGZ%Z;ZS{^4r3s{QPBNtu=JJ{koE70j3yafN+an{u1wI-%+sp&d&2^Sm0iu}6&3%OIyEc0^X=`u zM~cJdH=Yiv*sD!>YOU~e^2E$qbQ$hG$HAcj*gDUm+r8})Lz*8u#dJLxlQlOX_{`%7 z@nC{iO!SG;=d5otmxR2~^{))j+qGq;_3EbQJ%ooz?3417INnJOH}Q3a>g%O&b6r-; z76&Vcij>$c96|BJZ=Fp@+M}ncqocDhQ&C_4NH)QR{v<5_@L?-wchTbsk3>|yy|ht1 zc;I1EwnL))f>qv@aSG;#PMmmGli&LEtYl+Tla>JrNGQ8uc3r63fl_GucKztich^5R zs7Y^?GEXXS*qz!@MNCeZ78zW=t>{R}=OxVZ+js5^a9fnACg!-=lSEoAMN*o)=faZr z^`9G#ZIWvv+a=O3FEbrm?5#1`*X5*lrE!BFYF50HJvKMaUyT_e{y{o9v30}E*tfFL#HRQ+&^5{{q1GqZs#jEj$ZZ8S(Q2h%9^HJQ<$l4l>JI& z>!uk@W`@0E8EwPMkeHs&>26+oyxq>+oIEzJ`;qEZ*ODsI$d{K-(W(v~K78Wj$z^L% z8$RH+R8H}fHH`Y|=q{5V`tY5$RoFh&dZj1k-=2S(?={`**|UY;wgXFROZ|g)RiiI< zHj0J3SmTs_c)Moy3g#3ERN)$2%H0WuuZmnXHXpE9)q4HhA0yVNv?-r?_2)>%a1V2f zuJ5lD!qs#+_gWt7-m_pld3WzhRW|WhZtlb@^itzTrKH#d9}D*bawNs0g7NUNn{Z_1r+8&6R^ zFmbl!(PdHNW8G8QJ5C?KMybqfctbQRifX(syD0i@^yZ95bkBmo>g(I)l%Di{L^uxB zUnwmuwT<1ftI4=$%nE6Kk3d=Ng8+uX%Mf*`G?4Saz8vPkkHbox9!a zQ(63U(^b{k$$Re^;3p8a@Ag%Tw_J5;@$O^C7)=kXcc{x#3rL1FZYNjWojrH%jk>zJ z%ZFq{mMO+cv8GahLCk)0^U-m#1&x+Ny7Xl1SY?SNM>yq4*g1rG`hm`;FoqLF4c8}> zXv@&Ejb~AxZtjH9pudF59-E>1>26eI{xVAz@tUiPaZz}ZBO{PnD3wR|C~KDR)#Xx{LWMIpUr-R z%0IN#Vy`@T!o0q9(Xn$ngil@*l!OfJ0TJaq|f%{dnp0 z1u(+M_72SRCZl?%J(YL_k;`i2yCycY|fS=JZIL(O}hYr2HJbr;a zfw1cB{`K>wZaYzXe{ldUpZ+BEBID`1?k>&Kg$5$1*ij2f!3SR#oi#sgBssZJ^xDf& zj5Vd4C+n z@D<3^>j0MWnuvqv&e0woUA@OtQb*U$)=nN(rtW>oLbd1UyP7wql)?r3-_kB$5-r~- zuf_IzpENaJTDlo~_u+vHYeZ|GOYMJuofe)c0m+OkKeK;7xvjA}CnpE&OwMZcdo9gX zDrEM1S#ANAyQgQ6tLwK%CtZq)-0bY+b90yM+J$k=ogABU?!w~CEh|@^>h6lNw(OWS zs|~Enh_d+O2M`Zgx2;-L9E&>t^qx$3`-UY> zrUic639X+$FX;YKgt2_->RFZK7mXoo(@Yb4o7yi2 z(o3#|eRK2ArWAOzH$OQ|xw=W!>Cc;Kx(z0go2Ey|O?j=Tvd-PKxaUh15!mbpT3y%Q z+j98ySF=(XkwYA{uyvW&AFiA3`1W-TdA;oEiJ6jU^w$q{KWZq+8{`w8cM_I$iG+U` z7i^+n`_6w~bn1>BhH${v#MvBopQc5QpH44t#Y>x?z??29_}1B3d}~sp(ie=#{fVYP z)x5d2dxWScthU;oGVdIbJY2EH*)Aic;(By6v(8zQU3Ud^t~mU zY75t=?%b`oY>jx_;oMxnfpDNmK7Rb@e$wwsdHGkd^5zWx@Yoe!!ra!NG1H7$ufak* z>32)cC^%zJ@tx*vZm*V=<*Ba7ldXPndA;Vc;xF*XIS1rVPLEnS+Gx+k6E}f&4{LrL z`mMFTr@JdzPJgbtxNXTP1GJuT-@VH%)q4~%Vk^Qoi4{-}%5{p8#$K5?7x2HXTH;>HbdW7OA2{>}Ho znX+@T~q{xx1k?%cAWQudo2^C;e};D)r@V)fTbWkDGp2E32^3 zASvG}GbDvdbw7IS7?Vz?2L!07t2aM9R(B@k)ui;|kR3lh~Av#iuK@cq|&~vOgEk9z~QoF-niyn=8y}PPIG2>w+ zs{MJ2el9jzb&H3yOH7VgE|c*7vcuUCJs%coF8$V};CT7R=<}o~d`7sbGYW;8$H6V; zP?$mRiAWTL4Wb$&1-h(!)pMRz93 ze1=2h@i>CzQFHIr|8qh5|G{g>^B+Rl9{!y^esTUoTSrH$fBq)}E#2YsAOFNPod0P! z|I={(_u))X|FxN*c*4ie{q)Nu{lf{Mh7&;juSx&jH{WkxafLhhxyb&fGr?1X{>e=6 z&|k>rj_#Yy{a?-@-I@5y}RPl-XR2!;h%#%ChJKh^#<8TlMQvw>3LWz7#@hQg&u`3)KJ z!~}>Al6Z3w$} zu5S3*4m5~v=*=?5OT*Kfct((W4Mk(zU(MYg1Z0ekv7q6x)>`ny- zfhRf~CX%lTkp(!36TG~6wTFWS)E*Yftc7SZSc3o&^Bt-|=793CT#Y4ILEMU?f~1Fn znINj3Vl=IXEx4qtEjX`iGICj51g$Cr3wC3)r36+!0dyHp70c!p z89;VSCd-$rTe*4ndDI}e?R=?Vme>?3QX2uug@r-)(_lh*2ZQ?LB!sgo`u3^j$~Obt zuq1+DdlRf<(7v!R0NNORawzs~15dCb^7%tW_x;ThXYOLn|50dKg?P}bI0d5bOXrtM zf4l))lFMoF^ z+`ENG(r4m&hePI$0ZwX&By59?EkG)wf_Md{nL?Cumq_@GsX2(lvAFvt@vNOZTrWbt=mQwm4M~ zeT-x$gvDI-Crlvmv`SyAmFs3O1}``LYtHjaB10;FSMP{2`i*YkrTq8x3hRyE=ro+n zV*Gub!t47tIz@^}|9!n8OZYds^&@QK6{}m*#7K=t9sL2Q@P&>>>b4Og=yoNqA&@- zq+!v5sAv^95hhpH!3uH^OZz9@BiAfqQH3&bs`fX5sKSmJyoHbjJ`%Zaxp#r#H$-iA zs84bBU({u1P{UOK-3aib0{f>JsGq7rSpL%saEHO^uib`z1b7jlV2N^Aq12&n1pfAr z4WS1LqtFg6DDw{fqatjl@Qck;8DTWU?m@7fAxq9PkW{S@w+a=qgRo)f-IvMgS5h8U zJ-nxS@8NB+3}M@mn-)2Ah>G+=&kH>%FyzT}3b_{$jm?)_m~?^A zgUu0mAS}derqdV!LWVyVTH){dK}_Ca`-NyiL?4)DDu3y+nP8h0PUb6=yPb=}_%esG z4hJ{90Vy1W7-07!IgcUq5UNDjQSawb2pexhE-Uyh=(pw*jp%LYFV0=>r14dk5O|2d z7F^9H1e7B>3^-?k8-=D$s0>>FG{11dZhkK0!N9*hv)LcR`b{8y!2Lr3@dIxD2@pT< zz9E750k;nU#0w!_ShzgpUvFAF zKfa_=0Ig^u9~T(}JMDdv!{qQCiUHLyH6U{`oCums2P+-Pf8Vzr0fGy|J02g06h;+< z@Y}%%7@Q$IU^EQbM1??XCR%`x^1vIem&srTQH3Bs4G2MO_)KJR4S|6@fxa+kAv6xb z?zpIRXwX2m!I~cyLOx;unq_k_J0_0;CZ7T{q8bFmYCw24TL_cjg!(dvvkUjlE-Zvg z4xU_C&qQaqqTqkyHDvskkb?eq`WQO?OUqDOcR>9=1D)aefB(oe9RD>O|216yZ#e4f zzbxu&xc=X8_*cLCc<83U&+J={?|)s?7oX+)s3oqgh5#YGE-eDy^5?04xj#g^A_y95 z2$+Ybap5<#uw&M*E4Vlx`RA0tFC*dKAm71bKR8s1Ka1?A5gbZUXVI7%+?o^I29#iJ z?8Iw}AM?=fZ56oR46>vKGieB&NSMHYp$Mb6U?dncY+wLxQX>YbqKDM?BV&ZHTnv{- zzGMX9?fV=C@}q)H-j_Ti_QZ!~1$ZrYfGT8PUl>y6MzKIkFyLoLG6(qijAcR~U?2Pj zaejHv@mygOzy;vjfr&t7K@g(C6pk1e@EhI{X_Of%@ShPtA3hEPk(o$r1T-+_N;q1J z#}$oUw5A`K@TmIHh~)9Nn0y3Mh(`h$g5P8! zoI(0U+9UFUO!~Gfc!Eng7yq5*O9qQ}7J|k@vv_FyQU>=&-jFl~z+OC6E?D|Qyjtk< zW`QS*zj(pG6IlL};2u~|_?5o&ffF|<>fZNph(qN+BS6cMcbdGrk-w4qH8h3*)sepy z2VmvHP!1Q$5%Sp)C`Si|a`ZK|wKcU3AsubFPL#IMFqAWVaj&8ApOAn5@E__|_>Z=> zp4Nc#f7-+KpZ=L^82=f@e}?g&Vf<$p{~5-A{&(U(d|YRd{jV^c|F(mF!VnNL{NAWI za^If@hkm$+FIWQ(U+|A9a1W-zaXvm|1_i-Se377Z(4q!}1M4vqh%IdenO8d;c#gk$ z!UqOzo(Au1%h)M{ix!e1tj|p9bY#Pj0vGf@q?lnROB~5 zpmBi40}k*!ni>Crd73mcZXog!z!*9e-t@S4aF25!zc1t70NRGVct0AI?mNUih>!oP zn|KJokhd+TQiFkC8O9^XhY8jd8KHO?1|2;VmNa0{{Xi2(u=CQ`WZtP4GKUJ2GR-+G(UJ#gPakBgw6=U2LXc-GMU@}5~R6-Am7g+ zBf)$QfYi9qnBa^iBIgLa!-B}%qZq$LPBnf3{%~m#0)T)8;tUfs7~(TH-X)N=pU@BZ z0>q!$mwYfR1c~Fy{_h~C|H?=#0cpQKklqFH7e>N`2>TzX{JjzVRd5cB2#Hhu{UHf2 z-@h_F+;cuc`0IacKn`3Ae{)CzRnu=UxFCqb{4Mx>@YTr+W$&lchsNc(r+<+Khs5T& z6gp9nbKapsNB4mKpuw6f2nnR+F})vM{GO35R2VAm#}A--;b`dp074tW6SsapBYUVu zpsx?5FM3O5gkj)=H86hLdymQ-z+jD_Nd9LHOBNuSHAnU5pl=8rf_KKj_C-OoIXAkS z+XA?e-!Y)Ug!i1v9Jo6Zq-P`x01rLZgyG;hn4!bW;cE_u5pHL_zw0Q~yI=|Htv)A?IJ%U;j7y z_(lAufu6R0-}wj1U^xEspSk`&#Q(88{1<_OIk3ql*qDJyM+Un*6+U1-jQjr%?k^!B zg!=cMT|pWd0`7;gseb_Q|4UQ-KaKUn?`{q;Ws?DsdOf7%8&P>VsK!N9Pk z(5HXlB>@5>{l#|!$RB_4oqz@RkN?Tn0X%5%Uw#F^{qz@Me|uh*9Upk155=^f!T#L8 z{?o8O4~-Y#{6nMjLSVlYZOGRG|6-y)ek9@F0QV2Nn)qq%LdkwW_fj<&RE{Q38MB3r zDmJV6e8? zl%Rg?TDUq5-X51jy`O&XwFsN~_q`9{2^!R!=Z*hDg#QbT4RHdf{P)Wo!JQfqo&yB} zQxFPg(csj8@Llkm5FUERMhgxj(wG`-jxTUHdx4(6@UnqtQL8NZ-B{0`MKdC|VWD8| zZxDsdfPBEfxabts7v4;H0gF%oGaMNYZ!CZb$iwhR0r!NX6rBTL6vU4lO6R}`Vkp8e zE*(lg2}@KO0`KB$nO_55O8xkw^ixoZ&%l21hW#5rVhxr0p*Kpx5r#_rFdHRqT%l5* z-7%)B@{^5!$goEBi_kVBTa2R_~fa!j)|TT5N{TX z>JQ{$7!3NGuOa>a-YxOp>f=}Oe>z&){p0`ibPb37|9|2d_Wy_d|6%`s*#95)|A+nm z{}03d{!t`=hfnaF|NdyjFaq%ZKLUVE-5~zIGf+>xF_AoH8EiI)pUei|BF;YSi~_e2 z_Wr?m{R6mJqXpsAN#RV^PooKu1aLop8a}Lw{Kg0k@`1VB`tx(gFHWE3?t09LC_Hx&0uq9oau)kAY5kiCh_MXPB6EB z(jFXU7)*nwe$Xai+Z7=jo*Xg+7(@l8FVOOl5VC&(frHbGBVz|1GABTgUHqrSz!NzL zF)r}@!s15`1!OQdNG@C^V~EqZyh$IVEl0jQ{FU~&LNZ8ePF(5X0#I-O5CrGovgE-^ zy?~M+5J>5lF=qo$5_9Q>CGl7N=;;5ld9KtB(t#ycoRLUhzP9jZQQ@Pkh-|?F6?Dml zf92waU|`(vJ)j!kOsUAJYPgl3)4*FB8XV^DN*+(%aaZ*D(G&jQ(B+d=sR#zjM5Ehb`@0H0TY7XfO>oB?kP z5b!6Gdxn||KJnopV(p1J~Spf zlFhH$%VcZ7z48VkP#^*UL-44eU@#j3j&q^Mfg=Xv@e4&J9c;v8q@Ep(9tmUDL10-0 zfInejfLmZ|@MjRlqq(RSnZd<8dCxK#RKe|VEjrLxBoxq#l(BhI#Yef^)n^5%&+=93 zh3L2(M5b0ib}zigdyYd53ZBK*06qO0H~zl`>A@`fIiiQ?8zmS$<8coI_0GZ1qA9s5 z<3AfpISj`MU={?8GaN?ahOd9@8WR8O^|}77K7N7!>F62g4~YLX9M1pvk6gp}-!T67 z@8N$uM_m|B6Zr1`1xO%oEL`x9_hA?T97X_#5y1b#2+(05@V@{E>{CFxR|~^!_iAE3 zGAOhsg82!f`BITGtiQV#X`t~OHm|Tf6i#MCK4cj2VKN3J!sNTumX)Bo_U&GXDpoOTTgaQYU!J$XOc`o6AI5tKQr^>@+V4x2!z#`~cc%_nsS1MAR z1p}dZ>k@;wpcrmk2!>Ze00Cm)h#TNd28VLky@f@E$)d3#KNgh=p7G;^lUY>cDFiG< zLgZis=OB4!YAow8bDp>$L;mJ9=#a!SI9yii>*jAAtu12Xuiwc%bb5N{t~9 zA(G7%vVw0!CN&twWCx|PkEMZ7+Q-@$WNivRBEajYFiOh-g!@GD+3MR{P1%Ikvo9Yr z_vH*?tU?w{7La_w(QzQXecmCkg{)c70IwxqA?4OrPYd=zzBu)+{Jx>|e-|4lYz?^BJcY_( zGBl{Zp_;3FX;gnEEL46}HX8xo2Q2{w>AG{R(cn;YGEiG! zM`MOEkR@b6X3?2!2s{$XhF^&VP+9Q%B5s7biYj+|qk_MYX22vefvTjyI})<+kZ^YH zkpOtF7<4*d3blnO)YaB>AhQOeklO(KY0yTrgoml4NnnP-jp+S;BZ8SlYF;au@oIs? z(YOE2b)8IKLfWV@M#9qzwj_3cv}i=K5+GzC7D5^Ga+Xr^&z|todalO zeT3q3&b=*k}x9=2>&k7wtaNxPlq~m=PG3Gu^7ET)xr85Kq!{sD@gDU%Mt=t zYYd|P1UMCTVss&;#9sQ|Um9QWblx8+T?Xvc-_;Y$n7)-ipA%j|5OHauR{tm%sz#{Ks!2Dl-N78E`BQHs` zwT9o4{4Ljz_`k5h{%`d0%lr=px&!h*YUvE)|Nq1_jQIVKKaBnl zqyPUY^uJF(d=!q40QZgc{x?H_1+5O|boYm=O<>ekIJy%Cb$x)l2azdcUuqDI0{eJq z3hXhmC^R@SG?WF$Rs!FT1Cf1zB!|MWt`Gwb8Dt{|m0{Qf_AJ3yEM_Fwd4Uo|gJ!J> zF6wYJBLpZ82KI>`*tNj^h8Ra+SZocUQjAEED_+zj8~DBG0h>J>I?HB;vM5x(3B%U( zrTWnrG~_HcS9*!yCbScB7vlZ$hYh3I@X2X}Q(Ql|A8sx1wb8YKEMeN7eYLcBjmv}7ESQlfJY@a>nE75NZ{DRPa+b)vo?CEMI%wjj7a_r!xPM# zRfHqJU4#OF5W*44OfW0UVJrcO`eZWbk^E>(7+4T=Nb^Jb^zGjj{N{$rKz?I`cIm#5 zKP`-k4rN2!4H3pyXbcKHR1gmhlrD=I%z^`}dpQF$7Yq^1Y7iAc>tIfUM&WW;$kqf$ z^1{3X!VwA+#!u-W#4%x;kmkc8vm#;YheD*#LjXaTK5*0kSO_hEg%G|88sdUHTxkJ) z!-Z*hZzFh9=!+IeE+0^0X_|3g*a)~W8)l3tj0@meVgdF!CIij%f$eo9>K&O0uCT!gVT9j+k=bC&p&>6P z`Y<1jyeWZH;5k)t;yt0Hige;j1rp9%EBv4Ml7|*j6c{1d;0q?57DVH*5q=zD2%9J4 z7=%s?I*92@^NYklK$F44LY5;t00a5b;HG`R1YzKV`aG6n;BjaI0b*0>aA}`lM2q?L zp$@}c#Y~ttpno2Vkbc7h!0h!I35|{R3uQ4tm)r3@uniDER}jt>e1M#6u=e&yS6CN7Jqe-Dg6QZ@!du%o zLpDTvOB~4wZH@z!Va@Gv+^)c&EbOs(2MlD1b--HVkf(^C6%ukAk2*IS9P$CfWujO|EsQ{@!tW^(7)8j z(D<*8p`QK#{MSHVYZ(9iC$0^S1naSAIe1Zx#oJhtz<*=m|BH))f9;okO-G?L4&yDc z&JmBBqr)RyaF07obsGvf=Fnu4&DvPSg(^zZu?w-5^nHia;?-pGy59BF`X{!WE-J?<8o3ZK=At7Z=QKk2s@lsHph9y}9f4i=tXn|H_+P zmFGTx#ip}6#($ad{Mn3>AE6!NMOIAhv556t_d_aU$BPAGZ>eW;Bub2bcxfJdYAGgl z=FP*^o!LLOLv3GCkN;qAlA2(1RaP=-W?b#5(_Q5buXaymBuvlnRzPW$TV>{FWo2Es z&~sHGCWZRwXjW_K|6}h<;Gyik$A?sm7Fr})9upyB-`BELc3Gn=V+=-PhMBP?-yv&GO{L<;;#mL zEL|o2v9a;gsZ$GLV{NRhot&M|pFh80Mhazh-um5>7Fr66n~huKw7#(Hp(R@oclfH9 zpqU!Z{YjaAR?2`-GclZ#RI`*oiLfMDka8uiWFvl0$vIQukOxPzw{Q2oyiQI)K;TEq zy|axUKPDz5oI8Jhe9hU|*3XTNOzZ3mez$_Ol8qWy6#M!nk&>jPr8PA*+rE8k`SfPw zs8KI#YO>1T+%cRMy>+wNRx@Ln6=LyX8fh;R685|b5H-70W(R9)Lj2K!f>$qJ66YRQGcrndntyS8WJ*fP%a<=7 z&9B>EE23agQP=eS`*%t5Y43yHjR8l#o?9v!aO6HsM^{^W)db`D#ft|9Cn=FfDxDuG zRq1_2zh+(hmMzLtzlDBpeaCXh$laSuEAUjry=HHIA6lhOCN!K>jed1?_Wo4ID`J94 zkDIEN2s!G+SXqgb&VD9~i&MXT<;sH-;W-;Ox?5UaxRdQ%b2Y8}&Yco{0Iqw6osG@I z<6&eQo5W+sj*YL|q#3ySh4erlJRa|PW`TaqBbtu8ySvT0U8RlJw;CSwKD{|LRbuSe z?0a<;N}1+w2jEJBu5He(`mu0PbhI{3a1BlvC-^kr$nHb$gGr>X?mpukX0C{8t*1sl z-Y`>T0T{Gb;HyaL5nEmJG?y0v|<$o5mTySW~Ac6RtPwY9aM8y*`*Hayz2 zNwRddr{{y>C4-yaRV`|M9NAoV@7>$`N6s%B>Rd7;@dESB?cFlw%PN}`O)AG8NlHpeNu8jSrJgupfZL=- zT3qZa)+o2zWdZAXiAYX`0U(In++0@8b&)e+U*134zJ2?;btCe^--gyFFp$x{Nf(v` zE3Qy~RbOw+e0iz0;iN-WxuV19F=KoRnFGnRNF(1Q&pG=et4^Ef9&=f@fRe_%K0fc@ z1VOTGYT@)3X9FERPfDhZI{GYqKxJ9h%jUB`Vvl8d-#@k8bJrG~kbV32k2hfNwa=Ot z6m;pvjfsX4xtl^lL*IXRaZy>KY?C_K-{Z+qs`J8y-=Cb05s}dhylyoAQ&4d5zM?x# zL30u;wkJ97cSYidO)&b>bkFDB-Mh<{FOP|dN!%vX9QEPCRzM2YnIAS#JVLh&s~Ut$ zQn$Jt80aH1UgQ;^!rC6=gtBGlD0JUwIOs2Ipo=lXHd3N3K-O<^^i>t>=8_z#l?0ei^ zFwT0GBLk^6H#0M%(cY$M21dNCymj|(>ZVN!n{M37+- z`Q6}$5@Sske0f^DL|G#7K23#49A_Bu7T^rP`1!2}9$#CY<>0Vs$tVqlz%ScPmt@2= z6fPAV^FT)(SClY%x&ATVr14{CE@wPVA4#aVtCQ=&62!$T>|WLoXzDll&6_u4$Bs2I zF&VT(MoB5hVVjA#xcGoULn@CkCYI_M7(A!~E4tyay1F`GnUthA>=Qf8mrD&9Wc>y( z?dJN2?z3lqDR-EvUOFM_ser1g>T9cc$>Sdm89qEYIk{$>aPfu>c4Zsisig_2pHPeY zJR>;xL8{7lIjc%K;ql~wicC?n*YBU5U%GUu>giAG4jxp+(W=hGz9?O_W5I_gG#|JE-qjqC=_sL&OI@Bt9|pQa)+8%ucTI$TCJaKX=#~#!y!xSP<`Ej;oc$7 z#Im$-!e84it-ZZ$+4Q8Ls}qlDZo2jI<=ktRvnS{f7b^TGllX|rwUhGDOzOzV?+L;5_W(W%&dim1DaM-I8 z!rRxSq#X{$72Ugc?97=7E`*!)$Ev*N%u#x8!gzA(%au7zYNx=late#FV7PLx5XCtoLz_ueRghXTwL7RNi!OroSq}xw7Qfu!$#FiQik0W zT()-7?y+O#E+%iRuDO@GQFm6bz#6YIS>b5}3u&oZ=`myUf?d8G4;xULv{HE3=i=j! z4;1M)m$-=Fo;=yyK#1G8as7b^^QL++oBi3IqXJ2!o2%flTLUPRb1!t%oE?w+#SqB73d z^TC}vLem6Rd@-N7B=7F%=P9h6M~@yj`lujY}zM(p>m zH5C;VX8~k@18f5jZ`~TACOJKM!uW|3eVm<-FsrWs?y_v@QjzD1t5N>0kz(D2CP zP{6gz+ZIkyOWQ1<7B`4YNb;ES!u=w$S|CZBoUV@d9q4PYwfRo=l2qbY^?7dTZZ?uH z%!pzB)`zdkioAQ`rA98zlB_#H94JDw8gb=vw1J7qOxsh^!id2M_8X`9^IPB+?LWb4 z9Z{m}$_6DME^Ui?E<##Nr_(=w_&^N``U2<@EUu_`r<=d~nOUrG8ib2~TA(v;eoI>O z6GP@RGesQkwXh8C+{HUXky9=yPB=|m$%Un=J|?f$&Y*wze0K^NS3wt>zGB&+@~6d0 zQ>JVdBY2sQE?uF{@_bN~Ib$39)5UO4@gtf#xFW!ac4lTSS-iO9uiRTfY=g&zU~kJX zR?6L^4x z-<1r6ro{(|-M({I>KJ2cbM?lW*ab%w6?d$Qr+8GFF1n9TVXCUy&6?GgM_wBLy5z;y zSmn}9ta8Re&FD|Bg=erFYa-(OblszLOTRz_DJ#c5TRP^`eB<3IVoV^u07-NGWfyPn z@8?8S@7%k$F*SABvSot?4pg-FrQD+UkDA*2=z4Chjj)wuozS*7I=Lq=h?=cX7p+O1 zLtpu|wJOj)U2=Dl^(;hf`oMwV=a(N0rb~RTu}@o~SGq~PZoBDUS@y>DbvfaW1h(EB zkdmLQPMNMc4dZ42iO&gkHsJVR zxz9Q@yq@m*=`i-wZ7_!6Bu3yGO~a6x*g5m>_TGd4&BY zSy@@a?7^|cV&eX37fJ`6`Q9=r&TZ8m=irgYc6fd-^9g8aDbPG|VB$IaL;XeHzbzXo zElEC11UvSPt%l%q@(iHqQdybkkRe)9s{olLo3!jDmNCw@eI78}NG<3l;*q*xiA!qQ zbo12{l)a7yy||FLJ3cB*@Ib9LH zHS3B&;lY^rLAVuSw%KE4K3z9F;uA$8?zR=4C1@!jdb%cK=);1o>tuZ{e5|Hb)_Vy! zTF==wKlt|GiB}_*w%LnKyA`Dy^1#K_H6IYwg>WE376K-u;(1g-TYEI_db&OfFsXuq zf)giB$l0W>IPVb_JfP^{qP7?E+s4V36zMkrf^pn&++S$XMafAeiXpL|ZiUUe`^a+U z$*E35GFacQD8)R9jhu>`F;jjuUi-$V!NlDuto73~7uD@I%viKAspyQ-11};c!KIS?SKW)#~eH3Ay8w)U8d|Ein0EM1FPk)1JwqGP6C-rk}6+9?`nP+`)d6 z*bV&+)dALa>18{WuJ2DNxXjcn4SI6wPI=b0h2OubFWyj?w}8EQ;CPb-QDv#hKoD>O z6S8!JP3En)50AYAyNBwj_lrG?-0c^LJNasDes%S0t0SO(_L3DoPiLR1>lBl zZ~Ckg6>XK$xM%W_ieSMt0$P&ucEplotj-;Nl%A>+)cV;nwpFTRRLT4?!q=`$`SEPI zXj+<_rDc<~?_EGbBju-G+qP}g#47iojrOjmR7MmPq`sLkG1djJ+NckHa(8M@H$MTZ zjjw)Nc0+g%{Vwr+uopd$)jee%af%Z-Lx#=+L3JZ)s+i4pYi3($~+g zPaN*1w8hvk_D05BtH#1-l^1auHI3(%PWt|Sxz);*rmH1qz5mkIT(hY4q4CnCqvNAi zYP#L@Js1DQ>*R!6Z&rvcFAAWKke#KlV}X@$sia=B!mH~d0(VXvcwoy|{s<&+YyceV z(xpq;&RGdhwW}!whsN0pdmnw>`sq`q?u1rJaw$kh44g6ALkZxVOLkz>Q}GqH>v$4cKg|| zP`{z!pKfH|+V=%FX!wM2BS&Ud1Xt|XR=a4adfh7BVW04y#m^;qoIm$1qG18;_08{Y zN~4*l5Bs`)92kGd(UEO%IHLa1-o0^EZS=vVgG#5RX3Ku1RfZa=9C)|wyOyi%6_wjA zZ)~4}(?|$dY9ta#L_}nK15UmG`H*xg=<4+8`;9Shna#Yn6x$5QYzF zhD@ofDyVm(dzuzJ3*; zuc^6Bj3gzH6h3&^+;KX@1(()*H(M21zx`Eg%cty|9790lK!(4=X5uTUV{nd6PU|u< zzJnviIOF*)QTaua=O+xxa@eLLwd&lXJy)+4h#i-GmXPpjw~ejSa zixz!eAx@GI9WC>sL41c$vH0S#WX4%z^0zN~)(=`j%+JrC`r{kR%}qi^R#w)c{z6-A&Osok0mi+j^4_Qi zE7HEzx=SZdP?jwTT~ZyJq)y(W=sW`SF0uQn`iNcTQY$i*6tk-yn=|cRLCv8coA-K;ESXW z!+m;J<&#s9VG`Q{2!FWAm+jsM-B)?fY@568{XL&;t>xPm5=s(pOXt?%7u<5qX-G({ zQ*wM0J#+0jGsWt)YXt&txOp9SoIdkpNV-`4QqkSFZke86zI@h|t>fj-mbjLbmJS=M zQL2SKlo|-25|&ii!q`N_=Zx^dk}+{K3f+>_n68)A!PePZWkdjC`Wc z{>mIJ^FTT&_F>e^%j+|>rFPEVaPnrdm@eaVxbL*MiDZ{t+I4-I2e)tMfE+Pe*s_S@ z5h-mIGDY@--g=8W53Y?1(YPsp*r-t&R{#pE$wbt7LrdGZo~zW9PZUC{7tcExRb=@)lqi6(f8jT*Hp zT{(3B`vEv5w{bdBTZGphkWboPhU{EBc-SZR@Y@?c0q{V$z-x zE8Uv(%!Nmf9vxD7$aI&f-oRvuY|n|Ml8I`X+F2vZeAb0}c)Y0DwoUM6Q|eZaUG}e= z2&!)lP731GB(?4xkbP!b5&N||ZRgHGR_6+?iq;@jw^xpox3;k}3Jd?V|z(x;C%me$;GC+w=t&+4^9V>kQ z{X+(8ZqxSnH7i!Es4m->_$_e8>!`tV3z-+dQFd2YVellYZG9Aielf_36fJhH*VNq zIeq$KyV0TJ4s3e);RR*)?r>r1{F6tMH_49n+bL;Vb9$ley7y_C8>(VA4tQ#$o6IVj zy>DNz9&^_yn*BgsW2MR?^X>`=Y~Hd3NK_VjXXk|v!1=y=Vut%_plNktfEan4%=x?f z?^i8YuPiuh>w`h*b{2WXINYh0T6#{!%gMS9j`QC=v7w6z53@>(xG5mIj-s!x?{P;d ztRivR{D6R!FGv+O2q9t@rL5pp&Ani)lHlFJb*Uc%X_d!3(`29NRv8^4&sZJftWq;B zZk);7ok+2zv~N;%b@j?z83z$0biA0@`qX zzo<(%9w~ZmAF<+&*0r?t-g9ZAv>elq4kOsLE~2E(x{~jCcz)A|AI(1^NVL#xlEh)( z9zEJzTPu;Yc1!l8cpX~hnk`#Ihoz4@S%3P);ppf0&Ye4vB-aZL?;Oyf;@mZ?Wt*zH}~4#wII`S<9eA|LX~YsG`BN`!Z8TXg1I zW7$cE45Eusmu8wCNkeuysVGT4#!=!n=l+4 z&Ll=W|MO$yG6{2MJU4YLwg?eti45{^P5m8M>-rU*4~I z>N|1kYPHfWTa-7d>VB*9aX<6jptUm342P6F{21!0UTw3nwy0^CSXE4P^ypEe^!#o= z9)^n>FnAbX;L|NED&_80YAa0%elJ_H;^XI0KC70o-JjSjS9qQtwp#cDJy;_vYoe9I z)P1+2n(Aso)Mh4qST=|i8><;NHqJM9`Da0ujFcCSYZ4O@q>7dndw3Kt89ZEKM)nNi zOx$kvjSORNZ*RaW4y;k~cK5jd_St+HAseTdO|OQ^;8y%K%UVE9#+$%8e(Kbdf>LqZ zTG@$Vl5Cx*Y4Iyu+;o;mZyQsZ{_)bKnR5E>j}H$JeBCr(JfTkGsJIMn??GMt*|~Hb z$DMdfYL3t3>-u{ueckt&-nq90hdU`2bf?%QqWXBz=?Ta_MsU8TZbT!!4 z)>6!^PhPMS%3nEkAUPvaezv1cqNVJ}sJq{#LXQm~O4!)gB$9{P8~P^A*>4=V=DS8z zadFWrt;h`%!$LG)ofx_!g=KGPa>(h^Dlvjap|Q8qrC>@@n0u5{-T7LE(D8=?gO)sd zwtV6+5fOpVnupF;O^ve$v2e0xjg-Q)+ir5Z&v|IxzngpQ?y?*y;XSq>lXb-V;LxE% zSF8{oBJx33@@V=TnE4>Pc3Q(w(?@QK@9GYo1%gY&3a0$B1Syl%7DomotsU|0j=7fD z2P7}AZDOpJWvWMP?87S?E{k0N~z6OS}DmL^X%*%5qRz~V{7yr7_) zi`v|;jE^iSz0lOue2Ei=l8%ja$ej?~mt=PY}> zZ6@On7!NRTEGa2`<|h6^SZ06fr@g~*WQ*)^W5#@WSY?lk0~=#SPO_m?pyd(L`Ncjl z^*T5`)}F=}$;mltE5rm#ZEZHLUR1Mntci)|Nvp44-<&(QK;Ay7f{NYyRlbcF&Rg*?YHbYuLhQI9Xp{nv`bz)bh~{ zhvhC-q4vdod7;-U^0o?s5j|RvxmmgP;XPbY%!!4k4wqdRTZdnG|M3X7MVB{eYaISD z@rT}0mc4K=P3!FUmNToQS@VKD6{`)#uUy^m@$He!jl{8}Jjea1ry8$>fJL8><#kpR zH`{mnlc5PhM~@!$O&V``Wmv#r`eOs}5w)H-2H}K$5T2eR?n^&Wuvz8ws#mKKIk{1|Q>V0m!2G08 zbH+MB+JX2BvaG}A(iOO+?5%M(Cox@g@8O@B>s~NOJMo+KugZsw$ zajy?7`tjY2$vh|`Kl$@OM0eknY3^}(5rMHbi34%N#!nFxn?J3!bacQh+@l9mV$N)_ zl-XWVg19R%lj@Jod+Ib~^l%{|p%t4X?kyW8gcA`lEl6+P!X6WPT|ld9VNC5qh64^~ zCS}IPjoa~gooTw}bxPc;y?ceEtqd|m$wQ_EPKrC3TKkQVJWBnRf|k}OvaMqH=>a$# zVbTEbAI`vk<7r`nxc9+ZUtTvY6s9VKWFB=*og=9!pyuNfOQXFX>0s-1x<$ny#sW8O z65-p<%+|Ph2W4?;rBc$;1EuQq3SXXx6vAD;eEE6AKwT+`-L_flmkl4TNX#vn&B}ax z)l1;IX(|P5oz>Nb3!)w=9}|+76|$T$*uvt=z`?CT1EZ<=7GdV$m0KJQot(@pF3V>L ziFsArySM0l@nD-&qKK&Ik-Ae$HiyNFkwlsE5^%UpT8g!;?;M(RmOaMJ5N6SvKHNI} zt?|yqi4!MGXvhi>PH6COtr#)trJPm9TZ&K-AP>PYgf)kQbN201*iFzWo3uP>e5F@D zSywn-4`-V$xoXY#J;sCLHxP(d88z2uEFV^{nyV|kqd;e#hlewj`U1$>V^r@pRQXsa z8qQ~nMEO40nIaG*@34AVM8r#Lhs8U0?%ci|sh%K~EPRu+aQA+Xm{kXNm@jd5Ha~pW z`oPIEkDC^I{&12J#C>^?A31#dgDU@ZP4g8eWqvt7JUK8RH6>NYbAJGCEZH|{viywb zON%6r3>hzFupmm|=sl~j2SWx-^Y+eoU#e#yVK~g;nCJe$8yO)~YFN3``?iw})uKxb)R`~tO3=tfaRT7T^OR;9`AsA7LSxfCAJOH9a}-A3s{i(N ziQMI~H;*Sg7Od4Z+)yZ>hm)|mJxmnGzPd>mcQe>3I=Xz~_e0Xt*2yyBW#c|K{&m<^ z;P}(MI-gLH1+kP zYVQQ$66FOFgk^BKCDg*NN3v(0jq_F=J0zkZ`Lnf3TWhOB#<&+L3yOkD7 zG}+2xp5jp1mAKjK*0r2d#ivNuUo@gRxdaDqB7a!-sz>M{hu~o0IIA4For3YQ z;$~{o%4}30OMn%%&+4J6^Lon#!Xh6kg4Jv0u1mSNR#rT5x4z!-cYwn^E-;B-FKVdf z`XNo#+emP(knh9Yp@qeB20N`8;glEs@m1m&)r7iT=@WF%AtsUZ+c$SStGVv#n;RZJ zDzQ!7uO!Z=E%?O2gV(7y^H=TlRhv2Wd(?+>OQ+znk5?)L({V*U-!)hdjwbAxoGD!Y zJe@hLEY%L2M?P4SCTbht-rqm60q2`{bJM0GIh)c2?~A=lk0!}HD}OQW_HDoN@^`C~ z-zicy>%O0Wy)wbx0@t_6Zs}}Vcgw=Qw>8rZG-k6e6Ayw_bsN` zdy2x|Rjcaf<=-By)F5eW@NEl&xo_X*d{2!a$ES}9R~`wx_=fEi8@t6@^-a^vto0cS z=YMN`H<3!slUz0V;at7aO-^6$2VTTyEzYr>E%TmMb>^|Jnr()W$JSd5ht?Wh9vQLi z%|1^GG60G|b-zw3b9!vl=iEx6dMz=thfj-1`ub(tCzThD7nl(HX?b|v>Y#iR37dzP z)(&W{Z{3ib>_!`S($6aXDcJTuluA#nsa9@oyq#gEat*_tUrABi*7joJ$7MrB-7GYocu#-yt!C=P1+Dd` zWn}&uJ9c+$%j+8%`%gp|*B%Qg%TOmjo-y(9=#iO^@FkXa*mibhK-PH@+w5zT7*_wl zc~R@bA-ks}gdTqoB^+w+vncj(@l)p4Npr%UX$D>o(%QUs(u~D*PruvWOJW_79>w-e zs<~=aRiM0F%yNqBV#yPs69ol|tfvhi2Ux9}Y@f7MOHo5ZV_K$+w)Xxkdso`Sh`fFK zrn`6u9!j_`pz!tiOvPP0@6~15B}z|S=xY%_(QNPG!*43{8Xun&t*xt5)4_oi%Bq=M z74E*X7}>BvJGSM`<&QN=;_JlBlJf1gq<$%PNKP0R9a_4+aDUOqIgHaAHf;)WpOvX3 z^P{ zl^9{d@5GZ68&_VPEQB}7ma~|2jwx=Iz9nVNeBAz3uA!$VjMr~`seCM6p<7y1UO-U-#ozM-Po}yRUfBt*G2- z;PdlGspb3j?K^zrh}Tlw%6FD)uaEJT)Q$P<=pm68e(#O?^oVVW)r5y;U!Q(3_8D*T zw)*ay^1)|YYK6j{EpblYw?Q>)K4Xjsu3(8}%B>N)FACjM*6cK2*m(KW zUjvpXG|3)+v1g!6q^FsA>$evZBb7ASw;LX4-ZrN{d~^Fkd6vV$oScythR?mfRIlco z#b}9FTQbf#X37-YPW%y}C8kG_%>48zX7I32V|K6bT3Rn0ucfW6SUt-?Yf9v5T>8hN zqN2cz=;?EXUX?oE&>y3?bL3=;170!1<2+KDzZ~0X8ly0&=9PmW&?)B z$%@Q+(D-W0kqL{8TxCDAFSSJ0KcM7$u3x{tSTpTlIq{NudHMDCyA}%KN|ugNJ+0M{ zyeQq0nkc(t(O~a8t7ARrU+WoxXFfj=+QBL;PSRt7W7sf2aW{;cC5H^s)lt!A@7}kG z`7PmLpjVng2`NsDAaq$Hrmbn^kB?I$FEf=&ckcRVXER{6*kmF9!lvPiHno*XJC9m* z&-kN2+$w3^VbVH8eSHrvdZjU2Zu{I>qIdVt$tr)-aQ4T->evH!%+@N&SiM~Da5!TD zb5hMFF}oXu^aF!iB}ZQ0pI+{o)8Jh|b6H+Fc*9Ol7nf0DFg>0A@$izmeL1=jZ!2G1 zOb(<_M7+*Zr75rDeRDRLd?;Bl-f&?>R&vH|9jg)c8@Bi>t*}^lZuXXg2kCWpXKYlK zrsO;6R=OWqcx&>MDOakhs?P6~5b%gxSNBy%b?+v(iHp+jXw=Im#e zCYj3H8)*l-93|?G6x3awP^2zF%hH#lJY6~RY=)-1_a!6xp?5)Jony|N@EIOzp+u%N zzPt<$u}=TMy2ZtLsZY=u#wWjscn{vgwRYQeBtp{8je&A#9fx^p2_U-$+HFDUZ zZy)mZOr8`cK^|&$^D${peSrP-ztolDEDN86yFz2#2BjO}sSE5y^ME;7;8jr{)YtFPwZh@d0Y`%co7rffF(t~c-6=G?}{ z92{=@=(X8fPh7ZrSysHVp=t+C0w*jY;(1E1>9YKcWy@O&3vb3?^td$cKzW;cV-7s^JouK&(a^iX=_zIR-hw* ziyJh}DRkG%!jopl^h8J33SN3Xh`yva@?8Ah850VtuN#iENZn-?b7AUR{JVrTnOAN0 zx3Pz|KDNS9s4i}92fR-kXlVgro%k87sh2@a*(FiCPMxCOJFs}Gp{RzYjkS$5u0+}Q zoVnun18*u{8IlX8?s!c-e@?J;m9!cw;BC^_JaO@Q(_8m;o>?OJ=&9I_x0k7rnIee9 zz|!M8c95ECE3&h*!OrBORGndArcfra!^dJRklek!L)_fH-aq16Sm{DlEXRcka;AmTG%nXY!a&k?8E~83T9NM)DSz?+gQDhXTr?Y76q<9w>my`_~ zR*lnlT6I(<^UM|z-x&jD`I|i=4k~Edp>TDA{hXDP4u3>6N>@!^e=A5w%5L&{;uO~) zt=R`Rers!5xbQ?A?)2l^5|Pa-=QtbY2W+r!{P=Nd+oy8VC4-c`PaU5(A~1R6G`j&! z``$HXxK>rjT_-)O4PzN*8raT!^l4{$(WQv5?txk4e9z|khsVelS1UU2xtgX~V-UT1 ze3aCfmof^=JPc2K|5WY(WcHnnZp&}4-FNJ>NwI{$Uba%ivdqi(mW_9O{j!p@T=Lk+ zOi?`k^Si1amE`1=(uq%7?7dnABHs-QHJE7qCU9G9>c)+_&|quiWVVN2-7Los$L2L! ziJKiJ9?Q@F+R}33+NfH>C!)Zek%oZPyt=k!fS@2`TTPD{H}{L~D_i1Xla{1@i5`f zv7KCgm{KMa*o})PzaF7JE_-i5 z8h~x9eb$gte+_XnEvZ${S*HaIpO%Uj4UGUWX=-Y!f@x&GaWdSP;e0sz!u*OgB<0^y1S>@*;E*y68H-!H0RZ+HMrkQ2qa-9= z)zoBdAAX`_Yl`J*a7su@8sg(q_4@T|0KB}c?20l|qr9EXLZ7~jeTu&`Wec*zE7msg z0u#V~B=83Fy0+A{M}@5A!^ZDZ+g(tglax0-Gc1Kd@i=hsAcIDu1qCT6E7#vUSam$? z#i;bja&i~YB;uC&8Sx%|u+Ct@{IvtKO|KEA<(JNxGe=2DNmNvHwg-@9>#pKJ=0i>0;gYyCPStq2njIJ#k8#7C^&_j6pAouI` zO&dW6O-)S_i5G(N3GvfckIT*tO1$9Y?EIpxuCBUz_nC^vDxm^&!GU6Qd%>c7Eyv1Z z(gViLwb}Q%@cyuuTgt!4Y`=FM*Zed^JI6FuajmC|>!NIv9ESbd^L8f(e1A7hb?(>J ziH_%g3_k4?W3@ff&;^IX8L=&Av&opNCmdoG0;6{XQs@+(%fK1-uE-1+w-$3qfhhP> zBB*4FaVR~6Ns3g&wpi=P;SV&*D8(Poi_eJdx>y9r$RH{?2nk}){2}f;1hm9LOwuWl?fB#|!}hk|`sPK& zYSXH!vc^8Jh`K0fPxdMlyvOLE-NduP~1ec2MYi2@OC1hTiT*96ay}D&jjt z{KSR_y#aTPsmd3plmn0{{UYwN*m>0|+L73gbwK?zf!0xX)NHP=CNL^4*c5+)3f>8N>43xiTk#zDcT}(#1E_)FOs-JM z=gz;wE6j%%1zR4d3k@tjDFflagG~V7ZqUgP^cY29(xRbPC=xHu0EHew1+xWLQn$ew zcvJ=Y>MUk(C&RSkq5?c50Q$i0=)VV?n}Qhr98Xwid}UUL0L$%U09}4#ZngtBD+sHJ zdiWw@zQcI&crj|{Ej^5Lgpi`)v_LmaV9&zBuM+Xln-uiTg?)XZEiiBJjKm3x49-eyDqtv7b~I$}(770jEGnHE5*~ulDRi=gabthfZyZ0D zRdF|UvgbmG`XB4~+RA>q1NSv_^VRXKg{7J64DM^RFIIb~Y|Pson?vj>yucgWkOi0@ z8#oI&lN2L7}Xsk%LFn0vAJ@PoDm>_Ck5Dj&3#f=>e z=s6Iq4W3^rK2V{rIx+()9e5}}JL}63ux0VnAz($i9YQDrid|H|d!msb5;FwilSO5R zlQ5TtedyoP$;rW~7XUbAx`hCX0nRtafFvN=SZuf_lOQ|dp^zVCoFLCsdN>7PhSTX7 ziT4WbbW;~o+g`xsl<5{+z*qo70=Zxjb_G2W?l7F$rm(_80M7s{jY9J8GUJdl`2q1y zrBf^lO%pqeeFAo^`S-|>!Zd&kS^kI4ssh}dYS9X3EHy|pt^J`uDto$!e~?TQg7^t3BSxZ(~ZYfc$# z&*q#*VDB732qj(^*@%saK^QRb?8N~F&+%^vy$t%3nEsroYG??kNKhFv1WeL_jkF&E z{23IMB2V=ANf>y98??RW5b)smq`+-h0iG0yNGDS7q7~?nP|!Maho4trQot!0Fe_#_ z61MqgZSSTzu3(pnV zf0jh~iQwpFRSM6^IfqpXL!I zQJ9q`8UdM-L109s;BX*t(<$hg z3J>O*9*8YASQ}fhT&4Uyai~Hm>T#A64N&g%qBvJ>e*spo)%!>dW9F z1EXRf;V2qVy#*R!jL$tYo}+&vbviNypwrxO`~V&xt`Wfjk;US8Z^m=`foC!qHmwMf^uL>Z3pY)BmRVM~AT1o#PDkTYdbuS$%NBm-D`-b5sN1P|D5g z5bO!;I8Z;-K{LWLkRWj^C{*yBnuQ_;8a9O9eUKzJg$z!T9X>&K7ttJ5W?*qp0O!L8 zGyGJH{FvZegvS&_@PjBHU}(4*I-T?J7mNr7fP&#__`kWMx*9qg&ke5Bu?CsO0Ha0~ z9o=eecuGg^`4)p&f#mNGzdI4p$SBAhB6#gcVzVhsx)+~ftAjZLdM4)7;wq}yc;mk z54mtmAy7Gi0Rp%@1u|DGk~vpp#6)KBhyjM+G9MI{#Y+RQ@-$>`BCMIZols3zd8L}{}cA>mw#}5i2tpj*;)UiuC3Xx z|M?TCU;opu|LNEN^y`26^*{akpZ|aKKU}@eEZg3cI{g=a{>M~6vur!-e>mm?{BJsI zfl%}G4%X?I7MV1bddVKr7Ct^J|qCyb_w>3uLAB@w~5Un_tn>%1N~ zH+nGl1Xu-rNPlW_(^YvBMvFnGqFo6TK!S!6(cpw`L^a`7FjA$O5Yd8j&=I0a7qkRs z_l~~z!U}-4p7xqztNc=&cY3(?2Z+qk)4nZ3G7(KL%hNBotyVB0lzKx~DFK z?pFN+jS0D`AHEAm{MINW-bA$P(m2*B?TzrNcDe@yt@@(bRA~9ZUmu#maI6!t8AAK= z?^&(Ho0uMySm>N_49T#2R=h>cQJV4en<|J!CzTP_7p67>JBtfyvDQ&f)V-#Qw-ovS z6*kQsph7iN;B{wBCx+L~Q1U@&0V?(h!1i_c&mhFKXa595)Jm~WF!GbZKZBC1DEudI z+F^Bjhm=Q&-N0x?#}<0e>S~VhE0582R9|;c=z>=qRVOF9cu#6k0H_&GF_i9VSXoU7mbYD;j_V*+6^rsYh1QFf|fEv{H z*9!7vMuf(Za*$}9G)b`7H;ko9-R_<8ofn7u950vQIC$2tZu7;x$-$iwao z(4NtYs~jb+D%8))6Mt^_3zIyX94b#l2i2N7&(D@nPZw9;@t#-J#=t z1mL?N&9RYyt#ZnmhO>hhOqK!sjUL2FfegePNT?*l5sGh!0vpYnM)jwVs4NvINBaSx z6RT~`2#scozBqjwO5LtnIU=R@oO9h_W6%@O4^z)wjauE>7 z{yn@?#DjPLX;S&GOuh4eOeg-&xqq+xUsFv>r!)W8RO`S0@ki3{W^Y{n&s#Nri~FPB zTzcgGP?-}*ji8{ek*J|mXzBQ0wG&|47*+^76fs7)Z#iGEU~YGN1&U||)Ey0rvrAwP zpb5?o1`~;i<$I$7jS=AGSmVwa?IqEFr~%vp=-oCodCK^_*9 z=ktw2WpRh$k6MiISbTfSOmZl@4=uxDy|&!r9{CGfBxg?e)N36#N6s+%wnzSaGY;r9 z9V)DF>{4k5y!4cMsM`zNor?cs;CtS?`Oz4{3IqVfAU!QWA_7%GAe)86{##C%YUdf#;=Hfy~%$X8eQc-b~Hnhp^PM%=sIH%>a(Zrx%GPzyST)uJ8-;RKNW3 ze>wHO|MOVIzoh?HSJTw#vj6L7>Gtpce4L_09NMs z>VkH6VD~`S42&6fGS0)ima#BfH>e39hcj7J!2P1Tl@BaPfUh$U7gXR-K;@3Ef&nOJ zO7~~JLCm>8DR9A?*2S(<@&7Nu1KUubtU$zY#@*zI9FrU(;=@C=@y`o#%i-~uqiLQg z4)m@E#%Krc%kar=cpq~IM-L~f88cm=@WF=y^PW*a!24KOI-5ILIl5Rm*u#2%}KiY%&FMHpBa!v2`H4%t`74aYTJt^;SSP37l*<;XTq@2pZgQWWBmb;&>!t^w7VDW z=p4A4o`2>e7_{~eTm<9M-T_eXZ#zuw&Pe<2?H6>^P7`(_Fbi%#BgE|pB zK}>rg;7J2ML1dv%n(zr70W7HnpU@WJlQwDq_uCl*WJx?bXUK19{5MN}dv`o04i5&H zEk58GBHUvPCkH*maEo$|F(M)z)WO_~C*4?Ys}S%as4iHflXYZFEX;xrD%grJ#uxxk z@Z`M2pa5^NA9!9Zp7YUmD@ug_P@@Q-pW;Nauw+S6STPP0UW-Az;A~O%ou-Dh!N+p9bPZ)ym2ND{DOds@FtrJT-PJ3 zh)BCNuyK3$e51iy;yY|omA<-3B2G>8U}C!Trq!Q7+WOkTH+Yf3rc9k#%mcLoxK6_pfj`N9^p( z;$4N{x@7*{eep2T`AZAusP511N}7CD*fg{_`b`A$5(4I}M?W4NZ032onm|^#AD2)7 zo0O9yp#OruTyt+u7yRY1Otc{Ei~s@cTX7UB0+0Rmr3wc)LMJsv`%(Y}|GlMPjs^DM z-0I<6h~SIyf$vldy$gfgxj=20-WNbXojgIU zs|{Eu*L+Ag>SCSeUGKl^;~;16z((5H9;~}>huyjB>*lNBA2yKc_rm|LQXlsJ zuwS$O?sfmyR`2Zp4e(p_e*bTOB>nDfjJN-X{eA0i%>1XP%^x)Z!kk;QZ~I}i|E@j1 zTQ@H4*4-k#ns)QMaOsi-6-qo0AN;jC`E}_oms1z@z0s*^2X`;sW^*cIUNJh=?&Jri zhZmd{xc(}zuLhj5-S|1c?8!kTRPoVMxxRdAuxIeO>E&}J!R?Ay8&frlbmLZ`lf`?x zZ-WkdG@lcOp5RsB*RF83(cdi1K~(~jAv(jV2$2aLH*j#P*f#;A?}O?ED2`myw_f@1 z(kIadrryMx-yqe|F!BMo;L5=SIS*yI5M?=kL~f>moSlK3b1z11SVNfJ3hAn?v$A)# zbaFwg>|GoXIToTI2jpSwe?`R2)YjF~8BvgzV?n1Jynhu5eQ@Q`W9rOfh}|&{Vz*p@ z_;Z}~sozd)g2=`3-&^#3xew5O@Cb#@oggWwU_tyqXXrA=W~Fa81p0dJ`0t?~PMh4( z09Xt-=u_wm;`oNqXXO1G!}ujOz!|{L_ko@g#8_VrSN)eo`cvOi_vb%5(mV<@W&S;V z^m6`F)7I+j|65yEv;Y3@A4!w2;~ICu+if*dHz%;q725Tz!{z*w0c$1O8@mfdZ&NgF8+V|>Hp89PV^5a9OVI;93G&ls;-S_s2gbLcJ%Px`z}ej?`2@5mC`vpFoGM{>8Cj@Uc6 zAeOVOoL%_nmD>PHkk8yd$6s=z5w$LHrqH7Bmy@&7t-G`9V2pU0f!Gv27}%8J*?%+ z!HX=n7$O7B_4v?&4IG-2Qc)XGUP%J)rFjsEj*1jqj1f4Xp(iF|UX4yCC}`{Ek0?_y zY%5a`0&799=dSh=vb-J^5ZdR83zIz~65gLd4oF>P`OF(CIw?y6Wov=l?&FxL1Q=$OiPTA_4w1Z$GUQh@8CX)J_?8 zoRd2*!eDJaJ&*kQrSU>oED*<1^m|3 z8~soJW$$l&p#Lu4|8#ZL`|p4Jk<^*~vD0Z!#EOboj z*uj4qMgP^QH~P2xRp;Nh-sxYb^ZhSC{~G=D|3^}1`bWRV^~?a!*GNon#!8q|X9UK{ zqD_M_!=Sx&?{JBLrntRd-EuRaFZYi}twkh%=i>C9_pk zE$z`u{N2Q;cX3k1Les;VoS(`pw3>=P+n->9H^PFv8$k^kC+0ny%BE3FY{N;;vuq8Z z^F?^H262(@9&#ESP5u*_3^c+@KhVpcTF~J-aiL;acV&f7$W2#=!~0f z?CLUISr4{iq>ACh2*yA&!Q+kmsSya(-9Vt)`L85nSY50i+pGC$r!0Ma|6 zoKA|M29hw~z!FyH4G#PSg9)dhxTI0rF;AuYQ=(8FN-&wp2%$jiL9fW1vOSib#E76U zBdC-}f{7cI)jo(B6efv=O#!I*(-r_@V~4W{CeG;JzSZ$(MAB&t5+GCy&ab}JBQpWA z*`PCX=41*9-s(04&x}6yiY{=tk|EWQ*o+Rfj8r*j3%j$ytE zlc;nyHu30uT47IJ*3D0bz~2~|5fVy;D-n(Y{v^@;`&yS{P)p(h0-w4r;665n9-P5U zxG+g!K9~b}f{AH}9}Lq<=`#|! zI$vH3kOxHl?a2sdvKY+vHqggD)(vH_*f5BK4`9_4ItvCiAecB}nJBIIsTEYa+@T4( z=)TuxFiB(@r9*WGG^=;Y;ILWCC<+kY;FR=kh1;G?{@>FW9m9kj>RQ zcdU$UDqwpE0NV&fg-&6sa`qJ#SC|BtgE<&UcTj1gNd4T6bTcp&0}z3B>bpW9}ULprr7Cvz)n#4DY zSWBHZB))y7)1JhUB(QBMNCWl<_grHFS6&CZFKE4e`au~`J=Db1k3@}P5RnK5c`}7e zWs(hH9E`~%Y`T%~5F`|cE)+TgpVAes@*VjzCpN-Qeej7f+e)sIGH zuqkAc3f?jVVNn9Z!H!Kt7~x>)@tT7{Qowc%_#|kTNd-bT=o8Pw*CZ;Ng1Ytf;f#b} zg68;Rgp05keoP9&Kww}F8XIIot`;6b0)IfU5GtMI4;!bWZ&i#`L&2~ChBVtTZmw4+Y>#6HG-Y=!Q%qu~ zP#PEuCUJNn9xzH6UIP7egeY{Xte}X-79yjf4`>0P7v8zx$~<_~1rx6_|7R@@7|NKg z6>WtHx@OYRR@fvz3XOz^e(*bZUm;jHIXEINre?O5U z&`pblr%^dJ$?yw5Higy<7FWCg=wN}fLU;tgHxcW?m=MfhQKpg6Ow4oui6!z?2Lb|v zLPM+>BrtIy?bSlie3f7kL0O5SIY~Vml=s{OKMNg0rQqrMU}&wS~xCO63d~ zkSmZ1_Z=4WiUhk4f zEI2KlK>`^Zm^kPQpn#=}u)_ghuo%}Z55J2ZlrlNL0XJe&FgEPafq}8$&0F-m1GpxS z85>~St9wp_jktS4Xvab)Lg3Wuxc=Kq_q_gj6+0|@{+b<@J#VBPId50i&Sk&=3+-GU zW4}Pw@`v}4naJdDY=ms+$}fPzq>w4-ropX&o&U&?@pBg(Y>F_2y!eAO?POT!^!xNWQw5S z;UL<(Is22yR3Iv}Q$CqNgBlyK&}cv^f`8#Vd z6!2k=u%rlNCv0_dprJ&;z++VGKu6&LhbRC!gc?94!^0*XtP&DvnFLA$VgURd?Him) zgGekzj!4v5(&WmM95J)gTT}zmNdhJL0l5xUI)!$Trz1!-Ao;$H6yJ|B769LMrvAMrsDPS>0NuDbLIhqdh>o=`@Wf<0&~vU zYwf+(+H0@fDhO?Y{gTXl#m86m;^+?`7{?58SG9&2nm!1hB&p4azkKp6cL0cNzXtf z?Lq-VT!!H2G3V5o;Vc^tP>S!@vb!o>r^Ei=F65r5MwMUpZgTb+4{7YxoSr85@C1XW^uf;*7} ztIfs~Fb-TPe5|m=`8d>{!C(-+N?WkPFm!___$Y&UmPTrvvS4Y;Ft6mG6oyGzo*Ii% zfw2Us5)@I0MzTbednql=;?uhYSi;J>-%PaX9qj-jP8`GidC)H(lY6y_U^lCfhVWJq z-pVSR%@FW>JnrCt8(5dXUoJg!^1L}qskn@%3=BYoA%G{udm4b7t<1#M^U`IA$W;A$WU@ zi8t-SRuxEyWjSFnj`rfDZLfU(dp_*f5gaIcwlfK%BIIt z942LeMw$x2ZfUb8%ik9i1>T1B62ZEOHCW2)Fq9W7{4^2dx+qR8!?{tnpc|KWqI^W& zX3(zLY9QE~vrbm-d734@fM%Hj3+RKw$r0#ld|Jyw-4v;WNes5rwl{`SFs&(}V_H=W z=H=014wm9ZBs>O@9%1(I&!8R7EfT1i_leP*I>1fpNt6b)B^Qh)2)P)pbO~*W5yrn; z(T4df<*-}9Hq4Bj=iyN}fmn?jX`Bz{Ekp|3!A?A%Cpest7{SjQ7#QwA=sXbWKs27_ z2p8Ja)Mfg_7RmgPbxk0-pb8lCgAOUpjmX##hFWxNQ4A;Dn|!+qP*u+4{}a$E!BySS zLISG>OL<%s28jq192p%P6&)Jh3Re|SRlfV)99q2vvU;}xtACPDyZEnbc7De^Zh`-X z1-IG%AtJ)J|Jxt)@!`Kd{MU#7{x9Ia0<1zHU;c{^_x0hvKHS%b``#6}uWt?bpC1AC z0DxTs2d3?9@W3E2hBx>j-nEjsyn3)x|E~bG}Mfe~C z*8)+D?U03EWMNeR6+nJ-tI>sJS>CV&FH%RW)o3rJY0D6C6q$Y^EAZXp;jhkz~zFO@50B^(5gff`D$%0#2#FQ*{& z-asX>8_mc-Trw(fLZATNsNC`2c6cIxH`Fu}`W8G6{24tAsGv6_1NpPU!a8@F#4vB! zkegQ@Q7oqx7p52%D3!pEU;>j#y)=cxvf63PEg7m36etSG)QYy0dDOUF%D=lwA>LGy zdJ~oKXkjWIN@_jK^|mrW}rQt@MIHI8RY0QCoS)~_Uu_ME63LD zik<~$3l-q6wSA+;NRFmAIQyJ)nW>S6AR3VssdmOj7Wq0TagosX3K$DMm_vL!<8TmL zXf4HgFgCELu*h?81GY){dD1VDSWVJrEOM}p){YU~7B4d9>!5NrhGv5Z{doQx$@qm6 zpQ53;b3{VKc;NALK3p_S*4MgWw_YUV%&TEN@ZQoxKD5@Vvwa$?j<$g!6|~L4QYOaC>I=(Y7_%6h>`(#^ ziHd2YwVItTB%x#n!&0o(#J@6yEdiTK8$Gl$r{`lXltylGj`!wkq;JuCT_8Pfsh-b$ z@D24|a|x0g9Fz?d@f2R5?qnrF+Cqi``&VQ8m!KrD87p{pRu5w#Uac%aiIjygS&`NO zm6sqft^i|!p39hB$pD5Wz>1C0IT$ZF7z1(Eg%s3ZW3?9oQ^GS5A}VGg@B_a^TP>t| z$FoEn)DhBeY-wVh5+EE9L2vndr!@<~Zo{ci%>=W@RShP5GWpT@L;}<7DgaQKteg-!xk)c6c zO1hBJA%8qh4wHz%Sn*3d2^7mh8zt>oEY2@_S3UA~jmyJ$dGlTp_nZ=|sf2OPUESqP z!6aSJkVODR_@y1M{lG{;PzOfI6hKo=_>Gi6oy{*UNvI>a3k@T;ai0L&Qz+$X&{Kj^ zUF_XW2p9!%69P^lyjIEiOp-Li8=u+CUgR&~LuuM9cANAuCcBkvmKLB?1!Ssa83Ec9 znKCVNl$Xw|cfljrZ4M~Gqa6FFE9?T}yQwqBb#tEu zNyBi&$)|Y1T=Wi>^_ZArS6k%aZ(PmA790{d(m9(?&W5o31ho+hsnfh%k? z1c9G1QFe+W#4&NI>;HT9&4sAB&Tn?6-lC#IMnp^RDE0QId#l0sx!q5@`9Jpw=NddFM;Pv;Q11G zz69RClE4$jzgB4$&#koXENz$0#n&z*fgio`>RTI4J5xi^V#W@0Hw#SVVNy&R@KhS< ztoA}g>0xL!GkSuy;3c=TP0zsmuE=47o_Mo1Ob*2##QJ~Bz(iR94H`Q#bED@5tpJ^uRx5o2pVT~ z*z~jzf3ZOZ+Q?WKOo%sC6+DD8$y3C#geC`y6?VLD0TB>OYRX|?jLt-pg8;qqEU-8T zGofHmL6I=NB&*Xo1k@#De5^HN!H0N*z;sXs8LT*JAku`Zw~Mp#c!!$1M%sZ-=Rh!~ zA}mE4p3D=WBNLf^bM{= z5j)(Bvq)!U3nfn68Yd7~(u1+kCAb|yU_2~sGKql#acxGA+DW)RZsiv! z@FHUImC{1cpGQj=R%~?GEWnZ`WuP~(R*CaGF}Q*sH(E{5lX26)%NvN3W1~H+mD0hy zpiKwhy$!>1b>WoD-(m|PvcztmlN+#SEMj~~Xq64u0wPX}ow$9gjj(OqT9^HZwJCCx zsY=r3$TV`K$V6(5DqE2#PegvQO!)36K{*O-iYiNs;0cXPsU3qBsS3OQU;C==4N5*5m16c6Q;DlJM^WGJ*iRI5UmAx}yn&&0$s)Cj8bxx77Nw}t6XkF*UJg|wo7NFt(5i%V znIc1i5@i{(WH~9N0xB9YevGRg%1M#qOPHSw{v~J?DkW}5f=a2?z*h-0Q=@ej%~52^ zB}k@GWMYXVX;c{!F_tHkP!S?fPATW8U|Ay%mB1tTdse30Nf0H3j_#PpE%4t+X?W}Neoa#N<2Ul0` zX}WK1v}Jj~;8!}m?4LU?W20z8LJuU_Z*9Jse8uQLWOL*f)4wjbc70(({pM54*yjqK z+FK*(>HWm0ZWmfw?iVfp=%bObv4@JZmoHzgtENOR0n!3?^@TI!{ zIrQdZJ-+yMrK;(dUw&z7s$9DCuiD`Q=T_D9m(80vVRUqeU)^!h{dF&;{_T_FqpEdp zWZv`Lo;@c|oTz#G?Zl)cAR`)Ov)PJ^&s8VSHJMC0oi0qiyo3}3i$<3?qAdb(1%`uj7>moI;{U!-nH_f^`m#vQYM-rFxV?Stv@Gg~$-)&=bRp!96q^ViESH6PXv4-X1j zS6gd2`uE8P9x*>6?efIJoyU(;B2gd7=;f31Mvsn)i)%i6w!!$mV#xgWcE``V^2?Yb z1yv)@{M;|H+peQk#XqTS6Sv&>Zs{3A^Zm!KU%x(c=FIi$*E389nKU@Kd&h07R}UA7 zqWaHC^n18}|FH8c>NG#)?fV|+lO8Y`dRy3=DMPkQym;n#-HaR8FKtb$(Of7NcU-V) z)&7{0L&0OOh(uwLv-Z?}w1G~Wqg@@=-`2ck`OKM}MI!%RJ9lk0naz{S%MTnl(4%Kh zP|&XvVyhZTi;H((dtzZ~Omy@c=|f-KCVlc@ihLF~O+NP!^L&(D?W=)>ls8IZ6 z$(z%D+UmGoo>6eB(9&!j*6X7Tb9P5m@nuC#`CoBPb#o>mcf zpD5pCdiR}oPF_BLDz)aDg9l^c;-33{byjU{?Y?)|p>qe0+`^ukGYaL0ERKkX$h>jo zr|Rc_Jh}0WK4$j)uXpb@p4OCB-q6K%x^(GMRZMB1pP%2bVKYae&rkeT5j5_~l`G@V zX!G*&9FB`$RmOyy;}aAL#ZyncmRhr6)26wvydv(>Wf}t0no@6selz$XUEdCM09in$ zztXCPAb0b?Vx+K-$-~d1>A8!ewU$=MrJqglB4-1_}taW}e#uIaVtMQNw0UGA^0tqlwd)7EIh;b(TX zczXP#Nt1GO4<^qY*tz4>*|TTw+O=!NiWO(hj9;ZqeM{Y;Lx&aB)s8v4&cCo?h4Osb zAkmaLb9SFJJ~e7eY9}+>!j~yuPKf?)c;cGj!zmd>U(E795>#5;Nyb_Cw;jn;MG@O?InIJDr(ro7$DCN#mdWuNgCTTLyl8I{VQ_cYU66iT*P7haX~BX`kq6D|q(V z3(vh4XEMDUI!K46z>srf>+@BqHH%(zuZ)O+&D1a{?H0RaJfYoEDVZ+))u=bx_v{i#!@?%TKT(@zuozBK5` z=dNA5%ubI#-rPK}XV1pw<~c*-7p7KL?45WrJu5G7NoviG;pdLS6SwsD z&u&UQ9%sLPYG|*VX9b_%ZClpXV(jmKc+H|&33rPdZoWE}o14EOl=iefD3_`!Op6`f zXR}jW7t%q%m(HFQR9xT2zt|G=>#xP&pwkwlAAF=_ue|nN)t&k-T`%6w&9WRDr$Hjc zOgiiTz@@dd{J=y{*1?2%9(~J~`h=x<#AGOj2}obkuK%~Mh0JF4EEf%u}4FZOGV!1wo?9_*L@Eeba5RS0odvU z@f$Zj|5WAX%H~r?k2>gvKh9oRnxC(6=5xrW;~Q^ViJO;f7=M22fWz)NM_uM@*bqI^ zuqNtD?Zp<4dnKt#@z=8WUMXvWXFTe4t)l+&<;!JdWg0^!tfp)N+-Kalj|~k!X=&|> zhjNh$&>-1=JVCvMvBWa#nbhYFI@0E;VvAf-F3Mdxm${` zD$FO}Jzrcn=vM8j{>z#~nGwZCiQzU%EjL0QPYQZFFv@+JUSD->$ELa*$DHUjfn9do z^7b}a>bI3~rt$sD+ct-c$H1Tab)W7urZ;aJd$R0eewy2vLG~-M9-Q#t7y1@G$ags) z3Tdui_x$;uriE9ZT}t)u+WLOakw_1|>1Z30Uux6W+KWevUMIPqh_bibkK! zv)#Ky=H{vnQ;twnEG$cD3tnmI)TRb9HTTW1&FF4&vYSXOe);0XP4BbCNppHAEBj_E zSr>#4b@)_U&VRa-aprBqgX9BN)v1dPRn#wH=q_(*y7bDo-@X}X$wRF*saj5N-gNIt zE;+T3TQFWjT_ZRnq|K^FkJz-+u8fZZ4!Y_OnYg0y?W5!!J9gZ==Qe88s3Bo<+}+O! ztDIMYHFE=qBW#HHj^CF-l>j|W{7SuC?!}KeI4j|l7r(KwVr?X2)Aq$>7uya*PE%UB zcbrOaP>^5L+9}b)h7M&uyRyN;)<(1We0f>(vyGXL9IXbu5+(KQfB(e1b$)%uk3RG; zc|>jV(kCfZfYU5If3A0!gSo%Xz<~(~37f;h9Ey5IF41?1ExdB&3Poj>z7`;?CMO^l zy7q9&{!%$G=p|d5Mhn`oVIPxeH8XTXc%A?K#)|s%D_8C$ojXleUR0%V%cA@Z#37cJcXKxGv$5Gbv1P`p zXveEMlMamGb{nPXc#fB6KRa%K+7w4em6))s=Y?h6)=<)Y3w4c*j1IYieKj2t*28+o zlzC2l4+3eMl;q#i)X=0HP%)*VDyDz_!Y{gl%G^OZIz5Dp0C8&4$#;BS>$OiyJW5ZW zGGZ3$zTj=kc}883u6d@X&E9U8jVA!?F@Ju^!-tN;`V7_8-A(iK^Y>r=_Tibjy1K^3 zCDHtCVYj<>y;xmiUp(KZtC7)skJ2H#cJ}M~;)U4>k6>1bt&dM>Wo4P^oSX4$0`%0@ z9^A5J+LS5R>*@mL&6~G$=@+0c0FJ^kdG!16X&*0$>z*=u?w&{@jhfT6*9&0YVIzc& z!?J9YW~>}%X7*)L+wA6-dkppt`-wYpu(tNyyLVgbHcqm0aPSw+Ir>_||8=d-q-7rs z^fsGDK3JGDC8Fed=m4!Fwqccx_3uy8M(f2GpNw+V-*x23kqgT|)4Z}5c!}N z&w2DHBO_y;7m3;p(9*@WC+~~F$$rPnLMS|zc%^ce7i~`QgKG1Gk!y`xWjSQC4|F_{?V8Gt#8ihiiRRx8^)ko4Y=?4{1>9 zowH|$d|Y;0c*(1E7AO8bYxd5k*SAf{p)jttFYwuk=+8s9m^k{Oe2m zv$D>Wrp@4o`9}NOiCXb7^p$v z)%qahr^9M(&0n5gUEgK&TxVzJXP-?%zI?piX*mB$*4z*0&z?P%qP1=_ zS=Y*nSzq5j=-rB%oi5KsC5irkq)(p~mS-=Y@MN{>Bd@bp^8yC+=&><8JUlZ0Oz+A5 zqY_WvFD(4@s?aU3c3lsh{B0x>$u;3#`HBy3zt$#=<*3|y)or|G>GJ@JT8>j(X2R6D zt_7>U2s~M=7MuSqHivx0kw@23RzH8v(9zMca~K#MJ@itRgYL}5J`ccuT}X@g zF7d98gElgq;xa;Aeebtvt2pBNMX+I>*Zi#Q{soN*=z)IULu1Uq3%7+4vkD0iA9=FMy;mkA{ zMv9xInqxdj>E=sK#@@DTdv}8ODB+F+2M+Z8SY5d}GF){vWs#4=;i407-#Y4@H=n$- z1%MeqNx5b}o13WsW##G9MP>$+K2=w~>Ta}sFn6odus@70t~hKo*HJ~-0w|uO+~wA- zotYXZ0IVLvoxgu~W&c5cq$Cfm2sk*um&^2<)o(&qHJ@pCoZ%Ond$hpYYh=V2bMv_P zc<1HY^DI`|MfI%RGI8S8{E5?mN<`UfMp<3p8m~8(89VtX$;5Q1`e3JX$zL}Zs;c+6 z>wEvqnFHXzkY;8sIDKPzS(77;O$Ltts;R6*G8WF!*%x(tQSR=RE|n`9=`S|-WtZHY zlSB`9yjwnr7OtOK`aqP~@bdP+@bF_RMv+LXudlE@#y6$7VNF3dpu;*1>th$K6&$?0e}8hF zf9T{(OP3d!nhw2lz|;TU7IpRePoAh)8LQ<0-O3_DS#$p60Qh5kcvOhC`qtkVWm%hp zo^t|Kl(qL%UwN6?U3pwnq2<=yG@C80Mb1?!z@kXKge9)=HsMx zadT_G4eOOZow6Zmk=bpndjYJR9{*0y(nL3|XxrXjV@F484;VnQE-0LN!*$Ig@+Y8& zJfWBlQ;a{)Kt#gSO4xEPj6>J(K@xo zUFsUdDrAA5ujXEzh{yqZvwVE`1-pQH>Jsy5|Acv8o+^cuuzx>ws`t9nr%vUV1-?0w zl(gj0cB^^bhzpMzJ7{Eaeq4N@LA+`1h?uL7N~=H3J5uZ=3{HD6CoejhtD!x2jfvIyAj8q+W6cw- z#~B;fJ-M*FrlzK;Bz*TrQHYn<6#r3YYh7p$Sf6=rcQZpSdJ3021K@Fe6p;81VJD|g z&l*=_JjT@Yd2HC>6ngw2F*tdCXMwleu~=3QnrVh*eFnFD zxVE#VW@!1Uug9~p<{VnxrHgj?awE|-GM_}cvp?ZUc63kDWM(Wy|5f^!AtnRM@1Au? z7OGmmxxJ^F_jpNRnW5g!dL^ap{`ZxS9R2#NKD}_}z=)<~k8?R2r(JAHoKD@HmzDGE z#jTXw+y|O{Lu#K`<&}-AB$KS1hHLc^Frqe0a_^$j)5F#6V@Ukq#q2fo#*eQPfmBFK z3mG>XaKEh9Oc&m}(qX?pS?1|sc{;G7yeD}~#`(6QgRJuG=AjO&0!cR(7kOnhT0OVk zJ6+FG@WRp0FLBMjfoCQG!mAHy@qgdcFlTY=@SO&Q)wle5tLUX(T$;7!$dN5R`6r{t zyKUcgYf?)}-NQ3Sr|a2&h=|NS^{&i++O+ecCXvNHtCgP@i`)Qlur{hk{NbH=>LTsy z``cPwTfVO8I@NdkFV%0}Ox9E*o0wU~M4TT+AFwdPk?L7X%h1G6`AI$xmi|($dd3zJ6 z$d4YS&Tfd=WAvFyeY|yCb7JwEz9XDZKYE*zV%GKY*1oF&XuJK=!szDSDITQ(zOQb5 zNl50YySuM{^JegxH8+#KCX)L<1@?zofVpNH=okd(rK}U1q(cnTsz+HwCMHS zrlw^dyQ-_K^+*eCYpk$LuIe?Uudi9s{{3kHE#*C|Sv7X-*jOhWXmid-fQERF!O zWZJay@{5xePu%~DzmoOS9F3v3|2Wswr0czRrEA; zXjXxT8MF%vOCD+lzunYWp~L)`U@&O%3HS1>rOBzO;-dH&n+_YHF&B(gF_w2azBx`AXQ^T4{ ze(yK4FB+5Ioy+IsvrwfnmI`yTv(mIenxUG+1Tr;Rr{Rr4%IUHEvW@qqiPs&DVP z#S|yC^h#GdtCDQeeUsf`ut`0Xm4}TO!R&L$DUQePy*r}e-hK7^4>VHK!ajc5{@TO2 z@8)r1$1WeUub=kYEZ@SlHyuB(COPb?4BGVNO?7ooRcm(#yL?WsD}6Svx6>V%ez$1) zE+=1+o1T`_ky#PfXPZS%KYdQmc)%F5s0gKNeRr~XylioGzn!-pr?C4jOIEe3yiN6; z*wxyVPN%ck277LMW(bC#OZB6ji=_{sjT|{>(Aj3c+h+6U&mTE*t@T+o{%Q+i0Hg4P){Py9R zXN!_FdTLyWI+foy94yuI=g%`UE%bIq{{H*(moLqGs3r#l=T_85MMVKEyizYMbm{vS zQ$s>Rrc9Z#XwlRC!>?a4eERbCp0FWSZ(h9$5D3UUdsYZCy1#pIU3-Jg=;DyA3uq(y zY!(*OOlK`T-ZeBd6daqMfBtz=ft>O}1R93!UGC?=|RaI4gEv*+-RX!!x4c&8xDou|~ zO>KCVv(eVpR#SOq!o6L)b|vgqCvWHycB3L7Ju=!{*_v@?F126S_U-B#8b!Wlv^_~J zX|b`kC)~l>-r4!`W|rf6=M^jA&r88lFE6iKNd>>D?3ycA?O#m!1^1FBO=JkXNu zbi*%PxDXK$am~klQ}g_8br(a&M++`6^l;B;^CaHy!J9rSC#C?=IYDGUS7ZyrLU|$* zWh$5M!=m`Gc(4*18WHE<{42%5moF4y73lQ6SwUz^GV)PqfsLTxL&6 zkq&D+7fZ@iI79}_AIGB1UW)!ABqW&PAt^eAaF_vrAM=F;atQ!ZBc#SWx=IOJ9-g z;gGR6WeSMXF%%`>(wDJ#ul%6L&{LWE?Mo`B48P$ zd^rZ<0Oq5^((Z)hp^5|xogi4KWIl2YRlXj&Onby^qzc3gvz?fMiP>bIq8SI#`tG1j zN&Z;4UEpkj!@-jrXsV)#$cZJUL@ZJ9Y_IsJ1!%Hax&Wn}cBkXpnPY{2A!{s!kTq6e z>N5$vL6e_JA&%UwWy#RmWs~Eh=?le3!Y@BDhD@*`ZbB>rrY%K}=S>&-T9OF`-q4R& z#F}qRaDpWh;P@hK!_rsaY|D`?S)WJ;G`!#ug(X8DG$!`k03U#Cf9Mdi}& zZKZ!8`~k^GiKnjQQ{XhQ0!1*p8DFkuom}5!q;7{q|came0k0y!(XGGy$UC;rdileB>$ecFXNCw1tFE+&PF@pn(bP300 zh}{szMuDDtM5HM?^RloU6{H0XA1ZFPYusV4!fh(6EUs$+tn1&>R*QDu#zAhtJWw4 zBrQOB1U6_y24T|%XP-yR14#CU$rgD?-b`5Jk0qi5mMtWZh)|kB7MI;{Meqfo!BEKM2W6pTk%;|)^*}0_g7f4H zlS4|j52(LOv6` z!nH?I+qYZzZ>=*~;X(r%01{y_EkMjP1SgWl5E!izfOZ4nf`e}%%Z(+vCY%T&3&f2H z@MDDrg^q+jR`n7JF(!&e=?nk|=qM*cWVJ#WCDAd+GL;6}S^Q`~V-Udm?vU>x)h8i(z797srM@m6$FQVO?6Izkwf4EW=MYZu;AT(6fLtj@Nb~B z^9W@Zd2EgZOTf+*$#f$bBu+(S6C17F2=@zYu@JYR!l6+h{zlXT&?EU9J3?3+SY0<}gmaw>>un~E!9?Y=9wh7_4K1j-n?aAX+; zL!xL(UhLRB%t8i=Ap+8ct{$0+=wU1Q~WDe_JB*O zbHIh-L*@lFS^`6YG7{D)=AucL+fgFU#2{oxTZUkSh(d7G$%pI`qYFjaDd5N~)KUfb z1)aTwFG*DlGykCVsxiwJfEXCUqu`DSzBhxZ3%?;?VN=EWrN|Wd?Q9Ire5_IlWGRsQ zf~n)hYAKQ_lBIJ3a|gTtsaL}BLA4xXJd;10qjsCG-If@^!23W`{T zaXphpc1DN<^vx$`VVB5I0Q`kAY7u(ih-Xo*W&&BdPw3#jebN=>I9FtBfow!-$;bJ~ zuZW061*ue-6F>_f%9|lLQ7nNv(JBekfajSAdT{F$TI-?XxnUrdxEpwzWPM0(FtI&q z=!fFO0KpSDX;HsLyI_GRRulr^>KhPgRD>7?CF8}dK+>f`nT0Gzg4(x?m5;TA** zOEakxaVr(&Re+4xLR^W0Pq0@IJ1(GFTmhkxQEf3$jEn=yGcZQt5UB{?Hbj(3A;hNm z3Svl?$PQ3xkJc~XljX!d?v_<}1Y`^#eqbFX{Fks37T>)Sumy@fv{TU#DnlO7P~oRb z*dbrDi8EvbFjNU=7c017ZAUB;e?H-rgLFmf*L0K)35Q#t|- z2rnQya!?t>!n`+@lD1{hSUdS|H`|%O;xHH?_ZB?=f*?t)7jX1g?VEQZG>=%Fxwyj2 zm)iB?9JEC_n(Rc8@4ihQSf`6ffqh0wF`Btz(Dl#oe z@daJp0Rvs0Qpih3lm0&e~HwuO!i+1P|v;(lOjFN{P zE*Vdjlyeb~7S69wD-0?Cr1gjXmb`*3cPy~rr+-FbwOa~lGk;QW@udO_Is;iSZ7AXo z1B_0AoZ`#LDGH)kv>Ohc&GV*9qzQyVBKkir(ul7u2HXjz%KWy(LN|fW1zL8;yMTP$ z**4fOW{JdbAAqvQ6DlxXAPOGh&_Qe!IE|p}pP*#`OvYrxnpaY0#g#hq+eg?zL`nF% z)Cta&9}2;z{V!n&Ns|CVK`&|hRp7}vZJ`Z9z(TYQa6X`sk6`X0s29>{dDFjROHp5N z$CQPAt`8&dkY+pEUDUTs!Rbo!J^bV$4gv^}I#^mh<-5Gi;9&Uj#X-oT;KfX-a9QBW zVce0+5=a-?8wy|_=+K3P$N_{XwLxNH^*feJz~^unbf$lY>xIA285P*Egp29Reo(=G z1{DZdB05;yPWYS5Tlx$>pTnZ_I@xDyz{in+db5Od^mnx2t}bkfg7x^_n@rqX;?e#G zHko3t;M@@VP}nqRjzQ-D^njTwz(O&Ra-ZM}y2wO{^F+;ZunEGDBz<%=G|Vr|WijbI zHnfIFq%vWf`6wwX#H9btCsr{Im1T?w2F0L)zpZAFS%mk$8Lj${;aIWY z8!%QZ_%kRLAqaHw|4n-b+Jj?P&7Ihx#5sLFKSKsDN`I$<}#3 zomx1ss^*Zf1_*HAzJ$%?OXNM&wIwJ)Zn0|gg1co2irc%WrMkyq(dy@}QBX;OQYwZeYo`t!zQGctK3I9XsJ zHAZ;L#dss<8#|J^JYCu22~VbEP*QFR9dQ!E!N(7033}&=C7fA+X#4sBbZ@EW+yEu5 z4o5)$`y-%p7SrWNA=@h|jU<1`8tza(b|*>1##5acu=RGG;Rw9jiKSwLe#7$wWlHHn#R6R1x>94fBq9KX(lRzaNV2VsIOXqT*$>+d7gdK@~ zA0Py=S2{yKGS*%EvH(;(B=n2KOmf6Ly70RO2JgRiGBD(ozcDb3L=+DUgZF5`3d}h~ zK%pH3wJF56@LeLt#q|JdjuiWQqp>|G2Scu+3MmXp(Q`HoB0w*Au)PtsENB;tPL+m7 zxZ>_->`n;c$Aghrh}t0E4IS`h_%~ZpOQsXt{1;tf9#ohH0(-_6h&(+zg^Y2NJ-3!+`QP-iyUxUR z-8tFj_FMDqR$eO+$`LQ~K`hD7@#TLbZgj|hrzmO%26 z)Z2-DtV=joNH+$5#uwJvrJ#S#uceR?w&QjHEeZI+opQQwPfDT57LEAt(BLa$u$48` z@(7w6jNV{~h0M;)BkjF~uz$>B_^-1?)Mt$PasL0|j9AE-0{HM(xFSW~ef@86#UJGN zKSh3koB+TCts&u^*oo=ndK4fDxllzjnlTmpGa78ZIn5aKM}}dR$ibsgtkH1%_TNG@ zAQ2l034ve6NDjJd;nBe(n>(~E)4@lwfte_L6OwK0Y#{QU>g){AKD>GaZ$HUIE5aee zSA^I#92EUyfKSp8wf#L*GVWG@W^sw#4Sk5akmQ4EWZVxDA=utYz*Q7bt-!(w4+U=J z{MVTxrYOmBMa(oz=t05@Ie&!}{OWNnPreWy<-fKP-v7-X#rfaFLZg4M518d` zthspy`QMNqx%_WtW6X?66!U*@3?2UbAJ6~R;r`2{lKFdmbW;D(WVDI={*N_<`~M^V z-@pI!pO^p74v)CS6@?(SXemlZpF+~))VSY1183C^9N)q^eYe_rJ z-G}`3SM&8DuJ*s2t`Gg|Pp0UD7p4UiUpmkGPxSr|X6Lh)KKok<`mjeolJk9Mwn}>p zP!Y82@5;!>hnZ{ssYHC}ZG->oiTH%XUHj`9_*CUC(PA5nnu(;_jT?#_;dN*>ywX6y zUZwCCBjOGSLN*gRPVfg<#v&TodNJZ-@}-NY;Cp=VnLzSop)X7{1OB1FXi))+4paQ_ z2${#&Fk%~=A1}%6N&E?NX$VRvq&L*i0{f<85hCP3F$;8$+LOR6O{KF$#_A=;L-K6! zp@VsvPVC^$CRkG_l<=qp`77@@ee1#(v562k7X@V+*v(IP6;&Xj=*xXq-@pL*Hp-Xa zioly&6x6y8(-INBN;LmtV=xr4gd$zE4H)SHIu#2jNSq28x@)aq%Xn0!uH7sbSBjgp z&2)Q80E-Xjh`ogOKzP~10~}A=S@za$_A+15M@}tVQwqGG2Z5r#xv>EidCUUPg+qJ{ zo*IxnJ(2Ozy}hC1j};7KM&JSo$uL|FbiW+DwjA3hCqBH;L>E$QVa&f!mx?xOrRxVi zn9M{T(qKLqDrF^=@I4@t`792_iBAWc#Fc)Hi#(_Kq0c8X>Hm+tD}isS%K8z}4-ZnU&eN!zqdm!u|XfvG@~=B0V?nuNTBQfU*<-?SIZa$L0n9{}w60 z(PAh%6%arv34CK12^HykuR;!sK3a)fh;|^CnRc^SxVSx`i1-e-%2);GY!c2z3{wz3 zBc#w1Zb<0>w3_IOKE(~LJU2a9?8vM zqbbHp$gy(#4CtTW@QD%`*nx_|8u19e>aqLXph(JKw^1{ zP|`#B%N$YOwHfY!PQibPeh3pOnfh=m#b(oRbeXbp?L@a2hJ~yPLt36)$UT@^TAe^b zO3KDqEm-%-C}vgiLjWG5G4H`C#K%wENmx8$S&XM}e9Z&v60)U%a2pUhij^y9M-k(-3S$R}fap^jt{`e6#Hpk`Oc_5+ z_{x+k@W4l`D?p*tPLb6P{D6=u6med`9f>eBR4~~6S#3X@@y8FO<;*|PqWLFkFp7#y zh>5}felzn=(E9TS`?QMxOE;poS;kH9e^pFObRhm86&)GG|9^{55dRP2|Nq@AKS4`C z&=L@|1OzPse*#NDt7&=!s5l@^4?miURscW4LC_TNJ2D0MTLSpCGY8{{(&Ov^KIcsF zsq0)bqrz3;QKGm}0p8C=;eU7)J<8uD^A^>cckm>rKVHPxomM~*xcxlmdhd$?fp}L< zHF?17i}hrqg;UAmY|tGWJrVqZodT3V z`@EzT7P#;9ItWynLyx0SE<`G3DM#oH$#8))AqXwPgD!+z7u;^8uW3cJgJL~?ck*0T zk~~*Dp92k&KG2HCI>Pl%T=Vd_Q3R()NU7wCjiDyeQi$JaL$26pv}bG>9VO5+dUh zqGJOv&7ed3ullr#|M|9gw_V0f@W1FtRUrO1Xi#)8|Mze53F3c2{4a?A-3b2^HsJ*F zyJ@QFAnq5${erk(5cj(++%M=1{6|LsePcg4GA@q)VmdB<1_pOvKGT9E_crkkf|(D( zSs}=vP5f~v2W(N{4auyCpApke5!E9(4pV%7uv}tol3tM0*X#0YbFdg}VI{GA#C>d{ zz#5>d;r+VIZVT-J7iE7hAOD99f&(S*JP6)UW^msLvy_E_8zJvOW;3&P0;C1(m?ccI zxhcw*^BAh?C1C^b3V{U|+8bp&<^(J^vtp{_mQo-Ivo1U<%)Eipn&87v!lRJFhx@2P zp^^YFnJ1WOh9C)W*XN7vo1m?d30ji83cR2!v*lcll6dGIiYE^<3T zDo9-fu~FsxBo*pMTZ%B>h&WL6waKp?h_r)ezc1>AoCA1N{!QT!nOiHbg;Mk>S`-i2 z%KWJMBhdemRzwBJAoJE_K#1@uQ^~H313a_v-!VubWwyT2a)l7moGbm&LWjf}(_9|3G9fTkqdpxFUlhQiypLSz6W76!fp$!|2TMZif2lI%9z zWq0{c7SiOm$b~l!;RtDMsLbglK83{7`PQ@QT4;wE4{0oyv^JUlMrg;9F~LAF6zpZ9 zlybAkQ$GGPXn-(+IBfxq=gb*qk2s{sg_`rVZfVRCSMMa6wXlNcMlE}cke)RP%mWa1 z8AKq3fJ@B~_mIPXIk$6z6Ov~*k(P3MSu;bIutoMVJb5^*ZZR}X3J<%H&S!FpDQ{Vn z4goq?Cu2rjVm;n^?gbT_?D8WfmYHWdCT=vB8}B+ zhD=D0LwqSoJT{Y^HWx!^G?Ec54GY|fM_0B8>x#op(q>uZsb&YwIFZTAK*~!}K3*r5 zf%|R|MDb(^5j~t4skvnV;8EEeF3$m0l;Cj3c1Z?+(^^vG`XaTDZ1S8EsdDsPMXh& zB<`k#rAL}z3F5;G5(&7tK}NDop&7gkgh#@3`Y>azIw#DOq1I&?hqchniu^Y1;c~nW z=1e;b_wKEF5n4-zq%KbAd5FzB>s&-vq+bN&F~T!Jp#K~ql9loK@N z1Wh@APE(HHaUiS{{G;jodIJvZ%SEEX_PZ4eM1q|52*@3rI43im1@DWIxyWp#O6Vf8 z83sQ^%3Va`J($bu#+nbt8xJyDSSRE4P)r$@n}_ufw8eMK+3hUD^Ex@R?MCUkyf6lQ zoN--Uc=2Py6Qi5r)>NRo;evGnvQg7Ec+1STh+yDdx`PXdBCL(r2rFfy9W?P{=2TOU zA3_{ZOH@i|a=2XUVG+M8;IM)K5U9m6iydB4nDAmmu}hdR(sQ|F)DklfU_&&A9k{#} z{0_1@VcI9$ye%YAK8~VXh$arKt}-|5xH*W6AzNhL&z3aHLNU(La6iKg>!RJX#}}Q4 zv;`^*k$L0-m`qf}<0OH6_%?xF5NwbWKS-Y!Ibj*zb>qon0y#17#9|wV-{q?1bYSh^ zLlqE^iZ2Y&9C&S&7Ndld`wnuQkB&i3=|gs9vK9bL%l~Y?*@gM#a?=oMM`Q@FA2&@7 zZo#EQA8A6=jrbKAs3Wj2!2ey!DPbwf1u%kIi#Vj8XE6t~-Ihp^hccJ6h7c2!k%IY^ zwt<2KEibl#)mp)B(@>Uddr)~=KQ zyGq289t=z;#^nfbt)>`84jK1I1{}ZIaRz9Qkj0B<5jl}iYUiy%VoPXNZu7bwxJb?s z9nuXtNr_{5t2aE(Ir~G?@F;I3gPbo0iX>b{U4vkKB}@K}LO=X}H>;L0TiqHR$uTshU(2qBi31Axbn{ zYs%2)nGk-$pw^j2B7GWC>qeq1tu9rGG$V2i8lw^E4RUQxZnjo~uW5BD*?Fm2T{=p} z@9Fd=l&#ItnlMq59zlUTDXqo`#Bwx-lnne;ovh8)nno(+XKt{thPjH@0Ro}qzD zP@Wq9OEGEnI%r3VUS~4kuS(oZgGqdKxYnpqBDFzl1dgN`^f^j7@DsnGCq(djIt@n! zc#Zr-f**nJc}9&$5T$C=*_alVkIqkiw*pZA5`6l1ACp89l7t}BQq=Gl#3T7nfz!cg zB)|02I{qsnNVi?aP4M41RqXZt|FN+_{P(x`%*fTH-zR?vddhv;j8p^uJsJMDYlDAg zKXHDEOxA0aHdSq!xUZ?I>^0HRW-Ys?pl-JSQggzg?7&?3g+f)kgZSYjFfww&6m?J z*%bXY#eF*Mi{dL+7c}hHbYdy{RPke54xgT^YJcb2bv@&=9yv0mYIvJwRCe2`jW(U*EiW^Xk=ED^2)KcGDBxX4YPuS%38FZ@!ta)$-7b zwv+P~^*wHqsoD=WnZ7%5;;WOM`={SIrLdr&ASWj$JA3;J4?H@owtPH)TV~{^#od|G=yLJAeAs3VqX$KmOR%RJCNu-%JC0&#A8M zsh<1f#1RQmA@xUPch^6c`S%Zx4y&=eV!Y$)UAvASJ68Mp>#1pJn2cm7E6rg;}d5)-6gAEw_w2oRl0vRp80Cq@PP|9Y}la7&d%29R(*47*|KFX_K34A z?zGZW*7)(vA9nZ1%z9^9@{IGF7B3!EKIHO_xMvNFKNG7n%>62F6B2tgWka9R5eezK2R4Qni0{!M3AE%`#ax<%ne! zqeqO0PfBV&eY(N+wzl8Aw{|Aaz4YVAL&eoYPyNs%uH*K@)#Ja zyqeK(^OHZHI$A&d+SLnNvT6?BzU%7H`;)DZ{Ph678V&Z1*s(Wuel{MS6DyFBq zdGoRvGwzYe6kWG%-@=rXRFs$R+qbWCmo8X9|C%_Yx}kLZ_?=fCU625jKx@C5n2_*F z_JC(UP(AjbnSAEYpTB0!nx>{EYt)0sW>!=*YPEk^{OZ*2w|K9X=MB3Q0{DAp`-#+}x64RTb zD?a_(m%DRE?77(dPMq^lx$*FkS=Y{1Uz=5Oa!dKepFW&+@6e$`yUM3EoWOcH^||Nf zeQNE|WARTvx!XK*q_HtN_T7wruP#~gV{>!2nOn0e!|#$6GR&KAym9>E*%O(yU+&+Z zn3VL?H>>jM>gx8q!48pDH89T)K2=>?zae(WAZIpFgikj4eq{(Q37i zKmJl??fQ)y=e+QOynXwr2&>lQ9X8x=`rdEp-lkqv-4LNrbnn@-eTNQX{yuhrEhN_% z{r<6~hSfO{ih&Cbe7XLgd-qN_KBoJ|$psr7gA)?!M!l0C9ow&CyY_dd6g-bBKBV{B zHEY6Ds@%jo$CsA&=?$Ob?oGXV_3|WCZM6(eOzbk_qfJVzK*KtET&{KRnqS{8oxa6y5g{N2jgb1Zw>6n0OV_^-n9@^U;ZoYxi?7nhVY?b-9n z^y%riryn_Tq&BN^SjSnjytB8TeP;P`-Px=@vdOb&?>ugMeAwj1|2@&YVamLD z^VYxpc85Mm?dvi9JMOrHrs<_im!ftHD=SYNJGN%TTT{|%YFDhNSG}3PdVKtWo)@A& z{;=`qq6hN4-fM5(`~Lp@lRjG*_Tq~#c9r*!kKgn8=eo<4)zxE0k3NK(Ypc1h?FW1J zFaKa}U0vjx%TJx$+3A7vKgil&&D`m2E>pv_Q*{N5rk|j%+ci*)$gAVT4@%feG{VR*UxMt5)cv7c5BP;CQ+|*P; z(`U||!^7vU??%3s+y4Ih$DUtg?q0WcZ9_wYJ~MOuh7E%TU41LEZ2XzezWlOog?`f5 zasM-Y`c6mhFHYt^{P6ZqGA>Y`4f*!lAuCOfc5xSv8+Y!hmy#If`RG0tG#O7hhqgRj zomso^<(Kgu_3msRz8&0JXc?eQHS_lO() z^1=y=^Y2Sfvu@oQF>~ga-U+760gW}wNAwuf_8(_HP98oy@!U%j%XV&$SbnX~0~N

+%Mc3Se$=H}jAx->R7 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

7vILk*vAofp%dpOsD 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 -#include -#include -#include -#include -#include -#include -#include -#include "axhttp.h" - -#define HTTP_VERSION "HTTP/1.1" - -static const char * index_file = "index.html"; -static const char * rfc1123_format = "%a, %d %b %Y %H:%M:%S GMT"; - -static int special_read(struct connstruct *cn, void *buf, size_t count); -static int special_write(struct connstruct *cn, - const char *buf, size_t count); -static void send_error(struct connstruct *cn, int err); -static int hexit(char c); -static void urldecode(char *buf); -static void buildactualfile(struct connstruct *cn); -static int sanitizefile(const char *buf); -static int sanitizehost(char *buf); -static int htaccess_check(struct connstruct *cn); -static const char *getmimetype(const char *name); - -#if defined(CONFIG_HTTP_DIRECTORIES) -static void urlencode(const uint8_t *s, char *t); -static void procdirlisting(struct connstruct *cn); -#endif -#if defined(CONFIG_HTTP_HAS_CGI) -static void proccgi(struct connstruct *cn); -static void decode_path_info(struct connstruct *cn, char *path_info); -static int init_read_post_data(char *buf, char *data, struct connstruct *cn, int old_rv); -#endif -#ifdef CONFIG_HTTP_HAS_AUTHORIZATION -static int auth_check(struct connstruct *cn); -#endif - -#if AXDEBUG -#define AXDEBUGSTART \ - { \ - FILE *axdout; \ - axdout = fopen("/var/log/axdebug", "a"); \ - -#define AXDEBUGEND \ - fclose(axdout); \ - } -#else /* AXDEBUG */ -#define AXDEBUGSTART -#define AXDEBUGEND -#endif /* AXDEBUG */ - -/* Returns 1 if elems should continue being read, 0 otherwise */ -static int procheadelem(struct connstruct *cn, char *buf) -{ - char *delim, *value; - - if ((delim = strchr(buf, ' ')) == NULL) - return 0; - - *delim = 0; - value = delim+1; - - if (strcmp(buf, "GET") == 0 || strcmp(buf, "HEAD") == 0 || - strcmp(buf, "POST") == 0) - { - if (buf[0] == 'H') - cn->reqtype = TYPE_HEAD; - else if (buf[0] == 'P') - cn->reqtype = TYPE_POST; - - if ((delim = strchr(value, ' ')) == NULL) /* expect HTTP type */ - return 0; - - *delim++ = 0; - urldecode(value); - - if (sanitizefile(value) == 0) - { - send_error(cn, 403); - return 0; - } - -#if defined(CONFIG_HTTP_HAS_CGI) - decode_path_info(cn, value); -#else - my_strncpy(cn->filereq, value, MAXREQUESTLENGTH); -#endif - cn->if_modified_since = -1; - if (strcmp(delim, "HTTP/1.0") == 0) /* v1.0 HTTP? */ - cn->is_v1_0 = 1; - } - else if (strcasecmp(buf, "Host:") == 0) - { - if (sanitizehost(value) == 0) - { - removeconnection(cn); - return 0; - } - - my_strncpy(cn->server_name, value, MAXREQUESTLENGTH); - } - else if (strcasecmp(buf, "Connection:") == 0 && strcmp(value, "close") == 0) - { - cn->close_when_done = 1; - } - else if (strcasecmp(buf, "If-Modified-Since:") == 0) - { - cn->if_modified_since = tdate_parse(value); - } - else if (strcasecmp(buf, "Expect:") == 0) - { - /* supposed to be safe to ignore 100-continue */ - if (strcasecmp(value, "100-continue") != 0) { - send_error(cn, 417); /* expectation failed */ - return 0; - } - } -#ifdef CONFIG_HTTP_HAS_AUTHORIZATION - else if (strcasecmp(buf, "Authorization:") == 0 && - strncmp(value, "Basic ", 6) == 0) - { - int size = sizeof(cn->authorization); - if (base64_decode(&value[6], strlen(&value[6]), - (uint8_t *)cn->authorization, &size)) - cn->authorization[0] = 0; /* error */ - else - cn->authorization[size] = 0; - } -#endif -#if defined(CONFIG_HTTP_HAS_CGI) - else if (strcasecmp(buf, "Content-Length:") == 0) - { - sscanf(value, "%d", &cn->content_length); - } - else if (strcasecmp(buf, "Content-Type:") == 0) - { - my_strncpy(cn->cgicontenttype, value, MAXREQUESTLENGTH); - } - else if (strcasecmp(buf, "Cookie:") == 0) - { - my_strncpy(cn->cookie, value, MAXREQUESTLENGTH); - } -#endif - - return 1; -} - -#if defined(CONFIG_HTTP_DIRECTORIES) -static void procdirlisting(struct connstruct *cn) -{ - char buf[MAXREQUESTLENGTH]; - char actualfile[1024]; - - if (cn->reqtype == TYPE_HEAD) - { - snprintf(buf, sizeof(buf), HTTP_VERSION - " 200 OK\nContent-Type: text/html\n\n"); - if (write(cn->networkdesc, buf, strlen(buf)) < 0) - { - printf("procdirlisting: could not write"); - TTY_FLUSH(); - } - - removeconnection(cn); - return; - } - - strcpy(actualfile, cn->actualfile); - -#ifdef WIN32 - strcat(actualfile, "*"); - cn->dirp = FindFirstFile(actualfile, &cn->file_data); - - if (cn->dirp == INVALID_HANDLE_VALUE) - { - send_error(cn, 404); - return; - } -#else - if ((cn->dirp = opendir(actualfile)) == NULL) - { - send_error(cn, 404); - return; - } -#endif - - snprintf(buf, sizeof(buf), HTTP_VERSION - " 200 OK\nContent-Type: text/html\n\n" - "\nDirectory Listing\n" - "

Directory listing of %s://%s%s


\n", - cn->is_ssl ? "https" : "http", cn->server_name, cn->filereq); - special_write(cn, buf, strlen(buf)); - cn->state = STATE_DOING_DIR; -} - -void procdodir(struct connstruct *cn) -{ -#ifndef WIN32 - struct dirent *dp; -#endif - char buf[MAXREQUESTLENGTH]; - char encbuf[1024]; - char *file; - - do - { - buf[0] = 0; - -#ifdef WIN32 - if (!FindNextFile(cn->dirp, &cn->file_data)) -#else - if ((dp = readdir(cn->dirp)) == NULL) -#endif - { - snprintf(buf, sizeof(buf), "\n"); - special_write(cn, buf, strlen(buf)); - removeconnection(cn); -#ifndef WIN32 - closedir(cn->dirp); -#endif - return; - } - -#ifdef WIN32 - file = cn->file_data.cFileName; -#else - file = dp->d_name; -#endif - - /* if no index file, don't display the ".." directory */ - if (cn->filereq[0] == '/' && cn->filereq[1] == '\0' && - strcmp(file, "..") == 0) - continue; - - /* don't display files beginning with "." */ - if (file[0] == '.' && file[1] != '.') - continue; - - /* make sure a '/' is at the end of a directory */ - if (cn->filereq[strlen(cn->filereq)-1] != '/') - strcat(cn->filereq, "/"); - - /* see if the dir + file is another directory */ - snprintf(buf, sizeof(buf), "%s%s", cn->actualfile, file); - if (isdir(buf)) - strcat(file, "/"); - - urlencode((uint8_t *)file, encbuf); - snprintf(buf, sizeof(buf), "
%s
\n", - cn->filereq, encbuf, file); - } while (special_write(cn, buf, strlen(buf))); -} - -/* Encode funny chars -> %xx in newly allocated storage */ -/* (preserves '/' !) */ -static void urlencode(const uint8_t *s, char *t) -{ - const uint8_t *p = s; - char *tp = t; - - for (; *p; p++) - { - if ((*p > 0x00 && *p < ',') || - (*p > '9' && *p < 'A') || - (*p > 'Z' && *p < '_') || - (*p > '_' && *p < 'a') || - (*p > 'z' && *p < 0xA1)) - { - sprintf((char *)tp, "%%%02X", *p); - tp += 3; - } - else - { - *tp = *p; - tp++; - } - } - - *tp='\0'; -} - -#endif - -void procreadhead(struct connstruct *cn) -{ - char buf[MAXREADLENGTH], *tp, *next; - int rv; - - memset(buf, 0, sizeof(buf)); - rv = special_read(cn, buf, sizeof(buf)-1); - if (rv <= 0) - { - if (rv < 0 || !cn->is_ssl) /* really dead? */ - removeconnection(cn); - return; - } - - buf[rv] = '\0'; - next = tp = buf; - -#ifdef CONFIG_HTTP_HAS_AUTHORIZATION - cn->authorization[0] = 0; -#endif - - /* Split up lines and send to procheadelem() */ - while (*next != '\0') - { - /* If we have a blank line, advance to next stage */ - if (*next == '\r' || *next == '\n') - { -#if defined(CONFIG_HTTP_HAS_CGI) - if (cn->reqtype == TYPE_POST && cn->content_length > 0) - { - if (init_read_post_data(buf, next, cn, rv) == 0) - return; - } -#endif - - buildactualfile(cn); - cn->state = STATE_WANT_TO_SEND_HEAD; - return; - } - - while (*next != '\r' && *next != '\n' && *next != '\0') - next++; - - if (*next == '\r') - { - *next = '\0'; - next += 2; - } - else if (*next == '\n') - *next++ = '\0'; - - if (procheadelem(cn, tp) == 0) - return; - - tp = next; - } -} - -/* In this function we assume that the file has been checked for - * maliciousness (".."s, etc) and has been decoded - */ -void procsendhead(struct connstruct *cn) -{ - char buf[MAXREQUESTLENGTH]; - struct stat stbuf; - time_t t_time; - struct tm *ptm; - char date[32]; - char last_modified[32]; - char expires[32]; - int file_exists; - - /* are we trying to access a file over the HTTP connection instead of a - * HTTPS connection? Or is this directory disabled? */ - if (htaccess_check(cn)) - { - send_error(cn, 403); - return; - } - -#ifdef CONFIG_HTTP_HAS_AUTHORIZATION - if (auth_check(cn)) /* see if there is a '.htpasswd' file */ - { -#ifdef CONFIG_HTTP_VERBOSE - printf("axhttpd: access to %s denied\n", cn->filereq); TTY_FLUSH(); -#endif - removeconnection(cn); - return; - } -#endif - - file_exists = stat(cn->actualfile, &stbuf); - -#if defined(CONFIG_HTTP_HAS_CGI) - if (file_exists != -1 && cn->is_cgi) - { - proccgi(cn); - return; - } -#endif - - /* look for "index.html"? */ - if (isdir(cn->actualfile)) - { - char tbuf[MAXREQUESTLENGTH]; - snprintf(tbuf, MAXREQUESTLENGTH, "%s%s", cn->actualfile, index_file); - - if ((file_exists = stat(tbuf, &stbuf)) != -1) - my_strncpy(cn->actualfile, tbuf, MAXREQUESTLENGTH); - else - { -#if defined(CONFIG_HTTP_DIRECTORIES) - /* If not, we do a directory listing of it */ - procdirlisting(cn); -#else - send_error(cn, 404); -#endif - return; - } - } - - if (file_exists == -1) - { - send_error(cn, 404); - return; - } - - - time(&t_time); - ptm = gmtime(&t_time); - strftime(date, sizeof(date), rfc1123_format, ptm); - - /* has the file been read before? */ - if (cn->if_modified_since != -1) - - { - ptm = gmtime(&stbuf.st_mtime); - t_time = mktime(ptm); - - if (cn->if_modified_since >= t_time) - { - snprintf(buf, sizeof(buf), HTTP_VERSION" 304 Not Modified\nServer: " - "%s\nDate: %s\n\n", server_version, date); - special_write(cn, buf, strlen(buf)); - cn->state = STATE_WANT_TO_READ_HEAD; - return; - } - } - - if (cn->reqtype == TYPE_HEAD) - { - removeconnection(cn); - return; - } - else - { - int flags = O_RDONLY; -#if defined(WIN32) || defined(CONFIG_PLATFORM_CYGWIN) - flags |= O_BINARY; -#endif - cn->filedesc = open(cn->actualfile, flags); - - if (cn->filedesc < 0) - { - send_error(cn, 404); - return; - } - - ptm = gmtime(&stbuf.st_mtime); - strftime(last_modified, sizeof(last_modified), rfc1123_format, ptm); - t_time += CONFIG_HTTP_TIMEOUT; - ptm = gmtime(&t_time); - strftime(expires, sizeof(expires), rfc1123_format, ptm); - - snprintf(buf, sizeof(buf), HTTP_VERSION" 200 OK\nServer: %s\n" - "Content-Type: %s\nContent-Length: %ld\n" - "Date: %s\nLast-Modified: %s\nExpires: %s\n\n", server_version, - getmimetype(cn->actualfile), (long) stbuf.st_size, - date, last_modified, expires); - - special_write(cn, buf, strlen(buf)); - -#ifdef CONFIG_HTTP_VERBOSE - printf("axhttpd: %s:/%s\n", cn->is_ssl ? "https" : "http", cn->filereq); - TTY_FLUSH(); -#endif - -#ifdef WIN32 - for (;;) - { - procreadfile(cn); - if (cn->filedesc == -1) - break; - - do - { - procsendfile(cn); - } while (cn->state != STATE_WANT_TO_READ_FILE); - } -#else - cn->state = STATE_WANT_TO_READ_FILE; -#endif - } -} - -void procreadfile(struct connstruct *cn) -{ - int rv = read(cn->filedesc, cn->databuf, BLOCKSIZE); - - if (rv <= 0) - { - close(cn->filedesc); - cn->filedesc = -1; - - if (cn->close_when_done) /* close immediately */ - removeconnection(cn); - else - { - if (cn->is_v1_0) /* die now */ - removeconnection(cn); - else /* keep socket open - HTTP 1.1 */ - { - cn->state = STATE_WANT_TO_READ_HEAD; - cn->numbytes = 0; - } - } - - return; - } - - cn->numbytes = rv; - cn->state = STATE_WANT_TO_SEND_FILE; -} - -void procsendfile(struct connstruct *cn) -{ - int rv = special_write(cn, cn->databuf, cn->numbytes); - - if (rv < 0) - removeconnection(cn); - else if (rv == cn->numbytes) - { - cn->state = STATE_WANT_TO_READ_FILE; - } - else if (rv == 0) - { - /* Do nothing */ - } - else - { - memmove(cn->databuf, cn->databuf + rv, cn->numbytes - rv); - cn->numbytes -= rv; - } -} - -#if defined(CONFIG_HTTP_HAS_CGI) -/* Should this be a bit more dynamic? It would mean more calls to malloc etc */ -#define CGI_ARG_SIZE 17 - -static void proccgi(struct connstruct *cn) -{ - int tpipe[2], spipe[2]; - char *myargs[3]; - char cgienv[CGI_ARG_SIZE][MAXREQUESTLENGTH]; - char * cgiptr[CGI_ARG_SIZE+4]; - const char *type = "HEAD"; - int cgi_index = 0, i; - pid_t pid; -#ifdef WIN32 - int tmp_stdout; -#endif - - snprintf(cgienv[0], MAXREQUESTLENGTH, - HTTP_VERSION" 200 OK\nServer: %s\n%s", - server_version, (cn->reqtype == TYPE_HEAD) ? "\n" : ""); - special_write(cn, cgienv[0], strlen(cgienv[0])); - - if (cn->reqtype == TYPE_HEAD) - { - removeconnection(cn); - return; - } - -#ifdef CONFIG_HTTP_VERBOSE - printf("[CGI]: %s:/%s\n", cn->is_ssl ? "https" : "http", cn->filereq); - TTY_FLUSH(); -#endif - - /* win32 cgi is a bit too painful */ -#ifndef WIN32 - /* set up pipe that is used for sending POST query data to CGI script*/ - if (cn->reqtype == TYPE_POST) - { - if (pipe(spipe) == -1) - { - printf("[CGI]: could not create pipe"); - TTY_FLUSH(); - return; - } - } - - if (pipe(tpipe) == -1) - { - printf("[CGI]: could not create pipe"); - TTY_FLUSH(); - return; - } - - /* - * use vfork() instead of fork() for performance - */ - if ((pid = vfork()) > 0) /* parent */ - { - /* Send POST query data to CGI script */ - if ((cn->reqtype == TYPE_POST) && (cn->content_length > 0)) - { - if (write(spipe[1], cn->post_data, cn->content_length) == -1) - { - printf("[CGI]: could write to pipe"); - TTY_FLUSH(); - return; - } - - close(spipe[0]); - close(spipe[1]); - - /* free the memory that is allocated in read_post_data() */ - free(cn->post_data); - cn->post_data = NULL; - } - - /* Close the write descriptor */ - close(tpipe[1]); - cn->filedesc = tpipe[0]; - cn->state = STATE_WANT_TO_READ_FILE; - cn->close_when_done = 1; - return; - } - - if (pid < 0) /* vfork failed */ - exit(1); - - /* The problem child... */ - - /* Our stdout/stderr goes to the socket */ - dup2(tpipe[1], 1); - dup2(tpipe[1], 2); - close(tpipe[0]); - close(tpipe[1]); - - /* If it was a POST request, send the socket data to our stdin */ - if (cn->reqtype == TYPE_POST) { - dup2(spipe[0], 0); - close(spipe[0]); - close(spipe[1]); - } else /* Otherwise we can shutdown the read side of the sock */ - shutdown(cn->networkdesc, 0); - - myargs[0] = CONFIG_HTTP_CGI_LAUNCHER; - myargs[1] = cn->actualfile; - myargs[2] = NULL; - - /* - * set the cgi args. A url is defined by: - * http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO?$QUERY_STRING - * TODO: other CGI parameters? - */ - sprintf(cgienv[cgi_index++], "SERVER_SOFTWARE=%s", server_version); - strcpy(cgienv[cgi_index++], "DOCUMENT_ROOT=" CONFIG_HTTP_WEBROOT); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "SERVER_NAME=%s", cn->server_name); - sprintf(cgienv[cgi_index++], "SERVER_PORT=%d", - cn->is_ssl ? CONFIG_HTTP_HTTPS_PORT : CONFIG_HTTP_PORT); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "REQUEST_URI=%s", cn->uri_request); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "SCRIPT_NAME=%s", cn->filereq); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "PATH_INFO=%s", cn->uri_path_info); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "QUERY_STRING=%s", cn->uri_query); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "REMOTE_ADDR=%s", cn->remote_addr); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "HTTP_COOKIE=%s", cn->cookie); /* note: small size */ -#if defined(CONFIG_HTTP_HAS_AUTHORIZATION) - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "REMOTE_USER=%s", cn->authorization); -#endif - - switch (cn->reqtype) - { - case TYPE_GET: - type = "GET"; - break; - -#if defined(CONFIG_HTTP_HAS_CGI) - case TYPE_POST: - type = "POST"; - sprintf(cgienv[cgi_index++], - "CONTENT_LENGTH=%d", cn->content_length); - snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH, - "CONTENT_TYPE=%s", cn->cgicontenttype); - break; -#endif - } - - sprintf(cgienv[cgi_index++], "REQUEST_METHOD=%s", type); - - if (cn->is_ssl) - strcpy(cgienv[cgi_index++], "HTTPS=on"); - - if (cgi_index >= CGI_ARG_SIZE) - { - printf("Content-type: text/plain\n\nToo many CGI args (%d, %d)\n", - cgi_index, CGI_ARG_SIZE); - _exit(1); - } - - /* copy across the pointer indexes */ - for (i = 0; i < cgi_index; i++) - cgiptr[i] = cgienv[i]; - - cgiptr[i++] = "AUTH_TYPE=Basic"; - cgiptr[i++] = "GATEWAY_INTERFACE=CGI/1.1"; - cgiptr[i++] = "SERVER_PROTOCOL="HTTP_VERSION; - cgiptr[i] = NULL; - - execve(myargs[0], myargs, cgiptr); - printf("Content-type: text/plain\n\nshouldn't get here\n"); - _exit(1); -#endif -} - -static char * cgi_filetype_match(struct connstruct *cn, const char *fn) -{ - struct cgiextstruct *tp = cgiexts; - - while (tp != NULL) - { - char *t; - - if ((t = strstr(fn, tp->ext)) != NULL) - { - t += strlen(tp->ext); - - if (*t == '/' || *t == '\0') - return t; - else - return NULL; - - } - - tp = tp->next; - } - - return NULL; -} - -static void decode_path_info(struct connstruct *cn, char *path_info) -{ - char *cgi_delim; - -#if defined(CONFIG_HTTP_HAS_CGI) - cn->is_cgi = 0; -#endif - *cn->uri_request = '\0'; - *cn->uri_path_info = '\0'; - *cn->uri_query = '\0'; - - my_strncpy(cn->uri_request, path_info, MAXREQUESTLENGTH); - - /* query info? */ - if ((cgi_delim = strchr(path_info, '?'))) - { - *cgi_delim = '\0'; - my_strncpy(cn->uri_query, cgi_delim+1, MAXREQUESTLENGTH); - } - -#if defined(CONFIG_HTTP_HAS_CGI) - if ((cgi_delim = cgi_filetype_match(cn, path_info)) != NULL) - { - cn->is_cgi = 1; /* definitely a CGI script */ - - /* path info? */ - if (*cgi_delim != '\0') - { - my_strncpy(cn->uri_path_info, cgi_delim, MAXREQUESTLENGTH); - *cgi_delim = '\0'; - } - } -#endif - - /* the bit at the start must be the script name */ - my_strncpy(cn->filereq, path_info, MAXREQUESTLENGTH); -} - -static int init_read_post_data(char *buf, char *data, - struct connstruct *cn, int old_rv) -{ - char *next = data; - int rv = old_rv; - char *post_data; - - /* Too much Post data to send. MAXPOSTDATASIZE should be - configured (now it can be changed in the header file) */ - if (cn->content_length > MAXPOSTDATASIZE) - { - send_error(cn, 418); - return 0; - } - - /* remove CRLF */ - while ((*next == '\r' || *next == '\n') && (next < &buf[rv])) - next++; - - if (cn->post_data == NULL) - { - /* Allocate buffer for the POST data that will be used by proccgi - to send POST data to the CGI script */ - cn->post_data = (char *)calloc(1, (cn->content_length + 1)); - } - - cn->post_state = 0; - cn->post_read = 0; - post_data = cn->post_data; - - while (next < &buf[rv]) - { - /* copy POST data to buffer */ - *post_data++ = *next++; - cn->post_read++; - if (cn->post_read == cn->content_length) - { - /* No more POST data to be copied */ - *post_data = '\0'; - return 1; - } - } - - /* More POST data has to be read. read_post_data will continue with that */ - cn->post_state = 1; - return 0; -} - -void read_post_data(struct connstruct *cn) -{ - char buf[MAXREADLENGTH], *next; - char *post_data; - int rv; - - memset(buf, 0, sizeof(buf)); - rv = special_read(cn, buf, sizeof(buf)-1); - if (rv <= 0) - { - if (rv < 0 || !cn->is_ssl) /* really dead? */ - removeconnection(cn); - return; - } - - buf[rv] = '\0'; - next = buf; - post_data = &cn->post_data[cn->post_read]; - - while (next < &buf[rv]) - { - *post_data++ = *next++; - cn->post_read++; - - if (cn->post_read == cn->content_length) - { - /* No more POST data to be copied */ - *post_data='\0'; - cn->post_state = 0; - buildactualfile(cn); - cn->state = STATE_WANT_TO_SEND_HEAD; - return; - } - } - - /* More POST data to read */ -} - -#endif /* CONFIG_HTTP_HAS_CGI */ - -/* Decode string %xx -> char (in place) */ -static void urldecode(char *buf) -{ - int v; - char *p, *s, *w; - - w = p = buf; - - while (*p) - { - v = 0; - - if (*p == '%') - { - s = p; - s++; - - if (isxdigit((int) s[0]) && isxdigit((int) s[1])) - { - v = hexit(s[0])*16 + hexit(s[1]); - - if (v) - { - /* do not decode %00 to null char */ - *w = (char)v; - p = &s[1]; - } - } - - } - - if (!v) *w=*p; - p++; - w++; - } - - *w='\0'; -} - -static int hexit(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - else if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - else - return 0; -} - -static void buildactualfile(struct connstruct *cn) -{ - char *cp; - snprintf(cn->actualfile, MAXREQUESTLENGTH, ".%s", cn->filereq); - -#ifndef WIN32 - /* Add directory slash if not there */ - if (isdir(cn->actualfile) && - cn->actualfile[strlen(cn->actualfile)-1] != '/') - strcat(cn->actualfile, "/"); - - /* work out the directory name */ - strncpy(cn->dirname, cn->actualfile, MAXREQUESTLENGTH); - if ((cp = strrchr(cn->dirname, '/')) == NULL) - cn->dirname[0] = 0; - else - *cp = 0; -#else - { - char curr_dir[MAXREQUESTLENGTH]; - char path[MAXREQUESTLENGTH]; - char *t = cn->actualfile; - - GetCurrentDirectory(MAXREQUESTLENGTH, curr_dir); - - /* convert all the forward slashes to back slashes */ - while ((t = strchr(t, '/'))) - *t++ = '\\'; - - snprintf(path, MAXREQUESTLENGTH, "%s%s", curr_dir, cn->actualfile); - memcpy(cn->actualfile, path, MAXREQUESTLENGTH); - - /* Add directory slash if not there */ - if (isdir(cn->actualfile) && - cn->actualfile[strlen(cn->actualfile)-1] != '\\') - strcat(cn->actualfile, "\\"); - - /* work out the directory name */ - strncpy(cn->dirname, cn->actualfile, MAXREQUESTLENGTH); - if ((cp = strrchr(cn->dirname, '\\')) == NULL) - cn->dirname[0] = 0; - else - *cp = 0; - } -#endif -} - -static int sanitizefile(const char *buf) -{ - int len, i; - - /* Don't accept anything not starting with a / */ - if (*buf != '/') - return 0; - - len = strlen(buf); - for (i = 0; i < len; i++) - { - /* Check for "/." i.e. don't send files starting with a . */ - if (buf[i] == '/' && buf[i+1] == '.') - return 0; - } - - return 1; -} - -static int sanitizehost(char *buf) -{ - while (*buf != '\0') - { - /* Handle the port */ - if (*buf == ':') - { - *buf = '\0'; - return 1; - } - - /* Enforce some basic URL rules... */ - if ((isalnum((int)(*buf)) == 0 && *buf != '-' && *buf != '.') || - (*buf == '.' && *(buf+1) == '.') || - (*buf == '.' && *(buf+1) == '-') || - (*buf == '-' && *(buf+1) == '.')) - return 0; - - buf++; - } - - return 1; -} - -static FILE * exist_check(struct connstruct *cn, const char *check_file) -{ - char pathname[MAXREQUESTLENGTH]; - snprintf(pathname, MAXREQUESTLENGTH, "%s/%s", cn->dirname, check_file); - return fopen(pathname, "r"); -} - -#ifdef CONFIG_HTTP_HAS_AUTHORIZATION -static void send_authenticate(struct connstruct *cn, const char *realm) -{ - char buf[1024]; - - snprintf(buf, sizeof(buf), HTTP_VERSION" 401 Unauthorized\n" - "WWW-Authenticate: Basic\n" - "realm=\"%s\"\n", realm); - special_write(cn, buf, strlen(buf)); -} - -static int check_digest(char *salt, const char *msg_passwd) -{ - uint8_t b256_salt[MAXREQUESTLENGTH]; - uint8_t real_passwd[MD5_SIZE]; - int salt_size = sizeof(b256_salt); - int password_size = sizeof(real_passwd); - char *b64_passwd; - uint8_t md5_result[MD5_SIZE]; - MD5_CTX ctx; - - /* retrieve the salt */ - if ((b64_passwd = strchr(salt, '$')) == NULL) - return -1; - - *b64_passwd++ = 0; - if (base64_decode(salt, strlen(salt), b256_salt, &salt_size)) - return -1; - - if (base64_decode(b64_passwd, strlen(b64_passwd), real_passwd, - &password_size)) - return -1; - - /* very simple MD5 crypt algorithm, but then the salt we use is large */ - MD5_Init(&ctx); - MD5_Update(&ctx, b256_salt, salt_size); /* process the salt */ - MD5_Update(&ctx, (uint8_t *)msg_passwd, strlen(msg_passwd)); - MD5_Final(md5_result, &ctx); - return memcmp(md5_result, real_passwd, MD5_SIZE);/* 0 = ok */ -} - -static int auth_check(struct connstruct *cn) -{ - char line[MAXREQUESTLENGTH]; - FILE *fp; - char *cp; - - if ((fp = exist_check(cn, ".htpasswd")) == NULL) - return 0; /* no .htpasswd file, so let though */ - - if (cn->authorization[0] == 0) - goto error; - - /* cn->authorization is in form "username:password" */ - if ((cp = strchr(cn->authorization, ':')) == NULL) - goto error; - else - *cp++ = 0; /* cp becomes the password */ - - while (fgets(line, sizeof(line), fp) != NULL) - { - char *b64_file_passwd; - int l = strlen(line); - - /* nuke newline */ - if (line[l-1] == '\n') - line[l-1] = 0; - - /* line is form "username:salt(b64)$password(b64)" */ - if ((b64_file_passwd = strchr(line, ':')) == NULL) - continue; - - *b64_file_passwd++ = 0; - - if (strcmp(line, cn->authorization)) /* our user? */ - continue; - - if (check_digest(b64_file_passwd, cp) == 0) - { - fclose(fp); - return 0; - } - } - -error: - fclose(fp); - send_authenticate(cn, cn->server_name); - return -1; -} -#endif - -static int htaccess_check(struct connstruct *cn) -{ - char line[MAXREQUESTLENGTH]; - FILE *fp; - int ret = 0; - - if ((fp = exist_check(cn, ".htaccess")) == NULL) - return 0; /* no .htaccess file, so let though */ - - while (fgets(line, sizeof(line), fp) != NULL) - { - if (strstr(line, "Deny all") || /* access to this dir denied */ - /* Access will be denied unless SSL is active */ - (!cn->is_ssl && strstr(line, "SSLRequireSSL")) || - /* Access will be denied if SSL is active */ - (cn->is_ssl && strstr(line, "SSLDenySSL"))) - { - ret = -1; - break; - } - } - - fclose(fp); - return ret; -} - -static void send_error(struct connstruct *cn, int err) -{ - char buf[MAXREQUESTLENGTH]; - char *title; - char *text; - - switch (err) - { - case 403: - title = "Forbidden"; - text = "File is protected"; -#ifdef CONFIG_HTTP_VERBOSE - printf("axhttpd: access to %s denied\n", cn->filereq); TTY_FLUSH(); -#endif - break; - - case 404: - title = "Not Found"; - text = title; - break; - - case 418: - title = "POST data size is too large"; - text = title; - break; - - default: - title = "Unknown"; - text = "Unknown"; - break; - } - - snprintf(buf, sizeof(buf), HTTP_VERSION" 200 OK\n" - "Content-Type: text/html\n\n" - "\n%s\n" - "

Error %d - %s

\n\n", - title, err, text); - special_write(cn, buf, strlen(buf)); - -#ifdef CONFIG_HTTP_VERBOSE - printf("axhttpd: http error: %s [%d]\n", title, err); TTY_FLUSH(); -#endif - removeconnection(cn); -} - -static const char *getmimetype(const char *name) -{ - /* only bother with a few mime types - let the browser figure the rest out */ - if (strstr(name, ".htm")) - return "text/html"; - else if (strstr(name, ".css")) - return "text/css"; - else if (strstr(name, ".php")) - return "application/x-http-php"; - else - return "application/octet-stream"; -} - -static int special_write(struct connstruct *cn, - const char *buf, size_t count) -{ - if (cn->is_ssl) - { - SSL *ssl = cn->ssl; - return ssl ? ssl_write(ssl, (uint8_t *)buf, count) : -1; - } - else - return SOCKET_WRITE(cn->networkdesc, buf, count); -} - -static int special_read(struct connstruct *cn, void *buf, size_t count) -{ - int res; - - if (cn->is_ssl) - { - uint8_t *read_buf; - if ((res = ssl_read(cn->ssl, &read_buf)) > SSL_OK) - { - memcpy(buf, read_buf, res > (int)count ? count : res); - } - } - else - res = SOCKET_READ(cn->networkdesc, buf, count); - - return res; -} - diff --git a/user/mpy/lib/axtls/httpd/tdate_parse.c b/user/mpy/lib/axtls/httpd/tdate_parse.c deleted file mode 100644 index 7165bde..0000000 --- a/user/mpy/lib/axtls/httpd/tdate_parse.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include "axhttp.h" - -struct day_mon_map -{ - const char* s; - uint8_t l; -}; - -static struct day_mon_map wday_tab[] = -{ - { "Sun", 0 }, { "Mon", 1 }, { "Tue", 2 }, { "Wed", 3 }, - { "Thu", 4 }, { "Fri", 5 }, { "Sat", 6 }, -}; - -static struct day_mon_map mon_tab[] = -{ - { "Jan", 0 }, { "Feb", 1 }, { "Mar", 2 }, { "Apr", 3 }, - { "May", 4 }, { "Jun", 5 }, { "Jul", 6 }, { "Aug", 7 }, - { "Sep", 8 }, { "Oct", 9 }, { "Nov", 10 }, { "Dec", 11 }, -}; - -static int day_mon_map_compare(const char *v1, const char *v2) -{ - return strcmp(((struct day_mon_map*)v1)->s, ((struct day_mon_map*)v2)->s); -} - -void tdate_init(void) -{ - qsort(wday_tab, sizeof(wday_tab)/sizeof(struct day_mon_map), - sizeof(struct day_mon_map), - (int (*)(const void *, const void *))day_mon_map_compare); - qsort(mon_tab, sizeof(mon_tab)/sizeof(struct day_mon_map), - sizeof(struct day_mon_map), - (int (*)(const void *, const void *))day_mon_map_compare); -} - -static int8_t day_mon_map_search(const char* str, - const struct day_mon_map* tab, int n) -{ - struct day_mon_map *search = bsearch(&str, tab, n, - sizeof(struct day_mon_map), - (int (*)(const void *, const void *))day_mon_map_compare); - return search ? search->l : -1; -} - -time_t tdate_parse(const char* str) -{ - struct tm tm; - char str_mon[4], str_wday[4]; - int tm_sec, tm_min, tm_hour, tm_mday, tm_year; - - /* Initialize. */ - memset(&tm, 0, sizeof(struct tm)); - - /* wdy, DD mth YY HH:MM:SS GMT */ - if (sscanf(str, "%3[a-zA-Z], %d %3[a-zA-Z] %d %d:%d:%d GMT", - str_wday, &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, - &tm_sec) == 7) - { - int8_t tm_wday = day_mon_map_search(str_wday, wday_tab, - sizeof(wday_tab)/sizeof(struct day_mon_map)); - int8_t tm_mon = day_mon_map_search(str_mon, mon_tab, - sizeof(mon_tab)/sizeof(struct day_mon_map)); - - if (tm_wday < 0 || tm_mon < 0) - return -1; - - tm.tm_wday = tm_wday; - tm.tm_mon = tm_mon; - tm.tm_mday = tm_mday; - tm.tm_hour = tm_hour; - tm.tm_min = tm_min; - tm.tm_sec = tm_sec; - tm.tm_year = tm_year - 1900; - return mktime(&tm); - } - - return -1; /* error */ -} diff --git a/user/mpy/lib/axtls/samples/Config.in b/user/mpy/lib/axtls/samples/Config.in deleted file mode 100644 index ecad25e..0000000 --- a/user/mpy/lib/axtls/samples/Config.in +++ /dev/null @@ -1,63 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see scripts/config/Kconfig-language.txt -# -menu "Samples" - -config CONFIG_SAMPLES - bool "Create Samples" - default y - help - axTLS contains various sample code. - - Select Y here if you want to build the various samples. - -config CONFIG_C_SAMPLES - bool "axssl - C version" - default y - depends on CONFIG_SAMPLES - help - Build the "C" version of axssl. The features enabled are very - dependent on the build mode ('full' mode will give all features). - -config CONFIG_CSHARP_SAMPLES - bool "axssl - C# version" - default y - depends on CONFIG_SAMPLES && CONFIG_CSHARP_BINDINGS - help - Build the "C#" version of axssl. The features enabled are very - dependent on the build mode ('full' mode will give all features). - -config CONFIG_VBNET_SAMPLES - bool "axssl - VB.NET version" - default y - depends on CONFIG_SAMPLES && CONFIG_VBNET_BINDINGS - help - Build the "VB.NET" version of axssl. The features enabled are very - dependent on the build mode ('full' mode will give all features). - -config CONFIG_JAVA_SAMPLES - bool "axssl - Java version" - default y - depends on CONFIG_SAMPLES && CONFIG_JAVA_BINDINGS - help - Build the "Java" version of axssl. The features enabled are very - dependent on the build mode ('full' mode will give all features). - -config CONFIG_PERL_SAMPLES - bool "axssl - Perl version" - default y - depends on CONFIG_SAMPLES && CONFIG_PERL_BINDINGS - help - Build the "Perl" version of axssl. The features enabled are very - dependent on the build mode ('full' mode will give all features). - -config CONFIG_LUA_SAMPLES - bool "axssl - Lua version" - default y - depends on CONFIG_SAMPLES && CONFIG_LUA_BINDINGS - help - Build the "Lua" version of axssl. The features enabled are very - dependent on the build mode ('full' mode will give all features). -endmenu - diff --git a/user/mpy/lib/axtls/samples/Makefile b/user/mpy/lib/axtls/samples/Makefile deleted file mode 100644 index afbdd43..0000000 --- a/user/mpy/lib/axtls/samples/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -all: - -include ../config/.config -include ../config/makefile.conf - -all: -ifdef CONFIG_C_SAMPLES - $(MAKE) -C c -endif -ifdef CONFIG_CSHARP_SAMPLES - $(MAKE) -C csharp -endif -ifdef CONFIG_VBNET_SAMPLES - $(MAKE) -C vbnet -endif -ifdef CONFIG_JAVA_SAMPLES - $(MAKE) -C java -endif -ifdef CONFIG_PERL_SAMPLES - $(MAKE) -C perl -endif -ifdef CONFIG_LUA_SAMPLES - $(MAKE) -C lua -endif - -clean:: - $(MAKE) -C c clean - $(MAKE) -C csharp clean - $(MAKE) -C vbnet clean - $(MAKE) -C java clean - $(MAKE) -C perl clean - $(MAKE) -C lua clean diff --git a/user/mpy/lib/axtls/samples/c/Makefile b/user/mpy/lib/axtls/samples/c/Makefile deleted file mode 100644 index 1966eec..0000000 --- a/user/mpy/lib/axtls/samples/c/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright (c) 2007-2016, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -all : sample - -AXTLS_HOME=../.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -ifndef CONFIG_PLATFORM_WIN32 - -ifdef CONFIG_PLATFORM_CYGWIN -TARGET=$(AXTLS_HOME)/$(STAGE)/axssl.exe -else -TARGET=$(AXTLS_HOME)/$(STAGE)/axssl -endif # cygwin - -LIBS=$(AXTLS_HOME)/$(STAGE) -else -TARGET=$(AXTLS_HOME)/$(STAGE)/axssl.exe -endif - -ifndef CONFIG_C_SAMPLES -sample: - -else -sample : $(TARGET) -OBJ= axssl.o -include $(AXTLS_HOME)/config/makefile.post - -ifndef CONFIG_PLATFORM_WIN32 - -$(TARGET): $(OBJ) $(LIBS)/libaxtls.a - $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)/libaxtls.a -# $(LD) $(LDFLAGS) -o $@ $(OBJ) -L$(LIBS) -laxtls (shared library) -ifdef CONFIG_STRIP_UNWANTED_SECTIONS - $(STRIP) --remove-section=.comment $(TARGET) -endif # use strip -else # Win32 - -$(TARGET): $(OBJ) - $(LD) $(LDFLAGS) $(AXTLS_HOME)/config/axtls.res /out:$@ $^ /libpath:"$(AXTLS_HOME)/$(STAGE)" axtls.lib -endif - -endif # CONFIG_C_SAMPLES - -clean:: - -@rm -f $(AXTLS_HOME)/$(STAGE)/axssl* - diff --git a/user/mpy/lib/axtls/samples/c/axssl.c b/user/mpy/lib/axtls/samples/c/axssl.c deleted file mode 100644 index 8de9d60..0000000 --- a/user/mpy/lib/axtls/samples/c/axssl.c +++ /dev/null @@ -1,904 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Demonstrate the use of the axTLS library in C with a set of - * command-line parameters similar to openssl. In fact, openssl clients - * should be able to communicate with axTLS servers and visa-versa. - * - * This code has various bits enabled depending on the configuration. To enable - * the most interesting version, compile with the 'full mode' enabled. - * - * To see what options you have, run the following: - * > axssl s_server -? - * > axssl s_client -? - * - * The axtls shared library must be in the same directory or be found - * by the OS. - */ -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -/* define standard input */ -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif - -static void do_server(int argc, char *argv[]); -static void print_options(char *option); -static void print_server_options(char *option); -static void do_client(int argc, char *argv[]); -static void print_client_options(char *option); -static void display_cipher(SSL *ssl); -static void display_session_id(SSL *ssl); - -/** - * Main entry point. Doesn't do much except works out whether we are a client - * or a server. - */ -int main(int argc, char *argv[]) -{ -#ifdef WIN32 - WSADATA wsaData; - WORD wVersionRequested = MAKEWORD(2, 2); - WSAStartup(wVersionRequested, &wsaData); -#elif !defined(CONFIG_PLATFORM_SOLARIS) - signal(SIGPIPE, SIG_IGN); /* ignore pipe errors */ -#endif - - if (argc == 2 && strcmp(argv[1], "version") == 0) - { - printf("axssl %s %s\n", ssl_version(), __DATE__); - exit(0); - } - - if (argc < 2 || ( - strcmp(argv[1], "s_server") && strcmp(argv[1], "s_client"))) - print_options(argc > 1 ? argv[1] : ""); - -// strcmp(argv[1], "s_server") ? - do_client(argc, argv);// : do_server(argc, argv); - return 0; -} - -/** - * Implement the SSL server logic. - */ -static void do_server(int argc, char *argv[]) -{ - int i = 2; - uint16_t port = 4433; - uint32_t options = SSL_DISPLAY_CERTS; - int client_fd; - SSL_CTX *ssl_ctx; - int server_fd, res = 0; - socklen_t client_len; -#ifndef CONFIG_SSL_SKELETON_MODE - char *private_key_file = NULL; - const char *password = NULL; - char **cert; - int cert_index = 0; - int cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); -#endif -#ifdef WIN32 - char yes = 1; -#else - int yes = 1; -#endif - struct sockaddr_in serv_addr; - struct sockaddr_in client_addr; - int quiet = 0; -#ifdef CONFIG_SSL_CERT_VERIFICATION - int ca_cert_index = 0; - int ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); - char **ca_cert = (char **)calloc(1, sizeof(char *)*ca_cert_size); -#endif - fd_set read_set; - -#ifndef CONFIG_SSL_SKELETON_MODE - cert = (char **)calloc(1, sizeof(char *)*cert_size); -#endif - - while (i < argc) - { - if (strcmp(argv[i], "-accept") == 0) - { - if (i >= argc-1) - { - print_server_options(argv[i]); - } - - port = atoi(argv[++i]); - } -#ifndef CONFIG_SSL_SKELETON_MODE - else if (strcmp(argv[i], "-cert") == 0) - { - if (i >= argc-1 || cert_index >= cert_size) - { - print_server_options(argv[i]); - } - - cert[cert_index++] = argv[++i]; - } - else if (strcmp(argv[i], "-key") == 0) - { - if (i >= argc-1) - { - print_server_options(argv[i]); - } - - private_key_file = argv[++i]; - options |= SSL_NO_DEFAULT_KEY; - } - else if (strcmp(argv[i], "-pass") == 0) - { - if (i >= argc-1) - { - print_server_options(argv[i]); - } - - password = argv[++i]; - } -#endif - else if (strcmp(argv[i], "-quiet") == 0) - { - quiet = 1; - options &= ~SSL_DISPLAY_CERTS; - } -#ifdef CONFIG_SSL_CERT_VERIFICATION - else if (strcmp(argv[i], "-verify") == 0) - { - options |= SSL_CLIENT_AUTHENTICATION; - } - else if (strcmp(argv[i], "-CAfile") == 0) - { - if (i >= argc-1 || ca_cert_index >= ca_cert_size) - { - print_server_options(argv[i]); - } - - ca_cert[ca_cert_index++] = argv[++i]; - } -#endif -#ifdef CONFIG_SSL_FULL_MODE - else if (strcmp(argv[i], "-debug") == 0) - { - options |= SSL_DISPLAY_BYTES; - } - else if (strcmp(argv[i], "-state") == 0) - { - options |= SSL_DISPLAY_STATES; - } - else if (strcmp(argv[i], "-show-rsa") == 0) - { - options |= SSL_DISPLAY_RSA; - } -#endif - else /* don't know what this is */ - { - print_server_options(argv[i]); - } - - i++; - } - - if ((ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_SVR_SESS)) == NULL) - { - fprintf(stderr, "Error: Server context is invalid\n"); - exit(1); - } - -#ifndef CONFIG_SSL_SKELETON_MODE - if (private_key_file) - { - int obj_type = SSL_OBJ_RSA_KEY; - - /* auto-detect the key type from the file extension */ - if (strstr(private_key_file, ".p8")) - obj_type = SSL_OBJ_PKCS8; - else if (strstr(private_key_file, ".p12")) - obj_type = SSL_OBJ_PKCS12; - - if (ssl_obj_load(ssl_ctx, obj_type, private_key_file, password)) - { - fprintf(stderr, "Error: Private key '%s' is undefined.\n", - private_key_file); - exit(1); - } - } - - for (i = 0; i < cert_index; i++) - { - if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, cert[i], NULL)) - { - printf("Certificate '%s' is undefined.\n", cert[i]); - exit(1); - } - } -#endif - -#ifdef CONFIG_SSL_CERT_VERIFICATION - for (i = 0; i < ca_cert_index; i++) - { - if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, ca_cert[i], NULL)) - { - printf("Certificate '%s' is undefined.\n", ca_cert[i]); - exit(1); - } - } - - free(ca_cert); -#endif -#ifndef CONFIG_SSL_SKELETON_MODE - free(cert); -#endif - - /* Create socket for incoming connections */ - if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) - { - perror("socket"); - return; - } - - setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); - - /* Construct local address structure */ - memset(&serv_addr, 0, sizeof(serv_addr)); /* Zero out structure */ - serv_addr.sin_family = AF_INET; /* Internet address family */ - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */ - serv_addr.sin_port = htons(port); /* Local port */ - - /* Bind to the local address */ - if (bind(server_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) - { - perror("bind"); - exit(1); - } - - if (listen(server_fd, 5) < 0) - { - perror("listen"); - exit(1); - } - - client_len = sizeof(client_addr); - - /************************************************************************* - * This is where the interesting stuff happens. Up until now we've - * just been setting up sockets etc. Now we do the SSL handshake. - *************************************************************************/ - for (;;) - { - SSL *ssl; - int reconnected = 0; - - if (!quiet) - { - printf("ACCEPT\n"); - TTY_FLUSH(); - } - - if ((client_fd = accept(server_fd, - (struct sockaddr *)&client_addr, &client_len)) < 0) - { - break; - } - - ssl = ssl_server_new(ssl_ctx, client_fd); - - /* now read (and display) whatever the client sends us */ - for (;;) - { - /* allow parallel reading of client and standard input */ - FD_ZERO(&read_set); - FD_SET(client_fd, &read_set); - -#ifndef WIN32 - /* win32 doesn't like mixing up stdin and sockets */ - if (isatty(STDIN_FILENO))/* but only if we are in an active shell */ - { - FD_SET(STDIN_FILENO, &read_set); - } - - if ((res = select(client_fd+1, &read_set, NULL, NULL, NULL)) > 0) - { - uint8_t buf[1024]; - - /* read standard input? */ - if (FD_ISSET(STDIN_FILENO, &read_set)) - { - if (fgets((char *)buf, sizeof(buf), stdin) == NULL) - { - res = SSL_ERROR_CONN_LOST; - } - else - { - /* small hack to check renegotiation */ - if (buf[0] == 'r' && (buf[1] == '\n' || buf[1] == '\r')) - { - res = ssl_renegotiate(ssl); - } - else /* write our ramblings to the client */ - { - res = ssl_write(ssl, buf, strlen((char *)buf)+1); - } - } - } - else /* a socket read */ -#endif - { - /* keep reading until we get something interesting */ - uint8_t *read_buf; - - if ((res = ssl_read(ssl, &read_buf)) == SSL_OK) - { - /* are we in the middle of doing a handshake? */ - if (ssl_handshake_status(ssl) != SSL_OK) - { - reconnected = 0; - } - else if (!reconnected) - { - /* we are connected/reconnected */ - if (!quiet) - { - display_session_id(ssl); - display_cipher(ssl); - } - - reconnected = 1; - } - } - - if (res > SSL_OK) /* display our interesting output */ - { - int written = 0; - while (written < res) - { - written += write(STDOUT_FILENO, read_buf+written, - res-written); - } - TTY_FLUSH(); - } - else if (res == SSL_CLOSE_NOTIFY) - { - printf("shutting down SSL\n"); - TTY_FLUSH(); - } - else if (res < SSL_OK && !quiet) - { - ssl_display_error(res); - } - } -#ifndef WIN32 - } -#endif - - if (res < SSL_OK) - { - if (!quiet) - { - printf("CONNECTION CLOSED\n"); - TTY_FLUSH(); - } - - break; - } - } - - /* client was disconnected or the handshake failed. */ - ssl_free(ssl); - SOCKET_CLOSE(client_fd); - } - - ssl_ctx_free(ssl_ctx); -} - -/** - * Implement the SSL client logic. - */ -static void do_client(int argc, char *argv[]) -{ -#ifdef CONFIG_SSL_ENABLE_CLIENT - int res, i = 2; - uint16_t port = 4433; - uint32_t options = SSL_SERVER_VERIFY_LATER|SSL_DISPLAY_CERTS; - int client_fd; - char *private_key_file = NULL; - struct sockaddr_in client_addr; - struct hostent *hostent; - int reconnect = 0; - uint32_t sin_addr; - SSL_CTX *ssl_ctx; - SSL *ssl = NULL; - int quiet = 0; - int cert_index = 0, ca_cert_index = 0; - int cert_size, ca_cert_size; - char **ca_cert, **cert; - uint8_t session_id[SSL_SESSION_ID_SIZE]; - fd_set read_set; - const char *password = NULL; - SSL_EXTENSIONS *extensions = NULL; - - FD_ZERO(&read_set); - sin_addr = inet_addr("127.0.0.1"); - cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); - ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); - ca_cert = (char **)calloc(1, sizeof(char *)*ca_cert_size); - cert = (char **)calloc(1, sizeof(char *)*cert_size); - - while (i < argc) - { - if (strcmp(argv[i], "-connect") == 0) - { - char *host, *ptr; - - if (i >= argc-1) - { - print_client_options(argv[i]); - } - - host = argv[++i]; - if ((ptr = strchr(host, ':')) == NULL) - { - print_client_options(argv[i]); - } - - *ptr++ = 0; - port = atoi(ptr); - hostent = gethostbyname(host); - - if (hostent == NULL) - { - print_client_options(argv[i]); - } - - sin_addr = *((uint32_t **)hostent->h_addr_list)[0]; - } - else if (strcmp(argv[i], "-cert") == 0) - { - if (i >= argc-1 || cert_index >= cert_size) - { - print_client_options(argv[i]); - } - - cert[cert_index++] = argv[++i]; - } - else if (strcmp(argv[i], "-key") == 0) - { - if (i >= argc-1) - { - print_client_options(argv[i]); - } - - private_key_file = argv[++i]; - options |= SSL_NO_DEFAULT_KEY; - } - else if (strcmp(argv[i], "-CAfile") == 0) - { - if (i >= argc-1 || ca_cert_index >= ca_cert_size) - { - print_client_options(argv[i]); - } - - ca_cert[ca_cert_index++] = argv[++i]; - } - else if (strcmp(argv[i], "-verify") == 0) - { - options &= ~SSL_SERVER_VERIFY_LATER; - } - else if (strcmp(argv[i], "-reconnect") == 0) - { - reconnect = 4; - } - else if (strcmp(argv[i], "-quiet") == 0) - { - quiet = 1; - options &= ~SSL_DISPLAY_CERTS; - } - else if (strcmp(argv[i], "-pass") == 0) - { - if (i >= argc-1) - { - print_client_options(argv[i]); - } - - password = argv[++i]; - } - else if (strcmp(argv[i], "-servername") == 0) - { - if (i >= argc-1) - { - print_client_options(argv[i]); - } - - extensions = ssl_ext_new(); - extensions->host_name = argv[++i]; - } -#ifdef CONFIG_SSL_FULL_MODE - else if (strcmp(argv[i], "-debug") == 0) - { - options |= SSL_DISPLAY_BYTES; - } - else if (strcmp(argv[i], "-state") == 0) - { - options |= SSL_DISPLAY_STATES; - } - else if (strcmp(argv[i], "-show-rsa") == 0) - { - options |= SSL_DISPLAY_RSA; - } -#endif - else /* don't know what this is */ - { - print_client_options(argv[i]); - } - - i++; - } - - if ((ssl_ctx = ssl_ctx_new(options, SSL_DEFAULT_CLNT_SESS)) == NULL) - { - fprintf(stderr, "Error: Client context is invalid\n"); - exit(1); - } - -#ifndef CONFIG_SSL_SKELETON_MODE - if (private_key_file) - { - int obj_type = SSL_OBJ_RSA_KEY; - - /* auto-detect the key type from the file extension */ - if (strstr(private_key_file, ".p8")) - obj_type = SSL_OBJ_PKCS8; - else if (strstr(private_key_file, ".p12")) - obj_type = SSL_OBJ_PKCS12; - - if (ssl_obj_load(ssl_ctx, obj_type, private_key_file, password)) - { - fprintf(stderr, "Error: Private key '%s' is undefined.\n", - private_key_file); - exit(1); - } - } - - for (i = 0; i < cert_index; i++) - { - if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, cert[i], NULL)) - { - printf("Certificate '%s' is undefined.\n", cert[i]); - exit(1); - } - } - - for (i = 0; i < ca_cert_index; i++) - { - if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, ca_cert[i], NULL)) - { - printf("Certificate '%s' is undefined.\n", ca_cert[i]); - exit(1); - } - } -#endif - - free(cert); - free(ca_cert); - - /************************************************************************* - * This is where the interesting stuff happens. Up until now we've - * just been setting up sockets etc. Now we do the SSL handshake. - *************************************************************************/ - client_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - memset(&client_addr, 0, sizeof(client_addr)); - client_addr.sin_family = AF_INET; - client_addr.sin_port = htons(port); - client_addr.sin_addr.s_addr = sin_addr; - - if (connect(client_fd, (struct sockaddr *)&client_addr, - sizeof(client_addr)) < 0) - { - perror("connect"); - exit(1); - } - - if (!quiet) - { - printf("CONNECTED\n"); - TTY_FLUSH(); - } - - /* Try session resumption? */ - if (reconnect) - { - while (reconnect--) - { - ssl = ssl_client_new(ssl_ctx, client_fd, session_id, - sizeof(session_id), extensions); - if ((res = ssl_handshake_status(ssl)) != SSL_OK) - { - if (!quiet) - { - ssl_display_error(res); - } - - ssl_free(ssl); - exit(1); - } - - display_session_id(ssl); - memcpy(session_id, ssl_get_session_id(ssl), SSL_SESSION_ID_SIZE); - - if (reconnect) - { - ssl_free(ssl); - SOCKET_CLOSE(client_fd); - - client_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - connect(client_fd, (struct sockaddr *)&client_addr, - sizeof(client_addr)); - } - } - } - else - { - ssl = ssl_client_new(ssl_ctx, client_fd, NULL, 0, extensions); - } - - /* check the return status */ - if ((res = ssl_handshake_status(ssl)) != SSL_OK) - { - if (!quiet) - { - ssl_display_error(res); - } - - exit(1); - } - - if (!quiet) - { - display_session_id(ssl); - display_cipher(ssl); - } - - for (;;) - { - uint8_t buf[1024]; - - /* allow parallel reading of server and standard input */ - FD_SET(client_fd, &read_set); -#ifndef WIN32 - /* win32 doesn't like mixing up stdin and sockets */ - FD_SET(STDIN_FILENO, &read_set); - - if ((res = select(client_fd+1, &read_set, NULL, NULL, NULL)) > 0) - { - /* read standard input? */ - if (FD_ISSET(STDIN_FILENO, &read_set)) -#endif - { - if (fgets((char *)buf, sizeof(buf), stdin) == NULL) - { - /* bomb out of here */ - ssl_free(ssl); - break; - } - else - { - /* small hack to check renegotiation */ - if (buf[0] == 'R' && (buf[1] == '\n' || buf[1] == '\r')) - { - res = ssl_renegotiate(ssl); - } - else - { - res = ssl_write(ssl, buf, strlen((char *)buf)); - } - } - } -#ifndef WIN32 - else /* a socket read */ - { - uint8_t *read_buf; - - res = ssl_read(ssl, &read_buf); - - if (res > 0) /* display our interesting output */ - { - int written = 0; - while (written < res) - { - written += write(STDOUT_FILENO, read_buf+written, - res-written); - } - TTY_FLUSH(); - } - } - } -#endif - - if (res < 0) - { - if (!quiet) - { - ssl_display_error(res); - } - - break; /* get outta here */ - } - } - - ssl_ctx_free(ssl_ctx); - SOCKET_CLOSE(client_fd); -#else - print_client_options(argv[1]); -#endif -} - -/** - * We've had some sort of command-line error. Print out the basic options. - */ -static void print_options(char *option) -{ - printf("axssl: Error: '%s' is an invalid command.\n", option); - printf("usage: axssl [s_server|s_client|version] [args ...]\n"); - exit(1); -} - -/** - * We've had some sort of command-line error. Print out the server options. - */ -static void print_server_options(char *option) -{ -#ifndef CONFIG_SSL_SKELETON_MODE - int cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); -#endif -#ifdef CONFIG_SSL_CERT_VERIFICATION - int ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); -#endif - - printf("unknown option %s\n", option); - printf("usage: s_server [args ...]\n"); - printf(" -accept arg\t- port to accept on (default is 4433)\n"); -#ifndef CONFIG_SSL_SKELETON_MODE - printf(" -cert arg\t- certificate file to add (in addition to default)" - " to chain -\n" - "\t\t Can repeat up to %d times\n", cert_size); - printf(" -key arg\t- Private key file to use\n"); - printf(" -pass\t\t- private key file pass phrase source\n"); -#endif - printf(" -quiet\t\t- No server output\n"); -#ifdef CONFIG_SSL_CERT_VERIFICATION - printf(" -verify\t- turn on peer certificate verification\n"); - printf(" -CAfile arg\t- Certificate authority\n"); - printf("\t\t Can repeat up to %d times\n", ca_cert_size); -#endif -#ifdef CONFIG_SSL_FULL_MODE - printf(" -debug\t\t- Print more output\n"); - printf(" -state\t\t- Show state messages\n"); - printf(" -show-rsa\t- Show RSA state\n"); -#endif - exit(1); -} - -/** - * We've had some sort of command-line error. Print out the client options. - */ -static void print_client_options(char *option) -{ -#ifdef CONFIG_SSL_ENABLE_CLIENT - int cert_size = ssl_get_config(SSL_MAX_CERT_CFG_OFFSET); - int ca_cert_size = ssl_get_config(SSL_MAX_CA_CERT_CFG_OFFSET); -#endif - - printf("unknown option %s\n", option); -#ifdef CONFIG_SSL_ENABLE_CLIENT - printf("usage: s_client [args ...]\n"); - printf(" -connect host:port - who to connect to (default " - "is localhost:4433)\n"); - printf(" -verify\t- turn on peer certificate verification\n"); - printf(" -cert arg\t- certificate file to use\n"); - printf("\t\t Can repeat up to %d times\n", cert_size); - printf(" -key arg\t- Private key file to use\n"); - printf(" -CAfile arg\t- Certificate authority\n"); - printf("\t\t Can repeat up to %d times\n", ca_cert_size); - printf(" -quiet\t\t- No client output\n"); - printf(" -reconnect\t- Drop and re-make the connection " - "with the same Session-ID\n"); - printf(" -pass\t\t- Private key file pass phrase source\n"); - printf(" -servername\t- Set TLS extension servername in ClientHello\n"); -#ifdef CONFIG_SSL_FULL_MODE - printf(" -debug\t\t- Print more output\n"); - printf(" -state\t\t- Show state messages\n"); - printf(" -show-rsa\t- Show RSA state\n"); -#endif -#else - printf("Change configuration to allow this feature\n"); -#endif - exit(1); -} - -/** - * Display what cipher we are using - */ -static void display_cipher(SSL *ssl) -{ - printf("CIPHER is "); - switch (ssl_get_cipher_id(ssl)) - { - case SSL_AES128_SHA: - printf("AES128-SHA"); - break; - - case SSL_AES256_SHA: - printf("AES256-SHA"); - break; - - case SSL_AES128_SHA256: - printf("AES128-SHA256"); - break; - - case SSL_AES256_SHA256: - printf("AES256-SHA256"); - break; - - default: - printf("Unknown - %d", ssl_get_cipher_id(ssl)); - break; - } - - printf("\n"); - TTY_FLUSH(); -} - -/** - * Display what session id we have. - */ -static void display_session_id(SSL *ssl) -{ - int i; - const uint8_t *session_id = ssl_get_session_id(ssl); - int sess_id_size = ssl_get_session_id_size(ssl); - - if (sess_id_size > 0) - { - printf("-----BEGIN SSL SESSION PARAMETERS-----\n"); - for (i = 0; i < sess_id_size; i++) - { - printf("%02x", session_id[i]); - } - - printf("\n-----END SSL SESSION PARAMETERS-----\n"); - TTY_FLUSH(); - } -} diff --git a/user/mpy/lib/axtls/samples/csharp/Makefile b/user/mpy/lib/axtls/samples/csharp/Makefile deleted file mode 100644 index 46c2421..0000000 --- a/user/mpy/lib/axtls/samples/csharp/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf -include ../../config/makefile.dotnet.conf - -all : sample -TARGET=../../$(STAGE)/axssl.csharp.exe -sample : $(TARGET) - -$(TARGET): ../../bindings/csharp/axTLS.cs ../../bindings/csharp/axInterface.cs axssl.cs -ifdef GO_DOT_NET - csc.exe /nologo /t:exe /out:"`cygpath -w $@`" $(foreach file, $^, "`cygpath -w $(file)`") -else # use mono to build - mcs -out:$@ $^ - -endif # ARCH - -clean:: - -@rm -f $(TARGET) diff --git a/user/mpy/lib/axtls/samples/csharp/axssl.cs b/user/mpy/lib/axtls/samples/csharp/axssl.cs deleted file mode 100644 index df3c576..0000000 --- a/user/mpy/lib/axtls/samples/csharp/axssl.cs +++ /dev/null @@ -1,758 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Demonstrate the use of the axTLS library in C# with a set of - * command-line parameters similar to openssl. In fact, openssl clients - * should be able to communicate with axTLS servers and visa-versa. - * - * This code has various bits enabled depending on the configuration. To enable - * the most interesting version, compile with the 'full mode' enabled. - * - * To see what options you have, run the following: - * > axssl.csharp.exe s_server -? - * > axssl.csharp.exe s_client -? - * - * The axtls shared library must be in the same directory or be found - * by the OS. - */ - -using System; -using System.Net; -using System.Net.Sockets; -using axTLS; - -public class axssl -{ - /* - * Main() - */ - public static void Main(string[] args) - { - if (args.Length == 1 && args[0] == "version") - { - Console.WriteLine("axssl.csharp " + SSLUtil.Version()); - Environment.Exit(0); - } - - axssl runner = new axssl(); - - if (args.Length < 1 || (args[0] != "s_server" && args[0] != "s_client")) - runner.print_options(args.Length > 0 ? args[0] : ""); - - int build_mode = SSLUtil.BuildMode(); - - if (args[0] == "s_server") - runner.do_server(build_mode, args); - else - runner.do_client(build_mode, args); - } - - /* - * do_server() - */ - private void do_server(int build_mode, string[] args) - { - int i = 1; - int port = 4433; - uint options = axtls.SSL_DISPLAY_CERTS; - bool quiet = false; - string password = null; - string private_key_file = null; - - /* organise the cert/ca_cert lists */ - int cert_size = SSLUtil.MaxCerts(); - int ca_cert_size = SSLUtil.MaxCACerts(); - string[] cert = new string[cert_size]; - string[] ca_cert = new string[ca_cert_size]; - int cert_index = 0; - int ca_cert_index = 0; - - while (i < args.Length) - { - if (args[i] == "-accept") - { - if (i >= args.Length-1) - { - print_server_options(build_mode, args[i]); - } - - port = Int32.Parse(args[++i]); - } - else if (args[i] == "-quiet") - { - quiet = true; - options &= ~(uint)axtls.SSL_DISPLAY_CERTS; - } - else if (build_mode >= axtls.SSL_BUILD_SERVER_ONLY) - { - if (args[i] == "-cert") - { - if (i >= args.Length-1 || cert_index >= cert_size) - { - print_server_options(build_mode, args[i]); - } - - cert[cert_index++] = args[++i]; - } - else if (args[i] == "-key") - { - if (i >= args.Length-1) - { - print_server_options(build_mode, args[i]); - } - - private_key_file = args[++i]; - options |= axtls.SSL_NO_DEFAULT_KEY; - } - else if (args[i] == "-pass") - { - if (i >= args.Length-1) - { - print_server_options(build_mode, args[i]); - } - - password = args[++i]; - } - else if (build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION) - { - if (args[i] == "-verify") - { - options |= axtls.SSL_CLIENT_AUTHENTICATION; - } - else if (args[i] == "-CAfile") - { - if (i >= args.Length-1 || ca_cert_index >= ca_cert_size) - { - print_server_options(build_mode, args[i]); - } - - ca_cert[ca_cert_index++] = args[++i]; - } - else if (build_mode == axtls.SSL_BUILD_FULL_MODE) - { - if (args[i] == "-debug") - { - options |= axtls.SSL_DISPLAY_BYTES; - } - else if (args[i] == "-state") - { - options |= axtls.SSL_DISPLAY_STATES; - } - else if (args[i] == "-show-rsa") - { - options |= axtls.SSL_DISPLAY_RSA; - } - else - print_server_options(build_mode, args[i]); - } - else - print_server_options(build_mode, args[i]); - } - else - print_server_options(build_mode, args[i]); - } - else - print_server_options(build_mode, args[i]); - - i++; - } - - /* Create socket for incoming connections */ - IPEndPoint ep = new IPEndPoint(IPAddress.Any, port); - TcpListener server_sock = new TcpListener(ep); - server_sock.Start(); - - /********************************************************************** - * This is where the interesting stuff happens. Up until now we've - * just been setting up sockets etc. Now we do the SSL handshake. - **********************************************************************/ - SSLServer ssl_ctx = new SSLServer( - options, axtls.SSL_DEFAULT_SVR_SESS); - - if (ssl_ctx == null) - { - Console.Error.WriteLine("Error: Server context is invalid"); - Environment.Exit(1); - } - - if (private_key_file != null) - { - int obj_type = axtls.SSL_OBJ_RSA_KEY; - - if (private_key_file.EndsWith(".p8")) - obj_type = axtls.SSL_OBJ_PKCS8; - else if (private_key_file.EndsWith(".p12")) - obj_type = axtls.SSL_OBJ_PKCS12; - - if (ssl_ctx.ObjLoad(obj_type, - private_key_file, password) != axtls.SSL_OK) - { - Console.Error.WriteLine("Private key '" + private_key_file + - "' is undefined."); - Environment.Exit(1); - } - } - - for (i = 0; i < cert_index; i++) - { - if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, - cert[i], null) != axtls.SSL_OK) - { - Console.WriteLine("Certificate '" + cert[i] + - "' is undefined."); - Environment.Exit(1); - } - } - - for (i = 0; i < ca_cert_index; i++) - { - if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, - ca_cert[i], null) != axtls.SSL_OK) - { - Console.WriteLine("Certificate '" + cert[i] + - "' is undefined."); - Environment.Exit(1); - } - } - - byte[] buf = null; - int res; - - for (;;) - { - if (!quiet) - { - Console.WriteLine("ACCEPT"); - } - - Socket client_sock = server_sock.AcceptSocket(); - - SSL ssl = ssl_ctx.Connect(client_sock); - - /* do the actual SSL handshake */ - while ((res = ssl_ctx.Read(ssl, out buf)) == axtls.SSL_OK) - { - /* check when the connection has been established */ - if (ssl.HandshakeStatus() == axtls.SSL_OK) - break; - - /* could do something else here */ - } - - if (res == axtls.SSL_OK) /* connection established and ok */ - { - if (!quiet) - { - display_session_id(ssl); - display_cipher(ssl); - } - - /* now read (and display) whatever the client sends us */ - for (;;) - { - /* keep reading until we get something interesting */ - while ((res = ssl_ctx.Read(ssl, out buf)) == axtls.SSL_OK) - { - /* could do something else here */ - } - - if (res < axtls.SSL_OK) - { - if (!quiet) - { - Console.WriteLine("CONNECTION CLOSED"); - } - - break; - } - - /* convert to string */ - char[] str = new char[res]; - for (i = 0; i < res; i++) - { - str[i] = (char)buf[i]; - } - - Console.Write(str); - } - } - else if (!quiet) - { - SSLUtil.DisplayError(res); - } - - /* client was disconnected or the handshake failed. */ - ssl.Dispose(); - client_sock.Close(); - } - - /* ssl_ctx.Dispose(); */ - } - - /* - * do_client() - */ - private void do_client(int build_mode, string[] args) - { - if (build_mode < axtls.SSL_BUILD_ENABLE_CLIENT) - { - print_client_options(build_mode, args[1]); - } - - int i = 1, res; - int port = 4433; - bool quiet = false; - string password = null; - int reconnect = 0; - string private_key_file = null; - string hostname = "127.0.0.1"; - - /* organise the cert/ca_cert lists */ - int cert_index = 0; - int ca_cert_index = 0; - int cert_size = SSLUtil.MaxCerts(); - int ca_cert_size = SSLUtil.MaxCACerts(); - string[] cert = new string[cert_size]; - string[] ca_cert = new string[ca_cert_size]; - - uint options = axtls.SSL_SERVER_VERIFY_LATER|axtls.SSL_DISPLAY_CERTS; - byte[] session_id = null; - - while (i < args.Length) - { - if (args[i] == "-connect") - { - string host_port; - - if (i >= args.Length-1) - { - print_client_options(build_mode, args[i]); - } - - host_port = args[++i]; - int index_colon; - - if ((index_colon = host_port.IndexOf(':')) < 0) - print_client_options(build_mode, args[i]); - - hostname = new string(host_port.ToCharArray(), - 0, index_colon); - port = Int32.Parse(new String(host_port.ToCharArray(), - index_colon+1, host_port.Length-index_colon-1)); - } - else if (args[i] == "-cert") - { - if (i >= args.Length-1 || cert_index >= cert_size) - { - print_client_options(build_mode, args[i]); - } - - cert[cert_index++] = args[++i]; - } - else if (args[i] == "-key") - { - if (i >= args.Length-1) - { - print_client_options(build_mode, args[i]); - } - - private_key_file = args[++i]; - options |= axtls.SSL_NO_DEFAULT_KEY; - } - else if (args[i] == "-CAfile") - { - if (i >= args.Length-1 || ca_cert_index >= ca_cert_size) - { - print_client_options(build_mode, args[i]); - } - - ca_cert[ca_cert_index++] = args[++i]; - } - else if (args[i] == "-verify") - { - options &= ~(uint)axtls.SSL_SERVER_VERIFY_LATER; - } - else if (args[i] == "-reconnect") - { - reconnect = 4; - } - else if (args[i] == "-quiet") - { - quiet = true; - options &= ~(uint)axtls.SSL_DISPLAY_CERTS; - } - else if (args[i] == "-pass") - { - if (i >= args.Length-1) - { - print_client_options(build_mode, args[i]); - } - - password = args[++i]; - } - else if (build_mode == axtls.SSL_BUILD_FULL_MODE) - { - if (args[i] == "-debug") - { - options |= axtls.SSL_DISPLAY_BYTES; - } - else if (args[i] == "-state") - { - options |= axtls.SSL_DISPLAY_STATES; - } - else if (args[i] == "-show-rsa") - { - options |= axtls.SSL_DISPLAY_RSA; - } - else - print_client_options(build_mode, args[i]); - } - else /* don't know what this is */ - print_client_options(build_mode, args[i]); - - i++; - } - - // IPHostEntry hostInfo = Dns.Resolve(hostname); - IPHostEntry hostInfo = Dns.GetHostEntry(hostname); - IPAddress[] addresses = hostInfo.AddressList; - IPEndPoint ep = new IPEndPoint(addresses[0], port); - Socket client_sock = new Socket(AddressFamily.InterNetwork, - SocketType.Stream, ProtocolType.Tcp); - client_sock.Connect(ep); - - if (!client_sock.Connected) - { - Console.WriteLine("could not connect"); - Environment.Exit(1); - } - - if (!quiet) - { - Console.WriteLine("CONNECTED"); - } - - /********************************************************************** - * This is where the interesting stuff happens. Up until now we've - * just been setting up sockets etc. Now we do the SSL handshake. - **********************************************************************/ - SSLClient ssl_ctx = new SSLClient(options, - axtls.SSL_DEFAULT_CLNT_SESS); - - if (ssl_ctx == null) - { - Console.Error.WriteLine("Error: Client context is invalid"); - Environment.Exit(1); - } - - if (private_key_file != null) - { - int obj_type = axtls.SSL_OBJ_RSA_KEY; - - if (private_key_file.EndsWith(".p8")) - obj_type = axtls.SSL_OBJ_PKCS8; - else if (private_key_file.EndsWith(".p12")) - obj_type = axtls.SSL_OBJ_PKCS12; - - if (ssl_ctx.ObjLoad(obj_type, - private_key_file, password) != axtls.SSL_OK) - { - Console.Error.WriteLine("Private key '" + private_key_file + - "' is undefined."); - Environment.Exit(1); - } - } - - for (i = 0; i < cert_index; i++) - { - if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, - cert[i], null) != axtls.SSL_OK) - { - Console.WriteLine("Certificate '" + cert[i] + - "' is undefined."); - Environment.Exit(1); - } - } - - for (i = 0; i < ca_cert_index; i++) - { - if (ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, - ca_cert[i], null) != axtls.SSL_OK) - { - Console.WriteLine("Certificate '" + cert[i] + - "' is undefined."); - Environment.Exit(1); - } - } - - SSL ssl = new SSL(new IntPtr(0)); /* keep compiler happy */ - - /* Try session resumption? */ - if (reconnect > 0) - { - while (reconnect-- > 0) - { - ssl = ssl_ctx.Connect(client_sock, session_id); - - if ((res = ssl.HandshakeStatus()) != axtls.SSL_OK) - { - if (!quiet) - { - SSLUtil.DisplayError(res); - } - - ssl.Dispose(); - Environment.Exit(1); - } - - display_session_id(ssl); - session_id = ssl.GetSessionId(); - - if (reconnect > 0) - { - ssl.Dispose(); - client_sock.Close(); - - /* and reconnect */ - client_sock = new Socket(AddressFamily.InterNetwork, - SocketType.Stream, ProtocolType.Tcp); - client_sock.Connect(ep); - } - } - } - else - { - ssl = ssl_ctx.Connect(client_sock, null); - } - - /* check the return status */ - if ((res = ssl.HandshakeStatus()) != axtls.SSL_OK) - { - if (!quiet) - { - SSLUtil.DisplayError(res); - } - - Environment.Exit(1); - } - - if (!quiet) - { - string common_name = - ssl.GetCertificateDN(axtls.SSL_X509_CERT_COMMON_NAME); - - if (common_name != null) - { - Console.WriteLine("Common Name:\t\t\t" + common_name); - } - - display_session_id(ssl); - display_cipher(ssl); - } - - for (;;) - { - string user_input = Console.ReadLine(); - - if (user_input == null) - break; - - byte[] buf = new byte[user_input.Length+2]; - buf[buf.Length-2] = (byte)'\n'; /* add the carriage return */ - buf[buf.Length-1] = 0; /* null terminate */ - - for (i = 0; i < buf.Length-2; i++) - { - buf[i] = (byte)user_input[i]; - } - - if ((res = ssl_ctx.Write(ssl, buf, buf.Length)) < axtls.SSL_OK) - { - if (!quiet) - { - SSLUtil.DisplayError(res); - } - - break; - } - } - - ssl_ctx.Dispose(); - } - - /** - * We've had some sort of command-line error. Print out the basic options. - */ - private void print_options(string option) - { - Console.WriteLine("axssl: Error: '" + option + - "' is an invalid command."); - Console.WriteLine("usage: axssl.csharp [s_server|" + - "s_client|version] [args ...]"); - Environment.Exit(1); - } - - /** - * We've had some sort of command-line error. Print out the server options. - */ - private void print_server_options(int build_mode, string option) - { - int cert_size = SSLUtil.MaxCerts(); - int ca_cert_size = SSLUtil.MaxCACerts(); - - Console.WriteLine("unknown option " + option); - Console.WriteLine("usage: s_server [args ...]"); - Console.WriteLine(" -accept arg\t- port to accept on (default " + - "is 4433)"); - Console.WriteLine(" -quiet\t\t- No server output"); - - if (build_mode >= axtls.SSL_BUILD_SERVER_ONLY) - { - Console.WriteLine(" -cert arg\t- certificate file to add (in " + - "addition to default) to chain -"); - Console.WriteLine("\t\t Can repeat up to " + cert_size + " times"); - Console.WriteLine(" -key arg\t- Private key file to use"); - Console.WriteLine(" -pass\t\t- private key file pass phrase source"); - } - - if (build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION) - { - Console.WriteLine(" -verify\t- turn on peer certificate " + - "verification"); - Console.WriteLine(" -CAfile arg\t- Certificate authority."); - Console.WriteLine("\t\t Can repeat up to " + - ca_cert_size + "times"); - } - - if (build_mode == axtls.SSL_BUILD_FULL_MODE) - { - Console.WriteLine(" -debug\t\t- Print more output"); - Console.WriteLine(" -state\t\t- Show state messages"); - Console.WriteLine(" -show-rsa\t- Show RSA state"); - } - - Environment.Exit(1); - } - - /** - * We've had some sort of command-line error. Print out the client options. - */ - private void print_client_options(int build_mode, string option) - { - int cert_size = SSLUtil.MaxCerts(); - int ca_cert_size = SSLUtil.MaxCACerts(); - - Console.WriteLine("unknown option " + option); - - if (build_mode >= axtls.SSL_BUILD_ENABLE_CLIENT) - { - Console.WriteLine("usage: s_client [args ...]"); - Console.WriteLine(" -connect host:port - who to connect to " + - "(default is localhost:4433)"); - Console.WriteLine(" -verify\t- turn on peer certificate " + - "verification"); - Console.WriteLine(" -cert arg\t- certificate file to use"); - Console.WriteLine("\t\t Can repeat up to %d times", cert_size); - Console.WriteLine(" -key arg\t- Private key file to use"); - Console.WriteLine(" -CAfile arg\t- Certificate authority."); - Console.WriteLine("\t\t Can repeat up to " + ca_cert_size + - " times"); - Console.WriteLine(" -quiet\t\t- No client output"); - Console.WriteLine(" -pass\t\t- private key file pass " + - "phrase source"); - Console.WriteLine(" -reconnect\t- Drop and re-make the " + - "connection with the same Session-ID"); - - if (build_mode == axtls.SSL_BUILD_FULL_MODE) - { - Console.WriteLine(" -debug\t\t- Print more output"); - Console.WriteLine(" -state\t\t- Show state messages"); - Console.WriteLine(" -show-rsa\t- Show RSA state"); - } - } - else - { - Console.WriteLine("Change configuration to allow this feature"); - } - - Environment.Exit(1); - } - - /** - * Display what cipher we are using - */ - private void display_cipher(SSL ssl) - { - Console.Write("CIPHER is "); - - switch (ssl.GetCipherId()) - { - case axtls.SSL_AES128_SHA: - Console.WriteLine("AES128-SHA"); - break; - - case axtls.SSL_AES256_SHA: - Console.WriteLine("AES256-SHA"); - break; - - case axtls.SSL_AES128_SHA256: - Console.WriteLine("AES128-SHA256"); - break; - - case axtls.SSL_AES256_SHA256: - Console.WriteLine("AES128-SHA256"); - break; - - default: - Console.WriteLine("Unknown - " + ssl.GetCipherId()); - break; - } - } - - /** - * Display what session id we have. - */ - private void display_session_id(SSL ssl) - { - byte[] session_id = ssl.GetSessionId(); - - if (session_id.Length > 0) - { - Console.WriteLine("-----BEGIN SSL SESSION PARAMETERS-----"); - foreach (byte b in session_id) - { - Console.Write("{0:x02}", b); - } - - Console.WriteLine("\n-----END SSL SESSION PARAMETERS-----"); - } - } -} diff --git a/user/mpy/lib/axtls/samples/java/Makefile b/user/mpy/lib/axtls/samples/java/Makefile deleted file mode 100644 index 9c1ed6d..0000000 --- a/user/mpy/lib/axtls/samples/java/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2007-2016, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf -include ../../config/makefile.java.conf - -all : sample -JAR=../../$(STAGE)/axtls.jar -CLASSES=../../bindings/java/classes -sample : $(JAR) - -$(JAR) : $(CLASSES)/axssl.class $(wildcard $(CLASSES)/axTLSj/*.class) - jar mcvf manifest.mf $@ -C $(CLASSES) axTLSj -C $(CLASSES) axssl.class - -JAVA_FILES=axssl.java -JAVA_CLASSES:=$(JAVA_FILES:%.java=$(CLASSES)/axTLSj/%.class) - -$(CLASSES)/%.class : %.java - javac -d $(CLASSES) -classpath $(CLASSES) $^ - -clean:: - -@rm -f $(TARGET) - diff --git a/user/mpy/lib/axtls/samples/java/axssl.java b/user/mpy/lib/axtls/samples/java/axssl.java deleted file mode 100644 index e013c11..0000000 --- a/user/mpy/lib/axtls/samples/java/axssl.java +++ /dev/null @@ -1,760 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Demonstrate the use of the axTLS library in Java with a set of - * command-line parameters similar to openssl. In fact, openssl clients - * should be able to communicate with axTLS servers and visa-versa. * - * This code has various bits enabled depending on the configuration. To enable - * the most interesting version, compile with the 'full mode' enabled. - * - * To see what options you have, run the following: - * > java -jar axtls.jar s_server -? - * > java -jar axtls.jar s_client -? - * - * The axtls/axtlsj shared libraries must be in the same directory or be found - * by the OS. - */ - -import java.io.*; -import java.util.*; -import java.net.*; -import axTLSj.*; - -public class axssl -{ - /* - * Main() - */ - public static void main(String[] args) - { - if (args.length == 1 && args[0].equals("version")) - { - System.out.println("axtls.jar " + SSLUtil.version()); - System.exit(0); - } - - axssl runner = new axssl(); - - try - { - if (args.length < 1 || - (!args[0].equals("s_server") && - !args[0].equals("s_client"))) - { - runner.print_options(args.length > 0 ? args[0] : ""); - } - - int build_mode = SSLUtil.buildMode(); - - if (args[0].equals("s_server")) - runner.do_server(build_mode, args); - else - runner.do_client(build_mode, args); - } - catch (Exception e) - { - System.out.println(e); - } - } - - /* - * do_server() - */ - private void do_server(int build_mode, String[] args) - throws Exception - { - int i = 1; - int port = 4433; - int options = axtlsj.SSL_DISPLAY_CERTS; - boolean quiet = false; - String password = null; - String private_key_file = null; - - /* organise the cert/ca_cert lists */ - int cert_size = SSLUtil.maxCerts(); - int ca_cert_size = SSLUtil.maxCACerts(); - String[] cert = new String[cert_size]; - String[] ca_cert = new String[ca_cert_size]; - int cert_index = 0; - int ca_cert_index = 0; - - while (i < args.length) - { - if (args[i].equals("-accept")) - { - if (i >= args.length-1) - { - print_server_options(build_mode, args[i]); - } - - port = Integer.parseInt(args[++i]); - } - else if (args[i].equals("-quiet")) - { - quiet = true; - options &= ~(int)axtlsj.SSL_DISPLAY_CERTS; - } - else if (build_mode >= axtlsj.SSL_BUILD_SERVER_ONLY) - { - if (args[i].equals("-cert")) - { - if (i >= args.length-1 || cert_index >= cert_size) - { - print_server_options(build_mode, args[i]); - } - - cert[cert_index++] = args[++i]; - } - else if (args[i].equals("-key")) - { - if (i >= args.length-1) - { - print_server_options(build_mode, args[i]); - } - - private_key_file = args[++i]; - options |= axtlsj.SSL_NO_DEFAULT_KEY; - } - else if (args[i].equals("-pass")) - { - if (i >= args.length-1) - { - print_server_options(build_mode, args[i]); - } - - password = args[++i]; - } - else if (build_mode >= axtlsj.SSL_BUILD_ENABLE_VERIFICATION) - { - if (args[i].equals("-verify")) - { - options |= axtlsj.SSL_CLIENT_AUTHENTICATION; - } - else if (args[i].equals("-CAfile")) - { - if (i >= args.length-1 || ca_cert_index >= ca_cert_size) - { - print_server_options(build_mode, args[i]); - } - - ca_cert[ca_cert_index++] = args[++i]; - } - else if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) - { - if (args[i].equals("-debug")) - { - options |= axtlsj.SSL_DISPLAY_BYTES; - } - else if (args[i].equals("-state")) - { - options |= axtlsj.SSL_DISPLAY_STATES; - } - else if (args[i].equals("-show-rsa")) - { - options |= axtlsj.SSL_DISPLAY_RSA; - } - else - print_server_options(build_mode, args[i]); - } - else - print_server_options(build_mode, args[i]); - } - else - print_server_options(build_mode, args[i]); - } - else - print_server_options(build_mode, args[i]); - - i++; - } - - /* Create socket for incoming connections */ - ServerSocket server_sock = new ServerSocket(port); - - /********************************************************************** - * This is where the interesting stuff happens. Up until now we've - * just been setting up sockets etc. Now we do the SSL handshake. - **********************************************************************/ - SSLServer ssl_ctx = new SSLServer(options, - axtlsj.SSL_DEFAULT_SVR_SESS); - - if (ssl_ctx == null) - throw new Exception("Error: Server context is invalid"); - - if (private_key_file != null) - { - int obj_type = axtlsj.SSL_OBJ_RSA_KEY; - - if (private_key_file.endsWith(".p8")) - obj_type = axtlsj.SSL_OBJ_PKCS8; - else if (private_key_file.endsWith(".p12")) - obj_type = axtlsj.SSL_OBJ_PKCS12; - - if (ssl_ctx.objLoad(obj_type, - private_key_file, password) != axtlsj.SSL_OK) - { - throw new Exception("Error: Private key '" + private_key_file + - "' is undefined."); - } - } - - for (i = 0; i < cert_index; i++) - { - if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CERT, - cert[i], null) != axtlsj.SSL_OK) - { - throw new Exception("Certificate '" + cert[i] + - "' is undefined."); - } - } - - for (i = 0; i < ca_cert_index; i++) - { - if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CACERT, - ca_cert[i], null) != axtlsj.SSL_OK) - { - throw new Exception("Certificate '" + ca_cert[i] + - "' is undefined."); - } - } - - int res; - SSLReadHolder rh = new SSLReadHolder(); - - for (;;) - { - if (!quiet) - { - System.out.println("ACCEPT"); - } - - Socket client_sock = server_sock.accept(); - - SSL ssl = ssl_ctx.connect(client_sock); - - while ((res = ssl_ctx.read(ssl, rh)) == axtlsj.SSL_OK) - { - /* check when the connection has been established */ - if (ssl.handshakeStatus() == axtlsj.SSL_OK) - break; - - /* could do something else here */ - } - - if (res == axtlsj.SSL_OK) /* connection established and ok */ - { - if (!quiet) - { - display_session_id(ssl); - display_cipher(ssl); - } - - /* now read (and display) whatever the client sends us */ - for (;;) - { - /* keep reading until we get something interesting */ - while ((res = ssl_ctx.read(ssl, rh)) == axtlsj.SSL_OK) - { - /* could do something else here */ - } - - if (res < axtlsj.SSL_OK) - { - if (!quiet) - { - System.out.println("CONNECTION CLOSED"); - } - - break; - } - - /* convert to String */ - byte[] buf = rh.getData(); - char[] str = new char[res]; - - for (i = 0; i < res; i++) - { - str[i] = (char)buf[i]; - } - - System.out.print(str); - } - } - else if (!quiet) - { - SSLUtil.displayError(res); - } - - /* client was disconnected or the handshake failed. */ - ssl.dispose(); - client_sock.close(); - } - - /* ssl_ctx.dispose(); */ - } - - /* - * do_client() - */ - private void do_client(int build_mode, String[] args) - throws Exception - { - if (build_mode < axtlsj.SSL_BUILD_ENABLE_CLIENT) - print_client_options(build_mode, args[1]); - - int i = 1, res; - int port = 4433; - boolean quiet = false; - String password = null; - int reconnect = 0; - String private_key_file = null; - String hostname = "127.0.0.1"; - - /* organise the cert/ca_cert lists */ - int cert_index = 0; - int ca_cert_index = 0; - int cert_size = SSLUtil.maxCerts(); - int ca_cert_size = SSLUtil.maxCACerts(); - String[] cert = new String[cert_size]; - String[] ca_cert = new String[ca_cert_size]; - - int options = axtlsj.SSL_SERVER_VERIFY_LATER|axtlsj.SSL_DISPLAY_CERTS; - byte[] session_id = null; - - while (i < args.length) - { - if (args[i].equals("-connect")) - { - String host_port; - - if (i >= args.length-1) - { - print_client_options(build_mode, args[i]); - } - - host_port = args[++i]; - int index_colon; - - if ((index_colon = host_port.indexOf(':')) < 0) - print_client_options(build_mode, args[i]); - - hostname = new String(host_port.toCharArray(), - 0, index_colon); - port = Integer.parseInt(new String(host_port.toCharArray(), - index_colon+1, host_port.length()-index_colon-1)); - } - else if (args[i].equals("-cert")) - { - if (i >= args.length-1 || cert_index >= cert_size) - { - print_client_options(build_mode, args[i]); - } - - cert[cert_index++] = args[++i]; - } - else if (args[i].equals("-CAfile")) - { - if (i >= args.length-1 || ca_cert_index >= ca_cert_size) - { - print_client_options(build_mode, args[i]); - } - - ca_cert[ca_cert_index++] = args[++i]; - } - else if (args[i].equals("-key")) - { - if (i >= args.length-1) - { - print_client_options(build_mode, args[i]); - } - - private_key_file = args[++i]; - options |= axtlsj.SSL_NO_DEFAULT_KEY; - } - else if (args[i].equals("-verify")) - { - options &= ~(int)axtlsj.SSL_SERVER_VERIFY_LATER; - } - else if (args[i].equals("-reconnect")) - { - reconnect = 4; - } - else if (args[i].equals("-quiet")) - { - quiet = true; - options &= ~(int)axtlsj.SSL_DISPLAY_CERTS; - } - else if (args[i].equals("-pass")) - { - if (i >= args.length-1) - { - print_server_options(build_mode, args[i]); - } - - password = args[++i]; - } - else if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) - { - if (args[i].equals("-debug")) - { - options |= axtlsj.SSL_DISPLAY_BYTES; - } - else if (args[i].equals("-state")) - { - options |= axtlsj.SSL_DISPLAY_STATES; - } - else if (args[i].equals("-show-rsa")) - { - options |= axtlsj.SSL_DISPLAY_RSA; - } - else - print_client_options(build_mode, args[i]); - } - else /* don't know what this is */ - print_client_options(build_mode, args[i]); - - i++; - } - - Socket client_sock = new Socket(hostname, port); - - if (!client_sock.isConnected()) - { - System.out.println("could not connect"); - throw new Exception(); - } - - if (!quiet) - { - System.out.println("CONNECTED"); - } - - /********************************************************************** - * This is where the interesting stuff happens. Up until now we've - * just been setting up sockets etc. Now we do the SSL handshake. - **********************************************************************/ - SSLClient ssl_ctx = new SSLClient(options, - axtlsj.SSL_DEFAULT_CLNT_SESS); - - if (ssl_ctx == null) - { - throw new Exception("Error: Client context is invalid"); - } - - if (private_key_file != null) - { - int obj_type = axtlsj.SSL_OBJ_RSA_KEY; - - if (private_key_file.endsWith(".p8")) - obj_type = axtlsj.SSL_OBJ_PKCS8; - else if (private_key_file.endsWith(".p12")) - obj_type = axtlsj.SSL_OBJ_PKCS12; - - if (ssl_ctx.objLoad(obj_type, - private_key_file, password) != axtlsj.SSL_OK) - { - throw new Exception("Error: Private key '" + private_key_file + - "' is undefined."); - } - } - - for (i = 0; i < cert_index; i++) - { - if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CERT, - cert[i], null) != axtlsj.SSL_OK) - { - throw new Exception("Certificate '" + cert[i] + - "' is undefined."); - } - } - - for (i = 0; i < ca_cert_index; i++) - { - if (ssl_ctx.objLoad(axtlsj.SSL_OBJ_X509_CACERT, - ca_cert[i], null) != axtlsj.SSL_OK) - { - throw new Exception("Certificate '" + ca_cert[i] + - "' is undefined."); - } - } - - SSL ssl = null; - - /* Try session resumption? */ - if (reconnect > 0) - { - while (reconnect-- > 0) - { - ssl = ssl_ctx.connect(client_sock, session_id); - - if ((res = ssl.handshakeStatus()) != axtlsj.SSL_OK) - { - if (!quiet) - { - SSLUtil.displayError(res); - } - - ssl.dispose(); - throw new Exception(); - } - - display_session_id(ssl); - session_id = ssl.getSessionId(); - - if (reconnect > 0) - { - ssl.dispose(); - client_sock.close(); - - /* and reconnect */ - client_sock = new Socket(hostname, port); - } - } - } - else - { - ssl = ssl_ctx.connect(client_sock, null); - } - - /* check the return status */ - if ((res = ssl.handshakeStatus()) != axtlsj.SSL_OK) - { - if (!quiet) - { - SSLUtil.displayError(res); - } - - throw new Exception(); - } - - if (!quiet) - { - String common_name = - ssl.getCertificateDN(axtlsj.SSL_X509_CERT_COMMON_NAME); - - if (common_name != null) - { - System.out.println("Common Name:\t\t\t" + common_name); - } - - display_session_id(ssl); - display_cipher(ssl); - } - - BufferedReader in = new BufferedReader( - new InputStreamReader(System.in)); - - for (;;) - { - String user_input = in.readLine(); - - if (user_input == null) - break; - - byte[] buf = new byte[user_input.length()+2]; - buf[buf.length-2] = (byte)'\n'; /* add the carriage return */ - buf[buf.length-1] = 0; /* null terminate */ - - for (i = 0; i < buf.length-2; i++) - { - buf[i] = (byte)user_input.charAt(i); - } - - if ((res = ssl_ctx.write(ssl, buf)) < axtlsj.SSL_OK) - { - if (!quiet) - { - SSLUtil.displayError(res); - } - - break; - } - } - - ssl_ctx.dispose(); - } - - /** - * We've had some sort of command-line error. Print out the basic options. - */ - private void print_options(String option) - { - System.out.println("axssl: Error: '" + option + - "' is an invalid command."); - System.out.println("usage: axtlsj.jar [s_server|s_client|version] " + - "[args ...]"); - System.exit(1); - } - - /** - * We've had some sort of command-line error. Print out the server options. - */ - private void print_server_options(int build_mode, String option) - { - int cert_size = SSLUtil.maxCerts(); - int ca_cert_size = SSLUtil.maxCACerts(); - - System.out.println("unknown option " + option); - System.out.println("usage: s_server [args ...]"); - System.out.println(" -accept arg\t- port to accept on (default " + - "is 4433)"); - System.out.println(" -quiet\t\t- No server output"); - - if (build_mode >= axtlsj.SSL_BUILD_SERVER_ONLY) - { - System.out.println(" -cert arg\t- certificate file to add (in " + - "addition to default) to chain -"); - System.out.println("\t\t Can repeat up to " + cert_size + " times"); - System.out.println(" -key arg\t- Private key file to use"); - System.out.println(" -pass\t\t- private key file pass phrase source"); - } - - if (build_mode >= axtlsj.SSL_BUILD_ENABLE_VERIFICATION) - { - System.out.println(" -verify\t- turn on peer certificate " + - "verification"); - System.out.println(" -CAfile arg\t- Certificate authority. "); - System.out.println("\t\t Can repeat up to " + - ca_cert_size + " times"); - } - - if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) - { - System.out.println(" -debug\t\t- Print more output"); - System.out.println(" -state\t\t- Show state messages"); - System.out.println(" -show-rsa\t- Show RSA state"); - } - - System.exit(1); - } - - /** - * We've had some sort of command-line error. Print out the client options. - */ - private void print_client_options(int build_mode, String option) - { - int cert_size = SSLUtil.maxCerts(); - int ca_cert_size = SSLUtil.maxCACerts(); - - System.out.println("unknown option " + option); - - if (build_mode >= axtlsj.SSL_BUILD_ENABLE_CLIENT) - { - System.out.println("usage: s_client [args ...]"); - System.out.println(" -connect host:port - who to connect to " + - "(default is localhost:4433)"); - System.out.println(" -verify\t- turn on peer certificate " + - "verification"); - System.out.println(" -cert arg\t- certificate file to use"); - System.out.println(" -key arg\t- Private key file to use"); - System.out.println("\t\t Can repeat up to " + cert_size + - " times"); - System.out.println(" -CAfile arg\t- Certificate authority."); - System.out.println("\t\t Can repeat up to " + ca_cert_size + - " times"); - System.out.println(" -quiet\t\t- No client output"); - System.out.println(" -pass\t\t- private key file pass " + - "phrase source"); - System.out.println(" -reconnect\t- Drop and re-make the " + - "connection with the same Session-ID"); - - if (build_mode == axtlsj.SSL_BUILD_FULL_MODE) - { - System.out.println(" -debug\t\t- Print more output"); - System.out.println(" -state\t\t- Show state messages"); - System.out.println(" -show-rsa\t- Show RSA state"); - } - } - else - { - System.out.println("Change configuration to allow this feature"); - } - - System.exit(1); - } - - /** - * Display what cipher we are using - */ - private void display_cipher(SSL ssl) - { - System.out.print("CIPHER is "); - - byte ciph_id = ssl.getCipherId(); - - if (ciph_id == axtlsj.SSL_AES128_SHA) - System.out.println("AES128-SHA"); - else if (ciph_id == axtlsj.SSL_AES256_SHA) - System.out.println("AES256-SHA"); - else if (ciph_id == axtlsj.SSL_AES128_SHA256) - System.out.println("AES128-SHA256"); - else if (ciph_id == axtlsj.SSL_AES256_SHA256) - System.out.println("AES256-SHA256"); - else - System.out.println("Unknown - " + ssl.getCipherId()); - } - - public char toHexChar(int i) - { - if ((0 <= i) && (i <= 9 )) - return (char)('0' + i); - else - return (char)('a' + (i-10)); - } - - public void bytesToHex(byte[] data) - { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < data.length; i++ ) - { - buf.append(toHexChar((data[i]>>>4)&0x0F)); - buf.append(toHexChar(data[i]&0x0F)); - } - - System.out.println(buf); - } - - - /** - * Display what session id we have. - */ - private void display_session_id(SSL ssl) - { - byte[] session_id = ssl.getSessionId(); - - if (session_id.length > 0) - { - System.out.println("-----BEGIN SSL SESSION PARAMETERS-----"); - bytesToHex(session_id); - System.out.println("-----END SSL SESSION PARAMETERS-----"); - } - } -} diff --git a/user/mpy/lib/axtls/samples/java/manifest.mf b/user/mpy/lib/axtls/samples/java/manifest.mf deleted file mode 100644 index b906ed2..0000000 --- a/user/mpy/lib/axtls/samples/java/manifest.mf +++ /dev/null @@ -1 +0,0 @@ -Main-Class: axssl diff --git a/user/mpy/lib/axtls/samples/lua/Makefile b/user/mpy/lib/axtls/samples/lua/Makefile deleted file mode 100644 index a460da3..0000000 --- a/user/mpy/lib/axtls/samples/lua/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf - -all: samples -TARGET=../../$(STAGE)/axssl.lua -samples: $(TARGET) - -$(TARGET): axssl.lua - install $< $@ - -clean:: - -@rm -f $(TARGET) - diff --git a/user/mpy/lib/axtls/samples/lua/axssl.lua b/user/mpy/lib/axtls/samples/lua/axssl.lua deleted file mode 100755 index b4f24ed..0000000 --- a/user/mpy/lib/axtls/samples/lua/axssl.lua +++ /dev/null @@ -1,562 +0,0 @@ -#!/usr/local/bin/lua - --- --- Copyright (c) 2007-2016, Cameron Rich --- --- All rights reserved. --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- * Neither the name of the axTLS project nor the names of its --- contributors may be used to endorse or promote products derived --- from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR --- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY --- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF --- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- - --- --- Demonstrate the use of the axTLS library in Lua with a set of --- command-line parameters similar to openssl. In fact, openssl clients --- should be able to communicate with axTLS servers and visa-versa. --- --- This code has various bits enabled depending on the configuration. To enable --- the most interesting version, compile with the 'full mode' enabled. --- --- To see what options you have, run the following: --- > [lua] axssl s_server -? --- > [lua] axssl s_client -? --- --- The axtls/axtlsl shared libraries must be in the same directory or be found --- by the OS. --- --- -require "bit" -require("axtlsl") -local socket = require("socket") - --- print version? -if #arg == 1 and arg[1] == "version" then - print("axssl.lua "..axtlsl.ssl_version()) - os.exit(1) -end - --- --- We've had some sort of command-line error. Print out the basic options. --- -function print_options(option) - print("axssl: Error: '"..option.."' is an invalid command.") - print("usage: axssl [s_server|s_client|version] [args ...]") - os.exit(1) -end - --- --- We've had some sort of command-line error. Print out the server options. --- -function print_server_options(build_mode, option) - local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) - local ca_cert_size = axtlsl.ssl_get_config( - axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) - - print("unknown option "..option) - print("usage: s_server [args ...]") - print(" -accept\t- port to accept on (default is 4433)") - print(" -quiet\t\t- No server output") - - if build_mode >= axtlsl.SSL_BUILD_SERVER_ONLY then - print(" -cert arg\t- certificate file to add (in addition to ".. - "default) to chain -") - print("\t\t Can repeat up to "..cert_size.." times") - print(" -key arg\t- Private key file to use - default DER format") - print(" -pass\t\t- private key file pass phrase source") - end - - if build_mode >= axtlsl.SSL_BUILD_ENABLE_VERIFICATION then - print(" -verify\t- turn on peer certificate verification") - print(" -CAfile arg\t- Certificate authority - default DER format") - print("\t\t Can repeat up to "..ca_cert_size.." times") - end - - if build_mode == axtlsl.SSL_BUILD_FULL_MODE then - print(" -debug\t\t- Print more output") - print(" -state\t\t- Show state messages") - print(" -show-rsa\t- Show RSA state") - end - - os.exit(1) -end - --- --- We've had some sort of command-line error. Print out the client options. --- -function print_client_options(build_mode, option) - local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) - local ca_cert_size = axtlsl.ssl_get_config( - axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) - - print("unknown option "..option) - - if build_mode >= axtlsl.SSL_BUILD_ENABLE_CLIENT then - print("usage: s_client [args ...]") - print(" -connect host:port - who to connect to (default ".. - "is localhost:4433)") - print(" -verify\t- turn on peer certificate verification") - print(" -cert arg\t- certificate file to use - default DER format") - print(" -key arg\t- Private key file to use - default DER format") - print("\t\t Can repeat up to "..cert_size.." times") - print(" -CAfile arg\t- Certificate authority - default DER format") - print("\t\t Can repeat up to "..ca_cert_size.."times") - print(" -quiet\t\t- No client output") - print(" -pass\t\t- private key file pass phrase source") - print(" -reconnect\t- Drop and re-make the connection ".. - "with the same Session-ID") - - if build_mode == axtlsl.SSL_BUILD_FULL_MODE then - print(" -debug\t\t- Print more output") - print(" -state\t\t- Show state messages") - print(" -show-rsa\t- Show RSA state") - end - else - print("Change configuration to allow this feature") - end - - os.exit(1) -end - --- Implement the SSL server logic. -function do_server(build_mode) - local i = 2 - local v - local port = 4433 - local options = axtlsl.SSL_DISPLAY_CERTS - local quiet = false - local password = "" - local private_key_file = nil - local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) - local ca_cert_size = axtlsl. - ssl_get_config(axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) - local cert = {} - local ca_cert = {} - - while i <= #arg do - if arg[i] == "-accept" then - if i >= #arg then - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - port = arg[i] - elseif arg[i] == "-quiet" then - quiet = true - options = bit.band(options, bit.bnot(axtlsl.SSL_DISPLAY_CERTS)) - elseif build_mode >= axtlsl.SSL_BUILD_SERVER_ONLY then - if arg[i] == "-cert" then - if i >= #arg or #cert >= cert_size then - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - table.insert(cert, arg[i]) - elseif arg[i] == "-key" then - if i >= #arg then - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - private_key_file = arg[i] - options = bit.bor(options, axtlsl.SSL_NO_DEFAULT_KEY) - elseif arg[i] == "-pass" then - if i >= #arg then - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - password = arg[i] - elseif build_mode >= axtlsl.SSL_BUILD_ENABLE_VERIFICATION then - if arg[i] == "-verify" then - options = bit.bor(options, axtlsl.SSL_CLIENT_AUTHENTICATION) - elseif arg[i] == "-CAfile" then - if i >= #arg or #ca_cert >= ca_cert_size then - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - table.insert(ca_cert, arg[i]) - elseif build_mode == axtlsl.SSL_BUILD_FULL_MODE then - if arg[i] == "-debug" then - options = bit.bor(options, axtlsl.SSL_DISPLAY_BYTES) - elseif arg[i] == "-state" then - options = bit.bor(options, axtlsl.SSL_DISPLAY_STATES) - elseif arg[i] == "-show-rsa" then - options = bit.bor(options, axtlsl.SSL_DISPLAY_RSA) - else - print_server_options(build_mode, arg[i]) - end - else - print_server_options(build_mode, arg[i]) - end - else - print_server_options(build_mode, arg[i]) - end - else - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - end - - -- Create socket for incoming connections - local server_sock = socket.try(socket.bind("*", port)) - - --------------------------------------------------------------------------- - -- This is where the interesting stuff happens. Up until now we've - -- just been setting up sockets etc. Now we do the SSL handshake. - --------------------------------------------------------------------------- - local ssl_ctx = axtlsl.ssl_ctx_new(options, axtlsl.SSL_DEFAULT_SVR_SESS) - if ssl_ctx == nil then error("Error: Server context is invalid") end - - if private_key_file ~= nil then - local obj_type = axtlsl.SSL_OBJ_RSA_KEY - - if string.find(private_key_file, ".p8") then - obj_type = axtlsl.SSL_OBJ_PKCS8 - end - - if string.find(private_key_file, ".p12") then - obj_type = axtlsl.SSL_OBJ_PKCS12 - end - - if axtlsl.ssl_obj_load(ssl_ctx, obj_type, private_key_file, - password) ~= axtlsl.SSL_OK then - error("Private key '" .. private_key_file .. "' is undefined.") - end - end - - for _, v in ipairs(cert) do - if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CERT, v, "") ~= - axtlsl.SSL_OK then - error("Certificate '"..v .. "' is undefined.") - end - end - - for _, v in ipairs(ca_cert) do - if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CACERT, v, "") ~= - axtlsl.SSL_OK then - error("Certificate '"..v .."' is undefined.") - end - end - - while true do - if not quiet then print("ACCEPT") end - local client_sock = server_sock:accept(); - local ssl = axtlsl.ssl_server_new(ssl_ctx, client_sock:getfd()) - - -- do the actual SSL handshake - local connected = false - local res - local buf - - while true do - socket.select({client_sock}, nil) - res, buf = axtlsl.ssl_read(ssl) - - if res == axtlsl.SSL_OK then -- connection established and ok - if axtlsl.ssl_handshake_status(ssl) == axtlsl.SSL_OK then - if not quiet and not connected then - display_session_id(ssl) - display_cipher(ssl) - end - connected = true - end - end - - if res > axtlsl.SSL_OK then - for _, v in ipairs(buf) do - io.write(string.format("%c", v)) - end - elseif res < axtlsl.SSL_OK then - if not quiet then - axtlsl.ssl_display_error(res) - end - break - end - end - - -- client was disconnected or the handshake failed. - print("CONNECTION CLOSED") - axtlsl.ssl_free(ssl) - client_sock:close() - end - - axtlsl.ssl_ctx_free(ssl_ctx) -end - --- --- Implement the SSL client logic. --- -function do_client(build_mode) - local i = 2 - local v - local port = 4433 - local options = - bit.bor(axtlsl.SSL_SERVER_VERIFY_LATER, axtlsl.SSL_DISPLAY_CERTS) - local private_key_file = nil - local reconnect = 0 - local quiet = false - local password = "" - local session_id = {} - local host = "127.0.0.1" - local cert_size = axtlsl.ssl_get_config(axtlsl.SSL_MAX_CERT_CFG_OFFSET) - local ca_cert_size = axtlsl. - ssl_get_config(axtlsl.SSL_MAX_CA_CERT_CFG_OFFSET) - local cert = {} - local ca_cert = {} - - while i <= #arg do - if arg[i] == "-connect" then - if i >= #arg then - print_client_options(build_mode, arg[i]) - end - - i = i + 1 - local t = string.find(arg[i], ":") - host = string.sub(arg[i], 1, t-1) - port = string.sub(arg[i], t+1) - elseif arg[i] == "-cert" then - if i >= #arg or #cert >= cert_size then - print_client_options(build_mode, arg[i]) - end - - i = i + 1 - table.insert(cert, arg[i]) - elseif arg[i] == "-key" then - if i >= #arg then - print_client_options(build_mode, arg[i]) - end - - i = i + 1 - private_key_file = arg[i] - options = bit.bor(options, axtlsl.SSL_NO_DEFAULT_KEY) - elseif arg[i] == "-CAfile" then - if i >= #arg or #ca_cert >= ca_cert_size then - print_client_options(build_mode, arg[i]) - end - - i = i + 1 - table.insert(ca_cert, arg[i]) - elseif arg[i] == "-verify" then - options = bit.band(options, - bit.bnot(axtlsl.SSL_SERVER_VERIFY_LATER)) - elseif arg[i] == "-reconnect" then - reconnect = 4 - elseif arg[i] == "-quiet" then - quiet = true - options = bit.band(options, bnot(axtlsl.SSL_DISPLAY_CERTS)) - elseif arg[i] == "-pass" then - if i >= #arg then - print_server_options(build_mode, arg[i]) - end - - i = i + 1 - password = arg[i] - elseif build_mode == axtlsl.SSL_BUILD_FULL_MODE then - if arg[i] == "-debug" then - options = bit.bor(options, axtlsl.SSL_DISPLAY_BYTES) - elseif arg[i] == "-state" then - options = bit.bor(axtlsl.SSL_DISPLAY_STATES) - elseif arg[i] == "-show-rsa" then - options = bit.bor(axtlsl.SSL_DISPLAY_RSA) - else -- don't know what this is - print_client_options(build_mode, arg[i]) - end - else -- don't know what this is - print_client_options(build_mode, arg[i]) - end - - i = i + 1 - end - - local client_sock = socket.try(socket.connect(host, port)) - local ssl - local res - - if not quiet then print("CONNECTED") end - - --------------------------------------------------------------------------- - -- This is where the interesting stuff happens. Up until now we've - -- just been setting up sockets etc. Now we do the SSL handshake. - --------------------------------------------------------------------------- - local ssl_ctx = axtlsl.ssl_ctx_new(options, axtlsl.SSL_DEFAULT_CLNT_SESS) - - if ssl_ctx == nil then - error("Error: Client context is invalid") - end - - if private_key_file ~= nil then - local obj_type = axtlsl.SSL_OBJ_RSA_KEY - - if string.find(private_key_file, ".p8") then - obj_type = axtlsl.SSL_OBJ_PKCS8 - end - - if string.find(private_key_file, ".p12") then - obj_type = axtlsl.SSL_OBJ_PKCS12 - end - - if axtlsl.ssl_obj_load(ssl_ctx, obj_type, private_key_file, - password) ~= axtlsl.SSL_OK then - error("Private key '"..private_key_file.."' is undefined.") - end - end - - for _, v in ipairs(cert) do - if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CERT, v, "") ~= - axtlsl.SSL_OK then - error("Certificate '"..v .. "' is undefined.") - end - end - - for _, v in ipairs(ca_cert) do - if axtlsl.ssl_obj_load(ssl_ctx, axtlsl.SSL_OBJ_X509_CACERT, v, "") ~= - axtlsl.SSL_OK then - error("Certificate '"..v .."' is undefined.") - end - end - - -- Try session resumption? - if reconnect ~= 0 then - local session_id = nil - local sess_id_size = 0 - - while reconnect > 0 do - reconnect = reconnect - 1 - ssl = axtlsl.ssl_client_new(ssl_ctx, - client_sock:getfd(), session_id, sess_id_size) - - res = axtlsl.ssl_handshake_status(ssl) - if res ~= axtlsl.SSL_OK then - if not quiet then axtlsl.ssl_display_error(res) end - axtlsl.ssl_free(ssl) - os.exit(1) - end - - display_session_id(ssl) - session_id = axtlsl.ssl_get_session_id(ssl) - sess_id_size = axtlsl.ssl_get_session_id_size(ssl) - - if reconnect > 0 then - axtlsl.ssl_free(ssl) - client_sock:close() - client_sock = socket.try(socket.connect(host, port)) - end - - end - else - ssl = axtlsl.ssl_client_new(ssl_ctx, client_sock:getfd(), nil, 0) - end - - -- check the return status - res = axtlsl.ssl_handshake_status(ssl) - if res ~= axtlsl.SSL_OK then - if not quiet then axtlsl.ssl_display_error(res) end - os.exit(1) - end - - if not quiet then - local common_name = axtlsl.ssl_get_cert_dn(ssl, - axtlsl.SSL_X509_CERT_COMMON_NAME) - - if common_name ~= nil then - print("Common Name:\t\t\t"..common_name) - end - - display_session_id(ssl) - display_cipher(ssl) - end - - while true do - local line = io.read() - if line == nil then break end - local bytes = {} - - for i = 1, #line do - bytes[i] = line.byte(line, i) - end - - bytes[#line+1] = 10 -- add carriage return, null - bytes[#line+2] = 0 - - res = axtlsl.ssl_write(ssl, bytes, #bytes) - if res < axtlsl.SSL_OK then - if not quiet then axtlsl.ssl_display_error(res) end - break - end - end - - axtlsl.ssl_ctx_free(ssl_ctx) - client_sock:close() -end - --- --- Display what cipher we are using --- -function display_cipher(ssl) - io.write("CIPHER is ") - local cipher_id = axtlsl.ssl_get_cipher_id(ssl) - - if cipher_id == axtlsl.SSL_AES128_SHA then - print("AES128-SHA") - elseif cipher_id == axtlsl.SSL_AES256_SHA then - print("AES256-SHA") - elseif axtlsl.SSL_AES128_SHA256 then - print("AES128-SHA256") - elseif axtlsl.SSL_AES256_SHA256 then - print("AES256-SHA256") - else - print("Unknown - "..cipher_id) - end -end - --- --- Display what session id we have. --- -function display_session_id(ssl) - local session_id = axtlsl.ssl_get_session_id(ssl) - local v - - if #session_id > 0 then - print("-----BEGIN SSL SESSION PARAMETERS-----") - for _, v in ipairs(session_id) do - io.write(string.format("%02x", v)) - end - print("\n-----END SSL SESSION PARAMETERS-----") - end -end - --- --- Main entry point. Doesn't do much except works out whether we are a client --- or a server. --- -if #arg == 0 or (arg[1] ~= "s_server" and arg[1] ~= "s_client") then - print_options(#arg > 0 and arg[1] or "") -end - -local build_mode = axtlsl.ssl_get_config(axtlsl.SSL_BUILD_MODE) -_ = arg[1] == "s_server" and do_server(build_mode) or do_client(build_mode) -os.exit(0) - diff --git a/user/mpy/lib/axtls/samples/perl/Makefile b/user/mpy/lib/axtls/samples/perl/Makefile deleted file mode 100644 index 5200c43..0000000 --- a/user/mpy/lib/axtls/samples/perl/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf - -all: samples -TARGET=../../$(STAGE)/axssl.pl -samples: $(TARGET) - -$(TARGET): axssl.pl - install $< $@ - -clean:: - -@rm -f $(TARGET) - diff --git a/user/mpy/lib/axtls/samples/perl/axssl.pl b/user/mpy/lib/axtls/samples/perl/axssl.pl deleted file mode 100755 index f3b0449..0000000 --- a/user/mpy/lib/axtls/samples/perl/axssl.pl +++ /dev/null @@ -1,634 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (c) 2007-2016, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# -# Demonstrate the use of the axTLS library in Perl with a set of -# command-line parameters similar to openssl. In fact, openssl clients -# should be able to communicate with axTLS servers and visa-versa. -# -# This code has various bits enabled depending on the configuration. To enable -# the most interesting version, compile with the 'full mode' enabled. -# -# To see what options you have, run the following: -# > [perl] axssl s_server -? -# > [perl] axssl s_client -? -# -# The axtls/axtlsp shared libraries must be in the same directory or be found -# by the OS. axtlsp.pm must be in this directory or be in @INC. -# -# Under Win32, ActivePerl was used (see -# http://www.activestate.com/Products/ActivePerl/?mp=1) -# -use axtlsp; -use IO::Socket; - -# To get access to Win32 file descriptor stuff -my $is_win32 = 0; - -if ($^O eq "MSWin32") -{ - eval("use Win32API::File 0.08 qw( :ALL )"); - $is_win32 = 1; -} - -use strict; - -# -# Win32 has some problems with socket handles -# -sub get_native_sock -{ - my ($sock) = @_; - return $is_win32 ? FdGetOsFHandle($sock) : $sock; -} - -# print version? -if ($#ARGV == 0 && $ARGV[0] eq "version") -{ - printf("axssl.pl ".axtlsp::ssl_version()."\n"); - exit 0; -} - -# -# Main entry point. Doesn't do much except works out whether we are a client -# or a server. -# -print_options($#ARGV > -1 ? $ARGV[0] : "") - if ($#ARGV < 0 || ($ARGV[0] ne "s_server" && $ARGV[0] ne "s_client")); - - -# Cygwin/Win32 issue - flush our output continuously -select STDOUT; -local $|=1; - -my $build_mode = axtlsp::ssl_get_config($axtlsp::SSL_BUILD_MODE); -$ARGV[0] eq "s_server" ? do_server($build_mode) : do_client($build_mode); - -# -# Implement the SSL server logic. -# -sub do_server -{ - my ($build_mode) = @_; - my $i = 1; - my $port = 4433; - my $options = $axtlsp::SSL_DISPLAY_CERTS; - my $quiet = 0; - my $password = undef; - my $private_key_file = undef; - my $cert_size = axtlsp::ssl_get_config($axtlsp::SSL_MAX_CERT_CFG_OFFSET); - my $ca_cert_size = axtlsp::ssl_get_config( - $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); - my @cert; - my @ca_cert; - - while ($i <= $#ARGV) - { - if ($ARGV[$i] eq "-accept") - { - print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; - $port = $ARGV[++$i]; - } - elsif ($ARGV[$i] eq "-quiet") - { - $quiet = 1; - $options &= ~$axtlsp::SSL_DISPLAY_CERTS; - } - elsif ($build_mode >= $axtlsp::SSL_BUILD_SERVER_ONLY) - { - if ($ARGV[$i] eq "-cert") - { - print_server_options($build_mode, $ARGV[$i]) - if $i >= $#ARGV || $#cert >= $cert_size-1; - - push @cert, $ARGV[++$i]; - } - elsif ($ARGV[$i] eq "-key") - { - print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; - $private_key_file = $ARGV[++$i]; - $options |= $axtlsp::SSL_NO_DEFAULT_KEY; - } - elsif ($ARGV[$i] eq "-pass") - { - print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; - $password = $ARGV[++$i]; - } - elsif ($build_mode >= $axtlsp::SSL_BUILD_ENABLE_VERIFICATION) - { - if ($ARGV[$i] eq "-verify") - { - $options |= $axtlsp::SSL_CLIENT_AUTHENTICATION; - } - elsif ($ARGV[$i] eq "-CAfile") - { - print_server_options($build_mode, $ARGV[$i]) - if $i >= $#ARGV || $#ca_cert >= $ca_cert_size-1; - push @ca_cert, $ARGV[++$i]; - } - elsif ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) - { - if ($ARGV[$i] eq "-debug") - { - $options |= $axtlsp::SSL_DISPLAY_BYTES; - } - elsif ($ARGV[$i] eq "-state") - { - $options |= $axtlsp::SSL_DISPLAY_STATES; - } - elsif ($ARGV[$i] eq "-show-rsa") - { - $options |= $axtlsp::SSL_DISPLAY_RSA; - } - else - { - print_server_options($build_mode, $ARGV[$i]); - } - } - else - { - print_server_options($build_mode, $ARGV[$i]); - } - } - else - { - print_server_options($build_mode, $ARGV[$i]); - } - } - else - { - print_server_options($build_mode, $ARGV[$i]); - } - - $i++; - } - - # Create socket for incoming connections - my $server_sock = IO::Socket::INET->new(Proto => 'tcp', - LocalPort => $port, - Listen => 1, - Reuse => 1) or die $!; - - ########################################################################### - # This is where the interesting stuff happens. Up until now we've - # just been setting up sockets etc. Now we do the SSL handshake. - ########################################################################### - my $ssl_ctx = axtlsp::ssl_ctx_new($options, $axtlsp::SSL_DEFAULT_SVR_SESS); - die "Error: Server context is invalid" if not defined $ssl_ctx; - - if (defined $private_key_file) - { - my $obj_type = $axtlsp::SSL_OBJ_RSA_KEY; - - $obj_type = $axtlsp::SSL_OBJ_PKCS8 if $private_key_file =~ /.p8$/; - $obj_type = $axtlsp::SSL_OBJ_PKCS12 if $private_key_file =~ /.p12$/; - - die "Private key '$private_key_file' is undefined." if - axtlsp::ssl_obj_load($ssl_ctx, $obj_type, - $private_key_file, $password); - } - - foreach (@cert) - { - die "Certificate '$_' is undefined." - if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CERT, - $_, undef) != $axtlsp::SSL_OK; - } - - foreach (@ca_cert) - { - die "Certificate '$_' is undefined." - if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CACERT, - $_, undef) != $axtlsp::SSL_OK; - } - - for (;;) - { - printf("ACCEPT\n") if not $quiet; - my $client_sock = $server_sock->accept; - my $native_sock = get_native_sock($client_sock->fileno); - - # This doesn't work in Win32 - need to get file descriptor from socket. - my $ssl = axtlsp::ssl_server_new($ssl_ctx, $native_sock); - - # do the actual SSL handshake - my $res; - my $buf; - my $connected = 0; - - while (1) - { - ($res, $buf) = axtlsp::ssl_read($ssl, undef); - last if $res < $axtlsp::SSL_OK; - - if ($res == $axtlsp::SSL_OK) # connection established and ok - { - if (axtlsp::ssl_handshake_status($ssl) == $axtlsp::SSL_OK) - { - if (!$quiet && !$connected) - { - display_session_id($ssl); - display_cipher($ssl); - } - - $connected = 1; - } - } - - if ($res > $axtlsp::SSL_OK) - { - printf($$buf); - } - elsif ($res < $axtlsp::SSL_OK) - { - axtlsp::ssl_display_error($res) if not $quiet; - last; - } - } - - # client was disconnected or the handshake failed. - printf("CONNECTION CLOSED\n") if not $quiet; - axtlsp::ssl_free($ssl); - $client_sock->close; - } - - axtlsp::ssl_ctx_free($ssl_ctx); -} - -# -# Implement the SSL client logic. -# -sub do_client -{ - my ($build_mode) = @_; - my $i = 1; - my $port = 4433; - my $options = $axtlsp::SSL_SERVER_VERIFY_LATER|$axtlsp::SSL_DISPLAY_CERTS; - my $private_key_file = undef; - my $reconnect = 0; - my $quiet = 0; - my $password = undef; - my @session_id; - my $host = "127.0.0.1"; - my @cert; - my @ca_cert; - my $cert_size = axtlsp::ssl_get_config( - $axtlsp::SSL_MAX_CERT_CFG_OFFSET); - my $ca_cert_size = axtlsp::ssl_get_config( - $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); - - while ($i <= $#ARGV) - { - if ($ARGV[$i] eq "-connect") - { - print_client_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; - ($host, $port) = split(':', $ARGV[++$i]); - } - elsif ($ARGV[$i] eq "-cert") - { - print_client_options($build_mode, $ARGV[$i]) - if $i >= $#ARGV || $#cert >= $cert_size-1; - - push @cert, $ARGV[++$i]; - } - elsif ($ARGV[$i] eq "-key") - { - print_client_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; - $private_key_file = $ARGV[++$i]; - $options |= $axtlsp::SSL_NO_DEFAULT_KEY; - } - elsif ($ARGV[$i] eq "-CAfile") - { - print_client_options($build_mode, $ARGV[$i]) - if $i >= $#ARGV || $#ca_cert >= $ca_cert_size-1; - - push @ca_cert, $ARGV[++$i]; - } - elsif ($ARGV[$i] eq "-verify") - { - $options &= ~$axtlsp::SSL_SERVER_VERIFY_LATER; - } - elsif ($ARGV[$i] eq "-reconnect") - { - $reconnect = 4; - } - elsif ($ARGV[$i] eq "-quiet") - { - $quiet = 1; - $options &= ~$axtlsp::SSL_DISPLAY_CERTS; - } - elsif ($ARGV[$i] eq "-pass") - { - print_server_options($build_mode, $ARGV[$i]) if $i >= $#ARGV; - $password = $ARGV[++$i]; - } - elsif ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) - { - if ($ARGV[$i] eq "-debug") - { - $options |= $axtlsp::SSL_DISPLAY_BYTES; - } - elsif ($ARGV[$i] eq "-state") - { - $options |= $axtlsp::SSL_DISPLAY_STATES; - } - elsif ($ARGV[$i] eq "-show-rsa") - { - $options |= $axtlsp::SSL_DISPLAY_RSA; - } - else # don't know what this is - { - print_client_options($build_mode, $ARGV[$i]); - } - } - else # don't know what this is - { - print_client_options($build_mode, $ARGV[$i]); - } - - $i++; - } - - my $client_sock = new IO::Socket::INET ( - PeerAddr => $host, PeerPort => $port, Proto => 'tcp') - || die ("no socket: $!"); - my $ssl; - my $res; - my $native_sock = get_native_sock($client_sock->fileno); - - printf("CONNECTED\n") if not $quiet; - - ########################################################################### - # This is where the interesting stuff happens. Up until now we've - # just been setting up sockets etc. Now we do the SSL handshake. - ########################################################################### - my $ssl_ctx = axtlsp::ssl_ctx_new($options, $axtlsp::SSL_DEFAULT_CLNT_SESS); - die "Error: Client context is invalid" if not defined $ssl_ctx; - - if (defined $private_key_file) - { - my $obj_type = $axtlsp::SSL_OBJ_RSA_KEY; - - $obj_type = $axtlsp::SSL_OBJ_PKCS8 if $private_key_file =~ /.p8$/; - $obj_type = $axtlsp::SSL_OBJ_PKCS12 if $private_key_file =~ /.p12$/; - - die "Private key '$private_key_file' is undefined." if - axtlsp::ssl_obj_load($ssl_ctx, $obj_type, - $private_key_file, $password); - } - - foreach (@cert) - { - die "Certificate '$_' is undefined." - if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CERT, - $_, undef) != $axtlsp::SSL_OK; - } - - foreach (@ca_cert) - { - die "Certificate '$_' is undefined." - if axtlsp::ssl_obj_load($ssl_ctx, $axtlsp::SSL_OBJ_X509_CACERT, - $_, undef) != $axtlsp::SSL_OK; - } - - # Try session resumption? - if ($reconnect) - { - my $session_id = undef; - my $sess_id_size = 0; - - while ($reconnect--) - { - $ssl = axtlsp::ssl_client_new($ssl_ctx, $native_sock, - $session_id, $sess_id_size); - - $res = axtlsp::ssl_handshake_status($ssl); - if ($res != $axtlsp::SSL_OK) - { - axtlsp::ssl_display_error($res) if !$quiet; - axtlsp::ssl_free($ssl); - exit 1; - } - - display_session_id($ssl); - $session_id = axtlsp::ssl_get_session_id($ssl); - - if ($reconnect) - { - axtlsp::ssl_free($ssl); - $client_sock->close; - $client_sock = new IO::Socket::INET ( - PeerAddr => $host, PeerPort => $port, Proto => 'tcp') - || die ("no socket: $!"); - - } - } - } - else - { - $ssl = axtlsp::ssl_client_new($ssl_ctx, $native_sock, undef, 0); - } - - # check the return status - $res = axtlsp::ssl_handshake_status($ssl); - if ($res != $axtlsp::SSL_OK) - { - axtlsp::ssl_display_error($res) if not $quiet; - exit 1; - } - - if (!$quiet) - { - my $common_name = axtlsp::ssl_get_cert_dn($ssl, - $axtlsp::SSL_X509_CERT_COMMON_NAME); - - printf("Common Name:\t\t\t%s\n", $common_name) if defined $common_name; - display_session_id($ssl); - display_cipher($ssl); - } - - while () - { - my $cstring = pack("a*x", $_); # add null terminator - $res = axtlsp::ssl_write($ssl, \$cstring, length($cstring)); - if ($res < $axtlsp::SSL_OK) - { - axtlsp::ssl_display_error($res) if not $quiet; - last; - } - } - - axtlsp::ssl_ctx_free($ssl_ctx); - $client_sock->close; -} - -# -# We've had some sort of command-line error. Print out the basic options. -# -sub print_options -{ - my ($option) = @_; - printf("axssl: Error: '%s' is an invalid command.\n", $option); - printf("usage: axssl [s_server|s_client|version] [args ...]\n"); - exit 1; -} - -# -# We've had some sort of command-line error. Print out the server options. -# -sub print_server_options -{ - my ($build_mode, $option) = @_; - my $cert_size = axtlsp::ssl_get_config($axtlsp::SSL_MAX_CERT_CFG_OFFSET); - my $ca_cert_size = axtlsp::ssl_get_config( - $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); - - printf("unknown option %s\n", $option); - printf("usage: s_server [args ...]\n"); - printf(" -accept arg\t- port to accept on (default is 4433)\n"); - printf(" -quiet\t\t- No server output\n"); - - if ($build_mode >= $axtlsp::SSL_BUILD_SERVER_ONLY) - { - printf(" -cert arg\t- certificate file to add (in addition to default)". - " to chain -\n". - "\t\t Can repeat up to %d times\n", $cert_size); - printf(" -key arg\t- Private key file to use - default DER format\n"); - printf(" -pass\t\t- private key file pass phrase source\n"); - } - - if ($build_mode >= $axtlsp::SSL_BUILD_ENABLE_VERIFICATION) - { - printf(" -verify\t- turn on peer certificate verification\n"); - printf(" -CAfile arg\t- Certificate authority - default DER format\n"); - printf("\t\t Can repeat up to %d times\n", $ca_cert_size); - } - - if ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) - { - printf(" -debug\t\t- Print more output\n"); - printf(" -state\t\t- Show state messages\n"); - printf(" -show-rsa\t- Show RSA state\n"); - } - - exit 1; -} - -# -# We've had some sort of command-line error. Print out the client options. -# -sub print_client_options -{ - my ($build_mode, $option) = @_; - my $cert_size = axtlsp::ssl_get_config($axtlsp::SSL_MAX_CERT_CFG_OFFSET); - my $ca_cert_size = axtlsp::ssl_get_config( - $axtlsp::SSL_MAX_CA_CERT_CFG_OFFSET); - - printf("unknown option %s\n", $option); - - if ($build_mode >= $axtlsp::SSL_BUILD_ENABLE_CLIENT) - { - printf("usage: s_client [args ...]\n"); - printf(" -connect host:port - who to connect to (default ". - "is localhost:4433)\n"); - printf(" -verify\t- turn on peer certificate verification\n"); - printf(" -cert arg\t- certificate file to use - default DER format\n"); - printf(" -key arg\t- Private key file to use - default DER format\n"); - printf("\t\t Can repeat up to %d times\n", $cert_size); - printf(" -CAfile arg\t- Certificate authority - default DER format\n"); - printf("\t\t Can repeat up to %d times\n", $ca_cert_size); - printf(" -quiet\t\t- No client output\n"); - printf(" -pass\t\t- private key file pass phrase source\n"); - printf(" -reconnect\t- Drop and re-make the connection ". - "with the same Session-ID\n"); - - if ($build_mode == $axtlsp::SSL_BUILD_FULL_MODE) - { - printf(" -debug\t\t- Print more output\n"); - printf(" -state\t\t- Show state messages\n"); - printf(" -show-rsa\t- Show RSA state\n"); - } - } - else - { - printf("Change configuration to allow this feature\n"); - } - - exit 1; -} - -# -# Display what cipher we are using -# -sub display_cipher -{ - my ($ssl) = @_; - printf("CIPHER is "); - my $cipher_id = axtlsp::ssl_get_cipher_id($ssl); - - if ($cipher_id == $axtlsp::SSL_AES128_SHA) - { - printf("AES128-SHA"); - } - elsif ($cipher_id == $axtlsp::SSL_AES256_SHA) - { - printf("AES256-SHA"); - } - elsif ($axtlsp::SSL_AES128_SHA256) - { - printf("AES128-SHA256"); - } - elsif ($axtlsp::SSL_AES256_SHA256) - { - printf("AES256-SHA256"); - } - else - { - printf("Unknown - %d", $cipher_id); - } - - printf("\n"); -} - -# -# Display what session id we have. -# -sub display_session_id -{ - my ($ssl) = @_; - my $session_id = axtlsp::ssl_get_session_id($ssl); - if (length($$session_id) > 0) - { - printf("-----BEGIN SSL SESSION PARAMETERS-----\n"); - printf(unpack("H*", $$session_id)); - printf("\n-----END SSL SESSION PARAMETERS-----\n"); - } -} diff --git a/user/mpy/lib/axtls/samples/vbnet/Makefile b/user/mpy/lib/axtls/samples/vbnet/Makefile deleted file mode 100644 index 0984d4e..0000000 --- a/user/mpy/lib/axtls/samples/vbnet/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -include ../../config/.config -include ../../config/makefile.conf -include ../../config/makefile.dotnet.conf - -# only build on Win32 platforms -ifdef GO_DOT_NET -all : sample -TARGET=../../$(STAGE)/axssl.vbnet.exe -sample : $(TARGET) - -$(TARGET): ../../bindings/vbnet/axTLSvb.vb ../../bindings/vbnet/axInterface.vb axssl.vb - vbc.exe /r:"`cygpath -w "$(CONFIG_DOT_NET_FRAMEWORK_BASE)/System.dll"`" /nologo /t:exe /out:"`cygpath -w $@`" $(foreach file, $^, "`cygpath -w $(file)`") - -endif # ARCH - -clean:: - -@rm -f $(TARGET) - diff --git a/user/mpy/lib/axtls/samples/vbnet/axssl.vb b/user/mpy/lib/axtls/samples/vbnet/axssl.vb deleted file mode 100644 index 7e5d682..0000000 --- a/user/mpy/lib/axtls/samples/vbnet/axssl.vb +++ /dev/null @@ -1,702 +0,0 @@ -' -' Copyright (c) 2007-2016, Cameron Rich -' -' All rights reserved. -' -' Redistribution and use in source and binary forms, with or without -' modification, are permitted provided that the following conditions are met: -' -' * Redistributions of source code must retain the above copyright notice, -' this list of conditions and the following disclaimer. -' * Redistributions in binary form must reproduce the above copyright -' notice, this list of conditions and the following disclaimer in the -' documentation and/or other materials provided with the distribution. -' * Neither the name of the axTLS project nor the names of its -' contributors may be used to endorse or promote products derived -' from this software without specific prior written permission. -' -' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -' CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -' TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -' OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -' NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -' THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -' - -' -' Demonstrate the use of the axTLS library in VB.NET with a set of -' command-line parameters similar to openssl. In fact, openssl clients -' should be able to communicate with axTLS servers and visa-versa. -' -' This code has various bits enabled depending on the configuration. To enable -' the most interesting version, compile with the 'full mode' enabled. -' -' To see what options you have, run the following: -' > axssl.vbnet.exe s_server -? -' > axssl.vbnet.exe s_client -? -' -' The axtls shared library must be in the same directory or be found -' by the OS. -' - -Imports System -Imports System.Net -Imports System.Net.Sockets -Imports Microsoft.VisualBasic -Imports axTLSvb - -Public Class axssl - ' - ' do_server() - ' - Public Sub do_server(ByVal build_mode As Integer, _ - ByVal args() As String) - Dim i As Integer = 1 - Dim port As Integer = 4433 - Dim options As Integer = axtls.SSL_DISPLAY_CERTS - Dim quiet As Boolean = False - Dim password As String = Nothing - Dim private_key_file As String = Nothing - - ' organise the cert/ca_cert lists - Dim cert_size As Integer = SSLUtil.MaxCerts() - Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() - Dim cert(cert_size) As String - Dim ca_cert(ca_cert_size) As String - Dim cert_index As Integer = 0 - Dim ca_cert_index As Integer = 0 - - While i < args.Length - If args(i) = "-accept" Then - If i >= args.Length-1 - print_server_options(build_mode, args(i)) - End If - - i += 1 - port = Int32.Parse(args(i)) - ElseIf args(i) = "-quiet" - quiet = True - options = options And Not axtls.SSL_DISPLAY_CERTS - ElseIf build_mode >= axtls.SSL_BUILD_SERVER_ONLY - If args(i) = "-cert" - If i >= args.Length-1 Or cert_index >= cert_size - print_server_options(build_mode, args(i)) - End If - - i += 1 - cert(cert_index) = args(i) - cert_index += 1 - ElseIf args(i) = "-key" - If i >= args.Length-1 - print_server_options(build_mode, args(i)) - End If - - i += 1 - private_key_file = args(i) - options = options Or axtls.SSL_NO_DEFAULT_KEY - ElseIf args(i) = "-pass" - If i >= args.Length-1 - print_server_options(build_mode, args(i)) - End If - - i += 1 - password = args(i) - ElseIf build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION - If args(i) = "-verify" Then - options = options Or axtls.SSL_CLIENT_AUTHENTICATION - ElseIf args(i) = "-CAfile" - If i >= args.Length-1 Or _ - ca_cert_index >= ca_cert_size Then - print_server_options(build_mode, args(i)) - End If - - i += 1 - ca_cert(ca_cert_index) = args(i) - ca_cert_index += 1 - ElseIf build_mode = axtls.SSL_BUILD_FULL_MODE - If args(i) = "-debug" Then - options = options Or axtls.SSL_DISPLAY_BYTES - ElseIf args(i) = "-state" - options = options Or axtls.SSL_DISPLAY_STATES - ElseIf args(i) = "-show-rsa" - options = options Or axtls.SSL_DISPLAY_RSA - Else - print_server_options(build_mode, args(i)) - End If - Else - print_server_options(build_mode, args(i)) - End If - Else - print_server_options(build_mode, args(i)) - End If - End If - - i += 1 - End While - - ' Create socket for incoming connections - Dim ep As IPEndPoint = New IPEndPoint(IPAddress.Any, port) - Dim server_sock As TcpListener = New TcpListener(ep) - server_sock.Start() - - '********************************************************************* - ' This is where the interesting stuff happens. Up until now we've - ' just been setting up sockets etc. Now we do the SSL handshake. - '*********************************************************************/ - Dim ssl_ctx As SSLServer = New SSLServer(options, _ - axtls.SSL_DEFAULT_SVR_SESS) - - If ssl_ctx Is Nothing Then - Console.Error.WriteLine("Error: Server context is invalid") - Environment.Exit(1) - End If - - If private_key_file <> Nothing Then - Dim obj_type As Integer = axtls.SSL_OBJ_RSA_KEY - - If private_key_file.EndsWith(".p8") Then - obj_type = axtls.SSL_OBJ_PKCS8 - Else If (private_key_file.EndsWith(".p12")) - obj_type = axtls.SSL_OBJ_PKCS12 - End If - - If ssl_ctx.ObjLoad(obj_type, private_key_file, _ - password) <> axtls.SSL_OK Then - Console.Error.WriteLine("Error: Private key '" & _ - private_key_file & "' is undefined.") - Environment.Exit(1) - End If - End If - - For i = 0 To cert_index-1 - If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, _ - cert(i), Nothing) <> axtls.SSL_OK Then - Console.WriteLine("Certificate '" & cert(i) & _ - "' is undefined.") - Environment.Exit(1) - End If - Next - - For i = 0 To ca_cert_index-1 - If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, _ - ca_cert(i), Nothing) <> axtls.SSL_OK Then - Console.WriteLine("Certificate '" & ca_cert(i) & _ - "' is undefined.") - Environment.Exit(1) - End If - Next - - Dim buf As Byte() = Nothing - Dim res As Integer - Dim ssl As SSL - - While 1 - If Not quiet Then - Console.WriteLine("ACCEPT") - End If - - Dim client_sock As Socket = server_sock.AcceptSocket() - - ssl = ssl_ctx.Connect(client_sock) - - ' do the actual SSL handshake - While 1 - res = ssl_ctx.Read(ssl, buf) - If res <> axtls.SSL_OK Then - Exit While - End If - - ' check when the connection has been established - If ssl.HandshakeStatus() = axtls.SSL_OK - Exit While - End If - - ' could do something else here - End While - - If res = axtls.SSL_OK Then ' connection established and ok - If Not quiet - display_session_id(ssl) - display_cipher(ssl) - End If - - ' now read (and display) whatever the client sends us - While 1 - ' keep reading until we get something interesting - While 1 - res = ssl_ctx.Read(ssl, buf) - If res <> axtls.SSL_OK Then - Exit While - End If - - ' could do something else here - End While - - If res < axtls.SSL_OK - If Not quiet - Console.WriteLine("CONNECTION CLOSED") - End If - - Exit While - End If - - ' convert to String - Dim str(res) As Char - For i = 0 To res-1 - str(i) = Chr(buf(i)) - Next - - Console.Write(str) - End While - ElseIf Not quiet - SSLUtil.DisplayError(res) - End If - - ' client was disconnected or the handshake failed. */ - ssl.Dispose() - client_sock.Close() - End While - - ssl_ctx.Dispose() - End Sub - - ' - ' do_client() - ' - Public Sub do_client(ByVal build_mode As Integer, _ - ByVal args() As String) - - If build_mode < axtls.SSL_BUILD_ENABLE_CLIENT Then - print_client_options(build_mode, args(1)) - End If - - Dim i As Integer = 1 - Dim res As Integer - Dim port As Integer = 4433 - Dim quiet As Boolean = False - Dim password As String = Nothing - Dim reconnect As Integer = 0 - Dim private_key_file As String = Nothing - Dim hostname As String = "127.0.0.1" - - ' organise the cert/ca_cert lists - Dim ssl As SSL = Nothing - Dim cert_size As Integer = SSLUtil.MaxCerts() - Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() - Dim cert(cert_size) As String - Dim ca_cert(ca_cert_size) As String - Dim cert_index As Integer = 0 - Dim ca_cert_index As Integer = 0 - - Dim options As Integer = _ - axtls.SSL_SERVER_VERIFY_LATER Or axtls.SSL_DISPLAY_CERTS - Dim session_id As Byte() = Nothing - - While i < args.Length - If args(i) = "-connect" Then - Dim host_port As String - - If i >= args.Length-1 - print_client_options(build_mode, args(i)) - End If - - i += 1 - host_port = args(i) - - Dim index_colon As Integer = host_port.IndexOf(":"C) - If index_colon < 0 Then - print_client_options(build_mode, args(i)) - End If - - hostname = New String(host_port.ToCharArray(), _ - 0, index_colon) - port = Int32.Parse(New String(host_port.ToCharArray(), _ - index_colon+1, host_port.Length-index_colon-1)) - ElseIf args(i) = "-cert" - If i >= args.Length-1 Or cert_index >= cert_size Then - print_client_options(build_mode, args(i)) - End If - - i += 1 - cert(cert_index) = args(i) - cert_index += 1 - ElseIf args(i) = "-key" - If i >= args.Length-1 - print_client_options(build_mode, args(i)) - End If - - i += 1 - private_key_file = args(i) - options = options Or axtls.SSL_NO_DEFAULT_KEY - ElseIf args(i) = "-CAfile" - If i >= args.Length-1 Or ca_cert_index >= ca_cert_size - print_client_options(build_mode, args(i)) - End If - - i += 1 - ca_cert(ca_cert_index) = args(i) - ca_cert_index += 1 - ElseIf args(i) = "-verify" - options = options And Not axtls.SSL_SERVER_VERIFY_LATER - ElseIf args(i) = "-reconnect" - reconnect = 4 - ElseIf args(i) = "-quiet" - quiet = True - options = options And Not axtls.SSL_DISPLAY_CERTS - ElseIf args(i) = "-pass" - If i >= args.Length-1 - print_client_options(build_mode, args(i)) - End If - - i += 1 - password = args(i) - ElseIf build_mode = axtls.SSL_BUILD_FULL_MODE - If args(i) = "-debug" Then - options = options Or axtls.SSL_DISPLAY_BYTES - ElseIf args(i) = "-state" - options = options Or axtls.SSL_DISPLAY_STATES - ElseIf args(i) = "-show-rsa" - options = options Or axtls.SSL_DISPLAY_RSA - Else - print_client_options(build_mode, args(i)) - End If - Else ' don't know what this is - print_client_options(build_mode, args(i)) - End If - - i += 1 - End While - - 'Dim hostInfo As IPHostEntry = Dns.Resolve(hostname) - Dim hostInfo As IPHostEntry = Dns.GetHostEntry(hostname) - Dim addresses As IPAddress() = hostInfo.AddressList - Dim ep As IPEndPoint = New IPEndPoint(addresses(0), port) - Dim client_sock As Socket = New Socket(AddressFamily.InterNetwork, _ - SocketType.Stream, ProtocolType.Tcp) - client_sock.Connect(ep) - - If Not client_sock.Connected Then - Console.WriteLine("could not connect") - Environment.Exit(1) - End If - - If Not quiet Then - Console.WriteLine("CONNECTED") - End If - - '********************************************************************* - ' This is where the interesting stuff happens. Up until now we've - ' just been setting up sockets etc. Now we do the SSL handshake. - '*********************************************************************/ - Dim ssl_ctx As SSLClient = New SSLClient(options, _ - axtls.SSL_DEFAULT_CLNT_SESS) - - If ssl_ctx Is Nothing Then - Console.Error.WriteLine("Error: Client context is invalid") - Environment.Exit(1) - End If - - If private_key_file <> Nothing Then - Dim obj_type As Integer = axtls.SSL_OBJ_RSA_KEY - - If private_key_file.EndsWith(".p8") Then - obj_type = axtls.SSL_OBJ_PKCS8 - Else If (private_key_file.EndsWith(".p12")) - obj_type = axtls.SSL_OBJ_PKCS12 - End If - - If ssl_ctx.ObjLoad(obj_type, private_key_file, _ - password) <> axtls.SSL_OK Then - Console.Error.WriteLine("Error: Private key '" & _ - private_key_file & "' is undefined.") - Environment.Exit(1) - End If - End If - - For i = 0 To cert_index-1 - If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CERT, _ - cert(i), Nothing) <> axtls.SSL_OK Then - Console.WriteLine("Certificate '" & cert(i) & _ - "' is undefined.") - Environment.Exit(1) - End If - Next - - For i = 0 To ca_cert_index-1 - If ssl_ctx.ObjLoad(axtls.SSL_OBJ_X509_CACERT, _ - ca_cert(i), Nothing) <> axtls.SSL_OK Then - Console.WriteLine("Certificate '" & ca_cert(i) & _ - "' is undefined.") - Environment.Exit(1) - End If - Next - - ' Try session resumption? - If reconnect > 0 Then - While reconnect > 0 - reconnect -= 1 - ssl = ssl_ctx.Connect(client_sock, session_id) - - res = ssl.HandshakeStatus() - If res <> axtls.SSL_OK Then - If Not quiet Then - SSLUtil.DisplayError(res) - End If - - ssl.Dispose() - Environment.Exit(1) - End If - - display_session_id(ssl) - session_id = ssl.GetSessionId() - - If reconnect > 0 Then - ssl.Dispose() - client_sock.Close() - - ' and reconnect - client_sock = New Socket(AddressFamily.InterNetwork, _ - SocketType.Stream, ProtocolType.Tcp) - client_sock.Connect(ep) - End If - End While - Else - ssl = ssl_ctx.Connect(client_sock, Nothing) - End If - - ' check the return status - res = ssl.HandshakeStatus() - If res <> axtls.SSL_OK Then - If Not quiet Then - SSLUtil.DisplayError(res) - End If - - Environment.Exit(1) - End If - - If Not quiet Then - Dim common_name As String = _ - ssl.GetCertificateDN(axtls.SSL_X509_CERT_COMMON_NAME) - - If common_name <> Nothing - Console.WriteLine("Common Name:" & _ - ControlChars.Tab & ControlChars.Tab & _ - ControlChars.Tab & common_name) - End If - - display_session_id(ssl) - display_cipher(ssl) - End If - - While (1) - Dim user_input As String = Console.ReadLine() - - If user_input = Nothing Then - Exit While - End If - - Dim buf(user_input.Length+1) As Byte - buf(buf.Length-2) = Asc(ControlChars.Lf) ' add the carriage return - buf(buf.Length-1) = 0 ' null terminate - - For i = 0 To user_input.Length-1 - buf(i) = Asc(user_input.Chars(i)) - Next - - res = ssl_ctx.Write(ssl, buf, buf.Length) - If res < axtls.SSL_OK Then - If Not quiet Then - SSLUtil.DisplayError(res) - End If - - Exit While - End If - End While - - ssl_ctx.Dispose() - End Sub - - ' - ' Display what cipher we are using - ' - Private Sub display_cipher(ByVal ssl As SSL) - Console.Write("CIPHER is ") - - Select ssl.GetCipherId() - Case axtls.SSL_AES128_SHA - Console.WriteLine("AES128-SHA") - - Case axtls.SSL_AES256_SHA - Console.WriteLine("AES256-SHA") - - Case axtls.SSL_AES128_SHA256 - Console.WriteLine("AES128-SHA256") - - Case axtls.SSL_AES256_SHA256 - Console.WriteLine("AES256-SHA256") - - Case Else - Console.WriteLine("Unknown - " & ssl.GetCipherId()) - End Select - End Sub - - ' - ' Display what session id we have. - ' - Private Sub display_session_id(ByVal ssl As SSL) - Dim session_id As Byte() = ssl.GetSessionId() - - If session_id.Length > 0 Then - Console.WriteLine("-----BEGIN SSL SESSION PARAMETERS-----") - Dim b As Byte - For Each b In session_id - Console.Write("{0:x02}", b) - Next - - Console.WriteLine() - Console.WriteLine("-----END SSL SESSION PARAMETERS-----") - End If - End Sub - - ' - ' We've had some sort of command-line error. Print out the basic options. - ' - Public Sub print_options(ByVal options As String) - Console.WriteLine("axssl: Error: '" & options & _ - "' is an invalid command.") - Console.WriteLine("usage: axssl.vbnet [s_server|s_client|" & _ - "version] [args ...]") - Environment.Exit(1) - End Sub - - ' - ' We've had some sort of command-line error. Print out the server options. - ' - Private Sub print_server_options(ByVal build_mode As Integer, _ - ByVal options As String) - Dim cert_size As Integer = SSLUtil.MaxCerts() - Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() - - Console.WriteLine("unknown option " & options) - Console.WriteLine("usage: s_server [args ...]") - Console.WriteLine(" -accept arg" & ControlChars.Tab & _ - "- port to accept on (default is 4433)") - Console.WriteLine(" -quiet" & ControlChars.Tab & ControlChars.Tab & _ - "- No server output") - If build_mode >= axtls.SSL_BUILD_SERVER_ONLY - Console.WriteLine(" -cert arg" & ControlChars.Tab & _ - "- certificate file to add (in addition to default) to chain -") - Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ - " Can repeat up to " & cert_size & " times") - Console.WriteLine(" -key arg" & ControlChars.Tab & _ - "- Private key file to use") - Console.WriteLine(" -pass" & ControlChars.Tab & ControlChars.Tab & _ - "- private key file pass phrase source") - End If - - If build_mode >= axtls.SSL_BUILD_ENABLE_VERIFICATION - Console.WriteLine(" -verify" & ControlChars.Tab & _ - "- turn on peer certificate verification") - Console.WriteLine(" -CAfile arg" & ControlChars.Tab & _ - "- Certificate authority") - Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ - " Can repeat up to " & ca_cert_size & " times") - End If - - If build_mode = axtls.SSL_BUILD_FULL_MODE - Console.WriteLine(" -debug" & _ - ControlChars.Tab & ControlChars.Tab & _ - "- Print more output") - Console.WriteLine(" -state" & _ - ControlChars.Tab & ControlChars.Tab & _ - "- Show state messages") - Console.WriteLine(" -show-rsa" & _ - ControlChars.Tab & "- Show RSA state") - End If - - Environment.Exit(1) - End Sub - - ' - ' We've had some sort of command-line error. Print out the client options. - ' - Private Sub print_client_options(ByVal build_mode As Integer, _ - ByVal options As String) - Dim cert_size As Integer = SSLUtil.MaxCerts() - Dim ca_cert_size As Integer = SSLUtil.MaxCACerts() - - Console.WriteLine("unknown option " & options) - - If build_mode >= axtls.SSL_BUILD_ENABLE_CLIENT Then - Console.WriteLine("usage: s_client [args ...]") - Console.WriteLine(" -connect host:port - who to connect to " & _ - "(default is localhost:4433)") - Console.WriteLine(" -verify" & ControlChars.Tab & _ - "- turn on peer certificate verification") - Console.WriteLine(" -cert arg" & ControlChars.Tab & _ - "- certificate file to use") - Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ - " Can repeat up to " & cert_size & " times") - Console.WriteLine(" -key arg" & ControlChars.Tab & _ - "- Private key file to use") - Console.WriteLine(" -CAfile arg" & ControlChars.Tab & _ - "- Certificate authority") - Console.WriteLine(ControlChars.Tab & ControlChars.Tab & _ - " Can repeat up to " & ca_cert_size & " times") - Console.WriteLine(" -quiet" & _ - ControlChars.Tab & ControlChars.Tab & "- No client output") - Console.WriteLine(" -pass" & ControlChars.Tab & _ - ControlChars.Tab & _ - "- private key file pass phrase source") - Console.WriteLine(" -reconnect" & ControlChars.Tab & _ - "- Drop and re-make the " & _ - "connection with the same Session-ID") - - If build_mode = axtls.SSL_BUILD_FULL_MODE Then - Console.WriteLine(" -debug" & _ - ControlChars.Tab & ControlChars.Tab & _ - "- Print more output") - Console.WriteLine(" -state" & _ - ControlChars.Tab & ControlChars.Tab & _ - "- Show state messages") - Console.WriteLine(" -show-rsa" & ControlChars.Tab & _ - "- Show RSA state") - End If - Else - Console.WriteLine("Change configuration to allow this feature") - End If - - Environment.Exit(1) - End Sub - -End Class - -Public Module MyMain - Function Main(ByVal args() As String) As Integer - Dim runner As axssl = New axssl() - - If args.Length = 1 And args(0) = "version" Then - Console.WriteLine("axssl.vbnet " & SSLUtil.Version()) - Environment.Exit(0) - End If - - If args.Length < 1 - runner.print_options("") - ElseIf args(0) <> "s_server" And args(0) <> "s_client" - runner.print_options(args(0)) - End If - - Dim build_mode As Integer = SSLUtil.BuildMode() - - If args(0) = "s_server" Then - runner.do_server(build_mode, args) - Else - runner.do_client(build_mode, args) - End If - End Function -End Module diff --git a/user/mpy/lib/axtls/ssl/BigIntConfig.in b/user/mpy/lib/axtls/ssl/BigIntConfig.in deleted file mode 100644 index 116ce17..0000000 --- a/user/mpy/lib/axtls/ssl/BigIntConfig.in +++ /dev/null @@ -1,145 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see scripts/config/Kconfig-language.txt -# - -menu "BigInt Options" - depends on !CONFIG_SSL_SKELETON_MODE - -choice - prompt "Reduction Algorithm" - default CONFIG_BIGINT_BARRETT - -config CONFIG_BIGINT_CLASSICAL - bool "Classical" - help - Classical uses standard division. It has no limitations and is - theoretically the slowest due to the divisions used. For this particular - implementation it is surprisingly quite fast. - -config CONFIG_BIGINT_MONTGOMERY - bool "Montgomery" - help - Montgomery uses simple addition and multiplication to achieve its - performance. It has the limitation that 0 <= x, y < m, and so is not - used when CRT is active. - - This option will not be normally selected. - -config CONFIG_BIGINT_BARRETT - bool "Barrett" - help - Barrett performs expensive precomputation before reduction and partial - multiplies for computational speed. - - It is about 40% faster than Classical/Montgomery with the expense of - about 2kB, and so this option is normally selected. - -endchoice - -config CONFIG_BIGINT_CRT - bool "Chinese Remainder Theorem (CRT)" - default y - help - Allow the Chinese Remainder Theorem (CRT) to be used. - - Uses a number of extra coefficients from the private key to improve the - performance of a decryption. This feature is one of the most - significant performance improvements (it reduces a decryption time by - over 3 times). - - This option should be selected. - -config CONFIG_BIGINT_KARATSUBA - bool "Karatsuba Multiplication" - default n - help - Allow Karasuba multiplication to be used. - - Uses 3 multiplications (plus a number of additions/subtractions) - instead of 4. Multiplications are O(N^2) but addition/subtraction - is O(N) hence for large numbers is beneficial. For this project, the - effect was only useful for 4096 bit keys (for 32 bit processors). For - 8 bit processors this option might be a possibility. - - It costs about 2kB to enable it. - -config MUL_KARATSUBA_THRESH - int "Karatsuba Multiplication Theshold" - default 20 - depends on CONFIG_BIGINT_KARATSUBA - help - The minimum number of components needed before Karasuba muliplication - is used. - - This is very dependent on the speed/implementation of bi_add()/ - bi_subtract(). There is a bit of trial and error here and will be - at a different point for different architectures. - -config SQU_KARATSUBA_THRESH - int "Karatsuba Square Threshold" - default 40 - depends on CONFIG_BIGINT_KARATSUBA && CONFIG_BIGINT_SQUARE - help - The minimum number of components needed before Karatsuba squaring - is used. - - This is very dependent on the speed/implementation of bi_add()/ - bi_subtract(). There is a bit of trial and error here and will be - at a different point for different architectures. - -config CONFIG_BIGINT_SLIDING_WINDOW - bool "Sliding Window Exponentiation" - default y - help - Allow Sliding-Window Exponentiation to be used. - - Potentially processes more than 1 bit at a time when doing - exponentiation. The sliding-window technique reduces the number of - precomputations compared to other precomputed techniques. - - It results in a considerable performance improvement with it enabled - (it halves the decryption time) and so should be selected. - -config CONFIG_BIGINT_SQUARE - bool "Square Algorithm" - default y - help - Allow squaring to be used instead of a multiplication. It uses - 1/2 of the standard multiplies to obtain its performance. - It gives a 20% speed improvement overall and so should be selected. - -config CONFIG_BIGINT_CHECK_ON - bool "BigInt Integrity Checking" - default n if !CONFIG_DEBUG - default y if CONFIG_DEBUG - help - This is used when developing bigint algorithms. It performs a sanity - check on all operations at the expense of speed. - - This option is only selected when developing and should normally be - turned off. - -choice - prompt "Integer Size" - default CONFIG_INTEGER_32BIT - -config CONFIG_INTEGER_32BIT - bool "32" - help - The native integer size is 32 bits or higher. - - -config CONFIG_INTEGER_16BIT - bool "16" - help - The native integer size is 16 bits. - -config CONFIG_INTEGER_8BIT - bool "8" - help - The native integer size is 8 bits. - -endchoice -endmenu - diff --git a/user/mpy/lib/axtls/ssl/Config.in b/user/mpy/lib/axtls/ssl/Config.in deleted file mode 100644 index aac4144..0000000 --- a/user/mpy/lib/axtls/ssl/Config.in +++ /dev/null @@ -1,341 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see scripts/config/Kconfig-language.txt -# - -menu "SSL Library" - -choice - prompt "Mode" - default CONFIG_SSL_FULL_MODE - -config CONFIG_SSL_SERVER_ONLY - bool "Server only - no verification" - help - Enable server functionality (no client functionality). - This mode still supports sessions and chaining (which can be turned - off in configuration). - - The axssl sample runs with the minimum of features. - - This is the most space efficient of the modes with the library - about 45kB in size. Use this mode if you are doing standard SSL server - work. - -config CONFIG_SSL_CERT_VERIFICATION - bool "Server only - with verification" - help - Enable server functionality with client authentication (no client - functionality). - - The axssl sample runs with the "-verify" and "-CAfile" options. - - This mode produces a library about 49kB in size. Use this mode if you - have an SSL server which requires client authentication (which is - uncommon in browser applications). - - -config CONFIG_SSL_FULL_MODE - bool "Client/Server enabled with diagnostics" - help - Enable client/server functionality including diagnostics. Most of the - extra size in this mode is due to the storage of various strings that - are used. - - The axssl sample has 3 more options, "-debug", "-state" and "-show-rsa" - - This mode produces a library about 58kB in size. It is suggested that - this mode is used only during development, or systems that have more - generous memory limits. - - It is the default to demonstrate the features of axTLS. - -config CONFIG_SSL_SKELETON_MODE - bool "Skeleton mode - the smallest server mode" - help - This is an experiment to build the smallest library at the expense of - features and speed. - - * Server mode only. - * The AES cipher is disabled. - * No session resumption. - * No external keys/certificates are supported. - * The bigint library has most of the performance features disabled. - * Some other features/API calls may not work. - - This mode produces a library about 37kB in size. The main - disadvantage of this mode is speed - it will be much slower than the - other build modes. - -endchoice - -config CONFIG_SSL_ENABLE_SERVER - bool "Server enabled" - help - Enable server functionality. - -config CONFIG_SSL_ENABLE_CLIENT - bool "Client enabled" - help - Enable client functionality. - - The axssl sample runs with the "s_client" option enabled. - - This mode produces a library about 51kB in size. Use this mode if you - require axTLS to use SSL client functionality (the SSL server code - is always enabled). - -config CONFIG_SSL_DIAGNOSTICS - bool "Diagnostic messages" - help - Enable support for diagnostics of connection progress and state. - -choice - prompt "Protocol Preference" -# depends on !CONFIG_SSL_SKELETON_MODE - default CONFIG_SSL_PROT_MEDIUM - -config CONFIG_SSL_PROT_LOW - bool "Low" - help - Chooses the cipher in the order of AES128-SHA, AES128-SHA256, - AES256-SHA256. - - This will use the fastest cipher(s) but at the expense of security. - -config CONFIG_SSL_PROT_MEDIUM - bool "Medium" - help - Chooses the cipher in the order of AES128-SHA256, AES256-SHA256, - AES128-SHA - - This mode is a balance between speed and security and is the default. - -config CONFIG_SSL_PROT_HIGH - bool "High" - help - Chooses the cipher in the order of AES256-SHA256, AES128-SHA256, - AES128-SHA. - - This will use the strongest cipher(s) at the cost of speed. - -endchoice - -config CONFIG_SSL_AES - bool "Enable AES cipher" - default y - help - Enable/disable AES support. - -config CONFIG_SSL_USE_DEFAULT_KEY - bool "Enable default key" -# depends on !CONFIG_SSL_SKELETON_MODE - default y - help - Some applications will not require the default private key/certificate - that is built in. This is one way to save on a couple of kB's if an - external private key/certificate is used. - - The private key is in ssl/private_key.h and the certificate is in - ssl/cert.h. - - The advantage of a built-in private key/certificate is that no file - system is required for access. Both the certificate and the private - key will be automatically loaded on a ssl_ctx_new(). - - However this private key/certificate can never be changed (without a - code update). - - This mode is enabled by default. Disable this mode if the - built-in key/certificate is not used. - -config CONFIG_SSL_PRIVATE_KEY_LOCATION - string "Private key file location" - depends on !CONFIG_SSL_USE_DEFAULT_KEY && !CONFIG_SSL_SKELETON_MODE - help - The file location of the private key which will be automatically - loaded on a ssl_ctx_new(). - -config CONFIG_SSL_PRIVATE_KEY_PASSWORD - string "Private key password" - depends on !CONFIG_SSL_USE_DEFAULT_KEY && CONFIG_SSL_HAS_PEM - help - The password required to decrypt a PEM-encoded password file. - -config CONFIG_SSL_X509_CERT_LOCATION - string "X.509 certificate file location" - depends on !CONFIG_SSL_GENERATE_X509_CERT && !CONFIG_SSL_USE_DEFAULT_KEY && !CONFIG_SSL_SKELETON_MODE - help - The file location of the X.509 certificate which will be automatically - loaded on a ssl_ctx_new(). - -config CONFIG_SSL_GENERATE_X509_CERT - bool "Generate X.509 Certificate" - default n - help - An X.509 certificate can be automatically generated on a - ssl_ctx_new(). A private key still needs to be provided (the private - key in ss/private_key.h will be used unless - CONFIG_SSL_PRIVATE_KEY_LOCATION is set). - - The certificate is generated on the fly, and so a minor start-up time - penalty is to be expected. This feature adds around 5kB to the - library. - - This feature is disabled by default. - -config CONFIG_SSL_X509_COMMON_NAME - string "X.509 Common Name" - depends on CONFIG_SSL_GENERATE_X509_CERT - help - The common name for the X.509 certificate. This should be the fully - qualified domain name (FQDN), e.g. www.foo.com. - - If this is blank, then this will be value from gethostname() and - getdomainname(). - -config CONFIG_SSL_X509_ORGANIZATION_NAME - string "X.509 Organization Name" - depends on CONFIG_SSL_GENERATE_X509_CERT - help - The organization name for the generated X.509 certificate. - - This field is optional. - -config CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME - string "X.509 Organization Unit Name" - depends on CONFIG_SSL_GENERATE_X509_CERT - help - The organization unit name for the generated X.509 certificate. - - This field is optional. - -config CONFIG_SSL_HAS_PEM - bool "Enable PEM" - default n if !CONFIG_SSL_FULL_MODE - default y if CONFIG_SSL_FULL_MODE - depends on !CONFIG_SSL_SKELETON_MODE - help - Enable the use of PEM format for certificates and private keys. - - PEM is not normally needed - PEM files can be converted into DER files - quite easily. However they have the convenience of allowing multiple - certificates/keys in the same file. - - This feature will add a couple of kB to the library. - - Disable if PEM is not used (which will be in most cases). - -config CONFIG_SSL_USE_PKCS12 - bool "Use PKCS8/PKCS12" - default n if !CONFIG_SSL_FULL_MODE - default y if CONFIG_SSL_FULL_MODE - depends on !CONFIG_SSL_SKELETON_MODE - help - PKCS#12 certificates combine private keys and certificates together in - one file. - - PKCS#8 private keys are also suppported (as it is a subset of PKCS#12). - - The decryption of these certificates uses RC4-128 (and these - certificates must be encrypted using this cipher). The actual - algorithm is "PBE-SHA1-RC4-128". - - Disable if PKCS#12 is not used (which will be in most cases). - -config CONFIG_SSL_EXPIRY_TIME - int "Session expiry time (in hours)" - depends on !CONFIG_SSL_SKELETON_MODE - default 24 - help - The time (in hours) before a session expires. - - A longer time means that the expensive parts of a handshake don't - need to be run when a client reconnects later. - - The default is 1 day. - -config CONFIG_X509_MAX_CA_CERTS - int "Maximum number of certificate authorites" - default 150 -# depends on !CONFIG_SSL_SERVER_ONLY && !CONFIG_SSL_SKELETON_MODE - help - Determines the number of CA's allowed. - - Increase this figure if more trusted sites are allowed. Each - certificate adds about 300 bytes (when added). - - The default is to allow the Debian cert bundle to be parsed. - -config CONFIG_SSL_MAX_CERTS - int "Maximum number of chained certificates" - default 3 - help - Determines the number of certificates used in a certificate - chain. The chain length must be at least 1. - - Increase this figure if more certificates are to be added to the - chain. Each certificate adds about 300 bytes (when added). - - The default is to allow one certificate + 2 certificates in the chain. - -config CONFIG_SSL_CTX_MUTEXING - bool "Enable SSL_CTX mutexing" - default n - help - Normally mutexing is not required - each SSL_CTX object can deal with - many SSL objects (as long as each SSL_CTX object is using a single - thread). - - If the SSL_CTX object is not thread safe e.g. the case where a - new thread is created for each SSL object, then mutexing is required. - - Select y when a mutex on the SSL_CTX object is required. - -config CONFIG_USE_DEV_URANDOM - bool "Use /dev/urandom" - default y - depends on !CONFIG_PLATFORM_WIN32 - help - Use /dev/urandom. Otherwise a custom RNG is used. - - This will be the default on most Linux systems. - -config CONFIG_WIN32_USE_CRYPTO_LIB - bool "Use Win32 Crypto Library" - depends on CONFIG_PLATFORM_WIN32 - help - Microsoft produce a Crypto API which requires the Platform SDK to be - installed. It's used for the RNG. - - This will be the default on most Win32 systems. - -config CONFIG_OPENSSL_COMPATIBLE - bool "Enable openssl API compatibility" - default n - help - To ease the porting of openssl applications, a subset of the openssl - API is wrapped around the axTLS API. - - Note: not all the API is implemented, so parts may still break. And - it's definitely not 100% compatible. - -config CONFIG_PERFORMANCE_TESTING - bool "Build the bigint performance test tool" - default n - depends on CONFIG_SSL_CERT_VERIFICATION - help - Used for performance testing of bigint. - - This is a testing tool and is normally disabled. - -config CONFIG_SSL_TEST - bool "Build the SSL testing tool" - default n - depends on CONFIG_SSL_FULL_MODE && !CONFIG_SSL_GENERATE_X509_CERT - help - Used for sanity checking the SSL handshaking. - - This is a testing tool and is normally disabled. - -endmenu diff --git a/user/mpy/lib/axtls/ssl/Makefile b/user/mpy/lib/axtls/ssl/Makefile deleted file mode 100644 index a222884..0000000 --- a/user/mpy/lib/axtls/ssl/Makefile +++ /dev/null @@ -1,125 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -AXTLS_HOME=.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -all: libs -ifdef CONFIG_PERFORMANCE_TESTING - $(MAKE) -C test -else -ifdef CONFIG_SSL_TEST - $(MAKE) -C test -endif -endif - -ifndef CONFIG_PLATFORM_WIN32 -TARGET1=$(AXTLS_HOME)/$(STAGE)/libaxtls.a -BASETARGET=libaxtls.so -CRYPTO_PATH=$(AXTLS_HOME)/crypto/ -ifdef CONFIG_PLATFORM_CYGWIN -TARGET2=$(AXTLS_HOME)/$(STAGE)/libaxtls.dll.a -else -TARGET2=$(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) -endif - -# shared library major/minor numbers -LIBMAJOR=$(BASETARGET).1 -LIBMINOR=$(BASETARGET).1.2 -else -TARGET1=$(AXTLS_HOME)/$(STAGE)/axtls.lib -TARGET2=$(AXTLS_HOME)/$(STAGE)/axtls.dll -STATIC_LIB=$(AXTLS_HOME)/$(STAGE)/axtls.static.lib -CRYPTO_PATH=$(AXTLS_HOME)\\crypto\\ -endif - -libs: $(TARGET1) #$(TARGET2) - -CRYPTO_OBJ=\ - $(CRYPTO_PATH)aes.o \ - $(CRYPTO_PATH)bigint.o \ - $(CRYPTO_PATH)crypto_misc.o \ - $(CRYPTO_PATH)hmac.o \ - $(CRYPTO_PATH)md5.o \ - $(CRYPTO_PATH)rc4.o \ - $(CRYPTO_PATH)rsa.o \ - $(CRYPTO_PATH)sha1.o \ - $(CRYPTO_PATH)sha256.o \ - $(CRYPTO_PATH)sha384.o \ - $(CRYPTO_PATH)sha512.o - -OBJ=\ - asn1.o \ - gen_cert.o \ - loader.o \ - openssl.o \ - os_port.o \ - p12.o \ - tls1.o \ - tls1_svr.o \ - tls1_clnt.o \ - x509.o - -include $(AXTLS_HOME)/config/makefile.post - -ifndef CONFIG_PLATFORM_WIN32 # Linux/Unix/Cygwin - -$(TARGET1) : $(CRYPTO_OBJ) $(OBJ) - $(AR) -rcs $@ $(CRYPTO_OBJ) $(OBJ) - -$(TARGET2) : $(CRYPTO_OBJ) $(OBJ) -ifndef CONFIG_PLATFORM_CYGWIN - $(LD) $(LDFLAGS) $(LDSHARED) -Wl,-soname,$(LIBMAJOR) -o $(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) $(CRYPTO_OBJ) $(OBJ) - cd $(AXTLS_HOME)/$(STAGE); ln -sf $(LIBMINOR) $(LIBMAJOR); ln -sf $(LIBMAJOR) $(BASETARGET); cd - -else - $(LD) $(LDFLAGS) $(LDSHARED) -o $(AXTLS_HOME)/$(STAGE)/cygaxtls.dll \ - -Wl,--out-implib=$(AXTLS_HOME)/$(STAGE)/libaxtls.dll.a \ - -Wl,--export-all-symbols \ - -Wl,--enable-auto-import $(CRYPTO_OBJ) $(OBJ) -endif - -else # Win32 -CRYPTO_OBJ:=$(CRYPTO_OBJ:.o=.obj) - -$(TARGET1) : $(OBJ) - $(AR) /out:$@ $(CRYPTO_OBJ) $(OBJ) - -$(TARGET2) : $(OBJ) - cp $(TARGET1) $(STATIC_LIB) - $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(CRYPTO_OBJ) $(OBJ) - -endif - -clean:: - $(MAKE) -C test clean - -@rm -f $(AXTLS_HOME)/$(STAGE)/* *.a $(TARGET1) $(TARGET2) - diff --git a/user/mpy/lib/axtls/ssl/asn1.c b/user/mpy/lib/axtls/ssl/asn1.c deleted file mode 100644 index 6f85257..0000000 --- a/user/mpy/lib/axtls/ssl/asn1.c +++ /dev/null @@ -1,776 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Some primitive asn methods for extraction ASN.1 data. - */ - -#include -#include -#include -#include -#include "os_port.h" -#include "crypto.h" -#include "crypto_misc.h" - -/* 1.2.840.113549.1.1 OID prefix - handle the following */ -/* md5WithRSAEncryption(4) */ -/* sha1WithRSAEncryption(5) */ -/* sha256WithRSAEncryption (11) */ -/* sha384WithRSAEncryption (12) */ -/* sha512WithRSAEncryption (13) */ -static const uint8_t sig_oid_prefix[] = -{ - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01 -}; - -/* 1.3.14.3.2.29 SHA1 with RSA signature */ -static const uint8_t sig_sha1WithRSAEncrypt[] = -{ - 0x2b, 0x0e, 0x03, 0x02, 0x1d -}; - -/* 2.16.840.1.101.3.4.2.1 SHA-256 */ -static const uint8_t sig_sha256[] = -{ - 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 -}; - -/* 2.16.840.1.101.3.4.2.2 SHA-384 */ -static const uint8_t sig_sha384[] = -{ - 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 -}; - -/* 2.16.840.1.101.3.4.2.3 SHA-512 */ -static const uint8_t sig_sha512[] = -{ - 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 -}; - -static const uint8_t sig_subject_alt_name[] = -{ - 0x55, 0x1d, 0x11 -}; - -static const uint8_t sig_basic_constraints[] = -{ - 0x55, 0x1d, 0x13 -}; - -static const uint8_t sig_key_usage[] = -{ - 0x55, 0x1d, 0x0f -}; - -/* CN, O, OU, L, C, ST */ -static const uint8_t g_dn_types[] = { 3, 10, 11, 7, 6, 8 }; - -uint32_t get_asn1_length(const uint8_t *buf, int *offset) -{ - int i; - uint32_t len; - - if (!(buf[*offset] & 0x80)) /* short form */ - { - len = buf[(*offset)++]; - } - else /* long form */ - { - int length_bytes = buf[(*offset)++]&0x7f; - if (length_bytes > 4) /* limit number of bytes */ - return 0; - - len = 0; - for (i = 0; i < length_bytes; i++) - { - len <<= 8; - len += buf[(*offset)++]; - } - } - - return len; -} - -/** - * Skip the ASN1.1 object type and its length. Get ready to read the object's - * data. - */ -int asn1_next_obj(const uint8_t *buf, int *offset, int obj_type) -{ - if (buf[*offset] != obj_type) - return X509_NOT_OK; - - (*offset)++; - return get_asn1_length(buf, offset); -} - -/** - * Skip over an ASN.1 object type completely. Get ready to read the next - * object. - */ -int asn1_skip_obj(const uint8_t *buf, int *offset, int obj_type) -{ - int len; - - if (buf[*offset] != obj_type) - return X509_NOT_OK; - (*offset)++; - len = get_asn1_length(buf, offset); - *offset += len; - return 0; -} - -/** - * Read an integer value for ASN.1 data - * Note: This function allocates memory which must be freed by the user. - */ -int asn1_get_big_int(const uint8_t *buf, int *offset, uint8_t **object) -{ - int len; - - if ((len = asn1_next_obj(buf, offset, ASN1_INTEGER)) < 0) - goto end_big_int; - - if (len > 1 && buf[*offset] == 0x00) /* ignore the negative byte */ - { - len--; - (*offset)++; - } - - *object = (uint8_t *)malloc(len); - memcpy(*object, &buf[*offset], len); - *offset += len; - -end_big_int: - return len; -} - -/** - * Read an integer value for ASN.1 data - */ -int asn1_get_int(const uint8_t *buf, int *offset, int32_t *val) -{ - int res = X509_OK; - int len; - int i; - - if ((len = asn1_next_obj(buf, offset, ASN1_INTEGER)) < 0 || - len > sizeof(int32_t)) - { - res = X509_NOT_OK; - goto end_int; - } - - *val = 0; - for (i = 0; i < len; i++) - { - *val <<= 8; - *val |= buf[(*offset)++]; - } - -end_int: - return res; -} - -/** - * Read an boolean value for ASN.1 data - */ -int asn1_get_bool(const uint8_t *buf, int *offset, bool *val) -{ - int res = X509_OK; - - if (asn1_next_obj(buf, offset, ASN1_BOOLEAN) != 1) - { - res = X509_NOT_OK; - goto end_bool; - } - - /* DER demands that "If the encoding represents the boolean value TRUE, - its single contents octet shall have all eight bits set to one." - Thus only 0 and 255 are valid encoded values. */ - *val = buf[(*offset)++] == 0xFF; - -end_bool: - return res; -} - -/** - * Convert an ASN.1 bit string into a 32 bit integer. Used for key usage - */ -int asn1_get_bit_string_as_int(const uint8_t *buf, int *offset, uint32_t *val) -{ - int res = X509_OK; - int len, i; - - if ((len = asn1_next_obj(buf, offset, ASN1_BIT_STRING)) < 0 || len > 5) - { - res = X509_NOT_OK; - goto end_bit_string_as_int; - } - - /* number of bits left unused in the final byte of content */ - (*offset)++; - len--; - *val = 0; - - /* not sure why key usage doesn't used proper DER spec version */ - for (i = len-1; i >= 0; --i) - { - *val <<= 8; - *val |= buf[(*offset) + i]; - } - - *offset += len; - -end_bit_string_as_int: - return res; -} - -/** - * Get all the RSA private key specifics from an ASN.1 encoded file - */ -int asn1_get_private_key(const uint8_t *buf, int len, RSA_CTX **rsa_ctx) -{ - int offset = 7; - uint8_t *modulus = NULL, *priv_exp = NULL, *pub_exp = NULL; - int mod_len, priv_len, pub_len; -#ifdef CONFIG_BIGINT_CRT - uint8_t *p = NULL, *q = NULL, *dP = NULL, *dQ = NULL, *qInv = NULL; - int p_len, q_len, dP_len, dQ_len, qInv_len; -#endif - - /* not in der format */ - if (buf[0] != ASN1_SEQUENCE) /* basic sanity check */ - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: This is not a valid ASN.1 file\n"); -#endif - return X509_INVALID_PRIV_KEY; - } - - /* Use the private key to mix up the RNG if possible. */ - RNG_custom_init(buf, len); - - mod_len = asn1_get_big_int(buf, &offset, &modulus); - pub_len = asn1_get_big_int(buf, &offset, &pub_exp); - priv_len = asn1_get_big_int(buf, &offset, &priv_exp); - - if (mod_len <= 0 || pub_len <= 0 || priv_len <= 0) - return X509_INVALID_PRIV_KEY; - -#ifdef CONFIG_BIGINT_CRT - p_len = asn1_get_big_int(buf, &offset, &p); - q_len = asn1_get_big_int(buf, &offset, &q); - dP_len = asn1_get_big_int(buf, &offset, &dP); - dQ_len = asn1_get_big_int(buf, &offset, &dQ); - qInv_len = asn1_get_big_int(buf, &offset, &qInv); - - if (p_len <= 0 || q_len <= 0 || dP_len <= 0 || dQ_len <= 0 || qInv_len <= 0) - return X509_INVALID_PRIV_KEY; - - RSA_priv_key_new(rsa_ctx, - modulus, mod_len, pub_exp, pub_len, priv_exp, priv_len, - p, p_len, q, p_len, dP, dP_len, dQ, dQ_len, qInv, qInv_len); - - free(p); - free(q); - free(dP); - free(dQ); - free(qInv); -#else - RSA_priv_key_new(rsa_ctx, - modulus, mod_len, pub_exp, pub_len, priv_exp, priv_len); -#endif - - free(modulus); - free(priv_exp); - free(pub_exp); - return X509_OK; -} - -/** - * Get the time of a certificate. Ignore hours/minutes/seconds. - */ -static int asn1_get_utc_time(const uint8_t *buf, int *offset, time_t *t) -{ - int ret = X509_NOT_OK, len, t_offset, abs_year; - struct tm tm; - - /* see http://tools.ietf.org/html/rfc5280#section-4.1.2.5 */ - if (buf[*offset] == ASN1_UTC_TIME) - { - (*offset)++; - - len = get_asn1_length(buf, offset); - t_offset = *offset; - - memset(&tm, 0, sizeof(struct tm)); - tm.tm_year = (buf[t_offset] - '0')*10 + (buf[t_offset+1] - '0'); - - if (tm.tm_year < 50) /* 1951-2050 thing */ - { - tm.tm_year += 100; - } - - tm.tm_mon = (buf[t_offset+2] - '0')*10 + (buf[t_offset+3] - '0') - 1; - tm.tm_mday = (buf[t_offset+4] - '0')*10 + (buf[t_offset+5] - '0'); - tm.tm_hour = (buf[t_offset+6] - '0')*10 + (buf[t_offset+7] - '0'); - tm.tm_min = (buf[t_offset+8] - '0')*10 + (buf[t_offset+9] - '0'); - tm.tm_sec = (buf[t_offset+10] - '0')*10 + (buf[t_offset+11] - '0'); - *t = mktime(&tm); - *offset += len; - ret = X509_OK; - } - else if (buf[*offset] == ASN1_GENERALIZED_TIME) - { - (*offset)++; - - len = get_asn1_length(buf, offset); - t_offset = *offset; - - memset(&tm, 0, sizeof(struct tm)); - abs_year = ((buf[t_offset] - '0')*1000 + - (buf[t_offset+1] - '0')*100 + (buf[t_offset+2] - '0')*10 + - (buf[t_offset+3] - '0')); - - if (abs_year <= 1901) - { - tm.tm_year = 1; - tm.tm_mon = 0; - tm.tm_mday = 1; - } - else - { - tm.tm_year = abs_year - 1900; - tm.tm_mon = (buf[t_offset+4] - '0')*10 + - (buf[t_offset+5] - '0') - 1; - tm.tm_mday = (buf[t_offset+6] - '0')*10 + (buf[t_offset+7] - '0'); - tm.tm_hour = (buf[t_offset+8] - '0')*10 + (buf[t_offset+9] - '0'); - tm.tm_min = (buf[t_offset+10] - '0')*10 + (buf[t_offset+11] - '0'); - tm.tm_sec = (buf[t_offset+12] - '0')*10 + (buf[t_offset+13] - '0'); - *t = mktime(&tm); - } - - *offset += len; - ret = X509_OK; - } - - return ret; -} - -/** - * Get the version type of a certificate - */ -int asn1_version(const uint8_t *cert, int *offset, int *val) -{ - (*offset) += 2; /* get past explicit tag */ - return asn1_get_int(cert, offset, val); -} - -/** - * Retrieve the notbefore and notafter certificate times. - */ -int asn1_validity(const uint8_t *cert, int *offset, X509_CTX *x509_ctx) -{ - return (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0 || - asn1_get_utc_time(cert, offset, &x509_ctx->not_before) || - asn1_get_utc_time(cert, offset, &x509_ctx->not_after)); -} - -/** - * Get the components of a distinguished name - */ -static int asn1_get_oid_x520(const uint8_t *buf, int *offset) -{ - int dn_type = 0; - int len; - - if ((len = asn1_next_obj(buf, offset, ASN1_OID)) < 0) - goto end_oid; - - /* expect a sequence of 2.5.4.[x] where x is a one of distinguished name - components we are interested in. */ - if (len == 3 && buf[(*offset)++] == 0x55 && buf[(*offset)++] == 0x04) - dn_type = buf[(*offset)++]; - else - { - *offset += len; /* skip over it */ - } - -end_oid: - return dn_type; -} - -/** - * Obtain an ASN.1 printable string type. - */ -static int asn1_get_printable_str(const uint8_t *buf, int *offset, char **str) -{ - int len = X509_NOT_OK; - int asn1_type = buf[*offset]; - - /* some certs have this awful crud in them for some reason */ - if (asn1_type != ASN1_PRINTABLE_STR && - asn1_type != ASN1_PRINTABLE_STR2 && - asn1_type != ASN1_TELETEX_STR && - asn1_type != ASN1_IA5_STR && - asn1_type != ASN1_UNICODE_STR) - goto end_pnt_str; - - (*offset)++; - len = get_asn1_length(buf, offset); - - if (asn1_type == ASN1_UNICODE_STR) - { - int i; - *str = (char *)malloc(len/2+1); /* allow for null */ - - for (i = 0; i < len; i += 2) - (*str)[i/2] = buf[*offset + i + 1]; - - (*str)[len/2] = 0; /* null terminate */ - } - else - { - *str = (char *)malloc(len+1); /* allow for null */ - memcpy(*str, &buf[*offset], len); - (*str)[len] = 0; /* null terminate */ - } - - *offset += len; - -end_pnt_str: - return len; -} - -/** - * Get the subject name (or the issuer) of a certificate. - */ -int asn1_name(const uint8_t *cert, int *offset, char *dn[]) -{ - int ret = X509_NOT_OK; - int dn_type; - char *tmp; - - if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0) - goto end_name; - - while (asn1_next_obj(cert, offset, ASN1_SET) >= 0) - { - int i, found = 0; - - if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0 || - (dn_type = asn1_get_oid_x520(cert, offset)) < 0) - goto end_name; - - tmp = NULL; - - if (asn1_get_printable_str(cert, offset, &tmp) < 0) - { - free(tmp); - goto end_name; - } - - /* find the distinguished named type */ - for (i = 0; i < X509_NUM_DN_TYPES; i++) - { - if (dn_type == g_dn_types[i]) - { - if (dn[i] == NULL) - { - dn[i] = tmp; - found = 1; - break; - } - } - } - - if (found == 0) /* not found so get rid of it */ - { - free(tmp); - } - } - - ret = X509_OK; -end_name: - return ret; -} - -/** - * Read the modulus and public exponent of a certificate. - */ -int asn1_public_key(const uint8_t *cert, int *offset, X509_CTX *x509_ctx) -{ - int ret = X509_NOT_OK, mod_len, pub_len; - uint8_t *modulus = NULL, *pub_exp = NULL; - - if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(cert, offset, ASN1_SEQUENCE) || - asn1_next_obj(cert, offset, ASN1_BIT_STRING) < 0) - goto end_pub_key; - - (*offset)++; /* ignore the padding bit field */ - - if (asn1_next_obj(cert, offset, ASN1_SEQUENCE) < 0) - goto end_pub_key; - - mod_len = asn1_get_big_int(cert, offset, &modulus); - pub_len = asn1_get_big_int(cert, offset, &pub_exp); - - RSA_pub_key_new(&x509_ctx->rsa_ctx, modulus, mod_len, pub_exp, pub_len); - - free(modulus); - free(pub_exp); - ret = X509_OK; - -end_pub_key: - return ret; -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION -/** - * Read the signature of the certificate. - */ -int asn1_signature(const uint8_t *cert, int *offset, X509_CTX *x509_ctx) -{ - int ret = X509_NOT_OK; - - if (cert[(*offset)++] != ASN1_BIT_STRING) - goto end_sig; - - x509_ctx->sig_len = get_asn1_length(cert, offset)-1; - (*offset)++; /* ignore bit string padding bits */ - x509_ctx->signature = (uint8_t *)malloc(x509_ctx->sig_len); - memcpy(x509_ctx->signature, &cert[*offset], x509_ctx->sig_len); - *offset += x509_ctx->sig_len; - ret = X509_OK; - -end_sig: - return ret; -} - -/* - * Compare 2 distinguished name components for equality - * @return 0 if a match - */ -static int asn1_compare_dn_comp(const char *dn1, const char *dn2) -{ - int ret; - - if (dn1 == NULL && dn2 == NULL) - ret = 0; - else - ret = (dn1 && dn2) ? strcmp(dn1, dn2) : 1; - - return ret; -} - -/** - * Clean up all of the CA certificates. - */ -void remove_ca_certs(CA_CERT_CTX *ca_cert_ctx) -{ - int i = 0; - - if (ca_cert_ctx == NULL) - return; - - while (i < CONFIG_X509_MAX_CA_CERTS && ca_cert_ctx->cert[i]) - { - x509_free(ca_cert_ctx->cert[i]); - ca_cert_ctx->cert[i++] = NULL; - } - - free(ca_cert_ctx); -} - -/* - * Compare 2 distinguished names for equality - * @return 0 if a match - */ -int asn1_compare_dn(char * const dn1[], char * const dn2[]) -{ - int i; - - for (i = 0; i < X509_NUM_DN_TYPES; i++) - { - if (asn1_compare_dn_comp(dn1[i], dn2[i])) - return 1; - } - - return 0; /* all good */ -} - -int asn1_find_oid(const uint8_t* cert, int* offset, - const uint8_t* oid, int oid_length) -{ - int seqlen; - if ((seqlen = asn1_next_obj(cert, offset, ASN1_SEQUENCE))> 0) - { - int end = *offset + seqlen; - - while (*offset < end) - { - int type = cert[(*offset)++]; - int length = get_asn1_length(cert, offset); - int noffset = *offset + length; - - if (type == ASN1_SEQUENCE) - { - type = cert[(*offset)++]; - length = get_asn1_length(cert, offset); - - if (type == ASN1_OID && length == oid_length && - memcmp(cert + *offset, oid, oid_length) == 0) - { - *offset += oid_length; - return 1; - } - } - - *offset = noffset; - } - } - - return 0; -} - -int asn1_is_subject_alt_name(const uint8_t *cert, int offset) -{ - if (asn1_find_oid(cert, &offset, sig_subject_alt_name, - sizeof(sig_subject_alt_name))) - { - return offset; - } - - return 0; -} - -int asn1_is_basic_constraints(const uint8_t *cert, int offset) -{ - if (asn1_find_oid(cert, &offset, sig_basic_constraints, - sizeof(sig_basic_constraints))) - { - return offset; - } - - return 0; -} - -int asn1_is_key_usage(const uint8_t *cert, int offset) -{ - if (asn1_find_oid(cert, &offset, sig_key_usage, - sizeof(sig_key_usage))) - { - return offset; - } - - return 0; -} - -bool asn1_is_critical_ext(const uint8_t *buf, int *offset) -{ - /* critical is optional */ - bool res = false; - - if (asn1_next_obj(buf, offset, ASN1_BOOLEAN) == 1) - res = buf[(*offset)++] == 0xFF; - - return res; -} - -#endif /* CONFIG_SSL_CERT_VERIFICATION */ - -/** - * Read the signature type of the certificate. We only support RSA-MD5 and - * RSA-SHA1 signature types. - */ -int asn1_signature_type(const uint8_t *cert, - int *offset, X509_CTX *x509_ctx) -{ - int ret = X509_NOT_OK, len; - - if (cert[(*offset)++] != ASN1_OID) - goto end_check_sig; - - len = get_asn1_length(cert, offset); - - if (len == sizeof(sig_sha1WithRSAEncrypt) && - memcmp(sig_sha1WithRSAEncrypt, &cert[*offset], - sizeof(sig_sha1WithRSAEncrypt)) == 0) - { - x509_ctx->sig_type = SIG_TYPE_SHA1; - } - else if (len == sizeof(sig_sha256) && - memcmp(sig_sha256, &cert[*offset], - sizeof(sig_sha256)) == 0) - { - x509_ctx->sig_type = SIG_TYPE_SHA256; - } - else if (len == sizeof(sig_sha384) && - memcmp(sig_sha384, &cert[*offset], - sizeof(sig_sha384)) == 0) - { - x509_ctx->sig_type = SIG_TYPE_SHA384; - } - else if (len == sizeof(sig_sha512) && - memcmp(sig_sha512, &cert[*offset], - sizeof(sig_sha512)) == 0) - { - x509_ctx->sig_type = SIG_TYPE_SHA512; - } - else - { - if (memcmp(sig_oid_prefix, &cert[*offset], sizeof(sig_oid_prefix))) - { -#ifdef CONFIG_SSL_FULL_MODE - int i; - printf("invalid digest: "); - - for (i = 0; i < len; i++) - printf("%02x ", cert[*offset + i]); - - printf("\n"); -#endif - goto end_check_sig; /* unrecognised cert type */ - } - - x509_ctx->sig_type = cert[*offset + sizeof(sig_oid_prefix)]; - } - - *offset += len; - asn1_skip_obj(cert, offset, ASN1_NULL); /* if it's there */ - ret = X509_OK; - -end_check_sig: - return ret; -} - diff --git a/user/mpy/lib/axtls/ssl/cert.h b/user/mpy/lib/axtls/ssl/cert.h deleted file mode 100644 index 40234b9..0000000 --- a/user/mpy/lib/axtls/ssl/cert.h +++ /dev/null @@ -1,54 +0,0 @@ -unsigned char default_certificate[] = { - 0x30, 0x82, 0x02, 0x58, 0x30, 0x82, 0x01, 0x40, 0x02, 0x09, 0x00, 0xa5, - 0x2a, 0xc8, 0x78, 0x87, 0xf2, 0xe7, 0xc5, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x34, - 0x31, 0x32, 0x30, 0x30, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x29, 0x61, - 0x78, 0x54, 0x4c, 0x53, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x20, 0x44, 0x6f, 0x64, 0x67, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x31, 0x32, - 0x33, 0x30, 0x32, 0x31, 0x30, 0x34, 0x32, 0x37, 0x5a, 0x17, 0x0d, 0x33, - 0x30, 0x30, 0x39, 0x30, 0x38, 0x32, 0x31, 0x30, 0x34, 0x32, 0x37, 0x5a, - 0x30, 0x2c, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x0d, 0x61, 0x78, 0x54, 0x4c, 0x53, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, - 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x81, - 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, - 0x81, 0x81, 0x00, 0xbd, 0x0f, 0xd4, 0x42, 0xa8, 0x74, 0x87, 0x54, 0xaa, - 0xb9, 0x3a, 0x1f, 0x8b, 0xce, 0xbd, 0xb7, 0x65, 0xfb, 0x40, 0x3d, 0xd0, - 0x11, 0x9a, 0x9c, 0xdc, 0x82, 0x7c, 0xea, 0xa8, 0x17, 0xe1, 0x74, 0xf3, - 0x05, 0x0e, 0x61, 0xc1, 0xc1, 0x78, 0x8a, 0xb2, 0xba, 0x15, 0x22, 0x5a, - 0xff, 0x9b, 0xb8, 0x7a, 0x2e, 0x0f, 0x88, 0xb7, 0x74, 0xde, 0x04, 0x99, - 0xa5, 0xa2, 0x99, 0x53, 0x8b, 0xad, 0x78, 0x5a, 0x31, 0xed, 0xbc, 0x01, - 0xe7, 0xdf, 0xe9, 0xec, 0x2f, 0xa0, 0x5d, 0x53, 0xf6, 0xe6, 0x8a, 0xa0, - 0xc8, 0x6d, 0x41, 0x45, 0x63, 0x23, 0xb3, 0xcf, 0x4e, 0x50, 0x1f, 0x28, - 0xdf, 0x36, 0xe2, 0x73, 0xdf, 0xd6, 0xa1, 0xb3, 0x46, 0x4f, 0x6e, 0xbb, - 0x0d, 0x9b, 0xef, 0xa8, 0xf9, 0x4c, 0xa5, 0x71, 0xa1, 0x88, 0xdd, 0x07, - 0xa9, 0x86, 0x0d, 0x3f, 0xcd, 0x99, 0x23, 0xa2, 0x84, 0x77, 0x0f, 0x02, - 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0x32, 0xe0, 0x3c, 0x6e, 0x21, 0xe6, 0xa6, 0xf4, 0xb8, 0x10, 0x9f, 0x8a, - 0xe6, 0x0b, 0x84, 0x4e, 0x2c, 0xe5, 0x14, 0xca, 0x56, 0x81, 0x3f, 0xc0, - 0x2c, 0xa3, 0x39, 0x89, 0x24, 0xce, 0xaf, 0x47, 0x2e, 0x19, 0x62, 0xb2, - 0xe4, 0x76, 0x91, 0x25, 0xbc, 0xe1, 0xa8, 0xee, 0x6a, 0x68, 0x3a, 0x77, - 0xb9, 0xb2, 0x62, 0x97, 0x0c, 0x25, 0x3c, 0x5e, 0x13, 0x48, 0x87, 0x80, - 0xa3, 0x91, 0xd9, 0x2e, 0xe6, 0x92, 0x2b, 0x1c, 0x52, 0x24, 0xb1, 0x77, - 0xc6, 0xf6, 0xde, 0xd8, 0x9b, 0xd9, 0x57, 0x37, 0x56, 0x68, 0x17, 0x32, - 0x66, 0x01, 0x08, 0x38, 0x08, 0x9a, 0xc1, 0x8c, 0x5e, 0x3f, 0xe7, 0xc9, - 0x44, 0xcb, 0x62, 0xb9, 0x48, 0xc7, 0x89, 0xa6, 0xff, 0x8e, 0x7d, 0x3d, - 0xe1, 0x46, 0x32, 0x9c, 0x13, 0x06, 0x9a, 0xd1, 0x17, 0xab, 0x3f, 0xa9, - 0x90, 0x04, 0x33, 0x2d, 0x3f, 0x81, 0x0a, 0xa5, 0x55, 0xce, 0xb6, 0x95, - 0x54, 0xad, 0xf1, 0x4f, 0xa2, 0xca, 0xc3, 0xf6, 0x25, 0x7b, 0x71, 0xd2, - 0x68, 0x85, 0xe9, 0x72, 0xb6, 0x99, 0x34, 0x6d, 0xe5, 0x5f, 0xf6, 0x74, - 0x1c, 0xb9, 0xa2, 0xda, 0x2b, 0x04, 0xff, 0x82, 0xc5, 0x09, 0x04, 0xc4, - 0xba, 0xbc, 0x82, 0x3e, 0xb4, 0x72, 0x18, 0x8e, 0x30, 0x68, 0x48, 0x4a, - 0x0d, 0xa7, 0x3d, 0xb5, 0xf4, 0x42, 0x3a, 0x97, 0x60, 0x7d, 0xa8, 0x61, - 0x8a, 0x9e, 0x98, 0xc4, 0x7e, 0x65, 0x99, 0xea, 0x7e, 0xca, 0x75, 0xe7, - 0xdb, 0x21, 0x5d, 0xce, 0x7c, 0x66, 0x3d, 0x7e, 0xdc, 0x14, 0xfe, 0x55, - 0x04, 0x97, 0xa8, 0x64, 0x12, 0xb4, 0xb5, 0x30, 0x48, 0x72, 0xbc, 0xdb, - 0xeb, 0x5b, 0x4f, 0xa6, 0xfb, 0x87, 0x01, 0x41, 0x91, 0xec, 0x98, 0x98, - 0xf1, 0x4b, 0x38, 0xa2, 0x40, 0xf1, 0x05, 0x90, 0xbb, 0x9b, 0x5d, 0x96, - 0xb1, 0x22, 0x6b, 0x50 -}; -unsigned int default_certificate_len = 604; diff --git a/user/mpy/lib/axtls/ssl/crypto_misc.h b/user/mpy/lib/axtls/ssl/crypto_misc.h deleted file mode 100644 index 21b59cb..0000000 --- a/user/mpy/lib/axtls/ssl/crypto_misc.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 2007-2017, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** - * @file crypto_misc.h - */ - -#ifndef HEADER_CRYPTO_MISC_H -#define HEADER_CRYPTO_MISC_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "crypto.h" -#include "bigint.h" - -/************************************************************************** - * X509 declarations - **************************************************************************/ -#define X509_OK 0 -#define X509_NOT_OK -1 -#define X509_VFY_ERROR_NO_TRUSTED_CERT -2 -#define X509_VFY_ERROR_BAD_SIGNATURE -3 -#define X509_VFY_ERROR_NOT_YET_VALID -4 -#define X509_VFY_ERROR_EXPIRED -5 -#define X509_VFY_ERROR_SELF_SIGNED -6 -#define X509_VFY_ERROR_INVALID_CHAIN -7 -#define X509_VFY_ERROR_UNSUPPORTED_DIGEST -8 -#define X509_INVALID_PRIV_KEY -9 -#define X509_MAX_CERTS -10 -#define X509_VFY_ERROR_BASIC_CONSTRAINT -11 - -/* - * The Distinguished Name - */ -#define X509_NUM_DN_TYPES 6 -#define X509_COMMON_NAME 0 -#define X509_ORGANIZATION 1 -#define X509_ORGANIZATIONAL_UNIT 2 -#define X509_LOCATION 3 -#define X509_COUNTRY 4 -#define X509_STATE 5 - -/* - * Key Usage bits - */ -#define IS_SET_KEY_USAGE_FLAG(A, B) (A->key_usage & B) - -#define KEY_USAGE_DIGITAL_SIGNATURE 0x0080 -#define KEY_USAGE_NON_REPUDIATION 0x0040 -#define KEY_USAGE_KEY_ENCIPHERMENT 0x0020 -#define KEY_USAGE_DATA_ENCIPHERMENT 0x0010 -#define KEY_USAGE_KEY_AGREEMENT 0x0008 -#define KEY_USAGE_KEY_CERT_SIGN 0x0004 -#define KEY_USAGE_CRL_SIGN 0x0002 -#define KEY_USAGE_ENCIPHER_ONLY 0x0001 -#define KEY_USAGE_DECIPHER_ONLY 0x8000 - -struct _x509_ctx -{ - char *ca_cert_dn[X509_NUM_DN_TYPES]; - char *cert_dn[X509_NUM_DN_TYPES]; - char **subject_alt_dnsnames; - time_t not_before; - time_t not_after; - uint8_t *signature; - RSA_CTX *rsa_ctx; - bigint *digest; - uint16_t sig_len; - uint8_t sig_type; - bool basic_constraint_present; - bool basic_constraint_is_critical; - bool key_usage_present; - bool key_usage_is_critical; - bool subject_alt_name_present; - bool subject_alt_name_is_critical; - bool basic_constraint_cA; - int basic_constraint_pathLenConstraint; - uint32_t key_usage; - struct _x509_ctx *next; -}; - -typedef struct _x509_ctx X509_CTX; - -//#ifdef CONFIG_SSL_CERT_VERIFICATION -typedef struct -{ - X509_CTX *cert[CONFIG_X509_MAX_CA_CERTS]; -} CA_CERT_CTX; -//#endif - -int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx); -void x509_free(X509_CTX *x509_ctx); -//#ifdef CONFIG_SSL_CERT_VERIFICATION -int x509_verify(const CA_CERT_CTX *ca_cert_ctx, const X509_CTX *cert, - int *pathLenConstraint); -//#endif -//#ifdef CONFIG_SSL_FULL_MODE -void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx); -const char * x509_display_error(int error); -//#endif - -/************************************************************************** - * ASN1 declarations - **************************************************************************/ -#define ASN1_BOOLEAN 0x01 -#define ASN1_INTEGER 0x02 -#define ASN1_BIT_STRING 0x03 -#define ASN1_OCTET_STRING 0x04 -#define ASN1_NULL 0x05 -#define ASN1_PRINTABLE_STR2 0x0C -#define ASN1_OID 0x06 -#define ASN1_PRINTABLE_STR2 0x0C -#define ASN1_PRINTABLE_STR 0x13 -#define ASN1_TELETEX_STR 0x14 -#define ASN1_IA5_STR 0x16 -#define ASN1_UTC_TIME 0x17 -#define ASN1_GENERALIZED_TIME 0x18 -#define ASN1_UNICODE_STR 0x1e -#define ASN1_SEQUENCE 0x30 -#define ASN1_CONTEXT_DNSNAME 0x82 -#define ASN1_SET 0x31 -#define ASN1_V3_DATA 0xa3 -#define ASN1_IMPLICIT_TAG 0x80 -#define ASN1_CONTEXT_DNSNAME 0x82 -#define ASN1_EXPLICIT_TAG 0xa0 -#define ASN1_V3_DATA 0xa3 - -#define SIG_TYPE_MD5 0x04 -#define SIG_TYPE_SHA1 0x05 -#define SIG_TYPE_SHA256 0x0b -#define SIG_TYPE_SHA384 0x0c -#define SIG_TYPE_SHA512 0x0d - -uint32_t get_asn1_length(const uint8_t *buf, int *offset); -int asn1_get_private_key(const uint8_t *buf, int len, RSA_CTX **rsa_ctx); -int asn1_next_obj(const uint8_t *buf, int *offset, int obj_type); -int asn1_skip_obj(const uint8_t *buf, int *offset, int obj_type); -int asn1_get_big_int(const uint8_t *buf, int *offset, uint8_t **object); -int asn1_get_int(const uint8_t *buf, int *offset, int32_t *val); -int asn1_get_bool(const uint8_t *buf, int *offset, bool *val); -int asn1_get_bit_string_as_int(const uint8_t *buf, int *offset, uint32_t *val); -int asn1_version(const uint8_t *cert, int *offset, int *val); -int asn1_validity(const uint8_t *cert, int *offset, X509_CTX *x509_ctx); -int asn1_name(const uint8_t *cert, int *offset, char *dn[]); -int asn1_public_key(const uint8_t *cert, int *offset, X509_CTX *x509_ctx); -#ifdef CONFIG_SSL_CERT_VERIFICATION -int asn1_signature(const uint8_t *cert, int *offset, X509_CTX *x509_ctx); -int asn1_compare_dn(char * const dn1[], char * const dn2[]); -int asn1_is_subject_alt_name(const uint8_t *cert, int offset); -int asn1_is_basic_constraints(const uint8_t *cert, int offset); -int asn1_is_key_usage(const uint8_t *cert, int offset); -bool asn1_is_critical_ext(const uint8_t *buf, int *offset); -#endif /* CONFIG_SSL_CERT_VERIFICATION */ -int asn1_signature_type(const uint8_t *cert, - int *offset, X509_CTX *x509_ctx); - -/************************************************************************** - * MISC declarations - **************************************************************************/ -#define SALT_SIZE 8 - -extern const char * const unsupported_str; - -typedef void (*crypt_func)(void *, const uint8_t *, uint8_t *, int); -typedef void (*hmac_func)(const uint8_t *msg, int length, const uint8_t *key, - int key_len, uint8_t *digest); - -int get_file(const char *filename, uint8_t **buf); - -#if defined(CONFIG_SSL_DIAGNOSTICS) || defined(WIN32) || defined(CONFIG_DEBUG) -EXP_FUNC void STDCALL print_blob(const char *format, const uint8_t *data, int size, ...); -#else - #define print_blob(...) -#endif - -EXP_FUNC int STDCALL base64_decode(const char *in, int len, - uint8_t *out, int *outlen); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/axtls/ssl/gen_cert.c b/user/mpy/lib/axtls/ssl/gen_cert.c deleted file mode 100644 index 17ad38e..0000000 --- a/user/mpy/lib/axtls/ssl/gen_cert.c +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (c) 2007-2014, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#ifdef CONFIG_SSL_GENERATE_X509_CERT -#include -#include -#include "os_port.h" -#include "ssl.h" - -/** - * Generate a basic X.509 certificate - */ - -static uint8_t set_gen_length(int len, uint8_t *buf, int *offset) -{ - if (len < 0x80) /* short form */ - { - buf[(*offset)++] = len; - return 1; - } - else /* long form */ - { - int i, length_bytes = 0; - - if (len & 0x00FF0000) - length_bytes = 3; - else if (len & 0x0000FF00) - length_bytes = 2; - else if (len & 0x000000FF) - length_bytes = 1; - - buf[(*offset)++] = 0x80 + length_bytes; - - for (i = length_bytes-1; i >= 0; i--) - { - buf[*offset+i] = len & 0xFF; - len >>= 8; - } - - *offset += length_bytes; - return length_bytes+1; - } -} - -static int pre_adjust_with_size(uint8_t type, - int *seq_offset, uint8_t *buf, int *offset) -{ - buf[(*offset)++] = type; - *seq_offset = *offset; - *offset += 4; /* fill in later */ - return *offset; -} - -static void adjust_with_size(int seq_size, int seq_start, - uint8_t *buf, int *offset) -{ - uint8_t seq_byte_size; - int orig_seq_size = seq_size; - int orig_seq_start = seq_start; - - seq_size = *offset-seq_size; - seq_byte_size = set_gen_length(seq_size, buf, &seq_start); - - if (seq_byte_size != 4) - { - memmove(&buf[orig_seq_start+seq_byte_size], - &buf[orig_seq_size], seq_size); - *offset -= 4-seq_byte_size; - } -} - -static void gen_serial_number(uint8_t *buf, int *offset) -{ - static const uint8_t ser_oid[] = { ASN1_INTEGER, 1, 0x7F }; - memcpy(&buf[*offset], ser_oid , sizeof(ser_oid)); - *offset += sizeof(ser_oid); -} - -static void gen_signature_alg(uint8_t *buf, int *offset) -{ - /* OBJECT IDENTIFIER sha1withRSAEncryption (1 2 840 113549 1 1 5) */ - static const uint8_t sig_oid[] = - { - ASN1_SEQUENCE, 0x0d, ASN1_OID, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - ASN1_NULL, 0x00 - }; - - memcpy(&buf[*offset], sig_oid, sizeof(sig_oid)); - *offset += sizeof(sig_oid); -} - -static int gen_dn(const char *name, uint8_t dn_type, - uint8_t *buf, int *offset) -{ - int ret = X509_OK; - int name_size = strlen(name); - - if (name_size > 0x70) /* just too big */ - { - ret = X509_NOT_OK; - goto error; - } - - buf[(*offset)++] = ASN1_SET; - set_gen_length(9+name_size, buf, offset); - buf[(*offset)++] = ASN1_SEQUENCE; - set_gen_length(7+name_size, buf, offset); - buf[(*offset)++] = ASN1_OID; - buf[(*offset)++] = 3; - buf[(*offset)++] = 0x55; - buf[(*offset)++] = 0x04; - buf[(*offset)++] = dn_type; - buf[(*offset)++] = ASN1_PRINTABLE_STR; - buf[(*offset)++] = name_size; - strcpy((char *)&buf[*offset], name); - *offset += name_size; - -error: - return ret; -} - -static int gen_issuer(const char * dn[], uint8_t *buf, int *offset) -{ - int ret = X509_OK; - int seq_offset; - int seq_size = pre_adjust_with_size( - ASN1_SEQUENCE, &seq_offset, buf, offset); - char fqdn[128]; - - /* we need the common name, so if not configured, work out the fully - * qualified domain name */ - if (dn[X509_COMMON_NAME] == NULL || strlen(dn[X509_COMMON_NAME]) == 0) - { - int fqdn_len; - gethostname(fqdn, sizeof(fqdn)); - fqdn_len = strlen(fqdn); - fqdn[fqdn_len++] = '.'; - - if (getdomainname(&fqdn[fqdn_len], sizeof(fqdn)-fqdn_len) < 0) - { - ret = X509_NOT_OK; - goto error; - } - - fqdn_len = strlen(fqdn); - - if (fqdn[fqdn_len-1] == '.') /* ensure '.' is not last char */ - fqdn[fqdn_len-1] = 0; - - dn[X509_COMMON_NAME] = fqdn; - } - - if ((ret = gen_dn(dn[X509_COMMON_NAME], 3, buf, offset))) - goto error; - - if (dn[X509_ORGANIZATION] != NULL && strlen(dn[X509_ORGANIZATION]) > 0) - { - if ((ret = gen_dn(dn[X509_ORGANIZATION], 10, buf, offset))) - goto error; - } - - if (dn[X509_ORGANIZATIONAL_UNIT] != NULL && - strlen(dn[X509_ORGANIZATIONAL_UNIT]) > 0) - { - if ((ret = gen_dn(dn[X509_ORGANIZATIONAL_UNIT], 11, buf, offset))) - goto error; - } - - adjust_with_size(seq_size, seq_offset, buf, offset); - -error: - return ret; -} - -static void gen_utc_time(uint8_t *buf, int *offset) -{ - static const uint8_t time_seq[] = - { - ASN1_SEQUENCE, 30, - ASN1_UTC_TIME, 13, - '0', '7', '0', '1', '0', '1', '0', '0', '0', '0', '0', '0', 'Z', - ASN1_UTC_TIME, 13, /* make it good for 30 or so years */ - '3', '8', '0', '1', '0', '1', '0', '0', '0', '0', '0', '0', 'Z' - }; - - /* fixed time */ - memcpy(&buf[*offset], time_seq, sizeof(time_seq)); - *offset += sizeof(time_seq); -} - -static void gen_pub_key2(const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset) -{ - static const uint8_t pub_key_seq[] = - { - ASN1_INTEGER, 0x03, 0x01, 0x00, 0x01 /* INTEGER 65537 */ - }; - - int seq_offset; - int pub_key_size = rsa_ctx->num_octets; - uint8_t *block = (uint8_t *)alloca(pub_key_size); - int seq_size = pre_adjust_with_size( - ASN1_SEQUENCE, &seq_offset, buf, offset); - buf[(*offset)++] = ASN1_INTEGER; - bi_export(rsa_ctx->bi_ctx, rsa_ctx->m, block, pub_key_size); - - if (*block & 0x80) /* make integer positive */ - { - set_gen_length(pub_key_size+1, buf, offset); - buf[(*offset)++] = 0; - } - else - set_gen_length(pub_key_size, buf, offset); - - memcpy(&buf[*offset], block, pub_key_size); - *offset += pub_key_size; - memcpy(&buf[*offset], pub_key_seq, sizeof(pub_key_seq)); - *offset += sizeof(pub_key_seq); - adjust_with_size(seq_size, seq_offset, buf, offset); -} - -static void gen_pub_key1(const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset) -{ - int seq_offset; - int seq_size = pre_adjust_with_size( - ASN1_BIT_STRING, &seq_offset, buf, offset); - buf[(*offset)++] = 0; /* bit string is multiple of 8 */ - gen_pub_key2(rsa_ctx, buf, offset); - adjust_with_size(seq_size, seq_offset, buf, offset); -} - -static void gen_pub_key(const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset) -{ - /* OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1) */ - static const uint8_t rsa_enc_oid[] = - { - ASN1_SEQUENCE, 0x0d, ASN1_OID, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, - ASN1_NULL, 0x00 - }; - - int seq_offset; - int seq_size = pre_adjust_with_size( - ASN1_SEQUENCE, &seq_offset, buf, offset); - - memcpy(&buf[*offset], rsa_enc_oid, sizeof(rsa_enc_oid)); - *offset += sizeof(rsa_enc_oid); - gen_pub_key1(rsa_ctx, buf, offset); - adjust_with_size(seq_size, seq_offset, buf, offset); -} - -static void gen_signature(const RSA_CTX *rsa_ctx, const uint8_t *sha_dgst, - uint8_t *buf, int *offset) -{ - static const uint8_t asn1_sig[] = - { - ASN1_SEQUENCE, 0x21, ASN1_SEQUENCE, 0x09, ASN1_OID, 0x05, - 0x2b, 0x0e, 0x03, 0x02, 0x1a, /* sha1 (1 3 14 3 2 26) */ - ASN1_NULL, 0x00, ASN1_OCTET_STRING, 0x14 - }; - - uint8_t *enc_block = (uint8_t *)alloca(rsa_ctx->num_octets); - uint8_t *block = (uint8_t *)alloca(sizeof(asn1_sig) + SHA1_SIZE); - int sig_size; - - /* add the digest as an embedded asn.1 sequence */ - memcpy(block, asn1_sig, sizeof(asn1_sig)); - memcpy(&block[sizeof(asn1_sig)], sha_dgst, SHA1_SIZE); - - sig_size = RSA_encrypt(rsa_ctx, block, - sizeof(asn1_sig) + SHA1_SIZE, enc_block, 1); - - buf[(*offset)++] = ASN1_BIT_STRING; - set_gen_length(sig_size+1, buf, offset); - buf[(*offset)++] = 0; /* bit string is multiple of 8 */ - memcpy(&buf[*offset], enc_block, sig_size); - *offset += sig_size; -} - -static int gen_tbs_cert(const char * dn[], - const RSA_CTX *rsa_ctx, uint8_t *buf, int *offset, - uint8_t *sha_dgst) -{ - int ret = X509_OK; - SHA1_CTX sha_ctx; - int seq_offset; - int begin_tbs = *offset; - int seq_size = pre_adjust_with_size( - ASN1_SEQUENCE, &seq_offset, buf, offset); - - gen_serial_number(buf, offset); - gen_signature_alg(buf, offset); - - /* CA certicate issuer */ - if ((ret = gen_issuer(dn, buf, offset))) - goto error; - - gen_utc_time(buf, offset); - - /* certificate issuer */ - if ((ret = gen_issuer(dn, buf, offset))) - goto error; - - gen_pub_key(rsa_ctx, buf, offset); - adjust_with_size(seq_size, seq_offset, buf, offset); - - SHA1_Init(&sha_ctx); - SHA1_Update(&sha_ctx, &buf[begin_tbs], *offset-begin_tbs); - SHA1_Final(sha_dgst, &sha_ctx); - -error: - return ret; -} - -/** - * Create a new certificate. - */ -EXP_FUNC int STDCALL ssl_x509_create(SSL_CTX *ssl_ctx, uint32_t options, const char * dn[], uint8_t **cert_data) -{ - int ret = X509_OK, offset = 0, seq_offset; - /* allocate enough space to load a new certificate */ - uint8_t *buf = (uint8_t *)alloca(ssl_ctx->rsa_ctx->num_octets*2 + 512); - uint8_t sha_dgst[SHA1_SIZE]; - int seq_size = pre_adjust_with_size(ASN1_SEQUENCE, - &seq_offset, buf, &offset); - - if ((ret = gen_tbs_cert(dn, ssl_ctx->rsa_ctx, buf, &offset, sha_dgst)) < 0) - goto error; - - gen_signature_alg(buf, &offset); - gen_signature(ssl_ctx->rsa_ctx, sha_dgst, buf, &offset); - adjust_with_size(seq_size, seq_offset, buf, &offset); - *cert_data = (uint8_t *)malloc(offset); /* create the exact memory for it */ - memcpy(*cert_data, buf, offset); - -error: - return ret < 0 ? ret : offset; -} - -#endif - diff --git a/user/mpy/lib/axtls/ssl/loader.c b/user/mpy/lib/axtls/ssl/loader.c deleted file mode 100644 index 38ed0bf..0000000 --- a/user/mpy/lib/axtls/ssl/loader.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (c) 2007-2014, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Load certificates/keys into memory. These can be in many different formats. - * PEM support and other formats can be processed here. - * - * The PEM private keys may be optionally encrypted with AES128 or AES256. - * The encrypted PEM keys were generated with something like: - * - * openssl genrsa -aes128 -passout pass:abcd -out axTLS.key_aes128.pem 512 - */ - -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -#if CONFIG_SSL_ENABLE_SERVER - -static int do_obj(SSL_CTX *ssl_ctx, int obj_type, - SSLObjLoader *ssl_obj, const char *password); -#ifdef CONFIG_SSL_HAS_PEM -static int ssl_obj_PEM_load(SSL_CTX *ssl_ctx, int obj_type, - SSLObjLoader *ssl_obj, const char *password); -#endif - -/* - * Load a file into memory that is in binary DER (or ascii PEM) format. - */ -EXP_FUNC int STDCALL ssl_obj_load(SSL_CTX *ssl_ctx, int obj_type, - const char *filename, const char *password) -{ -#ifndef CONFIG_SSL_SKELETON_MODE - static const char * const begin = "-----BEGIN"; - int ret = SSL_OK; - SSLObjLoader *ssl_obj = NULL; - - if (filename == NULL) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - - ssl_obj = (SSLObjLoader *)calloc(1, sizeof(SSLObjLoader)); - ssl_obj->len = get_file(filename, &ssl_obj->buf); - if (ssl_obj->len <= 0) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - - /* is the file a PEM file? */ - if (strstr((char *)ssl_obj->buf, begin) != NULL) - { -#ifdef CONFIG_SSL_HAS_PEM - ret = ssl_obj_PEM_load(ssl_ctx, obj_type, ssl_obj, password); -#else -#ifdef CONFIG_SSL_FULL_MODE - printf("%s", unsupported_str); -#endif - ret = SSL_ERROR_NOT_SUPPORTED; -#endif - } - else - ret = do_obj(ssl_ctx, obj_type, ssl_obj, password); - -error: - ssl_obj_free(ssl_obj); - return ret; -#else -#ifdef CONFIG_SSL_FULL_MODE - printf("%s", unsupported_str); -#endif - return SSL_ERROR_NOT_SUPPORTED; -#endif /* CONFIG_SSL_SKELETON_MODE */ -} - -/* - * Transfer binary data into the object loader. - */ -EXP_FUNC int STDCALL ssl_obj_memory_load(SSL_CTX *ssl_ctx, int mem_type, - const uint8_t *data, int len, const char *password) -{ - int ret; - SSLObjLoader *ssl_obj; - - ssl_obj = (SSLObjLoader *)calloc(1, sizeof(SSLObjLoader)); - ssl_obj->buf = (uint8_t *)malloc(len); - memcpy(ssl_obj->buf, data, len); - ssl_obj->len = len; - ret = do_obj(ssl_ctx, mem_type, ssl_obj, password); - ssl_obj_free(ssl_obj); - return ret; -} - -/* - * Actually work out what we are doing - */ -static int do_obj(SSL_CTX *ssl_ctx, int obj_type, - SSLObjLoader *ssl_obj, const char *password) -{ - int ret = SSL_OK; - - switch (obj_type) - { - case SSL_OBJ_RSA_KEY: - ret = add_private_key(ssl_ctx, ssl_obj); - break; - - case SSL_OBJ_X509_CERT: - ret = add_cert(ssl_ctx, ssl_obj->buf, ssl_obj->len); - break; - -#ifdef CONFIG_SSL_CERT_VERIFICATION - case SSL_OBJ_X509_CACERT: - add_cert_auth(ssl_ctx, ssl_obj->buf, ssl_obj->len); - break; -#endif - -#ifdef CONFIG_SSL_USE_PKCS12 - case SSL_OBJ_PKCS8: - ret = pkcs8_decode(ssl_ctx, ssl_obj, password); - break; - - case SSL_OBJ_PKCS12: - ret = pkcs12_decode(ssl_ctx, ssl_obj, password); - break; -#endif - default: -#ifdef CONFIG_SSL_FULL_MODE - printf("%s", unsupported_str); -#endif - ret = SSL_ERROR_NOT_SUPPORTED; - break; - } - - return ret; -} - -/* - * Clean up our mess. - */ -void ssl_obj_free(SSLObjLoader *ssl_obj) -{ - if (ssl_obj) - { - free(ssl_obj->buf); - free(ssl_obj); - } -} - -/* - * Support for PEM encoded keys/certificates. - */ -#ifdef CONFIG_SSL_HAS_PEM - -#define NUM_PEM_TYPES 4 -#define IV_SIZE 16 -#define IS_RSA_PRIVATE_KEY 0 -#define IS_ENCRYPTED_PRIVATE_KEY 1 -#define IS_PRIVATE_KEY 2 -#define IS_CERTIFICATE 3 - -static const char * const begins[NUM_PEM_TYPES] = -{ - "-----BEGIN RSA PRIVATE KEY-----", - "-----BEGIN ENCRYPTED PRIVATE KEY-----", - "-----BEGIN PRIVATE KEY-----", - "-----BEGIN CERTIFICATE-----", -}; - -static const char * const ends[NUM_PEM_TYPES] = -{ - "-----END RSA PRIVATE KEY-----", - "-----END ENCRYPTED PRIVATE KEY-----", - "-----END PRIVATE KEY-----", - "-----END CERTIFICATE-----", -}; - -static const char * const aes_str[2] = -{ - "DEK-Info: AES-128-CBC,", - "DEK-Info: AES-256-CBC," -}; - -/** - * Take a base64 blob of data and decrypt it (using AES) into its - * proper ASN.1 form. - */ -static int pem_decrypt(const char *where, const char *end, - const char *password, SSLObjLoader *ssl_obj) -{ - int ret = -1; - int is_aes_256 = 0; - char *start = NULL; - uint8_t iv[IV_SIZE]; - int i, pem_size; - MD5_CTX md5_ctx; - AES_CTX aes_ctx; - uint8_t key[32]; /* AES256 size */ - - if (password == NULL || strlen(password) == 0) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: Need a password for this PEM file\n"); -#endif - goto error; - } - - if ((start = strstr((const char *)where, aes_str[0]))) /* AES128? */ - { - start += strlen(aes_str[0]); - } - else if ((start = strstr((const char *)where, aes_str[1]))) /* AES256? */ - { - is_aes_256 = 1; - start += strlen(aes_str[1]); - } - else - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: Unsupported password cipher\n"); -#endif - goto error; - } - - /* convert from hex to binary - assumes uppercase hex */ - for (i = 0; i < IV_SIZE; i++) - { - char c = *start++ - '0'; - iv[i] = (c > 9 ? c + '0' - 'A' + 10 : c) << 4; - c = *start++ - '0'; - iv[i] += (c > 9 ? c + '0' - 'A' + 10 : c); - } - - while (*start == '\r' || *start == '\n') - start++; - - /* turn base64 into binary */ - pem_size = (int)(end-start); - if (base64_decode(start, pem_size, ssl_obj->buf, &ssl_obj->len) != 0) - goto error; - - /* work out the key */ - MD5_Init(&md5_ctx); - MD5_Update(&md5_ctx, (const uint8_t *)password, strlen(password)); - MD5_Update(&md5_ctx, iv, SALT_SIZE); - MD5_Final(key, &md5_ctx); - - if (is_aes_256) - { - MD5_Init(&md5_ctx); - MD5_Update(&md5_ctx, key, MD5_SIZE); - MD5_Update(&md5_ctx, (const uint8_t *)password, strlen(password)); - MD5_Update(&md5_ctx, iv, SALT_SIZE); - MD5_Final(&key[MD5_SIZE], &md5_ctx); - } - - /* decrypt using the key/iv */ - AES_set_key(&aes_ctx, key, iv, is_aes_256 ? AES_MODE_256 : AES_MODE_128); - AES_convert_key(&aes_ctx); - AES_cbc_decrypt(&aes_ctx, ssl_obj->buf, ssl_obj->buf, ssl_obj->len); - ret = 0; - -error: - return ret; -} - -/** - * Take a base64 blob of data and turn it into its proper ASN.1 form. - */ -static int new_pem_obj(SSL_CTX *ssl_ctx, int is_cacert, char *where, - int remain, const char *password) -{ - int ret = SSL_ERROR_BAD_CERTIFICATE; - SSLObjLoader *ssl_obj = NULL; - - while (remain > 0) - { - int i, pem_size, obj_type; - char *start = NULL, *end = NULL; - - for (i = 0; i < NUM_PEM_TYPES; i++) - { - if ((start = strstr(where, begins[i])) && - (end = strstr(where, ends[i]))) - { - remain -= (int)(end-where); - start += strlen(begins[i]); - pem_size = (int)(end-start); - - ssl_obj = (SSLObjLoader *)calloc(1, sizeof(SSLObjLoader)); - - /* 4/3 bigger than what we need but so what */ - ssl_obj->buf = (uint8_t *)calloc(1, pem_size); - ssl_obj->len = pem_size; - - if (i == IS_RSA_PRIVATE_KEY && - strstr(start, "Proc-Type:") && - strstr(start, "4,ENCRYPTED")) - { - /* check for encrypted PEM file */ - if (pem_decrypt(start, end, password, ssl_obj) < 0) - { - ret = SSL_ERROR_BAD_CERTIFICATE; - goto error; - } - } - else - { - ssl_obj->len = pem_size; - if (base64_decode(start, pem_size, - ssl_obj->buf, &ssl_obj->len) != 0) - { - ret = SSL_ERROR_BAD_CERTIFICATE; - goto error; - } - } - - switch (i) - { - case IS_RSA_PRIVATE_KEY: - obj_type = SSL_OBJ_RSA_KEY; - break; - - case IS_ENCRYPTED_PRIVATE_KEY: - case IS_PRIVATE_KEY: - obj_type = SSL_OBJ_PKCS8; - break; - - case IS_CERTIFICATE: - obj_type = is_cacert ? - SSL_OBJ_X509_CACERT : SSL_OBJ_X509_CERT; - break; - - default: - ret = SSL_ERROR_BAD_CERTIFICATE; - goto error; - } - - /* In a format we can now understand - so process it */ - if ((ret = do_obj(ssl_ctx, obj_type, ssl_obj, password))) - goto error; - - end += strlen(ends[i]); - remain -= strlen(ends[i]); - while (remain > 0 && (*end == '\r' || *end == '\n')) - { - end++; - remain--; - } - - where = end; - break; - } - } - - ssl_obj_free(ssl_obj); - ssl_obj = NULL; - if (start == NULL) - break; - } -error: - ssl_obj_free(ssl_obj); - return ret; -} - -/* - * Load a file into memory that is in ASCII PEM format. - */ -static int ssl_obj_PEM_load(SSL_CTX *ssl_ctx, int obj_type, - SSLObjLoader *ssl_obj, const char *password) -{ - char *start; - - /* add a null terminator */ - ssl_obj->len++; - ssl_obj->buf = (uint8_t *)realloc(ssl_obj->buf, ssl_obj->len); - ssl_obj->buf[ssl_obj->len-1] = 0; - start = (char *)ssl_obj->buf; - return new_pem_obj(ssl_ctx, obj_type == SSL_OBJ_X509_CACERT, - start, ssl_obj->len, password); -} -#endif /* CONFIG_SSL_HAS_PEM */ - -/** - * Load the key/certificates in memory depending on compile-time and user - * options. - */ -int load_key_certs(SSL_CTX *ssl_ctx) -{ - int ret = SSL_OK; - uint32_t options = ssl_ctx->options; -#ifdef CONFIG_SSL_GENERATE_X509_CERT - uint8_t *cert_data = NULL; - int cert_size; - static const char *dn[] = - { - CONFIG_SSL_X509_COMMON_NAME, - CONFIG_SSL_X509_ORGANIZATION_NAME, - CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME - }; -#endif - - /* do the private key first */ - if (strlen(CONFIG_SSL_PRIVATE_KEY_LOCATION) > 0) - { - if ((ret = ssl_obj_load(ssl_ctx, SSL_OBJ_RSA_KEY, - CONFIG_SSL_PRIVATE_KEY_LOCATION, - CONFIG_SSL_PRIVATE_KEY_PASSWORD)) < 0) - goto error; - } - else if (!(options & SSL_NO_DEFAULT_KEY)) - { -#if defined(CONFIG_SSL_USE_DEFAULT_KEY) || defined(CONFIG_SSL_SKELETON_MODE) - static const /* saves a few more bytes */ -#include "private_key.h" - - ssl_obj_memory_load(ssl_ctx, SSL_OBJ_RSA_KEY, default_private_key, - default_private_key_len, NULL); -#endif - } - - /* now load the certificate */ -#ifdef CONFIG_SSL_GENERATE_X509_CERT - if ((cert_size = ssl_x509_create(ssl_ctx, 0, dn, &cert_data)) < 0) - { - ret = cert_size; - goto error; - } - - ssl_obj_memory_load(ssl_ctx, SSL_OBJ_X509_CERT, cert_data, cert_size, NULL); - free(cert_data); -#else - if (strlen(CONFIG_SSL_X509_CERT_LOCATION)) - { - if ((ret = ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, - CONFIG_SSL_X509_CERT_LOCATION, NULL)) < 0) - goto error; - } - else if (!(options & SSL_NO_DEFAULT_KEY)) - { -#if defined(CONFIG_SSL_USE_DEFAULT_KEY) || defined(CONFIG_SSL_SKELETON_MODE) -#include "cert.h" - ssl_obj_memory_load(ssl_ctx, SSL_OBJ_X509_CERT, - default_certificate, default_certificate_len, NULL); -#endif - } -#endif - -error: -#ifdef CONFIG_SSL_FULL_MODE - if (ret) - { - printf("Error: Certificate or key not loaded\n"); - } -#endif - - return ret; - -} - -#endif diff --git a/user/mpy/lib/axtls/ssl/openssl.c b/user/mpy/lib/axtls/ssl/openssl.c deleted file mode 100644 index d0343e5..0000000 --- a/user/mpy/lib/axtls/ssl/openssl.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Enable a subset of openssl compatible functions. We don't aim to be 100% - * compatible - just to be able to do basic ports etc. - * - * Only really tested on mini_httpd, so I'm not too sure how extensive this - * port is. - */ - -#include "config.h" - -#ifdef CONFIG_OPENSSL_COMPATIBLE -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -#define OPENSSL_CTX_ATTR ((OPENSSL_CTX *)ssl_ctx->bonus_attr) - -static char *key_password = NULL; - -void *SSLv3_server_method(void) { return NULL; } -void *TLSv1_server_method(void) { return NULL; } -void *SSLv3_client_method(void) { return NULL; } -void *TLSv1_client_method(void) { return NULL; } - -typedef void * (*ssl_func_type_t)(void); -typedef void * (*bio_func_type_t)(void); - -typedef struct -{ - ssl_func_type_t ssl_func_type; -} OPENSSL_CTX; - -SSL_CTX * SSL_CTX_new(ssl_func_type_t meth) -{ - SSL_CTX *ssl_ctx = ssl_ctx_new(0, 5); - ssl_ctx->bonus_attr = malloc(sizeof(OPENSSL_CTX)); - OPENSSL_CTX_ATTR->ssl_func_type = meth; - return ssl_ctx; -} - -void SSL_CTX_free(SSL_CTX * ssl_ctx) -{ - free(ssl_ctx->bonus_attr); - ssl_ctx_free(ssl_ctx); -} - -SSL * SSL_new(SSL_CTX *ssl_ctx) -{ - SSL *ssl; -#ifdef CONFIG_SSL_ENABLE_CLIENT - ssl_func_type_t ssl_func_type = OPENSSL_CTX_ATTR->ssl_func_type; -#endif - - ssl = ssl_new(ssl_ctx, -1); /* fd is set later */ -#ifdef CONFIG_SSL_ENABLE_CLIENT - if (ssl_func_type == SSLv3_client_method || - ssl_func_type == TLSv1_client_method) - { - SET_SSL_FLAG(SSL_IS_CLIENT); - } - else -#endif - { - ssl->next_state = HS_CLIENT_HELLO; - } - - return ssl; -} - -int SSL_set_fd(SSL *s, int fd) -{ - s->client_fd = fd; - return 1; /* always succeeds */ -} - -int SSL_accept(SSL *ssl) -{ - while (ssl_read(ssl, NULL) == SSL_OK) - { - if (ssl->next_state == HS_CLIENT_HELLO) - return 1; /* we're done */ - } - - return -1; -} - -#ifdef CONFIG_SSL_ENABLE_CLIENT -int SSL_connect(SSL *ssl) -{ - return do_client_connect(ssl) == SSL_OK ? 1 : -1; -} -#endif - -void SSL_free(SSL *ssl) -{ - ssl_free(ssl); -} - -int SSL_read(SSL *ssl, void *buf, int num) -{ - uint8_t *read_buf; - int ret; - - while ((ret = ssl_read(ssl, &read_buf)) == SSL_OK); - - if (ret > SSL_OK) - { - memcpy(buf, read_buf, ret > num ? num : ret); - } - - return ret; -} - -int SSL_write(SSL *ssl, const void *buf, int num) -{ - return ssl_write(ssl, buf, num); -} - -int SSL_CTX_use_certificate_file(SSL_CTX *ssl_ctx, const char *file, int type) -{ - return (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, file, NULL) == SSL_OK); -} - -int SSL_CTX_use_PrivateKey_file(SSL_CTX *ssl_ctx, const char *file, int type) -{ - return (ssl_obj_load(ssl_ctx, SSL_OBJ_RSA_KEY, file, key_password) == SSL_OK); -} - -int SSL_CTX_use_certificate_ASN1(SSL_CTX *ssl_ctx, int len, const uint8_t *d) -{ - return (ssl_obj_memory_load(ssl_ctx, - SSL_OBJ_X509_CERT, d, len, NULL) == SSL_OK); -} - -int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, - unsigned int sid_ctx_len) -{ - return 1; -} - -int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) -{ - return 1; -} - -int SSL_CTX_use_certificate_chain_file(SSL_CTX *ssl_ctx, const char *file) -{ - return (ssl_obj_load(ssl_ctx, - SSL_OBJ_X509_CERT, file, NULL) == SSL_OK); -} - -int SSL_shutdown(SSL *ssl) -{ - return 1; -} - -/*** get/set session ***/ -SSL_SESSION *SSL_get1_session(SSL *ssl) -{ - return (SSL_SESSION *)ssl_get_session_id(ssl); /* note: wrong cast */ -} - -int SSL_set_session(SSL *ssl, SSL_SESSION *session) -{ - memcpy(ssl->session_id, (uint8_t *)session, SSL_SESSION_ID_SIZE); - return 1; -} - -void SSL_SESSION_free(SSL_SESSION *session) { } -/*** end get/set session ***/ - -long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) -{ - return 0; -} - -void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, - int (*verify_callback)(int, void *)) { } - -void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) { } - -int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, - const char *CApath) -{ - return 1; -} - -void *SSL_load_client_CA_file(const char *file) -{ - return (void *)file; -} - -void SSL_CTX_set_client_CA_list(SSL_CTX *ssl_ctx, void *file) -{ - - ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, (const char *)file, NULL); -} - -void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, void *cb) { } - -void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u) -{ - key_password = (char *)u; -} - -int SSL_peek(SSL *ssl, void *buf, int num) -{ - memcpy(buf, ssl->bm_data, num); - return num; -} - -void SSL_set_bio(SSL *ssl, void *rbio, void *wbio) { } - -long SSL_get_verify_result(const SSL *ssl) -{ - return ssl_handshake_status(ssl); -} - -int SSL_state(SSL *ssl) -{ - return 0x03; // ok state -} - -/** end of could do better list */ - -void *SSL_get_peer_certificate(const SSL *ssl) -{ - return &ssl->ssl_ctx->certs[0]; -} - -int SSL_clear(SSL *ssl) -{ - return 1; -} - - -int SSL_CTX_check_private_key(const SSL_CTX *ctx) -{ - return 1; -} - -int SSL_CTX_set_cipher_list(SSL *s, const char *str) -{ - return 1; -} - -int SSL_get_error(const SSL *ssl, int ret) -{ - ssl_display_error(ret); - return 0; /* TODO: return proper return code */ -} - -void SSL_CTX_set_options(SSL_CTX *ssl_ctx, int option) {} -int SSL_library_init(void ) { return 1; } -void SSL_load_error_strings(void ) {} -void ERR_print_errors_fp(FILE *fp) {} - -#ifndef CONFIG_SSL_SKELETON_MODE -long SSL_CTX_get_timeout(const SSL_CTX *ssl_ctx) { - return CONFIG_SSL_EXPIRY_TIME*3600; } -long SSL_CTX_set_timeout(SSL_CTX *ssl_ctx, long t) { - return SSL_CTX_get_timeout(ssl_ctx); } -#endif -void BIO_printf(FILE *f, const char *format, ...) -{ - va_list(ap); - va_start(ap, format); - vfprintf(f, format, ap); - va_end(ap); -} - -void* BIO_s_null(void) { return NULL; } -FILE *BIO_new(bio_func_type_t func) -{ - if (func == BIO_s_null) - return fopen("/dev/null", "r"); - else - return NULL; -} - -FILE *BIO_new_fp(FILE *stream, int close_flag) { return stream; } -int BIO_free(FILE *a) { if (a != stdout && a != stderr) fclose(a); return 1; } - - - -#endif diff --git a/user/mpy/lib/axtls/ssl/os_port.c b/user/mpy/lib/axtls/ssl/os_port.c deleted file mode 100644 index e69de29..0000000 diff --git a/user/mpy/lib/axtls/ssl/os_port.h b/user/mpy/lib/axtls/ssl/os_port.h deleted file mode 120000 index 76d6248..0000000 --- a/user/mpy/lib/axtls/ssl/os_port.h +++ /dev/null @@ -1 +0,0 @@ -os_port_micropython.h \ No newline at end of file diff --git a/user/mpy/lib/axtls/ssl/os_port_micropython.h b/user/mpy/lib/axtls/ssl/os_port_micropython.h deleted file mode 100644 index 88697f2..0000000 --- a/user/mpy/lib/axtls/ssl/os_port_micropython.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2007-2015, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file os_port.h - * - * Some stuff to minimise the differences between windows and linux/unix - */ - -#ifndef HEADER_OS_PORT_H -#define HEADER_OS_PORT_H - -#include "os_int.h" -#include -#include -#ifndef __ets__ -#include -#endif -#include -#include "config.h" - -ssize_t mp_stream_posix_write(void *sock_obj, const void *buf, size_t len); -ssize_t mp_stream_posix_read(void *sock_obj, void *buf, size_t len); -extern int mp_stream_errno; - -#if 1 -#define SOCKET_READ(A,B,C) mp_stream_posix_read((void*)A,B,C) -#define SOCKET_WRITE(A,B,C) mp_stream_posix_write((void*)A,B,C) -#define SOCKET_CLOSE(A) NOT_USED_IN_LIB_CODE -#define SOCKET_ERRNO() mp_stream_errno -#else -#define SOCKET_READ(A,B,C) read(A,B,C) -#define SOCKET_WRITE(A,B,C) write(A,B,C) -#define SOCKET_CLOSE(A) if (A >= 0) close(A) -#define SOCKET_ERRNO() errno -#endif -#define ax_calloc(x, y) calloc(x, y) -#define ax_open(x, y) open(x, y) - -#ifndef be64toh -#define be64toh(x) __be64_to_cpu(x) -#endif - -#define SSL_CTX_MUTEX_INIT(A) -#define SSL_CTX_MUTEX_DESTROY(A) -#define SSL_CTX_LOCK(A) -#define SSL_CTX_UNLOCK(A) - -#define TTY_FLUSH() - -#include "../../../extmod/crypto-algorithms/sha256.h" - -#define SHA256_CTX CRYAL_SHA256_CTX -#define SHA256_Init(a) sha256_init(a) -#define SHA256_Update(a, b, c) sha256_update(a, b, c) -#define SHA256_Final(a, b) sha256_final(b, a) - -#endif diff --git a/user/mpy/lib/axtls/ssl/p12.c b/user/mpy/lib/axtls/ssl/p12.c deleted file mode 100644 index 2c16581..0000000 --- a/user/mpy/lib/axtls/ssl/p12.c +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Process PKCS#8/PKCS#12 keys. - * - * The decoding of a PKCS#12 key is fairly specific - this code was tested on a - * key generated with: - * - * openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem - * -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 - * -name "p12_withoutCA" -out axTLS.withoutCA.p12 -password pass:abcd - * - * or with a certificate chain: - * - * openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem - * -certfile axTLS.ca_x509.pem -keypbe PBE-SHA1-RC4-128 -certpbe - * PBE-SHA1-RC4-128 -name "p12_withCA" -out axTLS.withCA.p12 -password pass:abcd - * - * Note that the PBE has to be specified with PBE-SHA1-RC4-128. The - * private/public keys/certs have to use RSA encryption. Both the integrity - * and privacy passwords are the same. - * - * The PKCS#8 files were generated with something like: - * - * PEM format: - * openssl pkcs8 -in axTLS.key_512.pem -passout pass:abcd -topk8 -v1 - * PBE-SHA1-RC4-128 -out axTLS.encrypted_pem.p8 - * - * DER format: - * openssl pkcs8 -in axTLS.key_512.pem -passout pass:abcd -topk8 -outform DER - * -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted.p8 - */ - -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -/* all commented out if not used */ -#ifdef CONFIG_SSL_USE_PKCS12 - -#define BLOCK_SIZE 64 -#define PKCS12_KEY_ID 1 -#define PKCS12_IV_ID 2 -#define PKCS12_MAC_ID 3 - -static char *make_uni_pass(const char *password, int *uni_pass_len); -static int p8_decrypt(const char *uni_pass, int uni_pass_len, - const uint8_t *salt, int iter, - uint8_t *priv_key, int priv_key_len, int id); -static int p8_add_key(SSL_CTX *ssl_ctx, uint8_t *priv_key); -static int get_pbe_params(uint8_t *buf, int *offset, - const uint8_t **salt, int *iterations); - -/* - * Take a raw pkcs8 block and then decrypt it and turn it into a normal key. - */ -int pkcs8_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password) -{ - uint8_t *buf = ssl_obj->buf; - int len, offset = 0; - int iterations; - int ret = SSL_NOT_OK; - uint8_t *version = NULL; - const uint8_t *salt; - uint8_t *priv_key; - int uni_pass_len; - char *uni_pass = make_uni_pass(password, &uni_pass_len); - - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: Invalid p8 ASN.1 file\n"); -#endif - goto error; - } - - /* unencrypted key? */ - if (asn1_get_big_int(buf, &offset, &version) > 0 && *version == 0) - { - ret = p8_add_key(ssl_ctx, buf); - goto error; - } - - if (get_pbe_params(buf, &offset, &salt, &iterations) < 0) - goto error; - - if ((len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0) - goto error; - - priv_key = &buf[offset]; - - p8_decrypt(uni_pass, uni_pass_len, salt, - iterations, priv_key, len, PKCS12_KEY_ID); - ret = p8_add_key(ssl_ctx, priv_key); - -error: - free(version); - free(uni_pass); - return ret; -} - -/* - * Take the unencrypted pkcs8 and turn it into a private key - */ -static int p8_add_key(SSL_CTX *ssl_ctx, uint8_t *priv_key) -{ - uint8_t *buf = priv_key; - int len, offset = 0; - int ret = SSL_NOT_OK; - - /* Skip the preamble and go straight to the private key. - We only support rsaEncryption (1.2.840.113549.1.1.1) */ - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(buf, &offset, ASN1_INTEGER) < 0 || - asn1_skip_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0) - goto error; - - ret = asn1_get_private_key(&buf[offset], len, &ssl_ctx->rsa_ctx); - -error: - return ret; -} - -/* - * Create the unicode password - */ -static char *make_uni_pass(const char *password, int *uni_pass_len) -{ - int pass_len = 0, i; - char *uni_pass; - - if (password == NULL) - { - password = ""; - } - - uni_pass = (char *)malloc((strlen(password)+1)*2); - - /* modify the password into a unicode version */ - for (i = 0; i < (int)strlen(password); i++) - { - uni_pass[pass_len++] = 0; - uni_pass[pass_len++] = password[i]; - } - - uni_pass[pass_len++] = 0; /* null terminate */ - uni_pass[pass_len++] = 0; - *uni_pass_len = pass_len; - return uni_pass; -} - -/* - * Decrypt a pkcs8 block. - */ -static int p8_decrypt(const char *uni_pass, int uni_pass_len, - const uint8_t *salt, int iter, - uint8_t *priv_key, int priv_key_len, int id) -{ - uint8_t p[BLOCK_SIZE*2]; - uint8_t d[BLOCK_SIZE]; - uint8_t Ai[SHA1_SIZE]; - SHA1_CTX sha_ctx; - RC4_CTX rc4_ctx; - int i; - - for (i = 0; i < BLOCK_SIZE; i++) - { - p[i] = salt[i % SALT_SIZE]; - p[BLOCK_SIZE+i] = uni_pass[i % uni_pass_len]; - d[i] = id; - } - - /* get the key - no IV since we are using RC4 */ - SHA1_Init(&sha_ctx); - SHA1_Update(&sha_ctx, d, sizeof(d)); - SHA1_Update(&sha_ctx, p, sizeof(p)); - SHA1_Final(Ai, &sha_ctx); - - for (i = 1; i < iter; i++) - { - SHA1_Init(&sha_ctx); - SHA1_Update(&sha_ctx, Ai, SHA1_SIZE); - SHA1_Final(Ai, &sha_ctx); - } - - /* do the decryption */ - if (id == PKCS12_KEY_ID) - { - RC4_setup(&rc4_ctx, Ai, 16); - RC4_crypt(&rc4_ctx, priv_key, priv_key, priv_key_len); - } - else /* MAC */ - memcpy(priv_key, Ai, SHA1_SIZE); - - return 0; -} - -/* - * Take a raw pkcs12 block and the decrypt it and turn it into a certificate(s) - * and keys. - */ -int pkcs12_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password) -{ - uint8_t *buf = ssl_obj->buf; - int len, iterations, auth_safes_start, - auth_safes_end, auth_safes_len, key_offset, offset = 0; - int all_certs = 0; - uint8_t *version = NULL, *auth_safes = NULL, *cert, *orig_mac; - uint8_t key[SHA1_SIZE]; - uint8_t mac[SHA1_SIZE]; - const uint8_t *salt; - int uni_pass_len, ret = SSL_OK; - char *uni_pass = make_uni_pass(password, &uni_pass_len); - static const uint8_t pkcs_data[] = /* pkc7 data */ - { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01 }; - static const uint8_t pkcs_encrypted[] = /* pkc7 encrypted */ - { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x06 }; - static const uint8_t pkcs8_key_bag[] = /* 1.2.840.113549.1.12.10.1.2 */ - { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01, 0x02 }; - - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: Invalid p12 ASN.1 file\n"); -#endif - goto error; - } - - if (asn1_get_big_int(buf, &offset, &version) < 0 || *version != 3) - { - ret = SSL_ERROR_INVALID_VERSION; - goto error; - } - - /* remove all the boring pcks7 bits */ - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || - len != sizeof(pkcs_data) || - memcmp(&buf[offset], pkcs_data, sizeof(pkcs_data))) - goto error; - - offset += len; - - if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || - asn1_next_obj(buf, &offset, ASN1_OCTET_STRING) < 0) - goto error; - - /* work out the MAC start/end points (done on AuthSafes) */ - auth_safes_start = offset; - auth_safes_end = offset; - if (asn1_skip_obj(buf, &auth_safes_end, ASN1_SEQUENCE) < 0) - goto error; - - auth_safes_len = auth_safes_end - auth_safes_start; - auth_safes = malloc(auth_safes_len); - - memcpy(auth_safes, &buf[auth_safes_start], auth_safes_len); - - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || - (len != sizeof(pkcs_encrypted) || - memcmp(&buf[offset], pkcs_encrypted, sizeof(pkcs_encrypted)))) - goto error; - - offset += len; - - if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(buf, &offset, ASN1_INTEGER) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || - len != sizeof(pkcs_data) || - memcmp(&buf[offset], pkcs_data, sizeof(pkcs_data))) - goto error; - - offset += len; - - /* work out the salt for the certificate */ - if (get_pbe_params(buf, &offset, &salt, &iterations) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_IMPLICIT_TAG)) < 0) - goto error; - - /* decrypt the certificate */ - cert = &buf[offset]; - if ((ret = p8_decrypt(uni_pass, uni_pass_len, salt, iterations, cert, - len, PKCS12_KEY_ID)) < 0) - goto error; - - offset += len; - - /* load the certificate */ - key_offset = 0; - all_certs = asn1_next_obj(cert, &key_offset, ASN1_SEQUENCE); - - /* keep going until all certs are loaded */ - while (key_offset < all_certs) - { - int cert_offset = key_offset; - - if (asn1_skip_obj(cert, &cert_offset, ASN1_SEQUENCE) < 0 || - asn1_next_obj(cert, &key_offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(cert, &key_offset, ASN1_OID) < 0 || - asn1_next_obj(cert, &key_offset, ASN1_EXPLICIT_TAG) < 0 || - asn1_next_obj(cert, &key_offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(cert, &key_offset, ASN1_OID) < 0 || - asn1_next_obj(cert, &key_offset, ASN1_EXPLICIT_TAG) < 0 || - (len = asn1_next_obj(cert, &key_offset, ASN1_OCTET_STRING)) < 0) - goto error; - - if ((ret = add_cert(ssl_ctx, &cert[key_offset], len)) < 0) - goto error; - - key_offset = cert_offset; - } - - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || - len != sizeof(pkcs_data) || - memcmp(&buf[offset], pkcs_data, sizeof(pkcs_data))) - goto error; - - offset += len; - - if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || - asn1_next_obj(buf, &offset, ASN1_OCTET_STRING) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OID)) < 0 || - (len != sizeof(pkcs8_key_bag)) || - memcmp(&buf[offset], pkcs8_key_bag, sizeof(pkcs8_key_bag))) - goto error; - - offset += len; - - /* work out the salt for the private key */ - if (asn1_next_obj(buf, &offset, ASN1_EXPLICIT_TAG) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - get_pbe_params(buf, &offset, &salt, &iterations) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0) - goto error; - - /* decrypt the private key */ - cert = &buf[offset]; - if ((ret = p8_decrypt(uni_pass, uni_pass_len, salt, iterations, cert, - len, PKCS12_KEY_ID)) < 0) - goto error; - - offset += len; - - /* load the private key */ - if ((ret = p8_add_key(ssl_ctx, cert)) < 0) - goto error; - - /* miss out on friendly name, local key id etc */ - if (asn1_skip_obj(buf, &offset, ASN1_SET) < 0) - goto error; - - /* work out the MAC */ - if (asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - asn1_next_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(buf, &offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0 || - len != SHA1_SIZE) - goto error; - - orig_mac = &buf[offset]; - offset += len; - - /* get the salt */ - if ((len = asn1_next_obj(buf, &offset, ASN1_OCTET_STRING)) < 0 || len != 8) - goto error; - - salt = &buf[offset]; - - /* work out what the mac should be */ - if ((ret = p8_decrypt(uni_pass, uni_pass_len, salt, iterations, - key, SHA1_SIZE, PKCS12_MAC_ID)) < 0) - goto error; - - ssl_hmac_sha1(auth_safes, auth_safes_len, key, SHA1_SIZE, mac); - - if (memcmp(mac, orig_mac, SHA1_SIZE)) - { - ret = SSL_ERROR_INVALID_HMAC; - goto error; - } - -error: - free(version); - free(uni_pass); - free(auth_safes); - return ret; -} - -/* - * Retrieve the salt/iteration details from a PBE block. - */ -static int get_pbe_params(uint8_t *buf, int *offset, - const uint8_t **salt, int *iterations) -{ - static const uint8_t pbeSH1RC4[] = /* pbeWithSHAAnd128BitRC4 */ - { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x01 }; - - int i, len; - uint8_t *iter = NULL; - int error_code = SSL_ERROR_NOT_SUPPORTED; - - /* Get the PBE type */ - if (asn1_next_obj(buf, offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, offset, ASN1_OID)) < 0) - goto error; - - /* we expect pbeWithSHAAnd128BitRC4 (1.2.840.113549.1.12.1.1) - which is the only algorithm we support */ - if (len != sizeof(pbeSH1RC4) || - memcmp(&buf[*offset], pbeSH1RC4, sizeof(pbeSH1RC4))) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: pkcs8/pkcs12 must use \"PBE-SHA1-RC4-128\"\n"); -#endif - goto error; - } - - *offset += len; - - if (asn1_next_obj(buf, offset, ASN1_SEQUENCE) < 0 || - (len = asn1_next_obj(buf, offset, ASN1_OCTET_STRING)) < 0 || - len != 8) - goto error; - - *salt = &buf[*offset]; - *offset += len; - - if ((len = asn1_get_big_int(buf, offset, &iter)) < 0) - goto error; - - *iterations = 0; - for (i = 0; i < len; i++) - { - (*iterations) <<= 8; - (*iterations) += iter[i]; - } - - free(iter); - error_code = SSL_OK; /* got here - we are ok */ - -error: - return error_code; -} - -#endif diff --git a/user/mpy/lib/axtls/ssl/private_key.h b/user/mpy/lib/axtls/ssl/private_key.h deleted file mode 100644 index f72bee2..0000000 --- a/user/mpy/lib/axtls/ssl/private_key.h +++ /dev/null @@ -1,54 +0,0 @@ -unsigned char default_private_key[] = { - 0x30, 0x82, 0x02, 0x5d, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xbd, - 0x0f, 0xd4, 0x42, 0xa8, 0x74, 0x87, 0x54, 0xaa, 0xb9, 0x3a, 0x1f, 0x8b, - 0xce, 0xbd, 0xb7, 0x65, 0xfb, 0x40, 0x3d, 0xd0, 0x11, 0x9a, 0x9c, 0xdc, - 0x82, 0x7c, 0xea, 0xa8, 0x17, 0xe1, 0x74, 0xf3, 0x05, 0x0e, 0x61, 0xc1, - 0xc1, 0x78, 0x8a, 0xb2, 0xba, 0x15, 0x22, 0x5a, 0xff, 0x9b, 0xb8, 0x7a, - 0x2e, 0x0f, 0x88, 0xb7, 0x74, 0xde, 0x04, 0x99, 0xa5, 0xa2, 0x99, 0x53, - 0x8b, 0xad, 0x78, 0x5a, 0x31, 0xed, 0xbc, 0x01, 0xe7, 0xdf, 0xe9, 0xec, - 0x2f, 0xa0, 0x5d, 0x53, 0xf6, 0xe6, 0x8a, 0xa0, 0xc8, 0x6d, 0x41, 0x45, - 0x63, 0x23, 0xb3, 0xcf, 0x4e, 0x50, 0x1f, 0x28, 0xdf, 0x36, 0xe2, 0x73, - 0xdf, 0xd6, 0xa1, 0xb3, 0x46, 0x4f, 0x6e, 0xbb, 0x0d, 0x9b, 0xef, 0xa8, - 0xf9, 0x4c, 0xa5, 0x71, 0xa1, 0x88, 0xdd, 0x07, 0xa9, 0x86, 0x0d, 0x3f, - 0xcd, 0x99, 0x23, 0xa2, 0x84, 0x77, 0x0f, 0x02, 0x03, 0x01, 0x00, 0x01, - 0x02, 0x81, 0x80, 0x26, 0x3f, 0xec, 0x96, 0xab, 0xd4, 0x1f, 0x89, 0x0e, - 0x9d, 0x38, 0xd8, 0x27, 0x05, 0xe5, 0xb6, 0x14, 0x08, 0xd7, 0xff, 0x69, - 0x78, 0x16, 0x4a, 0xc4, 0x06, 0x16, 0x55, 0xb7, 0x3a, 0x55, 0x9f, 0xbe, - 0x86, 0xf8, 0x58, 0xe8, 0xc5, 0x46, 0xa8, 0xf0, 0xed, 0xda, 0xd6, 0xbf, - 0x88, 0x55, 0x2d, 0xe6, 0x72, 0x29, 0x2c, 0x64, 0xc9, 0x5d, 0x1d, 0x9b, - 0x24, 0x3a, 0x98, 0x40, 0xa1, 0xd2, 0xaf, 0x5c, 0xab, 0x23, 0xe4, 0x33, - 0xd0, 0xea, 0x60, 0x52, 0xe7, 0x7a, 0x9e, 0x73, 0x5f, 0x2e, 0x80, 0xd1, - 0xdc, 0x6f, 0x47, 0x0f, 0x97, 0x80, 0x36, 0xd2, 0x30, 0x07, 0xdd, 0xd6, - 0xd7, 0x15, 0x89, 0x2b, 0x74, 0xd5, 0x7e, 0x8a, 0xbc, 0x63, 0x42, 0x0a, - 0xf2, 0x31, 0x29, 0xbf, 0xf9, 0xf9, 0xf0, 0x88, 0x8f, 0x8a, 0xc2, 0x22, - 0x6e, 0x15, 0x26, 0xb7, 0x5e, 0x5b, 0x58, 0x44, 0x1c, 0x3b, 0x79, 0x02, - 0x41, 0x00, 0xe1, 0xf1, 0xb2, 0xe5, 0xc8, 0x80, 0x93, 0x40, 0x50, 0x74, - 0x14, 0xdd, 0xb2, 0xf2, 0x27, 0x5c, 0x0c, 0x3d, 0xc0, 0x5f, 0xee, 0x9c, - 0x45, 0x6c, 0x13, 0x00, 0xdf, 0xd0, 0xd9, 0x83, 0xfa, 0x90, 0x2c, 0x84, - 0xf2, 0xaa, 0xc2, 0xdd, 0xfb, 0xcf, 0x03, 0x41, 0x88, 0x10, 0xc6, 0xbb, - 0x5e, 0xb7, 0xb6, 0x2e, 0xa6, 0x1d, 0xaa, 0xba, 0xfb, 0x4a, 0x72, 0xd8, - 0x9a, 0xad, 0x88, 0x0d, 0x6a, 0x15, 0x02, 0x41, 0x00, 0xd6, 0x36, 0x23, - 0xf3, 0x5d, 0x77, 0xc8, 0xd3, 0x49, 0xc1, 0x93, 0xfe, 0xca, 0x0d, 0xeb, - 0x9b, 0xda, 0xbd, 0x47, 0x28, 0x73, 0x97, 0xa0, 0x50, 0xd7, 0x4c, 0x24, - 0xdf, 0x9b, 0x0b, 0x37, 0xae, 0xc3, 0x31, 0xb5, 0x4f, 0x62, 0x08, 0xca, - 0xe5, 0xef, 0x97, 0x7b, 0x43, 0xa0, 0xda, 0x2b, 0x1f, 0xbf, 0xa8, 0x08, - 0x93, 0xd2, 0x16, 0x1c, 0x89, 0x99, 0xf1, 0xdf, 0x26, 0xd1, 0x42, 0x99, - 0x93, 0x02, 0x41, 0x00, 0xb1, 0x41, 0xe4, 0x7e, 0xdf, 0x20, 0xf7, 0xe4, - 0xf1, 0xf9, 0x4f, 0xd1, 0x6a, 0x2d, 0x0d, 0xf1, 0xe9, 0xec, 0x9c, 0x3a, - 0xe6, 0xc0, 0x94, 0xba, 0x27, 0xe2, 0x7c, 0xb4, 0xa5, 0xa1, 0x23, 0xf6, - 0xed, 0xe6, 0x53, 0x56, 0xe2, 0x50, 0x32, 0xd8, 0x02, 0x8e, 0xeb, 0xc7, - 0x75, 0x91, 0xd3, 0xca, 0x3e, 0xd4, 0x34, 0x20, 0x7c, 0x2b, 0xfb, 0x2f, - 0x3a, 0x10, 0x72, 0xb1, 0x07, 0x56, 0xb6, 0xcd, 0x02, 0x40, 0x1e, 0x3b, - 0xf2, 0x03, 0x0d, 0x74, 0x34, 0xb2, 0x2d, 0xbc, 0xd6, 0xc8, 0xa5, 0x78, - 0x25, 0x83, 0x0f, 0xf2, 0x9b, 0x32, 0x88, 0x6e, 0x24, 0x40, 0x84, 0xc2, - 0xc8, 0x89, 0x8e, 0xf6, 0x9c, 0x5b, 0x5c, 0x4d, 0x8d, 0xcb, 0xb0, 0x88, - 0x91, 0x2a, 0xb7, 0x10, 0x68, 0x63, 0x79, 0x36, 0x91, 0xd3, 0x9f, 0x57, - 0x76, 0x2e, 0x76, 0xfe, 0x8b, 0xf4, 0x97, 0xf7, 0xdd, 0x89, 0x3b, 0x0b, - 0xed, 0x65, 0x02, 0x41, 0x00, 0xb9, 0xaf, 0xbf, 0x09, 0xc9, 0x90, 0x26, - 0xf3, 0x72, 0x8b, 0xbf, 0xb3, 0x7c, 0xe7, 0x6f, 0x6f, 0x5b, 0xa3, 0x95, - 0xb8, 0x9e, 0x03, 0xb9, 0xcf, 0xa0, 0x53, 0xba, 0x32, 0xc1, 0xd3, 0xad, - 0x85, 0xbb, 0x79, 0x48, 0x09, 0xd6, 0x3f, 0x9c, 0xd9, 0x37, 0x91, 0x11, - 0x0d, 0x04, 0xd5, 0x3b, 0xca, 0x74, 0x5d, 0x1c, 0x91, 0x8d, 0x3d, 0xf1, - 0xf8, 0xf9, 0xbe, 0x35, 0xd7, 0xb2, 0x53, 0x50, 0x1d -}; -unsigned int default_private_key_len = 609; diff --git a/user/mpy/lib/axtls/ssl/ssl.h b/user/mpy/lib/axtls/ssl/ssl.h deleted file mode 100644 index d143fd0..0000000 --- a/user/mpy/lib/axtls/ssl/ssl.h +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @mainpage axTLS API - * - * @image html axolotl.jpg - * - * The axTLS library has features such as: - * - The TLSv1 SSL client/server protocol - * - No requirement to use any openssl libraries. - * - A choice between AES block (128/256 bit) and RC4 (128 bit) stream ciphers. - * - RSA encryption/decryption with variable sized keys (up to 4096 bits). - * - Certificate chaining and peer authentication. - * - Session resumption, session renegotiation. - * - ASN.1, X.509, PKCS#8, PKCS#12 keys/certificates with DER/PEM encoding. - * - Highly configurable compile time options. - * - Portable across many platforms (written in ANSI C), and has language - * bindings in C, C#, VB.NET, Java, Perl and Lua. - * - Partial openssl API compatibility (via a wrapper). - * - A very small footprint (around 50-60kB for the library in 'server-only' - * mode). - * - No dependencies on sockets - can use serial connections for example. - * - A very simple API - ~ 20 functions/methods. - * - * A list of these functions/methods are described below. - * - * @ref c_api - * - * @ref bigint_api - * - * @ref csharp_api - * - * @ref java_api - */ -#ifndef HEADER_SSL_H -#define HEADER_SSL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* need to predefine before ssl_lib.h gets to it */ -#define SSL_SESSION_ID_SIZE 32 - -#include "tls1.h" - -/* The optional parameters that can be given to the client/server SSL engine */ -#define SSL_CLIENT_AUTHENTICATION 0x00010000 -#define SSL_SERVER_VERIFY_LATER 0x00020000 -#define SSL_NO_DEFAULT_KEY 0x00040000 -#define SSL_DISPLAY_STATES 0x00080000 -#define SSL_DISPLAY_BYTES 0x00100000 -#define SSL_DISPLAY_CERTS 0x00200000 -#define SSL_DISPLAY_RSA 0x00400000 -#define SSL_CONNECT_IN_PARTS 0x00800000 - -/* errors that can be generated */ -#define SSL_OK 0 -#define SSL_NOT_OK -1 -#define SSL_ERROR_DEAD -2 -#define SSL_CLOSE_NOTIFY -3 -#define SSL_ERROR_CONN_LOST -256 -#define SSL_ERROR_RECORD_OVERFLOW -257 -#define SSL_ERROR_SOCK_SETUP_FAILURE -258 -#define SSL_ERROR_INVALID_HANDSHAKE -260 -#define SSL_ERROR_INVALID_PROT_MSG -261 -#define SSL_ERROR_INVALID_HMAC -262 -#define SSL_ERROR_INVALID_VERSION -263 -#define SSL_ERROR_UNSUPPORTED_EXTENSION -264 -#define SSL_ERROR_INVALID_SESSION -265 -#define SSL_ERROR_NO_CIPHER -266 -#define SSL_ERROR_INVALID_CERT_HASH_ALG -267 -#define SSL_ERROR_BAD_CERTIFICATE -268 -#define SSL_ERROR_INVALID_KEY -269 -#define SSL_ERROR_FINISHED_INVALID -271 -#define SSL_ERROR_NO_CERT_DEFINED -272 -#define SSL_ERROR_NO_CLIENT_RENOG -273 -#define SSL_ERROR_NOT_SUPPORTED -274 -#define SSL_X509_OFFSET -512 -#define SSL_X509_ERROR(A) (SSL_X509_OFFSET+A) - -/* alert types that are recognized */ -#define SSL_ALERT_TYPE_WARNING 1 -#define SLL_ALERT_TYPE_FATAL 2 - -/* these are all the alerts that are recognized */ -#define SSL_ALERT_CLOSE_NOTIFY 0 -#define SSL_ALERT_UNEXPECTED_MESSAGE 10 -#define SSL_ALERT_BAD_RECORD_MAC 20 -#define SSL_ALERT_RECORD_OVERFLOW 22 -#define SSL_ALERT_HANDSHAKE_FAILURE 40 -#define SSL_ALERT_BAD_CERTIFICATE 42 -#define SSL_ALERT_UNSUPPORTED_CERTIFICATE 43 -#define SSL_ALERT_CERTIFICATE_EXPIRED 45 -#define SSL_ALERT_CERTIFICATE_UNKNOWN 46 -#define SSL_ALERT_ILLEGAL_PARAMETER 47 -#define SSL_ALERT_UNKNOWN_CA 48 -#define SSL_ALERT_DECODE_ERROR 50 -#define SSL_ALERT_DECRYPT_ERROR 51 -#define SSL_ALERT_INVALID_VERSION 70 -#define SSL_ALERT_NO_RENEGOTIATION 100 -#define SSL_ALERT_UNSUPPORTED_EXTENSION 110 - -/* The ciphers that are supported */ -#define SSL_AES128_SHA 0x2f -#define SSL_AES256_SHA 0x35 -#define SSL_AES128_SHA256 0x3c -#define SSL_AES256_SHA256 0x3d - -/* build mode ids' */ -#define SSL_BUILD_SKELETON_MODE 0x01 -#define SSL_BUILD_SERVER_ONLY 0x02 -#define SSL_BUILD_ENABLE_VERIFICATION 0x03 -#define SSL_BUILD_ENABLE_CLIENT 0x04 -#define SSL_BUILD_FULL_MODE 0x05 - -/* offsets to retrieve configuration information */ -#define SSL_BUILD_MODE 0 -#define SSL_MAX_CERT_CFG_OFFSET 1 -#define SSL_MAX_CA_CERT_CFG_OFFSET 2 -#define SSL_HAS_PEM 3 - -/* default session sizes */ -#define SSL_DEFAULT_SVR_SESS 5 -#define SSL_DEFAULT_CLNT_SESS 1 - -/* X.509/X.520 distinguished name types */ -#define SSL_X509_CERT_COMMON_NAME 0 -#define SSL_X509_CERT_ORGANIZATION 1 -#define SSL_X509_CERT_ORGANIZATIONAL_NAME 2 -#define SSL_X509_CERT_LOCATION 3 -#define SSL_X509_CERT_COUNTRY 4 -#define SSL_X509_CERT_STATE 5 -#define SSL_X509_CA_CERT_COMMON_NAME 6 -#define SSL_X509_CA_CERT_ORGANIZATION 7 -#define SSL_X509_CA_CERT_ORGANIZATIONAL_NAME 8 -#define SSL_X509_CA_CERT_LOCATION 9 -#define SSL_X509_CA_CERT_COUNTRY 10 -#define SSL_X509_CA_CERT_STATE 11 - -/* SSL object loader types */ -#define SSL_OBJ_X509_CERT 1 -#define SSL_OBJ_X509_CACERT 2 -#define SSL_OBJ_RSA_KEY 3 -#define SSL_OBJ_PKCS8 4 -#define SSL_OBJ_PKCS12 5 - -/** - * @defgroup c_api Standard C API - * @brief The standard interface in C. - * @{ - */ - -/** - * @brief Establish a new client/server context. - * - * This function is called before any client/server SSL connections are made. - * - * Each new connection will use the this context's private key and - * certificate chain. If a different certificate chain is required, then a - * different context needs to be be used. - * - * There are two threading models supported - a single thread with one - * SSL_CTX can support any number of SSL connections - and multiple threads can - * support one SSL_CTX object each (the default). But if a single SSL_CTX - * object uses many SSL objects in individual threads, then the - * CONFIG_SSL_CTX_MUTEXING option needs to be configured. - * - * @param options [in] Any particular options. At present the options - * supported are: - * - SSL_SERVER_VERIFY_LATER (client only): Don't stop a handshake if the server - * authentication fails. The certificate can be authenticated later with a - * call to ssl_verify_cert(). - * - SSL_CLIENT_AUTHENTICATION (server only): Enforce client authentication - * i.e. each handshake will include a "certificate request" message from the - * server. Only available if verification has been enabled. - * - SSL_DISPLAY_BYTES (full mode build only): Display the byte sequences - * during the handshake. - * - SSL_DISPLAY_STATES (full mode build only): Display the state changes - * during the handshake. - * - SSL_DISPLAY_CERTS (full mode build only): Display the certificates that - * are passed during a handshake. - * - SSL_DISPLAY_RSA (full mode build only): Display the RSA key details that - * are passed during a handshake. - * - SSL_CONNECT_IN_PARTS (client only): To use a non-blocking version of - * ssl_client_new(). - * @param num_sessions [in] The number of sessions to be used for session - * caching. If this value is 0, then there is no session caching. This option - * is not used in skeleton mode. - * @return A client/server context. - */ -EXP_FUNC SSL_CTX * STDCALL ssl_ctx_new(uint32_t options, int num_sessions); - -/** - * @brief Remove a client/server context. - * - * Frees any used resources used by this context. Each connection will be - * sent a "Close Notify" alert (if possible). - * @param ssl_ctx [in] The client/server context. - */ -EXP_FUNC void STDCALL ssl_ctx_free(SSL_CTX *ssl_ctx); - -/** - * @brief Allocates new SSL extensions structure and returns pointer to it - * - * @return ssl_ext Pointer to SSL_EXTENSIONS structure - * - */ -EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new(void); - -/** - * @brief Frees SSL extensions structure - * - * @param ssl_ext [in] Pointer to SSL_EXTENSION structure - * - */ -EXP_FUNC void STDCALL ssl_ext_free(SSL_EXTENSIONS *ssl_ext); - -/** - * @brief (server only) Establish a new SSL connection to an SSL client. - * - * It is up to the application to establish the logical connection (whether it - * is a socket, serial connection etc). - * @param ssl_ctx [in] The server context. - * @param client_fd [in] The client's file descriptor. - * @return An SSL object reference. - */ -EXP_FUNC SSL * STDCALL ssl_server_new(SSL_CTX *ssl_ctx, long client_fd); - -/** - * @brief (client only) Establish a new SSL connection to an SSL server. - * - * It is up to the application to establish the initial logical connection - * (whether it is a socket, serial connection etc). - * - * This is a normally a blocking call - it will finish when the handshake is - * complete (or has failed). To use in non-blocking mode, set - * SSL_CONNECT_IN_PARTS in ssl_ctx_new(). - * @param ssl_ctx [in] The client context. - * @param client_fd [in] The client's file descriptor. - * @param session_id [in] A 32 byte session id for session resumption. This - * can be null if no session resumption is being used or required. This option - * is not used in skeleton mode. - * @param sess_id_size The size of the session id (max 32) - * @param ssl_ext pointer to a structure with the activated SSL extensions - * and their values - * @return An SSL object reference. Use ssl_handshake_status() to check - * if a handshake succeeded. - */ -EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, long client_fd, const uint8_t *session_id, uint8_t sess_id_size, SSL_EXTENSIONS* ssl_ext); - -/** - * @brief Free any used resources on this connection. - - * A "Close Notify" message is sent on this connection (if possible). It is up - * to the application to close the socket or file descriptor. - * @param ssl [in] The ssl object reference. - */ -EXP_FUNC void STDCALL ssl_free(SSL *ssl); - -/** - * @brief Read the SSL data stream. - * If the socket is non-blocking and data is blocked then SSO_OK will be - * returned. - * @param ssl [in] An SSL object reference. - * @param in_data [out] If the read was successful, a pointer to the read - * buffer will be here. Do NOT ever free this memory as this buffer is used in - * sucessive calls. If the call was unsuccessful, this value will be null. - * @return The number of decrypted bytes: - * - if > 0, then the handshaking is complete and we are returning the number - * of decrypted bytes. - * - SSL_OK if the handshaking stage is successful (but not yet complete). - * - < 0 if an error. - * @see ssl.h for the error code list. - * @note Use in_data before doing any successive ssl calls. - */ -EXP_FUNC int STDCALL ssl_read(SSL *ssl, uint8_t **in_data); - -/** - * @brief Write to the SSL data stream. - * if the socket is non-blocking and data is blocked then a check is made - * to ensure that all data is sent (i.e. blocked mode is forced). - * @param ssl [in] An SSL obect reference. - * @param out_data [in] The data to be written - * @param out_len [in] The number of bytes to be written. - * @return The number of bytes sent, or if < 0 if an error. - * @see ssl.h for the error code list. - */ -EXP_FUNC int STDCALL ssl_write(SSL *ssl, const uint8_t *out_data, int out_len); - -/** - * @brief Find an ssl object based on a file descriptor. - * - * Goes through the list of SSL objects maintained in a client/server context - * to look for a file descriptor match. - * @param ssl_ctx [in] The client/server context. - * @param client_fd [in] The file descriptor. - * @return A reference to the SSL object. Returns null if the object could not - * be found. - */ -EXP_FUNC SSL * STDCALL ssl_find(SSL_CTX *ssl_ctx, long client_fd); - -/** - * @brief Get the session id for a handshake. - * - * This will be a 32 byte sequence and is available after the first - * handshaking messages are sent. - * @param ssl [in] An SSL object reference. - * @return The session id as a 32 byte sequence. - * @note A SSLv23 handshake may have only 16 valid bytes. - */ -EXP_FUNC const uint8_t * STDCALL ssl_get_session_id(const SSL *ssl); - -/** - * @brief Get the session id size for a handshake. - * - * This will normally be 32 but could be 0 (no session id) or something else. - * @param ssl [in] An SSL object reference. - * @return The size of the session id. - */ -EXP_FUNC uint8_t STDCALL ssl_get_session_id_size(const SSL *ssl); - -/** - * @brief Return the cipher id (in the SSL form). - * @param ssl [in] An SSL object reference. - * @return The cipher id. This will be one of the following: - * - SSL_AES128_SHA (0x2f) - * - SSL_AES256_SHA (0x35) - * - SSL_AES128_SHA256 (0x3c) - * - SSL_AES256_SHA256 (0x3d) - */ -EXP_FUNC uint8_t STDCALL ssl_get_cipher_id(const SSL *ssl); - -/** - * @brief Return the status of the handshake. - * @param ssl [in] An SSL object reference. - * @return SSL_OK if the handshake is complete and ok. - * @see ssl.h for the error code list. - */ -EXP_FUNC int STDCALL ssl_handshake_status(const SSL *ssl); - -/** - * @brief Retrieve various parameters about the axTLS engine. - * @param offset [in] The configuration offset. It will be one of the following: - * - SSL_BUILD_MODE The build mode. This will be one of the following: - * - SSL_BUILD_SERVER_ONLY (basic server mode) - * - SSL_BUILD_ENABLE_VERIFICATION (server can do client authentication) - * - SSL_BUILD_ENABLE_CLIENT (client/server capabilties) - * - SSL_BUILD_FULL_MODE (client/server with diagnostics) - * - SSL_BUILD_SKELETON_MODE (skeleton mode) - * - SSL_MAX_CERT_CFG_OFFSET The maximum number of certificates allowed. - * - SSL_MAX_CA_CERT_CFG_OFFSET The maximum number of CA certificates allowed. - * - SSL_HAS_PEM 1 if supported - * @return The value of the requested parameter. - */ -EXP_FUNC int STDCALL ssl_get_config(int offset); - -/** - * @brief Display why the handshake failed. - * - * This call is only useful in a 'full mode' build. The output is to stdout. - * @param error_code [in] An error code. - * @see ssl.h for the error code list. - */ -EXP_FUNC void STDCALL ssl_display_error(int error_code); - -/** - * @brief Authenticate a received certificate. - * - * This call is usually made by a client after a handshake is complete and the - * context is in SSL_SERVER_VERIFY_LATER mode. - * @param ssl [in] An SSL object reference. - * @return SSL_OK if the certificate is verified. - */ -EXP_FUNC int STDCALL ssl_verify_cert(const SSL *ssl); - -/** - * @brief Retrieve an X.509 distinguished name component. - * - * When a handshake is complete and a certificate has been exchanged, then the - * details of the remote certificate can be retrieved. - * - * This will usually be used by a client to check that the server's common - * name matches the URL. - * - * @param ssl [in] An SSL object reference. - * @param component [in] one of: - * - SSL_X509_CERT_COMMON_NAME - * - SSL_X509_CERT_ORGANIZATION - * - SSL_X509_CERT_ORGANIZATIONAL_NAME - * - SSL_X509_CERT_LOCATION - * - SSL_X509_CERT_COUNTRY - * - SSL_X509_CERT_STATE - * - SSL_X509_CA_CERT_COMMON_NAME - * - SSL_X509_CA_CERT_ORGANIZATION - * - SSL_X509_CA_CERT_ORGANIZATIONAL_NAME - * - SSL_X509_CA_CERT_LOCATION - * - SSL_X509_CA_CERT_COUNTRY - * - SSL_X509_CA_CERT_STATE - * @return The appropriate string (or null if not defined) - * @note Verification build mode must be enabled. - */ -EXP_FUNC const char * STDCALL ssl_get_cert_dn(const SSL *ssl, int component); - -/** - * @brief Retrieve a Subject Alternative DNSName - * - * When a handshake is complete and a certificate has been exchanged, then the - * details of the remote certificate can be retrieved. - * - * This will usually be used by a client to check that the server's DNS - * name matches the URL. - * - * @param ssl [in] An SSL object reference. - * @param dnsindex [in] The index of the DNS name to retrieve. - * @return The appropriate string (or null if not defined) - * @note Verification build mode must be enabled. - */ -EXP_FUNC const char * STDCALL ssl_get_cert_subject_alt_dnsname(const SSL *ssl, int dnsindex); - -/** - * @brief Force the client to perform its handshake again. - * - * For a client this involves sending another "client hello" message. - * For the server is means sending a "hello request" message. - * - * This is a blocking call on the client (until the handshake completes). - * - * @param ssl [in] An SSL object reference. - * @return SSL_OK if renegotiation instantiation was ok - */ -EXP_FUNC int STDCALL ssl_renegotiate(SSL *ssl); - -/** - * @brief Process a file that is in binary DER or ASCII PEM format. - * - * These are temporary objects that are used to load private keys, - * certificates etc into memory. - * @param ssl_ctx [in] The client/server context. - * @param obj_type [in] The format of the file. Can be one of: - * - SSL_OBJ_X509_CERT (no password required) - * - SSL_OBJ_X509_CACERT (no password required) - * - SSL_OBJ_RSA_KEY (AES128/AES256 PEM encryption supported) - * - SSL_OBJ_PKCS8 (RC4-128 encrypted data supported) - * - SSL_OBJ_PKCS12 (RC4-128 encrypted data supported) - * - * PEM files are automatically detected (if supported). The object type is - * also detected, and so is not relevant for these types of files. - * @param filename [in] The location of a file in DER/PEM format. - * @param password [in] The password used. Can be null if not required. - * @return SSL_OK if all ok - * @note Not available in skeleton build mode. - */ -EXP_FUNC int STDCALL ssl_obj_load(SSL_CTX *ssl_ctx, int obj_type, const char *filename, const char *password); - -/** - * @brief Process binary data. - * - * These are temporary objects that are used to load private keys, - * certificates etc into memory. - * @param ssl_ctx [in] The client/server context. - * @param obj_type [in] The format of the memory data. - * @param data [in] The binary data to be loaded. - * @param len [in] The amount of data to be loaded. - * @param password [in] The password used. Can be null if not required. - * @return SSL_OK if all ok - * @see ssl_obj_load for more details on obj_type. - */ -EXP_FUNC int STDCALL ssl_obj_memory_load(SSL_CTX *ssl_ctx, int obj_type, const uint8_t *data, int len, const char *password); - -#ifdef CONFIG_SSL_GENERATE_X509_CERT -/** - * @brief Create an X.509 certificate. - * - * This certificate is a self-signed v1 cert with a fixed start/stop validity - * times. It is signed with an internal private key in ssl_ctx. - * - * @param ssl_ctx [in] The client/server context. - * @param options [in] Not used yet. - * @param dn [in] An array of distinguished name strings. The array is defined - * by: - * - SSL_X509_CERT_COMMON_NAME (0) - * - If SSL_X509_CERT_COMMON_NAME is empty or not defined, then the - * hostname will be used. - * - SSL_X509_CERT_ORGANIZATION (1) - * - If SSL_X509_CERT_ORGANIZATION is empty or not defined, then $USERNAME - * will be used. - * - SSL_X509_CERT_ORGANIZATIONAL_NAME (2) - * - SSL_X509_CERT_ORGANIZATIONAL_NAME is optional. - * @param cert_data [out] The certificate as a sequence of bytes. - * @return < 0 if an error, or the size of the certificate in bytes. - * @note cert_data must be freed when there is no more need for it. - */ -EXP_FUNC int STDCALL ssl_x509_create(SSL_CTX *ssl_ctx, uint32_t options, const char * dn[], uint8_t **cert_data); -#endif - -/** - * @brief Return the axTLS library version as a string. - */ -EXP_FUNC const char * STDCALL ssl_version(void); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/axtls/ssl/test/Makefile b/user/mpy/lib/axtls/ssl/test/Makefile deleted file mode 100644 index b1d7538..0000000 --- a/user/mpy/lib/axtls/ssl/test/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -all: - -AXTLS_HOME=../.. - -include $(AXTLS_HOME)/config/.config -include $(AXTLS_HOME)/config/makefile.conf - -ifdef CONFIG_PERFORMANCE_TESTING -all: performance -endif - -ifdef CONFIG_SSL_TEST -all: ssltesting -endif - -include $(AXTLS_HOME)/config/makefile.post - -ifndef CONFIG_PLATFORM_WIN32 -performance: $(AXTLS_HOME)/$(STAGE)/perf_bigint -ssltesting: $(AXTLS_HOME)/$(STAGE)/ssltest -LIBS=$(AXTLS_HOME)/$(STAGE) - -$(AXTLS_HOME)/$(STAGE)/perf_bigint: perf_bigint.o $(LIBS)/libaxtls.a - $(LD) $(LDFLAGS) -o $@ $^ -L $(LIBS) -laxtls - -$(AXTLS_HOME)/$(STAGE)/ssltest: ssltest.o $(LIBS)/libaxtls.a - $(LD) $(LDFLAGS) -o $@ $^ -lpthread -L $(LIBS) -laxtls -else -performance: $(AXTLS_HOME)/$(STAGE)/perf_bigint.exe -ssltesting: $(AXTLS_HOME)/$(STAGE)/ssltest.exe - -CRYPTO_PATH="$(AXTLS_INCLUDE)crypto\\" -AXTLS_SSL_PATH="$(AXTLS_INCLUDE)ssl\\" - -CRYPTO_OBJ=\ - $(CRYPTO_PATH)aes.obj \ - $(CRYPTO_PATH)bigint.obj \ - $(CRYPTO_PATH)crypto_misc.obj \ - $(CRYPTO_PATH)hmac.obj \ - $(CRYPTO_PATH)md2.obj \ - $(CRYPTO_PATH)md5.obj \ - $(CRYPTO_PATH)rc4.obj \ - $(CRYPTO_PATH)rsa.obj \ - $(CRYPTO_PATH)sha1.obj \ - $(CRYPTO_PATH)sha256.obj \ - $(CRYPTO_PATH)sha384.obj \ - $(CRYPTO_PATH)sha512.obj - -OBJ=\ - $(AXTLS_SSL_PATH)asn1.obj \ - $(AXTLS_SSL_PATH)gen_cert.obj \ - $(AXTLS_SSL_PATH)loader.obj \ - $(AXTLS_SSL_PATH)openssl.obj \ - $(AXTLS_SSL_PATH)os_port.obj \ - $(AXTLS_SSL_PATH)p12.obj \ - $(AXTLS_SSL_PATH)x509.obj \ - $(AXTLS_SSL_PATH)tls1.obj \ - $(AXTLS_SSL_PATH)tls1_svr.obj \ - $(AXTLS_SSL_PATH)tls1_clnt.obj - -$(AXTLS_HOME)/$(STAGE)/perf_bigint.exe: perf_bigint.obj - $(LD) $(LDFLAGS) /out:$@ $? $(CRYPTO_OBJ) $(OBJ) - -$(AXTLS_HOME)/$(STAGE)/ssltest.exe: ssltest.obj - $(LD) $(LDFLAGS) /out:$@ $? $(CRYPTO_OBJ) $(OBJ) -endif - -clean:: - -@rm -f $(AXTLS_HOME)/$(STAGE)/perf_bigint* $(AXTLS_HOME)/$(STAGE)/ssltest* - diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem b/user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem deleted file mode 100644 index 0c8c19b..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.ca_key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAsSMwkpYHlwIsi1oxllJLjAPjjycx9t6Q3BOzXBSoZHc1wA+r -QVuKHarpe8tYOKlNP8b79ejbCv/1U3NlVkMJJtLZUPtDwTEwUZNEG17ixS438mGI -1AbHXvwhPaoT24UymEOcbJxAZuClDfzKpN7Cl6OzN7Ox44gHmBCBSnUhRAnJYxD6 -x8wBLw8HdH0bMdoc2+H4KyW31uMGva7C9YlUCPVQGPJsTP1DLRskqy+zO1NERUTO -XytHeYLlh/X/o+NYVvUf7WKu6qC3I4HK+OZ5OW3E+EaE73oYRmUVDaVavL7bRKEf -2NSbzowU+VsFEnyXIF7YnRFp0D1yrMzaC49bDQIDAQABAoIBAQCwOrNLUunwKaCJ -b00gIXW5sfDGbhc+ZUU3Pn5V4NN7SEJ4dt5JYrnxNCWgHLkDfiQ1jFEF4QlzUx0O -TiMGhCDpuCGueJx66uYIcnvywx7XT1kn0jNfxfK6JBsqDzg8ULL6W2GXiIhmEZ8E -YHh3OIvec2WMyED1flMXzWvj2M4ksfMgZH290T9BSxzlEj9X7dZu55K4sFtu0XNi -7uJDB0vF8KfW5gLpwj6pd7i32Cm/Pgpl+7lcqMNpDHo0U2dMyWeH1EmWinS4rHxd -mGDm0N0qK4BOYAJdasq7HwRjzDZkAPuNqcH0gOzSq3aYCI2tP2E6IvprM/vbqA4I -ooo+GDJhAoGBAORiphxweuGBRTpSqoi9qEICM2WMC2NZW8bpFyWn79CuALGzvvc+ -Buw8W3LVElByUyTVWBnBQQ1iXZGe9f1x2P9q8R1Bdl0rpePg3J9ff9674VRLrcov -M85/NUHkj1fJ+2CkCx7KG5BFm3GaAb74e+7MceEW/eErMmCqtNgkR2Z5AoGBAMaO -O9SnVNd4wgnJAjVgN4fqaXWNzZz6NYWtnFVIcTTO7vU1P9t5NjgcsdF9+SnLA/jV -Ylo5Pl0fLPKg5QtIvlooZjXB8hgKVjrVGRLFt9TN0tJMeJ//11Bo88MNMOf0OQPg -i2OMWI3w/oRFJthmpeYWOgXNlLOcoSW1LsnWR0Q1AoGBALAXi+KTq3tiM+FzSb/j -E+/JSJ28bC9u/7+Pi2RiZxrsfuaFI/H4ZlgRdaVFujhC3e6hfKtnAWRzepfEDAEd -neXaLAyVo9DUzbS1dQaBGNPA400eiOJCoNxP4t1qgEd9GhB6i4Ry6uvDb8YYq832 -Q4BtLEUUeC38I3y7QnMBDfhpAoGAZ13InA54xqvhKELy2WK7xhAs0rv93MkNcAhP -qL5L4RgRoqoUEmfp6BBYKh2Qx0cfTD2aNCo04znFppJIazV1k24Qt8+9/vHyrjIe -GX3BFBIKvNx+t5zzNLNOo66MVVT5EaGmLy7zMwHRHn75mBLoLv5HOpop3c+evQiz -0POyqjkCgYA2+ql0jS7Qbk7EPyFXftQhHcD/Ld8TKjonShkASoudSEHKwuQGBuit -ftPsg/E5YfhlRpQB6p00kXb4vZsdpFV38eXkyLuLwg0kbpaLedahIujIENNvWP1w -89T/ueiafWPqvwu3M7sAkkd/ReAQ0LcPwrsBHlOk0uujq+WV+b+Xfw== ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer b/user/mpy/lib/axtls/ssl/test/axTLS.ca_x509.cer deleted file mode 100644 index 7bde7b0a4231cedc65d7bbdcb877cfc56e79ade4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 786 zcmXqLV&*ewV*Iv%nTe5!iId?;!n6&HOIThQ@Un4gwRyCC=VfGMWo0lhF*GtTU}Fwt z;S$zNtO)T5RtPA{&q_@$QE{YLH8e9c zGBz+WG%ztTj}qrKHZZU>uz+&OG_{FQ3E6p!tPIRejQk8hZ*Va+F)}i2R5qA2jeR@*u=Ewc&hTrZ@xFftdMr1`wx#1%)N_tzJWz*C4um2Z6jtKiI|2Apes|DMY8&Cas zR%w}gn@ECYj)k)bI0{DSQw zUDgwX5*BDDADR7FsNllkf=%5FZn@PP?f(RtulByMW}}Pv#60dy-^<>Hp+`lHzr5f5 zSbNXgyc)$dZf5IERy|Cy{1tTndehcj%{Sjk{F&W!-^1%q=0djB&5aS|=PR5)Ke!UN z-rPTa?>UY`%O>4({MK4!c1u-9;Qgar4KshLPEN`wbu$m_dlmBQY3}EhuPV>_&3b4T zQaNi$vi9a$gJ>lWmd3T5XTCL+-t)BD!|Gnj8x_Q4E%m$Y!U?ezlh^PH%BT6x+S$o_ z*mOzgQU~Ved#nU?A8XF~I+L$(b!5ZmQ+Ji0pdkmlHgD7Vz zCm9>FJDCD@>~r}|@snQhXFpIWl5vk2sM{QxjI_9P)WipyQj*FPWsvp@aSaHp@pMDK z$MZ1uGwhQEoVP#A-kSi+dF@r}0bd6_%=)sMicLuiwtg#<3Y7GXU1(kJizJNz?rB8R{k=4>M8Z{jx$bSb z;tb0$e|023ira) zD>a(ty;nL}MC^RHtzL7Qc>{bsjm=OO9*Eb+*ftfQu80Z%gf49F03=jRv$9vannCiq zf5{60qu}m6-rO}9Z!j6by%67*uwJK$%i(EW%Y3`v zEK6MzCSvG=;jW{#t^^ps&}d7nJ?CA*f8PEzY6f44WRx=aquSW0uMo|h^4N5oU#CUY zzPn(1I=F_2Luh4{P}g>Lw+t71V^!Z#OO^Sepe==Jwey=>11<+a%YiDyyv0>1%F)+lUE`S)`6xBS@V)O-(`jMu^s6c^<#;>i{2IW5?bTxuZ~w%dx787P?vjtU zyeek_O^XX?nEBTi*5i#QQZL#ra;^+llVBeDl_hR{TBlMCL`Xov*IvWw@7Mab>K>qx z91lbWCd`Ij^a&hPw#2c(_^5Pcxmu-5%&Fk~WTNIbGwDg(YP}?j6oq}T(+M_nCrTlQ HUEnaSBD_pH diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 b/user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 deleted file mode 100644 index bc28403..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.encrypted_pem.p8 +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIICnTAcBgoqhkiG9w0BDAEBMA4ECLZOmsNEeDZnAgIIAASCAnu22JX3BRRr9cTr -j4x62+iDbrqcwmhQkybM1xShFgWObY3/OQf1NJfH4DO4zGQN45ZN0X9zSUVRu8Dd -ycHls5qsROJ96PYQ8d1xnuh1C9TWmFiLieM0qUyn35raHcKPQiBl8PYHtNr3+m0K -bsql6T23hE5ZjVhbRtcRdRd9MsQeTZ6n4mdWPEhzN1+rmSPV8ybCbrtJl3/Dh1v8 -LnswXB92T6WcmHRyRiNsbAXR9SQkOaXFZ/1RUXDNqoRYZjlWPBWdcQf48mzgaDjq -3RXF1mjbOlX2x4/V4qVwH1qZADlT38fSRk/iVdRfureS+wfOuJgJ/g9Riwa0o41K -2q+sOEcTOv4rShXRGp/0ckeuwhARDdSMymlSBhgBWdf14qdgxCx0rAXYlRAc/4Ze -Zl9ErfydwdUfDJoPK+QlGZMF//hFRF+vdO/wJHleLsels4KaqN9v/sB+BrGWaeUC -ScKMISixquCwfWi2qGiqLQGsxHn0d6ejiMblZR4kTf7dcuWVWGXdf5VZqxLNP8Xg -zzjjeP59OxHRVH0ytGBUejTehcxWDKq+6ESAuujzVXa0v1+5QzZXsJ8rPyZOINzj -bdpN4Cr3tZj9ALrNzoC2oG62+OO45U7lg54cV1nyrQ2QiI4XFnt0WA06K1G1JrRW -a/y6nZkntGybbCpuuIBiWl2FfdcTepctiXcJ0vCYqVNOTT4L2Y1RwajDzALhgb7e -wOy0eA8gmOmMLNozSlMV7siL0LeE1WlotLwK+AHMU1lmPMqS7jK9nycXtZyg4IKl -eBAnW052fnKZhT4zNlfJkZqpcp6YWpCU16PWx6L+/FDzFPzswluHyfB72oVqRniI -2A== ------END ENCRYPTED PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_1024 b/user/mpy/lib/axtls/ssl/test/axTLS.key_1024 deleted file mode 100644 index e39791ec8b54056d5bc75137a9e8ade3ae6c29c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 609 zcmV-n0-pUaf&yIv0RRGlfdIV^)Iz9qhg7P$Iv$5h}{RNh7CW>nIocvcMk#s0RRC4fq*7I z?3Sz4ABhf~IM^oz<+cR?jmdY*G%E`ZV8Z$}T8fHu-F2i?}!6^Sc!)qaY+V?qk@ zF)6?K`S6I3iozmp6(+Y{TUbOKJ9z>@0O9en<;Z}OKu~lP-Lmp0Tns(HU+$bmY!d+A z(Ak6fkSv7qs>0p-&jUe-5XQS+x3(^(9jdzfN^;nmt%wb36#_v3);1&aU3bXSNx_r; z$_?wA+Pz08bC;k{*Gween+rFt!!fl_VhGCR@0WW+pxP@Rzo-b4(iR+vnepEy(L$M% z0zm+=LF9hlAot|)`A^YmEe-MM?3_C0z?8Zt;(WBFp(FO~=2KSUP%_v8j_b#Dk<-dP z)HEP`EBh}x5OT2xR<_LoKps2t0}XUEvMs#U$fbBCgAekXGKg*@K!n1`iH`Q1TUgjXm-B`Mx#RvQtnU*ex&x diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem deleted file mode 100644 index fd8226e..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_1024.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXQIBAAKBgQC9D9RCqHSHVKq5Oh+Lzr23ZftAPdARmpzcgnzqqBfhdPMFDmHB -wXiKsroVIlr/m7h6Lg+It3TeBJmloplTi614WjHtvAHn3+nsL6BdU/bmiqDIbUFF -YyOzz05QHyjfNuJz39ahs0ZPbrsNm++o+UylcaGI3Qephg0/zZkjooR3DwIDAQAB -AoGAJj/slqvUH4kOnTjYJwXlthQI1/9peBZKxAYWVbc6VZ++hvhY6MVGqPDt2ta/ -iFUt5nIpLGTJXR2bJDqYQKHSr1yrI+Qz0OpgUud6nnNfLoDR3G9HD5eANtIwB93W -1xWJK3TVfoq8Y0IK8jEpv/n58IiPisIibhUmt15bWEQcO3kCQQDh8bLlyICTQFB0 -FN2y8idcDD3AX+6cRWwTAN/Q2YP6kCyE8qrC3fvPA0GIEMa7Xre2LqYdqrr7SnLY -mq2IDWoVAkEA1jYj8113yNNJwZP+yg3rm9q9Ryhzl6BQ10wk35sLN67DMbVPYgjK -5e+Xe0Og2isfv6gIk9IWHImZ8d8m0UKZkwJBALFB5H7fIPfk8flP0WotDfHp7Jw6 -5sCUuififLSloSP27eZTVuJQMtgCjuvHdZHTyj7UNCB8K/svOhBysQdWts0CQB47 -8gMNdDSyLbzWyKV4JYMP8psyiG4kQITCyImO9pxbXE2Ny7CIkSq3EGhjeTaR059X -di52/ov0l/fdiTsL7WUCQQC5r78JyZAm83KLv7N8529vW6OVuJ4Duc+gU7oywdOt -hbt5SAnWP5zZN5ERDQTVO8p0XRyRjT3x+Pm+NdeyU1Ad ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_2048 b/user/mpy/lib/axtls/ssl/test/axTLS.key_2048 deleted file mode 100644 index 00989873bb903c8c1537d4318e535fe068d6aa00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1192 zcmV;Z1Xueof&`=j0RRGm0RaH{T6R3AC2^VxXLF))22BHn=^2*8_o14xzC`P*=rH@6 z?q9N&et`5QFL)W+(l6XVbV9s-!tGHNzp`upSmteb&<0wmV){%MxUPyI4%}1$so8x0|-eF z53KPPtq)(3fr9U|R-lCkCHu0BSqDwK7RiZF-j+6sH-#U^)dhS-)$f4D)6-0{m`T`G z`Tbwxtpv2E)FiZC|-?&eX=i#pSP=0JEA z`*pDo=d(>5BYeo-P6_TWG5DC>*nJWe!wIXSrR*ifFe{Iz);M+Zz{jwH z7={XO-&;!7t}aIj4&HO+t{m{TDFKj~5b2S1EX8coAi^v#r?)d`*bnMt;~5F4-F`V= zz&>OjFDoICVE7Q<>Kj*Lc*Hb&&PT@(v20NjJ2PKA0?ZuDilWu=VCv63J0Z@{) zDxfm3MqM7$mYQie95%BL9ghXFsRDt40RMqc^_O{AEjs;TcPsrwZTOJlLJg!&wOKcV zlMOBS{g{a*a{(PoDPg2sZ@#fm0b~daQ}Y%}q%zMMBH*+dZZpJxyhL6(mk3~Sc~?Kq z$cT)V=o+qS31(OWJy3cj-}d$ZJydp@hI>ixT8%3rt2m|GMobPtNhKJ0rdNkCLjr+; z0QuG#YJ+OL(ruGCO=l~|qrP%7=d#>GTjwB1A}gENm8)#5_<8v|P1-lqtdd-Y#ds*n z2S&ZNC!G0rx&-y#(u9bIlt>^{*Oia_)?SX0=CwiHxI8suq@@I(Q~I7lNHIRzLTF~~ za~rj{cp7VF%&IkOaNIl`*x#O-v3@jP2LgeC0Nli^1x2fN3o3HyN-%ezUg{&+8)+iF^8WCm-LE4e4f0-pB70*JaNYbk69WV847=TWm`?k zCjxO8j7flrH>@xnRz@w@sxFy3hH%?>FdeE?D02hXZ4*hE{d7(IddsZcxeH zYGjNKF`$KI$aFILIK?}Etd6n~-QuCvT4K!EYn6*K-%YmqdN&s}sLclAM>D8M$)rUa zv8(jlPBY9Nc{`-cUVyD^l>MZ$;cQ-RJoHG}0)c>43rt-w_O7VyNPF?A=_BhSAAW2w z<-kkl4oJV*6MN5+B$ye|7ZdX93W12hQN)$V;;qt2CgO3wyG;p7+x2Swvid>z<3P_D z6FN_Nb}2vnGBE|+R~O;bVM9+hq5>7uyc-!-KN0JNO@!8spNZNsP`HMyT4!Q_(+cBF G5|Pp%l0WbO diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem deleted file mode 100644 index 5ef719d..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_2048.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEA+Vp2PKclcZoKZ3OicQZNA4XpGZbD96Gasb5E66voMPub7l+y -ln6A9CYveBna0i/cQHRCwpYuzzbHQgOjAAw7rcveiIqm8nJMxA8BFNMJCHv0knDl -RT3H28xoTt08Z/MCfCYyOXoVsJOS6BSOSdFVyzhfU6nAie5iskYnmKecmhYaFm94 -S8WWJMNgEvwzPyhdmE4rpqUBHRSu3zPgHUnRRIOfui5KdZGzKpaC+i1Gn58MOC4W -L8kguEMDCEkQD6zxFq0PX5GBgu+zVqCFByX7soxZB027FsmJUN6WNoo3hR/H1QV8 -RdXvgMbT00yymEnYVfn9ZL7nXShKI70Pi5Y11QIDAQABAoIBAQDQQBrrgPUmsW3r -BIowNwDu5lHNizrTf+ZAeBX7dbEP57NNHCN8yN5OCe4vMfis/kfGlNKEzQT/DlLP -8VWa3pyhA9kw1AumBIvUWmuexrmOmmeiPiNc9sIJ8edTpjWi4zO6F/RuSGYA+N8C -cNh9EhXDCaujpewlxjArj6fWOHXzwMewghiGCm/fW0rWri5HCQ7ec+WuHPC2KQGQ -mRDpkXUsxWzTIMIsMKe3M2jYD+pk4xkJqN1+OV/APmQfLyshkGD4EN/qG1dieMQ0 -e85HxxCxbFETOzip0+pHXMbtxY/ok25/SCdtBXkBUJK1KqAysEZdHtOWmmk4HDaz -Dx2PBbKpAoGBAP+BT/WXeVgtOv1idyv9RG34kOJCDaROtVk3g5MNLfj9mIklcwEd -SylhpFxvvrFQAWQIDFPzFkukMs8aIuC0Gm4zxH+8RF45lwhgcXlXP87IiIyW6Bqu -aglmWAM9UHol3/b2AD1UdpqGe0nvWo0rIqs4pdtGTA5BSSUYeaZXhzFDAoGBAPnW -GWqDarzSbZM4TWcrx6O+cjLnstxDW+cgSCIrm9iVq2ys+Hn5O03aN9SsklyGxXgo -ygdGvbYnnPl3ugT139KEiIeUSCBU15WP/NZejpHmtUHduDw1Y6SlBJ9T+p5CSDE+ -2kJoZu1zG7W3eBprZsyqNWtw3Dwc2N+emrF+NF8HAoGBANzErAVFq6if9E+KK/SL -cvwegXmun0DwbUu4ZuzBv45b+NfPzu4QlKgd4TmpqDhnK7x2I8jJyuLy7p/6Mla7 -5/Z+rnO8hcpwsmqfgozY8Z5HsYzgu46KU77penTaHtZcMYefCZf0ikJ8nrzEnxZJ -RjxxxwWPWRocGQp/emVbTconAoGAUClmFkr8YIGULvyNuWDOubdNpQ+6z/m87zfo -bS5Y3vGHA2OshlZ1tNEjwNVuUMndamSMDjGghWXIdDL6OMU7f6yOshHd4qHWWmLM -2WuVizLfTbb6ejcXNajNBuJHM6hIyaRFG7Gr9NxOM8weeTukzF6ArWyU/aSz4Wxe -bjz0SNkCgYBVC0xdMPauqO1Ie/Gp6SPrIx9+bDDlwEvnDki/2RN7z5IkmBnRFxPy -6wqBiMFRxJXI4q3SSSbicb+7TQlK2/Vq/bL6QfjjQM8ZEzpPenYpP/wyMQXdVxfh -1GFDTzeiAhXTvBsZVj8R64VNhNaNn4naMlC4hqxaZ2KA0wrjTRKR0g== ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_4096 b/user/mpy/lib/axtls/ssl/test/axTLS.key_4096 deleted file mode 100644 index df8a8fde95f87836187040e8746243bebd557e15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2347 zcmV+`3Dov5f(a)A0RRGm0s#QP3QnWf^s^<%@HvE#|2%kbpk<#0x@QOp%A6JL4$B06 zQpMDD2u!G_%q}k$mC8P>+J$g8>^C4Klpx}(&t0eXjgNSz2~a3rc8R(sQ0dkEQqWOU zMZI#r^XVAit&~0Z$s0Q#j9piF;Ey8_Wo}z)3f1H@Q{hx^U7e4PW=*2$FQ9Q<#l{P_ zwkao$@0gatD@@2~i9#yX@%wF1*1A>luI?)_5iI$Qr6##63}lIV9yz}&8JWgFZWjGn zn_{FYqAgeTszHFOo(QGXj&mfq$5>Ni1FiT|t@2r#IW1%u@|t*BhHvZOg~# z3gv%fj)MK=x8KnU{G-Vg4HL!_8>R!n)TXWMBD$g5GzqV%R1qOUo% z$%26b0|5X50)henB`H~QXEoUT^w(Fa35@!jtKPl~dB#d@$;U-e5a5mU zzH_JursW1el*jZR^pxY^ApYQ2h}zQ#3w@BMjBCP4;Bp{SPOpTmYbr4qu9bDljSSm& z0fEI?Q9sw&l90q<0i~GvW$$^Im9dV&PuIC(FyzozS{5PC|nptna#& zMdhF^A%Vx+RFj}~AI1sc)F{ztqy7nO+*@&nHYJ9*d+K|I)rh`h#248>-wZ=9lmt1t zsQzN6HUZEWcUO%0V?1A+2Y1n2N6mYX7gqf7Qt%Wvwwhh&Lermw^m*rQuDv+mrFw7j z39c=jQ1`8v^)M5N4p&RoN37kd-7O|RFNA*v1XeXgk(>CFuaZpWc^u@pb3(u`k#iV6fhkx0ypxWj72$-jbw#u zNguMfE%9jNL0gpoJZsqDA0)hbn0O73zXm=?(p;NijJdiKV+fi;4)j2T|?I&T+<7kr*2h59B z>1H#x<_M}{7x6ThvP}8b4Y?8>Tg|y5z#E@GUd;+l<-!sLt^lw_wg@-$8qZBXO2c5C zs3-`h9zd)d1^anJd}0Tbhp0LfdpN1h@vVRAUdmMA@mGONU)GhHiM$k|s*RQ$Ikr6L z$O}2MEw`O7(ZZM-16d0#M=piOL}Gs4oT+3*bgLH5w`j%!5h)G-%XNQ5&wvPEt$O{g zK)p%LCR@#SZwo#I!o2dlG93S#?&hKh0RY+9MDO3_$)TR!Txuq4@pQ4bDjIjd2{`>DItc$>l;26> zNIOtbh!ap0v%SYZ30InfvJ+bVgQd0!qfB8MU#Tq|SSsA(fNAw|{Mqy0!i+4B(58%Xu+2L=R++!W1c%WXF1Y9xZDb%Mc7D>_yDs|rPRi*_@>yY0GWKE zmr#8v4<}lQ<4w8bR2@|GF$4UGnq}Acmnb__*Lw>H1xW&?1_bjs&U?%JbkKntIN!cn zA)uCqL(@JDz(PC@_Z=6)17tt3jyEXH%9Ok?Hm;qWF4; zx^5dYje5j|($8)!ETTCNR1Bx5H1pe>7fjq7D&)@gqg_ZV1kb*&d3#T2+2L5xDQd!^ R-KpUHmbT&ib)P%cX;_ZKh7|w+ diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem deleted file mode 100644 index 73fb75f..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_4096.pem +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -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 ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem deleted file mode 100644 index 470f29b..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_aes128.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-128-CBC,7BFA0887B7740C1BBA458D0362E75F89 - -aBIhF2zVGRMFZAWg8s11WnxoTQhGabdzchHBxPltnipEgvwOM9FGmYnVIDsFPvyb -hSA2HgmN972SPeRG4hITzrIXiRZMBOd6Lchz9p2Ui/mqkR6RUfnUBkUtkgxGymSa -oD7WAmbpNG73+7KX4gV36tevC1dM9lQzbClhhXQL9FH9LFh11cS7ZFa9L/esWHbb -sxgicR8zG919UEA+XvhLPVXpYD3AVHTcyEHbPWiGY49SIEI+GOcLi6rvxQizcXKY -pFtmlk/jM06OdZWur5/qLg3HqGP/o8GUjjA6KuAe5SIWVrmlkHCYHj6c1KFLVQJZ -7qAUNvjVaELXOc3+SE64Fl4OMP/4MiUA5WJ+gcdIKFtX/qksjywzF7goNTsxB1ZX -8g9JP6m5BF2VS/Woz+9ypekzk7DEKST4Knh8cYBNdz6yYwX73FBb93jk1aPMXv2K -SzhupTSHyAt7ddvXm+QYXBrklpZgUcuvinrkb7TNYEDcc2h3iDkLMHhI2VW0fiSF -JcL2DZWLu1UChg+Nkc43+9f8Ao76tjJHdV+IkWfINlKz8cpKthIfOiUSQWYK4Czr -0E3dyUrljIqFyKmZGokQ2QH+kdMmcm2/R+8NwL4s0Y4k1ylB0mZ5+A55t0ESaUVC -8NJtoIMrLz2pyhf2ohXMVepcjvR/Id8vNxSlLFResmIwSo4orTZOnsHBlQqm5hJl -9dr8G0o7n7WVfGbHLlpuPHoKegn1OK5xLbDbAi14HnZIi7/lUnbQHMbFFBjyS5EE -v+SMbI7JU+5zeJc34WLUTm1zll1ZNpFH/76vlP7tUWxYqVUZfKYHOndqS4b1rAs2 ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem deleted file mode 100644 index 5e9c5fd..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_aes256.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-256-CBC,5AA67B48694516B66EECE19E0F3BB048 - -eXbuyN1kJR84JMhFruS9yeJ/WnyD0V6h9w/6fhEcPfxW0HmFqgIk35IE4c4QYazZ -aMC0J1S19Yb4kKnRd7j0+92IDBw3B7zeJKjPDrcRDSo8R8K7O7+6MYwcmJJ/DZlC -yqcaHr3cJEiS4I8NS3EdffffFA37Uf2O4C26b96ewg899YZXmPtai6uOvKbF1A90 -aRV4PdCpJdJq0q69VfoSeQ5p//Wokb4RfDGWTNxpgclYr0SK2F8qfITjCNDbqR+E -r+6tRsy9VcHVRjswuewU19HOQNQzaPlIiNaoGBGvOVRHLdE0s8b1Czyh3oeuRAZi -EK/SPEdZ5JMWbtxpKi+rdqFZhW3sGE5T9QItYqAWezScOCcuZw7ivVITWj0HuAJl -YZnkL4CS2qMKfQ7oz/YBAuShDvfl/W1M2YXt8caoYIox8NWnGaifHbk+eP7sQRE3 -UMA/71gfz4AOUSKOWTNCen+qeAImyRi++6kFOVyAZnmvGAj1INv76xh6tHP9aDN+ -0ROlEMeL+4EyqEeTeRL5+i9xEGtA247hMjtwB6i8SDl2N9RZkIzGOj6GmJpWQhHK -qRSu+PvoDfSHqfHYXof0rtvCuKj6pAhYgKeL5Ycfc0FtJX6gTvErlKWENUrsJxgV -RJNcRbltxcOylmdYP2tUe/PxQCSFcYIzFbQbXJDoZ9hMgJRv086fzn/QWiZEx59o -9r8kKQrYhKjS34Aq13ghFBf/Mr+GKrB8JtO5DnlC4N9AnapVlDgeZn2NmXyVZygA -mcIq5MTJcZzCdX6PdzNVBsttRfYeItN9M8aP5q5YodBfuLXPOvFhV2J7wc5Bgt4i ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem deleted file mode 100644 index 5c9a845..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_device.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAvV0Pomdmpxx7s19ue0itPlPusWrTSwofoWEU141dp7cS9eXc -SnQV5pfvYvvw21HsZHy+xW2cupjQBzvqPtrrqAz4p2E9VHTMuzvDSScj6GU0BUD+ -GQ3qthLkXMfh7pJZFN5DYtVqzSE+ufZlYlfBqsT1BON9eRs2fTf6OnMFApx0ANjJ -yFElu2cEf3iif/3Z6PF0iUNtKaDNDVvVBoiRa9mUuj4vxnyH4HmyzThp2bXDLMUO -Viz/WWZs9Nl/QoJduyJZGEii1UM5VS81qQnu2dT1g/E0yPXwtOQUnVgjSMPfW+CA -yJ1XTdSwVDSsyXApyxxtSEYbM81t3GGvmmCf+QIDAQABAoIBAFFO4COvmlgu1r6S -P3IYJqsYhukPIWKbGjHE6ZoUTR5ycWW8KPafGbhFjLhHzYeeiY4sMg27nwxQCSLS -CyaqAX3K9AmKqzbUYAQVCSkj8TscGVYYLgK8Awfi3MMp4Ez78dwQA4cwdAdYOwLG -VYoAfFvC7iIHPB0AHklt+7eVI5WWsYlOIf9aS6+PDVii86GVoCpBE0eNZjE3JJo7 -hC0ctcjOqSVZRPC4p5KLFI8QkwyEK3vstyIiQOKSCFbZIn5Wi0+d6A9K96WhwssM -OpmenLv3xgz4zrUkRDbv0cPAU+/e7ZVPCiIbL/Y78qk3lBjUuyztX6fwQ/eDFadw -BS6LcvECgYEA+Nlwgi1Kzcd46xKG7xryI0mYjHO4cbZMsTcB4FQK5xXkGlg6j+WD -NAi/LKDJhaKcBKIYDhYi8tY1ye7JSDmyrPfZ0WvQF8K4yprUAqidNIuwOPMASjTW -CEBgTfMwCATNYNiaQ8eRuTLyknF4I2lrc4Ifby7cYEZrJ6aLGyolvdcCgYEAws4J -rGQS8W1DmzrL9mIDlSUtMFkTWqhx7nvG4lCYWVGpMByiQwf4DRvcqmXhwPr0syaj -qE6nu8G3iuOywSx2qrPX1a6NzeoZZybOSL7poaVmnpxgtS1xXyo1Bdc5ZPPOom1T -apb1QXHIPFVFKsuKsrQvyXfYLFGlQbYh3TGrtq8CgYEAmDqT+95vI0ECNHNp/f0y -4OlVm53y2AUYF1S6Hhvra3/VwVP1xy80uvEa2dcmUEywOplaM8vQ51KpJvWfRkKd -jfg01Eqqys5AsxhR16qEOK+3Rq9InxyBThzrjOPWnyEo7jSy8gG0oGGNSI6HWspT -hB620hINmAub426bLCv1WJMCgYEAkdfBZEAT8o30BH5TfyVIO1v25fB6TfA4Q+yF -LKBcPtqlSPDXBkosClxmq2fVSS5ZDtsJwZMJfsb8C86G4JrSSOCV4VNqtNPjqtdh -rxLHRQ7YsjyvJlVcQHwP8Ex+mrbxZ6djwTQ9b36pA4pvWyfBsiK2eCXyQNPrXjPm -THzIat8CgYAXN7CO+EUKtBil/r3PTj8FpWxvfZiKMbmktiHKD9ntcN3te2hrOWVs -1SmrIzr8/eBIsh7OGS3LUZTb4wKGtY29N6fTHuoA8pYILeRcJALGZnmrsTyFDzGH -iXBSkZ94EXpywxWHAEglow028nQ9UNugKk9SIkpg42u4vrqhRitMqw== ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem deleted file mode 100644 index 7c1cb6c..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_end_chain.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEA7R4S75j5ZfknrzbsAvUnqS997FNk545sGo0YraDQ7CeJXGqe -DyUTpdwtzBt8H8/axNP1BFdgNEWnF1C1HXVbhqWxq16IlakqZYkYldHJMPQgFa3Y -uRN4Y0i8sn8A1Fbe69D//57JZr1wt+qxAJWWn0anPGXmR0HlO0At1ACQkKGSE+aj -TB2TnO7UTsjKRrXPv16FdWTXkJTVHUdVuAs6IfgAKkvQQ5zA8D6IXgjWsToWdFzl -I8eTDHZqZJiw8gPg7xG0jepN9JU05JRc4NduzeVj/0WT0tdilO0jQP/+8FgikdOe -DU6wo4/e0Ta5bdZe7apqOBfdDnq3EUnHO1ZQbQIDAQABAoIBADbu47Yse4L7YQ0/ -rRfWUfTpMsQgYd0far4P+Cqpeh1r32/Qp4OctFuVkeqaZ3w7PFSjQj1aPMh/ZoGJ -ShxkBus/0dSA1yXNBix1wYNcEb9Mn25GU1I1R4vA2y6DK98FrSl2xwgickhiFQ4W -yiD3huiphq8AcIQLqR679KIL63IF+lMnHmYTrm9/rkGvO/wiW55OMhLvhuR4w7/n -5g+PMBLF4vEqtN6wEpb5f3Q8ugNCG35ykpgBMFWI6FGGmcZkYgux+xnTweZ9+Xol -tBQRrq9cY3/ouIrRX4K30e/EcaJN0eA0Cx9WerEHfYO45BWUJGySsxPab9vk6Qep -uxRnHoECgYEA+uv054HQKGQOZPjgZ9lCqfPB4wQ98T4hNSLgNwAkd85D7UtF6Wb9 -GMsEecJ5aPIQjDN6dTT6Nb45AV4e0XWtQFtxHFXP6SKfyIlf0Zcl0cd8Fvt7CX/e -ghZF6ndUxHaWtAltALVwo+Fi6LOgEN7+dsBjkAZf994cZNfqrr6B1s0CgYEA8eqY -u2p/QE7YNfw7naMUKDqgqGzo41IjF915rznYOyuO4hu+zGrL2D+7EeZnLWfSCSxl -t0uowOzDOKkm6XeungMyJFH0DnzhYEgh6K9AXMi3QF0zfgGrh7hhK5wFEt+a4nOY -hIAnqhANqISRhOOd0iT2VIt+igQhEQv8XLjAICECgYAVvkKfmQkfpuP0bfiMJzB2 -p6/Ca0iu0fJwt0/0lCeU1iPeuSoaupjuABGoN2jr5iX28DMJWwjfhVdNPgmvnuHf -dM0NZoY4ro5oAzdxYwac8gtXtn0H6rOuVB3E3ohS6e/PNA3lBNP473vxrDcPnzMv -uSYngdXpFa8iMe+dKtb3dQKBgQCAzse56q+Mvy5yODZJ7f4amXTXmP27pA1ZdKyI -90TB5KR0kg9aanbVUsG5ezNuwrvb9I7INPnKl4Yu0ioM35PTQKJfIl/PowChsmaT -rVSY0qp4E+gJ7Lu3TR44CR/Od87RSnln+5CjBV8wXj3ZQxTSQqoCRDABLseoevhJ -Knnp4QKBgEHHHpegaCXl7+kaPzD/qD38iN6AmoAya9ZUxCUH55bDmkTFu1ZGgA6S -87fuXQ2tzwFyOtaxAftPuOkSKMpZYRPJY92SalHA4WyN1pl0MhWMZQiyKOh0QQ7A -yaHjrLn5wPrhHhkpmYu2L1ZNiN+NIFDuD/j+APCX+wqb9otfbfxk ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem deleted file mode 100644 index 57fef36..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAzhdv9CgZ895+JuF4J5ttgKS8HDKL5uCAYOS2B+o1OkGzYRkS -I+vA41BpPfE8D8P9lgjcbzAOrOvgYHPZneE3Ix1mhlyPwbnXesC48AahbWXeHFJL -u3Hr3EfjIVngptIHF0/FXmLtOjcxLpP/mXyUTX7bm0NMhgEvxAX34fPfgM4r6AwP -YLwxJGl0c4rrb9choDmXp7+72NnjiO/pXzrUkI0VL+fV6U/cT9ro6p6wJYewvfXA -zqV01B76xf+QhYGp6h/HSZQntTQfA2KIp3H7jhaVXgC/CyyZ/fvx1QUAVCy8pMck -Fs7YuLtVuhAOZ1KpeZzaQotwRjTEeRkF99iCxwIDAQABAoIBAFNxi+O4hOGHuV42 -tjabKNgIWx2znY+KYJBaqhVET+7ZgS6UPxMKNlwTR7lLvjzH5xnjVpUySQ7cpkmH -Ppo9AN0X31YRjicq/sL12ytcE+o+b5LaA03Oz2euN5leUaZZrYNTyh7wQQrsI96v -D7NujIFgFryjoA0118gvfnEfE+SLW5q4m+n7D4cZ2D1nolDnOo2noLhKhMVWT9jp -UVoa5sO+9/Ap71ElAaet2LawNsKbyjjRuI84544G09zQ+YUfcelADaqtXyYZpSJL -iWrmHasD1w8NfiHB84y2hWHySoiuTBfVBJFfTjg075TaxBwCtDbzzEe0ecDCVGnb -gZfkevECgYEA5+5cUFf9LXt7Cwqc/lnuIUYmX7pvTPVVZbdjEzd1MUvu12p01cRN -QYk4K41LZsQYwDrCk82TFn1+hDbVt27i5r4FPJ9GbkSh4AiqUFDkqpqE/U06ZiUX -JOosU6laI6MmguWbXAAQuv2OwK7xVA0575HdbsEK8LRP2bSTRUYNFjkCgYEA43qb -FaKixVC4KOm8dyNYFHB5oldZW0u4ieemum8B+a9wd2BEG8FdxFw6IuGnKyMQ1BWu -NVwN2wZsHbosmCYxGO7cX4OT37711hdCr4pCGQhQ3gf9eNls4ZjjykZp8EHWQnx8 -SYl7sjQMQUjhfqePKwR396IGx4KSrc/l1rxKYP8CgYEAjYPPJ+bIQFw7s30CVeAh -gIQBHh/vkZGQTcQb27nW9AFU9nOqXlSsnvRPJaPNAiNcxs4Ts4OX3/0qmRmsRYSP -RiNjpp24p8eQzdX7tY3mOIKX6saYf4LaIFgSO+n1ahE+ilf296fCjZXw6HjWH2cC -lr710YJQXpZmsnuP8JDRo2ECgYBrasL+5WydZi+ASldPnuYByNb3HO46GTiMDlKB -6Ndy8zBVfqTKwnWnurFNNWc+DHHu5En+Mnjse0zkgLx8IFTA5FI13Ckg18i4jwVT -ZSMvNOkS340G2wz6PrsaEkQGSuCFRsld5Ej/7mn3DhZFO5R0iMipq94tqe/fmbN7 -wjAROwKBgHLl/XNhPTI/ed76ZjmCpbCvQlKZeYLhNbTS4lHvKCuniHKQsPz4BxjB -fuVCUDH61yQT7WM31zIMfzQZjx9hTgFYYvnptRWj9zIBlIZJEieX3//flvEJ3Qmd -/tbSoADa/1y+Y58biKkgmM4f4qS9h0AkVe88OCbpm14Xs2u7/4Nu ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem b/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem deleted file mode 100644 index 5a4dbee..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.key_intermediate_ca2.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAqhp+ySEP4Oods+29nF39auqEmJ/qTUqQCz+9iWyOhp6NU5pJ -2LZiQNxVWIzasFHp9I1cvmf+4fnstMpaFl/TtdCpQnuV+eFIe7alEP6+Pc3YiFrO -zyO0XnqJcZwmmkpr5omvGcx9FbcrKflzfgmn4ZvGIdgtwkA+ZAj6WkpZHGGpzqLY -yAFz86fwANeT4I3a90aGwOEo/on+jvJA+O8KARsFx+yspxrfSZtNVTNWFfQfkIIt -7vOWnevZNAEkMnHxY8jDFq8EACNGDo3r0j+G5imRl8P0hdklpN261OS1hANVM3l2 -t2INNN/UkZjJe3/T7RW30A0VZ3Wk/nz3IgKlDwIDAQABAoIBACV6FurrPNtZ2Vd2 -DqtvzdCLgNE7klybC+dekLzBTRl9vzdnK9PyQu11XdxXlCr6sSfvKTrOIMrazHr8 -hiKd1EAfi9sY7W8TYmvXTsDSz0lAm+9Wym+6txeFudhtBdhCg0lUll6BviFVrM3f -psFjETjUoC9+uH4ut1BE5huUe9OTmOXxupLWdETcHViMc2VrpnDsNKX/lFIMFSo7 -3JDVojyTA/xdawJgkksCmQyHLICDvqJrIbLaDKxCfEiMKMyjVqgf9qwR33WAJ73e -ES8XMVtgIce2Zpzx6OITf+gNhS0ekqsxZJ56iiacOVHxpphNKk+BwSj1bBxHLRoo -narBebkCgYEA1BuLsbfr5lXAmGxE4JG1XrOZ7YtTqQNMYzy03s6fndoITqS+YpHk -dtPqM/lQ6qByqLbaPZFVEqecIb9EVRoG1m+9rIkAutiWf/vAWwr7w7yIbFID2YBH -50crmdtbK+1eoml/MkNx2grmgelqtMy5iOzwbPcFzmgXaTBzXvJvZEUCgYEAzU3F -f3QP0xgbrT0iK6138waegsuPaLoBdq+arlZ0LMzuN7T3KTKiNfkJKWbxoaECmu1p -PpJsQpG+0cQxyKU1PK9Pz+9qUXaPf/OsRKTcvpiS2kdBFXLPEgGi2JeSoPZxErYM -WuaqLIM8krYrV0JBRgGv38Pd0u0VaSbQvPx5u0MCgYEAidFoIE6IKf64CJH44w3q -EiGSt8Va06u/+48bWtZY4kEkOq1Sw0tWbltdhu3NRNaCCdvdzDldVKSxjz/vD3i8 -zqKGVNAkOEO47mnO35kwY0tiPTfBJpbyoXUeAHeGMvGmFtODgU5PcMS6Z9kZq2aG -e1CxG6waCraZ15BStnPCKx0CgYA2n7Olhp7TPn3WqQZXcq8QdTlleX2tkpfjGTPh -oNUGOnxDTB3a00L/c0QxxNcTdwB3ciVnZZPyXk7UBwxr4zD39XkZzQyPoijqFU5H -cUneWD/yXbT+XO6lTtQiJqn3s7pADTnaUbcDYuOR8XA0pkcxti8yLS3u+e+Ra6ds -MQy+ewKBgDfHrvBhbxyYskxc/xHnSeAZjrKsKoFNmV3/n9XTmms3WAVoCYydIEou -Pm3p5kDiaiTTqLBpxoa4g2tuaEXBJpgLwxq79Jod4PA1bnip45ERRrk4kRROIaFg -eHV6U0+PQTrdFhiJkvK7CgNZVr+NLiS1V1pM3x7xI81nAV9Sv4c5 ------END RSA PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 b/user/mpy/lib/axtls/ssl/test/axTLS.noname.p12 deleted file mode 100644 index 0383293487b156598a1383a699cb16e6db4a4a1b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1612 zcmZXTdpOez7{|AtZ5mk{T5@nSilMbVGnR6hWS87_s8HAxJMCCtmiqm=Q)48&-*-|@AJNYeZF`;j0S+!@O&5o2DeC} zB`s)y)xr6E=qiK{UB>gF3wS=T{BH!y=L6F!Gy#A?sx|y?0>&G_H2(Uq77WHCAZvD< z6Q_nwKXU|tHK6l+pn~xdJsU6T+gKWOpI|W6#>7-w?*<|El0^O>)P4%m{>@9^{N)e3 z+~A3oA+g`9RLRWTs(#p{*g`%zmOjy6M10R!(o+awd_ zXbx^UyHl2Nl3BkBM2TKRv{Rz`!Q_a*ZeGp%2Sx|Xi3b?YvZR!ipKXA*7FpqKy#bH? zM((ck6e2{Dnw~ng;o!h~Wh}1Oo<8|VUcT96EIxt2X4Wr>IbQA%o2`D+u|Cv5Bz6d1 zx9ox4xxcnZnu<>03|5`=-_s?9@iQ1MP32gz&^7VMH|=rfp>x7pr4+80&y5CxXL9lI zP-uy?I{4I*Wo1hDSv?cn=W*+*3HldB$AOS)WBVn_IPJ4pH_Eg9%2Ua{ z?6q~?9=;}vSn|eAkq@B`^u-UWj$mZp+(B1np z@@FHw8}vC{M49F*U&rDBIPPW|Il>dS+jb-9)2hHN4)X+MxuP%8A8)QQk8dbN zoN~R5kq={L&JCjVO4vhDMv>~W+H2Z{Jp?L?F3`%~T{8Ot|PMdQ#bD=*|CHd$7NUqX<6r%E8g=MPgg=zk+yapIhg?Ci& z_Wzr3>4h@8$KK)E_a>;$<8IzNmXI=x-7l}cPWLTnnY5T{ex$_SJ0r%HQRgM$TvNas z+o~tdFmK89j5l_>Q&-`&_)0$~XwJjNj=kQ|#aj19_!tpf8o5Zmcnb(h<_hNXl6qn? zS%(j|Ni~gT`gH>xDQ5ib_&)@>)ZhmT6-8D*ZO7#GaZ z1kk&6F|nZZls-c}j&TuFZ5?_GC9Sl7qd^Q4U}`P03NwZIJ1?w=xf3I{24SaVae)Ia z4`msZI=iKu>N?{}d~exNn>2i&}aextd7q{jtq(Dd3SH zc{4b7LUhjy4Ge*I<<86<-)zZkba({gWLKk7MM26=-AincOYjjk$bOp zL!vtEH-|YhR5r$x&{&`42K!nUmL^>1z0I?chvAgGz*J}5MZZEv?R3t37u-W$IYy0# zYA!*274meEW?NN4eJf9RZkt*^J9C6)Oev)pAy}yg{jbJ!RGFV9H*Mw-%-tz1wqoL0 zrQW=C@;<+;jvp*xh6}ECCy{DS^-~_M6Yx|yy&YopbM-S<0nx{4>fo6NN^9x>q^SA^ zNC{cY$=hpfyQu{vskmgU(ZExnHrV1|TQ4_h#zvoD*|PQp2~)@W9qC=2i)Vil{f>nX zHeR)#+hdY)sca@}#+&>jG<-b)4bd&kz6Lm1aWbOycP3*VzJ;Iy zCMNI%{3bjc2DL<}0s2r7M0a!g#q{~O5TK6iMN8_B+@Wj3w}PyhVLV64LdIC%#r_j8 CC*Z9B diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted.p8 b/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted.p8 deleted file mode 100644 index df7c2e21600e2f296671ecc261f79616e864929e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 635 zcmV->0)+iAf&zB}0RS)!1_>&LNQUpVK9OMT>=3B0)c@5y${qvsC0)^ zs<}EJi_X2bW&1!q&=H!P+=6`Ss2AaM^92rJ!NGWnvbq%_TK}84dM*!$w{+eFnWdtc zQ;V&5S~2as0q5W8>@T2QQ}*VHpvY}OMPnng&rVPuDBm{XbKlmXvqn#DyA7M~sQFB# zaiNIa2dRb)Kh2pVqJ(!30s{d60Rn-5CO_njyzJ~Z%=*32;@a@{xzlc>W=5i@4WXW9}nwcGB5oBXw_aOVL>xPL0zm-b z@v`N}fRjK_bQImP@+VvjJ-}b?oJDLC0N>ErgZhvxgz~Dw-TTi2L5L8>yI!}pE~Xu- zy8B9U*qW_~4QdqvK>*e^BlBH%$kR!|lm5yL>zmrWM<{cbpitLLB;T70H?G4mwNGLQ z%H{8udqbewD<8k82$Rwl9Eq9n-zL#QnUexR0I@;je%~PXqCkJMse!bTqOp zyw=F2cqM}m@|!YO^wU2h>)e0zX{2ZCi8NOzq5SjZ*N@ VJIZuj9FdJZ@%Z_^HP^CJP#x3uH1Yrd diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 b/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 deleted file mode 100644 index dee0ed4..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.unencrypted_pem.p8 +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL0P1EKodIdUqrk6 -H4vOvbdl+0A90BGanNyCfOqoF+F08wUOYcHBeIqyuhUiWv+buHouD4i3dN4EmaWi -mVOLrXhaMe28Aeff6ewvoF1T9uaKoMhtQUVjI7PPTlAfKN824nPf1qGzRk9uuw2b -76j5TKVxoYjdB6mGDT/NmSOihHcPAgMBAAECgYAmP+yWq9QfiQ6dONgnBeW2FAjX -/2l4FkrEBhZVtzpVn76G+FjoxUao8O3a1r+IVS3mciksZMldHZskOphAodKvXKsj -5DPQ6mBS53qec18ugNHcb0cPl4A20jAH3dbXFYkrdNV+irxjQgryMSm/+fnwiI+K -wiJuFSa3XltYRBw7eQJBAOHxsuXIgJNAUHQU3bLyJ1wMPcBf7pxFbBMA39DZg/qQ -LITyqsLd+88DQYgQxrtet7Yuph2quvtKctiarYgNahUCQQDWNiPzXXfI00nBk/7K -Deub2r1HKHOXoFDXTCTfmws3rsMxtU9iCMrl75d7Q6DaKx+/qAiT0hYciZnx3ybR -QpmTAkEAsUHkft8g9+Tx+U/Rai0N8ensnDrmwJS6J+J8tKWhI/bt5lNW4lAy2AKO -68d1kdPKPtQ0IHwr+y86EHKxB1a2zQJAHjvyAw10NLItvNbIpXglgw/ymzKIbiRA -hMLIiY72nFtcTY3LsIiRKrcQaGN5NpHTn1d2Lnb+i/SX992JOwvtZQJBALmvvwnJ -kCbzcou/s3znb29bo5W4ngO5z6BTujLB062Fu3lICdY/nNk3kRENBNU7ynRdHJGN -PfH4+b4117JTUB0= ------END PRIVATE KEY----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 b/user/mpy/lib/axtls/ssl/test/axTLS.withCA.p12 deleted file mode 100644 index 0a89e7358b4104678b647bbd9388f20d8a2593ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2521 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 diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.cer b/user/mpy/lib/axtls/ssl/test/axTLS.x509_1024.cer deleted file mode 100644 index 784e26ffb786bd96d7d95ecab3eaca6f55beca66..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 604 zcmXqLVu~j5Y@Awc9&O)w85vnw84OGejSLLfm_u2(gf$Z@ zLVSW10*dmpQj<#*T=G-WD;1nmi%K%nGLsWaQWYFaOEU6{GD|8A>-Tv$Sww$6fZ7ZM^npXDTmhDd%TmW@KPQb{;U$ zn41_G8H^s-JZp^+JZXT8)Zj{EzVZkx$U{9R= z^OG*8lXiL>?_Bo3uh#aVo6#I$wpka&SKF_gz+$Xx-^jHz^xU?oA!|SSFFJMjn`(98 zrHs~>McZbYKdkZ!5;0t4Xu1yCd>1lx6yg6rn9!4LpkW+lVPdWiHi15&rcfgvT6)$}FigkQ3)MG&3|ZHZU?Y zFflTZ66ZBGFt9YRfN~9V48;sYAg1!7m})3wAOI3)7Us;!PfpCq$S*Ddx=;z(S&Xa< z%uS5^3_x)%rY1&4hM!SoHp^8DXK|$$FDhj7Wo~^bIqmTGg|jy9b9ue`g~9LH@8UO2 zt84h8re7g>>yrK*hZ3hl)AY`p9d}}0%)n#4_Vm4uu4SK!e2(xlid^R8sQxmk;Hj(a z@!MxI{O;PMe`cytGqS7_-7tC53z0t0i=n42;)7Qn=zN#7$xVI6@;S4_q{Q+oypK*( zIh-K$$JkyYc7~t!vZai&BJ1uOKalmj=+ZoYm!4PY#LZgMnttiJ&7aR>p(mz)QelTP zGl!=D|C*0tYx(0RHa5NA9JZj9UG?{-o=A4z-C`#@1MW>T>oRYZKYo?9#`Ws^hGUm6 z`)r!wc_Z}a-;{mNV>P^#_wsj7Grh{h%*eoq974c|1BMVIgUqU~+buVuH|I+=Db;Li zJ-K89BWu0IgO{B%CwIQR{#3x-y-xq@&x4a^Eoc3AB*p#EjuZAXFAL00%-P=EcwRp1 z!_VB>lTDfR`>&j3eOB{O=*-Ex2kz}T5O?HewR7kFgezwqH9Sv=ELeYC;Lkdn$(I;j zw*(dn|K-gNGPf={Z(tFiwRD2?sq!Uv3-nhr8!u|S5q#c#Yxbq7HA^;bttsMQkvy?H zr#3S&T=jh9-F0j4bJT1Px# diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem deleted file mode 100644 index 95bdb5a..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.x509_2048.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIC3DCCAcQCCQClKsh4h/LnyTANBgkqhkiG9w0BAQUFADA0MTIwMAYDVQQKEylh -eFRMUyBQcm9qZWN0IERvZGd5IENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNjEy -MzAyMTA0MjdaFw0zMDA5MDgyMTA0MjdaMCwxFjAUBgNVBAoTDWF4VExTIFByb2pl -Y3QxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBAPladjynJXGaCmdzonEGTQOF6RmWw/ehmrG+ROur6DD7m+5fspZ+gPQm -L3gZ2tIv3EB0QsKWLs82x0IDowAMO63L3oiKpvJyTMQPARTTCQh79JJw5UU9x9vM -aE7dPGfzAnwmMjl6FbCTkugUjknRVcs4X1OpwInuYrJGJ5innJoWGhZveEvFliTD -YBL8Mz8oXZhOK6alAR0Urt8z4B1J0USDn7ouSnWRsyqWgvotRp+fDDguFi/JILhD -AwhJEA+s8RatD1+RgYLvs1aghQcl+7KMWQdNuxbJiVDeljaKN4Ufx9UFfEXV74DG -09NMsphJ2FX5/WS+510oSiO9D4uWNdUCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA -HKqK24TYW7NvGoIifLaFyaSwAQV/OODpiZmTie3X5RBHR34v9fnBk5qnBf7EZEfC -uMg/mdMQm2Fst4uBzx9q8PltfcmCaX+/1M0F5nzhEszJ3cDevMBexNl7Q4nfYNTN -QShJyhSgr9cQ/K48k9IA64RRcRP9DWtSNzt0zzA4UCqlkBvKd6TdcC+rAzOigdhT -z0e1a9KVfKSxtXxyCAQZyKdsfWlhVyXPWd2urd8IfLfHdiFMKwyyreCCc4tCDjcA -QcJkv2bfL8Cb4cUd2vtI8kic9zUBFaOWyz9tOicGG2k3SBjN99iQfBAsqbHjtGnj -+dKbDCxXy4udsNINgfE3aA== ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.cer b/user/mpy/lib/axtls/ssl/test/axTLS.x509_4096.cer deleted file mode 100644 index f90fb1cc28c86af31bb0a93aa18c129d2d3698b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 992 zcmV<610Vb_f&<(zf&#<>2>_)k$ashH=gKe*1_>&LNQU@ro9v2NUHZd|Y zFfuVPG%`0@7Y#EoFgY+dGBGeTGB;WY-n$DbTEPfA}|dG2`Yw2hW8Bt0RaU71A+n%05F0A3Ic)x0RX@X zPNUcKvn9yzIfRh^Ja}-RWuFDQX9x+(oE7a3%LIK=#ng2OOsJ>KE-x09%08^xg>X0Q zHy|aHAmXdfU8nYqk9emEP$*t@iMl3G>DB#G&{0%Hy>h?v=@{Uxls)*#8#^D2T~~PE zk0TLfZd+;!)#Ni%;Z$#3osW)YO`_>9pmANr#tXN$DJPEan3lpTOvq`8LMqkq`)yFx zx>fS7?kh17EcuP4Cb=sNWQlqnIln6znZ`hF7X4Y9Vx%gfEm!rbL4d2C2&L4Hb0oOO zSW{yIt@u-|@>!ZWEo2z-nt8)5EVM5>$dLQeyDZK*x6SD7Tm@pLZM*nop4GC5=|B~K zA-Bus!~mm)bJqG&l?m=7Pj`KTt&oY=8=F;a%g5*n<$?>b{@*|ZPXV_zDZ7c-Vs^jS zp&;Dkt0ek2p-G<4!Eu?#0eLZ!;Hx1K3 z2=dh45AKOWq?mP9OnIwk+i45Pt5M9N^rjf1uQ|2jj0!531zLzJq>{hgja^fE?MY9a z8b7;g2;-{-fLd5{wIJYn#8Z-fkR-X4U*ZafvR$K2BG~IN;gP4wf`I}90RRCo4F(A+ zhDe6@4FLfK1potr0RaFL@KNiqM#QC5L6G ze>~xk+?vfj)}U+iSBjy`u1Zt8>tH{{n0)wpm#ij<5rH&0c zZtJ76;$u0Laz23cXCmrpx#jBmWM%Zok51H8&SWe=1oB0YF#wZ+kV(ec5HML^OFIr+(nIT`uIB?fZhyoP257KWyV21W*^W>Mn2#s&r^ zMkY|MfwrNhfjY!A1r*a1TvE$2lT#I(Q;SM6(=wA2OHvIQ=Oa6Yk(GhDv6sQ1v6HE> zk>S7|p$yLd2f|Dj=6{NLb1Le)z%wq^#+EJTl9w%E`!60XT(|XFkkJ3no-yAWU3d7; zeH?nIsB2}{pS#Crh(G_JdEYB@+y4H)wg*(R93>BLkn}pu$Na90|Ks|*IoH~ETxV8(yjZKI!|a$yap-3Wlh%B$#z%(6%RbK3{-(O&X4>hayZ<(` zuIxW{ovZZQzus~lv8Pp`EN}Jro;;Y!xz{D`#e=>D6Wj$hS-)^xZIJHu_xsh!Zthza d?&43cZg3RhOG+2|`$Fh=y_^1Dp%9^+ivW7xwDbS~ diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem deleted file mode 100644 index 2ecdabe..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.x509_device.pem +++ /dev/null @@ -1,34 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICUjCCAbsCCQClKsh4h/LnyzANBgkqhkiG9w0BAQUFADAsMRYwFAYDVQQKEw1h -eFRMUyBQcm9qZWN0MRIwEAYDVQQDEwlsb2NhbGhvc3QwHhcNMTYxMjMwMjEwNDI3 -WhcNMzAwOTA4MjEwNDI3WjArMSkwJwYDVQQKEyBheFRMUyBQcm9qZWN0IERldmlj -ZSBDZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL1d -D6JnZqcce7NfbntIrT5T7rFq00sKH6FhFNeNXae3EvXl3Ep0FeaX72L78NtR7GR8 -vsVtnLqY0Ac76j7a66gM+KdhPVR0zLs7w0knI+hlNAVA/hkN6rYS5FzH4e6SWRTe -Q2LVas0hPrn2ZWJXwarE9QTjfXkbNn03+jpzBQKcdADYychRJbtnBH94on/92ejx -dIlDbSmgzQ1b1QaIkWvZlLo+L8Z8h+B5ss04adm1wyzFDlYs/1lmbPTZf0KCXbsi -WRhIotVDOVUvNakJ7tnU9YPxNMj18LTkFJ1YI0jD31vggMidV03UsFQ0rMlwKcsc -bUhGGzPNbdxhr5pgn/kCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBX+beg1jGMSqQd -6Q/d07mQCLuEwmXmmz7hc0lgp6IumjsxulO2xLiotXie7e3GIRAVgJsd6ysRJKim -IioOMxcwUMWw0CcqjcwqorczJjsqzW99dzCd3NcDiDxx+7Pye58D8qOLHGtafC9n -TjQELV6dNIUX5IfH/18jAkPEmFcOUg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDDjCCAfagAwIBAgIJAORglrABpAToMA0GCSqGSIb3DQEBBQUAMDQxMjAwBgNV -BAoTKWF4VExTIFByb2plY3QgRG9kZ3kgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X -DTE2MTIzMDIxMDQyN1oXDTMwMDkwODIxMDQyN1owNDEyMDAGA1UEChMpYXhUTFMg -UHJvamVjdCBEb2RneSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqGSIb3 -DQEBAQUAA4IBDwAwggEKAoIBAQCxIzCSlgeXAiyLWjGWUkuMA+OPJzH23pDcE7Nc -FKhkdzXAD6tBW4odqul7y1g4qU0/xvv16NsK//VTc2VWQwkm0tlQ+0PBMTBRk0Qb -XuLFLjfyYYjUBsde/CE9qhPbhTKYQ5xsnEBm4KUN/Mqk3sKXo7M3s7HjiAeYEIFK -dSFECcljEPrHzAEvDwd0fRsx2hzb4fgrJbfW4wa9rsL1iVQI9VAY8mxM/UMtGySr -L7M7U0RFRM5fK0d5guWH9f+j41hW9R/tYq7qoLcjgcr45nk5bcT4RoTvehhGZRUN -pVq8vttEoR/Y1JvOjBT5WwUSfJcgXtidEWnQPXKszNoLj1sNAgMBAAGjIzAhMA8G -A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IB -AQByY8+gtxSKO5ASYKArY8Sb4xJw0MNwsosARm17sT/8UTerS9CssUQXkW4LaU3T -SzFVxRUz9O+74yu87W58IaxGNq80quFkOfpS39eCtbqD2e4Y/JuC30hK/GmhBquD -gVh3z3hD8+DUXq83T1+9zgjCppLeQfaFejbaJSwQ7+K6gJn5JZNiaHVGN1GO6lT6 -5W3zqep5zU6a4T5UeZqkYyuzfTBbIkgEga0JzPaCdd5JOrwFR3UNWlICOxr7htDI -FqiTrA0RH2ZNmrmJDcM1pFWlQAPnvDoRLeMpmvWZDnGrWYDzyt0j5G0bIPL7214c -b5kxOvfGlM4E6v+lMSw/HDrI ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem deleted file mode 100644 index c0a4eb3..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain.pem +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDJDCCAgygAwIBAgIJAKUqyHiH8ufOMA0GCSqGSIb3DQEBCwUAMCgxJjAkBgNV -BAoTHWF4VExTIFByb2plY3QgSW50ZXJtZWRpYXRlIENBMB4XDTE2MTIzMDIxMDQy -OFoXDTMwMDkwODIxMDQyOFowLDEWMBQGA1UEChMNYXhUTFMgUHJvamVjdDESMBAG -A1UEAxMJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA -7R4S75j5ZfknrzbsAvUnqS997FNk545sGo0YraDQ7CeJXGqeDyUTpdwtzBt8H8/a -xNP1BFdgNEWnF1C1HXVbhqWxq16IlakqZYkYldHJMPQgFa3YuRN4Y0i8sn8A1Fbe -69D//57JZr1wt+qxAJWWn0anPGXmR0HlO0At1ACQkKGSE+ajTB2TnO7UTsjKRrXP -v16FdWTXkJTVHUdVuAs6IfgAKkvQQ5zA8D6IXgjWsToWdFzlI8eTDHZqZJiw8gPg -7xG0jepN9JU05JRc4NduzeVj/0WT0tdilO0jQP/+8FgikdOeDU6wo4/e0Ta5bdZe -7apqOBfdDnq3EUnHO1ZQbQIDAQABo00wSzAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB -/wQEAwIF4DArBgNVHREEJDAigg93d3cuZXhhbXBsZS5uZXSCD3d3dy5leGFtcGxl -Lm9yZzANBgkqhkiG9w0BAQsFAAOCAQEAbPQ1Y205Ricl1K2ByVa2RHJyYGP0Qj+H -5mWj4A92N1vAb6uOrliqFYOClYINGsKKC8YDZdyA4c8ZglCKZ2RePwOSdaWIw7wi -Efhysyq3WLSlo5jEcnkO7o5dV/7V7FX/+65UEXu35ZqaE8ZY++eotmLzccnInYP3 -1e4oaF5hyZIHVNCXnywNvchSkXjN0HhvIpeLTyzC5MQkQMMEOi8EBOgTGAo4UvL9 -eau3YhhpvfnCDlrRB6N79RcTLmJyOj5g1YO/9wn/du+EMwEkKUg5QJHzwUB2+ISp -57JjKh2BQt0g/XJfRugHQcNtjUu73Ziexpl0qaXjNjb8mvsuV9RX0g== ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem deleted file mode 100644 index 743dbc0..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.x509_end_chain_bad.pem +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDJjCCAg6gAwIBAgIJAKUqyHiH8ufPMA0GCSqGSIb3DQEBCwUAMCoxKDAmBgNV -BAoTH2F4VExTIFByb2plY3QgSW50ZXJtZWRpYXRlIDIgQ0EwHhcNMTYxMjMwMjEw -NDI4WhcNMzAwOTA4MjEwNDI4WjAsMRYwFAYDVQQKEw1heFRMUyBQcm9qZWN0MRIw -EAYDVQQDEwlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB -AQDtHhLvmPll+SevNuwC9SepL33sU2TnjmwajRitoNDsJ4lcap4PJROl3C3MG3wf -z9rE0/UEV2A0RacXULUddVuGpbGrXoiVqSpliRiV0ckw9CAVrdi5E3hjSLyyfwDU -Vt7r0P//nslmvXC36rEAlZafRqc8ZeZHQeU7QC3UAJCQoZIT5qNMHZOc7tROyMpG -tc+/XoV1ZNeQlNUdR1W4Czoh+AAqS9BDnMDwPoheCNaxOhZ0XOUjx5MMdmpkmLDy -A+DvEbSN6k30lTTklFzg127N5WP/RZPS12KU7SNA//7wWCKR054NTrCjj97RNrlt -1l7tqmo4F90OercRScc7VlBtAgMBAAGjTTBLMAwGA1UdEwEB/wQCMAAwDgYDVR0P -AQH/BAQDAgXgMCsGA1UdEQQkMCKCD3d3dy5leGFtcGxlLm5ldIIPd3d3LmV4YW1w -bGUub3JnMA0GCSqGSIb3DQEBCwUAA4IBAQBGJydzARx5fNYprptRG9c3pqecGKlX -ArxbLe+K+83wS427HnWONnuZ5LJKGkuXjIeh1G/2AfKYXJz/SMN0IPYY3ro5Lt1Z -GOPyn01qcj6OkfyiUPCDIsVFS9V0TVLTBLTMZFa1j6nMHs8Ajmm10Fkf/NQP/CVk -zEgoktjb+wLqw1iPUGqkVepVtp3wg7VQY6E07SliNp/06Q3ue6xLJnYlKqFhUQf7 -064JyRIH9W/C2WnxWbKRBjsE4gCRnMvKQrCrfR64VohCr6XvygIIufwCG/CLJogn -4OJMqz1oDkABPgSgjNhOdwnt+3dvxbjQBiRy1ERfNAJLo+V6x6aO1Gqz ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem deleted file mode 100644 index 4fbad81..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca.pem +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDAjCCAeqgAwIBAgIJAKUqyHiH8ufMMA0GCSqGSIb3DQEBCwUAMDQxMjAwBgNV -BAoTKWF4VExTIFByb2plY3QgRG9kZ3kgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X -DTE2MTIzMDIxMDQyN1oXDTMwMDkwODIxMDQyN1owKDEmMCQGA1UEChMdYXhUTFMg -UHJvamVjdCBJbnRlcm1lZGlhdGUgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQDOF2/0KBnz3n4m4Xgnm22ApLwcMovm4IBg5LYH6jU6QbNhGRIj68Dj -UGk98TwPw/2WCNxvMA6s6+Bgc9md4TcjHWaGXI/Budd6wLjwBqFtZd4cUku7cevc -R+MhWeCm0gcXT8VeYu06NzEuk/+ZfJRNftubQ0yGAS/EBffh89+AzivoDA9gvDEk -aXRziutv1yGgOZenv7vY2eOI7+lfOtSQjRUv59XpT9xP2ujqnrAlh7C99cDOpXTU -HvrF/5CFganqH8dJlCe1NB8DYoincfuOFpVeAL8LLJn9+/HVBQBULLykxyQWzti4 -u1W6EA5nUql5nNpCi3BGNMR5GQX32ILHAgMBAAGjIzAhMBIGA1UdEwEB/wQIMAYB -Af8CAQAwCwYDVR0PBAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAYt1Wq1XsZjOWf -mH9XzI3k8UEtErTkBX5SXH10siY5tYmHzH02jaZVRC1yNrxQevqARhR1yj3daKg3 -+innX8foKlYRCxTfFeE/HELcm7rIt5mrIGdGAFn2fnImO5kpXxbPk6IAXRTp6lN8 -QS08Ah1Aaeh0ae2Ruzx2TOnG/IuB7ChliJxepo0KtRw6RN6ETvC2KS0glSf5fPW7 -c18UPbTesecrki12FlaGbPD/sWHOltBIpPXzgef7G8b6CiYqaX0T3T/47RLRwrMm -SAcbMerJZoyudbLd+OHGtvz5kOmYCoZYkay121MSvtFucHnR3UjEui2lUbL1Qi92 -2L3MUIVn ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem b/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem deleted file mode 100644 index ea8ab7d..0000000 --- a/user/mpy/lib/axtls/ssl/test/axTLS.x509_intermediate_ca2.pem +++ /dev/null @@ -1,37 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIC+TCCAeGgAwIBAgIJAKUqyHiH8ufNMA0GCSqGSIb3DQEBCwUAMCgxJjAkBgNV -BAoTHWF4VExTIFByb2plY3QgSW50ZXJtZWRpYXRlIENBMB4XDTE2MTIzMDIxMDQy -N1oXDTMwMDkwODIxMDQyN1owKjEoMCYGA1UEChMfYXhUTFMgUHJvamVjdCBJbnRl -cm1lZGlhdGUgMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoa -fskhD+DqHbPtvZxd/WrqhJif6k1KkAs/vYlsjoaejVOaSdi2YkDcVViM2rBR6fSN -XL5n/uH57LTKWhZf07XQqUJ7lfnhSHu2pRD+vj3N2Ihazs8jtF56iXGcJppKa+aJ -rxnMfRW3Kyn5c34Jp+GbxiHYLcJAPmQI+lpKWRxhqc6i2MgBc/On8ADXk+CN2vdG -hsDhKP6J/o7yQPjvCgEbBcfsrKca30mbTVUzVhX0H5CCLe7zlp3r2TQBJDJx8WPI -wxavBAAjRg6N69I/huYpkZfD9IXZJaTdutTktYQDVTN5drdiDTTf1JGYyXt/0+0V -t9ANFWd1pP589yICpQ8CAwEAAaMkMCIwEgYDVR0TAQH/BAgwBgEB/wIBCjAMBgNV -HQ8EBQMDBwWAMA0GCSqGSIb3DQEBCwUAA4IBAQBNWDjqxlO0BwMdyxfUs1wDsLiq -4hOmUFwCv8TuTFsL9aNe7OIJRT8IF2pHw07qyvAxJVEWUCLK/KLq0HrRTzRZO/tK -eNroHMHS+fBwFuHFp+1RGMK2rHLajxVVB6X0aeLWKrNKrvUQZL+Tx+NZ3dEO62rq -rANnElCrnyI1bIBKwHdUbOMOHeZAECr7H0KfvaX8F67aln4IwPzCauQM3DFf9h9Z -FvmxUdVgjRZK4e5he9k4gT/Faom0z/ApnW4DJRF8rpCPWqN872aNpL8NPZuOFtiD -Gzg5O4wJYx7OWIPa/qcQ0hTbn5waPzC68X448tlJTPiwyeKsYT3JwWqLi6o5 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDAjCCAeqgAwIBAgIJAKUqyHiH8ufMMA0GCSqGSIb3DQEBCwUAMDQxMjAwBgNV -BAoTKWF4VExTIFByb2plY3QgRG9kZ3kgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X -DTE2MTIzMDIxMDQyN1oXDTMwMDkwODIxMDQyN1owKDEmMCQGA1UEChMdYXhUTFMg -UHJvamVjdCBJbnRlcm1lZGlhdGUgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQDOF2/0KBnz3n4m4Xgnm22ApLwcMovm4IBg5LYH6jU6QbNhGRIj68Dj -UGk98TwPw/2WCNxvMA6s6+Bgc9md4TcjHWaGXI/Budd6wLjwBqFtZd4cUku7cevc -R+MhWeCm0gcXT8VeYu06NzEuk/+ZfJRNftubQ0yGAS/EBffh89+AzivoDA9gvDEk -aXRziutv1yGgOZenv7vY2eOI7+lfOtSQjRUv59XpT9xP2ujqnrAlh7C99cDOpXTU -HvrF/5CFganqH8dJlCe1NB8DYoincfuOFpVeAL8LLJn9+/HVBQBULLykxyQWzti4 -u1W6EA5nUql5nNpCi3BGNMR5GQX32ILHAgMBAAGjIzAhMBIGA1UdEwEB/wQIMAYB -Af8CAQAwCwYDVR0PBAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAYt1Wq1XsZjOWf -mH9XzI3k8UEtErTkBX5SXH10siY5tYmHzH02jaZVRC1yNrxQevqARhR1yj3daKg3 -+innX8foKlYRCxTfFeE/HELcm7rIt5mrIGdGAFn2fnImO5kpXxbPk6IAXRTp6lN8 -QS08Ah1Aaeh0ae2Ruzx2TOnG/IuB7ChliJxepo0KtRw6RN6ETvC2KS0glSf5fPW7 -c18UPbTesecrki12FlaGbPD/sWHOltBIpPXzgef7G8b6CiYqaX0T3T/47RLRwrMm -SAcbMerJZoyudbLd+OHGtvz5kOmYCoZYkay121MSvtFucHnR3UjEui2lUbL1Qi92 -2L3MUIVn ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/ca-bundle.crt b/user/mpy/lib/axtls/ssl/test/ca-bundle.crt deleted file mode 100644 index 0c00239..0000000 --- a/user/mpy/lib/axtls/ssl/test/ca-bundle.crt +++ /dev/null @@ -1,3585 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEuDCCA6CgAwIBAgIBBDANBgkqhkiG9w0BAQUFADCBtDELMAkGA1UEBhMCQlIx -EzARBgNVBAoTCklDUC1CcmFzaWwxPTA7BgNVBAsTNEluc3RpdHV0byBOYWNpb25h -bCBkZSBUZWNub2xvZ2lhIGRhIEluZm9ybWFjYW8gLSBJVEkxETAPBgNVBAcTCEJy -YXNpbGlhMQswCQYDVQQIEwJERjExMC8GA1UEAxMoQXV0b3JpZGFkZSBDZXJ0aWZp -Y2Fkb3JhIFJhaXogQnJhc2lsZWlyYTAeFw0wMTExMzAxMjU4MDBaFw0xMTExMzAy -MzU5MDBaMIG0MQswCQYDVQQGEwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDE9MDsG -A1UECxM0SW5zdGl0dXRvIE5hY2lvbmFsIGRlIFRlY25vbG9naWEgZGEgSW5mb3Jt -YWNhbyAtIElUSTERMA8GA1UEBxMIQnJhc2lsaWExCzAJBgNVBAgTAkRGMTEwLwYD -VQQDEyhBdXRvcmlkYWRlIENlcnRpZmljYWRvcmEgUmFpeiBCcmFzaWxlaXJhMIIB -IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwPMudwX/hvm+Uh2b/lQAcHVA -isamaLkWdkwP9/S/tOKIgRrL6Oy+ZIGlOUdd6uYtk9Ma/3pUpgcfNAj0vYm5gsyj -Qo9emsc+x6m4VWwk9iqMZSCK5EQkAq/Ut4n7KuLE1+gdftwdIgxfUsPt4CyNrY50 -QV57KM2UT8x5rrmzEjr7TICGpSUAl2gVqe6xaii+bmYR1QrmWaBSAG59LrkrjrYt -bRhFboUDe1DK+6T8s5L6k8c8okpbHpa9veMztDVC9sPJ60MWXh6anVKo1UcLcbUR -yEeNvZneVRKAAU6ouwdjDvwlsaKydFKwed0ToQ47bmUKgcm+wV3eTRk36UOnTwID -AQABo4HSMIHPME4GA1UdIARHMEUwQwYFYEwBAQAwOjA4BggrBgEFBQcCARYsaHR0 -cDovL2FjcmFpei5pY3BicmFzaWwuZ292LmJyL0RQQ2FjcmFpei5wZGYwPQYDVR0f -BDYwNDAyoDCgLoYsaHR0cDovL2FjcmFpei5pY3BicmFzaWwuZ292LmJyL0xDUmFj -cmFpei5jcmwwHQYDVR0OBBYEFIr68VeEERM1kEL6V0lUaQ2kxPA3MA8GA1UdEwEB -/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQAZA5c1 -U/hgIh6OcgLAfiJgFWpvmDZWqlV30/bHFpj8iBobJSm5uDpt7TirYh1Uxe3fQaGl -YjJe+9zd+izPRbBqXPVQA34EXcwk4qpWuf1hHriWfdrx8AcqSqr6CuQFwSr75Fos -SzlwDADa70mT7wZjAmQhnZx2xJ6wfWlT9VQfS//JYeIc7Fue2JNLd00UOSMMaiK/ -t79enKNHEA2fupH3vEigf5Eh4bVAN5VohrTm6MY53x7XQZZr1ME7a55lFEnSeT0u -mlOAjR2mAbvSM5X5oSZNrmetdzyTj2flCM8CC7MLab0kkdngRIlUBGHF1/S5nmPb -K+9A46sd33oqK8n8 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIESzCCAzOgAwIBAgIJAJigUTEEXRQpMA0GCSqGSIb3DQEBBQUAMHYxCzAJBgNV -BAYTAkRFMQ8wDQYDVQQIEwZIZXNzZW4xDjAMBgNVBAcTBUZ1bGRhMRAwDgYDVQQK -EwdEZWJjb25mMRMwEQYDVQQDEwpEZWJjb25mIENBMR8wHQYJKoZIhvcNAQkBFhBq -b2VyZ0BkZWJpYW4ub3JnMB4XDTA1MTEwNTE3NTUxNFoXDTE1MTEwMzE3NTUxNFow -djELMAkGA1UEBhMCREUxDzANBgNVBAgTBkhlc3NlbjEOMAwGA1UEBxMFRnVsZGEx -EDAOBgNVBAoTB0RlYmNvbmYxEzARBgNVBAMTCkRlYmNvbmYgQ0ExHzAdBgkqhkiG -9w0BCQEWEGpvZXJnQGRlYmlhbi5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQCvbOo0SrIwI5IMlsshH8WF3dHB9r9JlSKhMPaybawa1EyvZspMQ3wa -F5qxNf3Sj+NElEmjseEqvCZiIIzqwerHu0Qw62cDYCdCd2+Wb5m0bPYB5CGHiyU1 -eNP0je42O0YeXG2BvUujN8AviocVo39X2YwNQ0ryy4OaqYgm2pRlbtT2ESbF+SfV -Y2iqQj/f8ymF+lHo/pz8tbAqxWcqaSiHFAVQJrdqtFhtoodoNiE3q76zJoUkZTXB -k60Yc3MJSnatZCpnsSBr/D7zpntl0THrUjjtdRWCjQVhqfhM1yZJV+ApbLdheFh0 -ZWlSxdnp25p0q0XYw/7G92ELyFDfBUUNAgMBAAGjgdswgdgwHQYDVR0OBBYEFMuV -dFNb4mCWUFbcP5LOtxFLrEVTMIGoBgNVHSMEgaAwgZ2AFMuVdFNb4mCWUFbcP5LO -txFLrEVToXqkeDB2MQswCQYDVQQGEwJERTEPMA0GA1UECBMGSGVzc2VuMQ4wDAYD -VQQHEwVGdWxkYTEQMA4GA1UEChMHRGViY29uZjETMBEGA1UEAxMKRGViY29uZiBD -QTEfMB0GCSqGSIb3DQEJARYQam9lcmdAZGViaWFuLm9yZ4IJAJigUTEEXRQpMAwG -A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAGZXxHg4mnkvilRIM1EQfGdY -S5b/WcyF2MYSTeTvK4aIB6VHwpZoZCnDGj2m2D3CkHT0upAD9o0zM1tdsfncLzV+ -mDT/jNmBtYo4QXx5vEPwvEIcgrWjwk7SyaEUhZjtolTkHB7ACl0oD0r71St4iEPR -qTUCEXk2E47bg1Fz58wNt/yo2+4iqiRjg1XCH4evkQuhpW+dTZnDyFNqwSYZapOE -TBA+9zBb6xD1KM2DdY7r4GiyYItN0BKLfuWbh9LXGbl1C+f4P11g+m2MPiavIeCe -1iazG5pcS3KoTLACsYlEX24TINtg4kcuS81XdllcnsV3Kdts0nIqPj6uhTTZD0k= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDtTCCAp2gAwIBAgIRANAeQJAAAEZSAAAAAQAAAAQwDQYJKoZIhvcNAQEFBQAw -gYkxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJEQzETMBEGA1UEBxMKV2FzaGluZ3Rv -bjEXMBUGA1UEChMOQUJBLkVDT00sIElOQy4xGTAXBgNVBAMTEEFCQS5FQ09NIFJv -b3QgQ0ExJDAiBgkqhkiG9w0BCQEWFWFkbWluQGRpZ3NpZ3RydXN0LmNvbTAeFw05 -OTA3MTIxNzMzNTNaFw0wOTA3MDkxNzMzNTNaMIGJMQswCQYDVQQGEwJVUzELMAkG -A1UECBMCREMxEzARBgNVBAcTCldhc2hpbmd0b24xFzAVBgNVBAoTDkFCQS5FQ09N -LCBJTkMuMRkwFwYDVQQDExBBQkEuRUNPTSBSb290IENBMSQwIgYJKoZIhvcNAQkB -FhVhZG1pbkBkaWdzaWd0cnVzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQCx0xHgeVVDBwhMywVCAOINg0Y95JO6tgbTDVm9PsHOQ2cBiiGo77zM -0KLMsFWWU4RmBQDaREmA2FQKpSWGlO1jVv9wbKOhGdJ4vmgqRF4vz8wYXke8OrFG -PR7wuSw0X4x8TAgpnUBV6zx9g9618PeKgw6hTLQ6pbNfWiKX7BmbwQVo/ea3qZGU -LOR4SCQaJRk665WcOQqKz0Ky8BzVX/tr7WhWezkscjiw7pOp03t3POtxA6k4ShZs -iSrK2jMTecJVjO2cu/LLWxD4LmE1xilMKtAqY9FlWbT4zfn0AIS2V0KFnTKo+SpU -+/94Qby9cSj0u5C8/5Y0BONFnqFGKECBAgMBAAGjFjAUMBIGA1UdEwEB/wQIMAYB -Af8CAQgwDQYJKoZIhvcNAQEFBQADggEBAARvJYbk5pYntNlCwNDJALF/VD6Hsm0k -qS8Kfv2kRLD4VAe9G52dyntQJHsRW0mjpr8SdNWJt7cvmGQlFLdh6X9ggGvTZOir -vRrWUfrAtF13Gn9kCF55xgVM8XrdTX3O5kh7VNJhkoHWG9YA8A6eKHegTYjHInYZ -w8eeG6Z3ePhfm1bR8PIXrI6dWeYf/le22V7hXZ9F7GFoGUHhsiAm/lowdiT/QHI8 -eZ98IkirRs3bs4Ysj78FQdPB4xTjQRcm0HyncUwZ6EoPclgxfexgeqMiKL0ZJGA/ -O4dzwGvky663qyVDslUte6sGDnVdNOVdc22esnVApVnJTzFxiNmIf1Q= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU -MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs -IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 -MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux -FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h -bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v -dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt -H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 -uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX -mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX -a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN -E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 -WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD -VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 -Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU -cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx -IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN -AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH -YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 -6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC -Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX -c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a -mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEGDCCAwCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQGEwJTRTEU -MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 -b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwHhcNMDAwNTMw -MTAzODMxWhcNMjAwNTMwMTAzODMxWjBlMQswCQYDVQQGEwJTRTEUMBIGA1UEChML -QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYD -VQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUA -A4IBDwAwggEKAoIBAQCWltQhSWDia+hBBwzexODcEyPNwTXH+9ZOEQpnXvUGW2ul -CDtbKRY654eyNAbFvAWlA3yCyykQruGIgb3WntP+LVbBFc7jJp0VLhD7Bo8wBN6n -tGO0/7Gcrjyvd7ZWxbWroulpOj0OM3kyP3CCkplhbY0wCI9xP6ZIVxn4JdxLZlyl -dI+Yrsj5wAYi56xz36Uu+1LcsRVlIPo1Zmne3yzxbrww2ywkEtvrNTVokMsAsJch -PXQhI2U0K7t4WaPW4XY5mqRJjox0r26kmqPZm9I4XJuiGMx1I4S+6+JNM3GOGvDC -+Mcdoq0Dlyz4zyXG9rgkMbFjXZJ/Y/AlyVMuH79NAgMBAAGjgdIwgc8wHQYDVR0O -BBYEFJWxtPCUtr3H2tERCSG+wa9J/RB7MAsGA1UdDwQEAwIBBjAPBgNVHRMBAf8E -BTADAQH/MIGPBgNVHSMEgYcwgYSAFJWxtPCUtr3H2tERCSG+wa9J/RB7oWmkZzBl -MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFk -ZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENB -IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBACxtZBsfzQ3duQH6lmM0MkhHma6X -7f1yFqZzR1r0693p9db7RcwpiURdv0Y5PejuvE1Uhh4dbOMXJ0PhiVYrqW9yTkkz -43J8KiOavD7/KCrto/8cI7pDVwlnTUtiBi34/2ydYB7YHEt9tTEv2dB8Xfjea4MY -eDdXL+gzB2ffHsdrKpV2ro9Xo/D0UrSpUwjP4E/TelOL/bscVjby/rK25Xa71SJl -pz/+0WatC7xrmYbvP33zGDLKe8bjq2RGlfgmadlVg3sslgf/WSxEo8bl6ancoWOA -WiFeIc9TVPC6b4nbqKqVz4vjccweGyBECMB6tkD9xOQ14R0WHNC8K47Wcdk= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEFTCCAv2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJTRTEU -MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 -b3JrMSAwHgYDVQQDExdBZGRUcnVzdCBQdWJsaWMgQ0EgUm9vdDAeFw0wMDA1MzAx -MDQxNTBaFw0yMDA1MzAxMDQxNTBaMGQxCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtB -ZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5ldHdvcmsxIDAeBgNV -BAMTF0FkZFRydXN0IFB1YmxpYyBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOC -AQ8AMIIBCgKCAQEA6Rowj4OIFMEg2Dybjxt+A3S72mnTRqX4jsIMEZBRpS9mVEBV -6tsfSlbunyNu9DnLoblv8n75XYcmYZ4c+OLspoH4IcUkzBEMP9smcnrHAZcHF/nX -GCwwfQ56HmIexkvA/X1id9NEHif2P0tEs7c42TkfYNVRknMDtABp4/MUTu7R3AnP -dzRGULD4EfL+OHn3Bzn+UZKXC1sIXzSGAa2Il+tmzV7R/9x98oTaunet3IAIx6eH -1lWfl2royBFkuucZKT8Rs3iQhCBSWxHveNCD9tVIkNAwHM+A+WD+eeSI8t0A65RF -62WUaUC6wNW0uLp9BBGo6zEFlpROWCGOn9Bg/QIDAQABo4HRMIHOMB0GA1UdDgQW -BBSBPjfYkrAfd59ctKtzquf2NGAv+jALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/BAUw -AwEB/zCBjgYDVR0jBIGGMIGDgBSBPjfYkrAfd59ctKtzquf2NGAv+qFopGYwZDEL -MAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRU -cnVzdCBUVFAgTmV0d29yazEgMB4GA1UEAxMXQWRkVHJ1c3QgUHVibGljIENBIFJv -b3SCAQEwDQYJKoZIhvcNAQEFBQADggEBAAP3FUr4JNojVhaTdt02KLmuG7jD8WS6 -IBh4lSknVwW8fCr0uVFV2ocC3g8WFzH4qnkuCRO7r7IgGRLlk/lL+YPoRNWyQSW/ -iHVv/xD8SlTQX/D67zZzfRs2RcYhbbQVuE7PnFylPVoAjgbjPGsye/Kf8Lb93/Ao -GEjwxrzQvzSAlsJKsW2Ox5BF3i9nrEUEo3rcVZLJR2bYGozH7ZxOmuASu7VqTITh -4SINhwBk/ox9Yjllpu9CtoAlEmEBqCQTcAARJl/6NVDFSMwGR+gn2HCNX2TmoUQm -XiLsks3/QppEIW1cxeMiHV9HEufOX1362KqxMy3ZdvJOOjMMK7MtkAY= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJTRTEU -MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 -b3JrMSMwIQYDVQQDExpBZGRUcnVzdCBRdWFsaWZpZWQgQ0EgUm9vdDAeFw0wMDA1 -MzAxMDQ0NTBaFw0yMDA1MzAxMDQ0NTBaMGcxCzAJBgNVBAYTAlNFMRQwEgYDVQQK -EwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5ldHdvcmsxIzAh -BgNVBAMTGkFkZFRydXN0IFF1YWxpZmllZCBDQSBSb290MIIBIjANBgkqhkiG9w0B -AQEFAAOCAQ8AMIIBCgKCAQEA5B6a/twJWoekn0e+EV+vhDTbYjx5eLfpMLXsDBwq -xBb/4Oxx64r1EW7tTw2R0hIYLUkVAcKkIhPHEWT/IhKauY5cLwjPcWqzZwFZ8V1G -87B4pfYOQnrjfxvM0PC3KP0q6p6zsLkEqv32x7SxuCqg+1jxGaBvcCV+PmlKfw8i -2O+tCBGaKZnhqkRFmhJePp1tUvznoD1oL/BLcHwTOK28FSXx1s6rosAx1i+f4P8U -WfyEk9mHfExUE+uf0S0R+Bg6Ot4l2ffTQO2kBhLEO+GRwVY18BTcZTYJbqukB8c1 -0cIDMzZbdSZtQvESa0NvS3GU+jQd7RNuyoB/mC9suWXY6QIDAQABo4HUMIHRMB0G -A1UdDgQWBBQ5lYtii1zJ1IC6WA+XPxUIQ8yYpzALBgNVHQ8EBAMCAQYwDwYDVR0T -AQH/BAUwAwEB/zCBkQYDVR0jBIGJMIGGgBQ5lYtii1zJ1IC6WA+XPxUIQ8yYp6Fr -pGkwZzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQL -ExRBZGRUcnVzdCBUVFAgTmV0d29yazEjMCEGA1UEAxMaQWRkVHJ1c3QgUXVhbGlm -aWVkIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBABmrder4i2VhlRO6aQTv -hsoToMeqT2QbPxj2qC0sVY8FtzDqQmodwCVRLae/DLPt7wh/bDxGGuoYQ992zPlm -hpwsaPXpF/gxsxjE1kh9I0xowX67ARRvxdlu3rsEQmr49lx95dr6h+sNNVJn0J6X -dgWTP5XHAeZpVTh/EGGZyeNfpso+gmNIquIISD6q8rKFYqa0p9m9N5xotS1WfbC3 -P6CxB9bpT9zeRXEwMn8bLgn5v1Kh7sKAPgZcLlVAwRv1cEWw3F369nJad9Jjzc9Y -iQBCYz95OdBEsIJuQRno3eDBiFrRHnGTHyQwdOUeqN48Jzd/g66ed8/wMLH/S5no -xqE= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDpDCCAoygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEc -MBoGA1UEChMTQW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBP -bmxpbmUgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyODA2 -MDAwMFoXDTM3MTExOTIwNDMwMFowYzELMAkGA1UEBhMCVVMxHDAaBgNVBAoTE0Ft -ZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2EgT25saW5lIFJvb3Qg -Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP -ADCCAQoCggEBAKgv6KRpBgNHw+kqmP8ZonCaxlCyfqXfaE0bfA+2l2h9LaaLl+lk -hsmj76CGv2BlnEtUiMJIxUo5vxTjWVXlGbR0yLQFOVwWpeKVBeASrlmLojNoWBym -1BW32J/X3HGrfpq/m44zDyL9Hy7nBzbvYjnF3cu6JRQj3gzGPTzOggjmZj7aUTsW -OqMFf6Dch9Wc/HKpoH145LcxVR5lu9RhsCFg7RAycsWSJR74kEoYeEfffjA3PlAb -2xzTa5qGUwew76wGePiEmf4hjUyAtgyC9mZweRrTT6PP8c9GsEsPPt2IYriMqQko -O3rHl+Ee5fSfwMCuJKDIodkP1nsmgmkyPacCAwEAAaNjMGEwDwYDVR0TAQH/BAUw -AwEB/zAdBgNVHQ4EFgQUAK3Zo/Z59m50qX8zPYEX10zPM94wHwYDVR0jBBgwFoAU -AK3Zo/Z59m50qX8zPYEX10zPM94wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB -BQUAA4IBAQB8itEfGDeC4Liwo+1WlchiYZwFos3CYiZhzRAW18y0ZTTQEYqtqKkF -Zu90821fnZmv9ov761KyBZiibyrFVL0lvV+uyIbqRizBs73B6UlwGBaXCBOMIOAb -LjpHyx7kADCVW/RFo8AasAFOq73AI25jP4BKxQft3OJvx8Fi8eNy1gTIdGcL+oir -oQHIb/AUr9KZzVGTfu0uOMe9zkZQPXLjeSWdm4grECDdpbgyn43gKd8hdIaC2y+C -MMbHNYaz+ZZfRtsMRf3zUMNvxsNIrUam4SdHCh0Om7bCd39j8uB9Gr784N/Xx6ds -sPmuujz9dLQR6FgNgLzTqIA6me11zEZ7 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFpDCCA4ygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEc -MBoGA1UEChMTQW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBP -bmxpbmUgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyODA2 -MDAwMFoXDTM3MDkyOTE0MDgwMFowYzELMAkGA1UEBhMCVVMxHDAaBgNVBAoTE0Ft -ZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2EgT25saW5lIFJvb3Qg -Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP -ADCCAgoCggIBAMxBRR3pPU0Q9oyxQcngXssNt79Hc9PwVU3dxgz6sWYFas14tNwC -206B89enfHG8dWOgXeMHDEjsJcQDIPT/DjsS/5uN4cbVG7RtIuOx238hZK+GvFci -KtZHgVdEglZTvYYUAQv8f3SkWq7xuhG1m1hagLQ3eAkzfDJHA1zEpYNI9FdWboE2 -JxhP7JsowtS013wMPgwr38oE18aO6lhOqKSlGBxsRZijQdEt0sdtjRnxrXm3gT+9 -BoInLRBYBbV4Bbkv2wxrkJB+FFk4u5QkE+XRnRTf04JNRvCAOVIyD+OEsnpD8l7e -Xz8d3eOyG6ChKiMDbi4BFYdcpnV1x5dhvt6G3NRI270qv0pV2uh9UPu0gBe4lL8B -PeraunzgWGcXuVjgiIZGZ2ydEEdYMtA1fHkqkKJaEBEjNa0vzORKW6fIJ/KD3l67 -Xnfn6KVuY8INXWHQjNJsWiEOyiijzirplcdIz5ZvHZIlyMbGwcEMBawmxNJ10uEq -Z8A9W6Wa6897GqidFEXlD6CaZd4vKL3Ob5Rmg0gp2OpljK+T2WSfVVcmv2/LNzGZ -o2C7HK2JNDJiuEMhBnIMoVxtRsX6Kc8w3onccVvdtjc+31D1uAclJuW8tf48ArO3 -+L5DwYcRlJ4jbBeKuIonDFRH8KmzwICMoCfrHRnjB453cMor9H124HhnAgMBAAGj -YzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFE1FwWg4u3OpaaEg5+31IqEj -FNeeMB8GA1UdIwQYMBaAFE1FwWg4u3OpaaEg5+31IqEjFNeeMA4GA1UdDwEB/wQE -AwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAZ2sGuV9FOypLM7PmG2tZTiLMubekJcmn -xPBUlgtk87FYT15R/LKXeydlwuXK5w0MJXti4/qftIe3RUavg6WXSIylvfEWK5t2 -LHo1YGwRgJfMqZJS5ivmae2p+DYtLHe/YUjRYwu5W1LtGLBDQiKmsXeu3mnFzccc -obGlHBD7GL4acN3Bkku+KVqdPzW+5X1R+FXgJXUjhx5c3LqdsKyzadsXg8n33gy8 -CNyRnqjQ1xU3c6U1uPx+xURABsPr+CKAXEfOAuMRn0T//ZoyzH1kUQ7rVyZ2OuMe -IjzCpjbdGe+n/BLzJsBZMYVMnNjP36TMzCmT/5RtdlwTCJfy7aULTd3oyWgOZtMA -DjMSW7yV5TKQqLPGbIOtd+6Lfn6xqavT4fG2wLHqiMDn05DpKJKUe2h7lyoKZy2F -AjgQ5ANh1NolNscIWC2hp1GvMApJ9aZphwctREZ2jirlmjvXGKL8nDgQzMY70rUX -Om/9riW99XJZZLF0KjhfGEzfz3EEWjbUvy+ZnOjZurGV5gJLIaFb1cFPj65pbVPb -AZO1XB4Y3WRayhgoPmMEEf0cjQAPuDffZ4qdZqkCapH/E8ovXYO8h5Ns3CRRFgQl -Zvqz2cK6Kb6aSDiCmfS/O0oxGfm/jiEzFMpPVF/7zvuPcX/9XhmgD0uRuMRUvAaw -RY8mkaKO/qk= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID5jCCAs6gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMCVVMx -HTAbBgNVBAoTFEFPTCBUaW1lIFdhcm5lciBJbmMuMRwwGgYDVQQLExNBbWVyaWNh -IE9ubGluZSBJbmMuMTcwNQYDVQQDEy5BT0wgVGltZSBXYXJuZXIgUm9vdCBDZXJ0 -aWZpY2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyOTA2MDAwMFoXDTM3MTEyMDE1 -MDMwMFowgYMxCzAJBgNVBAYTAlVTMR0wGwYDVQQKExRBT0wgVGltZSBXYXJuZXIg -SW5jLjEcMBoGA1UECxMTQW1lcmljYSBPbmxpbmUgSW5jLjE3MDUGA1UEAxMuQU9M -IFRpbWUgV2FybmVyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIw -DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnej8Mlo2k06AX3dLm/WpcZuS+U -0pPlLYnKhHw/EEMbjIt8hFj4JHxIzyr9wBXZGH6EGhfT257XyuTZ16pYUYfw8ItI -TuLCxFlpMGK2MKKMCxGZYTVtfu/FsRkGIBKOQuHfD5YQUqjPnF+VFNivO3ULMSAf -RC+iYkGzuxgh28pxPIzstrkNn+9R7017EvILDOGsQI93f7DKeHEMXRZxcKLXwjqF -zQ6axOAAsNUl6twr5JQtOJyJQVdkKGUZHLZEtMgxa44Be3ZZJX8VHIQIfHNlIAqh -BC4aMqiaILGcLCFZ5/vP7nAtCMpjPiybkxlqpMKX/7eGV4iFbJ4VFitNLLMCAwEA -AaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUoTYwFsuGkABFgFOxj8jY -PXy+XxIwHwYDVR0jBBgwFoAUoTYwFsuGkABFgFOxj8jYPXy+XxIwDgYDVR0PAQH/ -BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IBAQCKIBilvrMvtKaEAEAwKfq0FHNMeUWn -9nDg6H5kHgqVfGphwu9OH77/yZkfB2FK4V1Mza3u0FIy2VkyvNp5ctZ7CegCgTXT -Ct8RHcl5oIBN/lrXVtbtDyqvpxh1MwzqwWEFT2qaifKNuZ8u77BfWgDrvq2g+EQF -Z7zLBO+eZMXpyD8Fv8YvBxzDNnGGyjhmSs3WuEvGbKeXO/oTLW4jYYehY0KswsuX -n2Fozy1MBJ3XJU8KDk2QixhWqJNIV9xvrr2eZ1d3iVCzvhGbRWeDhhmH05i9CBoW -H1iCC+GWaQVLjuyDUTEH1dSf/1l7qG6Fz9NLqUmwX7A5KGgOc90lmt4S ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIF5jCCA86gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMCVVMx -HTAbBgNVBAoTFEFPTCBUaW1lIFdhcm5lciBJbmMuMRwwGgYDVQQLExNBbWVyaWNh -IE9ubGluZSBJbmMuMTcwNQYDVQQDEy5BT0wgVGltZSBXYXJuZXIgUm9vdCBDZXJ0 -aWZpY2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyOTA2MDAwMFoXDTM3MDkyODIz -NDMwMFowgYMxCzAJBgNVBAYTAlVTMR0wGwYDVQQKExRBT0wgVGltZSBXYXJuZXIg -SW5jLjEcMBoGA1UECxMTQW1lcmljYSBPbmxpbmUgSW5jLjE3MDUGA1UEAxMuQU9M -IFRpbWUgV2FybmVyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIw -DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALQ3WggWmRToVbEbJGv8x4vmh6mJ -7ouZzU9AhqS2TcnZsdw8TQ2FTBVsRotSeJ/4I/1n9SQ6aF3Q92RhQVSji6UI0ilb -m2BPJoPRYxJWSXakFsKlnUWsi4SVqBax7J/qJBrvuVdcmiQhLE0OcR+mrF1FdAOY -xFSMFkpBd4aVdQxHAWZg/BXxD+r1FHjHDtdugRxev17nOirYlxcwfACtCJ0zr7iZ -YYCLqJV+FNwSbKTQ2O9ASQI2+W6p1h2WVgSysy0WVoaP2SBXgM1nEG2wTPDaRrbq -JS5Gr42whTg0ixQmgiusrpkLjhTXUr2eacOGAgvqdnUxCc4zGSGFQ+aJLZ8lN2fx -I2rSAG2X+Z/nKcrdH9cG6rjJuQkhn8g/BsXS6RJGAE57COtCPStIbp1n3UsC5ETz -kxmlJ85per5n0/xQpCyrw2u544BMzwVhSyvcG7mm0tCq9Stz+86QNZ8MUhy/XCFh -EVsVS6kkUfykXPcXnbDS+gfpj1bkGoxoigTTfFrjnqKhynFbotSg5ymFXQNoKk/S -Btc9+cMDLz9l+WceR0DTYw/j1Y75hauXTLPXJuuWCpTehTacyH+BCQJJKg71ZDIM -gtG6aoIbs0t0EfOMd9afv9w3pKdVBC/UMejTRrkDfNoSTllkt1ExMVCgyhwn2RAu -rda9EGYrw7AiShJbAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE -FE9pbQN+nZ8HGEO8txBO1b+pxCAoMB8GA1UdIwQYMBaAFE9pbQN+nZ8HGEO8txBO -1b+pxCAoMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAO/Ouyugu -h4X7ZVnnrREUpVe8WJ8kEle7+z802u6teio0cnAxa8cZmIDJgt43d15Ui47y6mdP -yXSEkVYJ1eV6moG2gcKtNuTxVBFT8zRFASbI5Rq8NEQh3q0l/HYWdyGQgJhXnU7q -7C+qPBR7V8F+GBRn7iTGvboVsNIYvbdVgaxTwOjdaRITQrcCtQVBynlQboIOcXKT -RuidDV29rs4prWPVVRaAMCf/drr3uNZK49m1+VLQTkCpx+XCMseqdiThawVQ68W/ -ClTluUI8JPu3B5wwn3la5uBAUhX0/Kr0VvlEl4ftDmVyXr4m+02kLQgH3thcoNyB -M5kYJRF3p+v9WAksmWsbivNSPxpNSGDxoPYzAlOL7SUJuA0t7Zdz7NeWH45gDtoQ -my8YJPamTQr5O8t1wswvziRpyQoijlmn94IM19drNZxDAGrElWe6nEXLuA4399xO -AU++CrYD062KRffaJ00psUjf5BHklka9bAI+1lHIlRcBFanyqqryvy9lG2/QuRqT -9Y41xICHPpQvZuTpqP9BnHAqTyo5GJUefvthATxRCC4oGKQWDzH9OmwjkyB24f0H -hdFbP9IcczLd+rn4jM8Ch3qaluTtT4mNU0OrDhPAARW0eTjb/G49nlG2uBOLZ8/5 -fNkiHfZdxRwBL5joeiQYvITX+txyW/fBOmg= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ -RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD -VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX -DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y -ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy -VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr -mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr -IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK -mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu -XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy -dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye -jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1 -BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3 -DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92 -9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx -jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0 -Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz -ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS -R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFajCCBFKgAwIBAgIEPLU9RjANBgkqhkiG9w0BAQUFADBmMRIwEAYDVQQKEwli -ZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENBczEzMDEGA1UEAxMq -YmVUUlVTVGVkIFJvb3QgQ0EtQmFsdGltb3JlIEltcGxlbWVudGF0aW9uMB4XDTAy -MDQxMTA3Mzg1MVoXDTIyMDQxMTA3Mzg1MVowZjESMBAGA1UEChMJYmVUUlVTVGVk -MRswGQYDVQQLExJiZVRSVVNUZWQgUm9vdCBDQXMxMzAxBgNVBAMTKmJlVFJVU1Rl -ZCBSb290IENBLUJhbHRpbW9yZSBJbXBsZW1lbnRhdGlvbjCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBALx+xDmcjOPWHIb/ymKt4H8wRXqOGrO4x/nRNv8i -805qX4QQ+2aBw5R5MdKR4XeOGCrDFN5R9U+jK7wYFuK13XneIviCfsuBH/0nLI/6 -l2Qijvj/YaOcGx6Sj8CoCd8JEey3fTGaGuqDIQY8n7pc/5TqarjDa1U0Tz0yH92B -FODEPM2dMPgwqZfT7syj0B9fHBOB1BirlNFjw55/NZKeX0Tq7PQiXLfoPX2k+Ymp -kbIq2eszh+6l/ePazIjmiSZuxyuC0F6dWdsU7JGDBcNeDsYq0ATdcT0gTlgn/FP7 -eHgZFLL8kFKJOGJgB7Sg7KxrUNb9uShr71ItOrL/8QFArDcCAwEAAaOCAh4wggIa -MA8GA1UdEwEB/wQFMAMBAf8wggG1BgNVHSAEggGsMIIBqDCCAaQGDysGAQQBsT4A -AAEJKIORMTCCAY8wggFIBggrBgEFBQcCAjCCAToaggE2UmVsaWFuY2Ugb24gb3Ig -dXNlIG9mIHRoaXMgQ2VydGlmaWNhdGUgY3JlYXRlcyBhbiBhY2tub3dsZWRnbWVu -dCBhbmQgYWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJk -IHRlcm1zIGFuZCBjb25kaXRpb25zIG9mIHVzZSwgdGhlIENlcnRpZmljYXRpb24g -UHJhY3RpY2UgU3RhdGVtZW50IGFuZCB0aGUgUmVseWluZyBQYXJ0eSBBZ3JlZW1l -bnQsIHdoaWNoIGNhbiBiZSBmb3VuZCBhdCB0aGUgYmVUUlVTVGVkIHdlYiBzaXRl -LCBodHRwOi8vd3d3LmJldHJ1c3RlZC5jb20vcHJvZHVjdHNfc2VydmljZXMvaW5k -ZXguaHRtbDBBBggrBgEFBQcCARY1aHR0cDovL3d3dy5iZXRydXN0ZWQuY29tL3By -b2R1Y3RzX3NlcnZpY2VzL2luZGV4Lmh0bWwwHQYDVR0OBBYEFEU9w6nR3D8kVpgc -cxiIav+DR+22MB8GA1UdIwQYMBaAFEU9w6nR3D8kVpgccxiIav+DR+22MA4GA1Ud -DwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEASZK8o+6svfoNyYt5hhwjdrCA -WXf82n+0S9/DZEtqTg6t8n1ZdwWtColzsPq8y9yNAIiPpqCy6qxSJ7+hSHyXEHu6 -7RMdmgduyzFiEuhjA6p9beP4G3YheBufS0OM00mG9htc9i5gFdPp43t1P9ACg9AY -gkHNZTfqjjJ+vWuZXTARyNtIVBw74acT02pIk/c9jH8F6M7ziCpjBLjqflh8AXtb -4cV97yHgjQ5dUX2xZ/2jvTg2xvI4hocalmhgRvsoFEdV4aeADGvi6t9NfJBIoDa9 -CReJf8Py05yc493EG931t3GzUwWJBtDLSoDByFOQtTwxiBdQn8nEDovYqAJjDQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFLDCCBBSgAwIBAgIEOU99hzANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJX -VzESMBAGA1UEChMJYmVUUlVTVGVkMRswGQYDVQQDExJiZVRSVVNUZWQgUm9vdCBD -QXMxGjAYBgNVBAMTEWJlVFJVU1RlZCBSb290IENBMB4XDTAwMDYyMDE0MjEwNFoX -DTEwMDYyMDEzMjEwNFowWjELMAkGA1UEBhMCV1cxEjAQBgNVBAoTCWJlVFJVU1Rl -ZDEbMBkGA1UEAxMSYmVUUlVTVGVkIFJvb3QgQ0FzMRowGAYDVQQDExFiZVRSVVNU -ZWQgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANS0c3oT -CjhVAb6JVuGUntS+WutKNHUbYSnE4a0IYCF4SP+00PpeQY1hRIfo7clY+vyTmt9P -6j41ffgzeubx181vSUs9Ty1uDoM6GHh3o8/n9E1z2Jo7Gh2+lVPPIJfCzz4kUmwM -jmVZxXH/YgmPqsWPzGCgc0rXOD8Vcr+il7dw6K/ifhYGTPWqZCZyByWtNfwYsSbX -2P8ZDoMbjNx4RWc0PfSvHI3kbWvtILNnmrRhyxdviTX/507AMhLn7uzf/5cwdO2N -R47rtMNE5qdMf1ZD6Li8tr76g5fmu/vEtpO+GRg+jIG5c4gW9JZDnGdzF5DYCW5j -rEq2I8QBoa2k5MUCAwEAAaOCAfgwggH0MA8GA1UdEwEB/wQFMAMBAf8wggFZBgNV -HSAEggFQMIIBTDCCAUgGCisGAQQBsT4BAAAwggE4MIIBAQYIKwYBBQUHAgIwgfQa -gfFSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBhc3N1 -bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0 -ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGFuZCBjZXJ0aWZpY2F0aW9uIHBy -YWN0aWNlIHN0YXRlbWVudCwgd2hpY2ggY2FuIGJlIGZvdW5kIGF0IGJlVFJVU1Rl -ZCdzIHdlYiBzaXRlLCBodHRwczovL3d3dy5iZVRSVVNUZWQuY29tL3ZhdWx0L3Rl -cm1zMDEGCCsGAQUFBwIBFiVodHRwczovL3d3dy5iZVRSVVNUZWQuY29tL3ZhdWx0 -L3Rlcm1zMDQGA1UdHwQtMCswKaAnoCWkIzAhMRIwEAYDVQQKEwliZVRSVVNUZWQx -CzAJBgNVBAYTAldXMB0GA1UdDgQWBBQquZtpLjub2M3eKjEENGvKBxirZzAfBgNV -HSMEGDAWgBQquZtpLjub2M3eKjEENGvKBxirZzAOBgNVHQ8BAf8EBAMCAf4wDQYJ -KoZIhvcNAQEFBQADggEBAHlh26Nebhax6nZR+csVm8tpvuaBa58oH2U+3RGFktTo -Qb9+M70j5/Egv6S0phkBxoyNNXxlpE8JpNbYIxUFE6dDea/bow6be3ga8wSGWsb2 -jCBHOElQBp1yZzrwmAOtlmdE/D8QDYZN5AA7KXvOOzuZhmElQITcE2K3+spZ1gMe -1lMBzW1MaFVA4e5rxyoAAEiCswoBw2AqDPeCNe5IhpbkdNQ96gFxugR1QKepfzk5 -mlWXKWWuGVUlBXJH0+gY3Ljpr0NzARJ0o+FcXxVdJPP55PS2Z2cS52QiivalQaYc -tmBjRYoQtLpGEK5BV2VsPyMQPyEQWbfkQN0mDCP2qq4= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIGUTCCBTmgAwIBAgIEPLVPQDANBgkqhkiG9w0BAQUFADBmMRIwEAYDVQQKEwli -ZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENBczEzMDEGA1UEAxMq -YmVUUlVTVGVkIFJvb3QgQ0EgLSBFbnRydXN0IEltcGxlbWVudGF0aW9uMB4XDTAy -MDQxMTA4MjQyN1oXDTIyMDQxMTA4NTQyN1owZjESMBAGA1UEChMJYmVUUlVTVGVk -MRswGQYDVQQLExJiZVRSVVNUZWQgUm9vdCBDQXMxMzAxBgNVBAMTKmJlVFJVU1Rl -ZCBSb290IENBIC0gRW50cnVzdCBJbXBsZW1lbnRhdGlvbjCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBALr0RAOqEmq1Q+xVkrYwfTVXDNvzDSduTPdQqJtO -K2/b9a0cS12zqcH+e0TrW6MFDR/FNCswACnxeECypP869AGIF37m1CbTukzqMvtD -d5eHI8XbQ6P1KqNRXuE70mVpflUVm3rnafdE4Fe1FehmYA8NA/uCjqPoEXtsvsdj -DheT389Lrm5zdeDzqrmkwAkbhepxKYhBMvnwKg5sCfJ0a2ZsUhMfGLzUPvfYbiCe -yv78IZTuEyhL11xeDGbu6bsPwTSxfwh28z0mcMmLJR1iJAzqHHVOwBLkuhMdMCkt -VjMFu5dZfsZJT4nXLySotohAtWSSU1Yk5KKghbNekLQSM80CAwEAAaOCAwUwggMB -MIIBtwYDVR0gBIIBrjCCAaowggGmBg8rBgEEAbE+AAACCSiDkTEwggGRMIIBSQYI -KwYBBQUHAgIwggE7GoIBN1JlbGlhbmNlIG9uIG9yIHVzZSBvZiB0aGlzIENlcnRp -ZmljYXRlIGNyZWF0ZXMgYW4gYWNrbm93bGVkZ21lbnQgYW5kIGFjY2VwdGFuY2Ug -b2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0 -aW9ucyBvZiB1c2UsIHRoZSBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVu -dCBhbmQgdGhlIFJlbHlpbmcgUGFydHkgQWdyZWVtZW50LCB3aGljaCBjYW4gYmUg -Zm91bmQgYXQgdGhlIGJlVFJVU1RlZCB3ZWIgc2l0ZSwgaHR0cHM6Ly93d3cuYmV0 -cnVzdGVkLmNvbS9wcm9kdWN0c19zZXJ2aWNlcy9pbmRleC5odG1sMEIGCCsGAQUF -BwIBFjZodHRwczovL3d3dy5iZXRydXN0ZWQuY29tL3Byb2R1Y3RzX3NlcnZpY2Vz -L2luZGV4Lmh0bWwwEQYJYIZIAYb4QgEBBAQDAgAHMIGJBgNVHR8EgYEwfzB9oHug -eaR3MHUxEjAQBgNVBAoTCWJlVFJVU1RlZDEbMBkGA1UECxMSYmVUUlVTVGVkIFJv -b3QgQ0FzMTMwMQYDVQQDEypiZVRSVVNUZWQgUm9vdCBDQSAtIEVudHJ1c3QgSW1w -bGVtZW50YXRpb24xDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMjAwMjA0MTEw -ODI0MjdagQ8yMDIyMDQxMTA4NTQyN1owCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaA -FH1w5a44iwY/qhwaj/nPJDCqhIQWMB0GA1UdDgQWBBR9cOWuOIsGP6ocGo/5zyQw -qoSEFjAMBgNVHRMEBTADAQH/MB0GCSqGSIb2fQdBAAQQMA4bCFY2LjA6NC4wAwIE -kDANBgkqhkiG9w0BAQUFAAOCAQEAKrgXzh8QlOu4mre5X+za95IkrNySO8cgjfKZ -5V04ocI07cUTWVwFtStPYZuR+0H8/NU8TZh2BvWBfevdkObRVlTa4y0MnxEylCIB -evZsLHRnBMylj44ss0O1lKLQfelifwa+JwGDnjr9iu6YQ0pr17WXOzq/T220Y/oz -ADQuLW2WyXvKmWO6vvT2MKAtmJbpVkQFqUSjYRDrgqFnXbxdJ3Wqiig2KjiS2d2k -XgClzMx8KSreKJCrt+G2/30lC0DYqjSjLd4H61/OCt3Kfjp9JsFiaDrmLzfzgYYh -xKlkqu9FNtEaZnz46TfW1mG+oq1I59/mdP7TbX3SJdysYlep9w== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFaDCCBFCgAwIBAgIQO1nHe81bV569N1KsdrSqGjANBgkqhkiG9w0BAQUFADBi -MRIwEAYDVQQKEwliZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENB -czEvMC0GA1UEAxMmYmVUUlVTVGVkIFJvb3QgQ0EgLSBSU0EgSW1wbGVtZW50YXRp -b24wHhcNMDIwNDExMTExODEzWhcNMjIwNDEyMTEwNzI1WjBiMRIwEAYDVQQKEwli -ZVRSVVNUZWQxGzAZBgNVBAsTEmJlVFJVU1RlZCBSb290IENBczEvMC0GA1UEAxMm -YmVUUlVTVGVkIFJvb3QgQ0EgLSBSU0EgSW1wbGVtZW50YXRpb24wggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkujQwCY5X0LkGLG9uJIAiv11DpvpPrILn -HGhwhRujbrWqeNluB0s/6d/16uhUoWGKDi9pdRi3DOUUjXFumLhV/AyV0Jtu4S2I -1DpAa5LxmZZk3tv/ePTulh1HiXzUvrmIdyM6CeYEnm2qXtLIvZpOGd+J6lsOfsPk -tPDgaTuID0GQ+NRxQyTBjyZLO1bp/4xsN+lFrYWMU8NghpBKlsmzVLC7F/AcRdnU -GxlkVgoZ98zh/4avflherHqQH8koOUV7orbHnB/ahdQhhlkwk75TMzf270HPM8er -cmsl9fNTGwxMLvF1S++gh/f+ihXQbNXL+WhTuXAVE8L1LvtDNXUtAgMBAAGjggIY -MIICFDAMBgNVHRMEBTADAQH/MIIBtQYDVR0gBIIBrDCCAagwggGkBg8rBgEEAbE+ -AAADCSiDkTEwggGPMEEGCCsGAQUFBwIBFjVodHRwOi8vd3d3LmJldHJ1c3RlZC5j -b20vcHJvZHVjdHNfc2VydmljZXMvaW5kZXguaHRtbDCCAUgGCCsGAQUFBwICMIIB -OhqCATZSZWxpYW5jZSBvbiBvciB1c2Ugb2YgdGhpcyBDZXJ0aWZpY2F0ZSBjcmVh -dGVzIGFuIGFja25vd2xlZGdtZW50IGFuZCBhY2NlcHRhbmNlIG9mIHRoZSB0aGVu -IGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNl -LCB0aGUgQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1lbnQgYW5kIHRoZSBS -ZWx5aW5nIFBhcnR5IEFncmVlbWVudCwgd2hpY2ggY2FuIGJlIGZvdW5kIGF0IHRo -ZSBiZVRSVVNUZWQgd2ViIHNpdGUsIGh0dHA6Ly93d3cuYmV0cnVzdGVkLmNvbS9w -cm9kdWN0c19zZXJ2aWNlcy9pbmRleC5odG1sMAsGA1UdDwQEAwIBBjAfBgNVHSME -GDAWgBSp7BR++dlDzFMrFK3P9/BZiUHNGTAdBgNVHQ4EFgQUqewUfvnZQ8xTKxSt -z/fwWYlBzRkwDQYJKoZIhvcNAQEFBQADggEBANuXsHXqDMTBmMpWBcCorSZIry0g -6IHHtt9DwSwddUvUQo3neqh03GZCWYez9Wlt2ames30cMcH1VOJZJEnl7r05pmuK -mET7m9cqg5c0Lcd9NUwtNLg+DcTsiCevnpL9UGGCqGAHFFPMZRPB9kdEadIxyKbd -LrML3kqNWz2rDcI1UqJWN8wyiyiFQpyRQHpwKzg21eFzGh/l+n5f3NacOzDq28Bb -J1zTcwfBwvNMm2+fG8oeqqg4MwlYsq78B+g23FW6L09A/nq9BqaBwZMifIYRCgZ3 -SK41ty8ymmFei74pnykkiFY5LKjSq5YDWtRIn7lAhAuYaPsBQ9Yb4gmxlxw= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDDDCCAfSgAwIBAgIDAQAgMA0GCSqGSIb3DQEBBQUAMD4xCzAJBgNVBAYTAlBM -MRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBD -QTAeFw0wMjA2MTExMDQ2MzlaFw0yNzA2MTExMDQ2MzlaMD4xCzAJBgNVBAYTAlBM -MRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBD -QTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM6xwS7TT3zNJc4YPk/E -jG+AanPIW1H4m9LcuwBcsaD8dQPugfCI7iNS6eYVM42sLQnFdvkrOYCJ5JdLkKWo -ePhzQ3ukYbDYWMzhbGZ+nPMJXlVjhNWo7/OxLjBos8Q82KxujZlakE403Daaj4GI -ULdtlkIJ89eVgw1BS7Bqa/j8D35in2fE7SZfECYPCE/wpFcozo+47UX2bu4lXapu -Ob7kky/ZR6By6/qmW6/KUz/iDsaWVhFu9+lmqSbYf5VT7QqFiLpPKaVCjF62/IUg -AKpoC6EahQGcxEZjgoi2IrHu/qpGWX7PNSzVttpd90gzFFS269lvzs2I1qsb2pY7 -HVkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEA -uI3O7+cUus/usESSbLQ5PqKEbq24IXfS1HeCh+YgQYHu4vgRt2PRFze+GXYkHAQa -TOs9qmdvLdTN/mUxcMUbpgIKumB7bVjCmkn+YzILa+M6wKyrO7Do0wlRjBCDxjTg -xSvgGrZgFCdsMneMvLJymM/NzD+5yCRCFNZX/OYmQ6kd5YCQzgNUKD73P9P4Te1q -CjqTE5s7FCMTY5w/0YcneeVMUeMBrYVdGjux1XMQpNPyvG5k9VpWkKjHDkx0Dy5x -O/fIR/RpbxXyEV6DHpx8Uq79AtoSqFlnGNu8cN2bsWntgM6JQEhqDjXKKWYVIZQs -6GAqm4VKQPNriiTsBhYscw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb -MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow -GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj -YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL -MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE -BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM -GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP -ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua -BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe -3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4 -YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR -rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm -ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU -oBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF -MAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20v -QUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29t -b2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUF -AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q -GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz -Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2 -G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi -l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3 -smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEPzCCAyegAwIBAgIBATANBgkqhkiG9w0BAQUFADB+MQswCQYDVQQGEwJHQjEb -MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow -GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEkMCIGA1UEAwwbU2VjdXJlIENlcnRp -ZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVow -fjELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G -A1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxJDAiBgNV -BAMMG1NlY3VyZSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEB -BQADggEPADCCAQoCggEBAMBxM4KK0HDrc4eCQNUd5MvJDkKQ+d40uaG6EfQlhfPM -cm3ye5drswfxdySRXyWP9nQ95IDC+DwN879A6vfIUtFyb+/Iq0G4bi4XKpVpDM3S -HpR7LZQdqnXXs5jLrLxkU0C8j6ysNstcrbvd4JQX7NFc0L/vpZXJkMWwrPsbQ996 -CF23uPJAGysnnlDOXmWCiIxe004MeuoIkbY2qitC++rCoznl2yY4rYsK7hljxxwk -3wN42ubqwUcaCwtGCd0C/N7Lh1/XMGNooa7cMqG6vv5Eq2i2pRcV/b3Vp6ea5EQz -6YiO/O1R65NxTq0B50SOqy3LqP4BSUjwwN3HaNiS/j0CAwEAAaOBxzCBxDAdBgNV -HQ4EFgQUPNiTiMLAggnMAZkGkyDpnnAJY08wDgYDVR0PAQH/BAQDAgEGMA8GA1Ud -EwEB/wQFMAMBAf8wgYEGA1UdHwR6MHgwO6A5oDeGNWh0dHA6Ly9jcmwuY29tb2Rv -Y2EuY29tL1NlY3VyZUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDmgN6A1hjNodHRw -Oi8vY3JsLmNvbW9kby5uZXQvU2VjdXJlQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmww -DQYJKoZIhvcNAQEFBQADggEBAIcBbSMdflsXfcFhMs+P5/OKlFlm4J4oqF7Tt/Q0 -5qo5spcWxYJvMqTpjOev/e/C6LlLqqP05tqNZSH7uoDrJiiFGv45jN5bBAS0VPmj -Z55B+glSzAVIqMk/IQQezkhr/IXownuvf7fM+F86/TXGDe+X3EyrEeFryzHRbPtI -gKvcnDe4IRRLDXE97IMzbtFuMhbsmMcWi1mmNKsFVy2T96oTy9IT4rcuO81rUBcJ -aD61JlfutuC23bkpgHl9j6PwpCikFcSF9CfUa7/lXORlAnZUtOM3ZiTTGWHIUhDl -izeauan5Hb/qmZJhlv8BzaFfDbxxvA6sCx1HRR3B7Hzs/Sk= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEQzCCAyugAwIBAgIBATANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJHQjEb -MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow -GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDElMCMGA1UEAwwcVHJ1c3RlZCBDZXJ0 -aWZpY2F0ZSBTZXJ2aWNlczAeFw0wNDAxMDEwMDAwMDBaFw0yODEyMzEyMzU5NTla -MH8xCzAJBgNVBAYTAkdCMRswGQYDVQQIDBJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO -BgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoMEUNvbW9kbyBDQSBMaW1pdGVkMSUwIwYD -VQQDDBxUcnVzdGVkIENlcnRpZmljYXRlIFNlcnZpY2VzMIIBIjANBgkqhkiG9w0B -AQEFAAOCAQ8AMIIBCgKCAQEA33FvNlhTWvI2VFeAxHQIIO0Yfyod5jWaHiWsnOWW -fnJSoBVC21ndZHoa0Lh73TkVvFVIxO06AOoxEbrycXQaZ7jPM8yoMa+j49d/vzMt -TGo87IvDktJTdyR0nAducPy9C1t2ul/y/9c3S0pgePfw+spwtOpZqqPOSC+pw7IL -fhdyFgymBwwbOM/JYrc/oJOlh0Hyt3BAd9i+FHzjqMB6juljatEPmsbS9Is6FARW -1O24zG71++IsWL1/T2sr92AkWCTOJu80kTrV44HQsvAEAtdbtz6SrGsSivnkBbA7 -kUlcsutT6vifR4buv5XAwAaf0lteERv0xwQ1KdJVXOTt6wIDAQABo4HJMIHGMB0G -A1UdDgQWBBTFe1i97doladL3WRaoszLAeydb9DAOBgNVHQ8BAf8EBAMCAQYwDwYD -VR0TAQH/BAUwAwEB/zCBgwYDVR0fBHwwejA8oDqgOIY2aHR0cDovL2NybC5jb21v -ZG9jYS5jb20vVHJ1c3RlZENlcnRpZmljYXRlU2VydmljZXMuY3JsMDqgOKA2hjRo -dHRwOi8vY3JsLmNvbW9kby5uZXQvVHJ1c3RlZENlcnRpZmljYXRlU2VydmljZXMu -Y3JsMA0GCSqGSIb3DQEBBQUAA4IBAQDIk4E7ibSvuIQSTI3S8NtwuleGFTQQuS9/ -HrCoiWChisJ3DFBKmwCL2Iv0QeLQg4pKHBQGsKNoBXAxMKdTmw7pSqBYaWcOrp32 -pSxBvzwGa+RZzG0Q8ZZvH9/0BAKkn0U+yNj6NkZEUD+Cl5EfKNsYEYwq5GWDVxIS -jBc/lDb+XbDABHcTuPQV1T84zJQ6VdCsmPW6AF/ghhmBeC8owH7TzEIK9a5QoNE+ -xqFx7D+gIIxmOom0jtTYsU0lR+4viMi14QVFwL4Ucd56/Y57fU0IlqUSc/Atyjcn -dBInTMu2l+nZrghtWjlA3QVHdWpaIbOjGM9O9y5Xt5hwXsjEeLBi ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDKTCCApKgAwIBAgIENnAVljANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJV -UzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMREwDwYDVQQL -EwhEU1RDQSBFMTAeFw05ODEyMTAxODEwMjNaFw0xODEyMTAxODQwMjNaMEYxCzAJ -BgNVBAYTAlVTMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4x -ETAPBgNVBAsTCERTVENBIEUxMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQCg -bIGpzzQeJN3+hijM3oMv+V7UQtLodGBmE5gGHKlREmlvMVW5SXIACH7TpWJENySZ -j9mDSI+ZbZUTu0M7LklOiDfBu1h//uG9+LthzfNHwJmm8fOR6Hh8AMthyUQncWlV -Sn5JTe2io74CTADKAqjuAQIxZA9SLRN0dja1erQtcQIBA6OCASQwggEgMBEGCWCG -SAGG+EIBAQQEAwIABzBoBgNVHR8EYTBfMF2gW6BZpFcwVTELMAkGA1UEBhMCVVMx -JDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UECxMI -RFNUQ0EgRTExDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMTk5ODEyMTAxODEw -MjNagQ8yMDE4MTIxMDE4MTAyM1owCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaAFGp5 -fpFpRhgTCgJ3pVlbYJglDqL4MB0GA1UdDgQWBBRqeX6RaUYYEwoCd6VZW2CYJQ6i -+DAMBgNVHRMEBTADAQH/MBkGCSqGSIb2fQdBAAQMMAobBFY0LjADAgSQMA0GCSqG -SIb3DQEBBQUAA4GBACIS2Hod3IEGtgllsofIH160L+nEHvI8wbsEkBFKg05+k7lN -QseSJqBcNJo4cvj9axY+IO6CizEqkzaFI4iKPANo08kJD038bKTaKHKTDomAsH3+ -gG9lbRgzl4vCa4nuYD3Im+9/KzJic5PLPON74nZ4RbyhkwS7hp86W0N6w4pl ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID2DCCAsACEQDQHkCLAAACfAAAAAIAAAABMA0GCSqGSIb3DQEBBQUAMIGpMQsw -CQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMOU2FsdCBMYWtlIENp -dHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UE -CxMIRFNUQ0EgWDExFjAUBgNVBAMTDURTVCBSb290Q0EgWDExITAfBgkqhkiG9w0B -CQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTAeFw05ODEyMDExODE4NTVaFw0wODExMjgx -ODE4NTVaMIGpMQswCQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMO -U2FsdCBMYWtlIENpdHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0 -IENvLjERMA8GA1UECxMIRFNUQ0EgWDExFjAUBgNVBAMTDURTVCBSb290Q0EgWDEx -ITAfBgkqhkiG9w0BCQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBANLGJrbnpT3BxGjVUG9TxW9JEwm4ryxIjRRqoxdf -WvnTLnUv2Chi0ZMv/E3Uq4flCMeZ55I/db3rJbQVwZsZPdJEjdd0IG03Ao9pk1uK -xBmd9LIO/BZsubEFkoPRhSxglD5FVaDZqwgh5mDoO3TymVBRaNADLbGAvqPYUrBE -zUNKcI5YhZXhTizWLUFv1oTnyJhEykfbLCSlaSbPa7gnYsP0yXqSI+0TZ4KuRS5F -5X5yP4WdlGIQ5jyRoa13AOAV7POEgHJ6jm5gl8ckWRA0g1vhpaRptlc1HHhZxtMv -OnNn7pTKBBMFYgZwI7P0fO5F2WQLW0mqpEPOJsREEmy43XkCAwEAATANBgkqhkiG -9w0BAQUFAAOCAQEAojeyP2n714Z5VEkxlTMr89EJFEliYIalsBHiUMIdBlc+Legz -ZL6bqq1fG03UmZWii5rJYnK1aerZWKs17RWiQ9a2vAd5ZWRzfdd5ynvVWlHG4VME -lo04z6MXrDlxawHDi1M8Y+nuecDkvpIyZHqzH5eUYr3qsiAVlfuX8ngvYzZAOONG -Dx3drJXK50uQe7FLqdTF65raqtWjlBRGjS0f8zrWkzr2Pnn86Oawde3uPclwx12q -gUtGJRzHbBXjlU4PqjI3lAoXJJIThFjSY28r9+ZbYgsTF7ANUkz+/m9c4pFuHf2k -Ytdo+o56T9II2pPc8JIRetDccpMMc5NihWjQ9A== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDKTCCApKgAwIBAgIENm7TzjANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJV -UzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMREwDwYDVQQL -EwhEU1RDQSBFMjAeFw05ODEyMDkxOTE3MjZaFw0xODEyMDkxOTQ3MjZaMEYxCzAJ -BgNVBAYTAlVTMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4x -ETAPBgNVBAsTCERTVENBIEUyMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQC/ -k48Xku8zExjrEH9OFr//Bo8qhbxe+SSmJIi2A7fBw18DW9Fvrn5C6mYjuGODVvso -LeE4i7TuqAHhzhy2iCoiRoX7n6dwqUcUP87eZfCocfdPJmyMvMa1795JJ/9IKn3o -TQPMx7JSxhcxEzu1TdvIxPbDDyQq2gyd55FbgM2UnQIBA6OCASQwggEgMBEGCWCG -SAGG+EIBAQQEAwIABzBoBgNVHR8EYTBfMF2gW6BZpFcwVTELMAkGA1UEBhMCVVMx -JDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UECxMI -RFNUQ0EgRTIxDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMTk5ODEyMDkxOTE3 -MjZagQ8yMDE4MTIwOTE5MTcyNlowCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaAFB6C -TShlgDzJQW6sNS5ay97u+DlbMB0GA1UdDgQWBBQegk0oZYA8yUFurDUuWsve7vg5 -WzAMBgNVHRMEBTADAQH/MBkGCSqGSIb2fQdBAAQMMAobBFY0LjADAgSQMA0GCSqG -SIb3DQEBBQUAA4GBAEeNg61i8tuwnkUiBbmi1gMOOHLnnvx75pO2mqWilMg0HZHR -xdf0CiUPPXiBng+xZ8SQTGPdXqfiup/1902lMXucKS1M/mQ+7LZT/uqb7YLbdHVL -B3luHtgZg3Pe9T7Qtd7nS2h9Qy4qIOF+oHhEngj1mPnHfxsb1gYgAlihw6ID ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID2DCCAsACEQDQHkCLAAB3bQAAAAEAAAAEMA0GCSqGSIb3DQEBBQUAMIGpMQsw -CQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMOU2FsdCBMYWtlIENp -dHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0IENvLjERMA8GA1UE -CxMIRFNUQ0EgWDIxFjAUBgNVBAMTDURTVCBSb290Q0EgWDIxITAfBgkqhkiG9w0B -CQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTAeFw05ODExMzAyMjQ2MTZaFw0wODExMjcy -MjQ2MTZaMIGpMQswCQYDVQQGEwJ1czENMAsGA1UECBMEVXRhaDEXMBUGA1UEBxMO -U2FsdCBMYWtlIENpdHkxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0dXJlIFRydXN0 -IENvLjERMA8GA1UECxMIRFNUQ0EgWDIxFjAUBgNVBAMTDURTVCBSb290Q0EgWDIx -ITAfBgkqhkiG9w0BCQEWEmNhQGRpZ3NpZ3RydXN0LmNvbTCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBANx18IzAdZaawGIfJvfE4Zrq4FZzW5nNAUSoCLbV -p9oaBBg5kkp4o4HC9Xd6ULRw/5qrxsfKboNPQpj7Jgva3G3WqZlVUmfpKAOS3OWw -BZoPFflrWXJW8vo5/Kpo7g8fEIMv/J36F5bdguPmRX3AS4BEH+0s4IT9kVySVGkl -5WJp3OXuAFK9MwutdQKFp2RQLcUZGTDAJtvJ0/0uma1ZtQtN1EGuhUhDWdy3qOKi -3sOP17ihYqZoUFLkzzGnlIXan0YyF1bl8utmPRL/Q9uY73fPy4GNNLHGUEom0eQ+ -QVCvbK4iNC7Va26Dunm4dmVI2gkpZGMiuftHdoWMhkTLCdsCAwEAATANBgkqhkiG -9w0BAQUFAAOCAQEAtTYOXeFhKFoRZcA/gwN5Tb4opgsHAlKFzfiR0BBstWogWxyQ -2TA8xkieil5k+aFxd+8EJx8H6+Qm93N0yUQYGmbT4EOvkTvRyyzYdFQ6HE3K1GjN -I3wdEJ5F6fYAbqbNGf9PLCmPV03Ed5K+4EwJ+11EhmYhqLkyolbV6YyDfFk/xPEL -553snr2cGA4+wjl5KLcDDQjLxufZATdQEOzMYRZA1K8xdHv8PzGn0EdzMzkbzE5q -10mDEQb+64JYMzJM8FasHpwvVpp7wUocpf1VNs78lk30sPDst2yC7S8xmUJMqbIN -uBVd8d+6ybVK1GSYsyapMMj9puyrliGtf8J4tg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEgzCCA+ygAwIBAgIEOJ725DANBgkqhkiG9w0BAQQFADCBtDEUMBIGA1UEChML -RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9HQ0NBX0NQUyBp -bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAyMDAw -IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENsaWVu -dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMDAyMDcxNjE2NDBaFw0yMDAy -MDcxNjQ2NDBaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3 -LmVudHJ1c3QubmV0L0dDQ0FfQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp -YWIuKTElMCMGA1UECxMcKGMpIDIwMDAgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG -A1UEAxMqRW50cnVzdC5uZXQgQ2xpZW50IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTdLS25MVL1qFof2LV7PdRV7Ny -Spj10InJrWPNTTVRaoTUrcloeW+46xHbh65cJFET8VQlhK8pK5/jgOLZy93GRUk0 -iJBeAZfv6lOm3fzB3ksqJeTpNfpVBQbliXrqpBFXO/x8PTbNZzVtpKklWb1m9fkn -5JVn1j+SgF7yNH0rhQIDAQABo4IBnjCCAZowEQYJYIZIAYb4QgEBBAQDAgAHMIHd -BgNVHR8EgdUwgdIwgc+ggcyggcmkgcYwgcMxFDASBgNVBAoTC0VudHJ1c3QubmV0 -MUAwPgYDVQQLFDd3d3cuZW50cnVzdC5uZXQvR0NDQV9DUFMgaW5jb3JwLiBieSBy -ZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMjAwMCBFbnRydXN0Lm5l -dCBMaW1pdGVkMTMwMQYDVQQDEypFbnRydXN0Lm5ldCBDbGllbnQgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkxDTALBgNVBAMTBENSTDEwKwYDVR0QBCQwIoAPMjAwMDAy -MDcxNjE2NDBagQ8yMDIwMDIwNzE2NDY0MFowCwYDVR0PBAQDAgEGMB8GA1UdIwQY -MBaAFISLdP3FjcD/J20gN0V8/i3OutN9MB0GA1UdDgQWBBSEi3T9xY3A/ydtIDdF -fP4tzrrTfTAMBgNVHRMEBTADAQH/MB0GCSqGSIb2fQdBAAQQMA4bCFY1LjA6NC4w -AwIEkDANBgkqhkiG9w0BAQQFAAOBgQBObzWAO9GK9Q6nIMstZVXQkvTnhLUGJoMS -hAusO7JE7r3PQNsgDrpuFOow4DtifH+La3xKp9U1PL6oXOpLu5OOgGarDyn9TS2/ -GpsKkMWr2tGzhtQvJFJcem3G8v7lTRowjJDyutdKPkN+1MhQGof4T4HHdguEOnKd -zmVml64mXg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIElTCCA/6gAwIBAgIEOJsRPDANBgkqhkiG9w0BAQQFADCBujEUMBIGA1UEChML -RW50cnVzdC5uZXQxPzA9BgNVBAsUNnd3dy5lbnRydXN0Lm5ldC9TU0xfQ1BTIGlu -Y29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMcKGMpIDIwMDAg -RW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5uZXQgU2VjdXJl -IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMDAyMDQxNzIwMDBa -Fw0yMDAyMDQxNzUwMDBaMIG6MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDE/MD0GA1UE -CxQ2d3d3LmVudHJ1c3QubmV0L1NTTF9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p -dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMjAwMCBFbnRydXN0Lm5ldCBMaW1pdGVk -MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp -b24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHwV9OcfHO -8GCGD9JYf9Mzly0XonUwtZZkJi9ow0SrqHXmAGc0V55lxyKbc+bT3QgON1WqJUaB -bL3+qPZ1V1eMkGxKwz6LS0MKyRFWmponIpnPVZ5h2QLifLZ8OAfc439PmrkDQYC2 -dWcTC5/oVzbIXQA23mYU2m52H083jIITiQIDAQABo4IBpDCCAaAwEQYJYIZIAYb4 -QgEBBAQDAgAHMIHjBgNVHR8EgdswgdgwgdWggdKggc+kgcwwgckxFDASBgNVBAoT -C0VudHJ1c3QubmV0MT8wPQYDVQQLFDZ3d3cuZW50cnVzdC5uZXQvU1NMX0NQUyBp -bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAyMDAw -IEVudHJ1c3QubmV0IExpbWl0ZWQxOjA4BgNVBAMTMUVudHJ1c3QubmV0IFNlY3Vy -ZSBTZXJ2ZXIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxDTALBgNVBAMTBENSTDEw -KwYDVR0QBCQwIoAPMjAwMDAyMDQxNzIwMDBagQ8yMDIwMDIwNDE3NTAwMFowCwYD -VR0PBAQDAgEGMB8GA1UdIwQYMBaAFMtswGvjuz7L/CKc/vuLkpyw8m4iMB0GA1Ud -DgQWBBTLbMBr47s+y/winP77i5KcsPJuIjAMBgNVHRMEBTADAQH/MB0GCSqGSIb2 -fQdBAAQQMA4bCFY1LjA6NC4wAwIEkDANBgkqhkiG9w0BAQQFAAOBgQBi24GRzsia -d0Iv7L0no1MPUBvqTpLwqa+poLpIYcvvyQbvH9X07t9WLebKahlzqlO+krNQAraF -JnJj2HVQYnUUt7NQGj/KEQALhUVpbbalrlHhStyCP2yMNLJ3a9kC9n8O6mUE8c1U -yrrJzOCE98g+EZfTYAkYvAX/bIkz8OwVDw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEXDCCA0SgAwIBAgIEOGO5ZjANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML -RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp -bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5 -IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp -ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0xOTEy -MjQxODIwNTFaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3 -LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp -YWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG -A1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU1LqRKGsuqjIAcVFmQq -K0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOLGp18EzoOH1u3Hs/lJBQe -sYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSrhRSGlVuX -MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT -XTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/ -HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH -4QIDAQABo3QwcjARBglghkgBhvhCAQEEBAMCAAcwHwYDVR0jBBgwFoAUVeSB0RGA -vtiJuQijMfmhJAkWuXAwHQYDVR0OBBYEFFXkgdERgL7YibkIozH5oSQJFrlwMB0G -CSqGSIb2fQdBAAQQMA4bCFY1LjA6NC4wAwIEkDANBgkqhkiG9w0BAQUFAAOCAQEA -WUesIYSKF8mciVMeuoCFGsY8Tj6xnLZ8xpJdGGQC49MGCBFhfGPjK50xA3B20qMo -oPS7mmNz7W3lKtvtFKkrxjYR0CvrB4ul2p5cGZ1WEvVUKcgF7bISKo30Axv/55IQ -h7A6tcOdBTcSo8f0FbnVpDkWm1M6I5HxqIKiaohowXkCIryqptau37AUX7iH0N18 -f3v/rxzP5tsHrV7bhZ3QKw0z2wTR5klAEyt2+z7pnIkPFc4YsIV4IU9rTw76NmfN -B/L/CNDi3tm/Kq+4h4YhPATKt5Rof8886ZjXOP/swNlQ8C5LWK5Gb9Auw2DaclVy -vUxFnmG6v4SBkgPR0ml8xQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIE7TCCBFagAwIBAgIEOAOR7jANBgkqhkiG9w0BAQQFADCByTELMAkGA1UEBhMC -VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MUgwRgYDVQQLFD93d3cuZW50cnVzdC5u -ZXQvQ2xpZW50X0NBX0luZm8vQ1BTIGluY29ycC4gYnkgcmVmLiBsaW1pdHMgbGlh -Yi4xJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV -BAMTKkVudHJ1c3QubmV0IENsaWVudCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe -Fw05OTEwMTIxOTI0MzBaFw0xOTEwMTIxOTU0MzBaMIHJMQswCQYDVQQGEwJVUzEU -MBIGA1UEChMLRW50cnVzdC5uZXQxSDBGBgNVBAsUP3d3dy5lbnRydXN0Lm5ldC9D -bGllbnRfQ0FfSW5mby9DUFMgaW5jb3JwLiBieSByZWYuIGxpbWl0cyBsaWFiLjEl -MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMq -RW50cnVzdC5uZXQgQ2xpZW50IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0G -CSqGSIb3DQEBAQUAA4GLADCBhwKBgQDIOpleMRffrCdvkHvkGf9FozTC28GoT/Bo -6oT9n3V5z8GKUZSvx1cDR2SerYIbWtp/N3hHuzeYEpbOxhN979IMMFGpOZ5V+Pux -5zDeg7K6PvHViTs7hbqqdCz+PzFur5GVbgbUB01LLFZHGARS2g4Qk79jkJvh34zm -AqTmT173iwIBA6OCAeAwggHcMBEGCWCGSAGG+EIBAQQEAwIABzCCASIGA1UdHwSC -ARkwggEVMIHkoIHhoIHepIHbMIHYMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50 -cnVzdC5uZXQxSDBGBgNVBAsUP3d3dy5lbnRydXN0Lm5ldC9DbGllbnRfQ0FfSW5m -by9DUFMgaW5jb3JwLiBieSByZWYuIGxpbWl0cyBsaWFiLjElMCMGA1UECxMcKGMp -IDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5uZXQg -Q2xpZW50IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCyg -KqAohiZodHRwOi8vd3d3LmVudHJ1c3QubmV0L0NSTC9DbGllbnQxLmNybDArBgNV -HRAEJDAigA8xOTk5MTAxMjE5MjQzMFqBDzIwMTkxMDEyMTkyNDMwWjALBgNVHQ8E -BAMCAQYwHwYDVR0jBBgwFoAUxPucKXuXzUyW/O5bs8qZdIuV6kwwHQYDVR0OBBYE -FMT7nCl7l81MlvzuW7PKmXSLlepMMAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EA -BAwwChsEVjQuMAMCBJAwDQYJKoZIhvcNAQEEBQADgYEAP66K8ddmAwWePvrqHEa7 -pFuPeJoSSJn59DXeDDYHAmsQOokUgZwxpnyyQbJq5wcBoUv5nyU7lsqZwz6hURzz -wy5E97BnRqqS5TvaHBkUODDV4qIxJS7x7EU47fgGWANzYrAQMY9Av2TgXD7FTx/a -EkP/TOYGJqibGapEPHayXOw= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC -VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u -ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc -KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u -ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1 -MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE -ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j -b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF -bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg -U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA -A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/ -I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3 -wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC -AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb -oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5 -BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p -dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk -MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp -b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu -dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0 -MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi -E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa -MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI -hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN -95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd -2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV -UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy -dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1 -MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx -dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B -AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f -BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A -cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC -AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ -MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm -aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw -ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj -IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF -MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA -A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y -7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh -1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICgjCCAeugAwIBAgIBBDANBgkqhkiG9w0BAQQFADBTMQswCQYDVQQGEwJVUzEc -MBoGA1UEChMTRXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBT -ZWN1cmUgZUJ1c2luZXNzIENBLTEwHhcNOTkwNjIxMDQwMDAwWhcNMjAwNjIxMDQw -MDAwWjBTMQswCQYDVQQGEwJVUzEcMBoGA1UEChMTRXF1aWZheCBTZWN1cmUgSW5j -LjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNzIENBLTEwgZ8wDQYJ -KoZIhvcNAQEBBQADgY0AMIGJAoGBAM4vGbwXt3fek6lfWg0XTzQaDJj0ItlZ1MRo -RvC0NcWFAyDGr0WlIVFFQesWWDYyb+JQYmT5/VGcqiTZ9J2DKocKIdMSODRsjQBu -WqDZQu4aIZX5UkxVWsUPOE9G+m34LjXWHXzr4vCwdYDIqROsvojvOm6rXyo4YgKw -Env+j6YDAgMBAAGjZjBkMBEGCWCGSAGG+EIBAQQEAwIABzAPBgNVHRMBAf8EBTAD -AQH/MB8GA1UdIwQYMBaAFEp4MlIR21kWNl7fwRQ2QGpHfEyhMB0GA1UdDgQWBBRK -eDJSEdtZFjZe38EUNkBqR3xMoTANBgkqhkiG9w0BAQQFAAOBgQB1W6ibAxHm6VZM -zfmpTMANmvPMZWnmJXbMWbfWVMMdzZmsGd20hdXgPfxiIKeES1hl8eL5lSE/9dR+ -WB5Hh1Q+WKG1tfgq73HnvMP2sUlG4tega+VWeponmHxGYhTnyfxuAxJ5gDgdSIKN -/Bf+KpYrtWKmpj29f5JZzVoqgrI3eQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDIDCCAomgAwIBAgIEN3DPtTANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV -UzEXMBUGA1UEChMORXF1aWZheCBTZWN1cmUxJjAkBgNVBAsTHUVxdWlmYXggU2Vj -dXJlIGVCdXNpbmVzcyBDQS0yMB4XDTk5MDYyMzEyMTQ0NVoXDTE5MDYyMzEyMTQ0 -NVowTjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDkVxdWlmYXggU2VjdXJlMSYwJAYD -VQQLEx1FcXVpZmF4IFNlY3VyZSBlQnVzaW5lc3MgQ0EtMjCBnzANBgkqhkiG9w0B -AQEFAAOBjQAwgYkCgYEA5Dk5kx5SBhsoNviyoynF7Y6yEb3+6+e0dMKP/wXn2Z0G -vxLIPw7y1tEkshHe0XMJitSxLJgJDR5QRrKDpkWNYmi7hRsgcDKqQM2mll/EcTc/ -BPO3QSQ5BxoeLmFYoBIL5aXfxavqN3HMHMg3OrmXUqesxWoklE6ce8/AatbfIb0C -AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEX -MBUGA1UEChMORXF1aWZheCBTZWN1cmUxJjAkBgNVBAsTHUVxdWlmYXggU2VjdXJl -IGVCdXNpbmVzcyBDQS0yMQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTkw -NjIzMTIxNDQ1WjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUUJ4L6q9euSBIplBq -y/3YIHqngnYwHQYDVR0OBBYEFFCeC+qvXrkgSKZQasv92CB6p4J2MAwGA1UdEwQF -MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA -A4GBAAyGgq3oThr1jokn4jVYPSm0B482UJW/bsGe68SQsoWou7dC4A8HOd/7npCy -0cE+U58DRLB+S/Rv5Hwf5+Kx5Lia78O9zt4LMjTZ3ijtM2vE1Nc9ElirfQkty3D1 -E4qUoSek1nDFbZS1yX2doNLGCEnZZpum0/QL3MUmV+GRMOrN ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT -MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i -YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG -EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg -R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9 -9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq -fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv -iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU -1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+ -bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW -MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA -ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l -uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn -Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS -tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF -PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un -hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV -5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG -A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv -b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw -MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i -YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT -aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ -jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp -xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp -1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG -snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ -U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 -9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E -BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B -AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz -yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE -38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP -AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad -DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME -HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYD -VQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNv -bHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJv -b3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEzMjM1OTAwWjB1MQswCQYDVQQGEwJV -UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU -cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds -b2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrH -iM3dFw4usJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTS -r41tiGeA5u2ylc9yMcqlHHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X4 -04Wqk2kmhXBIgD8SFcd5tB8FLztimQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAG3r -GwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMWM4ETCJ57NE7fQMh017l9 -3PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P -lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIB+jCCAWMCAgGjMA0GCSqGSIb3DQEBBAUAMEUxCzAJBgNVBAYTAlVTMRgwFgYD -VQQKEw9HVEUgQ29ycG9yYXRpb24xHDAaBgNVBAMTE0dURSBDeWJlclRydXN0IFJv -b3QwHhcNOTYwMjIzMjMwMTAwWhcNMDYwMjIzMjM1OTAwWjBFMQswCQYDVQQGEwJV -UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMRwwGgYDVQQDExNHVEUgQ3liZXJU -cnVzdCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC45k+625h8cXyv -RLfTD0bZZOWTwUKOx7pJjTUteueLveUFMVnGsS8KDPufpz+iCWaEVh43KRuH6X4M -ypqfpX/1FZSj1aJGgthoTNE3FQZor734sLPwKfWVWgkWYXcKIiXUT0Wqx73llt/5 -1KiOQswkwB6RJ0q1bQaAYznEol44AwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABKz -dcZfHeFhVYAA1IFLezEPI2PnPfMD+fQ2qLvZ46WXTeorKeDWanOB5sCJo9Px4KWl -IjeaY8JIILTbcuPI9tl8vrGvU9oUtCG41tWW4/5ODFlitppK+ULdjG+BqXH/9Apy -bW1EDp3zdHSo1TRJ6V6e6bR64eVaH4QwnNOfpSXY ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIH9zCCB2CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARwxCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE -ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE -ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEzMDEGA1UECxMq -SVBTIENBIENoYWluZWQgQ0FzIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MTMwMQYD -VQQDEypJUFMgQ0EgQ2hhaW5lZCBDQXMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx -HjAcBgkqhkiG9w0BCQEWD2lwc0BtYWlsLmlwcy5lczAeFw0wMTEyMjkwMDUzNTha -Fw0yNTEyMjcwMDUzNThaMIIBHDELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUJhcmNl -bG9uYTESMBAGA1UEBxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJUFMgSW50ZXJuZXQg -cHVibGlzaGluZyBTZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJpcHNAbWFpbC5pcHMu -ZXMgQy5JLkYuICBCLTYwOTI5NDUyMTMwMQYDVQQLEypJUFMgQ0EgQ2hhaW5lZCBD -QXMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMzAxBgNVBAMTKklQUyBDQSBDaGFp -bmVkIENBcyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEeMBwGCSqGSIb3DQEJARYP -aXBzQG1haWwuaXBzLmVzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcVpJJ -spQgvJhPUOtopKdJC7/SMejHT8KGC/po/UNaivNgkjWZOLtNA1IhW/A3mTXhQSCB -hYEFcYGdtJUZqV92NC5jNzVXjrQfQj8VXOF6wV8TGDIxya2+o8eDZh65nAQTy2nB -Bt4wBrszo7Uf8I9vzv+W6FS+ZoCua9tBhDaiPQIDAQABo4IEQzCCBD8wHQYDVR0O -BBYEFKGtMbH5PuEXpsirNPxShwkeYlJBMIIBTgYDVR0jBIIBRTCCAUGAFKGtMbH5 -PuEXpsirNPxShwkeYlJBoYIBJKSCASAwggEcMQswCQYDVQQGEwJFUzESMBAGA1UE -CBMJQmFyY2Vsb25hMRIwEAYDVQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJ -bnRlcm5ldCBwdWJsaXNoaW5nIFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0Bt -YWlsLmlwcy5lcyBDLkkuRi4gIEItNjA5Mjk0NTIxMzAxBgNVBAsTKklQUyBDQSBD -aGFpbmVkIENBcyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEzMDEGA1UEAxMqSVBT -IENBIENoYWluZWQgQ0FzIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4wHAYJKoZI -hvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYDVR0TBAUwAwEB/zAMBgNVHQ8E -BQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYBBQUHAwMG -CCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIBFQYKKwYBBAGCNwIBFgYKKwYB -BAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhCAQEEBAMCAAcwGgYDVR0RBBMw -EYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGBD2lwc0BtYWlsLmlwcy5lczBC -BglghkgBhvhCAQ0ENRYzQ2hhaW5lZCBDQSBDZXJ0aWZpY2F0ZSBpc3N1ZWQgYnkg -aHR0cDovL3d3dy5pcHMuZXMvMCkGCWCGSAGG+EIBAgQcFhpodHRwOi8vd3d3Lmlw -cy5lcy9pcHMyMDAyLzA3BglghkgBhvhCAQQEKhYoaHR0cDovL3d3dy5pcHMuZXMv -aXBzMjAwMi9pcHMyMDAyQ0FDLmNybDA8BglghkgBhvhCAQMELxYtaHR0cDovL3d3 -dy5pcHMuZXMvaXBzMjAwMi9yZXZvY2F0aW9uQ0FDLmh0bWw/MDkGCWCGSAGG+EIB -BwQsFipodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3JlbmV3YWxDQUMuaHRtbD8w -NwYJYIZIAYb4QgEIBCoWKGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcG9saWN5 -Q0FDLmh0bWwwbQYDVR0fBGYwZDAuoCygKoYoaHR0cDovL3d3dy5pcHMuZXMvaXBz -MjAwMi9pcHMyMDAyQ0FDLmNybDAyoDCgLoYsaHR0cDovL3d3d2JhY2suaXBzLmVz -L2lwczIwMDIvaXBzMjAwMkNBQy5jcmwwLwYIKwYBBQUHAQEEIzAhMB8GCCsGAQUF -BzABhhNodHRwOi8vb2NzcC5pcHMuZXMvMA0GCSqGSIb3DQEBBQUAA4GBAERyMJ1W -WKJBGyi3leGmGpVfp3hAK+/blkr8THFj2XOVvQLiogbHvpcqk4A0hgP63Ng9HgfN -HnNDJGD1HWHc3JagvPsd4+cSACczAsDAK1M92GsDgaPb1pOVIO/Tln4mkImcJpvN -b2ar7QMiRDjMWb2f2/YHogF/JsRj9SVCXmK9 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIH6jCCB1OgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARIxCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE -ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE -ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEuMCwGA1UECxMl -SVBTIENBIENMQVNFMSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMl -SVBTIENBIENMQVNFMSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEeMBwGCSqGSIb3 -DQEJARYPaXBzQG1haWwuaXBzLmVzMB4XDTAxMTIyOTAwNTkzOFoXDTI1MTIyNzAw -NTkzOFowggESMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQmFyY2Vsb25hMRIwEAYD -VQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJbnRlcm5ldCBwdWJsaXNoaW5n -IFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0BtYWlsLmlwcy5lcyBDLkkuRi4g -IEItNjA5Mjk0NTIxLjAsBgNVBAsTJUlQUyBDQSBDTEFTRTEgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxLjAsBgNVBAMTJUlQUyBDQSBDTEFTRTEgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2lwc0BtYWlsLmlwcy5lczCBnzAN -BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4FEnpwvdr9G5Q1uCN0VWcu+atsIS7ywS -zHb5BlmvXSHU0lq4oNTzav3KaY1mSPd05u42veiWkXWmcSjK5yISMmmwPh5r9FBS -YmL9Yzt9fuzuOOpi9GyocY3h6YvJP8a1zZRCb92CRTzo3wno7wpVqVZHYUxJZHMQ -KD/Kvwn/xi8CAwEAAaOCBEowggRGMB0GA1UdDgQWBBTrsxl588GlHKzcuh9morKb -adB4CDCCAUQGA1UdIwSCATswggE3gBTrsxl588GlHKzcuh9morKbadB4CKGCARqk -ggEWMIIBEjELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUJhcmNlbG9uYTESMBAGA1UE -BxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJUFMgSW50ZXJuZXQgcHVibGlzaGluZyBT -ZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJpcHNAbWFpbC5pcHMuZXMgQy5JLkYuICBC -LTYwOTI5NDUyMS4wLAYDVQQLEyVJUFMgQ0EgQ0xBU0UxIENlcnRpZmljYXRpb24g -QXV0aG9yaXR5MS4wLAYDVQQDEyVJUFMgQ0EgQ0xBU0UxIENlcnRpZmljYXRpb24g -QXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYD -VR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggr -BgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIB -FQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhC -AQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGB -D2lwc0BtYWlsLmlwcy5lczBBBglghkgBhvhCAQ0ENBYyQ0xBU0UxIENBIENlcnRp -ZmljYXRlIGlzc3VlZCBieSBodHRwOi8vd3d3Lmlwcy5lcy8wKQYJYIZIAYb4QgEC -BBwWGmh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvMDoGCWCGSAGG+EIBBAQtFito -dHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTEuY3JsMD8GCWCG -SAGG+EIBAwQyFjBodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3Jldm9jYXRpb25D -TEFTRTEuaHRtbD8wPAYJYIZIAYb4QgEHBC8WLWh0dHA6Ly93d3cuaXBzLmVzL2lw -czIwMDIvcmVuZXdhbENMQVNFMS5odG1sPzA6BglghkgBhvhCAQgELRYraHR0cDov -L3d3dy5pcHMuZXMvaXBzMjAwMi9wb2xpY3lDTEFTRTEuaHRtbDBzBgNVHR8EbDBq -MDGgL6AthitodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTEu -Y3JsMDWgM6Axhi9odHRwOi8vd3d3YmFjay5pcHMuZXMvaXBzMjAwMi9pcHMyMDAy -Q0xBU0UxLmNybDAvBggrBgEFBQcBAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9v -Y3NwLmlwcy5lcy8wDQYJKoZIhvcNAQEFBQADgYEAK9Dr/drIyllq2tPMMi7JVBuK -Yn4VLenZMdMu9Ccj/1urxUq2ckCuU3T0vAW0xtnIyXf7t/k0f3gA+Nak5FI/LEpj -V4F1Wo7ojPsCwJTGKbqz3Bzosq/SLmJbGqmODszFV0VRFOlOHIilkfSj945RyKm+ -hjM+5i9Ibq9UkE6tsSU= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIH6jCCB1OgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARIxCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE -ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE -ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEuMCwGA1UECxMl -SVBTIENBIENMQVNFMyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMl -SVBTIENBIENMQVNFMyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEeMBwGCSqGSIb3 -DQEJARYPaXBzQG1haWwuaXBzLmVzMB4XDTAxMTIyOTAxMDE0NFoXDTI1MTIyNzAx -MDE0NFowggESMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQmFyY2Vsb25hMRIwEAYD -VQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJbnRlcm5ldCBwdWJsaXNoaW5n -IFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0BtYWlsLmlwcy5lcyBDLkkuRi4g -IEItNjA5Mjk0NTIxLjAsBgNVBAsTJUlQUyBDQSBDTEFTRTMgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxLjAsBgNVBAMTJUlQUyBDQSBDTEFTRTMgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxHjAcBgkqhkiG9w0BCQEWD2lwc0BtYWlsLmlwcy5lczCBnzAN -BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqxf+DrDGaBtT8FK+n/ra+osTBLsBjzLZ -H49NzjaY2uQARIwo2BNEKqRrThckQpzTiKRBgtYj+4vJhuW5qYIF3PHeH+AMmVWY -8jjsbJ0gA8DvqqPGZARRLXgNo9KoOtYkTOmWehisEyMiG3zoMRGzXwmqMHBxRiVr -SXGAK5UBsh8CAwEAAaOCBEowggRGMB0GA1UdDgQWBBS4k/8uy9wsjqLnev42USGj -mFsMNDCCAUQGA1UdIwSCATswggE3gBS4k/8uy9wsjqLnev42USGjmFsMNKGCARqk -ggEWMIIBEjELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUJhcmNlbG9uYTESMBAGA1UE -BxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJUFMgSW50ZXJuZXQgcHVibGlzaGluZyBT -ZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJpcHNAbWFpbC5pcHMuZXMgQy5JLkYuICBC -LTYwOTI5NDUyMS4wLAYDVQQLEyVJUFMgQ0EgQ0xBU0UzIENlcnRpZmljYXRpb24g -QXV0aG9yaXR5MS4wLAYDVQQDEyVJUFMgQ0EgQ0xBU0UzIENlcnRpZmljYXRpb24g -QXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYD -VR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggr -BgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIB -FQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhC -AQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGB -D2lwc0BtYWlsLmlwcy5lczBBBglghkgBhvhCAQ0ENBYyQ0xBU0UzIENBIENlcnRp -ZmljYXRlIGlzc3VlZCBieSBodHRwOi8vd3d3Lmlwcy5lcy8wKQYJYIZIAYb4QgEC -BBwWGmh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvMDoGCWCGSAGG+EIBBAQtFito -dHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTMuY3JsMD8GCWCG -SAGG+EIBAwQyFjBodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3Jldm9jYXRpb25D -TEFTRTMuaHRtbD8wPAYJYIZIAYb4QgEHBC8WLWh0dHA6Ly93d3cuaXBzLmVzL2lw -czIwMDIvcmVuZXdhbENMQVNFMy5odG1sPzA6BglghkgBhvhCAQgELRYraHR0cDov -L3d3dy5pcHMuZXMvaXBzMjAwMi9wb2xpY3lDTEFTRTMuaHRtbDBzBgNVHR8EbDBq -MDGgL6AthitodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJDTEFTRTMu -Y3JsMDWgM6Axhi9odHRwOi8vd3d3YmFjay5pcHMuZXMvaXBzMjAwMi9pcHMyMDAy -Q0xBU0UzLmNybDAvBggrBgEFBQcBAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9v -Y3NwLmlwcy5lcy8wDQYJKoZIhvcNAQEFBQADgYEAF2VcmZVDAyevJuXr0LMXI/dD -qsfwfewPxqmurpYPdikc4gYtfibFPPqhwYHOU7BC0ZdXGhd+pFFhxu7pXu8Fuuu9 -D6eSb9ijBmgpjnn1/7/5p6/ksc7C0YBCJwUENPjDfxZ4IwwHJPJGR607VNCv1TGy -r33I6unUVtkOE7LFRVA= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIH9zCCB2CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARQxCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE -ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE -ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEvMC0GA1UECxMm -SVBTIENBIENMQVNFQTEgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxLzAtBgNVBAMT -JklQUyBDQSBDTEFTRUExIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4wHAYJKoZI -hvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMwHhcNMDExMjI5MDEwNTMyWhcNMjUxMjI3 -MDEwNTMyWjCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ -BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp -bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G -LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTEgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUExIENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMw -gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALsw19zQVL01Tp/FTILq0VA8R5j8 -m2mdd81u4D/u6zJfX5/S0HnllXNEITLgCtud186Nq1KLK3jgm1t99P1tCeWu4Wwd -ByOgF9H5fahGRpEiqLJpxq339fWUoTCUvQDMRH/uxJ7JweaPCjbB/SQ9AaD1e+J8 -eGZDi09Z8pvZ+kmzAgMBAAGjggRTMIIETzAdBgNVHQ4EFgQUZyaW56G/2LUDnf47 -3P7yiuYV3TAwggFGBgNVHSMEggE9MIIBOYAUZyaW56G/2LUDnf473P7yiuYV3TCh -ggEcpIIBGDCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ -BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp -bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G -LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTEgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUExIENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOC -AQAwDAYDVR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUF -BwMBBggrBgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYB -BAGCNwIBFQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglg -hkgBhvhCAQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1Ud -EgQTMBGBD2lwc0BtYWlsLmlwcy5lczBCBglghkgBhvhCAQ0ENRYzQ0xBU0VBMSBD -QSBDZXJ0aWZpY2F0ZSBpc3N1ZWQgYnkgaHR0cDovL3d3dy5pcHMuZXMvMCkGCWCG -SAGG+EIBAgQcFhpodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyLzA7BglghkgBhvhC -AQQELhYsaHR0cDovL3d3dy5pcHMuZXMvaXBzMjAwMi9pcHMyMDAyQ0xBU0VBMS5j -cmwwQAYJYIZIAYb4QgEDBDMWMWh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcmV2 -b2NhdGlvbkNMQVNFQTEuaHRtbD8wPQYJYIZIAYb4QgEHBDAWLmh0dHA6Ly93d3cu -aXBzLmVzL2lwczIwMDIvcmVuZXdhbENMQVNFQTEuaHRtbD8wOwYJYIZIAYb4QgEI -BC4WLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcG9saWN5Q0xBU0VBMS5odG1s -MHUGA1UdHwRuMGwwMqAwoC6GLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvaXBz -MjAwMkNMQVNFQTEuY3JsMDagNKAyhjBodHRwOi8vd3d3YmFjay5pcHMuZXMvaXBz -MjAwMi9pcHMyMDAyQ0xBU0VBMS5jcmwwLwYIKwYBBQUHAQEEIzAhMB8GCCsGAQUF -BzABhhNodHRwOi8vb2NzcC5pcHMuZXMvMA0GCSqGSIb3DQEBBQUAA4GBAH66iqyA -AIQVCtWYUQxkxZwCWINmyq0eB81+atqAB98DNEock8RLWCA1NnHtogo1EqWmZaeF -aQoO42Hu6r4okzPV7Oi+xNtff6j5YzHIa5biKcJboOeXNp13XjFr/tOn2yrb25aL -H2betgPAK7N41lUH5Y85UN4HI3LmvSAUS7SG ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIH9zCCB2CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCARQxCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE -ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE -ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjEvMC0GA1UECxMm -SVBTIENBIENMQVNFQTMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxLzAtBgNVBAMT -JklQUyBDQSBDTEFTRUEzIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4wHAYJKoZI -hvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMwHhcNMDExMjI5MDEwNzUwWhcNMjUxMjI3 -MDEwNzUwWjCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ -BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp -bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G -LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTMgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUEzIENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXMw -gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAO6AAPYaZC6tasiDsYun7o/ZttvN -G7uGBiJ2MwwSbUhWYdLcgiViL5/SaTBlA0IjWLxH3GvWdV0XPOH/8lhneaDBgbHU -VqLyjRGZ/fZ98cfEXgIqmuJKtROKAP2Md4bm15T1IHUuDky/dMQ/gT6DtKM4Ninn -6Cr1jIhBqoCm42zvAgMBAAGjggRTMIIETzAdBgNVHQ4EFgQUHp9XUEe2YZM50yz8 -2l09BXW3mQIwggFGBgNVHSMEggE9MIIBOYAUHp9XUEe2YZM50yz82l09BXW3mQKh -ggEcpIIBGDCCARQxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQ -BgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UEChMlSVBTIEludGVybmV0IHB1Ymxpc2hp -bmcgU2VydmljZXMgcy5sLjErMCkGA1UEChQiaXBzQG1haWwuaXBzLmVzIEMuSS5G -LiAgQi02MDkyOTQ1MjEvMC0GA1UECxMmSVBTIENBIENMQVNFQTMgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkxLzAtBgNVBAMTJklQUyBDQSBDTEFTRUEzIENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5MR4wHAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOC -AQAwDAYDVR0TBAUwAwEB/zAMBgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUF -BwMBBggrBgEFBQcDAgYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYB -BAGCNwIBFQYKKwYBBAGCNwIBFgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglg -hkgBhvhCAQEEBAMCAAcwGgYDVR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1Ud -EgQTMBGBD2lwc0BtYWlsLmlwcy5lczBCBglghkgBhvhCAQ0ENRYzQ0xBU0VBMyBD -QSBDZXJ0aWZpY2F0ZSBpc3N1ZWQgYnkgaHR0cDovL3d3dy5pcHMuZXMvMCkGCWCG -SAGG+EIBAgQcFhpodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyLzA7BglghkgBhvhC -AQQELhYsaHR0cDovL3d3dy5pcHMuZXMvaXBzMjAwMi9pcHMyMDAyQ0xBU0VBMy5j -cmwwQAYJYIZIAYb4QgEDBDMWMWh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcmV2 -b2NhdGlvbkNMQVNFQTMuaHRtbD8wPQYJYIZIAYb4QgEHBDAWLmh0dHA6Ly93d3cu -aXBzLmVzL2lwczIwMDIvcmVuZXdhbENMQVNFQTMuaHRtbD8wOwYJYIZIAYb4QgEI -BC4WLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvcG9saWN5Q0xBU0VBMy5odG1s -MHUGA1UdHwRuMGwwMqAwoC6GLGh0dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvaXBz -MjAwMkNMQVNFQTMuY3JsMDagNKAyhjBodHRwOi8vd3d3YmFjay5pcHMuZXMvaXBz -MjAwMi9pcHMyMDAyQ0xBU0VBMy5jcmwwLwYIKwYBBQUHAQEEIzAhMB8GCCsGAQUF -BzABhhNodHRwOi8vb2NzcC5pcHMuZXMvMA0GCSqGSIb3DQEBBQUAA4GBAEo9IEca -2on0eisxeewBwMwB9dbB/MjD81ACUZBYKp/nNQlbMAqBACVHr9QPDp5gJqiVp4MI -3y2s6Q73nMify5NF8bpqxmdRSmlPa/59Cy9SKcJQrSRE7SOzSMtEQMEDlQwKeAYS -AfWRMS1Jjbs/RU4s4OjNtckUFQzjB4ObJnXv ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICtzCCAiACAQAwDQYJKoZIhvcNAQEEBQAwgaMxCzAJBgNVBAYTAkVTMRIwEAYD -VQQIEwlCQVJDRUxPTkExEjAQBgNVBAcTCUJBUkNFTE9OQTEZMBcGA1UEChMQSVBT -IFNlZ3VyaWRhZCBDQTEYMBYGA1UECxMPQ2VydGlmaWNhY2lvbmVzMRcwFQYDVQQD -Ew5JUFMgU0VSVklET1JFUzEeMBwGCSqGSIb3DQEJARYPaXBzQG1haWwuaXBzLmVz -MB4XDTk4MDEwMTIzMjEwN1oXDTA5MTIyOTIzMjEwN1owgaMxCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCQVJDRUxPTkExEjAQBgNVBAcTCUJBUkNFTE9OQTEZMBcGA1UE -ChMQSVBTIFNlZ3VyaWRhZCBDQTEYMBYGA1UECxMPQ2VydGlmaWNhY2lvbmVzMRcw -FQYDVQQDEw5JUFMgU0VSVklET1JFUzEeMBwGCSqGSIb3DQEJARYPaXBzQG1haWwu -aXBzLmVzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsT1J0nznqjtwlxLyY -XZhkJAk8IbPMGbWOlI6H0fg3PqHILVikgDVboXVsHUUMH2Fjal5vmwpMwci4YSM1 -gf/+rHhwLWjhOgeYlQJU3c0jt4BT18g3RXIGJBK6E2Ehim51KODFDzT9NthFf+G4 -Nu+z4cYgjui0OLzhPvYR3oydAQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBACzzw3lY -JN7GO9HgQmm47mSzPWIBubOE3yN93ZjPEKn+ANgilgUTB1RXxafey9m4iEL2mdsU -dx+2/iU94aI+A6mB0i1sR/WWRowiq8jMDQ6XXotBtDvECgZAHd1G9AHduoIuPD14 -cJ58GNCr+Lh3B0Zx8coLY1xq+XKU1QFPoNtC ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIIODCCB6GgAwIBAgIBADANBgkqhkiG9w0BAQUFADCCAR4xCzAJBgNVBAYTAkVT -MRIwEAYDVQQIEwlCYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9uYTEuMCwGA1UE -ChMlSVBTIEludGVybmV0IHB1Ymxpc2hpbmcgU2VydmljZXMgcy5sLjErMCkGA1UE -ChQiaXBzQG1haWwuaXBzLmVzIEMuSS5GLiAgQi02MDkyOTQ1MjE0MDIGA1UECxMr -SVBTIENBIFRpbWVzdGFtcGluZyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTE0MDIG -A1UEAxMrSVBTIENBIFRpbWVzdGFtcGluZyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 -eTEeMBwGCSqGSIb3DQEJARYPaXBzQG1haWwuaXBzLmVzMB4XDTAxMTIyOTAxMTAx -OFoXDTI1MTIyNzAxMTAxOFowggEeMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQmFy -Y2Vsb25hMRIwEAYDVQQHEwlCYXJjZWxvbmExLjAsBgNVBAoTJUlQUyBJbnRlcm5l -dCBwdWJsaXNoaW5nIFNlcnZpY2VzIHMubC4xKzApBgNVBAoUImlwc0BtYWlsLmlw -cy5lcyBDLkkuRi4gIEItNjA5Mjk0NTIxNDAyBgNVBAsTK0lQUyBDQSBUaW1lc3Rh -bXBpbmcgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxNDAyBgNVBAMTK0lQUyBDQSBU -aW1lc3RhbXBpbmcgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHjAcBgkqhkiG9w0B -CQEWD2lwc0BtYWlsLmlwcy5lczCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA -vLjuVqWajOY2ycJioGaBjRrVetJznw6EZLqVtJCneK/K/lRhW86yIFcBrkSSQxA4 -Efdo/BdApWgnMjvEp+ZCccWZ73b/K5Uk9UmSGGjKALWkWi9uy9YbLA1UZ2t6KaFY -q6JaANZbuxjC3/YeE1Z2m6Vo4pjOxgOKNNtMg0GmqaMCAwEAAaOCBIAwggR8MB0G -A1UdDgQWBBSL0BBQCYHynQnVDmB4AyKiP8jKZjCCAVAGA1UdIwSCAUcwggFDgBSL -0BBQCYHynQnVDmB4AyKiP8jKZqGCASakggEiMIIBHjELMAkGA1UEBhMCRVMxEjAQ -BgNVBAgTCUJhcmNlbG9uYTESMBAGA1UEBxMJQmFyY2Vsb25hMS4wLAYDVQQKEyVJ -UFMgSW50ZXJuZXQgcHVibGlzaGluZyBTZXJ2aWNlcyBzLmwuMSswKQYDVQQKFCJp -cHNAbWFpbC5pcHMuZXMgQy5JLkYuICBCLTYwOTI5NDUyMTQwMgYDVQQLEytJUFMg -Q0EgVGltZXN0YW1waW5nIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MTQwMgYDVQQD -EytJUFMgQ0EgVGltZXN0YW1waW5nIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR4w -HAYJKoZIhvcNAQkBFg9pcHNAbWFpbC5pcHMuZXOCAQAwDAYDVR0TBAUwAwEB/zAM -BgNVHQ8EBQMDB/+AMGsGA1UdJQRkMGIGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYB -BQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCNwIBFQYKKwYBBAGCNwIB -FgYKKwYBBAGCNwoDAQYKKwYBBAGCNwoDBDARBglghkgBhvhCAQEEBAMCAAcwGgYD -VR0RBBMwEYEPaXBzQG1haWwuaXBzLmVzMBoGA1UdEgQTMBGBD2lwc0BtYWlsLmlw -cy5lczBHBglghkgBhvhCAQ0EOhY4VGltZXN0YW1waW5nIENBIENlcnRpZmljYXRl -IGlzc3VlZCBieSBodHRwOi8vd3d3Lmlwcy5lcy8wKQYJYIZIAYb4QgECBBwWGmh0 -dHA6Ly93d3cuaXBzLmVzL2lwczIwMDIvMEAGCWCGSAGG+EIBBAQzFjFodHRwOi8v -d3d3Lmlwcy5lcy9pcHMyMDAyL2lwczIwMDJUaW1lc3RhbXBpbmcuY3JsMEUGCWCG -SAGG+EIBAwQ4FjZodHRwOi8vd3d3Lmlwcy5lcy9pcHMyMDAyL3Jldm9jYXRpb25U -aW1lc3RhbXBpbmcuaHRtbD8wQgYJYIZIAYb4QgEHBDUWM2h0dHA6Ly93d3cuaXBz -LmVzL2lwczIwMDIvcmVuZXdhbFRpbWVzdGFtcGluZy5odG1sPzBABglghkgBhvhC -AQgEMxYxaHR0cDovL3d3dy5pcHMuZXMvaXBzMjAwMi9wb2xpY3lUaW1lc3RhbXBp -bmcuaHRtbDB/BgNVHR8EeDB2MDegNaAzhjFodHRwOi8vd3d3Lmlwcy5lcy9pcHMy -MDAyL2lwczIwMDJUaW1lc3RhbXBpbmcuY3JsMDugOaA3hjVodHRwOi8vd3d3YmFj -ay5pcHMuZXMvaXBzMjAwMi9pcHMyMDAyVGltZXN0YW1waW5nLmNybDAvBggrBgEF -BQcBAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9vY3NwLmlwcy5lcy8wDQYJKoZI -hvcNAQEFBQADgYEAZbrBzAAalZHK6Ww6vzoeFAh8+4Pua2JR0zORtWB5fgTYXXk3 -6MNbsMRnLWhasl8OCvrNPzpFoeo2zyYepxEoxZSPhExTCMWTs/zif/WN87GphV+I -3pGW7hdbrqXqcGV4LCFkAZXOzkw+UPS2Wctjjba9GNSHSl/c7+lW8AoM6HU= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC -TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0 -aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0 -aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz -MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw -IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR -dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp -li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D -rOpm2RgbaIr1VxqYuvXtdj182d6UajtLF8HVj71lODqV0D1VNk7feVcxKh7YWWVJ -WCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeLYzcS19Dsw3sgQUSj7cug -F+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWenAScOospU -xbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCC -Ak4wPQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVv -dmFkaXNvZmZzaG9yZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREw -ggENMIIBCQYJKwYBBAG+WAABMIH7MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNl -IG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBh -c3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFy -ZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh -Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYI -KwYBBQUHAgEWFmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3T -KbkGGew5Oanwl4Rqy+/fMIGuBgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rq -y+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1p -dGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD -VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL -MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk -fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8 -7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R -cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y -mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW -xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK -SnQ2+Q== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 -IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz -BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDMgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y -aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG -9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMjIzM1oXDTE5MDYy -NjAwMjIzM1owgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y -azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs -YXNzIDMgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw -Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl -cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjmFGWHOjVsQaBalfD -cnWTq8+epvzzFlLWLU2fNUSoLgRNB0mKOCn1dzfnt6td3zZxFJmP3MKS8edgkpfs -2Ejcv8ECIMYkpChMMFp2bbFc893enhBxoYjHW5tBbcqwuI4V7q0zK89HBFx1cQqY -JJgpp0lZpd34t0NiYfPT4tBVPwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFa7AliE -Zwgs3x/be0kz9dNnnfS0ChCzycUs4pJqcXgn8nCDQtM+z6lU9PHYkhaM0QTLS6vJ -n0WuPIqpsHEzXcjFV9+vqDWzf4mH6eglkrh/hXqu1rweN1gqZ8mRzyqBPu3GOd/A -PhmcGcwTTYJBtYze4D1gCCAPRX5ron+jjBXu ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICXDCCAcWgAwIBAgIQCgEBAQAAAnwAAAALAAAAAjANBgkqhkiG9w0BAQUFADA6 -MRkwFwYDVQQKExBSU0EgU2VjdXJpdHkgSW5jMR0wGwYDVQQLExRSU0EgU2VjdXJp -dHkgMTAyNCBWMzAeFw0wMTAyMjIyMTAxNDlaFw0yNjAyMjIyMDAxNDlaMDoxGTAX -BgNVBAoTEFJTQSBTZWN1cml0eSBJbmMxHTAbBgNVBAsTFFJTQSBTZWN1cml0eSAx -MDI0IFYzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDV3f5mCc8kPD6ugU5O -isRpgFtZO9+5TUzKtS3DJy08rwBCbbwoppbPf9dYrIMKo1W1exeQFYRMiu4mmdxY -78c4pqqv0I5CyGLXq6yp+0p9v+r+Ek3d/yYtbzZUaMjShFbuklNhCbM/OZuoyZu9 -zp9+1BlqFikYvtc6adwlWzMaUQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4G -A1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBTEwBykB5T9zU0B1FTapQxf3q4FWjAd -BgNVHQ4EFgQUxMAcpAeU/c1NAdRU2qUMX96uBVowDQYJKoZIhvcNAQEFBQADgYEA -Py1q4yZDlX2Jl2X7deRyHUZXxGFraZ8SmyzVWujAovBDleMf6XbN3Ou8k6BlCsdN -T1+nr6JGFLkM88y9am63nd4lQtBU/55oc2PcJOsiv6hy8l4A4Q1OOkNumU4/iXgD -mMrzVcydro7BqkWY+o8aoI2II/EVQQ2lRj6RP4vr93E= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDYTCCAkmgAwIBAgIQCgEBAQAAAnwAAAAKAAAAAjANBgkqhkiG9w0BAQUFADA6 -MRkwFwYDVQQKExBSU0EgU2VjdXJpdHkgSW5jMR0wGwYDVQQLExRSU0EgU2VjdXJp -dHkgMjA0OCBWMzAeFw0wMTAyMjIyMDM5MjNaFw0yNjAyMjIyMDM5MjNaMDoxGTAX -BgNVBAoTEFJTQSBTZWN1cml0eSBJbmMxHTAbBgNVBAsTFFJTQSBTZWN1cml0eSAy -MDQ4IFYzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt49VcdKA3Xtp -eafwGFAyPGJn9gqVB93mG/Oe2dJBVGutn3y+Gc37RqtBaB4Y6lXIL5F4iSj7Jylg -/9+PjDvJSZu1pJTOAeo+tWN7fyb9Gd3AIb2E0S1PRsNO3Ng3OTsor8udGuorryGl -wSMiuLgbWhOHV4PR8CDn6E8jQrAApX2J6elhc5SYcSa8LWrg903w8bYqODGBDSnh -AMFRD0xS+ARaqn1y07iHKrtjEAMqs6FPDVpeRrc9DvV07Jmf+T0kgYim3WBU6JU2 -PcYJk5qjEoAAVZkZR73QpXzDuvsf9/UP+Ky5tfQ3mBMY3oVbtwyCO4dvlTlYMNpu -AWgXIszACwIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB -BjAfBgNVHSMEGDAWgBQHw1EwpKrpRa41JPr/JCwz0LGdjDAdBgNVHQ4EFgQUB8NR -MKSq6UWuNST6/yQsM9CxnYwwDQYJKoZIhvcNAQEFBQADggEBAF8+hnZuuDU8TjYc -HnmYv/3VEhF5Ug7uMYm83X/50cYVIeiKAVQNOvtUudZj1LGqlk2iQk3UUx+LEN5/ -Zb5gEydxiKRz44Rj0aRV4VCT5hsOedBnvEbIvz8XDZXmxpBp3ue0L96VfdASPz0+ -f00/FGj1EVDVwfSQpQgdMWD/YIwjVAqv/qFuxdF6Kmh4zx6CCiC0H63lhbJqaHVO -rSU3lIW+vaHU6rcMSzyd6BIA8F+sDeGscGNz9395nzIlQnQFgCi/vcEkllgVsRch -6YlL2weIZ/QVrXA+L02FO8K32/6YaCOJ4XQP3vTFhGMpG8zLB8kApKnXwiJPZ9d3 -7CAFYd4= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY -MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t -dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5 -WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD -VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3 -DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8 -9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ -DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9 -Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N -QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ -xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G -A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T -AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG -kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr -Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5 -Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU -JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot -RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDIDCCAgigAwIBAgIBJDANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP -MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MxIENBMB4XDTAx -MDQwNjEwNDkxM1oXDTIxMDQwNjEwNDkxM1owOTELMAkGA1UEBhMCRkkxDzANBgNV -BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMSBDQTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALWJHytPZwp5/8Ue+H887dF+2rDNbS82rDTG -29lkFwhjMDMiikzujrsPDUJVyZ0upe/3p4zDq7mXy47vPxVnqIJyY1MPQYx9EJUk -oVqlBvqSV536pQHydekfvFYmUk54GWVYVQNYwBSujHxVX3BbdyMGNpfzJLWaRpXk -3w0LBUXl0fIdgrvGE+D+qnr9aTCU89JFhfzyMlsy3uhsXR/LpCJ0sICOXZT3BgBL -qdReLjVQCfOAl/QMF6452F/NM8EcyonCIvdFEu1eEpOdY6uCLrnrQkFEy0oaAIIN -nvmLVz5MxxftLItyM19yejhW1ebZrgUaHXVFsculJRwSVzb9IjcCAwEAAaMzMDEw -DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQIR+IMi/ZTiFIwCwYDVR0PBAQDAgEG -MA0GCSqGSIb3DQEBBQUAA4IBAQCLGrLJXWG04bkruVPRsoWdd44W7hE928Jj2VuX -ZfsSZ9gqXLar5V7DtxYvyOirHYr9qxp81V9jz9yw3Xe5qObSIjiHBxTZ/75Wtf0H -DjxVyhbMp6Z3N/vbXB9OWQaHowND9Rart4S9Tu+fMTfwRvFAttEMpWT4Y14h21VO -TzF2nBBhjrZTOqMRvq9tfB69ri3iDGnHhVNoomG6xT60eVR4ngrHAr5i0RGCS2Uv -kVrCqIexVmiUefkl98HVrhq4uz2PqYo4Ffdz0Fpg0YCw8NzVUM1O7pJIae2yIx4w -zMiUyLb1O4Z/P6Yun/Y+LLWSlj7fLJOK/4GMDw9ZIRlXvVWa ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP -MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx -MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV -BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o -Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt -5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s -3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej -vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu -8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw -DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG -MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil -zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/ -3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD -FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6 -Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2 -ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDujCCAqKgAwIBAgIEAJiWijANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJO -TDEeMBwGA1UEChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSYwJAYDVQQDEx1TdGFh -dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQTAeFw0wMjEyMTcwOTIzNDlaFw0xNTEy -MTYwOTE1MzhaMFUxCzAJBgNVBAYTAk5MMR4wHAYDVQQKExVTdGFhdCBkZXIgTmVk -ZXJsYW5kZW4xJjAkBgNVBAMTHVN0YWF0IGRlciBOZWRlcmxhbmRlbiBSb290IENB -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmNK1URF6gaYUmHFtvszn -ExvWJw56s2oYHLZhWtVhCb/ekBPHZ+7d89rFDBKeNVU+LCeIQGv33N0iYfXCxw71 -9tV2U02PjLwYdjeFnejKScfST5gTCaI+Ioicf9byEGW07l8Y1Rfj+MX94p2i71MO -hXeiD+EwR+4A5zN9RGcaC1Hoi6CeUJhoNFIfLm0B8mBF8jHrqTFoKbt6QZ7GGX+U -tFE5A3+y3qcym7RHjm+0Sq7lr7HcsBthvJly3uSJt3omXdozSVtSnA71iq3DuD3o -BmrC1SoLbHuEvVYFy4ZlkuxEK7COudxwC0barbxjiDn622r+I/q85Ej0ZytqERAh -SQIDAQABo4GRMIGOMAwGA1UdEwQFMAMBAf8wTwYDVR0gBEgwRjBEBgRVHSAAMDww -OgYIKwYBBQUHAgEWLmh0dHA6Ly93d3cucGtpb3ZlcmhlaWQubmwvcG9saWNpZXMv -cm9vdC1wb2xpY3kwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSofeu8Y6R0E3QA -7Jbg0zTBLL9s+DANBgkqhkiG9w0BAQUFAAOCAQEABYSHVXQ2YcG70dTGFagTtJ+k -/rvuFbQvBgwp8qiSpGEN/KtcCFtREytNwiphyPgJWPwtArI5fZlmgb9uXJVFIGzm -eafR2Bwp/MIgJ1HI8XxdNGdphREwxgDS1/PTfLbwMVcoEoJz6TMvplW0C5GUR5z6 -u3pCMuiufi3IvKwUv9kP2Vv8wfl6leF9fpb8cbDCTMjfRTTJzg3ynGQI0DvDKcWy -7ZAEwbEpkcUwb8GpcjPM/l0WFywRaed+/sWDCN+83CI6LiBpIzlWYGeQiy52OfsR -iJf2fL1LuCAWZwWN4jvBcj+UlTfHXbme2JOhF4//DGYVwSR8MnwDHTuhWEUykw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDXDCCAsWgAwIBAgICA+owDQYJKoZIhvcNAQEEBQAwgbwxCzAJBgNVBAYTAkRF -MRAwDgYDVQQIEwdIYW1idXJnMRAwDgYDVQQHEwdIYW1idXJnMTowOAYDVQQKEzFU -QyBUcnVzdENlbnRlciBmb3IgU2VjdXJpdHkgaW4gRGF0YSBOZXR3b3JrcyBHbWJI -MSIwIAYDVQQLExlUQyBUcnVzdENlbnRlciBDbGFzcyAyIENBMSkwJwYJKoZIhvcN -AQkBFhpjZXJ0aWZpY2F0ZUB0cnVzdGNlbnRlci5kZTAeFw05ODAzMDkxMTU5NTla -Fw0xMTAxMDExMTU5NTlaMIG8MQswCQYDVQQGEwJERTEQMA4GA1UECBMHSGFtYnVy -ZzEQMA4GA1UEBxMHSGFtYnVyZzE6MDgGA1UEChMxVEMgVHJ1c3RDZW50ZXIgZm9y -IFNlY3VyaXR5IGluIERhdGEgTmV0d29ya3MgR21iSDEiMCAGA1UECxMZVEMgVHJ1 -c3RDZW50ZXIgQ2xhc3MgMiBDQTEpMCcGCSqGSIb3DQEJARYaY2VydGlmaWNhdGVA -dHJ1c3RjZW50ZXIuZGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANo46O0y -AClxgwENv4wB3NrGrTmkqYov1YtcaF9QxmL1Zr3KkSLsqh1R1z2zUbKDTl3LSbDw -TFXlay3HhQswHJJOgtTKAu33b77c4OMUuAVT8pr0VotanoWT0bSCVq5Nu6hLVxa8 -/vhYnvgpjbB7zXjJT6yLZwzxnPv8V5tXXE8NAgMBAAGjazBpMA8GA1UdEwEB/wQF -MAMBAf8wDgYDVR0PAQH/BAQDAgGGMDMGCWCGSAGG+EIBCAQmFiRodHRwOi8vd3d3 -LnRydXN0Y2VudGVyLmRlL2d1aWRlbGluZXMwEQYJYIZIAYb4QgEBBAQDAgAHMA0G -CSqGSIb3DQEBBAUAA4GBAIRS+yjf/x91AbwBvgRWl2p0QiQxg/lGsQaKic+WLDO/ -jLVfenKhhQbOhvgFjuj5Jcrag4wGrOs2bYWRNAQ29ELw+HkuCkhcq8xRT3h2oNms -Gb0q0WkEKJHKNhAngFdb0lz1wlurZIFjdFH0l7/NEij3TWZ/p/AcASZ4smZHcFFk ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDXDCCAsWgAwIBAgICA+swDQYJKoZIhvcNAQEEBQAwgbwxCzAJBgNVBAYTAkRF -MRAwDgYDVQQIEwdIYW1idXJnMRAwDgYDVQQHEwdIYW1idXJnMTowOAYDVQQKEzFU -QyBUcnVzdENlbnRlciBmb3IgU2VjdXJpdHkgaW4gRGF0YSBOZXR3b3JrcyBHbWJI -MSIwIAYDVQQLExlUQyBUcnVzdENlbnRlciBDbGFzcyAzIENBMSkwJwYJKoZIhvcN -AQkBFhpjZXJ0aWZpY2F0ZUB0cnVzdGNlbnRlci5kZTAeFw05ODAzMDkxMTU5NTla -Fw0xMTAxMDExMTU5NTlaMIG8MQswCQYDVQQGEwJERTEQMA4GA1UECBMHSGFtYnVy -ZzEQMA4GA1UEBxMHSGFtYnVyZzE6MDgGA1UEChMxVEMgVHJ1c3RDZW50ZXIgZm9y -IFNlY3VyaXR5IGluIERhdGEgTmV0d29ya3MgR21iSDEiMCAGA1UECxMZVEMgVHJ1 -c3RDZW50ZXIgQ2xhc3MgMyBDQTEpMCcGCSqGSIb3DQEJARYaY2VydGlmaWNhdGVA -dHJ1c3RjZW50ZXIuZGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALa0wTUF -Lg2N7KBAahwOJ6ZQkmtQGwfeLud2zODa/ISoXoxjaitN2U4CdhHBC/KNecoAtvGw -Dtf7pBc9r6tpepYnv68zoZoqWarEtTcI8hKlMbZD9TKWcSgoq40oht+77uMMfTDW -w1Krj10nnGvAo+cFa1dJRLNu6mTP0o56UHd3AgMBAAGjazBpMA8GA1UdEwEB/wQF -MAMBAf8wDgYDVR0PAQH/BAQDAgGGMDMGCWCGSAGG+EIBCAQmFiRodHRwOi8vd3d3 -LnRydXN0Y2VudGVyLmRlL2d1aWRlbGluZXMwEQYJYIZIAYb4QgEBBAQDAgAHMA0G -CSqGSIb3DQEBBAUAA4GBABY9xs3Bu4VxhUafPiCPUSiZ7C1FIWMjWwS7TJC4iJIE -Tb19AaM/9uzO8d7+feXhPrvGq14L3T2WxMup1Pkm5gZOngylerpuw3yCGdHHsbHD -2w2Om0B8NwvxXej9H5CIpQ5ON2QhqE6NtJ/x3kit1VYYUimLRzQSCdS7kjXvD9s0 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEKzCCAxOgAwIBAgIEOsylTDANBgkqhkiG9w0BAQUFADBDMQswCQYDVQQGEwJE -SzEVMBMGA1UEChMMVERDIEludGVybmV0MR0wGwYDVQQLExRUREMgSW50ZXJuZXQg -Um9vdCBDQTAeFw0wMTA0MDUxNjMzMTdaFw0yMTA0MDUxNzAzMTdaMEMxCzAJBgNV -BAYTAkRLMRUwEwYDVQQKEwxUREMgSW50ZXJuZXQxHTAbBgNVBAsTFFREQyBJbnRl -cm5ldCBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxLhA -vJHVYx/XmaCLDEAedLdInUaMArLgJF/wGROnN4NrXceO+YQwzho7+vvOi20jxsNu -Zp+Jpd/gQlBn+h9sHvTQBda/ytZO5GhgbEaqHF1j4QeGDmUApy6mcca8uYGoOn0a -0vnRrEvLznWv3Hv6gXPU/Lq9QYjUdLP5Xjg6PEOo0pVOd20TDJ2PeAG3WiAfAzc1 -4izbSysseLlJ28TQx5yc5IogCSEWVmb/Bexb4/DPqyQkXsN/cHoSxNK1EKC2IeGN -eGlVRGn1ypYcNIUXJXfi9i8nmHj9eQY6otZaQ8H/7AQ77hPv01ha/5Lr7K7a8jcD -R0G2l8ktCkEiu7vmpwIDAQABo4IBJTCCASEwEQYJYIZIAYb4QgEBBAQDAgAHMGUG -A1UdHwReMFwwWqBYoFakVDBSMQswCQYDVQQGEwJESzEVMBMGA1UEChMMVERDIElu -dGVybmV0MR0wGwYDVQQLExRUREMgSW50ZXJuZXQgUm9vdCBDQTENMAsGA1UEAxME -Q1JMMTArBgNVHRAEJDAigA8yMDAxMDQwNTE2MzMxN1qBDzIwMjEwNDA1MTcwMzE3 -WjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUbGQBx/2FbazI2p5QCIUItTxWqFAw -HQYDVR0OBBYEFGxkAcf9hW2syNqeUAiFCLU8VqhQMAwGA1UdEwQFMAMBAf8wHQYJ -KoZIhvZ9B0EABBAwDhsIVjUuMDo0LjADAgSQMA0GCSqGSIb3DQEBBQUAA4IBAQBO -Q8zR3R0QGwZ/t6T609lN+yOfI1Rb5osvBCiLtSdtiaHsmGnc540mgwV5dOy0uaOX -wTUA/RXaOYE6lTGQ3pfphqiZdwzlWqCE/xIWrG64jcN7ksKsLtB9KOy282A4aW8+ -2ARVPp7MVdK6/rtHBNcK2RYKNCn1WBPVT8+PVkuzHu7TmHnaCB4Mb7j4Fifvwm89 -9qNLPg7kbWzbO0ESm70NRyN/PErQr8Cv9u8btRXE64PECV90i9kR+8JWsTz4cMo0 -jUNAE4z9mQNUecYu6oah9jrUCbz0vGbMPVjQV0kK7iXiQe4T+Zs4NNEA9X7nlB38 -aQNiuJkFBT1reBK9sG9l ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFGTCCBAGgAwIBAgIEPki9xDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJE -SzEMMAoGA1UEChMDVERDMRQwEgYDVQQDEwtUREMgT0NFUyBDQTAeFw0wMzAyMTEw -ODM5MzBaFw0zNzAyMTEwOTA5MzBaMDExCzAJBgNVBAYTAkRLMQwwCgYDVQQKEwNU -REMxFDASBgNVBAMTC1REQyBPQ0VTIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEArGL2YSCyz8DGhdfjeebM7fI5kqSXLmSjhFuHnEz9pPPEXyG9VhDr -2y5h7JNp46PMvZnDBfwGuMo2HP6QjklMxFaaL1a8z3sM8W9Hpg1DTeLpHTk0zY0s -2RKY+ePhwUp8hjjEqcRhiNJerxomTdXkoCJHhNlktxmW/OwZ5LKXJk5KTMuPJItU -GBxIYXvViGjaXbXqzRowwYCDdlCqT9HU3Tjw7xb04QxQBr/q+3pJoSgrHPb8FTKj -dGqPqcNiKXEx5TukYBdedObaE+3pHx8b0bJoc8YQNHVGEBDjkAB2QMuLt0MJIf+r -TpPGWOmlgtt3xDqZsXKVSQTwtyv6e1mO3QIDAQABo4ICNzCCAjMwDwYDVR0TAQH/ -BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwgewGA1UdIASB5DCB4TCB3gYIKoFQgSkB -AQEwgdEwLwYIKwYBBQUHAgEWI2h0dHA6Ly93d3cuY2VydGlmaWthdC5kay9yZXBv -c2l0b3J5MIGdBggrBgEFBQcCAjCBkDAKFgNUREMwAwIBARqBgUNlcnRpZmlrYXRl -ciBmcmEgZGVubmUgQ0EgdWRzdGVkZXMgdW5kZXIgT0lEIDEuMi4yMDguMTY5LjEu -MS4xLiBDZXJ0aWZpY2F0ZXMgZnJvbSB0aGlzIENBIGFyZSBpc3N1ZWQgdW5kZXIg -T0lEIDEuMi4yMDguMTY5LjEuMS4xLjARBglghkgBhvhCAQEEBAMCAAcwgYEGA1Ud -HwR6MHgwSKBGoESkQjBAMQswCQYDVQQGEwJESzEMMAoGA1UEChMDVERDMRQwEgYD -VQQDEwtUREMgT0NFUyBDQTENMAsGA1UEAxMEQ1JMMTAsoCqgKIYmaHR0cDovL2Ny -bC5vY2VzLmNlcnRpZmlrYXQuZGsvb2Nlcy5jcmwwKwYDVR0QBCQwIoAPMjAwMzAy -MTEwODM5MzBagQ8yMDM3MDIxMTA5MDkzMFowHwYDVR0jBBgwFoAUYLWF7FZkfhIZ -J2cdUBVLc647+RIwHQYDVR0OBBYEFGC1hexWZH4SGSdnHVAVS3OuO/kSMB0GCSqG -SIb2fQdBAAQQMA4bCFY2LjA6NC4wAwIEkDANBgkqhkiG9w0BAQUFAAOCAQEACrom -JkbTc6gJ82sLMJn9iuFXehHTuJTXCRBuo7E4A9G28kNBKWKnctj7fAXmMXAnVBhO -inxO5dHKjHiIzxvTkIvmI/gLDjNDfZziChmPyQE+dF10yYscA+UYyAFMP8uXBV2Y -caaYb7Z8vTd/vuGTJW1v8AqtFxjhA7wHKcitJuj4YfD9IQl+mo6paH1IYnK9AOoB -mbgGglGBTvH1tJFUuSN6AJqfXY3gPGS5GhKSKseCRHI53OI8xthV9RVOyAUO28bQ -YqbsFbS1AoLbrIyigfCbmTH1ICCoiGEKB5+U/NDXG8wuF/MEJ3Zn61SD/aSQfgY9 -BKNDLdr8C2LqL19iUw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDITCCAoqgAwIBAgIBADANBgkqhkiG9w0BAQQFADCByzELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYD -VQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBT -ZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFBlcnNvbmFsIEJhc2lj -IENBMSgwJgYJKoZIhvcNAQkBFhlwZXJzb25hbC1iYXNpY0B0aGF3dGUuY29tMB4X -DTk2MDEwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgcsxCzAJBgNVBAYTAlpBMRUw -EwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UE -ChMRVGhhd3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2Vy -dmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQZXJzb25hbCBCYXNpYyBD -QTEoMCYGCSqGSIb3DQEJARYZcGVyc29uYWwtYmFzaWNAdGhhd3RlLmNvbTCBnzAN -BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvLyTU23AUE+CFeZIlDWmWr5vQvoPR+53 -dXLdjUmbllegeNTKP1GzaQuRdhciB5dqxFGTS+CN7zeVoQxN2jSQHReJl+A1OFdK -wPQIcOk8RHtQfmGakOMj04gRRif1CwcOu93RfyAKiLlWCy4cgNrx454p7xS9CkT7 -G1sY0b8jkyECAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQQF -AAOBgQAt4plrsD16iddZopQBHyvdEktTwq1/qqcAXJFAVyVKOKqEcLnZgA+le1z7 -c8a914phXAPjLSeoF+CEhULcXpvGt7Jtu3Sv5D/Lp7ew4F2+eIMllNLbgQ95B21P -9DkVWlIBe94y1k049hJcBlDfBVu9FEuh3ym6O0GN92NWod8isQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDLTCCApagAwIBAgIBADANBgkqhkiG9w0BAQQFADCB0TELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYD -VQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBT -ZXJ2aWNlcyBEaXZpc2lvbjEkMCIGA1UEAxMbVGhhd3RlIFBlcnNvbmFsIEZyZWVt -YWlsIENBMSswKQYJKoZIhvcNAQkBFhxwZXJzb25hbC1mcmVlbWFpbEB0aGF3dGUu -Y29tMB4XDTk2MDEwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgdExCzAJBgNVBAYT -AlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEa -MBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRp -b24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0ZSBQZXJzb25hbCBG -cmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxAdGhh -d3RlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1GnX1LCUZFtx6UfY -DFG26nKRsIRefS0Nj3sS34UldSh0OkIsYyeflXtL734Zhx2G6qPduc6WZBrCFG5E -rHzmj+hND3EfQDimAKOHePb5lIZererAXnbr2RSjXW56fAylS1V/Bhkpf56aJtVq -uzgkCGqYx7Hao5iR/Xnb5VrEHLkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zAN -BgkqhkiG9w0BAQQFAAOBgQDH7JJ+Tvj1lqVnYiqk8E0RYNBvjWBYYawmu1I1XAjP -MPuoSpaKH2JCI4wXD/S6ZJwXrEcp352YXtJsYHFcoqzceePnbgBHH7UNKOgCneSa -/RP0ptl8sfjcXyMmCZGAc9AUG95DqYMl8uacLxXK/qarigd1iwzdUYRr5PjRznei -gQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDKTCCApKgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBzzELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYD -VQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBT -ZXJ2aWNlcyBEaXZpc2lvbjEjMCEGA1UEAxMaVGhhd3RlIFBlcnNvbmFsIFByZW1p -dW0gQ0ExKjAoBgkqhkiG9w0BCQEWG3BlcnNvbmFsLXByZW1pdW1AdGhhd3RlLmNv -bTAeFw05NjAxMDEwMDAwMDBaFw0yMDEyMzEyMzU5NTlaMIHPMQswCQYDVQQGEwJa -QTEVMBMGA1UECBMMV2VzdGVybiBDYXBlMRIwEAYDVQQHEwlDYXBlIFRvd24xGjAY -BgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9u -IFNlcnZpY2VzIERpdmlzaW9uMSMwIQYDVQQDExpUaGF3dGUgUGVyc29uYWwgUHJl -bWl1bSBDQTEqMCgGCSqGSIb3DQEJARYbcGVyc29uYWwtcHJlbWl1bUB0aGF3dGUu -Y29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJZtn4B0TPuYwu8KHvE0Vs -Bd/eJxZRNkERbGw77f4QfRKe5ZtCmv5gMcNmt3M6SK5O0DI3lIi1DbbZ8/JE2dWI -Et12TfIa/G8jHnrx2JhFTgcQ7xZC0EN1bUre4qrJMf8fAHB8Zs8QJQi6+u4A6UYD -ZicRFTuqW/KY3TZCstqIdQIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MA0GCSqG -SIb3DQEBBAUAA4GBAGk2ifc0KjNyL2071CKyuG+axTZmDhs8obF1Wub9NdP4qPIH -b4Vnjt4rueIXsDqg8A6iAJrf8xQVbrvIhVqYgPn/vnQdPfP+MCXRNzRn+qVxeTBh -KXLA4CxM+1bkOqhv5TJZUtt1KFBZDPgLGeSs2a+WjS9Q2wfD6h+rM+D1KzGJ ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD -VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv -biBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFByZW1pdW0gU2Vy -dmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZlckB0aGF3dGUuY29t -MB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYTAlpB -MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsG -A1UEChMUVGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRp -b24gU2VydmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNl -cnZlciBDQTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNv -bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2aovXwlue2oFBYo847kkE -VdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIhUdib0GfQ -ug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMR -uHM/qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG -9w0BAQQFAAOBgQAmSCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUI -hfzJATj/Tb7yFkJD57taRvvBxhEf8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JM -pAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDEzCCAnygAwIBAgIBATANBgkqhkiG9w0BAQQFADCBxDELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD -VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv -biBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcGA1UEAxMQVGhhd3RlIFNlcnZlciBDQTEm -MCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5jb20wHhcNOTYwODAx -MDAwMDAwWhcNMjAxMjMxMjM1OTU5WjCBxDELMAkGA1UEBhMCWkExFTATBgNVBAgT -DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3 -dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNl -cyBEaXZpc2lvbjEZMBcGA1UEAxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3 -DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD -gY0AMIGJAoGBANOkUG7I/1Zr5s9dtuoMaHVHoqrC2oQl/Kj0R1HahbUgdJSGHg91 -yekIYfUGbTBuFRkC6VLAYttNmZ7iagxEOM3+vuNkCXDF/rFrKbYvScg71CcEJRCX -L+eQbcAoQpnXTEPew/UhbVSfXcNY4cDk2VuwuNy0e982OsK1ZiIS1ocNAgMBAAGj -EzARMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAB/pMaVz7lcxG -7oWDTSEwjsrZqG9JGubaUeNgcGyEYRGhGshIPllDfU+VPaGLtwtimHp1it2ITk6e -QNuozDJ0uW8NxuOzRAvZim+aKZuZGCg70eNAKJpaPNW15yAbi8qkq43pUdniTCxZ -qdq5snUb9kLy78fyGPmJvKP/iiMucEc= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICoTCCAgqgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBizELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTEUMBIGA1UEBxMLRHVyYmFudmlsbGUxDzAN -BgNVBAoTBlRoYXd0ZTEdMBsGA1UECxMUVGhhd3RlIENlcnRpZmljYXRpb24xHzAd -BgNVBAMTFlRoYXd0ZSBUaW1lc3RhbXBpbmcgQ0EwHhcNOTcwMTAxMDAwMDAwWhcN -MjAxMjMxMjM1OTU5WjCBizELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4g -Q2FwZTEUMBIGA1UEBxMLRHVyYmFudmlsbGUxDzANBgNVBAoTBlRoYXd0ZTEdMBsG -A1UECxMUVGhhd3RlIENlcnRpZmljYXRpb24xHzAdBgNVBAMTFlRoYXd0ZSBUaW1l -c3RhbXBpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANYrWHhhRYZT -6jR7UZztsOYuGA7+4F+oJ9O0yeB8WU4WDnNUYMF/9p8u6TqFJBU820cEY8OexJQa -Wt9MevPZQx08EHp5JduQ/vBR5zDWQQD9nyjfeb6Uu522FOMjhdepQeBMpHmwKxqL -8vg7ij5FrHGSALSQQZj7X+36ty6K+Ig3AgMBAAGjEzARMA8GA1UdEwEB/wQFMAMB -Af8wDQYJKoZIhvcNAQEEBQADgYEAZ9viwuaHPUCDhjc1fR/OmsMMZiCouqoEiYbC -9RAIDb/LogWK0E02PvTX72nGXuSwlG9KuefeW4i2e9vjJ+V2w/A1wcu1J5szedyQ -pgCed/r8zSeUQhac0xxo7L9c3eWpexAKMnRUEzGLhQOEkbdYATAUOK8oyvyxUBkZ -CayJSdM= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB -kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug -Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho -dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw -IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG -EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD -VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu -dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6 -E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ -D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK -4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq -lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW -bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB -o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT -MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js -LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr -BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB -AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft -Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj -j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH -KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv -2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3 -mfnGV/TJVTl4uix5yaaIK/QI ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEojCCA4qgAwIBAgIQRL4Mi1AAJLQR0zYlJWfJiTANBgkqhkiG9w0BAQUFADCB -rjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug -Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho -dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xNjA0BgNVBAMTLVVUTi1VU0VSRmlyc3Qt -Q2xpZW50IEF1dGhlbnRpY2F0aW9uIGFuZCBFbWFpbDAeFw05OTA3MDkxNzI4NTBa -Fw0xOTA3MDkxNzM2NThaMIGuMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAV -BgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5l -dHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTE2MDQGA1UE -AxMtVVROLVVTRVJGaXJzdC1DbGllbnQgQXV0aGVudGljYXRpb24gYW5kIEVtYWls -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsjmFpPJ9q0E7YkY3rs3B -YHW8OWX5ShpHornMSMxqmNVNNRm5pELlzkniii8efNIxB8dOtINknS4p1aJkxIW9 -hVE1eaROaJB7HHqkkqgX8pgV8pPMyaQylbsMTzC9mKALi+VuG6JG+ni8om+rWV6l -L8/K2m2qL+usobNqqrcuZzWLeeEeaYji5kbNoKXqvgvOdjp6Dpvq/NonWz1zHyLm -SGHGTPNpsaguG7bUMSAsvIKKjqQOpdeJQ/wWWq8dcdcRWdq6hw2v+vPhwvCkxWeM -1tZUOt4KpLoDd7NlyP0e03RiqhjKaJMeoYV+9Udly/hNVyh00jT/MLbu9mIwFIws -6wIDAQABo4G5MIG2MAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud -DgQWBBSJgmd9xJ0mcABLtFBIfN49rgRufTBYBgNVHR8EUTBPME2gS6BJhkdodHRw -Oi8vY3JsLnVzZXJ0cnVzdC5jb20vVVROLVVTRVJGaXJzdC1DbGllbnRBdXRoZW50 -aWNhdGlvbmFuZEVtYWlsLmNybDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUH -AwQwDQYJKoZIhvcNAQEFBQADggEBALFtYV2mGn98q0rkMPxTbyUkxsrt4jFcKw7u -7mFVbwQ+zznexRtJlOTrIEy05p5QLnLZjfWqo7NK2lYcYJeA3IKirUq9iiv/Cwm0 -xtcgBEXkzYABurorbs6q15L+5K/r9CYdFip/bDCVNy8zEqx/3cfREYxRmLLQo5HQ -rfafnoOTHh1CuEava2bwm3/q4wMC5QJRwarVNZ1yQAOJujEdxRBoUp7fooXFXAim -eOZTT7Hot9MUnpOmw2TjrH5xzbyf6QMbzPvprDHBr3wVdAKZw7JHpsIyYdfHb0gk -USeh1YdV8nuPmD0Wnu51tvjQjvLzxq4oW6fw8zYX/MMF08oDSlQ= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCB -lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug -Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho -dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt -SGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgxOTIyWjCBlzELMAkG -A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEe -MBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8v -d3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdh -cmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn -0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlIwrthdBKWHTxqctU8EGc6Oe0rE81m65UJ -M6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFdtqdt++BxF2uiiPsA3/4a -MXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8i4fDidNd -oI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqI -DsjfPe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9Ksy -oUhbAgMBAAGjgbkwgbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYD -VR0OBBYEFKFyXyYbKJhDlV0HN9WFlp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0 -dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LUhhcmR3YXJlLmNy -bDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEF -BQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM -//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28Gpgoiskli -CE7/yMgUsogWXecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gE -CJChicsZUN/KHAG8HQQZexB2lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t -3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kniCrVWFCVH/A7HFe7fRQ5YiuayZSS -KqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67nfhmqA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEZDCCA0ygAwIBAgIQRL4Mi1AAJLQR0zYwS8AzdzANBgkqhkiG9w0BAQUFADCB -ozELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug -Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho -dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xKzApBgNVBAMTIlVUTi1VU0VSRmlyc3Qt -TmV0d29yayBBcHBsaWNhdGlvbnMwHhcNOTkwNzA5MTg0ODM5WhcNMTkwNzA5MTg1 -NzQ5WjCBozELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0 -IExha2UgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYD -VQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xKzApBgNVBAMTIlVUTi1VU0VS -Rmlyc3QtTmV0d29yayBBcHBsaWNhdGlvbnMwggEiMA0GCSqGSIb3DQEBAQUAA4IB -DwAwggEKAoIBAQCz+5Gh5DZVhawGNFugmliy+LUPBXeDrjKxdpJo7CNKyXY/45y2 -N3kDuatpjQclthln5LAbGHNhSuh+zdMvZOOmfAz6F4CjDUeJT1FxL+78P/m4FoCH -iZMlIJpDgmkkdihZNaEdwH+DBmQWICzTSaSFtMBhf1EI+GgVkYDLpdXuOzr0hARe -YFmnjDRy7rh4xdE7EkpvfmUnuaRVxblvQ6TFHSyZwFKkeEwVs0CYCGtDxgGwenv1 -axwiP8vv/6jQOkt2FZ7S0cYu49tXGzKiuG/ohqY/cKvlcJKrRB5AUPuco2LkbG6g -yN7igEL66S/ozjIEj3yNtxyjNTwV3Z7DrpelAgMBAAGjgZEwgY4wCwYDVR0PBAQD -AgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFPqGydvguul49Uuo1hXf8NPh -ahQ8ME8GA1UdHwRIMEYwRKBCoECGPmh0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9V -VE4tVVNFUkZpcnN0LU5ldHdvcmtBcHBsaWNhdGlvbnMuY3JsMA0GCSqGSIb3DQEB -BQUAA4IBAQCk8yXM0dSRgyLQzDKrm5ZONJFUICU0YV8qAhXhi6r/fWRRzwr/vH3Y -IWp4yy9Rb/hCHTO967V7lMPDqaAt39EpHx3+jz+7qEUqf9FuVSTiuwL7MT++6Lzs -QCv4AdRWOOTKRIK1YSAhZ2X28AvnNPilwpyjXEAfhZOVBt5P1CeptqX8Fs1zMT+4 -ZSfP1FMa8Kxun08FDAOBp4QpxFq9ZFdyrTvPNximmMatBrTcCKME1SmklpoSZ0qM -YEWd8SOasACcaLWYUNPvji6SZbFIPiG+FTAqDbUMo2s/rn9X9R+WfN9v3YIwLGUb -QErNaLly7HF27FSOH4UMAWr6pjisH8SE ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 -IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz -BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y -aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG -9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNTIyMjM0OFoXDTE5MDYy -NTIyMjM0OFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y -azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs -YXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw -Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl -cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYWYJ6ibiWuqYvaG9Y -LqdUHAZu9OqNSLwxlBfw8068srg1knaw0KWlAdcAAxIiGQj4/xEjm84H9b9pGib+ -TunRf50sQB1ZaG6m+FiwnRqP0z/x3BkGgagO4DrdyFNFCQbmD3DD+kCmDuJWBQ8Y -TfwggtFzVXSNdnKgHZ0dwN0/cQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFBoPUn0 -LBwGlN+VYH+Wexf+T3GtZMjdd9LvWVXoP+iOBSoh8gfStadS/pyxtuJbdxdA6nLW -I8sogTLDAHkY7FkXicnGah5xyf23dKUlRWnFSKsZ4UWKJWsZ7uW7EvV/96aNUcPw -nXS3qT6gpf+2SQMT2iLM7XGCK5nPOrf1LXLI ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 -IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz -BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y -aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG -9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE5MDYy -NjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y -azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs -YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw -Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl -cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5avIWZJV16vY -dA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zfN1SLUzm1NZ9 -WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7RfZHM047QS -v4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9v -UJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTu -IYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwC -W/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICPTCCAaYCEQDNun9W8N/kvFT+IqyzcqpVMA0GCSqGSIb3DQEBAgUAMF8xCzAJ -BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xh -c3MgMSBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05 -NjAxMjkwMDAwMDBaFw0yODA4MDEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYD -VQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgMSBQdWJsaWMgUHJp -bWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOB -jQAwgYkCgYEA5Rm/baNWYS2ZSHH2Z965jeu3noaACpEO+jglr0aIguVzqKCbJF0N -H8xlbgyw0FaEGIeaBpsQoXPftFg5a27B9hXVqKg/qhIGjTGsf7A01480Z4gJzRQR -4k5FVmkfeAKA2txHkSm7NsljXMXg1y2He6G3MrB7MLoqLzGq7qNn2tsCAwEAATAN -BgkqhkiG9w0BAQIFAAOBgQBMP7iLxmjf7kMzDl3ppssHhE16M/+SG/Q2rdiVIjZo -EWx8QszznC7EBz8UsA9P/5CSdvnivErpj82ggAr3xSnxgiJduLHdgSOjeyUVRjB5 -FvjqBUuUfx3CHMjjt/QQQDwTw18fU+hI5Ia0e6E1sHslurjTjqs/OJ0ANACY89Fx -lA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDAjCCAmsCEEzH6qqYPnHTkxD4PTqJkZIwDQYJKoZIhvcNAQEFBQAwgcExCzAJ -BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh -c3MgMSBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy -MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp -emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X -DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw -FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMSBQdWJsaWMg -UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo -YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 -MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB -AQUAA4GNADCBiQKBgQCq0Lq+Fi24g9TK0g+8djHKlNgdk4xWArzZbxpvUjZudVYK -VdPfQ4chEWWKfo+9Id5rMj8bhDSVBZ1BNeuS65bdqlk/AVNtmU/t5eIqWpDBucSm -Fc/IReumXY6cPvBkJHalzasab7bYe1FhbqZ/h8jit+U03EGI6glAvnOSPWvndQID -AQABMA0GCSqGSIb3DQEBBQUAA4GBAKlPww3HZ74sy9mozS11534Vnjty637rXC0J -h9ZrbWB85a7FkCMMXErQr7Fd88e2CtvgFZMN3QO8x3aKtd1Pw5sTdbgBwObJW2ul -uIncrKTdcu1OofdPvAbT6shkdHvClUGcZXNY8ZCaPGqxmMnEh7zPRW1F4m4iP/68 -DzFc6PLZ ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEGjCCAwICEQCLW3VWhFSFCwDPrzhIzrGkMA0GCSqGSIb3DQEBBQUAMIHKMQsw -CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl -cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu -LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT -aWduIENsYXNzIDEgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp -dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD -VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT -aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ -bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu -IENsYXNzIDEgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg -LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN2E1Lm0+afY8wR4 -nN493GwTFtl63SRRZsDHJlkNrAYIwpTRMx/wgzUfbhvI3qpuFU5UJ+/EbRrsC+MO -8ESlV8dAWB6jRx9x7GD2bZTIGDnt/kIYVt/kTEkQeE4BdjVjEjbdZrwBBDajVWjV -ojYJrKshJlQGrT/KFOCsyq0GHZXi+J3x4GD/wn91K0zM2v6HmSHquv4+VNfSWXjb -PG7PoBMAGrgnoeS+Z5bKoMWznN3JdZ7rMJpfo83ZrngZPyPpXNspva1VyBtUjGP2 -6KbqxzcSXKMpHgLZ2x87tNcPVkeBFQRKr4Mn0cVYiMHd9qqnoxjaaKptEVHhv2Vr -n5Z20T0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAq2aN17O6x5q25lXQBfGfMY1a -qtmqRiYPce2lrVNWYgFHKkTp/j90CxObufRNG7LRX7K20ohcs5/Ny9Sn2WCVhDr4 -wTcdYcrnsMXlkdpUpqwxga6X3s0IrLjAl4B/bnKk52kTlWUfxJM8/XmPBNQ+T+r3 -ns7NZ3xPZQL/kYVUc8f/NveGLezQXk//EZ9yBta4GvFMDSZl4kSAHsef493oCtrs -pSCAaWihT37ha88HQfqDjrw43bAuEbFrskLMmrz5SCJ5ShkPshw+IHTZasO+8ih4 -E1Z5T21Q6huwtVexN2ZYI/PcD98Kh8TvhgXVOBRgmaNL3gaWcSzy27YfpO8/7g== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICPDCCAaUCEC0b/EoXjaOR6+f/9YtFvgswDQYJKoZIhvcNAQECBQAwXzELMAkG -A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz -cyAyIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 -MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV -BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAyIFB1YmxpYyBQcmlt -YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN -ADCBiQKBgQC2WoujDWojg4BrzzmH9CETMwZMJaLtVRKXxaeAufqDwSCg+i8VDXyh -YGt+eSz6Bg86rvYbb7HS/y8oUl+DfUvEerf4Zh+AVPy3wo5ZShRXRtGak75BkQO7 -FYCTXOvnzAhsPz6zSvz/S2wj1VCCJkQZjiPDceoZJEcEnnW/yKYAHwIDAQABMA0G -CSqGSIb3DQEBAgUAA4GBAIobK/o5wXTXXtgZZKJYSi034DNHD6zt96rbHuSLBlxg -J8pFUs4W7z8GZOeUaHxgMxURaa+dYo2jA1Rrpr7l7gUYYAS/QoD90KioHgE796Nc -r6Pc5iaAIzy4RHT3Cq5Ji2F4zCS/iIqnDupzGUH9TQPwiNHleI2lKk/2lw0Xd8rY ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDAzCCAmwCEQC5L2DMiJ+hekYJuFtwbIqvMA0GCSqGSIb3DQEBBQUAMIHBMQsw -CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0Ns -YXNzIDIgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH -MjE6MDgGA1UECxMxKGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9y -aXplZCB1c2Ugb25seTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazAe -Fw05ODA1MTgwMDAwMDBaFw0yODA4MDEyMzU5NTlaMIHBMQswCQYDVQQGEwJVUzEX -MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0NsYXNzIDIgUHVibGlj -IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjE6MDgGA1UECxMx -KGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s -eTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazCBnzANBgkqhkiG9w0B -AQEFAAOBjQAwgYkCgYEAp4gBIXQs5xoD8JjhlzwPIQjxnNuX6Zr8wgQGE75fUsjM -HiwSViy4AWkszJkfrbCWrnkE8hM5wXuYuggs6MKEEyyqaekJ9MepAqRCwiNPStjw -DqL7MWzJ5m+ZJwf15vRMeJ5t60aG+rmGyVTyssSv1EYcWskVMP8NbPUtDm3Of3cC -AwEAATANBgkqhkiG9w0BAQUFAAOBgQByLvl/0fFx+8Se9sVeUYpAmLho+Jscg9ji -nb3/7aHmZuovCfTK1+qlK5X2JGCGTUQug6XELaDTrnhpb3LabK4I8GOSN+a7xDAX -rXfMSTWqz9iP0b63GJZHc2pUIjRkLbYWm1lbtFFZOrMLFPQS32eg9K0yZF6xRnIn -jBJ7xUS0rg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEGTCCAwECEGFwy0mMX5hFKeewptlQW3owDQYJKoZIhvcNAQEFBQAwgcoxCzAJ -BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEfMB0GA1UECxMWVmVy -aVNpZ24gVHJ1c3QgTmV0d29yazE6MDgGA1UECxMxKGMpIDE5OTkgVmVyaVNpZ24s -IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTFFMEMGA1UEAxM8VmVyaVNp -Z24gQ2xhc3MgMiBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 -eSAtIEczMB4XDTk5MTAwMTAwMDAwMFoXDTM2MDcxNjIzNTk1OVowgcoxCzAJBgNV -BAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEfMB0GA1UECxMWVmVyaVNp -Z24gVHJ1c3QgTmV0d29yazE6MDgGA1UECxMxKGMpIDE5OTkgVmVyaVNpZ24sIElu -Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTFFMEMGA1UEAxM8VmVyaVNpZ24g -Q2xhc3MgMiBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt -IEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArwoNwtUs22e5LeWU -J92lvuCwTY+zYVY81nzD9M0+hsuiiOLh2KRpxbXiv8GmR1BeRjmL1Za6tW8UvxDO -JxOeBUebMXoT2B/Z0wI3i60sR/COgQanDTAM6/c8DyAd3HJG7qUCyFvDyVZpTMUY -wZF7C9UTAJu878NIPkZgIIUq1ZC2zYugzDLdt/1AVbJQHFauzI13TccgTacxdu9o -koqQHgiBVrKtaaNS0MscxCM9H5n+TOgWY47GCI72MfbS+uV23bUckqNJzc0BzWjN -qWm6o+sdDZykIKbBoMXRRkwXbdKsZj+WjOCE1Db/IlnF+RFgqF8EffIa9iVCYQ/E -Srg+iQIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQA0JhU8wI1NQ0kdvekhktdmnLfe -xbjQ5F1fdiLAJvmEOjr5jLX77GDx6M4EsMjdpwOPMPOY36TmpDHf0xwLRtxyID+u -7gU8pDM/CzmscHhzS5kr3zDCVLCoO1Wh/hYozUK9dG6A2ydEp85EXdQbkJgNHkKU -sQAsBNB0owIFImNjzYO1+8FtYmtpdf1dcEG59b98377BMnMiIYtYgXsVkXq642RI -sH/7NiXaldDxJBQX3RiAa0YjOVT1jmIJBB2UkKab5iXiQkWquJCtvgiPqQtCGJTP -cjnhsUPgKM+351psE2tJs//jGHyJizNdrDPXp/naOlXJWBD5qu9ats9LS98q ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG -A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz -cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 -MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV -BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt -YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN -ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE -BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is -I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G -CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do -lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc -AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJ -BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh -c3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy -MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp -emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X -DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw -FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMg -UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo -YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 -MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB -AQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4 -pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg0 -13gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwID -AQABMA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSk -U01UbSuvDV1Ai2TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i -F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY -oJ2daZH9 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw -CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl -cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu -LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT -aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp -dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD -VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT -aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ -bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu -IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg -LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b -N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t -KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu -kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm -CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ -Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu -imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te -2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe -DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC -/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p -F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt -TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDAjCCAmsCEDKIjprS9esTR/h/xCA3JfgwDQYJKoZIhvcNAQEFBQAwgcExCzAJ -BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh -c3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy -MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp -emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X -DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw -FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgNCBQdWJsaWMg -UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo -YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 -MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB -AQUAA4GNADCBiQKBgQC68OTP+cSuhVS5B1f5j8V/aBH4xBewRNzjMHPVKmIquNDM -HO0oW369atyzkSTKQWI8/AIBvxwWMZQFl3Zuoq29YRdsTjCG8FE3KlDHqGKB3FtK -qsGgtG7rL+VXxbErQHDbWk2hjh+9Ax/YA9SPTJlxvOKCzFjomDqG04Y48wApHwID -AQABMA0GCSqGSIb3DQEBBQUAA4GBAIWMEsGnuVAVess+rLhDityq3RS6iYF+ATwj -cSGIL4LcY/oCRaxFWdcqWERbt5+BO5JoPeI3JPV7bI92NZYJqFmduc4jq3TWg/0y -cyfYaT5DdPauxYma51N86Xv2S/PBZYPejYqcPIiNOVn8qj8ijaHBZlCBckztImRP -T8qAkbYp ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQsw -CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl -cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu -LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT -aWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp -dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD -VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT -aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ -bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu -IENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg -LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK3LpRFpxlmr8Y+1 -GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaStBO3IFsJ -+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0Gbd -U6LM8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLm -NxdLMEYH5IBtptiWLugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XY -ufTsgsbSPZUd5cBPhMnZo0QoBmrXRazwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ -ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAj/ola09b5KROJ1WrIhVZPMq1 -CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXttmhwwjIDLk5Mq -g6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm -fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c -2NU8Qh0XwRJdRTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/ -bLvSHgCwIe34QWKCudiyxLtGUPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICNDCCAaECEAKtZn5ORf5eV288mBle3cAwDQYJKoZIhvcNAQECBQAwXzELMAkG -A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD -VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk0 -MTEwOTAwMDAwMFoXDTEwMDEwNzIzNTk1OVowXzELMAkGA1UEBhMCVVMxIDAeBgNV -BAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYDVQQLEyVTZWN1cmUgU2Vy -dmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGbMA0GCSqGSIb3DQEBAQUAA4GJ -ADCBhQJ+AJLOesGugz5aqomDV6wlAXYMra6OLDfO6zV4ZFQD5YRAUcm/jwjiioII -0haGN1XpsSECrXZogZoFokvJSyVmIlZsiAeP94FZbYQHZXATcXY+m3dM41CJVphI -uR2nKRoTLkoRWZweFdVJVCxzOmmCsZc5nG1wZ0jl3S3WyB57AgMBAAEwDQYJKoZI -hvcNAQECBQADfgBl3X7hsuyw4jrg7HFGmhkRuNPHoLQDQCYCPgmc4RKz0Vr2N6W3 -YQO2WxZpO8ZECAyIUwxrl0nHPjXcbLm7qt9cuzovk2C2qUtN8iD3zV9/ZHuO3ABc -1/p3yjkWWW8O6tO1g39NTUJWdrTJXwT4OPjr0l91X817/OWOgHz8UA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDzTCCAzagAwIBAgIQU2GyYK7bcY6nlLMTM/QHCTANBgkqhkiG9w0BAQUFADCB -wTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTwwOgYDVQQL -EzNDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 -IC0gRzIxOjA4BgNVBAsTMShjKSAxOTk4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1 -dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv -cmswHhcNMDAwOTI2MDAwMDAwWhcNMTAwOTI1MjM1OTU5WjCBpTEXMBUGA1UEChMO -VmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsx -OzA5BgNVBAsTMlRlcm1zIG9mIHVzZSBhdCBodHRwczovL3d3dy52ZXJpc2lnbi5j -b20vcnBhIChjKTAwMSwwKgYDVQQDEyNWZXJpU2lnbiBUaW1lIFN0YW1waW5nIEF1 -dGhvcml0eSBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0hmdZ8IAIVli -zrQJIkRpivglWtvtDbc2fk7gu5Q+kCWHwmFHKdm9VLhjzCx9abQzNvQ3B5rB3UBU -/OB4naCTuQk9I1F/RMIUdNsKvsvJMDRAmD7Q1yUQgZS9B0+c1lQn3y6ov8uQjI11 -S7zi6ESHzeZBCiVu6PQkAsVSD27smHUCAwEAAaOB3zCB3DAPBgNVHRMECDAGAQH/ -AgEAMEUGA1UdIAQ+MDwwOgYMYIZIAYb4RQEHFwEDMCowKAYIKwYBBQUHAgEWHGh0 -dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9ycGEwMQYDVR0fBCowKDAmoCSgIoYgaHR0 -cDovL2NybC52ZXJpc2lnbi5jb20vcGNhMy5jcmwwCwYDVR0PBAQDAgEGMEIGCCsG -AQUFBwEBBDYwNDAyBggrBgEFBQcwAaYmFiRodHRwOi8vb2NzcC52ZXJpc2lnbi5j -b20vb2NzcC9zdGF0dXMwDQYJKoZIhvcNAQEFBQADgYEAgnBold+2DcIBcBlK0lRW -HqzyRUyHuPU163hLBanInTsZIS5wNEqi9YngFXVF5yg3ADQnKeg3S/LvRJdrF1Ea -w1adPBqK9kpGRjeM+sv1ZFo4aC4cw+9wzrhGBha/937ntag+RaypJXUie28/sJyU -58dzq6wf7iWbwBbtt8pb8BQ= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDojCCAoqgAwIBAgIQE4Y1TR0/BvLB+WUF1ZAcYjANBgkqhkiG9w0BAQUFADBr -MQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRl -cm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNv -bW1lcmNlIFJvb3QwHhcNMDIwNjI2MDIxODM2WhcNMjIwNjI0MDAxNjEyWjBrMQsw -CQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRlcm5h -dGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNvbW1l -cmNlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvV95WHm6h -2mCxlCfLF9sHP4CFT8icttD0b0/Pmdjh28JIXDqsOTPHH2qLJj0rNfVIsZHBAk4E -lpF7sDPwsRROEW+1QK8bRaVK7362rPKgH1g/EkZgPI2h4H3PVz4zHvtH8aoVlwdV -ZqW1LS7YgFmypw23RuwhY/81q6UCzyr0TP579ZRdhE2o8mCP2w4lPJ9zcc+U30rq -299yOIzzlr3xF7zSujtFWsan9sYXiwGd/BmoKoMWuDpI/k4+oKsGGelT84ATB+0t -vz8KPFUgOSwsAGl0lUq8ILKpeeUYiZGo3BxN77t+Nwtd/jmliFKMAGzsGHxBvfaL -dXe6YJ2E5/4tAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD -AgEGMB0GA1UdDgQWBBQVOIMPPyw/cDMezUb+B4wg4NfDtzANBgkqhkiG9w0BAQUF -AAOCAQEAX/FBfXxcCLkr4NWSR/pnXKUTwwMhmytMiUbPWU3J/qVAtmPN3XEolWcR -zCSs00Rsca4BIGsDoo8Ytyk6feUWYFN4PMCvFYP3j1IzJL1kk5fui/fbGKhtcbP3 -LBfQdCVp9/5rPJS+TUtBjE7ic9DjkCJzQ83z7+pzzkWKsKZJ/0x9nXGIxHYdkFsd -7v3M9+79YKWxehZx0RbQfBI8bGmX265fOZpwLwU8GUYEmSA20GBuYQa7FkKMcPcw -++DbZqMAAb3mLNqRX6BGi01qnD093QVG/na/oAo85ADmJ7f/hC3euiInlhBx6yLt -398znM/jra6O1I7mT1GvFpLgXPYHDw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDgDCCAmigAwIBAgICAx4wDQYJKoZIhvcNAQEFBQAwYTELMAkGA1UEBhMCVVMx -DTALBgNVBAoTBFZJU0ExLzAtBgNVBAsTJlZpc2EgSW50ZXJuYXRpb25hbCBTZXJ2 -aWNlIEFzc29jaWF0aW9uMRIwEAYDVQQDEwlHUCBSb290IDIwHhcNMDAwODE2MjI1 -MTAwWhcNMjAwODE1MjM1OTAwWjBhMQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklT -QTEvMC0GA1UECxMmVmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRp -b24xEjAQBgNVBAMTCUdQIFJvb3QgMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBAKkBcLWqxEDwq2omYXkZAPy/mzdZDK9vZBv42pWUJGkzEXDK41Z0ohdX -ZFwgBuHW73G3O/erwWnQSaSxBNf0V2KJXLB1LRckaeNCYOTudNargFbYiCjh+20i -/SN8RnNPflRzHqgsVVh1t0zzWkWlAhr62p3DRcMiXvOL8WAp0sdftAw6UYPvMPjU -58fy+pmjIlC++QU3o63tmsPm7IgbthknGziLgE3sucfFicv8GjLtI/C1AVj59o/g -halMCXI5Etuz9c9OYmTaxhkVOmMd6RdVoUwiPDQyRvhlV7or7zaMavrZ2UT0qt2E -1w0cslSsMoW0ZA3eQbuxNMYBhjJk1Z8CAwEAAaNCMEAwHQYDVR0OBBYEFJ59SzS/ -ca3CBfYDdYDOqU8axCRMMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEG -MA0GCSqGSIb3DQEBBQUAA4IBAQAhpXYUVfmtJ3CPPPTVbMjMCqujmAuKBiPFyWHb -mQdpNSYx/scuhMKZYdQN6X0uEyt8joW2hcdLzzW2LEc9zikv2G+fiRxkk78IvXbQ -kIqUs38oW26sTTMs7WXcFsziza6kPWKSBpUmv9+55CCmc2rBvveURNZNbyoLaxhN -dBA2aGpawWqn3TYpjLgwi08hPwAuVDAHOrqK5MOeyti12HvOdUVmB/RtLdh6yumJ -ivIj2C/LbgA2T/vwLwHMD8AiZfSr4k5hLQOCfZEWtTDVFN5ex5D8ofyrEK9ca3Cn -B+8phuiyJccg/ybdd+95RBTEvd07xQObdyPsoOy7Wjm1zK0G ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIETzCCAzegAwIBAgIEO63vKTANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE -ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg -U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDEwOTIzMTQxODE3WhcNMTEw -OTIzMTMxODE3WjB1MQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v -LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MR8wHQYDVQQDExZDQyBTaWdu -ZXQgLSBDQSBLbGFzYSAxMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4SRW9Q58g5DY1Hw7h -gCRKBEdPdGn0MFHsfw7rlu/oQm7IChI/uWd9q5wwo77YojtTDjRnpgZsjqBeynX8T90vFILqsY2K -5CF1OESalwvVr3sZiQX79lisuFKat92u6hBFikFIVxfHHB67Af+g7u0dEHdDW7lwy81MwFYxBTRy -9wIDAQABo4IBbTCCAWkwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwggEEBgNVHSAE -gfwwgfkwgfYGDSsGAQQBvj8CAQoBAQAwgeQwgZoGCCsGAQUFBwICMIGNGoGKQ2VydHlmaWthdCB3 -eXN0YXdpb255IHpnb2RuaWUgeiBkb2t1bWVudGVtOiAiUG9saXR5a2EgQ2VydHlmaWthY2ppIGRs -YSBSb290Q0EiLiBDZXJ0eWZpa2F0IHd5c3Rhd2lvbnkgcHJ6ZXogUm9vdENBIHcgaGllcmFyY2hp -aSBDQyBTaWduZXQuMEUGCCsGAQUFBwIBFjlodHRwOi8vd3d3LnNpZ25ldC5wbC9yZXBvenl0b3Jp -dW0vZG9rdW1lbnR5L3BjX3Jvb3RjYS50eHQwHwYDVR0jBBgwFoAUwJvFIw0C4aZOSGsfAOnjmhQb -sa8wHQYDVR0OBBYEFMODHtVZd1T7TftXR/nEI1zR54njMA0GCSqGSIb3DQEBBQUAA4IBAQBRIHQB -FIGh8Jpxt87AgSLwIEEk4+oGy769u3NtoaR0R3WNMdmt7fXTi0tyTQ9V4AIszxVjhnUPaKnF1KYy -f8Tl+YTzk9ZfFkZ3kCdSaILZAOIrmqWNLPmjUQ5/JiMGho0e1YmWUcMci84+pIisTsytFzVP32/W -+sz2H4FQAvOIMmxB7EJX9AdbnXn9EXZ+4nCqi0ft5z96ZqOJJiCB3vSaoYg+wdkcvb6souMJzuc2 -uptXtR1Xf3ihlHaGW+hmnpcwFA6AoNrom6Vgzk6U1ienx0Cw28BhRSKqzKkyXkuK8gRflZUx84uf -tXncwKJrMiE3lvgOOBITRzcahirLer4c ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIE9zCCA9+gAwIBAgIEPL/xoTANBgkqhkiG9w0BAQUFADB2MQswCQYDVQQGEwJQTDEfMB0GA1UE -ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg -U2lnbmV0MSAwHgYDVQQDExdDQyBTaWduZXQgLSBQQ0EgS2xhc2EgMjAeFw0wMjA0MTkxMDI5NTNa -Fw0xNzA0MTgxMjUzMDdaMHUxCzAJBgNVBAYTAlBMMR8wHQYDVQQKExZUUCBJbnRlcm5ldCBTcC4g -eiBvLm8uMSQwIgYDVQQLExtDZW50cnVtIENlcnR5ZmlrYWNqaSBTaWduZXQxHzAdBgNVBAMTFkND -IFNpZ25ldCAtIENBIEtsYXNhIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqgLJu -QqY4yavbSgHg8CyfKTx4BokNSDOVz4eD9vptUr11Kqd06ED1hlH7Sg0goBFAfntNU/QTKwSBaNui -me7C4sSEdgsKrPoAhGb4Mq8y7Ty7RqZz7mkzNMqzL2L2U4yQ2QjvpH8MH0IBqOWEcpSkpwnrCDIm -RoTfd+YlZWKi2JceQixUUYIQ45Ox8+x8hHbvvZdgqtcvo8PW27qoHkp/7hMuJ44kDAGrmxffBXl/ -OBRZp0uO1CSLcMcVJzyr2phKhy406MYdWrtNPEluGs0GFDzd0nrIctiWAO4cmct4S72S9Q6e//0G -O9f3/Ca5Kb2I1xYLj/xE+HgjHX9aD2MhAgMBAAGjggGMMIIBiDAPBgNVHRMBAf8EBTADAQH/MA4G -A1UdDwEB/wQEAwIBBjCB4wYDVR0gBIHbMIHYMIHVBg0rBgEEAb4/AhQKAQEAMIHDMHUGCCsGAQUF -BwICMGkaZ0NlcnR5ZmlrYXQgd3lzdGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0 -eWthIENlcnR5ZmlrYWNqaSBQQ0EyIC0gQ2VydHlmaWthdHkgVXJ6ZWRvdyBLbGFzeSAyIi4wSgYI -KwYBBQUHAgEWPmh0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9kb2t1bWVudHkva2xh -c2EyL3BjX3BjYTIudHh0MD8GA1UdHwQ4MDYwNKAyoDCGLmh0dHA6Ly93d3cuc2lnbmV0LnBsL3Jl -cG96eXRvcml1bS9jcmwvcGNhMi5jcmwwHwYDVR0jBBgwFoAUwGxGyl2CfpYHRonE82AVXO08kMIw -HQYDVR0OBBYEFLtFBlILy4HNKVSzvHxBTM0HDowlMA0GCSqGSIb3DQEBBQUAA4IBAQBWTsCbqXrX -hBBev5v5cIuc6gJM8ww7oR0uMQRZoFSqvQUPWBYM2/TLI/f8UM9hSShUVj3zEsSj/vFHagUVmzuV -Xo5u0WK8iaqATSyEVBhADHrPG6wYcLKJlagge/ILA0m+SieyP2sjYD9MUB9KZIEyBKv0429UuDTw -6P7pslxMWJBSNyQxaLIs0SRKsqZZWkc7ZYAj2apSkBMX2Is1oHA+PwkF6jQMwCao/+CndXPUzfCF -6caa9WwW31W26MlXCvSmJgfiTPwGvm4PkPmOnmWZ3CczzhHl4q7ztHFzshJH3sZWDnrWwBFjzz5e -Pr3WHV1wA7EY6oT4zBx+2gT9XBTB ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEUzCCAzugAwIBAgIEPq+qjzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJQTDE3MDUGA1UE -ChMuQ1ppQyBDZW50cmFzdCBTQSB3IGltaWVuaXUgTWluaXN0cmEgR29zcG9kYXJraTEZMBcGA1UE -AxMQQ1ppQyBDZW50cmFzdCBTQTAeFw0wMzA0MzAxMDUwNTVaFw0wODA0MjgxMDUwNTVaMGgxCzAJ -BgNVBAYTAlBMMR8wHQYDVQQKExZUUCBJbnRlcm5ldCBTcC4geiBvLm8uMR8wHQYDVQQDExZDQyBT -aWduZXQgLSBDQSBLbGFzYSAzMRcwFQYDVQQFEw5OdW1lciB3cGlzdTogNDCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBALVdeOM62cPH2NERFxbS5FIp/HSv3fgesdVsTUFxZbGtE+/E0RMl -KZQJHH9emx7vRYubsi4EOLCjYsCOTFvgGRIpZzx7R7T5c0Di5XFkRU4gjBl7aHJoKb5SLzGlWdoX -GsekVtl6keEACrizV2EafqjI8cnBWY7OxQ1ooLQp5AeFjXg+5PT0lO6TUZAubqjFbhVbxSWjqvdj -93RGfyYE76MnNn4c2xWySD07n7uno06TC0IJe6+3WSX1h+76VsIFouWBXOoM7cxxiLjoqdBVu24+ -P8e81SukE7qEvOwDPmk9ZJFtt1nBNg8a1kaixcljrA/43XwOPz6qnJ+cIj/xywECAwEAAaOCAQow -ggEGMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMDMGA1UdIAEB/wQpMCcwJQYEVR0g -ADAdMBsGCCsGAQUFBwIBFg93d3cuY2VudHJhc3QucGwwgY4GA1UdIwSBhjCBg4AU2a7r85Cp1iJN -W0Ca1LR6VG3996ShZaRjMGExCzAJBgNVBAYTAlBMMTcwNQYDVQQKEy5DWmlDIENlbnRyYXN0IFNB -IHcgaW1pZW5pdSBNaW5pc3RyYSBHb3Nwb2RhcmtpMRkwFwYDVQQDExBDWmlDIENlbnRyYXN0IFNB -ggQ9/0sQMB0GA1UdDgQWBBR7Y8wZkHq0zrY7nn1tFSdQ0PlJuTANBgkqhkiG9w0BAQUFAAOCAQEA -ldt/svO5c1MU08FKgrOXCGEbEPbQxhpM0xcd6Iv3dCo6qugEgjEs9Qm5CwUNKMnFsvR27cJWUvZb -MVcvwlwCwclOdwF6u/QRS8bC2HYErhYo9bp9yuxxzuow2A94c5fPqfVrjXy+vDouchAm6+A5Wjzv -J8wxVFDCs+9iGACmyUWr/JGXCYiQIbQkwlkRKHHlan9ymKf1NvIej/3EpeT8fKr6ywxGuhAfqofW -pg3WJY/RCB4lTzD8vZGNwfMFGkWhJkypad3i9w3lGmDVpsHaWtCgGfd0H7tUtWPkP+t7EjIRCD9J -HYnTR+wbbewc5vOI+UobR15ynGfFIaSIiMTVtQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEejCCA2KgAwIBAgIEP4vk6TANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJQ -TDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2Vu -dHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MR8wHQYDVQQDExZDQyBTaWduZXQgLSBD -QSBLbGFzYSAyMB4XDTAzMTAxNDExNTgyMloXDTE3MDQxODEyNTMwN1owdzELMAkG -A1UEBhMCUEwxHzAdBgNVBAoTFlRQIEludGVybmV0IFNwLiB6IG8uby4xJDAiBgNV -BAsTG0NlbnRydW0gQ2VydHlmaWthY2ppIFNpZ25ldDEhMB8GA1UEAxMYQ0MgU2ln -bmV0IC0gT0NTUCBLbGFzYSAyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCo -VCsaBStblXQYVNthe3dvaCrfvKpPXngh4almm988iIlEv9CVTaAdCfaJNihvA+Vs -Qw8++ix1VqteMQE474/MV/YaXigP0Zr0QB+g+/7PWVlv+5U9Gzp9+Xx4DJay8AoI -iB7Iy5Qf9iZiHm5BiPRIuUXT4ZRbZRYPh0/76vgRsQIDAQABo4IBkjCCAY4wDgYD -VR0PAQH/BAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMJMEEGA1UdHwQ6MDgwNqA0 -oDKGMGh0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9jcmwva2xhc2Ey -LmNybDCB2AYDVR0gBIHQMIHNMIHKBg4rBgEEAb4/AoFICgwBADCBtzBsBggrBgEF -BQcCAjBgGl5DZXJ0eWZpa2F0IHd5ZGFueSB6Z29kbmllIHogZG9rdW1lbnRlbSAi -UG9saXR5a2EgQ2VydHlmaWthY2ppIC0gQ2VydHlmaWthdHkgcmVzcG9uZGVyb3cg -T0NTUCIuMEcGCCsGAQUFBwIBFjtodHRwOi8vd3d3LnNpZ25ldC5wbC9yZXBvenl0 -b3JpdW0vZG9rdW1lbnR5L3BjX29jc3BfMV8wLnBkZjAfBgNVHSMEGDAWgBS7RQZS -C8uBzSlUs7x8QUzNBw6MJTAdBgNVHQ4EFgQUKEVrOY7cEHvsVgvoyZdytlbtgwEw -CQYDVR0TBAIwADANBgkqhkiG9w0BAQUFAAOCAQEAQrRg5MV6dxr0HU2IsLInxhvt -iUVmSFkIUsBCjzLoewOXA16d2oDyHhI/eE+VgAsp+2ANjZu4xRteHIHoYMsN218M -eD2MLRsYS0U9xxAFK9gDj/KscPbrrdoqLvtPSMhUb4adJS9HLhvUe6BicvBf3A71 -iCNe431axGNDWKnpuj2KUpj4CFHYsWCXky847YtTXDjri9NIwJJauazsrSjK+oXp -ngRS506mdQ7vWrtApkh8zhhWp7duCkjcCo1O8JxqYr2qEW1fXmgOISe010v2mmuv -hHxPyVwoAU4KkOw0nbXZn53yak0is5+XmAjh0wWue44AssHrjC9nUh3mkLt6eQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEezCCA2OgAwIBAgIEP4vnLzANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJQ -TDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEfMB0GA1UEAxMWQ0Mg -U2lnbmV0IC0gQ0EgS2xhc2EgMzEXMBUGA1UEBRMOTnVtZXIgd3Bpc3U6IDQwHhcN -MDMxMDE0MTIwODAwWhcNMDgwNDI4MTA1MDU1WjB3MQswCQYDVQQGEwJQTDEfMB0G -A1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBD -ZXJ0eWZpa2FjamkgU2lnbmV0MSEwHwYDVQQDExhDQyBTaWduZXQgLSBPQ1NQIEts -YXNhIDMwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM/9GwvARNuCVN+PqZmO -4FqH8vTqhenUyqRkmAVT4YhLu0a9AXeLAYVDu+NTkYzsAUMAfu55rIKHNLlm6WbF -KvLiKKz4p4pbUr+ToPcwl/TDotidloUdBAxDg0SL+PmQqACZDe3seJho2IYf2vDL -/G4TLMbKmNB0mlWFuN0f4fJNAgMBAAGjggGgMIIBnDAOBgNVHQ8BAf8EBAMCB4Aw -EwYDVR0lBAwwCgYIKwYBBQUHAwkwTwYDVR0fBEgwRjBEoEKgQIY+aHR0cDovL3d3 -dy5zaWduZXQucGwva3dhbGlmaWtvd2FuZS9yZXBvenl0b3JpdW0vY3JsL2tsYXNh -My5jcmwwgdgGA1UdIASB0DCBzTCBygYOKwYBBAG+PwKCLAoCAQAwgbcwbAYIKwYB -BQUHAgIwYBpeQ2VydHlmaWthdCB3eWRhbnkgemdvZG5pZSB6IGRva3VtZW50ZW0g -IlBvbGl0eWthIENlcnR5ZmlrYWNqaSAtIENlcnR5ZmlrYXR5IHJlc3BvbmRlcm93 -IE9DU1AiLjBHBggrBgEFBQcCARY7aHR0cDovL3d3dy5zaWduZXQucGwvcmVwb3p5 -dG9yaXVtL2Rva3VtZW50eS9wY19vY3NwXzFfMC5wZGYwHwYDVR0jBBgwFoAUe2PM -GZB6tM62O559bRUnUND5SbkwHQYDVR0OBBYEFG4jnCMvBALRQXtmDn9TyXQ/EKP+ -MAkGA1UdEwQCMAAwDQYJKoZIhvcNAQEFBQADggEBACXrKG5Def5lpRwmZom3UEDq -bl7y4U3qomG4B+ok2FVZGgPZti+ZgvrenPj7PtbYCUBPsCSTNrznKinoT3gD9lQQ -xkEHwdc6VD1GlFp+qI64u0+wS9Epatrdf7aBnizrOIB4LJd4E2TWQ6trspetjMIU -upyWls1BmYUxB91R7QkTiAUSNZ87s3auhZuG4f0V0JLVCcg2rn7AN1rfMkgxCbHk -GxiQbYWFljl6aatxR3odnnzVUe1I8uoY2JXpmmUcOG4dNGuQYziyKG3mtXCQWvug -5qi9Mf3KUh1oSTKx6HfLjjNl1+wMB5Mdb8LF0XyZLdJM9yIZh7SBRsYm9QiXevY= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFGjCCBAKgAwIBAgIEPL7eEDANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE -ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg -U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDIwNDE4MTQ1NDA4WhcNMjYw -OTIxMTU0MjE5WjB2MQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v -LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MSAwHgYDVQQDExdDQyBTaWdu -ZXQgLSBQQ0EgS2xhc2EgMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM7BrBlbN5ma -M5eg0BOTqoZ+9NBDvU8Lm5rTdrMswFTCathzpVVLK/JD4K3+4oCZ9SRAspEXE4gvwb08ASY6w5s+ -HpRkeJw8YzMFR5kDZD5adgnCAy4vDfIXYZgppXPaTQ8wnfUZ7BZ7Zfa7QBemUIcJIzJBB0UqgtxW -Ceol9IekpBRVmuuSA6QG0Jkm+pGDJ05yj2eQG8jTcBENM7sVA8rGRMyFA4skSZ+D0OG6FS2xC1i9 -JyN0ag1yII/LPx8HK5J4W9MaPRNjAEeaa2qI9EpchwrOxnyVbQfSedCG1VRJfAsE/9tT9CMUPZ3x -W20QjQcSZJqVcmGW9gVsXKQOVLsCAwEAAaOCAbMwggGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P -AQH/BAQDAgEGMIIBBAYDVR0gBIH8MIH5MIH2Bg0rBgEEAb4/AgEKAQEBMIHkMIGaBggrBgEFBQcC -AjCBjRqBikNlcnR5ZmlrYXQgd3lzdGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0 -eWthIENlcnR5ZmlrYWNqaSBkbGEgUm9vdENBIi4gQ2VydHlmaWthdCB3eXN0YXdpb255IHByemV6 -IFJvb3RDQSB3IGhpZXJhcmNoaWkgQ0MgU2lnbmV0LjBFBggrBgEFBQcCARY5aHR0cDovL3d3dy5z -aWduZXQucGwvcmVwb3p5dG9yaXVtL2Rva3VtZW50eS9wY19yb290Y2EudHh0MEQGA1UdHwQ9MDsw -OaA3oDWGM2h0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9yb290Y2Evcm9vdGNhLmNy -bDAfBgNVHSMEGDAWgBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAdBgNVHQ4EFgQUwGxGyl2CfpYHRonE -82AVXO08kMIwDQYJKoZIhvcNAQEFBQADggEBABp1TAUsa+BeVWg4cjowc8yTJ5XN3GvN96GObMkx -UGY7U9kVrLI71xBgoNVyzXTiMNDBvjh7vdPWjpl5SDiRpnnKiOFXA43HvNWzUaOkTu1mxjJsZsan -ot1Xt6j0ZDC+03FjLHdYMyM9kSWp6afb4980EPYZCcSzgM5TOGfJmNii5Tq468VFKrX+52Aou1G2 -2Ohu+EEOlOrG7ylKv1hHUJJCjwN0ZVEIn1nDbrU9FeGCz8J9ihVUvnENEBbBkU37PWqWuHitKQDV -tcwTwJJdR8cmKq3NmkwAm9fPacidQLpaw0WkuGrS+fEDhu1Nhy9xELP6NA9GRTCNxm/dXlcwnmY= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFGjCCBAKgAwIBAgIEPV0tNDANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE -ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg -U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDIwODE2MTY0OTU2WhcNMjYw -OTIxMTU0MjE5WjB2MQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v -LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MSAwHgYDVQQDExdDQyBTaWdu -ZXQgLSBQQ0EgS2xhc2EgMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALN3LanJtdue -Ne6geWUTFENa+lEuzqELcoqhYB+a/tJcPEkc6TX/bYPzalRRjqs+quMP6KZTU0DixOrV+K7iWaqA -iQ913HX5IBLmKDCrTVW/ZvSDpiBKbxlHfSNuJxAuVT6HdbzK7yAW38ssX+yS2tZYHZ5FhZcfqzPE -OpO94mAKcBUhk6T/ki0evXX/ZvvktwmF3hKattzwtM4JMLurAEl8SInyEYULw5JdlfcBez2Tg6Db -w34hA1A+ckTwhxzecrB8TUe2BnQKOs9vr2cCACpFFcOmPkM0Drtjctr1QHm1tYSqRFRf9VcV5tfC -3P8QqoK4ONjtLPHc9x5NE1uK/FMCAwEAAaOCAbMwggGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P -AQH/BAQDAgEGMIIBBAYDVR0gBIH8MIH5MIH2Bg0rBgEEAb4/AgEKAQECMIHkMIGaBggrBgEFBQcC -AjCBjRqBikNlcnR5ZmlrYXQgd3lzdGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0 -eWthIENlcnR5ZmlrYWNqaSBkbGEgUm9vdENBIi4gQ2VydHlmaWthdCB3eXN0YXdpb255IHByemV6 -IFJvb3RDQSB3IGhpZXJhcmNoaWkgQ0MgU2lnbmV0LjBFBggrBgEFBQcCARY5aHR0cDovL3d3dy5z -aWduZXQucGwvcmVwb3p5dG9yaXVtL2Rva3VtZW50eS9wY19yb290Y2EudHh0MEQGA1UdHwQ9MDsw -OaA3oDWGM2h0dHA6Ly93d3cuc2lnbmV0LnBsL3JlcG96eXRvcml1bS9yb290Y2Evcm9vdGNhLmNy -bDAfBgNVHSMEGDAWgBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAdBgNVHQ4EFgQUXvthcPHlH5BgGhlM -ErJNXWlhlgAwDQYJKoZIhvcNAQEFBQADggEBACIce95Mvn710KCAISA0CuHD4aznTU6pLoCDShW4 -7OR+GTpJUm1coTcUqlBHV9mra4VFrBcBuOkHZoBLq/jmE0QJWnpSEULDcH9J3mF0nqO9SM+mWyJG -dsJF/XU/7smummgjMNQXwzQTtWORF+6v5KUbWX85anO2wR+M6YTBWC55zWpWi4RG3vkHFs5Ze2oF -JTlpuxw9ZgxTnWlwI9QR2MvEhYIUMKMOWxw1nt0kKj+5TCNQQGh/VJJ1dsiroGh/io1DOcePEhKz -1Ag52y6Wf0nJJB9yk0sFakqZH18F7eQecQImgZyyeRtsG95leNugB3BXWCW+KxwiBrtQTXv4dTE= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEzzCCA7egAwIBAgIEO6ocGTANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJQTDEfMB0GA1UE -ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg -U2lnbmV0MRswGQYDVQQDExJDQyBTaWduZXQgLSBSb290Q0EwHhcNMDEwOTIwMTY0MjE5WhcNMjYw -OTIxMTU0MjE5WjBxMQswCQYDVQQGEwJQTDEfMB0GA1UEChMWVFAgSW50ZXJuZXQgU3AuIHogby5v -LjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2FjamkgU2lnbmV0MRswGQYDVQQDExJDQyBTaWdu -ZXQgLSBSb290Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrr2vydnNpELfGW3Ks -ARiDhJvwDtUe4AbWev+OfMc3+vA29nX8ZmIwno3gmItjo5DbUCCRiCMq5c9epcGu+kg4a3BJChVX -REl8gVh0ST15rr3RKrSc4VgsvQzl0ZUraeQLl8JoRT5PLsUj3qwF78jUCQVckiiLVcnGfZtFCm+D -CJXliQBDMB9XFAUEiO/DtEBs0B7wJGx7lgJeJpQUcGiaOPjcJDYOk7rNAYmmD2gWeSlepufO8luU -YG/YDxTC4mqhRqfa4MnVO5dqy+ICj2UvUpHbZDB0KfGRibgBYeQP1kuqgIzJN4UqknVAJb0aMBSP -l+9k2fAUdchx1njlbdcbAgMBAAGjggFtMIIBaTAPBgNVHRMBAf8EBTADAQH/MIIBBAYDVR0gBIH8 -MIH5MIH2Bg0rBgEEAb4/AgEKAQEAMIHkMIGaBggrBgEFBQcCAjCBjRqBikNlcnR5ZmlrYXQgd3lz -dGF3aW9ueSB6Z29kbmllIHogZG9rdW1lbnRlbTogIlBvbGl0eWthIENlcnR5ZmlrYWNqaSBkbGEg -Um9vdENBIi4gQ2VydHlmaWthdCB3eXN0YXdpb255IHByemV6IFJvb3RDQSB3IGhpZXJhcmNoaWkg -Q0MgU2lnbmV0LjBFBggrBgEFBQcCARY5aHR0cDovL3d3dy5zaWduZXQucGwvcmVwb3p5dG9yaXVt -L2Rva3VtZW50eS9wY19yb290Y2EudHh0MB0GA1UdDgQWBBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAf -BgNVHSMEGDAWgBTAm8UjDQLhpk5Iax8A6eOaFBuxrzAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcN -AQEFBQADggEBAGnY5QmYqnnO9OqFOWZxxb25UHRnaRF6IV9aaGit5BZufZj2Tq3v8L3SgE34GOoI -cdRMMG5JEpEU4mN/Ef3oY6Eo+7HfqaPHI4KFmbDSPiK5s+wmf+bQSm0Yq5/h4ZOdcAESlLQeLSt1 -CQk2JoKQJ6pyAf6xJBgWEIlm4RXE4J3324PUiOp83kW6MDvaa1xY976WyInr4rwoLgxVl11LZeKW -ha0RJJxJgw/NyWpKG7LWCm1fglF8JH51vZNndGYq1iKtfnrIOvLZq6bzaCiZm1EurD8HE6P7pmAB -KK6o3C2OXlNfNIgwkDN/cDqk5TYsTkrpfriJPdxXBH8hQOkW89g= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID/TCCA2agAwIBAgIEP4/gkTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJQTDEfMB0GA1UE -ChMWVFAgSW50ZXJuZXQgU3AuIHogby5vLjEkMCIGA1UECxMbQ2VudHJ1bSBDZXJ0eWZpa2Fjamkg -U2lnbmV0MR8wHQYDVQQDExZDQyBTaWduZXQgLSBDQSBLbGFzYSAxMB4XDTAzMTAxNzEyMjkwMloX -DTExMDkyMzExMTgxN1owdjELMAkGA1UEBhMCUEwxHzAdBgNVBAoTFlRQIEludGVybmV0IFNwLiB6 -IG8uby4xJDAiBgNVBAsTG0NlbnRydW0gQ2VydHlmaWthY2ppIFNpZ25ldDEgMB4GA1UEAxMXQ0Mg -U2lnbmV0IC0gVFNBIEtsYXNhIDEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOJYrISEtSsd -uHajROh5/n7NGrkpYTT9NEaPe9+ucuQ37KxIbfJwXJjgUc1dw4wCkcQ12FJarD1X6mSQ4cfN/60v -LfKI5ZD4nhJTMKlAj1pX9ScQ/MuyvKStCbn5WTkjPhjRAM0tdwXSnzuTEunfw0Oup559y3Iqxg1c -ExflB6cfAgMBAAGjggGXMIIBkzBBBgNVHR8EOjA4MDagNKAyhjBodHRwOi8vd3d3LnNpZ25ldC5w -bC9yZXBvenl0b3JpdW0vY3JsL2tsYXNhMS5jcmwwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQM -MAoGCCsGAQUFBwMIMIHaBgNVHSAEgdIwgc8wgcwGDSsGAQQBvj8CZAoRAgEwgbowbwYIKwYBBQUH -AgIwYxphQ2VydHlmaWthdCB3eXN0YXdpb255IHpnb2RuaWUgeiBkb2t1bWVudGVtICJQb2xpdHlr -YSBDZXJ0eWZpa2FjamkgQ0MgU2lnbmV0IC0gWm5ha293YW5pZSBjemFzZW0iLjBHBggrBgEFBQcC -ARY7aHR0cDovL3d3dy5zaWduZXQucGwvcmVwb3p5dG9yaXVtL2Rva3VtZW50eS9wY190c2ExXzJf -MS5wZGYwHwYDVR0jBBgwFoAUw4Me1Vl3VPtN+1dH+cQjXNHnieMwHQYDVR0OBBYEFJdDwEqtcavO -Yd9u9tej53vWXwNBMAkGA1UdEwQCMAAwDQYJKoZIhvcNAQEFBQADgYEAnpiQkqLCJQYXUrqMHUEz -+z3rOqS0XzSFnVVLhkVssvXc8S3FkJIiQTUrkScjI4CToCzujj3EyfNxH6yiLlMbskF8I31JxIeB -vueqV+s+o76CZm3ycu9hb0I4lswuxoT+q5ZzPR8Irrb51rZXlolR+7KtwMg4sFDJZ8RNgOf7tbA= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEvTCCA6WgAwIBAgIBADANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJFVTEn -MCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQL -ExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEiMCAGA1UEAxMZQ2hhbWJlcnMg -b2YgQ29tbWVyY2UgUm9vdDAeFw0wMzA5MzAxNjEzNDNaFw0zNzA5MzAxNjEzNDRa -MH8xCzAJBgNVBAYTAkVVMScwJQYDVQQKEx5BQyBDYW1lcmZpcm1hIFNBIENJRiBB -ODI3NDMyODcxIzAhBgNVBAsTGmh0dHA6Ly93d3cuY2hhbWJlcnNpZ24ub3JnMSIw -IAYDVQQDExlDaGFtYmVycyBvZiBDb21tZXJjZSBSb290MIIBIDANBgkqhkiG9w0B -AQEFAAOCAQ0AMIIBCAKCAQEAtzZV5aVdGDDg2olUkfzIx1L4L1DZ77F1c2VHfRtb -unXF/KGIJPov7coISjlUxFF6tdpg6jg8gbLL8bvZkSM/SAFwdakFKq0fcfPJVD0d -BmpAPrMMhe5cG3nCYsS4No41XQEMIwRHNaqbYE6gZj3LJgqcQKH0XZi/caulAGgq -7YN6D6IUtdQis4CwPAxaUWktWBiP7Zme8a7ileb2R6jWDA+wWFjbw2Y3npuRVDM3 -0pQcakjJyfKl2qUMI/cjDpwyVV5xnIQFUZot/eZOKjRa3spAN2cMVCFVd9oKDMyX -roDclDZK9D7ONhMeU+SsTjoF7Nuucpw4i9A5O4kKPnf+dQIBA6OCAUQwggFAMBIG -A1UdEwEB/wQIMAYBAf8CAQwwPAYDVR0fBDUwMzAxoC+gLYYraHR0cDovL2NybC5j -aGFtYmVyc2lnbi5vcmcvY2hhbWJlcnNyb290LmNybDAdBgNVHQ4EFgQU45T1sU3p -26EpW1eLTXYGduHRooowDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIA -BzAnBgNVHREEIDAegRxjaGFtYmVyc3Jvb3RAY2hhbWJlcnNpZ24ub3JnMCcGA1Ud -EgQgMB6BHGNoYW1iZXJzcm9vdEBjaGFtYmVyc2lnbi5vcmcwWAYDVR0gBFEwTzBN -BgsrBgEEAYGHLgoDATA+MDwGCCsGAQUFBwIBFjBodHRwOi8vY3BzLmNoYW1iZXJz -aWduLm9yZy9jcHMvY2hhbWJlcnNyb290Lmh0bWwwDQYJKoZIhvcNAQEFBQADggEB -AAxBl8IahsAifJ/7kPMa0QOx7xP5IV8EnNrJpY0nbJaHkb5BkAFyk+cefV/2icZd -p0AJPaxJRUXcLo0waLIJuvvDL8y6C98/d3tGfToSJI6WjzwFCm/SlCgdbQzALogi -1djPHRPH8EjX1wWnz8dHnjs8NMiAT9QUu/wNUPf6s+xCX6ndbcj0dc97wXImsQEc -XCz9ek60AcUFV7nnPKoF2YjpB0ZBzu9Bga5Y34OirsrXdx/nADydb47kMgkdTXg0 -eDQ8lJsm7U9xxhl6vSAiSFr+S30Dt+dYvsYyTnQeaN2oaFuzPu5ifdmA6Ap1erfu -tGWaIZDgqtCYvDi1czyL+Nw= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIExTCCA62gAwIBAgIBADANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJFVTEn -MCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQL -ExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEgMB4GA1UEAxMXR2xvYmFsIENo -YW1iZXJzaWduIFJvb3QwHhcNMDMwOTMwMTYxNDE4WhcNMzcwOTMwMTYxNDE4WjB9 -MQswCQYDVQQGEwJFVTEnMCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgy -NzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEgMB4G -A1UEAxMXR2xvYmFsIENoYW1iZXJzaWduIFJvb3QwggEgMA0GCSqGSIb3DQEBAQUA -A4IBDQAwggEIAoIBAQCicKLQn0KuWxfH2H3PFIP8T8mhtxOviteePgQKkotgVvq0 -Mi+ITaFgCPS3CU6gSS9J1tPfnZdan5QEcOw/Wdm3zGaLmFIoCQLfxS+EjXqXd7/s -QJ0lcqu1PzKY+7e3/HKE5TWH+VX6ox8Oby4o3Wmg2UIQxvi1RMLQQ3/bvOSiPGpV -eAp3qdjqGTK3L/5cPxvusZjsyq16aUXjlg9V9ubtdepl6DJWk0aJqCWKZQbua795 -B9Dxt6/tLE2Su8CoX6dnfQTyFQhwrJLWfQTSM/tMtgsL+xrJxI0DqX5c8lCrEqWh -z0hQpe/SyBoT+rB/sYIcd2oPX9wLlY/vQ37mRQklAgEDo4IBUDCCAUwwEgYDVR0T -AQH/BAgwBgEB/wIBDDA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3JsLmNoYW1i -ZXJzaWduLm9yZy9jaGFtYmVyc2lnbnJvb3QuY3JsMB0GA1UdDgQWBBRDnDafsJ4w -TcbOX60Qq+UDpfqpFDAOBgNVHQ8BAf8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgAH -MCoGA1UdEQQjMCGBH2NoYW1iZXJzaWducm9vdEBjaGFtYmVyc2lnbi5vcmcwKgYD -VR0SBCMwIYEfY2hhbWJlcnNpZ25yb290QGNoYW1iZXJzaWduLm9yZzBbBgNVHSAE -VDBSMFAGCysGAQQBgYcuCgEBMEEwPwYIKwYBBQUHAgEWM2h0dHA6Ly9jcHMuY2hh -bWJlcnNpZ24ub3JnL2Nwcy9jaGFtYmVyc2lnbnJvb3QuaHRtbDANBgkqhkiG9w0B -AQUFAAOCAQEAPDtwkfkEVCeR4e3t/mh/YV3lQWVPMvEYBZRqHN4fcNs+ezICNLUM -bKGKfKX0j//U2K0X1S0E0T9YgOKBWYi+wONGkyT+kL0mojAt6JcmVzWJdJYY9hXi -ryQZVgICsroPFOrGimbBhkVVi76SvpykBMdJPJ7oKXqJ1/6v/2j1pReQvayZzKWG -VwlnRtvWFsJG8eSpUPWP0ZIV018+xgBJOm5YstHRJw0lyDL4IBHNfTIzSJRUTN3c -ecQwn+uOuFW114hcxWokPbLTBQNRxgfvzBRydD1ucs4YKIxKoHflCStFREest2d/ -AYoFWpO+ocH/+OcOZ6RHSXZddZAa9SaP8A== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAw -PTELMAkGA1UEBhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFz -cyAyIFByaW1hcnkgQ0EwHhcNOTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9 -MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2VydHBsdXMxGzAZBgNVBAMTEkNsYXNz -IDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANxQ -ltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR5aiR -VhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyL -kcAbmXuZVg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCd -EgETjdyAYveVqUSISnFOYFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yas -H7WLO7dDWWuwJKZtkIvEcupdM5i3y95ee++U8Rs+yskhwcWYAqqi9lt3m/V+llU0 -HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRMECDAGAQH/AgEKMAsGA1Ud -DwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJYIZIAYb4 -QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMu -Y29tL0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/ -AN9WM2K191EBkOvDP9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8 -yfFC82x/xXp8HVGIutIKPidd3i1RTtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMR -FcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+7UCmnYR0ObncHoUW2ikbhiMA -ybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW//1IMwrh3KWB -kJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7 -l7+ijrRU ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB -gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G -A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV -BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw -MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl -YXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01P -RE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0 -aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3 -UcEbVASY06m/weaKXTuH+7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI -2GqGd0S7WWaXUF601CxwRM/aN5VCaTwwxHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8 -Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV4EajcNxo2f8ESIl33rXp -+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA1KGzqSX+ -DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5O -nKVIrLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW -/zAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6g -PKA6hjhodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9u -QXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAPpiem/Yb6dc5t3iuHXIY -SdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CPOGEIqB6BCsAv -IC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/ -RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4 -zJVSk/BwJVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd -BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB -ZQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv -b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG -EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl -cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c -JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP -mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+ -wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4 -VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/ -AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB -AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW -BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun -pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC -dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf -fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm -NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx -H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe -+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD -QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT -MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j -b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB -CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 -nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt -43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P -T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4 -gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO -BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR -TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw -DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr -hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg -06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF -PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls -YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk -CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j -ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL -MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3 -LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug -RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm -+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW -PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM -xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB -Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3 -hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg -EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF -MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA -FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec -nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z -eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF -hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2 -Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe -vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep -+OkuE6N36B9K ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIECTCCAvGgAwIBAgIQDV6ZCtadt3js2AdWO4YV2TANBgkqhkiG9w0BAQUFADBb -MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3Qx -ETAPBgNVBAsTCERTVCBBQ0VTMRcwFQYDVQQDEw5EU1QgQUNFUyBDQSBYNjAeFw0w -MzExMjAyMTE5NThaFw0xNzExMjAyMTE5NThaMFsxCzAJBgNVBAYTAlVTMSAwHgYD -VQQKExdEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdDERMA8GA1UECxMIRFNUIEFDRVMx -FzAVBgNVBAMTDkRTVCBBQ0VTIENBIFg2MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEAuT31LMmU3HWKlV1j6IR3dma5WZFcRt2SPp/5DgO0PWGSvSMmtWPu -ktKe1jzIDZBfZIGxqAgNTNj50wUoUrQBJcWVHAx+PhCEdc/BGZFjz+iokYi5Q1K7 -gLFViYsx+tC3dr5BPTCapCIlF3PoHuLTrCq9Wzgh1SpL11V94zpVvddtawJXa+ZH -fAjIgrrep4c9oW24MFbCswKBXy314powGCi4ZtPLAZZv6opFVdbgnf9nKxcCpk4a -ahELfrd755jWjHZvwTvbUJN+5dCOHze4vbrGn2zpfDPyMjwmR/onJALJfh1biEIT -ajV8fTXpLmaRcpPVMibEdPVTo7NdmvYJywIDAQABo4HIMIHFMA8GA1UdEwEB/wQF -MAMBAf8wDgYDVR0PAQH/BAQDAgHGMB8GA1UdEQQYMBaBFHBraS1vcHNAdHJ1c3Rk -c3QuY29tMGIGA1UdIARbMFkwVwYKYIZIAWUDAgEBATBJMEcGCCsGAQUFBwIBFjto -dHRwOi8vd3d3LnRydXN0ZHN0LmNvbS9jZXJ0aWZpY2F0ZXMvcG9saWN5L0FDRVMt -aW5kZXguaHRtbDAdBgNVHQ4EFgQUCXIGThhDD+XWzMNqizF7eI+og7gwDQYJKoZI -hvcNAQEFBQADggEBAKPYjtay284F5zLNAdMEA+V25FYrnJmQ6AgwbN99Pe7lv7Uk -QIRJ4dEorsTCOlMwiPH1d25Ryvr/ma8kXxug/fKshMrfqfBfBC6tFr8hlxCBPeP/ -h40y3JTlR4peahPJlJU90u7INJXQgNStMgiAVDzgvVJT11J8smk/f3rPanTK+gQq -nExaBqXpIK1FZg9p8d2/6eMyi/rgwYZNcjwu2JN4Cir42NInPRmJX1p7ijvMDNpR -rscL9yuwNwXsvFcj4jjSm2jzVhKIT0J8uDHEtdvkyCE06UgRNe76x5JXxZ805Mf2 -9w4LTJxoeHtxMcfrHuBnQfO3oKfN5XozNmr6mis= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/ -MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT -DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow -PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD -Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O -rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq -OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b -xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw -7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD -aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV -HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG -SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69 -ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr -AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz -R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5 -JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo -Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC -VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0 -Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW -KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl -cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw -NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw -NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy -ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV -BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo -Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4 -4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9 -KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI -rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi -94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB -sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi -gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo -kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE -vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA -A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t -O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua -AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP -9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/ -eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m -0vdXcDazv/wor3ElhVsT/h5/WrQ8 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEVzCCAz+gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBnTELMAkGA1UEBhMCRVMx -IjAgBgNVBAcTGUMvIE11bnRhbmVyIDI0NCBCYXJjZWxvbmExQjBABgNVBAMTOUF1 -dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 -MjYzNDA2ODEmMCQGCSqGSIb3DQEJARYXY2FAZmlybWFwcm9mZXNpb25hbC5jb20w -HhcNMDExMDI0MjIwMDAwWhcNMTMxMDI0MjIwMDAwWjCBnTELMAkGA1UEBhMCRVMx -IjAgBgNVBAcTGUMvIE11bnRhbmVyIDI0NCBCYXJjZWxvbmExQjBABgNVBAMTOUF1 -dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 -MjYzNDA2ODEmMCQGCSqGSIb3DQEJARYXY2FAZmlybWFwcm9mZXNpb25hbC5jb20w -ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDnIwNvbyOlXnjOlSztlB5u -Cp4Bx+ow0Syd3Tfom5h5VtP8c9/Qit5Vj1H5WuretXDE7aTt/6MNbg9kUDGvASdY -rv5sp0ovFy3Tc9UTHI9ZpTQsHVQERc1ouKDAA6XPhUJHlShbz++AbOCQl4oBPB3z -hxAwJkh91/zpnZFx/0GaqUC1N5wpIE8fUuOgfRNtVLcK3ulqTgesrBlf3H5idPay -BQC6haD9HThuy1q7hryUZzM1gywfI834yJFxzJeL764P3CkDG8A563DtwW4O2GcL -iam8NeTvtjS0pbbELaW+0MOUJEjb35bTALVmGotmBQ/dPz/LP6pemkr4tErvlTcb -AgMBAAGjgZ8wgZwwKgYDVR0RBCMwIYYfaHR0cDovL3d3dy5maXJtYXByb2Zlc2lv -bmFsLmNvbTASBgNVHRMBAf8ECDAGAQH/AgEBMCsGA1UdEAQkMCKADzIwMDExMDI0 -MjIwMDAwWoEPMjAxMzEwMjQyMjAwMDBaMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4E -FgQUMwugZtHq2s7eYpMEKFK1FH84aLcwDQYJKoZIhvcNAQEFBQADggEBAEdz/o0n -VPD11HecJ3lXV7cVVuzH2Fi3AQL0M+2TUIiefEaxvT8Ub/GzR0iLjJcG1+p+o1wq -u00vR+L4OQbJnC4xGgN49Lw4xiKLMzHwFgQEffl25EvXwOaD7FnMP97/T2u3Z36m -hoEyIwOdyPdfwUpgpZKpsaSgYMN4h7Mi8yrrW6ntBas3D7Hi05V2Y1Z0jFhyGzfl -ZKG+TQyTmAyX9odtsz/ny4Cm7YjHX1BiAuiZdBbQ5rQ58SfLyEDW44YQqSMSkuBp -QWOnryULwMWSyx6Yo1q6xTMPoJcB3X/ge9YGVM+h4k0460tQtcsm9MracEpqoeJ5 -quGnM/b9Sh/22WA= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDZjCCAk6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBEMQswCQYDVQQGEwJVUzEW -MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFs -IENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMTkwMzA0MDUwMDAwWjBEMQswCQYDVQQG -EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3Qg -R2xvYmFsIENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDvPE1A -PRDfO1MA4Wf+lGAVPoWI8YkNkMgoI5kF6CsgncbzYEbYwbLVjDHZ3CB5JIG/NTL8 -Y2nbsSpr7iFY8gjpeMtvy/wWUsiRxP89c96xPqfCfWbB9X5SJBri1WeR0IIQ13hL -TytCOb1kLUCgsBDTOEhGiKEMuzozKmKY+wCdE1l/bztyqu6mD4b5BWHqZ38MN5aL -5mkWRxHCJ1kDs6ZgwiFAVvqgx306E+PsV8ez1q6diYD3Aecs9pYrEw15LNnA5IZ7 -S4wMcoKK+xfNAGw6EzywhIdLFnopsk/bHdQL82Y3vdj2V7teJHq4PIu5+pIaGoSe -2HSPqht/XvT+RSIhAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE -FHE4NvICMVNHK266ZUapEBVYIAUJMB8GA1UdIwQYMBaAFHE4NvICMVNHK266ZUap -EBVYIAUJMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAQEAA/e1K6td -EPx7srJerJsOflN4WT5CBP51o62sgU7XAotexC3IUnbHLB/8gTKY0UvGkpMzNTEv -/NgdRN3ggX+d6YvhZJFiCzkIjKx0nVnZellSlxG5FntvRdOW2TF9AjYPnDtuzywN -A0ZF66D0f0hExghAzN4bcLUprbqLOzRldRtxIR0sFAqwlpW41uryZfspuk/qkZN0 -abby/+Ea0AzRdoXLiiW9l14sbxWZJue2Kf8i7MkCx1YAzUm5s2x7UwQa4qjJqhIF -I8LO57sEAszAR6LkxCkvW0VXiVHuPOtSCP8HNR6fNWpHSlaY0VqFH4z1Ir+rzoPz -4iIprn2DQKi6bA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY -MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo -R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx -MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK -Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp -ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC -AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9 -AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA -ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0 -7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W -kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI -mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G -A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ -KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1 -6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl -4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K -oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj -UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU -AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW -MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVy -c2FsIENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYD -VQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1 -c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC -AQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0DE81 -WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUG -FF+3Qs17j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdq -XbboW0W63MOhBW9Wjo8QJqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxL -se4YuU6W3Nx2/zu+z18DwPw76L5GG//aQMJS9/7jOvdqdzXQ2o3rXhhqMcceujwb -KNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2WP0+GfPtDCapkzj4T8Fd -IgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP20gaXT73 -y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRt -hAAnZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgoc -QIgfksILAAX/8sgCSqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4 -Lt1ZrtmhN79UNdxzMk+MBB4zsslG8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNV -HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAfBgNV -HSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8EBAMCAYYwDQYJ -KoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z -dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQ -L1EuxBRa3ugZ4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgr -Fg5fNuH8KrUwJM/gYwx7WBr+mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSo -ag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpqA1Ihn0CoZ1Dy81of398j9tx4TuaY -T1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz -GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m -1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV -OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH -6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX -QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW -MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy -c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE -BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0 -IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV -VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8 -cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT -QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh -F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v -c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w -mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd -VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX -teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ -f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfRe -Bi9Fi1jUIxaS5BZuKGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+ -nhutxx9z3SxPGWX9f5NAEC7S8O08ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB -/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY -MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG -9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc -aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX -IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn -ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z -uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN -Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja -QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW -koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9 -ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt -DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm -bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G -A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp -Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1 -MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG -A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL -v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8 -eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq -tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd -C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa -zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB -mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH -V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n -bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG -3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs -J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO -291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS -ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd -AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 -TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh -MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE -YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3 -MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo -ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg -MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN -ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA -PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w -wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi -EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY -avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+ -YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE -sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h -/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5 -IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD -ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy -OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P -TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ -HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER -dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf -ReYNnyicsbkqWletNw+vHX/bvZ8= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFSzCCBLSgAwIBAgIBaTANBgkqhkiG9w0BAQQFADCBmTELMAkGA1UEBhMCSFUx -ETAPBgNVBAcTCEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0 -b25zYWdpIEtmdC4xGjAYBgNVBAsTEVRhbnVzaXR2YW55a2lhZG9rMTIwMAYDVQQD -EylOZXRMb2NrIFV6bGV0aSAoQ2xhc3MgQikgVGFudXNpdHZhbnlraWFkbzAeFw05 -OTAyMjUxNDEwMjJaFw0xOTAyMjAxNDEwMjJaMIGZMQswCQYDVQQGEwJIVTERMA8G -A1UEBxMIQnVkYXBlc3QxJzAlBgNVBAoTHk5ldExvY2sgSGFsb3phdGJpenRvbnNh -Z2kgS2Z0LjEaMBgGA1UECxMRVGFudXNpdHZhbnlraWFkb2sxMjAwBgNVBAMTKU5l -dExvY2sgVXpsZXRpIChDbGFzcyBCKSBUYW51c2l0dmFueWtpYWRvMIGfMA0GCSqG -SIb3DQEBAQUAA4GNADCBiQKBgQCx6gTsIKAjwo84YM/HRrPVG/77uZmeBNwcf4xK -gZjupNTKihe5In+DCnVMm8Bp2GQ5o+2So/1bXHQawEfKOml2mrriRBf8TKPV/riX -iK+IA4kfpPIEPsgHC+b5sy96YhQJRhTKZPWLgLViqNhr1nGTLbO/CVRY7QbrqHvc -Q7GhaQIDAQABo4ICnzCCApswEgYDVR0TAQH/BAgwBgEB/wIBBDAOBgNVHQ8BAf8E -BAMCAAYwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1G -SUdZRUxFTSEgRXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFu -b3MgU3pvbGdhbHRhdGFzaSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBh -bGFwamFuIGtlc3p1bHQuIEEgaGl0ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExv -Y2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2VnLWJpenRvc2l0YXNhIHZlZGkuIEEgZGln -aXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUgYXogZWxvaXJ0 -IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFzIGxlaXJh -c2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGph -biBhIGh0dHBzOi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJo -ZXRvIGF6IGVsbGVub3J6ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBP -UlRBTlQhIFRoZSBpc3N1YW5jZSBhbmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmlj -YXRlIGlzIHN1YmplY3QgdG8gdGhlIE5ldExvY2sgQ1BTIGF2YWlsYWJsZSBhdCBo -dHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBjcHNA -bmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUAA4GBAATbrowXr/gOkDFOzT4JwG06 -sPgzTEdM43WIEJessDgVkcYplswhwG08pXTP2IKlOcNl40JwuyKQ433bNXbhoLXa -n3BukxowOR0w2y7jfLKRstE3Kfq51hdcR0/jHTjrn9V7lagonhVK0dHQKwCXoOKS -NitjrFgBazMpUIaD8QFI ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFTzCCBLigAwIBAgIBaDANBgkqhkiG9w0BAQQFADCBmzELMAkGA1UEBhMCSFUx -ETAPBgNVBAcTCEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0 -b25zYWdpIEtmdC4xGjAYBgNVBAsTEVRhbnVzaXR2YW55a2lhZG9rMTQwMgYDVQQD -EytOZXRMb2NrIEV4cHJlc3N6IChDbGFzcyBDKSBUYW51c2l0dmFueWtpYWRvMB4X -DTk5MDIyNTE0MDgxMVoXDTE5MDIyMDE0MDgxMVowgZsxCzAJBgNVBAYTAkhVMREw -DwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6dG9u -c2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE0MDIGA1UEAxMr -TmV0TG9jayBFeHByZXNzeiAoQ2xhc3MgQykgVGFudXNpdHZhbnlraWFkbzCBnzAN -BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA6+ywbGGKIyWvYCDj2Z/8kwvbXY2wobNA -OoLO/XXgeDIDhlqGlZHtU/qdQPzm6N3ZW3oDvV3zOwzDUXmbrVWg6dADEK8KuhRC -2VImESLH0iDMgqSaqf64gXadarfSNnU+sYYJ9m5tfk63euyucYT2BDMIJTLrdKwW -RMbkQJMdf60CAwEAAaOCAp8wggKbMBIGA1UdEwEB/wQIMAYBAf8CAQQwDgYDVR0P -AQH/BAQDAgAGMBEGCWCGSAGG+EIBAQQEAwIABzCCAmAGCWCGSAGG+EIBDQSCAlEW -ggJNRklHWUVMRU0hIEV6ZW4gdGFudXNpdHZhbnkgYSBOZXRMb2NrIEtmdC4gQWx0 -YWxhbm9zIFN6b2xnYWx0YXRhc2kgRmVsdGV0ZWxlaWJlbiBsZWlydCBlbGphcmFz -b2sgYWxhcGphbiBrZXN6dWx0LiBBIGhpdGVsZXNpdGVzIGZvbHlhbWF0YXQgYSBO -ZXRMb2NrIEtmdC4gdGVybWVrZmVsZWxvc3NlZy1iaXp0b3NpdGFzYSB2ZWRpLiBB -IGRpZ2l0YWxpcyBhbGFpcmFzIGVsZm9nYWRhc2FuYWsgZmVsdGV0ZWxlIGF6IGVs -b2lydCBlbGxlbm9yemVzaSBlbGphcmFzIG1lZ3RldGVsZS4gQXogZWxqYXJhcyBs -ZWlyYXNhIG1lZ3RhbGFsaGF0byBhIE5ldExvY2sgS2Z0LiBJbnRlcm5ldCBob25s -YXBqYW4gYSBodHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIGNpbWVuIHZhZ3kg -a2VyaGV0byBheiBlbGxlbm9yemVzQG5ldGxvY2submV0IGUtbWFpbCBjaW1lbi4g -SU1QT1JUQU5UISBUaGUgaXNzdWFuY2UgYW5kIHRoZSB1c2Ugb2YgdGhpcyBjZXJ0 -aWZpY2F0ZSBpcyBzdWJqZWN0IHRvIHRoZSBOZXRMb2NrIENQUyBhdmFpbGFibGUg -YXQgaHR0cHM6Ly93d3cubmV0bG9jay5uZXQvZG9jcyBvciBieSBlLW1haWwgYXQg -Y3BzQG5ldGxvY2submV0LjANBgkqhkiG9w0BAQQFAAOBgQAQrX/XDDKACtiG8XmY -ta3UzbM2xJZIwVzNmtkFLp++UOv0JhQQLdRmF/iewSf98e3ke0ugbLWrmldwpu2g -pO0u9f38vf5NNwgMvOOWgyL1SRt/Syu0VMGAfJlOHdCM7tCs5ZL6dVb+ZKATj7i4 -Fp1hBWeAyNDYpQcCNJgEjTME1A== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIGfTCCBWWgAwIBAgICAQMwDQYJKoZIhvcNAQEEBQAwga8xCzAJBgNVBAYTAkhV -MRAwDgYDVQQIEwdIdW5nYXJ5MREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMe -TmV0TG9jayBIYWxvemF0Yml6dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0 -dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9jayBLb3pqZWd5em9pIChDbGFzcyBB -KSBUYW51c2l0dmFueWtpYWRvMB4XDTk5MDIyNDIzMTQ0N1oXDTE5MDIxOTIzMTQ0 -N1owga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQIEwdIdW5nYXJ5MREwDwYDVQQHEwhC -dWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6dG9uc2FnaSBLZnQu -MRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9jayBL -b3pqZWd5em9pIChDbGFzcyBBKSBUYW51c2l0dmFueWtpYWRvMIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvHSMD7tM9DceqQWC2ObhbHDqeLVu0ThEDaiD -zl3S1tWBxdRL51uUcCbbO51qTGL3cfNk1mE7PetzozfZz+qMkjvN9wfcZnSX9EUi -3fRc4L9t875lM+QVOr/bmJBVOMTtplVjC7B4BPTjbsE/jvxReB+SnoPC/tmwqcm8 -WgD/qaiYdPv2LD4VOQ22BFWoDpggQrOxJa1+mm9dU7GrDPzr4PN6s6iz/0b2Y6LY -Oph7tqyF/7AlT3Rj5xMHpQqPBffAZG9+pyeAlt7ULoZgx2srXnN7F+eRP2QM2Esi -NCubMvJIH5+hCoR64sKtlz2O1cH5VqNQ6ca0+pii7pXmKgOM3wIDAQABo4ICnzCC -ApswDgYDVR0PAQH/BAQDAgAGMBIGA1UdEwEB/wQIMAYBAf8CAQQwEQYJYIZIAYb4 -QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1GSUdZRUxFTSEgRXplbiB0 -YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pvbGdhbHRhdGFz -aSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQu -IEEgaGl0ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtm -ZWxlbG9zc2VnLWJpenRvc2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMg -ZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUgYXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVs -amFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFzIGxlaXJhc2EgbWVndGFsYWxoYXRv -IGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGphbiBhIGh0dHBzOi8vd3d3 -Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRvIGF6IGVsbGVub3J6 -ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRoZSBpc3N1 -YW5jZSBhbmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3Qg -dG8gdGhlIE5ldExvY2sgQ1BTIGF2YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRs -b2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBjcHNAbmV0bG9jay5uZXQuMA0G -CSqGSIb3DQEBBAUAA4IBAQBIJEb3ulZv+sgoA0BO5TE5ayZrU3/b39/zcT0mwBQO -xmd7I6gMc90Bu8bKbjc5VdXHjFYgDigKDtIqpLBJUsY4B/6+CgmM0ZjPytoUMaFP -0jn8DxEsQ8Pdq5PHVT5HfBgaANzze9jyf1JsIPQLX2lS9O74silg6+NJMSEN1rUQ -QeJBCWziGppWS3cC9qCbmieH6FUpccKQn0V4GuEVZD3QDtigdp+uxdAu6tYPVuxk -f1qbFFgBJ34TUMdrKuZoPL9coAob4Q566eKAw+np9v1sEZ7Q5SgnK1QyQhSCdeZK -8CtmdWOMovsEPoMOmzbwGOQmIMOM8CgHrTwXZoi1/baI ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIG0TCCBbmgAwIBAgIBezANBgkqhkiG9w0BAQUFADCByTELMAkGA1UEBhMCSFUx -ETAPBgNVBAcTCEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0 -b25zYWdpIEtmdC4xGjAYBgNVBAsTEVRhbnVzaXR2YW55a2lhZG9rMUIwQAYDVQQD -EzlOZXRMb2NrIE1pbm9zaXRldHQgS296amVneXpvaSAoQ2xhc3MgUUEpIFRhbnVz -aXR2YW55a2lhZG8xHjAcBgkqhkiG9w0BCQEWD2luZm9AbmV0bG9jay5odTAeFw0w -MzAzMzAwMTQ3MTFaFw0yMjEyMTUwMTQ3MTFaMIHJMQswCQYDVQQGEwJIVTERMA8G -A1UEBxMIQnVkYXBlc3QxJzAlBgNVBAoTHk5ldExvY2sgSGFsb3phdGJpenRvbnNh -Z2kgS2Z0LjEaMBgGA1UECxMRVGFudXNpdHZhbnlraWFkb2sxQjBABgNVBAMTOU5l -dExvY2sgTWlub3NpdGV0dCBLb3pqZWd5em9pIChDbGFzcyBRQSkgVGFudXNpdHZh -bnlraWFkbzEeMBwGCSqGSIb3DQEJARYPaW5mb0BuZXRsb2NrLmh1MIIBIjANBgkq -hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx1Ilstg91IRVCacbvWy5FPSKAtt2/Goq -eKvld/Bu4IwjZ9ulZJm53QE+b+8tmjwi8F3JV6BVQX/yQ15YglMxZc4e8ia6AFQe -r7C8HORSjKAyr7c3sVNnaHRnUPYtLmTeriZ539+Zhqurf4XsoPuAzPS4DB6TRWO5 -3Lhbm+1bOdRfYrCnjnxmOCyqsQhjF2d9zL2z8cM/z1A57dEZgxXbhxInlrfa6uWd -vLrqOU+L73Sa58XQ0uqGURzk/mQIKAR5BevKxXEOC++r6uwSEaEYBTJp0QwsGj0l -mT+1fMptsK6ZmfoIYOcZwvK9UdPM0wKswREMgM6r3JSda6M5UzrWhQIDAMV9o4IC -wDCCArwwEgYDVR0TAQH/BAgwBgEB/wIBBDAOBgNVHQ8BAf8EBAMCAQYwggJ1Bglg -hkgBhvhCAQ0EggJmFoICYkZJR1lFTEVNISBFemVuIHRhbnVzaXR2YW55IGEgTmV0 -TG9jayBLZnQuIE1pbm9zaXRldHQgU3pvbGdhbHRhdGFzaSBTemFiYWx5emF0YWJh -biBsZWlydCBlbGphcmFzb2sgYWxhcGphbiBrZXN6dWx0LiBBIG1pbm9zaXRldHQg -ZWxla3Ryb25pa3VzIGFsYWlyYXMgam9naGF0YXMgZXJ2ZW55ZXN1bGVzZW5laywg -dmFsYW1pbnQgZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUgYSBNaW5vc2l0ZXR0IFN6 -b2xnYWx0YXRhc2kgU3phYmFseXphdGJhbiwgYXogQWx0YWxhbm9zIFN6ZXJ6b2Rl -c2kgRmVsdGV0ZWxla2JlbiBlbG9pcnQgZWxsZW5vcnplc2kgZWxqYXJhcyBtZWd0 -ZXRlbGUuIEEgZG9rdW1lbnR1bW9rIG1lZ3RhbGFsaGF0b2sgYSBodHRwczovL3d3 -dy5uZXRsb2NrLmh1L2RvY3MvIGNpbWVuIHZhZ3kga2VyaGV0b2sgYXogaW5mb0Bu -ZXRsb2NrLm5ldCBlLW1haWwgY2ltZW4uIFdBUk5JTkchIFRoZSBpc3N1YW5jZSBh -bmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGFyZSBzdWJqZWN0IHRvIHRo -ZSBOZXRMb2NrIFF1YWxpZmllZCBDUFMgYXZhaWxhYmxlIGF0IGh0dHBzOi8vd3d3 -Lm5ldGxvY2suaHUvZG9jcy8gb3IgYnkgZS1tYWlsIGF0IGluZm9AbmV0bG9jay5u -ZXQwHQYDVR0OBBYEFAlqYhaSsFq7VQ7LdTI6MuWyIckoMA0GCSqGSIb3DQEBBQUA -A4IBAQCRalCc23iBmz+LQuM7/KbD7kPgz/PigDVJRXYC4uMvBcXxKufAQTPGtpvQ -MznNwNuhrWw3AkxYQTvyl5LGSKjN5Yo5iWH5Upfpvfb5lHTocQ68d4bDBsxafEp+ -NFAwLvt/MpqNPfMgW/hqyobzMUwsWYACff44yTB1HLdV47yfuqhthCgFdbOLDcCR -VCHnpgu0mfVRQdzNo0ci2ccBgcTcR08m6h/t280NmPSjnLRzMkqWmf68f8glWPhY -83ZmiVSkpj7EUFy6iRiCdUgh0k8T6GB+B3bbELVR5qq5aKrN9p2QdRLqOBrKROi3 -macqaJVmlaut74nLYKkGEsaUR+ko ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x -GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv -b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV -BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W -YWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCa -GMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6XJxg -Fyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55J -WpzmM+Yklvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bB -rrcCaoF6qUWD4gXmuVbBlDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp -+ARz8un+XJiM9XOva7R+zdRcAitMOeGylZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1 -ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt66/3FsvbzSUr5R/7mp/i -Ucw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1JdxnwQ5hYIiz -PtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og -/zOhD7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UH -oycR7hYQe7xFSkyyBNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuI -yV77zGHcizN300QyNQliBJIWENieJ0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1Ud -EwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBQahGK8SEwzJQTU7tD2 -A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGUa6FJpEcwRTEL -MAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT -ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2f -BluornFdLwUvZ+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzn -g/iN/Ae42l9NLmeyhP3ZRPx3UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2Bl -fF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodmVjB3pjd4M1IQWK4/YY7yarHvGH5K -WWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK+JDSV6IZUaUtl0Ha -B0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrWIozc -hLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPR -TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD -mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z -ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y -4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza -8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x -GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv -b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV -BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W -YWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM -V0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNggDhoB -4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUr -H556VOijKTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd -8lyyBTNvijbO0BNO/79KDDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9Cabwv -vWhDFlaJKjdhkf2mrk7AyxRllDdLkgbvBNDInIjbC3uBr7E9KsRlOni27tyAsdLT -mZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwpp5ijJUMv7/FfJuGITfhe -btfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8nT8KKdjc -T5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDt -WAEXMJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZ -c6tsgLjoC2SToJyMGf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A -4iLItLRkT9a6fUg+qGkM17uGcclzuD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYD -VR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHTBgkrBgEEAb5YAAMwgcUwgZMG -CCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmljYXRlIGNvbnN0 -aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0 -aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVu -dC4wLQYIKwYBBQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2Nw -czALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4G -A1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4ywLQoUmkRzBFMQswCQYDVQQGEwJC -TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UEAxMSUXVvVmFkaXMg -Um9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZVqyM0 -7ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSem -d1o417+shvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd -+LJ2w/w4E6oM3kJpK27zPOuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B -4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadN -t54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp8kokUvd0/bpO5qgdAm6x -DYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBCbjPsMZ57 -k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6s -zHXug/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0j -Wy10QJLZYxkNc91pvGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeT -mJlglFwjz1onl14LBQaTNx47aTbrqZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK -4SVhM7JZG+Ju1zdXtg2pEto= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBK -MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x -GTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkx -MjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3Qg -Q29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwgQ0EwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jxYDiJ -iQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa -/FHtaMbQbqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJ -jnIFHovdRIWCQtBJwB1g8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnI -HmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYVHDGA76oYa8J719rO+TMg1fW9ajMtgQT7 -sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi0XPnj3pDAgMBAAGjgZ0w -gZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQF -MAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCsw -KaAnoCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsG -AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L -URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO -H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm -I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY -iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc -f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI -MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x -FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz -MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv -cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz -Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO -0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao -wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj -7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS -8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT -BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB -/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg -JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGC -NxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt3 -6Z3q059c4EVlew3KW+JwULKUBRSuSceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/ -3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm -D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS -CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR -3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl -MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp -U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw -NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE -ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp -ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3 -DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf -8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN -+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0 -X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa -K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA -1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G -A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR -zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0 -YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD -bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w -DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3 -L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D -eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl -xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp -VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY -WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIHyTCCBbGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEW -MBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwg -Q2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0NjM2WhcNMzYwOTE3MTk0NjM2WjB9 -MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMi -U2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3Rh -cnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA -A4ICDwAwggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZk -pMyONvg45iPwbm2xPN1yo4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rf -OQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/C -Ji/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/deMotHweXMAEtcnn6RtYT -Kqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt2PZE4XNi -HzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMM -Av+Z6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w -+2OqqGwaVLRcJXrJosmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+ -Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3 -Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVcUjyJthkqcwEKDwOzEmDyei+B -26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT37uMdBNSSwID -AQABo4ICUjCCAk4wDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAa4wHQYDVR0OBBYE -FE4L7xqkQFulF2mHMMo0aEPQQa7yMGQGA1UdHwRdMFswLKAqoCiGJmh0dHA6Ly9j -ZXJ0LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMCugKaAnhiVodHRwOi8vY3Js -LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMIIBXQYDVR0gBIIBVDCCAVAwggFM -BgsrBgEEAYG1NwEBATCCATswLwYIKwYBBQUHAgEWI2h0dHA6Ly9jZXJ0LnN0YXJ0 -Y29tLm9yZy9wb2xpY3kucGRmMDUGCCsGAQUFBwIBFilodHRwOi8vY2VydC5zdGFy -dGNvbS5vcmcvaW50ZXJtZWRpYXRlLnBkZjCB0AYIKwYBBQUHAgIwgcMwJxYgU3Rh -cnQgQ29tbWVyY2lhbCAoU3RhcnRDb20pIEx0ZC4wAwIBARqBl0xpbWl0ZWQgTGlh -YmlsaXR5LCByZWFkIHRoZSBzZWN0aW9uICpMZWdhbCBMaW1pdGF0aW9ucyogb2Yg -dGhlIFN0YXJ0Q29tIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFBvbGljeSBhdmFp -bGFibGUgYXQgaHR0cDovL2NlcnQuc3RhcnRjb20ub3JnL3BvbGljeS5wZGYwEQYJ -YIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilTdGFydENvbSBGcmVlIFNT -TCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAgEAFmyZ -9GYMNPXQhV59CuzaEE44HF7fpiUFS5Eyweg78T3dRAlbB0mKKctmArexmvclmAk8 -jhvh3TaHK0u7aNM5Zj2gJsfyOZEdUauCe37Vzlrk4gNXcGmXCPleWKYK34wGmkUW -FjgKXlf2Ysd6AgXmvB618p70qSmD+LIU424oh0TDkBreOKk8rENNZEXO3SipXPJz -ewT4F+irsfMuXGRuczE6Eri8sxHkfY+BUZo7jYn0TZNmezwD7dOaHZrzZVD1oNB1 -ny+v8OqCQ5j4aZyJecRDjkZy42Q2Eq/3JR44iZB3fsNrarnDy0RLrHiQi+fHLB5L -EUTINFInzQpdn4XBidUaePKVEFMy3YCEZnXZtWgo+2EuvoSoOMCZEoalHmdkrQYu -L6lwhceWD3yJZfWOQ1QOq92lgDmUYMA0yZZwLKMS9R9Ie70cfmu3nZD0Ijuu+Pwq -yvqCUqDvr0tVk+vBtfAii6w0TiYiBKGHLHVKt+V9E9e4DGTANtLJL4YSjCMJwRuC -O3NJo2pXh5Tl1njFmUNj403gdy3hZZlyaQQaRwnmDwFWJPsfvw55qVguucQJAX6V -um0ABj6y6koQOdjQK/W/7HW/lwLFCRsI3FU34oH7N4RDYiDK51ZLZer+bMEkkySh -NOsF/5oirpt9P/FlUQqmMGqz9IgcgA38corog14= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFFjCCBH+gAwIBAgIBADANBgkqhkiG9w0BAQQFADCBsDELMAkGA1UEBhMCSUwx -DzANBgNVBAgTBklzcmFlbDEOMAwGA1UEBxMFRWlsYXQxFjAUBgNVBAoTDVN0YXJ0 -Q29tIEx0ZC4xGjAYBgNVBAsTEUNBIEF1dGhvcml0eSBEZXAuMSkwJwYDVQQDEyBG -cmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYS -YWRtaW5Ac3RhcnRjb20ub3JnMB4XDTA1MDMxNzE3Mzc0OFoXDTM1MDMxMDE3Mzc0 -OFowgbAxCzAJBgNVBAYTAklMMQ8wDQYDVQQIEwZJc3JhZWwxDjAMBgNVBAcTBUVp -bGF0MRYwFAYDVQQKEw1TdGFydENvbSBMdGQuMRowGAYDVQQLExFDQSBBdXRob3Jp -dHkgRGVwLjEpMCcGA1UEAxMgRnJlZSBTU0wgQ2VydGlmaWNhdGlvbiBBdXRob3Jp -dHkxITAfBgkqhkiG9w0BCQEWEmFkbWluQHN0YXJ0Y29tLm9yZzCBnzANBgkqhkiG -9w0BAQEFAAOBjQAwgYkCgYEA7YRgACOeyEpRKSfeOqE5tWmrCbIvNP1h3D3TsM+x -18LEwrHkllbEvqoUDufMOlDIOmKdw6OsWXuO7lUaHEe+o5c5s7XvIywI6Nivcy+5 -yYPo7QAPyHWlLzRMGOh2iCNJitu27Wjaw7ViKUylS7eYtAkUEKD4/mJ2IhULpNYI -LzUCAwEAAaOCAjwwggI4MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgHmMB0G -A1UdDgQWBBQcicOWzL3+MtUNjIExtpidjShkjTCB3QYDVR0jBIHVMIHSgBQcicOW -zL3+MtUNjIExtpidjShkjaGBtqSBszCBsDELMAkGA1UEBhMCSUwxDzANBgNVBAgT -BklzcmFlbDEOMAwGA1UEBxMFRWlsYXQxFjAUBgNVBAoTDVN0YXJ0Q29tIEx0ZC4x -GjAYBgNVBAsTEUNBIEF1dGhvcml0eSBEZXAuMSkwJwYDVQQDEyBGcmVlIFNTTCBD -ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSYWRtaW5Ac3Rh -cnRjb20ub3JnggEAMB0GA1UdEQQWMBSBEmFkbWluQHN0YXJ0Y29tLm9yZzAdBgNV -HRIEFjAUgRJhZG1pbkBzdGFydGNvbS5vcmcwEQYJYIZIAYb4QgEBBAQDAgAHMC8G -CWCGSAGG+EIBDQQiFiBGcmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAy -BglghkgBhvhCAQQEJRYjaHR0cDovL2NlcnQuc3RhcnRjb20ub3JnL2NhLWNybC5j -cmwwKAYJYIZIAYb4QgECBBsWGWh0dHA6Ly9jZXJ0LnN0YXJ0Y29tLm9yZy8wOQYJ -YIZIAYb4QgEIBCwWKmh0dHA6Ly9jZXJ0LnN0YXJ0Y29tLm9yZy9pbmRleC5waHA/ -YXBwPTExMTANBgkqhkiG9w0BAQQFAAOBgQBscSXhnjSRIe/bbL0BCFaPiNhBOlP1 -ct8nV0t2hPdopP7rPwl+KLhX6h/BquL/lp9JmeaylXOWxkjHXo0Hclb4g4+fd68p -00UOpO6wNnQt8M2YI3s3S9r+UZjEHjQ8iP2ZO1CnwYszx8JSFhKVU2Ui77qLzmLb -cCOxgN8aIDjnfg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIF2TCCA8GgAwIBAgIQXAuFXAvnWUHfV8w/f52oNjANBgkqhkiG9w0BAQUFADBk -MQswCQYDVQQGEwJjaDERMA8GA1UEChMIU3dpc3Njb20xJTAjBgNVBAsTHERpZ2l0 -YWwgQ2VydGlmaWNhdGUgU2VydmljZXMxGzAZBgNVBAMTElN3aXNzY29tIFJvb3Qg -Q0EgMTAeFw0wNTA4MTgxMjA2MjBaFw0yNTA4MTgyMjA2MjBaMGQxCzAJBgNVBAYT -AmNoMREwDwYDVQQKEwhTd2lzc2NvbTElMCMGA1UECxMcRGlnaXRhbCBDZXJ0aWZp -Y2F0ZSBTZXJ2aWNlczEbMBkGA1UEAxMSU3dpc3Njb20gUm9vdCBDQSAxMIICIjAN -BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0LmwqAzZuz8h+BvVM5OAFmUgdbI9 -m2BtRsiMMW8Xw/qabFbtPMWRV8PNq5ZJkCoZSx6jbVfd8StiKHVFXqrWW/oLJdih -FvkcxC7mlSpnzNApbjyFNDhhSbEAn9Y6cV9Nbc5fuankiX9qUvrKm/LcqfmdmUc/ -TilftKaNXXsLmREDA/7n29uj/x2lzZAeAR81sH8A25Bvxn570e56eqeqDFdvpG3F -EzuwpdntMhy0XmeLVNxzh+XTF3xmUHJd1BpYwdnP2IkCb6dJtDZd0KTeByy2dbco -kdaXvij1mB7qWybJvbCXc9qukSbraMH5ORXWZ0sKbU/Lz7DkQnGMU3nn7uHbHaBu -HYwadzVcFh4rUx80i9Fs/PJnB3r1re3WmquhsUvhzDdf/X/NTa64H5xD+SpYVUNF -vJbNcA78yeNmuk6NO4HLFWR7uZToXTNShXEuT46iBhFRyePLoW4xCGQMwtI89Tbo -19AOeCMgkckkKmUpWyL3Ic6DXqTz3kvTaI9GdVyDCW4pa8RwjPWd1yAv/0bSKzjC -L3UcPX7ape8eYIVpQtPM+GP+HkM5haa2Y0EQs3MevNP6yn0WR+Kn1dCjigoIlmJW -bjTb2QK5MHXjBNLnj8KwEUAKrNVxAmKLMb7dxiNYMUJDLXT5xp6mig/p/r+D5kNX -JLrvRjSq1xIBOO0CAwEAAaOBhjCBgzAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0hBBYw -FDASBgdghXQBUwABBgdghXQBUwABMBIGA1UdEwEB/wQIMAYBAf8CAQcwHwYDVR0j -BBgwFoAUAyUv3m+CATpcLNwroWm1Z9SM0/0wHQYDVR0OBBYEFAMlL95vggE6XCzc -K6FptWfUjNP9MA0GCSqGSIb3DQEBBQUAA4ICAQA1EMvspgQNDQ/NwNurqPKIlwzf -ky9NfEBWMXrrpA9gzXrzvsMnjgM+pN0S734edAY8PzHyHHuRMSG08NBsl9Tpl7Ik -Vh5WwzW9iAUPWxAaZOHHgjD5Mq2eUCzneAXQMbFamIp1TpBcahQq4FJHgmDmHtqB -sfsUC1rxn9KVuj7QG9YVHaO+htXbD8BJZLsuUBlL0iT43R4HVtA4oJVwIHaM190e -3p9xxCPvgxNcoyQVTSlAPGrEqdi3pkSlDfTgnXceQHAm/NrZNuR55LU/vJtlvrsR -ls/bxig5OgjOR1tTWsWZ/l2p3e9M1MalrQLmjAcSHm8D0W+go/MpvRLHUKKwf4ip -mXeascClOS5cfGniLLDqN2qk4Vrh9VDlg++luyqI54zb/W1elxmofmZ1a3Hqv7HH -b6D0jqTsNFFbjCYDcKF31QESVwA12yPeDooomf2xEG9L/zgtYE4snOtnta1J7ksf -rK/7DZBaZmBwXarNeNQk7shBoJMBkpxqnvy5JMWzFYJ+vq6VK+uxwNrjAWALXmms -hFZhvnEX/h0TD/7Gh0Xp/jKgGg0TpJRVcaUWi7rKibCyx/yP2FS1k2Kdzs9Z+z0Y -zirLNRWCXf9UIltxUvu3yf5gmwBBZPCqKuy2QkPOiWaByIufOVQDJdMWNY6E0F/6 -MBr1mmz0DlP5OlvRHA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -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 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFwTCCA6mgAwIBAgIITrIAZwwDXU8wDQYJKoZIhvcNAQEFBQAwSTELMAkGA1UE -BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEjMCEGA1UEAxMaU3dpc3NTaWdu -IFBsYXRpbnVtIENBIC0gRzIwHhcNMDYxMDI1MDgzNjAwWhcNMzYxMDI1MDgzNjAw -WjBJMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMSMwIQYDVQQD -ExpTd2lzc1NpZ24gUGxhdGludW0gQ0EgLSBHMjCCAiIwDQYJKoZIhvcNAQEBBQAD -ggIPADCCAgoCggIBAMrfogLi2vj8Bxax3mCq3pZcZB/HL37PZ/pEQtZ2Y5Wu669y -IIpFR4ZieIbWIDkm9K6j/SPnpZy1IiEZtzeTIsBQnIJ71NUERFzLtMKfkr4k2Htn -IuJpX+UFeNSH2XFwMyVTtIc7KZAoNppVRDBopIOXfw0enHb/FZ1glwCNioUD7IC+ -6ixuEFGSzH7VozPY1kneWCqv9hbrS3uQMpe5up1Y8fhXSQQeol0GcN1x2/ndi5ob -jM89o03Oy3z2u5yg+gnOI2Ky6Q0f4nIoj5+saCB9bzuohTEJfwvH6GXp43gOCWcw -izSC+13gzJ2BbWLuCB4ELE6b7P6pT1/9aXjvCR+htL/68++QHkwFix7qepF6w9fl -+zC8bBsQWJj3Gl/QKTIDE0ZNYWqFTFJ0LwYfexHihJfGmfNtf9dng34TaNhxKFrY -zt3oEBSa/m0jh26OWnA81Y0JAKeqvLAxN23IhBQeW71FYyBrS3SMvds6DsHPWhaP -pZjydomyExI7C3d3rLvlPClKknLKYRorXkzig3R3+jVIeoVNjZpTxN94ypeRSCtF -KwH3HBqi7Ri6Cr2D+m+8jVeTO9TUps4e8aCxzqv9KyiaTxvXw3LbpMS/XUz13XuW -ae5ogObnmLo2t/5u7Su9IPhlGdpVCX4l3P5hYnL5fhgC72O00Puv5TtjjGePAgMB -AAGjgawwgakwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O -BBYEFFCvzAeHFUdvOMW0ZdHelarp35zMMB8GA1UdIwQYMBaAFFCvzAeHFUdvOMW0 -ZdHelarp35zMMEYGA1UdIAQ/MD0wOwYJYIV0AVkBAQEBMC4wLAYIKwYBBQUHAgEW -IGh0dHA6Ly9yZXBvc2l0b3J5LnN3aXNzc2lnbi5jb20vMA0GCSqGSIb3DQEBBQUA -A4ICAQAIhab1Fgz8RBrBY+D5VUYI/HAcQiiWjrfFwUF1TglxeeVtlspLpYhg0DB0 -uMoI3LQwnkAHFmtllXcBrqS3NQuB2nEVqXQXOHtYyvkv+8Bldo1bAbl93oI9ZLi+ -FHSjClTTLJUYFzX1UWs/j6KWYTl4a0vlpqD4U99REJNi54Av4tHgvI42Rncz7Lj7 -jposiU0xEQ8mngS7twSNC/K5/FqdOxa3L8iYq/6KUFkuozv8KV2LwUvJ4ooTHbG/ -u0IdUt1O2BReEMYxB+9xJ/cbOQncguqLs5WGXv312l0xpuAxtpTmREl0xRbl9x8D -YSjFyMsSoEJL+WuICI20MhjzdZ/EfwBPBZWcoxcCw7NTm6ogOSkrZvqdr16zktK1 -puEa+S1BaYEUtLS17Yk9zvupnTVCRLEcFHOBzyoBNZox1S2PbYTfgE1X4z/FhHXa -icYwu+uPyyIIoK6q8QNsOktNCaUOcsZWayFCTiMlFGiudgp8DAdwZPmaL/YFOSbG -DI8Zf0NebvRbFS/bYV3mZy8/CJT5YLSYMdp08YSTcU1f+2BY0fvEwW2JorsgH51x -kcsymxM9Pn2SUjWskpSi0xjCfMfqr3YFFt1nJ8J+HAciIfNAChs0B0QTwoRqjt8Z -Wr9/6x3iGjjRXK9HkmuAtTClyY3YqzGBH9/CZjfTk6mFhnll0g== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -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 ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/ -MQswCQYDVQQGEwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5MB4XDTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1ow -PzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dvdmVybm1lbnQgUm9vdCBDZXJ0aWZp -Y2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB -AJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qNw8XR -IePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1q -gQdW8or5BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKy -yhwOeYHWtXBiCAEuTk8O1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAts -F/tnyMKtsc2AtJfcdgEWFelq16TheEfOhtX7MfP6Mb40qij7cEwdScevLJ1tZqa2 -jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wovJ5pGfaENda1UhhXcSTvx -ls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7Q3hub/FC -VGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHK -YS1tB6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoH -EgKXTiCQ8P8NHuJBO9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThN -Xo+EHWbNxWCWtFJaBYmOlXqYwZE8lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1Ud -DgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNVHRMEBTADAQH/MDkGBGcqBwAE -MTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg209yewDL7MTqK -UWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ -TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyf -qzvS/3WXy6TjZwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaK -ZEk9GhiHkASfQlK3T8v+R0F2Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFE -JPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlUD7gsL0u8qV1bYH+Mh6XgUmMqvtg7 -hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6QzDxARvBMB1uUO07+1 -EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+HbkZ6Mm -nD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WX -udpVBrkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz -ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe -LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl -pYYsfPQS ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB -qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf -Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw -MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV -BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw -NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j -LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG -A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl -IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs -W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta -3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGcq/gcfomk -6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6 -Sk/KaAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J -NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA -MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP -r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU -DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz -YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX -xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2 -/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/ -LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7 -jVaMaA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID+zCCAuOgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBtzE/MD0GA1UEAww2VMOc -UktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sx -c8SxMQswCQYDVQQGDAJUUjEPMA0GA1UEBwwGQU5LQVJBMVYwVAYDVQQKDE0oYykg -MjAwNSBUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8 -dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjAeFw0wNTA1MTMxMDI3MTdaFw0xNTAz -MjIxMDI3MTdaMIG3MT8wPQYDVQQDDDZUw5xSS1RSVVNUIEVsZWt0cm9uaWsgU2Vy -dGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLExCzAJBgNVBAYMAlRSMQ8wDQYD -VQQHDAZBTktBUkExVjBUBgNVBAoMTShjKSAyMDA1IFTDnFJLVFJVU1QgQmlsZ2kg -xLBsZXRpxZ9pbSB2ZSBCaWxpxZ9pbSBHw7x2ZW5sacSfaSBIaXptZXRsZXJpIEEu -xZ4uMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylIF1mMD2Bxf3dJ7 -XfIMYGFbazt0K3gNfUW9InTojAPBxhEqPZW8qZSwu5GXyGl8hMW0kWxsE2qkVa2k -heiVfrMArwDCBRj1cJ02i67L5BuBf5OI+2pVu32Fks66WJ/bMsW9Xe8iSi9BB35J -YbOG7E6mQW6EvAPs9TscyB/C7qju6hJKjRTP8wrgUDn5CDX4EVmt5yLqS8oUBt5C -urKZ8y1UiBAG6uEaPj1nH/vO+3yC6BFdSsG5FOpU2WabfIl9BJpiyelSPJ6c79L1 -JuTm5Rh8i27fbMx4W09ysstcP4wFjdFMjK2Sx+F4f2VsSQZQLJ4ywtdKxnWKWU51 -b0dewQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAV -9VX/N5aAWSGk/KEVTCD21F/aAyT8z5Aa9CEKmu46sWrv7/hg0Uw2ZkUd82YCdAR7 -kjCo3gp2D++Vbr3JN+YaDayJSFvMgzbC9UZcWYJWtNX+I7TYVBxEq8Sn5RTOPEFh -fEPmzcSBCYsk+1Ql1haolgxnB2+zUEfjHCQo3SqYpGH+2+oSN7wBGjSFvW5P55Fy -B0SFHljKVETd96y5y4khctuPwGkplyqjrhgjlxxBKot8KsF8kOipKMDTkcatKIdA -aLX/7KfS0zgYnNN9aV3wxqUeJBujR/xpB2jn5Jq07Q+hh4cCzofSSE7hvP/L8XKS -RGQDJereW26fyfJOrN3H ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEPDCCAySgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBvjE/MD0GA1UEAww2VMOc -UktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sx -c8SxMQswCQYDVQQGEwJUUjEPMA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xS -S1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kg -SGl6bWV0bGVyaSBBLsWeLiAoYykgS2FzxLFtIDIwMDUwHhcNMDUxMTA3MTAwNzU3 -WhcNMTUwOTE2MTAwNzU3WjCBvjE/MD0GA1UEAww2VMOcUktUUlVTVCBFbGVrdHJv -bmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJU -UjEPMA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSw -bGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWe -LiAoYykgS2FzxLFtIDIwMDUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB -AQCpNn7DkUNMwxmYCMjHWHtPFoylzkkBH3MOrHUTpvqeLCDe2JAOCtFp0if7qnef -J1Il4std2NiDUBd9irWCPwSOtNXwSadktx4uXyCcUHVPr+G1QRT0mJKIx+XlZEdh -R3n9wFHxwZnn3M5q+6+1ATDcRhzviuyV79z/rxAc653YsKpqhRgNF8k+v/Gb0AmJ -Qv2gQrSdiVFVKc8bcLyEVK3BEx+Y9C52YItdP5qtygy/p1Zbj3e41Z55SZI/4PGX -JHpsmxcPbe9TmJEr5A++WXkHeLuXlfSfadRYhwqp48y2WBmfJiGxxFmNskF1wK1p -zpwACPI2/z7woQ8arBT9pmAPAgMBAAGjQzBBMB0GA1UdDgQWBBTZN7NOBf3Zz58S -Fq62iS/rJTqIHDAPBgNVHQ8BAf8EBQMDBwYAMA8GA1UdEwEB/wQFMAMBAf8wDQYJ -KoZIhvcNAQEFBQADggEBAHJglrfJ3NgpXiOFX7KzLXb7iNcX/nttRbj2hWyfIvwq -ECLsqrkw9qtY1jkQMZkpAL2JZkH7dN6RwRgLn7Vhy506vvWolKMiVW4XSf/SKfE4 -Jl3vpao6+XF75tpYHdN0wgH6PmlYX63LaL4ULptswLbcoCb6dxriJNoaN+BnrdFz -gw2lGh1uEpJ+hGIAF728JRhX8tepb1mIvDS3LoV4nZbcFMMsilKbloxSZj2GFotH -uFEJjOp9zYhys2AzsfAKRO8P9Qk3iCQOLGsgOqL6EfJANZxEaGM7rDNvY7wsu/LS -y3Z9fYjYHcgFHW68lKlmjHdxx/qR+i9Rnuk5UrbnBEI= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB -yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL -ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp -U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW -ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0 -aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL -MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW -ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln -biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp -U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y -aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1 -nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex -t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz -SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG -BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+ -rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/ -NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E -BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH -BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy -aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv -MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE -p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y -5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK -WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ -4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N -hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID5TCCAs2gAwIBAgIEOeSXnjANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UEBhMC -VVMxFDASBgNVBAoTC1dlbGxzIEZhcmdvMSwwKgYDVQQLEyNXZWxscyBGYXJnbyBD -ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEvMC0GA1UEAxMmV2VsbHMgRmFyZ28gUm9v -dCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDAxMDExMTY0MTI4WhcNMjEwMTE0 -MTY0MTI4WjCBgjELMAkGA1UEBhMCVVMxFDASBgNVBAoTC1dlbGxzIEZhcmdvMSww -KgYDVQQLEyNXZWxscyBGYXJnbyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEvMC0G -A1UEAxMmV2VsbHMgRmFyZ28gUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVqDM7Jvk0/82bfuUER84A4n13 -5zHCLielTWi5MbqNQ1mXx3Oqfz1cQJ4F5aHiidlMuD+b+Qy0yGIZLEWukR5zcUHE -SxP9cMIlrCL1dQu3U+SlK93OvRw6esP3E48mVJwWa2uv+9iWsWCaSOAlIiR5NM4O -JgALTqv9i86C1y8IcGjBqAr5dE8Hq6T54oN+J3N0Prj5OEL8pahbSCOz6+MlsoCu -ltQKnMJ4msZoGK43YjdeUXWoWGPAUe5AeH6orxqg4bB4nVCMe+ez/I4jsNtlAHCE -AQgAFG5Uhpq6zPk3EPbg3oQtnaSFN9OH4xXQwReQfhkhahKpdv0SAulPIV4XAgMB -AAGjYTBfMA8GA1UdEwEB/wQFMAMBAf8wTAYDVR0gBEUwQzBBBgtghkgBhvt7hwcB -CzAyMDAGCCsGAQUFBwIBFiRodHRwOi8vd3d3LndlbGxzZmFyZ28uY29tL2NlcnRw -b2xpY3kwDQYJKoZIhvcNAQEFBQADggEBANIn3ZwKdyu7IvICtUpKkfnRLb7kuxpo -7w6kAOnu5+/u9vnldKTC2FJYxHT7zmu1Oyl5GFrvm+0fazbuSCUlFLZWohDo7qd/ -0D+j0MNdJu4HzMPBJCGHHt8qElNvQRbn7a6U+oxy+hNH8Dx+rn0ROhPs7fpvcmR7 -nX1/Jv16+yWt6j4pf0zjAFcysLPp7VMX2YuyFA4w6OXVE8Zkr8QA1dhYJPz1j+zx -x32l2w8n0cbyQIjmH/ZhqPRCyLk306m+LFZ4wnKbWV01QIroTmMatukgalHizqSQ -33ZwmVxwQ023tqcZZE6St8WRPH9IFmV7Fv3L/PvZ1dZPIWU7Sn9Ho/s= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB -gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk -MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY -UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx -NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3 -dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2Vy -dmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB -dXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS6 -38eMpSe2OAtp87ZOqCwuIR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCP -KZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMxfoArtYzAQDsRhtDLooY2YKTVMIJt2W7Q -DxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FEzG+gSqmUsE3a56k0enI4 -qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqsAxcZZPRa -JSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNVi -PvryxS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0P -BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASs -jVy16bYbMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0 -eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQEwDQYJKoZIhvcNAQEFBQAD -ggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc/Kh4ZzXxHfAR -vbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt -qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLa -IR9NmXmd4c8nnxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSy -i6mx5O+aGtA9aZnuqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ -O+7ETPTsJ3xCwnR8gooJybQDJbw= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEc -MBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2Vj -IFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENB -IDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5MjM1OTAwWjBxMQswCQYDVQQGEwJE -RTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxl -U2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290 -IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEU -ha88EOQ5bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhC -QN/Po7qCWWqSG6wcmtoIKyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1Mjwr -rFDa1sPeg5TKqAyZMg4ISFZbavva4VhYAUlfckE8FQYBjl2tqriTtM2e66foai1S -NNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aKSe5TBY8ZTNXeWHmb0moc -QqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTVjlsB9WoH -txa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAP -BgNVHRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOC -AQEAlGRZrTlk5ynrE/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756Abrsp -tJh6sTtU6zkXR34ajgv8HzFZMQSyzhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpa -IzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8rZ7/gFnkm0W09juwzTkZmDLl -6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4Gdyd1Lx+4ivn+ -xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU -Cm26OWMohpLzGITY+9HPBVZkVw== ------END CERTIFICATE----- - ------BEGIN CERTIFICATE----- -MIIEFTCCA36gAwIBAgIBADANBgkqhkiG9w0BAQQFADCBvjELMAkGA1UEBhMCVVMx -EDAOBgNVBAgTB0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UE -ChMfU29mdHdhcmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9z -dG1hc3RlcjEgMB4GA1UEAxMXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxJTAjBgkq -hkiG9w0BCQEWFmhvc3RtYXN0ZXJAc3BpLWluYy5vcmcwHhcNMDMwMTE1MTYyOTE3 -WhcNMDcwMTE0MTYyOTE3WjCBvjELMAkGA1UEBhMCVVMxEDAOBgNVBAgTB0luZGlh -bmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UEChMfU29mdHdhcmUgaW4g -dGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9zdG1hc3RlcjEgMB4GA1UE -AxMXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxJTAjBgkqhkiG9w0BCQEWFmhvc3Rt -YXN0ZXJAc3BpLWluYy5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAPB6 -rdoiLR3RodtM22LMcfwfqb5OrJNl7fwmvskgF7yP6sdD2bOfDIXhg9852jhY8/kL -VOFe1ELAL2OyN4RAxk0rliZQVgeTgqvgkOVIBbNwgnjN6mqtuWzFiPL+NXQExq40 -I3whM+4lEiwSHaV+MYxWanMdhc+kImT50LKfkxcdAgMBAAGjggEfMIIBGzAdBgNV -HQ4EFgQUB63oQR1/vda/G4F6P4xLiN4E0vowgesGA1UdIwSB4zCB4IAUB63oQR1/ -vda/G4F6P4xLiN4E0vqhgcSkgcEwgb4xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdJ -bmRpYW5hMRUwEwYDVQQHEwxJbmRpYW5hcG9saXMxKDAmBgNVBAoTH1NvZnR3YXJl -IGluIHRoZSBQdWJsaWMgSW50ZXJlc3QxEzARBgNVBAsTCmhvc3RtYXN0ZXIxIDAe -BgNVBAMTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MSUwIwYJKoZIhvcNAQkBFhZo -b3N0bWFzdGVyQHNwaS1pbmMub3JnggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN -AQEEBQADgYEAm/Abn8c2y1nO3fgpAIslxvi9iNBZDhQtJ0VQZY6wgSfANyDOR4DW -iexO/AlorB49KnkFS7TjCAoLOZhcg5FaNiKnlstMI5krQmau1Qnb/vGSNsE/UGms -1ts+QYPUs0KmGEAFUri2XzLy+aQo9Kw74VBvqnxvaaMeY5yMcKNOieY= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIIDjCCBfagAwIBAgIJAOiOtsn4KhQoMA0GCSqGSIb3DQEBBQUAMIG8MQswCQYD -VQQGEwJVUzEQMA4GA1UECBMHSW5kaWFuYTEVMBMGA1UEBxMMSW5kaWFuYXBvbGlz -MSgwJgYDVQQKEx9Tb2Z0d2FyZSBpbiB0aGUgUHVibGljIEludGVyZXN0MRMwEQYD -VQQLEwpob3N0bWFzdGVyMR4wHAYDVQQDExVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkx -JTAjBgkqhkiG9w0BCQEWFmhvc3RtYXN0ZXJAc3BpLWluYy5vcmcwHhcNMDgwNTEz -MDgwNzU2WhcNMTgwNTExMDgwNzU2WjCBvDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT -B0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UEChMfU29mdHdh -cmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9zdG1hc3RlcjEe -MBwGA1UEAxMVQ2VydGlmaWNhdGUgQXV0aG9yaXR5MSUwIwYJKoZIhvcNAQkBFhZo -b3N0bWFzdGVyQHNwaS1pbmMub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC -CgKCAgEA3DbmR0LCxFF1KYdAw9iOIQbSGE7r7yC9kDyFEBOMKVuUY/b0LfEGQpG5 -GcRCaQi/izZF6igFM0lIoCdDkzWKQdh4s/Dvs24t3dHLfer0dSbTPpA67tfnLAS1 -fOH1fMVO73e9XKKTM5LOfYFIz2u1IiwIg/3T1c87Lf21SZBb9q1NE8re06adU1Fx -Y0b4ShZcmO4tbZoWoXaQ4mBDmdaJ1mwuepiyCwMs43pPx93jzONKao15Uvr0wa8u -jyoIyxspgpJyQ7zOiKmqp4pRQ1WFmjcDeJPI8L20QcgHQprLNZd6ioFl3h1UCAHx -ZFy3FxpRvB7DWYd2GBaY7r/2Z4GLBjXFS21ZGcfSxki+bhQog0oQnBv1b7ypjvVp -/rLBVcznFMn5WxRTUQfqzj3kTygfPGEJ1zPSbqdu1McTCW9rXRTunYkbpWry9vjQ -co7qch8vNGopCsUK7BxAhRL3pqXTT63AhYxMfHMgzFMY8bJYTAH1v+pk1Vw5xc5s -zFNaVrpBDyXfa1C2x4qgvQLCxTtVpbJkIoRRKFauMe5e+wsWTUYFkYBE7axt8Feo -+uthSKDLG7Mfjs3FIXcDhB78rKNDCGOM7fkn77SwXWfWT+3Qiz5dW8mRvZYChD3F -TbxCP3T9PF2sXEg2XocxLxhsxGjuoYvJWdAY4wCAs1QnLpnwFVMCAwEAAaOCAg8w -ggILMB0GA1UdDgQWBBQ0cdE41xU2g0dr1zdkQjuOjVKdqzCB8QYDVR0jBIHpMIHm -gBQ0cdE41xU2g0dr1zdkQjuOjVKdq6GBwqSBvzCBvDELMAkGA1UEBhMCVVMxEDAO -BgNVBAgTB0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEoMCYGA1UEChMf -U29mdHdhcmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDETMBEGA1UECxMKaG9zdG1h -c3RlcjEeMBwGA1UEAxMVQ2VydGlmaWNhdGUgQXV0aG9yaXR5MSUwIwYJKoZIhvcN -AQkBFhZob3N0bWFzdGVyQHNwaS1pbmMub3JnggkA6I62yfgqFCgwDwYDVR0TAQH/ -BAUwAwEB/zARBglghkgBhvhCAQEEBAMCAAcwCQYDVR0SBAIwADAuBglghkgBhvhC -AQ0EIRYfU29mdHdhcmUgaW4gdGhlIFB1YmxpYyBJbnRlcmVzdDAwBglghkgBhvhC -AQQEIxYhaHR0cHM6Ly9jYS5zcGktaW5jLm9yZy9jYS1jcmwucGVtMDIGCWCGSAGG -+EIBAwQlFiNodHRwczovL2NhLnNwaS1pbmMub3JnL2NlcnQtY3JsLnBlbTAhBgNV -HREEGjAYgRZob3N0bWFzdGVyQHNwaS1pbmMub3JnMA4GA1UdDwEB/wQEAwIBBjAN -BgkqhkiG9w0BAQUFAAOCAgEAtM294LnqsgMrfjLp3nI/yUuCXp3ir1UJogxU6M8Y -PCggHam7AwIvUjki+RfPrWeQswN/2BXja367m1YBrzXU2rnHZxeb1NUON7MgQS4M -AcRb+WU+wmHo0vBqlXDDxm/VNaSsWXLhid+hoJ0kvSl56WEq2dMeyUakCHhBknIP -qxR17QnwovBc78MKYiC3wihmrkwvLo9FYyaW8O4x5otVm6o6+YI5HYg84gd1GuEP -sTC8cTLSOv76oYnzQyzWcsR5pxVIBcDYLXIC48s9Fmq6ybgREOJJhcyWR2AFJS7v -dVkz9UcZFu/abF8HyKZQth3LZjQl/GaD68W2MEH4RkRiqMEMVObqTFoo5q7Gt/5/ -O5aoLu7HaD7dAD0prypjq1/uSSotxdz70cbT0ZdWUoa2lOvUYFG3/B6bzAKb1B+P -+UqPti4oOxfMxaYF49LTtcYDyeFIQpvLP+QX4P4NAZUJurgNceQJcHdC2E3hQqlg -g9cXiUPS1N2nGLar1CQlh7XU4vwuImm9rWgs/3K1mKoGnOcqarihk3bOsPN/nOHg -T7jYhkalMwIsJWE3KpLIrIF0aGOHM3a9BX9e1dUCbb2v/ypaqknsmHlHU5H2DjRa -yaXG67Ljxay2oHA1u8hRadDytaIybrw/oDc5fHE2pgXfDBLkFqfF1stjo5VwP+YE -o2A= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDvjCCA3ygAwIBAgIFJQaThoEwCwYHKoZIzjgEAwUAMIGFMQswCQYDVQQGEwJG -UjEPMA0GA1UECBMGRnJhbmNlMQ4wDAYDVQQHEwVQYXJpczEQMA4GA1UEChMHUE0v -U0dETjEOMAwGA1UECxMFRENTU0kxDjAMBgNVBAMTBUlHQy9BMSMwIQYJKoZIhvcN -AQkBFhRpZ2NhQHNnZG4ucG0uZ291di5mcjAeFw0wMjEyMTMxNDM5MTVaFw0yMDEw -MTcxNDM5MTRaMIGFMQswCQYDVQQGEwJGUjEPMA0GA1UECBMGRnJhbmNlMQ4wDAYD -VQQHEwVQYXJpczEQMA4GA1UEChMHUE0vU0dETjEOMAwGA1UECxMFRENTU0kxDjAM -BgNVBAMTBUlHQy9BMSMwIQYJKoZIhvcNAQkBFhRpZ2NhQHNnZG4ucG0uZ291di5m -cjCCAbYwggErBgcqhkjOOAQBMIIBHgKBgQCFkMImdk9zDzJfTO4XPdAAmLbAdWws -ZiEMZh19RyTo3CyhFqO77OIXrwY6vc1pcc3MgWJ0dgQpAgrDMtmFFxpUu4gmjVsx -8GpxQC+4VOgLY8Cvmcd/UDzYg07EIRto8BwCpPJ/JfUxwzV2V3N713aAX+cEoKZ/ -s+kgxC6nZCA7oQIVALME/JYjkdW2uKIGngsEPbXAjdhDAoGADh/uqWJx94UBm31c -9d8ZTBfRGRnmSSRVFDgPWgA69JD4BR5da8tKz+1HjfMhDXljbMH86ixpD5Ka1Z0V -pRYUPbyAoB37tsmXMJY7kjyD19d5VdaZboUjVvhH6UJy5lpNNNGSvFl4fqkxyvw+ -pq1QV0N5RcvK120hlXdfHUX+YKYDgYQAAoGAQGr7IuKJcYIvJRMjxwl43KxXY2xC -aoCiM/bv117MfI94aNf1UusGhp7CbYAY9CXuL60P0oPMAajbaTE5Z34AuITeHq3Y -CNMHwxalip8BHqSSGmGiQsXeK7T+r1rPXsccZ1c5ikGDZ4xn5gUaCyy2rCmb+fOJ -6VAfCbAbAjmNKwejdzB1MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgFGMBUG -A1UdIAQOMAwwCgYIKoF6AXkBAQEwHQYDVR0OBBYEFPkeNRcUf8idzpKblYbLNxs0 -MQhSMB8GA1UdIwQYMBaAFPkeNRcUf8idzpKblYbLNxs0MQhSMAsGByqGSM44BAMF -AAMvADAsAhRVh+CJA5eVyEYU5AO9Tm7GxX0rmQIUBCqsU5u1WxoZ5lEXicDX5/Ob -sRQ= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEAjCCAuqgAwIBAgIFORFFEJQwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYT -AkZSMQ8wDQYDVQQIEwZGcmFuY2UxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQ -TS9TR0ROMQ4wDAYDVQQLEwVEQ1NTSTEOMAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG -9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2LmZyMB4XDTAyMTIxMzE0MjkyM1oXDTIw -MTAxNzE0MjkyMlowgYUxCzAJBgNVBAYTAkZSMQ8wDQYDVQQIEwZGcmFuY2UxDjAM -BgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQTS9TR0ROMQ4wDAYDVQQLEwVEQ1NTSTEO -MAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2 -LmZyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsh/R0GLFMzvABIaI -s9z4iPf930Pfeo2aSVz2TqrMHLmh6yeJ8kbpO0px1R2OLc/mratjUMdUC24SyZA2 -xtgv2pGqaMVy/hcKshd+ebUyiHDKcMCWSo7kVc0dJ5S/znIq7Fz5cyD+vfcuiWe4 -u0dzEvfRNWk68gq5rv9GQkaiv6GFGvm/5P9JhfejcIYyHF2fYPepraX/z9E0+X1b -F8bc1g4oa8Ld8fUzaJ1O/Id8NhLWo4DoQw1VYZTqZDdH6nfK0LJYBcNdfrGoRpAx -Vs5wKpayMLh35nnAvSk7/ZR3TL0gzUEl4C7HG7vupARB0l2tEmqKm0f7yd1GQOGd -PDPQtQIDAQABo3cwdTAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBRjAVBgNV -HSAEDjAMMAoGCCqBegF5AQEBMB0GA1UdDgQWBBSjBS8YYFDCiQrdKyFP/45OqDAx -NjAfBgNVHSMEGDAWgBSjBS8YYFDCiQrdKyFP/45OqDAxNjANBgkqhkiG9w0BAQUF -AAOCAQEABdwm2Pp3FURo/C9mOnTgXeQp/wYHE4RKq89toB9RlPhJy3Q2FLwV3duJ -L92PoF189RLrn544pEfMs5bZvpwlqwN+Mw+VgQ39FuCIvjfwbF3QMZsyK10XZZOY -YLxuj7GoPB7ZHPOpJkL5ZB3C55L29B5aqhlSXa/oovdgoPaN8In1buAKBQGVyYsg -Crpa/JosPL3Dt8ldeCUFP1YUmwza+zpI/pdpXsoQhvdOlgQITeywvl3cO45Pwf2a -NjSaTFR+FwNIlQgRHAdvhQh+XU3Endv7rs6y0bO4g2wdsrN58dhwmX7wEwLOXt1R -0982gaEbeC9xs/FZTEYYKKuF0mBWWg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 -IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB -IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA -Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO -BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi -MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ -ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC -CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ -8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 -zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y -fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 -w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc -G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k -epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q -laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ -QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU -fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 -YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w -ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY -gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe -MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 -IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy -dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw -czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 -dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl -aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC -AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg -b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB -ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc -nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg -18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c -gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl -Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY -sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T -SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF -CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum -GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk -zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW -omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIGCDCCA/CgAwIBAgIBATANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 -IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB -IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA -Y2FjZXJ0Lm9yZzAeFw0wNTEwMTQwNzM2NTVaFw0zMzAzMjgwNzM2NTVaMFQxFDAS -BgNVBAoTC0NBY2VydCBJbmMuMR4wHAYDVQQLExVodHRwOi8vd3d3LkNBY2VydC5v -cmcxHDAaBgNVBAMTE0NBY2VydCBDbGFzcyAzIFJvb3QwggIiMA0GCSqGSIb3DQEB -AQUAA4ICDwAwggIKAoICAQCrSTURSHzSJn5TlM9Dqd0o10Iqi/OHeBlYfA+e2ol9 -4fvrcpANdKGWZKufoCSZc9riVXbHF3v1BKxGuMO+f2SNEGwk82GcwPKQ+lHm9WkB -Y8MPVuJKQs/iRIwlKKjFeQl9RrmK8+nzNCkIReQcn8uUBByBqBSzmGXEQ+xOgo0J -0b2qW42S0OzekMV/CsLj6+YxWl50PpczWejDAz1gM7/30W9HxM3uYoNSbi4ImqTZ -FRiRpoWSR7CuSOtttyHshRpocjWr//AQXcD0lKdq1TuSfkyQBX6TwSyLpI5idBVx -bgtxA+qvFTia1NIFcm+M+SvrWnIl+TlG43IbPgTDZCciECqKT1inA62+tC4T7V2q -SNfVfdQqe1z6RgRQ5MwOQluM7dvyz/yWk+DbETZUYjQ4jwxgmzuXVjit89Jbi6Bb -6k6WuHzX1aCGcEDTkSm3ojyt9Yy7zxqSiuQ0e8DYbF/pCsLDpyCaWt8sXVJcukfV -m+8kKHA4IC/VfynAskEDaJLM4JzMl0tF7zoQCqtwOpiVcK01seqFK6QcgCExqa5g -eoAmSAC4AcCTY1UikTxW56/bOiXzjzFU6iaLgVn5odFTEcV7nQP2dBHgbbEsPyyG -kZlxmqZ3izRg0RS0LKydr4wQ05/EavhvE/xzWfdmQnQeiuP43NJvmJzLR5iVQAX7 -6QIDAQABo4G/MIG8MA8GA1UdEwEB/wQFMAMBAf8wXQYIKwYBBQUHAQEEUTBPMCMG -CCsGAQUFBzABhhdodHRwOi8vb2NzcC5DQWNlcnQub3JnLzAoBggrBgEFBQcwAoYc -aHR0cDovL3d3dy5DQWNlcnQub3JnL2NhLmNydDBKBgNVHSAEQzBBMD8GCCsGAQQB -gZBKMDMwMQYIKwYBBQUHAgEWJWh0dHA6Ly93d3cuQ0FjZXJ0Lm9yZy9pbmRleC5w -aHA/aWQ9MTAwDQYJKoZIhvcNAQEEBQADggIBAH8IiKHaGlBJ2on7oQhy84r3HsQ6 -tHlbIDCxRd7CXdNlafHCXVRUPIVfuXtCkcKZ/RtRm6tGpaEQU55tiKxzbiwzpvD0 -nuB1wT6IRanhZkP+VlrRekF490DaSjrxC1uluxYG5sLnk7mFTZdPsR44Q4Dvmw2M -77inYACHV30eRBzLI++bPJmdr7UpHEV5FpZNJ23xHGzDwlVks7wU4vOkHx4y/CcV -Bc/dLq4+gmF78CEQGPZE6lM5+dzQmiDgxrvgu1pPxJnIB721vaLbLmINQjRBvP+L -ivVRIqqIMADisNS8vmW61QNXeZvo3MhN+FDtkaVSKKKs+zZYPumUK5FQhxvWXtaM -zPcPEAxSTtAWYeXlCmy/F8dyRlecmPVsYGN6b165Ti/Iubm7aoW8mA3t+T6XhDSU -rgCvoeXnkm5OvfPi2RSLXNLrAWygF6UtEOucekq9ve7O/e0iQKtwOIj1CodqwqsF -YMlIBdpTwd5Ed2qz8zw87YC8pjhKKSRf/lk7myV6VmMAZLldpGJ9VzZPrYPvH5JT -oI53V93lYRE9IwCQTDz6o2CTBKOvNfYOao9PSmCnhQVsRqGP9Md246FZV/dxssRu -FFxtbUFm3xuTsdQAw+7Lzzw9IYCpX2Nl/N3gX6T0K/CFcUHUZyX7GrGXrtaZghNB -0m6lG5kngOcLqagA ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL -MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE -BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT -IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw -MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy -ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N -T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR -FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J -cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW -BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ -BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm -fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv -GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIFijCCA3KgAwIBAgIQDHbanJEMTiye/hXQWJM8TDANBgkqhkiG9w0BAQUFADBf -MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp -Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww -HhcNMDcwNTE2MTcxOTM2WhcNMjUwMzMxMTgxOTIxWjBfMQswCQYDVQQGEwJOTDES -MBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdpTm90YXIgUm9vdCBDQTEg -MB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmwwggIiMA0GCSqGSIb3DQEB -AQUAA4ICDwAwggIKAoICAQCssFjBAL3YIQgLK5r+blYwBZ8bd5AQQVzDDYcRd46B -8cp86Yxq7Th0Nbva3/m7wAk3tJZzgX0zGpg595NvlX89ubF1h7pRSOiLcD6VBMXY -tsMW2YiwsYcdcNqGtA8Ui3rPENF0NqISe3eGSnnme98CEWilToauNFibJBN4ViIl -HgGLS1Fx+4LMWZZpiFpoU8W5DQI3y0u8ZkqQfioLBQftFl9VkHXYRskbg+IIvvEj -zJkd1ioPgyAVWCeCLvriIsJJsbkBgWqdbZ1Ad2h2TiEqbYRAhU52mXyC8/O3AlnU -JgEbjt+tUwbRrhjd4rI6y9eIOI6sWym5GdOY+RgDz0iChmYLG2kPyes4iHomGgVM -ktck1JbyrFIto0fVUvY//s6EBnCmqj6i8rZWNBhXouSBbefK8GrTx5FrAoNBfBXv -a5pkXuPQPOWx63tdhvvL5ndJzaNl3Pe5nLjkC1+Tz8wwGjIczhxjlaX56uF0i57p -K6kwe6AYHw4YC+VbqdPRbB4HZ4+RS6mKvNJmqpMBiLKR+jFc1abBUggJzQpjotMi -puih2TkGl/VujQKQjBR7P4DNG5y6xFhyI6+2Vp/GekIzKQc/gsnmHwUNzUwoNovT -yD4cxojvXu6JZOkd69qJfjKmadHdzIif0dDJZiHcBmfFlHqabWJMfczgZICynkeO -owIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV -HQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wDQYJKoZIhvcNAQEFBQADggIBADsC -jcs8MOhuoK3yc7NfniUTBAXT9uOLuwt5zlPe5JbF0a9zvNXD0EBVfEB/zRtfCdXy -fJ9oHbtdzno5wozWmHvFg1Wo1X1AyuAe94leY12hE8JdiraKfADzI8PthV9xdvBo -Y6pFITlIYXg23PFDk9Qlx/KAZeFTAnVR/Ho67zerhChXDNjU1JlWbOOi/lmEtDHo -M/hklJRRl6s5xUvt2t2AC298KQ3EjopyDedTFLJgQT2EkTFoPSdE2+Xe9PpjRchM -Ppj1P0G6Tss3DbpmmPHdy59c91Q2gmssvBNhl0L4eLvMyKKfyvBovWsdst+Nbwed -2o5nx0ceyrm/KkKRt2NTZvFCo+H0Wk1Ya7XkpDOtXHAd3ODy63MUkZoDweoAZbwH -/M8SESIsrqC9OuCiKthZ6SnTGDWkrBFfGbW1G/8iSlzGeuQX7yCpp/Q/rYqnmgQl -nQ7KN+ZQ/YxCKQSa7LnPS3K94gg2ryMvYuXKAdNw23yCIywWMQzGNgeQerEfZ1jE -O1hZibCMjFCz2IbLaKPECudpSyDOwR5WS5WpI2jYMNjD67BVUc3l/Su49bsRn1NU -9jQZjHkJNsphFyUXC4KYcwx3dMPVDceoEkzHp1RxRy4sGn3J4ys7SN4nhKdjNrN9 -j6BkOSQNPXuHr2ZcdBtLc7LljPCGmbjlxd+Ewbfr ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi -MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu -MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp -dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJV -UzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydO -ZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwz -c7MEL7xxjOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPP -OCwGJgl6cvf6UDL4wpPTaaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rl -mGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXTcrA/vGp97Eh/jcOrqnErU2lBUzS1sLnF -BgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc/Qzpf14Dl847ABSHJ3A4 -qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMBAAGjgZcw -gZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIB -BjAPBgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwu -bmV0c29sc3NsLmNvbS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3Jp -dHkuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc8 -6fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q4LqILPxFzBiwmZVRDuwduIj/ -h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/GGUsyfJj4akH -/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv -wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN -pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEvTCCA6WgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCVVMx -IDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxs -cyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9v -dCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDcxMjEzMTcwNzU0WhcNMjIxMjE0 -MDAwNzU0WjCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdl -bGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQD -DC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw -ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDub7S9eeKPCCGeOARBJe+r -WxxTkqxtnt3CxC5FlAM1iGd0V+PfjLindo8796jE2yljDpFoNoqXjopxaAkH5OjU -Dk/41itMpBb570OYj7OeUt9tkTmPOL13i0Nj67eT/DBMHAGTthP796EfvyXhdDcs -HqRePGj4S78NuR4uNuip5Kf4D8uCdXw1LSLWwr8L87T8bJVhHlfXBIEyg1J55oNj -z7fLY4sR4r1e6/aN7ZVyKLSsEmLpSjPmgzKuBXWVvYSV2ypcm44uDLiBK0HmOFaf -SZtsdvqKXfcBeYF8wYNABf5x/Qw/zE5gCQ5lRxAvAcAFP4/4s0HvWkJ+We/Slwxl -AgMBAAGjggE0MIIBMDAPBgNVHRMBAf8EBTADAQH/MDkGA1UdHwQyMDAwLqAsoCqG -KGh0dHA6Ly9jcmwucGtpLndlbGxzZmFyZ28uY29tL3dzcHJjYS5jcmwwDgYDVR0P -AQH/BAQDAgHGMB0GA1UdDgQWBBQmlRkQ2eihl5H/3BnZtQQ+0nMKajCBsgYDVR0j -BIGqMIGngBQmlRkQ2eihl5H/3BnZtQQ+0nMKaqGBi6SBiDCBhTELMAkGA1UEBhMC -VVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNX -ZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMg -Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCAQEwDQYJKoZIhvcNAQEFBQADggEB -ALkVsUSRzCPIK0134/iaeycNzXK7mQDKfGYZUMbVmO2rvwNa5U3lHshPcZeG1eMd -/ZDJPHV3V3p9+N701NX3leZ0bh08rnyd2wIDBSxxSyU+B+NemvVmFymIGjifz6pB -A4SXa5M4esowRBskRDPQ5NHcKDj0E0M1NSljqHyita04pO2t/caaH/+Xc/77szWn -k4bGdpEA5qxRFsQnMlzbc9qlk1eOPm01JghZ1edE13YgY+esE2fDbbFwRnzVlhE9 -iW9dqKHrjQrawx0zbKPqZxmamX9LPYNRKh3KL4YMon4QLSvUFpULB6ouFJJJtylv -2G0xffX8oRAHh84vWdw+WNs= ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt b/user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt deleted file mode 100644 index 453bafa..0000000 --- a/user/mpy/lib/axtls/ssl/test/camster_duckdns_org.crt +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFXTCCBEWgAwIBAgIQRKGXkBbin0Hge3vNu4Z04TANBgkqhkiG9w0BAQsFADCB -kDELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G -A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxNjA0BgNV -BAMTLUNPTU9ETyBSU0EgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD -QTAeFw0xNDExMTIwMDAwMDBaFw0xNzExMTEyMzU5NTlaMFcxITAfBgNVBAsTGERv -bWFpbiBDb250cm9sIFZhbGlkYXRlZDEUMBIGA1UECxMLUG9zaXRpdmVTU0wxHDAa -BgNVBAMTE2NhbXN0ZXIuZHVja2Rucy5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IB -DwAwggEKAoIBAQCvKi9/3GOq1pqgnIQR2hTxr1kv17pUzpQeAVOZVCd/q6KbMrsw -ayPj41hJd+EVtu6DV8Zd/Rxv4P6i2HTRWev9aE2+vFfTmhIZG0HUZqs3Fbq6yONn -ox8d7Dsu/vwIkyaIE9mMAYYr81bX86v8cmvCHatCO/lluwUqjnXUjYpMOpTopHjC -hNzUe63ZtUDVmXfTBHneO5GLZqhQSSX7rd33cJzkojGCoPSFP5TUhN5WGyRi+xa2 -bD+Q5xXlC4f/WVXiZxGiGPrWIpQBO5Y5o33S6Vo2ck9Bvg2g1atsR02m+yARtmH3 -+IDlvg7DeyLL3AXgUwDNHnRb0t9LVDXcYOJnAgMBAAGjggHpMIIB5TAfBgNVHSME -GDAWgBSQr2o6lFoL2JDqElZz30O0Oija5zAdBgNVHQ4EFgQUGNRX8FYKZUYa1F4+ -L7nyHOn3ArcwDgYDVR0PAQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYw -FAYIKwYBBQUHAwEGCCsGAQUFBwMCME8GA1UdIARIMEYwOgYLKwYBBAGyMQECAgcw -KzApBggrBgEFBQcCARYdaHR0cHM6Ly9zZWN1cmUuY29tb2RvLmNvbS9DUFMwCAYG -Z4EMAQIBMFQGA1UdHwRNMEswSaBHoEWGQ2h0dHA6Ly9jcmwuY29tb2RvY2EuY29t -L0NPTU9ET1JTQURvbWFpblZhbGlkYXRpb25TZWN1cmVTZXJ2ZXJDQS5jcmwwgYUG -CCsGAQUFBwEBBHkwdzBPBggrBgEFBQcwAoZDaHR0cDovL2NydC5jb21vZG9jYS5j -b20vQ09NT0RPUlNBRG9tYWluVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAk -BggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMDcGA1UdEQQwMC6C -E2NhbXN0ZXIuZHVja2Rucy5vcmeCF3d3dy5jYW1zdGVyLmR1Y2tkbnMub3JnMA0G -CSqGSIb3DQEBCwUAA4IBAQBpfJIXHPyoxbXlS1Jy5V4oDpDR+vKRIXXUPDp6GlmK -6w8W7M536W7JamLrT8wbA04hKgtjQkXD8pXZPFHBNJ92Lza5fKB/KiIlObz386lK -Z9AVc10TwWlkZlFYhYVhQ+kpTtcUUdj5QI2org81s9XQoSViVOM8cxIuYk/er20g -jY3Nvdbjg4dtakH1nsITGMYLN+wJglSAq1QGSQ76fLyYhMfF25nNjPYP96SFf1Dd -XinknP2tED6ukzIgfkimlyn2/XIbnz4Xry8ouq4x/cPd8MOcffWt1QWlGIel5B8i -I1vtVHceHSsHjnnNPSkXIn0/lpc5vzVZ+bw9yLt+Lvc6 ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/comodo.sha384.cer b/user/mpy/lib/axtls/ssl/test/comodo.sha384.cer deleted file mode 100644 index b52ea61..0000000 --- a/user/mpy/lib/axtls/ssl/test/comodo.sha384.cer +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv -MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk -ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF -eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow -gYUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO -BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMSswKQYD -VQQDEyJDT01PRE8gUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkq -hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkehUktIKVrGsDSTdxc9EZ3SZKzejfSNw -AHG8U9/E+ioSj0t/EFa9n3Byt2F/yUsPF6c947AEYe7/EZfH9IY+Cvo+XPmT5jR6 -2RRr55yzhaCCenavcZDX7P0N+pxs+t+wgvQUfvm+xKYvT3+Zf7X8Z0NyvQwA1onr -ayzT7Y+YHBSrfuXjbvzYqOSSJNpDa2K4Vf3qwbxstovzDo2a5JtsaZn4eEgwRdWt -4Q08RWD8MpZRJ7xnw8outmvqRsfHIKCxH2XeSAi6pE6p8oNGN4Tr6MyBSENnTnIq -m1y9TBsoilwie7SrmNnu4FGDwwlGTm0+mfqVF9p8M1dBPI1R7Qu2XK8sYxrfV8g/ -vOldxJuvRZnio1oktLqpVj3Pb6r/SVi+8Kj/9Lit6Tf7urj0Czr56ENCHonYhMsT -8dm74YlguIwoVqwUHZwK53Hrzw7dPamWoUi9PPevtQ0iTMARgexWO/bTouJbt7IE -IlKVgJNp6I5MZfGRAy1wdALqi2cVKWlSArvX31BqVUa/oKMoYX9w0MOiqiwhqkfO -KJwGRXa/ghgntNWutMtQ5mv0TIZxMOmm3xaG4Nj/QN370EKIf6MzOi5cHkERgWPO -GHFrK+ymircxXDpqR+DDeVnWIBqv8mqYqnK8V0rSS527EPywTEHl7R09XiidnMy/ -s1Hap0flhFMCAwEAAaOB9DCB8TAfBgNVHSMEGDAWgBStvZh6NLQm9/rEJlTvA73g -JMtUGjAdBgNVHQ4EFgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQD -AgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAGBgRVHSAAMEQGA1UdHwQ9 -MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9BZGRUcnVzdEV4dGVy -bmFsQ0FSb290LmNybDA1BggrBgEFBQcBAQQpMCcwJQYIKwYBBQUHMAGGGWh0dHA6 -Ly9vY3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggEBAGS/g/FfmoXQ -zbihKVcN6Fr30ek+8nYEbvFScLsePP9NDXRqzIGCJdPDoCpdTPW6i6FtxFQJdcfj -Jw5dhHk3QBN39bSsHNA7qxcS1u80GH4r6XnTq1dFDK8o+tDb5VCViLvfhVdpfZLY -Uspzgb8c8+a4bmYRBbMelC1/kZWSWfFMzqORcUx8Rww7Cxn2obFshj5cqsQugsv5 -B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx -PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR -pu/xO28QOG8= ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/deutsche_telecom.x509_ca b/user/mpy/lib/axtls/ssl/test/deutsche_telecom.x509_ca deleted file mode 100644 index 0f4b96a0d5b66ac34b258e34a8943630d55feacc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 670 zcmXqLVwz>p#KgRSnTe5!iBZLXmyJ`a&7xk*W}qnv{YLwX`%aH?TA`G&V6Xh!W>D1apmyO)Y`kfpAje zeB^LpWMyD(>}4=$>||7N?y$<5%!OzF zERzTg``9Ao-X*XBQfdA{s)V1MQHyO zWy#)aHLqswC)*oOrXGIdcj#m4Y98-5?oH8;9tM=&_?EauBId2}0<I-~KIoDw&uW z85kEk890CgUzU$Wj73Dm@KODoQ$kaJe=JbA?W-YN=#+TOfFBt2vcfDJ25gLs|CtzB z4fsF;{6G#13o!QCki7_udS;;C=E@5EntVbwMZq<0PCjey;-LEFE80^xr_VBLt0)o^ z{eRuHSc9>xWA4OP_pWJj^Vlt(S>nKR=8eFEls^UAc3BFke~M!W*vfs)>;B68FPk|v z8vb08JMyN$t<~qA>juWD7Hh=jyLr9SJ-zpI>PD-l%e+~<`HcU|RG(;Raeo+<;^qYa DuXy4z diff --git a/user/mpy/lib/axtls/ssl/test/equifax.x509_ca b/user/mpy/lib/axtls/ssl/test/equifax.x509_ca deleted file mode 100644 index 79b0a3f98764a07fdf6cae1a80eebf704d1f8796..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 646 zcmXqLVrnvIVtl=TnTe5!iIK&CmyJ`a&7A-4f18*?ZNn=n&ou%V2B z6o|tmEbLlXnwgeZp%9#!Tw0W>;F*`KXQ*bN0+MAGmPM0Ibt)~+%u6jUR&aLIH8hYD z=e4vnFf%eVFfjmvC~;mR10*hOENz^R>^DYM2Ij_I27|^_GV!Yaq78vdHv|ahSG);D}~qW z>v(UKw>nj0}v6(+pA!1lc$f+B_KBemDWcpM{x;f!%-~7^bqq zjEw(TSPhtglz}`*K$%6tK&(N;tHLNq@OGq_S={}DB4!R*?lnFO4P-$I_*lePuuG#x zF*DHrrO_*9GYdX@8Rm2L=SrUgyt6)^NzHtwT6QLK`?Zk6vS(+mk-WR5_38uLKS>J9 zTf8GuKR)_7Rnh+ImAVKy_x2FGh=p6X{?K|~_^nW3?Pk)dG}kZXa&H83}nHjo5q@oeRF+y~C}AK5 zF_#}?pk8`jX-Q78UVc%!LE{``H!w0c_AnSUb}%(IT;CP5elgDny_M==tAhJhysmF7 z^~s*G&+FB8xgXw#vyR;2W!Uk`M_ArWZ1TOL_s5pRZOYqrimM~Ebi%Z^%fk2YSeNlm zm)raDP5tGSZ+^F?EXZEqajv|sc#fg)f7=u5mL}xg+}0B{D}UR*`B{6He^_9w{&lI0t~bUk(V|yzt>L6d&agTOlQ%<1HtMiK21dqF;?crMuy~AZ)cCC zcar#4F@K*Wyr$(`=edOf)X_qG#W2@k=EugP0m@R{;Q^*WZi) diff --git a/user/mpy/lib/axtls/ssl/test/header_issue.dat b/user/mpy/lib/axtls/ssl/test/header_issue.dat deleted file mode 100755 index a48d23d2b937820a533bc1394d6c155fd28c1959..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1159 zcmWe*W@Kq%Vqj2XW^_B{aBjXp>E)wm*3`MA7YKbx?VUNb&ow+D@R^CtrU!`(45kd+ z3@iZ*EWQj(j0R1Ne}Q;86SDvVivceir&gOs+jm|@Mpjk^gU02C@&>YO%%Ln?!eYS% znMJ92B?`{@xw)lznaPPInfZCehI|G*AO+mQtO1U?;Q@xK2Fh?lI2pynic1R$@{39w ziXqyQ^K_r&^DUdsvg@wz@%k`ix z(#=UO2Kme&200WNSs9qU84Ns_92wpo`5|5!qql9!X6NU%!l&1>n0uS&D5^(1N_N=q zT3#1Xo$~t3DZM?rcUCRjoTpWPC&fDJUdopHOj#EUEFSSFWs-_7#%qy;W$R;IY>2#oGL(LO(Mop($Bszg1H5j-<7 zYyB}vW~D>tw?BFLXek4en?Vzk6EF?DVd7-C`OWT+eQSgcnmt1@C72qS8d)Mz0)#t+ ze1a<>?d5STc=(BH&V_n5t}ZuuwkKi#Kd5eDJK@OGejq5*ct+H>r89oKDBiP7sKoTQ zuBR~j#nTEypxQCB{fdK$z?p#a& diff --git a/user/mpy/lib/axtls/ssl/test/killgnutls.sh b/user/mpy/lib/axtls/ssl/test/killgnutls.sh deleted file mode 100755 index f910f4b..0000000 --- a/user/mpy/lib/axtls/ssl/test/killgnutls.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ps -ef|grep gnutls-serv | /usr/bin/awk '{print $2}' |xargs kill -9 diff --git a/user/mpy/lib/axtls/ssl/test/killopenssl.sh b/user/mpy/lib/axtls/ssl/test/killopenssl.sh deleted file mode 100755 index 17950fb..0000000 --- a/user/mpy/lib/axtls/ssl/test/killopenssl.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ps -ef|grep openssl | /usr/bin/awk '{print $2}' |xargs kill -9 diff --git a/user/mpy/lib/axtls/ssl/test/make_certs.sh b/user/mpy/lib/axtls/ssl/test/make_certs.sh deleted file mode 100755 index f234b3f..0000000 --- a/user/mpy/lib/axtls/ssl/test/make_certs.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2007-2016, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# -# Generate the certificates and keys for testing. -# - -PROJECT_NAME="axTLS Project" - -# Generate the openssl configuration files. -cat > ca_cert.conf << EOF -[ req ] -distinguished_name = req_distinguished_name -prompt = no -req_extensions = v3_ca - -[ req_distinguished_name ] - O = $PROJECT_NAME Dodgy Certificate Authority - -[ v3_ca ] -basicConstraints = critical, CA:true -keyUsage = critical, cRLSign, keyCertSign, digitalSignature -EOF - -cat > certs.conf << EOF -[ req ] -distinguished_name = req_distinguished_name -prompt = no -req_extensions = v3_usr_cert - -[ req_distinguished_name ] - O = $PROJECT_NAME - CN = localhost - -[ v3_usr_cert ] -basicConstraints = critical, CA:false -keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment -subjectAltName = @alt_names - -[alt_names] -DNS.1 = www.example.net -DNS.2 = www.example.org -EOF - -cat > device_cert.conf << EOF -[ req ] -distinguished_name = req_distinguished_name -prompt = no - -[ req_distinguished_name ] - O = $PROJECT_NAME Device Certificate -EOF - -cat > intermediate_ca.conf << EOF -[ req ] -distinguished_name = req_distinguished_name -prompt = no -req_extensions = v3_intermediate_ca - -[ req_distinguished_name ] - O = $PROJECT_NAME Intermediate CA - -[ v3_intermediate_ca ] -basicConstraints = critical, CA:true, pathlen:0 -keyUsage = cRLSign, keyCertSign, digitalSignature -EOF - -cat > intermediate_ca2.conf << EOF -[ req ] -distinguished_name = req_distinguished_name -prompt = no -req_extensions = v3_intermediate_ca2 - -[ req_distinguished_name ] - O = $PROJECT_NAME Intermediate 2 CA - -[ v3_intermediate_ca2 ] -basicConstraints = critical, CA:true, pathlen:10 -keyUsage = encipherOnly, keyCertSign, decipherOnly -EOF - -# private key generation -openssl genrsa -out axTLS.ca_key.pem 2048 -openssl genrsa -out axTLS.key_1024.pem 1024 -openssl genrsa -out axTLS.key_2048.pem 2048 -openssl genrsa -out axTLS.key_4096.pem 4096 -openssl genrsa -out axTLS.key_device.pem 2048 -openssl genrsa -out axTLS.key_intermediate_ca.pem 2048 -openssl genrsa -out axTLS.key_intermediate_ca2.pem 2048 -openssl genrsa -out axTLS.key_end_chain.pem 2048 -openssl genrsa -aes128 -passout pass:abcd -out axTLS.key_aes128.pem 1024 -openssl genrsa -aes256 -passout pass:abcd -out axTLS.key_aes256.pem 1024 - -# convert private keys into DER format -openssl rsa -in axTLS.key_1024.pem -out axTLS.key_1024 -outform DER -openssl rsa -in axTLS.key_2048.pem -out axTLS.key_2048 -outform DER -openssl rsa -in axTLS.key_4096.pem -out axTLS.key_4096 -outform DER - -# cert requests -openssl req -out axTLS.ca_x509.csr -key axTLS.ca_key.pem -new \ - -config ./ca_cert.conf -openssl req -out axTLS.x509_1024.csr -key axTLS.key_1024.pem -new \ - -config ./certs.conf -openssl req -out axTLS.x509_2048.csr -key axTLS.key_2048.pem -new \ - -config ./certs.conf -openssl req -out axTLS.x509_4096.csr -key axTLS.key_4096.pem -new \ - -config ./certs.conf -openssl req -out axTLS.x509_device.csr -key axTLS.key_device.pem -new \ - -config ./device_cert.conf -openssl req -out axTLS.x509_intermediate_ca.csr \ - -key axTLS.key_intermediate_ca.pem -new \ - -config ./intermediate_ca.conf -openssl req -out axTLS.x509_intermediate_ca2.csr \ - -key axTLS.key_intermediate_ca2.pem -new \ - -config ./intermediate_ca2.conf -openssl req -out axTLS.x509_end_chain.csr -key axTLS.key_end_chain.pem -new \ - -config ./certs.conf -openssl req -out axTLS.x509_aes128.csr -key axTLS.key_aes128.pem \ - -new -config ./certs.conf -passin pass:abcd -openssl req -out axTLS.x509_aes256.csr -key axTLS.key_aes256.pem \ - -new -config ./certs.conf -passin pass:abcd - -# generate the actual certs. -openssl x509 -req -in axTLS.ca_x509.csr -out axTLS.ca_x509.pem \ - -sha1 -days 5000 -signkey axTLS.ca_key.pem \ - -CAkey axTLS.ca_key.pem -extfile ./ca_cert.conf -extensions v3_ca -openssl x509 -req -in axTLS.ca_x509.csr -out axTLS.ca_x509_sha256.pem \ - -sha256 -days 5000 -signkey axTLS.ca_key.pem \ - -CAkey axTLS.ca_key.pem -extfile ./ca_cert.conf -extensions v3_ca -openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024.pem \ - -sha1 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024_sha256.pem \ - -sha256 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509_sha256.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024_sha384.pem \ - -sha384 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509_sha256.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_1024_sha512.pem \ - -sha512 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509_sha256.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_2048.csr -out axTLS.x509_2048.pem \ - -sha1 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_4096.csr -out axTLS.x509_4096.pem \ - -sha1 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_device.csr -out axTLS.x509_device.pem \ - -sha1 -CAcreateserial -days 5000 \ - -CA axTLS.x509_1024.pem -CAkey axTLS.key_1024.pem -openssl x509 -req -in axTLS.x509_intermediate_ca.csr -out axTLS.x509_intermediate_ca.pem \ - -sha256 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem \ - -extfile ./intermediate_ca.conf -extensions v3_intermediate_ca -openssl x509 -req -in axTLS.x509_intermediate_ca2.csr -out axTLS.x509_intermediate_ca2.pem \ - -sha256 -CAcreateserial -days 5000 \ - -CA axTLS.x509_intermediate_ca.pem \ - -CAkey axTLS.key_intermediate_ca.pem \ - -extfile ./intermediate_ca2.conf -extensions v3_intermediate_ca2 -openssl x509 -req -in axTLS.x509_end_chain.csr -out axTLS.x509_end_chain.pem \ - -sha256 -CAcreateserial -days 5000 \ - -CA axTLS.x509_intermediate_ca.pem \ - -CAkey axTLS.key_intermediate_ca.pem \ - -extfile ./certs.conf -extensions v3_usr_cert -# basic constraint path len failure -openssl x509 -req -in axTLS.x509_end_chain.csr \ - -out axTLS.x509_end_chain_bad.pem \ - -sha256 -CAcreateserial -days 5000 \ - -CA axTLS.x509_intermediate_ca2.pem \ - -CAkey axTLS.key_intermediate_ca2.pem \ - -extfile ./certs.conf -extensions v3_usr_cert -cat axTLS.x509_intermediate_ca.pem >> axTLS.x509_intermediate_ca2.pem -openssl x509 -req -in axTLS.x509_aes128.csr \ - -out axTLS.x509_aes128.pem \ - -sha1 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem -openssl x509 -req -in axTLS.x509_aes256.csr \ - -out axTLS.x509_aes256.pem \ - -sha1 -CAcreateserial -days 5000 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem - -# note: must be root to do this -DATE_NOW=`date` -if date -s "Jan 1 2025"; then -openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_bad_before.pem \ - -sha1 -CAcreateserial -days 365 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem -date -s "$DATE_NOW" -touch axTLS.x509_bad_before.pem -fi -openssl x509 -req -in axTLS.x509_1024.csr -out axTLS.x509_bad_after.pem \ - -sha1 -CAcreateserial -days -365 \ - -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem - -# some cleanup -rm axTLS*.csr -rm *.srl -rm *.conf - -# need this for the client tests -openssl x509 -in axTLS.ca_x509.pem -outform DER -out axTLS.ca_x509.cer -openssl x509 -in axTLS.x509_1024.pem -outform DER -out axTLS.x509_1024.cer -openssl x509 -in axTLS.x509_2048.pem -outform DER -out axTLS.x509_2048.cer -openssl x509 -in axTLS.x509_4096.pem -outform DER -out axTLS.x509_4096.cer - -# generate pkcs8 files (use RC4-128 for encryption) -openssl pkcs8 -in axTLS.key_1024.pem -passout pass:abcd -topk8 -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted_pem.p8 -openssl pkcs8 -in axTLS.key_1024.pem -passout pass:abcd -topk8 -outform DER -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted.p8 -openssl pkcs8 -in axTLS.key_1024.pem -nocrypt -topk8 -out axTLS.unencrypted_pem.p8 -openssl pkcs8 -in axTLS.key_1024.pem -nocrypt -topk8 -outform DER -out axTLS.unencrypted.p8 - -# generate pkcs12 files (use RC4-128 for encryption) -openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -certfile axTLS.ca_x509.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -name "p12_with_CA" -out axTLS.withCA.p12 -password pass:abcd -openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -name "p12_without_CA" -out axTLS.withoutCA.p12 -password pass:abcd -openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -out axTLS.noname.p12 -password pass:abcd - -# PEM certificate chain -cat axTLS.ca_x509.pem >> axTLS.x509_device.pem - -# set default key/cert for use in the server -xxd -i axTLS.x509_1024.cer | sed -e \ - "s/axTLS_x509_1024_cer/default_certificate/" > ../../ssl/cert.h -xxd -i axTLS.key_1024 | sed -e \ - "s/axTLS_key_1024/default_private_key/" > ../../ssl/private_key.h diff --git a/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca b/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca deleted file mode 100644 index b90803452b6cd92749d3e34c60420fd20e5b1c4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1046 zcmXqLVi7WEV*0g!nTe5!iJ##hL${4hhu}rKZ^>`&I~ee?acZ@Bw0-AgWMpAwFeot8 zHqc~a4rSpMR&vfSs4U7%&nQvQNY+#^w6ru=@Xbsv$}i4OD^YOHFDlS8lrxZlC>BMP z$uCMQ$;{6)R5XwW$ukQ}AmoGc^Gg&QOG`5Hi!w_p4dldmEzJ!K4Gj#;4S*m@oY%;} z(8$;j${hd~H8Cn72MZ%B19KB2KZ8LNBNtN>BO}8~ro9IXo>_nLlh&9&y&}%w)uNTX zs_{SmP4!v4{omY03U)Pti)JtCPcX{9=#*0VZcW+AkXxT#&uNqCpWl+U`Dk`klJYfK zn|u6>lU__avR^lC)~pP*nHQ{d_Va9wP&?@MoXgH)n$AiM%N1`to1GrF@b8|L6PmcD zsb*n!o!TfGUH;@z+EkjRPZ-kzwi!?gPD_ zr%RZ=-NC4Gqg?QFOoGw;dEBS%SSNP$pR{_W_~}FVWSy-G+)pIE|8xC}wRO}=vyjYx zD!KM2&#bz~T65R1*LJ=@LDuenLjDq&2mV}eek>TJ;QuPAdi^TN6WZpgy8BWW3U#US zColdUBJ)%6pZD?vZDNP*#d?OS@s7n znRPvI6k1`LC7pHK^x+j5mM1G*Sx!V5Tjcr5@Fs2NTGVs-YKXntS((sf1-FH)+9#LJ IUw&x;05YnPSO5S3 diff --git a/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem b/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem deleted file mode 100644 index 478e60b..0000000 --- a/user/mpy/lib/axtls/ssl/test/microsoft.x509_ca.pem +++ /dev/null @@ -1,24 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEEjCCAvqgAwIBAgIPAMEAizw8iBHRPvZj7N9AMA0GCSqGSIb3DQEBBAUAMHAx -KzApBgNVBAsTIkNvcHlyaWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAc -BgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8GA1UEAxMYTWljcm9zb2Z0 -IFJvb3QgQXV0aG9yaXR5MB4XDTk3MDExMDA3MDAwMFoXDTIwMTIzMTA3MDAwMFow -cDErMCkGA1UECxMiQ29weXJpZ2h0IChjKSAxOTk3IE1pY3Jvc29mdCBDb3JwLjEe -MBwGA1UECxMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSEwHwYDVQQDExhNaWNyb3Nv -ZnQgUm9vdCBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB -AQCpAr3BcOY78k4bKJ+XeF4w6qKpjSVf+P6VTKO3/p2iID58UaKboo9gMmvRQmR5 -7qx2yVTa8uuchhyPn4Rms8VremIj1h083g8BkuiWxL8tZpqaaCaZ0Dosvwy1WCbB -RucKPjiWLKkoOajsSYNC44QPu5psVWGsgnyhYC13TOmZtGQ7mlAcMQgkFJ+p55Er -GOY9mGMUYFgFZZ8dN1KH96fvlALGG9O/VUWziYC/OuxUlE6u/ad6bXROrxjMlgko -IQBXkGBpN7tLEgc8Vv9b+6RmCgim0oFWV++2O14WgXcE2va+roCV/rDNf9anGnJc -PMq88AijIjCzBoXJsyB3E4XfAgMBAAGjgagwgaUwgaIGA1UdAQSBmjCBl4AQW9Bw -72lyniNRfhSyTY7/y6FyMHAxKzApBgNVBAsTIkNvcHlyaWdodCAoYykgMTk5NyBN -aWNyb3NvZnQgQ29ycC4xHjAcBgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEh -MB8GA1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5gg8AwQCLPDyIEdE+9mPs -30AwDQYJKoZIhvcNAQEEBQADggEBAJXoC8CN85cYNe24ASTYdxHzXGAyn54Lyz4F -kYiPyTrmIfLwV5MstaBHyGLv/NfMOztaqTZUaf4kbT/JzKreBXzdMY09nxBwarv+ -Ek8YacD80EPjEVogT+pie6+qGcgrNyUtvmWhEoolD2Oj91Qc+SHJ1hXzUqxuQzIH -/YIX+OVnbA1R9r3xUse958Qw/CAxCYgdlSkaTdUdAqXxgOADtFv0sd3IV+5lScdS -VLa0AygS/5DW8AiPfriXxas3LOR65Kh343agANBqP8HSNorgQRKoNWobats14dQc -BOSoRQTIWjM4bk0cDWK3CqKM09VUP0bNHFWmcNsSOoeTdZ+n0qA= ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/ms_iis.cer b/user/mpy/lib/axtls/ssl/test/ms_iis.cer deleted file mode 100755 index 250b926..0000000 --- a/user/mpy/lib/axtls/ssl/test/ms_iis.cer +++ /dev/null @@ -1,13 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIB5jCCAVOgAwIBAgIQWPe7KyA+U7lLUohulwW2HDAJBgUrDgMCHQUAMCExHzAd -BgNVBAMTFmF4dGxzLmNlcm9jY2x1Yi5jb20uYXUwHhcNMDgwMzE3MTAyMTA2WhcN -MDkwMzE3MTAyMTA2WjAhMR8wHQYDVQQDExZheHRscy5jZXJvY2NsdWIuY29tLmF1 -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9JqHlQjrQMt3JW8yxcGhFagDa -D4QiIY8+KItTt13fIBt5g1AG4VXniaylSqKKYNPwVzqSWl7WhxMmoFU73veF8o4M -G0Zc5qbVB6ukrSV4WaTgHrIO6pWkyiaQ4L/eYfCo/2pByhl0IUKkf/TMN346/rFg -JgrElx01l6QHNQrzVQIDAQABoycwJTATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNV -HQ8EBwMFALAAAAAwCQYFKw4DAh0FAAOBgQAbH94H1fryngROJ//Oa0D3vvTO8CJ3 -8VW+3gQEwrPBOWmN6RV8OM0dE6pf8wD3s7PTCcM5+/HI1Qk53nUGrNiOmKM1s0JB -bvsO9RT+UF8mtdbo/n30M0MHMWPCC76baW3R+ANBp/V/z4l1ytpUTt+MHvz0VlUs -J4uJA3s3uh23Tg== ------END CERTIFICATE----- diff --git a/user/mpy/lib/axtls/ssl/test/perf_bigint.c b/user/mpy/lib/axtls/ssl/test/perf_bigint.c deleted file mode 100644 index 6336d1b..0000000 --- a/user/mpy/lib/axtls/ssl/test/perf_bigint.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2007, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Some performance testing of bigint. - */ - -#include -#include -#include - -#include "os_port.h" -#include "ssl.h" - -/************************************************************************** - * BIGINT tests - * - **************************************************************************/ - -int main(int argc, char *argv[]) -{ -#ifdef CONFIG_SSL_CERT_VERIFICATION - RSA_CTX *rsa_ctx = NULL; - BI_CTX *ctx; - bigint *bi_data, *bi_res; - float diff; - int res = 1; - struct timeval tv_old, tv_new; - const char *plaintext; - uint8_t compare[MAX_KEY_BYTE_SIZE]; - int i, max_biggie = 10; /* really crank performance */ - int len; - uint8_t *buf; - - /** - * 512 bit key - */ - plaintext = /* 64 byte number */ - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; - - len = get_file("../ssl/test/axTLS.key_512", &buf); - asn1_get_private_key(buf, len, &rsa_ctx); - ctx = rsa_ctx->bi_ctx; - bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); - bi_res = RSA_public(rsa_ctx, bi_data); - bi_data = bi_res; /* reuse again */ - - gettimeofday(&tv_old, NULL); - for (i = 0; i < max_biggie; i++) - { - bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); - if (i < max_biggie-1) - { - bi_free(ctx, bi_res); - } - } - - gettimeofday(&tv_new, NULL); - bi_free(ctx, bi_data); - - diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + - (tv_new.tv_usec-tv_old.tv_usec)/1000; - printf("512 bit decrypt time: %.2fms\n", diff/max_biggie); - TTY_FLUSH(); - bi_export(ctx, bi_res, compare, 64); - RSA_free(rsa_ctx); - free(buf); - if (memcmp(plaintext, compare, 64) != 0) - goto end; - - /** - * 1024 bit key - */ - plaintext = /* 128 byte number */ - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; - - len = get_file("../ssl/test/axTLS.key_1024", &buf); - rsa_ctx = NULL; - asn1_get_private_key(buf, len, &rsa_ctx); - ctx = rsa_ctx->bi_ctx; - bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); - bi_res = RSA_public(rsa_ctx, bi_data); - bi_data = bi_res; /* reuse again */ - - gettimeofday(&tv_old, NULL); - for (i = 0; i < max_biggie; i++) - { - bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); - if (i < max_biggie-1) - { - bi_free(ctx, bi_res); - } - } - - gettimeofday(&tv_new, NULL); - bi_free(ctx, bi_data); - - diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + - (tv_new.tv_usec-tv_old.tv_usec)/1000; - printf("1024 bit decrypt time: %.2fms\n", diff/max_biggie); - TTY_FLUSH(); - bi_export(ctx, bi_res, compare, 128); - RSA_free(rsa_ctx); - free(buf); - if (memcmp(plaintext, compare, 128) != 0) - goto end; - - /** - * 2048 bit key - */ - plaintext = /* 256 byte number */ - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; - - len = get_file("../ssl/test/axTLS.key_2048", &buf); - rsa_ctx = NULL; - asn1_get_private_key(buf, len, &rsa_ctx); - ctx = rsa_ctx->bi_ctx; - bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); - bi_res = RSA_public(rsa_ctx, bi_data); - bi_data = bi_res; /* reuse again */ - - gettimeofday(&tv_old, NULL); - for (i = 0; i < max_biggie; i++) - { - bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); - if (i < max_biggie-1) - { - bi_free(ctx, bi_res); - } - } - gettimeofday(&tv_new, NULL); - bi_free(ctx, bi_data); - - diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + - (tv_new.tv_usec-tv_old.tv_usec)/1000; - printf("2048 bit decrypt time: %.2fms\n", diff/max_biggie); - TTY_FLUSH(); - bi_export(ctx, bi_res, compare, 256); - RSA_free(rsa_ctx); - free(buf); - if (memcmp(plaintext, compare, 256) != 0) - goto end; - - /** - * 4096 bit key - */ - plaintext = /* 512 byte number */ - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^" - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*^"; - - len = get_file("../ssl/test/axTLS.key_4096", &buf); - rsa_ctx = NULL; - asn1_get_private_key(buf, len, &rsa_ctx); - ctx = rsa_ctx->bi_ctx; - bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); - gettimeofday(&tv_old, NULL); - bi_res = RSA_public(rsa_ctx, bi_data); - gettimeofday(&tv_new, NULL); - diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + - (tv_new.tv_usec-tv_old.tv_usec)/1000; - printf("4096 bit encrypt time: %.2fms\n", diff); - TTY_FLUSH(); - bi_data = bi_res; /* reuse again */ - - gettimeofday(&tv_old, NULL); - for (i = 0; i < max_biggie; i++) - { - bi_res = RSA_private(rsa_ctx, bi_copy(bi_data)); - if (i < max_biggie-1) - { - bi_free(ctx, bi_res); - } - } - - gettimeofday(&tv_new, NULL); - bi_free(ctx, bi_data); - - diff = (tv_new.tv_sec-tv_old.tv_sec)*1000 + - (tv_new.tv_usec-tv_old.tv_usec)/1000; - printf("4096 bit decrypt time: %.2fms\n", diff/max_biggie); - TTY_FLUSH(); - bi_export(ctx, bi_res, compare, 512); - RSA_free(rsa_ctx); - free(buf); - if (memcmp(plaintext, compare, 512) != 0) - goto end; - - /* done */ - printf("Bigint performance testing complete\n"); - res = 0; - -end: - return res; -#else - return 0; -#endif -} diff --git a/user/mpy/lib/axtls/ssl/test/qualityssl.com.der b/user/mpy/lib/axtls/ssl/test/qualityssl.com.der deleted file mode 100644 index c73b246440aed171f9e8baa9f1963c6981945fb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1385 zcmXqLVofz@V)0$T%*4pVB*2;)`+UuO=IctEE2C}NI+_i5**LY@JlekVGBUEVG8i;Y zH{>?pWMd9xVH0Kw4TfJijR0P|-jhB+o4@kx^1oV5P5LUS6(OTAW%`QdC-8qL-YX zYbb9Z3sS-?EEXE#rwcN|EwiY&MAsv+D5X5HDAhntoY%k-2#pNDAWEFq&;-OaGB&j| zwTv=oya#hE(B&@PhP(#cAOi)3S&Yn#ObxjVI6zzuVMbj;5d$F*n_ZYYEHNi1HLo}+ zF*Vyz%0L1n$|)@9mztB4nVnjen3|WKTB2ZRWGHMP2$JIx=5op`am`E5%u6kX333Z_ z1(qh}0K*|T*azkhZeg*2qWrSVl++Z3q)G)OT`~qzAfvd2g%P?G!ZUMHl7T)olr#_r z$uf%wXz3L~Of4?X0fmr3<9y`EVq|4tZtMj{SSM3sBg5`nnJKJ07Hqy6pyHLVUvwd3 z@~>YS$_!^sg3J_F?3&asrlD&(tI7XYeTYKsT^^MMlKQI7tC^qLoj7vl|N4rgqv4&7 z!E9wY3_1?GSxhJVyl~7*o=NEU=T)maZ!phzb2CM^&rssSS)ZE2I~F8IsfOBj$6r?{ zF*#=%c9tcsGvH&kULvAAuuVR+&Y@K&(MzVNtxAw8jkQsj=+lS6ipe z^}cl26&%&Fd@N!tBCo_AG)l+3O3gaJFj@ale%`%lX>SbpfI%S3&&c?ng@u`kb%6m7 zh%XG{GZ`>IG^?_R8HliPXtM!REju$KoW*3|22!lRVsBt;V9mw@RKUWx$&itWk(tFn z+dvbhkcm-D7L*o?fr+s=HMz7X6%@w#DfxPNsU`Z(0l@~0?i@dO&psKz$30+6*vsf^EU0uMp-=Mn;xYgJhsjpk6g#YSV|C z2F^Js?r=;=2?1rP;MAhB)FNj`pd(5QRN$H!+h7?mKe@O7>SKs6475T16=YE{P-?$1?wo@z>i|9+~!DQVdb$zhdFPbbjeVz2aw9=Am=6Z-;U6 z|F>9q<}bL2pT$;l&p_UnL$%W88hLxTb-d_1NV7 z5vx7lh|YY~@$^u!tXR95RjB_Ln|2=Syaf4&D?T>;^EGyAxV=4)>HYDKrcYa=n;bdT zD1_gVIX$B?$mr*qC0U=IFPUawmVUQ6EAPkWtjR+Ab~fHD=a}%eSF`D(HiO5};&o+v z&!=k&N1dwdc6(Y{w23{{=0l>Iu~pl_{j_`!T z;QZvw)RI&M_td=9qQsn3Lm2}pu`Kb zlb2eeSDc@mo|>nZoS$pZI3GE97+D#Z8+#dmE@WzKWVoD|Jf%l(uZI1`=4qA=*RJJA z?chpsFj>bp<>2Cnn~pKH_~~}+WSdv5Vp-g~=R*{W@9c}qf6Ug-cl@VZLQQ_OCeH@^h`oXZ!fnJj3XJKJxVqIWh1LDZD zm>L)x7%tFXpxdUMQBqQ1rLUh{l%ofXrp)5Zbg*Cbf$tUR59|fBpSpoj9n0I5NQx@ z5Gux*nVXoNs-K>jW}s*wZ@|vRs?EpDB*h}q|Map{+nV0K?8E09vaWbY=u}JU8K{aW zL+t=2fqWD@^vjCDVjz=Ha|v@D1BdA4&`;!%a z`ZjicJXrPWUp61x_6yT?-1OPGnCp)Bskw&pd3$HgaIL> -#include -#include -#include -#include -#include -#include - -#ifndef WIN32 -#include -#endif - -#include "os_port.h" -#include "ssl.h" - -#define DEFAULT_CERT "../ssl/test/axTLS.x509_1024.cer" -#define DEFAULT_KEY "../ssl/test/axTLS.key_1024" -//#define DEFAULT_SVR_OPTION SSL_DISPLAY_BYTES|SSL_DISPLAY_STATES -#define DEFAULT_SVR_OPTION 0 -//#define DEFAULT_CLNT_OPTION SSL_DISPLAY_BYTES|SSL_DISPLAY_STATES -#define DEFAULT_CLNT_OPTION 0 - -/* hack to remove gcc warning */ -#define SYSTEM(A) if (system(A) < 0) printf("system call error\n"); - -static int g_port = 19001; - -/************************************************************************** - * AES tests - * - * Run through a couple of the RFC3602 tests to verify that AES is correct. - **************************************************************************/ -#define TEST1_SIZE 16 -#define TEST2_SIZE 32 - -static int AES_test(BI_CTX *bi_ctx) -{ - AES_CTX aes_key; - int res = 1; - uint8_t key[TEST1_SIZE]; - uint8_t iv[TEST1_SIZE]; - - { - /* - Case #1: Encrypting 16 bytes (1 block) using AES-CBC - Key : 0x06a9214036b8a15b512e03d534120006 - IV : 0x3dafba429d9eb430b422da802c9fac41 - Plaintext : "Single block msg" - Ciphertext: 0xe353779c1079aeb82708942dbe77181a - - */ - char *in_str = "Single block msg"; - uint8_t ct[TEST1_SIZE]; - uint8_t enc_data[TEST1_SIZE]; - uint8_t dec_data[TEST1_SIZE]; - - bigint *key_bi = bi_str_import( - bi_ctx, "06A9214036B8A15B512E03D534120006"); - bigint *iv_bi = bi_str_import( - bi_ctx, "3DAFBA429D9EB430B422DA802C9FAC41"); - bigint *ct_bi = bi_str_import( - bi_ctx, "E353779C1079AEB82708942DBE77181A"); - bi_export(bi_ctx, key_bi, key, TEST1_SIZE); - bi_export(bi_ctx, iv_bi, iv, TEST1_SIZE); - bi_export(bi_ctx, ct_bi, ct, TEST1_SIZE); - - AES_set_key(&aes_key, key, iv, AES_MODE_128); - AES_cbc_encrypt(&aes_key, (const uint8_t *)in_str, - enc_data, sizeof(enc_data)); - if (memcmp(enc_data, ct, sizeof(ct))) - { - printf("Error: AES ENCRYPT #1 failed\n"); - goto end; - } - - AES_set_key(&aes_key, key, iv, AES_MODE_128); - AES_convert_key(&aes_key); - AES_cbc_decrypt(&aes_key, enc_data, dec_data, sizeof(enc_data)); - - if (memcmp(dec_data, in_str, sizeof(dec_data))) - { - printf("Error: AES DECRYPT #1 failed\n"); - goto end; - } - } - - { - /* - Case #2: Encrypting 32 bytes (2 blocks) using AES-CBC - Key : 0xc286696d887c9aa0611bbb3e2025a45a - IV : 0x562e17996d093d28ddb3ba695a2e6f58 - Plaintext : 0x000102030405060708090a0b0c0d0e0f - 101112131415161718191a1b1c1d1e1f - Ciphertext: 0xd296cd94c2cccf8a3a863028b5e1dc0a - 7586602d253cfff91b8266bea6d61ab1 - */ - uint8_t in_data[TEST2_SIZE]; - uint8_t ct[TEST2_SIZE]; - uint8_t enc_data[TEST2_SIZE]; - uint8_t dec_data[TEST2_SIZE]; - - bigint *in_bi = bi_str_import(bi_ctx, - "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); - bigint *key_bi = bi_str_import( - bi_ctx, "C286696D887C9AA0611BBB3E2025A45A"); - bigint *iv_bi = bi_str_import( - bi_ctx, "562E17996D093D28DDB3BA695A2E6F58"); - bigint *ct_bi = bi_str_import(bi_ctx, - "D296CD94C2CCCF8A3A863028B5E1DC0A7586602D253CFFF91B8266BEA6D61AB1"); - bi_export(bi_ctx, in_bi, in_data, TEST2_SIZE); - bi_export(bi_ctx, key_bi, key, TEST1_SIZE); - bi_export(bi_ctx, iv_bi, iv, TEST1_SIZE); - bi_export(bi_ctx, ct_bi, ct, TEST2_SIZE); - - AES_set_key(&aes_key, key, iv, AES_MODE_128); - AES_cbc_encrypt(&aes_key, (const uint8_t *)in_data, - enc_data, sizeof(enc_data)); - - if (memcmp(enc_data, ct, sizeof(ct))) - { - printf("Error: ENCRYPT #2 failed\n"); - goto end; - } - - AES_set_key(&aes_key, key, iv, AES_MODE_128); - AES_convert_key(&aes_key); - AES_cbc_decrypt(&aes_key, enc_data, dec_data, sizeof(enc_data)); - if (memcmp(dec_data, in_data, sizeof(dec_data))) - { - printf("Error: DECRYPT #2 failed\n"); - goto end; - } - } - - res = 0; - printf("All AES tests passed\n"); - -end: - return res; -} - -/************************************************************************** - * SHA1 tests - * - * Run through a couple of the RFC3174 tests to verify that SHA1 is correct. - **************************************************************************/ -static int SHA1_test(BI_CTX *bi_ctx) -{ - SHA1_CTX ctx; - uint8_t ct[SHA1_SIZE]; - uint8_t digest[SHA1_SIZE]; - int res = 1; - - { - const char *in_str = "abc"; - bigint *ct_bi = bi_str_import(bi_ctx, - "A9993E364706816ABA3E25717850C26C9CD0D89D"); - bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); - - SHA1_Init(&ctx); - SHA1_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA1_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA1 #1 failed\n"); - goto end; - } - } - - { - const char *in_str = - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - bigint *ct_bi = bi_str_import(bi_ctx, - "84983E441C3BD26EBAAE4AA1F95129E5E54670F1"); - bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); - - SHA1_Init(&ctx); - SHA1_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA1_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA1 #2 failed\n"); - goto end; - } - } - - res = 0; - printf("All SHA1 tests passed\n"); - -end: - return res; -} - -/************************************************************************** - * SHA256 tests - * - * Run through a couple of the SHA-2 tests to verify that SHA256 is correct. - **************************************************************************/ -static int SHA256_test(BI_CTX *bi_ctx) -{ - SHA256_CTX ctx; - uint8_t ct[SHA256_SIZE]; - uint8_t digest[SHA256_SIZE]; - int res = 1; - - { - const char *in_str = "abc"; - bigint *ct_bi = bi_str_import(bi_ctx, - "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD"); - bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); - - SHA256_Init(&ctx); - SHA256_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA256_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA256 #1 failed\n"); - goto end; - } - } - - { - const char *in_str = - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - bigint *ct_bi = bi_str_import(bi_ctx, - "248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1"); - bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); - - SHA256_Init(&ctx); - SHA256_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA256_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA256 #2 failed\n"); - goto end; - } - } - - res = 0; - printf("All SHA256 tests passed\n"); - -end: - return res; -} - -/************************************************************************** - * SHA384 tests - * - * Run through a couple of the SHA-2 tests to verify that SHA384 is correct. - **************************************************************************/ -static int SHA384_test(BI_CTX *bi_ctx) -{ - SHA384_CTX ctx; - uint8_t ct[SHA384_SIZE]; - uint8_t digest[SHA384_SIZE]; - int res = 1; - - { - const char *in_str = "abc"; - bigint *ct_bi = bi_str_import(bi_ctx, - "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7"); - bi_export(bi_ctx, ct_bi, ct, SHA384_SIZE); - - SHA384_Init(&ctx); - SHA384_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA384_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA384 #1 failed\n"); - goto end; - } - } - - { - const char *in_str = - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - bigint *ct_bi = bi_str_import(bi_ctx, - "3391FDDDFC8DC7393707A65B1B4709397CF8B1D162AF05ABFE8F450DE5F36BC6B0455A8520BC4E6F5FE95B1FE3C8452B"); - bi_export(bi_ctx, ct_bi, ct, SHA384_SIZE); - - SHA384_Init(&ctx); - SHA384_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA384_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA384 #2 failed\n"); - goto end; - } - } - - res = 0; - printf("All SHA384 tests passed\n"); - -end: - return res; -} -/************************************************************************** - * SHA512 tests - * - * Run through a couple of the SHA-2 tests to verify that SHA512 is correct. - **************************************************************************/ -static int SHA512_test(BI_CTX *bi_ctx) -{ - SHA512_CTX ctx; - uint8_t ct[SHA512_SIZE]; - uint8_t digest[SHA512_SIZE]; - int res = 1; - - { - const char *in_str = "abc"; - bigint *ct_bi = bi_str_import(bi_ctx, - "DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F"); - bi_export(bi_ctx, ct_bi, ct, SHA512_SIZE); - - SHA512_Init(&ctx); - SHA512_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA512_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA512 #1 failed\n"); - goto end; - } - } - - { - const char *in_str = - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - bigint *ct_bi = bi_str_import(bi_ctx, - "204A8FC6DDA82F0A0CED7BEB8E08A41657C16EF468B228A8279BE331A703C33596FD15C13B1B07F9AA1D3BEA57789CA031AD85C7A71DD70354EC631238CA3445"); - bi_export(bi_ctx, ct_bi, ct, SHA512_SIZE); - - SHA512_Init(&ctx); - SHA512_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - SHA512_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: SHA512 #2 failed\n"); - goto end; - } - } - - res = 0; - printf("All SHA512 tests passed\n"); - -end: - return res; -} -/************************************************************************** - * MD5 tests - * - * Run through a couple of the RFC1321 tests to verify that MD5 is correct. - **************************************************************************/ -static int MD5_test(BI_CTX *bi_ctx) -{ - MD5_CTX ctx; - uint8_t ct[MD5_SIZE]; - uint8_t digest[MD5_SIZE]; - int res = 1; - - { - const char *in_str = "abc"; - bigint *ct_bi = bi_str_import(bi_ctx, - "900150983CD24FB0D6963F7D28E17F72"); - bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); - - MD5_Init(&ctx); - MD5_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - MD5_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: MD5 #1 failed\n"); - goto end; - } - } - - { - const char *in_str = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - bigint *ct_bi = bi_str_import( - bi_ctx, "D174AB98D277D9F5A5611C2C9F419D9F"); - bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); - - MD5_Init(&ctx); - MD5_Update(&ctx, (const uint8_t *)in_str, strlen(in_str)); - MD5_Final(digest, &ctx); - - if (memcmp(digest, ct, sizeof(ct))) - { - printf("Error: MD5 #2 failed\n"); - goto end; - } - } - res = 0; - printf("All MD5 tests passed\n"); - -end: - return res; -} - -/************************************************************************** - * HMAC tests - * - * Run through a couple of the RFC2202 tests to verify that HMAC is correct. - **************************************************************************/ -static int HMAC_test(BI_CTX *bi_ctx) -{ - uint8_t key[SHA256_SIZE]; - uint8_t ct[SHA256_SIZE]; - uint8_t dgst[SHA256_SIZE]; - int res = 1; - const char *key_str; - - const char *data_str = "Hi There"; - bigint *key_bi = bi_str_import(bi_ctx, "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); - bigint *ct_bi = bi_str_import(bi_ctx, "9294727A3638BB1C13F48EF8158BFC9D"); - bi_export(bi_ctx, key_bi, key, MD5_SIZE); - bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); - hmac_md5((const uint8_t *)data_str, 8, key, MD5_SIZE, dgst); - if (memcmp(dgst, ct, MD5_SIZE)) - { - printf("HMAC MD5 #1 failed\n"); - goto end; - } - - data_str = "what do ya want for nothing?"; - key_str = "Jefe"; - ct_bi = bi_str_import(bi_ctx, "750C783E6AB0B503EAA86E310A5DB738"); - bi_export(bi_ctx, ct_bi, ct, MD5_SIZE); - hmac_md5((const uint8_t *)data_str, 28, (const uint8_t *)key_str, 4, dgst); - if (memcmp(dgst, ct, MD5_SIZE)) - { - printf("HMAC MD5 #2 failed\n"); - goto end; - } - - data_str = "Hi There"; - key_bi = bi_str_import(bi_ctx, "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); - ct_bi = bi_str_import(bi_ctx, "B617318655057264E28BC0B6FB378C8EF146BE00"); - bi_export(bi_ctx, key_bi, key, SHA1_SIZE); - bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); - - hmac_sha1((const uint8_t *)data_str, 8, - (const uint8_t *)key, SHA1_SIZE, dgst); - if (memcmp(dgst, ct, SHA1_SIZE)) - { - printf("HMAC SHA1 #1 failed\n"); - goto end; - } - - data_str = "what do ya want for nothing?"; - key_str = "Jefe"; - ct_bi = bi_str_import(bi_ctx, "EFFCDF6AE5EB2FA2D27416D5F184DF9C259A7C79"); - bi_export(bi_ctx, ct_bi, ct, SHA1_SIZE); - - hmac_sha1((const uint8_t *)data_str, 28, (const uint8_t *)key_str, 4, dgst); - if (memcmp(dgst, ct, SHA1_SIZE)) - { - printf("HMAC SHA1 #2 failed\n"); - goto end; - } - - data_str = "Hi There"; - key_bi = bi_str_import(bi_ctx, "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); - ct_bi = bi_str_import(bi_ctx, - "B0344C61D8DB38535CA8AFCEAF0BF12B881DC200C9833DA726E9376C2E32CFF7"); - bi_export(bi_ctx, key_bi, key, 20); - bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); - - hmac_sha256((const uint8_t *)data_str, 8, - (const uint8_t *)key, 20, dgst); - - if (memcmp(dgst, ct, SHA256_SIZE)) - { - printf("HMAC SHA256 #1 failed\n"); - goto end; - } - - data_str = "what do ya want for nothing?"; - key_str = "Jefe"; - ct_bi = bi_str_import(bi_ctx, - "5BDCC146BF60754E6A042426089575C75A003F089D2739839DEC58B964EC3843"); - bi_export(bi_ctx, ct_bi, ct, SHA256_SIZE); - - hmac_sha256((const uint8_t *)data_str, 28, - (const uint8_t *)key_str, 4, dgst); - if (memcmp(dgst, ct, SHA256_SIZE)) - { - printf("HMAC SHA256 #2 failed\n"); - goto end; - } - - // other test - /*uint8_t secret[16]; - key_str = "9BBE436BA940F017B17652849A71DB35"; - ct_bi = bi_str_import(bi_ctx, key_str); - bi_export(bi_ctx, ct_bi, secret, 16); - - uint8_t random[26]; - data_str = "74657374206C6162656CA0BA9F936CDA311827A6F796FFD5198C"; - ct_bi = bi_str_import(bi_ctx, data_str); - bi_export(bi_ctx, ct_bi, random, 26); - - uint8_t output[256]; - p_hash_sha256(secret, 16, random, 26, output, 100); - ct_bi = bi_import(bi_ctx, output, 100); - bi_print("RESULT", ct_bi); - */ - - /*uint8_t secret[48]; - uint8_t random[256]; - uint8_t output[256]; - - key_str = - "8C6D256467157DAEC7BAEBC1371E6DABFF1AB686EFA7DCF6B65242AA6EEBFC0A7472A1E583C4F2B23F784F25A6DE05A6"; - ct_bi = bi_str_import(bi_ctx, key_str); - bi_export(bi_ctx, ct_bi, secret, 48); - - data_str = - "636C69656E742066696E697368656475F80B2E4375CFA44105D16694A5E2D232302FF27241BDF52BA681C13E2CDF9F"; - ct_bi = bi_str_import(bi_ctx, data_str); - bi_export(bi_ctx, ct_bi, random, 47); - - p_hash_sha256(secret, 48, random, 47, output, 12); - ct_bi = bi_import(bi_ctx, output, 12); - bi_print("RESULT1", ct_bi);*/ - - res = 0; - printf("All HMAC tests passed\n"); - -end: - return res; -} - -/************************************************************************** - * BIGINT tests - * - **************************************************************************/ -static int BIGINT_test(BI_CTX *ctx) -{ - int res = 1; - -#ifndef CONFIG_INTEGER_8BIT -#ifndef CONFIG_INTEGER_16BIT - bigint *bi_data, *bi_exp, *bi_res; - const char *expnt, *plaintext, *mod; - uint8_t compare[MAX_KEY_BYTE_SIZE]; - /** - * 512 bit key - */ - plaintext = /* 64 byte number */ - "01aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee"; - - mod = "C30773C8ABE09FCC279EE0E5343370DE" - "8B2FFDB6059271E3005A7CEEF0D35E0A" - "1F9915D95E63560836CC2EB2C289270D" - "BCAE8CAF6F5E907FC2759EE220071E1B"; - - expnt = "A1E556CD1738E10DF539E35101334E97" - "BE8D391C57A5C89A7AD9A2EA2ACA1B3D" - "F3140F5091CC535CBAA47CEC4159EE1F" - "B6A3661AFF1AB758426EAB158452A9B9"; - - bi_data = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext)); - bi_exp = int_to_bi(ctx, 0x10001); - bi_set_mod(ctx, bi_str_import(ctx, mod), 0); - bi_res = bi_mod_power(ctx, bi_data, bi_exp); - - bi_data = bi_res; /* resuse again - see if we get the original */ - - bi_exp = bi_str_import(ctx, expnt); - bi_res = bi_mod_power(ctx, bi_data, bi_exp); - bi_free_mod(ctx, 0); - - bi_export(ctx, bi_res, compare, 64); - if (memcmp(plaintext, compare, 64) != 0) - goto end; -#endif -#endif - - /* - * Multiply with psssible carry issue (8 bit) - */ - { - bigint *bi_x = bi_str_import(ctx, - "AFD5060E224B70DA99EFB385BA5C0D2BEA0AD1DAAA52686E1A02D677BC65C1DA7A496BBDCC02999E8814F10AFC4B8E0DD4E6687E0762CE717A5EA1E452B5C56065C8431F0FB9D23CFF3A4B4149798C0670AF7F9565A0EAE5CF1AB16A1F0C3DD5E485DC5ABB96EBE0B6778A15B7302CBCE358E4BF2E2E30932758AC6EFA9F5828"); - bigint *arg2 = bi_clone(ctx, bi_x); - bigint *arg3 = bi_clone(ctx, bi_x); - bigint *sqr_result = bi_square(ctx, bi_x); - bigint *mlt_result = bi_multiply(ctx, arg2, arg3); - - if (bi_compare(sqr_result, mlt_result) != 0) - { - bi_print("SQR_RESULT", sqr_result); - bi_print("MLT_RESULT", mlt_result); - bi_free(ctx, sqr_result); - bi_free(ctx, mlt_result); - goto end; - } - - bi_free(ctx, sqr_result); - bi_free(ctx, mlt_result); - } - - printf("All BIGINT tests passed\n"); - res = 0; - -end: - return res; -} - -/************************************************************************** - * RSA tests - * - * Use the results from openssl to verify PKCS1 etc - **************************************************************************/ -static int RSA_test(void) -{ - int res = 1; - const char *plaintext = /* 128 byte hex number */ - "1aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee2" - "1aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeee2\012"; - uint8_t enc_data[128], dec_data[128]; - RSA_CTX *rsa_ctx = NULL; - BI_CTX *bi_ctx; - bigint *plaintext_bi; - bigint *enc_data_bi, *dec_data_bi; - uint8_t enc_data2[128], dec_data2[128]; - int len; - uint8_t *buf; - - RNG_initialize(); - - /* extract the private key elements */ - len = get_file("../ssl/test/axTLS.key_1024", &buf); - if (asn1_get_private_key(buf, len, &rsa_ctx) < 0) - { - goto end; - } - - free(buf); - bi_ctx = rsa_ctx->bi_ctx; - plaintext_bi = bi_import(bi_ctx, - (const uint8_t *)plaintext, strlen(plaintext)); - - /* basic rsa encrypt */ - enc_data_bi = RSA_public(rsa_ctx, plaintext_bi); - bi_export(bi_ctx, bi_copy(enc_data_bi), enc_data, sizeof(enc_data)); - - /* basic rsa decrypt */ - dec_data_bi = RSA_private(rsa_ctx, enc_data_bi); - bi_export(bi_ctx, dec_data_bi, dec_data, sizeof(dec_data)); - - if (memcmp(dec_data, plaintext, strlen(plaintext))) - { - printf("Error: DECRYPT #1 failed\n"); - goto end; - } - - if (RSA_encrypt(rsa_ctx, (const uint8_t *)"abc", 3, enc_data2, 0) < 0) - { - printf("Error: ENCRYPT #2 failed\n"); - goto end; - } - - RSA_decrypt(rsa_ctx, enc_data2, dec_data2, sizeof(dec_data2), 1); - if (memcmp("abc", dec_data2, 3)) - { - printf("Error: DECRYPT #2 failed\n"); - goto end; - } - - RSA_free(rsa_ctx); - res = 0; - printf("All RSA tests passed\n"); - -end: - RNG_terminate(); - return res; -} - -/************************************************************************** - * Cert Testing - * - **************************************************************************/ -static int cert_tests(void) -{ - int res = -1, len; - X509_CTX *x509_ctx; - SSL_CTX *ssl_ctx; - uint8_t *buf; - - /* check a bunch of 3rd party certificates */ - ssl_ctx = ssl_ctx_new(0, 0); - len = get_file("../ssl/test/microsoft.x509_ca", &buf); - if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) - { - printf("Cert #1\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - free(buf); - - ssl_ctx = ssl_ctx_new(0, 0); - len = get_file("../ssl/test/thawte.x509_ca", &buf); - if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) - { - printf("Cert #2\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - free(buf); - - ssl_ctx = ssl_ctx_new(0, 0); - len = get_file("../ssl/test/deutsche_telecom.x509_ca", &buf); - if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) - { - printf("Cert #3\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - free(buf); - - ssl_ctx = ssl_ctx_new(0, 0); - len = get_file("../ssl/test/equifax.x509_ca", &buf); - if ((res = add_cert_auth(ssl_ctx, buf, len)) < 0) - { - printf("Cert #4\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - free(buf); - - ssl_ctx = ssl_ctx_new(0, 0); - len = get_file("../ssl/test/gnutls.cer", &buf); - if ((res = add_cert(ssl_ctx, buf, len)) < 0) - { - printf("Cert #5\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - free(buf); - - ssl_ctx = ssl_ctx_new(0, 0); - len = get_file("../ssl/test/socgen.cer", &buf); - if ((res = add_cert(ssl_ctx, buf, len)) < 0) - { - printf("Cert #6\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - free(buf); - - ssl_ctx = ssl_ctx_new(0, 0); - if ((res = ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, - "../ssl/test/camster_duckdns_org.crt", NULL)) != SSL_OK) - { - printf("Cert #7\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - - ssl_ctx = ssl_ctx_new(0, 0); - if ((res = ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, - "../ssl/test/comodo.sha384.cer", NULL)) != SSL_OK) - { - printf("Cert #8\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - - ssl_ctx = ssl_ctx_new(0, 0); - if ((res = ssl_obj_load(ssl_ctx, - SSL_OBJ_X509_CERT, "../ssl/test/ms_iis.cer", NULL)) != SSL_OK) - { - printf("Cert #9\n"); - ssl_display_error(res); - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - - if (get_file("../ssl/test/qualityssl.com.der", &buf) < 0 || - x509_new(buf, &len, &x509_ctx)) - { - printf("Cert #10\n"); - res = -1; - goto bad_cert; - } - - if (strcmp(x509_ctx->subject_alt_dnsnames[1], "qualityssl.com")) - { - printf("Cert #11\n"); - res = -1; - goto bad_cert; - } - x509_free(x509_ctx); - free(buf); - - // this bundle has two DSA (1.2.840.10040.4.3 invalid) certificates - ssl_ctx = ssl_ctx_new(0, 0); - if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, - "../ssl/test/ca-bundle.crt", NULL)) - { - goto bad_cert; - } - - ssl_ctx_free(ssl_ctx); - res = 0; /* all ok */ - printf("All Certificate tests passed\n"); - -bad_cert: - if (res) - printf("Error: A certificate test failed\n"); - - return res; -} - -/** - * init a server socket. - */ -static int server_socket_init(int *port) -{ - struct sockaddr_in serv_addr; - int server_fd; - char yes = 1; - - /* Create socket for incoming connections */ - if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) - { - return -1; - } - - setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); - -go_again: - /* Construct local address structure */ - memset(&serv_addr, 0, sizeof(serv_addr)); /* Zero out structure */ - serv_addr.sin_family = AF_INET; /* Internet address family */ - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */ - serv_addr.sin_port = htons(*port); /* Local port */ - - /* Bind to the local address */ - if (bind(server_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) - { - (*port)++; - goto go_again; - } - /* Mark the socket so it will listen for incoming connections */ - if (listen(server_fd, 3000) < 0) - { - return -1; - } - - return server_fd; -} - -/** - * init a client socket. - */ -static int client_socket_init(uint16_t port) -{ - struct sockaddr_in address; - int client_fd; - - address.sin_family = AF_INET; - address.sin_port = htons(port); - address.sin_addr.s_addr = inet_addr("127.0.0.1"); - client_fd = socket(AF_INET, SOCK_STREAM, 0); - if (connect(client_fd, (struct sockaddr *)&address, sizeof(address)) < 0) - { - perror("socket"); - SOCKET_CLOSE(client_fd); - client_fd = -1; - } - - return client_fd; -} - -/************************************************************************** - * SSL Server Testing - * - **************************************************************************/ -typedef struct -{ - /* not used as yet */ - int dummy; -} SVR_CTX; - -typedef struct -{ - const char *testname; - const char *openssl_option; -} client_t; - -static void do_client(client_t *clnt) -{ - char openssl_buf[2048]; - usleep(200000); /* allow server to start */ - - /* show the session ids in the reconnect test */ - if (strcmp(clnt->testname, "Session Reuse") == 0) - { - sprintf(openssl_buf, "echo \"hello client\" | openssl s_client " - "-connect localhost:%d %s 2>&1 | grep \"Session-ID:\"", - g_port, clnt->openssl_option); - } - else if (strstr(clnt->testname, "GNUTLS") == NULL) - { - sprintf(openssl_buf, "echo \"hello client\" | openssl s_client " -#ifdef WIN32 - "-connect localhost:%d -quiet %s", -#else - "-connect localhost:%d -quiet %s > /dev/null 2>&1", -#endif - g_port, clnt->openssl_option); - } - else /* gnutls */ - { - sprintf(openssl_buf, "echo \"hello client\" | gnutls-cli " -#ifdef WIN32 - "-p %d %s localhost", -#else - "-p %d %s localhost > /dev/null 2>&1", -#endif - g_port, clnt->openssl_option); - } - -//printf("CLIENT %s\n", openssl_buf); - SYSTEM(openssl_buf); -} - -static int SSL_server_test( - const char *testname, - const char *openssl_option, - const char *device_cert, - const char *product_cert, - const char *private_key, - const char *ca_cert, - const char *password, - int axtls_option) -{ - int server_fd, ret = 0; - SSL_CTX *ssl_ctx = NULL; - struct sockaddr_in client_addr; - uint8_t *read_buf; - socklen_t clnt_len = sizeof(client_addr); - client_t client_data; -#ifndef WIN32 - pthread_t thread; -#endif - g_port++; - - client_data.testname = testname; - client_data.openssl_option = openssl_option; - - if ((server_fd = server_socket_init(&g_port)) < 0) - goto error; - - if (private_key) - { - axtls_option |= SSL_NO_DEFAULT_KEY; - } - - if ((ssl_ctx = ssl_ctx_new(axtls_option, SSL_DEFAULT_SVR_SESS)) == NULL) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - - if (private_key) - { - int obj_type = SSL_OBJ_RSA_KEY; - - if (strstr(private_key, ".p8")) - obj_type = SSL_OBJ_PKCS8; - else if (strstr(private_key, ".p12")) - obj_type = SSL_OBJ_PKCS12; - - if (ssl_obj_load(ssl_ctx, obj_type, private_key, password)) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - } - - if (device_cert) /* test chaining */ - { - if ((ret = ssl_obj_load(ssl_ctx, - SSL_OBJ_X509_CERT, device_cert, NULL)) != SSL_OK) - goto error; - } - - if (product_cert) /* test chaining */ - { - if ((ret = ssl_obj_load(ssl_ctx, - SSL_OBJ_X509_CERT, product_cert, NULL)) != SSL_OK) - goto error; - } - - if (ca_cert) /* test adding certificate authorities */ - { - if ((ret = ssl_obj_load(ssl_ctx, - SSL_OBJ_X509_CACERT, ca_cert, NULL)) != SSL_OK) - goto error; - } - -#ifndef WIN32 - pthread_create(&thread, NULL, - (void *(*)(void *))do_client, (void *)&client_data); - pthread_detach(thread); -#else - CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_client, - (LPVOID)&client_data, 0, NULL); -#endif - - for (;;) - { - int client_fd, size = 0; - SSL *ssl; - - /* Wait for a client to connect */ - if ((client_fd = accept(server_fd, - (struct sockaddr *)&client_addr, &clnt_len)) < 0) - { - ret = SSL_ERROR_SOCK_SETUP_FAILURE; - goto error; - } - - /* we are ready to go */ - ssl = ssl_server_new(ssl_ctx, client_fd); - while ((size = ssl_read(ssl, &read_buf)) == SSL_OK); - SOCKET_CLOSE(client_fd); - - if (size == SSL_CLOSE_NOTIFY) - { - /* do nothing */ - } - else if (size < SSL_OK) /* got some alert or something nasty */ - { - ret = size; - - if (ret == SSL_ERROR_CONN_LOST) - continue; - - break; /* we've got a problem */ - } - else /* looks more promising */ - { - if (strstr("hello client", (char *)read_buf) == NULL) - { - printf("SSL server test \"%s\" passed\n", testname); - TTY_FLUSH(); - ret = 0; - break; - } - } - - ssl_free(ssl); - } - - SOCKET_CLOSE(server_fd); - -error: - ssl_ctx_free(ssl_ctx); - return ret; -} - -int SSL_server_tests(void) -{ - int ret = -1; - struct stat stat_buf; - SVR_CTX svr_test_ctx; - memset(&svr_test_ctx, 0, sizeof(SVR_CTX)); - - printf("### starting server tests\n"); TTY_FLUSH(); - - /* Go through the algorithms */ - - /* - * TLS client hello - */ - - /* - * AES128-SHA TLS1.2 - */ - if ((ret = SSL_server_test("AES128-SHA TLS1.2", - "-cipher AES128-SHA -tls1_2", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES256-SHA TLS1.2 - */ - if ((ret = SSL_server_test("AES256-SHA TLS1.2", - "-cipher AES256-SHA -tls1_2", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES128-SHA256 TLS1.2 - */ - if ((ret = SSL_server_test("AES128-SHA256 TLS1.2", - "-cipher AES128-SHA256 -tls1_2", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - - /* - * AES256-SHA256 TLS1.2 - */ - if ((ret = SSL_server_test("AES256-SHA256 TLS1.2", - "-cipher AES256-SHA256 -tls1_2", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES128-SHA TLS1.1 - */ - if ((ret = SSL_server_test("AES128-SHA TLS1.1", - "-cipher AES128-SHA -tls1_1", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES128-SHA TLS1.0 - */ - if ((ret = SSL_server_test("AES128-SHA TLS1.0", - "-cipher AES128-SHA -tls1", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * Session Reuse - * all the session id's should match for session resumption. - */ - if ((ret = SSL_server_test("Session Reuse", - "-cipher AES128-SHA -reconnect -tls1_2", - DEFAULT_CERT, NULL, DEFAULT_KEY, NULL, NULL, - DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * 1024 bit RSA key (check certificate chaining) - */ - if ((ret = SSL_server_test("1024 bit key", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_1024.cer", NULL, - "../ssl/test/axTLS.key_1024", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * 2048 bit RSA key - */ - if ((ret = SSL_server_test("2048 bit key", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_2048.cer", NULL, - "../ssl/test/axTLS.key_2048", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * 4096 bit RSA key - */ - if ((ret = SSL_server_test("4096 bit key", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_4096.cer", NULL, - "../ssl/test/axTLS.key_4096", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * RSA1024/SHA256 - */ - if ((ret = SSL_server_test("RSA1024/SHA256", - "-tls1_2", - "../ssl/test/axTLS.x509_1024_sha256.pem" , NULL, - "../ssl/test/axTLS.key_1024", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * RSA1024/SHA384 - */ - if ((ret = SSL_server_test("RSA1024/SHA384", - "-tls1_2", - "../ssl/test/axTLS.x509_1024_sha384.pem" , NULL, - "../ssl/test/axTLS.key_1024", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * RSA1024/SHA512 - */ - if ((ret = SSL_server_test("RSA1024/SHA512", - "-tls1_2", - "../ssl/test/axTLS.x509_1024_sha512.pem" , NULL, - "../ssl/test/axTLS.key_1024", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * Client Verification - */ - if ((ret = SSL_server_test("Client Verification TLS1.2", - "-cipher AES128-SHA -tls1_2 " - "-cert ../ssl/test/axTLS.x509_2048.pem " - "-key ../ssl/test/axTLS.key_2048.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - "../ssl/test/axTLS.ca_x509.cer", NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) - goto cleanup; - - if ((ret = SSL_server_test("Client Verification TLS1.1", - "-cipher AES128-SHA -tls1_1 " - "-cert ../ssl/test/axTLS.x509_2048.pem " - "-key ../ssl/test/axTLS.key_2048.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - "../ssl/test/axTLS.ca_x509.cer", NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) - goto cleanup; - - /* this test should fail */ - if (stat("../ssl/test/axTLS.x509_bad_before.pem", &stat_buf) >= 0) - { - if ((ret = SSL_server_test("Error: Bad Before Cert", - "-cipher AES128-SHA -tls1_2 " - "-cert ../ssl/test/axTLS.x509_bad_before.pem " - "-key ../ssl/test/axTLS.key_1024.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - "../ssl/test/axTLS.ca_x509.cer", NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != - SSL_X509_ERROR(X509_VFY_ERROR_NOT_YET_VALID)) - goto cleanup; - - printf("SSL server test \"%s\" passed\n", "Bad Before Cert"); - TTY_FLUSH(); - } - - /* this test should fail */ - if ((ret = SSL_server_test("Error: Bad After Cert", - "-cipher AES128-SHA -tls1_2 " - "-cert ../ssl/test/axTLS.x509_bad_after.pem " - "-key ../ssl/test/axTLS.key_1024.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - "../ssl/test/axTLS.ca_x509.cer", NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != - SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED)) - goto cleanup; - - printf("SSL server test \"%s\" passed\n", "Bad After Cert"); - TTY_FLUSH(); - - /* - * No trusted cert - */ - if ((ret = SSL_server_test("Error: No trusted certificate", - "-cipher AES128-SHA -tls1_2 " - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - NULL, NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != - SSL_X509_ERROR(X509_VFY_ERROR_NO_TRUSTED_CERT)) - goto cleanup; - - printf("SSL server test \"%s\" passed\n", "No trusted certificate"); - TTY_FLUSH(); - - /* - * Self-signed (from the server) - */ - if ((ret = SSL_server_test("Error: Self-signed certificate (from server)", - "-cipher AES128-SHA -tls1_2 " - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem " - "-CAfile ../ssl/test/axTLS.ca_x509.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - NULL, NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION)) != - SSL_X509_ERROR(X509_VFY_ERROR_SELF_SIGNED)) - goto cleanup; - - printf("SSL server test \"%s\" passed\n", - "Self-signed certificate (from server)"); - TTY_FLUSH(); - - /* - * Self-signed (from the client) - */ - if ((ret = SSL_server_test("Self-signed certificate (from client)", - "-cipher AES128-SHA -tls1_2 " - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem ", - NULL, - "../ssl/test/axTLS.x509_1024.pem", - "../ssl/test/axTLS.key_1024.pem", - "../ssl/test/axTLS.ca_x509.cer", - NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) - goto cleanup; - - /* - * Key in PEM format - */ - if ((ret = SSL_server_test("Key in PEM format", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_1024.cer", NULL, - "../ssl/test/axTLS.key_1024.pem", NULL, - NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * Cert in PEM format - */ - if ((ret = SSL_server_test("Cert in PEM format", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_1024.pem", NULL, - "../ssl/test/axTLS.key_1024.pem", NULL, - NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * Cert chain in PEM format - */ - if ((ret = SSL_server_test("Cert chain in PEM format", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_device.pem", - NULL, "../ssl/test/axTLS.key_device.pem", - "../ssl/test/axTLS.ca_x509.pem", NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES128 Encrypted key - */ - if ((ret = SSL_server_test("AES128 encrypted key", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_aes128.pem", NULL, - "../ssl/test/axTLS.key_aes128.pem", - NULL, "abcd", DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES256 Encrypted key - */ - if ((ret = SSL_server_test("AES256 encrypted key", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_aes256.pem", NULL, - "../ssl/test/axTLS.key_aes256.pem", - NULL, "abcd", DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * AES128 Encrypted invalid key - */ - if ((ret = SSL_server_test("AES128 encrypted invalid key", - "-cipher AES128-SHA -tls1_2", - "../ssl/test/axTLS.x509_aes128.pem", NULL, - "../ssl/test/axTLS.key_aes128.pem", - NULL, "xyz", DEFAULT_SVR_OPTION)) != SSL_ERROR_INVALID_KEY) - goto cleanup; - - printf("SSL server test \"%s\" passed\n", "AES128 encrypted invalid key"); - TTY_FLUSH(); - - /* - * PKCS#8 key (encrypted) - */ - if ((ret = SSL_server_test("pkcs#8 encrypted", - "-cipher AES128-SHA -tls1_2", - DEFAULT_CERT, NULL, "../ssl/test/axTLS.encrypted.p8", - NULL, "abcd", DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * PKCS#8 key (unencrypted DER format) - */ - if ((ret = SSL_server_test("pkcs#8 DER unencrypted", - "-cipher AES128-SHA -tls1_2", - DEFAULT_CERT, NULL, "../ssl/test/axTLS.unencrypted.p8", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * PKCS#8 key (unencrypted PEM format) - */ - if ((ret = SSL_server_test("pkcs#8 PEM unencrypted", - "-cipher AES128-SHA -tls1_2", - DEFAULT_CERT, NULL, "../ssl/test/axTLS.unencrypted_pem.p8", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * PKCS#12 key/certificate - */ - if ((ret = SSL_server_test("pkcs#12 with CA", "-cipher AES128-SHA", - NULL, NULL, "../ssl/test/axTLS.withCA.p12", - NULL, "abcd", DEFAULT_SVR_OPTION))) - goto cleanup; - - if ((ret = SSL_server_test("pkcs#12 no CA", "-cipher AES128-SHA", - DEFAULT_CERT, NULL, "../ssl/test/axTLS.withoutCA.p12", - NULL, "abcd", DEFAULT_SVR_OPTION))) - goto cleanup; - - /* - * GNUTLS - */ - if ((ret = SSL_server_test("GNUTLS client", - "", - "../ssl/test/axTLS.x509_1024.cer", NULL, - "../ssl/test/axTLS.key_1024", - NULL, NULL, DEFAULT_SVR_OPTION))) - goto cleanup; - - if ((ret = SSL_server_test("GNUTLS client with verify", - "--x509certfile ../ssl/test/axTLS.x509_1024.pem " - "--x509keyfile ../ssl/test/axTLS.key_1024.pem", - "../ssl/test/axTLS.x509_1024.cer", NULL, - "../ssl/test/axTLS.key_1024", - "../ssl/test/axTLS.ca_x509.cer", NULL, - DEFAULT_SVR_OPTION|SSL_CLIENT_AUTHENTICATION))) - goto cleanup; - ret = 0; - -cleanup: - if (ret) - { - printf("Error: A server test failed\n"); - ssl_display_error(ret); - exit(1); - } - else - { - printf("All server tests passed\n"); TTY_FLUSH(); - } - - return ret; -} - -/************************************************************************** - * SSL Client Testing - * - **************************************************************************/ -typedef struct -{ - uint8_t session_id[SSL_SESSION_ID_SIZE]; -#ifndef WIN32 - pthread_t server_thread; -#endif - int start_server; - int stop_server; - int do_reneg; -} CLNT_SESSION_RESUME_CTX; - -typedef struct -{ - const char *testname; - const char *openssl_option; - int do_gnutls; -} server_t; - -static void do_server(server_t *svr) -{ - char openssl_buf[2048]; -#ifndef WIN32 - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); -#endif - if (svr->do_gnutls) - { - sprintf(openssl_buf, "gnutls-serv " - "-p %d --quiet %s ", g_port, svr->openssl_option); - } - else - { - sprintf(openssl_buf, "openssl s_server " -#ifdef WIN32 - "-accept %d -quiet %s", -#else - "-accept %d -quiet %s > /dev/null", -#endif - g_port, svr->openssl_option); - } -//printf("SERVER %s\n", openssl_buf); - SYSTEM(openssl_buf); -} - -static int SSL_client_test( - const char *test, - SSL_CTX **ssl_ctx, - const char *openssl_option, - CLNT_SESSION_RESUME_CTX *sess_resume, - uint32_t client_options, - const char *private_key, - const char *password, - const char *cert) -{ - server_t server_data; - SSL *ssl = NULL; - int client_fd = -1; - uint8_t *session_id = NULL; - int ret = 1; -#ifndef WIN32 - pthread_t thread; -#endif - - server_data.do_gnutls = strstr(test, "GNUTLS") != NULL; - - if (sess_resume == NULL || sess_resume->start_server) - { - g_port++; - server_data.openssl_option = openssl_option; - -#ifndef WIN32 - pthread_create(&thread, NULL, - (void *(*)(void *))do_server, (void *)&server_data); - pthread_detach(thread); -#else - CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_server, - (LPVOID)&server_data, 0, NULL); -#endif - } - - usleep(200000); /* allow server to start */ - - if (*ssl_ctx == NULL) - { - if (private_key) - { - client_options |= SSL_NO_DEFAULT_KEY; - } - - if ((*ssl_ctx = ssl_ctx_new( - client_options, SSL_DEFAULT_CLNT_SESS)) == NULL) - { - ret = SSL_ERROR_INVALID_KEY; - goto client_test_exit; - } - - if (private_key) - { - int obj_type = SSL_OBJ_RSA_KEY; - - if (strstr(private_key, ".p8")) - obj_type = SSL_OBJ_PKCS8; - else if (strstr(private_key, ".p12")) - obj_type = SSL_OBJ_PKCS12; - - if (ssl_obj_load(*ssl_ctx, obj_type, private_key, password)) - { - ret = SSL_ERROR_INVALID_KEY; - goto client_test_exit; - } - } - - if (cert) - { - if ((ret = ssl_obj_load(*ssl_ctx, - SSL_OBJ_X509_CERT, cert, NULL)) != SSL_OK) - { - printf("could not add cert %s (%d)\n", cert, ret); - TTY_FLUSH(); - goto client_test_exit; - } - } - - if (ssl_obj_load(*ssl_ctx, SSL_OBJ_X509_CACERT, - "../ssl/test/axTLS.ca_x509.cer", NULL)) - { - printf("could not add cert auth\n"); TTY_FLUSH(); - goto client_test_exit; - } - } - - if (sess_resume && !sess_resume->start_server) - { - session_id = sess_resume->session_id; - } - - if ((client_fd = client_socket_init(g_port)) < 0) - { - printf("could not start socket on %d\n", g_port); TTY_FLUSH(); - goto client_test_exit; - } - - ssl = ssl_client_new(*ssl_ctx, client_fd, - session_id, sizeof(session_id), NULL); - - /* check the return status */ - if ((ret = ssl_handshake_status(ssl))) - goto client_test_exit; - - /* renegotiate client */ - if (sess_resume && sess_resume->do_reneg) - { - if (ssl_renegotiate(ssl) == -SSL_ALERT_NO_RENEGOTIATION) - ret = 0; - else - ret = -SSL_ALERT_NO_RENEGOTIATION; - - goto client_test_exit; - } - - if (sess_resume) - { - memcpy(sess_resume->session_id, - ssl_get_session_id(ssl), SSL_SESSION_ID_SIZE); - } - - if (IS_SET_SSL_FLAG(SSL_SERVER_VERIFY_LATER) && - (ret = ssl_verify_cert(ssl))) - { - goto client_test_exit; - } - - ssl_write(ssl, (uint8_t *)"hello world\n", 13); - if (sess_resume) - { - const uint8_t *sess_id = ssl_get_session_id(ssl); - int i; - - printf(" Session-ID: "); - for (i = 0; i < SSL_SESSION_ID_SIZE; i++) - { - printf("%02X", sess_id[i]); - } - printf("\n"); - TTY_FLUSH(); - } - - ret = 0; - -client_test_exit: - ssl_free(ssl); - SOCKET_CLOSE(client_fd); - usleep(200000); /* allow openssl to say something */ - - if (sess_resume) - { - if (sess_resume->stop_server) - { - ssl_ctx_free(*ssl_ctx); - *ssl_ctx = NULL; - } - else if (sess_resume->start_server) - { -#ifndef WIN32 - sess_resume->server_thread = thread; -#endif - } - } - else - { - ssl_ctx_free(*ssl_ctx); - *ssl_ctx = NULL; - } - - if (ret == 0) - { - printf("SSL client test \"%s\" passed\n", test); - TTY_FLUSH(); - } - - return ret; -} - -int SSL_client_tests(void) -{ - int ret = -1; - SSL_CTX *ssl_ctx = NULL; - CLNT_SESSION_RESUME_CTX sess_resume; - memset(&sess_resume, 0, sizeof(CLNT_SESSION_RESUME_CTX)); - - sess_resume.start_server = 1; - printf("### starting client tests\n"); - - if ((ret = SSL_client_test("1024 bit key", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem", - &sess_resume, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - /* all the session id's should match for session resumption */ - sess_resume.start_server = 0; - if ((ret = SSL_client_test("Client session resumption #1", - &ssl_ctx, NULL, &sess_resume, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - // no client renegotiation - sess_resume.do_reneg = 1; - // test relies on openssl killing the call - if ((ret = SSL_client_test("Client renegotiation", - &ssl_ctx, NULL, &sess_resume, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - sess_resume.do_reneg = 0; - - sess_resume.stop_server = 1; - if ((ret = SSL_client_test("Client session resumption #2", - &ssl_ctx, NULL, &sess_resume, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("1024 bit key", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("2048 bit key", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_2048.pem " - "-key ../ssl/test/axTLS.key_2048.pem", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("4096 bit key", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_4096.pem " - "-key ../ssl/test/axTLS.key_4096.pem", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("TLS 1.1", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem -tls1_1", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("TLS 1.0", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_1024.pem " - "-key ../ssl/test/axTLS.key_1024.pem -tls1", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("Basic Constraint - len OK", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_end_chain.pem -key " - "../ssl/test/axTLS.key_end_chain.pem -CAfile " - "../ssl/test/axTLS.x509_intermediate_ca.pem", - NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - if ((ret = SSL_client_test("Basic Constraint - len NOT OK", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_end_chain_bad.pem -key " - "../ssl/test/axTLS.key_end_chain.pem -CAfile " - "../ssl/test/axTLS.x509_intermediate_ca2.pem", - NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL)) - != SSL_X509_ERROR(X509_VFY_ERROR_BASIC_CONSTRAINT)) - { - printf("*** Error: %d\n", ret); - if (ret == 0) - ret = SSL_NOT_OK; - - goto cleanup; - } - - printf("SSL server test \"%s\" passed\n", "Basic Constraint - len NOT OK"); - - if ((ret = SSL_client_test("Server cert chaining", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_device.pem " - "-key ../ssl/test/axTLS.key_device.pem " - "-CAfile ../ssl/test/axTLS.x509_1024.pem ", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL))) - goto cleanup; - - /* Check the server can verify the client */ - if ((ret = SSL_client_test("Client peer authentication", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_2048.pem " - "-key ../ssl/test/axTLS.key_2048.pem " - "-CAfile ../ssl/test/axTLS.ca_x509.pem " - "-verify 1 ", NULL, DEFAULT_CLNT_OPTION, - "../ssl/test/axTLS.key_1024", NULL, - "../ssl/test/axTLS.x509_1024.cer"))) - goto cleanup; - - /* Check the server can verify the client */ - if ((ret = SSL_client_test("Client peer authentication TLS1.1", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_2048.pem " - "-key ../ssl/test/axTLS.key_2048.pem " - "-CAfile ../ssl/test/axTLS.ca_x509.pem " - "-verify 1 -tls1_1", NULL, DEFAULT_CLNT_OPTION, - "../ssl/test/axTLS.key_1024", NULL, - "../ssl/test/axTLS.x509_1024.cer"))) - goto cleanup; - - /* Should get an "ERROR" from openssl (as the handshake fails as soon as - * the certificate verification fails) */ - if ((ret = SSL_client_test("Error: Expired cert (verify now)", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_bad_after.pem " - "-key ../ssl/test/axTLS.key_1024.pem", NULL, - DEFAULT_CLNT_OPTION, NULL, NULL, NULL)) != - SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED)) - { - printf("*** Error: %d\n", ret); - goto cleanup; - } - - printf("SSL client test \"Expired cert (verify now)\" passed\n"); - - /* There is no "ERROR" from openssl */ - if ((ret = SSL_client_test("Error: Expired cert (verify later)", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_bad_after.pem " - "-key ../ssl/test/axTLS.key_1024.pem", NULL, - DEFAULT_CLNT_OPTION|SSL_SERVER_VERIFY_LATER, NULL, - NULL, NULL)) != SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED)) - { - printf("*** Error: %d\n", ret); TTY_FLUSH(); - goto cleanup; - } - - printf("SSL client test \"Expired cert (verify later)\" passed\n"); - - /* invalid cert type */ - /*if ((ret = SSL_client_test("Error: Invalid certificate type", - &ssl_ctx, - "-cert ../ssl/test/axTLS.x509_2048.pem " - "-key ../ssl/test/axTLS.key_2048.pem " - "-CAfile ../ssl/test/axTLS.ca_x509.pem " - "-verify 1 ", NULL, DEFAULT_CLNT_OPTION, - "../ssl/test/axTLS.key_1024.pem", NULL, - "../ssl/test/axTLS.x509_1024.pem")) - != SSL_ERROR_INVALID_KEY) - { - if (ret == 0) - ret = SSL_NOT_OK; - - printf("*** Error: %d\n", ret); TTY_FLUSH(); - goto cleanup; - } - - printf("SSL client test \"Invalid certificate type\" passed\n"); */ - - if ((ret = SSL_client_test("GNUTLS client", - &ssl_ctx, - "--x509certfile ../ssl/test/axTLS.x509_1024.pem " - "--x509keyfile ../ssl/test/axTLS.key_1024.pem -g", NULL, - DEFAULT_CLNT_OPTION, - "../ssl/test/axTLS.key_1024.pem", NULL, - "../ssl/test/axTLS.x509_1024.pem"))) - goto cleanup; - - ret = 0; - - if ((ret = SSL_client_test("GNUTLS client with verify", - &ssl_ctx, - "--x509certfile ../ssl/test/axTLS.x509_1024.pem " - "--x509keyfile ../ssl/test/axTLS.key_1024.pem -r -g", NULL, - DEFAULT_CLNT_OPTION|SSL_SERVER_VERIFY_LATER, - "../ssl/test/axTLS.key_1024.pem", NULL, - "../ssl/test/axTLS.x509_1024.pem"))) - goto cleanup; - - ret = 0; - -cleanup: - if (ret) - { - ssl_display_error(ret); - printf("Error: A client test failed\n"); - SYSTEM("sh ../ssl/test/killopenssl.sh"); - SYSTEM("sh ../ssl/test/killgnutls.sh"); - exit(1); - } - else - { - printf("All client tests passed\n"); TTY_FLUSH(); - } - - ssl_ctx_free(ssl_ctx); - return ret; -} - -/************************************************************************** - * SSL Basic Testing (test a big packet handshake) - * - **************************************************************************/ -static uint8_t basic_buf[256*1024]; - -static void do_basic(void) -{ - int client_fd; - SSL *ssl_clnt; - SSL_CTX *ssl_clnt_ctx = ssl_ctx_new( - DEFAULT_CLNT_OPTION, SSL_DEFAULT_CLNT_SESS); - usleep(200000); /* allow server to start */ - - if ((client_fd = client_socket_init(g_port)) < 0) - goto error; - - if (ssl_obj_load(ssl_clnt_ctx, SSL_OBJ_X509_CACERT, - "../ssl/test/axTLS.ca_x509.cer", NULL)) - goto error; - - ssl_clnt = ssl_client_new(ssl_clnt_ctx, client_fd, NULL, 0, NULL); - - /* check the return status */ - if (ssl_handshake_status(ssl_clnt) < 0) - { - ssl_display_error(ssl_handshake_status(ssl_clnt)); - goto error; - } - - ssl_write(ssl_clnt, basic_buf, sizeof(basic_buf)); - ssl_free(ssl_clnt); - -error: - ssl_ctx_free(ssl_clnt_ctx); - SOCKET_CLOSE(client_fd); - - /* exit this thread */ -} - -static int SSL_basic_test(void) -{ - int server_fd, client_fd, ret = 0, size = 0, offset = 0; - SSL_CTX *ssl_svr_ctx = NULL; - struct sockaddr_in client_addr; - uint8_t *read_buf; - socklen_t clnt_len = sizeof(client_addr); - SSL *ssl_svr; -#ifndef WIN32 - pthread_t thread; -#endif - memset(basic_buf, 0xA5, sizeof(basic_buf)/2); - memset(&basic_buf[sizeof(basic_buf)/2], 0x5A, sizeof(basic_buf)/2); - - if ((server_fd = server_socket_init(&g_port)) < 0) - goto error; - - ssl_svr_ctx = ssl_ctx_new(DEFAULT_SVR_OPTION, SSL_DEFAULT_SVR_SESS); - if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_X509_CERT, - "../ssl/test/axTLS.x509_1024.pem", NULL)) != SSL_OK) - goto error; - - if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_RSA_KEY, - "../ssl/test/axTLS.key_1024.pem", NULL)) != SSL_OK) - goto error; -#ifndef WIN32 - pthread_create(&thread, NULL, - (void *(*)(void *))do_basic, NULL); - pthread_detach(thread); -#else - CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_basic, NULL, 0, NULL); -#endif - - /* Wait for a client to connect */ - if ((client_fd = accept(server_fd, - (struct sockaddr *) &client_addr, &clnt_len)) < 0) - { - ret = SSL_ERROR_SOCK_SETUP_FAILURE; - goto error; - } - - /* we are ready to go */ - ssl_svr = ssl_server_new(ssl_svr_ctx, client_fd); - - do - { - while ((size = ssl_read(ssl_svr, &read_buf)) == SSL_OK); - - if (size < SSL_OK) /* got some alert or something nasty */ - { - ssl_display_error(size); - ret = size; - break; - } - else /* looks more promising */ - { - if (memcmp(read_buf, &basic_buf[offset], size) != 0) - { - ret = SSL_NOT_OK; - break; - } - } - - offset += size; - } while (offset < sizeof(basic_buf)); - - printf(ret == SSL_OK && offset == sizeof(basic_buf) ? - "SSL basic test passed\n" : - "SSL basic test failed\n"); - TTY_FLUSH(); - - ssl_free(ssl_svr); - SOCKET_CLOSE(server_fd); - SOCKET_CLOSE(client_fd); - -error: - ssl_ctx_free(ssl_svr_ctx); - return ret; -} - -/************************************************************************** - * SSL unblocked case - * - **************************************************************************/ -static void do_unblocked(void) -{ - int client_fd; - SSL *ssl_clnt; - SSL_CTX *ssl_clnt_ctx = ssl_ctx_new( - DEFAULT_CLNT_OPTION, - SSL_DEFAULT_CLNT_SESS | - SSL_CONNECT_IN_PARTS); - usleep(200000); /* allow server to start */ - - if ((client_fd = client_socket_init(g_port)) < 0) - goto error; - - { -#ifdef WIN32 - u_long argp = 1; - ioctlsocket(client_fd, FIONBIO, &argp); -#else - int flags = fcntl(client_fd, F_GETFL, NULL); - fcntl(client_fd, F_SETFL, flags | O_NONBLOCK); -#endif - } - - if (ssl_obj_load(ssl_clnt_ctx, SSL_OBJ_X509_CACERT, - "../ssl/test/axTLS.ca_x509.cer", NULL)) - goto error; - - ssl_clnt = ssl_client_new(ssl_clnt_ctx, client_fd, NULL, 0, NULL); - - while (ssl_handshake_status(ssl_clnt) != SSL_OK) - { - if (ssl_read(ssl_clnt, NULL) < 0) - { - ssl_display_error(ssl_handshake_status(ssl_clnt)); - goto error; - } - } - - ssl_write(ssl_clnt, basic_buf, sizeof(basic_buf)); - ssl_free(ssl_clnt); - -error: - ssl_ctx_free(ssl_clnt_ctx); - SOCKET_CLOSE(client_fd); - - /* exit this thread */ -} - -static int SSL_unblocked_test(void) -{ - int server_fd, client_fd, ret = 0, size = 0, offset = 0; - SSL_CTX *ssl_svr_ctx = NULL; - struct sockaddr_in client_addr; - uint8_t *read_buf; - socklen_t clnt_len = sizeof(client_addr); - SSL *ssl_svr; -#ifndef WIN32 - pthread_t thread; -#endif - memset(basic_buf, 0xA5, sizeof(basic_buf)/2); - memset(&basic_buf[sizeof(basic_buf)/2], 0x5A, sizeof(basic_buf)/2); - - if ((server_fd = server_socket_init(&g_port)) < 0) - goto error; - - ssl_svr_ctx = ssl_ctx_new(DEFAULT_SVR_OPTION, SSL_DEFAULT_SVR_SESS); - if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_X509_CERT, - "../ssl/test/axTLS.x509_1024.pem", NULL)) != SSL_OK) - goto error; - - if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_RSA_KEY, - "../ssl/test/axTLS.key_1024.pem", NULL)) != SSL_OK) - goto error; - -#ifndef WIN32 - pthread_create(&thread, NULL, - (void *(*)(void *))do_unblocked, NULL); - pthread_detach(thread); -#else - CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_unblocked, - NULL, 0, NULL); -#endif - - /* Wait for a client to connect */ - if ((client_fd = accept(server_fd, - (struct sockaddr *) &client_addr, &clnt_len)) < 0) - { - ret = SSL_ERROR_SOCK_SETUP_FAILURE; - goto error; - } - - /* we are ready to go */ - ssl_svr = ssl_server_new(ssl_svr_ctx, client_fd); - - do - { - while ((size = ssl_read(ssl_svr, &read_buf)) == SSL_OK); - - if (size < SSL_OK) /* got some alert or something nasty */ - { - ssl_display_error(size); - ret = size; - break; - } - else /* looks more promising */ - { - if (memcmp(read_buf, &basic_buf[offset], size) != 0) - { - ret = SSL_NOT_OK; - break; - } - } - - offset += size; - } while (offset < sizeof(basic_buf)); - - printf(ret == SSL_OK && offset == sizeof(basic_buf) ? - "SSL unblocked test passed\n" : - "SSL unblocked test failed\n"); - TTY_FLUSH(); - - ssl_free(ssl_svr); - SOCKET_CLOSE(server_fd); - SOCKET_CLOSE(client_fd); - -error: - ssl_ctx_free(ssl_svr_ctx); - return ret; -} - -#if !defined(WIN32) && defined(CONFIG_SSL_CTX_MUTEXING) -/************************************************************************** - * Multi-Threading Tests - * - **************************************************************************/ -#define NUM_THREADS 100 - -typedef struct -{ - SSL_CTX *ssl_clnt_ctx; - int port; - int thread_id; -} multi_t; - -void do_multi_clnt(multi_t *multi_data) -{ - int res = 1, client_fd, i; - SSL *ssl = NULL; - char tmp[5]; - - if ((client_fd = client_socket_init(multi_data->port)) < 0) - goto client_test_exit; - - usleep(200000); - ssl = ssl_client_new(multi_data->ssl_clnt_ctx, client_fd, NULL, 0, NULL); - - if ((res = ssl_handshake_status(ssl))) - { - printf("Client "); - ssl_display_error(res); - goto client_test_exit; - } - - sprintf(tmp, "%d\n", multi_data->thread_id); - for (i = 0; i < 10; i++) - ssl_write(ssl, (uint8_t *)tmp, strlen(tmp)+1); - -client_test_exit: - ssl_free(ssl); - SOCKET_CLOSE(client_fd); - free(multi_data); -} - -void do_multi_svr(SSL *ssl) -{ - uint8_t *read_buf; - int *res_ptr = malloc(sizeof(int)); - int res; - - for (;;) - { - res = ssl_read(ssl, &read_buf); - - /* kill the client */ - if (res != SSL_OK) - { - if (res == SSL_ERROR_CONN_LOST) - { - SOCKET_CLOSE(ssl->client_fd); - ssl_free(ssl); - break; - } - else if (res > 0) - { - /* do nothing */ - } - else /* some problem */ - { - printf("Server "); - ssl_display_error(res); - goto error; - } - } - } - - res = SSL_OK; -error: - *res_ptr = res; - pthread_exit(res_ptr); -} - -int multi_thread_test(void) -{ - int server_fd = -1; - SSL_CTX *ssl_server_ctx; - SSL_CTX *ssl_clnt_ctx; - pthread_t clnt_threads[NUM_THREADS]; - pthread_t svr_threads[NUM_THREADS]; - int i, res = 0; - struct sockaddr_in client_addr; - socklen_t clnt_len = sizeof(client_addr); - - printf("Do multi-threading test (takes a minute)\n"); - - ssl_svr_ctx = ssl_ctx_new(DEFAULT_SVR_OPTION, SSL_DEFAULT_SVR_SESS); - if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_X509_CERT, - "../ssl/test/axTLS.x509_1024.pem", NULL)) != SSL_OK) - goto error; - - if ((ret = ssl_obj_load(ssl_svr_ctx, SSL_OBJ_RSA_KEY, - "../ssl/test/axTLS.key_1024.pem", NULL)) != SSL_OK) - goto error; - ssl_clnt_ctx = ssl_ctx_new(DEFAULT_CLNT_OPTION, SSL_DEFAULT_CLNT_SESS); - - if (ssl_obj_load(ssl_clnt_ctx, SSL_OBJ_X509_CACERT, - "../ssl/test/axTLS.ca_x509.cer", NULL)) - goto error; - - if ((server_fd = server_socket_init(&g_port)) < 0) - goto error; - - for (i = 0; i < NUM_THREADS; i++) - { - multi_t *multi_data = (multi_t *)malloc(sizeof(multi_t)); - multi_data->ssl_clnt_ctx = ssl_clnt_ctx; - multi_data->port = g_port; - multi_data->thread_id = i+1; - pthread_create(&clnt_threads[i], NULL, - (void *(*)(void *))do_multi_clnt, (void *)multi_data); - pthread_detach(clnt_threads[i]); - } - - for (i = 0; i < NUM_THREADS; i++) - { - SSL *ssl_svr; - int client_fd = accept(server_fd, - (struct sockaddr *)&client_addr, &clnt_len); - - if (client_fd < 0) - goto error; - - ssl_svr = ssl_server_new(ssl_server_ctx, client_fd); - - pthread_create(&svr_threads[i], NULL, - (void *(*)(void *))do_multi_svr, (void *)ssl_svr); - } - - /* make sure we've run all of the threads */ - for (i = 0; i < NUM_THREADS; i++) - { - void *thread_res; - pthread_join(svr_threads[i], &thread_res); - - if (*((int *)thread_res) != 0) - res = 1; - - free(thread_res); - } - - if (res) - goto error; - - printf("Multi-thread test passed (%d)\n", NUM_THREADS); -error: - ssl_ctx_free(ssl_svr_ctx); - ssl_ctx_free(ssl_clnt_ctx); - SOCKET_CLOSE(server_fd); - return res; -} -#endif /* !defined(WIN32) && defined(CONFIG_SSL_CTX_MUTEXING) */ - -/************************************************************************** - * Header issue - * - **************************************************************************/ -//static void do_header_issue(void) -//{ -// char axtls_buf[2048]; -//#ifndef WIN32 -// pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); -//#endif -// sprintf(axtls_buf, "./axssl s_client -connect localhost:%d", g_port); -// SYSTEM(axtls_buf); -//} -// -//static int header_issue(void) -//{ -// FILE *f = fopen("../ssl/test/header_issue.dat", "r"); -// int server_fd = -1, client_fd = -1, ret = 1; -// uint8_t buf[2048]; -// int size = 0; -// struct sockaddr_in client_addr; -// socklen_t clnt_len = sizeof(client_addr); -//#ifndef WIN32 -// pthread_t thread; -//#endif -// -// if (f == NULL || (server_fd = server_socket_init(&g_port)) < 0) -// goto error; -// -//#ifndef WIN32 -// pthread_create(&thread, NULL, -// (void *(*)(void *))do_header_issue, NULL); -// pthread_detach(thread); -//#else -// CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)do_header_issue, -// NULL, 0, NULL); -//#endif -// if ((client_fd = accept(server_fd, -// (struct sockaddr *) &client_addr, &clnt_len)) < 0) -// { -// ret = SSL_ERROR_SOCK_SETUP_FAILURE; -// goto error; -// } -// -// size = fread(buf, 1, sizeof(buf), f); -// if (SOCKET_WRITE(client_fd, buf, size) < 0) -// { -// ret = SSL_ERROR_SOCK_SETUP_FAILURE; -// goto error; -// } -// -// usleep(200000); -// -// ret = 0; -//error: -// fclose(f); -// SOCKET_CLOSE(client_fd); -// SOCKET_CLOSE(server_fd); -// TTY_FLUSH(); -// SYSTEM("killall axssl"); -// return ret; -//} - -/************************************************************************** - * main() - * - **************************************************************************/ -int main(int argc, char *argv[]) -{ - int ret = 1; - BI_CTX *bi_ctx; - int fd; - -#ifdef WIN32 - WSADATA wsaData; - WORD wVersionRequested = MAKEWORD(2, 2); - WSAStartup(wVersionRequested, &wsaData); - fd = _open("test_result.txt", O_WRONLY|O_TEMPORARY|O_CREAT, _S_IWRITE); - dup2(fd, 2); /* write stderr to this file */ -#else - fd = open("/dev/null", O_WRONLY); /* write stderr to /dev/null */ - signal(SIGPIPE, SIG_IGN); /* ignore pipe errors */ - dup2(fd, 2); -#endif - - /* can't do testing in this mode */ -#if defined CONFIG_SSL_GENERATE_X509_CERT - printf("Error: Must compile with default key/certificates\n"); - exit(1); -#endif - - bi_ctx = bi_initialize(); - - if (AES_test(bi_ctx)) - { - printf("AES tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (MD5_test(bi_ctx)) - { - printf("MD5 tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (SHA1_test(bi_ctx)) - { - printf("SHA1 tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (SHA256_test(bi_ctx)) - { - printf("SHA256 tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (SHA384_test(bi_ctx)) - { - printf("SHA384 tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (SHA512_test(bi_ctx)) - { - printf("SHA512 tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (HMAC_test(bi_ctx)) - { - printf("HMAC tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (BIGINT_test(bi_ctx)) - { - printf("BigInt tests failed!\n"); - goto cleanup; - } - TTY_FLUSH(); - - bi_terminate(bi_ctx); - - if (RSA_test()) - { - printf("RSA tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - - if (cert_tests()) - { - printf("CERT tests failed\n"); - goto cleanup; - } - TTY_FLUSH(); - -#if !defined(WIN32) && defined(CONFIG_SSL_CTX_MUTEXING) - if (multi_thread_test()) - goto cleanup; -#endif - - if (SSL_basic_test()) - goto cleanup; - - SYSTEM("sh ../ssl/test/killopenssl.sh"); - - if (SSL_unblocked_test()) - goto cleanup; - - SYSTEM("sh ../ssl/test/killopenssl.sh"); - - if (SSL_client_tests()) - goto cleanup; - - SYSTEM("sh ../ssl/test/killopenssl.sh"); - SYSTEM("sh ../ssl/test/killgnutls.sh"); - - if (SSL_server_tests()) - goto cleanup; - - SYSTEM("sh ../ssl/test/killopenssl.sh"); - -// if (header_issue()) -// { -// printf("Header tests failed\n"); TTY_FLUSH(); -// goto cleanup; -// } - - ret = 0; /* all ok */ - printf("**** ALL TESTS PASSED ****\n"); TTY_FLUSH(); -cleanup: - - if (ret) - printf("Error: Some tests failed!\n"); - - close(fd); - return ret; -} diff --git a/user/mpy/lib/axtls/ssl/test/test_axssl.sh b/user/mpy/lib/axtls/ssl/test/test_axssl.sh deleted file mode 100755 index acf11a6..0000000 --- a/user/mpy/lib/axtls/ssl/test/test_axssl.sh +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2007, Cameron Rich -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the axTLS project nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# -# Test the various axssl bindings. To run it, got to the _install directory -# and run this script from there. -# - -if grep "CONFIG_PLATFORM_WIN32=y" "../config/.config" > /dev/null; then - JAVA_EXE="$JAVA_HOME/bin/java.exe" - PERL_BIN="/cygdrive/c/Perl/bin/perl" - KILL_AXSSL="kill %1" - KILL_CSHARP="kill %1" - KILL_PERL="kill %1" - KILL_JAVA="kill %1" - KILL_LUA="kill %1" -else - if grep "CONFIG_PLATFORM_CYGWIN=y" "../config/.config" > /dev/null; then - # no .net or java on cygwin - PERL_BIN=/usr/bin/perl - KILL_AXSSL="killall axssl" - KILL_PERL="killall /usr/bin/perl" - KILL_LUA="killall /usr/local/bin/lua" - else # Linux - JAVA_EXE=/usr/java/default/bin/java - PERL_BIN=/usr/bin/perl - KILL_AXSSL="killall axssl" - KILL_CSHARP="killall mono" - KILL_PERL="killall /usr/bin/perl" - RUN_CSHARP="mono" - KILL_JAVA="killall $JAVA_EXE" - KILL_LUA="killall /usr/local/bin/lua" - fi -fi - -BASE=.. -SERVER_ARGS="s_server -accept 15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer" -CLIENT_ARGS="s_client -reconnect -connect localhost:15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer -key $BASE/ssl/test/axTLS.key_1024 -cert $BASE/ssl/test/axTLS.x509_1024.cer" - -# check pem arguments -SERVER_PEM_ARGS="s_server -accept 15001 -pass abcd -key $BASE/ssl/test/axTLS.key_aes128.pem -cert $BASE/ssl/test/axTLS.x509_aes128.pem" -CLIENT_PEM_ARGS="s_client -connect localhost:15001 -CAfile $BASE/ssl/test/axTLS.ca_x509.pem -key $BASE/ssl/test/axTLS.key_1024.pem -cert $BASE/ssl/test/axTLS.x509_1024.pem" - -export LD_LIBRARY_PATH=.:`perl -e 'use Config; print $Config{archlib};'`/CORE - -if [ -x ./axssl ]; then -echo "############################# C SAMPLE ###########################" -./axssl $SERVER_ARGS & -echo "C Test passed" | ./axssl $CLIENT_ARGS -$KILL_AXSSL -sleep 1 - -./axssl $SERVER_PEM_ARGS & -echo "C Test passed" | ./axssl $CLIENT_PEM_ARGS -$KILL_AXSSL -sleep 1 -echo "### C tests complete" -fi - -if [ -f ./axtls.jar ]; then -echo "########################## JAVA SAMPLE ###########################" -"$JAVA_EXE" -jar ./axtls.jar $SERVER_ARGS & -echo "Java Test passed" | "$JAVA_EXE" -jar ./axtls.jar $CLIENT_ARGS -$KILL_JAVA -sleep 1 - -"$JAVA_EXE" -jar ./axtls.jar $SERVER_PEM_ARGS & -echo "Java Test passed" | "$JAVA_EXE" -jar ./axtls.jar $CLIENT_PEM_ARGS -$KILL_JAVA -sleep 1 - -echo "### Java tests complete" -fi - -if [ -x ./axssl.csharp.exe ]; then -echo "############################ C# SAMPLE ###########################" -$RUN_CSHARP ./axssl.csharp.exe $SERVER_ARGS & -echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_ARGS -$KILL_CSHARP -sleep 1 - -$RUN_CSHARP ./axssl.csharp.exe $SERVER_PEM_ARGS & -echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_PEM_ARGS -$KILL_CSHARP -sleep 1 - -echo "### C# tests complete" -fi - -if [ -x ./axssl.vbnet.exe ]; then -echo "######################## VB.NET SAMPLE ###########################" -echo $SERVER_ARGS -echo $CLIENT_ARGS -./axssl.vbnet $SERVER_ARGS & -echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_ARGS -kill %1 -sleep 1 - -./axssl.vbnet $SERVER_PEM_ARGS & -echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_PEM_ARGS -kill %1 -sleep 1 -echo "### VB.NET tests complete" -fi - -if [ -f ./axssl.pl ]; then -echo "########################## PERL SAMPLE ###########################" -"$PERL_BIN" ./axssl.pl $SERVER_ARGS & -echo "Perl Test passed" | "$PERL_BIN" ./axssl.pl $CLIENT_ARGS -$KILL_PERL -sleep 1 - -"$PERL_BIN" ./axssl.pl $SERVER_PEM_ARGS & -echo "Perl Test passed" | "$PERL_BIN" ./axssl.pl $CLIENT_PEM_ARGS -$KILL_PERL -sleep 1 -echo "### Perl tests complete" -fi - -if [ -f ./axssl.lua ]; then -echo "########################## LUA SAMPLE ###########################" -./axssl.lua $SERVER_ARGS & -echo "Lua Test passed" | ./axssl.lua $CLIENT_ARGS -$KILL_LUA -sleep 1 - -./axssl.lua $SERVER_PEM_ARGS & -echo "Lua Test passed" | ./axssl.lua $CLIENT_PEM_ARGS -$KILL_LUA -sleep 1 -echo "### Lua tests complete" -fi - -echo "########################## ALL TESTS COMPLETE ###########################" diff --git a/user/mpy/lib/axtls/ssl/test/thawte.x509_ca b/user/mpy/lib/axtls/ssl/test/thawte.x509_ca deleted file mode 100644 index 59b1059f84086fa580dc1001303c4db4e070e572..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 811 zcmXqLVpcb3Vw$jknTe5!iILHOmyJ`a&71aK>;=YaCsSi1!zDAbtnTZF zqUYUebWG~Ec<0FydhNn{8R@BF?(Zc$Os#^xXlJqYTkF3Hd%V7_cb@q7d0SFTnS9@$ z=3Jy0cw_d3^b5OqC$WhXUzvP*x)#Hn7(bppzeI!nd~(UVCFqsMF<)Qz@y}IOZN=N% zf+J3JvhHmb+)-@5ioN%XlkanfxiaQV%!~|-i-ipY4fugEEGx{&_@9N=wue#B(wSB};{CmAjN`|kTB z=H&c*ca+=jgU1BrKYDG@a65VUh*RyJU#lbYu5J(P5PZC(RWiHDX9 -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -/* The session expiry time */ -#define SSL_EXPIRY_TIME (CONFIG_SSL_EXPIRY_TIME*3600) - -static const uint8_t g_hello_request[] = { HS_HELLO_REQUEST, 0, 0, 0 }; -static const uint8_t g_chg_cipher_spec_pkt[] = { 1 }; -static const char * server_finished = "server finished"; -static const char * client_finished = "client finished"; - -static int do_handshake(SSL *ssl, uint8_t *buf, int read_len); -static int set_key_block(SSL *ssl, int is_write); -static int verify_digest(SSL *ssl, int mode, const uint8_t *buf, int read_len); -static void *crypt_new(SSL *ssl, uint8_t *key, uint8_t *iv, int is_decrypt); -static int send_raw_packet(SSL *ssl, uint8_t protocol); -static int check_certificate_chain(SSL *ssl); - -/** - * The server will pick the cipher based on the order that the order that the - * ciphers are listed. This order is defined at compile time. - */ -#ifndef CONFIG_SSL_SKELETON_MODE -static void session_free(SSL_SESSION *ssl_sessions[], int sess_index); -#endif - -const uint8_t ssl_prot_prefs[NUM_PROTOCOLS] = -#ifdef CONFIG_SSL_PROT_LOW /* low security, fast speed */ -{ SSL_AES128_SHA, SSL_AES128_SHA256, SSL_AES256_SHA, SSL_AES256_SHA256 }; -#elif CONFIG_SSL_PROT_MEDIUM /* medium security, medium speed */ -{ SSL_AES128_SHA256, SSL_AES256_SHA256, SSL_AES256_SHA, SSL_AES128_SHA }; -#else /* CONFIG_SSL_PROT_HIGH */ /* high security, low speed */ -{ SSL_AES256_SHA256, SSL_AES128_SHA256, SSL_AES256_SHA, SSL_AES128_SHA }; -#endif - -/** - * The cipher map containing all the essentials for each cipher. - */ -static const cipher_info_t cipher_info[NUM_PROTOCOLS] = -{ - { /* AES128-SHA */ - SSL_AES128_SHA, /* AES128-SHA */ - 16, /* key size */ - 16, /* iv size */ - 16, /* block padding size */ - SHA1_SIZE, /* digest size */ - 2*(SHA1_SIZE+16+16), /* key block size */ - ssl_hmac_sha1, /* hmac algorithm */ - (crypt_func)AES_cbc_encrypt, /* encrypt */ - (crypt_func)AES_cbc_decrypt /* decrypt */ - }, - { /* AES256-SHA */ - SSL_AES256_SHA, /* AES256-SHA */ - 32, /* key size */ - 16, /* iv size */ - 16, /* block padding size */ - SHA1_SIZE, /* digest size */ - 2*(SHA1_SIZE+32+16), /* key block size */ - ssl_hmac_sha1, /* hmac algorithm */ - (crypt_func)AES_cbc_encrypt, /* encrypt */ - (crypt_func)AES_cbc_decrypt /* decrypt */ - }, - { /* AES128-SHA256 */ - SSL_AES128_SHA256, /* AES128-SHA256 */ - 16, /* key size */ - 16, /* iv size */ - 16, /* block padding size */ - SHA256_SIZE, /* digest size */ - 2*(SHA256_SIZE+32+16), /* key block size */ - hmac_sha256, /* hmac algorithm */ - (crypt_func)AES_cbc_encrypt, /* encrypt */ - (crypt_func)AES_cbc_decrypt /* decrypt */ - }, - { /* AES256-SHA256 */ - SSL_AES256_SHA256, /* AES256-SHA256 */ - 32, /* key size */ - 16, /* iv size */ - 16, /* block padding size */ - SHA256_SIZE, /* digest size */ - 2*(SHA256_SIZE+32+16), /* key block size */ - hmac_sha256, /* hmac algorithm */ - (crypt_func)AES_cbc_encrypt, /* encrypt */ - (crypt_func)AES_cbc_decrypt /* decrypt */ - } -}; - -static void prf(SSL *ssl, const uint8_t *sec, int sec_len, - uint8_t *seed, int seed_len, - uint8_t *out, int olen); -static const cipher_info_t *get_cipher_info(uint8_t cipher); -static void increment_read_sequence(SSL *ssl); -static void increment_write_sequence(SSL *ssl); -static void add_hmac_digest(SSL *ssl, int snd, uint8_t *hmac_header, - const uint8_t *buf, int buf_len, uint8_t *hmac_buf); - -/* win32 VC6.0 doesn't have variadic macros */ -#if defined(WIN32) && !defined(CONFIG_SSL_FULL_MODE) -void DISPLAY_BYTES(SSL *ssl, const char *format, - const uint8_t *data, int size, ...) {} -#endif - -/** - * Allocates new SSL extensions structure and returns pointer to it - * - */ -EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new() -{ - return (SSL_EXTENSIONS *)calloc(1, sizeof(SSL_EXTENSIONS)); -} - -/** - * Allocates new SSL extensions structure and returns pointer to it - * - */ -EXP_FUNC void STDCALL ssl_ext_free(SSL_EXTENSIONS *ssl_ext) -{ - if (ssl_ext == NULL ) - { - return; - } - - free(ssl_ext); -} - -/** - * Establish a new client/server context. - */ -EXP_FUNC SSL_CTX *STDCALL ssl_ctx_new(uint32_t options, int num_sessions) -{ - SSL_CTX *ssl_ctx = (SSL_CTX *)calloc(1, sizeof (SSL_CTX)); - ssl_ctx->options = options; - RNG_initialize(); - -#ifdef CONFIG_SSL_ENABLE_SERVER - if (load_key_certs(ssl_ctx) < 0) - { - free(ssl_ctx); /* can't load our key/certificate pair, so die */ - return NULL; - } -#endif - -#ifndef CONFIG_SSL_SKELETON_MODE - ssl_ctx->num_sessions = num_sessions; -#endif - - SSL_CTX_MUTEX_INIT(ssl_ctx->mutex); - -#ifndef CONFIG_SSL_SKELETON_MODE - if (num_sessions) - { - ssl_ctx->ssl_sessions = (SSL_SESSION **) - calloc(1, num_sessions*sizeof(SSL_SESSION *)); - } -#endif - - return ssl_ctx; -} - -/* - * Remove a client/server context. - */ -EXP_FUNC void STDCALL ssl_ctx_free(SSL_CTX *ssl_ctx) -{ - SSL *ssl; - int i; - - if (ssl_ctx == NULL) - return; - - ssl = ssl_ctx->head; - - /* clear out all the ssl entries */ - while (ssl) - { - SSL *next = ssl->next; - ssl_free(ssl); - ssl = next; - } - -#ifndef CONFIG_SSL_SKELETON_MODE - /* clear out all the sessions */ - for (i = 0; i < ssl_ctx->num_sessions; i++) - session_free(ssl_ctx->ssl_sessions, i); - - free(ssl_ctx->ssl_sessions); -#endif - - i = 0; - while (i < CONFIG_SSL_MAX_CERTS && ssl_ctx->certs[i].buf) - { - free(ssl_ctx->certs[i].buf); - ssl_ctx->certs[i++].buf = NULL; - } - -#ifdef CONFIG_SSL_CERT_VERIFICATION - remove_ca_certs(ssl_ctx->ca_cert_ctx); -#endif - ssl_ctx->chain_length = 0; - SSL_CTX_MUTEX_DESTROY(ssl_ctx->mutex); - RSA_free(ssl_ctx->rsa_ctx); - RNG_terminate(); - free(ssl_ctx); -} - -/* - * Free any used resources used by this connection. - */ -EXP_FUNC void STDCALL ssl_free(SSL *ssl) -{ - SSL_CTX *ssl_ctx; - - if (ssl == NULL) /* just ignore null pointers */ - return; - - /* only notify if we weren't notified first */ - /* spec says we must notify when we are dying */ - if (!IS_SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY)) - send_alert(ssl, SSL_ALERT_CLOSE_NOTIFY); - - ssl_ctx = ssl->ssl_ctx; - - SSL_CTX_LOCK(ssl_ctx->mutex); - - /* adjust the server SSL list */ - if (ssl->prev) - ssl->prev->next = ssl->next; - else - ssl_ctx->head = ssl->next; - - if (ssl->next) - ssl->next->prev = ssl->prev; - else - ssl_ctx->tail = ssl->prev; - - SSL_CTX_UNLOCK(ssl_ctx->mutex); - - /* may already be free - but be sure */ - free(ssl->encrypt_ctx); - ssl->encrypt_ctx = NULL; - free(ssl->decrypt_ctx); - ssl->decrypt_ctx = NULL; - disposable_free(ssl); -#ifdef CONFIG_SSL_CERT_VERIFICATION - x509_free(ssl->x509_ctx); -#endif - - ssl_ext_free(ssl->extensions); - ssl->extensions = NULL; - free(ssl); -} - -/* - * Read the SSL connection and send any alerts for various errors. - */ -EXP_FUNC int STDCALL ssl_read(SSL *ssl, uint8_t **in_data) -{ - int ret = basic_read(ssl, in_data); - - /* check for return code so we can send an alert */ - if (ret < SSL_OK && ret != SSL_CLOSE_NOTIFY) - { - if (ret != SSL_ERROR_CONN_LOST) - { - send_alert(ssl, ret); -#ifndef CONFIG_SSL_SKELETON_MODE - /* something nasty happened, so get rid of this session */ - kill_ssl_session(ssl->ssl_ctx->ssl_sessions, ssl); -#endif - } - } - - return ret; -} - -/* - * Write application data to the client - */ -EXP_FUNC int STDCALL ssl_write(SSL *ssl, const uint8_t *out_data, int out_len) -{ - int n = out_len, nw, i, tot = 0; - - /* maximum size of a TLS packet is around 16kB, so fragment */ - do - { - nw = n; - - if (nw > RT_MAX_PLAIN_LENGTH) /* fragment if necessary */ - nw = RT_MAX_PLAIN_LENGTH; - - if ((i = send_packet(ssl, PT_APP_PROTOCOL_DATA, - &out_data[tot], nw)) <= 0) - { - out_len = i; /* an error */ - break; - } - - tot += i; - n -= i; - } while (n > 0); - - return out_len; -} - -/** - * Add a certificate to the certificate chain. - */ -int add_cert(SSL_CTX *ssl_ctx, const uint8_t *buf, int len) -{ - int ret = SSL_ERROR_NO_CERT_DEFINED, i = 0; - SSL_CERT *ssl_cert; - X509_CTX *cert = NULL; - int offset; - - while (i < CONFIG_SSL_MAX_CERTS && ssl_ctx->certs[i].buf) - i++; - - if (i == CONFIG_SSL_MAX_CERTS) /* too many certs */ - { -#ifdef CONFIG_SSL_DIAGNOSTICS - printf("Error: maximum number of certs added (%d) - change of " - "compile-time configuration required\n", - CONFIG_SSL_MAX_CERTS); -#endif - goto error; - } - - if ((ret = x509_new(buf, &offset, &cert))) - goto error; - -#if defined (CONFIG_SSL_FULL_MODE) - if (ssl_ctx->options & SSL_DISPLAY_CERTS) - x509_print(cert, NULL); -#endif - - ssl_cert = &ssl_ctx->certs[i]; - ssl_cert->size = len; - ssl_cert->buf = (uint8_t *)malloc(len); - - switch (cert->sig_type) - { - case SIG_TYPE_SHA1: - ssl_cert->hash_alg = SIG_ALG_SHA1; - break; - - case SIG_TYPE_SHA256: - ssl_cert->hash_alg = SIG_ALG_SHA256; - break; - - case SIG_TYPE_SHA384: - ssl_cert->hash_alg = SIG_ALG_SHA384; - break; - - case SIG_TYPE_SHA512: - ssl_cert->hash_alg = SIG_ALG_SHA512; - break; - } - - memcpy(ssl_cert->buf, buf, len); - ssl_ctx->chain_length++; - len -= offset; - ret = SSL_OK; /* ok so far */ - - /* recurse? */ - if (len > 0) - { - ret = add_cert(ssl_ctx, &buf[offset], len); - } - -error: - x509_free(cert); /* don't need anymore */ - return ret; -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION -/** - * Add a certificate authority. - */ -int add_cert_auth(SSL_CTX *ssl_ctx, const uint8_t *buf, int len) -{ - int ret = X509_OK; /* ignore errors for now */ - int i = 0; - CA_CERT_CTX *ca_cert_ctx; - - if (ssl_ctx->ca_cert_ctx == NULL) - ssl_ctx->ca_cert_ctx = (CA_CERT_CTX *)calloc(1, sizeof(CA_CERT_CTX)); - - ca_cert_ctx = ssl_ctx->ca_cert_ctx; - - while (i < CONFIG_X509_MAX_CA_CERTS && ca_cert_ctx->cert[i]) - i++; - - while (len > 0) - { - int offset; - if (i >= CONFIG_X509_MAX_CA_CERTS) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: maximum number of CA certs added (%d) - change of " - "compile-time configuration required\n", - CONFIG_X509_MAX_CA_CERTS); -#endif - ret = X509_MAX_CERTS; - break; - } - - /* ignore the return code */ - if (x509_new(buf, &offset, &ca_cert_ctx->cert[i]) == X509_OK) - { -#if defined (CONFIG_SSL_FULL_MODE) - if (ssl_ctx->options & SSL_DISPLAY_CERTS) - x509_print(ca_cert_ctx->cert[i], NULL); -#endif - } - - i++; - len -= offset; - } - - return ret; -} - -/* - * Retrieve an X.509 distinguished name component - */ -EXP_FUNC const char * STDCALL ssl_get_cert_dn(const SSL *ssl, int component) -{ - if (ssl->x509_ctx == NULL) - return NULL; - - switch (component) - { - case SSL_X509_CERT_COMMON_NAME: - return ssl->x509_ctx->cert_dn[X509_COMMON_NAME]; - - case SSL_X509_CERT_ORGANIZATION: - return ssl->x509_ctx->cert_dn[X509_ORGANIZATION]; - - case SSL_X509_CERT_ORGANIZATIONAL_NAME: - return ssl->x509_ctx->cert_dn[X509_ORGANIZATIONAL_UNIT]; - - case SSL_X509_CERT_LOCATION: - return ssl->x509_ctx->cert_dn[X509_LOCATION]; - - case SSL_X509_CERT_COUNTRY: - return ssl->x509_ctx->cert_dn[X509_COUNTRY]; - - case SSL_X509_CERT_STATE: - return ssl->x509_ctx->cert_dn[X509_STATE]; - - case SSL_X509_CA_CERT_COMMON_NAME: - return ssl->x509_ctx->ca_cert_dn[X509_COMMON_NAME]; - - case SSL_X509_CA_CERT_ORGANIZATION: - return ssl->x509_ctx->ca_cert_dn[X509_ORGANIZATION]; - - case SSL_X509_CA_CERT_ORGANIZATIONAL_NAME: - return ssl->x509_ctx->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]; - - case SSL_X509_CA_CERT_LOCATION: - return ssl->x509_ctx->ca_cert_dn[X509_LOCATION]; - - case SSL_X509_CA_CERT_COUNTRY: - return ssl->x509_ctx->ca_cert_dn[X509_COUNTRY]; - - case SSL_X509_CA_CERT_STATE: - return ssl->x509_ctx->ca_cert_dn[X509_STATE]; - - default: - return NULL; - } -} - -/* - * Retrieve a "Subject Alternative Name" from a v3 certificate - */ -EXP_FUNC const char * STDCALL ssl_get_cert_subject_alt_dnsname(const SSL *ssl, - int dnsindex) -{ - int i; - - if (ssl->x509_ctx == NULL || ssl->x509_ctx->subject_alt_dnsnames == NULL) - return NULL; - - for (i = 0; i < dnsindex; ++i) - { - if (ssl->x509_ctx->subject_alt_dnsnames[i] == NULL) - return NULL; - } - - return ssl->x509_ctx->subject_alt_dnsnames[dnsindex]; -} - -#endif /* CONFIG_SSL_CERT_VERIFICATION */ - -/* - * Find an ssl object based on the client's file descriptor. - */ -EXP_FUNC SSL * STDCALL ssl_find(SSL_CTX *ssl_ctx, long client_fd) -{ - SSL *ssl; - - SSL_CTX_LOCK(ssl_ctx->mutex); - ssl = ssl_ctx->head; - - /* search through all the ssl entries */ - while (ssl) - { - if (ssl->client_fd == client_fd) - { - SSL_CTX_UNLOCK(ssl_ctx->mutex); - return ssl; - } - - ssl = ssl->next; - } - - SSL_CTX_UNLOCK(ssl_ctx->mutex); - return NULL; -} - -/* - * Force the client to perform its handshake again. - */ -EXP_FUNC int STDCALL ssl_renegotiate(SSL *ssl) -{ - int ret = SSL_OK; - - disposable_new(ssl); -#ifdef CONFIG_SSL_ENABLE_CLIENT - if (IS_SET_SSL_FLAG(SSL_IS_CLIENT)) - { - ret = do_client_connect(ssl); - } - else -#endif - { - send_packet(ssl, PT_HANDSHAKE_PROTOCOL, - g_hello_request, sizeof(g_hello_request)); - SET_SSL_FLAG(SSL_NEED_RECORD); - } - - return ret; -} - -/** - * @brief Get what we need for key info. - * @param cipher [in] The cipher information we are after - * @param key_size [out] The key size for the cipher - * @param iv_size [out] The iv size for the cipher - * @return The amount of key information we need. - */ -static const cipher_info_t *get_cipher_info(uint8_t cipher) -{ - int i; - - for (i = 0; i < NUM_PROTOCOLS; i++) - { - if (cipher_info[i].cipher == cipher) - { - return &cipher_info[i]; - } - } - - return NULL; /* error */ -} - -/* - * Get a new ssl context for a new connection. - */ -SSL *ssl_new(SSL_CTX *ssl_ctx, long client_fd) -{ - SSL *ssl = (SSL *)calloc(1, sizeof(SSL)); - ssl->ssl_ctx = ssl_ctx; - ssl->need_bytes = SSL_RECORD_SIZE; /* need a record */ - ssl->client_fd = client_fd; - ssl->flag = SSL_NEED_RECORD; - ssl->bm_data = ssl->bm_all_data+BM_RECORD_OFFSET; /* space at the start */ - ssl->hs_status = SSL_NOT_OK; /* not connected */ -#ifdef CONFIG_ENABLE_VERIFICATION - ssl->ca_cert_ctx = ssl_ctx->ca_cert_ctx; -#endif - disposable_new(ssl); - - /* a bit hacky but saves a few bytes of memory */ - ssl->flag |= ssl_ctx->options; - SSL_CTX_LOCK(ssl_ctx->mutex); - - if (ssl_ctx->head == NULL) - { - ssl_ctx->head = ssl; - ssl_ctx->tail = ssl; - } - else - { - ssl->prev = ssl_ctx->tail; - ssl_ctx->tail->next = ssl; - ssl_ctx->tail = ssl; - } - - SSL_CTX_UNLOCK(ssl_ctx->mutex); - return ssl; -} - -/* - * Add a private key to a context. - */ -int add_private_key(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj) -{ - int ret = SSL_OK; - - /* get the private key details */ - if (asn1_get_private_key(ssl_obj->buf, ssl_obj->len, &ssl_ctx->rsa_ctx)) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - -error: - return ret; -} - -/** - * Increment the read sequence number (as a 64 bit endian indepenent #) - */ -static void increment_read_sequence(SSL *ssl) -{ - int i; - - for (i = 7; i >= 0; i--) - { - if (++ssl->read_sequence[i]) - break; - } -} - -/** - * Increment the read sequence number (as a 64 bit endian indepenent #) - */ -static void increment_write_sequence(SSL *ssl) -{ - int i; - - for (i = 7; i >= 0; i--) - { - if (++ssl->write_sequence[i]) - break; - } -} - -/** - * Work out the HMAC digest in a packet. - */ -static void add_hmac_digest(SSL *ssl, int mode, uint8_t *hmac_header, - const uint8_t *buf, int buf_len, uint8_t *hmac_buf) -{ - int hmac_len = buf_len + 8 + SSL_RECORD_SIZE; - uint8_t *t_buf = (uint8_t *)alloca(hmac_len); - - memcpy(t_buf, (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_WRITE) ? - ssl->write_sequence : ssl->read_sequence, 8); - memcpy(&t_buf[8], hmac_header, SSL_RECORD_SIZE); - memcpy(&t_buf[8+SSL_RECORD_SIZE], buf, buf_len); - - ssl->cipher_info->hmac(t_buf, hmac_len, - (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_READ) ? - ssl->server_mac : ssl->client_mac, - ssl->cipher_info->digest_size, hmac_buf); - -#if 0 - print_blob("record", hmac_header, SSL_RECORD_SIZE); - print_blob("buf", buf, buf_len); - if (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_WRITE) - { - print_blob("write seq", ssl->write_sequence, 8); - } - else - { - print_blob("read seq", ssl->read_sequence, 8); - } - - if (mode == SSL_SERVER_WRITE || mode == SSL_CLIENT_READ) - { - print_blob("server mac", - ssl->server_mac, ssl->cipher_info->digest_size); - } - else - { - print_blob("client mac", - ssl->client_mac, ssl->cipher_info->digest_size); - } - print_blob("hmac", hmac_buf, ssl->cipher_info->digest_size); -#endif -} - -/** - * Verify that the digest of a packet is correct. - */ -static int verify_digest(SSL *ssl, int mode, const uint8_t *buf, int read_len) -{ - uint8_t hmac_buf[SHA256_SIZE]; // size of largest digest - int hmac_offset; - - int last_blk_size = buf[read_len-1], i; - hmac_offset = read_len-last_blk_size-ssl->cipher_info->digest_size-1; - - /* guard against a timing attack - make sure we do the digest */ - if (hmac_offset < 0) - { - hmac_offset = 0; - } - else - { - /* already looked at last byte */ - for (i = 1; i < last_blk_size; i++) - { - if (buf[read_len-i] != last_blk_size) - { - hmac_offset = 0; - break; - } - } - } - - /* sanity check the offset */ - ssl->hmac_header[3] = hmac_offset >> 8; /* insert size */ - ssl->hmac_header[4] = hmac_offset & 0xff; - add_hmac_digest(ssl, mode, ssl->hmac_header, buf, hmac_offset, hmac_buf); - - if (memcmp(hmac_buf, &buf[hmac_offset], ssl->cipher_info->digest_size)) - { - return SSL_ERROR_INVALID_HMAC; - } - - return hmac_offset; -} - -/** - * Add a packet to the end of our sent and received packets, so that we may use - * it to calculate the hash at the end. - */ -void add_packet(SSL *ssl, const uint8_t *pkt, int len) -{ - // TLS1.2+ - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2 || ssl->version == 0) - { - SHA256_Update(&ssl->dc->sha256_ctx, pkt, len); - } - - if (ssl->version < SSL_PROTOCOL_VERSION_TLS1_2 || - ssl->next_state == HS_SERVER_HELLO || - ssl->next_state == 0) - { - MD5_Update(&ssl->dc->md5_ctx, pkt, len); - SHA1_Update(&ssl->dc->sha1_ctx, pkt, len); - } -} - -/** - * Work out the MD5 PRF. - */ -static void p_hash_md5(const uint8_t *sec, int sec_len, - uint8_t *seed, int seed_len, uint8_t *out, int olen) -{ - uint8_t a1[MD5_SIZE+77]; - - /* A(1) */ - ssl_hmac_md5(seed, seed_len, sec, sec_len, a1); - memcpy(&a1[MD5_SIZE], seed, seed_len); - ssl_hmac_md5(a1, MD5_SIZE+seed_len, sec, sec_len, out); - - while (olen > MD5_SIZE) - { - uint8_t a2[MD5_SIZE]; - out += MD5_SIZE; - olen -= MD5_SIZE; - - /* A(N) */ - ssl_hmac_md5(a1, MD5_SIZE, sec, sec_len, a2); - memcpy(a1, a2, MD5_SIZE); - - /* work out the actual hash */ - ssl_hmac_md5(a1, MD5_SIZE+seed_len, sec, sec_len, out); - } -} - -/** - * Work out the SHA1 PRF. - */ -static void p_hash_sha1(const uint8_t *sec, int sec_len, - uint8_t *seed, int seed_len, uint8_t *out, int olen) -{ - uint8_t a1[SHA1_SIZE+77]; - - /* A(1) */ - ssl_hmac_sha1(seed, seed_len, sec, sec_len, a1); - memcpy(&a1[SHA1_SIZE], seed, seed_len); - ssl_hmac_sha1(a1, SHA1_SIZE+seed_len, sec, sec_len, out); - - while (olen > SHA1_SIZE) - { - uint8_t a2[SHA1_SIZE]; - out += SHA1_SIZE; - olen -= SHA1_SIZE; - - /* A(N) */ - ssl_hmac_sha1(a1, SHA1_SIZE, sec, sec_len, a2); - memcpy(a1, a2, SHA1_SIZE); - - /* work out the actual hash */ - ssl_hmac_sha1(a1, SHA1_SIZE+seed_len, sec, sec_len, out); - } -} - -/** - * Work out the SHA256 PRF. - */ -static void p_hash_sha256(const uint8_t *sec, int sec_len, - uint8_t *seed, int seed_len, uint8_t *out, int olen) -{ - uint8_t a1[SHA256_SIZE+77]; - - /* A(1) */ - hmac_sha256(seed, seed_len, sec, sec_len, a1); - memcpy(&a1[SHA256_SIZE], seed, seed_len); - hmac_sha256(a1, SHA256_SIZE+seed_len, sec, sec_len, out); - - while (olen > SHA256_SIZE) - { - uint8_t a2[SHA256_SIZE]; - out += SHA256_SIZE; - olen -= SHA256_SIZE; - - // A(N) - hmac_sha256(a1, SHA256_SIZE, sec, sec_len, a2); - memcpy(a1, a2, SHA256_SIZE); - - // work out the actual hash - hmac_sha256(a1, SHA256_SIZE+seed_len, sec, sec_len, out); - } -} - -/** - * Work out the PRF. - */ -static void prf(SSL *ssl, const uint8_t *sec, int sec_len, - uint8_t *seed, int seed_len, - uint8_t *out, int olen) -{ - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - p_hash_sha256(sec, sec_len, seed, seed_len, out, olen); - } - else // TLS1.0/1.1 - { - int len, i; - const uint8_t *S1, *S2; - uint8_t xbuf[2*(SHA256_SIZE+32+16) + MD5_SIZE]; /* max keyblock */ - uint8_t ybuf[2*(SHA256_SIZE+32+16) + SHA1_SIZE]; /* max keyblock */ - - len = sec_len/2; - S1 = sec; - S2 = &sec[len]; - len += (sec_len & 1); /* add for odd, make longer */ - - p_hash_md5(S1, len, seed, seed_len, xbuf, olen); - p_hash_sha1(S2, len, seed, seed_len, ybuf, olen); - - for (i = 0; i < olen; i++) - out[i] = xbuf[i] ^ ybuf[i]; - } -} - -/** - * Generate a master secret based on the client/server random data and the - * premaster secret. - */ -void generate_master_secret(SSL *ssl, const uint8_t *premaster_secret) -{ - uint8_t buf[77]; -//print_blob("premaster secret", premaster_secret, 48); - strcpy((char *)buf, "master secret"); - memcpy(&buf[13], ssl->dc->client_random, SSL_RANDOM_SIZE); - memcpy(&buf[45], ssl->dc->server_random, SSL_RANDOM_SIZE); - prf(ssl, premaster_secret, SSL_SECRET_SIZE, buf, 77, ssl->dc->master_secret, - SSL_SECRET_SIZE); -#if 0 - print_blob("client random", ssl->dc->client_random, 32); - print_blob("server random", ssl->dc->server_random, 32); - print_blob("master secret", ssl->dc->master_secret, 48); -#endif -} - -/** - * Generate a 'random' blob of data used for the generation of keys. - */ -static void generate_key_block(SSL *ssl, - uint8_t *client_random, uint8_t *server_random, - uint8_t *master_secret, uint8_t *key_block, int key_block_size) -{ - uint8_t buf[77]; - strcpy((char *)buf, "key expansion"); - memcpy(&buf[13], server_random, SSL_RANDOM_SIZE); - memcpy(&buf[45], client_random, SSL_RANDOM_SIZE); - prf(ssl, master_secret, SSL_SECRET_SIZE, buf, 77, - key_block, key_block_size); -} - -/** - * Calculate the digest used in the finished message. This function also - * doubles up as a certificate verify function. - */ -int finished_digest(SSL *ssl, const char *label, uint8_t *digest) -{ - uint8_t mac_buf[SHA1_SIZE+MD5_SIZE+15]; - uint8_t *q = mac_buf; - int dgst_len; - - if (label) - { - strcpy((char *)q, label); - q += strlen(label); - } - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - SHA256_CTX sha256_ctx = ssl->dc->sha256_ctx; // interim copy - SHA256_Final(q, &sha256_ctx); - q += SHA256_SIZE; - dgst_len = (int)(q-mac_buf); - } - else // TLS1.0/1.1 - { - MD5_CTX md5_ctx = ssl->dc->md5_ctx; // interim copy - SHA1_CTX sha1_ctx = ssl->dc->sha1_ctx; - - MD5_Final(q, &md5_ctx); - q += MD5_SIZE; - - SHA1_Final(q, &sha1_ctx); - q += SHA1_SIZE; - dgst_len = (int)(q-mac_buf); - } - - if (label) - { - prf(ssl, ssl->dc->master_secret, SSL_SECRET_SIZE, - mac_buf, dgst_len, digest, SSL_FINISHED_HASH_SIZE); - } - else /* for use in a certificate verify */ - { - memcpy(digest, mac_buf, dgst_len); - } - -#if 0 - printf("label: %s\n", label); - print_blob("mac_buf", mac_buf, dgst_len); - print_blob("finished digest", digest, SSL_FINISHED_HASH_SIZE); -#endif - - return dgst_len; -} - -/** - * Retrieve (and initialise) the context of a cipher. - */ -static void *crypt_new(SSL *ssl, uint8_t *key, uint8_t *iv, int is_decrypt) -{ - switch (ssl->cipher) - { - case SSL_AES128_SHA: - case SSL_AES128_SHA256: - { - AES_CTX *aes_ctx = (AES_CTX *)malloc(sizeof(AES_CTX)); - AES_set_key(aes_ctx, key, iv, AES_MODE_128); - - if (is_decrypt) - { - AES_convert_key(aes_ctx); - } - - return (void *)aes_ctx; - } - - case SSL_AES256_SHA: - case SSL_AES256_SHA256: - { - AES_CTX *aes_ctx = (AES_CTX *)malloc(sizeof(AES_CTX)); - AES_set_key(aes_ctx, key, iv, AES_MODE_256); - - if (is_decrypt) - { - AES_convert_key(aes_ctx); - } - - return (void *)aes_ctx; - } - - } - - return NULL; /* its all gone wrong */ -} - -/** - * Send a packet over the socket. - */ -static int send_raw_packet(SSL *ssl, uint8_t protocol) -{ - uint8_t *rec_buf = ssl->bm_all_data; - int pkt_size = SSL_RECORD_SIZE+ssl->bm_index; - int sent = 0; - int ret = SSL_OK; - - rec_buf[0] = protocol; - rec_buf[1] = 0x03; /* version = 3.1 or higher */ - rec_buf[2] = ssl->version & 0x0f; - rec_buf[3] = ssl->bm_index >> 8; - rec_buf[4] = ssl->bm_index & 0xff; - - DISPLAY_BYTES(ssl, "sending %d bytes", ssl->bm_all_data, - pkt_size, pkt_size); - - while (sent < pkt_size) - { - ret = SOCKET_WRITE(ssl->client_fd, - &ssl->bm_all_data[sent], pkt_size-sent); - - if (ret >= 0) - sent += ret; - else - { - -#ifdef WIN32 - if (GetLastError() != WSAEWOULDBLOCK) -#else - if (SOCKET_ERRNO() != EAGAIN && SOCKET_ERRNO() != EWOULDBLOCK) -#endif - return SSL_ERROR_CONN_LOST; - } - -#ifdef PORT_USE_SELECT - // TODO: This should be factored into SOCKET_WAIT_WRITABLE(), - // with semantic being waiting until socket can be written - // regardless whether it is in blocking or non-blocking mode. - /* keep going until the write buffer has some space */ - if (sent != pkt_size) - { - fd_set wfds; - FD_ZERO(&wfds); - FD_SET(ssl->client_fd, &wfds); - - /* block and wait for it */ - if (select(ssl->client_fd + 1, NULL, &wfds, NULL, NULL) < 0) - return SSL_ERROR_CONN_LOST; - } -#endif - } - - SET_SSL_FLAG(SSL_NEED_RECORD); /* reset for next time */ - ssl->bm_index = 0; - - if (protocol != PT_APP_PROTOCOL_DATA) - { - /* always return SSL_OK during handshake */ - ret = SSL_OK; - } - - return ret; -} - -/** - * Send an encrypted packet with padding bytes if necessary. - */ -int send_packet(SSL *ssl, uint8_t protocol, const uint8_t *in, int length) -{ - int ret, msg_length = 0; - - /* if our state is bad, don't bother */ - if (ssl->hs_status == SSL_ERROR_DEAD) - return SSL_ERROR_CONN_LOST; - - if (IS_SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY)) - return SSL_CLOSE_NOTIFY; - - if (in) /* has the buffer already been initialised? */ - { - memcpy(ssl->bm_data, in, length); - } - - msg_length += length; - - if (IS_SET_SSL_FLAG(SSL_TX_ENCRYPTED)) - { - int mode = IS_SET_SSL_FLAG(SSL_IS_CLIENT) ? - SSL_CLIENT_WRITE : SSL_SERVER_WRITE; - uint8_t hmac_header[SSL_RECORD_SIZE] = - { - protocol, - 0x03, /* version = 3.1 or higher */ - ssl->version & 0x0f, - msg_length >> 8, - msg_length & 0xff - }; - - if (protocol == PT_HANDSHAKE_PROTOCOL) - { - DISPLAY_STATE(ssl, 1, ssl->bm_data[0], 0); - - if (ssl->bm_data[0] != HS_HELLO_REQUEST) - { - add_packet(ssl, ssl->bm_data, msg_length); - } - } - - /* add the packet digest */ - add_hmac_digest(ssl, mode, hmac_header, ssl->bm_data, msg_length, - &ssl->bm_data[msg_length]); - msg_length += ssl->cipher_info->digest_size; - - /* add padding */ - { - int last_blk_size = msg_length%ssl->cipher_info->padding_size; - int pad_bytes = ssl->cipher_info->padding_size - last_blk_size; - - /* ensure we always have at least 1 padding byte */ - if (pad_bytes == 0) - pad_bytes += ssl->cipher_info->padding_size; - - memset(&ssl->bm_data[msg_length], pad_bytes-1, pad_bytes); - msg_length += pad_bytes; - } - - DISPLAY_BYTES(ssl, "unencrypted write", ssl->bm_data, msg_length); - increment_write_sequence(ssl); - - /* add the explicit IV for TLS1.1 */ - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_1) - { - uint8_t iv_size = ssl->cipher_info->iv_size; - uint8_t *t_buf = alloca(msg_length + iv_size); - memcpy(t_buf + iv_size, ssl->bm_data, msg_length); - if (get_random(iv_size, t_buf) < 0) - return SSL_NOT_OK; - - msg_length += iv_size; - memcpy(ssl->bm_data, t_buf, msg_length); - } - - /* now encrypt the packet */ - ssl->cipher_info->encrypt(ssl->encrypt_ctx, ssl->bm_data, - ssl->bm_data, msg_length); - } - else if (protocol == PT_HANDSHAKE_PROTOCOL) - { - DISPLAY_STATE(ssl, 1, ssl->bm_data[0], 0); - - if (ssl->bm_data[0] != HS_HELLO_REQUEST) - { - add_packet(ssl, ssl->bm_data, length); - } - } - - ssl->bm_index = msg_length; - if ((ret = send_raw_packet(ssl, protocol)) <= 0) - return ret; - - return length; /* just return what we wanted to send */ -} - -/** - * Work out the cipher keys we are going to use for this session based on the - * master secret. - */ -static int set_key_block(SSL *ssl, int is_write) -{ - const cipher_info_t *ciph_info = get_cipher_info(ssl->cipher); - uint8_t *q; - uint8_t client_key[32], server_key[32]; /* big enough for AES256 */ - uint8_t client_iv[16], server_iv[16]; /* big enough for AES128/256 */ - int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); - - if (ciph_info == NULL) - return -1; - - /* only do once in a handshake */ - if (!ssl->dc->key_block_generated) - { - generate_key_block(ssl, ssl->dc->client_random, ssl->dc->server_random, - ssl->dc->master_secret, ssl->dc->key_block, - ciph_info->key_block_size); -#if 0 - print_blob("master", ssl->dc->master_secret, SSL_SECRET_SIZE); - print_blob("keyblock", ssl->dc->key_block, ciph_info->key_block_size); - print_blob("client random", ssl->dc->client_random, 32); - print_blob("server random", ssl->dc->server_random, 32); -#endif - ssl->dc->key_block_generated = 1; - } - - q = ssl->dc->key_block; - - if ((is_client && is_write) || (!is_client && !is_write)) - { - memcpy(ssl->client_mac, q, ciph_info->digest_size); - } - - q += ciph_info->digest_size; - - if ((!is_client && is_write) || (is_client && !is_write)) - { - memcpy(ssl->server_mac, q, ciph_info->digest_size); - } - - q += ciph_info->digest_size; - memcpy(client_key, q, ciph_info->key_size); - q += ciph_info->key_size; - memcpy(server_key, q, ciph_info->key_size); - q += ciph_info->key_size; - - memcpy(client_iv, q, ciph_info->iv_size); - q += ciph_info->iv_size; - memcpy(server_iv, q, ciph_info->iv_size); - q += ciph_info->iv_size; -#if 0 - print_blob("client key", client_key, ciph_info->key_size); - print_blob("server key", server_key, ciph_info->key_size); - print_blob("client iv", client_iv, ciph_info->iv_size); - print_blob("server iv", server_iv, ciph_info->iv_size); -#endif - - free(is_write ? ssl->encrypt_ctx : ssl->decrypt_ctx); - - /* now initialise the ciphers */ - if (is_client) - { - finished_digest(ssl, server_finished, ssl->dc->final_finish_mac); - - if (is_write) - ssl->encrypt_ctx = crypt_new(ssl, client_key, client_iv, 0); - else - ssl->decrypt_ctx = crypt_new(ssl, server_key, server_iv, 1); - } - else - { - finished_digest(ssl, client_finished, ssl->dc->final_finish_mac); - - if (is_write) - ssl->encrypt_ctx = crypt_new(ssl, server_key, server_iv, 0); - else - ssl->decrypt_ctx = crypt_new(ssl, client_key, client_iv, 1); - } - - ssl->cipher_info = ciph_info; - return 0; -} - -/** - * Read the SSL connection. - */ -int basic_read(SSL *ssl, uint8_t **in_data) -{ - int ret = SSL_OK; - int read_len, is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); - uint8_t *buf = ssl->bm_data; - - if (IS_SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY)) - return SSL_CLOSE_NOTIFY; - - read_len = SOCKET_READ(ssl->client_fd, &buf[ssl->bm_read_index], - ssl->need_bytes-ssl->got_bytes); - - if (read_len < 0) - { -#ifdef WIN32 - if (GetLastError() == WSAEWOULDBLOCK) -#else - if (SOCKET_ERRNO() == EAGAIN || SOCKET_ERRNO() == EWOULDBLOCK) -#endif - return 0; - } - - /* connection has gone, so die */ - if (read_len <= 0) - { - ret = SSL_ERROR_CONN_LOST; - ssl->hs_status = SSL_ERROR_DEAD; /* make sure it stays dead */ - goto error; - } - - DISPLAY_BYTES(ssl, "received %d bytes", - &ssl->bm_data[ssl->bm_read_index], read_len, read_len); - - ssl->got_bytes += read_len; - ssl->bm_read_index += read_len; - - /* haven't quite got what we want, so try again later */ - if (ssl->got_bytes < ssl->need_bytes) - return SSL_OK; - - read_len = ssl->got_bytes; - ssl->got_bytes = 0; - - if (IS_SET_SSL_FLAG(SSL_NEED_RECORD)) - { - /* check for sslv2 "client hello" */ - if ((buf[0] & 0x80) && buf[2] == 1) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: no SSLv23 handshaking allowed\n"); -#endif - ret = SSL_ERROR_NOT_SUPPORTED; - goto error; /* not an error - just get out of here */ - } - - ssl->need_bytes = (buf[3] << 8) + buf[4]; - - /* do we violate the spec with the message size? */ - if (ssl->need_bytes > RT_MAX_PLAIN_LENGTH+RT_EXTRA-BM_RECORD_OFFSET) - { - printf("TLS buffer overflow, record size: %u (+5)\n", ssl->need_bytes); - ret = SSL_ERROR_RECORD_OVERFLOW; - goto error; - } - - CLR_SSL_FLAG(SSL_NEED_RECORD); - memcpy(ssl->hmac_header, buf, 3); /* store for hmac */ - ssl->record_type = buf[0]; - goto error; /* no error, we're done */ - } - - /* for next time - just do it now in case of an error */ - SET_SSL_FLAG(SSL_NEED_RECORD); - ssl->need_bytes = SSL_RECORD_SIZE; - - /* decrypt if we need to */ - if (IS_SET_SSL_FLAG(SSL_RX_ENCRYPTED)) - { - ssl->cipher_info->decrypt(ssl->decrypt_ctx, buf, buf, read_len); - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_1) - { - buf += ssl->cipher_info->iv_size; - read_len -= ssl->cipher_info->iv_size; - } - - read_len = verify_digest(ssl, - is_client ? SSL_CLIENT_READ : SSL_SERVER_READ, buf, read_len); - - /* does the hmac work? */ - if (read_len < 0) - { - ret = read_len; - goto error; - } - - DISPLAY_BYTES(ssl, "decrypted", buf, read_len); - increment_read_sequence(ssl); - } - - /* The main part of the SSL packet */ - switch (ssl->record_type) - { - case PT_HANDSHAKE_PROTOCOL: - if (ssl->dc != NULL) - { - ssl->dc->bm_proc_index = 0; - ret = do_handshake(ssl, buf, read_len); - } - else /* no client renegotiation allowed */ - { - ret = SSL_ERROR_NO_CLIENT_RENOG; - goto error; - } - break; - - case PT_CHANGE_CIPHER_SPEC: - if (ssl->next_state != HS_FINISHED) - { - ret = SSL_ERROR_INVALID_HANDSHAKE; - goto error; - } - - if (set_key_block(ssl, 0) < 0) - { - ret = SSL_ERROR_INVALID_HANDSHAKE; - goto error; - } - - /* all encrypted from now on */ - SET_SSL_FLAG(SSL_RX_ENCRYPTED); - memset(ssl->read_sequence, 0, 8); - break; - - case PT_APP_PROTOCOL_DATA: - if (in_data && ssl->hs_status == SSL_OK) - { - *in_data = buf; /* point to the work buffer */ - (*in_data)[read_len] = 0; /* null terminate just in case */ - ret = read_len; - } - else - ret = SSL_ERROR_INVALID_PROT_MSG; - break; - - case PT_ALERT_PROTOCOL: - /* return the alert # with alert bit set */ - if (buf[0] == SSL_ALERT_TYPE_WARNING && - buf[1] == SSL_ALERT_CLOSE_NOTIFY) - { - ret = SSL_CLOSE_NOTIFY; - send_alert(ssl, SSL_ALERT_CLOSE_NOTIFY); - SET_SSL_FLAG(SSL_SENT_CLOSE_NOTIFY); - } - else - { - ret = -buf[1]; - DISPLAY_ALERT(ssl, buf[1]); - } - - break; - - default: - ret = SSL_ERROR_INVALID_PROT_MSG; - break; - } - -error: - ssl->bm_read_index = 0; /* reset to go again */ - - if (ret < SSL_OK && in_data)/* if all wrong, then clear this buffer ptr */ - *in_data = NULL; - - return ret; -} - -/** - * Do some basic checking of data and then perform the appropriate handshaking. - */ -static int do_handshake(SSL *ssl, uint8_t *buf, int read_len) -{ - int hs_len = (buf[2]<<8) + buf[3]; - uint8_t handshake_type = buf[0]; - int ret = SSL_OK; - int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); - - /* some integrity checking on the handshake */ - PARANOIA_CHECK(read_len-SSL_HS_HDR_SIZE, hs_len); - - if (handshake_type != ssl->next_state) - { - /* handle a special case on the client */ - if (!is_client || handshake_type != HS_CERT_REQ || - ssl->next_state != HS_SERVER_HELLO_DONE) - { - ret = SSL_ERROR_INVALID_HANDSHAKE; - goto error; - } - } - - hs_len += SSL_HS_HDR_SIZE; /* adjust for when adding packets */ - ssl->bm_index = hs_len; /* store the size and check later */ - DISPLAY_STATE(ssl, 0, handshake_type, 0); - - if (handshake_type != HS_CERT_VERIFY && handshake_type != HS_HELLO_REQUEST) - add_packet(ssl, buf, hs_len); - -#if defined(CONFIG_SSL_ENABLE_CLIENT) && defined(CONFIG_SSL_ENABLE_SERVER) - ret = is_client ? - do_clnt_handshake(ssl, handshake_type, buf, hs_len) : - do_svr_handshake(ssl, handshake_type, buf, hs_len); -#elif defined(CONFIG_SSL_ENABLE_CLIENT) - ret = do_clnt_handshake(ssl, handshake_type, buf, hs_len); -#else - ret = do_svr_handshake(ssl, handshake_type, buf, hs_len); -#endif - - /* just use recursion to get the rest */ - if (hs_len < read_len && ret == SSL_OK) - ret = do_handshake(ssl, &buf[hs_len], read_len-hs_len); - -error: - return ret; -} - -/** - * Sends the change cipher spec message. We have just read a finished message - * from the client. - */ -int send_change_cipher_spec(SSL *ssl) -{ - int ret = send_packet(ssl, PT_CHANGE_CIPHER_SPEC, - g_chg_cipher_spec_pkt, sizeof(g_chg_cipher_spec_pkt)); - - if (ret >= 0 && set_key_block(ssl, 1) < 0) - ret = SSL_ERROR_INVALID_HANDSHAKE; - - if (ssl->cipher_info) - SET_SSL_FLAG(SSL_TX_ENCRYPTED); - - memset(ssl->write_sequence, 0, 8); - return ret; -} - -/** - * Send a "finished" message - */ -int send_finished(SSL *ssl) -{ - uint8_t buf[SHA1_SIZE+MD5_SIZE+15+4] = { - HS_FINISHED, 0, 0, SSL_FINISHED_HASH_SIZE }; - - /* now add the finished digest mac (12 bytes) */ - finished_digest(ssl, - IS_SET_SSL_FLAG(SSL_IS_CLIENT) ? - client_finished : server_finished, &buf[4]); - -#ifndef CONFIG_SSL_SKELETON_MODE - /* store in the session cache */ - if (!IS_SET_SSL_FLAG(SSL_SESSION_RESUME) && ssl->ssl_ctx->num_sessions) - { - memcpy(ssl->session->master_secret, - ssl->dc->master_secret, SSL_SECRET_SIZE); - } -#endif - - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, - buf, SSL_FINISHED_HASH_SIZE+4); -} - -/** - * Send an alert message. - * Return 1 if the alert was an "error". - */ -int send_alert(SSL *ssl, int error_code) -{ - int alert_num = 0; - int is_warning = 0; - uint8_t buf[2]; - - /* Don't bother, we're already dead */ - if (ssl->hs_status == SSL_ERROR_DEAD) - { - return SSL_ERROR_CONN_LOST; - } - -#ifdef CONFIG_SSL_DIAGNOSTICS - if (IS_SET_SSL_FLAG(SSL_DISPLAY_STATES)) - ssl_display_error(error_code); -#endif - - switch (error_code) - { - case SSL_ALERT_CLOSE_NOTIFY: - is_warning = 1; - alert_num = SSL_ALERT_CLOSE_NOTIFY; - break; - - case SSL_ERROR_CONN_LOST: /* don't send alert just yet */ - is_warning = 1; - break; - - case SSL_ERROR_NO_CIPHER: - alert_num = SSL_ALERT_HANDSHAKE_FAILURE; - break; - - case SSL_ERROR_INVALID_HMAC: - alert_num = SSL_ALERT_BAD_RECORD_MAC; - break; - - case SSL_ERROR_FINISHED_INVALID: - case SSL_ERROR_INVALID_KEY: - alert_num = SSL_ALERT_DECRYPT_ERROR; - break; - - case SSL_ERROR_INVALID_VERSION: - alert_num = SSL_ALERT_INVALID_VERSION; - break; - - case SSL_ERROR_INVALID_SESSION: - alert_num = SSL_ALERT_ILLEGAL_PARAMETER; - break; - - case SSL_ERROR_NO_CLIENT_RENOG: - alert_num = SSL_ALERT_NO_RENEGOTIATION; - break; - - case SSL_ERROR_RECORD_OVERFLOW: - alert_num = SSL_ALERT_RECORD_OVERFLOW; - break; - - case SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED): - case SSL_X509_ERROR(X509_VFY_ERROR_NOT_YET_VALID): - alert_num = SSL_ALERT_CERTIFICATE_EXPIRED; - break; - - case SSL_X509_ERROR(X509_VFY_ERROR_NO_TRUSTED_CERT): - alert_num = SSL_ALERT_UNKNOWN_CA; - break; - - case SSL_X509_ERROR(X509_VFY_ERROR_UNSUPPORTED_DIGEST): - case SSL_ERROR_INVALID_CERT_HASH_ALG: - alert_num = SSL_ALERT_UNSUPPORTED_CERTIFICATE; - break; - - case SSL_ERROR_BAD_CERTIFICATE: - case SSL_X509_ERROR(X509_VFY_ERROR_BAD_SIGNATURE): - alert_num = SSL_ALERT_BAD_CERTIFICATE; - break; - - case SSL_ERROR_INVALID_HANDSHAKE: - case SSL_ERROR_INVALID_PROT_MSG: - default: - /* a catch-all for anything bad */ - alert_num = (error_code <= SSL_X509_OFFSET) ? - SSL_ALERT_CERTIFICATE_UNKNOWN: SSL_ALERT_UNEXPECTED_MESSAGE; - break; - } - - buf[0] = is_warning ? 1 : 2; - buf[1] = alert_num; - send_packet(ssl, PT_ALERT_PROTOCOL, buf, sizeof(buf)); - DISPLAY_ALERT(ssl, alert_num); - return is_warning ? 0 : 1; -} - -/** - * Process a client finished message. - */ -int process_finished(SSL *ssl, uint8_t *buf, int hs_len) -{ - int ret = SSL_OK; - int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); - int resume = IS_SET_SSL_FLAG(SSL_SESSION_RESUME); - - PARANOIA_CHECK(ssl->bm_index, SSL_FINISHED_HASH_SIZE+4); - - /* check that we all work before we continue */ - if (memcmp(ssl->dc->final_finish_mac, &buf[4], SSL_FINISHED_HASH_SIZE)) - return SSL_ERROR_FINISHED_INVALID; - - if ((!is_client && !resume) || (is_client && resume)) - { - if ((ret = send_change_cipher_spec(ssl)) == SSL_OK) - ret = send_finished(ssl); - } - - /* if we ever renegotiate */ - ssl->next_state = is_client ? HS_HELLO_REQUEST : HS_CLIENT_HELLO; - ssl->hs_status = ret; /* set the final handshake status */ - -error: - return ret; -} - -/** - * Send a certificate. - */ -int send_certificate(SSL *ssl) -{ - int ret = SSL_OK; - int i = 0; - uint8_t *buf = ssl->bm_data; - int offset = 7; - int chain_length; - - buf[0] = HS_CERTIFICATE; - buf[1] = 0; - buf[4] = 0; - - /* spec says we must check if the hash/sig algorithm is OK */ - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2 && - ((ret = check_certificate_chain(ssl)) != SSL_OK)) - { - ret = SSL_ERROR_INVALID_CERT_HASH_ALG; - goto error; - } - - while (i < ssl->ssl_ctx->chain_length) - { - SSL_CERT *cert = &ssl->ssl_ctx->certs[i]; - buf[offset++] = 0; - buf[offset++] = cert->size >> 8; /* cert 1 length */ - buf[offset++] = cert->size & 0xff; - memcpy(&buf[offset], cert->buf, cert->size); - offset += cert->size; - i++; - } - - chain_length = offset - 7; - buf[5] = chain_length >> 8; /* cert chain length */ - buf[6] = chain_length & 0xff; - chain_length += 3; - buf[2] = chain_length >> 8; /* handshake length */ - buf[3] = chain_length & 0xff; - ssl->bm_index = offset; - ret = send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, offset); - -error: - return ret; -} - -/** - * Create a blob of memory that we'll get rid of once the handshake is - * complete. - */ -void disposable_new(SSL *ssl) -{ - if (ssl->dc == NULL) - { - ssl->dc = (DISPOSABLE_CTX *)calloc(1, sizeof(DISPOSABLE_CTX)); - SHA256_Init(&ssl->dc->sha256_ctx); - MD5_Init(&ssl->dc->md5_ctx); - SHA1_Init(&ssl->dc->sha1_ctx); - } -} - -/** - * Remove the temporary blob of memory. - */ -void disposable_free(SSL *ssl) -{ - if (ssl->dc) - { - memset(ssl->dc, 0, sizeof(DISPOSABLE_CTX)); - free(ssl->dc); - ssl->dc = NULL; - } - -} - -#ifndef CONFIG_SSL_SKELETON_MODE /* no session resumption in this mode */ -/** - * Find if an existing session has the same session id. If so, use the - * master secret from this session for session resumption. - */ -SSL_SESSION *ssl_session_update(int max_sessions, SSL_SESSION *ssl_sessions[], - SSL *ssl, const uint8_t *session_id) -{ - time_t tm = time(NULL); - time_t oldest_sess_time = tm; - SSL_SESSION *oldest_sess = NULL; - int i; - - /* no sessions? Then bail */ - if (max_sessions == 0) - return NULL; - - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - if (session_id) - { - for (i = 0; i < max_sessions; i++) - { - if (ssl_sessions[i]) - { - /* kill off any expired sessions (including those in - the future) */ - if ((tm > ssl_sessions[i]->conn_time + SSL_EXPIRY_TIME) || - (tm < ssl_sessions[i]->conn_time)) - { - session_free(ssl_sessions, i); - continue; - } - - /* if the session id matches, it must still be less than - the expiry time */ - if (memcmp(ssl_sessions[i]->session_id, session_id, - SSL_SESSION_ID_SIZE) == 0) - { - ssl->session_index = i; - memcpy(ssl->dc->master_secret, - ssl_sessions[i]->master_secret, SSL_SECRET_SIZE); - SET_SSL_FLAG(SSL_SESSION_RESUME); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - return ssl_sessions[i]; /* a session was found */ - } - } - } - } - - /* If we've got here, no matching session was found - so create one */ - for (i = 0; i < max_sessions; i++) - { - if (ssl_sessions[i] == NULL) - { - /* perfect, this will do */ - ssl_sessions[i] = (SSL_SESSION *)calloc(1, sizeof(SSL_SESSION)); - ssl_sessions[i]->conn_time = tm; - ssl->session_index = i; - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - return ssl_sessions[i]; /* return the session object */ - } - else if (ssl_sessions[i]->conn_time <= oldest_sess_time) - { - /* find the oldest session */ - oldest_sess_time = ssl_sessions[i]->conn_time; - oldest_sess = ssl_sessions[i]; - ssl->session_index = i; - } - } - - /* ok, we've used up all of our sessions. So blow the oldest session away */ - oldest_sess->conn_time = tm; - memset(oldest_sess->session_id, 0, SSL_SESSION_ID_SIZE); - memset(oldest_sess->master_secret, 0, SSL_SECRET_SIZE); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - return oldest_sess; -} - -/** - * Free an existing session. - */ -static void session_free(SSL_SESSION *ssl_sessions[], int sess_index) -{ - if (ssl_sessions[sess_index]) - { - free(ssl_sessions[sess_index]); - ssl_sessions[sess_index] = NULL; - } -} - -/** - * This ssl object doesn't want this session anymore. - */ -void kill_ssl_session(SSL_SESSION **ssl_sessions, SSL *ssl) -{ - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - - if (ssl->ssl_ctx->num_sessions) - { - session_free(ssl_sessions, ssl->session_index); - ssl->session = NULL; - } - - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); -} -#endif /* CONFIG_SSL_SKELETON_MODE */ - -/* - * Get the session id for a handshake. This will be a 32 byte sequence. - */ -EXP_FUNC const uint8_t * STDCALL ssl_get_session_id(const SSL *ssl) -{ - return ssl->session_id; -} - -/* - * Get the session id size for a handshake. - */ -EXP_FUNC uint8_t STDCALL ssl_get_session_id_size(const SSL *ssl) -{ - return ssl->sess_id_size; -} - -/* - * Return the cipher id (in the SSL form). - */ -EXP_FUNC uint8_t STDCALL ssl_get_cipher_id(const SSL *ssl) -{ - return ssl->cipher; -} - -/* - * Return the status of the handshake. - */ -EXP_FUNC int STDCALL ssl_handshake_status(const SSL *ssl) -{ - return ssl->hs_status; -} - -/* - * Retrieve various parameters about the SSL engine. - */ -EXP_FUNC int STDCALL ssl_get_config(int offset) -{ - switch (offset) - { - /* return the appropriate build mode */ - case SSL_BUILD_MODE: -#if defined(CONFIG_SSL_FULL_MODE) - return SSL_BUILD_FULL_MODE; -#elif defined(CONFIG_SSL_ENABLE_CLIENT) - return SSL_BUILD_ENABLE_CLIENT; -#elif defined(CONFIG_ENABLE_VERIFICATION) - return SSL_BUILD_ENABLE_VERIFICATION; -#elif defined(CONFIG_SSL_SERVER_ONLY ) - return SSL_BUILD_SERVER_ONLY; -#else - return SSL_BUILD_SKELETON_MODE; -#endif - - case SSL_MAX_CERT_CFG_OFFSET: - return CONFIG_SSL_MAX_CERTS; - -#ifdef CONFIG_SSL_CERT_VERIFICATION - case SSL_MAX_CA_CERT_CFG_OFFSET: - return CONFIG_X509_MAX_CA_CERTS; -#endif -#ifdef CONFIG_SSL_HAS_PEM - case SSL_HAS_PEM: - return 1; -#endif - default: - return 0; - } -} - -/** - * Check the certificate chain to see if the certs are supported - */ -static int check_certificate_chain(SSL *ssl) -{ - int i = 0; - int ret = SSL_OK; - - while (i < ssl->ssl_ctx->chain_length) - { - int j = 0; - uint8_t found = 0; - SSL_CERT *cert = &ssl->ssl_ctx->certs[i]; - - while (j < ssl->num_sig_algs) - { - if (ssl->sig_algs[j++] == cert->hash_alg) - { - found = 1; - break; - } - } - - if (!found) - { - - ret = SSL_ERROR_INVALID_CERT_HASH_ALG; - goto error; - } - - i++; - } - -error: - return ret; -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION -/** - * Authenticate a received certificate. - */ -EXP_FUNC int STDCALL ssl_verify_cert(const SSL *ssl) -{ - int ret; - int pathLenConstraint = 0; - - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - ret = x509_verify(ssl->ssl_ctx->ca_cert_ctx, ssl->x509_ctx, - &pathLenConstraint); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - - if (ret) /* modify into an SSL error type */ - { - ret = SSL_X509_ERROR(ret); - } - - return ret; -} -#endif /* CONFIG_SSL_CERT_VERIFICATION */ - -/** - * Process a certificate message. - */ -int process_certificate(SSL *ssl, X509_CTX **x509_ctx) -{ - int ret = SSL_OK; - uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; - int pkt_size = ssl->bm_index; - int cert_size, offset = 5, offset_start; - int total_cert_len = (buf[offset]<<8) + buf[offset+1]; - int is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT); - X509_CTX *chain = 0; - X509_CTX **certs = 0; - int *cert_used = 0; - int num_certs = 0; - int i = 0; - offset += 2; - - PARANOIA_CHECK(pkt_size, total_cert_len + offset); - - // record the start point for the second pass - offset_start = offset; - - // first pass - count the certificates - while (offset < total_cert_len) - { - offset++; /* skip empty char */ - cert_size = (buf[offset]<<8) + buf[offset+1]; - offset += 2; - offset += cert_size; - num_certs++; - } - - PARANOIA_CHECK(pkt_size, offset); - - certs = (X509_CTX**) calloc(num_certs, sizeof(void*)); - cert_used = (int*) calloc(num_certs, sizeof(int)); - num_certs = 0; - - // restore the offset from the saved value - offset = offset_start; - - // second pass - load the certificates - while (offset < total_cert_len) - { - offset++; /* skip empty char */ - cert_size = (buf[offset]<<8) + buf[offset+1]; - offset += 2; - - if (x509_new(&buf[offset], NULL, certs+num_certs)) - { - ret = SSL_ERROR_BAD_CERTIFICATE; - goto error; - } - -#if defined (CONFIG_SSL_FULL_MODE) - if (ssl->ssl_ctx->options & SSL_DISPLAY_CERTS) - x509_print(certs[num_certs], NULL); -#endif - num_certs++; - offset += cert_size; - } - - PARANOIA_CHECK(pkt_size, offset); - - // third pass - link certs together, assume server cert is the first - *x509_ctx = certs[0]; - chain = certs[0]; - cert_used[0] = 1; - -#ifndef CONFIG_SSL_SKELETON_MODE - // repeat until the end of the chain is found - while (1) - { - // look for CA cert - for( i = 1; i < num_certs; i++ ) - { - if (certs[i] == chain) - continue; - - if (cert_used[i]) - continue; // don't allow loops - - if (asn1_compare_dn(chain->ca_cert_dn, certs[i]->cert_dn) == 0) - { - // CA cert found, add it to the chain - cert_used[i] = 1; - chain->next = certs[i]; - chain = certs[i]; - break; - } - } - - // no CA cert found, reached the end of the chain - if (i >= num_certs) - break; - } - - // clean up any certs that aren't part of the chain - for (i = 1; i < num_certs; i++) - { - if (cert_used[i] == 0) - x509_free(certs[i]); - } - - /* if we are client we can do the verify now or later */ - if (is_client && !IS_SET_SSL_FLAG(SSL_SERVER_VERIFY_LATER)) - { - ret = ssl_verify_cert(ssl); - } -#endif - - ssl->next_state = is_client ? HS_SERVER_HELLO_DONE : HS_CLIENT_KEY_XCHG; - ssl->dc->bm_proc_index += offset; -error: - // clean up arrays - if (certs) - free(certs); - - if (cert_used) - free(cert_used); - - return ret; -} - -//#endif /* CONFIG_SSL_CERT_VERIFICATION */ - -/** - * Debugging routine to display SSL handshaking stuff. - */ -#ifdef CONFIG_SSL_DIAGNOSTICS -/** - * Debugging routine to display SSL states. - */ -void DISPLAY_STATE(SSL *ssl, int is_send, uint8_t state, int not_ok) -{ - const char *str; - - if (!IS_SET_SSL_FLAG(SSL_DISPLAY_STATES)) - return; - - printf(not_ok ? "Error - invalid State:\t" : "State:\t"); - printf(is_send ? "sending " : "receiving "); - - switch (state) - { - case HS_HELLO_REQUEST: - str = "Hello Request (0)"; - break; - - case HS_CLIENT_HELLO: - str = "Client Hello (1)"; - break; - - case HS_SERVER_HELLO: - str = "Server Hello (2)"; - break; - - case HS_CERTIFICATE: - str = "Certificate (11)"; - break; - - case HS_SERVER_KEY_XCHG: - str = "Certificate Request (12)"; - break; - - case HS_CERT_REQ: - str = "Certificate Request (13)"; - break; - - case HS_SERVER_HELLO_DONE: - str = "Server Hello Done (14)"; - break; - - case HS_CERT_VERIFY: - str = "Certificate Verify (15)"; - break; - - case HS_CLIENT_KEY_XCHG: - str = "Client Key Exchange (16)"; - break; - - case HS_FINISHED: - str = "Finished (16)"; - break; - - default: - str = "Error (Unknown)"; - - break; - } - - printf("%s\n", str); -} - -/** - * Debugging routine to display RSA objects - */ -void DISPLAY_RSA(SSL *ssl, const RSA_CTX *rsa_ctx) -{ -#ifdef CONFIG_SSL_FULL_MODE - if (!IS_SET_SSL_FLAG(SSL_DISPLAY_RSA)) - return; - - RSA_print(rsa_ctx); - TTY_FLUSH(); -#endif -} - -/** - * Debugging routine to display SSL handshaking bytes. - */ -void DISPLAY_BYTES(SSL *ssl, const char *format, - const uint8_t *data, int size, ...) -{ - va_list(ap); - - if (!IS_SET_SSL_FLAG(SSL_DISPLAY_BYTES)) - return; - - va_start(ap, size); - print_blob(format, data, size, va_arg(ap, char *)); - va_end(ap); - TTY_FLUSH(); -} - -/** - * Debugging routine to display SSL handshaking errors. - */ -EXP_FUNC void STDCALL ssl_display_error(int error_code) -{ - if (error_code == SSL_OK) - return; - - printf("Error: "); - - /* X509 error? */ - if (error_code < SSL_X509_OFFSET) - { - printf("%s\n", x509_display_error(error_code - SSL_X509_OFFSET)); - return; - } - - /* SSL alert error code */ - if (error_code > SSL_ERROR_CONN_LOST) - { - printf("SSL error %d\n", -error_code); - return; - } - - switch (error_code) - { - case SSL_ERROR_DEAD: - printf("connection dead"); - break; - - case SSL_ERROR_RECORD_OVERFLOW: - printf("record overflow"); - break; - - case SSL_ERROR_INVALID_HANDSHAKE: - printf("invalid handshake"); - break; - - case SSL_ERROR_INVALID_PROT_MSG: - printf("invalid protocol message"); - break; - - case SSL_ERROR_INVALID_HMAC: - printf("invalid mac"); - break; - - case SSL_ERROR_INVALID_VERSION: - printf("invalid version"); - break; - - case SSL_ERROR_INVALID_SESSION: - printf("invalid session"); - break; - - case SSL_ERROR_NO_CIPHER: - printf("no cipher"); - break; - - case SSL_ERROR_INVALID_CERT_HASH_ALG: - printf("invalid cert hash algorithm"); - break; - - case SSL_ERROR_CONN_LOST: - printf("connection lost"); - break; - - case SSL_ERROR_BAD_CERTIFICATE: - printf("bad certificate"); - break; - - case SSL_ERROR_INVALID_KEY: - printf("invalid key"); - break; - - case SSL_ERROR_FINISHED_INVALID: - printf("finished invalid"); - break; - - case SSL_ERROR_NO_CERT_DEFINED: - printf("no certificate defined"); - break; - - case SSL_ERROR_NO_CLIENT_RENOG: - printf("client renegotiation not supported"); - break; - - case SSL_ERROR_NOT_SUPPORTED: - printf("Option not supported"); - break; - - default: - printf("undefined as yet - %d", error_code); - break; - } - - printf("\n"); -} - -/** - * Debugging routine to display alerts. - */ - -/** - * Debugging routine to display alerts. - */ -void DISPLAY_ALERT(SSL *ssl, int alert) -{ - if (!IS_SET_SSL_FLAG(SSL_DISPLAY_STATES)) - return; - - printf("Alert: "); - - switch (alert) - { - case SSL_ALERT_CLOSE_NOTIFY: - printf("close notify"); - break; - - case SSL_ALERT_UNEXPECTED_MESSAGE: - printf("unexpected message"); - break; - - case SSL_ALERT_BAD_RECORD_MAC: - printf("bad record mac"); - break; - - case SSL_ALERT_RECORD_OVERFLOW: - printf("record overlow"); - break; - - case SSL_ALERT_HANDSHAKE_FAILURE: - printf("handshake failure"); - break; - - case SSL_ALERT_BAD_CERTIFICATE: - printf("bad certificate"); - break; - - case SSL_ALERT_UNSUPPORTED_CERTIFICATE: - printf("unsupported certificate"); - break; - - case SSL_ALERT_CERTIFICATE_EXPIRED: - printf("certificate expired"); - break; - - case SSL_ALERT_CERTIFICATE_UNKNOWN: - printf("certificate unknown"); - break; - - case SSL_ALERT_ILLEGAL_PARAMETER: - printf("illegal parameter"); - break; - - case SSL_ALERT_UNKNOWN_CA: - printf("unknown ca"); - break; - - case SSL_ALERT_DECODE_ERROR: - printf("decode error"); - break; - - case SSL_ALERT_DECRYPT_ERROR: - printf("decrypt error"); - break; - - case SSL_ALERT_INVALID_VERSION: - printf("invalid version"); - break; - - case SSL_ALERT_NO_RENEGOTIATION: - printf("no renegotiation"); - break; - - default: - printf("alert - (unknown %d)", alert); - break; - } - - printf("\n"); -} - -#endif /* CONFIG_SSL_FULL_MODE */ - -/** - * Return the version of this library. - */ -EXP_FUNC const char * STDCALL ssl_version() -{ - static const char * axtls_version = AXTLS_VERSION; - return axtls_version; -} - -/** - * Enable the various language bindings to work regardless of the - * configuration - they just return an error statement and a bad return code. - */ -#if !defined(CONFIG_SSL_DIAGNOSTICS) -EXP_FUNC void STDCALL ssl_display_error(int error_code) {} -#endif - -#ifdef CONFIG_BINDINGS -#if !defined(CONFIG_SSL_ENABLE_CLIENT) -EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, long client_fd, const - uint8_t *session_id, uint8_t sess_id_size) -{ - printf("%s", unsupported_str); - return NULL; -} -#endif - -#if !defined(CONFIG_SSL_CERT_VERIFICATION) -EXP_FUNC int STDCALL ssl_verify_cert(const SSL *ssl) -{ - printf("%s", unsupported_str); - return -1; -} - - -EXP_FUNC const char * STDCALL ssl_get_cert_dn(const SSL *ssl, int component) -{ - printf("%s", unsupported_str); - return NULL; -} - -EXP_FUNC const char * STDCALL ssl_get_cert_subject_alt_dnsname(const SSL *ssl, int index) -{ - printf("%s", unsupported_str); - return NULL; -} - -#endif /* CONFIG_SSL_CERT_VERIFICATION */ - -#endif /* CONFIG_BINDINGS */ - diff --git a/user/mpy/lib/axtls/ssl/tls1.h b/user/mpy/lib/axtls/ssl/tls1.h deleted file mode 100755 index b656380..0000000 --- a/user/mpy/lib/axtls/ssl/tls1.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file tls1.h - * - * @brief The definitions for the TLS library. - */ -#ifndef HEADER_SSL_LIB_H -#define HEADER_SSL_LIB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "version.h" -#include "config.h" -#include "os_int.h" -#include "os_port.h" -#include "crypto.h" -#include "crypto_misc.h" - -#define SSL_PROTOCOL_MIN_VERSION 0x31 /* TLS v1.0 */ -#define SSL_PROTOCOL_VERSION_MAX 0x33 /* TLS v1.3 */ -#define SSL_PROTOCOL_VERSION_TLS1_1 0x32 /* TLS v1.1 */ -#define SSL_PROTOCOL_VERSION_TLS1_2 0x33 /* TLS v1.2 */ -#define SSL_RANDOM_SIZE 32 -#define SSL_SECRET_SIZE 48 -#define SSL_FINISHED_HASH_SIZE 12 -#define SSL_RECORD_SIZE 5 -#define SSL_SERVER_READ 0 -#define SSL_SERVER_WRITE 1 -#define SSL_CLIENT_READ 2 -#define SSL_CLIENT_WRITE 3 -#define SSL_HS_HDR_SIZE 4 - -/* the flags we use while establishing a connection */ -#define SSL_NEED_RECORD 0x0001 -#define SSL_TX_ENCRYPTED 0x0002 -#define SSL_RX_ENCRYPTED 0x0004 -#define SSL_SESSION_RESUME 0x0008 -#define SSL_IS_CLIENT 0x0010 -#define SSL_HAS_CERT_REQ 0x0020 -#define SSL_SENT_CLOSE_NOTIFY 0x0040 - -/* some macros to muck around with flag bits */ -#define SET_SSL_FLAG(A) (ssl->flag |= A) -#define CLR_SSL_FLAG(A) (ssl->flag &= ~A) -#define IS_SET_SSL_FLAG(A) (ssl->flag & A) - -#define MAX_KEY_BYTE_SIZE 512 /* for a 4096 bit key */ -/* On send, will send another SSL fragment if plaintext exceeds RT_MAX_PLAIN_LENGTH */ -#ifndef RT_MAX_PLAIN_LENGTH -#define RT_MAX_PLAIN_LENGTH 16384 -#endif -/* Total receive buffer is RT_MAX_PLAIN_LENGTH + RT_EXTRA */ -#ifndef RT_EXTRA -#define RT_EXTRA 1024 -#endif -#define BM_RECORD_OFFSET 5 - -#define NUM_PROTOCOLS 4 - -#define MAX_SIG_ALGORITHMS 4 -#define SIG_ALG_SHA1 2 -#define SIG_ALG_SHA256 4 -#define SIG_ALG_SHA384 5 -#define SIG_ALG_SHA512 6 -#define SIG_ALG_RSA 1 - -#define PARANOIA_CHECK(A, B) if (A < B) { \ - ret = SSL_ERROR_INVALID_HANDSHAKE; goto error; } - -/* protocol types */ -enum -{ - PT_CHANGE_CIPHER_SPEC = 20, - PT_ALERT_PROTOCOL, - PT_HANDSHAKE_PROTOCOL, - PT_APP_PROTOCOL_DATA -}; - -/* handshaking types */ -enum -{ - HS_HELLO_REQUEST, - HS_CLIENT_HELLO, - HS_SERVER_HELLO, - HS_CERTIFICATE = 11, - HS_SERVER_KEY_XCHG, - HS_CERT_REQ, - HS_SERVER_HELLO_DONE, - HS_CERT_VERIFY, - HS_CLIENT_KEY_XCHG, - HS_FINISHED = 20 -}; - -/* SSL extension types */ -enum -{ - SSL_EXT_SERVER_NAME = 0, - SSL_EXT_MAX_FRAGMENT_SIZE, - SSL_EXT_SIG_ALG = 0x0d, -}; - -typedef struct -{ - uint8_t cipher; - uint8_t key_size; - uint8_t iv_size; - uint8_t padding_size; - uint8_t digest_size; - uint8_t key_block_size; - hmac_func hmac; - crypt_func encrypt; - crypt_func decrypt; -} cipher_info_t; - -struct _SSLObjLoader -{ - uint8_t *buf; - int len; -}; - -typedef struct _SSLObjLoader SSLObjLoader; - -typedef struct -{ - time_t conn_time; - uint8_t session_id[SSL_SESSION_ID_SIZE]; - uint8_t master_secret[SSL_SECRET_SIZE]; -} SSL_SESSION; - -typedef struct -{ - uint8_t *buf; - int size; - uint8_t hash_alg; -} SSL_CERT; - -typedef struct -{ - MD5_CTX md5_ctx; - SHA1_CTX sha1_ctx; - SHA256_CTX sha256_ctx; - uint8_t client_random[SSL_RANDOM_SIZE]; /* client's random sequence */ - uint8_t server_random[SSL_RANDOM_SIZE]; /* server's random sequence */ - uint8_t final_finish_mac[128]; - uint8_t master_secret[SSL_SECRET_SIZE]; - uint8_t key_block[256]; - uint16_t bm_proc_index; - uint8_t key_block_generated; -} DISPOSABLE_CTX; - -typedef struct -{ - char *host_name; /* Needed for the SNI support */ - /* Needed for the Max Fragment Size Extension. - Allowed values: 2^9, 2^10 .. 2^14 */ - uint16_t max_fragment_size; -} SSL_EXTENSIONS; - -struct _SSL -{ - uint32_t flag; - uint16_t need_bytes; - uint16_t got_bytes; - uint8_t record_type; - uint8_t cipher; - uint8_t sess_id_size; - uint8_t version; - uint8_t client_version; - int16_t next_state; - int16_t hs_status; - DISPOSABLE_CTX *dc; /* temporary data which we'll get rid of soon */ - long client_fd; - const cipher_info_t *cipher_info; - void *encrypt_ctx; - void *decrypt_ctx; - uint8_t bm_all_data[RT_MAX_PLAIN_LENGTH+RT_EXTRA]; - uint8_t *bm_data; - uint16_t bm_index; - uint16_t bm_read_index; - uint8_t sig_algs[MAX_SIG_ALGORITHMS]; - uint8_t num_sig_algs; - struct _SSL *next; /* doubly linked list */ - struct _SSL *prev; - struct _SSL_CTX *ssl_ctx; /* back reference to a clnt/svr ctx */ -#ifndef CONFIG_SSL_SKELETON_MODE - uint16_t session_index; - SSL_SESSION *session; -#endif -#if defined(CONFIG_SSL_CERT_VERIFICATION) || defined(CONFIG_SSL_ENABLE_CLIENT) - X509_CTX *x509_ctx; -#endif - - uint8_t session_id[SSL_SESSION_ID_SIZE]; - uint8_t client_mac[SHA256_SIZE]; /* for HMAC verification */ - uint8_t server_mac[SHA256_SIZE]; /* for HMAC verification */ - uint8_t read_sequence[8]; /* 64 bit sequence number */ - uint8_t write_sequence[8]; /* 64 bit sequence number */ - uint8_t hmac_header[SSL_RECORD_SIZE]; /* rx hmac */ - SSL_EXTENSIONS *extensions; /* Contains the SSL (client) extensions */ -}; - -typedef struct _SSL SSL; - -struct _SSL_CTX -{ - uint32_t options; - uint8_t chain_length; - RSA_CTX *rsa_ctx; -#ifdef CONFIG_SSL_CERT_VERIFICATION - CA_CERT_CTX *ca_cert_ctx; -#endif - SSL *head; - SSL *tail; - SSL_CERT certs[CONFIG_SSL_MAX_CERTS]; -#ifndef CONFIG_SSL_SKELETON_MODE - uint16_t num_sessions; - SSL_SESSION **ssl_sessions; -#endif -#ifdef CONFIG_SSL_CTX_MUTEXING - SSL_CTX_MUTEX_TYPE mutex; -#endif -#ifdef CONFIG_OPENSSL_COMPATIBLE - void *bonus_attr; -#endif -}; - -typedef struct _SSL_CTX SSL_CTX; - -/* backwards compatibility */ -typedef struct _SSL_CTX SSLCTX; - -extern const uint8_t ssl_prot_prefs[NUM_PROTOCOLS]; - -SSL *ssl_new(SSL_CTX *ssl_ctx, long client_fd); -void disposable_new(SSL *ssl); -void disposable_free(SSL *ssl); -int send_packet(SSL *ssl, uint8_t protocol, - const uint8_t *in, int length); -int do_svr_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len); -int do_clnt_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len); -int process_finished(SSL *ssl, uint8_t *buf, int hs_len); -int process_sslv23_client_hello(SSL *ssl); -int send_alert(SSL *ssl, int error_code); -int send_finished(SSL *ssl); -int send_certificate(SSL *ssl); -int basic_read(SSL *ssl, uint8_t **in_data); -int send_change_cipher_spec(SSL *ssl); -int finished_digest(SSL *ssl, const char *label, uint8_t *digest); -void generate_master_secret(SSL *ssl, const uint8_t *premaster_secret); -void add_packet(SSL *ssl, const uint8_t *pkt, int len); -int add_cert(SSL_CTX *ssl_ctx, const uint8_t *buf, int len); -int add_private_key(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj); -void ssl_obj_free(SSLObjLoader *ssl_obj); -int pkcs8_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password); -int pkcs12_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password); -int load_key_certs(SSL_CTX *ssl_ctx); -#ifdef CONFIG_SSL_CERT_VERIFICATION -int add_cert_auth(SSL_CTX *ssl_ctx, const uint8_t *buf, int len); -void remove_ca_certs(CA_CERT_CTX *ca_cert_ctx); -#endif -#ifdef CONFIG_SSL_ENABLE_CLIENT -int do_client_connect(SSL *ssl); -#endif - -#ifdef CONFIG_SSL_DIAGNOSTICS -void DISPLAY_STATE(SSL *ssl, int is_send, uint8_t state, int not_ok); -void DISPLAY_BYTES(SSL *ssl, const char *format, - const uint8_t *data, int size, ...); -void DISPLAY_CERT(SSL *ssl, const X509_CTX *x509_ctx); -void DISPLAY_RSA(SSL *ssl, const RSA_CTX *rsa_ctx); -void DISPLAY_ALERT(SSL *ssl, int alert); -#else -#define DISPLAY_STATE(A,B,C,D) -#define DISPLAY_CERT(A,B) -#define DISPLAY_RSA(A,B) -#define DISPLAY_ALERT(A, B) -#ifdef WIN32 -void DISPLAY_BYTES(SSL *ssl, const char *format,/* win32 has no variadic macros */ - const uint8_t *data, int size, ...); -#else -#define DISPLAY_BYTES(A,B,C,D,...) -#endif -#endif - -//#ifdef CONFIG_SSL_CERT_VERIFICATION -int process_certificate(SSL *ssl, X509_CTX **x509_ctx); -//#endif - -SSL_SESSION *ssl_session_update(int max_sessions, - SSL_SESSION *ssl_sessions[], SSL *ssl, - const uint8_t *session_id); -void kill_ssl_session(SSL_SESSION **ssl_sessions, SSL *ssl); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/axtls/ssl/tls1_clnt.c b/user/mpy/lib/axtls/ssl/tls1_clnt.c deleted file mode 100644 index 667825f..0000000 --- a/user/mpy/lib/axtls/ssl/tls1_clnt.c +++ /dev/null @@ -1,546 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -#ifdef CONFIG_SSL_ENABLE_CLIENT /* all commented out if no client */ - -/* support sha512/384/256/1 RSA */ -static const uint8_t g_sig_alg[] = { - 0x00, SSL_EXT_SIG_ALG, - 0x00, 0x0a, 0x00, 0x08, - SIG_ALG_SHA512, SIG_ALG_RSA, - SIG_ALG_SHA384, SIG_ALG_RSA, - SIG_ALG_SHA256, SIG_ALG_RSA, - SIG_ALG_SHA1, SIG_ALG_RSA -}; - -static const uint8_t g_asn1_sha256[] = -{ - 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, - 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 -}; - -static int send_client_hello(SSL *ssl); -static int process_server_hello(SSL *ssl); -static int process_server_hello_done(SSL *ssl); -static int send_client_key_xchg(SSL *ssl); -static int process_cert_req(SSL *ssl); -static int send_cert_verify(SSL *ssl); - -/* - * Establish a new SSL connection to an SSL server. - */ -EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, long client_fd, const - uint8_t *session_id, uint8_t sess_id_size, SSL_EXTENSIONS* ssl_ext) -{ - SSL *ssl = ssl_new(ssl_ctx, client_fd); - ssl->version = SSL_PROTOCOL_VERSION_MAX; /* try top version first */ - -#ifndef CONFIG_SSL_SKELETON_MODE - if (session_id && ssl_ctx->num_sessions) - { - if (sess_id_size > SSL_SESSION_ID_SIZE) /* validity check */ - { - ssl_free(ssl); - return NULL; - } - - memcpy(ssl->session_id, session_id, sess_id_size); - ssl->sess_id_size = sess_id_size; - SET_SSL_FLAG(SSL_SESSION_RESUME); /* just flag for later */ - } -#endif - - ssl->extensions = ssl_ext; - - SET_SSL_FLAG(SSL_IS_CLIENT); - do_client_connect(ssl); - return ssl; -} - -/* - * Process the handshake record. - */ -int do_clnt_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len) -{ - int ret; - - /* To get here the state must be valid */ - switch (handshake_type) - { - case HS_SERVER_HELLO: - ret = process_server_hello(ssl); - break; - - case HS_CERTIFICATE: - ret = process_certificate(ssl, &ssl->x509_ctx); - break; - - case HS_SERVER_HELLO_DONE: - if ((ret = process_server_hello_done(ssl)) == SSL_OK) - { - if (IS_SET_SSL_FLAG(SSL_HAS_CERT_REQ)) - { - if ((ret = send_certificate(ssl)) == SSL_OK && - (ret = send_client_key_xchg(ssl)) == SSL_OK) - { - send_cert_verify(ssl); - } - } - else - { - ret = send_client_key_xchg(ssl); - } - - if (ret == SSL_OK && - (ret = send_change_cipher_spec(ssl)) == SSL_OK) - { - ret = send_finished(ssl); - } - } - break; - - case HS_CERT_REQ: - ret = process_cert_req(ssl); - break; - - case HS_FINISHED: - ret = process_finished(ssl, buf, hs_len); - disposable_free(ssl); /* free up some memory */ - /* note: client renegotiation is not allowed after this */ - break; - - case HS_HELLO_REQUEST: - disposable_new(ssl); - ret = do_client_connect(ssl); - break; - - default: - ret = SSL_ERROR_INVALID_HANDSHAKE; - break; - } - - return ret; -} - -/* - * Do the handshaking from the beginning. - */ -int do_client_connect(SSL *ssl) -{ - int ret = SSL_OK; - - send_client_hello(ssl); /* send the client hello */ - ssl->bm_read_index = 0; - ssl->next_state = HS_SERVER_HELLO; - ssl->hs_status = SSL_NOT_OK; /* not connected */ - - /* sit in a loop until it all looks good */ - if (!IS_SET_SSL_FLAG(SSL_CONNECT_IN_PARTS)) - { - while (ssl->hs_status != SSL_OK) - { - ret = ssl_read(ssl, NULL); - - if (ret < SSL_OK) - break; - } - - ssl->hs_status = ret; /* connected? */ - } - - return ret; -} - -/* - * Send the initial client hello. - */ -static int send_client_hello(SSL *ssl) -{ - uint8_t *buf = ssl->bm_data; - time_t tm = time(NULL); - uint8_t *tm_ptr = &buf[6]; /* time will go here */ - int i, offset, ext_offset; - int ext_len = 0; - - - buf[0] = HS_CLIENT_HELLO; - buf[1] = 0; - buf[2] = 0; - /* byte 3 is calculated later */ - buf[4] = 0x03; - buf[5] = ssl->version & 0x0f; - - /* client random value - spec says that 1st 4 bytes are big endian time */ - *tm_ptr++ = (uint8_t)(((long)tm & 0xff000000) >> 24); - *tm_ptr++ = (uint8_t)(((long)tm & 0x00ff0000) >> 16); - *tm_ptr++ = (uint8_t)(((long)tm & 0x0000ff00) >> 8); - *tm_ptr++ = (uint8_t)(((long)tm & 0x000000ff)); - if (get_random(SSL_RANDOM_SIZE-4, &buf[10]) < 0) - return SSL_NOT_OK; - - memcpy(ssl->dc->client_random, &buf[6], SSL_RANDOM_SIZE); - offset = 6 + SSL_RANDOM_SIZE; - - /* give session resumption a go */ - if (IS_SET_SSL_FLAG(SSL_SESSION_RESUME)) /* set initially by user */ - { - buf[offset++] = ssl->sess_id_size; - memcpy(&buf[offset], ssl->session_id, ssl->sess_id_size); - offset += ssl->sess_id_size; - CLR_SSL_FLAG(SSL_SESSION_RESUME); /* clear so we can set later */ - } - else - { - /* no session id - because no session resumption just yet */ - buf[offset++] = 0; - } - - buf[offset++] = 0; /* number of ciphers */ - buf[offset++] = NUM_PROTOCOLS*2;/* number of ciphers */ - - /* put all our supported protocols in our request */ - for (i = 0; i < NUM_PROTOCOLS; i++) - { - buf[offset++] = 0; /* cipher we are using */ - buf[offset++] = ssl_prot_prefs[i]; - } - - buf[offset++] = 1; /* no compression */ - buf[offset++] = 0; - - ext_offset = offset; - - buf[offset++] = 0; /* total length of extensions */ - buf[offset++] = 0; - - /* send the signature algorithm extension for TLS 1.2+ */ - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) - { - memcpy(&buf[offset], g_sig_alg, sizeof(g_sig_alg)); - offset += sizeof(g_sig_alg); - ext_len += sizeof(g_sig_alg); - } - - if (ssl->extensions != NULL) - { - /* send the host name if specified */ - if (ssl->extensions->host_name != NULL) - { - size_t host_len = strlen(ssl->extensions->host_name); - buf[offset++] = 0; - buf[offset++] = SSL_EXT_SERVER_NAME; /* server_name(0) (65535) */ - buf[offset++] = 0; - buf[offset++] = host_len + 5; /* server_name length */ - buf[offset++] = 0; - buf[offset++] = host_len + 3; /* server_list length */ - buf[offset++] = 0; /* host_name(0) (255) */ - buf[offset++] = 0; - buf[offset++] = host_len; /* host_name length */ - strncpy((char*) &buf[offset], ssl->extensions->host_name, host_len); - offset += host_len; - ext_len += host_len + 9; - } - - if (ssl->extensions->max_fragment_size) - { - buf[offset++] = 0; - buf[offset++] = SSL_EXT_MAX_FRAGMENT_SIZE; - - buf[offset++] = 0; // size of data - buf[offset++] = 2; - - buf[offset++] = (uint8_t) - ((ssl->extensions->max_fragment_size >> 8) & 0xff); - buf[offset++] = (uint8_t) - (ssl->extensions->max_fragment_size & 0xff); - ext_len += 6; - } - } - - if (ext_len > 0) - { - // update the extensions length value - buf[ext_offset] = (uint8_t) ((ext_len >> 8) & 0xff); - buf[ext_offset + 1] = (uint8_t) (ext_len & 0xff); - } - - buf[3] = offset - 4; /* handshake size */ - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, offset); -} - -/* - * Process the server hello. - */ -static int process_server_hello(SSL *ssl) -{ - uint8_t *buf = ssl->bm_data; - int pkt_size = ssl->bm_index; -#ifndef CONFIG_SSL_SKELETON_MODE - int num_sessions = ssl->ssl_ctx->num_sessions; -#endif - uint8_t sess_id_size; - int offset, ret = SSL_OK; - - /* check that we are talking to a TLSv1 server */ - uint8_t version = (buf[4] << 4) + buf[5]; - if (version > SSL_PROTOCOL_VERSION_MAX) - { - version = SSL_PROTOCOL_VERSION_MAX; - } - else if (ssl->version < SSL_PROTOCOL_MIN_VERSION) - { - ret = SSL_ERROR_INVALID_VERSION; -#ifdef CONFIG_SSL_DIAGNOSTICS - ssl_display_error(ret); -#endif - goto error; - } - - ssl->version = version; - - /* get the server random value */ - memcpy(ssl->dc->server_random, &buf[6], SSL_RANDOM_SIZE); - offset = 6 + SSL_RANDOM_SIZE; /* skip of session id size */ - sess_id_size = buf[offset++]; - - if (sess_id_size > SSL_SESSION_ID_SIZE) - { - ret = SSL_ERROR_INVALID_SESSION; - goto error; - } - -#ifndef CONFIG_SSL_SKELETON_MODE - if (num_sessions) - { - ssl->session = ssl_session_update(num_sessions, - ssl->ssl_ctx->ssl_sessions, ssl, &buf[offset]); - memcpy(ssl->session->session_id, &buf[offset], sess_id_size); - - /* pad the rest with 0's */ - if (sess_id_size < SSL_SESSION_ID_SIZE) - { - memset(&ssl->session->session_id[sess_id_size], 0, - SSL_SESSION_ID_SIZE-sess_id_size); - } - } -#endif - - memcpy(ssl->session_id, &buf[offset], sess_id_size); - ssl->sess_id_size = sess_id_size; - offset += sess_id_size; - - /* get the real cipher we are using - ignore MSB */ - ssl->cipher = buf[++offset]; - ssl->next_state = IS_SET_SSL_FLAG(SSL_SESSION_RESUME) ? - HS_FINISHED : HS_CERTIFICATE; - - offset += 2; // ignore compression - PARANOIA_CHECK(pkt_size, offset); - - ssl->dc->bm_proc_index = offset; - PARANOIA_CHECK(pkt_size, offset); - - // no extensions -error: - return ret; -} - -/** - * Process the server hello done message. - */ -static int process_server_hello_done(SSL *ssl) -{ - ssl->next_state = HS_FINISHED; - return SSL_OK; -} - -/* - * Send a client key exchange message. - */ -static int send_client_key_xchg(SSL *ssl) -{ - uint8_t *buf = ssl->bm_data; - uint8_t premaster_secret[SSL_SECRET_SIZE]; - int enc_secret_size = -1; - - buf[0] = HS_CLIENT_KEY_XCHG; - buf[1] = 0; - - // spec says client must use the what is initially negotiated - - // and this is our current version - premaster_secret[0] = 0x03; - premaster_secret[1] = SSL_PROTOCOL_VERSION_MAX & 0x0f; - if (get_random(SSL_SECRET_SIZE-2, &premaster_secret[2]) < 0) - return SSL_NOT_OK; - - DISPLAY_RSA(ssl, ssl->x509_ctx->rsa_ctx); - - /* rsa_ctx->bi_ctx is not thread-safe */ - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - enc_secret_size = RSA_encrypt(ssl->x509_ctx->rsa_ctx, premaster_secret, - SSL_SECRET_SIZE, &buf[6], 0); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - - buf[2] = (enc_secret_size + 2) >> 8; - buf[3] = (enc_secret_size + 2) & 0xff; - buf[4] = enc_secret_size >> 8; - buf[5] = enc_secret_size & 0xff; - - generate_master_secret(ssl, premaster_secret); - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, enc_secret_size+6); -} - -/* - * Process the certificate request. - */ -static int process_cert_req(SSL *ssl) -{ - uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; - int ret = SSL_OK; - int cert_req_size = (buf[2]<<8) + buf[3]; - int offset = 4; - int pkt_size = ssl->bm_index; - uint8_t cert_type_len, sig_alg_len; - - PARANOIA_CHECK(pkt_size, offset + cert_req_size); - ssl->dc->bm_proc_index = cert_req_size; - - /* don't do any processing - we will send back an RSA certificate anyway */ - ssl->next_state = HS_SERVER_HELLO_DONE; - SET_SSL_FLAG(SSL_HAS_CERT_REQ); - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - // supported certificate types - cert_type_len = buf[offset++]; - PARANOIA_CHECK(pkt_size, offset + cert_type_len); - offset += cert_type_len; - - // supported signature algorithms - sig_alg_len = buf[offset++] << 8; - sig_alg_len += buf[offset++]; - PARANOIA_CHECK(pkt_size, offset + sig_alg_len); - - while (sig_alg_len > 0) - { - uint8_t hash_alg = buf[offset++]; - uint8_t sig_alg = buf[offset++]; - sig_alg_len -= 2; - - if (sig_alg == SIG_ALG_RSA && - (hash_alg == SIG_ALG_SHA1 || - hash_alg == SIG_ALG_SHA256 || - hash_alg == SIG_ALG_SHA384 || - hash_alg == SIG_ALG_SHA512)) - { - ssl->sig_algs[ssl->num_sig_algs++] = hash_alg; - } - } - } - -error: - return ret; -} - -/* - * Send a certificate verify message. - */ -static int send_cert_verify(SSL *ssl) -{ - uint8_t *buf = ssl->bm_data; - uint8_t dgst[SHA1_SIZE+MD5_SIZE+15]; - RSA_CTX *rsa_ctx = ssl->ssl_ctx->rsa_ctx; - int n = 0, ret; - int offset = 0; - int dgst_len; - - if (rsa_ctx == NULL) - return SSL_OK; - - DISPLAY_RSA(ssl, rsa_ctx); - - buf[0] = HS_CERT_VERIFY; - buf[1] = 0; - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - buf[4] = SIG_ALG_SHA256; - buf[5] = SIG_ALG_RSA; - offset = 6; - memcpy(dgst, g_asn1_sha256, sizeof(g_asn1_sha256)); - dgst_len = finished_digest(ssl, NULL, &dgst[sizeof(g_asn1_sha256)]) + - sizeof(g_asn1_sha256); - } - else - { - offset = 4; - dgst_len = finished_digest(ssl, NULL, dgst); - } - - /* rsa_ctx->bi_ctx is not thread-safe */ - if (rsa_ctx) - { - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - n = RSA_encrypt(rsa_ctx, dgst, dgst_len, &buf[offset + 2], 1); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - - if (n == 0) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - } - - buf[offset] = n >> 8; /* add the RSA size */ - buf[offset+1] = n & 0xff; - n += 2; - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - n += 2; // sig/alg - offset -= 2; - } - - buf[2] = n >> 8; - buf[3] = n & 0xff; - ret = send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, n + offset); - -error: - return ret; -} - -#endif /* CONFIG_SSL_ENABLE_CLIENT */ diff --git a/user/mpy/lib/axtls/ssl/tls1_svr.c b/user/mpy/lib/axtls/ssl/tls1_svr.c deleted file mode 100644 index f45b0c5..0000000 --- a/user/mpy/lib/axtls/ssl/tls1_svr.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include -#include "os_port.h" -#include "ssl.h" - -#ifdef CONFIG_SSL_ENABLE_SERVER - -static const uint8_t g_hello_done[] = { HS_SERVER_HELLO_DONE, 0, 0, 0 }; -static const uint8_t g_asn1_sha256[] = -{ - 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, - 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 -}; - -static int process_client_hello(SSL *ssl); -static int send_server_hello_sequence(SSL *ssl); -static int send_server_hello(SSL *ssl); -static int send_server_hello_done(SSL *ssl); -static int process_client_key_xchg(SSL *ssl); -#ifdef CONFIG_SSL_CERT_VERIFICATION -static int send_certificate_request(SSL *ssl); -static int process_cert_verify(SSL *ssl); -#endif - -/* - * Establish a new SSL connection to an SSL client. - */ -EXP_FUNC SSL * STDCALL ssl_server_new(SSL_CTX *ssl_ctx, long client_fd) -{ - SSL *ssl; - - ssl = ssl_new(ssl_ctx, client_fd); - ssl->next_state = HS_CLIENT_HELLO; - -#ifdef CONFIG_SSL_DIAGNOSTICS - if (ssl_ctx->chain_length == 0) - printf("Warning - no server certificate defined\n"); TTY_FLUSH(); -#endif - - return ssl; -} - -/* - * Process the handshake record. - */ -int do_svr_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len) -{ - int ret = SSL_OK; - ssl->hs_status = SSL_NOT_OK; /* not connected */ - - /* To get here the state must be valid */ - switch (handshake_type) - { - case HS_CLIENT_HELLO: - if ((ret = process_client_hello(ssl)) == SSL_OK) - ret = send_server_hello_sequence(ssl); - break; - -#ifdef CONFIG_SSL_CERT_VERIFICATION - case HS_CERTIFICATE:/* the client sends its cert */ - ret = process_certificate(ssl, &ssl->x509_ctx); - - if (ret == SSL_OK) /* verify the cert */ - { - int cert_res; - int pathLenConstraint = 0; - - cert_res = x509_verify(ssl->ssl_ctx->ca_cert_ctx, - ssl->x509_ctx, &pathLenConstraint); - ret = (cert_res == 0) ? SSL_OK : SSL_X509_ERROR(cert_res); - } - break; - - case HS_CERT_VERIFY: - ret = process_cert_verify(ssl); - add_packet(ssl, buf, hs_len); /* needs to be done after */ - break; -#endif - case HS_CLIENT_KEY_XCHG: - ret = process_client_key_xchg(ssl); - break; - - case HS_FINISHED: - ret = process_finished(ssl, buf, hs_len); - disposable_free(ssl); /* free up some memory */ - break; - } - - return ret; -} - -/* - * Process a client hello message. - */ -static int process_client_hello(SSL *ssl) -{ - uint8_t *buf = ssl->bm_data; - int pkt_size = ssl->bm_index; - int i, j, cs_len, id_len, offset = 6 + SSL_RANDOM_SIZE; - int ret = SSL_OK; - - uint8_t version = (buf[4] << 4) + buf[5]; - ssl->version = ssl->client_version = version; - - if (version > SSL_PROTOCOL_VERSION_MAX) - { - /* use client's version instead */ - ssl->version = SSL_PROTOCOL_VERSION_MAX; - } - else if (version < SSL_PROTOCOL_MIN_VERSION) /* old version supported? */ - { - ret = SSL_ERROR_INVALID_VERSION; -#ifdef CONFIG_SSL_DIAGNOSTICS - ssl_display_error(ret); -#endif - goto error; - } - - memcpy(ssl->dc->client_random, &buf[6], SSL_RANDOM_SIZE); - - /* process the session id */ - id_len = buf[offset++]; - if (id_len > SSL_SESSION_ID_SIZE) - { - return SSL_ERROR_INVALID_SESSION; - } - -#ifndef CONFIG_SSL_SKELETON_MODE - ssl->session = ssl_session_update(ssl->ssl_ctx->num_sessions, - ssl->ssl_ctx->ssl_sessions, ssl, id_len ? &buf[offset] : NULL); -#endif - - offset += id_len; - cs_len = (buf[offset]<<8) + buf[offset+1]; - offset += 3; /* add 1 due to all cipher suites being 8 bit */ - - PARANOIA_CHECK(pkt_size, offset + cs_len); - - /* work out what cipher suite we are going to use - client defines - the preference */ - for (i = 0; i < cs_len; i += 2) - { - for (j = 0; j < NUM_PROTOCOLS; j++) - { - if (ssl_prot_prefs[j] == buf[offset+i]) /* got a match? */ - { - ssl->cipher = ssl_prot_prefs[j]; - goto do_compression; - } - } - } - - /* ouch! protocol is not supported */ - return SSL_ERROR_NO_CIPHER; - - /* completely ignore compression */ -do_compression: - offset += cs_len; - id_len = buf[offset++]; - offset += id_len; - PARANOIA_CHECK(pkt_size, offset + id_len); - - if (offset == pkt_size) - { - /* no extensions */ - goto error; - } - - /* extension size */ - id_len = buf[offset++] << 8; - id_len += buf[offset++]; - PARANOIA_CHECK(pkt_size, offset + id_len); - - // Check for extensions from the client - only the signature algorithm - // is supported - while (offset < pkt_size) - { - int ext = buf[offset++] << 8; - ext += buf[offset++]; - int ext_len = buf[offset++] << 8; - ext_len += buf[offset++]; - PARANOIA_CHECK(pkt_size, offset + ext_len); - - if (ext == SSL_EXT_SIG_ALG) - { - while (ext_len > 0) - { - uint8_t hash_alg = buf[offset++]; - uint8_t sig_alg = buf[offset++]; - ext_len -= 2; - - if (sig_alg == SIG_ALG_RSA && - (hash_alg == SIG_ALG_SHA1 || - hash_alg == SIG_ALG_SHA256 || - hash_alg == SIG_ALG_SHA384 || - hash_alg == SIG_ALG_SHA512)) - { - ssl->sig_algs[ssl->num_sig_algs++] = hash_alg; - } - } - } - else - { - offset += ext_len; - } - } - - /* default is RSA/SHA1 */ - if (ssl->num_sig_algs == 0) - { - ssl->sig_algs[ssl->num_sig_algs++] = SIG_ALG_SHA1; - } - -error: - return ret; -} - -/* - * Send the entire server hello sequence - */ -#if CONFIG_SSL_ENABLE_SERVER -static int send_server_hello_sequence(SSL *ssl) -{ - int ret; - - if ((ret = send_server_hello(ssl)) == SSL_OK) - { -#ifndef CONFIG_SSL_SKELETON_MODE - /* resume handshake? */ - if (IS_SET_SSL_FLAG(SSL_SESSION_RESUME)) - { - if ((ret = send_change_cipher_spec(ssl)) == SSL_OK) - { - ret = send_finished(ssl); - ssl->next_state = HS_FINISHED; - } - } - else -#endif - if ((ret = send_certificate(ssl)) == SSL_OK) - { -#ifdef CONFIG_SSL_CERT_VERIFICATION - /* ask the client for its certificate */ - if (IS_SET_SSL_FLAG(SSL_CLIENT_AUTHENTICATION)) - { - if ((ret = send_certificate_request(ssl)) == SSL_OK) - { - ret = send_server_hello_done(ssl); - ssl->next_state = HS_CERTIFICATE; - } - } - else -#endif - { - ret = send_server_hello_done(ssl); - ssl->next_state = HS_CLIENT_KEY_XCHG; - } - } - } - - return ret; -} - -/* - * Send a server hello message. - */ -static int send_server_hello(SSL *ssl) -{ - uint8_t *buf = ssl->bm_data; - int offset = 0; - - buf[0] = HS_SERVER_HELLO; - buf[1] = 0; - buf[2] = 0; - /* byte 3 is calculated later */ - buf[4] = 0x03; - buf[5] = ssl->version & 0x0f; - - /* server random value */ - if (get_random(SSL_RANDOM_SIZE, &buf[6]) < 0) - return SSL_NOT_OK; - - memcpy(ssl->dc->server_random, &buf[6], SSL_RANDOM_SIZE); - offset = 6 + SSL_RANDOM_SIZE; - -#ifndef CONFIG_SSL_SKELETON_MODE - if (IS_SET_SSL_FLAG(SSL_SESSION_RESUME)) - { - /* retrieve id from session cache */ - buf[offset++] = SSL_SESSION_ID_SIZE; - memcpy(&buf[offset], ssl->session->session_id, SSL_SESSION_ID_SIZE); - memcpy(ssl->session_id, ssl->session->session_id, SSL_SESSION_ID_SIZE); - ssl->sess_id_size = SSL_SESSION_ID_SIZE; - offset += SSL_SESSION_ID_SIZE; - } - else /* generate our own session id */ -#endif - { -#ifndef CONFIG_SSL_SKELETON_MODE - buf[offset++] = SSL_SESSION_ID_SIZE; - get_random(SSL_SESSION_ID_SIZE, &buf[offset]); - memcpy(ssl->session_id, &buf[offset], SSL_SESSION_ID_SIZE); - ssl->sess_id_size = SSL_SESSION_ID_SIZE; - - /* store id in session cache */ - if (ssl->ssl_ctx->num_sessions) - { - memcpy(ssl->session->session_id, - ssl->session_id, SSL_SESSION_ID_SIZE); - } - - offset += SSL_SESSION_ID_SIZE; -#else - buf[offset++] = 0; /* don't bother with session id in skelton mode */ -#endif - } - - buf[offset++] = 0; /* cipher we are using */ - buf[offset++] = ssl->cipher; - buf[offset++] = 0; /* no compression and no extensions supported */ - buf[3] = offset - 4; /* handshake size */ - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, NULL, offset); -} - -/* - * Send the server hello done message. - */ -static int send_server_hello_done(SSL *ssl) -{ - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, - g_hello_done, sizeof(g_hello_done)); -} -#endif - -/* - * Pull apart a client key exchange message. Decrypt the pre-master key (using - * our RSA private key) and then work out the master key. Initialise the - * ciphers. - */ -static int process_client_key_xchg(SSL *ssl) -{ - uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; - int pkt_size = ssl->bm_index; - int premaster_size, secret_length = (buf[2] << 8) + buf[3]; - uint8_t premaster_secret[MAX_KEY_BYTE_SIZE]; - RSA_CTX *rsa_ctx = ssl->ssl_ctx->rsa_ctx; - int offset = 4; - int ret = SSL_OK; - - if (rsa_ctx == NULL) - { - ret = SSL_ERROR_NO_CERT_DEFINED; - goto error; - } - - /* is there an extra size field? */ - if ((secret_length - 2) == rsa_ctx->num_octets) - offset += 2; - - PARANOIA_CHECK(pkt_size, rsa_ctx->num_octets+offset); - - /* rsa_ctx->bi_ctx is not thread-safe */ - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - premaster_size = RSA_decrypt(rsa_ctx, &buf[offset], premaster_secret, - sizeof(premaster_secret), 1); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - - if (premaster_size != SSL_SECRET_SIZE || - premaster_secret[0] != 0x03 || /* must be the same as client - offered version */ - premaster_secret[1] != (ssl->client_version & 0x0f)) - { - /* guard against a Bleichenbacher attack */ - if (get_random(SSL_SECRET_SIZE, premaster_secret) < 0) - return SSL_NOT_OK; - - /* and continue - will die eventually when checking the mac */ - } - - generate_master_secret(ssl, premaster_secret); - -#ifdef CONFIG_SSL_CERT_VERIFICATION - ssl->next_state = IS_SET_SSL_FLAG(SSL_CLIENT_AUTHENTICATION) ? - HS_CERT_VERIFY : HS_FINISHED; -#else - ssl->next_state = HS_FINISHED; -#endif - - ssl->dc->bm_proc_index += rsa_ctx->num_octets+offset; -error: - return ret; -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION -static const uint8_t g_cert_request[] = { HS_CERT_REQ, 0, - 0, 0x0e, - 1, 1, // rsa sign - 0x00, 0x08, - SIG_ALG_SHA256, SIG_ALG_RSA, - SIG_ALG_SHA512, SIG_ALG_RSA, - SIG_ALG_SHA384, SIG_ALG_RSA, - SIG_ALG_SHA1, SIG_ALG_RSA, - 0, 0 -}; - -static const uint8_t g_cert_request_v1[] = { HS_CERT_REQ, 0, 0, 4, 1, 0, 0, 0 }; - -/* - * Send the certificate request message. - */ -static int send_certificate_request(SSL *ssl) -{ - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, - g_cert_request, sizeof(g_cert_request)); - } - else - { - return send_packet(ssl, PT_HANDSHAKE_PROTOCOL, - g_cert_request_v1, sizeof(g_cert_request_v1)); - } -} - -/* - * Ensure the client has the private key by first decrypting the packet and - * then checking the packet digests. - */ -static int process_cert_verify(SSL *ssl) -{ - uint8_t *buf = &ssl->bm_data[ssl->dc->bm_proc_index]; - int pkt_size = ssl->bm_index; - uint8_t dgst_buf[MAX_KEY_BYTE_SIZE]; - uint8_t dgst[MD5_SIZE + SHA1_SIZE]; - X509_CTX *x509_ctx = ssl->x509_ctx; - int ret = SSL_OK; - int offset = 6; - int rsa_len; - int n; - - DISPLAY_RSA(ssl, x509_ctx->rsa_ctx); - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - // TODO: should really need to be able to handle other algorihms. An - // assumption is made on RSA/SHA256 and appears to be OK. - //uint8_t hash_alg = buf[4]; - //uint8_t sig_alg = buf[5]; - offset = 8; - rsa_len = (buf[6] << 8) + buf[7]; - } - else - { - rsa_len = (buf[4] << 8) + buf[5]; - } - - PARANOIA_CHECK(pkt_size, offset + rsa_len); - - /* rsa_ctx->bi_ctx is not thread-safe */ - SSL_CTX_LOCK(ssl->ssl_ctx->mutex); - n = RSA_decrypt(x509_ctx->rsa_ctx, &buf[offset], dgst_buf, - sizeof(dgst_buf), 0); - SSL_CTX_UNLOCK(ssl->ssl_ctx->mutex); - - if (ssl->version >= SSL_PROTOCOL_VERSION_TLS1_2) // TLS1.2+ - { - if (memcmp(dgst_buf, g_asn1_sha256, sizeof(g_asn1_sha256))) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - - finished_digest(ssl, NULL, dgst); /* calculate the digest */ - if (memcmp(&dgst_buf[sizeof(g_asn1_sha256)], dgst, SHA256_SIZE)) - { - ret = SSL_ERROR_INVALID_KEY; - goto error; - } - } - else // TLS1.0/1.1 - { - if (n != SHA1_SIZE + MD5_SIZE) - { - ret = SSL_ERROR_INVALID_KEY; - goto end_cert_vfy; - } - - finished_digest(ssl, NULL, dgst); /* calculate the digest */ - if (memcmp(dgst_buf, dgst, MD5_SIZE + SHA1_SIZE)) - { - ret = SSL_ERROR_INVALID_KEY; - } - } - -end_cert_vfy: - ssl->next_state = HS_FINISHED; -error: - return ret; -} - -#endif - -#endif diff --git a/user/mpy/lib/axtls/ssl/x509.c b/user/mpy/lib/axtls/ssl/x509.c deleted file mode 100644 index abdebdb..0000000 --- a/user/mpy/lib/axtls/ssl/x509.c +++ /dev/null @@ -1,861 +0,0 @@ -/* - * Copyright (c) 2007-2016, Cameron Rich - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the axTLS project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file x509.c - * - * Certificate processing. - */ - -#include -#include -#include -#include -#include "os_port.h" -#include "crypto_misc.h" - -#ifdef CONFIG_SSL_CERT_VERIFICATION -static int x509_v3_subject_alt_name(const uint8_t *cert, int offset, - X509_CTX *x509_ctx); -static int x509_v3_basic_constraints(const uint8_t *cert, int offset, - X509_CTX *x509_ctx); -static int x509_v3_key_usage(const uint8_t *cert, int offset, - X509_CTX *x509_ctx); - -/** - * Retrieve the signature from a certificate. - */ -static const uint8_t *get_signature(const uint8_t *asn1_sig, int *len) -{ - int offset = 0; - const uint8_t *ptr = NULL; - - if (asn1_next_obj(asn1_sig, &offset, ASN1_SEQUENCE) < 0 || - asn1_skip_obj(asn1_sig, &offset, ASN1_SEQUENCE)) - goto end_get_sig; - - if (asn1_sig[offset++] != ASN1_OCTET_STRING) - goto end_get_sig; - *len = get_asn1_length(asn1_sig, &offset); - ptr = &asn1_sig[offset]; /* all ok */ - -end_get_sig: - return ptr; -} - -#endif - -/** - * Construct a new x509 object. - * @return 0 if ok. < 0 if there was a problem. - */ -int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx) -{ - int begin_tbs, end_tbs; - int ret = X509_NOT_OK, offset = 0, cert_size = 0; - int version = 0; - X509_CTX *x509_ctx; -#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */ - BI_CTX *bi_ctx; -#endif - - *ctx = (X509_CTX *)calloc(1, sizeof(X509_CTX)); - x509_ctx = *ctx; - - /* get the certificate size */ - asn1_skip_obj(cert, &cert_size, ASN1_SEQUENCE); - - if (asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0) - goto end_cert; - - begin_tbs = offset; /* start of the tbs */ - end_tbs = begin_tbs; /* work out the end of the tbs */ - asn1_skip_obj(cert, &end_tbs, ASN1_SEQUENCE); - - if (asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0) - goto end_cert; - - /* optional version */ - if (cert[offset] == ASN1_EXPLICIT_TAG && - asn1_version(cert, &offset, &version) == X509_NOT_OK) - goto end_cert; - - if (asn1_skip_obj(cert, &offset, ASN1_INTEGER) || /* serial number */ - asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0) - goto end_cert; - - /* make sure the signature is ok */ - if (asn1_signature_type(cert, &offset, x509_ctx)) - { - ret = X509_VFY_ERROR_UNSUPPORTED_DIGEST; - goto end_cert; - } - - if (asn1_name(cert, &offset, x509_ctx->ca_cert_dn) || - asn1_validity(cert, &offset, x509_ctx) || - asn1_name(cert, &offset, x509_ctx->cert_dn) || - asn1_public_key(cert, &offset, x509_ctx)) - { - goto end_cert; - } - -#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */ - bi_ctx = x509_ctx->rsa_ctx->bi_ctx; - - /* use the appropriate signature algorithm */ - switch (x509_ctx->sig_type) - { - case SIG_TYPE_MD5: - { - MD5_CTX md5_ctx; - uint8_t md5_dgst[MD5_SIZE]; - MD5_Init(&md5_ctx); - MD5_Update(&md5_ctx, &cert[begin_tbs], end_tbs-begin_tbs); - MD5_Final(md5_dgst, &md5_ctx); - x509_ctx->digest = bi_import(bi_ctx, md5_dgst, MD5_SIZE); - } - break; - - case SIG_TYPE_SHA1: - { - SHA1_CTX sha_ctx; - uint8_t sha_dgst[SHA1_SIZE]; - SHA1_Init(&sha_ctx); - SHA1_Update(&sha_ctx, &cert[begin_tbs], end_tbs-begin_tbs); - SHA1_Final(sha_dgst, &sha_ctx); - x509_ctx->digest = bi_import(bi_ctx, sha_dgst, SHA1_SIZE); - } - break; - - case SIG_TYPE_SHA256: - { - SHA256_CTX sha256_ctx; - uint8_t sha256_dgst[SHA256_SIZE]; - SHA256_Init(&sha256_ctx); - SHA256_Update(&sha256_ctx, &cert[begin_tbs], end_tbs-begin_tbs); - SHA256_Final(sha256_dgst, &sha256_ctx); - x509_ctx->digest = bi_import(bi_ctx, sha256_dgst, SHA256_SIZE); - } - break; - - case SIG_TYPE_SHA384: - { - SHA384_CTX sha384_ctx; - uint8_t sha384_dgst[SHA384_SIZE]; - SHA384_Init(&sha384_ctx); - SHA384_Update(&sha384_ctx, &cert[begin_tbs], end_tbs-begin_tbs); - SHA384_Final(sha384_dgst, &sha384_ctx); - x509_ctx->digest = bi_import(bi_ctx, sha384_dgst, SHA384_SIZE); - } - break; - - case SIG_TYPE_SHA512: - { - SHA512_CTX sha512_ctx; - uint8_t sha512_dgst[SHA512_SIZE]; - SHA512_Init(&sha512_ctx); - SHA512_Update(&sha512_ctx, &cert[begin_tbs], end_tbs-begin_tbs); - SHA512_Final(sha512_dgst, &sha512_ctx); - x509_ctx->digest = bi_import(bi_ctx, sha512_dgst, SHA512_SIZE); - } - break; - } - - if (version == 2 && asn1_next_obj(cert, &offset, ASN1_V3_DATA) > 0) - { - x509_v3_subject_alt_name(cert, offset, x509_ctx); - x509_v3_basic_constraints(cert, offset, x509_ctx); - x509_v3_key_usage(cert, offset, x509_ctx); - } - - offset = end_tbs; /* skip the rest of v3 data */ - if (asn1_skip_obj(cert, &offset, ASN1_SEQUENCE) || - asn1_signature(cert, &offset, x509_ctx)) - goto end_cert; -#endif - ret = X509_OK; -end_cert: - if (len) - { - *len = cert_size; - } - - if (ret) - { -#ifdef CONFIG_SSL_FULL_MODE - printf("Error: Invalid X509 ASN.1 file (%s)\n", - x509_display_error(ret)); -#endif - x509_free(x509_ctx); - *ctx = NULL; - } - - return ret; -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */ -static int x509_v3_subject_alt_name(const uint8_t *cert, int offset, - X509_CTX *x509_ctx) -{ - if ((offset = asn1_is_subject_alt_name(cert, offset)) > 0) - { - x509_ctx->subject_alt_name_present = true; - x509_ctx->subject_alt_name_is_critical = - asn1_is_critical_ext(cert, &offset); - - if (asn1_next_obj(cert, &offset, ASN1_OCTET_STRING) > 0) - { - int altlen; - - if ((altlen = asn1_next_obj(cert, &offset, ASN1_SEQUENCE)) > 0) - { - int endalt = offset + altlen; - int totalnames = 0; - - while (offset < endalt) - { - int type = cert[offset++]; - int dnslen = get_asn1_length(cert, &offset); - - if (type == ASN1_CONTEXT_DNSNAME) - { - x509_ctx->subject_alt_dnsnames = (char**) - realloc(x509_ctx->subject_alt_dnsnames, - (totalnames + 2) * sizeof(char*)); - x509_ctx->subject_alt_dnsnames[totalnames] = - (char*)malloc(dnslen + 1); - x509_ctx->subject_alt_dnsnames[totalnames+1] = NULL; - memcpy(x509_ctx->subject_alt_dnsnames[totalnames], - cert + offset, dnslen); - x509_ctx->subject_alt_dnsnames[totalnames][dnslen] = 0; - totalnames++; - } - - offset += dnslen; - } - } - } - } - - return X509_OK; -} - -/** - * Basic constraints - see https://tools.ietf.org/html/rfc5280#page-39 - */ -static int x509_v3_basic_constraints(const uint8_t *cert, int offset, - X509_CTX *x509_ctx) -{ - int ret = X509_OK; - - if ((offset = asn1_is_basic_constraints(cert, offset)) == 0) - goto end_contraints; - - x509_ctx->basic_constraint_present = true; - x509_ctx->basic_constraint_is_critical = - asn1_is_critical_ext(cert, &offset); - - if (asn1_next_obj(cert, &offset, ASN1_OCTET_STRING) < 0 || - asn1_next_obj(cert, &offset, ASN1_SEQUENCE) < 0 || - asn1_get_bool(cert, &offset, &x509_ctx->basic_constraint_cA) < 0 || - asn1_get_int(cert, &offset, - &x509_ctx->basic_constraint_pathLenConstraint) < 0) - { - ret = X509_NOT_OK; - } - -end_contraints: - return ret; -} - -/* - * Key usage - see https://tools.ietf.org/html/rfc5280#section-4.2.1.3 - */ -static int x509_v3_key_usage(const uint8_t *cert, int offset, - X509_CTX *x509_ctx) -{ - int ret = X509_OK; - - if ((offset = asn1_is_key_usage(cert, offset)) == 0) - goto end_key_usage; - - x509_ctx->key_usage_present = true; - x509_ctx->key_usage_is_critical = asn1_is_critical_ext(cert, &offset); - - if (asn1_next_obj(cert, &offset, ASN1_OCTET_STRING) < 0 || - asn1_get_bit_string_as_int(cert, &offset, &x509_ctx->key_usage)) - { - ret = X509_NOT_OK; - } - -end_key_usage: - return ret; -} -#endif - -/** - * Free an X.509 object's resources. - */ -void x509_free(X509_CTX *x509_ctx) -{ - X509_CTX *next; - int i; - - if (x509_ctx == NULL) /* if already null, then don't bother */ - return; - - for (i = 0; i < X509_NUM_DN_TYPES; i++) - { - free(x509_ctx->ca_cert_dn[i]); - free(x509_ctx->cert_dn[i]); - } - - free(x509_ctx->signature); - -#ifdef CONFIG_SSL_CERT_VERIFICATION - if (x509_ctx->digest) - { - bi_free(x509_ctx->rsa_ctx->bi_ctx, x509_ctx->digest); - } - - if (x509_ctx->subject_alt_dnsnames) - { - for (i = 0; x509_ctx->subject_alt_dnsnames[i]; ++i) - free(x509_ctx->subject_alt_dnsnames[i]); - - free(x509_ctx->subject_alt_dnsnames); - } -#endif - - RSA_free(x509_ctx->rsa_ctx); - next = x509_ctx->next; - free(x509_ctx); - x509_free(next); /* clear the chain */ -} - -#ifdef CONFIG_SSL_CERT_VERIFICATION -/** - * Take a signature and decrypt it. - */ -static bigint *sig_verify(BI_CTX *ctx, const uint8_t *sig, int sig_len, - bigint *modulus, bigint *pub_exp) -{ - int i, size; - bigint *decrypted_bi, *dat_bi; - bigint *bir = NULL; - uint8_t *block = (uint8_t *)alloca(sig_len); - - /* decrypt */ - dat_bi = bi_import(ctx, sig, sig_len); - ctx->mod_offset = BIGINT_M_OFFSET; - - /* convert to a normal block */ - decrypted_bi = bi_mod_power2(ctx, dat_bi, modulus, pub_exp); - - bi_export(ctx, decrypted_bi, block, sig_len); - ctx->mod_offset = BIGINT_M_OFFSET; - - i = 10; /* start at the first possible non-padded byte */ - while (block[i++] && i < sig_len); - size = sig_len - i; - - /* get only the bit we want */ - if (size > 0) - { - int len; - const uint8_t *sig_ptr = get_signature(&block[i], &len); - - if (sig_ptr) - { - bir = bi_import(ctx, sig_ptr, len); - } - } - - /* save a few bytes of memory */ - bi_clear_cache(ctx); - return bir; -} - -/** - * Do some basic checks on the certificate chain. - * - * Certificate verification consists of a number of checks: - * - The date of the certificate is after the start date. - * - The date of the certificate is before the finish date. - * - A root certificate exists in the certificate store. - * - That the certificate(s) are not self-signed. - * - The certificate chain is valid. - * - The signature of the certificate is valid. - * - Basic constraints - */ -int x509_verify(const CA_CERT_CTX *ca_cert_ctx, const X509_CTX *cert, - int *pathLenConstraint) -{ - int ret = X509_OK, i = 0; - bigint *cert_sig; - X509_CTX *next_cert = NULL; - BI_CTX *ctx = NULL; - bigint *mod = NULL, *expn = NULL; - int match_ca_cert = 0; - struct timeval tv; - uint8_t is_self_signed = 0; - - if (cert == NULL) - { - ret = X509_VFY_ERROR_NO_TRUSTED_CERT; - goto end_verify; - } - - /* a self-signed certificate that is not in the CA store - use this - to check the signature */ - if (asn1_compare_dn(cert->ca_cert_dn, cert->cert_dn) == 0) - { - is_self_signed = 1; - ctx = cert->rsa_ctx->bi_ctx; - mod = cert->rsa_ctx->m; - expn = cert->rsa_ctx->e; - } - - gettimeofday(&tv, NULL); - - /* check the not before date */ - if (tv.tv_sec < cert->not_before) - { - ret = X509_VFY_ERROR_NOT_YET_VALID; - goto end_verify; - } - - /* check the not after date */ - if (tv.tv_sec > cert->not_after) - { - ret = X509_VFY_ERROR_EXPIRED; - goto end_verify; - } - - if (cert->basic_constraint_present) - { - /* If the cA boolean is not asserted, - then the keyCertSign bit in the key usage extension MUST NOT be - asserted. */ - if (!cert->basic_constraint_cA && - IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_CERT_SIGN)) - { - ret = X509_VFY_ERROR_BASIC_CONSTRAINT; - goto end_verify; - } - - /* The pathLenConstraint field is meaningful only if the cA boolean is - asserted and the key usage extension, if present, asserts the - keyCertSign bit. In this case, it gives the maximum number of - non-self-issued intermediate certificates that may follow this - certificate in a valid certification path. */ - if (cert->basic_constraint_cA && - (!cert->key_usage_present || - IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_CERT_SIGN)) && - (cert->basic_constraint_pathLenConstraint+1) < *pathLenConstraint) - { - ret = X509_VFY_ERROR_BASIC_CONSTRAINT; - goto end_verify; - } - } - - next_cert = cert->next; - - /* last cert in the chain - look for a trusted cert */ - if (next_cert == NULL) - { - if (ca_cert_ctx != NULL) - { - /* go thru the CA store */ - while (i < CONFIG_X509_MAX_CA_CERTS && ca_cert_ctx->cert[i]) - { - /* the extension is present but the cA boolean is not - asserted, then the certified public key MUST NOT be used - to verify certificate signatures. */ - if (cert->basic_constraint_present && - !ca_cert_ctx->cert[i]->basic_constraint_cA) - continue; - - if (asn1_compare_dn(cert->ca_cert_dn, - ca_cert_ctx->cert[i]->cert_dn) == 0) - { - /* use this CA certificate for signature verification */ - match_ca_cert = true; - ctx = ca_cert_ctx->cert[i]->rsa_ctx->bi_ctx; - mod = ca_cert_ctx->cert[i]->rsa_ctx->m; - expn = ca_cert_ctx->cert[i]->rsa_ctx->e; - - - break; - } - - i++; - } - } - - /* couldn't find a trusted cert (& let self-signed errors - be returned) */ - if (!match_ca_cert && !is_self_signed) - { - ret = X509_VFY_ERROR_NO_TRUSTED_CERT; - goto end_verify; - } - } - else if (asn1_compare_dn(cert->ca_cert_dn, next_cert->cert_dn) != 0) - { - /* check the chain */ - ret = X509_VFY_ERROR_INVALID_CHAIN; - goto end_verify; - } - else /* use the next certificate in the chain for signature verify */ - { - ctx = next_cert->rsa_ctx->bi_ctx; - mod = next_cert->rsa_ctx->m; - expn = next_cert->rsa_ctx->e; - } - - /* cert is self signed */ - if (!match_ca_cert && is_self_signed) - { - ret = X509_VFY_ERROR_SELF_SIGNED; - goto end_verify; - } - - /* check the signature */ - cert_sig = sig_verify(ctx, cert->signature, cert->sig_len, - bi_clone(ctx, mod), bi_clone(ctx, expn)); - - if (cert_sig && cert->digest) - { - if (bi_compare(cert_sig, cert->digest) != 0) - ret = X509_VFY_ERROR_BAD_SIGNATURE; - - - bi_free(ctx, cert_sig); - } - else - { - ret = X509_VFY_ERROR_BAD_SIGNATURE; - } - - if (ret) - goto end_verify; - - /* go down the certificate chain using recursion. */ - if (next_cert != NULL) - { - (*pathLenConstraint)++; /* don't include last certificate */ - ret = x509_verify(ca_cert_ctx, next_cert, pathLenConstraint); - } - -end_verify: - return ret; -} -#endif - -#if defined (CONFIG_SSL_FULL_MODE) -/** - * Used for diagnostics. - */ -static const char *not_part_of_cert = ""; -void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx) -{ - if (cert == NULL) - return; - - printf("=== CERTIFICATE ISSUED TO ===\n"); - printf("Common Name (CN):\t\t"); - printf("%s\n", cert->cert_dn[X509_COMMON_NAME] ? - cert->cert_dn[X509_COMMON_NAME] : not_part_of_cert); - - printf("Organization (O):\t\t"); - printf("%s\n", cert->cert_dn[X509_ORGANIZATION] ? - cert->cert_dn[X509_ORGANIZATION] : not_part_of_cert); - - if (cert->cert_dn[X509_ORGANIZATIONAL_UNIT]) - { - printf("Organizational Unit (OU):\t"); - printf("%s\n", cert->cert_dn[X509_ORGANIZATIONAL_UNIT]); - } - - if (cert->cert_dn[X509_LOCATION]) - { - printf("Location (L):\t\t\t"); - printf("%s\n", cert->cert_dn[X509_LOCATION]); - } - - if (cert->cert_dn[X509_COUNTRY]) - { - printf("Country (C):\t\t\t"); - printf("%s\n", cert->cert_dn[X509_COUNTRY]); - } - - if (cert->cert_dn[X509_STATE]) - { - printf("State (ST):\t\t\t"); - printf("%s\n", cert->cert_dn[X509_STATE]); - } - - if (cert->basic_constraint_present) - { - printf("Basic Constraints:\t\t%sCA:%s, pathlen:%d\n", - cert->basic_constraint_is_critical ? - "critical, " : "", - cert->basic_constraint_cA? "TRUE" : "FALSE", - cert->basic_constraint_pathLenConstraint); - } - - if (cert->key_usage_present) - { - printf("Key Usage:\t\t\t%s", cert->key_usage_is_critical ? - "critical, " : ""); - bool has_started = false; - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_DIGITAL_SIGNATURE)) - { - printf("Digital Signature"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_NON_REPUDIATION)) - { - if (has_started) - printf(", "); - - printf("Non Repudiation"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_ENCIPHERMENT)) - { - if (has_started) - printf(", "); - - printf("Key Encipherment"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_DATA_ENCIPHERMENT)) - { - if (has_started) - printf(", "); - - printf("Data Encipherment"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_AGREEMENT)) - { - if (has_started) - printf(", "); - - printf("Key Agreement"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_KEY_CERT_SIGN)) - { - if (has_started) - printf(", "); - - printf("Key Cert Sign"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_CRL_SIGN)) - { - if (has_started) - printf(", "); - - printf("CRL Sign"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_ENCIPHER_ONLY)) - { - if (has_started) - printf(", "); - - printf("Encipher Only"); - has_started = true; - } - - if (IS_SET_KEY_USAGE_FLAG(cert, KEY_USAGE_DECIPHER_ONLY)) - { - if (has_started) - printf(", "); - - printf("Decipher Only"); - has_started = true; - } - - printf("\n"); - } - - if (cert->subject_alt_name_present) - { - printf("Subject Alt Name:\t\t%s", cert->subject_alt_name_is_critical - ? "critical, " : ""); - if (cert->subject_alt_dnsnames) - { - int i = 0; - - while (cert->subject_alt_dnsnames[i]) - printf("%s ", cert->subject_alt_dnsnames[i++]); - } - printf("\n"); - - } - - printf("=== CERTIFICATE ISSUED BY ===\n"); - printf("Common Name (CN):\t\t"); - printf("%s\n", cert->ca_cert_dn[X509_COMMON_NAME] ? - cert->ca_cert_dn[X509_COMMON_NAME] : not_part_of_cert); - - printf("Organization (O):\t\t"); - printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATION] ? - cert->ca_cert_dn[X509_ORGANIZATION] : not_part_of_cert); - - if (cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]) - { - printf("Organizational Unit (OU):\t"); - printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]); - } - - if (cert->ca_cert_dn[X509_LOCATION]) - { - printf("Location (L):\t\t\t"); - printf("%s\n", cert->ca_cert_dn[X509_LOCATION]); - } - - if (cert->ca_cert_dn[X509_COUNTRY]) - { - printf("Country (C):\t\t\t"); - printf("%s\n", cert->ca_cert_dn[X509_COUNTRY]); - } - - if (cert->ca_cert_dn[X509_STATE]) - { - printf("State (ST):\t\t\t"); - printf("%s\n", cert->ca_cert_dn[X509_STATE]); - } - - printf("Not Before:\t\t\t%s", ctime(&cert->not_before)); - printf("Not After:\t\t\t%s", ctime(&cert->not_after)); - printf("RSA bitsize:\t\t\t%d\n", cert->rsa_ctx->num_octets*8); - printf("Sig Type:\t\t\t"); - switch (cert->sig_type) - { - case SIG_TYPE_MD5: - printf("MD5\n"); - break; - case SIG_TYPE_SHA1: - printf("SHA1\n"); - break; - case SIG_TYPE_SHA256: - printf("SHA256\n"); - break; - case SIG_TYPE_SHA384: - printf("SHA384\n"); - break; - case SIG_TYPE_SHA512: - printf("SHA512\n"); - break; - default: - printf("Unrecognized: %d\n", cert->sig_type); - break; - } - - if (ca_cert_ctx) - { - int pathLenConstraint = 0; - printf("Verify:\t\t\t\t%s\n", - x509_display_error(x509_verify(ca_cert_ctx, cert, - &pathLenConstraint))); - } - -#if 0 - print_blob("Signature", cert->signature, cert->sig_len); - bi_print("Modulus", cert->rsa_ctx->m); - bi_print("Pub Exp", cert->rsa_ctx->e); -#endif - - if (ca_cert_ctx) - { - x509_print(cert->next, ca_cert_ctx); - } - - TTY_FLUSH(); -} -#endif - -const char * x509_display_error(int error) -{ - switch (error) - { - case X509_OK: - return "Certificate verify successful"; - - case X509_NOT_OK: - return "X509 not ok"; - - case X509_VFY_ERROR_NO_TRUSTED_CERT: - return "No trusted cert is available"; - - case X509_VFY_ERROR_BAD_SIGNATURE: - return "Bad signature"; - - case X509_VFY_ERROR_NOT_YET_VALID: - return "Cert is not yet valid"; - - case X509_VFY_ERROR_EXPIRED: - return "Cert has expired"; - - case X509_VFY_ERROR_SELF_SIGNED: - return "Cert is self-signed"; - - case X509_VFY_ERROR_INVALID_CHAIN: - return "Chain is invalid (check order of certs)"; - - case X509_VFY_ERROR_UNSUPPORTED_DIGEST: - return "Unsupported digest"; - - case X509_INVALID_PRIV_KEY: - return "Invalid private key"; - - case X509_VFY_ERROR_BASIC_CONSTRAINT: - return "Basic constraint invalid"; - - default: - return "Unknown"; - } -} -//#endif /* CONFIG_SSL_FULL_MODE */ - diff --git a/user/mpy/lib/axtls/www/bin/.htaccess b/user/mpy/lib/axtls/www/bin/.htaccess deleted file mode 100644 index 4496fa9..0000000 --- a/user/mpy/lib/axtls/www/bin/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Deny all - diff --git a/user/mpy/lib/axtls/www/favicon.ico b/user/mpy/lib/axtls/www/favicon.ico deleted file mode 100644 index 9f6f30e4c6de09f2e93be5e3cbde8a97850b1989..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22486 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 diff --git a/user/mpy/lib/axtls/www/index.html b/user/mpy/lib/axtls/www/index.html deleted file mode 100755 index 2b1d8b3..0000000 --- a/user/mpy/lib/axtls/www/index.html +++ /dev/null @@ -1,7103 +0,0 @@ - - - - - - - - - - - - axTLS Embedded SSL - changes, notes and errata - - - - - - - - - - - - - -
-
-
-
-
changes, notes and errata
-
Type the text for 'YourName'
-
@@bgcolor(#ff0000):color(#ffffff):Changes for 2.1.2 (2016-12-31)@@\n\n!!__SSL Library__\n* Basic constraint/key usage v3 extensions now supported\n* Test harness must now be run without built-in default cert\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.1.1 (2016-12-20)@@\n\n!!__SSL Library__\n* X509 State, country and location are now used for verification and display.\n* SNI hostname memory is now managed by the calling application\n* X509 version number is checked before processing v3 extensions.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.1.0 (2016-12-13)@@\n\n!!__SSL Library__\n* SNI added\n* Some non-C sample code updated.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.0.1 (2016-08-30)@@\n\n!!__SSL Library__\n* ~RC4 only used if ~PKCS12 is used.\n* Buffer sizes tightned up.\n* Buffer check on client handshake due to some incompatibilities.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 2.0.0 (2016-08-17)@@\n\n!!__SSL Library__\n* Support for TLS 1.2\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.4 (2016-07-07)@@\n\n!!__SSL Library__\n* Fixed client certificate issue where there is no client certificate and a certificate verify msg was still being sent.\n* Tag 64-bit constants with "LL" (e.g. keep ~AVR32 gcc happy)\n* Removed ~RC4 from the list of ciphers\n* Can handle chains that are out of order (thanks Paul Johnstone)\n* Removed some printfs in skeleton mode\n* Removed endian.h as it was causing some porting issues\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.3 (2015-04-30)@@\n\n!!__SSL Library__\n* Added named unions to ~SHA512 code as some compilers don't support it\n* Some other porting suggesions from Chris Ghormley\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.2 (2015-03-10)@@\n\n!!__SSL Library__\n* ~SHA384/~SHA512 support added\n* Security issue fixed where a plain text could be injected before the handshake was completed\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.1 (2014-11-19)@@\n\n!!__SSL Library__\n* ~SHA256 support added\n* All padding/separator bytes checked in ~RSA_decrypt()\n* Added check to get_asn1_length() to limit the number of octets and to not allow overflow\n* ~MD2 removed\n* Return code checked for get_random()\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.5.0 (2014-10-31)@@\n\n!!__SSL Library__\n* Fixed array access out of bounds bug in add_cert() (thanks Ole Reinhardt)\n* Fix handling of return values of ~SOCKET_READ in process_sslv23_client_hello() (thanks Ole Reinhardt)\n* added generalized time for certificates\n* added printf changes from Fabian Frank to stop warnings/errors\n* Moved setting encryption flags to after handshake completion (thanks Eric Hu)\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.9@@\n\n!!__SSL Library__\n* Fixed issue where the Chrome browser could not connect. This was due to Chrome sending different version numbers in its record header and client hello. ~AxTLS has been modified to use the client hello version as part of ~RFC5246.\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.8@@\n\n!!__SSL Library__\n* Fixed issue where the stdint typedefs were not imported by default (stdint.h had to be included explicity) (thanks Anthony G. Basile)\n\n!!__axhttpd__\n* The password hash broke due to an over zealous buffer overflow check. \n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.6@@\n\n!!__SSL Library__\n* Fixed issue where the stdint typedefs were not imported by default (stdint.h had to be included explicity) (thanks Anthony G. Basile)\n* Fixed RNG initialization issue where client library was performed incorrectly (thanks Gilles Boccon~-Gibod). \n\n!!__axhttpd__\n* Now compiles properly under TCP/IP v6.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.5@@\n\n!!__SSL Library__\n* Fixed possible buffer overflow when doing base64 decoding (thanks Emil Kvarnhammar).\n* Fixed unicode parsing error in certificates (thanks Eric Hu)\n\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.4@@\n\n!!__axhttpd__\n* Allow other CGI applications (such as PHP) to call HTML files from their command line.\n\n!!__SSL Library__\n* Fixed memory leak with invalid certificates (thanks Jon Trauntvein)\n* Fixed issue with non-blocking client connections not working properly (thanks Richard Titmuss).\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.3@@\n\n!!__SSL Library__\n* axtlswrap compilation error fixed.\n\n!!__axhttpd__\n* added '-w' command-line option to set the webroot directory.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.2@@\n\n!!__SSL Library__\n* bi_export could have a buffer overrun with incorrect input (thanks Gilles ~Boccon-Gibod - 3334305)\n\n!!__axhttpd__\n* ~RFC1123 time format used in the headers.\n* Expires heading added (current time + ~CONFIG_HTTP_TIMEOUT)\n* UTC/localtime issue with ~If-Modified-Since header.\n\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.1@@\n\n!!__SSL Library__\n* Allow reading of ~PKCS8/12 unencrypted keys in PEM format and mconf will allow the option in server mode (thanks Steve Bennett).\n* Issue where comparing a null and an empty string could return a false positive for cert check (thanks Gilles ~Boccon-Gibod - 3310885).\n* -fPIC added as a Linux compile option.\n\n!!__axhttpd__\n* Killing connections on session timeout is guaranteed.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.4.0@@\n\n!!__SSL Library__\n* TLS v1.1 implemented and is enabled by default.\n* Closure alerts implemented correctly.\n* Fixed issue with ~SSLv23 hello versioning. \n \n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.4@@\n\n!!__SSL Library__\n* SSL 2.0 client hello is turned off by default as per RFC 4346 Appendix E.\n* Client determines the cipher suite selected rather than the server as per RFC 4346 7.4.1.2.\n* Guard against timing HMAC timing attacks as per RFC 4346 6.2.3.2.\n* Fixed ~SOCKET_WRITE buffer issue (thanks Hardy Griech - 3177419)\n* Fixed variable length MAC issue as used by gnutls.\n* Fixed version issue when TLS >=1.1 is used.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.2@@\n\n!!__SSL Library__\n* Loading of PEM certificate bundles now loads CA certs properly.\n* ssl_client_new() can now be broken up into an ssl_client_new() and successive ssl_read()'s now by setting the ~SSL_CONNECT_IN_PARTS as an option in ssl_ctx_new().\n* Non-blocked mode is now not a requirement but calls may still be blocked.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.1@@\n\n!!__SSL Library__\n* Certificate bundles which contain "invalid" certificates (i.e. invalid digests types etc) are ignored rather than cause failure.\n\n!!__axhttpd__\n* ~HTTPv1.0 packets close a connection upon completion.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.3.0@@\n\n!!__SSL Library__\n* Close notify is now sent as an error code from ssl_read(). Server code should be modified to check for ~SSL_CLOSE_NOTIFY (thanks to Eric Hu - 3132700).\n* regular_square() issue fixed (3078672)\n* partial_multiply() removed and merged with regular_multiply() (3078372).\n* Invalid session id size now returns ~SSL_ERROR_INVALID_SESSION (thanks to Hardy Griech - 3072881)\n* q-dash issue with Barrett reduction fixed (thanks to Hardy Griech - 3079291).\n* PEM file detection now looks for "-BEGIN" in any part of the file rather than at the start (3123838).\n* 8/16/32 bit native int sizes can be selected in configuration.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.7@@\n\n!!__SSL Library__\n* A fix to find_max_exp_index() (thanks to Hardy Griech).\n* Check is made to get_cipher_info() if the appropriate cipher is not found (thanks to Hardy Griech).\n* Extra x509_free() removed from do_client_connect().\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.5@@\n\n!!__SSL Library__\n* The custom RNG updated to use an entropy pool (with better hooks to use counters).\n\n!!__axhttpd__\n* Headers are case insensitive (thanks to Joe Pruett for this and the following).\n* Child zombie issue fixed.\n* EOF on ~POSTs fixed.\n* Expect is ignored.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.4@@\n\n!!__SSL Library__\n* Client renegotiation now results in an error. This is the result of a security flaw described in this paper http://extendedsubset.com/Renegotiating_TLS.pdf, and also is explained in detail here http://www.cupfighter.net/index.php/2009/11/tls-renegotiation-attack/.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.3@@\n\n!!__SSL Library__\n* v3 certificates with ~SANs now supports (thanks to Carsten Sørensen).\n* axtlswrap added - a port of sslwrap (thanks to Steve Bennett)\n\n!!__axhttpd__\n* shutdown() called before socket close in CGI (thanks to Tom Brown)\n* command-line parameters to specify the http/https port.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.2@@\n\n!!__axhttpd__\n* File uploads over 1kB (but under MAXPOSTDATASIZE) are now supported.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.1@@\n\n!!__SSL Library__\n* Certificate verification now works for Firefox.\n* Extended the openssl API.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.0@@\n\n!!__SSL Library__\n* A self-signed certificate will be verified as ok provided that that it is on the certificate authority list.\n* Certificates are not verified when added as certificate authorities (since self-signed and expired certificates can be added to browsers etc)\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.9@@\n\n!!__SSL Library__\n* Now support MS IIS resource kit certificates (thanks to Carsten Sørensen).\n* Fixed a memory leak when freeing more than one CA certificate.\n* The bigint library had a problem with squaring which affected classical reduction (thanks to Manuel Klimek).\n\n!!__axhttpd__\n* Brought back setuid()/setgid() as an option.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.8@@\n\n!!__SSL Library__\n* Now using a BSD style license.\n* Self-signed certificates can now be automatically generated (the keys still need to be provided).\n* A new API call //ssl_x509_create()// can be used to programatically create the certificate.\n* Certificate/keys can be loaded automatically given a file location.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.7@@\n\n!!__SSL Library__\n\n* Variable sized session id's is now better handled for session caching. It has meant a new API call //ssl_get_session_id_size()// and a change to //ssl_client_new()// to define the session id size.\n* Muliple records with a single header are now better supported (thanks to Hervé Sibert).\n* ~MD2 added for Verisign root cert verification (thanks to Byron Rakitzis).\n* The ~MD5/~SHA1 digests are calculated incrementally to reduce memory (thanks to Byron Rakitzis).\n* The bigint cache is now cleared regularly to reduce memory.\n\n!!__axhttpd__\n\n* Improved the POST handling (thanks to Christian Melki).\n* CSS files now work properly.\n* Lua's CGI launcher location is configurable.\n* //vfork()// is now used for CGI for performance reasons.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.6@@\n\n!!__SSL Library__\n\n* ~RC4 speed improvements\n* Lua samples/bindings now work properly\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.5@@\n\n!!__SSL Library__\n\n* Session id's can now be variable lengths in server hello messages.\n* 0 length client certificates are now supported.\n* ssl_version() now returns just the version and not the date.\n* ssl_write() was not sending complete packets under load.\n\n!!__axhttpd__\n\n* Completely updated the CGI code.\n* Lua now integrated - Lua scripts and Lua Pages now run.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.4@@\n\n!!__SSL Library__\n\n* Fixed a Win32 crypto library issue with non-Administrator users\n* Removed compiler warnings that showed up in ~FC6.\n* GNU TLS certificates are now accepted.\n* Separated the send/receive headers for HMAC calculations.\n* Fixed a compilation problem with swig/perl/~FC6.\n* Fixed an issue with loading PEM CA certificates.\n\n!!__axhttpd__\n\n* Made //setuid()/setgid()// call an mconf option.\n* Made //chroot()// an mconf option. Default to //chdir()// instead.\n* Removed optional permissions checking.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.1@@\n\n!!__SSL Library__\n\n* AES should now work on 16bit processors (there was an alignment problem).\n* Various freed objects are cleared before freeing.\n* Header files now installed in ///usr/local/include/axTLS//.\n* -DCYGWIN replaced with -~DCONFIG_PLATFORM_CYGWIN (and the same for Solaris).\n* removed "-noextern" option in Swig. Fixed some other warnings in Win32.\n* SSLCTX changed to ~SSL_CTX (to be consistent with openssl). SSLCTX still exists for backwards compatibility.\n* malloc() and friends call abort() on failure.\n* Fixed a memory leak in directory listings.\n* Added openssl() compatibility functions.\n* Fixed Cygwin 'make install' issue.\n\n!!__axhttpd__\n\n* main.c now becomes axhttpd.c.\n* Header file issue fixed (in mime_types.c).\n* //chroot()// now used for better security.\n* Basic authentication implemented (via .htpasswd).\n* SSL access/denial protection implemented (via .htaccess).\n* Directory access protection implemented (via .htaccess).\n* Can now have more than one CGI file extension in mconf.\n* "~If-Modified-Since" request now handled properly.\n* Performance tweaks to remove //ssl_find()//.
[[Read Me]]
axTLS uses a BSD style license:\n\nCopyright (c) 2008, Cameron Rich All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer. Redistributions in binary\nform must reproduce the above copyright notice, this list of conditions and\nthe following disclaimer in the documentation and/or other materials\nprovided with the distribution. Neither the name of the axTLS Project nor\nthe names of its contributors may be used to endorse or promote products\nderived from this software without specific prior written permission. \n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGE.
[[Read Me]] \n[[Changelog]]\n[[axhttpd]]\n[[License]]
-
<div class='header' macro='gradient vert #390108 #900'>\n<div class='headerShadow'>\n<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;\n<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>\n</div>\n<div class='headerForeground'>\n<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;\n<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>\n</div>\n</div>\n<div id='mainMenu'>\n<div refresh='content' tiddler='MainMenu'></div>\n</div>\n<div id='sidebar'>\n<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>\n<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>\n</div>\n<div id='displayArea'>\n<div id='messageArea'></div>\n<div id='tiddlerDisplay'></div>\n</div>
-
!@@bgcolor(#ff0000):color(#ffffff):axTLS Quick Start Guide@@\n\nThis is a guide to get a small SSL web-server up and running quickly.\n\n!!__Introduction__\n\nThe axTLS project is an SSL client/server library using the ~TLSv1 protocol. It is designed to be small and fast, and is suited to embedded projects. A web server is included.\n\nThe basic web server + SSL library is around 60-70kB and is configurable for features or size.\n\n!!__Compilation__\n\nAll platforms require GNU make. This means on Win32 that Cygwin needs to be installed with "make" and various developer options selected.\n\nConfiguration now uses a tool called "mconf" which gives a nice way to configure options (similar to what is used in ~BusyBox and the Linux kernel).\n\nYou should be able to compile axTLS simply by extracting it, change into the extracted directory and typing:\n\n{{indent{{{{> make}}}\n\nSelect your platform type, save the configuration, exit, and then type "make" again.\n\nIf all goes well, you should end up with an executable called "axhttpd" (or axhttpd.exe) in the //_stage// directory.\n\nTo play with all the various axTLS options, type:\n\n{{indent{{{{> make menuconfig}}}\n\nSave the new configuration and rebuild.\n\n!!__Running it__\n\nTo run it, go to the //_stage// directory, and type (as superuser):\n\n{{indent{{{{> axhttpd}}}\n\nNote: you may have to set your ~LD_LIBRARY_PATH - e.g. go to //_stage// and type //export ~LD_LIBRARY_PATH=`pwd`//\n\nAnd then point your browser at https://127.0.0.1 And you should see a this html page with a padlock appearing on your browser. or type http://127.0.0.1 to see the same page unencrypted.\n\n!!__The axssl utilities__\n\nThe axssl suite of tools are the SSL test tools in the various language bindings. They are:\n\n* axssl - C sample\n* axssl.csharp - C# sample\n* axssl.vbnet - VB.NET sample\n* axtls.jar - Java sample\n* axssl.pl - Perl sample\n* axssl.lua - Lua sample\n\nAll the tools have identical command-line parameters. e.g. to run something interesting:\n\n{{indent{{{{> axssl s_server -verify -CAfile ../ssl/test/axTLS.ca_x509}}}\n\nand\n\n{{indent{{{{> axssl s_client -cert ../ssl/test/axTLS.x509_1024 -key ../ssl/test/axTLS.key_1024 -reconnect}}}\n\n!!!!C#\n\nIf building under Linux or other non-Win32 platforms, Mono must be installed and the executable is run as:\n\n{{indent{{{{> mono axssl.csharp.exe ...}}}\n\n!!!!Java\n\nThe java version is run as:\n\n{{indent{{{{> java -jar axtls.jar <options>}}}\n\n!!!!Perl\n\n{{indent{{{{> [perl] ./axssl.pl <options>}}}\n\nIf running under Win32, be sure to use the correct version of Perl (i.e. ~ActiveState's version works ok).\n\n!!!!Lua\n\n{{indent{{{{> [lua] ./axssl.lua <options>}}}\n\n!__Known Issues__\n\n* Firefox doesn't handle legacy ~SSLv2 at all well. Disabling ~SSLv2 still initiates a ~SSLv23 handshake (v1.5). And continuous pressing of the "Reload" page instigates a change to ~SSLv3 for some reason (even though the TLS 1.0 option is selected). This will cause a "Firefox and <server> cannot communicate securely because they have no common encryption algorithms" (v1.5), or "Firefox can't connect to <server> because the site uses a security protocol which isn't enabled" (v2.0). See bugzilla issues 343543 and 359484 (Comment #7). It's all broken (hopefully fixed soon).\n* Perl/Java bindings don't work on 64 bit Linux machines. I can't even compile the latest version of Perl on an ~AMD64 box (using ~FC3).\n* Java 1.4 or better is required for the Java interfaces.\n* Processes that fork can't use session resumption unless some form of IPC is used.\n* Ensure libperl.so and libaxtls.so are in the shared library path when running with the perl bindings. A way to do this is with:\n\n{{indent{{{{> export LD_LIBRARY_PATH=`perl -e 'use Config; print $Config{archlib};'`/CORE:.}}}\n* The lua sample requires the luabit library from http://luaforge.net/projects/bit.\n\n!!!!Win32 issues\n\n* Be careful about doing .NET executions on network drives - .NET complains with security exceptions on the binary. //TODO: Add a manifest file to prevent this.//\n* CGI has been removed from Win32 - it needs a lot more work to get it right.\n* The default Microsoft .NET SDK is v2.0.50727. Download from: http://msdn.microsoft.com/netframework/downloads/updates/default.aspx.\n\n!!!!Solaris issues\n\n* mconf doesn't work well - some manual tweaking is required for string values.\n* GNU make is required and needs to be in $PATH.\n* To get swig's library dependencies to work (and for the C library to be found), I needed to type:\n\n{{indent{{{{> export LD_LIBRARY_PATH=/usr/local/gcc-3.3.1/lib:.}}}\n\n!!!!Cygwin issues\n\n* The bindings all compile but don't run under Cygwin with the exception of Perl. This is due to win32 executables being incompatible with Cygwin libraries.\n\n
-
changes, notes and errata
-
axTLS Embedded SSL
-
http://axtls.cerocclub.com.au
-
/***\nhttp://tiddlystyles.com/#theme:DevFire\nAuthor: Clint Checketts\n***/\n\n/*{{{*/\nbody {\nbackground: #000;\n}\n/*}}}*/\n/***\n!Link styles /% ============================================================= %/\n***/\n/*{{{*/\na,\na.button,\n#mainMenu a.button,\n#sidebarOptions .sliderPanel a{\n color: #ffbf00;\n border: 0;\n background: transparent;\n}\n\na:hover,\na.button:hover,\n#mainMenu a.button:hover,\n#sidebarOptions .sliderPanel a:hover\n#sidebarOptions .sliderPanel a:active{\n color: #ff7f00;\n border: 0;\n border-bottom: #ff7f00 1px dashed;\n background: transparent;\n text-decoration: none;\n}\n\n#displayArea .button.highlight{\n color: #ffbf00;\n background: #4c4c4c;\n}\n/*}}}*/\n/***\n!Header styles /% ============================================================= %/\n***/\n/*{{{*/\n.header{\n border-bottom: 2px solid #ffbf00;\n color: #fff;\n}\n\n.headerForeground a {\n color: #fff;\n}\n\n.header a:hover {\n border-bottom: 1px dashed #fff;\n}\n/*}}}*/\n/***\n!Main menu styles /% ============================================================= %/\n***/\n/*{{{*/\n#mainMenu {color: #fff;}\n#mainMenu h1{\n font-size: 1.1em;\n}\n#mainMenu li,#mainMenu ul{\n list-style: none;\n margin: 0;\n padding: 0;\n}\n/*}}}*/\n/***\n!Sidebar styles /% ============================================================= %/\n***/\n/*{{{*/\n#sidebar {\n right: 0;\n color: #fff;\n border: 2px solid #ffbf00;\n border-width: 0 0 2px 2px;\n}\n#sidebarOptions {\n background-color: #4c4c4c;\n padding: 0;\n}\n\n#sidebarOptions a{\n margin: 0;\n color: #ffbf00;\n border: 0;\n}\n#sidebarOptions a:hover {\n color: #4c4c4c;\n background-color: #ffbf00;\n\n}\n\n#sidebarOptions a:active {\n color: #ffbf00;\n background-color: transparent;\n}\n\n#sidebarOptions .sliderPanel {\n background-color: #333;\n margin: 0;\n}\n\n#sidebarTabs {background-color: #4c4c4c;}\n#sidebarTabs .tabSelected {\n padding: 3px 3px;\n cursor: default;\n color: #ffbf00;\n background-color: #666;\n}\n#sidebarTabs .tabUnselected {\n color: #ffbf00;\n background-color: #5f5f5f;\n padding: 0 4px;\n}\n\n#sidebarTabs .tabUnselected:hover,\n#sidebarTabs .tabContents {\n background-color: #666;\n}\n\n.listTitle{color: #FFF;}\n#sidebarTabs .tabContents a{\n color: #ffbf00;\n}\n\n#sidebarTabs .tabContents a:hover{\n color: #ff7f00;\n background: transparent;\n}\n\n#sidebarTabs .txtMoreTab .tabSelected,\n#sidebarTabs .txtMoreTab .tab:hover,\n#sidebarTabs .txtMoreTab .tabContents{\n color: #ffbf00;\n background: #4c4c4c;\n}\n\n#sidebarTabs .txtMoreTab .tabUnselected {\n color: #ffbf00;\n background: #5f5f5f;\n}\n\n.tab.tabSelected, .tab.tabSelected:hover{color: #ffbf00; border: 0; background-color: #4c4c4c;cursor:default;}\n.tab.tabUnselected {background-color: #666;}\n.tab.tabUnselected:hover{color:#ffbf00; border: 0;background-color: #4c4c4c;}\n.tabContents {\n background-color: #4c4c4c;\n border: 0;\n}\n.tabContents .tabContents{background: #666;}\n.tabContents .tabSelected{background: #666;}\n.tabContents .tabUnselected{background: #5f5f5f;}\n.tabContents .tab:hover{background: #666;}\n/*}}}*/\n/***\n!Message area styles /% ============================================================= %/\n***/\n/*{{{*/\n#messageArea {background-color: #666; color: #fff; border: 2px solid #ffbf00;}\n#messageArea a:link, #messageArea a:visited {color: #ffbf00; text-decoration:none;}\n#messageArea a:hover {color: #ff7f00;}\n#messageArea a:active {color: #ff7f00;}\n#messageArea .messageToolbar a{\n border: 1px solid #ffbf00;\n background: #4c4c4c;\n}\n/*}}}*/\n/***\n!Popup styles /% ============================================================= %/\n***/\n/*{{{*/\n.popup {color: #fff; background-color: #4c4c4c; border: 1px solid #ffbf00;}\n.popup li.disabled{color: #fff;}\n.popup a {color: #ffbf00; }\n.popup a:hover { background: transparent; color: #ff7f00; border: 0;}\n.popup hr {color: #ffbf00; background: #ffbf00;}\n/*}}}*/\n/***\n!Tiddler Display styles /% ============================================================= %/\n***/\n/*{{{*/\n.title{color: #fff;}\nh1, h2, h3, h4, h5 {\n color: #fff;\n background-color: transparent;\n border-bottom: 1px solid #333;\n}\n\n.subtitle{\n color: #666;\n}\n\n.viewer {color: #fff; }\n\n.viewer table{background: #666; color: #fff;}\n\n.viewer th {background-color: #996; color: #fff;}\n\n.viewer pre, .viewer code {color: #ddd; background-color: #4c4c4c; border: 1px solid #ffbf00;}\n\n.viewer hr {color: #666;}\n\n.tiddler .button {color: #4c4c4c;}\n.tiddler .button:hover { color: #ffbf00; background-color: #4c4c4c;}\n.tiddler .button:active {color: #ffbf00; background-color: #4c4c4c;}\n\n.toolbar {\n color: #4c4c4c;\n}\n\n.toolbar a.button,\n.toolbar a.button:hover,\n.toolbar a.button:active,\n.editorFooter a{\n border: 0;\n}\n\n.footer {\n color: #ddd;\n}\n\n.selected .footer {\n color: #888;\n}\n\n.highlight, .marked {\n color: #000;\n background-color: #ffe72f;\n}\n.editorFooter {\n color: #aaa;\n}\n\n.tab{\n-moz-border-radius-topleft: 3px;\n-moz-border-radius-topright: 3px;\n}\n\n.tagging,\n.tagged{\n background: #4c4c4c;\n border: 1px solid #4c4c4c; \n}\n\n.selected .tagging,\n.selected .tagged{\n background-color: #333;\n border: 1px solid #ffbf00;\n}\n\n.tagging .listTitle,\n.tagged .listTitle{\n color: #fff;\n}\n\n.tagging .button,\n.tagged .button{\n color: #ffbf00;\n border: 0;\n padding: 0;\n}\n\n.tagging .button:hover,\n.tagged .button:hover{\nbackground: transparent;\n}\n\n.selected .isTag .tagging.simple,\n.selected .tagged.simple,\n.isTag .tagging.simple,\n.tagged.simple {\n float: none;\n display: inline;\n border: 0;\n background: transparent;\n color: #fff;\n margin: 0;\n}\n\n.cascade {\n background: #4c4c4c;\n color: #ddd;\n border: 1px solid #ffbf00;\n}\n/*}}}*/
-
axhttpd is a small embedded web server using the axTLS library. It is based originally on the web server written by Doug Currie which is at http://www.hcsw.org/awhttpd.\n\n!@@bgcolor(#ff0000):color(#ffffff):axhttpd Features@@ \n\n!!__Basic Authentication__\n\nBasic Authentication uses a password file called ".htpasswd", in the directory to be protected. This file is formatted as the familiar colon-separated username/encrypted-password pair, records delimited by newlines. The protection does not carry over to subdirectories. The utility program htpasswd is included to help manually edit .htpasswd files.\n\nThe encryption of this password uses a proprietary algorithm due to the dependency of many crypt libraries on DES. An example is in [[/test_dir/no_http|https://localhost/test_dir/no_http]] (username 'abcd', password is '1234').\n\n//Note: This is an mconf enabled configuration option.//\n\n!!__SSL Protection__\n\nDirectories/files can be accessed using the 'http' or 'https' uri prefix. If normal http access for a directory needs to be disabled, then put "~SSLRequireSSL" into a '.htaccess' file in the directory to be protected. \n\nConversely, use "~SSLDenySSL" to deny access to directories via SSL.\n\nAn example is in [[/test_dir/no_http|http://localhost/test_dir/no_http]] and [[/test_dir/no_ssl|https://localhost/test_dir/no_ssl]].\n\nEntire directories can be denied access with a "Deny all" directive (regardless of SSL or authentication). An example is in [[/test_dir/bin|http://localhost/test_dir/bin]]\n\n!!__CGI__\n\nMost of the CGI 1.1 variables are now placed into the script environment and should work as normal.\n\n!!__Lua and Lua Pages__\n\nThis is a small scripting language gaining popularity in embedded applications due to its small footprint and fast speed.\n\nLua has been incorporated into the build, so simply select it and it will automatically install. Try pointing your browser at [[test_main.html|http://localhost/lua/test_main.html]] to see an example of Lua Pages.\n\n//Note: This is an mconf enabled configuration option.//\n\nThe readline development library may have to be downloaded: //yum install readline-devel//\n\n!!__Directory Listing__\n\nAn mconf option. Allow the files in directories to be displayed. An example is in [[/test_dir|http://localhost/test_dir]]\n\n!!__Other Features__\n\n* Timeout - HTTP 1.1 allows for persistent connections. This is the time allowed for this connection in seconds.\n* Daemon - Puts the process in daemon mode. \n* SSL session cache size - The size of the session cache (a heavily loaded server should maintain many sessions). A session will save on expensive SSL handshaking.\n\n
-
- - - - - diff --git a/user/mpy/lib/axtls/www/lua/download.lua b/user/mpy/lib/axtls/www/lua/download.lua deleted file mode 100644 index 2ee1a71..0000000 --- a/user/mpy/lib/axtls/www/lua/download.lua +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/local/bin/lua - -require"luasocket" - -function receive (connection) - connection:settimeout(0) - local s, status = connection:receive (2^10) - if status == "timeout" then - coroutine.yield (connection) - end - return s, status -end - -function download (host, file, outfile) - --local f = assert (io.open (outfile, "w")) - local c = assert (socket.connect (host, 80)) - c:send ("GET "..file.." HTTP/1.0\r\n\r\n") - while true do - local s, status = receive (c) - --f:write (s) - if status == "closed" then - break - end - end - c:close() - --f:close() -end - -local threads = {} -function get (host, file, outfile) - print (string.format ("Downloading %s from %s to %s", file, host, outfile)) - local co = coroutine.create (function () - return download (host, file, outfile) - end) - table.insert (threads, co) -end - -function dispatcher () - while true do - local n = table.getn (threads) - if n == 0 then - break - end - local connections = {} - for i = 1, n do - local status, res = coroutine.resume (threads[i]) - if not res then - table.remove (threads, i) - break - else - table.insert (connections, res) - end - end - if table.getn (connections) == n then - socket.select (connections) - end - end -end - -local url = arg[1] -if not url then - print (string.format ("usage: %s url [times]", arg[0])) - os.exit() -end -local times = arg[2] or 5 - -url = string.gsub (url, "^http.?://", "") -local _, _, host, file = string.find (url, "^([^/]+)(/.*)") -local _, _, fn = string.find (file, "([^/]+)$") - -for i = 1, times do - get (host, file, fn..i) -end - -dispatcher () diff --git a/user/mpy/lib/axtls/www/lua/env.lua b/user/mpy/lib/axtls/www/lua/env.lua deleted file mode 100644 index c429847..0000000 --- a/user/mpy/lib/axtls/www/lua/env.lua +++ /dev/null @@ -1,26 +0,0 @@ --- This file should be executed before any script in this directory --- according to the configuration (cgilua/conf.lua). - -pcall (cgilua.enablesession) - -local put, mkurlpath = cgilua.put, cgilua.mkurlpath - -cgilua.addclosefunction (function () - put [[ -

- -Main]] - for _, test in { - { "Get", "test_main.lua", {ab = "cd", ef = "gh"} }, - { "Cookies", "test_cookies.lua", }, - { "FileSystem", "test_fs.lua", }, - { "Libraries", "test_lib.lua", }, - { "Session", "test_session.lua", }, - { "Variables", "test_variables.lp", }, - } do - put (string.format (' · %s', - mkurlpath (test[2], test[3]), test[1])) - end - put [[ -]] -end) diff --git a/user/mpy/lib/axtls/www/lua/overview.lp b/user/mpy/lib/axtls/www/lua/overview.lp deleted file mode 100644 index 4d17002..0000000 --- a/user/mpy/lib/axtls/www/lua/overview.lp +++ /dev/null @@ -1,64 +0,0 @@ - - -CGILua installation overview - - -

CGILua installation overview

- - - - - - - - - - - - - -
Version - Copyright - Description -
<%= tostring(_G[l[2]]) %> - - -
<%= idx(p,"VERSION") %> - <%= idx(p,"COPYRIGHT") %> - <%= idx(p,"DESCRIPTION") %> -
- - - diff --git a/user/mpy/lib/axtls/www/lua/prepara_sql2.lua b/user/mpy/lib/axtls/www/lua/prepara_sql2.lua deleted file mode 100644 index 6a37c2f..0000000 --- a/user/mpy/lib/axtls/www/lua/prepara_sql2.lua +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/local/bin/lua - -MAX_ROWS = arg[1] or 10 - -require"postgres" - -local env = assert (luasql.postgres ()) -local conn = assert (env:connect ("luasql-test", "tomas")) - --- Apaga restos de outros testes. -conn:execute "drop table t2" -conn:execute "drop table t1" - --- Criando as tabelas. -assert (conn:execute [[create table t1 ( - a int, - b int -)]]) -assert (conn:execute [[create table t2 ( - c int, - d int -)]]) - --- Preenchedo as tabelas. -for i = 1, MAX_ROWS do - local ii = 2*i - assert (conn:execute (string.format ([[ -insert into t1 values (%d, %d); -insert into t2 values (%d, %d);]], - ii, i, ii, i))) -end diff --git a/user/mpy/lib/axtls/www/lua/test_conc.lua b/user/mpy/lib/axtls/www/lua/test_conc.lua deleted file mode 100644 index bbb9be7..0000000 --- a/user/mpy/lib/axtls/www/lua/test_conc.lua +++ /dev/null @@ -1,38 +0,0 @@ -cgilua.htmlheader() -if ap then - local pid, ppid = ap.pid () - if not ppid then - ppid = "no parent pid" - end - cgilua.put ("pid = "..pid.." ("..ppid..")".."\n") -end - -assert(type(stable.get) == "function") -assert(type(stable.set) == "function") - -cgilua.put"stable.pairs = {
\n" -for i, v in stable.pairs () do - cgilua.put (i.." = "..tostring(v).."
\n") -end -cgilua.put"}
\n" - -local counter = stable.get"counter" or 0 -stable.set ("counter", counter + 1) - -local f = stable.get"f" -if not f then - local d = os.date() - stable.set ("f", function () return d end) -else - cgilua.put ("f() = "..tostring (f ())) -end - -cgilua.put"
\n" -for i = 1,800 do - cgilua.put (i) - for ii = 1,1000 do - cgilua.put ("") - end - cgilua.put ("\n") -end -cgilua.put ("End") diff --git a/user/mpy/lib/axtls/www/lua/test_cookies.lp b/user/mpy/lib/axtls/www/lua/test_cookies.lp deleted file mode 100644 index 932b9c5..0000000 --- a/user/mpy/lib/axtls/www/lua/test_cookies.lp +++ /dev/null @@ -1,13 +0,0 @@ - - -

Testing Cookies library

- -<%= CL_COOKIE%> = <%= tostring(test)%>
-Assigning current date to cookie!
-Reload this script to check cookie's value! diff --git a/user/mpy/lib/axtls/www/lua/test_cookies.lua b/user/mpy/lib/axtls/www/lua/test_cookies.lua deleted file mode 100644 index 6af935e..0000000 --- a/user/mpy/lib/axtls/www/lua/test_cookies.lua +++ /dev/null @@ -1,14 +0,0 @@ -local cookies = require"cgilua.cookies" -CL_COOKIE = "cgilua_cookie" - -local test = cookies.get (CL_COOKIE) -cookies.set (CL_COOKIE, os.date()) - -cgilua.htmlheader () -cgilua.put ([[ -

Testing Cookies library

- -]]..CL_COOKIE..' = '..tostring(test)..[[
-Assigning current date to cookie!
-Reload this script to check cookie's value! -]]) diff --git a/user/mpy/lib/axtls/www/lua/test_err.lua b/user/mpy/lib/axtls/www/lua/test_err.lua deleted file mode 100644 index 4d6ffc9..0000000 --- a/user/mpy/lib/axtls/www/lua/test_err.lua +++ /dev/null @@ -1,4 +0,0 @@ -cgilua.htmlheader() -cgilua.put"Oi!" ---io.write"something\n" -cgilua.errorlog ("eca", "emerg") diff --git a/user/mpy/lib/axtls/www/lua/test_fs.lua b/user/mpy/lib/axtls/www/lua/test_fs.lua deleted file mode 100644 index 566ed8b..0000000 --- a/user/mpy/lib/axtls/www/lua/test_fs.lua +++ /dev/null @@ -1,23 +0,0 @@ -function link_dir (dir, base) - local path = base.."/"..dir - local mode = lfs.attributes (path).mode - if mode == "directory" then - return string.format ('%s', - cgilua.mkurlpath ("test_fs.lua", { dir = path }), - dir) - else - return dir - end -end - -cgilua.htmlheader () -cgilua.put ("

Testing Filesystem library

\n") -cgilua.put ("\n") -cgilua.put ("\n") -local i = 0 -local dir = cgi.dir or "." -for file in lfs.dir (dir) do - i = i+1 - cgilua.put ("\n") -end -cgilua.put ("
Testing dir
"..i..""..link_dir(file, dir).."
\n") diff --git a/user/mpy/lib/axtls/www/lua/test_htk.lua b/user/mpy/lib/axtls/www/lua/test_htk.lua deleted file mode 100644 index ac1de6c..0000000 --- a/user/mpy/lib/axtls/www/lua/test_htk.lua +++ /dev/null @@ -1,22 +0,0 @@ -require"htk" - -local a_table = {} -for i = 1, 20 do - local l = {} - for j = 1, 20 do - table.insert (l, HTK.TD { "cell "..i..","..j }) - end - table.insert (a_table, HTK.TR (l)) -end - -cgilua.htmlheader() -cgilua.put (HTK.HTML { - HTK.HEAD { HTK.TITLE { "Titulo da Pagina" } }, - HTK.BODY { - bgcolor = "#FFFFFF", - HTK.H1 { "Titulo da Pagina" }, - HTK.P {}, - "Uma página qualquer", - HTK.TABLE (a_table), - } -}) diff --git a/user/mpy/lib/axtls/www/lua/test_lib.lua b/user/mpy/lib/axtls/www/lua/test_lib.lua deleted file mode 100644 index 5041253..0000000 --- a/user/mpy/lib/axtls/www/lua/test_lib.lua +++ /dev/null @@ -1,31 +0,0 @@ -local function getfield (t, f) - for w in string.gfind(f, "[%w_]+") do - if not t then return nil end - t = t[w] - end - return t -end - -function test_lib (libname) - local ok, err = pcall (require, libname) - if not ok then - cgilua.put ("Library "..libname.." not found
\n".. - err) - else - cgilua.put ("Library "..libname.."
\n") - local t = getfield (_G, libname) - if type(t) ~= "table" then - cgilua.put (tostring(t)) - else - for i, v in pairs (t) do - cgilua.put ("  "..tostring(i).." = "..tostring(v).."
\n") - end - end - end - cgilua.put ("\n

\n") -end - -cgilua.htmlheader () -for _, lib in ipairs { "lfs", "socket", "luasql.postgres", "luasql", "lxp", "lxp.lom", "lualdap", "htk", "xmlrpc", "xmlrpc.http" } do - test_lib (lib) -end diff --git a/user/mpy/lib/axtls/www/lua/test_main.html b/user/mpy/lib/axtls/www/lua/test_main.html deleted file mode 100644 index a50dd63..0000000 --- a/user/mpy/lib/axtls/www/lua/test_main.html +++ /dev/null @@ -1,127 +0,0 @@ - -Test Page - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GET: -
Lua scriptmodule
HTML templatemodule
POST: -
-
- - - - - - - - - - - - -
- field 1:
- field 2:
- field 3: - op 1 - op 2 - op 3 -
Lua script - module -
HTML template - module -
-
-
POST (with upload): -
-
- - - - - - - - - - - - -
- field 1:
- file (binary!):
-
Lua script - module -
HTML template - module -
-
-
Cookies: -
Lua scriptmodule
HTML templatemodule
Filesystem: -
Lua scriptmodule
Session: -
Lua scriptmodule
CGI Variables: -
HTML templatemodule
Library Overview: -
HTML templatemodule
Concurrency -
Lua scriptmodule
- diff --git a/user/mpy/lib/axtls/www/lua/test_main.lp b/user/mpy/lib/axtls/www/lua/test_main.lp deleted file mode 100644 index 917ee1e..0000000 --- a/user/mpy/lib/axtls/www/lua/test_main.lp +++ /dev/null @@ -1,31 +0,0 @@ - -Embeded Lua Test - - -cgi = { -\n", vv, a, tostring(b)) - end - v = vv.."}" - end -?> -<%= i %> = <%= tostring(v) %>
-<% -end -%> -} -
-Remote address: <%= cgilua.servervariable"REMOTE_ADDR" %> -
-Is persistent = <%= tostring (SAPI.Info.ispersistent) %> -
-ap =
-lfcgi = <% = tostring(lfcgi) %>
-<%= (ap and ap.handler()) or "" %>
- - - diff --git a/user/mpy/lib/axtls/www/lua/test_main.lua b/user/mpy/lib/axtls/www/lua/test_main.lua deleted file mode 100644 index 0e997a2..0000000 --- a/user/mpy/lib/axtls/www/lua/test_main.lua +++ /dev/null @@ -1,46 +0,0 @@ -cgilua.htmlheader() -cgilua.put[[ - -Script Lua Test - - -cgi = { -]] - -for i,v in pairs (cgi) do - if type(v) == "table" then - local vv = "{" - for a,b in pairs(v) do - vv = string.format ("%s%s = %s
\n", vv, a, tostring(b)) - end - v = vv.."}" - end - cgilua.put (string.format ("%s = %s
\n", i, tostring(v))) -end -cgilua.put "}
\n" -cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR") -cgilua.put "
\n" -cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."
\n") -cgilua.put ("ap="..tostring(ap).."
\n") -cgilua.put ("lfcgi="..tostring(lfcgi).."
\n") - --- Checking Virtual Environment -local my_output = cgilua.put -cgilua.put = nil -local status, err = pcall (function () - assert (cgilua.put == nil, "cannot change cgilua.put value") -end) -cgilua.put = my_output -assert (status == true, err) - --- Checking require -local status, err = pcall (function () require"unknown_module" end) -assert (status == false, "unknown_module loaded!") --- assert (package == nil, "Access to package table allowed!") - -cgilua.put[[ -

- - -]] -cgilua = nil diff --git a/user/mpy/lib/axtls/www/lua/test_session.lua b/user/mpy/lib/axtls/www/lua/test_session.lua deleted file mode 100644 index d97cc45..0000000 --- a/user/mpy/lib/axtls/www/lua/test_session.lua +++ /dev/null @@ -1,43 +0,0 @@ -cgilua.enablesession () - -function pt (tab) - for i, v in pairs (tab) do - local vv = v - if type(v) == "table" then - vv = "" - for _i, _v in pairs (v) do - vv = vv..string.format ("%s = %q, ", _i, _v) - end - vv = '{'..vv..'}' - end - cgilua.put (string.format ("%s = %s
\n", tostring (i), tostring (vv))) - end -end - - -if cgi.field then - if not cgilua.session.data.field then - cgilua.session.data.field = {} - end - table.insert (cgilua.session.data.field, cgi.field) -end -cgilua.htmlheader() -if cgilua.session then - cgilua.put "cgi = {
\n" - pt (cgi) - cgilua.put "}
\n" - cgilua.put "cgilua.session.data = {
\n" - pt (cgilua.session.data) - cgilua.put "}
\n" - - cgilua.put [[

- field:
-
-
]] -else - cgilua.put "Sessions library is not available or not well configured" -end diff --git a/user/mpy/lib/axtls/www/lua/test_sql.lua b/user/mpy/lib/axtls/www/lua/test_sql.lua deleted file mode 100644 index 085ce97..0000000 --- a/user/mpy/lib/axtls/www/lua/test_sql.lua +++ /dev/null @@ -1,13 +0,0 @@ -local s = require"luasql.postgres" - -local env = assert (luasql.postgres ()) -local conn = assert (env:connect ("luasql-test", "tomas")) -local cur = assert (conn:execute ("select count(*) from fetch_test")) - -cgilua.htmlheader() -cgilua.put ("Total lines at table fetch_test is "..cur:fetch()) -cgilua.put (string.format ("
\n%s == %s
\n", tostring(s), tostring(luasql))) - -cur:close() -conn:close() -env:close() diff --git a/user/mpy/lib/axtls/www/lua/test_sql2.lua b/user/mpy/lib/axtls/www/lua/test_sql2.lua deleted file mode 100644 index a2f6ee1..0000000 --- a/user/mpy/lib/axtls/www/lua/test_sql2.lua +++ /dev/null @@ -1,24 +0,0 @@ -require"postgres" - -local env = assert (luasql.postgres ()) -local conn = assert (env:connect ("luasql-test", "tomas")) -local cur = assert (conn:execute ("select count(*) from t1")) -local total = tonumber (cur:fetch()) -cur:close() -local aleatorio = math.random(total) -local cur = assert (conn:execute ("select * from t1, t2 where b = d and a != "..2*aleatorio)) - -cgilua.htmlheader() -cgilua.put ("Aleatorio = "..aleatorio.."
\n") - -local a,b,c,d = cur:fetch() -cgilua.put ("\n") -while a do --- cgilua.put ("") - a,b,c,d = cur:fetch() -end -cgilua.put ("
",a,"",b,"",c,"",d,"
\n") - -cur:close() -conn:close() -env:close() diff --git a/user/mpy/lib/axtls/www/lua/test_variables.lp b/user/mpy/lib/axtls/www/lua/test_variables.lp deleted file mode 100644 index c1ac332..0000000 --- a/user/mpy/lib/axtls/www/lua/test_variables.lp +++ /dev/null @@ -1,14 +0,0 @@ - -<% for _, var in pairs { "SERVER_SOFTWARE", "SERVER_NAME", "GATEWAY_INTERFACE", "SERVER_PROTOCOL", "SERVER_PORT", "REQUEST_METHOD", "PATH_INFO", "PATH_TRANSLATED", "SCRIPT_NAME", "QUERY_STRING", "REMOTE_HOST", "REMOTE_ADDR", "AUTH_TYPE", "REMOTE_USER", "REMOTE_IDENT", "CONTENT_TYPE", "CONTENT_LENGTH", "HTTP_REFERER", "HTTP_COOKIE", "SCRIPT_FILENAME", "DOCUMENT_ROOT", } do %> - -<% end %> -
<%= var %>="<%= cgilua.servervariable(var) or "not defined"%>"
- -

- -<% for _, var in ipairs { "script_file", "script_path", "script_pdir", "script_vdir", "script_vpath", "urlpath", } do %> - -<% end %> -
<%= var %>="<%= cgilua[var] %>"
- -

diff --git a/user/mpy/lib/axtls/www/test_dir/bin/.htaccess b/user/mpy/lib/axtls/www/test_dir/bin/.htaccess deleted file mode 100644 index 8fd8c46..0000000 --- a/user/mpy/lib/axtls/www/test_dir/bin/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny all diff --git a/user/mpy/lib/axtls/www/test_dir/no_http/.htaccess b/user/mpy/lib/axtls/www/test_dir/no_http/.htaccess deleted file mode 100644 index 3e20076..0000000 --- a/user/mpy/lib/axtls/www/test_dir/no_http/.htaccess +++ /dev/null @@ -1 +0,0 @@ -SSLRequireSSL diff --git a/user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd b/user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd deleted file mode 100644 index 0471b01..0000000 --- a/user/mpy/lib/axtls/www/test_dir/no_http/.htpasswd +++ /dev/null @@ -1,2 +0,0 @@ -abcd:CQhgDPyy0rvEU8OMxnQIvg==$YdJfIKZimFLYxPf/rbnhtQ== -yaya:Syuss5jE2FNGVdr0kKGoHg==$WLw/SgHZFuAoOuml3GTJVw== diff --git a/user/mpy/lib/axtls/www/test_dir/no_http/index.html b/user/mpy/lib/axtls/www/test_dir/no_http/index.html deleted file mode 100644 index 8b86eba..0000000 --- a/user/mpy/lib/axtls/www/test_dir/no_http/index.html +++ /dev/null @@ -1,6 +0,0 @@ - -axhttpd is running - -Looks like you got to this directory. - - diff --git a/user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess b/user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess deleted file mode 100644 index d980d26..0000000 --- a/user/mpy/lib/axtls/www/test_dir/no_ssl/.htaccess +++ /dev/null @@ -1 +0,0 @@ -SSLDenySSL diff --git a/user/mpy/lib/axtls/www/test_dir/no_ssl/index.html b/user/mpy/lib/axtls/www/test_dir/no_ssl/index.html deleted file mode 100644 index 8b86eba..0000000 --- a/user/mpy/lib/axtls/www/test_dir/no_ssl/index.html +++ /dev/null @@ -1,6 +0,0 @@ - -axhttpd is running - -Looks like you got to this directory. - - diff --git a/user/mpy/lib/berkeley-db-1.xx/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/Makefile.inc deleted file mode 100644 index 77af9c5..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# @(#)Makefile.inc 8.2 (Berkeley) 2/21/94 -# -CFLAGS+=-D__DBINTERFACE_PRIVATE - -.include "${.CURDIR}/db/btree/Makefile.inc" -.include "${.CURDIR}/db/db/Makefile.inc" -.include "${.CURDIR}/db/hash/Makefile.inc" -.include "${.CURDIR}/db/man/Makefile.inc" -.include "${.CURDIR}/db/mpool/Makefile.inc" -.include "${.CURDIR}/db/recno/Makefile.inc" diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/Makefile deleted file mode 100644 index 383b259..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/README b/user/mpy/lib/berkeley-db-1.xx/PORT/README deleted file mode 100644 index 6d47281..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/README +++ /dev/null @@ -1,131 +0,0 @@ -# @(#)README 8.6 (Berkeley) 6/20/94 - -This is the area for building the libdb library. There are a number -of porting directories, for various architecture/OS combinations. Pick -the one that's closest to yours and try "make". For the rest of this -file, I'll use "MACH" as a fake architecture/OS name. - -To PORT to a new system, create the following subdirectories and -symbolic links. - - mkdir MACH (for example: mkdir sunos.4.0) - cd MACH - cp ../Makefile . - chmod 664 Makefile - ln -s ../clib . - mkdir include - ln -s include sys - cd include - ln -s ../../include/*.h . - rm compat.h - cp ../../include/compat.h . - chmod 664 compat.h - cd .. - -The basic idea is that you now have a local area that you can modify. -In particular, you have local copies of the Makefile and the include -file compat.h. Read through the Makefile and compat.h and make whatever -changes are appropriate to your system. If there's an architecture -that's close to yours, you probably should diff the Makefile and -compat.h in that tree against the standard ones and see what changes -were necessary, as they're probably necessary for you as well. Then, -enter "make" and see what happens! - -There are several subroutines that are found in POSIX 1003.2, ANSI -C, or 4.4BSD that you may not have. Once you get libdb.a to compile, -go through the list of undefined routines and add entries to the MISC -line in the Makefile as necessary. - -If you have to add some functions that are missing (and which aren't -in the PORT/clib directory), please don't add them in the PORT/clib -directory. Add them in a MACH/local directory, and add lines of the -form: - - function.o: local/function.o - ${CL} -Ilocal local/function.o - -to your local Makefile. - -Hopefully, over time, we'll develop a set of system directories that -are known to work. If you send me the changes that were necessary to -make your system work, this will happen much more quickly. - -In some of the system directories, you'll see a file named OTHER_PATCHES. -This is a set of patches which you'll have to make from the top-level db -directory to get libdb.a to run on this system: - - cd .. - patch < PORT/MACH/OTHER_PATCHES - -If patch prompts you for the name of the file to modify (some versions -of patch don't figure it out on their own) use the file name which patch -displays. - -Some knobs you may have to turn: - -In include/db.h: - Before attempting to build libdb, you should look through the - db.h file, and adjust it as necessary for your system. The - only adjustments that you should need to make are for the - fixed sized typedef's at the top of the file. Make sure they're - right for your system. - -In include/compat.h: - Before attempting to build libdb, you should look through the - compat.h file, and adjust it as necessary for your system. - It's possible to use the #ifndef construct to figure out if a - #ifdef has been set, but C provides no similar method to figure - out if a typedef has been done. Your compile errors should - give you a good indication of which ones you need. - -You may see warning messages about illegal pointer combinations. You may -also see lots of warning messages about #define's being redefined. These -can mostly be ignored. I usually ignore warning messages until something -doesn't work. Some systems produce thousands of lines of useless warnings, -bless their little hearts. - -The other parts of the PORT directory are as follows: - - The directory PORT/clib is a set of functions that the 4.4BSD - C library had and which your system may not have. They are - added to the MISC line of the Makefile if they aren't defined - when you try and load libdb.a. - - The directory PORT/include is header files that the 4.4BSD - system had which your system may not have. There is also - one really important extra one, named compat.h, which is a - set of compatibility work-arounds that you'll almost certainly - have to copy and modify for a new system. - - The symbolic link PORT/sys points to the PORT/include directory - so that includes of the form work. - -Some of the more common portability problems: - - If you don't have: - - memmove(3): add memmove.o - mkstemp(3): add mktemp.o - - ... to the MISC line in the Makefile. - - If you don't have snprintf/vsnprintf(3), add snprintf.o to the - MISC line in the Makefile. This workaround depends on your - system having vsprintf(3) -- if you don't, there's no workaround - other than changing the source code to not use the snprintf calls. - If you have to make that change, check to see if your vsprintf - returns a length or a char *; if it's the latter, make sure you - set VSPRINTF_CHARSTAR in the MACH/include/compat.h file. - -Installing the DB library: - - The Makefile builds a C library named libdb.a. This file needs - to be installed in a place where the loader will automatically - look for it (or, if you're building it for a single project, - wherever that project's Makefile loads it from). - - In addition, the header file PORT/include/db.h must be copied to - a directory (often /usr/include/) where programs that use the - db package can include it in their source. (If you intend to use - the ndbm interface to libdb, you'll need to copy the header file - PORT/include/ndbm.h as well.) diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile deleted file mode 100644 index 85b09a7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h deleted file mode 100644 index 2bd360a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/aix.3.2/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h deleted file mode 120000 index c626d51..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/compat.h +++ /dev/null @@ -1 +0,0 @@ -../../include/compat.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h deleted file mode 100644 index cae13f9..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/db.h +++ /dev/null @@ -1,222 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)db.h 8.6 (Berkeley) 6/16/94 - */ - -#ifndef _DB_H_ -#define _DB_H_ - -#include -#include - -#include - -#ifdef __DBINTERFACE_PRIVATE -#include -#endif - -#define RET_ERROR -1 /* Return values. */ -#define RET_SUCCESS 0 -#define RET_SPECIAL 1 - -#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ -typedef u_int32_t pgno_t; -#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ -typedef u_int16_t indx_t; -#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ -typedef u_int32_t recno_t; - -/* Key/data structure -- a Data-Base Thang. */ -typedef struct { - void *data; /* data */ - size_t size; /* data length */ -} DBT; - -/* Routine flags. */ -#define R_CURSOR 1 /* del, put, seq */ -#define __R_UNUSED 2 /* UNUSED */ -#define R_FIRST 3 /* seq */ -#define R_IAFTER 4 /* put (RECNO) */ -#define R_IBEFORE 5 /* put (RECNO) */ -#define R_LAST 6 /* seq (BTREE, RECNO) */ -#define R_NEXT 7 /* seq */ -#define R_NOOVERWRITE 8 /* put */ -#define R_PREV 9 /* seq (BTREE, RECNO) */ -#define R_SETCURSOR 10 /* put (RECNO) */ -#define R_RECNOSYNC 11 /* sync (RECNO) */ - -typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; - -/* - * !!! - * The following flags are included in the dbopen(3) call as part of the - * open(2) flags. In order to avoid conflicts with the open flags, start - * at the top of the 16 or 32-bit number space and work our way down. If - * the open flags were significantly expanded in the future, it could be - * a problem. Wish I'd left another flags word in the dbopen call. - * - * !!! - * None of this stuff is implemented yet. The only reason that it's here - * is so that the access methods can skip copying the key/data pair when - * the DB_LOCK flag isn't set. - */ -#if UINT_MAX > 65535 -#define DB_LOCK 0x20000000 /* Do locking. */ -#define DB_SHMEM 0x40000000 /* Use shared memory. */ -#define DB_TXN 0x80000000 /* Do transactions. */ -#else -#define DB_LOCK 0x2000 /* Do locking. */ -#define DB_SHMEM 0x4000 /* Use shared memory. */ -#define DB_TXN 0x8000 /* Do transactions. */ -#endif - -/* Access method description structure. */ -typedef struct __db { - DBTYPE type; /* Underlying db type. */ - int (*close) __P((struct __db *)); - int (*del) __P((const struct __db *, const DBT *, u_int)); - int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); - int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); - int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); - int (*sync) __P((const struct __db *, u_int)); - void *internal; /* Access method private. */ - int (*fd) __P((const struct __db *)); -} DB; - -#define BTREEMAGIC 0x053162 -#define BTREEVERSION 3 - -/* Structure used to pass parameters to the btree routines. */ -typedef struct { -#define R_DUP 0x01 /* duplicate keys */ - u_long flags; - u_int cachesize; /* bytes to cache */ - int maxkeypage; /* maximum keys per page */ - int minkeypage; /* minimum keys per page */ - u_int psize; /* page size */ - int (*compare) /* comparison function */ - __P((const DBT *, const DBT *)); - size_t (*prefix) /* prefix function */ - __P((const DBT *, const DBT *)); - int lorder; /* byte order */ -} BTREEINFO; - -#define HASHMAGIC 0x061561 -#define HASHVERSION 2 - -/* Structure used to pass parameters to the hashing routines. */ -typedef struct { - u_int bsize; /* bucket size */ - u_int ffactor; /* fill factor */ - u_int nelem; /* number of elements */ - u_int cachesize; /* bytes to cache */ - u_int32_t /* hash function */ - (*hash) __P((const void *, size_t)); - int lorder; /* byte order */ -} HASHINFO; - -/* Structure used to pass parameters to the record routines. */ -typedef struct { -#define R_FIXEDLEN 0x01 /* fixed-length records */ -#define R_NOKEY 0x02 /* key not required */ -#define R_SNAPSHOT 0x04 /* snapshot the input */ - u_long flags; - u_int cachesize; /* bytes to cache */ - u_int psize; /* page size */ - int lorder; /* byte order */ - size_t reclen; /* record length (fixed-length records) */ - u_char bval; /* delimiting byte (variable-length records */ - char *bfname; /* btree file name */ -} RECNOINFO; - -#ifdef __DBINTERFACE_PRIVATE -/* - * Little endian <==> big endian 32-bit swap macros. - * M_32_SWAP swap a memory location - * P_32_SWAP swap a referenced memory location - * P_32_COPY swap from one location to another - */ -#define M_32_SWAP(a) { \ - u_int32_t _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[3]; \ - ((char *)&a)[1] = ((char *)&_tmp)[2]; \ - ((char *)&a)[2] = ((char *)&_tmp)[1]; \ - ((char *)&a)[3] = ((char *)&_tmp)[0]; \ -} -#define P_32_SWAP(a) { \ - u_int32_t _tmp = *(u_int32_t *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[3]; \ - ((char *)a)[1] = ((char *)&_tmp)[2]; \ - ((char *)a)[2] = ((char *)&_tmp)[1]; \ - ((char *)a)[3] = ((char *)&_tmp)[0]; \ -} -#define P_32_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[3]; \ - ((char *)&(b))[1] = ((char *)&(a))[2]; \ - ((char *)&(b))[2] = ((char *)&(a))[1]; \ - ((char *)&(b))[3] = ((char *)&(a))[0]; \ -} - -/* - * Little endian <==> big endian 16-bit swap macros. - * M_16_SWAP swap a memory location - * P_16_SWAP swap a referenced memory location - * P_16_COPY swap from one location to another - */ -#define M_16_SWAP(a) { \ - u_int16_t _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[1]; \ - ((char *)&a)[1] = ((char *)&_tmp)[0]; \ -} -#define P_16_SWAP(a) { \ - u_int16_t _tmp = *(u_int16_t *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[1]; \ - ((char *)a)[1] = ((char *)&_tmp)[0]; \ -} -#define P_16_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[1]; \ - ((char *)&(b))[1] = ((char *)&(a))[0]; \ -} -#endif - -__BEGIN_DECLS -DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); - -#ifdef __DBINTERFACE_PRIVATE -DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); -DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); -DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); -void __dbpanic __P((DB *dbp)); -#endif -__END_DECLS -#endif /* !_DB_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsd.4.4/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES deleted file mode 100644 index 85027c9..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/OTHER_PATCHES +++ /dev/null @@ -1,19 +0,0 @@ -*** PORT/db/recno/rec_open.c.orig Mon Aug 16 16:29:18 1993 ---- PORT/db/recno/rec_open.c Mon Aug 16 16:29:35 1993 -*************** -*** 159,165 **** - else { - t->bt_msize = sb.st_size; - if ((t->bt_smap = mmap(NULL, t->bt_msize, -! PROT_READ, MAP_PRIVATE, rfd, - (off_t)0)) == (caddr_t)-1) - goto slow; - t->bt_cmap = t->bt_smap; ---- 159,165 ---- - else { - t->bt_msize = sb.st_size; - if ((t->bt_smap = mmap(NULL, t->bt_msize, -! PROT_READ, MAP_FILE | MAP_PRIVATE, rfd, - (off_t)0)) == (caddr_t)-1) - goto slow; - t->bt_cmap = t->bt_smap; diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h deleted file mode 100644 index f455fe8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/assert.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)assert.h 4.4 (Berkeley) 4/3/91 - */ - -#ifndef _ASSERT_H_ -#define _ASSERT_H_ - -#ifdef NDEBUG -#define assert(expression) -#define _assert(expression) -#else -#define assert(expression) { \ - if (!(expression)) { \ - (void)fprintf(stderr, \ - "assertion \"%s\" failed: file \"%s\", line %d\n", \ - "expression", __FILE__, __LINE__); \ - exit(2); \ - } \ -} -#define _assert(expression) assert(expression) -#endif - -#endif /* !_ASSERT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h deleted file mode 100644 index ae735ef..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h deleted file mode 100644 index 21966d7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/local.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)local.h 5.3 (Berkeley) 5/6/93 - */ - -/* - * Information local to this implementation of stdio, - * in particular, macros and private variables. - */ - -int __sflush __P((FILE *)); -FILE *__sfp __P((void)); -int __srefill __P((FILE *)); -int __sread __P((void *, char *, int)); -int __swrite __P((void *, char const *, int)); -fpos_t __sseek __P((void *, fpos_t, int)); -int __sclose __P((void *)); -void __sinit __P((void)); -void _cleanup __P((void)); -void (*__cleanup) __P((void)); -void __smakebuf __P((FILE *)); -int __swhatbuf __P((FILE *, size_t *, int *)); -int _fwalk __P((int (*)(FILE *))); -int __swsetup __P((FILE *)); -int __sflags __P((const char *, int *)); - -extern int __sdidinit; - -/* - * Return true iff the given FILE cannot be written now. - */ -#define cantwrite(fp) \ - ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ - __swsetup(fp)) - -/* - * Test whether the given stdio file has an active ungetc buffer; - * release such a buffer, without restoring ordinary unread data. - */ -#define HASUB(fp) ((fp)->_ub._base != NULL) -#define FREEUB(fp) { \ - if ((fp)->_ub._base != (fp)->_ubuf) \ - free((char *)(fp)->_ub._base); \ - (fp)->_ub._base = NULL; \ -} - -/* - * test for an fgetline() buffer. - */ -#define HASLB(fp) ((fp)->_lb._base != NULL) -#define FREELB(fp) { \ - free((char *)(fp)->_lb._base); \ - (fp)->_lb._base = NULL; \ -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c deleted file mode 100644 index cb87e60..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/makebuf.c +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)makebuf.c 5.3 (Berkeley) 5/6/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include "local.h" - -/* - * Allocate a file buffer, or switch to unbuffered I/O. - * Per the ANSI C standard, ALL tty devices default to line buffered. - * - * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek - * optimisation) right after the fstat() that finds the buffer size. - */ -void -__smakebuf(fp) - register FILE *fp; -{ - register void *p; - register int flags; - size_t size; - int couldbetty; - - if (fp->_flags & __SNBF) { - fp->_bf._base = fp->_p = fp->_nbuf; - fp->_bf._size = 1; - return; - } - flags = __swhatbuf(fp, &size, &couldbetty); - if ((p = malloc(size)) == NULL) { - fp->_flags |= __SNBF; - fp->_bf._base = fp->_p = fp->_nbuf; - fp->_bf._size = 1; - return; - } - __cleanup = _cleanup; - flags |= __SMBF; - fp->_bf._base = fp->_p = p; - fp->_bf._size = size; - if (couldbetty && isatty(fp->_file)) - flags |= __SLBF; - fp->_flags |= flags; -} - -/* - * Internal routine to determine `proper' buffering for a file. - */ -int -__swhatbuf(fp, bufsize, couldbetty) - register FILE *fp; - size_t *bufsize; - int *couldbetty; -{ - struct stat st; - - if (fp->_file < 0 || fstat(fp->_file, &st) < 0) { - *couldbetty = 0; - *bufsize = BUFSIZ; - return (__SNPT); - } - - /* could be a tty iff it is a character device */ - *couldbetty = (st.st_mode & S_IFMT) == S_IFCHR; - if (st.st_blksize <= 0) { - *bufsize = BUFSIZ; - return (__SNPT); - } - - /* - * Optimise fseek() only if it is a regular file. (The test for - * __sseek is mainly paranoia.) It is safe to set _blksize - * unconditionally; it will only be used if __SOPT is also set. - */ - *bufsize = st.st_blksize; - fp->_blksize = st.st_blksize; - return ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ? - __SOPT : __SNPT); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c deleted file mode 100644 index 41bb16b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/local/setvbuf.c +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -! static char sccsid[] = "@(#)setvbuf.c 5.5 (Berkeley) 5/6/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include "local.h" - -/* - * Set one of the three kinds of buffering, optionally including - * a buffer. - */ -setvbuf(fp, buf, mode, size) - register FILE *fp; - char *buf; - register int mode; - register size_t size; -{ - register int ret, flags; - size_t iosize; - int ttyflag; - - /* - * Verify arguments. The `int' limit on `size' is due to this - * particular implementation. Note, buf and size are ignored - * when setting _IONBF. - */ - if (mode != _IONBF) - if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0) - return (EOF); - - /* - * Write current buffer, if any. Discard unread input, cancel - * line buffering, and free old buffer if malloc()ed. - */ - ret = 0; - (void)__sflush(fp); - fp->_r = fp->_lbfsize = 0; - flags = fp->_flags; - if (flags & __SMBF) - free((void *)fp->_bf._base); - flags &= ~(__SLBF | __SNBF | __SMBF | __SOPT | __SNPT); - - /* If setting unbuffered mode, skip all the hard work. */ - if (mode == _IONBF) - goto nbf; - - /* - * Find optimal I/O size for seek optimization. This also returns - * a `tty flag' to suggest that we check isatty(fd), but we do not - * care since our caller told us how to buffer. - */ - flags |= __swhatbuf(fp, &iosize, &ttyflag); - if (size == 0) { - buf = NULL; /* force local allocation */ - size = iosize; - } - - /* Allocate buffer if needed. */ - if (buf == NULL) { - if ((buf = malloc(size)) == NULL) { - /* - * Unable to honor user's request. We will return - * failure, but try again with file system size. - */ - ret = EOF; - if (size != iosize) { - size = iosize; - buf = malloc(size); - } - } - if (buf == NULL) { - /* No luck; switch to unbuffered I/O. */ -nbf: - fp->_flags = flags | __SNBF; - fp->_w = 0; - fp->_bf._base = fp->_p = fp->_nbuf; - fp->_bf._size = 1; - return (ret); - } - flags |= __SMBF; - } - - /* - * Kill any seek optimization if the buffer is not the - * right size. - * - * SHOULD WE ALLOW MULTIPLES HERE (i.e., ok iff (size % iosize) == 0)? - */ - if (size != iosize) - flags |= __SNPT; - - /* - * Fix up the FILE fields, and set __cleanup for output flush on - * exit (since we are buffered in some way). If in r/w mode, go - * to the intermediate state, so that everyone has to call - * __srefill or __swsetup on the first operation -- it is more - * trouble than it is worth to set things up correctly here. - */ - if (mode == _IOLBF) - flags |= __SLBF; - if (flags & __SRW) - flags &= ~(__SRD | __SWR); - fp->_w = 0; - fp->_flags = flags; - fp->_bf._base = fp->_p = (unsigned char *)buf; - fp->_bf._size = size; - fp->_lbfsize = 0; - __cleanup = _cleanup; - - return (ret); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/bsdi.1.0/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c deleted file mode 100644 index f90b09c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/memmove.c +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef int word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -/* - * Copy a block of memory, handling overlap. - * This is the routine that actually implements - * (the portable versions of) bcopy, memcpy, and memmove. - */ -#ifdef MEMCOPY -void * -memcpy(dst0, src0, length) -#else -#ifdef MEMMOVE -void * -memmove(dst0, src0, length) -#else -void -bcopy(src0, dst0, length) -#endif -#endif - void *dst0; - const void *src0; - register size_t length; -{ - register char *dst = dst0; - register const char *src = src0; - register size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - if ((unsigned long)dst < (unsigned long)src) { - /* - * Copy forward. - */ - t = (int)src; /* only need low bits */ - if ((t | (int)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (int)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (int)src; - if ((t | (int)dst) & wmask) { - if ((t ^ (int)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: -#if defined(MEMCOPY) || defined(MEMMOVE) - return (dst0); -#else - return; -#endif -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c deleted file mode 100644 index 6cedd6a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/mktemp.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -static int _gettemp(); - -mkstemp(path) - char *path; -{ - int fd; - - return (_gettemp(path, &fd) ? fd : -1); -} - -char * -mktemp(path) - char *path; -{ - return(_gettemp(path, (int *)NULL) ? path : (char *)NULL); -} - -static -_gettemp(path, doopen) - char *path; - register int *doopen; -{ - extern int errno; - register char *start, *trv; - struct stat sbuf; - u_int pid; - - pid = getpid(); - for (trv = path; *trv; ++trv); /* extra X's get set to 0's */ - while (*--trv == 'X') { - *trv = (pid % 10) + '0'; - pid /= 10; - } - - /* - * check the target directory; if you have six X's and it - * doesn't exist this runs for a *very* long time. - */ - for (start = trv + 1;; --trv) { - if (trv <= path) - break; - if (*trv == '/') { - *trv = '\0'; - if (stat(path, &sbuf)) - return(0); - if (!S_ISDIR(sbuf.st_mode)) { - errno = ENOTDIR; - return(0); - } - *trv = '/'; - break; - } - } - - for (;;) { - if (doopen) { - if ((*doopen = - open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) - return(1); - if (errno != EEXIST) - return(0); - } - else if (stat(path, &sbuf)) - return(errno == ENOENT ? 1 : 0); - - /* tricky little algorithm for backward compatibility */ - for (trv = start;;) { - if (!*trv) - return(0); - if (*trv == 'z') - *trv++ = 'a'; - else { - if (isdigit(*trv)) - *trv = 'a'; - else - ++*trv; - break; - } - } - } - /*NOTREACHED*/ -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c deleted file mode 100644 index 2863fa2..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/snprintf.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -#include - -#ifdef __STDC__ -#include -#else -#include -#endif - -int -#ifdef __STDC__ -snprintf(char *str, size_t n, const char *fmt, ...) -#else -snprintf(str, n, fmt, va_alist) - char *str; - size_t n; - const char *fmt; - va_dcl -#endif -{ - va_list ap; - char *rp; - int rval; -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif -#ifdef VSPRINTF_CHARSTAR - rp = vsprintf(str, fmt, ap); - va_end(ap); - return (strlen(rp)); -#else - rval = vsprintf(str, fmt, ap); - va_end(ap); - return (rval); -#endif -} - -int -vsnprintf(str, n, fmt, ap) - char *str; - size_t n; - const char *fmt; - va_list ap; -{ -#ifdef VSPRINTF_CHARSTAR - return (strlen(vsprintf(str, fmt, ap))); -#else - return (vsprintf(str, fmt, ap)); -#endif -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c b/user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c deleted file mode 100644 index 53f374b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/clib/strerror.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -char * -strerror(num) - int num; -{ - extern int sys_nerr; - extern char *sys_errlist[]; -#define UPREFIX "Unknown error: " - static char ebuf[40] = UPREFIX; /* 64-bit number + slop */ - register unsigned int errnum; - register char *p, *t; - char tmp[40]; - - errnum = num; /* convert to unsigned */ - if (errnum < sys_nerr) - return(sys_errlist[errnum]); - - /* Do this by hand, so we don't include stdio(3). */ - t = tmp; - do { - *t++ = "0123456789"[errnum % 10]; - } while (errnum /= 10); - for (p = ebuf + sizeof(UPREFIX) - 1;;) { - *p++ = *--t; - if (t <= tmp) - break; - } - return(ebuf); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile deleted file mode 100644 index 4053c4b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -CC= gcc -OORG= -O2 -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h deleted file mode 100644 index 2bd360a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/dgux.5.4/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 deleted file mode 120000 index e634b1f..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.8.07 +++ /dev/null @@ -1 +0,0 @@ -hpux.9.01 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile deleted file mode 100644 index 85b09a7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h deleted file mode 100644 index 2bd360a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c deleted file mode 100644 index e65083b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/local/hp_siglist.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Derived from: - * static char sccsid[] = "@(#)siglist.c 8.1 (Berkeley) 6/4/93"; - */ -#include - -#include - -const char *const sys_signame[NSIG] = { - "Signal 0", - "hup", /* SIGHUP */ - "int", /* SIGINT */ - "quit", /* SIGQUIT */ - "ill", /* SIGILL */ - "trap", /* SIGTRAP */ - "abrt", /* SIGABRT */ - "emt", /* SIGEMT */ - "fpe", /* SIGFPE */ - "kill", /* SIGKILL */ - "bus", /* SIGBUS */ - "segv", /* SIGSEGV */ - "sys", /* SIGSYS */ - "pipe", /* SIGPIPE */ - "alrm", /* SIGALRM */ - "term", /* SIGTERM */ - "usr1", /* SIGUSR1 */ - "usr2", /* SIGUSR2 */ - "chld", /* SIGCHLD */ - "pwr", /* SIGPWR */ - "vtalrm", /* SIGVTALRM */ - "prof", /* SIGPROF */ - "io", /* SIGIO */ - "winch", /* SIGWINCH */ - "stop", /* SIGSTOP */ - "tstp", /* SIGTSTP */ - "cont", /* SIGCONT */ - "ttin", /* SIGTTIN */ - "ttou", /* SIGTTOU */ - "urg", /* SIGURG */ - "lost", /* SIGLOST */ -}; - -const char *const sys_siglist[NSIG] = { - "Signal 0", - "Hangup", /* SIGHUP */ - "Interrupt", /* SIGINT */ - "Quit", /* SIGQUIT */ - "Illegal instruction", /* SIGILL */ - "Trace/BPT trap", /* SIGTRAP */ - "Abort trap", /* SIGABRT */ - "EMT trap", /* SIGEMT */ - "Floating point exception", /* SIGFPE */ - "Killed", /* SIGKILL */ - "Bus error", /* SIGBUS */ - "Segmentation fault", /* SIGSEGV */ - "Bad system call", /* SIGSYS */ - "Broken pipe", /* SIGPIPE */ - "Alarm clock", /* SIGALRM */ - "Terminated", /* SIGTERM */ - "User defined signal 1", /* SIGUSR1 */ - "User defined signal 2" /* SIGUSR2 */ - "Child exited", /* SIGCHLD */ - "Power failure", /* SIGPWR */ - "Virtual timer expired", /* SIGVTALRM */ - "Profiling timer expired", /* SIGPROF */ - "I/O possible", /* SIGIO */ - "Window size changes", /* SIGWINCH */ - "Suspended (signal)", /* SIGSTOP */ - "Suspended", /* SIGTSTP */ - "Continued", /* SIGCONT */ - "Stopped (tty input)", /* SIGTTIN */ - "Stopped (tty output)", /* SIGTTOU */ - "Urgent I/O condition", /* SIGURG */ - "File lock lost", /* SIGLOST */ -}; diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/hpux.9.01/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h deleted file mode 120000 index f28ad5d..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/bsd-queue.h +++ /dev/null @@ -1 +0,0 @@ -queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h deleted file mode 100644 index c104b9e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/cdefs.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Berkeley Software Design, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)cdefs.h 8.7 (Berkeley) 1/21/94 - */ - -#ifndef _CDEFS_H_ -#define _CDEFS_H_ - -#if defined(__cplusplus) -#define __BEGIN_DECLS extern "C" { -#define __END_DECLS }; -#else -#define __BEGIN_DECLS -#define __END_DECLS -#endif - -/* - * The __CONCAT macro is used to concatenate parts of symbol names, e.g. - * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. - * The __CONCAT macro is a bit tricky -- make sure you don't put spaces - * in between its arguments. __CONCAT can also concatenate double-quoted - * strings produced by the __STRING macro, but this only works with ANSI C. - */ -#if defined(__STDC__) || defined(__cplusplus) -#define __P(protos) protos /* full-blown ANSI C */ -#define __CONCAT(x,y) x ## y -#define __STRING(x) #x - -#define __const const /* define reserved names to standard */ -#define __signed signed -#define __volatile volatile -#if defined(__cplusplus) -#define __inline inline /* convert to C++ keyword */ -#else -#ifndef __GNUC__ -#define __inline /* delete GCC keyword */ -#endif /* !__GNUC__ */ -#endif /* !__cplusplus */ - -#else /* !(__STDC__ || __cplusplus) */ -#define __P(protos) () /* traditional C preprocessor */ -#define __CONCAT(x,y) x/**/y -#define __STRING(x) "x" - -#ifndef __GNUC__ -#define __const /* delete pseudo-ANSI C keywords */ -#define __inline -#define __signed -#define __volatile -/* - * In non-ANSI C environments, new programs will want ANSI-only C keywords - * deleted from the program and old programs will want them left alone. - * When using a compiler other than gcc, programs using the ANSI C keywords - * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. - * When using "gcc -traditional", we assume that this is the intent; if - * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. - */ -#ifndef NO_ANSI_KEYWORDS -#define const /* delete ANSI C keywords */ -#define inline -#define signed -#define volatile -#endif -#endif /* !__GNUC__ */ -#endif /* !(__STDC__ || __cplusplus) */ - -/* - * GCC1 and some versions of GCC2 declare dead (non-returning) and - * pure (no side effects) functions using "volatile" and "const"; - * unfortunately, these then cause warnings under "-ansi -pedantic". - * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of - * these work for GNU C++ (modulo a slight glitch in the C++ grammar - * in the distribution version of 2.5.5). - */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 -#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#define __dead __volatile -#define __pure __const -#endif -#endif - -/* Delete pseudo-keywords wherever they are not available or needed. */ -#ifndef __dead -#define __dead -#define __pure -#endif - -#endif /* !_CDEFS_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h deleted file mode 100644 index 30cf88d..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/compat.h +++ /dev/null @@ -1,233 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#ifndef memmove -#define memmove(a, b, n) bcopy(b, a, n) -#endif -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h deleted file mode 120000 index 25306d1..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/filevtable.h +++ /dev/null @@ -1 +0,0 @@ -../../include/filevtable.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h deleted file mode 100644 index a545bca..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/ndbm.h +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _NDBM_H_ -#define _NDBM_H_ - -#include - -/* Map dbm interface onto db(3). */ -#define DBM_RDONLY O_RDONLY - -/* Flags to dbm_store(). */ -#define DBM_INSERT 0 -#define DBM_REPLACE 1 - -/* - * The db(3) support for ndbm(3) always appends this suffix to the - * file name to avoid overwriting the user's original database. - */ -#define DBM_SUFFIX ".db" - -typedef struct { - char *dptr; - int dsize; -} datum; - -typedef DB DBM; -#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE - -__BEGIN_DECLS -void dbm_close __P((DBM *)); -int dbm_delete __P((DBM *, datum)); -datum dbm_fetch __P((DBM *, datum)); -datum dbm_firstkey __P((DBM *)); -long dbm_forder __P((DBM *, datum)); -datum dbm_nextkey __P((DBM *)); -DBM *dbm_open __P((const char *, int, int)); -int dbm_store __P((DBM *, datum, datum, int)); -int dbm_dirfno __P((DBM *)); -__END_DECLS - -#endif /* !_NDBM_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h deleted file mode 100644 index 40d32cc..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/include/queue.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.3 (Berkeley) 12/13/93 - */ - -#ifndef _QUEUE_H_ -#define _QUEUE_H_ - -/* - * This file defines three types of data structures: lists, tail queues, - * and circular queues. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list after - * an existing element or at the head of the list. A list may only be - * traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A tail queue may only be traversed in the forward direction. - * - * A circle queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or after - * an existing element, at the head of the list, or at the end of the list. - * A circle queue may be traversed in either direction, but has a more - * complex end of list detection. - * - * For details on the use of these macros, see the queue(3) manual page. - */ - -/* - * List definitions. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ -#define LIST_INIT(head) { \ - (head)->lh_first = NULL; \ -} - -#define LIST_INSERT_AFTER(listelm, elm, field) { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} - -#define LIST_INSERT_HEAD(head, elm, field) { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} - -#define LIST_REMOVE(elm, field) { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} - -/* - * Tail queue definitions. - */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ -} - -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ -} - -/* - * Tail queue functions. - */ -#define TAILQ_INIT(head) { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} - -#define TAILQ_INSERT_HEAD(head, elm, field) { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} - -#define TAILQ_INSERT_TAIL(head, elm, field) { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} - -#define TAILQ_REMOVE(head, elm, field) { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} - -/* - * Circular queue definitions. - */ -#define CIRCLEQ_HEAD(name, type) \ -struct name { \ - struct type *cqh_first; /* first element */ \ - struct type *cqh_last; /* last element */ \ -} - -#define CIRCLEQ_ENTRY(type) \ -struct { \ - struct type *cqe_next; /* next element */ \ - struct type *cqe_prev; /* previous element */ \ -} - -/* - * Circular queue functions. - */ -#define CIRCLEQ_INIT(head) { \ - (head)->cqh_first = (void *)(head); \ - (head)->cqh_last = (void *)(head); \ -} - -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \ - (elm)->field.cqe_next = (listelm)->field.cqe_next; \ - (elm)->field.cqe_prev = (listelm); \ - if ((listelm)->field.cqe_next == (void *)(head)) \ - (head)->cqh_last = (elm); \ - else \ - (listelm)->field.cqe_next->field.cqe_prev = (elm); \ - (listelm)->field.cqe_next = (elm); \ -} - -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \ - (elm)->field.cqe_next = (listelm); \ - (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ - if ((listelm)->field.cqe_prev == (void *)(head)) \ - (head)->cqh_first = (elm); \ - else \ - (listelm)->field.cqe_prev->field.cqe_next = (elm); \ - (listelm)->field.cqe_prev = (elm); \ -} - -#define CIRCLEQ_INSERT_HEAD(head, elm, field) { \ - (elm)->field.cqe_next = (head)->cqh_first; \ - (elm)->field.cqe_prev = (void *)(head); \ - if ((head)->cqh_last == (void *)(head)) \ - (head)->cqh_last = (elm); \ - else \ - (head)->cqh_first->field.cqe_prev = (elm); \ - (head)->cqh_first = (elm); \ -} - -#define CIRCLEQ_INSERT_TAIL(head, elm, field) { \ - (elm)->field.cqe_next = (void *)(head); \ - (elm)->field.cqe_prev = (head)->cqh_last; \ - if ((head)->cqh_first == (void *)(head)) \ - (head)->cqh_first = (elm); \ - else \ - (head)->cqh_last->field.cqe_next = (elm); \ - (head)->cqh_last = (elm); \ -} - -#define CIRCLEQ_REMOVE(head, elm, field) { \ - if ((elm)->field.cqe_next == (void *)(head)) \ - (head)->cqh_last = (elm)->field.cqe_prev; \ - else \ - (elm)->field.cqe_next->field.cqe_prev = \ - (elm)->field.cqe_prev; \ - if ((elm)->field.cqe_prev == (void *)(head)) \ - (head)->cqh_first = (elm)->field.cqe_next; \ - else \ - (elm)->field.cqe_prev->field.cqe_next = \ - (elm)->field.cqe_next; \ -} -#endif /* !_QUEUE_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile deleted file mode 100644 index 1775095..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -CC= cc -cckr -D_BSD_COMPAT -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES deleted file mode 100644 index 46c624b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/OTHER_PATCHES +++ /dev/null @@ -1,32 +0,0 @@ -*** PORT/db/btree/bt_open.c.dist Thu Sep 16 14:42:22 1993 ---- PORT/db/btree/bt_open.c Mon Nov 8 07:03:40 1993 -*************** -*** 256,262 **** ---- 256,266 ---- - * Don't overflow the page offset type. - */ - if (b.psize == 0) { -+ #ifndef sgi - b.psize = sb.st_blksize; -+ #else -+ b.psize = 4096; -+ #endif /* sgi */ - if (b.psize < MINPSIZE) - b.psize = MINPSIZE; - if (b.psize > MAX_PAGE_OFFSET + 1) -*** PORT/db/hash/hash.c.dist Thu Nov 4 15:32:16 1993 ---- PORT/db/hash/hash.c Mon Nov 8 07:05:12 1993 -*************** -*** 301,307 **** ---- 301,311 ---- - if (file != NULL) { - if (stat(file, &statbuf)) - return (NULL); -+ #ifndef sgi - hashp->BSIZE = statbuf.st_blksize; -+ #else -+ hashp->BSIZE = 4096; -+ #endif /* sgi */ - hashp->BSHIFT = __log2(hashp->BSIZE); - } - diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h deleted file mode 100644 index 2bd360a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/irix.4.05F/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile deleted file mode 100644 index 85b09a7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES deleted file mode 100644 index b0387a5..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/OTHER_PATCHES +++ /dev/null @@ -1,29 +0,0 @@ -*** PORT/db/recno/rec_open.c.orig 1993/10/13 02:01:31 ---- PORT/db/recno/rec_open.c 1993/10/13 02:20:47 -*************** -*** 159,167 **** ---- 159,182 ---- - SET(t, R_EOF); - else { - t->bt_msize = sb.st_size; -+ /* -+ * hack : -+ * -+ * The Linux kernel mmap() semantics are broken : -+ * -+ * Under Linux, read only private mappings cause write only and read/write -+ * opens to fail with errno=ETXTBSY. Shared read only mappings should work -+ * fine though, but I'm not familiar enough with the code to ascertain that -+ * a MAP_SHARED mapping would be safe so I use the non-mmap'd version -+ * instead. -+ * -+ */ -+ -+ #if !defined(linux) - if ((t->bt_smap = mmap(NULL, t->bt_msize, - PROT_READ, MAP_PRIVATE, rfd, - (off_t)0)) == (caddr_t)-1) -+ #endif - goto slow; - t->bt_cmap = t->bt_smap; - t->bt_emap = t->bt_smap + sb.st_size; diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h deleted file mode 100644 index ae735ef..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/linux/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile deleted file mode 100644 index 85b09a7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h deleted file mode 100644 index ae735ef..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.0.2/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 deleted file mode 120000 index 1a1d658..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.1.3 +++ /dev/null @@ -1 +0,0 @@ -osf.1.0.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 b/user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 deleted file mode 120000 index 1a1d658..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/osf.2.0 +++ /dev/null @@ -1 +0,0 @@ -osf.1.0.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile deleted file mode 100644 index e852b76..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/Makefile +++ /dev/null @@ -1,104 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= mktemp.o snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -CC= gcc -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude \ - -DMMAP_NOT_AVAILABLE -DSTBLKSIZE_NOT_AVAILABLE -DSYS5 - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES deleted file mode 100644 index 891cccb..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/OTHER_PATCHES +++ /dev/null @@ -1,95 +0,0 @@ -*** PORT/db/btree/bt_open.c.orig 1993/11/24 11:16:51 ---- PORT/db/btree/bt_open.c 1993/11/24 12:38:12 -*************** -*** 256,262 **** ---- 256,266 ---- - * Don't overflow the page offset type. - */ - if (b.psize == 0) { -+ #ifdef STBLKSIZE_NOT_AVAILABLE -+ b.psize = 4096; -+ #else - b.psize = sb.st_blksize; -+ #endif - if (b.psize < MINPSIZE) - b.psize = MINPSIZE; - if (b.psize > MAX_PAGE_OFFSET + 1) -*** PORT/db/recno/rec_open.c.orig 1993/11/29 18:26:26 ---- PORT/db/recno/rec_open.c 1993/11/30 11:35:21 -*************** -*** 159,164 **** ---- 159,167 ---- - SET(t, R_EOF); - else { - t->bt_msize = sb.st_size; -+ #ifdef MMAP_NOT_AVAILABLE -+ goto slow; -+ #else - if ((t->bt_smap = mmap(NULL, t->bt_msize, - PROT_READ, MAP_PRIVATE, rfd, - (off_t)0)) == (caddr_t)-1) -*************** -*** 168,173 **** ---- 171,177 ---- - t->bt_irec = ISSET(t, R_FIXLEN) ? - __rec_fmap : __rec_vmap; - SET(t, R_MEMMAPPED); -+ #endif - } - } - } -*** PORT/db/hash/hash_log2.c.orig 1993/11/24 11:10:40 ---- PORT/db/hash/hash_log2.c 1993/11/24 12:38:52 -*************** -*** 40,50 **** - - #include - -! u_int - __log2(num) -! u_int num; - { -! register u_int i, limit; - - limit = 1; - for (i = 0; limit < num; limit = limit << 1, i++); ---- 40,50 ---- - - #include - -! unsigned int - __log2(num) -! unsigned int num; - { -! register unsigned int i, limit; - - limit = 1; - for (i = 0; limit < num; limit = limit << 1, i++); -*** PORT/db/hash/hash.c.orig 1993/11/24 11:18:44 ---- PORT/db/hash/hash.c 1993/11/24 12:38:29 -*************** -*** 301,307 **** ---- 301,311 ---- - if (file != NULL) { - if (stat(file, &statbuf)) - return (NULL); -+ #ifdef STBLKSIZE_NOT_AVAILABLE -+ hashp->BSIZE = 4096; -+ #else - hashp->BSIZE = statbuf.st_blksize; -+ #endif - hashp->BSHIFT = __log2(hashp->BSIZE); - } - -*** PORT/db/hash/hash.h.orig 1993/11/24 11:20:03 ---- PORT/db/hash/hash.h 1993/11/24 12:38:38 -*************** -*** 261,266 **** ---- 261,267 ---- - #define REAL_KEY 4 - - /* Short hands for accessing structure */ -+ #undef BSIZE - #define BSIZE hdr.bsize - #define BSHIFT hdr.bshift - #define DSIZE hdr.dsize diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h deleted file mode 100644 index 108060d..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/compat.h +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include -#include /* For fd_set. */ - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 1 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h deleted file mode 100644 index 81b9f32..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/pathnames.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.5 (Berkeley) 12/21/93 - */ - -#define _PATH_BSHELL "/bin/sh" -#define _PATH_DEVNULL "/dev/null" -#define _PATH_EXRC ".exrc" -#define _PATH_NEXRC ".nexrc" -#define _PATH_PRESERVE "/usr/tmp/vi.recover" -#define _PATH_SENDMAIL "/usr/lib/sendmail" -#define _PATH_SYSEXRC "/etc/vi.exrc" -#define _PATH_TAGS "tags" -#define _PATH_TMP "/tmp" -#define _PATH_TTY "/dev/tty" diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ptx.2.0/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile deleted file mode 100644 index dd459ad..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= mktemp.o snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h deleted file mode 100644 index 2bd360a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sinix.5.41/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 b/user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 deleted file mode 120000 index b9f1ef8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/solaris.2.2 +++ /dev/null @@ -1 +0,0 @@ -sunos.5.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile deleted file mode 100644 index aae1a45..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= memmove.o snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h deleted file mode 100644 index 62643bd..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 1 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 1 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h deleted file mode 100644 index df94cd0..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/pathnames.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.5 (Berkeley) 12/21/93 - */ - -#define _PATH_BSHELL "/bin/sh" -#define _PATH_DEVNULL "/dev/null" -#define _PATH_EXRC ".exrc" -#define _PATH_NEXRC ".nexrc" -#define _PATH_PRESERVE "/var/tmp/vi.recover" -#define _PATH_SENDMAIL "/usr/lib/sendmail" -#define _PATH_SYSEXRC "/etc/vi.exrc" -#define _PATH_TAGS "tags /var/db/libc.tags /sys/kern/tags" -#define _PATH_TMP "/tmp" -#define _PATH_TTY "/dev/tty" diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.1/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 deleted file mode 120000 index cf2aa36..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.2 +++ /dev/null @@ -1 +0,0 @@ -sunos.4.1.1 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 deleted file mode 120000 index cf2aa36..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.4.1.3 +++ /dev/null @@ -1 +0,0 @@ -sunos.4.1.1 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile deleted file mode 100644 index 85b09a7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h deleted file mode 100644 index b302f19..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/compat.h +++ /dev/null @@ -1,236 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -#define NO_ERRLIST - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 0 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - - -#define write _write - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h deleted file mode 120000 index 44c1ba4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/db.h +++ /dev/null @@ -1 +0,0 @@ -../../include/db.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/sunos.5.2/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile deleted file mode 100644 index dd459ad..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# @(#)Makefile 8.9 (Berkeley) 7/14/94 - -LIBDB= libdb.a -OBJ1= hash.o hash_bigkey.o hash_buf.o hash_func.o hash_log2.o hash_page.o \ - hsearch.o ndbm.o -OBJ2= bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \ - bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o bt_split.o \ - bt_utils.o -OBJ3= db.o -OBJ4= mpool.o -OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \ - rec_seq.o rec_utils.o - -MISC= mktemp.o snprintf.o - -${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - rm -f $@ - ar cq $@ \ - `lorder ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} | tsort` - ranlib $@ - -clean: - rm -f ${LIBDB} ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC} - -OORG= -O -CL= ${CC} -c -D__DBINTERFACE_PRIVATE ${OORG} -I. -Iinclude - -hash.o: ../../hash/hash.c - ${CL} -I../../hash ../../hash/hash.c -hash_bigkey.o: ../../hash/hash_bigkey.c - ${CL} -I../../hash ../../hash/hash_bigkey.c -hash_buf.o: ../../hash/hash_buf.c - ${CL} -I../../hash ../../hash/hash_buf.c -hash_func.o: ../../hash/hash_func.c - ${CL} -I../../hash ../../hash/hash_func.c -hash_log2.o: ../../hash/hash_log2.c - ${CL} -I../../hash ../../hash/hash_log2.c -hash_page.o: ../../hash/hash_page.c - ${CL} -I../../hash ../../hash/hash_page.c -hsearch.o: ../../hash/hsearch.c - ${CL} -I../../hash ../../hash/hsearch.c -ndbm.o: ../../hash/ndbm.c - ${CL} -I../../hash ../../hash/ndbm.c - -bt_close.o: ../../btree/bt_close.c - ${CL} -I../../btree ../../btree/bt_close.c -bt_conv.o: ../../btree/bt_conv.c - ${CL} -I../../btree ../../btree/bt_conv.c -bt_debug.o: ../../btree/bt_debug.c - ${CL} -I../../btree ../../btree/bt_debug.c -bt_delete.o: ../../btree/bt_delete.c - ${CL} -I../../btree ../../btree/bt_delete.c -bt_get.o: ../../btree/bt_get.c - ${CL} -I../../btree ../../btree/bt_get.c -bt_open.o: ../../btree/bt_open.c - ${CL} -I../../btree ../../btree/bt_open.c -bt_overflow.o: ../../btree/bt_overflow.c - ${CL} -I../../btree ../../btree/bt_overflow.c -bt_page.o: ../../btree/bt_page.c - ${CL} -I../../btree ../../btree/bt_page.c -bt_put.o: ../../btree/bt_put.c - ${CL} -I../../btree ../../btree/bt_put.c -bt_search.o: ../../btree/bt_search.c - ${CL} -I../../btree ../../btree/bt_search.c -bt_seq.o: ../../btree/bt_seq.c - ${CL} -I../../btree ../../btree/bt_seq.c -bt_split.o: ../../btree/bt_split.c - ${CL} -I../../btree ../../btree/bt_split.c -bt_stack.o: ../../btree/bt_stack.c - ${CL} -I../../btree ../../btree/bt_stack.c -bt_utils.o: ../../btree/bt_utils.c - ${CL} -I../../btree ../../btree/bt_utils.c - -db.o: ../../db/db.c - ${CL} ../../db/db.c - -mpool.o: ../../mpool/mpool.c - ${CL} -I../../mpool ../../mpool/mpool.c - -rec_close.o: ../../recno/rec_close.c - ${CL} -I../../recno ../../recno/rec_close.c -rec_delete.o: ../../recno/rec_delete.c - ${CL} -I../../recno ../../recno/rec_delete.c -rec_get.o: ../../recno/rec_get.c - ${CL} -I../../recno ../../recno/rec_get.c -rec_open.o: ../../recno/rec_open.c - ${CL} -I../../recno ../../recno/rec_open.c -rec_put.o: ../../recno/rec_put.c - ${CL} -I../../recno ../../recno/rec_put.c -rec_search.o: ../../recno/rec_search.c - ${CL} -I../../recno ../../recno/rec_search.c -rec_seq.o: ../../recno/rec_seq.c - ${CL} -I../../recno ../../recno/rec_seq.c -rec_utils.o: ../../recno/rec_utils.c - ${CL} -I../../recno ../../recno/rec_utils.c - -memmove.o: - ${CC} -DMEMMOVE -c -O -I. -Iinclude clib/memmove.c -mktemp.o: - ${CC} -c -O -I. -Iinclude clib/mktemp.c -snprintf.o: - ${CC} -c -O -I. -Iinclude clib/snprintf.c diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib deleted file mode 120000 index f0f4f38..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/clib +++ /dev/null @@ -1 +0,0 @@ -../clib \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h deleted file mode 120000 index d248490..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/cdefs.h +++ /dev/null @@ -1 +0,0 @@ -../../include/cdefs.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h deleted file mode 100644 index 46a2964..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)compat.h 8.13 (Berkeley) 2/21/94 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned char u_char; /* 4.[34]BSD names. */ -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short u_short; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ -#endif - -/* If your system doesn't typedef ssize_t, change the 0 to a 1. */ -#if 1 -typedef int ssize_t; /* POSIX names. */ -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 /* POSIX 1003.1 signal mask type. */ -typedef unsigned int sigset_t; -#endif - -/* - * If your system's vsprintf returns a char *, not an int, - * change the 0 to a 1. - */ -#if 0 -#define VSPRINTF_CHARSTAR -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ -#endif - -#if defined(SYSV) || defined(SYSTEM5) -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK /* 4.4BSD extension. */ -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK /* 4.4BSD extension. */ -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ -#define _POSIX_VDISABLE 0 /* Some systems used 0. */ -#endif - -#ifndef TCSASOFT /* 4.4BSD extension. */ -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#ifndef MAX /* Usually found in . */ -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN /* Usually found in . */ -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Default file permissions. */ -#ifndef DEFFILEMODE /* 4.4BSD extension. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ -#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ -#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ -#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ -#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ -#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ -#endif -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ -#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ -#endif - -/* The type of a va_list. */ -#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h deleted file mode 100644 index 55f8c57..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/db.h +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)db.h 8.7 (Berkeley) 6/16/94 - */ - -#ifndef _DB_H_ -#define _DB_H_ - -#include -#include - -#include - -#ifdef __DBINTERFACE_PRIVATE -#include -#endif - -#define RET_ERROR -1 /* Return values. */ -#define RET_SUCCESS 0 -#define RET_SPECIAL 1 - -#ifndef __BIT_TYPES_DEFINED__ -#define __BIT_TYPES_DEFINED__ -typedef __signed char int8_t; -typedef unsigned char u_int8_t; -typedef short int16_t; -typedef unsigned short u_int16_t; -typedef int int32_t; -typedef unsigned int u_int32_t; -#ifdef WE_DONT_NEED_QUADS -typedef long long int64_t; -typedef unsigned long long u_int64_t; -#endif -#endif - -#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ -typedef u_int32_t pgno_t; -#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ -typedef u_int16_t indx_t; -#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ -typedef u_int32_t recno_t; - -/* Key/data structure -- a Data-Base Thang. */ -typedef struct { - void *data; /* data */ - size_t size; /* data length */ -} DBT; - -/* Routine flags. */ -#define R_CURSOR 1 /* del, put, seq */ -#define __R_UNUSED 2 /* UNUSED */ -#define R_FIRST 3 /* seq */ -#define R_IAFTER 4 /* put (RECNO) */ -#define R_IBEFORE 5 /* put (RECNO) */ -#define R_LAST 6 /* seq (BTREE, RECNO) */ -#define R_NEXT 7 /* seq */ -#define R_NOOVERWRITE 8 /* put */ -#define R_PREV 9 /* seq (BTREE, RECNO) */ -#define R_SETCURSOR 10 /* put (RECNO) */ -#define R_RECNOSYNC 11 /* sync (RECNO) */ - -typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; - -/* - * !!! - * The following flags are included in the dbopen(3) call as part of the - * open(2) flags. In order to avoid conflicts with the open flags, start - * at the top of the 16 or 32-bit number space and work our way down. If - * the open flags were significantly expanded in the future, it could be - * a problem. Wish I'd left another flags word in the dbopen call. - * - * !!! - * None of this stuff is implemented yet. The only reason that it's here - * is so that the access methods can skip copying the key/data pair when - * the DB_LOCK flag isn't set. - */ -#define DB_LOCK 0x20000000 /* Do locking. */ -#define DB_SHMEM 0x40000000 /* Use shared memory. */ -#define DB_TXN 0x80000000 /* Do transactions. */ - -/* Access method description structure. */ -typedef struct __db { - DBTYPE type; /* Underlying db type. */ - int (*close) __P((struct __db *)); - int (*del) __P((const struct __db *, const DBT *, u_int)); - int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); - int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); - int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); - int (*sync) __P((const struct __db *, u_int)); - void *internal; /* Access method private. */ - int (*fd) __P((const struct __db *)); -} DB; - -#define BTREEMAGIC 0x053162 -#define BTREEVERSION 3 - -/* Structure used to pass parameters to the btree routines. */ -typedef struct { -#define R_DUP 0x01 /* duplicate keys */ - u_long flags; - u_int cachesize; /* bytes to cache */ - int maxkeypage; /* maximum keys per page */ - int minkeypage; /* minimum keys per page */ - u_int psize; /* page size */ - int (*compare) /* comparison function */ - __P((const DBT *, const DBT *)); - size_t (*prefix) /* prefix function */ - __P((const DBT *, const DBT *)); - int lorder; /* byte order */ -} BTREEINFO; - -#define HASHMAGIC 0x061561 -#define HASHVERSION 2 - -/* Structure used to pass parameters to the hashing routines. */ -typedef struct { - u_int bsize; /* bucket size */ - u_int ffactor; /* fill factor */ - u_int nelem; /* number of elements */ - u_int cachesize; /* bytes to cache */ - u_int32_t /* hash function */ - (*hash) __P((const void *, size_t)); - int lorder; /* byte order */ -} HASHINFO; - -/* Structure used to pass parameters to the record routines. */ -typedef struct { -#define R_FIXEDLEN 0x01 /* fixed-length records */ -#define R_NOKEY 0x02 /* key not required */ -#define R_SNAPSHOT 0x04 /* snapshot the input */ - u_long flags; - u_int cachesize; /* bytes to cache */ - u_int psize; /* page size */ - int lorder; /* byte order */ - size_t reclen; /* record length (fixed-length records) */ - u_char bval; /* delimiting byte (variable-length records */ - char *bfname; /* btree file name */ -} RECNOINFO; - -#ifdef __DBINTERFACE_PRIVATE -/* - * Little endian <==> big endian 32-bit swap macros. - * M_32_SWAP swap a memory location - * P_32_SWAP swap a referenced memory location - * P_32_COPY swap from one location to another - */ -#define M_32_SWAP(a) { \ - u_int32_t _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[3]; \ - ((char *)&a)[1] = ((char *)&_tmp)[2]; \ - ((char *)&a)[2] = ((char *)&_tmp)[1]; \ - ((char *)&a)[3] = ((char *)&_tmp)[0]; \ -} -#define P_32_SWAP(a) { \ - u_int32_t _tmp = *(u_int32_t *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[3]; \ - ((char *)a)[1] = ((char *)&_tmp)[2]; \ - ((char *)a)[2] = ((char *)&_tmp)[1]; \ - ((char *)a)[3] = ((char *)&_tmp)[0]; \ -} -#define P_32_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[3]; \ - ((char *)&(b))[1] = ((char *)&(a))[2]; \ - ((char *)&(b))[2] = ((char *)&(a))[1]; \ - ((char *)&(b))[3] = ((char *)&(a))[0]; \ -} - -/* - * Little endian <==> big endian 16-bit swap macros. - * M_16_SWAP swap a memory location - * P_16_SWAP swap a referenced memory location - * P_16_COPY swap from one location to another - */ -#define M_16_SWAP(a) { \ - u_int16_t _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[1]; \ - ((char *)&a)[1] = ((char *)&_tmp)[0]; \ -} -#define P_16_SWAP(a) { \ - u_int16_t _tmp = *(u_int16_t *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[1]; \ - ((char *)a)[1] = ((char *)&_tmp)[0]; \ -} -#define P_16_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[1]; \ - ((char *)&(b))[1] = ((char *)&(a))[0]; \ -} -#endif - -__BEGIN_DECLS -DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); - -#ifdef __DBINTERFACE_PRIVATE -DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); -DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); -DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); -void __dbpanic __P((DB *dbp)); -#endif -__END_DECLS -#endif /* !_DB_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h deleted file mode 120000 index 03f870c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/mpool.h +++ /dev/null @@ -1 +0,0 @@ -../../include/mpool.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h deleted file mode 120000 index a1a41a8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/ndbm.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ndbm.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h deleted file mode 120000 index e54c7cf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/include/queue.h +++ /dev/null @@ -1 +0,0 @@ -../../include/queue.h \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys deleted file mode 120000 index 2996fba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.2/sys +++ /dev/null @@ -1 +0,0 @@ -include \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 b/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 deleted file mode 120000 index 283b111..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/PORT/ultrix.4.3 +++ /dev/null @@ -1 +0,0 @@ -ultrix.4.2 \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/README b/user/mpy/lib/berkeley-db-1.xx/README deleted file mode 100644 index bed2c92..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/README +++ /dev/null @@ -1,40 +0,0 @@ -# @(#)README 8.27 (Berkeley) 9/1/94 - -This is version 1.85 of the Berkeley DB code. - -For information on compiling and installing this software, see the file -PORT/README. - -Newer versions of this software will periodically be made available by -anonymous ftp from ftp.cs.berkeley.edu. An archive in compressed format -is in ucb/4bsd/db.tar.Z, or in gzip format in ucb/4bsd/db.tar.gz. If -you'd like to receive announcements of future releases of this software, -send email to the contact address below. - -Email questions may be addressed to Keith Bostic at bostic@cs.berkeley.edu. - -============================================ -Distribution contents: - -Makefile.inc Ignore this, it's the 4.4BSD subsystem Makefile. -PORT The per OS/architecture directories to use to build - libdb.a, if you're not running 4.4BSD. See the file - PORT/README for more information. -README This file. -btree The B+tree routines. -changelog List of changes, per version. -db The dbopen(3) interface routine. -docs Various USENIX papers, and the formatted manual pages. -hash The extended linear hashing routines. -man The unformatted manual pages. -mpool The memory pool routines. -recno The fixed/variable length record routines. -test Test package. - -============================================ -Debugging: - -If you're running a memory checker (e.g. Purify) on DB, make sure that -you recompile it with "-DPURIFY" in the CFLAGS, first. By default, -allocated pages are not initialized by the DB code, and they will show -up as reads of uninitialized memory in the buffer write routines. diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc deleted file mode 100644 index 8ed7649..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile.inc 8.2 (Berkeley) 7/14/94 - -.PATH: ${.CURDIR}/db/btree - -SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c \ - bt_overflow.c bt_page.c bt_put.c bt_search.c bt_seq.c bt_split.c \ - bt_utils.c diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c deleted file mode 100644 index 523bbdb..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_close.c +++ /dev/null @@ -1,179 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_meta __P((BTREE *)); - -/* - * BT_CLOSE -- Close a btree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_close(dbp) - DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync the tree. */ - if (__bt_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - /* Close the memory pool. */ - if (mpool_close(t->bt_mp) == RET_ERROR) - return (RET_ERROR); - - /* Free random memory. */ - if (t->bt_cursor.key.data != NULL) { - free(t->bt_cursor.key.data); - t->bt_cursor.key.size = 0; - t->bt_cursor.key.data = NULL; - } - if (t->bt_rkey.data) { - free(t->bt_rkey.data); - t->bt_rkey.size = 0; - t->bt_rkey.data = NULL; - } - if (t->bt_rdata.data) { - free(t->bt_rdata.data); - t->bt_rdata.size = 0; - t->bt_rdata.data = NULL; - } - - free(t); - free(dbp); - return RET_SUCCESS; -} - -/* - * BT_SYNC -- sync the btree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_sync(dbp, flags) - const DB *dbp; - u_int flags; -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync doesn't currently take any flags. */ - if (flags != 0) { - errno = EINVAL; - return (RET_ERROR); - } - - if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED)) - return (RET_SUCCESS); - - if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) - return (RET_ERROR); - - if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS) - F_CLR(t, B_MODIFIED); - - return (status); -} - -/* - * BT_META -- write the tree meta data to disk. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_meta(t) - BTREE *t; -{ - BTMETA m; - void *p; - - if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL) - return (RET_ERROR); - - /* Fill in metadata. */ - m.magic = BTREEMAGIC; - m.version = BTREEVERSION; - m.psize = t->bt_psize; - m.free = t->bt_free; - m.nrecs = t->bt_nrecs; - m.flags = F_ISSET(t, SAVEMETA); - - memmove(p, &m, sizeof(BTMETA)); - mpool_put(t->bt_mp, p, MPOOL_DIRTY); - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c deleted file mode 100644 index 1cb208b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_conv.c +++ /dev/null @@ -1,221 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_conv.c 8.5 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -static void mswap __P((PAGE *)); - -/* - * __BT_BPGIN, __BT_BPGOUT -- - * Convert host-specific number layout to/from the host-independent - * format stored on disk. - * - * Parameters: - * t: tree - * pg: page number - * h: page to convert - */ -void -__bt_pgin(t, pg, pp) - void *t; - pgno_t pg; - void *pp; -{ - PAGE *h; - indx_t i, top; - u_char flags; - char *p; - - if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - M_32_SWAP(h->pgno); - M_32_SWAP(h->prevpg); - M_32_SWAP(h->nextpg); - M_32_SWAP(h->flags); - M_16_SWAP(h->lower); - M_16_SWAP(h->upper); - - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - M_16_SWAP(h->linp[i]); - p = (char *)GETBINTERNAL(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - if (*(u_char *)p & P_BIGKEY) { - p += sizeof(u_char); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - M_16_SWAP(h->linp[i]); - p = (char *)GETBLEAF(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(u_int32_t); - flags = *(u_char *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(u_char); - if (flags & P_BIGKEY) { - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - } -} - -void -__bt_pgout(t, pg, pp) - void *t; - pgno_t pg; - void *pp; -{ - PAGE *h; - indx_t i, top; - u_char flags; - char *p; - - if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - p = (char *)GETBINTERNAL(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - if (*(u_char *)p & P_BIGKEY) { - p += sizeof(u_char); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - M_16_SWAP(h->linp[i]); - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - p = (char *)GETBLEAF(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(u_int32_t); - flags = *(u_char *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(u_char); - if (flags & P_BIGKEY) { - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - M_16_SWAP(h->linp[i]); - } - - M_32_SWAP(h->pgno); - M_32_SWAP(h->prevpg); - M_32_SWAP(h->nextpg); - M_32_SWAP(h->flags); - M_16_SWAP(h->lower); - M_16_SWAP(h->upper); -} - -/* - * MSWAP -- Actually swap the bytes on the meta page. - * - * Parameters: - * p: page to convert - */ -static void -mswap(pg) - PAGE *pg; -{ - char *p; - - p = (char *)pg; - P_32_SWAP(p); /* magic */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* version */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* psize */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* free */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* nrecs */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* flags */ - p += sizeof(u_int32_t); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c deleted file mode 100644 index 3aefbe7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_debug.c +++ /dev/null @@ -1,329 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_debug.c 8.5 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -/* - * BT_DUMP -- Dump the tree - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_dump(dbp) - DB *dbp; -{ - BTREE *t; - PAGE *h; - pgno_t i; - char *sep; - - t = dbp->internal; - (void)fprintf(stderr, "%s: pgsz %d", - F_ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize); - if (F_ISSET(t, R_RECNO)) - (void)fprintf(stderr, " keys %lu", t->bt_nrecs); -#undef X -#define X(flag, name) \ - if (F_ISSET(t, flag)) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (t->flags != 0) { - sep = " flags ("; - X(R_FIXLEN, "FIXLEN"); - X(B_INMEM, "INMEM"); - X(B_NODUPS, "NODUPS"); - X(B_RDONLY, "RDONLY"); - X(R_RECNO, "RECNO"); - X(B_METADIRTY,"METADIRTY"); - (void)fprintf(stderr, ")\n"); - } -#undef X - - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DMPAGE -- Dump the meta page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dmpage(h) - PAGE *h; -{ - BTMETA *m; - char *sep; - - m = (BTMETA *)h; - (void)fprintf(stderr, "magic %lx\n", m->magic); - (void)fprintf(stderr, "version %lu\n", m->version); - (void)fprintf(stderr, "psize %lu\n", m->psize); - (void)fprintf(stderr, "free %lu\n", m->free); - (void)fprintf(stderr, "nrecs %lu\n", m->nrecs); - (void)fprintf(stderr, "flags %lu", m->flags); -#undef X -#define X(flag, name) \ - if (m->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (m->flags) { - sep = " ("; - X(B_NODUPS, "NODUPS"); - X(R_RECNO, "RECNO"); - (void)fprintf(stderr, ")"); - } -} - -/* - * BT_DNPAGE -- Dump the page - * - * Parameters: - * n: page number to dump. - */ -void -__bt_dnpage(dbp, pgno) - DB *dbp; - pgno_t pgno; -{ - BTREE *t; - PAGE *h; - - t = dbp->internal; - if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DPAGE -- Dump the page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dpage(h) - PAGE *h; -{ - BINTERNAL *bi; - BLEAF *bl; - RINTERNAL *ri; - RLEAF *rl; - indx_t cur, top; - char *sep; - - (void)fprintf(stderr, " page %d: (", h->pgno); -#undef X -#define X(flag, name) \ - if (h->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - sep = ""; - X(P_BINTERNAL, "BINTERNAL") /* types */ - X(P_BLEAF, "BLEAF") - X(P_RINTERNAL, "RINTERNAL") /* types */ - X(P_RLEAF, "RLEAF") - X(P_OVERFLOW, "OVERFLOW") - X(P_PRESERVE, "PRESERVE"); - (void)fprintf(stderr, ")\n"); -#undef X - - (void)fprintf(stderr, "\tprev %2d next %2d", h->prevpg, h->nextpg); - if (h->flags & P_OVERFLOW) - return; - - top = NEXTINDEX(h); - (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n", - h->lower, h->upper, top); - for (cur = 0; cur < top; cur++) { - (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]); - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(h, cur); - (void)fprintf(stderr, - "size %03d pgno %03d", bi->ksize, bi->pgno); - if (bi->flags & P_BIGKEY) - (void)fprintf(stderr, " (indirect)"); - else if (bi->ksize) - (void)fprintf(stderr, - " {%.*s}", (int)bi->ksize, bi->bytes); - break; - case P_RINTERNAL: - ri = GETRINTERNAL(h, cur); - (void)fprintf(stderr, "entries %03d pgno %03d", - ri->nrecs, ri->pgno); - break; - case P_BLEAF: - bl = GETBLEAF(h, cur); - if (bl->flags & P_BIGKEY) - (void)fprintf(stderr, - "big key page %lu size %u/", - *(pgno_t *)bl->bytes, - *(u_int32_t *)(bl->bytes + sizeof(pgno_t))); - else if (bl->ksize) - (void)fprintf(stderr, "%s/", bl->bytes); - if (bl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %u", - *(pgno_t *)(bl->bytes + bl->ksize), - *(u_int32_t *)(bl->bytes + bl->ksize + - sizeof(pgno_t))); - else if (bl->dsize) - (void)fprintf(stderr, "%.*s", - (int)bl->dsize, bl->bytes + bl->ksize); - break; - case P_RLEAF: - rl = GETRLEAF(h, cur); - if (rl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %u", - *(pgno_t *)rl->bytes, - *(u_int32_t *)(rl->bytes + sizeof(pgno_t))); - else if (rl->dsize) - (void)fprintf(stderr, - "%.*s", (int)rl->dsize, rl->bytes); - break; - } - (void)fprintf(stderr, "\n"); - } -} -#endif - -#ifdef STATISTICS -/* - * BT_STAT -- Gather/print the tree statistics - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_stat(dbp) - DB *dbp; -{ - extern u_long bt_cache_hit, bt_cache_miss, bt_pfxsaved, bt_rootsplit; - extern u_long bt_sortsplit, bt_split; - BTREE *t; - PAGE *h; - pgno_t i, pcont, pinternal, pleaf; - u_long ifree, lfree, nkeys; - int levels; - - t = dbp->internal; - pcont = pinternal = pleaf = 0; - nkeys = ifree = lfree = 0; - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - case P_RINTERNAL: - ++pinternal; - ifree += h->upper - h->lower; - break; - case P_BLEAF: - case P_RLEAF: - ++pleaf; - lfree += h->upper - h->lower; - nkeys += NEXTINDEX(h); - break; - case P_OVERFLOW: - ++pcont; - break; - } - (void)mpool_put(t->bt_mp, h, 0); - } - - /* Count the levels of the tree. */ - for (i = P_ROOT, levels = 0 ;; ++levels) { - h = mpool_get(t->bt_mp, i, 0); - if (h->flags & (P_BLEAF|P_RLEAF)) { - if (levels == 0) - levels = 1; - (void)mpool_put(t->bt_mp, h, 0); - break; - } - i = F_ISSET(t, R_RECNO) ? - GETRINTERNAL(h, 0)->pgno : - GETBINTERNAL(h, 0)->pgno; - (void)mpool_put(t->bt_mp, h, 0); - } - - (void)fprintf(stderr, "%d level%s with %ld keys", - levels, levels == 1 ? "" : "s", nkeys); - if (F_ISSET(t, R_RECNO)) - (void)fprintf(stderr, " (%ld header count)", t->bt_nrecs); - (void)fprintf(stderr, - "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n", - pinternal + pleaf + pcont, pleaf, pinternal, pcont); - (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n", - bt_cache_hit, bt_cache_miss); - (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n", - bt_split, bt_rootsplit, bt_sortsplit); - pleaf *= t->bt_psize - BTDATAOFF; - if (pleaf) - (void)fprintf(stderr, - "%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n", - ((double)(pleaf - lfree) / pleaf) * 100, - pleaf - lfree, lfree); - pinternal *= t->bt_psize - BTDATAOFF; - if (pinternal) - (void)fprintf(stderr, - "%.0f%% internal fill (%ld bytes used, %ld bytes free\n", - ((double)(pinternal - ifree) / pinternal) * 100, - pinternal - ifree, ifree); - if (bt_pfxsaved) - (void)fprintf(stderr, "prefix checking removed %lu bytes.\n", - bt_pfxsaved); -} -#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c deleted file mode 100644 index 667bff5..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_delete.c +++ /dev/null @@ -1,657 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_delete.c 8.13 (Berkeley) 7/28/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -static int __bt_bdelete __P((BTREE *, const DBT *)); -static int __bt_curdel __P((BTREE *, const DBT *, PAGE *, u_int)); -static int __bt_pdelete __P((BTREE *, PAGE *)); -static int __bt_relink __P((BTREE *, PAGE *)); -static int __bt_stkacq __P((BTREE *, PAGE **, CURSOR *)); - -/* - * __bt_delete - * Delete the item(s) referenced by a key. - * - * Return RET_SPECIAL if the key is not found. - */ -int -__bt_delete(dbp, key, flags) - const DB *dbp; - const DBT *key; - u_int flags; -{ - BTREE *t; - CURSOR *c; - PAGE *h; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Check for change to a read-only tree. */ - if (F_ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch (flags) { - case 0: - status = __bt_bdelete(t, key); - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, delete the cursor. Must already - * have started a scan and not have already deleted it. - */ - c = &t->bt_cursor; - if (F_ISSET(c, CURS_INIT)) { - if (F_ISSET(c, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * If the page is about to be emptied, we'll need to - * delete it, which means we have to acquire a stack. - */ - if (NEXTINDEX(h) == 1) - if (__bt_stkacq(t, &h, &t->bt_cursor)) - return (RET_ERROR); - - status = __bt_dleaf(t, NULL, h, c->pg.index); - - if (NEXTINDEX(h) == 0 && status == RET_SUCCESS) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - } else - mpool_put(t->bt_mp, - h, status == RET_SUCCESS ? MPOOL_DIRTY : 0); - break; - } - /* FALLTHROUGH */ - default: - errno = EINVAL; - return (RET_ERROR); - } - if (status == RET_SUCCESS) - F_SET(t, B_MODIFIED); - return (status); -} - -/* - * __bt_stkacq -- - * Acquire a stack so we can delete a cursor entry. - * - * Parameters: - * t: tree - * hp: pointer to current, pinned PAGE pointer - * c: pointer to the cursor - * - * Returns: - * 0 on success, 1 on failure - */ -static int -__bt_stkacq(t, hp, c) - BTREE *t; - PAGE **hp; - CURSOR *c; -{ - BINTERNAL *bi; - EPG *e; - EPGNO *parent; - PAGE *h; - indx_t index = 0; - pgno_t pgno; - recno_t nextpg, prevpg; - int exact, level; - - /* - * Find the first occurrence of the key in the tree. Toss the - * currently locked page so we don't hit an already-locked page. - */ - h = *hp; - mpool_put(t->bt_mp, h, 0); - if ((e = __bt_search(t, &c->key, &exact)) == NULL) - return (1); - h = e->page; - - /* See if we got it in one shot. */ - if (h->pgno == c->pg.pgno) - goto ret; - - /* - * Move right, looking for the page. At each move we have to move - * up the stack until we don't have to move to the next page. If - * we have to change pages at an internal level, we have to fix the - * stack back up. - */ - while (h->pgno != c->pg.pgno) { - if ((nextpg = h->nextpg) == P_INVALID) - break; - mpool_put(t->bt_mp, h, 0); - - /* Move up the stack. */ - for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (1); - - /* Move to the next index. */ - if (parent->index != NEXTINDEX(h) - 1) { - index = parent->index + 1; - BT_PUSH(t, h->pgno, index); - break; - } - mpool_put(t->bt_mp, h, 0); - } - - /* Restore the stack. */ - while (level--) { - /* Push the next level down onto the stack. */ - bi = GETBINTERNAL(h, index); - pgno = bi->pgno; - BT_PUSH(t, pgno, 0); - - /* Lose the currently pinned page. */ - mpool_put(t->bt_mp, h, 0); - - /* Get the next level down. */ - if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) - return (1); - index = 0; - } - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL) - return (1); - } - - if (h->pgno == c->pg.pgno) - goto ret; - - /* Reacquire the original stack. */ - mpool_put(t->bt_mp, h, 0); - if ((e = __bt_search(t, &c->key, &exact)) == NULL) - return (1); - h = e->page; - - /* - * Move left, looking for the page. At each move we have to move - * up the stack until we don't have to change pages to move to the - * next page. If we have to change pages at an internal level, we - * have to fix the stack back up. - */ - while (h->pgno != c->pg.pgno) { - if ((prevpg = h->prevpg) == P_INVALID) - break; - mpool_put(t->bt_mp, h, 0); - - /* Move up the stack. */ - for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (1); - - /* Move to the next index. */ - if (parent->index != 0) { - index = parent->index - 1; - BT_PUSH(t, h->pgno, index); - break; - } - mpool_put(t->bt_mp, h, 0); - } - - /* Restore the stack. */ - while (level--) { - /* Push the next level down onto the stack. */ - bi = GETBINTERNAL(h, index); - pgno = bi->pgno; - - /* Lose the currently pinned page. */ - mpool_put(t->bt_mp, h, 0); - - /* Get the next level down. */ - if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) - return (1); - - index = NEXTINDEX(h) - 1; - BT_PUSH(t, pgno, index); - } - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL) - return (1); - } - - -ret: mpool_put(t->bt_mp, h, 0); - return ((*hp = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL); -} - -/* - * __bt_bdelete -- - * Delete all key/data pairs matching the specified key. - * - * Parameters: - * t: tree - * key: key to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -__bt_bdelete(t, key) - BTREE *t; - const DBT *key; -{ - EPG *e; - PAGE *h; - int deleted, exact, redo; - - deleted = 0; - - /* Find any matching record; __bt_search pins the page. */ -loop: if ((e = __bt_search(t, key, &exact)) == NULL) - return (deleted ? RET_SUCCESS : RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (deleted ? RET_SUCCESS : RET_SPECIAL); - } - - /* - * Delete forward, then delete backward, from the found key. If - * there are duplicates and we reach either side of the page, do - * the key search again, so that we get them all. - */ - redo = 0; - h = e->page; - do { - if (__bt_dleaf(t, key, h, e->index)) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - if (F_ISSET(t, B_NODUPS)) { - if (NEXTINDEX(h) == 0) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - } else - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); - } - deleted = 1; - } while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0); - - /* Check for right-hand edge of the page. */ - if (e->index == NEXTINDEX(h)) - redo = 1; - - /* Delete from the key to the beginning of the page. */ - while (e->index-- > 0) { - if (__bt_cmp(t, key, e) != 0) - break; - if (__bt_dleaf(t, key, h, e->index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - if (e->index == 0) - redo = 1; - } - - /* Check for an empty page. */ - if (NEXTINDEX(h) == 0) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - goto loop; - } - - /* Put the page. */ - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - if (redo) - goto loop; - return (RET_SUCCESS); -} - -/* - * __bt_pdelete -- - * Delete a single page from the tree. - * - * Parameters: - * t: tree - * h: leaf page - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side-effects: - * mpool_put's the page - */ -static int -__bt_pdelete(t, h) - BTREE *t; - PAGE *h; -{ - BINTERNAL *bi; - PAGE *pg; - EPGNO *parent; - indx_t cnt, index, *ip, offset; - u_int32_t nksize; - char *from; - - /* - * Walk the parent page stack -- a LIFO stack of the pages that were - * traversed when we searched for the page where the delete occurred. - * Each stack entry is a page number and a page index offset. The - * offset is for the page traversed on the search. We've just deleted - * a page, so we have to delete the key from the parent page. - * - * If the delete from the parent page makes it empty, this process may - * continue all the way up the tree. We stop if we reach the root page - * (which is never deleted, it's just not worth the effort) or if the - * delete does not empty the page. - */ - while ((parent = BT_POP(t)) != NULL) { - /* Get the parent page. */ - if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (RET_ERROR); - - index = parent->index; - bi = GETBINTERNAL(pg, index); - - /* Free any overflow pages. */ - if (bi->flags & P_BIGKEY && - __ovfl_delete(t, bi->bytes) == RET_ERROR) { - mpool_put(t->bt_mp, pg, 0); - return (RET_ERROR); - } - - /* - * Free the parent if it has only the one key and it's not the - * root page. If it's the rootpage, turn it back into an empty - * leaf page. - */ - if (NEXTINDEX(pg) == 1) - if (pg->pgno == P_ROOT) { - pg->lower = BTDATAOFF; - pg->upper = t->bt_psize; - pg->flags = P_BLEAF; - } else { - if (__bt_relink(t, pg) || __bt_free(t, pg)) - return (RET_ERROR); - continue; - } - else { - /* Pack remaining key items at the end of the page. */ - nksize = NBINTERNAL(bi->ksize); - from = (char *)pg + pg->upper; - memmove(from + nksize, from, (char *)bi - from); - pg->upper += nksize; - - /* Adjust indices' offsets, shift the indices down. */ - offset = pg->linp[index]; - for (cnt = index, ip = &pg->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nksize; - for (cnt = NEXTINDEX(pg) - index; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1]; - pg->lower -= sizeof(indx_t); - } - - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - break; - } - - /* Free the leaf page, as long as it wasn't the root. */ - if (h->pgno == P_ROOT) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); - } - return (__bt_relink(t, h) || __bt_free(t, h)); -} - -/* - * __bt_dleaf -- - * Delete a single record from a leaf page. - * - * Parameters: - * t: tree - * key: referenced key - * h: page - * index: index on page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_dleaf(t, key, h, index) - BTREE *t; - const DBT *key; - PAGE *h; - u_int index; -{ - BLEAF *bl; - indx_t cnt, *ip, offset; - u_int32_t nbytes; - void *to; - char *from; - - /* If this record is referenced by the cursor, delete the cursor. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == index && - __bt_curdel(t, key, h, index)) - return (RET_ERROR); - - /* If the entry uses overflow pages, make them available for reuse. */ - to = bl = GETBLEAF(h, index); - if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) - return (RET_ERROR); - if (bl->flags & P_BIGDATA && - __ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR) - return (RET_ERROR); - - /* Pack the remaining key/data items at the end of the page. */ - nbytes = NBLEAF(bl); - from = (char *)h + h->upper; - memmove(from + nbytes, from, (char *)to - from); - h->upper += nbytes; - - /* Adjust the indices' offsets, shift the indices down. */ - offset = h->linp[index]; - for (cnt = index, ip = &h->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - for (cnt = NEXTINDEX(h) - index; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - - /* If the cursor is on this page, adjust it as necessary. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > index) - --t->bt_cursor.pg.index; - - return (RET_SUCCESS); -} - -/* - * __bt_curdel -- - * Delete the cursor. - * - * Parameters: - * t: tree - * key: referenced key (or NULL) - * h: page - * index: index on page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -__bt_curdel(t, key, h, index) - BTREE *t; - const DBT *key; - PAGE *h; - u_int index; -{ - CURSOR *c; - EPG e; - PAGE *pg; - int curcopy, status; - - /* - * If there are duplicates, move forward or backward to one. - * Otherwise, copy the key into the cursor area. - */ - c = &t->bt_cursor; - F_CLR(c, CURS_AFTER | CURS_BEFORE | CURS_ACQUIRE); - - curcopy = 0; - if (!F_ISSET(t, B_NODUPS)) { - /* - * We're going to have to do comparisons. If we weren't - * provided a copy of the key, i.e. the user is deleting - * the current cursor position, get one. - */ - if (key == NULL) { - e.page = h; - e.index = index; - if ((status = __bt_ret(t, &e, - &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS) - return (status); - curcopy = 1; - key = &c->key; - } - /* Check previous key, if not at the beginning of the page. */ - if (index > 0) { - e.page = h; - e.index = index - 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_BEFORE); - goto dup2; - } - } - /* Check next key, if not at the end of the page. */ - if (index < NEXTINDEX(h) - 1) { - e.page = h; - e.index = index + 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_AFTER); - goto dup2; - } - } - /* Check previous key if at the beginning of the page. */ - if (index == 0 && h->prevpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (RET_ERROR); - e.page = pg; - e.index = NEXTINDEX(pg) - 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_BEFORE); - goto dup1; - } - mpool_put(t->bt_mp, pg, 0); - } - /* Check next key if at the end of the page. */ - if (index == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (RET_ERROR); - e.page = pg; - e.index = 0; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_AFTER); -dup1: mpool_put(t->bt_mp, pg, 0); -dup2: c->pg.pgno = e.page->pgno; - c->pg.index = e.index; - return (RET_SUCCESS); - } - mpool_put(t->bt_mp, pg, 0); - } - } - e.page = h; - e.index = index; - if (curcopy || (status = - __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) { - F_SET(c, CURS_ACQUIRE); - return (RET_SUCCESS); - } - return (status); -} - -/* - * __bt_relink -- - * Link around a deleted page. - * - * Parameters: - * t: tree - * h: page to be deleted - */ -static int -__bt_relink(t, h) - BTREE *t; - PAGE *h; -{ - PAGE *pg; - - if (h->nextpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (RET_ERROR); - pg->prevpg = h->prevpg; - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - } - if (h->prevpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (RET_ERROR); - pg->nextpg = h->nextpg; - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - } - return (0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c deleted file mode 100644 index 74824c7..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_get.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_get.c 8.6 (Berkeley) 7/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__bt_get(dbp, key, data, flags) - const DB *dbp; - const DBT *key; - DBT *data; - u_int flags; -{ - BTREE *t; - EPG *e; - int exact, status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags. */ - if (flags) { - errno = EINVAL; - return (RET_ERROR); - } - - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (RET_SPECIAL); - } - - status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0); - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c deleted file mode 100644 index 7269ef0..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_open.c +++ /dev/null @@ -1,412 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Implementation of btree access method for 4.4BSD. - * - * The design here was originally based on that of the btree access method - * used in the Postgres database system at UC Berkeley. This implementation - * is wholly independent of the Postgres code. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -#undef MINPSIZE -#define MINPSIZE 128 -#endif - -static int byteorder __P((void)); -static int nroot __P((BTREE *)); - -#ifdef BTREE_POSIX -/* Default vmethods and vtable to work with POSIX fd's. */ -static ssize_t bt_read(void *fd, void *buf, size_t size) -{ -//printf("read: %p(%lx)\n", buf, size); - return read((int)(uintptr_t)fd, buf, size); -} - -static ssize_t bt_write(void *fd, const void *buf, size_t size) -{ -//printf("write: %p(%lx)\n", buf, size); - return write((int)(uintptr_t)fd, buf, size); -} - -static off_t bt_lseek(void *fd, off_t offset, int whence) -{ -//printf("lseek: %lx(%d)\n", offset, whence); - return lseek((int)(uintptr_t)fd, offset, whence); -} - -static int bt_fsync(void *fd) -{ - return fsync((int)(uintptr_t)fd); -} - -static FILEVTABLE bt_fd_fvtable = { - bt_read, - bt_write, - bt_lseek, - bt_fsync -}; -#endif - -/* - * __BT_OPEN -- Open a btree. - * - * Creates and fills a DB struct, and calls the routine that actually - * opens the btree. - * - * Parameters: - * fname: filename (NULL for in-memory trees) - * b: BTREEINFO pointer - * - * Returns: - * NULL on failure, pointer to DB on success. - * - */ -DB * -__bt_open(file, vtable, openinfo, dflags) - virt_fd_t file; - const FILEVTABLE *vtable; - int dflags; - const BTREEINFO *openinfo; -{ - BTMETA m; - BTREE *t; - BTREEINFO b; - DB *dbp; - pgno_t ncache; - ssize_t nr; - int machine_lorder; - - t = NULL; -#ifdef BTREE_POSIX - if (vtable == NULL) - vtable = &bt_fd_fvtable; -#endif - - /* - * Intention is to make sure all of the user's selections are okay - * here and then use them without checking. Can't be complete, since - * we don't know the right page size, lorder or flags until the backing - * file is opened. Also, the file's page size can cause the cachesize - * to change. - */ - machine_lorder = byteorder(); - if (openinfo) { - b = *openinfo; - - /* Flags: R_DUP. */ - if (b.flags & ~(R_DUP)) - goto einval; - - /* - * Page size must be indx_t aligned and >= MINPSIZE. Default - * page size is set farther on, based on the underlying file - * transfer size. - */ - if (b.psize && - (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 || - b.psize & (sizeof(indx_t) - 1))) - goto einval; - - /* Minimum number of keys per page; absolute minimum is 2. */ - if (b.minkeypage) { - if (b.minkeypage < 2) - goto einval; - } else - b.minkeypage = DEFMINKEYPAGE; - - /* If no comparison, use default comparison and prefix. */ - if (b.compare == NULL) { - b.compare = __bt_defcmp; - if (b.prefix == NULL) - b.prefix = __bt_defpfx; - } - - if (b.lorder == 0) - b.lorder = machine_lorder; - } else { - b.compare = __bt_defcmp; - b.cachesize = 0; - b.flags = 0; - b.lorder = machine_lorder; - b.minkeypage = DEFMINKEYPAGE; - b.prefix = __bt_defpfx; - b.psize = 0; - } - - /* Check for the ubiquitous PDP-11. */ - if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN) - goto einval; - - /* Allocate and initialize DB and BTREE structures. */ - if ((t = (BTREE *)malloc(sizeof(BTREE))) == NULL) - goto err; - memset(t, 0, sizeof(BTREE)); - t->bt_fd = file; - t->bt_lorder = b.lorder; - t->bt_order = NOT; - t->bt_cmp = b.compare; - t->bt_pfx = b.prefix; - t->bt_rfd = -1; - - if ((t->bt_dbp = dbp = (DB *)malloc(sizeof(DB))) == NULL) - goto err; - memset(t->bt_dbp, 0, sizeof(DB)); - if (t->bt_lorder != machine_lorder) - F_SET(t, B_NEEDSWAP); - - dbp->type = DB_BTREE; - dbp->internal = t; - dbp->close = __bt_close; - dbp->del = __bt_delete; - dbp->fd = __bt_fd; - dbp->get = __bt_get; - dbp->put = __bt_put; - dbp->seq = __bt_seq; - dbp->sync = __bt_sync; - - if ((nr = vtable->read(t->bt_fd, &m, sizeof(BTMETA))) < 0) - goto err; - if (nr != 0) { - if (nr != sizeof(BTMETA)) - goto eftype; - - /* - * Read in the meta-data. This can change the notion of what - * the lorder, page size and flags are, and, when the page size - * changes, the cachesize value can change too. If the user - * specified the wrong byte order for an existing database, we - * don't bother to return an error, we just clear the NEEDSWAP - * bit. - */ - if (m.magic == BTREEMAGIC) - F_CLR(t, B_NEEDSWAP); - else { - F_SET(t, B_NEEDSWAP); - M_32_SWAP(m.magic); - M_32_SWAP(m.version); - M_32_SWAP(m.psize); - M_32_SWAP(m.free); - M_32_SWAP(m.nrecs); - M_32_SWAP(m.flags); - } - if (m.magic != BTREEMAGIC || m.version != BTREEVERSION) - goto eftype; - if (m.psize < MINPSIZE || m.psize > MAX_PAGE_OFFSET + 1 || - m.psize & (sizeof(indx_t) - 1)) - goto eftype; - if (m.flags & ~SAVEMETA) - goto eftype; - b.psize = m.psize; - F_SET(t, m.flags); - t->bt_free = m.free; - t->bt_nrecs = m.nrecs; - } else { - /* - * Set the page size to the best value for I/O to this file. - * Don't overflow the page offset type. - */ - if (b.psize == 0) { - b.psize = DEFPSIZE; - } - - /* Set flag if duplicates permitted. */ - if (!(b.flags & R_DUP)) - F_SET(t, B_NODUPS); - - t->bt_free = P_INVALID; - t->bt_nrecs = 0; - F_SET(t, B_METADIRTY); - } - - t->bt_psize = b.psize; - - /* Set the cache size; must be a multiple of the page size. */ - if (b.cachesize && b.cachesize & (b.psize - 1)) - b.cachesize += (~b.cachesize & (b.psize - 1)) + 1; - if (b.cachesize < b.psize * MINCACHE) - b.cachesize = b.psize * MINCACHE; - - /* Calculate number of pages to cache. */ - ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; - - /* - * The btree data structure requires that at least two keys can fit on - * a page, but other than that there's no fixed requirement. The user - * specified a minimum number per page, and we translated that into the - * number of bytes a key/data pair can use before being placed on an - * overflow page. This calculation includes the page header, the size - * of the index referencing the leaf item and the size of the leaf item - * structure. Also, don't let the user specify a minkeypage such that - * a key/data pair won't fit even if both key and data are on overflow - * pages. - */ - t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage - - (sizeof(indx_t) + NBLEAFDBT(0, 0)); - if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t)) - t->bt_ovflsize = - NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t); - - /* Initialize the buffer pool. */ - if ((t->bt_mp = - mpool_open(NULL, t->bt_fd, vtable, t->bt_psize, ncache)) == NULL) - goto err; - if (!F_ISSET(t, B_INMEM)) - mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t); - - /* Create a root page if new tree. */ - if (nroot(t) == RET_ERROR) - goto err; - - /* Global flags. */ - if (dflags & DB_LOCK) - F_SET(t, B_DB_LOCK); - if (dflags & DB_SHMEM) - F_SET(t, B_DB_SHMEM); - if (dflags & DB_TXN) - F_SET(t, B_DB_TXN); - - return (dbp); - -einval: errno = EINVAL; - goto err; - -eftype: errno = EFTYPE; - goto err; - -err: if (t) { - if (t->bt_dbp) - free(t->bt_dbp); - free(t); - } - return (NULL); -} - -/* - * NROOT -- Create the root of a new tree. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -nroot(t) - BTREE *t; -{ - PAGE *meta, *root; - pgno_t npg; - - if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { - mpool_put(t->bt_mp, meta, 0); - return (RET_SUCCESS); - } - if (errno != EINVAL) /* It's OK to not exist. */ - return (RET_ERROR); - errno = 0; - - if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if ((root = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if (npg != P_ROOT) - return (RET_ERROR); - root->pgno = npg; - root->prevpg = root->nextpg = P_INVALID; - root->lower = BTDATAOFF; - root->upper = t->bt_psize; - root->flags = P_BLEAF; - memset(meta, 0, t->bt_psize); - mpool_put(t->bt_mp, meta, MPOOL_DIRTY); - mpool_put(t->bt_mp, root, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -static int -byteorder() -{ - u_int32_t x; - u_char *p; - - x = 0x01020304; - p = (u_char *)&x; - switch (*p) { - case 1: - return (BIG_ENDIAN); - case 4: - return (LITTLE_ENDIAN); - default: - return (0); - } -} - -int -__bt_fd(dbp) - const DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - return -1; -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c deleted file mode 100644 index b1bd343..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_overflow.c +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * Big key/data code. - * - * Big key and data entries are stored on linked lists of pages. The initial - * reference is byte string stored with the key or data and is the page number - * and size. The actual record is stored in a chain of pages linked by the - * nextpg field of the PAGE header. - * - * The first page of the chain has a special property. If the record is used - * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set - * in the header. - * - * XXX - * A single DBT is written to each chain, so a lot of space on the last page - * is wasted. This is a fairly major bug for some data sets. - */ - -/* - * __OVFL_GET -- Get an overflow key/data item. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, u_int32_t } - * buf: storage address - * bufsz: storage size - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_get(t, p, ssz, buf, bufsz) - BTREE *t; - void *p; - size_t *ssz; - void **buf; - size_t *bufsz; -{ - PAGE *h; - pgno_t pg; - size_t nb, plen; - u_int32_t sz; - - memcpy(&pg, p, sizeof(pgno_t)); - memcpy(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); - *ssz = sz; - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - /* Make the buffer bigger as necessary. */ - if (*bufsz < sz) { - *buf = (char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz)); - if (*buf == NULL) - return (RET_ERROR); - *bufsz = sz; - } - - /* - * Step through the linked list of pages, copying the data on each one - * into the buffer. Never copy more than the data's length. - */ - plen = t->bt_psize - BTDATAOFF; - for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - nb = MIN(sz, plen); - memmove(p, (char *)h + BTDATAOFF, nb); - mpool_put(t->bt_mp, h, 0); - - if ((sz -= nb) == 0) - break; - } - return (RET_SUCCESS); -} - -/* - * __OVFL_PUT -- Store an overflow key/data item. - * - * Parameters: - * t: tree - * data: DBT to store - * pgno: storage page number - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_put(t, dbt, pg) - BTREE *t; - const DBT *dbt; - pgno_t *pg; -{ - PAGE *h, *last; - void *p; - pgno_t npg; - size_t nb, plen; - u_int32_t sz; - - /* - * Allocate pages and copy the key/data record into them. Store the - * number of the first page in the chain. - */ - plen = t->bt_psize - BTDATAOFF; - for (last = NULL, p = dbt->data, sz = dbt->size;; - p = (char *)p + plen, last = h) { - if ((h = __bt_new(t, &npg)) == NULL) - return (RET_ERROR); - - h->pgno = npg; - h->nextpg = h->prevpg = P_INVALID; - h->flags = P_OVERFLOW; - h->lower = h->upper = 0; - - nb = MIN(sz, plen); - memmove((char *)h + BTDATAOFF, p, nb); - - if (last) { - last->nextpg = h->pgno; - mpool_put(t->bt_mp, last, MPOOL_DIRTY); - } else - *pg = h->pgno; - - if ((sz -= nb) == 0) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - } - return (RET_SUCCESS); -} - -/* - * __OVFL_DELETE -- Delete an overflow chain. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, u_int32_t } - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_delete(t, p) - BTREE *t; - void *p; -{ - PAGE *h; - pgno_t pg; - size_t plen; - u_int32_t sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Don't delete chains used by internal pages. */ - if (h->flags & P_PRESERVE) { - mpool_put(t->bt_mp, h, 0); - return (RET_SUCCESS); - } - - /* Step through the chain, calling the free routine for each page. */ - for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) { - pg = h->nextpg; - __bt_free(t, h); - if (sz <= plen) - break; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c deleted file mode 100644 index ce9cbf1..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_page.c +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -/* - * __bt_free -- - * Put a page on the freelist. - * - * Parameters: - * t: tree - * h: page to free - * - * Returns: - * RET_ERROR, RET_SUCCESS - * - * Side-effect: - * mpool_put's the page. - */ -int -__bt_free(t, h) - BTREE *t; - PAGE *h; -{ - /* Insert the page at the head of the free list. */ - h->prevpg = P_INVALID; - h->nextpg = t->bt_free; - t->bt_free = h->pgno; - F_SET(t, B_METADIRTY); - - /* Make sure the page gets written back. */ - return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); -} - -/* - * __bt_new -- - * Get a new page, preferably from the freelist. - * - * Parameters: - * t: tree - * npg: storage for page number. - * - * Returns: - * Pointer to a page, NULL on error. - */ -PAGE * -__bt_new(t, npg) - BTREE *t; - pgno_t *npg; -{ - PAGE *h; - - if (t->bt_free != P_INVALID && - (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { - *npg = t->bt_free; - t->bt_free = h->nextpg; - F_SET(t, B_METADIRTY); - return (h); - } - return (mpool_new(t->bt_mp, npg)); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c deleted file mode 100644 index 4f3bd1f..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_put.c +++ /dev/null @@ -1,321 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_put.c 8.8 (Berkeley) 7/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static EPG *bt_fast __P((BTREE *, const DBT *, const DBT *, int *)); - -/* - * __BT_PUT -- Add a btree item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the - * tree and R_NOOVERWRITE specified. - */ -int -__bt_put(dbp, key, data, flags) - const DB *dbp; - DBT *key; - const DBT *data; - u_int flags; -{ - BTREE *t; - DBT tkey, tdata; - EPG *e = NULL; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - u_int32_t nbytes; - int dflags, exact, status; - char *dest, db[NOVFLSIZE], kb[NOVFLSIZE]; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Check for change to a read-only tree. */ - if (F_ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch (flags) { - case 0: - case R_NOOVERWRITE: - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, put the cursor. Must already - * have started a scan and not have already deleted it. - */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, - CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) - break; - /* FALLTHROUGH */ - default: - errno = EINVAL; - return (RET_ERROR); - } - - /* - * If the key/data pair won't fit on a page, store it on overflow - * pages. Only put the key on the overflow page if the pair are - * still too big after moving the data to an overflow page. - * - * XXX - * If the insert fails later on, the overflow pages aren't recovered. - */ - dflags = 0; - if (key->size + data->size > t->bt_ovflsize) { - if (key->size > t->bt_ovflsize) { -storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR) - return (RET_ERROR); - tkey.data = kb; - tkey.size = NOVFLSIZE; - memmove(kb, &pg, sizeof(pgno_t)); - memmove(kb + sizeof(pgno_t), - &key->size, sizeof(u_int32_t)); - dflags |= P_BIGKEY; - key = &tkey; - } - if (key->size + data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - memmove(db, &pg, sizeof(pgno_t)); - memmove(db + sizeof(pgno_t), - &data->size, sizeof(u_int32_t)); - dflags |= P_BIGDATA; - data = &tdata; - } - if (key->size + data->size > t->bt_ovflsize) - goto storekey; - } - - /* Replace the cursor. */ - if (flags == R_CURSOR) { - if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL) - return (RET_ERROR); - index = t->bt_cursor.pg.index; - goto delete; - } - - /* - * Find the key to delete, or, the location at which to insert. - * Bt_fast and __bt_search both pin the returned page. - */ - if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL) - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - h = e->page; - index = e->index; - - /* - * Add the key/data pair to the tree. If an identical key is already - * in the tree, and R_NOOVERWRITE is set, an error is returned. If - * R_NOOVERWRITE is not set, the key is either added (if duplicates are - * permitted) or an error is returned. - */ - switch (flags) { - case R_NOOVERWRITE: - if (!exact) - break; - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - default: - if (!exact || !F_ISSET(t, B_NODUPS)) - break; - /* - * !!! - * Note, the delete may empty the page, so we need to put a - * new entry into the page immediately. - */ -delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, or the user has put a ceiling on the number of - * keys permitted in the page, split the page. The split code will - * insert the key and data and unpin the current page. If inserting - * into the offset array, shift the pointers up. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - if ((status = __bt_split(t, h, key, - data, dflags, nbytes, index)) != RET_SUCCESS) - return (status); - goto success; - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BLEAF(dest, key, data, dflags); - - /* If the cursor is on this page, adjust it as necessary. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= index) - ++t->bt_cursor.pg.index; - - if (t->bt_order == NOT) { - if (h->nextpg == P_INVALID) { - if (index == NEXTINDEX(h) - 1) { - t->bt_order = FORWARD; - t->bt_last.index = index; - t->bt_last.pgno = h->pgno; - } - } else if (h->prevpg == P_INVALID) { - if (index == 0) { - t->bt_order = BACK; - t->bt_last.index = 0; - t->bt_last.pgno = h->pgno; - } - } - } - - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - -success: - if (flags == R_SETCURSOR) - __bt_setcur(t, e->page->pgno, e->index); - - F_SET(t, B_MODIFIED); - return (RET_SUCCESS); -} - -#ifdef STATISTICS -u_long bt_cache_hit, bt_cache_miss; -#endif - -/* - * BT_FAST -- Do a quick check for sorted data. - * - * Parameters: - * t: tree - * key: key to insert - * - * Returns: - * EPG for new record or NULL if not found. - */ -static EPG * -bt_fast(t, key, data, exactp) - BTREE *t; - const DBT *key, *data; - int *exactp; -{ - PAGE *h; - u_int32_t nbytes; - int cmp; - - if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) { - t->bt_order = NOT; - return (NULL); - } - t->bt_cur.page = h; - t->bt_cur.index = t->bt_last.index; - - /* - * If won't fit in this page or have too many keys in this page, - * have to search to get split stack. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) - goto miss; - - if (t->bt_order == FORWARD) { - if (t->bt_cur.page->nextpg != P_INVALID) - goto miss; - if (t->bt_cur.index != NEXTINDEX(h) - 1) - goto miss; - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) < 0) - goto miss; - t->bt_last.index = cmp ? ++t->bt_cur.index : t->bt_cur.index; - } else { - if (t->bt_cur.page->prevpg != P_INVALID) - goto miss; - if (t->bt_cur.index != 0) - goto miss; - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) > 0) - goto miss; - t->bt_last.index = 0; - } - *exactp = cmp == 0; -#ifdef STATISTICS - ++bt_cache_hit; -#endif - return (&t->bt_cur); - -miss: -#ifdef STATISTICS - ++bt_cache_miss; -#endif - t->bt_order = NOT; - mpool_put(t->bt_mp, h, 0); - return (NULL); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c deleted file mode 100644 index 485afcb..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_search.c +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_search.c 8.8 (Berkeley) 7/31/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -static int __bt_snext __P((BTREE *, PAGE *, const DBT *, int *)); -static int __bt_sprev __P((BTREE *, PAGE *, const DBT *, int *)); - -/* - * __bt_search -- - * Search a btree for a key. - * - * Parameters: - * t: tree to search - * key: key to find - * exactp: pointer to exact match flag - * - * Returns: - * The EPG for matching record, if any, or the EPG for the location - * of the key, if it were inserted into the tree, is entered into - * the bt_cur field of the tree. A pointer to the field is returned. - */ -EPG * -__bt_search(t, key, exactp) - BTREE *t; - const DBT *key; - int *exactp; -{ - PAGE *h; - indx_t base, index, lim; - pgno_t pg; - int cmp; - - BT_CLR(t); - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - - /* Do a binary search on the current page. */ - t->bt_cur.page = h; - for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { - t->bt_cur.index = index = base + (lim >> 1); - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) { - if (h->flags & P_BLEAF) { - *exactp = 1; - return (&t->bt_cur); - } - goto next; - } - if (cmp > 0) { - base = index + 1; - --lim; - } - } - - /* - * If it's a leaf page, we're almost done. If no duplicates - * are allowed, or we have an exact match, we're done. Else, - * it's possible that there were matching keys on this page, - * which later deleted, and we're on a page with no matches - * while there are matches on other pages. If at the start or - * end of a page, check the adjacent page. - */ - if (h->flags & P_BLEAF) { - if (!F_ISSET(t, B_NODUPS)) { - if (base == 0 && - h->prevpg != P_INVALID && - __bt_sprev(t, h, key, exactp)) - return (&t->bt_cur); - if (base == NEXTINDEX(h) && - h->nextpg != P_INVALID && - __bt_snext(t, h, key, exactp)) - return (&t->bt_cur); - } - *exactp = 0; - t->bt_cur.index = base; - return (&t->bt_cur); - } - - /* - * No match found. Base is the smallest index greater than - * key and may be zero or a last + 1 index. If it's non-zero, - * decrement by one, and record the internal page which should - * be a parent page for the key. If a split later occurs, the - * inserted page will be to the right of the saved page. - */ - index = base ? base - 1 : base; - -next: BT_PUSH(t, h->pgno, index); - pg = GETBINTERNAL(h, index)->pgno; - mpool_put(t->bt_mp, h, 0); - } -} - -/* - * __bt_snext -- - * Check for an exact match after the key. - * - * Parameters: - * t: tree - * h: current page - * key: key - * exactp: pointer to exact match flag - * - * Returns: - * If an exact match found. - */ -static int -__bt_snext(t, h, key, exactp) - BTREE *t; - PAGE *h; - const DBT *key; - int *exactp; -{ - EPG e; - - /* - * Get the next page. The key is either an exact - * match, or not as good as the one we already have. - */ - if ((e.page = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (0); - e.index = 0; - if (__bt_cmp(t, key, &e) == 0) { - mpool_put(t->bt_mp, h, 0); - t->bt_cur = e; - *exactp = 1; - return (1); - } - mpool_put(t->bt_mp, e.page, 0); - return (0); -} - -/* - * __bt_sprev -- - * Check for an exact match before the key. - * - * Parameters: - * t: tree - * h: current page - * key: key - * exactp: pointer to exact match flag - * - * Returns: - * If an exact match found. - */ -static int -__bt_sprev(t, h, key, exactp) - BTREE *t; - PAGE *h; - const DBT *key; - int *exactp; -{ - EPG e; - - /* - * Get the previous page. The key is either an exact - * match, or not as good as the one we already have. - */ - if ((e.page = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (0); - e.index = NEXTINDEX(e.page) - 1; - if (__bt_cmp(t, key, &e) == 0) { - mpool_put(t->bt_mp, h, 0); - t->bt_cur = e; - *exactp = 1; - return (1); - } - mpool_put(t->bt_mp, e.page, 0); - return (0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c deleted file mode 100644 index d5a700d..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_seq.c +++ /dev/null @@ -1,460 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_seq.c 8.7 (Berkeley) 7/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int __bt_first __P((BTREE *, const DBT *, EPG *, int *)); -static int __bt_seqadv __P((BTREE *, EPG *, int)); -static int __bt_seqset __P((BTREE *, EPG *, DBT *, int)); - -/* - * Sequential scan support. - * - * The tree can be scanned sequentially, starting from either end of the - * tree or from any specific key. A scan request before any scanning is - * done is initialized as starting from the least node. - */ - -/* - * __bt_seq -- - * Btree sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__bt_seq(dbp, key, data, flags) - const DB *dbp; - DBT *key, *data; - u_int flags; -{ - BTREE *t; - EPG e; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If scan unitialized as yet, or starting at a specific record, set - * the scan to a specific key. Both __bt_seqset and __bt_seqadv pin - * the page the cursor references if they're successful. - */ - switch (flags) { - case R_NEXT: - case R_PREV: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - status = __bt_seqadv(t, &e, flags); - break; - } - /* FALLTHROUGH */ - case R_FIRST: - case R_LAST: - case R_CURSOR: - status = __bt_seqset(t, &e, key, flags); - break; - default: - errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) { - __bt_setcur(t, e.page->pgno, e.index); - - status = - __bt_ret(t, &e, key, &t->bt_rkey, data, &t->bt_rdata, 0); - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e.page, 0); - else - t->bt_pinned = e.page; - } - return (status); -} - -/* - * __bt_seqset -- - * Set the sequential scan to a specific key. - * - * Parameters: - * t: tree - * ep: storage for returned key - * key: key for initial scan position - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV - * - * Side effects: - * Pins the page the cursor references. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -__bt_seqset(t, ep, key, flags) - BTREE *t; - EPG *ep; - DBT *key; - int flags; -{ - PAGE *h; - pgno_t pg; - int exact; - - /* - * Find the first, last or specific key in the tree and point the - * cursor at it. The cursor may not be moved until a new key has - * been found. - */ - switch (flags) { - case R_CURSOR: /* Keyed scan. */ - /* - * Find the first instance of the key or the smallest key - * which is greater than or equal to the specified key. - */ - if (key->data == NULL || key->size == 0) { - errno = EINVAL; - return (RET_ERROR); - } - return (__bt_first(t, key, ep, &exact)); - case R_FIRST: /* First record. */ - case R_NEXT: - /* Walk down the left-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Check for an empty tree. */ - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, 0)->pgno; - mpool_put(t->bt_mp, h, 0); - } - ep->page = h; - ep->index = 0; - break; - case R_LAST: /* Last record. */ - case R_PREV: - /* Walk down the right-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Check for an empty tree. */ - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - ep->page = h; - ep->index = NEXTINDEX(h) - 1; - break; - } - return (RET_SUCCESS); -} - -/* - * __bt_seqadvance -- - * Advance the sequential scan. - * - * Parameters: - * t: tree - * flags: R_NEXT, R_PREV - * - * Side effects: - * Pins the page the new key/data record is on. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -__bt_seqadv(t, ep, flags) - BTREE *t; - EPG *ep; - int flags; -{ - CURSOR *c; - PAGE *h; - indx_t index = 0; - pgno_t pg; - int exact; - - /* - * There are a couple of states that we can be in. The cursor has - * been initialized by the time we get here, but that's all we know. - */ - c = &t->bt_cursor; - - /* - * The cursor was deleted where there weren't any duplicate records, - * so the key was saved. Find out where that key would go in the - * current tree. It doesn't matter if the returned key is an exact - * match or not -- if it's an exact match, the record was added after - * the delete so we can just return it. If not, as long as there's - * a record there, return it. - */ - if (F_ISSET(c, CURS_ACQUIRE)) - return (__bt_first(t, &c->key, ep, &exact)); - - /* Get the page referenced by the cursor. */ - if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * Find the next/previous record in the tree and point the cursor at - * it. The cursor may not be moved until a new key has been found. - */ - switch (flags) { - case R_NEXT: /* Next record. */ - /* - * The cursor was deleted in duplicate records, and moved - * forward to a record that has yet to be returned. Clear - * that flag, and return the record. - */ - if (F_ISSET(c, CURS_AFTER)) - goto usecurrent; - index = c->pg.index; - if (++index == NEXTINDEX(h)) { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - index = 0; - } - break; - case R_PREV: /* Previous record. */ - /* - * The cursor was deleted in duplicate records, and moved - * backward to a record that has yet to be returned. Clear - * that flag, and return the record. - */ - if (F_ISSET(c, CURS_BEFORE)) { -usecurrent: F_CLR(c, CURS_AFTER | CURS_BEFORE); - ep->page = h; - ep->index = c->pg.index; - return (RET_SUCCESS); - } - index = c->pg.index; - if (index == 0) { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - index = NEXTINDEX(h) - 1; - } else - --index; - break; - } - - ep->page = h; - ep->index = index; - return (RET_SUCCESS); -} - -/* - * __bt_first -- - * Find the first entry. - * - * Parameters: - * t: the tree - * key: the key - * erval: return EPG - * exactp: pointer to exact match flag - * - * Returns: - * The first entry in the tree greater than or equal to key, - * or RET_SPECIAL if no such key exists. - */ -static int -__bt_first(t, key, erval, exactp) - BTREE *t; - const DBT *key; - EPG *erval; - int *exactp; -{ - PAGE *h; - EPG *ep, save; - pgno_t pg; - - /* - * Find any matching record; __bt_search pins the page. - * - * If it's an exact match and duplicates are possible, walk backwards - * in the tree until we find the first one. Otherwise, make sure it's - * a valid key (__bt_search may return an index just past the end of a - * page) and return it. - */ - if ((ep = __bt_search(t, key, exactp)) == NULL) - return (RET_SPECIAL); - if (*exactp) { - if (F_ISSET(t, B_NODUPS)) { - *erval = *ep; - return (RET_SUCCESS); - } - - /* - * Walk backwards, as long as the entry matches and there are - * keys left in the tree. Save a copy of each match in case - * we go too far. - */ - save = *ep; - h = ep->page; - do { - if (save.page->pgno != ep->page->pgno) { - mpool_put(t->bt_mp, save.page, 0); - save = *ep; - } else - save.index = ep->index; - - /* - * Don't unpin the page the last (or original) match - * was on, but make sure it's unpinned if an error - * occurs. - */ - if (ep->index == 0) { - if (h->prevpg == P_INVALID) - break; - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, - h->prevpg, 0)) == NULL) { - if (h->pgno == save.page->pgno) - mpool_put(t->bt_mp, - save.page, 0); - return (RET_ERROR); - } - ep->page = h; - ep->index = NEXTINDEX(h); - } - --ep->index; - } while (__bt_cmp(t, key, ep) == 0); - - /* - * Reach here with the last page that was looked at pinned, - * which may or may not be the same as the last (or original) - * match page. If it's not useful, release it. - */ - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - - *erval = save; - return (RET_SUCCESS); - } - - /* If at the end of a page, find the next entry. */ - if (ep->index == NEXTINDEX(ep->page)) { - h = ep->page; - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - ep->index = 0; - ep->page = h; - } - *erval = *ep; - return (RET_SUCCESS); -} - -/* - * __bt_setcur -- - * Set the cursor to an entry in the tree. - * - * Parameters: - * t: the tree - * pgno: page number - * index: page index - */ -void -__bt_setcur(t, pgno, index) - BTREE *t; - pgno_t pgno; - u_int index; -{ - /* Lose any already deleted key. */ - if (t->bt_cursor.key.data != NULL) { - free(t->bt_cursor.key.data); - t->bt_cursor.key.size = 0; - t->bt_cursor.key.data = NULL; - } - F_CLR(&t->bt_cursor, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE); - - /* Update the cursor. */ - t->bt_cursor.pg.pgno = pgno; - t->bt_cursor.pg.index = index; - F_SET(&t->bt_cursor, CURS_INIT); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c deleted file mode 100644 index e743178..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_split.c +++ /dev/null @@ -1,834 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_split.c 8.9 (Berkeley) 7/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static PAGE *bt_page - __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t)); -static int bt_preserve __P((BTREE *, pgno_t)); -static PAGE *bt_psplit - __P((BTREE *, PAGE *, PAGE *, PAGE *, indx_t *, size_t)); -static PAGE *bt_root - __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t)); -static int bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static recno_t rec_total __P((PAGE *)); - -#ifdef STATISTICS -u_long bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved; -#endif - -/* - * __BT_SPLIT -- Split the tree. - * - * Parameters: - * t: tree - * sp: page to split - * key: key to insert - * data: data to insert - * flags: BIGKEY/BIGDATA flags - * ilen: insert length - * skip: index to leave open - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_split(t, sp, key, data, flags, ilen, argskip) - BTREE *t; - PAGE *sp; - const DBT *key, *data; - int flags; - size_t ilen; - u_int32_t argskip; -{ - BINTERNAL *bi = NULL; - BLEAF *bl = NULL, *tbl; - DBT a, b; - EPGNO *parent; - PAGE *h, *l, *r, *lchild, *rchild; - indx_t nxtindex; - u_int16_t skip; - u_int32_t n, nbytes, nksize = 0; - int parentsplit; - char *dest; - pgno_t pg_tmp; - - /* - * Split the page into two pages, l and r. The split routines return - * a pointer to the page into which the key should be inserted and with - * skip set to the offset which should be used. Additionally, l and r - * are pinned. - */ - skip = argskip; - h = sp->pgno == P_ROOT ? - bt_root(t, sp, &l, &r, &skip, ilen) : - bt_page(t, sp, &l, &r, &skip, ilen); - if (h == NULL) - return (RET_ERROR); - - /* - * Insert the new key/data pair into the leaf page. (Key inserts - * always cause a leaf page to split first.) - */ - h->linp[skip] = h->upper -= ilen; - dest = (char *)h + h->upper; - if (F_ISSET(t, R_RECNO)) - WR_RLEAF(dest, data, flags) - else - WR_BLEAF(dest, key, data, flags) - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (F_ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err2; - - /* - * Now we walk the parent page stack -- a LIFO stack of the pages that - * were traversed when we searched for the page that split. Each stack - * entry is a page number and a page index offset. The offset is for - * the page traversed on the search. We've just split a page, so we - * have to insert a new key into the parent page. - * - * If the insert into the parent page causes it to split, may have to - * continue splitting all the way up the tree. We stop if the root - * splits or the page inserted into didn't have to split to hold the - * new key. Some algorithms replace the key for the old page as well - * as the new page. We don't, as there's no reason to believe that the - * first key on the old page is any better than the key we have, and, - * in the case of a key being placed at index 0 causing the split, the - * key is unavailable. - * - * There are a maximum of 5 pages pinned at any time. We keep the left - * and right pages pinned while working on the parent. The 5 are the - * two children, left parent and right parent (when the parent splits) - * and the root page or the overflow key page when calling bt_preserve. - * This code must make sure that all pins are released other than the - * root page or overflow page which is unlocked elsewhere. - */ - while ((parent = BT_POP(t)) != NULL) { - lchild = l; - rchild = r; - - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - goto err2; - - /* - * The new key goes ONE AFTER the index, because the split - * was to the right. - */ - skip = parent->index + 1; - - /* - * Calculate the space needed on the parent page. - * - * Prefix trees: space hack when inserting into BINTERNAL - * pages. Retain only what's needed to distinguish between - * the new entry and the LAST entry on the page to its left. - * If the keys compare equal, retain the entire key. Note, - * we don't touch overflow keys, and the entire key must be - * retained for the next-to-left most key on the leftmost - * page of each level, or the search will fail. Applicable - * ONLY to internal pages that have leaf pages as children. - * Further reduction of the key between pairs of internal - * pages loses too much information. - */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(rchild, 0); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - bl = GETBLEAF(rchild, 0); - nbytes = NBINTERNAL(bl->ksize); - if (t->bt_pfx && !(bl->flags & P_BIGKEY) && - (h->prevpg != P_INVALID || skip > 1)) { - tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1); - a.size = tbl->ksize; - a.data = tbl->bytes; - b.size = bl->ksize; - b.data = bl->bytes; - nksize = t->bt_pfx(&a, &b); - n = NBINTERNAL(nksize); - if (n < nbytes) { -#ifdef STATISTICS - bt_pfxsaved += nbytes - n; -#endif - nbytes = n; - } else - nksize = 0; - } else - nksize = 0; - break; - case P_RINTERNAL: - case P_RLEAF: - nbytes = NRINTERNAL; - break; - default: - abort(); - } - - /* Split the parent page if necessary or shift the indices. */ - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - sp = h; - h = h->pgno == P_ROOT ? - bt_root(t, h, &l, &r, &skip, nbytes) : - bt_page(t, h, &l, &r, &skip, nbytes); - if (h == NULL) - goto err1; - parentsplit = 1; - } else { - if (skip < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + skip + 1, h->linp + skip, - (nxtindex - skip) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - parentsplit = 0; - } - - /* Insert the key into the parent page. */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_BLEAF: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, - rchild->pgno, bl->flags & P_BIGKEY); - memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); - /* Avoid alignment violation */ - memcpy(&pg_tmp, bl->bytes, sizeof(pgno_t)); - if (bl->flags & P_BIGKEY && - bt_preserve(t, pg_tmp) == RET_ERROR) - goto err1; - break; - case P_RINTERNAL: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = rec_total(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = rec_total(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_RLEAF: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - default: - abort(); - } - - /* Unpin the held pages. */ - if (!parentsplit) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (F_ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err1; - - mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - } - - /* Unpin the held pages. */ - mpool_put(t->bt_mp, l, MPOOL_DIRTY); - mpool_put(t->bt_mp, r, MPOOL_DIRTY); - - /* Clear any pages left on the stack. */ - return (RET_SUCCESS); - - /* - * If something fails in the above loop we were already walking back - * up the tree and the tree is now inconsistent. Nothing much we can - * do about it but release any memory we're holding. - */ -err1: mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - -err2: mpool_put(t->bt_mp, l, 0); - mpool_put(t->bt_mp, r, 0); - __dbpanic(t->bt_dbp); - return (RET_ERROR); -} - -/* - * BT_PAGE -- Split a non-root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_page(t, h, lp, rp, skip, ilen) - BTREE *t; - PAGE *h, **lp, **rp; - indx_t *skip; - size_t ilen; -{ - PAGE *l, *r, *tp; - pgno_t npg; - -#ifdef STATISTICS - ++bt_split; -#endif - /* Put the new right page for the split into place. */ - if ((r = __bt_new(t, &npg)) == NULL) - return (NULL); - r->pgno = npg; - r->lower = BTDATAOFF; - r->upper = t->bt_psize; - r->nextpg = h->nextpg; - r->prevpg = h->pgno; - r->flags = h->flags & P_TYPE; - - /* - * If we're splitting the last page on a level because we're appending - * a key to it (skip is NEXTINDEX()), it's likely that the data is - * sorted. Adding an empty page on the side of the level is less work - * and can push the fill factor much higher than normal. If we're - * wrong it's no big deal, we'll just do the split the right way next - * time. It may look like it's equally easy to do a similar hack for - * reverse sorted data, that is, split the tree left, but it's not. - * Don't even try. - */ - if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) { -#ifdef STATISTICS - ++bt_sortsplit; -#endif - h->nextpg = r->pgno; - r->lower = BTDATAOFF + sizeof(indx_t); - *skip = 0; - *lp = h; - *rp = r; - return (r); - } - - /* Put the new left page for the split into place. */ - if ((l = (PAGE *)malloc(t->bt_psize)) == NULL) { - mpool_put(t->bt_mp, r, 0); - return (NULL); - } -#ifdef PURIFY - memset(l, 0xff, t->bt_psize); -#endif - l->pgno = h->pgno; - l->nextpg = r->pgno; - l->prevpg = h->prevpg; - l->lower = BTDATAOFF; - l->upper = t->bt_psize; - l->flags = h->flags & P_TYPE; - - /* Fix up the previous pointer of the page after the split page. */ - if (h->nextpg != P_INVALID) { - if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) { - free(l); - /* XXX mpool_free(t->bt_mp, r->pgno); */ - return (NULL); - } - tp->prevpg = r->pgno; - mpool_put(t->bt_mp, tp, MPOOL_DIRTY); - } - - /* - * Split right. The key/data pairs aren't sorted in the btree page so - * it's simpler to copy the data from the split page onto two new pages - * instead of copying half the data to the right page and compacting - * the left page in place. Since the left page can't change, we have - * to swap the original and the allocated left page after the split. - */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - /* Move the new left page onto the old left page. */ - memmove(h, l, t->bt_psize); - if (tp == l) - tp = h; - free(l); - - *lp = h; - *rp = r; - return (tp); -} - -/* - * BT_ROOT -- Split the root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_root(t, h, lp, rp, skip, ilen) - BTREE *t; - PAGE *h, **lp, **rp; - indx_t *skip; - size_t ilen; -{ - PAGE *l, *r, *tp; - pgno_t lnpg, rnpg; - -#ifdef STATISTICS - ++bt_split; - ++bt_rootsplit; -#endif - /* Put the new left and right pages for the split into place. */ - if ((l = __bt_new(t, &lnpg)) == NULL || - (r = __bt_new(t, &rnpg)) == NULL) - return (NULL); - l->pgno = lnpg; - r->pgno = rnpg; - l->nextpg = r->pgno; - r->prevpg = l->pgno; - l->prevpg = r->nextpg = P_INVALID; - l->lower = r->lower = BTDATAOFF; - l->upper = r->upper = t->bt_psize; - l->flags = r->flags = h->flags & P_TYPE; - - /* Split the root page. */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - *lp = l; - *rp = r; - return (tp); -} - -/* - * BT_RROOT -- Fix up the recno root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_rroot(t, h, l, r) - BTREE *t; - PAGE *h, *l, *r; -{ - char *dest; - - /* Insert the left and right keys, set the header information. */ - h->linp[0] = h->upper = t->bt_psize - NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno); - - h->linp[1] = h->upper -= NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno); - - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to recno internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_RINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_BROOT -- Fix up the btree root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_broot(t, h, l, r) - BTREE *t; - PAGE *h, *l, *r; -{ - BINTERNAL *bi; - BLEAF *bl; - u_int32_t nbytes; - char *dest; - pgno_t pg_tmp; - - /* - * If the root page was a leaf page, change it into an internal page. - * We copy the key we split on (but not the key's data, in the case of - * a leaf page) to the new root page. - * - * The btree comparison code guarantees that the left-most key on any - * level of the tree is never used, so it doesn't need to be filled in. - */ - nbytes = NBINTERNAL(0); - h->linp[0] = h->upper = t->bt_psize - nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, 0, l->pgno, 0); - - switch (h->flags & P_TYPE) { - case P_BLEAF: - bl = GETBLEAF(r, 0); - nbytes = NBINTERNAL(bl->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, bl->ksize, r->pgno, 0); - memmove(dest, bl->bytes, bl->ksize); - - /* - * If the key is on an overflow page, mark the overflow chain - * so it isn't deleted when the leaf copy of the key is deleted. - */ - /* Avoid alignment violation */ - memcpy(&pg_tmp, bl->bytes, sizeof(pgno_t)); - if (bl->flags & P_BIGKEY && - bt_preserve(t, pg_tmp) == RET_ERROR) - return (RET_ERROR); - break; - case P_BINTERNAL: - bi = GETBINTERNAL(r, 0); - nbytes = NBINTERNAL(bi->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = r->pgno; - break; - default: - abort(); - } - - /* There are two keys on the page. */ - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to btree internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_BINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_PSPLIT -- Do the real work of splitting the page. - * - * Parameters: - * t: tree - * h: page to be split - * l: page to put lower half of data - * r: page to put upper half of data - * pskip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert. - */ -static PAGE * -bt_psplit(t, h, l, r, pskip, ilen) - BTREE *t; - PAGE *h, *l, *r; - indx_t *pskip; - size_t ilen; -{ - BINTERNAL *bi; - BLEAF *bl; - CURSOR *c; - RLEAF *rl; - PAGE *rval; - void *src = NULL; - indx_t full, half, nxt, off, skip, top, used; - u_int32_t nbytes; - int bigkeycnt, isbigkey; - - /* - * Split the data to the left and right pages. Leave the skip index - * open. Additionally, make some effort not to split on an overflow - * key. This makes internal page processing faster and can save - * space as overflow keys used by internal pages are never deleted. - */ - bigkeycnt = 0; - skip = *pskip; - full = t->bt_psize - BTDATAOFF; - half = full / 2; - used = 0; - for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { - if (skip == off) { - nbytes = ilen; - isbigkey = 0; /* XXX: not really known. */ - } else - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - isbigkey = bi->flags & P_BIGKEY; - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - isbigkey = bl->flags & P_BIGKEY; - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - isbigkey = 0; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - isbigkey = 0; - break; - default: - abort(); - } - - /* - * If the key/data pairs are substantial fractions of the max - * possible size for the page, it's possible to get situations - * where we decide to try and copy too much onto the left page. - * Make sure that doesn't happen. - */ - if ((skip <= off && - used + nbytes + sizeof(indx_t) >= full) || nxt == top - 1) { - --off; - break; - } - - /* Copy the key/data pair, if not the skipped index. */ - if (skip != off) { - ++nxt; - - l->linp[off] = l->upper -= nbytes; - memmove((char *)l + l->upper, src, nbytes); - } - - used += nbytes + sizeof(indx_t); - if (used >= half) { - if (!isbigkey || bigkeycnt == 3) - break; - else - ++bigkeycnt; - } - } - - /* - * Off is the last offset that's valid for the left page. - * Nxt is the first offset to be placed on the right page. - */ - l->lower += (off + 1) * sizeof(indx_t); - - /* - * If splitting the page that the cursor was on, the cursor has to be - * adjusted to point to the same record as before the split. If the - * cursor is at or past the skipped slot, the cursor is incremented by - * one. If the cursor is on the right page, it is decremented by the - * number of records split to the left page. - */ - c = &t->bt_cursor; - if (F_ISSET(c, CURS_INIT) && c->pg.pgno == h->pgno) { - if (c->pg.index >= skip) - ++c->pg.index; - if (c->pg.index < nxt) /* Left page. */ - c->pg.pgno = l->pgno; - else { /* Right page. */ - c->pg.pgno = r->pgno; - c->pg.index -= nxt; - } - } - - /* - * If the skipped index was on the left page, just return that page. - * Otherwise, adjust the skip index to reflect the new position on - * the right page. - */ - if (skip <= off) { - skip = 0; - rval = l; - } else { - rval = r; - *pskip -= nxt; - } - - for (off = 0; nxt < top; ++off) { - if (skip == nxt) { - ++off; - skip = 0; - } - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - break; - default: - abort(); - } - ++nxt; - r->linp[off] = r->upper -= nbytes; - memmove((char *)r + r->upper, src, nbytes); - } - r->lower += off * sizeof(indx_t); - - /* If the key is being appended to the page, adjust the index. */ - if (skip == top) - r->lower += sizeof(indx_t); - - return (rval); -} - -/* - * BT_PRESERVE -- Mark a chain of pages as used by an internal node. - * - * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the - * record that references them gets deleted. Chains pointed to by internal - * pages never get deleted. This routine marks a chain as pointed to by an - * internal page. - * - * Parameters: - * t: tree - * pg: page number of first page in the chain. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -bt_preserve(t, pg) - BTREE *t; - pgno_t pg; -{ - PAGE *h; - - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - h->flags |= P_PRESERVE; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * REC_TOTAL -- Return the number of recno entries below a page. - * - * Parameters: - * h: page - * - * Returns: - * The number of recno entries below a page. - * - * XXX - * These values could be set by the bt_psplit routine. The problem is that the - * entry has to be popped off of the stack etc. or the values have to be passed - * all the way back to bt_split/bt_rroot and it's not very clean. - */ -static recno_t -rec_total(h) - PAGE *h; -{ - recno_t recs; - indx_t nxt, top; - - for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt) - recs += GETRINTERNAL(h, nxt)->nrecs; - return (recs); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c b/user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c deleted file mode 100644 index 9c1438e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/bt_utils.c +++ /dev/null @@ -1,260 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_utils.c 8.8 (Berkeley) 7/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __bt_ret -- - * Build return key/data pair. - * - * Parameters: - * t: tree - * e: key/data pair to be returned - * key: user's key structure (NULL if not to be filled in) - * rkey: memory area to hold key - * data: user's data structure (NULL if not to be filled in) - * rdata: memory area to hold data - * copy: always copy the key/data item - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_ret(t, e, key, rkey, data, rdata, copy) - BTREE *t; - EPG *e; - DBT *key, *rkey, *data, *rdata; - int copy; -{ - BLEAF *bl; - void *p; - - bl = GETBLEAF(e->page, e->index); - - /* - * We must copy big keys/data to make them contigous. Otherwise, - * leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - if (key == NULL) - goto dataonly; - - if (bl->flags & P_BIGKEY) { - if (__ovfl_get(t, bl->bytes, - &key->size, &rkey->data, &rkey->size)) - return (RET_ERROR); - key->data = rkey->data; - } else if (copy || F_ISSET(t, B_DB_LOCK)) { - if (bl->ksize > rkey->size) { - p = (void *)(rkey->data == NULL ? - malloc(bl->ksize) : realloc(rkey->data, bl->ksize)); - if (p == NULL) - return (RET_ERROR); - rkey->data = p; - rkey->size = bl->ksize; - } - memmove(rkey->data, bl->bytes, bl->ksize); - key->size = bl->ksize; - key->data = rkey->data; - } else { - key->size = bl->ksize; - key->data = bl->bytes; - } - -dataonly: - if (data == NULL) - return (RET_SUCCESS); - - if (bl->flags & P_BIGDATA) { - if (__ovfl_get(t, bl->bytes + bl->ksize, - &data->size, &rdata->data, &rdata->size)) - return (RET_ERROR); - data->data = rdata->data; - } else if (copy || F_ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (bl->dsize + 1 > rdata->size) { - p = (void *)(rdata->data == NULL ? - malloc(bl->dsize + 1) : - realloc(rdata->data, bl->dsize + 1)); - if (p == NULL) - return (RET_ERROR); - rdata->data = p; - rdata->size = bl->dsize + 1; - } - memmove(rdata->data, bl->bytes + bl->ksize, bl->dsize); - data->size = bl->dsize; - data->data = rdata->data; - } else { - data->size = bl->dsize; - data->data = bl->bytes + bl->ksize; - } - - return (RET_SUCCESS); -} - -/* - * __BT_CMP -- Compare a key to a given record. - * - * Parameters: - * t: tree - * k1: DBT pointer of first arg to comparison - * e: pointer to EPG for comparison - * - * Returns: - * < 0 if k1 is < record - * = 0 if k1 is = record - * > 0 if k1 is > record - */ -int -__bt_cmp(t, k1, e) - BTREE *t; - const DBT *k1; - EPG *e; -{ - BINTERNAL *bi; - BLEAF *bl; - DBT k2; - PAGE *h; - void *bigkey; - - /* - * The left-most key on internal pages, at any level of the tree, is - * guaranteed by the following code to be less than any user key. - * This saves us from having to update the leftmost key on an internal - * page when the user inserts a new key in the tree smaller than - * anything we've yet seen. - */ - h = e->page; - if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF)) - return (1); - - bigkey = NULL; - if (h->flags & P_BLEAF) { - bl = GETBLEAF(h, e->index); - if (bl->flags & P_BIGKEY) - bigkey = bl->bytes; - else { - k2.data = bl->bytes; - k2.size = bl->ksize; - } - } else { - bi = GETBINTERNAL(h, e->index); - if (bi->flags & P_BIGKEY) - bigkey = bi->bytes; - else { - k2.data = bi->bytes; - k2.size = bi->ksize; - } - } - - if (bigkey) { - if (__ovfl_get(t, bigkey, - &k2.size, &t->bt_rdata.data, &t->bt_rdata.size)) - return (RET_ERROR); - k2.data = t->bt_rdata.data; - } - return ((*t->bt_cmp)(k1, &k2)); -} - -/* - * __BT_DEFCMP -- Default comparison routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * < 0 if a is < b - * = 0 if a is = b - * > 0 if a is > b - */ -int -__bt_defcmp(a, b) - const DBT *a, *b; -{ - register size_t len; - register u_char *p1, *p2; - - /* - * XXX - * If a size_t doesn't fit in an int, this routine can lose. - * What we need is a integral type which is guaranteed to be - * larger than a size_t, and there is no such thing. - */ - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2) - if (*p1 != *p2) - return ((int)*p1 - (int)*p2); - return ((int)a->size - (int)b->size); -} - -/* - * __BT_DEFPFX -- Default prefix routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * Number of bytes needed to distinguish b from a. - */ -size_t -__bt_defpfx(a, b) - const DBT *a, *b; -{ - register u_char *p1, *p2; - register size_t cnt, len; - - cnt = 1; - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt) - if (*p1 != *p2) - return (cnt); - - /* a->size must be <= b->size, or they wouldn't be in this order. */ - return (a->size < b->size ? a->size + 1 : a->size); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/btree.h b/user/mpy/lib/berkeley-db-1.xx/btree/btree.h deleted file mode 100644 index af94ae6..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/btree.h +++ /dev/null @@ -1,384 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)btree.h 8.11 (Berkeley) 8/17/94 - */ - -/* Macros to set/clear/test flags. */ -#define F_SET(p, f) (p)->flags |= (f) -#define F_CLR(p, f) (p)->flags &= ~(f) -#define F_ISSET(p, f) ((p)->flags & (f)) - -#include - -#define DEFMINKEYPAGE (2) /* Minimum keys per page */ -#define MINCACHE (5) /* Minimum cached pages */ -#define MINPSIZE (512) /* Minimum page size */ -#define DEFPSIZE (4096) /* Default page size */ - -/* - * Page 0 of a btree file contains a copy of the meta-data. This page is also - * used as an out-of-band page, i.e. page pointers that point to nowhere point - * to page 0. Page 1 is the root of the btree. - */ -#define P_INVALID 0 /* Invalid tree page number. */ -#define P_META 0 /* Tree metadata page number. */ -#define P_ROOT 1 /* Tree root page number. */ - -/* - * There are five page layouts in the btree: btree internal pages (BINTERNAL), - * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages - * (RLEAF) and overflow pages. All five page types have a page header (PAGE). - * This implementation requires that values within structures NOT be padded. - * (ANSI C permits random padding.) If your compiler pads randomly you'll have - * to do some work to get this package to run. - */ -typedef struct _page { - pgno_t pgno; /* this page's page number */ - pgno_t prevpg; /* left sibling */ - pgno_t nextpg; /* right sibling */ - -#define P_BINTERNAL 0x01 /* btree internal page */ -#define P_BLEAF 0x02 /* leaf page */ -#define P_OVERFLOW 0x04 /* overflow page */ -#define P_RINTERNAL 0x08 /* recno internal page */ -#define P_RLEAF 0x10 /* leaf page */ -#define P_TYPE 0x1f /* type mask */ -#define P_PRESERVE 0x20 /* never delete this chain of pages */ - u_int32_t flags; - - indx_t lower; /* lower bound of free space on page */ - indx_t upper; /* upper bound of free space on page */ - indx_t linp[1]; /* indx_t-aligned VAR. LENGTH DATA */ -} PAGE; - -/* First and next index. */ -#define BTDATAOFF \ - (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ - sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t)) -#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) - -/* - * For pages other than overflow pages, there is an array of offsets into the - * rest of the page immediately following the page header. Each offset is to - * an item which is unique to the type of page. The h_lower offset is just - * past the last filled-in index. The h_upper offset is the first item on the - * page. Offsets are from the beginning of the page. - * - * If an item is too big to store on a single page, a flag is set and the item - * is a { page, size } pair such that the page is the first page of an overflow - * chain with size bytes of item. Overflow pages are simply bytes without any - * external structure. - * - * The page number and size fields in the items are pgno_t-aligned so they can - * be manipulated without copying. (This presumes that 32 bit items can be - * manipulated on this system.) - */ -#define LALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) -#define NOVFLSIZE (sizeof(pgno_t) + sizeof(u_int32_t)) - -/* - * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} - * pairs, such that the key compares less than or equal to all of the records - * on that page. For a tree without duplicate keys, an internal page with two - * consecutive keys, a and b, will have all records greater than or equal to a - * and less than b stored on the page associated with a. Duplicate keys are - * somewhat special and can cause duplicate internal and leaf page records and - * some minor modifications of the above rule. - */ -typedef struct _binternal { - u_int32_t ksize; /* key size */ - pgno_t pgno; /* page number stored on */ -#define P_BIGDATA 0x01 /* overflow data */ -#define P_BIGKEY 0x02 /* overflow key */ - u_char flags; - char bytes[1]; /* data */ -} BINTERNAL; - -/* Get the page's BINTERNAL structure at index indx. */ -#define GETBINTERNAL(pg, indx) \ - ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBINTERNAL(len) \ - LALIGN(sizeof(u_int32_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) - -/* Copy a BINTERNAL entry to the page. */ -#define WR_BINTERNAL(p, size, pgno, flags) { \ - *(u_int32_t *)p = size; \ - p += sizeof(u_int32_t); \ - *(pgno_t *)p = pgno; \ - p += sizeof(pgno_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ -} - -/* - * For the recno internal pages, the item is a page number with the number of - * keys found on that page and below. - */ -typedef struct _rinternal { - recno_t nrecs; /* number of records */ - pgno_t pgno; /* page number stored below */ -} RINTERNAL; - -/* Get the page's RINTERNAL structure at index indx. */ -#define GETRINTERNAL(pg, indx) \ - ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRINTERNAL \ - LALIGN(sizeof(recno_t) + sizeof(pgno_t)) - -/* Copy a RINTERAL entry to the page. */ -#define WR_RINTERNAL(p, nrecs, pgno) { \ - *(recno_t *)p = nrecs; \ - p += sizeof(recno_t); \ - *(pgno_t *)p = pgno; \ -} - -/* For the btree leaf pages, the item is a key and data pair. */ -typedef struct _bleaf { - u_int32_t ksize; /* size of key */ - u_int32_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA, P_BIGKEY */ - char bytes[1]; /* data */ -} BLEAF; - -/* Get the page's BLEAF structure at index indx. */ -#define GETBLEAF(pg, indx) \ - ((BLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) - -/* Get the number of bytes in the user's key/data pair. */ -#define NBLEAFDBT(ksize, dsize) \ - LALIGN(sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_char) + \ - (ksize) + (dsize)) - -/* Copy a BLEAF entry to the page. */ -#define WR_BLEAF(p, key, data, flags) { \ - *(u_int32_t *)p = key->size; \ - p += sizeof(u_int32_t); \ - *(u_int32_t *)p = data->size; \ - p += sizeof(u_int32_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, key->data, key->size); \ - p += key->size; \ - memmove(p, data->data, data->size); \ -} - -/* For the recno leaf pages, the item is a data entry. */ -typedef struct _rleaf { - u_int32_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA */ - char bytes[1]; -} RLEAF; - -/* Get the page's RLEAF structure at index indx. */ -#define GETRLEAF(pg, indx) \ - ((RLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRLEAF(p) NRLEAFDBT((p)->dsize) - -/* Get the number of bytes from the user's data. */ -#define NRLEAFDBT(dsize) \ - LALIGN(sizeof(u_int32_t) + sizeof(u_char) + (dsize)) - -/* Copy a RLEAF entry to the page. */ -#define WR_RLEAF(p, data, flags) { \ - *(u_int32_t *)p = data->size; \ - p += sizeof(u_int32_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, data->data, data->size); \ -} - -/* - * A record in the tree is either a pointer to a page and an index in the page - * or a page number and an index. These structures are used as a cursor, stack - * entry and search returns as well as to pass records to other routines. - * - * One comment about searches. Internal page searches must find the largest - * record less than key in the tree so that descents work. Leaf page searches - * must find the smallest record greater than key so that the returned index - * is the record's correct position for insertion. - */ -typedef struct _epgno { - pgno_t pgno; /* the page number */ - indx_t index; /* the index on the page */ -} EPGNO; - -typedef struct _epg { - PAGE *page; /* the (pinned) page */ - indx_t index; /* the index on the page */ -} EPG; - -/* - * About cursors. The cursor (and the page that contained the key/data pair - * that it referenced) can be deleted, which makes things a bit tricky. If - * there are no duplicates of the cursor key in the tree (i.e. B_NODUPS is set - * or there simply aren't any duplicates of the key) we copy the key that it - * referenced when it's deleted, and reacquire a new cursor key if the cursor - * is used again. If there are duplicates keys, we move to the next/previous - * key, and set a flag so that we know what happened. NOTE: if duplicate (to - * the cursor) keys are added to the tree during this process, it is undefined - * if they will be returned or not in a cursor scan. - * - * The flags determine the possible states of the cursor: - * - * CURS_INIT The cursor references *something*. - * CURS_ACQUIRE The cursor was deleted, and a key has been saved so that - * we can reacquire the right position in the tree. - * CURS_AFTER, CURS_BEFORE - * The cursor was deleted, and now references a key/data pair - * that has not yet been returned, either before or after the - * deleted key/data pair. - * XXX - * This structure is broken out so that we can eventually offer multiple - * cursors as part of the DB interface. - */ -typedef struct _cursor { - EPGNO pg; /* B: Saved tree reference. */ - DBT key; /* B: Saved key, or key.data == NULL. */ - recno_t rcursor; /* R: recno cursor (1-based) */ - -#define CURS_ACQUIRE 0x01 /* B: Cursor needs to be reacquired. */ -#define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ -#define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ -#define CURS_INIT 0x08 /* RB: Cursor initialized. */ - u_int8_t flags; -} CURSOR; - -/* - * The metadata of the tree. The nrecs field is used only by the RECNO code. - * This is because the btree doesn't really need it and it requires that every - * put or delete call modify the metadata. - */ -typedef struct _btmeta { - u_int32_t magic; /* magic number */ - u_int32_t version; /* version */ - u_int32_t psize; /* page size */ - u_int32_t free; /* page number of first free page */ - u_int32_t nrecs; /* R: number of records */ - -#define SAVEMETA (B_NODUPS | R_RECNO) - u_int32_t flags; /* bt_flags & SAVEMETA */ -} BTMETA; - -/* The in-memory btree/recno data structure. */ -typedef struct _btree { - MPOOL *bt_mp; /* memory pool cookie */ - - DB *bt_dbp; /* pointer to enclosing DB */ - - EPG bt_cur; /* current (pinned) page */ - PAGE *bt_pinned; /* page pinned across calls */ - - CURSOR bt_cursor; /* cursor */ - -#define BT_PUSH(t, p, i) { \ - t->bt_sp->pgno = p; \ - t->bt_sp->index = i; \ - ++t->bt_sp; \ -} -#define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL : --t->bt_sp) -#define BT_CLR(t) (t->bt_sp = t->bt_stack) - EPGNO bt_stack[50]; /* stack of parent pages */ - EPGNO *bt_sp; /* current stack pointer */ - - DBT bt_rkey; /* returned key */ - DBT bt_rdata; /* returned data */ - - virt_fd_t bt_fd; /* tree virtual file descriptor */ - - pgno_t bt_free; /* next free page */ - u_int32_t bt_psize; /* page size */ - indx_t bt_ovflsize; /* cut-off for key/data overflow */ - int bt_lorder; /* byte order */ - /* sorted order */ - enum { NOT, BACK, FORWARD } bt_order; - EPGNO bt_last; /* last insert */ - - /* B: key comparison function */ - int (*bt_cmp) __P((const DBT *, const DBT *)); - /* B: prefix comparison function */ - size_t (*bt_pfx) __P((const DBT *, const DBT *)); - /* R: recno input function */ - int (*bt_irec) __P((struct _btree *, recno_t)); - - FILE *bt_rfp; /* R: record FILE pointer */ - int bt_rfd; /* R: record file descriptor */ - - caddr_t bt_cmap; /* R: current point in mapped space */ - caddr_t bt_smap; /* R: start of mapped space */ - caddr_t bt_emap; /* R: end of mapped space */ - size_t bt_msize; /* R: size of mapped region. */ - - recno_t bt_nrecs; /* R: number of records */ - size_t bt_reclen; /* R: fixed record length */ - u_char bt_bval; /* R: delimiting byte/pad character */ - -/* - * NB: - * B_NODUPS and R_RECNO are stored on disk, and may not be changed. - */ -#define B_INMEM 0x00001 /* in-memory tree */ -#define B_METADIRTY 0x00002 /* need to write metadata */ -#define B_MODIFIED 0x00004 /* tree modified */ -#define B_NEEDSWAP 0x00008 /* if byte order requires swapping */ -#define B_RDONLY 0x00010 /* read-only tree */ - -#define B_NODUPS 0x00020 /* no duplicate keys permitted */ -#define R_RECNO 0x00080 /* record oriented tree */ - -#define R_CLOSEFP 0x00040 /* opened a file pointer */ -#define R_EOF 0x00100 /* end of input file reached. */ -#define R_FIXLEN 0x00200 /* fixed length records */ -#define R_MEMMAPPED 0x00400 /* memory mapped file. */ -#define R_INMEM 0x00800 /* in-memory file */ -#define R_MODIFIED 0x01000 /* modified file */ -#define R_RDONLY 0x02000 /* read-only file */ - -#define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ -#define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ -#define B_DB_TXN 0x10000 /* DB_TXN specified. */ - u_int32_t flags; -} BTREE; - -#include "extern.h" diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/extern.h b/user/mpy/lib/berkeley-db-1.xx/btree/extern.h deleted file mode 100644 index ebd9c54..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/extern.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.10 (Berkeley) 7/20/94 - */ - -int __bt_close __P((DB *)); -int __bt_cmp __P((BTREE *, const DBT *, EPG *)); -int __bt_crsrdel __P((BTREE *, EPGNO *)); -int __bt_defcmp __P((const DBT *, const DBT *)); -size_t __bt_defpfx __P((const DBT *, const DBT *)); -int __bt_delete __P((const DB *, const DBT *, u_int)); -int __bt_dleaf __P((BTREE *, const DBT *, PAGE *, u_int)); -int __bt_fd __P((const DB *)); -int __bt_free __P((BTREE *, PAGE *)); -int __bt_get __P((const DB *, const DBT *, DBT *, u_int)); -PAGE *__bt_new __P((BTREE *, pgno_t *)); -void __bt_pgin __P((void *, pgno_t, void *)); -void __bt_pgout __P((void *, pgno_t, void *)); -int __bt_push __P((BTREE *, pgno_t, int)); -int __bt_put __P((const DB *dbp, DBT *, const DBT *, u_int)); -int __bt_ret __P((BTREE *, EPG *, DBT *, DBT *, DBT *, DBT *, int)); -EPG *__bt_search __P((BTREE *, const DBT *, int *)); -int __bt_seq __P((const DB *, DBT *, DBT *, u_int)); -void __bt_setcur __P((BTREE *, pgno_t, u_int)); -int __bt_split __P((BTREE *, PAGE *, - const DBT *, const DBT *, int, size_t, u_int32_t)); -int __bt_sync __P((const DB *, u_int)); - -int __ovfl_delete __P((BTREE *, void *)); -int __ovfl_get __P((BTREE *, void *, size_t *, void **, size_t *)); -int __ovfl_put __P((BTREE *, const DBT *, pgno_t *)); - -#ifdef DEBUG -void __bt_dnpage __P((DB *, pgno_t)); -void __bt_dpage __P((PAGE *)); -void __bt_dump __P((DB *)); -#endif -#ifdef STATISTICS -void __bt_stat __P((DB *)); -#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/btree/tags b/user/mpy/lib/berkeley-db-1.xx/btree/tags deleted file mode 120000 index 7ab656b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/btree/tags +++ /dev/null @@ -1 +0,0 @@ -../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/changelog b/user/mpy/lib/berkeley-db-1.xx/changelog deleted file mode 100644 index 1540ca8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/changelog +++ /dev/null @@ -1,103 +0,0 @@ -1.84 -> 1.85 - recno: #ifdef out use of mmap, it's not portable enough. - -1.83 -> 1.84 Thu Aug 18 15:46:07 EDT 1994 - recno: Rework fixed-length records so that closing and reopening - the file now works. Pad short records on input. Never do - signed comparison in recno input reading functions. - -1.82 -> 1.83 Tue Jul 26 15:33:44 EDT 1994 - btree: Rework cursor deletion code yet again; bugs with - deleting empty pages that only contained the cursor - record. - -1.81 -> 1.82 Sat Jul 16 11:01:50 EDT 1994 - btree: Fix bugs introduced by new cursor/deletion code. - Replace return kbuf/dbuf with real DBT's. - -1.80 -> 1.81 - btree: Fix bugs introduced by new cursor/deletion code. - all: Add #defines for Purify. - -1.79 -> 1.80 Wed Jul 13 22:41:54 EDT 1994 - btree Change deletion to coalesce empty pages. This is a major - change, cursors and duplicate pages all had to be reworked. - Return to a fixed stack. - recno: Affected by cursor changes. New cursor structures should - permit multiple cursors in the future. - -1.78 -> 1.79 Mon Jun 20 17:36:47 EDT 1994 - all: Minor cleanups of 1.78 for porting reasons; only - major change was inlining check of NULL pointer - so that __fix_realloc goes away. - -1.77 -> 1.78 Thu Jun 16 19:06:43 EDT 1994 - all: Move "standard" size typedef's into db.h. - -1.76 -> 1.77 Thu Jun 16 16:48:38 EDT 1994 - hash: Delete __init_ routine, has special meaning to OSF 2.0. - -1.74 -> 1.76 - all: Finish up the port to the Alpha. - -1.73 -> 1.74 - recno: Don't put the record if rec_search fails, in rec_rdelete. - Create fixed-length intermediate records past "end" of DB - correctly. - Realloc bug when reading in fixed records. - all: First cut at port to Alpha (64-bit architecture) using - 4.4BSD basic integral types typedef's. - Cast allocation pointers to shut up old compilers. - Rework PORT directory into OS/machine directories. - -1.72 -> 1.73 - btree: If enough duplicate records were inserted and then deleted - that internal pages had references to empty pages of the - duplicate keys, the search function ended up on the wrong - page. - -1.7 -> 1.72 12 Oct 1993 - hash: Support NET/2 hash formats. - -1.7 -> 1.71 16 Sep 1993 - btree/recno: - Fix bug in internal search routines that caused - return of invalid pointers. - -1.6 -> 1.7 07 Sep 1993 - hash: Fixed big key overflow bugs. - test: Portability hacks, rewrite test script, Makefile. - btree/recno: - Stop copying non-overflow key/data pairs. - PORT: Break PORT directory up into per architecture/OS - subdirectories. - -1.5 -> 1.6 06 Jun 1993 - hash: In PAIRFITS, the first comparison should look at (P)[2]. - The hash_realloc function was walking off the end of memory. - The overflow page number was wrong when bumping splitpoint. - -1.4 -> 1.5 23 May 1993 - hash: Set hash default fill factor dynamically. - recno: Fixed bug in sorted page splits. - Add page size parameter support. - Allow recno to specify the name of the underlying btree; - used for vi recovery. - btree/recno: - Support 64K pages. - btree/hash/recno: - Provide access to an underlying file descriptor. - Change sync routines to take a flag argument, recno - uses this to sync out the underlying btree. - -1.3 -> 1.4 10 May 1993 - recno: Delete the R_CURSORLOG flag from the recno interface. - Zero-length record fix for non-mmap reads. - Try and make SIZE_T_MAX test in open portable. - -1.2 -> 1.3 01 May 1993 - btree: Ignore user byte-order setting when reading already - existing database. Fixes to byte-order conversions. - -1.1 -> 1.2 15 Apr 1993 - No bug fixes, only compatibility hacks. diff --git a/user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc deleted file mode 100644 index 59478ba..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/db/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/db - -SRCS+= db.c diff --git a/user/mpy/lib/berkeley-db-1.xx/db/db.c b/user/mpy/lib/berkeley-db-1.xx/db/db.c deleted file mode 100644 index a18f056..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/db/db.c +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include - -DB * -dbopen(fname, flags, mode, type, openinfo) - const char *fname; - int flags, mode; - DBTYPE type; - const void *openinfo; -{ - -#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) -#define USE_OPEN_FLAGS \ - (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \ - O_RDWR | O_SHLOCK | O_TRUNC) - - if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) - switch (type) { - case DB_BTREE: - return (__bt_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - case DB_HASH: - return (__hash_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - case DB_RECNO: - return (__rec_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - } - errno = EINVAL; - return (NULL); -} - -static int -__dberr() -{ - return (RET_ERROR); -} - -/* - * __DBPANIC -- Stop. - * - * Parameters: - * dbp: pointer to the DB structure. - */ -void -__dbpanic(dbp) - DB *dbp; -{ - /* The only thing that can succeed is a close. */ - dbp->del = (int (*)())__dberr; - dbp->fd = (int (*)())__dberr; - dbp->get = (int (*)())__dberr; - dbp->put = (int (*)())__dberr; - dbp->seq = (int (*)())__dberr; - dbp->sync = (int (*)())__dberr; -} diff --git a/user/mpy/lib/berkeley-db-1.xx/db/tags b/user/mpy/lib/berkeley-db-1.xx/db/tags deleted file mode 100644 index f9c1143..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/db/tags +++ /dev/null @@ -1,205 +0,0 @@ -BT_CLR ../btree/btree.h /^#define BT_CLR(t) (t->bt_sp = t->bt_stack)$/ -BT_POP ../btree/btree.h /^#define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL / -BT_PUSH ../btree/btree.h /^#define BT_PUSH(t, p, i) { \\$/ -BUCKET_TO_PAGE ../hash/hash.h /^#define BUCKET_TO_PAGE(B) \\$/ -BUF_INSERT ../hash/hash_buf.c /^#define BUF_INSERT(B, P) { \\$/ -BUF_REMOVE ../hash/hash_buf.c /^#define BUF_REMOVE(B) { \\$/ -CLRBIT ../hash/hash.h /^#define CLRBIT(A, N) ((A)[(N)\/BITS_PER_MAP] &= ~(/ -DODISK ../hash/hash.h /^#define DODISK(X) ((X) = (char *)((ptrdiff_t)(X)|0/ -DOMOD ../hash/hash.h /^#define DOMOD(X) ((X) = (char *)((ptrdiff_t)(X)|0x/ -FREESPACE ../hash/page.h /^#define FREESPACE(P) ((P)[(P)[0]+1])$/ -F_CLR ../btree/btree.h /^#define F_CLR(p, f) (p)->flags &= ~(f)$/ -F_ISSET ../btree/btree.h /^#define F_ISSET(p, f) ((p)->flags & (f))$/ -F_SET ../btree/btree.h /^#define F_SET(p, f) (p)->flags |= (f)$/ -GETBINTERNAL ../btree/btree.h /^#define GETBINTERNAL(pg, indx) \\$/ -GETBLEAF ../btree/btree.h /^#define GETBLEAF(pg, indx) \\$/ -GETRINTERNAL ../btree/btree.h /^#define GETRINTERNAL(pg, indx) \\$/ -GETRLEAF ../btree/btree.h /^#define GETRLEAF(pg, indx) \\$/ -HASHKEY ../include/mpool.h /^#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE)$/ -ISDISK ../hash/hash.h /^#define ISDISK(X) ((u_int32_t)(ptrdiff_t)(X)&0x2)$/ -ISMOD ../hash/hash.h /^#define ISMOD(X) ((u_int32_t)(ptrdiff_t)(X)&0x1)$/ -ISSET ../hash/hash.h /^#define ISSET(A, N) ((A)[(N)\/BITS_PER_MAP] & (1<siz/ -LALIGN ../btree/btree.h /^#define LALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(/ -LRU_INSERT ../hash/hash_buf.c /^#define LRU_INSERT(B) BUF_INSERT((B), LRU)$/ -MOD ../hash/hash.c /^#define MOD(x, y) ((x) & ((y) - 1))$/ -MRU_INSERT ../hash/hash_buf.c /^#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufh/ -M_16_SWAP ../include/db.h /^#define M_16_SWAP(a) { \\$/ -M_32_SWAP ../include/db.h /^#define M_32_SWAP(a) { \\$/ -NBINTERNAL ../btree/btree.h /^#define NBINTERNAL(len) \\$/ -NBLEAF ../btree/btree.h /^#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize/ -NBLEAFDBT ../btree/btree.h /^#define NBLEAFDBT(ksize, dsize) \\$/ -NEXTINDEX ../btree/btree.h /^#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) \/ / -NRLEAF ../btree/btree.h /^#define NRLEAF(p) NRLEAFDBT((p)->dsize)$/ -NRLEAFDBT ../btree/btree.h /^#define NRLEAFDBT(dsize) \\$/ -OADDR_OF ../hash/hash.h /^#define OADDR_OF(S,O) ((u_int32_t)((u_int32_t)(S) / -OADDR_TO_PAGE ../hash/hash.h /^#define OADDR_TO_PAGE(B) \\$/ -OFFSET ../hash/page.h /^#define OFFSET(P) ((P)[(P)[0]+2])$/ -OPAGENUM ../hash/hash.h /^#define OPAGENUM(N) ((N) & SPLITMASK)$/ -PAGE_INIT ../hash/hash_page.c /^#define PAGE_INIT(P) { \\$/ -PAGE_META ../hash/page.h /^#define PAGE_META(N) (((N)+3) * sizeof(u_int16_t))/ -PAIRFITS ../hash/page.h /^#define PAIRFITS(P,K,D) \\$/ -PAIRSIZE ../hash/page.h /^#define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->/ -PTROF ../hash/hash.h /^#define PTROF(X) ((BUFHEAD *)((ptrdiff_t)(X)&~0x3)/ -P_16_COPY ../include/db.h /^#define P_16_COPY(a, b) { \\$/ -P_16_SWAP ../include/db.h /^#define P_16_SWAP(a) { \\$/ -P_32_COPY ../include/db.h /^#define P_32_COPY(a, b) { \\$/ -P_32_SWAP ../include/db.h /^#define P_32_SWAP(a) { \\$/ -RETURN_ERROR ../hash/hash.c /^#define RETURN_ERROR(ERR, LOC) { save_errno = ERR;/ -SETBIT ../hash/hash.h /^#define SETBIT(A, N) ((A)[(N)\/BITS_PER_MAP] |= (1/ -SPLITNUM ../hash/hash.h /^#define SPLITNUM(N) (((u_int32_t)(N)) >> SPLITSHIF/ -WR_BINTERNAL ../btree/btree.h /^#define WR_BINTERNAL(p, size, pgno, flags) { \\/ -WR_BLEAF ../btree/btree.h /^#define WR_BLEAF(p, key, data, flags) { \\$/ -WR_RINTERNAL ../btree/btree.h /^#define WR_RINTERNAL(p, nrecs, pgno) { \\$/ -WR_RLEAF ../btree/btree.h /^#define WR_RLEAF(p, data, flags) { \\$/ -X ../btree/bt_debug.c /^#define X(flag, name) \\$/ -__add_ovflpage ../hash/hash_page.c /^__add_ovflpage(hashp, bufp)$/ -__addel ../hash/hash_page.c /^__addel(hashp, bufp, key, val)$/ -__big_delete ../hash/hash_bigkey.c /^__big_delete(hashp, bufp)$/ -__big_insert ../hash/hash_bigkey.c /^__big_insert(hashp, bufp, key, val)$/ -__big_keydata ../hash/hash_bigkey.c /^__big_keydata(hashp, bufp, key, val, set)$/ -__big_return ../hash/hash_bigkey.c /^__big_return(hashp, bufp, ndx, val, set_current)$/ -__big_split ../hash/hash_bigkey.c /^__big_split(hashp, op, np, big_keyp, addr, obucket/ -__bt_bdelete ../btree/bt_delete.c /^__bt_bdelete(t, key)$/ -__bt_close ../btree/bt_close.c /^__bt_close(dbp)$/ -__bt_cmp ../btree/bt_utils.c /^__bt_cmp(t, k1, e)$/ -__bt_curdel ../btree/bt_delete.c /^__bt_curdel(t, key, h, index)$/ -__bt_defcmp ../btree/bt_utils.c /^__bt_defcmp(a, b)$/ -__bt_defpfx ../btree/bt_utils.c /^__bt_defpfx(a, b)$/ -__bt_delete ../btree/bt_delete.c /^__bt_delete(dbp, key, flags)$/ -__bt_dleaf ../btree/bt_delete.c /^__bt_dleaf(t, key, h, index)$/ -__bt_dmpage ../btree/bt_debug.c /^__bt_dmpage(h)$/ -__bt_dnpage ../btree/bt_debug.c /^__bt_dnpage(dbp, pgno)$/ -__bt_dpage ../btree/bt_debug.c /^__bt_dpage(h)$/ -__bt_dump ../btree/bt_debug.c /^__bt_dump(dbp)$/ -__bt_fd ../btree/bt_open.c /^__bt_fd(dbp)$/ -__bt_first ../btree/bt_seq.c /^__bt_first(t, key, erval, exactp)$/ -__bt_free ../btree/bt_page.c /^__bt_free(t, h)$/ -__bt_get ../btree/bt_get.c /^__bt_get(dbp, key, data, flags)$/ -__bt_new ../btree/bt_page.c /^__bt_new(t, npg)$/ -__bt_open ../btree/bt_open.c /^__bt_open(fname, flags, mode, openinfo, dflags)$/ -__bt_pdelete ../btree/bt_delete.c /^__bt_pdelete(t, h)$/ -__bt_pgin ../btree/bt_conv.c /^__bt_pgin(t, pg, pp)$/ -__bt_pgout ../btree/bt_conv.c /^__bt_pgout(t, pg, pp)$/ -__bt_put ../btree/bt_put.c /^__bt_put(dbp, key, data, flags)$/ -__bt_relink ../btree/bt_delete.c /^__bt_relink(t, h)$/ -__bt_ret ../btree/bt_utils.c /^__bt_ret(t, e, key, rkey, data, rdata, copy)$/ -__bt_search ../btree/bt_search.c /^__bt_search(t, key, exactp)$/ -__bt_seq ../btree/bt_seq.c /^__bt_seq(dbp, key, data, flags)$/ -__bt_seqadv ../btree/bt_seq.c /^__bt_seqadv(t, ep, flags)$/ -__bt_seqset ../btree/bt_seq.c /^__bt_seqset(t, ep, key, flags)$/ -__bt_setcur ../btree/bt_seq.c /^__bt_setcur(t, pgno, index)$/ -__bt_snext ../btree/bt_search.c /^__bt_snext(t, h, key, exactp)$/ -__bt_split ../btree/bt_split.c /^__bt_split(t, sp, key, data, flags, ilen, argskip)/ -__bt_sprev ../btree/bt_search.c /^__bt_sprev(t, h, key, exactp)$/ -__bt_stat ../btree/bt_debug.c /^__bt_stat(dbp)$/ -__bt_stkacq ../btree/bt_delete.c /^__bt_stkacq(t, hp, c)$/ -__bt_sync ../btree/bt_close.c /^__bt_sync(dbp, flags)$/ -__buf_free ../hash/hash_buf.c /^__buf_free(hashp, do_free, to_disk)$/ -__buf_init ../hash/hash_buf.c /^__buf_init(hashp, nbytes)$/ -__call_hash ../hash/hash.c /^__call_hash(hashp, k, len)$/ -__dberr ../db/db.c /^__dberr()$/ -__dbpanic ../db/db.c /^__dbpanic(dbp)$/ -__delpair ../hash/hash_page.c /^__delpair(hashp, bufp, ndx)$/ -__expand_table ../hash/hash.c /^__expand_table(hashp)$/ -__find_bigpair ../hash/hash_bigkey.c /^__find_bigpair(hashp, bufp, ndx, key, size)$/ -__find_last_page ../hash/hash_bigkey.c /^__find_last_page(hashp, bpp)$/ -__free_ovflpage ../hash/hash_page.c /^__free_ovflpage(hashp, obufp)$/ -__get_buf ../hash/hash_buf.c /^__get_buf(hashp, addr, prev_bp, newpage)$/ -__get_page ../hash/hash_page.c /^__get_page(hashp, p, bucket, is_bucket, is_disk, i/ -__hash_open ../hash/hash.c /^__hash_open(file, flags, mode, info, dflags)$/ -__ibitmap ../hash/hash_page.c /^__ibitmap(hashp, pnum, nbits, ndx)$/ -__log2 ../hash/hash_log2.c /^__log2(num)$/ -__ovfl_delete ../btree/bt_overflow.c /^__ovfl_delete(t, p)$/ -__ovfl_get ../btree/bt_overflow.c /^__ovfl_get(t, p, ssz, buf, bufsz)$/ -__ovfl_put ../btree/bt_overflow.c /^__ovfl_put(t, dbt, pg)$/ -__put_page ../hash/hash_page.c /^__put_page(hashp, p, bucket, is_bucket, is_bitmap)/ -__rec_close ../recno/rec_close.c /^__rec_close(dbp)$/ -__rec_delete ../recno/rec_delete.c /^__rec_delete(dbp, key, flags)$/ -__rec_dleaf ../recno/rec_delete.c /^__rec_dleaf(t, h, index)$/ -__rec_fd ../recno/rec_open.c /^__rec_fd(dbp)$/ -__rec_fmap ../recno/rec_get.c /^__rec_fmap(t, top)$/ -__rec_fpipe ../recno/rec_get.c /^__rec_fpipe(t, top)$/ -__rec_get ../recno/rec_get.c /^__rec_get(dbp, key, data, flags)$/ -__rec_iput ../recno/rec_put.c /^__rec_iput(t, nrec, data, flags)$/ -__rec_open ../recno/rec_open.c /^__rec_open(fname, flags, mode, openinfo, dflags)$/ -__rec_put ../recno/rec_put.c /^__rec_put(dbp, key, data, flags)$/ -__rec_ret ../recno/rec_utils.c /^__rec_ret(t, e, nrec, key, data)$/ -__rec_search ../recno/rec_search.c /^__rec_search(t, recno, op)$/ -__rec_seq ../recno/rec_seq.c /^__rec_seq(dbp, key, data, flags)$/ -__rec_sync ../recno/rec_close.c /^__rec_sync(dbp, flags)$/ -__rec_vmap ../recno/rec_get.c /^__rec_vmap(t, top)$/ -__rec_vpipe ../recno/rec_get.c /^__rec_vpipe(t, top)$/ -__reclaim_buf ../hash/hash_buf.c /^__reclaim_buf(hashp, bp)$/ -__split_page ../hash/hash_page.c /^__split_page(hashp, obucket, nbucket)$/ -alloc_segs ../hash/hash.c /^alloc_segs(hashp, nsegs)$/ -bt_broot ../btree/bt_split.c /^bt_broot(t, h, l, r)$/ -bt_fast ../btree/bt_put.c /^bt_fast(t, key, data, exactp)$/ -bt_meta ../btree/bt_close.c /^bt_meta(t)$/ -bt_page ../btree/bt_split.c /^bt_page(t, h, lp, rp, skip, ilen)$/ -bt_preserve ../btree/bt_split.c /^bt_preserve(t, pg)$/ -bt_psplit ../btree/bt_split.c /^bt_psplit(t, h, l, r, pskip, ilen)$/ -bt_root ../btree/bt_split.c /^bt_root(t, h, lp, rp, skip, ilen)$/ -bt_rroot ../btree/bt_split.c /^bt_rroot(t, h, l, r)$/ -byteorder ../btree/bt_open.c /^byteorder()$/ -collect_data ../hash/hash_bigkey.c /^collect_data(hashp, bufp, len, set)$/ -collect_key ../hash/hash_bigkey.c /^collect_key(hashp, bufp, len, val, set)$/ -dbm_clearerr ../hash/ndbm.c /^dbm_clearerr(db)$/ -dbm_close ../hash/ndbm.c /^dbm_close(db)$/ -dbm_delete ../hash/ndbm.c /^dbm_delete(db, key)$/ -dbm_dirfno ../hash/ndbm.c /^dbm_dirfno(db)$/ -dbm_error ../hash/ndbm.c /^dbm_error(db)$/ -dbm_fetch ../hash/ndbm.c /^dbm_fetch(db, key)$/ -dbm_firstkey ../hash/ndbm.c /^dbm_firstkey(db)$/ -dbm_nextkey ../hash/ndbm.c /^dbm_nextkey(db)$/ -dbm_open ../hash/ndbm.c /^dbm_open(file, flags, mode)$/ -dbm_store ../hash/ndbm.c /^dbm_store(db, key, content, flags)$/ -dbopen ../db/db.c /^dbopen(fname, flags, mode, type, openinfo)$/ -dcharhash ../hash/hash_func.c /^#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x/ -fetch_bitmap ../hash/hash_page.c /^fetch_bitmap(hashp, ndx)$/ -first_free ../hash/hash_page.c /^first_free(map)$/ -flush_meta ../hash/hash.c /^flush_meta(hashp)$/ -hash2 ../hash/hash_func.c /^hash2(keyarg, len)$/ -hash3 ../hash/hash_func.c /^hash3(keyarg, len)$/ -hash4 ../hash/hash_func.c /^hash4(keyarg, len)$/ -hash_access ../hash/hash.c /^hash_access(hashp, action, key, val)$/ -hash_close ../hash/hash.c /^hash_close(dbp)$/ -hash_delete ../hash/hash.c /^hash_delete(dbp, key, flag)$/ -hash_fd ../hash/hash.c /^hash_fd(dbp)$/ -hash_get ../hash/hash.c /^hash_get(dbp, key, data, flag)$/ -hash_put ../hash/hash.c /^hash_put(dbp, key, data, flag)$/ -hash_realloc ../hash/hash.c /^hash_realloc(p_ptr, oldsize, newsize)$/ -hash_seq ../hash/hash.c /^hash_seq(dbp, key, data, flag)$/ -hash_sync ../hash/hash.c /^hash_sync(dbp, flags)$/ -hcreate ../hash/hsearch.c /^hcreate(nel)$/ -hdestroy ../hash/hash.c /^hdestroy(hashp)$/ -hsearch ../hash/hsearch.c /^hsearch(item, action)$/ -init_hash ../hash/hash.c /^init_hash(hashp, file, info)$/ -init_htab ../hash/hash.c /^init_htab(hashp, nelem)$/ -mpool_bkt ../mpool/mpool.c /^mpool_bkt(mp)$/ -mpool_close ../mpool/mpool.c /^mpool_close(mp)$/ -mpool_filter ../mpool/mpool.c /^mpool_filter(mp, pgin, pgout, pgcookie)$/ -mpool_get ../mpool/mpool.c /^mpool_get(mp, pgno, flags)$/ -mpool_look ../mpool/mpool.c /^mpool_look(mp, pgno)$/ -mpool_new ../mpool/mpool.c /^mpool_new(mp, pgnoaddr)$/ -mpool_open ../mpool/mpool.c /^mpool_open(key, fd, pagesize, maxcache)$/ -mpool_put ../mpool/mpool.c /^mpool_put(mp, page, flags)$/ -mpool_stat ../mpool/mpool.c /^mpool_stat(mp)$/ -mpool_sync ../mpool/mpool.c /^mpool_sync(mp)$/ -mpool_write ../mpool/mpool.c /^mpool_write(mp, bp)$/ -mswap ../btree/bt_conv.c /^mswap(pg)$/ -newbuf ../hash/hash_buf.c /^newbuf(hashp, addr, prev_bp)$/ -nroot ../btree/bt_open.c /^nroot(t)$/ -open_temp ../hash/hash_page.c /^open_temp(hashp)$/ -overflow_page ../hash/hash_page.c /^overflow_page(hashp)$/ -print_chain ../hash/hash_page.c /^print_chain(addr)$/ -putpair ../hash/hash_page.c /^putpair(p, key, val)$/ -rec_rdelete ../recno/rec_delete.c /^rec_rdelete(t, nrec)$/ -rec_total ../btree/bt_split.c /^rec_total(h)$/ -squeeze_key ../hash/hash_page.c /^squeeze_key(sp, key, val)$/ -swap_header ../hash/hash.c /^swap_header(hashp)$/ -swap_header_copy ../hash/hash.c /^swap_header_copy(srcp, destp)$/ -tmp ../btree/bt_open.c /^tmp()$/ -u_int32_t ../hash/extern.h /^extern u_int32_t (*__default_hash) __P((const void/ -ugly_split ../hash/hash_page.c /^ugly_split(hashp, obucket, old_bufp, new_bufp, cop/ diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/btree.3.ps deleted file mode 100644 index c79c97232ccc4cf3e96fc896cba56020878922a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16754 zcmd6vTXW;am4M&zE3mbdGMJSJ0=(O))XqqhtawJ!h?-;_kIMl`kc0;$XaJN(R{6j0 zcTP7zNFyh+Re9KlcnF~T^toSK`NMx)Pmf z=kG4cC{5-KsMGy!mnKi(?(%G2#HC=fD-;V?u)K~|a%yOQUge7zlwTF|cq_+T0X35qrI$=@#X})%&XCF?h4+^C3h6YCT5|9aN z^G$Xamznzv%vs~p7oc;g5EX`bbhD| z#pz&p*6y5t(@AN37pGus%=>0Ct$tp=seZj_ygPq%Rz-9dyW9AF7nN&wo+dl}A^(}p zvQK!%xWHk@jKRUieK!J+S34~o~vW@4_?(pz)hG!avt{}Kb z?$lis^C*p-H`7OFjH}3Sud(ynBTNEy9PGA8^-Z#j(;@~GF3W6bpfCXii$R69IGY{r zyou@Qt4A1aD30>^)-B3B`}kzZ^zso$%c;vO-#G2C?-u)+A-nnDrk9Sf5&0#2694!aHm4^CgwdKo#|3SKl@+lFs!7}JTXz$cdGg7q!0F`C z;gt;`_KOIvW~t#~tpTDu?LPnc{1o6IOar5NVbo zp|`ibbrXkmCvW_ky2jEoIA%#%<u$61F%aPshE41>arY4wwHq!@ z;qD{W@Y|!<5C3DWYVmJqSCpoXKiST+g@k?Mh%g*H&Ecr}ttDP#Jh_O-7%J2OJ+sEs z$ysgalh>2;3l!RFntn1^Hnedvxjgj+=7CQqm$#MIP^${6r)vw)m^+3jK19sD)+$HL zx^{2!pfnhZ6=$c9^^e28PAx+H^_lBXiQyHj0M(NO`nXBT7>(l}=Z7El&4P@@5m6hR zixxlci?W$nEhBu1fNCx<2^BBNR`Ok*ka;$ev3g7WRo7d0;`qX|IZmMz85JejoHAx# z#JNh%W@VLIdi+h;))2!rVnE5$ILe)8a0E17=n*0Pmd861Y2)mOA=XD9;8^8Q>R(7H zp{`0NC4JP?wMtHTy4cRs{UWa3yqJIgvo$sy|7S~Vc5d=kWs0wQ8Q26iUb+W8_4kkM zPA70T`?My}g+yNh2yp}+`qyuq;n@5n#2GQk`^n`==LbJ3=1DS7@KYP}yG+tW>`&)W zo^AcVn}5(wdHPlVas2NW2|0L?6h7*?h&NIG(f?(imAu-n(%5ff`*Om+_}BSY3%>OG zzYUOIApF?zvB5Oj7@8Kd)ZgwmGbzYcTYo_{5as?ZrvBQNezf6N5y5d~K%T7DrN4_P zOVW5*I_9T&8x@#gQhfAx>Avvi)I*WKe%P(!tw2k%g-;|e*8ZX;a{x;bPZ4ht^DB*u!jFI1M=A9W<`Czghbd5(`B6!^ z^V&ag{8NA8pZVwhxBi9y7ymo|jsMoa^soGD|DAv1PyJi}z5iGLZ~p)I-}`^}XE`QI zaDXg-#!p4osa_irjUFviq5;t##>`2O3}uk@r z(qE<-Zp>don(_uYl( ztBL={C{M)=qrnRTv9E`T?h!Ipz6q4`2mb*Tnn`xIo#9bY9>ap#wCCCG!Je8gmZ+9$ zn($GrT(P5qPsmO&cc1V30`XB>%USWl-$Zk98jBbej8*A%ji`08SB=k&de=|Ud|$@? zX0K)w!M)wunugGzK^9i>ZisC`+~ zhM~NAWkmMMVDhS=&#zS5Xcg29dZj{pHStd>q$Xzf#O$6lc2DYE7iP_cu5tW}#-fXQ z(WG4amqxv>%=#+>^Qy7@$}XsOIdCp5lU@4YUm0b1Z}z@7d*3(qzOOd<-nz{; zC_FtR)D1}r|IyFLe2*HN>F-F0h-w&-aw0;RD^4JD*&OR;{Apu10<^&+F^dv&f(=6I zJd%1%3@5hcyiAuPQL{d4z|8E5dK-CF0*aa8!`>XUHyihdjgG&sw>+4y*guSTs9ygl zam@7BOkn=+jw^xl$vet5$G(sN|8$AGVS)XwO}eKG^p$|nWTWnjNvrK^lIx)Ak;#i` zT<&+y>ubBVe&e5Y+@M0LI%9g~2HmjT?Rl?nZzhuuUiU-GeLX#Gkr?zw?v2M;aE88I z{#7fawwbv6*DKz(oa1)C@19rNqb-rdJpgHSd!2SLR3QFY;EtaX&$-9#VB}rCl9NU~ zcj|a=CoNua!db_gl{f_VL&y>4=OQX2@nf!d#-eaHNIhG$g3ibt58QX|S>R2-zr4Dh zUQB`L1VPvyx$pe5@IbTW`}EBF&&1?t?w^VWLdnA}F52rqE3hE!$;QT##jNGXF+q2r zUu5NRyC--C-sxm|a&vKgdvSFsgarL=Td|=I48|kxb{$iW?@PRnfj;Q-{l@XnNbf6I z)Jg+pi&?gdw{UteHk>eUlEN(kl_o^k{DImCU$wNW&Ky08q{OBEt@-pJ40^7Q78h=| zO&?nAu;-pRp0LKCTFSB~6S zltx>e6%7uJRXz9<`ptNu(-i@;%0s{TrZr5Z8d0Gdf95U8Y%?L&3A=qzc<0?0U-OL?&cqWt z!WCLpxsQe^eOa~tiR5!7;QG<3_@))~dTuy?Sq`71NSsIWHKoC?vHdm_Nl6R9EFFnS ze)_3&cV>-}I$=Rc#VrE{-R5*V9o<&Cq!9>(Q@R1?KNX25s`QN!1v~-92k(#M+LDrg zXnpYJ*_KN8^!2U#M+*Zrdk!NwqEc08Z4=sC4b;^ztVE?C=kLil*Xn=6e zy%&#Zu5r&B$Ea`q?X@z#i~F8>;?yrL&#t~fal!!Ga^<}-0up8&w;0PsHx8NxC(v(P zf)zInE#nps;&y^wdk}b5q%NM$96Jicxb1uQ&IAoFN}0RJ5tV_WfHN@>(H!*zS#IMC z-v2ALuWhS6?DACt&VyC&bA4Ktt!^MD(ACqX9uC0Z+J(qb;F$MlrvSRE6jYEnsO!y7 zr|++gj*LfYxIsG{54>vO1=8fpxr0TS>13; zC<@$f9dmd#dvbW3w0Z+V)$_wWJq5l;DfQmsq1D3=kH+;GR(U_Ql-MwYSV4Q-?c+Bj zE*O6y=o>#q>Y!f{y)+S819`%W=v&8&$TXRwts_PD%)3hvF#<=Ty><_%NAjgd3Sl0L zMXTE%wQ&({uX(!TX^@$z%W8FpumYTQg~X7`*(ngwC9)hv%f=9tjZ;X6^xy)odCNvX<^*_cPw=a>vW_WU+uXvjSd*+yK!YV)su#)btsGfLNCCW``=H5XR-_6J6$5yXP zUexP3Jw0ezAJpq(X`}_!dp)w5%?N*`g>zil&8RzcRC_eNPy!7L#$zRcq!%i@RZPOs z?G6cDqU6SA+q&82$_lxN7f0?I`_Q##-o03@h6`nd8nF_F6Y=sRYc4p1BL0OCo_l|IwjJ)9>aktkIP`T_pi(ctXe8;5r8Jru(4 zeQx}s?Q^*QP?EfVh|=Xn`4vbHB?*%#_LW32o-~R%q9NUGw>|2+3LkgdRu1*O?Ss3b zg6bh<`|Vap*olmrDl2w0QHkLtZN}+UX{J{vRT`Q5A%P!#?(_%Vt3m@`zsJOvtglaG z+SAISE3+Wq{*-L?8&@(dG9%pn?18o|b)l^sHgwD=LKHfwH7Xwr2Cl%8jI`gE5&_k? z!!ZC^)5?Co$^eWE$x=g4Q+UBgQ-F>aE$)&6$VkAv(|;WkCkE;{f$rfJ5M8TJ{xL-U z_S|6~b9kCai)A9fG}9;!&M{S^qMkGN!(hsFv~`z;6Qrr);X(z2t-4ckV2u;v*+OBo z+EdIh1_W6ret$Ud;6%Z^fh!)^9rzGGhOqNfL<&lsB3hPbnMQ2=2x*RHpcOk!J|Ntb za3kwC8Tn@(OG7JtaG8EAwE7`?+RvDZY|8|yr~)@q5Rl|LeNt)bAr7$(h3ogc!bCNq zPKPH`JD1!AYPWj*v1TY{vwU{Ei>*xKl4C^2v(Pdi$CK3L$la|Cr%26_^I#BS0MglW zHF{Dz!QVxkMh}u=6y)U}9EpPkGdnt-vy`N#$cT%Z3}+>Il`0Vb-9qbPFXbz=n>IRH z(ot>=IyiOo?!v!vsf^hNE-->NyQ%Zw28Ezx`hALo8$uXcy!I6kRAtmx%t%8=9V`!4 zu?lBQ16S%tHJ@%fV9U|I+M*DoKM1l0M^u57sX&|`JgOyH1miK9HySy@32$F&IZ8~i z%di!pB~3Ku6Y1gDXMSkraB)y z0|@U!UuMfxU3>utHqv)!j5O^dO~rY;11Ypj(r1}QbU<}Y1A?d*w#TCR3W~g&j>;e$ z(NU44iVsrWSH}qR^!H2dN2)giT3Qy&kZD3ZO-?nF73C$-(lQ%URF|eb1bYZ7E_s-) z3LUQx`s(L2?@%kWez3X89rV7lOs2gh{V~`qfF!FW^eA;L2U5)&3U9ti-Q7WTVB`~E z&$(HDL>dBs)&@K0>#UIc3H?K9Ot8_(N%|ntmpFq`SWOW-nc?w1D*r61eeH!gg!z#8 zuerjlE!PGEX^PyCPxQw_PZ(g631O|YnOePehpJJsdMXfy;GNgp*1Ijt(W}-RJ-J98 zRODj5b`OVHyO!%~dwQKrU>OeL-^5NR9Hh7rXEPdk20z>eenAls+a8#zQdZ#R!QmT~ zz13meITn|@6E8DMn2>K52>=YRd!y=R8SX?dm^Iyv+dGoNQ7!b$h?IkjNMRWMK9ENb z$Hf{l7n4{hGPP{&sxwQ$XVxM*Wv?KR)?nxcIo2675l224oBm-yJ{eFVQFPFZb^o%b zn4rBlY-)roH>z8@~^R-^1<5l-8^O>09N+ zpd$LMqmW)=Us}nM1&l)pZboY)*Jd|)5Myh#U-I}~r$h5YThC%U^4;b^39=dApK2S zKC03v&bHpHvR<>=BvyBdi^xC$h!7x)n#{j2#Qnh(5KTtf7j}D z@PbS@lmOLhhz_etO?)ScG@*H_eN>I_^ikR)swOlf@VMM94OZD8p3o}$K%*!u?eqh! zW1!ZZD`}Em_a*z2eG~?y>iew@psV(i!o8r`D>svDDON>|zI>FJGVG&6qJT1Z=je!3 zR@{UB#*$~mSw*UCUHSyasxTg@4?onR;tRWvjVY{drJrY`(e$iN_0 zl|cZH>PkATLc27LQD`z==|W(?#6fsnN&``5EP{o1sBPQ2n`HlAVQ-P|_Ctfb@R)gh zMzv&FJ(3RYjYC=-)|`GBWrzceqHMZA2DNs#4<&_M-!oEvA`~M92vT1sZq;2S#3(?0 zPL{mx(npbwh!%E$_GHXLU8j0BbOVF$Glo!ZDPPH>M*&VyN*OV2I4gs*Dg_S4GOM%M z84D#~2Ua(U(_MMvi3QcMT%iHw^8K4PCRKZhMix9t+D!WeKdB&}xg^@N-GJV3U4e~w z!U6zHfz=tcX{r;+4W?onTpzUa4nFF{L+UH)6jjX$X(dflNoJ(7@e+C%q*HQj0TGi0 zQq8%c*;xr#cA9R3SImt3P{E^rTiPLp?XaSkPMrms7c zy74nJ2)kzZi0LAGwYGm^y3)`xrfWj9I54hb<4I%;ivb^EI4%PXkrZ&zt* z*keG#G}j!aE(}NlM>-Qllh8SnY9ky<7H+)<%Z&Hf z$$)AkPo5d#0m!-!1MG?Ss1?2nTH>Of`VI^3%v@4GYsm?9~_Q>bTE-VEfa z$s5~$WtF%A^{m2hx+;g54*X-#m%TE{mu&bcqmHQXUvwWVTX0>=ifk-qEvW|eq3x~P z%Gi#(2rZIwcJY%s$Qe>F>RjuCYJoV4tDkOVSYq@|0KLCFsXD`)#uc__5>(@s@uIfM zWQUFzo2#@=RSy_(jYcwlRX|i)TjeqiKf?QJQ7+6e{Si%+R$E$@I;W>cDX53l{esYo z?o9q|=ApC!X;0U)(U8!|GsGJmco)dz!ro>QzJFkvk!wkSE7sLaZrL?X=YS+ zaD+47nU4RNBFp%7>gA@ylJ&Wm5?4sIJt=<}L7xscV7pa9(K63A$}%o!ld(y2OgmzS z6sj6*N~EJ_Dxx?S0*ps3%C=S{G>pyp?<8^Tb-k%v$pt)r`RK|Y@8L%nZlg>(zT>un z{5{6=qRMP-+|D@Qr-L1l_+gaN%*qJteNN4DgP=ts<~}e!grP;0$_>%g+J*zfxY35~ zhKtY)Fh_JT2Kpx=f)d$jgf|rVQsK+QwL8W!C22&SKi|L+qWE`9aA}=FHDzJxZ0HKOVV={ z2~xuL2q2xYBCF`DDk}PNi_1&+`zEqF@dTeFP9`E`sbs3rhWxPu?@+RDarq)8fNLU7 zI5irF&LGQz5sjpTdJUB8|H?vDA#Ul2%NOO^a+<=Y|R3ghitr9;t9H)K?3~@o_aU58UvnW#%jZTMuB4hdzWURRrXb7aR?*hT%q{W0xhqwWA1j&U!`GNyd7_XUJj z@f#?;#zMMfR20H98B7(7-z{BoWrrDVK~Qd{b@KH&Ht>zFei8r&7_%&0ezIs zE@rGEXo0T9YizWoffu1(#u4U1iT3E-H4bDJbC-?w4NXwyh)Uy)cW75j0>xhk8rGS6 zcT$+57S_4ZR#5UR!M6Fy^)IV4g(=3oEzI8o$W27|wCaFQbzXya z`74y$%P@jO#y~NIWO(paXN53f2oqYzaxcg^^Mc@*aII46bF<0nl?d`xPN#TjnGGow zZ?ujv6X|RvLJ=<^jz_Q)A9C((=mxDoMIEH#(EZw-QZdSFVTpJ~L4kIhnIe1hwID8| zdDfVX4mWBlC84!>?zJav_q*-BTuUE%Fk&*eLwLb)j}cp|J7QvOanpH!XY9RxFZRMT z63v-9-ubj85k#!OyOJ0q4SPW+O-lYeqUzl@h7ov|`nsxR64zYh`r!YeQ64^Tl;86I SJdpC|8`K)K%_mo9&i?|$3`J@H diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/dbopen.3.ps deleted file mode 100644 index c621bef97db51a132b8902ceefcf72bb955c8992..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 26477 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%0D0u}#;uT9jcxHw_Q*z~&sUkGj1Ijlf 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 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/hash.3.ps deleted file mode 100644 index 18303cfb7cd25528580455f93b1c8afed2cb6fee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11349 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 MU;|R7w=?Je0Rq3mX8-^I diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/hash.usenix.ps b/user/mpy/lib/berkeley-db-1.xx/docs/hash.usenix.ps deleted file mode 100644 index c884778830d2fa8b5f335e527b8430be9cef5b06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158771 zcmceucUZ4EkH!qK$oo~)o$Ni_hqfb8he7joQZ?>Oy z9_}}H>&2%xi|ys6)BVTJ%hmP$Usl^+PkOWC{_u-m&wA6rub=S7>H7Y9^=W5!f4;u$ zbkEoK+s(y=esEXo&F%BWJ-?qmtUAwE%TB-F>5o6{O+FosJN@}wV}5aa{`uzSW_5eN zJNo1o|GWG5PwsZ~^Ym`J`9=TfuroU8k56W^qfa{5>$8*kTj%(=LzC;xW#?kE?f7{! zfzHMHdPRSo&o_7Px9iKR`%ZWHgdu06U+cf)j+fne`F?l5y4iKUx?OIzcbhGfJ%8GH zc75IXRxj;3->!D6?He9y{Kf9Rvtn+n_iD3UbzUy+J1;hGI)hl>_uNJqL ztMks;`_32VZx`G1&L4Qt>8||ce?KhG7TdeU)3ep~ht>7!{nOR?!;{Yaro(IJ*Q?Iu zc5!#LUhaNPSN&<{%hlPhJG1H2qob35c>dL?HmTDe^*ZP4<$dRTb!S<=N+2+!PUxuZ9m#wFK+KUZgX_xX*~ggLzFoIl)kZdaF`-EzU?d;H(c=FRGUa}*=}_h!=hl5Xx6m#f|4 z&8p-7u!g_#zoV0HK6~^75bI56^=^6PLB1$g(gH`Wx6PHuqO;(oh+7XZH*?0+5ZecfE2)428M z=;VHJ`zWyPIGA48a2xJ zZ}+9q#be-Zd;HGH?s{{7yJ?0qdedar$zLv4_s|h=-tYanbGx}e>OAU6ZBl=}Sl^!O zOXu#PdFjJu{QB2*qS?FO#I*9rlofWq%;~?3pX2x({<_N_b^hva?Gxx}>Q^1j?6Sat zGhE-vpT6|Eaw@&f^=fZ!?arA0k-@SH;LuqCl&L`+5FJ;&l|9Booo1ioeh0D%@@Gd$ zAZ}NW{d_GJ4Z1>X{Kg>P=-doD%gya_aUTc4v$t9$=_+8f0b1%Mb^)P|!K zSbDeN46N?2*SD*;>+}1ofcPID4VArv?k8#{a6Uiy?Yockq)y!1 z2d!T|Hod}0?jCkm#@rKq*%VZN_D2Rh&Jlldj=dOX(e(Q4#p9?0fo)CpBaOcMu>lUJ z{*iZILe{;y)~LVzPxKl6QQgMP#We0_n{1}6He*bv#ydqCM zOPUWT@%;YiZ_`8lxI|B>x`zT?+5zwYkWcXu#0Lyb4f+iShu!p+A)r!|()xczIu zLoaBw#~5?eS^fF()eJe}`@iO+{>0CQgU)dB{a+zt(Q?49(UiyiK__2$^*x7bb-i2d z|KarHC}m9Kx*t}Lm!`gZQ)ZDdAE1$wT`mB$UqB2A&Ue(=!w!z(-QxZ#4^xhD{kRpJ zkzs(BhKuJg$JO=q`fdlAI$tktT5Q_i8?bkh3+7PCJ=yky(Hn-2bmJcNUpPO4NC+S& z+r_zmy5c06%fpfPm*A~bv&H#&?5n;U_h-G1{>QA#bbw0IFLs^{Uz#m9%i3S=^VQ>z z{Lcrs{Yk8EpYeet>r{s zU*+pD6HP~rVj`N&$6mQTm+V^JxaurK?F9`u^ZjDWx63*mF^)0~eQvjXyIKjg@(uda zi@S$2%a3rf`^Vt~*q@(+&e8wQuK>{$xh}=lPj1%nX6Y$f#a6pJiMTYDMi_<^s((6%uum)Yk2uFL?F&Lg%}^ z$dDp0VYjRk?#W5IK1X}g@iZ)A?wY7pI^26IS<&<6B#h#dHmS3}Ijv6BxNKH?FrMo* z@3=SgN8a(_5!Ub_UjX?&+W1YJG$C9zE(04{>Zt(9!|K5nQXn;=9x*}XXS{Ymhj=Tg z=YRzj40p8AlIgp5<>d+JASxqrqgN84pJK+w_ZJfq(Jed^!WZgC3OGf3odh z)Su1zqrqq}>-T4a(NE2{0xLf>qXFX8a57x=m+d)d2IZgH4hM-4+I0P+wf~jx7j!F~m+$5GX#FGIlo^zl7ddp9N%_6Z zXuq5NAxfL(Z|SA%MrrQ@Q$SpRQKrzmzW-^OUt66uvnh)%^DPi9fA_m;zIleFo5PtL zes5me|CBTT*Y81`PaZBSH7S#!wT4IcxTtME_S8Q& zZKGTMyVtfp68&l!JDnzUFFZ$`t1_Mb`v)*8!7Wwp}GTjI&(B>i0c3(E4k1EGC zqkLSJI}qhOc7O8Ey(#j=#jM8(>J1^S`IXb!>+^NUuTzH6*ZmgxRnwvyeN#7nU;TXK zfx1z5>el_Wn#byv!{t!x&_8|7&Lsp3XkM)N)W^T-ErH{M7JJ?3R|Ady+>sybec=bo zyc(v}ye@Ug{8zo{Ip==H|M6+XlO=1W8~@dJJ=gDQr}ljz(hv4=oH|-}U2B_-X8^IJsH8Yx@@X`mWkU_8YEm_ZqHm z+YN8@)h}OS1#G^le}2%f((w6Tn5Na4htB5tEv7^B_j}Es7wu8nY1jwR(b36eVz+sz zem&|et~b~sWWvN^vc9XUiLY-DzF%SDn`tl%EbA~nz0zxMZD7}@D}6HjIwxtK`iT~? zbgg&!W{m+x@2_nx^T#xGFqjwV|CEMrn}%;2i$WL@SDPhc~uu^kiqYTMa7+~caf#=yN<0(jh~7(ZHAxLmfr>^TEz%!JiC z-tk1`yAc+(yny;T6`5`fum;llFO9qBgXT@!&64PV<*wtg?J9WOdlZLkwfyU&TP)Ag z0v>BUxzIXqISPh2?ci@Zo~3i;VYyo^ zt~+H4CVzPLZn5+ei*t9+-_D}*&1QH1a=BgeUDQsYE$bV6XbKb()|%q&?pDh+eTgn9 z+6NcluJcx;cy+rt!{LUTgBOV_S}vAXD}G-QMRZTdQs?a9@^Yn@esQ_F#kNma$_0*U zVw~_w5!ZEi0fb~y9ithVnrx2sNfeY?DVAOPyJbMt<; zy1sbwcSrRI5P^{)HD7WpPv76Iu(_K-==%$W8=Mf4bG2ChKzN26M0)<)i2Qg3RKqD= zK78M_`RudJyUwfQ0gS=_!MH?3NzW~SCkxdo?>kSQK0P}5f&eGa5QM=w1+#TWIIB8? z@%XX+Y|?e|6mKeX5$81DD?cCE(K7pcgu{~^;K7f|0H63{`3>{-3C=J75Rq5Q)f#Vr zVo_#)-zVw`XM}&fUR~V7v5{%OrdEr=$=RD|afa`r1DN6V<@Mpo^$+dW@r4|`K03KR zYqvPt+#j?UpWw}EP4L4hOis2rN-W{SQKl!`93@(OFv|t+FJl0hzwFIw+&_WFc*aC1t?V>Dl4y)?^{dm1b7IsQ{&RHl*~9w! zoM^f&Q44Vrae=m_6W%Bc8-6ZQVu^sq&8d;Jz)Sk0GaAh#!>HA7SA=OHYPeB(eZQ$> z5x3PuzOi8P@zxq%{Sr|_&msjr=4#xi0C05EGlakOlC2yR&-?!+V68(~9}Q~A!Vv;Q zc-tLZt2`HglDMX~%0$(v4Fub;j7;CC4Vn*Pt+LDN4S>^FG0 zriWw2M1Fh*o3lrRQHW&~m5St5;++D>YSbg}B0>O`*PGqSp$_ekhO>wNUSCo+0&KfK zKN4*4BU8!%sIvVp%LRhF8Re z?G>_F_^8pL_afTV7`2>h?m)u4wLfs;j}5jXy6OM&R?C1o!1olOcyDawiDS^$OX*3ZZW`4p*b zL}Zy;AYj$ch*Hhx)^o(P=6U<`vU!e()3mv0J|h{`=g5NfGqS``%aWLk)KEVo+f3{8 zcg<&nr1~65rmhP4p?*eyi5?BT;Btk54N5c2Y#?k5!RKK|B*xQ#04QLqh3rCj{ulIs zQ%+Ey^?04kWOmoP8tc}^bW@rSLL}pzAm)EdIJW1fMd^Qyj!|SCFzy2J!h(|&dBs8< zb?=AFr4(tY;i#Szx>UiZb5KOXhRqiJ{bR-dMG)}asc;jl}j zCW;~72vV7LztM;Bbks%NV>G@E`@=~W+oC>>dgJcz^N4=!cHT5B; z^UioOz=*==T9D_2d$}{6&bz-=#*TiO&8FSV+TnFUW5C3^$9(Yyq6c<=f4fF(->vW8 zYlO*c(%oF>({$eJe$K`+t=skD*E|{y2J`M`nQNjZJ**b9>A3s5zkn1k0L*C6{ce4^ zzUM~|Hkyo@!N#M0_q)yZ2Y1fg_Xaj#heP1rV+PMYdwKfpv(Hb<>bzb3v4U0yy!ZlW zusWd7-96lqv7-U|lkqgB-k-9p^Yu<6_2+|rcLUZC6M3$Y2mML+s|{Yv7GUA z+QkIJyI$F}-|t>w3)(KP)SV!S%-$uBpf&_ZFD^XKNk8h9!mqd|Yb-e51m z0Cc~`ilk?_tJ=6Tn}B~U^>yTu*kP)q6yQ%O@JRYl)%LMMwK-A4DKNw;l$0&zJ)JUFA0&}Mq0`TV39*4X+y~6=yX|W3$H6G4#rNasIG07mc8Sj$#w<~*s`@5)?mo~dv(mcSElH*J>jIbh!(1QYZC@@c;3M#3?Py==XfLf!|n|R zV0|7l4NR_xC^!o^5IkZZ;Q%P(csZec=yK-|#t2V*XZ0^BU z2!DbKc+uKm5+dU`ks(^?z+@=Se4|E?-FfT=J}DADM}hbN{>9OJI_#bkrcSedpY0C{ zshJ8C{Sk|KUYP}yzu;qkIx5tmKO6Trs@wG&NX{GY#b7Y(w-Cm|j)2<_tM@S~$ETsi z{b@h(Y=Fp6I3Rv}(LN=k!Q+oXH?c(F z{Txox9)FxtOn(TZDu(ta(5m(n=IpbkVDKPH>A>wghatNX6xd@;I4{}1K&(FRuQuo2 zu^}`LtET`y;%pocYv`VyXeQ4$eju4U^=Rz9^gKo~n2qJQ` z5W{5uAb%V6*q^dPXP(6jn&>Py3mQEHqh#fCXiS zv4==<%f)SuIYBgxF{dB^`P!Bu-^zp$n)LBb&{+8i1jbAg)i2(*YDkQ z#`!mGn6a$|83gwY)Rp7DxivhI^}Ao1ta|7HA}RLvEh0upjAYz*uaWMJZv*&`ASK#w z38X&(UT?2faVTcUU$PLV=7GQvuvGjERQ7sJ&bW}-Bk7O>Owf>{Y1Eq2Y6U@rroLHu z4S)sA2w`f7Adq4e;1MM6d{APs97nv<+I4+L=Rg>`TKO;z*~CCEk2_-P${IwW1(N6& zn@HDrEZVvOH0yPD{d6TL^+%vcqUacK-hmWvH(Q^985Cap^m_IBiO24#!Jd@kamNtF z6un(_Kw}fCr!%Gz1dcdhBM$ZEOgjnI35g5@4#A~3u|l!hK!&L?9g@uX&EpXFERG?# zmUYh)!L@Db5!YJ~Dn^~}t<|0|0&EqsAZgplrDb2!>1YfeG2NDT2(S zfx#iziil%i>sj*EF=XI2? zC=2@l8mw;4R;ilyB{f-4=#xoQMjoR2!%HC?IJiBnDeMLn>kW%36tyQ&TgwI!y9<(g zv0@c5X+%a**E5g9cd^~rRM3}Qz}jicFq%T*JiFFpVWpJhhTVEP*Xv~7!h@B5cIcB?-D(_5uZo5y>B5?Uthgm|_O#4b&U4DlJX%e6{4Pni$eko!&%rDM`Q#Bn%QT7dsETKu`Qb zs);}gOY?lRa@hNz`;`v7VIbwi3`rygCY^l}E|EN>r^6JAWgm@`^iRQK2=Bk%ybWXn zllIvII++w^LJ=WzfqB@yz`Qu%d+ZBZ0a6iVvbI*LT>vKn);+p`W^2F!Os*2#5qprk zfi#snHUWRB!zwz_l5#K_ zNYb-h+@H))9fAPPm|!AvT|WXEL}f!224RkYFa0qkOsyLk8#PI*Mcpl34Iz`sLPm(v z$wDU5%~MsHS^I$(d3_lFx?dB3ljOaT6|^FaIwt6(E{kEMTJ@k8MJV<5vdl)uhKHcU zd*7!ttY?~*CzAxTa%$0xFj38EQve*4Go zj@S>(#?P<48ALrDk$8j27V=kYwsRhiCmaiFq~9G$h7QrE2Qr5u2`$)Ci$@_zA%2h` z+9j&$oQPCgQXyVxo3X`NmOsx&7Sq9OIt%sq)NFXz8k0uauGmwM8rUi{O9(lb68vUMt7I!7Bq2#&(O^yo zX;MLZhkg`85o3$^8XK{t)-4pT9L}UJ>w^q*EprhjSZubU2fWQ*2Kn&lLulH*&FBSo zAB4ADGU?M}11n5=l2Y z4Roqx+zU(5P?m!jKze=I>?tBrY>G6N1j8KddG$^vNDC_;!>> z0Ody|usO#T$};Y#wJ?nI!2yX~M6HWpKf@OaP?R)dlcav4ry<1!cA~R5L`Gd0#d3A= zAc+f?4GR$O)|V-rTy8gS@2|vZNcAo#HImr6dPmq|dk1G6PS`mvI3F1fD+~*#o4UdV z)8#lCEWKb5)vx*{E zW3Pr~wFi;mIJRYsu)sUiEYsj}VWc>$6cC>jbh_#0t(G&wLYvr~Ln85pPMm}$I1U6r zm`$gFLdbuEV%B7%!WV!!Msh<6ki!`V=VpZk{C2&&@vcc;RU}wFX~RBtnzM)V^Y_OH z$Zr=|ByTTep|=MMw3SzQ*8QU3uCN4LOsgZPIPdh@y)I?431vBFt=cjj_U%LN>GD_LLN;QPL;KO`qfniKS67ZyL! z4A2-q)#-13_uF~zds7RHz)W792&-~M&>-Y^X%)8YOE&%@6n!ktnireaGU5cc< zu$&3^V=E8=c@uqrQ{us7$cdm$Z{C<~0W_vS7M}UEbD?!)E9Cz!mNu&QOt#&j}(3I0$2jExV0lkFpnhU@p1L=sqGX z8gy5IjWYHKXJ>cU7(Pa5S~0Akj(j9il6;WURdBe+WGfB}fE>ks_ZiwH_A-5)&ZnK; z)BZ#PY2m-eE&t!ML?5W%sK7&rEN}=FE}JP0B{9Y>Kq*s*k}-9=Qr!_--JnLu&m3Ki zEsD2zv%s@U**0qhsmJOE{x2f|UA2MFHGV^YP!DQAMZimP{8 zg4hWsQF;d^y(HkG@+hl0?+9Oz78si|hnBti;>BmP+4sgtb_bD4#@j>>X_UDh3u`Fo zTF)xfPw7iz$!VuRE{?XvumjN_-q=<+ks(AfH06noUWqI~Ss8Ty!?Q;cNokd+7mEf zS8vlo1Z5Dm%Dzm@lU$T_$O&A&WfB9BhRT_z3LaKB*CCZatSeSO0Tb_f(m>fILCJHU zH+Aq#!vcY@4QmSU4by#U)g`h>9cdUPpiM>@q6Smm$BO_ldC*~I986({rVX-j1nbkF zlmG$hg##kP6=qTx9On|lK7v~w7RSU$m9k^FBN zTuW=*ctg9l&KG!W(!dk4isgL;FLA{mqW3ry#Bk0Wx5vTjzHkuB1U&ss70W3N-TkIoChVL@ z+m>w8MUw{l4_yejDLKu_z^e3Z0nkFIeIoH>wDEk|+TZDd7=A^5RIx&rEm< zGY#TBhk_NSh#VemJ&pn3;Pw;AvKJyTTGFH~5)15llmfBjVKV%?r@u=Tla#Pw_Ycp$ zo{f-|+1n9h4QWFkDJ%d1Dxnz)*D|r~&w|B;_apNA=BeQs!bB2>IM62%O# zO|UM5IX9Lt=P;H+{GcUl;dur!h>brqag5A0(M=4#MF??}!#%K^mSqApgfh8*8CK`g z+;R$F?Yx}vIx3r3lfxPg9SKarp%-3aaQfxLE)@d|gefFJFN+&Wu*Gf1+^Zu0;%F+l zAxP33qu~Wkrcl)#Zxf(|vlXLqh`7KsLyNON7uvc*lu!O<6h)U^|wR2toWLkQ{5|Q{?B|j~PG` z4!m2PAIsYyeaaIWHE|p=ZJi+@{-BppUjDGU-&xj1I)*JoV5ouw!-1qZ$TX15 znf=le1%DMACY@oWk=kezsYfM1Tk@VaA30m7Dm#AIKV}HDMhCfm_0t@gKV~9W;gqO* zj}F+J4*fR4S<*JCOOk2^J%m#%I@{(4mLKBx!yESiV7oG_;AJd?n>7IeS&6ZIk zy!4I(e79YvcS=%aOxMG*mp=CRq+&USz?3g3S91X5nvOUdMPJ91DqhSWTYp&JU(pNn z02wES4hjka?Sp;*aW6|SK~ls|&;rmAJ>r;(=dkhhUqV>$Y~~OlGi~NVkL7*MAE?L) zFq=-f8~}PbU=rSA8S3X`VnIQh)&qtB9H`CEH2Oql3V&% zrr=Xb%*3K5?UFh;92_%cdeJlqbEuJj5?!t72uyPP{LVCY4m-Af#Ew}NFOdo(y3%B1 zS&=dopaIi11iI)4#g9ke&lFJ`1F@gZ!OGOV2-jm`IvbvgLU(S_ig!Cj`-+wTW}i^G z3?#CtSH)5V6mW?nKVuHSfFpcF*YX5CHU!qk{Y1WZUUqsX~wn5K@u3|_~26YOr^u0O6 z6b4Kj4v25)$if^7G0a!nw%d?MA2w;IQ44gCXnWQ*M|m;QsDgJIwHCK`MJ+kA-{Wv) zl^pfgL6Wdi_IOjwEN2sEhUMxMh67SQ(j*2(E|W}+2T|9d(#I)?n-OqIJJ3L)NHp*y zUOy2Qd*$OQJ;{|6q-)9uMrv7kV<`DK=-Uo!S?5|OHeeofT7Bf)WOZ-tHu#mhtpkDT zP$n=zo&tHOT|l6L@EU?+83`Q|Mzp%SOBhHYyuT{(M94i&OqZ8TzxLRtCtC3wX&3cE zwWU=;U>MMQefviC30^SJfO4K?Ykz{6cnf(<%p-zEOo$YTwHJ&gZVIFA;ZecJ4L5Y0 z!CYt@L|gb%peLQGcs}~WAXU=4J%tJIGwl>Zt7edooK9(^gJ28B4}4Z=AX#AIQuip^)}X+$UjPv5=e)#JbX$L_7_}#p=-O zEcLM9V#tpeH0gpl7ey+xh@ryPIN(VskQM?2OtNwaYp2Xi8+&(+>q-Qc-IG1g4Ax^q zrOPVeWx$qgFpFU5KZL&riEYcFM6+jxX zorQwITgDvXdn#mmN(yz0t=3yH5q7S}j#ySRahO0h`WktPY#t{Za5I{i$2JeS&?FCy zd^UoU4&fBuj{!iK{p35)nXhpa32VoR6sU@vAo}yVbTDN=)|-c&gGUv9U$7`dQH2->o8OCkYEHGHD~ll%Le)B^{2#Y0WFSV32XwThXmrtk2$w}Xg3?K! zoNz>mTiI^jse)I;wxS?O)}a~;gUWFb%Oy#rfKxUArk^KNPABZy!bis-MI;*q> z0bm=0O^{v-Gej1GN{XD4YAE+cnzbMwGCA?w@RDOHdu5w|S5J!+f5Fkz>pr`HgaH8= zKS3OAh3yRzEG%FuIwyye&m-b{H7GV>P~M`GXr#_~;W;7%84%h-$kp%#I9T#rjeM7!{{IF*d1yH7Qn2@+dQQz2aK{kL1{VE;+XBIYv2 zVkVA)PhoaXQTF%;HfM_AsBs!NR22NSQE9MP-vI6mNANTP9^T5Jp4CP9Urc>w@x% zXg}O$bl#kklM{g#5xL_460aWHWUfx94IiIZHx++(|FXOFeQ4xKIt|f8(SGJ`4nSgW z#E4^c6D)C7x-CvRYb2=j0VN~I9MuHmVx=HvD{yYcaS1|N?5BO@Rz~-fkuOLfl-xrC z2V(A%`pLZC@kp$mk%;{(Bw4QAz@`s&L2i4~ACo;aj(~&=YVn4$6q4g(gGqKQo?baV z{&qrkpwpoWDAYXo@KkC?5xzaLmmsaJ*%Q&B=0GC^djk~k?chwsA~tmUgQ-xsN%5knMgsg6rW9r^miv`3HppBqBL=CS`KTn}yML>oNLo-4Y$5H{C3}cW? zbB=MA!@Hbfg4^~YfLuhg$T!-u@b5_!mij#mu^<}NNOlZU+GiO&d+ zu~>DW(8WSq1k!3yBASx%8`)}ad<>4GI)VNKq^vUl=jJhm%oM;x!)AtWuyBpBL<#%n zgbQQ_!#c@-n)cFu76g)BZ0~XDLOmN4H?w{Pk4^&^oObyC?O501YP;PAS-yt z#u6mkUctr~QRCU%&ICn__iEZ?%l zDf_0Kz@hknqVG%hPZ5~zl^K>MazY28CCbpzxUvG-ZH*1;S`VbhOM(qL&WYOF9~q80 zNenHK=V5!xEAkU8-fY(Pm5AOd`U`=v*iVo`Vk^jis)DjkSrL@&|58twl7d7#ucl=b zkPL4AsW0P@=FigH>!f(Mr@=z#LK` zBmF|Q5!omVntsS3gfYnmpy^B{;0Uf*v}`QUM}=X_>R}6Mb{^_@hN0JhIHI+R{>qEM zZyth1a73j0jKwunNCIKWxOj?~ zZe`w>D-#Dc*`veo8U*F!@?`1{D+_P|1##Iu*5bJp*20P=<{@apAap3-#QTrB@7F5| z2x(=U<$zW|7a6&m`A~*$Tf7AO5&MD&3oNVw!#$ak5gj%{x@ofzyJ4HD1M0%PI1Wg) zA52|iH&bU~YQoeJyd|+XIy84y!ax;!W9ITX=HxWvRE?FnTWdg>uU`=MkJkkQljoceM~dh|r#<77S&SW^zSWA_2D~EMh}c zyu(%$@ll=F;zneJg~^yRi4LHM3GYjo($zraKyvwbTXUOds9Lojt;_(QKx)r{s1}WJ z#>hc|p;<;p5TPOFUIT`)nYKbB7)lmD$3{3Bf~Y+d26_2EavWq?GFN6S;8*?3f=1*_nu-dQo8ju5&FBU z*J8P^pZu>Uip&+%@$C_&A>ySOwO;M^{#V(VfkIn3V7LR+Xf%m#p&BrPozQS~|C-O9 z0UZyOg0HY1!guAH+x=kEDFk|ETEQ8V4?>UqgF~dqdr_r`n20jcy@olb`E@*2zZ{i+ z{%3a#TJ@t>84pB(IOIHQCar|`q$Qd)Ou#)Vz`+v*0183&JY5@xvHiA$Rmn5Nv{U1G z2H$DNi%Ouuq7!idbWCe(q#09+yrl1QmfZvs`7D};5W~*Cdj8Oz4vF%F$Yu!Ud!2zkgS3w zyz3=;RGG=zqe}6ObeRdPvp52YE4FM6O_)Q+GM`A>yUWxq9q$YhGy#`r5JW;^O2&%C zLb1?8H4rTT^_VV52B%`UrzMwU2r6QIAxb-!hIsiEu7qG;4m@2g2<-DvQm|fq_tn46 z=1~Z1#>qLgSV2;n6X+`OBh--?T?Ith(&~C)H6ALcA2yXxszJ?S#{}u&Kp8^g^sROb z4WvKCIf0b`I0UOEZil1@*qbIAtEU7}OBDbFQz%goMxlc8Dq8W*P-9en2O~fnQ6dz) zMPWAWzdReby$F{#7?hkB5SKWbl7c6sCDlS@72i;~>i$}kw)-e7?9{~K9Zy=qVbXY9 zU6nS5AC@^3ULb2~wi6YsEI*RVf79zibd~^$S@h zDWhNj`6x)5P*5z;4`#`V4~(ASf`}$j(aht^XuDS_hl$u{7P-ptS4(HLF0AP{fH50X2WzM8MLcEav~H#b;Hp2wC>elmeOZCGXauI@5sSDR#X1!?z21^xE$Jjg zdAG8k%cqAd34~zb9)k-|V=YC1QkLFy7F7ThWJwQMZ!rJ|t#D^0j9tDr)d>H8cp zM4>$ReGpVNf^f!x&$6GQUux+{r~zdKg`AQ7Zo7!%fRh=K0l{o>k$BniWtr?T14Wgj zN~hwPaXNE{X=bW^h_m=VYP=G5H2IXH6kG)DE96jENbjfFu@25tT5n8FI1=~0A?LTwXkxA zvbwXcgcWEKQcnxWRI0N~u#yW5vn6I!kcVdkL7lR1B?u@Mp5`4+8Ipp5!GL#w|Y3=q&-PX@ji2bZkL;7&VohAo0Yd>L^iKt=*vDTy)O?lNU)>oOP*#? zKv{mQ2PP?zAsJE4Y(|wk;zi{Qm-wiCs{*+`kfAL}TvP=V(9J2l#n5L~8t``{edrd9 zH(*(9CZRZ~*F{O!gp?w6yTP-}7vzwlM8winsjg}g9#UexcZuECM|GhrVP(=4MkGPx zHJ#obXZ(>GiNb1}7&A3)BzWmnx_`uqN{p(Aq$HritI9eM)EF{YN1P!Xu;tt!VMpMO zQApZgJBLSxl2D*j0WmjV&OANu2B+oY6gw44vx5dqrR?Z@`@&N>% zBR>M!OwA4~RGLZ})HFx$gw8u+l*52fk8M!phnR>88F+AkL)LsD3Foc&f?zGK0;s1m zG}ktwDIKuj75P>0usGaVyGDZtv9S$Ka&d}xbIwx>n{p<|Y3?nId@|44M-UPqL?&Gg z=*K~#iCxE!fC<+*QvyaUrb_CL$ne^l7nw0CvU3^X&qQd2d4s$+B+qM1sued#+VSy= zm_e9~@Ms;xRxbJ%d59Qm8hJE?L6ud@hV_}&tda%=I}VPfEIoTiQ$drt=&~cEw=?R4 ztl!XFk;yj+0-X(eud($MFN_9M*4^HjaY=-BOe69tx*r5v&F63;aP!7UFY-s$j6&To zB`k1ZGprnkfxVo^NTDqUU+HMgo+C`W?tX6arpmg{{Ygb;3$q8Kz6b?RRVFiV#sbA{ z)XO?Bt3v;j52a$1TE1o~>r!ah`XD8(p%%)($(5VmC}-!iBw+5vaSm0iuni;xAy*Ak zrv}1AJU#3dEX4tWqB9Vk5`Qh3A;BV-r|^pgC`b?a;YS8j)-jCB;cjy^;V#gdl8I3b1T=Tq(whzpO@IKyK8xo+{M9$A;jc!mAvX*`T&6h$Oz|9Htz_ zuX{bMAFj4c+#wI96nj+9velRil2}l151F)DGO3!Q(;tz?s%evkXF{;BC@LABS|;{j zQSud5q3H?$D%W6{MWeG?ol2!3*Fak3Z5PlHn-HKQvUrlTfWpK0k2J+er4LjC;pdDx z<0D&{IZf2 zh4s5%XfzNx8a?-8?h+-ltl#}y->~76_W`r{Oy5ZSrvoPQbx-{%GfQnzM!ZqFv9;qu z;rbOx2umG!a@z{F(0~VuN0z>HefN?>`>>7rG;wh;3nZ+N7t9UsW)#WgtSew)%71QXIxOW&*ZYjRV9J|l|Olmh0}5;!q( z_bZKoTvCC7R@m%{{mxazKQm32vAZQ=dU8sQ2oePmgB_a!%QkJfh0upes}vaWh58Y& z3jxCm(uf|AvwcMcpd>Yv)PRtlUMmbRg$|>YEBYx_KR5-J%8hHpczSY@q)wn%0b3eW ztTzORIbwg2Xh9d^r3+0&G8p`qiK4ixN?=kdW7PffVas3=y&PfDSfW}<6%zpBsbSSB zx{5>UqXw7v1CLG^XSF>|$hlUDX#$)1hEz+EA?1;ye%`G6`?T{CJR6=UXa&*fMQee9 z5r$ZBXWGIRxrahR>>-OfSVCi}tY&}>HX32GVHxoh6jN{GgXnH!9Etr#d_$)qJs^Z` z$8khg#EcVHerP{XnesFp1gCWPdSgD&3YkI*-@e5|YMGgYBEI!mDZeG~+q00*9*@jH z*bAxCwfcbxy#HJTH8c_)j!jZ{OjvUvc4^ac{#L?FxwUDXAvuY3 z->eAYLA4i@@S<+6Y`LWDQ80zeX>6xw|0+&kiLZxxtcas9YoK|vV#P_?*vzn@rxNX@ zWM|dn@D3v4Rbj~ED*mJhL~I-ac<6_crU7force@w6=j(_5rP<}Z3u@?H0h0cQ+nln z$U`KNA=6O=&^oZH)?kN`Z0YfBIlRa zQqoTmL{v>mNy8G@J&Y{*0wyF%q^I4DoO}=uFIc6(5-oLYL+%!leiUxV-E#gw%u%Hq zt653sLx+VCiF2TW7y%?vs>%~^NQn}BnE{Ke$4(}QB+>${+?HgLtJ)K!bSP9XmDgkF zaL3oc)VfyuIzk@^v2!dNsf}9rw-2%fR7vR|S{%bc^u~!0#VAfw&6d&|5J-ODxx#3JJE|UC63<8B(Zv!$l}{`D$d7}FDUq8#pHU;PL-8prIjRX6Y*?a4r1cBJJ9hU;RpcXNJO6t%?Rjv0}+)x9L}9=X~j`wjNs> zE=wz8@^5;7^96+f#0I0WB#1P)0%iQ3aYxQZH{+qK7!H(?b#5R>v+CYN1h6U9C`_NXK+v^&Zt;y9aIrXjohZv24xCLd27-> z8BxHlM9*Qxr(wtzJ1okbW<#x?bgL-wD+Z0pV1}~B%yeLgg@sCBC?^XH!ndXc%KTPJ z*mJ(Dxcai43l#uU3z`3e04ZcR36O$VirUKgmnEGuYZC$!BdGeH*1uAulP9DoKUubz z56ntG4WykGf~2rVhfW#`iF_n}fIFUPL3E$Wj0p)biOvEE-CTx+#6cKN#7p2diV$Wj ziL}*AV!DZgR4|KBW6URnFFV*l_20DD$uVs}8kiW`TAC-!b%z`&!O*5a`;ih9V5P(b zaBP>fQe`LzY4~weQU_L&1>fjz$U*(L7rwMj?#xWKLQ=+-mhRK3LsM=kg1Crm zpJ~I)HC}LDl|Basdc2X)!<&m0SPA^$$gs7!RiKVdO3{T)O+S;UURJ83LRF0vWB&uo z!0Vw(&S_}HC$tOBDRGt34Yomh9(InCJY5UUVf+toGkBl?g#vwD%F>EYkzkYI9${dt zdIv`TTG$_}P{aT<15R`r5C<2I`0y5&CCIWIOR)18WNMWsp_tO3dm{M3_>o62oi#BK zE(jL03xg--cB&=4_~L77LJAJbF^MRL0KcwtQMJRHJ2F)@33);`v_vyOdQup)zR0Xs z15h|rRz=VsO*m{k!ruvvx@un{rs2>hPJ{j!%DPb@(cF=fEkG(j7o$`Za$&scwoo|f zVhh92{cOkAtJ_N()bZL9El$9Ia0!94_(8~dLI-r-Z7fk%`-;VRl)@t@<;%_*XF?+W z$?2-@&|YMbl$#Bwl#Fpj_M&qNkjN=G0$f%0!o8t78;n$PFi6>zlQ9-gm{qOU7y(=I z?3Kmqq*>_P1>pH9T>X|g0|i9p>(v|3rDE&%uW~=Nkw7W)twNFl4;0NReZ@b*-heQf z2@z`U%H2?6PuM^jSB%#!jAgFCW`rUb@ROKOy>Pl#%B0p)k`ygN0HH*s!X!C+qKK)o zfV}&KG#Ldl4^Shbuhx-uXhZWN&gZ!a3~%Ry@X+3xz>5OC0#T#+8X8NU;?d>sd7`Vrbcg_c~VyOvJ?abSniVFIE8ii;)1QIWF!d^;skF zBlM+4CB{(F8EW@&-gpx8RhgO8h)_5)j2xFk4a6jhKM0=ztULQcZ)?&-Ab9iAhZ9}B zO$gxvtS6I-!QR6hZS_aM zWY-m7DYJk4HbKIce;|I-9Zdd4mJu>9uWs;8mD=!mIfPF@{_1NVVUsb}%9EQ45N<#Gyum;x2*t48nb` zt6H|H^h4;0A}G8Ko(z}GC7|b$=8Bm1U*>$0PT5p!KZv5brUGK;3x_4_z|*mzHqwa2Uav+!scypl5-=+{scdJ- z+BdOS9sr4B*#r-?j1)0@Rjo0kOlDJpu&{g1^?kl>NlFYAH@lMAG+`wUMB!OowW3U+ zrkJuKLEG6>lmjP@r(MYgkz~$t6{{8b{lz z1fddmEj=tHA65D;D4=ke0O*80H3ldSt(wtsHY0z<1WLs)EE=a0_G5ILNWxsMEn<~9 zj4Y$oiXfAP@_b{bq!ekVl$Kws?ZM%i7ZmwejMB)!85{3#kD7N=r9gZd#mEvu8STrK z5Cm2O896i%Y*7vMKYof+I_Du_QUx7R^LI92QqbAW~I$ z`6eXeia9shDJoCRDkl0T6}hH%hhU>@^#r`m7O`?10~>~vs2##_kF9EFE+3X(pCcwv z5h>Y2f8y? zBL?=xh;R{BLbP^qOCT%~J5Q-!fmm5rsYUvx5zj%U;2=oMExa~{fT^PDXa~b74$(2GaXSg~K;JJ^R-i}o($VEGfQSnJL!DQ^ z--p{yKD`1gNeja|g1&gComYLIrc##gZt~KUw0{5oF0;Lzwo9bn539FI&Q<4fE>+Ua z1s(O=286LfRPz%^oOS~td>b%Cmnqt(ts@zsREYL8bRqeAa000QueD$bS*Mxg5Utsu zHgPpt+jJ7wv=4x5XoQMsYtb877D_Z_twcuHB80%(t(dbcg{#TA7Cau1mW8b}jgN42M)A77_H!2h{2-QsjAN2My=`_&FHn6c+3pBz4{HriWUE0i6H z`lB$t?(RCSf>sKep-)V3F&QFQuw9jE>U<3%kS@Y|j;WIP zL`JM4pwxT?Lj2~H$51Pi=?9P$UXtYp>~D~7&+NpJeXdq0dL}5yR_`*dRJed+7;*~z zew+Evb3j|^DvAYb6JK)BfD0Mvi<|?390IOOKG++jjII(<#|~yC2qK8EqM6T&etA64 zgSA%qM0vq3PsV*PO{qhsmrMiiA@;38?QyMVRufyI`k`6vZ~{aFkdAVc+yplg?%?=F zDlx1yw(bo%Un@IN4i#lZH)K^@@oVi19>*GgGr&=R#e|2Xo(8Fb^p~spZ~=;C1Zqyr z*ws`wgcZDi`PepAc7a_b%qD9Ds+4ovPKK=tfx4LYOiNslE=so1vu=VakddR@Oh+OS zl5#QpYn>b(uq{xYg-*eWKraVkO70d*s;MzJ`C1|y3)F=WQD{!&G5lJJNv;vfF81Or zJsdgi1Wzt6*ST_+PlW~&CWwpJ+)&#+vYz9vRI?CHJEDef2f%t(W!8_aP2r}^5oZ8- zy|vjhWXDoRMsl3O1yE_wpV_7{Q>hkfhphhEvNM3P{S+q@Y;U7GlOn7{fi77QPe}?6 zkJlF9n#Mp)c1Z@h90CC4CW!?Y##9Y><-7$-Xp+tB>CmEtEVvltWkj|nB=YDK`dY2e z@}`%m`2D)^p0-aUCW#g?Q+AQu%yc{E%z6^IM=N3~KPQFj4{D*}j38)@Sa}&~<>E0R zP*R35K|bO(&C!k8K`KNtxgjl*f9XZJ-?jd+<3YUFV4LqkW^zVWIqT23?(Ftb1F8(I zyPF{i`9KnD7S+%QJJxYDc@}&4U0h<1Bb^myfojy0TrA=@Ah!b}iaeQ&1XW-|?W>4f zJe?S!>1&NgIUJ}&WR1wTkWt%NjZ2BL0aj}I7XBnDE9)|2@=K9~lZ#8RmO`WI6{It~ z!VQ54GA({p3526jLgXJ~S@)K!f=C%bl>!!*A$K?uDqt_7l^LnV_w6QbK-T3Ru^3`n zi*5xL*CWO*cov4*Au`J%0Kwt5cQ66O4pOWQ&~~0)d3F%YBt?0bi*E&3QYa$ghGg+h zdMGDFTOB1bFRQc(6JVV|#n=Ooyrz1UZdJ*pVFu(zYR59nLsrXxgbKd}$x=$u`2#zn zlH8FACZ>8CmIn%B`!rEIUqVfD%Xogf2+^rCKXLbvB_k+n zBd|~=he1#=KpFe*rOKTget#o<4Si6d(O6@Q4Ozra<*~?v<+HhwYK0~;DaQTls2i$M z1uFeihzL1Vd^ZbLz1JXs5~b3n zVX4Oy=qUO@^yVB!Vp`$zT07?_HpEGtxptP2oK@9*ny{82F{IbZ$TA&v4~oXx zQ%M;~A*hY)g!`^a;0gz9jucI$PX?|Y;-9Ls*A&=kq1;XJV!^E^sUbJpCju*1v5eV| zhd^$wwxwW|UeN6s-b`Rz4KQAyDqRCiunTTn`IN3B$Xcy(LFn(-K^$T9*@?wXJ&u zh=eyroQOC%**Dtxb`F>+@k$DOOzsbFOiCd!kdn=qat%nEfi&L1wqV?7n{dGd;?CfL zd2yZYp={eBZAmRvo!~-a-zBB>z!#vV3^0-hl5bv+R@Vq(itG1)s-J0ZJgzCO4$0!V zy4b_gjY3=+(ytI|Z%$_rP3 zbrEc^cW^n>MH*J(dO-_IF>&LDN5xJK_2LF$2IVko*1C`=ChZ_yWxH23Qq{mINn$Ar ztR2;;7l+f;W>b(TPPFb|h*STe(BKjavJ*<+me6_XgR48y!YGn5tx`vqnGdE=(~Irm zvefLAxOTO==6)NdqlD!+2@1t)Ojg=VfmnHtnhfZS0PR?Z^Ne+v!=xoymLZX0_SgXy zt`dgek=US=PgIU70;h{GgkZ;Ec4V@~fnQ2_i<_^d=?8EY%gl!PlmzzJ%yBKeC-GC0ZaY#X0?3fef{1=l=PZ! z9!<1nKvtvyVcvDXI@4F4l>$$RfhsYpQ6q`|Vq564AK|FFlUBtE>XZnf8yx5XXFS?F+K>g3e61q!uO z)~P7uf7ODO{_Oe0id9)vD|VzV_kPVYN?6gyRx&M>;1+Q2+MBx3hOuIPBWgIpml1vH zYEzF@xUY7O>rHXR)q0H^bRg5q+>?tY0|5=2bhN@3i-hJq}MlTA)Cu9OL4M+zw) zpd;woc!j%(*l$S;o*sS<$t*HL2yo~Ku_TF3WkrH|j47=uj993EAsfL6N*#CDrPu`t z@L9B*!;8M4jX<<2Z>suzNjAobNqqo|zq%kmO z+Ss7a;z@yh@@2VaQD`<3VcobS!oso@Hfo(nNe31XR1YgDsdf`wsS>>-%oSZ}HIS+4 z@{r&;irWm(iGa7Ki_H??+kk>YxNNI31+&sO45ui0x>7GfA2nGaZTk`-1zI||(Oc)6 z&93jSd{Ht}L86EWh~@50Kp7MUfl)~L1=pKP`FeCUkb#12@#;M{?qz-x7+l*UBZ$(_ z4(U!htyba*$hEOqQqohH!>*Q^E<(Ya2?wz*$5)s8W4|$B3b0mQIk1yJhu!8suBqqCg+3ixlMdf+0#_0DcwDTs)uTc{N z%ygYE**0QaJFu$>T4P%Wy^8#{sN+E%p1M-7!g-e6l46QfhyYiLPvVZ`a^!M7vkQd& zN0j^%0KG;9b%&LtU>?F2$l|u+n^X zcW^eLazuQ3Pz8NQ{H5YN0^>0yaoqvJ5q;tS#DF0PvWqmx>f*#dP#GT5Bl#&J83@Mh zcR!OlPY8fS`-?@^mnYIP!}MjXOHVoHRB~-BU9sTzQCWhDD^2R7cwb4cRL7#Qg{3;X z!z`6kB$DJ=vf<+3LMQ+o+3cDW>AzqT1fN%;a?803fs z0Uw21=@EX{RW0Mf`}@tO7Boma{lr&aH4m5;mjBkcBRFB-xeM*m zpTc_LD_~aSr%^yof;SuAGNlsu1TNv7TA{NY+0gy7*|>U^9c{MRF)v`t;i zYBKAHf1^OGS+X@I7SE7er4 zN&*r%i~1VF$^P4vJ{DP&yg+yeC4k89u+dFM#|C#~`wbY96DtGnZB#WDj}N@lEov@) zM7VnkQ=NSpZ^{?rH+_Z-=`p4w#@1G&abVF)m5a%!u+c>p(sZz0nrjHhMbfBSU#>~PH(L~e4_c3d2Dz!;H}2#paH}B@L=bo7B94KjE<{C7Ul!CXrnxwYakD5i zGa|~S67Yxykss^#UI-x7ZHKW3u}al!FqgV`FO*SfQl=RdX}G?&8zy{=hfOh3d05*l zLW%C)FOG>)9JCW*d||X&1;E1*fIbGle*g0GZ$T-M0Zw|MR%YQnj&vv@ghRj?^V!gEPn4m1~$5B|>bb z!A(rJT#8-igg7h(m^SRh*M&+jvv4tjs>cSaPyyCLmW^on3IIT zMgvLsf6cMVl?&D~sipEybUv2;1qdiX2&N+=pCLokuVMnO@7Li?3n>BlU$q3P@Q5hV zR1=p&zl23nm&>J3UGJQCQ+|>XS~$G4^1|Ucs;lMI?HZsO!f=B4N%!bU;t-;6aGlUo z4=zZlv@)$FWoEWKv}cK;!~kxt;|f0V97?vPveS3u@Fp%OUK@ddfvKV|O-tj;;hlL; zhkTVlKLtl$BRDyv#D1L0VhHxty&jQJt)4WRm_Oi85Xco#xg6%&pq6T@d*PDFNFWv2 zY?i7!;L3p_wI|Sn-IXM0*`sVQd@ISG)~r)mDN>SsagrT!tPZ_%$Vt+irIDCR3?Y8C#9$iieS>WfIQ zxrk3iOygs4F_xJz1(b{4=jbqQe3Bv^@BjrVWXW>ZJ_*suN_o^BMD;~RQCcuT@j^)1 zl{g}16F#(*E{l{=omyy5<>gc4SXfffMfBl73{@Wpq1)NE%0G1lIFfyIYiZC!$ssH6yQiQUHL>X569lBYt35$O0_cuN7c@}4^rqdD8to`6ZN#G z<*gV8Hc39df*2S<=N1Y{{}?$`LP=hc5NIV2m(*M67`wwUPCqDOsZN*oU2{_e$L`^h zEsrRDT?#gcu#Fg0wbr=AN3dm>O#IcT;_M;0&d_ysR}UAQp=n4n2v_0cp%8u~5U$Jp zCKJwn2D_o`Dtx4T)0ru8buqSd&G5Y?QX}yhalolU#UU4?3MbevOV6#+@^mw)1ukOD zD>lpHAJQ~@&p|aAWG~`)YIYpsPe7GY#a$q$^N`+rn@Uh#&etdz1yR<}!30Fm5^_)3 zvpBj+5(iqd2SZJs z<`&*Q|IM?nUVQQVm%o%37?g2+9zkC>62oe^bw=Oh3W6E>D8SWV13`}fW^zKcQq=(^ z#Rk_jiPunL#YB98-VilWYyBBNbjjPhE)7_TbRPTAuLLoV;*6#9v zvP^4}S<;xvhI%aJt+0ELQyOc)6xI>}rx}M`7N8}`lNxLv0^u8TE8F+gtpQ=d`hk*} zm8Fs{retK_RwG}dN$mvdO$Dhd_Y0(qV&y7MqreX5DY*|iB_&B(mYF1h3Pox`OZmbf zCNwZtxq#0C0)|($CZS$73z77AoBXwH+-I_kfq zUd5nFo%qwAUjFXe)8Bs+$5Glt6h&8Rc>MPKcYk;hzsiab9W*E$msplaZ3M&;KI=uJ&e+nf$p4WKDLQth z01!CG&nU+KZ!7DLTao|d0{{HTf4MvVCoAhZE`-_#4*ox<&Oxe1GNG#`pv)1cA%gLQ zGIrQiODo(DdWMyYLwTlx7{V#)fz4Z$Snw$paad(kzS!MF`Tv2cmwmIow}_}!Pa(gy zeTSlm{aFQ-Y8`etSQxy@?$jx5Ut2+4MYvhZx}q-SP0|e!v)T7-J8^@QWd>n1Nf>H~ zy$Jv;zI*NiYIhx!t-xp~5doW@3RMWPG=xm{Ur{g@8xXgH0055@8Z**t1}|tp8WuU1 zXn9OJx*|`A%urBBe^Ny$5jrlfZe>C^F07tt0u_sIQWL;+H{fm?RVtDHJ}u2Wot66w zqMQ=aJ{SA@1yQwo;t1d_lz;Gc1ikIGV#V^+K6fF%V> z?AM5kIf9F=#b`4$rrc`=u()u5noy520~wF&)+n7Mz^QG3EhO`Z$k?zU>l*gDA0Af@ zri2aMzTIg4IG`r!CFR_d!Bo@vmH-_!zzNfyEl(u2CR|iErOXN=`LNCk&8E)EgUf{{ z(+fKzNmO!$EV2rb^*j{h@Vu61l&hkow1}ZJ;4+dZEm7>j<_S6W>q42iCTBs+X0YNZmkITjVw@{$+s&?x>*N2E5>&^9{}QafhPadkY4A~_x_ND?D8 zE+$q9d%5TK67RJ3H+EV9e#Ueuy-j+NE`@E@resbov+(^N7TB;Mf^wm*c(qCn(bfQE zJXYljMr||4#WU2FDrcbfiqkObT0y&{J$Tm@`|3@Cph)WBUP3=t33Ue+Q_J~9& zrhXzkC6c|9gyac1&*J7mH}a@9R-J;#+}#FB<@qo+JRJQvPsXNsd z%MdOV*DR4unAiT9hpM+m|DK2}e6Iy7xpQSjDA9tdav4#NY+6o3nN!7MuZoNrYo-*{ z*d$0t0~1Gw2%!nAO(+XX@pM+OsKeCrkY7@Z^SsJMP)rJ2OS2ruNmpi(55sIwos%ZaA_<^AMD}*nhDt14@AE@fC^|eE5adVt&1g%rORqPUsA5a}?m7;ByD{CM(8Dn9LL{p701VqE!Y-}yQv6HamyZ~FK>N0EQ z;T!T4K4O4N>@UbkiM^=gc!-4{C??v(LXrCNy6CR4#3V>@y1sJL$#Pkv&sBp~FjS|( zX^&wARZUls^s=vr_n1@dv^TUR2nM;8#l>MbT^+rY ztE7n*D=Z9E>&^U12?!b;u8{U5PF*yHnX$&1YrRm6AW^!p#lgW60mG_Huv$Io@)S4NO5wqVD0xVwn8!ppfoLJ_R7!f1 zJ*y))ngnEp?*s{yIQ5s+c4O|R=(3FanutgyHDsR}=&pW7x1o|F;RyDzfK%fdID8SIF3}>vuiF$aRo+r40%WNI{ej7z1V(%4xZvk=2ts(RzLm?EnBe(?}uC3IpmWaSFcDPhIl2_d{) zgIYT=3K8b(Aa*(8Ph&A8IqD)@-at$hM|I?mGiehGp^gr3k*3MMGia4N6`7=?n=Y0OKc5{#zM1P-9WYAs40l4Y{> z;er&q=m4=MGb zQupQpcht>7*T^;0kUFpEfpR!g6hc-(Vs#spR8Fy+m}2P@I}nBAPI8Z}P{EoV2qkSrh8I#tj=;P+0}lTcdt(t`szA0-q^28ZZvESVO@k zOur2_DR?B0HTH!D@Vaod1Tffb<9?v4It7k~Q3Wcs7u>ziic$PZ4ia5by26eS5L86i zk~+8MACdubO1kp^6&fF{HhPShl&Wu|8`rYhK32IyD4Ip4!J2rWXgZv!ihQDKDL*US zGzV6N%uB2hMmPCbIIUU)Vy0?KS`(kLJ#A}=6-?#)dg+qz>#b;7J0b~a5;amdS5}<^ zs`6{#N>U_{#wbCjeo0q)C~-rMAcdH!T4@RN|JXIweo5(qi5iRqQHp#70AX6GyE*?+ zi-G#NGkNHARQ`|ls>v9TX1jI~Yc|>$T`I-U;G8_aP87h4Rr>+={!cbhLWXQ#kv`y{ z{|RudGqV8UsVRyl$@nCuMx`8gsWbv0dN4Cm&jSijqzHQ`!LnI#y(VLcQ4+{F2&^O7 zT4vYqXc8}8rFsBXljqoDUp?l%SNdBpc4b+W!)NhD^wF`}O#y&;P&sUnjwBdnVEmwY z={`kG(6iwlflLk8$z#=6-^hVcUou7(b%FgTsve z7)_Ny9K${;xdnOuj*D3 zaoRo!0xsHT}V` zn*@>Qz#1L zn)KTXJsW|^dPgDiY(5^&G}E#BC?Sr$Vpzg5Vp59H_NG%uRpNuU0TF|1S1Vv~KW5^C zw_B)&u0(1EV!DJ0rI0Y?7j}noDyh?@OBJQTm+E6iSCxMBoq)e{rVD}eZ2MtL- za2di3>C-Yx&^@9EWbf9P19)5hp@5E>hLOORu+o6sa37+M@cY@4!K+fop;7PZH? zs2r`ln#p?*PgPJQNp-#Oi`|Og%aT4|xXW+?wEto;^1ji}EH>IYX9B_ek%0X@_ z#~Rcfs}*~PXUnc}okf^DsE+^&AJZCvP89&af$-4XL}rq(Q#Q@QCmoKNQj9RaIrgAs z!5zY-Am2vK0IF&MV5o9*kfpzk`jrk}USV9Uj}mn=THVe0CL2~fR|cS>$P~+iyUN5D zh?|EyR9QfYTIB_tN$R|4-RR)aV$sMB=D3;1&qy*-!}T*zBdEfdjVLlx#smd&T))pC zdBnq5DFhgqSSz5OS8%UbyuwlU`UT~!$!AbCfk@Elvfgo(C7g6pEI_aE4P%3zkn1ZYLIiOIrtkb&QyZP$)8QDGp9C{S7}1V_oWoGfUAT|XQK(CkhK6ZT4*9Z0R;!(py5Pu_y@D|;W>hf!{H497zwawaRO8?aOaA=E49Jrdq3RVG-25V#JR*?wAe^Qlh_k>{* zxzZBe5{6xyHjqw9dj;vB0Wqk-A=h4PeW>wZcTp$_R&5Df7|$L6q?H4t`oUO%9LmNllpTRQkPPtx|Py`$22*5~f$s)iWQ)NWsTvE)Xd$YQs(u9tb zaWM)b5rhvltXUOQM8)Ku#Vt?~IL#vASRMiY!<{Yz6s$b13gginN*D&w2<!uz2T0s&AObScq@ zBMx~~`lJbsLPGY>6>*M3tNi+11^-|o!|p_db9fM`y@>p}@t_p6LJW%vLe-c6Vx(k| zh}uwjib5#>gx5``|3 zL*`M4gejQIZnur)NFwymzH-LF-(i|GqA1g^kW!Gx6j+uWiN!<+%@vebv58ocOJ@@G)8BYt{U>5xOW}K5K*9#SUTfb}BL?JFt)F6l#w|7==#%KknYO$*$`- z)BNsVfrtsUYkC?~73$v6(-WWwS+vBS6TG_dTbHg0u z>OmTkGzR{XU3CvYmRCQ#u)Lt#mH`w{F9BP<#S`*cPb z+@;}bZ5+`3wW+knz6-c(4p7i2~c)frj=f+=<*EtTbpfH4EW$lHJ**AO5 zi`hpV9hmV-4~Gp6#j-YReP+&aqSB2TUo?}FY_!Waok8P+gp|)#B(BeIELn0dsp1R- zbd3y+r%%J!JVh`ns3&JnuP&BS0a@!2YxkGxDdZ#JKeGaf5YUzm{r_@MyV-~@FRDSG z9WXOR13zsTA`aWH0huhFRor`j7A_q@v3|PgMKFZ ztt_xYKeuq9KUmg$`1P_&@PQ8Rv(1ie$AnBD|vnboWJ;ZtZX+@K8(h<=CTI4SCy58VYD zlMP5cmAZ2ce0&(I2Z*bisN{)Q2d|5JXisPsn9jL+-f)8jYfv&*su(P^sr&=>Qd&?( ziWInkyd0mQuP0kKdP5~lb9g4Bz+<@xq7qWw5+pA`HM3<}Z|NbYw;Uu@!|euZRmfhnO%jjcVIkoqzy{5hdE0Qo zWyR(z|6NHh?Ifm36MsZhnt0_37iLn+g5uqRl@DXfCoKQ}kA4!z%=>pItE>|0Fx@_@ z#PpZHZ9j=5+(7p^pkQBfL@s7y+KLM7%DE5~5jvW%I*UIU1UluyiLsUv_%Usk?GBi)V?(|-BWgB7sQ-pxwLeR=T%@uJ{$R4pou0H=Pn z{}4#-#ZC9p5M4IO-CfD4WvoVdsu)~-7AD-{7m@qn@ikv_$WlZ(VW9V5P^)ZMlL++U z$E4)ec9d>ce2Xoypt-tzZjitibz5C*m)hLyux&SJ(^8R_5f=^6NIJVq4x&<5iK zt7Nf^{G6oOy0R0u2__@@;Ah6Yx4xio*)9fJ(V+-T(73EXg86GOoA+&X^Kyx3aRGwP$K}FVZ&c*(hj@r&_>L|tEg<`fMI3cPso;|2c8h^>L7;noQcbAJS`RTQBXBI))_yWFZG1_8}2 zbYe4s@f9g> zo}zt3UenDoz9jk!IFH(H==2Ks6_}xd7k6pW=dKZ&oz|`yO<8A19gm;Ez$CdYqCC%u zpc}Y;Rl_6p9@( zUbbgIB)nVu2=YOjWx^P0KJJ;N{{?63kQa4l!&17KR`Vx8j>XYMVWo5i#WIHJmR1QH&m5@ht=3q?j0T2l%5vol0PeSQj>pEtsDg7{7hW@i?&}LkR2(*Qu?Rsu(=T zQ#B%?s((ds4NXN0Fo=u+8?I#W%p`1kiWtc07_I0SQq{=Fz&fQGS#iTa0oyqw5=(%E z7FM{;8Bro0m(;EmLKDs!uEgPS7z<1)rc>I?RG8jZZ^M748~S{Bq0b>j#r5Jo5lj?n zBZIZnjbeq7a@4E!j}{;)CUx%J5|roA(6>M{SWOPoBCy$=!;)B=(cEvUN2bk-M-+Ho z)&^y=sF&-o#-~l4nS;OluUQeBncIUDCm^ySB&t~!pO6-+5dP`aQytbd; zj6(fXTl@sv44#nU@g}hr*)VyMHs|CRP^6RI%bXl30%!Uk5ARiLg7;2dvL=%c(#Ic& zFwm(MThrOxY)D#n#` zs&uoz_kZyhB0UQ-TqX-z^0mDed?okWYMArH*ptF-L`ec}7# z79&aR?!o{1?_@JGtORTqgSTxAw)@rn&p!KR*;go$@5~*r^}@0q`WF;5;4$0K_>P?1 z^g}?q{2%|rysbsPSGz4tASc;FqPdre)i5&vC^5U& z)CtpV_WyeN{r5RE!z-`6ic~|mgHe9U-kbMBL{T#FGI9SDItm|3);}m{A z;?4PS5~N}G;l}br0gR`Tt4)RB>ieIHr)c0W-jnpeEul?!#*pe*jd$8|0dAG_BPBm&Mqv6HZPTM>a=h!)|>3q5x+75vjRMjqHuYp)vMz?=9H0mua>XxGFbp zI^+?BIMX=(#7OY=3TA??1K}RYu{zAbzexkfi7#836&QuulT&w z8~O7v`KqZb7GIdn6pCWR8F60epqyLk7|J@l_uGnaM=L^D%yZS=XoWE_RjEhUk_tm$ z8-W;Gv)=Cw`o+^a5uc#Cz7Fd4CV*j64I@}$>hXkOs7?!F*b~>IXCU)wVO%mzG;xoZ z8iE8)_X03Z2v&{)7%uXmb|bXt3Ln9YKt~FshzsUri^yRsNTM#^g4Q)mn>(n=KFAgvS=AEFYT`yqfNd!gU= zw6M|=;)S|~NgN9%oB@Ip5A!lp!u0z~#m%O4+z+elXHo@_VTYtmZs8CL(f1b4fp@Ou zxCsXR2;YuA045bGtJUr`vCQ2Ai6UeYOHz513g6*Z?A}t-aoAcOx>xFrFkxarz=dHY zZcxWS&Pb4S5E1{JM z>(EE&lB>uLD?KnnFVZ9@0eiB#Hw6 z+6aMG?42vn2YGNjR*8R6;}V|Z$tOzQ}5p`930<1)R; z>4{Axyas>S(caNNd|EyZa5}m)c;*nTNG~QS>LdOaDdWy(ui;|kP7;!FeCLZl{0qW5 zYq;~-Gom)>{q~l}v_N>n`O2x!ee|#qq1)J|F8GYTN2jA@PeLCa(z}FQNbaZ|PKH;|i?S#s>F<+8jb&f?Nr;Y4Je&f===h@qrm*u!2E6C1r0PJ@0 zvkt&q*j+Gr_uf5E3y1Q=e>p33JI@o8Hnz?q2^+=u)L*zQG%`2uxeHsnd#~S`BOKp3 z%K)6{d`}eL^1Xx2?++NbKbKqNjAl_;i}W}~m;;2k=KyGyS=L=g;y+i&551M~eH60Z zK%lmKe|+b>)`)^v-vg4`>fHnAHA|A>Cjdki%|uxmg5l;7KpL4xpa^aNs)^fQCn?iD zx*)OngdmmWog9hXC#!Kb$UU$7NBndQ?uU?jjvD0N$6@vH+m^LEWzO8jBJyN4&c-6< z9}5Iy5uTJRVjh{f@A<{%lZ`3!)$WsbEn-eme5Myccz5_H{7d3meS8NwADr$!Sx;GC z?LJw3wT8qpNew<0(cA}S3me*;a(7vIvN2`8+I{k_Ma)T-)k_l+$eIOG)_mvwna{HR z_1p5N?OS#}3!7WN{r+1voDbK#fvERnv2eZfFu=lmrfvD&Ti<4VTQSbc#RXSqX zpS>cY6&0pEGDzJgSXvG>@J3Zo(yv*g;j~SnR2=+7OBNxQ&SI`X5G3f~@&zRpW*-{k zUrH^3)8b;U;Kg%hD-%mpwTS46DNRLA^#`=={pf<``jic%bjR30xG5?#_scV{>6}`dqN;8-=ZVHIU$js zsUsNPMpE(l9Rk7Wr}pOi@6q)kEbaAQT)aR;GXmC0eG&NF!8}lj&1}?ALGz*bJGwuP zz>z#?vAf_U2`kg@LTJVa0jF-t5|C8s0ih=9ppy zUqTE7uZ@=y34u&wiuf$w1**`ydP0e(R}}@_ke6?UtGp}zW)=jJkz>V7mH-@ar5dx! zGD2?XI;V{y&IRwJeGNkc+w{~dIaAPwmXO~HPOG+k*NY1V@fIIqe{gef4OZPjeWx77 zuV)+^HoLYm1fUqjDorF62P)40SmVZHD-o4xN7q9&uuN=fPZl0Pc>_wXNv#~R-kE7v z1L-LF80|zq#5&SF{f*S{#YxHe;Ph8k#~J3P4aQN^Spc@UhafdPu+VyXe00Z_$2_6Y zD|tfXH$BmDK&CfIp(BntQ?iX(iscbmYz5F;9&Tg8w0VkY1=0vYb-uTm(?G3g*d2Rw zhP&|9b4bP+WLj8P}RzMH?`F)o#|FTYO3# zh6wX_vWf~Rh+ELBtmWkS!V`Jw*?~<3E=l1<_L8@%Y&rz?o?((%j zJrBRtt56eoCx-h9P!^@p)IVx?{@pjf_eaB)Fv1f@RhI|IA&!96WZTJ3Fd`-XEi&ya zQugv0K}!xR6vEMMV%^OTB=U7D&Hd@&C(KNg&h2RJ8C<9sHyEt`Iw{2~WRr_`awIFr zj)?3fa?8|QL1kf!=HFnsKv9R;XxLCsAqrFH{UTm6I3`(PfYX)B*x1k~(CrO7q00PT z1=kXOEx@=APo)s$bfZF4LN+ipJj3@4N-XFm!DUuDFz_IR&s|Tw?Tg1(vxp@TQKq98 z4!l~nq3rP>3+;4fo-@Dx$IHrmxvDFcn~Uo$OwC=f;xVB)n+ta|NO2r4EN3GLL9PVN z&l<*=6uYbp#r?9z=6*_0^S&f3rY^b4Dz~2Q*0Rj%Tb6Yqh3DL$ENpTmq`eNkoB+2* zOdm8XNe!Vo8%D9kVdJXk)xwsWqP8Ad|PhAtE`06JEynLO0dA#-?G<*@@k5jfiL`dhVbJK<%X&tWHW1)tdazo=lJ7~AI>t2 zt}9-G+NLWzyoBIYxJ4of9dS5FF=H-7L$F~xKdQKz?!z1e8^KgUfr&o71{odY;3^-1 z-aC-7^V{HQMZECB5!TONDLtUuE_|3-@HVQ+IEya9DT)zcVdszQ7rB54-$n8IzJdS~ zDp;^0JXu&RN0Zr&zwe{TR4Gd0w1Tkk#JBy?yLU5c;uTaNua-v(*apLm(sSrs=tfF`+MG;olc#YITy&P+oiYzNmX(c;04L}>LnI~eCf#O@4b8HW%HEoU%iLHRm3u55(5jno zoB>GC6tc~Fhg~$Xe9=S?8LPe=gtXyUh}exM6C&4*@U~phr$cHXOcG%-F>kDb?tWbFbSaeHdp^dJR)3#3}LBpN0?7e3PW9sq= zCSbC4E}y4=y7xn38G1UMvX#ijA4pssH;N-=%Vszz>wifZQ^Xt|Tclz&EEdDMcJLaG zTZ3>b1NVXk<}>|f!Goo*%Jod-29kP24a?hX9Jowwl3)%3JLk>}pE+lHm0gf(-X=0v zg=~XJnsEVqU^ddeIn7)s*}2_q8fsQLXwlJ@l-|0D$fb-dfhEFttJW~)rZsH=g{4_c z-PdTo;4u>&!_Wj40i8Pk*MTqRT&|PWiRFil)p>(-i?@ZQvz0)>WQaN{%GF^i%{y#% zwn7CrV2y=|{bcXU-~aA+VW!pu`aEpSKC72t<#D*aN)QTCM$_X%dbm*U6RQLW?>$|EME|Fi%c1{bsMug`4EI()%I&|AY|E_ zDNs#AYaHI_`5FFhuX#gfD?>$pBF12EH(ZwekzEl1}I5tgqQq8eY6{P#~bm zA)0X$PZ6DQYn#N#RXRkt7e7}B3BZH2w+6+Vk&_o@X3xSR4eA)lFQ%~p65`y}4afb2 zp5Hf|$OPayZOEaXUubRfnlo}T+%#-Ut7cOI?6Rmp^5OQnK{u|r6>6u<9=O}P%k?-} zzXC;zC{}Zkd`-T6lY#^m}Q7^WQ) zIFIr*nl29+fdYYPmP`fMX%={A`4z^P00Jb2gL+}}31;l+QLV3bpEzuPwYczb057xD=zfX&46Y59 zOyvA(tr~*)!x1bYZ>K*Gu2@b=1?oVNVo*Q_Qu>BMfndKVar{8=&7`k!7}}-d=__0z zY-V7nNpy=Mqh$(Lr*|?UxN0XFSRO=zNQ}{6XyrseT1^hDqTS(>+;k&5V!~-M3CcW# zGIqr$yI-@Q+A6^j+g}S4cK_Dz-ZLv9#Xo<^wP7k{{=5wbjX(G6Ed1wwT)dXVm1XY) z9*kcHnNxASfwTEU9L*>BYWIm$@HWCQ8;k6VA$*r@z{L zvKnVOgtDJ8iOoxL?CK1{aV8aWQpc}j%Y90g4X#F-@8ql1#Jl4xO9?+1vn;CuEZ$EL z^_|>PE07v*38UD3vYs&??L1h0v$29XMGftDEWmbG_`NXt4#^>+=5M0O!HNhMUGdKO z+W^D4H`a;=-pPYCo6ILW4_2S77I{SH&Yo_LGie7oFQ>4P;jd#Ab@%N)S%IRz+I_P6 zYGWmZCjVNa`z32B@*c;s&y>H8wUpGb`-J+r%R4z!yH8eMZLDRPv_|(!;nG)UliuoU zLIXt1?vwSLMfkfXVK6^R|D?z&$(B zvWO2A&04n%_tg?%Qn#CuN}l;8$IW<%55Jsqa{IU8FtjDdl-?Qw2 z=v%H^+~0oPEmf?>e&4#4GH*S0*zWD$_Eg;dZ54^lx8Jw!L*tV%M%72g1BO_%deB8;N09~vefS8$(pIwSG!N%%4fM5=bXz> zVQxyw-Ub`eDRD%Crmb19o)IQw_^)aqE|#NVc}3F&3P&Sas50o=UJ`T7^rdhHD=#EE zHX*LKFF#EqRLmy;_Bd*>buWN%+?H@-?91gzPdvs-5hn~|?e)*Hz;(6p#dtT37B+C0 z<|j&`w5c_EE+Jtt(Lw+=O&&eMETyrC>-^Ee%x$2i1PIADL3`FnYCs#I(AC#&MMF=p z;ONuM;*fPnO0Zmqgke%zcN~WA5cW}7S`ZsngIUzatQF@?n-~&iSC%F2D_S0mYnwn2 zjFqu#S$?fM8gP#QzdW@_-rC}lB^g%KK~|t zUhvel@c_FKD&Bt}IEn1BgF8p(80{V=1cBpZI`r2|J@R$uiRz*RiT!gmFu*+DCQ0m} zBkqBKI7~Dh(BOF;_CqYT)i)+p)3CaXL_VUcSAik0fU2Wf#ylKG$vSz~NG8pClm$)- z9&lS4rC@c!{WDv&S%$q#+Zr!N+3%czGpx4rMF^~I;LNSxR3AFbDDEE3wxTi_oe8gy zv{um-Q0G#af<82(c8*;iA74CviXpeBoVG$eKbmr}R;R7Z&E0jYh0JCqXCg^BXm~k> zqlu4jNZ8v=3m|tM^cu&Dgf_biUOvg$v%}=WDm9=*Zyr&O(aeCt;A%O|GGb=GQg1RYvU@%&0#HLXdInN2F!o|Sa1+{C< z%wox?8nz5asaOdiM?s0lUm8&JqHnI3+f?x~%ror<*uNKm#qsPdbCuX0&wL2Qv&7JQ0%oZ=%eI4eH; zsLDyaB(l_IoRsAmdro5`3KD7V=k)F4wi(ex7{hgcjzVX!Fyg@I0ZOIL^8Xn>6B{}e z&Q|e$ptQ2+m^L-~`1KKCqMjrDw0I+?#S_CCc2O3Csk3KJIwDC&dM4U^hM~C#K~zz* z5X%Zb5cs@`bV!q*CYDUAPc~ag%wt+1ynb4acU)V0CwdZ-yg1I=q35lf_u7ifaREuZa>w*ziQA+MtniabP(WkV*$ieRDl1)6pcCT2_2dr@kl?F?#U%ce zwBuJea``I(0~Hcf@D+@9KETc^04+y6!n_i?BozfVhVgx#XrXle%Zy~bmP?9I3;bv= ziPNAx@L;Tjbu{x~`y+@XWlR_Tcusj^pza;~`k*gdAys(|x6jLJ6jwrf+Pcoa>y6g!2uM zJm+eai!!s#dSLp-$nBo&q(Qv^~;v9S3#&_*2=5s1j8 zH(7r?6il({uWm9p5)-GX zymLUAL&NDU=${b(QV_PhNdqRW0|kaqW&e2Os^0-P#+ColK4{PQQ*Aqi@kZ4K0?>#! zg~8OsNI@MUNp#nW;Ef=vLix3Ou-g%x*2xXSBUaW*%g=Dr6}2k`B|Zo+aEHT~B1Y9B zbPyM|3F#RdVKFBuNGkhUmnNxi3{Rx~0s@=pLdQ?Z3OEl{F$M-G0&;cpCo2pRYG;Jz z8Bt%Bi$Fj=**l7`2SoRYVdWX&WtbR%K(|H6&>iHu>(JTOc|b6sP&2)8-q=qOE+`*> z3&QK!>XmW%hW)|(j`of({@bH0UfH{+(v@n@VaoDyF+SrKNe@z=oGqs%o%!O-m69lQ z)g2nSXYbJn_GY0GZVSfAokezhIo%x0Ub%CthC%oIvf;T^PzP4$Rtf$cq6PZPi2VTc zK&?tcp$*ZJufj^GFJKsU1z5_Y672l288f%psFCfh(B0Y0592<5g=4=?s`pFIK1%4p z9%j|k+(u{k3q-fFi`ORx4-)Q^O`>qDb1d& zPT48>q?6XF6R>a8{13%Bjd$#=!7a&BccBSWS74)m!2%zWa3dF$43e8T2sniSO#~3I zL32kxHTwSMjgZ2JmWZ1*0^ofz-^8~^FX%PLU7wlxrpoAZG-f8mZeNvzAE#?rg`O(i zye@cif9+YjZ*-bObQ$cQz{R0MF2A&i+}?bLL4TB<`IE6*q?)5@z3SY6 zGa!WFFEEFGf4I4L`81c2kz%i&_PxAr=w>`A)lFXfkk|Yk4koSwvS7IvR9m(_fE>ub z%W?5eHqLAg9^Io$I&gxIWbxZ5l09p!j0i zFX;>0LSIN*Of=mye)Bc5>iM_X1O(89-BMoW$xYfLFyIkv1K@P!PSV&8_KrR|{Pf$; z?tXLmLXHWfRIXqA@a!_l26D*g8j7m(-p0d&5w6uv;x}HW7I)ydL$XD)xkiIWEZ}m>9_EMzqRtfePLr%t`DV4X)dN zdo#5$6IXJCZ6epoC=p-DU{Qc64HSiV6h6*{-D(ILG3UN;2NOX~0kE>>0)XvTxHv$7 zy+S$}lpR{W_c+p-mQEYa7w=R}69NcGRkf6#4ZBApyC9h-1a8E<6+J64lLd6z9tVmj z-=Gy>B$9an2C}@kB_)PlP<>&+T(8O&gGH!RYo=3U9ZEdE+WC5-AA|y!R!@%9d^=%h zZkU{+z3(qAa3s+|*F(56eyR%Ra=fPHlZ+a;Q^bxG00t?YHDpbj6_%n#iX|8n+Djb* zk^y9$H_Nd@tV<>9(%E5K5DzVL*@w+-YGM4M2K1Qj>sPNd%!Ff_%<~(RYAiU#snC5o z-izSi$)fEyH!Zb=V_g}E5|b}4W;SLV&$hEUF(jOt`6(z z3hoeB8{AxO&1^y2`=Kt?s$sqgkr3gvSUbtcYOx-cyoBT>1#c!ys0s93b{#|VvjCBK zk?{5~j-;&0+(<%6*-E;8yJsYcLI`BdA+Cz^Det4fUvs(}I|l2eDx2NYH@SI=!-k-@ zs1u@Mnx_Kz4y?~uex-FuVAwv!rS37TKR6en-k8CJnGwcYTA!D1z#TxUQqfr$FuknoEU;KEjX)$=yI6jDHt3Mfey5)Wd z=nxM)PEMpRrnrwXMOjQy=a4i*>`C=)sM+m(QLXGQ*20PO!vUyajJJ&x!r3_`Oq1rw zDVj%LZ(31Zr`%rXi0&^aON#hfDFapvJ}o6^{k(o;;Cyi((;E^(O%a1}Dw5hgbbxa% zr4%1zEftl%yO;a%S7Rg0x zYzi?SaYqeW!2HsZodAz~RSWIqAYR2+9w|FsvVy#};J;utcwI6#0>QAjahEAGgkgA! zCsi}jwYiA}Qn?lemIf);EY}2=QEns86LH=pOnaK(-0Hw#O2n^hFeR8h9G6<%qx_i` z&7M^6N{AxVggs`+sA<~MqRq~xj}R|jJ=5w2<;t?7r=v87X=-mPWLt=+ZYH?hl0kaR z>+^PicPR%IIV;~co7VI`$(4p!D{?K!D{TZg?w{MZ6Gjj$`Ec*Rd`B*g)jbrsddzeJ zKKhJkc}!h4%uDMzH4M}dDW4iK?%sDfC$)qV07;eJR1pjqwClZogRQ7d@9>nxgiZkE z0K0`8;Me2{mL#^%I+uLE$6*Ikyfxl3eg~QD@4tQU<>!9@=;twIA+UK}`wCt*JZ{Nz z=Lr(i!QS7Wd->%}dsEIgk5Sz|gG*lwC&=;M!$0sQNd!lGr~E*9sh5BEi(h<=4e7sA z8tCly8D=Rq1h#E!e2ku2UFvP3_M6!hUO(Q~Gl`YPGqaC`30J>&e{AUlQ_#1U&tCs~ zQ57Ec)KW#OKHdA5s~^g14d}|$*szYV~$fXSZCC0p_<4xwa{b=PoJF=K7YXv8ttm+#xqYku0tF` zE2)-8`gBTkPH=lKA^BdTagI}&K-Nw!CL0VtdTLov?4HsW2PGfowg|+|mF4WRpC)|{ zRx^9p3)kHAGnBU|-min-x|jHmT>;5uKihpw1rw}~h6)kNZNa7rFXjIyF32Yxje0^L zGyMZ9KK=b~8clLcSoj>XB4;Gc1@dQogM2=0MS?{9+vf( z7Tq)4mT2|u9U-Q_eb9}C=4&ZnJ?eYllnB!T>$#y!DL;8!apLE9h?rq91X)!v8>7X2 zKwvY$#Q76_4y51r?!$+N!khh3WPhfg|LoA0tWMyu(o*B~Z zl3kwkHI~PB*xR$;6(k5#2LeE%AT1=S?ii5B%R-_+qN!Y?uLu3hQIcm)gBFoRu!#(1 zd|5`~{}=9gUL#7&22HqT_v{MZ^ST60af0#shensGkx|C$bM$O`@J25<2y?P`#V0fXPBKpEQ>Jr+=J(Jvs8DPO6cS6{?pv>!ToM{*@eG zr~}68Zt_u4<{bX5Gf{4kT#t|Y2+y9}cYHKb1GbkJ7_#!(F{LBe#$bi>u^f;O0d1IJ z{kZ%U#eV(O?I1yfNtkJ~-3ivWFL0uS1c~+W-v{eW7!)Ne!r+wigM1KR^AoQS?dRY4 z3-@9Ey2}brBn>MT;aLg-fo^8Hu9D9jTW};qPZDyS6ajn(yh9B;{xxMW^*c^yV z?wIdbr99ifu6hx+SQRaK+6h;Hq;izN8V7PMB+}UrE!3FZ{{i@NyDc2y0r)RXTHOsQntj>l2vdDwGEHO-w_@mqg#SBk6|>zYvx`SWNNJvSad`2|ND0uit5oQAT5*lA$TN~+xAZM{o1qv5uK|bREdx(9$wNbo&j>yDPYU^N)k*;w$$4TjCW2FoqA8VrNY#|~y2sw^zm z=Q0+&;$w%RNlFd%9@r~jwY=~ia4q1QZ;wX{aU$xGFkyUqiz{Kc@E3git@lOPE$e}K z-hfTXh-$_y8b#ZRRYEcIM8gMi4Ei61*!2R&wuBO;+Qwx_8Mra+SDRYtInRXk+rRB{PhIw#Q4dN0w0a9 zp^3H;W_h=O9ufHPY2uU05Xcv3l@f-+cM%3cqZs2wQl9-uCcU4rJL3L4qCwYr7 zLK217+c2Wy(Svx<`7+hJd3xQ3O#mO(=5xFWM$PU%{CW;KjgM~ox<_5=YA(99_P6n9 zDz?q*=mYmlVW!2(HDp3b&{QBV?(>802AaGQnH+Qe+G`++>4w!Prs!3p7$@pPu|I&} z3?;A54{yQm#=#HSw3~v=ECrS3x#hYjy!H!qnEIE~N|CSE@DO{di^27yQ$gDXEw-qO z1=(zFqaI--XKUxU1WPuADK$k8i{$wo>>EYUK(gt1d#`UH=6cuR1}%GZot68mA)dor zk3ziG>+W6s&Z!^`bF_RT`ArpqkC8Jro_+8thue?U6r;8wjj!ffQ^$`1oG5KmFWp5 zqzM>NRBqPVCt_uUQDO0z8Fyr@jTku#KabR5J|_S4EI|Szub?7jY^|QiMMCBYAkeyy z81*GN%=o5?PU?bju7t~IM!Y3DerC*^VRonDuPPXYm?E811<<68z8lE?u-B-md>!lM1TN^qogQSP%-xQ2_)k$ z#{hU0JD0zyz@oJm&VQ6Sjrev_V}L3OO1luT)}czkx}U(&!m8D&7iu$kyPj)}9EqmCdcDTVQc78&4x+elsI0}E=9l;5x6xM6uvqs)pn)gxl^h53F*7pij(g&jWgk7XV7HDpYa%D6|s?*H%2$r%%&)>!j_30BjWCoCBhT?Xj?q8lOJswQ^}7; z9|6=W8bgQ@5PUcoGrw_XP~Y46OusQTZkf?Y=p@QztFqj}0Ue&GbKDt!a8ZWwX!iNW z4!Ri;L`)Jiaryc$mlZTj!-F znYK2<;7hLQ2ovTEjKexzG-g5n!BH%ELR8(LEY8cb%kRx3sYTf<;?V^OiCNUhHb24G z+Q}=)Kf?ao869RIJ-()dc4x$zD^da7N5r2#dUG{fwQ70pRU4!_w}x^6_phz>8WO8j z2c1Dy`(yGY`cvzB?awsoH!tQ6<*{Rjr27#DW`LvMF`FX0lL`n549GcNCv$f)8Z3Zd z%PoE)81OReebx2AX{OBr6X-RDd`IPKGK688Gt3Y>vTqduN4$G_d*Mrs8NB&+63;XBg0AW{H`6^3#ip z=Up$wsfj1;s_2B4S}OPTauQOJ0R|@_K&i!t?N(3+Fr3eF&MU%iv-oJXs%-XiP2%Sr z$OIs$I%o7}NYYT5^mIy)ZvDn45(J;$w0CP3=R3ScX1Qq>@83XP_5+}CTjD_ZmcNlf zi|9@4;;@Y8rkIxTRNy18HNAA#hH-pbjH0P0_8J1sTW5*!09lqot!19Wp3r5LYB0GN z6_0iYL#+F#!8D5*O?SMNv)3*nE9|ANT+yZ3ThajA952%vX+GL8Dhi_c=w6<#_RvLsiLSwouAzCX| z2JjTyNW~>$94Uh*7BUQ;{*}~E45HCUPf@l?$xbX>j3pVtHMPmKj|)cf(nm$XI&^O9 z{c*g|t!reVOk`f2KTHU*?Yw(@xF#F{?ifwQNQGv+4TSiudYT%E#+DOa*$bW(#9@UeaE##VJlp2lu&Bo+>GY5xQ zhBjEgXUsw-xxBTP_q`c3!qb;GgP4tV=1C!NM!URk%%F~fO&=aJNP~yfoA23sp-c67 z*S_7DYbz>PD?EU>i8o9|g*PBG5r+kjhaO8ET>c!?8Ggdg!+4)#vg?xW#{lyY)4WGibsZAhQS(d{)Bi_8N zk48i%*IPwU${2FoK{&#@NCe}}vSsOa`A^J-GZdDC@#6j)i~%T+v34}^(}vV~ zhN@#+&oE}^Jp!S0mhyri?DxzoI2>`RBKfguFYBM<^)p;`VehMNkBRi1`>bypEEs}T z*6}(5r=6Cd2Ed)nMga(&W&BAArmij_LX?&d1Cn|gkaU`X*IY|Bk>)WIc?9H$?ulV% z01F_kM|Ihi1E60GJ@D6Ny7LYw!ly`Ap!D8R>$*d2US6$HHx^KjLhk1PR`_MqcfSgB z=1F@00&?S7Q2N88hQ0%K&C^23sjVZK+lF+kU852s_AaUdts~e{t!xzHvF2x2&(L@{tYv2yMq)^h9u#{j(*3G3XO!~P z2N@x3gqM$iv{(U`AU0CrEaoxF>Dg&X?L9UD;-ZGdjfCu#5y5(?t0*=!oYP@UCn{`4 zv0=g))w8=r-oz@t0d-uVJU&)G*c(*^%zz=%Bi)lqiop*CSpO>lC*8AIo`(@ zsI}|$U2IBh_yonOcNR;-dS_Hz9cCBQbWDfW*EeMsI>ts;9t&$=#6oK0rj6cD$Z9hf zGx#Ftix5fcV>QA*4-}019A^AeQb-?D+R|;?PrioUheQYTO)(s6ER(Hfq>Ir+((XOo z=3Bf{j`NM>(P9PGWOi(WYs$W53D}2UR&%vrV^{=%L+yzx1Jj@>mtbTc3nrz>+7eIs zxp6eK(FXz+(Ww%0RlkI*dAxI`aqp5+7+syE;K41$3t0+&vNu!#`=PSe8U37!y(u_E z9gue5u!OFuie+gQcI856{!kvF2!l?{{2d^(QuU7)&)x*8;Tc6Ws9WSJ$37O&&`))5 zRjAc<*&IA{1c5H5{VG64;XvVHd7RVDauyD#LmV`XVSeFq}rG%sh%z3M^y+ z&9Vj2z+9h*M$nvyN#)2T3za*hr3YWVu>@dmd2AuoG~0@51G%c03EVqESh#bH{_?aM z|Lw2?vb@(08s2P=3CF!_A_tN9_$|~_J`;fRa!Y=2)9owH~$@8Jrlyof9Lr97qEd>>uBbK9}=OHnzKo~uiSGk z%d=JTIrRn(R@vtmipkJVv(6Mt>Fo1$uRp~o^#AXK>j(VnU%v|y@N#?-f+`fI9Fg6pRx`k%_(fS$9yw44Rh@&zJj0i+m z%(}g-2cg}w7%QbopqThOwciz)I=$}UM`n^!(0J1_FL)8Y%i+OR+1};NbGe&=)#W@U z6N~!QKRu>@xzF_zUHz7}X zJD2qJo9icU;x}XVv1Z(oh-{P#N*xuNcER#ySso`M(Q55CL?<^ae@tuC0LO}1xu%tP z;?ALvEX_hJA zw)Fij_KH+`gLy zOAYLYrz*MxX)du?2w_eqc+*GyP$x?Lev2(7d1NVa$`kFbLlDkXO3>csr^HJv{0B^S z8BJ=&%+fvhPHFe{Jl5urrCKDwePx4qxAiv{j%~Ogy7i`pCexd)D|J z*%K#->Whzvs0c$$tyAZ)=PZ1XGF^qLY~!A7Y)4Cc#7#^jv3Lni0q{* z`j{-$QsltL`ms3{YGTV{OF*zWOn!NeR=G0rITTtvCvn(jwVhk)w{wA@U=ZC}RhsqS z11M#WHDFB0ucMm=DL$;&7dD?zC3|_2uXdlTzFIodkRrOwQltB&{du5hmu@UCc81m0 zJR$1uEl)P)%vZZlR^u$IK(AkBsnL5C4L|aZxAskoh|MMB!Fs-Yvh(1r^JBFc-fHJ@C?B?LJw? z*@VcPrAOyW))I7i0vm73*SZgd$j%d;LSq&6)$WtkSIa7-zK|e8*5H2l7UEb>xkCzt z(Djss?A<5tSj0k0%TO+2i#Aq^Sg<$tT~9Wq46b*dylWAYl$N0u(f~K|`9T_MBo}Gy zJlU8ysNQ{|3${0~M#@4-MHzm`Qp$2iY=or9)tUt@zYa)1ATUW^*m|;pUw^gxWcg}Y z5VyrLOOMW%0*Ba1`5(85H}ZN;F6FIN^b_vgv9A7V_sKg}vCOiJh%KUZiHcym0<`cvo*1Pj$V=dd` zY_4UFslYSW(&%E~HI1z1c?*NKr`T9`PV@6?msua+m9Ynfv< zz3|>bFCAZC@}g_u*E!EN=8={Lj^{h|WcRD($>v(-m^~Knv6c_h%PuYC$(p6rAiGai z^u4Two2SSHBp10flPk=LuXmA4h+~ELCYSZZHOTIh)mQ7KEOQpMjHOKSsHMzbC-iqI zAx}0Y&R4rnR#dmKlsQQe%UH^!j#|q6buML>5b|VW;(WFHWJPovOPP}tt@Kh#nza)) zC7((wqCm^|b*{&3=De^x!9C9XzG8n?1>1ho!}eFpdQ@5FEJOkJSQ4*e;wKz`U(Zmh z*m;6McsXVnb@$0?rOPT*S!xxG$q!z7jO8l)cUi^8c=Npl7Jj*biHy4YWHrvR3cRax z(Y1)iO-Tsns3RP%Qe^MU-{$0K#P#>hCnva^nO2 zpKg;ly(#fQMu7GmL^+(~Snc{3%u%F!g8ts$+hrm3$6eJS7+(^3gi#|sS&V)`+x3d+BPKMK& zn5V-0xlfQwIfI1-eMQk z;+5LZqr^Yv8BN1oszu9nS3$vMI>yJjf-mE_vzqJ`|25&BbN*v|MziMt-(e(;Tl3%y z%TN10Nm;@++g>I*T^{P3U_`3b5gp!n0+zESh@Qt;r-gBu3`)QX*hvC}c#Rq{mW+RL zX~Ftf2JsDz1?ymAuJZh03Wm~Rjg6lt(_%ejIc*)*+F#YAQ^jRu41k#)5L@lhl464$ zu?yp8l}AiAa*Kebi65@Vt|B9EfP9Yb=0&zAcIPKQS}k9rzcq#$5>)Y_>V4-EfZmx; zprx)iD!|Gk71)`fGWUsehYP8)9kMXJOHv32gpp@fgyjf&g$I+OAw6u%H`hV3#dc%n z)^t0Qdw641&&kR?@Y9M)!;b%$XWxFHG?QB#`&11QpIIpmhVo@LMyV~jc5_%!yZtRf zp8IJPS`kp3LqJu;UEi_}LuzSEUjaz~dl%2I>Ej?q7O%yr-f!F~Wnbp};h4Cl=VCcX zNY!c&3^*NQIU5NNdhFAXSNlC)_Umgs8eV1X|4%{VcyhG{GRx)TD>0OzAxt!Eb z+#W84ZF3H|a>#@)@7XnE$^q&ZFt!7^kp}#5><4F*DEZ(ejTE{#%u;=NBnPK|H z4PyoPX_)6iD$ZcfzlO8zB4%kR7?mLh*Uv)o#y31Hw#9|Aig`KYAoie{or)L3fh2EC zYAu0N?YY>8T#UG5YbXSXR|qU9M>IHRaxe?;Cww=vfk4T+$hkp8?f->ndLpjLfgsDj zADp=MEX$^-u3x{_dXxJc_(7vAY-|N?kL#ugz)I@z)<^>JrwwjlFJqf*=Y|}~QQ+oe z4+eboJoiRsm%q(y&vVX5f!;8U(WC+~`IJlV-`-r67ZTS)d*;FQXisY&ze3RElU%q6 z-yLv4P(8UJU*w3;j+9d8DIu2WF?tz<#ol49nfe?8TQDs(<+O(s?aVd_VuRb*^13sV z>O9DWD*{Q++ULLgN?@d2NnFM?IS>vrV|oxZ&m=-i;%g)YfPKHugx(eLFLt3&q%@yojX_Uc{I49029V$zKi1pVH+rGs`CY!FC`|ZZ7OI zYHJzXD7f&_+s`%7HNC^5@MD2JTW<}g8`s+i6EPukE2GPHAgNGBh?}YT2W%A9oGR0b zlQ7d`+IvJlKBKT_JQ3rgQ^G0{`p)JzCU%`!4a%sRZ?D4ujd&kyyP6@=Q<~tD0xdPW za74epxqRMTa8F?f)N@;s>astxQo~{lMd~}Cpq&*S1IcPCRgOg>fzlu%dG0@5zY$`( z06oMd7sX3nK_#$I;xSgOA_HGYx0Z+iO*gaIBg)#o-6sTbr%zBV0;#(eAp}ied~`{C zK=5cgonA+g_0@~iu|KYBD;LeF>5pX5K1*6H(i-%d;284IjwUA!VXyDHW8;N#di8Ze zVIG@n_dr1?YTM^Vl@}n5Rth(MFaqLeQgQX~BhwZFn%U5i{`=tBs=oImnHhUk7w~m1 z!KfS<^%3vSDb=C508g$lyi5EnCYSu~h6?W53s!C^JYs zD`*pu8En=w*y#uiAYu}b&Mh4_NC4>oTP6DdP)!_(Zm)Xk0Go&fo>=k-9o!#Bq$}ayDn63&-}QcvUr_}T*eIUFR1~oV zVf;{M7b@y%hEP~P;#`KBmcL12GGA7*$epW=sjNHMC<+WluQB1R#17+8Kv8qn(}@@VOeT=-{Jv3RB>=Qc_V6+Z=8aQ!?;y zWoWj8m+}HATOkqK68k}D-aWNoIGU? zR*&&%Z9e|+9NslYZ`+3fox+CijmR=OyHyms z3pWb5;?C*oy7%MN&Fhiefk{y_>Z?ma_wB%yZKBOYW+nS&SX;1jBI*yD5J+#8(c+y$ zpF$?h3T>?vtxE30#xH)Pqo(10YG@QoAUJ;2{!!Wgkt6 zVo4Oj_&Mu)k-IS8!pgu~k@0IKR_?xfL2JZU>NA3i-D1&sd3}>E;?DvcLv$6<>1#T4 zT;k%j^c4x%dM)}frDo;}r>M45R|ZgvRRp`sy}buNR&(<%tHbChVaL_ajbE}n8WG|Q zu;iG4!n%j%8Y{BVJwVe+cVctB1pd9PHc4AUYpaNJ|Dm8# z^F=I7d${-D#Z!&No)}bNifnf@>;)xNqPcNeF!+!aNrgGAJJ3CE?gLVDAWBW8Y3n*J zoFMBM`hL86QfXt_U6T`FyXLZ1p;(W60It9)#Pj+}wZ1lZipk{>N*rqtYLM#<9T?G_ z10hY2MPs%}vFj)*cFe0uzAF7rMV?B>R33lwD0XLmKZi!rpN?#`Sjg$tac--^Wona? ztD9{FRl8uH`vbV~8og!KS>zlhP3;h;YXmYwa!xxs7g5sUUHmk$98NiMi;ITEs z8HVI^71yu|QM99oTq6vq1oHE=;9*U_#mtmbNXeChz0Y6g1k$JK;@K-nfgBx5@Kydv zc4iQLj<;6sI^Gzp`$n@0&N$wEpj`(9xH{0**)5`}c~O;Cr`ltn$+;}!o??O)_MX1F zytsKRtfg=!)DVabXdG-B%F<+bB6MTC#3_opT2vC0nI-$l#ZQ zQ37_I!2`KDm78Y|PuBS+&IrD5&NW>$E72}e_SfXxh@ElGu zO4e$=M(gj#bX4(=cc<1+pts%|^N?N44pN>-*yI-WSbdc!C*7o#`k?cqW~ph4zY zuL$&2x@^{iR}b&>t3Piog@VfOSPK4xfxD~*1ISp-iJrY2EFz|N4knl&+ZI}nu{M)q zpVWL>j%Vl;N{qSmZ__6AoE2dST_v>f%fbHbQ`+qRp)h+NlK;=|l#2fkd;8hmH;9|L zI`O3FMhD%-6*o3cka6Qr6EA>=fUw|{2hEX_HHD3uTdQ2G zmNnHESvM|Ywgf^n!<>kyGmf2Sk{FD&P(!c0zH|lJsn^Ao0!~Grmgk%&0?LxMw`RardxPKRv@o0oujeQw@mNchL?;3XZPXH zy+cm%zA$aX2L0t(tU?ds!1-7ZS**lgyvp5*);;{&NDr`-lw!PkRVUm2=y?t6$K>10 zjhauhgHH}W{r0oF-(2Dq!zBQxRwb#bnh53Xrj?7bZn)?o{!!!WY%k1{ZsvQRl2=~t zMh4BiSgnRe0`Nicr5V@*=yAA!55z*oh7s<)T86e4ZUN6fnqvFI@<*0^wijsZL!iJZ zlC}Crdx~`MmMT&!IzgZcJt67h0I3rKG_mBXNIj3FEHcQdOk3;dV<#}veB~0%iCk@6 zx1cMa;Qm0eMOObJwXQ1d%M`BT_|e}8^mJG^y!_+1c#h0+T2q76qCOcA}Zyy<^s4?pqw@HPvxE{_O6_ra)&JwIp!6AZM za=4cRa%#Mm@UuRsXQOb<&3pYKIv%F*Wx7LjmcEfWe@s0tMxp_Rj7X&`%dln*`~(kM zP<{+?y?g@?4f8ocJ&qVhW)|<|M@z2{Sq`Wg1C>*XQ(y^tq4GiCm$m9=D_XFebk{}A z?3?G03LAqQ!&brbAXT~5fT%S&!?`$*1GaS_A(BnW4Iey+Y30tdDIZ5YC5!{ny{?Eh zXqc;7Tr_Luhz?$B#{URW3%0$RHc` zZdV6{=N%QHJC)->m5DcxD=a97Z!qjgMnMw9{1Wv>CDz$=DDM5``o_yiw|-GHe^jhV zg%ub9h+WE!w}V=?XkR#Xal$b|>@sXA1=2YS2YU~5wPgxxcieEQZ&F*?G8+xvGj_AJ zXd^~Cn;f&rh_&PHL*1<@!j#Xk8x$VwfxALPO$ecjG55sWg%0W!Q5WL}io*su^4SU~ z(atk41`{Zy(D3WQ{pbokUa({dPI}G`(MIl_K9l3(-5`I%Xanemt&9U^6i2pctA7e}azTO#~nS-C{Y_Q%o_S`)D0vE$;MVuqEgN-bvkjuX0kmdezIsnlNP zb?-EA-$4iFVdzo!F$TvG0%=L!x@@hJ(_lK~H2&sm-y{xWkLcQp_|b586;5n2&5wEHTic(>l}(yVs1Lgr#`_8NHHE&LNT(?lx%*1;PoH>+Jc~r|Oi~iJQ5h z1VG>qrUwErH5?>(Y6!X~oc@c)H`lK+k(XnGS%!9;ox2w2Xnt|V{VoBrap##`2%0U> zBXaNH7Xpz8k!I|vH(o5!Td~*XJH~qabOoKXX-md&e(dLgvax=RFm7^0^O6;!eq$HP znyot3_Xp_RSPpALcsJruS7tM zm;`hpxXQQ}!BrO2;t|iwB9>AV6}!rDpGBz>)H$M^+xvl8;q27Pnw{S}Pjt&y4@rf;^twpNP^h6v0Z1 zt|4&l%Z4?V6x+}i(Haagav;L{+-$SQ0kTO;D!F?N_3G^`5_)E~0!iODF0F4+^#h)s zzIpXDGtL@DFbt#1)!z%7*`L=*R20tu^KR|VfMa!5)sJV_*MENV(%qrQ=e9lvIO_;H zG&c-}u>(?AW4V5WTi*-TD2wET+%-;1F1(i0vNK8)l&q%AAmO=G{3j>sANU1a5HoEp zHkPNq`C^InoallEkkJZT=it4W!9MzLn>-OuF|el`Rndd8VM#uMe^n;mFqypzt!mL% zg$q6_l_snr>>rj-uYez}FkhG8t9xmhbx=YHseK`789vzyIpX1vhfff8BM-01fks#w z7XR&y*IDf1M(nd*8g3LbZnC$@*WUe9$WW0VWY2*tJgZ|;*%&KC zx@n03R^DRQN+r$qPtYE-eBi8uPifxOucCQb9ycSJ)k-DQB)*s&na?tJK&|4Cxd+j{ zmM#Aw$NI?1FTH`l!NO$W5o)Ugubk!Hd0eVPTC{UVzhY$GkXY+DYmt5vyO!L#)u(Jv zP^&`8NesWVW|_N#dd7r^0+W!KTswPP*4-B3eP7}yF=C($HxlAFIc?b+pptwm` zp&|6=Ts6gijR;><5`>9mBdE};pic?w9A+JmY~$%1iqN!EEO9Agv<{r+^p^3)1F@k{ zXwdE((|p37Ld5E-S|e6H$X#J>${piR^M-e;YTE|))3g!T zjpy0bqnnGHpSnPi&hk)EHVmH1iZrg=Opn(D8%lc0KnvXRE#85LA;2S6H(aS8Fbsky zMq@TcC$je3Vam2h<<_e2gefJgiBlrF*uwP3XY!*qYJzt_2*!BnjDywe8TVvQywBbQ znxy1qgUgqQCm{Fvi@RT3KEFok;1;3*WrQ0S#7k)|RYp)Y4pvXq2kQ33iy8&WWg#sU zz!4n{QXkbmt?D`b^sFiei2#m!olt;3bs#wYmAHNAPgXa+qCPSG1lwLbjz86kcA82t z>${j^Xta)|vHE9YX9V!js|lT^B${9L#ZTtkTzl<}z!d|4KUZ!e{XUU zKsD5k{D9KY_X@X7-`#Fr|3f~+A!4nn%g(t$)xx|ZM##9auVm8LVMaeTcp;!BoXcHbzoK5wv zExlPMAMYl|j5Q#oKjz#vXjn zvlH9thzB6`vQLNB)979=Z*-Jb_NkR5V=Lf{sO#rUK(ZVoINvvUQ&D8 zvPQ&@7;#z}vu{#Xd%$xas#%XoOb~!*aUpan_ur&b*dgd#eBQ>Ft!R|Gte7roWi{5M zba8()V-pBmk$q+)aVf2p;({EkgwxNxkSk9s$>m?4UOh@3MyO00?6>`3+8XIMi=`GlMdY38E>< zr5tLuImN%OZ5xf(v!9~+ju01kOa;?vKpzMo>}zyj1N!C=E{5=K>2)6aV_mLh>MOQC zqq}10l)xoe63Q~sc+b4Tq&;w4^TRWV)%_^>#ecqlhMVM#ly+rM?BXRd)vbJ6c8pre0kxnX)1!J46Qqnb*o5B6__RwBL%eJ-c<0LxW=-kOh%RIY@AhGivhEk8s#2@ zHSOxjTal-5wf1yNZ@6|EB=&o39&iS*TL%hEoW-bH<_)d}<^OUNd%!HL8ldGD zcGq@~aoW%i@@E5i`oge+~{Q+w~Xb+s(!P@q3!O#=hl`8~OOd`ZboRQw$F(QS@{ zK6kWl?rv8~JrrXKVNJ6LvpP#lLO;~3+F;NkIxXWz$?j|sxu%BE-@xmHKB$d-;GShO z-?V=KCn-{}I5CB+^c8`~0**HbQ`c5(-N<-@Sx|Y7s^HWiZ&rgDz%@^Kxr9(po%2t{ zQ5AsvMqrT82meDb1nI1Ez@rmD%tOY3#*=;1K5r!8!La?xo^P(sc_6{z0=z(eg6C9sMed z1DGfjgmZGoqldF$K11j}-aFebo3Jqe-wwQMD(%&1)pGOY-HTFXgUKD*+$9Nueaa{j zoRmR?Nl!7Ab{K|h$gzNUR(BYYv8}fvh@bOvn@^z432%*ttvleKwe5C`fDp0cq zlddoS`uH+l15RUGanaOcOOu|oyS;vT6UI(DPcCO@xqO;(J?shPNpU=2I@yVqlQlaz zL^*F05DcAzFI(nh@9&XN{`k*z#d!hd80_E<;I&i!E_`o9F|briQs?1yxV>vU%kAD-vL1lJ;xJby@>_Bj6}_T+UrK; zW;F#lW(NyHj|0GqZlO`sq125m=?fo@PKT;8naE zw6+NxL*4``Jx5kjoBq3H{}lC`*1R=Q$!)x^j!X&}f_2AxpTL60F#+u7pk;=Ox$703 z5zReNYd!$_-ZT2FjwZ!g@ia#8|$0R+|U$Q?Uu0f1rF`->}`*zATcLrqZ_VJqQ+Xv=KL$khpz>AKd z^fX8{slP!}1FG!4{JUTL;%jK^zY`P2|J^*Ntb36B2`6A&y2=l~c#N)Eweo#kh2F^wocgHAG&|y1xpTsq{?#`R?mv9M zQs;1%t@!BSDAIF$N79X!z-UUxC!ZX#wS?Rp-23F7+uY}f9;NI$Asu&&ON7>)U3ms? zux|W(aCr2IWx)X?7#umRDe|og@LCZMF!0LGY}U#u>96PJ^1GHU;oS4 zODMq-JRh};g%XZ%9<0y*VIAk9go)Urg%XZ2`+qbgoWSnhN(pLQp@ih-NC`62P=dWT zHYveTb|~StBZLwhVV4qaIYd!{L%f9&KAHmuakjhoXvBpQH1>b{;Q#&ogD)R`e*bqH z)L?YiM-Q6IfKb%xgW`Ce^Lt_F#2?Th@{{u%bLPE!&Ge$X_zK@Az@aEmY8dIWZ4XevDsS0i{W+;)TzLqs>Kh7$ zF6N<9L+IyN=-#SRFr(`0N6jeLB6^BCI-shwieGMunfY5wt+(Ar@j{B&VVqu+3%q{F zmMI0P4s&qYTmcjGNv;zDZS8@)Xcv5N5Mh+WjeC3h%@uI4+yy|*7hFB5o*U|gGo5}C zg{5aIw!loskz*FNkdK?^-FABf4OfV-Hx&wXohCwB#t(hYVim}VnkOB{ZLQW%iJ~bj z2QygzV6Il3I27S*>q9SE!{#f~MuB?P%a2?L1g{JHuxri30o%Bz!plRjQiIIybQ{(mh4;7gpFoa0tW1LyPx_55JuG-?3*@##=*E>2P zZk6N2icjH~FF*f-_E#gFAI6T$6|B=f33Z0QF5hE5+9)wh2nr@%_iwyYJbjf{p9GY0 zzj!qkAhJ<%CT3c56^a0=+TChPc(O2*(_yvNk6(DB;_+D`hO!;OPPW?c;4vc{m2P|q zLaM2-CTiZqx~i|K=NL}CD#$<#dxDJ&xpBP| z0oERR12-7wf{^R|=}|K-AS5y;jUMXgXRUO7G;p&W@88AK=GF~T?)bBP97#ov z6v@R&bba&ZXV(|xhBXH5Q*A8Qi#ikgd-oSZbDeZ!yqikmM#xi5`hDEZIC98x`a?36 zG)$Olq5#s{vz(y;qXi+b`9BL3!NklDC97d6VBjt=pijo}y0(=`lkJNCjxfk7%Wq&- zBXn%bOtca9;!No?$v!D`>PY5Qbka3mnCI6|)>XLmspvAG@+e-Mcz}}f-C(3l9~Dkt z5TIgFTq5W1In%^on7RdV1gQM<$WkAZpAzq|EEQRKy5XGAHpGe1$bHb=TD?@O&Vthc zPTVA~pI*C<0MsK;K$I*yLXj*$8R1RfrmwTegs`sSUm8i4O~6n$JoLnE;lNI9hs-G# zoJ=*7T7v7*rA*67xvB6BJfqWdpqrDIne~u0naE0i|AL?aQo`d{A`W{*(!iSbeg$`g zW?x*z*XSgacG=(i^z!DE9x}SMg7;>;Sx!av>YpBharhWxJfk^7j*8i zvM~e5HCQv*Jw&`(NL{zEx_BwcX$MoyzTH*glS7pjDjzUq=TcKG$^mJ2pLTj0qI;%@8ZjPf~$jV#CdcdZ;M2veiiMu#PItb(XYR+x2RUEW(x>}wMCK4}5(g(6WV5eArVCk7?juGJ^OI*R#(9{IFAANE} zod-aQ3pEM~v0&b~L{boWa8)(#tn=crAg$Uz#bf&#q+XEx{0E~^kxmx;_)f;x@|oKP zZNfl@oIdmlT=bNn`EKu^;@R+&5+w+s=ZOx?RZ^5!B+aG()){7#12Yj1zF@U78Jj=qBrT^6)vkwI*28X${-8m z!4d%jW#!BpjElxsUO<#tM=(kHOlk?88dtP@7Yd$f4De-uq9e@`gSWI48%I1?89hl z7R;)$kHUbKtdGM$eMe;NM}D_ZgE8Q1TTPG154!DUvIhuixf^n0YKLD+)#kNkuruLc=^LZ3XZbB819Q0 zZaYGVVS9uS!!1V;47HQDkb;)9k3&EqPHXMQeYcQ;J?S^Sf;FZ&EgwH-5rZ+s?<5B8 zbz6)f*=6sdhQslG?EjM*(Cs%2cat$hZ;PP{Pjzq~=SZl*po$G@$SB*?aO)AIhMf_l zhTD!1YN!!*7z2+#_J9X-%>8pPmumubi8Ay%p1~S7NzWgB{e&X0Nz9mm-SaNPCxG+b z-rY(^35OtrX+#a|ej#sJ7|LJ}BzEn@41__@Rz$pWa~^S0Bmn#e9x?Y9??0U}C}v zhOHF9#Xne!unNe>FQVw@gbVAP9A%Rllr(S=jX;B26OT2omfNL2i!1_8gU%Jr37+K+ zNA&(!_!9h&d&IUwp-Z`N=+cGP4?rtFn3ta)j{9;$ZRsakCGscjh512|EI(+x$`2-K z`$O7F)(`zM;f4LDcVC;BdixzU(tNJ9B0t!cpWz;{Y zrR7CMvK2Vq{bJ72Ek;C3(TViGIe6w z7I$IIY2BVa&9|JhSqke_@qUZPum(0g_u~g9>KZSTv^m)Xew6b29awMcXc&!Kb@(jWeVZ4_Zok!w96nuUKWo(j zTB8Db^6c-X&da59_GtJF!QRSecnG&%`3w>1M~+ppkTgwza1)8GE|;Qb@^UNy!-ODtjg}1NNV;pS?-Vxm2?ECY5B#fBV+@==b*i(a~;x@_m^pQ(!g4 z-hHk`G{8DK!rJ6s&W>v@co*hgeET=wKDhtQuYU90-lzBf^t;bLUG{`^Y3_*%1|&O; zF!-8Ed))6yWo3hI1_5#G4H%g5GvDWgAMO29oct~y^Vwmg@VUj8FU2m|!H3u)PVOG> zpSc_EGt!?a2k#$iBNm1DA0x}37ZKu? z`t{|bn?Xh}8V02A?*u%yNCE%tXJ;pU8jknAtP`*h3#{+FOXdokQ#SOW<3JzJqb8XU z5F44t(J?IA{STBPjKd>j15E`2Hn!Ptz95yi>o8}moi94EYSR`Ri7Q5gVq+X`n2g5K zrL;5{4W-eS<81Gb55D~L>}*ongBOpkpX8iTuHk&|o6zhLR@#3oD$~gS*_(`~Gx0b1 z`ziLdU)A4DbpF?W?QYy6i<$O*gNbojq{h#3K_%+r+s98SWw4?o2!f*0XPM)blzzNyA0rfUMXSzsl0{r~)u$fL(kub;)GV6j1c4PRg3Tp}d}SGC4iUJ4V>)uq|kPYa`^5_thVU5@3PDt`SnH02yjMdHpmWTI}(&Pab5Bgan!*_prit ztWS5pJlw}=2EG3AclWkr$nHCP4%Jse@?9g+z{s*tdcwWbP(cl zuL6p*y-z=XC>FppEB>}XVoHBtP*t}MB2JviGzdMY3HhbiTgogG8Go0s?zvba5?yR@ zf6F+m7mM3ixcSQ5w1Tf*96Q~`B*59I)!b6uW95=S&TCWHz(&;Bjxk;GJ1O(nvx z^#vz4sWY4?+xe%(pgHdSLzjL$2I~hS-R~UV@*AoaWz8Ur0xd|qj}qjQ<(l{7 zMgv>S)!?lUta&HTB8kaJzr9v|M>8$Z_Z9b zq0rnzyz5;ZA9h?KSp1$zTAAI>B49Ea1g63Y)XeUKt31Y}bUVieXbi!Olrf7rfd9<*)b62?VVvFcgtA)eH zdf_zt=2Z2ZL2A zuS9fix0Wt5DxH49rNp`d8_g8}*gxO@-Putv{r~lLHcf3DK^VUCD^k8hKKP3-!4XVV zOsWVjNEPPhMF^urNCc!9^XvUQ-MzbllTTb+GKig>nV$Zdx8KHio;7s)DOH5L#%Tz5 z2c;c?*>Z9u#PC7^x%R>d=$#V+qjsYFwTX=< zGxdtlEr0u+#^7?+=h1oMhd?a461cM^48t01wi=hXoAYyi_{UCU9~92x#{jv=*mvsJ z(1*K&a|m$L8}w%V>sPAV{nZxMzF;z(3RfH=+PsrNc5jUIUMHJqYX}p10D;- zjxZ(2G5~IFigc5ouiqZT*8{z?08E%@E#*BSdE#+1^@d&_4i3hmrK-Q7qZ?0fU{o3O zZ=BM<@~&`dV6;d}-DK(omvCqB6j2G3ZnF#HohaTatVro43&9i3U!B_=M?btJFbQYtJ+b==%+fXn zA|lh>(CNyPpSoqp_-cvJqN%D-g{dL2!lZ06NKxg+XxNN0sKOXQP21|MmdZXU_3+vu zobZeRWU8Y_Uu;$A@q44b1hmP2{evl~QyfDet@vl3YOu$4#j28sgV$uiW~M2U4HTPt z+sq~jlvhV(K|>h~Q+MrL*x3LHwlj%%MyY6rL8tWVWTK#^;x=vJ442uELuv*0ezo{6{IZ=#+G2d^Cojrv7tpf_EeGl`^CUlw*4al%wPPNzKOHfGVGE$u zF$P>ZQ<7hRmh14aRD1ir`UXcJ&xMx&dt&(thKdJv)NoL4@C8RMKDXr^OLq)FlK(eQ zG^W5mHFv-SFW;Rsmm>hcSL4@vj0h(qCt^AsCt1W6qMKtGf1wp4*A|bGGVf47%u>#L zNik;-pJaaxt54(%35zGUcj^b%9-nNKP{?g$d3oP93&u??P+hq4SF~CQXsc9x0BU)1 zx7X4Qb3-zoHFI_B9sA$1K?)WnL>>?%Oc&~lxxQY`zJ*f^UmfHz zb1kB89#ge1$32QE8r{amYZVbw4sK4510C#v^iTs=4%jv2H7L{J{vPEXQYG77b`u(S zD%~TA>7i^&Cc_$WNcw%h`N8U%f8B%PEat|f&*q4DB_sBuSL_6r8ryc5T;6Ku-HlZKwORUpr{lZ-CuqRfR!e2h(ObT} zUP-U>Lyb#q_$emM{aEndw&F?6j_yY>^;x9WszbJ2dc`~<=6b7#D5(x)tn?|`r0fpl z*<0}nz7Lt6UCGAcj{(>SD9?4Hf`{%Re0JT|y-rV6=Pb!Vp@Zs%$C=noxm2HAm(3*^ z8N;lG8-f^xx4NBED^PCxvsy0Z`o04g^L$?LX7bS0Hrb;vEulRM@)POvsQz;FA>nba zhcShy3@t$J!E+hlU_fAa0lJ7@WF^zfw0vMmWj>sLDv|s7sNi#$-pH z2(}W_mA!IErWjAgy;W@5{KD32`7*JXzI(&SW(kQtx2fG`VXj?-jBtO%X+qh6Gj*Pp)?aGcz%d%i~t|K|U%gZ%OYJA!* zFdWw2uR-8AOGX)^H&EARXE_cfK1}Ns_`>8QX^}kb%m-LyZ%ZtbQLYqXLZY;PDBZ#A zj=s8Yrjvieenm_)eu$7o!V3~iD3ZL$Glq>5!-8Cex9JZk@kX*k%CTKlh7>dO))uTk z2HDoMF)|09csv6w6onXvNa^=Z#in1u$aq*a`Z|)OLz(OP;Pc0HU!>-1wI7DaEsG>e zjBNG({DL^%m^L$p2=a;(yU9+~anvgF8`e<)cEvd8mqX^relCdIRLJZ^TDP+iM z#oBzI{_z^ak~L&zc`$dC>C{5AcWN9@s3y*L4tg^4B!^#=t+aI@3F|A7e>e+qc4gqD z9{j$m9*S=Yr|Z6Hj_QCCmnLP~tlHmS_$IoH@OgtzDB;x@kL>v7ug7?OKq?W{O9Z6( SvfOT1TDbPGSX+CzU;7E%nZ#EB diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/libtp.usenix.ps b/user/mpy/lib/berkeley-db-1.xx/docs/libtp.usenix.ps deleted file mode 100644 index ea821a9145e2482e7e17b157cff518aecfaeffc4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168201 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 diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/mpool.3.ps deleted file mode 100644 index 816c9243c8636087c0c9cb31b2f9354af6ac5fea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13573 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 K=;sTUQ}sW}*6BL{ diff --git a/user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps b/user/mpy/lib/berkeley-db-1.xx/docs/recno.3.ps deleted file mode 100644 index 8ffccfca90db10b200826806cb47c3bcc2acc42b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14632 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 -#include - -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int alloc_segs __P((HTAB *, int)); -static int flush_meta __P((HTAB *)); -static int hash_access __P((HTAB *, ACTION, DBT *, DBT *)); -static int hash_close __P((DB *)); -static int hash_delete __P((const DB *, const DBT *, u_int32_t)); -static int hash_fd __P((const DB *)); -static int hash_get __P((const DB *, const DBT *, DBT *, u_int32_t)); -static int hash_put __P((const DB *, DBT *, const DBT *, u_int32_t)); -static void *hash_realloc __P((SEGMENT **, int, int)); -static int hash_seq __P((const DB *, DBT *, DBT *, u_int32_t)); -static int hash_sync __P((const DB *, u_int32_t)); -static int hdestroy __P((HTAB *)); -static HTAB *init_hash __P((HTAB *, const char *, HASHINFO *)); -static int init_htab __P((HTAB *, int)); -#if BYTE_ORDER == LITTLE_ENDIAN -static void swap_header __P((HTAB *)); -static void swap_header_copy __P((HASHHDR *, HASHHDR *)); -#endif - -/* Fast arithmetic, relying on powers of 2, */ -#define MOD(x, y) ((x) & ((y) - 1)) - -#define RETURN_ERROR(ERR, LOC) { save_errno = ERR; goto LOC; } - -/* Return values */ -#define SUCCESS (0) -#define ERROR (-1) -#define ABNORMAL (1) - -#ifdef HASH_STATISTICS -int hash_accesses, hash_collisions, hash_expansions, hash_overflows; -#endif - -/************************** INTERFACE ROUTINES ***************************/ -/* OPEN/CLOSE */ - -extern DB * -__hash_open(file, flags, mode, info, dflags) - const char *file; - int flags, mode, dflags; - const HASHINFO *info; /* Special directives for create */ -{ - HTAB *hashp; - struct stat statbuf; - DB *dbp; - int bpages, hdrsize, new_table, nsegs, save_errno; - - if ((flags & O_ACCMODE) == O_WRONLY) { - errno = EINVAL; - return (NULL); - } - - if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB)))) - return (NULL); - hashp->fp = -1; - - /* - * Even if user wants write only, we need to be able to read - * the actual file, so we need to open it read/write. But, the - * field in the hashp structure needs to be accurate so that - * we can check accesses. - */ - hashp->flags = flags; - - new_table = 0; - if (!file || (flags & O_TRUNC) || - (stat(file, &statbuf) && (errno == ENOENT))) { - if (errno == ENOENT) - errno = 0; /* Just in case someone looks at errno */ - new_table = 1; - } - if (file) { - if ((hashp->fp = open(file, flags, mode)) == -1) - RETURN_ERROR(errno, error0); - (void)fcntl(hashp->fp, F_SETFD, 1); - } - if (new_table) { - if (!(hashp = init_hash(hashp, file, (HASHINFO *)info))) - RETURN_ERROR(errno, error1); - } else { - /* Table already exists */ - if (info && info->hash) - hashp->hash = info->hash; - else - hashp->hash = __default_hash; - - hdrsize = read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); -#if BYTE_ORDER == LITTLE_ENDIAN - swap_header(hashp); -#endif - if (hdrsize == -1) - RETURN_ERROR(errno, error1); - if (hdrsize != sizeof(HASHHDR)) - RETURN_ERROR(EFTYPE, error1); - /* Verify file type, versions and hash function */ - if (hashp->MAGIC != HASHMAGIC) - RETURN_ERROR(EFTYPE, error1); -#define OLDHASHVERSION 1 - if (hashp->VERSION != HASHVERSION && - hashp->VERSION != OLDHASHVERSION) - RETURN_ERROR(EFTYPE, error1); - if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != hashp->H_CHARKEY) - RETURN_ERROR(EFTYPE, error1); - /* - * Figure out how many segments we need. Max_Bucket is the - * maximum bucket number, so the number of buckets is - * max_bucket + 1. - */ - nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) / - hashp->SGSIZE; - hashp->nsegs = 0; - if (alloc_segs(hashp, nsegs)) - /* - * If alloc_segs fails, table will have been destroyed - * and errno will have been set. - */ - return (NULL); - /* Read in bitmaps */ - bpages = (hashp->SPARES[hashp->OVFL_POINT] + - (hashp->BSIZE << BYTE_SHIFT) - 1) >> - (hashp->BSHIFT + BYTE_SHIFT); - - hashp->nmaps = bpages; - (void)memset(&hashp->mapp[0], 0, bpages * sizeof(u_int32_t *)); - } - - /* Initialize Buffer Manager */ - if (info && info->cachesize) - __buf_init(hashp, info->cachesize); - else - __buf_init(hashp, DEF_BUFSIZE); - - hashp->new_file = new_table; - hashp->save_file = file && (hashp->flags & O_RDWR); - hashp->cbucket = -1; - if (!(dbp = (DB *)malloc(sizeof(DB)))) { - save_errno = errno; - hdestroy(hashp); - errno = save_errno; - return (NULL); - } - dbp->internal = hashp; - dbp->close = hash_close; - dbp->del = hash_delete; - dbp->fd = hash_fd; - dbp->get = hash_get; - dbp->put = hash_put; - dbp->seq = hash_seq; - dbp->sync = hash_sync; - dbp->type = DB_HASH; - -#ifdef DEBUG - (void)fprintf(stderr, -"%s\n%s%x\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%x\n%s%x\n%s%d\n%s%d\n", - "init_htab:", - "TABLE POINTER ", hashp, - "BUCKET SIZE ", hashp->BSIZE, - "BUCKET SHIFT ", hashp->BSHIFT, - "DIRECTORY SIZE ", hashp->DSIZE, - "SEGMENT SIZE ", hashp->SGSIZE, - "SEGMENT SHIFT ", hashp->SSHIFT, - "FILL FACTOR ", hashp->FFACTOR, - "MAX BUCKET ", hashp->MAX_BUCKET, - "OVFL POINT ", hashp->OVFL_POINT, - "LAST FREED ", hashp->LAST_FREED, - "HIGH MASK ", hashp->HIGH_MASK, - "LOW MASK ", hashp->LOW_MASK, - "NSEGS ", hashp->nsegs, - "NKEYS ", hashp->NKEYS); -#endif -#ifdef HASH_STATISTICS - hash_overflows = hash_accesses = hash_collisions = hash_expansions = 0; -#endif - return (dbp); - -error1: - if (hashp != NULL) - (void)close(hashp->fp); - -error0: - free(hashp); - errno = save_errno; - return (NULL); -} - -static int -hash_close(dbp) - DB *dbp; -{ - HTAB *hashp; - int retval; - - if (!dbp) - return (ERROR); - - hashp = (HTAB *)dbp->internal; - retval = hdestroy(hashp); - free(dbp); - return (retval); -} - -static int -hash_fd(dbp) - const DB *dbp; -{ - HTAB *hashp; - - if (!dbp) - return (ERROR); - - hashp = (HTAB *)dbp->internal; - if (hashp->fp == -1) { - errno = ENOENT; - return (-1); - } - return (hashp->fp); -} - -/************************** LOCAL CREATION ROUTINES **********************/ -static HTAB * -init_hash(hashp, file, info) - HTAB *hashp; - const char *file; - HASHINFO *info; -{ - struct stat statbuf; - int nelem; - - nelem = 1; - hashp->NKEYS = 0; - hashp->LORDER = BYTE_ORDER; - hashp->BSIZE = DEF_BUCKET_SIZE; - hashp->BSHIFT = DEF_BUCKET_SHIFT; - hashp->SGSIZE = DEF_SEGSIZE; - hashp->SSHIFT = DEF_SEGSIZE_SHIFT; - hashp->DSIZE = DEF_DIRSIZE; - hashp->FFACTOR = DEF_FFACTOR; - hashp->hash = __default_hash; - memset(hashp->SPARES, 0, sizeof(hashp->SPARES)); - memset(hashp->BITMAPS, 0, sizeof (hashp->BITMAPS)); - - /* Fix bucket size to be optimal for file system */ - if (file != NULL) { - if (stat(file, &statbuf)) - return (NULL); - hashp->BSIZE = statbuf.st_blksize; - hashp->BSHIFT = __log2(hashp->BSIZE); - } - - if (info) { - if (info->bsize) { - /* Round pagesize up to power of 2 */ - hashp->BSHIFT = __log2(info->bsize); - hashp->BSIZE = 1 << hashp->BSHIFT; - if (hashp->BSIZE > MAX_BSIZE) { - errno = EINVAL; - return (NULL); - } - } - if (info->ffactor) - hashp->FFACTOR = info->ffactor; - if (info->hash) - hashp->hash = info->hash; - if (info->nelem) - nelem = info->nelem; - if (info->lorder) { - if (info->lorder != BIG_ENDIAN && - info->lorder != LITTLE_ENDIAN) { - errno = EINVAL; - return (NULL); - } - hashp->LORDER = info->lorder; - } - } - /* init_htab should destroy the table and set errno if it fails */ - if (init_htab(hashp, nelem)) - return (NULL); - else - return (hashp); -} -/* - * This calls alloc_segs which may run out of memory. Alloc_segs will destroy - * the table and set errno, so we just pass the error information along. - * - * Returns 0 on No Error - */ -static int -init_htab(hashp, nelem) - HTAB *hashp; - int nelem; -{ - register int nbuckets, nsegs; - int l2; - - /* - * Divide number of elements by the fill factor and determine a - * desired number of buckets. Allocate space for the next greater - * power of two number of buckets. - */ - nelem = (nelem - 1) / hashp->FFACTOR + 1; - - l2 = __log2(MAX(nelem, 2)); - nbuckets = 1 << l2; - - hashp->SPARES[l2] = l2 + 1; - hashp->SPARES[l2 + 1] = l2 + 1; - hashp->OVFL_POINT = l2; - hashp->LAST_FREED = 2; - - /* First bitmap page is at: splitpoint l2 page offset 1 */ - if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0)) - return (-1); - - hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1; - hashp->HIGH_MASK = (nbuckets << 1) - 1; - hashp->HDRPAGES = ((MAX(sizeof(HASHHDR), MINHDRSIZE) - 1) >> - hashp->BSHIFT) + 1; - - nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; - nsegs = 1 << __log2(nsegs); - - if (nsegs > hashp->DSIZE) - hashp->DSIZE = nsegs; - return (alloc_segs(hashp, nsegs)); -} - -/********************** DESTROY/CLOSE ROUTINES ************************/ - -/* - * Flushes any changes to the file if necessary and destroys the hashp - * structure, freeing all allocated space. - */ -static int -hdestroy(hashp) - HTAB *hashp; -{ - int i, save_errno; - - save_errno = 0; - -#ifdef HASH_STATISTICS - (void)fprintf(stderr, "hdestroy: accesses %ld collisions %ld\n", - hash_accesses, hash_collisions); - (void)fprintf(stderr, "hdestroy: expansions %ld\n", - hash_expansions); - (void)fprintf(stderr, "hdestroy: overflows %ld\n", - hash_overflows); - (void)fprintf(stderr, "keys %ld maxp %d segmentcount %d\n", - hashp->NKEYS, hashp->MAX_BUCKET, hashp->nsegs); - - for (i = 0; i < NCACHED; i++) - (void)fprintf(stderr, - "spares[%d] = %d\n", i, hashp->SPARES[i]); -#endif - /* - * Call on buffer manager to free buffers, and if required, - * write them to disk. - */ - if (__buf_free(hashp, 1, hashp->save_file)) - save_errno = errno; - if (hashp->dir) { - free(*hashp->dir); /* Free initial segments */ - /* Free extra segments */ - while (hashp->exsegs--) - free(hashp->dir[--hashp->nsegs]); - free(hashp->dir); - } - if (flush_meta(hashp) && !save_errno) - save_errno = errno; - /* Free Bigmaps */ - for (i = 0; i < hashp->nmaps; i++) - if (hashp->mapp[i]) - free(hashp->mapp[i]); - - if (hashp->fp != -1) - (void)close(hashp->fp); - - free(hashp); - - if (save_errno) { - errno = save_errno; - return (ERROR); - } - return (SUCCESS); -} -/* - * Write modified pages to disk - * - * Returns: - * 0 == OK - * -1 ERROR - */ -static int -hash_sync(dbp, flags) - const DB *dbp; - u_int32_t flags; -{ - HTAB *hashp; - - if (flags != 0) { - errno = EINVAL; - return (ERROR); - } - - if (!dbp) - return (ERROR); - - hashp = (HTAB *)dbp->internal; - if (!hashp->save_file) - return (0); - if (__buf_free(hashp, 0, 1) || flush_meta(hashp)) - return (ERROR); - hashp->new_file = 0; - return (0); -} - -/* - * Returns: - * 0 == OK - * -1 indicates that errno should be set - */ -static int -flush_meta(hashp) - HTAB *hashp; -{ - HASHHDR *whdrp; -#if BYTE_ORDER == LITTLE_ENDIAN - HASHHDR whdr; -#endif - int fp, i, wsize; - - if (!hashp->save_file) - return (0); - hashp->MAGIC = HASHMAGIC; - hashp->VERSION = HASHVERSION; - hashp->H_CHARKEY = hashp->hash(CHARKEY, sizeof(CHARKEY)); - - fp = hashp->fp; - whdrp = &hashp->hdr; -#if BYTE_ORDER == LITTLE_ENDIAN - whdrp = &whdr; - swap_header_copy(&hashp->hdr, whdrp); -#endif - if ((lseek(fp, (off_t)0, SEEK_SET) == -1) || - ((wsize = write(fp, whdrp, sizeof(HASHHDR))) == -1)) - return (-1); - else - if (wsize != sizeof(HASHHDR)) { - errno = EFTYPE; - hashp->errno = errno; - return (-1); - } - for (i = 0; i < NCACHED; i++) - if (hashp->mapp[i]) - if (__put_page(hashp, (char *)hashp->mapp[i], - hashp->BITMAPS[i], 0, 1)) - return (-1); - return (0); -} - -/*******************************SEARCH ROUTINES *****************************/ -/* - * All the access routines return - * - * Returns: - * 0 on SUCCESS - * 1 to indicate an external ERROR (i.e. key not found, etc) - * -1 to indicate an internal ERROR (i.e. out of memory, etc) - */ -static int -hash_get(dbp, key, data, flag) - const DB *dbp; - const DBT *key; - DBT *data; - u_int32_t flag; -{ - HTAB *hashp; - - hashp = (HTAB *)dbp->internal; - if (flag) { - hashp->errno = errno = EINVAL; - return (ERROR); - } - return (hash_access(hashp, HASH_GET, (DBT *)key, data)); -} - -static int -hash_put(dbp, key, data, flag) - const DB *dbp; - DBT *key; - const DBT *data; - u_int32_t flag; -{ - HTAB *hashp; - - hashp = (HTAB *)dbp->internal; - if (flag && flag != R_NOOVERWRITE) { - hashp->errno = errno = EINVAL; - return (ERROR); - } - if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; - return (ERROR); - } - return (hash_access(hashp, flag == R_NOOVERWRITE ? - HASH_PUTNEW : HASH_PUT, (DBT *)key, (DBT *)data)); -} - -static int -hash_delete(dbp, key, flag) - const DB *dbp; - const DBT *key; - u_int32_t flag; /* Ignored */ -{ - HTAB *hashp; - - hashp = (HTAB *)dbp->internal; - if (flag && flag != R_CURSOR) { - hashp->errno = errno = EINVAL; - return (ERROR); - } - if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; - return (ERROR); - } - return (hash_access(hashp, HASH_DELETE, (DBT *)key, NULL)); -} - -/* - * Assume that hashp has been set in wrapper routine. - */ -static int -hash_access(hashp, action, key, val) - HTAB *hashp; - ACTION action; - DBT *key, *val; -{ - register BUFHEAD *rbufp; - BUFHEAD *bufp, *save_bufp; - register u_int16_t *bp; - register int n, ndx, off, size; - register char *kp; - u_int16_t pageno; - -#ifdef HASH_STATISTICS - hash_accesses++; -#endif - - off = hashp->BSIZE; - size = key->size; - kp = (char *)key->data; - rbufp = __get_buf(hashp, __call_hash(hashp, kp, size), NULL, 0); - if (!rbufp) - return (ERROR); - save_bufp = rbufp; - - /* Pin the bucket chain */ - rbufp->flags |= BUF_PIN; - for (bp = (u_int16_t *)rbufp->page, n = *bp++, ndx = 1; ndx < n;) - if (bp[1] >= REAL_KEY) { - /* Real key/data pair */ - if (size == off - *bp && - memcmp(kp, rbufp->page + *bp, size) == 0) - goto found; - off = bp[1]; -#ifdef HASH_STATISTICS - hash_collisions++; -#endif - bp += 2; - ndx += 2; - } else if (bp[1] == OVFLPAGE) { - rbufp = __get_buf(hashp, *bp, rbufp, 0); - if (!rbufp) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - /* FOR LOOP INIT */ - bp = (u_int16_t *)rbufp->page; - n = *bp++; - ndx = 1; - off = hashp->BSIZE; - } else if (bp[1] < REAL_KEY) { - if ((ndx = - __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0) - goto found; - if (ndx == -2) { - bufp = rbufp; - if (!(pageno = - __find_last_page(hashp, &bufp))) { - ndx = 0; - rbufp = bufp; - break; /* FOR */ - } - rbufp = __get_buf(hashp, pageno, bufp, 0); - if (!rbufp) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - /* FOR LOOP INIT */ - bp = (u_int16_t *)rbufp->page; - n = *bp++; - ndx = 1; - off = hashp->BSIZE; - } else { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - } - - /* Not found */ - switch (action) { - case HASH_PUT: - case HASH_PUTNEW: - if (__addel(hashp, rbufp, key, val)) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } else { - save_bufp->flags &= ~BUF_PIN; - return (SUCCESS); - } - case HASH_GET: - case HASH_DELETE: - default: - save_bufp->flags &= ~BUF_PIN; - return (ABNORMAL); - } - -found: - switch (action) { - case HASH_PUTNEW: - save_bufp->flags &= ~BUF_PIN; - return (ABNORMAL); - case HASH_GET: - bp = (u_int16_t *)rbufp->page; - if (bp[ndx + 1] < REAL_KEY) { - if (__big_return(hashp, rbufp, ndx, val, 0)) - return (ERROR); - } else { - val->data = (u_char *)rbufp->page + (int)bp[ndx + 1]; - val->size = bp[ndx] - bp[ndx + 1]; - } - break; - case HASH_PUT: - if ((__delpair(hashp, rbufp, ndx)) || - (__addel(hashp, rbufp, key, val))) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - break; - case HASH_DELETE: - if (__delpair(hashp, rbufp, ndx)) - return (ERROR); - break; - default: - abort(); - } - save_bufp->flags &= ~BUF_PIN; - return (SUCCESS); -} - -static int -hash_seq(dbp, key, data, flag) - const DB *dbp; - DBT *key, *data; - u_int32_t flag; -{ - register u_int32_t bucket; - register BUFHEAD *bufp; - HTAB *hashp; - u_int16_t *bp, ndx; - - hashp = (HTAB *)dbp->internal; - if (flag && flag != R_FIRST && flag != R_NEXT) { - hashp->errno = errno = EINVAL; - return (ERROR); - } -#ifdef HASH_STATISTICS - hash_accesses++; -#endif - if ((hashp->cbucket < 0) || (flag == R_FIRST)) { - hashp->cbucket = 0; - hashp->cndx = 1; - hashp->cpage = NULL; - } - - for (bp = NULL; !bp || !bp[0]; ) { - if (!(bufp = hashp->cpage)) { - for (bucket = hashp->cbucket; - bucket <= hashp->MAX_BUCKET; - bucket++, hashp->cndx = 1) { - bufp = __get_buf(hashp, bucket, NULL, 0); - if (!bufp) - return (ERROR); - hashp->cpage = bufp; - bp = (u_int16_t *)bufp->page; - if (bp[0]) - break; - } - hashp->cbucket = bucket; - if (hashp->cbucket > hashp->MAX_BUCKET) { - hashp->cbucket = -1; - return (ABNORMAL); - } - } else - bp = (u_int16_t *)hashp->cpage->page; - -#ifdef DEBUG - assert(bp); - assert(bufp); -#endif - while (bp[hashp->cndx + 1] == OVFLPAGE) { - bufp = hashp->cpage = - __get_buf(hashp, bp[hashp->cndx], bufp, 0); - if (!bufp) - return (ERROR); - bp = (u_int16_t *)(bufp->page); - hashp->cndx = 1; - } - if (!bp[0]) { - hashp->cpage = NULL; - ++hashp->cbucket; - } - } - ndx = hashp->cndx; - if (bp[ndx + 1] < REAL_KEY) { - if (__big_keydata(hashp, bufp, key, data, 1)) - return (ERROR); - } else { - key->data = (u_char *)hashp->cpage->page + bp[ndx]; - key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx]; - data->data = (u_char *)hashp->cpage->page + bp[ndx + 1]; - data->size = bp[ndx] - bp[ndx + 1]; - ndx += 2; - if (ndx > bp[0]) { - hashp->cpage = NULL; - hashp->cbucket++; - hashp->cndx = 1; - } else - hashp->cndx = ndx; - } - return (SUCCESS); -} - -/********************************* UTILITIES ************************/ - -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -extern int -__expand_table(hashp) - HTAB *hashp; -{ - u_int32_t old_bucket, new_bucket; - int dirsize, new_segnum, spare_ndx; - -#ifdef HASH_STATISTICS - hash_expansions++; -#endif - new_bucket = ++hashp->MAX_BUCKET; - old_bucket = (hashp->MAX_BUCKET & hashp->LOW_MASK); - - new_segnum = new_bucket >> hashp->SSHIFT; - - /* Check if we need a new segment */ - if (new_segnum >= hashp->nsegs) { - /* Check if we need to expand directory */ - if (new_segnum >= hashp->DSIZE) { - /* Reallocate directory */ - dirsize = hashp->DSIZE * sizeof(SEGMENT *); - if (!hash_realloc(&hashp->dir, dirsize, dirsize << 1)) - return (-1); - hashp->DSIZE = dirsize << 1; - } - if ((hashp->dir[new_segnum] = - (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) - return (-1); - hashp->exsegs++; - hashp->nsegs++; - } - /* - * If the split point is increasing (MAX_BUCKET's log base 2 - * * increases), we need to copy the current contents of the spare - * split bucket to the next bucket. - */ - spare_ndx = __log2(hashp->MAX_BUCKET + 1); - if (spare_ndx > hashp->OVFL_POINT) { - hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT]; - hashp->OVFL_POINT = spare_ndx; - } - - if (new_bucket > hashp->HIGH_MASK) { - /* Starting a new doubling */ - hashp->LOW_MASK = hashp->HIGH_MASK; - hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK; - } - /* Relocate records to the new bucket */ - return (__split_page(hashp, old_bucket, new_bucket)); -} - -/* - * If realloc guarantees that the pointer is not destroyed if the realloc - * fails, then this routine can go away. - */ -static void * -hash_realloc(p_ptr, oldsize, newsize) - SEGMENT **p_ptr; - int oldsize, newsize; -{ - register void *p; - - if (p = malloc(newsize)) { - memmove(p, *p_ptr, oldsize); - memset((char *)p + oldsize, 0, newsize - oldsize); - free(*p_ptr); - *p_ptr = p; - } - return (p); -} - -extern u_int32_t -__call_hash(hashp, k, len) - HTAB *hashp; - char *k; - int len; -{ - int n, bucket; - - n = hashp->hash(k, len); - bucket = n & hashp->HIGH_MASK; - if (bucket > hashp->MAX_BUCKET) - bucket = bucket & hashp->LOW_MASK; - return (bucket); -} - -/* - * Allocate segment table. On error, destroy the table and set errno. - * - * Returns 0 on success - */ -static int -alloc_segs(hashp, nsegs) - HTAB *hashp; - int nsegs; -{ - register int i; - register SEGMENT store; - - int save_errno; - - if ((hashp->dir = - (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { - save_errno = errno; - (void)hdestroy(hashp); - errno = save_errno; - return (-1); - } - /* Allocate segments */ - if ((store = - (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { - save_errno = errno; - (void)hdestroy(hashp); - errno = save_errno; - return (-1); - } - for (i = 0; i < nsegs; i++, hashp->nsegs++) - hashp->dir[i] = &store[i << hashp->SSHIFT]; - return (0); -} - -#if BYTE_ORDER == LITTLE_ENDIAN -/* - * Hashp->hdr needs to be byteswapped. - */ -static void -swap_header_copy(srcp, destp) - HASHHDR *srcp, *destp; -{ - int i; - - P_32_COPY(srcp->magic, destp->magic); - P_32_COPY(srcp->version, destp->version); - P_32_COPY(srcp->lorder, destp->lorder); - P_32_COPY(srcp->bsize, destp->bsize); - P_32_COPY(srcp->bshift, destp->bshift); - P_32_COPY(srcp->dsize, destp->dsize); - P_32_COPY(srcp->ssize, destp->ssize); - P_32_COPY(srcp->sshift, destp->sshift); - P_32_COPY(srcp->ovfl_point, destp->ovfl_point); - P_32_COPY(srcp->last_freed, destp->last_freed); - P_32_COPY(srcp->max_bucket, destp->max_bucket); - P_32_COPY(srcp->high_mask, destp->high_mask); - P_32_COPY(srcp->low_mask, destp->low_mask); - P_32_COPY(srcp->ffactor, destp->ffactor); - P_32_COPY(srcp->nkeys, destp->nkeys); - P_32_COPY(srcp->hdrpages, destp->hdrpages); - P_32_COPY(srcp->h_charkey, destp->h_charkey); - for (i = 0; i < NCACHED; i++) { - P_32_COPY(srcp->spares[i], destp->spares[i]); - P_16_COPY(srcp->bitmaps[i], destp->bitmaps[i]); - } -} - -static void -swap_header(hashp) - HTAB *hashp; -{ - HASHHDR *hdrp; - int i; - - hdrp = &hashp->hdr; - - M_32_SWAP(hdrp->magic); - M_32_SWAP(hdrp->version); - M_32_SWAP(hdrp->lorder); - M_32_SWAP(hdrp->bsize); - M_32_SWAP(hdrp->bshift); - M_32_SWAP(hdrp->dsize); - M_32_SWAP(hdrp->ssize); - M_32_SWAP(hdrp->sshift); - M_32_SWAP(hdrp->ovfl_point); - M_32_SWAP(hdrp->last_freed); - M_32_SWAP(hdrp->max_bucket); - M_32_SWAP(hdrp->high_mask); - M_32_SWAP(hdrp->low_mask); - M_32_SWAP(hdrp->ffactor); - M_32_SWAP(hdrp->nkeys); - M_32_SWAP(hdrp->hdrpages); - M_32_SWAP(hdrp->h_charkey); - for (i = 0; i < NCACHED; i++) { - M_32_SWAP(hdrp->spares[i]); - M_16_SWAP(hdrp->bitmaps[i]); - } -} -#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash.h b/user/mpy/lib/berkeley-db-1.xx/hash/hash.h deleted file mode 100644 index 913e82b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hash.h +++ /dev/null @@ -1,293 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)hash.h 8.3 (Berkeley) 5/31/94 - */ - -/* Operations */ -typedef enum { - HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT -} ACTION; - -/* Buffer Management structures */ -typedef struct _bufhead BUFHEAD; - -struct _bufhead { - BUFHEAD *prev; /* LRU links */ - BUFHEAD *next; /* LRU links */ - BUFHEAD *ovfl; /* Overflow page buffer header */ - u_int32_t addr; /* Address of this page */ - char *page; /* Actual page data */ - char flags; -#define BUF_MOD 0x0001 -#define BUF_DISK 0x0002 -#define BUF_BUCKET 0x0004 -#define BUF_PIN 0x0008 -}; - -#define IS_BUCKET(X) ((X) & BUF_BUCKET) - -typedef BUFHEAD **SEGMENT; - -/* Hash Table Information */ -typedef struct hashhdr { /* Disk resident portion */ - int magic; /* Magic NO for hash tables */ - int version; /* Version ID */ - u_int32_t lorder; /* Byte Order */ - int bsize; /* Bucket/Page Size */ - int bshift; /* Bucket shift */ - int dsize; /* Directory Size */ - int ssize; /* Segment Size */ - int sshift; /* Segment shift */ - int ovfl_point; /* Where overflow pages are being - * allocated */ - int last_freed; /* Last overflow page freed */ - int max_bucket; /* ID of Maximum bucket in use */ - int high_mask; /* Mask to modulo into entire table */ - int low_mask; /* Mask to modulo into lower half of - * table */ - int ffactor; /* Fill factor */ - int nkeys; /* Number of keys in hash table */ - int hdrpages; /* Size of table header */ - int h_charkey; /* value of hash(CHARKEY) */ -#define NCACHED 32 /* number of bit maps and spare - * points */ - int spares[NCACHED];/* spare pages for overflow */ - u_int16_t bitmaps[NCACHED]; /* address of overflow page - * bitmaps */ -} HASHHDR; - -typedef struct htab { /* Memory resident data structure */ - HASHHDR hdr; /* Header */ - int nsegs; /* Number of allocated segments */ - int exsegs; /* Number of extra allocated - * segments */ - u_int32_t /* Hash function */ - (*hash)__P((const void *, size_t)); - int flags; /* Flag values */ - int fp; /* File pointer */ - char *tmp_buf; /* Temporary Buffer for BIG data */ - char *tmp_key; /* Temporary Buffer for BIG keys */ - BUFHEAD *cpage; /* Current page */ - int cbucket; /* Current bucket */ - int cndx; /* Index of next item on cpage */ - int errno; /* Error Number -- for DBM - * compatability */ - int new_file; /* Indicates if fd is backing store - * or no */ - int save_file; /* Indicates whether we need to flush - * file at - * exit */ - u_int32_t *mapp[NCACHED]; /* Pointers to page maps */ - int nmaps; /* Initial number of bitmaps */ - int nbufs; /* Number of buffers left to - * allocate */ - BUFHEAD bufhead; /* Header of buffer lru list */ - SEGMENT *dir; /* Hash Bucket directory */ -} HTAB; - -/* - * Constants - */ -#define MAX_BSIZE 65536 /* 2^16 */ -#define MIN_BUFFERS 6 -#define MINHDRSIZE 512 -#define DEF_BUFSIZE 65536 /* 64 K */ -#define DEF_BUCKET_SIZE 4096 -#define DEF_BUCKET_SHIFT 12 /* log2(BUCKET) */ -#define DEF_SEGSIZE 256 -#define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */ -#define DEF_DIRSIZE 256 -#define DEF_FFACTOR 65536 -#define MIN_FFACTOR 4 -#define SPLTMAX 8 -#define CHARKEY "%$sniglet^&" -#define NUMKEY 1038583 -#define BYTE_SHIFT 3 -#define INT_TO_BYTE 2 -#define INT_BYTE_SHIFT 5 -#define ALL_SET ((u_int32_t)0xFFFFFFFF) -#define ALL_CLEAR 0 - -#define PTROF(X) ((BUFHEAD *)((ptrdiff_t)(X)&~0x3)) -#define ISMOD(X) ((u_int32_t)(ptrdiff_t)(X)&0x1) -#define DOMOD(X) ((X) = (char *)((ptrdiff_t)(X)|0x1)) -#define ISDISK(X) ((u_int32_t)(ptrdiff_t)(X)&0x2) -#define DODISK(X) ((X) = (char *)((ptrdiff_t)(X)|0x2)) - -#define BITS_PER_MAP 32 - -/* Given the address of the beginning of a big map, clear/set the nth bit */ -#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) -#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) -#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) - -/* Overflow management */ -/* - * Overflow page numbers are allocated per split point. At each doubling of - * the table, we can allocate extra pages. So, an overflow page number has - * the top 5 bits indicate which split point and the lower 11 bits indicate - * which page at that split point is indicated (pages within split points are - * numberered starting with 1). - */ - -#define SPLITSHIFT 11 -#define SPLITMASK 0x7FF -#define SPLITNUM(N) (((u_int32_t)(N)) >> SPLITSHIFT) -#define OPAGENUM(N) ((N) & SPLITMASK) -#define OADDR_OF(S,O) ((u_int32_t)((u_int32_t)(S) << SPLITSHIFT) + (O)) - -#define BUCKET_TO_PAGE(B) \ - (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((B)+1)-1] : 0) -#define OADDR_TO_PAGE(B) \ - BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)); - -/* - * page.h contains a detailed description of the page format. - * - * Normally, keys and data are accessed from offset tables in the top of - * each page which point to the beginning of the key and data. There are - * four flag values which may be stored in these offset tables which indicate - * the following: - * - * - * OVFLPAGE Rather than a key data pair, this pair contains - * the address of an overflow page. The format of - * the pair is: - * OVERFLOW_PAGE_NUMBER OVFLPAGE - * - * PARTIAL_KEY This must be the first key/data pair on a page - * and implies that page contains only a partial key. - * That is, the key is too big to fit on a single page - * so it starts on this page and continues on the next. - * The format of the page is: - * KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE - * - * KEY_OFF -- offset of the beginning of the key - * PARTIAL_KEY -- 1 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * FULL_KEY This must be the first key/data pair on the page. It - * is used in two cases. - * - * Case 1: - * There is a complete key on the page but no data - * (because it wouldn't fit). The next page contains - * the data. - * - * Page format it: - * KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE - * - * KEY_OFF -- offset of the beginning of the key - * FULL_KEY -- 2 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * Case 2: - * This page contains no key, but part of a large - * data field, which is continued on the next page. - * - * Page format it: - * DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE - * - * KEY_OFF -- offset of the beginning of the data on - * this page - * FULL_KEY -- 2 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * FULL_KEY_DATA - * This must be the first key/data pair on the page. - * There are two cases: - * - * Case 1: - * This page contains a key and the beginning of the - * data field, but the data field is continued on the - * next page. - * - * Page format is: - * KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF - * - * KEY_OFF -- offset of the beginning of the key - * FULL_KEY_DATA -- 3 - * OVFL_PAGENO - page number of the next overflow page - * DATA_OFF -- offset of the beginning of the data - * - * Case 2: - * This page contains the last page of a big data pair. - * There is no key, only the tail end of the data - * on this page. - * - * Page format is: - * DATA_OFF FULL_KEY_DATA - * - * DATA_OFF -- offset of the beginning of the data on - * this page - * FULL_KEY_DATA -- 3 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * OVFL_PAGENO and OVFLPAGE are optional (they are - * not present if there is no next page). - */ - -#define OVFLPAGE 0 -#define PARTIAL_KEY 1 -#define FULL_KEY 2 -#define FULL_KEY_DATA 3 -#define REAL_KEY 4 - -/* Short hands for accessing structure */ -#define BSIZE hdr.bsize -#define BSHIFT hdr.bshift -#define DSIZE hdr.dsize -#define SGSIZE hdr.ssize -#define SSHIFT hdr.sshift -#define LORDER hdr.lorder -#define OVFL_POINT hdr.ovfl_point -#define LAST_FREED hdr.last_freed -#define MAX_BUCKET hdr.max_bucket -#define FFACTOR hdr.ffactor -#define HIGH_MASK hdr.high_mask -#define LOW_MASK hdr.low_mask -#define NKEYS hdr.nkeys -#define HDRPAGES hdr.hdrpages -#define SPARES hdr.spares -#define BITMAPS hdr.bitmaps -#define VERSION hdr.version -#define MAGIC hdr.magic -#define NEXT_FREE hdr.next_free -#define H_CHARKEY hdr.h_charkey diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c deleted file mode 100644 index 578314a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hash_bigkey.c +++ /dev/null @@ -1,667 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hash - * DESCRIPTION: - * Big key/data handling for the hashing package. - * - * ROUTINES: - * External - * __big_keydata - * __big_split - * __big_insert - * __big_return - * __big_delete - * __find_last_page - * Internal - * collect_key - * collect_data - */ - -#include - -#include -#include -#include -#include - -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int)); -static int collect_data __P((HTAB *, BUFHEAD *, int, int)); - -/* - * Big_insert - * - * You need to do an insert and the key/data pair is too big - * - * Returns: - * 0 ==> OK - *-1 ==> ERROR - */ -extern int -__big_insert(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; -{ - register u_int16_t *p; - int key_size, n, val_size; - u_int16_t space, move_bytes, off; - char *cp, *key_data, *val_data; - - cp = bufp->page; /* Character pointer of p. */ - p = (u_int16_t *)cp; - - key_data = (char *)key->data; - key_size = key->size; - val_data = (char *)val->data; - val_size = val->size; - - /* First move the Key */ - for (space = FREESPACE(p) - BIGOVERHEAD; key_size; - space = FREESPACE(p) - BIGOVERHEAD) { - move_bytes = MIN(space, key_size); - off = OFFSET(p) - move_bytes; - memmove(cp + off, key_data, move_bytes); - key_size -= move_bytes; - key_data += move_bytes; - n = p[0]; - p[++n] = off; - p[0] = ++n; - FREESPACE(p) = off - PAGE_META(n); - OFFSET(p) = off; - p[n] = PARTIAL_KEY; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - n = p[0]; - if (!key_size) - if (FREESPACE(p)) { - move_bytes = MIN(FREESPACE(p), val_size); - off = OFFSET(p) - move_bytes; - p[n] = off; - memmove(cp + off, val_data, move_bytes); - val_data += move_bytes; - val_size -= move_bytes; - p[n - 2] = FULL_KEY_DATA; - FREESPACE(p) = FREESPACE(p) - move_bytes; - OFFSET(p) = off; - } else - p[n - 2] = FULL_KEY; - p = (u_int16_t *)bufp->page; - cp = bufp->page; - bufp->flags |= BUF_MOD; - } - - /* Now move the data */ - for (space = FREESPACE(p) - BIGOVERHEAD; val_size; - space = FREESPACE(p) - BIGOVERHEAD) { - move_bytes = MIN(space, val_size); - /* - * Here's the hack to make sure that if the data ends on the - * same page as the key ends, FREESPACE is at least one. - */ - if (space == val_size && val_size == val->size) - move_bytes--; - off = OFFSET(p) - move_bytes; - memmove(cp + off, val_data, move_bytes); - val_size -= move_bytes; - val_data += move_bytes; - n = p[0]; - p[++n] = off; - p[0] = ++n; - FREESPACE(p) = off - PAGE_META(n); - OFFSET(p) = off; - if (val_size) { - p[n] = FULL_KEY; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - cp = bufp->page; - p = (u_int16_t *)cp; - } else - p[n] = FULL_KEY_DATA; - bufp->flags |= BUF_MOD; - } - return (0); -} - -/* - * Called when bufp's page contains a partial key (index should be 1) - * - * All pages in the big key/data pair except bufp are freed. We cannot - * free bufp because the page pointing to it is lost and we can't get rid - * of its pointer. - * - * Returns: - * 0 => OK - *-1 => ERROR - */ -extern int -__big_delete(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; -{ - register BUFHEAD *last_bfp, *rbufp; - u_int16_t *bp, pageno; - int key_done, n; - - rbufp = bufp; - last_bfp = NULL; - bp = (u_int16_t *)bufp->page; - pageno = 0; - key_done = 0; - - while (!key_done || (bp[2] != FULL_KEY_DATA)) { - if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) - key_done = 1; - - /* - * If there is freespace left on a FULL_KEY_DATA page, then - * the data is short and fits entirely on this page, and this - * is the last page. - */ - if (bp[2] == FULL_KEY_DATA && FREESPACE(bp)) - break; - pageno = bp[bp[0] - 1]; - rbufp->flags |= BUF_MOD; - rbufp = __get_buf(hashp, pageno, rbufp, 0); - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = rbufp; - if (!rbufp) - return (-1); /* Error. */ - bp = (u_int16_t *)rbufp->page; - } - - /* - * If we get here then rbufp points to the last page of the big - * key/data pair. Bufp points to the first one -- it should now be - * empty pointing to the next page after this pair. Can't free it - * because we don't have the page pointing to it. - */ - - /* This is information from the last page of the pair. */ - n = bp[0]; - pageno = bp[n - 1]; - - /* Now, bp is the first page of the pair. */ - bp = (u_int16_t *)bufp->page; - if (n > 2) { - /* There is an overflow page. */ - bp[1] = pageno; - bp[2] = OVFLPAGE; - bufp->ovfl = rbufp->ovfl; - } else - /* This is the last page. */ - bufp->ovfl = NULL; - n -= 2; - bp[0] = n; - FREESPACE(bp) = hashp->BSIZE - PAGE_META(n); - OFFSET(bp) = hashp->BSIZE - 1; - - bufp->flags |= BUF_MOD; - if (rbufp) - __free_ovflpage(hashp, rbufp); - if (last_bfp != rbufp) - __free_ovflpage(hashp, last_bfp); - - hashp->NKEYS--; - return (0); -} -/* - * Returns: - * 0 = key not found - * -1 = get next overflow page - * -2 means key not found and this is big key/data - * -3 error - */ -extern int -__find_bigpair(hashp, bufp, ndx, key, size) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; - char *key; - int size; -{ - register u_int16_t *bp; - register char *p; - int ksize; - u_int16_t bytes; - char *kkey; - - bp = (u_int16_t *)bufp->page; - p = bufp->page; - ksize = size; - kkey = key; - - for (bytes = hashp->BSIZE - bp[ndx]; - bytes <= size && bp[ndx + 1] == PARTIAL_KEY; - bytes = hashp->BSIZE - bp[ndx]) { - if (memcmp(p + bp[ndx], kkey, bytes)) - return (-2); - kkey += bytes; - ksize -= bytes; - bufp = __get_buf(hashp, bp[ndx + 2], bufp, 0); - if (!bufp) - return (-3); - p = bufp->page; - bp = (u_int16_t *)p; - ndx = 1; - } - - if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) { -#ifdef HASH_STATISTICS - ++hash_collisions; -#endif - return (-2); - } else - return (ndx); -} - -/* - * Given the buffer pointer of the first overflow page of a big pair, - * find the end of the big pair - * - * This will set bpp to the buffer header of the last page of the big pair. - * It will return the pageno of the overflow page following the last page - * of the pair; 0 if there isn't any (i.e. big pair is the last key in the - * bucket) - */ -extern u_int16_t -__find_last_page(hashp, bpp) - HTAB *hashp; - BUFHEAD **bpp; -{ - BUFHEAD *bufp; - u_int16_t *bp, pageno; - int n; - - bufp = *bpp; - bp = (u_int16_t *)bufp->page; - for (;;) { - n = bp[0]; - - /* - * This is the last page if: the tag is FULL_KEY_DATA and - * either only 2 entries OVFLPAGE marker is explicit there - * is freespace on the page. - */ - if (bp[2] == FULL_KEY_DATA && - ((n == 2) || (bp[n] == OVFLPAGE) || (FREESPACE(bp)))) - break; - - pageno = bp[n - 1]; - bufp = __get_buf(hashp, pageno, bufp, 0); - if (!bufp) - return (0); /* Need to indicate an error! */ - bp = (u_int16_t *)bufp->page; - } - - *bpp = bufp; - if (bp[0] > 2) - return (bp[3]); - else - return (0); -} - -/* - * Return the data for the key/data pair that begins on this page at this - * index (index should always be 1). - */ -extern int -__big_return(hashp, bufp, ndx, val, set_current) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; - DBT *val; - int set_current; -{ - BUFHEAD *save_p; - u_int16_t *bp, len, off, save_addr; - char *tp; - - bp = (u_int16_t *)bufp->page; - while (bp[ndx + 1] == PARTIAL_KEY) { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - ndx = 1; - } - - if (bp[ndx + 1] == FULL_KEY) { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - save_p = bufp; - save_addr = save_p->addr; - off = bp[1]; - len = 0; - } else - if (!FREESPACE(bp)) { - /* - * This is a hack. We can't distinguish between - * FULL_KEY_DATA that contains complete data or - * incomplete data, so we require that if the data - * is complete, there is at least 1 byte of free - * space left. - */ - off = bp[bp[0]]; - len = bp[1] - off; - save_p = bufp; - save_addr = bufp->addr; - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - } else { - /* The data is all on one page. */ - tp = (char *)bp; - off = bp[bp[0]]; - val->data = (u_char *)tp + off; - val->size = bp[1] - off; - if (set_current) { - if (bp[0] == 2) { /* No more buckets in - * chain */ - hashp->cpage = NULL; - hashp->cbucket++; - hashp->cndx = 1; - } else { - hashp->cpage = __get_buf(hashp, - bp[bp[0] - 1], bufp, 0); - if (!hashp->cpage) - return (-1); - hashp->cndx = 1; - if (!((u_int16_t *) - hashp->cpage->page)[0]) { - hashp->cbucket++; - hashp->cpage = NULL; - } - } - } - return (0); - } - - val->size = collect_data(hashp, bufp, (int)len, set_current); - if (val->size == -1) - return (-1); - if (save_p->addr != save_addr) { - /* We are pretty short on buffers. */ - errno = EINVAL; /* OUT OF BUFFERS */ - return (-1); - } - memmove(hashp->tmp_buf, (save_p->page) + off, len); - val->data = (u_char *)hashp->tmp_buf; - return (0); -} -/* - * Count how big the total datasize is by recursing through the pages. Then - * allocate a buffer and copy the data as you recurse up. - */ -static int -collect_data(hashp, bufp, len, set) - HTAB *hashp; - BUFHEAD *bufp; - int len, set; -{ - register u_int16_t *bp; - register char *p; - BUFHEAD *xbp; - u_int16_t save_addr; - int mylen, totlen; - - p = bufp->page; - bp = (u_int16_t *)p; - mylen = hashp->BSIZE - bp[1]; - save_addr = bufp->addr; - - if (bp[2] == FULL_KEY_DATA) { /* End of Data */ - totlen = len + mylen; - if (hashp->tmp_buf) - free(hashp->tmp_buf); - if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL) - return (-1); - if (set) { - hashp->cndx = 1; - if (bp[0] == 2) { /* No more buckets in chain */ - hashp->cpage = NULL; - hashp->cbucket++; - } else { - hashp->cpage = - __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!hashp->cpage) - return (-1); - else if (!((u_int16_t *)hashp->cpage->page)[0]) { - hashp->cbucket++; - hashp->cpage = NULL; - } - } - } - } else { - xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!xbp || ((totlen = - collect_data(hashp, xbp, len + mylen, set)) < 1)) - return (-1); - } - if (bufp->addr != save_addr) { - errno = EINVAL; /* Out of buffers. */ - return (-1); - } - memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen); - return (totlen); -} - -/* - * Fill in the key and data for this big pair. - */ -extern int -__big_keydata(hashp, bufp, key, val, set) - HTAB *hashp; - BUFHEAD *bufp; - DBT *key, *val; - int set; -{ - key->size = collect_key(hashp, bufp, 0, val, set); - if (key->size == -1) - return (-1); - key->data = (u_char *)hashp->tmp_key; - return (0); -} - -/* - * Count how big the total key size is by recursing through the pages. Then - * collect the data, allocate a buffer and copy the key as you recurse up. - */ -static int -collect_key(hashp, bufp, len, val, set) - HTAB *hashp; - BUFHEAD *bufp; - int len; - DBT *val; - int set; -{ - BUFHEAD *xbp; - char *p; - int mylen, totlen; - u_int16_t *bp, save_addr; - - p = bufp->page; - bp = (u_int16_t *)p; - mylen = hashp->BSIZE - bp[1]; - - save_addr = bufp->addr; - totlen = len + mylen; - if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ - if (hashp->tmp_key != NULL) - free(hashp->tmp_key); - if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL) - return (-1); - if (__big_return(hashp, bufp, 1, val, set)) - return (-1); - } else { - xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!xbp || ((totlen = - collect_key(hashp, xbp, totlen, val, set)) < 1)) - return (-1); - } - if (bufp->addr != save_addr) { - errno = EINVAL; /* MIS -- OUT OF BUFFERS */ - return (-1); - } - memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen); - return (totlen); -} - -/* - * Returns: - * 0 => OK - * -1 => error - */ -extern int -__big_split(hashp, op, np, big_keyp, addr, obucket, ret) - HTAB *hashp; - BUFHEAD *op; /* Pointer to where to put keys that go in old bucket */ - BUFHEAD *np; /* Pointer to new bucket page */ - /* Pointer to first page containing the big key/data */ - BUFHEAD *big_keyp; - int addr; /* Address of big_keyp */ - u_int32_t obucket;/* Old Bucket */ - SPLIT_RETURN *ret; -{ - register BUFHEAD *tmpp; - register u_int16_t *tp; - BUFHEAD *bp; - DBT key, val; - u_int32_t change; - u_int16_t free_space, n, off; - - bp = big_keyp; - - /* Now figure out where the big key/data goes */ - if (__big_keydata(hashp, big_keyp, &key, &val, 0)) - return (-1); - change = (__call_hash(hashp, key.data, key.size) != obucket); - - if (ret->next_addr = __find_last_page(hashp, &big_keyp)) { - if (!(ret->nextp = - __get_buf(hashp, ret->next_addr, big_keyp, 0))) - return (-1);; - } else - ret->nextp = NULL; - - /* Now make one of np/op point to the big key/data pair */ -#ifdef DEBUG - assert(np->ovfl == NULL); -#endif - if (change) - tmpp = np; - else - tmpp = op; - - tmpp->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, - "BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->addr, - (tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0)); -#endif - tmpp->ovfl = bp; /* one of op/np point to big_keyp */ - tp = (u_int16_t *)tmpp->page; -#ifdef DEBUG - assert(FREESPACE(tp) >= OVFLSIZE); -#endif - n = tp[0]; - off = OFFSET(tp); - free_space = FREESPACE(tp); - tp[++n] = (u_int16_t)addr; - tp[++n] = OVFLPAGE; - tp[0] = n; - OFFSET(tp) = off; - FREESPACE(tp) = free_space - OVFLSIZE; - - /* - * Finally, set the new and old return values. BIG_KEYP contains a - * pointer to the last page of the big key_data pair. Make sure that - * big_keyp has no following page (2 elements) or create an empty - * following page. - */ - - ret->newp = np; - ret->oldp = op; - - tp = (u_int16_t *)big_keyp->page; - big_keyp->flags |= BUF_MOD; - if (tp[0] > 2) { - /* - * There may be either one or two offsets on this page. If - * there is one, then the overflow page is linked on normally - * and tp[4] is OVFLPAGE. If there are two, tp[4] contains - * the second offset and needs to get stuffed in after the - * next overflow page is added. - */ - n = tp[4]; - free_space = FREESPACE(tp); - off = OFFSET(tp); - tp[0] -= 2; - FREESPACE(tp) = free_space + OVFLSIZE; - OFFSET(tp) = off; - tmpp = __add_ovflpage(hashp, big_keyp); - if (!tmpp) - return (-1); - tp[4] = n; - } else - tmpp = big_keyp; - - if (change) - ret->newp = tmpp; - else - ret->oldp = tmpp; - return (0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c deleted file mode 100644 index 92e1f93..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hash_buf.c +++ /dev/null @@ -1,355 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hash - * - * DESCRIPTION: - * Contains buffer management - * - * ROUTINES: - * External - * __buf_init - * __get_buf - * __buf_free - * __reclaim_buf - * Internal - * newbuf - */ - -#include - -#include -#include -#include -#include - -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static BUFHEAD *newbuf __P((HTAB *, u_int32_t, BUFHEAD *)); - -/* Unlink B from its place in the lru */ -#define BUF_REMOVE(B) { \ - (B)->prev->next = (B)->next; \ - (B)->next->prev = (B)->prev; \ -} - -/* Insert B after P */ -#define BUF_INSERT(B, P) { \ - (B)->next = (P)->next; \ - (B)->prev = (P); \ - (P)->next = (B); \ - (B)->next->prev = (B); \ -} - -#define MRU hashp->bufhead.next -#define LRU hashp->bufhead.prev - -#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead) -#define LRU_INSERT(B) BUF_INSERT((B), LRU) - -/* - * We are looking for a buffer with address "addr". If prev_bp is NULL, then - * address is a bucket index. If prev_bp is not NULL, then it points to the - * page previous to an overflow page that we are trying to find. - * - * CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer - * be valid. Therefore, you must always verify that its address matches the - * address you are seeking. - */ -extern BUFHEAD * -__get_buf(hashp, addr, prev_bp, newpage) - HTAB *hashp; - u_int32_t addr; - BUFHEAD *prev_bp; - int newpage; /* If prev_bp set, indicates a new overflow page. */ -{ - register BUFHEAD *bp; - register u_int32_t is_disk_mask; - register int is_disk, segment_ndx; - SEGMENT segp; - - is_disk = 0; - is_disk_mask = 0; - if (prev_bp) { - bp = prev_bp->ovfl; - if (!bp || (bp->addr != addr)) - bp = NULL; - if (!newpage) - is_disk = BUF_DISK; - } else { - /* Grab buffer out of directory */ - segment_ndx = addr & (hashp->SGSIZE - 1); - - /* valid segment ensured by __call_hash() */ - segp = hashp->dir[addr >> hashp->SSHIFT]; -#ifdef DEBUG - assert(segp != NULL); -#endif - bp = PTROF(segp[segment_ndx]); - is_disk_mask = ISDISK(segp[segment_ndx]); - is_disk = is_disk_mask || !hashp->new_file; - } - - if (!bp) { - bp = newbuf(hashp, addr, prev_bp); - if (!bp || - __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) - return (NULL); - if (!prev_bp) - segp[segment_ndx] = - (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask); - } else { - BUF_REMOVE(bp); - MRU_INSERT(bp); - } - return (bp); -} - -/* - * We need a buffer for this page. Either allocate one, or evict a resident - * one (if we have as many buffers as we're allowed) and put this one in. - * - * If newbuf finds an error (returning NULL), it also sets errno. - */ -static BUFHEAD * -newbuf(hashp, addr, prev_bp) - HTAB *hashp; - u_int32_t addr; - BUFHEAD *prev_bp; -{ - register BUFHEAD *bp; /* The buffer we're going to use */ - register BUFHEAD *xbp; /* Temp pointer */ - register BUFHEAD *next_xbp; - SEGMENT segp; - int segment_ndx; - u_int16_t oaddr, *shortp; - - oaddr = 0; - bp = LRU; - /* - * If LRU buffer is pinned, the buffer pool is too small. We need to - * allocate more buffers. - */ - if (hashp->nbufs || (bp->flags & BUF_PIN)) { - /* Allocate a new one */ - if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL) - return (NULL); -#ifdef PURIFY - memset(bp, 0xff, sizeof(BUFHEAD)); -#endif - if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) { - free(bp); - return (NULL); - } -#ifdef PURIFY - memset(bp->page, 0xff, hashp->BSIZE); -#endif - if (hashp->nbufs) - hashp->nbufs--; - } else { - /* Kick someone out */ - BUF_REMOVE(bp); - /* - * If this is an overflow page with addr 0, it's already been - * flushed back in an overflow chain and initialized. - */ - if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { - /* - * Set oaddr before __put_page so that you get it - * before bytes are swapped. - */ - shortp = (u_int16_t *)bp->page; - if (shortp[0]) - oaddr = shortp[shortp[0] - 1]; - if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, - bp->addr, (int)IS_BUCKET(bp->flags), 0)) - return (NULL); - /* - * Update the pointer to this page (i.e. invalidate it). - * - * If this is a new file (i.e. we created it at open - * time), make sure that we mark pages which have been - * written to disk so we retrieve them from disk later, - * rather than allocating new pages. - */ - if (IS_BUCKET(bp->flags)) { - segment_ndx = bp->addr & (hashp->SGSIZE - 1); - segp = hashp->dir[bp->addr >> hashp->SSHIFT]; -#ifdef DEBUG - assert(segp != NULL); -#endif - - if (hashp->new_file && - ((bp->flags & BUF_MOD) || - ISDISK(segp[segment_ndx]))) - segp[segment_ndx] = (BUFHEAD *)BUF_DISK; - else - segp[segment_ndx] = NULL; - } - /* - * Since overflow pages can only be access by means of - * their bucket, free overflow pages associated with - * this bucket. - */ - for (xbp = bp; xbp->ovfl;) { - next_xbp = xbp->ovfl; - xbp->ovfl = 0; - xbp = next_xbp; - - /* Check that ovfl pointer is up date. */ - if (IS_BUCKET(xbp->flags) || - (oaddr != xbp->addr)) - break; - - shortp = (u_int16_t *)xbp->page; - if (shortp[0]) - /* set before __put_page */ - oaddr = shortp[shortp[0] - 1]; - if ((xbp->flags & BUF_MOD) && __put_page(hashp, - xbp->page, xbp->addr, 0, 0)) - return (NULL); - xbp->addr = 0; - xbp->flags = 0; - BUF_REMOVE(xbp); - LRU_INSERT(xbp); - } - } - } - - /* Now assign this buffer */ - bp->addr = addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n", - bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); -#endif - bp->ovfl = NULL; - if (prev_bp) { - /* - * If prev_bp is set, this is an overflow page, hook it in to - * the buffer overflow links. - */ -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n", - prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0), - (bp ? bp->addr : 0)); -#endif - prev_bp->ovfl = bp; - bp->flags = 0; - } else - bp->flags = BUF_BUCKET; - MRU_INSERT(bp); - return (bp); -} - -extern void -__buf_init(hashp, nbytes) - HTAB *hashp; - int nbytes; -{ - BUFHEAD *bfp; - int npages; - - bfp = &(hashp->bufhead); - npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT; - npages = MAX(npages, MIN_BUFFERS); - - hashp->nbufs = npages; - bfp->next = bfp; - bfp->prev = bfp; - /* - * This space is calloc'd so these are already null. - * - * bfp->ovfl = NULL; - * bfp->flags = 0; - * bfp->page = NULL; - * bfp->addr = 0; - */ -} - -extern int -__buf_free(hashp, do_free, to_disk) - HTAB *hashp; - int do_free, to_disk; -{ - BUFHEAD *bp; - - /* Need to make sure that buffer manager has been initialized */ - if (!LRU) - return (0); - for (bp = LRU; bp != &hashp->bufhead;) { - /* Check that the buffer is valid */ - if (bp->addr || IS_BUCKET(bp->flags)) { - if (to_disk && (bp->flags & BUF_MOD) && - __put_page(hashp, bp->page, - bp->addr, IS_BUCKET(bp->flags), 0)) - return (-1); - } - /* Check if we are freeing stuff */ - if (do_free) { - if (bp->page) - free(bp->page); - BUF_REMOVE(bp); - free(bp); - bp = LRU; - } else - bp = bp->prev; - } - return (0); -} - -extern void -__reclaim_buf(hashp, bp) - HTAB *hashp; - BUFHEAD *bp; -{ - bp->ovfl = 0; - bp->addr = 0; - bp->flags = 0; - BUF_REMOVE(bp); - LRU_INSERT(bp); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c deleted file mode 100644 index a5ec434..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hash_func.c +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static u_int32_t hash1 __P((const void *, size_t)); -static u_int32_t hash2 __P((const void *, size_t)); -static u_int32_t hash3 __P((const void *, size_t)); -static u_int32_t hash4 __P((const void *, size_t)); - -/* Global default hash function */ -u_int32_t (*__default_hash) __P((const void *, size_t)) = hash4; - -/* - * HASH FUNCTIONS - * - * Assume that we've already split the bucket to which this key hashes, - * calculate that bucket, and check that in fact we did already split it. - * - * This came from ejb's hsearch. - */ - -#define PRIME1 37 -#define PRIME2 1048583 - -static u_int32_t -hash1(keyarg, len) - const void *keyarg; - register size_t len; -{ - register const u_char *key; - register u_int32_t h; - - /* Convert string to integer */ - for (key = keyarg, h = 0; len--;) - h = h * PRIME1 ^ (*key++ - ' '); - h %= PRIME2; - return (h); -} - -/* - * Phong's linear congruential hash - */ -#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) - -static u_int32_t -hash2(keyarg, len) - const void *keyarg; - size_t len; -{ - register const u_char *e, *key; - register u_int32_t h; - register u_char c; - - key = keyarg; - e = key + len; - for (h = 0; key != e;) { - c = *key++; - if (!c && key > e) - break; - dcharhash(h, c); - } - return (h); -} - -/* - * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte - * units. On the first time through the loop we get the "leftover bytes" - * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle - * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If - * this routine is heavily used enough, it's worth the ugly coding. - * - * OZ's original sdbm hash - */ -static u_int32_t -hash3(keyarg, len) - const void *keyarg; - register size_t len; -{ - register const u_char *key; - register size_t loop; - register u_int32_t h; - -#define HASHC h = *key++ + 65599 * h - - h = 0; - key = keyarg; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { - HASHC; - /* FALLTHROUGH */ - case 7: - HASHC; - /* FALLTHROUGH */ - case 6: - HASHC; - /* FALLTHROUGH */ - case 5: - HASHC; - /* FALLTHROUGH */ - case 4: - HASHC; - /* FALLTHROUGH */ - case 3: - HASHC; - /* FALLTHROUGH */ - case 2: - HASHC; - /* FALLTHROUGH */ - case 1: - HASHC; - } while (--loop); - } - } - return (h); -} - -/* Hash function from Chris Torek. */ -static u_int32_t -hash4(keyarg, len) - const void *keyarg; - register size_t len; -{ - register const u_char *key; - register size_t loop; - register u_int32_t h; - -#define HASH4a h = (h << 5) - h + *key++; -#define HASH4b h = (h << 5) + h + *key++; -#define HASH4 HASH4b - - h = 0; - key = keyarg; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { - HASH4; - /* FALLTHROUGH */ - case 7: - HASH4; - /* FALLTHROUGH */ - case 6: - HASH4; - /* FALLTHROUGH */ - case 5: - HASH4; - /* FALLTHROUGH */ - case 4: - HASH4; - /* FALLTHROUGH */ - case 3: - HASH4; - /* FALLTHROUGH */ - case 2: - HASH4; - /* FALLTHROUGH */ - case 1: - HASH4; - } while (--loop); - } - } - return (h); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c deleted file mode 100644 index c8c56bf..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hash_log2.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -u_int32_t -__log2(num) - u_int32_t num; -{ - register u_int32_t i, limit; - - limit = 1; - for (i = 0; limit < num; limit = limit << 1, i++); - return (i); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c b/user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c deleted file mode 100644 index e1dfe6b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hash_page.c +++ /dev/null @@ -1,944 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hashing - * - * DESCRIPTION: - * Page manipulation for hashing package. - * - * ROUTINES: - * - * External - * __get_page - * __add_ovflpage - * Internal - * overflow_page - * open_temp - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static u_int32_t *fetch_bitmap __P((HTAB *, int)); -static u_int32_t first_free __P((u_int32_t)); -static int open_temp __P((HTAB *)); -static u_int16_t overflow_page __P((HTAB *)); -static void putpair __P((char *, const DBT *, const DBT *)); -static void squeeze_key __P((u_int16_t *, const DBT *, const DBT *)); -static int ugly_split - __P((HTAB *, u_int32_t, BUFHEAD *, BUFHEAD *, int, int)); - -#define PAGE_INIT(P) { \ - ((u_int16_t *)(P))[0] = 0; \ - ((u_int16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_int16_t); \ - ((u_int16_t *)(P))[2] = hashp->BSIZE; \ -} - -/* - * This is called AFTER we have verified that there is room on the page for - * the pair (PAIRFITS has returned true) so we go right ahead and start moving - * stuff on. - */ -static void -putpair(p, key, val) - char *p; - const DBT *key, *val; -{ - register u_int16_t *bp, n, off; - - bp = (u_int16_t *)p; - - /* Enter the key first. */ - n = bp[0]; - - off = OFFSET(bp) - key->size; - memmove(p + off, key->data, key->size); - bp[++n] = off; - - /* Now the data. */ - off -= val->size; - memmove(p + off, val->data, val->size); - bp[++n] = off; - - /* Adjust page info. */ - bp[0] = n; - bp[n + 1] = off - ((n + 3) * sizeof(u_int16_t)); - bp[n + 2] = off; -} - -/* - * Returns: - * 0 OK - * -1 error - */ -extern int -__delpair(hashp, bufp, ndx) - HTAB *hashp; - BUFHEAD *bufp; - register int ndx; -{ - register u_int16_t *bp, newoff; - register int n; - u_int16_t pairlen; - - bp = (u_int16_t *)bufp->page; - n = bp[0]; - - if (bp[ndx + 1] < REAL_KEY) - return (__big_delete(hashp, bufp)); - if (ndx != 1) - newoff = bp[ndx - 1]; - else - newoff = hashp->BSIZE; - pairlen = newoff - bp[ndx + 1]; - - if (ndx != (n - 1)) { - /* Hard Case -- need to shuffle keys */ - register int i; - register char *src = bufp->page + (int)OFFSET(bp); - register char *dst = src + (int)pairlen; - memmove(dst, src, bp[ndx + 1] - OFFSET(bp)); - - /* Now adjust the pointers */ - for (i = ndx + 2; i <= n; i += 2) { - if (bp[i + 1] == OVFLPAGE) { - bp[i - 2] = bp[i]; - bp[i - 1] = bp[i + 1]; - } else { - bp[i - 2] = bp[i] + pairlen; - bp[i - 1] = bp[i + 1] + pairlen; - } - } - } - /* Finally adjust the page data */ - bp[n] = OFFSET(bp) + pairlen; - bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(u_int16_t); - bp[0] = n - 2; - hashp->NKEYS--; - - bufp->flags |= BUF_MOD; - return (0); -} -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -extern int -__split_page(hashp, obucket, nbucket) - HTAB *hashp; - u_int32_t obucket, nbucket; -{ - register BUFHEAD *new_bufp, *old_bufp; - register u_int16_t *ino; - register char *np; - DBT key, val; - int n, ndx, retval; - u_int16_t copyto, diff, off, moved; - char *op; - - copyto = (u_int16_t)hashp->BSIZE; - off = (u_int16_t)hashp->BSIZE; - old_bufp = __get_buf(hashp, obucket, NULL, 0); - if (old_bufp == NULL) - return (-1); - new_bufp = __get_buf(hashp, nbucket, NULL, 0); - if (new_bufp == NULL) - return (-1); - - old_bufp->flags |= (BUF_MOD | BUF_PIN); - new_bufp->flags |= (BUF_MOD | BUF_PIN); - - ino = (u_int16_t *)(op = old_bufp->page); - np = new_bufp->page; - - moved = 0; - - for (n = 1, ndx = 1; n < ino[0]; n += 2) { - if (ino[n + 1] < REAL_KEY) { - retval = ugly_split(hashp, obucket, old_bufp, new_bufp, - (int)copyto, (int)moved); - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (retval); - - } - key.data = (u_char *)op + ino[n]; - key.size = off - ino[n]; - - if (__call_hash(hashp, key.data, key.size) == obucket) { - /* Don't switch page */ - diff = copyto - off; - if (diff) { - copyto = ino[n + 1] + diff; - memmove(op + copyto, op + ino[n + 1], - off - ino[n + 1]); - ino[ndx] = copyto + ino[n] - ino[n + 1]; - ino[ndx + 1] = copyto; - } else - copyto = ino[n + 1]; - ndx += 2; - } else { - /* Switch page */ - val.data = (u_char *)op + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - putpair(np, &key, &val); - moved += 2; - } - - off = ino[n + 1]; - } - - /* Now clean up the page */ - ino[0] -= moved; - FREESPACE(ino) = copyto - sizeof(u_int16_t) * (ino[0] + 3); - OFFSET(ino) = copyto; - -#ifdef DEBUG3 - (void)fprintf(stderr, "split %d/%d\n", - ((u_int16_t *)np)[0] / 2, - ((u_int16_t *)op)[0] / 2); -#endif - /* unpin both pages */ - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (0); -} - -/* - * Called when we encounter an overflow or big key/data page during split - * handling. This is special cased since we have to begin checking whether - * the key/data pairs fit on their respective pages and because we may need - * overflow pages for both the old and new pages. - * - * The first page might be a page with regular key/data pairs in which case - * we have a regular overflow condition and just need to go on to the next - * page or it might be a big key/data pair in which case we need to fix the - * big key/data pair. - * - * Returns: - * 0 ==> success - * -1 ==> failure - */ -static int -ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) - HTAB *hashp; - u_int32_t obucket; /* Same as __split_page. */ - BUFHEAD *old_bufp, *new_bufp; - int copyto; /* First byte on page which contains key/data values. */ - int moved; /* Number of pairs moved to new page. */ -{ - register BUFHEAD *bufp; /* Buffer header for ino */ - register u_int16_t *ino; /* Page keys come off of */ - register u_int16_t *np; /* New page */ - register u_int16_t *op; /* Page keys go on to if they aren't moving */ - - BUFHEAD *last_bfp; /* Last buf header OVFL needing to be freed */ - DBT key, val; - SPLIT_RETURN ret; - u_int16_t n, off, ov_addr, scopyto; - char *cino; /* Character value of ino */ - - bufp = old_bufp; - ino = (u_int16_t *)old_bufp->page; - np = (u_int16_t *)new_bufp->page; - op = (u_int16_t *)old_bufp->page; - last_bfp = NULL; - scopyto = (u_int16_t)copyto; /* ANSI */ - - n = ino[0] - 1; - while (n < ino[0]) { - if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) { - if (__big_split(hashp, old_bufp, - new_bufp, bufp, bufp->addr, obucket, &ret)) - return (-1); - old_bufp = ret.oldp; - if (!old_bufp) - return (-1); - op = (u_int16_t *)old_bufp->page; - new_bufp = ret.newp; - if (!new_bufp) - return (-1); - np = (u_int16_t *)new_bufp->page; - bufp = ret.nextp; - if (!bufp) - return (0); - cino = (char *)bufp->page; - ino = (u_int16_t *)cino; - last_bfp = ret.nextp; - } else if (ino[n + 1] == OVFLPAGE) { - ov_addr = ino[n]; - /* - * Fix up the old page -- the extra 2 are the fields - * which contained the overflow information. - */ - ino[0] -= (moved + 2); - FREESPACE(ino) = - scopyto - sizeof(u_int16_t) * (ino[0] + 3); - OFFSET(ino) = scopyto; - - bufp = __get_buf(hashp, ov_addr, bufp, 0); - if (!bufp) - return (-1); - - ino = (u_int16_t *)bufp->page; - n = 1; - scopyto = hashp->BSIZE; - moved = 0; - - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = bufp; - } - /* Move regular sized pairs of there are any */ - off = hashp->BSIZE; - for (n = 1; (n < ino[0]) && (ino[n + 1] >= REAL_KEY); n += 2) { - cino = (char *)ino; - key.data = (u_char *)cino + ino[n]; - key.size = off - ino[n]; - val.data = (u_char *)cino + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - off = ino[n + 1]; - - if (__call_hash(hashp, key.data, key.size) == obucket) { - /* Keep on old page */ - if (PAIRFITS(op, (&key), (&val))) - putpair((char *)op, &key, &val); - else { - old_bufp = - __add_ovflpage(hashp, old_bufp); - if (!old_bufp) - return (-1); - op = (u_int16_t *)old_bufp->page; - putpair((char *)op, &key, &val); - } - old_bufp->flags |= BUF_MOD; - } else { - /* Move to new page */ - if (PAIRFITS(np, (&key), (&val))) - putpair((char *)np, &key, &val); - else { - new_bufp = - __add_ovflpage(hashp, new_bufp); - if (!new_bufp) - return (-1); - np = (u_int16_t *)new_bufp->page; - putpair((char *)np, &key, &val); - } - new_bufp->flags |= BUF_MOD; - } - } - } - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - return (0); -} - -/* - * Add the given pair to the page - * - * Returns: - * 0 ==> OK - * 1 ==> failure - */ -extern int -__addel(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; -{ - register u_int16_t *bp, *sop; - int do_expand; - - bp = (u_int16_t *)bufp->page; - do_expand = 0; - while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY)) - /* Exception case */ - if (bp[2] == FULL_KEY_DATA && bp[0] == 2) - /* This is the last page of a big key/data pair - and we need to add another page */ - break; - else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - } else - /* Try to squeeze key on this page */ - if (FREESPACE(bp) > PAIRSIZE(key, val)) { - squeeze_key(bp, key, val); - return (0); - } else { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - } - - if (PAIRFITS(bp, key, val)) - putpair(bufp->page, key, val); - else { - do_expand = 1; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - sop = (u_int16_t *)bufp->page; - - if (PAIRFITS(sop, key, val)) - putpair((char *)sop, key, val); - else - if (__big_insert(hashp, bufp, key, val)) - return (-1); - } - bufp->flags |= BUF_MOD; - /* - * If the average number of keys per bucket exceeds the fill factor, - * expand the table. - */ - hashp->NKEYS++; - if (do_expand || - (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR)) - return (__expand_table(hashp)); - return (0); -} - -/* - * - * Returns: - * pointer on success - * NULL on error - */ -extern BUFHEAD * -__add_ovflpage(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; -{ - register u_int16_t *sp; - u_int16_t ndx, ovfl_num; -#ifdef DEBUG1 - int tmp1, tmp2; -#endif - sp = (u_int16_t *)bufp->page; - - /* Check if we are dynamically determining the fill factor */ - if (hashp->FFACTOR == DEF_FFACTOR) { - hashp->FFACTOR = sp[0] >> 1; - if (hashp->FFACTOR < MIN_FFACTOR) - hashp->FFACTOR = MIN_FFACTOR; - } - bufp->flags |= BUF_MOD; - ovfl_num = overflow_page(hashp); -#ifdef DEBUG1 - tmp1 = bufp->addr; - tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0; -#endif - if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1))) - return (NULL); - bufp->ovfl->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n", - tmp1, tmp2, bufp->ovfl->addr); -#endif - ndx = sp[0]; - /* - * Since a pair is allocated on a page only if there's room to add - * an overflow page, we know that the OVFL information will fit on - * the page. - */ - sp[ndx + 4] = OFFSET(sp); - sp[ndx + 3] = FREESPACE(sp) - OVFLSIZE; - sp[ndx + 1] = ovfl_num; - sp[ndx + 2] = OVFLPAGE; - sp[0] = ndx + 2; -#ifdef HASH_STATISTICS - hash_overflows++; -#endif - return (bufp->ovfl); -} - -/* - * Returns: - * 0 indicates SUCCESS - * -1 indicates FAILURE - */ -extern int -__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) - HTAB *hashp; - char *p; - u_int32_t bucket; - int is_bucket, is_disk, is_bitmap; -{ - register int fd, page, size; - int rsize; - u_int16_t *bp; - - fd = hashp->fp; - size = hashp->BSIZE; - - if ((fd == -1) || !is_disk) { - PAGE_INIT(p); - return (0); - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((rsize = read(fd, p, size)) == -1)) - return (-1); - bp = (u_int16_t *)p; - if (!rsize) - bp[0] = 0; /* We hit the EOF, so initialize a new page */ - else - if (rsize != size) { - errno = EFTYPE; - return (-1); - } - if (!is_bitmap && !bp[0]) { - PAGE_INIT(p); - } else - if (hashp->LORDER != BYTE_ORDER) { - register int i, max; - - if (is_bitmap) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - M_32_SWAP(((int *)p)[i]); - } else { - M_16_SWAP(bp[0]); - max = bp[0] + 2; - for (i = 1; i <= max; i++) - M_16_SWAP(bp[i]); - } - } - return (0); -} - -/* - * Write page p to disk - * - * Returns: - * 0 ==> OK - * -1 ==>failure - */ -extern int -__put_page(hashp, p, bucket, is_bucket, is_bitmap) - HTAB *hashp; - char *p; - u_int32_t bucket; - int is_bucket, is_bitmap; -{ - register int fd, page, size; - int wsize; - - size = hashp->BSIZE; - if ((hashp->fp == -1) && open_temp(hashp)) - return (-1); - fd = hashp->fp; - - if (hashp->LORDER != BYTE_ORDER) { - register int i; - register int max; - - if (is_bitmap) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - M_32_SWAP(((int *)p)[i]); - } else { - max = ((u_int16_t *)p)[0] + 2; - for (i = 0; i <= max; i++) - M_16_SWAP(((u_int16_t *)p)[i]); - } - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((wsize = write(fd, p, size)) == -1)) - /* Errno is set */ - return (-1); - if (wsize != size) { - errno = EFTYPE; - return (-1); - } - return (0); -} - -#define BYTE_MASK ((1 << INT_BYTE_SHIFT) -1) -/* - * Initialize a new bitmap page. Bitmap pages are left in memory - * once they are read in. - */ -extern int -__ibitmap(hashp, pnum, nbits, ndx) - HTAB *hashp; - int pnum, nbits, ndx; -{ - u_int32_t *ip; - int clearbytes, clearints; - - if ((ip = (u_int32_t *)malloc(hashp->BSIZE)) == NULL) - return (1); - hashp->nmaps++; - clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; - clearbytes = clearints << INT_TO_BYTE; - (void)memset((char *)ip, 0, clearbytes); - (void)memset(((char *)ip) + clearbytes, 0xFF, - hashp->BSIZE - clearbytes); - ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK); - SETBIT(ip, 0); - hashp->BITMAPS[ndx] = (u_int16_t)pnum; - hashp->mapp[ndx] = ip; - return (0); -} - -static u_int32_t -first_free(map) - u_int32_t map; -{ - register u_int32_t i, mask; - - mask = 0x1; - for (i = 0; i < BITS_PER_MAP; i++) { - if (!(mask & map)) - return (i); - mask = mask << 1; - } - return (i); -} - -static u_int16_t -overflow_page(hashp) - HTAB *hashp; -{ - register u_int32_t *freep; - register int max_free, offset, splitnum; - u_int16_t addr; - int bit, first_page, free_bit, free_page, i, in_use_bits, j; -#ifdef DEBUG2 - int tmp1, tmp2; -#endif - splitnum = hashp->OVFL_POINT; - max_free = hashp->SPARES[splitnum]; - - free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT); - free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - /* Look through all the free maps to find the first free block */ - first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT); - for ( i = first_page; i <= free_page; i++ ) { - if (!(freep = (u_int32_t *)hashp->mapp[i]) && - !(freep = fetch_bitmap(hashp, i))) - return (0); - if (i == free_page) - in_use_bits = free_bit; - else - in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1; - - if (i == first_page) { - bit = hashp->LAST_FREED & - ((hashp->BSIZE << BYTE_SHIFT) - 1); - j = bit / BITS_PER_MAP; - bit = bit & ~(BITS_PER_MAP - 1); - } else { - bit = 0; - j = 0; - } - for (; bit <= in_use_bits; j++, bit += BITS_PER_MAP) - if (freep[j] != ALL_SET) - goto found; - } - - /* No Free Page Found */ - hashp->LAST_FREED = hashp->SPARES[splitnum]; - hashp->SPARES[splitnum]++; - offset = hashp->SPARES[splitnum] - - (splitnum ? hashp->SPARES[splitnum - 1] : 0); - -#define OVMSG "HASH: Out of overflow pages. Increase page size\n" - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return (0); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 1; - } - - /* Check if we need to allocate a new bitmap page */ - if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { - free_page++; - if (free_page >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return (0); - } - /* - * This is tricky. The 1 indicates that you want the new page - * allocated with 1 clear bit. Actually, you are going to - * allocate 2 pages from this map. The first is going to be - * the map page, the second is the overflow page we were - * looking for. The init_bitmap routine automatically, sets - * the first bit of itself to indicate that the bitmap itself - * is in use. We would explicitly set the second bit, but - * don't have to if we tell init_bitmap not to leave it clear - * in the first place. - */ - if (__ibitmap(hashp, - (int)OADDR_OF(splitnum, offset), 1, free_page)) - return (0); - hashp->SPARES[splitnum]++; -#ifdef DEBUG2 - free_bit = 2; -#endif - offset++; - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, - sizeof(OVMSG) - 1); - return (0); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 0; - } - } else { - /* - * Free_bit addresses the last used bit. Bump it to address - * the first available bit. - */ - free_bit++; - SETBIT(freep, free_bit); - } - - /* Calculate address of the new overflow page */ - addr = OADDR_OF(splitnum, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, free_bit, free_page); -#endif - return (addr); - -found: - bit = bit + first_free(freep[j]); - SETBIT(freep, bit); -#ifdef DEBUG2 - tmp1 = bit; - tmp2 = i; -#endif - /* - * Bits are addressed starting with 0, but overflow pages are addressed - * beginning at 1. Bit is a bit addressnumber, so we need to increment - * it to convert it to a page number. - */ - bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT)); - if (bit >= hashp->LAST_FREED) - hashp->LAST_FREED = bit - 1; - - /* Calculate the split number for this page */ - for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++); - offset = (i ? bit - hashp->SPARES[i - 1] : bit); - if (offset >= SPLITMASK) - return (0); /* Out of overflow pages */ - addr = OADDR_OF(i, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, tmp1, tmp2); -#endif - - /* Allocate and return the overflow page */ - return (addr); -} - -/* - * Mark this overflow page as free. - */ -extern void -__free_ovflpage(hashp, obufp) - HTAB *hashp; - BUFHEAD *obufp; -{ - register u_int16_t addr; - u_int32_t *freep; - int bit_address, free_page, free_bit; - u_int16_t ndx; - - addr = obufp->addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "Freeing %d\n", addr); -#endif - ndx = (((u_int16_t)addr) >> SPLITSHIFT); - bit_address = - (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1; - if (bit_address < hashp->LAST_FREED) - hashp->LAST_FREED = bit_address; - free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT)); - free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - if (!(freep = hashp->mapp[free_page])) - freep = fetch_bitmap(hashp, free_page); -#ifdef DEBUG - /* - * This had better never happen. It means we tried to read a bitmap - * that has already had overflow pages allocated off it, and we - * failed to read it from the file. - */ - if (!freep) - assert(0); -#endif - CLRBIT(freep, free_bit); -#ifdef DEBUG2 - (void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", - obufp->addr, free_bit, free_page); -#endif - __reclaim_buf(hashp, obufp); -} - -/* - * Returns: - * 0 success - * -1 failure - */ -static int -open_temp(hashp) - HTAB *hashp; -{ - sigset_t set, oset; - static char namestr[] = "_hashXXXXXX"; - - /* Block signals; make sure file goes away at process exit. */ - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((hashp->fp = mkstemp(namestr)) != -1) { - (void)unlink(namestr); - (void)fcntl(hashp->fp, F_SETFD, 1); - } - (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); - return (hashp->fp != -1 ? 0 : -1); -} - -/* - * We have to know that the key will fit, but the last entry on the page is - * an overflow pair, so we need to shift things. - */ -static void -squeeze_key(sp, key, val) - u_int16_t *sp; - const DBT *key, *val; -{ - register char *p; - u_int16_t free_space, n, off, pageno; - - p = (char *)sp; - n = sp[0]; - free_space = FREESPACE(sp); - off = OFFSET(sp); - - pageno = sp[n - 1]; - off -= key->size; - sp[n - 1] = off; - memmove(p + off, key->data, key->size); - off -= val->size; - sp[n] = off; - memmove(p + off, val->data, val->size); - sp[0] = n + 2; - sp[n + 1] = pageno; - sp[n + 2] = OVFLPAGE; - FREESPACE(sp) = free_space - PAIRSIZE(key, val); - OFFSET(sp) = off; -} - -static u_int32_t * -fetch_bitmap(hashp, ndx) - HTAB *hashp; - int ndx; -{ - if (ndx >= hashp->nmaps) - return (NULL); - if ((hashp->mapp[ndx] = (u_int32_t *)malloc(hashp->BSIZE)) == NULL) - return (NULL); - if (__get_page(hashp, - (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) { - free(hashp->mapp[ndx]); - return (NULL); - } - return (hashp->mapp[ndx]); -} - -#ifdef DEBUG4 -int -print_chain(addr) - int addr; -{ - BUFHEAD *bufp; - short *bp, oaddr; - - (void)fprintf(stderr, "%d ", addr); - bufp = __get_buf(hashp, addr, NULL, 0); - bp = (short *)bufp->page; - while (bp[0] && ((bp[bp[0]] == OVFLPAGE) || - ((bp[0] > 2) && bp[2] < REAL_KEY))) { - oaddr = bp[bp[0] - 1]; - (void)fprintf(stderr, "%d ", (int)oaddr); - bufp = __get_buf(hashp, (int)oaddr, bufp, 0); - bp = (short *)bufp->page; - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c b/user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c deleted file mode 100644 index cc8f7a4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/hsearch.c +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hsearch.c 8.4 (Berkeley) 7/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#include -#include "search.h" - -static DB *dbp = NULL; -static ENTRY retval; - -extern int -hcreate(nel) - u_int nel; -{ - HASHINFO info; - - info.nelem = nel; - info.bsize = 256; - info.ffactor = 8; - info.cachesize = 0; - info.hash = NULL; - info.lorder = 0; - dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0); - return ((int)dbp); -} - -extern ENTRY * -hsearch(item, action) - ENTRY item; - ACTION action; -{ - DBT key, val; - int status; - - if (!dbp) - return (NULL); - key.data = (u_char *)item.key; - key.size = strlen(item.key) + 1; - - if (action == ENTER) { - val.data = (u_char *)item.data; - val.size = strlen(item.data) + 1; - status = (dbp->put)(dbp, &key, &val, R_NOOVERWRITE); - if (status) - return (NULL); - } else { - /* FIND */ - status = (dbp->get)(dbp, &key, &val, 0); - if (status) - return (NULL); - else - item.data = (char *)val.data; - } - retval.key = item.key; - retval.data = item.data; - return (&retval); -} - -extern void -hdestroy() -{ - if (dbp) { - (void)(dbp->close)(dbp); - dbp = NULL; - } -} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c b/user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c deleted file mode 100644 index 2cbbe91..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/ndbm.c +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * This package provides a dbm compatible interface to the new hashing - * package described in db(3). - */ - -#include - -#include -#include - -#include -#include "hash.h" - -/* - * Returns: - * *DBM on success - * NULL on failure - */ -extern DBM * -dbm_open(file, flags, mode) - const char *file; - int flags, mode; -{ - HASHINFO info; - char path[MAXPATHLEN]; - - info.bsize = 4096; - info.ffactor = 40; - info.nelem = 1; - info.cachesize = 0; - info.hash = NULL; - info.lorder = 0; - (void)strcpy(path, file); - (void)strcat(path, DBM_SUFFIX); - return ((DBM *)__hash_open(path, flags, mode, &info, 0)); -} - -extern void -dbm_close(db) - DBM *db; -{ - (void)(db->close)(db); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_fetch(db, key) - DBM *db; - datum key; -{ - datum retval; - int status; - - status = (db->get)(db, (DBT *)&key, (DBT *)&retval, 0); - if (status) { - retval.dptr = NULL; - retval.dsize = 0; - } - return (retval); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_firstkey(db) - DBM *db; -{ - int status; - datum retdata, retkey; - - status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_FIRST); - if (status) - retkey.dptr = NULL; - return (retkey); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_nextkey(db) - DBM *db; -{ - int status; - datum retdata, retkey; - - status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_NEXT); - if (status) - retkey.dptr = NULL; - return (retkey); -} -/* - * Returns: - * 0 on success - * <0 failure - */ -extern int -dbm_delete(db, key) - DBM *db; - datum key; -{ - int status; - - status = (db->del)(db, (DBT *)&key, 0); - if (status) - return (-1); - else - return (0); -} - -/* - * Returns: - * 0 on success - * <0 failure - * 1 if DBM_INSERT and entry exists - */ -extern int -dbm_store(db, key, content, flags) - DBM *db; - datum key, content; - int flags; -{ - return ((db->put)(db, (DBT *)&key, (DBT *)&content, - (flags == DBM_INSERT) ? R_NOOVERWRITE : 0)); -} - -extern int -dbm_error(db) - DBM *db; -{ - HTAB *hp; - - hp = (HTAB *)db->internal; - return (hp->errno); -} - -extern int -dbm_clearerr(db) - DBM *db; -{ - HTAB *hp; - - hp = (HTAB *)db->internal; - hp->errno = 0; - return (0); -} - -extern int -dbm_dirfno(db) - DBM *db; -{ - return(((HTAB *)db->internal)->fp); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/page.h b/user/mpy/lib/berkeley-db-1.xx/hash/page.h deleted file mode 100644 index 0fc0d5a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/page.h +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)page.h 8.2 (Berkeley) 5/31/94 - */ - -/* - * Definitions for hashing page file format. - */ - -/* - * routines dealing with a data page - * - * page format: - * +------------------------------+ - * p | n | keyoff | datoff | keyoff | - * +------------+--------+--------+ - * | datoff | free | ptr | --> | - * +--------+---------------------+ - * | F R E E A R E A | - * +--------------+---------------+ - * | <---- - - - | data | - * +--------+-----+----+----------+ - * | key | data | key | - * +--------+----------+----------+ - * - * Pointer to the free space is always: p[p[0] + 2] - * Amount of free space on the page is: p[p[0] + 1] - */ - -/* - * How many bytes required for this pair? - * 2 shorts in the table at the top of the page + room for the - * key and room for the data - * - * We prohibit entering a pair on a page unless there is also room to append - * an overflow page. The reason for this it that you can get in a situation - * where a single key/data pair fits on a page, but you can't append an - * overflow page and later you'd have to split the key/data and handle like - * a big pair. - * You might as well do this up front. - */ - -#define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->size + (D)->size) -#define BIGOVERHEAD (4*sizeof(u_int16_t)) -#define KEYSIZE(K) (4*sizeof(u_int16_t) + (K)->size); -#define OVFLSIZE (2*sizeof(u_int16_t)) -#define FREESPACE(P) ((P)[(P)[0]+1]) -#define OFFSET(P) ((P)[(P)[0]+2]) -#define PAIRFITS(P,K,D) \ - (((P)[2] >= REAL_KEY) && \ - (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) -#define PAGE_META(N) (((N)+3) * sizeof(u_int16_t)) - -typedef struct { - BUFHEAD *newp; - BUFHEAD *oldp; - BUFHEAD *nextp; - u_int16_t next_addr; -} SPLIT_RETURN; diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/search.h b/user/mpy/lib/berkeley-db-1.xx/hash/search.h deleted file mode 100644 index 4d3b914..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/search.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)search.h 8.1 (Berkeley) 6/4/93 - */ - -/* Backward compatibility to hsearch interface. */ -typedef struct entry { - char *key; - char *data; -} ENTRY; - -typedef enum { - FIND, ENTER -} ACTION; - -int hcreate __P((unsigned int)); -void hdestroy __P((void)); -ENTRY *hsearch __P((ENTRY, ACTION)); diff --git a/user/mpy/lib/berkeley-db-1.xx/hash/tags b/user/mpy/lib/berkeley-db-1.xx/hash/tags deleted file mode 120000 index 7ab656b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/hash/tags +++ /dev/null @@ -1 +0,0 @@ -../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/include/db.h b/user/mpy/lib/berkeley-db-1.xx/include/db.h deleted file mode 100644 index 2029de5..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/include/db.h +++ /dev/null @@ -1,237 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)db.h 8.7 (Berkeley) 6/16/94 - */ - -#ifndef _DB_H_ -#define _DB_H_ - -#include -#include - -#include - -#include -#ifdef __DBINTERFACE_PRIVATE -#include -#endif - -#define RET_ERROR -1 /* Return values. */ -#define RET_SUCCESS 0 -#define RET_SPECIAL 1 - -#ifndef __BIT_TYPES_DEFINED__ -#define __BIT_TYPES_DEFINED__ -typedef __signed char int8_t; -typedef unsigned char u_int8_t; -typedef short int16_t; -typedef unsigned short u_int16_t; -typedef int int32_t; -typedef unsigned int u_int32_t; -#ifdef WE_DONT_NEED_QUADS -typedef long long int64_t; -typedef unsigned long long u_int64_t; -#endif -#endif - -#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ -typedef u_int32_t pgno_t; -#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ -typedef u_int16_t indx_t; -#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ -typedef u_int32_t recno_t; - -/* Key/data structure -- a Data-Base Thang. */ -typedef struct { - void *data; /* data */ - size_t size; /* data length */ -} DBT; - -/* Routine flags. */ -#define R_CURSOR 1 /* del, put, seq */ -#define __R_UNUSED 2 /* UNUSED */ -#define R_FIRST 3 /* seq */ -#define R_IAFTER 4 /* put (RECNO) */ -#define R_IBEFORE 5 /* put (RECNO) */ -#define R_LAST 6 /* seq (BTREE, RECNO) */ -#define R_NEXT 7 /* seq */ -#define R_NOOVERWRITE 8 /* put */ -#define R_PREV 9 /* seq (BTREE, RECNO) */ -#define R_SETCURSOR 10 /* put (RECNO) */ -#define R_RECNOSYNC 11 /* sync (RECNO) */ - -typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; - -/* - * !!! - * The following flags are included in the dbopen(3) call as part of the - * open(2) flags. In order to avoid conflicts with the open flags, start - * at the top of the 16 or 32-bit number space and work our way down. If - * the open flags were significantly expanded in the future, it could be - * a problem. Wish I'd left another flags word in the dbopen call. - * - * !!! - * None of this stuff is implemented yet. The only reason that it's here - * is so that the access methods can skip copying the key/data pair when - * the DB_LOCK flag isn't set. - */ -#if UINT_MAX > 65535 -#define DB_LOCK 0x20000000 /* Do locking. */ -#define DB_SHMEM 0x40000000 /* Use shared memory. */ -#define DB_TXN 0x80000000 /* Do transactions. */ -#else -#define DB_LOCK 0x2000 /* Do locking. */ -#define DB_SHMEM 0x4000 /* Use shared memory. */ -#define DB_TXN 0x8000 /* Do transactions. */ -#endif - -/* Access method description structure. */ -typedef struct __db { - DBTYPE type; /* Underlying db type. */ - int (*close) __P((struct __db *)); - int (*del) __P((const struct __db *, const DBT *, u_int)); - int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); - int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); - int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); - int (*sync) __P((const struct __db *, u_int)); - void *internal; /* Access method private. */ - int (*fd) __P((const struct __db *)); -} DB; - -#define BTREEMAGIC 0x053162 -#define BTREEVERSION 3 - -/* Structure used to pass parameters to the btree routines. */ -typedef struct { -#define R_DUP 0x01 /* duplicate keys */ - u_long flags; - u_int cachesize; /* bytes to cache */ - int maxkeypage; /* maximum keys per page */ - int minkeypage; /* minimum keys per page */ - u_int psize; /* page size */ - int (*compare) /* comparison function */ - __P((const DBT *, const DBT *)); - size_t (*prefix) /* prefix function */ - __P((const DBT *, const DBT *)); - int lorder; /* byte order */ -} BTREEINFO; - -#define HASHMAGIC 0x061561 -#define HASHVERSION 2 - -/* Structure used to pass parameters to the hashing routines. */ -typedef struct { - u_int bsize; /* bucket size */ - u_int ffactor; /* fill factor */ - u_int nelem; /* number of elements */ - u_int cachesize; /* bytes to cache */ - u_int32_t /* hash function */ - (*hash) __P((const void *, size_t)); - int lorder; /* byte order */ -} HASHINFO; - -/* Structure used to pass parameters to the record routines. */ -typedef struct { -#define R_FIXEDLEN 0x01 /* fixed-length records */ -#define R_NOKEY 0x02 /* key not required */ -#define R_SNAPSHOT 0x04 /* snapshot the input */ - u_long flags; - u_int cachesize; /* bytes to cache */ - u_int psize; /* page size */ - int lorder; /* byte order */ - size_t reclen; /* record length (fixed-length records) */ - u_char bval; /* delimiting byte (variable-length records */ - char *bfname; /* btree file name */ -} RECNOINFO; - -#ifdef __DBINTERFACE_PRIVATE -/* - * Little endian <==> big endian 32-bit swap macros. - * M_32_SWAP swap a memory location - * P_32_SWAP swap a referenced memory location - * P_32_COPY swap from one location to another - */ -#define M_32_SWAP(a) { \ - u_int32_t _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[3]; \ - ((char *)&a)[1] = ((char *)&_tmp)[2]; \ - ((char *)&a)[2] = ((char *)&_tmp)[1]; \ - ((char *)&a)[3] = ((char *)&_tmp)[0]; \ -} -#define P_32_SWAP(a) { \ - u_int32_t _tmp = *(u_int32_t *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[3]; \ - ((char *)a)[1] = ((char *)&_tmp)[2]; \ - ((char *)a)[2] = ((char *)&_tmp)[1]; \ - ((char *)a)[3] = ((char *)&_tmp)[0]; \ -} -#define P_32_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[3]; \ - ((char *)&(b))[1] = ((char *)&(a))[2]; \ - ((char *)&(b))[2] = ((char *)&(a))[1]; \ - ((char *)&(b))[3] = ((char *)&(a))[0]; \ -} - -/* - * Little endian <==> big endian 16-bit swap macros. - * M_16_SWAP swap a memory location - * P_16_SWAP swap a referenced memory location - * P_16_COPY swap from one location to another - */ -#define M_16_SWAP(a) { \ - u_int16_t _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[1]; \ - ((char *)&a)[1] = ((char *)&_tmp)[0]; \ -} -#define P_16_SWAP(a) { \ - u_int16_t _tmp = *(u_int16_t *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[1]; \ - ((char *)a)[1] = ((char *)&_tmp)[0]; \ -} -#define P_16_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[1]; \ - ((char *)&(b))[1] = ((char *)&(a))[0]; \ -} -#endif - -__BEGIN_DECLS -DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); - -#ifdef __DBINTERFACE_PRIVATE -DB *__bt_open __P((virt_fd_t, const FILEVTABLE *, const BTREEINFO *, int)); -DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); -DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); -void __dbpanic __P((DB *dbp)); -#endif -__END_DECLS -#endif /* !_DB_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/include/filevtable.h b/user/mpy/lib/berkeley-db-1.xx/include/filevtable.h deleted file mode 100644 index d1f3dfe..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/include/filevtable.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _BDB_FILEVTABLE_H_ -#define _BDB_FILEVTABLE_H_ - -#ifdef VIRT_FD_T_HEADER -#include VIRT_FD_T_HEADER -#endif -#include -#include - -#ifndef virt_fd_t -#define virt_fd_t int -#endif - -typedef struct FILEVTABLE { - ssize_t (*read) __P((virt_fd_t, void *, size_t)); - ssize_t (*write) __P((virt_fd_t, const void *, size_t)); - off_t (*lseek) __P((virt_fd_t, off_t, int)); - int (*fsync) __P((virt_fd_t)); -} FILEVTABLE; - -#endif /* _BDB_FILEVTABLE_H_ */ diff --git a/user/mpy/lib/berkeley-db-1.xx/include/mpool.h b/user/mpy/lib/berkeley-db-1.xx/include/mpool.h deleted file mode 100644 index 5607b49..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/include/mpool.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mpool.h 8.2 (Berkeley) 7/14/94 - */ - -#include -#include - -/* - * The memory pool scheme is a simple one. Each in-memory page is referenced - * by a bucket which is threaded in up to two of three ways. All active pages - * are threaded on a hash chain (hashed by page number) and an lru chain. - * Inactive pages are threaded on a free chain. Each reference to a memory - * pool is handed an opaque MPOOL cookie which stores all of this information. - */ -#define HASHSIZE 128 -#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) - -/* The BKT structures are the elements of the queues. */ -typedef struct _bkt { - CIRCLEQ_ENTRY(_bkt) hq; /* hash queue */ - CIRCLEQ_ENTRY(_bkt) q; /* lru queue */ - void *page; /* page */ - pgno_t pgno; /* page number */ - -#define MPOOL_DIRTY 0x01 /* page needs to be written */ -#define MPOOL_PINNED 0x02 /* page is pinned into memory */ - u_int8_t flags; /* flags */ -} BKT; - -typedef struct MPOOL { - CIRCLEQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */ - /* hash queue array */ - CIRCLEQ_HEAD(_hqh, _bkt) hqh[HASHSIZE]; - pgno_t curcache; /* current number of cached pages */ - pgno_t maxcache; /* max number of cached pages */ - pgno_t npages; /* number of pages in the file */ - u_long pagesize; /* file page size */ - virt_fd_t fd; /* virtual file descriptor */ - /* page in conversion routine */ - const FILEVTABLE *fvtable; - void (*pgin) __P((void *, pgno_t, void *)); - /* page out conversion routine */ - void (*pgout) __P((void *, pgno_t, void *)); - void *pgcookie; /* cookie for page in/out routines */ -#ifdef STATISTICS - u_long cachehit; - u_long cachemiss; - u_long pagealloc; - u_long pageflush; - u_long pageget; - u_long pagenew; - u_long pageput; - u_long pageread; - u_long pagewrite; -#endif -} MPOOL; - -__BEGIN_DECLS -MPOOL *mpool_open __P((void *, virt_fd_t, const FILEVTABLE *, pgno_t, pgno_t)); -void mpool_filter __P((MPOOL *, void (*)(void *, pgno_t, void *), - void (*)(void *, pgno_t, void *), void *)); -void *mpool_new __P((MPOOL *, pgno_t *)); -void *mpool_get __P((MPOOL *, pgno_t, u_int)); -int mpool_put __P((MPOOL *, void *, u_int)); -int mpool_sync __P((MPOOL *)); -int mpool_close __P((MPOOL *)); -#ifdef STATISTICS -void mpool_stat __P((MPOOL *)); -#endif -__END_DECLS diff --git a/user/mpy/lib/berkeley-db-1.xx/include/tags b/user/mpy/lib/berkeley-db-1.xx/include/tags deleted file mode 120000 index 7ab656b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/include/tags +++ /dev/null @@ -1 +0,0 @@ -../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc deleted file mode 100644 index d8d93f9..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/man/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/man - -# mpool.3 -MAN3+= btree.0 dbopen.0 hash.0 recno.0 -MLINKS+= dbopen.3 db.3 diff --git a/user/mpy/lib/berkeley-db-1.xx/man/btree.3 b/user/mpy/lib/berkeley-db-1.xx/man/btree.3 deleted file mode 100644 index 8284b21..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/man/btree.3 +++ /dev/null @@ -1,233 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)btree.3 8.4 (Berkeley) 8/18/94 -.\" -.TH BTREE 3 "August 18, 1994" -.\".UC 7 -.SH NAME -btree \- btree database access method -.SH SYNOPSIS -.nf -.ft B -#include -#include -.ft R -.fi -.SH DESCRIPTION -The routine -.IR dbopen -is the library interface to database files. -One of the supported file formats is btree files. -The general description of the database access methods is in -.IR dbopen (3), -this manual page describes only the btree specific information. -.PP -The btree data structure is a sorted, balanced tree structure storing -associated key/data pairs. -.PP -The btree access method specific data structure provided to -.I dbopen -is defined in the include file as follows: -.PP -typedef struct { -.RS -u_long flags; -.br -u_int cachesize; -.br -int maxkeypage; -.br -int minkeypage; -.br -u_int psize; -.br -int (*compare)(const DBT *key1, const DBT *key2); -.br -size_t (*prefix)(const DBT *key1, const DBT *key2); -.br -int lorder; -.RE -} BTREEINFO; -.PP -The elements of this structure are as follows: -.TP -flags -The flag value is specified by -.IR or 'ing -any of the following values: -.RS -.TP -R_DUP -Permit duplicate keys in the tree, i.e. permit insertion if the key to be -inserted already exists in the tree. -The default behavior, as described in -.IR dbopen (3), -is to overwrite a matching key when inserting a new key or to fail if -the R_NOOVERWRITE flag is specified. -The R_DUP flag is overridden by the R_NOOVERWRITE flag, and if the -R_NOOVERWRITE flag is specified, attempts to insert duplicate keys into -the tree will fail. -.IP -If the database contains duplicate keys, the order of retrieval of -key/data pairs is undefined if the -.I get -routine is used, however, -.I seq -routine calls with the R_CURSOR flag set will always return the logical -``first'' of any group of duplicate keys. -.RE -.TP -cachesize -A suggested maximum size (in bytes) of the memory cache. -This value is -.B only -advisory, and the access method will allocate more memory rather than fail. -Since every search examines the root page of the tree, caching the most -recently used pages substantially improves access time. -In addition, physical writes are delayed as long as possible, so a moderate -cache can reduce the number of I/O operations significantly. -Obviously, using a cache increases (but only increases) the likelihood of -corruption or lost data if the system crashes while a tree is being modified. -If -.I cachesize -is 0 (no size is specified) a default cache is used. -.TP -maxkeypage -The maximum number of keys which will be stored on any single page. -Not currently implemented. -.\" The maximum number of keys which will be stored on any single page. -.\" Because of the way the btree data structure works, -.\" .I maxkeypage -.\" must always be greater than or equal to 2. -.\" If -.\" .I maxkeypage -.\" is 0 (no maximum number of keys is specified) the page fill factor is -.\" made as large as possible (which is almost invariably what is wanted). -.TP -minkeypage -The minimum number of keys which will be stored on any single page. -This value is used to determine which keys will be stored on overflow -pages, i.e. if a key or data item is longer than the pagesize divided -by the minkeypage value, it will be stored on overflow pages instead -of in the page itself. -If -.I minkeypage -is 0 (no minimum number of keys is specified) a value of 2 is used. -.TP -psize -Page size is the size (in bytes) of the pages used for nodes in the tree. -The minimum page size is 512 bytes and the maximum page size is 64K. -If -.I psize -is 0 (no page size is specified) a page size is chosen based on the -underlying file system I/O block size. -.TP -compare -Compare is the key comparison function. -It must return an integer less than, equal to, or greater than zero if the -first key argument is considered to be respectively less than, equal to, -or greater than the second key argument. -The same comparison function must be used on a given tree every time it -is opened. -If -.I compare -is NULL (no comparison function is specified), the keys are compared -lexically, with shorter keys considered less than longer keys. -.TP -prefix -Prefix is the prefix comparison function. -If specified, this routine must return the number of bytes of the second key -argument which are necessary to determine that it is greater than the first -key argument. -If the keys are equal, the key length should be returned. -Note, the usefulness of this routine is very data dependent, but, in some -data sets can produce significantly reduced tree sizes and search times. -If -.I prefix -is NULL (no prefix function is specified), -.B and -no comparison function is specified, a default lexical comparison routine -is used. -If -.I prefix -is NULL and a comparison routine is specified, no prefix comparison is -done. -.TP -lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.I lorder -is 0 (no order is specified) the current host order is used. -.PP -If the file already exists (and the O_TRUNC flag is not specified), the -values specified for the parameters flags, lorder and psize are ignored -in favor of the values used when the tree was created. -.PP -Forward sequential scans of a tree are from the least key to the greatest. -.PP -Space freed up by deleting key/data pairs from the tree is never reclaimed, -although it is normally made available for reuse. -This means that the btree storage structure is grow-only. -The only solutions are to avoid excessive deletions, or to create a fresh -tree periodically from a scan of an existing one. -.PP -Searches, insertions, and deletions in a btree will all complete in -O lg base N where base is the average fill factor. -Often, inserting ordered data into btrees results in a low fill factor. -This implementation has been modified to make ordered insertion the best -case, resulting in a much better than normal page fill factor. -.SH ERRORS -The -.I btree -access method routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR dbopen (3). -.SH "SEE ALSO" -.IR dbopen (3), -.IR hash (3), -.IR mpool (3), -.IR recno (3) -.sp -.IR "The Ubiquitous B-tree" , -Douglas Comer, ACM Comput. Surv. 11, 2 (June 1979), 121-138. -.sp -.IR "Prefix B-trees" , -Bayer and Unterauer, ACM Transactions on Database Systems, Vol. 2, 1 -(March 1977), 11-26. -.sp -.IR "The Art of Computer Programming Vol. 3: Sorting and Searching" , -D.E. Knuth, 1968, pp 471-480. -.SH BUGS -Only big and little endian byte order is supported. diff --git a/user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 b/user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 deleted file mode 100644 index f06a4ef..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/man/dbopen.3 +++ /dev/null @@ -1,476 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94 -.\" -.TH DBOPEN 3 "January 2, 1994" -.UC 7 -.SH NAME -dbopen \- database access methods -.SH SYNOPSIS -.nf -.ft B -#include -#include -#include - -DB * -dbopen(const char *file, int flags, int mode, DBTYPE type, -.ti +5 -const void *openinfo); -.ft R -.fi -.SH DESCRIPTION -.IR Dbopen -is the library interface to database files. -The supported file formats are btree, hashed and UNIX file oriented. -The btree format is a representation of a sorted, balanced tree structure. -The hashed format is an extensible, dynamic hashing scheme. -The flat-file format is a byte stream file with fixed or variable length -records. -The formats and file format specific information are described in detail -in their respective manual pages -.IR btree (3), -.IR hash (3) -and -.IR recno (3). -.PP -Dbopen opens -.I file -for reading and/or writing. -Files never intended to be preserved on disk may be created by setting -the file parameter to NULL. -.PP -The -.I flags -and -.I mode arguments -are as specified to the -.IR open (2) -routine, however, only the O_CREAT, O_EXCL, O_EXLOCK, O_NONBLOCK, -O_RDONLY, O_RDWR, O_SHLOCK and O_TRUNC flags are meaningful. -(Note, opening a database file O_WRONLY is not possible.) -.\"Three additional options may be specified by -.\".IR or 'ing -.\"them into the -.\".I flags -.\"argument. -.\".TP -.\"DB_LOCK -.\"Do the necessary locking in the database to support concurrent access. -.\"If concurrent access isn't needed or the database is read-only this -.\"flag should not be set, as it tends to have an associated performance -.\"penalty. -.\".TP -.\"DB_SHMEM -.\"Place the underlying memory pool used by the database in shared -.\"memory. -.\"Necessary for concurrent access. -.\".TP -.\"DB_TXN -.\"Support transactions in the database. -.\"The DB_LOCK and DB_SHMEM flags must be set as well. -.PP -The -.I type -argument is of type DBTYPE (as defined in the include file) and -may be set to DB_BTREE, DB_HASH or DB_RECNO. -.PP -The -.I openinfo -argument is a pointer to an access method specific structure described -in the access method's manual page. -If -.I openinfo -is NULL, each access method will use defaults appropriate for the system -and the access method. -.PP -.I Dbopen -returns a pointer to a DB structure on success and NULL on error. -The DB structure is defined in the include file, and contains at -least the following fields: -.sp -.nf -typedef struct { -.RS -DBTYPE type; -int (*close)(const DB *db); -int (*del)(const DB *db, const DBT *key, u_int flags); -int (*fd)(const DB *db); -int (*get)(const DB *db, DBT *key, DBT *data, u_int flags); -int (*put)(const DB *db, DBT *key, const DBT *data, -.ti +5 -u_int flags); -int (*sync)(const DB *db, u_int flags); -int (*seq)(const DB *db, DBT *key, DBT *data, u_int flags); -.RE -} DB; -.fi -.PP -These elements describe a database type and a set of functions performing -various actions. -These functions take a pointer to a structure as returned by -.IR dbopen , -and sometimes one or more pointers to key/data structures and a flag value. -.TP -type -The type of the underlying access method (and file format). -.TP -close -A pointer to a routine to flush any cached information to disk, free any -allocated resources, and close the underlying file(s). -Since key/data pairs may be cached in memory, failing to sync the file -with a -.I close -or -.I sync -function may result in inconsistent or lost information. -.I Close -routines return -1 on error (setting -.IR errno ) -and 0 on success. -.TP -del -A pointer to a routine to remove key/data pairs from the database. -.IP -The parameter -.I flag -may be set to the following value: -.RS -.TP -R_CURSOR -Delete the record referenced by the cursor. -The cursor must have previously been initialized. -.RE -.IP -.I Delete -routines return -1 on error (setting -.IR errno ), -0 on success, and 1 if the specified -.I key -was not in the file. -.TP -fd -A pointer to a routine which returns a file descriptor representative -of the underlying database. -A file descriptor referencing the same file will be returned to all -processes which call -.I dbopen -with the same -.I file -name. -This file descriptor may be safely used as an argument to the -.IR fcntl (2) -and -.IR flock (2) -locking functions. -The file descriptor is not necessarily associated with any of the -underlying files used by the access method. -No file descriptor is available for in memory databases. -.I Fd -routines return -1 on error (setting -.IR errno ), -and the file descriptor on success. -.TP -get -A pointer to a routine which is the interface for keyed retrieval from -the database. -The address and length of the data associated with the specified -.I key -are returned in the structure referenced by -.IR data . -.I Get -routines return -1 on error (setting -.IR errno ), -0 on success, and 1 if the -.I key -was not in the file. -.TP -put -A pointer to a routine to store key/data pairs in the database. -.IP -The parameter -.I flag -may be set to one of the following values: -.RS -.TP -R_CURSOR -Replace the key/data pair referenced by the cursor. -The cursor must have previously been initialized. -.TP -R_IAFTER -Append the data immediately after the data referenced by -.IR key , -creating a new key/data pair. -The record number of the appended key/data pair is returned in the -.I key -structure. -(Applicable only to the DB_RECNO access method.) -.TP -R_IBEFORE -Insert the data immediately before the data referenced by -.IR key , -creating a new key/data pair. -The record number of the inserted key/data pair is returned in the -.I key -structure. -(Applicable only to the DB_RECNO access method.) -.TP -R_NOOVERWRITE -Enter the new key/data pair only if the key does not previously exist. -.TP -R_SETCURSOR -Store the key/data pair, setting or initializing the position of the -cursor to reference it. -(Applicable only to the DB_BTREE and DB_RECNO access methods.) -.RE -.IP -R_SETCURSOR is available only for the DB_BTREE and DB_RECNO access -methods because it implies that the keys have an inherent order -which does not change. -.IP -R_IAFTER and R_IBEFORE are available only for the DB_RECNO -access method because they each imply that the access method is able to -create new keys. -This is only true if the keys are ordered and independent, record numbers -for example. -.IP -The default behavior of the -.I put -routines is to enter the new key/data pair, replacing any previously -existing key. -.IP -.I Put -routines return -1 on error (setting -.IR errno ), -0 on success, and 1 if the R_NOOVERWRITE -.I flag -was set and the key already exists in the file. -.TP -seq -A pointer to a routine which is the interface for sequential -retrieval from the database. -The address and length of the key are returned in the structure -referenced by -.IR key , -and the address and length of the data are returned in the -structure referenced -by -.IR data . -.IP -Sequential key/data pair retrieval may begin at any time, and the -position of the ``cursor'' is not affected by calls to the -.IR del , -.IR get , -.IR put , -or -.I sync -routines. -Modifications to the database during a sequential scan will be reflected -in the scan, i.e. records inserted behind the cursor will not be returned -while records inserted in front of the cursor will be returned. -.IP -The flag value -.B must -be set to one of the following values: -.RS -.TP -R_CURSOR -The data associated with the specified key is returned. -This differs from the -.I get -routines in that it sets or initializes the cursor to the location of -the key as well. -(Note, for the DB_BTREE access method, the returned key is not necessarily an -exact match for the specified key. -The returned key is the smallest key greater than or equal to the specified -key, permitting partial key matches and range searches.) -.TP -R_FIRST -The first key/data pair of the database is returned, and the cursor -is set or initialized to reference it. -.TP -R_LAST -The last key/data pair of the database is returned, and the cursor -is set or initialized to reference it. -(Applicable only to the DB_BTREE and DB_RECNO access methods.) -.TP -R_NEXT -Retrieve the key/data pair immediately after the cursor. -If the cursor is not yet set, this is the same as the R_FIRST flag. -.TP -R_PREV -Retrieve the key/data pair immediately before the cursor. -If the cursor is not yet set, this is the same as the R_LAST flag. -(Applicable only to the DB_BTREE and DB_RECNO access methods.) -.RE -.IP -R_LAST and R_PREV are available only for the DB_BTREE and DB_RECNO -access methods because they each imply that the keys have an inherent -order which does not change. -.IP -.I Seq -routines return -1 on error (setting -.IR errno ), -0 on success and 1 if there are no key/data pairs less than or greater -than the specified or current key. -If the DB_RECNO access method is being used, and if the database file -is a character special file and no complete key/data pairs are currently -available, the -.I seq -routines return 2. -.TP -sync -A pointer to a routine to flush any cached information to disk. -If the database is in memory only, the -.I sync -routine has no effect and will always succeed. -.IP -The flag value may be set to the following value: -.RS -.TP -R_RECNOSYNC -If the DB_RECNO access method is being used, this flag causes -the sync routine to apply to the btree file which underlies the -recno file, not the recno file itself. -(See the -.I bfname -field of the -.IR recno (3) -manual page for more information.) -.RE -.IP -.I Sync -routines return -1 on error (setting -.IR errno ) -and 0 on success. -.SH "KEY/DATA PAIRS" -Access to all file types is based on key/data pairs. -Both keys and data are represented by the following data structure: -.PP -typedef struct { -.RS -void *data; -.br -size_t size; -.RE -} DBT; -.PP -The elements of the DBT structure are defined as follows: -.TP -data -A pointer to a byte string. -.TP -size -The length of the byte string. -.PP -Key and data byte strings may reference strings of essentially unlimited -length although any two of them must fit into available memory at the same -time. -It should be noted that the access methods provide no guarantees about -byte string alignment. -.SH ERRORS -The -.I dbopen -routine may fail and set -.I errno -for any of the errors specified for the library routines -.IR open (2) -and -.IR malloc (3) -or the following: -.TP -[EFTYPE] -A file is incorrectly formatted. -.TP -[EINVAL] -A parameter has been specified (hash function, pad byte etc.) that is -incompatible with the current file specification or which is not -meaningful for the function (for example, use of the cursor without -prior initialization) or there is a mismatch between the version -number of file and the software. -.PP -The -.I close -routines may fail and set -.I errno -for any of the errors specified for the library routines -.IR close (2), -.IR read (2), -.IR write (2), -.IR free (3), -or -.IR fsync (2). -.PP -The -.IR del , -.IR get , -.I put -and -.I seq -routines may fail and set -.I errno -for any of the errors specified for the library routines -.IR read (2), -.IR write (2), -.IR free (3) -or -.IR malloc (3). -.PP -The -.I fd -routines will fail and set -.I errno -to ENOENT for in memory databases. -.PP -The -.I sync -routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR fsync (2). -.SH "SEE ALSO" -.IR btree (3), -.IR hash (3), -.IR mpool (3), -.IR recno (3) -.sp -.IR "LIBTP: Portable, Modular Transactions for UNIX" , -Margo Seltzer, Michael Olson, USENIX proceedings, Winter 1992. -.SH BUGS -The typedef DBT is a mnemonic for ``data base thang'', and was used -because noone could think of a reasonable name that wasn't already used. -.PP -The file descriptor interface is a kluge and will be deleted in a -future version of the interface. -.PP -None of the access methods provide any form of concurrent access, -locking, or transactions. diff --git a/user/mpy/lib/berkeley-db-1.xx/man/hash.3 b/user/mpy/lib/berkeley-db-1.xx/man/hash.3 deleted file mode 100644 index 4367031..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/man/hash.3 +++ /dev/null @@ -1,159 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)hash.3 8.6 (Berkeley) 8/18/94 -.\" -.TH HASH 3 "August 18, 1994" -.UC 7 -.SH NAME -hash \- hash database access method -.SH SYNOPSIS -.nf -.ft B -#include -#include -.ft R -.fi -.SH DESCRIPTION -The routine -.IR dbopen -is the library interface to database files. -One of the supported file formats is hash files. -The general description of the database access methods is in -.IR dbopen (3), -this manual page describes only the hash specific information. -.PP -The hash data structure is an extensible, dynamic hashing scheme. -.PP -The access method specific data structure provided to -.I dbopen -is defined in the include file as follows: -.sp -typedef struct { -.RS -u_int bsize; -.br -u_int ffactor; -.br -u_int nelem; -.br -u_int cachesize; -.br -u_int32_t (*hash)(const void *, size_t); -.br -int lorder; -.RE -} HASHINFO; -.PP -The elements of this structure are as follows: -.TP -bsize -.I Bsize -defines the hash table bucket size, and is, by default, 256 bytes. -It may be preferable to increase the page size for disk-resident tables -and tables with large data items. -.TP -ffactor -.I Ffactor -indicates a desired density within the hash table. -It is an approximation of the number of keys allowed to accumulate in any -one bucket, determining when the hash table grows or shrinks. -The default value is 8. -.TP -nelem -.I Nelem -is an estimate of the final size of the hash table. -If not set or set too low, hash tables will expand gracefully as keys -are entered, although a slight performance degradation may be noticed. -The default value is 1. -.TP -cachesize -A suggested maximum size, in bytes, of the memory cache. -This value is -.B only -advisory, and the access method will allocate more memory rather -than fail. -.TP -hash -.I Hash -is a user defined hash function. -Since no hash function performs equally well on all possible data, the -user may find that the built-in hash function does poorly on a particular -data set. -User specified hash functions must take two arguments (a pointer to a byte -string and a length) and return a 32-bit quantity to be used as the hash -value. -.TP -lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.I lorder -is 0 (no order is specified) the current host order is used. -If the file already exists, the specified value is ignored and the -value specified when the tree was created is used. -.PP -If the file already exists (and the O_TRUNC flag is not specified), the -values specified for the parameters bsize, ffactor, lorder and nelem are -ignored and the values specified when the tree was created are used. -.PP -If a hash function is specified, -.I hash_open -will attempt to determine if the hash function specified is the same as -the one with which the database was created, and will fail if it is not. -.PP -Backward compatible interfaces to the routines described in -.IR dbm (3), -and -.IR ndbm (3) -are provided, however these interfaces are not compatible with -previous file formats. -.SH ERRORS -The -.I hash -access method routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR dbopen (3). -.SH "SEE ALSO" -.IR btree (3), -.IR dbopen (3), -.IR mpool (3), -.IR recno (3) -.sp -.IR "Dynamic Hash Tables" , -Per-Ake Larson, Communications of the ACM, April 1988. -.sp -.IR "A New Hash Package for UNIX" , -Margo Seltzer, USENIX Proceedings, Winter 1991. -.SH BUGS -Only big and little endian byte order is supported. diff --git a/user/mpy/lib/berkeley-db-1.xx/man/mpool.3 b/user/mpy/lib/berkeley-db-1.xx/man/mpool.3 deleted file mode 100644 index c17606e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/man/mpool.3 +++ /dev/null @@ -1,219 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93 -.\" -.TH MPOOL 3 "June 4, 1993" -.UC 7 -.SH NAME -mpool \- shared memory buffer pool -.SH SYNOPSIS -.nf -.ft B -#include -#include - -MPOOL * -mpool_open (DBT *key, int fd, pgno_t pagesize, pgno_t maxcache); - -void -mpool_filter (MPOOL *mp, void (*pgin)(void *, pgno_t, void *), -.ti +5 -void (*pgout)(void *, pgno_t, void *), void *pgcookie); - -void * -mpool_new (MPOOL *mp, pgno_t *pgnoaddr); - -void * -mpool_get (MPOOL *mp, pgno_t pgno, u_int flags); - -int -mpool_put (MPOOL *mp, void *pgaddr, u_int flags); - -int -mpool_sync (MPOOL *mp); - -int -mpool_close (MPOOL *mp); -.ft R -.fi -.SH DESCRIPTION -.IR Mpool -is the library interface intended to provide page oriented buffer management -of files. -The buffers may be shared between processes. -.PP -The function -.I mpool_open -initializes a memory pool. -The -.I key -argument is the byte string used to negotiate between multiple -processes wishing to share buffers. -If the file buffers are mapped in shared memory, all processes using -the same key will share the buffers. -If -.I key -is NULL, the buffers are mapped into private memory. -The -.I fd -argument is a file descriptor for the underlying file, which must be seekable. -If -.I key -is non-NULL and matches a file already being mapped, the -.I fd -argument is ignored. -.PP -The -.I pagesize -argument is the size, in bytes, of the pages into which the file is broken up. -The -.I maxcache -argument is the maximum number of pages from the underlying file to cache -at any one time. -This value is not relative to the number of processes which share a file's -buffers, but will be the largest value specified by any of the processes -sharing the file. -.PP -The -.I mpool_filter -function is intended to make transparent input and output processing of the -pages possible. -If the -.I pgin -function is specified, it is called each time a buffer is read into the memory -pool from the backing file. -If the -.I pgout -function is specified, it is called each time a buffer is written into the -backing file. -Both functions are are called with the -.I pgcookie -pointer, the page number and a pointer to the page to being read or written. -.PP -The function -.I mpool_new -takes an MPOOL pointer and an address as arguments. -If a new page can be allocated, a pointer to the page is returned and -the page number is stored into the -.I pgnoaddr -address. -Otherwise, NULL is returned and errno is set. -.PP -The function -.I mpool_get -takes a MPOOL pointer and a page number as arguments. -If the page exists, a pointer to the page is returned. -Otherwise, NULL is returned and errno is set. -The flags parameter is not currently used. -.PP -The function -.I mpool_put -unpins the page referenced by -.IR pgaddr . -.I Pgaddr -must be an address previously returned by -.I mpool_get -or -.IR mpool_new . -The flag value is specified by -.IR or 'ing -any of the following values: -.TP -MPOOL_DIRTY -The page has been modified and needs to be written to the backing file. -.PP -.I Mpool_put -returns 0 on success and -1 if an error occurs. -.PP -The function -.I mpool_sync -writes all modified pages associated with the MPOOL pointer to the -backing file. -.I Mpool_sync -returns 0 on success and -1 if an error occurs. -.PP -The -.I mpool_close -function free's up any allocated memory associated with the memory pool -cookie. -Modified pages are -.B not -written to the backing file. -.I Mpool_close -returns 0 on success and -1 if an error occurs. -.SH ERRORS -The -.I mpool_open -function may fail and set -.I errno -for any of the errors specified for the library routine -.IR malloc (3). -.PP -The -.I mpool_get -function may fail and set -.I errno -for the following: -.TP 15 -[EINVAL] -The requested record doesn't exist. -.PP -The -.I mpool_new -and -.I mpool_get -functions may fail and set -.I errno -for any of the errors specified for the library routines -.IR read (2) , -.IR write (2) , -and -.IR malloc (3). -.PP -The -.I mpool_sync -function may fail and set -.I errno -for any of the errors specified for the library routine -.IR write (2). -.PP -The -.I mpool_close -function may fail and set -.I errno -for any of the errors specified for the library routine -.IR free (3). -.SH "SEE ALSO" -.IR dbopen (3), -.IR btree (3), -.IR hash (3), -.IR recno (3) diff --git a/user/mpy/lib/berkeley-db-1.xx/man/recno.3 b/user/mpy/lib/berkeley-db-1.xx/man/recno.3 deleted file mode 100644 index 516bef0..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/man/recno.3 +++ /dev/null @@ -1,216 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)recno.3 8.5 (Berkeley) 8/18/94 -.\" -.TH RECNO 3 "August 18, 1994" -.UC 7 -.SH NAME -recno \- record number database access method -.SH SYNOPSIS -.nf -.ft B -#include -#include -.ft R -.fi -.SH DESCRIPTION -The routine -.IR dbopen -is the library interface to database files. -One of the supported file formats is record number files. -The general description of the database access methods is in -.IR dbopen (3), -this manual page describes only the recno specific information. -.PP -The record number data structure is either variable or fixed-length -records stored in a flat-file format, accessed by the logical record -number. -The existence of record number five implies the existence of records -one through four, and the deletion of record number one causes -record number five to be renumbered to record number four, as well -as the cursor, if positioned after record number one, to shift down -one record. -.PP -The recno access method specific data structure provided to -.I dbopen -is defined in the include file as follows: -.PP -typedef struct { -.RS -u_long flags; -.br -u_int cachesize; -.br -u_int psize; -.br -int lorder; -.br -size_t reclen; -.br -u_char bval; -.br -char *bfname; -.RE -} RECNOINFO; -.PP -The elements of this structure are defined as follows: -.TP -flags -The flag value is specified by -.IR or 'ing -any of the following values: -.RS -.TP -R_FIXEDLEN -The records are fixed-length, not byte delimited. -The structure element -.I reclen -specifies the length of the record, and the structure element -.I bval -is used as the pad character. -Any records, inserted into the database, that are less than -.I reclen -bytes long are automatically padded. -.TP -R_NOKEY -In the interface specified by -.IR dbopen , -the sequential record retrieval fills in both the caller's key and -data structures. -If the R_NOKEY flag is specified, the -.I cursor -routines are not required to fill in the key structure. -This permits applications to retrieve records at the end of files without -reading all of the intervening records. -.TP -R_SNAPSHOT -This flag requires that a snapshot of the file be taken when -.I dbopen -is called, instead of permitting any unmodified records to be read from -the original file. -.RE -.TP -cachesize -A suggested maximum size, in bytes, of the memory cache. -This value is -.B only -advisory, and the access method will allocate more memory rather than fail. -If -.I cachesize -is 0 (no size is specified) a default cache is used. -.TP -psize -The recno access method stores the in-memory copies of its records -in a btree. -This value is the size (in bytes) of the pages used for nodes in that tree. -If -.I psize -is 0 (no page size is specified) a page size is chosen based on the -underlying file system I/O block size. -See -.IR btree (3) -for more information. -.TP -lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.I lorder -is 0 (no order is specified) the current host order is used. -.TP -reclen -The length of a fixed-length record. -.TP -bval -The delimiting byte to be used to mark the end of a record for -variable-length records, and the pad character for fixed-length -records. -If no value is specified, newlines (``\en'') are used to mark the end -of variable-length records and fixed-length records are padded with -spaces. -.TP -bfname -The recno access method stores the in-memory copies of its records -in a btree. -If bfname is non-NULL, it specifies the name of the btree file, -as if specified as the file name for a dbopen of a btree file. -.PP -The data part of the key/data pair used by the recno access method -is the same as other access methods. -The key is different. -The -.I data -field of the key should be a pointer to a memory location of type -.IR recno_t , -as defined in the include file. -This type is normally the largest unsigned integral type available to -the implementation. -The -.I size -field of the key should be the size of that type. -.PP -Because there can be no meta-data associated with the underlying -recno access method files, any changes made to the default values -(e.g. fixed record length or byte separator value) must be explicitly -specified each time the file is opened. -.PP -In the interface specified by -.IR dbopen , -using the -.I put -interface to create a new record will cause the creation of multiple, -empty records if the record number is more than one greater than the -largest record currently in the database. -.SH ERRORS -The -.I recno -access method routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR dbopen (3) -or the following: -.TP -[EINVAL] -An attempt was made to add a record to a fixed-length database that -was too large to fit. -.SH "SEE ALSO" -.IR btree (3) -.IR dbopen (3), -.IR hash (3), -.IR mpool (3), -.sp -.IR "Document Processing in a Relational Database System" , -Michael Stonebraker, Heidi Stettner, Joseph Kalash, Antonin Guttman, -Nadene Lynn, Memorandum No. UCB/ERL M82/32, May 1982. -.SH BUGS -Only big and little endian byte order is supported. diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc deleted file mode 100644 index 93210c8..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/mpool/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/mpool - -SRCS+= mpool.c diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/README b/user/mpy/lib/berkeley-db-1.xx/mpool/README deleted file mode 100644 index 0f01fbc..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/mpool/README +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)README 8.1 (Berkeley) 6/4/93 - -These are the current memory pool routines. -They aren't ready for prime time, yet, and -the interface is expected to change. - ---keith diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c b/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c deleted file mode 100644 index 2331259..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.c +++ /dev/null @@ -1,452 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include - -#include - -#define __MPOOLINTERFACE_PRIVATE -#include - -static BKT *mpool_bkt __P((MPOOL *)); -static BKT *mpool_look __P((MPOOL *, pgno_t)); -static int mpool_write __P((MPOOL *, BKT *)); - -/* - * mpool_open -- - * Initialize a memory pool. - */ -MPOOL * -mpool_open(key, fd, fvtable, pagesize, maxcache) - void *key; - virt_fd_t fd; - const FILEVTABLE * fvtable; - pgno_t pagesize, maxcache; -{ - MPOOL *mp; - int entry; - - /* Allocate and initialize the MPOOL cookie. */ - if ((mp = (MPOOL *)calloc(1, sizeof(MPOOL))) == NULL) - return (NULL); - CIRCLEQ_INIT(&mp->lqh); - for (entry = 0; entry < HASHSIZE; ++entry) - CIRCLEQ_INIT(&mp->hqh[entry]); - mp->maxcache = maxcache; - mp->fvtable = fvtable; - off_t file_size = mp->fvtable->lseek(fd, 0, SEEK_END); - if (file_size == (off_t)-1) - return (NULL); - mp->npages = file_size / pagesize; - mp->pagesize = pagesize; - mp->fd = fd; - return (mp); -} - -/* - * mpool_filter -- - * Initialize input/output filters. - */ -void -mpool_filter(mp, pgin, pgout, pgcookie) - MPOOL *mp; - void (*pgin) __P((void *, pgno_t, void *)); - void (*pgout) __P((void *, pgno_t, void *)); - void *pgcookie; -{ - mp->pgin = pgin; - mp->pgout = pgout; - mp->pgcookie = pgcookie; -} - -/* - * mpool_new -- - * Get a new page of memory. - */ -void * -mpool_new(mp, pgnoaddr) - MPOOL *mp; - pgno_t *pgnoaddr; -{ - struct _hqh *head; - BKT *bp; - - if (mp->npages == MAX_PAGE_NUMBER) { - mpool_error("mpool_new: page allocation overflow.\n"); - abort(); - } -#ifdef STATISTICS - ++mp->pagenew; -#endif - /* - * Get a BKT from the cache. Assign a new page number, attach - * it to the head of the hash chain, the tail of the lru chain, - * and return. - */ - if ((bp = mpool_bkt(mp)) == NULL) - return (NULL); - *pgnoaddr = bp->pgno = mp->npages++; - bp->flags = MPOOL_PINNED; - - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_INSERT_HEAD(head, bp, hq); - CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); - return (bp->page); -} - -/* - * mpool_get - * Get a page. - */ -void * -mpool_get(mp, pgno, flags) - MPOOL *mp; - pgno_t pgno; - u_int flags; /* XXX not used? */ -{ - struct _hqh *head; - BKT *bp; - off_t off; - int nr; - - /* Check for attempt to retrieve a non-existent page. */ - if (pgno >= mp->npages) { - errno = EINVAL; - return (NULL); - } - -#ifdef STATISTICS - ++mp->pageget; -#endif - - /* Check for a page that is cached. */ - if ((bp = mpool_look(mp, pgno)) != NULL) { -#ifdef DEBUG - if (bp->flags & MPOOL_PINNED) { - mpool_error( - "mpool_get: page %d already pinned\n", bp->pgno); - abort(); - } -#endif - /* - * Move the page to the head of the hash chain and the tail - * of the lru chain. - */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_REMOVE(head, bp, hq); - CIRCLEQ_INSERT_HEAD(head, bp, hq); - CIRCLEQ_REMOVE(&mp->lqh, bp, q); - CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); - - /* Return a pinned page. */ - bp->flags |= MPOOL_PINNED; - return (bp->page); - } - - /* Get a page from the cache. */ - if ((bp = mpool_bkt(mp)) == NULL) - return (NULL); - - /* Read in the contents. */ -#ifdef STATISTICS - ++mp->pageread; -#endif - off = mp->pagesize * pgno; - if (mp->fvtable->lseek(mp->fd, off, SEEK_SET) != off) - return (NULL); - if ((nr = mp->fvtable->read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { - if (nr >= 0) - errno = EFTYPE; - return (NULL); - } - - /* Set the page number, pin the page. */ - bp->pgno = pgno; - bp->flags = MPOOL_PINNED; - - /* - * Add the page to the head of the hash chain and the tail - * of the lru chain. - */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_INSERT_HEAD(head, bp, hq); - CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); - - /* Run through the user's filter. */ - if (mp->pgin != NULL) - (mp->pgin)(mp->pgcookie, bp->pgno, bp->page); - - return (bp->page); -} - -/* - * mpool_put - * Return a page. - */ -int -mpool_put(mp, page, flags) - MPOOL *mp; - void *page; - u_int flags; -{ - BKT *bp; - -#ifdef STATISTICS - ++mp->pageput; -#endif - bp = (BKT *)((char *)page - sizeof(BKT)); -#ifdef DEBUG - if (!(bp->flags & MPOOL_PINNED)) { - mpool_error( - "mpool_put: page %d not pinned\n", bp->pgno); - abort(); - } -#endif - bp->flags &= ~MPOOL_PINNED; - bp->flags |= flags & MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * mpool_close - * Close the buffer pool. - */ -int -mpool_close(mp) - MPOOL *mp; -{ - BKT *bp; - - /* Free up any space allocated to the lru pages. */ - while ((bp = mp->lqh.cqh_first) != (void *)&mp->lqh) { - CIRCLEQ_REMOVE(&mp->lqh, mp->lqh.cqh_first, q); - free(bp); - } - - /* Free the MPOOL cookie. */ - free(mp); - return (RET_SUCCESS); -} - -/* - * mpool_sync - * Sync the pool to disk. - */ -int -mpool_sync(mp) - MPOOL *mp; -{ - BKT *bp; - - /* Walk the lru chain, flushing any dirty pages to disk. */ - for (bp = mp->lqh.cqh_first; - bp != (void *)&mp->lqh; bp = bp->q.cqe_next) - if (bp->flags & MPOOL_DIRTY && - mpool_write(mp, bp) == RET_ERROR) - return (RET_ERROR); - - /* Sync the file descriptor. */ - return (mp->fvtable->fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); -} - -/* - * mpool_bkt - * Get a page from the cache (or create one). - */ -static BKT * -mpool_bkt(mp) - MPOOL *mp; -{ - struct _hqh *head; - BKT *bp; - - /* If under the max cached, always create a new page. */ - if (mp->curcache < mp->maxcache) - goto new; - - /* - * If the cache is max'd out, walk the lru list for a buffer we - * can flush. If we find one, write it (if necessary) and take it - * off any lists. If we don't find anything we grow the cache anyway. - * The cache never shrinks. - */ - for (bp = mp->lqh.cqh_first; - bp != (void *)&mp->lqh; bp = bp->q.cqe_next) - if (!(bp->flags & MPOOL_PINNED)) { - /* Flush if dirty. */ - if (bp->flags & MPOOL_DIRTY && - mpool_write(mp, bp) == RET_ERROR) - return (NULL); -#ifdef STATISTICS - ++mp->pageflush; -#endif - /* Remove from the hash and lru queues. */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_REMOVE(head, bp, hq); - CIRCLEQ_REMOVE(&mp->lqh, bp, q); -#ifdef DEBUG - { void *spage; - spage = bp->page; - memset(bp, 0xff, sizeof(BKT) + mp->pagesize); - bp->page = spage; - } -#endif - return (bp); - } - -new: if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL) - return (NULL); -#ifdef STATISTICS - ++mp->pagealloc; -#endif -#if defined(DEBUG) || defined(PURIFY) - memset(bp, 0xff, sizeof(BKT) + mp->pagesize); -#endif - bp->page = (char *)bp + sizeof(BKT); - ++mp->curcache; - return (bp); -} - -/* - * mpool_write - * Write a page to disk. - */ -static int -mpool_write(mp, bp) - MPOOL *mp; - BKT *bp; -{ - off_t off; - -#ifdef STATISTICS - ++mp->pagewrite; -#endif - - /* Run through the user's filter. */ - if (mp->pgout) - (mp->pgout)(mp->pgcookie, bp->pgno, bp->page); - - off = mp->pagesize * bp->pgno; - if (mp->fvtable->lseek(mp->fd, off, SEEK_SET) != off) - return (RET_ERROR); - if (mp->fvtable->write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) - return (RET_ERROR); - - bp->flags &= ~MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * mpool_look - * Lookup a page in the cache. - */ -static BKT * -mpool_look(mp, pgno) - MPOOL *mp; - pgno_t pgno; -{ - struct _hqh *head; - BKT *bp; - - head = &mp->hqh[HASHKEY(pgno)]; - for (bp = head->cqh_first; bp != (void *)head; bp = bp->hq.cqe_next) - if (bp->pgno == pgno) { -#ifdef STATISTICS - ++mp->cachehit; -#endif - return (bp); - } -#ifdef STATISTICS - ++mp->cachemiss; -#endif - return (NULL); -} - -#ifdef STATISTICS -/* - * mpool_stat - * Print out cache statistics. - */ -void -mpool_stat(mp) - MPOOL *mp; -{ - BKT *bp; - int cnt; - char *sep; - - (void)fprintf(stderr, "%lu pages in the file\n", mp->npages); - (void)fprintf(stderr, - "page size %lu, cacheing %lu pages of %lu page max cache\n", - mp->pagesize, mp->curcache, mp->maxcache); - (void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n", - mp->pageput, mp->pageget, mp->pagenew); - (void)fprintf(stderr, "%lu page allocs, %lu page flushes\n", - mp->pagealloc, mp->pageflush); - if (mp->cachehit + mp->cachemiss) - (void)fprintf(stderr, - "%.0f%% cache hit rate (%lu hits, %lu misses)\n", - ((double)mp->cachehit / (mp->cachehit + mp->cachemiss)) - * 100, mp->cachehit, mp->cachemiss); - (void)fprintf(stderr, "%lu page reads, %lu page writes\n", - mp->pageread, mp->pagewrite); - - sep = ""; - cnt = 0; - for (bp = mp->lqh.cqh_first; - bp != (void *)&mp->lqh; bp = bp->q.cqe_next) { - (void)fprintf(stderr, "%s%d", sep, bp->pgno); - if (bp->flags & MPOOL_DIRTY) - (void)fprintf(stderr, "d"); - if (bp->flags & MPOOL_PINNED) - (void)fprintf(stderr, "P"); - if (++cnt == 10) { - sep = "\n"; - cnt = 0; - } else - sep = ", "; - - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp b/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp deleted file mode 100644 index 8c0fc27..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/mpool/mpool.libtp +++ /dev/null @@ -1,746 +0,0 @@ -/****************************************************************************** - -VERSION $Id: buf.c,v 1.26 92/01/09 09:15:26 margo Exp $ -PACKAGE: User Level Shared Memory Manager - -DESCRIPTION: - This package provides a buffer pool interface implemented as - a collection of file pages mapped into shared memory. - - Based on Mark's buffer manager - -ROUTINES: - External - buf_alloc - buf_flags - buf_get - buf_init - buf_last - buf_open - buf_pin - buf_sync - buf_unpin - Internal - bf_assign_buf - bf_fid_to_fd - bf_newbuf - bf_put_page - - -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "list.h" -#include "user.h" -#include "txn_sys.h" -#include "buf.h" -#include "semkeys.h" -#include "error.h" - -/* - we need to translate between some type of file id that the user - process passes and a file descriptor. For now, it's a nop. -*/ -#define GET_MASTER get_sem ( buf_spinlock ) -#define RELEASE_MASTER release_sem ( buf_spinlock ) - -#define LRUID *buf_lru -#define LRUP (bufhdr_table+*buf_lru) -#define MRU bufhdr_table[*buf_lru].lru.prev - -/* Global indicator that you have started reusing buffers */ -int do_statistics = 0; -/* - Process Statics (pointers into shared memory) -*/ -static BUF_T *buf_table = 0; -static BUFHDR_T *bufhdr_table; -static int *buf_hash_table; -static int *buf_lru; /* LRU is the free list */ -static int buf_spinlock; -static FINFO_T *buf_fids; -static int *buf_sp; /* Pointer to string free space */ -static char *buf_strings; - -/* Process Local FID->FD table */ -static int fds[NUM_FILE_ENTRIES]; - -/* Static routines */ -static BUFHDR_T *bf_assign_buf(); -static int bf_fid_to_fd(); -static BUFHDR_T *bf_newbuf(); -static int bf_put_page(); - -/* - Return 0 on success - 1 on failure -*/ -extern int -buf_init ( ) -{ - ADDR_T buf_region; - BUFHDR_T *bhp; - int i; - int ref_count; - int *spinlockp; - - /* - Initialize Process local structures - */ - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - fds[i] = -1; - } - - buf_region = attach_region ( BUF_REGION_NAME, BUF_REGION_NUM, - BUF_REGION_SIZE, &ref_count ); - if ( !buf_region ) { - return (1); - } - error_log3 ( "Buf Region: ADDR: %d ID: %d SIZE: %d\n", buf_region, - BUF_REGION_NUM, BUF_REGION_SIZE ); - - buf_table = (BUF_T *)buf_region; - bufhdr_table = (BUFHDR_T *)(buf_table + NUM_BUFS); - buf_hash_table = (int *)(bufhdr_table + NUM_BUFS); - buf_lru = buf_hash_table + NUMTABLE_ENTRIES; - spinlockp = buf_lru + 1; - buf_fids = (FINFO_T *)(spinlockp+1); - buf_sp = (int *)(buf_fids + NUM_FILE_ENTRIES); - buf_strings = (char *)(buf_sp + 1); - - /* Create locking spinlock (gets creating holding the lock) */ - buf_spinlock = create_sem ( BUF_SPIN_NAME, BUF_SPIN_NUM, ref_count <= 1 ); - if ( buf_spinlock < 0 ) { - return(1); - } - if ( ref_count <= 1 ) { - *spinlockp = buf_spinlock; - - /* Now initialize the buffer manager */ - - /* 1. Free list */ - *buf_lru = 0; - - /* 2. Buffer headers */ - for ( i = 0, bhp = bufhdr_table; i < NUM_BUFS; bhp++, i++ ) { - bhp->lru.next = i+1; - bhp->lru.prev = i-1; - bhp->flags = 0; /* All Flags off */ - bhp->refcount = 0; - bhp->wait_proc = -1; /* No sleepers */ - LISTPE_INIT ( hash, bhp, i ); /* Hash chains */ - } - bufhdr_table[0].lru.prev = NUM_BUFS-1; - bufhdr_table[NUM_BUFS-1].lru.next = 0; - - /* 3. Hash Table */ - for ( i = 0; i < NUMTABLE_ENTRIES; i++ ) { - buf_hash_table[i] = NUM_BUFS; - } - - /* 4. File ID Table */ - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - buf_fids[i].offset = -1; - buf_fids[i].npages = -1; - buf_fids[i].refcount = 0; - } - - /* 5. Free String Pointer */ - *buf_sp = (FILE_NAME_LEN*NUM_FILE_ENTRIES); - if (RELEASE_MASTER) { - return(1); - } - error_log0 ( "Initialized buffer region\n" ); - } - return (0); -} - -extern void -buf_exit() -{ - int ref; - int i; - - /* Flush Buffer Pool on Exit */ - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - if ( fds[i] != -1 ) { - close ( fds[i] ); - } - } - if ( buf_table ) { - detach_region ( buf_table, BUF_REGION_NUM, BUF_REGION_SIZE, &ref ); - } - return; -} - -/* - We need an empty buffer. Find the LRU unpinned NON-Dirty page. -*/ -static BUFHDR_T * -bf_newbuf() -{ - int fd; - int lruid; - int nbytes; - int ndx; - BUFHDR_T *bhp; - - lruid = LRUID; - for ( bhp = LRUP; - bhp->flags & (BUF_PINNED|BUF_IO_IN_PROGRESS); - bhp = LISTP_NEXTP (bufhdr_table, lru, bhp ) ) { - - if ( bhp->lru.next == lruid ) { - /* OUT OF BUFFERS */ - error_log1 ( "All buffers are pinned. %s\n", - "Unable to grant buffer request" ); - return(NULL); - } - } - /* BHP can be used */ - if ( bhp->flags & BUF_DIRTY ) { - do_statistics = 1; - /* - MIS Check for log flushed appropriately - */ - fd = bf_fid_to_fd(bhp->id.file_id); - if ( fd == -1 ) { - error_log1 ("Invalid fid %d\n", bhp->id.file_id); - return(NULL); - } - if ( bf_put_page(fd, bhp) < 0 ) { - return(NULL); - } - } - /* Update Hash Pointers */ - ndx = BUF_HASH ( bhp->id.file_id, bhp->id.obj_id ); - LISTP_REMOVE(bufhdr_table, hash, bhp); - if ( buf_hash_table[ndx] == (bhp-bufhdr_table) ) { - if ( bhp->hash.next != (bhp-bufhdr_table) ) { - buf_hash_table[ndx] = bhp->hash.next; - } else { - buf_hash_table[ndx] = NUM_BUFS; - } - } - INIT_BUF(bhp); - - return(bhp); -} -/* - buf_alloc - - Add a page to a file and return a buffer for it. - -*/ -ADDR_T -buf_alloc ( fid, new_pageno ) -int fid; -int *new_pageno; -{ - BUFHDR_T *bhp; - int fd; - int len; - int ndx; - OBJ_T fobj; - - if (GET_MASTER) { - return(NULL); - } - if ( buf_fids[fid].npages == -1 ) { - /* initialize npages field */ - fd = bf_fid_to_fd ( fid ); - } - assert (fid < NUM_FILE_ENTRIES); - - *new_pageno = buf_fids[fid].npages; - if ( *new_pageno == -1 ) { - RELEASE_MASTER; - return ( NULL ); - } - buf_fids[fid].npages++; - ndx = BUF_HASH ( fid, *new_pageno ); - fobj.file_id = fid; - fobj.obj_id = *new_pageno; - bhp = bf_assign_buf ( ndx, &fobj, BF_PIN|BF_DIRTY|BF_EMPTY, &len ); - if ( RELEASE_MASTER ) { - /* Memory leak */ - return(NULL); - } - if ( bhp ) { - return ((ADDR_T)(buf_table+(bhp-bufhdr_table))); - } else { - return ( NULL ); - } -} - - -/* - Buffer Flags - BF_DIRTY Mark page as dirty - BF_EMPTY Don't initialize page, just get buffer - BF_PIN Retrieve with pin - -MIS -Might want to add a flag that sets an LSN for this buffer is the -DIRTY flag is set - -Eventually, you may want a flag that indicates the I/O and lock -request should be shipped off together, but not for now. -*/ -extern ADDR_T -buf_get ( file_id, page_id, flags, len ) -int file_id; -int page_id; -u_long flags; -int *len; /* Number of bytes read into buffer */ -{ - BUFHDR_T *bhp; - int bufid; - int fd; - int ndx; - int next_bufid; - int stat; - OBJ_T fobj; - - ndx = BUF_HASH ( file_id, page_id ); - fobj.file_id = (long) file_id; - fobj.obj_id = (long) page_id; - if ( GET_MASTER ) { - return(NULL); - } - /* - This could be a for loop, but we lose speed - by making all the cases general purpose so we - optimize for the no-collision case. - */ - bufid = buf_hash_table[ndx]; - if ( bufid < NUM_BUFS ) { - for ( bhp = bufhdr_table+bufid; - !OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID); - bhp = LISTP_NEXTP ( bufhdr_table, hash, bhp ) ) { - - if ( bhp->hash.next == bufid ) { - goto not_found; - } - } -/* found */ - if ( flags & BF_PIN ) { - bhp->flags |= BUF_PINNED; - bhp->refcount++; -#ifdef PIN_DEBUG - fprintf(stderr, "buf_get: %X PINNED (%d)\n", - buf_table + (bhp-bufhdr_table), bhp->refcount); -#endif - } - if ( flags & BF_DIRTY ) { - bhp->flags |= BUF_DIRTY; - } - - while ( bhp->flags & BUF_IO_IN_PROGRESS ) { - /* MIS -- eventually err check here */ -#ifdef DEBUG - printf("About to sleep on %d (me: %d\n)\n", bhp->wait_proc, - my_txnp - txn_table); -#endif -#ifdef WAIT_STATS - buf_waits++; -#endif - stat = proc_sleep_on ( &(bhp->wait_proc), buf_spinlock ); - if ( stat ) { - /* Memory leak */ - return(NULL); - } - if (!( bhp->flags & BUF_IO_IN_PROGRESS) && - (!OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID))) { - if (RELEASE_MASTER) - return(NULL); - return(buf_get ( file_id, page_id, flags, len )); - } - } - MAKE_MRU( bhp ); - *len = BUFSIZE; - } else { -not_found: - /* If you get here, the page isn't in the hash table */ - bhp = bf_assign_buf ( ndx, &fobj, flags, len ); - } - /* Common code between found and not found */ - - if ( bhp && bhp->flags & BUF_NEWPAGE ) { - *len = 0; - } - if (RELEASE_MASTER){ - /* Memory leak */ - return(NULL); - } - if ( bhp ) { - return ((ADDR_T)(buf_table+(bhp-bufhdr_table))); - } else { - return ( NULL ); - } -} - -/* - MIS - do I want to add file links to buffer pool? -*/ -extern int -buf_sync ( fid, close ) -int fid; -int close; /* should we dec refcount and possibly - invalidate all the buffers */ -{ - int i; - int fd; - int invalidate; - BUFHDR_T *bhp; - - if ( (fd = bf_fid_to_fd ( fid )) < 0 ) { - return(1); - } - if (GET_MASTER) { - return(1); - } - invalidate = (buf_fids[fid].refcount == 1 && close); - if ( invalidate ) - for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) { - if (bhp->id.file_id == fid) { - if ((bhp->flags & BF_DIRTY) && (bf_put_page( fd, bhp ) < 0)) { - return(1); - } - bhp->id.file_id = -1; - } - } - if (invalidate || close) - buf_fids[fid].refcount--; - - if (RELEASE_MASTER) { - return(1); - } - return(0); - - -} - -extern int -buf_flags ( addr, set_flags, unset_flags ) -ADDR_T addr; -u_long set_flags; -u_long unset_flags; -{ - int bufid; - BUFHDR_T *bhp; - -#ifdef PIN_DEBUG - fprintf(stderr, "buf_flags: %X setting %s%s%s%s%s releasing %s%s%s%s%s\n", - addr, - set_flags&BUF_DIRTY ? "DIRTY " : "", - set_flags&BUF_VALID ? "VALID " : "", - set_flags&BUF_PINNED ? "PINNED " : "", - set_flags&BUF_IO_ERROR ? "IO_ERROR " : "", - set_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", - set_flags&BUF_NEWPAGE ? "NEWPAGE " : "", - unset_flags&BUF_DIRTY ? "DIRTY " : "", - unset_flags&BUF_VALID ? "VALID " : "", - unset_flags&BUF_PINNED ? "PINNED " : "", - unset_flags&BUF_IO_ERROR ? "IO_ERROR " : "", - unset_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", - unset_flags&BUF_NEWPAGE ? "NEWPAGE " : "" ); -#endif - if (!ADDR_OK(addr)) { - error_log1 ( "buf_pin: Invalid Buffer Address %x\n", addr ); - return(1); - } - bufid = ((BUF_T *)addr) - buf_table; - assert ( bufid < NUM_BUFS); - bhp = &bufhdr_table[bufid]; - if (GET_MASTER) { - return(1); - } - bhp->flags |= set_flags; - if ( set_flags & BUF_PINNED ) { - bhp->refcount++; - } - if ( set_flags & BUF_DIRTY ) { - unset_flags |= BUF_NEWPAGE; - } - - if ( unset_flags & BUF_PINNED ) { - bhp->refcount--; - if ( bhp->refcount ) { - /* Turn off pin bit so it doesn't get unset */ - unset_flags &= ~BUF_PINNED; - } - } - bhp->flags &= ~unset_flags; - MAKE_MRU(bhp); - if (RELEASE_MASTER) { - return(1); - } - return(0); -} - -/* - Take a string name and produce an fid. - - returns -1 on error - - MIS -- this is a potential problem -- you keep actual names - here -- what if people run from different directories? -*/ -extern int -buf_name_lookup ( fname ) -char *fname; -{ - int i; - int fid; - int ndx; - - fid = -1; - if (GET_MASTER) { - return(-1); - } - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - if ( buf_fids[i].offset == -1 ) { - fid = i; - } else { - if (!strcmp (fname, buf_strings+buf_fids[i].offset)) { - if (RELEASE_MASTER) { - return(-1); - } - buf_fids[i].refcount++; - return(i); - } - } - } - if ( fid == -1 ) { - error_log0 ( "No more file ID's\n" ); - } else { - ndx = *buf_sp - strlen(fname) - 1; - if ( ndx < 0 ) { - error_log0 ( "Out of string space\n" ); - fid = -1; - } else { - *buf_sp = ndx; - strcpy ( buf_strings+ndx, fname ); - buf_fids[fid].offset = ndx; - } - buf_fids[fid].refcount = 1; - } - if (RELEASE_MASTER) { - return(-1); - } - return(fid); -} - -static int -bf_fid_to_fd ( fid ) -int fid; -{ - struct stat sbuf; - - assert ( (fid < NUM_FILE_ENTRIES) && (buf_fids[fid].offset != -1) ); - if ( fds[fid] != -1 ) { - return(fds[fid]); - - } - fds[fid] = open ( buf_strings+buf_fids[fid].offset, O_RDWR|O_CREAT, - 0666 ); - if ( fds[fid] < 0 ) { - error_log3 ( "Error Opening File %s FID: %d FD: %d. Errno = %d\n", - buf_strings+buf_fids[fid].offset, fid, fds[fid], - errno ); - return(-1); - } - error_log3 ( "Opening File %s FID: %d FD: %d\n", - buf_strings+buf_fids[fid].offset, fid, fds[fid] ); - if ( buf_fids[fid].npages == -1 ) { - /* Initialize the npages field */ - if ( fstat ( fds[fid], &sbuf ) ) { - error_log3 ( "Error Fstating %s FID: %d. Errno = %d\n", - buf_strings+buf_fids[fid].offset, fid, errno ); - } else { - buf_fids[fid].npages = ( sbuf.st_size / BUFSIZE ); - } - } - - return ( fds[fid] ); -} - -static int -bf_put_page ( fd, bhp ) -int fd; -BUFHDR_T *bhp; -{ - int nbytes; - - assert ( (bhp-bufhdr_table) < NUM_BUFS ); - if ( lseek ( fd, bhp->id.obj_id << BUFSHIFT, L_SET ) < 0 ) { - return(-1); - } - bhp->flags |= BUF_IO_IN_PROGRESS; - if (RELEASE_MASTER) { - return(-1); - } - nbytes = write(fd, buf_table[bhp-bufhdr_table], BUFSIZE); - if (GET_MASTER) { - return(-2); - } - if ( nbytes < 0 ) { - error_log1 ("Write failed with error code %d\n", errno); - return(-1); - } else if ( nbytes != BUFSIZE ) { - error_log1 ("Short write: %d bytes of %d\n", nbytes, BUFSIZE ); - } - bhp->flags &= ~(BUF_DIRTY|BUF_IO_IN_PROGRESS); - return (0); -} - -static BUFHDR_T * -bf_assign_buf ( ndx, obj, flags, len ) -int ndx; -OBJ_T *obj; -u_long flags; -int *len; /* Number of bytes read */ -{ - BUFHDR_T *bhp; - int fd; - - assert ( obj->file_id < NUM_FILE_ENTRIES ); - bhp = bf_newbuf(); - if ( !bhp ) { - return(NULL); - } - OBJ_ASSIGN ( (*obj), bhp->id ); - if ( buf_hash_table[ndx] >= NUM_BUFS ) { - buf_hash_table[ndx] = bhp-bufhdr_table; - } else { - LISTPE_INSERT ( bufhdr_table, hash, bhp, buf_hash_table[ndx] ); - } - - bhp->flags |= BUF_VALID; - if ( flags & BF_PIN ) { - bhp->flags |= BUF_PINNED; - bhp->refcount++; -#ifdef PIN_DEBUG - fprintf(stderr, "bf_assign_buf: %X PINNED (%d)\n", - buf_table + (bhp-bufhdr_table), bhp->refcount); -#endif - } - fd = bf_fid_to_fd(obj->file_id); - if ( fd == -1 ) { - error_log1 ("Invalid fid %d\n", obj->file_id); - bhp->flags |= ~BUF_IO_ERROR; - return(NULL); - } - if ( obj->obj_id >= buf_fids[obj->file_id].npages) { - buf_fids[obj->file_id].npages = obj->obj_id+1; - *len = 0; - } else if ( flags & BF_EMPTY ) { - *len = 0; - } else { - bhp->flags |= BUF_IO_IN_PROGRESS; - if (RELEASE_MASTER) { - return(NULL); - } - if ( lseek ( fd, obj->obj_id << BUFSHIFT, L_SET ) < -1 ) { - error_log2 ("Unable to perform seek on file: %d to page %d", - obj->file_id, obj->obj_id ); - bhp->flags &= ~BUF_IO_IN_PROGRESS; - bhp->flags |= ~BUF_IO_ERROR; - return(NULL); - } - *len = read(fd, buf_table[bhp-bufhdr_table], BUFSIZE); - if ( *len < 0 ) { - error_log2 ("Unable to perform read on file: %d to page %d", - obj->file_id, obj->obj_id ); - bhp->flags &= ~BUF_IO_IN_PROGRESS; - bhp->flags |= ~BUF_IO_ERROR; - return(NULL); - } - if (GET_MASTER) { - return(NULL); - } - bhp->flags &= ~BUF_IO_IN_PROGRESS; - if ( bhp->wait_proc != -1 ) { - /* wake up waiter and anyone waiting on it */ -#ifdef DEBUG - printf("Waking transaction %d due to completed I/O\n", - bhp->wait_proc); -#endif - proc_wake_id ( bhp->wait_proc ); - bhp->wait_proc = -1; - } - MAKE_MRU(bhp); - } - - if ( flags & BF_DIRTY ) { - bhp->flags |= BUF_DIRTY; - } else if ( *len < BUFSIZE ) { - bhp->flags |= BUF_NEWPAGE; - } - return ( bhp ); -} - -int -buf_last ( fid ) -int fid; -{ - int val; - - if (GET_MASTER) { - return(-1); - } - assert ( fid < NUM_FILE_ENTRIES ); - if ( buf_fids[fid].npages == -1 ) { - /* initialize npages field */ - (void) bf_fid_to_fd ( fid ); - } - val = buf_fids[fid].npages; - if ( val ) { - val--; /* Convert to page number */ - } - if (RELEASE_MASTER) { - return(-1); - } - return(val); -} - -#ifdef DEBUG -extern void -buf_dump ( id, all ) -int id; -int all; -{ - int i; - BUFHDR_T *bhp; - - printf ( "LRU + %d\n", *buf_lru ); - if ( all ) { - printf("ID\tFID\tPID\tLNEXT\tLPREV\tHNEXT\tHPREV\tSLEEP\tFLAG\tREFS\n"); - for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) { - printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i, - bhp->id.file_id, bhp->id.obj_id, - bhp->lru.next, bhp->lru.prev, - bhp->hash.next, bhp->hash.prev, - bhp->wait_proc, bhp->flags, bhp->refcount ); - } - } else { - if ( id >= NUM_BUFS ) { - printf ( "Buffer ID (%d) too high\n", id ); - return; - } - bhp = bufhdr_table+id; - printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i, - bhp->id.file_id, bhp->id.obj_id, - bhp->lru.next, bhp->lru.prev, - bhp->hash.next, bhp->hash.prev, - bhp->wait_proc, bhp->flags, bhp->refcount ); - } - return; -} -#endif - diff --git a/user/mpy/lib/berkeley-db-1.xx/mpool/tags b/user/mpy/lib/berkeley-db-1.xx/mpool/tags deleted file mode 120000 index 7ab656b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/mpool/tags +++ /dev/null @@ -1 +0,0 @@ -../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc b/user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc deleted file mode 100644 index e49e225..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/recno - -SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c rec_search.c \ - rec_seq.c rec_utils.c diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/extern.h b/user/mpy/lib/berkeley-db-1.xx/recno/extern.h deleted file mode 100644 index feed434..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/extern.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.3 (Berkeley) 6/4/94 - */ - -#include "../btree/extern.h" - -int __rec_close __P((DB *)); -int __rec_delete __P((const DB *, const DBT *, u_int)); -int __rec_dleaf __P((BTREE *, PAGE *, u_int32_t)); -int __rec_fd __P((const DB *)); -int __rec_fmap __P((BTREE *, recno_t)); -int __rec_fout __P((BTREE *)); -int __rec_fpipe __P((BTREE *, recno_t)); -int __rec_get __P((const DB *, const DBT *, DBT *, u_int)); -int __rec_iput __P((BTREE *, recno_t, const DBT *, u_int)); -int __rec_put __P((const DB *dbp, DBT *, const DBT *, u_int)); -int __rec_ret __P((BTREE *, EPG *, recno_t, DBT *, DBT *)); -EPG *__rec_search __P((BTREE *, recno_t, enum SRCHOP)); -int __rec_seq __P((const DB *, DBT *, DBT *, u_int)); -int __rec_sync __P((const DB *, u_int)); -int __rec_vmap __P((BTREE *, recno_t)); -int __rec_vout __P((BTREE *)); -int __rec_vpipe __P((BTREE *, recno_t)); diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c deleted file mode 100644 index 16fb0b4..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_close.c +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_CLOSE -- Close a recno tree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_close(dbp) - DB *dbp; -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (__rec_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - /* Committed to closing. */ - status = RET_SUCCESS; - if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize)) - status = RET_ERROR; - - if (!F_ISSET(t, R_INMEM)) - if (F_ISSET(t, R_CLOSEFP)) { - if (fclose(t->bt_rfp)) - status = RET_ERROR; - } else - if (close(t->bt_rfd)) - status = RET_ERROR; - - if (__bt_close(dbp) == RET_ERROR) - status = RET_ERROR; - - return (status); -} - -/* - * __REC_SYNC -- sync the recno tree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_sync(dbp, flags) - const DB *dbp; - u_int flags; -{ - struct iovec iov[2]; - BTREE *t; - DBT data, key; - off_t off; - recno_t scursor, trec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (flags == R_RECNOSYNC) - return (__bt_sync(dbp, 0)); - - if (F_ISSET(t, R_RDONLY | R_INMEM) || !F_ISSET(t, R_MODIFIED)) - return (RET_SUCCESS); - - /* Read any remaining records into the tree. */ - if (!F_ISSET(t, R_EOF) && t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - - /* Rewind the file descriptor. */ - if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0) - return (RET_ERROR); - - /* Save the cursor. */ - scursor = t->bt_cursor.rcursor; - - key.size = sizeof(recno_t); - key.data = &trec; - - if (F_ISSET(t, R_FIXLEN)) { - /* - * We assume that fixed length records are all fixed length. - * Any that aren't are either EINVAL'd or corrected by the - * record put code. - */ - status = (dbp->seq)(dbp, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - if (write(t->bt_rfd, data.data, data.size) != data.size) - return (RET_ERROR); - status = (dbp->seq)(dbp, &key, &data, R_NEXT); - } - } else { - iov[1].iov_base = &t->bt_bval; - iov[1].iov_len = 1; - - status = (dbp->seq)(dbp, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - iov[0].iov_base = data.data; - iov[0].iov_len = data.size; - if (writev(t->bt_rfd, iov, 2) != data.size + 1) - return (RET_ERROR); - status = (dbp->seq)(dbp, &key, &data, R_NEXT); - } - } - - /* Restore the cursor. */ - t->bt_cursor.rcursor = scursor; - - if (status == RET_ERROR) - return (RET_ERROR); - if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1) - return (RET_ERROR); - if (ftruncate(t->bt_rfd, off)) - return (RET_ERROR); - F_CLR(t, R_MODIFIED); - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c deleted file mode 100644 index a16593d..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_delete.c +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_delete.c 8.7 (Berkeley) 7/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "recno.h" - -static int rec_rdelete __P((BTREE *, recno_t)); - -/* - * __REC_DELETE -- Delete the item(s) referenced by a key. - * - * Parameters: - * dbp: pointer to access method - * key: key to delete - * flags: R_CURSOR if deleting what the cursor references - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__rec_delete(dbp, key, flags) - const DB *dbp; - const DBT *key; - u_int flags; -{ - BTREE *t; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch(flags) { - case 0: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec > t->bt_nrecs) - return (RET_SPECIAL); - --nrec; - status = rec_rdelete(t, nrec); - break; - case R_CURSOR: - if (!F_ISSET(&t->bt_cursor, CURS_INIT)) - goto einval; - if (t->bt_nrecs == 0) - return (RET_SPECIAL); - status = rec_rdelete(t, t->bt_cursor.rcursor - 1); - if (status == RET_SUCCESS) - --t->bt_cursor.rcursor; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) - F_SET(t, B_MODIFIED | R_MODIFIED); - return (status); -} - -/* - * REC_RDELETE -- Delete the data matching the specified key. - * - * Parameters: - * tree: tree - * nrec: record to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -rec_rdelete(t, nrec) - BTREE *t; - recno_t nrec; -{ - EPG *e; - PAGE *h; - int status; - - /* Find the record; __rec_search pins the page. */ - if ((e = __rec_search(t, nrec, SDELETE)) == NULL) - return (RET_ERROR); - - /* Delete the record. */ - h = e->page; - status = __rec_dleaf(t, h, e->index); - if (status != RET_SUCCESS) { - mpool_put(t->bt_mp, h, 0); - return (status); - } - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * __REC_DLEAF -- Delete a single record from a recno leaf page. - * - * Parameters: - * t: tree - * index: index on current page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_dleaf(t, h, index) - BTREE *t; - PAGE *h; - u_int32_t index; -{ - RLEAF *rl; - indx_t *ip, cnt, offset; - u_int32_t nbytes; - char *from; - void *to; - - /* - * Delete a record from a recno leaf page. Internal records are never - * deleted from internal pages, regardless of the records that caused - * them to be added being deleted. Pages made empty by deletion are - * not reclaimed. They are, however, made available for reuse. - * - * Pack the remaining entries at the end of the page, shift the indices - * down, overwriting the deleted record and its index. If the record - * uses overflow pages, make them available for reuse. - */ - to = rl = GETRLEAF(h, index); - if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) - return (RET_ERROR); - nbytes = NRLEAF(rl); - - /* - * Compress the key/data pairs. Compress and adjust the [BR]LEAF - * offsets. Reset the headers. - */ - from = (char *)h + h->upper; - memmove(from + nbytes, from, (char *)to - from); - h->upper += nbytes; - - offset = h->linp[index]; - for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - --t->bt_nrecs; - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c deleted file mode 100644 index 47dd773..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_get.c +++ /dev/null @@ -1,311 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_get.c 8.9 (Berkeley) 8/18/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__rec_get(dbp, key, data, flags) - const DB *dbp; - const DBT *key; - DBT *data; - u_int flags; -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags, and keys of 0 are illegal. */ - if (flags || (nrec = *(recno_t *)key->data) == 0) { - errno = EINVAL; - return (RET_ERROR); - } - - /* - * If we haven't seen this record yet, try to find it in the - * original file. - */ - if (nrec > t->bt_nrecs) { - if (F_ISSET(t, R_EOF | R_INMEM)) - return (RET_SPECIAL); - if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - } - - --nrec; - if ((e = __rec_search(t, nrec, SEARCH)) == NULL) - return (RET_ERROR); - - status = __rec_ret(t, e, 0, NULL, data); - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} - -/* - * __REC_FPIPE -- Get fixed length records from a pipe. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_fpipe(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - recno_t nrec; - size_t len; - int ch; - u_char *p; - - if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - realloc(t->bt_rdata.data, t->bt_reclen); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - t->bt_rdata.size = t->bt_reclen; - } - data.data = t->bt_rdata.data; - data.size = t->bt_reclen; - - for (nrec = t->bt_nrecs; nrec < top;) { - len = t->bt_reclen; - for (p = t->bt_rdata.data;; *p++ = ch) - if ((ch = getc(t->bt_rfp)) == EOF || !--len) { - if (ch != EOF) - *p = ch; - if (len != 0) - memset(p, t->bt_bval, len); - if (__rec_iput(t, - nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - ++nrec; - break; - } - if (ch == EOF) - break; - } - if (nrec < top) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - return (RET_SUCCESS); -} - -/* - * __REC_VPIPE -- Get variable length records from a pipe. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_vpipe(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - recno_t nrec; - indx_t len; - size_t sz; - int bval, ch; - u_char *p; - - bval = t->bt_bval; - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - for (p = t->bt_rdata.data, - sz = t->bt_rdata.size;; *p++ = ch, --sz) { - if ((ch = getc(t->bt_rfp)) == EOF || ch == bval) { - data.data = t->bt_rdata.data; - data.size = p - (u_char *)t->bt_rdata.data; - if (ch == EOF && data.size == 0) - break; - if (__rec_iput(t, nrec, &data, 0) - != RET_SUCCESS) - return (RET_ERROR); - break; - } - if (sz == 0) { - len = p - (u_char *)t->bt_rdata.data; - t->bt_rdata.size += (sz = 256); - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_rdata.size) : - realloc(t->bt_rdata.data, t->bt_rdata.size); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - p = (u_char *)t->bt_rdata.data + len; - } - } - if (ch == EOF) - break; - } - if (nrec < top) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - return (RET_SUCCESS); -} - -/* - * __REC_FMAP -- Get fixed length records from a file. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_fmap(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - recno_t nrec; - u_char *sp, *ep, *p; - size_t len; - - if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - realloc(t->bt_rdata.data, t->bt_reclen); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - t->bt_rdata.size = t->bt_reclen; - } - data.data = t->bt_rdata.data; - data.size = t->bt_reclen; - - sp = (u_char *)t->bt_cmap; - ep = (u_char *)t->bt_emap; - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - if (sp >= ep) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - len = t->bt_reclen; - for (p = t->bt_rdata.data; - sp < ep && len > 0; *p++ = *sp++, --len); - if (len != 0) - memset(p, t->bt_bval, len); - if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - } - t->bt_cmap = (caddr_t)sp; - return (RET_SUCCESS); -} - -/* - * __REC_VMAP -- Get variable length records from a file. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_vmap(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - u_char *sp, *ep; - recno_t nrec; - int bval; - - sp = (u_char *)t->bt_cmap; - ep = (u_char *)t->bt_emap; - bval = t->bt_bval; - - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - if (sp >= ep) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - for (data.data = sp; sp < ep && *sp != bval; ++sp); - data.size = sp - (u_char *)data.data; - if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - ++sp; - } - t->bt_cmap = (caddr_t)sp; - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c deleted file mode 100644 index 51d8a3c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_open.c +++ /dev/null @@ -1,241 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -DB * -__rec_open(fname, flags, mode, openinfo, dflags) - const char *fname; - int flags, mode, dflags; - const RECNOINFO *openinfo; -{ - BTREE *t; - BTREEINFO btopeninfo; - DB *dbp; - PAGE *h; - struct stat sb; - int rfd, sverrno; - - /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = open(fname, flags, mode)) < 0) - return (NULL); - - /* Create a btree in memory (backed by disk). */ - dbp = NULL; - if (openinfo) { - if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT)) - goto einval; - btopeninfo.flags = 0; - btopeninfo.cachesize = openinfo->cachesize; - btopeninfo.maxkeypage = 0; - btopeninfo.minkeypage = 0; - btopeninfo.psize = openinfo->psize; - btopeninfo.compare = NULL; - btopeninfo.prefix = NULL; - btopeninfo.lorder = openinfo->lorder; - dbp = __bt_open(openinfo->bfname, - O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags); - } else - dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags); - if (dbp == NULL) - goto err; - - /* - * Some fields in the tree structure are recno specific. Fill them - * in and make the btree structure look like a recno structure. We - * don't change the bt_ovflsize value, it's close enough and slightly - * bigger. - */ - t = dbp->internal; - if (openinfo) { - if (openinfo->flags & R_FIXEDLEN) { - F_SET(t, R_FIXLEN); - t->bt_reclen = openinfo->reclen; - if (t->bt_reclen == 0) - goto einval; - } - t->bt_bval = openinfo->bval; - } else - t->bt_bval = '\n'; - - F_SET(t, R_RECNO); - if (fname == NULL) - F_SET(t, R_EOF | R_INMEM); - else - t->bt_rfd = rfd; - - if (fname != NULL) { - /* - * In 4.4BSD, stat(2) returns true for ISSOCK on pipes. - * Unfortunately, that's not portable, so we use lseek - * and check the errno values. - */ - errno = 0; - if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, R_RDONLY); - break; - default: - goto einval; - } -slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL) - goto err; - F_SET(t, R_CLOSEFP); - t->bt_irec = - F_ISSET(t, R_FIXLEN) ? __rec_fpipe : __rec_vpipe; - } else { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, R_RDONLY); - break; - case O_RDWR: - break; - default: - goto einval; - } - - if (fstat(rfd, &sb)) - goto err; - /* - * Kluge -- we'd like to test to see if the file is too - * big to mmap. Since, we don't know what size or type - * off_t's or size_t's are, what the largest unsigned - * integral type is, or what random insanity the local - * C compiler will perpetrate, doing the comparison in - * a portable way is flatly impossible. Hope that mmap - * fails if the file is too large. - */ - if (sb.st_size == 0) - F_SET(t, R_EOF); - else { -#ifdef MMAP_NOT_AVAILABLE - /* - * XXX - * Mmap doesn't work correctly on many current - * systems. In particular, it can fail subtly, - * with cache coherency problems. Don't use it - * for now. - */ - t->bt_msize = sb.st_size; - if ((t->bt_smap = mmap(NULL, t->bt_msize, - PROT_READ, MAP_PRIVATE, rfd, - (off_t)0)) == (caddr_t)-1) - goto slow; - t->bt_cmap = t->bt_smap; - t->bt_emap = t->bt_smap + sb.st_size; - t->bt_irec = F_ISSET(t, R_FIXLEN) ? - __rec_fmap : __rec_vmap; - F_SET(t, R_MEMMAPPED); -#else - goto slow; -#endif - } - } - } - - /* Use the recno routines. */ - dbp->close = __rec_close; - dbp->del = __rec_delete; - dbp->fd = __rec_fd; - dbp->get = __rec_get; - dbp->put = __rec_put; - dbp->seq = __rec_seq; - dbp->sync = __rec_sync; - - /* If the root page was created, reset the flags. */ - if ((h = mpool_get(t->bt_mp, P_ROOT, 0)) == NULL) - goto err; - if ((h->flags & P_TYPE) == P_BLEAF) { - F_CLR(h, P_TYPE); - F_SET(h, P_RLEAF); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } else - mpool_put(t->bt_mp, h, 0); - - if (openinfo && openinfo->flags & R_SNAPSHOT && - !F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - goto err; - return (dbp); - -einval: errno = EINVAL; -err: sverrno = errno; - if (dbp != NULL) - (void)__bt_close(dbp); - if (fname != NULL) - (void)close(rfd); - errno = sverrno; - return (NULL); -} - -int -__rec_fd(dbp) - const DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* In-memory database can't have a file descriptor. */ - if (F_ISSET(t, R_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_rfd); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c deleted file mode 100644 index 1afae0d..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_put.c +++ /dev/null @@ -1,280 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_put.c 8.7 (Berkeley) 8/18/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_PUT -- Add a recno item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is - * already in the tree and R_NOOVERWRITE specified. - */ -int -__rec_put(dbp, key, data, flags) - const DB *dbp; - DBT *key; - const DBT *data; - u_int flags; -{ - BTREE *t; - DBT fdata, tdata; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If using fixed-length records, and the record is long, return - * EINVAL. If it's short, pad it out. Use the record data return - * memory, it's only short-term. - */ - if (F_ISSET(t, R_FIXLEN) && data->size != t->bt_reclen) { - if (data->size > t->bt_reclen) - goto einval; - - if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - realloc(t->bt_rdata.data, t->bt_reclen); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - t->bt_rdata.size = t->bt_reclen; - } - memmove(t->bt_rdata.data, data->data, data->size); - memset((char *)t->bt_rdata.data + data->size, - t->bt_bval, t->bt_reclen - data->size); - fdata.data = t->bt_rdata.data; - fdata.size = t->bt_reclen; - } else { - fdata.data = data->data; - fdata.size = data->size; - } - - switch (flags) { - case R_CURSOR: - if (!F_ISSET(&t->bt_cursor, CURS_INIT)) - goto einval; - nrec = t->bt_cursor.rcursor; - break; - case R_SETCURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_IAFTER: - if ((nrec = *(recno_t *)key->data) == 0) { - nrec = 1; - flags = R_IBEFORE; - } - break; - case 0: - case R_IBEFORE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NOOVERWRITE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec <= t->bt_nrecs) - return (RET_SPECIAL); - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - /* - * Make sure that records up to and including the put record are - * already in the database. If skipping records, create empty ones. - */ - if (nrec > t->bt_nrecs) { - if (!F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, nrec) == RET_ERROR) - return (RET_ERROR); - if (nrec > t->bt_nrecs + 1) { - if (F_ISSET(t, R_FIXLEN)) { - if ((tdata.data = - (void *)malloc(t->bt_reclen)) == NULL) - return (RET_ERROR); - tdata.size = t->bt_reclen; - memset(tdata.data, t->bt_bval, tdata.size); - } else { - tdata.data = NULL; - tdata.size = 0; - } - while (nrec > t->bt_nrecs + 1) - if (__rec_iput(t, - t->bt_nrecs, &tdata, 0) != RET_SUCCESS) - return (RET_ERROR); - if (F_ISSET(t, R_FIXLEN)) - free(tdata.data); - } - } - - if ((status = __rec_iput(t, nrec - 1, &fdata, flags)) != RET_SUCCESS) - return (status); - - if (flags == R_SETCURSOR) - t->bt_cursor.rcursor = nrec; - - F_SET(t, R_MODIFIED); - return (__rec_ret(t, NULL, nrec, key, NULL)); -} - -/* - * __REC_IPUT -- Add a recno item to the tree. - * - * Parameters: - * t: tree - * nrec: record number - * data: data - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_iput(t, nrec, data, flags) - BTREE *t; - recno_t nrec; - const DBT *data; - u_int flags; -{ - DBT tdata; - EPG *e; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - u_int32_t nbytes; - int dflags, status; - char *dest, db[NOVFLSIZE]; - - /* - * If the data won't fit on a page, store it on indirect pages. - * - * XXX - * If the insert fails later on, these pages aren't recovered. - */ - if (data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - *(pgno_t *)db = pg; - *(u_int32_t *)(db + sizeof(pgno_t)) = data->size; - dflags = P_BIGDATA; - data = &tdata; - } else - dflags = 0; - - /* __rec_search pins the returned page. */ - if ((e = __rec_search(t, nrec, - nrec > t->bt_nrecs || flags == R_IAFTER || flags == R_IBEFORE ? - SINSERT : SEARCH)) == NULL) - return (RET_ERROR); - - h = e->page; - index = e->index; - - /* - * Add the specified key/data pair to the tree. The R_IAFTER and - * R_IBEFORE flags insert the key after/before the specified key. - * - * Pages are split as required. - */ - switch (flags) { - case R_IAFTER: - ++index; - break; - case R_IBEFORE: - break; - default: - if (nrec < t->bt_nrecs && - __rec_dleaf(t, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, split the page. The split code will insert - * the key and data and unpin the current page. If inserting into - * the offset array, shift the pointers up. - */ - nbytes = NRLEAFDBT(data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - status = __bt_split(t, h, NULL, data, dflags, nbytes, index); - if (status == RET_SUCCESS) - ++t->bt_nrecs; - return (status); - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_RLEAF(dest, data, dflags); - - ++t->bt_nrecs; - F_SET(t, B_MODIFIED); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c deleted file mode 100644 index acc109e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_search.c +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_search.c 8.4 (Berkeley) 7/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEARCH -- Search a btree for a key. - * - * Parameters: - * t: tree to search - * recno: key to find - * op: search operation - * - * Returns: - * EPG for matching record, if any, or the EPG for the location of the - * key, if it were inserted into the tree. - * - * Returns: - * The EPG for matching record, if any, or the EPG for the location - * of the key, if it were inserted into the tree, is entered into - * the bt_cur field of the tree. A pointer to the field is returned. - */ -EPG * -__rec_search(t, recno, op) - BTREE *t; - recno_t recno; - enum SRCHOP op; -{ - register indx_t index; - register PAGE *h; - EPGNO *parent; - RINTERNAL *r; - pgno_t pg; - indx_t top; - recno_t total; - int sverrno; - - BT_CLR(t); - for (pg = P_ROOT, total = 0;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - goto err; - if (h->flags & P_RLEAF) { - t->bt_cur.page = h; - t->bt_cur.index = recno - total; - return (&t->bt_cur); - } - for (index = 0, top = NEXTINDEX(h);;) { - r = GETRINTERNAL(h, index); - if (++index == top || total + r->nrecs > recno) - break; - total += r->nrecs; - } - - BT_PUSH(t, pg, index - 1); - - pg = r->pgno; - switch (op) { - case SDELETE: - --GETRINTERNAL(h, (index - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SINSERT: - ++GETRINTERNAL(h, (index - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SEARCH: - mpool_put(t->bt_mp, h, 0); - break; - } - - } - /* Try and recover the tree. */ -err: sverrno = errno; - if (op != SEARCH) - while ((parent = BT_POP(t)) != NULL) { - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - break; - if (op == SINSERT) - --GETRINTERNAL(h, parent->index)->nrecs; - else - ++GETRINTERNAL(h, parent->index)->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } - errno = sverrno; - return (NULL); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c deleted file mode 100644 index f80992c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_seq.c +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)rec_seq.c 8.3 (Berkeley) 7/14/94"; -#endif /* not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEQ -- Recno sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__rec_seq(dbp, key, data, flags) - const DB *dbp; - DBT *key, *data; - u_int flags; -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch(flags) { - case R_CURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NEXT: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - nrec = t->bt_cursor.rcursor + 1; - break; - } - /* FALLTHROUGH */ - case R_FIRST: - nrec = 1; - break; - case R_PREV: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - if ((nrec = t->bt_cursor.rcursor - 1) == 0) - return (RET_SPECIAL); - break; - } - /* FALLTHROUGH */ - case R_LAST: - if (!F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - nrec = t->bt_nrecs; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { - if (!F_ISSET(t, R_EOF | R_INMEM) && - (status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) - return (RET_SPECIAL); - } - - if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) - return (RET_ERROR); - - F_SET(&t->bt_cursor, CURS_INIT); - t->bt_cursor.rcursor = nrec; - - status = __rec_ret(t, e, nrec, key, data); - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c b/user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c deleted file mode 100644 index baea3fa..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/rec_utils.c +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_utils.c 8.6 (Berkeley) 7/16/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "recno.h" - -/* - * __rec_ret -- - * Build return data. - * - * Parameters: - * t: tree - * e: key/data pair to be returned - * nrec: record number - * key: user's key structure - * data: user's data structure - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_ret(t, e, nrec, key, data) - BTREE *t; - EPG *e; - recno_t nrec; - DBT *key, *data; -{ - RLEAF *rl; - void *p; - - if (key == NULL) - goto dataonly; - - /* We have to copy the key, it's not on the page. */ - if (sizeof(recno_t) > t->bt_rkey.size) { - p = (void *)(t->bt_rkey.data == NULL ? - malloc(sizeof(recno_t)) : - realloc(t->bt_rkey.data, sizeof(recno_t))); - if (p == NULL) - return (RET_ERROR); - t->bt_rkey.data = p; - t->bt_rkey.size = sizeof(recno_t); - } - memmove(t->bt_rkey.data, &nrec, sizeof(recno_t)); - key->size = sizeof(recno_t); - key->data = t->bt_rkey.data; - -dataonly: - if (data == NULL) - return (RET_SUCCESS); - - /* - * We must copy big keys/data to make them contigous. Otherwise, - * leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - rl = GETRLEAF(e->page, e->index); - if (rl->flags & P_BIGDATA) { - if (__ovfl_get(t, rl->bytes, - &data->size, &t->bt_rdata.data, &t->bt_rdata.size)) - return (RET_ERROR); - data->data = t->bt_rdata.data; - } else if (F_ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (rl->dsize + 1 > t->bt_rdata.size) { - p = (void *)(t->bt_rdata.data == NULL ? - malloc(rl->dsize + 1) : - realloc(t->bt_rdata.data, rl->dsize + 1)); - if (p == NULL) - return (RET_ERROR); - t->bt_rdata.data = p; - t->bt_rdata.size = rl->dsize + 1; - } - memmove(t->bt_rdata.data, rl->bytes, rl->dsize); - data->size = rl->dsize; - data->data = t->bt_rdata.data; - } else { - data->size = rl->dsize; - data->data = rl->bytes; - } - return (RET_SUCCESS); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/recno.h b/user/mpy/lib/berkeley-db-1.xx/recno/recno.h deleted file mode 100644 index bec772c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/recno.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)recno.h 8.1 (Berkeley) 6/4/93 - */ - -enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ - -#include "../btree/btree.h" -#include "extern.h" diff --git a/user/mpy/lib/berkeley-db-1.xx/recno/tags b/user/mpy/lib/berkeley-db-1.xx/recno/tags deleted file mode 120000 index 7ab656b..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/recno/tags +++ /dev/null @@ -1 +0,0 @@ -../db/tags \ No newline at end of file diff --git a/user/mpy/lib/berkeley-db-1.xx/test/Makefile b/user/mpy/lib/berkeley-db-1.xx/test/Makefile deleted file mode 100644 index a5dd08a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# @(#)Makefile 8.15 (Berkeley) 7/28/94 - -PROG= dbtest -OBJS= dbtest.o strerror.o - -# Uncomment the STAT line get hash and btree statistical use info. This -# also forces ld to load the btree debug functions for use by gdb, which -# is useful. The db library has to be compiled with -DSTATISTICS as well. -INC= -I${PORTDIR}/include -I${PORTDIR} -OORG= -g -#STAT= -DSTATISTICS -CFLAGS= -D__DBINTERFACE_PRIVATE -DDEBUG ${STAT} ${OORG} ${INC} - -dbtest: ${OBJS} ${PORTDIR}/libdb.a - ${CC} -o $@ ${OBJS} ${PORTDIR}/libdb.a - -strerror.o: ${PORTDIR}/clib/strerror.c - ${CC} -c ${PORTDIR}/clib/strerror.c - -clean: - rm -f dbtest.core gmon.out ${OBJS} ${PROG} t1 t2 t3 - -${OBJS}: Makefile diff --git a/user/mpy/lib/berkeley-db-1.xx/test/README b/user/mpy/lib/berkeley-db-1.xx/test/README deleted file mode 100644 index 0c0cd13..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/README +++ /dev/null @@ -1,74 +0,0 @@ -# @(#)README 8.8 (Berkeley) 7/31/94 - -To build this portably, try something like: - - make PORTDIR="../PORT/MACH" - -where MACH is the machine, i.e. "sunos.4.1.1". - -To run the tests, enter "sh run.test". If your system dictionary isn't -in /usr/share/dict/words, edit run.test to reflect the correct place. - -Fairly large files (the command files) are built in this directory during -the test runs, and even larger files (the database files) are created in -"/var/tmp". If the latter directory doesn't exist, set the environmental -variable TMPDIR to a directory where the files can be built. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -The script file consists of lines with an initial character which is -the command for that line, or an initial character indicating a key -or data entry for a previous command. - -Legal command characters are as follows: - -c: compare a record - + must be followed by [kK][dD]; the data value in the database - associated with the specified key is compared to the specified - data value. -e: echo a string - + writes out the rest of the line into the output file; if the - last character is not a carriage-return, a newline is appended. -f: set the flags for the next command - + no value zero's the flags -g: do a get command - + must be followed by [kK] - + writes out the retrieved data DBT. -o [r]: dump [reverse] - + dump the database out, if 'r' is set, in reverse order. -p: do a put command - + must be followed by [kK][dD] -r: do a del command - + must be followed by [kK] unless R_CURSOR flag set. -S: sync the database -s: do a seq command - + must be followed by [kK] if R_CURSOR flag set. - + writes out the retrieved data DBT. - -Legal key/data characters are as follows: - -D [file]: data file - + set the current data value to the contents of the file -d [data]: - + set the current key value to the contents of the line. -K [file]: key file - + set the current key value to the contents of the file -k [data]: - + set the current key value to the contents of the line. - -Blank lines, lines with leading white space, and lines with leading -hash marks (#) are ignored. - -Options to dbtest are as follows: - - -d: Set the DB_LOCK flag. - -f: Use the file argument as the database file. - -i: Use the rest of the argument to set elements in the info - structure. If the type is btree, then "-i cachesize=10240" - will set BTREEINFO.cachesize to 10240. - -o: The rest of the argument is the output file instead of - using stdout. - -s: Don't delete the database file before opening it, i.e. - use the database file from a previous run. - -Dbtest requires two arguments, the type of access "hash", "recno" -or "btree", and the script name or "-" to indicate stdin. diff --git a/user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c b/user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c deleted file mode 100644 index f26e193..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/btree.tests/main.c +++ /dev/null @@ -1,765 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "btree.h" - -typedef struct cmd_table { - char *cmd; - int nargs; - int rconv; - void (*func) __P((DB *, char **)); - char *usage, *descrip; -} cmd_table; - -int stopstop; -DB *globaldb; - -void append __P((DB *, char **)); -void bstat __P((DB *, char **)); -void cursor __P((DB *, char **)); -void delcur __P((DB *, char **)); -void delete __P((DB *, char **)); -void dump __P((DB *, char **)); -void first __P((DB *, char **)); -void get __P((DB *, char **)); -void help __P((DB *, char **)); -void iafter __P((DB *, char **)); -void ibefore __P((DB *, char **)); -void icursor __P((DB *, char **)); -void insert __P((DB *, char **)); -void keydata __P((DBT *, DBT *)); -void last __P((DB *, char **)); -void list __P((DB *, char **)); -void load __P((DB *, char **)); -void mstat __P((DB *, char **)); -void next __P((DB *, char **)); -int parse __P((char *, char **, int)); -void previous __P((DB *, char **)); -void show __P((DB *, char **)); -void usage __P((void)); -void user __P((DB *)); - -cmd_table commands[] = { - "?", 0, 0, help, "help", NULL, - "a", 2, 1, append, "append key def", "append key with data def", - "b", 0, 0, bstat, "bstat", "stat btree", - "c", 1, 1, cursor, "cursor word", "move cursor to word", - "delc", 0, 0, delcur, "delcur", "delete key the cursor references", - "dele", 1, 1, delete, "delete word", "delete word", - "d", 0, 0, dump, "dump", "dump database", - "f", 0, 0, first, "first", "move cursor to first record", - "g", 1, 1, get, "get key", "locate key", - "h", 0, 0, help, "help", "print command summary", - "ia", 2, 1, iafter, "iafter key data", "insert data after key", - "ib", 2, 1, ibefore, "ibefore key data", "insert data before key", - "ic", 2, 1, icursor, "icursor key data", "replace cursor", - "in", 2, 1, insert, "insert key def", "insert key with data def", - "la", 0, 0, last, "last", "move cursor to last record", - "li", 1, 1, list, "list file", "list to a file", - "loa", 1, 0, load, "load file", NULL, - "loc", 1, 1, get, "get key", NULL, - "m", 0, 0, mstat, "mstat", "stat memory pool", - "n", 0, 0, next, "next", "move cursor forward one record", - "p", 0, 0, previous, "previous", "move cursor back one record", - "q", 0, 0, NULL, "quit", "quit", - "sh", 1, 0, show, "show page", "dump a page", - { NULL }, -}; - -int recno; /* use record numbers */ -char *dict = "words"; /* default dictionary */ -char *progname; - -int -main(argc, argv) - int argc; - char **argv; -{ - int c; - DB *db; - BTREEINFO b; - - progname = *argv; - - b.flags = 0; - b.cachesize = 0; - b.maxkeypage = 0; - b.minkeypage = 0; - b.psize = 0; - b.compare = NULL; - b.prefix = NULL; - b.lorder = 0; - - while ((c = getopt(argc, argv, "bc:di:lp:ru")) != EOF) { - switch (c) { - case 'b': - b.lorder = BIG_ENDIAN; - break; - case 'c': - b.cachesize = atoi(optarg); - break; - case 'd': - b.flags |= R_DUP; - break; - case 'i': - dict = optarg; - break; - case 'l': - b.lorder = LITTLE_ENDIAN; - break; - case 'p': - b.psize = atoi(optarg); - break; - case 'r': - recno = 1; - break; - case 'u': - b.flags = 0; - break; - default: - usage(); - } - } - argc -= optind; - argv += optind; - - if (recno) - db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR, - 0, DB_RECNO, NULL); - else - db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR, - 0600, DB_BTREE, &b); - - if (db == NULL) { - (void)fprintf(stderr, "dbopen: %s\n", strerror(errno)); - exit(1); - } - globaldb = db; - user(db); - exit(0); - /* NOTREACHED */ -} - -void -user(db) - DB *db; -{ - FILE *ifp; - int argc, i, last; - char *lbuf, *argv[4], buf[512]; - - if ((ifp = fopen("/dev/tty", "r")) == NULL) { - (void)fprintf(stderr, - "/dev/tty: %s\n", strerror(errno)); - exit(1); - } - for (last = 0;;) { - (void)printf("> "); - (void)fflush(stdout); - if ((lbuf = fgets(&buf[0], 512, ifp)) == NULL) - break; - if (lbuf[0] == '\n') { - i = last; - goto uselast; - } - lbuf[strlen(lbuf) - 1] = '\0'; - - if (lbuf[0] == 'q') - break; - - argc = parse(lbuf, &argv[0], 3); - if (argc == 0) - continue; - - for (i = 0; commands[i].cmd != NULL; i++) - if (strncmp(commands[i].cmd, argv[0], - strlen(commands[i].cmd)) == 0) - break; - - if (commands[i].cmd == NULL) { - (void)fprintf(stderr, - "%s: command unknown ('help' for help)\n", lbuf); - continue; - } - - if (commands[i].nargs != argc - 1) { - (void)fprintf(stderr, "usage: %s\n", commands[i].usage); - continue; - } - - if (recno && commands[i].rconv) { - static recno_t nlong; - nlong = atoi(argv[1]); - argv[1] = (char *)&nlong; - } -uselast: last = i; - (*commands[i].func)(db, argv); - } - if ((db->sync)(db) == RET_ERROR) - perror("dbsync"); - else if ((db->close)(db) == RET_ERROR) - perror("dbclose"); -} - -int -parse(lbuf, argv, maxargc) - char *lbuf, **argv; - int maxargc; -{ - int argc = 0; - char *c; - - c = lbuf; - while (isspace(*c)) - c++; - while (*c != '\0' && argc < maxargc) { - *argv++ = c; - argc++; - while (!isspace(*c) && *c != '\0') { - c++; - } - while (isspace(*c)) - *c++ = '\0'; - } - return (argc); -} - -void -append(db, argv) - DB *db; - char **argv; -{ - DBT key, data; - int status; - - if (!recno) { - (void)fprintf(stderr, - "append only available for recno db's.\n"); - return; - } - key.data = argv[1]; - key.size = sizeof(recno_t); - data.data = argv[2]; - data.size = strlen(data.data); - status = (db->put)(db, &key, &data, R_APPEND); - switch (status) { - case RET_ERROR: - perror("append/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -cursor(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - status = (*db->seq)(db, &key, &data, R_CURSOR); - switch (status) { - case RET_ERROR: - perror("cursor/seq"); - break; - case RET_SPECIAL: - (void)printf("key not found\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -delcur(db, argv) - DB *db; - char **argv; -{ - int status; - - status = (*db->del)(db, NULL, R_CURSOR); - - if (status == RET_ERROR) - perror("delcur/del"); -} - -void -delete(db, argv) - DB *db; - char **argv; -{ - DBT key; - int status; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - - status = (*db->del)(db, &key, 0); - switch (status) { - case RET_ERROR: - perror("delete/del"); - break; - case RET_SPECIAL: - (void)printf("key not found\n"); - break; - case RET_SUCCESS: - break; - } -} - -void -dump(db, argv) - DB *db; - char **argv; -{ - __bt_dump(db); -} - -void -first(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_FIRST); - - switch (status) { - case RET_ERROR: - perror("first/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -get(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - - status = (*db->get)(db, &key, &data, 0); - - switch (status) { - case RET_ERROR: - perror("get/get"); - break; - case RET_SPECIAL: - (void)printf("key not found\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -help(db, argv) - DB *db; - char **argv; -{ - int i; - - for (i = 0; commands[i].cmd; i++) - if (commands[i].descrip) - (void)printf("%s: %s\n", - commands[i].usage, commands[i].descrip); -} - -void -iafter(db, argv) - DB *db; - char **argv; -{ - DBT key, data; - int status; - - if (!recno) { - (void)fprintf(stderr, - "iafter only available for recno db's.\n"); - return; - } - key.data = argv[1]; - key.size = sizeof(recno_t); - data.data = argv[2]; - data.size = strlen(data.data); - status = (db->put)(db, &key, &data, R_IAFTER); - switch (status) { - case RET_ERROR: - perror("iafter/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -ibefore(db, argv) - DB *db; - char **argv; -{ - DBT key, data; - int status; - - if (!recno) { - (void)fprintf(stderr, - "ibefore only available for recno db's.\n"); - return; - } - key.data = argv[1]; - key.size = sizeof(recno_t); - data.data = argv[2]; - data.size = strlen(data.data); - status = (db->put)(db, &key, &data, R_IBEFORE); - switch (status) { - case RET_ERROR: - perror("ibefore/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -icursor(db, argv) - DB *db; - char **argv; -{ - int status; - DBT data, key; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - data.data = argv[2]; - data.size = strlen(argv[2]) + 1; - - status = (*db->put)(db, &key, &data, R_CURSOR); - switch (status) { - case RET_ERROR: - perror("icursor/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -insert(db, argv) - DB *db; - char **argv; -{ - int status; - DBT data, key; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - data.data = argv[2]; - data.size = strlen(argv[2]) + 1; - - status = (*db->put)(db, &key, &data, R_NOOVERWRITE); - switch (status) { - case RET_ERROR: - perror("insert/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -last(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_LAST); - - switch (status) { - case RET_ERROR: - perror("last/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -list(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - FILE *fp; - int status; - - if ((fp = fopen(argv[1], "w")) == NULL) { - (void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); - return; - } - status = (*db->seq)(db, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - (void)fprintf(fp, "%s\n", key.data); - status = (*db->seq)(db, &key, &data, R_NEXT); - } - if (status == RET_ERROR) - perror("list/seq"); -} - -DB *BUGdb; -void -load(db, argv) - DB *db; - char **argv; -{ - register char *p, *t; - FILE *fp; - DBT data, key; - recno_t cnt; - size_t len; - int status; - char *lp, buf[16 * 1024]; - - BUGdb = db; - if ((fp = fopen(argv[1], "r")) == NULL) { - (void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); - return; - } - (void)printf("loading %s...\n", argv[1]); - - for (cnt = 1; (lp = fgetline(fp, &len)) != NULL; ++cnt) { - if (recno) { - key.data = &cnt; - key.size = sizeof(recno_t); - data.data = lp; - data.size = len + 1; - } else { - key.data = lp; - key.size = len + 1; - for (p = lp + len - 1, t = buf; p >= lp; *t++ = *p--); - *t = '\0'; - data.data = buf; - data.size = len + 1; - } - - status = (*db->put)(db, &key, &data, R_NOOVERWRITE); - switch (status) { - case RET_ERROR: - perror("load/put"); - exit(1); - case RET_SPECIAL: - if (recno) - (void)fprintf(stderr, - "duplicate: %ld {%s}\n", cnt, data.data); - else - (void)fprintf(stderr, - "duplicate: %ld {%s}\n", cnt, key.data); - exit(1); - case RET_SUCCESS: - break; - } - } - (void)fclose(fp); -} - -void -next(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_NEXT); - - switch (status) { - case RET_ERROR: - perror("next/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -previous(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_PREV); - - switch (status) { - case RET_ERROR: - perror("previous/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -show(db, argv) - DB *db; - char **argv; -{ - BTREE *t; - PAGE *h; - pgno_t pg; - - pg = atoi(argv[1]); - t = db->internal; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) { - (void)printf("getpage of %ld failed\n", pg); - return; - } - if (pg == 0) - __bt_dmpage(h); - else - __bt_dpage(h); - mpool_put(t->bt_mp, h, 0); -} - -void -bstat(db, argv) - DB *db; - char **argv; -{ - (void)printf("BTREE\n"); - __bt_stat(db); -} - -void -mstat(db, argv) - DB *db; - char **argv; -{ - (void)printf("MPOOL\n"); - mpool_stat(((BTREE *)db->internal)->bt_mp); -} - -void -keydata(key, data) - DBT *key, *data; -{ - if (!recno && key->size > 0) - (void)printf("%s/", key->data); - if (data->size > 0) - (void)printf("%s", data->data); - (void)printf("\n"); -} - -void -usage() -{ - (void)fprintf(stderr, - "usage: %s [-bdlu] [-c cache] [-i file] [-p page] [file]\n", - progname); - exit (1); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/dbtest.c b/user/mpy/lib/berkeley-db-1.xx/test/dbtest.c deleted file mode 100644 index 4341b4c..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/dbtest.c +++ /dev/null @@ -1,753 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA }; - -void compare __P((DBT *, DBT *)); -DBTYPE dbtype __P((char *)); -void dump __P((DB *, int)); -void err __P((const char *, ...)); -void get __P((DB *, DBT *)); -void getdata __P((DB *, DBT *, DBT *)); -void put __P((DB *, DBT *, DBT *)); -void rem __P((DB *, DBT *)); -char *sflags __P((int)); -void synk __P((DB *)); -void *rfile __P((char *, size_t *)); -void seq __P((DB *, DBT *)); -u_int setflags __P((char *)); -void *setinfo __P((DBTYPE, char *)); -void usage __P((void)); -void *xmalloc __P((char *, size_t)); - -DBTYPE type; /* Database type. */ -void *infop; /* Iflags. */ -u_long lineno; /* Current line in test script. */ -u_int flags; /* Current DB flags. */ -int ofd = STDOUT_FILENO; /* Standard output fd. */ - -DB *XXdbp; /* Global for gdb. */ -int XXlineno; /* Fast breakpoint for gdb. */ - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern int optind; - extern char *optarg; - enum S command, state; - DB *dbp; - DBT data, key, keydata; - size_t len; - int ch, oflags, sflag; - char *fname, *infoarg, *p, *t, buf[8 * 1024]; - - infoarg = NULL; - fname = NULL; - oflags = O_CREAT | O_RDWR; - sflag = 0; - while ((ch = getopt(argc, argv, "f:i:lo:s")) != EOF) - switch (ch) { - case 'f': - fname = optarg; - break; - case 'i': - infoarg = optarg; - break; - case 'l': - oflags |= DB_LOCK; - break; - case 'o': - if ((ofd = open(optarg, - O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) - err("%s: %s", optarg, strerror(errno)); - break; - case 's': - sflag = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 2) - usage(); - - /* Set the type. */ - type = dbtype(*argv++); - - /* Open the descriptor file. */ - if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL) - err("%s: %s", *argv, strerror(errno)); - - /* Set up the db structure as necessary. */ - if (infoarg == NULL) - infop = NULL; - else - for (p = strtok(infoarg, ",\t "); p != NULL; - p = strtok(0, ",\t ")) - if (*p != '\0') - infop = setinfo(type, p); - - /* - * Open the DB. Delete any preexisting copy, you almost never - * want it around, and it often screws up tests. - */ - if (fname == NULL) { - p = getenv("TMPDIR"); - if (p == NULL) - p = "/var/tmp"; - (void)sprintf(buf, "%s/__dbtest", p); - fname = buf; - (void)unlink(buf); - } else if (!sflag) - (void)unlink(fname); - - if ((dbp = dbopen(fname, - oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL) - err("dbopen: %s", strerror(errno)); - XXdbp = dbp; - - state = COMMAND; - for (lineno = 1; - (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) { - /* Delete the newline, displaying the key/data is easier. */ - if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL) - *t = '\0'; - if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#') - continue; - - /* Convenient gdb break point. */ - if (XXlineno == lineno) - XXlineno = 1; - switch (*p) { - case 'c': /* compare */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - state = KEY; - command = COMPARE; - break; - case 'e': /* echo */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - /* Don't display the newline, if CR at EOL. */ - if (p[len - 2] == '\r') - --len; - if (write(ofd, p + 1, len - 1) != len - 1 || - write(ofd, "\n", 1) != 1) - err("write: %s", strerror(errno)); - break; - case 'g': /* get */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - state = KEY; - command = GET; - break; - case 'p': /* put */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - state = KEY; - command = PUT; - break; - case 'r': /* remove */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - if (flags == R_CURSOR) { - rem(dbp, &key); - state = COMMAND; - } else { - state = KEY; - command = REMOVE; - } - break; - case 'S': /* sync */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - synk(dbp); - state = COMMAND; - break; - case 's': /* seq */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - if (flags == R_CURSOR) { - state = KEY; - command = SEQ; - } else - seq(dbp, &key); - break; - case 'f': - flags = setflags(p + 1); - break; - case 'D': /* data file */ - if (state != DATA) - err("line %lu: not expecting data", lineno); - data.data = rfile(p + 1, &data.size); - goto ldata; - case 'd': /* data */ - if (state != DATA) - err("line %lu: not expecting data", lineno); - data.data = xmalloc(p + 1, len - 1); - data.size = len - 1; -ldata: switch (command) { - case COMPARE: - compare(&keydata, &data); - break; - case PUT: - put(dbp, &key, &data); - break; - default: - err("line %lu: command doesn't take data", - lineno); - } - if (type != DB_RECNO) - free(key.data); - free(data.data); - state = COMMAND; - break; - case 'K': /* key file */ - if (state != KEY) - err("line %lu: not expecting a key", lineno); - if (type == DB_RECNO) - err("line %lu: 'K' not available for recno", - lineno); - key.data = rfile(p + 1, &key.size); - goto lkey; - case 'k': /* key */ - if (state != KEY) - err("line %lu: not expecting a key", lineno); - if (type == DB_RECNO) { - static recno_t recno; - recno = atoi(p + 1); - key.data = &recno; - key.size = sizeof(recno); - } else { - key.data = xmalloc(p + 1, len - 1); - key.size = len - 1; - } -lkey: switch (command) { - case COMPARE: - getdata(dbp, &key, &keydata); - state = DATA; - break; - case GET: - get(dbp, &key); - if (type != DB_RECNO) - free(key.data); - state = COMMAND; - break; - case PUT: - state = DATA; - break; - case REMOVE: - rem(dbp, &key); - if ((type != DB_RECNO) && (flags != R_CURSOR)) - free(key.data); - state = COMMAND; - break; - case SEQ: - seq(dbp, &key); - if ((type != DB_RECNO) && (flags != R_CURSOR)) - free(key.data); - state = COMMAND; - break; - default: - err("line %lu: command doesn't take a key", - lineno); - } - break; - case 'o': - dump(dbp, p[1] == 'r'); - break; - default: - err("line %lu: %s: unknown command character", - lineno, p); - } - } -#ifdef STATISTICS - /* - * -l must be used (DB_LOCK must be set) for this to be - * used, otherwise a page will be locked and it will fail. - */ - if (type == DB_BTREE && oflags & DB_LOCK) - __bt_stat(dbp); -#endif - if (dbp->close(dbp)) - err("db->close: %s", strerror(errno)); - (void)close(ofd); - exit(0); -} - -#define NOOVERWRITE "put failed, would overwrite key\n" - -void -compare(db1, db2) - DBT *db1, *db2; -{ - register size_t len; - register u_char *p1, *p2; - - if (db1->size != db2->size) - printf("compare failed: key->data len %lu != data len %lu\n", - db1->size, db2->size); - - len = MIN(db1->size, db2->size); - for (p1 = db1->data, p2 = db2->data; len--;) - if (*p1++ != *p2++) { - printf("compare failed at offset %d\n", - p1 - (u_char *)db1->data); - break; - } -} - -void -get(dbp, kp) - DB *dbp; - DBT *kp; -{ - DBT data; - - switch (dbp->get(dbp, kp, &data, flags)) { - case 0: - (void)write(ofd, data.data, data.size); - if (ofd == STDOUT_FILENO) - (void)write(ofd, "\n", 1); - break; - case -1: - err("line %lu: get: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: -#define NOSUCHKEY "get failed, no such key\n" - if (ofd != STDOUT_FILENO) - (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); - else - (void)fprintf(stderr, "%d: %.*s: %s", - lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); -#undef NOSUCHKEY - break; - } -} - -void -getdata(dbp, kp, dp) - DB *dbp; - DBT *kp, *dp; -{ - switch (dbp->get(dbp, kp, dp, flags)) { - case 0: - return; - case -1: - err("line %lu: getdata: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: - err("line %lu: getdata failed, no such key", lineno); - /* NOTREACHED */ - } -} - -void -put(dbp, kp, dp) - DB *dbp; - DBT *kp, *dp; -{ - switch (dbp->put(dbp, kp, dp, flags)) { - case 0: - break; - case -1: - err("line %lu: put: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: - (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1); - break; - } -} - -void -rem(dbp, kp) - DB *dbp; - DBT *kp; -{ - switch (dbp->del(dbp, kp, flags)) { - case 0: - break; - case -1: - err("line %lu: rem: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: -#define NOSUCHKEY "rem failed, no such key\n" - if (ofd != STDOUT_FILENO) - (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); - else if (flags != R_CURSOR) - (void)fprintf(stderr, "%d: %.*s: %s", - lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); - else - (void)fprintf(stderr, - "%d: rem of cursor failed\n", lineno); -#undef NOSUCHKEY - break; - } -} - -void -synk(dbp) - DB *dbp; -{ - switch (dbp->sync(dbp, flags)) { - case 0: - break; - case -1: - err("line %lu: synk: %s", lineno, strerror(errno)); - /* NOTREACHED */ - } -} - -void -seq(dbp, kp) - DB *dbp; - DBT *kp; -{ - DBT data; - - switch (dbp->seq(dbp, kp, &data, flags)) { - case 0: - (void)write(ofd, data.data, data.size); - if (ofd == STDOUT_FILENO) - (void)write(ofd, "\n", 1); - break; - case -1: - err("line %lu: seq: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: -#define NOSUCHKEY "seq failed, no such key\n" - if (ofd != STDOUT_FILENO) - (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); - else if (flags == R_CURSOR) - (void)fprintf(stderr, "%d: %.*s: %s", - lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); - else - (void)fprintf(stderr, - "%d: seq (%s) failed\n", lineno, sflags(flags)); -#undef NOSUCHKEY - break; - } -} - -void -dump(dbp, rev) - DB *dbp; - int rev; -{ - DBT key, data; - int flags, nflags; - - if (rev) { - flags = R_LAST; - nflags = R_PREV; - } else { - flags = R_FIRST; - nflags = R_NEXT; - } - for (;; flags = nflags) - switch (dbp->seq(dbp, &key, &data, flags)) { - case 0: - (void)write(ofd, data.data, data.size); - if (ofd == STDOUT_FILENO) - (void)write(ofd, "\n", 1); - break; - case 1: - goto done; - case -1: - err("line %lu: (dump) seq: %s", - lineno, strerror(errno)); - /* NOTREACHED */ - } -done: return; -} - -u_int -setflags(s) - char *s; -{ - char *p, *index(); - - for (; isspace(*s); ++s); - if (*s == '\n' || *s == '\0') - return (0); - if ((p = index(s, '\n')) != NULL) - *p = '\0'; - if (!strcmp(s, "R_CURSOR")) return (R_CURSOR); - if (!strcmp(s, "R_FIRST")) return (R_FIRST); - if (!strcmp(s, "R_IAFTER")) return (R_IAFTER); - if (!strcmp(s, "R_IBEFORE")) return (R_IBEFORE); - if (!strcmp(s, "R_LAST")) return (R_LAST); - if (!strcmp(s, "R_NEXT")) return (R_NEXT); - if (!strcmp(s, "R_NOOVERWRITE")) return (R_NOOVERWRITE); - if (!strcmp(s, "R_PREV")) return (R_PREV); - if (!strcmp(s, "R_SETCURSOR")) return (R_SETCURSOR); - - err("line %lu: %s: unknown flag", lineno, s); - /* NOTREACHED */ -} - -char * -sflags(flags) - int flags; -{ - switch (flags) { - case R_CURSOR: return ("R_CURSOR"); - case R_FIRST: return ("R_FIRST"); - case R_IAFTER: return ("R_IAFTER"); - case R_IBEFORE: return ("R_IBEFORE"); - case R_LAST: return ("R_LAST"); - case R_NEXT: return ("R_NEXT"); - case R_NOOVERWRITE: return ("R_NOOVERWRITE"); - case R_PREV: return ("R_PREV"); - case R_SETCURSOR: return ("R_SETCURSOR"); - } - - return ("UNKNOWN!"); -} - -DBTYPE -dbtype(s) - char *s; -{ - if (!strcmp(s, "btree")) - return (DB_BTREE); - if (!strcmp(s, "hash")) - return (DB_HASH); - if (!strcmp(s, "recno")) - return (DB_RECNO); - err("%s: unknown type (use btree, hash or recno)", s); - /* NOTREACHED */ -} - -void * -setinfo(type, s) - DBTYPE type; - char *s; -{ - static BTREEINFO ib; - static HASHINFO ih; - static RECNOINFO rh; - char *eq, *index(); - - if ((eq = index(s, '=')) == NULL) - err("%s: illegal structure set statement", s); - *eq++ = '\0'; - if (!isdigit(*eq)) - err("%s: structure set statement must be a number", s); - - switch (type) { - case DB_BTREE: - if (!strcmp("flags", s)) { - ib.flags = atoi(eq); - return (&ib); - } - if (!strcmp("cachesize", s)) { - ib.cachesize = atoi(eq); - return (&ib); - } - if (!strcmp("maxkeypage", s)) { - ib.maxkeypage = atoi(eq); - return (&ib); - } - if (!strcmp("minkeypage", s)) { - ib.minkeypage = atoi(eq); - return (&ib); - } - if (!strcmp("lorder", s)) { - ib.lorder = atoi(eq); - return (&ib); - } - if (!strcmp("psize", s)) { - ib.psize = atoi(eq); - return (&ib); - } - break; - case DB_HASH: - if (!strcmp("bsize", s)) { - ih.bsize = atoi(eq); - return (&ih); - } - if (!strcmp("ffactor", s)) { - ih.ffactor = atoi(eq); - return (&ih); - } - if (!strcmp("nelem", s)) { - ih.nelem = atoi(eq); - return (&ih); - } - if (!strcmp("cachesize", s)) { - ih.cachesize = atoi(eq); - return (&ih); - } - if (!strcmp("lorder", s)) { - ih.lorder = atoi(eq); - return (&ih); - } - break; - case DB_RECNO: - if (!strcmp("flags", s)) { - rh.flags = atoi(eq); - return (&rh); - } - if (!strcmp("cachesize", s)) { - rh.cachesize = atoi(eq); - return (&rh); - } - if (!strcmp("lorder", s)) { - rh.lorder = atoi(eq); - return (&rh); - } - if (!strcmp("reclen", s)) { - rh.reclen = atoi(eq); - return (&rh); - } - if (!strcmp("bval", s)) { - rh.bval = atoi(eq); - return (&rh); - } - if (!strcmp("psize", s)) { - rh.psize = atoi(eq); - return (&rh); - } - break; - } - err("%s: unknown structure value", s); - /* NOTREACHED */ -} - -void * -rfile(name, lenp) - char *name; - size_t *lenp; -{ - struct stat sb; - void *p; - int fd; - char *np, *index(); - - for (; isspace(*name); ++name); - if ((np = index(name, '\n')) != NULL) - *np = '\0'; - if ((fd = open(name, O_RDONLY, 0)) < 0 || - fstat(fd, &sb)) - err("%s: %s\n", name, strerror(errno)); -#ifdef NOT_PORTABLE - if (sb.st_size > (off_t)SIZE_T_MAX) - err("%s: %s\n", name, strerror(E2BIG)); -#endif - if ((p = (void *)malloc((u_int)sb.st_size)) == NULL) - err("%s", strerror(errno)); - (void)read(fd, p, (int)sb.st_size); - *lenp = sb.st_size; - (void)close(fd); - return (p); -} - -void * -xmalloc(text, len) - char *text; - size_t len; -{ - void *p; - - if ((p = (void *)malloc(len)) == NULL) - err("%s", strerror(errno)); - memmove(p, text, len); - return (p); -} - -void -usage() -{ - (void)fprintf(stderr, - "usage: dbtest [-l] [-f file] [-i info] [-o file] type script\n"); - exit(1); -} - -#if __STDC__ -#include -#else -#include -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "dbtest: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c deleted file mode 100644 index 2008a28..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/driver2.c +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)driver2.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Test driver, to try to tackle the large ugly-split problem. - */ - -#include -#include -#include "ndbm.h" - -int my_hash(key, len) - char *key; - int len; -{ - return(17); /* So I'm cruel... */ -} - -main(argc, argv) - int argc; -{ - DB *db; - DBT key, content; - char keybuf[2049]; - char contentbuf[2049]; - char buf[256]; - int i; - HASHINFO info; - - info.bsize = 1024; - info.ffactor = 5; - info.nelem = 1; - info.cachesize = NULL; -#ifdef HASH_ID_PROGRAM_SPECIFIED - info.hash_id = HASH_ID_PROGRAM_SPECIFIED; - info.hash_func = my_hash; -#else - info.hash = my_hash; -#endif - info.lorder = 0; - if (!(db = dbopen("bigtest", O_RDWR | O_CREAT, 0644, DB_HASH, &info))) { - sprintf(buf, "dbopen: failed on file bigtest"); - perror(buf); - exit(1); - } - srandom(17); - key.data = keybuf; - content.data = contentbuf; - bzero(keybuf, sizeof(keybuf)); - bzero(contentbuf, sizeof(contentbuf)); - for (i=1; i <= 500; i++) { - key.size = 128 + (random()&1023); - content.size = 128 + (random()&1023); -/* printf("%d: Key size %d, data size %d\n", i, key.size, - content.size); */ - sprintf(keybuf, "Key #%d", i); - sprintf(contentbuf, "Contents #%d", i); - if ((db->put)(db, &key, &content, R_NOOVERWRITE)) { - sprintf(buf, "dbm_store #%d", i); - perror(buf); - } - } - if ((db->close)(db)) { - perror("closing hash file"); - exit(1); - } - exit(0); -} - - - diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh deleted file mode 100644 index f28e281..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/makedb.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# @(#)makedb.sh 8.1 (Berkeley) 6/4/93 - -awk '{i++; print $0; print i;}' /usr/share/dict/words > WORDS -ls /bin /usr/bin /usr/ucb /etc | egrep '^(...|....|.....|......)$' | \ -sort | uniq | \ -awk '{ - printf "%s\n", $0 - for (i = 0; i < 1000; i++) - printf "%s+", $0 - printf "\n" -}' > LONG.DATA diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c deleted file mode 100644 index bd125ac..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tcreat3.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tcreat3.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key; - DB *dbp; - HASHINFO ctl; - FILE *fp; - int trash; - - int i = 0; - - argv++; - ctl.hash = NULL; - ctl.bsize = atoi(*argv++); - ctl.ffactor = atoi(*argv++); - ctl.nelem = atoi(*argv++); - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", - O_CREAT|O_TRUNC|O_RDWR, 0600, DB_HASH, &ctl))){ - /* create table */ - fprintf(stderr, "cannot create: hash table (size %d)\n", - INITIAL); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - -/* - * enter key/data pair into the table - */ - if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { - fprintf(stderr, "cannot enter: key %s\n", - item.data); - exit(1); - } - } - - (dbp->close)(dbp); - exit(0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c deleted file mode 100644 index ed3f90a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tdel.c +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tdel.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -/* Usage: thash pagesize fillfactor file */ -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key; - DB *dbp; - HASHINFO ctl; - FILE *fp; - int stat; - - int i = 0; - - argv++; - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = atoi(*argv++); - ctl.ffactor = atoi(*argv++); - ctl.cachesize = 1024 * 1024; /* 1 MEG */ - ctl.lorder = 0; - argc -= 2; - if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot create: hash table size %d)\n", - INITIAL); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - -/* - * enter key/data pair into the table - */ - if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { - fprintf(stderr, "cannot enter: key %s\n", - item.data); - exit(1); - } - } - - if ( --argc ) { - fp = fopen ( argv[0], "r"); - i = 0; - while ( fgets(wp1, 8192, fp) && - fgets(wp2, 8192, fp) && - i++ < MAXWORDS) { - key.size = strlen(wp1); - stat = (dbp->del)(dbp, &key, 0); - if (stat) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } - } - fclose(fp); - } - (dbp->close)(dbp); - exit(0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit deleted file mode 100644 index 039457a..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/testit +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/csh -f -# -# @(#)testit 8.1 (Berkeley) 6/4/93 -# - -echo "" -echo "PAGE FILL " -set name=WORDS - set i = 256 - foreach j ( 11 14 21 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 512 - foreach j ( 21 28 43 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 1024 - foreach j ( 43 57 85 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 2048 - foreach j ( 85 114 171 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 4096 - foreach j ( 171 228 341 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 8192 - foreach j ( 341 455 683 ) - thash4 $i $j 25000 65536 $name < $name - end - echo "PAGE FILL " - set i = 256 - foreach j ( 11 14 21 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 512 - foreach j ( 21 28 43 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 1024 - foreach j ( 43 57 85 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 2048 - foreach j ( 85 114 171 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 4096 - foreach j ( 171 228 341 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 8192 - foreach j ( 341 455 683 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end -set name=LONG.DATA - set i = 1024 - foreach j ( 1 2 4 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - - set i = 2048 - foreach j ( 1 2 4 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - set i = 4096 - foreach j ( 1 2 4 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - set i = 8192 - foreach j ( 2 4 8 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - echo "PAGE FILL " - set i = 1024 - foreach j ( 1 2 4 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 2048 - foreach j ( 1 2 4 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 4096 - foreach j ( 1 2 4 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 8192 - foreach j ( 2 4 8 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end -driver2 diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c deleted file mode 100644 index 9e344cb..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/thash4.c +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)thash4.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -/* Usage: thash pagesize fillfactor file */ -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - HASHINFO ctl; - FILE *fp; - int stat; - time_t t; - - int i = 0; - - argv++; - ctl.hash = NULL; - ctl.bsize = atoi(*argv++); - ctl.ffactor = atoi(*argv++); - ctl.nelem = atoi(*argv++); - ctl.cachesize = atoi(*argv++); - ctl.lorder = 0; - if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot create: hash table size %d)\n", - INITIAL); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - -/* - * enter key/data pair into the table - */ - if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { - fprintf(stderr, "cannot enter: key %s\n", - item.data); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } - } - - if ( --argc ) { - fp = fopen ( argv[0], "r"); - i = 0; - while ( fgets(wp1, 256, fp) && - fgets(wp2, 8192, fp) && - i++ < MAXWORDS) { - - key.size = strlen(wp1); - stat = (dbp->get)(dbp, &key, &res, 0); - if (stat < 0 ) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } - } - fclose(fp); - } - dbp->close(dbp); - exit(0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c deleted file mode 100644 index 8f01556..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tread2.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tread2.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -typedef struct { /* info to be stored */ - int num, siz; -} info; - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - HASHINFO ctl; - int stat; - - int i = 0; - - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = 64; - ctl.ffactor = 1; - ctl.cachesize = atoi(*argv++); - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - - stat = (dbp->get)(dbp, &key, &res,0); - if (stat < 0) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - exit(1); - } - } - (dbp->close)(dbp); - exit(0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c deleted file mode 100644 index f45700e..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tseq.c +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tseq.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - - -char wp[8192]; -char cp[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - FILE *fp; - int stat; - - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - -/* -* put info in structure, and structure in the item -*/ - for ( stat = (dbp->seq) (dbp, &res, &item, 1 ); - stat == 0; - stat = (dbp->seq) (dbp, &res, &item, 0 ) ) { - - bcopy ( res.data, wp, res.size ); - wp[res.size] = 0; - bcopy ( item.data, cp, item.size ); - cp[item.size] = 0; - - printf ( "%s %s\n", wp, cp ); - } - (dbp->close)(dbp); - exit(0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c b/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c deleted file mode 100644 index ac5d2f9..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/hash.tests/tverify.c +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tverify.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -typedef struct { /* info to be stored */ - int num, siz; -} info; - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT key, res; - DB *dbp; - HASHINFO ctl; - int trash; - int stat; - - int i = 0; - - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = 64; - ctl.ffactor = 1; - ctl.cachesize = 1024 * 1024; /* 1 MEG */ - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - - key.data = wp1; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - - stat = (dbp->get)(dbp, &key, &res,0); - if (stat < 0) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - exit(1); - } - if ( memcmp ( res.data, wp2, res.size ) ) { - fprintf ( stderr, "data for %s is incorrect. Data was %s. Should have been %s\n", key.data, res.data, wp2 ); - } - } - (dbp->close)(dbp); - exit(0); -} diff --git a/user/mpy/lib/berkeley-db-1.xx/test/run.test b/user/mpy/lib/berkeley-db-1.xx/test/run.test deleted file mode 100644 index 52b74c3..0000000 --- a/user/mpy/lib/berkeley-db-1.xx/test/run.test +++ /dev/null @@ -1,705 +0,0 @@ -#!/bin/sh - -# -# @(#)run.test 8.10 (Berkeley) 7/26/94 -# - -# db regression tests -main() -{ - - PROG=./dbtest - TMP1=t1 - TMP2=t2 - TMP3=t3 - - if [ -f /usr/share/dict/words ]; then - DICT=/usr/share/dict/words - elif [ -f /usr/dict/words ]; then - DICT=/usr/dict/words - else - echo 'run.test: no dictionary' - exit 1 - fi - - if [ $# -eq 0 ]; then - for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do - test$t - done - else - while [ $# -gt 0 ] - do case "$1" in - test*) - $1;; - [0-9]*) - test$1;; - btree) - for t in 1 2 3 7 8 9 10 12 13; do - test$t - done;; - hash) - for t in 1 2 3 8 13 20; do - test$t - done;; - recno) - for t in 1 2 3 4 5 6 7 10 11; do - test$t - done;; - *) - echo "run.test: unknown test $1" - echo "usage: run.test test# | type" - exit 1 - esac - shift - done - fi - rm -f $TMP1 $TMP2 $TMP3 - exit 0 -} - -# Take the first hundred entries in the dictionary, and make them -# be key/data pairs. -test1() -{ - echo "Test 1: btree, hash: small key, small data pairs" - sed 200q $DICT > $TMP1 - for type in btree hash; do - rm -f $TMP2 $TMP3 - for i in `sed 200q $DICT`; do - echo p - echo k$i - echo d$i - echo g - echo k$i - done > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test1: type $type: failed" - exit 1 - fi - done - echo "Test 1: recno: small key, small data pairs" - rm -f $TMP2 $TMP3 - sed 200q $DICT | - awk '{ - ++i; - printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test1: type recno: failed" - exit 1 - fi -} - -# Take the first 200 entries in the dictionary, and give them -# each a medium size data entry. -test2() -{ - echo "Test 2: btree, hash: small key, medium data pairs" - mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - echo $mdata | - awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 - for type in hash btree; do - rm -f $TMP2 $TMP3 - for i in `sed 200q $DICT`; do - echo p - echo k$i - echo d$mdata - echo g - echo k$i - done > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test2: type $type: failed" - exit 1 - fi - done - echo "Test 2: recno: small key, medium data pairs" - rm -f $TMP2 $TMP3 - echo $mdata | - awk '{ for (i = 1; i < 201; ++i) - printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test2: type recno: failed" - exit 1 - fi -} - -# Insert the programs in /bin with their paths as their keys. -test3() -{ - echo "Test 3: hash: small key, big data pairs" - rm -f $TMP1 - (find /bin -type f -print | xargs cat) > $TMP1 - for type in hash; do - rm -f $TMP2 $TMP3 - for i in `find /bin -type f -print`; do - echo p - echo k$i - echo D$i - echo g - echo k$i - done > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test3: $type: failed" - exit 1 - fi - done - echo "Test 3: btree: small key, big data pairs" - for psize in 512 16384 65536; do - echo " page size $psize" - for type in btree; do - rm -f $TMP2 $TMP3 - for i in `find /bin -type f -print`; do - echo p - echo k$i - echo D$i - echo g - echo k$i - done > $TMP2 - $PROG -i psize=$psize -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test3: $type: page size $psize: failed" - exit 1 - fi - done - done - echo "Test 3: recno: big data pairs" - rm -f $TMP2 $TMP3 - find /bin -type f -print | - awk '{ - ++i; - printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 - for psize in 512 16384 65536; do - echo " page size $psize" - $PROG -i psize=$psize -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test3: recno: page size $psize: failed" - exit 1 - fi - done -} - -# Do random recno entries. -test4() -{ - echo "Test 4: recno: random entries" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 37; i <= 37 + 88 * 17; i += 17) { - if (i % 41) - s = substr($0, 1, i % 41); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - for (i = 1; i <= 15; ++i) { - if (i % 41) - s = substr($0, 1, i % 41); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - for (i = 19234; i <= 19234 + 61 * 27; i += 27) { - if (i % 41) - s = substr($0, 1, i % 41); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - exit - }' > $TMP1 - rm -f $TMP2 $TMP3 - cat $TMP1 | - awk 'BEGIN { - i = 37; - incr = 17; - } - { - printf("p\nk%d\nd%s\n", i, $0); - if (i == 19234 + 61 * 27) - exit; - if (i == 37 + 88 * 17) { - i = 1; - incr = 1; - } else if (i == 15) { - i = 19234; - incr = 27; - } else - i += incr; - } - END { - for (i = 37; i <= 37 + 88 * 17; i += 17) - printf("g\nk%d\n", i); - for (i = 1; i <= 15; ++i) - printf("g\nk%d\n", i); - for (i = 19234; i <= 19234 + 61 * 27; i += 27) - printf("g\nk%d\n", i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test4: type recno: failed" - exit 1 - fi -} - -# Do reverse order recno entries. -test5() -{ - echo "Test 5: recno: reverse order entries" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk ' { - for (i = 1500; i; --i) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - cat $TMP1 | - awk 'BEGIN { - i = 1500; - } - { - printf("p\nk%d\nd%s\n", i, $0); - --i; - } - END { - for (i = 1500; i; --i) - printf("g\nk%d\n", i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test5: type recno: failed" - exit 1 - fi -} - -# Do alternating order recno entries. -test6() -{ - echo "Test 6: recno: alternating order entries" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk ' { - for (i = 1; i < 1200; i += 2) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - for (i = 2; i < 1200; i += 2) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - cat $TMP1 | - awk 'BEGIN { - i = 1; - even = 0; - } - { - printf("p\nk%d\nd%s\n", i, $0); - i += 2; - if (i >= 1200) { - if (even == 1) - exit; - even = 1; - i = 2; - } - } - END { - for (i = 1; i < 1200; ++i) - printf("g\nk%d\n", i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - sort -o $TMP1 $TMP1 - sort -o $TMP3 $TMP3 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test6: type recno: failed" - exit 1 - fi -} - -# Delete cursor record -test7() -{ - echo "Test 7: btree, recno: delete cursor record" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 120; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - printf("%05d: input key %d: %s\n", 120, 120, $0); - printf("seq failed, no such key\n"); - printf("%05d: input key %d: %s\n", 1, 1, $0); - printf("%05d: input key %d: %s\n", 2, 2, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - for type in btree recno; do - cat $TMP1 | - awk '{ - if (i == 120) - exit; - printf("p\nk%d\nd%s\n", ++i, $0); - } - END { - printf("fR_NEXT\n"); - for (i = 1; i <= 120; ++i) - printf("s\n"); - printf("fR_CURSOR\ns\nk120\n"); - printf("r\n"); - printf("fR_NEXT\ns\n"); - printf("fR_CURSOR\ns\nk1\n"); - printf("r\n"); - printf("fR_FIRST\ns\n"); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test7: type $type: failed" - exit 1 - fi - done -} - -# Make sure that overflow pages are reused. -test8() -{ - echo "Test 8: btree, hash: repeated small key, big data pairs" - rm -f $TMP1 - echo "" | - awk 'BEGIN { - for (i = 1; i <= 10; ++i) { - printf("p\nkkey1\nD/bin/sh\n"); - printf("p\nkkey2\nD/bin/csh\n"); - if (i % 8 == 0) { - printf("c\nkkey2\nD/bin/csh\n"); - printf("c\nkkey1\nD/bin/sh\n"); - printf("e\t%d of 10 (comparison)\n", i); - } else - printf("e\t%d of 10 \n", i); - printf("r\nkkey1\nr\nkkey2\n"); - } - }' > $TMP1 - $PROG btree $TMP1 -# $PROG hash $TMP1 - # No explicit test for success. -} - -# Test btree duplicate keys -test9() -{ - echo "Test 9: btree: duplicate keys" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 543; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - for type in btree; do - cat $TMP1 | - awk '{ - if (i++ % 2) - printf("p\nkduplicatekey\nd%s\n", $0); - else - printf("p\nkunique%dkey\nd%s\n", i, $0); - } - END { - printf("o\n"); - }' > $TMP2 - $PROG -iflags=1 -o $TMP3 $type $TMP2 - sort -o $TMP3 $TMP3 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test9: type $type: failed" - exit 1 - fi - done -} - -# Test use of cursor flags without initialization -test10() -{ - echo "Test 10: btree, recno: test cursor flag use" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 20; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - # Test that R_CURSOR doesn't succeed before cursor initialized - for type in btree recno; do - cat $TMP1 | - awk '{ - if (i == 10) - exit; - printf("p\nk%d\nd%s\n", ++i, $0); - } - END { - printf("fR_CURSOR\nr\n"); - printf("eR_CURSOR SHOULD HAVE FAILED\n"); - }' > $TMP2 - $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 - if [ -s $TMP3 ] ; then - echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED" - exit 1 - fi - done - for type in btree recno; do - cat $TMP1 | - awk '{ - if (i == 10) - exit; - printf("p\nk%d\nd%s\n", ++i, $0); - } - END { - printf("fR_CURSOR\np\nk1\ndsome data\n"); - printf("eR_CURSOR SHOULD HAVE FAILED\n"); - }' > $TMP2 - $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 - if [ -s $TMP3 ] ; then - echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED" - exit 1 - fi - done -} - -# Test insert in reverse order. -test11() -{ - echo "Test 11: recno: reverse order insert" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 779; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - for type in recno; do - cat $TMP1 | - awk '{ - if (i == 0) { - i = 1; - printf("p\nk1\nd%s\n", $0); - printf("%s\n", "fR_IBEFORE"); - } else - printf("p\nk1\nd%s\n", $0); - } - END { - printf("or\n"); - }' > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test11: type $type: failed" - exit 1 - fi - done -} - -# Take the first 20000 entries in the dictionary, reverse them, and give -# them each a small size data entry. Use a small page size to make sure -# the btree split code gets hammered. -test12() -{ - echo "Test 12: btree: lots of keys, small page size" - mdata=abcdefghijklmnopqrstuvwxy - echo $mdata | - awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 - for type in btree; do - rm -f $TMP2 $TMP3 - for i in `sed 20000q $DICT | rev`; do - echo p - echo k$i - echo d$mdata - echo g - echo k$i - done > $TMP2 - $PROG -i psize=512 -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test12: type $type: failed" - exit 1 - fi - done -} - -# Test different byte orders. -test13() -{ - echo "Test 13: btree, hash: differing byte orders" - sed 50q $DICT > $TMP1 - for order in 1234 4321; do - for type in btree hash; do - rm -f byte.file $TMP2 $TMP3 - for i in `sed 50q $DICT`; do - echo p - echo k$i - echo d$i - echo g - echo k$i - done > $TMP2 - $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test13: $type/$order put failed" - exit 1 - fi - for i in `sed 50q $DICT`; do - echo g - echo k$i - done > $TMP2 - $PROG -s \ - -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test13: $type/$order get failed" - exit 1 - fi - done - done - rm -f byte.file -} - -# Try a variety of bucketsizes and fill factors for hashing -test20() -{ - echo\ - "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 10000; ++i) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("%s\n", s); - } - exit; - }' > $TMP1 - sed 10000q $DICT | - awk 'BEGIN { - ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" - } - { - if (++i % 34) - s = substr(ds, 1, i % 34); - else - s = substr(ds, 1); - printf("p\nk%s\nd%s\n", $0, s); - }' > $TMP2 - sed 10000q $DICT | - awk '{ - ++i; - printf("g\nk%s\n", $0); - }' >> $TMP2 - bsize=256 - for ffactor in 11 14 21; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=512 - for ffactor in 21 28 43; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=1024 - for ffactor in 43 57 85; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=2048 - for ffactor in 85 114 171; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=4096 - for ffactor in 171 228 341; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=8192 - for ffactor in 341 455 683; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done -} - -main $* diff --git a/user/mpy/lib/cmsis/inc/cmsis_armcc.h b/user/mpy/lib/cmsis/inc/cmsis_armcc.h deleted file mode 100644 index 74c49c6..0000000 --- a/user/mpy/lib/cmsis/inc/cmsis_armcc.h +++ /dev/null @@ -1,734 +0,0 @@ -/**************************************************************************//** - * @file cmsis_armcc.h - * @brief CMSIS Cortex-M Core Function/Instruction Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#ifndef __CMSIS_ARMCC_H -#define __CMSIS_ARMCC_H - - -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) - #error "Please use ARM Compiler Toolchain V4.0.677 or later!" -#endif - -/* ########################### Core Function Access ########################### */ -/** \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions - @{ - */ - -/* intrinsic void __enable_irq(); */ -/* intrinsic void __disable_irq(); */ - -/** - \brief Get Control Register - \details Returns the content of the Control Register. - \return Control Register value - */ -__STATIC_INLINE uint32_t __get_CONTROL(void) -{ - register uint32_t __regControl __ASM("control"); - return(__regControl); -} - - -/** - \brief Set Control Register - \details Writes the given value to the Control Register. - \param [in] control Control Register value to set - */ -__STATIC_INLINE void __set_CONTROL(uint32_t control) -{ - register uint32_t __regControl __ASM("control"); - __regControl = control; -} - - -/** - \brief Get IPSR Register - \details Returns the content of the IPSR Register. - \return IPSR Register value - */ -__STATIC_INLINE uint32_t __get_IPSR(void) -{ - register uint32_t __regIPSR __ASM("ipsr"); - return(__regIPSR); -} - - -/** - \brief Get APSR Register - \details Returns the content of the APSR Register. - \return APSR Register value - */ -__STATIC_INLINE uint32_t __get_APSR(void) -{ - register uint32_t __regAPSR __ASM("apsr"); - return(__regAPSR); -} - - -/** - \brief Get xPSR Register - \details Returns the content of the xPSR Register. - \return xPSR Register value - */ -__STATIC_INLINE uint32_t __get_xPSR(void) -{ - register uint32_t __regXPSR __ASM("xpsr"); - return(__regXPSR); -} - - -/** - \brief Get Process Stack Pointer - \details Returns the current value of the Process Stack Pointer (PSP). - \return PSP Register value - */ -__STATIC_INLINE uint32_t __get_PSP(void) -{ - register uint32_t __regProcessStackPointer __ASM("psp"); - return(__regProcessStackPointer); -} - - -/** - \brief Set Process Stack Pointer - \details Assigns the given value to the Process Stack Pointer (PSP). - \param [in] topOfProcStack Process Stack Pointer value to set - */ -__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) -{ - register uint32_t __regProcessStackPointer __ASM("psp"); - __regProcessStackPointer = topOfProcStack; -} - - -/** - \brief Get Main Stack Pointer - \details Returns the current value of the Main Stack Pointer (MSP). - \return MSP Register value - */ -__STATIC_INLINE uint32_t __get_MSP(void) -{ - register uint32_t __regMainStackPointer __ASM("msp"); - return(__regMainStackPointer); -} - - -/** - \brief Set Main Stack Pointer - \details Assigns the given value to the Main Stack Pointer (MSP). - \param [in] topOfMainStack Main Stack Pointer value to set - */ -__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) -{ - register uint32_t __regMainStackPointer __ASM("msp"); - __regMainStackPointer = topOfMainStack; -} - - -/** - \brief Get Priority Mask - \details Returns the current state of the priority mask bit from the Priority Mask Register. - \return Priority Mask value - */ -__STATIC_INLINE uint32_t __get_PRIMASK(void) -{ - register uint32_t __regPriMask __ASM("primask"); - return(__regPriMask); -} - - -/** - \brief Set Priority Mask - \details Assigns the given value to the Priority Mask Register. - \param [in] priMask Priority Mask - */ -__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) -{ - register uint32_t __regPriMask __ASM("primask"); - __regPriMask = (priMask); -} - - -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - -/** - \brief Enable FIQ - \details Enables FIQ interrupts by clearing the F-bit in the CPSR. - Can only be executed in Privileged modes. - */ -#define __enable_fault_irq __enable_fiq - - -/** - \brief Disable FIQ - \details Disables FIQ interrupts by setting the F-bit in the CPSR. - Can only be executed in Privileged modes. - */ -#define __disable_fault_irq __disable_fiq - - -/** - \brief Get Base Priority - \details Returns the current value of the Base Priority register. - \return Base Priority register value - */ -__STATIC_INLINE uint32_t __get_BASEPRI(void) -{ - register uint32_t __regBasePri __ASM("basepri"); - return(__regBasePri); -} - - -/** - \brief Set Base Priority - \details Assigns the given value to the Base Priority register. - \param [in] basePri Base Priority value to set - */ -__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) -{ - register uint32_t __regBasePri __ASM("basepri"); - __regBasePri = (basePri & 0xFFU); -} - - -/** - \brief Set Base Priority with condition - \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, - or the new value increases the BASEPRI priority level. - \param [in] basePri Base Priority value to set - */ -__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) -{ - register uint32_t __regBasePriMax __ASM("basepri_max"); - __regBasePriMax = (basePri & 0xFFU); -} - - -/** - \brief Get Fault Mask - \details Returns the current value of the Fault Mask register. - \return Fault Mask register value - */ -__STATIC_INLINE uint32_t __get_FAULTMASK(void) -{ - register uint32_t __regFaultMask __ASM("faultmask"); - return(__regFaultMask); -} - - -/** - \brief Set Fault Mask - \details Assigns the given value to the Fault Mask register. - \param [in] faultMask Fault Mask value to set - */ -__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) -{ - register uint32_t __regFaultMask __ASM("faultmask"); - __regFaultMask = (faultMask & (uint32_t)1); -} - -#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ - - -#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) - -/** - \brief Get FPSCR - \details Returns the current value of the Floating Point Status/Control register. - \return Floating Point Status/Control register value - */ -__STATIC_INLINE uint32_t __get_FPSCR(void) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - register uint32_t __regfpscr __ASM("fpscr"); - return(__regfpscr); -#else - return(0U); -#endif -} - - -/** - \brief Set FPSCR - \details Assigns the given value to the Floating Point Status/Control register. - \param [in] fpscr Floating Point Status/Control value to set - */ -__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - register uint32_t __regfpscr __ASM("fpscr"); - __regfpscr = (fpscr); -#endif -} - -#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ - - - -/*@} end of CMSIS_Core_RegAccFunctions */ - - -/* ########################## Core Instruction Access ######################### */ -/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface - Access to dedicated instructions - @{ -*/ - -/** - \brief No Operation - \details No Operation does nothing. This instruction can be used for code alignment purposes. - */ -#define __NOP __nop - - -/** - \brief Wait For Interrupt - \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. - */ -#define __WFI __wfi - - -/** - \brief Wait For Event - \details Wait For Event is a hint instruction that permits the processor to enter - a low-power state until one of a number of events occurs. - */ -#define __WFE __wfe - - -/** - \brief Send Event - \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. - */ -#define __SEV __sev - - -/** - \brief Instruction Synchronization Barrier - \details Instruction Synchronization Barrier flushes the pipeline in the processor, - so that all instructions following the ISB are fetched from cache or memory, - after the instruction has been completed. - */ -#define __ISB() do {\ - __schedule_barrier();\ - __isb(0xF);\ - __schedule_barrier();\ - } while (0U) - -/** - \brief Data Synchronization Barrier - \details Acts as a special kind of Data Memory Barrier. - It completes when all explicit memory accesses before this instruction complete. - */ -#define __DSB() do {\ - __schedule_barrier();\ - __dsb(0xF);\ - __schedule_barrier();\ - } while (0U) - -/** - \brief Data Memory Barrier - \details Ensures the apparent order of the explicit memory operations before - and after the instruction, without ensuring their completion. - */ -#define __DMB() do {\ - __schedule_barrier();\ - __dmb(0xF);\ - __schedule_barrier();\ - } while (0U) - -/** - \brief Reverse byte order (32 bit) - \details Reverses the byte order in integer value. - \param [in] value Value to reverse - \return Reversed value - */ -#define __REV __rev - - -/** - \brief Reverse byte order (16 bit) - \details Reverses the byte order in two unsigned short values. - \param [in] value Value to reverse - \return Reversed value - */ -#ifndef __NO_EMBEDDED_ASM -__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) -{ - rev16 r0, r0 - bx lr -} -#endif - -/** - \brief Reverse byte order in signed short value - \details Reverses the byte order in a signed short value with sign extension to integer. - \param [in] value Value to reverse - \return Reversed value - */ -#ifndef __NO_EMBEDDED_ASM -__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value) -{ - revsh r0, r0 - bx lr -} -#endif - - -/** - \brief Rotate Right in unsigned value (32 bit) - \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. - \param [in] value Value to rotate - \param [in] value Number of Bits to rotate - \return Rotated value - */ -#define __ROR __ror - - -/** - \brief Breakpoint - \details Causes the processor to enter Debug state. - Debug tools can use this to investigate system state when the instruction at a particular address is reached. - \param [in] value is ignored by the processor. - If required, a debugger can use it to store additional information about the breakpoint. - */ -#define __BKPT(value) __breakpoint(value) - - -/** - \brief Reverse bit order of value - \details Reverses the bit order of the given value. - \param [in] value Value to reverse - \return Reversed value - */ -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - #define __RBIT __rbit -#else -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) -{ - uint32_t result; - int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ - - result = value; /* r will be reversed bits of v; first get LSB of v */ - for (value >>= 1U; value; value >>= 1U) - { - result <<= 1U; - result |= value & 1U; - s--; - } - result <<= s; /* shift when v's highest bits are zero */ - return(result); -} -#endif - - -/** - \brief Count leading zeros - \details Counts the number of leading zeros of a data value. - \param [in] value Value to count the leading zeros - \return number of leading zeros in value - */ -#define __CLZ __clz - - -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - -/** - \brief LDR Exclusive (8 bit) - \details Executes a exclusive LDR instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) - #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) -#else - #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") -#endif - - -/** - \brief LDR Exclusive (16 bit) - \details Executes a exclusive LDR instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) - #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) -#else - #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") -#endif - - -/** - \brief LDR Exclusive (32 bit) - \details Executes a exclusive LDR instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) - #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) -#else - #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") -#endif - - -/** - \brief STR Exclusive (8 bit) - \details Executes a exclusive STR instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) - #define __STREXB(value, ptr) __strex(value, ptr) -#else - #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") -#endif - - -/** - \brief STR Exclusive (16 bit) - \details Executes a exclusive STR instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) - #define __STREXH(value, ptr) __strex(value, ptr) -#else - #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") -#endif - - -/** - \brief STR Exclusive (32 bit) - \details Executes a exclusive STR instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) - #define __STREXW(value, ptr) __strex(value, ptr) -#else - #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") -#endif - - -/** - \brief Remove the exclusive lock - \details Removes the exclusive lock which is created by LDREX. - */ -#define __CLREX __clrex - - -/** - \brief Signed Saturate - \details Saturates a signed value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (1..32) - \return Saturated value - */ -#define __SSAT __ssat - - -/** - \brief Unsigned Saturate - \details Saturates an unsigned value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (0..31) - \return Saturated value - */ -#define __USAT __usat - - -/** - \brief Rotate Right with Extend (32 bit) - \details Moves each bit of a bitstring right by one bit. - The carry input is shifted in at the left end of the bitstring. - \param [in] value Value to rotate - \return Rotated value - */ -#ifndef __NO_EMBEDDED_ASM -__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) -{ - rrx r0, r0 - bx lr -} -#endif - - -/** - \brief LDRT Unprivileged (8 bit) - \details Executes a Unprivileged LDRT instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) - - -/** - \brief LDRT Unprivileged (16 bit) - \details Executes a Unprivileged LDRT instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) - - -/** - \brief LDRT Unprivileged (32 bit) - \details Executes a Unprivileged LDRT instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) - - -/** - \brief STRT Unprivileged (8 bit) - \details Executes a Unprivileged STRT instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -#define __STRBT(value, ptr) __strt(value, ptr) - - -/** - \brief STRT Unprivileged (16 bit) - \details Executes a Unprivileged STRT instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -#define __STRHT(value, ptr) __strt(value, ptr) - - -/** - \brief STRT Unprivileged (32 bit) - \details Executes a Unprivileged STRT instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -#define __STRT(value, ptr) __strt(value, ptr) - -#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ - -/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ - - -/* ################### Compiler specific Intrinsics ########################### */ -/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics - Access to dedicated SIMD instructions - @{ -*/ - -#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ - -#define __SADD8 __sadd8 -#define __QADD8 __qadd8 -#define __SHADD8 __shadd8 -#define __UADD8 __uadd8 -#define __UQADD8 __uqadd8 -#define __UHADD8 __uhadd8 -#define __SSUB8 __ssub8 -#define __QSUB8 __qsub8 -#define __SHSUB8 __shsub8 -#define __USUB8 __usub8 -#define __UQSUB8 __uqsub8 -#define __UHSUB8 __uhsub8 -#define __SADD16 __sadd16 -#define __QADD16 __qadd16 -#define __SHADD16 __shadd16 -#define __UADD16 __uadd16 -#define __UQADD16 __uqadd16 -#define __UHADD16 __uhadd16 -#define __SSUB16 __ssub16 -#define __QSUB16 __qsub16 -#define __SHSUB16 __shsub16 -#define __USUB16 __usub16 -#define __UQSUB16 __uqsub16 -#define __UHSUB16 __uhsub16 -#define __SASX __sasx -#define __QASX __qasx -#define __SHASX __shasx -#define __UASX __uasx -#define __UQASX __uqasx -#define __UHASX __uhasx -#define __SSAX __ssax -#define __QSAX __qsax -#define __SHSAX __shsax -#define __USAX __usax -#define __UQSAX __uqsax -#define __UHSAX __uhsax -#define __USAD8 __usad8 -#define __USADA8 __usada8 -#define __SSAT16 __ssat16 -#define __USAT16 __usat16 -#define __UXTB16 __uxtb16 -#define __UXTAB16 __uxtab16 -#define __SXTB16 __sxtb16 -#define __SXTAB16 __sxtab16 -#define __SMUAD __smuad -#define __SMUADX __smuadx -#define __SMLAD __smlad -#define __SMLADX __smladx -#define __SMLALD __smlald -#define __SMLALDX __smlaldx -#define __SMUSD __smusd -#define __SMUSDX __smusdx -#define __SMLSD __smlsd -#define __SMLSDX __smlsdx -#define __SMLSLD __smlsld -#define __SMLSLDX __smlsldx -#define __SEL __sel -#define __QADD __qadd -#define __QSUB __qsub - -#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ - ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) - -#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ - ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) - -#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ - ((int64_t)(ARG3) << 32U) ) >> 32U)) - -#endif /* (__CORTEX_M >= 0x04) */ -/*@} end of group CMSIS_SIMD_intrinsics */ - - -#endif /* __CMSIS_ARMCC_H */ diff --git a/user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h b/user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h deleted file mode 100644 index cd13240..0000000 --- a/user/mpy/lib/cmsis/inc/cmsis_armcc_V6.h +++ /dev/null @@ -1,1800 +0,0 @@ -/**************************************************************************//** - * @file cmsis_armcc_V6.h - * @brief CMSIS Cortex-M Core Function/Instruction Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#ifndef __CMSIS_ARMCC_V6_H -#define __CMSIS_ARMCC_V6_H - - -/* ########################### Core Function Access ########################### */ -/** \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions - @{ - */ - -/** - \brief Enable IRQ Interrupts - \details Enables IRQ interrupts by clearing the I-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void) -{ - __ASM volatile ("cpsie i" : : : "memory"); -} - - -/** - \brief Disable IRQ Interrupts - \details Disables IRQ interrupts by setting the I-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void) -{ - __ASM volatile ("cpsid i" : : : "memory"); -} - - -/** - \brief Get Control Register - \details Returns the content of the Control Register. - \return Control Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, control" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get Control Register (non-secure) - \details Returns the content of the non-secure Control Register when in secure mode. - \return non-secure Control Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Control Register - \details Writes the given value to the Control Register. - \param [in] control Control Register value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control) -{ - __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Control Register (non-secure) - \details Writes the given value to the non-secure Control Register when in secure state. - \param [in] control Control Register value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control) -{ - __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); -} -#endif - - -/** - \brief Get IPSR Register - \details Returns the content of the IPSR Register. - \return IPSR Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get IPSR Register (non-secure) - \details Returns the content of the non-secure IPSR Register when in secure state. - \return IPSR Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_IPSR_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, ipsr_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Get APSR Register - \details Returns the content of the APSR Register. - \return APSR Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, apsr" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get APSR Register (non-secure) - \details Returns the content of the non-secure APSR Register when in secure state. - \return APSR Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_APSR_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, apsr_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Get xPSR Register - \details Returns the content of the xPSR Register. - \return xPSR Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get xPSR Register (non-secure) - \details Returns the content of the non-secure xPSR Register when in secure state. - \return xPSR Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_xPSR_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, xpsr_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Get Process Stack Pointer - \details Returns the current value of the Process Stack Pointer (PSP). - \return PSP Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, psp" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get Process Stack Pointer (non-secure) - \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. - \return PSP Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Process Stack Pointer - \details Assigns the given value to the Process Stack Pointer (PSP). - \param [in] topOfProcStack Process Stack Pointer value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) -{ - __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : "sp"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Process Stack Pointer (non-secure) - \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. - \param [in] topOfProcStack Process Stack Pointer value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) -{ - __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : "sp"); -} -#endif - - -/** - \brief Get Main Stack Pointer - \details Returns the current value of the Main Stack Pointer (MSP). - \return MSP Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, msp" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get Main Stack Pointer (non-secure) - \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. - \return MSP Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Main Stack Pointer - \details Assigns the given value to the Main Stack Pointer (MSP). - \param [in] topOfMainStack Main Stack Pointer value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) -{ - __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : "sp"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Main Stack Pointer (non-secure) - \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. - \param [in] topOfMainStack Main Stack Pointer value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) -{ - __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : "sp"); -} -#endif - - -/** - \brief Get Priority Mask - \details Returns the current state of the priority mask bit from the Priority Mask Register. - \return Priority Mask value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, primask" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get Priority Mask (non-secure) - \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. - \return Priority Mask value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Priority Mask - \details Assigns the given value to the Priority Mask Register. - \param [in] priMask Priority Mask - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) -{ - __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Priority Mask (non-secure) - \details Assigns the given value to the non-secure Priority Mask Register when in secure state. - \param [in] priMask Priority Mask - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) -{ - __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); -} -#endif - - -#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ - -/** - \brief Enable FIQ - \details Enables FIQ interrupts by clearing the F-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__((always_inline)) __STATIC_INLINE void __enable_fault_irq(void) -{ - __ASM volatile ("cpsie f" : : : "memory"); -} - - -/** - \brief Disable FIQ - \details Disables FIQ interrupts by setting the F-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__((always_inline)) __STATIC_INLINE void __disable_fault_irq(void) -{ - __ASM volatile ("cpsid f" : : : "memory"); -} - - -/** - \brief Get Base Priority - \details Returns the current value of the Base Priority register. - \return Base Priority register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, basepri" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get Base Priority (non-secure) - \details Returns the current value of the non-secure Base Priority register when in secure state. - \return Base Priority register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Base Priority - \details Assigns the given value to the Base Priority register. - \param [in] basePri Base Priority value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t value) -{ - __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Base Priority (non-secure) - \details Assigns the given value to the non-secure Base Priority register when in secure state. - \param [in] basePri Base Priority value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t value) -{ - __ASM volatile ("MSR basepri_ns, %0" : : "r" (value) : "memory"); -} -#endif - - -/** - \brief Set Base Priority with condition - \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, - or the new value increases the BASEPRI priority level. - \param [in] basePri Base Priority value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) -{ - __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Base Priority with condition (non_secure) - \details Assigns the given value to the non-secure Base Priority register when in secure state only if BASEPRI masking is disabled, - or the new value increases the BASEPRI priority level. - \param [in] basePri Base Priority value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_MAX_NS(uint32_t value) -{ - __ASM volatile ("MSR basepri_max_ns, %0" : : "r" (value) : "memory"); -} -#endif - - -/** - \brief Get Fault Mask - \details Returns the current value of the Fault Mask register. - \return Fault Mask register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get Fault Mask (non-secure) - \details Returns the current value of the non-secure Fault Mask register when in secure state. - \return Fault Mask register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Fault Mask - \details Assigns the given value to the Fault Mask register. - \param [in] faultMask Fault Mask value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) -{ - __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); -} - - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set Fault Mask (non-secure) - \details Assigns the given value to the non-secure Fault Mask register when in secure state. - \param [in] faultMask Fault Mask value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) -{ - __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); -} -#endif - - -#endif /* ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ - - -#if (__ARM_ARCH_8M__ == 1U) - -/** - \brief Get Process Stack Pointer Limit - \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). - \return PSPLIM Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, psplim" : "=r" (result) ); - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ -/** - \brief Get Process Stack Pointer Limit (non-secure) - \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. - \return PSPLIM Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Process Stack Pointer Limit - \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). - \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) -{ - __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); -} - - -#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ -/** - \brief Set Process Stack Pointer (non-secure) - \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. - \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) -{ - __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); -} -#endif - - -/** - \brief Get Main Stack Pointer Limit - \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). - \return MSPLIM Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, msplim" : "=r" (result) ); - - return(result); -} - - -#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ -/** - \brief Get Main Stack Pointer Limit (non-secure) - \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. - \return MSPLIM Register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); - return(result); -} -#endif - - -/** - \brief Set Main Stack Pointer Limit - \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). - \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) -{ - __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); -} - - -#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ -/** - \brief Set Main Stack Pointer Limit (non-secure) - \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. - \param [in] MainStackPtrLimit Main Stack Pointer value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) -{ - __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); -} -#endif - -#endif /* (__ARM_ARCH_8M__ == 1U) */ - - -#if ((__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=4 */ - -/** - \brief Get FPSCR - \details eturns the current value of the Floating Point Status/Control register. - \return Floating Point Status/Control register value - */ -#define __get_FPSCR __builtin_arm_get_fpscr -#if 0 -__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - uint32_t result; - - __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ - __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); - __ASM volatile (""); - return(result); -#else - return(0); -#endif -} -#endif - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Get FPSCR (non-secure) - \details Returns the current value of the non-secure Floating Point Status/Control register when in secure state. - \return Floating Point Status/Control register value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FPSCR_NS(void) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - uint32_t result; - - __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ - __ASM volatile ("VMRS %0, fpscr_ns" : "=r" (result) ); - __ASM volatile (""); - return(result); -#else - return(0); -#endif -} -#endif - - -/** - \brief Set FPSCR - \details Assigns the given value to the Floating Point Status/Control register. - \param [in] fpscr Floating Point Status/Control value to set - */ -#define __set_FPSCR __builtin_arm_set_fpscr -#if 0 -__attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ - __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); - __ASM volatile (""); -#endif -} -#endif - -#if (__ARM_FEATURE_CMSE == 3U) -/** - \brief Set FPSCR (non-secure) - \details Assigns the given value to the non-secure Floating Point Status/Control register when in secure state. - \param [in] fpscr Floating Point Status/Control value to set - */ -__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FPSCR_NS(uint32_t fpscr) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ - __ASM volatile ("VMSR fpscr_ns, %0" : : "r" (fpscr) : "vfpcc"); - __ASM volatile (""); -#endif -} -#endif - -#endif /* ((__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ - - - -/*@} end of CMSIS_Core_RegAccFunctions */ - - -/* ########################## Core Instruction Access ######################### */ -/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface - Access to dedicated instructions - @{ -*/ - -/* Define macros for porting to both thumb1 and thumb2. - * For thumb1, use low register (r0-r7), specified by constraint "l" - * Otherwise, use general registers, specified by constraint "r" */ -#if defined (__thumb__) && !defined (__thumb2__) -#define __CMSIS_GCC_OUT_REG(r) "=l" (r) -#define __CMSIS_GCC_USE_REG(r) "l" (r) -#else -#define __CMSIS_GCC_OUT_REG(r) "=r" (r) -#define __CMSIS_GCC_USE_REG(r) "r" (r) -#endif - -/** - \brief No Operation - \details No Operation does nothing. This instruction can be used for code alignment purposes. - */ -#define __NOP __builtin_arm_nop - -/** - \brief Wait For Interrupt - \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. - */ -#define __WFI __builtin_arm_wfi - - -/** - \brief Wait For Event - \details Wait For Event is a hint instruction that permits the processor to enter - a low-power state until one of a number of events occurs. - */ -#define __WFE __builtin_arm_wfe - - -/** - \brief Send Event - \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. - */ -#define __SEV __builtin_arm_sev - - -/** - \brief Instruction Synchronization Barrier - \details Instruction Synchronization Barrier flushes the pipeline in the processor, - so that all instructions following the ISB are fetched from cache or memory, - after the instruction has been completed. - */ -#define __ISB() __builtin_arm_isb(0xF); - -/** - \brief Data Synchronization Barrier - \details Acts as a special kind of Data Memory Barrier. - It completes when all explicit memory accesses before this instruction complete. - */ -#define __DSB() __builtin_arm_dsb(0xF); - - -/** - \brief Data Memory Barrier - \details Ensures the apparent order of the explicit memory operations before - and after the instruction, without ensuring their completion. - */ -#define __DMB() __builtin_arm_dmb(0xF); - - -/** - \brief Reverse byte order (32 bit) - \details Reverses the byte order in integer value. - \param [in] value Value to reverse - \return Reversed value - */ -#define __REV __builtin_bswap32 - - -/** - \brief Reverse byte order (16 bit) - \details Reverses the byte order in two unsigned short values. - \param [in] value Value to reverse - \return Reversed value - */ -#define __REV16 __builtin_bswap16 /* ToDo: ARMCC_V6: check if __builtin_bswap16 could be used */ -#if 0 -__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) -{ - uint32_t result; - - __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -} -#endif - - -/** - \brief Reverse byte order in signed short value - \details Reverses the byte order in a signed short value with sign extension to integer. - \param [in] value Value to reverse - \return Reversed value - */ - /* ToDo: ARMCC_V6: check if __builtin_bswap16 could be used */ -__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) -{ - int32_t result; - - __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -} - - -/** - \brief Rotate Right in unsigned value (32 bit) - \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. - \param [in] op1 Value to rotate - \param [in] op2 Number of Bits to rotate - \return Rotated value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) -{ - return (op1 >> op2) | (op1 << (32U - op2)); -} - - -/** - \brief Breakpoint - \details Causes the processor to enter Debug state. - Debug tools can use this to investigate system state when the instruction at a particular address is reached. - \param [in] value is ignored by the processor. - If required, a debugger can use it to store additional information about the breakpoint. - */ -#define __BKPT(value) __ASM volatile ("bkpt "#value) - - -/** - \brief Reverse bit order of value - \details Reverses the bit order of the given value. - \param [in] value Value to reverse - \return Reversed value - */ - /* ToDo: ARMCC_V6: check if __builtin_arm_rbit is supported */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) -{ - uint32_t result; - -#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ - __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); -#else - int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ - - result = value; /* r will be reversed bits of v; first get LSB of v */ - for (value >>= 1U; value; value >>= 1U) - { - result <<= 1U; - result |= value & 1U; - s--; - } - result <<= s; /* shift when v's highest bits are zero */ -#endif - return(result); -} - - -/** - \brief Count leading zeros - \details Counts the number of leading zeros of a data value. - \param [in] value Value to count the leading zeros - \return number of leading zeros in value - */ -#define __CLZ __builtin_clz - - -#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ - -/** - \brief LDR Exclusive (8 bit) - \details Executes a exclusive LDR instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -#define __LDREXB (uint8_t)__builtin_arm_ldrex - - -/** - \brief LDR Exclusive (16 bit) - \details Executes a exclusive LDR instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -#define __LDREXH (uint16_t)__builtin_arm_ldrex - - -/** - \brief LDR Exclusive (32 bit) - \details Executes a exclusive LDR instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -#define __LDREXW (uint32_t)__builtin_arm_ldrex - - -/** - \brief STR Exclusive (8 bit) - \details Executes a exclusive STR instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#define __STREXB (uint32_t)__builtin_arm_strex - - -/** - \brief STR Exclusive (16 bit) - \details Executes a exclusive STR instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#define __STREXH (uint32_t)__builtin_arm_strex - - -/** - \brief STR Exclusive (32 bit) - \details Executes a exclusive STR instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#define __STREXW (uint32_t)__builtin_arm_strex - - -/** - \brief Remove the exclusive lock - \details Removes the exclusive lock which is created by LDREX. - */ -#define __CLREX __builtin_arm_clrex - - -/** - \brief Signed Saturate - \details Saturates a signed value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (1..32) - \return Saturated value - */ -/*#define __SSAT __builtin_arm_ssat*/ -#define __SSAT(ARG1,ARG2) \ -({ \ - int32_t __RES, __ARG1 = (ARG1); \ - __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - - -/** - \brief Unsigned Saturate - \details Saturates an unsigned value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (0..31) - \return Saturated value - */ -#define __USAT __builtin_arm_usat -#if 0 -#define __USAT(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) -#endif - - -/** - \brief Rotate Right with Extend (32 bit) - \details Moves each bit of a bitstring right by one bit. - The carry input is shifted in at the left end of the bitstring. - \param [in] value Value to rotate - \return Rotated value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) -{ - uint32_t result; - - __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -} - - -/** - \brief LDRT Unprivileged (8 bit) - \details Executes a Unprivileged LDRT instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr) -{ - uint32_t result; - - __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); - return ((uint8_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDRT Unprivileged (16 bit) - \details Executes a Unprivileged LDRT instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr) -{ - uint32_t result; - - __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); - return ((uint16_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDRT Unprivileged (32 bit) - \details Executes a Unprivileged LDRT instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr) -{ - uint32_t result; - - __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); - return(result); -} - - -/** - \brief STRT Unprivileged (8 bit) - \details Executes a Unprivileged STRT instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) -{ - __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); -} - - -/** - \brief STRT Unprivileged (16 bit) - \details Executes a Unprivileged STRT instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) -{ - __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); -} - - -/** - \brief STRT Unprivileged (32 bit) - \details Executes a Unprivileged STRT instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr) -{ - __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); -} - -#endif /* ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ - - -#if (__ARM_ARCH_8M__ == 1U) - -/** - \brief Load-Acquire (8 bit) - \details Executes a LDAB instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr) -{ - uint32_t result; - - __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); - return ((uint8_t) result); -} - - -/** - \brief Load-Acquire (16 bit) - \details Executes a LDAH instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr) -{ - uint32_t result; - - __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) ); - return ((uint16_t) result); -} - - -/** - \brief Load-Acquire (32 bit) - \details Executes a LDA instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr) -{ - uint32_t result; - - __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) ); - return(result); -} - - -/** - \brief Store-Release (8 bit) - \details Executes a STLB instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr) -{ - __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); -} - - -/** - \brief Store-Release (16 bit) - \details Executes a STLH instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr) -{ - __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); -} - - -/** - \brief Store-Release (32 bit) - \details Executes a STL instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr) -{ - __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); -} - - -/** - \brief Load-Acquire Exclusive (8 bit) - \details Executes a LDAB exclusive instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -#define __LDAEXB (uint8_t)__builtin_arm_ldaex - - -/** - \brief Load-Acquire Exclusive (16 bit) - \details Executes a LDAH exclusive instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -#define __LDAEXH (uint16_t)__builtin_arm_ldaex - - -/** - \brief Load-Acquire Exclusive (32 bit) - \details Executes a LDA exclusive instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -#define __LDAEX (uint32_t)__builtin_arm_ldaex - - -/** - \brief Store-Release Exclusive (8 bit) - \details Executes a STLB exclusive instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#define __STLEXB (uint32_t)__builtin_arm_stlex - - -/** - \brief Store-Release Exclusive (16 bit) - \details Executes a STLH exclusive instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#define __STLEXH (uint32_t)__builtin_arm_stlex - - -/** - \brief Store-Release Exclusive (32 bit) - \details Executes a STL exclusive instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -#define __STLEX (uint32_t)__builtin_arm_stlex - -#endif /* (__ARM_ARCH_8M__ == 1U) */ - -/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ - - -/* ################### Compiler specific Intrinsics ########################### */ -/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics - Access to dedicated SIMD instructions - @{ -*/ - -#if (__ARM_FEATURE_DSP == 1U) /* ToDo: ARMCC_V6: This should be ARCH >= ARMv7-M + SIMD */ - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -#define __SSAT16(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - -#define __USAT16(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) -{ - uint32_t result; - - __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) -{ - uint32_t result; - - __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) -{ - int32_t result; - - __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) -{ - int32_t result; - - __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -#define __PKHBT(ARG1,ARG2,ARG3) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ - __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ - __RES; \ - }) - -#define __PKHTB(ARG1,ARG2,ARG3) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ - if (ARG3 == 0) \ - __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ - else \ - __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ - __RES; \ - }) - -__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) -{ - int32_t result; - - __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -#endif /* (__ARM_FEATURE_DSP == 1U) */ -/*@} end of group CMSIS_SIMD_intrinsics */ - - -#endif /* __CMSIS_ARMCC_V6_H */ diff --git a/user/mpy/lib/cmsis/inc/cmsis_gcc.h b/user/mpy/lib/cmsis/inc/cmsis_gcc.h deleted file mode 100644 index bb89fbb..0000000 --- a/user/mpy/lib/cmsis/inc/cmsis_gcc.h +++ /dev/null @@ -1,1373 +0,0 @@ -/**************************************************************************//** - * @file cmsis_gcc.h - * @brief CMSIS Cortex-M Core Function/Instruction Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#ifndef __CMSIS_GCC_H -#define __CMSIS_GCC_H - -/* ignore some GCC warnings */ -#if defined ( __GNUC__ ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - - -/* ########################### Core Function Access ########################### */ -/** \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions - @{ - */ - -/** - \brief Enable IRQ Interrupts - \details Enables IRQ interrupts by clearing the I-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) -{ - __ASM volatile ("cpsie i" : : : "memory"); -} - - -/** - \brief Disable IRQ Interrupts - \details Disables IRQ interrupts by setting the I-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) -{ - __ASM volatile ("cpsid i" : : : "memory"); -} - - -/** - \brief Get Control Register - \details Returns the content of the Control Register. - \return Control Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, control" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Control Register - \details Writes the given value to the Control Register. - \param [in] control Control Register value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) -{ - __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); -} - - -/** - \brief Get IPSR Register - \details Returns the content of the IPSR Register. - \return IPSR Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); - return(result); -} - - -/** - \brief Get APSR Register - \details Returns the content of the APSR Register. - \return APSR Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, apsr" : "=r" (result) ); - return(result); -} - - -/** - \brief Get xPSR Register - \details Returns the content of the xPSR Register. - - \return xPSR Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); - return(result); -} - - -/** - \brief Get Process Stack Pointer - \details Returns the current value of the Process Stack Pointer (PSP). - \return PSP Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Process Stack Pointer - \details Assigns the given value to the Process Stack Pointer (PSP). - \param [in] topOfProcStack Process Stack Pointer value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) -{ - __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); -} - - -/** - \brief Get Main Stack Pointer - \details Returns the current value of the Main Stack Pointer (MSP). - \return MSP Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Main Stack Pointer - \details Assigns the given value to the Main Stack Pointer (MSP). - - \param [in] topOfMainStack Main Stack Pointer value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) -{ - __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); -} - - -/** - \brief Get Priority Mask - \details Returns the current state of the priority mask bit from the Priority Mask Register. - \return Priority Mask value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, primask" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Priority Mask - \details Assigns the given value to the Priority Mask Register. - \param [in] priMask Priority Mask - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) -{ - __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); -} - - -#if (__CORTEX_M >= 0x03U) - -/** - \brief Enable FIQ - \details Enables FIQ interrupts by clearing the F-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) -{ - __ASM volatile ("cpsie f" : : : "memory"); -} - - -/** - \brief Disable FIQ - \details Disables FIQ interrupts by setting the F-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void) -{ - __ASM volatile ("cpsid f" : : : "memory"); -} - - -/** - \brief Get Base Priority - \details Returns the current value of the Base Priority register. - \return Base Priority register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, basepri" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Base Priority - \details Assigns the given value to the Base Priority register. - \param [in] basePri Base Priority value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) -{ - __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); -} - - -/** - \brief Set Base Priority with condition - \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, - or the new value increases the BASEPRI priority level. - \param [in] basePri Base Priority value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) -{ - __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); -} - - -/** - \brief Get Fault Mask - \details Returns the current value of the Fault Mask register. - \return Fault Mask register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Fault Mask - \details Assigns the given value to the Fault Mask register. - \param [in] faultMask Fault Mask value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) -{ - __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); -} - -#endif /* (__CORTEX_M >= 0x03U) */ - - -#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) - -/** - \brief Get FPSCR - \details Returns the current value of the Floating Point Status/Control register. - \return Floating Point Status/Control register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - uint32_t result; - - /* Empty asm statement works as a scheduling barrier */ - __ASM volatile (""); - __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); - __ASM volatile (""); - return(result); -#else - return(0); -#endif -} - - -/** - \brief Set FPSCR - \details Assigns the given value to the Floating Point Status/Control register. - \param [in] fpscr Floating Point Status/Control value to set - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) -{ -#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) - /* Empty asm statement works as a scheduling barrier */ - __ASM volatile (""); - __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); - __ASM volatile (""); -#endif -} - -#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ - - - -/*@} end of CMSIS_Core_RegAccFunctions */ - - -/* ########################## Core Instruction Access ######################### */ -/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface - Access to dedicated instructions - @{ -*/ - -/* Define macros for porting to both thumb1 and thumb2. - * For thumb1, use low register (r0-r7), specified by constraint "l" - * Otherwise, use general registers, specified by constraint "r" */ -#if defined (__thumb__) && !defined (__thumb2__) -#define __CMSIS_GCC_OUT_REG(r) "=l" (r) -#define __CMSIS_GCC_USE_REG(r) "l" (r) -#else -#define __CMSIS_GCC_OUT_REG(r) "=r" (r) -#define __CMSIS_GCC_USE_REG(r) "r" (r) -#endif - -/** - \brief No Operation - \details No Operation does nothing. This instruction can be used for code alignment purposes. - */ -__attribute__((always_inline)) __STATIC_INLINE void __NOP(void) -{ - __ASM volatile ("nop"); -} - - -/** - \brief Wait For Interrupt - \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. - */ -__attribute__((always_inline)) __STATIC_INLINE void __WFI(void) -{ - __ASM volatile ("wfi"); -} - - -/** - \brief Wait For Event - \details Wait For Event is a hint instruction that permits the processor to enter - a low-power state until one of a number of events occurs. - */ -__attribute__((always_inline)) __STATIC_INLINE void __WFE(void) -{ - __ASM volatile ("wfe"); -} - - -/** - \brief Send Event - \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. - */ -__attribute__((always_inline)) __STATIC_INLINE void __SEV(void) -{ - __ASM volatile ("sev"); -} - - -/** - \brief Instruction Synchronization Barrier - \details Instruction Synchronization Barrier flushes the pipeline in the processor, - so that all instructions following the ISB are fetched from cache or memory, - after the instruction has been completed. - */ -__attribute__((always_inline)) __STATIC_INLINE void __ISB(void) -{ - __ASM volatile ("isb 0xF":::"memory"); -} - - -/** - \brief Data Synchronization Barrier - \details Acts as a special kind of Data Memory Barrier. - It completes when all explicit memory accesses before this instruction complete. - */ -__attribute__((always_inline)) __STATIC_INLINE void __DSB(void) -{ - __ASM volatile ("dsb 0xF":::"memory"); -} - - -/** - \brief Data Memory Barrier - \details Ensures the apparent order of the explicit memory operations before - and after the instruction, without ensuring their completion. - */ -__attribute__((always_inline)) __STATIC_INLINE void __DMB(void) -{ - __ASM volatile ("dmb 0xF":::"memory"); -} - - -/** - \brief Reverse byte order (32 bit) - \details Reverses the byte order in integer value. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) -{ -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) - return __builtin_bswap32(value); -#else - uint32_t result; - - __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -#endif -} - - -/** - \brief Reverse byte order (16 bit) - \details Reverses the byte order in two unsigned short values. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) -{ - uint32_t result; - - __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -} - - -/** - \brief Reverse byte order in signed short value - \details Reverses the byte order in a signed short value with sign extension to integer. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) -{ -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - return (short)__builtin_bswap16(value); -#else - int32_t result; - - __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -#endif -} - - -/** - \brief Rotate Right in unsigned value (32 bit) - \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. - \param [in] value Value to rotate - \param [in] value Number of Bits to rotate - \return Rotated value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) -{ - return (op1 >> op2) | (op1 << (32U - op2)); -} - - -/** - \brief Breakpoint - \details Causes the processor to enter Debug state. - Debug tools can use this to investigate system state when the instruction at a particular address is reached. - \param [in] value is ignored by the processor. - If required, a debugger can use it to store additional information about the breakpoint. - */ -#define __BKPT(value) __ASM volatile ("bkpt "#value) - - -/** - \brief Reverse bit order of value - \details Reverses the bit order of the given value. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) -{ - uint32_t result; - -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); -#else - int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ - - result = value; /* r will be reversed bits of v; first get LSB of v */ - for (value >>= 1U; value; value >>= 1U) - { - result <<= 1U; - result |= value & 1U; - s--; - } - result <<= s; /* shift when v's highest bits are zero */ -#endif - return(result); -} - - -/** - \brief Count leading zeros - \details Counts the number of leading zeros of a data value. - \param [in] value Value to count the leading zeros - \return number of leading zeros in value - */ -#define __CLZ __builtin_clz - - -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - -/** - \brief LDR Exclusive (8 bit) - \details Executes a exclusive LDR instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); -#else - /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not - accepted by assembler. So has to use following less efficient pattern. - */ - __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); -#endif - return ((uint8_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDR Exclusive (16 bit) - \details Executes a exclusive LDR instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); -#else - /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not - accepted by assembler. So has to use following less efficient pattern. - */ - __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); -#endif - return ((uint16_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDR Exclusive (32 bit) - \details Executes a exclusive LDR instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr) -{ - uint32_t result; - - __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); - return(result); -} - - -/** - \brief STR Exclusive (8 bit) - \details Executes a exclusive STR instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) -{ - uint32_t result; - - __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); - return(result); -} - - -/** - \brief STR Exclusive (16 bit) - \details Executes a exclusive STR instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) -{ - uint32_t result; - - __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); - return(result); -} - - -/** - \brief STR Exclusive (32 bit) - \details Executes a exclusive STR instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - \return 0 Function succeeded - \return 1 Function failed - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) -{ - uint32_t result; - - __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); - return(result); -} - - -/** - \brief Remove the exclusive lock - \details Removes the exclusive lock which is created by LDREX. - */ -__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) -{ - __ASM volatile ("clrex" ::: "memory"); -} - - -/** - \brief Signed Saturate - \details Saturates a signed value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (1..32) - \return Saturated value - */ -#define __SSAT(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - - -/** - \brief Unsigned Saturate - \details Saturates an unsigned value. - \param [in] value Value to be saturated - \param [in] sat Bit position to saturate to (0..31) - \return Saturated value - */ -#define __USAT(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - - -/** - \brief Rotate Right with Extend (32 bit) - \details Moves each bit of a bitstring right by one bit. - The carry input is shifted in at the left end of the bitstring. - \param [in] value Value to rotate - \return Rotated value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) -{ - uint32_t result; - - __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -} - - -/** - \brief LDRT Unprivileged (8 bit) - \details Executes a Unprivileged LDRT instruction for 8 bit value. - \param [in] ptr Pointer to data - \return value of type uint8_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) ); -#else - /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not - accepted by assembler. So has to use following less efficient pattern. - */ - __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); -#endif - return ((uint8_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDRT Unprivileged (16 bit) - \details Executes a Unprivileged LDRT instruction for 16 bit values. - \param [in] ptr Pointer to data - \return value of type uint16_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) ); -#else - /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not - accepted by assembler. So has to use following less efficient pattern. - */ - __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); -#endif - return ((uint16_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDRT Unprivileged (32 bit) - \details Executes a Unprivileged LDRT instruction for 32 bit values. - \param [in] ptr Pointer to data - \return value of type uint32_t at (*ptr) - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr) -{ - uint32_t result; - - __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) ); - return(result); -} - - -/** - \brief STRT Unprivileged (8 bit) - \details Executes a Unprivileged STRT instruction for 8 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr) -{ - __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); -} - - -/** - \brief STRT Unprivileged (16 bit) - \details Executes a Unprivileged STRT instruction for 16 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr) -{ - __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); -} - - -/** - \brief STRT Unprivileged (32 bit) - \details Executes a Unprivileged STRT instruction for 32 bit values. - \param [in] value Value to store - \param [in] ptr Pointer to location - */ -__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr) -{ - __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) ); -} - -#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ - -/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ - - -/* ################### Compiler specific Intrinsics ########################### */ -/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics - Access to dedicated SIMD instructions - @{ -*/ - -#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -#define __SSAT16(ARG1,ARG2) \ -({ \ - int32_t __RES, __ARG1 = (ARG1); \ - __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - -#define __USAT16(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) -{ - uint32_t result; - - __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) -{ - uint32_t result; - - __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) -{ - int32_t result; - - __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) -{ - int32_t result; - - __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -#define __PKHBT(ARG1,ARG2,ARG3) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ - __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ - __RES; \ - }) - -#define __PKHTB(ARG1,ARG2,ARG3) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ - if (ARG3 == 0) \ - __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ - else \ - __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ - __RES; \ - }) - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) -{ - int32_t result; - - __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -#endif /* (__CORTEX_M >= 0x04) */ -/*@} end of group CMSIS_SIMD_intrinsics */ - - -#if defined ( __GNUC__ ) -#pragma GCC diagnostic pop -#endif - -#endif /* __CMSIS_GCC_H */ diff --git a/user/mpy/lib/cmsis/inc/core_cm0.h b/user/mpy/lib/cmsis/inc/core_cm0.h deleted file mode 100644 index 711dad5..0000000 --- a/user/mpy/lib/cmsis/inc/core_cm0.h +++ /dev/null @@ -1,798 +0,0 @@ -/**************************************************************************//** - * @file core_cm0.h - * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CM0_H_GENERIC -#define __CORE_CM0_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup Cortex_M0 - @{ - */ - -/* CMSIS CM0 definitions */ -#define __CM0_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM0_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ - __CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x00U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - This core does not support an FPU at all -*/ -#define __FPU_USED 0U - -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM0_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_CM0_H_DEPENDANT -#define __CORE_CM0_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __CM0_REV - #define __CM0_REV 0x0000U - #warning "__CM0_REV not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 2U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group Cortex_M0 */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t _reserved0:1; /*!< bit: 0 Reserved */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[31U]; - __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[31U]; - __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[31U]; - __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[31U]; - uint32_t RESERVED4[64U]; - __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ -} NVIC_Type; - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ - uint32_t RESERVED0; - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - uint32_t RESERVED1; - __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. - Therefore they are not covered by the Cortex-M0 header file. - @{ - */ -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of Cortex-M0 Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ - - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/* Interrupt Priorities are WORD accessible only under ARMv6M */ -/* The following MACROS handle generation of the register offset and byte masks */ -#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) -#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) -#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | - (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); - } - else - { - NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | - (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - SCB_AIRCR_SYSRESETREQ_Msk); - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM0_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm0plus.h b/user/mpy/lib/cmsis/inc/core_cm0plus.h deleted file mode 100644 index b04aa39..0000000 --- a/user/mpy/lib/cmsis/inc/core_cm0plus.h +++ /dev/null @@ -1,914 +0,0 @@ -/**************************************************************************//** - * @file core_cm0plus.h - * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CM0PLUS_H_GENERIC -#define __CORE_CM0PLUS_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup Cortex-M0+ - @{ - */ - -/* CMSIS CM0+ definitions */ -#define __CM0PLUS_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM0PLUS_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ - __CM0PLUS_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x00U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - This core does not support an FPU at all -*/ -#define __FPU_USED 0U - -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM0PLUS_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_CM0PLUS_H_DEPENDANT -#define __CORE_CM0PLUS_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __CM0PLUS_REV - #define __CM0PLUS_REV 0x0000U - #warning "__CM0PLUS_REV not defined in device header file; using default!" - #endif - - #ifndef __MPU_PRESENT - #define __MPU_PRESENT 0U - #warning "__MPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __VTOR_PRESENT - #define __VTOR_PRESENT 0U - #warning "__VTOR_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 2U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group Cortex-M0+ */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - - Core MPU Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ -#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[31U]; - __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[31U]; - __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[31U]; - __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[31U]; - uint32_t RESERVED4[64U]; - __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ -} NVIC_Type; - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ -#if (__VTOR_PRESENT == 1U) - __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ -#else - uint32_t RESERVED0; -#endif - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - uint32_t RESERVED1; - __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -#if (__VTOR_PRESENT == 1U) -/* SCB Interrupt Control State Register Definitions */ -#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ -#endif - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - -#if (__MPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_MPU Memory Protection Unit (MPU) - \brief Type definitions for the Memory Protection Unit (MPU) - @{ - */ - -/** - \brief Structure type to access the Memory Protection Unit (MPU). - */ -typedef struct -{ - __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ - __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ - __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ - __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ - __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ -} MPU_Type; - -/* MPU Type Register Definitions */ -#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ -#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ - -#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ -#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ - -#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ -#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ - -/* MPU Control Register Definitions */ -#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ -#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ - -#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ -#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ - -#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ -#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ - -/* MPU Region Number Register Definitions */ -#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ -#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ - -/* MPU Region Base Address Register Definitions */ -#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ -#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ - -#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ -#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ - -#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ -#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ - -/* MPU Region Attribute and Size Register Definitions */ -#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ -#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ - -#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ -#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ - -#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ -#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ - -#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ -#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ - -#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ -#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ - -#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ -#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ - -#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ -#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ - -#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ -#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ - -#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ -#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ - -#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ -#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ - -/*@} end of group CMSIS_MPU */ -#endif - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. - Therefore they are not covered by the Cortex-M0+ header file. - @{ - */ -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of Cortex-M0+ Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ - -#if (__MPU_PRESENT == 1U) - #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ -#endif - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/* Interrupt Priorities are WORD accessible only under ARMv6M */ -/* The following MACROS handle generation of the register offset and byte masks */ -#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) -#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) -#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | - (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); - } - else - { - NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | - (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - SCB_AIRCR_SYSRESETREQ_Msk); - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM0PLUS_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm3.h b/user/mpy/lib/cmsis/inc/core_cm3.h deleted file mode 100644 index b4ac4c7..0000000 --- a/user/mpy/lib/cmsis/inc/core_cm3.h +++ /dev/null @@ -1,1763 +0,0 @@ -/**************************************************************************//** - * @file core_cm3.h - * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CM3_H_GENERIC -#define __CORE_CM3_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup Cortex_M3 - @{ - */ - -/* CMSIS CM3 definitions */ -#define __CM3_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM3_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ - __CM3_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x03U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - This core does not support an FPU at all -*/ -#define __FPU_USED 0U - -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM3_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_CM3_H_DEPENDANT -#define __CORE_CM3_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __CM3_REV - #define __CM3_REV 0x0200U - #warning "__CM3_REV not defined in device header file; using default!" - #endif - - #ifndef __MPU_PRESENT - #define __MPU_PRESENT 0U - #warning "__MPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 4U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group Cortex_M3 */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - - Core Debug Register - - Core MPU Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - -#define APSR_Q_Pos 27U /*!< APSR: Q Position */ -#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ -#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ - -#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ -#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ -#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[24U]; - __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[24U]; - __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[24U]; - __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[24U]; - __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ - uint32_t RESERVED4[56U]; - __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ - uint32_t RESERVED5[644U]; - __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ -} NVIC_Type; - -/* Software Triggered Interrupt Register Definitions */ -#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ -#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ - __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ - __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ - __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ - __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ - __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ - __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ - __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ - __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ - __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ - __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ - __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ - __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ - uint32_t RESERVED0[5U]; - __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ -#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -/* SCB Vector Table Offset Register Definitions */ -#if (__CM3_REV < 0x0201U) /* core r2p1 */ -#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ -#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ - -#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ -#else -#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ -#endif - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ -#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ -#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ -#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ - -#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ -#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ -#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ - -#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ -#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ -#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ - -#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ -#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ - -#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ -#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ - -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ -#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ - -#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ -#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ - -#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ -#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ - -#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ -#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ - -#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ -#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ - -#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ -#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ - -#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ -#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ - -#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ -#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ - -#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ -#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ - -#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ -#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ - -/* SCB Configurable Fault Status Register Definitions */ -#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ -#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ - -#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ -#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ - -#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ -#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ - -/* SCB Hard Fault Status Register Definitions */ -#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ -#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ - -#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ -#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ - -#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ -#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ - -/* SCB Debug Fault Status Register Definitions */ -#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ -#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ - -#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ -#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ - -#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ -#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ - -#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ -#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ - -#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ -#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) - \brief Type definitions for the System Control and ID Register not in the SCB - @{ - */ - -/** - \brief Structure type to access the System Control and ID Register not in the SCB. - */ -typedef struct -{ - uint32_t RESERVED0[1U]; - __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ -#if ((defined __CM3_REV) && (__CM3_REV >= 0x200U)) - __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ -#else - uint32_t RESERVED1[1U]; -#endif -} SCnSCB_Type; - -/* Interrupt Controller Type Register Definitions */ -#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ -#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ - -/* Auxiliary Control Register Definitions */ - -#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ -#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ - -#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ -#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ - -#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ -#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ - -/*@} end of group CMSIS_SCnotSCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) - \brief Type definitions for the Instrumentation Trace Macrocell (ITM) - @{ - */ - -/** - \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). - */ -typedef struct -{ - __OM union - { - __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ - __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ - __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ - } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ - uint32_t RESERVED0[864U]; - __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ - uint32_t RESERVED1[15U]; - __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ - uint32_t RESERVED2[15U]; - __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ - uint32_t RESERVED3[29U]; - __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ - __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ - __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ - uint32_t RESERVED4[43U]; - __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ - __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ - uint32_t RESERVED5[6U]; - __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ - __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ - __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ - __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ - __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ - __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ - __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ - __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ - __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ - __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ - __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ - __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ -} ITM_Type; - -/* ITM Trace Privilege Register Definitions */ -#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ -#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ - -/* ITM Trace Control Register Definitions */ -#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ -#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ - -#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ -#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ - -#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ -#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ - -#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ -#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ - -#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ -#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ - -#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ -#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ - -#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ -#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ - -#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ -#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ - -#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ -#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ - -/* ITM Integration Write Register Definitions */ -#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ -#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ - -/* ITM Integration Read Register Definitions */ -#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ -#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ - -/* ITM Integration Mode Control Register Definitions */ -#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ -#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ - -/* ITM Lock Status Register Definitions */ -#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ -#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ - -#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ -#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ - -#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ -#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ - -/*@}*/ /* end of group CMSIS_ITM */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) - \brief Type definitions for the Data Watchpoint and Trace (DWT) - @{ - */ - -/** - \brief Structure type to access the Data Watchpoint and Trace Register (DWT). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ - __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ - __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ - __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ - __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ - __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ - __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ - __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ - __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ - __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ - uint32_t RESERVED0[1U]; - __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ - __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ - __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ - uint32_t RESERVED1[1U]; - __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ - __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ - __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ - uint32_t RESERVED2[1U]; - __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ - __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ - __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ -} DWT_Type; - -/* DWT Control Register Definitions */ -#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ -#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ - -#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ -#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ - -#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ -#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ - -#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ -#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ - -#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ -#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ - -#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ -#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ - -#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ -#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ - -#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ -#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ - -#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ -#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ - -#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ -#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ - -#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ -#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ - -#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ -#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ - -#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ -#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ - -#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ -#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ - -#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ -#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ - -#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ -#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ - -#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ -#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ - -#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ -#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ - -/* DWT CPI Count Register Definitions */ -#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ -#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ - -/* DWT Exception Overhead Count Register Definitions */ -#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ -#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ - -/* DWT Sleep Count Register Definitions */ -#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ -#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ - -/* DWT LSU Count Register Definitions */ -#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ -#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ - -/* DWT Folded-instruction Count Register Definitions */ -#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ -#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ - -/* DWT Comparator Mask Register Definitions */ -#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ -#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ - -/* DWT Comparator Function Register Definitions */ -#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ -#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ - -#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ -#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ - -#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ -#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ - -#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ -#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ - -#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ -#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ - -#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ -#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ - -#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ -#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ - -#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ -#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ - -#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ -#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ - -/*@}*/ /* end of group CMSIS_DWT */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_TPI Trace Port Interface (TPI) - \brief Type definitions for the Trace Port Interface (TPI) - @{ - */ - -/** - \brief Structure type to access the Trace Port Interface Register (TPI). - */ -typedef struct -{ - __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ - __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ - uint32_t RESERVED0[2U]; - __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ - uint32_t RESERVED1[55U]; - __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ - uint32_t RESERVED2[131U]; - __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ - __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ - __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ - uint32_t RESERVED3[759U]; - __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ - __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ - __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ - uint32_t RESERVED4[1U]; - __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ - __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ - __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ - uint32_t RESERVED5[39U]; - __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ - __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ - uint32_t RESERVED7[8U]; - __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ - __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ -} TPI_Type; - -/* TPI Asynchronous Clock Prescaler Register Definitions */ -#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ -#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ - -/* TPI Selected Pin Protocol Register Definitions */ -#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ -#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ - -/* TPI Formatter and Flush Status Register Definitions */ -#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ -#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ - -#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ -#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ - -#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ -#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ - -#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ -#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ - -/* TPI Formatter and Flush Control Register Definitions */ -#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ -#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ - -#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ -#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ - -/* TPI TRIGGER Register Definitions */ -#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ -#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ - -/* TPI Integration ETM Data Register Definitions (FIFO0) */ -#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ -#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ - -#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ -#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ - -#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ -#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ - -#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ -#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ - -#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ -#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ - -#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ -#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ - -#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ -#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ - -/* TPI ITATBCTR2 Register Definitions */ -#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ -#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ - -/* TPI Integration ITM Data Register Definitions (FIFO1) */ -#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ -#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ - -#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ -#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ - -#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ -#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ - -#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ -#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ - -#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ -#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ - -#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ -#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ - -#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ -#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ - -/* TPI ITATBCTR0 Register Definitions */ -#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ -#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ - -/* TPI Integration Mode Control Register Definitions */ -#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ -#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ - -/* TPI DEVID Register Definitions */ -#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ -#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ - -#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ -#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ - -#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ -#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ - -#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ -#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ - -#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ -#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ - -#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ -#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ - -/* TPI DEVTYPE Register Definitions */ -#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ -#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ - -#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ -#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ - -/*@}*/ /* end of group CMSIS_TPI */ - - -#if (__MPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_MPU Memory Protection Unit (MPU) - \brief Type definitions for the Memory Protection Unit (MPU) - @{ - */ - -/** - \brief Structure type to access the Memory Protection Unit (MPU). - */ -typedef struct -{ - __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ - __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ - __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ - __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ - __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ - __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ - __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ - __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ - __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ -} MPU_Type; - -/* MPU Type Register Definitions */ -#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ -#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ - -#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ -#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ - -#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ -#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ - -/* MPU Control Register Definitions */ -#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ -#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ - -#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ -#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ - -#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ -#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ - -/* MPU Region Number Register Definitions */ -#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ -#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ - -/* MPU Region Base Address Register Definitions */ -#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ -#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ - -#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ -#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ - -#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ -#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ - -/* MPU Region Attribute and Size Register Definitions */ -#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ -#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ - -#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ -#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ - -#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ -#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ - -#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ -#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ - -#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ -#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ - -#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ -#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ - -#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ -#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ - -#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ -#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ - -#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ -#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ - -#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ -#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ - -/*@} end of group CMSIS_MPU */ -#endif - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief Type definitions for the Core Debug Registers - @{ - */ - -/** - \brief Structure type to access the Core Debug Register (CoreDebug). - */ -typedef struct -{ - __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ - __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ - __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ - __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ -} CoreDebug_Type; - -/* Debug Halting Control and Status Register Definitions */ -#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ -#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ - -#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ -#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ - -#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ -#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ - -#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ -#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ - -#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ -#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ - -#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ -#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ - -#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ -#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ - -#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ -#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ - -#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ -#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ - -#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ -#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ - -#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ -#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ - -#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ -#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ - -/* Debug Core Register Selector Register Definitions */ -#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ -#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ - -#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ -#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ - -/* Debug Exception and Monitor Control Register Definitions */ -#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ -#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ - -#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ -#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ - -#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ -#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ - -#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ -#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ - -#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ -#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ - -#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ -#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ - -#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ -#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ - -#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ -#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ - -#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ -#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ - -#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ -#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ - -#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ -#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ - -#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ -#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ - -#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ -#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ - -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of Cortex-M3 Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ -#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ -#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ -#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ -#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ -#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ -#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ -#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ - -#if (__MPU_PRESENT == 1U) - #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ -#endif - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Debug Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/** - \brief Set Priority Grouping - \details Sets the priority grouping field using the required unlock sequence. - The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. - Only values from 0..7 are used. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Priority grouping field. - */ -__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) -{ - uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ - reg_value = (reg_value | - ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ - SCB->AIRCR = reg_value; -} - - -/** - \brief Get Priority Grouping - \details Reads the priority grouping field from the NVIC Interrupt Controller. - \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). - */ -__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) -{ - return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); -} - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Active Interrupt - \details Reads the active register in NVIC and returns the active bit. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not active. - \return 1 Interrupt status is active. - */ -__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } - else - { - NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief Encode Priority - \details Encodes the priority for an interrupt with the given priority group, - preemptive priority value, and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Used priority group. - \param [in] PreemptPriority Preemptive priority value (starting from 0). - \param [in] SubPriority Subpriority value (starting from 0). - \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). - */ -__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - return ( - ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | - ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) - ); -} - - -/** - \brief Decode Priority - \details Decodes an interrupt priority value with a given priority group to - preemptive priority value and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. - \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). - \param [in] PriorityGroup Used priority group. - \param [out] pPreemptPriority Preemptive priority value (starting from 0). - \param [out] pSubPriority Subpriority value (starting from 0). - */ -__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); - *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | - SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - -/* ##################################### Debug In/Output function ########################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_core_DebugFunctions ITM Functions - \brief Functions that access the ITM debug interface. - @{ - */ - -extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ -#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ - - -/** - \brief ITM Send Character - \details Transmits a character via the ITM channel 0, and - \li Just returns when no debugger is connected that has booked the output. - \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. - \param [in] ch Character to transmit. - \returns Character to transmit. - */ -__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) -{ - if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ - ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ - { - while (ITM->PORT[0U].u32 == 0UL) - { - __NOP(); - } - ITM->PORT[0U].u8 = (uint8_t)ch; - } - return (ch); -} - - -/** - \brief ITM Receive Character - \details Inputs a character via the external variable \ref ITM_RxBuffer. - \return Received character. - \return -1 No character pending. - */ -__STATIC_INLINE int32_t ITM_ReceiveChar (void) -{ - int32_t ch = -1; /* no character available */ - - if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) - { - ch = ITM_RxBuffer; - ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ - } - - return (ch); -} - - -/** - \brief ITM Check Character - \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. - \return 0 No character available. - \return 1 Character available. - */ -__STATIC_INLINE int32_t ITM_CheckChar (void) -{ - - if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) - { - return (0); /* no character available */ - } - else - { - return (1); /* character available */ - } -} - -/*@} end of CMSIS_core_DebugFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM3_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm4.h b/user/mpy/lib/cmsis/inc/core_cm4.h deleted file mode 100644 index dc840eb..0000000 --- a/user/mpy/lib/cmsis/inc/core_cm4.h +++ /dev/null @@ -1,1937 +0,0 @@ -/**************************************************************************//** - * @file core_cm4.h - * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CM4_H_GENERIC -#define __CORE_CM4_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup Cortex_M4 - @{ - */ - -/* CMSIS CM4 definitions */ -#define __CM4_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM4_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ - __CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x04U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. -*/ -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #if (__FPU_PRESENT == 1) - #define __FPU_USED 1U - #else - #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ -#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM4_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_CM4_H_DEPENDANT -#define __CORE_CM4_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __CM4_REV - #define __CM4_REV 0x0000U - #warning "__CM4_REV not defined in device header file; using default!" - #endif - - #ifndef __FPU_PRESENT - #define __FPU_PRESENT 0U - #warning "__FPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __MPU_PRESENT - #define __MPU_PRESENT 0U - #warning "__MPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 4U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group Cortex_M4 */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - - Core Debug Register - - Core MPU Register - - Core FPU Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ - uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ - uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - -#define APSR_Q_Pos 27U /*!< APSR: Q Position */ -#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ - -#define APSR_GE_Pos 16U /*!< APSR: GE Position */ -#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ - uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ - uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ -#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ - -#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ -#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ -#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ - uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ -#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ - -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ -#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[24U]; - __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[24U]; - __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[24U]; - __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[24U]; - __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ - uint32_t RESERVED4[56U]; - __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ - uint32_t RESERVED5[644U]; - __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ -} NVIC_Type; - -/* Software Triggered Interrupt Register Definitions */ -#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ -#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ - __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ - __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ - __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ - __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ - __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ - __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ - __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ - __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ - __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ - __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ - __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ - __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ - uint32_t RESERVED0[5U]; - __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ -#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -/* SCB Vector Table Offset Register Definitions */ -#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ -#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ -#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ -#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ - -#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ -#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ -#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ - -#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ -#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ -#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ - -#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ -#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ - -#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ -#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ - -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ -#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ - -#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ -#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ - -#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ -#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ - -#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ -#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ - -#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ -#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ - -#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ -#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ - -#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ -#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ - -#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ -#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ - -#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ -#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ - -#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ -#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ - -/* SCB Configurable Fault Status Register Definitions */ -#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ -#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ - -#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ -#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ - -#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ -#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ - -/* SCB Hard Fault Status Register Definitions */ -#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ -#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ - -#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ -#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ - -#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ -#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ - -/* SCB Debug Fault Status Register Definitions */ -#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ -#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ - -#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ -#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ - -#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ -#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ - -#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ -#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ - -#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ -#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) - \brief Type definitions for the System Control and ID Register not in the SCB - @{ - */ - -/** - \brief Structure type to access the System Control and ID Register not in the SCB. - */ -typedef struct -{ - uint32_t RESERVED0[1U]; - __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ - __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ -} SCnSCB_Type; - -/* Interrupt Controller Type Register Definitions */ -#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ -#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ - -/* Auxiliary Control Register Definitions */ -#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ -#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ - -#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ -#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ - -#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ -#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ - -#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ -#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ - -#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ -#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ - -/*@} end of group CMSIS_SCnotSCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) - \brief Type definitions for the Instrumentation Trace Macrocell (ITM) - @{ - */ - -/** - \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). - */ -typedef struct -{ - __OM union - { - __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ - __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ - __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ - } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ - uint32_t RESERVED0[864U]; - __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ - uint32_t RESERVED1[15U]; - __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ - uint32_t RESERVED2[15U]; - __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ - uint32_t RESERVED3[29U]; - __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ - __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ - __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ - uint32_t RESERVED4[43U]; - __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ - __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ - uint32_t RESERVED5[6U]; - __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ - __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ - __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ - __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ - __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ - __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ - __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ - __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ - __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ - __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ - __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ - __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ -} ITM_Type; - -/* ITM Trace Privilege Register Definitions */ -#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ -#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ - -/* ITM Trace Control Register Definitions */ -#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ -#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ - -#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ -#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ - -#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ -#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ - -#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ -#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ - -#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ -#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ - -#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ -#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ - -#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ -#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ - -#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ -#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ - -#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ -#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ - -/* ITM Integration Write Register Definitions */ -#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ -#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ - -/* ITM Integration Read Register Definitions */ -#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ -#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ - -/* ITM Integration Mode Control Register Definitions */ -#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ -#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ - -/* ITM Lock Status Register Definitions */ -#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ -#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ - -#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ -#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ - -#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ -#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ - -/*@}*/ /* end of group CMSIS_ITM */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) - \brief Type definitions for the Data Watchpoint and Trace (DWT) - @{ - */ - -/** - \brief Structure type to access the Data Watchpoint and Trace Register (DWT). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ - __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ - __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ - __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ - __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ - __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ - __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ - __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ - __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ - __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ - uint32_t RESERVED0[1U]; - __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ - __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ - __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ - uint32_t RESERVED1[1U]; - __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ - __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ - __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ - uint32_t RESERVED2[1U]; - __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ - __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ - __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ -} DWT_Type; - -/* DWT Control Register Definitions */ -#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ -#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ - -#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ -#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ - -#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ -#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ - -#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ -#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ - -#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ -#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ - -#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ -#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ - -#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ -#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ - -#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ -#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ - -#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ -#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ - -#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ -#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ - -#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ -#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ - -#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ -#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ - -#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ -#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ - -#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ -#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ - -#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ -#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ - -#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ -#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ - -#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ -#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ - -#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ -#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ - -/* DWT CPI Count Register Definitions */ -#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ -#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ - -/* DWT Exception Overhead Count Register Definitions */ -#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ -#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ - -/* DWT Sleep Count Register Definitions */ -#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ -#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ - -/* DWT LSU Count Register Definitions */ -#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ -#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ - -/* DWT Folded-instruction Count Register Definitions */ -#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ -#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ - -/* DWT Comparator Mask Register Definitions */ -#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ -#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ - -/* DWT Comparator Function Register Definitions */ -#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ -#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ - -#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ -#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ - -#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ -#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ - -#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ -#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ - -#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ -#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ - -#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ -#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ - -#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ -#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ - -#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ -#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ - -#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ -#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ - -/*@}*/ /* end of group CMSIS_DWT */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_TPI Trace Port Interface (TPI) - \brief Type definitions for the Trace Port Interface (TPI) - @{ - */ - -/** - \brief Structure type to access the Trace Port Interface Register (TPI). - */ -typedef struct -{ - __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ - __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ - uint32_t RESERVED0[2U]; - __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ - uint32_t RESERVED1[55U]; - __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ - uint32_t RESERVED2[131U]; - __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ - __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ - __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ - uint32_t RESERVED3[759U]; - __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ - __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ - __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ - uint32_t RESERVED4[1U]; - __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ - __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ - __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ - uint32_t RESERVED5[39U]; - __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ - __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ - uint32_t RESERVED7[8U]; - __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ - __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ -} TPI_Type; - -/* TPI Asynchronous Clock Prescaler Register Definitions */ -#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ -#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ - -/* TPI Selected Pin Protocol Register Definitions */ -#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ -#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ - -/* TPI Formatter and Flush Status Register Definitions */ -#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ -#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ - -#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ -#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ - -#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ -#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ - -#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ -#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ - -/* TPI Formatter and Flush Control Register Definitions */ -#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ -#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ - -#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ -#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ - -/* TPI TRIGGER Register Definitions */ -#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ -#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ - -/* TPI Integration ETM Data Register Definitions (FIFO0) */ -#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ -#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ - -#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ -#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ - -#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ -#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ - -#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ -#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ - -#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ -#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ - -#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ -#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ - -#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ -#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ - -/* TPI ITATBCTR2 Register Definitions */ -#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ -#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ - -/* TPI Integration ITM Data Register Definitions (FIFO1) */ -#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ -#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ - -#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ -#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ - -#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ -#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ - -#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ -#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ - -#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ -#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ - -#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ -#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ - -#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ -#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ - -/* TPI ITATBCTR0 Register Definitions */ -#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ -#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ - -/* TPI Integration Mode Control Register Definitions */ -#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ -#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ - -/* TPI DEVID Register Definitions */ -#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ -#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ - -#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ -#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ - -#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ -#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ - -#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ -#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ - -#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ -#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ - -#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ -#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ - -/* TPI DEVTYPE Register Definitions */ -#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ -#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ - -#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ -#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ - -/*@}*/ /* end of group CMSIS_TPI */ - - -#if (__MPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_MPU Memory Protection Unit (MPU) - \brief Type definitions for the Memory Protection Unit (MPU) - @{ - */ - -/** - \brief Structure type to access the Memory Protection Unit (MPU). - */ -typedef struct -{ - __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ - __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ - __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ - __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ - __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ - __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ - __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ - __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ - __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ -} MPU_Type; - -/* MPU Type Register Definitions */ -#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ -#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ - -#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ -#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ - -#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ -#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ - -/* MPU Control Register Definitions */ -#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ -#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ - -#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ -#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ - -#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ -#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ - -/* MPU Region Number Register Definitions */ -#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ -#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ - -/* MPU Region Base Address Register Definitions */ -#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ -#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ - -#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ -#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ - -#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ -#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ - -/* MPU Region Attribute and Size Register Definitions */ -#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ -#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ - -#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ -#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ - -#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ -#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ - -#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ -#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ - -#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ -#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ - -#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ -#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ - -#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ -#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ - -#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ -#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ - -#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ -#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ - -#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ -#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ - -/*@} end of group CMSIS_MPU */ -#endif - - -#if (__FPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_FPU Floating Point Unit (FPU) - \brief Type definitions for the Floating Point Unit (FPU) - @{ - */ - -/** - \brief Structure type to access the Floating Point Unit (FPU). - */ -typedef struct -{ - uint32_t RESERVED0[1U]; - __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ - __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ - __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ - __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ - __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ -} FPU_Type; - -/* Floating-Point Context Control Register Definitions */ -#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ -#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ - -#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ -#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ - -#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ -#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ - -#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ -#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ - -#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ -#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ - -#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ -#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ - -#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ -#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ - -#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ -#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ - -#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ -#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ - -/* Floating-Point Context Address Register Definitions */ -#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ -#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ - -/* Floating-Point Default Status Control Register Definitions */ -#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ -#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ - -#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ -#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ - -#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ -#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ - -#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ -#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ - -/* Media and FP Feature Register 0 Definitions */ -#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ -#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ - -#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ -#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ - -#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ -#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ - -#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ -#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ - -#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ -#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ - -#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ -#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ - -#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ -#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ - -#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ -#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ - -/* Media and FP Feature Register 1 Definitions */ -#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ -#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ - -#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ -#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ - -#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ -#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ - -#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ -#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ - -/*@} end of group CMSIS_FPU */ -#endif - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief Type definitions for the Core Debug Registers - @{ - */ - -/** - \brief Structure type to access the Core Debug Register (CoreDebug). - */ -typedef struct -{ - __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ - __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ - __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ - __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ -} CoreDebug_Type; - -/* Debug Halting Control and Status Register Definitions */ -#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ -#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ - -#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ -#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ - -#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ -#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ - -#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ -#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ - -#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ -#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ - -#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ -#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ - -#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ -#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ - -#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ -#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ - -#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ -#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ - -#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ -#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ - -#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ -#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ - -#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ -#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ - -/* Debug Core Register Selector Register Definitions */ -#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ -#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ - -#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ -#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ - -/* Debug Exception and Monitor Control Register Definitions */ -#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ -#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ - -#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ -#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ - -#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ -#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ - -#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ -#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ - -#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ -#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ - -#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ -#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ - -#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ -#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ - -#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ -#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ - -#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ -#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ - -#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ -#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ - -#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ -#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ - -#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ -#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ - -#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ -#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ - -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of Cortex-M4 Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ -#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ -#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ -#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ -#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ -#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ -#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ -#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ - -#if (__MPU_PRESENT == 1U) - #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ -#endif - -#if (__FPU_PRESENT == 1U) - #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ - #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ -#endif - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Debug Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/** - \brief Set Priority Grouping - \details Sets the priority grouping field using the required unlock sequence. - The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. - Only values from 0..7 are used. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Priority grouping field. - */ -__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) -{ - uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ - reg_value = (reg_value | - ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ - SCB->AIRCR = reg_value; -} - - -/** - \brief Get Priority Grouping - \details Reads the priority grouping field from the NVIC Interrupt Controller. - \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). - */ -__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) -{ - return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); -} - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Active Interrupt - \details Reads the active register in NVIC and returns the active bit. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not active. - \return 1 Interrupt status is active. - */ -__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } - else - { - NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief Encode Priority - \details Encodes the priority for an interrupt with the given priority group, - preemptive priority value, and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Used priority group. - \param [in] PreemptPriority Preemptive priority value (starting from 0). - \param [in] SubPriority Subpriority value (starting from 0). - \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). - */ -__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - return ( - ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | - ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) - ); -} - - -/** - \brief Decode Priority - \details Decodes an interrupt priority value with a given priority group to - preemptive priority value and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. - \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). - \param [in] PriorityGroup Used priority group. - \param [out] pPreemptPriority Preemptive priority value (starting from 0). - \param [out] pSubPriority Subpriority value (starting from 0). - */ -__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); - *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | - SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - -/* ##################################### Debug In/Output function ########################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_core_DebugFunctions ITM Functions - \brief Functions that access the ITM debug interface. - @{ - */ - -extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ -#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ - - -/** - \brief ITM Send Character - \details Transmits a character via the ITM channel 0, and - \li Just returns when no debugger is connected that has booked the output. - \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. - \param [in] ch Character to transmit. - \returns Character to transmit. - */ -__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) -{ - if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ - ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ - { - while (ITM->PORT[0U].u32 == 0UL) - { - __NOP(); - } - ITM->PORT[0U].u8 = (uint8_t)ch; - } - return (ch); -} - - -/** - \brief ITM Receive Character - \details Inputs a character via the external variable \ref ITM_RxBuffer. - \return Received character. - \return -1 No character pending. - */ -__STATIC_INLINE int32_t ITM_ReceiveChar (void) -{ - int32_t ch = -1; /* no character available */ - - if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) - { - ch = ITM_RxBuffer; - ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ - } - - return (ch); -} - - -/** - \brief ITM Check Character - \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. - \return 0 No character available. - \return 1 Character available. - */ -__STATIC_INLINE int32_t ITM_CheckChar (void) -{ - - if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) - { - return (0); /* no character available */ - } - else - { - return (1); /* character available */ - } -} - -/*@} end of CMSIS_core_DebugFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM4_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cm7.h b/user/mpy/lib/cmsis/inc/core_cm7.h deleted file mode 100644 index 3b7530a..0000000 --- a/user/mpy/lib/cmsis/inc/core_cm7.h +++ /dev/null @@ -1,2512 +0,0 @@ -/**************************************************************************//** - * @file core_cm7.h - * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CM7_H_GENERIC -#define __CORE_CM7_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup Cortex_M7 - @{ - */ - -/* CMSIS CM7 definitions */ -#define __CM7_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __CM7_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ - __CM7_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_M (0x07U) /*!< Cortex-M Core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. -*/ -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #if (__FPU_PRESENT == 1) - #define __FPU_USED 1U - #else - #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #if (__FPU_PRESENT == 1U) - #define __FPU_USED 1U - #else - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #define __FPU_USED 0U - #endif - #else - #define __FPU_USED 0U - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ -#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM7_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_CM7_H_DEPENDANT -#define __CORE_CM7_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __CM7_REV - #define __CM7_REV 0x0000U - #warning "__CM7_REV not defined in device header file; using default!" - #endif - - #ifndef __FPU_PRESENT - #define __FPU_PRESENT 0U - #warning "__FPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __MPU_PRESENT - #define __MPU_PRESENT 0U - #warning "__MPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __ICACHE_PRESENT - #define __ICACHE_PRESENT 0U - #warning "__ICACHE_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __DCACHE_PRESENT - #define __DCACHE_PRESENT 0U - #warning "__DCACHE_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __DTCM_PRESENT - #define __DTCM_PRESENT 0U - #warning "__DTCM_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 3U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group Cortex_M7 */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - - Core Debug Register - - Core MPU Register - - Core FPU Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ - uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ - uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - -#define APSR_Q_Pos 27U /*!< APSR: Q Position */ -#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ - -#define APSR_GE_Pos 16U /*!< APSR: GE Position */ -#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ - uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ - uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ -#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ - -#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ -#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ -#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ - uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ -#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ - -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ -#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[24U]; - __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[24U]; - __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[24U]; - __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[24U]; - __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ - uint32_t RESERVED4[56U]; - __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ - uint32_t RESERVED5[644U]; - __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ -} NVIC_Type; - -/* Software Triggered Interrupt Register Definitions */ -#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ -#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ - __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ - __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ - __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ - __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ - __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ - __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ - __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ - __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ - __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ - __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ - __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ - __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ - uint32_t RESERVED0[1U]; - __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ - __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ - __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ - __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ - __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ - uint32_t RESERVED3[93U]; - __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ - uint32_t RESERVED4[15U]; - __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ - __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ - __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 1 */ - uint32_t RESERVED5[1U]; - __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ - uint32_t RESERVED6[1U]; - __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ - __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ - __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ - __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ - __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ - __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ - __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ - __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ - uint32_t RESERVED7[6U]; - __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ - __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ - __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ - __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ - __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ - uint32_t RESERVED8[1U]; - __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ -#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -/* SCB Vector Table Offset Register Definitions */ -#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ -#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ -#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ -#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ - -#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ -#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ - -#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ -#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ - -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ -#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ - -#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ -#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ -#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ - -#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ -#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ -#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ - -#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ -#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ - -#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ -#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ - -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ -#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ - -#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ -#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ - -#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ -#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ - -#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ -#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ - -#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ -#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ - -#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ -#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ - -#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ -#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ - -#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ -#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ - -#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ -#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ - -#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ -#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ - -/* SCB Configurable Fault Status Register Definitions */ -#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ -#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ - -#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ -#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ - -#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ -#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ - -/* SCB Hard Fault Status Register Definitions */ -#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ -#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ - -#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ -#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ - -#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ -#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ - -/* SCB Debug Fault Status Register Definitions */ -#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ -#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ - -#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ -#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ - -#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ -#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ - -#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ -#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ - -#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ -#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ - -/* SCB Cache Level ID Register Definitions */ -#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ -#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ - -#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ -#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ - -/* SCB Cache Type Register Definitions */ -#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ -#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ - -#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ -#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ - -#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ -#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ - -#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ -#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ - -#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ -#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ - -/* SCB Cache Size ID Register Definitions */ -#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ -#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ - -#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ -#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ - -#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ -#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ - -#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ -#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ - -#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ -#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ - -#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ -#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ - -#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ -#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ - -/* SCB Cache Size Selection Register Definitions */ -#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ -#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ - -#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ -#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ - -/* SCB Software Triggered Interrupt Register Definitions */ -#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ -#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ - -/* SCB D-Cache Invalidate by Set-way Register Definitions */ -#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ -#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ - -#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ -#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ - -/* SCB D-Cache Clean by Set-way Register Definitions */ -#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ -#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ - -#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ -#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ - -/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ -#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ -#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ - -#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ -#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ - -/* Instruction Tightly-Coupled Memory Control Register Definitions */ -#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ -#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ - -#define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ -#define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ - -#define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ -#define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ - -#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ -#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ - -/* Data Tightly-Coupled Memory Control Register Definitions */ -#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ -#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ - -#define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ -#define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ - -#define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ -#define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ - -#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ -#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ - -/* AHBP Control Register Definitions */ -#define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ -#define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ - -#define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ -#define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ - -/* L1 Cache Control Register Definitions */ -#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ -#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ - -#define SCB_CACR_ECCEN_Pos 1U /*!< SCB CACR: ECCEN Position */ -#define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< SCB CACR: ECCEN Mask */ - -#define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ -#define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ - -/* AHBS Control Register Definitions */ -#define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ -#define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBPCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ - -#define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ -#define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBPCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ - -#define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ -#define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBPCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ - -/* Auxiliary Bus Fault Status Register Definitions */ -#define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ -#define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ - -#define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ -#define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ - -#define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ -#define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ - -#define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ -#define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ - -#define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ -#define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ - -#define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ -#define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) - \brief Type definitions for the System Control and ID Register not in the SCB - @{ - */ - -/** - \brief Structure type to access the System Control and ID Register not in the SCB. - */ -typedef struct -{ - uint32_t RESERVED0[1U]; - __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ - __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ -} SCnSCB_Type; - -/* Interrupt Controller Type Register Definitions */ -#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ -#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ - -/* Auxiliary Control Register Definitions */ -#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ -#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ - -#define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ -#define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ - -#define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ -#define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ - -#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ -#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ - -#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ -#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ - -/*@} end of group CMSIS_SCnotSCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) - \brief Type definitions for the Instrumentation Trace Macrocell (ITM) - @{ - */ - -/** - \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). - */ -typedef struct -{ - __OM union - { - __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ - __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ - __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ - } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ - uint32_t RESERVED0[864U]; - __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ - uint32_t RESERVED1[15U]; - __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ - uint32_t RESERVED2[15U]; - __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ - uint32_t RESERVED3[29U]; - __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ - __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ - __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ - uint32_t RESERVED4[43U]; - __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ - __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ - uint32_t RESERVED5[6U]; - __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ - __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ - __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ - __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ - __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ - __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ - __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ - __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ - __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ - __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ - __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ - __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ -} ITM_Type; - -/* ITM Trace Privilege Register Definitions */ -#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ -#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ - -/* ITM Trace Control Register Definitions */ -#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ -#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ - -#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ -#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ - -#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ -#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ - -#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ -#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ - -#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ -#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ - -#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ -#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ - -#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ -#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ - -#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ -#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ - -#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ -#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ - -/* ITM Integration Write Register Definitions */ -#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ -#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ - -/* ITM Integration Read Register Definitions */ -#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ -#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ - -/* ITM Integration Mode Control Register Definitions */ -#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ -#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ - -/* ITM Lock Status Register Definitions */ -#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ -#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ - -#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ -#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ - -#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ -#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ - -/*@}*/ /* end of group CMSIS_ITM */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) - \brief Type definitions for the Data Watchpoint and Trace (DWT) - @{ - */ - -/** - \brief Structure type to access the Data Watchpoint and Trace Register (DWT). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ - __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ - __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ - __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ - __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ - __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ - __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ - __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ - __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ - __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ - uint32_t RESERVED0[1U]; - __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ - __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ - __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ - uint32_t RESERVED1[1U]; - __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ - __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ - __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ - uint32_t RESERVED2[1U]; - __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ - __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ - __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ - uint32_t RESERVED3[981U]; - __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ - __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ -} DWT_Type; - -/* DWT Control Register Definitions */ -#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ -#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ - -#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ -#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ - -#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ -#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ - -#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ -#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ - -#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ -#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ - -#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ -#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ - -#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ -#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ - -#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ -#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ - -#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ -#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ - -#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ -#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ - -#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ -#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ - -#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ -#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ - -#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ -#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ - -#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ -#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ - -#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ -#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ - -#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ -#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ - -#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ -#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ - -#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ -#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ - -/* DWT CPI Count Register Definitions */ -#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ -#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ - -/* DWT Exception Overhead Count Register Definitions */ -#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ -#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ - -/* DWT Sleep Count Register Definitions */ -#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ -#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ - -/* DWT LSU Count Register Definitions */ -#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ -#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ - -/* DWT Folded-instruction Count Register Definitions */ -#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ -#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ - -/* DWT Comparator Mask Register Definitions */ -#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ -#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ - -/* DWT Comparator Function Register Definitions */ -#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ -#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ - -#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ -#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ - -#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ -#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ - -#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ -#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ - -#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ -#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ - -#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ -#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ - -#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ -#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ - -#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ -#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ - -#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ -#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ - -/*@}*/ /* end of group CMSIS_DWT */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_TPI Trace Port Interface (TPI) - \brief Type definitions for the Trace Port Interface (TPI) - @{ - */ - -/** - \brief Structure type to access the Trace Port Interface Register (TPI). - */ -typedef struct -{ - __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ - __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ - uint32_t RESERVED0[2U]; - __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ - uint32_t RESERVED1[55U]; - __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ - uint32_t RESERVED2[131U]; - __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ - __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ - __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ - uint32_t RESERVED3[759U]; - __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ - __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ - __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ - uint32_t RESERVED4[1U]; - __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ - __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ - __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ - uint32_t RESERVED5[39U]; - __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ - __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ - uint32_t RESERVED7[8U]; - __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ - __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ -} TPI_Type; - -/* TPI Asynchronous Clock Prescaler Register Definitions */ -#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ -#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ - -/* TPI Selected Pin Protocol Register Definitions */ -#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ -#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ - -/* TPI Formatter and Flush Status Register Definitions */ -#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ -#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ - -#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ -#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ - -#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ -#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ - -#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ -#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ - -/* TPI Formatter and Flush Control Register Definitions */ -#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ -#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ - -#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ -#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ - -/* TPI TRIGGER Register Definitions */ -#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ -#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ - -/* TPI Integration ETM Data Register Definitions (FIFO0) */ -#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ -#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ - -#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ -#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ - -#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ -#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ - -#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ -#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ - -#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ -#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ - -#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ -#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ - -#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ -#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ - -/* TPI ITATBCTR2 Register Definitions */ -#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ -#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ - -/* TPI Integration ITM Data Register Definitions (FIFO1) */ -#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ -#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ - -#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ -#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ - -#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ -#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ - -#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ -#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ - -#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ -#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ - -#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ -#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ - -#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ -#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ - -/* TPI ITATBCTR0 Register Definitions */ -#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ -#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ - -/* TPI Integration Mode Control Register Definitions */ -#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ -#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ - -/* TPI DEVID Register Definitions */ -#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ -#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ - -#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ -#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ - -#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ -#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ - -#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ -#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ - -#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ -#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ - -#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ -#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ - -/* TPI DEVTYPE Register Definitions */ -#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ -#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ - -#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ -#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ - -/*@}*/ /* end of group CMSIS_TPI */ - - -#if (__MPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_MPU Memory Protection Unit (MPU) - \brief Type definitions for the Memory Protection Unit (MPU) - @{ - */ - -/** - \brief Structure type to access the Memory Protection Unit (MPU). - */ -typedef struct -{ - __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ - __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ - __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ - __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ - __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ - __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ - __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ - __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ - __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ -} MPU_Type; - -/* MPU Type Register Definitions */ -#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ -#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ - -#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ -#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ - -#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ -#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ - -/* MPU Control Register Definitions */ -#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ -#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ - -#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ -#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ - -#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ -#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ - -/* MPU Region Number Register Definitions */ -#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ -#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ - -/* MPU Region Base Address Register Definitions */ -#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ -#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ - -#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ -#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ - -#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ -#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ - -/* MPU Region Attribute and Size Register Definitions */ -#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ -#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ - -#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ -#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ - -#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ -#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ - -#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ -#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ - -#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ -#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ - -#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ -#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ - -#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ -#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ - -#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ -#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ - -#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ -#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ - -#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ -#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ - -/*@} end of group CMSIS_MPU */ -#endif - - -#if (__FPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_FPU Floating Point Unit (FPU) - \brief Type definitions for the Floating Point Unit (FPU) - @{ - */ - -/** - \brief Structure type to access the Floating Point Unit (FPU). - */ -typedef struct -{ - uint32_t RESERVED0[1U]; - __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ - __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ - __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ - __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ - __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ - __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ -} FPU_Type; - -/* Floating-Point Context Control Register Definitions */ -#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ -#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ - -#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ -#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ - -#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ -#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ - -#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ -#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ - -#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ -#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ - -#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ -#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ - -#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ -#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ - -#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ -#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ - -#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ -#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ - -/* Floating-Point Context Address Register Definitions */ -#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ -#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ - -/* Floating-Point Default Status Control Register Definitions */ -#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ -#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ - -#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ -#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ - -#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ -#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ - -#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ -#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ - -/* Media and FP Feature Register 0 Definitions */ -#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ -#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ - -#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ -#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ - -#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ -#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ - -#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ -#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ - -#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ -#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ - -#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ -#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ - -#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ -#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ - -#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ -#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ - -/* Media and FP Feature Register 1 Definitions */ -#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ -#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ - -#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ -#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ - -#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ -#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ - -#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ -#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ - -/* Media and FP Feature Register 2 Definitions */ - -/*@} end of group CMSIS_FPU */ -#endif - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief Type definitions for the Core Debug Registers - @{ - */ - -/** - \brief Structure type to access the Core Debug Register (CoreDebug). - */ -typedef struct -{ - __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ - __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ - __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ - __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ -} CoreDebug_Type; - -/* Debug Halting Control and Status Register Definitions */ -#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ -#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ - -#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ -#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ - -#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ -#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ - -#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ -#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ - -#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ -#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ - -#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ -#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ - -#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ -#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ - -#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ -#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ - -#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ -#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ - -#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ -#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ - -#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ -#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ - -#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ -#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ - -/* Debug Core Register Selector Register Definitions */ -#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ -#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ - -#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ -#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ - -/* Debug Exception and Monitor Control Register Definitions */ -#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ -#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ - -#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ -#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ - -#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ -#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ - -#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ -#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ - -#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ -#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ - -#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ -#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ - -#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ -#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ - -#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ -#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ - -#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ -#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ - -#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ -#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ - -#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ -#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ - -#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ -#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ - -#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ -#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ - -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of Cortex-M4 Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ -#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ -#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ -#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ -#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ -#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ -#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ -#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ - -#if (__MPU_PRESENT == 1U) - #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ -#endif - -#if (__FPU_PRESENT == 1U) - #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ - #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ -#endif - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Debug Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/** - \brief Set Priority Grouping - \details Sets the priority grouping field using the required unlock sequence. - The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. - Only values from 0..7 are used. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Priority grouping field. - */ -__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) -{ - uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ - reg_value = (reg_value | - ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ - SCB->AIRCR = reg_value; -} - - -/** - \brief Get Priority Grouping - \details Reads the priority grouping field from the NVIC Interrupt Controller. - \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). - */ -__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) -{ - return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); -} - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Active Interrupt - \details Reads the active register in NVIC and returns the active bit. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not active. - \return 1 Interrupt status is active. - */ -__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHPR[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } - else - { - NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return(((uint32_t)SCB->SHPR[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief Encode Priority - \details Encodes the priority for an interrupt with the given priority group, - preemptive priority value, and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Used priority group. - \param [in] PreemptPriority Preemptive priority value (starting from 0). - \param [in] SubPriority Subpriority value (starting from 0). - \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). - */ -__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - return ( - ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | - ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) - ); -} - - -/** - \brief Decode Priority - \details Decodes an interrupt priority value with a given priority group to - preemptive priority value and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. - \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). - \param [in] PriorityGroup Used priority group. - \param [out] pPreemptPriority Preemptive priority value (starting from 0). - \param [out] pSubPriority Subpriority value (starting from 0). - */ -__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); - *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | - SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - -/* ########################## FPU functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_FpuFunctions FPU Functions - \brief Function that provides FPU type. - @{ - */ - -/** - \brief get FPU type - \details returns the FPU type - \returns - - \b 0: No FPU - - \b 1: Single precision FPU - - \b 2: Double + Single precision FPU - */ -__STATIC_INLINE uint32_t SCB_GetFPUType(void) -{ - uint32_t mvfr0; - - mvfr0 = SCB->MVFR0; - if ((mvfr0 & 0x00000FF0UL) == 0x220UL) - { - return 2UL; /* Double + Single precision FPU */ - } - else if ((mvfr0 & 0x00000FF0UL) == 0x020UL) - { - return 1UL; /* Single precision FPU */ - } - else - { - return 0UL; /* No FPU */ - } -} - - -/*@} end of CMSIS_Core_FpuFunctions */ - - - -/* ########################## Cache functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_CacheFunctions Cache Functions - \brief Functions that configure Instruction and Data cache. - @{ - */ - -/* Cache Size ID Register Macros */ -#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) -#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) - - -/** - \brief Enable I-Cache - \details Turns on I-Cache - */ -__STATIC_INLINE void SCB_EnableICache (void) -{ - #if (__ICACHE_PRESENT == 1U) - __DSB(); - __ISB(); - SCB->ICIALLU = 0UL; /* invalidate I-Cache */ - SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Disable I-Cache - \details Turns off I-Cache - */ -__STATIC_INLINE void SCB_DisableICache (void) -{ - #if (__ICACHE_PRESENT == 1U) - __DSB(); - __ISB(); - SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ - SCB->ICIALLU = 0UL; /* invalidate I-Cache */ - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Invalidate I-Cache - \details Invalidates I-Cache - */ -__STATIC_INLINE void SCB_InvalidateICache (void) -{ - #if (__ICACHE_PRESENT == 1U) - __DSB(); - __ISB(); - SCB->ICIALLU = 0UL; - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Enable D-Cache - \details Turns on D-Cache - */ -__STATIC_INLINE void SCB_EnableDCache (void) -{ - #if (__DCACHE_PRESENT == 1U) - uint32_t ccsidr; - uint32_t sets; - uint32_t ways; - - SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ - __DSB(); - - ccsidr = SCB->CCSIDR; - - /* invalidate D-Cache */ - sets = (uint32_t)(CCSIDR_SETS(ccsidr)); - do { - ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); - do { - SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | - ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); - #if defined ( __CC_ARM ) - __schedule_barrier(); - #endif - } while (ways--); - } while(sets--); - __DSB(); - - SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Disable D-Cache - \details Turns off D-Cache - */ -__STATIC_INLINE void SCB_DisableDCache (void) -{ - #if (__DCACHE_PRESENT == 1U) - uint32_t ccsidr; - uint32_t sets; - uint32_t ways; - - SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ - __DSB(); - - ccsidr = SCB->CCSIDR; - - SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ - - /* clean & invalidate D-Cache */ - sets = (uint32_t)(CCSIDR_SETS(ccsidr)); - do { - ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); - do { - SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | - ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); - #if defined ( __CC_ARM ) - __schedule_barrier(); - #endif - } while (ways--); - } while(sets--); - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Invalidate D-Cache - \details Invalidates D-Cache - */ -__STATIC_INLINE void SCB_InvalidateDCache (void) -{ - #if (__DCACHE_PRESENT == 1U) - uint32_t ccsidr; - uint32_t sets; - uint32_t ways; - - SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ - __DSB(); - - ccsidr = SCB->CCSIDR; - - /* invalidate D-Cache */ - sets = (uint32_t)(CCSIDR_SETS(ccsidr)); - do { - ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); - do { - SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | - ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); - #if defined ( __CC_ARM ) - __schedule_barrier(); - #endif - } while (ways--); - } while(sets--); - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Clean D-Cache - \details Cleans D-Cache - */ -__STATIC_INLINE void SCB_CleanDCache (void) -{ - #if (__DCACHE_PRESENT == 1U) - uint32_t ccsidr; - uint32_t sets; - uint32_t ways; - - SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ - __DSB(); - - ccsidr = SCB->CCSIDR; - - /* clean D-Cache */ - sets = (uint32_t)(CCSIDR_SETS(ccsidr)); - do { - ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); - do { - SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | - ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); - #if defined ( __CC_ARM ) - __schedule_barrier(); - #endif - } while (ways--); - } while(sets--); - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief Clean & Invalidate D-Cache - \details Cleans and Invalidates D-Cache - */ -__STATIC_INLINE void SCB_CleanInvalidateDCache (void) -{ - #if (__DCACHE_PRESENT == 1U) - uint32_t ccsidr; - uint32_t sets; - uint32_t ways; - - SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ - __DSB(); - - ccsidr = SCB->CCSIDR; - - /* clean & invalidate D-Cache */ - sets = (uint32_t)(CCSIDR_SETS(ccsidr)); - do { - ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); - do { - SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | - ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); - #if defined ( __CC_ARM ) - __schedule_barrier(); - #endif - } while (ways--); - } while(sets--); - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief D-Cache Invalidate by address - \details Invalidates D-Cache for the given address - \param[in] addr address (aligned to 32-byte boundary) - \param[in] dsize size of memory block (in number of bytes) -*/ -__STATIC_INLINE void SCB_InvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) -{ - #if (__DCACHE_PRESENT == 1U) - int32_t op_size = dsize; - uint32_t op_addr = (uint32_t)addr; - int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ - - __DSB(); - - while (op_size > 0) { - SCB->DCIMVAC = op_addr; - op_addr += linesize; - op_size -= linesize; - } - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief D-Cache Clean by address - \details Cleans D-Cache for the given address - \param[in] addr address (aligned to 32-byte boundary) - \param[in] dsize size of memory block (in number of bytes) -*/ -__STATIC_INLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) -{ - #if (__DCACHE_PRESENT == 1) - int32_t op_size = dsize; - uint32_t op_addr = (uint32_t) addr; - int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ - - __DSB(); - - while (op_size > 0) { - SCB->DCCMVAC = op_addr; - op_addr += linesize; - op_size -= linesize; - } - - __DSB(); - __ISB(); - #endif -} - - -/** - \brief D-Cache Clean and Invalidate by address - \details Cleans and invalidates D_Cache for the given address - \param[in] addr address (aligned to 32-byte boundary) - \param[in] dsize size of memory block (in number of bytes) -*/ -__STATIC_INLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) -{ - #if (__DCACHE_PRESENT == 1U) - int32_t op_size = dsize; - uint32_t op_addr = (uint32_t) addr; - int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ - - __DSB(); - - while (op_size > 0) { - SCB->DCCIMVAC = op_addr; - op_addr += linesize; - op_size -= linesize; - } - - __DSB(); - __ISB(); - #endif -} - - -/*@} end of CMSIS_Core_CacheFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - -/* ##################################### Debug In/Output function ########################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_core_DebugFunctions ITM Functions - \brief Functions that access the ITM debug interface. - @{ - */ - -extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ -#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ - - -/** - \brief ITM Send Character - \details Transmits a character via the ITM channel 0, and - \li Just returns when no debugger is connected that has booked the output. - \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. - \param [in] ch Character to transmit. - \returns Character to transmit. - */ -__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) -{ - if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ - ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ - { - while (ITM->PORT[0U].u32 == 0UL) - { - __NOP(); - } - ITM->PORT[0U].u8 = (uint8_t)ch; - } - return (ch); -} - - -/** - \brief ITM Receive Character - \details Inputs a character via the external variable \ref ITM_RxBuffer. - \return Received character. - \return -1 No character pending. - */ -__STATIC_INLINE int32_t ITM_ReceiveChar (void) -{ - int32_t ch = -1; /* no character available */ - - if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) - { - ch = ITM_RxBuffer; - ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ - } - - return (ch); -} - - -/** - \brief ITM Check Character - \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. - \return 0 No character available. - \return 1 Character available. - */ -__STATIC_INLINE int32_t ITM_CheckChar (void) -{ - - if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) - { - return (0); /* no character available */ - } - else - { - return (1); /* character available */ - } -} - -/*@} end of CMSIS_core_DebugFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CM7_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_cmFunc.h b/user/mpy/lib/cmsis/inc/core_cmFunc.h deleted file mode 100644 index 652a48a..0000000 --- a/user/mpy/lib/cmsis/inc/core_cmFunc.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************//** - * @file core_cmFunc.h - * @brief CMSIS Cortex-M Core Function Access Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CMFUNC_H -#define __CORE_CMFUNC_H - - -/* ########################### Core Function Access ########################### */ -/** \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions - @{ -*/ - -/*------------------ RealView Compiler -----------------*/ -#if defined ( __CC_ARM ) - #include "cmsis_armcc.h" - -/*------------------ ARM Compiler V6 -------------------*/ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #include "cmsis_armcc_V6.h" - -/*------------------ GNU Compiler ----------------------*/ -#elif defined ( __GNUC__ ) - #include "cmsis_gcc.h" - -/*------------------ ICC Compiler ----------------------*/ -#elif defined ( __ICCARM__ ) - #include - -/*------------------ TI CCS Compiler -------------------*/ -#elif defined ( __TMS470__ ) - #include - -/*------------------ TASKING Compiler ------------------*/ -#elif defined ( __TASKING__ ) - /* - * The CMSIS functions have been implemented as intrinsics in the compiler. - * Please use "carm -?i" to get an up to date list of all intrinsics, - * Including the CMSIS ones. - */ - -/*------------------ COSMIC Compiler -------------------*/ -#elif defined ( __CSMC__ ) - #include - -#endif - -/*@} end of CMSIS_Core_RegAccFunctions */ - -#endif /* __CORE_CMFUNC_H */ diff --git a/user/mpy/lib/cmsis/inc/core_cmInstr.h b/user/mpy/lib/cmsis/inc/core_cmInstr.h deleted file mode 100644 index f474b0e..0000000 --- a/user/mpy/lib/cmsis/inc/core_cmInstr.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************//** - * @file core_cmInstr.h - * @brief CMSIS Cortex-M Core Instruction Access Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CMINSTR_H -#define __CORE_CMINSTR_H - - -/* ########################## Core Instruction Access ######################### */ -/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface - Access to dedicated instructions - @{ -*/ - -/*------------------ RealView Compiler -----------------*/ -#if defined ( __CC_ARM ) - #include "cmsis_armcc.h" - -/*------------------ ARM Compiler V6 -------------------*/ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #include "cmsis_armcc_V6.h" - -/*------------------ GNU Compiler ----------------------*/ -#elif defined ( __GNUC__ ) - #include "cmsis_gcc.h" - -/*------------------ ICC Compiler ----------------------*/ -#elif defined ( __ICCARM__ ) - #include - -/*------------------ TI CCS Compiler -------------------*/ -#elif defined ( __TMS470__ ) - #include - -/*------------------ TASKING Compiler ------------------*/ -#elif defined ( __TASKING__ ) - /* - * The CMSIS functions have been implemented as intrinsics in the compiler. - * Please use "carm -?i" to get an up to date list of all intrinsics, - * Including the CMSIS ones. - */ - -/*------------------ COSMIC Compiler -------------------*/ -#elif defined ( __CSMC__ ) - #include - -#endif - -/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ - -#endif /* __CORE_CMINSTR_H */ diff --git a/user/mpy/lib/cmsis/inc/core_cmSimd.h b/user/mpy/lib/cmsis/inc/core_cmSimd.h deleted file mode 100644 index 66bf5c2..0000000 --- a/user/mpy/lib/cmsis/inc/core_cmSimd.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************//** - * @file core_cmSimd.h - * @brief CMSIS Cortex-M SIMD Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_CMSIMD_H -#define __CORE_CMSIMD_H - -#ifdef __cplusplus - extern "C" { -#endif - - -/* ################### Compiler specific Intrinsics ########################### */ -/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics - Access to dedicated SIMD instructions - @{ -*/ - -/*------------------ RealView Compiler -----------------*/ -#if defined ( __CC_ARM ) - #include "cmsis_armcc.h" - -/*------------------ ARM Compiler V6 -------------------*/ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #include "cmsis_armcc_V6.h" - -/*------------------ GNU Compiler ----------------------*/ -#elif defined ( __GNUC__ ) - #include "cmsis_gcc.h" - -/*------------------ ICC Compiler ----------------------*/ -#elif defined ( __ICCARM__ ) - #include - -/*------------------ TI CCS Compiler -------------------*/ -#elif defined ( __TMS470__ ) - #include - -/*------------------ TASKING Compiler ------------------*/ -#elif defined ( __TASKING__ ) - /* - * The CMSIS functions have been implemented as intrinsics in the compiler. - * Please use "carm -?i" to get an up to date list of all intrinsics, - * Including the CMSIS ones. - */ - -/*------------------ COSMIC Compiler -------------------*/ -#elif defined ( __CSMC__ ) - #include - -#endif - -/*@} end of group CMSIS_SIMD_intrinsics */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_CMSIMD_H */ diff --git a/user/mpy/lib/cmsis/inc/core_sc000.h b/user/mpy/lib/cmsis/inc/core_sc000.h deleted file mode 100644 index 514dbd8..0000000 --- a/user/mpy/lib/cmsis/inc/core_sc000.h +++ /dev/null @@ -1,926 +0,0 @@ -/**************************************************************************//** - * @file core_sc000.h - * @brief CMSIS SC000 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_SC000_H_GENERIC -#define __CORE_SC000_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup SC000 - @{ - */ - -/* CMSIS SC000 definitions */ -#define __SC000_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __SC000_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \ - __SC000_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_SC (000U) /*!< Cortex secure core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - This core does not support an FPU at all -*/ -#define __FPU_USED 0U - -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_SC000_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_SC000_H_DEPENDANT -#define __CORE_SC000_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __SC000_REV - #define __SC000_REV 0x0000U - #warning "__SC000_REV not defined in device header file; using default!" - #endif - - #ifndef __MPU_PRESENT - #define __MPU_PRESENT 0U - #warning "__MPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 2U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group SC000 */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - - Core MPU Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t _reserved0:1; /*!< bit: 0 Reserved */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[31U]; - __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[31U]; - __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[31U]; - __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[31U]; - uint32_t RESERVED4[64U]; - __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ -} NVIC_Type; - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ - __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - uint32_t RESERVED0[1U]; - __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ - uint32_t RESERVED1[154U]; - __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) - \brief Type definitions for the System Control and ID Register not in the SCB - @{ - */ - -/** - \brief Structure type to access the System Control and ID Register not in the SCB. - */ -typedef struct -{ - uint32_t RESERVED0[2U]; - __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ -} SCnSCB_Type; - -/* Auxiliary Control Register Definitions */ -#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ -#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ - -/*@} end of group CMSIS_SCnotSCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - -#if (__MPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_MPU Memory Protection Unit (MPU) - \brief Type definitions for the Memory Protection Unit (MPU) - @{ - */ - -/** - \brief Structure type to access the Memory Protection Unit (MPU). - */ -typedef struct -{ - __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ - __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ - __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ - __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ - __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ -} MPU_Type; - -/* MPU Type Register Definitions */ -#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ -#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ - -#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ -#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ - -#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ -#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ - -/* MPU Control Register Definitions */ -#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ -#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ - -#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ -#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ - -#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ -#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ - -/* MPU Region Number Register Definitions */ -#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ -#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ - -/* MPU Region Base Address Register Definitions */ -#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ -#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ - -#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ -#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ - -#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ -#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ - -/* MPU Region Attribute and Size Register Definitions */ -#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ -#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ - -#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ -#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ - -#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ -#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ - -#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ -#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ - -#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ -#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ - -#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ -#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ - -#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ -#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ - -#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ -#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ - -#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ -#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ - -#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ -#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ - -/*@} end of group CMSIS_MPU */ -#endif - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. - Therefore they are not covered by the SC000 header file. - @{ - */ -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of SC000 Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ - -#if (__MPU_PRESENT == 1U) - #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ -#endif - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/* Interrupt Priorities are WORD accessible only under ARMv6M */ -/* The following MACROS handle generation of the register offset and byte masks */ -#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) -#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) -#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | - (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); - } - else - { - NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | - (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - SCB_AIRCR_SYSRESETREQ_Msk); - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_SC000_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/cmsis/inc/core_sc300.h b/user/mpy/lib/cmsis/inc/core_sc300.h deleted file mode 100644 index 8bd18aa..0000000 --- a/user/mpy/lib/cmsis/inc/core_sc300.h +++ /dev/null @@ -1,1745 +0,0 @@ -/**************************************************************************//** - * @file core_sc300.h - * @brief CMSIS SC300 Core Peripheral Access Layer Header File - * @version V4.30 - * @date 20. October 2015 - ******************************************************************************/ -/* Copyright (c) 2009 - 2015 ARM LIMITED - - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of ARM nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - * - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------------*/ - - -#if defined ( __ICCARM__ ) - #pragma system_include /* treat file as system include file for MISRA check */ -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang system_header /* treat file as system include file */ -#endif - -#ifndef __CORE_SC300_H_GENERIC -#define __CORE_SC300_H_GENERIC - -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/** - \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions - CMSIS violates the following MISRA-C:2004 rules: - - \li Required Rule 8.5, object/function definition in header file.
- Function definitions in header files are used to allow 'inlining'. - - \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
- Unions are used for effective representation of core registers. - - \li Advisory Rule 19.7, Function-like macro defined.
- Function-like macros are used to allow more efficient code. - */ - - -/******************************************************************************* - * CMSIS definitions - ******************************************************************************/ -/** - \ingroup SC3000 - @{ - */ - -/* CMSIS SC300 definitions */ -#define __SC300_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ -#define __SC300_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ -#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \ - __SC300_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ - -#define __CORTEX_SC (300U) /*!< Cortex secure core */ - - -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline - -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline - -#elif defined ( __TMS470__ ) - #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __TASKING__ ) - #define __ASM __asm /*!< asm keyword for TASKING Compiler */ - #define __INLINE inline /*!< inline keyword for TASKING Compiler */ - #define __STATIC_INLINE static inline - -#elif defined ( __CSMC__ ) - #define __packed - #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ - #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ - #define __STATIC_INLINE static inline - -#else - #error Unknown compiler -#endif - -/** __FPU_USED indicates whether an FPU is used or not. - This core does not support an FPU at all -*/ -#define __FPU_USED 0U - -#if defined ( __CC_ARM ) - #if defined __TARGET_FPU_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __GNUC__ ) - #if defined (__VFP_FP__) && !defined(__SOFTFP__) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __ICCARM__ ) - #if defined __ARMVFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TMS470__ ) - #if defined __TI_VFP_SUPPORT__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __TASKING__ ) - #if defined __FPU_VFP__ - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#elif defined ( __CSMC__ ) - #if ( __CSMC__ & 0x400U) - #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" - #endif - -#endif - -#include "core_cmInstr.h" /* Core Instruction Access */ -#include "core_cmFunc.h" /* Core Function Access */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_SC300_H_GENERIC */ - -#ifndef __CMSIS_GENERIC - -#ifndef __CORE_SC300_H_DEPENDANT -#define __CORE_SC300_H_DEPENDANT - -#ifdef __cplusplus - extern "C" { -#endif - -/* check device defines and use defaults */ -#if defined __CHECK_DEVICE_DEFINES - #ifndef __SC300_REV - #define __SC300_REV 0x0000U - #warning "__SC300_REV not defined in device header file; using default!" - #endif - - #ifndef __MPU_PRESENT - #define __MPU_PRESENT 0U - #warning "__MPU_PRESENT not defined in device header file; using default!" - #endif - - #ifndef __NVIC_PRIO_BITS - #define __NVIC_PRIO_BITS 4U - #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" - #endif - - #ifndef __Vendor_SysTickConfig - #define __Vendor_SysTickConfig 0U - #warning "__Vendor_SysTickConfig not defined in device header file; using default!" - #endif -#endif - -/* IO definitions (access restrictions to peripheral registers) */ -/** - \defgroup CMSIS_glob_defs CMSIS Global Defines - - IO Type Qualifiers are used - \li to specify the access to peripheral variables. - \li for automatic generation of peripheral register debug information. -*/ -#ifdef __cplusplus - #define __I volatile /*!< Defines 'read only' permissions */ -#else - #define __I volatile const /*!< Defines 'read only' permissions */ -#endif -#define __O volatile /*!< Defines 'write only' permissions */ -#define __IO volatile /*!< Defines 'read / write' permissions */ - -/* following defines should be used for structure members */ -#define __IM volatile const /*! Defines 'read only' structure member permissions */ -#define __OM volatile /*! Defines 'write only' structure member permissions */ -#define __IOM volatile /*! Defines 'read / write' structure member permissions */ - -/*@} end of group SC300 */ - - - -/******************************************************************************* - * Register Abstraction - Core Register contain: - - Core Register - - Core NVIC Register - - Core SCB Register - - Core SysTick Register - - Core Debug Register - - Core MPU Register - ******************************************************************************/ -/** - \defgroup CMSIS_core_register Defines and Type Definitions - \brief Type definitions and defines for Cortex-M processor based devices. -*/ - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CORE Status and Control Registers - \brief Core Register type definitions. - @{ - */ - -/** - \brief Union type to access the Application Program Status Register (APSR). - */ -typedef union -{ - struct - { - uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} APSR_Type; - -/* APSR Register Definitions */ -#define APSR_N_Pos 31U /*!< APSR: N Position */ -#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ - -#define APSR_Z_Pos 30U /*!< APSR: Z Position */ -#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ - -#define APSR_C_Pos 29U /*!< APSR: C Position */ -#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ - -#define APSR_V_Pos 28U /*!< APSR: V Position */ -#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ - -#define APSR_Q_Pos 27U /*!< APSR: Q Position */ -#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ - - -/** - \brief Union type to access the Interrupt Program Status Register (IPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} IPSR_Type; - -/* IPSR Register Definitions */ -#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ - - -/** - \brief Union type to access the Special-Purpose Program Status Registers (xPSR). - */ -typedef union -{ - struct - { - uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ - uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ - uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ - uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ - uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ - uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ - uint32_t C:1; /*!< bit: 29 Carry condition code flag */ - uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ - uint32_t N:1; /*!< bit: 31 Negative condition code flag */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} xPSR_Type; - -/* xPSR Register Definitions */ -#define xPSR_N_Pos 31U /*!< xPSR: N Position */ -#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ - -#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ -#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ - -#define xPSR_C_Pos 29U /*!< xPSR: C Position */ -#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ - -#define xPSR_V_Pos 28U /*!< xPSR: V Position */ -#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ - -#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ -#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ - -#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ -#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ - -#define xPSR_T_Pos 24U /*!< xPSR: T Position */ -#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ - -#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ -#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ - - -/** - \brief Union type to access the Control Registers (CONTROL). - */ -typedef union -{ - struct - { - uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ - uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ - uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ - } b; /*!< Structure used for bit access */ - uint32_t w; /*!< Type used for word access */ -} CONTROL_Type; - -/* CONTROL Register Definitions */ -#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ -#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ - -#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ -#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ - -/*@} end of group CMSIS_CORE */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) - \brief Type definitions for the NVIC Registers - @{ - */ - -/** - \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). - */ -typedef struct -{ - __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ - uint32_t RESERVED0[24U]; - __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ - uint32_t RSERVED1[24U]; - __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ - uint32_t RESERVED2[24U]; - __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ - uint32_t RESERVED3[24U]; - __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ - uint32_t RESERVED4[56U]; - __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ - uint32_t RESERVED5[644U]; - __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ -} NVIC_Type; - -/* Software Triggered Interrupt Register Definitions */ -#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ -#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ - -/*@} end of group CMSIS_NVIC */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCB System Control Block (SCB) - \brief Type definitions for the System Control Block Registers - @{ - */ - -/** - \brief Structure type to access the System Control Block (SCB). - */ -typedef struct -{ - __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ - __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ - __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ - __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ - __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ - __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ - __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ - __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ - __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ - __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ - __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ - __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ - __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ - __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ - __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ - __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ - __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ - __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ - __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ - uint32_t RESERVED0[5U]; - __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ - uint32_t RESERVED1[129U]; - __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ -} SCB_Type; - -/* SCB CPUID Register Definitions */ -#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ -#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ - -#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ -#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ - -#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ -#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ - -#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ -#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ - -#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ -#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ - -/* SCB Interrupt Control State Register Definitions */ -#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ -#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ - -#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ -#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ - -#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ -#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ - -#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ -#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ - -#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ -#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ - -#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ -#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ - -#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ -#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ - -#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ -#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ - -#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ -#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ - -#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ -#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ - -/* SCB Vector Table Offset Register Definitions */ -#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ -#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ - -#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ -#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ - -/* SCB Application Interrupt and Reset Control Register Definitions */ -#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ -#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ - -#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ -#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ - -#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ -#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ - -#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ -#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ - -#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ -#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ - -#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ -#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ - -#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ -#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ - -/* SCB System Control Register Definitions */ -#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ -#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ - -#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ -#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ - -#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ -#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ - -/* SCB Configuration Control Register Definitions */ -#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ -#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ - -#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ -#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ - -#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ -#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ - -#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ -#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ - -#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ -#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ - -#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ -#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ - -/* SCB System Handler Control and State Register Definitions */ -#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ -#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ - -#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ -#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ - -#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ -#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ - -#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ -#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ - -#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ -#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ - -#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ -#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ - -#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ -#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ - -#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ -#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ - -#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ -#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ - -#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ -#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ - -#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ -#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ - -#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ -#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ - -#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ -#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ - -#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ -#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ - -/* SCB Configurable Fault Status Register Definitions */ -#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ -#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ - -#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ -#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ - -#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ -#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ - -/* SCB Hard Fault Status Register Definitions */ -#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ -#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ - -#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ -#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ - -#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ -#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ - -/* SCB Debug Fault Status Register Definitions */ -#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ -#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ - -#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ -#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ - -#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ -#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ - -#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ -#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ - -#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ -#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ - -/*@} end of group CMSIS_SCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) - \brief Type definitions for the System Control and ID Register not in the SCB - @{ - */ - -/** - \brief Structure type to access the System Control and ID Register not in the SCB. - */ -typedef struct -{ - uint32_t RESERVED0[1U]; - __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ - uint32_t RESERVED1[1U]; -} SCnSCB_Type; - -/* Interrupt Controller Type Register Definitions */ -#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ -#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ - -/*@} end of group CMSIS_SCnotSCB */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_SysTick System Tick Timer (SysTick) - \brief Type definitions for the System Timer Registers. - @{ - */ - -/** - \brief Structure type to access the System Timer (SysTick). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ - __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ - __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ - __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ -} SysTick_Type; - -/* SysTick Control / Status Register Definitions */ -#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ -#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ - -#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ -#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ - -#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ -#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ - -#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ -#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ - -/* SysTick Reload Register Definitions */ -#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ -#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ - -/* SysTick Current Register Definitions */ -#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ -#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ - -/* SysTick Calibration Register Definitions */ -#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ -#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ - -#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ -#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ - -#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ -#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ - -/*@} end of group CMSIS_SysTick */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) - \brief Type definitions for the Instrumentation Trace Macrocell (ITM) - @{ - */ - -/** - \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). - */ -typedef struct -{ - __OM union - { - __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ - __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ - __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ - } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ - uint32_t RESERVED0[864U]; - __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ - uint32_t RESERVED1[15U]; - __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ - uint32_t RESERVED2[15U]; - __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ - uint32_t RESERVED3[29U]; - __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ - __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ - __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ - uint32_t RESERVED4[43U]; - __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ - __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ - uint32_t RESERVED5[6U]; - __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ - __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ - __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ - __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ - __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ - __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ - __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ - __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ - __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ - __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ - __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ - __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ -} ITM_Type; - -/* ITM Trace Privilege Register Definitions */ -#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ -#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ - -/* ITM Trace Control Register Definitions */ -#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ -#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ - -#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ -#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ - -#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ -#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ - -#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ -#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ - -#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ -#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ - -#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ -#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ - -#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ -#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ - -#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ -#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ - -#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ -#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ - -/* ITM Integration Write Register Definitions */ -#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ -#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ - -/* ITM Integration Read Register Definitions */ -#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ -#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ - -/* ITM Integration Mode Control Register Definitions */ -#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ -#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ - -/* ITM Lock Status Register Definitions */ -#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ -#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ - -#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ -#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ - -#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ -#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ - -/*@}*/ /* end of group CMSIS_ITM */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) - \brief Type definitions for the Data Watchpoint and Trace (DWT) - @{ - */ - -/** - \brief Structure type to access the Data Watchpoint and Trace Register (DWT). - */ -typedef struct -{ - __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ - __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ - __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ - __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ - __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ - __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ - __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ - __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ - __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ - __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ - uint32_t RESERVED0[1U]; - __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ - __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ - __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ - uint32_t RESERVED1[1U]; - __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ - __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ - __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ - uint32_t RESERVED2[1U]; - __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ - __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ - __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ -} DWT_Type; - -/* DWT Control Register Definitions */ -#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ -#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ - -#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ -#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ - -#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ -#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ - -#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ -#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ - -#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ -#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ - -#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ -#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ - -#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ -#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ - -#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ -#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ - -#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ -#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ - -#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ -#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ - -#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ -#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ - -#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ -#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ - -#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ -#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ - -#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ -#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ - -#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ -#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ - -#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ -#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ - -#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ -#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ - -#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ -#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ - -/* DWT CPI Count Register Definitions */ -#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ -#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ - -/* DWT Exception Overhead Count Register Definitions */ -#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ -#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ - -/* DWT Sleep Count Register Definitions */ -#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ -#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ - -/* DWT LSU Count Register Definitions */ -#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ -#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ - -/* DWT Folded-instruction Count Register Definitions */ -#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ -#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ - -/* DWT Comparator Mask Register Definitions */ -#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ -#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ - -/* DWT Comparator Function Register Definitions */ -#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ -#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ - -#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ -#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ - -#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ -#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ - -#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ -#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ - -#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ -#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ - -#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ -#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ - -#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ -#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ - -#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ -#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ - -#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ -#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ - -/*@}*/ /* end of group CMSIS_DWT */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_TPI Trace Port Interface (TPI) - \brief Type definitions for the Trace Port Interface (TPI) - @{ - */ - -/** - \brief Structure type to access the Trace Port Interface Register (TPI). - */ -typedef struct -{ - __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ - __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ - uint32_t RESERVED0[2U]; - __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ - uint32_t RESERVED1[55U]; - __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ - uint32_t RESERVED2[131U]; - __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ - __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ - __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ - uint32_t RESERVED3[759U]; - __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ - __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ - __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ - uint32_t RESERVED4[1U]; - __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ - __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ - __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ - uint32_t RESERVED5[39U]; - __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ - __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ - uint32_t RESERVED7[8U]; - __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ - __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ -} TPI_Type; - -/* TPI Asynchronous Clock Prescaler Register Definitions */ -#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ -#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ - -/* TPI Selected Pin Protocol Register Definitions */ -#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ -#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ - -/* TPI Formatter and Flush Status Register Definitions */ -#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ -#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ - -#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ -#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ - -#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ -#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ - -#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ -#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ - -/* TPI Formatter and Flush Control Register Definitions */ -#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ -#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ - -#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ -#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ - -/* TPI TRIGGER Register Definitions */ -#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ -#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ - -/* TPI Integration ETM Data Register Definitions (FIFO0) */ -#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ -#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ - -#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ -#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ - -#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ -#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ - -#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ -#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ - -#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ -#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ - -#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ -#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ - -#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ -#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ - -/* TPI ITATBCTR2 Register Definitions */ -#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ -#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ - -/* TPI Integration ITM Data Register Definitions (FIFO1) */ -#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ -#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ - -#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ -#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ - -#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ -#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ - -#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ -#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ - -#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ -#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ - -#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ -#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ - -#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ -#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ - -/* TPI ITATBCTR0 Register Definitions */ -#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ -#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ - -/* TPI Integration Mode Control Register Definitions */ -#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ -#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ - -/* TPI DEVID Register Definitions */ -#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ -#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ - -#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ -#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ - -#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ -#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ - -#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ -#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ - -#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ -#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ - -#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ -#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ - -/* TPI DEVTYPE Register Definitions */ -#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ -#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ - -#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ -#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ - -/*@}*/ /* end of group CMSIS_TPI */ - - -#if (__MPU_PRESENT == 1U) -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_MPU Memory Protection Unit (MPU) - \brief Type definitions for the Memory Protection Unit (MPU) - @{ - */ - -/** - \brief Structure type to access the Memory Protection Unit (MPU). - */ -typedef struct -{ - __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ - __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ - __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ - __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ - __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ - __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ - __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ - __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ - __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ - __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ -} MPU_Type; - -/* MPU Type Register Definitions */ -#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ -#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ - -#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ -#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ - -#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ -#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ - -/* MPU Control Register Definitions */ -#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ -#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ - -#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ -#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ - -#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ -#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ - -/* MPU Region Number Register Definitions */ -#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ -#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ - -/* MPU Region Base Address Register Definitions */ -#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ -#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ - -#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ -#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ - -#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ -#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ - -/* MPU Region Attribute and Size Register Definitions */ -#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ -#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ - -#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ -#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ - -#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ -#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ - -#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ -#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ - -#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ -#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ - -#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ -#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ - -#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ -#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ - -#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ -#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ - -#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ -#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ - -#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ -#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ - -/*@} end of group CMSIS_MPU */ -#endif - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) - \brief Type definitions for the Core Debug Registers - @{ - */ - -/** - \brief Structure type to access the Core Debug Register (CoreDebug). - */ -typedef struct -{ - __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ - __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ - __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ - __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ -} CoreDebug_Type; - -/* Debug Halting Control and Status Register Definitions */ -#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ -#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ - -#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ -#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ - -#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ -#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ - -#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ -#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ - -#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ -#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ - -#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ -#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ - -#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ -#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ - -#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ -#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ - -#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ -#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ - -#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ -#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ - -#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ -#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ - -#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ -#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ - -/* Debug Core Register Selector Register Definitions */ -#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ -#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ - -#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ -#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ - -/* Debug Exception and Monitor Control Register Definitions */ -#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ -#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ - -#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ -#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ - -#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ -#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ - -#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ -#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ - -#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ -#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ - -#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ -#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ - -#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ -#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ - -#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ -#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ - -#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ -#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ - -#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ -#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ - -#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ -#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ - -#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ -#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ - -#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ -#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ - -/*@} end of group CMSIS_CoreDebug */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_bitfield Core register bit field macros - \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). - @{ - */ - -/** - \brief Mask and shift a bit field value for use in a register bit range. - \param[in] field Name of the register bit field. - \param[in] value Value of the bit field. - \return Masked and shifted value. -*/ -#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) - -/** - \brief Mask and shift a register value to extract a bit filed value. - \param[in] field Name of the register bit field. - \param[in] value Value of register. - \return Masked and shifted bit field value. -*/ -#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) - -/*@} end of group CMSIS_core_bitfield */ - - -/** - \ingroup CMSIS_core_register - \defgroup CMSIS_core_base Core Definitions - \brief Definitions for base addresses, unions, and structures. - @{ - */ - -/* Memory mapping of Cortex-M3 Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ -#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ -#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ -#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ -#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ -#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ -#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ -#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ - -#if (__MPU_PRESENT == 1U) - #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ - #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ -#endif - -/*@} */ - - - -/******************************************************************************* - * Hardware Abstraction Layer - Core Function Interface contains: - - Core NVIC Functions - - Core SysTick Functions - - Core Debug Functions - - Core Register Access Functions - ******************************************************************************/ -/** - \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference -*/ - - - -/* ########################## NVIC functions #################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_NVICFunctions NVIC Functions - \brief Functions that manage interrupts and exceptions via the NVIC. - @{ - */ - -/** - \brief Set Priority Grouping - \details Sets the priority grouping field using the required unlock sequence. - The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. - Only values from 0..7 are used. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Priority grouping field. - */ -__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) -{ - uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ - reg_value = (reg_value | - ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ - SCB->AIRCR = reg_value; -} - - -/** - \brief Get Priority Grouping - \details Reads the priority grouping field from the NVIC Interrupt Controller. - \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). - */ -__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) -{ - return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); -} - - -/** - \brief Enable External Interrupt - \details Enables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) -{ - NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Disable External Interrupt - \details Disables a device-specific interrupt in the NVIC interrupt controller. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) -{ - NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Pending Interrupt - \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not pending. - \return 1 Interrupt status is pending. - */ -__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Pending Interrupt - \details Sets the pending bit of an external interrupt. - \param [in] IRQn Interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Clear Pending Interrupt - \details Clears the pending bit of an external interrupt. - \param [in] IRQn External interrupt number. Value cannot be negative. - */ -__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); -} - - -/** - \brief Get Active Interrupt - \details Reads the active register in NVIC and returns the active bit. - \param [in] IRQn Interrupt number. - \return 0 Interrupt status is not active. - \return 1 Interrupt status is active. - */ -__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) -{ - return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); -} - - -/** - \brief Set Interrupt Priority - \details Sets the priority of an interrupt. - \note The priority cannot be set for every core interrupt. - \param [in] IRQn Interrupt number. - \param [in] priority Priority to set. - */ -__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - if ((int32_t)(IRQn) < 0) - { - SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } - else - { - NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); - } -} - - -/** - \brief Get Interrupt Priority - \details Reads the priority of an interrupt. - The interrupt number can be positive to specify an external (device specific) interrupt, - or negative to specify an internal (core) interrupt. - \param [in] IRQn Interrupt number. - \return Interrupt Priority. - Value is aligned automatically to the implemented priority bits of the microcontroller. - */ -__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) -{ - - if ((int32_t)(IRQn) < 0) - { - return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); - } - else - { - return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); - } -} - - -/** - \brief Encode Priority - \details Encodes the priority for an interrupt with the given priority group, - preemptive priority value, and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. - \param [in] PriorityGroup Used priority group. - \param [in] PreemptPriority Preemptive priority value (starting from 0). - \param [in] SubPriority Subpriority value (starting from 0). - \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). - */ -__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - return ( - ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | - ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) - ); -} - - -/** - \brief Decode Priority - \details Decodes an interrupt priority value with a given priority group to - preemptive priority value and subpriority value. - In case of a conflict between priority grouping and available - priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. - \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). - \param [in] PriorityGroup Used priority group. - \param [out] pPreemptPriority Preemptive priority value (starting from 0). - \param [out] pSubPriority Subpriority value (starting from 0). - */ -__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) -{ - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ - uint32_t PreemptPriorityBits; - uint32_t SubPriorityBits; - - PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); - SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); - - *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); - *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); -} - - -/** - \brief System Reset - \details Initiates a system reset request to reset the MCU. - */ -__STATIC_INLINE void NVIC_SystemReset(void) -{ - __DSB(); /* Ensure all outstanding memory accesses included - buffered write are completed before reset */ - SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | - SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ - __DSB(); /* Ensure completion of memory access */ - - for(;;) /* wait until reset */ - { - __NOP(); - } -} - -/*@} end of CMSIS_Core_NVICFunctions */ - - - -/* ################################## SysTick function ############################################ */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_SysTickFunctions SysTick Functions - \brief Functions that configure the System. - @{ - */ - -#if (__Vendor_SysTickConfig == 0U) - -/** - \brief System Tick Configuration - \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. - Counter is in free running mode to generate periodic interrupts. - \param [in] ticks Number of ticks between two interrupts. - \return 0 Function succeeded. - \return 1 Function failed. - \note When the variable __Vendor_SysTickConfig is set to 1, then the - function SysTick_Config is not included. In this case, the file device.h - must contain a vendor-specific implementation of this function. - */ -__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) -{ - if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) - { - return (1UL); /* Reload value impossible */ - } - - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | - SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ - return (0UL); /* Function successful */ -} - -#endif - -/*@} end of CMSIS_Core_SysTickFunctions */ - - - -/* ##################################### Debug In/Output function ########################################### */ -/** - \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_core_DebugFunctions ITM Functions - \brief Functions that access the ITM debug interface. - @{ - */ - -extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ -#define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ - - -/** - \brief ITM Send Character - \details Transmits a character via the ITM channel 0, and - \li Just returns when no debugger is connected that has booked the output. - \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. - \param [in] ch Character to transmit. - \returns Character to transmit. - */ -__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) -{ - if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ - ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ - { - while (ITM->PORT[0U].u32 == 0UL) - { - __NOP(); - } - ITM->PORT[0U].u8 = (uint8_t)ch; - } - return (ch); -} - - -/** - \brief ITM Receive Character - \details Inputs a character via the external variable \ref ITM_RxBuffer. - \return Received character. - \return -1 No character pending. - */ -__STATIC_INLINE int32_t ITM_ReceiveChar (void) -{ - int32_t ch = -1; /* no character available */ - - if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) - { - ch = ITM_RxBuffer; - ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ - } - - return (ch); -} - - -/** - \brief ITM Check Character - \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. - \return 0 No character available. - \return 1 Character available. - */ -__STATIC_INLINE int32_t ITM_CheckChar (void) -{ - - if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) - { - return (0); /* no character available */ - } - else - { - return (1); /* character available */ - } -} - -/*@} end of CMSIS_core_DebugFunctions */ - - - - -#ifdef __cplusplus -} -#endif - -#endif /* __CORE_SC300_H_DEPENDANT */ - -#endif /* __CMSIS_GENERIC */ diff --git a/user/mpy/lib/embed/abort_.c b/user/mpy/lib/embed/abort_.c deleted file mode 100644 index a6df814..0000000 --- a/user/mpy/lib/embed/abort_.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -NORETURN void abort_(void); - -NORETURN void abort_(void) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "abort() called")); -} diff --git a/user/mpy/lib/libc/string0.c b/user/mpy/lib/libc/string0.c deleted file mode 100644 index c2f2abd..0000000 --- a/user/mpy/lib/libc/string0.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#define likely(x) __builtin_expect((x), 1) - -void *memcpy(void *dst, const void *src, size_t n) { - if (likely(!(((uintptr_t)dst) & 3) && !(((uintptr_t)src) & 3))) { - // pointers aligned - uint32_t *d = dst; - const uint32_t *s = src; - - // copy words first - for (size_t i = (n >> 2); i; i--) { - *d++ = *s++; - } - - if (n & 2) { - // copy half-word - *(uint16_t*)d = *(const uint16_t*)s; - d = (uint32_t*)((uint16_t*)d + 1); - s = (const uint32_t*)((const uint16_t*)s + 1); - } - - if (n & 1) { - // copy byte - *((uint8_t*)d) = *((const uint8_t*)s); - } - } else { - // unaligned access, copy bytes - uint8_t *d = dst; - const uint8_t *s = src; - - for (; n; n--) { - *d++ = *s++; - } - } - - return dst; -} - -void *memmove(void *dest, const void *src, size_t n) { - if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) { - // need to copy backwards - uint8_t *d = (uint8_t*)dest + n - 1; - const uint8_t *s = (const uint8_t*)src + n - 1; - for (; n > 0; n--) { - *d-- = *s--; - } - return dest; - } else { - // can use normal memcpy - return memcpy(dest, src, n); - } -} - -void *memset(void *s, int c, size_t n) { - if (c == 0 && ((uintptr_t)s & 3) == 0) { - // aligned store of 0 - uint32_t *s32 = s; - for (size_t i = n >> 2; i > 0; i--) { - *s32++ = 0; - } - if (n & 2) { - *((uint16_t*)s32) = 0; - s32 = (uint32_t*)((uint16_t*)s32 + 1); - } - if (n & 1) { - *((uint8_t*)s32) = 0; - } - } else { - uint8_t *s2 = s; - for (; n > 0; n--) { - *s2++ = c; - } - } - return s; -} - -int memcmp(const void *s1, const void *s2, size_t n) { - const uint8_t *s1_8 = s1; - const uint8_t *s2_8 = s2; - while (n--) { - char c1 = *s1_8++; - char c2 = *s2_8++; - if (c1 < c2) return -1; - else if (c1 > c2) return 1; - } - return 0; -} - -void *memchr(const void *s, int c, size_t n) { - if (n != 0) { - const unsigned char *p = s; - - do { - if (*p++ == c) - return ((void *)(p - 1)); - } while (--n != 0); - } - return 0; -} - -size_t strlen(const char *str) { - int len = 0; - for (const char *s = str; *s; s++) { - len += 1; - } - return len; -} - -int strcmp(const char *s1, const char *s2) { - while (*s1 && *s2) { - char c1 = *s1++; // XXX UTF8 get char, next char - char c2 = *s2++; // XXX UTF8 get char, next char - if (c1 < c2) return -1; - else if (c1 > c2) return 1; - } - if (*s2) return -1; - else if (*s1) return 1; - else return 0; -} - -int strncmp(const char *s1, const char *s2, size_t n) { - while (*s1 && *s2 && n > 0) { - char c1 = *s1++; // XXX UTF8 get char, next char - char c2 = *s2++; // XXX UTF8 get char, next char - n--; - if (c1 < c2) return -1; - else if (c1 > c2) return 1; - } - if (n == 0) return 0; - else if (*s2) return -1; - else if (*s1) return 1; - else return 0; -} - -char *strcpy(char *dest, const char *src) { - char *d = dest; - while (*src) { - *d++ = *src++; - } - *d = '\0'; - return dest; -} - -// needed because gcc optimises strcpy + strcat to this -char *stpcpy(char *dest, const char *src) { - while (*src) { - *dest++ = *src++; - } - *dest = '\0'; - return dest; -} - -char *strcat(char *dest, const char *src) { - char *d = dest; - while (*d) { - d++; - } - while (*src) { - *d++ = *src++; - } - *d = '\0'; - return dest; -} - -// Public Domain implementation of strchr from: -// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strchr_function -char *strchr(const char *s, int c) -{ - /* Scan s for the character. When this loop is finished, - s will either point to the end of the string or the - character we were looking for. */ - while (*s != '\0' && *s != (char)c) - s++; - return ((*s == c) ? (char *) s : 0); -} - - -// Public Domain implementation of strstr from: -// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strstr_function -char *strstr(const char *haystack, const char *needle) -{ - size_t needlelen; - /* Check for the null needle case. */ - if (*needle == '\0') - return (char *) haystack; - needlelen = strlen(needle); - for (; (haystack = strchr(haystack, *needle)) != 0; haystack++) - if (strncmp(haystack, needle, needlelen) == 0) - return (char *) haystack; - return 0; -} diff --git a/user/mpy/lib/libffi/.gitignore b/user/mpy/lib/libffi/.gitignore deleted file mode 100644 index 6f89994..0000000 --- a/user/mpy/lib/libffi/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -.libs -.deps -*.o -*.lo -.dirstamp -*.la -Makefile -Makefile.in -aclocal.m4 -compile -config.* -configure -depcomp -doc/libffi.info -*~ -fficonfig.h.in -fficonfig.h -include/ffi.h -include/ffitarget.h -install-sh -libffi.pc -libtool -libtool-ldflags -ltmain.sh -m4/libtool.m4 -m4/lt*.m4 -mdate-sh -missing -stamp-h1 -libffi*gz -autom4te.cache -libffi.xcodeproj/xcuserdata -libffi.xcodeproj/project.xcworkspace -build_*/ -darwin_*/ -src/arm/trampoline.S diff --git a/user/mpy/lib/libffi/.travis.yml b/user/mpy/lib/libffi/.travis.yml deleted file mode 100644 index 6c14fcd..0000000 --- a/user/mpy/lib/libffi/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: cpp -compiler: - - gcc - - clang -env: - - - - HOST=i386-pc-linux-gnu -matrix: - exclude: - - compiler: clang - env: HOST=i386-pc-linux-gnu - -before_script: - - sudo apt-get install dejagnu texinfo - - if [ "$HOST" = i386-pc-linux-gnu ] ; then sudo apt-get install gcc-multilib g++-multilib && CC="$CC -m32" && CXX="$CXX -m32" ; fi - -script: - - ./autogen.sh - - ./configure ${HOST+--host=$HOST} - - make - - make dist - - make check diff --git a/user/mpy/lib/libffi/ChangeLog.libffi b/user/mpy/lib/libffi/ChangeLog.libffi deleted file mode 100644 index 49ba8da..0000000 --- a/user/mpy/lib/libffi/ChangeLog.libffi +++ /dev/null @@ -1,584 +0,0 @@ -2011-02-08 Andreas Tobler - - * testsuite/lib/libffi.exp: Tweak for stand-alone mode. - -2009-12-25 Samuli Suominen - - * configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64. - * configure: Rebuilt. - * fficonfig.h.in: Rebuilt. - -2009-06-16 Andrew Haley - - * testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_medium2.c: Fix printf format - specifiers. - * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs. - * testsuite/libffi.call/float2.c: Fix dg-excess-errors. - * testsuite/libffi.call/ffitest.h, - testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define. - -2009-06-12 Andrew Haley - - * testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_medium2.c: Fix printf format - specifiers. - testsuite/libffi.special/unwindtest.cc: include stdint.h. - -2009-06-11 Timothy Wall - - * Makefile.am, - configure.ac, - include/ffi.h.in, - include/ffi_common.h, - src/closures.c, - src/dlmalloc.c, - src/x86/ffi.c, - src/x86/ffitarget.h, - src/x86/win64.S (new), - README: Added win64 support (mingw or MSVC) - * Makefile.in, - include/Makefile.in, - man/Makefile.in, - testsuite/Makefile.in, - configure, - aclocal.m4: Regenerated - * ltcf-c.sh: properly escape cygwin/w32 path - * man/ffi_call.3: Clarify size requirements for return value. - * src/x86/ffi64.c: Fix filename in comment. - * src/x86/win32.S: Remove unused extern. - - * testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/cls_12byte.c, - testsuite/libffi.call/cls_16byte.c, - testsuite/libffi.call/cls_18byte.c, - testsuite/libffi.call/cls_19byte.c, - testsuite/libffi.call/cls_1_1byte.c, - testsuite/libffi.call/cls_20byte.c, - testsuite/libffi.call/cls_20byte1.c, - testsuite/libffi.call/cls_24byte.c, - testsuite/libffi.call/cls_2byte.c, - testsuite/libffi.call/cls_3_1byte.c, - testsuite/libffi.call/cls_3byte1.c, - testsuite/libffi.call/cls_3byte2.c, - testsuite/libffi.call/cls_4_1byte.c, - testsuite/libffi.call/cls_4byte.c, - testsuite/libffi.call/cls_5_1_byte.c, - testsuite/libffi.call/cls_5byte.c, - testsuite/libffi.call/cls_64byte.c, - testsuite/libffi.call/cls_6_1_byte.c, - testsuite/libffi.call/cls_6byte.c, - testsuite/libffi.call/cls_7_1_byte.c, - testsuite/libffi.call/cls_7byte.c, - testsuite/libffi.call/cls_8byte.c, - testsuite/libffi.call/cls_9byte1.c, - testsuite/libffi.call/cls_9byte2.c, - testsuite/libffi.call/cls_align_double.c, - testsuite/libffi.call/cls_align_float.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_align_sint16.c, - testsuite/libffi.call/cls_align_sint32.c, - testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint16.c, - testsuite/libffi.call/cls_align_uint32.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_dbls_struct.c, - testsuite/libffi.call/cls_double.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_float.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_multi_schar.c, - testsuite/libffi.call/cls_multi_sshort.c, - testsuite/libffi.call/cls_multi_sshortchar.c, - testsuite/libffi.call/cls_multi_uchar.c, - testsuite/libffi.call/cls_multi_ushort.c, - testsuite/libffi.call/cls_multi_ushortchar.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c, - testsuite/libffi.call/cls_schar.c, - testsuite/libffi.call/cls_sint.c, - testsuite/libffi.call/cls_sshort.c, - testsuite/libffi.call/cls_uchar.c, - testsuite/libffi.call/cls_uint.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/cls_ushort.c, - testsuite/libffi.call/err_bad_abi.c, - testsuite/libffi.call/err_bad_typedef.c, - testsuite/libffi.call/float2.c, - testsuite/libffi.call/huge_struct.c, - testsuite/libffi.call/nested_struct.c, - testsuite/libffi.call/nested_struct1.c, - testsuite/libffi.call/nested_struct10.c, - testsuite/libffi.call/nested_struct2.c, - testsuite/libffi.call/nested_struct3.c, - testsuite/libffi.call/nested_struct4.c, - testsuite/libffi.call/nested_struct5.c, - testsuite/libffi.call/nested_struct6.c, - testsuite/libffi.call/nested_struct7.c, - testsuite/libffi.call/nested_struct8.c, - testsuite/libffi.call/nested_struct9.c, - testsuite/libffi.call/problem1.c, - testsuite/libffi.call/return_ldl.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_large.c, - testsuite/libffi.call/stret_large2.c, - testsuite/libffi.call/stret_medium.c, - testsuite/libffi.call/stret_medium2.c, - testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead - of checking for MMAP. Use intptr_t instead of long casts. - -2009-06-04 Andrew Haley - - * src/powerpc/ffitarget.h: Fix misapplied merge from gcc. - -2009-06-04 Andrew Haley - - * src/mips/o32.S, - src/mips/n32.S: Fix licence formatting. - -2009-06-04 Andrew Haley - - * src/x86/darwin.S: Fix licence formatting. - src/x86/win32.S: Likewise. - src/sh64/sysv.S: Likewise. - src/sh/sysv.S: Likewise. - -2009-06-04 Andrew Haley - - * src/sh64/ffi.c: Remove lint directives. Was missing from merge - of Andreas Tobler's patch from 2006-04-22. - -2009-06-04 Andrew Haley - - * src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of - 2007-03-07. - -2008-12-26 Timothy Wall - - * testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected - failures on x86_64 cygwin/mingw. - -2008-12-22 Timothy Wall - - * testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/closure_loc_fn0.c, - testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c: use portable cast from - pointer to integer (intptr_t). - * testsuite/libffi.call/cls_longdouble.c: disable for win64. - -2008-12-19 Anthony Green - - * configure.ac: Bump version to 3.0.8. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-11-11 Anthony Green - - * configure.ac: Bump version to 3.0.7. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-08-25 Andreas Tobler - - * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and - FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. - Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. - Adjust copyright notice. - * src/powerpc/ffi.c: Add two new flags to indicate if we have one - register or two register to use for FFI_SYSV structs. - (ffi_prep_cif_machdep): Pass the right register flag introduced above. - (ffi_closure_helper_SYSV): Fix the return type for - FFI_SYSV_TYPE_SMALL_STRUCT. Comment. - Adjust copyright notice. - -2008-07-24 Anthony Green - - * testsuite/libffi.call/cls_dbls_struct.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c, - testsuite/libffi.call/err_bad_abi.c: Clean up failures from - compiler warnings. - -2008-07-17 Anthony Green - - * configure.ac: Bump version to 3.0.6. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. Add documentation. - * README: Update for new release. - -2008-07-16 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned - int. - -2008-07-16 Kaz Kojima - - * src/sh/sysv.S: Add .note.GNU-stack on Linux. - * src/sh64/sysv.S: Likewise. - -2008-04-03 Anthony Green - - * libffi.pc.in (Libs): Add -L${libdir}. - * configure.ac: Bump version to 3.0.5. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-04-03 Anthony Green - Xerces Ranby - - * include/ffi.h.in: Wrap definition of target architecture to - protect from double definitions. - -2008-03-22 Moriyoshi Koizumi - - * src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in - closure_loc_fn0.c. - * testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0): - New test. - -2008-03-04 Anthony Green - Blake Chaffin - hos@tamanegi.org - - * testsuite/libffi.call/cls_align_longdouble_split2.c - testsuite/libffi.call/cls_align_longdouble_split.c - testsuite/libffi.call/cls_dbls_struct.c - testsuite/libffi.call/cls_double_va.c - testsuite/libffi.call/cls_longdouble.c - testsuite/libffi.call/cls_longdouble_va.c - testsuite/libffi.call/cls_pointer.c - testsuite/libffi.call/cls_pointer_stack.c - testsuite/libffi.call/err_bad_abi.c - testsuite/libffi.call/err_bad_typedef.c - testsuite/libffi.call/huge_struct.c - testsuite/libffi.call/stret_large2.c - testsuite/libffi.call/stret_large.c - testsuite/libffi.call/stret_medium2.c - testsuite/libffi.call/stret_medium.c: New tests from Apple. - -2008-02-26 Jakub Jelinek - Anthony Green - - * src/alpha/osf.S: Add .note.GNU-stack on Linux. - * src/s390/sysv.S: Likewise. - * src/powerpc/linux64.S: Likewise. - * src/powerpc/linux64_closure.S: Likewise. - * src/powerpc/ppc_closure.S: Likewise. - * src/powerpc/sysv.S: Likewise. - * src/x86/unix64.S: Likewise. - * src/x86/sysv.S: Likewise. - * src/sparc/v8.S: Likewise. - * src/sparc/v9.S: Likewise. - * src/m68k/sysv.S: Likewise. - * src/ia64/unix.S: Likewise. - * src/arm/sysv.S: Likewise. - -2008-02-26 Anthony Green - Thomas Heller - - * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C - comment. - -2008-02-26 Anthony Green - Thomas Heller - - * include/ffi.h.in: Change void (*)() to void (*)(void). - -2008-02-26 Anthony Green - Thomas Heller - - * src/alpha/ffi.c: Change void (*)() to void (*)(void). - src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c, - src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c, - src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S, - src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c, - src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c, - src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S, - src/x86/ffi64.c: Ditto. - -2008-02-24 Anthony Green - - * configure.ac: Accept openbsd*, not just openbsd. - Bump version to 3.0.4. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-02-22 Anthony Green - - * README: Clean up list of tested platforms. - -2008-02-22 Anthony Green - - * configure.ac: Bump version to 3.0.3. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. Clean up test docs. - -2008-02-22 Bjoern Koenig - Andreas Tobler - - * configure.ac: Add amd64-*-freebsd* target. - * configure: Regenerate. - -2008-02-22 Thomas Heller - - * configure.ac: Add x86 OpenBSD support. - * configure: Rebuilt. - -2008-02-21 Thomas Heller - - * README: Change "make test" to "make check". - -2008-02-21 Anthony Green - - * configure.ac: Bump version to 3.0.2. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-02-21 Björn König - - * src/x86/freebsd.S: New file. - * configure.ac: Add x86 FreeBSD support. - * Makefile.am: Ditto. - -2008-02-15 Anthony Green - - * configure.ac: Bump version to 3.0.1. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-02-15 David Daney - - * src/mips/ffi.c: Remove extra '>' from include directive. - (ffi_prep_closure_loc): Use clear_location instead of tramp. - -2008-02-15 Anthony Green - - * configure.ac: Bump version to 3.0.0. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - -2008-02-15 David Daney - - * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE): - Define (conditionally), and use it to include cachectl.h. - (ffi_prep_closure_loc): Fix cache flushing. - * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define. - -2008-02-15 Anthony Green - - * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3: - Update dates and remove all references to ffi_prep_closure. - * configure.ac: Bump version to 2.99.9. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - -2008-02-15 Anthony Green - - * man/ffi_prep_closure.3: Delete. - * man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3. - (man_MANS): Ditto. - * man/Makefile.in: Rebuilt. - * configure.ac: Bump version to 2.99.8. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - -2008-02-14 Anthony Green - - * configure.ac: Bump version to 2.99.7. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * include/ffi.h.in LICENSE src/debug.c src/closures.c - src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h - src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c - src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S - src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c - src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c - src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S - src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h - src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c - src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S - src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h - src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h - src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S - src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h - src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S - src/arm/ffitarget.h src/prep_cif.c: Update license text. - -2008-02-14 Anthony Green - - * README: Update tested platforms. - * configure.ac: Bump version to 2.99.6. - * configure: Rebuilt. - -2008-02-14 Anthony Green - - * configure.ac: Bump version to 2.99.5. - * configure: Rebuilt. - * Makefile.am (EXTRA_DIST): Add darwin64.S - * Makefile.in: Rebuilt. - * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree. - * LICENSE: Update WARRANTY. - -2008-02-14 Anthony Green - - * libffi.pc.in (libdir): Fix libdir definition. - * configure.ac: Bump version to 2.99.4. - * configure: Rebuilt. - -2008-02-14 Anthony Green - - * README: Update. - * libffi.info: New file. - * doc/stamp-vti: New file. - * configure.ac: Bump version to 2.99.3. - * configure: Rebuilt. - -2008-02-14 Anthony Green - - * Makefile.am (SUBDIRS): Add man dir. - * Makefile.in: Rebuilt. - * configure.ac: Create Makefile. - * configure: Rebuilt. - * man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3 - man/Makefile.am man/Makefile.in: New files. - -2008-02-14 Tom Tromey - - * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt. - * mdate-sh, texinfo.tex: New files. - * Makefile.am (info_TEXINFOS): New variable. - * doc/libffi.texi: New file. - * doc/version.texi: Likewise. - -2008-02-14 Anthony Green - - * Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET). - (lib_LTLIBRARIES): Define. - (toolexeclib_LIBRARIES): Undefine. - * Makefile.in: Rebuilt. - * configure.ac: Reset version to 2.99.1. - * configure.in: Rebuilt. - -2008-02-14 Anthony Green - - * libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@. - * configure.ac: Reset version to 2.99.1. - * configure.in: Rebuilt. - * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi. - * Makefile.in: Rebuilt. - * LICENSE: Update copyright notice. - -2008-02-14 Anthony Green - - * include/Makefile.am (nodist_includes_HEADERS): Define. Don't - distribute ffitarget.h or ffi.h from the build include dir. - * Makefile.in: Rebuilt. - -2008-02-14 Anthony Green - - * include/Makefile.am (includesdir): Install headers under libdir. - (pkgconfigdir): Define. Install libffi.pc. - * include/Makefile.in: Rebuilt. - * libffi.pc.in: Create. - * libtool-version: Increment CURRENT - * configure.ac: Add libffi.pc.in - * configure: Rebuilt. - -2008-02-03 Anthony Green - - * include/Makefile.am (includesdir): Fix header install with - DESTDIR. - * include/Makefile.in: Rebuilt. - -2008-02-03 Timothy Wall - - * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return - offset based on code pointer, not data pointer. - -2008-02-01 Anthony Green - - * include/Makefile.am: Fix header installs. - * Makefile.am: Ditto. - * include/Makefile.in: Rebuilt. - * Makefile.in: Ditto. - -2008-02-01 Anthony Green - - * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL, - FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last - patch. - -2008-01-31 Anthony Green - - * Makefile.am (EXTRA_DIST): Add missing files. - * testsuite/Makefile.am: Ditto. - * Makefile.in, testsuite/Makefile.in: Rebuilt. - -2008-01-31 Timothy Wall - - * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall - closures. - * src/x86/ffitarget.h: Increase size of trampoline for stdcall - closures. - * src/x86/win32.S: Add assembly for stdcall closure. - * src/x86/ffi.c: Initialize stdcall closure trampoline. - -2008-01-30 H.J. Lu - - PR libffi/34612 - * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when - returning struct. - - * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer" - tests. - -2008-01-30 Anthony Green - - * Makefile.am, include/Makefile.am: Move headers to - libffi_la_SOURCES for new automake. - * Makefile.in, include/Makefile.in: Rebuilt. - - * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for - execution outside of gcc tree. - * testsuite/lib/target-libpath.exp: Ditto. - - * testsuite/lib/libffi-dg.exp: Many changes to allow for execution - outside of gcc tree. - diff --git a/user/mpy/lib/libffi/ChangeLog.libffi-3.1 b/user/mpy/lib/libffi/ChangeLog.libffi-3.1 deleted file mode 100644 index 8f7f50d..0000000 --- a/user/mpy/lib/libffi/ChangeLog.libffi-3.1 +++ /dev/null @@ -1,6000 +0,0 @@ -2014-03-16 Josh Triplett - - * ChangeLog: Archive to ChangeLog.libffi-3.1 and delete. Future - changelogs will come from git, with autogenerated snapshots shipped in - distributed tarballs. - -2014-03-16 Josh Triplett - - Add support for stdcall, thiscall, and fastcall on non-Windows - x86-32. - - Linux supports the stdcall calling convention, either via - functions explicitly declared with the stdcall attribute, or via - code compiled with -mrtd which effectively makes stdcall the - default. - - This introduces FFI_STDCALL, FFI_THISCALL, and FFI_FASTCALL on - non-Windows x86-32 platforms, as non-default calling conventions. - - * Makefile.am: Compile in src/x86/win32.S on non-Windows x86-32. - * src/x86/ffitarget.h: Add FFI_STDCALL, FFI_THISCALL, and - FFI_FASTCALL on non-Windows x86-32. Increase trampoline size to - accomodate these calling conventions, and unify some ifdeffery. - * src/x86/ffi.c: Add support for FFI_STDCALL, FFI_THISCALL, and - FFI_FASTCALL on non-Windows x86-32 platforms; update ifdeffery. - * src/x86/win32.S: Support compiling on non-Windows x86-32 - platforms. On those platforms, avoid redefining the SYSV symbols - already provided by src/x86/sysv.S. - * testsuite/libffi.call/closure_stdcall.c: Run on non-Windows. - #define __stdcall if needed. - * testsuite/libffi.call/closure_thiscall.c: Run on non-Windows. - #define __fastcall if needed. - * testsuite/libffi.call/fastthis1_win32.c: Run on non-Windows. - * testsuite/libffi.call/fastthis2_win32.c: Ditto. - * testsuite/libffi.call/fastthis3_win32.c: Ditto. - * testsuite/libffi.call/many2_win32.c: Ditto. - * testsuite/libffi.call/many_win32.c: Ditto. - * testsuite/libffi.call/strlen2_win32.c: Ditto. - * testsuite/libffi.call/strlen_win32.c: Ditto. - * testsuite/libffi.call/struct1_win32.c: Ditto. - * testsuite/libffi.call/struct2_win32.c: Ditto. - -2014-03-16 Josh Triplett - - * prep_cif.c: Remove unnecessary ifdef for X86_WIN32. - ffi_prep_cif_core had a special case for X86_WIN32, checking for - FFI_THISCALL in addition to the FFI_FIRST_ABI-to-FFI_LAST_ABI - range before returning FFI_BAD_ABI. However, on X86_WIN32, - FFI_THISCALL already falls in that range, making the special case - unnecessary. Remove it. - -2014-03-16 Josh Triplett - - * testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/closure_thiscall.c: Remove fragile stack - pointer checks. These files included inline assembly to save the - stack pointer before and after the call, and compare the values. - However, compilers can and do leave the stack in different states - for these two pieces of inline assembly, such as by saving a - temporary value on the stack across the call; observed with gcc - -Os, and verified as spurious through careful inspection of - disassembly. - -2014-03-16 Josh Triplett - - * testsuite/libffi.call/many.c: Avoid spurious failure due to - excess floating-point precision. - * testsuite/libffi.call/many_win32.c: Ditto. - -2014-03-16 Josh Triplett - - * libtool-ldflags: Re-add. - -2014-03-16 Josh Triplett - - * Makefile.in, aclocal.m4, compile, config.guess, config.sub, - configure, depcomp, include/Makefile.in, install-sh, - libtool-ldflags, ltmain.sh, m4/libtool.m4, m4/ltoptions.m4, - m4/ltsugar.m4, m4/ltversion.m4, m4/lt~obsolete.m4, - man/Makefile.in, mdate-sh, missing, testsuite/Makefile.in: Delete - autogenerated files from version control. - * .gitignore: Add autogenerated files. - * autogen.sh: New script to generate the autogenerated files. - * README: Document requirement to run autogen.sh when building - directly from version control. - * .travis.yml: Run autogen.sh - -2014-03-14 Anthony Green - - * configure, Makefile.in: Rebuilt. - -2014-03-10 Mike Hommey - - * configure.ac: Allow building for mipsel with Android NDK r8. - * Makefile.am (AM_MAKEFLAGS): Replace double quotes with single - quotes. - -2014-03-10 Landry Breuil - - * configure.ac: Ensure the linker supports @unwind sections in libffi. - -2014-03-01 Anthony Green - - * Makefile.am (EXTRA_DIST): Replace old scripts with - generate-darwin-source-and-headers.py. - * Makefile.in: Rebuilt. - -2014-02-28 Anthony Green - - * Makefile.am (AM_CFLAGS): Reintroduce missing -DFFI_DEBUG for - --enable-debug builds. - * Makefile.in: Rebuilt. - -2014-02-28 Makoto Kato - - * src/closures.c: Fix build failure when using clang for Android. - -2014-02-28 Marcin Wojdyr - - * libffi.pc.in (toolexeclibdir): use -L${toolexeclibdir} instead - of -L${libdir}. - -2014-02-28 Paulo Pizarro - - * src/bfin/sysv.S: Calling functions in shared libraries requires - considering the GOT. - -2014-02-28 Josh Triplett - - * src/x86/ffi64.c (classify_argument): Handle case where - FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE. - -2014-02-28 Anthony Green - - * ltmain.sh: Generate with libtool-2.4.2.418. - * m4/libtool.m4, m4/ltoptions.m4, m4/ltversion.m4: Ditto. - * configure: Rebuilt. - -2014-02-28 Dominik Vogt - - * configure.ac (AC_ARG_ENABLE struct): Fix typo in help - message. - (AC_ARG_ENABLE raw_api): Ditto. - * configure, fficonfig.h.in: Rebuilt. - -2014-02-28 Will Newton - - * src/arm/sysv.S: Initialize IP register with FP. - -2014-02-28 Yufeng Zhang - - * src/aarch64/sysv.S (ffi_closure_SYSV): Use x29 as the - main CFA reg; update cfi_rel_offset. - -2014-02-15 Marcus Comstedt - - * src/powerpc/ffi_linux64.c, src/powerpc/linux64_closure.S: Remove - assumption on contents of r11 in closure. - -2014-02-09 Heiher - - * src/mips/n32.S: Fix call floating point va function. - -2014-01-21 Zachary Waldowski - - * src/aarch64/ffi.c: Fix missing semicolons on assertions under - debug mode. - -2013-12-30 Zachary Waldowski - - * .gitignore: Exclude darwin_* generated source and build_* trees. - * src/aarch64/ffi.c, src/arm/ffi.c, src/x86/ffi.c: Inhibit Clang - previous prototype warnings. - * src/arm/ffi.c: Prevent NULL dereference, fix short type warning - * src/dlmalloc.c: Fix warnings from set_segment_flags return type, - and the native use of size_t for malloc on platforms - * src/arm/sysv.S: Use unified syntax. Clang clean-ups for - ARM_FUNC_START. - * generate-osx-source-and-headers.py: Remove. - * build-ios.sh: Remove. - * libffi.xcodeproj/project.pbxproj: Rebuild targets. Include - x86_64+aarch64 pieces in library. Export headers properly. - * src/x86/ffi64.c: More Clang warning clean-ups. - * src/closures.c (open_temp_exec_file_dir): Use size_t. - * src/prep_cif.c (ffi_prep_cif_core): Cast ALIGN result. - * src/aarch64/sysv.S: Use CNAME for global symbols. Only use - .size for ELF targets. - * src/aarch64/ffi.c: Clean up for double == long double. Clean up - from Clang warnings. Use Clang cache invalidation builtin. Use - size_t in place of unsigned in many places. Accommodate for - differences in Apple AArch64 ABI. - -2013-12-02 Daniel Rodríguez Troitiño - - * generate-darwin-source-and-headers.py: Clean up, modernize, - merged version of previous scripts. - -2013-11-21 Anthony Green - - * configure, Makefile.in, include/Makefile.in, include/ffi.h.in, - man/Makefile.in, testsuite/Makefile.in, fficonfig.h.in: Rebuilt. - -2013-11-21 Alan Modra - - * Makefile.am (EXTRA_DIST): Add new src/powerpc files. - (nodist_libffi_la_SOURCES ): Likewise. - * configure.ac (HAVE_LONG_DOUBLE_VARIANT): Define for powerpc. - * include/ffi.h.in (ffi_prep_types): Declare. - * src/prep_cif.c (ffi_prep_cif_core): Call ffi_prep_types. - * src/types.c (FFI_NONCONST_TYPEDEF): Define and use for - HAVE_LONG_DOUBLE_VARIANT. - * src/powerpc/ffi_powerpc.h: New file. - * src/powerpc/ffi.c: Split into.. - * src/powerpc/ffi_sysv.c: ..new file, and.. - * src/powerpc/ffi_linux64.c: ..new file, rewriting parts. - * src/powerpc/ffitarget.h (enum ffi_abi): Rewrite powerpc ABI - selection as bits controlling features. - * src/powerpc/linux64.S: For consistency, use POWERPC64 rather - than __powerpc64__. - * src/powerpc/linux64_closure.S: Likewise. - * src/powerpc/ppc_closure.S: Likewise. Move .note.FNU-stack - inside guard. - * src/powerpc/sysv.S: Likewise. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * Makefile.in: Regenerate. - -2013-11-20 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use - NUM_FPR_ARG_REGISTERS64 and NUM_GPR_ARG_REGISTERS64 not their - 32-bit versions for 64-bit code. - * src/powerpc/linux64_closure.S: Don't use the return value area - as a parameter save area on ELFv2. - -2013-11-18 Iain Sandoe - - * src/powerpc/darwin.S (EH): Correct use of pcrel FDE encoding. - * src/powerpc/darwin_closure.S (EH): Likewise. Modernise picbase - labels. - -2013-11-18 Anthony Green - - * src/arm/ffi.c (ffi_call): Hoist declaration of temp to top of - function. - * src/arm/ffi.c (ffi_closure_inner): Moderize function declaration - to appease compiler. - Thanks for Gregory P. Smith . - -2013-11-18 Anthony Green - - * README (tested): Mention PowerPC ELFv2. - -2013-11-16 Alan Modra - - * src/powerpc/ppc_closure.S: Move errant #endif to where it belongs. - Don't bl .Luint128. - -2013-11-16 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use #if _CALL_ELF - test to select parameter save sizing for ELFv2 vs. ELFv1. - * src/powerpc/ffitarget.h (FFI_V2_TYPE_FLOAT_HOMOG, - FFI_V2_TYPE_DOUBLE_HOMOG, FFI_V2_TYPE_SMALL_STRUCT): Define. - (FFI_TRAMPOLINE_SIZE): Define variant for ELFv2. - * src/powerpc/ffi.c (FLAG_ARG_NEEDS_PSAVE): Define. - (discover_homogeneous_aggregate): New function. - (ffi_prep_args64): Adjust start of param save area for ELFv2. - Handle homogenous floating point struct parms. - (ffi_prep_cif_machdep_core): Adjust space calculation for ELFv2. - Handle ELFv2 return values. Set FLAG_ARG_NEEDS_PSAVE. Handle - homogenous floating point structs. - (ffi_call): Increase size of smst_buffer for ELFv2. Handle ELFv2. - (flush_icache): Compile for ELFv2. - (ffi_prep_closure_loc): Set up ELFv2 trampoline. - (ffi_closure_helper_LINUX64): Don't return all structs directly - to caller. Handle homogenous floating point structs. Handle - ELFv2 struct return values. - * src/powerpc/linux64.S (ffi_call_LINUX64): Set up r2 for - ELFv2. Adjust toc save location. Call function pointer using - r12. Handle FLAG_RETURNS_SMST. Don't predict branches. - * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Set up r2 - for ELFv2. Define ELFv2 versions of STACKFRAME, PARMSAVE, and - RETVAL. Handle possibly missing parameter save area. Handle - ELFv2 return values. - (.note.GNU-stack): Move inside outer #ifdef. - -2013-11-16 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_cif_machdep): Revert 2013-02-08 - change. Do not consume an int arg when returning a small struct - for FFI_SYSV ABI. - (ffi_call): Only use bounce buffer when FLAG_RETURNS_SMST. - Properly copy bounce buffer to destination. - * src/powerpc/sysv.S: Revert 2013-02-08 change. - * src/powerpc/ppc_closure.S: Remove stray '+'. - -2013-11-16 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_args64): Align struct parameters - according to __STRUCT_PARM_ALIGN__. - (ffi_prep_cif_machdep_core): Likewise. - (ffi_closure_helper_LINUX64): Likewise. - -2013-11-16 Alan Modra - - * src/powerpc/linux64.S (ffi_call_LINUX64): Tweak restore of r28. - (.note.GNU-stack): Move inside outer #ifdef. - * src/powerpc/linux64_closure.S (STACKFRAME, PARMSAVE, - RETVAL): Define and use throughout. - (ffi_closure_LINUX64): Save fprs before buying stack. - (.note.GNU-stack): Move inside outer #ifdef. - -2013-11-16 Alan Modra - - * src/powerpc/ffitarget.h (FFI_TARGET_SPECIFIC_VARIADIC): Define. - (FFI_EXTRA_CIF_FIELDS): Define. - * src/powerpc/ffi.c (ffi_prep_args64): Save fprs as per the - ABI, not to both fpr and param save area. - (ffi_prep_cif_machdep_core): Renamed from ffi_prep_cif_machdep. - Keep initial flags. Formatting. Remove dead FFI_LINUX_SOFT_FLOAT - code. - (ffi_prep_cif_machdep, ffi_prep_cif_machdep_var): New functions. - (ffi_closure_helper_LINUX64): Pass floating point as per ABI, - not to both fpr and parameter save areas. - - * libffi/testsuite/libffi.call/cls_double_va.c (main): Correct - function cast and don't call ffi_prep_cif. - * libffi/testsuite/libffi.call/cls_longdouble_va.c (main): Likewise. - -2013-11-15 Andrew Haley - - * doc/libffi.texi (Closure Example): Fix the sample code. - * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt. - -2013-11-15 Andrew Haley - - * testsuite/libffi.call/va_struct1.c (main): Fix broken test. - * testsuite/libffi.call/cls_uint_va.c (cls_ret_T_fn): Likewise - * testsuite/libffi.call/cls_struct_va1.c (test_fn): Likewise. - * testsuite/libffi.call/va_1.c (main): Likewise. - -2013-11-14 David Schneider - - * src/arm/ffi.c: Fix register allocation for mixed float and - doubles. - * testsuite/libffi.call/cls_many_mixed_float_double.c: Testcase - for many mixed float and double arguments. - -2013-11-13 Alan Modra - - * doc/libffi.texi (Simple Example): Correct example code. - * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt. - -2013-11-13 Anthony Green - - * include/ffi_common.h: Respect HAVE_ALLOCA_H for GNU compiler - based build. (Thanks to tmr111116 on github) - -2013-11-09 Anthony Green - - * m4/libtool.m4: Refresh. - * configure, Makefile.in: Rebuilt. - * README: Add more notes about next release. - -2013-11-09 Shigeharu TAKENO - - * m4/ax_gcc_archflag.m4 (ax_gcc_arch): Don't recognize - UltraSPARC-IIi as ultrasparc3. - -2013-11-06 Mark Kettenis - - * src/x86/freebsd.S (ffi_call_SYSV): Align the stack pointer to - 16-bytes. - -2013-11-06 Konstantin Belousov - - * src/x86/freebsd.S (ffi_closure_raw_SYSV): Mark the assembler - source as not requiring executable stack. - -2013-11-02 Anthony Green - - * doc/libffi.texi (The Basics): Clarify return value buffer size - requirements. Also, NULL result buffer pointers are no longer - supported. - * doc/libffi.info: Rebuilt. - -2013-11-02 Mischa Jonker - - * Makefile.am (nodist_libffi_la_SOURCES): Fix build error. - * Makefile.in: Rebuilt. - -2013-11-02 David Schneider - - * src/arm/ffi.c: more robust argument handling for closures on arm hardfloat - * testsuite/libffi.call/many_mixed.c: New file. - * testsuite/libffi.call/cls_many_mixed_args.c: More tests. - -2013-11-02 Vitaly Budovski - - * src/x86/ffi.c (ffi_prep_cif_machdep): Don't align stack for win32. - -2013-10-23 Mark H Weaver - - * src/mips/ffi.c: Fix handling of uint32_t arguments on the - MIPS N32 ABI. - -2013-10-13 Sandra Loosemore - - * README: Add Nios II to table of supported platforms. - * Makefile.am (EXTRA_DIST): Add nios2 files. - (nodist_libffi_la_SOURCES): Likewise. - * Makefile.in: Regenerated. - * configure.ac (nios2*-linux*): New host. - (NIOS2): Add AM_CONDITIONAL. - * configure: Regenerated. - * src/nios2/ffi.c: New. - * src/nios2/ffitarget.h: New. - * src/nios2/sysv.S: New. - * src/prep_cif.c (initialize_aggregate): Handle extra structure - alignment via FFI_AGGREGATE_ALIGNMENT. - (ffi_prep_cif_core): Conditionalize structure return for NIOS2. - -2013-10-10 Sandra Loosemore - - * testsuite/libffi.call/cls_many_mixed_args.c (cls_ret_double_fn): - Fix uninitialized variable. - -2013-10-11 Marcus Shawcroft - - * testsuite/libffi.call/many.c (many): Replace * with +. - -2013-10-08 Ondřej Bílka - - * src/aarch64/ffi.c, src/aarch64/sysv.S, src/arm/ffi.c, - src/arm/gentramp.sh, src/bfin/sysv.S, src/closures.c, - src/dlmalloc.c, src/ia64/ffi.c, src/microblaze/ffi.c, - src/microblaze/sysv.S, src/powerpc/darwin_closure.S, - src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/sh/ffi.c, - src/tile/tile.S, testsuite/libffi.call/nested_struct11.c: Fix - spelling errors. - -2013-10-08 Anthony Green - - * aclocal.m4, compile, config.guess, config.sub, depcomp, - install-sh, mdate-sh, missing, texinfo.tex: Update from upstream. - * configure.ac: Update version to 3.0.14-rc0. - * Makefile.in, configure, Makefile.in, include/Makefile.in, - man/Makefile.in, testsuite/Makefile.in: Rebuilt. - * README: Mention M88K and VAX. - -2013-07-15 Miod Vallat - - * Makefile.am, - configure.ac, - src/m88k/ffi.c, - src/m88k/ffitarget.h, - src/m88k/obsd.S, - src/vax/elfbsd.S, - src/vax/ffi.c, - src/vax/ffitarget.h: Add m88k and vax support. - -2013-06-24 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Move var declaration - before statements. - (ffi_prep_args64): Support little-endian. - (ffi_closure_helper_SYSV, ffi_closure_helper_LINUX64): Likewise. - * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise. - * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Likewise. - -2013-06-12 Mischa Jonker - - * configure.ac: Add support for ARC. - * Makefile.am: Likewise. - * README: Add ARC details. - * src/arc/arcompact.S: New. - * src/arc/ffi.c: Likewise. - * src/arc/ffitarget.h: Likewise. - -2013-03-28 David Schneider - - * src/arm/ffi.c: Fix support for ARM hard-float calling convention. - * src/arm/sysv.S: call different methods for SYSV and VFP ABIs. - * testsuite/libffi.call/cls_many_mixed_args.c: testcase for a closure with - mixed arguments, many doubles. - * testsuite/libffi.call/many_double.c: testcase for calling a function using - more than 8 doubles. - * testcase/libffi.call/many.c: use absolute value to check result against an - epsilon - -2013-03-17 Anthony Green - - * README: Update for 3.0.13. - * configure.ac: Ditto. - * configure: Rebuilt. - * doc/*: Update version. - -2013-03-17 Dave Korn - - * src/closures.c (is_emutramp_enabled - [!FFI_MMAP_EXEC_EMUTRAMP_PAX]): Move default definition outside - enclosing #if scope. - -2013-03-17 Anthony Green - - * configure.ac: Only modify toolexecdir in certain cases. - * configure: Rebuilt. - -2013-03-16 Gilles Talis - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Don't use - fparg_count,etc on __NO_FPRS__ targets. - -2013-03-16 Alan Hourihane - - * src/m68k/sysv.S (epilogue): Don't use extb instruction on - m680000 machines. - -2013-03-16 Alex Gaynor - - * src/x86/ffi.c (ffi_prep_cif_machdep): Always align stack. - -2013-03-13 Markos Chandras - - * configure.ac: Add support for Imagination Technologies Meta. - * Makefile.am: Likewise. - * README: Add Imagination Technologies Meta details. - * src/metag/ffi.c: New. - * src/metag/ffitarget.h: Likewise. - * src/metag/sysv.S: Likewise. - -2013-02-24 Andreas Schwab - - * doc/libffi.texi (Structures): Fix missing category argument of - @deftp. - -2013-02-11 Anthony Green - - * configure.ac: Update release number to 3.0.12. - * configure: Rebuilt. - * README: Update release info. - -2013-02-10 Anthony Green - - * README: Add Moxie. - * src/moxie/ffi.c: Created. - * src/moxie/eabi.S: Created. - * src/moxie/ffitarget.h: Created. - * Makefile.am (nodist_libffi_la_SOURCES): Add Moxie. - * Makefile.in: Rebuilt. - * configure.ac: Add Moxie. - * configure: Rebuilt. - * testsuite/libffi.call/huge_struct.c: Disable format string - warnings for moxie*-*-elf tests. - -2013-02-10 Anthony Green - - * Makefile.am (LTLDFLAGS): Fix reference. - * Makefile.in: Rebuilt. - -2013-02-10 Anthony Green - - * README: Update supported platforms. Update test results link. - -2013-02-09 Anthony Green - - * testsuite/libffi.call/negint.c: Remove forced -O2. - * testsuite/libffi.call/many2.c (foo): Remove GCCism. - * testsuite/libffi.call/ffitest.h: Add default PRIuPTR definition. - - * src/sparc/v8.S (ffi_closure_v8): Import ancient ulonglong - closure return type fix developed by Martin v. Löwis for cpython - fork. - -2013-02-08 Andreas Tobler - - * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix small struct - support. - * src/powerpc/sysv.S: Ditto. - -2013-02-08 Anthony Green - - * testsuite/libffi.call/cls_longdouble.c: Remove xfail for - arm*-*-*. - -2013-02-08 Anthony Green - - * src/sparc/ffi.c (ffi_prep_closure_loc): Fix cache flushing for GCC. - -2013-02-08 Matthias Klose - - * man/ffi_prep_cif.3: Clean up for debian linter. - -2013-02-08 Peter Bergner - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Account for FP args pushed - on the stack. - -2013-02-08 Anthony Green - - * Makefile.am (EXTRA_DIST): Add missing files. - * testsuite/Makefile.am (EXTRA_DIST): Ditto. - * Makefile.in: Rebuilt. - -2013-02-08 Anthony Green - - * configure.ac: Move sparc asm config checks to within functions - for compatibility with sun tools. - * configure: Rebuilt. - * src/sparc/ffi.c (ffi_prep_closure_loc): Flush cache on v9 - systems. - * src/sparc/v8.S (ffi_flush_icache): Implement a sparc v9 cache - flusher. - -2013-02-08 Nathan Rossi - - * src/microblaze/ffi.c (ffi_closure_call_SYSV): Fix handling of - small big-endian structures. - (ffi_prep_args): Ditto. - -2013-02-07 Anthony Green - - * src/sparc/v8.S (ffi_call_v8): Fix typo from last patch - (effectively hiding ffi_call_v8). - -2013-02-07 Anthony Green - - * configure.ac: Update bug reporting address. - * configure.in: Rebuild. - - * src/sparc/v8.S (ffi_flush_icache): Out-of-line cache flusher for - Sun compiler. - * src/sparc/ffi.c (ffi_call): Remove warning. - Call ffi_flush_icache for non-GCC builds. - (ffi_prep_closure_loc): Use ffi_flush_icache. - - * Makefile.am (EXTRA_DIST): Add libtool-ldflags. - * Makefile.in: Rebuilt. - * libtool-ldflags: New file. - -2013-02-07 Daniel Schepler - - * configure.ac: Correctly identify x32 systems as 64-bit. - * m4/libtool.m4: Remove libtool expr error. - * aclocal.m4, configure: Rebuilt. - -2013-02-07 Anthony Green - - * configure.ac: Fix GCC usage test. - * configure: Rebuilt. - * README: Mention LLVM/GCC x86_64 issue. - * testsuite/Makefile.in: Rebuilt. - -2013-02-07 Anthony Green - - * testsuite/libffi.call/cls_double_va.c (main): Replace // style - comments with /* */ for xlc compiler. - * testsuite/libffi.call/stret_large.c (main): Ditto. - * testsuite/libffi.call/stret_large2.c (main): Ditto. - * testsuite/libffi.call/nested_struct1.c (main): Ditto. - * testsuite/libffi.call/huge_struct.c (main): Ditto. - * testsuite/libffi.call/float_va.c (main): Ditto. - * testsuite/libffi.call/cls_struct_va1.c (main): Ditto. - * testsuite/libffi.call/cls_pointer_stack.c (main): Ditto. - * testsuite/libffi.call/cls_pointer.c (main): Ditto. - * testsuite/libffi.call/cls_longdouble_va.c (main): Ditto. - -2013-02-06 Anthony Green - - * man/ffi_prep_cif.3: Clean up for debian lintian checker. - -2013-02-06 Anthony Green - - * Makefile.am (pkgconfigdir): Add missing pkgconfig install bits. - * Makefile.in: Rebuild. - -2013-02-02 Mark H Weaver - - * src/x86/ffi64.c (ffi_call): Sign-extend integer arguments passed - via general purpose registers. - -2013-01-21 Nathan Rossi - - * README: Add MicroBlaze details. - * Makefile.am: Add MicroBlaze support. - * configure.ac: Likewise. - * src/microblaze/ffi.c: New. - * src/microblaze/ffitarget.h: Likewise. - * src/microblaze/sysv.S: Likewise. - -2013-01-21 Nathan Rossi - * testsuite/libffi.call/return_uc.c: Fixed issue. - -2013-01-21 Chris Zankel - - * README: Add Xtensa support. - * Makefile.am: Likewise. - * configure.ac: Likewise. - * Makefile.in Regenerate. - * configure: Likewise. - * src/prep_cif.c: Handle Xtensa. - * src/xtensa: New directory. - * src/xtensa/ffi.c: New file. - * src/xtensa/ffitarget.h: Ditto. - * src/xtensa/sysv.S: Ditto. - -2013-01-11 Anthony Green - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Replace // style - comments with /* */ for xlc compiler. - * src/powerpc/aix.S (ffi_call_AIX): Ditto. - * testsuite/libffi.call/ffitest.h (allocate_mmap): Delete - deprecated inline function. - * testsuite/libffi.special/ffitestcxx.h: Ditto. - * README: Add update for AIX support. - -2013-01-11 Anthony Green - - * configure.ac: Robustify pc relative reloc check. - * m4/ax_cc_maxopt.m4: Don't -malign-double. This is an ABI - changing option for 32-bit x86. - * aclocal.m4, configure: Rebuilt. - * README: Update supported target list. - -2013-01-10 Anthony Green - - * README (tested): Add Compiler column to table. - -2013-01-10 Anthony Green - - * src/x86/ffi64.c (struct register_args): Make sse array and array - of unions for sunpro compiler compatibility. - -2013-01-10 Anthony Green - - * configure.ac: Test target platform size_t size. Handle both 32 - and 64-bit builds for x86_64-* and i?86-* targets (allowing for - CFLAG option to change default settings). - * configure, aclocal.m4: Rebuilt. - -2013-01-10 Anthony Green - - * testsuite/libffi.special/special.exp: Only run exception - handling tests when using GNU compiler. - - * m4/ax_compiler_vendor.m4: New file. - * configure.ac: Test for compiler vendor and don't use - AX_CFLAGS_WARN_ALL with the sun compiler. - * aclocal.m4, configure: Rebuilt. - -2013-01-10 Anthony Green - - * include/ffi_common.h: Don't use GCCisms to define types when - building with the SUNPRO compiler. - -2013-01-10 Anthony Green - - * configure.ac: Put local.exp in the right place. - * configure: Rebuilt. - - * src/x86/ffi.c: Update comment about regparm function attributes. - * src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires - that all function arguments be passed on the stack (no regparm - support). - -2013-01-08 Anthony Green - - * configure.ac: Generate local.exp. This sets CC_FOR_TARGET - when we are using the vendor compiler. - * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): Point to - ../local.exp. - * configure, testsuite/Makefile.in: Rebuilt. - - * testsuite/libffi.call/call.exp: Run tests with different - options, depending on whether or not we are using gcc or the - vendor compiler. - * testsuite/lib/libffi.exp (libffi-init): Set using_gcc based on - whether or not we are building/testing with gcc. - -2013-01-08 Anthony Green - - * configure.ac: Switch x86 solaris target to X86 by default. - * configure: Rebuilt. - -2013-01-08 Anthony Green - - * configure.ac: Fix test for read-only eh_frame. - * configure: Rebuilt. - -2013-01-08 Anthony Green - - * src/x86/sysv.S, src/x86/unix64.S: Only emit DWARF unwind info - when building with the GNU toolchain. - * testsuite/libffi.call/ffitest.h (CHECK): Fix for Solaris vendor - compiler. - -2013-01-07 Thorsten Glaser - - * testsuite/libffi.call/cls_uchar_va.c, - testsuite/libffi.call/cls_ushort_va.c, - testsuite/libffi.call/va_1.c: Testsuite fixes. - -2013-01-07 Thorsten Glaser - - * src/m68k/ffi.c (CIF_FLAGS_SINT8, CIF_FLAGS_SINT16): Define. - (ffi_prep_cif_machdep): Fix 8-bit and 16-bit signed calls. - * src/m68k/sysv.S (ffi_call_SYSV, ffi_closure_SYSV): Ditto. - -2013-01-04 Anthony Green - - * Makefile.am (AM_CFLAGS): Don't automatically add -fexceptions - and -Wall. This is set in the configure script after testing for - GCC. - * Makefile.in: Rebuilt. - -2013-01-02 rofl0r - - * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix build error on ppc - when long double == double. - -2013-01-02 Reini Urban - - * Makefile.am (libffi_la_LDFLAGS): Add -no-undefined to LDFLAGS - (required for shared libs on cygwin/mingw). - * Makefile.in: Rebuilt. - -2012-10-31 Alan Modra - - * src/powerpc/linux64_closure.S: Add new ABI support. - * src/powerpc/linux64.S: Likewise. - -2012-10-30 Magnus Granberg - Pavel Labushev - - * configure.ac: New options pax_emutramp - * configure, fficonfig.h.in: Regenerated - * src/closures.c: New function emutramp_enabled_check() and - checks. - -2012-10-30 Frederick Cheung - - * configure.ac: Enable FFI_MAP_EXEC_WRIT for Darwin 12 (mountain - lion) and future version. - * configure: Rebuild. - -2012-10-30 James Greenhalgh - Marcus Shawcroft - - * README: Add details of aarch64 port. - * src/aarch64/ffi.c: New. - * src/aarch64/ffitarget.h: Likewise. - * src/aarch64/sysv.S: Likewise. - * Makefile.am: Support aarch64. - * configure.ac: Support aarch64. - * Makefile.in, configure: Rebuilt. - -2012-10-30 James Greenhalgh - Marcus Shawcroft - - * testsuite/lib/libffi.exp: Add support for aarch64. - * testsuite/libffi.call/cls_struct_va1.c: New. - * testsuite/libffi.call/cls_uchar_va.c: Likewise. - * testsuite/libffi.call/cls_uint_va.c: Likewise. - * testsuite/libffi.call/cls_ulong_va.c: Likewise. - * testsuite/libffi.call/cls_ushort_va.c: Likewise. - * testsuite/libffi.call/nested_struct11.c: Likewise. - * testsuite/libffi.call/uninitialized.c: Likewise. - * testsuite/libffi.call/va_1.c: Likewise. - * testsuite/libffi.call/va_struct1.c: Likewise. - * testsuite/libffi.call/va_struct2.c: Likewise. - * testsuite/libffi.call/va_struct3.c: Likewise. - -2012-10-12 Walter Lee - - * Makefile.am: Add TILE-Gx/TILEPro support. - * configure.ac: Likewise. - * Makefile.in: Regenerate. - * configure: Likewise. - * src/prep_cif.c (ffi_prep_cif_core): Handle TILE-Gx/TILEPro. - * src/tile: New directory. - * src/tile/ffi.c: New file. - * src/tile/ffitarget.h: Ditto. - * src/tile/tile.S: Ditto. - -2012-10-12 Matthias Klose - - * generate-osx-source-and-headers.py: Normalize whitespace. - -2012-09-14 David Edelsohn - - * configure: Regenerated. - -2012-08-26 Andrew Pinski - - PR libffi/53014 - * src/mips/ffi.c (ffi_prep_closure_loc): Allow n32 with soft-float and n64 with - soft-float. - -2012-08-08 Uros Bizjak - - * src/s390/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - -2012-07-18 H.J. Lu - - PR libffi/53982 - PR libffi/53973 - * src/x86/ffitarget.h: Check __ILP32__ instead of __LP64__ for x32. - (FFI_SIZEOF_JAVA_RAW): Defined to 4 for x32. - -2012-05-16 H.J. Lu - - * configure: Regenerated. - -2012-05-05 Nicolas Lelong - - * libffi.xcodeproj/project.pbxproj: Fixes. - * README: Update for iOS builds. - -2012-04-23 Alexandre Keunecke I. de Mendonca - - * configure.ac: Add Blackfin/sysv support - * Makefile.am: Add Blackfin/sysv support - * src/bfin/ffi.c: Add Blackfin/sysv support - * src/bfin/ffitarget.h: Add Blackfin/sysv support - -2012-04-11 Anthony Green - - * Makefile.am (EXTRA_DIST): Add new script. - * Makefile.in: Rebuilt. - -2012-04-11 Zachary Waldowski - - * generate-ios-source-and-headers.py, - libffi.xcodeproj/project.pbxproj: Support a Mac static library via - Xcode. Set iOS compatibility to 4.0. Move iOS trampoline - generation into an Xcode "run script" phase. Include both as - Xcode build scripts. Don't always regenerate config files. - -2012-04-10 Anthony Green - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Add missing semicolon. - -2012-04-06 Anthony Green - - * Makefile.am (EXTRA_DIST): Add new iOS/xcode files. - * Makefile.in: Rebuilt. - -2012-04-06 Mike Lewis - - * generate-ios-source-and-headers.py: New file. - * libffi.xcodeproj/project.pbxproj: New file. - * README: Update instructions on building iOS binary. - * build-ios.sh: Delete. - -2012-04-06 Anthony Green - - * src/x86/ffi64.c (UINT128): Define differently for Intel and GNU - compilers, then use it. - -2012-04-06 H.J. Lu - - * m4/libtool.m4 (_LT_ENABLE_LOCK): Support x32. - -2012-04-06 Anthony Green - - * testsuite/Makefile.am (EXTRA_DIST): Add missing test cases. - * testsuite/Makefile.in: Rebuilt. - -2012-04-05 Zachary Waldowski - - * include/ffi.h.in: Add missing trampoline table fields. - * src/arm/sysv.S: Fix ENTRY definition, and wrap symbol references - in CNAME. - * src/x86/ffi.c: Wrap Windows specific code in ifdefs. - -2012-04-02 Peter Bergner - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Declare double_tmp. - Silence casting pointer to integer of different size warning. - Delete goto to previously deleted label. - (ffi_call): Silence possibly undefined warning. - (ffi_closure_helper_SYSV): Declare variable type. - -2012-04-02 Peter Rosin - - * src/x86/win32.S (ffi_call_win32): Sign/zero extend the return - value in the Intel version as is already done for the AT&T version. - (ffi_closure_SYSV): Likewise. - (ffi_closure_raw_SYSV): Likewise. - (ffi_closure_STDCALL): Likewise. - -2012-03-29 Peter Rosin - - * src/x86/win32.S (ffi_closure_raw_THISCALL): Unify the frame - generation, fix the ENDP label and remove the surplus third arg - from the 'lea' insn. - -2012-03-29 Peter Rosin - - * src/x86/win32.S (ffi_closure_raw_SYSV): Make the 'stubraw' label - visible outside the PROC, so that ffi_closure_raw_THISCALL can see - it. Also instruct the assembler to add a frame to the function. - -2012-03-23 Peter Rosin - - * Makefile.am (AM_CPPFLAGS): Add -DFFI_BUILDING. - * Makefile.in: Rebuilt. - * include/ffi.h.in [MSVC]: Add __declspec(dllimport) decorations - to all data exports, when compiling libffi clients using MSVC. - -2012-03-29 Peter Rosin - - * src/x86/ffitarget.h (ffi_abi): Add new ABI FFI_MS_CDECL and - make it the default for MSVC. - (FFI_TYPE_MS_STRUCT): New structure return convention. - * src/x86/ffi.c (ffi_prep_cif_machdep): Tweak the structure - return convention for FFI_MS_CDECL to be FFI_TYPE_MS_STRUCT - instead of an ordinary FFI_TYPE_STRUCT. - (ffi_prep_args): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT. - (ffi_call): Likewise. - (ffi_prep_incoming_args_SYSV): Likewise. - (ffi_raw_call): Likewise. - (ffi_prep_closure_loc): Treat FFI_MS_CDECL as FFI_SYSV. - * src/x86/win32.S (ffi_closure_SYSV): For FFI_TYPE_MS_STRUCT, - return a pointer to the result structure in eax and don't pop - that pointer from the stack, the caller takes care of it. - (ffi_call_win32): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT. - (ffi_closure_raw_SYSV): Likewise. - -2012-03-22 Peter Rosin - - * testsuite/libffi.call/closure_stdcall.c [MSVC]: Add inline - assembly version with Intel syntax. - * testsuite/libffi.call/closure_thiscall.c [MSVC]: Likewise. - -2012-03-23 Peter Rosin - - * testsuite/libffi.call/ffitest.h: Provide abstration of - __attribute__((fastcall)) in the form of a __FASTCALL__ - define. Define it to __fastcall for MSVC. - * testsuite/libffi.call/fastthis1_win32.c: Use the above. - * testsuite/libffi.call/fastthis2_win32.c: Likewise. - * testsuite/libffi.call/fastthis3_win32.c: Likewise. - * testsuite/libffi.call/strlen2_win32.c: Likewise. - * testsuite/libffi.call/struct1_win32.c: Likewise. - * testsuite/libffi.call/struct2_win32.c: Likewise. - -2012-03-22 Peter Rosin - - * src/x86/win32.S [MSVC] (ffi_closure_THISCALL): Remove the manual - frame on function entry, MASM adds one automatically. - -2012-03-22 Peter Rosin - - * testsuite/libffi.call/ffitest.h [MSVC]: Add kludge for missing - bits in the MSVC headers. - -2012-03-22 Peter Rosin - - * testsuite/libffi.call/cls_12byte.c: Adjust to the C89 style - with no declarations after statements. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_18byte.c: Likewise. - * testsuite/libffi.call/cls_19byte.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_20byte1.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_5_1_byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - * testsuite/libffi.call/cls_64byte.c: Likewise. - * testsuite/libffi.call/cls_6_1_byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7_1_byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_9byte1.c: Likewise. - * testsuite/libffi.call/cls_9byte2.c: Likewise. - * testsuite/libffi.call/cls_align_double.c: Likewise. - * testsuite/libffi.call/cls_align_float.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble_split.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise. - * testsuite/libffi.call/cls_align_pointer.c: Likewise. - * testsuite/libffi.call/cls_align_sint16.c: Likewise. - * testsuite/libffi.call/cls_align_sint32.c: Likewise. - * testsuite/libffi.call/cls_align_sint64.c: Likewise. - * testsuite/libffi.call/cls_align_uint16.c: Likewise. - * testsuite/libffi.call/cls_align_uint32.c: Likewise. - * testsuite/libffi.call/cls_align_uint64.c: Likewise. - * testsuite/libffi.call/cls_dbls_struct.c: Likewise. - * testsuite/libffi.call/cls_pointer_stack.c: Likewise. - * testsuite/libffi.call/err_bad_typedef.c: Likewise. - * testsuite/libffi.call/huge_struct.c: Likewise. - * testsuite/libffi.call/nested_struct.c: Likewise. - * testsuite/libffi.call/nested_struct1.c: Likewise. - * testsuite/libffi.call/nested_struct10.c: Likewise. - * testsuite/libffi.call/nested_struct2.c: Likewise. - * testsuite/libffi.call/nested_struct3.c: Likewise. - * testsuite/libffi.call/nested_struct4.c: Likewise. - * testsuite/libffi.call/nested_struct5.c: Likewise. - * testsuite/libffi.call/nested_struct6.c: Likewise. - * testsuite/libffi.call/nested_struct7.c: Likewise. - * testsuite/libffi.call/nested_struct8.c: Likewise. - * testsuite/libffi.call/nested_struct9.c: Likewise. - * testsuite/libffi.call/stret_large.c: Likewise. - * testsuite/libffi.call/stret_large2.c: Likewise. - * testsuite/libffi.call/stret_medium.c: Likewise. - * testsuite/libffi.call/stret_medium2.c: Likewise. - * testsuite/libffi.call/struct1.c: Likewise. - * testsuite/libffi.call/struct1_win32.c: Likewise. - * testsuite/libffi.call/struct2.c: Likewise. - * testsuite/libffi.call/struct2_win32.c: Likewise. - * testsuite/libffi.call/struct3.c: Likewise. - * testsuite/libffi.call/struct4.c: Likewise. - * testsuite/libffi.call/struct5.c: Likewise. - * testsuite/libffi.call/struct6.c: Likewise. - * testsuite/libffi.call/struct7.c: Likewise. - * testsuite/libffi.call/struct8.c: Likewise. - * testsuite/libffi.call/struct9.c: Likewise. - * testsuite/libffi.call/testclosure.c: Likewise. - -2012-03-21 Peter Rosin - - * testsuite/libffi.call/float_va.c (float_va_fn): Use %f when - printing doubles (%lf is for long doubles). - (main): Likewise. - -2012-03-21 Peter Rosin - - * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*] - (set_ld_library_path_env_vars): Add the library search dir to PATH - (and save PATH for later). - (restore_ld_library_path_env_vars): Restore PATH. - -2012-03-21 Peter Rosin - - * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*] - (set_ld_library_path_env_vars): Add the library search dir to PATH - (and save PATH for later). - (restore_ld_library_path_env_vars): Restore PATH. - -2012-03-20 Peter Rosin - - * testsuite/libffi.call/strlen2_win32.c (main): Remove bug. - * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label - visible outside the PROC, so that ffi_closure_THISCALL can see it. - -2012-03-20 Peter Rosin - - * testsuite/libffi.call/strlen2_win32.c (main): Remove bug. - * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label - visible outside the PROC, so that ffi_closure_THISCALL can see it. - -2012-03-19 Alan Hourihane - - * src/m68k/ffi.c: Add MINT support. - * src/m68k/sysv.S: Ditto. - -2012-03-06 Chung-Lin Tang - - * src/arm/ffi.c (ffi_call): Add __ARM_EABI__ guard around call to - ffi_call_VFP(). - (ffi_prep_closure_loc): Add __ARM_EABI__ guard around use of - ffi_closure_VFP. - * src/arm/sysv.S: Add __ARM_EABI__ guard around VFP code. - -2012-03-19 chennam - - * src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure - support. - -2012-03-13 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - * src/sh64/ffi.c (ffi_prep_closure_loc): Ditto. - -2012-03-09 David Edelsohn - - * src/powerpc/aix_closure.S (ffi_closure_ASM): Adjust for Darwin64 - change to return value of ffi_closure_helper_DARWIN and load type - from return type. - -2012-03-03 H.J. Lu - - * src/x86/ffi64.c (ffi_call): Cast the return value to unsigned - long. - (ffi_prep_closure_loc): Cast to 64bit address in trampoline. - (ffi_closure_unix64_inner): Cast return pointer to unsigned long - first. - - * src/x86/ffitarget.h (FFI_SIZEOF_ARG): Defined to 8 for x32. - (ffi_arg): Set to unsigned long long for x32. - (ffi_sarg): Set to long long for x32. - -2012-03-03 H.J. Lu - - * src/prep_cif.c (ffi_prep_cif_core): Properly check bad ABI. - -2012-03-03 Andoni Morales Alastruey - - * configure.ac: Add -no-undefined for both 32- and 64-bit x86 - windows-like hosts. - * configure: Rebuilt. - -2012-02-27 Mikael Pettersson - - PR libffi/52223 - * Makefile.am (FLAGS_TO_PASS): Define. - * Makefile.in: Regenerate. - -2012-02-23 Anthony Green - - * src/*/ffitarget.h: Ensure that users never include ffitarget.h - directly. - -2012-02-23 Kai Tietz - - PR libffi/52221 - * src/x86/ffi.c (ffi_closure_raw_THISCALL): New - prototype. - (ffi_prep_raw_closure_loc): Use ffi_closure_raw_THISCALL for - thiscall-convention. - (ffi_raw_call): Use ffi_prep_args_raw. - * src/x86/win32.S (ffi_closure_raw_THISCALL): Add - implementation for stub. - -2012-02-10 Kai Tietz - - * configure.ac (AM_LTLDFLAGS): Add -no-undefine for x64 - windows target. - * configure: Regenerated. - -2012-02-08 Kai Tietz - - * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32 - also FFI_THISCALL. - * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype. - (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code. - (ffi_prep_closure_loc): Add FFI_THISCALL support. - * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size. - * src/x86/win32.S (ffi_closure_THISCALL): New closure code - for thiscall-calling convention. - * testsuite/libffi.call/closure_thiscall.c: New test. - -2012-01-28 Kai Tietz - - * src/libffi/src/x86/ffi.c (ffi_call_win32): Add new - argument to prototype for specify calling-convention. - (ffi_call): Add support for stdcall/thiscall convention. - (ffi_prep_args): Likewise. - (ffi_raw_call): Likewise. - * src/x86/ffitarget.h (ffi_abi): Add FFI_THISCALL and - FFI_FASTCALL. - * src/x86/win32.S (_ffi_call_win32): Add support for - fastcall/thiscall calling-convention calls. - * testsuite/libffi.call/fastthis1_win32.c: New test. - * testsuite/libffi.call/fastthis2_win32.c: New test. - * testsuite/libffi.call/fastthis3_win32.c: New test. - * testsuite/libffi.call/strlen2_win32.c: New test. - * testsuite/libffi.call/many2_win32.c: New test. - * testsuite/libffi.call/struct1_win32.c: New test. - * testsuite/libffi.call/struct2_win32.c: New test. - -2012-01-23 Uros Bizjak - - * src/alpha/ffi.c (ffi_prep_closure_loc): Check for bad ABI. - -2012-01-23 Anthony Green - Chris Young - - * configure.ac: Add Amiga support. - * configure: Rebuilt. - -2012-01-23 Dmitry Nadezhin - - * include/ffi_common.h (LIKELY, UNLIKELY): Fix definitions. - -2012-01-23 Andreas Schwab - - * src/m68k/sysv.S (ffi_call_SYSV): Properly test for plain - mc68000. Test for __HAVE_68881__ in addition to __MC68881__. - -2012-01-19 Jakub Jelinek - - PR rtl-optimization/48496 - * src/ia64/ffi.c (ffi_call): Fix up aliasing violations. - -2012-01-09 Rainer Orth - - * configure.ac (i?86-*-*): Set TARGET to X86_64. - * configure: Regenerate. - -2011-12-07 Andrew Pinski - - PR libffi/50051 - * src/mips/n32.S: Add ".set mips4". - -2011-11-21 Andreas Tobler - - * configure: Regenerate. - -2011-11-12 David Gilbert - - * doc/libffi.texi, include/ffi.h.in, include/ffi_common.h, - man/Makefile.am, man/ffi.3, man/ffi_prep_cif.3, - man/ffi_prep_cif_var.3, src/arm/ffi.c, src/arm/ffitarget.h, - src/cris/ffi.c, src/prep_cif.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/float_va.c: Many changes to support variadic - function calls. - -2011-11-12 Kyle Moffett - - * src/powerpc/ffi.c, src/powerpc/ffitarget.h, - src/powerpc/ppc_closure.S, src/powerpc/sysv.S: Many changes for - softfloat powerpc variants. - -2011-11-12 Petr Salinger - - * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Fix kfreebsd support. - * configure: Rebuilt. - -2011-11-12 Timothy Wall - - * src/arm/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV): Max - alignment of 4 for wince on ARM. - -2011-11-12 Kyle Moffett - Anthony Green - - * src/ppc/sysv.S, src/ppc/ffi.c: Remove use of ppc string - instructions (not available on some cores, like the PPC440). - -2011-11-12 Kimura Wataru - - * m4/ax_enable_builddir: Change from string comparison to numeric - comparison for wc output. - * configure.ac: Enable FFI_MMAP_EXEC_WRIT for darwin11 aka Mac OS - X 10.7. - * configure: Rebuilt. - -2011-11-12 Anthony Green - - * Makefile.am (AM_CCASFLAGS): Add -g option to build assembly - files with debug info. - * Makefile.in: Rebuilt. - -2011-11-12 Jasper Lievisse Adriaanse - - * README: Update list of supported OpenBSD systems. - -2011-11-12 Anthony Green - - * libtool-version: Update. - * Makefile.am (nodist_libffi_la_SOURCES): Add src/debug.c if - FFI_DEBUG. - (libffi_la_SOURCES): Remove src/debug.c - (EXTRA_DIST): Add src/debug.c - * Makefile.in: Rebuilt. - * README: Update for 3.0.11. - -2011-11-10 Richard Henderson - - * configure.ac (GCC_AS_CFI_PSEUDO_OP): Use it instead of inline check. - * configure, aclocal.m4: Rebuild. - -2011-09-04 Iain Sandoe - - PR libffi/49594 - * src/powerpc/darwin_closure.S (stubs): Make the stub binding - helper reference track the architecture pointer size. - -2011-08-25 Andrew Haley - - * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Remove hard-coded assembly - instructions. - * src/arm/sysv.S (ffi_arm_trampoline): Put them here instead. - -2011-07-11 Andrew Haley - - * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Clear icache. - -2011-06-29 Rainer Orth - - * testsuite/libffi.call/cls_double_va.c: Move PR number to comment. - * testsuite/libffi.call/cls_longdouble_va.c: Likewise. - -2011-06-29 Rainer Orth - - PR libffi/46660 - * testsuite/libffi.call/cls_double_va.c: xfail dg-output on - mips-sgi-irix6*. - * testsuite/libffi.call/cls_longdouble_va.c: Likewise. - -2011-06-14 Rainer Orth - - * testsuite/libffi.call/huge_struct.c (test_large_fn): Use PRIu8, - PRId8 instead of %hhu, %hhd. - * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRId8, - PRIu8): Define. - [__sgi__] (PRId8, PRIu8): Define. - -2011-04-29 Rainer Orth - - * src/alpha/osf.S (UA_SI, FDE_ENCODING, FDE_ENCODE, FDE_ARANGE): - Define. - Use them to handle ELF vs. ECOFF differences. - [__osf__] (_GLOBAL__F_ffi_call_osf): Define. - -2011-03-30 Timothy Wall - - * src/powerpc/darwin.S: Fix unknown FDE encoding. - * src/powerpc/darwin_closure.S: ditto. - -2011-02-25 Anthony Green - - * src/powerpc/ffi.c (ffi_prep_closure_loc): Allow for more - 32-bit ABIs. - -2011-02-15 Anthony Green - - * m4/ax_cc_maxopt.m4: Don't -malign-double or use -ffast-math. - * configure: Rebuilt. - -2011-02-13 Ralf Wildenhues - - * configure: Regenerate. - -2011-02-13 Anthony Green - - * include/ffi_common.h (UNLIKELY, LIKELY): Define. - * src/x86/ffi64.c (UNLIKELY, LIKELY): Remove definition. - * src/prep_cif.c (UNLIKELY, LIKELY): Remove definition. - - * src/prep_cif.c (initialize_aggregate): Convert assertion into - FFI_BAD_TYPEDEF return. Initialize arg size and alignment to 0. - - * src/pa/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - * src/arm/ffi.c (ffi_prep_closure_loc): Ditto. - * src/powerpc/ffi.c (ffi_prep_closure_loc): Ditto. - * src/mips/ffi.c (ffi_prep_closure_loc): Ditto. - * src/ia64/ffi.c (ffi_prep_closure_loc): Ditto. - * src/avr32/ffi.c (ffi_prep_closure_loc): Ditto. - -2011-02-11 Anthony Green - - * src/sparc/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - -2012-02-11 Eric Botcazou - - * src/sparc/v9.S (STACKFRAME): Bump to 176. - -2011-02-09 Stuart Shelton - - http://bugs.gentoo.org/show_bug.cgi?id=286911 - * src/mips/ffitarget.h: Clean up error messages. - * src/java_raw_api.c (ffi_java_translate_args): Cast raw arg to - ffi_raw*. - * include/ffi.h.in: Add pragma for SGI compiler. - -2011-02-09 Anthony Green - - * configure.ac: Add powerpc64-*-darwin* support. - -2011-02-09 Anthony Green - - * README: Mention Interix. - -2011-02-09 Jonathan Callen - - * configure.ac: Add Interix to win32/cygwin/mingw case. - * configure: Ditto. - * src/closures.c: Treat Interix like Cygwin, instead of as a - generic win32. - -2011-02-09 Anthony Green - - * testsuite/libffi.call/err_bad_typedef.c: Remove xfail. - * testsuite/libffi.call/err_bad_abi.c: Remove xfail. - * src/x86/ffi64.c (UNLIKELY, LIKELY): Define. - (ffi_prep_closure_loc): Check for bad ABI. - * src/prep_cif.c (UNLIKELY, LIKELY): Define. - (initialize_aggregate): Check for bad types. - -2011-02-09 Landon Fuller - - * Makefile.am (EXTRA_DIST): Add build-ios.sh, src/arm/gentramp.sh, - src/arm/trampoline.S. - (nodist_libffi_la_SOURCES): Add src/arc/trampoline.S. - * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Define. - * src/arm/ffi.c (ffi_trampoline_table) - (ffi_closure_trampoline_table_page, ffi_trampoline_table_entry) - (FFI_TRAMPOLINE_CODELOC_CONFIG, FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) - (FFI_TRAMPOLINE_COUNT, ffi_trampoline_lock, ffi_trampoline_tables) - (ffi_trampoline_table_alloc, ffi_closure_alloc, ffi_closure_free): - Define for FFI_EXEC_TRAMPOLINE_TABLE case (iOS). - (ffi_prep_closure_loc): Handl FFI_EXEC_TRAMPOLINE_TABLE case - separately. - * src/arm/sysv.S: Handle Apple iOS host. - * src/closures.c: Handle FFI_EXEC_TRAMPOLINE_TABLE case. - * build-ios.sh: New file. - * fficonfig.h.in, configure, Makefile.in: Rebuilt. - * README: Mention ARM iOS. - -2011-02-08 Oren Held - - * src/dlmalloc.c (_STRUCT_MALLINFO): Define in order to avoid - redefinition of mallinfo on HP-UX. - -2011-02-08 Ginn Chen - - * src/sparc/ffi.c (ffi_call): Make compatible with Solaris Studio - aggregate return ABI. Flush cache. - (ffi_prep_closure_loc): Flush cache. - -2011-02-11 Anthony Green - - From Tom Honermann : - * src/powerpc/aix.S (ffi_call_AIX): Support for xlc toolchain on - AIX. Declare .ffi_prep_args. Insert nops after branch - instructions so that the AIX linker can insert TOC reload - instructions. - * src/powerpc/aix_closure.S: Declare .ffi_closure_helper_DARWIN. - -2011-02-08 Ed - - * src/powerpc/asm.h: Fix grammar nit in comment. - -2011-02-08 Uli Link - - * include/ffi.h.in (FFI_64_BIT_MAX): Define and use. - -2011-02-09 Rainer Orth - - PR libffi/46661 - * testsuite/libffi.call/cls_pointer.c (main): Cast void * to - uintptr_t first. - * testsuite/libffi.call/cls_pointer_stack.c (main): Likewise. - -2011-02-08 Rafael Avila de Espindola - - * configure.ac: Fix x86 test for pc related relocs. - * configure: Rebuilt. - -2011-02-07 Joel Sherrill - - * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing. - Handle case when CPU variant does not have long double support. - * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire, - and cores with soft floating point. - -2011-02-07 Joel Sherrill - - * configure.ac: Add mips*-*-rtems* support. - * configure: Regenerate. - * src/mips/ffitarget.h: Ensure needed constants are available - for targets which do not have sgidefs.h. - -2011-01-26 Dave Korn - - PR target/40125 - * configure.ac (AM_LTLDFLAGS): Add -bindir option for windows DLLs. - * configure: Regenerate. - -2010-12-18 Iain Sandoe - - PR libffi/29152 - PR libffi/42378 - * src/powerpc/darwin_closure.S: Provide Darwin64 implementation, - update comments. - * src/powerpc/ffitarget.h (POWERPC_DARWIN64): New, - (FFI_TRAMPOLINE_SIZE): Update for Darwin64. - * src/powerpc/darwin.S: Provide Darwin64 implementation, - update comments. - * src/powerpc/ffi_darwin.c: Likewise. - -2010-12-06 Rainer Orth - - * configure.ac (libffi_cv_as_ascii_pseudo_op): Use double - backslashes. - (libffi_cv_as_string_pseudo_op): Likewise. - * configure: Regenerate. - -2010-12-03 Chung-Lin Tang - - * src/arm/sysv.S (ffi_closure_SYSV): Add UNWIND to .pad directive. - (ffi_closure_VFP): Same. - (ffi_call_VFP): Move down to before ffi_closure_VFP. Add '.fpu vfp' - directive. - -2010-12-01 Rainer Orth - - * testsuite/libffi.call/ffitest.h [__sgi] (PRId64, PRIu64): Define. - (PRIuPTR): Define. - -2010-11-29 Richard Henderson - Rainer Orth - - * src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define. - (.eh_frame): Use FDE_ENCODING. - (.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE. - -2010-11-22 Jacek Caban - - * configure.ac: Check for symbol underscores on mingw-w64. - * configure: Rebuilt. - * src/x86/win64.S: Correctly access extern symbols in respect to - underscores. - -2010-11-15 Rainer Orth - - * testsuite/lib/libffi-dg.exp: Rename ... - * testsuite/lib/libffi.exp: ... to this. - * libffi/testsuite/libffi.call/call.exp: Don't load libffi-dg.exp. - * libffi/testsuite/libffi.special/special.exp: Likewise. - -2010-10-28 Chung-Lin Tang - - * src/arm/ffi.c (ffi_prep_args): Add VFP register argument handling - code, new parameter, and return value. Update comments. - (ffi_prep_cif_machdep): Add case for VFP struct return values. Add - call to layout_vfp_args(). - (ffi_call_SYSV): Update declaration. - (ffi_call_VFP): New declaration. - (ffi_call): Add VFP struct return conditions. Call ffi_call_VFP() - when ABI is FFI_VFP. - (ffi_closure_VFP): New declaration. - (ffi_closure_SYSV_inner): Add new vfp_args parameter, update call to - ffi_prep_incoming_args_SYSV(). - (ffi_prep_incoming_args_SYSV): Update parameters. Add VFP argument - case handling. - (ffi_prep_closure_loc): Pass ffi_closure_VFP to trampoline - construction under VFP hard-float. - (rec_vfp_type_p): New function. - (vfp_type_p): Same. - (place_vfp_arg): Same. - (layout_vfp_args): Same. - * src/arm/ffitarget.h (ffi_abi): Add FFI_VFP. Define FFI_DEFAULT_ABI - based on __ARM_PCS_VFP. - (FFI_EXTRA_CIF_FIELDS): Define for adding VFP hard-float specific - fields. - (FFI_TYPE_STRUCT_VFP_FLOAT): Define internally used type code. - (FFI_TYPE_STRUCT_VFP_DOUBLE): Same. - * src/arm/sysv.S (ffi_call_SYSV): Change call of ffi_prep_args() to - direct call. Move function pointer load upwards. - (ffi_call_VFP): New function. - (ffi_closure_VFP): Same. - - * testsuite/lib/libffi-dg.exp (check-flags): New function. - (dg-skip-if): New function. - * testsuite/libffi.call/cls_double_va.c: Skip if target is arm*-*-* - and compiler options include -mfloat-abi=hard. - * testsuite/libffi.call/cls_longdouble_va.c: Same. - -2010-10-01 Jakub Jelinek - - PR libffi/45677 - * src/x86/ffi64.c (ffi_prep_cif_machdep): Ensure cif->bytes is - a multiple of 8. - * testsuite/libffi.call/many2.c: New test. - -2010-08-20 Mark Wielaard - - * src/closures.c (open_temp_exec_file_mnt): Check if getmntent_r - returns NULL. - -2010-08-09 Andreas Tobler - - * configure.ac: Add target powerpc64-*-freebsd*. - * configure: Regenerate. - * testsuite/libffi.call/cls_align_longdouble_split.c: Pass - -mlong-double-128 only to linux targets. - * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise. - * testsuite/libffi.call/cls_longdouble.c: Likewise. - * testsuite/libffi.call/huge_struct.c: Likewise. - -2010-08-05 Dan Witte - - * Makefile.am: Pass FFI_DEBUG define to msvcc.sh for linking to the - debug CRT when --enable-debug is given. - * configure.ac: Define it. - * msvcc.sh: Translate -g and -DFFI_DEBUG appropriately. - -2010-08-04 Dan Witte - - * src/x86/ffitarget.h: Add X86_ANY define for all x86/x86_64 - platforms. - * src/x86/ffi.c: Remove redundant ifdef checks. - * src/prep_cif.c: Push stack space computation into src/x86/ffi.c - for X86_ANY so return value space doesn't get added twice. - -2010-08-03 Neil Rashbrooke - - * msvcc.sh: Don't pass -safeseh to ml64 because behavior is buggy. - -2010-07-22 Dan Witte - - * src/*/ffitarget.h: Make FFI_LAST_ABI one past the last valid ABI. - * src/prep_cif.c: Fix ABI assertion. - * src/cris/ffi.c: Ditto. - -2010-07-10 Evan Phoenix - - * src/closures.c (selinux_enabled_check): Fix strncmp usage bug. - -2010-07-07 Dan Horák - - * include/ffi.h.in: Protect #define with #ifndef. - * src/powerpc/ffitarget.h: Ditto. - * src/s390/ffitarget.h: Ditto. - * src/sparc/ffitarget.h: Ditto. - -2010-07-07 Neil Roberts - - * src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to - 16-bytes. - -2010-07-02 Jakub Jelinek - - * Makefile.am (AM_MAKEFLAGS): Pass also mandir to submakes. - * Makefile.in: Regenerated. - -2010-05-19 Rainer Orth - - * configure.ac (libffi_cv_as_x86_pcrel): Check for illegal in as - output, too. - (libffi_cv_as_ascii_pseudo_op): Check for .ascii. - (libffi_cv_as_string_pseudo_op): Check for .string. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * src/x86/sysv.S (.eh_frame): Use .ascii, .string or error. - -2010-05-11 Dan Witte - - * doc/libffi.tex: Document previous change. - -2010-05-11 Makoto Kato - - * src/x86/ffi.c (ffi_call): Don't copy structs passed by value. - -2010-05-05 Michael Kohler - - * src/dlmalloc.c (dlfree): Fix spelling. - * src/ia64/ffi.c (ffi_prep_cif_machdep): Ditto. - * configure.ac: Ditto. - * configure: Rebuilt. - -2010-04-13 Dan Witte - - * msvcc.sh: Build with -W3 instead of -Wall. - * src/powerpc/ffi_darwin.c: Remove build warnings. - * src/x86/ffi.c: Ditto. - * src/x86/ffitarget.h: Ditto. - -2010-04-12 Dan Witte - Walter Meinl - - * configure.ac: Add OS/2 support. - * configure: Rebuilt. - * src/closures.c: Ditto. - * src/dlmalloc.c: Ditto. - * src/x86/win32.S: Ditto. - -2010-04-07 Jakub Jelinek - - * testsuite/libffi.call/err_bad_abi.c: Remove unused args variable. - -2010-04-02 Ralf Wildenhues - - * Makefile.in: Regenerate. - * aclocal.m4: Regenerate. - * include/Makefile.in: Regenerate. - * man/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2010-03-30 Dan Witte - - * msvcc.sh: Disable build warnings. - * README (tested): Clarify windows build procedure. - -2010-03-15 Rainer Orth - - * configure.ac (libffi_cv_as_x86_64_unwind_section_type): New test. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * libffi/src/x86/unix64.S (.eh_frame) - [HAVE_AS_X86_64_UNWIND_SECTION_TYPE]: Use @unwind section type. - -2010-03-14 Matthias Klose - - * src/x86/ffi64.c: Fix typo in comment. - * src/x86/ffi.c: Use /* ... */ comment style. - -2010-02-24 Rainer Orth - - * doc/libffi.texi (The Closure API): Fix typo. - * doc/libffi.info: Remove. - -2010-02-15 Matthias Klose - - * src/arm/sysv.S (__ARM_ARCH__): Define for processor - __ARM_ARCH_7EM__. - -2010-01-15 Anthony Green - - * README: Add notes on building with Microsoft Visual C++. - -2010-01-15 Daniel Witte - - * msvcc.sh: New file. - - * src/x86/win32.S: Port assembly routines to MSVC and #ifdef. - * src/x86/ffi.c: Tweak function declaration and remove excess - parens. - * include/ffi.h.in: Add __declspec(align(8)) to typedef struct - ffi_closure. - - * src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new - function ffi_call_win32 on X86_WIN32. - * src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32. - (ffi_call_STDCALL): Remove. - - * src/prep_cif.c (ffi_prep_cif): Move stack space allocation code - to ffi_prep_cif_machdep for x86. - * src/x86/ffi.c (ffi_prep_cif_machdep): To here. - -2010-01-15 Oliver Kiddle - - * src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for - Sun Studio compiler compatibility. - -2010-01-12 Conrad Irwin - - * doc/libffi.texi: Add closure example. - -2010-01-07 Rainer Orth - - PR libffi/40701 - * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRIdLL, - PRIuLL, PRId64, PRIu64, PRIuPTR): Define. - * testsuite/libffi.call/cls_align_sint64.c: Add -Wno-format on - alpha*-dec-osf*. - * testsuite/libffi.call/cls_align_uint64.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/return_ll1.c: Likewise. - * testsuite/libffi.call/stret_medium2.c: Likewise. - * testsuite/libffi.special/ffitestcxx.h (allocate_mmap): Cast - MAP_FAILED to char *. - -2010-01-06 Rainer Orth - - * src/mips/n32.S: Use .abicalls and .eh_frame with __GNUC__. - -2009-12-31 Anthony Green - - * README: Update for libffi 3.0.9. - -2009-12-27 Matthias Klose - - * configure.ac (HAVE_LONG_DOUBLE): Define for mips when - appropriate. - * configure: Rebuilt. - -2009-12-26 Anthony Green - - * testsuite/libffi.call/cls_longdouble_va.c: Mark as xfail for - avr32*-*-*. - * testsuite/libffi.call/cls_double_va.c: Ditto. - -2009-12-26 Andreas Tobler - - * testsuite/libffi.call/ffitest.h: Conditionally include stdint.h - and inttypes.h. - * testsuite/libffi.special/unwindtest.cc: Ditto. - -2009-12-26 Andreas Tobler - - * configure.ac: Add amd64-*-openbsd*. - * configure: Rebuilt. - * testsuite/lib/libffi-dg.exp (libffi_target_compile): Link - openbsd programs with -lpthread. - -2009-12-26 Anthony Green - - * testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c: Remove xfail for - mips*-*-* and arm*-*-*. - * testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c, - testsuite/libffi.call/stret_medium2.c, - testsuite/libffi.call/stret_medium.c, - testsuite/libffi.call/stret_large.c, - testsuite/libffi.call/stret_large2.c: Remove xfail for arm*-*-*. - -2009-12-31 Kay Tietz - - * testsuite/libffi.call/ffitest.h, - testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRuLL): Fix - definitions. - -2009-12-31 Carlo Bramini - - * configure.ac (AM_LTLDFLAGS): Define for windows hosts. - * Makefile.am (libffi_la_LDFLAGS): Add AM_LTLDFLAGS. - * configure: Rebuilt. - * Makefile.in: Rebuilt. - -2009-12-31 Anthony Green - Blake Chaffin. - - * testsuite/libffi.call/huge_struct.c: New test case from Blake - Chaffin @ Apple. - -2009-12-28 David Edelsohn - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Copy abi and nargs to - local variables. - (aix_adjust_aggregate_sizes): New function. - (ffi_prep_cif_machdep): Call it. - -2009-12-26 Andreas Tobler - - * configure.ac: Define FFI_MMAP_EXEC_WRIT for the given targets. - * configure: Regenerate. - * fficonfig.h.in: Likewise. - * src/closures.c: Remove the FFI_MMAP_EXEC_WRIT definition for - Solaris/x86. - -2009-12-26 Andreas Schwab - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Advance intarg_count - when a float arguments is passed in memory. - (ffi_closure_helper_SYSV): Mark general registers as used up when - a 64bit or soft-float long double argument is passed in memory. - -2009-12-25 Matthias Klose - - * man/ffi_call.3: Fix #include in examples. - * doc/libffi.texi: Add dircategory. - -2009-12-25 Frank Everdij - - * include/ffi.h.in: Placed '__GNUC__' ifdef around - '__attribute__((aligned(8)))' in ffi_closure, fixes compile for - IRIX MIPSPro c99. - * include/ffi_common.h: Added '__sgi' define to non - '__attribute__((__mode__()))' integer typedefs. - * src/mips/ffi.c (ffi_call, ffi_closure_mips_inner_O32, - ffi_closure_mips_inner_N32): Added 'defined(_MIPSEB)' to BE check. - (ffi_closure_mips_inner_O32, ffi_closure_mips_inner_N32): Added - FFI_LONGDOUBLE support and alignment(N32 only). - * src/mips/ffitarget.h: Corrected '#include ' for IRIX and - fixed non '__attribute__((__mode__()))' integer typedefs. - * src/mips/n32.S: Put '#ifdef linux' around '.abicalls' and '.eh_frame' - since they are Linux/GNU Assembler specific. - -2009-12-25 Bradley Smith - - * configure.ac, Makefile.am, src/avr32/ffi.c, - src/avr32/ffitarget.h, - src/avr32/sysv.S: Add AVR32 port. - * configure, Makefile.in: Rebuilt. - -2009-12-21 Andreas Tobler - - * configure.ac: Make i?86 build on FreeBSD and OpenBSD. - * configure: Regenerate. - -2009-12-15 John David Anglin - - * testsuite/libffi.call/ffitest.h: Define PRIuPTR on PA HP-UX. - -2009-12-13 John David Anglin - - * src/pa/ffi.c (ffi_closure_inner_pa32): Handle FFI_TYPE_LONGDOUBLE - type on HP-UX. - -2012-02-13 Kai Tietz - - PR libffi/52221 - * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall - support for X86_WIN32. - (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement. - -2009-12-11 Eric Botcazou - - * src/sparc/ffi.c (ffi_closure_sparc_inner_v9): Properly align 'long - double' arguments. - -2009-12-11 Eric Botcazou - - * testsuite/libffi.call/ffitest.h: Define PRIuPTR on Solaris < 10. - -2009-12-10 Rainer Orth - - PR libffi/40700 - * src/closures.c [X86_64 && __sun__ && __svr4__] - (FFI_MMAP_EXEC_WRIT): Define. - -2009-12-08 David Daney - - * testsuite/libffi.call/stret_medium.c: Remove xfail for mips*-*-* - * testsuite/libffi.call/cls_align_longdouble_split2.c: Same. - * testsuite/libffi.call/stret_large.c: Same. - * testsuite/libffi.call/cls_align_longdouble_split.c: Same. - * testsuite/libffi.call/stret_large2.c: Same. - * testsuite/libffi.call/stret_medium2.c: Same. - -2009-12-07 David Edelsohn - - * src/powerpc/aix_closure.S (libffi_closure_ASM): Fix tablejump - typo. - -2009-12-05 David Edelsohn - - * src/powerpc/aix.S: Update AIX32 code to be consistent with AIX64 - code. - * src/powerpc/aix_closure.S: Same. - -2009-12-05 Ralf Wildenhues - - * Makefile.in: Regenerate. - * configure: Regenerate. - * include/Makefile.in: Regenerate. - * man/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2009-12-04 David Edelsohn - - * src/powerpc/aix_closure.S: Reorganize 64-bit code to match - linux64_closure.S. - -2009-12-04 Uros Bizjak - - PR libffi/41908 - * src/x86/ffi64.c (classify_argument): Update from - gcc/config/i386/i386.c. - (ffi_closure_unix64_inner): Do not use the address of two consecutive - SSE registers directly. - * testsuite/libffi.call/cls_dbls_struct.c (main): Remove xfail - for x86_64 linux targets. - -2009-12-04 David Edelsohn - - * src/powerpc/ffi_darwin.c (ffi_closure_helper_DARWIN): Increment - pfr for long double split between fpr13 and stack. - -2009-12-03 David Edelsohn - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Increment next_arg and - fparg_count twice for long double. - -2009-12-03 David Edelsohn - - PR libffi/42243 - * src/powerpc/ffi_darwin.c (ffi_prep_args): Remove extra parentheses. - -2009-12-03 Uros Bizjak - - * testsuite/libffi.call/cls_longdouble_va.c (main): Fix format string. - Remove xfails for x86 linux targets. - -2009-12-02 David Edelsohn - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Fix typo in INT64 - case. - -2009-12-01 David Edelsohn - - * src/powerpc/aix.S (ffi_call_AIX): Convert to more standard - register usage. Call ffi_prep_args directly. Add long double - return value support. - * src/powerpc/ffi_darwin.c (ffi_prep_args): Double arg increment - applies to FFI_TYPE_DOUBLE. Correct fpr_base increment typo. - Separate FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases. - (ffi_prep_cif_machdep): Only 16 byte stack alignment in 64 bit - mode. - (ffi_closure_helper_DARWIN): Remove nf and ng counters. Move temp - into case. - * src/powerpc/aix_closure.S: Maintain 16 byte stack alignment. - Allocate result area between params and FPRs. - -2009-11-30 David Edelsohn - - PR target/35484 - * src/powerpc/ffitarget.h (POWERPC64): Define for PPC64 Linux and - AIX64. - * src/powerpc/aix.S: Implement AIX64 version. - * src/powerpc/aix_closure.S: Implement AIX64 version. - (ffi_closure_ASM): Use extsb, lha and displament addresses. - * src/powerpc/ffi_darwin.c (ffi_prep_args): Implement AIX64 - support. - (ffi_prep_cif_machdep): Same. - (ffi_call): Same. - (ffi_closure_helper_DARWIN): Same. - -2009-11-02 Andreas Tobler - - PR libffi/41908 - * testsuite/libffi.call/testclosure.c: New test. - -2009-09-28 Kai Tietz - - * src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu - assembly version use of ___chkstk. - -2009-09-23 Matthias Klose - - PR libffi/40242, PR libffi/41443 - * src/arm/sysv.S (__ARM_ARCH__): Define for processors - __ARM_ARCH_6T2__, __ARM_ARCH_6M__, __ARM_ARCH_7__, - __ARM_ARCH_7A__, __ARM_ARCH_7R__, __ARM_ARCH_7M__. - Change the conditionals to __SOFTFP__ || __ARM_EABI__ - for -mfloat-abi=softfp to work. - -2009-09-17 Loren J. Rittle - - PR testsuite/32843 (strikes again) - * src/x86/ffi.c (ffi_prep_cif_machdep): Add X86_FREEBSD to - enable proper extension on char and short. - -2009-09-15 David Daney - - * src/java_raw_api.c (ffi_java_raw_to_rvalue): Remove special - handling for FFI_TYPE_POINTER. - * src/mips/ffitarget.h (FFI_TYPE_STRUCT_D_SOFT, - FFI_TYPE_STRUCT_F_SOFT, FFI_TYPE_STRUCT_DD_SOFT, - FFI_TYPE_STRUCT_FF_SOFT, FFI_TYPE_STRUCT_FD_SOFT, - FFI_TYPE_STRUCT_DF_SOFT, FFI_TYPE_STRUCT_SOFT): New defines. - (FFI_N32_SOFT_FLOAT, FFI_N64_SOFT_FLOAT): New ffi_abi enumerations. - (enum ffi_abi): Set FFI_DEFAULT_ABI for soft-float. - * src/mips/n32.S (ffi_call_N32): Add handling for soft-float - structure and pointer returns. - (ffi_closure_N32): Add handling for pointer returns. - * src/mips/ffi.c (ffi_prep_args, calc_n32_struct_flags, - calc_n32_return_struct_flags): Handle soft-float. - (ffi_prep_cif_machdep): Handle soft-float, fix pointer handling. - (ffi_call_N32): Declare proper argument types. - (ffi_call, copy_struct_N32, ffi_closure_mips_inner_N32): Handle - soft-float. - -2009-08-24 Ralf Wildenhues - - * configure.ac (AC_PREREQ): Bump to 2.64. - -2009-08-22 Ralf Wildenhues - - * Makefile.am (install-html, install-pdf): Remove. - * Makefile.in: Regenerate. - - * Makefile.in: Regenerate. - * aclocal.m4: Regenerate. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * include/Makefile.in: Regenerate. - * man/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2011-08-22 Jasper Lievisse Adriaanse - - * configure.ac: Add OpenBSD/hppa and OpenBSD/powerpc support. - * configure: Rebuilt. - -2009-07-30 Ralf Wildenhues - - * configure.ac (_AC_ARG_VAR_PRECIOUS): Use m4_rename_force. - -2009-07-24 Dave Korn - - PR libffi/40807 - * src/x86/ffi.c (ffi_prep_cif_machdep): Also use sign/zero-extending - return types for X86_WIN32. - * src/x86/win32.S (_ffi_call_SYSV): Handle omitted return types. - (_ffi_call_STDCALL, _ffi_closure_SYSV, _ffi_closure_raw_SYSV, - _ffi_closure_STDCALL): Likewise. - - * src/closures.c (is_selinux_enabled): Define to const 0 for Cygwin. - (dlmmap, dlmunmap): Also use these functions on Cygwin. - -2009-07-11 Richard Sandiford - - PR testsuite/40699 - PR testsuite/40707 - PR testsuite/40709 - * testsuite/lib/libffi-dg.exp: Revert 2009-07-02, 2009-07-01 and - 2009-06-30 commits. - -2009-07-01 Richard Sandiford - - * testsuite/lib/libffi-dg.exp (libffi-init): Set ld_library_path - to "" before adding paths. (This reinstates an assignment that - was removed by my 2009-06-30 commit, but changes the initial - value from "." to "".) - -2009-07-01 H.J. Lu - - PR testsuite/40601 - * testsuite/lib/libffi-dg.exp (libffi-init): Properly set - gccdir. Adjust ld_library_path for gcc only if gccdir isn't - empty. - -2009-06-30 Richard Sandiford - - * testsuite/lib/libffi-dg.exp (libffi-init): Don't add "." - to ld_library_path. Use add_path. Add just find_libgcc_s - to ld_library_path, not every libgcc multilib directory. - -2009-06-16 Wim Lewis - - * src/powerpc/ffi.c: Avoid clobbering cr3 and cr4, which are - supposed to be callee-saved. - * src/powerpc/sysv.S (small_struct_return_value): Fix overrun of - return buffer for odd-size structs. - -2009-06-16 Andreas Tobler - - PR libffi/40444 - * testsuite/lib/libffi-dg.exp (libffi_target_compile): Add - allow_stack_execute for Darwin. - -2009-06-16 Andrew Haley - - * configure.ac (TARGETDIR): Add missing blank lines. - * configure: Regenerate. - -2009-06-16 Andrew Haley - - * testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_medium2.c: Fix printf format - specifiers. - * testsuite/libffi.call/ffitest.h, - testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define. - -2009-06-15 Andrew Haley - - * testsuite/libffi.call/err_bad_typedef.c: xfail everywhere. - * testsuite/libffi.call/err_bad_abi.c: Likewise. - -2009-06-12 Andrew Haley - - * Makefile.am: Remove info_TEXINFOS. - -2009-06-12 Andrew Haley - - * ChangeLog.libffi: testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_medium2.c: Fix printf format - specifiers. - testsuite/libffi.special/unwindtest.cc: include stdint.h. - -2009-06-11 Timothy Wall - - * Makefile.am, - configure.ac, - include/ffi.h.in, - include/ffi_common.h, - src/closures.c, - src/dlmalloc.c, - src/x86/ffi.c, - src/x86/ffitarget.h, - src/x86/win64.S (new), - README: Added win64 support (mingw or MSVC) - * Makefile.in, - include/Makefile.in, - man/Makefile.in, - testsuite/Makefile.in, - configure, - aclocal.m4: Regenerated - * ltcf-c.sh: properly escape cygwin/w32 path - * man/ffi_call.3: Clarify size requirements for return value. - * src/x86/ffi64.c: Fix filename in comment. - * src/x86/win32.S: Remove unused extern. - - * testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/cls_12byte.c, - testsuite/libffi.call/cls_16byte.c, - testsuite/libffi.call/cls_18byte.c, - testsuite/libffi.call/cls_19byte.c, - testsuite/libffi.call/cls_1_1byte.c, - testsuite/libffi.call/cls_20byte.c, - testsuite/libffi.call/cls_20byte1.c, - testsuite/libffi.call/cls_24byte.c, - testsuite/libffi.call/cls_2byte.c, - testsuite/libffi.call/cls_3_1byte.c, - testsuite/libffi.call/cls_3byte1.c, - testsuite/libffi.call/cls_3byte2.c, - testsuite/libffi.call/cls_4_1byte.c, - testsuite/libffi.call/cls_4byte.c, - testsuite/libffi.call/cls_5_1_byte.c, - testsuite/libffi.call/cls_5byte.c, - testsuite/libffi.call/cls_64byte.c, - testsuite/libffi.call/cls_6_1_byte.c, - testsuite/libffi.call/cls_6byte.c, - testsuite/libffi.call/cls_7_1_byte.c, - testsuite/libffi.call/cls_7byte.c, - testsuite/libffi.call/cls_8byte.c, - testsuite/libffi.call/cls_9byte1.c, - testsuite/libffi.call/cls_9byte2.c, - testsuite/libffi.call/cls_align_double.c, - testsuite/libffi.call/cls_align_float.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_align_sint16.c, - testsuite/libffi.call/cls_align_sint32.c, - testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint16.c, - testsuite/libffi.call/cls_align_uint32.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_dbls_struct.c, - testsuite/libffi.call/cls_double.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_float.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_multi_schar.c, - testsuite/libffi.call/cls_multi_sshort.c, - testsuite/libffi.call/cls_multi_sshortchar.c, - testsuite/libffi.call/cls_multi_uchar.c, - testsuite/libffi.call/cls_multi_ushort.c, - testsuite/libffi.call/cls_multi_ushortchar.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c, - testsuite/libffi.call/cls_schar.c, - testsuite/libffi.call/cls_sint.c, - testsuite/libffi.call/cls_sshort.c, - testsuite/libffi.call/cls_uchar.c, - testsuite/libffi.call/cls_uint.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/cls_ushort.c, - testsuite/libffi.call/err_bad_abi.c, - testsuite/libffi.call/err_bad_typedef.c, - testsuite/libffi.call/float2.c, - testsuite/libffi.call/huge_struct.c, - testsuite/libffi.call/nested_struct.c, - testsuite/libffi.call/nested_struct1.c, - testsuite/libffi.call/nested_struct10.c, - testsuite/libffi.call/nested_struct2.c, - testsuite/libffi.call/nested_struct3.c, - testsuite/libffi.call/nested_struct4.c, - testsuite/libffi.call/nested_struct5.c, - testsuite/libffi.call/nested_struct6.c, - testsuite/libffi.call/nested_struct7.c, - testsuite/libffi.call/nested_struct8.c, - testsuite/libffi.call/nested_struct9.c, - testsuite/libffi.call/problem1.c, - testsuite/libffi.call/return_ldl.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_large.c, - testsuite/libffi.call/stret_large2.c, - testsuite/libffi.call/stret_medium.c, - testsuite/libffi.call/stret_medium2.c, - testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead - of checking for MMAP. Use intptr_t instead of long casts. - -2009-06-11 Kaz Kojima - - * testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*. - * testsuite/libffi.call/err_bad_abi.c: Add xfail sh*-*-*. - * testsuite/libffi.call/err_bad_typedef.c: Likewise. - -2009-06-09 Andrew Haley - - * src/x86/freebsd.S: Add missing file. - -2009-06-08 Andrew Haley - - Import from libffi 3.0.8: - - * doc/libffi.texi: New file. - * doc/libffi.info: Likewise. - * doc/stamp-vti: Likewise. - * man/Makefile.am: New file. - * man/ffi_call.3: New file. - - * Makefile.am (EXTRA_DIST): Add src/x86/darwin64.S, - src/dlmalloc.c. - (nodist_libffi_la_SOURCES): Add X86_FREEBSD. - - * configure.ac: Bump version to 3.0.8. - parisc*-*-linux*: Add. - i386-*-freebsd* | i386-*-openbsd*: Add. - powerpc-*-beos*: Add. - AM_CONDITIONAL X86_FREEBSD: Add. - AC_CONFIG_FILES: Add man/Makefile. - - * include/ffi.h.in (FFI_FN): Change void (*)() to void (*)(void). - -2009-06-08 Andrew Haley - - * README: Import from libffi 3.0.8. - -2009-06-08 Andrew Haley - - * testsuite/libffi.call/err_bad_abi.c: Add xfails. - * testsuite/libffi.call/cls_longdouble_va.c: Add xfails. - * testsuite/libffi.call/cls_dbls_struct.c: Add xfail x86_64-*-linux-*. - * testsuite/libffi.call/err_bad_typedef.c: Add xfails. - - * testsuite/libffi.call/stret_medium2.c: Add __UNUSED__ to args. - * testsuite/libffi.call/stret_medium.c: Likewise. - * testsuite/libffi.call/stret_large2.c: Likewise. - * testsuite/libffi.call/stret_large.c: Likewise. - -2008-12-26 Timothy Wall - - * testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected - failures on x86_64 cygwin/mingw. - -2008-12-22 Timothy Wall - - * testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/closure_loc_fn0.c, - testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c: use portable cast from - pointer to integer (intptr_t). - * testsuite/libffi.call/cls_longdouble.c: disable for win64. - -2008-07-24 Anthony Green - - * testsuite/libffi.call/cls_dbls_struct.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c, - testsuite/libffi.call/err_bad_abi.c: Clean up failures from - compiler warnings. - -2008-03-04 Anthony Green - Blake Chaffin - hos@tamanegi.org - - * testsuite/libffi.call/cls_align_longdouble_split2.c - testsuite/libffi.call/cls_align_longdouble_split.c - testsuite/libffi.call/cls_dbls_struct.c - testsuite/libffi.call/cls_double_va.c - testsuite/libffi.call/cls_longdouble.c - testsuite/libffi.call/cls_longdouble_va.c - testsuite/libffi.call/cls_pointer.c - testsuite/libffi.call/cls_pointer_stack.c - testsuite/libffi.call/err_bad_abi.c - testsuite/libffi.call/err_bad_typedef.c - testsuite/libffi.call/stret_large2.c - testsuite/libffi.call/stret_large.c - testsuite/libffi.call/stret_medium2.c - testsuite/libffi.call/stret_medium.c: New tests from Apple. - -2009-06-05 Andrew Haley - - * src/x86/ffitarget.h, src/x86/ffi.c: Merge stdcall changes from - libffi. - -2009-06-04 Andrew Haley - - * src/x86/ffitarget.h, src/x86/win32.S, src/x86/ffi.c: Back out - stdcall changes. - -2008-02-26 Anthony Green - Thomas Heller - - * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C - comment. - -2008-02-03 Timothy Wall - - * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return - offset based on code pointer, not data pointer. - -2008-01-31 Timothy Wall - - * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall - closures. - * src/x86/ffitarget.h: Increase size of trampoline for stdcall - closures. - * src/x86/win32.S: Add assembly for stdcall closure. - * src/x86/ffi.c: Initialize stdcall closure trampoline. - -2009-06-04 Andrew Haley - - * include/ffi.h.in: Change void (*)() to void (*)(void). - * src/x86/ffi.c: Likewise. - -2009-06-04 Andrew Haley - - * src/powerpc/ppc_closure.S: Insert licence header. - * src/powerpc/linux64_closure.S: Likewise. - * src/m68k/sysv.S: Likewise. - - * src/sh64/ffi.c: Change void (*)() to void (*)(void). - * src/powerpc/ffi.c: Likewise. - * src/powerpc/ffi_darwin.c: Likewise. - * src/m32r/ffi.c: Likewise. - * src/sh64/ffi.c: Likewise. - * src/x86/ffi64.c: Likewise. - * src/alpha/ffi.c: Likewise. - * src/alpha/osf.S: Likewise. - * src/frv/ffi.c: Likewise. - * src/s390/ffi.c: Likewise. - * src/pa/ffi.c: Likewise. - * src/pa/hpux32.S: Likewise. - * src/ia64/unix.S: Likewise. - * src/ia64/ffi.c: Likewise. - * src/sparc/ffi.c: Likewise. - * src/mips/ffi.c: Likewise. - * src/sh/ffi.c: Likewise. - -2008-02-15 David Daney - - * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE): - Define (conditionally), and use it to include cachectl.h. - (ffi_prep_closure_loc): Fix cache flushing. - * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define. - -2009-06-04 Andrew Haley - - include/ffi.h.in, - src/arm/ffitarget.h, - src/arm/ffi.c, - src/arm/sysv.S, - src/powerpc/ffitarget.h, - src/closures.c, - src/sh64/ffitarget.h, - src/sh64/ffi.c, - src/sh64/sysv.S, - src/types.c, - src/x86/ffi64.c, - src/x86/ffitarget.h, - src/x86/win32.S, - src/x86/darwin.S, - src/x86/ffi.c, - src/x86/sysv.S, - src/x86/unix64.S, - src/alpha/ffitarget.h, - src/alpha/ffi.c, - src/alpha/osf.S, - src/m68k/ffitarget.h, - src/frv/ffitarget.h, - src/frv/ffi.c, - src/s390/ffitarget.h, - src/s390/sysv.S, - src/cris/ffitarget.h, - src/pa/linux.S, - src/pa/ffitarget.h, - src/pa/ffi.c, - src/raw_api.c, - src/ia64/ffitarget.h, - src/ia64/unix.S, - src/ia64/ffi.c, - src/ia64/ia64_flags.h, - src/java_raw_api.c, - src/debug.c, - src/sparc/v9.S, - src/sparc/ffitarget.h, - src/sparc/ffi.c, - src/sparc/v8.S, - src/mips/ffitarget.h, - src/mips/n32.S, - src/mips/o32.S, - src/mips/ffi.c, - src/prep_cif.c, - src/sh/ffitarget.h, - src/sh/ffi.c, - src/sh/sysv.S: Update license text. - -2009-05-22 Dave Korn - - * src/x86/win32.S (_ffi_closure_STDCALL): New function. - (.eh_frame): Add FDE for it. - -2009-05-22 Dave Korn - - * configure.ac: Also check if assembler supports pc-relative - relocs on X86_WIN32 targets. - * configure: Regenerate. - * src/x86/win32.S (ffi_prep_args): Declare extern, not global. - (_ffi_call_SYSV): Add missing function type symbol .def and - add EH markup labels. - (_ffi_call_STDCALL): Likewise. - (_ffi_closure_SYSV): Likewise. - (_ffi_closure_raw_SYSV): Likewise. - (.eh_frame): Add hand-crafted EH data. - -2009-04-09 Jakub Jelinek - - * testsuite/lib/libffi-dg.exp: Change copyright header to refer to - version 3 of the GNU General Public License and to point readers - at the COPYING3 file and the FSF's license web page. - * testsuite/libffi.call/call.exp: Likewise. - * testsuite/libffi.special/special.exp: Likewise. - -2009-03-01 Ralf Wildenhues - - * configure: Regenerate. - -2008-12-18 Rainer Orth - - PR libffi/26048 - * configure.ac (HAVE_AS_X86_PCREL): New test. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * src/x86/sysv.S [!FFI_NO_RAW_API]: Precalculate - RAW_CLOSURE_CIF_OFFSET, RAW_CLOSURE_FUN_OFFSET, - RAW_CLOSURE_USER_DATA_OFFSET for the Solaris 10/x86 assembler. - (.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL. - * src/x86/unix64.S (.Lstore_table): Move to .text section. - (.Lload_table): Likewise. - (.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL. - -2008-12-18 Ralf Wildenhues - - * configure: Regenerate. - -2008-11-21 Eric Botcazou - - * src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for - signed/unsigned int8/16 return values. - * src/sparc/v8.S (ffi_call_v8): Likewise. - (ffi_closure_v8): Likewise. - -2008-09-26 Peter O'Gorman - Steve Ellcey - - * configure: Regenerate for new libtool. - * Makefile.in: Ditto. - * include/Makefile.in: Ditto. - * aclocal.m4: Ditto. - -2008-08-25 Andreas Tobler - - * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and - FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. - Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. - Adjust copyright notice. - * src/powerpc/ffi.c: Add two new flags to indicate if we have one - register or two register to use for FFI_SYSV structs. - (ffi_prep_cif_machdep): Pass the right register flag introduced above. - (ffi_closure_helper_SYSV): Fix the return type for - FFI_SYSV_TYPE_SMALL_STRUCT. Comment. - Adjust copyright notice. - -2008-07-16 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned - int. - -2008-06-17 Ralf Wildenhues - - * configure: Regenerate. - * include/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2008-06-07 Joseph Myers - - * configure.ac (parisc*-*-linux*, powerpc-*-sysv*, - powerpc-*-beos*): Remove. - * configure: Regenerate. - -2008-05-09 Julian Brown - - * Makefile.am (LTLDFLAGS): New. - (libffi_la_LDFLAGS): Use above. - * Makefile.in: Regenerate. - -2008-04-18 Paolo Bonzini - - PR bootstrap/35457 - * aclocal.m4: Regenerate. - * configure: Regenerate. - -2008-03-26 Kaz Kojima - - * src/sh/sysv.S: Add .note.GNU-stack on Linux. - * src/sh64/sysv.S: Likewise. - -2008-03-26 Daniel Jacobowitz - - * src/arm/sysv.S: Fix ARM comment marker. - -2008-03-26 Jakub Jelinek - - * src/alpha/osf.S: Add .note.GNU-stack on Linux. - * src/s390/sysv.S: Likewise. - * src/powerpc/ppc_closure.S: Likewise. - * src/powerpc/sysv.S: Likewise. - * src/x86/unix64.S: Likewise. - * src/x86/sysv.S: Likewise. - * src/sparc/v8.S: Likewise. - * src/sparc/v9.S: Likewise. - * src/m68k/sysv.S: Likewise. - * src/arm/sysv.S: Likewise. - -2008-03-16 Ralf Wildenhues - - * aclocal.m4: Regenerate. - * configure: Likewise. - * Makefile.in: Likewise. - * include/Makefile.in: Likewise. - * testsuite/Makefile.in: Likewise. - -2008-02-12 Bjoern Koenig - Andreas Tobler - - * configure.ac: Add amd64-*-freebsd* target. - * configure: Regenerate. - -2008-01-30 H.J. Lu - - PR libffi/34612 - * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when - returning struct. - - * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer" - tests. - -2008-01-24 David Edelsohn - - * configure: Regenerate. - -2008-01-06 Andreas Tobler - - * src/x86/ffi.c (ffi_prep_cif_machdep): Fix thinko. - -2008-01-05 Andreas Tobler - - PR testsuite/32843 - * src/x86/ffi.c (ffi_prep_cif_machdep): Add code for - signed/unsigned int8/16 for X86_DARWIN. - Updated copyright info. - Handle one and two byte structs with special cif->flags. - * src/x86/ffitarget.h: Add special types for one and two byte structs. - Updated copyright info. - * src/x86/darwin.S (ffi_call_SYSV): Rewrite to use a jump table like - sysv.S - Remove code to pop args from the stack after call. - Special-case signed/unsigned for int8/16, one and two byte structs. - (ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8, - FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32, - FFI_TYPE_SINT32. - Updated copyright info. - -2007-12-08 David Daney - - * src/mips/n32.S (ffi_call_N32): Replace dadd with ADDU, dsub with - SUBU, add with ADDU and use smaller code sequences. - -2007-12-07 David Daney - - * src/mips/ffi.c (ffi_prep_cif_machdep): Handle long double return - type. - -2007-12-06 David Daney - - * include/ffi.h.in (FFI_SIZEOF_JAVA_RAW): Define if not already - defined. - (ffi_java_raw): New typedef. - (ffi_java_raw_call, ffi_java_ptrarray_to_raw, - ffi_java_raw_to_ptrarray): Change parameter types from ffi_raw to - ffi_java_raw. - (ffi_java_raw_closure) : Same. - (ffi_prep_java_raw_closure, ffi_prep_java_raw_closure_loc): Change - parameter types. - * src/java_raw_api.c (ffi_java_raw_size): Replace FFI_SIZEOF_ARG with - FFI_SIZEOF_JAVA_RAW. - (ffi_java_raw_to_ptrarray): Change type of raw to ffi_java_raw. - Replace FFI_SIZEOF_ARG with FFI_SIZEOF_JAVA_RAW. Use - sizeof(ffi_java_raw) for alignment calculations. - (ffi_java_ptrarray_to_raw): Same. - (ffi_java_rvalue_to_raw): Add special handling for FFI_TYPE_POINTER - if FFI_SIZEOF_JAVA_RAW == 4. - (ffi_java_raw_to_rvalue): Same. - (ffi_java_raw_call): Change type of raw to ffi_java_raw. - (ffi_java_translate_args): Same. - (ffi_prep_java_raw_closure_loc, ffi_prep_java_raw_closure): Change - parameter types. - * src/mips/ffitarget.h (FFI_SIZEOF_JAVA_RAW): Define for N32 ABI. - -2007-12-06 David Daney - - * src/mips/n32.S (ffi_closure_N32): Use 64-bit add instruction on - pointer values. - -2007-12-01 Andreas Tobler - - PR libffi/31937 - * src/powerpc/ffitarget.h: Introduce new ABI FFI_LINUX_SOFT_FLOAT. - Add local FFI_TYPE_UINT128 to handle soft-float long-double-128. - * src/powerpc/ffi.c: Distinguish between __NO_FPRS__ and not and - set the NUM_FPR_ARG_REGISTERS according to. - Add support for potential soft-float support under hard-float - architecture. - (ffi_prep_args_SYSV): Set NUM_FPR_ARG_REGISTERS to 0 in case of - FFI_LINUX_SOFT_FLOAT, handle float, doubles and long-doubles according - to the FFI_LINUX_SOFT_FLOAT ABI. - (ffi_prep_cif_machdep): Likewise. - (ffi_closure_helper_SYSV): Likewise. - * src/powerpc/ppc_closure.S: Make sure not to store float/double - on archs where __NO_FPRS__ is true. - Add FFI_TYPE_UINT128 support. - * src/powerpc/sysv.S: Add support for soft-float long-double-128. - Adjust copyright notice. - -2007-11-25 Andreas Tobler - - * src/closures.c: Move defintion of MAYBE_UNUSED from here to ... - * include/ffi_common.h: ... here. - Update copyright. - -2007-11-17 Andreas Tobler - - * src/powerpc/sysv.S: Load correct cr to compare if we have long double. - * src/powerpc/linux64.S: Likewise. - * src/powerpc/ffi.c: Add a comment to show which part goes into cr6. - * testsuite/libffi.call/return_ldl.c: New test. - -2007-09-04 - - * src/arm/sysv.S (UNWIND): New. - (Whole file): Conditionally compile unwinder directives. - * src/arm/sysv.S: Add unwinder directives. - - * src/arm/ffi.c (ffi_prep_args): Align structs by at least 4 bytes. - Only treat r0 as a struct address if we're actually returning a - struct by address. - Only copy the bytes that are actually within a struct. - (ffi_prep_cif_machdep): A Composite Type not larger than 4 bytes - is returned in r0, not passed by address. - (ffi_call): Allocate a word-sized temporary for the case where - a composite is returned in r0. - (ffi_prep_incoming_args_SYSV): Align as necessary. - -2007-08-05 Steven Newbury - - * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Use __clear_cache instead of - directly using the sys_cacheflush syscall. - -2007-07-27 Andrew Haley - - * src/arm/sysv.S (ffi_closure_SYSV): Add soft-float. - -2007-09-03 Maciej W. Rozycki - - * Makefile.am: Unify MIPS_IRIX and MIPS_LINUX into MIPS. - * configure.ac: Likewise. - * Makefile.in: Regenerate. - * include/Makefile.in: Likewise. - * testsuite/Makefile.in: Likewise. - * configure: Likewise. - -2007-08-24 David Daney - - * testsuite/libffi.call/return_sl.c: New test. - -2007-08-10 David Daney - - * testsuite/libffi.call/cls_multi_ushort.c, - testsuite/libffi.call/cls_align_uint16.c, - testsuite/libffi.call/nested_struct1.c, - testsuite/libffi.call/nested_struct3.c, - testsuite/libffi.call/cls_7_1_byte.c, - testsuite/libffi.call/nested_struct5.c, - testsuite/libffi.call/cls_double.c, - testsuite/libffi.call/nested_struct7.c, - testsuite/libffi.call/cls_sint.c, - testsuite/libffi.call/nested_struct9.c, - testsuite/libffi.call/cls_20byte1.c, - testsuite/libffi.call/cls_multi_sshortchar.c, - testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_3byte2.c, - testsuite/libffi.call/cls_multi_schar.c, - testsuite/libffi.call/cls_multi_uchar.c, - testsuite/libffi.call/cls_19byte.c, - testsuite/libffi.call/cls_9byte1.c, - testsuite/libffi.call/cls_align_float.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/problem1.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/cls_sshort.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/cls_align_double.c, - testsuite/libffi.call/nested_struct.c, - testsuite/libffi.call/cls_2byte.c, - testsuite/libffi.call/nested_struct10.c, - testsuite/libffi.call/cls_4byte.c, - testsuite/libffi.call/cls_6byte.c, - testsuite/libffi.call/cls_8byte.c, - testsuite/libffi.call/cls_multi_sshort.c, - testsuite/libffi.call/cls_align_sint16.c, - testsuite/libffi.call/cls_align_uint32.c, - testsuite/libffi.call/cls_20byte.c, - testsuite/libffi.call/cls_float.c, - testsuite/libffi.call/nested_struct2.c, - testsuite/libffi.call/cls_5_1_byte.c, - testsuite/libffi.call/nested_struct4.c, - testsuite/libffi.call/cls_24byte.c, - testsuite/libffi.call/nested_struct6.c, - testsuite/libffi.call/cls_64byte.c, - testsuite/libffi.call/nested_struct8.c, - testsuite/libffi.call/cls_uint.c, - testsuite/libffi.call/cls_multi_ushortchar.c, - testsuite/libffi.call/cls_schar.c, - testsuite/libffi.call/cls_uchar.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_1_1byte.c, - testsuite/libffi.call/cls_12byte.c, - testsuite/libffi.call/cls_3_1byte.c, - testsuite/libffi.call/cls_3byte1.c, - testsuite/libffi.call/cls_4_1byte.c, - testsuite/libffi.call/cls_6_1_byte.c, - testsuite/libffi.call/cls_16byte.c, - testsuite/libffi.call/cls_18byte.c, - testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/cls_9byte2.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/cls_ushort.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/cls_5byte.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_7byte.c, - testsuite/libffi.call/cls_align_sint32.c, - testsuite/libffi.special/unwindtest_ffi_call.cc, - testsuite/libffi.special/unwindtest.cc: Remove xfail for mips64*-*-*. - -2007-08-10 David Daney - - PR libffi/28313 - * configure.ac: Don't treat mips64 as a special case. - * Makefile.am (nodist_libffi_la_SOURCES): Add n32.S. - * configure: Regenerate - * Makefile.in: Ditto. - * fficonfig.h.in: Ditto. - * src/mips/ffitarget.h (REG_L, REG_S, SUBU, ADDU, SRL, LI): Indent. - (LA, EH_FRAME_ALIGN, FDE_ADDR_BYTES): New preprocessor macros. - (FFI_DEFAULT_ABI): Set for n64 case. - (FFI_CLOSURES, FFI_TRAMPOLINE_SIZE): Define for n32 and n64 cases. - * src/mips/n32.S (ffi_call_N32): Add debug macros and labels for FDE. - (ffi_closure_N32): New function. - (.eh_frame): New section - * src/mips/o32.S: Clean up comments. - (ffi_closure_O32): Pass ffi_closure parameter in $12. - * src/mips/ffi.c: Use FFI_MIPS_N32 instead of - _MIPS_SIM == _ABIN32 throughout. - (FFI_MIPS_STOP_HERE): New, use in place of - ffi_stop_here. - (ffi_prep_args): Use unsigned long to hold pointer values. Rewrite - to support n32/n64 ABIs. - (calc_n32_struct_flags): Rewrite. - (calc_n32_return_struct_flags): Remove unused variable. Reverse - position of flag bits. - (ffi_prep_cif_machdep): Rewrite n32 portion. - (ffi_call): Enable for n64. Add special handling for small structure - return values. - (ffi_prep_closure_loc): Add n32 and n64 support. - (ffi_closure_mips_inner_O32): Add cast to silence warning. - (copy_struct_N32, ffi_closure_mips_inner_N32): New functions. - -2007-08-08 David Daney - - * testsuite/libffi.call/ffitest.h (ffi_type_mylong): Remove definition. - * testsuite/libffi.call/cls_align_uint16.c (main): Use correct type - specifiers. - * testsuite/libffi.call/nested_struct1.c (main): Ditto. - * testsuite/libffi.call/cls_sint.c (main): Ditto. - * testsuite/libffi.call/nested_struct9.c (main): Ditto. - * testsuite/libffi.call/cls_20byte1.c (main): Ditto. - * testsuite/libffi.call/cls_9byte1.c (main): Ditto. - * testsuite/libffi.call/closure_fn1.c (main): Ditto. - * testsuite/libffi.call/closure_fn3.c (main): Ditto. - * testsuite/libffi.call/return_dbl2.c (main): Ditto. - * testsuite/libffi.call/cls_sshort.c (main): Ditto. - * testsuite/libffi.call/return_fl3.c (main): Ditto. - * testsuite/libffi.call/closure_fn5.c (main): Ditto. - * testsuite/libffi.call/nested_struct.c (main): Ditto. - * testsuite/libffi.call/nested_struct10.c (main): Ditto. - * testsuite/libffi.call/return_ll1.c (main): Ditto. - * testsuite/libffi.call/cls_8byte.c (main): Ditto. - * testsuite/libffi.call/cls_align_uint32.c (main): Ditto. - * testsuite/libffi.call/cls_align_sint16.c (main): Ditto. - * testsuite/libffi.call/cls_20byte.c (main): Ditto. - * testsuite/libffi.call/nested_struct2.c (main): Ditto. - * testsuite/libffi.call/cls_24byte.c (main): Ditto. - * testsuite/libffi.call/nested_struct6.c (main): Ditto. - * testsuite/libffi.call/cls_uint.c (main): Ditto. - * testsuite/libffi.call/cls_12byte.c (main): Ditto. - * testsuite/libffi.call/cls_16byte.c (main): Ditto. - * testsuite/libffi.call/closure_fn0.c (main): Ditto. - * testsuite/libffi.call/cls_9byte2.c (main): Ditto. - * testsuite/libffi.call/closure_fn2.c (main): Ditto. - * testsuite/libffi.call/return_dbl1.c (main): Ditto. - * testsuite/libffi.call/closure_fn4.c (main): Ditto. - * testsuite/libffi.call/closure_fn6.c (main): Ditto. - * testsuite/libffi.call/cls_align_sint32.c (main): Ditto. - -2007-08-07 Andrew Haley - - * src/x86/sysv.S (ffi_closure_raw_SYSV): Fix typo in previous - checkin. - -2007-08-06 Andrew Haley - - PR testsuite/32843 - * src/x86/sysv.S (ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8, - FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32, - FFI_TYPE_SINT32. - -2007-08-02 David Daney - - * testsuite/libffi.call/return_ul.c (main): Define return type as - ffi_arg. Use proper printf conversion specifier. - -2007-07-30 Andrew Haley - - PR testsuite/32843 - * src/x86/ffi.c (ffi_prep_cif_machdep): in x86 case, add code for - signed/unsigned int8/16. - * src/x86/sysv.S (ffi_call_SYSV): Rewrite to: - Use a jump table. - Remove code to pop args from the stack after call. - Special-case signed/unsigned int8/16. - * testsuite/libffi.call/return_sc.c (main): Revert. - -2007-07-26 Richard Guenther - - PR testsuite/32843 - * testsuite/libffi.call/return_sc.c (main): Verify call - result as signed char, not ffi_arg. - -2007-07-16 Rainer Orth - - * configure.ac (i?86-*-solaris2.1[0-9]): Set TARGET to X86_64. - * configure: Regenerate. - -2007-07-11 David Daney - - * src/mips/ffi.c: Don't include sys/cachectl.h. - (ffi_prep_closure_loc): Use __builtin___clear_cache() instead of - cacheflush(). - -2007-05-18 Aurelien Jarno - - * src/arm/ffi.c (ffi_prep_closure_loc): Renamed and ajusted - from (ffi_prep_closure): ... this. - (FFI_INIT_TRAMPOLINE): Adjust. - -2005-12-31 Phil Blundell - - * src/arm/ffi.c (ffi_prep_incoming_args_SYSV, - ffi_closure_SYSV_inner, ffi_prep_closure): New, add closure support. - * src/arm/sysv.S(ffi_closure_SYSV): Likewise. - * src/arm/ffitarget.h (FFI_TRAMPOLINE_SIZE): Likewise. - (FFI_CLOSURES): Enable closure support. - -2007-07-03 Andrew Haley - - * testsuite/libffi.call/cls_multi_ushort.c, - testsuite/libffi.call/cls_align_uint16.c, - testsuite/libffi.call/nested_struct1.c, - testsuite/libffi.call/nested_struct3.c, - testsuite/libffi.call/cls_7_1_byte.c, - testsuite/libffi.call/cls_double.c, - testsuite/libffi.call/nested_struct5.c, - testsuite/libffi.call/nested_struct7.c, - testsuite/libffi.call/cls_sint.c, - testsuite/libffi.call/nested_struct9.c, - testsuite/libffi.call/cls_20byte1.c, - testsuite/libffi.call/cls_multi_sshortchar.c, - testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_3byte2.c, - testsuite/libffi.call/cls_multi_schar.c, - testsuite/libffi.call/cls_multi_uchar.c, - testsuite/libffi.call/cls_19byte.c, - testsuite/libffi.call/cls_9byte1.c, - testsuite/libffi.call/cls_align_float.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/problem1.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/cls_sshort.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/cls_align_double.c, - testsuite/libffi.call/cls_2byte.c, - testsuite/libffi.call/nested_struct.c, - testsuite/libffi.call/nested_struct10.c, - testsuite/libffi.call/cls_4byte.c, - testsuite/libffi.call/cls_6byte.c, - testsuite/libffi.call/cls_8byte.c, - testsuite/libffi.call/cls_multi_sshort.c, - testsuite/libffi.call/cls_align_uint32.c, - testsuite/libffi.call/cls_align_sint16.c, - testsuite/libffi.call/cls_float.c, - testsuite/libffi.call/cls_20byte.c, - testsuite/libffi.call/cls_5_1_byte.c, - testsuite/libffi.call/nested_struct2.c, - testsuite/libffi.call/cls_24byte.c, - testsuite/libffi.call/nested_struct4.c, - testsuite/libffi.call/nested_struct6.c, - testsuite/libffi.call/cls_64byte.c, - testsuite/libffi.call/nested_struct8.c, - testsuite/libffi.call/cls_uint.c, - testsuite/libffi.call/cls_multi_ushortchar.c, - testsuite/libffi.call/cls_schar.c, - testsuite/libffi.call/cls_uchar.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_1_1byte.c, - testsuite/libffi.call/cls_12byte.c, - testsuite/libffi.call/cls_3_1byte.c, - testsuite/libffi.call/cls_3byte1.c, - testsuite/libffi.call/cls_4_1byte.c, - testsuite/libffi.call/cls_6_1_byte.c, - testsuite/libffi.call/cls_16byte.c, - testsuite/libffi.call/cls_18byte.c, - testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/cls_9byte2.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/cls_ushort.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/cls_5byte.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_7byte.c, - testsuite/libffi.call/cls_align_sint32.c, - testsuite/libffi.special/unwindtest_ffi_call.cc, - testsuite/libffi.special/unwindtest.cc: Enable for ARM. - -2007-07-05 H.J. Lu - - * aclocal.m4: Regenerated. - -2007-06-02 Paolo Bonzini - - * configure: Regenerate. - -2007-05-23 Steve Ellcey - - * Makefile.in: Regenerate. - * configure: Regenerate. - * aclocal.m4: Regenerate. - * include/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2007-05-10 Roman Zippel - - * src/m68k/ffi.c (ffi_prep_incoming_args_SYSV, - ffi_closure_SYSV_inner,ffi_prep_closure): New, add closure support. - * src/m68k/sysv.S(ffi_closure_SYSV,ffi_closure_struct_SYSV): Likewise. - * src/m68k/ffitarget.h (FFI_TRAMPOLINE_SIZE): Likewise. - (FFI_CLOSURES): Enable closure support. - -2007-05-10 Roman Zippel - - * configure.ac (HAVE_AS_CFI_PSEUDO_OP): New test. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * src/m68k/sysv.S (CFI_STARTPROC,CFI_ENDPROC, - CFI_OFFSET,CFI_DEF_CFA): New macros. - (ffi_call_SYSV): Add callframe annotation. - -2007-05-10 Roman Zippel - - * src/m68k/ffi.c (ffi_prep_args,ffi_prep_cif_machdep): Fix - numerous test suite failures. - * src/m68k/sysv.S (ffi_call_SYSV): Likewise. - -2007-04-11 Paolo Bonzini - - * Makefile.am (EXTRA_DIST): Bring up to date. - * Makefile.in: Regenerate. - * src/frv/eabi.S: Remove RCS keyword. - -2007-04-06 Richard Henderson - - * configure.ac: Tidy target case. - (HAVE_LONG_DOUBLE): Allow the target to override. - * configure: Regenerate. - * include/ffi.h.in: Don't define ffi_type_foo if - LIBFFI_HIDE_BASIC_TYPES is defined. - (ffi_type_longdouble): If not HAVE_LONG_DOUBLE, define - to ffi_type_double. - * types.c (LIBFFI_HIDE_BASIC_TYPES): Define. - (FFI_TYPEDEF, ffi_type_void): Mark the data const. - (ffi_type_longdouble): Special case for Alpha. Don't define - if long double == double. - - * src/alpha/ffi.c (FFI_TYPE_LONGDOUBLE): Assert unique value. - (ffi_prep_cif_machdep): Handle it as the 128-bit type. - (ffi_call, ffi_closure_osf_inner): Likewise. - (ffi_closure_osf_inner): Likewise. Mark hidden. - (ffi_call_osf, ffi_closure_osf): Mark hidden. - * src/alpha/ffitarget.h (FFI_LAST_ABI): Tidy definition. - * src/alpha/osf.S (ffi_call_osf, ffi_closure_osf): Mark hidden. - (load_table): Handle 128-bit long double. - - * testsuite/libffi.call/float4.c: Add -mieee for alpha. - -2007-04-06 Tom Tromey - - PR libffi/31491: - * README: Fixed bug in example. - -2007-04-03 Jakub Jelinek - - * src/closures.c: Include sys/statfs.h. - (_GNU_SOURCE): Define on Linux. - (FFI_MMAP_EXEC_SELINUX): Define. - (selinux_enabled): New variable. - (selinux_enabled_check): New function. - (is_selinux_enabled): Define. - (dlmmap): Use it. - -2007-03-24 Uros Bizjak - - * testsuite/libffi.call/return_fl2.c (return_fl): Mark as static. - Use 'volatile float sum' to create sum of floats to avoid false - negative due to excess precision on ix86 targets. - (main): Ditto. - -2007-03-08 Alexandre Oliva - - * src/powerpc/ffi.c (flush_icache): Fix left-over from previous - patch. - (ffi_prep_closure_loc): Remove unneeded casts. Add needed ones. - -2007-03-07 Alexandre Oliva - - * include/ffi.h.in (ffi_closure_alloc, ffi_closure_free): New. - (ffi_prep_closure_loc): New. - (ffi_prep_raw_closure_loc): New. - (ffi_prep_java_raw_closure_loc): New. - * src/closures.c: New file. - * src/dlmalloc.c [FFI_MMAP_EXEC_WRIT] (struct malloc_segment): - Replace sflags with exec_offset. - [FFI_MMAP_EXEC_WRIT] (mmap_exec_offset, add_segment_exec_offset, - sub_segment_exec_offset): New macros. - (get_segment_flags, set_segment_flags, check_segment_merge): New - macros. - (is_mmapped_segment, is_extern_segment): Use get_segment_flags. - (add_segment, sys_alloc, create_mspace, create_mspace_with_base, - destroy_mspace): Use new macros. - (sys_alloc): Silence warning. - * Makefile.am (libffi_la_SOURCES): Add src/closures.c. - * Makefile.in: Rebuilt. - * src/prep_cif [FFI_CLOSURES] (ffi_prep_closure): Implement in - terms of ffi_prep_closure_loc. - * src/raw_api.c (ffi_prep_raw_closure_loc): Renamed and adjusted - from... - (ffi_prep_raw_closure): ... this. Re-implement in terms of the - renamed version. - * src/java_raw_api (ffi_prep_java_raw_closure_loc): Renamed and - adjusted from... - (ffi_prep_java_raw_closure): ... this. Re-implement in terms of - the renamed version. - * src/alpha/ffi.c (ffi_prep_closure_loc): Renamed from - (ffi_prep_closure): ... this. - * src/pa/ffi.c: Likewise. - * src/cris/ffi.c: Likewise. Adjust. - * src/frv/ffi.c: Likewise. - * src/ia64/ffi.c: Likewise. - * src/mips/ffi.c: Likewise. - * src/powerpc/ffi_darwin.c: Likewise. - * src/s390/ffi.c: Likewise. - * src/sh/ffi.c: Likewise. - * src/sh64/ffi.c: Likewise. - * src/sparc/ffi.c: Likewise. - * src/x86/ffi64.c: Likewise. - * src/x86/ffi.c: Likewise. - (FFI_INIT_TRAMPOLINE): Adjust. - (ffi_prep_raw_closure_loc): Renamed and adjusted from... - (ffi_prep_raw_closure): ... this. - * src/powerpc/ffi.c (ffi_prep_closure_loc): Renamed from - (ffi_prep_closure): ... this. - (flush_icache): Adjust. - -2007-03-07 Alexandre Oliva - - * src/dlmalloc.c: New file, imported version 2.8.3 of Doug - Lea's malloc. - -2007-03-01 Brooks Moses - - * Makefile.am: Add dummy install-pdf target. - * Makefile.in: Regenerate - -2007-02-13 Andreas Krebbel - - * src/s390/ffi.c (ffi_prep_args, ffi_prep_cif_machdep, - ffi_closure_helper_SYSV): Add long double handling. - -2007-02-02 Jakub Jelinek - - * src/powerpc/linux64.S (ffi_call_LINUX64): Move restore of r2 - immediately after bctrl instruction. - -2007-01-18 Alexandre Oliva - - * Makefile.am (all-recursive, install-recursive, - mostlyclean-recursive, clean-recursive, distclean-recursive, - maintainer-clean-recursive): Add missing targets. - * Makefile.in: Rebuilt. - -2006-12-14 Andreas Tobler - - * configure.ac: Add TARGET for x86_64-*-darwin*. - * Makefile.am (nodist_libffi_la_SOURCES): Add rules for 64-bit sources - for X86_DARWIN. - * src/x86/ffitarget.h: Set trampoline size for x86_64-*-darwin*. - * src/x86/darwin64.S: New file for x86_64-*-darwin* support. - * configure: Regenerate. - * Makefile.in: Regenerate. - * include/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - * testsuite/libffi.special/unwindtest_ffi_call.cc: New test case for - ffi_call only. - -2006-12-13 Andreas Tobler - - * aclocal.m4: Regenerate with aclocal -I .. as written in the - Makefile.am. - -2006-10-31 Geoffrey Keating - - * src/powerpc/ffi_darwin.c (darwin_adjust_aggregate_sizes): New. - (ffi_prep_cif_machdep): Call darwin_adjust_aggregate_sizes for - Darwin. - * testsuite/libffi.call/nested_struct4.c: Remove Darwin XFAIL. - * testsuite/libffi.call/nested_struct6.c: Remove Darwin XFAIL. - -2006-10-10 Paolo Bonzini - Sandro Tolaini - - * configure.ac [i*86-*-darwin*]: Set X86_DARWIN symbol and - conditional. - * configure: Regenerated. - * Makefile.am (nodist_libffi_la_SOURCES) [X86_DARWIN]: New case. - (EXTRA_DIST): Add src/x86/darwin.S. - * Makefile.in: Regenerated. - * include/Makefile.in: Regenerated. - * testsuite/Makefile.in: Regenerated. - - * src/x86/ffi.c (ffi_prep_cif_machdep) [X86_DARWIN]: Treat like - X86_WIN32, and additionally align stack to 16 bytes. - * src/x86/darwin.S: New, based on sysv.S. - * src/prep_cif.c (ffi_prep_cif) [X86_DARWIN]: Align > 8-byte structs. - -2006-09-12 David Daney - - PR libffi/23935 - * include/Makefile.am: Install both ffi.h and ffitarget.h in - $(libdir)/gcc/$(target_alias)/$(gcc_version)/include. - * aclocal.m4: Regenerated for automake 1.9.6. - * Makefile.in: Regenerated. - * include/Makefile.in: Regenerated. - * testsuite/Makefile.in: Regenerated. - -2006-08-17 Andreas Tobler - - * include/ffi_common.h (struct): Revert accidental commit. - -2006-08-15 Andreas Tobler - - * include/ffi_common.h: Remove lint directives. - * include/ffi.h.in: Likewise. - -2006-07-25 Torsten Schoenfeld - - * include/ffi.h.in (ffi_type_ulong, ffi_type_slong): Define correctly - for 32-bit architectures. - * testsuite/libffi.call/return_ul.c: New test case. - -2006-07-19 David Daney - - * testsuite/libffi.call/closure_fn6.c: Remove xfail for mips, - xfail remains for mips64. - -2006-05-23 Carlos O'Donell - - * Makefile.am: Add install-html target. Add install-html to .PHONY - * Makefile.in: Regenerate. - * aclocal.m4: Regenerate. - * include/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2006-05-18 John David Anglin - - * pa/ffi.c (ffi_prep_args_pa32): Load floating point arguments from - stack slot. - -2006-04-22 Andreas Tobler - - * README: Remove notice about 'Crazy Comments'. - * src/debug.c: Remove lint directives. Cleanup white spaces. - * src/java_raw_api.c: Likewise. - * src/prep_cif.c: Likewise. - * src/raw_api.c: Likewise. - * src/ffitest.c: Delete. No longer needed, all test cases migrated - to the testsuite. - * src/arm/ffi.c: Remove lint directives. - * src/m32r/ffi.c: Likewise. - * src/pa/ffi.c: Likewise. - * src/powerpc/ffi.c: Likewise. - * src/powerpc/ffi_darwin.c: Likewise. - * src/sh/ffi.c: Likewise. - * src/sh64/ffi.c: Likewise. - * src/x86/ffi.c: Likewise. - * testsuite/libffi.call/float2.c: Likewise. - * testsuite/libffi.call/promotion.c: Likewise. - * testsuite/libffi.call/struct1.c: Likewise. - -2006-04-13 Andreas Tobler - - * src/pa/hpux32.S: Correct unwind offset calculation for - ffi_closure_pa32. - * src/pa/linux.S: Likewise. - -2006-04-12 James E Wilson - - PR libgcj/26483 - * src/ia64/ffi.c (stf_spill, ldf_fill): Rewrite as macros. - (hfa_type_load): Call stf_spill. - (hfa_type_store): Call ldf_fill. - (ffi_call): Adjust calls to above routines. Add local temps for - macro result. - -2006-04-10 Matthias Klose - - * testsuite/lib/libffi-dg.exp (libffi-init): Recognize multilib - directory names containing underscores. - -2006-04-07 James E Wilson - - * testsuite/libffi.call/float4.c: New testcase. - -2006-04-05 John David Anglin - Andreas Tobler - - * Makefile.am: Add PA_HPUX port. - * Makefile.in: Regenerate. - * include/Makefile.in: Likewise. - * testsuite/Makefile.in: Likewise. - * configure.ac: Add PA_HPUX rules. - * configure: Regenerate. - * src/pa/ffitarget.h: Rename linux target to PA_LINUX. - Add PA_HPUX and PA64_HPUX. - Rename FFI_LINUX ABI to FFI_PA32 ABI. - (FFI_TRAMPOLINE_SIZE): Define for 32-bit HP-UX targets. - (FFI_TYPE_SMALL_STRUCT2): Define. - (FFI_TYPE_SMALL_STRUCT4): Likewise. - (FFI_TYPE_SMALL_STRUCT8): Likewise. - (FFI_TYPE_SMALL_STRUCT3): Redefine. - (FFI_TYPE_SMALL_STRUCT5): Likewise. - (FFI_TYPE_SMALL_STRUCT6): Likewise. - (FFI_TYPE_SMALL_STRUCT7): Likewise. - * src/pa/ffi.c (ROUND_DOWN): Delete. - (fldw, fstw, fldd, fstd): Use '__asm__'. - (ffi_struct_type): Add support for FFI_TYPE_SMALL_STRUCT2, - FFI_TYPE_SMALL_STRUCT4 and FFI_TYPE_SMALL_STRUCT8. - (ffi_prep_args_LINUX): Rename to ffi_prep_args_pa32. Update comment. - Simplify incrementing of stack slot variable. Change type of local - 'n' to unsigned int. - (ffi_size_stack_LINUX): Rename to ffi_size_stack_pa32. Handle long - double on PA_HPUX. - (ffi_prep_cif_machdep): Likewise. - (ffi_call): Likewise. - (ffi_closure_inner_LINUX): Rename to ffi_closure_inner_pa32. Change - return type to ffi_status. Simplify incrementing of stack slot - variable. Only copy floating point argument registers when PA_LINUX - is true. Reformat debug statement. - Add support for FFI_TYPE_SMALL_STRUCT2, FFI_TYPE_SMALL_STRUCT4 and - FFI_TYPE_SMALL_STRUCT8. - (ffi_closure_LINUX): Rename to ffi_closure_pa32. Add 'extern' to - declaration. - (ffi_prep_closure): Make linux trampoline conditional on PA_LINUX. - Add nops to cache flush. Add trampoline for PA_HPUX. - * src/pa/hpux32.S: New file. - * src/pa/linux.S (ffi_call_LINUX): Rename to ffi_call_pa32. Rename - ffi_prep_args_LINUX to ffi_prep_args_pa32. - Localize labels. Add support for 2, 4 and 8-byte small structs. Handle - unaligned destinations in 3, 5, 6 and 7-byte small structs. Order - argument type checks so that common argument types appear first. - (ffi_closure_LINUX): Rename to ffi_closure_pa32. Rename - ffi_closure_inner_LINUX to ffi_closure_inner_pa32. - -2006-03-24 Alan Modra - - * src/powerpc/ffitarget.h (enum ffi_abi): Add FFI_LINUX. Default - for 32-bit using IBM extended double format. Fix FFI_LAST_ABI. - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Handle linux variant of - FFI_TYPE_LONGDOUBLE. - (ffi_prep_args64): Assert using IBM extended double. - (ffi_prep_cif_machdep): Don't munge FFI_TYPE_LONGDOUBLE type. - Handle FFI_LINUX FFI_TYPE_LONGDOUBLE return and args. - (ffi_call): Handle FFI_LINUX. - (ffi_closure_helper_SYSV): Non FFI_LINUX long double return needs - gpr3 return pointer as for struct return. Handle FFI_LINUX - FFI_TYPE_LONGDOUBLE return and args. Don't increment "nf" - unnecessarily. - * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Load both f1 and f2 - for FFI_TYPE_LONGDOUBLE. Move epilogue insns into case table. - Don't use r6 as pointer to results, instead use sp offset. Don't - make a special call to load lr with case table address, instead - use offset from previous call. - * src/powerpc/sysv.S (ffi_call_SYSV): Save long double return. - * src/powerpc/linux64.S (ffi_call_LINUX64): Simplify long double - return. - -2006-03-15 Kaz Kojima - - * src/sh64/ffi.c (ffi_prep_cif_machdep): Handle float arguments - passed with FP registers correctly. - (ffi_closure_helper_SYSV): Likewise. - * src/sh64/sysv.S: Likewise. - -2006-03-01 Andreas Tobler - - * testsuite/libffi.special/unwindtest.cc (closure_test_fn): Mark cif, - args and userdata unused. - (closure_test_fn1): Mark cif and userdata unused. - (main): Remove unused res. - -2006-02-28 Andreas Tobler - - * testsuite/libffi.call/call.exp: Adjust FSF address. Add test runs for - -O2, -O3, -Os and the warning flags -W -Wall. - * testsuite/libffi.special/special.exp: Likewise. - * testsuite/libffi.call/ffitest.h: Add an __UNUSED__ macro to mark - unused parameter unused for gcc or else do nothing. - * testsuite/libffi.special/ffitestcxx.h: Likewise. - * testsuite/libffi.call/cls_12byte.c (cls_struct_12byte_gn): Mark cif - and userdata unused. - * testsuite/libffi.call/cls_16byte.c (cls_struct_16byte_gn): Likewise. - * testsuite/libffi.call/cls_18byte.c (cls_struct_18byte_gn): Likewise. - * testsuite/libffi.call/cls_19byte.c (cls_struct_19byte_gn): Likewise. - * testsuite/libffi.call/cls_1_1byte.c (cls_struct_1_1byte_gn): Likewise. - * testsuite/libffi.call/cls_20byte.c (cls_struct_20byte_gn): Likewise. - * testsuite/libffi.call/cls_20byte1.c (cls_struct_20byte_gn): Likewise. - * testsuite/libffi.call/cls_24byte.c (cls_struct_24byte_gn): Likewise. - * testsuite/libffi.call/cls_2byte.c (cls_struct_2byte_gn): Likewise. - * testsuite/libffi.call/cls_3_1byte.c (cls_struct_3_1byte_gn): Likewise. - * testsuite/libffi.call/cls_3byte1.c (cls_struct_3byte_gn): Likewise. - * testsuite/libffi.call/cls_3byte2.c (cls_struct_3byte_gn1): Likewise. - * testsuite/libffi.call/cls_4_1byte.c (cls_struct_4_1byte_gn): Likewise. - * testsuite/libffi.call/cls_4byte.c (cls_struct_4byte_gn): Likewise. - * testsuite/libffi.call/cls_5_1_byte.c (cls_struct_5byte_gn): Likewise. - * testsuite/libffi.call/cls_5byte.c (cls_struct_5byte_gn): Likewise. - * testsuite/libffi.call/cls_64byte.c (cls_struct_64byte_gn): Likewise. - * testsuite/libffi.call/cls_6_1_byte.c (cls_struct_6byte_gn): Likewise. - * testsuite/libffi.call/cls_6byte.c (cls_struct_6byte_gn): Likewise. - * testsuite/libffi.call/cls_7_1_byte.c (cls_struct_7byte_gn): Likewise. - * testsuite/libffi.call/cls_7byte.c (cls_struct_7byte_gn): Likewise. - * testsuite/libffi.call/cls_8byte.c (cls_struct_8byte_gn): Likewise. - * testsuite/libffi.call/cls_9byte1.c (cls_struct_9byte_gn): Likewise. - * testsuite/libffi.call/cls_9byte2.c (cls_struct_9byte_gn): Likewise. - * testsuite/libffi.call/cls_align_double.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_float.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_longdouble.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_pointer.c (cls_struct_align_fn): Cast - void* to avoid compiler warning. - (main): Likewise. - (cls_struct_align_gn): Mark cif and userdata unused. - * testsuite/libffi.call/cls_align_sint16.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_sint32.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_sint64.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_uint16.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_align_uint32.c (cls_struct_align_gn): - Likewise. - * testsuite/libffi.call/cls_double.c (cls_ret_double_fn): Likewise. - * testsuite/libffi.call/cls_float.c (cls_ret_float_fn): Likewise. - * testsuite/libffi.call/cls_multi_schar.c (test_func_gn): Mark cif and - data unused. - (main): Cast res_call to silence gcc. - * testsuite/libffi.call/cls_multi_sshort.c (test_func_gn): Mark cif and - data unused. - (main): Cast res_call to silence gcc. - * testsuite/libffi.call/cls_multi_sshortchar.c (test_func_gn): Mark cif - and data unused. - (main): Cast res_call to silence gcc. - * testsuite/libffi.call/cls_multi_uchar.c (test_func_gn): Mark cif and - data unused. - (main): Cast res_call to silence gcc. - * testsuite/libffi.call/cls_multi_ushort.c (test_func_gn): Mark cif and - data unused. - (main): Cast res_call to silence gcc. - * testsuite/libffi.call/cls_multi_ushortchar.c (test_func_gn): Mark cif - and data unused. - (main): Cast res_call to silence gcc. - * testsuite/libffi.call/cls_schar.c (cls_ret_schar_fn): Mark cif and - userdata unused. - (cls_ret_schar_fn): Cast printf parameter to silence gcc. - * testsuite/libffi.call/cls_sint.c (cls_ret_sint_fn): Mark cif and - userdata unused. - (cls_ret_sint_fn): Cast printf parameter to silence gcc. - * testsuite/libffi.call/cls_sshort.c (cls_ret_sshort_fn): Mark cif and - userdata unused. - (cls_ret_sshort_fn): Cast printf parameter to silence gcc. - * testsuite/libffi.call/cls_uchar.c (cls_ret_uchar_fn): Mark cif and - userdata unused. - (cls_ret_uchar_fn): Cast printf parameter to silence gcc. - * testsuite/libffi.call/cls_uint.c (cls_ret_uint_fn): Mark cif and - userdata unused. - (cls_ret_uint_fn): Cast printf parameter to silence gcc. - * testsuite/libffi.call/cls_ulonglong.c (cls_ret_ulonglong_fn): Mark cif - and userdata unused. - * testsuite/libffi.call/cls_ushort.c (cls_ret_ushort_fn): Mark cif and - userdata unused. - (cls_ret_ushort_fn): Cast printf parameter to silence gcc. - * testsuite/libffi.call/float.c (floating): Remove unused parameter e. - * testsuite/libffi.call/float1.c (main): Remove unused variable i. - Cleanup white spaces. - * testsuite/libffi.call/negint.c (checking): Remove unused variable i. - * testsuite/libffi.call/nested_struct.c (cls_struct_combined_gn): Mark - cif and userdata unused. - * testsuite/libffi.call/nested_struct1.c (cls_struct_combined_gn): - Likewise. - * testsuite/libffi.call/nested_struct10.c (B_gn): Likewise. - * testsuite/libffi.call/nested_struct2.c (B_fn): Adjust printf - formatters to silence gcc. - (B_gn): Mark cif and userdata unused. - * testsuite/libffi.call/nested_struct3.c (B_gn): Mark cif and userdata - unused. - * testsuite/libffi.call/nested_struct4.c: Mention related PR. - (B_gn): Mark cif and userdata unused. - * testsuite/libffi.call/nested_struct5.c (B_gn): Mark cif and userdata - unused. - * testsuite/libffi.call/nested_struct6.c: Mention related PR. - (B_gn): Mark cif and userdata unused. - * testsuite/libffi.call/nested_struct7.c (B_gn): Mark cif and userdata - unused. - * testsuite/libffi.call/nested_struct8.c (B_gn): Likewise. - * testsuite/libffi.call/nested_struct9.c (B_gn): Likewise. - * testsuite/libffi.call/problem1.c (stub): Likewise. - * testsuite/libffi.call/pyobjc-tc.c (main): Cast the result to silence - gcc. - * testsuite/libffi.call/return_fl2.c (return_fl): Add the note mentioned - in the last commit for this test case in the test case itself. - * testsuite/libffi.call/closure_fn0.c (closure_test_fn0): Mark cif as - unused. - * testsuite/libffi.call/closure_fn1.c (closure_test_fn1): Likewise. - * testsuite/libffi.call/closure_fn2.c (closure_test_fn2): Likewise. - * testsuite/libffi.call/closure_fn3.c (closure_test_fn3): Likewise. - * testsuite/libffi.call/closure_fn4.c (closure_test_fn0): Likewise. - * testsuite/libffi.call/closure_fn5.c (closure_test_fn5): Likewise. - * testsuite/libffi.call/closure_fn6.c (closure_test_fn0): Likewise. - -2006-02-22 Kaz Kojima - - * src/sh/sysv.S: Fix register numbers in the FDE for - ffi_closure_SYSV. - -2006-02-20 Andreas Tobler - - * testsuite/libffi.call/return_fl2.c (return_fl): Remove static - declaration to avoid a false negative on ix86. See PR323. - -2006-02-18 Kaz Kojima - - * src/sh/ffi.c (ffi_closure_helper_SYSV): Remove unused variable - and cast integer to void * if needed. Update the pointer to - the FP register saved area correctly. - -2006-02-17 Andreas Tobler - - * testsuite/libffi.call/nested_struct6.c: XFAIL this test until PR25630 - is fixed. - * testsuite/libffi.call/nested_struct4.c: Likewise. - -2006-02-16 Andreas Tobler - - * testsuite/libffi.call/return_dbl.c: New test case. - * testsuite/libffi.call/return_dbl1.c: Likewise. - * testsuite/libffi.call/return_dbl2.c: Likewise. - * testsuite/libffi.call/return_fl.c: Likewise. - * testsuite/libffi.call/return_fl1.c: Likewise. - * testsuite/libffi.call/return_fl2.c: Likewise. - * testsuite/libffi.call/return_fl3.c: Likewise. - * testsuite/libffi.call/closure_fn6.c: Likewise. - - * testsuite/libffi.call/nested_struct2.c: Remove ffi_type_mylong - definition. - * testsuite/libffi.call/ffitest.h: Add ffi_type_mylong definition - here to be used by other test cases too. - - * testsuite/libffi.call/nested_struct10.c: New test case. - * testsuite/libffi.call/nested_struct9.c: Likewise. - * testsuite/libffi.call/nested_struct8.c: Likewise. - * testsuite/libffi.call/nested_struct7.c: Likewise. - * testsuite/libffi.call/nested_struct6.c: Likewise. - * testsuite/libffi.call/nested_struct5.c: Likewise. - * testsuite/libffi.call/nested_struct4.c: Likewise. - -2006-01-21 Andreas Tobler - - * configure.ac: Enable libffi for sparc64-*-freebsd*. - * configure: Rebuilt. - -2006-01-18 Jakub Jelinek - - * src/powerpc/sysv.S (smst_two_register): Don't call __ashldi3, - instead do the shifting inline. - * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Don't compute %r5 - shift count unconditionally. Simplify load sequences for 1, 2, 3, 4 - and 8 byte structs, for the remaining struct sizes don't call - __lshrdi3, instead do the shifting inline. - -2005-12-07 Thiemo Seufer - - * src/mips/ffitarget.h: Remove obsolete sgidefs.h include. Add - missing parentheses. - * src/mips/o32.S (ffi_call_O32): Code formatting. Define - and use A3_OFF, FP_OFF, RA_OFF. Micro-optimizations. - (ffi_closure_O32): Likewise, but with newly defined A3_OFF2, - A2_OFF2, A1_OFF2, A0_OFF2, RA_OFF2, FP_OFF2, S0_OFF2, GP_OFF2, - V1_OFF2, V0_OFF2, FA_1_1_OFF2, FA_1_0_OFF2, FA_0_1_OFF2, - FA_0_0_OFF2. - * src/mips/ffi.c (ffi_prep_args): Code formatting. Fix - endianness bugs. - (ffi_prep_closure): Improve trampoline instruction scheduling. - (ffi_closure_mips_inner_O32): Fix endianness bugs. - -2005-12-03 Alan Modra - - * src/powerpc/ffi.c: Formatting. - (ffi_prep_args_SYSV): Avoid possible aliasing problems by using unions. - (ffi_prep_args64): Likewise. - -2005-09-30 Geoffrey Keating - - * testsuite/lib/libffi-dg.exp (libffi_target_compile): For - darwin, use -shared-libgcc not -lgcc_s, and explain why. - -2005-09-26 Tom Tromey - - * testsuite/libffi.call/float1.c (value_type): New typedef. - (CANARY): New define. - (main): Check for result buffer overflow. - * src/powerpc/linux64.S: Handle linux64 long double returns. - * src/powerpc/ffi.c (FLAG_RETURNS_128BITS): New constant. - (ffi_prep_cif_machdep): Handle linux64 long double returns. - -2005-08-25 Alan Modra - - PR target/23404 - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Correct placement of stack - homed fp args. - (ffi_status ffi_prep_cif_machdep): Correct stack sizing for same. - -2005-08-11 Jakub Jelinek - - * configure.ac (HAVE_HIDDEN_VISIBILITY_ATTRIBUTE): New test. - (AH_BOTTOM): Add FFI_HIDDEN definition. - * configure: Rebuilt. - * fficonfig.h.in: Rebuilt. - * src/powerpc/ffi.c (hidden): Remove. - (ffi_closure_LINUX64, ffi_prep_args64, ffi_call_LINUX64, - ffi_closure_helper_LINUX64): Use FFI_HIDDEN instead of hidden. - * src/powerpc/linux64_closure.S (ffi_closure_LINUX64, - .ffi_closure_LINUX64): Use FFI_HIDDEN instead of .hidden. - * src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV): Remove, - add FFI_HIDDEN to its prototype. - (ffi_closure_SYSV_inner): New. - * src/x86/sysv.S (ffi_closure_SYSV, ffi_closure_raw_SYSV): New. - * src/x86/win32.S (ffi_closure_SYSV, ffi_closure_raw_SYSV): New. - -2005-08-10 Alfred M. Szmidt - - PR libffi/21819: - * configure: Rebuilt. - * configure.ac: Handle i*86-*-gnu*. - -2005-08-09 Jakub Jelinek - - * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Use - DW_CFA_offset_extended_sf rather than - DW_CFA_GNU_negative_offset_extended. - * src/powerpc/sysv.S (ffi_call_SYSV): Likewise. - -2005-07-22 SUGIOKA Toshinobu - - * src/sh/sysv.S (ffi_call_SYSV): Stop argument popping correctly - on sh3. - (ffi_closure_SYSV): Change the stack layout for sh3 struct argument. - * src/sh/ffi.c (ffi_prep_args): Fix sh3 argument copy, when it is - partially on register. - (ffi_closure_helper_SYSV): Likewise. - (ffi_prep_cif_machdep): Don't set too many cif->flags. - -2005-07-20 Kaz Kojima - - * src/sh/ffi.c (ffi_call): Handle small structures correctly. - Remove empty line. - * src/sh64/ffi.c (simple_type): Remove. - (return_type): Handle small structures correctly. - (ffi_prep_args): Likewise. - (ffi_call): Likewise. - (ffi_closure_helper_SYSV): Likewise. - * src/sh64/sysv.S (ffi_call_SYSV): Handle 1, 2 and 4-byte return. - Emit position independent code if PIC and remove wrong datalabel - prefixes from EH data. - -2005-07-19 Andreas Tobler - - * Makefile.am (nodist_libffi_la_SOURCES): Add POWERPC_FREEBSD. - * Makefile.in: Regenerate. - * include/Makefile.in: Likewise. - * testsuite/Makefile.in: Likewise. - * configure.ac: Add POWERPC_FREEBSD rules. - * configure: Regenerate. - * src/powerpc/ffitarget.h: Add POWERPC_FREEBSD rules. - (FFI_SYSV_TYPE_SMALL_STRUCT): Define. - * src/powerpc/ffi.c: Add flags to handle small structure returns - in ffi_call_SYSV. - (ffi_prep_cif_machdep): Handle small structures for SYSV 4 ABI. - Aka FFI_SYSV. - (ffi_closure_helper_SYSV): Likewise. - * src/powerpc/ppc_closure.S: Add return types for small structures. - * src/powerpc/sysv.S: Add bits to handle small structures for - final SYSV 4 ABI. - -2005-07-10 Andreas Tobler - - * testsuite/libffi.call/cls_5_1_byte.c: New test file. - * testsuite/libffi.call/cls_6_1_byte.c: Likewise. - * testsuite/libffi.call/cls_7_1_byte.c: Likewise. - -2005-07-05 Randolph Chung - - * src/pa/ffi.c (ffi_struct_type): Rename FFI_TYPE_SMALL_STRUCT1 - as FFI_TYPE_SMALL_STRUCT3. Break out handling for 5-7 byte - structures. Kill compilation warnings. - (ffi_closure_inner_LINUX): Print return values as hex in debug - message. Rename FFI_TYPE_SMALL_STRUCT1 as FFI_TYPE_SMALL_STRUCT3. - Properly handle 5-7 byte structure returns. - * src/pa/ffitarget.h (FFI_TYPE_SMALL_STRUCT1) - (FFI_TYPE_SMALL_STRUCT2): Remove. - (FFI_TYPE_SMALL_STRUCT3, FFI_TYPE_SMALL_STRUCT5) - (FFI_TYPE_SMALL_STRUCT6, FFI_TYPE_SMALL_STRUCT7): Define. - * src/pa/linux.S: Mark source file as using PA1.1 assembly. - (checksmst1, checksmst2): Remove. - (checksmst3): Optimize handling of 3-byte struct returns. - (checksmst567): Properly handle 5-7 byte struct returns. - -2005-06-15 Rainer Orth - - PR libgcj/21943 - * src/mips/n32.S: Enforce PIC code. - * src/mips/o32.S: Likewise. - -2005-06-15 Rainer Orth - - * configure.ac: Treat i*86-*-solaris2.10 and up as X86_64. - * configure: Regenerate. - -2005-06-01 Alan Modra - - * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Don't use JUMPTARGET - to call ffi_closure_helper_SYSV. Append @local instead. - * src/powerpc/sysv.S (ffi_call_SYSV): Likewise for ffi_prep_args_SYSV. - -2005-05-17 Kelley Cook - - * configure.ac: Use AC_C_BIGENDIAN instead of AC_C_BIGENDIAN_CROSS. - Use AC_CHECK_SIZEOF instead of AC_COMPILE_CHECK_SIZEOF. - * Makefile.am (ACLOCAL_AMFLAGS): Remove -I ../config. - * aclocal.m4, configure, fficonfig.h.in, Makefile.in, - include/Makefile.in, testsuite/Makefile.in: Regenerate. - -2005-05-09 Mike Stump - - * configure: Regenerate. - -2005-05-08 Richard Henderson - - PR libffi/21285 - * src/alpha/osf.S: Update unwind into to match code. - -2005-05-04 Andreas Degert - Richard Henderson - - * src/x86/ffi64.c (ffi_prep_cif_machdep): Save sse-used flag in - bit 11 of flags. - (ffi_call): Mask return type field. Pass ssecount to ffi_call_unix64. - (ffi_prep_closure): Set carry bit if sse-used flag set. - * src/x86/unix64.S (ffi_call_unix64): Add ssecount argument. - Only load sse registers if ssecount non-zero. - (ffi_closure_unix64): Only save sse registers if carry set on entry. - -2005-04-29 Ralf Corsepius - - * configure.ac: Add i*86-*-rtems*, sparc*-*-rtems*, - powerpc-*rtems*, arm*-*-rtems*, sh-*-rtems*. - * configure: Regenerate. - -2005-04-20 Hans-Peter Nilsson - - * testsuite/lib/libffi-dg.exp (libffi-dg-test-1): In regsub use, - have Tcl8.3-compatible intermediate variable. - -2005-04-18 Simon Posnjak - Hans-Peter Nilsson - - * Makefile.am: Add CRIS support. - * configure.ac: Likewise. - * Makefile.in, configure, testsuite/Makefile.in, - include/Makefile.in: Regenerate. - * src/cris: New directory. - * src/cris/ffi.c, src/cris/sysv.S, src/cris/ffitarget.h: New files. - * src/prep_cif.c (ffi_prep_cif): Wrap in #ifndef __CRIS__. - - * testsuite/lib/libffi-dg.exp (libffi-dg-test-1): Replace \n with - \r?\n in output tests. - -2005-04-12 Mike Stump - - * configure: Regenerate. - -2005-03-30 Hans Boehm - - * src/ia64/ffitarget.h (ffi_arg): Use long long instead of DI. - -2005-03-30 Steve Ellcey - - * src/ia64/ffitarget.h (ffi_arg) ADD DI attribute. - (ffi_sarg) Ditto. - * src/ia64/unix.S (ffi_closure_unix): Extend gp - to 64 bits in ILP32 mode. - Load 64 bits even for short data. - -2005-03-23 Mike Stump - - * src/powerpc/darwin.S: Update for -m64 multilib. - * src/powerpc/darwin_closure.S: Likewise. - -2005-03-21 Zack Weinberg - - * configure.ac: Do not invoke TL_AC_GCC_VERSION. - Do not set tool_include_dir. - * aclocal.m4, configure, Makefile.in, testsuite/Makefile.in: - Regenerate. - * include/Makefile.am: Set gcc_version and toollibffidir. - * include/Makefile.in: Regenerate. - -2005-02-22 Andrew Haley - - * src/powerpc/ffi.c (ffi_prep_cif_machdep): Bump alignment to - odd-numbered register pairs for 64-bit integer types. - -2005-02-23 Andreas Tobler - - PR libffi/20104 - * testsuite/libffi.call/return_ll1.c: New test case. - -2005-02-11 Janis Johnson - - * testsuite/libffi.call/cls_align_longdouble.c: Remove dg-options. - * testsuite/libffi.call/float.c: Ditto. - * testsuite/libffi.call/float2.c: Ditto. - * testsuite/libffi.call/float3.c: Ditto. - -2005-02-08 Andreas Tobler - - * src/frv/ffitarget.h: Remove PPC stuff which does not belong to frv. - -2005-01-12 Eric Botcazou - - * testsuite/libffi.special/special.exp (cxx_options): Add - -shared-libgcc. - -2004-12-31 Richard Henderson - - * src/types.c (FFI_AGGREGATE_TYPEDEF): Remove. - (FFI_TYPEDEF): Rename from FFI_INTEGRAL_TYPEDEF. Replace size and - offset parameters with a type parameter; deduce size and structure - alignment. Update all users. - -2004-12-31 Richard Henderson - - * src/types.c (FFI_TYPE_POINTER): Define with sizeof. - (FFI_TYPE_LONGDOUBLE): Fix for ia64. - * src/ia64/ffitarget.h (struct ffi_ia64_trampoline_struct): Move - into ffi_prep_closure. - * src/ia64/ia64_flags.h, src/ia64/ffi.c, src/ia64/unix.S: Rewrite - from scratch. - -2004-12-27 Richard Henderson - - * src/x86/unix64.S: Fix typo in unwind info. - -2004-12-25 Richard Henderson - - * src/x86/ffi64.c (struct register_args): Rename from stackLayout. - (enum x86_64_reg_class): Add X86_64_COMPLEX_X87_CLASS. - (merge_classes): Check for it. - (SSE_CLASS_P): New. - (classify_argument): Pass byte_offset by value; perform all updates - inside struct case. - (examine_argument): Add classes argument; handle - X86_64_COMPLEX_X87_CLASS. - (ffi_prep_args): Merge into ... - (ffi_call): ... here. Share stack frame with ffi_call_unix64. - (ffi_prep_cif_machdep): Setup cif->flags for proper structure return. - (ffi_fill_return_value): Remove. - (ffi_prep_closure): Remove dead assert. - (ffi_closure_unix64_inner): Rename from ffi_closure_UNIX64_inner. - Rewrite to use struct register_args instead of va_list. Create - flags for handling structure returns. - * src/x86/unix64.S: Remove dead strings. - (ffi_call_unix64): Rename from ffi_call_UNIX64. Rewrite to share - stack frame with ffi_call. Handle structure returns properly. - (float2sse, floatfloat2sse, double2sse): Remove. - (sse2float, sse2double, sse2floatfloat): Remove. - (ffi_closure_unix64): Rename from ffi_closure_UNIX64. Rewrite - to handle structure returns properly. - -2004-12-08 David Edelsohn - - * Makefile.am (AM_MAKEFLAGS): Remove duplicate LIBCFLAGS and - PICFLAG. - * Makefile.in: Regenerated. - -2004-12-02 Richard Sandiford - - * configure.ac: Use TL_AC_GCC_VERSION to set gcc_version. - * configure, aclocal.m4, Makefile.in: Regenerate. - * include/Makefile.in, testsuite/Makefile.in: Regenerate. - -2004-11-29 Kelley Cook - - * configure: Regenerate for libtool change. - -2004-11-25 Kelley Cook - - * configure: Regenerate for libtool reversion. - -2004-11-24 Kelley Cook - - * configure: Regenerate for libtool change. - -2004-11-23 John David Anglin - - * testsuite/lib/libffi-dg.exp: Use new procs in target-libpath.exp. - -2004-11-23 Richard Sandiford - - * src/mips/o32.S (ffi_call_O32, ffi_closure_O32): Use jalr instead - of jal. Use an absolute encoding for the frame information. - -2004-11-23 Kelley Cook - - * Makefile.am: Remove no-dependencies. Add ACLOCAL_AMFLAGS. - * acinclude.m4: Delete logic for sincludes. - * aclocal.m4, Makefile.in, configure: Regenerate. - * include/Makefile: Likewise. - * testsuite/Makefile: Likewise. - -2004-11-22 Eric Botcazou - - * src/sparc/ffi.c (ffi_prep_closure): Align doubles and 64-bit integers - on a 8-byte boundary. - * src/sparc/v8.S (ffi_closure_v8): Reserve frame space for arguments. - -2004-10-27 Richard Earnshaw - - * src/arm/ffi.c (ffi_prep_cif_machdep): Handle functions that return - long long values. Round stack allocation to a multiple of 8 bytes - for ATPCS compatibility. - * src/arm/sysv.S (ffi_call_SYSV): Rework to avoid use of APCS register - names. Handle returning long long types. Add Thumb and interworking - support. Improve soft-float code. - -2004-10-27 Richard Earnshaw - - * testsuite/lib/libffi-db.exp (load_gcc_lib): New function. - (libffi_exit): New function. - (libffi_init): Build the testglue wrapper if needed. - -2004-10-25 Eric Botcazou - - PR other/18138 - * testsuite/lib/libffi-dg.exp: Accept more than one multilib libgcc. - -2004-10-25 Kazuhiro Inaoka - - * src/m32r/libffitarget.h (FFI_CLOSURES): Set to 0. - -2004-10-20 Kaz Kojima - - * src/sh/sysv.S (ffi_call_SYSV): Don't align for double data. - * testsuite/libffi.call/float3.c: New test case. - -2004-10-18 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_closure): Set T bit in trampoline for - the function returning a structure pointed with R2. - * src/sh/sysv.S (ffi_closure_SYSV): Use R2 as the pointer to - the structure return value if T bit set. Emit position - independent code and EH data if PIC. - -2004-10-13 Kazuhiro Inaoka - - * Makefile.am: Add m32r support. - * configure.ac: Likewise. - * Makefile.in: Regenerate. - * confiugre: Regenerate. - * src/types.c: Add m32r port to FFI_INTERNAL_TYPEDEF - (uint64, sint64, double, longdouble) - * src/m32r: New directory. - * src/m32r/ffi.c: New file. - * src/m32r/sysv.S: Likewise. - * src/m32r/ffitarget.h: Likewise. - -2004-10-02 Kaz Kojima - - * testsuite/libffi.call/negint.c: New test case. - -2004-09-14 H.J. Lu - - PR libgcj/17465 - * testsuite/lib/libffi-dg.exp: Don't use global ld_library_path. - Set up LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH, - LD_LIBRARY64_PATH, LD_LIBRARY_PATH_32, LD_LIBRARY_PATH_64 and - DYLD_LIBRARY_PATH. - -2004-09-05 Andreas Tobler - - * testsuite/libffi.call/many_win32.c: Remove whitespaces. - * testsuite/libffi.call/promotion.c: Likewise. - * testsuite/libffi.call/return_ll.c: Remove unused var. Cleanup - whitespaces. - * testsuite/libffi.call/return_sc.c: Likewise. - * testsuite/libffi.call/return_uc.c: Likewise. - -2004-09-05 Andreas Tobler - - * src/powerpc/darwin.S: Fix comments and identation. - * src/powerpc/darwin_closure.S: Likewise. - -2004-09-02 Andreas Tobler - - * src/powerpc/ffi_darwin.c: Add flag for longdouble return values. - (ffi_prep_args): Handle longdouble arguments. - (ffi_prep_cif_machdep): Set flags for longdouble. Calculate space for - longdouble. - (ffi_closure_helper_DARWIN): Add closure handling for longdouble. - * src/powerpc/darwin.S (_ffi_call_DARWIN): Add handling of longdouble - values. - * src/powerpc/darwin_closure.S (_ffi_closure_ASM): Likewise. - * src/types.c: Defined longdouble size and alignment for darwin. - -2004-09-02 Andreas Tobler - - * src/powerpc/aix.S: Remove whitespaces. - * src/powerpc/aix_closure.S: Likewise. - * src/powerpc/asm.h: Likewise. - * src/powerpc/ffi.c: Likewise. - * src/powerpc/ffitarget.h: Likewise. - * src/powerpc/linux64.S: Likewise. - * src/powerpc/linux64_closure.S: Likewise. - * src/powerpc/ppc_closure.S: Likewise. - * src/powerpc/sysv.S: Likewise. - -2004-08-30 Anthony Green - - * Makefile.am: Add frv support. - * Makefile.in, testsuite/Makefile.in: Rebuilt. - * configure.ac: Read configure.host. - * configure.in: Read configure.host. - * configure.host: New file. frv-elf needs libgloss. - * include/ffi.h.in: Force ffi_closure to have a nice big (8) - alignment. This is needed to frv and shouldn't harm the others. - * include/ffi_common.h (ALIGN_DOWN): New macro. - * src/frv/ffi.c, src/frv/ffitarget.h, src/frv/eabi.S: New files. - -2004-08-24 David Daney - - * testsuite/libffi.call/closure_fn0.c: Xfail mips64* instead of mips*. - * testsuite/libffi.call/closure_fn1.c: Likewise. - * testsuite/libffi.call/closure_fn2.c Likewise. - * testsuite/libffi.call/closure_fn3.c: Likewise. - * testsuite/libffi.call/closure_fn4.c: Likewise. - * testsuite/libffi.call/closure_fn5.c: Likewise. - * testsuite/libffi.call/cls_18byte.c: Likewise. - * testsuite/libffi.call/cls_19byte.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_20byte1.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_64byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_9byte1.c: Likewise. - * testsuite/libffi.call/cls_9byte2.c: Likewise. - * testsuite/libffi.call/cls_align_double.c: Likewise. - * testsuite/libffi.call/cls_align_float.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble.c: Likewise. - * testsuite/libffi.call/cls_align_pointer.c: Likewise. - * testsuite/libffi.call/cls_align_sint16.c: Likewise. - * testsuite/libffi.call/cls_align_sint32.c: Likewise. - * testsuite/libffi.call/cls_align_sint64.c: Likewise. - * testsuite/libffi.call/cls_align_uint16.c: Likewise. - * testsuite/libffi.call/cls_align_uint32.c: Likewise. - * testsuite/libffi.call/cls_align_uint64.c: Likewise. - * testsuite/libffi.call/cls_double.c: Likewise. - * testsuite/libffi.call/cls_float.c: Likewise. - * testsuite/libffi.call/cls_multi_schar.c: Likewise. - * testsuite/libffi.call/cls_multi_sshort.c: Likewise. - * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise. - * testsuite/libffi.call/cls_multi_uchar.c: Likewise. - * testsuite/libffi.call/cls_multi_ushort.c: Likewise. - * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise. - * testsuite/libffi.call/cls_schar.c: Likewise. - * testsuite/libffi.call/cls_sint.c: Likewise. - * testsuite/libffi.call/cls_sshort.c: Likewise. - * testsuite/libffi.call/cls_uchar.c: Likewise. - * testsuite/libffi.call/cls_uint.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/cls_ushort.c: Likewise. - * testsuite/libffi.call/nested_struct.c: Likewise. - * testsuite/libffi.call/nested_struct1.c: Likewise. - * testsuite/libffi.call/nested_struct2.c: Likewise. - * testsuite/libffi.call/nested_struct3.c: Likewise. - * testsuite/libffi.call/problem1.c: Likewise. - * testsuite/libffi.special/unwindtest.cc: Likewise. - * testsuite/libffi.call/cls_12byte.c: Likewise and set return value - to zero. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - -2004-08-23 David Daney - - PR libgcj/13141 - * src/mips/ffitarget.h (FFI_O32_SOFT_FLOAT): New ABI. - * src/mips/ffi.c (ffi_prep_args): Fix alignment calculation. - (ffi_prep_cif_machdep): Handle FFI_O32_SOFT_FLOAT floating point - parameters and return types. - (ffi_call): Handle FFI_O32_SOFT_FLOAT ABI. - (ffi_prep_closure): Ditto. - (ffi_closure_mips_inner_O32): Handle FFI_O32_SOFT_FLOAT ABI, fix - alignment calculations. - * src/mips/o32.S (ffi_closure_O32): Don't use floating point - instructions if FFI_O32_SOFT_FLOAT, make stack frame ABI compliant. - -2004-08-14 Casey Marshall - - * src/mips/ffi.c (ffi_pref_cif_machdep): set `cif->flags' to - contain `FFI_TYPE_UINT64' as return type for any 64-bit - integer (O32 ABI only). - (ffi_prep_closure): new function. - (ffi_closure_mips_inner_O32): new function. - * src/mips/ffitarget.h: Define `FFI_CLOSURES' and - `FFI_TRAMPOLINE_SIZE' appropriately if the ABI is o32. - * src/mips/o32.S (ffi_call_O32): add labels for .eh_frame. Return - 64 bit integers correctly. - (ffi_closure_O32): new function. - Added DWARF-2 unwind info for both functions. - -2004-08-10 Andrew Haley - - * src/x86/ffi64.c (ffi_prep_args ): 8-align all stack arguments. - -2004-08-01 Robert Millan - - * configure.ac: Detect knetbsd-gnu and kfreebsd-gnu. - * configure: Regenerate. - -2004-07-30 Maciej W. Rozycki - - * acinclude.m4 (AC_FUNC_MMAP_BLACKLIST): Check for - and mmap() explicitly instead of relying on preset autoconf cache - variables. - * aclocal.m4: Regenerate. - * configure: Regenerate. - -2004-07-11 Ulrich Weigand - - * src/s390/ffi.c (ffi_prep_args): Fix C aliasing violation. - (ffi_check_float_struct): Remove unused prototype. - -2004-06-30 Geoffrey Keating - - * src/powerpc/ffi_darwin.c (flush_icache): ';' is a comment - character on Darwin, use '\n\t' instead. - -2004-06-26 Matthias Klose - - * libtool-version: Fix typo in revision/age. - -2004-06-17 Matthias Klose - - * libtool-version: New. - * Makefile.am (libffi_la_LDFLAGS): Use -version-info for soname. - * Makefile.in: Regenerate. - -2004-06-15 Paolo Bonzini - - * Makefile.am: Remove useless multilib rules. - * Makefile.in: Regenerate. - * aclocal.m4: Regenerate with automake 1.8.5. - * configure.ac: Remove useless multilib configury. - * configure: Regenerate. - -2004-06-15 Paolo Bonzini - - * .cvsignore: New file. - -2004-06-10 Jakub Jelinek - - * src/ia64/unix.S (ffi_call_unix): Insert group barrier break - fp_done. - (ffi_closure_UNIX): Fix f14/f15 adjustment if FLOAT_SZ is ever - changed from 8. - -2004-06-06 Sean McNeil - - * configure.ac: Add x86_64-*-freebsd* support. - * configure: Regenerate. - -2004-04-26 Joe Buck - - Bug 15093 - * configure.ac: Test for existence of mmap and sys/mman.h before - checking blacklist. Fix suggested by Jim Wilson. - * configure: Regenerate. - -2004-04-26 Matt Austern - - * src/powerpc/darwin.S: Go through a non-lazy pointer for initial - FDE location. - * src/powerpc/darwin_closure.S: Likewise. - -2004-04-24 Andreas Tobler - - * testsuite/libffi.call/cls_multi_schar.c (main): Fix initialization - error. Reported by Thomas Heller . - * testsuite/libffi.call/cls_multi_sshort.c (main): Likewise. - * testsuite/libffi.call/cls_multi_ushort.c (main): Likewise. - -2004-03-20 Matthias Klose - - * src/pa/linux.S: Fix typo. - -2004-03-19 Matthias Klose - - * Makefile.am: Update. - * Makefile.in: Regenerate. - * src/pa/ffi.h.in: Remove. - * src/pa/ffitarget.h: New file. - -2004-02-10 Randolph Chung - - * Makefile.am: Add PA support. - * Makefile.in: Regenerate. - * include/Makefile.in: Regenerate. - * configure.ac: Add PA target. - * configure: Regenerate. - * src/pa/ffi.c: New file. - * src/pa/ffi.h.in: Add PA support. - * src/pa/linux.S: New file. - * prep_cif.c: Add PA support. - -2004-03-16 Hosaka Yuji - - * src/types.c: Fix alignment size of X86_WIN32 case int64 and - double. - * src/x86/ffi.c (ffi_prep_args): Replace ecif->cif->rtype->type - with ecif->cif->flags. - (ffi_call, ffi_prep_incoming_args_SYSV): Replace cif->rtype->type - with cif->flags. - (ffi_prep_cif_machdep): Add X86_WIN32 struct case. - (ffi_closure_SYSV): Add 1 or 2-bytes struct case for X86_WIN32. - * src/x86/win32.S (retstruct1b, retstruct2b, sc_retstruct1b, - sc_retstruct2b): Add for 1 or 2-bytes struct case. - -2004-03-15 Kelley Cook - - * configure.in: Rename file to ... - * configure.ac: ... this. - * fficonfig.h.in: Regenerate. - * Makefile.in: Regenerate. - * include/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2004-03-12 Matt Austern - - * src/powerpc/darwin.S: Fix EH information so it corresponds to - changes in EH format resulting from addition of linkonce support. - * src/powerpc/darwin_closure.S: Likewise. - -2004-03-11 Andreas Tobler - Paolo Bonzini - - * Makefile.am (AUTOMAKE_OPTIONS): Set them. - Remove VPATH. Remove rules for object files. Remove multilib support. - (AM_CCASFLAGS): Add. - * configure.in (AC_CONFIG_HEADERS): Relace AM_CONFIG_HEADER. - (AC_PREREQ): Bump version to 2.59. - (AC_INIT): Fill with version info and bug address. - (ORIGINAL_LD_FOR_MULTILIBS): Remove. - (AM_ENABLE_MULTILIB): Use this instead of AC_ARG_ENABLE. - De-precious CC so that the right flags are passed down to multilibs. - (AC_MSG_ERROR): Replace obsolete macro AC_ERROR. - (AC_CONFIG_FILES): Replace obsolete macro AC_LINK_FILES. - (AC_OUTPUT): Reorganize the output with AC_CONFIG_COMMANDS. - * configure: Rebuilt. - * aclocal.m4: Likewise. - * Makefile.in, include/Makefile.in, testsuite/Makefile.in: Likewise. - * fficonfig.h.in: Likewise. - -2004-03-11 Andreas Schwab - - * src/ia64/ffi.c (ffi_prep_incoming_args_UNIX): Get floating point - arguments from fp registers only for the first 8 parameter slots. - Don't convert a float parameter when passed in memory. - -2004-03-09 Hans-Peter Nilsson - - * configure: Regenerate for config/accross.m4 correction. - -2004-02-25 Matt Kraai - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Change - ecif->cif->bytes to bytes. - (ffi_prep_cif_machdep): Add braces around nested if statement. - -2004-02-09 Alan Modra - - * src/types.c (pointer): POWERPC64 has 8 byte pointers. - - * src/powerpc/ffi.c (ffi_prep_args64): Correct long double handling. - (ffi_closure_helper_LINUX64): Fix typo. - * testsuite/libffi.call/cls_align_longdouble.c: Pass -mlong-double-128 - for powerpc64-*-*. - * testsuite/libffi.call/float.c: Likewise. - * testsuite/libffi.call/float2.c: Likewise. - -2004-02-08 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_cif_machdep ): Correct - long double function return and long double arg handling. - (ffi_closure_helper_LINUX64): Formatting. Delete unused "ng" var. - Use "end_pfr" instead of "nf". Correct long double handling. - Localise "temp". - * src/powerpc/linux64.S (ffi_call_LINUX64): Save f2 long double - return value. - * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Allocate - space for long double return value. Adjust stack frame and offsets. - Load f2 long double return. - -2004-02-07 Alan Modra - - * src/types.c: Use 16 byte long double for POWERPC64. - -2004-01-25 Eric Botcazou - - * src/sparc/ffi.c (ffi_prep_args_v9): Shift the parameter array - when the structure return address is passed in %o0. - (ffi_V9_return_struct): Rename into ffi_v9_layout_struct. - (ffi_v9_layout_struct): Align the field following a nested structure - on a word boundary. Use memmove instead of memcpy. - (ffi_call): Update call to ffi_V9_return_struct. - (ffi_prep_closure): Define 'ctx' only for V8. - (ffi_closure_sparc_inner): Clone into ffi_closure_sparc_inner_v8 - and ffi_closure_sparc_inner_v9. - (ffi_closure_sparc_inner_v8): Return long doubles by reference. - Always skip the structure return address. For structures and long - doubles, copy the argument directly. - (ffi_closure_sparc_inner_v9): Skip the structure return address only - if required. Shift the maximum floating-point slot accordingly. For - big structures, copy the argument directly; otherwise, left-justify the - argument and call ffi_v9_layout_struct to lay out the structure on - the stack. - * src/sparc/v8.S: Undef STACKFRAME before defining it. - (ffi_closure_v8): Pass the structure return address. Update call to - ffi_closure_sparc_inner_v8. Short-circuit FFI_TYPE_INT handling. - Skip the 'unimp' insn when returning long doubles and structures. - * src/sparc/v9.S: Undef STACKFRAME before defining it. - (ffi_closure_v9): Increase the frame size by 2 words. Short-circuit - FFI_TYPE_INT handling. Load structures both in integers and - floating-point registers on return. - * README: Update status of the SPARC port. - -2004-01-24 Andreas Tobler - - * testsuite/libffi.call/pyobjc-tc.c (main): Treat result value - as of type ffi_arg. - * testsuite/libffi.call/struct3.c (main): Fix CHECK. - -2004-01-22 Ulrich Weigand - - * testsuite/libffi.call/cls_uint.c (cls_ret_uint_fn): Treat result - value as of type ffi_arg, not unsigned int. - -2004-01-21 Michael Ritzert - - * ffi64.c (ffi_prep_args): Cast the RHS of an assignment instead - of the LHS. - -2004-01-12 Andreas Tobler - - * testsuite/lib/libffi-dg.exp: Set LD_LIBRARY_PATH_32 for - Solaris. - -2004-01-08 Rainer Orth - - * testsuite/libffi.call/ffitest.h (allocate_mmap): Cast MAP_FAILED - to void *. - -2003-12-10 Richard Henderson - - * testsuite/libffi.call/cls_align_pointer.c: Cast pointers to - size_t instead of int. - -2003-12-04 Hosaka Yuji - - * testsuite/libffi.call/many_win32.c: Include . - * testsuite/libffi.call/many_win32.c (main): Replace variable - int i with unsigned long ul. - - * testsuite/libffi.call/cls_align_uint64.c: New test case. - * testsuite/libffi.call/cls_align_sint64.c: Likewise. - * testsuite/libffi.call/cls_align_uint32.c: Likewise. - * testsuite/libffi.call/cls_align_sint32.c: Likewise. - * testsuite/libffi.call/cls_align_uint16.c: Likewise. - * testsuite/libffi.call/cls_align_sint16.c: Likewise. - * testsuite/libffi.call/cls_align_float.c: Likewise. - * testsuite/libffi.call/cls_align_double.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble.c: Likewise. - * testsuite/libffi.call/cls_align_pointer.c: Likewise. - -2003-12-02 Hosaka Yuji - - PR other/13221 - * src/x86/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV): - Align arguments to 32 bits. - -2003-12-01 Andreas Tobler - - PR other/13221 - * testsuite/libffi.call/cls_multi_sshort.c: New test case. - * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise. - * testsuite/libffi.call/cls_multi_uchar.c: Likewise. - * testsuite/libffi.call/cls_multi_schar.c: Likewise. - * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise. - * testsuite/libffi.call/cls_multi_ushort.c: Likewise. - - * testsuite/libffi.special/unwindtest.cc: Cosmetics. - -2003-11-26 Kaveh R. Ghazi - - * testsuite/libffi.call/ffitest.h: Include . - * testsuite/libffi.special/ffitestcxx.h: Likewise. - -2003-11-22 Andreas Tobler - - * Makefile.in: Rebuilt. - * configure: Likewise. - * testsuite/libffi.special/unwindtest.cc: Convert the mmap to - the right type. - -2003-11-21 Andreas Jaeger - Andreas Tobler - - * acinclude.m4: Add AC_FUNC_MMAP_BLACKLIST. - * configure.in: Call AC_FUNC_MMAP_BLACKLIST. - * Makefile.in: Rebuilt. - * aclocal.m4: Likewise. - * configure: Likewise. - * fficonfig.h.in: Likewise. - * testsuite/lib/libffi-dg.exp: Add include dir. - * testsuite/libffi.call/ffitest.h: Add MMAP definitions. - * testsuite/libffi.special/ffitestcxx.h: Likewise. - * testsuite/libffi.call/closure_fn0.c: Use MMAP functionality - for ffi_closure if available. - * testsuite/libffi.call/closure_fn1.c: Likewise. - * testsuite/libffi.call/closure_fn2.c: Likewise. - * testsuite/libffi.call/closure_fn3.c: Likewise. - * testsuite/libffi.call/closure_fn4.c: Likewise. - * testsuite/libffi.call/closure_fn5.c: Likewise. - * testsuite/libffi.call/cls_12byte.c: Likewise. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_18byte.c: Likewise. - * testsuite/libffi.call/cls_19byte.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_20byte1.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - * testsuite/libffi.call/cls_64byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_9byte1.c: Likewise. - * testsuite/libffi.call/cls_9byte2.c: Likewise. - * testsuite/libffi.call/cls_double.c: Likewise. - * testsuite/libffi.call/cls_float.c: Likewise. - * testsuite/libffi.call/cls_schar.c: Likewise. - * testsuite/libffi.call/cls_sint.c: Likewise. - * testsuite/libffi.call/cls_sshort.c: Likewise. - * testsuite/libffi.call/cls_uchar.c: Likewise. - * testsuite/libffi.call/cls_uint.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/cls_ushort.c: Likewise. - * testsuite/libffi.call/nested_struct.c: Likewise. - * testsuite/libffi.call/nested_struct1.c: Likewise. - * testsuite/libffi.call/nested_struct2.c: Likewise. - * testsuite/libffi.call/nested_struct3.c: Likewise. - * testsuite/libffi.call/problem1.c: Likewise. - * testsuite/libffi.special/unwindtest.cc: Likewise. - -2003-11-20 Andreas Tobler - - * testsuite/lib/libffi-dg.exp: Make the -lgcc_s conditional. - -2003-11-19 Andreas Tobler - - * testsuite/lib/libffi-dg.exp: Add DYLD_LIBRARY_PATH for darwin. - Add -lgcc_s to additional flags. - -2003-11-12 Andreas Tobler - - * configure.in, include/Makefile.am: PR libgcj/11147, install - the ffitarget.h header file in a gcc versioned and target - dependent place. - * configure: Regenerated. - * Makefile.in, include/Makefile.in: Likewise. - * testsuite/Makefile.in: Likewise. - -2003-11-09 Andreas Tobler - - * testsuite/libffi.call/closure_fn0.c: Print result and check - with dg-output to make debugging easier. - * testsuite/libffi.call/closure_fn1.c: Likewise. - * testsuite/libffi.call/closure_fn2.c: Likewise. - * testsuite/libffi.call/closure_fn3.c: Likewise. - * testsuite/libffi.call/closure_fn4.c: Likewise. - * testsuite/libffi.call/closure_fn5.c: Likewise. - * testsuite/libffi.call/cls_12byte.c: Likewise. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_18byte.c: Likewise. - * testsuite/libffi.call/cls_19byte.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_20byte1.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - * testsuite/libffi.call/cls_64byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_9byte1.c: Likewise. - * testsuite/libffi.call/cls_9byte2.c: Likewise. - * testsuite/libffi.call/cls_double.c: Likewise. - * testsuite/libffi.call/cls_float.c: Likewise. - * testsuite/libffi.call/cls_schar.c: Likewise. - * testsuite/libffi.call/cls_sint.c: Likewise. - * testsuite/libffi.call/cls_sshort.c: Likewise. - * testsuite/libffi.call/cls_uchar.c: Likewise. - * testsuite/libffi.call/cls_uint.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/cls_ushort.c: Likewise. - * testsuite/libffi.call/problem1.c: Likewise. - - * testsuite/libffi.special/unwindtest.cc: Make ffi_closure - static. - -2003-11-08 Andreas Tobler - - * testsuite/libffi.call/cls_9byte2.c: New test case. - * testsuite/libffi.call/cls_9byte1.c: Likewise. - * testsuite/libffi.call/cls_64byte.c: Likewise. - * testsuite/libffi.call/cls_20byte1.c: Likewise. - * testsuite/libffi.call/cls_19byte.c: Likewise. - * testsuite/libffi.call/cls_18byte.c: Likewise. - * testsuite/libffi.call/closure_fn4.c: Likewise. - * testsuite/libffi.call/closure_fn5.c: Likewise. - * testsuite/libffi.call/cls_schar.c: Likewise. - * testsuite/libffi.call/cls_sint.c: Likewise. - * testsuite/libffi.call/cls_sshort.c: Likewise. - * testsuite/libffi.call/nested_struct2.c: Likewise. - * testsuite/libffi.call/nested_struct3.c: Likewise. - -2003-11-08 Andreas Tobler - - * testsuite/libffi.call/cls_double.c: Do a check on the result. - * testsuite/libffi.call/cls_uchar.c: Likewise. - * testsuite/libffi.call/cls_uint.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/cls_ushort.c: Likewise. - * testsuite/libffi.call/return_sc.c: Cleanup whitespaces. - -2003-11-06 Andreas Tobler - - * src/prep_cif.c (ffi_prep_cif): Move the validity check after - the initialization. - -2003-10-23 Andreas Tobler - - * src/java_raw_api.c (ffi_java_ptrarray_to_raw): Replace - FFI_ASSERT(FALSE) with FFI_ASSERT(0). - -2003-10-22 David Daney - - * src/mips/ffitarget.h: Replace undefined UINT32 and friends with - __attribute__((__mode__(__SI__))) and friends. - -2003-10-22 Andreas Schwab - - * src/ia64/ffi.c: Replace FALSE/TRUE with false/true. - -2003-10-21 Andreas Tobler - - * configure.in: AC_LINK_FILES(ffitarget.h). - * configure: Regenerate. - * Makefile.in: Likewise. - * include/Makefile.in: Likewise. - * testsuite/Makefile.in: Likewise. - * fficonfig.h.in: Likewise. - -2003-10-21 Paolo Bonzini - Richard Henderson - - Avoid that ffi.h includes fficonfig.h. - - * Makefile.am (EXTRA_DIST): Include ffitarget.h files - (TARGET_SRC_MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX. - (TARGET_SRC_MIPS_SGI): Removed. - (MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX. - (MIPS_SGI): Removed. - (CLEANFILES): Removed. - (mostlyclean-am, clean-am, mostlyclean-sub, clean-sub): New - targets. - * acconfig.h: Removed. - * configure.in: Compute sizeofs only for double and long double. - Use them to define and subst HAVE_LONG_DOUBLE. Include comments - into AC_DEFINE instead of using acconfig.h. Create - include/ffitarget.h instead of include/fficonfig.h. Rename - MIPS_GCC to MIPS_IRIX, drop MIPS_SGI since we are in gcc's tree. - AC_DEFINE EH_FRAME_FLAGS. - * include/Makefile.am (DISTCLEANFILES): New automake macro. - (hack_DATA): Add ffitarget.h. - * include/ffi.h.in: Remove all system specific definitions. - Declare raw API even if it is not installed, why bother? - Use limits.h instead of SIZEOF_* to define ffi_type_*. Do - not define EH_FRAME_FLAGS, it is in fficonfig.h now. Include - ffitarget.h instead of fficonfig.h. Remove ALIGN macro. - (UINT_ARG, INT_ARG): Removed, use ffi_arg and ffi_sarg instead. - * include/ffi_common.h (bool): Do not define. - (ffi_assert): Accept failed assertion. - (ffi_type_test): Return void and accept file/line. - (FFI_ASSERT): Pass stringized failed assertion. - (FFI_ASSERT_AT): New macro. - (FFI_ASSERT_VALID_TYPE): New macro. - (UINT8, SINT8, UINT16, SINT16, UINT32, SINT32, - UINT64, SINT64): Define here with gcc's __attribute__ macro - instead of in ffi.h - (FLOAT32, ALIGN): Define here instead of in ffi.h - * include/ffi-mips.h: Removed. Its content moved to - src/mips/ffitarget.h after separating assembly and C sections. - * src/alpha/ffi.c, src/alpha/ffi.c, src/java_raw_api.c - src/prep_cif.c, src/raw_api.c, src/ia64/ffi.c, - src/mips/ffi.c, src/mips/n32.S, src/mips/o32.S, - src/mips/ffitarget.h, src/sparc/ffi.c, src/x86/ffi64.c: - SIZEOF_ARG -> FFI_SIZEOF_ARG. - * src/ia64/ffi.c: Include stdbool.h (provided by GCC 2.95+). - * src/debug.c (ffi_assert): Accept stringized failed assertion. - (ffi_type_test): Rewritten. - * src/prep-cif.c (initialize_aggregate, ffi_prep_cif): Call - FFI_ASSERT_VALID_TYPE. - * src/alpha/ffitarget.h, src/arm/ffitarget.h, - src/ia64/ffitarget.h, src/m68k/ffitarget.h, - src/mips/ffitarget.h, src/powerpc/ffitarget.h, - src/s390/ffitarget.h, src/sh/ffitarget.h, - src/sh64/ffitarget.h, src/sparc/ffitarget.h, - src/x86/ffitarget.h: New files. - * src/alpha/osf.S, src/arm/sysv.S, src/ia64/unix.S, - src/m68k/sysv.S, src/mips/n32.S, src/mips/o32.S, - src/powerpc/aix.S, src/powerpc/darwin.S, - src/powerpc/ffi_darwin.c, src/powerpc/linux64.S, - src/powerpc/linux64_closure.S, src/powerpc/ppc_closure.S, - src/powerpc/sysv.S, src/s390/sysv.S, src/sh/sysv.S, - src/sh64/sysv.S, src/sparc/v8.S, src/sparc/v9.S, - src/x86/sysv.S, src/x86/unix64.S, src/x86/win32.S: - include fficonfig.h - -2003-10-20 Rainer Orth - - * src/mips/ffi.c: Use _ABIN32, _ABIO32 instead of external - _MIPS_SIM_NABI32, _MIPS_SIM_ABI32. - -2003-10-19 Andreas Tobler - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Declare bytes again. - Used when FFI_DEBUG = 1. - -2003-10-14 Alan Modra - - * src/types.c (double, longdouble): Default POWERPC64 to 8 byte size - and align. - -2003-10-06 Rainer Orth - - * include/ffi_mips.h: Define FFI_MIPS_N32 for N32/N64 ABIs, - FFI_MIPS_O32 for O32 ABI. - -2003-10-01 Andreas Tobler - - * testsuite/lib/libffi-dg.exp: Set LD_LIBRARY_PATH_64 for - SPARC64. Cleanup whitespaces. - -2003-09-19 Andreas Tobler - - * testsuite/libffi.call/closure_fn0.c: Xfail mips, arm, - strongarm, xscale. Cleanup whitespaces. - * testsuite/libffi.call/closure_fn1.c: Likewise. - * testsuite/libffi.call/closure_fn2.c: Likewise. - * testsuite/libffi.call/closure_fn3.c: Likewise. - * testsuite/libffi.call/cls_12byte.c: Likewise. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_double.c: Likewise. - * testsuite/libffi.call/cls_float.c: Likewise. - * testsuite/libffi.call/cls_uchar.c: Likewise. - * testsuite/libffi.call/cls_uint.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/cls_ushort.c: Likewise. - * testsuite/libffi.call/nested_struct.c: Likewise. - * testsuite/libffi.call/nested_struct1.c: Likewise. - * testsuite/libffi.call/problem1.c: Likewise. - * testsuite/libffi.special/unwindtest.cc: Likewise. - * testsuite/libffi.call/pyobjc-tc.c: Cleanup whitespaces. - -2003-09-18 David Edelsohn - - * src/powerpc/aix.S: Cleanup whitespaces. - * src/powerpc/aix_closure.S: Likewise. - -2003-09-18 Andreas Tobler - - * src/powerpc/darwin.S: Cleanup whitespaces, comment formatting. - * src/powerpc/darwin_closure.S: Likewise. - * src/powerpc/ffi_darwin.c: Likewise. - -2003-09-18 Andreas Tobler - David Edelsohn - - * src/types.c (double): Add AIX and Darwin to the right TYPEDEF. - * src/powerpc/aix_closure.S: Remove the pointer to the outgoing - parameter stack. - * src/powerpc/darwin_closure.S: Likewise. - * src/powerpc/ffi_darwin.c (ffi_prep_args): Handle structures - according to the Darwin/AIX ABI. - (ffi_prep_cif_machdep): Likewise. - (ffi_closure_helper_DARWIN): Likewise. - Remove the outgoing parameter stack logic. Simplify the evaluation - of the different CASE types. - (ffi_prep_clousure): Avoid the casts on lvalues. Change the branch - statement in the trampoline code. - -2003-09-18 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_args): Take account into the alignement - for the register size. - (ffi_closure_helper_SYSV): Handle the structure return value - address correctly. - (ffi_closure_helper_SYSV): Return the appropriate type when - the registers are used for the structure return value. - * src/sh/sysv.S (ffi_closure_SYSV): Fix the stack layout for - the 64-bit return value. Update copyright years. - -2003-09-17 Rainer Orth - - * testsuite/lib/libffi-dg.exp (libffi_target_compile): Search in - srcdir for ffi_mips.h. - -2003-09-12 Alan Modra - - * src/prep_cif.c (initialize_aggregate): Include tail padding in - structure size. - * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Correct - placement of float result. - * testsuite/libffi.special/unwindtest.cc (closure_test_fn1): Correct - cast of "resp" for big-endian 64 bit machines. - -2003-09-11 Alan Modra - - * src/types.c (double, longdouble): Merge identical SH and ARM - typedefs, and add POWERPC64. - * src/powerpc/ffi.c (ffi_prep_args64): Correct next_arg calc for - struct split over gpr and rest. - (ffi_prep_cif_machdep): Correct intarg_count for structures. - * src/powerpc/linux64.S (ffi_call_LINUX64): Fix gpr offsets. - -2003-09-09 Andreas Tobler - - * src/powerpc/ffi.c (ffi_closure_helper_SYSV) Handle struct - passing correctly. - -2003-09-09 Alan Modra - - * configure: Regenerate. - -2003-09-04 Andreas Tobler - - * Makefile.am: Remove build rules for ffitest. - * Makefile.in: Rebuilt. - -2003-09-04 Andreas Tobler - - * src/java_raw_api.c: Include to fix compiler warning - about implicit declaration of abort(). - -2003-09-04 Andreas Tobler - - * Makefile.am: Add dejagnu test framework. Fixes PR other/11411. - * Makefile.in: Rebuilt. - * configure.in: Add dejagnu test framework. - * configure: Rebuilt. - - * testsuite/Makefile.am: New file. - * testsuite/Makefile.in: Built - * testsuite/lib/libffi-dg.exp: New file. - * testsuite/config/default.exp: Likewise. - * testsuite/libffi.call/call.exp: Likewise. - * testsuite/libffi.call/ffitest.h: Likewise. - * testsuite/libffi.call/closure_fn0.c: Likewise. - * testsuite/libffi.call/closure_fn1.c: Likewise. - * testsuite/libffi.call/closure_fn2.c: Likewise. - * testsuite/libffi.call/closure_fn3.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_12byte.c: Likewise. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_double.c: Likewise. - * testsuite/libffi.call/cls_float.c: Likewise. - * testsuite/libffi.call/cls_uchar.c: Likewise. - * testsuite/libffi.call/cls_uint.c: Likewise. - * testsuite/libffi.call/cls_ulonglong.c: Likewise. - * testsuite/libffi.call/cls_ushort.c: Likewise. - * testsuite/libffi.call/float.c: Likewise. - * testsuite/libffi.call/float1.c: Likewise. - * testsuite/libffi.call/float2.c: Likewise. - * testsuite/libffi.call/many.c: Likewise. - * testsuite/libffi.call/many_win32.c: Likewise. - * testsuite/libffi.call/nested_struct.c: Likewise. - * testsuite/libffi.call/nested_struct1.c: Likewise. - * testsuite/libffi.call/pyobjc-tc.c: Likewise. - * testsuite/libffi.call/problem1.c: Likewise. - * testsuite/libffi.call/promotion.c: Likewise. - * testsuite/libffi.call/return_ll.c: Likewise. - * testsuite/libffi.call/return_sc.c: Likewise. - * testsuite/libffi.call/return_uc.c: Likewise. - * testsuite/libffi.call/strlen.c: Likewise. - * testsuite/libffi.call/strlen_win32.c: Likewise. - * testsuite/libffi.call/struct1.c: Likewise. - * testsuite/libffi.call/struct2.c: Likewise. - * testsuite/libffi.call/struct3.c: Likewise. - * testsuite/libffi.call/struct4.c: Likewise. - * testsuite/libffi.call/struct5.c: Likewise. - * testsuite/libffi.call/struct6.c: Likewise. - * testsuite/libffi.call/struct7.c: Likewise. - * testsuite/libffi.call/struct8.c: Likewise. - * testsuite/libffi.call/struct9.c: Likewise. - * testsuite/libffi.special/special.exp: New file. - * testsuite/libffi.special/ffitestcxx.h: Likewise. - * testsuite/libffi.special/unwindtest.cc: Likewise. - - -2003-08-13 Kaz Kojima - - * src/sh/ffi.c (OFS_INT16): Set 0 for little endian case. Update - copyright years. - -2003-08-02 Alan Modra - - * src/powerpc/ffi.c (ffi_prep_args64): Modify for changed gcc - structure passing. - (ffi_closure_helper_LINUX64): Likewise. - * src/powerpc/linux64.S: Remove code writing to parm save area. - * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Use return - address in lr from ffi_closure_helper_LINUX64 call to calculate - table address. Optimize function tail. - -2003-07-28 Andreas Tobler - - * src/sparc/ffi.c: Handle all floating point registers. - * src/sparc/v9.S: Likewise. Fixes second part of PR target/11410. - -2003-07-11 Gerald Pfeifer - - * README: Note that libffi is not part of GCC. Update the project - URL and status. - -2003-06-19 Franz Sirl - - * src/powerpc/ppc_closure.S: Include ffi.h. - -2003-06-13 Rainer Orth - - * src/x86/sysv.S: Avoid gas-only .uleb128/.sleb128 directives. - Use C style comments. - -2003-06-13 Kaz Kojima - - * Makefile.am: Add SHmedia support. Fix a typo of SH support. - * Makefile.in: Regenerate. - * configure.in (sh64-*-linux*, sh5*-*-linux*): Add target. - * configure: Regenerate. - * include/ffi.h.in: Add SHmedia support. - * src/sh64/ffi.c: New file. - * src/sh64/sysv.S: New file. - -2003-05-16 Jakub Jelinek - - * configure.in (HAVE_RO_EH_FRAME): Check whether .eh_frame section - should be read-only. - * configure: Rebuilt. - * fficonfig.h.in: Rebuilt. - * include/ffi.h.in (EH_FRAME_FLAGS): Define. - * src/alpha/osf.S: Use EH_FRAME_FLAGS. - * src/powerpc/linux64.S: Likewise. - * src/powerpc/linux64_closure.S: Likewise. Include ffi.h. - * src/powerpc/sysv.S: Use EH_FRAME_FLAGS. Use pcrel encoding - if -fpic/-fPIC/-mrelocatable. - * src/powerpc/powerpc_closure.S: Likewise. - * src/sparc/v8.S: If HAVE_RO_EH_FRAME is defined, don't include - #write in .eh_frame flags. - * src/sparc/v9.S: Likewise. - * src/x86/unix64.S: Use EH_FRAME_FLAGS. - * src/x86/sysv.S: Likewise. Use pcrel encoding if -fpic/-fPIC. - * src/s390/sysv.S: Use EH_FRAME_FLAGS. Include ffi.h. - -2003-05-07 Jeff Sturm - - Fixes PR bootstrap/10656 - * configure.in (HAVE_AS_REGISTER_PSEUDO_OP): Test assembler - support for .register pseudo-op. - * src/sparc/v8.S: Use it. - * fficonfig.h.in: Rebuilt. - * configure: Rebuilt. - -2003-04-18 Jakub Jelinek - - * include/ffi.h.in (POWERPC64): Define if 64-bit. - (enum ffi_abi): Add FFI_LINUX64 on POWERPC. - Make it the default on POWERPC64. - (FFI_TRAMPOLINE_SIZE): Define to 24 on POWERPC64. - * configure.in: Change powerpc-*-linux* into powerpc*-*-linux*. - * configure: Rebuilt. - * src/powerpc/ffi.c (hidden): Define. - (ffi_prep_args_SYSV): Renamed from - ffi_prep_args. Cast pointers to unsigned long to shut up warnings. - (NUM_GPR_ARG_REGISTERS64, NUM_FPR_ARG_REGISTERS64, - ASM_NEEDS_REGISTERS64): New. - (ffi_prep_args64): New function. - (ffi_prep_cif_machdep): Handle FFI_LINUX64 ABI. - (ffi_call): Likewise. - (ffi_prep_closure): Likewise. - (flush_icache): Surround by #ifndef POWERPC64. - (ffi_dblfl): New union type. - (ffi_closure_helper_SYSV): Use it to avoid aliasing problems. - (ffi_closure_helper_LINUX64): New function. - * src/powerpc/ppc_closure.S: Surround whole file by #ifndef - __powerpc64__. - * src/powerpc/sysv.S: Likewise. - (ffi_call_SYSV): Rename ffi_prep_args to ffi_prep_args_SYSV. - * src/powerpc/linux64.S: New file. - * src/powerpc/linux64_closure.S: New file. - * Makefile.am (EXTRA_DIST): Add src/powerpc/linux64.S and - src/powerpc/linux64_closure.S. - (TARGET_SRC_POWERPC): Likewise. - - * src/ffitest.c (closure_test_fn, closure_test_fn1, closure_test_fn2, - closure_test_fn3): Fix result printing on big-endian 64-bit - machines. - (main): Print tst2_arg instead of uninitialized tst2_result. - - * src/ffitest.c (main): Hide what closure pointer really points to - from the compiler. - -2003-04-16 Richard Earnshaw - - * configure.in (arm-*-netbsdelf*): Add configuration. - (configure): Regenerated. - -2003-04-04 Loren J. Rittle - - * include/Makefile.in: Regenerate. - -2003-03-21 Zdenek Dvorak - - * libffi/include/ffi.h.in: Define X86 instead of X86_64 in 32 - bit mode. - * libffi/src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV): - Receive closure pointer through parameter, read args using - __builtin_dwarf_cfa. - (FFI_INIT_TRAMPOLINE): Send closure reference through eax. - -2003-03-12 Andreas Schwab - - * configure.in: Avoid trailing /. in toolexeclibdir. - * configure: Rebuilt. - -2003-03-03 Andreas Tobler - - * src/powerpc/darwin_closure.S: Recode to fit dynamic libraries. - -2003-02-06 Andreas Tobler - - * libffi/src/powerpc/darwin_closure.S: - Fix alignement bug, allocate 8 bytes for the result. - * libffi/src/powerpc/aix_closure.S: - Likewise. - * libffi/src/powerpc/ffi_darwin.c: - Update stackframe description for aix/darwin_closure.S. - -2003-02-06 Jakub Jelinek - - * src/s390/ffi.c (ffi_closure_helper_SYSV): Add hidden visibility - attribute. - -2003-01-31 Christian Cornelssen , - Andreas Schwab - - * configure.in: Adjust command to source config-ml.in to account - for changes to the libffi_basedir definition. - (libffi_basedir): Remove ${srcdir} from value and include trailing - slash if nonempty. - - * configure: Regenerate. - -2003-01-29 Franz Sirl - - * src/powerpc/ppc_closure.S: Recode to fit shared libs. - -2003-01-28 Andrew Haley - - * include/ffi.h.in: Enable FFI_CLOSURES for x86_64. - * src/x86/ffi64.c (ffi_prep_closure): New. - (ffi_closure_UNIX64_inner): New. - * src/x86/unix64.S (ffi_closure_UNIX64): New. - -2003-01-27 Alexandre Oliva - - * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST. - Remove USE_LIBDIR conditional. - * Makefile.am (toolexecdir, toolexeclibdir): Don't override. - * Makefile.in, configure: Rebuilt. - -2003-01027 David Edelsohn - - * Makefile.am (TARGET_SRC_POWERPC_AIX): Fix typo. - * Makefile.in: Regenerate. - -2003-01-22 Andrew Haley - - * src/powerpc/darwin.S (_ffi_call_AIX): Add Augmentation size to - unwind info. - -2003-01-21 Andreas Tobler - - * src/powerpc/darwin.S: Add unwind info. - * src/powerpc/darwin_closure.S: Likewise. - -2003-01-14 Andrew Haley - - * src/x86/ffi64.c (ffi_prep_args): Check for void retval. - (ffi_prep_cif_machdep): Likewise. - * src/x86/unix64.S: Add unwind info. - -2003-01-14 Andreas Jaeger - - * src/ffitest.c (main): Only use ffi_closures if those are - supported. - -2003-01-13 Andreas Tobler - - * libffi/src/ffitest.c - add closure testcases - -2003-01-13 Kevin B. Hendricks - - * libffi/src/powerpc/ffi.c - fix alignment bug for float (4 byte aligned iso 8 byte) - -2003-01-09 Geoffrey Keating - - * src/powerpc/ffi_darwin.c: Remove RCS version string. - * src/powerpc/darwin.S: Remove RCS version string. - -2003-01-03 Jeff Sturm - - * include/ffi.h.in: Add closure defines for SPARC, SPARC64. - * src/ffitest.c (main): Use static storage for closure. - * src/sparc/ffi.c (ffi_prep_closure, ffi_closure_sparc_inner): New. - * src/sparc/v8.S (ffi_closure_v8): New. - * src/sparc/v9.S (ffi_closure_v9): New. - -2002-11-10 Ranjit Mathew - - * include/ffi.h.in: Added FFI_STDCALL ffi_type - enumeration for X86_WIN32. - * src/x86/win32.S: Added ffi_call_STDCALL function - definition. - * src/x86/ffi.c (ffi_call/ffi_raw_call): Added - switch cases for recognising FFI_STDCALL and - calling ffi_call_STDCALL if target is X86_WIN32. - * src/ffitest.c (my_stdcall_strlen/stdcall_many): - stdcall versions of the "my_strlen" and "many" - test functions (for X86_WIN32). - Added test cases to test stdcall invocation using - these functions. - -2002-12-02 Kaz Kojima - - * src/sh/sysv.S: Add DWARF2 unwind info. - -2002-11-27 Ulrich Weigand - - * src/s390/sysv.S (.eh_frame section): Make section read-only. - -2002-11-26 Jim Wilson - - * src/types.c (FFI_TYPE_POINTER): Has size 8 on IA64. - -2002-11-23 H.J. Lu - - * acinclude.m4: Add dummy AM_PROG_LIBTOOL. - Include ../config/accross.m4. - * aclocal.m4; Rebuild. - * configure: Likewise. - -2002-11-15 Ulrich Weigand - - * src/s390/sysv.S (.eh_frame section): Adapt to pcrel FDE encoding. - -2002-11-11 DJ Delorie - - * configure.in: Look for common files in the right place. - -2002-10-08 Ulrich Weigand - - * src/java_raw_api.c (ffi_java_raw_to_ptrarray): Interpret - raw data as _Jv_word values, not ffi_raw. - (ffi_java_ptrarray_to_raw): Likewise. - (ffi_java_rvalue_to_raw): New function. - (ffi_java_raw_call): Call it. - (ffi_java_raw_to_rvalue): New function. - (ffi_java_translate_args): Call it. - * src/ffitest.c (closure_test_fn): Interpret return value - as ffi_arg, not int. - * src/s390/ffi.c (ffi_prep_cif_machdep): Add missing - FFI_TYPE_POINTER case. - (ffi_closure_helper_SYSV): Likewise. Also, assume return - values extended to word size. - -2002-10-02 Andreas Jaeger - - * src/x86/ffi64.c (ffi_prep_cif_machdep): Remove debug output. - -2002-10-01 Bo Thorsen - - * include/ffi.h.in: Fix i386 win32 compilation. - -2002-09-30 Ulrich Weigand - - * configure.in: Add s390x-*-linux-* target. - * configure: Regenerate. - * include/ffi.h.in: Define S390X for s390x targets. - (FFI_CLOSURES): Define for s390/s390x. - (FFI_TRAMPOLINE_SIZE): Likewise. - (FFI_NATIVE_RAW_API): Likewise. - * src/prep_cif.c (ffi_prep_cif): Do not compute stack space for s390. - * src/types.c (FFI_TYPE_POINTER): Use 8-byte pointers on s390x. - * src/s390/ffi.c: Major rework of existing code. Add support for - s390x targets. Add closure support. - * src/s390/sysv.S: Likewise. - -2002-09-29 Richard Earnshaw - - * src/arm/sysv.S: Fix typo. - -2002-09-28 Richard Earnshaw - - * src/arm/sysv.S: If we don't have machine/asm.h and the pre-processor - has defined __USER_LABEL_PREFIX__, then use it in CNAME. - (ffi_call_SYSV): Handle soft-float. - -2002-09-27 Bo Thorsen - - * include/ffi.h.in: Fix multilib x86-64 support. - -2002-09-22 Kaveh R. Ghazi - - * Makefile.am (all-multi): Fix multilib parallel build. - -2002-07-19 Kaz Kojima - - * configure.in (sh[34]*-*-linux*): Add brackets. - * configure: Regenerate. - -2002-07-18 Kaz Kojima - - * Makefile.am: Add SH support. - * Makefile.in: Regenerate. - * configure.in (sh-*-linux*, sh[34]*-*-linux*): Add target. - * configure: Regenerate. - * include/ffi.h.in: Add SH support. - * src/sh/ffi.c: New file. - * src/sh/sysv.S: New file. - * src/types.c: Add SH support. - -2002-07-16 Bo Thorsen - - * src/x86/ffi64.c: New file that adds x86-64 support. - * src/x86/unix64.S: New file that handles argument setup for - x86-64. - * src/x86/sysv.S: Don't use this on x86-64. - * src/x86/ffi.c: Don't use this on x86-64. - Remove unused vars. - * src/prep_cif.c (ffi_prep_cif): Don't do stack size calculation - for x86-64. - * src/ffitest.c (struct6): New test that tests a special case in - the x86-64 ABI. - (struct7): Likewise. - (struct8): Likewise. - (struct9): Likewise. - (closure_test_fn): Silence warning about this when it's not used. - (main): Add the new tests. - (main): Fix a couple of wrong casts and silence some compiler warnings. - * include/ffi.h.in: Add x86-64 ABI definition. - * fficonfig.h.in: Regenerate. - * Makefile.am: Add x86-64 support. - * configure.in: Likewise. - * Makefile.in: Regenerate. - * configure: Likewise. - -2002-06-24 Bo Thorsen - - * src/types.c: Merge settings for similar architectures. - Add x86-64 sizes and alignments. - -2002-06-23 Bo Thorsen - - * src/arm/ffi.c (ffi_prep_args): Remove unused vars. - * src/sparc/ffi.c (ffi_prep_args_v8): Likewise. - * src/mips/ffi.c (ffi_prep_args): Likewise. - * src/m68k/ffi.c (ffi_prep_args): Likewise. - -2002-07-18 H.J. Lu (hjl@gnu.org) - - * Makefile.am (TARGET_SRC_MIPS_LINUX): New. - (libffi_la_SOURCES): Support MIPS_LINUX. - (libffi_convenience_la_SOURCES): Likewise. - * Makefile.in: Regenerated. - - * configure.in (mips64*-*): Skip. - (mips*-*-linux*): New. - * configure: Regenerated. - - * src/mips/ffi.c: Include . - -2002-06-06 Ulrich Weigand - - * src/s390/sysv.S: Save/restore %r6. Add DWARF-2 unwind info. - -2002-05-27 Roger Sayle - - * src/x86/ffi.c (ffi_prep_args): Remove reference to avn. - -2002-05-27 Bo Thorsen - - * src/x86/ffi.c (ffi_prep_args): Remove unused variable and - fix formatting. - -2002-05-13 Andreas Tobler - - * src/powerpc/ffi_darwin.c (ffi_prep_closure): Declare fd at - beginning of function (for older apple cc). - -2002-05-08 Alexandre Oliva - - * configure.in (ORIGINAL_LD_FOR_MULTILIBS): Preserve LD at - script entry, and set LD to it when configuring multilibs. - * configure: Rebuilt. - -2002-05-05 Jason Thorpe - - * configure.in (sparc64-*-netbsd*): Add target. - (sparc-*-netbsdelf*): Likewise. - * configure: Regenerate. - -2002-04-28 David S. Miller - - * configure.in, configure: Fix SPARC test in previous change. - -2002-04-29 Gerhard Tonn - - * Makefile.am: Add Linux for S/390 support. - * Makefile.in: Regenerate. - * configure.in: Add Linux for S/390 support. - * configure: Regenerate. - * include/ffi.h.in: Add Linux for S/390 support. - * src/s390/ffi.c: New file from libffi CVS tree. - * src/s390/sysv.S: New file from libffi CVS tree. - -2002-04-28 Jakub Jelinek - - * configure.in (HAVE_AS_SPARC_UA_PCREL): Check for working - %r_disp32(). - * src/sparc/v8.S: Use it. - * src/sparc/v9.S: Likewise. - * fficonfig.h.in: Rebuilt. - * configure: Rebuilt. - -2002-04-08 Hans Boehm - - * src/java_raw_api.c (ffi_java_raw_size): Handle FFI_TYPE_DOUBLE - correctly. - * src/ia64/unix.S: Add unwind information. Fix comments. - Save sp in a way that's compatible with unwind info. - (ffi_call_unix): Correctly restore sp in all cases. - * src/ia64/ffi.c: Add, fix comments. - -2002-04-08 Jakub Jelinek - - * src/sparc/v8.S: Make .eh_frame dependent on target word size. - -2002-04-06 Jason Thorpe - - * configure.in (alpha*-*-netbsd*): Add target. - * configure: Regenerate. - -2002-04-04 Jeff Sturm - - * src/sparc/v8.S: Add unwind info. - * src/sparc/v9.S: Likewise. - -2002-03-30 Krister Walfridsson - - * configure.in: Enable i*86-*-netbsdelf*. - * configure: Rebuilt. - -2002-03-29 David Billinghurst - - PR other/2620 - * src/mips/n32.s: Delete - * src/mips/o32.s: Delete - -2002-03-21 Loren J. Rittle - - * configure.in: Enable alpha*-*-freebsd*. - * configure: Rebuilt. - -2002-03-17 Bryce McKinlay - - * Makefile.am: libfficonvenience -> libffi_convenience. - * Makefile.in: Rebuilt. - - * Makefile.am: Define ffitest_OBJECTS. - * Makefile.in: Rebuilt. - -2002-03-07 Andreas Tobler - David Edelsohn - - * Makefile.am (EXTRA_DIST): Add Darwin and AIX closure files. - (TARGET_SRC_POWERPC_AIX): Add aix_closure.S. - (TARGET_SRC_POWERPC_DARWIN): Add darwin_closure.S. - * Makefile.in: Regenerate. - * include/ffi.h.in: Add AIX and Darwin closure definitions. - * src/powerpc/ffi_darwin.c (ffi_prep_closure): New function. - (flush_icache, flush_range): New functions. - (ffi_closure_helper_DARWIN): New function. - * src/powerpc/aix_closure.S: New file. - * src/powerpc/darwin_closure.S: New file. - -2002-02-24 Jeff Sturm - - * include/ffi.h.in: Add typedef for ffi_arg. - * src/ffitest.c (main): Declare rint with ffi_arg. - -2002-02-21 Andreas Tobler - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Skip appropriate - number of GPRs for floating-point arguments. - -2002-01-31 Anthony Green - - * configure: Rebuilt. - * configure.in: Replace CHECK_SIZEOF and endian tests with - cross-compiler friendly macros. - * aclocal.m4 (AC_COMPILE_CHECK_SIZEOF, AC_C_BIGENDIAN_CROSS): New - macros. - -2002-01-18 David Edelsohn - - * src/powerpc/darwin.S (_ffi_call_AIX): New. - * src/powerpc/aix.S (ffi_call_DARWIN): New. - -2002-01-17 David Edelsohn - - * Makefile.am (EXTRA_DIST): Add Darwin and AIX files. - (TARGET_SRC_POWERPC_AIX): New. - (POWERPC_AIX): New stanza. - * Makefile.in: Regenerate. - * configure.in: Add AIX case. - * configure: Regenerate. - * include/ffi.h.in (ffi_abi): Add FFI_AIX. - * src/powerpc/ffi_darwin.c (ffi_status): Use "long" to scale frame - size. Fix "long double" support. - (ffi_call): Add FFI_AIX case. - * src/powerpc/aix.S: New. - -2001-10-09 John Hornkvist - - Implement Darwin PowerPC ABI. - * configure.in: Handle powerpc-*-darwin*. - * Makefile.am: Set source files for POWERPC_DARWIN. - * configure: Rebuilt. - * Makefile.in: Rebuilt. - * include/ffi.h.in: Define FFI_DARWIN and FFI_DEFAULT_ABI for - POWERPC_DARWIN. - * src/powerpc/darwin.S: New file. - * src/powerpc/ffi_darwin.c: New file. - -2001-10-07 Joseph S. Myers - - * src/x86/ffi.c: Fix spelling error of "separate" as "seperate". - -2001-07-16 Rainer Orth - - * src/x86/sysv.S: Avoid gas-only .balign directive. - Use C style comments. - -2001-07-16 Rainer Orth - - * src/alpha/ffi.c (ffi_prep_closure): Avoid gas-only mnemonic. - Fixes PR bootstrap/3563. - -2001-06-26 Rainer Orth - - * src/alpha/osf.S (ffi_closure_osf): Use .rdata for ECOFF. - -2001-06-25 Rainer Orth - - * configure.in: Recognize sparc*-sun-* host. - * configure: Regenerate. - -2001-06-06 Andrew Haley - - * src/alpha/osf.S (__FRAME_BEGIN__): Conditionalize for ELF. - -2001-06-03 Andrew Haley - - * src/alpha/osf.S: Add unwind info. - * src/powerpc/sysv.S: Add unwind info. - * src/powerpc/ppc_closure.S: Likewise. - -2000-05-31 Jeff Sturm - - * configure.in: Fix AC_ARG_ENABLE usage. - * configure: Rebuilt. - -2001-05-06 Bryce McKinlay - - * configure.in: Remove warning about beta code. - * configure: Rebuilt. - -2001-04-25 Hans Boehm - - * src/ia64/unix.S: Restore stack pointer when returning from - ffi_closure_UNIX. - * src/ia64/ffi.c: Fix typo in comment. - -2001-04-18 Jim Wilson - - * src/ia64/unix.S: Delete unnecessary increment and decrement of loc2 - to eliminate RAW DV. - -2001-04-12 Bryce McKinlay - - * Makefile.am: Make a libtool convenience library. - * Makefile.in: Rebuilt. - -2001-03-29 Bryce McKinlay - - * configure.in: Use different syntax for subdirectory creation. - * configure: Rebuilt. - -2001-03-27 Jon Beniston - - * configure.in: Added X86_WIN32 target (Win32, CygWin, MingW). - * configure: Rebuilt. - * Makefile.am: Added X86_WIN32 target support. - * Makefile.in: Rebuilt. - - * include/ffi.h.in: Added X86_WIN32 target support. - - * src/ffitest.c: Doesn't run structure tests for X86_WIN32 targets. - * src/types.c: Added X86_WIN32 target support. - - * src/x86/win32.S: New file. Based on sysv.S, but with EH - stuff removed and made to work with CygWin's gas. - -2001-03-26 Bryce McKinlay - - * configure.in: Make target subdirectory in build dir. - * Makefile.am: Override suffix based rules to specify correct output - subdirectory. - * Makefile.in: Rebuilt. - * configure: Rebuilt. - -2001-03-23 Kevin B Hendricks - - * src/powerpc/ppc_closure.S: New file. - * src/powerpc/ffi.c (ffi_prep_args): Fixed ABI compatibility bug - involving long long and register pairs. - (ffi_prep_closure): New function. - (flush_icache): Likewise. - (ffi_closure_helper_SYSV): Likewise. - * include/ffi.h.in (FFI_CLOSURES): Define on PPC. - (FFI_TRAMPOLINE_SIZE): Likewise. - (FFI_NATIVE_RAW_API): Likewise. - * Makefile.in: Rebuilt. - * Makefile.am (EXTRA_DIST): Added src/powerpc/ppc_closure.S. - (TARGET_SRC_POWERPC): Likewise. - -2001-03-19 Tom Tromey - - * Makefile.in: Rebuilt. - * Makefile.am (ffitest_LDFLAGS): New macro. - -2001-03-02 Nick Clifton - - * include/ffi.h.in: Remove RCS ident string. - * include/ffi_mips.h: Remove RCS ident string. - * src/debug.c: Remove RCS ident string. - * src/ffitest.c: Remove RCS ident string. - * src/prep_cif.c: Remove RCS ident string. - * src/types.c: Remove RCS ident string. - * src/alpha/ffi.c: Remove RCS ident string. - * src/alpha/osf.S: Remove RCS ident string. - * src/arm/ffi.c: Remove RCS ident string. - * src/arm/sysv.S: Remove RCS ident string. - * src/mips/ffi.c: Remove RCS ident string. - * src/mips/n32.S: Remove RCS ident string. - * src/mips/o32.S: Remove RCS ident string. - * src/sparc/ffi.c: Remove RCS ident string. - * src/sparc/v8.S: Remove RCS ident string. - * src/sparc/v9.S: Remove RCS ident string. - * src/x86/ffi.c: Remove RCS ident string. - * src/x86/sysv.S: Remove RCS ident string. - -2001-02-08 Joseph S. Myers - - * include/ffi.h.in: Change sourceware.cygnus.com references to - gcc.gnu.org. - -2000-12-09 Richard Henderson - - * src/alpha/ffi.c (ffi_call): Simplify struct return test. - (ffi_closure_osf_inner): Index rather than increment avalue - and arg_types. Give ffi_closure_osf the raw return value type. - * src/alpha/osf.S (ffi_closure_osf): Handle return value type - promotion. - -2000-12-07 Richard Henderson - - * src/raw_api.c (ffi_translate_args): Fix typo. - (ffi_prep_closure): Likewise. - - * include/ffi.h.in [ALPHA]: Define FFI_CLOSURES and - FFI_TRAMPOLINE_SIZE. - * src/alpha/ffi.c (ffi_prep_cif_machdep): Adjust minimal - cif->bytes for new ffi_call_osf implementation. - (ffi_prep_args): Absorb into ... - (ffi_call): ... here. Do all stack allocation here and - avoid a callback function. - (ffi_prep_closure, ffi_closure_osf_inner): New. - * src/alpha/osf.S (ffi_call_osf): Reimplement with no callback. - (ffi_closure_osf): New. - -2000-09-10 Alexandre Oliva - - * config.guess, config.sub, install-sh: Removed. - * ltconfig, ltmain.sh, missing, mkinstalldirs: Likewise. - * Makefile.in: Rebuilt. - - * acinclude.m4: Include libtool macros from the top level. - * aclocal.m4, configure: Rebuilt. - -2000-08-22 Alexandre Oliva - - * configure.in [i*86-*-freebsd*] (TARGET, TARGETDIR): Set. - * configure: Rebuilt. - -2000-05-11 Scott Bambrough - - * libffi/src/arm/sysv.S (ffi_call_SYSV): Doubles are not saved to - memory correctly. Use conditional instructions, not branches where - possible. - -2000-05-04 Tom Tromey - - * configure: Rebuilt. - * configure.in: Match `arm*-*-linux-*'. - From Chris Dornan . - -2000-04-28 Jakub Jelinek - - * Makefile.am (SUBDIRS): Define. - (AM_MAKEFLAGS): Likewise. - (Multilib support.): Add section. - * Makefile.in: Rebuilt. - * ltconfig (extra_compiler_flags, extra_compiler_flags_value): - New variables. Set for gcc using -print-multi-lib. Export them - to libtool. - (sparc64-*-linux-gnu*): Use libsuff 64 for search paths. - * ltmain.sh (B|b|V): Don't throw away gcc's -B, -b and -V options - for -shared links. - (extra_compiler_flags_value, extra_compiler_flags): Check these - for extra compiler options which need to be passed down in - compiler_flags. - -2000-04-16 Anthony Green - - * configure: Rebuilt. - * configure.in: Change i*86-pc-linux* to i*86-*-linux*. - -2000-04-14 Jakub Jelinek - - * include/ffi.h.in (SPARC64): Define for 64bit SPARC builds. - Set SPARC FFI_DEFAULT_ABI based on SPARC64 define. - * src/sparc/ffi.c (ffi_prep_args_v8): Renamed from ffi_prep_args. - Replace all void * sizeofs with sizeof(int). - Only compare type with FFI_TYPE_LONGDOUBLE if LONGDOUBLE is - different than DOUBLE. - Remove FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases (handled elsewhere). - (ffi_prep_args_v9): New function. - (ffi_prep_cif_machdep): Handle V9 ABI and long long on V8. - (ffi_V9_return_struct): New function. - (ffi_call): Handle FFI_V9 ABI from 64bit code and FFI_V8 ABI from - 32bit code (not yet cross-arch calls). - * src/sparc/v8.S: Add struct return delay nop. - Handle long long. - * src/sparc/v9.S: New file. - * src/prep_cif.c (ffi_prep_cif): Return structure pointer - is used on sparc64 only for structures larger than 32 bytes. - Pass by reference for structures is done for structure arguments - larger than 16 bytes. - * src/ffitest.c (main): Use 64bit rint on sparc64. - Run long long tests on sparc. - * src/types.c (FFI_TYPE_POINTER): Pointer is 64bit on alpha and - sparc64. - (FFI_TYPE_LONGDOUBLE): long double is 128 bit aligned to 128 bits - on sparc64. - * configure.in (sparc-*-linux*): New supported target. - (sparc64-*-linux*): Likewise. - * configure: Rebuilt. - * Makefile.am: Add v9.S to SPARC files. - * Makefile.in: Likewise. - (LINK): Surround $(CCLD) into double quotes, so that multilib - compiles work correctly. - -2000-04-04 Alexandre Petit-Bianco - - * configure: Rebuilt. - * configure.in: (i*86-*-solaris*): New libffi target. Patch - proposed by Bryce McKinlay. - -2000-03-20 Tom Tromey - - * Makefile.in: Hand edit for java_raw_api.lo. - -2000-03-08 Bryce McKinlay - - * config.guess, config.sub: Update from the gcc tree. - Fix for PR libgcj/168. - -2000-03-03 Tom Tromey - - * Makefile.in: Fixed ia64 by hand. - - * configure: Rebuilt. - * configure.in (--enable-multilib): New option. - (libffi_basedir): New subst. - (AC_OUTPUT): Added multilib code. - -2000-03-02 Tom Tromey - - * Makefile.in: Rebuilt. - * Makefile.am (TARGET_SRC_IA64): Use `ia64', not `alpha', as - directory name. - -2000-02-25 Hans Boehm - - * src/ia64/ffi.c, src/ia64/ia64_flags.h, src/ia64/unix.S: New - files. - * src/raw_api.c (ffi_translate_args): Fixed typo in argument - list. - (ffi_prep_raw_closure): Use ffi_translate_args, not - ffi_closure_translate. - * src/java_raw_api.c: New file. - * src/ffitest.c (closure_test_fn): New function. - (main): Define `rint' as long long on IA64. Added new test when - FFI_CLOSURES is defined. - * include/ffi.h.in (ALIGN): Use size_t, not unsigned. - (ffi_abi): Recognize IA64. - (ffi_raw): Added `flt' field. - Added "Java raw API" code. - * configure.in: Recognize ia64. - * Makefile.am (TARGET_SRC_IA64): New macro. - (libffi_la_common_SOURCES): Added java_raw_api.c. - (libffi_la_SOURCES): Define in IA64 case. - -2000-01-04 Tom Tromey - - * Makefile.in: Rebuilt with newer automake. - -1999-12-31 Tom Tromey - - * Makefile.am (INCLUDES): Added -I$(top_srcdir)/src. - -1999-09-01 Tom Tromey - - * include/ffi.h.in: Removed PACKAGE and VERSION defines and - undefs. - * fficonfig.h.in: Rebuilt. - * configure: Rebuilt. - * configure.in: Pass 3rd argument to AM_INIT_AUTOMAKE. - Use AM_PROG_LIBTOOL (automake 1.4 compatibility). - * acconfig.h: Don't #undef PACKAGE or VERSION. - -1999-08-09 Anthony Green - - * include/ffi.h.in: Try to work around messy header problem - with PACKAGE and VERSION. - - * configure: Rebuilt. - * configure.in: Change version to 2.00-beta. - - * fficonfig.h.in: Rebuilt. - * acconfig.h (FFI_NO_STRUCTS, FFI_NO_RAW_API): Define. - - * src/x86/ffi.c (ffi_raw_call): Rename. - -1999-08-02 Kresten Krab Thorup - - * src/x86/ffi.c (ffi_closure_SYSV): New function. - (ffi_prep_incoming_args_SYSV): Ditto. - (ffi_prep_closure): Ditto. - (ffi_closure_raw_SYSV): Ditto. - (ffi_prep_raw_closure): More ditto. - (ffi_call_raw): Final ditto. - - * include/ffi.h.in: Add definitions for closure and raw API. - - * src/x86/ffi.c (ffi_prep_cif_machdep): Added case for - FFI_TYPE_UINT64. - - * Makefile.am (libffi_la_common_SOURCES): Added raw_api.c - - * src/raw_api.c: New file. - - * include/ffi.h.in (ffi_raw): New type. - (UINT_ARG, SINT_ARG): New defines. - (ffi_closure, ffi_raw_closure): New types. - (ffi_prep_closure, ffi_prep_raw_closure): New declarations. - - * configure.in: Add check for endianness and sizeof void*. - - * src/x86/sysv.S (ffi_call_SYSV): Call fixup routine via argument, - instead of directly. - - * configure: Rebuilt. - -Thu Jul 8 14:28:42 1999 Anthony Green - - * configure.in: Add x86 and powerpc BeOS configurations. - From Makoto Kato . - -1999-05-09 Anthony Green - - * configure.in: Add warning about this being beta code. - Remove src/Makefile.am from the picture. - * configure: Rebuilt. - - * Makefile.am: Move logic from src/Makefile.am. Add changes - to support libffi as a target library. - * Makefile.in: Rebuilt. - - * aclocal.m4, config.guess, config.sub, ltconfig, ltmain.sh: - Upgraded to new autoconf, automake, libtool. - - * README: Tweaks. - - * LICENSE: Update copyright date. - - * src/Makefile.am, src/Makefile.in: Removed. - -1998-11-29 Anthony Green - - * include/ChangeLog: Removed. - * src/ChangeLog: Removed. - * src/mips/ChangeLog: Removed. - * src/sparc/ChangeLog: Remboved. - * src/x86/ChangeLog: Removed. - - * ChangeLog.v1: Created. diff --git a/user/mpy/lib/libffi/ChangeLog.libgcj b/user/mpy/lib/libffi/ChangeLog.libgcj deleted file mode 100644 index ea5d02f..0000000 --- a/user/mpy/lib/libffi/ChangeLog.libgcj +++ /dev/null @@ -1,40 +0,0 @@ -2004-01-14 Kelley Cook - - * configure.in: Add in AC_PREREQ(2.13) - -2003-02-20 Alexandre Oliva - - * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to - config.status. - * configure: Rebuilt. - -2002-01-27 Alexandre Oliva - - * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST. - Remove USE_LIBDIR conditional. - * Makefile.am (toolexecdir, toolexeclibdir): Don't override. - * Makefile.in, configure: Rebuilt. - -Mon Aug 9 18:33:38 1999 Rainer Orth - - * include/Makefile.in: Rebuilt. - * Makefile.in: Rebuilt - * Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native - builds. - Use USE_LIBDIR. - - * configure: Rebuilt. - * configure.in (USE_LIBDIR): Define for native builds. - Use lowercase in configure --help explanations. - -1999-08-08 Anthony Green - - * include/ffi.h.in (FFI_FN): Remove `...'. - -1999-08-08 Anthony Green - - * Makefile.in: Rebuilt. - * Makefile.am (AM_CFLAGS): Compile with -fexceptions. - - * src/x86/sysv.S: Add exception handling metadata. - diff --git a/user/mpy/lib/libffi/ChangeLog.v1 b/user/mpy/lib/libffi/ChangeLog.v1 deleted file mode 100644 index af3a377..0000000 --- a/user/mpy/lib/libffi/ChangeLog.v1 +++ /dev/null @@ -1,764 +0,0 @@ -The libffi version 1 ChangeLog archive. - -Version 1 of libffi had per-directory ChangeLogs. Current and future -versions have a single ChangeLog file in the root directory. The -version 1 ChangeLogs have all been concatenated into this file for -future reference only. - ---- libffi ---------------------------------------------------------------- - -Mon Oct 5 02:17:50 1998 Anthony Green - - * configure.in: Boosted rev. - * configure, Makefile.in, aclocal.m4: Rebuilt. - * README: Boosted rev and updated release notes. - -Mon Oct 5 01:03:03 1998 Anthony Green - - * configure.in: Boosted rev. - * configure, Makefile.in, aclocal.m4: Rebuilt. - * README: Boosted rev and updated release notes. - -1998-07-25 Andreas Schwab - - * m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags. - Correctly handle small structures. - (ffi_prep_args): Also handle small structures. - (ffi_call): Pass size of return type to ffi_call_SYSV. - * m68k/sysv.S: Adjust for above changes. Correctly align small - structures in the return value. - - * types.c (uint64, sint64) [M68K]: Change alignment to 4. - -Fri Apr 17 17:26:58 1998 Anthony Green - - * configure.in: Boosted rev. - * configure,Makefile.in,aclocal.m4: Rebuilt. - * README: Boosted rev and added release notes. - -Sun Feb 22 00:50:41 1998 Geoff Keating - - * configure.in: Add PowerPC config bits. - -1998-02-14 Andreas Schwab - - * configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM - to AC_CANONICAL_HOST, this is not a compiler. Use $host instead - of $target. Remove AC_CHECK_SIZEOF(char), we already know the - result. Fix argument of AC_ARG_ENABLE. - * configure, fficonfig.h.in: Rebuilt. - -Tue Feb 10 20:53:40 1998 Richard Henderson - - * configure.in: Add Alpha config bits. - -Tue May 13 13:39:20 1997 Anthony Green - - * README: Updated dates and reworded Irix comments. - - * configure.in: Removed AC_PROG_RANLIB. - - * Makefile.in, aclocal.m4, config.guess, config.sub, configure, - ltmain.sh, */Makefile.in: libtoolized again and rebuilt with - automake and autoconf. - -Sat May 10 18:44:50 1997 Tom Tromey - - * configure, aclocal.m4: Rebuilt. - * configure.in: Don't compute EXTRADIST; now handled in - src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE. - Don't run AM_MAINTAINER_MODE. - -Thu May 8 14:34:05 1997 Anthony Green - - * missing, ltmain.sh, ltconfig.sh: Created. These are new files - required by automake and libtool. - - * README: Boosted rev to 1.14. Added notes. - - * acconfig.h: Moved PACKAGE and VERSION for new automake. - - * configure.in: Changes for libtool. - - * Makefile.am (check): make test now make check. Uses libtool now. - - * Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt. - -Thu May 1 16:27:07 1997 Anthony Green - - * missing: Added file required by new automake. - -Tue Nov 26 14:10:42 1996 Anthony Green - - * acconfig.h: Added USING_PURIFY flag. This is defined when - --enable-purify-safety was used at configure time. - - * configure.in (allsources): Added --enable-purify-safety switch. - (VERSION): Boosted rev to 1.13. - * configure: Rebuilt. - -Fri Nov 22 06:46:12 1996 Anthony Green - - * configure.in (VERSION): Boosted rev to 1.12. - Removed special CFLAGS hack for gcc. - * configure: Rebuilt. - - * README: Boosted rev to 1.12. Added notes. - - * Many files: Cygnus Support changed to Cygnus Solutions. - -Wed Oct 30 11:15:25 1996 Anthony Green - - * configure.in (VERSION): Boosted rev to 1.11. - * configure: Rebuilt. - - * README: Boosted rev to 1.11. Added notes about GNU make. - -Tue Oct 29 12:25:12 1996 Anthony Green - - * configure.in: Fixed -Wall trick. - (VERSION): Boosted rev. - * configure: Rebuilt - - * acconfig.h: Needed for --enable-debug configure switch. - - * README: Boosted rev to 1.09. Added more notes on building - libffi, and LCLint. - - * configure.in: Added --enable-debug switch. Boosted rev to - 1.09. - * configure: Rebuilt - -Tue Oct 15 13:11:28 1996 Anthony Green - - * configure.in (VERSION): Boosted rev to 1.08 - * configure: Rebuilt. - - * README: Added n32 bug fix notes. - - * Makefile.am: Added "make lint" production. - * Makefile.in: Rebuilt. - -Mon Oct 14 10:54:46 1996 Anthony Green - - * README: Added web page reference. - - * configure.in, README: Boosted rev to 1.05 - * configure: Rebuilt. - - * README: Fixed n32 sample code. - -Fri Oct 11 17:09:28 1996 Anthony Green - - * README: Added sparc notes. - - * configure.in, README: Boosted rev to 1.04. - * configure: Rebuilt. - -Thu Oct 10 10:31:03 1996 Anthony Green - - * configure.in, README: Boosted rev to 1.03. - * configure: Rebuilt. - - * README: Added struct notes. - - * Makefile.am (EXTRA_DIST): Added LICENSE to distribution. - * Makefile.in: Rebuilt. - - * README: Removed Linux section. No special notes now - because aggregates arg/return types work. - -Wed Oct 9 16:16:42 1996 Anthony Green - - * README, configure.in (VERSION): Boosted rev to 1.02 - * configure: Rebuilt. - -Tue Oct 8 11:56:33 1996 Anthony Green - - * README (NOTE): Added n32 notes. - - * Makefile.am: Added test production. - * Makefile: Rebuilt - - * README: spell checked! - - * configure.in (VERSION): Boosted rev to 1.01 - * configure: Rebuilt. - -Mon Oct 7 15:50:22 1996 Anthony Green - - * configure.in: Added nasty bit to support SGI tools. - * configure: Rebuilt. - - * README: Added SGI notes. Added note about automake bug. - -Mon Oct 7 11:00:28 1996 Anthony Green - - * README: Rewrote intro, and fixed examples. - -Fri Oct 4 10:19:55 1996 Anthony Green - - * configure.in: -D$TARGET is no longer used as a compiler switch. - It is now inserted into ffi.h at configure time. - * configure: Rebuilt. - - * FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status. - -Thu Oct 3 13:47:34 1996 Anthony Green - - * README, LICENSE: Created. Wrote some docs. - - * configure.in: Don't barf on i586-unknown-linuxaout. - Added EXTRADIST code for "make dist". - * configure: Rebuilt. - - * */Makefile.in: Rebuilt with patched automake. - -Tue Oct 1 17:12:25 1996 Anthony Green - - * Makefile.am, aclocal.m4, config.guess, config.sub, - configure.in, fficonfig.h.in, install-sh, mkinstalldirs, - stamp-h.in: Created - * Makefile.in, configure: Generated - ---- libffi/include -------------------------------------------------------- - -Tue Feb 24 13:09:36 1998 Anthony Green - - * ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on - ffi.h.in changes. This is a work-around for SGI's "simple" - assembler. - -Sun Feb 22 00:51:55 1998 Geoff Keating - - * ffi.h.in: PowerPC support. - -1998-02-14 Andreas Schwab - - * ffi.h.in: Add m68k support. - (FFI_TYPE_LONGDOUBLE): Make it a separate value. - -Tue Feb 10 20:55:16 1998 Richard Henderson - - * ffi.h.in (SIZEOF_ARG): Use a pointer type by default. - - * ffi.h.in: Alpha support. - -Fri Nov 22 06:48:45 1996 Anthony Green - - * ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions. - -Wed Nov 20 22:31:01 1996 Anthony Green - - * ffi.h.in: Added ffi_type_void definition. - -Tue Oct 29 12:22:40 1996 Anthony Green - - * Makefile.am (hack_DATA): Always install ffi_mips.h. - - * ffi.h.in: Removed FFI_DEBUG. It's now in the correct - place (acconfig.h). - Added #include for size_t definition. - -Tue Oct 15 17:23:35 1996 Anthony Green - - * ffi.h.in, ffi_common.h, ffi_mips.h: More clean up. - Commented out #define of FFI_DEBUG. - -Tue Oct 15 13:01:06 1996 Anthony Green - - * ffi_common.h: Added bool definition. - - * ffi.h.in, ffi_common.h: Clean up based on LCLint output. - Added funny /*@...@*/ comments to annotate source. - -Mon Oct 14 12:29:23 1996 Anthony Green - - * ffi.h.in: Interface changes based on feedback from Jim - Blandy. - -Fri Oct 11 16:49:35 1996 Anthony Green - - * ffi.h.in: Small change for sparc support. - -Thu Oct 10 14:53:37 1996 Anthony Green - - * ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for - special structure return types. - -Wed Oct 9 13:55:57 1996 Anthony Green - - * ffi.h.in: Added SIZEOF_ARG definition for X86 - -Tue Oct 8 11:40:36 1996 Anthony Green - - * ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings. - Use it to case your function pointers to the proper type. - - * ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug. - - * Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST. - * Makefile: Rebuilt. - - * ffi_mips.h: Created. Moved all common mips definitions here. - -Mon Oct 7 10:58:12 1996 Anthony Green - - * ffi.h.in: The SGI assember is very picky about parens. Redefined - some macros to avoid problems. - - * ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added - externs for pointer, and 64bit integral ffi_types. - -Fri Oct 4 09:51:37 1996 Anthony Green - - * ffi.h.in: Added FFI_ABI member to ffi_cif and changed - function prototypes accordingly. - Added #define @TARGET@. Now programs including ffi.h don't - have to specify this themselves. - -Thu Oct 3 15:36:44 1996 Anthony Green - - * ffi.h.in: Changed ffi_prep_cif's values from void* to void** - - * Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist" - to work. - * Makefile.in: Regenerated. - -Wed Oct 2 10:16:59 1996 Anthony Green - - * Makefile.am: Created - * Makefile.in: Generated - - * ffi_common.h: Added rcsid comment - -Tue Oct 1 17:13:51 1996 Anthony Green - - * ffi.h.in, ffi_common.h: Created - ---- libffi/src ------------------------------------------------------------ - -Mon Oct 5 02:17:50 1998 Anthony Green - - * arm/ffi.c, arm/sysv.S: Created. - - * Makefile.am: Added arm files. - * Makefile.in: Rebuilt. - -Mon Oct 5 01:41:38 1998 Anthony Green - - * Makefile.am (libffi_la_LDFLAGS): Incremented revision. - -Sun Oct 4 16:27:17 1998 Anthony Green - - * alpha/osf.S (ffi_call_osf): Patch for DU assembler. - - * ffitest.c (main): long long and long double return values work - for x86. - -Fri Apr 17 11:50:58 1998 Anthony Green - - * Makefile.in: Rebuilt. - - * ffitest.c (main): Floating point tests not executed for systems - with broken lond double (SunOS 4 w/ GCC). - - * types.c: Fixed x86 alignment info for long long types. - -Thu Apr 16 07:15:28 1998 Anthony Green - - * ffitest.c: Added more notes about GCC bugs under Irix 6. - -Wed Apr 15 08:42:22 1998 Anthony Green - - * ffitest.c (struct5): New test function. - (main): New test with struct5. - -Thu Mar 5 10:48:11 1998 Anthony Green - - * prep_cif.c (initialize_aggregate): Fix assertion for - nested structures. - -Tue Feb 24 16:33:41 1998 Anthony Green - - * prep_cif.c (ffi_prep_cif): Added long double support for sparc. - -Sun Feb 22 00:52:18 1998 Geoff Keating - - * powerpc/asm.h: New file. - * powerpc/ffi.c: New file. - * powerpc/sysv.S: New file. - * Makefile.am: PowerPC port. - * ffitest.c (main): Allow all tests to run even in presence of gcc - bug on PowerPC. - -1998-02-17 Anthony Green - - * mips/ffi.c: Fixed comment typo. - - * x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat): - Fixed x86 long double return handling. - - * types.c: Fixed x86 long double alignment info. - -1998-02-14 Andreas Schwab - - * types.c: Add m68k support. - - * ffitest.c (floating): Add long double parameter. - (return_ll, ldblit): New functions to test long long and long - double return value. - (main): Fix type error in assignment of ts[1-4]_type.elements. - Add tests for long long and long double arguments and return - values. - - * prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for - struct value pointer. - - * m68k/ffi.c, m68k/sysv.S: New files. - * Makefile.am: Add bits for m68k port. Add kludge to work around - automake deficiency. - (test): Don't require "." in $PATH. - * Makefile.in: Rebuilt. - -Wed Feb 11 07:36:50 1998 Anthony Green - - * Makefile.in: Rebuilt. - -Tue Feb 10 20:56:00 1998 Richard Henderson - - * alpha/ffi.c, alpha/osf.S: New files. - * Makefile.am: Alpha port. - -Tue Nov 18 14:12:07 1997 Anthony Green - - * mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag - for n32. - -Tue Jun 3 17:18:20 1997 Anthony Green - - * ffitest.c (main): Added hack to get structure tests working - correctly. - -Sat May 10 19:06:42 1997 Tom Tromey - - * Makefile.in: Rebuilt. - * Makefile.am (EXTRA_DIST): Explicitly list all distributable - files in subdirs. - (VERSION, CC): Removed. - -Thu May 8 17:19:01 1997 Anthony Green - - * Makefile.am: Many changes for new automake and libtool. - * Makefile.in: Rebuilt. - -Fri Nov 22 06:57:56 1996 Anthony Green - - * ffitest.c (main): Fixed test case for non mips machines. - -Wed Nov 20 22:31:59 1996 Anthony Green - - * types.c: Added ffi_type_void declaration. - -Tue Oct 29 13:07:19 1996 Anthony Green - - * ffitest.c (main): Fixed character constants. - (main): Emit warning for structure test 3 failure on Sun. - - * Makefile.am (VPATH): Fixed VPATH def'n so automake won't - strip it out. - Moved distdir hack from libffi to automake. - (ffitest): Added missing -c for $(COMPILE) (change in automake). - * Makefile.in: Rebuilt. - -Tue Oct 15 13:08:20 1996 Anthony Green - - * Makefile.am: Added "make lint" production. - * Makefile.in: Rebuilt. - - * prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro. - Clean up based on LCLint output. Added funny /*@...@*/ comments to - annotate source. - - * ffitest.c, debug.c: Cleaned up code. - -Mon Oct 14 12:26:56 1996 Anthony Green - - * ffitest.c: Changes based on interface changes. - - * prep_cif.c (ffi_prep_cif): Cleaned up interface based on - feedback from Jim Blandy. - -Fri Oct 11 15:53:18 1996 Anthony Green - - * ffitest.c: Reordered tests while porting to sparc. - Made changes to handle lame structure passing for sparc. - Removed calls to fflush(). - - * prep_cif.c (ffi_prep_cif): Added special case for sparc - aggregate type arguments. - -Thu Oct 10 09:56:51 1996 Anthony Green - - * ffitest.c (main): Added structure passing/returning tests. - - * prep_cif.c (ffi_prep_cif): Perform proper initialization - of structure return types if needed. - (initialize_aggregate): Bug fix - -Wed Oct 9 16:04:20 1996 Anthony Green - - * types.c: Added special definitions for x86 (double doesn't - need double word alignment). - - * ffitest.c: Added many tests - -Tue Oct 8 09:19:22 1996 Anthony Green - - * prep_cif.c (ffi_prep_cif): Fixed assertion. - - * debug.c (ffi_assert): Must return a non void now. - - * Makefile.am: Added test production. - * Makefile: Rebuilt. - - * ffitest.c (main): Created. - - * types.c: Created. Stripped common code out of */ffi.c. - - * prep_cif.c: Added missing stdlib.h include. - - * debug.c (ffi_type_test): Used "a" to eliminate compiler - warnings in non-debug builds. Included ffi_common.h. - -Mon Oct 7 15:36:42 1996 Anthony Green - - * Makefile.am: Added a rule for .s -> .o - This is required by the SGI compiler. - * Makefile: Rebuilt. - -Fri Oct 4 09:51:08 1996 Anthony Green - - * prep_cif.c (initialize_aggregate): Moved abi specification - to ffi_prep_cif(). - -Thu Oct 3 15:37:37 1996 Anthony Green - - * prep_cif.c (ffi_prep_cif): Changed values from void* to void**. - (initialize_aggregate): Fixed aggregate type initialization. - - * Makefile.am (EXTRA_DIST): Added support code for "make dist". - * Makefile.in: Regenerated. - -Wed Oct 2 11:41:57 1996 Anthony Green - - * debug.c, prep_cif: Created. - - * Makefile.am: Added debug.o and prep_cif.o to OBJ. - * Makefile.in: Regenerated. - - * Makefile.am (INCLUDES): Added missing -I../include - * Makefile.in: Regenerated. - -Tue Oct 1 17:11:51 1996 Anthony Green - - * error.c, Makefile.am: Created. - * Makefile.in: Generated. - ---- libffi/src/x86 -------------------------------------------------------- - -Sun Oct 4 16:27:17 1998 Anthony Green - - * sysv.S (retlongdouble): Fixed long long return value support. - * ffi.c (ffi_prep_cif_machdep): Ditto. - -Wed May 13 04:30:33 1998 Anthony Green - - * ffi.c (ffi_prep_cif_machdep): Fixed long double return value - support. - -Wed Apr 15 08:43:20 1998 Anthony Green - - * ffi.c (ffi_prep_args): small struct support was missing. - -Thu May 8 16:53:58 1997 Anthony Green - - * objects.mak: Removed. - -Mon Dec 2 15:12:58 1996 Tom Tromey - - * sysv.S: Use .balign, for a.out Linux boxes. - -Tue Oct 15 13:06:50 1996 Anthony Green - - * ffi.c: Clean up based on LCLint output. - Added funny /*@...@*/ comments to annotate source. - -Fri Oct 11 16:43:38 1996 Anthony Green - - * ffi.c (ffi_call): Added assertion for bad ABIs. - -Wed Oct 9 13:57:27 1996 Anthony Green - - * sysv.S (retdouble): Fixed double return problems. - - * ffi.c (ffi_call): Corrected fn arg definition. - (ffi_prep_cif_machdep): Fixed double return problems - -Tue Oct 8 12:12:49 1996 Anthony Green - - * ffi.c: Moved ffi_type definitions to types.c. - (ffi_prep_args): Fixed type promotion bug. - -Mon Oct 7 15:53:06 1996 Anthony Green - - * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' - -Fri Oct 4 09:54:53 1996 Anthony Green - - * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped - remaining args. - -Wed Oct 2 10:07:05 1996 Anthony Green - - * ffi.c, sysv.S, objects.mak: Created. - (ffi_prep_cif): cif->rvalue no longer initialized to NULL. - (ffi_prep_cif_machdep): Moved machine independent cif processing - to src/prep_cif.c. Introduced ffi_prep_cif_machdep(). - ---- libffi/src/mips ------------------------------------------------------- - -Tue Feb 17 17:18:07 1998 Anthony Green - - * o32.S: Fixed typo in comment. - - * ffi.c (ffi_prep_cif_machdep): Fixed argument processing. - -Thu May 8 16:53:58 1997 Anthony Green - - * o32.s, n32.s: Wrappers for SGI tool support. - - * objects.mak: Removed. - -Tue Oct 29 14:37:45 1996 Anthony Green - - * ffi.c (ffi_prep_args): Changed int z to size_t z. - -Tue Oct 15 13:17:25 1996 Anthony Green - - * n32.S: Fixed bad stack munging. - - * ffi.c: Moved prototypes for ffi_call_?32() to here from - ffi_mips.h because extended_cif is not defined in ffi_mips.h. - -Mon Oct 14 12:42:02 1996 Anthony Green - - * ffi.c: Interface changes based on feedback from Jim Blandy. - -Thu Oct 10 11:22:16 1996 Anthony Green - - * n32.S, ffi.c: Lots of changes to support passing and - returning structures with the n32 calling convention. - - * n32.S: Fixed fn pointer bug. - - * ffi.c (ffi_prep_cif_machdep): Fix for o32 structure - return values. - (ffi_prep_args): Fixed n32 structure passing when structures - partially fit in registers. - -Wed Oct 9 13:49:25 1996 Anthony Green - - * objects.mak: Added n32.o. - - * n32.S: Created. - - * ffi.c (ffi_prep_args): Added magic to support proper - n32 processing. - -Tue Oct 8 10:37:35 1996 Anthony Green - - * ffi.c: Moved ffi_type definitions to types.c. - (ffi_prep_args): Fixed type promotion bug. - - * o32.S: This code is only built for o32 compiles. - A lot of the #define cruft has moved to ffi_mips.h. - - * ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg - is only processed if the first is either a float or double. - -Mon Oct 7 15:33:59 1996 Anthony Green - - * o32.S: Modified to compile under each of o32, n32 and n64. - - * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' - -Fri Oct 4 09:53:25 1996 Anthony Green - - * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped - remaining args. - -Wed Oct 2 17:41:22 1996 Anthony Green - - * o32.S: Removed crufty definitions. - -Wed Oct 2 12:53:42 1996 Anthony Green - - * ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL. - (ffi_prep_cif_machdep): Moved all machine independent cif processing - to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types - of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT. - -Tue Oct 1 17:11:02 1996 Anthony Green - - * ffi.c, o32.S, object.mak: Created - ---- libffi/src/sparc ------------------------------------------------------ - -Tue Feb 24 16:33:18 1998 Anthony Green - - * ffi.c (ffi_prep_args): Added long double support. - -Thu May 8 16:53:58 1997 Anthony Green - - * objects.mak: Removed. - -Thu May 1 16:07:56 1997 Anthony Green - - * v8.S: Fixed minor portability problem reported by - Russ McManus . - -Tue Nov 26 14:12:43 1996 Anthony Green - - * v8.S: Used STACKFRAME define elsewhere. - - * ffi.c (ffi_prep_args): Zero out space when USING_PURIFY - is set. - (ffi_prep_cif_machdep): Allocate the correct stack frame - space for functions with < 6 args. - -Tue Oct 29 15:08:55 1996 Anthony Green - - * ffi.c (ffi_prep_args): int z is now size_t z. - -Mon Oct 14 13:31:24 1996 Anthony Green - - * v8.S (ffi_call_V8): Gordon rewrites this again. It looks - great now. - - * ffi.c (ffi_call): The comment about hijacked registers - is no longer valid after gordoni hacked v8.S. - - * v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler. - - * v8.S, ffi.c: ffi_call() had changed to accept more than - two args, so v8.S had to change (because it hijacks incoming - arg registers). - - * ffi.c: Interface changes based on feedback from Jim Blandy. - -Thu Oct 10 17:48:16 1996 Anthony Green - - * ffi.c, v8.S, objects.mak: Created. - - diff --git a/user/mpy/lib/libffi/LICENSE b/user/mpy/lib/libffi/LICENSE deleted file mode 100644 index a66fab4..0000000 --- a/user/mpy/lib/libffi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -libffi - Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others. -See source files for details. - -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. diff --git a/user/mpy/lib/libffi/Makefile.am b/user/mpy/lib/libffi/Makefile.am deleted file mode 100644 index 6fb3d47..0000000 --- a/user/mpy/lib/libffi/Makefile.am +++ /dev/null @@ -1,174 +0,0 @@ -## Process this with automake to create Makefile.in - -AUTOMAKE_OPTIONS = foreign subdir-objects - -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = include testsuite man - -EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \ - ChangeLog.libffi ChangeLog.libffi-3.1 \ - m4/libtool.m4 m4/lt~obsolete.m4 \ - m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ - m4/ltversion.m4 src/debug.c msvcc.sh \ - generate-darwin-source-and-headers.py \ - libffi.xcodeproj/project.pbxproj \ - libtool-ldflags - -info_TEXINFOS = doc/libffi.texi - -## ################################################################ - -## -## This section is for make and multilib madness. -## - -# Work around what appears to be a GNU make bug handling MAKEFLAGS -# values defined in terms of make variables, as is the case for CC and -# friends when we are called from the top level Makefile. -AM_MAKEFLAGS = \ - 'AR_FLAGS=$(AR_FLAGS)' \ - 'CC_FOR_BUILD=$(CC_FOR_BUILD)' \ - 'CFLAGS=$(CFLAGS)' \ - 'CXXFLAGS=$(CXXFLAGS)' \ - 'CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)' \ - 'CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)' \ - 'INSTALL=$(INSTALL)' \ - 'INSTALL_DATA=$(INSTALL_DATA)' \ - 'INSTALL_PROGRAM=$(INSTALL_PROGRAM)' \ - 'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \ - 'JC1FLAGS=$(JC1FLAGS)' \ - 'LDFLAGS=$(LDFLAGS)' \ - 'LIBCFLAGS=$(LIBCFLAGS)' \ - 'LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)' \ - 'MAKE=$(MAKE)' \ - 'MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)' \ - 'PICFLAG=$(PICFLAG)' \ - 'PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)' \ - 'RUNTESTFLAGS=$(RUNTESTFLAGS)' \ - 'SHELL=$(SHELL)' \ - 'exec_prefix=$(exec_prefix)' \ - 'infodir=$(infodir)' \ - 'libdir=$(libdir)' \ - 'mandir=$(mandir)' \ - 'prefix=$(prefix)' \ - 'AR=$(AR)' \ - 'AS=$(AS)' \ - 'CC=$(CC)' \ - 'CXX=$(CXX)' \ - 'LD=$(LD)' \ - 'NM=$(NM)' \ - 'RANLIB=$(RANLIB)' \ - 'DESTDIR=$(DESTDIR)' - -# Subdir rules rely on $(FLAGS_TO_PASS) -FLAGS_TO_PASS = $(AM_MAKEFLAGS) - -MAKEOVERRIDES= - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libffi.pc - -toolexeclib_LTLIBRARIES = libffi.la -noinst_LTLIBRARIES = libffi_convenience.la - -libffi_la_SOURCES = src/prep_cif.c src/types.c \ - src/raw_api.c src/java_raw_api.c src/closures.c - -if FFI_DEBUG -libffi_la_SOURCES += src/debug.c -endif - -noinst_HEADERS = \ - src/aarch64/ffitarget.h src/aarch64/internal.h \ - src/alpha/ffitarget.h src/alpha/internal.h \ - src/arc/ffitarget.h \ - src/arm/ffitarget.h src/arm/internal.h \ - src/avr32/ffitarget.h \ - src/bfin/ffitarget.h \ - src/cris/ffitarget.h \ - src/frv/ffitarget.h \ - src/ia64/ffitarget.h src/ia64/ia64_flags.h \ - src/m32r/ffitarget.h \ - src/m68k/ffitarget.h \ - src/m88k/ffitarget.h \ - src/metag/ffitarget.h \ - src/microblaze/ffitarget.h \ - src/mips/ffitarget.h \ - src/moxie/ffitarget.h \ - src/nios2/ffitarget.h \ - src/or1k/ffitarget.h \ - src/pa/ffitarget.h \ - src/powerpc/ffitarget.h src/powerpc/asm.h src/powerpc/ffi_powerpc.h \ - src/s390/ffitarget.h \ - src/sh/ffitarget.h \ - src/sh64/ffitarget.h \ - src/sparc/ffitarget.h src/sparc/internal.h \ - src/tile/ffitarget.h \ - src/vax/ffitarget.h \ - src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h \ - src/xtensa/ffitarget.h \ - src/dlmalloc.c - -EXTRA_libffi_la_SOURCES = \ - src/aarch64/ffi.c src/aarch64/sysv.S \ - src/alpha/ffi.c src/alpha/osf.S \ - src/arc/ffi.c src/arc/arcompact.S \ - src/arm/ffi.c src/arm/sysv.S \ - src/avr32/ffi.c src/avr32/sysv.S \ - src/bfin/ffi.c src/bfin/sysv.S \ - src/cris/ffi.c src/cris/sysv.S \ - src/frv/ffi.c src/frv/eabi.S \ - src/ia64/ffi.c src/ia64/unix.S \ - src/m32r/ffi.c src/m32r/sysv.S \ - src/m68k/ffi.c src/m68k/sysv.S \ - src/m88k/ffi.c src/m88k/obsd.S \ - src/metag/ffi.c src/metag/sysv.S \ - src/microblaze/ffi.c src/microblaze/sysv.S \ - src/mips/ffi.c src/mips/o32.S src/mips/n32.S \ - src/moxie/ffi.c src/moxie/eabi.S \ - src/nios2/ffi.c src/nios2/sysv.S \ - src/or1k/ffi.c src/or1k/sysv.S \ - src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ - src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \ - src/powerpc/sysv.S src/powerpc/linux64.S \ - src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ - src/powerpc/aix.S src/powerpc/darwin.S src/powerpc/aix_closure.S \ - src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ - src/s390/ffi.c src/s390/sysv.S \ - src/sh/ffi.c src/sh/sysv.S \ - src/sh64/ffi.c src/sh64/sysv.S \ - src/sparc/ffi.c src/sparc/ffi64.c src/sparc/v8.S src/sparc/v9.S \ - src/tile/ffi.c src/tile/tile.S \ - src/vax/ffi.c src/vax/elfbsd.S \ - src/x86/ffi.c src/x86/sysv.S \ - src/x86/ffiw64.c src/x86/win64.S \ - src/x86/ffi64.c src/x86/unix64.S \ - src/xtensa/ffi.c src/xtensa/sysv.S - -TARGET_OBJ = @TARGET_OBJ@ -libffi_la_LIBADD = $(TARGET_OBJ) -libffi_la_DEPENDENCIES = $(TARGET_OBJ) - -libffi_convenience_la_SOURCES = $(libffi_la_SOURCES) -EXTRA_libffi_convenience_la_SOURCES = $(EXTRA_libffi_la_SOURCES) -libffi_convenience_la_LIBADD = $(libffi_la_LIBADD) -libffi_convenience_la_DEPENDENCIES = $(libffi_la_DEPENDENCIES) -nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) - -LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) - -AM_CFLAGS = -if FFI_DEBUG -# Build debug. Define FFI_DEBUG on the commandline so that, when building with -# MSVC, it can link against the debug CRT. -AM_CFLAGS += -DFFI_DEBUG -endif - -libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) - -AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src -AM_CCASFLAGS = $(AM_CPPFLAGS) - -dist-hook: - if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog diff --git a/user/mpy/lib/libffi/README b/user/mpy/lib/libffi/README deleted file mode 100644 index c072101..0000000 --- a/user/mpy/lib/libffi/README +++ /dev/null @@ -1,450 +0,0 @@ -Status -====== - -libffi-4?? was released on TBD. Check the libffi web -page for updates: . - - -What is libffi? -=============== - -Compilers for high level languages generate code that follow certain -conventions. These conventions are necessary, in part, for separate -compilation to work. One such convention is the "calling -convention". The "calling convention" is essentially a set of -assumptions made by the compiler about where function arguments will -be found on entry to a function. A "calling convention" also specifies -where the return value for a function is found. - -Some programs may not know at the time of compilation what arguments -are to be passed to a function. For instance, an interpreter may be -told at run-time about the number and types of arguments used to call -a given function. Libffi can be used in such programs to provide a -bridge from the interpreter program to compiled code. - -The libffi library provides a portable, high level programming -interface to various calling conventions. This allows a programmer to -call any function specified by a call interface description at run -time. - -FFI stands for Foreign Function Interface. A foreign function -interface is the popular name for the interface that allows code -written in one language to call code written in another language. The -libffi library really only provides the lowest, machine dependent -layer of a fully featured foreign function interface. A layer must -exist above libffi that handles type conversions for values passed -between the two languages. - - -Supported Platforms -=================== - -Libffi has been ported to many different platforms. -For specific configuration details and testing status, please -refer to the wiki page here: - - http://www.moxielogic.org/wiki/index.php?title=Libffi_3.2 - -At the time of release, the following basic configurations have been -tested: - -|-----------------+------------------+-------------------------| -| Architecture | Operating System | Compiler | -|-----------------+------------------+-------------------------| -| AArch64 (ARM64) | iOS | Clang | -| AArch64 | Linux | GCC | -| Alpha | Linux | GCC | -| Alpha | Tru64 | GCC | -| ARC | Linux | GCC | -| ARM | Linux | GCC | -| ARM | iOS | GCC | -| AVR32 | Linux | GCC | -| Blackfin | uClinux | GCC | -| HPPA | HPUX | GCC | -| IA-64 | Linux | GCC | -| M68K | FreeMiNT | GCC | -| M68K | Linux | GCC | -| M68K | RTEMS | GCC | -| M88K | OpenBSD/mvme88k | GCC | -| Meta | Linux | GCC | -| MicroBlaze | Linux | GCC | -| MIPS | IRIX | GCC | -| MIPS | Linux | GCC | -| MIPS | RTEMS | GCC | -| MIPS64 | Linux | GCC | -| Moxie | Bare metal | GCC | -| Nios II | Linux | GCC | -| OpenRISC | Linux | GCC | -| PowerPC 32-bit | AIX | IBM XL C | -| PowerPC 64-bit | AIX | IBM XL C | -| PowerPC | AMIGA | GCC | -| PowerPC | Linux | GCC | -| PowerPC | Mac OSX | GCC | -| PowerPC | FreeBSD | GCC | -| PowerPC 64-bit | FreeBSD | GCC | -| PowerPC 64-bit | Linux ELFv1 | GCC | -| PowerPC 64-bit | Linux ELFv2 | GCC | -| S390 | Linux | GCC | -| S390X | Linux | GCC | -| SPARC | Linux | GCC | -| SPARC | Solaris | GCC | -| SPARC | Solaris | Oracle Solaris Studio C | -| SPARC64 | Linux | GCC | -| SPARC64 | FreeBSD | GCC | -| SPARC64 | Solaris | Oracle Solaris Studio C | -| TILE-Gx/TILEPro | Linux | GCC | -| VAX | OpenBSD/vax | GCC | -| X86 | FreeBSD | GCC | -| X86 | GNU HURD | GCC | -| X86 | Interix | GCC | -| X86 | kFreeBSD | GCC | -| X86 | Linux | GCC | -| X86 | Mac OSX | GCC | -| X86 | OpenBSD | GCC | -| X86 | OS/2 | GCC | -| X86 | Solaris | GCC | -| X86 | Solaris | Oracle Solaris Studio C | -| X86 | Windows/Cygwin | GCC | -| X86 | Windows/MingW | GCC | -| X86-64 | FreeBSD | GCC | -| X86-64 | Linux | GCC | -| X86-64 | Linux/x32 | GCC | -| X86-64 | OpenBSD | GCC | -| X86-64 | Solaris | Oracle Solaris Studio C | -| X86-64 | Windows/Cygwin | GCC | -| X86-64 | Windows/MingW | GCC | -| Xtensa | Linux | GCC | -|-----------------+------------------+-------------------------| - -Please send additional platform test results to -libffi-discuss@sourceware.org and feel free to update the wiki page -above. - -Installing libffi -================= - -First you must configure the distribution for your particular -system. Go to the directory you wish to build libffi in and run the -"configure" program found in the root directory of the libffi source -distribution. - -If you're building libffi directly from version control, configure won't -exist yet; run ./autogen.sh first. - -You may want to tell configure where to install the libffi library and -header files. To do that, use the --prefix configure switch. Libffi -will install under /usr/local by default. - -If you want to enable extra run-time debugging checks use the the ---enable-debug configure switch. This is useful when your program dies -mysteriously while using libffi. - -Another useful configure switch is --enable-purify-safety. Using this -will add some extra code which will suppress certain warnings when you -are using Purify with libffi. Only use this switch when using -Purify, as it will slow down the library. - -It's also possible to build libffi on Windows platforms with -Microsoft's Visual C++ compiler. In this case, use the msvcc.sh -wrapper script during configuration like so: - -path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" - -For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and -CXX="path/to/msvcc.sh -m64". You may also need to specify --build -appropriately. - -It is also possible to build libffi on Windows platforms with the LLVM -project's clang-cl compiler, like below: - -path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" - -When building with MSVC under a MingW environment, you may need to -remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath' -command. ('cygpath' is not present in MingW, and is not required when -using MingW-style paths.) - -For iOS builds, the 'libffi.xcodeproj' Xcode project is available. - -Configure has many other options. Use "configure --help" to see them all. - -Once configure has finished, type "make". Note that you must be using -GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make . - -To ensure that libffi is working as advertised, type "make check". -This will require that you have DejaGNU installed. - -To install the library and header files, type "make install". - - -History -======= - -See the git log for details at http://github.com/atgreen/libffi. - -4.0 TBD - New API in support of GO closures. - -3.2.1 Nov-12-14 - Build fix for non-iOS AArch64 targets. - -3.2 Nov-11-14 - Add C99 Complex Type support (currently only supported on - s390). - Add support for PASCAL and REGISTER calling conventions on x86 - Windows/Linux. - Add OpenRISC and Cygwin-64 support. - Bug fixes. - -3.1 May-19-14 - Add AArch64 (ARM64) iOS support. - Add Nios II support. - Add m88k and DEC VAX support. - Add support for stdcall, thiscall, and fastcall on non-Windows - 32-bit x86 targets such as Linux. - Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi - fixes. - Make the testsuite more robust: eliminate several spurious - failures, and respect the $CC and $CXX environment variables. - Archive off the manually maintained ChangeLog in favor of git - log. - -3.0.13 Mar-17-13 - Add Meta support. - Add missing Moxie bits. - Fix stack alignment bug on 32-bit x86. - Build fix for m68000 targets. - Build fix for soft-float Power targets. - Fix the install dir location for some platforms when building - with GCC (OS X, Solaris). - Fix Cygwin regression. - -3.0.12 Feb-11-13 - Add Moxie support. - Add AArch64 support. - Add Blackfin support. - Add TILE-Gx/TILEPro support. - Add MicroBlaze support. - Add Xtensa support. - Add support for PaX enabled kernels with MPROTECT. - Add support for native vendor compilers on - Solaris and AIX. - Work around LLVM/GCC interoperability issue on x86_64. - -3.0.11 Apr-11-12 - Lots of build fixes. - Add support for variadic functions (ffi_prep_cif_var). - Add Linux/x32 support. - Add thiscall, fastcall and MSVC cdecl support on Windows. - Add Amiga and newer MacOS support. - Add m68k FreeMiNT support. - Integration with iOS' xcode build tools. - Fix Octeon and MC68881 support. - Fix code pessimizations. - -3.0.10 Aug-23-11 - Add support for Apple's iOS. - Add support for ARM VFP ABI. - Add RTEMS support for MIPS and M68K. - Fix instruction cache clearing problems on - ARM and SPARC. - Fix the N64 build on mips-sgi-irix6.5. - Enable builds with Microsoft's compiler. - Enable x86 builds with Oracle's Solaris compiler. - Fix support for calling code compiled with Oracle's Sparc - Solaris compiler. - Testsuite fixes for Tru64 Unix. - Additional platform support. - -3.0.9 Dec-31-09 - Add AVR32 and win64 ports. Add ARM softfp support. - Many fixes for AIX, Solaris, HP-UX, *BSD. - Several PowerPC and x86-64 bug fixes. - Build DLL for windows. - -3.0.8 Dec-19-08 - Add *BSD, BeOS, and PA-Linux support. - -3.0.7 Nov-11-08 - Fix for ppc FreeBSD. - (thanks to Andreas Tobler) - -3.0.6 Jul-17-08 - Fix for closures on sh. - Mark the sh/sh64 stack as non-executable. - (both thanks to Kaz Kojima) - -3.0.5 Apr-3-08 - Fix libffi.pc file. - Fix #define ARM for IcedTea users. - Fix x86 closure bug. - -3.0.4 Feb-24-08 - Fix x86 OpenBSD configury. - -3.0.3 Feb-22-08 - Enable x86 OpenBSD thanks to Thomas Heller, and - x86-64 FreeBSD thanks to Björn König and Andreas Tobler. - Clean up test instruction in README. - -3.0.2 Feb-21-08 - Improved x86 FreeBSD support. - Thanks to Björn König. - -3.0.1 Feb-15-08 - Fix instruction cache flushing bug on MIPS. - Thanks to David Daney. - -3.0.0 Feb-15-08 - Many changes, mostly thanks to the GCC project. - Cygnus Solutions is now Red Hat. - - [10 years go by...] - -1.20 Oct-5-98 - Raffaele Sena produces ARM port. - -1.19 Oct-5-98 - Fixed x86 long double and long long return support. - m68k bug fixes from Andreas Schwab. - Patch for DU assembler compatibility for the Alpha from Richard - Henderson. - -1.18 Apr-17-98 - Bug fixes and MIPS configuration changes. - -1.17 Feb-24-98 - Bug fixes and m68k port from Andreas Schwab. PowerPC port from - Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes. - -1.16 Feb-11-98 - Richard Henderson produces Alpha port. - -1.15 Dec-4-97 - Fixed an n32 ABI bug. New libtool, auto* support. - -1.14 May-13-97 - libtool is now used to generate shared and static libraries. - Fixed a minor portability problem reported by Russ McManus - . - -1.13 Dec-2-96 - Added --enable-purify-safety to keep Purify from complaining - about certain low level code. - Sparc fix for calling functions with < 6 args. - Linux x86 a.out fix. - -1.12 Nov-22-96 - Added missing ffi_type_void, needed for supporting void return - types. Fixed test case for non MIPS machines. Cygnus Support - is now Cygnus Solutions. - -1.11 Oct-30-96 - Added notes about GNU make. - -1.10 Oct-29-96 - Added configuration fix for non GNU compilers. - -1.09 Oct-29-96 - Added --enable-debug configure switch. Clean-ups based on LCLint - feedback. ffi_mips.h is always installed. Many configuration - fixes. Fixed ffitest.c for sparc builds. - -1.08 Oct-15-96 - Fixed n32 problem. Many clean-ups. - -1.07 Oct-14-96 - Gordon Irlam rewrites v8.S again. Bug fixes. - -1.06 Oct-14-96 - Gordon Irlam improved the sparc port. - -1.05 Oct-14-96 - Interface changes based on feedback. - -1.04 Oct-11-96 - Sparc port complete (modulo struct passing bug). - -1.03 Oct-10-96 - Passing struct args, and returning struct values works for - all architectures/calling conventions. Expanded tests. - -1.02 Oct-9-96 - Added SGI n32 support. Fixed bugs in both o32 and Linux support. - Added "make test". - -1.01 Oct-8-96 - Fixed float passing bug in mips version. Restructured some - of the code. Builds cleanly with SGI tools. - -1.00 Oct-7-96 - First release. No public announcement. - - -Authors & Credits -================= - -libffi was originally written by Anthony Green . - -The developers of the GNU Compiler Collection project have made -innumerable valuable contributions. See the ChangeLog file for -details. - -Some of the ideas behind libffi were inspired by Gianni Mariani's free -gencall library for Silicon Graphics machines. - -The closure mechanism was designed and implemented by Kresten Krab -Thorup. - -Major processor architecture ports were contributed by the following -developers: - -aarch64 Marcus Shawcroft, James Greenhalgh -alpha Richard Henderson -arm Raffaele Sena -blackfin Alexandre Keunecke I. de Mendonca -cris Simon Posnjak, Hans-Peter Nilsson -frv Anthony Green -ia64 Hans Boehm -m32r Kazuhiro Inaoka -m68k Andreas Schwab -m88k Miod Vallat -microblaze Nathan Rossi -mips Anthony Green, Casey Marshall -mips64 David Daney -moxie Anthony Green -nios ii Sandra Loosemore -openrisc Sebastian Macke -pa Randolph Chung, Dave Anglin, Andreas Tobler -powerpc Geoffrey Keating, Andreas Tobler, - David Edelsohn, John Hornkvist -powerpc64 Jakub Jelinek -s390 Gerhard Tonn, Ulrich Weigand -sh Kaz Kojima -sh64 Kaz Kojima -sparc Anthony Green, Gordon Irlam -tile-gx/tilepro Walter Lee -vax Miod Vallat -x86 Anthony Green, Jon Beniston -x86-64 Bo Thorsen -xtensa Chris Zankel - -Jesper Skov and Andrew Haley both did more than their fair share of -stepping through the code and tracking down bugs. - -Thanks also to Tom Tromey for bug fixes, documentation and -configuration help. - -Thanks to Jim Blandy, who provided some useful feedback on the libffi -interface. - -Andreas Tobler has done a tremendous amount of work on the testsuite. - -Alex Oliva solved the executable page problem for SElinux. - -The list above is almost certainly incomplete and inaccurate. I'm -happy to make corrections or additions upon request. - -If you have a problem, or have found a bug, please send a note to the -author at green@moxielogic.com, or the project mailing list at -libffi-discuss@sourceware.org. diff --git a/user/mpy/lib/libffi/acinclude.m4 b/user/mpy/lib/libffi/acinclude.m4 deleted file mode 100644 index 3e8f8ba..0000000 --- a/user/mpy/lib/libffi/acinclude.m4 +++ /dev/null @@ -1,92 +0,0 @@ -# mmap(2) blacklisting. Some platforms provide the mmap library routine -# but don't support all of the features we need from it. -AC_DEFUN([AC_FUNC_MMAP_BLACKLIST], -[ -AC_CHECK_HEADER([sys/mman.h], - [libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no]) -AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no]) -if test "$libffi_header_sys_mman_h" != yes \ - || test "$libffi_func_mmap" != yes; then - ac_cv_func_mmap_file=no - ac_cv_func_mmap_dev_zero=no - ac_cv_func_mmap_anon=no -else - AC_CACHE_CHECK([whether read-only mmap of a plain file works], - ac_cv_func_mmap_file, - [# Add a system to this blacklist if - # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a - # memory area containing the same data that you'd get if you applied - # read() to the same fd. The only system known to have a problem here - # is VMS, where text files have record structure. - case "$host_os" in - vms* | ultrix*) - ac_cv_func_mmap_file=no ;; - *) - ac_cv_func_mmap_file=yes;; - esac]) - AC_CACHE_CHECK([whether mmap from /dev/zero works], - ac_cv_func_mmap_dev_zero, - [# Add a system to this blacklist if it has mmap() but /dev/zero - # does not exist, or if mmapping /dev/zero does not give anonymous - # zeroed pages with both the following properties: - # 1. If you map N consecutive pages in with one call, and then - # unmap any subset of those pages, the pages that were not - # explicitly unmapped remain accessible. - # 2. If you map two adjacent blocks of memory and then unmap them - # both at once, they must both go away. - # Systems known to be in this category are Windows (all variants), - # VMS, and Darwin. - case "$host_os" in - vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00) - ac_cv_func_mmap_dev_zero=no ;; - *) - ac_cv_func_mmap_dev_zero=yes;; - esac]) - - # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for. - AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon, - [AC_TRY_COMPILE( -[#include -#include -#include - -#ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif -], -[int n = MAP_ANONYMOUS;], - ac_cv_decl_map_anon=yes, - ac_cv_decl_map_anon=no)]) - - if test $ac_cv_decl_map_anon = no; then - ac_cv_func_mmap_anon=no - else - AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works], - ac_cv_func_mmap_anon, - [# Add a system to this blacklist if it has mmap() and MAP_ANON or - # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) - # doesn't give anonymous zeroed pages with the same properties listed - # above for use of /dev/zero. - # Systems known to be in this category are Windows, VMS, and SCO Unix. - case "$host_os" in - vms* | cygwin* | pe | mingw* | sco* | udk* ) - ac_cv_func_mmap_anon=no ;; - *) - ac_cv_func_mmap_anon=yes;; - esac]) - fi -fi - -if test $ac_cv_func_mmap_file = yes; then - AC_DEFINE(HAVE_MMAP_FILE, 1, - [Define if read-only mmap of a plain file works.]) -fi -if test $ac_cv_func_mmap_dev_zero = yes; then - AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1, - [Define if mmap of /dev/zero works.]) -fi -if test $ac_cv_func_mmap_anon = yes; then - AC_DEFINE(HAVE_MMAP_ANON, 1, - [Define if mmap with MAP_ANON(YMOUS) works.]) -fi -]) diff --git a/user/mpy/lib/libffi/autogen.sh b/user/mpy/lib/libffi/autogen.sh deleted file mode 100755 index d270b98..0000000 --- a/user/mpy/lib/libffi/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec autoreconf -v -f -i diff --git a/user/mpy/lib/libffi/configure.ac b/user/mpy/lib/libffi/configure.ac deleted file mode 100644 index 445c589..0000000 --- a/user/mpy/lib/libffi/configure.ac +++ /dev/null @@ -1,372 +0,0 @@ -dnl Process this with autoconf to create configure - -AC_PREREQ(2.68) - -AC_INIT([libffi], [3.99999], [http://github.com/atgreen/libffi/issues]) -AC_CONFIG_HEADERS([fficonfig.h]) - -AC_CANONICAL_SYSTEM -target_alias=${target_alias-$host_alias} - -case "${host}" in - frv*-elf) - LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/ - ;; -esac - -AX_ENABLE_BUILDDIR - -AM_INIT_AUTOMAKE - -# The same as in boehm-gc and libstdc++. Have to borrow it from there. -# We must force CC to /not/ be precious variables; otherwise -# the wrong, non-multilib-adjusted value will be used in multilibs. -# As a side effect, we have to subst CFLAGS ourselves. -# Also save and restore CFLAGS, since AC_PROG_CC will come up with -# defaults of its own if none are provided. - -m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) -m4_define([_AC_ARG_VAR_PRECIOUS],[]) -save_CFLAGS=$CFLAGS -AC_PROG_CC -AC_PROG_CXX -CFLAGS=$save_CFLAGS -m4_undefine([_AC_ARG_VAR_PRECIOUS]) -m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) - -AC_SUBST(CFLAGS) - -AM_PROG_AS -AM_PROG_CC_C_O -AC_PROG_LIBTOOL -AC_CONFIG_MACRO_DIR([m4]) - -# Test for 64-bit build. -AC_CHECK_SIZEOF([size_t]) - -AX_COMPILER_VENDOR -AX_CC_MAXOPT -# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro -# compiler. -if test "$ax_cv_c_compiler_vendor" != "sun"; then - AX_CFLAGS_WARN_ALL -fi - -if test "x$GCC" = "xyes"; then - CFLAGS="$CFLAGS -fexceptions" -fi - -cat > local.exp < conftest.s - if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then - libffi_cv_as_x86_pcrel=yes - fi - ]) - if test "x$libffi_cv_as_x86_pcrel" = xyes; then - AC_DEFINE(HAVE_AS_X86_PCREL, 1, - [Define if your assembler supports PC relative relocs.]) - fi - ;; - - S390) - AC_CACHE_CHECK([compiler uses zarch features], - libffi_cv_as_s390_zarch, [ - libffi_cv_as_s390_zarch=no - echo 'void foo(void) { bar(); bar(); }' > conftest.c - if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then - if grep -q brasl conftest.s; then - libffi_cv_as_s390_zarch=yes - fi - fi - ]) - if test "x$libffi_cv_as_s390_zarch" = xyes; then - AC_DEFINE(HAVE_AS_S390_ZARCH, 1, - [Define if the compiler uses zarch features.]) - fi - ;; -esac - -# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. -AC_ARG_ENABLE(pax_emutramp, - [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC], - if test "$enable_pax_emutramp" = "yes"; then - AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1, - [Define this if you want to enable pax emulated trampolines]) - fi) - -LT_SYS_SYMBOL_USCORE -if test "x$sys_symbol_underscore" = xyes; then - AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.]) -fi - -FFI_EXEC_TRAMPOLINE_TABLE=0 -case "$target" in - *arm*-apple-darwin* | aarch64-apple-darwin*) - FFI_EXEC_TRAMPOLINE_TABLE=1 - AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1, - [Cannot use PROT_EXEC on this target, so, we revert to - alternative means]) - ;; - *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*) - AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, - [Cannot use malloc on this target, so, we revert to - alternative means]) - ;; -esac -AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1) -AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE) - -if test x$TARGET = xX86_64; then - AC_CACHE_CHECK([toolchain supports unwind section type], - libffi_cv_as_x86_64_unwind_section_type, [ - cat > conftest1.s << EOF -.text -.globl foo -foo: -jmp bar -.section .eh_frame,"a",@unwind -bar: -EOF - - cat > conftest2.c << EOF -extern void foo(); -int main(){foo();} -EOF - - libffi_cv_as_x86_64_unwind_section_type=no - # we ensure that we can compile _and_ link an assembly file containing an @unwind section - # since the compiler can support it and not the linker (ie old binutils) - if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \ - $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then - libffi_cv_as_x86_64_unwind_section_type=yes - fi - ]) - if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then - AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1, - [Define if your assembler supports unwind section type.]) - fi -fi - -if test "x$GCC" = "xyes"; then - AC_CACHE_CHECK([whether .eh_frame section should be read-only], - libffi_cv_ro_eh_frame, [ - libffi_cv_ro_eh_frame=no - echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c - if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then - objdump -h conftest.o > conftest.dump 2>&1 - libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` - if test "x$libffi_eh_frame_line" != "x"; then - libffi_test_line=`expr $libffi_eh_frame_line + 1`p - sed -n $libffi_test_line conftest.dump > conftest.line - if grep READONLY conftest.line > /dev/null; then - libffi_cv_ro_eh_frame=yes - fi - fi - fi - rm -f conftest.* - ]) - if test "x$libffi_cv_ro_eh_frame" = xyes; then - AC_DEFINE(HAVE_RO_EH_FRAME, 1, - [Define if .eh_frame sections should be read-only.]) - AC_DEFINE(EH_FRAME_FLAGS, "a", - [Define to the flags needed for the .section .eh_frame directive. ]) - else - AC_DEFINE(EH_FRAME_FLAGS, "aw", - [Define to the flags needed for the .section .eh_frame directive. ]) - fi - - AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], - libffi_cv_hidden_visibility_attribute, [ - echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c - libffi_cv_hidden_visibility_attribute=no - if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - libffi_cv_hidden_visibility_attribute=yes - fi - fi - rm -f conftest.* - ]) - if test $libffi_cv_hidden_visibility_attribute = yes; then - AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1, - [Define if __attribute__((visibility("hidden"))) is supported.]) - fi -fi - -AH_BOTTOM([ -#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE -#ifdef LIBFFI_ASM -#define FFI_HIDDEN(name) .hidden name -#else -#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) -#endif -#else -#ifdef LIBFFI_ASM -#define FFI_HIDDEN(name) -#else -#define FFI_HIDDEN -#endif -#endif -]) - -AC_SUBST(TARGET) -AC_SUBST(TARGETDIR) - -changequote(<,>) -TARGET_OBJ= -for i in $SOURCES; do - TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'` -done -changequote([,]) -AC_SUBST(TARGET_OBJ) - -AC_SUBST(SHELL) - -AC_ARG_ENABLE(debug, -[ --enable-debug debugging mode], - if test "$enable_debug" = "yes"; then - AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.]) - fi) -AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") - -AC_ARG_ENABLE(structs, -[ --disable-structs omit code for struct support], - if test "$enable_structs" = "no"; then - AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.]) - fi) -AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") - -AC_ARG_ENABLE(raw-api, -[ --disable-raw-api make the raw api unavailable], - if test "$enable_raw_api" = "no"; then - AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.]) - fi) - -AC_ARG_ENABLE(purify-safety, -[ --enable-purify-safety purify-safe mode], - if test "$enable_purify_safety" = "yes"; then - AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) - fi) - -# These variables are only ever used when we cross-build to X86_WIN32. -# And we only support this with GCC, so... -if test "x$GCC" = "xyes"; then - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - toolexecdir="${exec_prefix}"/'$(target_alias)' - toolexeclibdir="${toolexecdir}"/lib - else - toolexecdir="${libdir}"/gcc-lib/'$(target_alias)' - toolexeclibdir="${libdir}" - fi - multi_os_directory=`$CC $CFLAGS -print-multi-os-directory` - case $multi_os_directory in - .) ;; # Avoid trailing /. - ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; - esac - AC_SUBST(toolexecdir) -else - toolexeclibdir="${libdir}" -fi -AC_SUBST(toolexeclibdir) - -AC_CONFIG_COMMANDS(include, [test -d include || mkdir include]) -AC_CONFIG_COMMANDS(src, [ -test -d src || mkdir src -test -d src/$TARGETDIR || mkdir src/$TARGETDIR -], [TARGETDIR="$TARGETDIR"]) - -AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) - -AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) - -AC_OUTPUT diff --git a/user/mpy/lib/libffi/configure.host b/user/mpy/lib/libffi/configure.host deleted file mode 100644 index c6f6a02..0000000 --- a/user/mpy/lib/libffi/configure.host +++ /dev/null @@ -1,259 +0,0 @@ -# configure.host -# -# This shell script handles all host based configuration for libffi. -# - -# THIS TABLE IS SORTED. KEEP IT THAT WAY. -# Most of the time we can define all the variables all at once... -case "${host}" in - aarch64*-*-*) - TARGET=AARCH64; TARGETDIR=aarch64 - SOURCES="ffi.c sysv.S" - ;; - - alpha*-*-*) - TARGET=ALPHA; TARGETDIR=alpha; - # Support 128-bit long double, changeable via command-line switch. - HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' - SOURCES="ffi.c osf.S" - ;; - - arc*-*-*) - TARGET=ARC; TARGETDIR=arc - SOURCES="ffi.c arcompact.S" - ;; - - arm*-*-*) - TARGET=ARM; TARGETDIR=arm - SOURCES="ffi.c sysv.S" - ;; - - avr32*-*-*) - TARGET=AVR32; TARGETDIR=avr32 - SOURCES="ffi.c sysv.S" - ;; - - bfin*) - TARGET=BFIN; TARGETDIR=bfin - SOURCES="ffi.c sysv.S" - ;; - - cris-*-*) - TARGET=LIBFFI_CRIS; TARGETDIR=cris - SOURCES="ffi.c sysv.S" - ;; - - frv-*-*) - TARGET=FRV; TARGETDIR=frv - SOURCES="ffi.c eabi.S" - ;; - - hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*) - TARGET=PA_LINUX; TARGETDIR=pa - SOURCES="ffi.c linux.S" - ;; - hppa*64-*-hpux*) - TARGET=PA64_HPUX; TARGETDIR=pa - ;; - hppa*-*-hpux*) - TARGET=PA_HPUX; TARGETDIR=pa - SOURCES="ffi.c hpux32.S" - ;; - - i?86-*-freebsd* | i?86-*-openbsd*) - TARGET=X86_FREEBSD; TARGETDIR=x86 - ;; - - i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix* \ - | x86_64-*-cygwin* | x86_64-*-mingw*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - TARGET=X86_WIN32 - else - TARGET=X86_WIN64 - fi - # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. - # We must also check with_cross_host to decide if this is a native - # or cross-build and select where to install dlls appropriately. - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; - else - AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; - fi - ;; - - i?86-*-darwin* | x86_64-*-darwin*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - TARGET=X86_DARWIN - else - TARGET=X86_64 - fi - ;; - - i?86-*-* | x86_64-*-* | amd64-*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - case "$host" in - *-gnux32) - TARGET=X86_64 - ;; - *) - TARGET=X86 - ;; - esac - else - TARGET=X86_64; - fi - ;; - - ia64*-*-*) - TARGET=IA64; TARGETDIR=ia64 - SOURCES="ffi.c unix.S" - ;; - - m32r*-*-*) - TARGET=M32R; TARGETDIR=m32r - SOURCES="ffi.c sysv.S" - ;; - - m68k-*-*) - TARGET=M68K; TARGETDIR=m68k - SOURCES="ffi.c sysv.S" - ;; - - m88k-*-*) - TARGET=M88K; TARGETDIR=m88k - SOURCES="ffi.c obsd.S" - ;; - - microblaze*-*-*) - TARGET=MICROBLAZE; TARGETDIR=microblaze - SOURCES="ffi.c sysv.S" - ;; - - moxie-*-*) - TARGET=MOXIE; TARGETDIR=moxie - SOURCES="ffi.c eabi.S" - ;; - - metag-*-*) - TARGET=METAG; TARGETDIR=metag - SOURCES="ffi.c sysv.S" - ;; - - mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) - TARGET=MIPS; TARGETDIR=mips - ;; - mips*-*linux* | mips*-*-openbsd*) - # Support 128-bit long double for NewABI. - HAVE_LONG_DOUBLE='defined(__mips64)' - TARGET=MIPS; TARGETDIR=mips - ;; - - nios2*-linux*) - TARGET=NIOS2; TARGETDIR=nios2 - SOURCES="ffi.c sysv.S" - ;; - - or1k*-linux*) - TARGET=OR1K; TARGETDIR=or1k - SOURCES="ffi.c sysv.S" - ;; - - powerpc*-*-linux* | powerpc-*-sysv*) - TARGET=POWERPC; TARGETDIR=powerpc - HAVE_LONG_DOUBLE_VARIANT=1 - ;; - powerpc-*-amigaos*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - powerpc-*-beos*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - powerpc-*-darwin* | powerpc64-*-darwin*) - TARGET=POWERPC_DARWIN; TARGETDIR=powerpc - ;; - powerpc-*-aix* | rs6000-*-aix*) - TARGET=POWERPC_AIX; TARGETDIR=powerpc - ;; - powerpc-*-freebsd* | powerpc-*-openbsd* | powerpc-*-netbsd*) - TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc - HAVE_LONG_DOUBLE_VARIANT=1 - ;; - powerpc64-*-freebsd*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - powerpc*-*-rtems*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - - s390-*-* | s390x-*-*) - TARGET=S390; TARGETDIR=s390 - SOURCES="ffi.c sysv.S" - ;; - - sh-*-* | sh[34]*-*-*) - TARGET=SH; TARGETDIR=sh - SOURCES="ffi.c sysv.S" - ;; - sh64-*-* | sh5*-*-*) - TARGET=SH64; TARGETDIR=sh64 - SOURCES="ffi.c sysv.S" - ;; - - sparc*-*-*) - TARGET=SPARC; TARGETDIR=sparc - SOURCES="ffi.c ffi64.c v8.S v9.S" - ;; - - tile*-*) - TARGET=TILE; TARGETDIR=tile - SOURCES="ffi.c tile.S" - ;; - - vax-*-*) - TARGET=VAX; TARGETDIR=vax - SOURCES="ffi.c elfbsd.S" - ;; - - xtensa*-*) - TARGET=XTENSA; TARGETDIR=xtensa - SOURCES="ffi.c sysv.S" - ;; -esac - -# ... but some of the cases above share configury. -case "${TARGET}" in - MIPS) - SOURCES="ffi.c o32.S n32.S" - ;; - POWERPC) - SOURCES="ffi.c ffi_sysv.c ffi_linux64.c sysv.S ppc_closure.S" - SOURCES="${SOURCES} linux64.S linux64_closure.S" - ;; - POWERPC_AIX) - SOURCES="ffi_darwin.c aix.S aix_closure.S" - ;; - POWERPC_DARWIN) - SOURCES="ffi_darwin.c darwin.S darwin_closure.S" - ;; - POWERPC_FREEBSD) - SOURCES="ffi.c ffi_sysv.c sysv.S ppc_closure.S" - ;; - X86 | X86_DARWIN | X86_FREEBSD | X86_WIN32) - SOURCES="ffi.c sysv.S" - ;; - X86_64) - SOURCES="ffi64.c unix64.S" - ;; - X86_WIN64) - SOURCES="ffiw64.c win64.S" - ;; -esac - -# If we failed to configure SOURCES, we can't do anything. -if test -z "${SOURCES}"; then - UNSUPPORTED=1 -fi diff --git a/user/mpy/lib/libffi/doc/libffi.texi b/user/mpy/lib/libffi/doc/libffi.texi deleted file mode 100644 index ff72e58..0000000 --- a/user/mpy/lib/libffi/doc/libffi.texi +++ /dev/null @@ -1,765 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename libffi.info -@settitle libffi -@setchapternewpage off -@c %**end of header - -@c Merge the standard indexes into a single one. -@syncodeindex fn cp -@syncodeindex vr cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp - -@include version.texi - -@copying - -This manual is for Libffi, a portable foreign-function interface -library. - -Copyright @copyright{} 2008, 2010, 2011 Red Hat, Inc. - -@quotation -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. A copy of the license is included in the -section entitled ``GNU General Public License''. - -@end quotation -@end copying - -@dircategory Development -@direntry -* libffi: (libffi). Portable foreign-function interface library. -@end direntry - -@titlepage -@title Libffi -@page -@vskip 0pt plus 1filll -@insertcopying -@end titlepage - - -@ifnottex -@node Top -@top libffi - -@insertcopying - -@menu -* Introduction:: What is libffi? -* Using libffi:: How to use libffi. -* Missing Features:: Things libffi can't do. -* Index:: Index. -@end menu - -@end ifnottex - - -@node Introduction -@chapter What is libffi? - -Compilers for high level languages generate code that follow certain -conventions. These conventions are necessary, in part, for separate -compilation to work. One such convention is the @dfn{calling -convention}. The calling convention is a set of assumptions made by -the compiler about where function arguments will be found on entry to -a function. A calling convention also specifies where the return -value for a function is found. The calling convention is also -sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}. -@cindex calling convention -@cindex ABI -@cindex Application Binary Interface - -Some programs may not know at the time of compilation what arguments -are to be passed to a function. For instance, an interpreter may be -told at run-time about the number and types of arguments used to call -a given function. @samp{Libffi} can be used in such programs to -provide a bridge from the interpreter program to compiled code. - -The @samp{libffi} library provides a portable, high level programming -interface to various calling conventions. This allows a programmer to -call any function specified by a call interface description at run -time. - -@acronym{FFI} stands for Foreign Function Interface. A foreign -function interface is the popular name for the interface that allows -code written in one language to call code written in another language. -The @samp{libffi} library really only provides the lowest, machine -dependent layer of a fully featured foreign function interface. A -layer must exist above @samp{libffi} that handles type conversions for -values passed between the two languages. -@cindex FFI -@cindex Foreign Function Interface - - -@node Using libffi -@chapter Using libffi - -@menu -* The Basics:: The basic libffi API. -* Simple Example:: A simple example. -* Types:: libffi type descriptions. -* Multiple ABIs:: Different passing styles on one platform. -* The Closure API:: Writing a generic function. -* Closure Example:: A closure example. -@end menu - - -@node The Basics -@section The Basics - -@samp{Libffi} assumes that you have a pointer to the function you wish -to call and that you know the number and types of arguments to pass -it, as well as the return type of the function. - -The first thing you must do is create an @code{ffi_cif} object that -matches the signature of the function you wish to call. This is a -separate step because it is common to make multiple calls using a -single @code{ffi_cif}. The @dfn{cif} in @code{ffi_cif} stands for -Call InterFace. To prepare a call interface object, use the function -@code{ffi_prep_cif}. -@cindex cif - -@findex ffi_prep_cif -@defun ffi_status ffi_prep_cif (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes}) -This initializes @var{cif} according to the given parameters. - -@var{abi} is the ABI to use; normally @code{FFI_DEFAULT_ABI} is what -you want. @ref{Multiple ABIs} for more information. - -@var{nargs} is the number of arguments that this function accepts. - -@var{rtype} is a pointer to an @code{ffi_type} structure that -describes the return type of the function. @xref{Types}. - -@var{argtypes} is a vector of @code{ffi_type} pointers. -@var{argtypes} must have @var{nargs} elements. If @var{nargs} is 0, -this argument is ignored. - -@code{ffi_prep_cif} returns a @code{libffi} status code, of type -@code{ffi_status}. This will be either @code{FFI_OK} if everything -worked properly; @code{FFI_BAD_TYPEDEF} if one of the @code{ffi_type} -objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter -is invalid. -@end defun - -If the function being called is variadic (varargs) then -@code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}. - -@findex ffi_prep_cif_var -@defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nfixedargs}, unsigned int @var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes}) -This initializes @var{cif} according to the given parameters for -a call to a variadic function. In general it's operation is the -same as for @code{ffi_prep_cif} except that: - -@var{nfixedargs} is the number of fixed arguments, prior to any -variadic arguments. It must be greater than zero. - -@var{ntotalargs} the total number of arguments, including variadic -and fixed arguments. @var{argtypes} must have this many elements. - -Note that, different cif's must be prepped for calls to the same -function when different numbers of arguments are passed. - -Also note that a call to @code{ffi_prep_cif_var} with -@var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to -@code{ffi_prep_cif}. - -@end defun - - -To call a function using an initialized @code{ffi_cif}, use the -@code{ffi_call} function: - -@findex ffi_call -@defun void ffi_call (ffi_cif *@var{cif}, void *@var{fn}, void *@var{rvalue}, void **@var{avalues}) -This calls the function @var{fn} according to the description given in -@var{cif}. @var{cif} must have already been prepared using -@code{ffi_prep_cif}. - -@var{rvalue} is a pointer to a chunk of memory that will hold the -result of the function call. This must be large enough to hold the -result, no smaller than the system register size (generally 32 or 64 -bits), and must be suitably aligned; it is the caller's responsibility -to ensure this. If @var{cif} declares that the function returns -@code{void} (using @code{ffi_type_void}), then @var{rvalue} is -ignored. - -@var{avalues} is a vector of @code{void *} pointers that point to the -memory locations holding the argument values for a call. If @var{cif} -declares that the function has no arguments (i.e., @var{nargs} was 0), -then @var{avalues} is ignored. Note that argument values may be -modified by the callee (for instance, structs passed by value); the -burden of copying pass-by-value arguments is placed on the caller. -@end defun - - -@node Simple Example -@section Simple Example - -Here is a trivial example that calls @code{puts} a few times. - -@example -#include -#include - -int main() -@{ - ffi_cif cif; - ffi_type *args[1]; - void *values[1]; - char *s; - ffi_arg rc; - - /* Initialize the argument info vectors */ - args[0] = &ffi_type_pointer; - values[0] = &s; - - /* Initialize the cif */ - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_sint, args) == FFI_OK) - @{ - s = "Hello World!"; - ffi_call(&cif, puts, &rc, values); - /* rc now holds the result of the call to puts */ - - /* values holds a pointer to the function's arg, so to - call puts() again all we need to do is change the - value of s */ - s = "This is cool!"; - ffi_call(&cif, puts, &rc, values); - @} - - return 0; -@} -@end example - - -@node Types -@section Types - -@menu -* Primitive Types:: Built-in types. -* Structures:: Structure types. -* Type Example:: Structure type example. -* Complex:: Complex types. -* Complex Type Example:: Complex type example. -@end menu - -@node Primitive Types -@subsection Primitive Types - -@code{Libffi} provides a number of built-in type descriptors that can -be used to describe argument and return types: - -@table @code -@item ffi_type_void -@tindex ffi_type_void -The type @code{void}. This cannot be used for argument types, only -for return values. - -@item ffi_type_uint8 -@tindex ffi_type_uint8 -An unsigned, 8-bit integer type. - -@item ffi_type_sint8 -@tindex ffi_type_sint8 -A signed, 8-bit integer type. - -@item ffi_type_uint16 -@tindex ffi_type_uint16 -An unsigned, 16-bit integer type. - -@item ffi_type_sint16 -@tindex ffi_type_sint16 -A signed, 16-bit integer type. - -@item ffi_type_uint32 -@tindex ffi_type_uint32 -An unsigned, 32-bit integer type. - -@item ffi_type_sint32 -@tindex ffi_type_sint32 -A signed, 32-bit integer type. - -@item ffi_type_uint64 -@tindex ffi_type_uint64 -An unsigned, 64-bit integer type. - -@item ffi_type_sint64 -@tindex ffi_type_sint64 -A signed, 64-bit integer type. - -@item ffi_type_float -@tindex ffi_type_float -The C @code{float} type. - -@item ffi_type_double -@tindex ffi_type_double -The C @code{double} type. - -@item ffi_type_uchar -@tindex ffi_type_uchar -The C @code{unsigned char} type. - -@item ffi_type_schar -@tindex ffi_type_schar -The C @code{signed char} type. (Note that there is not an exact -equivalent to the C @code{char} type in @code{libffi}; ordinarily you -should either use @code{ffi_type_schar} or @code{ffi_type_uchar} -depending on whether @code{char} is signed.) - -@item ffi_type_ushort -@tindex ffi_type_ushort -The C @code{unsigned short} type. - -@item ffi_type_sshort -@tindex ffi_type_sshort -The C @code{short} type. - -@item ffi_type_uint -@tindex ffi_type_uint -The C @code{unsigned int} type. - -@item ffi_type_sint -@tindex ffi_type_sint -The C @code{int} type. - -@item ffi_type_ulong -@tindex ffi_type_ulong -The C @code{unsigned long} type. - -@item ffi_type_slong -@tindex ffi_type_slong -The C @code{long} type. - -@item ffi_type_longdouble -@tindex ffi_type_longdouble -On platforms that have a C @code{long double} type, this is defined. -On other platforms, it is not. - -@item ffi_type_pointer -@tindex ffi_type_pointer -A generic @code{void *} pointer. You should use this for all -pointers, regardless of their real type. - -@item ffi_type_complex_float -@tindex ffi_type_complex_float -The C @code{_Complex float} type. - -@item ffi_type_complex_double -@tindex ffi_type_complex_double -The C @code{_Complex double} type. - -@item ffi_type_complex_longdouble -@tindex ffi_type_complex_longdouble -The C @code{_Complex long double} type. -On platforms that have a C @code{long double} type, this is defined. -On other platforms, it is not. -@end table - -Each of these is of type @code{ffi_type}, so you must take the address -when passing to @code{ffi_prep_cif}. - - -@node Structures -@subsection Structures - -Although @samp{libffi} has no special support for unions or -bit-fields, it is perfectly happy passing structures back and forth. -You must first describe the structure to @samp{libffi} by creating a -new @code{ffi_type} object for it. - -@tindex ffi_type -@deftp {Data type} ffi_type -The @code{ffi_type} has the following members: -@table @code -@item size_t size -This is set by @code{libffi}; you should initialize it to zero. - -@item unsigned short alignment -This is set by @code{libffi}; you should initialize it to zero. - -@item unsigned short type -For a structure, this should be set to @code{FFI_TYPE_STRUCT}. - -@item ffi_type **elements -This is a @samp{NULL}-terminated array of pointers to @code{ffi_type} -objects. There is one element per field of the struct. -@end table -@end deftp - - -@node Type Example -@subsection Type Example - -The following example initializes a @code{ffi_type} object -representing the @code{tm} struct from Linux's @file{time.h}. - -Here is how the struct is defined: - -@example -struct tm @{ - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - /* Those are for future use. */ - long int __tm_gmtoff__; - __const char *__tm_zone__; -@}; -@end example - -Here is the corresponding code to describe this struct to -@code{libffi}: - -@example - @{ - ffi_type tm_type; - ffi_type *tm_type_elements[12]; - int i; - - tm_type.size = tm_type.alignment = 0; - tm_type.type = FFI_TYPE_STRUCT; - tm_type.elements = &tm_type_elements; - - for (i = 0; i < 9; i++) - tm_type_elements[i] = &ffi_type_sint; - - tm_type_elements[9] = &ffi_type_slong; - tm_type_elements[10] = &ffi_type_pointer; - tm_type_elements[11] = NULL; - - /* tm_type can now be used to represent tm argument types and - return types for ffi_prep_cif() */ - @} -@end example - -@node Complex -@subsection Complex Types - -@samp{libffi} supports the complex types defined by the C99 -standard (@code{_Complex float}, @code{_Complex double} and -@code{_Complex long double} with the built-in type descriptors -@code{ffi_type_complex_float}, @code{ffi_type_complex_double} and -@code{ffi_type_complex_longdouble}. - -Custom complex types like @code{_Complex int} can also be used. -An @code{ffi_type} object has to be defined to describe the -complex type to @samp{libffi}. - -@tindex ffi_type -@deftp {Data type} ffi_type -@table @code -@item size_t size -This must be manually set to the size of the complex type. - -@item unsigned short alignment -This must be manually set to the alignment of the complex type. - -@item unsigned short type -For a complex type, this must be set to @code{FFI_TYPE_COMPLEX}. - -@item ffi_type **elements - -This is a @samp{NULL}-terminated array of pointers to -@code{ffi_type} objects. The first element is set to the -@code{ffi_type} of the complex's base type. The second element -must be set to @code{NULL}. -@end table -@end deftp - -The section @ref{Complex Type Example} shows a way to determine -the @code{size} and @code{alignment} members in a platform -independent way. - -For platforms that have no complex support in @code{libffi} yet, -the functions @code{ffi_prep_cif} and @code{ffi_prep_args} abort -the program if they encounter a complex type. - -@node Complex Type Example -@subsection Complex Type Example - -This example demonstrates how to use complex types: - -@example -#include -#include -#include - -void complex_fn(_Complex float cf, - _Complex double cd, - _Complex long double cld) -@{ - printf("cf=%f+%fi\ncd=%f+%fi\ncld=%f+%fi\n", - (float)creal (cf), (float)cimag (cf), - (float)creal (cd), (float)cimag (cd), - (float)creal (cld), (float)cimag (cld)); -@} - -int main() -@{ - ffi_cif cif; - ffi_type *args[3]; - void *values[3]; - _Complex float cf; - _Complex double cd; - _Complex long double cld; - - /* Initialize the argument info vectors */ - args[0] = &ffi_type_complex_float; - args[1] = &ffi_type_complex_double; - args[2] = &ffi_type_complex_longdouble; - values[0] = &cf; - values[1] = &cd; - values[2] = &cld; - - /* Initialize the cif */ - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &ffi_type_void, args) == FFI_OK) - @{ - cf = 1.0 + 20.0 * I; - cd = 300.0 + 4000.0 * I; - cld = 50000.0 + 600000.0 * I; - /* Call the function */ - ffi_call(&cif, (void (*)(void))complex_fn, 0, values); - @} - - return 0; -@} -@end example - -This is an example for defining a custom complex type descriptor -for compilers that support them: - -@example -/* - * This macro can be used to define new complex type descriptors - * in a platform independent way. - * - * name: Name of the new descriptor is ffi_type_complex_. - * type: The C base type of the complex type. - */ -#define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \ - static ffi_type *ffi_elements_complex_##name [2] = @{ \ - (ffi_type *)(&ffitype), NULL \ - @}; \ - struct struct_align_complex_##name @{ \ - char c; \ - _Complex type x; \ - @}; \ - ffi_type ffi_type_complex_##name = @{ \ - sizeof(_Complex type), \ - offsetof(struct struct_align_complex_##name, x), \ - FFI_TYPE_COMPLEX, \ - (ffi_type **)ffi_elements_complex_##name \ - @} - -/* Define new complex type descriptors using the macro: */ -/* ffi_type_complex_sint */ -FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint); -/* ffi_type_complex_uchar */ -FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8); -@end example - -The new type descriptors can then be used like one of the built-in -type descriptors in the previous example. - -@node Multiple ABIs -@section Multiple ABIs - -A given platform may provide multiple different ABIs at once. For -instance, the x86 platform has both @samp{stdcall} and @samp{fastcall} -functions. - -@code{libffi} provides some support for this. However, this is -necessarily platform-specific. - -@c FIXME: document the platforms - -@node The Closure API -@section The Closure API - -@code{libffi} also provides a way to write a generic function -- a -function that can accept and decode any combination of arguments. -This can be useful when writing an interpreter, or to provide wrappers -for arbitrary functions. - -This facility is called the @dfn{closure API}. Closures are not -supported on all platforms; you can check the @code{FFI_CLOSURES} -define to determine whether they are supported on the current -platform. -@cindex closures -@cindex closure API -@findex FFI_CLOSURES - -Because closures work by assembling a tiny function at runtime, they -require special allocation on platforms that have a non-executable -heap. Memory management for closures is handled by a pair of -functions: - -@findex ffi_closure_alloc -@defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code}) -Allocate a chunk of memory holding @var{size} bytes. This returns a -pointer to the writable address, and sets *@var{code} to the -corresponding executable address. - -@var{size} should be sufficient to hold a @code{ffi_closure} object. -@end defun - -@findex ffi_closure_free -@defun void ffi_closure_free (void *@var{writable}) -Free memory allocated using @code{ffi_closure_alloc}. The argument is -the writable address that was returned. -@end defun - - -Once you have allocated the memory for a closure, you must construct a -@code{ffi_cif} describing the function call. Finally you can prepare -the closure function: - -@findex ffi_prep_closure_loc -@defun ffi_status ffi_prep_closure_loc (ffi_closure *@var{closure}, ffi_cif *@var{cif}, void (*@var{fun}) (ffi_cif *@var{cif}, void *@var{ret}, void **@var{args}, void *@var{user_data}), void *@var{user_data}, void *@var{codeloc}) -Prepare a closure function. - -@var{closure} is the address of a @code{ffi_closure} object; this is -the writable address returned by @code{ffi_closure_alloc}. - -@var{cif} is the @code{ffi_cif} describing the function parameters. - -@var{user_data} is an arbitrary datum that is passed, uninterpreted, -to your closure function. - -@var{codeloc} is the executable address returned by -@code{ffi_closure_alloc}. - -@var{fun} is the function which will be called when the closure is -invoked. It is called with the arguments: -@table @var -@item cif -The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}. - -@item ret -A pointer to the memory used for the function's return value. -@var{fun} must fill this, unless the function is declared as returning -@code{void}. -@c FIXME: is this NULL for void-returning functions? - -@item args -A vector of pointers to memory holding the arguments to the function. - -@item user_data -The same @var{user_data} that was passed to -@code{ffi_prep_closure_loc}. -@end table - -@code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything -went ok, and something else on error. -@c FIXME: what? - -After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc} -to the appropriate pointer-to-function type. -@end defun - -You may see old code referring to @code{ffi_prep_closure}. This -function is deprecated, as it cannot handle the need for separate -writable and executable addresses. - -@node Closure Example -@section Closure Example - -A trivial example that creates a new @code{puts} by binding -@code{fputs} with @code{stdout}. - -@example -#include -#include - -/* Acts like puts with the file given at time of enclosure. */ -void puts_binding(ffi_cif *cif, void *ret, void* args[], - void *stream) -@{ - *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream); -@} - -typedef int (*puts_t)(char *); - -int main() -@{ - ffi_cif cif; - ffi_type *args[1]; - ffi_closure *closure; - - void *bound_puts; - int rc; - - /* Allocate closure and bound_puts */ - closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts); - - if (closure) - @{ - /* Initialize the argument info vectors */ - args[0] = &ffi_type_pointer; - - /* Initialize the cif */ - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_sint, args) == FFI_OK) - @{ - /* Initialize the closure, setting stream to stdout */ - if (ffi_prep_closure_loc(closure, &cif, puts_binding, - stdout, bound_puts) == FFI_OK) - @{ - rc = ((puts_t)bound_puts)("Hello World!"); - /* rc now holds the result of the call to fputs */ - @} - @} - @} - - /* Deallocate both closure, and bound_puts */ - ffi_closure_free(closure); - - return 0; -@} - -@end example - - -@node Missing Features -@chapter Missing Features - -@code{libffi} is missing a few features. We welcome patches to add -support for these. - -@itemize @bullet -@item -Variadic closures. - -@item -There is no support for bit fields in structures. - -@item -The ``raw'' API is undocumented. -@c argument promotion? -@c unions? -@c anything else? -@end itemize - -Note that variadic support is very new and tested on a relatively -small number of platforms. - -@node Index -@unnumbered Index - -@printindex cp - -@bye diff --git a/user/mpy/lib/libffi/doc/version.texi b/user/mpy/lib/libffi/doc/version.texi deleted file mode 100644 index ccef70f..0000000 --- a/user/mpy/lib/libffi/doc/version.texi +++ /dev/null @@ -1,4 +0,0 @@ -@set UPDATED 8 November 2014 -@set UPDATED-MONTH November 2014 -@set EDITION 3.2.1 -@set VERSION 3.2.1 diff --git a/user/mpy/lib/libffi/generate-darwin-source-and-headers.py b/user/mpy/lib/libffi/generate-darwin-source-and-headers.py deleted file mode 100644 index f551c35..0000000 --- a/user/mpy/lib/libffi/generate-darwin-source-and-headers.py +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env python -import subprocess -import os -import errno -import collections -import glob -import argparse - -class Platform(object): - pass - -class simulator_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphonesimulator' - arch = 'i386' - triple = 'i386-apple-darwin11' - version_min = '-miphoneos-version-min=7.0' - - prefix = "#ifdef __i386__\n\n" - suffix = "\n\n#endif" - src_dir = 'x86' - src_files = ['sysv.S', 'ffi.c'] - - -class simulator64_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphonesimulator' - arch = 'x86_64' - triple = 'x86_64-apple-darwin13' - version_min = '-miphoneos-version-min=7.0' - - prefix = "#ifdef __x86_64__\n\n" - suffix = "\n\n#endif" - src_dir = 'x86' - src_files = ['unix64.S', 'ffi64.c'] - - -class device_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphoneos' - arch = 'armv7' - triple = 'arm-apple-darwin11' - version_min = '-miphoneos-version-min=7.0' - - prefix = "#ifdef __arm__\n\n" - suffix = "\n\n#endif" - src_dir = 'arm' - src_files = ['sysv.S', 'trampoline.S', 'ffi.c'] - - -class device64_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphoneos' - arch = 'arm64' - triple = 'aarch64-apple-darwin13' - version_min = '-miphoneos-version-min=7.0' - - prefix = "#ifdef __arm64__\n\n" - suffix = "\n\n#endif" - src_dir = 'aarch64' - src_files = ['sysv.S', 'ffi.c'] - - -class desktop32_platform(Platform): - directory = 'darwin_osx' - sdk = 'macosx' - arch = 'i386' - triple = 'i386-apple-darwin10' - version_min = '-mmacosx-version-min=10.6' - src_dir = 'x86' - src_files = ['sysv.S', 'ffi.c'] - - prefix = "#ifdef __i386__\n\n" - suffix = "\n\n#endif" - - -class desktop64_platform(Platform): - directory = 'darwin_osx' - sdk = 'macosx' - arch = 'x86_64' - triple = 'x86_64-apple-darwin10' - version_min = '-mmacosx-version-min=10.6' - - prefix = "#ifdef __x86_64__\n\n" - suffix = "\n\n#endif" - src_dir = 'x86' - src_files = ['unix64.S', 'ffi64.c'] - - -def mkdir_p(path): - try: - os.makedirs(path) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST: - pass - else: - raise - - -def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''): - mkdir_p(dst_dir) - out_filename = filename - - if file_suffix: - split_name = os.path.splitext(filename) - out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1]) - - with open(os.path.join(src_dir, filename)) as in_file: - with open(os.path.join(dst_dir, out_filename), 'w') as out_file: - if prefix: - out_file.write(prefix) - - out_file.write(in_file.read()) - - if suffix: - out_file.write(suffix) - - -def list_files(src_dir, pattern=None, filelist=None): - if pattern: filelist = glob.iglob(os.path.join(src_dir, pattern)) - for file in filelist: - yield os.path.basename(file) - - -def copy_files(src_dir, dst_dir, pattern=None, filelist=None, file_suffix=None, prefix=None, suffix=None): - for filename in list_files(src_dir, pattern=pattern, filelist=filelist): - move_file(src_dir, dst_dir, filename, file_suffix=file_suffix, prefix=prefix, suffix=suffix) - - -def copy_src_platform_files(platform): - src_dir = os.path.join('src', platform.src_dir) - dst_dir = os.path.join(platform.directory, 'src', platform.src_dir) - copy_files(src_dir, dst_dir, filelist=platform.src_files, file_suffix=platform.arch, prefix=platform.prefix, suffix=platform.suffix) - - -def build_target(platform, platform_headers): - def xcrun_cmd(cmd): - return 'xcrun -sdk %s %s -arch %s' % (platform.sdk, cmd, platform.arch) - - tag='%s-%s' % (platform.sdk, platform.arch) - build_dir = 'build_%s' % tag - mkdir_p(build_dir) - env = dict(CC=xcrun_cmd('clang'), - LD=xcrun_cmd('ld'), - CFLAGS='%s' % (platform.version_min)) - working_dir = os.getcwd() - try: - os.chdir(build_dir) - subprocess.check_call(['../configure', '-host', platform.triple], env=env) - finally: - os.chdir(working_dir) - - for src_dir in [build_dir, os.path.join(build_dir, 'include')]: - copy_files(src_dir, - os.path.join(platform.directory, 'include'), - pattern='*.h', - file_suffix=platform.arch, - prefix=platform.prefix, - suffix=platform.suffix) - - for filename in list_files(src_dir, pattern='*.h'): - platform_headers[filename].add((platform.prefix, platform.arch, platform.suffix)) - - -def make_tramp(): - with open('src/arm/trampoline.S', 'w') as tramp_out: - p = subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=tramp_out) - p.wait() - - -def generate_source_and_headers(generate_osx=True, generate_ios=True): - copy_files('src', 'darwin_common/src', pattern='*.c') - copy_files('include', 'darwin_common/include', pattern='*.h') - - if generate_ios: - make_tramp() - copy_src_platform_files(simulator_platform) - copy_src_platform_files(simulator64_platform) - copy_src_platform_files(device_platform) - copy_src_platform_files(device64_platform) - if generate_osx: - copy_src_platform_files(desktop32_platform) - copy_src_platform_files(desktop64_platform) - - platform_headers = collections.defaultdict(set) - - if generate_ios: - build_target(simulator_platform, platform_headers) - build_target(simulator64_platform, platform_headers) - build_target(device_platform, platform_headers) - build_target(device64_platform, platform_headers) - if generate_osx: - build_target(desktop32_platform, platform_headers) - build_target(desktop64_platform, platform_headers) - - mkdir_p('darwin_common/include') - for header_name, tag_tuples in platform_headers.iteritems(): - basename, suffix = os.path.splitext(header_name) - with open(os.path.join('darwin_common/include', header_name), 'w') as header: - for tag_tuple in tag_tuples: - header.write('%s#include <%s_%s%s>\n%s\n' % (tag_tuple[0], basename, tag_tuple[1], suffix, tag_tuple[2])) - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument('--only-ios', action='store_true', default=False) - parser.add_argument('--only-osx', action='store_true', default=False) - args = parser.parse_args() - - generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx) diff --git a/user/mpy/lib/libffi/include/Makefile.am b/user/mpy/lib/libffi/include/Makefile.am deleted file mode 100644 index bb241e8..0000000 --- a/user/mpy/lib/libffi/include/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -## Process this with automake to create Makefile.in - -AUTOMAKE_OPTIONS=foreign - -DISTCLEANFILES=ffitarget.h -noinst_HEADERS=ffi_common.h ffi_cfi.h -EXTRA_DIST=ffi.h.in - -includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include -nodist_includes_HEADERS = ffi.h ffitarget.h diff --git a/user/mpy/lib/libffi/include/ffi.h.in b/user/mpy/lib/libffi/include/ffi.h.in deleted file mode 100644 index c43d52f..0000000 --- a/user/mpy/lib/libffi/include/ffi.h.in +++ /dev/null @@ -1,503 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - libffi @VERSION@ - Copyright (c) 2011, 2014 Anthony Green - - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. - - 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. - - ----------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------- - The basic API is described in the README file. - - The raw API is designed to bypass some of the argument packing - and unpacking on architectures for which it can be avoided. - - The closure API allows interpreted functions to be packaged up - inside a C function pointer, so that they can be called as C functions, - with no understanding on the client side that they are interpreted. - It can also be used in other cases in which it is necessary to package - up a user specified parameter and a function pointer as a single - function pointer. - - The closure API must be implemented in order to get its functionality, - e.g. for use by gij. Routines are provided to emulate the raw API - if the underlying platform doesn't allow faster implementation. - - More details on the raw and cloure API can be found in: - - http://gcc.gnu.org/ml/java/1999-q3/msg00138.html - - and - - http://gcc.gnu.org/ml/java/1999-q3/msg00174.html - -------------------------------------------------------------------- */ - -#ifndef LIBFFI_H -#define LIBFFI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Specify which architecture libffi is configured for. */ -#ifndef @TARGET@ -#define @TARGET@ -#endif - -/* ---- System configuration information --------------------------------- */ - -#include - -#ifndef LIBFFI_ASM - -#if defined(_MSC_VER) && !defined(__clang__) -#define __attribute__(X) -#endif - -#include -#include - -/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). - But we can find it either under the correct ANSI name, or under GNU - C's internal name. */ - -#define FFI_64_BIT_MAX 9223372036854775807 - -#ifdef LONG_LONG_MAX -# define FFI_LONG_LONG_MAX LONG_LONG_MAX -#else -# ifdef LLONG_MAX -# define FFI_LONG_LONG_MAX LLONG_MAX -# ifdef _AIX52 /* or newer has C99 LLONG_MAX */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif /* _AIX52 or newer */ -# else -# ifdef __GNUC__ -# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ -# endif -# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ -# ifndef __PPC64__ -# if defined (__IBMC__) || defined (__IBMCPP__) -# define FFI_LONG_LONG_MAX LONGLONG_MAX -# endif -# endif /* __PPC64__ */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif -# endif -#endif - -/* The closure code assumes that this works on pointers, i.e. a size_t */ -/* can hold a pointer. */ - -typedef struct _ffi_type -{ - size_t size; - unsigned short alignment; - unsigned short type; - struct _ffi_type **elements; -} ffi_type; - -#ifndef LIBFFI_HIDE_BASIC_TYPES -#if SCHAR_MAX == 127 -# define ffi_type_uchar ffi_type_uint8 -# define ffi_type_schar ffi_type_sint8 -#else - #error "char size not supported" -#endif - -#if SHRT_MAX == 32767 -# define ffi_type_ushort ffi_type_uint16 -# define ffi_type_sshort ffi_type_sint16 -#elif SHRT_MAX == 2147483647 -# define ffi_type_ushort ffi_type_uint32 -# define ffi_type_sshort ffi_type_sint32 -#else - #error "short size not supported" -#endif - -#if INT_MAX == 32767 -# define ffi_type_uint ffi_type_uint16 -# define ffi_type_sint ffi_type_sint16 -#elif INT_MAX == 2147483647 -# define ffi_type_uint ffi_type_uint32 -# define ffi_type_sint ffi_type_sint32 -#elif INT_MAX == 9223372036854775807 -# define ffi_type_uint ffi_type_uint64 -# define ffi_type_sint ffi_type_sint64 -#else - #error "int size not supported" -#endif - -#if LONG_MAX == 2147483647 -# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX - #error "no 64-bit data type supported" -# endif -#elif LONG_MAX != FFI_64_BIT_MAX - #error "long size not supported" -#endif - -#if LONG_MAX == 2147483647 -# define ffi_type_ulong ffi_type_uint32 -# define ffi_type_slong ffi_type_sint32 -#elif LONG_MAX == FFI_64_BIT_MAX -# define ffi_type_ulong ffi_type_uint64 -# define ffi_type_slong ffi_type_sint64 -#else - #error "long size not supported" -#endif - -/* Need minimal decorations for DLLs to works on Windows. */ -/* GCC has autoimport and autoexport. Rely on Libtool to */ -/* help MSVC export from a DLL, but always declare data */ -/* to be imported for MSVC clients. This costs an extra */ -/* indirection for MSVC clients using the static version */ -/* of the library, but don't worry about that. Besides, */ -/* as a workaround, they can define FFI_BUILDING if they */ -/* *know* they are going to link with the static library. */ -#if defined _MSC_VER && !defined FFI_BUILDING -#define FFI_EXTERN extern __declspec(dllimport) -#else -#define FFI_EXTERN extern -#endif - -/* These are defined in types.c */ -FFI_EXTERN ffi_type ffi_type_void; -FFI_EXTERN ffi_type ffi_type_uint8; -FFI_EXTERN ffi_type ffi_type_sint8; -FFI_EXTERN ffi_type ffi_type_uint16; -FFI_EXTERN ffi_type ffi_type_sint16; -FFI_EXTERN ffi_type ffi_type_uint32; -FFI_EXTERN ffi_type ffi_type_sint32; -FFI_EXTERN ffi_type ffi_type_uint64; -FFI_EXTERN ffi_type ffi_type_sint64; -FFI_EXTERN ffi_type ffi_type_float; -FFI_EXTERN ffi_type ffi_type_double; -FFI_EXTERN ffi_type ffi_type_pointer; - -#if @HAVE_LONG_DOUBLE@ -FFI_EXTERN ffi_type ffi_type_longdouble; -#else -#define ffi_type_longdouble ffi_type_double -#endif - -#ifdef FFI_TARGET_HAS_COMPLEX_TYPE -FFI_EXTERN ffi_type ffi_type_complex_float; -FFI_EXTERN ffi_type ffi_type_complex_double; -#if @HAVE_LONG_DOUBLE@ -FFI_EXTERN ffi_type ffi_type_complex_longdouble; -#else -#define ffi_type_complex_longdouble ffi_type_complex_double -#endif -#endif -#endif /* LIBFFI_HIDE_BASIC_TYPES */ - -typedef enum { - FFI_OK = 0, - FFI_BAD_TYPEDEF, - FFI_BAD_ABI -} ffi_status; - -typedef unsigned FFI_TYPE; - -typedef struct { - ffi_abi abi; - unsigned nargs; - ffi_type **arg_types; - ffi_type *rtype; - unsigned bytes; - unsigned flags; -#ifdef FFI_EXTRA_CIF_FIELDS - FFI_EXTRA_CIF_FIELDS; -#endif -} ffi_cif; - -#if @HAVE_LONG_DOUBLE_VARIANT@ -/* Used to adjust size/alignment of ffi types. */ -void ffi_prep_types (ffi_abi abi); -#endif - -/* Used internally, but overridden by some architectures */ -ffi_status ffi_prep_cif_core(ffi_cif *cif, - ffi_abi abi, - unsigned int isvariadic, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - -/* ---- Definitions for the raw API -------------------------------------- */ - -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == FFI_64_BIT_MAX -# define FFI_SIZEOF_ARG 8 -# endif -#endif - -#ifndef FFI_SIZEOF_JAVA_RAW -# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG -#endif - -typedef union { - ffi_sarg sint; - ffi_arg uint; - float flt; - char data[FFI_SIZEOF_ARG]; - void* ptr; -} ffi_raw; - -#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 -/* This is a special case for mips64/n32 ABI (and perhaps others) where - sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ -typedef union { - signed int sint; - unsigned int uint; - float flt; - char data[FFI_SIZEOF_JAVA_RAW]; - void* ptr; -} ffi_java_raw; -#else -typedef ffi_raw ffi_java_raw; -#endif - - -void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - -void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); -void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); -size_t ffi_raw_size (ffi_cif *cif); - -/* This is analogous to the raw API, except it uses Java parameter */ -/* packing, even on 64-bit machines. I.e. on 64-bit machines */ -/* longs and doubles are followed by an empty 64-bit word. */ - -void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue); - -void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); -void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); -size_t ffi_java_raw_size (ffi_cif *cif); - -/* ---- Definitions for closures ----------------------------------------- */ - -#if FFI_CLOSURES - -#ifdef _MSC_VER -__declspec(align(8)) -#endif -typedef struct { -#if @FFI_EXEC_TRAMPOLINE_TABLE@ - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); - void *user_data; -#ifdef __GNUC__ -} ffi_closure __attribute__((aligned (8))); -#else -} ffi_closure; -# ifdef __sgi -# pragma pack 0 -# endif -#endif - -void *ffi_closure_alloc (size_t size, void **code); -void ffi_closure_free (void *); - -ffi_status -ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data); - -ffi_status -ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void*codeloc); - -#ifdef __sgi -# pragma pack 8 -#endif -typedef struct { -#if @FFI_EXEC_TRAMPOLINE_TABLE@ - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* if this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the transaltion, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_raw*,void*); - void *user_data; - -} ffi_raw_closure; - -typedef struct { -#if @FFI_EXEC_TRAMPOLINE_TABLE@ - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* if this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the transaltion, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); - void *user_data; - -} ffi_java_raw_closure; - -ffi_status -ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - -ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - -ffi_status -ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data); - -ffi_status -ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data, - void *codeloc); - -#endif /* FFI_CLOSURES */ - -#if FFI_GO_CLOSURES - -typedef struct { - void *tramp; - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); -} ffi_go_closure; - -ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*)); - -void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure); - -#endif /* FFI_GO_CLOSURES */ - -/* ---- Public interface definition -------------------------------------- */ - -ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - -ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - -void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); - -/* Useful for eliminating compiler warnings */ -#define FFI_FN(f) ((void (*)(void))f) - -/* ---- Definitions shared with assembly code ---------------------------- */ - -#endif - -/* If these change, update src/mips/ffitarget.h. */ -#define FFI_TYPE_VOID 0 -#define FFI_TYPE_INT 1 -#define FFI_TYPE_FLOAT 2 -#define FFI_TYPE_DOUBLE 3 -#if @HAVE_LONG_DOUBLE@ -#define FFI_TYPE_LONGDOUBLE 4 -#else -#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE -#endif -#define FFI_TYPE_UINT8 5 -#define FFI_TYPE_SINT8 6 -#define FFI_TYPE_UINT16 7 -#define FFI_TYPE_SINT16 8 -#define FFI_TYPE_UINT32 9 -#define FFI_TYPE_SINT32 10 -#define FFI_TYPE_UINT64 11 -#define FFI_TYPE_SINT64 12 -#define FFI_TYPE_STRUCT 13 -#define FFI_TYPE_POINTER 14 -#define FFI_TYPE_COMPLEX 15 - -/* This should always refer to the last type code (for sanity checks) */ -#define FFI_TYPE_LAST FFI_TYPE_COMPLEX - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/libffi/include/ffi_cfi.h b/user/mpy/lib/libffi/include/ffi_cfi.h deleted file mode 100644 index 244ce57..0000000 --- a/user/mpy/lib/libffi/include/ffi_cfi.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi_cfi.h - Copyright (c) 2014 Red Hat, Inc. - - Conditionally assemble cfi directives. Only necessary for building libffi. - ----------------------------------------------------------------------- */ - -#ifndef FFI_CFI_H -#define FFI_CFI_H - -#ifdef HAVE_AS_CFI_PSEUDO_OP - -# define cfi_startproc .cfi_startproc -# define cfi_endproc .cfi_endproc -# define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off -# define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg -# define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off -# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off -# define cfi_offset(reg, off) .cfi_offset reg, off -# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off -# define cfi_register(r1, r2) .cfi_register r1, r2 -# define cfi_return_column(reg) .cfi_return_column reg -# define cfi_restore(reg) .cfi_restore reg -# define cfi_same_value(reg) .cfi_same_value reg -# define cfi_undefined(reg) .cfi_undefined reg -# define cfi_remember_state .cfi_remember_state -# define cfi_restore_state .cfi_restore_state -# define cfi_window_save .cfi_window_save -# define cfi_personality(enc, exp) .cfi_personality enc, exp -# define cfi_lsda(enc, exp) .cfi_lsda enc, exp -# define cfi_escape(...) .cfi_escape __VA_ARGS__ - -#else - -# define cfi_startproc -# define cfi_endproc -# define cfi_def_cfa(reg, off) -# define cfi_def_cfa_register(reg) -# define cfi_def_cfa_offset(off) -# define cfi_adjust_cfa_offset(off) -# define cfi_offset(reg, off) -# define cfi_rel_offset(reg, off) -# define cfi_register(r1, r2) -# define cfi_return_column(reg) -# define cfi_restore(reg) -# define cfi_same_value(reg) -# define cfi_undefined(reg) -# define cfi_remember_state -# define cfi_restore_state -# define cfi_window_save -# define cfi_personality(enc, exp) -# define cfi_lsda(enc, exp) -# define cfi_escape(...) - -#endif /* HAVE_AS_CFI_PSEUDO_OP */ -#endif /* FFI_CFI_H */ diff --git a/user/mpy/lib/libffi/include/ffi_common.h b/user/mpy/lib/libffi/include/ffi_common.h deleted file mode 100644 index 37f5a9e..0000000 --- a/user/mpy/lib/libffi/include/ffi_common.h +++ /dev/null @@ -1,132 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi_common.h - Copyright (C) 2011, 2012, 2013 Anthony Green - Copyright (C) 2007 Free Software Foundation, Inc - Copyright (c) 1996 Red Hat, Inc. - - Common internal definitions and macros. Only necessary for building - libffi. - ----------------------------------------------------------------------- */ - -#ifndef FFI_COMMON_H -#define FFI_COMMON_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Do not move this. Some versions of AIX are very picky about where - this is positioned. */ -#ifdef __GNUC__ -# if HAVE_ALLOCA_H -# include -# else - /* mingw64 defines this already in malloc.h. */ -# ifndef alloca -# define alloca __builtin_alloca -# endif -# endif -# define MAYBE_UNUSED __attribute__((__unused__)) -#else -# define MAYBE_UNUSED -# if HAVE_ALLOCA_H -# include -# else -# ifdef _AIX -# pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -# ifdef _MSC_VER -# define alloca _alloca -# else -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -/* Check for the existence of memcpy. */ -#if STDC_HEADERS -# include -#else -# ifndef HAVE_MEMCPY -# define memcpy(d, s, n) bcopy ((s), (d), (n)) -# endif -#endif - -#if defined(FFI_DEBUG) -#include -#endif - -#ifdef FFI_DEBUG -void ffi_assert(char *expr, char *file, int line); -void ffi_stop_here(void); -void ffi_type_test(ffi_type *a, char *file, int line); - -#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__)) -#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l))) -#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__) -#else -#define FFI_ASSERT(x) -#define FFI_ASSERT_AT(x, f, l) -#define FFI_ASSERT_VALID_TYPE(x) -#endif - -#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1) -#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a) - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif); -ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, - unsigned int nfixedargs, unsigned int ntotalargs); - -/* Extended cif, used in callback from assembly routine */ -typedef struct -{ - ffi_cif *cif; - void *rvalue; - void **avalue; -} extended_cif; - -/* Terse sized type definitions. */ -#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C) -typedef unsigned char UINT8; -typedef signed char SINT8; -typedef unsigned short UINT16; -typedef signed short SINT16; -typedef unsigned int UINT32; -typedef signed int SINT32; -# ifdef _MSC_VER -typedef unsigned __int64 UINT64; -typedef signed __int64 SINT64; -# else -# include -typedef uint64_t UINT64; -typedef int64_t SINT64; -# endif -#else -typedef unsigned int UINT8 __attribute__((__mode__(__QI__))); -typedef signed int SINT8 __attribute__((__mode__(__QI__))); -typedef unsigned int UINT16 __attribute__((__mode__(__HI__))); -typedef signed int SINT16 __attribute__((__mode__(__HI__))); -typedef unsigned int UINT32 __attribute__((__mode__(__SI__))); -typedef signed int SINT32 __attribute__((__mode__(__SI__))); -typedef unsigned int UINT64 __attribute__((__mode__(__DI__))); -typedef signed int SINT64 __attribute__((__mode__(__DI__))); -#endif - -typedef float FLOAT32; - -#ifndef __GNUC__ -#define __builtin_expect(x, expected_value) (x) -#endif -#define LIKELY(x) __builtin_expect(!!(x),1) -#define UNLIKELY(x) __builtin_expect((x)!=0,0) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/libffi/libffi.pc.in b/user/mpy/lib/libffi/libffi.pc.in deleted file mode 100644 index edf6fde..0000000 --- a/user/mpy/lib/libffi/libffi.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -toolexeclibdir=@toolexeclibdir@ -includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include - -Name: @PACKAGE_NAME@ -Description: Library supporting Foreign Function Interfaces -Version: @PACKAGE_VERSION@ -Libs: -L${toolexeclibdir} -lffi -Cflags: -I${includedir} diff --git a/user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj b/user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj deleted file mode 100644 index 1cf396f..0000000 --- a/user/mpy/lib/libffi/libffi.xcodeproj/project.pbxproj +++ /dev/null @@ -1,637 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; }; - DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; }; - DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7140187F1D8600A76262 /* fficonfig.h */; }; - DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; }; - DBFA714E187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; - DBFA714F187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; - DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; - DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; - DBFA7158187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; }; - DBFA7159187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; }; - DBFA715A187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; }; - DBFA715B187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; }; - DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716C187F1D9B00A76262 /* ffi_arm64.c */; }; - DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716D187F1D9B00A76262 /* sysv_arm64.S */; }; - DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716F187F1D9B00A76262 /* ffi_armv7.c */; }; - DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7170187F1D9B00A76262 /* sysv_armv7.S */; }; - DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */; }; - DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */; }; - DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7174187F1D9B00A76262 /* darwin_i386.S */; }; - DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; }; - DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; }; - DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; }; - DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; }; - DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; }; - DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; }; - DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; }; - DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; }; - DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */; }; - DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* darwin_i386.S */; }; - DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; }; - DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718D187F1DA100A76262 /* ffi_i386.c */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - DB13B1641849DF1E0010F42D /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 8; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - DB13B1661849DF1E0010F42D /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; - DB13B1911849DF510010F42D /* ffi.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = ffi.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; - DBFA713E187F1D8600A76262 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = ""; }; - DBFA713F187F1D8600A76262 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = ""; }; - DBFA7140187F1D8600A76262 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = ""; }; - DBFA7141187F1D8600A76262 /* ffitarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget.h; sourceTree = ""; }; - DBFA7143187F1D8600A76262 /* closures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = closures.c; sourceTree = ""; }; - DBFA7145187F1D8600A76262 /* dlmalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dlmalloc.c; sourceTree = ""; }; - DBFA7147187F1D8600A76262 /* prep_cif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = prep_cif.c; sourceTree = ""; }; - DBFA7148187F1D8600A76262 /* raw_api.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raw_api.c; sourceTree = ""; }; - DBFA7149187F1D8600A76262 /* types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = types.c; sourceTree = ""; }; - DBFA715E187F1D9B00A76262 /* ffi_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_arm64.h; sourceTree = ""; }; - DBFA715F187F1D9B00A76262 /* ffi_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_armv7.h; sourceTree = ""; }; - DBFA7160187F1D9B00A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; - DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; - DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_arm64.h; sourceTree = ""; }; - DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_armv7.h; sourceTree = ""; }; - DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; - DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; - DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_arm64.h; sourceTree = ""; }; - DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_armv7.h; sourceTree = ""; }; - DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; - DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; - DBFA716C187F1D9B00A76262 /* ffi_arm64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_arm64.c; sourceTree = ""; }; - DBFA716D187F1D9B00A76262 /* sysv_arm64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_arm64.S; sourceTree = ""; }; - DBFA716F187F1D9B00A76262 /* ffi_armv7.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_armv7.c; sourceTree = ""; }; - DBFA7170187F1D9B00A76262 /* sysv_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_armv7.S; sourceTree = ""; }; - DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = trampoline_armv7.S; sourceTree = ""; }; - DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = ""; }; - DBFA7174187F1D9B00A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = ""; }; - DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = ""; }; - DBFA7176187F1D9B00A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = ""; }; - DBFA7182187F1DA100A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; - DBFA7183187F1DA100A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; - DBFA7184187F1DA100A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; - DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; - DBFA7186187F1DA100A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; - DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; - DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = ""; }; - DBFA718B187F1DA100A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = ""; }; - DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = ""; }; - DBFA718D187F1DA100A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXGroup section */ - DB13B15B1849DEB70010F42D = { - isa = PBXGroup; - children = ( - DBFA713C187F1D8600A76262 /* darwin_common */, - DBFA715C187F1D9B00A76262 /* darwin_ios */, - DBFA7180187F1DA100A76262 /* darwin_osx */, - DB13B1671849DF1E0010F42D /* Products */, - ); - sourceTree = ""; - }; - DB13B1671849DF1E0010F42D /* Products */ = { - isa = PBXGroup; - children = ( - DB13B1661849DF1E0010F42D /* libffi.a */, - DB13B1911849DF510010F42D /* ffi.dylib */, - ); - name = Products; - sourceTree = ""; - }; - DBFA713C187F1D8600A76262 /* darwin_common */ = { - isa = PBXGroup; - children = ( - DBFA713D187F1D8600A76262 /* include */, - DBFA7142187F1D8600A76262 /* src */, - ); - path = "darwin_common"; - sourceTree = ""; - }; - DBFA713D187F1D8600A76262 /* include */ = { - isa = PBXGroup; - children = ( - DBFA713E187F1D8600A76262 /* ffi.h */, - DBFA713F187F1D8600A76262 /* ffi_common.h */, - DBFA7140187F1D8600A76262 /* fficonfig.h */, - DBFA7141187F1D8600A76262 /* ffitarget.h */, - ); - path = include; - sourceTree = ""; - }; - DBFA7142187F1D8600A76262 /* src */ = { - isa = PBXGroup; - children = ( - DBFA7143187F1D8600A76262 /* closures.c */, - DBFA7145187F1D8600A76262 /* dlmalloc.c */, - DBFA7147187F1D8600A76262 /* prep_cif.c */, - DBFA7148187F1D8600A76262 /* raw_api.c */, - DBFA7149187F1D8600A76262 /* types.c */, - ); - path = src; - sourceTree = ""; - }; - DBFA715C187F1D9B00A76262 /* darwin_ios */ = { - isa = PBXGroup; - children = ( - DBFA715D187F1D9B00A76262 /* include */, - DBFA716A187F1D9B00A76262 /* src */, - ); - path = "darwin_ios"; - sourceTree = ""; - }; - DBFA715D187F1D9B00A76262 /* include */ = { - isa = PBXGroup; - children = ( - DBFA715E187F1D9B00A76262 /* ffi_arm64.h */, - DBFA715F187F1D9B00A76262 /* ffi_armv7.h */, - DBFA7160187F1D9B00A76262 /* ffi_i386.h */, - DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */, - DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */, - DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */, - DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */, - DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */, - DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */, - DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */, - DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */, - DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */, - ); - path = include; - sourceTree = ""; - }; - DBFA716A187F1D9B00A76262 /* src */ = { - isa = PBXGroup; - children = ( - DBFA716B187F1D9B00A76262 /* aarch64 */, - DBFA716E187F1D9B00A76262 /* arm */, - DBFA7172187F1D9B00A76262 /* x86 */, - ); - path = src; - sourceTree = ""; - }; - DBFA716B187F1D9B00A76262 /* aarch64 */ = { - isa = PBXGroup; - children = ( - DBFA716C187F1D9B00A76262 /* ffi_arm64.c */, - DBFA716D187F1D9B00A76262 /* sysv_arm64.S */, - ); - path = aarch64; - sourceTree = ""; - }; - DBFA716E187F1D9B00A76262 /* arm */ = { - isa = PBXGroup; - children = ( - DBFA716F187F1D9B00A76262 /* ffi_armv7.c */, - DBFA7170187F1D9B00A76262 /* sysv_armv7.S */, - DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */, - ); - path = arm; - sourceTree = ""; - }; - DBFA7172187F1D9B00A76262 /* x86 */ = { - isa = PBXGroup; - children = ( - DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */, - DBFA7174187F1D9B00A76262 /* darwin_i386.S */, - DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */, - DBFA7176187F1D9B00A76262 /* ffi_i386.c */, - ); - path = x86; - sourceTree = ""; - }; - DBFA7180187F1DA100A76262 /* darwin_osx */ = { - isa = PBXGroup; - children = ( - DBFA7181187F1DA100A76262 /* include */, - DBFA7188187F1DA100A76262 /* src */, - ); - path = "darwin_osx"; - sourceTree = ""; - }; - DBFA7181187F1DA100A76262 /* include */ = { - isa = PBXGroup; - children = ( - DBFA7182187F1DA100A76262 /* ffi_i386.h */, - DBFA7183187F1DA100A76262 /* ffi_x86_64.h */, - DBFA7184187F1DA100A76262 /* fficonfig_i386.h */, - DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */, - DBFA7186187F1DA100A76262 /* ffitarget_i386.h */, - DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */, - ); - path = include; - sourceTree = ""; - }; - DBFA7188187F1DA100A76262 /* src */ = { - isa = PBXGroup; - children = ( - DBFA7189187F1DA100A76262 /* x86 */, - ); - path = src; - sourceTree = ""; - }; - DBFA7189187F1DA100A76262 /* x86 */ = { - isa = PBXGroup; - children = ( - DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */, - DBFA718B187F1DA100A76262 /* darwin_i386.S */, - DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */, - DBFA718D187F1DA100A76262 /* ffi_i386.c */, - ); - path = x86; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - DB13B18F1849DF510010F42D /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */, - DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */, - DBFA714A187F1D8600A76262 /* ffi.h in Headers */, - DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */, - DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */, - DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */, - DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */, - DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */, - DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */, - DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - DB13B1651849DF1E0010F42D /* libffi-iOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */; - buildPhases = ( - DB13B3051849E01C0010F42D /* ShellScript */, - DB13B1621849DF1E0010F42D /* Sources */, - DB13B1641849DF1E0010F42D /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libffi-iOS"; - productName = ffi; - productReference = DB13B1661849DF1E0010F42D /* libffi.a */; - productType = "com.apple.product-type.library.static"; - }; - DB13B1901849DF510010F42D /* libffi-Mac */ = { - isa = PBXNativeTarget; - buildConfigurationList = DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */; - buildPhases = ( - DB13B3061849E0490010F42D /* ShellScript */, - DB13B18D1849DF510010F42D /* Sources */, - DB13B18F1849DF510010F42D /* Headers */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libffi-Mac"; - productName = ffi; - productReference = DB13B1911849DF510010F42D /* ffi.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - DB13B15C1849DEB70010F42D /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0510; - }; - buildConfigurationList = DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = DB13B15B1849DEB70010F42D; - productRefGroup = DB13B1671849DF1E0010F42D /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - DB13B1651849DF1E0010F42D /* libffi-iOS */, - DB13B1901849DF510010F42D /* libffi-Mac */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXShellScriptBuildPhase section */ - DB13B3051849E01C0010F42D /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-ios"; - }; - DB13B3061849E0490010F42D /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-osx"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - DB13B1621849DF1E0010F42D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */, - DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */, - DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */, - DBFA714E187F1D8600A76262 /* closures.c in Sources */, - DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */, - DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */, - DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */, - DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */, - DBFA7158187F1D8600A76262 /* raw_api.c in Sources */, - DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */, - DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */, - DBFA715A187F1D8600A76262 /* types.c in Sources */, - DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - DB13B18D1849DF510010F42D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */, - DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */, - DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */, - DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */, - DBFA715B187F1D8600A76262 /* types.c in Sources */, - DBFA7159187F1D8600A76262 /* raw_api.c in Sources */, - DBFA714F187F1D8600A76262 /* closures.c in Sources */, - DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - DB13B1601849DEB70010F42D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "darwin_common/include", - ); - ONLY_ACTIVE_ARCH = YES; - }; - name = Debug; - }; - DB13B1611849DEB70010F42D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "darwin_common/include", - ); - }; - name = Release; - }; - DB13B1871849DF1E0010F42D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DSTROOT = /tmp/ffi.dst; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "darwin_ios/include", - ); - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = ffi; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - DB13B1881849DF1E0010F42D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - DSTROOT = /tmp/ffi.dst; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "darwin_ios/include", - ); - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = ffi; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - DB13B1B11849DF520010F42D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "darwin_osx/include", - ); - MACOSX_DEPLOYMENT_TARGET = 10.6; - ONLY_ACTIVE_ARCH = YES; - OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; - PRODUCT_NAME = ffi; - SDKROOT = macosx; - }; - name = Debug; - }; - DB13B1B21849DF520010F42D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "darwin_osx/include", - ); - MACOSX_DEPLOYMENT_TARGET = 10.6; - OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; - PRODUCT_NAME = ffi; - SDKROOT = macosx; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - DB13B1601849DEB70010F42D /* Debug */, - DB13B1611849DEB70010F42D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - DB13B1871849DF1E0010F42D /* Debug */, - DB13B1881849DF1E0010F42D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - DB13B1B11849DF520010F42D /* Debug */, - DB13B1B21849DF520010F42D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = DB13B15C1849DEB70010F42D /* Project object */; -} diff --git a/user/mpy/lib/libffi/libtool-version b/user/mpy/lib/libffi/libtool-version deleted file mode 100644 index 149a51a..0000000 --- a/user/mpy/lib/libffi/libtool-version +++ /dev/null @@ -1,29 +0,0 @@ -# This file is used to maintain libtool version info for libffi. See -# the libtool manual to understand the meaning of the fields. This is -# a separate file so that version updates don't involve re-running -# automake. -# -# Here are a set of rules to help you update your library version -# information: -# -# 1. Start with version information of `0:0:0' for each libtool library. -# -# 2. Update the version information only immediately before a public -# release of your software. More frequent updates are unnecessary, -# and only guarantee that the current interface number gets larger -# faster. -# -# 3. If the library source code has changed at all since the last -# update, then increment revision (`c:r:a' becomes `c:r+1:a'). -# -# 4. If any interfaces have been added, removed, or changed since the -# last update, increment current, and set revision to 0. -# -# 5. If any interfaces have been added since the last public release, -# then increment age. -# -# 6. If any interfaces have been removed since the last public -# release, then set age to 0. -# -# CURRENT:REVISION:AGE -6:4:0 diff --git a/user/mpy/lib/libffi/m4/asmcfi.m4 b/user/mpy/lib/libffi/m4/asmcfi.m4 deleted file mode 100644 index dbf73a0..0000000 --- a/user/mpy/lib/libffi/m4/asmcfi.m4 +++ /dev/null @@ -1,13 +0,0 @@ -AC_DEFUN([GCC_AS_CFI_PSEUDO_OP], -[AC_CACHE_CHECK([assembler .cfi pseudo-op support], - gcc_cv_as_cfi_pseudo_op, [ - gcc_cv_as_cfi_pseudo_op=unknown - AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],, - [gcc_cv_as_cfi_pseudo_op=yes], - [gcc_cv_as_cfi_pseudo_op=no]) - ]) - if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then - AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1, - [Define if your assembler supports .cfi_* directives.]) - fi -]) diff --git a/user/mpy/lib/libffi/m4/ax_append_flag.m4 b/user/mpy/lib/libffi/m4/ax_append_flag.m4 deleted file mode 100644 index 1d38b76..0000000 --- a/user/mpy/lib/libffi/m4/ax_append_flag.m4 +++ /dev/null @@ -1,69 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) -# -# DESCRIPTION -# -# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space -# added in between. -# -# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. -# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains -# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly -# FLAG. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_APPEND_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl -AS_VAR_SET_IF(FLAGS, - [case " AS_VAR_GET(FLAGS) " in - *" $1 "*) - AC_RUN_LOG([: FLAGS already contains $1]) - ;; - *) - AC_RUN_LOG([: FLAGS="$FLAGS $1"]) - AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) - ;; - esac], - [AS_VAR_SET(FLAGS,["$1"])]) -AS_VAR_POPDEF([FLAGS])dnl -])dnl AX_APPEND_FLAG diff --git a/user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 b/user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 deleted file mode 100644 index 62e3b53..0000000 --- a/user/mpy/lib/libffi/m4/ax_cc_maxopt.m4 +++ /dev/null @@ -1,181 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CC_MAXOPT -# -# DESCRIPTION -# -# Try to turn on "good" C optimization flags for various compilers and -# architectures, for some definition of "good". (In our case, good for -# FFTW and hopefully for other scientific codes. Modify as needed.) -# -# The user can override the flags by setting the CFLAGS environment -# variable. The user can also specify --enable-portable-binary in order to -# disable any optimization flags that might result in a binary that only -# runs on the host architecture. -# -# Note also that the flags assume that ANSI C aliasing rules are followed -# by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point -# computations can be re-ordered as needed. -# -# Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR, -# AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 13 - -AC_DEFUN([AX_CC_MAXOPT], -[ -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AX_COMPILER_VENDOR]) -AC_REQUIRE([AC_CANONICAL_HOST]) - -AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])], - acx_maxopt_portable=$enableval, acx_maxopt_portable=no) - -# Try to determine "good" native compiler flags if none specified via CFLAGS -if test "$ac_test_CFLAGS" != "set"; then - CFLAGS="" - case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" - if test "x$acx_maxopt_portable" = xno; then - CFLAGS="$CFLAGS -arch host" - fi;; - - sun) CFLAGS="-native -fast -xO5 -dalign" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS -xarch=generic" - fi;; - - hp) CFLAGS="+Oall +Optrs_ansi +DSnative" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS +DAportable" - fi;; - - ibm) if test "x$acx_maxopt_portable" = xno; then - xlc_opt="-qarch=auto -qtune=auto" - else - xlc_opt="-qtune=auto" - fi - AX_CHECK_COMPILE_FLAG($xlc_opt, - CFLAGS="-O3 -qansialias -w $xlc_opt", - [CFLAGS="-O3 -qansialias -w" - echo "******************************************************" - echo "* You seem to have the IBM C compiler. It is *" - echo "* recommended for best performance that you use: *" - echo "* *" - echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" - echo "* ^^^ ^^^ *" - echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" - echo "* CPU you have. (Set the CFLAGS environment var. *" - echo "* and re-run configure.) For more info, man cc. *" - echo "******************************************************"]) - ;; - - intel) CFLAGS="-O3 -ansi_alias" - if test "x$acx_maxopt_portable" = xno; then - icc_archflag=unknown - icc_flags="" - case $host_cpu in - i686*|x86_64*) - # icc accepts gcc assembly syntax, so these should work: - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";; - *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";; - *f??:*:*:*) icc_flags="-xN -xW -xK";; - esac ;; - esac ;; - esac - if test "x$icc_flags" != x; then - for flag in $icc_flags; do - AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break]) - done - fi - AC_MSG_CHECKING([for icc architecture flag]) - AC_MSG_RESULT($icc_archflag) - if test "x$icc_archflag" != xunknown; then - CFLAGS="$CFLAGS $icc_archflag" - fi - fi - ;; - - gnu) - # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" - - # -malign-double for x86 systems - # LIBFFI -- DON'T DO THIS - CHANGES ABI - # AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double") - - # -fstrict-aliasing for gcc-2.95+ - AX_CHECK_COMPILE_FLAG(-fstrict-aliasing, - CFLAGS="$CFLAGS -fstrict-aliasing") - - # note that we enable "unsafe" fp optimization with other compilers, too - AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math") - - AX_GCC_ARCHFLAG($acx_maxopt_portable) - ;; - esac - - if test -z "$CFLAGS"; then - echo "" - echo "********************************************************" - echo "* WARNING: Don't know the best CFLAGS for this system *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" - echo "********************************************************" - echo "" - CFLAGS="-O3" - fi - - AX_CHECK_COMPILE_FLAG($CFLAGS, [], [ - echo "" - echo "********************************************************" - echo "* WARNING: The guessed CFLAGS don't seem to work with *" - echo "* your compiler. *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "********************************************************" - echo "" - CFLAGS="" - ]) - -fi -]) diff --git a/user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 b/user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 deleted file mode 100644 index 0fa3e18..0000000 --- a/user/mpy/lib/libffi/m4/ax_cflags_warn_all.m4 +++ /dev/null @@ -1,122 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# -# DESCRIPTION -# -# Try to find a compiler option that enables most reasonable warnings. -# -# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result -# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. -# -# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, -# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and -# Intel compilers. For a given compiler, the Fortran flags are much more -# experimental than their C equivalents. -# -# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS -# - $2 add-value-if-not-found : nothing -# - $3 action-if-found : add value to shellvariable -# - $4 action-if-not-found : nothing -# -# NOTE: These macros depend on AX_APPEND_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2010 Rhys Ulerich -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 14 - -AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl -AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], -VAR,[VAR="no, unknown" -ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-warn all % -warn all" dnl Intel - "-pedantic % -Wall" dnl GCC - "-xstrconst % -v" dnl Solaris C - "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix - "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX - "-ansi -ansiE % -fullwarn" dnl IRIX - "+ESlit % +w1" dnl HP-UX C - "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) - "-h conform % -h msglevel 2" dnl Cray C (Unicos) - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done -FLAGS="$ac_save_[]FLAGS" -]) -AS_VAR_POPDEF([FLAGS])dnl -AC_REQUIRE([AX_APPEND_FLAG]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; - *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -])dnl AX_FLAGS_WARN_ALL -dnl implementation tactics: -dnl the for-argument contains a list of options. The first part of -dnl these does only exist to detect the compiler - usually it is -dnl a global option to enable -ansi or -extrawarnings. All other -dnl compilers will fail about it. That was needed since a lot of -dnl compilers will give false positives for some option-syntax -dnl like -Woption or -Xoption as they think of it is a pass-through -dnl to later compile stages or something. The "%" is used as a -dnl delimiter. A non-option comment can be given after "%%" marks -dnl which will be shown but not added to the respective C/CXXFLAGS. - -AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([C]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([C]) -]) - -AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([C++]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([C++]) -]) - -AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([Fortran]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([Fortran]) -]) diff --git a/user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 b/user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 deleted file mode 100644 index c3a8d69..0000000 --- a/user/mpy/lib/libffi/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 b/user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 deleted file mode 100644 index 73e32ea..0000000 --- a/user/mpy/lib/libffi/m4/ax_compiler_vendor.m4 +++ /dev/null @@ -1,84 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VENDOR -# -# DESCRIPTION -# -# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, -# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, -# watcom, etc. The vendor is returned in the cache variable -# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 11 - -AC_DEFUN([AX_COMPILER_VENDOR], -[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - [# note: don't check for gcc first since some other compilers define __GNUC__ - vendors="intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__TURBOC__ - comeau: __COMO__ - cray: _CRAYC - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - portland: __PGI - unknown: UNKNOWN" - for ventest in $vendors; do - case $ventest in - *:) vendor=$ventest; continue ;; - *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; - esac - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ - #if !($vencpp) - thisisanerror; - #endif - ])], [break]) - done - ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` - ]) -]) diff --git a/user/mpy/lib/libffi/m4/ax_configure_args.m4 b/user/mpy/lib/libffi/m4/ax_configure_args.m4 deleted file mode 100644 index 0726b1b..0000000 --- a/user/mpy/lib/libffi/m4/ax_configure_args.m4 +++ /dev/null @@ -1,70 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_configure_args.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CONFIGURE_ARGS -# -# DESCRIPTION -# -# Helper macro for AX_ENABLE_BUILDDIR. -# -# The traditional way of starting a subdir-configure is running the script -# with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have -# to rely on eval'ing $ac_configure_args however some old autoconf -# versions do not provide that. To ensure maximum portability of autoconf -# extension macros this helper can be AC_REQUIRE'd so that -# $ac_configure_args will alsways be present. -# -# Sadly, the traditional "exec $SHELL" of the enable_builddir macros is -# spoiled now and must be replaced by "eval + exit $?". -# -# Example: -# -# AC_DEFUN([AX_ENABLE_SUBDIR],[dnl -# AC_REQUIRE([AX_CONFIGURE_ARGS])dnl -# eval $SHELL $ac_configure_args || exit $? -# ...]) -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AC_DEFUN([AX_CONFIGURE_ARGS],[ - # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args - if test "${ac_configure_args+set}" != "set" ; then - ac_configure_args= - for ac_arg in ${1+"[$]@"}; do - ac_configure_args="$ac_configure_args '$ac_arg'" - done - fi -]) diff --git a/user/mpy/lib/libffi/m4/ax_enable_builddir.m4 b/user/mpy/lib/libffi/m4/ax_enable_builddir.m4 deleted file mode 100644 index 3cb2093..0000000 --- a/user/mpy/lib/libffi/m4/ax_enable_builddir.m4 +++ /dev/null @@ -1,301 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])] -# -# DESCRIPTION -# -# If the current configure was run within the srcdir then we move all -# configure-files into a subdir and let the configure steps continue -# there. We provide an option --disable-builddir to suppress the move into -# a separate builddir. -# -# Defaults: -# -# $1 = $host (overridden with $HOST) -# $2 = Makefile.mk -# $3 = -all -# -# This macro must be called before AM_INIT_AUTOMAKE. It creates a default -# toplevel srcdir Makefile from the information found in the created -# toplevel builddir Makefile. It just copies the variables and -# rule-targets, each extended with a default rule-execution that recurses -# into the build directory of the current "HOST". You can override the -# auto-dection through `config.guess` and build-time of course, as in -# -# make HOST=i386-mingw-cross -# -# which can of course set at configure time as well using -# -# configure --host=i386-mingw-cross -# -# After the default has been created, additional rules can be appended -# that will not just recurse into the subdirectories and only ever exist -# in the srcdir toplevel makefile - these parts are read from the $2 = -# Makefile.mk file -# -# The automatic rules are usually scanning the toplevel Makefile for lines -# like '#### $host |$builddir' to recognize the place where to recurse -# into. Usually, the last one is the only one used. However, almost all -# targets have an additional "*-all" rule which makes the script to -# recurse into _all_ variants of the current HOST (!!) setting. The "-all" -# suffix can be overriden for the macro as well. -# -# a special rule is only given for things like "dist" that will copy the -# tarball from the builddir to the sourcedir (or $(PUB)) for reason of -# convenience. -# -# LICENSE -# -# Copyright (c) 2009 Guido U. Draheim -# Copyright (c) 2009 Alan Jenkins -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 23 - -AC_DEFUN([AX_ENABLE_BUILDDIR],[ -AC_REQUIRE([AC_CANONICAL_HOST])[]dnl -AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl -AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl -AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl -AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl -AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl -SUB="." -AC_ARG_ENABLE([builddir], AS_HELP_STRING( - [--disable-builddir],[disable automatic build in subdir of sources]) - ,[SUB="$enableval"], [SUB="auto"]) -if test ".$ac_srcdir_defaulted" != ".no" ; then -if test ".$srcdir" = ".." ; then - if test -f config.status ; then - AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build) - else - test ".$SUB" = "." && SUB="." - test ".$SUB" = ".no" && SUB="." - test ".$TARGET" = "." && TARGET="$target" - test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])" - if test ".$SUB" != ".." ; then # we know where to go and - AS_MKDIR_P([$SUB]) - echo __.$SUB.__ > $SUB/conftest.tmp - cd $SUB - if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then - rm conftest.tmp - AC_MSG_RESULT([continue configure in default builddir "./$SUB"]) - else - AC_MSG_ERROR([could not change to default builddir "./$SUB"]) - fi - srcdir=`echo "$SUB" | - sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'` - # going to restart from subdirectory location - test -f $srcdir/config.log && mv $srcdir/config.log . - test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h . - test -f $srcdir/conftest.log && mv $srcdir/conftest.log . - test -f $srcdir/$cache_file && mv $srcdir/$cache_file . - AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"}) - case "[$]0" in # restart - [[\\/]]* | ?:[[\\/]]*) # Asbolute name - eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; - *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; - esac ; exit $? - fi - fi -fi fi -test ".$SUB" = ".auto" && SUB="." -dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec" -AC_PATH_PROG(SED,gsed sed, sed) -AUX="$am_aux_dir" -AS_VAR_POPDEF([SED])dnl -AS_VAR_POPDEF([AUX])dnl -AS_VAR_POPDEF([SUB])dnl -AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status .............. -AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl -AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl -AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl -AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl -AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl -pushdef([END],[Makefile.mk])dnl -pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl - SRC="$ax_enable_builddir_srcdir" - if test ".$SUB" = ".." ; then - if test -f "$TOP/Makefile" ; then - AC_MSG_NOTICE([skipping TOP/Makefile - left untouched]) - else - AC_MSG_NOTICE([skipping TOP/Makefile - not created]) - fi - else - if test -f "$SRC/Makefile" ; then - a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile` - test "$a" != "$b" && rm "$SRC/Makefile" - fi - if test -f "$SRC/Makefile" ; then - echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk - echo " []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk - eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null" - if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null - then rm $SRC/Makefile ; fi - cp $tmp/conftemp.mk $SRC/makefiles.mk~ ## DEBUGGING - fi - if test ! -f "$SRC/Makefile" ; then - AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile]) - x='`' ; cat >$tmp/conftemp.sed <<_EOF -/^\$/n -x -/^\$/bS -x -/\\\\\$/{H;d;} -{H;s/.*//;x;} -bM -:S -x -/\\\\\$/{h;d;} -{h;s/.*//;x;} -:M -s/\\(\\n\\) /\\1 /g -/^ /d -/^[[ ]]*[[\\#]]/d -/^VPATH *=/d -s/^srcdir *=.*/srcdir = ./ -s/^top_srcdir *=.*/top_srcdir = ./ -/[[:=]]/!d -/^\\./d -dnl Now handle rules (i.e. lines containing ":" but not " = "). -/ = /b -/ .= /b -/:/!b -s/:.*/:/ -s/ / /g -s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g -s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/ -s/ / /g -/^all all[]_ALL[[ :]]/i\\ -all-configured : all[]_ALL -dnl dist-all exists... and would make for dist-all-all -s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g -/[]_ALL[]_ALL/d -a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\ - ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ - ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done -dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree) -/dist[]_ALL *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ - ; if test "\$\$found" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ - ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ - ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done -dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree) -/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\ - ; if test "\$\$found" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ - ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\ - ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done -dnl special rule add-on: "distclean" removes all local builddirs completely -/distclean[]_ALL *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\ - ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\ - ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\ - ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\ - ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile -_EOF - cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING - $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile - if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then - AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])]) - cat $SRC/END >>$SRC/Makefile - fi ; xxxx="####" - echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile - # sanity check - if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then - AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts]) - $SED -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $SRC/Makefile \ - >$SRC/Makefile~ - (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null - fi - else - xxxx="\\#\\#\\#\\#" - # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed - echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed - $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp - cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~" ## DEBUGGING - cp "$tmp/mkfile.tmp" "$SRC/makefiles.out~" ## DEBUGGING - if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then - AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure]) - rm "$tmp/mkfile.tmp" - else - AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure]) - mv "$tmp/mkfile.tmp" "$SRC/Makefile" - fi - fi - AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)]) - xxxx="####" - echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile - fi -popdef([END])dnl -AS_VAR_POPDEF([SED])dnl -AS_VAR_POPDEF([AUX])dnl -AS_VAR_POPDEF([SRC])dnl -AS_VAR_POPDEF([TOP])dnl -AS_VAR_POPDEF([SUB])dnl -],[dnl -ax_enable_builddir_srcdir="$srcdir" # $srcdir -ax_enable_builddir_host="$HOST" # $HOST / $host -ax_enable_builddir_version="$VERSION" # $VERSION -ax_enable_builddir_package="$PACKAGE" # $PACKAGE -ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX -ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED -ax_enable_builddir="$ax_enable_builddir" # $SUB -])dnl -]) diff --git a/user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 b/user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 deleted file mode 100644 index aab2661..0000000 --- a/user/mpy/lib/libffi/m4/ax_gcc_archflag.m4 +++ /dev/null @@ -1,225 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE]) -# -# DESCRIPTION -# -# This macro tries to guess the "native" arch corresponding to the target -# architecture for use with gcc's -march=arch or -mtune=arch flags. If -# found, the cache variable $ax_cv_gcc_archflag is set to this flag and -# ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to -# "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is -# to add $ax_cv_gcc_archflag to the end of $CFLAGS. -# -# PORTABLE? should be either [yes] (default) or [no]. In the former case, -# the flag is set to -mtune (or equivalent) so that the architecture is -# only used for tuning, but the instruction set used is still portable. In -# the latter case, the flag is set to -march (or equivalent) so that -# architecture-specific instructions are enabled. -# -# The user can specify --with-gcc-arch= in order to override the -# macro's choice of architecture, or --without-gcc-arch to disable this. -# -# When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is -# called unless the user specified --with-gcc-arch manually. -# -# Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID -# -# (The main emphasis here is on recent CPUs, on the principle that doing -# high-performance computing on old hardware is uncommon.) -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# Copyright (c) 2012 Tsukasa Oi -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 11 - -AC_DEFUN([AX_GCC_ARCHFLAG], -[AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_CANONICAL_HOST]) - -AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=], [use architecture for gcc -march/-mtune, instead of guessing])], - ax_gcc_arch=$withval, ax_gcc_arch=yes) - -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT([]) -AC_CACHE_VAL(ax_cv_gcc_archflag, -[ -ax_cv_gcc_archflag="unknown" - -if test "$GCC" = yes; then - -if test "x$ax_gcc_arch" = xyes; then -ax_gcc_arch="" -if test "$cross_compiling" = no; then -case $host_cpu in - i[[3456]]86*|x86_64*) # use cpuid codes - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; - *5??:*:*:*) ax_gcc_arch=pentium ;; - *0?6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6[[9de]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; - *0?6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;; - *1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;; - *1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;; - *1?6c?:*:*:*|*[[23]]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;; - *2?6[[ad]]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *0?6??:*:*:*) ax_gcc_arch=pentiumpro ;; - *6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;; - ?000?f3[[347]]:*:*:*|?000?f4[1347]:*:*:*|?000?f6?:*:*:*) - case $host_cpu in - x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; - *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; - esac ;; - ?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; - esac ;; - *:68747541:*:*) # AMD - case $ax_cv_gcc_x86_cpuid_1 in - *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;; - *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; - *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; - *60?:*:*:*) ax_gcc_arch=k7 ;; - *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;; - *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; - *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; - *6[[68a]]?:*:*:*) - AX_GCC_X86_CPUID(0x80000006) # L2 cache size - case $ax_cv_gcc_x86_cpuid_0x80000006 in - *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256 - ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; - *) ax_gcc_arch="athlon-4 athlon k7" ;; - esac ;; - ?00??f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; - ?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;; - ?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; - ?00??f??:*:*:*) ax_gcc_arch="k8" ;; - ?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;; - ?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;; - *f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;; - esac ;; - *:746e6543:*:*) # IDT - case $ax_cv_gcc_x86_cpuid_1 in - *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; - *58?:*:*:*) ax_gcc_arch=winchip2 ;; - *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;; - *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; - esac ;; - esac - if test x"$ax_gcc_arch" = x; then # fallback - case $host_cpu in - i586*) ax_gcc_arch=pentium ;; - i686*) ax_gcc_arch=pentiumpro ;; - esac - fi - ;; - - sparc*) - AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/]) - cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` - cputype=`echo "$cputype" | tr -d ' -' | sed 's/SPARCIIi/SPARCII/' | tr $as_cr_LETTERS $as_cr_letters` - case $cputype in - *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; - *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; - *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; - *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;; - *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;; - *cypress*) ax_gcc_arch=cypress ;; - esac ;; - - alphaev5) ax_gcc_arch=ev5 ;; - alphaev56) ax_gcc_arch=ev56 ;; - alphapca56) ax_gcc_arch="pca56 ev56" ;; - alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; - alphaev6) ax_gcc_arch=ev6 ;; - alphaev67) ax_gcc_arch=ev67 ;; - alphaev68) ax_gcc_arch="ev68 ev67" ;; - alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; - alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; - alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; - - powerpc*) - cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` - cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` - case $cputype in - *750*) ax_gcc_arch="750 G3" ;; - *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;; - *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;; - *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;; - *970*) ax_gcc_arch="970 G5 power4";; - *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; - *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; - 603ev|8240) ax_gcc_arch="$cputype 603e 603";; - *) ax_gcc_arch=$cputype ;; - esac - ax_gcc_arch="$ax_gcc_arch powerpc" - ;; -esac -fi # not cross-compiling -fi # guess arch - -if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then -for arch in $ax_gcc_arch; do - if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code - flags="-mtune=$arch" - # -mcpu=$arch and m$arch generate nonportable code on every arch except - # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. - case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac - else - flags="-march=$arch -mcpu=$arch -m$arch" - fi - for flag in $flags; do - AX_CHECK_COMPILE_FLAG($flag, [ax_cv_gcc_archflag=$flag; break]) - done - test "x$ax_cv_gcc_archflag" = xunknown || break -done -fi - -fi # $GCC=yes -]) -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT($ax_cv_gcc_archflag) -if test "x$ax_cv_gcc_archflag" = xunknown; then - m4_default([$3],:) -else - m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"]) -fi -]) diff --git a/user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 b/user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 deleted file mode 100644 index 7d46fee..0000000 --- a/user/mpy/lib/libffi/m4/ax_gcc_x86_cpuid.m4 +++ /dev/null @@ -1,79 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_X86_CPUID(OP) -# -# DESCRIPTION -# -# On Pentium and later x86 processors, with gcc or a compiler that has a -# compatible syntax for inline assembly instructions, run a small program -# that executes the cpuid instruction with input OP. This can be used to -# detect the CPU type. -# -# On output, the values of the eax, ebx, ecx, and edx registers are stored -# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable -# ax_cv_gcc_x86_cpuid_OP. -# -# If the cpuid instruction fails (because you are running a -# cross-compiler, or because you are not using gcc, or because you are on -# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP -# is set to the string "unknown". -# -# This macro mainly exists to be used in AX_GCC_ARCHFLAG. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AC_DEFUN([AX_GCC_X86_CPUID], -[AC_REQUIRE([AC_PROG_CC]) -AC_LANG_PUSH([C]) -AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, - [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ - int op = $1, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; -])], - [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown])]) -AC_LANG_POP([C]) -]) diff --git a/user/mpy/lib/libffi/man/Makefile.am b/user/mpy/lib/libffi/man/Makefile.am deleted file mode 100644 index afcbfb6..0000000 --- a/user/mpy/lib/libffi/man/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -## Process this with automake to create Makefile.in - -AUTOMAKE_OPTIONS=foreign - -EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 - -man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 - diff --git a/user/mpy/lib/libffi/man/ffi.3 b/user/mpy/lib/libffi/man/ffi.3 deleted file mode 100644 index 1f1d303..0000000 --- a/user/mpy/lib/libffi/man/ffi.3 +++ /dev/null @@ -1,41 +0,0 @@ -.Dd February 15, 2008 -.Dt FFI 3 -.Sh NAME -.Nm FFI -.Nd Foreign Function Interface -.Sh LIBRARY -libffi, -lffi -.Sh SYNOPSIS -.In ffi.h -.Ft ffi_status -.Fo ffi_prep_cif -.Fa "ffi_cif *cif" -.Fa "ffi_abi abi" -.Fa "unsigned int nargs" -.Fa "ffi_type *rtype" -.Fa "ffi_type **atypes" -.Fc -.Ft void -.Fo ffi_prep_cif_var -.Fa "ffi_cif *cif" -.Fa "ffi_abi abi" -.Fa "unsigned int nfixedargs" -.Fa "unsigned int ntotalargs" -.Fa "ffi_type *rtype" -.Fa "ffi_type **atypes" -.Fc -.Ft void -.Fo ffi_call -.Fa "ffi_cif *cif" -.Fa "void (*fn)(void)" -.Fa "void *rvalue" -.Fa "void **avalue" -.Fc -.Sh DESCRIPTION -The foreign function interface provides a mechanism by which a function can -generate a call to another function at runtime without requiring knowledge of -the called function's interface at compile time. -.Sh SEE ALSO -.Xr ffi_prep_cif 3 , -.Xr ffi_prep_cif_var 3 , -.Xr ffi_call 3 diff --git a/user/mpy/lib/libffi/man/ffi_call.3 b/user/mpy/lib/libffi/man/ffi_call.3 deleted file mode 100644 index 5351513..0000000 --- a/user/mpy/lib/libffi/man/ffi_call.3 +++ /dev/null @@ -1,103 +0,0 @@ -.Dd February 15, 2008 -.Dt ffi_call 3 -.Sh NAME -.Nm ffi_call -.Nd Invoke a foreign function. -.Sh SYNOPSIS -.In ffi.h -.Ft void -.Fo ffi_call -.Fa "ffi_cif *cif" -.Fa "void (*fn)(void)" -.Fa "void *rvalue" -.Fa "void **avalue" -.Fc -.Sh DESCRIPTION -The -.Nm ffi_call -function provides a simple mechanism for invoking a function without -requiring knowledge of the function's interface at compile time. -.Fa fn -is called with the values retrieved from the pointers in the -.Fa avalue -array. The return value from -.Fa fn -is placed in storage pointed to by -.Fa rvalue . -.Fa cif -contains information describing the data types, sizes and alignments of the -arguments to and return value from -.Fa fn , -and must be initialized with -.Nm ffi_prep_cif -before it is used with -.Nm ffi_call . -.Pp -.Fa rvalue -must point to storage that is sizeof(ffi_arg) or larger for non-floating point -types. For smaller-sized return value types, the -.Nm ffi_arg -or -.Nm ffi_sarg -integral type must be used to hold -the return value. -.Sh EXAMPLES -.Bd -literal -#include -#include - -unsigned char -foo(unsigned int, float); - -int -main(int argc, const char **argv) -{ - ffi_cif cif; - ffi_type *arg_types[2]; - void *arg_values[2]; - ffi_status status; - - // Because the return value from foo() is smaller than sizeof(long), it - // must be passed as ffi_arg or ffi_sarg. - ffi_arg result; - - // Specify the data type of each argument. Available types are defined - // in . - arg_types[0] = &ffi_type_uint; - arg_types[1] = &ffi_type_float; - - // Prepare the ffi_cif structure. - if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, - 2, &ffi_type_uint8, arg_types)) != FFI_OK) - { - // Handle the ffi_status error. - } - - // Specify the values of each argument. - unsigned int arg1 = 42; - float arg2 = 5.1; - - arg_values[0] = &arg1; - arg_values[1] = &arg2; - - // Invoke the function. - ffi_call(&cif, FFI_FN(foo), &result, arg_values); - - // The ffi_arg 'result' now contains the unsigned char returned from foo(), - // which can be accessed by a typecast. - printf("result is %hhu", (unsigned char)result); - - return 0; -} - -// The target function. -unsigned char -foo(unsigned int x, float y) -{ - unsigned char result = x - y; - return result; -} -.Ed -.Sh SEE ALSO -.Xr ffi 3 , -.Xr ffi_prep_cif 3 diff --git a/user/mpy/lib/libffi/man/ffi_prep_cif.3 b/user/mpy/lib/libffi/man/ffi_prep_cif.3 deleted file mode 100644 index ab2be8a..0000000 --- a/user/mpy/lib/libffi/man/ffi_prep_cif.3 +++ /dev/null @@ -1,68 +0,0 @@ -.Dd February 15, 2008 -.Dt ffi_prep_cif 3 -.Sh NAME -.Nm ffi_prep_cif -.Nd Prepare a -.Nm ffi_cif -structure for use with -.Nm ffi_call -. -.Sh SYNOPSIS -.In ffi.h -.Ft ffi_status -.Fo ffi_prep_cif -.Fa "ffi_cif *cif" -.Fa "ffi_abi abi" -.Fa "unsigned int nargs" -.Fa "ffi_type *rtype" -.Fa "ffi_type **atypes" -.Fc -.Sh DESCRIPTION -The -.Nm ffi_prep_cif -function prepares a -.Nm ffi_cif -structure for use with -.Nm ffi_call -. -.Fa abi -specifies a set of calling conventions to use. -.Fa atypes -is an array of -.Fa nargs -pointers to -.Nm ffi_type -structs that describe the data type, size and alignment of each argument. -.Fa rtype -points to an -.Nm ffi_type -that describes the data type, size and alignment of the -return value. Note that to call a variadic function -.Nm ffi_prep_cif_var -must be used instead. -.Sh RETURN VALUES -Upon successful completion, -.Nm ffi_prep_cif -returns -.Nm FFI_OK . -It will return -.Nm FFI_BAD_TYPEDEF -if -.Fa cif -is -.Nm NULL -or -.Fa atypes -or -.Fa rtype -is malformed. If -.Fa abi -does not refer to a valid ABI, -.Nm FFI_BAD_ABI -will be returned. Available ABIs are -defined in -.Nm . -.Sh SEE ALSO -.Xr ffi 3 , -.Xr ffi_call 3 , -.Xr ffi_prep_cif_var 3 diff --git a/user/mpy/lib/libffi/man/ffi_prep_cif_var.3 b/user/mpy/lib/libffi/man/ffi_prep_cif_var.3 deleted file mode 100644 index 7e19d0b..0000000 --- a/user/mpy/lib/libffi/man/ffi_prep_cif_var.3 +++ /dev/null @@ -1,73 +0,0 @@ -.Dd January 25, 2011 -.Dt ffi_prep_cif_var 3 -.Sh NAME -.Nm ffi_prep_cif_var -.Nd Prepare a -.Nm ffi_cif -structure for use with -.Nm ffi_call -for variadic functions. -.Sh SYNOPSIS -.In ffi.h -.Ft ffi_status -.Fo ffi_prep_cif_var -.Fa "ffi_cif *cif" -.Fa "ffi_abi abi" -.Fa "unsigned int nfixedargs" -.Fa "unsigned int ntotalargs" -.Fa "ffi_type *rtype" -.Fa "ffi_type **atypes" -.Fc -.Sh DESCRIPTION -The -.Nm ffi_prep_cif_var -function prepares a -.Nm ffi_cif -structure for use with -.Nm ffi_call -for variadic functions. -.Fa abi -specifies a set of calling conventions to use. -.Fa atypes -is an array of -.Fa ntotalargs -pointers to -.Nm ffi_type -structs that describe the data type, size and alignment of each argument. -.Fa rtype -points to an -.Nm ffi_type -that describes the data type, size and alignment of the -return value. -.Fa nfixedargs -must contain the number of fixed (non-variadic) arguments. -Note that to call a non-variadic function -.Nm ffi_prep_cif -must be used. -.Sh RETURN VALUES -Upon successful completion, -.Nm ffi_prep_cif_var -returns -.Nm FFI_OK . -It will return -.Nm FFI_BAD_TYPEDEF -if -.Fa cif -is -.Nm NULL -or -.Fa atypes -or -.Fa rtype -is malformed. If -.Fa abi -does not refer to a valid ABI, -.Nm FFI_BAD_ABI -will be returned. Available ABIs are -defined in -.Nm -. -.Sh SEE ALSO -.Xr ffi 3 , -.Xr ffi_call 3 , -.Xr ffi_prep_cif 3 diff --git a/user/mpy/lib/libffi/msvcc.sh b/user/mpy/lib/libffi/msvcc.sh deleted file mode 100755 index 65fbfef..0000000 --- a/user/mpy/lib/libffi/msvcc.sh +++ /dev/null @@ -1,257 +0,0 @@ -#!/bin/sh - -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the MSVC wrappificator. -# -# The Initial Developer of the Original Code is -# Timothy Wall . -# Portions created by the Initial Developer are Copyright (C) 2009 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Daniel Witte -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# GCC-compatible wrapper for cl.exe and ml.exe. Arguments are given in GCC -# format and translated into something sensible for cl or ml. -# - -args_orig=$@ -args="-nologo -W3" -static_crt= -debug_crt= -cl="cl" -ml="ml" -safeseh="-safeseh" -output= - -while [ $# -gt 0 ] -do - case $1 - in - -fexceptions) - # Don't enable exceptions for now. - #args="$args -EHac" - shift 1 - ;; - -m32) - shift 1 - ;; - -m64) - ml="ml64" # "$MSVC/x86_amd64/ml64" - safeseh= - shift 1 - ;; - -clang-cl) - cl="clang-cl" - safeseh= - shift 1 - ;; - -O0) - args="$args -Od" - shift 1 - ;; - -O*) - # Runtime error checks (enabled by setting -RTC1 in the -DFFI_DEBUG - # case below) are not compatible with optimization flags and will - # cause the build to fail. Therefore, drop the optimization flag if - # -DFFI_DEBUG is also set. - case $args_orig in - *-DFFI_DEBUG*) - args="$args" - ;; - *) - # The ax_cc_maxopt.m4 macro from the upstream autoconf-archive - # project doesn't support MSVC and therefore ends up trying to - # use -O3. Use the equivalent "max optimization" flag for MSVC - # instead of erroring out. - case $1 in - -O3) - args="$args -O2" - ;; - *) - args="$args $1" - ;; - esac - opt="true" - ;; - esac - shift 1 - ;; - -g) - # Enable debug symbol generation. - args="$args -Zi" - shift 1 - ;; - -DFFI_DEBUG) - # Enable runtime error checks. - args="$args -RTC1" - defines="$defines $1" - shift 1 - ;; - -DUSE_STATIC_RTL) - # Link against static CRT. - static_crt=1 - shift 1 - ;; - -DUSE_DEBUG_RTL) - # Link against debug CRT. - debug_crt=1 - shift 1 - ;; - -c) - args="$args -c" - args="$(echo $args | sed 's%/Fe%/Fo%g')" - single="-c" - shift 1 - ;; - -D*=*) - name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')" - value="$(echo $1|sed 's/-D[^=][^=]*=//g')" - args="$args -D${name}='$value'" - defines="$defines -D${name}='$value'" - shift 1 - ;; - -D*) - args="$args $1" - defines="$defines $1" - shift 1 - ;; - -I) - args="$args -I$2" - includes="$includes -I$2" - shift 2 - ;; - -I*) - args="$args $1" - includes="$includes $1" - shift 1 - ;; - -W|-Wextra) - # TODO map extra warnings - shift 1 - ;; - -Wall) - # -Wall on MSVC is overzealous, and we already build with -W3. Nothing - # to do here. - shift 1 - ;; - -pedantic) - # libffi tests -pedantic with -Wall, so drop it also. - shift 1 - ;; - -Werror) - args="$args -WX" - shift 1 - ;; - -W*) - # TODO map specific warnings - shift 1 - ;; - -S) - args="$args -FAs" - shift 1 - ;; - -o) - outdir="$(dirname $2)" - base="$(basename $2|sed 's/\.[^.]*//g')" - if [ -n "$single" ]; then - output="-Fo$2" - else - output="-Fe$2" - fi - if [ -n "$assembly" ]; then - args="$args $output" - else - args="$args $output -Fd$outdir/$base -Fp$outdir/$base -Fa$outdir/$base" - fi - shift 2 - ;; - *.S) - src=$1 - assembly="true" - shift 1 - ;; - *.c) - args="$args $1" - shift 1 - ;; - *) - # Assume it's an MSVC argument, and pass it through. - args="$args $1" - shift 1 - ;; - esac -done - -# If -Zi is specified, certain optimizations are implicitly disabled -# by MSVC. Add back those optimizations if this is an optimized build. -# NOTE: These arguments must come after all others. -if [ -n "$opt" ]; then - args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO" -fi - -if [ -n "$static_crt" ]; then - md=-MT -else - md=-MD -fi - -if [ -n "$debug_crt" ]; then - md="${md}d" -fi - -if [ -n "$assembly" ]; then - if [ -z "$outdir" ]; then - outdir="." - fi - ppsrc="$outdir/$(basename $src|sed 's/.S$/.asm/g')" - echo "$cl -nologo -EP $includes $defines $src > $ppsrc" - "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $? - output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')" - args="-nologo $safeseh $single $output $ppsrc" - - echo "$ml $args" - eval "\"$ml\" $args" - result=$? - - # required to fix ml64 broken output? - #mv *.obj $outdir -else - args="$md $args" - echo "$cl $args" - # Return an error code of 1 if an invalid command line parameter is passed - # instead of just ignoring it. - eval "(\"$cl\" $args 2>&1 1>&3 | \ - awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1" - result=$? -fi - -exit $result - diff --git a/user/mpy/lib/libffi/src/aarch64/ffi.c b/user/mpy/lib/libffi/src/aarch64/ffi.c deleted file mode 100644 index f79602b..0000000 --- a/user/mpy/lib/libffi/src/aarch64/ffi.c +++ /dev/null @@ -1,1152 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM 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. */ - -#include -#include -#include -#include -#include -#include "internal.h" - -/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; - all further uses in this file will refer to the 128-bit type. */ -#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE -# if FFI_TYPE_LONGDOUBLE != 4 -# error FFI_TYPE_LONGDOUBLE out of date -# endif -#else -# undef FFI_TYPE_LONGDOUBLE -# define FFI_TYPE_LONGDOUBLE 4 -#endif - -union _d -{ - UINT64 d; - UINT32 s[2]; -}; - -struct _v -{ - union _d d[2] __attribute__((aligned(16))); -}; - -struct call_context -{ - struct _v v[N_V_ARG_REG]; - UINT64 x[N_X_ARG_REG]; -}; - -#if defined (__clang__) && defined (__APPLE__) -extern void sys_icache_invalidate (void *start, size_t len); -#endif - -static inline void -ffi_clear_cache (void *start, void *end) -{ -#if defined (__clang__) && defined (__APPLE__) - sys_icache_invalidate (start, (char *)end - (char *)start); -#elif defined (__GNUC__) - __builtin___clear_cache (start, end); -#else -#error "Missing builtin to flush instruction cache" -#endif -} - -/* A subroutine of is_vfp_type. Given a structure type, return the type code - of the first non-structure element. Recurse for structure elements. - Return -1 if the structure is in fact empty, i.e. no nested elements. */ - -static int -is_hfa0 (const ffi_type *ty) -{ - ffi_type **elements = ty->elements; - int i, ret = -1; - - if (elements != NULL) - for (i = 0; elements[i]; ++i) - { - ret = elements[i]->type; - if (ret == FFI_TYPE_STRUCT || ret == FFI_TYPE_COMPLEX) - { - ret = is_hfa0 (elements[i]); - if (ret < 0) - continue; - } - break; - } - - return ret; -} - -/* A subroutine of is_vfp_type. Given a structure type, return true if all - of the non-structure elements are the same as CANDIDATE. */ - -static int -is_hfa1 (const ffi_type *ty, int candidate) -{ - ffi_type **elements = ty->elements; - int i; - - if (elements != NULL) - for (i = 0; elements[i]; ++i) - { - int t = elements[i]->type; - if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) - { - if (!is_hfa1 (elements[i], candidate)) - return 0; - } - else if (t != candidate) - return 0; - } - - return 1; -} - -/* Determine if TY may be allocated to the FP registers. This is both an - fp scalar type as well as an homogenous floating point aggregate (HFA). - That is, a structure consisting of 1 to 4 members of all the same type, - where that type is an fp scalar. - - Returns non-zero iff TY is an HFA. The result is the AARCH64_RET_* - constant for the type. */ - -static int -is_vfp_type (const ffi_type *ty) -{ - ffi_type **elements; - int candidate, i; - size_t size, ele_count; - - /* Quickest tests first. */ - candidate = ty->type; - switch (candidate) - { - default: - return 0; - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - ele_count = 1; - goto done; - case FFI_TYPE_COMPLEX: - candidate = ty->elements[0]->type; - switch (candidate) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - ele_count = 2; - goto done; - } - return 0; - case FFI_TYPE_STRUCT: - break; - } - - /* No HFA types are smaller than 4 bytes, or larger than 64 bytes. */ - size = ty->size; - if (size < 4 || size > 64) - return 0; - - /* Find the type of the first non-structure member. */ - elements = ty->elements; - candidate = elements[0]->type; - if (candidate == FFI_TYPE_STRUCT || candidate == FFI_TYPE_COMPLEX) - { - for (i = 0; ; ++i) - { - candidate = is_hfa0 (elements[i]); - if (candidate >= 0) - break; - } - } - - /* If the first member is not a floating point type, it's not an HFA. - Also quickly re-check the size of the structure. */ - switch (candidate) - { - case FFI_TYPE_FLOAT: - ele_count = size / sizeof(float); - if (size != ele_count * sizeof(float)) - return 0; - break; - case FFI_TYPE_DOUBLE: - ele_count = size / sizeof(double); - if (size != ele_count * sizeof(double)) - return 0; - break; - case FFI_TYPE_LONGDOUBLE: - ele_count = size / sizeof(long double); - if (size != ele_count * sizeof(long double)) - return 0; - break; - default: - return 0; - } - if (ele_count > 4) - return 0; - - /* Finally, make sure that all scalar elements are the same type. */ - for (i = 0; elements[i]; ++i) - { - int t = elements[i]->type; - if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) - { - if (!is_hfa1 (elements[i], candidate)) - return 0; - } - else if (t != candidate) - return 0; - } - - /* All tests succeeded. Encode the result. */ - done: - return candidate * 4 + (4 - ele_count); -} - -/* Representation of the procedure call argument marshalling - state. - - The terse state variable names match the names used in the AARCH64 - PCS. */ - -struct arg_state -{ - unsigned ngrn; /* Next general-purpose register number. */ - unsigned nsrn; /* Next vector register number. */ - size_t nsaa; /* Next stack offset. */ - -#if defined (__APPLE__) - unsigned allocating_variadic; -#endif -}; - -/* Initialize a procedure call argument marshalling state. */ -static void -arg_init (struct arg_state *state) -{ - state->ngrn = 0; - state->nsrn = 0; - state->nsaa = 0; -#if defined (__APPLE__) - state->allocating_variadic = 0; -#endif -} - -/* Allocate an aligned slot on the stack and return a pointer to it. */ -static void * -allocate_to_stack (struct arg_state *state, void *stack, - size_t alignment, size_t size) -{ - size_t nsaa = state->nsaa; - - /* Round up the NSAA to the larger of 8 or the natural - alignment of the argument's type. */ -#if defined (__APPLE__) - if (state->allocating_variadic && alignment < 8) - alignment = 8; -#else - if (alignment < 8) - alignment = 8; -#endif - - nsaa = ALIGN (nsaa, alignment); - state->nsaa = nsaa + size; - - return (char *)stack + nsaa; -} - -static ffi_arg -extend_integer_type (void *source, int type) -{ - switch (type) - { - case FFI_TYPE_UINT8: - return *(UINT8 *) source; - case FFI_TYPE_SINT8: - return *(SINT8 *) source; - case FFI_TYPE_UINT16: - return *(UINT16 *) source; - case FFI_TYPE_SINT16: - return *(SINT16 *) source; - case FFI_TYPE_UINT32: - return *(UINT32 *) source; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - return *(SINT32 *) source; - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - return *(UINT64 *) source; - break; - case FFI_TYPE_POINTER: - return *(uintptr_t *) source; - default: - abort(); - } -} - -static void -extend_hfa_type (void *dest, void *src, int h) -{ - int f = h - AARCH64_RET_S4; - void *x0; - - asm volatile ( - "adr %0, 0f\n" -" add %0, %0, %1\n" -" br %0\n" -"0: ldp s16, s17, [%3]\n" /* S4 */ -" ldp s18, s19, [%3, #8]\n" -" b 4f\n" -" ldp s16, s17, [%3]\n" /* S3 */ -" ldr s18, [%3, #8]\n" -" b 3f\n" -" ldp s16, s17, [%3]\n" /* S2 */ -" b 2f\n" -" nop\n" -" ldr s16, [%3]\n" /* S1 */ -" b 1f\n" -" nop\n" -" ldp d16, d17, [%3]\n" /* D4 */ -" ldp d18, d19, [%3, #16]\n" -" b 4f\n" -" ldp d16, d17, [%3]\n" /* D3 */ -" ldr d18, [%3, #16]\n" -" b 3f\n" -" ldp d16, d17, [%3]\n" /* D2 */ -" b 2f\n" -" nop\n" -" ldr d16, [%3]\n" /* D1 */ -" b 1f\n" -" nop\n" -" ldp q16, q17, [%3]\n" /* Q4 */ -" ldp q18, q19, [%3, #16]\n" -" b 4f\n" -" ldp q16, q17, [%3]\n" /* Q3 */ -" ldr q18, [%3, #16]\n" -" b 3f\n" -" ldp q16, q17, [%3]\n" /* Q2 */ -" b 2f\n" -" nop\n" -" ldr q16, [%3]\n" /* Q1 */ -" b 1f\n" -"4: str q19, [%2, #48]\n" -"3: str q18, [%2, #32]\n" -"2: str q17, [%2, #16]\n" -"1: str q16, [%2]" - : "=&r"(x0) - : "r"(f * 12), "r"(dest), "r"(src) - : "memory", "v16", "v17", "v18", "v19"); -} - -static void * -compress_hfa_type (void *dest, void *reg, int h) -{ - switch (h) - { - case AARCH64_RET_S1: - if (dest == reg) - { -#ifdef __AARCH64EB__ - dest += 12; -#endif - } - else - *(float *)dest = *(float *)reg; - break; - case AARCH64_RET_S2: - asm ("ldp q16, q17, [%1]\n\t" - "st2 { v16.s, v17.s }[0], [%0]" - : : "r"(dest), "r"(reg) : "memory", "v16", "v17"); - break; - case AARCH64_RET_S3: - asm ("ldp q16, q17, [%1]\n\t" - "ldr q18, [%1, #32]\n\t" - "st3 { v16.s, v17.s, v18.s }[0], [%0]" - : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18"); - break; - case AARCH64_RET_S4: - asm ("ldp q16, q17, [%1]\n\t" - "ldp q18, q19, [%1, #32]\n\t" - "st4 { v16.s, v17.s, v18.s, v19.s }[0], [%0]" - : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18", "v19"); - break; - - case AARCH64_RET_D1: - if (dest == reg) - { -#ifdef __AARCH64EB__ - dest += 8; -#endif - } - else - *(double *)dest = *(double *)reg; - break; - case AARCH64_RET_D2: - asm ("ldp q16, q17, [%1]\n\t" - "st2 { v16.d, v17.d }[0], [%0]" - : : "r"(dest), "r"(reg) : "memory", "v16", "v17"); - break; - case AARCH64_RET_D3: - asm ("ldp q16, q17, [%1]\n\t" - "ldr q18, [%1, #32]\n\t" - "st3 { v16.d, v17.d, v18.d }[0], [%0]" - : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18"); - break; - case AARCH64_RET_D4: - asm ("ldp q16, q17, [%1]\n\t" - "ldp q18, q19, [%1, #32]\n\t" - "st4 { v16.d, v17.d, v18.d, v19.d }[0], [%0]" - : : "r"(dest), "r"(reg) : "memory", "v16", "v17", "v18", "v19"); - break; - - default: - if (dest != reg) - return memcpy (dest, reg, 16 * (4 - (h & 3))); - break; - } - return dest; -} - -/* Either allocate an appropriate register for the argument type, or if - none are available, allocate a stack slot and return a pointer - to the allocated space. */ - -static void * -allocate_int_to_reg_or_stack (struct call_context *context, - struct arg_state *state, - void *stack, size_t size) -{ - if (state->ngrn < N_X_ARG_REG) - return &context->x[state->ngrn++]; - - state->ngrn = N_X_ARG_REG; - return allocate_to_stack (state, stack, size, size); -} - -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - ffi_type *rtype = cif->rtype; - size_t bytes = cif->bytes; - int flags, i, n; - - switch (rtype->type) - { - case FFI_TYPE_VOID: - flags = AARCH64_RET_VOID; - break; - case FFI_TYPE_UINT8: - flags = AARCH64_RET_UINT8; - break; - case FFI_TYPE_UINT16: - flags = AARCH64_RET_UINT16; - break; - case FFI_TYPE_UINT32: - flags = AARCH64_RET_UINT32; - break; - case FFI_TYPE_SINT8: - flags = AARCH64_RET_SINT8; - break; - case FFI_TYPE_SINT16: - flags = AARCH64_RET_SINT16; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - flags = AARCH64_RET_SINT32; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - flags = AARCH64_RET_INT64; - break; - case FFI_TYPE_POINTER: - flags = (sizeof(void *) == 4 ? AARCH64_RET_UINT32 : AARCH64_RET_INT64); - break; - - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: - flags = is_vfp_type (rtype); - if (flags == 0) - { - size_t s = rtype->size; - if (s > 16) - { - flags = AARCH64_RET_VOID | AARCH64_RET_IN_MEM; - bytes += 8; - } - else if (s == 16) - flags = AARCH64_RET_INT128; - else if (s == 8) - flags = AARCH64_RET_INT64; - else - flags = AARCH64_RET_INT128 | AARCH64_RET_NEED_COPY; - } - break; - - default: - abort(); - } - - for (i = 0, n = cif->nargs; i < n; i++) - if (is_vfp_type (cif->arg_types[i])) - { - flags |= AARCH64_FLAG_ARG_V; - break; - } - - /* Round the stack up to a multiple of the stack alignment requirement. */ - cif->bytes = ALIGN(bytes, 16); - cif->flags = flags; -#if defined (__APPLE__) - cif->aarch64_nfixedargs = 0; -#endif - - return FFI_OK; -} - -#if defined (__APPLE__) -/* Perform Apple-specific cif processing for variadic calls */ -ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, - unsigned int nfixedargs, - unsigned int ntotalargs) -{ - ffi_status status = ffi_prep_cif_machdep (cif); - cif->aarch64_nfixedargs = nfixedargs; - return status; -} -#endif /* __APPLE__ */ - -extern void ffi_call_SYSV (struct call_context *context, void *frame, - void (*fn)(void), void *rvalue, int flags, - void *closure) FFI_HIDDEN; - -/* Call a function with the provided arguments and capture the return - value. */ -static void -ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, - void **avalue, void *closure) -{ - struct call_context *context; - void *stack, *frame, *rvalue; - struct arg_state state; - size_t stack_bytes, rtype_size, rsize; - int i, nargs, flags; - ffi_type *rtype; - - flags = cif->flags; - rtype = cif->rtype; - rtype_size = rtype->size; - stack_bytes = cif->bytes; - - /* If the target function returns a structure via hidden pointer, - then we cannot allow a null rvalue. Otherwise, mash a null - rvalue to void return type. */ - rsize = 0; - if (flags & AARCH64_RET_IN_MEM) - { - if (orig_rvalue == NULL) - rsize = rtype_size; - } - else if (orig_rvalue == NULL) - flags &= AARCH64_FLAG_ARG_V; - else if (flags & AARCH64_RET_NEED_COPY) - rsize = 16; - - /* Allocate consectutive stack for everything we'll need. */ - context = alloca (sizeof(struct call_context) + stack_bytes + 32 + rsize); - stack = context + 1; - frame = stack + stack_bytes; - rvalue = (rsize ? frame + 32 : orig_rvalue); - - arg_init (&state); - for (i = 0, nargs = cif->nargs; i < nargs; i++) - { - ffi_type *ty = cif->arg_types[i]; - size_t s = ty->size; - void *a = avalue[i]; - int h, t; - - t = ty->type; - switch (t) - { - case FFI_TYPE_VOID: - FFI_ASSERT (0); - break; - - /* If the argument is a basic type the argument is allocated to an - appropriate register, or if none are available, to the stack. */ - case FFI_TYPE_INT: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_POINTER: - do_pointer: - { - ffi_arg ext = extend_integer_type (a, t); - if (state.ngrn < N_X_ARG_REG) - context->x[state.ngrn++] = ext; - else - { - void *d = allocate_to_stack (&state, stack, ty->alignment, s); - state.ngrn = N_X_ARG_REG; - /* Note that the default abi extends each argument - to a full 64-bit slot, while the iOS abi allocates - only enough space. */ -#ifdef __APPLE__ - memcpy(d, a, s); -#else - *(ffi_arg *)d = ext; -#endif - } - } - break; - - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: - { - void *dest; - - h = is_vfp_type (ty); - if (h) - { - int elems = 4 - (h & 3); - if (state.nsrn + elems <= N_V_ARG_REG) - { - dest = &context->v[state.nsrn]; - state.nsrn += elems; - extend_hfa_type (dest, a, h); - break; - } - state.nsrn = N_V_ARG_REG; - dest = allocate_to_stack (&state, stack, ty->alignment, s); - } - else if (s > 16) - { - /* If the argument is a composite type that is larger than 16 - bytes, then the argument has been copied to memory, and - the argument is replaced by a pointer to the copy. */ - a = &avalue[i]; - t = FFI_TYPE_POINTER; - goto do_pointer; - } - else - { - size_t n = (s + 7) / 8; - if (state.ngrn + n <= N_X_ARG_REG) - { - /* If the argument is a composite type and the size in - double-words is not more than the number of available - X registers, then the argument is copied into - consecutive X registers. */ - dest = &context->x[state.ngrn]; - state.ngrn += n; - } - else - { - /* Otherwise, there are insufficient X registers. Further - X register allocations are prevented, the NSAA is - adjusted and the argument is copied to memory at the - adjusted NSAA. */ - state.ngrn = N_X_ARG_REG; - dest = allocate_to_stack (&state, stack, ty->alignment, s); - } - } - memcpy (dest, a, s); - } - break; - - default: - abort(); - } - -#if defined (__APPLE__) - if (i + 1 == cif->aarch64_nfixedargs) - { - state.ngrn = N_X_ARG_REG; - state.nsrn = N_V_ARG_REG; - state.allocating_variadic = 1; - } -#endif - } - - ffi_call_SYSV (context, frame, fn, rvalue, flags, closure); - - if (flags & AARCH64_RET_NEED_COPY) - memcpy (orig_rvalue, rvalue, rtype_size); -} - -void -ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -#ifdef FFI_GO_CLOSURES -void -ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} -#endif /* FFI_GO_CLOSURES */ - -/* Build a trampoline. */ - -extern void ffi_closure_SYSV (void) FFI_HIDDEN; -extern void ffi_closure_SYSV_V (void) FFI_HIDDEN; - -#if FFI_EXEC_TRAMPOLINE_TABLE - -#include -#include -#include -#include - -extern void *ffi_closure_trampoline_table_page; - -typedef struct ffi_trampoline_table ffi_trampoline_table; -typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry; - -struct ffi_trampoline_table -{ - /* contiguous writable and executable pages */ - vm_address_t config_page; - vm_address_t trampoline_page; - - /* free list tracking */ - uint16_t free_count; - ffi_trampoline_table_entry *free_list; - ffi_trampoline_table_entry *free_list_pool; - - ffi_trampoline_table *prev; - ffi_trampoline_table *next; -}; - -struct ffi_trampoline_table_entry -{ - void *(*trampoline) (); - ffi_trampoline_table_entry *next; -}; - -/* The trampoline configuration is placed a page prior to the trampoline's entry point */ -#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - PAGE_SIZE)); - -/* Total number of trampolines that fit in one trampoline table */ -#define FFI_TRAMPOLINE_COUNT (PAGE_SIZE / FFI_TRAMPOLINE_SIZE) - -static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER; -static ffi_trampoline_table *ffi_trampoline_tables = NULL; - -static ffi_trampoline_table * -ffi_trampoline_table_alloc () -{ - ffi_trampoline_table *table = NULL; - - /* Loop until we can allocate two contiguous pages */ - while (table == NULL) - { - vm_address_t config_page = 0x0; - kern_return_t kt; - - /* Try to allocate two pages */ - kt = - vm_allocate (mach_task_self (), &config_page, PAGE_SIZE * 2, - VM_FLAGS_ANYWHERE); - if (kt != KERN_SUCCESS) - { - fprintf (stderr, "vm_allocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - break; - } - - /* Now drop the second half of the allocation to make room for the trampoline table */ - vm_address_t trampoline_page = config_page + PAGE_SIZE; - kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - { - fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - break; - } - - /* Remap the trampoline table to directly follow the config page */ - vm_prot_t cur_prot; - vm_prot_t max_prot; - - kt = - vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, - mach_task_self (), - (vm_address_t) & ffi_closure_trampoline_table_page, FALSE, - &cur_prot, &max_prot, VM_INHERIT_SHARE); - - /* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */ - if (kt != KERN_SUCCESS) - { - /* Log unexpected failures */ - if (kt != KERN_NO_SPACE) - { - fprintf (stderr, "vm_remap() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - } - - vm_deallocate (mach_task_self (), config_page, PAGE_SIZE); - continue; - } - - /* We have valid trampoline and config pages */ - table = calloc (1, sizeof (ffi_trampoline_table)); - table->free_count = FFI_TRAMPOLINE_COUNT; - table->config_page = config_page; - table->trampoline_page = trampoline_page; - - /* Create and initialize the free list */ - table->free_list_pool = - calloc (FFI_TRAMPOLINE_COUNT, sizeof (ffi_trampoline_table_entry)); - - uint16_t i; - for (i = 0; i < table->free_count; i++) - { - ffi_trampoline_table_entry *entry = &table->free_list_pool[i]; - entry->trampoline = - (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); - - if (i < table->free_count - 1) - entry->next = &table->free_list_pool[i + 1]; - } - - table->free_list = table->free_list_pool; - } - - return table; -} - -void * -ffi_closure_alloc (size_t size, void **code) -{ - /* Create the closure */ - ffi_closure *closure = malloc (size); - if (closure == NULL) - return NULL; - - pthread_mutex_lock (&ffi_trampoline_lock); - - /* Check for an active trampoline table with available entries. */ - ffi_trampoline_table *table = ffi_trampoline_tables; - if (table == NULL || table->free_list == NULL) - { - table = ffi_trampoline_table_alloc (); - if (table == NULL) - { - free (closure); - return NULL; - } - - /* Insert the new table at the top of the list */ - table->next = ffi_trampoline_tables; - if (table->next != NULL) - table->next->prev = table; - - ffi_trampoline_tables = table; - } - - /* Claim the free entry */ - ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list; - ffi_trampoline_tables->free_list = entry->next; - ffi_trampoline_tables->free_count--; - entry->next = NULL; - - pthread_mutex_unlock (&ffi_trampoline_lock); - - /* Initialize the return values */ - *code = entry->trampoline; - closure->trampoline_table = table; - closure->trampoline_table_entry = entry; - - return closure; -} - -void -ffi_closure_free (void *ptr) -{ - ffi_closure *closure = ptr; - - pthread_mutex_lock (&ffi_trampoline_lock); - - /* Fetch the table and entry references */ - ffi_trampoline_table *table = closure->trampoline_table; - ffi_trampoline_table_entry *entry = closure->trampoline_table_entry; - - /* Return the entry to the free list */ - entry->next = table->free_list; - table->free_list = entry; - table->free_count++; - - /* If all trampolines within this table are free, and at least one other table exists, deallocate - * the table */ - if (table->free_count == FFI_TRAMPOLINE_COUNT - && ffi_trampoline_tables != table) - { - /* Remove from the list */ - if (table->prev != NULL) - table->prev->next = table->next; - - if (table->next != NULL) - table->next->prev = table->prev; - - /* Deallocate pages */ - kern_return_t kt; - kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - - kt = - vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - - /* Deallocate free list */ - free (table->free_list_pool); - free (table); - } - else if (ffi_trampoline_tables != table) - { - /* Otherwise, bump this table to the top of the list */ - table->prev = NULL; - table->next = ffi_trampoline_tables; - if (ffi_trampoline_tables != NULL) - ffi_trampoline_tables->prev = table; - - ffi_trampoline_tables = table; - } - - pthread_mutex_unlock (&ffi_trampoline_lock); - - /* Free the closure */ - free (closure); -} - -#endif - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - void (*start)(void); - - if (cif->flags & AARCH64_FLAG_ARG_V) - start = ffi_closure_SYSV_V; - else - start = ffi_closure_SYSV; - -#if FFI_EXEC_TRAMPOLINE_TABLE - void **config = FFI_TRAMPOLINE_CODELOC_CONFIG (codeloc); - config[0] = closure; - config[1] = start; -#else - static const unsigned char trampoline[16] = { - 0x90, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */ - 0xf1, 0xff, 0xff, 0x10, /* adr x17, tramp+0 */ - 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ - }; - char *tramp = closure->tramp; - - memcpy (tramp, trampoline, sizeof(trampoline)); - - *(UINT64 *)(tramp + 16) = (uintptr_t)start; - - ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE); -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -#ifdef FFI_GO_CLOSURES -extern void ffi_go_closure_SYSV (void) FFI_HIDDEN; -extern void ffi_go_closure_SYSV_V (void) FFI_HIDDEN; - -ffi_status -ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*)) -{ - void (*start)(void); - - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - if (cif->flags & AARCH64_FLAG_ARG_V) - start = ffi_go_closure_SYSV_V; - else - start = ffi_go_closure_SYSV; - - closure->tramp = start; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} -#endif /* FFI_GO_CLOSURES */ - -/* Primary handler to setup and invoke a function within a closure. - - A closure when invoked enters via the assembler wrapper - ffi_closure_SYSV(). The wrapper allocates a call context on the - stack, saves the interesting registers (from the perspective of - the calling convention) into the context then passes control to - ffi_closure_SYSV_inner() passing the saved context and a pointer to - the stack at the point ffi_closure_SYSV() was invoked. - - On the return path the assembler wrapper will reload call context - registers. - - ffi_closure_SYSV_inner() marshalls the call context into ffi value - descriptors, invokes the wrapped function, then marshalls the return - value back into the call context. */ - -int FFI_HIDDEN -ffi_closure_SYSV_inner (ffi_cif *cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - struct call_context *context, - void *stack, void *rvalue, void *struct_rvalue) -{ - void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); - int i, h, nargs, flags; - struct arg_state state; - - arg_init (&state); - - for (i = 0, nargs = cif->nargs; i < nargs; i++) - { - ffi_type *ty = cif->arg_types[i]; - int t = ty->type; - size_t n, s = ty->size; - - switch (t) - { - case FFI_TYPE_VOID: - FFI_ASSERT (0); - break; - - case FFI_TYPE_INT: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_POINTER: - avalue[i] = allocate_int_to_reg_or_stack (context, &state, stack, s); - break; - - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: - h = is_vfp_type (ty); - if (h) - { - n = 4 - (h & 3); - if (state.nsrn + n <= N_V_ARG_REG) - { - void *reg = &context->v[state.nsrn]; - state.nsrn += n; - - /* Eeek! We need a pointer to the structure, however the - homogeneous float elements are being passed in individual - registers, therefore for float and double the structure - is not represented as a contiguous sequence of bytes in - our saved register context. We don't need the original - contents of the register storage, so we reformat the - structure into the same memory. */ - avalue[i] = compress_hfa_type (reg, reg, h); - } - else - { - state.nsrn = N_V_ARG_REG; - avalue[i] = allocate_to_stack (&state, stack, - ty->alignment, s); - } - } - else if (s > 16) - { - /* Replace Composite type of size greater than 16 with a - pointer. */ - avalue[i] = *(void **) - allocate_int_to_reg_or_stack (context, &state, stack, - sizeof (void *)); - } - else - { - n = (s + 7) / 8; - if (state.ngrn + n <= N_X_ARG_REG) - { - avalue[i] = &context->x[state.ngrn]; - state.ngrn += n; - } - else - { - state.ngrn = N_X_ARG_REG; - avalue[i] = allocate_to_stack (&state, stack, - ty->alignment, s); - } - } - break; - - default: - abort(); - } - } - - flags = cif->flags; - if (flags & AARCH64_RET_IN_MEM) - rvalue = struct_rvalue; - - fun (cif, rvalue, avalue, user_data); - - return flags; -} diff --git a/user/mpy/lib/libffi/src/aarch64/ffitarget.h b/user/mpy/lib/libffi/src/aarch64/ffitarget.h deleted file mode 100644 index 2862ec7..0000000 --- a/user/mpy/lib/libffi/src/aarch64/ffitarget.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -#ifdef __ILP32__ -#define FFI_SIZEOF_ARG 8 -typedef unsigned long long ffi_arg; -typedef signed long long ffi_sarg; -#else -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; -#endif - -typedef enum ffi_abi - { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV - } ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#if defined (__APPLE__) -#define FFI_TRAMPOLINE_SIZE 20 -#define FFI_TRAMPOLINE_CLOSURE_OFFSET 16 -#else -#define FFI_TRAMPOLINE_SIZE 24 -#define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE -#endif -#define FFI_NATIVE_RAW_API 0 - -/* ---- Internal ---- */ - -#if defined (__APPLE__) -#define FFI_TARGET_SPECIFIC_VARIADIC -#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs -#else -/* iOS reserves x18 for the system. Disable Go closures until - a new static chain is chosen. */ -#define FFI_GO_CLOSURES 1 -#endif - -#define FFI_TARGET_HAS_COMPLEX_TYPE - -#endif diff --git a/user/mpy/lib/libffi/src/aarch64/internal.h b/user/mpy/lib/libffi/src/aarch64/internal.h deleted file mode 100644 index 9c3e077..0000000 --- a/user/mpy/lib/libffi/src/aarch64/internal.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -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. */ - -#define AARCH64_RET_VOID 0 -#define AARCH64_RET_INT64 1 -#define AARCH64_RET_INT128 2 - -#define AARCH64_RET_UNUSED3 3 -#define AARCH64_RET_UNUSED4 4 -#define AARCH64_RET_UNUSED5 5 -#define AARCH64_RET_UNUSED6 6 -#define AARCH64_RET_UNUSED7 7 - -/* Note that FFI_TYPE_FLOAT == 2, _DOUBLE == 3, _LONGDOUBLE == 4, - so _S4 through _Q1 are layed out as (TYPE * 4) + (4 - COUNT). */ -#define AARCH64_RET_S4 8 -#define AARCH64_RET_S3 9 -#define AARCH64_RET_S2 10 -#define AARCH64_RET_S1 11 - -#define AARCH64_RET_D4 12 -#define AARCH64_RET_D3 13 -#define AARCH64_RET_D2 14 -#define AARCH64_RET_D1 15 - -#define AARCH64_RET_Q4 16 -#define AARCH64_RET_Q3 17 -#define AARCH64_RET_Q2 18 -#define AARCH64_RET_Q1 19 - -/* Note that each of the sub-64-bit integers gets two entries. */ -#define AARCH64_RET_UINT8 20 -#define AARCH64_RET_UINT16 22 -#define AARCH64_RET_UINT32 24 - -#define AARCH64_RET_SINT8 26 -#define AARCH64_RET_SINT16 28 -#define AARCH64_RET_SINT32 30 - -#define AARCH64_RET_MASK 31 - -#define AARCH64_RET_IN_MEM (1 << 5) -#define AARCH64_RET_NEED_COPY (1 << 6) - -#define AARCH64_FLAG_ARG_V_BIT 7 -#define AARCH64_FLAG_ARG_V (1 << AARCH64_FLAG_ARG_V_BIT) - -#define N_X_ARG_REG 8 -#define N_V_ARG_REG 8 -#define CALL_CONTEXT_SIZE (N_V_ARG_REG * 16 + N_X_ARG_REG * 8) diff --git a/user/mpy/lib/libffi/src/aarch64/sysv.S b/user/mpy/lib/libffi/src/aarch64/sysv.S deleted file mode 100644 index c1bf9b9..0000000 --- a/user/mpy/lib/libffi/src/aarch64/sysv.S +++ /dev/null @@ -1,434 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM 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. */ - -#define LIBFFI_ASM -#include -#include -#include -#include "internal.h" - -#ifdef HAVE_MACHINE_ASM_H -#include -#else -#ifdef __USER_LABEL_PREFIX__ -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ -#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x) -#else -#define CNAME(x) x -#endif -#endif - -#ifdef __AARCH64EB__ -# define BE(X) X -#else -# define BE(X) 0 -#endif - -#ifdef __ILP32__ -#define PTR_REG(n) w##n -#else -#define PTR_REG(n) x##n -#endif - -#ifdef __ILP32__ -#define PTR_SIZE 4 -#else -#define PTR_SIZE 8 -#endif - - .text - .align 4 - -/* ffi_call_SYSV - extern void ffi_call_SYSV (void *stack, void *frame, - void (*fn)(void), void *rvalue, - int flags, void *closure); - - Therefore on entry we have: - - x0 stack - x1 frame - x2 fn - x3 rvalue - x4 flags - x5 closure -*/ - - cfi_startproc -CNAME(ffi_call_SYSV): - /* Use a stack frame allocated by our caller. */ - cfi_def_cfa(x1, 32); - stp x29, x30, [x1] - mov x29, x1 - mov sp, x0 - cfi_def_cfa_register(x29) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) - - mov x9, x2 /* save fn */ - mov x8, x3 /* install structure return */ -#ifdef FFI_GO_CLOSURES - mov x18, x5 /* install static chain */ -#endif - stp x3, x4, [x29, #16] /* save rvalue and flags */ - - /* Load the vector argument passing registers, if necessary. */ - tbz w4, #AARCH64_FLAG_ARG_V_BIT, 1f - ldp q0, q1, [sp, #0] - ldp q2, q3, [sp, #32] - ldp q4, q5, [sp, #64] - ldp q6, q7, [sp, #96] -1: - /* Load the core argument passing registers, including - the structure return pointer. */ - ldp x0, x1, [sp, #16*N_V_ARG_REG + 0] - ldp x2, x3, [sp, #16*N_V_ARG_REG + 16] - ldp x4, x5, [sp, #16*N_V_ARG_REG + 32] - ldp x6, x7, [sp, #16*N_V_ARG_REG + 48] - - /* Deallocate the context, leaving the stacked arguments. */ - add sp, sp, #CALL_CONTEXT_SIZE - - blr x9 /* call fn */ - - ldp x3, x4, [x29, #16] /* reload rvalue and flags */ - - /* Partially deconstruct the stack frame. */ - mov sp, x29 - cfi_def_cfa_register (sp) - ldp x29, x30, [x29] - - /* Save the return value as directed. */ - adr x5, 0f - and w4, w4, #AARCH64_RET_MASK - add x5, x5, x4, lsl #3 - br x5 - - /* Note that each table entry is 2 insns, and thus 8 bytes. - For integer data, note that we're storing into ffi_arg - and therefore we want to extend to 64 bits; these types - have two consecutive entries allocated for them. */ - .align 4 -0: ret /* VOID */ - nop -1: str x0, [x3] /* INT64 */ - ret -2: stp x0, x1, [x3] /* INT128 */ - ret -3: brk #1000 /* UNUSED */ - ret -4: brk #1000 /* UNUSED */ - ret -5: brk #1000 /* UNUSED */ - ret -6: brk #1000 /* UNUSED */ - ret -7: brk #1000 /* UNUSED */ - ret -8: st4 { v0.s, v1.s, v2.s, v3.s }[0], [x3] /* S4 */ - ret -9: st3 { v0.s, v1.s, v2.s }[0], [x3] /* S3 */ - ret -10: stp s0, s1, [x3] /* S2 */ - ret -11: str s0, [x3] /* S1 */ - ret -12: st4 { v0.d, v1.d, v2.d, v3.d }[0], [x3] /* D4 */ - ret -13: st3 { v0.d, v1.d, v2.d }[0], [x3] /* D3 */ - ret -14: stp d0, d1, [x3] /* D2 */ - ret -15: str d0, [x3] /* D1 */ - ret -16: str q3, [x3, #48] /* Q4 */ - nop -17: str q2, [x3, #32] /* Q3 */ - nop -18: stp q0, q1, [x3] /* Q2 */ - ret -19: str q0, [x3] /* Q1 */ - ret -20: uxtb w0, w0 /* UINT8 */ - str x0, [x3] -21: ret /* reserved */ - nop -22: uxth w0, w0 /* UINT16 */ - str x0, [x3] -23: ret /* reserved */ - nop -24: mov w0, w0 /* UINT32 */ - str x0, [x3] -25: ret /* reserved */ - nop -26: sxtb x0, w0 /* SINT8 */ - str x0, [x3] -27: ret /* reserved */ - nop -28: sxth x0, w0 /* SINT16 */ - str x0, [x3] -29: ret /* reserved */ - nop -30: sxtw x0, w0 /* SINT32 */ - str x0, [x3] -31: ret /* reserved */ - nop - - cfi_endproc - - .globl CNAME(ffi_call_SYSV) -#ifdef __ELF__ - .type CNAME(ffi_call_SYSV), #function - .hidden CNAME(ffi_call_SYSV) - .size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV) -#endif - -/* ffi_closure_SYSV - - Closure invocation glue. This is the low level code invoked directly by - the closure trampoline to setup and call a closure. - - On entry x17 points to a struct ffi_closure, x16 has been clobbered - all other registers are preserved. - - We allocate a call context and save the argument passing registers, - then invoked the generic C ffi_closure_SYSV_inner() function to do all - the real work, on return we load the result passing registers back from - the call context. -*/ - -#define ffi_closure_SYSV_FS (8*2 + CALL_CONTEXT_SIZE + 64) - - .align 4 -CNAME(ffi_closure_SYSV_V): - cfi_startproc - stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! - cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) - - /* Save the argument passing vector registers. */ - stp q0, q1, [sp, #16 + 0] - stp q2, q3, [sp, #16 + 32] - stp q4, q5, [sp, #16 + 64] - stp q6, q7, [sp, #16 + 96] - b 0f - cfi_endproc - - .globl CNAME(ffi_closure_SYSV_V) -#ifdef __ELF__ - .type CNAME(ffi_closure_SYSV_V), #function - .hidden CNAME(ffi_closure_SYSV_V) - .size CNAME(ffi_closure_SYSV_V), . - CNAME(ffi_closure_SYSV_V) -#endif - - .align 4 - cfi_startproc -CNAME(ffi_closure_SYSV): - stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! - cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) -0: - mov x29, sp - - /* Save the argument passing core registers. */ - stp x0, x1, [sp, #16 + 16*N_V_ARG_REG + 0] - stp x2, x3, [sp, #16 + 16*N_V_ARG_REG + 16] - stp x4, x5, [sp, #16 + 16*N_V_ARG_REG + 32] - stp x6, x7, [sp, #16 + 16*N_V_ARG_REG + 48] - - /* Load ffi_closure_inner arguments. */ - ldp PTR_REG(0), PTR_REG(1), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET] /* load cif, fn */ - ldr PTR_REG(2), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+PTR_SIZE*2] /* load user_data */ -.Ldo_closure: - add x3, sp, #16 /* load context */ - add x4, sp, #ffi_closure_SYSV_FS /* load stack */ - add x5, sp, #16+CALL_CONTEXT_SIZE /* load rvalue */ - mov x6, x8 /* load struct_rval */ - bl CNAME(ffi_closure_SYSV_inner) - - /* Load the return value as directed. */ - adr x1, 0f - and w0, w0, #AARCH64_RET_MASK - add x1, x1, x0, lsl #3 - add x3, sp, #16+CALL_CONTEXT_SIZE - br x1 - - /* Note that each table entry is 2 insns, and thus 8 bytes. */ - .align 4 -0: b 99f /* VOID */ - nop -1: ldr x0, [x3] /* INT64 */ - b 99f -2: ldp x0, x1, [x3] /* INT128 */ - b 99f -3: brk #1000 /* UNUSED */ - nop -4: brk #1000 /* UNUSED */ - nop -5: brk #1000 /* UNUSED */ - nop -6: brk #1000 /* UNUSED */ - nop -7: brk #1000 /* UNUSED */ - nop -8: ldr s3, [x3, #12] /* S4 */ - nop -9: ldr s2, [x2, #8] /* S3 */ - nop -10: ldp s0, s1, [x3] /* S2 */ - b 99f -11: ldr s0, [x3] /* S1 */ - b 99f -12: ldr d3, [x3, #24] /* D4 */ - nop -13: ldr d2, [x3, #16] /* D3 */ - nop -14: ldp d0, d1, [x3] /* D2 */ - b 99f -15: ldr d0, [x3] /* D1 */ - b 99f -16: ldr q3, [x3, #48] /* Q4 */ - nop -17: ldr q2, [x3, #32] /* Q3 */ - nop -18: ldp q0, q1, [x3] /* Q2 */ - b 99f -19: ldr q0, [x3] /* Q1 */ - b 99f -20: ldrb w0, [x3, #BE(7)] /* UINT8 */ - b 99f -21: brk #1000 /* reserved */ - nop -22: ldrh w0, [x3, #BE(6)] /* UINT16 */ - b 99f -23: brk #1000 /* reserved */ - nop -24: ldr w0, [x3, #BE(4)] /* UINT32 */ - b 99f -25: brk #1000 /* reserved */ - nop -26: ldrsb x0, [x3, #BE(7)] /* SINT8 */ - b 99f -27: brk #1000 /* reserved */ - nop -28: ldrsh x0, [x3, #BE(6)] /* SINT16 */ - b 99f -29: brk #1000 /* reserved */ - nop -30: ldrsw x0, [x3, #BE(4)] /* SINT32 */ - nop -31: /* reserved */ -99: ldp x29, x30, [sp], #ffi_closure_SYSV_FS - cfi_adjust_cfa_offset (-ffi_closure_SYSV_FS) - cfi_restore (x29) - cfi_restore (x30) - ret - cfi_endproc - - .globl CNAME(ffi_closure_SYSV) -#ifdef __ELF__ - .type CNAME(ffi_closure_SYSV), #function - .hidden CNAME(ffi_closure_SYSV) - .size CNAME(ffi_closure_SYSV), . - CNAME(ffi_closure_SYSV) -#endif - -#if FFI_EXEC_TRAMPOLINE_TABLE - .align 12 -CNAME(ffi_closure_trampoline_table_page): - .rept 16384 / FFI_TRAMPOLINE_SIZE - adr x17, -16384 - adr x16, -16380 - ldr x16, [x16] - ldr x17, [x17] - br x16 - .endr - - .globl CNAME(ffi_closure_trampoline_table_page) - #ifdef __ELF__ - .type CNAME(ffi_closure_trampoline_table_page), #function - .hidden CNAME(ffi_closure_trampoline_table_page) - .size CNAME(ffi_closure_trampoline_table_page), . - CNAME(ffi_closure_trampoline_table_page) - #endif -#endif - -#ifdef FFI_GO_CLOSURES - .align 4 -CNAME(ffi_go_closure_SYSV_V): - cfi_startproc - stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! - cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) - - /* Save the argument passing vector registers. */ - stp q0, q1, [sp, #16 + 0] - stp q2, q3, [sp, #16 + 32] - stp q4, q5, [sp, #16 + 64] - stp q6, q7, [sp, #16 + 96] - b 0f - cfi_endproc - - .globl CNAME(ffi_go_closure_SYSV_V) -#ifdef __ELF__ - .type CNAME(ffi_go_closure_SYSV_V), #function - .hidden CNAME(ffi_go_closure_SYSV_V) - .size CNAME(ffi_go_closure_SYSV_V), . - CNAME(ffi_go_closure_SYSV_V) -#endif - - .align 4 - cfi_startproc -CNAME(ffi_go_closure_SYSV): - stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! - cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) -0: - mov x29, sp - - /* Save the argument passing core registers. */ - stp x0, x1, [sp, #16 + 16*N_V_ARG_REG + 0] - stp x2, x3, [sp, #16 + 16*N_V_ARG_REG + 16] - stp x4, x5, [sp, #16 + 16*N_V_ARG_REG + 32] - stp x6, x7, [sp, #16 + 16*N_V_ARG_REG + 48] - - /* Load ffi_closure_inner arguments. */ - ldp PTR_REG(0), PTR_REG(1), [x18, #PTR_SIZE]/* load cif, fn */ - mov x2, x18 /* load user_data */ - b .Ldo_closure - cfi_endproc - - .globl CNAME(ffi_go_closure_SYSV) -#ifdef __ELF__ - .type CNAME(ffi_go_closure_SYSV), #function - .hidden CNAME(ffi_go_closure_SYSV) - .size CNAME(ffi_go_closure_SYSV), . - CNAME(ffi_go_closure_SYSV) -#endif -#endif /* FFI_GO_CLOSURES */ - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",%progbits -#endif - diff --git a/user/mpy/lib/libffi/src/alpha/ffi.c b/user/mpy/lib/libffi/src/alpha/ffi.c deleted file mode 100644 index efae4cc..0000000 --- a/user/mpy/lib/libffi/src/alpha/ffi.c +++ /dev/null @@ -1,521 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012 Anthony Green - Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc. - - Alpha Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include "internal.h" - -/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; - all further uses in this file will refer to the 128-bit type. */ -#if defined(__LONG_DOUBLE_128__) -# if FFI_TYPE_LONGDOUBLE != 4 -# error FFI_TYPE_LONGDOUBLE out of date -# endif -#else -# undef FFI_TYPE_LONGDOUBLE -# define FFI_TYPE_LONGDOUBLE 4 -#endif - -extern void ffi_call_osf(void *stack, void *frame, unsigned flags, - void *raddr, void (*fn)(void), void *closure) - FFI_HIDDEN; -extern void ffi_closure_osf(void) FFI_HIDDEN; -extern void ffi_go_closure_osf(void) FFI_HIDDEN; - -/* Promote a float value to its in-register double representation. - Unlike actually casting to double, this does not trap on NaN. */ -static inline UINT64 lds(void *ptr) -{ - UINT64 ret; - asm("lds %0,%1" : "=f"(ret) : "m"(*(UINT32 *)ptr)); - return ret; -} - -/* And the reverse. */ -static inline void sts(void *ptr, UINT64 val) -{ - asm("sts %1,%0" : "=m"(*(UINT32 *)ptr) : "f"(val)); -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep(ffi_cif *cif) -{ - size_t bytes = 0; - int flags, i, avn; - ffi_type *rtype, *itype; - - if (cif->abi != FFI_OSF) - return FFI_BAD_ABI; - - /* Compute the size of the argument area. */ - for (i = 0, avn = cif->nargs; i < avn; i++) - { - itype = cif->arg_types[i]; - switch (itype->type) - { - case FFI_TYPE_INT: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - /* All take one 8 byte slot. */ - bytes += 8; - break; - - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - /* Passed by value in N slots. */ - bytes += ALIGN(itype->size, FFI_SIZEOF_ARG); - break; - - case FFI_TYPE_COMPLEX: - /* _Complex long double passed by reference; others in 2 slots. */ - if (itype->elements[0]->type == FFI_TYPE_LONGDOUBLE) - bytes += 8; - else - bytes += 16; - break; - - default: - abort(); - } - } - - /* Set the return type flag */ - rtype = cif->rtype; - switch (rtype->type) - { - case FFI_TYPE_VOID: - flags = ALPHA_FLAGS(ALPHA_ST_VOID, ALPHA_LD_VOID); - break; - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT32); - break; - case FFI_TYPE_FLOAT: - flags = ALPHA_FLAGS(ALPHA_ST_FLOAT, ALPHA_LD_FLOAT); - break; - case FFI_TYPE_DOUBLE: - flags = ALPHA_FLAGS(ALPHA_ST_DOUBLE, ALPHA_LD_DOUBLE); - break; - case FFI_TYPE_UINT8: - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_UINT8); - break; - case FFI_TYPE_SINT8: - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_SINT8); - break; - case FFI_TYPE_UINT16: - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_UINT16); - break; - case FFI_TYPE_SINT16: - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_SINT16); - break; - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_POINTER: - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT64); - break; - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_STRUCT: - /* Passed in memory, with a hidden pointer. */ - flags = ALPHA_RET_IN_MEM; - break; - case FFI_TYPE_COMPLEX: - itype = rtype->elements[0]; - switch (itype->type) - { - case FFI_TYPE_FLOAT: - flags = ALPHA_FLAGS(ALPHA_ST_CPLXF, ALPHA_LD_CPLXF); - break; - case FFI_TYPE_DOUBLE: - flags = ALPHA_FLAGS(ALPHA_ST_CPLXD, ALPHA_LD_CPLXD); - break; - default: - if (rtype->size <= 8) - flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT64); - else - flags = ALPHA_RET_IN_MEM; - break; - } - break; - default: - abort(); - } - cif->flags = flags; - - /* Include the hidden structure pointer in args requirement. */ - if (flags == ALPHA_RET_IN_MEM) - bytes += 8; - /* Minimum size is 6 slots, so that ffi_call_osf can pop them. */ - if (bytes < 6*8) - bytes = 6*8; - cif->bytes = bytes; - - return FFI_OK; -} - -static unsigned long -extend_basic_type(void *valp, int type, int argn) -{ - switch (type) - { - case FFI_TYPE_SINT8: - return *(SINT8 *)valp; - case FFI_TYPE_UINT8: - return *(UINT8 *)valp; - case FFI_TYPE_SINT16: - return *(SINT16 *)valp; - case FFI_TYPE_UINT16: - return *(UINT16 *)valp; - - case FFI_TYPE_FLOAT: - if (argn < 6) - return lds(valp); - /* FALLTHRU */ - - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - /* Note that unsigned 32-bit quantities are sign extended. */ - return *(SINT32 *)valp; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - case FFI_TYPE_DOUBLE: - return *(UINT64 *)valp; - - default: - abort(); - } -} - -static void -ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - unsigned long *argp; - long i, avn, argn, flags = cif->flags; - ffi_type **arg_types; - void *frame; - - /* If the return value is a struct and we don't have a return - value address then we need to make one. */ - if (rvalue == NULL && flags == ALPHA_RET_IN_MEM) - rvalue = alloca(cif->rtype->size); - - /* Allocate the space for the arguments, plus 4 words of temp - space for ffi_call_osf. */ - argp = frame = alloca(cif->bytes + 4*FFI_SIZEOF_ARG); - frame += cif->bytes; - - argn = 0; - if (flags == ALPHA_RET_IN_MEM) - argp[argn++] = (unsigned long)rvalue; - - avn = cif->nargs; - arg_types = cif->arg_types; - - for (i = 0, avn = cif->nargs; i < avn; i++) - { - ffi_type *ty = arg_types[i]; - void *valp = avalue[i]; - int type = ty->type; - size_t size; - - switch (type) - { - case FFI_TYPE_INT: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - argp[argn] = extend_basic_type(valp, type, argn); - argn++; - break; - - case FFI_TYPE_LONGDOUBLE: - by_reference: - /* Note that 128-bit long double is passed by reference. */ - argp[argn++] = (unsigned long)valp; - break; - - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - size = ty->size; - memcpy(argp + argn, valp, size); - argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - break; - - case FFI_TYPE_COMPLEX: - type = ty->elements[0]->type; - if (type == FFI_TYPE_LONGDOUBLE) - goto by_reference; - - /* Most complex types passed as two separate arguments. */ - size = ty->elements[0]->size; - argp[argn] = extend_basic_type(valp, type, argn); - argp[argn + 1] = extend_basic_type(valp + size, type, argn + 1); - argn += 2; - break; - - default: - abort(); - } - } - - flags = (flags >> ALPHA_ST_SHIFT) & 0xff; - ffi_call_osf(argp, frame, flags, rvalue, fn, closure); -} - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int(cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int(cif, fn, rvalue, avalue, closure); -} - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp; - - if (cif->abi != FFI_OSF) - return FFI_BAD_ABI; - - tramp = (unsigned int *) &closure->tramp[0]; - tramp[0] = 0x47fb0401; /* mov $27,$1 */ - tramp[1] = 0xa77b0010; /* ldq $27,16($27) */ - tramp[2] = 0x6bfb0000; /* jmp $31,($27),0 */ - tramp[3] = 0x47ff041f; /* nop */ - *(void **) &tramp[4] = ffi_closure_osf; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - /* Flush the Icache. - - Tru64 UNIX as doesn't understand the imb mnemonic, so use call_pal - instead, since both Compaq as and gas can handle it. - - 0x86 is PAL_imb in Tru64 UNIX . */ - asm volatile ("call_pal 0x86" : : : "memory"); - - return FFI_OK; -} - -ffi_status -ffi_prep_go_closure (ffi_go_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*)) -{ - if (cif->abi != FFI_OSF) - return FFI_BAD_ABI; - - closure->tramp = (void *)ffi_go_closure_osf; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -long FFI_HIDDEN -ffi_closure_osf_inner (ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *rvalue, unsigned long *argp) -{ - void **avalue; - ffi_type **arg_types; - long i, avn, argn, flags; - - avalue = alloca(cif->nargs * sizeof(void *)); - flags = cif->flags; - argn = 0; - - /* Copy the caller's structure return address to that the closure - returns the data directly to the caller. */ - if (flags == ALPHA_RET_IN_MEM) - { - rvalue = (void *) argp[0]; - argn = 1; - } - - arg_types = cif->arg_types; - - /* Grab the addresses of the arguments from the stack frame. */ - for (i = 0, avn = cif->nargs; i < avn; i++) - { - ffi_type *ty = arg_types[i]; - int type = ty->type; - void *valp = &argp[argn]; - size_t size; - - switch (type) - { - case FFI_TYPE_INT: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - argn += 1; - break; - - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - size = ty->size; - argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - break; - - case FFI_TYPE_FLOAT: - /* Floats coming from registers need conversion from double - back to float format. */ - if (argn < 6) - { - valp = &argp[argn - 6]; - sts(valp, argp[argn - 6]); - } - argn += 1; - break; - - case FFI_TYPE_DOUBLE: - if (argn < 6) - valp = &argp[argn - 6]; - argn += 1; - break; - - case FFI_TYPE_LONGDOUBLE: - by_reference: - /* 128-bit long double is passed by reference. */ - valp = (void *)argp[argn]; - argn += 1; - break; - - case FFI_TYPE_COMPLEX: - type = ty->elements[0]->type; - switch (type) - { - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - /* Passed as separate arguments, but they wind up sequential. */ - break; - - case FFI_TYPE_INT: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - /* Passed as separate arguments. Disjoint, but there's room - enough in one slot to hold the pair. */ - size = ty->elements[0]->size; - memcpy(valp + size, valp + 8, size); - break; - - case FFI_TYPE_FLOAT: - /* Passed as separate arguments. Disjoint, and each piece - may need conversion back to float. */ - if (argn < 6) - { - valp = &argp[argn - 6]; - sts(valp, argp[argn - 6]); - } - if (argn + 1 < 6) - sts(valp + 4, argp[argn + 1 - 6]); - else - *(UINT32 *)(valp + 4) = argp[argn + 1]; - break; - - case FFI_TYPE_DOUBLE: - /* Passed as separate arguments. Only disjoint if one part - is in fp regs and the other is on the stack. */ - if (argn < 5) - valp = &argp[argn - 6]; - else if (argn == 5) - { - valp = alloca(16); - ((UINT64 *)valp)[0] = argp[5 - 6]; - ((UINT64 *)valp)[1] = argp[6]; - } - break; - - case FFI_TYPE_LONGDOUBLE: - goto by_reference; - - default: - abort(); - } - argn += 2; - break; - - default: - abort (); - } - - avalue[i] = valp; - } - - /* Invoke the closure. */ - fun (cif, rvalue, avalue, user_data); - - /* Tell ffi_closure_osf how to perform return type promotions. */ - return (flags >> ALPHA_LD_SHIFT) & 0xff; -} diff --git a/user/mpy/lib/libffi/src/alpha/ffitarget.h b/user/mpy/lib/libffi/src/alpha/ffitarget.h deleted file mode 100644 index a02dbd0..0000000 --- a/user/mpy/lib/libffi/src/alpha/ffitarget.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for Alpha. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_OSF, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_OSF -} ffi_abi; -#endif - -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION -#define FFI_TARGET_HAS_COMPLEX_TYPE - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_GO_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 24 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/alpha/internal.h b/user/mpy/lib/libffi/src/alpha/internal.h deleted file mode 100644 index 44da192..0000000 --- a/user/mpy/lib/libffi/src/alpha/internal.h +++ /dev/null @@ -1,23 +0,0 @@ -#define ALPHA_ST_VOID 0 -#define ALPHA_ST_INT 1 -#define ALPHA_ST_FLOAT 2 -#define ALPHA_ST_DOUBLE 3 -#define ALPHA_ST_CPLXF 4 -#define ALPHA_ST_CPLXD 5 - -#define ALPHA_LD_VOID 0 -#define ALPHA_LD_INT64 1 -#define ALPHA_LD_INT32 2 -#define ALPHA_LD_UINT16 3 -#define ALPHA_LD_SINT16 4 -#define ALPHA_LD_UINT8 5 -#define ALPHA_LD_SINT8 6 -#define ALPHA_LD_FLOAT 7 -#define ALPHA_LD_DOUBLE 8 -#define ALPHA_LD_CPLXF 9 -#define ALPHA_LD_CPLXD 10 - -#define ALPHA_ST_SHIFT 0 -#define ALPHA_LD_SHIFT 8 -#define ALPHA_RET_IN_MEM 0x10000 -#define ALPHA_FLAGS(S, L) (((L) << ALPHA_LD_SHIFT) | (S)) diff --git a/user/mpy/lib/libffi/src/alpha/osf.S b/user/mpy/lib/libffi/src/alpha/osf.S deleted file mode 100644 index b031828..0000000 --- a/user/mpy/lib/libffi/src/alpha/osf.S +++ /dev/null @@ -1,282 +0,0 @@ -/* ----------------------------------------------------------------------- - osf.S - Copyright (c) 1998, 2001, 2007, 2008, 2011, 2014 Red Hat - - Alpha/OSF Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#include -#include "internal.h" - - .arch ev6 - .text - -/* Aid in building a direct addressed jump table, 4 insns per entry. */ -.macro E index - .align 4 - .org 99b + \index * 16 -.endm - -/* ffi_call_osf (void *stack, void *frame, unsigned flags, - void *raddr, void (*fnaddr)(void), void *closure) - - Bit o trickiness here -- FRAME is the base of the stack frame - for this function. This has been allocated by ffi_call. We also - deallocate some of the stack that has been alloca'd. */ - - .align 4 - .globl ffi_call_osf - .ent ffi_call_osf - FFI_HIDDEN(ffi_call_osf) - -ffi_call_osf: - cfi_startproc - cfi_def_cfa($17, 32) - mov $16, $30 - stq $26, 0($17) - stq $15, 8($17) - mov $17, $15 - .prologue 0 - cfi_def_cfa_register($15) - cfi_rel_offset($26, 0) - cfi_rel_offset($15, 8) - - stq $18, 16($17) # save flags into frame - stq $19, 24($17) # save rvalue into frame - mov $20, $27 # fn into place for call - mov $21, $1 # closure into static chain - - # Load up all of the (potential) argument registers. - ldq $16, 0($30) - ldt $f16, 0($30) - ldt $f17, 8($30) - ldq $17, 8($30) - ldt $f18, 16($30) - ldq $18, 16($30) - ldt $f19, 24($30) - ldq $19, 24($30) - ldt $f20, 32($30) - ldq $20, 32($30) - ldt $f21, 40($30) - ldq $21, 40($30) - - # Deallocate the register argument area. - lda $30, 48($30) - - jsr $26, ($27), 0 -0: - ldah $29, 0($26) !gpdisp!1 - ldq $2, 24($15) # reload rvalue - lda $29, 0($29) !gpdisp!1 - ldq $3, 16($15) # reload flags - lda $1, 99f-0b($26) - ldq $26, 0($15) - ldq $15, 8($15) - cfi_restore($26) - cfi_restore($15) - cfi_def_cfa($sp, 0) - cmoveq $2, ALPHA_ST_VOID, $3 # mash null rvalue to void - addq $3, $3, $3 - s8addq $3, $1, $1 # 99f + stcode * 16 - jmp $31, ($1), $st_int - - .align 4 -99: -E ALPHA_ST_VOID - ret -E ALPHA_ST_INT -$st_int: - stq $0, 0($2) - ret -E ALPHA_ST_FLOAT - sts $f0, 0($2) - ret -E ALPHA_ST_DOUBLE - stt $f0, 0($2) - ret -E ALPHA_ST_CPLXF - sts $f0, 0($2) - sts $f1, 4($2) - ret -E ALPHA_ST_CPLXD - stt $f0, 0($2) - stt $f1, 8($2) - ret - - cfi_endproc - .end ffi_call_osf - -/* ffi_closure_osf(...) - - Receives the closure argument in $1. */ - -#define CLOSURE_FS (16*8) - - .align 4 - .globl ffi_go_closure_osf - .ent ffi_go_closure_osf - FFI_HIDDEN(ffi_go_closure_osf) - -ffi_go_closure_osf: - cfi_startproc - ldgp $29, 0($27) - subq $30, CLOSURE_FS, $30 - cfi_adjust_cfa_offset(CLOSURE_FS) - stq $26, 0($30) - .prologue 1 - cfi_rel_offset($26, 0) - - stq $16, 10*8($30) - stq $17, 11*8($30) - stq $18, 12*8($30) - - ldq $16, 8($1) # load cif - ldq $17, 16($1) # load fun - mov $1, $18 # closure is user_data - br $do_closure - - cfi_endproc - .end ffi_go_closure_osf - - .align 4 - .globl ffi_closure_osf - .ent ffi_closure_osf - FFI_HIDDEN(ffi_closure_osf) - -ffi_closure_osf: - cfi_startproc - ldgp $29, 0($27) - subq $30, CLOSURE_FS, $30 - cfi_adjust_cfa_offset(CLOSURE_FS) - stq $26, 0($30) - .prologue 1 - cfi_rel_offset($26, 0) - - # Store all of the potential argument registers in va_list format. - stq $16, 10*8($30) - stq $17, 11*8($30) - stq $18, 12*8($30) - - ldq $16, 24($1) # load cif - ldq $17, 32($1) # load fun - ldq $18, 40($1) # load user_data - -$do_closure: - stq $19, 13*8($30) - stq $20, 14*8($30) - stq $21, 15*8($30) - stt $f16, 4*8($30) - stt $f17, 5*8($30) - stt $f18, 6*8($30) - stt $f19, 7*8($30) - stt $f20, 8*8($30) - stt $f21, 9*8($30) - - # Call ffi_closure_osf_inner to do the bulk of the work. - lda $19, 2*8($30) - lda $20, 10*8($30) - jsr $26, ffi_closure_osf_inner -0: - ldah $29, 0($26) !gpdisp!2 - lda $2, 99f-0b($26) - s4addq $0, 0, $1 # ldcode * 4 - ldq $0, 16($30) # preload return value - s4addq $1, $2, $1 # 99f + ldcode * 16 - lda $29, 0($29) !gpdisp!2 - ldq $26, 0($30) - cfi_restore($26) - jmp $31, ($1), $load_32 - -.macro epilogue - addq $30, CLOSURE_FS, $30 - cfi_adjust_cfa_offset(-CLOSURE_FS) - ret - .align 4 - cfi_adjust_cfa_offset(CLOSURE_FS) -.endm - - .align 4 -99: -E ALPHA_LD_VOID - epilogue - -E ALPHA_LD_INT64 - epilogue - -E ALPHA_LD_INT32 -$load_32: - sextl $0, $0 - epilogue - -E ALPHA_LD_UINT16 - zapnot $0, 3, $0 - epilogue - -E ALPHA_LD_SINT16 -#ifdef __alpha_bwx__ - sextw $0, $0 -#else - sll $0, 48, $0 - sra $0, 48, $0 -#endif - epilogue - -E ALPHA_LD_UINT8 - and $0, 0xff, $0 - epilogue - -E ALPHA_LD_SINT8 -#ifdef __alpha_bwx__ - sextb $0, $0 -#else - sll $0, 56, $0 - sra $0, 56, $0 -#endif - epilogue - -E ALPHA_LD_FLOAT - lds $f0, 16($sp) - epilogue - -E ALPHA_LD_DOUBLE - ldt $f0, 16($sp) - epilogue - -E ALPHA_LD_CPLXF - lds $f0, 16($sp) - lds $f1, 20($sp) - epilogue - -E ALPHA_LD_CPLXD - ldt $f0, 16($sp) - ldt $f1, 24($sp) - epilogue - - cfi_endproc - .end ffi_closure_osf - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/arc/arcompact.S b/user/mpy/lib/libffi/src/arc/arcompact.S deleted file mode 100644 index 03715fd..0000000 --- a/user/mpy/lib/libffi/src/arc/arcompact.S +++ /dev/null @@ -1,135 +0,0 @@ -/* ----------------------------------------------------------------------- - arcompact.S - Copyright (c) 2013 Synposys, Inc. (www.synopsys.com) - - ARCompact Foreign Function Interface - - 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 RENESAS TECHNOLOGY 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#ifdef HAVE_MACHINE_ASM_H -#include -#else -#define CNAME(x) x -#define ENTRY(x) .globl CNAME(x)` .type CNAME(x),%function` CNAME(x): -#endif - -.text - - /* R0: ffi_prep_args */ - /* R1: &ecif */ - /* R2: cif->bytes */ - /* R3: fig->flags */ - /* R4: ecif.rvalue */ - /* R5: fn */ -ENTRY(ffi_call_ARCompact) - /* Save registers. */ - st.a fp, [sp, -4] /* fp + 20, fp */ - push_s blink /* fp + 16, blink */ - st.a r4, [sp, -4] /* fp + 12, ecif.rvalue */ - push_s r3 /* fp + 8, fig->flags */ - st.a r5, [sp, -4] /* fp + 4, fn */ - push_s r2 /* fp + 0, cif->bytes */ - mov fp, sp - - /* Make room for all of the new args. */ - sub sp, sp, r2 - - /* Place all of the ffi_prep_args in position. */ - /* ffi_prep_args(char *stack, extended_cif *ecif) */ - /* R1 already set. */ - - /* And call. */ - jl_s.d [r0] - mov_s r0, sp - - ld.ab r12, [fp, 4] /* cif->bytes */ - ld.ab r11, [fp, 4] /* fn */ - - /* Move first 8 parameters in registers... */ - ld_s r0, [sp] - ld_s r1, [sp, 4] - ld_s r2, [sp, 8] - ld_s r3, [sp, 12] - ld r4, [sp, 16] - ld r5, [sp, 20] - ld r6, [sp, 24] - ld r7, [sp, 28] - - /* ...and adjust the stack. */ - min r12, r12, 32 - - /* Call the function. */ - jl.d [r11] - add sp, sp, r12 - - mov sp, fp - pop_s r3 /* fig->flags, return type */ - pop_s r2 /* ecif.rvalue, pointer for return value */ - - /* If the return value pointer is NULL, assume no return value. */ - breq.d r2, 0, epilogue - pop_s blink - - /* Return INT. */ - brne r3, FFI_TYPE_INT, return_double - b.d epilogue - st_s r0, [r2] - -return_double: - brne r3, FFI_TYPE_DOUBLE, epilogue - st_s r0, [r2] - st_s r1, [r2,4] - -epilogue: - j_s.d [blink] - ld.ab fp, [sp, 4] - -ENTRY(ffi_closure_ARCompact) - st.a r0, [sp, -32] - st_s r1, [sp, 4] - st_s r2, [sp, 8] - st_s r3, [sp, 12] - st r4, [sp, 16] - st r5, [sp, 20] - st r6, [sp, 24] - st r7, [sp, 28] - - /* pointer to arguments */ - mov_s r2, sp - - /* return value goes here */ - sub sp, sp, 8 - mov_s r1, sp - - push_s blink - - bl.d ffi_closure_inner_ARCompact - mov_s r0, r8 /* codeloc, set by trampoline */ - - pop_s blink - - /* set return value to r1:r0 */ - pop_s r0 - pop_s r1 - j_s.d [blink] - add_s sp, sp, 32 diff --git a/user/mpy/lib/libffi/src/arc/ffi.c b/user/mpy/lib/libffi/src/arc/ffi.c deleted file mode 100644 index 32f82a7..0000000 --- a/user/mpy/lib/libffi/src/arc/ffi.c +++ /dev/null @@ -1,268 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com) - - ARC Foreign Function Interface - - 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 RENESAS TECHNOLOGY 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include -#include - -#include - -/* for little endian ARC, the code is in fact stored as mixed endian for - performance reasons */ -#if __BIG_ENDIAN__ -#define CODE_ENDIAN(x) (x) -#else -#define CODE_ENDIAN(x) ( (((uint32_t) (x)) << 16) | (((uint32_t) (x)) >> 16)) -#endif - -/* ffi_prep_args is called by the assembly routine once stack - space has been allocated for the function's arguments. */ - -void -ffi_prep_args (char *stack, extended_cif * ecif) -{ - unsigned int i; - int tmp; - void **p_argv; - char *argp; - ffi_type **p_arg; - - tmp = 0; - argp = stack; - - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) - { - *(void **) argp = ecif->rvalue; - argp += 4; - } - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); i--, p_arg++) - { - size_t z; - int alignment; - - /* align alignment to 4 */ - alignment = (((*p_arg)->alignment - 1) | 3) + 1; - - /* Align if necessary. */ - if ((alignment - 1) & (unsigned) argp) - argp = (char *) ALIGN (argp, alignment); - - z = (*p_arg)->size; - if (z < sizeof (int)) - { - z = sizeof (int); - - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int) *(UINT8 *) (*p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) *(UINT16 *) (*p_argv); - break; - - case FFI_TYPE_STRUCT: - memcpy (argp, *p_argv, (*p_arg)->size); - break; - - default: - FFI_ASSERT (0); - } - } - else if (z == sizeof (int)) - { - *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv); - } - else - { - if ((*p_arg)->type == FFI_TYPE_STRUCT) - { - memcpy (argp, *p_argv, z); - } - else - { - /* Double or long long 64bit. */ - memcpy (argp, *p_argv, z); - } - } - p_argv++; - argp += z; - } - - return; -} - -/* Perform machine dependent cif processing. */ -ffi_status -ffi_prep_cif_machdep (ffi_cif * cif) -{ - /* Set the return type flag. */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - cif->flags = (unsigned) cif->rtype->type; - break; - - case FFI_TYPE_STRUCT: - cif->flags = (unsigned) cif->rtype->type; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - cif->flags = FFI_TYPE_DOUBLE; - break; - - case FFI_TYPE_FLOAT: - default: - cif->flags = FFI_TYPE_INT; - break; - } - - return FFI_OK; -} - -extern void ffi_call_ARCompact (void (*)(char *, extended_cif *), - extended_cif *, unsigned, unsigned, - unsigned *, void (*fn) (void)); - -void -ffi_call (ffi_cif * cif, void (*fn) (void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have - a return value address then we need to make one. */ - if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca (cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_ARCOMPACT: - ffi_call_ARCompact (ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - break; - - default: - FFI_ASSERT (0); - break; - } -} - -int -ffi_closure_inner_ARCompact (ffi_closure * closure, void *rvalue, - ffi_arg * args) -{ - void **arg_area, **p_argv; - ffi_cif *cif = closure->cif; - char *argp = (char *) args; - ffi_type **p_argt; - int i; - - arg_area = (void **) alloca (cif->nargs * sizeof (void *)); - - /* handle hidden argument */ - if (cif->flags == FFI_TYPE_STRUCT) - { - rvalue = *(void **) argp; - argp += 4; - } - - p_argv = arg_area; - - for (i = 0, p_argt = cif->arg_types; i < cif->nargs; - i++, p_argt++, p_argv++) - { - size_t z; - int alignment; - - /* align alignment to 4 */ - alignment = (((*p_argt)->alignment - 1) | 3) + 1; - - /* Align if necessary. */ - if ((alignment - 1) & (unsigned) argp) - argp = (char *) ALIGN (argp, alignment); - - z = (*p_argt)->size; - *p_argv = (void *) argp; - argp += z; - } - - (closure->fun) (cif, rvalue, arg_area, closure->user_data); - - return cif->flags; -} - -extern void ffi_closure_ARCompact (void); - -ffi_status -ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, void *codeloc) -{ - uint32_t *tramp = (uint32_t *) & (closure->tramp[0]); - - switch (cif->abi) - { - case FFI_ARCOMPACT: - FFI_ASSERT (tramp == codeloc); - tramp[0] = CODE_ENDIAN (0x200a1fc0); /* mov r8, pcl */ - tramp[1] = CODE_ENDIAN (0x20200f80); /* j [long imm] */ - tramp[2] = CODE_ENDIAN (ffi_closure_ARCompact); - break; - - default: - return FFI_BAD_ABI; - } - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - cacheflush (codeloc, FFI_TRAMPOLINE_SIZE, BCACHE); - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/arc/ffitarget.h b/user/mpy/lib/libffi/src/arc/ffitarget.h deleted file mode 100644 index bf8311b..0000000 --- a/user/mpy/lib/libffi/src/arc/ffitarget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ----------------------------------------------------------------------- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com) - Target configuration macros for ARC. - - 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 RENESAS TECHNOLOGY 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi -{ - FFI_FIRST_ABI = 0, - FFI_ARCOMPACT, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_ARCOMPACT -} ffi_abi; -#endif - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 12 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/arm/ffi.c b/user/mpy/lib/libffi/src/arm/ffi.c deleted file mode 100644 index 9c8732d..0000000 --- a/user/mpy/lib/libffi/src/arm/ffi.c +++ /dev/null @@ -1,1043 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011 Timothy Wall - Copyright (c) 2011 Plausible Labs Cooperative, Inc. - Copyright (c) 2011 Anthony Green - Copyright (c) 2011 Free Software Foundation - Copyright (c) 1998, 2008, 2011 Red Hat, Inc. - - ARM Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include "internal.h" - -/* Forward declares. */ -static int vfp_type_p (const ffi_type *); -static void layout_vfp_args (ffi_cif *); - -static void * -ffi_align (ffi_type *ty, void *p) -{ - /* Align if necessary */ - size_t alignment; -#ifdef _WIN32_WCE - alignment = 4; -#else - alignment = ty->alignment; - if (alignment < 4) - alignment = 4; -#endif - return (void *) ALIGN (p, alignment); -} - -static size_t -ffi_put_arg (ffi_type *ty, void *src, void *dst) -{ - size_t z = ty->size; - - switch (ty->type) - { - case FFI_TYPE_SINT8: - *(UINT32 *)dst = *(SINT8 *)src; - break; - case FFI_TYPE_UINT8: - *(UINT32 *)dst = *(UINT8 *)src; - break; - case FFI_TYPE_SINT16: - *(UINT32 *)dst = *(SINT16 *)src; - break; - case FFI_TYPE_UINT16: - *(UINT32 *)dst = *(UINT16 *)src; - break; - - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - case FFI_TYPE_FLOAT: - *(UINT32 *)dst = *(UINT32 *)src; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - *(UINT64 *)dst = *(UINT64 *)src; - break; - - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: - memcpy (dst, src, z); - break; - - default: - abort(); - } - - return ALIGN (z, 4); -} - -/* ffi_prep_args is called once stack space has been allocated - for the function's arguments. - - The vfp_space parameter is the load area for VFP regs, the return - value is cif->vfp_used (word bitset of VFP regs used for passing - arguments). These are only used for the VFP hard-float ABI. -*/ -static void -ffi_prep_args_SYSV (ffi_cif *cif, int flags, void *rvalue, - void **avalue, char *argp) -{ - ffi_type **arg_types = cif->arg_types; - int i, n; - - if (flags == ARM_TYPE_STRUCT) - { - *(void **) argp = rvalue; - argp += 4; - } - - for (i = 0, n = cif->nargs; i < n; i++) - { - ffi_type *ty = arg_types[i]; - argp = ffi_align (ty, argp); - argp += ffi_put_arg (ty, avalue[i], argp); - } -} - -static void -ffi_prep_args_VFP (ffi_cif *cif, int flags, void *rvalue, - void **avalue, char *stack, char *vfp_space) -{ - ffi_type **arg_types = cif->arg_types; - int i, n, vi = 0; - char *argp, *regp, *eo_regp; - char stack_used = 0; - char done_with_regs = 0; - - /* The first 4 words on the stack are used for values - passed in core registers. */ - regp = stack; - eo_regp = argp = regp + 16; - - /* If the function returns an FFI_TYPE_STRUCT in memory, - that address is passed in r0 to the function. */ - if (flags == ARM_TYPE_STRUCT) - { - *(void **) regp = rvalue; - regp += 4; - } - - for (i = 0, n = cif->nargs; i < n; i++) - { - ffi_type *ty = arg_types[i]; - void *a = avalue[i]; - int is_vfp_type = vfp_type_p (ty); - - /* Allocated in VFP registers. */ - if (vi < cif->vfp_nargs && is_vfp_type) - { - char *vfp_slot = vfp_space + cif->vfp_args[vi++] * 4; - ffi_put_arg (ty, a, vfp_slot); - continue; - } - /* Try allocating in core registers. */ - else if (!done_with_regs && !is_vfp_type) - { - char *tregp = ffi_align (ty, regp); - size_t size = ty->size; - size = (size < 4) ? 4 : size; // pad - /* Check if there is space left in the aligned register - area to place the argument. */ - if (tregp + size <= eo_regp) - { - regp = tregp + ffi_put_arg (ty, a, tregp); - done_with_regs = (regp == argp); - // ensure we did not write into the stack area - FFI_ASSERT (regp <= argp); - continue; - } - /* In case there are no arguments in the stack area yet, - the argument is passed in the remaining core registers - and on the stack. */ - else if (!stack_used) - { - stack_used = 1; - done_with_regs = 1; - argp = tregp + ffi_put_arg (ty, a, tregp); - FFI_ASSERT (eo_regp < argp); - continue; - } - } - /* Base case, arguments are passed on the stack */ - stack_used = 1; - argp = ffi_align (ty, argp); - argp += ffi_put_arg (ty, a, argp); - } -} - -/* Perform machine dependent cif processing */ -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - int flags = 0, cabi = cif->abi; - size_t bytes = cif->bytes; - - /* Map out the register placements of VFP register args. The VFP - hard-float calling conventions are slightly more sophisticated - than the base calling conventions, so we do it here instead of - in ffi_prep_args(). */ - if (cabi == FFI_VFP) - layout_vfp_args (cif); - - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - flags = ARM_TYPE_VOID; - break; - - case FFI_TYPE_INT: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - flags = ARM_TYPE_INT; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - flags = ARM_TYPE_INT64; - break; - - case FFI_TYPE_FLOAT: - flags = (cabi == FFI_VFP ? ARM_TYPE_VFP_S : ARM_TYPE_INT); - break; - case FFI_TYPE_DOUBLE: - flags = (cabi == FFI_VFP ? ARM_TYPE_VFP_D : ARM_TYPE_INT64); - break; - - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: - if (cabi == FFI_VFP) - { - int h = vfp_type_p (cif->rtype); - - flags = ARM_TYPE_VFP_N; - if (h == 0x100 + FFI_TYPE_FLOAT) - flags = ARM_TYPE_VFP_S; - if (h == 0x100 + FFI_TYPE_DOUBLE) - flags = ARM_TYPE_VFP_D; - if (h != 0) - break; - } - - /* A Composite Type not larger than 4 bytes is returned in r0. - A Composite Type larger than 4 bytes, or whose size cannot - be determined statically ... is stored in memory at an - address passed [in r0]. */ - if (cif->rtype->size <= 4) - flags = ARM_TYPE_INT; - else - { - flags = ARM_TYPE_STRUCT; - bytes += 4; - } - break; - - default: - abort(); - } - - /* Round the stack up to a multiple of 8 bytes. This isn't needed - everywhere, but it is on some platforms, and it doesn't harm anything - when it isn't needed. */ - bytes = ALIGN (bytes, 8); - - /* Minimum stack space is the 4 register arguments that we pop. */ - if (bytes < 4*4) - bytes = 4*4; - - cif->bytes = bytes; - cif->flags = flags; - - return FFI_OK; -} - -/* Perform machine dependent cif processing for variadic calls */ -ffi_status -ffi_prep_cif_machdep_var (ffi_cif * cif, - unsigned int nfixedargs, unsigned int ntotalargs) -{ - /* VFP variadic calls actually use the SYSV ABI */ - if (cif->abi == FFI_VFP) - cif->abi = FFI_SYSV; - - return ffi_prep_cif_machdep (cif); -} - -/* Prototypes for assembly functions, in sysv.S. */ - -struct call_frame -{ - void *fp; - void *lr; - void *rvalue; - int flags; - void *closure; -}; - -extern void ffi_call_SYSV (void *stack, struct call_frame *, - void (*fn) (void)) FFI_HIDDEN; -extern void ffi_call_VFP (void *vfp_space, struct call_frame *, - void (*fn) (void), unsigned vfp_used) FFI_HIDDEN; - -static void -ffi_call_int (ffi_cif * cif, void (*fn) (void), void *rvalue, - void **avalue, void *closure) -{ - int flags = cif->flags; - ffi_type *rtype = cif->rtype; - size_t bytes, rsize, vfp_size; - char *stack, *vfp_space, *new_rvalue; - struct call_frame *frame; - - rsize = 0; - if (rvalue == NULL) - { - /* If the return value is a struct and we don't have a return - value address then we need to make one. Otherwise the return - value is in registers and we can ignore them. */ - if (flags == ARM_TYPE_STRUCT) - rsize = rtype->size; - else - flags = ARM_TYPE_VOID; - } - else if (flags == ARM_TYPE_VFP_N) - { - /* Largest case is double x 4. */ - rsize = 32; - } - else if (flags == ARM_TYPE_INT && rtype->type == FFI_TYPE_STRUCT) - rsize = 4; - - /* Largest case. */ - vfp_size = (cif->abi == FFI_VFP && cif->vfp_used ? 8*8: 0); - - bytes = cif->bytes; - stack = alloca (vfp_size + bytes + sizeof(struct call_frame) + rsize); - - vfp_space = NULL; - if (vfp_size) - { - vfp_space = stack; - stack += vfp_size; - } - - frame = (struct call_frame *)(stack + bytes); - - new_rvalue = rvalue; - if (rsize) - new_rvalue = (void *)(frame + 1); - - frame->rvalue = new_rvalue; - frame->flags = flags; - frame->closure = closure; - - if (vfp_space) - { - ffi_prep_args_VFP (cif, flags, new_rvalue, avalue, stack, vfp_space); - ffi_call_VFP (vfp_space, frame, fn, cif->vfp_used); - } - else - { - ffi_prep_args_SYSV (cif, flags, new_rvalue, avalue, stack); - ffi_call_SYSV (stack, frame, fn); - } - - if (rvalue && rvalue != new_rvalue) - memcpy (rvalue, new_rvalue, rtype->size); -} - -void -ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} - -static void * -ffi_prep_incoming_args_SYSV (ffi_cif *cif, void *rvalue, - char *argp, void **avalue) -{ - ffi_type **arg_types = cif->arg_types; - int i, n; - - if (cif->flags == ARM_TYPE_STRUCT) - { - rvalue = *(void **) argp; - argp += 4; - } - - for (i = 0, n = cif->nargs; i < n; i++) - { - ffi_type *ty = arg_types[i]; - size_t z = ty->size; - - argp = ffi_align (ty, argp); - avalue[i] = (void *) argp; - argp += z; - } - - return rvalue; -} - -static void * -ffi_prep_incoming_args_VFP (ffi_cif *cif, void *rvalue, char *stack, - char *vfp_space, void **avalue) -{ - ffi_type **arg_types = cif->arg_types; - int i, n, vi = 0; - char *argp, *regp, *eo_regp; - char done_with_regs = 0; - char stack_used = 0; - - regp = stack; - eo_regp = argp = regp + 16; - - if (cif->flags == ARM_TYPE_STRUCT) - { - rvalue = *(void **) regp; - regp += 4; - } - - for (i = 0, n = cif->nargs; i < n; i++) - { - ffi_type *ty = arg_types[i]; - int is_vfp_type = vfp_type_p (ty); - size_t z = ty->size; - - if (vi < cif->vfp_nargs && is_vfp_type) - { - avalue[i] = vfp_space + cif->vfp_args[vi++] * 4; - continue; - } - else if (!done_with_regs && !is_vfp_type) - { - char *tregp = ffi_align (ty, regp); - - z = (z < 4) ? 4 : z; // pad - - /* If the arguments either fits into the registers or uses registers - and stack, while we haven't read other things from the stack */ - if (tregp + z <= eo_regp || !stack_used) - { - /* Because we're little endian, this is what it turns into. */ - avalue[i] = (void *) tregp; - regp = tregp + z; - - /* If we read past the last core register, make sure we - have not read from the stack before and continue - reading after regp. */ - if (regp > eo_regp) - { - FFI_ASSERT (!stack_used); - argp = regp; - } - if (regp >= eo_regp) - { - done_with_regs = 1; - stack_used = 1; - } - continue; - } - } - - stack_used = 1; - argp = ffi_align (ty, argp); - avalue[i] = (void *) argp; - argp += z; - } - - return rvalue; -} - -struct closure_frame -{ - char vfp_space[8*8] __attribute__((aligned(8))); - char result[8*4]; - char argp[]; -}; - -int FFI_HIDDEN -ffi_closure_inner_SYSV (ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - struct closure_frame *frame) -{ - void **avalue = (void **) alloca (cif->nargs * sizeof (void *)); - void *rvalue = ffi_prep_incoming_args_SYSV (cif, frame->result, - frame->argp, avalue); - fun (cif, rvalue, avalue, user_data); - return cif->flags; -} - -int FFI_HIDDEN -ffi_closure_inner_VFP (ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - struct closure_frame *frame) -{ - void **avalue = (void **) alloca (cif->nargs * sizeof (void *)); - void *rvalue = ffi_prep_incoming_args_VFP (cif, frame->result, frame->argp, - frame->vfp_space, avalue); - fun (cif, rvalue, avalue, user_data); - return cif->flags; -} - -void ffi_closure_SYSV (void) FFI_HIDDEN; -void ffi_closure_VFP (void) FFI_HIDDEN; -void ffi_go_closure_SYSV (void) FFI_HIDDEN; -void ffi_go_closure_VFP (void) FFI_HIDDEN; - -#if FFI_EXEC_TRAMPOLINE_TABLE - -#include -#include -#include -#include - -extern void *ffi_closure_trampoline_table_page; - -typedef struct ffi_trampoline_table ffi_trampoline_table; -typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry; - -struct ffi_trampoline_table -{ - /* contiguous writable and executable pages */ - vm_address_t config_page; - vm_address_t trampoline_page; - - /* free list tracking */ - uint16_t free_count; - ffi_trampoline_table_entry *free_list; - ffi_trampoline_table_entry *free_list_pool; - - ffi_trampoline_table *prev; - ffi_trampoline_table *next; -}; - -struct ffi_trampoline_table_entry -{ - void *(*trampoline) (); - ffi_trampoline_table_entry *next; -}; - -/* Override the standard architecture trampoline size */ -// XXX TODO - Fix -#undef FFI_TRAMPOLINE_SIZE -#define FFI_TRAMPOLINE_SIZE 12 - -/* The trampoline configuration is placed at 4080 bytes prior to the trampoline's entry point */ -#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - 4080)); - -/* The first 16 bytes of the config page are unused, as they are unaddressable from the trampoline page. */ -#define FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET 16 - -/* Total number of trampolines that fit in one trampoline table */ -#define FFI_TRAMPOLINE_COUNT ((PAGE_SIZE - FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) / FFI_TRAMPOLINE_SIZE) - -static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER; -static ffi_trampoline_table *ffi_trampoline_tables = NULL; - -static ffi_trampoline_table * -ffi_trampoline_table_alloc () -{ - ffi_trampoline_table *table = NULL; - - /* Loop until we can allocate two contiguous pages */ - while (table == NULL) - { - vm_address_t config_page = 0x0; - kern_return_t kt; - - /* Try to allocate two pages */ - kt = - vm_allocate (mach_task_self (), &config_page, PAGE_SIZE * 2, - VM_FLAGS_ANYWHERE); - if (kt != KERN_SUCCESS) - { - fprintf (stderr, "vm_allocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - break; - } - - /* Now drop the second half of the allocation to make room for the trampoline table */ - vm_address_t trampoline_page = config_page + PAGE_SIZE; - kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - { - fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - break; - } - - /* Remap the trampoline table to directly follow the config page */ - vm_prot_t cur_prot; - vm_prot_t max_prot; - - kt = - vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, - mach_task_self (), - (vm_address_t) & ffi_closure_trampoline_table_page, FALSE, - &cur_prot, &max_prot, VM_INHERIT_SHARE); - - /* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */ - if (kt != KERN_SUCCESS) - { - /* Log unexpected failures */ - if (kt != KERN_NO_SPACE) - { - fprintf (stderr, "vm_remap() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - } - - vm_deallocate (mach_task_self (), config_page, PAGE_SIZE); - continue; - } - - /* We have valid trampoline and config pages */ - table = calloc (1, sizeof (ffi_trampoline_table)); - table->free_count = FFI_TRAMPOLINE_COUNT; - table->config_page = config_page; - table->trampoline_page = trampoline_page; - - /* Create and initialize the free list */ - table->free_list_pool = - calloc (FFI_TRAMPOLINE_COUNT, sizeof (ffi_trampoline_table_entry)); - - uint16_t i; - for (i = 0; i < table->free_count; i++) - { - ffi_trampoline_table_entry *entry = &table->free_list_pool[i]; - entry->trampoline = - (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); - - if (i < table->free_count - 1) - entry->next = &table->free_list_pool[i + 1]; - } - - table->free_list = table->free_list_pool; - } - - return table; -} - -void * -ffi_closure_alloc (size_t size, void **code) -{ - /* Create the closure */ - ffi_closure *closure = malloc (size); - if (closure == NULL) - return NULL; - - pthread_mutex_lock (&ffi_trampoline_lock); - - /* Check for an active trampoline table with available entries. */ - ffi_trampoline_table *table = ffi_trampoline_tables; - if (table == NULL || table->free_list == NULL) - { - table = ffi_trampoline_table_alloc (); - if (table == NULL) - { - free (closure); - return NULL; - } - - /* Insert the new table at the top of the list */ - table->next = ffi_trampoline_tables; - if (table->next != NULL) - table->next->prev = table; - - ffi_trampoline_tables = table; - } - - /* Claim the free entry */ - ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list; - ffi_trampoline_tables->free_list = entry->next; - ffi_trampoline_tables->free_count--; - entry->next = NULL; - - pthread_mutex_unlock (&ffi_trampoline_lock); - - /* Initialize the return values */ - *code = entry->trampoline; - closure->trampoline_table = table; - closure->trampoline_table_entry = entry; - - return closure; -} - -void -ffi_closure_free (void *ptr) -{ - ffi_closure *closure = ptr; - - pthread_mutex_lock (&ffi_trampoline_lock); - - /* Fetch the table and entry references */ - ffi_trampoline_table *table = closure->trampoline_table; - ffi_trampoline_table_entry *entry = closure->trampoline_table_entry; - - /* Return the entry to the free list */ - entry->next = table->free_list; - table->free_list = entry; - table->free_count++; - - /* If all trampolines within this table are free, and at least one other table exists, deallocate - * the table */ - if (table->free_count == FFI_TRAMPOLINE_COUNT - && ffi_trampoline_tables != table) - { - /* Remove from the list */ - if (table->prev != NULL) - table->prev->next = table->next; - - if (table->next != NULL) - table->next->prev = table->prev; - - /* Deallocate pages */ - kern_return_t kt; - kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - - kt = - vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - fprintf (stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, - __FILE__, __LINE__); - - /* Deallocate free list */ - free (table->free_list_pool); - free (table); - } - else if (ffi_trampoline_tables != table) - { - /* Otherwise, bump this table to the top of the list */ - table->prev = NULL; - table->next = ffi_trampoline_tables; - if (ffi_trampoline_tables != NULL) - ffi_trampoline_tables->prev = table; - - ffi_trampoline_tables = table; - } - - pthread_mutex_unlock (&ffi_trampoline_lock); - - /* Free the closure */ - free (closure); -} - -#else - -extern unsigned int ffi_arm_trampoline[2] FFI_HIDDEN; - -#endif - -/* the cif must already be prep'ed */ - -ffi_status -ffi_prep_closure_loc (ffi_closure * closure, - ffi_cif * cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, void *codeloc) -{ - void (*closure_func) (void) = ffi_closure_SYSV; - - if (cif->abi == FFI_VFP) - { - /* We only need take the vfp path if there are vfp arguments. */ - if (cif->vfp_used) - closure_func = ffi_closure_VFP; - } - else if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - -#if FFI_EXEC_TRAMPOLINE_TABLE - void **config = FFI_TRAMPOLINE_CODELOC_CONFIG (codeloc); - config[0] = closure; - config[1] = closure_func; -#else - memcpy (closure->tramp, ffi_arm_trampoline, 8); - __clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */ - __clear_cache(codeloc, codeloc + 8); /* clear insn map */ - *(void (**)(void))(closure->tramp + 8) = closure_func; -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -ffi_status -ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *)) -{ - void (*closure_func) (void) = ffi_go_closure_SYSV; - - if (cif->abi == FFI_VFP) - { - /* We only need take the vfp path if there are vfp arguments. */ - if (cif->vfp_used) - closure_func = ffi_go_closure_VFP; - } - else if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - closure->tramp = closure_func; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -/* Below are routines for VFP hard-float support. */ - -/* A subroutine of vfp_type_p. Given a structure type, return the type code - of the first non-structure element. Recurse for structure elements. - Return -1 if the structure is in fact empty, i.e. no nested elements. */ - -static int -is_hfa0 (const ffi_type *ty) -{ - ffi_type **elements = ty->elements; - int i, ret = -1; - - if (elements != NULL) - for (i = 0; elements[i]; ++i) - { - ret = elements[i]->type; - if (ret == FFI_TYPE_STRUCT || ret == FFI_TYPE_COMPLEX) - { - ret = is_hfa0 (elements[i]); - if (ret < 0) - continue; - } - break; - } - - return ret; -} - -/* A subroutine of vfp_type_p. Given a structure type, return true if all - of the non-structure elements are the same as CANDIDATE. */ - -static int -is_hfa1 (const ffi_type *ty, int candidate) -{ - ffi_type **elements = ty->elements; - int i; - - if (elements != NULL) - for (i = 0; elements[i]; ++i) - { - int t = elements[i]->type; - if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) - { - if (!is_hfa1 (elements[i], candidate)) - return 0; - } - else if (t != candidate) - return 0; - } - - return 1; -} - -/* Determine if TY is an homogenous floating point aggregate (HFA). - That is, a structure consisting of 1 to 4 members of all the same type, - where that type is a floating point scalar. - - Returns non-zero iff TY is an HFA. The result is an encoded value where - bits 0-7 contain the type code, and bits 8-10 contain the element count. */ - -static int -vfp_type_p (const ffi_type *ty) -{ - ffi_type **elements; - int candidate, i; - size_t size, ele_count; - - /* Quickest tests first. */ - candidate = ty->type; - switch (ty->type) - { - default: - return 0; - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - ele_count = 1; - goto done; - case FFI_TYPE_COMPLEX: - candidate = ty->elements[0]->type; - if (candidate != FFI_TYPE_FLOAT && candidate != FFI_TYPE_DOUBLE) - return 0; - ele_count = 2; - goto done; - case FFI_TYPE_STRUCT: - break; - } - - /* No HFA types are smaller than 4 bytes, or larger than 32 bytes. */ - size = ty->size; - if (size < 4 || size > 32) - return 0; - - /* Find the type of the first non-structure member. */ - elements = ty->elements; - candidate = elements[0]->type; - if (candidate == FFI_TYPE_STRUCT || candidate == FFI_TYPE_COMPLEX) - { - for (i = 0; ; ++i) - { - candidate = is_hfa0 (elements[i]); - if (candidate >= 0) - break; - } - } - - /* If the first member is not a floating point type, it's not an HFA. - Also quickly re-check the size of the structure. */ - switch (candidate) - { - case FFI_TYPE_FLOAT: - ele_count = size / sizeof(float); - if (size != ele_count * sizeof(float)) - return 0; - break; - case FFI_TYPE_DOUBLE: - ele_count = size / sizeof(double); - if (size != ele_count * sizeof(double)) - return 0; - break; - default: - return 0; - } - if (ele_count > 4) - return 0; - - /* Finally, make sure that all scalar elements are the same type. */ - for (i = 0; elements[i]; ++i) - { - int t = elements[i]->type; - if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) - { - if (!is_hfa1 (elements[i], candidate)) - return 0; - } - else if (t != candidate) - return 0; - } - - /* All tests succeeded. Encode the result. */ - done: - return (ele_count << 8) | candidate; -} - -static int -place_vfp_arg (ffi_cif *cif, int h) -{ - unsigned short reg = cif->vfp_reg_free; - int align = 1, nregs = h >> 8; - - if ((h & 0xff) == FFI_TYPE_DOUBLE) - align = 2, nregs *= 2; - - /* Align register number. */ - if ((reg & 1) && align == 2) - reg++; - - while (reg + nregs <= 16) - { - int s, new_used = 0; - for (s = reg; s < reg + nregs; s++) - { - new_used |= (1 << s); - if (cif->vfp_used & (1 << s)) - { - reg += align; - goto next_reg; - } - } - /* Found regs to allocate. */ - cif->vfp_used |= new_used; - cif->vfp_args[cif->vfp_nargs++] = reg; - - /* Update vfp_reg_free. */ - if (cif->vfp_used & (1 << cif->vfp_reg_free)) - { - reg += nregs; - while (cif->vfp_used & (1 << reg)) - reg += 1; - cif->vfp_reg_free = reg; - } - return 0; - next_reg:; - } - // done, mark all regs as used - cif->vfp_reg_free = 16; - cif->vfp_used = 0xFFFF; - return 1; -} - -static void -layout_vfp_args (ffi_cif * cif) -{ - int i; - /* Init VFP fields */ - cif->vfp_used = 0; - cif->vfp_nargs = 0; - cif->vfp_reg_free = 0; - memset (cif->vfp_args, -1, 16); /* Init to -1. */ - - for (i = 0; i < cif->nargs; i++) - { - int h = vfp_type_p (cif->arg_types[i]); - if (h && place_vfp_arg (cif, h) == 1) - break; - } -} diff --git a/user/mpy/lib/libffi/src/arm/ffitarget.h b/user/mpy/lib/libffi/src/arm/ffitarget.h deleted file mode 100644 index 4f473f9..0000000 --- a/user/mpy/lib/libffi/src/arm/ffitarget.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2010 CodeSourcery - Copyright (c) 1996-2003 Red Hat, Inc. - - Target configuration macros for ARM. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_VFP, - FFI_LAST_ABI, -#ifdef __ARM_PCS_VFP - FFI_DEFAULT_ABI = FFI_VFP, -#else - FFI_DEFAULT_ABI = FFI_SYSV, -#endif -} ffi_abi; -#endif - -#define FFI_EXTRA_CIF_FIELDS \ - int vfp_used; \ - unsigned short vfp_reg_free, vfp_nargs; \ - signed char vfp_args[16] \ - -#define FFI_TARGET_SPECIFIC_VARIADIC -#define FFI_TARGET_HAS_COMPLEX_TYPE - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_GO_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 12 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/arm/internal.h b/user/mpy/lib/libffi/src/arm/internal.h deleted file mode 100644 index 6cf0b2a..0000000 --- a/user/mpy/lib/libffi/src/arm/internal.h +++ /dev/null @@ -1,7 +0,0 @@ -#define ARM_TYPE_VFP_S 0 -#define ARM_TYPE_VFP_D 1 -#define ARM_TYPE_VFP_N 2 -#define ARM_TYPE_INT64 3 -#define ARM_TYPE_INT 4 -#define ARM_TYPE_VOID 5 -#define ARM_TYPE_STRUCT 6 diff --git a/user/mpy/lib/libffi/src/arm/sysv.S b/user/mpy/lib/libffi/src/arm/sysv.S deleted file mode 100644 index fd16589..0000000 --- a/user/mpy/lib/libffi/src/arm/sysv.S +++ /dev/null @@ -1,335 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 1998, 2008, 2011 Red Hat, Inc. - Copyright (c) 2011 Plausible Labs Cooperative, Inc. - - ARM Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#include -#include "internal.h" - -/* GCC 4.8 provides __ARM_ARCH; construct it otherwise. */ -#ifndef __ARM_ARCH -# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) -# define __ARM_ARCH 7 -# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ - || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ - || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \ - || defined(__ARM_ARCH_6M__) -# define __ARM_ARCH 6 -# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \ - || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ - || defined(__ARM_ARCH_5TEJ__) -# define __ARM_ARCH 5 -# else -# define __ARM_ARCH 4 -# endif -#endif - -/* Conditionally compile unwinder directives. */ -.macro UNWIND text:vararg -#ifdef __ARM_EABI__ - \text -#endif -.endm -#if defined(HAVE_AS_CFI_PSEUDO_OP) && defined(__ARM_EABI__) - .cfi_sections .debug_frame -#endif - -#define CONCAT(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -#ifdef __USER_LABEL_PREFIX__ -# define CNAME(X) CONCAT (__USER_LABEL_PREFIX__, X) -#else -# define CNAME(X) X -#endif -#ifdef __ELF__ -# define SIZE(X) .size CNAME(X), . - CNAME(X) -# define TYPE(X, Y) .type CNAME(X), Y -#else -# define SIZE(X) -# define TYPE(X, Y) -#endif - -#define ARM_FUNC_START(name, gl) \ - .align 3; \ - .ifne gl; .globl CNAME(name); FFI_HIDDEN(CNAME(name)); .endif; \ - TYPE(name, %function); \ - CNAME(name): - -#define ARM_FUNC_END(name) \ - SIZE(name) - -/* Aid in defining a jump table with 8 bytes between entries. */ -.macro E index - .if . - 0b - 8*\index - .error "type table out of sync" - .endif -.endm - - .text - .syntax unified - .arm - - /* We require interworking on LDM, which implies ARMv5T, - which implies the existance of BLX. */ - .arch armv5t - - /* Note that we use STC and LDC to encode VFP instructions, - so that we do not need ".fpu vfp", nor get that added to - the object file attributes. These will not be executed - unless the FFI_VFP abi is used. */ - - @ r0: stack - @ r1: frame - @ r2: fn - @ r3: vfp_used - -ARM_FUNC_START(ffi_call_VFP, 1) - UNWIND .fnstart - cfi_startproc - - cmp r3, #3 @ load only d0 if possible - ldcle p11, cr0, [r0] @ vldrle d0, [sp] - ldcgt p11, cr0, [r0], {16} @ vldmgt sp, {d0-d7} - add r0, r0, #64 @ discard the vfp register args - /* FALLTHRU */ -ARM_FUNC_END(ffi_call_VFP) - -ARM_FUNC_START(ffi_call_SYSV, 1) - stm r1, {fp, lr} - mov fp, r1 - - @ This is a bit of a lie wrt the origin of the unwind info, but - @ now we've got the usual frame pointer and two saved registers. - UNWIND .save {fp,lr} - UNWIND .setfp fp, sp - cfi_def_cfa(fp, 8) - cfi_rel_offset(fp, 0) - cfi_rel_offset(lr, 4) - - mov sp, r0 @ install the stack pointer - mov lr, r2 @ move the fn pointer out of the way - ldr ip, [fp, #16] @ install the static chain - ldmia sp!, {r0-r3} @ move first 4 parameters in registers. - blx lr @ call fn - - @ Load r2 with the pointer to storage for the return value - @ Load r3 with the return type code - ldr r2, [fp, #8] - ldr r3, [fp, #12] - - @ Deallocate the stack with the arguments. - mov sp, fp - cfi_def_cfa_register(sp) - - @ Store values stored in registers. - .align 3 - add pc, pc, r3, lsl #3 - nop -0: -E ARM_TYPE_VFP_S - stc p10, cr0, [r2] @ vstr s0, [r2] - pop {fp,pc} -E ARM_TYPE_VFP_D - stc p11, cr0, [r2] @ vstr d0, [r2] - pop {fp,pc} -E ARM_TYPE_VFP_N - stc p11, cr0, [r2], {8} @ vstm r2, {d0-d3} - pop {fp,pc} -E ARM_TYPE_INT64 - str r1, [r2, #4] - nop -E ARM_TYPE_INT - str r0, [r2] - pop {fp,pc} -E ARM_TYPE_VOID - pop {fp,pc} - nop -E ARM_TYPE_STRUCT - pop {fp,pc} - - cfi_endproc - UNWIND .fnend -ARM_FUNC_END(ffi_call_SYSV) - - -/* - int ffi_closure_inner_* (cif, fun, user_data, frame) -*/ - -ARM_FUNC_START(ffi_go_closure_SYSV, 1) - cfi_startproc - stmdb sp!, {r0-r3} @ save argument regs - cfi_adjust_cfa_offset(16) - ldr r0, [ip, #4] @ load cif - ldr r1, [ip, #8] @ load fun - mov r2, ip @ load user_data - b 0f - cfi_endproc -ARM_FUNC_END(ffi_go_closure_SYSV) - -ARM_FUNC_START(ffi_closure_SYSV, 1) - UNWIND .fnstart - cfi_startproc - stmdb sp!, {r0-r3} @ save argument regs - cfi_adjust_cfa_offset(16) - ldr r0, [ip, #FFI_TRAMPOLINE_SIZE] @ load cif - ldr r1, [ip, #FFI_TRAMPOLINE_SIZE+4] @ load fun - ldr r2, [ip, #FFI_TRAMPOLINE_SIZE+8] @ load user_data -0: - add ip, sp, #16 @ compute entry sp - sub sp, sp, #64+32 @ allocate frame - cfi_adjust_cfa_offset(64+32) - stmdb sp!, {ip,lr} - - /* Remember that EABI unwind info only applies at call sites. - We need do nothing except note the save of the stack pointer - and the link registers. */ - UNWIND .save {sp,lr} - cfi_adjust_cfa_offset(8) - cfi_rel_offset(lr, 4) - - add r3, sp, #8 @ load frame - bl CNAME(ffi_closure_inner_SYSV) - - @ Load values returned in registers. - add r2, sp, #8+64 @ load result - adr r3, CNAME(ffi_closure_ret) - add pc, r3, r0, lsl #3 - cfi_endproc - UNWIND .fnend -ARM_FUNC_END(ffi_closure_SYSV) - -ARM_FUNC_START(ffi_go_closure_VFP, 1) - cfi_startproc - stmdb sp!, {r0-r3} @ save argument regs - cfi_adjust_cfa_offset(16) - ldr r0, [ip, #4] @ load cif - ldr r1, [ip, #8] @ load fun - mov r2, ip @ load user_data - b 0f - cfi_endproc -ARM_FUNC_END(ffi_go_closure_VFP) - -ARM_FUNC_START(ffi_closure_VFP, 1) - UNWIND .fnstart - cfi_startproc - stmdb sp!, {r0-r3} @ save argument regs - cfi_adjust_cfa_offset(16) - ldr r0, [ip, #FFI_TRAMPOLINE_SIZE] @ load cif - ldr r1, [ip, #FFI_TRAMPOLINE_SIZE+4] @ load fun - ldr r2, [ip, #FFI_TRAMPOLINE_SIZE+8] @ load user_data -0: - add ip, sp, #16 - sub sp, sp, #64+32 @ allocate frame - cfi_adjust_cfa_offset(64+32) - stc p11, cr0, [sp], {16} @ vstm sp, {d0-d7} - stmdb sp!, {ip,lr} - - /* See above. */ - UNWIND .save {sp,lr} - cfi_adjust_cfa_offset(8) - cfi_rel_offset(lr, 4) - - add r3, sp, #8 @ load frame - bl CNAME(ffi_closure_inner_VFP) - - @ Load values returned in registers. - add r2, sp, #8+64 @ load result - adr r3, CNAME(ffi_closure_ret) - add pc, r3, r0, lsl #3 - cfi_endproc - UNWIND .fnend -ARM_FUNC_END(ffi_closure_VFP) - -/* Load values returned in registers for both closure entry points. - Note that we use LDM with SP in the register set. This is deprecated - by ARM, but not yet unpredictable. */ - -ARM_FUNC_START(ffi_closure_ret, 0) - cfi_startproc - cfi_rel_offset(sp, 0) - cfi_rel_offset(lr, 4) -0: -E ARM_TYPE_VFP_S - ldc p10, cr0, [r2] @ vldr s0, [r2] - ldm sp, {sp,pc} -E ARM_TYPE_VFP_D - ldc p11, cr0, [r2] @ vldr d0, [r2] - ldm sp, {sp,pc} -E ARM_TYPE_VFP_N - ldc p11, cr0, [r2], {8} @ vldm r2, {d0-d3} - ldm sp, {sp,pc} -E ARM_TYPE_INT64 - ldr r1, [r2, #4] - nop -E ARM_TYPE_INT - ldr r0, [r2] - ldm sp, {sp,pc} -E ARM_TYPE_VOID - ldm sp, {sp,pc} - nop -E ARM_TYPE_STRUCT - ldm sp, {sp,pc} - cfi_endproc -ARM_FUNC_END(ffi_closure_ret) - -#if FFI_EXEC_TRAMPOLINE_TABLE - -/* ??? The iOS support should be updated. The first insn used to - be STMFD, but that's been moved into ffi_closure_SYSV. If the - writable page is put after this one we can make use of the - pc+8 feature of the architecture. We can also reduce the size - of the thunk to 8 and pack more of these into the page. - - In the meantime, simply replace the STMFD with a NOP so as to - keep all the magic numbers the same within ffi.c. */ - - .align 12 -ARM_FUNC_START(ffi_closure_trampoline_table_page) -.rept 4096 / 12 - nop - ldr ip, [pc, #-4092] - ldr pc, [pc, #-4092] -.endr - -#else - -ARM_FUNC_START(ffi_arm_trampoline, 1) -0: adr ip, 0b - ldr pc, 1f -1: .long 0 -ARM_FUNC_END(ffi_arm_trampoline) - -#endif /* FFI_EXEC_TRAMPOLINE_TABLE */ - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",%progbits -#endif diff --git a/user/mpy/lib/libffi/src/avr32/ffi.c b/user/mpy/lib/libffi/src/avr32/ffi.c deleted file mode 100644 index 3d43397..0000000 --- a/user/mpy/lib/libffi/src/avr32/ffi.c +++ /dev/null @@ -1,423 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011 Anthony Green - Copyright (c) 2009 Bradley Smith - - AVR32 Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include -#include -#include -#include - -/* #define DEBUG */ - -extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, - unsigned int, unsigned int, unsigned int*, unsigned int, - void (*fn)(void)); -extern void ffi_closure_SYSV (ffi_closure *); - -unsigned int pass_struct_on_stack(ffi_type *type) -{ - if(type->type != FFI_TYPE_STRUCT) - return 0; - - if(type->alignment < type->size && - !(type->size == 4 || type->size == 8) && - !(type->size == 8 && type->alignment >= 4)) - return 1; - - if(type->size == 3 || type->size == 5 || type->size == 6 || - type->size == 7) - return 1; - - return 0; -} - -/* ffi_prep_args is called by the assembly routine once stack space - * has been allocated for the function's arguments - * - * This is annoyingly complex since we need to keep track of used - * registers. - */ - -void ffi_prep_args(char *stack, extended_cif *ecif) -{ - unsigned int i; - void **p_argv; - ffi_type **p_arg; - char *reg_base = stack; - char *stack_base = stack + 20; - unsigned int stack_offset = 0; - unsigned int reg_mask = 0; - - p_argv = ecif->avalue; - - /* If cif->flags is struct then we know it's not passed in registers */ - if(ecif->cif->flags == FFI_TYPE_STRUCT) - { - *(void**)reg_base = ecif->rvalue; - reg_mask |= 1; - } - - for(i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; - i++, p_arg++) - { - size_t z = (*p_arg)->size; - int alignment = (*p_arg)->alignment; - int type = (*p_arg)->type; - char *addr = 0; - - if(z % 4 != 0) - z += (4 - z % 4); - - if(reg_mask != 0x1f) - { - if(pass_struct_on_stack(*p_arg)) - { - addr = stack_base + stack_offset; - stack_offset += z; - } - else if(z == sizeof(int)) - { - char index = 0; - - while((reg_mask >> index) & 1) - index++; - - addr = reg_base + (index * 4); - reg_mask |= (1 << index); - } - else if(z == 2 * sizeof(int)) - { - if(!((reg_mask >> 1) & 1)) - { - addr = reg_base + 4; - reg_mask |= (3 << 1); - } - else if(!((reg_mask >> 3) & 1)) - { - addr = reg_base + 12; - reg_mask |= (3 << 3); - } - } - } - - if(!addr) - { - addr = stack_base + stack_offset; - stack_offset += z; - } - - if(type == FFI_TYPE_STRUCT && (*p_arg)->elements[1] == NULL) - type = (*p_arg)->elements[0]->type; - - switch(type) - { - case FFI_TYPE_UINT8: - *(unsigned int *)addr = (unsigned int)*(UINT8 *)(*p_argv); - break; - case FFI_TYPE_SINT8: - *(signed int *)addr = (signed int)*(SINT8 *)(*p_argv); - break; - case FFI_TYPE_UINT16: - *(unsigned int *)addr = (unsigned int)*(UINT16 *)(*p_argv); - break; - case FFI_TYPE_SINT16: - *(signed int *)addr = (signed int)*(SINT16 *)(*p_argv); - break; - default: - memcpy(addr, *p_argv, z); - } - - p_argv++; - } - -#ifdef DEBUG - /* Debugging */ - for(i = 0; i < 5; i++) - { - if((reg_mask & (1 << i)) == 0) - printf("r%d: (unused)\n", 12 - i); - else - printf("r%d: 0x%08x\n", 12 - i, ((unsigned int*)reg_base)[i]); - } - - for(i = 0; i < stack_offset / 4; i++) - { - printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack_base)[i]); - } -#endif -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* Round the stack up to a multiple of 8 bytes. This isn't needed - * everywhere, but it is on some platforms, and it doesn't harm - * anything when it isn't needed. */ - cif->bytes = (cif->bytes + 7) & ~7; - - /* Flag to indicate that he return value is in fact a struct */ - cif->rstruct_flag = 0; - - /* Set the return type flag */ - switch(cif->rtype->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - cif->flags = (unsigned)FFI_TYPE_UINT8; - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - cif->flags = (unsigned)FFI_TYPE_UINT16; - break; - case FFI_TYPE_FLOAT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - cif->flags = (unsigned)FFI_TYPE_UINT32; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = (unsigned)FFI_TYPE_UINT64; - break; - case FFI_TYPE_STRUCT: - cif->rstruct_flag = 1; - if(!pass_struct_on_stack(cif->rtype)) - { - if(cif->rtype->size <= 1) - cif->flags = (unsigned)FFI_TYPE_UINT8; - else if(cif->rtype->size <= 2) - cif->flags = (unsigned)FFI_TYPE_UINT16; - else if(cif->rtype->size <= 4) - cif->flags = (unsigned)FFI_TYPE_UINT32; - else if(cif->rtype->size <= 8) - cif->flags = (unsigned)FFI_TYPE_UINT64; - else - cif->flags = (unsigned)cif->rtype->type; - } - else - cif->flags = (unsigned)cif->rtype->type; - break; - default: - cif->flags = (unsigned)cif->rtype->type; - break; - } - - return FFI_OK; -} - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - unsigned int size = 0, i = 0; - ffi_type **p_arg; - - ecif.cif = cif; - ecif.avalue = avalue; - - for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++) - size += (*p_arg)->size + (4 - (*p_arg)->size % 4); - - /* If the return value is a struct and we don't have a return value - * address then we need to make one */ - - /* If cif->flags is struct then it's not suitable for registers */ - if((rvalue == NULL) && (cif->flags == FFI_TYPE_STRUCT)) - ecif.rvalue = alloca(cif->rtype->size); - else - ecif.rvalue = rvalue; - - switch(cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, size, cif->flags, - ecif.rvalue, cif->rstruct_flag, fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - -static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, - void **avalue, ffi_cif *cif) -{ - register unsigned int i, reg_mask = 0; - register void **p_argv; - register ffi_type **p_arg; - register char *reg_base = stack; - register char *stack_base = stack + 20; - register unsigned int stack_offset = 0; - -#ifdef DEBUG - /* Debugging */ - for(i = 0; i < cif->nargs + 7; i++) - { - printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack)[i]); - } -#endif - - /* If cif->flags is struct then we know it's not passed in registers */ - if(cif->flags == FFI_TYPE_STRUCT) - { - *rvalue = *(void **)reg_base; - reg_mask |= 1; - } - - p_argv = avalue; - - for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++) - { - size_t z = (*p_arg)->size; - int alignment = (*p_arg)->alignment; - - *p_argv = 0; - - if(z % 4 != 0) - z += (4 - z % 4); - - if(reg_mask != 0x1f) - { - if(pass_struct_on_stack(*p_arg)) - { - *p_argv = (void*)stack_base + stack_offset; - stack_offset += z; - } - else if(z <= sizeof(int)) - { - char index = 0; - - while((reg_mask >> index) & 1) - index++; - - *p_argv = (void*)reg_base + (index * 4); - reg_mask |= (1 << index); - } - else if(z == 2 * sizeof(int)) - { - if(!((reg_mask >> 1) & 1)) - { - *p_argv = (void*)reg_base + 4; - reg_mask |= (3 << 1); - } - else if(!((reg_mask >> 3) & 1)) - { - *p_argv = (void*)reg_base + 12; - reg_mask |= (3 << 3); - } - } - } - - if(!*p_argv) - { - *p_argv = (void*)stack_base + stack_offset; - stack_offset += z; - } - - if((*p_arg)->type != FFI_TYPE_STRUCT || - (*p_arg)->elements[1] == NULL) - { - if(alignment == 1) - **(unsigned int**)p_argv <<= 24; - else if(alignment == 2) - **(unsigned int**)p_argv <<= 16; - } - - p_argv++; - } - -#ifdef DEBUG - /* Debugging */ - for(i = 0; i < cif->nargs; i++) - { - printf("sp+%d: 0x%08x\n", i*4, *(((unsigned int**)avalue)[i])); - } -#endif -} - -/* This function is jumped to by the trampoline */ - -unsigned int ffi_closure_SYSV_inner(ffi_closure *closure, void **respp, - void *args) -{ - ffi_cif *cif; - void **arg_area; - unsigned int i, size = 0; - ffi_type **p_arg; - - cif = closure->cif; - - for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++) - size += (*p_arg)->size + (4 - (*p_arg)->size % 4); - - arg_area = (void **)alloca(size); - - /* this call will initialize ARG_AREA, such that each element in that - * array points to the corresponding value on the stack; and if the - * function returns a structure, it will re-set RESP to point to the - * structure return address. */ - - ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); - - (closure->fun)(cif, *respp, arg_area, closure->user_data); - - return cif->flags; -} - -ffi_status ffi_prep_closure_loc(ffi_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), void *user_data, - void *codeloc) -{ - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]); - unsigned int __fun = (unsigned int)(&ffi_closure_SYSV); - unsigned int __ctx = (unsigned int)(codeloc); - unsigned int __rstruct_flag = (unsigned int)(cif->rstruct_flag); - unsigned int __inner = (unsigned int)(&ffi_closure_SYSV_inner); - *(unsigned int*) &__tramp[0] = 0xebcd1f00; /* pushm r8-r12 */ - *(unsigned int*) &__tramp[4] = 0xfefc0010; /* ld.w r12, pc[16] */ - *(unsigned int*) &__tramp[8] = 0xfefb0010; /* ld.w r11, pc[16] */ - *(unsigned int*) &__tramp[12] = 0xfefa0010; /* ld.w r10, pc[16] */ - *(unsigned int*) &__tramp[16] = 0xfeff0010; /* ld.w pc, pc[16] */ - *(unsigned int*) &__tramp[20] = __ctx; - *(unsigned int*) &__tramp[24] = __rstruct_flag; - *(unsigned int*) &__tramp[28] = __inner; - *(unsigned int*) &__tramp[32] = __fun; - syscall(__NR_cacheflush, 0, (&__tramp[0]), 36); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - diff --git a/user/mpy/lib/libffi/src/avr32/ffitarget.h b/user/mpy/lib/libffi/src/avr32/ffitarget.h deleted file mode 100644 index d0c7586..0000000 --- a/user/mpy/lib/libffi/src/avr32/ffitarget.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2009 Bradley Smith - Target configuration macros for AVR32. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#define FFI_EXTRA_CIF_FIELDS unsigned int rstruct_flag - -/* Definitions for closures */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 36 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/avr32/sysv.S b/user/mpy/lib/libffi/src/avr32/sysv.S deleted file mode 100644 index a984b3c..0000000 --- a/user/mpy/lib/libffi/src/avr32/sysv.S +++ /dev/null @@ -1,208 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2009 Bradley Smith - - AVR32 Foreign Function Interface - - 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. - --------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - /* r12: ffi_prep_args - * r11: &ecif - * r10: size - * r9: cif->flags - * r8: ecif.rvalue - * sp+0: cif->rstruct_flag - * sp+4: fn */ - - .text - .align 1 - .globl ffi_call_SYSV - .type ffi_call_SYSV, @function -ffi_call_SYSV: - stm --sp, r0,r1,lr - stm --sp, r8-r12 - mov r0, sp - - /* Make room for all of the new args. */ - sub sp, r10 - /* Pad to make way for potential skipped registers */ - sub sp, 20 - - /* Call ffi_prep_args(stack, &ecif). */ - /* r11 already set */ - mov r1, r12 - mov r12, sp - icall r1 - - /* Save new argument size */ - mov r1, r12 - - /* Move first 5 parameters in registers. */ - ldm sp++, r8-r12 - - /* call (fn) (...). */ - ld.w r1, r0[36] - icall r1 - - /* Remove the space we pushed for the args. */ - mov sp, r0 - - /* Load r1 with the rstruct flag. */ - ld.w r1, sp[32] - - /* Load r9 with the return type code. */ - ld.w r9, sp[12] - - /* Load r8 with the return value pointer. */ - ld.w r8, sp[16] - - /* If the return value pointer is NULL, assume no return value. */ - cp.w r8, 0 - breq .Lend - - /* Check if return type is actually a struct */ - cp.w r1, 0 - breq 1f - - /* Return 8bit */ - cp.w r9, FFI_TYPE_UINT8 - breq .Lstore8 - - /* Return 16bit */ - cp.w r9, FFI_TYPE_UINT16 - breq .Lstore16 - -1: - /* Return 32bit */ - cp.w r9, FFI_TYPE_UINT32 - breq .Lstore32 - cp.w r9, FFI_TYPE_UINT16 - breq .Lstore32 - cp.w r9, FFI_TYPE_UINT8 - breq .Lstore32 - - /* Return 64bit */ - cp.w r9, FFI_TYPE_UINT64 - breq .Lstore64 - - /* Didn't match anything */ - bral .Lend - -.Lstore64: - st.w r8[0], r11 - st.w r8[4], r10 - bral .Lend - -.Lstore32: - st.w r8[0], r12 - bral .Lend - -.Lstore16: - st.h r8[0], r12 - bral .Lend - -.Lstore8: - st.b r8[0], r12 - bral .Lend - -.Lend: - sub sp, -20 - ldm sp++, r0,r1,pc - - .size ffi_call_SYSV, . - ffi_call_SYSV - - - /* r12: __ctx - * r11: __rstruct_flag - * r10: __inner */ - - .align 1 - .globl ffi_closure_SYSV - .type ffi_closure_SYSV, @function -ffi_closure_SYSV: - stm --sp, r0,lr - mov r0, r11 - mov r8, r10 - sub r10, sp, -8 - sub sp, 12 - st.w sp[8], sp - sub r11, sp, -8 - icall r8 - - /* Check if return type is actually a struct */ - cp.w r0, 0 - breq 1f - - /* Return 8bit */ - cp.w r12, FFI_TYPE_UINT8 - breq .Lget8 - - /* Return 16bit */ - cp.w r12, FFI_TYPE_UINT16 - breq .Lget16 - -1: - /* Return 32bit */ - cp.w r12, FFI_TYPE_UINT32 - breq .Lget32 - cp.w r12, FFI_TYPE_UINT16 - breq .Lget32 - cp.w r12, FFI_TYPE_UINT8 - breq .Lget32 - - /* Return 64bit */ - cp.w r12, FFI_TYPE_UINT64 - breq .Lget64 - - /* Didn't match anything */ - bral .Lclend - -.Lget64: - ld.w r11, sp[0] - ld.w r10, sp[4] - bral .Lclend - -.Lget32: - ld.w r12, sp[0] - bral .Lclend - -.Lget16: - ld.uh r12, sp[0] - bral .Lclend - -.Lget8: - ld.ub r12, sp[0] - bral .Lclend - -.Lclend: - sub sp, -12 - ldm sp++, r0,lr - sub sp, -20 - mov pc, lr - - .size ffi_closure_SYSV, . - ffi_closure_SYSV - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/bfin/ffi.c b/user/mpy/lib/libffi/src/bfin/ffi.c deleted file mode 100644 index 22a2acd..0000000 --- a/user/mpy/lib/libffi/src/bfin/ffi.c +++ /dev/null @@ -1,196 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012 Alexandre K. I. de Mendonca , - Paulo Pizarro - - Blackfin Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ -#include -#include - -#include -#include - -/* Maximum number of GPRs available for argument passing. */ -#define MAX_GPRARGS 3 - -/* - * Return types - */ -#define FFIBFIN_RET_VOID 0 -#define FFIBFIN_RET_BYTE 1 -#define FFIBFIN_RET_HALFWORD 2 -#define FFIBFIN_RET_INT64 3 -#define FFIBFIN_RET_INT32 4 - -/*====================================================================*/ -/* PROTOTYPE * - /*====================================================================*/ -void ffi_prep_args(unsigned char *, extended_cif *); - -/*====================================================================*/ -/* Externals */ -/* (Assembly) */ -/*====================================================================*/ - -extern void ffi_call_SYSV(unsigned, extended_cif *, void(*)(unsigned char *, extended_cif *), unsigned, void *, void(*fn)(void)); - -/*====================================================================*/ -/* Implementation */ -/* */ -/*====================================================================*/ - - -/* - * This function calculates the return type (size) based on type. - */ - -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* --------------------------------------* - * Return handling * - * --------------------------------------*/ - switch (cif->rtype->type) { - case FFI_TYPE_VOID: - cif->flags = FFIBFIN_RET_VOID; - break; - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - cif->flags = FFIBFIN_RET_HALFWORD; - break; - case FFI_TYPE_UINT8: - cif->flags = FFIBFIN_RET_BYTE; - break; - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: - case FFI_TYPE_SINT8: - cif->flags = FFIBFIN_RET_INT32; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - cif->flags = FFIBFIN_RET_INT64; - break; - case FFI_TYPE_STRUCT: - if (cif->rtype->size <= 4){ - cif->flags = FFIBFIN_RET_INT32; - }else if (cif->rtype->size == 8){ - cif->flags = FFIBFIN_RET_INT64; - }else{ - //it will return via a hidden pointer in P0 - cif->flags = FFIBFIN_RET_VOID; - } - break; - default: - FFI_ASSERT(0); - break; - } - return FFI_OK; -} - -/* - * This will prepare the arguments and will call the assembly routine - * cif = the call interface - * fn = the function to be called - * rvalue = the return value - * avalue = the arguments - */ -void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue) -{ - int ret_type = cif->flags; - extended_cif ecif; - ecif.cif = cif; - ecif.avalue = avalue; - ecif.rvalue = rvalue; - - switch (cif->abi) { - case FFI_SYSV: - ffi_call_SYSV(cif->bytes, &ecif, ffi_prep_args, ret_type, ecif.rvalue, fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - - -/* -* This function prepares the parameters (copies them from the ecif to the stack) -* to call the function (ffi_prep_args is called by the assembly routine in file -* sysv.S, which also calls the actual function) -*/ -void ffi_prep_args(unsigned char *stack, extended_cif *ecif) -{ - register unsigned int i = 0; - void **p_argv; - unsigned char *argp; - ffi_type **p_arg; - argp = stack; - p_argv = ecif->avalue; - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); - i--, p_arg++) { - size_t z; - z = (*p_arg)->size; - if (z < sizeof(int)) { - z = sizeof(int); - switch ((*p_arg)->type) { - case FFI_TYPE_SINT8: { - signed char v = *(SINT8 *)(* p_argv); - signed int t = v; - *(signed int *) argp = t; - } - break; - case FFI_TYPE_UINT8: { - unsigned char v = *(UINT8 *)(* p_argv); - unsigned int t = v; - *(unsigned int *) argp = t; - } - break; - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) * (SINT16 *)(* p_argv); - break; - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) * (UINT16 *)(* p_argv); - break; - case FFI_TYPE_STRUCT: - memcpy(argp, *p_argv, (*p_arg)->size); - break; - default: - FFI_ASSERT(0); - break; - } - } else if (z == sizeof(int)) { - *(unsigned int *) argp = (unsigned int) * (UINT32 *)(* p_argv); - } else { - memcpy(argp, *p_argv, z); - } - p_argv++; - argp += z; - } -} - - - diff --git a/user/mpy/lib/libffi/src/bfin/ffitarget.h b/user/mpy/lib/libffi/src/bfin/ffitarget.h deleted file mode 100644 index 2175c01..0000000 --- a/user/mpy/lib/libffi/src/bfin/ffitarget.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ----------------------------------------------------------------------- - ffitarget.h - Copyright (c) 2012 Alexandre K. I. de Mendonca - - Blackfin Foreign Function Interface - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#endif - diff --git a/user/mpy/lib/libffi/src/bfin/sysv.S b/user/mpy/lib/libffi/src/bfin/sysv.S deleted file mode 100644 index f4278be..0000000 --- a/user/mpy/lib/libffi/src/bfin/sysv.S +++ /dev/null @@ -1,179 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2012 Alexandre K. I. de Mendonca , - Paulo Pizarro - - Blackfin Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -.text -.align 4 - - /* - There is a "feature" in the bfin toolchain that it puts a _ before function names - that's why the function here it's called _ffi_call_SYSV and not ffi_call_SYSV - */ - .global _ffi_call_SYSV; - .type _ffi_call_SYSV, STT_FUNC; - .func ffi_call_SYSV - - /* - cif->bytes = R0 (fp+8) - &ecif = R1 (fp+12) - ffi_prep_args = R2 (fp+16) - ret_type = stack (fp+20) - ecif.rvalue = stack (fp+24) - fn = stack (fp+28) - got (fp+32) - - There is room for improvement here (we can use temporary registers - instead of saving the values in the memory) - REGS: - P5 => Stack pointer (function arguments) - R5 => cif->bytes - R4 => ret->type - - FP-20 = P3 - FP-16 = SP (parameters area) - FP-12 = SP (temp) - FP-08 = function return part 1 [R0] - FP-04 = function return part 2 [R1] - */ - -_ffi_call_SYSV: -.prologue: - LINK 20; - [FP-20] = P3; - [FP+8] = R0; - [FP+12] = R1; - [FP+16] = R2; - -.allocate_stack: - //alocate cif->bytes into the stack - R1 = [FP+8]; - R0 = SP; - R0 = R0 - R1; - R1 = 4; - R0 = R0 - R1; - [FP-12] = SP; - SP = R0; - [FP-16] = SP; - -.call_prep_args: - //get the addr of prep_args - P0 = [P3 + _ffi_prep_args@FUNCDESC_GOT17M4]; - P1 = [P0]; - P3 = [P0+4]; - R0 = [FP-16];//SP (parameter area) - R1 = [FP+12];//ecif - call (P1); - -.call_user_function: - //ajust SP so as to allow the user function access the parameters on the stack - SP = [FP-16]; //point to function parameters - R0 = [SP]; - R1 = [SP+4]; - R2 = [SP+8]; - //load user function address - P0 = FP; - P0 +=28; - P1 = [P0]; - P1 = [P1]; - P3 = [P0+4]; - /* - For functions returning aggregate values (struct) occupying more than 8 bytes, - the caller allocates the return value object on the stack and the address - of this object is passed to the callee as a hidden argument in register P0. - */ - P0 = [FP+24]; - - call (P1); - SP = [FP-12]; -.compute_return: - P2 = [FP-20]; - [FP-8] = R0; - [FP-4] = R1; - - R0 = [FP+20]; - R1 = R0 << 2; - - R0 = [P2+.rettable@GOT17M4]; - R0 = R1 + R0; - P2 = R0; - R1 = [P2]; - - P2 = [FP+-20]; - R0 = [P2+.rettable@GOT17M4]; - R0 = R1 + R0; - P2 = R0; - R0 = [FP-8]; - R1 = [FP-4]; - jump (P2); - -/* -#define FFIBFIN_RET_VOID 0 -#define FFIBFIN_RET_BYTE 1 -#define FFIBFIN_RET_HALFWORD 2 -#define FFIBFIN_RET_INT64 3 -#define FFIBFIN_RET_INT32 4 -*/ -.align 4 -.align 4 -.rettable: - .dd .epilogue - .rettable - .dd .rbyte - .rettable; - .dd .rhalfword - .rettable; - .dd .rint64 - .rettable; - .dd .rint32 - .rettable; - -.rbyte: - P0 = [FP+24]; - R0 = R0.B (Z); - [P0] = R0; - JUMP .epilogue -.rhalfword: - P0 = [FP+24]; - R0 = R0.L; - [P0] = R0; - JUMP .epilogue -.rint64: - P0 = [FP+24];// &rvalue - [P0] = R0; - [P0+4] = R1; - JUMP .epilogue -.rint32: - P0 = [FP+24]; - [P0] = R0; -.epilogue: - R0 = [FP+8]; - R1 = [FP+12]; - R2 = [FP+16]; - P3 = [FP-20]; - UNLINK; - RTS; - -.size _ffi_call_SYSV,.-_ffi_call_SYSV; -.endfunc diff --git a/user/mpy/lib/libffi/src/closures.c b/user/mpy/lib/libffi/src/closures.c deleted file mode 100644 index 721ff00..0000000 --- a/user/mpy/lib/libffi/src/closures.c +++ /dev/null @@ -1,688 +0,0 @@ -/* ----------------------------------------------------------------------- - closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc. - Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc - Copyright (c) 2011 Plausible Labs Cooperative, Inc. - - Code to allocate and deallocate memory for closures. - - 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 defined __linux__ && !defined _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#include -#include - -#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE -# if __gnu_linux__ && !defined(__ANDROID__) -/* This macro indicates it may be forbidden to map anonymous memory - with both write and execute permission. Code compiled when this - option is defined will attempt to map such pages once, but if it - fails, it falls back to creating a temporary file in a writable and - executable filesystem and mapping pages from it into separate - locations in the virtual memory space, one location writable and - another executable. */ -# define FFI_MMAP_EXEC_WRIT 1 -# define HAVE_MNTENT 1 -# endif -# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__) -/* Windows systems may have Data Execution Protection (DEP) enabled, - which requires the use of VirtualMalloc/VirtualFree to alloc/free - executable memory. */ -# define FFI_MMAP_EXEC_WRIT 1 -# endif -#endif - -#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX -# ifdef __linux__ -/* When defined to 1 check for SELinux and if SELinux is active, - don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that - might cause audit messages. */ -# define FFI_MMAP_EXEC_SELINUX 1 -# endif -#endif - -#if FFI_CLOSURES - -# if FFI_EXEC_TRAMPOLINE_TABLE - -// Per-target implementation; It's unclear what can reasonable be shared between two OS/architecture implementations. - -# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */ - -#define USE_LOCKS 1 -#define USE_DL_PREFIX 1 -#ifdef __GNUC__ -#ifndef USE_BUILTIN_FFS -#define USE_BUILTIN_FFS 1 -#endif -#endif - -/* We need to use mmap, not sbrk. */ -#define HAVE_MORECORE 0 - -/* We could, in theory, support mremap, but it wouldn't buy us anything. */ -#define HAVE_MREMAP 0 - -/* We have no use for this, so save some code and data. */ -#define NO_MALLINFO 1 - -/* We need all allocations to be in regular segments, otherwise we - lose track of the corresponding code address. */ -#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T - -/* Don't allocate more than a page unless needed. */ -#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize) - -#if FFI_CLOSURE_TEST -/* Don't release single pages, to avoid a worst-case scenario of - continuously allocating and releasing single pages, but release - pairs of pages, which should do just as well given that allocations - are likely to be small. */ -#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize) -#endif - -#include -#include -#include -#include -#ifndef _MSC_VER -#include -#endif -#include -#include -#if !defined(X86_WIN32) && !defined(X86_WIN64) -#ifdef HAVE_MNTENT -#include -#endif /* HAVE_MNTENT */ -#include -#include - -/* We don't want sys/mman.h to be included after we redefine mmap and - dlmunmap. */ -#include -#define LACKS_SYS_MMAN_H 1 - -#if FFI_MMAP_EXEC_SELINUX -#include -#include - -static int selinux_enabled = -1; - -static int -selinux_enabled_check (void) -{ - struct statfs sfs; - FILE *f; - char *buf = NULL; - size_t len = 0; - - if (statfs ("/selinux", &sfs) >= 0 - && (unsigned int) sfs.f_type == 0xf97cff8cU) - return 1; - f = fopen ("/proc/mounts", "r"); - if (f == NULL) - return 0; - while (getline (&buf, &len, f) >= 0) - { - char *p = strchr (buf, ' '); - if (p == NULL) - break; - p = strchr (p + 1, ' '); - if (p == NULL) - break; - if (strncmp (p + 1, "selinuxfs ", 10) == 0) - { - free (buf); - fclose (f); - return 1; - } - } - free (buf); - fclose (f); - return 0; -} - -#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \ - : (selinux_enabled = selinux_enabled_check ())) - -#else - -#define is_selinux_enabled() 0 - -#endif /* !FFI_MMAP_EXEC_SELINUX */ - -/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */ -#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX -#include - -static int emutramp_enabled = -1; - -static int -emutramp_enabled_check (void) -{ - char *buf = NULL; - size_t len = 0; - FILE *f; - int ret; - f = fopen ("/proc/self/status", "r"); - if (f == NULL) - return 0; - ret = 0; - - while (getline (&buf, &len, f) != -1) - if (!strncmp (buf, "PaX:", 4)) - { - char emutramp; - if (sscanf (buf, "%*s %*c%c", &emutramp) == 1) - ret = (emutramp == 'E'); - break; - } - free (buf); - fclose (f); - return ret; -} - -#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ - : (emutramp_enabled = emutramp_enabled_check ())) -#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ - -#elif defined (__CYGWIN__) || defined(__INTERIX) - -#include - -/* Cygwin is Linux-like, but not quite that Linux-like. */ -#define is_selinux_enabled() 0 - -#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ - -#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX -#define is_emutramp_enabled() 0 -#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ - -/* Declare all functions defined in dlmalloc.c as static. */ -static void *dlmalloc(size_t); -static void dlfree(void*); -static void *dlcalloc(size_t, size_t) MAYBE_UNUSED; -static void *dlrealloc(void *, size_t) MAYBE_UNUSED; -static void *dlmemalign(size_t, size_t) MAYBE_UNUSED; -static void *dlvalloc(size_t) MAYBE_UNUSED; -static int dlmallopt(int, int) MAYBE_UNUSED; -static size_t dlmalloc_footprint(void) MAYBE_UNUSED; -static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED; -static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED; -static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED; -static void *dlpvalloc(size_t) MAYBE_UNUSED; -static int dlmalloc_trim(size_t) MAYBE_UNUSED; -static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; -static void dlmalloc_stats(void) MAYBE_UNUSED; - -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) -/* Use these for mmap and munmap within dlmalloc.c. */ -static void *dlmmap(void *, size_t, int, int, int, off_t); -static int dlmunmap(void *, size_t); -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ - -#define mmap dlmmap -#define munmap dlmunmap - -#include "dlmalloc.c" - -#undef mmap -#undef munmap - -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) - -/* A mutex used to synchronize access to *exec* variables in this file. */ -static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; - -/* A file descriptor of a temporary file from which we'll map - executable pages. */ -static int execfd = -1; - -/* The amount of space already allocated from the temporary file. */ -static size_t execsize = 0; - -/* Open a temporary file name, and immediately unlink it. */ -static int -open_temp_exec_file_name (char *name, int flags) -{ - int fd; - -#ifdef HAVE_MKOSTEMP - fd = mkostemp (name, flags); -#else - fd = mkstemp (name); -#endif - - if (fd != -1) - unlink (name); - - return fd; -} - -/* Open a temporary file in the named directory. */ -static int -open_temp_exec_file_dir (const char *dir) -{ - static const char suffix[] = "/ffiXXXXXX"; - int lendir, flags; - char *tempname; -#ifdef O_TMPFILE - int fd; -#endif - -#ifdef O_CLOEXEC - flags = O_CLOEXEC; -#else - flags = 0; -#endif - -#ifdef O_TMPFILE - fd = open (dir, flags | O_RDWR | O_EXCL | O_TMPFILE, 0700); - /* If the running system does not support the O_TMPFILE flag then retry without it. */ - if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP)) { - return fd; - } else { - errno = 0; - } -#endif - - lendir = strlen (dir); - tempname = __builtin_alloca (lendir + sizeof (suffix)); - - if (!tempname) - return -1; - - memcpy (tempname, dir, lendir); - memcpy (tempname + lendir, suffix, sizeof (suffix)); - - return open_temp_exec_file_name (tempname, flags); -} - -/* Open a temporary file in the directory in the named environment - variable. */ -static int -open_temp_exec_file_env (const char *envvar) -{ - const char *value = getenv (envvar); - - if (!value) - return -1; - - return open_temp_exec_file_dir (value); -} - -#ifdef HAVE_MNTENT -/* Open a temporary file in an executable and writable mount point - listed in the mounts file. Subsequent calls with the same mounts - keep searching for mount points in the same file. Providing NULL - as the mounts file closes the file. */ -static int -open_temp_exec_file_mnt (const char *mounts) -{ - static const char *last_mounts; - static FILE *last_mntent; - - if (mounts != last_mounts) - { - if (last_mntent) - endmntent (last_mntent); - - last_mounts = mounts; - - if (mounts) - last_mntent = setmntent (mounts, "r"); - else - last_mntent = NULL; - } - - if (!last_mntent) - return -1; - - for (;;) - { - int fd; - struct mntent mnt; - char buf[MAXPATHLEN * 3]; - - if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL) - return -1; - - if (hasmntopt (&mnt, "ro") - || hasmntopt (&mnt, "noexec") - || access (mnt.mnt_dir, W_OK)) - continue; - - fd = open_temp_exec_file_dir (mnt.mnt_dir); - - if (fd != -1) - return fd; - } -} -#endif /* HAVE_MNTENT */ - -/* Instructions to look for a location to hold a temporary file that - can be mapped in for execution. */ -static struct -{ - int (*func)(const char *); - const char *arg; - int repeat; -} open_temp_exec_file_opts[] = { - { open_temp_exec_file_env, "TMPDIR", 0 }, - { open_temp_exec_file_dir, "/tmp", 0 }, - { open_temp_exec_file_dir, "/var/tmp", 0 }, - { open_temp_exec_file_dir, "/dev/shm", 0 }, - { open_temp_exec_file_env, "HOME", 0 }, -#ifdef HAVE_MNTENT - { open_temp_exec_file_mnt, "/etc/mtab", 1 }, - { open_temp_exec_file_mnt, "/proc/mounts", 1 }, -#endif /* HAVE_MNTENT */ -}; - -/* Current index into open_temp_exec_file_opts. */ -static int open_temp_exec_file_opts_idx = 0; - -/* Reset a current multi-call func, then advances to the next entry. - If we're at the last, go back to the first and return nonzero, - otherwise return zero. */ -static int -open_temp_exec_file_opts_next (void) -{ - if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat) - open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL); - - open_temp_exec_file_opts_idx++; - if (open_temp_exec_file_opts_idx - == (sizeof (open_temp_exec_file_opts) - / sizeof (*open_temp_exec_file_opts))) - { - open_temp_exec_file_opts_idx = 0; - return 1; - } - - return 0; -} - -/* Return a file descriptor of a temporary zero-sized file in a - writable and executable filesystem. */ -static int -open_temp_exec_file (void) -{ - int fd; - - do - { - fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func - (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg); - - if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat - || fd == -1) - { - if (open_temp_exec_file_opts_next ()) - break; - } - } - while (fd == -1); - - return fd; -} - -/* Map in a chunk of memory from the temporary exec file into separate - locations in the virtual memory address space, one writable and one - executable. Returns the address of the writable portion, after - storing an offset to the corresponding executable portion at the - last word of the requested chunk. */ -static void * -dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset) -{ - void *ptr; - - if (execfd == -1) - { - open_temp_exec_file_opts_idx = 0; - retry_open: - execfd = open_temp_exec_file (); - if (execfd == -1) - return MFAIL; - } - - offset = execsize; - - if (ftruncate (execfd, offset + length)) - return MFAIL; - - flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS); - flags |= MAP_SHARED; - - ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC, - flags, execfd, offset); - if (ptr == MFAIL) - { - if (!offset) - { - close (execfd); - goto retry_open; - } - ftruncate (execfd, offset); - return MFAIL; - } - else if (!offset - && open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat) - open_temp_exec_file_opts_next (); - - start = mmap (start, length, prot, flags, execfd, offset); - - if (start == MFAIL) - { - munmap (ptr, length); - ftruncate (execfd, offset); - return start; - } - - mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start; - - execsize += length; - - return start; -} - -/* Map in a writable and executable chunk of memory if possible. - Failing that, fall back to dlmmap_locked. */ -static void * -dlmmap (void *start, size_t length, int prot, - int flags, int fd, off_t offset) -{ - void *ptr; - - assert (start == NULL && length % malloc_getpagesize == 0 - && prot == (PROT_READ | PROT_WRITE) - && flags == (MAP_PRIVATE | MAP_ANONYMOUS) - && fd == -1 && offset == 0); - -#if FFI_CLOSURE_TEST - printf ("mapping in %zi\n", length); -#endif - - if (execfd == -1 && is_emutramp_enabled ()) - { - ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset); - return ptr; - } - - if (execfd == -1 && !is_selinux_enabled ()) - { - ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset); - - if (ptr != MFAIL || (errno != EPERM && errno != EACCES)) - /* Cool, no need to mess with separate segments. */ - return ptr; - - /* If MREMAP_DUP is ever introduced and implemented, try mmap - with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with - MREMAP_DUP and prot at this point. */ - } - - if (execsize == 0 || execfd == -1) - { - pthread_mutex_lock (&open_temp_exec_file_mutex); - ptr = dlmmap_locked (start, length, prot, flags, offset); - pthread_mutex_unlock (&open_temp_exec_file_mutex); - - return ptr; - } - - return dlmmap_locked (start, length, prot, flags, offset); -} - -/* Release memory at the given address, as well as the corresponding - executable page if it's separate. */ -static int -dlmunmap (void *start, size_t length) -{ - /* We don't bother decreasing execsize or truncating the file, since - we can't quite tell whether we're unmapping the end of the file. - We don't expect frequent deallocation anyway. If we did, we - could locate pages in the file by writing to the pages being - deallocated and checking that the file contents change. - Yuck. */ - msegmentptr seg = segment_holding (gm, start); - void *code; - -#if FFI_CLOSURE_TEST - printf ("unmapping %zi\n", length); -#endif - - if (seg && (code = add_segment_exec_offset (start, seg)) != start) - { - int ret = munmap (code, length); - if (ret) - return ret; - } - - return munmap (start, length); -} - -#if FFI_CLOSURE_FREE_CODE -/* Return segment holding given code address. */ -static msegmentptr -segment_holding_code (mstate m, char* addr) -{ - msegmentptr sp = &m->seg; - for (;;) { - if (addr >= add_segment_exec_offset (sp->base, sp) - && addr < add_segment_exec_offset (sp->base, sp) + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; - } -} -#endif - -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ - -/* Allocate a chunk of memory with the given size. Returns a pointer - to the writable address, and sets *CODE to the executable - corresponding virtual address. */ -void * -ffi_closure_alloc (size_t size, void **code) -{ - void *ptr; - - if (!code) - return NULL; - - ptr = dlmalloc (size); - - if (ptr) - { - msegmentptr seg = segment_holding (gm, ptr); - - *code = add_segment_exec_offset (ptr, seg); - } - - return ptr; -} - -/* Release a chunk of memory allocated with ffi_closure_alloc. If - FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the - writable or the executable address given. Otherwise, only the - writable address can be provided here. */ -void -ffi_closure_free (void *ptr) -{ -#if FFI_CLOSURE_FREE_CODE - msegmentptr seg = segment_holding_code (gm, ptr); - - if (seg) - ptr = sub_segment_exec_offset (ptr, seg); -#endif - - dlfree (ptr); -} - - -#if FFI_CLOSURE_TEST -/* Do some internal sanity testing to make sure allocation and - deallocation of pages are working as intended. */ -int main () -{ - void *p[3]; -#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0) -#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0) - GET (0, malloc_getpagesize / 2); - GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*)); - PUT (1); - GET (1, 2 * malloc_getpagesize); - GET (2, malloc_getpagesize / 2); - PUT (1); - PUT (0); - PUT (2); - return 0; -} -#endif /* FFI_CLOSURE_TEST */ -# else /* ! FFI_MMAP_EXEC_WRIT */ - -/* On many systems, memory returned by malloc is writable and - executable, so just use it. */ - -#include - -void * -ffi_closure_alloc (size_t size, void **code) -{ - if (!code) - return NULL; - - return *code = malloc (size); -} - -void -ffi_closure_free (void *ptr) -{ - free (ptr); -} - -# endif /* ! FFI_MMAP_EXEC_WRIT */ -#endif /* FFI_CLOSURES */ diff --git a/user/mpy/lib/libffi/src/cris/ffi.c b/user/mpy/lib/libffi/src/cris/ffi.c deleted file mode 100644 index aaca5b1..0000000 --- a/user/mpy/lib/libffi/src/cris/ffi.c +++ /dev/null @@ -1,386 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 1998 Cygnus Solutions - Copyright (c) 2004 Simon Posnjak - Copyright (c) 2005 Axis Communications AB - Copyright (C) 2007 Free Software Foundation, Inc. - - CRIS Foreign Function Interface - - 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 SIMON POSNJAK 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG) - -static ffi_status -initialize_aggregate_packed_struct (ffi_type * arg) -{ - ffi_type **ptr; - - FFI_ASSERT (arg != NULL); - - FFI_ASSERT (arg->elements != NULL); - FFI_ASSERT (arg->size == 0); - FFI_ASSERT (arg->alignment == 0); - - ptr = &(arg->elements[0]); - - while ((*ptr) != NULL) - { - if (((*ptr)->size == 0) - && (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK)) - return FFI_BAD_TYPEDEF; - - FFI_ASSERT (ffi_type_test ((*ptr))); - - arg->size += (*ptr)->size; - - arg->alignment = (arg->alignment > (*ptr)->alignment) ? - arg->alignment : (*ptr)->alignment; - - ptr++; - } - - if (arg->size == 0) - return FFI_BAD_TYPEDEF; - else - return FFI_OK; -} - -int -ffi_prep_args (char *stack, extended_cif * ecif) -{ - unsigned int i; - unsigned int struct_count = 0; - void **p_argv; - char *argp; - ffi_type **p_arg; - - argp = stack; - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); i--, p_arg++) - { - size_t z; - - switch ((*p_arg)->type) - { - case FFI_TYPE_STRUCT: - { - z = (*p_arg)->size; - if (z <= 4) - { - memcpy (argp, *p_argv, z); - z = 4; - } - else if (z <= 8) - { - memcpy (argp, *p_argv, z); - z = 8; - } - else - { - unsigned int uiLocOnStack; - z = sizeof (void *); - uiLocOnStack = 4 * ecif->cif->nargs + struct_count; - struct_count = struct_count + (*p_arg)->size; - *(unsigned int *) argp = - (unsigned int) (UINT32 *) (stack + uiLocOnStack); - memcpy ((stack + uiLocOnStack), *p_argv, (*p_arg)->size); - } - break; - } - default: - z = (*p_arg)->size; - if (z < sizeof (int)) - { - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = - (unsigned int) *(UINT8 *) (*p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = - (unsigned int) *(UINT16 *) (*p_argv); - break; - - default: - FFI_ASSERT (0); - } - z = sizeof (int); - } - else if (z == sizeof (int)) - *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv); - else - memcpy (argp, *p_argv, z); - break; - } - p_argv++; - argp += z; - } - - return (struct_count); -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_core (ffi_cif * cif, - ffi_abi abi, unsigned int isvariadic, - unsigned int nfixedargs, unsigned int ntotalargs, - ffi_type * rtype, ffi_type ** atypes) -{ - unsigned bytes = 0; - unsigned int i; - ffi_type **ptr; - - FFI_ASSERT (cif != NULL); - FFI_ASSERT((!isvariadic) || (nfixedargs >= 1)); - FFI_ASSERT(nfixedargs <= ntotalargs); - FFI_ASSERT (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI); - - cif->abi = abi; - cif->arg_types = atypes; - cif->nargs = ntotalargs; - cif->rtype = rtype; - - cif->flags = 0; - - if ((cif->rtype->size == 0) - && (initialize_aggregate_packed_struct (cif->rtype) != FFI_OK)) - return FFI_BAD_TYPEDEF; - - FFI_ASSERT_VALID_TYPE (cif->rtype); - - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) - { - if (((*ptr)->size == 0) - && (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK)) - return FFI_BAD_TYPEDEF; - - FFI_ASSERT_VALID_TYPE (*ptr); - - if (((*ptr)->alignment - 1) & bytes) - bytes = ALIGN (bytes, (*ptr)->alignment); - if ((*ptr)->type == FFI_TYPE_STRUCT) - { - if ((*ptr)->size > 8) - { - bytes += (*ptr)->size; - bytes += sizeof (void *); - } - else - { - if ((*ptr)->size > 4) - bytes += 8; - else - bytes += 4; - } - } - else - bytes += STACK_ARG_SIZE ((*ptr)->size); - } - - cif->bytes = bytes; - - return ffi_prep_cif_machdep (cif); -} - -ffi_status -ffi_prep_cif_machdep (ffi_cif * cif) -{ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = (unsigned) cif->rtype->type; - break; - - default: - cif->flags = FFI_TYPE_INT; - break; - } - - return FFI_OK; -} - -extern void ffi_call_SYSV (int (*)(char *, extended_cif *), - extended_cif *, - unsigned, unsigned, unsigned *, void (*fn) ()) - __attribute__ ((__visibility__ ("hidden"))); - -void -ffi_call (ffi_cif * cif, void (*fn) (), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca (cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV (ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - break; - default: - FFI_ASSERT (0); - break; - } -} - -/* Because the following variables are not exported outside libffi, we - mark them hidden. */ - -/* Assembly code for the jump stub. */ -extern const char ffi_cris_trampoline_template[] - __attribute__ ((__visibility__ ("hidden"))); - -/* Offset into ffi_cris_trampoline_template of where to put the - ffi_prep_closure_inner function. */ -extern const int ffi_cris_trampoline_fn_offset - __attribute__ ((__visibility__ ("hidden"))); - -/* Offset into ffi_cris_trampoline_template of where to put the - closure data. */ -extern const int ffi_cris_trampoline_closure_offset - __attribute__ ((__visibility__ ("hidden"))); - -/* This function is sibling-called (jumped to) by the closure - trampoline. We get R10..R13 at PARAMS[0..3] and a copy of [SP] at - PARAMS[4] to simplify handling of a straddling parameter. A copy - of R9 is at PARAMS[5] and SP at PARAMS[6]. These parameters are - put at the appropriate place in CLOSURE which is then executed and - the return value is passed back to the caller. */ - -static unsigned long long -ffi_prep_closure_inner (void **params, ffi_closure* closure) -{ - char *register_args = (char *) params; - void *struct_ret = params[5]; - char *stack_args = params[6]; - char *ptr = register_args; - ffi_cif *cif = closure->cif; - ffi_type **arg_types = cif->arg_types; - - /* Max room needed is number of arguments as 64-bit values. */ - void **avalue = alloca (closure->cif->nargs * sizeof(void *)); - int i; - int doing_regs; - long long llret = 0; - - /* Find the address of each argument. */ - for (i = 0, doing_regs = 1; i < cif->nargs; i++) - { - /* Types up to and including 8 bytes go by-value. */ - if (arg_types[i]->size <= 4) - { - avalue[i] = ptr; - ptr += 4; - } - else if (arg_types[i]->size <= 8) - { - avalue[i] = ptr; - ptr += 8; - } - else - { - FFI_ASSERT (arg_types[i]->type == FFI_TYPE_STRUCT); - - /* Passed by-reference, so copy the pointer. */ - avalue[i] = *(void **) ptr; - ptr += 4; - } - - /* If we've handled more arguments than fit in registers, start - looking at the those passed on the stack. Step over the - first one if we had a straddling parameter. */ - if (doing_regs && ptr >= register_args + 4*4) - { - ptr = stack_args + ((ptr > register_args + 4*4) ? 4 : 0); - doing_regs = 0; - } - } - - /* Invoke the closure. */ - (closure->fun) (cif, - - cif->rtype->type == FFI_TYPE_STRUCT - /* The caller allocated space for the return - structure, and passed a pointer to this space in - R9. */ - ? struct_ret - - /* We take advantage of being able to ignore that - the high part isn't set if the return value is - not in R10:R11, but in R10 only. */ - : (void *) &llret, - - avalue, closure->user_data); - - return llret; -} - -/* API function: Prepare the trampoline. */ - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif *, void *, void **, void*), - void *user_data, - void *codeloc) -{ - void *innerfn = ffi_prep_closure_inner; - FFI_ASSERT (cif->abi == FFI_SYSV); - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - memcpy (closure->tramp, ffi_cris_trampoline_template, - FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE); - memcpy (closure->tramp + ffi_cris_trampoline_fn_offset, - &innerfn, sizeof (void *)); - memcpy (closure->tramp + ffi_cris_trampoline_closure_offset, - &codeloc, sizeof (void *)); - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/cris/ffitarget.h b/user/mpy/lib/libffi/src/cris/ffitarget.h deleted file mode 100644 index b837e97..0000000 --- a/user/mpy/lib/libffi/src/cris/ffitarget.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for CRIS. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE 36 -#define FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE (7*4) -#define FFI_TRAMPOLINE_SIZE \ - (FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE + FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE) -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/cris/sysv.S b/user/mpy/lib/libffi/src/cris/sysv.S deleted file mode 100644 index 79abaee..0000000 --- a/user/mpy/lib/libffi/src/cris/sysv.S +++ /dev/null @@ -1,215 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2004 Simon Posnjak - Copyright (c) 2005 Axis Communications AB - - CRIS Foreign Function Interface - - 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 SIMON POSNJAK 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#define CONCAT(x,y) x ## y -#define XCONCAT(x,y) CONCAT (x, y) -#define L(x) XCONCAT (__USER_LABEL_PREFIX__, x) - - .text - - ;; OK, when we get called we should have this (according to - ;; AXIS ETRAX 100LX Programmer's Manual chapter 6.3). - ;; - ;; R10: ffi_prep_args (func. pointer) - ;; R11: &ecif - ;; R12: cif->bytes - ;; R13: fig->flags - ;; sp+0: ecif.rvalue - ;; sp+4: fn (function pointer to the function that we need to call) - - .globl L(ffi_call_SYSV) - .type L(ffi_call_SYSV),@function - .hidden L(ffi_call_SYSV) - -L(ffi_call_SYSV): - ;; Save the regs to the stack. - push $srp - ;; Used for stack pointer saving. - push $r6 - ;; Used for function address pointer. - push $r7 - ;; Used for stack pointer saving. - push $r8 - ;; We save fig->flags to stack we will need them after we - ;; call The Function. - push $r13 - - ;; Saving current stack pointer. - move.d $sp,$r8 - move.d $sp,$r6 - - ;; Move address of ffi_prep_args to r13. - move.d $r10,$r13 - - ;; Make room on the stack for the args of fn. - sub.d $r12,$sp - - ;; Function void ffi_prep_args(char *stack, extended_cif *ecif) parameters are: - ;; r10 <-- stack pointer - ;; r11 <-- &ecif (already there) - move.d $sp,$r10 - - ;; Call the function. - jsr $r13 - - ;; Save the size of the structures which are passed on stack. - move.d $r10,$r7 - - ;; Move first four args in to r10..r13. - move.d [$sp+0],$r10 - move.d [$sp+4],$r11 - move.d [$sp+8],$r12 - move.d [$sp+12],$r13 - - ;; Adjust the stack and check if any parameters are given on stack. - addq 16,$sp - sub.d $r7,$r6 - cmp.d $sp,$r6 - - bpl go_on - nop - -go_on_no_params_on_stack: - move.d $r6,$sp - -go_on: - ;; Discover if we need to put rval address in to r9. - move.d [$r8+0],$r7 - cmpq FFI_TYPE_STRUCT,$r7 - bne call_now - nop - - ;; Move rval address to $r9. - move.d [$r8+20],$r9 - -call_now: - ;; Move address of The Function in to r7. - move.d [$r8+24],$r7 - - ;; Call The Function. - jsr $r7 - - ;; Reset stack. - move.d $r8,$sp - - ;; Load rval type (fig->flags) in to r13. - pop $r13 - - ;; Detect rval type. - cmpq FFI_TYPE_VOID,$r13 - beq epilogue - - cmpq FFI_TYPE_STRUCT,$r13 - beq epilogue - - cmpq FFI_TYPE_DOUBLE,$r13 - beq return_double_or_longlong - - cmpq FFI_TYPE_UINT64,$r13 - beq return_double_or_longlong - - cmpq FFI_TYPE_SINT64,$r13 - beq return_double_or_longlong - nop - - ;; Just return the 32 bit value. - ba return - nop - -return_double_or_longlong: - ;; Load half of the rval to r10 and the other half to r11. - move.d [$sp+16],$r13 - move.d $r10,[$r13] - addq 4,$r13 - move.d $r11,[$r13] - ba epilogue - nop - -return: - ;; Load the rval to r10. - move.d [$sp+16],$r13 - move.d $r10,[$r13] - -epilogue: - pop $r8 - pop $r7 - pop $r6 - Jump [$sp+] - - .size ffi_call_SYSV,.-ffi_call_SYSV - -/* Save R10..R13 into an array, somewhat like varargs. Copy the next - argument too, to simplify handling of any straddling parameter. - Save R9 and SP after those. Jump to function handling the rest. - Since this is a template, copied and the main function filled in by - the user. */ - - .globl L(ffi_cris_trampoline_template) - .type L(ffi_cris_trampoline_template),@function - .hidden L(ffi_cris_trampoline_template) - -L(ffi_cris_trampoline_template): -0: - /* The value we get for "PC" is right after the prefix instruction, - two bytes from the beginning, i.e. 0b+2. */ - move.d $r10,[$pc+2f-(0b+2)] - move.d $pc,$r10 -1: - addq 2f-1b+4,$r10 - move.d $r11,[$r10+] - move.d $r12,[$r10+] - move.d $r13,[$r10+] - move.d [$sp],$r11 - move.d $r11,[$r10+] - move.d $r9,[$r10+] - move.d $sp,[$r10+] - subq FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE,$r10 - move.d 0,$r11 -3: - jump 0 -2: - .size ffi_cris_trampoline_template,.-0b - -/* This macro create a constant usable as "extern const int \name" in - C from within libffi, when \name has no prefix decoration. */ - - .macro const name,value - .globl \name - .type \name,@object - .hidden \name -\name: - .dword \value - .size \name,4 - .endm - -/* Constants for offsets within the trampoline. We could do this with - just symbols, avoiding memory contents and memory accesses, but the - C usage code would look a bit stranger. */ - - const L(ffi_cris_trampoline_fn_offset),2b-4-0b - const L(ffi_cris_trampoline_closure_offset),3b-4-0b diff --git a/user/mpy/lib/libffi/src/debug.c b/user/mpy/lib/libffi/src/debug.c deleted file mode 100644 index f3172b1..0000000 --- a/user/mpy/lib/libffi/src/debug.c +++ /dev/null @@ -1,64 +0,0 @@ -/* ----------------------------------------------------------------------- - debug.c - Copyright (c) 1996 Red Hat, Inc. - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include - -/* General debugging routines */ - -void ffi_stop_here(void) -{ - /* This function is only useful for debugging purposes. - Place a breakpoint on ffi_stop_here to be notified of - significant events. */ -} - -/* This function should only be called via the FFI_ASSERT() macro */ - -void ffi_assert(char *expr, char *file, int line) -{ - fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line); - ffi_stop_here(); - abort(); -} - -/* Perform a sanity check on an ffi_type structure */ - -void ffi_type_test(ffi_type *a, char *file, int line) -{ - FFI_ASSERT_AT(a != NULL, file, line); - - FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line); - FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line); - FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line); - FFI_ASSERT_AT((a->type != FFI_TYPE_STRUCT && a->type != FFI_TYPE_COMPLEX) - || a->elements != NULL, file, line); - FFI_ASSERT_AT(a->type != FFI_TYPE_COMPLEX - || (a->elements != NULL - && a->elements[0] != NULL && a->elements[1] == NULL), - file, line); - -} diff --git a/user/mpy/lib/libffi/src/dlmalloc.c b/user/mpy/lib/libffi/src/dlmalloc.c deleted file mode 100644 index 7e4ea83..0000000 --- a/user/mpy/lib/libffi/src/dlmalloc.c +++ /dev/null @@ -1,5161 +0,0 @@ -/* - This is a version (aka dlmalloc) of malloc/free/realloc written by - Doug Lea and released to the public domain, as explained at - http://creativecommons.org/licenses/publicdomain. Send questions, - comments, complaints, performance data, etc to dl@cs.oswego.edu - -* Version 2.8.3 Thu Sep 22 11:16:15 2005 Doug Lea (dl at gee) - - Note: There may be an updated version of this malloc obtainable at - ftp://gee.cs.oswego.edu/pub/misc/malloc.c - Check before installing! - -* Quickstart - - This library is all in one file to simplify the most common usage: - ftp it, compile it (-O3), and link it into another program. All of - the compile-time options default to reasonable values for use on - most platforms. You might later want to step through various - compile-time and dynamic tuning options. - - For convenience, an include file for code using this malloc is at: - ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.3.h - You don't really need this .h file unless you call functions not - defined in your system include files. The .h file contains only the - excerpts from this file needed for using this malloc on ANSI C/C++ - systems, so long as you haven't changed compile-time options about - naming and tuning parameters. If you do, then you can create your - own malloc.h that does include all settings by cutting at the point - indicated below. Note that you may already by default be using a C - library containing a malloc that is based on some version of this - malloc (for example in linux). You might still want to use the one - in this file to customize settings or to avoid overheads associated - with library versions. - -* Vital statistics: - - Supported pointer/size_t representation: 4 or 8 bytes - size_t MUST be an unsigned type of the same width as - pointers. (If you are using an ancient system that declares - size_t as a signed type, or need it to be a different width - than pointers, you can use a previous release of this malloc - (e.g. 2.7.2) supporting these.) - - Alignment: 8 bytes (default) - This suffices for nearly all current machines and C compilers. - However, you can define MALLOC_ALIGNMENT to be wider than this - if necessary (up to 128bytes), at the expense of using more space. - - Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) - 8 or 16 bytes (if 8byte sizes) - Each malloced chunk has a hidden word of overhead holding size - and status information, and additional cross-check word - if FOOTERS is defined. - - Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) - 8-byte ptrs: 32 bytes (including overhead) - - Even a request for zero bytes (i.e., malloc(0)) returns a - pointer to something of the minimum allocatable size. - The maximum overhead wastage (i.e., number of extra bytes - allocated than were requested in malloc) is less than or equal - to the minimum size, except for requests >= mmap_threshold that - are serviced via mmap(), where the worst case wastage is about - 32 bytes plus the remainder from a system page (the minimal - mmap unit); typically 4096 or 8192 bytes. - - Security: static-safe; optionally more or less - The "security" of malloc refers to the ability of malicious - code to accentuate the effects of errors (for example, freeing - space that is not currently malloc'ed or overwriting past the - ends of chunks) in code that calls malloc. This malloc - guarantees not to modify any memory locations below the base of - heap, i.e., static variables, even in the presence of usage - errors. The routines additionally detect most improper frees - and reallocs. All this holds as long as the static bookkeeping - for malloc itself is not corrupted by some other means. This - is only one aspect of security -- these checks do not, and - cannot, detect all possible programming errors. - - If FOOTERS is defined nonzero, then each allocated chunk - carries an additional check word to verify that it was malloced - from its space. These check words are the same within each - execution of a program using malloc, but differ across - executions, so externally crafted fake chunks cannot be - freed. This improves security by rejecting frees/reallocs that - could corrupt heap memory, in addition to the checks preventing - writes to statics that are always on. This may further improve - security at the expense of time and space overhead. (Note that - FOOTERS may also be worth using with MSPACES.) - - By default detected errors cause the program to abort (calling - "abort()"). You can override this to instead proceed past - errors by defining PROCEED_ON_ERROR. In this case, a bad free - has no effect, and a malloc that encounters a bad address - caused by user overwrites will ignore the bad address by - dropping pointers and indices to all known memory. This may - be appropriate for programs that should continue if at all - possible in the face of programming errors, although they may - run out of memory because dropped memory is never reclaimed. - - If you don't like either of these options, you can define - CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything - else. And if if you are sure that your program using malloc has - no errors or vulnerabilities, you can define INSECURE to 1, - which might (or might not) provide a small performance improvement. - - Thread-safety: NOT thread-safe unless USE_LOCKS defined - When USE_LOCKS is defined, each public call to malloc, free, - etc is surrounded with either a pthread mutex or a win32 - spinlock (depending on WIN32). This is not especially fast, and - can be a major bottleneck. It is designed only to provide - minimal protection in concurrent environments, and to provide a - basis for extensions. If you are using malloc in a concurrent - program, consider instead using ptmalloc, which is derived from - a version of this malloc. (See http://www.malloc.de). - - System requirements: Any combination of MORECORE and/or MMAP/MUNMAP - This malloc can use unix sbrk or any emulation (invoked using - the CALL_MORECORE macro) and/or mmap/munmap or any emulation - (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system - memory. On most unix systems, it tends to work best if both - MORECORE and MMAP are enabled. On Win32, it uses emulations - based on VirtualAlloc. It also uses common C library functions - like memset. - - Compliance: I believe it is compliant with the Single Unix Specification - (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably - others as well. - -* Overview of algorithms - - This is not the fastest, most space-conserving, most portable, or - most tunable malloc ever written. However it is among the fastest - while also being among the most space-conserving, portable and - tunable. Consistent balance across these factors results in a good - general-purpose allocator for malloc-intensive programs. - - In most ways, this malloc is a best-fit allocator. Generally, it - chooses the best-fitting existing chunk for a request, with ties - broken in approximately least-recently-used order. (This strategy - normally maintains low fragmentation.) However, for requests less - than 256bytes, it deviates from best-fit when there is not an - exactly fitting available chunk by preferring to use space adjacent - to that used for the previous small request, as well as by breaking - ties in approximately most-recently-used order. (These enhance - locality of series of small allocations.) And for very large requests - (>= 256Kb by default), it relies on system memory mapping - facilities, if supported. (This helps avoid carrying around and - possibly fragmenting memory used only for large chunks.) - - All operations (except malloc_stats and mallinfo) have execution - times that are bounded by a constant factor of the number of bits in - a size_t, not counting any clearing in calloc or copying in realloc, - or actions surrounding MORECORE and MMAP that have times - proportional to the number of non-contiguous regions returned by - system allocation routines, which is often just 1. - - The implementation is not very modular and seriously overuses - macros. Perhaps someday all C compilers will do as good a job - inlining modular code as can now be done by brute-force expansion, - but now, enough of them seem not to. - - Some compilers issue a lot of warnings about code that is - dead/unreachable only on some platforms, and also about intentional - uses of negation on unsigned types. All known cases of each can be - ignored. - - For a longer but out of date high-level description, see - http://gee.cs.oswego.edu/dl/html/malloc.html - -* MSPACES - If MSPACES is defined, then in addition to malloc, free, etc., - this file also defines mspace_malloc, mspace_free, etc. These - are versions of malloc routines that take an "mspace" argument - obtained using create_mspace, to control all internal bookkeeping. - If ONLY_MSPACES is defined, only these versions are compiled. - So if you would like to use this allocator for only some allocations, - and your system malloc for others, you can compile with - ONLY_MSPACES and then do something like... - static mspace mymspace = create_mspace(0,0); // for example - #define mymalloc(bytes) mspace_malloc(mymspace, bytes) - - (Note: If you only need one instance of an mspace, you can instead - use "USE_DL_PREFIX" to relabel the global malloc.) - - You can similarly create thread-local allocators by storing - mspaces as thread-locals. For example: - static __thread mspace tlms = 0; - void* tlmalloc(size_t bytes) { - if (tlms == 0) tlms = create_mspace(0, 0); - return mspace_malloc(tlms, bytes); - } - void tlfree(void* mem) { mspace_free(tlms, mem); } - - Unless FOOTERS is defined, each mspace is completely independent. - You cannot allocate from one and free to another (although - conformance is only weakly checked, so usage errors are not always - caught). If FOOTERS is defined, then each chunk carries around a tag - indicating its originating mspace, and frees are directed to their - originating spaces. - - ------------------------- Compile-time options --------------------------- - -Be careful in setting #define values for numerical constants of type -size_t. On some systems, literal values are not automatically extended -to size_t precision unless they are explicitly casted. - -WIN32 default: defined if _WIN32 defined - Defining WIN32 sets up defaults for MS environment and compilers. - Otherwise defaults are for unix. - -MALLOC_ALIGNMENT default: (size_t)8 - Controls the minimum alignment for malloc'ed chunks. It must be a - power of two and at least 8, even on machines for which smaller - alignments would suffice. It may be defined as larger than this - though. Note however that code and data structures are optimized for - the case of 8-byte alignment. - -MSPACES default: 0 (false) - If true, compile in support for independent allocation spaces. - This is only supported if HAVE_MMAP is true. - -ONLY_MSPACES default: 0 (false) - If true, only compile in mspace versions, not regular versions. - -USE_LOCKS default: 0 (false) - Causes each call to each public routine to be surrounded with - pthread or WIN32 mutex lock/unlock. (If set true, this can be - overridden on a per-mspace basis for mspace versions.) - -FOOTERS default: 0 - If true, provide extra checking and dispatching by placing - information in the footers of allocated chunks. This adds - space and time overhead. - -INSECURE default: 0 - If true, omit checks for usage errors and heap space overwrites. - -USE_DL_PREFIX default: NOT defined - Causes compiler to prefix all public routines with the string 'dl'. - This can be useful when you only want to use this malloc in one part - of a program, using your regular system malloc elsewhere. - -ABORT default: defined as abort() - Defines how to abort on failed checks. On most systems, a failed - check cannot die with an "assert" or even print an informative - message, because the underlying print routines in turn call malloc, - which will fail again. Generally, the best policy is to simply call - abort(). It's not very useful to do more than this because many - errors due to overwriting will show up as address faults (null, odd - addresses etc) rather than malloc-triggered checks, so will also - abort. Also, most compilers know that abort() does not return, so - can better optimize code conditionally calling it. - -PROCEED_ON_ERROR default: defined as 0 (false) - Controls whether detected bad addresses cause them to bypassed - rather than aborting. If set, detected bad arguments to free and - realloc are ignored. And all bookkeeping information is zeroed out - upon a detected overwrite of freed heap space, thus losing the - ability to ever return it from malloc again, but enabling the - application to proceed. If PROCEED_ON_ERROR is defined, the - static variable malloc_corruption_error_count is compiled in - and can be examined to see if errors have occurred. This option - generates slower code than the default abort policy. - -DEBUG default: NOT defined - The DEBUG setting is mainly intended for people trying to modify - this code or diagnose problems when porting to new platforms. - However, it may also be able to better isolate user errors than just - using runtime checks. The assertions in the check routines spell - out in more detail the assumptions and invariants underlying the - algorithms. The checking is fairly extensive, and will slow down - execution noticeably. Calling malloc_stats or mallinfo with DEBUG - set will attempt to check every non-mmapped allocated and free chunk - in the course of computing the summaries. - -ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) - Debugging assertion failures can be nearly impossible if your - version of the assert macro causes malloc to be called, which will - lead to a cascade of further failures, blowing the runtime stack. - ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), - which will usually make debugging easier. - -MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 - The action to take before "return 0" when malloc fails to be able to - return memory because there is none available. - -HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES - True if this system supports sbrk or an emulation of it. - -MORECORE default: sbrk - The name of the sbrk-style system routine to call to obtain more - memory. See below for guidance on writing custom MORECORE - functions. The type of the argument to sbrk/MORECORE varies across - systems. It cannot be size_t, because it supports negative - arguments, so it is normally the signed type of the same width as - size_t (sometimes declared as "intptr_t"). It doesn't much matter - though. Internally, we only call it with arguments less than half - the max value of a size_t, which should work across all reasonable - possibilities, although sometimes generating compiler warnings. See - near the end of this file for guidelines for creating a custom - version of MORECORE. - -MORECORE_CONTIGUOUS default: 1 (true) - If true, take advantage of fact that consecutive calls to MORECORE - with positive arguments always return contiguous increasing - addresses. This is true of unix sbrk. It does not hurt too much to - set it true anyway, since malloc copes with non-contiguities. - Setting it false when definitely non-contiguous saves time - and possibly wasted space it would take to discover this though. - -MORECORE_CANNOT_TRIM default: NOT defined - True if MORECORE cannot release space back to the system when given - negative arguments. This is generally necessary only if you are - using a hand-crafted MORECORE function that cannot handle negative - arguments. - -HAVE_MMAP default: 1 (true) - True if this system supports mmap or an emulation of it. If so, and - HAVE_MORECORE is not true, MMAP is used for all system - allocation. If set and HAVE_MORECORE is true as well, MMAP is - primarily used to directly allocate very large blocks. It is also - used as a backup strategy in cases where MORECORE fails to provide - space from system. Note: A single call to MUNMAP is assumed to be - able to unmap memory that may have be allocated using multiple calls - to MMAP, so long as they are adjacent. - -HAVE_MREMAP default: 1 on linux, else 0 - If true realloc() uses mremap() to re-allocate large blocks and - extend or shrink allocation spaces. - -MMAP_CLEARS default: 1 on unix - True if mmap clears memory so calloc doesn't need to. This is true - for standard unix mmap using /dev/zero. - -USE_BUILTIN_FFS default: 0 (i.e., not used) - Causes malloc to use the builtin ffs() function to compute indices. - Some compilers may recognize and intrinsify ffs to be faster than the - supplied C version. Also, the case of x86 using gcc is special-cased - to an asm instruction, so is already as fast as it can be, and so - this setting has no effect. (On most x86s, the asm version is only - slightly faster than the C version.) - -malloc_getpagesize default: derive from system includes, or 4096. - The system page size. To the extent possible, this malloc manages - memory from the system in page-size units. This may be (and - usually is) a function rather than a constant. This is ignored - if WIN32, where page size is determined using getSystemInfo during - initialization. - -USE_DEV_RANDOM default: 0 (i.e., not used) - Causes malloc to use /dev/random to initialize secure magic seed for - stamping footers. Otherwise, the current time is used. - -NO_MALLINFO default: 0 - If defined, don't compile "mallinfo". This can be a simple way - of dealing with mismatches between system declarations and - those in this file. - -MALLINFO_FIELD_TYPE default: size_t - The type of the fields in the mallinfo struct. This was originally - defined as "int" in SVID etc, but is more usefully defined as - size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set - -REALLOC_ZERO_BYTES_FREES default: not defined - This should be set if a call to realloc with zero bytes should - be the same as a call to free. Some people think it should. Otherwise, - since this malloc returns a unique pointer for malloc(0), so does - realloc(p, 0). - -LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H -LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H -LACKS_STDLIB_H default: NOT defined unless on WIN32 - Define these if your system does not have these header files. - You might need to manually insert some of the declarations they provide. - -DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, - system_info.dwAllocationGranularity in WIN32, - otherwise 64K. - Also settable using mallopt(M_GRANULARITY, x) - The unit for allocating and deallocating memory from the system. On - most systems with contiguous MORECORE, there is no reason to - make this more than a page. However, systems with MMAP tend to - either require or encourage larger granularities. You can increase - this value to prevent system allocation functions to be called so - often, especially if they are slow. The value must be at least one - page and must be a power of two. Setting to 0 causes initialization - to either page size or win32 region size. (Note: In previous - versions of malloc, the equivalent of this option was called - "TOP_PAD") - -DEFAULT_TRIM_THRESHOLD default: 2MB - Also settable using mallopt(M_TRIM_THRESHOLD, x) - The maximum amount of unused top-most memory to keep before - releasing via malloc_trim in free(). Automatic trimming is mainly - useful in long-lived programs using contiguous MORECORE. Because - trimming via sbrk can be slow on some systems, and can sometimes be - wasteful (in cases where programs immediately afterward allocate - more large chunks) the value should be high enough so that your - overall system performance would improve by releasing this much - memory. As a rough guide, you might set to a value close to the - average size of a process (program) running on your system. - Releasing this much memory would allow such a process to run in - memory. Generally, it is worth tuning trim thresholds when a - program undergoes phases where several large chunks are allocated - and released in ways that can reuse each other's storage, perhaps - mixed with phases where there are no such chunks at all. The trim - value must be greater than page size to have any useful effect. To - disable trimming completely, you can set to MAX_SIZE_T. Note that the trick - some people use of mallocing a huge space and then freeing it at - program startup, in an attempt to reserve system memory, doesn't - have the intended effect under automatic trimming, since that memory - will immediately be returned to the system. - -DEFAULT_MMAP_THRESHOLD default: 256K - Also settable using mallopt(M_MMAP_THRESHOLD, x) - The request size threshold for using MMAP to directly service a - request. Requests of at least this size that cannot be allocated - using already-existing space will be serviced via mmap. (If enough - normal freed space already exists it is used instead.) Using mmap - segregates relatively large chunks of memory so that they can be - individually obtained and released from the host system. A request - serviced through mmap is never reused by any other request (at least - not directly; the system may just so happen to remap successive - requests to the same locations). Segregating space in this way has - the benefits that: Mmapped space can always be individually released - back to the system, which helps keep the system level memory demands - of a long-lived program low. Also, mapped memory doesn't become - `locked' between other chunks, as can happen with normally allocated - chunks, which means that even trimming via malloc_trim would not - release them. However, it has the disadvantage that the space - cannot be reclaimed, consolidated, and then used to service later - requests, as happens with normal chunks. The advantages of mmap - nearly always outweigh disadvantages for "large" chunks, but the - value of "large" may vary across systems. The default is an - empirically derived value that works well in most systems. You can - disable mmap by setting to MAX_SIZE_T. - -*/ - -#ifndef WIN32 -#ifdef _WIN32 -#define WIN32 1 -#endif /* _WIN32 */ -#endif /* WIN32 */ -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_UNISTD_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H -#define LACKS_STRING_H -#define LACKS_STRINGS_H -#define LACKS_SYS_TYPES_H -#define LACKS_ERRNO_H -#define MALLOC_FAILURE_ACTION -#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */ -#endif /* WIN32 */ - -#ifdef __OS2__ -#define INCL_DOS -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_SYS_MMAN_H -#endif /* __OS2__ */ - -#if defined(DARWIN) || defined(_DARWIN) -/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ -#ifndef HAVE_MORECORE -#define HAVE_MORECORE 0 -#define HAVE_MMAP 1 -#endif /* HAVE_MORECORE */ -#endif /* DARWIN */ - -#ifndef LACKS_SYS_TYPES_H -#include /* For size_t */ -#endif /* LACKS_SYS_TYPES_H */ - -/* The maximum possible size_t value has all bits set */ -#define MAX_SIZE_T (~(size_t)0) - -#ifndef ONLY_MSPACES -#define ONLY_MSPACES 0 -#endif /* ONLY_MSPACES */ -#ifndef MSPACES -#if ONLY_MSPACES -#define MSPACES 1 -#else /* ONLY_MSPACES */ -#define MSPACES 0 -#endif /* ONLY_MSPACES */ -#endif /* MSPACES */ -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT ((size_t)8U) -#endif /* MALLOC_ALIGNMENT */ -#ifndef FOOTERS -#define FOOTERS 0 -#endif /* FOOTERS */ -#ifndef ABORT -#define ABORT abort() -#endif /* ABORT */ -#ifndef ABORT_ON_ASSERT_FAILURE -#define ABORT_ON_ASSERT_FAILURE 1 -#endif /* ABORT_ON_ASSERT_FAILURE */ -#ifndef PROCEED_ON_ERROR -#define PROCEED_ON_ERROR 0 -#endif /* PROCEED_ON_ERROR */ -#ifndef USE_LOCKS -#define USE_LOCKS 0 -#endif /* USE_LOCKS */ -#ifndef INSECURE -#define INSECURE 0 -#endif /* INSECURE */ -#ifndef HAVE_MMAP -#define HAVE_MMAP 1 -#endif /* HAVE_MMAP */ -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 1 -#endif /* MMAP_CLEARS */ -#ifndef HAVE_MREMAP -#ifdef linux -#define HAVE_MREMAP 1 -#else /* linux */ -#define HAVE_MREMAP 0 -#endif /* linux */ -#endif /* HAVE_MREMAP */ -#ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION errno = ENOMEM; -#endif /* MALLOC_FAILURE_ACTION */ -#ifndef HAVE_MORECORE -#if ONLY_MSPACES -#define HAVE_MORECORE 0 -#else /* ONLY_MSPACES */ -#define HAVE_MORECORE 1 -#endif /* ONLY_MSPACES */ -#endif /* HAVE_MORECORE */ -#if !HAVE_MORECORE -#define MORECORE_CONTIGUOUS 0 -#else /* !HAVE_MORECORE */ -#ifndef MORECORE -#define MORECORE sbrk -#endif /* MORECORE */ -#ifndef MORECORE_CONTIGUOUS -#define MORECORE_CONTIGUOUS 1 -#endif /* MORECORE_CONTIGUOUS */ -#endif /* HAVE_MORECORE */ -#ifndef DEFAULT_GRANULARITY -#if MORECORE_CONTIGUOUS -#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ -#else /* MORECORE_CONTIGUOUS */ -#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) -#endif /* MORECORE_CONTIGUOUS */ -#endif /* DEFAULT_GRANULARITY */ -#ifndef DEFAULT_TRIM_THRESHOLD -#ifndef MORECORE_CANNOT_TRIM -#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) -#else /* MORECORE_CANNOT_TRIM */ -#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T -#endif /* MORECORE_CANNOT_TRIM */ -#endif /* DEFAULT_TRIM_THRESHOLD */ -#ifndef DEFAULT_MMAP_THRESHOLD -#if HAVE_MMAP -#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) -#else /* HAVE_MMAP */ -#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* DEFAULT_MMAP_THRESHOLD */ -#ifndef USE_BUILTIN_FFS -#define USE_BUILTIN_FFS 0 -#endif /* USE_BUILTIN_FFS */ -#ifndef USE_DEV_RANDOM -#define USE_DEV_RANDOM 0 -#endif /* USE_DEV_RANDOM */ -#ifndef NO_MALLINFO -#define NO_MALLINFO 0 -#endif /* NO_MALLINFO */ -#ifndef MALLINFO_FIELD_TYPE -#define MALLINFO_FIELD_TYPE size_t -#endif /* MALLINFO_FIELD_TYPE */ - -/* - mallopt tuning options. SVID/XPG defines four standard parameter - numbers for mallopt, normally defined in malloc.h. None of these - are used in this malloc, so setting them has no effect. But this - malloc does support the following options. -*/ - -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) - -/* ------------------------ Mallinfo declarations ------------------------ */ - -#if !NO_MALLINFO -/* - This version of malloc supports the standard SVID/XPG mallinfo - routine that returns a struct containing usage properties and - statistics. It should work on any system that has a - /usr/include/malloc.h defining struct mallinfo. The main - declaration needed is the mallinfo struct that is returned (by-copy) - by mallinfo(). The malloinfo struct contains a bunch of fields that - are not even meaningful in this version of malloc. These fields are - are instead filled by mallinfo() with other numbers that might be of - interest. - - HAVE_USR_INCLUDE_MALLOC_H should be set if you have a - /usr/include/malloc.h file that includes a declaration of struct - mallinfo. If so, it is included; else a compliant version is - declared below. These must be precisely the same for mallinfo() to - work. The original SVID version of this struct, defined on most - systems with mallinfo, declares all fields as ints. But some others - define as unsigned long. If your system defines the fields using a - type of different width than listed here, you MUST #include your - system version and #define HAVE_USR_INCLUDE_MALLOC_H. -*/ - -/* #define HAVE_USR_INCLUDE_MALLOC_H */ - -#ifdef HAVE_USR_INCLUDE_MALLOC_H -#include "/usr/include/malloc.h" -#else /* HAVE_USR_INCLUDE_MALLOC_H */ - -/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */ -#define _STRUCT_MALLINFO - -struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ -}; - -#endif /* HAVE_USR_INCLUDE_MALLOC_H */ -#endif /* NO_MALLINFO */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if !ONLY_MSPACES - -/* ------------------- Declarations of public routines ------------------- */ - -#ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlrealloc realloc -#define dlvalloc valloc -#define dlpvalloc pvalloc -#define dlmallinfo mallinfo -#define dlmallopt mallopt -#define dlmalloc_trim malloc_trim -#define dlmalloc_stats malloc_stats -#define dlmalloc_usable_size malloc_usable_size -#define dlmalloc_footprint malloc_footprint -#define dlmalloc_max_footprint malloc_max_footprint -#define dlindependent_calloc independent_calloc -#define dlindependent_comalloc independent_comalloc -#endif /* USE_DL_PREFIX */ - - -/* - malloc(size_t n) - Returns a pointer to a newly allocated chunk of at least n bytes, or - null if no space is available, in which case errno is set to ENOMEM - on ANSI C systems. - - If n is zero, malloc returns a minimum-sized chunk. (The minimum - size is 16 bytes on most 32bit systems, and 32 bytes on 64bit - systems.) Note that size_t is an unsigned type, so calls with - arguments that would be negative if signed are interpreted as - requests for huge amounts of space, which will often fail. The - maximum supported value of n differs across systems, but is in all - cases less than the maximum representable value of a size_t. -*/ -void* dlmalloc(size_t); - -/* - free(void* p) - Releases the chunk of memory pointed to by p, that had been previously - allocated using malloc or a related routine such as realloc. - It has no effect if p is null. If p was not malloced or already - freed, free(p) will by default cause the current program to abort. -*/ -void dlfree(void*); - -/* - calloc(size_t n_elements, size_t element_size); - Returns a pointer to n_elements * element_size bytes, with all locations - set to zero. -*/ -void* dlcalloc(size_t, size_t); - -/* - realloc(void* p, size_t n) - Returns a pointer to a chunk of size n that contains the same data - as does chunk p up to the minimum of (n, p's size) bytes, or null - if no space is available. - - The returned pointer may or may not be the same as p. The algorithm - prefers extending p in most cases when possible, otherwise it - employs the equivalent of a malloc-copy-free sequence. - - If p is null, realloc is equivalent to malloc. - - If space is not available, realloc returns null, errno is set (if on - ANSI) and p is NOT freed. - - if n is for fewer bytes than already held by p, the newly unused - space is lopped off and freed if possible. realloc with a size - argument of zero (re)allocates a minimum-sized chunk. - - The old unix realloc convention of allowing the last-free'd chunk - to be used as an argument to realloc is not supported. -*/ - -void* dlrealloc(void*, size_t); - -/* - memalign(size_t alignment, size_t n); - Returns a pointer to a newly allocated chunk of n bytes, aligned - in accord with the alignment argument. - - The alignment argument should be a power of two. If the argument is - not a power of two, the nearest greater power is used. - 8-byte alignment is guaranteed by normal malloc calls, so don't - bother calling memalign with an argument of 8 or less. - - Overreliance on memalign is a sure way to fragment space. -*/ -void* dlmemalign(size_t, size_t); - -/* - valloc(size_t n); - Equivalent to memalign(pagesize, n), where pagesize is the page - size of the system. If the pagesize is unknown, 4096 is used. -*/ -void* dlvalloc(size_t); - -/* - mallopt(int parameter_number, int parameter_value) - Sets tunable parameters The format is to provide a - (parameter-number, parameter-value) pair. mallopt then sets the - corresponding parameter to the argument value if it can (i.e., so - long as the value is meaningful), and returns 1 if successful else - 0. SVID/XPG/ANSI defines four standard param numbers for mallopt, - normally defined in malloc.h. None of these are use in this malloc, - so setting them has no effect. But this malloc also supports other - options in mallopt. See below for details. Briefly, supported - parameters are as follows (listed defaults are for "typical" - configurations). - - Symbol param # default allowed param values - M_TRIM_THRESHOLD -1 2*1024*1024 any (MAX_SIZE_T disables) - M_GRANULARITY -2 page size any power of 2 >= page size - M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) -*/ -int dlmallopt(int, int); - -/* - malloc_footprint(); - Returns the number of bytes obtained from the system. The total - number of bytes allocated by malloc, realloc etc., is less than this - value. Unlike mallinfo, this function returns only a precomputed - result, so can be called frequently to monitor memory consumption. - Even if locks are otherwise defined, this function does not use them, - so results might not be up to date. -*/ -size_t dlmalloc_footprint(void); - -/* - malloc_max_footprint(); - Returns the maximum number of bytes obtained from the system. This - value will be greater than current footprint if deallocated space - has been reclaimed by the system. The peak number of bytes allocated - by malloc, realloc etc., is less than this value. Unlike mallinfo, - this function returns only a precomputed result, so can be called - frequently to monitor memory consumption. Even if locks are - otherwise defined, this function does not use them, so results might - not be up to date. -*/ -size_t dlmalloc_max_footprint(void); - -#if !NO_MALLINFO -/* - mallinfo() - Returns (by copy) a struct containing various summary statistics: - - arena: current total non-mmapped bytes allocated from system - ordblks: the number of free chunks - smblks: always zero. - hblks: current number of mmapped regions - hblkhd: total bytes held in mmapped regions - usmblks: the maximum total allocated space. This will be greater - than current total if trimming has occurred. - fsmblks: always zero - uordblks: current total allocated space (normal or mmapped) - fordblks: total free space - keepcost: the maximum number of bytes that could ideally be released - back to system via malloc_trim. ("ideally" means that - it ignores page restrictions etc.) - - Because these fields are ints, but internal bookkeeping may - be kept as longs, the reported values may wrap around zero and - thus be inaccurate. -*/ -struct mallinfo dlmallinfo(void); -#endif /* NO_MALLINFO */ - -/* - independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); - - independent_calloc is similar to calloc, but instead of returning a - single cleared space, it returns an array of pointers to n_elements - independent elements that can hold contents of size elem_size, each - of which starts out cleared, and can be independently freed, - realloc'ed etc. The elements are guaranteed to be adjacently - allocated (this is not guaranteed to occur with multiple callocs or - mallocs), which may also improve cache locality in some - applications. - - The "chunks" argument is optional (i.e., may be null, which is - probably the most typical usage). If it is null, the returned array - is itself dynamically allocated and should also be freed when it is - no longer needed. Otherwise, the chunks array must be of at least - n_elements in length. It is filled in with the pointers to the - chunks. - - In either case, independent_calloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and "chunks" - is null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use regular calloc and assign pointers into this - space to represent elements. (In this case though, you cannot - independently free elements.) - - independent_calloc simplifies and speeds up implementations of many - kinds of pools. It may also be useful when constructing large data - structures that initially have a fixed number of fixed-sized nodes, - but the number is not known at compile time, and some of the nodes - may later need to be freed. For example: - - struct Node { int item; struct Node* next; }; - - struct Node* build_list() { - struct Node** pool; - int n = read_number_of_nodes_needed(); - if (n <= 0) return 0; - pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); - if (pool == 0) die(); - // organize into a linked list... - struct Node* first = pool[0]; - for (i = 0; i < n-1; ++i) - pool[i]->next = pool[i+1]; - free(pool); // Can now free the array (or not, if it is needed later) - return first; - } -*/ -void** dlindependent_calloc(size_t, size_t, void**); - -/* - independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); - - independent_comalloc allocates, all at once, a set of n_elements - chunks with sizes indicated in the "sizes" array. It returns - an array of pointers to these elements, each of which can be - independently freed, realloc'ed etc. The elements are guaranteed to - be adjacently allocated (this is not guaranteed to occur with - multiple callocs or mallocs), which may also improve cache locality - in some applications. - - The "chunks" argument is optional (i.e., may be null). If it is null - the returned array is itself dynamically allocated and should also - be freed when it is no longer needed. Otherwise, the chunks array - must be of at least n_elements in length. It is filled in with the - pointers to the chunks. - - In either case, independent_comalloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and chunks is - null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use a single regular malloc, and assign pointers at - particular offsets in the aggregate space. (In this case though, you - cannot independently free elements.) - - independent_comallac differs from independent_calloc in that each - element may have a different size, and also that it does not - automatically clear elements. - - independent_comalloc can be used to speed up allocation in cases - where several structs or objects must always be allocated at the - same time. For example: - - struct Head { ... } - struct Foot { ... } - - void send_message(char* msg) { - int msglen = strlen(msg); - size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; - void* chunks[3]; - if (independent_comalloc(3, sizes, chunks) == 0) - die(); - struct Head* head = (struct Head*)(chunks[0]); - char* body = (char*)(chunks[1]); - struct Foot* foot = (struct Foot*)(chunks[2]); - // ... - } - - In general though, independent_comalloc is worth using only for - larger values of n_elements. For small values, you probably won't - detect enough difference from series of malloc calls to bother. - - Overuse of independent_comalloc can increase overall memory usage, - since it cannot reuse existing noncontiguous small chunks that - might be available for some of the elements. -*/ -void** dlindependent_comalloc(size_t, size_t*, void**); - - -/* - pvalloc(size_t n); - Equivalent to valloc(minimum-page-that-holds(n)), that is, - round up n to nearest pagesize. - */ -void* dlpvalloc(size_t); - -/* - malloc_trim(size_t pad); - - If possible, gives memory back to the system (via negative arguments - to sbrk) if there is unused memory at the `high' end of the malloc - pool or in unused MMAP segments. You can call this after freeing - large blocks of memory to potentially reduce the system-level memory - requirements of a program. However, it cannot guarantee to reduce - memory. Under some allocation patterns, some large free blocks of - memory will be locked between two used chunks, so they cannot be - given back to the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, only - the minimum amount of memory to maintain internal data structures - will be left. Non-zero arguments can be supplied to maintain enough - trailing space to service future expected allocations without having - to re-obtain memory from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. -*/ -int dlmalloc_trim(size_t); - -/* - malloc_usable_size(void* p); - - Returns the number of bytes you can actually use in - an allocated chunk, which may be more than you requested (although - often not) due to alignment and minimum size constraints. - You can use this many bytes without worrying about - overwriting other allocated objects. This is not a particularly great - programming practice. malloc_usable_size can be more useful in - debugging and assertions, for example: - - p = malloc(n); - assert(malloc_usable_size(p) >= 256); -*/ -size_t dlmalloc_usable_size(void*); - -/* - malloc_stats(); - Prints on stderr the amount of space obtained from the system (both - via sbrk and mmap), the maximum amount (which may be more than - current if malloc_trim and/or munmap got called), and the current - number of bytes allocated via malloc (or realloc, etc) but not yet - freed. Note that this is the number of bytes allocated, not the - number requested. It will be larger than the number requested - because of alignment and bookkeeping overhead. Because it includes - alignment wastage as being in use, this figure may be greater than - zero even when no user-level chunks are allocated. - - The reported current and maximum system memory can be inaccurate if - a program makes other calls to system memory allocation functions - (normally sbrk) outside of malloc. - - malloc_stats prints only the most commonly interesting statistics. - More information can be obtained by calling mallinfo. -*/ -void dlmalloc_stats(void); - -#endif /* ONLY_MSPACES */ - -#if MSPACES - -/* - mspace is an opaque type representing an independent - region of space that supports mspace_malloc, etc. -*/ -typedef void* mspace; - -/* - create_mspace creates and returns a new independent space with the - given initial capacity, or, if 0, the default granularity size. It - returns null if there is no system memory available to create the - space. If argument locked is non-zero, the space uses a separate - lock to control access. The capacity of the space will grow - dynamically as needed to service mspace_malloc requests. You can - control the sizes of incremental increases of this space by - compiling with a different DEFAULT_GRANULARITY or dynamically - setting with mallopt(M_GRANULARITY, value). -*/ -mspace create_mspace(size_t capacity, int locked); - -/* - destroy_mspace destroys the given space, and attempts to return all - of its memory back to the system, returning the total number of - bytes freed. After destruction, the results of access to all memory - used by the space become undefined. -*/ -size_t destroy_mspace(mspace msp); - -/* - create_mspace_with_base uses the memory supplied as the initial base - of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this - space is used for bookkeeping, so the capacity must be at least this - large. (Otherwise 0 is returned.) When this initial space is - exhausted, additional memory will be obtained from the system. - Destroying this space will deallocate all additionally allocated - space (if possible) but not the initial base. -*/ -mspace create_mspace_with_base(void* base, size_t capacity, int locked); - -/* - mspace_malloc behaves as malloc, but operates within - the given space. -*/ -void* mspace_malloc(mspace msp, size_t bytes); - -/* - mspace_free behaves as free, but operates within - the given space. - - If compiled with FOOTERS==1, mspace_free is not actually needed. - free may be called instead of mspace_free because freed chunks from - any space are handled by their originating spaces. -*/ -void mspace_free(mspace msp, void* mem); - -/* - mspace_realloc behaves as realloc, but operates within - the given space. - - If compiled with FOOTERS==1, mspace_realloc is not actually - needed. realloc may be called instead of mspace_realloc because - realloced chunks from any space are handled by their originating - spaces. -*/ -void* mspace_realloc(mspace msp, void* mem, size_t newsize); - -/* - mspace_calloc behaves as calloc, but operates within - the given space. -*/ -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); - -/* - mspace_memalign behaves as memalign, but operates within - the given space. -*/ -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); - -/* - mspace_independent_calloc behaves as independent_calloc, but - operates within the given space. -*/ -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]); - -/* - mspace_independent_comalloc behaves as independent_comalloc, but - operates within the given space. -*/ -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]); - -/* - mspace_footprint() returns the number of bytes obtained from the - system for this space. -*/ -size_t mspace_footprint(mspace msp); - -/* - mspace_max_footprint() returns the peak number of bytes obtained from the - system for this space. -*/ -size_t mspace_max_footprint(mspace msp); - - -#if !NO_MALLINFO -/* - mspace_mallinfo behaves as mallinfo, but reports properties of - the given space. -*/ -struct mallinfo mspace_mallinfo(mspace msp); -#endif /* NO_MALLINFO */ - -/* - mspace_malloc_stats behaves as malloc_stats, but reports - properties of the given space. -*/ -void mspace_malloc_stats(mspace msp); - -/* - mspace_trim behaves as malloc_trim, but - operates within the given space. -*/ -int mspace_trim(mspace msp, size_t pad); - -/* - An alias for mallopt. -*/ -int mspace_mallopt(int, int); - -#endif /* MSPACES */ - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif /* __cplusplus */ - -/* - ======================================================================== - To make a fully customizable malloc.h header file, cut everything - above this line, put into file malloc.h, edit to suit, and #include it - on the next line, as well as in programs that use this malloc. - ======================================================================== -*/ - -/* #include "malloc.h" */ - -/*------------------------------ internal #includes ---------------------- */ - -#ifdef _MSC_VER -#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ -#endif /* _MSC_VER */ - -#include /* for printing in malloc_stats */ - -#ifndef LACKS_ERRNO_H -#include /* for MALLOC_FAILURE_ACTION */ -#endif /* LACKS_ERRNO_H */ -#if FOOTERS -#include /* for magic initialization */ -#endif /* FOOTERS */ -#ifndef LACKS_STDLIB_H -#include /* for abort() */ -#endif /* LACKS_STDLIB_H */ -#ifdef DEBUG -#if ABORT_ON_ASSERT_FAILURE -#define assert(x) if(!(x)) ABORT -#else /* ABORT_ON_ASSERT_FAILURE */ -#include -#endif /* ABORT_ON_ASSERT_FAILURE */ -#else /* DEBUG */ -#define assert(x) -#endif /* DEBUG */ -#ifndef LACKS_STRING_H -#include /* for memset etc */ -#endif /* LACKS_STRING_H */ -#if USE_BUILTIN_FFS -#ifndef LACKS_STRINGS_H -#include /* for ffs */ -#endif /* LACKS_STRINGS_H */ -#endif /* USE_BUILTIN_FFS */ -#if HAVE_MMAP -#ifndef LACKS_SYS_MMAN_H -#include /* for mmap */ -#endif /* LACKS_SYS_MMAN_H */ -#ifndef LACKS_FCNTL_H -#include -#endif /* LACKS_FCNTL_H */ -#endif /* HAVE_MMAP */ -#if HAVE_MORECORE -#ifndef LACKS_UNISTD_H -#include /* for sbrk */ -#else /* LACKS_UNISTD_H */ -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void* sbrk(ptrdiff_t); -#endif /* FreeBSD etc */ -#endif /* LACKS_UNISTD_H */ -#endif /* HAVE_MMAP */ - -#ifndef WIN32 -#ifndef malloc_getpagesize -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize ((size_t)4096U) -# endif -# endif -# endif -# endif -# endif -# endif -# endif -#endif -#endif - -/* ------------------- size_t and alignment properties -------------------- */ - -/* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) - -/* Some constants coerced to size_t */ -/* Annoying but necessary to avoid errors on some platforms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) -#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) - -/* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) - -/* True if address a has acceptable alignment */ -#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) - -/* the number of bytes to offset an address to align it */ -#define align_offset(A)\ - ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ - ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) - -/* -------------------------- MMAP preliminaries ------------------------- */ - -/* - If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and - checks to fail so compiler optimizer can delete code rather than - using so many "#if"s. -*/ - - -/* MORECORE and MMAP must return MFAIL on failure */ -#define MFAIL ((void*)(MAX_SIZE_T)) -#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ - -#if !HAVE_MMAP -#define IS_MMAPPED_BIT (SIZE_T_ZERO) -#define USE_MMAP_BIT (SIZE_T_ZERO) -#define CALL_MMAP(s) MFAIL -#define CALL_MUNMAP(a, s) (-1) -#define DIRECT_MMAP(s) MFAIL - -#else /* HAVE_MMAP */ -#define IS_MMAPPED_BIT (SIZE_T_ONE) -#define USE_MMAP_BIT (SIZE_T_ONE) - -#if !defined(WIN32) && !defined (__OS2__) -#define CALL_MUNMAP(a, s) munmap((a), (s)) -#define MMAP_PROT (PROT_READ|PROT_WRITE) -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif /* MAP_ANON */ -#ifdef MAP_ANONYMOUS -#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) -#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) -#else /* MAP_ANONYMOUS */ -/* - Nearly all versions of mmap support MAP_ANONYMOUS, so the following - is unlikely to be needed, but is supplied just in case. -*/ -#define MMAP_FLAGS (MAP_PRIVATE) -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ -#define CALL_MMAP(s) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) -#endif /* MAP_ANONYMOUS */ - -#define DIRECT_MMAP(s) CALL_MMAP(s) - -#elif defined(__OS2__) - -/* OS/2 MMAP via DosAllocMem */ -static void* os2mmap(size_t size) { - void* ptr; - if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) && - DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE)) - return MFAIL; - return ptr; -} - -#define os2direct_mmap(n) os2mmap(n) - -/* This function supports releasing coalesed segments */ -static int os2munmap(void* ptr, size_t size) { - while (size) { - ULONG ulSize = size; - ULONG ulFlags = 0; - if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0) - return -1; - if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 || - ulSize > size) - return -1; - if (DosFreeMem(ptr) != 0) - return -1; - ptr = ( void * ) ( ( char * ) ptr + ulSize ); - size -= ulSize; - } - return 0; -} - -#define CALL_MMAP(s) os2mmap(s) -#define CALL_MUNMAP(a, s) os2munmap((a), (s)) -#define DIRECT_MMAP(s) os2direct_mmap(s) - -#else /* WIN32 */ - -/* Win32 MMAP via VirtualAlloc */ -static void* win32mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE); - return (ptr != 0)? ptr: MFAIL; -} - -/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static void* win32direct_mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_EXECUTE_READWRITE); - return (ptr != 0)? ptr: MFAIL; -} - -/* This function supports releasing coalesed segments */ -static int win32munmap(void* ptr, size_t size) { - MEMORY_BASIC_INFORMATION minfo; - char* cptr = ptr; - while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; - if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || - minfo.State != MEM_COMMIT || minfo.RegionSize > size) - return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; - cptr += minfo.RegionSize; - size -= minfo.RegionSize; - } - return 0; -} - -#define CALL_MMAP(s) win32mmap(s) -#define CALL_MUNMAP(a, s) win32munmap((a), (s)) -#define DIRECT_MMAP(s) win32direct_mmap(s) -#endif /* WIN32 */ -#endif /* HAVE_MMAP */ - -#if HAVE_MMAP && HAVE_MREMAP -#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) -#else /* HAVE_MMAP && HAVE_MREMAP */ -#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL -#endif /* HAVE_MMAP && HAVE_MREMAP */ - -#if HAVE_MORECORE -#define CALL_MORECORE(S) MORECORE(S) -#else /* HAVE_MORECORE */ -#define CALL_MORECORE(S) MFAIL -#endif /* HAVE_MORECORE */ - -/* mstate bit set if contiguous morecore disabled or failed */ -#define USE_NONCONTIGUOUS_BIT (4U) - -/* segment bit set in create_mspace_with_base */ -#define EXTERN_BIT (8U) - - -/* --------------------------- Lock preliminaries ------------------------ */ - -#if USE_LOCKS - -/* - When locks are defined, there are up to two global locks: - - * If HAVE_MORECORE, morecore_mutex protects sequences of calls to - MORECORE. In many cases sys_alloc requires two calls, that should - not be interleaved with calls by other threads. This does not - protect against direct calls to MORECORE by other threads not - using this lock, so there is still code to cope the best we can on - interference. - - * magic_init_mutex ensures that mparams.magic and other - unique mparams values are initialized only once. -*/ - -#if !defined(WIN32) && !defined(__OS2__) -/* By default use posix locks */ -#include -#define MLOCK_T pthread_mutex_t -#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL) -#define ACQUIRE_LOCK(l) pthread_mutex_lock(l) -#define RELEASE_LOCK(l) pthread_mutex_unlock(l) - -#if HAVE_MORECORE -static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif /* HAVE_MORECORE */ - -static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; - -#elif defined(__OS2__) -#define MLOCK_T HMTX -#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE) -#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT) -#define RELEASE_LOCK(l) DosReleaseMutexSem(*l) -#if HAVE_MORECORE -static MLOCK_T morecore_mutex; -#endif /* HAVE_MORECORE */ -static MLOCK_T magic_init_mutex; - -#else /* WIN32 */ -/* - Because lock-protected regions have bounded times, and there - are no recursive lock calls, we can use simple spinlocks. -*/ - -#define MLOCK_T long -static int win32_acquire_lock (MLOCK_T *sl) { - for (;;) { -#ifdef InterlockedCompareExchangePointer - if (!InterlockedCompareExchange(sl, 1, 0)) - return 0; -#else /* Use older void* version */ - if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0)) - return 0; -#endif /* InterlockedCompareExchangePointer */ - Sleep (0); - } -} - -static void win32_release_lock (MLOCK_T *sl) { - InterlockedExchange (sl, 0); -} - -#define INITIAL_LOCK(l) *(l)=0 -#define ACQUIRE_LOCK(l) win32_acquire_lock(l) -#define RELEASE_LOCK(l) win32_release_lock(l) -#if HAVE_MORECORE -static MLOCK_T morecore_mutex; -#endif /* HAVE_MORECORE */ -static MLOCK_T magic_init_mutex; -#endif /* WIN32 */ - -#define USE_LOCK_BIT (2U) -#else /* USE_LOCKS */ -#define USE_LOCK_BIT (0U) -#define INITIAL_LOCK(l) -#endif /* USE_LOCKS */ - -#if USE_LOCKS && HAVE_MORECORE -#define ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex); -#define RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex); -#else /* USE_LOCKS && HAVE_MORECORE */ -#define ACQUIRE_MORECORE_LOCK() -#define RELEASE_MORECORE_LOCK() -#endif /* USE_LOCKS && HAVE_MORECORE */ - -#if USE_LOCKS -#define ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex); -#define RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex); -#else /* USE_LOCKS */ -#define ACQUIRE_MAGIC_INIT_LOCK() -#define RELEASE_MAGIC_INIT_LOCK() -#endif /* USE_LOCKS */ - - -/* ----------------------- Chunk representations ------------------------ */ - -/* - (The following includes lightly edited explanations by Colin Plumb.) - - The malloc_chunk declaration below is misleading (but accurate and - necessary). It declares a "view" into memory allowing access to - necessary fields at known offsets from a given base. - - Chunks of memory are maintained using a `boundary tag' method as - originally described by Knuth. (See the paper by Paul Wilson - ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such - techniques.) Sizes of free chunks are stored both in the front of - each chunk and at the end. This makes consolidating fragmented - chunks into bigger chunks fast. The head fields also hold bits - representing whether chunks are free or in use. - - Here are some pictures to make it clearer. They are "exploded" to - show that the state of a chunk can be thought of as extending from - the high 31 bits of the head field of its header through the - prev_foot and PINUSE_BIT bit of the following chunk header. - - A chunk that's in use looks like: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk (if P = 1) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| - | Size of this chunk 1| +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - +- -+ - | | - +- -+ - | : - +- size - sizeof(size_t) available payload bytes -+ - : | - chunk-> +- -+ - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| - | Size of next chunk (may or may not be in use) | +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - And if it's free, it looks like this: - - chunk-> +- -+ - | User payload (must be in use, or we would have merged!) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| - | Size of this chunk 0| +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Next pointer | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Prev pointer | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | : - +- size - sizeof(struct chunk) unused bytes -+ - : | - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of this chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| - | Size of next chunk (must be in use, or we would have merged)| +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | : - +- User payload -+ - : | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |0| - +-+ - Note that since we always merge adjacent free chunks, the chunks - adjacent to a free chunk must be in use. - - Given a pointer to a chunk (which can be derived trivially from the - payload pointer) we can, in O(1) time, find out whether the adjacent - chunks are free, and if so, unlink them from the lists that they - are on and merge them with the current chunk. - - Chunks always begin on even word boundaries, so the mem portion - (which is returned to the user) is also on an even word boundary, and - thus at least double-word aligned. - - The P (PINUSE_BIT) bit, stored in the unused low-order bit of the - chunk size (which is always a multiple of two words), is an in-use - bit for the *previous* chunk. If that bit is *clear*, then the - word before the current chunk size contains the previous chunk - size, and can be used to find the front of the previous chunk. - The very first chunk allocated always has this bit set, preventing - access to non-existent (or non-owned) memory. If pinuse is set for - any given chunk, then you CANNOT determine the size of the - previous chunk, and might even get a memory addressing fault when - trying to do so. - - The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of - the chunk size redundantly records whether the current chunk is - inuse. This redundancy enables usage checks within free and realloc, - and reduces indirection when freeing and consolidating chunks. - - Each freshly allocated chunk must have both cinuse and pinuse set. - That is, each allocated chunk borders either a previously allocated - and still in-use chunk, or the base of its memory arena. This is - ensured by making all allocations from the the `lowest' part of any - found chunk. Further, no free chunk physically borders another one, - so each free chunk is known to be preceded and followed by either - inuse chunks or the ends of memory. - - Note that the `foot' of the current chunk is actually represented - as the prev_foot of the NEXT chunk. This makes it easier to - deal with alignments etc but can be very confusing when trying - to extend or adapt this code. - - The exceptions to all this are - - 1. The special chunk `top' is the top-most available chunk (i.e., - the one bordering the end of available memory). It is treated - specially. Top is never included in any bin, is used only if - no other chunk is available, and is released back to the - system if it is very large (see M_TRIM_THRESHOLD). In effect, - the top chunk is treated as larger (and thus less well - fitting) than any other available chunk. The top chunk - doesn't update its trailing size field since there is no next - contiguous chunk that would have to index off it. However, - space is still allocated for it (TOP_FOOT_SIZE) to enable - separation or merging when space is extended. - - 3. Chunks allocated via mmap, which have the lowest-order bit - (IS_MMAPPED_BIT) set in their prev_foot fields, and do not set - PINUSE_BIT in their head fields. Because they are allocated - one-by-one, each must carry its own prev_foot field, which is - also used to hold the offset this chunk has within its mmapped - region, which is needed to preserve alignment. Each mmapped - chunk is trailed by the first two fields of a fake next-chunk - for sake of usage checks. - -*/ - -struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; -}; - -typedef struct malloc_chunk mchunk; -typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ -typedef size_t bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ - -/* ------------------- Chunks sizes and alignments ----------------------- */ - -#define MCHUNK_SIZE (sizeof(mchunk)) - -#if FOOTERS -#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -#else /* FOOTERS */ -#define CHUNK_OVERHEAD (SIZE_T_SIZE) -#endif /* FOOTERS */ - -/* MMapped chunks need a second word of overhead ... */ -#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -/* ... and additional padding for fake next-chunk at foot */ -#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) - -/* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE\ - ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) -/* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) - -/* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) - -/* pad request bytes into a usable size */ -#define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* pad request, checking for minimum (but not maximum) */ -#define request2size(req) \ - (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) - - -/* ------------------ Operations on head and foot fields ----------------- */ - -/* - The head field of a chunk is or'ed with PINUSE_BIT when previous - adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in - use. If the chunk was obtained with mmap, the prev_foot field has - IS_MMAPPED_BIT set, otherwise holding the offset of the base of the - mmapped region to the base of the chunk. -*/ - -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) - -/* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) - -/* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define chunksize(p) ((p)->head & ~(INUSE_BITS)) - -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) - -/* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) -#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) - -/* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS))) -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) - -/* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) - -/* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) - -/* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s)\ - ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) - -/* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n)\ - (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) - -#define is_mmapped(p)\ - (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT)) - -/* Get the internal overhead associated with chunk p */ -#define overhead_for(p)\ - (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) - -/* Return true if malloced space is not necessarily cleared */ -#if MMAP_CLEARS -#define calloc_must_clear(p) (!is_mmapped(p)) -#else /* MMAP_CLEARS */ -#define calloc_must_clear(p) (1) -#endif /* MMAP_CLEARS */ - -/* ---------------------- Overlaid data structures ----------------------- */ - -/* - When chunks are not in use, they are treated as nodes of either - lists or trees. - - "Small" chunks are stored in circular doubly-linked lists, and look - like this: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space (may be 0 bytes long) . - . . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Larger chunks are kept in a form of bitwise digital trees (aka - tries) keyed on chunksizes. Because malloc_tree_chunks are only for - free chunks greater than 256 bytes, their size doesn't impose any - constraints on user chunk sizes. Each node looks like: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk of same size | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk of same size | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Pointer to left child (child[0]) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Pointer to right child (child[1]) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Pointer to parent | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | bin index of this chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Each tree holding treenodes is a tree of unique chunk sizes. Chunks - of the same size are arranged in a circularly-linked list, with only - the oldest chunk (the next to be used, in our FIFO ordering) - actually in the tree. (Tree members are distinguished by a non-null - parent pointer.) If a chunk with the same size an an existing node - is inserted, it is linked off the existing node using pointers that - work in the same way as fd/bk pointers of small chunks. - - Each tree contains a power of 2 sized range of chunk sizes (the - smallest is 0x100 <= x < 0x180), which is is divided in half at each - tree level, with the chunks in the smaller half of the range (0x100 - <= x < 0x140 for the top nose) in the left subtree and the larger - half (0x140 <= x < 0x180) in the right subtree. This is, of course, - done by inspecting individual bits. - - Using these rules, each node's left subtree contains all smaller - sizes than its right subtree. However, the node at the root of each - subtree has no particular ordering relationship to either. (The - dividing line between the subtree sizes is based on trie relation.) - If we remove the last chunk of a given size from the interior of the - tree, we need to replace it with a leaf node. The tree ordering - rules permit a node to be replaced by any leaf below it. - - The smallest chunk in a tree (a common operation in a best-fit - allocator) can be found by walking a path to the leftmost leaf in - the tree. Unlike a usual binary tree, where we follow left child - pointers until we reach a null, here we follow the right child - pointer any time the left one is null, until we reach a leaf with - both child pointers null. The smallest chunk in the tree will be - somewhere along that path. - - The worst case number of steps to add, find, or remove a node is - bounded by the number of bits differentiating chunks within - bins. Under current bin calculations, this ranges from 6 up to 21 - (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case - is of course much better. -*/ - -struct malloc_tree_chunk { - /* The first four fields must be compatible with malloc_chunk */ - size_t prev_foot; - size_t head; - struct malloc_tree_chunk* fd; - struct malloc_tree_chunk* bk; - - struct malloc_tree_chunk* child[2]; - struct malloc_tree_chunk* parent; - bindex_t index; -}; - -typedef struct malloc_tree_chunk tchunk; -typedef struct malloc_tree_chunk* tchunkptr; -typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ - -/* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) - -/* ----------------------------- Segments -------------------------------- */ - -/* - Each malloc space may include non-contiguous segments, held in a - list headed by an embedded malloc_segment record representing the - top-most space. Segments also include flags holding properties of - the space. Large chunks that are directly allocated by mmap are not - included in this list. They are instead independently created and - destroyed without otherwise keeping track of them. - - Segment management mainly comes into play for spaces allocated by - MMAP. Any call to MMAP might or might not return memory that is - adjacent to an existing segment. MORECORE normally contiguously - extends the current space, so this space is almost always adjacent, - which is simpler and faster to deal with. (This is why MORECORE is - used preferentially to MMAP when both are available -- see - sys_alloc.) When allocating using MMAP, we don't use any of the - hinting mechanisms (inconsistently) supported in various - implementations of unix mmap, or distinguish reserving from - committing memory. Instead, we just ask for space, and exploit - contiguity when we get it. It is probably possible to do - better than this on some systems, but no general scheme seems - to be significantly better. - - Management entails a simpler variant of the consolidation scheme - used for chunks to reduce fragmentation -- new adjacent memory is - normally prepended or appended to an existing segment. However, - there are limitations compared to chunk consolidation that mostly - reflect the fact that segment processing is relatively infrequent - (occurring only when getting memory from system) and that we - don't expect to have huge numbers of segments: - - * Segments are not indexed, so traversal requires linear scans. (It - would be possible to index these, but is not worth the extra - overhead and complexity for most programs on most platforms.) - * New segments are only appended to old ones when holding top-most - memory; if they cannot be prepended to others, they are held in - different segments. - - Except for the top-most segment of an mstate, each segment record - is kept at the tail of its segment. Segments are added by pushing - segment records onto the list headed by &mstate.seg for the - containing mstate. - - Segment flags control allocation/merge/deallocation policies: - * If EXTERN_BIT set, then we did not allocate this segment, - and so should not try to deallocate or merge with others. - (This currently holds only for the initial segment passed - into create_mspace_with_base.) - * If IS_MMAPPED_BIT set, the segment may be merged with - other surrounding mmapped segments and trimmed/de-allocated - using munmap. - * If neither bit is set, then the segment was obtained using - MORECORE so can be merged with surrounding MORECORE'd segments - and deallocated/trimmed using MORECORE with negative arguments. -*/ - -struct malloc_segment { - char* base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment* next; /* ptr to next segment */ -#if FFI_MMAP_EXEC_WRIT - /* The mmap magic is supposed to store the address of the executable - segment at the very end of the requested block. */ - -# define mmap_exec_offset(b,s) (*(ptrdiff_t*)((b)+(s)-sizeof(ptrdiff_t))) - - /* We can only merge segments if their corresponding executable - segments are at identical offsets. */ -# define check_segment_merge(S,b,s) \ - (mmap_exec_offset((b),(s)) == (S)->exec_offset) - -# define add_segment_exec_offset(p,S) ((char*)(p) + (S)->exec_offset) -# define sub_segment_exec_offset(p,S) ((char*)(p) - (S)->exec_offset) - - /* The removal of sflags only works with HAVE_MORECORE == 0. */ - -# define get_segment_flags(S) (IS_MMAPPED_BIT) -# define set_segment_flags(S,v) \ - (((v) != IS_MMAPPED_BIT) ? (ABORT, (v)) : \ - (((S)->exec_offset = \ - mmap_exec_offset((S)->base, (S)->size)), \ - (mmap_exec_offset((S)->base + (S)->exec_offset, (S)->size) != \ - (S)->exec_offset) ? (ABORT, (v)) : \ - (mmap_exec_offset((S)->base, (S)->size) = 0), (v))) - - /* We use an offset here, instead of a pointer, because then, when - base changes, we don't have to modify this. On architectures - with segmented addresses, this might not work. */ - ptrdiff_t exec_offset; -#else - -# define get_segment_flags(S) ((S)->sflags) -# define set_segment_flags(S,v) ((S)->sflags = (v)) -# define check_segment_merge(S,b,s) (1) - - flag_t sflags; /* mmap and extern flag */ -#endif -}; - -#define is_mmapped_segment(S) (get_segment_flags(S) & IS_MMAPPED_BIT) -#define is_extern_segment(S) (get_segment_flags(S) & EXTERN_BIT) - -typedef struct malloc_segment msegment; -typedef struct malloc_segment* msegmentptr; - -/* ---------------------------- malloc_state ----------------------------- */ - -/* - A malloc_state holds all of the bookkeeping for a space. - The main fields are: - - Top - The topmost chunk of the currently active segment. Its size is - cached in topsize. The actual size of topmost space is - topsize+TOP_FOOT_SIZE, which includes space reserved for adding - fenceposts and segment records if necessary when getting more - space from the system. The size at which to autotrim top is - cached from mparams in trim_check, except that it is disabled if - an autotrim fails. - - Designated victim (dv) - This is the preferred chunk for servicing small requests that - don't have exact fits. It is normally the chunk split off most - recently to service another small request. Its size is cached in - dvsize. The link fields of this chunk are not maintained since it - is not kept in a bin. - - SmallBins - An array of bin headers for free chunks. These bins hold chunks - with sizes less than MIN_LARGE_SIZE bytes. Each bin contains - chunks of all the same size, spaced 8 bytes apart. To simplify - use in double-linked lists, each bin header acts as a malloc_chunk - pointing to the real first node, if it exists (else pointing to - itself). This avoids special-casing for headers. But to avoid - waste, we allocate only the fd/bk pointers of bins, and then use - repositioning tricks to treat these as the fields of a chunk. - - TreeBins - Treebins are pointers to the roots of trees holding a range of - sizes. There are 2 equally spaced treebins for each power of two - from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything - larger. - - Bin maps - There is one bit map for small bins ("smallmap") and one for - treebins ("treemap). Each bin sets its bit when non-empty, and - clears the bit when empty. Bit operations are then used to avoid - bin-by-bin searching -- nearly all "search" is done without ever - looking at bins that won't be selected. The bit maps - conservatively use 32 bits per map word, even if on 64bit system. - For a good description of some of the bit-based techniques used - here, see Henry S. Warren Jr's book "Hacker's Delight" (and - supplement at http://hackersdelight.org/). Many of these are - intended to reduce the branchiness of paths through malloc etc, as - well as to reduce the number of memory locations read or written. - - Segments - A list of segments headed by an embedded malloc_segment record - representing the initial space. - - Address check support - The least_addr field is the least address ever obtained from - MORECORE or MMAP. Attempted frees and reallocs of any address less - than this are trapped (unless INSECURE is defined). - - Magic tag - A cross-check field that should always hold same value as mparams.magic. - - Flags - Bits recording whether to use MMAP, locks, or contiguous MORECORE - - Statistics - Each space keeps track of current and maximum system memory - obtained via MORECORE or MMAP. - - Locking - If USE_LOCKS is defined, the "mutex" lock is acquired and released - around every public call using this mspace. -*/ - -/* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) -#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) - -struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char* least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t magic; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - flag_t mflags; -#if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ -#endif /* USE_LOCKS */ - msegment seg; -}; - -typedef struct malloc_state* mstate; - -/* ------------- Global malloc_state and malloc_params ------------------- */ - -/* - malloc_params holds global properties, including those that can be - dynamically set using mallopt. There is a single instance, mparams, - initialized in init_mparams. -*/ - -struct malloc_params { - size_t magic; - size_t page_size; - size_t granularity; - size_t mmap_threshold; - size_t trim_threshold; - flag_t default_mflags; -}; - -static struct malloc_params mparams; - -/* The global malloc_state used for all non-"mspace" calls */ -static struct malloc_state _gm_; -#define gm (&_gm_) -#define is_global(M) ((M) == &_gm_) -#define is_initialized(M) ((M)->top != 0) - -/* -------------------------- system alloc setup ------------------------- */ - -/* Operations on mflags */ - -#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) -#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) -#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) - -#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) -#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) -#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) - -#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) -#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) - -#define set_lock(M,L)\ - ((M)->mflags = (L)?\ - ((M)->mflags | USE_LOCK_BIT) :\ - ((M)->mflags & ~USE_LOCK_BIT)) - -/* page-align a size */ -#define page_align(S)\ - (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE)) - -/* granularity-align a size */ -#define granularity_align(S)\ - (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE)) - -#define is_page_aligned(S)\ - (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) -#define is_granularity_aligned(S)\ - (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) - -/* True if segment S holds address A */ -#define segment_holds(S, A)\ - ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) - -/* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char* addr) { - msegmentptr sp = &m->seg; - for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; - } -} - -/* Return true if segment contains a segment link */ -static int has_segment_link(mstate m, msegmentptr ss) { - msegmentptr sp = &m->seg; - for (;;) { - if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; - } -} - -#ifndef MORECORE_CANNOT_TRIM -#define should_trim(M,s) ((s) > (M)->trim_check) -#else /* MORECORE_CANNOT_TRIM */ -#define should_trim(M,s) (0) -#endif /* MORECORE_CANNOT_TRIM */ - -/* - TOP_FOOT_SIZE is padding at the end of a segment, including space - that may be needed to place segment records and fenceposts when new - noncontiguous segments are added. -*/ -#define TOP_FOOT_SIZE\ - (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) - - -/* ------------------------------- Hooks -------------------------------- */ - -/* - PREACTION should be defined to return 0 on success, and nonzero on - failure. If you are not using locking, you can redefine these to do - anything you like. -*/ - -#if USE_LOCKS - -/* Ensure locks are initialized */ -#define GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams()) - -#define PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) -#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } -#else /* USE_LOCKS */ - -#ifndef PREACTION -#define PREACTION(M) (0) -#endif /* PREACTION */ - -#ifndef POSTACTION -#define POSTACTION(M) -#endif /* POSTACTION */ - -#endif /* USE_LOCKS */ - -/* - CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. - USAGE_ERROR_ACTION is triggered on detected bad frees and - reallocs. The argument p is an address that might have triggered the - fault. It is ignored by the two predefined actions, but might be - useful in custom actions that try to help diagnose errors. -*/ - -#if PROCEED_ON_ERROR - -/* A count of the number of corruption errors causing resets */ -int malloc_corruption_error_count; - -/* default corruption action */ -static void reset_on_error(mstate m); - -#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) -#define USAGE_ERROR_ACTION(m, p) - -#else /* PROCEED_ON_ERROR */ - -#ifndef CORRUPTION_ERROR_ACTION -#define CORRUPTION_ERROR_ACTION(m) ABORT -#endif /* CORRUPTION_ERROR_ACTION */ - -#ifndef USAGE_ERROR_ACTION -#define USAGE_ERROR_ACTION(m,p) ABORT -#endif /* USAGE_ERROR_ACTION */ - -#endif /* PROCEED_ON_ERROR */ - -/* -------------------------- Debugging setup ---------------------------- */ - -#if ! DEBUG - -#define check_free_chunk(M,P) -#define check_inuse_chunk(M,P) -#define check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) -#define check_malloc_state(M) -#define check_top_chunk(M,P) - -#else /* DEBUG */ -#define check_free_chunk(M,P) do_check_free_chunk(M,P) -#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) -#define check_top_chunk(M,P) do_check_top_chunk(M,P) -#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) -#define check_malloc_state(M) do_check_malloc_state(M) - -static void do_check_any_chunk(mstate m, mchunkptr p); -static void do_check_top_chunk(mstate m, mchunkptr p); -static void do_check_mmapped_chunk(mstate m, mchunkptr p); -static void do_check_inuse_chunk(mstate m, mchunkptr p); -static void do_check_free_chunk(mstate m, mchunkptr p); -static void do_check_malloced_chunk(mstate m, void* mem, size_t s); -static void do_check_tree(mstate m, tchunkptr t); -static void do_check_treebin(mstate m, bindex_t i); -static void do_check_smallbin(mstate m, bindex_t i); -static void do_check_malloc_state(mstate m); -static int bin_find(mstate m, mchunkptr x); -static size_t traverse_and_check(mstate m); -#endif /* DEBUG */ - -/* ---------------------------- Indexing Bins ---------------------------- */ - -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) ((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) - -/* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) -#define treebin_at(M,i) (&((M)->treebins[i])) - -/* assign tree index for size S to variable I */ -#if defined(__GNUC__) && defined(__i386__) -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K;\ - __asm__("bsrl %1,%0\n\t" : "=r" (K) : "rm" (X));\ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} -#else /* GNUC */ -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int Y = (unsigned int)X;\ - unsigned int N = ((Y - 0x100) >> 16) & 8;\ - unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ - N += K;\ - N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ - K = 14 - N + ((Y <<= K) >> 15);\ - I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ - }\ -} -#endif /* GNUC */ - -/* Bit representing maximum resolved size in a treebin at i */ -#define bit_for_tree_index(i) \ - (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) - -/* Shift placing maximum resolved bit in a treebin at i as sign bit */ -#define leftshift_for_tree_index(i) \ - ((i == NTREEBINS-1)? 0 : \ - ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) - -/* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) - - -/* ------------------------ Operations on bin maps ----------------------- */ - -/* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) - -/* Mark/Clear bits with given index */ -#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) - -#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) - -/* index corresponding to given bit */ - -#if defined(__GNUC__) && defined(__i386__) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - __asm__("bsfl %1,%0\n\t" : "=r" (J) : "rm" (X));\ - I = (bindex_t)J;\ -} - -#else /* GNUC */ -#if USE_BUILTIN_FFS -#define compute_bit2idx(X, I) I = ffs(X)-1 - -#else /* USE_BUILTIN_FFS */ -#define compute_bit2idx(X, I)\ -{\ - unsigned int Y = X - 1;\ - unsigned int K = Y >> (16-4) & 16;\ - unsigned int N = K; Y >>= K;\ - N += K = Y >> (8-3) & 8; Y >>= K;\ - N += K = Y >> (4-2) & 4; Y >>= K;\ - N += K = Y >> (2-1) & 2; Y >>= K;\ - N += K = Y >> (1-0) & 1; Y >>= K;\ - I = (bindex_t)(N + Y);\ -} -#endif /* USE_BUILTIN_FFS */ -#endif /* GNUC */ - -/* isolate the least set bit of a bitmap */ -#define least_bit(x) ((x) & -(x)) - -/* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x<<1) | -(x<<1)) - -/* mask with all bits to left of or equal to least bit of x on */ -#define same_or_left_bits(x) ((x) | -(x)) - - -/* ----------------------- Runtime Check Support ------------------------- */ - -/* - For security, the main invariant is that malloc/free/etc never - writes to a static address other than malloc_state, unless static - malloc_state itself has been corrupted, which cannot occur via - malloc (because of these checks). In essence this means that we - believe all pointers, sizes, maps etc held in malloc_state, but - check all of those linked or offsetted from other embedded data - structures. These checks are interspersed with main code in a way - that tends to minimize their run-time cost. - - When FOOTERS is defined, in addition to range checking, we also - verify footer fields of inuse chunks, which can be used guarantee - that the mstate controlling malloc/free is intact. This is a - streamlined version of the approach described by William Robertson - et al in "Run-time Detection of Heap-based Overflows" LISA'03 - http://www.usenix.org/events/lisa03/tech/robertson.html The footer - of an inuse chunk holds the xor of its mstate and a random seed, - that is checked upon calls to free() and realloc(). This is - (probablistically) unguessable from outside the program, but can be - computed by any code successfully malloc'ing any chunk, so does not - itself provide protection against code that has already broken - security through some other means. Unlike Robertson et al, we - always dynamically check addresses of all offset chunks (previous, - next, etc). This turns out to be cheaper than relying on hashes. -*/ - -#if !INSECURE -/* Check if address a is at least as high as any from MORECORE or MMAP */ -#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) -/* Check if address of next chunk n is higher than base chunk p */ -#define ok_next(p, n) ((char*)(p) < (char*)(n)) -/* Check if p has its cinuse bit on */ -#define ok_cinuse(p) cinuse(p) -/* Check if p has its pinuse bit on */ -#define ok_pinuse(p) pinuse(p) - -#else /* !INSECURE */ -#define ok_address(M, a) (1) -#define ok_next(b, n) (1) -#define ok_cinuse(p) (1) -#define ok_pinuse(p) (1) -#endif /* !INSECURE */ - -#if (FOOTERS && !INSECURE) -/* Check if (alleged) mstate m has expected magic field */ -#define ok_magic(M) ((M)->magic == mparams.magic) -#else /* (FOOTERS && !INSECURE) */ -#define ok_magic(M) (1) -#endif /* (FOOTERS && !INSECURE) */ - - -/* In gcc, use __builtin_expect to minimize impact of checks */ -#if !INSECURE -#if defined(__GNUC__) && __GNUC__ >= 3 -#define RTCHECK(e) __builtin_expect(e, 1) -#else /* GNUC */ -#define RTCHECK(e) (e) -#endif /* GNUC */ -#else /* !INSECURE */ -#define RTCHECK(e) (1) -#endif /* !INSECURE */ - -/* macros to set up inuse chunks with or without footers */ - -#if !FOOTERS - -#define mark_inuse_foot(M,p,s) - -/* Set cinuse bit and pinuse bit of next chunk */ -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) - -/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) - -/* Set size, cinuse and pinuse bit of this chunk */ -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) - -#else /* FOOTERS */ - -/* Set foot of inuse chunk to be xor of mstate and seed */ -#define mark_inuse_foot(M,p,s)\ - (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) - -#define get_mstate_for(p)\ - ((mstate)(((mchunkptr)((char*)(p) +\ - (chunksize(p))))->prev_foot ^ mparams.magic)) - -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M,p,s)) - -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ - mark_inuse_foot(M,p,s)) - -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - mark_inuse_foot(M, p, s)) - -#endif /* !FOOTERS */ - -/* ---------------------------- setting mparams -------------------------- */ - -/* Initialize mparams */ -static int init_mparams(void) { - if (mparams.page_size == 0) { - size_t s; - - mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; - mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; -#if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; -#else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; -#endif /* MORECORE_CONTIGUOUS */ - -#if (FOOTERS && !INSECURE) - { -#if USE_DEV_RANDOM - int fd; - unsigned char buf[sizeof(size_t)]; - /* Try to use /dev/urandom, else fall back on using time */ - if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && - read(fd, buf, sizeof(buf)) == sizeof(buf)) { - s = *((size_t *) buf); - close(fd); - } - else -#endif /* USE_DEV_RANDOM */ - s = (size_t)(time(0) ^ (size_t)0x55555555U); - - s |= (size_t)8U; /* ensure nonzero */ - s &= ~(size_t)7U; /* improve chances of fault for bad values */ - - } -#else /* (FOOTERS && !INSECURE) */ - s = (size_t)0x58585858U; -#endif /* (FOOTERS && !INSECURE) */ - ACQUIRE_MAGIC_INIT_LOCK(); - if (mparams.magic == 0) { - mparams.magic = s; - /* Set up lock for main malloc area */ - INITIAL_LOCK(&gm->mutex); - gm->mflags = mparams.default_mflags; - } - RELEASE_MAGIC_INIT_LOCK(); - -#if !defined(WIN32) && !defined(__OS2__) - mparams.page_size = malloc_getpagesize; - mparams.granularity = ((DEFAULT_GRANULARITY != 0)? - DEFAULT_GRANULARITY : mparams.page_size); -#elif defined (__OS2__) - /* if low-memory is used, os2munmap() would break - if it were anything other than 64k */ - mparams.page_size = 4096u; - mparams.granularity = 65536u; -#else /* WIN32 */ - { - SYSTEM_INFO system_info; - GetSystemInfo(&system_info); - mparams.page_size = system_info.dwPageSize; - mparams.granularity = system_info.dwAllocationGranularity; - } -#endif /* WIN32 */ - - /* Sanity-check configuration: - size_t must be unsigned and as wide as pointer type. - ints must be at least 4 bytes. - alignment must be at least 8. - Alignment, min chunk size, and page size must all be powers of 2. - */ - if ((sizeof(size_t) != sizeof(char*)) || - (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || - (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || - ((mparams.granularity & (mparams.granularity-SIZE_T_ONE)) != 0) || - ((mparams.page_size & (mparams.page_size-SIZE_T_ONE)) != 0)) - ABORT; - } - return 0; -} - -/* support for mallopt */ -static int change_mparam(int param_number, int value) { - size_t val = (size_t)value; - init_mparams(); - switch(param_number) { - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val-1)) == 0)) { - mparams.granularity = val; - return 1; - } - else - return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; - return 1; - default: - return 0; - } -} - -#if DEBUG -/* ------------------------- Debugging Support --------------------------- */ - -/* Check properties of any chunk, whether free, inuse, mmapped etc */ -static void do_check_any_chunk(mstate m, mchunkptr p) { - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); -} - -/* Check properties of top chunk */ -static void do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding(m, (char*)p); - size_t sz = chunksize(p); - assert(sp != 0); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(sz == m->topsize); - assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); - assert(pinuse(p)); - assert(!next_pinuse(p)); -} - -/* Check properties of (inuse) mmapped chunks */ -static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); - size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD); - assert(is_mmapped(p)); - assert(use_mmap(m)); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(!is_small(sz)); - assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); - assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); -} - -/* Check properties of inuse chunks */ -static void do_check_inuse_chunk(mstate m, mchunkptr p) { - do_check_any_chunk(m, p); - assert(cinuse(p)); - assert(next_pinuse(p)); - /* If not pinuse and not mmapped, previous chunk has OK offset */ - assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) - do_check_mmapped_chunk(m, p); -} - -/* Check properties of free chunks */ -static void do_check_free_chunk(mstate m, mchunkptr p) { - size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); - mchunkptr next = chunk_plus_offset(p, sz); - do_check_any_chunk(m, p); - assert(!cinuse(p)); - assert(!next_pinuse(p)); - assert (!is_mmapped(p)); - if (p != m->dv && p != m->top) { - if (sz >= MIN_CHUNK_SIZE) { - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(is_aligned(chunk2mem(p))); - assert(next->prev_foot == sz); - assert(pinuse(p)); - assert (next == m->top || cinuse(next)); - assert(p->fd->bk == p); - assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_T_SIZE */ - assert(sz == SIZE_T_SIZE); - } -} - -/* Check properties of malloced chunks at the point they are malloced */ -static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); - do_check_inuse_chunk(m, p); - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(sz >= MIN_CHUNK_SIZE); - assert(sz >= s); - /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ - assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); - } -} - -/* Check a tree and its subtrees. */ -static void do_check_tree(mstate m, tchunkptr t) { - tchunkptr head = 0; - tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; - compute_tree_index(tsize, idx); - assert(tindex == idx); - assert(tsize >= MIN_LARGE_SIZE); - assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); - - do { /* traverse through chain of same-sized nodes */ - do_check_any_chunk(m, ((mchunkptr)u)); - assert(u->index == tindex); - assert(chunksize(u) == tsize); - assert(!cinuse(u)); - assert(!next_pinuse(u)); - assert(u->fd->bk == u); - assert(u->bk->fd == u); - if (u->parent == 0) { - assert(u->child[0] == 0); - assert(u->child[1] == 0); - } - else { - assert(head == 0); /* only one node on chain has parent */ - head = u; - assert(u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr*)(u->parent)) == u); - if (u->child[0] != 0) { - assert(u->child[0]->parent == u); - assert(u->child[0] != u); - do_check_tree(m, u->child[0]); - } - if (u->child[1] != 0) { - assert(u->child[1]->parent == u); - assert(u->child[1] != u); - do_check_tree(m, u->child[1]); - } - if (u->child[0] != 0 && u->child[1] != 0) { - assert(chunksize(u->child[0]) < chunksize(u->child[1])); - } - } - u = u->fd; - } while (u != t); - assert(head != 0); -} - -/* Check all the chunks in a treebin. */ -static void do_check_treebin(mstate m, bindex_t i) { - tbinptr* tb = treebin_at(m, i); - tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) - assert(empty); - if (!empty) - do_check_tree(m, t); -} - -/* Check all the chunks in a smallbin. */ -static void do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; - unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) - assert(empty); - if (!empty) { - for (; p != b; p = p->bk) { - size_t size = chunksize(p); - mchunkptr q; - /* each chunk claims to be free */ - do_check_free_chunk(m, p); - /* chunk belongs in bin */ - assert(small_index(size) == i); - assert(p->bk == b || chunksize(p->bk) == chunksize(p)); - /* chunk is followed by an inuse chunk */ - q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk(m, q); - } - } -} - -/* Find x in a bin. Used in other check functions. */ -static int bin_find(mstate m, mchunkptr x) { - size_t size = chunksize(x); - if (is_small(size)) { - bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); - if (smallmap_is_marked(m, sidx)) { - mchunkptr p = b; - do { - if (p == x) - return 1; - } while ((p = p->fd) != b); - } - } - else { - bindex_t tidx; - compute_tree_index(size, tidx); - if (treemap_is_marked(m, tidx)) { - tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); - while (t != 0 && chunksize(t) != size) { - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - sizebits <<= 1; - } - if (t != 0) { - tchunkptr u = t; - do { - if (u == (tchunkptr)x) - return 1; - } while ((u = u->fd) != t); - } - } - } - return 0; -} - -/* Traverse each chunk and check it; return total */ -static size_t traverse_and_check(mstate m) { - size_t sum = 0; - if (is_initialized(m)) { - msegmentptr s = &m->seg; - sum += m->topsize + TOP_FOOT_SIZE; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - mchunkptr lastq = 0; - assert(pinuse(q)); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - sum += chunksize(q); - if (cinuse(q)) { - assert(!bin_find(m, q)); - do_check_inuse_chunk(m, q); - } - else { - assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */ - do_check_free_chunk(m, q); - } - lastq = q; - q = next_chunk(q); - } - s = s->next; - } - } - return sum; -} - -/* Check all properties of malloc_state. */ -static void do_check_malloc_state(mstate m) { - bindex_t i; - size_t total; - /* check bins */ - for (i = 0; i < NSMALLBINS; ++i) - do_check_smallbin(m, i); - for (i = 0; i < NTREEBINS; ++i) - do_check_treebin(m, i); - - if (m->dvsize != 0) { /* check dv chunk */ - do_check_any_chunk(m, m->dv); - assert(m->dvsize == chunksize(m->dv)); - assert(m->dvsize >= MIN_CHUNK_SIZE); - assert(bin_find(m, m->dv) == 0); - } - - if (m->top != 0) { /* check top chunk */ - do_check_top_chunk(m, m->top); - assert(m->topsize == chunksize(m->top)); - assert(m->topsize > 0); - assert(bin_find(m, m->top) == 0); - } - - total = traverse_and_check(m); - assert(total <= m->footprint); - assert(m->footprint <= m->max_footprint); -} -#endif /* DEBUG */ - -/* ----------------------------- statistics ------------------------------ */ - -#if !NO_MALLINFO -static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (!PREACTION(m)) { - check_malloc_state(m); - if (is_initialized(m)) { - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; - msegmentptr s = &m->seg; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - size_t sz = chunksize(q); - sum += sz; - if (!cinuse(q)) { - mfree += sz; - ++nfree; - } - q = next_chunk(q); - } - s = s->next; - } - - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; - nm.uordblks = m->footprint - mfree; - nm.fordblks = mfree; - nm.keepcost = m->topsize; - } - - POSTACTION(m); - } - return nm; -} -#endif /* !NO_MALLINFO */ - -static void internal_malloc_stats(mstate m) { - if (!PREACTION(m)) { - size_t maxfp = 0; - size_t fp = 0; - size_t used = 0; - check_malloc_state(m); - if (is_initialized(m)) { - msegmentptr s = &m->seg; - maxfp = m->max_footprint; - fp = m->footprint; - used = fp - (m->topsize + TOP_FOOT_SIZE); - - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - if (!cinuse(q)) - used -= chunksize(q); - q = next_chunk(q); - } - s = s->next; - } - } - - fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); - fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); - fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); - - POSTACTION(m); - } -} - -/* ----------------------- Operations on smallbins ----------------------- */ - -/* - Various forms of linking and unlinking are defined as macros. Even - the ones for trees, which are very long but have very short typical - paths. This is ugly but reduces reliance on inlining support of - compilers. -*/ - -/* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) {\ - bindex_t I = small_index(S);\ - mchunkptr B = smallbin_at(M, I);\ - mchunkptr F = B;\ - assert(S >= MIN_CHUNK_SIZE);\ - if (!smallmap_is_marked(M, I))\ - mark_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, B->fd)))\ - F = B->fd;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - B->fd = P;\ - F->bk = P;\ - P->fd = F;\ - P->bk = B;\ -} - -/* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) {\ - mchunkptr F = P->fd;\ - mchunkptr B = P->bk;\ - bindex_t I = small_index(S);\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (F == B)\ - clear_smallmap(M, I);\ - else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ - (B == smallbin_at(M,I) || ok_address(M, B)))) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} - -/* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) {\ - mchunkptr F = P->fd;\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (B == F)\ - clear_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, F))) {\ - B->fd = F;\ - F->bk = B;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} - -/* Replace dv node, binning the old one */ -/* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) {\ - size_t DVS = M->dvsize;\ - if (DVS != 0) {\ - mchunkptr DV = M->dv;\ - assert(is_small(DVS));\ - insert_small_chunk(M, DV, DVS);\ - }\ - M->dvsize = S;\ - M->dv = P;\ -} - -/* ------------------------- Operations on trees ------------------------- */ - -/* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) {\ - tbinptr* H;\ - bindex_t I;\ - compute_tree_index(S, I);\ - H = treebin_at(M, I);\ - X->index = I;\ - X->child[0] = X->child[1] = 0;\ - if (!treemap_is_marked(M, I)) {\ - mark_treemap(M, I);\ - *H = X;\ - X->parent = (tchunkptr)H;\ - X->fd = X->bk = X;\ - }\ - else {\ - tchunkptr T = *H;\ - size_t K = S << leftshift_for_tree_index(I);\ - for (;;) {\ - if (chunksize(T) != S) {\ - tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ - K <<= 1;\ - if (*C != 0)\ - T = *C;\ - else if (RTCHECK(ok_address(M, C))) {\ - *C = X;\ - X->parent = T;\ - X->fd = X->bk = X;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - else {\ - tchunkptr F = T->fd;\ - if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ - T->fd = F->bk = X;\ - X->fd = F;\ - X->bk = T;\ - X->parent = 0;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - }\ - }\ -} - -/* - Unlink steps: - - 1. If x is a chained node, unlink it from its same-sized fd/bk links - and choose its bk node as its replacement. - 2. If x was the last node of its size, but not a leaf node, it must - be replaced with a leaf node (not merely one with an open left or - right), to make sure that lefts and rights of descendants - correspond properly to bit masks. We use the rightmost descendant - of x. We could use any other leaf, but this is easy to locate and - tends to counteract removal of leftmosts elsewhere, and so keeps - paths shorter than minimally guaranteed. This doesn't loop much - because on average a node in a tree is near the bottom. - 3. If x is the base of a chain (i.e., has parent links) relink - x's parent and children to x's replacement (or null if none). -*/ - -#define unlink_large_chunk(M, X) {\ - tchunkptr XP = X->parent;\ - tchunkptr R;\ - if (X->bk != X) {\ - tchunkptr F = X->fd;\ - R = X->bk;\ - if (RTCHECK(ok_address(M, F))) {\ - F->bk = R;\ - R->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - tchunkptr* RP;\ - if (((R = *(RP = &(X->child[1]))) != 0) ||\ - ((R = *(RP = &(X->child[0]))) != 0)) {\ - tchunkptr* CP;\ - while ((*(CP = &(R->child[1])) != 0) ||\ - (*(CP = &(R->child[0])) != 0)) {\ - R = *(RP = CP);\ - }\ - if (RTCHECK(ok_address(M, RP)))\ - *RP = 0;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - }\ - if (XP != 0) {\ - tbinptr* H = treebin_at(M, X->index);\ - if (X == *H) {\ - if ((*H = R) == 0) \ - clear_treemap(M, X->index);\ - }\ - else if (RTCHECK(ok_address(M, XP))) {\ - if (XP->child[0] == X) \ - XP->child[0] = R;\ - else \ - XP->child[1] = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - if (R != 0) {\ - if (RTCHECK(ok_address(M, R))) {\ - tchunkptr C0, C1;\ - R->parent = XP;\ - if ((C0 = X->child[0]) != 0) {\ - if (RTCHECK(ok_address(M, C0))) {\ - R->child[0] = C0;\ - C0->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - if ((C1 = X->child[1]) != 0) {\ - if (RTCHECK(ok_address(M, C1))) {\ - R->child[1] = C1;\ - C1->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ -} - -/* Relays to large vs small bin operations */ - -#define insert_chunk(M, P, S)\ - if (is_small(S)) insert_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - -#define unlink_chunk(M, P, S)\ - if (is_small(S)) unlink_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } - - -/* Relays to internal calls to malloc/free from realloc, memalign etc */ - -#if ONLY_MSPACES -#define internal_malloc(m, b) mspace_malloc(m, b) -#define internal_free(m, mem) mspace_free(m,mem); -#else /* ONLY_MSPACES */ -#if MSPACES -#define internal_malloc(m, b)\ - (m == gm)? dlmalloc(b) : mspace_malloc(m, b) -#define internal_free(m, mem)\ - if (m == gm) dlfree(mem); else mspace_free(m,mem); -#else /* MSPACES */ -#define internal_malloc(m, b) dlmalloc(b) -#define internal_free(m, mem) dlfree(mem) -#endif /* MSPACES */ -#endif /* ONLY_MSPACES */ - -/* ----------------------- Direct-mmapping chunks ----------------------- */ - -/* - Directly mmapped chunks are set up with an offset to the start of - the mmapped region stored in the prev_foot field of the chunk. This - allows reconstruction of the required argument to MUNMAP when freed, - and also allows adjustment of the returned chunk to meet alignment - requirements (especially in memalign). There is also enough space - allocated to hold a fake next chunk of size SIZE_T_SIZE to maintain - the PINUSE bit so frees can be checked. -*/ - -/* Malloc using mmap */ -static void* mmap_alloc(mstate m, size_t nb) { - size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - if (mmsize > nb) { /* Check for wrap around 0 */ - char* mm = (char*)(DIRECT_MMAP(mmsize)); - if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; - mchunkptr p = (mchunkptr)(mm + offset); - p->prev_foot = offset | IS_MMAPPED_BIT; - (p)->head = (psize|CINUSE_BIT); - mark_inuse_foot(m, p, psize); - chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; - - if (mm < m->least_addr) - m->least_addr = mm; - if ((m->footprint += mmsize) > m->max_footprint) - m->max_footprint = m->footprint; - assert(is_aligned(chunk2mem(p))); - check_mmapped_chunk(m, p); - return chunk2mem(p); - } - } - return 0; -} - -/* Realloc using mmap */ -static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) { - size_t oldsize = chunksize(oldp); - if (is_small(nb)) /* Can't shrink mmap regions below small size */ - return 0; - /* Keep old chunk if big enough but not too big */ - if (oldsize >= nb + SIZE_T_SIZE && - (oldsize - nb) <= (mparams.granularity << 1)) - return oldp; - else { - size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT; - size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; - size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES + - CHUNK_ALIGN_MASK); - char* cp = (char*)CALL_MREMAP((char*)oldp - offset, - oldmmsize, newmmsize, 1); - if (cp != CMFAIL) { - mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; - newp->head = (psize|CINUSE_BIT); - mark_inuse_foot(m, newp, psize); - chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; - - if (cp < m->least_addr) - m->least_addr = cp; - if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) - m->max_footprint = m->footprint; - check_mmapped_chunk(m, newp); - return newp; - } - } - return 0; -} - -/* -------------------------- mspace management -------------------------- */ - -/* Initialize top chunk and its size */ -static void init_top(mstate m, mchunkptr p, size_t psize) { - /* Ensure alignment */ - size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char*)p + offset); - psize -= offset; - - m->top = p; - m->topsize = psize; - p->head = psize | PINUSE_BIT; - /* set size of fake trailing chunk holding overhead space only once */ - chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ -} - -/* Initialize bins for a new mstate that is otherwise zeroed out */ -static void init_bins(mstate m) { - /* Establish circular links for smallbins */ - bindex_t i; - for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at(m,i); - bin->fd = bin->bk = bin; - } -} - -#if PROCEED_ON_ERROR - -/* default corruption action */ -static void reset_on_error(mstate m) { - int i; - ++malloc_corruption_error_count; - /* Reinitialize fields to forget about all memory */ - m->smallbins = m->treebins = 0; - m->dvsize = m->topsize = 0; - m->seg.base = 0; - m->seg.size = 0; - m->seg.next = 0; - m->top = m->dv = 0; - for (i = 0; i < NTREEBINS; ++i) - *treebin_at(m, i) = 0; - init_bins(m); -} -#endif /* PROCEED_ON_ERROR */ - -/* Allocate chunk and prepend remainder with chunk in successor base. */ -static void* prepend_alloc(mstate m, char* newbase, char* oldbase, - size_t nb) { - mchunkptr p = align_as_chunk(newbase); - mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (char*)oldfirst - (char*)p; - mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - - assert((char*)oldfirst > (char*)q); - assert(pinuse(oldfirst)); - assert(qsize >= MIN_CHUNK_SIZE); - - /* consolidate remainder with first chunk of old base */ - if (oldfirst == m->top) { - size_t tsize = m->topsize += qsize; - m->top = q; - q->head = tsize | PINUSE_BIT; - check_top_chunk(m, q); - } - else if (oldfirst == m->dv) { - size_t dsize = m->dvsize += qsize; - m->dv = q; - set_size_and_pinuse_of_free_chunk(q, dsize); - } - else { - if (!cinuse(oldfirst)) { - size_t nsize = chunksize(oldfirst); - unlink_chunk(m, oldfirst, nsize); - oldfirst = chunk_plus_offset(oldfirst, nsize); - qsize += nsize; - } - set_free_with_pinuse(q, qsize, oldfirst); - insert_chunk(m, q, qsize); - check_free_chunk(m, q); - } - - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); -} - - -/* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { - /* Determine locations and sizes of segment, fenceposts, old top */ - char* old_top = (char*)m->top; - msegmentptr oldsp = segment_holding(m, old_top); - char* old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char* asp = rawsp + offset; - char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; - msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; - - /* reset top to new space */ - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - - /* Set up segment record */ - assert(is_aligned(ss)); - set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ - m->seg.base = tbase; - m->seg.size = tsize; - (void)set_segment_flags(&m->seg, mmapped); - m->seg.next = ss; - - /* Insert trailing fenceposts */ - for (;;) { - mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); - p->head = FENCEPOST_HEAD; - ++nfences; - if ((char*)(&(nextp->head)) < old_end) - p = nextp; - else - break; - } - assert(nfences >= 2); - - /* Insert the rest of old top into a bin as an ordinary free chunk */ - if (csp != old_top) { - mchunkptr q = (mchunkptr)old_top; - size_t psize = csp - old_top; - mchunkptr tn = chunk_plus_offset(q, psize); - set_free_with_pinuse(q, psize, tn); - insert_chunk(m, q, psize); - } - - check_top_chunk(m, m->top); -} - -/* -------------------------- System allocation -------------------------- */ - -/* Get memory from system using MORECORE or MMAP */ -static void* sys_alloc(mstate m, size_t nb) { - char* tbase = CMFAIL; - size_t tsize = 0; - flag_t mmap_flag = 0; - - init_mparams(); - - /* Directly map large chunks */ - if (use_mmap(m) && nb >= mparams.mmap_threshold) { - void* mem = mmap_alloc(m, nb); - if (mem != 0) - return mem; - } - - /* - Try getting memory in any of three ways (in most-preferred to - least-preferred order): - 1. A call to MORECORE that can normally contiguously extend memory. - (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or - or main space is mmapped or a previous contiguous call failed) - 2. A call to MMAP new space (disabled if not HAVE_MMAP). - Note that under the default settings, if MORECORE is unable to - fulfill a request, and HAVE_MMAP is true, then mmap is - used as a noncontiguous system allocator. This is a useful backup - strategy for systems with holes in address spaces -- in this case - sbrk cannot contiguously expand the heap, but mmap may be able to - find space. - 3. A call to MORECORE that cannot usually contiguously extend memory. - (disabled if not HAVE_MORECORE) - */ - - if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - char* br = CMFAIL; - msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); - size_t asize = 0; - ACQUIRE_MORECORE_LOCK(); - - if (ss == 0) { /* First time through or recovery */ - char* base = (char*)CALL_MORECORE(0); - if (base != CMFAIL) { - asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); - /* Adjust to end on a page boundary */ - if (!is_page_aligned(base)) - asize += (page_align((size_t)base) - (size_t)base); - /* Can't call MORECORE if size is negative when treated as signed */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == base) { - tbase = base; - tsize = asize; - } - } - } - else { - /* Subtract out existing available top space from MORECORE request. */ - asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE); - /* Use mem here only if it did continuously extend old space */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) { - tbase = br; - tsize = asize; - } - } - - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (asize < HALF_MAX_SIZE_T && - asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) { - size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize); - if (esize < HALF_MAX_SIZE_T) { - char* end = (char*)CALL_MORECORE(esize); - if (end != CMFAIL) - asize += esize; - else { /* Can't use; try to release */ - (void)CALL_MORECORE(-asize); - br = CMFAIL; - } - } - } - } - if (br != CMFAIL) { /* Use the space we did get */ - tbase = br; - tsize = asize; - } - else - disable_contiguous(m); /* Don't try contiguous path in the future */ - } - - RELEASE_MORECORE_LOCK(); - } - - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; - size_t rsize = granularity_align(req); - if (rsize > nb) { /* Fail if wraps around zero */ - char* mp = (char*)(CALL_MMAP(rsize)); - if (mp != CMFAIL) { - tbase = mp; - tsize = rsize; - mmap_flag = IS_MMAPPED_BIT; - } - } - } - - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ - size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); - if (asize < HALF_MAX_SIZE_T) { - char* br = CMFAIL; - char* end = CMFAIL; - ACQUIRE_MORECORE_LOCK(); - br = (char*)(CALL_MORECORE(asize)); - end = (char*)(CALL_MORECORE(0)); - RELEASE_MORECORE_LOCK(); - if (br != CMFAIL && end != CMFAIL && br < end) { - size_t ssize = end - br; - if (ssize > nb + TOP_FOOT_SIZE) { - tbase = br; - tsize = ssize; - } - } - } - } - - if (tbase != CMFAIL) { - - if ((m->footprint += tsize) > m->max_footprint) - m->max_footprint = m->footprint; - - if (!is_initialized(m)) { /* first-time initialization */ - m->seg.base = m->least_addr = tbase; - m->seg.size = tsize; - (void)set_segment_flags(&m->seg, mmap_flag); - m->magic = mparams.magic; - init_bins(m); - if (is_global(m)) - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - else { - /* Offset top by embedded malloc_state */ - mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); - } - } - - else { - /* Try to merge with an existing segment */ - msegmentptr sp = &m->seg; - while (sp != 0 && tbase != sp->base + sp->size) - sp = sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - check_segment_merge(sp, tbase, tsize) && - (get_segment_flags(sp) & IS_MMAPPED_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ - sp->size += tsize; - init_top(m, m->top, m->topsize + tsize); - } - else { - if (tbase < m->least_addr) - m->least_addr = tbase; - sp = &m->seg; - while (sp != 0 && sp->base != tbase + tsize) - sp = sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - check_segment_merge(sp, tbase, tsize) && - (get_segment_flags(sp) & IS_MMAPPED_BIT) == mmap_flag) { - char* oldbase = sp->base; - sp->base = tbase; - sp->size += tsize; - return prepend_alloc(m, tbase, oldbase, nb); - } - else - add_segment(m, tbase, tsize, mmap_flag); - } - } - - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; - mchunkptr p = m->top; - mchunkptr r = m->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - check_top_chunk(m, m->top); - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); - } - } - - MALLOC_FAILURE_ACTION; - return 0; -} - -/* ----------------------- system deallocation -------------------------- */ - -/* Unmap and unlink any mmapped segments that don't contain used chunks */ -static size_t release_unused_segments(mstate m) { - size_t released = 0; - msegmentptr pred = &m->seg; - msegmentptr sp = pred->next; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - msegmentptr next = sp->next; - if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { - mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); - /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { - tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char*)sp)); - if (p == m->dv) { - m->dv = 0; - m->dvsize = 0; - } - else { - unlink_large_chunk(m, tp); - } - if (CALL_MUNMAP(base, size) == 0) { - released += size; - m->footprint -= size; - /* unlink obsoleted record */ - sp = pred; - sp->next = next; - } - else { /* back out if cannot unmap */ - insert_large_chunk(m, tp, psize); - } - } - } - pred = sp; - sp = next; - } - return released; -} - -static int sys_trim(mstate m, size_t pad) { - size_t released = 0; - if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ - - if (m->topsize > pad) { - /* Shrink top space in granularity-size units, keeping at least one */ - size_t unit = mparams.granularity; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char*)m->top); - - if (!is_extern_segment(sp)) { - if (is_mmapped_segment(sp)) { - if (HAVE_MMAP && - sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ - size_t newsize = sp->size - extra; - /* Prefer mremap, fall back to munmap */ - if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || - (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { - released = extra; - } - } - } - else if (HAVE_MORECORE) { - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ - extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; - ACQUIRE_MORECORE_LOCK(); - { - /* Make sure end of memory is where we last set it. */ - char* old_br = (char*)(CALL_MORECORE(0)); - if (old_br == sp->base + sp->size) { - char* rel_br = (char*)(CALL_MORECORE(-extra)); - char* new_br = (char*)(CALL_MORECORE(0)); - if (rel_br != CMFAIL && new_br < old_br) - released = old_br - new_br; - } - } - RELEASE_MORECORE_LOCK(); - } - } - - if (released != 0) { - sp->size -= released; - m->footprint -= released; - init_top(m, m->top, m->topsize - released); - check_top_chunk(m, m->top); - } - } - - /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) - released += release_unused_segments(m); - - /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0) - m->trim_check = MAX_SIZE_T; - } - - return (released != 0)? 1 : 0; -} - -/* ---------------------------- malloc support --------------------------- */ - -/* allocate a large request from the best fitting chunk in a treebin */ -static void* tmalloc_large(mstate m, size_t nb) { - tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ - tchunkptr t; - bindex_t idx; - compute_tree_index(nb, idx); - - if ((t = *treebin_at(m, idx)) != 0) { - /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ - for (;;) { - tchunkptr rt; - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - v = t; - if ((rsize = trem) == 0) - break; - } - rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; - if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ - break; - } - sizebits <<= 1; - } - } - - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ - binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; - if (leftbits != 0) { - bindex_t i; - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - t = *treebin_at(m, i); - } - } - - while (t != 0) { /* find smallest of tree or subtree */ - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - t = leftmost_child(t); - } - - /* If dv is a better fit, return 0 so malloc will use it */ - if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - if (RTCHECK(ok_address(m, v))) { /* split */ - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - insert_chunk(m, r, rsize); - } - return chunk2mem(v); - } - } - CORRUPTION_ERROR_ACTION(m); - } - return 0; -} - -/* allocate a small request from the best fitting chunk in a treebin */ -static void* tmalloc_small(mstate m, size_t nb) { - tchunkptr t, v; - size_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); - compute_bit2idx(leastbit, i); - - v = t = *treebin_at(m, i); - rsize = chunksize(t) - nb; - - while ((t = leftmost_child(t)) != 0) { - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - } - - if (RTCHECK(ok_address(m, v))) { - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(m, r, rsize); - } - return chunk2mem(v); - } - } - - CORRUPTION_ERROR_ACTION(m); - return 0; -} - -/* --------------------------- realloc support --------------------------- */ - -static void* internal_realloc(mstate m, void* oldmem, size_t bytes) { - if (bytes >= MAX_REQUEST) { - MALLOC_FAILURE_ACTION; - return 0; - } - if (!PREACTION(m)) { - mchunkptr oldp = mem2chunk(oldmem); - size_t oldsize = chunksize(oldp); - mchunkptr next = chunk_plus_offset(oldp, oldsize); - mchunkptr newp = 0; - void* extra = 0; - - /* Try to either shrink or extend into top. Else malloc-copy-free */ - - if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) && - ok_next(oldp, next) && ok_pinuse(next))) { - size_t nb = request2size(bytes); - if (is_mmapped(oldp)) - newp = mmap_resize(m, oldp, nb); - else if (oldsize >= nb) { /* already big enough */ - size_t rsize = oldsize - nb; - newp = oldp; - if (rsize >= MIN_CHUNK_SIZE) { - mchunkptr remainder = chunk_plus_offset(newp, nb); - set_inuse(m, newp, nb); - set_inuse(m, remainder, rsize); - extra = chunk2mem(remainder); - } - } - else if (next == m->top && oldsize + m->topsize > nb) { - /* Expand into top */ - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; - mchunkptr newtop = chunk_plus_offset(oldp, nb); - set_inuse(m, oldp, nb); - newtop->head = newtopsize |PINUSE_BIT; - m->top = newtop; - m->topsize = newtopsize; - newp = oldp; - } - } - else { - USAGE_ERROR_ACTION(m, oldmem); - POSTACTION(m); - return 0; - } - - POSTACTION(m); - - if (newp != 0) { - if (extra != 0) { - internal_free(m, extra); - } - check_inuse_chunk(m, newp); - return chunk2mem(newp); - } - else { - void* newmem = internal_malloc(m, bytes); - if (newmem != 0) { - size_t oc = oldsize - overhead_for(oldp); - memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); - internal_free(m, oldmem); - } - return newmem; - } - } - return 0; -} - -/* --------------------------- memalign support -------------------------- */ - -static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { - if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ - return internal_malloc(m, bytes); - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ - alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ - size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) a <<= 1; - alignment = a; - } - - if (bytes >= MAX_REQUEST - alignment) { - if (m != 0) { /* Test isn't needed but avoids compiler warning */ - MALLOC_FAILURE_ACTION; - } - } - else { - size_t nb = request2size(bytes); - size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; - char* mem = (char*)internal_malloc(m, req); - if (mem != 0) { - void* leader = 0; - void* trailer = 0; - mchunkptr p = mem2chunk(mem); - - if (PREACTION(m)) return 0; - if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ - /* - Find an aligned spot inside chunk. Since we need to give - back leading space in a chunk of at least MIN_CHUNK_SIZE, if - the first calculation places us at a spot with less than - MIN_CHUNK_SIZE leader, we can move to the next aligned spot. - We've allocated enough total room so that this is always - possible. - */ - char* br = (char*)mem2chunk((size_t)(((size_t)(mem + - alignment - - SIZE_T_ONE)) & - -alignment)); - char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? - br : br+alignment; - mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char*)(p); - size_t newsize = chunksize(p) - leadsize; - - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ - newp->prev_foot = p->prev_foot + leadsize; - newp->head = (newsize|CINUSE_BIT); - } - else { /* Otherwise, give back leader, use the rest */ - set_inuse(m, newp, newsize); - set_inuse(m, p, leadsize); - leader = chunk2mem(p); - } - p = newp; - } - - /* Give back spare room at the end */ - if (!is_mmapped(p)) { - size_t size = chunksize(p); - if (size > nb + MIN_CHUNK_SIZE) { - size_t remainder_size = size - nb; - mchunkptr remainder = chunk_plus_offset(p, nb); - set_inuse(m, p, nb); - set_inuse(m, remainder, remainder_size); - trailer = chunk2mem(remainder); - } - } - - assert (chunksize(p) >= nb); - assert((((size_t)(chunk2mem(p))) % alignment) == 0); - check_inuse_chunk(m, p); - POSTACTION(m); - if (leader != 0) { - internal_free(m, leader); - } - if (trailer != 0) { - internal_free(m, trailer); - } - return chunk2mem(p); - } - } - return 0; -} - -/* ------------------------ comalloc/coalloc support --------------------- */ - -static void** ialloc(mstate m, - size_t n_elements, - size_t* sizes, - int opts, - void* chunks[]) { - /* - This provides common support for independent_X routines, handling - all of the combinations that can result. - - The opts arg has: - bit 0 set if all elements are same size (using sizes[0]) - bit 1 set if elements should be zeroed - */ - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ - size_t size; - size_t i; - - /* compute array length, if needed */ - if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ - marray = chunks; - array_size = 0; - } - else { - /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (void**)internal_malloc(m, 0); - marray = 0; - array_size = request2size(n_elements * (sizeof(void*))); - } - - /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ - element_size = request2size(*sizes); - contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ - element_size = 0; - contents_size = 0; - for (i = 0; i != n_elements; ++i) - contents_size += request2size(sizes[i]); - } - - size = contents_size + array_size; - - /* - Allocate the aggregate chunk. First disable direct-mmapping so - malloc won't use it, since we would not be able to later - free/realloc space internal to a segregated mmap region. - */ - was_enabled = use_mmap(m); - disable_mmap(m); - mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) - enable_mmap(m); - if (mem == 0) - return 0; - - if (PREACTION(m)) return 0; - p = mem2chunk(mem); - remainder_size = chunksize(p); - - assert(!is_mmapped(p)); - - if (opts & 0x2) { /* optionally clear the elements */ - memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); - } - - /* If not provided, allocate the pointer array as final part of chunk */ - if (marray == 0) { - size_t array_chunk_size; - array_chunk = chunk_plus_offset(p, contents_size); - array_chunk_size = remainder_size - contents_size; - marray = (void**) (chunk2mem(array_chunk)); - set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); - remainder_size = contents_size; - } - - /* split out elements */ - for (i = 0; ; ++i) { - marray[i] = chunk2mem(p); - if (i != n_elements-1) { - if (element_size != 0) - size = element_size; - else - size = request2size(sizes[i]); - remainder_size -= size; - set_size_and_pinuse_of_inuse_chunk(m, p, size); - p = chunk_plus_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ - set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); - break; - } - } - -#if DEBUG - if (marray != chunks) { - /* final element must have exactly exhausted chunk */ - if (element_size != 0) { - assert(remainder_size == element_size); - } - else { - assert(remainder_size == request2size(sizes[i])); - } - check_inuse_chunk(m, mem2chunk(marray)); - } - for (i = 0; i != n_elements; ++i) - check_inuse_chunk(m, mem2chunk(marray[i])); - -#endif /* DEBUG */ - - POSTACTION(m); - return marray; -} - - -/* -------------------------- public routines ---------------------------- */ - -#if !ONLY_MSPACES - -void* dlmalloc(size_t bytes) { - /* - Basic algorithm: - If a small request (< 256 bytes minus per-chunk overhead): - 1. If one exists, use a remainderless chunk in associated smallbin. - (Remainderless means that there are too few excess bytes to - represent as a chunk.) - 2. If it is big enough, use the dv chunk, which is normally the - chunk adjacent to the one used for the most recent small request. - 3. If one exists, split the smallest available chunk in a bin, - saving remainder in dv. - 4. If it is big enough, use the top chunk. - 5. If available, get memory from system and use it - Otherwise, for a large request: - 1. Find the smallest available binned chunk that fits, and use it - if it is better fitting than dv chunk, splitting if necessary. - 2. If better fitting than any binned chunk, use the dv chunk. - 3. If it is big enough, use the top chunk. - 4. If request size >= mmap threshold, try to directly mmap this chunk. - 5. If available, get memory from system and use it - - The ugly goto's here ensure that postaction occurs along all paths. - */ - - if (!PREACTION(gm)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = gm->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(gm, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(gm, b, p, idx); - set_inuse_and_pinuse(gm, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (nb > gm->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(gm, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(gm, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(gm, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(gm, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - - if (nb <= gm->dvsize) { - size_t rsize = gm->dvsize - nb; - mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = gm->dv = chunk_plus_offset(p, nb); - gm->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - } - else { /* exhaust dv */ - size_t dvs = gm->dvsize; - gm->dvsize = 0; - gm->dv = 0; - set_inuse_and_pinuse(gm, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; - mchunkptr p = gm->top; - mchunkptr r = gm->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - mem = chunk2mem(p); - check_top_chunk(gm, gm->top); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - mem = sys_alloc(gm, nb); - - postaction: - POSTACTION(gm); - return mem; - } - - return 0; -} - -void dlfree(void* mem) { - /* - Consolidate freed chunks with preceding or succeeding bordering - free chunks, if they exist, and then place in a bin. Intermixed - with special cases for top, dv, mmapped chunks, and usage errors. - */ - - if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS - mstate fm = get_mstate_for(p); - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } -#else /* FOOTERS */ -#define fm gm -#endif /* FOOTERS */ - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_MMAPPED_BIT) != 0) { - prevsize &= ~IS_MMAPPED_BIT; - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - insert_chunk(fm, p, psize); - check_free_chunk(fm, p); - goto postaction; - } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); - } - } -#if !FOOTERS -#undef fm -#endif /* FOOTERS */ -} - -void* dlcalloc(size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = dlmalloc(req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; -} - -void* dlrealloc(void* oldmem, size_t bytes) { - if (oldmem == 0) - return dlmalloc(bytes); -#ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - dlfree(oldmem); - return 0; - } -#endif /* REALLOC_ZERO_BYTES_FREES */ - else { -#if ! FOOTERS - mstate m = gm; -#else /* FOOTERS */ - mstate m = get_mstate_for(mem2chunk(oldmem)); - if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); - return 0; - } -#endif /* FOOTERS */ - return internal_realloc(m, oldmem, bytes); - } -} - -void* dlmemalign(size_t alignment, size_t bytes) { - return internal_memalign(gm, alignment, bytes); -} - -void** dlindependent_calloc(size_t n_elements, size_t elem_size, - void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - return ialloc(gm, n_elements, &sz, 3, chunks); -} - -void** dlindependent_comalloc(size_t n_elements, size_t sizes[], - void* chunks[]) { - return ialloc(gm, n_elements, sizes, 0, chunks); -} - -void* dlvalloc(size_t bytes) { - size_t pagesz; - init_mparams(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, bytes); -} - -void* dlpvalloc(size_t bytes) { - size_t pagesz; - init_mparams(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); -} - -int dlmalloc_trim(size_t pad) { - int result = 0; - if (!PREACTION(gm)) { - result = sys_trim(gm, pad); - POSTACTION(gm); - } - return result; -} - -size_t dlmalloc_footprint(void) { - return gm->footprint; -} - -size_t dlmalloc_max_footprint(void) { - return gm->max_footprint; -} - -#if !NO_MALLINFO -struct mallinfo dlmallinfo(void) { - return internal_mallinfo(gm); -} -#endif /* NO_MALLINFO */ - -void dlmalloc_stats() { - internal_malloc_stats(gm); -} - -size_t dlmalloc_usable_size(void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (cinuse(p)) - return chunksize(p) - overhead_for(p); - } - return 0; -} - -int dlmallopt(int param_number, int value) { - return change_mparam(param_number, value); -} - -#endif /* !ONLY_MSPACES */ - -/* ----------------------------- user mspaces ---------------------------- */ - -#if MSPACES - -static mstate init_user_mstate(char* tbase, size_t tsize) { - size_t msize = pad_request(sizeof(struct malloc_state)); - mchunkptr mn; - mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); - memset(m, 0, msize); - INITIAL_LOCK(&m->mutex); - msp->head = (msize|PINUSE_BIT|CINUSE_BIT); - m->seg.base = m->least_addr = tbase; - m->seg.size = m->footprint = m->max_footprint = tsize; - m->magic = mparams.magic; - m->mflags = mparams.default_mflags; - disable_contiguous(m); - init_bins(m); - mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); - check_top_chunk(m, m->top); - return m; -} - -mspace create_mspace(size_t capacity, int locked) { - mstate m = 0; - size_t msize = pad_request(sizeof(struct malloc_state)); - init_mparams(); /* Ensure pagesize etc initialized */ - - if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - size_t rs = ((capacity == 0)? mparams.granularity : - (capacity + TOP_FOOT_SIZE + msize)); - size_t tsize = granularity_align(rs); - char* tbase = (char*)(CALL_MMAP(tsize)); - if (tbase != CMFAIL) { - m = init_user_mstate(tbase, tsize); - set_segment_flags(&m->seg, IS_MMAPPED_BIT); - set_lock(m, locked); - } - } - return (mspace)m; -} - -mspace create_mspace_with_base(void* base, size_t capacity, int locked) { - mstate m = 0; - size_t msize = pad_request(sizeof(struct malloc_state)); - init_mparams(); /* Ensure pagesize etc initialized */ - - if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate((char*)base, capacity); - set_segment_flags(&m->seg, EXTERN_BIT); - set_lock(m, locked); - } - return (mspace)m; -} - -size_t destroy_mspace(mspace msp) { - size_t freed = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - msegmentptr sp = &ms->seg; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - flag_t flag = get_segment_flags(sp); - sp = sp->next; - if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) && - CALL_MUNMAP(base, size) == 0) - freed += size; - } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return freed; -} - -/* - mspace versions of routines are near-clones of the global - versions. This is not so nice but better than the alternatives. -*/ - - -void* mspace_malloc(mspace msp, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (!PREACTION(ms)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = ms->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(ms, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(ms, b, p, idx); - set_inuse_and_pinuse(ms, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(ms, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(ms, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(ms, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(ms, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - - if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; - mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = ms->dv = chunk_plus_offset(p, nb); - ms->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } - else { /* exhaust dv */ - size_t dvs = ms->dvsize; - ms->dvsize = 0; - ms->dv = 0; - set_inuse_and_pinuse(ms, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; - mchunkptr p = ms->top; - mchunkptr r = ms->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - mem = chunk2mem(p); - check_top_chunk(ms, ms->top); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - mem = sys_alloc(ms, nb); - - postaction: - POSTACTION(ms); - return mem; - } - - return 0; -} - -void mspace_free(mspace msp, void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS - mstate fm = get_mstate_for(p); -#else /* FOOTERS */ - mstate fm = (mstate)msp; -#endif /* FOOTERS */ - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_MMAPPED_BIT) != 0) { - prevsize &= ~IS_MMAPPED_BIT; - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - insert_chunk(fm, p, psize); - check_free_chunk(fm, p); - goto postaction; - } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); - } - } -} - -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = internal_malloc(ms, req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; -} - -void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { - if (oldmem == 0) - return mspace_malloc(msp, bytes); -#ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - mspace_free(msp, oldmem); - return 0; - } -#endif /* REALLOC_ZERO_BYTES_FREES */ - else { -#if FOOTERS - mchunkptr p = mem2chunk(oldmem); - mstate ms = get_mstate_for(p); -#else /* FOOTERS */ - mstate ms = (mstate)msp; -#endif /* FOOTERS */ - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_realloc(ms, oldmem, bytes); - } -} - -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_memalign(ms, alignment, bytes); -} - -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, &sz, 3, chunks); -} - -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, sizes, 0, chunks); -} - -int mspace_trim(mspace msp, size_t pad) { - int result = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - if (!PREACTION(ms)) { - result = sys_trim(ms, pad); - POSTACTION(ms); - } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return result; -} - -void mspace_malloc_stats(mspace msp) { - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - internal_malloc_stats(ms); - } - else { - USAGE_ERROR_ACTION(ms,ms); - } -} - -size_t mspace_footprint(mspace msp) { - size_t result; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->footprint; - } - USAGE_ERROR_ACTION(ms,ms); - return result; -} - - -size_t mspace_max_footprint(mspace msp) { - size_t result; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->max_footprint; - } - USAGE_ERROR_ACTION(ms,ms); - return result; -} - - -#if !NO_MALLINFO -struct mallinfo mspace_mallinfo(mspace msp) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - } - return internal_mallinfo(ms); -} -#endif /* NO_MALLINFO */ - -int mspace_mallopt(int param_number, int value) { - return change_mparam(param_number, value); -} - -#endif /* MSPACES */ - -/* -------------------- Alternative MORECORE functions ------------------- */ - -/* - Guidelines for creating a custom version of MORECORE: - - * For best performance, MORECORE should allocate in multiples of pagesize. - * MORECORE may allocate more memory than requested. (Or even less, - but this will usually result in a malloc failure.) - * MORECORE must not allocate memory when given argument zero, but - instead return one past the end address of memory from previous - nonzero call. - * For best performance, consecutive calls to MORECORE with positive - arguments should return increasing addresses, indicating that - space has been contiguously extended. - * Even though consecutive calls to MORECORE need not return contiguous - addresses, it must be OK for malloc'ed chunks to span multiple - regions in those cases where they do happen to be contiguous. - * MORECORE need not handle negative arguments -- it may instead - just return MFAIL when given negative arguments. - Negative arguments are always multiples of pagesize. MORECORE - must not misinterpret negative args as large positive unsigned - args. You can suppress all such calls from even occurring by defining - MORECORE_CANNOT_TRIM, - - As an example alternative MORECORE, here is a custom allocator - kindly contributed for pre-OSX macOS. It uses virtually but not - necessarily physically contiguous non-paged memory (locked in, - present and won't get swapped out). You can use it by uncommenting - this section, adding some #includes, and setting up the appropriate - defines above: - - #define MORECORE osMoreCore - - There is also a shutdown routine that should somehow be called for - cleanup upon program exit. - - #define MAX_POOL_ENTRIES 100 - #define MINIMUM_MORECORE_SIZE (64 * 1024U) - static int next_os_pool; - void *our_os_pools[MAX_POOL_ENTRIES]; - - void *osMoreCore(int size) - { - void *ptr = 0; - static void *sbrk_top = 0; - - if (size > 0) - { - if (size < MINIMUM_MORECORE_SIZE) - size = MINIMUM_MORECORE_SIZE; - if (CurrentExecutionLevel() == kTaskLevel) - ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); - if (ptr == 0) - { - return (void *) MFAIL; - } - // save ptrs so they can be freed during cleanup - our_os_pools[next_os_pool] = ptr; - next_os_pool++; - ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); - sbrk_top = (char *) ptr + size; - return ptr; - } - else if (size < 0) - { - // we don't currently support shrink behavior - return (void *) MFAIL; - } - else - { - return sbrk_top; - } - } - - // cleanup any allocated memory pools - // called as last thing before shutting down driver - - void osCleanupMem(void) - { - void **ptr; - - for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) - if (*ptr) - { - PoolDeallocate(*ptr); - *ptr = 0; - } - } - -*/ - - -/* ----------------------------------------------------------------------- -History: - V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) - * Add max_footprint functions - * Ensure all appropriate literals are size_t - * Fix conditional compilation problem for some #define settings - * Avoid concatenating segments with the one provided - in create_mspace_with_base - * Rename some variables to avoid compiler shadowing warnings - * Use explicit lock initialization. - * Better handling of sbrk interference. - * Simplify and fix segment insertion, trimming and mspace_destroy - * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x - * Thanks especially to Dennis Flanagan for help on these. - - V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) - * Fix memalign brace error. - - V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) - * Fix improper #endif nesting in C++ - * Add explicit casts needed for C++ - - V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) - * Use trees for large bins - * Support mspaces - * Use segments to unify sbrk-based and mmap-based system allocation, - removing need for emulation on most platforms without sbrk. - * Default safety checks - * Optional footer checks. Thanks to William Robertson for the idea. - * Internal code refactoring - * Incorporate suggestions and platform-specific changes. - Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, - Aaron Bachmann, Emery Berger, and others. - * Speed up non-fastbin processing enough to remove fastbins. - * Remove useless cfree() to avoid conflicts with other apps. - * Remove internal memcpy, memset. Compilers handle builtins better. - * Remove some options that no one ever used and rename others. - - V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) - * Fix malloc_state bitmap array misdeclaration - - V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) - * Allow tuning of FIRST_SORTED_BIN_SIZE - * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. - * Better detection and support for non-contiguousness of MORECORE. - Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger - * Bypass most of malloc if no frees. Thanks To Emery Berger. - * Fix freeing of old top non-contiguous chunk im sysmalloc. - * Raised default trim and map thresholds to 256K. - * Fix mmap-related #defines. Thanks to Lubos Lunak. - * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. - * Branch-free bin calculation - * Default trim and mmap thresholds now 256K. - - V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) - * Introduce independent_comalloc and independent_calloc. - Thanks to Michael Pachos for motivation and help. - * Make optional .h file available - * Allow > 2GB requests on 32bit systems. - * new WIN32 sbrk, mmap, munmap, lock code from . - Thanks also to Andreas Mueller , - and Anonymous. - * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for - helping test this.) - * memalign: check alignment arg - * realloc: don't try to shift chunks backwards, since this - leads to more fragmentation in some programs and doesn't - seem to help in any others. - * Collect all cases in malloc requiring system memory into sysmalloc - * Use mmap as backup to sbrk - * Place all internal state in malloc_state - * Introduce fastbins (although similar to 2.5.1) - * Many minor tunings and cosmetic improvements - * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK - * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS - Thanks to Tony E. Bennett and others. - * Include errno.h to support default failure action. - - V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) - * return null for negative arguments - * Added Several WIN32 cleanups from Martin C. Fong - * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' - (e.g. WIN32 platforms) - * Cleanup header file inclusion for WIN32 platforms - * Cleanup code to avoid Microsoft Visual C++ compiler complaints - * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing - memory allocation routines - * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) - * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to - usage of 'assert' in non-WIN32 code - * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to - avoid infinite loop - * Always call 'fREe()' rather than 'free()' - - V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) - * Fixed ordering problem with boundary-stamping - - V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) - * Added pvalloc, as recommended by H.J. Liu - * Added 64bit pointer support mainly from Wolfram Gloger - * Added anonymously donated WIN32 sbrk emulation - * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen - * malloc_extend_top: fix mask error that caused wastage after - foreign sbrks - * Add linux mremap support code from HJ Liu - - V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) - * Integrated most documentation with the code. - * Add support for mmap, with help from - Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Use last_remainder in more cases. - * Pack bins using idea from colin@nyx10.cs.du.edu - * Use ordered bins instead of best-fit threshold - * Eliminate block-local decls to simplify tracing and debugging. - * Support another case of realloc via move into top - * Fix error occurring when initial sbrk_base not word-aligned. - * Rely on page size for units instead of SBRK_UNIT to - avoid surprises about sbrk alignment conventions. - * Add mallinfo, mallopt. Thanks to Raymond Nijssen - (raymond@es.ele.tue.nl) for the suggestion. - * Add `pad' argument to malloc_trim and top_pad mallopt parameter. - * More precautions for cases where other routines call sbrk, - courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Added macros etc., allowing use in linux libc from - H.J. Lu (hjl@gnu.ai.mit.edu) - * Inverted this history list - - V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) - * Re-tuned and fixed to behave more nicely with V2.6.0 changes. - * Removed all preallocation code since under current scheme - the work required to undo bad preallocations exceeds - the work saved in good cases for most test programs. - * No longer use return list or unconsolidated bins since - no scheme using them consistently outperforms those that don't - given above changes. - * Use best fit for very large chunks to prevent some worst-cases. - * Added some support for debugging - - V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) - * Removed footers when chunks are in use. Thanks to - Paul Wilson (wilson@cs.texas.edu) for the suggestion. - - V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) - * Added malloc_trim, with help from Wolfram Gloger - (wmglo@Dent.MED.Uni-Muenchen.DE). - - V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) - - V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) - * realloc: try to expand in both directions - * malloc: swap order of clean-bin strategy; - * realloc: only conditionally expand backwards - * Try not to scavenge used bins - * Use bin counts as a guide to preallocation - * Occasionally bin return list chunks in first scan - * Add a few optimizations from colin@nyx10.cs.du.edu - - V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) - * faster bin computation & slightly different binning - * merged all consolidations to one part of malloc proper - (eliminating old malloc_find_space & malloc_clean_bin) - * Scan 2 returns chunks (not just 1) - * Propagate failure in realloc if malloc returns 0 - * Add stuff to allow compilation on non-ANSI compilers - from kpv@research.att.com - - V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) - * removed potential for odd address access in prev_chunk - * removed dependency on getpagesize.h - * misc cosmetics and a bit more internal documentation - * anticosmetics: mangled names in macros to evade debugger strangeness - * tested on sparc, hp-700, dec-mips, rs6000 - with gcc & native cc (hp, dec only) allowing - Detlefs & Zorn comparison study (in SIGPLAN Notices.) - - Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) - * Based loosely on libg++-1.2X malloc. (It retains some of the overall - structure of old version, but most details differ.) - -*/ diff --git a/user/mpy/lib/libffi/src/frv/eabi.S b/user/mpy/lib/libffi/src/frv/eabi.S deleted file mode 100644 index 379ea4b..0000000 --- a/user/mpy/lib/libffi/src/frv/eabi.S +++ /dev/null @@ -1,128 +0,0 @@ -/* ----------------------------------------------------------------------- - eabi.S - Copyright (c) 2004 Anthony Green - - FR-V Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - .globl ffi_prep_args_EABI - - .text - .p2align 4 - .globl ffi_call_EABI - .type ffi_call_EABI, @function - - # gr8 : ffi_prep_args - # gr9 : &ecif - # gr10: cif->bytes - # gr11: fig->flags - # gr12: ecif.rvalue - # gr13: fn - -ffi_call_EABI: - addi sp, #-80, sp - sti fp, @(sp, #24) - addi sp, #24, fp - movsg lr, gr5 - - /* Make room for the new arguments. */ - /* subi sp, fp, gr10 */ - - /* Store return address and incoming args on stack. */ - sti gr5, @(fp, #8) - sti gr8, @(fp, #-4) - sti gr9, @(fp, #-8) - sti gr10, @(fp, #-12) - sti gr11, @(fp, #-16) - sti gr12, @(fp, #-20) - sti gr13, @(fp, #-24) - - sub sp, gr10, sp - - /* Call ffi_prep_args. */ - ldi @(fp, #-4), gr4 - addi sp, #0, gr8 - ldi @(fp, #-8), gr9 -#ifdef __FRV_FDPIC__ - ldd @(gr4, gr0), gr14 - calll @(gr14, gr0) -#else - calll @(gr4, gr0) -#endif - - /* ffi_prep_args returns the new stack pointer. */ - mov gr8, gr4 - - ldi @(sp, #0), gr8 - ldi @(sp, #4), gr9 - ldi @(sp, #8), gr10 - ldi @(sp, #12), gr11 - ldi @(sp, #16), gr12 - ldi @(sp, #20), gr13 - - /* Always copy the return value pointer into the hidden - parameter register. This is only strictly necessary - when we're returning an aggregate type, but it doesn't - hurt to do this all the time, and it saves a branch. */ - ldi @(fp, #-20), gr3 - - /* Use the ffi_prep_args return value for the new sp. */ - mov gr4, sp - - /* Call the target function. */ - ldi @(fp, -24), gr4 -#ifdef __FRV_FDPIC__ - ldd @(gr4, gr0), gr14 - calll @(gr14, gr0) -#else - calll @(gr4, gr0) -#endif - - /* Store the result. */ - ldi @(fp, #-16), gr10 /* fig->flags */ - ldi @(fp, #-20), gr4 /* ecif.rvalue */ - - /* Is the return value stored in two registers? */ - cmpi gr10, #8, icc0 - bne icc0, 0, .L2 - /* Yes, save them. */ - sti gr8, @(gr4, #0) - sti gr9, @(gr4, #4) - bra .L3 -.L2: - /* Is the return value a structure? */ - cmpi gr10, #-1, icc0 - beq icc0, 0, .L3 - /* No, save a 4 byte return value. */ - sti gr8, @(gr4, #0) -.L3: - - /* Restore the stack, and return. */ - ldi @(fp, 8), gr5 - ld @(fp, gr0), fp - addi sp,#80,sp - jmpl @(gr5,gr0) - .size ffi_call_EABI, .-ffi_call_EABI - diff --git a/user/mpy/lib/libffi/src/frv/ffi.c b/user/mpy/lib/libffi/src/frv/ffi.c deleted file mode 100644 index 5698c89..0000000 --- a/user/mpy/lib/libffi/src/frv/ffi.c +++ /dev/null @@ -1,292 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2004 Anthony Green - Copyright (C) 2007 Free Software Foundation, Inc. - Copyright (C) 2008 Red Hat, Inc. - - FR-V Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void *ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - register int count = 0; - - p_argv = ecif->avalue; - argp = stack; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); - i--, p_arg++) - { - size_t z; - - z = (*p_arg)->size; - - if ((*p_arg)->type == FFI_TYPE_STRUCT) - { - z = sizeof(void*); - *(void **) argp = *p_argv; - } - /* if ((*p_arg)->type == FFI_TYPE_FLOAT) - { - if (count > 24) - { - // This is going on the stack. Turn it into a double. - *(double *) argp = (double) *(float*)(* p_argv); - z = sizeof(double); - } - else - *(void **) argp = *(void **)(* p_argv); - } */ - else if (z < sizeof(int)) - { - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - default: - FFI_ASSERT(0); - } - } - else if (z == sizeof(int)) - { - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - } - else - { - memcpy(argp, *p_argv, z); - } - p_argv++; - argp += z; - count += z; - } - - return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8))); -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - if (cif->rtype->type == FFI_TYPE_STRUCT) - cif->flags = -1; - else - cif->flags = cif->rtype->size; - - cif->bytes = ALIGN (cif->bytes, 8); - - return FFI_OK; -} - -extern void ffi_call_EABI(void *(*)(char *, extended_cif *), - extended_cif *, - unsigned, unsigned, - unsigned *, - void (*fn)(void)); - -void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - - switch (cif->abi) - { - case FFI_EABI: - ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - -void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, - unsigned arg4, unsigned arg5, unsigned arg6) -{ - /* This function is called by a trampoline. The trampoline stows a - pointer to the ffi_closure object in gr7. We must save this - pointer in a place that will persist while we do our work. */ - register ffi_closure *creg __asm__ ("gr7"); - ffi_closure *closure = creg; - - /* Arguments that don't fit in registers are found on the stack - at a fixed offset above the current frame pointer. */ - register char *frame_pointer __asm__ ("fp"); - char *stack_args = frame_pointer + 16; - - /* Lay the register arguments down in a continuous chunk of memory. */ - unsigned register_args[6] = - { arg1, arg2, arg3, arg4, arg5, arg6 }; - - ffi_cif *cif = closure->cif; - ffi_type **arg_types = cif->arg_types; - void **avalue = alloca (cif->nargs * sizeof(void *)); - char *ptr = (char *) register_args; - int i; - - /* Find the address of each argument. */ - for (i = 0; i < cif->nargs; i++) - { - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - avalue[i] = ptr + 3; - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - avalue[i] = ptr + 2; - break; - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - avalue[i] = ptr; - break; - case FFI_TYPE_STRUCT: - avalue[i] = *(void**)ptr; - break; - default: - /* This is an 8-byte value. */ - avalue[i] = ptr; - ptr += 4; - break; - } - ptr += 4; - - /* If we've handled more arguments than fit in registers, - start looking at the those passed on the stack. */ - if (ptr == ((char *)register_args + (6*4))) - ptr = stack_args; - } - - /* Invoke the closure. */ - if (cif->rtype->type == FFI_TYPE_STRUCT) - { - /* The caller allocates space for the return structure, and - passes a pointer to this space in gr3. Use this value directly - as the return value. */ - register void *return_struct_ptr __asm__("gr3"); - (closure->fun) (cif, return_struct_ptr, avalue, closure->user_data); - } - else - { - /* Allocate space for the return value and call the function. */ - long long rvalue; - (closure->fun) (cif, &rvalue, avalue, closure->user_data); - - /* Functions return 4-byte or smaller results in gr8. 8-byte - values also use gr9. We fill the both, even for small return - values, just to avoid a branch. */ - asm ("ldi @(%0, #0), gr8" : : "r" (&rvalue)); - asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1])); - } -} - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp = (unsigned int *) &closure->tramp[0]; - unsigned long fn = (long) ffi_closure_eabi; - unsigned long cls = (long) codeloc; -#ifdef __FRV_FDPIC__ - register void *got __asm__("gr15"); -#endif - int i; - - fn = (unsigned long) ffi_closure_eabi; - -#ifdef __FRV_FDPIC__ - tramp[0] = &((unsigned int *)codeloc)[2]; - tramp[1] = got; - tramp[2] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */ - tramp[3] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */ - tramp[4] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */ - tramp[5] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */ - tramp[6] = 0x9cc86000; /* ldi @(gr6, #0), gr14 */ - tramp[7] = 0x8030e000; /* jmpl @(gr14, gr0) */ -#else - tramp[0] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */ - tramp[1] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */ - tramp[2] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */ - tramp[3] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */ - tramp[4] = 0x80300006; /* jmpl @(gr0, gr6) */ -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - /* Cache flushing. */ - for (i = 0; i < FFI_TRAMPOLINE_SIZE; i++) - __asm__ volatile ("dcf @(%0,%1)\n\tici @(%2,%1)" :: "r" (tramp), "r" (i), - "r" (codeloc)); - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/frv/ffitarget.h b/user/mpy/lib/libffi/src/frv/ffitarget.h deleted file mode 100644 index d42540e..0000000 --- a/user/mpy/lib/libffi/src/frv/ffitarget.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2004 Red Hat, Inc. - Target configuration macros for FR-V - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_EABI, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_EABI -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -#ifdef __FRV_FDPIC__ -/* Trampolines are 8 4-byte instructions long. */ -#define FFI_TRAMPOLINE_SIZE (8*4) -#else -/* Trampolines are 5 4-byte instructions long. */ -#define FFI_TRAMPOLINE_SIZE (5*4) -#endif - -#endif diff --git a/user/mpy/lib/libffi/src/ia64/ffi.c b/user/mpy/lib/libffi/src/ia64/ffi.c deleted file mode 100644 index b77a836..0000000 --- a/user/mpy/lib/libffi/src/ia64/ffi.c +++ /dev/null @@ -1,586 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 1998, 2007, 2008, 2012 Red Hat, Inc. - Copyright (c) 2000 Hewlett Packard Company - Copyright (c) 2011 Anthony Green - - IA64 Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include -#include -#include - -#include "ia64_flags.h" - -/* A 64-bit pointer value. In LP64 mode, this is effectively a plain - pointer. In ILP32 mode, it's a pointer that's been extended to - 64 bits by "addp4". */ -typedef void *PTR64 __attribute__((mode(DI))); - -/* Memory image of fp register contents. This is the implementation - specific format used by ldf.fill/stf.spill. All we care about is - that it wants a 16 byte aligned slot. */ -typedef struct -{ - UINT64 x[2] __attribute__((aligned(16))); -} fpreg; - - -/* The stack layout given to ffi_call_unix and ffi_closure_unix_inner. */ - -struct ia64_args -{ - fpreg fp_regs[8]; /* Contents of 8 fp arg registers. */ - UINT64 gp_regs[8]; /* Contents of 8 gp arg registers. */ - UINT64 other_args[]; /* Arguments passed on stack, variable size. */ -}; - - -/* Adjust ADDR, a pointer to an 8 byte slot, to point to the low LEN bytes. */ - -static inline void * -endian_adjust (void *addr, size_t len) -{ -#ifdef __BIG_ENDIAN__ - return addr + (8 - len); -#else - return addr; -#endif -} - -/* Store VALUE to ADDR in the current cpu implementation's fp spill format. - This is a macro instead of a function, so that it works for all 3 floating - point types without type conversions. Type conversion to long double breaks - the denorm support. */ - -#define stf_spill(addr, value) \ - asm ("stf.spill %0 = %1%P0" : "=m" (*addr) : "f"(value)); - -/* Load a value from ADDR, which is in the current cpu implementation's - fp spill format. As above, this must also be a macro. */ - -#define ldf_fill(result, addr) \ - asm ("ldf.fill %0 = %1%P1" : "=f"(result) : "m"(*addr)); - -/* Return the size of the C type associated with with TYPE. Which will - be one of the FFI_IA64_TYPE_HFA_* values. */ - -static size_t -hfa_type_size (int type) -{ - switch (type) - { - case FFI_IA64_TYPE_HFA_FLOAT: - return sizeof(float); - case FFI_IA64_TYPE_HFA_DOUBLE: - return sizeof(double); - case FFI_IA64_TYPE_HFA_LDOUBLE: - return sizeof(__float80); - default: - abort (); - } -} - -/* Load from ADDR a value indicated by TYPE. Which will be one of - the FFI_IA64_TYPE_HFA_* values. */ - -static void -hfa_type_load (fpreg *fpaddr, int type, void *addr) -{ - switch (type) - { - case FFI_IA64_TYPE_HFA_FLOAT: - stf_spill (fpaddr, *(float *) addr); - return; - case FFI_IA64_TYPE_HFA_DOUBLE: - stf_spill (fpaddr, *(double *) addr); - return; - case FFI_IA64_TYPE_HFA_LDOUBLE: - stf_spill (fpaddr, *(__float80 *) addr); - return; - default: - abort (); - } -} - -/* Load VALUE into ADDR as indicated by TYPE. Which will be one of - the FFI_IA64_TYPE_HFA_* values. */ - -static void -hfa_type_store (int type, void *addr, fpreg *fpaddr) -{ - switch (type) - { - case FFI_IA64_TYPE_HFA_FLOAT: - { - float result; - ldf_fill (result, fpaddr); - *(float *) addr = result; - break; - } - case FFI_IA64_TYPE_HFA_DOUBLE: - { - double result; - ldf_fill (result, fpaddr); - *(double *) addr = result; - break; - } - case FFI_IA64_TYPE_HFA_LDOUBLE: - { - __float80 result; - ldf_fill (result, fpaddr); - *(__float80 *) addr = result; - break; - } - default: - abort (); - } -} - -/* Is TYPE a struct containing floats, doubles, or extended doubles, - all of the same fp type? If so, return the element type. Return - FFI_TYPE_VOID if not. */ - -static int -hfa_element_type (ffi_type *type, int nested) -{ - int element = FFI_TYPE_VOID; - - switch (type->type) - { - case FFI_TYPE_FLOAT: - /* We want to return VOID for raw floating-point types, but the - synthetic HFA type if we're nested within an aggregate. */ - if (nested) - element = FFI_IA64_TYPE_HFA_FLOAT; - break; - - case FFI_TYPE_DOUBLE: - /* Similarly. */ - if (nested) - element = FFI_IA64_TYPE_HFA_DOUBLE; - break; - - case FFI_TYPE_LONGDOUBLE: - /* Similarly, except that that HFA is true for double extended, - but not quad precision. Both have sizeof == 16, so tell the - difference based on the precision. */ - if (LDBL_MANT_DIG == 64 && nested) - element = FFI_IA64_TYPE_HFA_LDOUBLE; - break; - - case FFI_TYPE_STRUCT: - { - ffi_type **ptr = &type->elements[0]; - - for (ptr = &type->elements[0]; *ptr ; ptr++) - { - int sub_element = hfa_element_type (*ptr, 1); - if (sub_element == FFI_TYPE_VOID) - return FFI_TYPE_VOID; - - if (element == FFI_TYPE_VOID) - element = sub_element; - else if (element != sub_element) - return FFI_TYPE_VOID; - } - } - break; - - default: - return FFI_TYPE_VOID; - } - - return element; -} - - -/* Perform machine dependent cif processing. */ - -ffi_status -ffi_prep_cif_machdep(ffi_cif *cif) -{ - int flags; - - /* Adjust cif->bytes to include space for the bits of the ia64_args frame - that precedes the integer register portion. The estimate that the - generic bits did for the argument space required is good enough for the - integer component. */ - cif->bytes += offsetof(struct ia64_args, gp_regs[0]); - if (cif->bytes < sizeof(struct ia64_args)) - cif->bytes = sizeof(struct ia64_args); - - /* Set the return type flag. */ - flags = cif->rtype->type; - switch (cif->rtype->type) - { - case FFI_TYPE_LONGDOUBLE: - /* Leave FFI_TYPE_LONGDOUBLE as meaning double extended precision, - and encode quad precision as a two-word integer structure. */ - if (LDBL_MANT_DIG != 64) - flags = FFI_IA64_TYPE_SMALL_STRUCT | (16 << 8); - break; - - case FFI_TYPE_STRUCT: - { - size_t size = cif->rtype->size; - int hfa_type = hfa_element_type (cif->rtype, 0); - - if (hfa_type != FFI_TYPE_VOID) - { - size_t nelts = size / hfa_type_size (hfa_type); - if (nelts <= 8) - flags = hfa_type | (size << 8); - } - else - { - if (size <= 32) - flags = FFI_IA64_TYPE_SMALL_STRUCT | (size << 8); - } - } - break; - - default: - break; - } - cif->flags = flags; - - return FFI_OK; -} - -extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(void), UINT64); - -void -ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - struct ia64_args *stack; - long i, avn, gpcount, fpcount; - ffi_type **p_arg; - - FFI_ASSERT (cif->abi == FFI_UNIX); - - /* If we have no spot for a return value, make one. */ - if (rvalue == NULL && cif->rtype->type != FFI_TYPE_VOID) - rvalue = alloca (cif->rtype->size); - - /* Allocate the stack frame. */ - stack = alloca (cif->bytes); - - gpcount = fpcount = 0; - avn = cif->nargs; - for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) - { - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - stack->gp_regs[gpcount++] = *(SINT8 *)avalue[i]; - break; - case FFI_TYPE_UINT8: - stack->gp_regs[gpcount++] = *(UINT8 *)avalue[i]; - break; - case FFI_TYPE_SINT16: - stack->gp_regs[gpcount++] = *(SINT16 *)avalue[i]; - break; - case FFI_TYPE_UINT16: - stack->gp_regs[gpcount++] = *(UINT16 *)avalue[i]; - break; - case FFI_TYPE_SINT32: - stack->gp_regs[gpcount++] = *(SINT32 *)avalue[i]; - break; - case FFI_TYPE_UINT32: - stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i]; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i]; - break; - - case FFI_TYPE_POINTER: - stack->gp_regs[gpcount++] = (UINT64)(PTR64) *(void **)avalue[i]; - break; - - case FFI_TYPE_FLOAT: - if (gpcount < 8 && fpcount < 8) - stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]); - { - UINT32 tmp; - memcpy (&tmp, avalue[i], sizeof (UINT32)); - stack->gp_regs[gpcount++] = tmp; - } - break; - - case FFI_TYPE_DOUBLE: - if (gpcount < 8 && fpcount < 8) - stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]); - memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64)); - break; - - case FFI_TYPE_LONGDOUBLE: - if (gpcount & 1) - gpcount++; - if (LDBL_MANT_DIG == 64 && gpcount < 8 && fpcount < 8) - stf_spill (&stack->fp_regs[fpcount++], *(__float80 *)avalue[i]); - memcpy (&stack->gp_regs[gpcount], avalue[i], 16); - gpcount += 2; - break; - - case FFI_TYPE_STRUCT: - { - size_t size = (*p_arg)->size; - size_t align = (*p_arg)->alignment; - int hfa_type = hfa_element_type (*p_arg, 0); - - FFI_ASSERT (align <= 16); - if (align == 16 && (gpcount & 1)) - gpcount++; - - if (hfa_type != FFI_TYPE_VOID) - { - size_t hfa_size = hfa_type_size (hfa_type); - size_t offset = 0; - size_t gp_offset = gpcount * 8; - - while (fpcount < 8 - && offset < size - && gp_offset < 8 * 8) - { - hfa_type_load (&stack->fp_regs[fpcount], hfa_type, - avalue[i] + offset); - offset += hfa_size; - gp_offset += hfa_size; - fpcount += 1; - } - } - - memcpy (&stack->gp_regs[gpcount], avalue[i], size); - gpcount += (size + 7) / 8; - } - break; - - default: - abort (); - } - } - - ffi_call_unix (stack, rvalue, fn, cif->flags); -} - -/* Closures represent a pair consisting of a function pointer, and - some user data. A closure is invoked by reinterpreting the closure - as a function pointer, and branching to it. Thus we can make an - interpreted function callable as a C function: We turn the - interpreter itself, together with a pointer specifying the - interpreted procedure, into a closure. - - For IA64, function pointer are already pairs consisting of a code - pointer, and a gp pointer. The latter is needed to access global - variables. Here we set up such a pair as the first two words of - the closure (in the "trampoline" area), but we replace the gp - pointer with a pointer to the closure itself. We also add the real - gp pointer to the closure. This allows the function entry code to - both retrieve the user data, and to restore the correct gp pointer. */ - -extern void ffi_closure_unix (); - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - /* The layout of a function descriptor. A C function pointer really - points to one of these. */ - struct ia64_fd - { - UINT64 code_pointer; - UINT64 gp; - }; - - struct ffi_ia64_trampoline_struct - { - UINT64 code_pointer; /* Pointer to ffi_closure_unix. */ - UINT64 fake_gp; /* Pointer to closure, installed as gp. */ - UINT64 real_gp; /* Real gp value. */ - }; - - struct ffi_ia64_trampoline_struct *tramp; - struct ia64_fd *fd; - - if (cif->abi != FFI_UNIX) - return FFI_BAD_ABI; - - tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp; - fd = (struct ia64_fd *)(void *)ffi_closure_unix; - - tramp->code_pointer = fd->code_pointer; - tramp->real_gp = fd->gp; - tramp->fake_gp = (UINT64)(PTR64)codeloc; - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - - -UINT64 -ffi_closure_unix_inner (ffi_closure *closure, struct ia64_args *stack, - void *rvalue, void *r8) -{ - ffi_cif *cif; - void **avalue; - ffi_type **p_arg; - long i, avn, gpcount, fpcount; - - cif = closure->cif; - avn = cif->nargs; - avalue = alloca (avn * sizeof (void *)); - - /* If the structure return value is passed in memory get that location - from r8 so as to pass the value directly back to the caller. */ - if (cif->flags == FFI_TYPE_STRUCT) - rvalue = r8; - - gpcount = fpcount = 0; - for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) - { - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 1); - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 2); - break; - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 4); - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - avalue[i] = &stack->gp_regs[gpcount++]; - break; - case FFI_TYPE_POINTER: - avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], sizeof(void*)); - break; - - case FFI_TYPE_FLOAT: - if (gpcount < 8 && fpcount < 8) - { - fpreg *addr = &stack->fp_regs[fpcount++]; - float result; - avalue[i] = addr; - ldf_fill (result, addr); - *(float *)addr = result; - } - else - avalue[i] = endian_adjust(&stack->gp_regs[gpcount], 4); - gpcount++; - break; - - case FFI_TYPE_DOUBLE: - if (gpcount < 8 && fpcount < 8) - { - fpreg *addr = &stack->fp_regs[fpcount++]; - double result; - avalue[i] = addr; - ldf_fill (result, addr); - *(double *)addr = result; - } - else - avalue[i] = &stack->gp_regs[gpcount]; - gpcount++; - break; - - case FFI_TYPE_LONGDOUBLE: - if (gpcount & 1) - gpcount++; - if (LDBL_MANT_DIG == 64 && gpcount < 8 && fpcount < 8) - { - fpreg *addr = &stack->fp_regs[fpcount++]; - __float80 result; - avalue[i] = addr; - ldf_fill (result, addr); - *(__float80 *)addr = result; - } - else - avalue[i] = &stack->gp_regs[gpcount]; - gpcount += 2; - break; - - case FFI_TYPE_STRUCT: - { - size_t size = (*p_arg)->size; - size_t align = (*p_arg)->alignment; - int hfa_type = hfa_element_type (*p_arg, 0); - - FFI_ASSERT (align <= 16); - if (align == 16 && (gpcount & 1)) - gpcount++; - - if (hfa_type != FFI_TYPE_VOID) - { - size_t hfa_size = hfa_type_size (hfa_type); - size_t offset = 0; - size_t gp_offset = gpcount * 8; - void *addr = alloca (size); - - avalue[i] = addr; - - while (fpcount < 8 - && offset < size - && gp_offset < 8 * 8) - { - hfa_type_store (hfa_type, addr + offset, - &stack->fp_regs[fpcount]); - offset += hfa_size; - gp_offset += hfa_size; - fpcount += 1; - } - - if (offset < size) - memcpy (addr + offset, (char *)stack->gp_regs + gp_offset, - size - offset); - } - else - avalue[i] = &stack->gp_regs[gpcount]; - - gpcount += (size + 7) / 8; - } - break; - - default: - abort (); - } - } - - closure->fun (cif, rvalue, avalue, closure->user_data); - - return cif->flags; -} diff --git a/user/mpy/lib/libffi/src/ia64/ffitarget.h b/user/mpy/lib/libffi/src/ia64/ffitarget.h deleted file mode 100644 index e68cea6..0000000 --- a/user/mpy/lib/libffi/src/ia64/ffitarget.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for IA-64. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long long ffi_arg; -typedef signed long long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_UNIX, /* Linux and all Unix variants use the same conventions */ - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_UNIX -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 24 /* Really the following struct, which */ - /* can be interpreted as a C function */ - /* descriptor: */ - -#endif - diff --git a/user/mpy/lib/libffi/src/ia64/ia64_flags.h b/user/mpy/lib/libffi/src/ia64/ia64_flags.h deleted file mode 100644 index 9d652ce..0000000 --- a/user/mpy/lib/libffi/src/ia64/ia64_flags.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ----------------------------------------------------------------------- - ia64_flags.h - Copyright (c) 2000 Hewlett Packard Company - - IA64/unix Foreign Function Interface - - Original author: Hans Boehm, HP Labs - - 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. - ----------------------------------------------------------------------- */ - -/* "Type" codes used between assembly and C. When used as a part of - a cfi->flags value, the low byte will be these extra type codes, - and bits 8-31 will be the actual size of the type. */ - -/* Small structures containing N words in integer registers. */ -#define FFI_IA64_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 1) - -/* Homogeneous Floating Point Aggregates (HFAs) which are returned - in FP registers. */ -#define FFI_IA64_TYPE_HFA_FLOAT (FFI_TYPE_LAST + 2) -#define FFI_IA64_TYPE_HFA_DOUBLE (FFI_TYPE_LAST + 3) -#define FFI_IA64_TYPE_HFA_LDOUBLE (FFI_TYPE_LAST + 4) diff --git a/user/mpy/lib/libffi/src/ia64/unix.S b/user/mpy/lib/libffi/src/ia64/unix.S deleted file mode 100644 index 4d2a86d..0000000 --- a/user/mpy/lib/libffi/src/ia64/unix.S +++ /dev/null @@ -1,560 +0,0 @@ -/* ----------------------------------------------------------------------- - unix.S - Copyright (c) 1998, 2008 Red Hat, Inc. - Copyright (c) 2000 Hewlett Packard Company - - IA64/unix Foreign Function Interface - - Primary author: Hans Boehm, HP Labs - - Loosely modeled on Cygnus code for other platforms. - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#include "ia64_flags.h" - - .pred.safe_across_calls p1-p5,p16-p63 -.text - -/* int ffi_call_unix (struct ia64_args *stack, PTR64 rvalue, - void (*fn)(void), int flags); - */ - - .align 16 - .global ffi_call_unix - .proc ffi_call_unix -ffi_call_unix: - .prologue - /* Bit o trickiness. We actually share a stack frame with ffi_call. - Rely on the fact that ffi_call uses a vframe and don't bother - tracking one here at all. */ - .fframe 0 - .save ar.pfs, r36 // loc0 - alloc loc0 = ar.pfs, 4, 3, 8, 0 - .save rp, loc1 - mov loc1 = b0 - .body - add r16 = 16, in0 - mov loc2 = gp - mov r8 = in1 - ;; - - /* Load up all of the argument registers. */ - ldf.fill f8 = [in0], 32 - ldf.fill f9 = [r16], 32 - ;; - ldf.fill f10 = [in0], 32 - ldf.fill f11 = [r16], 32 - ;; - ldf.fill f12 = [in0], 32 - ldf.fill f13 = [r16], 32 - ;; - ldf.fill f14 = [in0], 32 - ldf.fill f15 = [r16], 24 - ;; - ld8 out0 = [in0], 16 - ld8 out1 = [r16], 16 - ;; - ld8 out2 = [in0], 16 - ld8 out3 = [r16], 16 - ;; - ld8 out4 = [in0], 16 - ld8 out5 = [r16], 16 - ;; - ld8 out6 = [in0] - ld8 out7 = [r16] - ;; - - /* Deallocate the register save area from the stack frame. */ - mov sp = in0 - - /* Call the target function. */ - ld8 r16 = [in2], 8 - ;; - ld8 gp = [in2] - mov b6 = r16 - br.call.sptk.many b0 = b6 - ;; - - /* Dispatch to handle return value. */ - mov gp = loc2 - zxt1 r16 = in3 - ;; - mov ar.pfs = loc0 - addl r18 = @ltoffx(.Lst_table), gp - ;; - ld8.mov r18 = [r18], .Lst_table - mov b0 = loc1 - ;; - shladd r18 = r16, 3, r18 - ;; - ld8 r17 = [r18] - shr in3 = in3, 8 - ;; - add r17 = r17, r18 - ;; - mov b6 = r17 - br b6 - ;; - -.Lst_void: - br.ret.sptk.many b0 - ;; -.Lst_uint8: - zxt1 r8 = r8 - ;; - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_sint8: - sxt1 r8 = r8 - ;; - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_uint16: - zxt2 r8 = r8 - ;; - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_sint16: - sxt2 r8 = r8 - ;; - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_uint32: - zxt4 r8 = r8 - ;; - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_sint32: - sxt4 r8 = r8 - ;; - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_int64: - st8 [in1] = r8 - br.ret.sptk.many b0 - ;; -.Lst_float: - stfs [in1] = f8 - br.ret.sptk.many b0 - ;; -.Lst_double: - stfd [in1] = f8 - br.ret.sptk.many b0 - ;; -.Lst_ldouble: - stfe [in1] = f8 - br.ret.sptk.many b0 - ;; - -.Lst_small_struct: - add sp = -16, sp - cmp.lt p6, p0 = 8, in3 - cmp.lt p7, p0 = 16, in3 - cmp.lt p8, p0 = 24, in3 - ;; - add r16 = 8, sp - add r17 = 16, sp - add r18 = 24, sp - ;; - st8 [sp] = r8 -(p6) st8 [r16] = r9 - mov out0 = in1 -(p7) st8 [r17] = r10 -(p8) st8 [r18] = r11 - mov out1 = sp - mov out2 = in3 - br.call.sptk.many b0 = memcpy# - ;; - mov ar.pfs = loc0 - mov b0 = loc1 - mov gp = loc2 - br.ret.sptk.many b0 - -.Lst_hfa_float: - add r16 = 4, in1 - cmp.lt p6, p0 = 4, in3 - ;; - stfs [in1] = f8, 8 -(p6) stfs [r16] = f9, 8 - cmp.lt p7, p0 = 8, in3 - cmp.lt p8, p0 = 12, in3 - ;; -(p7) stfs [in1] = f10, 8 -(p8) stfs [r16] = f11, 8 - cmp.lt p9, p0 = 16, in3 - cmp.lt p10, p0 = 20, in3 - ;; -(p9) stfs [in1] = f12, 8 -(p10) stfs [r16] = f13, 8 - cmp.lt p6, p0 = 24, in3 - cmp.lt p7, p0 = 28, in3 - ;; -(p6) stfs [in1] = f14 -(p7) stfs [r16] = f15 - br.ret.sptk.many b0 - ;; - -.Lst_hfa_double: - add r16 = 8, in1 - cmp.lt p6, p0 = 8, in3 - ;; - stfd [in1] = f8, 16 -(p6) stfd [r16] = f9, 16 - cmp.lt p7, p0 = 16, in3 - cmp.lt p8, p0 = 24, in3 - ;; -(p7) stfd [in1] = f10, 16 -(p8) stfd [r16] = f11, 16 - cmp.lt p9, p0 = 32, in3 - cmp.lt p10, p0 = 40, in3 - ;; -(p9) stfd [in1] = f12, 16 -(p10) stfd [r16] = f13, 16 - cmp.lt p6, p0 = 48, in3 - cmp.lt p7, p0 = 56, in3 - ;; -(p6) stfd [in1] = f14 -(p7) stfd [r16] = f15 - br.ret.sptk.many b0 - ;; - -.Lst_hfa_ldouble: - add r16 = 16, in1 - cmp.lt p6, p0 = 16, in3 - ;; - stfe [in1] = f8, 32 -(p6) stfe [r16] = f9, 32 - cmp.lt p7, p0 = 32, in3 - cmp.lt p8, p0 = 48, in3 - ;; -(p7) stfe [in1] = f10, 32 -(p8) stfe [r16] = f11, 32 - cmp.lt p9, p0 = 64, in3 - cmp.lt p10, p0 = 80, in3 - ;; -(p9) stfe [in1] = f12, 32 -(p10) stfe [r16] = f13, 32 - cmp.lt p6, p0 = 96, in3 - cmp.lt p7, p0 = 112, in3 - ;; -(p6) stfe [in1] = f14 -(p7) stfe [r16] = f15 - br.ret.sptk.many b0 - ;; - - .endp ffi_call_unix - - .align 16 - .global ffi_closure_unix - .proc ffi_closure_unix - -#define FRAME_SIZE (8*16 + 8*8 + 8*16) - -ffi_closure_unix: - .prologue - .save ar.pfs, r40 // loc0 - alloc loc0 = ar.pfs, 8, 4, 4, 0 - .fframe FRAME_SIZE - add r12 = -FRAME_SIZE, r12 - .save rp, loc1 - mov loc1 = b0 - .save ar.unat, loc2 - mov loc2 = ar.unat - .body - - /* Retrieve closure pointer and real gp. */ -#ifdef _ILP32 - addp4 out0 = 0, gp - addp4 gp = 16, gp -#else - mov out0 = gp - add gp = 16, gp -#endif - ;; - ld8 gp = [gp] - - /* Spill all of the possible argument registers. */ - add r16 = 16 + 8*16, sp - add r17 = 16 + 8*16 + 16, sp - ;; - stf.spill [r16] = f8, 32 - stf.spill [r17] = f9, 32 - mov loc3 = gp - ;; - stf.spill [r16] = f10, 32 - stf.spill [r17] = f11, 32 - ;; - stf.spill [r16] = f12, 32 - stf.spill [r17] = f13, 32 - ;; - stf.spill [r16] = f14, 32 - stf.spill [r17] = f15, 24 - ;; - .mem.offset 0, 0 - st8.spill [r16] = in0, 16 - .mem.offset 8, 0 - st8.spill [r17] = in1, 16 - add out1 = 16 + 8*16, sp - ;; - .mem.offset 0, 0 - st8.spill [r16] = in2, 16 - .mem.offset 8, 0 - st8.spill [r17] = in3, 16 - add out2 = 16, sp - ;; - .mem.offset 0, 0 - st8.spill [r16] = in4, 16 - .mem.offset 8, 0 - st8.spill [r17] = in5, 16 - mov out3 = r8 - ;; - .mem.offset 0, 0 - st8.spill [r16] = in6 - .mem.offset 8, 0 - st8.spill [r17] = in7 - - /* Invoke ffi_closure_unix_inner for the hard work. */ - br.call.sptk.many b0 = ffi_closure_unix_inner - ;; - - /* Dispatch to handle return value. */ - mov gp = loc3 - zxt1 r16 = r8 - ;; - addl r18 = @ltoffx(.Lld_table), gp - mov ar.pfs = loc0 - ;; - ld8.mov r18 = [r18], .Lld_table - mov b0 = loc1 - ;; - shladd r18 = r16, 3, r18 - mov ar.unat = loc2 - ;; - ld8 r17 = [r18] - shr r8 = r8, 8 - ;; - add r17 = r17, r18 - add r16 = 16, sp - ;; - mov b6 = r17 - br b6 - ;; - .label_state 1 - -.Lld_void: - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; -.Lld_int: - .body - .copy_state 1 - ld8 r8 = [r16] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; -.Lld_float: - .body - .copy_state 1 - ldfs f8 = [r16] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; -.Lld_double: - .body - .copy_state 1 - ldfd f8 = [r16] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; -.Lld_ldouble: - .body - .copy_state 1 - ldfe f8 = [r16] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; - -.Lld_small_struct: - .body - .copy_state 1 - add r17 = 8, r16 - cmp.lt p6, p0 = 8, r8 - cmp.lt p7, p0 = 16, r8 - cmp.lt p8, p0 = 24, r8 - ;; - ld8 r8 = [r16], 16 -(p6) ld8 r9 = [r17], 16 - ;; -(p7) ld8 r10 = [r16] -(p8) ld8 r11 = [r17] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; - -.Lld_hfa_float: - .body - .copy_state 1 - add r17 = 4, r16 - cmp.lt p6, p0 = 4, r8 - ;; - ldfs f8 = [r16], 8 -(p6) ldfs f9 = [r17], 8 - cmp.lt p7, p0 = 8, r8 - cmp.lt p8, p0 = 12, r8 - ;; -(p7) ldfs f10 = [r16], 8 -(p8) ldfs f11 = [r17], 8 - cmp.lt p9, p0 = 16, r8 - cmp.lt p10, p0 = 20, r8 - ;; -(p9) ldfs f12 = [r16], 8 -(p10) ldfs f13 = [r17], 8 - cmp.lt p6, p0 = 24, r8 - cmp.lt p7, p0 = 28, r8 - ;; -(p6) ldfs f14 = [r16] -(p7) ldfs f15 = [r17] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; - -.Lld_hfa_double: - .body - .copy_state 1 - add r17 = 8, r16 - cmp.lt p6, p0 = 8, r8 - ;; - ldfd f8 = [r16], 16 -(p6) ldfd f9 = [r17], 16 - cmp.lt p7, p0 = 16, r8 - cmp.lt p8, p0 = 24, r8 - ;; -(p7) ldfd f10 = [r16], 16 -(p8) ldfd f11 = [r17], 16 - cmp.lt p9, p0 = 32, r8 - cmp.lt p10, p0 = 40, r8 - ;; -(p9) ldfd f12 = [r16], 16 -(p10) ldfd f13 = [r17], 16 - cmp.lt p6, p0 = 48, r8 - cmp.lt p7, p0 = 56, r8 - ;; -(p6) ldfd f14 = [r16] -(p7) ldfd f15 = [r17] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; - -.Lld_hfa_ldouble: - .body - .copy_state 1 - add r17 = 16, r16 - cmp.lt p6, p0 = 16, r8 - ;; - ldfe f8 = [r16], 32 -(p6) ldfe f9 = [r17], 32 - cmp.lt p7, p0 = 32, r8 - cmp.lt p8, p0 = 48, r8 - ;; -(p7) ldfe f10 = [r16], 32 -(p8) ldfe f11 = [r17], 32 - cmp.lt p9, p0 = 64, r8 - cmp.lt p10, p0 = 80, r8 - ;; -(p9) ldfe f12 = [r16], 32 -(p10) ldfe f13 = [r17], 32 - cmp.lt p6, p0 = 96, r8 - cmp.lt p7, p0 = 112, r8 - ;; -(p6) ldfe f14 = [r16] -(p7) ldfe f15 = [r17] - .restore sp - add sp = FRAME_SIZE, sp - br.ret.sptk.many b0 - ;; - - .endp ffi_closure_unix - - .section .rodata - .align 8 -.Lst_table: - data8 @pcrel(.Lst_void) // FFI_TYPE_VOID - data8 @pcrel(.Lst_sint32) // FFI_TYPE_INT - data8 @pcrel(.Lst_float) // FFI_TYPE_FLOAT - data8 @pcrel(.Lst_double) // FFI_TYPE_DOUBLE - data8 @pcrel(.Lst_ldouble) // FFI_TYPE_LONGDOUBLE - data8 @pcrel(.Lst_uint8) // FFI_TYPE_UINT8 - data8 @pcrel(.Lst_sint8) // FFI_TYPE_SINT8 - data8 @pcrel(.Lst_uint16) // FFI_TYPE_UINT16 - data8 @pcrel(.Lst_sint16) // FFI_TYPE_SINT16 - data8 @pcrel(.Lst_uint32) // FFI_TYPE_UINT32 - data8 @pcrel(.Lst_sint32) // FFI_TYPE_SINT32 - data8 @pcrel(.Lst_int64) // FFI_TYPE_UINT64 - data8 @pcrel(.Lst_int64) // FFI_TYPE_SINT64 - data8 @pcrel(.Lst_void) // FFI_TYPE_STRUCT - data8 @pcrel(.Lst_int64) // FFI_TYPE_POINTER - data8 @pcrel(.Lst_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT - data8 @pcrel(.Lst_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT - data8 @pcrel(.Lst_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE - data8 @pcrel(.Lst_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE - -.Lld_table: - data8 @pcrel(.Lld_void) // FFI_TYPE_VOID - data8 @pcrel(.Lld_int) // FFI_TYPE_INT - data8 @pcrel(.Lld_float) // FFI_TYPE_FLOAT - data8 @pcrel(.Lld_double) // FFI_TYPE_DOUBLE - data8 @pcrel(.Lld_ldouble) // FFI_TYPE_LONGDOUBLE - data8 @pcrel(.Lld_int) // FFI_TYPE_UINT8 - data8 @pcrel(.Lld_int) // FFI_TYPE_SINT8 - data8 @pcrel(.Lld_int) // FFI_TYPE_UINT16 - data8 @pcrel(.Lld_int) // FFI_TYPE_SINT16 - data8 @pcrel(.Lld_int) // FFI_TYPE_UINT32 - data8 @pcrel(.Lld_int) // FFI_TYPE_SINT32 - data8 @pcrel(.Lld_int) // FFI_TYPE_UINT64 - data8 @pcrel(.Lld_int) // FFI_TYPE_SINT64 - data8 @pcrel(.Lld_void) // FFI_TYPE_STRUCT - data8 @pcrel(.Lld_int) // FFI_TYPE_POINTER - data8 @pcrel(.Lld_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT - data8 @pcrel(.Lld_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT - data8 @pcrel(.Lld_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE - data8 @pcrel(.Lld_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/java_raw_api.c b/user/mpy/lib/libffi/src/java_raw_api.c deleted file mode 100644 index 127123d..0000000 --- a/user/mpy/lib/libffi/src/java_raw_api.c +++ /dev/null @@ -1,374 +0,0 @@ -/* ----------------------------------------------------------------------- - java_raw_api.c - Copyright (c) 1999, 2007, 2008 Red Hat, Inc. - - Cloned from raw_api.c - - Raw_api.c author: Kresten Krab Thorup - Java_raw_api.c author: Hans-J. Boehm - - $Id $ - - 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. - ----------------------------------------------------------------------- */ - -/* This defines a Java- and 64-bit specific variant of the raw API. */ -/* It assumes that "raw" argument blocks look like Java stacks on a */ -/* 64-bit machine. Arguments that can be stored in a single stack */ -/* stack slots (longs, doubles) occupy 128 bits, but only the first */ -/* 64 bits are actually used. */ - -#include -#include -#include - -#if !defined(NO_JAVA_RAW_API) - -size_t -ffi_java_raw_size (ffi_cif *cif) -{ - size_t result = 0; - int i; - - ffi_type **at = cif->arg_types; - - for (i = cif->nargs-1; i >= 0; i--, at++) - { - switch((*at) -> type) { - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_DOUBLE: - result += 2 * FFI_SIZEOF_JAVA_RAW; - break; - case FFI_TYPE_STRUCT: - /* No structure parameters in Java. */ - abort(); - case FFI_TYPE_COMPLEX: - /* Not supported yet. */ - abort(); - default: - result += FFI_SIZEOF_JAVA_RAW; - } - } - - return result; -} - - -void -ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) -{ - unsigned i; - ffi_type **tp = cif->arg_types; - -#if WORDS_BIGENDIAN - - for (i = 0; i < cif->nargs; i++, tp++, args++) - { - switch ((*tp)->type) - { - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - *args = (void*) ((char*)(raw++) + 3); - break; - - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - *args = (void*) ((char*)(raw++) + 2); - break; - -#if FFI_SIZEOF_JAVA_RAW == 8 - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_DOUBLE: - *args = (void *)raw; - raw += 2; - break; -#endif - - case FFI_TYPE_POINTER: - *args = (void*) &(raw++)->ptr; - break; - - case FFI_TYPE_COMPLEX: - /* Not supported yet. */ - abort(); - - default: - *args = raw; - raw += - ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw); - } - } - -#else /* WORDS_BIGENDIAN */ - -#if !PDP - - /* then assume little endian */ - for (i = 0; i < cif->nargs; i++, tp++, args++) - { -#if FFI_SIZEOF_JAVA_RAW == 8 - switch((*tp)->type) { - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_DOUBLE: - *args = (void*) raw; - raw += 2; - break; - case FFI_TYPE_COMPLEX: - /* Not supported yet. */ - abort(); - default: - *args = (void*) raw++; - } -#else /* FFI_SIZEOF_JAVA_RAW != 8 */ - *args = (void*) raw; - raw += - ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw); -#endif /* FFI_SIZEOF_JAVA_RAW == 8 */ - } - -#else -#error "pdp endian not supported" -#endif /* ! PDP */ - -#endif /* WORDS_BIGENDIAN */ -} - -void -ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) -{ - unsigned i; - ffi_type **tp = cif->arg_types; - - for (i = 0; i < cif->nargs; i++, tp++, args++) - { - switch ((*tp)->type) - { - case FFI_TYPE_UINT8: -#if WORDS_BIGENDIAN - *(UINT32*)(raw++) = *(UINT8*) (*args); -#else - (raw++)->uint = *(UINT8*) (*args); -#endif - break; - - case FFI_TYPE_SINT8: -#if WORDS_BIGENDIAN - *(SINT32*)(raw++) = *(SINT8*) (*args); -#else - (raw++)->sint = *(SINT8*) (*args); -#endif - break; - - case FFI_TYPE_UINT16: -#if WORDS_BIGENDIAN - *(UINT32*)(raw++) = *(UINT16*) (*args); -#else - (raw++)->uint = *(UINT16*) (*args); -#endif - break; - - case FFI_TYPE_SINT16: -#if WORDS_BIGENDIAN - *(SINT32*)(raw++) = *(SINT16*) (*args); -#else - (raw++)->sint = *(SINT16*) (*args); -#endif - break; - - case FFI_TYPE_UINT32: -#if WORDS_BIGENDIAN - *(UINT32*)(raw++) = *(UINT32*) (*args); -#else - (raw++)->uint = *(UINT32*) (*args); -#endif - break; - - case FFI_TYPE_SINT32: -#if WORDS_BIGENDIAN - *(SINT32*)(raw++) = *(SINT32*) (*args); -#else - (raw++)->sint = *(SINT32*) (*args); -#endif - break; - - case FFI_TYPE_FLOAT: - (raw++)->flt = *(FLOAT32*) (*args); - break; - -#if FFI_SIZEOF_JAVA_RAW == 8 - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_DOUBLE: - raw->uint = *(UINT64*) (*args); - raw += 2; - break; -#endif - - case FFI_TYPE_POINTER: - (raw++)->ptr = **(void***) args; - break; - - default: -#if FFI_SIZEOF_JAVA_RAW == 8 - FFI_ASSERT(0); /* Should have covered all cases */ -#else - memcpy ((void*) raw->data, (void*)*args, (*tp)->size); - raw += - ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw); -#endif - } - } -} - -#if !FFI_NATIVE_RAW_API - -static void -ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue) -{ -#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8 - switch (cif->rtype->type) - { - case FFI_TYPE_UINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_UINT32: - *(UINT64 *)rvalue <<= 32; - break; - - case FFI_TYPE_SINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_INT: -#if FFI_SIZEOF_JAVA_RAW == 4 - case FFI_TYPE_POINTER: -#endif - *(SINT64 *)rvalue <<= 32; - break; - - case FFI_TYPE_COMPLEX: - /* Not supported yet. */ - abort(); - - default: - break; - } -#endif -} - -static void -ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue) -{ -#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8 - switch (cif->rtype->type) - { - case FFI_TYPE_UINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_UINT32: - *(UINT64 *)rvalue >>= 32; - break; - - case FFI_TYPE_SINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_INT: - *(SINT64 *)rvalue >>= 32; - break; - - case FFI_TYPE_COMPLEX: - /* Not supported yet. */ - abort(); - - default: - break; - } -#endif -} - -/* This is a generic definition of ffi_raw_call, to be used if the - * native system does not provide a machine-specific implementation. - * Having this, allows code to be written for the raw API, without - * the need for system-specific code to handle input in that format; - * these following couple of functions will handle the translation forth - * and back automatically. */ - -void ffi_java_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, - ffi_java_raw *raw) -{ - void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); - ffi_java_raw_to_ptrarray (cif, raw, avalue); - ffi_call (cif, fn, rvalue, avalue); - ffi_java_rvalue_to_raw (cif, rvalue); -} - -#if FFI_CLOSURES /* base system provides closures */ - -static void -ffi_java_translate_args (ffi_cif *cif, void *rvalue, - void **avalue, void *user_data) -{ - ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif)); - ffi_raw_closure *cl = (ffi_raw_closure*)user_data; - - ffi_java_ptrarray_to_raw (cif, avalue, raw); - (*cl->fun) (cif, rvalue, (ffi_raw*)raw, cl->user_data); - ffi_java_raw_to_rvalue (cif, rvalue); -} - -ffi_status -ffi_prep_java_raw_closure_loc (ffi_java_raw_closure* cl, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data, - void *codeloc) -{ - ffi_status status; - - status = ffi_prep_closure_loc ((ffi_closure*) cl, - cif, - &ffi_java_translate_args, - codeloc, - codeloc); - if (status == FFI_OK) - { - cl->fun = fun; - cl->user_data = user_data; - } - - return status; -} - -/* Again, here is the generic version of ffi_prep_raw_closure, which - * will install an intermediate "hub" for translation of arguments from - * the pointer-array format, to the raw format */ - -ffi_status -ffi_prep_java_raw_closure (ffi_java_raw_closure* cl, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data) -{ - return ffi_prep_java_raw_closure_loc (cl, cif, fun, user_data, cl); -} - -#endif /* FFI_CLOSURES */ -#endif /* !FFI_NATIVE_RAW_API */ -#endif /* !NO_JAVA_RAW_API */ diff --git a/user/mpy/lib/libffi/src/m32r/ffi.c b/user/mpy/lib/libffi/src/m32r/ffi.c deleted file mode 100644 index 3000063..0000000 --- a/user/mpy/lib/libffi/src/m32r/ffi.c +++ /dev/null @@ -1,232 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2004 Renesas Technology - Copyright (c) 2008 Red Hat, Inc. - - M32R Foreign Function Interface - - 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 RENESAS TECHNOLOGY 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -/* ffi_prep_args is called by the assembly routine once stack - space has been allocated for the function's arguments. */ - -void ffi_prep_args(char *stack, extended_cif *ecif) -{ - unsigned int i; - int tmp; - unsigned int avn; - void **p_argv; - char *argp; - ffi_type **p_arg; - - tmp = 0; - argp = stack; - - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 8) - { - *(void **) argp = ecif->rvalue; - argp += 4; - } - - avn = ecif->cif->nargs; - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0) && (avn != 0); - i--, p_arg++) - { - size_t z; - - /* Align if necessary. */ - if (((*p_arg)->alignment - 1) & (unsigned) argp) - argp = (char *) ALIGN (argp, (*p_arg)->alignment); - - if (avn != 0) - { - avn--; - z = (*p_arg)->size; - if (z < sizeof (int)) - { - z = sizeof (int); - - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - case FFI_TYPE_STRUCT: - z = (*p_arg)->size; - if ((*p_arg)->alignment != 1) - memcpy (argp, *p_argv, z); - else - memcpy (argp + 4 - z, *p_argv, z); - z = sizeof (int); - break; - - default: - FFI_ASSERT(0); - } - } - else if (z == sizeof (int)) - { - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - } - else - { - if ((*p_arg)->type == FFI_TYPE_STRUCT) - { - if (z > 8) - { - *(unsigned int *) argp = (unsigned int)(void *)(* p_argv); - z = sizeof(void *); - } - else - { - memcpy(argp, *p_argv, z); - z = 8; - } - } - else - { - /* Double or long long 64bit. */ - memcpy (argp, *p_argv, z); - } - } - p_argv++; - argp += z; - } - } - - return; -} - -/* Perform machine dependent cif processing. */ -ffi_status -ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* Set the return type flag. */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - cif->flags = (unsigned) cif->rtype->type; - break; - - case FFI_TYPE_STRUCT: - if (cif->rtype->size <= 4) - cif->flags = FFI_TYPE_INT; - - else if (cif->rtype->size <= 8) - cif->flags = FFI_TYPE_DOUBLE; - - else - cif->flags = (unsigned) cif->rtype->type; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - cif->flags = FFI_TYPE_DOUBLE; - break; - - case FFI_TYPE_FLOAT: - default: - cif->flags = FFI_TYPE_INT; - break; - } - - return FFI_OK; -} - -extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, - unsigned, unsigned, unsigned *, void (*fn)(void)); - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have - a return value address then we need to make one. */ - if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca (cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - if (cif->rtype->type == FFI_TYPE_STRUCT) - { - int size = cif->rtype->size; - int align = cif->rtype->alignment; - - if (size < 4) - { - if (align == 1) - *(unsigned long *)(ecif.rvalue) <<= (4 - size) * 8; - } - else if (4 < size && size < 8) - { - if (align == 1) - { - memcpy (ecif.rvalue, ecif.rvalue + 8-size, size); - } - else if (align == 2) - { - if (size & 1) - size += 1; - - if (size != 8) - memcpy (ecif.rvalue, ecif.rvalue + 8-size, size); - } - } - } - break; - - default: - FFI_ASSERT(0); - break; - } -} diff --git a/user/mpy/lib/libffi/src/m32r/ffitarget.h b/user/mpy/lib/libffi/src/m32r/ffitarget.h deleted file mode 100644 index 6c34801..0000000 --- a/user/mpy/lib/libffi/src/m32r/ffitarget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2004 Renesas Technology. - Target configuration macros for M32R. - - 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 RENESAS TECHNOLOGY 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi - { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV - } ffi_abi; -#endif - -#define FFI_CLOSURES 0 -#define FFI_TRAMPOLINE_SIZE 24 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/m32r/sysv.S b/user/mpy/lib/libffi/src/m32r/sysv.S deleted file mode 100644 index 06b75c2..0000000 --- a/user/mpy/lib/libffi/src/m32r/sysv.S +++ /dev/null @@ -1,121 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2004 Renesas Technology - - M32R Foreign Function Interface - - 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 RENESAS TECHNOLOGY 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#ifdef HAVE_MACHINE_ASM_H -#include -#else -/* XXX these lose for some platforms, I'm sure. */ -#define CNAME(x) x -#define ENTRY(x) .globl CNAME(x)! .type CNAME(x),%function! CNAME(x): -#endif - -.text - - /* R0: ffi_prep_args */ - /* R1: &ecif */ - /* R2: cif->bytes */ - /* R3: fig->flags */ - /* sp+0: ecif.rvalue */ - /* sp+4: fn */ - - /* This assumes we are using gas. */ -ENTRY(ffi_call_SYSV) - /* Save registers. */ - push fp - push lr - push r3 - push r2 - push r1 - push r0 - mv fp, sp - - /* Make room for all of the new args. */ - sub sp, r2 - - /* Place all of the ffi_prep_args in position. */ - mv lr, r0 - mv r0, sp - /* R1 already set. */ - - /* And call. */ - jl lr - - /* Move first 4 parameters in registers... */ - ld r0, @(0,sp) - ld r1, @(4,sp) - ld r2, @(8,sp) - ld r3, @(12,sp) - - /* ...and adjust the stack. */ - ld lr, @(8,fp) - cmpi lr, #16 - bc adjust_stack - ldi lr, #16 -adjust_stack: - add sp, lr - - /* Call the function. */ - ld lr, @(28,fp) - jl lr - - /* Remove the space we pushed for the args. */ - mv sp, fp - - /* Load R2 with the pointer to storage for the return value. */ - ld r2, @(24,sp) - - /* Load R3 with the return type code. */ - ld r3, @(12,sp) - - /* If the return value pointer is NULL, assume no return value. */ - beqz r2, epilogue - - /* Return INT. */ - ldi r4, #FFI_TYPE_INT - bne r3, r4, return_double - st r0, @r2 - bra epilogue - -return_double: - /* Return DOUBLE or LONGDOUBLE. */ - ldi r4, #FFI_TYPE_DOUBLE - bne r3, r4, epilogue - st r0, @r2 - st r1, @(4,r2) - -epilogue: - pop r0 - pop r1 - pop r2 - pop r3 - pop lr - pop fp - jmp lr - -.ffi_call_SYSV_end: - .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) diff --git a/user/mpy/lib/libffi/src/m68k/ffi.c b/user/mpy/lib/libffi/src/m68k/ffi.c deleted file mode 100644 index 0dee938..0000000 --- a/user/mpy/lib/libffi/src/m68k/ffi.c +++ /dev/null @@ -1,362 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - - m68k Foreign Function Interface - ----------------------------------------------------------------------- */ - -#include -#include - -#include -#include -#ifdef __rtems__ -void rtems_cache_flush_multiple_data_lines( const void *, size_t ); -#else -#include -#ifdef __MINT__ -#include -#include -#else -#include -#endif -#endif - -void ffi_call_SYSV (extended_cif *, - unsigned, unsigned, - void *, void (*fn) ()); -void *ffi_prep_args (void *stack, extended_cif *ecif); -void ffi_closure_SYSV (ffi_closure *); -void ffi_closure_struct_SYSV (ffi_closure *); -unsigned int ffi_closure_SYSV_inner (ffi_closure *closure, - void *resp, void *args); - -/* ffi_prep_args is called by the assembly routine once stack space has - been allocated for the function's arguments. */ - -void * -ffi_prep_args (void *stack, extended_cif *ecif) -{ - unsigned int i; - void **p_argv; - char *argp; - ffi_type **p_arg; - void *struct_value_ptr; - - argp = stack; - - if ( -#ifdef __MINT__ - (ecif->cif->rtype->type == FFI_TYPE_LONGDOUBLE) || -#endif - (((ecif->cif->rtype->type == FFI_TYPE_STRUCT) - && !ecif->cif->flags))) - struct_value_ptr = ecif->rvalue; - else - struct_value_ptr = NULL; - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - i != 0; - i--, p_arg++) - { - size_t z = (*p_arg)->size; - int type = (*p_arg)->type; - - if (z < sizeof (int)) - { - switch (type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv; - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) *(SINT16 *) *p_argv; - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv; - break; - - case FFI_TYPE_STRUCT: -#ifdef __MINT__ - if (z == 1 || z == 2) - memcpy (argp + 2, *p_argv, z); - else - memcpy (argp, *p_argv, z); -#else - memcpy (argp + sizeof (int) - z, *p_argv, z); -#endif - break; - - default: - FFI_ASSERT (0); - } - z = sizeof (int); - } - else - { - memcpy (argp, *p_argv, z); - - /* Align if necessary. */ - if ((sizeof(int) - 1) & z) - z = ALIGN(z, sizeof(int)); - } - - p_argv++; - argp += z; - } - - return struct_value_ptr; -} - -#define CIF_FLAGS_INT 1 -#define CIF_FLAGS_DINT 2 -#define CIF_FLAGS_FLOAT 4 -#define CIF_FLAGS_DOUBLE 8 -#define CIF_FLAGS_LDOUBLE 16 -#define CIF_FLAGS_POINTER 32 -#define CIF_FLAGS_STRUCT1 64 -#define CIF_FLAGS_STRUCT2 128 -#define CIF_FLAGS_SINT8 256 -#define CIF_FLAGS_SINT16 512 - -/* Perform machine dependent cif processing */ -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - cif->flags = 0; - break; - - case FFI_TYPE_STRUCT: - if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT && - cif->rtype->elements[1]) - { - cif->flags = 0; - break; - } - - switch (cif->rtype->size) - { - case 1: -#ifdef __MINT__ - cif->flags = CIF_FLAGS_STRUCT2; -#else - cif->flags = CIF_FLAGS_STRUCT1; -#endif - break; - case 2: - cif->flags = CIF_FLAGS_STRUCT2; - break; -#ifdef __MINT__ - case 3: -#endif - case 4: - cif->flags = CIF_FLAGS_INT; - break; -#ifdef __MINT__ - case 7: -#endif - case 8: - cif->flags = CIF_FLAGS_DINT; - break; - default: - cif->flags = 0; - break; - } - break; - - case FFI_TYPE_FLOAT: - cif->flags = CIF_FLAGS_FLOAT; - break; - - case FFI_TYPE_DOUBLE: - cif->flags = CIF_FLAGS_DOUBLE; - break; - -#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE) - case FFI_TYPE_LONGDOUBLE: -#ifdef __MINT__ - cif->flags = 0; -#else - cif->flags = CIF_FLAGS_LDOUBLE; -#endif - break; -#endif - - case FFI_TYPE_POINTER: - cif->flags = CIF_FLAGS_POINTER; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = CIF_FLAGS_DINT; - break; - - case FFI_TYPE_SINT16: - cif->flags = CIF_FLAGS_SINT16; - break; - - case FFI_TYPE_SINT8: - cif->flags = CIF_FLAGS_SINT8; - break; - - default: - cif->flags = CIF_FLAGS_INT; - break; - } - - return FFI_OK; -} - -void -ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return value - address then we need to make one. */ - - if (rvalue == NULL - && cif->rtype->type == FFI_TYPE_STRUCT - && cif->rtype->size > 8) - ecif.rvalue = alloca (cif->rtype->size); - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV (&ecif, cif->bytes, cif->flags, - ecif.rvalue, fn); - break; - - default: - FFI_ASSERT (0); - break; - } -} - -static void -ffi_prep_incoming_args_SYSV (char *stack, void **avalue, ffi_cif *cif) -{ - unsigned int i; - void **p_argv; - char *argp; - ffi_type **p_arg; - - argp = stack; - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) - { - size_t z; - - z = (*p_arg)->size; -#ifdef __MINT__ - if (cif->flags && - cif->rtype->type == FFI_TYPE_STRUCT && - (z == 1 || z == 2)) - { - *p_argv = (void *) (argp + 2); - - z = 4; - } - else - if (cif->flags && - cif->rtype->type == FFI_TYPE_STRUCT && - (z == 3 || z == 4)) - { - *p_argv = (void *) (argp); - - z = 4; - } - else -#endif - if (z <= 4) - { - *p_argv = (void *) (argp + 4 - z); - - z = 4; - } - else - { - *p_argv = (void *) argp; - - /* Align if necessary */ - if ((sizeof(int) - 1) & z) - z = ALIGN(z, sizeof(int)); - } - - p_argv++; - argp += z; - } -} - -unsigned int -ffi_closure_SYSV_inner (ffi_closure *closure, void *resp, void *args) -{ - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void**) alloca (cif->nargs * sizeof (void *)); - - ffi_prep_incoming_args_SYSV(args, arg_area, cif); - - (closure->fun) (cif, resp, arg_area, closure->user_data); - - return cif->flags; -} - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - *(unsigned short *)closure->tramp = 0x207c; - *(void **)(closure->tramp + 2) = codeloc; - *(unsigned short *)(closure->tramp + 6) = 0x4ef9; - - if ( -#ifdef __MINT__ - (cif->rtype->type == FFI_TYPE_LONGDOUBLE) || -#endif - (((cif->rtype->type == FFI_TYPE_STRUCT) - && !cif->flags))) - *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV; - else - *(void **)(closure->tramp + 8) = ffi_closure_SYSV; - -#ifdef __rtems__ - rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE ); -#elif defined(__MINT__) - Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE); -#else - syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE, - FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE); -#endif - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/m68k/ffitarget.h b/user/mpy/lib/libffi/src/m68k/ffitarget.h deleted file mode 100644 index e81dde2..0000000 --- a/user/mpy/lib/libffi/src/m68k/ffitarget.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for Motorola 68K. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 16 -#define FFI_NATIVE_RAW_API 0 - -#endif - diff --git a/user/mpy/lib/libffi/src/m68k/sysv.S b/user/mpy/lib/libffi/src/m68k/sysv.S deleted file mode 100644 index ec2b14f..0000000 --- a/user/mpy/lib/libffi/src/m68k/sysv.S +++ /dev/null @@ -1,330 +0,0 @@ -/* ----------------------------------------------------------------------- - - sysv.S - Copyright (c) 2012 Alan Hourihane - Copyright (c) 1998, 2012 Andreas Schwab - Copyright (c) 2008 Red Hat, Inc. - Copyright (c) 2012 Thorsten Glaser - - m68k Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -#ifdef HAVE_AS_CFI_PSEUDO_OP -#define CFI_STARTPROC() .cfi_startproc -#define CFI_OFFSET(reg,off) .cfi_offset reg,off -#define CFI_DEF_CFA(reg,off) .cfi_def_cfa reg,off -#define CFI_ENDPROC() .cfi_endproc -#else -#define CFI_STARTPROC() -#define CFI_OFFSET(reg,off) -#define CFI_DEF_CFA(reg,off) -#define CFI_ENDPROC() -#endif - -#ifdef __MINT__ -#define CALLFUNC(funcname) _ ## funcname -#else -#define CALLFUNC(funcname) funcname -#endif - - .text - - .globl CALLFUNC(ffi_call_SYSV) - .type CALLFUNC(ffi_call_SYSV),@function - .align 4 - -CALLFUNC(ffi_call_SYSV): - CFI_STARTPROC() - link %fp,#0 - CFI_OFFSET(14,-8) - CFI_DEF_CFA(14,8) - move.l %d2,-(%sp) - CFI_OFFSET(2,-12) - - | Make room for all of the new args. - sub.l 12(%fp),%sp - - | Call ffi_prep_args - move.l 8(%fp),-(%sp) - pea 4(%sp) -#if !defined __PIC__ - jsr CALLFUNC(ffi_prep_args) -#else - bsr.l CALLFUNC(ffi_prep_args@PLTPC) -#endif - addq.l #8,%sp - - | Pass pointer to struct value, if any -#ifdef __MINT__ - move.l %d0,%a1 -#else - move.l %a0,%a1 -#endif - - | Call the function - move.l 24(%fp),%a0 - jsr (%a0) - - | Remove the space we pushed for the args - add.l 12(%fp),%sp - - | Load the pointer to storage for the return value - move.l 20(%fp),%a1 - - | Load the return type code - move.l 16(%fp),%d2 - - | If the return value pointer is NULL, assume no return value. - | NOTE: On the mc68000, tst on an address register is not supported. -#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) - cmp.w #0, %a1 -#else - tst.l %a1 -#endif - jbeq noretval - - btst #0,%d2 - jbeq retlongint - move.l %d0,(%a1) - jbra epilogue - -retlongint: - btst #1,%d2 - jbeq retfloat - move.l %d0,(%a1) - move.l %d1,4(%a1) - jbra epilogue - -retfloat: - btst #2,%d2 - jbeq retdouble -#if defined(__MC68881__) || defined(__HAVE_68881__) - fmove.s %fp0,(%a1) -#else - move.l %d0,(%a1) -#endif - jbra epilogue - -retdouble: - btst #3,%d2 - jbeq retlongdouble -#if defined(__MC68881__) || defined(__HAVE_68881__) - fmove.d %fp0,(%a1) -#else - move.l %d0,(%a1)+ - move.l %d1,(%a1) -#endif - jbra epilogue - -retlongdouble: - btst #4,%d2 - jbeq retpointer -#if defined(__MC68881__) || defined(__HAVE_68881__) - fmove.x %fp0,(%a1) -#else - move.l %d0,(%a1)+ - move.l %d1,(%a1)+ - move.l %d2,(%a1) -#endif - jbra epilogue - -retpointer: - btst #5,%d2 - jbeq retstruct1 -#ifdef __MINT__ - move.l %d0,(%a1) -#else - move.l %a0,(%a1) -#endif - jbra epilogue - -retstruct1: - btst #6,%d2 - jbeq retstruct2 - move.b %d0,(%a1) - jbra epilogue - -retstruct2: - btst #7,%d2 - jbeq retsint8 - move.w %d0,(%a1) - jbra epilogue - -retsint8: - btst #8,%d2 - jbeq retsint16 - | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32. -#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) - ext.w %d0 - ext.l %d0 -#else - extb.l %d0 -#endif - move.l %d0,(%a1) - jbra epilogue - -retsint16: - btst #9,%d2 - jbeq noretval - ext.l %d0 - move.l %d0,(%a1) - -noretval: -epilogue: - move.l (%sp)+,%d2 - unlk %fp - rts - CFI_ENDPROC() - .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV) - - .globl CALLFUNC(ffi_closure_SYSV) - .type CALLFUNC(ffi_closure_SYSV), @function - .align 4 - -CALLFUNC(ffi_closure_SYSV): - CFI_STARTPROC() - link %fp,#-12 - CFI_OFFSET(14,-8) - CFI_DEF_CFA(14,8) - move.l %sp,-12(%fp) - pea 8(%fp) - pea -12(%fp) - move.l %a0,-(%sp) -#if !defined __PIC__ - jsr CALLFUNC(ffi_closure_SYSV_inner) -#else - bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC) -#endif - - lsr.l #1,%d0 - jne 1f - jcc .Lcls_epilogue - | CIF_FLAGS_INT - move.l -12(%fp),%d0 -.Lcls_epilogue: - | no CIF_FLAGS_* - unlk %fp - rts -1: - lea -12(%fp),%a0 - lsr.l #2,%d0 - jne 1f - jcs .Lcls_ret_float - | CIF_FLAGS_DINT - move.l (%a0)+,%d0 - move.l (%a0),%d1 - jra .Lcls_epilogue -.Lcls_ret_float: -#if defined(__MC68881__) || defined(__HAVE_68881__) - fmove.s (%a0),%fp0 -#else - move.l (%a0),%d0 -#endif - jra .Lcls_epilogue -1: - lsr.l #2,%d0 - jne 1f - jcs .Lcls_ret_ldouble - | CIF_FLAGS_DOUBLE -#if defined(__MC68881__) || defined(__HAVE_68881__) - fmove.d (%a0),%fp0 -#else - move.l (%a0)+,%d0 - move.l (%a0),%d1 -#endif - jra .Lcls_epilogue -.Lcls_ret_ldouble: -#if defined(__MC68881__) || defined(__HAVE_68881__) - fmove.x (%a0),%fp0 -#else - move.l (%a0)+,%d0 - move.l (%a0)+,%d1 - move.l (%a0),%d2 -#endif - jra .Lcls_epilogue -1: - lsr.l #2,%d0 - jne 1f - jcs .Lcls_ret_struct1 - | CIF_FLAGS_POINTER - move.l (%a0),%a0 - move.l %a0,%d0 - jra .Lcls_epilogue -.Lcls_ret_struct1: - move.b (%a0),%d0 - jra .Lcls_epilogue -1: - lsr.l #2,%d0 - jne 1f - jcs .Lcls_ret_sint8 - | CIF_FLAGS_STRUCT2 - move.w (%a0),%d0 - jra .Lcls_epilogue -.Lcls_ret_sint8: - move.l (%a0),%d0 - | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32. -#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) - ext.w %d0 - ext.l %d0 -#else - extb.l %d0 -#endif - jra .Lcls_epilogue -1: - | CIF_FLAGS_SINT16 - move.l (%a0),%d0 - ext.l %d0 - jra .Lcls_epilogue - CFI_ENDPROC() - - .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV) - - .globl CALLFUNC(ffi_closure_struct_SYSV) - .type CALLFUNC(ffi_closure_struct_SYSV), @function - .align 4 - -CALLFUNC(ffi_closure_struct_SYSV): - CFI_STARTPROC() - link %fp,#0 - CFI_OFFSET(14,-8) - CFI_DEF_CFA(14,8) - move.l %sp,-12(%fp) - pea 8(%fp) - move.l %a1,-(%sp) - move.l %a0,-(%sp) -#if !defined __PIC__ - jsr CALLFUNC(ffi_closure_SYSV_inner) -#else - bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC) -#endif - unlk %fp - rts - CFI_ENDPROC() - .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV) - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/m88k/ffi.c b/user/mpy/lib/libffi/src/m88k/ffi.c deleted file mode 100644 index 68df494..0000000 --- a/user/mpy/lib/libffi/src/m88k/ffi.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Copyright (c) 2013 Miodrag Vallat. - * - * 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. - */ - -/* - * m88k Foreign Function Interface - * - * This file attempts to provide all the FFI entry points which can reliably - * be implemented in C. - * - * Only OpenBSD/m88k is currently supported; other platforms (such as - * Motorola's SysV/m88k) could be supported with the following tweaks: - * - * - non-OpenBSD systems use an `outgoing parameter area' as part of the - * 88BCS calling convention, which is not supported under OpenBSD from - * release 3.6 onwards. Supporting it should be as easy as taking it - * into account when adjusting the stack, in the assembly code. - * - * - the logic deciding whether a function argument gets passed through - * registers, or on the stack, has changed several times in OpenBSD in - * edge cases (especially for structs larger than 32 bytes being passed - * by value). The code below attemps to match the logic used by the - * system compiler of OpenBSD 5.3, i.e. gcc 3.3.6 with many m88k backend - * fixes. - */ - -#include -#include - -#include -#include - -void ffi_call_OBSD (unsigned int, extended_cif *, unsigned int, void *, - void (*fn) ()); -void *ffi_prep_args (void *, extended_cif *); -void ffi_closure_OBSD (ffi_closure *); -void ffi_closure_struct_OBSD (ffi_closure *); -unsigned int ffi_closure_OBSD_inner (ffi_closure *, void *, unsigned int *, - char *); -void ffi_cacheflush_OBSD (unsigned int, unsigned int); - -#define CIF_FLAGS_INT (1 << 0) -#define CIF_FLAGS_DINT (1 << 1) - -/* - * Foreign Function Interface API - */ - -/* ffi_prep_args is called by the assembly routine once stack space has - been allocated for the function's arguments. */ - -void * -ffi_prep_args (void *stack, extended_cif *ecif) -{ - unsigned int i; - void **p_argv; - char *argp, *stackp; - unsigned int *regp; - unsigned int regused; - ffi_type **p_arg; - void *struct_value_ptr; - - regp = (unsigned int *)stack; - stackp = (char *)(regp + 8); - regused = 0; - - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT - && !ecif->cif->flags) - struct_value_ptr = ecif->rvalue; - else - struct_value_ptr = NULL; - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i != 0; i--, p_arg++) - { - size_t z; - unsigned short t, a; - - z = (*p_arg)->size; - t = (*p_arg)->type; - a = (*p_arg)->alignment; - - /* - * Figure out whether the argument can be passed through registers - * or on the stack. - * The rule is that registers can only receive simple types not larger - * than 64 bits, or structs the exact size of a register and aligned to - * the size of a register. - */ - if (t == FFI_TYPE_STRUCT) - { - if (z == sizeof (int) && a == sizeof (int) && regused < 8) - argp = (char *)regp; - else - argp = stackp; - } - else - { - if (z > sizeof (int) && regused < 8 - 1) - { - /* align to an even register pair */ - if (regused & 1) - { - regp++; - regused++; - } - } - if (regused < 8) - argp = (char *)regp; - else - argp = stackp; - } - - /* Enforce proper stack alignment of 64-bit types */ - if (argp == stackp && a > sizeof (int)) - { - stackp = (char *) ALIGN(stackp, a); - argp = stackp; - } - - switch (t) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv; - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) *(SINT16 *) *p_argv; - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv; - break; - - case FFI_TYPE_INT: - case FFI_TYPE_FLOAT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - *(unsigned int *) argp = *(unsigned int *) *p_argv; - break; - - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_STRUCT: - memcpy (argp, *p_argv, z); - break; - - default: - FFI_ASSERT (0); - } - - /* Align if necessary. */ - if ((sizeof (int) - 1) & z) - z = ALIGN(z, sizeof (int)); - - p_argv++; - - /* Be careful, once all registers are filled, and about to continue - on stack, regp == stackp. Therefore the check for regused as well. */ - if (argp == (char *)regp && regused < 8) - { - regp += z / sizeof (int); - regused += z / sizeof (int); - } - else - stackp += z; - } - - return struct_value_ptr; -} - -/* Perform machine dependent cif processing */ -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - cif->flags = 0; - break; - - case FFI_TYPE_STRUCT: - if (cif->rtype->size == sizeof (int) && - cif->rtype->alignment == sizeof (int)) - cif->flags = CIF_FLAGS_INT; - else - cif->flags = 0; - break; - - case FFI_TYPE_DOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = CIF_FLAGS_DINT; - break; - - default: - cif->flags = CIF_FLAGS_INT; - break; - } - - return FFI_OK; -} - -void -ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return value - address then we need to make one. */ - - if (rvalue == NULL - && cif->rtype->type == FFI_TYPE_STRUCT - && (cif->rtype->size != sizeof (int) - || cif->rtype->alignment != sizeof (int))) - ecif.rvalue = alloca (cif->rtype->size); - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_OBSD: - ffi_call_OBSD (cif->bytes, &ecif, cif->flags, ecif.rvalue, fn); - break; - - default: - FFI_ASSERT (0); - break; - } -} - -/* - * Closure API - */ - -static void -ffi_prep_closure_args_OBSD (ffi_cif *cif, void **avalue, unsigned int *regp, - char *stackp) -{ - unsigned int i; - void **p_argv; - char *argp; - unsigned int regused; - ffi_type **p_arg; - - regused = 0; - - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++) - { - size_t z; - unsigned short t, a; - - z = (*p_arg)->size; - t = (*p_arg)->type; - a = (*p_arg)->alignment; - - /* - * Figure out whether the argument has been passed through registers - * or on the stack. - * The rule is that registers can only receive simple types not larger - * than 64 bits, or structs the exact size of a register and aligned to - * the size of a register. - */ - if (t == FFI_TYPE_STRUCT) - { - if (z == sizeof (int) && a == sizeof (int) && regused < 8) - argp = (char *)regp; - else - argp = stackp; - } - else - { - if (z > sizeof (int) && regused < 8 - 1) - { - /* align to an even register pair */ - if (regused & 1) - { - regp++; - regused++; - } - } - if (regused < 8) - argp = (char *)regp; - else - argp = stackp; - } - - /* Enforce proper stack alignment of 64-bit types */ - if (argp == stackp && a > sizeof (int)) - { - stackp = (char *) ALIGN(stackp, a); - argp = stackp; - } - - if (z < sizeof (int) && t != FFI_TYPE_STRUCT) - *p_argv = (void *) (argp + sizeof (int) - z); - else - *p_argv = (void *) argp; - - /* Align if necessary */ - if ((sizeof (int) - 1) & z) - z = ALIGN(z, sizeof (int)); - - p_argv++; - - /* Be careful, once all registers are exhausted, and about to fetch from - stack, regp == stackp. Therefore the check for regused as well. */ - if (argp == (char *)regp && regused < 8) - { - regp += z / sizeof (int); - regused += z / sizeof (int); - } - else - stackp += z; - } -} - -unsigned int -ffi_closure_OBSD_inner (ffi_closure *closure, void *resp, unsigned int *regp, - char *stackp) -{ - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void**) alloca (cif->nargs * sizeof (void *)); - - ffi_prep_closure_args_OBSD(cif, arg_area, regp, stackp); - - (closure->fun) (cif, resp, arg_area, closure->user_data); - - return cif->flags; -} - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, void *codeloc) -{ - unsigned int *tramp = (unsigned int *) codeloc; - void *fn; - - FFI_ASSERT (cif->abi == FFI_OBSD); - - if (cif->rtype->type == FFI_TYPE_STRUCT && !cif->flags) - fn = &ffi_closure_struct_OBSD; - else - fn = &ffi_closure_OBSD; - - /* or.u %r10, %r0, %hi16(fn) */ - tramp[0] = 0x5d400000 | (((unsigned int)fn) >> 16); - /* or.u %r13, %r0, %hi16(closure) */ - tramp[1] = 0x5da00000 | ((unsigned int)closure >> 16); - /* or %r10, %r10, %lo16(fn) */ - tramp[2] = 0x594a0000 | (((unsigned int)fn) & 0xffff); - /* jmp.n %r10 */ - tramp[3] = 0xf400c40a; - /* or %r13, %r13, %lo16(closure) */ - tramp[4] = 0x59ad0000 | ((unsigned int)closure & 0xffff); - - ffi_cacheflush_OBSD((unsigned int)codeloc, FFI_TRAMPOLINE_SIZE); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/m88k/ffitarget.h b/user/mpy/lib/libffi/src/m88k/ffitarget.h deleted file mode 100644 index e52bf9f..0000000 --- a/user/mpy/lib/libffi/src/m88k/ffitarget.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2013 Miodrag Vallat. - * - * 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. - */ - -/* - * m88k Foreign Function Interface - */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_OBSD, - FFI_DEFAULT_ABI = FFI_OBSD, - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 0x14 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/m88k/obsd.S b/user/mpy/lib/libffi/src/m88k/obsd.S deleted file mode 100644 index 1944a23..0000000 --- a/user/mpy/lib/libffi/src/m88k/obsd.S +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2013 Miodrag Vallat. - * - * 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. - */ - -/* - * m88k Foreign Function Interface - */ - -#define LIBFFI_ASM -#include -#include - - .text - -/* - * ffi_cacheflush_OBSD(unsigned int addr, %r2 - * unsigned int size); %r3 - */ - .align 4 - .globl ffi_cacheflush_OBSD - .type ffi_cacheflush_OBSD,@function -ffi_cacheflush_OBSD: - tb0 0, %r0, 451 - or %r0, %r0, %r0 - jmp %r1 - .size ffi_cacheflush_OBSD, . - ffi_cacheflush_OBSD - -/* - * ffi_call_OBSD(unsigned bytes, %r2 - * extended_cif *ecif, %r3 - * unsigned flags, %r4 - * void *rvalue, %r5 - * void (*fn)()); %r6 - */ - .align 4 - .globl ffi_call_OBSD - .type ffi_call_OBSD,@function -ffi_call_OBSD: - subu %r31, %r31, 32 - st %r30, %r31, 4 - st %r1, %r31, 0 - addu %r30, %r31, 32 - - | Save the few arguments we'll need after ffi_prep_args() - st.d %r4, %r31, 8 - st %r6, %r31, 16 - - | Allocate room for the image of r2-r9, and the stack space for - | the args (rounded to a 16-byte boundary) - addu %r2, %r2, (8 * 4) + 15 - clr %r2, %r2, 4<0> - subu %r31, %r31, %r2 - - | Fill register and stack image - or %r2, %r31, %r0 -#ifdef PIC - bsr ffi_prep_args#plt -#else - bsr ffi_prep_args -#endif - - | Save pointer to return struct address, if any - or %r12, %r2, %r0 - - | Get function pointer - subu %r4, %r30, 32 - ld %r1, %r4, 16 - - | Fetch the register arguments - ld.d %r2, %r31, (0 * 4) - ld.d %r4, %r31, (2 * 4) - ld.d %r6, %r31, (4 * 4) - ld.d %r8, %r31, (6 * 4) - addu %r31, %r31, (8 * 4) - - | Invoke the function - jsr %r1 - - | Restore stack now that we don't need the args anymore - subu %r31, %r30, 32 - - | Figure out what to return as the function's return value - ld %r5, %r31, 12 | rvalue - ld %r4, %r31, 8 | flags - - bcnd eq0, %r5, 9f - - bb0 0, %r4, 1f | CIF_FLAGS_INT - st %r2, %r5, 0 - br 9f - -1: - bb0 1, %r4, 1f | CIF_FLAGS_DINT - st.d %r2, %r5, 0 - br 9f - -1: -9: - ld %r1, %r31, 0 - ld %r30, %r31, 4 - jmp.n %r1 - addu %r31, %r31, 32 - .size ffi_call_OBSD, . - ffi_call_OBSD - -/* - * ffi_closure_OBSD(ffi_closure *closure); %r13 - */ - .align 4 - .globl ffi_closure_OBSD - .type ffi_closure_OBSD, @function -ffi_closure_OBSD: - subu %r31, %r31, 16 - st %r30, %r31, 4 - st %r1, %r31, 0 - addu %r30, %r31, 16 - - | Make room on the stack for saved register arguments and return - | value - subu %r31, %r31, (8 * 4) + (2 * 4) - st.d %r2, %r31, (0 * 4) - st.d %r4, %r31, (2 * 4) - st.d %r6, %r31, (4 * 4) - st.d %r8, %r31, (6 * 4) - - | Invoke the closure function - or %r5, %r30, 0 | calling stack - addu %r4, %r31, 0 | saved registers - addu %r3, %r31, (8 * 4) | return value - or %r2, %r13, %r0 | closure -#ifdef PIC - bsr ffi_closure_OBSD_inner#plt -#else - bsr ffi_closure_OBSD_inner -#endif - - | Figure out what to return as the function's return value - bb0 0, %r2, 1f | CIF_FLAGS_INT - ld %r2, %r31, (8 * 4) - br 9f - -1: - bb0 1, %r2, 1f | CIF_FLAGS_DINT - ld.d %r2, %r31, (8 * 4) - br 9f - -1: -9: - subu %r31, %r30, 16 - ld %r1, %r31, 0 - ld %r30, %r31, 4 - jmp.n %r1 - addu %r31, %r31, 16 - .size ffi_closure_OBSD,.-ffi_closure_OBSD - -/* - * ffi_closure_struct_OBSD(ffi_closure *closure); %r13 - */ - .align 4 - .globl ffi_closure_struct_OBSD - .type ffi_closure_struct_OBSD, @function -ffi_closure_struct_OBSD: - subu %r31, %r31, 16 - st %r30, %r31, 4 - st %r1, %r31, 0 - addu %r30, %r31, 16 - - | Make room on the stack for saved register arguments - subu %r31, %r31, (8 * 4) - st.d %r2, %r31, (0 * 4) - st.d %r4, %r31, (2 * 4) - st.d %r6, %r31, (4 * 4) - st.d %r8, %r31, (6 * 4) - - | Invoke the closure function - or %r5, %r30, 0 | calling stack - addu %r4, %r31, 0 | saved registers - or %r3, %r12, 0 | return value - or %r2, %r13, %r0 | closure -#ifdef PIC - bsr ffi_closure_OBSD_inner#plt -#else - bsr ffi_closure_OBSD_inner -#endif - - subu %r31, %r30, 16 - ld %r1, %r31, 0 - ld %r30, %r31, 4 - jmp.n %r1 - addu %r31, %r31, 16 - .size ffi_closure_struct_OBSD,.-ffi_closure_struct_OBSD diff --git a/user/mpy/lib/libffi/src/metag/ffi.c b/user/mpy/lib/libffi/src/metag/ffi.c deleted file mode 100644 index 46b383e..0000000 --- a/user/mpy/lib/libffi/src/metag/ffi.c +++ /dev/null @@ -1,330 +0,0 @@ -/* ---------------------------------------------------------------------- - ffi.c - Copyright (c) 2013 Imagination Technologies - - Meta Foreign Function Interface - 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 SIMON POSNJAK 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. ------------------------------------------------------------------------ */ - -#include -#include - -#include - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -/* - * ffi_prep_args is called by the assembly routine once stack space has been - * allocated for the function's arguments - */ - -unsigned int ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - /* Store return value */ - if ( ecif->cif->flags == FFI_TYPE_STRUCT ) { - argp -= 4; - *(void **) argp = ecif->rvalue; - } - - p_argv = ecif->avalue; - - /* point to next location */ - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; (i != 0); i--, p_arg++, p_argv++) - { - size_t z; - - /* Move argp to address of argument */ - z = (*p_arg)->size; - argp -= z; - - /* Align if necessary */ - argp = (char *) ALIGN_DOWN(ALIGN_DOWN(argp, (*p_arg)->alignment), 4); - - if (z < sizeof(int)) { - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - case FFI_TYPE_STRUCT: - memcpy(argp, *p_argv, (*p_arg)->size); - break; - default: - FFI_ASSERT(0); - } - } else if ( z == sizeof(int)) { - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - } else { - memcpy(argp, *p_argv, z); - } - } - - /* return the size of the arguments to be passed in registers, - padded to an 8 byte boundary to preserve stack alignment */ - return ALIGN(MIN(stack - argp, 6*4), 8); -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - ffi_type **ptr; - unsigned i, bytes = 0; - - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) { - if ((*ptr)->size == 0) - return FFI_BAD_TYPEDEF; - - /* Perform a sanity check on the argument type, do this - check after the initialization. */ - FFI_ASSERT_VALID_TYPE(*ptr); - - /* Add any padding if necessary */ - if (((*ptr)->alignment - 1) & bytes) - bytes = ALIGN(bytes, (*ptr)->alignment); - - bytes += ALIGN((*ptr)->size, 4); - } - - /* Ensure arg space is aligned to an 8-byte boundary */ - bytes = ALIGN(bytes, 8); - - /* Make space for the return structure pointer */ - if (cif->rtype->type == FFI_TYPE_STRUCT) { - bytes += sizeof(void*); - - /* Ensure stack is aligned to an 8-byte boundary */ - bytes = ALIGN(bytes, 8); - } - - cif->bytes = bytes; - - /* Set the return type flag */ - switch (cif->rtype->type) { - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags = (unsigned) cif->rtype->type; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = (unsigned) FFI_TYPE_SINT64; - break; - case FFI_TYPE_STRUCT: - /* Meta can store return values which are <= 64 bits */ - if (cif->rtype->size <= 4) - /* Returned to D0Re0 as 32-bit value */ - cif->flags = (unsigned)FFI_TYPE_INT; - else if ((cif->rtype->size > 4) && (cif->rtype->size <= 8)) - /* Returned valued is stored to D1Re0|R0Re0 */ - cif->flags = (unsigned)FFI_TYPE_DOUBLE; - else - /* value stored in memory */ - cif->flags = (unsigned)FFI_TYPE_STRUCT; - break; - default: - cif->flags = (unsigned)FFI_TYPE_INT; - break; - } - return FFI_OK; -} - -extern void ffi_call_SYSV(void (*fn)(void), extended_cif *, unsigned, unsigned, double *); - -/* - * Exported in API. Entry point - * cif -> ffi_cif object - * fn -> function pointer - * rvalue -> pointer to return value - * avalue -> vector of void * pointers pointing to memory locations holding the - * arguments - */ -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - int small_struct = (((cif->flags == FFI_TYPE_INT) || (cif->flags == FFI_TYPE_DOUBLE)) && (cif->rtype->type == FFI_TYPE_STRUCT)); - ecif.cif = cif; - ecif.avalue = avalue; - - double temp; - - /* - * If the return value is a struct and we don't have a return value address - * then we need to make one - */ - - if ((rvalue == NULL ) && (cif->flags == FFI_TYPE_STRUCT)) - ecif.rvalue = alloca(cif->rtype->size); - else if (small_struct) - ecif.rvalue = &temp; - else - ecif.rvalue = rvalue; - - switch (cif->abi) { - case FFI_SYSV: - ffi_call_SYSV(fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); - break; - default: - FFI_ASSERT(0); - break; - } - - if (small_struct) - memcpy (rvalue, &temp, cif->rtype->size); -} - -/* private members */ - -static void ffi_prep_incoming_args_SYSV (char *, void **, void **, - ffi_cif*, float *); - -void ffi_closure_SYSV (ffi_closure *); - -/* Do NOT change that without changing the FFI_TRAMPOLINE_SIZE */ -extern unsigned int ffi_metag_trampoline[10]; /* 10 instructions */ - -/* end of private members */ - -/* - * __tramp: trampoline memory location - * __fun: assembly routine - * __ctx: memory location for wrapper - * - * At this point, tramp[0] == __ctx ! - */ -void ffi_init_trampoline(unsigned char *__tramp, unsigned int __fun, unsigned int __ctx) { - memcpy (__tramp, ffi_metag_trampoline, sizeof(ffi_metag_trampoline)); - *(unsigned int*) &__tramp[40] = __ctx; - *(unsigned int*) &__tramp[44] = __fun; - /* This will flush the instruction cache */ - __builtin_meta2_cachewd(&__tramp[0], 1); - __builtin_meta2_cachewd(&__tramp[47], 1); -} - - - -/* the cif must already be prepared */ - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - void (*closure_func)(ffi_closure*) = NULL; - - if (cif->abi == FFI_SYSV) - closure_func = &ffi_closure_SYSV; - else - return FFI_BAD_ABI; - - ffi_init_trampoline( - (unsigned char*)&closure->tramp[0], - (unsigned int)closure_func, - (unsigned int)codeloc); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - - -/* This function is jumped to by the trampoline */ -unsigned int ffi_closure_SYSV_inner (closure, respp, args, vfp_args) - ffi_closure *closure; - void **respp; - void *args; - void *vfp_args; -{ - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void**) alloca (cif->nargs * sizeof (void*)); - - /* - * This call will initialize ARG_AREA, such that each - * element in that array points to the corresponding - * value on the stack; and if the function returns - * a structure, it will re-set RESP to point to the - * structure return address. - */ - ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args); - - (closure->fun) ( cif, *respp, arg_area, closure->user_data); - - return cif->flags; -} - -static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, - void **avalue, ffi_cif *cif, - float *vfp_stack) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - /* stack points to original arguments */ - argp = stack; - - /* Store return value */ - if ( cif->flags == FFI_TYPE_STRUCT ) { - argp -= 4; - *rvalue = *(void **) argp; - } - - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) { - size_t z; - size_t alignment; - - alignment = (*p_arg)->alignment; - if (alignment < 4) - alignment = 4; - if ((alignment - 1) & (unsigned)argp) - argp = (char *) ALIGN(argp, alignment); - - z = (*p_arg)->size; - *p_argv = (void*) argp; - p_argv++; - argp -= z; - } - return; -} diff --git a/user/mpy/lib/libffi/src/metag/ffitarget.h b/user/mpy/lib/libffi/src/metag/ffitarget.h deleted file mode 100644 index 7b9dbeb..0000000 --- a/user/mpy/lib/libffi/src/metag/ffitarget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2013 Imagination Technologies Ltd. - Target configuration macros for Meta - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_DEFAULT_ABI = FFI_SYSV, - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1, -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 48 -#define FFI_NATIVE_RAW_API 0 - -#endif - diff --git a/user/mpy/lib/libffi/src/metag/sysv.S b/user/mpy/lib/libffi/src/metag/sysv.S deleted file mode 100644 index b4b2a3b..0000000 --- a/user/mpy/lib/libffi/src/metag/sysv.S +++ /dev/null @@ -1,311 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2013 Imagination Technologies Ltd. - - Meta Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#ifdef HAVE_MACHINE_ASM_H -#include -#else -#ifdef __USER_LABEL_PREFIX__ -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ -#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x) -#else -#define CNAME(x) x -#endif -#define ENTRY(x) .globl CNAME(x); .type CNAME(x), %function; CNAME(x): -#endif - -#ifdef __ELF__ -#define LSYM(x) .x -#else -#define LSYM(x) x -#endif - -.macro call_reg x= - .text - .balign 4 - mov D1RtP, \x - swap D1RtP, PC -.endm - -! Save register arguments -.macro SAVE_ARGS - .text - .balign 4 - setl [A0StP++], D0Ar6, D1Ar5 - setl [A0StP++], D0Ar4, D1Ar3 - setl [A0StP++], D0Ar2, D1Ar1 -.endm - -! Save retrun, frame pointer and other regs -.macro SAVE_REGS regs= - .text - .balign 4 - setl [A0StP++], D0FrT, D1RtP - ! Needs to be a pair of regs - .ifnc "\regs","" - setl [A0StP++], \regs - .endif -.endm - -! Declare a global function -.macro METAG_FUNC_START name - .text - .balign 4 - ENTRY(\name) -.endm - -! Return registers from the stack. Reverse SAVE_REGS operation -.macro RET_REGS regs=, cond= - .ifnc "\regs", "" - getl \regs, [--A0StP] - .endif - getl D0FrT, D1RtP, [--A0StP] -.endm - -! Return arguments -.macro RET_ARGS - getl D0Ar2, D1Ar1, [--A0StP] - getl D0Ar4, D1Ar3, [--A0StP] - getl D0Ar6, D1Ar5, [--A0StP] -.endm - - - ! D1Ar1: fn - ! D0Ar2: &ecif - ! D1Ar3: cif->bytes - ! D0Ar4: fig->flags - ! D1Ar5: ecif.rvalue - - ! This assumes we are using GNU as -METAG_FUNC_START ffi_call_SYSV - ! Save argument registers - - SAVE_ARGS - - ! new frame - mov D0FrT, A0FrP - add A0FrP, A0StP, #0 - - ! Preserve the old frame pointer - SAVE_REGS "D1.5, D0.5" - - ! Make room for new args. cifs->bytes is the total space for input - ! and return arguments - - add A0StP, A0StP, D1Ar3 - - ! Preserve cifs->bytes & fn - mov D0.5, D1Ar3 - mov D1.5, D1Ar1 - - ! Place all of the ffi_prep_args in position - mov D1Ar1, A0StP - - ! Call ffi_prep_args(stack, &ecif) -#ifdef __PIC__ - callr D1RtP, CNAME(ffi_prep_args@PLT) -#else - callr D1RtP, CNAME(ffi_prep_args) -#endif - - ! Restore fn pointer - - ! The foreign stack should look like this - ! XXXXX XXXXXX <--- stack pointer - ! FnArgN rvalue - ! FnArgN+2 FnArgN+1 - ! FnArgN+4 FnArgN+3 - ! .... - ! - - ! A0StP now points to the first (or return) argument + 4 - - ! Preserve cif->bytes - getl D0Ar2, D1Ar1, [--A0StP] - getl D0Ar4, D1Ar3, [--A0StP] - getl D0Ar6, D1Ar5, [--A0StP] - - ! Place A0StP to the first argument again - add A0StP, A0StP, #24 ! That's because we loaded 6 regs x 4 byte each - - ! A0FrP points to the initial stack without the reserved space for the - ! cifs->bytes, whilst A0StP points to the stack after the space allocation - - ! fn was the first argument of ffi_call_SYSV. - ! The stack at this point looks like this: - ! - ! A0StP(on entry to _SYSV) -> Arg6 Arg5 | low - ! Arg4 Arg3 | - ! Arg2 Arg1 | - ! A0FrP ----> D0FrtP D1RtP | - ! D1.5 D0.5 | - ! A0StP(bf prep_args) -> FnArgn FnArgn-1 | - ! FnArgn-2FnArgn-3 | - ! ................ | <= cifs->bytes - ! FnArg4 FnArg3 | - ! A0StP (prv_A0StP+cifs->bytes) FnArg2 FnArg1 | high - ! - ! fn was in Arg1 so it's located in in A0FrP+#-0xC - ! - - ! D0Re0 contains the size of arguments stored in registers - sub A0StP, A0StP, D0Re0 - - ! Arg1 is the function pointer for the foreign call. This has been - ! preserved in D1.5 - - ! Time to call (fn). Arguments should be like this: - ! Arg1-Arg6 are loaded to regs - ! The rest of the arguments are stored in stack pointed by A0StP - - call_reg D1.5 - - ! Reset stack. - - mov A0StP, A0FrP - - ! Load Arg1 with the pointer to storage for the return type - ! This was stored in Arg5 - - getd D1Ar1, [A0FrP+#-20] - - ! Load D0Ar2 with the return type code. This was stored in Arg4 (flags) - - getd D0Ar2, [A0FrP+#-16] - - ! We are ready to start processing the return value - ! D0Re0 (and D1Re0) hold the return value - - ! If the return value is NULL, assume no return value - cmp D1Ar1, #0 - beq LSYM(Lepilogue) - - ! return INT - cmp D0Ar2, #FFI_TYPE_INT - ! Sadly, there is no setd{cc} instruction so we need to workaround that - bne .INT64 - setd [D1Ar1], D0Re0 - b LSYM(Lepilogue) - - ! return INT64 -.INT64: - cmp D0Ar2, #FFI_TYPE_SINT64 - setleq [D1Ar1], D0Re0, D1Re0 - - ! return DOUBLE - cmp D0Ar2, #FFI_TYPE_DOUBLE - setl [D1AR1++], D0Re0, D1Re0 - -LSYM(Lepilogue): - ! At this point, the stack pointer points right after the argument - ! saved area. We need to restore 4 regs, therefore we need to move - ! 16 bytes ahead. - add A0StP, A0StP, #16 - RET_REGS "D1.5, D0.5" - RET_ARGS - getd D0Re0, [A0StP] - mov A0FrP, D0FrT - swap D1RtP, PC - -.ffi_call_SYSV_end: - .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) - - -/* - (called by ffi_metag_trampoline) - void ffi_closure_SYSV (ffi_closure*) - - (called by ffi_closure_SYSV) - unsigned int FFI_HIDDEN - ffi_closure_SYSV_inner (closure,respp, args) - ffi_closure *closure; - void **respp; - void *args; -*/ - -METAG_FUNC_START ffi_closure_SYSV - ! We assume that D1Ar1 holds the address of the - ! ffi_closure struct. We will use that to fetch the - ! arguments. The stack pointer points to an empty space - ! and it is ready to store more data. - - ! D1Ar1 is ready - ! Allocate stack space for return value - add A0StP, A0StP, #8 - ! Store it to D0Ar2 - sub D0Ar2, A0StP, #8 - - sub D1Ar3, A0FrP, #4 - - ! D1Ar3 contains the address of the original D1Ar1 argument - ! We need to subtract #4 later on - - ! Preverve D0Ar2 - mov D0.5, D0Ar2 - -#ifdef __PIC__ - callr D1RtP, CNAME(ffi_closure_SYSV_inner@PLT) -#else - callr D1RtP, CNAME(ffi_closure_SYSV_inner) -#endif - - ! Check the return value and store it to D0.5 - cmp D0Re0, #FFI_TYPE_INT - beq .Lretint - cmp D0Re0, #FFI_TYPE_DOUBLE - beq .Lretdouble -.Lclosure_epilogue: - sub A0StP, A0StP, #8 - RET_REGS "D1.5, D0.5" - RET_ARGS - swap D1RtP, PC - -.Lretint: - setd [D0.5], D0Re0 - b .Lclosure_epilogue -.Lretdouble: - setl [D0.5++], D0Re0, D1Re0 - b .Lclosure_epilogue -.ffi_closure_SYSV_end: -.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) - - -ENTRY(ffi_metag_trampoline) - SAVE_ARGS - ! New frame - mov A0FrP, A0StP - SAVE_REGS "D1.5, D0.5" - mov D0.5, PC - ! Load D1Ar1 the value of ffi_metag_trampoline - getd D1Ar1, [D0.5 + #8] - ! Jump to ffi_closure_SYSV - getd PC, [D0.5 + #12] diff --git a/user/mpy/lib/libffi/src/microblaze/ffi.c b/user/mpy/lib/libffi/src/microblaze/ffi.c deleted file mode 100644 index ea962ea..0000000 --- a/user/mpy/lib/libffi/src/microblaze/ffi.c +++ /dev/null @@ -1,321 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012, 2013 Xilinx, Inc - - MicroBlaze Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -extern void ffi_call_SYSV(void (*)(void*, extended_cif*), extended_cif*, - unsigned int, unsigned int, unsigned int*, void (*fn)(void), - unsigned int, unsigned int); - -extern void ffi_closure_SYSV(void); - -#define WORD_SIZE sizeof(unsigned int) -#define ARGS_REGISTER_SIZE (WORD_SIZE * 6) -#define WORD_ALIGN(x) ALIGN(x, WORD_SIZE) - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ -void ffi_prep_args(void* stack, extended_cif* ecif) -{ - unsigned int i; - ffi_type** p_arg; - void** p_argv; - void* stack_args_p = stack; - - p_argv = ecif->avalue; - - if (ecif == NULL || ecif->cif == NULL) { - return; /* no description to prepare */ - } - - if ((ecif->cif->rtype != NULL) && - (ecif->cif->rtype->type == FFI_TYPE_STRUCT)) - { - /* if return type is a struct which is referenced on the stack/reg5, - * by a pointer. Stored the return value pointer in r5. - */ - char* addr = stack_args_p; - memcpy(addr, &(ecif->rvalue), WORD_SIZE); - stack_args_p += WORD_SIZE; - } - - if (ecif->avalue == NULL) { - return; /* no arguments to prepare */ - } - - for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; - i++, p_arg++) - { - size_t size = (*p_arg)->size; - int type = (*p_arg)->type; - void* value = p_argv[i]; - char* addr = stack_args_p; - int aligned_size = WORD_ALIGN(size); - - /* force word alignment on the stack */ - stack_args_p += aligned_size; - - switch (type) - { - case FFI_TYPE_UINT8: - *(unsigned int *)addr = (unsigned int)*(UINT8*)(value); - break; - case FFI_TYPE_SINT8: - *(signed int *)addr = (signed int)*(SINT8*)(value); - break; - case FFI_TYPE_UINT16: - *(unsigned int *)addr = (unsigned int)*(UINT16*)(value); - break; - case FFI_TYPE_SINT16: - *(signed int *)addr = (signed int)*(SINT16*)(value); - break; - case FFI_TYPE_STRUCT: -#if __BIG_ENDIAN__ - /* - * MicroBlaze toolchain appears to emit: - * bsrli r5, r5, 8 (caller) - * ... - * - * ... - * bslli r5, r5, 8 (callee) - * - * For structs like "struct a { uint8_t a[3]; };", when passed - * by value. - * - * Structs like "struct b { uint16_t a; };" are also expected - * to be packed strangely in registers. - * - * This appears to be because the microblaze toolchain expects - * "struct b == uint16_t", which is only any issue for big - * endian. - * - * The following is a work around for big-endian only, for the - * above mentioned case, it will re-align the contents of a - * <= 3-byte struct value. - */ - if (size < WORD_SIZE) - { - memcpy (addr + (WORD_SIZE - size), value, size); - break; - } -#endif - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - default: - memcpy(addr, value, aligned_size); - } - } -} - -ffi_status ffi_prep_cif_machdep(ffi_cif* cif) -{ - /* check ABI */ - switch (cif->abi) - { - case FFI_SYSV: - break; - default: - return FFI_BAD_ABI; - } - return FFI_OK; -} - -void ffi_call(ffi_cif* cif, void (*fn)(void), void* rvalue, void** avalue) -{ - extended_cif ecif; - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { - ecif.rvalue = alloca(cif->rtype->size); - } else { - ecif.rvalue = rvalue; - } - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, - ecif.rvalue, fn, cif->rtype->type, cif->rtype->size); - break; - default: - FFI_ASSERT(0); - break; - } -} - -void ffi_closure_call_SYSV(void* register_args, void* stack_args, - ffi_closure* closure, void* rvalue, - unsigned int* rtype, unsigned int* rsize) -{ - /* prepare arguments for closure call */ - ffi_cif* cif = closure->cif; - ffi_type** arg_types = cif->arg_types; - - /* re-allocate data for the args. This needs to be done in order to keep - * multi-word objects (e.g. structs) in contiguous memory. Callers are not - * required to store the value of args in the lower 6 words in the stack - * (although they are allocated in the stack). - */ - char* stackclone = alloca(cif->bytes); - void** avalue = alloca(cif->nargs * sizeof(void*)); - void* struct_rvalue = NULL; - char* ptr = stackclone; - int i; - - /* copy registers into stack clone */ - int registers_used = cif->bytes; - if (registers_used > ARGS_REGISTER_SIZE) { - registers_used = ARGS_REGISTER_SIZE; - } - memcpy(stackclone, register_args, registers_used); - - /* copy stack allocated args into stack clone */ - if (cif->bytes > ARGS_REGISTER_SIZE) { - int stack_used = cif->bytes - ARGS_REGISTER_SIZE; - memcpy(stackclone + ARGS_REGISTER_SIZE, stack_args, stack_used); - } - - /* preserve struct type return pointer passing */ - if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { - struct_rvalue = *((void**)ptr); - ptr += WORD_SIZE; - } - - /* populate arg pointer list */ - for (i = 0; i < cif->nargs; i++) - { - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: -#ifdef __BIG_ENDIAN__ - avalue[i] = ptr + 3; -#else - avalue[i] = ptr; -#endif - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: -#ifdef __BIG_ENDIAN__ - avalue[i] = ptr + 2; -#else - avalue[i] = ptr; -#endif - break; - case FFI_TYPE_STRUCT: -#if __BIG_ENDIAN__ - /* - * Work around strange ABI behaviour. - * (see info in ffi_prep_args) - */ - if (arg_types[i]->size < WORD_SIZE) - { - memcpy (ptr, ptr + (WORD_SIZE - arg_types[i]->size), arg_types[i]->size); - } -#endif - avalue[i] = (void*)ptr; - break; - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_DOUBLE: - avalue[i] = ptr; - break; - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - default: - /* default 4-byte argument */ - avalue[i] = ptr; - break; - } - ptr += WORD_ALIGN(arg_types[i]->size); - } - - /* set the return type info passed back to the wrapper */ - *rsize = cif->rtype->size; - *rtype = cif->rtype->type; - if (struct_rvalue != NULL) { - closure->fun(cif, struct_rvalue, avalue, closure->user_data); - /* copy struct return pointer value into function return value */ - *((void**)rvalue) = struct_rvalue; - } else { - closure->fun(cif, rvalue, avalue, closure->user_data); - } -} - -ffi_status ffi_prep_closure_loc( - ffi_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void* user_data, void* codeloc) -{ - unsigned long* tramp = (unsigned long*)&(closure->tramp[0]); - unsigned long cls = (unsigned long)codeloc; - unsigned long fn = 0; - unsigned long fn_closure_call_sysv = (unsigned long)ffi_closure_call_SYSV; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - switch (cif->abi) - { - case FFI_SYSV: - fn = (unsigned long)ffi_closure_SYSV; - - /* load r11 (temp) with fn */ - /* imm fn(upper) */ - tramp[0] = 0xb0000000 | ((fn >> 16) & 0xffff); - /* addik r11, r0, fn(lower) */ - tramp[1] = 0x31600000 | (fn & 0xffff); - - /* load r12 (temp) with cls */ - /* imm cls(upper) */ - tramp[2] = 0xb0000000 | ((cls >> 16) & 0xffff); - /* addik r12, r0, cls(lower) */ - tramp[3] = 0x31800000 | (cls & 0xffff); - - /* load r3 (temp) with ffi_closure_call_SYSV */ - /* imm fn_closure_call_sysv(upper) */ - tramp[4] = 0xb0000000 | ((fn_closure_call_sysv >> 16) & 0xffff); - /* addik r3, r0, fn_closure_call_sysv(lower) */ - tramp[5] = 0x30600000 | (fn_closure_call_sysv & 0xffff); - /* branch/jump to address stored in r11 (fn) */ - tramp[6] = 0x98085800; /* bra r11 */ - - break; - default: - return FFI_BAD_ABI; - } - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/microblaze/ffitarget.h b/user/mpy/lib/libffi/src/microblaze/ffitarget.h deleted file mode 100644 index c6fa5a4..0000000 --- a/user/mpy/lib/libffi/src/microblaze/ffitarget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ----------------------------------------------------------------------- - ffitarget.h - Copyright (c) 2012, 2013 Xilinx, Inc - - Target configuration macros for MicroBlaze. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -/* Definitions for closures */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -#define FFI_TRAMPOLINE_SIZE (4*8) - -#endif diff --git a/user/mpy/lib/libffi/src/microblaze/sysv.S b/user/mpy/lib/libffi/src/microblaze/sysv.S deleted file mode 100644 index ea43e9d..0000000 --- a/user/mpy/lib/libffi/src/microblaze/sysv.S +++ /dev/null @@ -1,302 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2012, 2013 Xilinx, Inc - - MicroBlaze Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - /* - * arg[0] (r5) = ffi_prep_args, - * arg[1] (r6) = &ecif, - * arg[2] (r7) = cif->bytes, - * arg[3] (r8) = cif->flags, - * arg[4] (r9) = ecif.rvalue, - * arg[5] (r10) = fn - * arg[6] (sp[0]) = cif->rtype->type - * arg[7] (sp[4]) = cif->rtype->size - */ - .text - .globl ffi_call_SYSV - .type ffi_call_SYSV, @function -ffi_call_SYSV: - /* push callee saves */ - addik r1, r1, -20 - swi r19, r1, 0 /* Frame Pointer */ - swi r20, r1, 4 /* PIC register */ - swi r21, r1, 8 /* PIC register */ - swi r22, r1, 12 /* save for locals */ - swi r23, r1, 16 /* save for locals */ - - /* save the r5-r10 registers in the stack */ - addik r1, r1, -24 /* increment sp to store 6x 32-bit words */ - swi r5, r1, 0 - swi r6, r1, 4 - swi r7, r1, 8 - swi r8, r1, 12 - swi r9, r1, 16 - swi r10, r1, 20 - - /* save function pointer */ - addik r3, r5, 0 /* copy ffi_prep_args into r3 */ - addik r22, r1, 0 /* save sp for unallocated args into r22 (callee-saved) */ - addik r23, r10, 0 /* save function address into r23 (callee-saved) */ - - /* prepare stack with allocation for n (bytes = r7) args */ - rsub r1, r7, r1 /* subtract bytes from sp */ - - /* prep args for ffi_prep_args call */ - addik r5, r1, 0 /* store stack pointer into arg[0] */ - /* r6 still holds ecif for arg[1] */ - - /* Call ffi_prep_args(stack, &ecif). */ - addik r1, r1, -4 - swi r15, r1, 0 /* store the link register in the frame */ - brald r15, r3 - nop /* branch has delay slot */ - lwi r15, r1, 0 - addik r1, r1, 4 /* restore the link register from the frame */ - /* returns calling stack pointer location */ - - /* prepare args for fn call, prep_args populates them onto the stack */ - lwi r5, r1, 0 /* arg[0] */ - lwi r6, r1, 4 /* arg[1] */ - lwi r7, r1, 8 /* arg[2] */ - lwi r8, r1, 12 /* arg[3] */ - lwi r9, r1, 16 /* arg[4] */ - lwi r10, r1, 20 /* arg[5] */ - - /* call (fn) (...). */ - addik r1, r1, -4 - swi r15, r1, 0 /* store the link register in the frame */ - brald r15, r23 - nop /* branch has delay slot */ - lwi r15, r1, 0 - addik r1, r1, 4 /* restore the link register from the frame */ - - /* Remove the space we pushed for the args. */ - addik r1, r22, 0 /* restore old SP */ - - /* restore this functions parameters */ - lwi r5, r1, 0 /* arg[0] */ - lwi r6, r1, 4 /* arg[1] */ - lwi r7, r1, 8 /* arg[2] */ - lwi r8, r1, 12 /* arg[3] */ - lwi r9, r1, 16 /* arg[4] */ - lwi r10, r1, 20 /* arg[5] */ - addik r1, r1, 24 /* decrement sp to de-allocate 6x 32-bit words */ - - /* If the return value pointer is NULL, assume no return value. */ - beqi r9, ffi_call_SYSV_end - - lwi r22, r1, 48 /* get return type (20 for locals + 28 for arg[6]) */ - lwi r23, r1, 52 /* get return size (20 for locals + 32 for arg[7]) */ - - /* Check if return type is actually a struct, do nothing */ - rsubi r11, r22, FFI_TYPE_STRUCT - beqi r11, ffi_call_SYSV_end - - /* Return 8bit */ - rsubi r11, r23, 1 - beqi r11, ffi_call_SYSV_store8 - - /* Return 16bit */ - rsubi r11, r23, 2 - beqi r11, ffi_call_SYSV_store16 - - /* Return 32bit */ - rsubi r11, r23, 4 - beqi r11, ffi_call_SYSV_store32 - - /* Return 64bit */ - rsubi r11, r23, 8 - beqi r11, ffi_call_SYSV_store64 - - /* Didn't match anything */ - bri ffi_call_SYSV_end - -ffi_call_SYSV_store64: - swi r3, r9, 0 /* store word r3 into return value */ - swi r4, r9, 4 /* store word r4 into return value */ - bri ffi_call_SYSV_end - -ffi_call_SYSV_store32: - swi r3, r9, 0 /* store word r3 into return value */ - bri ffi_call_SYSV_end - -ffi_call_SYSV_store16: -#ifdef __BIG_ENDIAN__ - shi r3, r9, 2 /* store half-word r3 into return value */ -#else - shi r3, r9, 0 /* store half-word r3 into return value */ -#endif - bri ffi_call_SYSV_end - -ffi_call_SYSV_store8: -#ifdef __BIG_ENDIAN__ - sbi r3, r9, 3 /* store byte r3 into return value */ -#else - sbi r3, r9, 0 /* store byte r3 into return value */ -#endif - bri ffi_call_SYSV_end - -ffi_call_SYSV_end: - /* callee restores */ - lwi r19, r1, 0 /* frame pointer */ - lwi r20, r1, 4 /* PIC register */ - lwi r21, r1, 8 /* PIC register */ - lwi r22, r1, 12 - lwi r23, r1, 16 - addik r1, r1, 20 - - /* return from sub-routine (with delay slot) */ - rtsd r15, 8 - nop - - .size ffi_call_SYSV, . - ffi_call_SYSV - -/* ------------------------------------------------------------------------- */ - - /* - * args passed into this function, are passed down to the callee. - * this function is the target of the closure trampoline, as such r12 is - * a pointer to the closure object. - */ - .text - .globl ffi_closure_SYSV - .type ffi_closure_SYSV, @function -ffi_closure_SYSV: - /* push callee saves */ - addik r11, r1, 28 /* save stack args start location (excluding regs/link) */ - addik r1, r1, -12 - swi r19, r1, 0 /* Frame Pointer */ - swi r20, r1, 4 /* PIC register */ - swi r21, r1, 8 /* PIC register */ - - /* store register args on stack */ - addik r1, r1, -24 - swi r5, r1, 0 - swi r6, r1, 4 - swi r7, r1, 8 - swi r8, r1, 12 - swi r9, r1, 16 - swi r10, r1, 20 - - /* setup args */ - addik r5, r1, 0 /* register_args */ - addik r6, r11, 0 /* stack_args */ - addik r7, r12, 0 /* closure object */ - addik r1, r1, -8 /* allocate return value */ - addik r8, r1, 0 /* void* rvalue */ - addik r1, r1, -8 /* allocate for return type/size values */ - addik r9, r1, 0 /* void* rtype */ - addik r10, r1, 4 /* void* rsize */ - - /* call the wrap_call function */ - addik r1, r1, -28 /* allocate args + link reg */ - swi r15, r1, 0 /* store the link register in the frame */ - brald r15, r3 - nop /* branch has delay slot */ - lwi r15, r1, 0 - addik r1, r1, 28 /* restore the link register from the frame */ - -ffi_closure_SYSV_prepare_return: - lwi r9, r1, 0 /* rtype */ - lwi r10, r1, 4 /* rsize */ - addik r1, r1, 8 /* de-allocate return info values */ - - /* Check if return type is actually a struct, store 4 bytes */ - rsubi r11, r9, FFI_TYPE_STRUCT - beqi r11, ffi_closure_SYSV_store32 - - /* Return 8bit */ - rsubi r11, r10, 1 - beqi r11, ffi_closure_SYSV_store8 - - /* Return 16bit */ - rsubi r11, r10, 2 - beqi r11, ffi_closure_SYSV_store16 - - /* Return 32bit */ - rsubi r11, r10, 4 - beqi r11, ffi_closure_SYSV_store32 - - /* Return 64bit */ - rsubi r11, r10, 8 - beqi r11, ffi_closure_SYSV_store64 - - /* Didn't match anything */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store64: - lwi r3, r1, 0 /* store word r3 into return value */ - lwi r4, r1, 4 /* store word r4 into return value */ - /* 64 bits == 2 words, no sign extend occurs */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store32: - lwi r3, r1, 0 /* store word r3 into return value */ - /* 32 bits == 1 word, no sign extend occurs */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store16: -#ifdef __BIG_ENDIAN__ - lhui r3, r1, 2 /* store half-word r3 into return value */ -#else - lhui r3, r1, 0 /* store half-word r3 into return value */ -#endif - rsubi r11, r9, FFI_TYPE_SINT16 - bnei r11, ffi_closure_SYSV_end - sext16 r3, r3 /* fix sign extend of sint8 */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store8: -#ifdef __BIG_ENDIAN__ - lbui r3, r1, 3 /* store byte r3 into return value */ -#else - lbui r3, r1, 0 /* store byte r3 into return value */ -#endif - rsubi r11, r9, FFI_TYPE_SINT8 - bnei r11, ffi_closure_SYSV_end - sext8 r3, r3 /* fix sign extend of sint8 */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_end: - addik r1, r1, 8 /* de-allocate return value */ - - /* de-allocate stored args */ - addik r1, r1, 24 - - /* callee restores */ - lwi r19, r1, 0 /* frame pointer */ - lwi r20, r1, 4 /* PIC register */ - lwi r21, r1, 8 /* PIC register */ - addik r1, r1, 12 - - /* return from sub-routine (with delay slot) */ - rtsd r15, 8 - nop - - .size ffi_closure_SYSV, . - ffi_closure_SYSV diff --git a/user/mpy/lib/libffi/src/mips/ffi.c b/user/mpy/lib/libffi/src/mips/ffi.c deleted file mode 100644 index 5d0dd70..0000000 --- a/user/mpy/lib/libffi/src/mips/ffi.c +++ /dev/null @@ -1,1050 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011 Anthony Green - Copyright (c) 2008 David Daney - Copyright (c) 1996, 2007, 2008, 2011 Red Hat, Inc. - - MIPS Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -#ifdef __GNUC__ -# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) -# define USE__BUILTIN___CLEAR_CACHE 1 -# endif -#endif - -#ifndef USE__BUILTIN___CLEAR_CACHE -# if defined(__OpenBSD__) -# include -# else -# include -# endif -#endif - -#ifdef FFI_DEBUG -# define FFI_MIPS_STOP_HERE() ffi_stop_here() -#else -# define FFI_MIPS_STOP_HERE() do {} while(0) -#endif - -#ifdef FFI_MIPS_N32 -#define FIX_ARGP \ -FFI_ASSERT(argp <= &stack[bytes]); \ -if (argp == &stack[bytes]) \ -{ \ - argp = stack; \ - FFI_MIPS_STOP_HERE(); \ -} -#else -#define FIX_ARGP -#endif - - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -static void ffi_prep_args(char *stack, - extended_cif *ecif, - int bytes, - int flags) -{ - int i; - void **p_argv; - char *argp; - ffi_type **p_arg; - -#ifdef FFI_MIPS_N32 - /* If more than 8 double words are used, the remainder go - on the stack. We reorder stuff on the stack here to - support this easily. */ - if (bytes > 8 * sizeof(ffi_arg)) - argp = &stack[bytes - (8 * sizeof(ffi_arg))]; - else - argp = stack; -#else - argp = stack; -#endif - - memset(stack, 0, bytes); - -#ifdef FFI_MIPS_N32 - if ( ecif->cif->rstruct_flag != 0 ) -#else - if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) -#endif - { - *(ffi_arg *) argp = (ffi_arg) ecif->rvalue; - argp += sizeof(ffi_arg); - FIX_ARGP; - } - - p_argv = ecif->avalue; - - for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; i++, p_arg++) - { - size_t z; - unsigned int a; - - /* Align if necessary. */ - a = (*p_arg)->alignment; - if (a < sizeof(ffi_arg)) - a = sizeof(ffi_arg); - - if ((a - 1) & (unsigned long) argp) - { - argp = (char *) ALIGN(argp, a); - FIX_ARGP; - } - - z = (*p_arg)->size; - if (z <= sizeof(ffi_arg)) - { - int type = (*p_arg)->type; - z = sizeof(ffi_arg); - - /* The size of a pointer depends on the ABI */ - if (type == FFI_TYPE_POINTER) - type = (ecif->cif->abi == FFI_N64 - || ecif->cif->abi == FFI_N64_SOFT_FLOAT) - ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32; - - if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT - || ecif->cif->abi == FFI_N64_SOFT_FLOAT)) - { - switch (type) - { - case FFI_TYPE_FLOAT: - type = FFI_TYPE_UINT32; - break; - case FFI_TYPE_DOUBLE: - type = FFI_TYPE_UINT64; - break; - default: - break; - } - } - switch (type) - { - case FFI_TYPE_SINT8: - *(ffi_arg *)argp = *(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(ffi_arg *)argp = *(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(ffi_arg *)argp = *(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(ffi_arg *)argp = *(UINT16 *)(* p_argv); - break; - - case FFI_TYPE_SINT32: - *(ffi_arg *)argp = *(SINT32 *)(* p_argv); - break; - - case FFI_TYPE_UINT32: -#ifdef FFI_MIPS_N32 - /* The N32 ABI requires that 32-bit integers - be sign-extended to 64-bits, regardless of - whether they are signed or unsigned. */ - *(ffi_arg *)argp = *(SINT32 *)(* p_argv); -#else - *(ffi_arg *)argp = *(UINT32 *)(* p_argv); -#endif - break; - - /* This can only happen with 64bit slots. */ - case FFI_TYPE_FLOAT: - *(float *) argp = *(float *)(* p_argv); - break; - - /* Handle structures. */ - default: - memcpy(argp, *p_argv, (*p_arg)->size); - break; - } - } - else - { -#ifdef FFI_MIPS_O32 - memcpy(argp, *p_argv, z); -#else - { - unsigned long end = (unsigned long) argp + z; - unsigned long cap = (unsigned long) stack + bytes; - - /* Check if the data will fit within the register space. - Handle it if it doesn't. */ - - if (end <= cap) - memcpy(argp, *p_argv, z); - else - { - unsigned long portion = cap - (unsigned long)argp; - - memcpy(argp, *p_argv, portion); - argp = stack; - z -= portion; - memcpy(argp, (void*)((unsigned long)(*p_argv) + portion), - z); - } - } -#endif - } - p_argv++; - argp += z; - FIX_ARGP; - } -} - -#ifdef FFI_MIPS_N32 - -/* The n32 spec says that if "a chunk consists solely of a double - float field (but not a double, which is part of a union), it - is passed in a floating point register. Any other chunk is - passed in an integer register". This code traverses structure - definitions and generates the appropriate flags. */ - -static unsigned -calc_n32_struct_flags(int soft_float, ffi_type *arg, - unsigned *loc, unsigned *arg_reg) -{ - unsigned flags = 0; - unsigned index = 0; - - ffi_type *e; - - if (soft_float) - return 0; - - while ((e = arg->elements[index])) - { - /* Align this object. */ - *loc = ALIGN(*loc, e->alignment); - if (e->type == FFI_TYPE_DOUBLE) - { - /* Already aligned to FFI_SIZEOF_ARG. */ - *arg_reg = *loc / FFI_SIZEOF_ARG; - if (*arg_reg > 7) - break; - flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS)); - *loc += e->size; - } - else - *loc += e->size; - index++; - } - /* Next Argument register at alignment of FFI_SIZEOF_ARG. */ - *arg_reg = ALIGN(*loc, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - - return flags; -} - -static unsigned -calc_n32_return_struct_flags(int soft_float, ffi_type *arg) -{ - unsigned flags = 0; - unsigned small = FFI_TYPE_SMALLSTRUCT; - ffi_type *e; - - /* Returning structures under n32 is a tricky thing. - A struct with only one or two floating point fields - is returned in $f0 (and $f2 if necessary). Any other - struct results at most 128 bits are returned in $2 - (the first 64 bits) and $3 (remainder, if necessary). - Larger structs are handled normally. */ - - if (arg->size > 16) - return 0; - - if (arg->size > 8) - small = FFI_TYPE_SMALLSTRUCT2; - - e = arg->elements[0]; - - if (e->type == FFI_TYPE_DOUBLE) - flags = FFI_TYPE_DOUBLE; - else if (e->type == FFI_TYPE_FLOAT) - flags = FFI_TYPE_FLOAT; - - if (flags && (e = arg->elements[1])) - { - if (e->type == FFI_TYPE_DOUBLE) - flags += FFI_TYPE_DOUBLE << FFI_FLAG_BITS; - else if (e->type == FFI_TYPE_FLOAT) - flags += FFI_TYPE_FLOAT << FFI_FLAG_BITS; - else - return small; - - if (flags && (arg->elements[2])) - { - /* There are three arguments and the first two are - floats! This must be passed the old way. */ - return small; - } - if (soft_float) - flags += FFI_TYPE_STRUCT_SOFT; - } - else - if (!flags) - return small; - - return flags; -} - -#endif - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - cif->flags = 0; - -#ifdef FFI_MIPS_O32 - /* Set the flags necessary for O32 processing. FFI_O32_SOFT_FLOAT - * does not have special handling for floating point args. - */ - - if (cif->rtype->type != FFI_TYPE_STRUCT && cif->abi == FFI_O32) - { - if (cif->nargs > 0) - { - switch ((cif->arg_types)[0]->type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags += (cif->arg_types)[0]->type; - break; - - default: - break; - } - - if (cif->nargs > 1) - { - /* Only handle the second argument if the first - is a float or double. */ - if (cif->flags) - { - switch ((cif->arg_types)[1]->type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags += (cif->arg_types)[1]->type << FFI_FLAG_BITS; - break; - - default: - break; - } - } - } - } - } - - /* Set the return type flag */ - - if (cif->abi == FFI_O32_SOFT_FLOAT) - { - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2); - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 2); - break; - - case FFI_TYPE_FLOAT: - default: - cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2); - break; - } - } - else - { - /* FFI_O32 */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2); - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 2); - break; - - default: - cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2); - break; - } - } -#endif - -#ifdef FFI_MIPS_N32 - /* Set the flags necessary for N32 processing */ - { - int type; - unsigned arg_reg = 0; - unsigned loc = 0; - unsigned count = (cif->nargs < 8) ? cif->nargs : 8; - unsigned index = 0; - - unsigned struct_flags = 0; - int soft_float = (cif->abi == FFI_N32_SOFT_FLOAT - || cif->abi == FFI_N64_SOFT_FLOAT); - - if (cif->rtype->type == FFI_TYPE_STRUCT) - { - struct_flags = calc_n32_return_struct_flags(soft_float, cif->rtype); - - if (struct_flags == 0) - { - /* This means that the structure is being passed as - a hidden argument */ - - arg_reg = 1; - count = (cif->nargs < 7) ? cif->nargs : 7; - - cif->rstruct_flag = !0; - } - else - cif->rstruct_flag = 0; - } - else - cif->rstruct_flag = 0; - - while (count-- > 0 && arg_reg < 8) - { - type = (cif->arg_types)[index]->type; - if (soft_float) - { - switch (type) - { - case FFI_TYPE_FLOAT: - type = FFI_TYPE_UINT32; - break; - case FFI_TYPE_DOUBLE: - type = FFI_TYPE_UINT64; - break; - default: - break; - } - } - switch (type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags += - ((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS)); - arg_reg++; - break; - case FFI_TYPE_LONGDOUBLE: - /* Align it. */ - arg_reg = ALIGN(arg_reg, 2); - /* Treat it as two adjacent doubles. */ - if (soft_float) - { - arg_reg += 2; - } - else - { - cif->flags += - (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS)); - arg_reg++; - cif->flags += - (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS)); - arg_reg++; - } - break; - - case FFI_TYPE_STRUCT: - loc = arg_reg * FFI_SIZEOF_ARG; - cif->flags += calc_n32_struct_flags(soft_float, - (cif->arg_types)[index], - &loc, &arg_reg); - break; - - default: - arg_reg++; - break; - } - - index++; - } - - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_STRUCT: - { - if (struct_flags == 0) - { - /* The structure is returned through a hidden - first argument. Do nothing, 'cause FFI_TYPE_VOID - is 0 */ - } - else - { - /* The structure is returned via some tricky - mechanism */ - cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8); - cif->flags += struct_flags << (4 + (FFI_FLAG_BITS * 8)); - } - break; - } - - case FFI_TYPE_VOID: - /* Do nothing, 'cause FFI_TYPE_VOID is 0 */ - break; - - case FFI_TYPE_POINTER: - if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32) - cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8); - else - cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8); - break; - - case FFI_TYPE_FLOAT: - if (soft_float) - { - cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8); - break; - } - /* else fall through */ - case FFI_TYPE_DOUBLE: - if (soft_float) - cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8); - else - cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8); - break; - - case FFI_TYPE_LONGDOUBLE: - /* Long double is returned as if it were a struct containing - two doubles. */ - if (soft_float) - { - cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8); - cif->flags += FFI_TYPE_SMALLSTRUCT2 << (4 + (FFI_FLAG_BITS * 8)); - } - else - { - cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8); - cif->flags += (FFI_TYPE_DOUBLE - + (FFI_TYPE_DOUBLE << FFI_FLAG_BITS)) - << (4 + (FFI_FLAG_BITS * 8)); - } - break; - default: - cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8); - break; - } - } -#endif - - return FFI_OK; -} - -/* Low level routine for calling O32 functions */ -extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int), - extended_cif *, unsigned, - unsigned, unsigned *, void (*)(void)); - -/* Low level routine for calling N32 functions */ -extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int), - extended_cif *, unsigned, - unsigned, void *, void (*)(void)); - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - ecif.rvalue = alloca(cif->rtype->size); - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { -#ifdef FFI_MIPS_O32 - case FFI_O32: - case FFI_O32_SOFT_FLOAT: - ffi_call_O32(ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - break; -#endif - -#ifdef FFI_MIPS_N32 - case FFI_N32: - case FFI_N32_SOFT_FLOAT: - case FFI_N64: - case FFI_N64_SOFT_FLOAT: - { - int copy_rvalue = 0; - int copy_offset = 0; - char *rvalue_copy = ecif.rvalue; - if (cif->rtype->type == FFI_TYPE_STRUCT && cif->rtype->size < 16) - { - /* For structures smaller than 16 bytes we clobber memory - in 8 byte increments. Make a copy so we don't clobber - the callers memory outside of the struct bounds. */ - rvalue_copy = alloca(16); - copy_rvalue = 1; - } - else if (cif->rtype->type == FFI_TYPE_FLOAT - && (cif->abi == FFI_N64_SOFT_FLOAT - || cif->abi == FFI_N32_SOFT_FLOAT)) - { - rvalue_copy = alloca (8); - copy_rvalue = 1; -#if defined(__MIPSEB__) || defined(_MIPSEB) - copy_offset = 4; -#endif - } - ffi_call_N32(ffi_prep_args, &ecif, cif->bytes, - cif->flags, rvalue_copy, fn); - if (copy_rvalue) - memcpy(ecif.rvalue, rvalue_copy + copy_offset, cif->rtype->size); - } - break; -#endif - - default: - FFI_ASSERT(0); - break; - } -} - -#if FFI_CLOSURES -#if defined(FFI_MIPS_O32) -extern void ffi_closure_O32(void); -#else -extern void ffi_closure_N32(void); -#endif /* FFI_MIPS_O32 */ - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp = (unsigned int *) &closure->tramp[0]; - void * fn; - char *clear_location = (char *) codeloc; - -#if defined(FFI_MIPS_O32) - if (cif->abi != FFI_O32 && cif->abi != FFI_O32_SOFT_FLOAT) - return FFI_BAD_ABI; - fn = ffi_closure_O32; -#else -#if _MIPS_SIM ==_ABIN32 - if (cif->abi != FFI_N32 - && cif->abi != FFI_N32_SOFT_FLOAT) - return FFI_BAD_ABI; -#else - if (cif->abi != FFI_N64 - && cif->abi != FFI_N64_SOFT_FLOAT) - return FFI_BAD_ABI; -#endif - fn = ffi_closure_N32; -#endif /* FFI_MIPS_O32 */ - -#if defined(FFI_MIPS_O32) || (_MIPS_SIM ==_ABIN32) - /* lui $25,high(fn) */ - tramp[0] = 0x3c190000 | ((unsigned)fn >> 16); - /* ori $25,low(fn) */ - tramp[1] = 0x37390000 | ((unsigned)fn & 0xffff); - /* lui $12,high(codeloc) */ - tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16); - /* jr $25 */ - tramp[3] = 0x03200008; - /* ori $12,low(codeloc) */ - tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff); -#else - /* N64 has a somewhat larger trampoline. */ - /* lui $25,high(fn) */ - tramp[0] = 0x3c190000 | ((unsigned long)fn >> 48); - /* lui $12,high(codeloc) */ - tramp[1] = 0x3c0c0000 | ((unsigned long)codeloc >> 48); - /* ori $25,mid-high(fn) */ - tramp[2] = 0x37390000 | (((unsigned long)fn >> 32 ) & 0xffff); - /* ori $12,mid-high(codeloc) */ - tramp[3] = 0x358c0000 | (((unsigned long)codeloc >> 32) & 0xffff); - /* dsll $25,$25,16 */ - tramp[4] = 0x0019cc38; - /* dsll $12,$12,16 */ - tramp[5] = 0x000c6438; - /* ori $25,mid-low(fn) */ - tramp[6] = 0x37390000 | (((unsigned long)fn >> 16 ) & 0xffff); - /* ori $12,mid-low(codeloc) */ - tramp[7] = 0x358c0000 | (((unsigned long)codeloc >> 16) & 0xffff); - /* dsll $25,$25,16 */ - tramp[8] = 0x0019cc38; - /* dsll $12,$12,16 */ - tramp[9] = 0x000c6438; - /* ori $25,low(fn) */ - tramp[10] = 0x37390000 | ((unsigned long)fn & 0xffff); - /* jr $25 */ - tramp[11] = 0x03200008; - /* ori $12,low(codeloc) */ - tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff); - -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - -#ifdef USE__BUILTIN___CLEAR_CACHE - __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE); -#else - cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE); -#endif - return FFI_OK; -} - -/* - * Decodes the arguments to a function, which will be stored on the - * stack. AR is the pointer to the beginning of the integer arguments - * (and, depending upon the arguments, some floating-point arguments - * as well). FPR is a pointer to the area where floating point - * registers have been saved, if any. - * - * RVALUE is the location where the function return value will be - * stored. CLOSURE is the prepared closure to invoke. - * - * This function should only be called from assembly, which is in - * turn called from a trampoline. - * - * Returns the function return type. - * - * Based on the similar routine for sparc. - */ -int -ffi_closure_mips_inner_O32 (ffi_closure *closure, - void *rvalue, ffi_arg *ar, - double *fpr) -{ - ffi_cif *cif; - void **avaluep; - ffi_arg *avalue; - ffi_type **arg_types; - int i, avn, argn, seen_int; - - cif = closure->cif; - avalue = alloca (cif->nargs * sizeof (ffi_arg)); - avaluep = alloca (cif->nargs * sizeof (ffi_arg)); - - seen_int = (cif->abi == FFI_O32_SOFT_FLOAT); - argn = 0; - - if ((cif->flags >> (FFI_FLAG_BITS * 2)) == FFI_TYPE_STRUCT) - { - rvalue = (void *)(UINT32)ar[0]; - argn = 1; - } - - i = 0; - avn = cif->nargs; - arg_types = cif->arg_types; - - while (i < avn) - { - if (i < 2 && !seen_int && - (arg_types[i]->type == FFI_TYPE_FLOAT || - arg_types[i]->type == FFI_TYPE_DOUBLE || - arg_types[i]->type == FFI_TYPE_LONGDOUBLE)) - { -#if defined(__MIPSEB__) || defined(_MIPSEB) - if (arg_types[i]->type == FFI_TYPE_FLOAT) - avaluep[i] = ((char *) &fpr[i]) + sizeof (float); - else -#endif - avaluep[i] = (char *) &fpr[i]; - } - else - { - if (arg_types[i]->alignment == 8 && (argn & 0x1)) - argn++; - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - avaluep[i] = &avalue[i]; - *(SINT8 *) &avalue[i] = (SINT8) ar[argn]; - break; - - case FFI_TYPE_UINT8: - avaluep[i] = &avalue[i]; - *(UINT8 *) &avalue[i] = (UINT8) ar[argn]; - break; - - case FFI_TYPE_SINT16: - avaluep[i] = &avalue[i]; - *(SINT16 *) &avalue[i] = (SINT16) ar[argn]; - break; - - case FFI_TYPE_UINT16: - avaluep[i] = &avalue[i]; - *(UINT16 *) &avalue[i] = (UINT16) ar[argn]; - break; - - default: - avaluep[i] = (char *) &ar[argn]; - break; - } - seen_int = 1; - } - argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - i++; - } - - /* Invoke the closure. */ - (closure->fun) (cif, rvalue, avaluep, closure->user_data); - - if (cif->abi == FFI_O32_SOFT_FLOAT) - { - switch (cif->rtype->type) - { - case FFI_TYPE_FLOAT: - return FFI_TYPE_INT; - case FFI_TYPE_DOUBLE: - return FFI_TYPE_UINT64; - default: - return cif->rtype->type; - } - } - else - { - return cif->rtype->type; - } -} - -#if defined(FFI_MIPS_N32) - -static void -copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type, - int argn, unsigned arg_offset, ffi_arg *ar, - ffi_arg *fpr, int soft_float) -{ - ffi_type **elt_typep = type->elements; - while(*elt_typep) - { - ffi_type *elt_type = *elt_typep; - unsigned o; - char *tp; - char *argp; - char *fpp; - - o = ALIGN(offset, elt_type->alignment); - arg_offset += o - offset; - offset = o; - argn += arg_offset / sizeof(ffi_arg); - arg_offset = arg_offset % sizeof(ffi_arg); - - argp = (char *)(ar + argn); - fpp = (char *)(argn >= 8 ? ar + argn : fpr + argn); - - tp = target + offset; - - if (elt_type->type == FFI_TYPE_DOUBLE && !soft_float) - *(double *)tp = *(double *)fpp; - else - memcpy(tp, argp + arg_offset, elt_type->size); - - offset += elt_type->size; - arg_offset += elt_type->size; - elt_typep++; - argn += arg_offset / sizeof(ffi_arg); - arg_offset = arg_offset % sizeof(ffi_arg); - } -} - -/* - * Decodes the arguments to a function, which will be stored on the - * stack. AR is the pointer to the beginning of the integer - * arguments. FPR is a pointer to the area where floating point - * registers have been saved. - * - * RVALUE is the location where the function return value will be - * stored. CLOSURE is the prepared closure to invoke. - * - * This function should only be called from assembly, which is in - * turn called from a trampoline. - * - * Returns the function return flags. - * - */ -int -ffi_closure_mips_inner_N32 (ffi_closure *closure, - void *rvalue, ffi_arg *ar, - ffi_arg *fpr) -{ - ffi_cif *cif; - void **avaluep; - ffi_arg *avalue; - ffi_type **arg_types; - int i, avn, argn; - int soft_float; - ffi_arg *argp; - - cif = closure->cif; - soft_float = cif->abi == FFI_N64_SOFT_FLOAT - || cif->abi == FFI_N32_SOFT_FLOAT; - avalue = alloca (cif->nargs * sizeof (ffi_arg)); - avaluep = alloca (cif->nargs * sizeof (ffi_arg)); - - argn = 0; - - if (cif->rstruct_flag) - { -#if _MIPS_SIM==_ABIN32 - rvalue = (void *)(UINT32)ar[0]; -#else /* N64 */ - rvalue = (void *)ar[0]; -#endif - argn = 1; - } - - i = 0; - avn = cif->nargs; - arg_types = cif->arg_types; - - while (i < avn) - { - if (arg_types[i]->type == FFI_TYPE_FLOAT - || arg_types[i]->type == FFI_TYPE_DOUBLE - || arg_types[i]->type == FFI_TYPE_LONGDOUBLE) - { - argp = (argn >= 8 || soft_float) ? ar + argn : fpr + argn; - if ((arg_types[i]->type == FFI_TYPE_LONGDOUBLE) && ((unsigned)argp & (arg_types[i]->alignment-1))) - { - argp=(ffi_arg*)ALIGN(argp,arg_types[i]->alignment); - argn++; - } -#if defined(__MIPSEB__) || defined(_MIPSEB) - if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8) - avaluep[i] = ((char *) argp) + sizeof (float); - else -#endif - avaluep[i] = (char *) argp; - } - else - { - unsigned type = arg_types[i]->type; - - if (arg_types[i]->alignment > sizeof(ffi_arg)) - argn = ALIGN(argn, arg_types[i]->alignment / sizeof(ffi_arg)); - - argp = ar + argn; - - /* The size of a pointer depends on the ABI */ - if (type == FFI_TYPE_POINTER) - type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT) - ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32; - - if (soft_float && type == FFI_TYPE_FLOAT) - type = FFI_TYPE_UINT32; - - switch (type) - { - case FFI_TYPE_SINT8: - avaluep[i] = &avalue[i]; - *(SINT8 *) &avalue[i] = (SINT8) *argp; - break; - - case FFI_TYPE_UINT8: - avaluep[i] = &avalue[i]; - *(UINT8 *) &avalue[i] = (UINT8) *argp; - break; - - case FFI_TYPE_SINT16: - avaluep[i] = &avalue[i]; - *(SINT16 *) &avalue[i] = (SINT16) *argp; - break; - - case FFI_TYPE_UINT16: - avaluep[i] = &avalue[i]; - *(UINT16 *) &avalue[i] = (UINT16) *argp; - break; - - case FFI_TYPE_SINT32: - avaluep[i] = &avalue[i]; - *(SINT32 *) &avalue[i] = (SINT32) *argp; - break; - - case FFI_TYPE_UINT32: - avaluep[i] = &avalue[i]; - *(UINT32 *) &avalue[i] = (UINT32) *argp; - break; - - case FFI_TYPE_STRUCT: - if (argn < 8) - { - /* Allocate space for the struct as at least part of - it was passed in registers. */ - avaluep[i] = alloca(arg_types[i]->size); - copy_struct_N32(avaluep[i], 0, cif->abi, arg_types[i], - argn, 0, ar, fpr, soft_float); - - break; - } - /* Else fall through. */ - default: - avaluep[i] = (char *) argp; - break; - } - } - argn += ALIGN(arg_types[i]->size, sizeof(ffi_arg)) / sizeof(ffi_arg); - i++; - } - - /* Invoke the closure. */ - (closure->fun) (cif, rvalue, avaluep, closure->user_data); - - return cif->flags >> (FFI_FLAG_BITS * 8); -} - -#endif /* FFI_MIPS_N32 */ - -#endif /* FFI_CLOSURES */ diff --git a/user/mpy/lib/libffi/src/mips/ffitarget.h b/user/mpy/lib/libffi/src/mips/ffitarget.h deleted file mode 100644 index 717d659..0000000 --- a/user/mpy/lib/libffi/src/mips/ffitarget.h +++ /dev/null @@ -1,247 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for MIPS. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifdef linux -# include -#elif defined(__rtems__) -/* - * Subprogram calling convention - copied from sgidefs.h - */ -#define _MIPS_SIM_ABI32 1 -#define _MIPS_SIM_NABI32 2 -#define _MIPS_SIM_ABI64 3 -#elif !defined(__OpenBSD__) -# include -#endif - -# ifndef _ABIN32 -# define _ABIN32 _MIPS_SIM_NABI32 -# endif -# ifndef _ABI64 -# define _ABI64 _MIPS_SIM_ABI64 -# endif -# ifndef _ABIO32 -# define _ABIO32 _MIPS_SIM_ABI32 -# endif - -#if !defined(_MIPS_SIM) -# error -- something is very wrong -- -#else -# if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64)) -# define FFI_MIPS_N32 -# else -# if (_MIPS_SIM==_ABIO32 && defined(_ABIO32)) -# define FFI_MIPS_O32 -# else -# error -- this is an unsupported platform -- -# endif -# endif -#endif - -#ifdef FFI_MIPS_O32 -/* O32 stack frames have 32bit integer args */ -# define FFI_SIZEOF_ARG 4 -#else -/* N32 and N64 frames have 64bit integer args */ -# define FFI_SIZEOF_ARG 8 -# if _MIPS_SIM == _ABIN32 -# define FFI_SIZEOF_JAVA_RAW 4 -# endif -#endif - -#define FFI_FLAG_BITS 2 - -/* SGI's strange assembler requires that we multiply by 4 rather - than shift left by FFI_FLAG_BITS */ - -#define FFI_ARGS_D FFI_TYPE_DOUBLE -#define FFI_ARGS_F FFI_TYPE_FLOAT -#define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE -#define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT -#define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT -#define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE - -/* Needed for N32 structure returns */ -#define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8 -#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8 - -#if 0 -/* The SGI assembler can't handle this.. */ -#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT -/* (and so on) */ -#else -/* ...so we calculate these by hand! */ -#define FFI_TYPE_STRUCT_D 61 -#define FFI_TYPE_STRUCT_F 45 -#define FFI_TYPE_STRUCT_DD 253 -#define FFI_TYPE_STRUCT_FF 173 -#define FFI_TYPE_STRUCT_FD 237 -#define FFI_TYPE_STRUCT_DF 189 -#define FFI_TYPE_STRUCT_SMALL 93 -#define FFI_TYPE_STRUCT_SMALL2 109 - -/* and for n32 soft float, add 16 * 2^4 */ -#define FFI_TYPE_STRUCT_D_SOFT 317 -#define FFI_TYPE_STRUCT_F_SOFT 301 -#define FFI_TYPE_STRUCT_DD_SOFT 509 -#define FFI_TYPE_STRUCT_FF_SOFT 429 -#define FFI_TYPE_STRUCT_FD_SOFT 493 -#define FFI_TYPE_STRUCT_DF_SOFT 445 -#define FFI_TYPE_STRUCT_SOFT 16 -#endif - -#ifdef LIBFFI_ASM -#define v0 $2 -#define v1 $3 -#define a0 $4 -#define a1 $5 -#define a2 $6 -#define a3 $7 -#define a4 $8 -#define a5 $9 -#define a6 $10 -#define a7 $11 -#define t0 $8 -#define t1 $9 -#define t2 $10 -#define t3 $11 -#define t4 $12 -#define t5 $13 -#define t6 $14 -#define t7 $15 -#define t8 $24 -#define t9 $25 -#define ra $31 - -#ifdef FFI_MIPS_O32 -# define REG_L lw -# define REG_S sw -# define SUBU subu -# define ADDU addu -# define SRL srl -# define LI li -#else /* !FFI_MIPS_O32 */ -# define REG_L ld -# define REG_S sd -# define SUBU dsubu -# define ADDU daddu -# define SRL dsrl -# define LI dli -# if (_MIPS_SIM==_ABI64) -# define LA dla -# define EH_FRAME_ALIGN 3 -# define FDE_ADDR_BYTES .8byte -# else -# define LA la -# define EH_FRAME_ALIGN 2 -# define FDE_ADDR_BYTES .4byte -# endif /* _MIPS_SIM==_ABI64 */ -#endif /* !FFI_MIPS_O32 */ -#else /* !LIBFFI_ASM */ -# ifdef __GNUC__ -# ifdef FFI_MIPS_O32 -/* O32 stack frames have 32bit integer args */ -typedef unsigned int ffi_arg __attribute__((__mode__(__SI__))); -typedef signed int ffi_sarg __attribute__((__mode__(__SI__))); -#else -/* N32 and N64 frames have 64bit integer args */ -typedef unsigned int ffi_arg __attribute__((__mode__(__DI__))); -typedef signed int ffi_sarg __attribute__((__mode__(__DI__))); -# endif -# else -# ifdef FFI_MIPS_O32 -/* O32 stack frames have 32bit integer args */ -typedef __uint32_t ffi_arg; -typedef __int32_t ffi_sarg; -# else -/* N32 and N64 frames have 64bit integer args */ -typedef __uint64_t ffi_arg; -typedef __int64_t ffi_sarg; -# endif -# endif /* __GNUC__ */ - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_O32, - FFI_N32, - FFI_N64, - FFI_O32_SOFT_FLOAT, - FFI_N32_SOFT_FLOAT, - FFI_N64_SOFT_FLOAT, - FFI_LAST_ABI, - -#ifdef FFI_MIPS_O32 -#ifdef __mips_soft_float - FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT -#else - FFI_DEFAULT_ABI = FFI_O32 -#endif -#else -# if _MIPS_SIM==_ABI64 -# ifdef __mips_soft_float - FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT -# else - FFI_DEFAULT_ABI = FFI_N64 -# endif -# else -# ifdef __mips_soft_float - FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT -# else - FFI_DEFAULT_ABI = FFI_N32 -# endif -# endif -#endif -} ffi_abi; - -#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag -#endif /* !LIBFFI_ASM */ - -/* ---- Definitions for closures ----------------------------------------- */ - -#if defined(FFI_MIPS_O32) -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 20 -#else -/* N32/N64. */ -# define FFI_CLOSURES 1 -#if _MIPS_SIM==_ABI64 -#define FFI_TRAMPOLINE_SIZE 52 -#else -#define FFI_TRAMPOLINE_SIZE 20 -#endif -#endif /* FFI_MIPS_O32 */ -#define FFI_NATIVE_RAW_API 0 - -#endif - diff --git a/user/mpy/lib/libffi/src/mips/n32.S b/user/mpy/lib/libffi/src/mips/n32.S deleted file mode 100644 index c6985d3..0000000 --- a/user/mpy/lib/libffi/src/mips/n32.S +++ /dev/null @@ -1,576 +0,0 @@ -/* ----------------------------------------------------------------------- - n32.S - Copyright (c) 1996, 1998, 2005, 2007, 2009, 2010 Red Hat, Inc. - - MIPS Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -/* Only build this code if we are compiling for n32 */ - -#if defined(FFI_MIPS_N32) - -#define callback a0 -#define bytes a2 -#define flags a3 -#define raddr a4 -#define fn a5 - -#define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG ) - -#ifdef __GNUC__ - .abicalls -#endif - .set mips4 - .text - .align 2 - .globl ffi_call_N32 - .ent ffi_call_N32 -ffi_call_N32: -.LFB3: - .frame $fp, SIZEOF_FRAME, ra - .mask 0xc0000000,-FFI_SIZEOF_ARG - .fmask 0x00000000,0 - - # Prologue - SUBU $sp, SIZEOF_FRAME # Frame size -.LCFI0: - REG_S $fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp) # Save frame pointer - REG_S ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp) # Save return address -.LCFI1: - move $fp, $sp -.LCFI3: - move t9, callback # callback function pointer - REG_S bytes, 2*FFI_SIZEOF_ARG($fp) # bytes - REG_S flags, 3*FFI_SIZEOF_ARG($fp) # flags - REG_S raddr, 4*FFI_SIZEOF_ARG($fp) # raddr - REG_S fn, 5*FFI_SIZEOF_ARG($fp) # fn - - # Allocate at least 4 words in the argstack - move v0, bytes - bge bytes, 4 * FFI_SIZEOF_ARG, bigger - LI v0, 4 * FFI_SIZEOF_ARG - b sixteen - - bigger: - ADDU t4, v0, 2 * FFI_SIZEOF_ARG -1 # make sure it is aligned - and v0, t4, -2 * FFI_SIZEOF_ARG # to a proper boundry. - -sixteen: - SUBU $sp, $sp, v0 # move the stack pointer to reflect the - # arg space - - move a0, $sp # 4 * FFI_SIZEOF_ARG - ADDU a3, $fp, 3 * FFI_SIZEOF_ARG - - # Call ffi_prep_args - jal t9 - - # Copy the stack pointer to t9 - move t9, $sp - - # Fix the stack if there are more than 8 64bit slots worth - # of arguments. - - # Load the number of bytes - REG_L t6, 2*FFI_SIZEOF_ARG($fp) - - # Is it bigger than 8 * FFI_SIZEOF_ARG? - daddiu t8, t6, -(8 * FFI_SIZEOF_ARG) - bltz t8, loadregs - - ADDU t9, t9, t8 - -loadregs: - - REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6. - - and t4, t6, ((1< -#include - -/* Only build this code if we are compiling for o32 */ - -#if defined(FFI_MIPS_O32) - -#define callback a0 -#define bytes a2 -#define flags a3 - -#define SIZEOF_FRAME (4 * FFI_SIZEOF_ARG + 2 * FFI_SIZEOF_ARG) -#define A3_OFF (SIZEOF_FRAME + 3 * FFI_SIZEOF_ARG) -#define FP_OFF (SIZEOF_FRAME - 2 * FFI_SIZEOF_ARG) -#define RA_OFF (SIZEOF_FRAME - 1 * FFI_SIZEOF_ARG) - - .abicalls - .text - .align 2 - .globl ffi_call_O32 - .ent ffi_call_O32 -ffi_call_O32: -$LFB0: - # Prologue - SUBU $sp, SIZEOF_FRAME # Frame size -$LCFI0: - REG_S $fp, FP_OFF($sp) # Save frame pointer -$LCFI1: - REG_S ra, RA_OFF($sp) # Save return address -$LCFI2: - move $fp, $sp - -$LCFI3: - move t9, callback # callback function pointer - REG_S flags, A3_OFF($fp) # flags - - # Allocate at least 4 words in the argstack - LI v0, 4 * FFI_SIZEOF_ARG - blt bytes, v0, sixteen - - ADDU v0, bytes, 7 # make sure it is aligned - and v0, -8 # to an 8 byte boundry - -sixteen: - SUBU $sp, v0 # move the stack pointer to reflect the - # arg space - - ADDU a0, $sp, 4 * FFI_SIZEOF_ARG - - jalr t9 - - REG_L t0, A3_OFF($fp) # load the flags word - SRL t2, t0, 4 # shift our arg info - and t0, ((1<<4)-1) # mask out the return type - - ADDU $sp, 4 * FFI_SIZEOF_ARG # adjust $sp to new args - - bnez t0, pass_d # make it quick for int - REG_L a0, 0*FFI_SIZEOF_ARG($sp) # just go ahead and load the - REG_L a1, 1*FFI_SIZEOF_ARG($sp) # four regs. - REG_L a2, 2*FFI_SIZEOF_ARG($sp) - REG_L a3, 3*FFI_SIZEOF_ARG($sp) - b call_it - -pass_d: - bne t0, FFI_ARGS_D, pass_f - l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args - REG_L a2, 2*FFI_SIZEOF_ARG($sp) # passing a double - REG_L a3, 3*FFI_SIZEOF_ARG($sp) - b call_it - -pass_f: - bne t0, FFI_ARGS_F, pass_d_d - l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args - REG_L a1, 1*FFI_SIZEOF_ARG($sp) # passing a float - REG_L a2, 2*FFI_SIZEOF_ARG($sp) - REG_L a3, 3*FFI_SIZEOF_ARG($sp) - b call_it - -pass_d_d: - bne t0, FFI_ARGS_DD, pass_f_f - l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args - l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing two doubles - b call_it - -pass_f_f: - bne t0, FFI_ARGS_FF, pass_d_f - l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args - l.s $f14, 1*FFI_SIZEOF_ARG($sp) # passing two floats - REG_L a2, 2*FFI_SIZEOF_ARG($sp) - REG_L a3, 3*FFI_SIZEOF_ARG($sp) - b call_it - -pass_d_f: - bne t0, FFI_ARGS_DF, pass_f_d - l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args - l.s $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float - REG_L a3, 3*FFI_SIZEOF_ARG($sp) - b call_it - -pass_f_d: - # assume that the only other combination must be float then double - # bne t0, FFI_ARGS_F_D, call_it - l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args - l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float - -call_it: - # Load the function pointer - REG_L t9, SIZEOF_FRAME + 5*FFI_SIZEOF_ARG($fp) - - # If the return value pointer is NULL, assume no return value. - REG_L t1, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) - beqz t1, noretval - - bne t2, FFI_TYPE_INT, retlonglong - jalr t9 - REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) - REG_S v0, 0(t0) - b epilogue - -retlonglong: - # Really any 64-bit int, signed or not. - bne t2, FFI_TYPE_UINT64, retfloat - jalr t9 - REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) - REG_S v1, 4(t0) - REG_S v0, 0(t0) - b epilogue - -retfloat: - bne t2, FFI_TYPE_FLOAT, retdouble - jalr t9 - REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) - s.s $f0, 0(t0) - b epilogue - -retdouble: - bne t2, FFI_TYPE_DOUBLE, noretval - jalr t9 - REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp) - s.d $f0, 0(t0) - b epilogue - -noretval: - jalr t9 - - # Epilogue -epilogue: - move $sp, $fp - REG_L $fp, FP_OFF($sp) # Restore frame pointer - REG_L ra, RA_OFF($sp) # Restore return address - ADDU $sp, SIZEOF_FRAME # Fix stack pointer - j ra - -$LFE0: - .end ffi_call_O32 - - -/* ffi_closure_O32. Expects address of the passed-in ffi_closure - in t4 ($12). Stores any arguments passed in registers onto the - stack, then calls ffi_closure_mips_inner_O32, which - then decodes them. - - Stack layout: - - 3 - a3 save - 2 - a2 save - 1 - a1 save - 0 - a0 save, original sp - -1 - ra save - -2 - fp save - -3 - $16 (s0) save - -4 - cprestore - -5 - return value high (v1) - -6 - return value low (v0) - -7 - f14 (le high, be low) - -8 - f14 (le low, be high) - -9 - f12 (le high, be low) - -10 - f12 (le low, be high) - -11 - Called function a3 save - -12 - Called function a2 save - -13 - Called function a1 save - -14 - Called function a0 save, our sp and fp point here - */ - -#define SIZEOF_FRAME2 (14 * FFI_SIZEOF_ARG) -#define A3_OFF2 (SIZEOF_FRAME2 + 3 * FFI_SIZEOF_ARG) -#define A2_OFF2 (SIZEOF_FRAME2 + 2 * FFI_SIZEOF_ARG) -#define A1_OFF2 (SIZEOF_FRAME2 + 1 * FFI_SIZEOF_ARG) -#define A0_OFF2 (SIZEOF_FRAME2 + 0 * FFI_SIZEOF_ARG) -#define RA_OFF2 (SIZEOF_FRAME2 - 1 * FFI_SIZEOF_ARG) -#define FP_OFF2 (SIZEOF_FRAME2 - 2 * FFI_SIZEOF_ARG) -#define S0_OFF2 (SIZEOF_FRAME2 - 3 * FFI_SIZEOF_ARG) -#define GP_OFF2 (SIZEOF_FRAME2 - 4 * FFI_SIZEOF_ARG) -#define V1_OFF2 (SIZEOF_FRAME2 - 5 * FFI_SIZEOF_ARG) -#define V0_OFF2 (SIZEOF_FRAME2 - 6 * FFI_SIZEOF_ARG) -#define FA_1_1_OFF2 (SIZEOF_FRAME2 - 7 * FFI_SIZEOF_ARG) -#define FA_1_0_OFF2 (SIZEOF_FRAME2 - 8 * FFI_SIZEOF_ARG) -#define FA_0_1_OFF2 (SIZEOF_FRAME2 - 9 * FFI_SIZEOF_ARG) -#define FA_0_0_OFF2 (SIZEOF_FRAME2 - 10 * FFI_SIZEOF_ARG) - - .text - .align 2 - .globl ffi_closure_O32 - .ent ffi_closure_O32 -ffi_closure_O32: -$LFB1: - # Prologue - .frame $fp, SIZEOF_FRAME2, ra - .set noreorder - .cpload t9 - .set reorder - SUBU $sp, SIZEOF_FRAME2 - .cprestore GP_OFF2 -$LCFI4: - REG_S $16, S0_OFF2($sp) # Save s0 - REG_S $fp, FP_OFF2($sp) # Save frame pointer - REG_S ra, RA_OFF2($sp) # Save return address -$LCFI6: - move $fp, $sp - -$LCFI7: - # Store all possible argument registers. If there are more than - # four arguments, then they are stored above where we put a3. - REG_S a0, A0_OFF2($fp) - REG_S a1, A1_OFF2($fp) - REG_S a2, A2_OFF2($fp) - REG_S a3, A3_OFF2($fp) - - # Load ABI enum to s0 - REG_L $16, 20($12) # cif pointer follows tramp. - REG_L $16, 0($16) # abi is first member. - - li $13, 1 # FFI_O32 - bne $16, $13, 1f # Skip fp save if FFI_O32_SOFT_FLOAT - - # Store all possible float/double registers. - s.d $f12, FA_0_0_OFF2($fp) - s.d $f14, FA_1_0_OFF2($fp) -1: - # Call ffi_closure_mips_inner_O32 to do the work. - la t9, ffi_closure_mips_inner_O32 - move a0, $12 # Pointer to the ffi_closure - addu a1, $fp, V0_OFF2 - addu a2, $fp, A0_OFF2 - addu a3, $fp, FA_0_0_OFF2 - jalr t9 - - # Load the return value into the appropriate register. - move $8, $2 - li $9, FFI_TYPE_VOID - beq $8, $9, closure_done - - li $13, 1 # FFI_O32 - bne $16, $13, 1f # Skip fp restore if FFI_O32_SOFT_FLOAT - - li $9, FFI_TYPE_FLOAT - l.s $f0, V0_OFF2($fp) - beq $8, $9, closure_done - - li $9, FFI_TYPE_DOUBLE - l.d $f0, V0_OFF2($fp) - beq $8, $9, closure_done -1: - REG_L $3, V1_OFF2($fp) - REG_L $2, V0_OFF2($fp) - -closure_done: - # Epilogue - move $sp, $fp - REG_L $16, S0_OFF2($sp) # Restore s0 - REG_L $fp, FP_OFF2($sp) # Restore frame pointer - REG_L ra, RA_OFF2($sp) # Restore return address - ADDU $sp, SIZEOF_FRAME2 - j ra -$LFE1: - .end ffi_closure_O32 - -/* DWARF-2 unwind info. */ - - .section .eh_frame,"a",@progbits -$Lframe0: - .4byte $LECIE0-$LSCIE0 # Length of Common Information Entry -$LSCIE0: - .4byte 0x0 # CIE Identifier Tag - .byte 0x1 # CIE Version - .ascii "zR\0" # CIE Augmentation - .uleb128 0x1 # CIE Code Alignment Factor - .sleb128 4 # CIE Data Alignment Factor - .byte 0x1f # CIE RA Column - .uleb128 0x1 # Augmentation size - .byte 0x00 # FDE Encoding (absptr) - .byte 0xc # DW_CFA_def_cfa - .uleb128 0x1d - .uleb128 0x0 - .align 2 -$LECIE0: -$LSFDE0: - .4byte $LEFDE0-$LASFDE0 # FDE Length -$LASFDE0: - .4byte $LASFDE0-$Lframe0 # FDE CIE offset - .4byte $LFB0 # FDE initial location - .4byte $LFE0-$LFB0 # FDE address range - .uleb128 0x0 # Augmentation size - .byte 0x4 # DW_CFA_advance_loc4 - .4byte $LCFI0-$LFB0 - .byte 0xe # DW_CFA_def_cfa_offset - .uleb128 0x18 - .byte 0x4 # DW_CFA_advance_loc4 - .4byte $LCFI2-$LCFI0 - .byte 0x11 # DW_CFA_offset_extended_sf - .uleb128 0x1e # $fp - .sleb128 -2 # SIZEOF_FRAME2 - 2*FFI_SIZEOF_ARG($sp) - .byte 0x11 # DW_CFA_offset_extended_sf - .uleb128 0x1f # $ra - .sleb128 -1 # SIZEOF_FRAME2 - 1*FFI_SIZEOF_ARG($sp) - .byte 0x4 # DW_CFA_advance_loc4 - .4byte $LCFI3-$LCFI2 - .byte 0xc # DW_CFA_def_cfa - .uleb128 0x1e - .uleb128 0x18 - .align 2 -$LEFDE0: -$LSFDE1: - .4byte $LEFDE1-$LASFDE1 # FDE Length -$LASFDE1: - .4byte $LASFDE1-$Lframe0 # FDE CIE offset - .4byte $LFB1 # FDE initial location - .4byte $LFE1-$LFB1 # FDE address range - .uleb128 0x0 # Augmentation size - .byte 0x4 # DW_CFA_advance_loc4 - .4byte $LCFI4-$LFB1 - .byte 0xe # DW_CFA_def_cfa_offset - .uleb128 0x38 - .byte 0x4 # DW_CFA_advance_loc4 - .4byte $LCFI6-$LCFI4 - .byte 0x11 # DW_CFA_offset_extended_sf - .uleb128 0x10 # $16 - .sleb128 -3 # SIZEOF_FRAME2 - 3*FFI_SIZEOF_ARG($sp) - .byte 0x11 # DW_CFA_offset_extended_sf - .uleb128 0x1e # $fp - .sleb128 -2 # SIZEOF_FRAME2 - 2*FFI_SIZEOF_ARG($sp) - .byte 0x11 # DW_CFA_offset_extended_sf - .uleb128 0x1f # $ra - .sleb128 -1 # SIZEOF_FRAME2 - 1*FFI_SIZEOF_ARG($sp) - .byte 0x4 # DW_CFA_advance_loc4 - .4byte $LCFI7-$LCFI6 - .byte 0xc # DW_CFA_def_cfa - .uleb128 0x1e - .uleb128 0x38 - .align 2 -$LEFDE1: - -#endif diff --git a/user/mpy/lib/libffi/src/moxie/eabi.S b/user/mpy/lib/libffi/src/moxie/eabi.S deleted file mode 100644 index ac7aceb..0000000 --- a/user/mpy/lib/libffi/src/moxie/eabi.S +++ /dev/null @@ -1,101 +0,0 @@ -/* ----------------------------------------------------------------------- - eabi.S - Copyright (c) 2012, 2013 Anthony Green - - Moxie Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - .globl ffi_prep_args_EABI - - .text - .p2align 4 - .globl ffi_call_EABI - .type ffi_call_EABI, @function - - # $r0 : ffi_prep_args - # $r1 : &ecif - # $r2 : cif->bytes - # $r3 : fig->flags - # $r4 : ecif.rvalue - # $r5 : fn - -ffi_call_EABI: - push $sp, $r6 - push $sp, $r7 - push $sp, $r8 - dec $sp, 24 - - /* Store incoming args on stack. */ - sto.l 0($sp), $r0 /* ffi_prep_args */ - sto.l 4($sp), $r1 /* ecif */ - sto.l 8($sp), $r2 /* bytes */ - sto.l 12($sp), $r3 /* flags */ - sto.l 16($sp), $r4 /* &rvalue */ - sto.l 20($sp), $r5 /* fn */ - - /* Call ffi_prep_args. */ - mov $r6, $r4 /* Save result buffer */ - mov $r7, $r5 /* Save the target fn */ - mov $r8, $r3 /* Save the flags */ - sub.l $sp, $r2 /* Allocate stack space */ - mov $r0, $sp /* We can stomp over $r0 */ - /* $r1 is already set up */ - jsra ffi_prep_args - - /* Load register arguments. */ - ldo.l $r0, 0($sp) - ldo.l $r1, 4($sp) - ldo.l $r2, 8($sp) - ldo.l $r3, 12($sp) - ldo.l $r4, 16($sp) - ldo.l $r5, 20($sp) - - /* Call the target function. */ - jsr $r7 - - ldi.l $r7, 0xffffffff - cmp $r8, $r7 - beq retstruct - - ldi.l $r7, 4 - cmp $r8, $r7 - bgt ret2reg - - st.l ($r6), $r0 - jmpa retdone - -ret2reg: - st.l ($r6), $r0 - sto.l 4($r6), $r1 - -retstruct: -retdone: - /* Return. */ - ldo.l $r6, -4($fp) - ldo.l $r7, -8($fp) - ldo.l $r8, -12($fp) - ret - .size ffi_call_EABI, .-ffi_call_EABI - diff --git a/user/mpy/lib/libffi/src/moxie/ffi.c b/user/mpy/lib/libffi/src/moxie/ffi.c deleted file mode 100644 index 540a042..0000000 --- a/user/mpy/lib/libffi/src/moxie/ffi.c +++ /dev/null @@ -1,272 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2012, 2013 Anthony Green - - Moxie Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void *ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - register int count = 0; - - p_argv = ecif->avalue; - argp = stack; - - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) - { - *(void **) argp = ecif->rvalue; - argp += 4; - } - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); - i--, p_arg++) - { - size_t z; - - z = (*p_arg)->size; - - if ((*p_arg)->type == FFI_TYPE_STRUCT) - { - z = sizeof(void*); - *(void **) argp = *p_argv; - } - else if (z < sizeof(int)) - { - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - default: - FFI_ASSERT(0); - } - } - else if (z == sizeof(int)) - { - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - } - else - { - memcpy(argp, *p_argv, z); - } - p_argv++; - argp += z; - count += z; - } - - return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8))); -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - if (cif->rtype->type == FFI_TYPE_STRUCT) - cif->flags = -1; - else - cif->flags = cif->rtype->size; - - cif->bytes = ALIGN (cif->bytes, 8); - - return FFI_OK; -} - -extern void ffi_call_EABI(void *(*)(char *, extended_cif *), - extended_cif *, - unsigned, unsigned, - unsigned *, - void (*fn)(void)); - -void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_EABI: - ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - -void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, - unsigned arg4, unsigned arg5, unsigned arg6) -{ - /* This function is called by a trampoline. The trampoline stows a - pointer to the ffi_closure object in $r7. We must save this - pointer in a place that will persist while we do our work. */ - register ffi_closure *creg __asm__ ("$r12"); - ffi_closure *closure = creg; - - /* Arguments that don't fit in registers are found on the stack - at a fixed offset above the current frame pointer. */ - register char *frame_pointer __asm__ ("$fp"); - - /* Pointer to a struct return value. */ - void *struct_rvalue = (void *) arg1; - - /* 6 words reserved for register args + 3 words from jsr */ - char *stack_args = frame_pointer + 9*4; - - /* Lay the register arguments down in a continuous chunk of memory. */ - unsigned register_args[6] = - { arg1, arg2, arg3, arg4, arg5, arg6 }; - char *register_args_ptr = (char *) register_args; - - ffi_cif *cif = closure->cif; - ffi_type **arg_types = cif->arg_types; - void **avalue = alloca (cif->nargs * sizeof(void *)); - char *ptr = (char *) register_args; - int i; - - /* preserve struct type return pointer passing */ - if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { - ptr += 4; - register_args_ptr = (char *)®ister_args[1]; - } - - /* Find the address of each argument. */ - for (i = 0; i < cif->nargs; i++) - { - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - avalue[i] = ptr + 3; - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - avalue[i] = ptr + 2; - break; - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: - avalue[i] = ptr; - break; - case FFI_TYPE_STRUCT: - avalue[i] = *(void**)ptr; - break; - default: - /* This is an 8-byte value. */ - avalue[i] = ptr; - ptr += 4; - break; - } - ptr += 4; - - /* If we've handled more arguments than fit in registers, - start looking at the those passed on the stack. */ - if (ptr == ®ister_args[6]) - ptr = stack_args; - } - - /* Invoke the closure. */ - if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT)) - { - (closure->fun) (cif, struct_rvalue, avalue, closure->user_data); - } - else - { - /* Allocate space for the return value and call the function. */ - long long rvalue; - (closure->fun) (cif, &rvalue, avalue, closure->user_data); - asm ("mov $r12, %0\n ld.l $r0, ($r12)\n ldo.l $r1, 4($r12)" : : "r" (&rvalue)); - } -} - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned short *tramp = (unsigned short *) &closure->tramp[0]; - unsigned long fn = (long) ffi_closure_eabi; - unsigned long cls = (long) codeloc; - - if (cif->abi != FFI_EABI) - return FFI_BAD_ABI; - - fn = (unsigned long) ffi_closure_eabi; - - tramp[0] = 0x01e0; /* ldi.l $r7, .... */ - tramp[1] = cls >> 16; - tramp[2] = cls & 0xffff; - tramp[3] = 0x1a00; /* jmpa .... */ - tramp[4] = fn >> 16; - tramp[5] = fn & 0xffff; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/moxie/ffitarget.h b/user/mpy/lib/libffi/src/moxie/ffitarget.h deleted file mode 100644 index 623e3ec..0000000 --- a/user/mpy/lib/libffi/src/moxie/ffitarget.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012, 2013 Anthony Green - Target configuration macros for Moxie - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -/* ---- System specific configurations ----------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_EABI, - FFI_DEFAULT_ABI = FFI_EABI, - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -/* Trampolines are 12-bytes long. See ffi_prep_closure_loc. */ -#define FFI_TRAMPOLINE_SIZE (12) - -#endif diff --git a/user/mpy/lib/libffi/src/nios2/ffi.c b/user/mpy/lib/libffi/src/nios2/ffi.c deleted file mode 100644 index 2efa033..0000000 --- a/user/mpy/lib/libffi/src/nios2/ffi.c +++ /dev/null @@ -1,304 +0,0 @@ -/* libffi support for Altera Nios II. - - Copyright (c) 2013 Mentor Graphics. - - 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. */ - - -#include -#include - -#include - -/* The Nios II Processor Reference Handbook defines the procedure call - ABI as follows. - - Arguments are passed as if a structure containing the types of - the arguments were constructed. The first 16 bytes are passed in r4 - through r7, the remainder on the stack. The first 16 bytes of a function - taking variable arguments are passed in r4-r7 in the same way. - - Return values of types up to 8 bytes are returned in r2 and r3. For - return values greater than 8 bytes, the caller must allocate memory for - the result and pass the address as if it were argument 0. - - While this isn't specified explicitly in the ABI documentation, GCC - promotes integral arguments smaller than int size to 32 bits. - - Also of note, the ABI specifies that all structure objects are - aligned to 32 bits even if all their fields have a smaller natural - alignment. See FFI_AGGREGATE_ALIGNMENT. */ - - -/* Declare the assembly language hooks. */ - -extern UINT64 ffi_call_sysv (void (*) (char *, extended_cif *), - extended_cif *, - unsigned, - void (*fn) (void)); -extern void ffi_closure_sysv (void); - -/* Perform machine-dependent cif processing. */ - -ffi_status ffi_prep_cif_machdep (ffi_cif *cif) -{ - /* We always want at least 16 bytes in the parameter block since it - simplifies the low-level call function. Also round the parameter - block size up to a multiple of 4 bytes to preserve - 32-bit alignment of the stack pointer. */ - if (cif->bytes < 16) - cif->bytes = 16; - else - cif->bytes = (cif->bytes + 3) & ~3; - - return FFI_OK; -} - - -/* ffi_prep_args is called by the assembly routine to transfer arguments - to the stack using the pointers in the ecif array. - Note that the stack buffer is big enough to fit all the arguments, - but the first 16 bytes will be copied to registers for the actual - call. */ - -void ffi_prep_args (char *stack, extended_cif *ecif) -{ - char *argp = stack; - unsigned int i; - - /* The implicit return value pointer is passed as if it were a hidden - first argument. */ - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT - && ecif->cif->rtype->size > 8) - { - (*(void **) argp) = ecif->rvalue; - argp += 4; - } - - for (i = 0; i < ecif->cif->nargs; i++) - { - void *avalue = ecif->avalue[i]; - ffi_type *atype = ecif->cif->arg_types[i]; - size_t size = atype->size; - size_t alignment = atype->alignment; - - /* Align argp as appropriate for the argument type. */ - if ((alignment - 1) & (unsigned) argp) - argp = (char *) ALIGN (argp, alignment); - - /* Copy the argument, promoting integral types smaller than a - word to word size. */ - if (size < sizeof (int)) - { - size = sizeof (int); - switch (atype->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int) *(SINT8 *) avalue; - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int) *(UINT8 *) avalue; - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) *(SINT16 *) avalue; - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) *(UINT16 *) avalue; - break; - - case FFI_TYPE_STRUCT: - memcpy (argp, avalue, atype->size); - break; - - default: - FFI_ASSERT(0); - } - } - else if (size == sizeof (int)) - *(unsigned int *) argp = (unsigned int) *(UINT32 *) avalue; - else - memcpy (argp, avalue, size); - argp += size; - } -} - - -/* Call FN using the prepared CIF. RVALUE points to space allocated by - the caller for the return value, and AVALUE is an array of argument - pointers. */ - -void ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) -{ - - extended_cif ecif; - UINT64 result; - - /* If bigret is true, this is the case where a return value of larger - than 8 bytes is handled by being passed by reference as an implicit - argument. */ - int bigret = (cif->rtype->type == FFI_TYPE_STRUCT - && cif->rtype->size > 8); - - ecif.cif = cif; - ecif.avalue = avalue; - - /* Allocate space for return value if this is the pass-by-reference case - and the caller did not provide a buffer. */ - if (rvalue == NULL && bigret) - ecif.rvalue = alloca (cif->rtype->size); - else - ecif.rvalue = rvalue; - - result = ffi_call_sysv (ffi_prep_args, &ecif, cif->bytes, fn); - - /* Now result contains the 64 bit contents returned from fn in - r2 and r3. Copy the value of the appropriate size to the user-provided - rvalue buffer. */ - if (rvalue && !bigret) - switch (cif->rtype->size) - { - case 1: - *(UINT8 *)rvalue = (UINT8) result; - break; - case 2: - *(UINT16 *)rvalue = (UINT16) result; - break; - case 4: - *(UINT32 *)rvalue = (UINT32) result; - break; - case 8: - *(UINT64 *)rvalue = (UINT64) result; - break; - default: - memcpy (rvalue, (void *)&result, cif->rtype->size); - break; - } -} - -/* This function is invoked from the closure trampoline to invoke - CLOSURE with argument block ARGS. Parse ARGS according to - CLOSURE->cfi and invoke CLOSURE->fun. */ - -static UINT64 -ffi_closure_helper (unsigned char *args, - ffi_closure *closure) -{ - ffi_cif *cif = closure->cif; - unsigned char *argp = args; - void **parsed_args = alloca (cif->nargs * sizeof (void *)); - UINT64 result; - void *retptr; - unsigned int i; - - /* First figure out what to do about the return type. If this is the - big-structure-return case, the first arg is the hidden return buffer - allocated by the caller. */ - if (cif->rtype->type == FFI_TYPE_STRUCT - && cif->rtype->size > 8) - { - retptr = *((void **) argp); - argp += 4; - } - else - retptr = (void *) &result; - - /* Fill in the array of argument pointers. */ - for (i = 0; i < cif->nargs; i++) - { - size_t size = cif->arg_types[i]->size; - size_t alignment = cif->arg_types[i]->alignment; - - /* Align argp as appropriate for the argument type. */ - if ((alignment - 1) & (unsigned) argp) - argp = (char *) ALIGN (argp, alignment); - - /* Arguments smaller than an int are promoted to int. */ - if (size < sizeof (int)) - size = sizeof (int); - - /* Store the pointer. */ - parsed_args[i] = argp; - argp += size; - } - - /* Call the user-supplied function. */ - (closure->fun) (cif, retptr, parsed_args, closure->user_data); - return result; -} - - -/* Initialize CLOSURE with a trampoline to call FUN with - CIF and USER_DATA. */ -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun) (ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp = (unsigned int *) &closure->tramp[0]; - int i; - - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - /* The trampoline looks like: - movhi r8, %hi(ffi_closure_sysv) - ori r8, r8, %lo(ffi_closure_sysv) - movhi r9, %hi(ffi_closure_helper) - ori r0, r9, %lo(ffi_closure_helper) - movhi r10, %hi(closure) - ori r10, r10, %lo(closure) - jmp r8 - and then ffi_closure_sysv retrieves the closure pointer out of r10 - in addition to the arguments passed in the normal way for the call, - and invokes ffi_closure_helper. We encode the pointer to - ffi_closure_helper in the trampoline because making a PIC call - to it in ffi_closure_sysv would be messy (it would have to indirect - through the GOT). */ - -#define HI(x) ((((unsigned int) (x)) >> 16) & 0xffff) -#define LO(x) (((unsigned int) (x)) & 0xffff) - tramp[0] = (0 << 27) | (8 << 22) | (HI (ffi_closure_sysv) << 6) | 0x34; - tramp[1] = (8 << 27) | (8 << 22) | (LO (ffi_closure_sysv) << 6) | 0x14; - tramp[2] = (0 << 27) | (9 << 22) | (HI (ffi_closure_helper) << 6) | 0x34; - tramp[3] = (9 << 27) | (9 << 22) | (LO (ffi_closure_helper) << 6) | 0x14; - tramp[4] = (0 << 27) | (10 << 22) | (HI (closure) << 6) | 0x34; - tramp[5] = (10 << 27) | (10 << 22) | (LO (closure) << 6) | 0x14; - tramp[6] = (8 << 27) | (0x0d << 11) | 0x3a; -#undef HI -#undef LO - - /* Flush the caches. - See Example 9-4 in the Nios II Software Developer's Handbook. */ - for (i = 0; i < 7; i++) - asm volatile ("flushd 0(%0); flushi %0" :: "r"(tramp + i) : "memory"); - asm volatile ("flushp" ::: "memory"); - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - diff --git a/user/mpy/lib/libffi/src/nios2/ffitarget.h b/user/mpy/lib/libffi/src/nios2/ffitarget.h deleted file mode 100644 index 134d118..0000000 --- a/user/mpy/lib/libffi/src/nios2/ffitarget.h +++ /dev/null @@ -1,52 +0,0 @@ -/* libffi target includes for Altera Nios II. - - Copyright (c) 2013 Mentor Graphics. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -/* Structures have a 4-byte alignment even if all the fields have lesser - alignment requirements. */ -#define FFI_AGGREGATE_ALIGNMENT 4 - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 28 /* 7 instructions */ -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/nios2/sysv.S b/user/mpy/lib/libffi/src/nios2/sysv.S deleted file mode 100644 index 75f442b..0000000 --- a/user/mpy/lib/libffi/src/nios2/sysv.S +++ /dev/null @@ -1,136 +0,0 @@ -/* Low-level libffi support for Altera Nios II. - - Copyright (c) 2013 Mentor Graphics. - - 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. */ - -/* This function is declared on the C side as - - extern UINT64 ffi_call_sysv (void (*arghook) (char *, extended_cif *), - extended_cif *ecif, - unsigned nbytes, - void (*fn) (void)); - - On input, the arguments appear as - r4 = arghook - r5 = ecif - r6 = nbytes - r7 = fn -*/ - - .section .text - .align 2 - .global ffi_call_sysv - .type ffi_call_sysv, @function - -ffi_call_sysv: - .cfi_startproc - - /* Create the stack frame, saving r16 so we can use it locally. */ - addi sp, sp, -12 - .cfi_def_cfa_offset 12 - stw ra, 8(sp) - stw fp, 4(sp) - stw r16, 0(sp) - .cfi_offset 31, -4 - .cfi_offset 28, -8 - .cfi_offset 16, -12 - mov fp, sp - .cfi_def_cfa_register 28 - mov r16, r7 - - /* Adjust the stack pointer to create the argument buffer - nbytes long. */ - sub sp, sp, r6 - - /* Call the arghook function. */ - mov r2, r4 /* fn */ - mov r4, sp /* argbuffer */ - callr r2 /* r5 already contains ecif */ - - /* Pop off the first 16 bytes of the argument buffer on the stack, - transferring the contents to the argument registers. */ - ldw r4, 0(sp) - ldw r5, 4(sp) - ldw r6, 8(sp) - ldw r7, 12(sp) - addi sp, sp, 16 - - /* Call the user function, which leaves its result in r2 and r3. */ - callr r16 - - /* Pop off the stack frame. */ - mov sp, fp - ldw ra, 8(sp) - ldw fp, 4(sp) - ldw r16, 0(sp) - addi sp, sp, 12 - ret - .cfi_endproc - .size ffi_call_sysv, .-ffi_call_sysv - - -/* Closure trampolines jump here after putting the C helper address - in r9 and the closure pointer in r10. The user-supplied arguments - to the closure are in the normal places, in r4-r7 and on the - stack. Push the register arguments on the stack too and then call the - C helper function to deal with them. */ - - .section .text - .align 2 - .global ffi_closure_sysv - .type ffi_closure_sysv, @function - -ffi_closure_sysv: - .cfi_startproc - - /* Create the stack frame, pushing the register args on the stack - just below the stack args. This is the same trick illustrated - in Figure 7-3 in the Nios II Processor Reference Handbook, used - for variable arguments and structures passed by value. */ - addi sp, sp, -20 - .cfi_def_cfa_offset 20 - stw ra, 0(sp) - .cfi_offset 31, -20 - stw r4, 4(sp) - .cfi_offset 4, -16 - stw r5, 8(sp) - .cfi_offset 5, -12 - stw r6, 12(sp) - .cfi_offset 6, -8 - stw r7, 16(sp) - .cfi_offset 7, -4 - - /* Call the helper. - r4 = pointer to arguments on stack - r5 = closure pointer (loaded in r10 by the trampoline) - r9 = address of helper function (loaded by trampoline) */ - addi r4, sp, 4 - mov r5, r10 - callr r9 - - /* Pop the stack and return. */ - ldw ra, 0(sp) - addi sp, sp, 20 - .cfi_def_cfa_offset -20 - ret - .cfi_endproc - .size ffi_closure_sysv, .-ffi_closure_sysv - diff --git a/user/mpy/lib/libffi/src/or1k/ffi.c b/user/mpy/lib/libffi/src/or1k/ffi.c deleted file mode 100644 index 2bad938..0000000 --- a/user/mpy/lib/libffi/src/or1k/ffi.c +++ /dev/null @@ -1,328 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2014 Sebastian Macke - - OpenRISC Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include "ffi_common.h" - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void* ffi_prep_args(char *stack, extended_cif *ecif) -{ - char *stacktemp = stack; - int i, s; - ffi_type **arg; - int count = 0; - int nfixedargs; - - nfixedargs = ecif->cif->nfixedargs; - arg = ecif->cif->arg_types; - void **argv = ecif->avalue; - - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) - { - *(void **) stack = ecif->rvalue; - stack += 4; - count = 4; - } - for(i=0; icif->nargs; i++) - { - - /* variadic args are saved on stack */ - if ((nfixedargs == 0) && (count < 24)) - { - count = 24; - stack = stacktemp + 24; - } - nfixedargs--; - - s = 4; - switch((*arg)->type) - { - case FFI_TYPE_STRUCT: - *(void **)stack = *argv; - break; - - case FFI_TYPE_SINT8: - *(signed int *) stack = (signed int)*(SINT8 *)(* argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) stack = (unsigned int)*(UINT8 *)(* argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) stack = (signed int)*(SINT16 *)(* argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) stack = (unsigned int)*(UINT16 *)(* argv); - break; - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: - *(int *)stack = *(int*)(*argv); - break; - - default: /* 8 byte types */ - if (count == 20) /* never split arguments */ - { - stack += 4; - count += 4; - } - s = (*arg)->size; - memcpy(stack, *argv, s); - break; - } - - stack += s; - count += s; - argv++; - arg++; - } - return stacktemp + ((count>24)?24:0); -} - -extern void ffi_call_SYSV(unsigned, - extended_cif *, - void *(*)(int *, extended_cif *), - unsigned *, - void (*fn)(void), - unsigned); - - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - int i; - int size; - ffi_type **arg; - - /* Calculate size to allocate on stack */ - - for(i = 0, arg = cif->arg_types, size=0; i < cif->nargs; i++, arg++) - { - if ((*arg)->type == FFI_TYPE_STRUCT) - size += 4; - else - if ((*arg)->size <= 4) - size += 4; - else - size += 8; - } - - /* for variadic functions more space is needed on the stack */ - if (cif->nargs != cif->nfixedargs) - size += 24; - - if (cif->rtype->type == FFI_TYPE_STRUCT) - size += 4; - - - extended_cif ecif; - ecif.cif = cif; - ecif.avalue = avalue; - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(size, &ecif, ffi_prep_args, rvalue, fn, cif->flags); - break; - default: - FFI_ASSERT(0); - break; - } -} - - -void ffi_closure_SYSV(unsigned long r3, unsigned long r4, unsigned long r5, - unsigned long r6, unsigned long r7, unsigned long r8) -{ - register int *sp __asm__ ("r17"); - register int *r13 __asm__ ("r13"); - - ffi_closure* closure = (ffi_closure*) r13; - char *stack_args = sp; - - /* Lay the register arguments down in a continuous chunk of memory. */ - unsigned register_args[6] = - { r3, r4, r5, r6, r7, r8 }; - - /* Pointer to a struct return value. */ - void *struct_rvalue = (void *) r3; - - ffi_cif *cif = closure->cif; - ffi_type **arg_types = cif->arg_types; - void **avalue = alloca (cif->nargs * sizeof(void *)); - char *ptr = (char *) register_args; - int count = 0; - int nfixedargs = cif->nfixedargs; - int i; - - /* preserve struct type return pointer passing */ - - if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ptr += 4; - count = 4; - } - - /* Find the address of each argument. */ - for (i = 0; i < cif->nargs; i++) - { - - /* variadic args are saved on stack */ - if ((nfixedargs == 0) && (count < 24)) - { - ptr = stack_args; - count = 24; - } - nfixedargs--; - - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - avalue[i] = ptr + 3; - break; - - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - avalue[i] = ptr + 2; - break; - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: - avalue[i] = ptr; - break; - - case FFI_TYPE_STRUCT: - avalue[i] = *(void**)ptr; - break; - - default: - /* 8-byte values */ - - /* arguments are never splitted */ - if (ptr == ®ister_args[5]) - ptr = stack_args; - avalue[i] = ptr; - ptr += 4; - count += 4; - break; - } - ptr += 4; - count += 4; - - /* If we've handled more arguments than fit in registers, - start looking at the those passed on the stack. */ - - if (count == 24) - ptr = stack_args; - } - - if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT)) - { - (closure->fun) (cif, struct_rvalue, avalue, closure->user_data); - } else - { - long long rvalue; - (closure->fun) (cif, &rvalue, avalue, closure->user_data); - if (cif->rtype) - asm ("l.ori r12, %0, 0x0\n l.lwz r11, 0(r12)\n l.lwz r12, 4(r12)" : : "r" (&rvalue)); - } -} - - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - unsigned short *tramp = (unsigned short *) closure->tramp; - unsigned long fn = (unsigned long) ffi_closure_SYSV; - unsigned long cls = (unsigned long) codeloc; - - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - /* write pointers to temporary registers */ - tramp[0] = (0x6 << 10) | (13 << 5); /* l.movhi r13, ... */ - tramp[1] = cls >> 16; - tramp[2] = (0x2a << 10) | (13 << 5) | 13; /* l.ori r13, r13, ... */ - tramp[3] = cls & 0xFFFF; - - tramp[4] = (0x6 << 10) | (15 << 5); /* l.movhi r15, ... */ - tramp[5] = fn >> 16; - tramp[6] = (0x2a << 10) | (15 << 5) | 15; /* l.ori r15, r15 ... */ - tramp[7] = fn & 0xFFFF; - - tramp[8] = (0x11 << 10); /* l.jr r15 */ - tramp[9] = 15 << 11; - - tramp[10] = (0x2a << 10) | (17 << 5) | 1; /* l.ori r17, r1, ... */ - tramp[11] = 0x0; - - return FFI_OK; -} - - -ffi_status ffi_prep_cif_machdep (ffi_cif *cif) -{ - cif->flags = 0; - - /* structures are returned as pointers */ - if (cif->rtype->type == FFI_TYPE_STRUCT) - cif->flags = FFI_TYPE_STRUCT; - else - if (cif->rtype->size > 4) - cif->flags = FFI_TYPE_UINT64; - - cif->nfixedargs = cif->nargs; - - return FFI_OK; -} - - -ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, - unsigned int nfixedargs, unsigned int ntotalargs) -{ - ffi_status status; - - status = ffi_prep_cif_machdep (cif); - cif->nfixedargs = nfixedargs; - return status; -} diff --git a/user/mpy/lib/libffi/src/or1k/ffitarget.h b/user/mpy/lib/libffi/src/or1k/ffitarget.h deleted file mode 100644 index e55da28..0000000 --- a/user/mpy/lib/libffi/src/or1k/ffitarget.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ----------------------------------------------------------------------- - ffitarget.h - Copyright (c) 2014 Sebastian Macke - - OpenRISC Target configuration macros - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 -#define FFI_TRAMPOLINE_SIZE (24) - -#define FFI_TARGET_SPECIFIC_VARIADIC 1 -#define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs; - -#endif - diff --git a/user/mpy/lib/libffi/src/or1k/sysv.S b/user/mpy/lib/libffi/src/or1k/sysv.S deleted file mode 100644 index df6570b..0000000 --- a/user/mpy/lib/libffi/src/or1k/sysv.S +++ /dev/null @@ -1,107 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2014 Sebastian Macke - - OpenRISC Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -.text - .globl ffi_call_SYSV - .type ffi_call_SYSV, @function -/* - r3: size to allocate on stack - r4: extended cif structure - r5: function pointer ffi_prep_args - r6: ret address - r7: function to call - r8: flag for return type -*/ - -ffi_call_SYSV: - /* Store registers used on stack */ - l.sw -4(r1), r9 /* return address */ - l.sw -8(r1), r1 /* stack address */ - l.sw -12(r1), r14 /* callee saved registers */ - l.sw -16(r1), r16 - l.sw -20(r1), r18 - l.sw -24(r1), r20 - - l.ori r14, r1, 0x0 /* save stack pointer */ - l.addi r1, r1, -24 - - l.ori r16, r7, 0x0 /* save function address */ - l.ori r18, r6, 0x0 /* save ret address */ - l.ori r20, r8, 0x0 /* save flag */ - - l.sub r1, r1, r3 /* reserve space on stack */ - - /* Call ffi_prep_args */ - l.ori r3, r1, 0x0 /* first argument stack address, second already ecif */ - l.jalr r5 - l.nop - - /* Load register arguments and call*/ - - l.lwz r3, 0(r1) - l.lwz r4, 4(r1) - l.lwz r5, 8(r1) - l.lwz r6, 12(r1) - l.lwz r7, 16(r1) - l.lwz r8, 20(r1) - l.ori r1, r11, 0x0 /* new stack pointer */ - l.jalr r16 - l.nop - - /* handle return values */ - - l.sfeqi r20, FFI_TYPE_STRUCT - l.bf ret /* structs don't return an rvalue */ - l.nop - - /* copy ret address */ - - l.sfeqi r20, FFI_TYPE_UINT64 - l.bnf four_byte_ret /* 8 byte value is returned */ - l.nop - - l.sw 4(r18), r12 - -four_byte_ret: - l.sw 0(r18), r11 - -ret: - /* return */ - l.ori r1, r14, 0x0 /* reset stack pointer */ - l.lwz r9, -4(r1) - l.lwz r1, -8(r1) - l.lwz r14, -12(r1) - l.lwz r16, -16(r1) - l.lwz r18, -20(r1) - l.lwz r20, -24(r1) - l.jr r9 - l.nop - -.size ffi_call_SYSV, .-ffi_call_SYSV diff --git a/user/mpy/lib/libffi/src/pa/ffi.c b/user/mpy/lib/libffi/src/pa/ffi.c deleted file mode 100644 index 4ce2bc6..0000000 --- a/user/mpy/lib/libffi/src/pa/ffi.c +++ /dev/null @@ -1,719 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - (c) 2011 Anthony Green - (c) 2008 Red Hat, Inc. - (c) 2006 Free Software Foundation, Inc. - (c) 2003-2004 Randolph Chung - - HPPA Foreign Function Interface - HP-UX PA ABI support - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include -#include - -#define ROUND_UP(v, a) (((size_t)(v) + (a) - 1) & ~((a) - 1)) - -#define MIN_STACK_SIZE 64 -#define FIRST_ARG_SLOT 9 -#define DEBUG_LEVEL 0 - -#define fldw(addr, fpreg) \ - __asm__ volatile ("fldw 0(%0), %%" #fpreg "L" : : "r"(addr) : #fpreg) -#define fstw(fpreg, addr) \ - __asm__ volatile ("fstw %%" #fpreg "L, 0(%0)" : : "r"(addr)) -#define fldd(addr, fpreg) \ - __asm__ volatile ("fldd 0(%0), %%" #fpreg : : "r"(addr) : #fpreg) -#define fstd(fpreg, addr) \ - __asm__ volatile ("fstd %%" #fpreg "L, 0(%0)" : : "r"(addr)) - -#define debug(lvl, x...) do { if (lvl <= DEBUG_LEVEL) { printf(x); } } while (0) - -static inline int ffi_struct_type(ffi_type *t) -{ - size_t sz = t->size; - - /* Small structure results are passed in registers, - larger ones are passed by pointer. Note that - small structures of size 2, 4 and 8 differ from - the corresponding integer types in that they have - different alignment requirements. */ - - if (sz <= 1) - return FFI_TYPE_UINT8; - else if (sz == 2) - return FFI_TYPE_SMALL_STRUCT2; - else if (sz == 3) - return FFI_TYPE_SMALL_STRUCT3; - else if (sz == 4) - return FFI_TYPE_SMALL_STRUCT4; - else if (sz == 5) - return FFI_TYPE_SMALL_STRUCT5; - else if (sz == 6) - return FFI_TYPE_SMALL_STRUCT6; - else if (sz == 7) - return FFI_TYPE_SMALL_STRUCT7; - else if (sz <= 8) - return FFI_TYPE_SMALL_STRUCT8; - else - return FFI_TYPE_STRUCT; /* else, we pass it by pointer. */ -} - -/* PA has a downward growing stack, which looks like this: - - Offset - [ Variable args ] - SP = (4*(n+9)) arg word N - ... - SP-52 arg word 4 - [ Fixed args ] - SP-48 arg word 3 - SP-44 arg word 2 - SP-40 arg word 1 - SP-36 arg word 0 - [ Frame marker ] - ... - SP-20 RP - SP-4 previous SP - - The first four argument words on the stack are reserved for use by - the callee. Instead, the general and floating registers replace - the first four argument slots. Non FP arguments are passed solely - in the general registers. FP arguments are passed in both general - and floating registers when using libffi. - - Non-FP 32-bit args are passed in gr26, gr25, gr24 and gr23. - Non-FP 64-bit args are passed in register pairs, starting - on an odd numbered register (i.e. r25+r26 and r23+r24). - FP 32-bit arguments are passed in fr4L, fr5L, fr6L and fr7L. - FP 64-bit arguments are passed in fr5 and fr7. - - The registers are allocated in the same manner as stack slots. - This allows the callee to save its arguments on the stack if - necessary: - - arg word 3 -> gr23 or fr7L - arg word 2 -> gr24 or fr6L or fr7R - arg word 1 -> gr25 or fr5L - arg word 0 -> gr26 or fr4L or fr5R - - Note that fr4R and fr6R are never used for arguments (i.e., - doubles are not passed in fr4 or fr6). - - The rest of the arguments are passed on the stack starting at SP-52, - but 64-bit arguments need to be aligned to an 8-byte boundary - - This means we can have holes either in the register allocation, - or in the stack. */ - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments - - The following code will put everything into the stack frame - (which was allocated by the asm routine), and on return - the asm routine will load the arguments that should be - passed by register into the appropriate registers - - NOTE: We load floating point args in this function... that means we - assume gcc will not mess with fp regs in here. */ - -void ffi_prep_args_pa32(UINT32 *stack, extended_cif *ecif, unsigned bytes) -{ - register unsigned int i; - register ffi_type **p_arg; - register void **p_argv; - unsigned int slot = FIRST_ARG_SLOT; - char *dest_cpy; - size_t len; - - debug(1, "%s: stack = %p, ecif = %p, bytes = %u\n", __FUNCTION__, stack, - ecif, bytes); - - p_arg = ecif->cif->arg_types; - p_argv = ecif->avalue; - - for (i = 0; i < ecif->cif->nargs; i++) - { - int type = (*p_arg)->type; - - switch (type) - { - case FFI_TYPE_SINT8: - *(SINT32 *)(stack - slot) = *(SINT8 *)(*p_argv); - break; - - case FFI_TYPE_UINT8: - *(UINT32 *)(stack - slot) = *(UINT8 *)(*p_argv); - break; - - case FFI_TYPE_SINT16: - *(SINT32 *)(stack - slot) = *(SINT16 *)(*p_argv); - break; - - case FFI_TYPE_UINT16: - *(UINT32 *)(stack - slot) = *(UINT16 *)(*p_argv); - break; - - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - debug(3, "Storing UINT32 %u in slot %u\n", *(UINT32 *)(*p_argv), - slot); - *(UINT32 *)(stack - slot) = *(UINT32 *)(*p_argv); - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - /* Align slot for 64-bit type. */ - slot += (slot & 1) ? 1 : 2; - *(UINT64 *)(stack - slot) = *(UINT64 *)(*p_argv); - break; - - case FFI_TYPE_FLOAT: - /* First 4 args go in fr4L - fr7L. */ - debug(3, "Storing UINT32(float) in slot %u\n", slot); - *(UINT32 *)(stack - slot) = *(UINT32 *)(*p_argv); - switch (slot - FIRST_ARG_SLOT) - { - /* First 4 args go in fr4L - fr7L. */ - case 0: fldw(stack - slot, fr4); break; - case 1: fldw(stack - slot, fr5); break; - case 2: fldw(stack - slot, fr6); break; - case 3: fldw(stack - slot, fr7); break; - } - break; - - case FFI_TYPE_DOUBLE: - /* Align slot for 64-bit type. */ - slot += (slot & 1) ? 1 : 2; - debug(3, "Storing UINT64(double) at slot %u\n", slot); - *(UINT64 *)(stack - slot) = *(UINT64 *)(*p_argv); - switch (slot - FIRST_ARG_SLOT) - { - /* First 2 args go in fr5, fr7. */ - case 1: fldd(stack - slot, fr5); break; - case 3: fldd(stack - slot, fr7); break; - } - break; - -#ifdef PA_HPUX - case FFI_TYPE_LONGDOUBLE: - /* Long doubles are passed in the same manner as structures - larger than 8 bytes. */ - *(UINT32 *)(stack - slot) = (UINT32)(*p_argv); - break; -#endif - - case FFI_TYPE_STRUCT: - - /* Structs smaller or equal than 4 bytes are passed in one - register. Structs smaller or equal 8 bytes are passed in two - registers. Larger structures are passed by pointer. */ - - len = (*p_arg)->size; - if (len <= 4) - { - dest_cpy = (char *)(stack - slot) + 4 - len; - memcpy(dest_cpy, (char *)*p_argv, len); - } - else if (len <= 8) - { - slot += (slot & 1) ? 1 : 2; - dest_cpy = (char *)(stack - slot) + 8 - len; - memcpy(dest_cpy, (char *)*p_argv, len); - } - else - *(UINT32 *)(stack - slot) = (UINT32)(*p_argv); - break; - - default: - FFI_ASSERT(0); - } - - slot++; - p_arg++; - p_argv++; - } - - /* Make sure we didn't mess up and scribble on the stack. */ - { - unsigned int n; - - debug(5, "Stack setup:\n"); - for (n = 0; n < (bytes + 3) / 4; n++) - { - if ((n%4) == 0) { debug(5, "\n%08x: ", (unsigned int)(stack - n)); } - debug(5, "%08x ", *(stack - n)); - } - debug(5, "\n"); - } - - FFI_ASSERT(slot * 4 <= bytes); - - return; -} - -static void ffi_size_stack_pa32(ffi_cif *cif) -{ - ffi_type **ptr; - int i; - int z = 0; /* # stack slots */ - - for (ptr = cif->arg_types, i = 0; i < cif->nargs; ptr++, i++) - { - int type = (*ptr)->type; - - switch (type) - { - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - z += 2 + (z & 1); /* must start on even regs, so we may waste one */ - break; - -#ifdef PA_HPUX - case FFI_TYPE_LONGDOUBLE: -#endif - case FFI_TYPE_STRUCT: - z += 1; /* pass by ptr, callee will copy */ - break; - - default: /* <= 32-bit values */ - z++; - } - } - - /* We can fit up to 6 args in the default 64-byte stack frame, - if we need more, we need more stack. */ - if (z <= 6) - cif->bytes = MIN_STACK_SIZE; /* min stack size */ - else - cif->bytes = 64 + ROUND_UP((z - 6) * sizeof(UINT32), MIN_STACK_SIZE); - - debug(3, "Calculated stack size is %u bytes\n", cif->bytes); -} - -/* Perform machine dependent cif processing. */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags = (unsigned) cif->rtype->type; - break; - -#ifdef PA_HPUX - case FFI_TYPE_LONGDOUBLE: - /* Long doubles are treated like a structure. */ - cif->flags = FFI_TYPE_STRUCT; - break; -#endif - - case FFI_TYPE_STRUCT: - /* For the return type we have to check the size of the structures. - If the size is smaller or equal 4 bytes, the result is given back - in one register. If the size is smaller or equal 8 bytes than we - return the result in two registers. But if the size is bigger than - 8 bytes, we work with pointers. */ - cif->flags = ffi_struct_type(cif->rtype); - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - cif->flags = FFI_TYPE_UINT64; - break; - - default: - cif->flags = FFI_TYPE_INT; - break; - } - - /* Lucky us, because of the unique PA ABI we get to do our - own stack sizing. */ - switch (cif->abi) - { - case FFI_PA32: - ffi_size_stack_pa32(cif); - break; - - default: - FFI_ASSERT(0); - break; - } - - return FFI_OK; -} - -extern void ffi_call_pa32(void (*)(UINT32 *, extended_cif *, unsigned), - extended_cif *, unsigned, unsigned, unsigned *, - void (*fn)(void)); - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return - value address then we need to make one. */ - - if (rvalue == NULL -#ifdef PA_HPUX - && (cif->rtype->type == FFI_TYPE_STRUCT - || cif->rtype->type == FFI_TYPE_LONGDOUBLE)) -#else - && cif->rtype->type == FFI_TYPE_STRUCT) -#endif - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - - switch (cif->abi) - { - case FFI_PA32: - debug(3, "Calling ffi_call_pa32: ecif=%p, bytes=%u, flags=%u, rvalue=%p, fn=%p\n", &ecif, cif->bytes, cif->flags, ecif.rvalue, (void *)fn); - ffi_call_pa32(ffi_prep_args_pa32, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); - break; - - default: - FFI_ASSERT(0); - break; - } -} - -#if FFI_CLOSURES -/* This is more-or-less an inverse of ffi_call -- we have arguments on - the stack, and we need to fill them into a cif structure and invoke - the user function. This really ought to be in asm to make sure - the compiler doesn't do things we don't expect. */ -ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) -{ - ffi_cif *cif; - void **avalue; - void *rvalue; - UINT32 ret[2]; /* function can return up to 64-bits in registers */ - ffi_type **p_arg; - char *tmp; - int i, avn; - unsigned int slot = FIRST_ARG_SLOT; - register UINT32 r28 asm("r28"); - - cif = closure->cif; - - /* If returning via structure, callee will write to our pointer. */ - if (cif->flags == FFI_TYPE_STRUCT) - rvalue = (void *)r28; - else - rvalue = &ret[0]; - - avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG); - avn = cif->nargs; - p_arg = cif->arg_types; - - for (i = 0; i < avn; i++) - { - int type = (*p_arg)->type; - - switch (type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - avalue[i] = (char *)(stack - slot) + sizeof(UINT32) - (*p_arg)->size; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - slot += (slot & 1) ? 1 : 2; - avalue[i] = (void *)(stack - slot); - break; - - case FFI_TYPE_FLOAT: -#ifdef PA_LINUX - /* The closure call is indirect. In Linux, floating point - arguments in indirect calls with a prototype are passed - in the floating point registers instead of the general - registers. So, we need to replace what was previously - stored in the current slot with the value in the - corresponding floating point register. */ - switch (slot - FIRST_ARG_SLOT) - { - case 0: fstw(fr4, (void *)(stack - slot)); break; - case 1: fstw(fr5, (void *)(stack - slot)); break; - case 2: fstw(fr6, (void *)(stack - slot)); break; - case 3: fstw(fr7, (void *)(stack - slot)); break; - } -#endif - avalue[i] = (void *)(stack - slot); - break; - - case FFI_TYPE_DOUBLE: - slot += (slot & 1) ? 1 : 2; -#ifdef PA_LINUX - /* See previous comment for FFI_TYPE_FLOAT. */ - switch (slot - FIRST_ARG_SLOT) - { - case 1: fstd(fr5, (void *)(stack - slot)); break; - case 3: fstd(fr7, (void *)(stack - slot)); break; - } -#endif - avalue[i] = (void *)(stack - slot); - break; - -#ifdef PA_HPUX - case FFI_TYPE_LONGDOUBLE: - /* Long doubles are treated like a big structure. */ - avalue[i] = (void *) *(stack - slot); - break; -#endif - - case FFI_TYPE_STRUCT: - /* Structs smaller or equal than 4 bytes are passed in one - register. Structs smaller or equal 8 bytes are passed in two - registers. Larger structures are passed by pointer. */ - if((*p_arg)->size <= 4) - { - avalue[i] = (void *)(stack - slot) + sizeof(UINT32) - - (*p_arg)->size; - } - else if ((*p_arg)->size <= 8) - { - slot += (slot & 1) ? 1 : 2; - avalue[i] = (void *)(stack - slot) + sizeof(UINT64) - - (*p_arg)->size; - } - else - avalue[i] = (void *) *(stack - slot); - break; - - default: - FFI_ASSERT(0); - } - - slot++; - p_arg++; - } - - /* Invoke the closure. */ - (closure->fun) (cif, rvalue, avalue, closure->user_data); - - debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0], - ret[1]); - - /* Store the result using the lower 2 bytes of the flags. */ - switch (cif->flags) - { - case FFI_TYPE_UINT8: - *(stack - FIRST_ARG_SLOT) = (UINT8)(ret[0] >> 24); - break; - case FFI_TYPE_SINT8: - *(stack - FIRST_ARG_SLOT) = (SINT8)(ret[0] >> 24); - break; - case FFI_TYPE_UINT16: - *(stack - FIRST_ARG_SLOT) = (UINT16)(ret[0] >> 16); - break; - case FFI_TYPE_SINT16: - *(stack - FIRST_ARG_SLOT) = (SINT16)(ret[0] >> 16); - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - *(stack - FIRST_ARG_SLOT) = ret[0]; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - *(stack - FIRST_ARG_SLOT) = ret[0]; - *(stack - FIRST_ARG_SLOT - 1) = ret[1]; - break; - - case FFI_TYPE_DOUBLE: - fldd(rvalue, fr4); - break; - - case FFI_TYPE_FLOAT: - fldw(rvalue, fr4); - break; - - case FFI_TYPE_STRUCT: - /* Don't need a return value, done by caller. */ - break; - - case FFI_TYPE_SMALL_STRUCT2: - case FFI_TYPE_SMALL_STRUCT3: - case FFI_TYPE_SMALL_STRUCT4: - tmp = (void*)(stack - FIRST_ARG_SLOT); - tmp += 4 - cif->rtype->size; - memcpy((void*)tmp, &ret[0], cif->rtype->size); - break; - - case FFI_TYPE_SMALL_STRUCT5: - case FFI_TYPE_SMALL_STRUCT6: - case FFI_TYPE_SMALL_STRUCT7: - case FFI_TYPE_SMALL_STRUCT8: - { - unsigned int ret2[2]; - int off; - - /* Right justify ret[0] and ret[1] */ - switch (cif->flags) - { - case FFI_TYPE_SMALL_STRUCT5: off = 3; break; - case FFI_TYPE_SMALL_STRUCT6: off = 2; break; - case FFI_TYPE_SMALL_STRUCT7: off = 1; break; - default: off = 0; break; - } - - memset (ret2, 0, sizeof (ret2)); - memcpy ((char *)ret2 + off, ret, 8 - off); - - *(stack - FIRST_ARG_SLOT) = ret2[0]; - *(stack - FIRST_ARG_SLOT - 1) = ret2[1]; - } - break; - - case FFI_TYPE_POINTER: - case FFI_TYPE_VOID: - break; - - default: - debug(0, "assert with cif->flags: %d\n",cif->flags); - FFI_ASSERT(0); - break; - } - return FFI_OK; -} - -/* Fill in a closure to refer to the specified fun and user_data. - cif specifies the argument and result types for fun. - The cif must already be prep'ed. */ - -extern void ffi_closure_pa32(void); - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - UINT32 *tramp = (UINT32 *)(closure->tramp); -#ifdef PA_HPUX - UINT32 *tmp; -#endif - - if (cif->abi != FFI_PA32) - return FFI_BAD_ABI; - - /* Make a small trampoline that will branch to our - handler function. Use PC-relative addressing. */ - -#ifdef PA_LINUX - tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */ - tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */ - tramp[2] = 0x4aa10028; /* ldw 20(%r21),%r1 ; load plabel */ - tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */ - tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */ - tramp[5] = 0xeac0c000; /* bv%r0(%r22) ; branch to handler */ - tramp[6] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */ - tramp[7] = ((UINT32)(ffi_closure_pa32) & ~2); - - /* Flush d/icache -- have to flush up 2 two lines because of - alignment. */ - __asm__ volatile( - "fdc 0(%0)\n\t" - "fdc %1(%0)\n\t" - "fic 0(%%sr4, %0)\n\t" - "fic %1(%%sr4, %0)\n\t" - "sync\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n" - : - : "r"((unsigned long)tramp & ~31), - "r"(32 /* stride */) - : "memory"); -#endif - -#ifdef PA_HPUX - tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */ - tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */ - tramp[2] = 0x4aa10038; /* ldw 28(%r21),%r1 ; load plabel */ - tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */ - tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */ - tramp[5] = 0x02c010b4; /* ldsid (%r22),%r20 ; load space id */ - tramp[6] = 0x00141820; /* mtsp %r20,%sr0 ; into %sr0 */ - tramp[7] = 0xe2c00000; /* be 0(%sr0,%r22) ; branch to handler */ - tramp[8] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */ - tramp[9] = ((UINT32)(ffi_closure_pa32) & ~2); - - /* Flush d/icache -- have to flush three lines because of alignment. */ - __asm__ volatile( - "copy %1,%0\n\t" - "fdc,m %2(%0)\n\t" - "fdc,m %2(%0)\n\t" - "fdc,m %2(%0)\n\t" - "ldsid (%1),%0\n\t" - "mtsp %0,%%sr0\n\t" - "copy %1,%0\n\t" - "fic,m %2(%%sr0,%0)\n\t" - "fic,m %2(%%sr0,%0)\n\t" - "fic,m %2(%%sr0,%0)\n\t" - "sync\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n" - : "=&r" ((unsigned long)tmp) - : "r" ((unsigned long)tramp & ~31), - "r" (32/* stride */) - : "memory"); -#endif - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} -#endif diff --git a/user/mpy/lib/libffi/src/pa/ffitarget.h b/user/mpy/lib/libffi/src/pa/ffitarget.h deleted file mode 100644 index fff4c6b..0000000 --- a/user/mpy/lib/libffi/src/pa/ffitarget.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for hppa. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - -#ifdef PA_LINUX - FFI_PA32, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_PA32 -#endif - -#ifdef PA_HPUX - FFI_PA32, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_PA32 -#endif - -#ifdef PA64_HPUX -#error "PA64_HPUX FFI is not yet implemented" - FFI_PA64, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_PA64 -#endif -} ffi_abi; -#endif - -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -#ifdef PA_LINUX -#define FFI_TRAMPOLINE_SIZE 32 -#else -#define FFI_TRAMPOLINE_SIZE 40 -#endif - -#define FFI_TYPE_SMALL_STRUCT2 -1 -#define FFI_TYPE_SMALL_STRUCT3 -2 -#define FFI_TYPE_SMALL_STRUCT4 -3 -#define FFI_TYPE_SMALL_STRUCT5 -4 -#define FFI_TYPE_SMALL_STRUCT6 -5 -#define FFI_TYPE_SMALL_STRUCT7 -6 -#define FFI_TYPE_SMALL_STRUCT8 -7 -#endif diff --git a/user/mpy/lib/libffi/src/pa/hpux32.S b/user/mpy/lib/libffi/src/pa/hpux32.S deleted file mode 100644 index 40528ba..0000000 --- a/user/mpy/lib/libffi/src/pa/hpux32.S +++ /dev/null @@ -1,368 +0,0 @@ -/* ----------------------------------------------------------------------- - hpux32.S - Copyright (c) 2006 Free Software Foundation, Inc. - (c) 2008 Red Hat, Inc. - based on src/pa/linux.S - - HP-UX PA Foreign Function Interface - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - .LEVEL 1.1 - .SPACE $PRIVATE$ - .IMPORT $global$,DATA - .IMPORT $$dyncall,MILLICODE - .SUBSPA $DATA$ - .align 4 - - /* void ffi_call_pa32(void (*)(char *, extended_cif *), - extended_cif *ecif, - unsigned bytes, - unsigned flags, - unsigned *rvalue, - void (*fn)(void)); - */ - - .export ffi_call_pa32,ENTRY,PRIV_LEV=3 - .import ffi_prep_args_pa32,CODE - - .SPACE $TEXT$ - .SUBSPA $CODE$ - .align 4 - -L$FB1 -ffi_call_pa32 - .proc - .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4 - .entry - stw %rp, -20(%sp) - copy %r3, %r1 -L$CFI11 - copy %sp, %r3 -L$CFI12 - - /* Setup the stack for calling prep_args... - We want the stack to look like this: - - [ Previous stack ] <- %r3 - - [ 64-bytes register save area ] <- %r4 - - [ Stack space for actual call, passed as ] <- %arg0 - [ arg0 to ffi_prep_args_pa32 ] - - [ Stack for calling prep_args ] <- %sp - */ - - stwm %r1, 64(%sp) - stw %r4, 12(%r3) -L$CFI13 - copy %sp, %r4 - - addl %arg2, %r4, %arg0 ; arg stack - stw %arg3, -48(%r3) ; save flags we need it later - - /* Call prep_args: - %arg0(stack) -- set up above - %arg1(ecif) -- same as incoming param - %arg2(bytes) -- same as incoming param */ - bl ffi_prep_args_pa32,%r2 - ldo 64(%arg0), %sp - ldo -64(%sp), %sp - - /* now %sp should point where %arg0 was pointing. */ - - /* Load the arguments that should be passed in registers - The fp args are loaded by the prep_args function. */ - ldw -36(%sp), %arg0 - ldw -40(%sp), %arg1 - ldw -44(%sp), %arg2 - ldw -48(%sp), %arg3 - - /* in case the function is going to return a structure - we need to give it a place to put the result. */ - ldw -52(%r3), %ret0 ; %ret0 <- rvalue - ldw -56(%r3), %r22 ; %r22 <- function to call - bl $$dyncall, %r31 ; Call the user function - copy %r31, %rp - - /* Prepare to store the result; we need to recover flags and rvalue. */ - ldw -48(%r3), %r21 ; r21 <- flags - ldw -52(%r3), %r20 ; r20 <- rvalue - - /* Store the result according to the return type. The most - likely types should come first. */ - -L$checkint - comib,<>,n FFI_TYPE_INT, %r21, L$checkint8 - b L$done - stw %ret0, 0(%r20) - -L$checkint8 - comib,<>,n FFI_TYPE_UINT8, %r21, L$checkint16 - b L$done - stb %ret0, 0(%r20) - -L$checkint16 - comib,<>,n FFI_TYPE_UINT16, %r21, L$checkdbl - b L$done - sth %ret0, 0(%r20) - -L$checkdbl - comib,<>,n FFI_TYPE_DOUBLE, %r21, L$checkfloat - b L$done - fstd %fr4,0(%r20) - -L$checkfloat - comib,<>,n FFI_TYPE_FLOAT, %r21, L$checkll - b L$done - fstw %fr4L,0(%r20) - -L$checkll - comib,<>,n FFI_TYPE_UINT64, %r21, L$checksmst2 - stw %ret0, 0(%r20) - b L$done - stw %ret1, 4(%r20) - -L$checksmst2 - comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, L$checksmst3 - /* 2-byte structs are returned in ret0 as ????xxyy. */ - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b L$done - stb %ret0, 0(%r20) - -L$checksmst3 - comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, L$checksmst4 - /* 3-byte structs are returned in ret0 as ??xxyyzz. */ - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b L$done - stb %ret0, 0(%r20) - -L$checksmst4 - comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, L$checksmst5 - /* 4-byte structs are returned in ret0 as wwxxyyzz. */ - extru %ret0, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b L$done - stb %ret0, 0(%r20) - -L$checksmst5 - comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, L$checksmst6 - /* 5 byte values are returned right justified: - ret0 ret1 - 5: ??????aa bbccddee */ - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b L$done - stb %ret1, 0(%r20) - -L$checksmst6 - comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, L$checksmst7 - /* 6 byte values are returned right justified: - ret0 ret1 - 6: ????aabb ccddeeff */ - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b L$done - stb %ret1, 0(%r20) - -L$checksmst7 - comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, L$checksmst8 - /* 7 byte values are returned right justified: - ret0 ret1 - 7: ??aabbcc ddeeffgg */ - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b L$done - stb %ret1, 0(%r20) - -L$checksmst8 - comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, L$done - /* 8 byte values are returned right justified: - ret0 ret1 - 8: aabbccdd eeffgghh */ - extru %ret0, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stb %ret1, 0(%r20) - -L$done - /* all done, return */ - copy %r4, %sp ; pop arg stack - ldw 12(%r3), %r4 - ldwm -64(%sp), %r3 ; .. and pop stack - ldw -20(%sp), %rp - bv %r0(%rp) - nop - .exit - .procend -L$FE1 - - /* void ffi_closure_pa32(void); - Called with closure argument in %r21 */ - - .SPACE $TEXT$ - .SUBSPA $CODE$ - .export ffi_closure_pa32,ENTRY,PRIV_LEV=3,RTNVAL=GR - .import ffi_closure_inner_pa32,CODE - .align 4 -L$FB2 -ffi_closure_pa32 - .proc - .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 - .entry - - stw %rp, -20(%sp) - copy %r3, %r1 -L$CFI21 - copy %sp, %r3 -L$CFI22 - stwm %r1, 64(%sp) - - /* Put arguments onto the stack and call ffi_closure_inner. */ - stw %arg0, -36(%r3) - stw %arg1, -40(%r3) - stw %arg2, -44(%r3) - stw %arg3, -48(%r3) - - copy %r21, %arg0 - bl ffi_closure_inner_pa32, %r2 - copy %r3, %arg1 - ldwm -64(%sp), %r3 - ldw -20(%sp), %rp - ldw -36(%sp), %ret0 - bv %r0(%rp) - ldw -40(%sp), %ret1 - .exit - .procend -L$FE2: - - .SPACE $PRIVATE$ - .SUBSPA $DATA$ - - .align 4 - .EXPORT _GLOBAL__F_ffi_call_pa32,DATA -_GLOBAL__F_ffi_call_pa32 -L$frame1: - .word L$ECIE1-L$SCIE1 ;# Length of Common Information Entry -L$SCIE1: - .word 0x0 ;# CIE Identifier Tag - .byte 0x1 ;# CIE Version - .ascii "\0" ;# CIE Augmentation - .uleb128 0x1 ;# CIE Code Alignment Factor - .sleb128 4 ;# CIE Data Alignment Factor - .byte 0x2 ;# CIE RA Column - .byte 0xc ;# DW_CFA_def_cfa - .uleb128 0x1e - .uleb128 0x0 - .align 4 -L$ECIE1: -L$SFDE1: - .word L$EFDE1-L$ASFDE1 ;# FDE Length -L$ASFDE1: - .word L$ASFDE1-L$frame1 ;# FDE CIE offset - .word L$FB1 ;# FDE initial location - .word L$FE1-L$FB1 ;# FDE address range - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word L$CFI11-L$FB1 - .byte 0x83 ;# DW_CFA_offset, column 0x3 - .uleb128 0x0 - .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20] - .uleb128 0x2 - .sleb128 -5 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word L$CFI12-L$CFI11 - .byte 0xd ;# DW_CFA_def_cfa_register = r3 - .uleb128 0x3 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word L$CFI13-L$CFI12 - .byte 0x84 ;# DW_CFA_offset, column 0x4 - .uleb128 0x3 - - .align 4 -L$EFDE1: - -L$SFDE2: - .word L$EFDE2-L$ASFDE2 ;# FDE Length -L$ASFDE2: - .word L$ASFDE2-L$frame1 ;# FDE CIE offset - .word L$FB2 ;# FDE initial location - .word L$FE2-L$FB2 ;# FDE address range - .byte 0x4 ;# DW_CFA_advance_loc4 - .word L$CFI21-L$FB2 - .byte 0x83 ;# DW_CFA_offset, column 0x3 - .uleb128 0x0 - .byte 0x11 ;# DW_CFA_offset_extended_sf - .uleb128 0x2 - .sleb128 -5 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word L$CFI22-L$CFI21 - .byte 0xd ;# DW_CFA_def_cfa_register = r3 - .uleb128 0x3 - - .align 4 -L$EFDE2: diff --git a/user/mpy/lib/libffi/src/pa/linux.S b/user/mpy/lib/libffi/src/pa/linux.S deleted file mode 100644 index f11ae76..0000000 --- a/user/mpy/lib/libffi/src/pa/linux.S +++ /dev/null @@ -1,357 +0,0 @@ -/* ----------------------------------------------------------------------- - linux.S - (c) 2003-2004 Randolph Chung - (c) 2008 Red Hat, Inc. - - HPPA Foreign Function Interface - - 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 RENESAS TECHNOLOGY 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - .text - .level 1.1 - .align 4 - - /* void ffi_call_pa32(void (*)(char *, extended_cif *), - extended_cif *ecif, - unsigned bytes, - unsigned flags, - unsigned *rvalue, - void (*fn)(void)); - */ - - .export ffi_call_pa32,code - .import ffi_prep_args_pa32,code - - .type ffi_call_pa32, @function -.LFB1: -ffi_call_pa32: - .proc - .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4 - .entry - stw %rp, -20(%sp) - copy %r3, %r1 -.LCFI11: - - copy %sp, %r3 -.LCFI12: - - /* Setup the stack for calling prep_args... - We want the stack to look like this: - - [ Previous stack ] <- %r3 - - [ 64-bytes register save area ] <- %r4 - - [ Stack space for actual call, passed as ] <- %arg0 - [ arg0 to ffi_prep_args_pa32 ] - - [ Stack for calling prep_args ] <- %sp - */ - - stwm %r1, 64(%sp) - stw %r4, 12(%r3) -.LCFI13: - copy %sp, %r4 - - addl %arg2, %r4, %arg0 /* arg stack */ - stw %arg3, -48(%r3) /* save flags; we need it later */ - - /* Call prep_args: - %arg0(stack) -- set up above - %arg1(ecif) -- same as incoming param - %arg2(bytes) -- same as incoming param */ - bl ffi_prep_args_pa32,%r2 - ldo 64(%arg0), %sp - ldo -64(%sp), %sp - - /* now %sp should point where %arg0 was pointing. */ - - /* Load the arguments that should be passed in registers - The fp args were loaded by the prep_args function. */ - ldw -36(%sp), %arg0 - ldw -40(%sp), %arg1 - ldw -44(%sp), %arg2 - ldw -48(%sp), %arg3 - - /* in case the function is going to return a structure - we need to give it a place to put the result. */ - ldw -52(%r3), %ret0 /* %ret0 <- rvalue */ - ldw -56(%r3), %r22 /* %r22 <- function to call */ - bl $$dyncall, %r31 /* Call the user function */ - copy %r31, %rp - - /* Prepare to store the result; we need to recover flags and rvalue. */ - ldw -48(%r3), %r21 /* r21 <- flags */ - ldw -52(%r3), %r20 /* r20 <- rvalue */ - - /* Store the result according to the return type. */ - -.Lcheckint: - comib,<>,n FFI_TYPE_INT, %r21, .Lcheckint8 - b .Ldone - stw %ret0, 0(%r20) - -.Lcheckint8: - comib,<>,n FFI_TYPE_UINT8, %r21, .Lcheckint16 - b .Ldone - stb %ret0, 0(%r20) - -.Lcheckint16: - comib,<>,n FFI_TYPE_UINT16, %r21, .Lcheckdbl - b .Ldone - sth %ret0, 0(%r20) - -.Lcheckdbl: - comib,<>,n FFI_TYPE_DOUBLE, %r21, .Lcheckfloat - b .Ldone - fstd %fr4,0(%r20) - -.Lcheckfloat: - comib,<>,n FFI_TYPE_FLOAT, %r21, .Lcheckll - b .Ldone - fstw %fr4L,0(%r20) - -.Lcheckll: - comib,<>,n FFI_TYPE_UINT64, %r21, .Lchecksmst2 - stw %ret0, 0(%r20) - b .Ldone - stw %ret1, 4(%r20) - -.Lchecksmst2: - comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, .Lchecksmst3 - /* 2-byte structs are returned in ret0 as ????xxyy. */ - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b .Ldone - stb %ret0, 0(%r20) - -.Lchecksmst3: - comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, .Lchecksmst4 - /* 3-byte structs are returned in ret0 as ??xxyyzz. */ - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b .Ldone - stb %ret0, 0(%r20) - -.Lchecksmst4: - comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, .Lchecksmst5 - /* 4-byte structs are returned in ret0 as wwxxyyzz. */ - extru %ret0, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b .Ldone - stb %ret0, 0(%r20) - -.Lchecksmst5: - comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, .Lchecksmst6 - /* 5 byte values are returned right justified: - ret0 ret1 - 5: ??????aa bbccddee */ - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b .Ldone - stb %ret1, 0(%r20) - -.Lchecksmst6: - comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, .Lchecksmst7 - /* 6 byte values are returned right justified: - ret0 ret1 - 6: ????aabb ccddeeff */ - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b .Ldone - stb %ret1, 0(%r20) - -.Lchecksmst7: - comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, .Lchecksmst8 - /* 7 byte values are returned right justified: - ret0 ret1 - 7: ??aabbcc ddeeffgg */ - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - b .Ldone - stb %ret1, 0(%r20) - -.Lchecksmst8: - comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, .Ldone - /* 8 byte values are returned right justified: - ret0 ret1 - 8: aabbccdd eeffgghh */ - extru %ret0, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret0, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stbs,ma %ret0, 1(%r20) - extru %ret1, 7, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 15, 8, %r22 - stbs,ma %r22, 1(%r20) - extru %ret1, 23, 8, %r22 - stbs,ma %r22, 1(%r20) - stb %ret1, 0(%r20) - -.Ldone: - /* all done, return */ - copy %r4, %sp /* pop arg stack */ - ldw 12(%r3), %r4 - ldwm -64(%sp), %r3 /* .. and pop stack */ - ldw -20(%sp), %rp - bv %r0(%rp) - nop - .exit - .procend -.LFE1: - - /* void ffi_closure_pa32(void); - Called with closure argument in %r21 */ - .export ffi_closure_pa32,code - .import ffi_closure_inner_pa32,code - - .type ffi_closure_pa32, @function -.LFB2: -ffi_closure_pa32: - .proc - .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 - .entry - - stw %rp, -20(%sp) -.LCFI20: - copy %r3, %r1 -.LCFI21: - copy %sp, %r3 -.LCFI22: - stwm %r1, 64(%sp) - - /* Put arguments onto the stack and call ffi_closure_inner. */ - stw %arg0, -36(%r3) - stw %arg1, -40(%r3) - stw %arg2, -44(%r3) - stw %arg3, -48(%r3) - - copy %r21, %arg0 - bl ffi_closure_inner_pa32, %r2 - copy %r3, %arg1 - - ldwm -64(%sp), %r3 - ldw -20(%sp), %rp - ldw -36(%sp), %ret0 - bv %r0(%r2) - ldw -40(%sp), %ret1 - - .exit - .procend -.LFE2: - - .section ".eh_frame",EH_FRAME_FLAGS,@progbits -.Lframe1: - .word .LECIE1-.LSCIE1 ;# Length of Common Information Entry -.LSCIE1: - .word 0x0 ;# CIE Identifier Tag - .byte 0x1 ;# CIE Version - .ascii "\0" ;# CIE Augmentation - .uleb128 0x1 ;# CIE Code Alignment Factor - .sleb128 4 ;# CIE Data Alignment Factor - .byte 0x2 ;# CIE RA Column - .byte 0xc ;# DW_CFA_def_cfa - .uleb128 0x1e - .uleb128 0x0 - .align 4 -.LECIE1: -.LSFDE1: - .word .LEFDE1-.LASFDE1 ;# FDE Length -.LASFDE1: - .word .LASFDE1-.Lframe1 ;# FDE CIE offset - .word .LFB1 ;# FDE initial location - .word .LFE1-.LFB1 ;# FDE address range - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI11-.LFB1 - .byte 0x83 ;# DW_CFA_offset, column 0x3 - .uleb128 0x0 - .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20] - .uleb128 0x2 - .sleb128 -5 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI12-.LCFI11 - .byte 0xd ;# DW_CFA_def_cfa_register = r3 - .uleb128 0x3 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI13-.LCFI12 - .byte 0x84 ;# DW_CFA_offset, column 0x4 - .uleb128 0x3 - - .align 4 -.LEFDE1: - -.LSFDE2: - .word .LEFDE2-.LASFDE2 ;# FDE Length -.LASFDE2: - .word .LASFDE2-.Lframe1 ;# FDE CIE offset - .word .LFB2 ;# FDE initial location - .word .LFE2-.LFB2 ;# FDE address range - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI21-.LFB2 - .byte 0x83 ;# DW_CFA_offset, column 0x3 - .uleb128 0x0 - .byte 0x11 ;# DW_CFA_offset_extended_sf - .uleb128 0x2 - .sleb128 -5 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI22-.LCFI21 - .byte 0xd ;# DW_CFA_def_cfa_register = r3 - .uleb128 0x3 - - .align 4 -.LEFDE2: diff --git a/user/mpy/lib/libffi/src/powerpc/aix.S b/user/mpy/lib/libffi/src/powerpc/aix.S deleted file mode 100644 index 349e78c..0000000 --- a/user/mpy/lib/libffi/src/powerpc/aix.S +++ /dev/null @@ -1,328 +0,0 @@ -/* ----------------------------------------------------------------------- - aix.S - Copyright (c) 2002, 2009 Free Software Foundation, Inc. - based on darwin.S by John Hornkvist - - PowerPC Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - - .set r0,0 - .set r1,1 - .set r2,2 - .set r3,3 - .set r4,4 - .set r5,5 - .set r6,6 - .set r7,7 - .set r8,8 - .set r9,9 - .set r10,10 - .set r11,11 - .set r12,12 - .set r13,13 - .set r14,14 - .set r15,15 - .set r16,16 - .set r17,17 - .set r18,18 - .set r19,19 - .set r20,20 - .set r21,21 - .set r22,22 - .set r23,23 - .set r24,24 - .set r25,25 - .set r26,26 - .set r27,27 - .set r28,28 - .set r29,29 - .set r30,30 - .set r31,31 - .set f0,0 - .set f1,1 - .set f2,2 - .set f3,3 - .set f4,4 - .set f5,5 - .set f6,6 - .set f7,7 - .set f8,8 - .set f9,9 - .set f10,10 - .set f11,11 - .set f12,12 - .set f13,13 - .set f14,14 - .set f15,15 - .set f16,16 - .set f17,17 - .set f18,18 - .set f19,19 - .set f20,20 - .set f21,21 - - .extern .ffi_prep_args - -#define LIBFFI_ASM -#include -#include -#define JUMPTARGET(name) name -#define L(x) x - .file "aix.S" - .toc - - /* void ffi_call_AIX(extended_cif *ecif, unsigned long bytes, - * unsigned int flags, unsigned int *rvalue, - * void (*fn)(), - * void (*prep_args)(extended_cif*, unsigned *const)); - * r3=ecif, r4=bytes, r5=flags, r6=rvalue, r7=fn, r8=prep_args - */ - -.csect .text[PR] - .align 2 - .globl ffi_call_AIX - .globl .ffi_call_AIX -.csect ffi_call_AIX[DS] -ffi_call_AIX: -#ifdef __64BIT__ - .llong .ffi_call_AIX, TOC[tc0], 0 - .csect .text[PR] -.ffi_call_AIX: - /* Save registers we use. */ - mflr r0 - - std r28,-32(r1) - std r29,-24(r1) - std r30,-16(r1) - std r31, -8(r1) - - std r0, 16(r1) - mr r28, r1 /* our AP. */ - stdux r1, r1, r4 - - /* Save arguments over call... */ - mr r31, r5 /* flags, */ - mr r30, r6 /* rvalue, */ - mr r29, r7 /* function address. */ - std r2, 40(r1) - - /* Call ffi_prep_args. */ - mr r4, r1 - bl .ffi_prep_args - nop - - /* Now do the call. */ - ld r0, 0(r29) - ld r2, 8(r29) - ld r11, 16(r29) - /* Set up cr1 with bits 4-7 of the flags. */ - mtcrf 0x40, r31 - mtctr r0 - /* Load all those argument registers. */ - /* We have set up a nice stack frame, just load it into registers. */ - ld r3, 40+(1*8)(r1) - ld r4, 40+(2*8)(r1) - ld r5, 40+(3*8)(r1) - ld r6, 40+(4*8)(r1) - nop - ld r7, 40+(5*8)(r1) - ld r8, 40+(6*8)(r1) - ld r9, 40+(7*8)(r1) - ld r10,40+(8*8)(r1) - -L1: - /* Load all the FP registers. */ - bf 6,L2 /* 2f + 0x18 */ - lfd f1,-32-(13*8)(r28) - lfd f2,-32-(12*8)(r28) - lfd f3,-32-(11*8)(r28) - lfd f4,-32-(10*8)(r28) - nop - lfd f5,-32-(9*8)(r28) - lfd f6,-32-(8*8)(r28) - lfd f7,-32-(7*8)(r28) - lfd f8,-32-(6*8)(r28) - nop - lfd f9,-32-(5*8)(r28) - lfd f10,-32-(4*8)(r28) - lfd f11,-32-(3*8)(r28) - lfd f12,-32-(2*8)(r28) - nop - lfd f13,-32-(1*8)(r28) - -L2: - /* Make the call. */ - bctrl - ld r2, 40(r1) - - /* Now, deal with the return value. */ - mtcrf 0x01, r31 - - bt 30, L(done_return_value) - bt 29, L(fp_return_value) - std r3, 0(r30) - - /* Fall through... */ - -L(done_return_value): - /* Restore the registers we used and return. */ - mr r1, r28 - ld r0, 16(r28) - ld r28, -32(r1) - mtlr r0 - ld r29, -24(r1) - ld r30, -16(r1) - ld r31, -8(r1) - blr - -L(fp_return_value): - bf 28, L(float_return_value) - stfd f1, 0(r30) - bf 31, L(done_return_value) - stfd f2, 8(r30) - b L(done_return_value) -L(float_return_value): - stfs f1, 0(r30) - b L(done_return_value) - -#else /* ! __64BIT__ */ - - .long .ffi_call_AIX, TOC[tc0], 0 - .csect .text[PR] -.ffi_call_AIX: - /* Save registers we use. */ - mflr r0 - - stw r28,-16(r1) - stw r29,-12(r1) - stw r30, -8(r1) - stw r31, -4(r1) - - stw r0, 8(r1) - mr r28, r1 /* out AP. */ - stwux r1, r1, r4 - - /* Save arguments over call... */ - mr r31, r5 /* flags, */ - mr r30, r6 /* rvalue, */ - mr r29, r7 /* function address, */ - stw r2, 20(r1) - - /* Call ffi_prep_args. */ - mr r4, r1 - bl .ffi_prep_args - nop - - /* Now do the call. */ - lwz r0, 0(r29) - lwz r2, 4(r29) - lwz r11, 8(r29) - /* Set up cr1 with bits 4-7 of the flags. */ - mtcrf 0x40, r31 - mtctr r0 - /* Load all those argument registers. */ - /* We have set up a nice stack frame, just load it into registers. */ - lwz r3, 20+(1*4)(r1) - lwz r4, 20+(2*4)(r1) - lwz r5, 20+(3*4)(r1) - lwz r6, 20+(4*4)(r1) - nop - lwz r7, 20+(5*4)(r1) - lwz r8, 20+(6*4)(r1) - lwz r9, 20+(7*4)(r1) - lwz r10,20+(8*4)(r1) - -L1: - /* Load all the FP registers. */ - bf 6,L2 /* 2f + 0x18 */ - lfd f1,-16-(13*8)(r28) - lfd f2,-16-(12*8)(r28) - lfd f3,-16-(11*8)(r28) - lfd f4,-16-(10*8)(r28) - nop - lfd f5,-16-(9*8)(r28) - lfd f6,-16-(8*8)(r28) - lfd f7,-16-(7*8)(r28) - lfd f8,-16-(6*8)(r28) - nop - lfd f9,-16-(5*8)(r28) - lfd f10,-16-(4*8)(r28) - lfd f11,-16-(3*8)(r28) - lfd f12,-16-(2*8)(r28) - nop - lfd f13,-16-(1*8)(r28) - -L2: - /* Make the call. */ - bctrl - lwz r2, 20(r1) - - /* Now, deal with the return value. */ - mtcrf 0x01, r31 - - bt 30, L(done_return_value) - bt 29, L(fp_return_value) - stw r3, 0(r30) - bf 28, L(done_return_value) - stw r4, 4(r30) - - /* Fall through... */ - -L(done_return_value): - /* Restore the registers we used and return. */ - mr r1, r28 - lwz r0, 8(r28) - lwz r28,-16(r1) - mtlr r0 - lwz r29,-12(r1) - lwz r30, -8(r1) - lwz r31, -4(r1) - blr - -L(fp_return_value): - bf 28, L(float_return_value) - stfd f1, 0(r30) - b L(done_return_value) -L(float_return_value): - stfs f1, 0(r30) - b L(done_return_value) -#endif - .long 0 - .byte 0,0,0,1,128,4,0,0 -/* END(ffi_call_AIX) */ - -.csect .text[PR] - .align 2 - .globl ffi_call_DARWIN - .globl .ffi_call_DARWIN -.csect ffi_call_DARWIN[DS] -ffi_call_DARWIN: -#ifdef __64BIT__ - .llong .ffi_call_DARWIN, TOC[tc0], 0 -#else - .long .ffi_call_DARWIN, TOC[tc0], 0 -#endif - .csect .text[PR] -.ffi_call_DARWIN: - blr - .long 0 - .byte 0,0,0,0,0,0,0,0 -/* END(ffi_call_DARWIN) */ diff --git a/user/mpy/lib/libffi/src/powerpc/aix_closure.S b/user/mpy/lib/libffi/src/powerpc/aix_closure.S deleted file mode 100644 index aabd3c3..0000000 --- a/user/mpy/lib/libffi/src/powerpc/aix_closure.S +++ /dev/null @@ -1,447 +0,0 @@ -/* ----------------------------------------------------------------------- - aix_closure.S - Copyright (c) 2002, 2003, 2009 Free Software Foundation, Inc. - based on darwin_closure.S - - PowerPC Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - - .set r0,0 - .set r1,1 - .set r2,2 - .set r3,3 - .set r4,4 - .set r5,5 - .set r6,6 - .set r7,7 - .set r8,8 - .set r9,9 - .set r10,10 - .set r11,11 - .set r12,12 - .set r13,13 - .set r14,14 - .set r15,15 - .set r16,16 - .set r17,17 - .set r18,18 - .set r19,19 - .set r20,20 - .set r21,21 - .set r22,22 - .set r23,23 - .set r24,24 - .set r25,25 - .set r26,26 - .set r27,27 - .set r28,28 - .set r29,29 - .set r30,30 - .set r31,31 - .set f0,0 - .set f1,1 - .set f2,2 - .set f3,3 - .set f4,4 - .set f5,5 - .set f6,6 - .set f7,7 - .set f8,8 - .set f9,9 - .set f10,10 - .set f11,11 - .set f12,12 - .set f13,13 - .set f14,14 - .set f15,15 - .set f16,16 - .set f17,17 - .set f18,18 - .set f19,19 - .set f20,20 - .set f21,21 - - .extern .ffi_closure_helper_DARWIN - -#define LIBFFI_ASM -#define JUMPTARGET(name) name -#define L(x) x - .file "aix_closure.S" - .toc -LC..60: - .tc L..60[TC],L..60 - .csect .text[PR] - .align 2 - -.csect .text[PR] - .align 2 - .globl ffi_closure_ASM - .globl .ffi_closure_ASM -.csect ffi_closure_ASM[DS] -ffi_closure_ASM: -#ifdef __64BIT__ - .llong .ffi_closure_ASM, TOC[tc0], 0 - .csect .text[PR] -.ffi_closure_ASM: -/* we want to build up an area for the parameters passed */ -/* in registers (both floating point and integer) */ - - /* we store gpr 3 to gpr 10 (aligned to 4) - in the parents outgoing area */ - std r3, 48+(0*8)(r1) - std r4, 48+(1*8)(r1) - std r5, 48+(2*8)(r1) - std r6, 48+(3*8)(r1) - mflr r0 - - std r7, 48+(4*8)(r1) - std r8, 48+(5*8)(r1) - std r9, 48+(6*8)(r1) - std r10, 48+(7*8)(r1) - std r0, 16(r1) /* save the return address */ - - - /* 48 Bytes (Linkage Area) */ - /* 64 Bytes (params) */ - /* 16 Bytes (result) */ - /* 104 Bytes (13*8 from FPR) */ - /* 8 Bytes (alignment) */ - /* 240 Bytes */ - - stdu r1, -240(r1) /* skip over caller save area - keep stack aligned to 16 */ - - /* next save fpr 1 to fpr 13 (aligned to 8) */ - stfd f1, 128+(0*8)(r1) - stfd f2, 128+(1*8)(r1) - stfd f3, 128+(2*8)(r1) - stfd f4, 128+(3*8)(r1) - stfd f5, 128+(4*8)(r1) - stfd f6, 128+(5*8)(r1) - stfd f7, 128+(6*8)(r1) - stfd f8, 128+(7*8)(r1) - stfd f9, 128+(8*8)(r1) - stfd f10, 128+(9*8)(r1) - stfd f11, 128+(10*8)(r1) - stfd f12, 128+(11*8)(r1) - stfd f13, 128+(12*8)(r1) - - /* set up registers for the routine that actually does the work */ - /* get the context pointer from the trampoline */ - mr r3, r11 - - /* now load up the pointer to the result storage */ - addi r4, r1, 112 - - /* now load up the pointer to the saved gpr registers */ - addi r5, r1, 288 - - /* now load up the pointer to the saved fpr registers */ - addi r6, r1, 128 - - /* make the call */ - bl .ffi_closure_helper_DARWIN - nop - - /* now r3 contains the return type */ - /* so use it to look up in a table */ - /* so we know how to deal with each type */ - - /* look up the proper starting point in table */ - /* by using return type as offset */ - lhz r3, 10(r3) /* load type from return type */ - ld r4, LC..60(2) /* get address of jump table */ - sldi r3, r3, 4 /* now multiply return type by 16 */ - ld r0, 240+16(r1) /* load return address */ - add r3, r3, r4 /* add contents of table to table address */ - mtctr r3 - bctr /* jump to it */ - -/* Each fragment must be exactly 16 bytes long (4 instructions). - Align to 16 byte boundary for cache and dispatch efficiency. */ - .align 4 - -L..60: -/* case FFI_TYPE_VOID */ - mtlr r0 - addi r1, r1, 240 - blr - nop - -/* case FFI_TYPE_INT */ - lwa r3, 112+4(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_FLOAT */ - lfs f1, 112+0(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_DOUBLE */ - lfd f1, 112+0(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_LONGDOUBLE */ - lfd f1, 112+0(r1) - mtlr r0 - lfd f2, 112+8(r1) - b L..finish - -/* case FFI_TYPE_UINT8 */ - lbz r3, 112+7(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_SINT8 */ - lbz r3, 112+7(r1) - mtlr r0 - extsb r3, r3 - b L..finish - -/* case FFI_TYPE_UINT16 */ - lhz r3, 112+6(r1) - mtlr r0 -L..finish: - addi r1, r1, 240 - blr - -/* case FFI_TYPE_SINT16 */ - lha r3, 112+6(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_UINT32 */ - lwz r3, 112+4(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_SINT32 */ - lwa r3, 112+4(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_UINT64 */ - ld r3, 112+0(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_SINT64 */ - ld r3, 112+0(r1) - mtlr r0 - addi r1, r1, 240 - blr - -/* case FFI_TYPE_STRUCT */ - mtlr r0 - addi r1, r1, 240 - blr - nop - -/* case FFI_TYPE_POINTER */ - ld r3, 112+0(r1) - mtlr r0 - addi r1, r1, 240 - blr - -#else /* ! __64BIT__ */ - - .long .ffi_closure_ASM, TOC[tc0], 0 - .csect .text[PR] -.ffi_closure_ASM: -/* we want to build up an area for the parameters passed */ -/* in registers (both floating point and integer) */ - - /* we store gpr 3 to gpr 10 (aligned to 4) - in the parents outgoing area */ - stw r3, 24+(0*4)(r1) - stw r4, 24+(1*4)(r1) - stw r5, 24+(2*4)(r1) - stw r6, 24+(3*4)(r1) - mflr r0 - - stw r7, 24+(4*4)(r1) - stw r8, 24+(5*4)(r1) - stw r9, 24+(6*4)(r1) - stw r10, 24+(7*4)(r1) - stw r0, 8(r1) - - /* 24 Bytes (Linkage Area) */ - /* 32 Bytes (params) */ - /* 16 Bytes (result) */ - /* 104 Bytes (13*8 from FPR) */ - /* 176 Bytes */ - - stwu r1, -176(r1) /* skip over caller save area - keep stack aligned to 16 */ - - /* next save fpr 1 to fpr 13 (aligned to 8) */ - stfd f1, 72+(0*8)(r1) - stfd f2, 72+(1*8)(r1) - stfd f3, 72+(2*8)(r1) - stfd f4, 72+(3*8)(r1) - stfd f5, 72+(4*8)(r1) - stfd f6, 72+(5*8)(r1) - stfd f7, 72+(6*8)(r1) - stfd f8, 72+(7*8)(r1) - stfd f9, 72+(8*8)(r1) - stfd f10, 72+(9*8)(r1) - stfd f11, 72+(10*8)(r1) - stfd f12, 72+(11*8)(r1) - stfd f13, 72+(12*8)(r1) - - /* set up registers for the routine that actually does the work */ - /* get the context pointer from the trampoline */ - mr r3, r11 - - /* now load up the pointer to the result storage */ - addi r4, r1, 56 - - /* now load up the pointer to the saved gpr registers */ - addi r5, r1, 200 - - /* now load up the pointer to the saved fpr registers */ - addi r6, r1, 72 - - /* make the call */ - bl .ffi_closure_helper_DARWIN - nop - - /* now r3 contains the return type */ - /* so use it to look up in a table */ - /* so we know how to deal with each type */ - - /* look up the proper starting point in table */ - /* by using return type as offset */ - lhz r3, 6(r3) /* load type from return type */ - lwz r4, LC..60(2) /* get address of jump table */ - slwi r3, r3, 4 /* now multiply return type by 16 */ - lwz r0, 176+8(r1) /* load return address */ - add r3, r3, r4 /* add contents of table to table address */ - mtctr r3 - bctr /* jump to it */ - -/* Each fragment must be exactly 16 bytes long (4 instructions). - Align to 16 byte boundary for cache and dispatch efficiency. */ - .align 4 - -L..60: -/* case FFI_TYPE_VOID */ - mtlr r0 - addi r1, r1, 176 - blr - nop - -/* case FFI_TYPE_INT */ - lwz r3, 56+0(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_FLOAT */ - lfs f1, 56+0(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_DOUBLE */ - lfd f1, 56+0(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_LONGDOUBLE */ - lfd f1, 56+0(r1) - mtlr r0 - lfd f2, 56+8(r1) - b L..finish - -/* case FFI_TYPE_UINT8 */ - lbz r3, 56+3(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_SINT8 */ - lbz r3, 56+3(r1) - mtlr r0 - extsb r3, r3 - b L..finish - -/* case FFI_TYPE_UINT16 */ - lhz r3, 56+2(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_SINT16 */ - lha r3, 56+2(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_UINT32 */ - lwz r3, 56+0(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_SINT32 */ - lwz r3, 56+0(r1) - mtlr r0 - addi r1, r1, 176 - blr - -/* case FFI_TYPE_UINT64 */ - lwz r3, 56+0(r1) - mtlr r0 - lwz r4, 56+4(r1) - b L..finish - -/* case FFI_TYPE_SINT64 */ - lwz r3, 56+0(r1) - mtlr r0 - lwz r4, 56+4(r1) - b L..finish - -/* case FFI_TYPE_STRUCT */ - mtlr r0 - addi r1, r1, 176 - blr - nop - -/* case FFI_TYPE_POINTER */ - lwz r3, 56+0(r1) - mtlr r0 -L..finish: - addi r1, r1, 176 - blr -#endif -/* END(ffi_closure_ASM) */ diff --git a/user/mpy/lib/libffi/src/powerpc/asm.h b/user/mpy/lib/libffi/src/powerpc/asm.h deleted file mode 100644 index 994f62d..0000000 --- a/user/mpy/lib/libffi/src/powerpc/asm.h +++ /dev/null @@ -1,125 +0,0 @@ -/* ----------------------------------------------------------------------- - asm.h - Copyright (c) 1998 Geoffrey Keating - - PowerPC Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#define ASM_GLOBAL_DIRECTIVE .globl - - -#define C_SYMBOL_NAME(name) name -/* Macro for a label. */ -#ifdef __STDC__ -#define C_LABEL(name) name##: -#else -#define C_LABEL(name) name/**/: -#endif - -/* This seems to always be the case on PPC. */ -#define ALIGNARG(log2) log2 -/* For ELF we need the `.type' directive to make shared libs work right. */ -#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; -#define ASM_SIZE_DIRECTIVE(name) .size name,.-name - -/* If compiled for profiling, call `_mcount' at the start of each function. */ -#ifdef PROF -/* The mcount code relies on the return address being on the stack - to locate our caller and so it can restore it; so store one just - for its benefit. */ -#ifdef PIC -#define CALL_MCOUNT \ - .pushsection; \ - .section ".data"; \ - .align ALIGNARG(2); \ -0:.long 0; \ - .previous; \ - mflr %r0; \ - stw %r0,4(%r1); \ - bl _GLOBAL_OFFSET_TABLE_@local-4; \ - mflr %r11; \ - lwz %r0,0b@got(%r11); \ - bl JUMPTARGET(_mcount); -#else /* PIC */ -#define CALL_MCOUNT \ - .section ".data"; \ - .align ALIGNARG(2); \ -0:.long 0; \ - .previous; \ - mflr %r0; \ - lis %r11,0b@ha; \ - stw %r0,4(%r1); \ - addi %r0,%r11,0b@l; \ - bl JUMPTARGET(_mcount); -#endif /* PIC */ -#else /* PROF */ -#define CALL_MCOUNT /* Do nothing. */ -#endif /* PROF */ - -#define ENTRY(name) \ - ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ - ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ - .align ALIGNARG(2); \ - C_LABEL(name) \ - CALL_MCOUNT - -#define EALIGN_W_0 /* No words to insert. */ -#define EALIGN_W_1 nop -#define EALIGN_W_2 nop;nop -#define EALIGN_W_3 nop;nop;nop -#define EALIGN_W_4 EALIGN_W_3;nop -#define EALIGN_W_5 EALIGN_W_4;nop -#define EALIGN_W_6 EALIGN_W_5;nop -#define EALIGN_W_7 EALIGN_W_6;nop - -/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes - past a 2^align boundary. */ -#ifdef PROF -#define EALIGN(name, alignt, words) \ - ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ - ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ - .align ALIGNARG(2); \ - C_LABEL(name) \ - CALL_MCOUNT \ - b 0f; \ - .align ALIGNARG(alignt); \ - EALIGN_W_##words; \ - 0: -#else /* PROF */ -#define EALIGN(name, alignt, words) \ - ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ - ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ - .align ALIGNARG(alignt); \ - EALIGN_W_##words; \ - C_LABEL(name) -#endif - -#define END(name) \ - ASM_SIZE_DIRECTIVE(name) - -#ifdef PIC -#define JUMPTARGET(name) name##@plt -#else -#define JUMPTARGET(name) name -#endif - -/* Local labels stripped out by the linker. */ -#define L(x) .L##x diff --git a/user/mpy/lib/libffi/src/powerpc/darwin.S b/user/mpy/lib/libffi/src/powerpc/darwin.S deleted file mode 100644 index 066eb82..0000000 --- a/user/mpy/lib/libffi/src/powerpc/darwin.S +++ /dev/null @@ -1,378 +0,0 @@ -/* ----------------------------------------------------------------------- - darwin.S - Copyright (c) 2000 John Hornkvist - Copyright (c) 2004, 2010 Free Software Foundation, Inc. - - PowerPC Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#if defined(__ppc64__) -#define MODE_CHOICE(x, y) y -#else -#define MODE_CHOICE(x, y) x -#endif - -#define machine_choice MODE_CHOICE(ppc7400,ppc64) - -; Define some pseudo-opcodes for size-independent load & store of GPRs ... -#define lgu MODE_CHOICE(lwzu, ldu) -#define lg MODE_CHOICE(lwz,ld) -#define sg MODE_CHOICE(stw,std) -#define sgu MODE_CHOICE(stwu,stdu) -#define sgux MODE_CHOICE(stwux,stdux) - -; ... and the size of GPRs and their storage indicator. -#define GPR_BYTES MODE_CHOICE(4,8) -#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ -#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ - -; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. -#define LINKAGE_SIZE MODE_CHOICE(24,48) -#define PARAM_AREA MODE_CHOICE(32,64) -#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ - -/* If there is any FP stuff we make space for all of the regs. */ -#define SAVED_FPR_COUNT 13 -#define FPR_SIZE 8 -#define RESULT_BYTES 16 - -/* This should be kept in step with the same value in ffi_darwin.c. */ -#define ASM_NEEDS_REGISTERS 4 -#define SAVE_REGS_SIZE (ASM_NEEDS_REGISTERS * GPR_BYTES) - -#include -#include - -#define JUMPTARGET(name) name -#define L(x) x - - .text - .align 2 - .globl _ffi_prep_args - - .align 2 - .globl _ffi_call_DARWIN - - /* We arrive here with: - r3 = ptr to extended cif. - r4 = -bytes. - r5 = cif flags. - r6 = ptr to return value. - r7 = fn pointer (user func). - r8 = fn pointer (ffi_prep_args). - r9 = ffi_type* for the ret val. */ - -_ffi_call_DARWIN: -Lstartcode: - mr r12,r8 /* We only need r12 until the call, - so it does not have to be saved. */ -LFB1: - /* Save the old stack pointer as AP. */ - mr r8,r1 -LCFI0: - - /* Save the retval type in parents frame. */ - sg r9,(LINKAGE_SIZE+6*GPR_BYTES)(r8) - - /* Allocate the stack space we need. */ - sgux r1,r1,r4 - - /* Save registers we use. */ - mflr r9 - sg r9,SAVED_LR_OFFSET(r8) - - sg r28,-(4 * GPR_BYTES)(r8) - sg r29,-(3 * GPR_BYTES)(r8) - sg r30,-(2 * GPR_BYTES)(r8) - sg r31,-( GPR_BYTES)(r8) - -#if !defined(POWERPC_DARWIN) - /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */ - sg r2,(5 * GPR_BYTES)(r1) -#endif - -LCFI1: - - /* Save arguments over call. */ - mr r31,r5 /* flags, */ - mr r30,r6 /* rvalue, */ - mr r29,r7 /* function address, */ - mr r28,r8 /* our AP. */ -LCFI2: - /* Call ffi_prep_args. r3 = extended cif, r4 = stack ptr copy. */ - mr r4,r1 - li r9,0 - - mtctr r12 /* r12 holds address of _ffi_prep_args. */ - bctrl - -#if !defined(POWERPC_DARWIN) - /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */ - lg r2,(5 * GPR_BYTES)(r1) -#endif - /* Now do the call. - Set up cr1 with bits 4-7 of the flags. */ - mtcrf 0x40,r31 - /* Get the address to call into CTR. */ - mtctr r29 - /* Load all those argument registers. - We have set up a nice stack frame, just load it into registers. */ - lg r3, (LINKAGE_SIZE )(r1) - lg r4, (LINKAGE_SIZE + GPR_BYTES)(r1) - lg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r1) - lg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r1) - nop - lg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r1) - lg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r1) - lg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r1) - lg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r1) - -L1: - /* ... Load all the FP registers. */ - bf 6,L2 /* No floats to load. */ - lfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28) - lfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28) - lfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28) - lfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28) - nop - lfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28) - lfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28) - lfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28) - lfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28) - nop - lfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28) - lfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28) - lfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28) - lfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28) - nop - lfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28) - -L2: - mr r12,r29 /* Put the target address in r12 as specified. */ - mtctr r12 - nop - nop - - /* Make the call. */ - bctrl - - /* Now, deal with the return value. */ - - /* m64 structure returns can occupy the same set of registers as - would be used to pass such a structure as arg0 - so take care - not to step on any possibly hot regs. */ - - /* Get the flags.. */ - mtcrf 0x03,r31 ; we need c6 & cr7 now. - ; FLAG_RETURNS_NOTHING also covers struct ret-by-ref. - bt 30,L(done_return_value) ; FLAG_RETURNS_NOTHING - bf 27,L(scalar_return_value) ; not FLAG_RETURNS_STRUCT - - /* OK, so we have a struct. */ -#if defined(__ppc64__) - bt 31,L(maybe_return_128) ; FLAG_RETURNS_128BITS, special case - - /* OK, we have to map the return back to a mem struct. - We are about to trample the parents param area, so recover the - return type. r29 is free, since the call is done. */ - lg r29,(LINKAGE_SIZE + 6 * GPR_BYTES)(r28) - - sg r3, (LINKAGE_SIZE )(r28) - sg r4, (LINKAGE_SIZE + GPR_BYTES)(r28) - sg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r28) - sg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r28) - nop - sg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r28) - sg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r28) - sg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r28) - sg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28) - /* OK, so do the block move - we trust that memcpy will not trample - the fprs... */ - mr r3,r30 ; dest - addi r4,r28,LINKAGE_SIZE ; source - /* The size is a size_t, should be long. */ - lg r5,0(r29) - /* Figure out small structs */ - cmpi 0,r5,4 - bgt L3 ; 1, 2 and 4 bytes have special rules. - cmpi 0,r5,3 - beq L3 ; not 3 - addi r4,r4,8 - subf r4,r5,r4 -L3: - bl _memcpy - - /* ... do we need the FP registers? - recover the flags.. */ - mtcrf 0x03,r31 ; we need c6 & cr7 now. - bf 29,L(done_return_value) /* No floats in the struct. */ - stfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28) - stfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28) - stfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28) - stfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28) - nop - stfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28) - stfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28) - stfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28) - stfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28) - nop - stfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28) - stfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28) - stfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28) - stfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28) - nop - stfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28) - - mr r3,r29 ; ffi_type * - mr r4,r30 ; dest - addi r5,r28,-SAVE_REGS_SIZE-(13*FPR_SIZE) ; fprs - xor r6,r6,r6 - sg r6,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28) - addi r6,r28,(LINKAGE_SIZE + 7 * GPR_BYTES) ; point to a zeroed counter. - bl _darwin64_struct_floats_to_mem - - b L(done_return_value) -#else - stw r3,0(r30) ; m32 the only struct return in reg is 4 bytes. -#endif - b L(done_return_value) - -L(fp_return_value): - /* Do we have long double to store? */ - bf 31,L(fd_return_value) ; FLAG_RETURNS_128BITS - stfd f1,0(r30) - stfd f2,FPR_SIZE(r30) - b L(done_return_value) - -L(fd_return_value): - /* Do we have double to store? */ - bf 28,L(float_return_value) - stfd f1,0(r30) - b L(done_return_value) - -L(float_return_value): - /* We only have a float to store. */ - stfs f1,0(r30) - b L(done_return_value) - -L(scalar_return_value): - bt 29,L(fp_return_value) ; FLAG_RETURNS_FP - ; ffi_arg is defined as unsigned long. - sg r3,0(r30) ; Save the reg. - bf 28,L(done_return_value) ; not FLAG_RETURNS_64BITS - -#if defined(__ppc64__) -L(maybe_return_128): - std r3,0(r30) - bf 31,L(done_return_value) ; not FLAG_RETURNS_128BITS - std r4,8(r30) -#else - stw r4,4(r30) -#endif - - /* Fall through. */ - /* We want this at the end to simplify eh epilog computation. */ - -L(done_return_value): - /* Restore the registers we used and return. */ - lg r29,SAVED_LR_OFFSET(r28) - ; epilog - lg r31,-(1 * GPR_BYTES)(r28) - mtlr r29 - lg r30,-(2 * GPR_BYTES)(r28) - lg r29,-(3 * GPR_BYTES)(r28) - lg r28,-(4 * GPR_BYTES)(r28) - lg r1,0(r1) - blr -LFE1: - .align 1 -/* END(_ffi_call_DARWIN) */ - -/* Provide a null definition of _ffi_call_AIX. */ - .text - .globl _ffi_call_AIX - .align 2 -_ffi_call_AIX: - blr -/* END(_ffi_call_AIX) */ - -/* EH stuff. */ - -#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) - - .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support -EH_frame1: - .set L$set$0,LECIE1-LSCIE1 - .long L$set$0 ; Length of Common Information Entry -LSCIE1: - .long 0x0 ; CIE Identifier Tag - .byte 0x1 ; CIE Version - .ascii "zR\0" ; CIE Augmentation - .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor - .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor - .byte 0x41 ; CIE RA Column - .byte 0x1 ; uleb128 0x1; Augmentation size - .byte 0x10 ; FDE Encoding (pcrel) - .byte 0xc ; DW_CFA_def_cfa - .byte 0x1 ; uleb128 0x1 - .byte 0x0 ; uleb128 0x0 - .align LOG2_GPR_BYTES -LECIE1: - - .globl _ffi_call_DARWIN.eh -_ffi_call_DARWIN.eh: -LSFDE1: - .set L$set$1,LEFDE1-LASFDE1 - .long L$set$1 ; FDE Length -LASFDE1: - .long LASFDE1-EH_frame1 ; FDE CIE offset - .g_long Lstartcode-. ; FDE initial location - .set L$set$3,LFE1-Lstartcode - .g_long L$set$3 ; FDE address range - .byte 0x0 ; uleb128 0x0; Augmentation size - .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$4,LCFI0-Lstartcode - .long L$set$4 - .byte 0xd ; DW_CFA_def_cfa_register - .byte 0x08 ; uleb128 0x08 - .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$5,LCFI1-LCFI0 - .long L$set$5 - .byte 0x11 ; DW_CFA_offset_extended_sf - .byte 0x41 ; uleb128 0x41 - .byte 0x7e ; sleb128 -2 - .byte 0x9f ; DW_CFA_offset, column 0x1f - .byte 0x1 ; uleb128 0x1 - .byte 0x9e ; DW_CFA_offset, column 0x1e - .byte 0x2 ; uleb128 0x2 - .byte 0x9d ; DW_CFA_offset, column 0x1d - .byte 0x3 ; uleb128 0x3 - .byte 0x9c ; DW_CFA_offset, column 0x1c - .byte 0x4 ; uleb128 0x4 - .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$6,LCFI2-LCFI1 - .long L$set$6 - .byte 0xd ; DW_CFA_def_cfa_register - .byte 0x1c ; uleb128 0x1c - .align LOG2_GPR_BYTES -LEFDE1: - .align 1 - diff --git a/user/mpy/lib/libffi/src/powerpc/darwin_closure.S b/user/mpy/lib/libffi/src/powerpc/darwin_closure.S deleted file mode 100644 index c7734d4..0000000 --- a/user/mpy/lib/libffi/src/powerpc/darwin_closure.S +++ /dev/null @@ -1,571 +0,0 @@ -/* ----------------------------------------------------------------------- - darwin_closure.S - Copyright (c) 2002, 2003, 2004, 2010, - Free Software Foundation, Inc. - based on ppc_closure.S - - PowerPC Assembly glue. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#define L(x) x - -#if defined(__ppc64__) -#define MODE_CHOICE(x, y) y -#else -#define MODE_CHOICE(x, y) x -#endif - -#define machine_choice MODE_CHOICE(ppc7400,ppc64) - -; Define some pseudo-opcodes for size-independent load & store of GPRs ... -#define lgu MODE_CHOICE(lwzu, ldu) -#define lg MODE_CHOICE(lwz,ld) -#define sg MODE_CHOICE(stw,std) -#define sgu MODE_CHOICE(stwu,stdu) - -; ... and the size of GPRs and their storage indicator. -#define GPR_BYTES MODE_CHOICE(4,8) -#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ -#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ - -; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. -#define LINKAGE_SIZE MODE_CHOICE(24,48) -#define PARAM_AREA MODE_CHOICE(32,64) - -#define SAVED_CR_OFFSET MODE_CHOICE(4,8) /* save position for CR */ -#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ - -/* WARNING: if ffi_type is changed... here be monsters. - Offsets of items within the result type. */ -#define FFI_TYPE_TYPE MODE_CHOICE(6,10) -#define FFI_TYPE_ELEM MODE_CHOICE(8,16) - -#define SAVED_FPR_COUNT 13 -#define FPR_SIZE 8 -/* biggest m64 struct ret is 8GPRS + 13FPRS = 168 bytes - rounded to 16bytes = 176. */ -#define RESULT_BYTES MODE_CHOICE(16,176) - -; The whole stack frame **MUST** be 16byte-aligned. -#define SAVE_SIZE (((LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)+15) & -16LL) -#define PAD_SIZE (SAVE_SIZE-(LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)) - -#define PARENT_PARM_BASE (SAVE_SIZE+LINKAGE_SIZE) -#define FP_SAVE_BASE (LINKAGE_SIZE+PARAM_AREA) - -#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 -; We no longer need the pic symbol stub for Darwin >= 9. -#define BLCLS_HELP _ffi_closure_helper_DARWIN -#define STRUCT_RETVALUE_P _darwin64_struct_ret_by_value_p -#define PASS_STR_FLOATS _darwin64_pass_struct_floats -#undef WANT_STUB -#else -#define BLCLS_HELP L_ffi_closure_helper_DARWIN$stub -#define STRUCT_RETVALUE_P L_darwin64_struct_ret_by_value_p$stub -#define PASS_STR_FLOATS L_darwin64_pass_struct_floats$stub -#define WANT_STUB -#endif - -/* m32/m64 - - The stack layout looks like this: - - | Additional params... | | Higher address - ~ ~ ~ - | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | - | Reserved 2*4/8 | | - |--------------------------------------------| | - | Space for callee`s LR 4/8 | | - |--------------------------------------------| | - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | - | Current backchain pointer 4/8 |-/ Parent`s frame. - |--------------------------------------------| <+ <<< on entry to - | Result Bytes 16/176 | | - |--------------------------------------------| | - ~ padding to 16-byte alignment ~ ~ - |--------------------------------------------| | - | NUM_FPR_ARG_REGISTERS slots | | - | here fp13 .. fp1 13*8 | | - |--------------------------------------------| | - | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | stack | - | Reserved [compiler,binder] 2*4/8 | | grows | - |--------------------------------------------| | down V - | Space for callees LR 4/8 | | - |--------------------------------------------| | lower addresses - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 4/8 |-/ during - |--------------------------------------------| <<< call. - -*/ - - .file "darwin_closure.S" - - .machine machine_choice - - .text - .globl _ffi_closure_ASM - .align LOG2_GPR_BYTES -_ffi_closure_ASM: -LFB1: -Lstartcode: - mflr r0 /* extract return address */ - sg r0,SAVED_LR_OFFSET(r1) /* save the return address */ -LCFI0: - sgu r1,-SAVE_SIZE(r1) /* skip over caller save area - keep stack aligned to 16. */ -LCFI1: - /* We want to build up an area for the parameters passed - in registers. (both floating point and integer) */ - - /* Put gpr 3 to gpr 10 in the parents outgoing area... - ... the remainder of any params that overflowed the regs will - follow here. */ - sg r3, (PARENT_PARM_BASE )(r1) - sg r4, (PARENT_PARM_BASE + GPR_BYTES )(r1) - sg r5, (PARENT_PARM_BASE + GPR_BYTES * 2)(r1) - sg r6, (PARENT_PARM_BASE + GPR_BYTES * 3)(r1) - sg r7, (PARENT_PARM_BASE + GPR_BYTES * 4)(r1) - sg r8, (PARENT_PARM_BASE + GPR_BYTES * 5)(r1) - sg r9, (PARENT_PARM_BASE + GPR_BYTES * 6)(r1) - sg r10,(PARENT_PARM_BASE + GPR_BYTES * 7)(r1) - - /* We save fpr 1 to fpr 14 in our own save frame. */ - stfd f1, (FP_SAVE_BASE )(r1) - stfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1) - stfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1) - stfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1) - stfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1) - stfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1) - stfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1) - stfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1) - stfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1) - stfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1) - stfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1) - stfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1) - stfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1) - - /* Set up registers for the routine that actually does the work - get the context pointer from the trampoline. */ - mr r3,r11 - - /* Now load up the pointer to the result storage. */ - addi r4,r1,(SAVE_SIZE-RESULT_BYTES) - - /* Now load up the pointer to the saved gpr registers. */ - addi r5,r1,PARENT_PARM_BASE - - /* Now load up the pointer to the saved fpr registers. */ - addi r6,r1,FP_SAVE_BASE - - /* Make the call. */ - bl BLCLS_HELP - - /* r3 contains the rtype pointer... save it since we will need - it later. */ - sg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type - lg r0,0(r3) ; size => r0 - lhz r3,FFI_TYPE_TYPE(r3) ; type => r3 - - /* The helper will have intercepted structure returns and inserted - the caller`s destination address for structs returned by ref. */ - - /* r3 contains the return type so use it to look up in a table - so we know how to deal with each type. */ - - addi r5,r1,(SAVE_SIZE-RESULT_BYTES) /* Otherwise, our return is here. */ - bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */ - mflr r4 /* Move to r4. */ - slwi r3,r3,4 /* Now multiply return type by 16. */ - add r3,r3,r4 /* Add contents of table to table address. */ - mtctr r3 - bctr /* Jump to it. */ -LFE1: -/* Each of the ret_typeX code fragments has to be exactly 16 bytes long - (4 instructions). For cache effectiveness we align to a 16 byte boundary - first. */ - - .align 4 - - nop - nop - nop -Lget_ret_type0_addr: - blrl - -/* case FFI_TYPE_VOID */ -Lret_type0: - b Lfinish - nop - nop - nop - -/* case FFI_TYPE_INT */ -Lret_type1: - lg r3,0(r5) - b Lfinish - nop - nop - -/* case FFI_TYPE_FLOAT */ -Lret_type2: - lfs f1,0(r5) - b Lfinish - nop - nop - -/* case FFI_TYPE_DOUBLE */ -Lret_type3: - lfd f1,0(r5) - b Lfinish - nop - nop - -/* case FFI_TYPE_LONGDOUBLE */ -Lret_type4: - lfd f1,0(r5) - lfd f2,8(r5) - b Lfinish - nop - -/* case FFI_TYPE_UINT8 */ -Lret_type5: -#if defined(__ppc64__) - lbz r3,7(r5) -#else - lbz r3,3(r5) -#endif - b Lfinish - nop - nop - -/* case FFI_TYPE_SINT8 */ -Lret_type6: -#if defined(__ppc64__) - lbz r3,7(r5) -#else - lbz r3,3(r5) -#endif - extsb r3,r3 - b Lfinish - nop - -/* case FFI_TYPE_UINT16 */ -Lret_type7: -#if defined(__ppc64__) - lhz r3,6(r5) -#else - lhz r3,2(r5) -#endif - b Lfinish - nop - nop - -/* case FFI_TYPE_SINT16 */ -Lret_type8: -#if defined(__ppc64__) - lha r3,6(r5) -#else - lha r3,2(r5) -#endif - b Lfinish - nop - nop - -/* case FFI_TYPE_UINT32 */ -Lret_type9: -#if defined(__ppc64__) - lwz r3,4(r5) -#else - lwz r3,0(r5) -#endif - b Lfinish - nop - nop - -/* case FFI_TYPE_SINT32 */ -Lret_type10: -#if defined(__ppc64__) - lwz r3,4(r5) -#else - lwz r3,0(r5) -#endif - b Lfinish - nop - nop - -/* case FFI_TYPE_UINT64 */ -Lret_type11: -#if defined(__ppc64__) - lg r3,0(r5) - b Lfinish - nop -#else - lwz r3,0(r5) - lwz r4,4(r5) - b Lfinish -#endif - nop - -/* case FFI_TYPE_SINT64 */ -Lret_type12: -#if defined(__ppc64__) - lg r3,0(r5) - b Lfinish - nop -#else - lwz r3,0(r5) - lwz r4,4(r5) - b Lfinish -#endif - nop - -/* case FFI_TYPE_STRUCT */ -Lret_type13: -#if defined(__ppc64__) - lg r3,0(r5) ; we need at least this... - cmpi 0,r0,4 - bgt Lstructend ; not a special small case - b Lsmallstruct ; see if we need more. -#else - cmpi 0,r0,4 - bgt Lfinish ; not by value - lg r3,0(r5) - b Lfinish -#endif -/* case FFI_TYPE_POINTER */ -Lret_type14: - lg r3,0(r5) - b Lfinish - nop - nop - -#if defined(__ppc64__) -Lsmallstruct: - beq Lfour ; continuation of Lret13. - cmpi 0,r0,3 - beq Lfinish ; don`t adjust this - can`t be any floats here... - srdi r3,r3,48 - cmpi 0,r0,2 - beq Lfinish ; .. or here .. - srdi r3,r3,8 - b Lfinish ; .. or here. - -Lfour: - lg r6,LINKAGE_SIZE(r1) ; get the result type - lg r6,FFI_TYPE_ELEM(r6) ; elements array pointer - lg r6,0(r6) ; first element - lhz r0,FFI_TYPE_TYPE(r6) ; OK go the type - cmpi 0,r0,2 ; FFI_TYPE_FLOAT - bne Lfourint - lfs f1,0(r5) ; just one float in the struct. - b Lfinish - -Lfourint: - srdi r3,r3,32 ; four bytes. - b Lfinish - -Lstructend: - lg r3,LINKAGE_SIZE(r1) ; get the result type - bl STRUCT_RETVALUE_P - cmpi 0,r3,0 - beq Lfinish ; nope. - /* Recover a pointer to the results. */ - addi r11,r1,(SAVE_SIZE-RESULT_BYTES) - lg r3,0(r11) ; we need at least this... - lg r4,8(r11) - cmpi 0,r0,16 - beq Lfinish ; special case 16 bytes we don't consider floats. - - /* OK, frustratingly, the process of saving the struct to mem might have - messed with the FPRs, so we have to re-load them :(. - We`ll use our FPRs space again - calling: - void darwin64_pass_struct_floats (ffi_type *s, char *src, - unsigned *nfpr, double **fprs) - We`ll temporarily pinch the first two slots of the param area for local - vars used by the routine. */ - xor r6,r6,r6 - addi r5,r1,PARENT_PARM_BASE ; some space - sg r6,0(r5) ; *nfpr zeroed. - addi r6,r5,8 ; **fprs - addi r3,r1,FP_SAVE_BASE ; pointer to FPRs space - sg r3,0(r6) - mr r4,r11 ; the struct is here... - lg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type. - bl PASS_STR_FLOATS ; get struct floats into FPR save space. - /* See if we used any floats */ - lwz r0,(SAVE_SIZE-RESULT_BYTES)(r1) - cmpi 0,r0,0 - beq Lstructints ; nope. - /* OK load `em up... */ - lfd f1, (FP_SAVE_BASE )(r1) - lfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1) - lfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1) - lfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1) - lfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1) - lfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1) - lfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1) - lfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1) - lfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1) - lfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1) - lfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1) - lfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1) - lfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1) - - /* point back at our saved struct. */ -Lstructints: - addi r11,r1,(SAVE_SIZE-RESULT_BYTES) - lg r3,0(r11) ; we end up picking the - lg r4,8(r11) ; first two again. - lg r5,16(r11) - lg r6,24(r11) - lg r7,32(r11) - lg r8,40(r11) - lg r9,48(r11) - lg r10,56(r11) -#endif - -/* case done */ -Lfinish: - addi r1,r1,SAVE_SIZE /* Restore stack pointer. */ - lg r0,SAVED_LR_OFFSET(r1) /* Get return address. */ - mtlr r0 /* Reset link register. */ - blr -Lendcode: - .align 1 - -/* END(ffi_closure_ASM) */ - -/* EH frame stuff. */ -#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) -/* 176, 400 */ -#define EH_FRAME_OFFSETA MODE_CHOICE(176,0x90) -#define EH_FRAME_OFFSETB MODE_CHOICE(1,3) - - .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support -EH_frame1: - .set L$set$0,LECIE1-LSCIE1 - .long L$set$0 ; Length of Common Information Entry -LSCIE1: - .long 0x0 ; CIE Identifier Tag - .byte 0x1 ; CIE Version - .ascii "zR\0" ; CIE Augmentation - .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor - .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor - .byte 0x41 ; CIE RA Column - .byte 0x1 ; uleb128 0x1; Augmentation size - .byte 0x10 ; FDE Encoding (pcrel) - .byte 0xc ; DW_CFA_def_cfa - .byte 0x1 ; uleb128 0x1 - .byte 0x0 ; uleb128 0x0 - .align LOG2_GPR_BYTES -LECIE1: - .globl _ffi_closure_ASM.eh -_ffi_closure_ASM.eh: -LSFDE1: - .set L$set$1,LEFDE1-LASFDE1 - .long L$set$1 ; FDE Length - -LASFDE1: - .long LASFDE1-EH_frame1 ; FDE CIE offset - .g_long Lstartcode-. ; FDE initial location - .set L$set$3,LFE1-Lstartcode - .g_long L$set$3 ; FDE address range - .byte 0x0 ; uleb128 0x0; Augmentation size - .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$3,LCFI1-LCFI0 - .long L$set$3 - .byte 0xe ; DW_CFA_def_cfa_offset - .byte EH_FRAME_OFFSETA,EH_FRAME_OFFSETB ; uleb128 176,1/190,3 - .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$4,LCFI0-Lstartcode - .long L$set$4 - .byte 0x11 ; DW_CFA_offset_extended_sf - .byte 0x41 ; uleb128 0x41 - .byte 0x7e ; sleb128 -2 - .align LOG2_GPR_BYTES -LEFDE1: - .align 1 - -#ifdef WANT_STUB - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 5 -L_ffi_closure_helper_DARWIN$stub: - .indirect_symbol _ffi_closure_helper_DARWIN - mflr r0 - bcl 20,31,"L1$spb" -"L1$spb": - mflr r11 - addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb") - mtlr r0 - lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb")(r11) - mtctr r12 - bctr - .lazy_symbol_pointer -L_ffi_closure_helper_DARWIN$lazy_ptr: - .indirect_symbol _ffi_closure_helper_DARWIN - .g_long dyld_stub_binding_helper - -#if defined(__ppc64__) - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 5 -L_darwin64_struct_ret_by_value_p$stub: - .indirect_symbol _darwin64_struct_ret_by_value_p - mflr r0 - bcl 20,31,"L2$spb" -"L2$spb": - mflr r11 - addis r11,r11,ha16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb") - mtlr r0 - lwzu r12,lo16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb")(r11) - mtctr r12 - bctr - .lazy_symbol_pointer -L_darwin64_struct_ret_by_value_p$lazy_ptr: - .indirect_symbol _darwin64_struct_ret_by_value_p - .g_long dyld_stub_binding_helper - - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 5 -L_darwin64_pass_struct_floats$stub: - .indirect_symbol _darwin64_pass_struct_floats - mflr r0 - bcl 20,31,"L3$spb" -"L3$spb": - mflr r11 - addis r11,r11,ha16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb") - mtlr r0 - lwzu r12,lo16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb")(r11) - mtctr r12 - bctr - .lazy_symbol_pointer -L_darwin64_pass_struct_floats$lazy_ptr: - .indirect_symbol _darwin64_pass_struct_floats - .g_long dyld_stub_binding_helper -# endif -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ffi.c b/user/mpy/lib/libffi/src/powerpc/ffi.c deleted file mode 100644 index 7eb543e..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ffi.c +++ /dev/null @@ -1,173 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2013 IBM - Copyright (C) 2011 Anthony Green - Copyright (C) 2011 Kyle Moffett - Copyright (C) 2008 Red Hat, Inc - Copyright (C) 2007, 2008 Free Software Foundation, Inc - Copyright (c) 1998 Geoffrey Keating - - PowerPC Foreign Function Interface - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#include "ffi.h" -#include "ffi_common.h" -#include "ffi_powerpc.h" - -#if HAVE_LONG_DOUBLE_VARIANT -/* Adjust ffi_type_longdouble. */ -void FFI_HIDDEN -ffi_prep_types (ffi_abi abi) -{ -# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -# ifdef POWERPC64 - ffi_prep_types_linux64 (abi); -# else - ffi_prep_types_sysv (abi); -# endif -# endif -} -#endif - -/* Perform machine dependent cif processing */ -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep (ffi_cif *cif) -{ -#ifdef POWERPC64 - return ffi_prep_cif_linux64 (cif); -#else - return ffi_prep_cif_sysv (cif); -#endif -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep_var (ffi_cif *cif, - unsigned int nfixedargs MAYBE_UNUSED, - unsigned int ntotalargs MAYBE_UNUSED) -{ -#ifdef POWERPC64 - return ffi_prep_cif_linux64_var (cif, nfixedargs, ntotalargs); -#else - return ffi_prep_cif_sysv (cif); -#endif -} - -static void -ffi_call_int (ffi_cif *cif, - void (*fn) (void), - void *rvalue, - void **avalue, - void *closure) -{ - /* The final SYSV ABI says that structures smaller or equal 8 bytes - are returned in r3/r4. A draft ABI used by linux instead returns - them in memory. - - We bounce-buffer SYSV small struct return values so that sysv.S - can write r3 and r4 to memory without worrying about struct size. - - For ELFv2 ABI, use a bounce buffer for homogeneous structs too, - for similar reasons. */ - unsigned long smst_buffer[8]; - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - ecif.rvalue = rvalue; - if ((cif->flags & FLAG_RETURNS_SMST) != 0) - ecif.rvalue = smst_buffer; - /* Ensure that we have a valid struct return value. - FIXME: Isn't this just papering over a user problem? */ - else if (!rvalue && cif->rtype->type == FFI_TYPE_STRUCT) - ecif.rvalue = alloca (cif->rtype->size); - -#ifdef POWERPC64 - ffi_call_LINUX64 (&ecif, fn, ecif.rvalue, cif->flags, closure, - -(long) cif->bytes); -#else - ffi_call_SYSV (&ecif, fn, ecif.rvalue, cif->flags, closure, -cif->bytes); -#endif - - /* Check for a bounce-buffered return value */ - if (rvalue && ecif.rvalue == smst_buffer) - { - unsigned int rsize = cif->rtype->size; -#ifndef __LITTLE_ENDIAN__ - /* The SYSV ABI returns a structure of up to 4 bytes in size - left-padded in r3. */ -# ifndef POWERPC64 - if (rsize <= 4) - memcpy (rvalue, (char *) smst_buffer + 4 - rsize, rsize); - else -# endif - /* The SYSV ABI returns a structure of up to 8 bytes in size - left-padded in r3/r4, and the ELFv2 ABI similarly returns a - structure of up to 8 bytes in size left-padded in r3. */ - if (rsize <= 8) - memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize); - else -#endif - memcpy (rvalue, smst_buffer, rsize); - } -} - -void -ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue, - void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - void *codeloc) -{ -#ifdef POWERPC64 - return ffi_prep_closure_loc_linux64 (closure, cif, fun, user_data, codeloc); -#else - return ffi_prep_closure_loc_sysv (closure, cif, fun, user_data, codeloc); -#endif -} - -ffi_status -ffi_prep_go_closure (ffi_go_closure *closure, - ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *)) -{ -#ifdef POWERPC64 - closure->tramp = ffi_go_closure_linux64; -#else - closure->tramp = ffi_go_closure_sysv; -#endif - closure->cif = cif; - closure->fun = fun; - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_darwin.c b/user/mpy/lib/libffi/src/powerpc/ffi_darwin.c deleted file mode 100644 index cf6fb6d..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ffi_darwin.c +++ /dev/null @@ -1,1359 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi_darwin.c - - Copyright (C) 1998 Geoffrey Keating - Copyright (C) 2001 John Hornkvist - Copyright (C) 2002, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. - - FFI support for Darwin and AIX. - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -extern void ffi_closure_ASM (void); - -enum { - /* The assembly depends on these exact flags. - For Darwin64 (when FLAG_RETURNS_STRUCT is set): - FLAG_RETURNS_FP indicates that the structure embeds FP data. - FLAG_RETURNS_128BITS signals a special struct size that is not - expanded for float content. */ - FLAG_RETURNS_128BITS = 1 << (31-31), /* These go in cr7 */ - FLAG_RETURNS_NOTHING = 1 << (31-30), - FLAG_RETURNS_FP = 1 << (31-29), - FLAG_RETURNS_64BITS = 1 << (31-28), - - FLAG_RETURNS_STRUCT = 1 << (31-27), /* This goes in cr6 */ - - FLAG_ARG_NEEDS_COPY = 1 << (31- 7), - FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ - FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), - FLAG_RETVAL_REFERENCE = 1 << (31- 4) -}; - -/* About the DARWIN ABI. */ -enum { - NUM_GPR_ARG_REGISTERS = 8, - NUM_FPR_ARG_REGISTERS = 13, - LINKAGE_AREA_GPRS = 6 -}; - -enum { ASM_NEEDS_REGISTERS = 4 }; /* r28-r31 */ - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments. - - m32/m64 - - The stack layout we want looks like this: - - | Return address from ffi_call_DARWIN | higher addresses - |--------------------------------------------| - | Previous backchain pointer 4/8 | stack pointer here - |--------------------------------------------|<+ <<< on entry to - | ASM_NEEDS_REGISTERS=r28-r31 4*(4/8) | | ffi_call_DARWIN - |--------------------------------------------| | - | When we have any FP activity... the | | - | FPRs occupy NUM_FPR_ARG_REGISTERS slots | | - | here fp13 .. fp1 from high to low addr. | | - ~ ~ ~ - | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | stack | - | Reserved 2*4/8 | | grows | - |--------------------------------------------| | down V - | Space for callee's LR 4/8 | | - |--------------------------------------------| | lower addresses - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 4/8 |-/ during - |--------------------------------------------| <<< ffi_call_DARWIN - - */ - -#if defined(POWERPC_DARWIN64) -static void -darwin64_pass_struct_by_value - (ffi_type *, char *, unsigned, unsigned *, double **, unsigned long **); -#endif - -/* This depends on GPR_SIZE = sizeof (unsigned long) */ - -void -ffi_prep_args (extended_cif *ecif, unsigned long *const stack) -{ - const unsigned bytes = ecif->cif->bytes; - const unsigned flags = ecif->cif->flags; - const unsigned nargs = ecif->cif->nargs; -#if !defined(POWERPC_DARWIN64) - const ffi_abi abi = ecif->cif->abi; -#endif - - /* 'stacktop' points at the previous backchain pointer. */ - unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long)); - - /* 'fpr_base' points at the space for fpr1, and grows upwards as - we use FPR registers. */ - double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS; - int gp_count = 0, fparg_count = 0; - - /* 'next_arg' grows up as we put parameters in it. */ - unsigned long *next_arg = stack + LINKAGE_AREA_GPRS; /* 6 reserved positions. */ - - int i; - double double_tmp; - void **p_argv = ecif->avalue; - unsigned long gprvalue; - ffi_type** ptr = ecif->cif->arg_types; -#if !defined(POWERPC_DARWIN64) - char *dest_cpy; -#endif - unsigned size_al = 0; - - /* Check that everything starts aligned properly. */ - FFI_ASSERT(((unsigned) (char *) stack & 0xF) == 0); - FFI_ASSERT(((unsigned) (char *) stacktop & 0xF) == 0); - FFI_ASSERT((bytes & 0xF) == 0); - - /* Deal with return values that are actually pass-by-reference. - Rule: - Return values are referenced by r3, so r4 is the first parameter. */ - - if (flags & FLAG_RETVAL_REFERENCE) - *next_arg++ = (unsigned long) (char *) ecif->rvalue; - - /* Now for the arguments. */ - for (i = nargs; i > 0; i--, ptr++, p_argv++) - { - switch ((*ptr)->type) - { - /* If a floating-point parameter appears before all of the general- - purpose registers are filled, the corresponding GPRs that match - the size of the floating-point parameter are skipped. */ - case FFI_TYPE_FLOAT: - double_tmp = *(float *) *p_argv; - if (fparg_count < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = double_tmp; -#if defined(POWERPC_DARWIN) - *(float *)next_arg = *(float *) *p_argv; -#else - *(double *)next_arg = double_tmp; -#endif - next_arg++; - gp_count++; - fparg_count++; - FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); - break; - - case FFI_TYPE_DOUBLE: - double_tmp = *(double *) *p_argv; - if (fparg_count < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = double_tmp; - *(double *)next_arg = double_tmp; -#ifdef POWERPC64 - next_arg++; - gp_count++; -#else - next_arg += 2; - gp_count += 2; -#endif - fparg_count++; - FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); - break; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - - case FFI_TYPE_LONGDOUBLE: -# if defined(POWERPC64) && !defined(POWERPC_DARWIN64) - /* ??? This will exceed the regs count when the value starts at fp13 - and it will not put the extra bit on the stack. */ - if (fparg_count < NUM_FPR_ARG_REGISTERS) - *(long double *) fpr_base++ = *(long double *) *p_argv; - else - *(long double *) next_arg = *(long double *) *p_argv; - next_arg += 2; - fparg_count += 2; -# else - double_tmp = ((double *) *p_argv)[0]; - if (fparg_count < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = double_tmp; - *(double *) next_arg = double_tmp; -# if defined(POWERPC_DARWIN64) - next_arg++; - gp_count++; -# else - next_arg += 2; - gp_count += 2; -# endif - fparg_count++; - double_tmp = ((double *) *p_argv)[1]; - if (fparg_count < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = double_tmp; - *(double *) next_arg = double_tmp; -# if defined(POWERPC_DARWIN64) - next_arg++; - gp_count++; -# else - next_arg += 2; - gp_count += 2; -# endif - fparg_count++; -# endif - FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); - break; -#endif - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: -#ifdef POWERPC64 - gprvalue = *(long long *) *p_argv; - goto putgpr; -#else - *(long long *) next_arg = *(long long *) *p_argv; - next_arg += 2; - gp_count += 2; -#endif - break; - case FFI_TYPE_POINTER: - gprvalue = *(unsigned long *) *p_argv; - goto putgpr; - case FFI_TYPE_UINT8: - gprvalue = *(unsigned char *) *p_argv; - goto putgpr; - case FFI_TYPE_SINT8: - gprvalue = *(signed char *) *p_argv; - goto putgpr; - case FFI_TYPE_UINT16: - gprvalue = *(unsigned short *) *p_argv; - goto putgpr; - case FFI_TYPE_SINT16: - gprvalue = *(signed short *) *p_argv; - goto putgpr; - - case FFI_TYPE_STRUCT: - size_al = (*ptr)->size; -#if defined(POWERPC_DARWIN64) - next_arg = (unsigned long *)ALIGN((char *)next_arg, (*ptr)->alignment); - darwin64_pass_struct_by_value (*ptr, (char *) *p_argv, - (unsigned) size_al, - (unsigned int *) &fparg_count, - &fpr_base, &next_arg); -#else - dest_cpy = (char *) next_arg; - - /* If the first member of the struct is a double, then include enough - padding in the struct size to align it to double-word. */ - if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) - size_al = ALIGN((*ptr)->size, 8); - -# if defined(POWERPC64) - FFI_ASSERT (abi != FFI_DARWIN); - memcpy ((char *) dest_cpy, (char *) *p_argv, size_al); - next_arg += (size_al + 7) / 8; -# else - /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, - SI 4 bytes) are aligned as if they were those modes. - Structures with 3 byte in size are padded upwards. */ - if (size_al < 3 && abi == FFI_DARWIN) - dest_cpy += 4 - size_al; - - memcpy((char *) dest_cpy, (char *) *p_argv, size_al); - next_arg += (size_al + 3) / 4; -# endif -#endif - break; - - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - gprvalue = *(signed int *) *p_argv; - goto putgpr; - - case FFI_TYPE_UINT32: - gprvalue = *(unsigned int *) *p_argv; - putgpr: - *next_arg++ = gprvalue; - gp_count++; - break; - default: - break; - } - } - - /* Check that we didn't overrun the stack... */ - /* FFI_ASSERT(gpr_base <= stacktop - ASM_NEEDS_REGISTERS); - FFI_ASSERT((unsigned *)fpr_base - <= stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); - FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); */ -} - -#if defined(POWERPC_DARWIN64) - -/* See if we can put some of the struct into fprs. - This should not be called for structures of size 16 bytes, since these are not - broken out this way. */ -static void -darwin64_scan_struct_for_floats (ffi_type *s, unsigned *nfpr) -{ - int i; - - FFI_ASSERT (s->type == FFI_TYPE_STRUCT) - - for (i = 0; s->elements[i] != NULL; i++) - { - ffi_type *p = s->elements[i]; - switch (p->type) - { - case FFI_TYPE_STRUCT: - darwin64_scan_struct_for_floats (p, nfpr); - break; - case FFI_TYPE_LONGDOUBLE: - (*nfpr) += 2; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_FLOAT: - (*nfpr) += 1; - break; - default: - break; - } - } -} - -static int -darwin64_struct_size_exceeds_gprs_p (ffi_type *s, char *src, unsigned *nfpr) -{ - unsigned struct_offset=0, i; - - for (i = 0; s->elements[i] != NULL; i++) - { - char *item_base; - ffi_type *p = s->elements[i]; - /* Find the start of this item (0 for the first one). */ - if (i > 0) - struct_offset = ALIGN(struct_offset, p->alignment); - - item_base = src + struct_offset; - - switch (p->type) - { - case FFI_TYPE_STRUCT: - if (darwin64_struct_size_exceeds_gprs_p (p, item_base, nfpr)) - return 1; - break; - case FFI_TYPE_LONGDOUBLE: - if (*nfpr >= NUM_FPR_ARG_REGISTERS) - return 1; - (*nfpr) += 1; - item_base += 8; - /* FALL THROUGH */ - case FFI_TYPE_DOUBLE: - if (*nfpr >= NUM_FPR_ARG_REGISTERS) - return 1; - (*nfpr) += 1; - break; - case FFI_TYPE_FLOAT: - if (*nfpr >= NUM_FPR_ARG_REGISTERS) - return 1; - (*nfpr) += 1; - break; - default: - /* If we try and place any item, that is non-float, once we've - exceeded the 8 GPR mark, then we can't fit the struct. */ - if ((unsigned long)item_base >= 8*8) - return 1; - break; - } - /* now count the size of what we just used. */ - struct_offset += p->size; - } - return 0; -} - -/* Can this struct be returned by value? */ -int -darwin64_struct_ret_by_value_p (ffi_type *s) -{ - unsigned nfp = 0; - - FFI_ASSERT (s && s->type == FFI_TYPE_STRUCT); - - /* The largest structure we can return is 8long + 13 doubles. */ - if (s->size > 168) - return 0; - - /* We can't pass more than 13 floats. */ - darwin64_scan_struct_for_floats (s, &nfp); - if (nfp > 13) - return 0; - - /* If there are not too many floats, and the struct is - small enough to accommodate in the GPRs, then it must be OK. */ - if (s->size <= 64) - return 1; - - /* Well, we have to look harder. */ - nfp = 0; - if (darwin64_struct_size_exceeds_gprs_p (s, NULL, &nfp)) - return 0; - - return 1; -} - -void -darwin64_pass_struct_floats (ffi_type *s, char *src, - unsigned *nfpr, double **fprs) -{ - int i; - double *fpr_base = *fprs; - unsigned struct_offset = 0; - - /* We don't assume anything about the alignment of the source. */ - for (i = 0; s->elements[i] != NULL; i++) - { - char *item_base; - ffi_type *p = s->elements[i]; - /* Find the start of this item (0 for the first one). */ - if (i > 0) - struct_offset = ALIGN(struct_offset, p->alignment); - item_base = src + struct_offset; - - switch (p->type) - { - case FFI_TYPE_STRUCT: - darwin64_pass_struct_floats (p, item_base, nfpr, - &fpr_base); - break; - case FFI_TYPE_LONGDOUBLE: - if (*nfpr < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = *(double *)item_base; - (*nfpr) += 1; - item_base += 8; - /* FALL THROUGH */ - case FFI_TYPE_DOUBLE: - if (*nfpr < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = *(double *)item_base; - (*nfpr) += 1; - break; - case FFI_TYPE_FLOAT: - if (*nfpr < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = (double) *(float *)item_base; - (*nfpr) += 1; - break; - default: - break; - } - /* now count the size of what we just used. */ - struct_offset += p->size; - } - /* Update the scores. */ - *fprs = fpr_base; -} - -/* Darwin64 special rules. - Break out a struct into params and float registers. */ -static void -darwin64_pass_struct_by_value (ffi_type *s, char *src, unsigned size, - unsigned *nfpr, double **fprs, unsigned long **arg) -{ - unsigned long *next_arg = *arg; - char *dest_cpy = (char *)next_arg; - - FFI_ASSERT (s->type == FFI_TYPE_STRUCT) - - if (!size) - return; - - /* First... special cases. */ - if (size < 3 - || (size == 4 - && s->elements[0] - && s->elements[0]->type != FFI_TYPE_FLOAT)) - { - /* Must be at least one GPR, padding is unspecified in value, - let's make it zero. */ - *next_arg = 0UL; - dest_cpy += 8 - size; - memcpy ((char *) dest_cpy, src, size); - next_arg++; - } - else if (size == 16) - { - memcpy ((char *) dest_cpy, src, size); - next_arg += 2; - } - else - { - /* now the general case, we consider embedded floats. */ - memcpy ((char *) dest_cpy, src, size); - darwin64_pass_struct_floats (s, src, nfpr, fprs); - next_arg += (size+7)/8; - } - - *arg = next_arg; -} - -double * -darwin64_struct_floats_to_mem (ffi_type *s, char *dest, double *fprs, unsigned *nf) -{ - int i; - unsigned struct_offset = 0; - - /* We don't assume anything about the alignment of the source. */ - for (i = 0; s->elements[i] != NULL; i++) - { - char *item_base; - ffi_type *p = s->elements[i]; - /* Find the start of this item (0 for the first one). */ - if (i > 0) - struct_offset = ALIGN(struct_offset, p->alignment); - item_base = dest + struct_offset; - - switch (p->type) - { - case FFI_TYPE_STRUCT: - fprs = darwin64_struct_floats_to_mem (p, item_base, fprs, nf); - break; - case FFI_TYPE_LONGDOUBLE: - if (*nf < NUM_FPR_ARG_REGISTERS) - { - *(double *)item_base = *fprs++ ; - (*nf) += 1; - } - item_base += 8; - /* FALL THROUGH */ - case FFI_TYPE_DOUBLE: - if (*nf < NUM_FPR_ARG_REGISTERS) - { - *(double *)item_base = *fprs++ ; - (*nf) += 1; - } - break; - case FFI_TYPE_FLOAT: - if (*nf < NUM_FPR_ARG_REGISTERS) - { - *(float *)item_base = (float) *fprs++ ; - (*nf) += 1; - } - break; - default: - break; - } - /* now count the size of what we just used. */ - struct_offset += p->size; - } - return fprs; -} - -#endif - -/* Adjust the size of S to be correct for Darwin. - On Darwin m32, the first field of a structure has natural alignment. - On Darwin m64, all fields have natural alignment. */ - -static void -darwin_adjust_aggregate_sizes (ffi_type *s) -{ - int i; - - if (s->type != FFI_TYPE_STRUCT) - return; - - s->size = 0; - for (i = 0; s->elements[i] != NULL; i++) - { - ffi_type *p; - int align; - - p = s->elements[i]; - if (p->type == FFI_TYPE_STRUCT) - darwin_adjust_aggregate_sizes (p); -#if defined(POWERPC_DARWIN64) - /* Natural alignment for all items. */ - align = p->alignment; -#else - /* Natural alignment for the first item... */ - if (i == 0) - align = p->alignment; - else if (p->alignment == 16 || p->alignment < 4) - /* .. subsequent items with vector or align < 4 have natural align. */ - align = p->alignment; - else - /* .. or align is 4. */ - align = 4; -#endif - /* Pad, if necessary, before adding the current item. */ - s->size = ALIGN(s->size, align) + p->size; - } - - s->size = ALIGN(s->size, s->alignment); - - /* This should not be necessary on m64, but harmless. */ - if (s->elements[0]->type == FFI_TYPE_UINT64 - || s->elements[0]->type == FFI_TYPE_SINT64 - || s->elements[0]->type == FFI_TYPE_DOUBLE - || s->elements[0]->alignment == 8) - s->alignment = s->alignment > 8 ? s->alignment : 8; - /* Do not add additional tail padding. */ -} - -/* Adjust the size of S to be correct for AIX. - Word-align double unless it is the first member of a structure. */ - -static void -aix_adjust_aggregate_sizes (ffi_type *s) -{ - int i; - - if (s->type != FFI_TYPE_STRUCT) - return; - - s->size = 0; - for (i = 0; s->elements[i] != NULL; i++) - { - ffi_type *p; - int align; - - p = s->elements[i]; - aix_adjust_aggregate_sizes (p); - align = p->alignment; - if (i != 0 && p->type == FFI_TYPE_DOUBLE) - align = 4; - s->size = ALIGN(s->size, align) + p->size; - } - - s->size = ALIGN(s->size, s->alignment); - - if (s->elements[0]->type == FFI_TYPE_UINT64 - || s->elements[0]->type == FFI_TYPE_SINT64 - || s->elements[0]->type == FFI_TYPE_DOUBLE - || s->elements[0]->alignment == 8) - s->alignment = s->alignment > 8 ? s->alignment : 8; - /* Do not add additional tail padding. */ -} - -/* Perform machine dependent cif processing. */ -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - /* All this is for the DARWIN ABI. */ - unsigned i; - ffi_type **ptr; - unsigned bytes; - unsigned fparg_count = 0, intarg_count = 0; - unsigned flags = 0; - unsigned size_al = 0; - - /* All the machine-independent calculation of cif->bytes will be wrong. - All the calculation of structure sizes will also be wrong. - Redo the calculation for DARWIN. */ - - if (cif->abi == FFI_DARWIN) - { - darwin_adjust_aggregate_sizes (cif->rtype); - for (i = 0; i < cif->nargs; i++) - darwin_adjust_aggregate_sizes (cif->arg_types[i]); - } - - if (cif->abi == FFI_AIX) - { - aix_adjust_aggregate_sizes (cif->rtype); - for (i = 0; i < cif->nargs; i++) - aix_adjust_aggregate_sizes (cif->arg_types[i]); - } - - /* Space for the frame pointer, callee's LR, CR, etc, and for - the asm's temp regs. */ - - bytes = (LINKAGE_AREA_GPRS + ASM_NEEDS_REGISTERS) * sizeof(unsigned long); - - /* Return value handling. - The rules m32 are as follows: - - 32-bit (or less) integer values are returned in gpr3; - - structures of size <= 4 bytes also returned in gpr3; - - 64-bit integer values [??? and structures between 5 and 8 bytes] are - returned in gpr3 and gpr4; - - Single/double FP values are returned in fpr1; - - Long double FP (if not equivalent to double) values are returned in - fpr1 and fpr2; - m64: - - 64-bit or smaller integral values are returned in GPR3 - - Single/double FP values are returned in fpr1; - - Long double FP values are returned in fpr1 and fpr2; - m64 Structures: - - If the structure could be accommodated in registers were it to be the - first argument to a routine, then it is returned in those registers. - m32/m64 structures otherwise: - - Larger structures values are allocated space and a pointer is passed - as the first argument. */ - switch (cif->rtype->type) - { - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - flags |= FLAG_RETURNS_128BITS; - flags |= FLAG_RETURNS_FP; - break; -#endif - - case FFI_TYPE_DOUBLE: - flags |= FLAG_RETURNS_64BITS; - /* Fall through. */ - case FFI_TYPE_FLOAT: - flags |= FLAG_RETURNS_FP; - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: -#ifdef POWERPC64 - case FFI_TYPE_POINTER: -#endif - flags |= FLAG_RETURNS_64BITS; - break; - - case FFI_TYPE_STRUCT: -#if defined(POWERPC_DARWIN64) - { - /* Can we fit the struct into regs? */ - if (darwin64_struct_ret_by_value_p (cif->rtype)) - { - unsigned nfpr = 0; - flags |= FLAG_RETURNS_STRUCT; - if (cif->rtype->size != 16) - darwin64_scan_struct_for_floats (cif->rtype, &nfpr) ; - else - flags |= FLAG_RETURNS_128BITS; - /* Will be 0 for 16byte struct. */ - if (nfpr) - flags |= FLAG_RETURNS_FP; - } - else /* By ref. */ - { - flags |= FLAG_RETVAL_REFERENCE; - flags |= FLAG_RETURNS_NOTHING; - intarg_count++; - } - } -#elif defined(DARWIN_PPC) - if (cif->rtype->size <= 4) - flags |= FLAG_RETURNS_STRUCT; - else /* else by reference. */ - { - flags |= FLAG_RETVAL_REFERENCE; - flags |= FLAG_RETURNS_NOTHING; - intarg_count++; - } -#else /* assume we pass by ref. */ - flags |= FLAG_RETVAL_REFERENCE; - flags |= FLAG_RETURNS_NOTHING; - intarg_count++; -#endif - break; - case FFI_TYPE_VOID: - flags |= FLAG_RETURNS_NOTHING; - break; - - default: - /* Returns 32-bit integer, or similar. Nothing to do here. */ - break; - } - - /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the - first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest - goes on the stack. - ??? Structures are passed as a pointer to a copy of the structure. - Stuff on the stack needs to keep proper alignment. - For m64 the count is effectively of half-GPRs. */ - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) - { - unsigned align_words; - switch ((*ptr)->type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - fparg_count++; -#if !defined(POWERPC_DARWIN64) - /* If this FP arg is going on the stack, it must be - 8-byte-aligned. */ - if (fparg_count > NUM_FPR_ARG_REGISTERS - && (intarg_count & 0x01) != 0) - intarg_count++; -#endif - break; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - fparg_count += 2; - /* If this FP arg is going on the stack, it must be - 16-byte-aligned. */ - if (fparg_count >= NUM_FPR_ARG_REGISTERS) -#if defined (POWERPC64) - intarg_count = ALIGN(intarg_count, 2); -#else - intarg_count = ALIGN(intarg_count, 4); -#endif - break; -#endif - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: -#if defined(POWERPC64) - intarg_count++; -#else - /* 'long long' arguments are passed as two words, but - either both words must fit in registers or both go - on the stack. If they go on the stack, they must - be 8-byte-aligned. */ - if (intarg_count == NUM_GPR_ARG_REGISTERS-1 - || (intarg_count >= NUM_GPR_ARG_REGISTERS - && (intarg_count & 0x01) != 0)) - intarg_count++; - intarg_count += 2; -#endif - break; - - case FFI_TYPE_STRUCT: - size_al = (*ptr)->size; -#if defined(POWERPC_DARWIN64) - align_words = (*ptr)->alignment >> 3; - if (align_words) - intarg_count = ALIGN(intarg_count, align_words); - /* Base size of the struct. */ - intarg_count += (size_al + 7) / 8; - /* If 16 bytes then don't worry about floats. */ - if (size_al != 16) - /* Scan through for floats to be placed in regs. */ - darwin64_scan_struct_for_floats (*ptr, &fparg_count) ; -#else - align_words = (*ptr)->alignment >> 2; - if (align_words) - intarg_count = ALIGN(intarg_count, align_words); - /* If the first member of the struct is a double, then align - the struct to double-word. - if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) - size_al = ALIGN((*ptr)->size, 8); */ -# ifdef POWERPC64 - intarg_count += (size_al + 7) / 8; -# else - intarg_count += (size_al + 3) / 4; -# endif -#endif - break; - - default: - /* Everything else is passed as a 4-byte word in a GPR, either - the object itself or a pointer to it. */ - intarg_count++; - break; - } - } - - if (fparg_count != 0) - flags |= FLAG_FP_ARGUMENTS; - -#if defined(POWERPC_DARWIN64) - /* Space to image the FPR registers, if needed - which includes when they might be - used in a struct return. */ - if (fparg_count != 0 - || ((flags & FLAG_RETURNS_STRUCT) - && (flags & FLAG_RETURNS_FP))) - bytes += NUM_FPR_ARG_REGISTERS * sizeof(double); -#else - /* Space for the FPR registers, if needed. */ - if (fparg_count != 0) - bytes += NUM_FPR_ARG_REGISTERS * sizeof(double); -#endif - - /* Stack space. */ -#ifdef POWERPC64 - if ((intarg_count + fparg_count) > NUM_GPR_ARG_REGISTERS) - bytes += (intarg_count + fparg_count) * sizeof(long); -#else - if ((intarg_count + 2 * fparg_count) > NUM_GPR_ARG_REGISTERS) - bytes += (intarg_count + 2 * fparg_count) * sizeof(long); -#endif - else - bytes += NUM_GPR_ARG_REGISTERS * sizeof(long); - - /* The stack space allocated needs to be a multiple of 16 bytes. */ - bytes = ALIGN(bytes, 16) ; - - cif->flags = flags; - cif->bytes = bytes; - - return FFI_OK; -} - -extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *, - void (*fn)(void), void (*fn2)(void)); - -extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *, - void (*fn)(void), void (*fn2)(void), ffi_type*); - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return - value address then we need to make one. */ - - if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca (cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_AIX: - ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn, - FFI_FN(ffi_prep_args)); - break; - case FFI_DARWIN: - ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn, - FFI_FN(ffi_prep_args), cif->rtype); - break; - default: - FFI_ASSERT(0); - break; - } -} - -static void flush_icache(char *); -static void flush_range(char *, int); - -/* The layout of a function descriptor. A C function pointer really - points to one of these. */ - -typedef struct aix_fd_struct { - void *code_pointer; - void *toc; -} aix_fd; - -/* here I'd like to add the stack frame layout we use in darwin_closure.S - and aix_closure.S - - m32/m64 - - The stack layout looks like this: - - | Additional params... | | Higher address - ~ ~ ~ - | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | - | Reserved 2*4/8 | | - |--------------------------------------------| | - | Space for callee's LR 4/8 | | - |--------------------------------------------| | - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | - | Current backchain pointer 4/8 |-/ Parent's frame. - |--------------------------------------------| <+ <<< on entry to ffi_closure_ASM - | Result Bytes 16 | | - |--------------------------------------------| | - ~ padding to 16-byte alignment ~ ~ - |--------------------------------------------| | - | NUM_FPR_ARG_REGISTERS slots | | - | here fp13 .. fp1 13*8 | | - |--------------------------------------------| | - | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | stack | - | Reserved [compiler,binder] 2*4/8 | | grows | - |--------------------------------------------| | down V - | Space for callee's LR 4/8 | | - |--------------------------------------------| | lower addresses - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 4/8 |-/ during - |--------------------------------------------| <<< ffi_closure_ASM. - -*/ - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp; - struct ffi_aix_trampoline_struct *tramp_aix; - aix_fd *fd; - - switch (cif->abi) - { - case FFI_DARWIN: - - FFI_ASSERT (cif->abi == FFI_DARWIN); - - tramp = (unsigned int *) &closure->tramp[0]; -#if defined(POWERPC_DARWIN64) - tramp[0] = 0x7c0802a6; /* mflr r0 */ - tramp[1] = 0x429f0015; /* bcl- 20,4*cr7+so, +0x18 (L1) */ - /* We put the addresses here. */ - tramp[6] = 0x7d6802a6; /*L1: mflr r11 */ - tramp[7] = 0xe98b0000; /* ld r12,0(r11) function address */ - tramp[8] = 0x7c0803a6; /* mtlr r0 */ - tramp[9] = 0x7d8903a6; /* mtctr r12 */ - tramp[10] = 0xe96b0008; /* lwz r11,8(r11) static chain */ - tramp[11] = 0x4e800420; /* bctr */ - - *((unsigned long *)&tramp[2]) = (unsigned long) ffi_closure_ASM; /* function */ - *((unsigned long *)&tramp[4]) = (unsigned long) codeloc; /* context */ -#else - tramp[0] = 0x7c0802a6; /* mflr r0 */ - tramp[1] = 0x429f000d; /* bcl- 20,4*cr7+so,0x10 */ - tramp[4] = 0x7d6802a6; /* mflr r11 */ - tramp[5] = 0x818b0000; /* lwz r12,0(r11) function address */ - tramp[6] = 0x7c0803a6; /* mtlr r0 */ - tramp[7] = 0x7d8903a6; /* mtctr r12 */ - tramp[8] = 0x816b0004; /* lwz r11,4(r11) static chain */ - tramp[9] = 0x4e800420; /* bctr */ - tramp[2] = (unsigned long) ffi_closure_ASM; /* function */ - tramp[3] = (unsigned long) codeloc; /* context */ -#endif - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - /* Flush the icache. Only necessary on Darwin. */ - flush_range(codeloc, FFI_TRAMPOLINE_SIZE); - - break; - - case FFI_AIX: - - tramp_aix = (struct ffi_aix_trampoline_struct *) (closure->tramp); - fd = (aix_fd *)(void *)ffi_closure_ASM; - - FFI_ASSERT (cif->abi == FFI_AIX); - - tramp_aix->code_pointer = fd->code_pointer; - tramp_aix->toc = fd->toc; - tramp_aix->static_chain = codeloc; - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - break; - - default: - return FFI_BAD_ABI; - break; - } - return FFI_OK; -} - -static void -flush_icache(char *addr) -{ -#ifndef _AIX - __asm__ volatile ( - "dcbf 0,%0\n" - "\tsync\n" - "\ticbi 0,%0\n" - "\tsync\n" - "\tisync" - : : "r"(addr) : "memory"); -#endif -} - -static void -flush_range(char * addr1, int size) -{ -#define MIN_LINE_SIZE 32 - int i; - for (i = 0; i < size; i += MIN_LINE_SIZE) - flush_icache(addr1+i); - flush_icache(addr1+size-1); -} - -typedef union -{ - float f; - double d; -} ffi_dblfl; - -ffi_type * -ffi_closure_helper_DARWIN (ffi_closure *, void *, - unsigned long *, ffi_dblfl *); - -/* Basically the trampoline invokes ffi_closure_ASM, and on - entry, r11 holds the address of the closure. - After storing the registers that could possibly contain - parameters to be passed into the stack frame and setting - up space for a return value, ffi_closure_ASM invokes the - following helper function to do most of the work. */ - -ffi_type * -ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue, - unsigned long *pgr, ffi_dblfl *pfr) -{ - /* rvalue is the pointer to space for return value in closure assembly - pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM - pfr is the pointer to where f1-f13 are stored in ffi_closure_ASM. */ - - typedef double ldbits[2]; - - union ldu - { - ldbits lb; - long double ld; - }; - - void ** avalue; - ffi_type ** arg_types; - long i, avn; - ffi_cif * cif; - ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS; - unsigned size_al; -#if defined(POWERPC_DARWIN64) - unsigned fpsused = 0; -#endif - - cif = closure->cif; - avalue = alloca (cif->nargs * sizeof(void *)); - - if (cif->rtype->type == FFI_TYPE_STRUCT) - { -#if defined(POWERPC_DARWIN64) - if (!darwin64_struct_ret_by_value_p (cif->rtype)) - { - /* Won't fit into the regs - return by ref. */ - rvalue = (void *) *pgr; - pgr++; - } -#elif defined(DARWIN_PPC) - if (cif->rtype->size > 4) - { - rvalue = (void *) *pgr; - pgr++; - } -#else /* assume we return by ref. */ - rvalue = (void *) *pgr; - pgr++; -#endif - } - - i = 0; - avn = cif->nargs; - arg_types = cif->arg_types; - - /* Grab the addresses of the arguments from the stack frame. */ - while (i < avn) - { - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: -#if defined(POWERPC64) - avalue[i] = (char *) pgr + 7; -#else - avalue[i] = (char *) pgr + 3; -#endif - pgr++; - break; - - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: -#if defined(POWERPC64) - avalue[i] = (char *) pgr + 6; -#else - avalue[i] = (char *) pgr + 2; -#endif - pgr++; - break; - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: -#if defined(POWERPC64) - avalue[i] = (char *) pgr + 4; -#else - case FFI_TYPE_POINTER: - avalue[i] = pgr; -#endif - pgr++; - break; - - case FFI_TYPE_STRUCT: - size_al = arg_types[i]->size; -#if defined(POWERPC_DARWIN64) - pgr = (unsigned long *)ALIGN((char *)pgr, arg_types[i]->alignment); - if (size_al < 3 || size_al == 4) - { - avalue[i] = ((char *)pgr)+8-size_al; - if (arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT - && fpsused < NUM_FPR_ARG_REGISTERS) - { - *(float *)pgr = (float) *(double *)pfr; - pfr++; - fpsused++; - } - } - else - { - if (size_al != 16) - pfr = (ffi_dblfl *) - darwin64_struct_floats_to_mem (arg_types[i], (char *)pgr, - (double *)pfr, &fpsused); - avalue[i] = pgr; - } - pgr += (size_al + 7) / 8; -#else - /* If the first member of the struct is a double, then align - the struct to double-word. */ - if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE) - size_al = ALIGN(arg_types[i]->size, 8); -# if defined(POWERPC64) - FFI_ASSERT (cif->abi != FFI_DARWIN); - avalue[i] = pgr; - pgr += (size_al + 7) / 8; -# else - /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, - SI 4 bytes) are aligned as if they were those modes. */ - if (size_al < 3 && cif->abi == FFI_DARWIN) - avalue[i] = (char*) pgr + 4 - size_al; - else - avalue[i] = pgr; - pgr += (size_al + 3) / 4; -# endif -#endif - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: -#if defined(POWERPC64) - case FFI_TYPE_POINTER: - avalue[i] = pgr; - pgr++; - break; -#else - /* Long long ints are passed in two gpr's. */ - avalue[i] = pgr; - pgr += 2; - break; -#endif - - case FFI_TYPE_FLOAT: - /* A float value consumes a GPR. - There are 13 64bit floating point registers. */ - if (pfr < end_pfr) - { - double temp = pfr->d; - pfr->f = (float) temp; - avalue[i] = pfr; - pfr++; - } - else - { - avalue[i] = pgr; - } - pgr++; - break; - - case FFI_TYPE_DOUBLE: - /* A double value consumes two GPRs. - There are 13 64bit floating point registers. */ - if (pfr < end_pfr) - { - avalue[i] = pfr; - pfr++; - } - else - { - avalue[i] = pgr; - } -#ifdef POWERPC64 - pgr++; -#else - pgr += 2; -#endif - break; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - - case FFI_TYPE_LONGDOUBLE: -#ifdef POWERPC64 - if (pfr + 1 < end_pfr) - { - avalue[i] = pfr; - pfr += 2; - } - else - { - if (pfr < end_pfr) - { - *pgr = *(unsigned long *) pfr; - pfr++; - } - avalue[i] = pgr; - } - pgr += 2; -#else /* POWERPC64 */ - /* A long double value consumes four GPRs and two FPRs. - There are 13 64bit floating point registers. */ - if (pfr + 1 < end_pfr) - { - avalue[i] = pfr; - pfr += 2; - } - /* Here we have the situation where one part of the long double - is stored in fpr13 and the other part is already on the stack. - We use a union to pass the long double to avalue[i]. */ - else if (pfr + 1 == end_pfr) - { - union ldu temp_ld; - memcpy (&temp_ld.lb[0], pfr, sizeof(ldbits)); - memcpy (&temp_ld.lb[1], pgr + 2, sizeof(ldbits)); - avalue[i] = &temp_ld.ld; - pfr++; - } - else - { - avalue[i] = pgr; - } - pgr += 4; -#endif /* POWERPC64 */ - break; -#endif - default: - FFI_ASSERT(0); - } - i++; - } - - (closure->fun) (cif, rvalue, avalue, closure->user_data); - - /* Tell ffi_closure_ASM to perform return type promotions. */ - return cif->rtype; -} diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_linux64.c b/user/mpy/lib/libffi/src/powerpc/ffi_linux64.c deleted file mode 100644 index b84b91f..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ffi_linux64.c +++ /dev/null @@ -1,945 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi_linux64.c - Copyright (C) 2013 IBM - Copyright (C) 2011 Anthony Green - Copyright (C) 2011 Kyle Moffett - Copyright (C) 2008 Red Hat, Inc - Copyright (C) 2007, 2008 Free Software Foundation, Inc - Copyright (c) 1998 Geoffrey Keating - - PowerPC Foreign Function Interface - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#include "ffi.h" - -#ifdef POWERPC64 -#include "ffi_common.h" -#include "ffi_powerpc.h" - - -/* About the LINUX64 ABI. */ -enum { - NUM_GPR_ARG_REGISTERS64 = 8, - NUM_FPR_ARG_REGISTERS64 = 13 -}; -enum { ASM_NEEDS_REGISTERS64 = 4 }; - - -#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -/* Adjust size of ffi_type_longdouble. */ -void FFI_HIDDEN -ffi_prep_types_linux64 (ffi_abi abi) -{ - if ((abi & (FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128)) == FFI_LINUX) - { - ffi_type_longdouble.size = 8; - ffi_type_longdouble.alignment = 8; - } - else - { - ffi_type_longdouble.size = 16; - ffi_type_longdouble.alignment = 16; - } -} -#endif - - -#if _CALL_ELF == 2 -static unsigned int -discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum) -{ - switch (t->type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - *elnum = 1; - return (int) t->type; - - case FFI_TYPE_STRUCT:; - { - unsigned int base_elt = 0, total_elnum = 0; - ffi_type **el = t->elements; - while (*el) - { - unsigned int el_elt, el_elnum = 0; - el_elt = discover_homogeneous_aggregate (*el, &el_elnum); - if (el_elt == 0 - || (base_elt && base_elt != el_elt)) - return 0; - base_elt = el_elt; - total_elnum += el_elnum; - if (total_elnum > 8) - return 0; - el++; - } - *elnum = total_elnum; - return base_elt; - } - - default: - return 0; - } -} -#endif - - -/* Perform machine dependent cif processing */ -static ffi_status -ffi_prep_cif_linux64_core (ffi_cif *cif) -{ - ffi_type **ptr; - unsigned bytes; - unsigned i, fparg_count = 0, intarg_count = 0; - unsigned flags = cif->flags; -#if _CALL_ELF == 2 - unsigned int elt, elnum; -#endif - -#if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE - /* If compiled without long double support.. */ - if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) - return FFI_BAD_ABI; -#endif - - /* The machine-independent calculation of cif->bytes doesn't work - for us. Redo the calculation. */ -#if _CALL_ELF == 2 - /* Space for backchain, CR, LR, TOC and the asm's temp regs. */ - bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long); - - /* Space for the general registers. */ - bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long); -#else - /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp - regs. */ - bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long); - - /* Space for the mandatory parm save area and general registers. */ - bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long); -#endif - - /* Return value handling. */ - switch (cif->rtype->type) - { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) - flags |= FLAG_RETURNS_128BITS; - /* Fall through. */ -#endif - case FFI_TYPE_DOUBLE: - flags |= FLAG_RETURNS_64BITS; - /* Fall through. */ - case FFI_TYPE_FLOAT: - flags |= FLAG_RETURNS_FP; - break; - - case FFI_TYPE_UINT128: - flags |= FLAG_RETURNS_128BITS; - /* Fall through. */ - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - flags |= FLAG_RETURNS_64BITS; - break; - - case FFI_TYPE_STRUCT: -#if _CALL_ELF == 2 - elt = discover_homogeneous_aggregate (cif->rtype, &elnum); - if (elt) - { - if (elt == FFI_TYPE_DOUBLE) - flags |= FLAG_RETURNS_64BITS; - flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST; - break; - } - if (cif->rtype->size <= 16) - { - flags |= FLAG_RETURNS_SMST; - break; - } -#endif - intarg_count++; - flags |= FLAG_RETVAL_REFERENCE; - /* Fall through. */ - case FFI_TYPE_VOID: - flags |= FLAG_RETURNS_NOTHING; - break; - - default: - /* Returns 32-bit integer, or similar. Nothing to do here. */ - break; - } - - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) - { - unsigned int align; - - switch ((*ptr)->type) - { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) - { - fparg_count++; - intarg_count++; - } - /* Fall through. */ -#endif - case FFI_TYPE_DOUBLE: - case FFI_TYPE_FLOAT: - fparg_count++; - intarg_count++; - if (fparg_count > NUM_FPR_ARG_REGISTERS64) - flags |= FLAG_ARG_NEEDS_PSAVE; - break; - - case FFI_TYPE_STRUCT: - if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0) - { - align = (*ptr)->alignment; - if (align > 16) - align = 16; - align = align / 8; - if (align > 1) - intarg_count = ALIGN (intarg_count, align); - } - intarg_count += ((*ptr)->size + 7) / 8; -#if _CALL_ELF == 2 - elt = discover_homogeneous_aggregate (*ptr, &elnum); - if (elt) - { - fparg_count += elnum; - if (fparg_count > NUM_FPR_ARG_REGISTERS64) - flags |= FLAG_ARG_NEEDS_PSAVE; - } - else -#endif - { - if (intarg_count > NUM_GPR_ARG_REGISTERS64) - flags |= FLAG_ARG_NEEDS_PSAVE; - } - break; - - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - /* Everything else is passed as a 8-byte word in a GPR, either - the object itself or a pointer to it. */ - intarg_count++; - if (intarg_count > NUM_GPR_ARG_REGISTERS64) - flags |= FLAG_ARG_NEEDS_PSAVE; - break; - default: - FFI_ASSERT (0); - } - } - - if (fparg_count != 0) - flags |= FLAG_FP_ARGUMENTS; - if (intarg_count > 4) - flags |= FLAG_4_GPR_ARGUMENTS; - - /* Space for the FPR registers, if needed. */ - if (fparg_count != 0) - bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double); - - /* Stack space. */ -#if _CALL_ELF == 2 - if ((flags & FLAG_ARG_NEEDS_PSAVE) != 0) - bytes += intarg_count * sizeof (long); -#else - if (intarg_count > NUM_GPR_ARG_REGISTERS64) - bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long); -#endif - - /* The stack space allocated needs to be a multiple of 16 bytes. */ - bytes = (bytes + 15) & ~0xF; - - cif->flags = flags; - cif->bytes = bytes; - - return FFI_OK; -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_linux64 (ffi_cif *cif) -{ - if ((cif->abi & FFI_LINUX) != 0) - cif->nfixedargs = cif->nargs; -#if _CALL_ELF != 2 - else if (cif->abi == FFI_COMPAT_LINUX64) - { - /* This call is from old code. Don't touch cif->nfixedargs - since old code will be using a smaller cif. */ - cif->flags |= FLAG_COMPAT; - /* Translate to new abi value. */ - cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128; - } -#endif - else - return FFI_BAD_ABI; - return ffi_prep_cif_linux64_core (cif); -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_linux64_var (ffi_cif *cif, - unsigned int nfixedargs, - unsigned int ntotalargs MAYBE_UNUSED) -{ - if ((cif->abi & FFI_LINUX) != 0) - cif->nfixedargs = nfixedargs; -#if _CALL_ELF != 2 - else if (cif->abi == FFI_COMPAT_LINUX64) - { - /* This call is from old code. Don't touch cif->nfixedargs - since old code will be using a smaller cif. */ - cif->flags |= FLAG_COMPAT; - /* Translate to new abi value. */ - cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128; - } -#endif - else - return FFI_BAD_ABI; -#if _CALL_ELF == 2 - cif->flags |= FLAG_ARG_NEEDS_PSAVE; -#endif - return ffi_prep_cif_linux64_core (cif); -} - - -/* ffi_prep_args64 is called by the assembly routine once stack space - has been allocated for the function's arguments. - - The stack layout we want looks like this: - - | Ret addr from ffi_call_LINUX64 8bytes | higher addresses - |--------------------------------------------| - | CR save area 8bytes | - |--------------------------------------------| - | Previous backchain pointer 8 | stack pointer here - |--------------------------------------------|<+ <<< on entry to - | Saved r28-r31 4*8 | | ffi_call_LINUX64 - |--------------------------------------------| | - | GPR registers r3-r10 8*8 | | - |--------------------------------------------| | - | FPR registers f1-f13 (optional) 13*8 | | - |--------------------------------------------| | - | Parameter save area | | - |--------------------------------------------| | - | TOC save area 8 | | - |--------------------------------------------| | stack | - | Linker doubleword 8 | | grows | - |--------------------------------------------| | down V - | Compiler doubleword 8 | | - |--------------------------------------------| | lower addresses - | Space for callee's LR 8 | | - |--------------------------------------------| | - | CR save area 8 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 8 |-/ during - |--------------------------------------------| <<< ffi_call_LINUX64 - -*/ - -void FFI_HIDDEN -ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) -{ - const unsigned long bytes = ecif->cif->bytes; - const unsigned long flags = ecif->cif->flags; - - typedef union - { - char *c; - unsigned long *ul; - float *f; - double *d; - size_t p; - } valp; - - /* 'stacktop' points at the previous backchain pointer. */ - valp stacktop; - - /* 'next_arg' points at the space for gpr3, and grows upwards as - we use GPR registers, then continues at rest. */ - valp gpr_base; - valp gpr_end; - valp rest; - valp next_arg; - - /* 'fpr_base' points at the space for fpr3, and grows upwards as - we use FPR registers. */ - valp fpr_base; - unsigned int fparg_count; - - unsigned int i, words, nargs, nfixedargs; - ffi_type **ptr; - double double_tmp; - union - { - void **v; - char **c; - signed char **sc; - unsigned char **uc; - signed short **ss; - unsigned short **us; - signed int **si; - unsigned int **ui; - unsigned long **ul; - float **f; - double **d; - } p_argv; - unsigned long gprvalue; - unsigned long align; - - stacktop.c = (char *) stack + bytes; - gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64; - gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64; -#if _CALL_ELF == 2 - rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64; -#else - rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64; -#endif - fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64; - fparg_count = 0; - next_arg.ul = gpr_base.ul; - - /* Check that everything starts aligned properly. */ - FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0); - FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0); - FFI_ASSERT ((bytes & 0xF) == 0); - - /* Deal with return values that are actually pass-by-reference. */ - if (flags & FLAG_RETVAL_REFERENCE) - *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue; - - /* Now for the arguments. */ - p_argv.v = ecif->avalue; - nargs = ecif->cif->nargs; -#if _CALL_ELF != 2 - nfixedargs = (unsigned) -1; - if ((flags & FLAG_COMPAT) == 0) -#endif - nfixedargs = ecif->cif->nfixedargs; - for (ptr = ecif->cif->arg_types, i = 0; - i < nargs; - i++, ptr++, p_argv.v++) - { -#if _CALL_ELF == 2 - unsigned int elt, elnum; -#endif - - switch ((*ptr)->type) - { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) - { - double_tmp = (*p_argv.d)[0]; - if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) - { - *fpr_base.d++ = double_tmp; -# if _CALL_ELF != 2 - if ((flags & FLAG_COMPAT) != 0) - *next_arg.d = double_tmp; -# endif - } - else - *next_arg.d = double_tmp; - if (++next_arg.ul == gpr_end.ul) - next_arg.ul = rest.ul; - fparg_count++; - double_tmp = (*p_argv.d)[1]; - if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) - { - *fpr_base.d++ = double_tmp; -# if _CALL_ELF != 2 - if ((flags & FLAG_COMPAT) != 0) - *next_arg.d = double_tmp; -# endif - } - else - *next_arg.d = double_tmp; - if (++next_arg.ul == gpr_end.ul) - next_arg.ul = rest.ul; - fparg_count++; - FFI_ASSERT (__LDBL_MANT_DIG__ == 106); - FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); - break; - } - /* Fall through. */ -#endif - case FFI_TYPE_DOUBLE: - double_tmp = **p_argv.d; - if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) - { - *fpr_base.d++ = double_tmp; -#if _CALL_ELF != 2 - if ((flags & FLAG_COMPAT) != 0) - *next_arg.d = double_tmp; -#endif - } - else - *next_arg.d = double_tmp; - if (++next_arg.ul == gpr_end.ul) - next_arg.ul = rest.ul; - fparg_count++; - FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); - break; - - case FFI_TYPE_FLOAT: - double_tmp = **p_argv.f; - if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) - { - *fpr_base.d++ = double_tmp; -#if _CALL_ELF != 2 - if ((flags & FLAG_COMPAT) != 0) - *next_arg.f = (float) double_tmp; -#endif - } - else - *next_arg.f = (float) double_tmp; - if (++next_arg.ul == gpr_end.ul) - next_arg.ul = rest.ul; - fparg_count++; - FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); - break; - - case FFI_TYPE_STRUCT: - if ((ecif->cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0) - { - align = (*ptr)->alignment; - if (align > 16) - align = 16; - if (align > 1) - next_arg.p = ALIGN (next_arg.p, align); - } -#if _CALL_ELF == 2 - elt = discover_homogeneous_aggregate (*ptr, &elnum); - if (elt) - { - union { - void *v; - float *f; - double *d; - } arg; - - arg.v = *p_argv.v; - if (elt == FFI_TYPE_FLOAT) - { - do - { - double_tmp = *arg.f++; - if (fparg_count < NUM_FPR_ARG_REGISTERS64 - && i < nfixedargs) - *fpr_base.d++ = double_tmp; - else - *next_arg.f = (float) double_tmp; - if (++next_arg.f == gpr_end.f) - next_arg.f = rest.f; - fparg_count++; - } - while (--elnum != 0); - if ((next_arg.p & 3) != 0) - { - if (++next_arg.f == gpr_end.f) - next_arg.f = rest.f; - } - } - else - do - { - double_tmp = *arg.d++; - if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs) - *fpr_base.d++ = double_tmp; - else - *next_arg.d = double_tmp; - if (++next_arg.d == gpr_end.d) - next_arg.d = rest.d; - fparg_count++; - } - while (--elnum != 0); - } - else -#endif - { - words = ((*ptr)->size + 7) / 8; - if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul) - { - size_t first = gpr_end.c - next_arg.c; - memcpy (next_arg.c, *p_argv.c, first); - memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first); - next_arg.c = rest.c + words * 8 - first; - } - else - { - char *where = next_arg.c; - -#ifndef __LITTLE_ENDIAN__ - /* Structures with size less than eight bytes are passed - left-padded. */ - if ((*ptr)->size < 8) - where += 8 - (*ptr)->size; -#endif - memcpy (where, *p_argv.c, (*ptr)->size); - next_arg.ul += words; - if (next_arg.ul == gpr_end.ul) - next_arg.ul = rest.ul; - } - } - break; - - case FFI_TYPE_UINT8: - gprvalue = **p_argv.uc; - goto putgpr; - case FFI_TYPE_SINT8: - gprvalue = **p_argv.sc; - goto putgpr; - case FFI_TYPE_UINT16: - gprvalue = **p_argv.us; - goto putgpr; - case FFI_TYPE_SINT16: - gprvalue = **p_argv.ss; - goto putgpr; - case FFI_TYPE_UINT32: - gprvalue = **p_argv.ui; - goto putgpr; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - gprvalue = **p_argv.si; - goto putgpr; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_POINTER: - gprvalue = **p_argv.ul; - putgpr: - *next_arg.ul++ = gprvalue; - if (next_arg.ul == gpr_end.ul) - next_arg.ul = rest.ul; - break; - } - } - - FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS - || (next_arg.ul >= gpr_base.ul - && next_arg.ul <= gpr_base.ul + 4)); -} - - -#if _CALL_ELF == 2 -#define MIN_CACHE_LINE_SIZE 8 - -static void -flush_icache (char *wraddr, char *xaddr, int size) -{ - int i; - for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) - __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" - : : "r" (xaddr + i), "r" (wraddr + i) : "memory"); - __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;" - : : "r"(xaddr + size - 1), "r"(wraddr + size - 1) - : "memory"); -} -#endif - - -ffi_status FFI_HIDDEN -ffi_prep_closure_loc_linux64 (ffi_closure *closure, - ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - void *codeloc) -{ -#if _CALL_ELF == 2 - unsigned int *tramp = (unsigned int *) &closure->tramp[0]; - - if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI) - return FFI_BAD_ABI; - - tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */ - tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */ - tramp[2] = 0x7d8903a6; /* mtctr 12 */ - tramp[3] = 0x4e800420; /* bctr */ - /* 1: .quad function_addr */ - /* 2: .quad context */ - *(void **) &tramp[4] = (void *) ffi_closure_LINUX64; - *(void **) &tramp[6] = codeloc; - flush_icache ((char *) tramp, (char *) codeloc, 4 * 4); -#else - void **tramp = (void **) &closure->tramp[0]; - - if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI) - return FFI_BAD_ABI; - - /* Copy function address and TOC from ffi_closure_LINUX64 OPD. */ - memcpy (&tramp[0], (void **) ffi_closure_LINUX64, sizeof (void *)); - tramp[1] = codeloc; - memcpy (&tramp[2], (void **) ffi_closure_LINUX64 + 1, sizeof (void *)); -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - - -int FFI_HIDDEN -ffi_closure_helper_LINUX64 (ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - void *rvalue, - unsigned long *pst, - ffi_dblfl *pfr) -{ - /* rvalue is the pointer to space for return value in closure assembly */ - /* pst is the pointer to parameter save area - (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */ - /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */ - - void **avalue; - ffi_type **arg_types; - unsigned long i, avn, nfixedargs; - ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64; - unsigned long align; - - avalue = alloca (cif->nargs * sizeof (void *)); - - /* Copy the caller's structure return value address so that the - closure returns the data directly to the caller. */ - if (cif->rtype->type == FFI_TYPE_STRUCT - && (cif->flags & FLAG_RETURNS_SMST) == 0) - { - rvalue = (void *) *pst; - pst++; - } - - i = 0; - avn = cif->nargs; -#if _CALL_ELF != 2 - nfixedargs = (unsigned) -1; - if ((cif->flags & FLAG_COMPAT) == 0) -#endif - nfixedargs = cif->nfixedargs; - arg_types = cif->arg_types; - - /* Grab the addresses of the arguments from the stack frame. */ - while (i < avn) - { - unsigned int elt, elnum; - - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: -#ifndef __LITTLE_ENDIAN__ - avalue[i] = (char *) pst + 7; - pst++; - break; -#endif - - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: -#ifndef __LITTLE_ENDIAN__ - avalue[i] = (char *) pst + 6; - pst++; - break; -#endif - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: -#ifndef __LITTLE_ENDIAN__ - avalue[i] = (char *) pst + 4; - pst++; - break; -#endif - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - avalue[i] = pst; - pst++; - break; - - case FFI_TYPE_STRUCT: - if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0) - { - align = arg_types[i]->alignment; - if (align > 16) - align = 16; - if (align > 1) - pst = (unsigned long *) ALIGN ((size_t) pst, align); - } - elt = 0; -#if _CALL_ELF == 2 - elt = discover_homogeneous_aggregate (arg_types[i], &elnum); -#endif - if (elt) - { - union { - void *v; - unsigned long *ul; - float *f; - double *d; - size_t p; - } to, from; - - /* Repackage the aggregate from its parts. The - aggregate size is not greater than the space taken by - the registers so store back to the register/parameter - save arrays. */ - if (pfr + elnum <= end_pfr) - to.v = pfr; - else - to.v = pst; - - avalue[i] = to.v; - from.ul = pst; - if (elt == FFI_TYPE_FLOAT) - { - do - { - if (pfr < end_pfr && i < nfixedargs) - { - *to.f = (float) pfr->d; - pfr++; - } - else - *to.f = *from.f; - to.f++; - from.f++; - } - while (--elnum != 0); - } - else - { - do - { - if (pfr < end_pfr && i < nfixedargs) - { - *to.d = pfr->d; - pfr++; - } - else - *to.d = *from.d; - to.d++; - from.d++; - } - while (--elnum != 0); - } - } - else - { -#ifndef __LITTLE_ENDIAN__ - /* Structures with size less than eight bytes are passed - left-padded. */ - if (arg_types[i]->size < 8) - avalue[i] = (char *) pst + 8 - arg_types[i]->size; - else -#endif - avalue[i] = pst; - } - pst += (arg_types[i]->size + 7) / 8; - break; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) - { - if (pfr + 1 < end_pfr && i + 1 < nfixedargs) - { - avalue[i] = pfr; - pfr += 2; - } - else - { - if (pfr < end_pfr && i < nfixedargs) - { - /* Passed partly in f13 and partly on the stack. - Move it all to the stack. */ - *pst = *(unsigned long *) pfr; - pfr++; - } - avalue[i] = pst; - } - pst += 2; - break; - } - /* Fall through. */ -#endif - case FFI_TYPE_DOUBLE: - /* On the outgoing stack all values are aligned to 8 */ - /* there are 13 64bit floating point registers */ - - if (pfr < end_pfr && i < nfixedargs) - { - avalue[i] = pfr; - pfr++; - } - else - avalue[i] = pst; - pst++; - break; - - case FFI_TYPE_FLOAT: - if (pfr < end_pfr && i < nfixedargs) - { - /* Float values are stored as doubles in the - ffi_closure_LINUX64 code. Fix them here. */ - pfr->f = (float) pfr->d; - avalue[i] = pfr; - pfr++; - } - else - avalue[i] = pst; - pst++; - break; - - default: - FFI_ASSERT (0); - } - - i++; - } - - (*fun) (cif, rvalue, avalue, user_data); - - /* Tell ffi_closure_LINUX64 how to perform return type promotions. */ - if ((cif->flags & FLAG_RETURNS_SMST) != 0) - { - if ((cif->flags & FLAG_RETURNS_FP) == 0) - return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1; - else if ((cif->flags & FLAG_RETURNS_64BITS) != 0) - return FFI_V2_TYPE_DOUBLE_HOMOG; - else - return FFI_V2_TYPE_FLOAT_HOMOG; - } - return cif->rtype->type; -} -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h b/user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h deleted file mode 100644 index 3dcd6b5..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ffi_powerpc.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi_powerpc.h - Copyright (C) 2013 IBM - Copyright (C) 2011 Anthony Green - Copyright (C) 2011 Kyle Moffett - Copyright (C) 2008 Red Hat, Inc - Copyright (C) 2007, 2008 Free Software Foundation, Inc - Copyright (c) 1998 Geoffrey Keating - - PowerPC Foreign Function Interface - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -enum { - /* The assembly depends on these exact flags. */ - /* These go in cr7 */ - FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */ - FLAG_RETURNS_NOTHING = 1 << (31-30), - FLAG_RETURNS_FP = 1 << (31-29), - FLAG_RETURNS_64BITS = 1 << (31-28), - - /* This goes in cr6 */ - FLAG_RETURNS_128BITS = 1 << (31-27), - - FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */ - - /* These go in cr1 */ - FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */ - FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */ - FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ - FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), - FLAG_RETVAL_REFERENCE = 1 << (31- 4) -}; - -typedef union -{ - float f; - double d; -} ffi_dblfl; - -void FFI_HIDDEN ffi_closure_SYSV (void); -void FFI_HIDDEN ffi_go_closure_sysv (void); -void FFI_HIDDEN ffi_call_SYSV(extended_cif *, void (*)(void), void *, - unsigned, void *, int); - -void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi); -ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *); -ffi_status FFI_HIDDEN ffi_prep_closure_loc_sysv (ffi_closure *, - ffi_cif *, - void (*) (ffi_cif *, void *, - void **, void *), - void *, void *); -int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_cif *, - void (*) (ffi_cif *, void *, - void **, void *), - void *, void *, unsigned long *, - ffi_dblfl *, unsigned long *); - -void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, void (*) (void), void *, - unsigned long, void *, long); -void FFI_HIDDEN ffi_closure_LINUX64 (void); -void FFI_HIDDEN ffi_go_closure_linux64 (void); - -void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi); -ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *); -ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int, - unsigned int); -void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const); -ffi_status FFI_HIDDEN ffi_prep_closure_loc_linux64 (ffi_closure *, ffi_cif *, - void (*) (ffi_cif *, void *, - void **, void *), - void *, void *); -int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_cif *, - void (*) (ffi_cif *, void *, - void **, void *), - void *, void *, - unsigned long *, ffi_dblfl *); diff --git a/user/mpy/lib/libffi/src/powerpc/ffi_sysv.c b/user/mpy/lib/libffi/src/powerpc/ffi_sysv.c deleted file mode 100644 index 646c340..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ffi_sysv.c +++ /dev/null @@ -1,934 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi_sysv.c - Copyright (C) 2013 IBM - Copyright (C) 2011 Anthony Green - Copyright (C) 2011 Kyle Moffett - Copyright (C) 2008 Red Hat, Inc - Copyright (C) 2007, 2008 Free Software Foundation, Inc - Copyright (c) 1998 Geoffrey Keating - - PowerPC Foreign Function Interface - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ - -#include "ffi.h" - -#ifndef POWERPC64 -#include "ffi_common.h" -#include "ffi_powerpc.h" - - -/* About the SYSV ABI. */ -#define ASM_NEEDS_REGISTERS 6 -#define NUM_GPR_ARG_REGISTERS 8 -#define NUM_FPR_ARG_REGISTERS 8 - - -#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -/* Adjust size of ffi_type_longdouble. */ -void FFI_HIDDEN -ffi_prep_types_sysv (ffi_abi abi) -{ - if ((abi & (FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128)) == FFI_SYSV) - { - ffi_type_longdouble.size = 8; - ffi_type_longdouble.alignment = 8; - } - else - { - ffi_type_longdouble.size = 16; - ffi_type_longdouble.alignment = 16; - } -} -#endif - -/* Transform long double, double and float to other types as per abi. */ -static int -translate_float (int abi, int type) -{ -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - if (type == FFI_TYPE_LONGDOUBLE - && (abi & FFI_SYSV_LONG_DOUBLE_128) == 0) - type = FFI_TYPE_DOUBLE; -#endif - if ((abi & FFI_SYSV_SOFT_FLOAT) != 0) - { - if (type == FFI_TYPE_FLOAT) - type = FFI_TYPE_UINT32; - else if (type == FFI_TYPE_DOUBLE) - type = FFI_TYPE_UINT64; -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - else if (type == FFI_TYPE_LONGDOUBLE) - type = FFI_TYPE_UINT128; - } - else if ((abi & FFI_SYSV_IBM_LONG_DOUBLE) == 0) - { - if (type == FFI_TYPE_LONGDOUBLE) - type = FFI_TYPE_STRUCT; -#endif - } - return type; -} - -/* Perform machine dependent cif processing */ -static ffi_status -ffi_prep_cif_sysv_core (ffi_cif *cif) -{ - ffi_type **ptr; - unsigned bytes; - unsigned i, fparg_count = 0, intarg_count = 0; - unsigned flags = cif->flags; - unsigned struct_copy_size = 0; - unsigned type = cif->rtype->type; - unsigned size = cif->rtype->size; - - /* The machine-independent calculation of cif->bytes doesn't work - for us. Redo the calculation. */ - - /* Space for the frame pointer, callee's LR, and the asm's temp regs. */ - bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int); - - /* Space for the GPR registers. */ - bytes += NUM_GPR_ARG_REGISTERS * sizeof (int); - - /* Return value handling. The rules for SYSV are as follows: - - 32-bit (or less) integer values are returned in gpr3; - - Structures of size <= 4 bytes also returned in gpr3; - - 64-bit integer values and structures between 5 and 8 bytes are returned - in gpr3 and gpr4; - - Larger structures are allocated space and a pointer is passed as - the first argument. - - Single/double FP values are returned in fpr1; - - long doubles (if not equivalent to double) are returned in - fpr1,fpr2 for Linux and as for large structs for SysV. */ - - type = translate_float (cif->abi, type); - - switch (type) - { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - flags |= FLAG_RETURNS_128BITS; - /* Fall through. */ -#endif - case FFI_TYPE_DOUBLE: - flags |= FLAG_RETURNS_64BITS; - /* Fall through. */ - case FFI_TYPE_FLOAT: - flags |= FLAG_RETURNS_FP; -#ifdef __NO_FPRS__ - return FFI_BAD_ABI; -#endif - break; - - case FFI_TYPE_UINT128: - flags |= FLAG_RETURNS_128BITS; - /* Fall through. */ - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - flags |= FLAG_RETURNS_64BITS; - break; - - case FFI_TYPE_STRUCT: - /* The final SYSV ABI says that structures smaller or equal 8 bytes - are returned in r3/r4. A draft ABI used by linux instead - returns them in memory. */ - if ((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8) - { - flags |= FLAG_RETURNS_SMST; - break; - } - intarg_count++; - flags |= FLAG_RETVAL_REFERENCE; - /* Fall through. */ - case FFI_TYPE_VOID: - flags |= FLAG_RETURNS_NOTHING; - break; - - default: - /* Returns 32-bit integer, or similar. Nothing to do here. */ - break; - } - - /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the - first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest - goes on the stack. Structures and long doubles (if not equivalent - to double) are passed as a pointer to a copy of the structure. - Stuff on the stack needs to keep proper alignment. */ - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) - { - unsigned short typenum = (*ptr)->type; - - typenum = translate_float (cif->abi, typenum); - - switch (typenum) - { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - fparg_count++; - /* Fall thru */ -#endif - case FFI_TYPE_DOUBLE: - fparg_count++; - /* If this FP arg is going on the stack, it must be - 8-byte-aligned. */ - if (fparg_count > NUM_FPR_ARG_REGISTERS - && intarg_count >= NUM_GPR_ARG_REGISTERS - && intarg_count % 2 != 0) - intarg_count++; -#ifdef __NO_FPRS__ - return FFI_BAD_ABI; -#endif - break; - - case FFI_TYPE_FLOAT: - fparg_count++; -#ifdef __NO_FPRS__ - return FFI_BAD_ABI; -#endif - break; - - case FFI_TYPE_UINT128: - /* A long double in FFI_LINUX_SOFT_FLOAT can use only a set - of four consecutive gprs. If we do not have enough, we - have to adjust the intarg_count value. */ - if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3 - && intarg_count < NUM_GPR_ARG_REGISTERS) - intarg_count = NUM_GPR_ARG_REGISTERS; - intarg_count += 4; - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - /* 'long long' arguments are passed as two words, but - either both words must fit in registers or both go - on the stack. If they go on the stack, they must - be 8-byte-aligned. - - Also, only certain register pairs can be used for - passing long long int -- specifically (r3,r4), (r5,r6), - (r7,r8), (r9,r10). */ - if (intarg_count == NUM_GPR_ARG_REGISTERS-1 - || intarg_count % 2 != 0) - intarg_count++; - intarg_count += 2; - break; - - case FFI_TYPE_STRUCT: - /* We must allocate space for a copy of these to enforce - pass-by-value. Pad the space up to a multiple of 16 - bytes (the maximum alignment required for anything under - the SYSV ABI). */ - struct_copy_size += ((*ptr)->size + 15) & ~0xF; - /* Fall through (allocate space for the pointer). */ - - case FFI_TYPE_POINTER: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - /* Everything else is passed as a 4-byte word in a GPR, either - the object itself or a pointer to it. */ - intarg_count++; - break; - - default: - FFI_ASSERT (0); - } - } - - if (fparg_count != 0) - flags |= FLAG_FP_ARGUMENTS; - if (intarg_count > 4) - flags |= FLAG_4_GPR_ARGUMENTS; - if (struct_copy_size != 0) - flags |= FLAG_ARG_NEEDS_COPY; - - /* Space for the FPR registers, if needed. */ - if (fparg_count != 0) - bytes += NUM_FPR_ARG_REGISTERS * sizeof (double); - - /* Stack space. */ - if (intarg_count > NUM_GPR_ARG_REGISTERS) - bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int); - if (fparg_count > NUM_FPR_ARG_REGISTERS) - bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double); - - /* The stack space allocated needs to be a multiple of 16 bytes. */ - bytes = (bytes + 15) & ~0xF; - - /* Add in the space for the copied structures. */ - bytes += struct_copy_size; - - cif->flags = flags; - cif->bytes = bytes; - - return FFI_OK; -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_sysv (ffi_cif *cif) -{ - if ((cif->abi & FFI_SYSV) == 0) - { - /* This call is from old code. Translate to new ABI values. */ - cif->flags |= FLAG_COMPAT; - switch (cif->abi) - { - default: - return FFI_BAD_ABI; - - case FFI_COMPAT_SYSV: - cif->abi = FFI_SYSV | FFI_SYSV_STRUCT_RET | FFI_SYSV_LONG_DOUBLE_128; - break; - - case FFI_COMPAT_GCC_SYSV: - cif->abi = FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128; - break; - - case FFI_COMPAT_LINUX: - cif->abi = (FFI_SYSV | FFI_SYSV_IBM_LONG_DOUBLE - | FFI_SYSV_LONG_DOUBLE_128); - break; - - case FFI_COMPAT_LINUX_SOFT_FLOAT: - cif->abi = (FFI_SYSV | FFI_SYSV_SOFT_FLOAT | FFI_SYSV_IBM_LONG_DOUBLE - | FFI_SYSV_LONG_DOUBLE_128); - break; - } - } - return ffi_prep_cif_sysv_core (cif); -} - -/* ffi_prep_args_SYSV is called by the assembly routine once stack space - has been allocated for the function's arguments. - - The stack layout we want looks like this: - - | Return address from ffi_call_SYSV 4bytes | higher addresses - |--------------------------------------------| - | Previous backchain pointer 4 | stack pointer here - |--------------------------------------------|<+ <<< on entry to - | Saved r28-r31 4*4 | | ffi_call_SYSV - |--------------------------------------------| | - | GPR registers r3-r10 8*4 | | ffi_call_SYSV - |--------------------------------------------| | - | FPR registers f1-f8 (optional) 8*8 | | - |--------------------------------------------| | stack | - | Space for copied structures | | grows | - |--------------------------------------------| | down V - | Parameters that didn't fit in registers | | - |--------------------------------------------| | lower addresses - | Space for callee's LR 4 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 4 |-/ during - |--------------------------------------------| <<< ffi_call_SYSV - -*/ - -void FFI_HIDDEN -ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack) -{ - const unsigned bytes = ecif->cif->bytes; - const unsigned flags = ecif->cif->flags; - - typedef union - { - char *c; - unsigned *u; - long long *ll; - float *f; - double *d; - } valp; - - /* 'stacktop' points at the previous backchain pointer. */ - valp stacktop; - - /* 'gpr_base' points at the space for gpr3, and grows upwards as - we use GPR registers. */ - valp gpr_base; - int intarg_count; - -#ifndef __NO_FPRS__ - /* 'fpr_base' points at the space for fpr1, and grows upwards as - we use FPR registers. */ - valp fpr_base; - int fparg_count; -#endif - - /* 'copy_space' grows down as we put structures in it. It should - stay 16-byte aligned. */ - valp copy_space; - - /* 'next_arg' grows up as we put parameters in it. */ - valp next_arg; - - int i; - ffi_type **ptr; -#ifndef __NO_FPRS__ - double double_tmp; -#endif - union - { - void **v; - char **c; - signed char **sc; - unsigned char **uc; - signed short **ss; - unsigned short **us; - unsigned int **ui; - long long **ll; - float **f; - double **d; - } p_argv; - size_t struct_copy_size; - unsigned gprvalue; - - stacktop.c = (char *) stack + bytes; - gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS; - intarg_count = 0; -#ifndef __NO_FPRS__ - fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS; - fparg_count = 0; - copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c); -#else - copy_space.c = gpr_base.c; -#endif - next_arg.u = stack + 2; - - /* Check that everything starts aligned properly. */ - FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0); - FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0); - FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0); - FFI_ASSERT ((bytes & 0xF) == 0); - FFI_ASSERT (copy_space.c >= next_arg.c); - - /* Deal with return values that are actually pass-by-reference. */ - if (flags & FLAG_RETVAL_REFERENCE) - { - *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue; - intarg_count++; - } - - /* Now for the arguments. */ - p_argv.v = ecif->avalue; - for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs; - i > 0; - i--, ptr++, p_argv.v++) - { - unsigned int typenum = (*ptr)->type; - - typenum = translate_float (ecif->cif->abi, typenum); - - /* Now test the translated value */ - switch (typenum) - { -#ifndef __NO_FPRS__ -# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - double_tmp = (*p_argv.d)[0]; - - if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1) - { - if (intarg_count >= NUM_GPR_ARG_REGISTERS - && intarg_count % 2 != 0) - { - intarg_count++; - next_arg.u++; - } - *next_arg.d = double_tmp; - next_arg.u += 2; - double_tmp = (*p_argv.d)[1]; - *next_arg.d = double_tmp; - next_arg.u += 2; - } - else - { - *fpr_base.d++ = double_tmp; - double_tmp = (*p_argv.d)[1]; - *fpr_base.d++ = double_tmp; - } - - fparg_count += 2; - FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); - break; -# endif - case FFI_TYPE_DOUBLE: - double_tmp = **p_argv.d; - - if (fparg_count >= NUM_FPR_ARG_REGISTERS) - { - if (intarg_count >= NUM_GPR_ARG_REGISTERS - && intarg_count % 2 != 0) - { - intarg_count++; - next_arg.u++; - } - *next_arg.d = double_tmp; - next_arg.u += 2; - } - else - *fpr_base.d++ = double_tmp; - fparg_count++; - FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); - break; - - case FFI_TYPE_FLOAT: - double_tmp = **p_argv.f; - if (fparg_count >= NUM_FPR_ARG_REGISTERS) - { - *next_arg.f = (float) double_tmp; - next_arg.u += 1; - intarg_count++; - } - else - *fpr_base.d++ = double_tmp; - fparg_count++; - FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); - break; -#endif /* have FPRs */ - - case FFI_TYPE_UINT128: - /* The soft float ABI for long doubles works like this, a long double - is passed in four consecutive GPRs if available. A maximum of 2 - long doubles can be passed in gprs. If we do not have 4 GPRs - left, the long double is passed on the stack, 4-byte aligned. */ - { - unsigned int int_tmp; - unsigned int ii; - if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) - { - if (intarg_count < NUM_GPR_ARG_REGISTERS) - intarg_count = NUM_GPR_ARG_REGISTERS; - for (ii = 0; ii < 4; ii++) - { - int_tmp = (*p_argv.ui)[ii]; - *next_arg.u++ = int_tmp; - } - } - else - { - for (ii = 0; ii < 4; ii++) - { - int_tmp = (*p_argv.ui)[ii]; - *gpr_base.u++ = int_tmp; - } - } - intarg_count += 4; - break; - } - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - if (intarg_count == NUM_GPR_ARG_REGISTERS-1) - intarg_count++; - if (intarg_count >= NUM_GPR_ARG_REGISTERS) - { - if (intarg_count % 2 != 0) - { - intarg_count++; - next_arg.u++; - } - *next_arg.ll = **p_argv.ll; - next_arg.u += 2; - } - else - { - /* The abi states only certain register pairs can be - used for passing long long int specifically (r3,r4), - (r5,r6), (r7,r8), (r9,r10). If next arg is long long - but not correct starting register of pair then skip - until the proper starting register. */ - if (intarg_count % 2 != 0) - { - intarg_count ++; - gpr_base.u++; - } - *gpr_base.ll++ = **p_argv.ll; - } - intarg_count += 2; - break; - - case FFI_TYPE_STRUCT: - struct_copy_size = ((*ptr)->size + 15) & ~0xF; - copy_space.c -= struct_copy_size; - memcpy (copy_space.c, *p_argv.c, (*ptr)->size); - - gprvalue = (unsigned long) copy_space.c; - - FFI_ASSERT (copy_space.c > next_arg.c); - FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY); - goto putgpr; - - case FFI_TYPE_UINT8: - gprvalue = **p_argv.uc; - goto putgpr; - case FFI_TYPE_SINT8: - gprvalue = **p_argv.sc; - goto putgpr; - case FFI_TYPE_UINT16: - gprvalue = **p_argv.us; - goto putgpr; - case FFI_TYPE_SINT16: - gprvalue = **p_argv.ss; - goto putgpr; - - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - - gprvalue = **p_argv.ui; - - putgpr: - if (intarg_count >= NUM_GPR_ARG_REGISTERS) - *next_arg.u++ = gprvalue; - else - *gpr_base.u++ = gprvalue; - intarg_count++; - break; - } - } - - /* Check that we didn't overrun the stack... */ - FFI_ASSERT (copy_space.c >= next_arg.c); - FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS); - /* The assert below is testing that the number of integer arguments agrees - with the number found in ffi_prep_cif_machdep(). However, intarg_count - is incremented whenever we place an FP arg on the stack, so account for - that before our assert test. */ -#ifndef __NO_FPRS__ - if (fparg_count > NUM_FPR_ARG_REGISTERS) - intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS; - FFI_ASSERT (fpr_base.u - <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); -#endif - FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); -} - -#define MIN_CACHE_LINE_SIZE 8 - -static void -flush_icache (char *wraddr, char *xaddr, int size) -{ - int i; - for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) - __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" - : : "r" (xaddr + i), "r" (wraddr + i) : "memory"); - __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;" - : : "r"(xaddr + size - 1), "r"(wraddr + size - 1) - : "memory"); -} - -ffi_status FFI_HIDDEN -ffi_prep_closure_loc_sysv (ffi_closure *closure, - ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - void *codeloc) -{ - unsigned int *tramp; - - if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI) - return FFI_BAD_ABI; - - tramp = (unsigned int *) &closure->tramp[0]; - tramp[0] = 0x7c0802a6; /* mflr r0 */ - tramp[1] = 0x429f0005; /* bcl 20,31,.+4 */ - tramp[2] = 0x7d6802a6; /* mflr r11 */ - tramp[3] = 0x7c0803a6; /* mtlr r0 */ - tramp[4] = 0x800b0018; /* lwz r0,24(r11) */ - tramp[5] = 0x816b001c; /* lwz r11,28(r11) */ - tramp[6] = 0x7c0903a6; /* mtctr r0 */ - tramp[7] = 0x4e800420; /* bctr */ - *(void **) &tramp[8] = (void *) ffi_closure_SYSV; /* function */ - *(void **) &tramp[9] = codeloc; /* context */ - - /* Flush the icache. */ - flush_icache ((char *)tramp, (char *)codeloc, 8 * 4); - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -/* Basically the trampoline invokes ffi_closure_SYSV, and on - entry, r11 holds the address of the closure. - After storing the registers that could possibly contain - parameters to be passed into the stack frame and setting - up space for a return value, ffi_closure_SYSV invokes the - following helper function to do most of the work. */ - -int -ffi_closure_helper_SYSV (ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - void *rvalue, - unsigned long *pgr, - ffi_dblfl *pfr, - unsigned long *pst) -{ - /* rvalue is the pointer to space for return value in closure assembly */ - /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */ - /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */ - /* pst is the pointer to outgoing parameter stack in original caller */ - - void ** avalue; - ffi_type ** arg_types; - long i, avn; -#ifndef __NO_FPRS__ - long nf = 0; /* number of floating registers already used */ -#endif - long ng = 0; /* number of general registers already used */ - - unsigned size = cif->rtype->size; - unsigned short rtypenum = cif->rtype->type; - - avalue = alloca (cif->nargs * sizeof (void *)); - - /* First translate for softfloat/nonlinux */ - rtypenum = translate_float (cif->abi, rtypenum); - - /* Copy the caller's structure return value address so that the closure - returns the data directly to the caller. - For FFI_SYSV the result is passed in r3/r4 if the struct size is less - or equal 8 bytes. */ - if (rtypenum == FFI_TYPE_STRUCT - && !((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)) - { - rvalue = (void *) *pgr; - ng++; - pgr++; - } - - i = 0; - avn = cif->nargs; - arg_types = cif->arg_types; - - /* Grab the addresses of the arguments from the stack frame. */ - while (i < avn) { - unsigned short typenum = arg_types[i]->type; - - /* We may need to handle some values depending on ABI. */ - typenum = translate_float (cif->abi, typenum); - - switch (typenum) - { -#ifndef __NO_FPRS__ - case FFI_TYPE_FLOAT: - /* Unfortunately float values are stored as doubles - in the ffi_closure_SYSV code (since we don't check - the type in that routine). */ - if (nf < NUM_FPR_ARG_REGISTERS) - { - /* FIXME? here we are really changing the values - stored in the original calling routines outgoing - parameter stack. This is probably a really - naughty thing to do but... */ - double temp = pfr->d; - pfr->f = (float) temp; - avalue[i] = pfr; - nf++; - pfr++; - } - else - { - avalue[i] = pst; - pst += 1; - } - break; - - case FFI_TYPE_DOUBLE: - if (nf < NUM_FPR_ARG_REGISTERS) - { - avalue[i] = pfr; - nf++; - pfr++; - } - else - { - if (((long) pst) & 4) - pst++; - avalue[i] = pst; - pst += 2; - } - break; - -# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - if (nf < NUM_FPR_ARG_REGISTERS - 1) - { - avalue[i] = pfr; - pfr += 2; - nf += 2; - } - else - { - if (((long) pst) & 4) - pst++; - avalue[i] = pst; - pst += 4; - nf = 8; - } - break; -# endif -#endif - - case FFI_TYPE_UINT128: - /* Test if for the whole long double, 4 gprs are available. - otherwise the stuff ends up on the stack. */ - if (ng < NUM_GPR_ARG_REGISTERS - 3) - { - avalue[i] = pgr; - pgr += 4; - ng += 4; - } - else - { - avalue[i] = pst; - pst += 4; - ng = 8+4; - } - break; - - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: -#ifndef __LITTLE_ENDIAN__ - if (ng < NUM_GPR_ARG_REGISTERS) - { - avalue[i] = (char *) pgr + 3; - ng++; - pgr++; - } - else - { - avalue[i] = (char *) pst + 3; - pst++; - } - break; -#endif - - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: -#ifndef __LITTLE_ENDIAN__ - if (ng < NUM_GPR_ARG_REGISTERS) - { - avalue[i] = (char *) pgr + 2; - ng++; - pgr++; - } - else - { - avalue[i] = (char *) pst + 2; - pst++; - } - break; -#endif - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - if (ng < NUM_GPR_ARG_REGISTERS) - { - avalue[i] = pgr; - ng++; - pgr++; - } - else - { - avalue[i] = pst; - pst++; - } - break; - - case FFI_TYPE_STRUCT: - /* Structs are passed by reference. The address will appear in a - gpr if it is one of the first 8 arguments. */ - if (ng < NUM_GPR_ARG_REGISTERS) - { - avalue[i] = (void *) *pgr; - ng++; - pgr++; - } - else - { - avalue[i] = (void *) *pst; - pst++; - } - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - /* Passing long long ints are complex, they must - be passed in suitable register pairs such as - (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10) - and if the entire pair aren't available then the outgoing - parameter stack is used for both but an alignment of 8 - must will be kept. So we must either look in pgr - or pst to find the correct address for this type - of parameter. */ - if (ng < NUM_GPR_ARG_REGISTERS - 1) - { - if (ng & 1) - { - /* skip r4, r6, r8 as starting points */ - ng++; - pgr++; - } - avalue[i] = pgr; - ng += 2; - pgr += 2; - } - else - { - if (((long) pst) & 4) - pst++; - avalue[i] = pst; - pst += 2; - ng = NUM_GPR_ARG_REGISTERS; - } - break; - - default: - FFI_ASSERT (0); - } - - i++; - } - - (*fun) (cif, rvalue, avalue, user_data); - - /* Tell ffi_closure_SYSV how to perform return type promotions. - Because the FFI_SYSV ABI returns the structures <= 8 bytes in - r3/r4 we have to tell ffi_closure_SYSV how to treat them. We - combine the base type FFI_SYSV_TYPE_SMALL_STRUCT with the size of - the struct less one. We never have a struct with size zero. - See the comment in ffitarget.h about ordering. */ - if (rtypenum == FFI_TYPE_STRUCT - && (cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8) - return FFI_SYSV_TYPE_SMALL_STRUCT - 1 + size; - return rtypenum; -} -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ffitarget.h b/user/mpy/lib/libffi/src/powerpc/ffitarget.h deleted file mode 100644 index 0f66d31..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ffitarget.h +++ /dev/null @@ -1,195 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc - Copyright (c) 1996-2003 Red Hat, Inc. - - Target configuration macros for PowerPC. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -#if defined (POWERPC) && defined (__powerpc64__) /* linux64 */ -#ifndef POWERPC64 -#define POWERPC64 -#endif -#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */ -#ifndef POWERPC64 -#define POWERPC64 -#endif -#ifndef POWERPC_DARWIN64 -#define POWERPC_DARWIN64 -#endif -#elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */ -#ifndef POWERPC64 -#define POWERPC64 -#endif -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - -#if defined (POWERPC_AIX) - FFI_AIX, - FFI_DARWIN, - FFI_DEFAULT_ABI = FFI_AIX, - FFI_LAST_ABI - -#elif defined (POWERPC_DARWIN) - FFI_AIX, - FFI_DARWIN, - FFI_DEFAULT_ABI = FFI_DARWIN, - FFI_LAST_ABI - -#else - /* The FFI_COMPAT values are used by old code. Since libffi may be - a shared library we have to support old values for backwards - compatibility. */ - FFI_COMPAT_SYSV, - FFI_COMPAT_GCC_SYSV, - FFI_COMPAT_LINUX64, - FFI_COMPAT_LINUX, - FFI_COMPAT_LINUX_SOFT_FLOAT, - -# if defined (POWERPC64) - /* This bit, always set in new code, must not be set in any of the - old FFI_COMPAT values that might be used for 64-bit linux. We - only need worry about FFI_COMPAT_LINUX64, but to be safe avoid - all old values. */ - FFI_LINUX = 8, - /* This and following bits can reuse FFI_COMPAT values. */ - FFI_LINUX_STRUCT_ALIGN = 1, - FFI_LINUX_LONG_DOUBLE_128 = 2, - FFI_DEFAULT_ABI = (FFI_LINUX -# ifdef __STRUCT_PARM_ALIGN__ - | FFI_LINUX_STRUCT_ALIGN -# endif -# ifdef __LONG_DOUBLE_128__ - | FFI_LINUX_LONG_DOUBLE_128 -# endif - ), - FFI_LAST_ABI = 12 - -# else - /* This bit, always set in new code, must not be set in any of the - old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd. */ - FFI_SYSV = 8, - /* This and following bits can reuse FFI_COMPAT values. */ - FFI_SYSV_SOFT_FLOAT = 1, - FFI_SYSV_STRUCT_RET = 2, - FFI_SYSV_IBM_LONG_DOUBLE = 4, - FFI_SYSV_LONG_DOUBLE_128 = 16, - - FFI_DEFAULT_ABI = (FFI_SYSV -# ifdef __NO_FPRS__ - | FFI_SYSV_SOFT_FLOAT -# endif -# if (defined (__SVR4_STRUCT_RETURN) \ - || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN)) - | FFI_SYSV_STRUCT_RET -# endif -# if __LDBL_MANT_DIG__ == 106 - | FFI_SYSV_IBM_LONG_DOUBLE -# endif -# ifdef __LONG_DOUBLE_128__ - | FFI_SYSV_LONG_DOUBLE_128 -# endif - ), - FFI_LAST_ABI = 32 -# endif -#endif - -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 -#if defined (POWERPC) || defined (POWERPC_FREEBSD) -# define FFI_GO_CLOSURES 1 -# define FFI_TARGET_SPECIFIC_VARIADIC 1 -# define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs -#endif - -/* ppc_closure.S and linux64_closure.S expect this. */ -#define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER - -/* We define additional types below. If generic types are added that - must be supported by powerpc libffi then it is likely that - FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in - ppc_closure.S and linux64_closure.S be extended. */ - -#if !(FFI_TYPE_LAST == FFI_PPC_TYPE_LAST \ - || (FFI_TYPE_LAST == FFI_TYPE_COMPLEX \ - && !defined FFI_TARGET_HAS_COMPLEX_TYPE)) -# error "You likely have a broken powerpc libffi" -#endif - -/* Needed for soft-float long-double-128 support. */ -#define FFI_TYPE_UINT128 (FFI_PPC_TYPE_LAST + 1) - -/* Needed for FFI_SYSV small structure returns. */ -#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2) - -/* Used by ELFv2 for homogenous structure returns. */ -#define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 1) -#define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 2) -#define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 3) - -#if _CALL_ELF == 2 -# define FFI_TRAMPOLINE_SIZE 32 -#else -# if defined(POWERPC64) || defined(POWERPC_AIX) -# if defined(POWERPC_DARWIN64) -# define FFI_TRAMPOLINE_SIZE 48 -# else -# define FFI_TRAMPOLINE_SIZE 24 -# endif -# else /* POWERPC || POWERPC_AIX */ -# define FFI_TRAMPOLINE_SIZE 40 -# endif -#endif - -#ifndef LIBFFI_ASM -#if defined(POWERPC_DARWIN) || defined(POWERPC_AIX) -struct ffi_aix_trampoline_struct { - void * code_pointer; /* Pointer to ffi_closure_ASM */ - void * toc; /* TOC */ - void * static_chain; /* Pointer to closure */ -}; -#endif -#endif - -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/linux64.S b/user/mpy/lib/libffi/src/powerpc/linux64.S deleted file mode 100644 index b2ae60e..0000000 --- a/user/mpy/lib/libffi/src/powerpc/linux64.S +++ /dev/null @@ -1,228 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.h - Copyright (c) 2003 Jakub Jelinek - Copyright (c) 2008 Red Hat, Inc. - - PowerPC64 Assembly glue. - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -#ifdef POWERPC64 - .hidden ffi_call_LINUX64 - .globl ffi_call_LINUX64 - .text - .cfi_startproc -# if _CALL_ELF == 2 -ffi_call_LINUX64: - addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha - addi %r2, %r2, .TOC.-ffi_call_LINUX64@l - .localentry ffi_call_LINUX64, . - ffi_call_LINUX64 -# else - .section ".opd","aw" - .align 3 -ffi_call_LINUX64: -# ifdef _CALL_LINUX - .quad .L.ffi_call_LINUX64,.TOC.@tocbase,0 - .type ffi_call_LINUX64,@function - .text -.L.ffi_call_LINUX64: -# else - .hidden .ffi_call_LINUX64 - .globl .ffi_call_LINUX64 - .quad .ffi_call_LINUX64,.TOC.@tocbase,0 - .size ffi_call_LINUX64,24 - .type .ffi_call_LINUX64,@function - .text -.ffi_call_LINUX64: -# endif -# endif - mflr %r0 - std %r28, -32(%r1) - std %r29, -24(%r1) - std %r30, -16(%r1) - std %r31, -8(%r1) - std %r7, 8(%r1) /* closure, saved in cr field. */ - std %r0, 16(%r1) - - mr %r28, %r1 /* our AP. */ - .cfi_def_cfa_register 28 - .cfi_offset 65, 16 - .cfi_offset 31, -8 - .cfi_offset 30, -16 - .cfi_offset 29, -24 - .cfi_offset 28, -32 - - stdux %r1, %r1, %r8 - mr %r31, %r6 /* flags, */ - mr %r30, %r5 /* rvalue, */ - mr %r29, %r4 /* function address. */ -/* Save toc pointer, not for the ffi_prep_args64 call, but for the later - bctrl function call. */ -# if _CALL_ELF == 2 - std %r2, 24(%r1) -# else - std %r2, 40(%r1) -# endif - - /* Call ffi_prep_args64. */ - mr %r4, %r1 -# if defined _CALL_LINUX || _CALL_ELF == 2 - bl ffi_prep_args64 -# else - bl .ffi_prep_args64 -# endif - -# if _CALL_ELF == 2 - mr %r12, %r29 -# else - ld %r12, 0(%r29) - ld %r2, 8(%r29) -# endif - /* Now do the call. */ - /* Set up cr1 with bits 4-7 of the flags. */ - mtcrf 0x40, %r31 - - /* Get the address to call into CTR. */ - mtctr %r12 - /* Load all those argument registers. */ - ld %r3, -32-(8*8)(%r28) - ld %r4, -32-(7*8)(%r28) - ld %r5, -32-(6*8)(%r28) - ld %r6, -32-(5*8)(%r28) - bf- 5, 1f - ld %r7, -32-(4*8)(%r28) - ld %r8, -32-(3*8)(%r28) - ld %r9, -32-(2*8)(%r28) - ld %r10, -32-(1*8)(%r28) -1: - - /* Load all the FP registers. */ - bf- 6, 2f - lfd %f1, -32-(21*8)(%r28) - lfd %f2, -32-(20*8)(%r28) - lfd %f3, -32-(19*8)(%r28) - lfd %f4, -32-(18*8)(%r28) - lfd %f5, -32-(17*8)(%r28) - lfd %f6, -32-(16*8)(%r28) - lfd %f7, -32-(15*8)(%r28) - lfd %f8, -32-(14*8)(%r28) - lfd %f9, -32-(13*8)(%r28) - lfd %f10, -32-(12*8)(%r28) - lfd %f11, -32-(11*8)(%r28) - lfd %f12, -32-(10*8)(%r28) - lfd %f13, -32-(9*8)(%r28) -2: - - /* Make the call. */ - ld %r11, 8(%r28) - bctrl - - /* This must follow the call immediately, the unwinder - uses this to find out if r2 has been saved or not. */ -# if _CALL_ELF == 2 - ld %r2, 24(%r1) -# else - ld %r2, 40(%r1) -# endif - - /* Now, deal with the return value. */ - mtcrf 0x01, %r31 - bt 31, .Lstruct_return_value - bt 30, .Ldone_return_value - bt 29, .Lfp_return_value - std %r3, 0(%r30) - /* Fall through... */ - -.Ldone_return_value: - /* Restore the registers we used and return. */ - mr %r1, %r28 - .cfi_def_cfa_register 1 - ld %r0, 16(%r28) - ld %r28, -32(%r28) - mtlr %r0 - ld %r29, -24(%r1) - ld %r30, -16(%r1) - ld %r31, -8(%r1) - blr - -.Lfp_return_value: - .cfi_def_cfa_register 28 - bf 28, .Lfloat_return_value - stfd %f1, 0(%r30) - mtcrf 0x02, %r31 /* cr6 */ - bf 27, .Ldone_return_value - stfd %f2, 8(%r30) - b .Ldone_return_value -.Lfloat_return_value: - stfs %f1, 0(%r30) - b .Ldone_return_value - -.Lstruct_return_value: - bf 29, .Lsmall_struct - bf 28, .Lfloat_homog_return_value - stfd %f1, 0(%r30) - stfd %f2, 8(%r30) - stfd %f3, 16(%r30) - stfd %f4, 24(%r30) - stfd %f5, 32(%r30) - stfd %f6, 40(%r30) - stfd %f7, 48(%r30) - stfd %f8, 56(%r30) - b .Ldone_return_value - -.Lfloat_homog_return_value: - stfs %f1, 0(%r30) - stfs %f2, 4(%r30) - stfs %f3, 8(%r30) - stfs %f4, 12(%r30) - stfs %f5, 16(%r30) - stfs %f6, 20(%r30) - stfs %f7, 24(%r30) - stfs %f8, 28(%r30) - b .Ldone_return_value - -.Lsmall_struct: - std %r3, 0(%r30) - std %r4, 8(%r30) - b .Ldone_return_value - - .cfi_endproc -# if _CALL_ELF == 2 - .size ffi_call_LINUX64,.-ffi_call_LINUX64 -# else -# ifdef _CALL_LINUX - .size ffi_call_LINUX64,.-.L.ffi_call_LINUX64 -# else - .long 0 - .byte 0,12,0,1,128,4,0,0 - .size .ffi_call_LINUX64,.-.ffi_call_LINUX64 -# endif -# endif - -#endif - -#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2 - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/linux64_closure.S b/user/mpy/lib/libffi/src/powerpc/linux64_closure.S deleted file mode 100644 index 6487d2a..0000000 --- a/user/mpy/lib/libffi/src/powerpc/linux64_closure.S +++ /dev/null @@ -1,488 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.h - Copyright (c) 2003 Jakub Jelinek - Copyright (c) 2008 Red Hat, Inc. - - PowerPC64 Assembly glue. - - 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. - ----------------------------------------------------------------------- */ -#define LIBFFI_ASM -#include -#include - - .file "linux64_closure.S" - -#ifdef POWERPC64 - FFI_HIDDEN (ffi_closure_LINUX64) - .globl ffi_closure_LINUX64 - .text - .cfi_startproc -# if _CALL_ELF == 2 -ffi_closure_LINUX64: - addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha - addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l - .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64 -# else - .section ".opd","aw" - .align 3 -ffi_closure_LINUX64: -# ifdef _CALL_LINUX - .quad .L.ffi_closure_LINUX64,.TOC.@tocbase,0 - .type ffi_closure_LINUX64,@function - .text -.L.ffi_closure_LINUX64: -# else - FFI_HIDDEN (.ffi_closure_LINUX64) - .globl .ffi_closure_LINUX64 - .quad .ffi_closure_LINUX64,.TOC.@tocbase,0 - .size ffi_closure_LINUX64,24 - .type .ffi_closure_LINUX64,@function - .text -.ffi_closure_LINUX64: -# endif -# endif - -# if _CALL_ELF == 2 -# 32 byte special reg save area + 64 byte parm save area -# + 64 byte retval area + 13*8 fpr save area + round to 16 -# define STACKFRAME 272 -# define PARMSAVE 32 -# define RETVAL PARMSAVE+64 -# else -# 48 bytes special reg save area + 64 bytes parm save area -# + 16 bytes retval area + 13*8 bytes fpr save area + round to 16 -# define STACKFRAME 240 -# define PARMSAVE 48 -# define RETVAL PARMSAVE+64 -# endif - -# if _CALL_ELF == 2 - ld %r12, FFI_TRAMPOLINE_SIZE(%r11) # closure->cif - mflr %r0 - lwz %r12, 28(%r12) # cif->flags - mtcrf 0x40, %r12 - addi %r12, %r1, PARMSAVE - bt 7, 0f - # Our caller has not allocated a parameter save area. - # We need to allocate one here and use it to pass gprs to - # ffi_closure_helper_LINUX64. - addi %r12, %r1, -STACKFRAME+PARMSAVE -0: - # Save general regs into parm save area - std %r3, 0(%r12) - std %r4, 8(%r12) - std %r5, 16(%r12) - std %r6, 24(%r12) - std %r7, 32(%r12) - std %r8, 40(%r12) - std %r9, 48(%r12) - std %r10, 56(%r12) - - # load up the pointer to the parm save area - mr %r7, %r12 -# else - # copy r2 to r11 and load TOC into r2 - mr %r11, %r2 - ld %r2, 16(%r2) - - mflr %r0 - # Save general regs into parm save area - # This is the parameter save area set up by our caller. - std %r3, PARMSAVE+0(%r1) - std %r4, PARMSAVE+8(%r1) - std %r5, PARMSAVE+16(%r1) - std %r6, PARMSAVE+24(%r1) - std %r7, PARMSAVE+32(%r1) - std %r8, PARMSAVE+40(%r1) - std %r9, PARMSAVE+48(%r1) - std %r10, PARMSAVE+56(%r1) - - # load up the pointer to the parm save area - addi %r7, %r1, PARMSAVE -# endif - std %r0, 16(%r1) - - # closure->cif - ld %r3, FFI_TRAMPOLINE_SIZE(%r11) - # closure->fun - ld %r4, FFI_TRAMPOLINE_SIZE+8(%r11) - # closure->user_data - ld %r5, FFI_TRAMPOLINE_SIZE+16(%r11) - -.Ldoclosure: - # next save fpr 1 to fpr 13 - stfd %f1, -104+(0*8)(%r1) - stfd %f2, -104+(1*8)(%r1) - stfd %f3, -104+(2*8)(%r1) - stfd %f4, -104+(3*8)(%r1) - stfd %f5, -104+(4*8)(%r1) - stfd %f6, -104+(5*8)(%r1) - stfd %f7, -104+(6*8)(%r1) - stfd %f8, -104+(7*8)(%r1) - stfd %f9, -104+(8*8)(%r1) - stfd %f10, -104+(9*8)(%r1) - stfd %f11, -104+(10*8)(%r1) - stfd %f12, -104+(11*8)(%r1) - stfd %f13, -104+(12*8)(%r1) - - # load up the pointer to the saved fpr registers */ - addi %r8, %r1, -104 - - # load up the pointer to the result storage - addi %r6, %r1, -STACKFRAME+RETVAL - - stdu %r1, -STACKFRAME(%r1) - .cfi_def_cfa_offset STACKFRAME - .cfi_offset 65, 16 - - # make the call -# if defined _CALL_LINUX || _CALL_ELF == 2 - bl ffi_closure_helper_LINUX64 -# else - bl .ffi_closure_helper_LINUX64 -# endif -.Lret: - - # now r3 contains the return type - # so use it to look up in a table - # so we know how to deal with each type - - # look up the proper starting point in table - # by using return type as offset - ld %r0, STACKFRAME+16(%r1) - cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT - bge .Lsmall - mflr %r4 # move address of .Lret to r4 - sldi %r3, %r3, 4 # now multiply return type by 16 - addi %r4, %r4, .Lret_type0 - .Lret - add %r3, %r3, %r4 # add contents of table to table address - mtctr %r3 - bctr # jump to it - -# Each of the ret_typeX code fragments has to be exactly 16 bytes long -# (4 instructions). For cache effectiveness we align to a 16 byte boundary -# first. - .align 4 - -.Lret_type0: -# case FFI_TYPE_VOID - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME - nop -# case FFI_TYPE_INT -# ifdef __LITTLE_ENDIAN__ - lwa %r3, RETVAL+0(%r1) -# else - lwa %r3, RETVAL+4(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_FLOAT - lfs %f1, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_DOUBLE - lfd %f1, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_LONGDOUBLE - lfd %f1, RETVAL+0(%r1) - mtlr %r0 - lfd %f2, RETVAL+8(%r1) - b .Lfinish -# case FFI_TYPE_UINT8 -# ifdef __LITTLE_ENDIAN__ - lbz %r3, RETVAL+0(%r1) -# else - lbz %r3, RETVAL+7(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_SINT8 -# ifdef __LITTLE_ENDIAN__ - lbz %r3, RETVAL+0(%r1) -# else - lbz %r3, RETVAL+7(%r1) -# endif - extsb %r3,%r3 - mtlr %r0 - b .Lfinish -# case FFI_TYPE_UINT16 -# ifdef __LITTLE_ENDIAN__ - lhz %r3, RETVAL+0(%r1) -# else - lhz %r3, RETVAL+6(%r1) -# endif - mtlr %r0 -.Lfinish: - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_SINT16 -# ifdef __LITTLE_ENDIAN__ - lha %r3, RETVAL+0(%r1) -# else - lha %r3, RETVAL+6(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_UINT32 -# ifdef __LITTLE_ENDIAN__ - lwz %r3, RETVAL+0(%r1) -# else - lwz %r3, RETVAL+4(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_SINT32 -# ifdef __LITTLE_ENDIAN__ - lwa %r3, RETVAL+0(%r1) -# else - lwa %r3, RETVAL+4(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_UINT64 - ld %r3, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_SINT64 - ld %r3, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_TYPE_STRUCT - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME - nop -# case FFI_TYPE_POINTER - ld %r3, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -# case FFI_V2_TYPE_FLOAT_HOMOG - lfs %f1, RETVAL+0(%r1) - lfs %f2, RETVAL+4(%r1) - lfs %f3, RETVAL+8(%r1) - b .Lmorefloat -# case FFI_V2_TYPE_DOUBLE_HOMOG - lfd %f1, RETVAL+0(%r1) - lfd %f2, RETVAL+8(%r1) - lfd %f3, RETVAL+16(%r1) - lfd %f4, RETVAL+24(%r1) - mtlr %r0 - lfd %f5, RETVAL+32(%r1) - lfd %f6, RETVAL+40(%r1) - lfd %f7, RETVAL+48(%r1) - lfd %f8, RETVAL+56(%r1) - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -.Lmorefloat: - lfs %f4, RETVAL+12(%r1) - mtlr %r0 - lfs %f5, RETVAL+16(%r1) - lfs %f6, RETVAL+20(%r1) - lfs %f7, RETVAL+24(%r1) - lfs %f8, RETVAL+28(%r1) - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -.Lsmall: -# ifdef __LITTLE_ENDIAN__ - ld %r3,RETVAL+0(%r1) - mtlr %r0 - ld %r4,RETVAL+8(%r1) - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr -# else - # A struct smaller than a dword is returned in the low bits of r3 - # ie. right justified. Larger structs are passed left justified - # in r3 and r4. The return value area on the stack will have - # the structs as they are usually stored in memory. - cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT + 7 # size 8 bytes? - neg %r5, %r3 - ld %r3,RETVAL+0(%r1) - blt .Lsmalldown - mtlr %r0 - ld %r4,RETVAL+8(%r1) - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset STACKFRAME -.Lsmalldown: - addi %r5, %r5, FFI_V2_TYPE_SMALL_STRUCT + 7 - mtlr %r0 - sldi %r5, %r5, 3 - addi %r1, %r1, STACKFRAME - .cfi_def_cfa_offset 0 - srd %r3, %r3, %r5 - blr -# endif - - .cfi_endproc -# if _CALL_ELF == 2 - .size ffi_closure_LINUX64,.-ffi_closure_LINUX64 -# else -# ifdef _CALL_LINUX - .size ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64 -# else - .long 0 - .byte 0,12,0,1,128,0,0,0 - .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64 -# endif -# endif - - - FFI_HIDDEN (ffi_go_closure_linux64) - .globl ffi_go_closure_linux64 - .text - .cfi_startproc -# if _CALL_ELF == 2 -ffi_go_closure_linux64: - addis %r2, %r12, .TOC.-ffi_go_closure_linux64@ha - addi %r2, %r2, .TOC.-ffi_go_closure_linux64@l - .localentry ffi_go_closure_linux64, . - ffi_go_closure_linux64 -# else - .section ".opd","aw" - .align 3 -ffi_go_closure_linux64: -# ifdef _CALL_LINUX - .quad .L.ffi_go_closure_linux64,.TOC.@tocbase,0 - .type ffi_go_closure_linux64,@function - .text -.L.ffi_go_closure_linux64: -# else - FFI_HIDDEN (.ffi_go_closure_linux64) - .globl .ffi_go_closure_linux64 - .quad .ffi_go_closure_linux64,.TOC.@tocbase,0 - .size ffi_go_closure_linux64,24 - .type .ffi_go_closure_linux64,@function - .text -.ffi_go_closure_linux64: -# endif -# endif - -# if _CALL_ELF == 2 - ld %r12, 8(%r11) # closure->cif - mflr %r0 - lwz %r12, 28(%r12) # cif->flags - mtcrf 0x40, %r12 - addi %r12, %r1, PARMSAVE - bt 7, 0f - # Our caller has not allocated a parameter save area. - # We need to allocate one here and use it to pass gprs to - # ffi_closure_helper_LINUX64. - addi %r12, %r1, -STACKFRAME+PARMSAVE -0: - # Save general regs into parm save area - std %r3, 0(%r12) - std %r4, 8(%r12) - std %r5, 16(%r12) - std %r6, 24(%r12) - std %r7, 32(%r12) - std %r8, 40(%r12) - std %r9, 48(%r12) - std %r10, 56(%r12) - - # load up the pointer to the parm save area - mr %r7, %r12 -# else - mflr %r0 - # Save general regs into parm save area - # This is the parameter save area set up by our caller. - std %r3, PARMSAVE+0(%r1) - std %r4, PARMSAVE+8(%r1) - std %r5, PARMSAVE+16(%r1) - std %r6, PARMSAVE+24(%r1) - std %r7, PARMSAVE+32(%r1) - std %r8, PARMSAVE+40(%r1) - std %r9, PARMSAVE+48(%r1) - std %r10, PARMSAVE+56(%r1) - - # load up the pointer to the parm save area - addi %r7, %r1, PARMSAVE -# endif - std %r0, 16(%r1) - - # closure->cif - ld %r3, 8(%r11) - # closure->fun - ld %r4, 16(%r11) - # user_data - mr %r5, %r11 - b .Ldoclosure - - .cfi_endproc -# if _CALL_ELF == 2 - .size ffi_go_closure_linux64,.-ffi_go_closure_linux64 -# else -# ifdef _CALL_LINUX - .size ffi_go_closure_linux64,.-.L.ffi_go_closure_linux64 -# else - .long 0 - .byte 0,12,0,1,128,0,0,0 - .size .ffi_go_closure_linux64,.-.ffi_go_closure_linux64 -# endif -# endif -#endif - -#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2 - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/ppc_closure.S b/user/mpy/lib/libffi/src/powerpc/ppc_closure.S deleted file mode 100644 index b6d209d..0000000 --- a/user/mpy/lib/libffi/src/powerpc/ppc_closure.S +++ /dev/null @@ -1,397 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.h - Copyright (c) 2003 Jakub Jelinek - Copyright (c) 2008 Red Hat, Inc. - - PowerPC Assembly glue. - - 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. - ----------------------------------------------------------------------- */ -#define LIBFFI_ASM -#include -#include -#include - - .file "ppc_closure.S" - -#ifndef POWERPC64 - -FFI_HIDDEN(ffi_closure_SYSV) -ENTRY(ffi_closure_SYSV) - .cfi_startproc - stwu %r1,-144(%r1) - .cfi_def_cfa_offset 144 - mflr %r0 - stw %r0,148(%r1) - .cfi_offset 65, 4 - -# we want to build up an areas for the parameters passed -# in registers (both floating point and integer) - - # so first save gpr 3 to gpr 10 (aligned to 4) - stw %r3, 16(%r1) - stw %r4, 20(%r1) - stw %r5, 24(%r1) - - # set up registers for the routine that does the work - - # closure->cif - lwz %r3,FFI_TRAMPOLINE_SIZE(%r11) - # closure->fun - lwz %r4,FFI_TRAMPOLINE_SIZE+4(%r11) - # closure->user_data - lwz %r5,FFI_TRAMPOLINE_SIZE+8(%r11) - -.Ldoclosure: - stw %r6, 28(%r1) - stw %r7, 32(%r1) - stw %r8, 36(%r1) - stw %r9, 40(%r1) - stw %r10,44(%r1) - -#ifndef __NO_FPRS__ - # next save fpr 1 to fpr 8 (aligned to 8) - stfd %f1, 48(%r1) - stfd %f2, 56(%r1) - stfd %f3, 64(%r1) - stfd %f4, 72(%r1) - stfd %f5, 80(%r1) - stfd %f6, 88(%r1) - stfd %f7, 96(%r1) - stfd %f8, 104(%r1) -#endif - - # pointer to the result storage - addi %r6,%r1,112 - - # pointer to the saved gpr registers - addi %r7,%r1,16 - - # pointer to the saved fpr registers - addi %r8,%r1,48 - - # pointer to the outgoing parameter save area in the previous frame - # i.e. the previous frame pointer + 8 - addi %r9,%r1,152 - - # make the call - bl ffi_closure_helper_SYSV@local -.Lret: - # now r3 contains the return type - # so use it to look up in a table - # so we know how to deal with each type - - # look up the proper starting point in table - # by using return type as offset - - mflr %r4 # move address of .Lret to r4 - slwi %r3,%r3,4 # now multiply return type by 16 - addi %r4, %r4, .Lret_type0 - .Lret - lwz %r0,148(%r1) - add %r3,%r3,%r4 # add contents of table to table address - mtctr %r3 - bctr # jump to it - -# Each of the ret_typeX code fragments has to be exactly 16 bytes long -# (4 instructions). For cache effectiveness we align to a 16 byte boundary -# first. - .align 4 -# case FFI_TYPE_VOID -.Lret_type0: - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - nop - -# case FFI_TYPE_INT - lwz %r3,112+0(%r1) - mtlr %r0 -.Lfinish: - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_FLOAT -#ifndef __NO_FPRS__ - lfs %f1,112+0(%r1) -#else - nop -#endif - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_DOUBLE -#ifndef __NO_FPRS__ - lfd %f1,112+0(%r1) -#else - nop -#endif - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_LONGDOUBLE -#ifndef __NO_FPRS__ - lfd %f1,112+0(%r1) - lfd %f2,112+8(%r1) - mtlr %r0 - b .Lfinish -#else - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - nop -#endif - -# case FFI_TYPE_UINT8 -#ifdef __LITTLE_ENDIAN__ - lbz %r3,112+0(%r1) -#else - lbz %r3,112+3(%r1) -#endif - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_SINT8 -#ifdef __LITTLE_ENDIAN__ - lbz %r3,112+0(%r1) -#else - lbz %r3,112+3(%r1) -#endif - extsb %r3,%r3 - mtlr %r0 - b .Lfinish - -# case FFI_TYPE_UINT16 -#ifdef __LITTLE_ENDIAN__ - lhz %r3,112+0(%r1) -#else - lhz %r3,112+2(%r1) -#endif - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_SINT16 -#ifdef __LITTLE_ENDIAN__ - lha %r3,112+0(%r1) -#else - lha %r3,112+2(%r1) -#endif - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_UINT32 - lwz %r3,112+0(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_SINT32 - lwz %r3,112+0(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_UINT64 - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) - mtlr %r0 - b .Lfinish - -# case FFI_TYPE_SINT64 - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) - mtlr %r0 - b .Lfinish - -# case FFI_TYPE_STRUCT - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - nop - -# case FFI_TYPE_POINTER - lwz %r3,112+0(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_TYPE_UINT128 - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) - lwz %r5,112+8(%r1) - b .Luint128 - -# The return types below are only used when the ABI type is FFI_SYSV. -# case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct. - lbz %r3,112+0(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 2. Two byte struct. - lhz %r3,112+0(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct. - lwz %r3,112+0(%r1) -#ifdef __LITTLE_ENDIAN__ - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 -#else - srwi %r3,%r3,8 - mtlr %r0 - b .Lfinish -#endif - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct. - lwz %r3,112+0(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct. - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) -#ifdef __LITTLE_ENDIAN__ - mtlr %r0 - b .Lfinish -#else - li %r5,24 - b .Lstruct567 -#endif - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct. - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) -#ifdef __LITTLE_ENDIAN__ - mtlr %r0 - b .Lfinish -#else - li %r5,16 - b .Lstruct567 -#endif - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct. - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) -#ifdef __LITTLE_ENDIAN__ - mtlr %r0 - b .Lfinish -#else - li %r5,8 - b .Lstruct567 -#endif - -# case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct. - lwz %r3,112+0(%r1) - lwz %r4,112+4(%r1) - mtlr %r0 - b .Lfinish - -#ifndef __LITTLE_ENDIAN__ -.Lstruct567: - subfic %r6,%r5,32 - srw %r4,%r4,%r5 - slw %r6,%r3,%r6 - srw %r3,%r3,%r5 - or %r4,%r6,%r4 - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_def_cfa_offset 144 -#endif - -.Luint128: - lwz %r6,112+12(%r1) - mtlr %r0 - addi %r1,%r1,144 - .cfi_def_cfa_offset 0 - blr - .cfi_endproc -END(ffi_closure_SYSV) - - -FFI_HIDDEN(ffi_go_closure_sysv) -ENTRY(ffi_go_closure_sysv) - .cfi_startproc - stwu %r1,-144(%r1) - .cfi_def_cfa_offset 144 - mflr %r0 - stw %r0,148(%r1) - .cfi_offset 65, 4 - - stw %r3, 16(%r1) - stw %r4, 20(%r1) - stw %r5, 24(%r1) - - # closure->cif - lwz %r3,4(%r11) - # closure->fun - lwz %r4,8(%r11) - # user_data - mr %r5,%r11 - b .Ldoclosure - .cfi_endproc -END(ffi_go_closure_sysv) - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif -#endif diff --git a/user/mpy/lib/libffi/src/powerpc/sysv.S b/user/mpy/lib/libffi/src/powerpc/sysv.S deleted file mode 100644 index 1474ce7..0000000 --- a/user/mpy/lib/libffi/src/powerpc/sysv.S +++ /dev/null @@ -1,175 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 1998 Geoffrey Keating - Copyright (C) 2007 Free Software Foundation, Inc - - PowerPC Assembly glue. - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#include - -#ifndef POWERPC64 -FFI_HIDDEN(ffi_call_SYSV) -ENTRY(ffi_call_SYSV) - .cfi_startproc - /* Save the old stack pointer as AP. */ - mr %r10,%r1 - .cfi_def_cfa_register 10 - - /* Allocate the stack space we need. */ - stwux %r1,%r1,%r8 - /* Save registers we use. */ - mflr %r9 - stw %r28,-16(%r10) - stw %r29,-12(%r10) - stw %r30, -8(%r10) - stw %r31, -4(%r10) - stw %r9, 4(%r10) - .cfi_offset 65, 4 - .cfi_offset 31, -4 - .cfi_offset 30, -8 - .cfi_offset 29, -12 - .cfi_offset 28, -16 - - /* Save arguments over call... */ - stw %r7, -20(%r10) /* closure, */ - mr %r31,%r6 /* flags, */ - mr %r30,%r5 /* rvalue, */ - mr %r29,%r4 /* function address, */ - mr %r28,%r10 /* our AP. */ - .cfi_def_cfa_register 28 - - /* Call ffi_prep_args_SYSV. */ - mr %r4,%r1 - bl ffi_prep_args_SYSV@local - - /* Now do the call. */ - /* Set up cr1 with bits 4-7 of the flags. */ - mtcrf 0x40,%r31 - /* Get the address to call into CTR. */ - mtctr %r29 - /* Load all those argument registers. */ - lwz %r3,-24-(8*4)(%r28) - lwz %r4,-24-(7*4)(%r28) - lwz %r5,-24-(6*4)(%r28) - lwz %r6,-24-(5*4)(%r28) - bf- 5,1f - nop - lwz %r7,-24-(4*4)(%r28) - lwz %r8,-24-(3*4)(%r28) - lwz %r9,-24-(2*4)(%r28) - lwz %r10,-24-(1*4)(%r28) - nop -1: - -#ifndef __NO_FPRS__ - /* Load all the FP registers. */ - bf- 6,2f - lfd %f1,-24-(8*4)-(8*8)(%r28) - lfd %f2,-24-(8*4)-(7*8)(%r28) - lfd %f3,-24-(8*4)-(6*8)(%r28) - lfd %f4,-24-(8*4)-(5*8)(%r28) - nop - lfd %f5,-24-(8*4)-(4*8)(%r28) - lfd %f6,-24-(8*4)-(3*8)(%r28) - lfd %f7,-24-(8*4)-(2*8)(%r28) - lfd %f8,-24-(8*4)-(1*8)(%r28) -#endif -2: - - /* Make the call. */ - lwz %r11, -20(%r28) - bctrl - - /* Now, deal with the return value. */ - mtcrf 0x01,%r31 /* cr7 */ - bt- 31,L(small_struct_return_value) - bt- 30,L(done_return_value) -#ifndef __NO_FPRS__ - bt- 29,L(fp_return_value) -#endif - stw %r3,0(%r30) - bf+ 28,L(done_return_value) - stw %r4,4(%r30) - mtcrf 0x02,%r31 /* cr6 */ - bf 27,L(done_return_value) - stw %r5,8(%r30) - stw %r6,12(%r30) - /* Fall through... */ - -L(done_return_value): - /* Restore the registers we used and return. */ - lwz %r9, 4(%r28) - lwz %r31, -4(%r28) - mtlr %r9 - lwz %r30, -8(%r28) - lwz %r29,-12(%r28) - lwz %r28,-16(%r28) - .cfi_remember_state - /* At this point we don't have a cfa register. Say all our - saved regs have been restored. */ - .cfi_same_value 65 - .cfi_same_value 31 - .cfi_same_value 30 - .cfi_same_value 29 - .cfi_same_value 28 - /* Hopefully this works.. */ - .cfi_def_cfa_register 1 - .cfi_offset 1, 0 - lwz %r1,0(%r1) - .cfi_same_value 1 - blr - -#ifndef __NO_FPRS__ -L(fp_return_value): - .cfi_restore_state - bf 28,L(float_return_value) - stfd %f1,0(%r30) - mtcrf 0x02,%r31 /* cr6 */ - bf 27,L(done_return_value) - stfd %f2,8(%r30) - b L(done_return_value) -L(float_return_value): - stfs %f1,0(%r30) - b L(done_return_value) -#endif - -L(small_struct_return_value): - /* - * The C code always allocates a properly-aligned 8-byte bounce - * buffer to make this assembly code very simple. Just write out - * r3 and r4 to the buffer to allow the C code to handle the rest. - */ - stw %r3, 0(%r30) - stw %r4, 4(%r30) - b L(done_return_value) - .cfi_endproc - -END(ffi_call_SYSV) - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif -#endif diff --git a/user/mpy/lib/libffi/src/prep_cif.c b/user/mpy/lib/libffi/src/prep_cif.c deleted file mode 100644 index 5881ceb..0000000 --- a/user/mpy/lib/libffi/src/prep_cif.c +++ /dev/null @@ -1,242 +0,0 @@ -/* ----------------------------------------------------------------------- - prep_cif.c - Copyright (c) 2011, 2012 Anthony Green - Copyright (c) 1996, 1998, 2007 Red Hat, Inc. - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include - -/* Round up to FFI_SIZEOF_ARG. */ - -#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG) - -/* Perform machine independent initialization of aggregate type - specifications. */ - -static ffi_status initialize_aggregate(ffi_type *arg) -{ - ffi_type **ptr; - - if (UNLIKELY(arg == NULL || arg->elements == NULL)) - return FFI_BAD_TYPEDEF; - - arg->size = 0; - arg->alignment = 0; - - ptr = &(arg->elements[0]); - - if (UNLIKELY(ptr == 0)) - return FFI_BAD_TYPEDEF; - - while ((*ptr) != NULL) - { - if (UNLIKELY(((*ptr)->size == 0) - && (initialize_aggregate((*ptr)) != FFI_OK))) - return FFI_BAD_TYPEDEF; - - /* Perform a sanity check on the argument type */ - FFI_ASSERT_VALID_TYPE(*ptr); - - arg->size = ALIGN(arg->size, (*ptr)->alignment); - arg->size += (*ptr)->size; - - arg->alignment = (arg->alignment > (*ptr)->alignment) ? - arg->alignment : (*ptr)->alignment; - - ptr++; - } - - /* Structure size includes tail padding. This is important for - structures that fit in one register on ABIs like the PowerPC64 - Linux ABI that right justify small structs in a register. - It's also needed for nested structure layout, for example - struct A { long a; char b; }; struct B { struct A x; char y; }; - should find y at an offset of 2*sizeof(long) and result in a - total size of 3*sizeof(long). */ - arg->size = ALIGN (arg->size, arg->alignment); - - /* On some targets, the ABI defines that structures have an additional - alignment beyond the "natural" one based on their elements. */ -#ifdef FFI_AGGREGATE_ALIGNMENT - if (FFI_AGGREGATE_ALIGNMENT > arg->alignment) - arg->alignment = FFI_AGGREGATE_ALIGNMENT; -#endif - - if (arg->size == 0) - return FFI_BAD_TYPEDEF; - else - return FFI_OK; -} - -#ifndef __CRIS__ -/* The CRIS ABI specifies structure elements to have byte - alignment only, so it completely overrides this functions, - which assumes "natural" alignment and padding. */ - -/* Perform machine independent ffi_cif preparation, then call - machine dependent routine. */ - -/* For non variadic functions isvariadic should be 0 and - nfixedargs==ntotalargs. - - For variadic calls, isvariadic should be 1 and nfixedargs - and ntotalargs set as appropriate. nfixedargs must always be >=1 */ - - -ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, - unsigned int isvariadic, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, ffi_type **atypes) -{ - unsigned bytes = 0; - unsigned int i; - ffi_type **ptr; - - FFI_ASSERT(cif != NULL); - FFI_ASSERT((!isvariadic) || (nfixedargs >= 1)); - FFI_ASSERT(nfixedargs <= ntotalargs); - - if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)) - return FFI_BAD_ABI; - - cif->abi = abi; - cif->arg_types = atypes; - cif->nargs = ntotalargs; - cif->rtype = rtype; - - cif->flags = 0; - -#if HAVE_LONG_DOUBLE_VARIANT - ffi_prep_types (abi); -#endif - - /* Initialize the return type if necessary */ - if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK)) - return FFI_BAD_TYPEDEF; - -#ifndef FFI_TARGET_HAS_COMPLEX_TYPE - if (rtype->type == FFI_TYPE_COMPLEX) - abort(); -#endif - /* Perform a sanity check on the return type */ - FFI_ASSERT_VALID_TYPE(cif->rtype); - - /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */ -#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION - /* Make space for the return structure pointer */ - if (cif->rtype->type == FFI_TYPE_STRUCT -#ifdef TILE - && (cif->rtype->size > 10 * FFI_SIZEOF_ARG) -#endif -#ifdef XTENSA - && (cif->rtype->size > 16) -#endif -#ifdef NIOS2 - && (cif->rtype->size > 8) -#endif - ) - bytes = STACK_ARG_SIZE(sizeof(void*)); -#endif - - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) - { - - /* Initialize any uninitialized aggregate type definitions */ - if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK)) - return FFI_BAD_TYPEDEF; - -#ifndef FFI_TARGET_HAS_COMPLEX_TYPE - if ((*ptr)->type == FFI_TYPE_COMPLEX) - abort(); -#endif - /* Perform a sanity check on the argument type, do this - check after the initialization. */ - FFI_ASSERT_VALID_TYPE(*ptr); - -#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION - { - /* Add any padding if necessary */ - if (((*ptr)->alignment - 1) & bytes) - bytes = (unsigned)ALIGN(bytes, (*ptr)->alignment); - -#ifdef TILE - if (bytes < 10 * FFI_SIZEOF_ARG && - bytes + STACK_ARG_SIZE((*ptr)->size) > 10 * FFI_SIZEOF_ARG) - { - /* An argument is never split between the 10 parameter - registers and the stack. */ - bytes = 10 * FFI_SIZEOF_ARG; - } -#endif -#ifdef XTENSA - if (bytes <= 6*4 && bytes + STACK_ARG_SIZE((*ptr)->size) > 6*4) - bytes = 6*4; -#endif - - bytes += STACK_ARG_SIZE((*ptr)->size); - } -#endif - } - - cif->bytes = bytes; - - /* Perform machine dependent cif processing */ -#ifdef FFI_TARGET_SPECIFIC_VARIADIC - if (isvariadic) - return ffi_prep_cif_machdep_var(cif, nfixedargs, ntotalargs); -#endif - - return ffi_prep_cif_machdep(cif); -} -#endif /* not __CRIS__ */ - -ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, - ffi_type *rtype, ffi_type **atypes) -{ - return ffi_prep_cif_core(cif, abi, 0, nargs, nargs, rtype, atypes); -} - -ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes) -{ - return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes); -} - -#if FFI_CLOSURES - -ffi_status -ffi_prep_closure (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data) -{ - return ffi_prep_closure_loc (closure, cif, fun, user_data, closure); -} - -#endif diff --git a/user/mpy/lib/libffi/src/raw_api.c b/user/mpy/lib/libffi/src/raw_api.c deleted file mode 100644 index 276cb22..0000000 --- a/user/mpy/lib/libffi/src/raw_api.c +++ /dev/null @@ -1,267 +0,0 @@ -/* ----------------------------------------------------------------------- - raw_api.c - Copyright (c) 1999, 2008 Red Hat, Inc. - - Author: Kresten Krab Thorup - - 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. - ----------------------------------------------------------------------- */ - -/* This file defines generic functions for use with the raw api. */ - -#include -#include - -#if !FFI_NO_RAW_API - -size_t -ffi_raw_size (ffi_cif *cif) -{ - size_t result = 0; - int i; - - ffi_type **at = cif->arg_types; - - for (i = cif->nargs-1; i >= 0; i--, at++) - { -#if !FFI_NO_STRUCTS - if ((*at)->type == FFI_TYPE_STRUCT) - result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG); - else -#endif - result += ALIGN ((*at)->size, FFI_SIZEOF_ARG); - } - - return result; -} - - -void -ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args) -{ - unsigned i; - ffi_type **tp = cif->arg_types; - -#if WORDS_BIGENDIAN - - for (i = 0; i < cif->nargs; i++, tp++, args++) - { - switch ((*tp)->type) - { - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1); - break; - - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2); - break; - -#if FFI_SIZEOF_ARG >= 4 - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4); - break; -#endif - -#if !FFI_NO_STRUCTS - case FFI_TYPE_STRUCT: - *args = (raw++)->ptr; - break; -#endif - - case FFI_TYPE_COMPLEX: - *args = (raw++)->ptr; - break; - - case FFI_TYPE_POINTER: - *args = (void*) &(raw++)->ptr; - break; - - default: - *args = raw; - raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - } - } - -#else /* WORDS_BIGENDIAN */ - -#if !PDP - - /* then assume little endian */ - for (i = 0; i < cif->nargs; i++, tp++, args++) - { -#if !FFI_NO_STRUCTS - if ((*tp)->type == FFI_TYPE_STRUCT) - { - *args = (raw++)->ptr; - } - else -#endif - if ((*tp)->type == FFI_TYPE_COMPLEX) - { - *args = (raw++)->ptr; - } - else - { - *args = (void*) raw; - raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*); - } - } - -#else -#error "pdp endian not supported" -#endif /* ! PDP */ - -#endif /* WORDS_BIGENDIAN */ -} - -void -ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw) -{ - unsigned i; - ffi_type **tp = cif->arg_types; - - for (i = 0; i < cif->nargs; i++, tp++, args++) - { - switch ((*tp)->type) - { - case FFI_TYPE_UINT8: - (raw++)->uint = *(UINT8*) (*args); - break; - - case FFI_TYPE_SINT8: - (raw++)->sint = *(SINT8*) (*args); - break; - - case FFI_TYPE_UINT16: - (raw++)->uint = *(UINT16*) (*args); - break; - - case FFI_TYPE_SINT16: - (raw++)->sint = *(SINT16*) (*args); - break; - -#if FFI_SIZEOF_ARG >= 4 - case FFI_TYPE_UINT32: - (raw++)->uint = *(UINT32*) (*args); - break; - - case FFI_TYPE_SINT32: - (raw++)->sint = *(SINT32*) (*args); - break; -#endif - -#if !FFI_NO_STRUCTS - case FFI_TYPE_STRUCT: - (raw++)->ptr = *args; - break; -#endif - - case FFI_TYPE_COMPLEX: - (raw++)->ptr = *args; - break; - - case FFI_TYPE_POINTER: - (raw++)->ptr = **(void***) args; - break; - - default: - memcpy ((void*) raw->data, (void*)*args, (*tp)->size); - raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - } - } -} - -#if !FFI_NATIVE_RAW_API - - -/* This is a generic definition of ffi_raw_call, to be used if the - * native system does not provide a machine-specific implementation. - * Having this, allows code to be written for the raw API, without - * the need for system-specific code to handle input in that format; - * these following couple of functions will handle the translation forth - * and back automatically. */ - -void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw) -{ - void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); - ffi_raw_to_ptrarray (cif, raw, avalue); - ffi_call (cif, fn, rvalue, avalue); -} - -#if FFI_CLOSURES /* base system provides closures */ - -static void -ffi_translate_args (ffi_cif *cif, void *rvalue, - void **avalue, void *user_data) -{ - ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif)); - ffi_raw_closure *cl = (ffi_raw_closure*)user_data; - - ffi_ptrarray_to_raw (cif, avalue, raw); - (*cl->fun) (cif, rvalue, raw, cl->user_data); -} - -ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure* cl, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc) -{ - ffi_status status; - - status = ffi_prep_closure_loc ((ffi_closure*) cl, - cif, - &ffi_translate_args, - codeloc, - codeloc); - if (status == FFI_OK) - { - cl->fun = fun; - cl->user_data = user_data; - } - - return status; -} - -#endif /* FFI_CLOSURES */ -#endif /* !FFI_NATIVE_RAW_API */ - -#if FFI_CLOSURES - -/* Again, here is the generic version of ffi_prep_raw_closure, which - * will install an intermediate "hub" for translation of arguments from - * the pointer-array format, to the raw format */ - -ffi_status -ffi_prep_raw_closure (ffi_raw_closure* cl, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data) -{ - return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl); -} - -#endif /* FFI_CLOSURES */ - -#endif /* !FFI_NO_RAW_API */ diff --git a/user/mpy/lib/libffi/src/s390/ffi.c b/user/mpy/lib/libffi/src/s390/ffi.c deleted file mode 100644 index 4035b6e..0000000 --- a/user/mpy/lib/libffi/src/s390/ffi.c +++ /dev/null @@ -1,756 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2000, 2007 Software AG - Copyright (c) 2008 Red Hat, Inc - - S390 Foreign Function Interface - - 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 AUTHOR 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. - ----------------------------------------------------------------------- */ -/*====================================================================*/ -/* Includes */ -/* -------- */ -/*====================================================================*/ - -#include -#include -#include -#include "internal.h" - -/*====================== End of Includes =============================*/ - -/*====================================================================*/ -/* Defines */ -/* ------- */ -/*====================================================================*/ - -/* Maximum number of GPRs available for argument passing. */ -#define MAX_GPRARGS 5 - -/* Maximum number of FPRs available for argument passing. */ -#ifdef __s390x__ -#define MAX_FPRARGS 4 -#else -#define MAX_FPRARGS 2 -#endif - -/* Round to multiple of 16. */ -#define ROUND_SIZE(size) (((size) + 15) & ~15) - -/*===================== End of Defines ===============================*/ - -/*====================================================================*/ -/* Externals */ -/* --------- */ -/*====================================================================*/ - -struct call_frame -{ - void *back_chain; - void *eos; - unsigned long gpr_args[5]; - unsigned long gpr_save[9]; - unsigned long long fpr_args[4]; -}; - -extern void FFI_HIDDEN ffi_call_SYSV(struct call_frame *, unsigned, void *, - void (*fn)(void), void *); - -extern void ffi_closure_SYSV(void); -extern void ffi_go_closure_SYSV(void); - -/*====================== End of Externals ============================*/ - -/*====================================================================*/ -/* */ -/* Name - ffi_check_struct_type. */ -/* */ -/* Function - Determine if a structure can be passed within a */ -/* general purpose or floating point register. */ -/* */ -/*====================================================================*/ - -static int -ffi_check_struct_type (ffi_type *arg) -{ - size_t size = arg->size; - - /* If the struct has just one element, look at that element - to find out whether to consider the struct as floating point. */ - while (arg->type == FFI_TYPE_STRUCT - && arg->elements[0] && !arg->elements[1]) - arg = arg->elements[0]; - - /* Structs of size 1, 2, 4, and 8 are passed in registers, - just like the corresponding int/float types. */ - switch (size) - { - case 1: - return FFI_TYPE_UINT8; - - case 2: - return FFI_TYPE_UINT16; - - case 4: - if (arg->type == FFI_TYPE_FLOAT) - return FFI_TYPE_FLOAT; - else - return FFI_TYPE_UINT32; - - case 8: - if (arg->type == FFI_TYPE_DOUBLE) - return FFI_TYPE_DOUBLE; - else - return FFI_TYPE_UINT64; - - default: - break; - } - - /* Other structs are passed via a pointer to the data. */ - return FFI_TYPE_POINTER; -} - -/*======================== End of Routine ============================*/ - -/*====================================================================*/ -/* */ -/* Name - ffi_prep_cif_machdep. */ -/* */ -/* Function - Perform machine dependent CIF processing. */ -/* */ -/*====================================================================*/ - -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep(ffi_cif *cif) -{ - size_t struct_size = 0; - int n_gpr = 0; - int n_fpr = 0; - int n_ov = 0; - - ffi_type **ptr; - int i; - - /* Determine return value handling. */ - - switch (cif->rtype->type) - { - /* Void is easy. */ - case FFI_TYPE_VOID: - cif->flags = FFI390_RET_VOID; - break; - - /* Structures and complex are returned via a hidden pointer. */ - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: - cif->flags = FFI390_RET_STRUCT; - n_gpr++; /* We need one GPR to pass the pointer. */ - break; - - /* Floating point values are returned in fpr 0. */ - case FFI_TYPE_FLOAT: - cif->flags = FFI390_RET_FLOAT; - break; - - case FFI_TYPE_DOUBLE: - cif->flags = FFI390_RET_DOUBLE; - break; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - cif->flags = FFI390_RET_STRUCT; - n_gpr++; - break; -#endif - /* Integer values are returned in gpr 2 (and gpr 3 - for 64-bit values on 31-bit machines). */ - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - cif->flags = FFI390_RET_INT64; - break; - - case FFI_TYPE_POINTER: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - /* These are to be extended to word size. */ -#ifdef __s390x__ - cif->flags = FFI390_RET_INT64; -#else - cif->flags = FFI390_RET_INT32; -#endif - break; - - default: - FFI_ASSERT (0); - break; - } - - /* Now for the arguments. */ - - for (ptr = cif->arg_types, i = cif->nargs; - i > 0; - i--, ptr++) - { - int type = (*ptr)->type; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - /* 16-byte long double is passed like a struct. */ - if (type == FFI_TYPE_LONGDOUBLE) - type = FFI_TYPE_STRUCT; -#endif - - /* Check how a structure type is passed. */ - if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX) - { - if (type == FFI_TYPE_COMPLEX) - type = FFI_TYPE_POINTER; - else - type = ffi_check_struct_type (*ptr); - - /* If we pass the struct via pointer, we must reserve space - to copy its data for proper call-by-value semantics. */ - if (type == FFI_TYPE_POINTER) - struct_size += ROUND_SIZE ((*ptr)->size); - } - - /* Now handle all primitive int/float data types. */ - switch (type) - { - /* The first MAX_FPRARGS floating point arguments - go in FPRs, the rest overflow to the stack. */ - - case FFI_TYPE_DOUBLE: - if (n_fpr < MAX_FPRARGS) - n_fpr++; - else - n_ov += sizeof (double) / sizeof (long); - break; - - case FFI_TYPE_FLOAT: - if (n_fpr < MAX_FPRARGS) - n_fpr++; - else - n_ov++; - break; - - /* On 31-bit machines, 64-bit integers are passed in GPR pairs, - if one is still available, or else on the stack. If only one - register is free, skip the register (it won't be used for any - subsequent argument either). */ - -#ifndef __s390x__ - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - if (n_gpr == MAX_GPRARGS-1) - n_gpr = MAX_GPRARGS; - if (n_gpr < MAX_GPRARGS) - n_gpr += 2; - else - n_ov += 2; - break; -#endif - - /* Everything else is passed in GPRs (until MAX_GPRARGS - have been used) or overflows to the stack. */ - - default: - if (n_gpr < MAX_GPRARGS) - n_gpr++; - else - n_ov++; - break; - } - } - - /* Total stack space as required for overflow arguments - and temporary structure copies. */ - - cif->bytes = ROUND_SIZE (n_ov * sizeof (long)) + struct_size; - - return FFI_OK; -} - -/*======================== End of Routine ============================*/ - -/*====================================================================*/ -/* */ -/* Name - ffi_call. */ -/* */ -/* Function - Call the FFI routine. */ -/* */ -/*====================================================================*/ - -static void -ffi_call_int(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue, - void *closure) -{ - int ret_type = cif->flags; - size_t rsize = 0, bytes = cif->bytes; - unsigned char *stack, *p_struct; - struct call_frame *frame; - unsigned long *p_ov, *p_gpr; - unsigned long long *p_fpr; - int n_fpr, n_gpr, n_ov, i, n; - ffi_type **arg_types; - - FFI_ASSERT (cif->abi == FFI_SYSV); - - /* If we don't have a return value, we need to fake one. */ - if (rvalue == NULL) - { - if (ret_type & FFI390_RET_IN_MEM) - rsize = cif->rtype->size; - else - ret_type = FFI390_RET_VOID; - } - - /* The stack space will be filled with those areas: - - dummy structure return (highest addresses) - FPR argument register save area - GPR argument register save area - stack frame for ffi_call_SYSV - temporary struct copies - overflow argument area (lowest addresses) - - We set up the following pointers: - - p_fpr: bottom of the FPR area (growing upwards) - p_gpr: bottom of the GPR area (growing upwards) - p_ov: bottom of the overflow area (growing upwards) - p_struct: top of the struct copy area (growing downwards) - - All areas are kept aligned to twice the word size. - - Note that we're going to create the stack frame for both - ffi_call_SYSV _and_ the target function right here. This - works because we don't make any function calls with more - than 5 arguments (indeed only memcpy and ffi_call_SYSV), - and thus we don't have any stacked outgoing parameters. */ - - stack = alloca (bytes + sizeof(struct call_frame) + rsize); - frame = (struct call_frame *)(stack + bytes); - if (rsize) - rvalue = frame + 1; - - /* Link the new frame back to the one from this function. */ - frame->back_chain = __builtin_frame_address (0); - - /* Fill in all of the argument stuff. */ - p_ov = (unsigned long *)stack; - p_struct = (unsigned char *)frame; - p_gpr = frame->gpr_args; - p_fpr = frame->fpr_args; - n_fpr = n_gpr = n_ov = 0; - - /* If we returning a structure then we set the first parameter register - to the address of where we are returning this structure. */ - if (cif->flags & FFI390_RET_IN_MEM) - p_gpr[n_gpr++] = (uintptr_t) rvalue; - - /* Now for the arguments. */ - arg_types = cif->arg_types; - for (i = 0, n = cif->nargs; i < n; ++i) - { - ffi_type *ty = arg_types[i]; - void *arg = avalue[i]; - int type = ty->type; - ffi_arg val; - - restart: - switch (type) - { - case FFI_TYPE_SINT8: - val = *(SINT8 *)arg; - goto do_int; - case FFI_TYPE_UINT8: - val = *(UINT8 *)arg; - goto do_int; - case FFI_TYPE_SINT16: - val = *(SINT16 *)arg; - goto do_int; - case FFI_TYPE_UINT16: - val = *(UINT16 *)arg; - goto do_int; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - val = *(SINT32 *)arg; - goto do_int; - case FFI_TYPE_UINT32: - val = *(UINT32 *)arg; - goto do_int; - case FFI_TYPE_POINTER: - val = *(uintptr_t *)arg; - do_int: - *(n_gpr < MAX_GPRARGS ? p_gpr + n_gpr++ : p_ov + n_ov++) = val; - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: -#ifdef __s390x__ - val = *(UINT64 *)arg; - goto do_int; -#else - if (n_gpr == MAX_GPRARGS-1) - n_gpr = MAX_GPRARGS; - if (n_gpr < MAX_GPRARGS) - p_gpr[n_gpr++] = ((UINT32 *) arg)[0], - p_gpr[n_gpr++] = ((UINT32 *) arg)[1]; - else - p_ov[n_ov++] = ((UINT32 *) arg)[0], - p_ov[n_ov++] = ((UINT32 *) arg)[1]; -#endif - break; - - case FFI_TYPE_DOUBLE: - if (n_fpr < MAX_FPRARGS) - p_fpr[n_fpr++] = *(UINT64 *) arg; - else - { -#ifdef __s390x__ - p_ov[n_ov++] = *(UINT64 *) arg; -#else - p_ov[n_ov++] = ((UINT32 *) arg)[0], - p_ov[n_ov++] = ((UINT32 *) arg)[1]; -#endif - } - break; - - case FFI_TYPE_FLOAT: - val = *(UINT32 *)arg; - if (n_fpr < MAX_FPRARGS) - p_fpr[n_fpr++] = (UINT64)val << 32; - else - p_ov[n_ov++] = val; - break; - - case FFI_TYPE_STRUCT: - /* Check how a structure type is passed. */ - type = ffi_check_struct_type (ty); - /* Some structures are passed via a type they contain. */ - if (type != FFI_TYPE_POINTER) - goto restart; - /* ... otherwise, passed by reference. fallthru. */ - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - /* 16-byte long double is passed via reference. */ -#endif - case FFI_TYPE_COMPLEX: - /* Complex types are passed via reference. */ - p_struct -= ROUND_SIZE (ty->size); - memcpy (p_struct, arg, ty->size); - val = (uintptr_t)p_struct; - goto do_int; - - default: - FFI_ASSERT (0); - break; - } - } - - ffi_call_SYSV (frame, ret_type & FFI360_RET_MASK, rvalue, fn, closure); -} - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int(cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int(cif, fn, rvalue, avalue, closure); -} - -/*======================== End of Routine ============================*/ - -/*====================================================================*/ -/* */ -/* Name - ffi_closure_helper_SYSV. */ -/* */ -/* Function - Call a FFI closure target function. */ -/* */ -/*====================================================================*/ - -void FFI_HIDDEN -ffi_closure_helper_SYSV (ffi_cif *cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - unsigned long *p_gpr, - unsigned long long *p_fpr, - unsigned long *p_ov) -{ - unsigned long long ret_buffer; - - void *rvalue = &ret_buffer; - void **avalue; - void **p_arg; - - int n_gpr = 0; - int n_fpr = 0; - int n_ov = 0; - - ffi_type **ptr; - int i; - - /* Allocate buffer for argument list pointers. */ - p_arg = avalue = alloca (cif->nargs * sizeof (void *)); - - /* If we returning a structure, pass the structure address - directly to the target function. Otherwise, have the target - function store the return value to the GPR save area. */ - if (cif->flags & FFI390_RET_IN_MEM) - rvalue = (void *) p_gpr[n_gpr++]; - - /* Now for the arguments. */ - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, p_arg++, ptr++) - { - int deref_struct_pointer = 0; - int type = (*ptr)->type; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - /* 16-byte long double is passed like a struct. */ - if (type == FFI_TYPE_LONGDOUBLE) - type = FFI_TYPE_STRUCT; -#endif - - /* Check how a structure type is passed. */ - if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX) - { - if (type == FFI_TYPE_COMPLEX) - type = FFI_TYPE_POINTER; - else - type = ffi_check_struct_type (*ptr); - - /* If we pass the struct via pointer, remember to - retrieve the pointer later. */ - if (type == FFI_TYPE_POINTER) - deref_struct_pointer = 1; - } - - /* Pointers are passed like UINTs of the same size. */ - if (type == FFI_TYPE_POINTER) - { -#ifdef __s390x__ - type = FFI_TYPE_UINT64; -#else - type = FFI_TYPE_UINT32; -#endif - } - - /* Now handle all primitive int/float data types. */ - switch (type) - { - case FFI_TYPE_DOUBLE: - if (n_fpr < MAX_FPRARGS) - *p_arg = &p_fpr[n_fpr++]; - else - *p_arg = &p_ov[n_ov], - n_ov += sizeof (double) / sizeof (long); - break; - - case FFI_TYPE_FLOAT: - if (n_fpr < MAX_FPRARGS) - *p_arg = &p_fpr[n_fpr++]; - else - *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4; - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: -#ifdef __s390x__ - if (n_gpr < MAX_GPRARGS) - *p_arg = &p_gpr[n_gpr++]; - else - *p_arg = &p_ov[n_ov++]; -#else - if (n_gpr == MAX_GPRARGS-1) - n_gpr = MAX_GPRARGS; - if (n_gpr < MAX_GPRARGS) - *p_arg = &p_gpr[n_gpr], n_gpr += 2; - else - *p_arg = &p_ov[n_ov], n_ov += 2; -#endif - break; - - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - if (n_gpr < MAX_GPRARGS) - *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 4; - else - *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4; - break; - - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - if (n_gpr < MAX_GPRARGS) - *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 2; - else - *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 2; - break; - - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - if (n_gpr < MAX_GPRARGS) - *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 1; - else - *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 1; - break; - - default: - FFI_ASSERT (0); - break; - } - - /* If this is a struct passed via pointer, we need to - actually retrieve that pointer. */ - if (deref_struct_pointer) - *p_arg = *(void **)*p_arg; - } - - - /* Call the target function. */ - (fun) (cif, rvalue, avalue, user_data); - - /* Convert the return value. */ - switch (cif->rtype->type) - { - /* Void is easy, and so is struct. */ - case FFI_TYPE_VOID: - case FFI_TYPE_STRUCT: - case FFI_TYPE_COMPLEX: -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: -#endif - break; - - /* Floating point values are returned in fpr 0. */ - case FFI_TYPE_FLOAT: - p_fpr[0] = (long long) *(unsigned int *) rvalue << 32; - break; - - case FFI_TYPE_DOUBLE: - p_fpr[0] = *(unsigned long long *) rvalue; - break; - - /* Integer values are returned in gpr 2 (and gpr 3 - for 64-bit values on 31-bit machines). */ - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: -#ifdef __s390x__ - p_gpr[0] = *(unsigned long *) rvalue; -#else - p_gpr[0] = ((unsigned long *) rvalue)[0], - p_gpr[1] = ((unsigned long *) rvalue)[1]; -#endif - break; - - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT32: - case FFI_TYPE_UINT16: - case FFI_TYPE_UINT8: - p_gpr[0] = *(unsigned long *) rvalue; - break; - - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_SINT16: - case FFI_TYPE_SINT8: - p_gpr[0] = *(signed long *) rvalue; - break; - - default: - FFI_ASSERT (0); - break; - } -} - -/*======================== End of Routine ============================*/ - -/*====================================================================*/ -/* */ -/* Name - ffi_prep_closure_loc. */ -/* */ -/* Function - Prepare a FFI closure. */ -/* */ -/*====================================================================*/ - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun) (ffi_cif *, void *, void **, void *), - void *user_data, - void *codeloc) -{ - static unsigned short const template[] = { - 0x0d10, /* basr %r1,0 */ -#ifndef __s390x__ - 0x9801, 0x1006, /* lm %r0,%r1,6(%r1) */ -#else - 0xeb01, 0x100e, 0x0004, /* lmg %r0,%r1,14(%r1) */ -#endif - 0x07f1 /* br %r1 */ - }; - - unsigned long *tramp = (unsigned long *)&closure->tramp; - - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - memcpy (tramp, template, sizeof(template)); - tramp[2] = (unsigned long)codeloc; - tramp[3] = (unsigned long)&ffi_closure_SYSV; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -/*======================== End of Routine ============================*/ - -/* Build a Go language closure. */ - -ffi_status -ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, - void (*fun)(ffi_cif*,void*,void**,void*)) -{ - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - closure->tramp = ffi_go_closure_SYSV; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/s390/ffitarget.h b/user/mpy/lib/libffi/src/s390/ffitarget.h deleted file mode 100644 index d8a4ee4..0000000 --- a/user/mpy/lib/libffi/src/s390/ffitarget.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for S390. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#if defined (__s390x__) -#ifndef S390X -#define S390X -#endif -#endif - -/* ---- System specific configurations ----------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION -#define FFI_TARGET_HAS_COMPLEX_TYPE - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_GO_CLOSURES 1 -#ifdef S390X -#define FFI_TRAMPOLINE_SIZE 32 -#else -#define FFI_TRAMPOLINE_SIZE 16 -#endif -#define FFI_NATIVE_RAW_API 0 - -#endif - diff --git a/user/mpy/lib/libffi/src/s390/internal.h b/user/mpy/lib/libffi/src/s390/internal.h deleted file mode 100644 index b875578..0000000 --- a/user/mpy/lib/libffi/src/s390/internal.h +++ /dev/null @@ -1,11 +0,0 @@ -/* If these values change, sysv.S must be adapted! */ -#define FFI390_RET_DOUBLE 0 -#define FFI390_RET_FLOAT 1 -#define FFI390_RET_INT64 2 -#define FFI390_RET_INT32 3 -#define FFI390_RET_VOID 4 - -#define FFI360_RET_MASK 7 -#define FFI390_RET_IN_MEM 8 - -#define FFI390_RET_STRUCT (FFI390_RET_VOID | FFI390_RET_IN_MEM) diff --git a/user/mpy/lib/libffi/src/s390/sysv.S b/user/mpy/lib/libffi/src/s390/sysv.S deleted file mode 100644 index c4b5006..0000000 --- a/user/mpy/lib/libffi/src/s390/sysv.S +++ /dev/null @@ -1,325 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2000 Software AG - Copyright (c) 2008 Red Hat, Inc. - - S390 Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - .text - -#ifndef __s390x__ - - # r2: frame - # r3: ret_type - # r4: ret_addr - # r5: fun - # r6: closure - - # This assumes we are using gas. - .balign 8 - .globl ffi_call_SYSV - FFI_HIDDEN(ffi_call_SYSV) - .type ffi_call_SYSV,%function -ffi_call_SYSV: - .cfi_startproc - st %r6,44(%r2) # Save registers - stm %r12,%r14,48(%r2) - lr %r13,%r2 # Install frame pointer - .cfi_rel_offset r6, 44 - .cfi_rel_offset r12, 48 - .cfi_rel_offset r13, 52 - .cfi_rel_offset r14, 56 - .cfi_def_cfa_register r13 - st %r2,0(%r15) # Set up back chain - sla %r3,3 # ret_type *= 8 - lr %r12,%r4 # Save ret_addr - lr %r1,%r5 # Save fun - lr %r0,%r6 # Install static chain - - # Set return address, so that there is only one indirect jump. -#ifdef HAVE_AS_S390_ZARCH - larl %r14,.Ltable - ar %r14,%r3 -#else - basr %r14,0 -0: la %r14,.Ltable-0b(%r14,%r3) -#endif - - lm %r2,%r6,8(%r13) # Load arguments - ld %f0,64(%r13) - ld %f2,72(%r13) - br %r1 # ... and call function - - .balign 8 -.Ltable: -# FFI390_RET_DOUBLE - std %f0,0(%r12) - j .Ldone - - .balign 8 -# FFI390_RET_FLOAT - ste %f0,0(%r12) - j .Ldone - - .balign 8 -# FFI390_RET_INT64 - st %r3,4(%r12) - nop - # fallthru - - .balign 8 -# FFI390_RET_INT32 - st %r2,0(%r12) - nop - # fallthru - - .balign 8 -# FFI390_RET_VOID -.Ldone: - l %r14,56(%r13) - l %r12,48(%r13) - l %r6,44(%r13) - l %r13,52(%r13) - .cfi_restore 14 - .cfi_restore 13 - .cfi_restore 12 - .cfi_restore 6 - .cfi_def_cfa r15, 96 - br %r14 - .cfi_endproc - .size ffi_call_SYSV,.-ffi_call_SYSV - - - .balign 8 - .globl ffi_go_closure_SYSV - FFI_HIDDEN(ffi_go_closure_SYSV) - .type ffi_go_closure_SYSV,%function -ffi_go_closure_SYSV: - .cfi_startproc - stm %r2,%r6,8(%r15) # Save arguments - lr %r4,%r0 # Load closure -> user_data - l %r2,4(%r4) # ->cif - l %r3,8(%r4) # ->fun - j .Ldoclosure - .cfi_endproc - - .balign 8 - .globl ffi_closure_SYSV - FFI_HIDDEN(ffi_closure_SYSV) - .type ffi_closure_SYSV,%function -ffi_closure_SYSV: - .cfi_startproc - stm %r2,%r6,8(%r15) # Save arguments - lr %r4,%r0 # Closure - l %r2,16(%r4) # ->cif - l %r3,20(%r4) # ->fun - l %r4,24(%r4) # ->user_data -.Ldoclosure: - stm %r12,%r15,48(%r15) # Save registers - lr %r12,%r15 - .cfi_def_cfa_register r12 - .cfi_rel_offset r6, 24 - .cfi_rel_offset r12, 48 - .cfi_rel_offset r13, 52 - .cfi_rel_offset r14, 56 - .cfi_rel_offset r15, 60 -#ifndef HAVE_AS_S390_ZARCH - basr %r13,0 # Set up base register -.Lcbase: - l %r1,.Lchelper-.Lcbase(%r13) # Get helper function -#endif - ahi %r15,-96-8 # Set up stack frame - st %r12,0(%r15) # Set up back chain - - std %f0,64(%r12) # Save fp arguments - std %f2,72(%r12) - - la %r5,96(%r12) # Overflow - st %r5,96(%r15) - la %r6,64(%r12) # FPRs - la %r5,8(%r12) # GPRs -#ifdef HAVE_AS_S390_ZARCH - brasl %r14,ffi_closure_helper_SYSV -#else - bas %r14,0(%r1,%r13) # Call helper -#endif - - lr %r15,%r12 - .cfi_def_cfa_register r15 - lm %r12,%r14,48(%r12) # Restore saved registers - l %r6,24(%r15) - ld %f0,64(%r15) # Load return registers - lm %r2,%r3,8(%r15) - br %r14 - .cfi_endproc - -#ifndef HAVE_AS_S390_ZARCH - .align 4 -.Lchelper: - .long ffi_closure_helper_SYSV-.Lcbase -#endif - - .size ffi_closure_SYSV,.-ffi_closure_SYSV - -#else - - # r2: frame - # r3: ret_type - # r4: ret_addr - # r5: fun - # r6: closure - - # This assumes we are using gas. - .balign 8 - .globl ffi_call_SYSV - FFI_HIDDEN(ffi_call_SYSV) - .type ffi_call_SYSV,%function -ffi_call_SYSV: - .cfi_startproc - stg %r6,88(%r2) # Save registers - stmg %r12,%r14,96(%r2) - lgr %r13,%r2 # Install frame pointer - .cfi_rel_offset r6, 88 - .cfi_rel_offset r12, 96 - .cfi_rel_offset r13, 104 - .cfi_rel_offset r14, 112 - .cfi_def_cfa_register r13 - stg %r2,0(%r15) # Set up back chain - larl %r14,.Ltable # Set up return address - slag %r3,%r3,3 # ret_type *= 8 - lgr %r12,%r4 # Save ret_addr - lgr %r1,%r5 # Save fun - lgr %r0,%r6 # Install static chain - agr %r14,%r3 - lmg %r2,%r6,16(%r13) # Load arguments - ld %f0,128(%r13) - ld %f2,136(%r13) - ld %f4,144(%r13) - ld %f6,152(%r13) - br %r1 # ... and call function - - .balign 8 -.Ltable: -# FFI390_RET_DOUBLE - std %f0,0(%r12) - j .Ldone - - .balign 8 -# FFI390_RET_DOUBLE - ste %f0,0(%r12) - j .Ldone - - .balign 8 -# FFI390_RET_INT64 - stg %r2,0(%r12) - - .balign 8 -# FFI390_RET_INT32 - # Never used, as we always store type ffi_arg. - # But the stg above is 6 bytes and we cannot - # jump around this case, so fall through. - nop - nop - - .balign 8 -# FFI390_RET_VOID -.Ldone: - lg %r14,112(%r13) - lg %r12,96(%r13) - lg %r6,88(%r13) - lg %r13,104(%r13) - .cfi_restore r14 - .cfi_restore r13 - .cfi_restore r12 - .cfi_restore r6 - .cfi_def_cfa r15, 160 - br %r14 - .cfi_endproc - .size ffi_call_SYSV,.-ffi_call_SYSV - - - .balign 8 - .globl ffi_go_closure_SYSV - FFI_HIDDEN(ffi_go_closure_SYSV) - .type ffi_go_closure_SYSV,%function -ffi_go_closure_SYSV: - .cfi_startproc - stmg %r2,%r6,16(%r15) # Save arguments - lgr %r4,%r0 # Load closure -> user_data - lg %r2,8(%r4) # ->cif - lg %r3,16(%r4) # ->fun - j .Ldoclosure - .cfi_endproc - .size ffi_go_closure_SYSV,.-ffi_go_closure_SYSV - - - .balign 8 - .globl ffi_closure_SYSV - FFI_HIDDEN(ffi_closure_SYSV) - .type ffi_closure_SYSV,%function -ffi_closure_SYSV: - .cfi_startproc - stmg %r2,%r6,16(%r15) # Save arguments - lgr %r4,%r0 # Load closure - lg %r2,32(%r4) # ->cif - lg %r3,40(%r4) # ->fun - lg %r4,48(%r4) # ->user_data -.Ldoclosure: - stmg %r13,%r15,104(%r15) # Save registers - lgr %r13,%r15 - .cfi_def_cfa_register r13 - .cfi_rel_offset r6, 48 - .cfi_rel_offset r13, 104 - .cfi_rel_offset r14, 112 - .cfi_rel_offset r15, 120 - aghi %r15,-160-16 # Set up stack frame - stg %r13,0(%r15) # Set up back chain - - std %f0,128(%r13) # Save fp arguments - std %f2,136(%r13) - std %f4,144(%r13) - std %f6,152(%r13) - la %r5,160(%r13) # Overflow - stg %r5,160(%r15) - la %r6,128(%r13) # FPRs - la %r5,16(%r13) # GPRs - brasl %r14,ffi_closure_helper_SYSV # Call helper - - lgr %r15,%r13 - .cfi_def_cfa_register r15 - lmg %r13,%r14,104(%r13) # Restore saved registers - lg %r6,48(%r15) - ld %f0,128(%r15) # Load return registers - lg %r2,16(%r15) - br %r14 - .cfi_endproc - .size ffi_closure_SYSV,.-ffi_closure_SYSV -#endif /* !s390x */ - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/sh/ffi.c b/user/mpy/lib/libffi/src/sh/ffi.c deleted file mode 100644 index 9ec86bf..0000000 --- a/user/mpy/lib/libffi/src/sh/ffi.c +++ /dev/null @@ -1,717 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2002-2008, 2012 Kaz Kojima - Copyright (c) 2008 Red Hat, Inc. - - SuperH Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -#define NGREGARG 4 -#if defined(__SH4__) -#define NFREGARG 8 -#endif - -#if defined(__HITACHI__) -#define STRUCT_VALUE_ADDRESS_WITH_ARG 1 -#else -#define STRUCT_VALUE_ADDRESS_WITH_ARG 0 -#endif - -/* If the structure has essentially an unique element, return its type. */ -static int -simple_type (ffi_type *arg) -{ - if (arg->type != FFI_TYPE_STRUCT) - return arg->type; - else if (arg->elements[1]) - return FFI_TYPE_STRUCT; - - return simple_type (arg->elements[0]); -} - -static int -return_type (ffi_type *arg) -{ - unsigned short type; - - if (arg->type != FFI_TYPE_STRUCT) - return arg->type; - - type = simple_type (arg->elements[0]); - if (! arg->elements[1]) - { - switch (type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - return FFI_TYPE_INT; - - default: - return type; - } - } - - /* gcc uses r0/r1 pair for some kind of structures. */ - if (arg->size <= 2 * sizeof (int)) - { - int i = 0; - ffi_type *e; - - while ((e = arg->elements[i++])) - { - type = simple_type (e); - switch (type) - { - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_INT: - case FFI_TYPE_FLOAT: - return FFI_TYPE_UINT64; - - default: - break; - } - } - } - - return FFI_TYPE_STRUCT; -} - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register int tmp; - register unsigned int avn; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - int greg, ireg; -#if defined(__SH4__) - int freg = 0; -#endif - - tmp = 0; - argp = stack; - - if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT) - { - *(void **) argp = ecif->rvalue; - argp += 4; - ireg = STRUCT_VALUE_ADDRESS_WITH_ARG ? 1 : 0; - } - else - ireg = 0; - - /* Set arguments for registers. */ - greg = ireg; - avn = ecif->cif->nargs; - p_argv = ecif->avalue; - - for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++) - { - size_t z; - - z = (*p_arg)->size; - if (z < sizeof(int)) - { - if (greg++ >= NGREGARG) - continue; - - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - case FFI_TYPE_STRUCT: - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - break; - - default: - FFI_ASSERT(0); - } - argp += z; - } - else if (z == sizeof(int)) - { -#if defined(__SH4__) - if ((*p_arg)->type == FFI_TYPE_FLOAT) - { - if (freg++ >= NFREGARG) - continue; - } - else -#endif - { - if (greg++ >= NGREGARG) - continue; - } - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - argp += z; - } -#if defined(__SH4__) - else if ((*p_arg)->type == FFI_TYPE_DOUBLE) - { - if (freg + 1 >= NFREGARG) - continue; - freg = (freg + 1) & ~1; - freg += 2; - memcpy (argp, *p_argv, z); - argp += z; - } -#endif - else - { - int n = (z + sizeof (int) - 1) / sizeof (int); -#if defined(__SH4__) - if (greg + n - 1 >= NGREGARG) - continue; -#else - if (greg >= NGREGARG) - continue; -#endif - greg += n; - memcpy (argp, *p_argv, z); - argp += n * sizeof (int); - } - } - - /* Set arguments on stack. */ - greg = ireg; -#if defined(__SH4__) - freg = 0; -#endif - p_argv = ecif->avalue; - - for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++) - { - size_t z; - - z = (*p_arg)->size; - if (z < sizeof(int)) - { - if (greg++ < NGREGARG) - continue; - - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - case FFI_TYPE_STRUCT: - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - break; - - default: - FFI_ASSERT(0); - } - argp += z; - } - else if (z == sizeof(int)) - { -#if defined(__SH4__) - if ((*p_arg)->type == FFI_TYPE_FLOAT) - { - if (freg++ < NFREGARG) - continue; - } - else -#endif - { - if (greg++ < NGREGARG) - continue; - } - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - argp += z; - } -#if defined(__SH4__) - else if ((*p_arg)->type == FFI_TYPE_DOUBLE) - { - if (freg + 1 < NFREGARG) - { - freg = (freg + 1) & ~1; - freg += 2; - continue; - } - memcpy (argp, *p_argv, z); - argp += z; - } -#endif - else - { - int n = (z + sizeof (int) - 1) / sizeof (int); - if (greg + n - 1 < NGREGARG) - { - greg += n; - continue; - } -#if (! defined(__SH4__)) - else if (greg < NGREGARG) - { - greg = NGREGARG; - continue; - } -#endif - memcpy (argp, *p_argv, z); - argp += n * sizeof (int); - } - } - - return; -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - int i, j; - int size, type; - int n, m; - int greg; -#if defined(__SH4__) - int freg = 0; -#endif - - cif->flags = 0; - - greg = ((return_type (cif->rtype) == FFI_TYPE_STRUCT) && - STRUCT_VALUE_ADDRESS_WITH_ARG) ? 1 : 0; - -#if defined(__SH4__) - for (i = j = 0; i < cif->nargs && j < 12; i++) - { - type = (cif->arg_types)[i]->type; - switch (type) - { - case FFI_TYPE_FLOAT: - if (freg >= NFREGARG) - continue; - freg++; - cif->flags += ((cif->arg_types)[i]->type) << (2 * j); - j++; - break; - - case FFI_TYPE_DOUBLE: - if ((freg + 1) >= NFREGARG) - continue; - freg = (freg + 1) & ~1; - freg += 2; - cif->flags += ((cif->arg_types)[i]->type) << (2 * j); - j++; - break; - - default: - size = (cif->arg_types)[i]->size; - n = (size + sizeof (int) - 1) / sizeof (int); - if (greg + n - 1 >= NGREGARG) - continue; - greg += n; - for (m = 0; m < n; m++) - cif->flags += FFI_TYPE_INT << (2 * j++); - break; - } - } -#else - for (i = j = 0; i < cif->nargs && j < 4; i++) - { - size = (cif->arg_types)[i]->size; - n = (size + sizeof (int) - 1) / sizeof (int); - if (greg >= NGREGARG) - continue; - else if (greg + n - 1 >= NGREGARG) - n = NGREGARG - greg; - greg += n; - for (m = 0; m < n; m++) - cif->flags += FFI_TYPE_INT << (2 * j++); - } -#endif - - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_STRUCT: - cif->flags += (unsigned) (return_type (cif->rtype)) << 24; - break; - - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags += (unsigned) cif->rtype->type << 24; - break; - - default: - cif->flags += FFI_TYPE_INT << 24; - break; - } - - return FFI_OK; -} - -extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, - unsigned, unsigned, unsigned *, void (*fn)(void)); - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - UINT64 trvalue; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if (cif->rtype->type == FFI_TYPE_STRUCT - && return_type (cif->rtype) != FFI_TYPE_STRUCT) - ecif.rvalue = &trvalue; - else if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, - fn); - break; - default: - FFI_ASSERT(0); - break; - } - - if (rvalue - && cif->rtype->type == FFI_TYPE_STRUCT - && return_type (cif->rtype) != FFI_TYPE_STRUCT) - memcpy (rvalue, &trvalue, cif->rtype->size); -} - -extern void ffi_closure_SYSV (void); -#if defined(__SH4__) -extern void __ic_invalidate (void *line); -#endif - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp; - unsigned int insn; - - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - tramp = (unsigned int *) &closure->tramp[0]; - /* Set T bit if the function returns a struct pointed with R2. */ - insn = (return_type (cif->rtype) == FFI_TYPE_STRUCT - ? 0x0018 /* sett */ - : 0x0008 /* clrt */); - -#ifdef __LITTLE_ENDIAN__ - tramp[0] = 0xd301d102; - tramp[1] = 0x0000412b | (insn << 16); -#else - tramp[0] = 0xd102d301; - tramp[1] = 0x412b0000 | insn; -#endif - *(void **) &tramp[2] = (void *)codeloc; /* ctx */ - *(void **) &tramp[3] = (void *)ffi_closure_SYSV; /* funaddr */ - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - -#if defined(__SH4__) - /* Flush the icache. */ - __ic_invalidate(codeloc); -#endif - - return FFI_OK; -} - -/* Basically the trampoline invokes ffi_closure_SYSV, and on - * entry, r3 holds the address of the closure. - * After storing the registers that could possibly contain - * parameters to be passed into the stack frame and setting - * up space for a return value, ffi_closure_SYSV invokes the - * following helper function to do most of the work. - */ - -#ifdef __LITTLE_ENDIAN__ -#define OFS_INT8 0 -#define OFS_INT16 0 -#else -#define OFS_INT8 3 -#define OFS_INT16 2 -#endif - -int -ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue, - unsigned long *pgr, unsigned long *pfr, - unsigned long *pst) -{ - void **avalue; - ffi_type **p_arg; - int i, avn; - int ireg, greg = 0; -#if defined(__SH4__) - int freg = 0; -#endif - ffi_cif *cif; - - cif = closure->cif; - avalue = alloca(cif->nargs * sizeof(void *)); - - /* Copy the caller's structure return value address so that the closure - returns the data directly to the caller. */ - if (cif->rtype->type == FFI_TYPE_STRUCT && STRUCT_VALUE_ADDRESS_WITH_ARG) - { - rvalue = (void *) *pgr++; - ireg = 1; - } - else - ireg = 0; - - cif = closure->cif; - greg = ireg; - avn = cif->nargs; - - /* Grab the addresses of the arguments from the stack frame. */ - for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) - { - size_t z; - - z = (*p_arg)->size; - if (z < sizeof(int)) - { - if (greg++ >= NGREGARG) - continue; - - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - avalue[i] = (((char *)pgr) + OFS_INT8); - break; - - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - avalue[i] = (((char *)pgr) + OFS_INT16); - break; - - case FFI_TYPE_STRUCT: - avalue[i] = pgr; - break; - - default: - FFI_ASSERT(0); - } - pgr++; - } - else if (z == sizeof(int)) - { -#if defined(__SH4__) - if ((*p_arg)->type == FFI_TYPE_FLOAT) - { - if (freg++ >= NFREGARG) - continue; - avalue[i] = pfr; - pfr++; - } - else -#endif - { - if (greg++ >= NGREGARG) - continue; - avalue[i] = pgr; - pgr++; - } - } -#if defined(__SH4__) - else if ((*p_arg)->type == FFI_TYPE_DOUBLE) - { - if (freg + 1 >= NFREGARG) - continue; - if (freg & 1) - pfr++; - freg = (freg + 1) & ~1; - freg += 2; - avalue[i] = pfr; - pfr += 2; - } -#endif - else - { - int n = (z + sizeof (int) - 1) / sizeof (int); -#if defined(__SH4__) - if (greg + n - 1 >= NGREGARG) - continue; -#else - if (greg >= NGREGARG) - continue; -#endif - greg += n; - avalue[i] = pgr; - pgr += n; - } - } - - greg = ireg; -#if defined(__SH4__) - freg = 0; -#endif - - for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) - { - size_t z; - - z = (*p_arg)->size; - if (z < sizeof(int)) - { - if (greg++ < NGREGARG) - continue; - - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - avalue[i] = (((char *)pst) + OFS_INT8); - break; - - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - avalue[i] = (((char *)pst) + OFS_INT16); - break; - - case FFI_TYPE_STRUCT: - avalue[i] = pst; - break; - - default: - FFI_ASSERT(0); - } - pst++; - } - else if (z == sizeof(int)) - { -#if defined(__SH4__) - if ((*p_arg)->type == FFI_TYPE_FLOAT) - { - if (freg++ < NFREGARG) - continue; - } - else -#endif - { - if (greg++ < NGREGARG) - continue; - } - avalue[i] = pst; - pst++; - } -#if defined(__SH4__) - else if ((*p_arg)->type == FFI_TYPE_DOUBLE) - { - if (freg + 1 < NFREGARG) - { - freg = (freg + 1) & ~1; - freg += 2; - continue; - } - avalue[i] = pst; - pst += 2; - } -#endif - else - { - int n = (z + sizeof (int) - 1) / sizeof (int); - if (greg + n - 1 < NGREGARG) - { - greg += n; - continue; - } -#if (! defined(__SH4__)) - else if (greg < NGREGARG) - { - greg += n; - pst += greg - NGREGARG; - continue; - } -#endif - avalue[i] = pst; - pst += n; - } - } - - (closure->fun) (cif, rvalue, avalue, closure->user_data); - - /* Tell ffi_closure_SYSV how to perform return type promotions. */ - return return_type (cif->rtype); -} diff --git a/user/mpy/lib/libffi/src/sh/ffitarget.h b/user/mpy/lib/libffi/src/sh/ffitarget.h deleted file mode 100644 index a36bf42..0000000 --- a/user/mpy/lib/libffi/src/sh/ffitarget.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for SuperH. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 16 -#define FFI_NATIVE_RAW_API 0 - -#endif - diff --git a/user/mpy/lib/libffi/src/sh/sysv.S b/user/mpy/lib/libffi/src/sh/sysv.S deleted file mode 100644 index 5be7516..0000000 --- a/user/mpy/lib/libffi/src/sh/sysv.S +++ /dev/null @@ -1,850 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2002, 2003, 2004, 2006, 2008 Kaz Kojima - - SuperH Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#ifdef HAVE_MACHINE_ASM_H -#include -#else -/* XXX these lose for some platforms, I'm sure. */ -#define CNAME(x) x -#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): -#endif - -#if defined(__HITACHI__) -#define STRUCT_VALUE_ADDRESS_WITH_ARG 1 -#else -#define STRUCT_VALUE_ADDRESS_WITH_ARG 0 -#endif - -.text - - # r4: ffi_prep_args - # r5: &ecif - # r6: bytes - # r7: flags - # sp+0: rvalue - # sp+4: fn - - # This assumes we are using gas. -ENTRY(ffi_call_SYSV) - # Save registers -.LFB1: - mov.l r8,@-r15 -.LCFI0: - mov.l r9,@-r15 -.LCFI1: - mov.l r10,@-r15 -.LCFI2: - mov.l r12,@-r15 -.LCFI3: - mov.l r14,@-r15 -.LCFI4: - sts.l pr,@-r15 -.LCFI5: - mov r15,r14 -.LCFI6: -#if defined(__SH4__) - mov r6,r8 - mov r7,r9 - - sub r6,r15 - add #-16,r15 - mov #~7,r0 - and r0,r15 - - mov r4,r0 - jsr @r0 - mov r15,r4 - - mov r9,r1 - shlr8 r9 - shlr8 r9 - shlr8 r9 - - mov #FFI_TYPE_STRUCT,r2 - cmp/eq r2,r9 - bf 1f -#if STRUCT_VALUE_ADDRESS_WITH_ARG - mov.l @r15+,r4 - bra 2f - mov #5,r2 -#else - mov.l @r15+,r10 -#endif -1: - mov #4,r2 -2: - mov #4,r3 - -L_pass: - cmp/pl r8 - bf L_call_it - - mov r1,r0 - and #3,r0 - -L_pass_d: - cmp/eq #FFI_TYPE_DOUBLE,r0 - bf L_pass_f - - mov r3,r0 - and #1,r0 - tst r0,r0 - bt 1f - add #1,r3 -1: - mov #12,r0 - cmp/hs r0,r3 - bt/s 3f - shlr2 r1 - bsr L_pop_d - nop -3: - add #2,r3 - bra L_pass - add #-8,r8 - -L_pop_d: - mov r3,r0 - add r0,r0 - add r3,r0 - add #-12,r0 - braf r0 - nop -#ifdef __LITTLE_ENDIAN__ - fmov.s @r15+,fr5 - rts - fmov.s @r15+,fr4 - fmov.s @r15+,fr7 - rts - fmov.s @r15+,fr6 - fmov.s @r15+,fr9 - rts - fmov.s @r15+,fr8 - fmov.s @r15+,fr11 - rts - fmov.s @r15+,fr10 -#else - fmov.s @r15+,fr4 - rts - fmov.s @r15+,fr5 - fmov.s @r15+,fr6 - rts - fmov.s @r15+,fr7 - fmov.s @r15+,fr8 - rts - fmov.s @r15+,fr9 - fmov.s @r15+,fr10 - rts - fmov.s @r15+,fr11 -#endif - -L_pass_f: - cmp/eq #FFI_TYPE_FLOAT,r0 - bf L_pass_i - - mov #12,r0 - cmp/hs r0,r3 - bt/s 2f - shlr2 r1 - bsr L_pop_f - nop -2: - add #1,r3 - bra L_pass - add #-4,r8 - -L_pop_f: - mov r3,r0 - shll2 r0 - add #-16,r0 - braf r0 - nop -#ifdef __LITTLE_ENDIAN__ - rts - fmov.s @r15+,fr5 - rts - fmov.s @r15+,fr4 - rts - fmov.s @r15+,fr7 - rts - fmov.s @r15+,fr6 - rts - fmov.s @r15+,fr9 - rts - fmov.s @r15+,fr8 - rts - fmov.s @r15+,fr11 - rts - fmov.s @r15+,fr10 -#else - rts - fmov.s @r15+,fr4 - rts - fmov.s @r15+,fr5 - rts - fmov.s @r15+,fr6 - rts - fmov.s @r15+,fr7 - rts - fmov.s @r15+,fr8 - rts - fmov.s @r15+,fr9 - rts - fmov.s @r15+,fr10 - rts - fmov.s @r15+,fr11 -#endif - -L_pass_i: - cmp/eq #FFI_TYPE_INT,r0 - bf L_call_it - - mov #8,r0 - cmp/hs r0,r2 - bt/s 2f - shlr2 r1 - bsr L_pop_i - nop -2: - add #1,r2 - bra L_pass - add #-4,r8 - -L_pop_i: - mov r2,r0 - shll2 r0 - add #-16,r0 - braf r0 - nop - rts - mov.l @r15+,r4 - rts - mov.l @r15+,r5 - rts - mov.l @r15+,r6 - rts - mov.l @r15+,r7 - -L_call_it: - # call function -#if (! STRUCT_VALUE_ADDRESS_WITH_ARG) - mov r10, r2 -#endif - mov.l @(28,r14),r1 - jsr @r1 - nop - -L_ret_d: - mov #FFI_TYPE_DOUBLE,r2 - cmp/eq r2,r9 - bf L_ret_ll - - mov.l @(24,r14),r1 -#ifdef __LITTLE_ENDIAN__ - fmov.s fr1,@r1 - add #4,r1 - bra L_epilogue - fmov.s fr0,@r1 -#else - fmov.s fr0,@r1 - add #4,r1 - bra L_epilogue - fmov.s fr1,@r1 -#endif - -L_ret_ll: - mov #FFI_TYPE_SINT64,r2 - cmp/eq r2,r9 - bt/s 1f - mov #FFI_TYPE_UINT64,r2 - cmp/eq r2,r9 - bf L_ret_f - -1: - mov.l @(24,r14),r2 - mov.l r0,@r2 - bra L_epilogue - mov.l r1,@(4,r2) - -L_ret_f: - mov #FFI_TYPE_FLOAT,r2 - cmp/eq r2,r9 - bf L_ret_i - - mov.l @(24,r14),r1 - bra L_epilogue - fmov.s fr0,@r1 - -L_ret_i: - mov #FFI_TYPE_INT,r2 - cmp/eq r2,r9 - bf L_epilogue - - mov.l @(24,r14),r1 - bra L_epilogue - mov.l r0,@r1 - -L_epilogue: - # Remove the space we pushed for the args - mov r14,r15 - - lds.l @r15+,pr - mov.l @r15+,r14 - mov.l @r15+,r12 - mov.l @r15+,r10 - mov.l @r15+,r9 - rts - mov.l @r15+,r8 -#else - mov r6,r8 - mov r7,r9 - - sub r6,r15 - add #-16,r15 - mov #~7,r0 - and r0,r15 - - mov r4,r0 - jsr @r0 - mov r15,r4 - - mov r9,r3 - shlr8 r9 - shlr8 r9 - shlr8 r9 - - mov #FFI_TYPE_STRUCT,r2 - cmp/eq r2,r9 - bf 1f -#if STRUCT_VALUE_ADDRESS_WITH_ARG - mov.l @r15+,r4 - bra 2f - mov #5,r2 -#else - mov.l @r15+,r10 -#endif -1: - mov #4,r2 -2: - -L_pass: - cmp/pl r8 - bf L_call_it - - mov r3,r0 - and #3,r0 - -L_pass_d: - cmp/eq #FFI_TYPE_DOUBLE,r0 - bf L_pass_i - - mov r15,r0 - and #7,r0 - tst r0,r0 - bt 1f - add #4,r15 -1: - mov #8,r0 - cmp/hs r0,r2 - bt/s 2f - shlr2 r3 - bsr L_pop_d - nop -2: - add #2,r2 - bra L_pass - add #-8,r8 - -L_pop_d: - mov r2,r0 - add r0,r0 - add r2,r0 - add #-12,r0 - add r0,r0 - braf r0 - nop - mov.l @r15+,r4 - rts - mov.l @r15+,r5 - mov.l @r15+,r5 - rts - mov.l @r15+,r6 - mov.l @r15+,r6 - rts - mov.l @r15+,r7 - rts - mov.l @r15+,r7 - -L_pass_i: - cmp/eq #FFI_TYPE_INT,r0 - bf L_call_it - - mov #8,r0 - cmp/hs r0,r2 - bt/s 2f - shlr2 r3 - bsr L_pop_i - nop -2: - add #1,r2 - bra L_pass - add #-4,r8 - -L_pop_i: - mov r2,r0 - shll2 r0 - add #-16,r0 - braf r0 - nop - rts - mov.l @r15+,r4 - rts - mov.l @r15+,r5 - rts - mov.l @r15+,r6 - rts - mov.l @r15+,r7 - -L_call_it: - # call function -#if (! STRUCT_VALUE_ADDRESS_WITH_ARG) - mov r10, r2 -#endif - mov.l @(28,r14),r1 - jsr @r1 - nop - -L_ret_d: - mov #FFI_TYPE_DOUBLE,r2 - cmp/eq r2,r9 - bf L_ret_ll - - mov.l @(24,r14),r2 - mov.l r0,@r2 - bra L_epilogue - mov.l r1,@(4,r2) - -L_ret_ll: - mov #FFI_TYPE_SINT64,r2 - cmp/eq r2,r9 - bt/s 1f - mov #FFI_TYPE_UINT64,r2 - cmp/eq r2,r9 - bf L_ret_i - -1: - mov.l @(24,r14),r2 - mov.l r0,@r2 - bra L_epilogue - mov.l r1,@(4,r2) - -L_ret_i: - mov #FFI_TYPE_FLOAT,r2 - cmp/eq r2,r9 - bt 1f - mov #FFI_TYPE_INT,r2 - cmp/eq r2,r9 - bf L_epilogue -1: - mov.l @(24,r14),r1 - bra L_epilogue - mov.l r0,@r1 - -L_epilogue: - # Remove the space we pushed for the args - mov r14,r15 - - lds.l @r15+,pr - mov.l @r15+,r14 - mov.l @r15+,r12 - mov.l @r15+,r10 - mov.l @r15+,r9 - rts - mov.l @r15+,r8 -#endif -.LFE1: -.ffi_call_SYSV_end: - .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) - -.globl ffi_closure_helper_SYSV - -ENTRY(ffi_closure_SYSV) -.LFB2: - mov.l r7,@-r15 -.LCFI7: - mov.l r6,@-r15 -.LCFI8: - mov.l r5,@-r15 -.LCFI9: - mov.l r4,@-r15 -.LCFIA: - mov.l r14,@-r15 -.LCFIB: - sts.l pr,@-r15 - - /* Stack layout: - xx bytes (on stack parameters) - 16 bytes (register parameters) - 4 bytes (saved frame pointer) - 4 bytes (saved return address) - 32 bytes (floating register parameters, SH-4 only) - 8 bytes (result) - 4 bytes (pad) - 4 bytes (5th arg) - <- new stack pointer - */ -.LCFIC: -#if defined(__SH4__) - add #-48,r15 -#else - add #-16,r15 -#endif -.LCFID: - mov r15,r14 -.LCFIE: - -#if defined(__SH4__) - mov r14,r1 - add #48,r1 -#ifdef __LITTLE_ENDIAN__ - fmov.s fr10,@-r1 - fmov.s fr11,@-r1 - fmov.s fr8,@-r1 - fmov.s fr9,@-r1 - fmov.s fr6,@-r1 - fmov.s fr7,@-r1 - fmov.s fr4,@-r1 - fmov.s fr5,@-r1 -#else - fmov.s fr11,@-r1 - fmov.s fr10,@-r1 - fmov.s fr9,@-r1 - fmov.s fr8,@-r1 - fmov.s fr7,@-r1 - fmov.s fr6,@-r1 - fmov.s fr5,@-r1 - fmov.s fr4,@-r1 -#endif - mov r1,r7 - mov r14,r6 - add #56,r6 -#else - mov r14,r6 - add #24,r6 -#endif - - bt/s 10f - mov r2, r5 - mov r14,r1 - add #8,r1 - mov r1,r5 -10: - - mov r14,r1 -#if defined(__SH4__) - add #72,r1 -#else - add #40,r1 -#endif - mov.l r1,@r14 - -#ifdef PIC - mov.l L_got,r1 - mova L_got,r0 - add r0,r1 - mov.l L_helper,r0 - add r1,r0 -#else - mov.l L_helper,r0 -#endif - jsr @r0 - mov r3,r4 - - shll r0 - mov r0,r1 - mova L_table,r0 - add r1,r0 - mov.w @r0,r0 - mov r14,r2 - braf r0 - add #8,r2 -0: - .align 2 -#ifdef PIC -L_got: - .long _GLOBAL_OFFSET_TABLE_ -L_helper: - .long ffi_closure_helper_SYSV@GOTOFF -#else -L_helper: - .long ffi_closure_helper_SYSV -#endif -L_table: - .short L_case_v - 0b /* FFI_TYPE_VOID */ - .short L_case_i - 0b /* FFI_TYPE_INT */ -#if defined(__SH4__) - .short L_case_f - 0b /* FFI_TYPE_FLOAT */ - .short L_case_d - 0b /* FFI_TYPE_DOUBLE */ - .short L_case_d - 0b /* FFI_TYPE_LONGDOUBLE */ -#else - .short L_case_i - 0b /* FFI_TYPE_FLOAT */ - .short L_case_ll - 0b /* FFI_TYPE_DOUBLE */ - .short L_case_ll - 0b /* FFI_TYPE_LONGDOUBLE */ -#endif - .short L_case_uq - 0b /* FFI_TYPE_UINT8 */ - .short L_case_q - 0b /* FFI_TYPE_SINT8 */ - .short L_case_uh - 0b /* FFI_TYPE_UINT16 */ - .short L_case_h - 0b /* FFI_TYPE_SINT16 */ - .short L_case_i - 0b /* FFI_TYPE_UINT32 */ - .short L_case_i - 0b /* FFI_TYPE_SINT32 */ - .short L_case_ll - 0b /* FFI_TYPE_UINT64 */ - .short L_case_ll - 0b /* FFI_TYPE_SINT64 */ - .short L_case_v - 0b /* FFI_TYPE_STRUCT */ - .short L_case_i - 0b /* FFI_TYPE_POINTER */ - -#if defined(__SH4__) -L_case_d: -#ifdef __LITTLE_ENDIAN__ - fmov.s @r2+,fr1 - bra L_case_v - fmov.s @r2,fr0 -#else - fmov.s @r2+,fr0 - bra L_case_v - fmov.s @r2,fr1 -#endif - -L_case_f: - bra L_case_v - fmov.s @r2,fr0 -#endif - -L_case_ll: - mov.l @r2+,r0 - bra L_case_v - mov.l @r2,r1 - -L_case_i: - bra L_case_v - mov.l @r2,r0 - -L_case_q: -#ifdef __LITTLE_ENDIAN__ -#else - add #3,r2 -#endif - bra L_case_v - mov.b @r2,r0 - -L_case_uq: -#ifdef __LITTLE_ENDIAN__ -#else - add #3,r2 -#endif - mov.b @r2,r0 - bra L_case_v - extu.b r0,r0 - -L_case_h: -#ifdef __LITTLE_ENDIAN__ -#else - add #2,r2 -#endif - bra L_case_v - mov.w @r2,r0 - -L_case_uh: -#ifdef __LITTLE_ENDIAN__ -#else - add #2,r2 -#endif - mov.w @r2,r0 - extu.w r0,r0 - /* fall through */ - -L_case_v: -#if defined(__SH4__) - add #48,r15 -#else - add #16,r15 -#endif - lds.l @r15+,pr - mov.l @r15+,r14 - rts - add #16,r15 -.LFE2: -.ffi_closure_SYSV_end: - .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif - - .section ".eh_frame","aw",@progbits -__FRAME_BEGIN__: - .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */ -.LSCIE1: - .4byte 0x0 /* CIE Identifier Tag */ - .byte 0x1 /* CIE Version */ -#ifdef PIC - .ascii "zR\0" /* CIE Augmentation */ -#else - .byte 0x0 /* CIE Augmentation */ -#endif - .byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */ - .byte 0x7c /* sleb128 -4; CIE Data Alignment Factor */ - .byte 0x11 /* CIE RA Column */ -#ifdef PIC - .uleb128 0x1 /* Augmentation size */ - .byte 0x10 /* FDE Encoding (pcrel) */ -#endif - .byte 0xc /* DW_CFA_def_cfa */ - .byte 0xf /* uleb128 0xf */ - .byte 0x0 /* uleb128 0x0 */ - .align 2 -.LECIE1: -.LSFDE1: - .4byte .LEFDE1-.LASFDE1 /* FDE Length */ -.LASFDE1: - .4byte .LASFDE1-__FRAME_BEGIN__ /* FDE CIE offset */ -#ifdef PIC - .4byte .LFB1-. /* FDE initial location */ -#else - .4byte .LFB1 /* FDE initial location */ -#endif - .4byte .LFE1-.LFB1 /* FDE address range */ -#ifdef PIC - .uleb128 0x0 /* Augmentation size */ -#endif - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI0-.LFB1 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x4 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI1-.LCFI0 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x8 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI2-.LCFI1 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0xc /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI3-.LCFI2 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x10 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI4-.LCFI3 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x14 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI5-.LCFI4 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x18 /* uleb128 0x4 */ - .byte 0x91 /* DW_CFA_offset, column 0x11 */ - .byte 0x6 /* uleb128 0x6 */ - .byte 0x8e /* DW_CFA_offset, column 0xe */ - .byte 0x5 /* uleb128 0x5 */ - .byte 0x8c /* DW_CFA_offset, column 0xc */ - .byte 0x4 /* uleb128 0x4 */ - .byte 0x8a /* DW_CFA_offset, column 0xa */ - .byte 0x3 /* uleb128 0x3 */ - .byte 0x89 /* DW_CFA_offset, column 0x9 */ - .byte 0x2 /* uleb128 0x2 */ - .byte 0x88 /* DW_CFA_offset, column 0x8 */ - .byte 0x1 /* uleb128 0x1 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI6-.LCFI5 - .byte 0xd /* DW_CFA_def_cfa_register */ - .byte 0xe /* uleb128 0xe */ - .align 2 -.LEFDE1: - -.LSFDE3: - .4byte .LEFDE3-.LASFDE3 /* FDE Length */ -.LASFDE3: - .4byte .LASFDE3-__FRAME_BEGIN__ /* FDE CIE offset */ -#ifdef PIC - .4byte .LFB2-. /* FDE initial location */ -#else - .4byte .LFB2 /* FDE initial location */ -#endif - .4byte .LFE2-.LFB2 /* FDE address range */ -#ifdef PIC - .uleb128 0x0 /* Augmentation size */ -#endif - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI7-.LFB2 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x4 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI8-.LCFI7 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x8 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFI9-.LCFI8 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0xc /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFIA-.LCFI9 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x10 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFIB-.LCFIA - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x14 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFIC-.LCFIB - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte 0x18 /* uleb128 0x4 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFID-.LCFIC - .byte 0xe /* DW_CFA_def_cfa_offset */ -#if defined(__SH4__) - .byte 24+48 /* uleb128 24+48 */ -#else - .byte 24+16 /* uleb128 24+16 */ -#endif - .byte 0x91 /* DW_CFA_offset, column 0x11 */ - .byte 0x6 /* uleb128 0x6 */ - .byte 0x8e /* DW_CFA_offset, column 0xe */ - .byte 0x5 /* uleb128 0x5 */ - .byte 0x84 /* DW_CFA_offset, column 0x4 */ - .byte 0x4 /* uleb128 0x4 */ - .byte 0x85 /* DW_CFA_offset, column 0x5 */ - .byte 0x3 /* uleb128 0x3 */ - .byte 0x86 /* DW_CFA_offset, column 0x6 */ - .byte 0x2 /* uleb128 0x2 */ - .byte 0x87 /* DW_CFA_offset, column 0x7 */ - .byte 0x1 /* uleb128 0x1 */ - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte .LCFIE-.LCFID - .byte 0xd /* DW_CFA_def_cfa_register */ - .byte 0xe /* uleb128 0xe */ - .align 2 -.LEFDE3: diff --git a/user/mpy/lib/libffi/src/sh64/ffi.c b/user/mpy/lib/libffi/src/sh64/ffi.c deleted file mode 100644 index 123b87a..0000000 --- a/user/mpy/lib/libffi/src/sh64/ffi.c +++ /dev/null @@ -1,469 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2003, 2004, 2006, 2007, 2012 Kaz Kojima - Copyright (c) 2008 Anthony Green - - SuperH SHmedia Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include - -#define NGREGARG 8 -#define NFREGARG 12 - -static int -return_type (ffi_type *arg) -{ - - if (arg->type != FFI_TYPE_STRUCT) - return arg->type; - - /* gcc uses r2 if the result can be packed in on register. */ - if (arg->size <= sizeof (UINT8)) - return FFI_TYPE_UINT8; - else if (arg->size <= sizeof (UINT16)) - return FFI_TYPE_UINT16; - else if (arg->size <= sizeof (UINT32)) - return FFI_TYPE_UINT32; - else if (arg->size <= sizeof (UINT64)) - return FFI_TYPE_UINT64; - - return FFI_TYPE_STRUCT; -} - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register unsigned int avn; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT) - { - *(void **) argp = ecif->rvalue; - argp += sizeof (UINT64); - } - - avn = ecif->cif->nargs; - p_argv = ecif->avalue; - - for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++) - { - size_t z; - int align; - - z = (*p_arg)->size; - align = (*p_arg)->alignment; - if (z < sizeof (UINT32)) - { - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(SINT64 *) argp = (SINT64) *(SINT8 *)(*p_argv); - break; - - case FFI_TYPE_UINT8: - *(UINT64 *) argp = (UINT64) *(UINT8 *)(*p_argv); - break; - - case FFI_TYPE_SINT16: - *(SINT64 *) argp = (SINT64) *(SINT16 *)(*p_argv); - break; - - case FFI_TYPE_UINT16: - *(UINT64 *) argp = (UINT64) *(UINT16 *)(*p_argv); - break; - - case FFI_TYPE_STRUCT: - memcpy (argp, *p_argv, z); - break; - - default: - FFI_ASSERT(0); - } - argp += sizeof (UINT64); - } - else if (z == sizeof (UINT32) && align == sizeof (UINT32)) - { - switch ((*p_arg)->type) - { - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - *(SINT64 *) argp = (SINT64) *(SINT32 *) (*p_argv); - break; - - case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT32: - case FFI_TYPE_STRUCT: - *(UINT64 *) argp = (UINT64) *(UINT32 *) (*p_argv); - break; - - default: - FFI_ASSERT(0); - break; - } - argp += sizeof (UINT64); - } - else if (z == sizeof (UINT64) - && align == sizeof (UINT64) - && ((int) *p_argv & (sizeof (UINT64) - 1)) == 0) - { - *(UINT64 *) argp = *(UINT64 *) (*p_argv); - argp += sizeof (UINT64); - } - else - { - int n = (z + sizeof (UINT64) - 1) / sizeof (UINT64); - - memcpy (argp, *p_argv, z); - argp += n * sizeof (UINT64); - } - } - - return; -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - int i, j; - int size, type; - int n, m; - int greg; - int freg; - int fpair = -1; - - greg = (return_type (cif->rtype) == FFI_TYPE_STRUCT ? 1 : 0); - freg = 0; - cif->flags2 = 0; - - for (i = j = 0; i < cif->nargs; i++) - { - type = (cif->arg_types)[i]->type; - switch (type) - { - case FFI_TYPE_FLOAT: - greg++; - cif->bytes += sizeof (UINT64) - sizeof (float); - if (freg >= NFREGARG - 1) - continue; - if (fpair < 0) - { - fpair = freg; - freg += 2; - } - else - fpair = -1; - cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++); - break; - - case FFI_TYPE_DOUBLE: - if (greg++ >= NGREGARG && (freg + 1) >= NFREGARG) - continue; - if ((freg + 1) < NFREGARG) - { - freg += 2; - cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++); - } - else - cif->flags2 += FFI_TYPE_INT << (2 * j++); - break; - - default: - size = (cif->arg_types)[i]->size; - if (size < sizeof (UINT64)) - cif->bytes += sizeof (UINT64) - size; - n = (size + sizeof (UINT64) - 1) / sizeof (UINT64); - if (greg >= NGREGARG) - continue; - else if (greg + n - 1 >= NGREGARG) - greg = NGREGARG; - else - greg += n; - for (m = 0; m < n; m++) - cif->flags2 += FFI_TYPE_INT << (2 * j++); - break; - } - } - - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_STRUCT: - cif->flags = return_type (cif->rtype); - break; - - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = cif->rtype->type; - break; - - default: - cif->flags = FFI_TYPE_INT; - break; - } - - return FFI_OK; -} - -/*@-declundef@*/ -/*@-exportheader@*/ -extern void ffi_call_SYSV(void (*)(char *, extended_cif *), - /*@out@*/ extended_cif *, - unsigned, unsigned, long long, - /*@out@*/ unsigned *, - void (*fn)(void)); -/*@=declundef@*/ -/*@=exportheader@*/ - -void ffi_call(/*@dependent@*/ ffi_cif *cif, - void (*fn)(void), - /*@out@*/ void *rvalue, - /*@dependent@*/ void **avalue) -{ - extended_cif ecif; - UINT64 trvalue; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if (cif->rtype->type == FFI_TYPE_STRUCT - && return_type (cif->rtype) != FFI_TYPE_STRUCT) - ecif.rvalue = &trvalue; - else if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, cif->flags2, - ecif.rvalue, fn); - break; - default: - FFI_ASSERT(0); - break; - } - - if (rvalue - && cif->rtype->type == FFI_TYPE_STRUCT - && return_type (cif->rtype) != FFI_TYPE_STRUCT) - memcpy (rvalue, &trvalue, cif->rtype->size); -} - -extern void ffi_closure_SYSV (void); -extern void __ic_invalidate (void *line); - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp; - - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - tramp = (unsigned int *) &closure->tramp[0]; - /* Since ffi_closure is an aligned object, the ffi trampoline is - called as an SHcompact code. Sigh. - SHcompact part: - mova @(1,pc),r0; add #1,r0; jmp @r0; nop; - SHmedia part: - movi fnaddr >> 16,r1; shori fnaddr,r1; ptabs/l r1,tr0 - movi cxt >> 16,r1; shori cxt,r1; blink tr0,r63 */ -#ifdef __LITTLE_ENDIAN__ - tramp[0] = 0x7001c701; - tramp[1] = 0x0009402b; -#else - tramp[0] = 0xc7017001; - tramp[1] = 0x402b0009; -#endif - tramp[2] = 0xcc000010 | (((UINT32) ffi_closure_SYSV) >> 16) << 10; - tramp[3] = 0xc8000010 | (((UINT32) ffi_closure_SYSV) & 0xffff) << 10; - tramp[4] = 0x6bf10600; - tramp[5] = 0xcc000010 | (((UINT32) codeloc) >> 16) << 10; - tramp[6] = 0xc8000010 | (((UINT32) codeloc) & 0xffff) << 10; - tramp[7] = 0x4401fff0; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - /* Flush the icache. */ - asm volatile ("ocbwb %0,0; synco; icbi %1,0; synci" : : "r" (tramp), - "r"(codeloc)); - - return FFI_OK; -} - -/* Basically the trampoline invokes ffi_closure_SYSV, and on - * entry, r3 holds the address of the closure. - * After storing the registers that could possibly contain - * parameters to be passed into the stack frame and setting - * up space for a return value, ffi_closure_SYSV invokes the - * following helper function to do most of the work. - */ - -int -ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue, - UINT64 *pgr, UINT64 *pfr, UINT64 *pst) -{ - void **avalue; - ffi_type **p_arg; - int i, avn; - int greg, freg; - ffi_cif *cif; - int fpair = -1; - - cif = closure->cif; - avalue = alloca (cif->nargs * sizeof (void *)); - - /* Copy the caller's structure return value address so that the closure - returns the data directly to the caller. */ - if (return_type (cif->rtype) == FFI_TYPE_STRUCT) - { - rvalue = (UINT64 *) *pgr; - greg = 1; - } - else - greg = 0; - - freg = 0; - cif = closure->cif; - avn = cif->nargs; - - /* Grab the addresses of the arguments from the stack frame. */ - for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++) - { - size_t z; - void *p; - - z = (*p_arg)->size; - if (z < sizeof (UINT32)) - { - p = pgr + greg++; - - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - case FFI_TYPE_STRUCT: -#ifdef __LITTLE_ENDIAN__ - avalue[i] = p; -#else - avalue[i] = ((char *) p) + sizeof (UINT32) - z; -#endif - break; - - default: - FFI_ASSERT(0); - } - } - else if (z == sizeof (UINT32)) - { - if ((*p_arg)->type == FFI_TYPE_FLOAT) - { - if (freg < NFREGARG - 1) - { - if (fpair >= 0) - { - avalue[i] = (UINT32 *) pfr + fpair; - fpair = -1; - } - else - { -#ifdef __LITTLE_ENDIAN__ - fpair = freg; - avalue[i] = (UINT32 *) pfr + (1 ^ freg); -#else - fpair = 1 ^ freg; - avalue[i] = (UINT32 *) pfr + freg; -#endif - freg += 2; - } - } - else -#ifdef __LITTLE_ENDIAN__ - avalue[i] = pgr + greg; -#else - avalue[i] = (UINT32 *) (pgr + greg) + 1; -#endif - } - else -#ifdef __LITTLE_ENDIAN__ - avalue[i] = pgr + greg; -#else - avalue[i] = (UINT32 *) (pgr + greg) + 1; -#endif - greg++; - } - else if ((*p_arg)->type == FFI_TYPE_DOUBLE) - { - if (freg + 1 >= NFREGARG) - avalue[i] = pgr + greg; - else - { - avalue[i] = pfr + (freg >> 1); - freg += 2; - } - greg++; - } - else - { - int n = (z + sizeof (UINT64) - 1) / sizeof (UINT64); - - avalue[i] = pgr + greg; - greg += n; - } - } - - (closure->fun) (cif, rvalue, avalue, closure->user_data); - - /* Tell ffi_closure_SYSV how to perform return type promotions. */ - return return_type (cif->rtype); -} - diff --git a/user/mpy/lib/libffi/src/sh64/ffitarget.h b/user/mpy/lib/libffi/src/sh64/ffitarget.h deleted file mode 100644 index 08a6fe9..0000000 --- a/user/mpy/lib/libffi/src/sh64/ffitarget.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for SuperH - SHmedia. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; - -#define FFI_EXTRA_CIF_FIELDS long long flags2 -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 32 -#define FFI_NATIVE_RAW_API 0 - -#endif - diff --git a/user/mpy/lib/libffi/src/sh64/sysv.S b/user/mpy/lib/libffi/src/sh64/sysv.S deleted file mode 100644 index c4587d5..0000000 --- a/user/mpy/lib/libffi/src/sh64/sysv.S +++ /dev/null @@ -1,539 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2003, 2004, 2006, 2008 Kaz Kojima - - SuperH SHmedia Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#ifdef HAVE_MACHINE_ASM_H -#include -#else -/* XXX these lose for some platforms, I'm sure. */ -#define CNAME(x) x -#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): -#endif - -#ifdef __LITTLE_ENDIAN__ -#define OFS_FLT 0 -#else -#define OFS_FLT 4 -#endif - - .section .text..SHmedia32,"ax" - - # r2: ffi_prep_args - # r3: &ecif - # r4: bytes - # r5: flags - # r6: flags2 - # r7: rvalue - # r8: fn - - # This assumes we are using gas. - .align 5 -ENTRY(ffi_call_SYSV) - # Save registers -.LFB1: - addi.l r15, -48, r15 -.LCFI0: - st.q r15, 40, r32 - st.q r15, 32, r31 - st.q r15, 24, r30 - st.q r15, 16, r29 - st.q r15, 8, r28 - st.l r15, 4, r18 - st.l r15, 0, r14 -.LCFI1: - add.l r15, r63, r14 -.LCFI2: -# add r4, r63, r28 - add r5, r63, r29 - add r6, r63, r30 - add r7, r63, r31 - add r8, r63, r32 - - addi r4, (64 + 7), r4 - andi r4, ~7, r4 - sub.l r15, r4, r15 - - ptabs/l r2, tr0 - add r15, r63, r2 - blink tr0, r18 - - addi r15, 64, r22 - movi 0, r0 - movi 0, r1 - movi -1, r23 - - pt/l 1f, tr1 - bnei/l r29, FFI_TYPE_STRUCT, tr1 - ld.l r15, 0, r19 - addi r15, 8, r15 - addi r0, 1, r0 -1: - -.L_pass: - andi r30, 3, r20 - shlri r30, 2, r30 - - pt/l .L_call_it, tr0 - pt/l .L_pass_i, tr1 - pt/l .L_pass_f, tr2 - - beqi/l r20, FFI_TYPE_VOID, tr0 - beqi/l r20, FFI_TYPE_INT, tr1 - beqi/l r20, FFI_TYPE_FLOAT, tr2 - -.L_pass_d: - addi r0, 1, r0 - pt/l 3f, tr0 - movi 12, r20 - bge/l r1, r20, tr0 - - pt/l .L_pop_d, tr1 - pt/l 2f, tr0 - blink tr1, r63 -2: - addi.l r15, 8, r15 -3: - pt/l .L_pass, tr0 - addi r1, 2, r1 - blink tr0, r63 - -.L_pop_d: - pt/l .L_pop_d_tbl, tr1 - gettr tr1, r20 - shlli r1, 2, r21 - add r20, r21, r20 - ptabs/l r20, tr1 - blink tr1, r63 - -.L_pop_d_tbl: - fld.d r15, 0, dr0 - blink tr0, r63 - fld.d r15, 0, dr2 - blink tr0, r63 - fld.d r15, 0, dr4 - blink tr0, r63 - fld.d r15, 0, dr6 - blink tr0, r63 - fld.d r15, 0, dr8 - blink tr0, r63 - fld.d r15, 0, dr10 - blink tr0, r63 - -.L_pass_f: - addi r0, 1, r0 - pt/l 3f, tr0 - movi 12, r20 - bge/l r1, r20, tr0 - - pt/l .L_pop_f, tr1 - pt/l 2f, tr0 - blink tr1, r63 -2: - addi.l r15, 8, r15 -3: - pt/l .L_pass, tr0 - blink tr0, r63 - -.L_pop_f: - pt/l .L_pop_f_tbl, tr1 - pt/l 5f, tr2 - gettr tr1, r20 - bge/l r23, r63, tr2 - add r1, r63, r23 - shlli r1, 3, r21 - addi r1, 2, r1 - add r20, r21, r20 - ptabs/l r20, tr1 - blink tr1, r63 -5: - addi r23, 1, r21 - movi -1, r23 - shlli r21, 3, r21 - add r20, r21, r20 - ptabs/l r20, tr1 - blink tr1, r63 - -.L_pop_f_tbl: - fld.s r15, OFS_FLT, fr0 - blink tr0, r63 - fld.s r15, OFS_FLT, fr1 - blink tr0, r63 - fld.s r15, OFS_FLT, fr2 - blink tr0, r63 - fld.s r15, OFS_FLT, fr3 - blink tr0, r63 - fld.s r15, OFS_FLT, fr4 - blink tr0, r63 - fld.s r15, OFS_FLT, fr5 - blink tr0, r63 - fld.s r15, OFS_FLT, fr6 - blink tr0, r63 - fld.s r15, OFS_FLT, fr7 - blink tr0, r63 - fld.s r15, OFS_FLT, fr8 - blink tr0, r63 - fld.s r15, OFS_FLT, fr9 - blink tr0, r63 - fld.s r15, OFS_FLT, fr10 - blink tr0, r63 - fld.s r15, OFS_FLT, fr11 - blink tr0, r63 - -.L_pass_i: - pt/l 3f, tr0 - movi 8, r20 - bge/l r0, r20, tr0 - - pt/l .L_pop_i, tr1 - pt/l 2f, tr0 - blink tr1, r63 -2: - addi.l r15, 8, r15 -3: - pt/l .L_pass, tr0 - addi r0, 1, r0 - blink tr0, r63 - -.L_pop_i: - pt/l .L_pop_i_tbl, tr1 - gettr tr1, r20 - shlli r0, 3, r21 - add r20, r21, r20 - ptabs/l r20, tr1 - blink tr1, r63 - -.L_pop_i_tbl: - ld.q r15, 0, r2 - blink tr0, r63 - ld.q r15, 0, r3 - blink tr0, r63 - ld.q r15, 0, r4 - blink tr0, r63 - ld.q r15, 0, r5 - blink tr0, r63 - ld.q r15, 0, r6 - blink tr0, r63 - ld.q r15, 0, r7 - blink tr0, r63 - ld.q r15, 0, r8 - blink tr0, r63 - ld.q r15, 0, r9 - blink tr0, r63 - -.L_call_it: - # call function - pt/l 1f, tr1 - bnei/l r29, FFI_TYPE_STRUCT, tr1 - add r19, r63, r2 -1: - add r22, r63, r15 - ptabs/l r32, tr0 - blink tr0, r18 - - pt/l .L_ret_i, tr0 - pt/l .L_ret_ll, tr1 - pt/l .L_ret_d, tr2 - pt/l .L_ret_f, tr3 - pt/l .L_epilogue, tr4 - - beqi/l r29, FFI_TYPE_INT, tr0 - beqi/l r29, FFI_TYPE_UINT32, tr0 - beqi/l r29, FFI_TYPE_SINT64, tr1 - beqi/l r29, FFI_TYPE_UINT64, tr1 - beqi/l r29, FFI_TYPE_DOUBLE, tr2 - beqi/l r29, FFI_TYPE_FLOAT, tr3 - - pt/l .L_ret_q, tr0 - pt/l .L_ret_h, tr1 - - beqi/l r29, FFI_TYPE_UINT8, tr0 - beqi/l r29, FFI_TYPE_UINT16, tr1 - blink tr4, r63 - -.L_ret_d: - fst.d r31, 0, dr0 - blink tr4, r63 - -.L_ret_ll: - st.q r31, 0, r2 - blink tr4, r63 - -.L_ret_f: - fst.s r31, OFS_FLT, fr0 - blink tr4, r63 - -.L_ret_q: - st.b r31, 0, r2 - blink tr4, r63 - -.L_ret_h: - st.w r31, 0, r2 - blink tr4, r63 - -.L_ret_i: - st.l r31, 0, r2 - # Fall - -.L_epilogue: - # Remove the space we pushed for the args - add r14, r63, r15 - - ld.l r15, 0, r14 - ld.l r15, 4, r18 - ld.q r15, 8, r28 - ld.q r15, 16, r29 - ld.q r15, 24, r30 - ld.q r15, 32, r31 - ld.q r15, 40, r32 - addi.l r15, 48, r15 - ptabs r18, tr0 - blink tr0, r63 - -.LFE1: -.ffi_call_SYSV_end: - .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) - - .align 5 -ENTRY(ffi_closure_SYSV) -.LFB2: - addi.l r15, -136, r15 -.LCFI3: - st.l r15, 12, r18 - st.l r15, 8, r14 - st.l r15, 4, r12 -.LCFI4: - add r15, r63, r14 -.LCFI5: - /* Stack layout: - ... - 64 bytes (register parameters) - 48 bytes (floating register parameters) - 8 bytes (result) - 4 bytes (r18) - 4 bytes (r14) - 4 bytes (r12) - 4 bytes (for align) - <- new stack pointer - */ - fst.d r14, 24, dr0 - fst.d r14, 32, dr2 - fst.d r14, 40, dr4 - fst.d r14, 48, dr6 - fst.d r14, 56, dr8 - fst.d r14, 64, dr10 - st.q r14, 72, r2 - st.q r14, 80, r3 - st.q r14, 88, r4 - st.q r14, 96, r5 - st.q r14, 104, r6 - st.q r14, 112, r7 - st.q r14, 120, r8 - st.q r14, 128, r9 - - add r1, r63, r2 - addi r14, 16, r3 - addi r14, 72, r4 - addi r14, 24, r5 - addi r14, 136, r6 -#ifdef PIC - movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12 - shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12 -.LPCS0: ptrel/u r12, tr0 - movi ((ffi_closure_helper_SYSV@GOTPLT) & 65535), r1 - gettr tr0, r12 - ldx.l r1, r12, r1 - ptabs r1, tr0 -#else - pt/l ffi_closure_helper_SYSV, tr0 -#endif - blink tr0, r18 - - shlli r2, 1, r1 - movi (((datalabel .L_table) >> 16) & 65535), r2 - shori ((datalabel .L_table) & 65535), r2 - ldx.w r2, r1, r1 - add r1, r2, r1 - pt/l .L_case_v, tr1 - ptabs r1, tr0 - blink tr0, r63 - - .align 2 -.L_table: - .word .L_case_v - datalabel .L_table /* FFI_TYPE_VOID */ - .word .L_case_i - datalabel .L_table /* FFI_TYPE_INT */ - .word .L_case_f - datalabel .L_table /* FFI_TYPE_FLOAT */ - .word .L_case_d - datalabel .L_table /* FFI_TYPE_DOUBLE */ - .word .L_case_d - datalabel .L_table /* FFI_TYPE_LONGDOUBLE */ - .word .L_case_uq - datalabel .L_table /* FFI_TYPE_UINT8 */ - .word .L_case_q - datalabel .L_table /* FFI_TYPE_SINT8 */ - .word .L_case_uh - datalabel .L_table /* FFI_TYPE_UINT16 */ - .word .L_case_h - datalabel .L_table /* FFI_TYPE_SINT16 */ - .word .L_case_i - datalabel .L_table /* FFI_TYPE_UINT32 */ - .word .L_case_i - datalabel .L_table /* FFI_TYPE_SINT32 */ - .word .L_case_ll - datalabel .L_table /* FFI_TYPE_UINT64 */ - .word .L_case_ll - datalabel .L_table /* FFI_TYPE_SINT64 */ - .word .L_case_v - datalabel .L_table /* FFI_TYPE_STRUCT */ - .word .L_case_i - datalabel .L_table /* FFI_TYPE_POINTER */ - - .align 2 -.L_case_d: - fld.d r14, 16, dr0 - blink tr1, r63 -.L_case_f: - fld.s r14, 16, fr0 - blink tr1, r63 -.L_case_ll: - ld.q r14, 16, r2 - blink tr1, r63 -.L_case_i: - ld.l r14, 16, r2 - blink tr1, r63 -.L_case_q: - ld.b r14, 16, r2 - blink tr1, r63 -.L_case_uq: - ld.ub r14, 16, r2 - blink tr1, r63 -.L_case_h: - ld.w r14, 16, r2 - blink tr1, r63 -.L_case_uh: - ld.uw r14, 16, r2 - blink tr1, r63 -.L_case_v: - add.l r14, r63, r15 - ld.l r15, 4, r12 - ld.l r15, 8, r14 - ld.l r15, 12, r18 - addi.l r15, 136, r15 - ptabs r18, tr0 - blink tr0, r63 - -.LFE2: -.ffi_closure_SYSV_end: - .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif - - .section ".eh_frame","aw",@progbits -__FRAME_BEGIN__: - .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */ -.LSCIE1: - .4byte 0x0 /* CIE Identifier Tag */ - .byte 0x1 /* CIE Version */ -#ifdef PIC - .ascii "zR\0" /* CIE Augmentation */ -#else - .byte 0x0 /* CIE Augmentation */ -#endif - .uleb128 0x1 /* CIE Code Alignment Factor */ - .sleb128 -4 /* CIE Data Alignment Factor */ - .byte 0x12 /* CIE RA Column */ -#ifdef PIC - .uleb128 0x1 /* Augmentation size */ - .byte 0x10 /* FDE Encoding (pcrel) */ -#endif - .byte 0xc /* DW_CFA_def_cfa */ - .uleb128 0xf - .uleb128 0x0 - .align 2 -.LECIE1: -.LSFDE1: - .4byte datalabel .LEFDE1-datalabel .LASFDE1 /* FDE Length */ -.LASFDE1: - .4byte datalabel .LASFDE1-datalabel __FRAME_BEGIN__ -#ifdef PIC - .4byte .LFB1-. /* FDE initial location */ -#else - .4byte .LFB1 /* FDE initial location */ -#endif - .4byte datalabel .LFE1-datalabel .LFB1 /* FDE address range */ -#ifdef PIC - .uleb128 0x0 /* Augmentation size */ -#endif - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte datalabel .LCFI0-datalabel .LFB1 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .uleb128 0x30 - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte datalabel .LCFI1-datalabel .LCFI0 - .byte 0x8e /* DW_CFA_offset, column 0xe */ - .uleb128 0xc - .byte 0x92 /* DW_CFA_offset, column 0x12 */ - .uleb128 0xb - .byte 0x9c /* DW_CFA_offset, column 0x1c */ - .uleb128 0xa - .byte 0x9d /* DW_CFA_offset, column 0x1d */ - .uleb128 0x8 - .byte 0x9e /* DW_CFA_offset, column 0x1e */ - .uleb128 0x6 - .byte 0x9f /* DW_CFA_offset, column 0x1f */ - .uleb128 0x4 - .byte 0xa0 /* DW_CFA_offset, column 0x20 */ - .uleb128 0x2 - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte datalabel .LCFI2-datalabel .LCFI1 - .byte 0xd /* DW_CFA_def_cfa_register */ - .uleb128 0xe - .align 2 -.LEFDE1: - -.LSFDE3: - .4byte datalabel .LEFDE3-datalabel .LASFDE3 /* FDE Length */ -.LASFDE3: - .4byte datalabel .LASFDE3-datalabel __FRAME_BEGIN__ -#ifdef PIC - .4byte .LFB2-. /* FDE initial location */ -#else - .4byte .LFB2 /* FDE initial location */ -#endif - .4byte datalabel .LFE2-datalabel .LFB2 /* FDE address range */ -#ifdef PIC - .uleb128 0x0 /* Augmentation size */ -#endif - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte datalabel .LCFI3-datalabel .LFB2 - .byte 0xe /* DW_CFA_def_cfa_offset */ - .uleb128 0x88 - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte datalabel .LCFI4-datalabel .LCFI3 - .byte 0x8c /* DW_CFA_offset, column 0xc */ - .uleb128 0x21 - .byte 0x8e /* DW_CFA_offset, column 0xe */ - .uleb128 0x20 - .byte 0x92 /* DW_CFA_offset, column 0x12 */ - .uleb128 0x1f - .byte 0x4 /* DW_CFA_advance_loc4 */ - .4byte datalabel .LCFI5-datalabel .LCFI4 - .byte 0xd /* DW_CFA_def_cfa_register */ - .uleb128 0xe - .align 2 -.LEFDE3: diff --git a/user/mpy/lib/libffi/src/sparc/ffi.c b/user/mpy/lib/libffi/src/sparc/ffi.c deleted file mode 100644 index d5212d8..0000000 --- a/user/mpy/lib/libffi/src/sparc/ffi.c +++ /dev/null @@ -1,468 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011, 2013 Anthony Green - Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc. - - SPARC Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include "internal.h" - -#ifndef SPARC64 - -/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; - all further uses in this file will refer to the 128-bit type. */ -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -# if FFI_TYPE_LONGDOUBLE != 4 -# error FFI_TYPE_LONGDOUBLE out of date -# endif -#else -# undef FFI_TYPE_LONGDOUBLE -# define FFI_TYPE_LONGDOUBLE 4 -#endif - -/* Perform machine dependent cif processing */ -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep(ffi_cif *cif) -{ - ffi_type *rtype = cif->rtype; - int rtt = rtype->type; - size_t bytes; - int i, n, flags; - - /* Set the return type flag */ - switch (rtt) - { - case FFI_TYPE_VOID: - flags = SPARC_RET_VOID; - break; - case FFI_TYPE_FLOAT: - flags = SPARC_RET_F_1; - break; - case FFI_TYPE_DOUBLE: - flags = SPARC_RET_F_2; - break; - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_STRUCT: - flags = (rtype->size & 0xfff) << SPARC_SIZEMASK_SHIFT; - flags |= SPARC_RET_STRUCT; - break; - case FFI_TYPE_SINT8: - flags = SPARC_RET_SINT8; - break; - case FFI_TYPE_UINT8: - flags = SPARC_RET_UINT8; - break; - case FFI_TYPE_SINT16: - flags = SPARC_RET_SINT16; - break; - case FFI_TYPE_UINT16: - flags = SPARC_RET_UINT16; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - flags = SPARC_RET_UINT32; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - flags = SPARC_RET_INT64; - break; - case FFI_TYPE_COMPLEX: - rtt = rtype->elements[0]->type; - switch (rtt) - { - case FFI_TYPE_FLOAT: - flags = SPARC_RET_F_2; - break; - case FFI_TYPE_DOUBLE: - flags = SPARC_RET_F_4; - break; - case FFI_TYPE_LONGDOUBLE: - flags = SPARC_RET_F_8; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - flags = SPARC_RET_INT128; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - flags = SPARC_RET_INT64; - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - flags = SP_V8_RET_CPLX16; - break; - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - flags = SP_V8_RET_CPLX8; - break; - default: - abort(); - } - break; - default: - abort(); - } - cif->flags = flags; - - bytes = 0; - for (i = 0, n = cif->nargs; i < n; ++i) - { - ffi_type *ty = cif->arg_types[i]; - size_t z = ty->size; - int tt = ty->type; - - switch (tt) - { - case FFI_TYPE_STRUCT: - case FFI_TYPE_LONGDOUBLE: - by_reference: - /* Passed by reference. */ - z = 4; - break; - - case FFI_TYPE_COMPLEX: - tt = ty->elements[0]->type; - if (tt == FFI_TYPE_FLOAT || z > 8) - goto by_reference; - /* FALLTHRU */ - - default: - z = ALIGN(z, 4); - } - bytes += z; - } - - /* Sparc call frames require that space is allocated for 6 args, - even if they aren't used. Make that space if necessary. */ - if (bytes < 6 * 4) - bytes = 6 * 4; - - /* The ABI always requires space for the struct return pointer. */ - bytes += 4; - - /* The stack must be 2 word aligned, so round bytes up appropriately. */ - bytes = ALIGN(bytes, 2 * 4); - - /* Include the call frame to prep_args. */ - bytes += 4*16 + 4*8; - cif->bytes = bytes; - - return FFI_OK; -} - -extern void ffi_call_v8(ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, size_t bytes, void *closure) FFI_HIDDEN; - -int FFI_HIDDEN -ffi_prep_args_v8(ffi_cif *cif, unsigned long *argp, void *rvalue, void **avalue) -{ - ffi_type **p_arg; - int flags = cif->flags; - int i, nargs; - - if (rvalue == NULL) - { - if ((flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) - { - /* Since we pass the pointer to the callee, we need a value. - We allowed for this space in ffi_call, before ffi_call_v8 - alloca'd the space. */ - rvalue = (char *)argp + cif->bytes; - } - else - { - /* Otherwise, we can ignore the return value. */ - flags = SPARC_RET_VOID; - } - } - - /* This could only really be done when we are returning a structure. - However, the space is reserved so we can do it unconditionally. */ - *argp++ = (unsigned long)rvalue; - -#ifdef USING_PURIFY - /* Purify will probably complain in our assembly routine, - unless we zero out this memory. */ - memset(argp, 0, 6*4); -#endif - - p_arg = cif->arg_types; - for (i = 0, nargs = cif->nargs; i < nargs; i++) - { - ffi_type *ty = p_arg[i]; - void *a = avalue[i]; - int tt = ty->type; - size_t z; - - switch (tt) - { - case FFI_TYPE_STRUCT: - case FFI_TYPE_LONGDOUBLE: - by_reference: - *argp++ = (unsigned long)a; - break; - - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - memcpy(argp, a, 8); - argp += 2; - break; - - case FFI_TYPE_INT: - case FFI_TYPE_FLOAT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - *argp++ = *(unsigned *)a; - break; - - case FFI_TYPE_UINT8: - *argp++ = *(UINT8 *)a; - break; - case FFI_TYPE_SINT8: - *argp++ = *(SINT8 *)a; - break; - case FFI_TYPE_UINT16: - *argp++ = *(UINT16 *)a; - break; - case FFI_TYPE_SINT16: - *argp++ = *(SINT16 *)a; - break; - - case FFI_TYPE_COMPLEX: - tt = ty->elements[0]->type; - z = ty->size; - if (tt == FFI_TYPE_FLOAT || z > 8) - goto by_reference; - if (z < 4) - { - memcpy((char *)argp + 4 - z, a, z); - argp++; - } - else - { - memcpy(argp, a, z); - argp += z / 4; - } - break; - - default: - abort(); - } - } - - return flags; -} - -static void -ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - size_t bytes = cif->bytes; - - FFI_ASSERT (cif->abi == FFI_V8); - - /* If we've not got a return value, we need to create one if we've - got to pass the return value to the callee. Otherwise ignore it. */ - if (rvalue == NULL - && (cif->flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) - bytes += ALIGN (cif->rtype->size, 8); - - ffi_call_v8(cif, fn, rvalue, avalue, -bytes, closure); -} - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} - -#ifdef __GNUC__ -static inline void -ffi_flush_icache (void *p) -{ - /* SPARC v8 requires 5 instructions for flush to be visible */ - asm volatile ("iflush %0; iflush %0+8; nop; nop; nop; nop; nop" - : : "r" (p) : "memory"); -} -#else -extern void ffi_flush_icache (void *) FFI_HIDDEN; -#endif - -extern void ffi_closure_v8(void) FFI_HIDDEN; -extern void ffi_go_closure_v8(void) FFI_HIDDEN; - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp = (unsigned int *) &closure->tramp[0]; - unsigned long ctx = (unsigned long) closure; - unsigned long fn = (unsigned long) ffi_closure_v8; - - if (cif->abi != FFI_V8) - return FFI_BAD_ABI; - - tramp[0] = 0x03000000 | fn >> 10; /* sethi %hi(fn), %g1 */ - tramp[1] = 0x05000000 | ctx >> 10; /* sethi %hi(ctx), %g2 */ - tramp[2] = 0x81c06000 | (fn & 0x3ff); /* jmp %g1+%lo(fn) */ - tramp[3] = 0x8410a000 | (ctx & 0x3ff);/* or %g2, %lo(ctx) */ - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - ffi_flush_icache (closure); - - return FFI_OK; -} - -ffi_status -ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*)) -{ - if (cif->abi != FFI_V8) - return FFI_BAD_ABI; - - closure->tramp = ffi_go_closure_v8; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -int FFI_HIDDEN -ffi_closure_sparc_inner_v8(ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, void *rvalue, - unsigned long *argp) -{ - ffi_type **arg_types; - void **avalue; - int i, nargs, flags; - - arg_types = cif->arg_types; - nargs = cif->nargs; - flags = cif->flags; - avalue = alloca(nargs * sizeof(void *)); - - /* Copy the caller's structure return address so that the closure - returns the data directly to the caller. Also install it so we - can return the address in %o0. */ - if ((flags & SPARC_FLAG_RET_MASK) == SPARC_RET_STRUCT) - { - void *new_rvalue = (void *)*argp; - *(void **)rvalue = new_rvalue; - rvalue = new_rvalue; - } - - /* Always skip the structure return address. */ - argp++; - - /* Grab the addresses of the arguments from the stack frame. */ - for (i = 0; i < nargs; i++) - { - ffi_type *ty = arg_types[i]; - int tt = ty->type; - void *a = argp; - size_t z; - - switch (tt) - { - case FFI_TYPE_STRUCT: - case FFI_TYPE_LONGDOUBLE: - by_reference: - /* Straight copy of invisible reference. */ - a = (void *)*argp; - break; - - case FFI_TYPE_DOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - if ((unsigned long)a & 7) - { - /* Align on a 8-byte boundary. */ - UINT64 *tmp = alloca(8); - *tmp = ((UINT64)argp[0] << 32) | argp[1]; - a = tmp; - } - argp++; - break; - - case FFI_TYPE_INT: - case FFI_TYPE_FLOAT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - break; - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - a += 2; - break; - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - a += 3; - break; - - case FFI_TYPE_COMPLEX: - tt = ty->elements[0]->type; - z = ty->size; - if (tt == FFI_TYPE_FLOAT || z > 8) - goto by_reference; - if (z < 4) - a += 4 - z; - else if (z > 4) - argp++; - break; - - default: - abort(); - } - argp++; - avalue[i] = a; - } - - /* Invoke the closure. */ - fun (cif, rvalue, avalue, user_data); - - /* Tell ffi_closure_sparc how to perform return type promotions. */ - return flags; -} -#endif /* !SPARC64 */ diff --git a/user/mpy/lib/libffi/src/sparc/ffi64.c b/user/mpy/lib/libffi/src/sparc/ffi64.c deleted file mode 100644 index 340b198..0000000 --- a/user/mpy/lib/libffi/src/sparc/ffi64.c +++ /dev/null @@ -1,608 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011, 2013 Anthony Green - Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc. - - SPARC Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include "internal.h" - -/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; - all further uses in this file will refer to the 128-bit type. */ -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -# if FFI_TYPE_LONGDOUBLE != 4 -# error FFI_TYPE_LONGDOUBLE out of date -# endif -#else -# undef FFI_TYPE_LONGDOUBLE -# define FFI_TYPE_LONGDOUBLE 4 -#endif - -#ifdef SPARC64 - -/* Flatten the contents of a structure to the parts that are passed in - floating point registers. The return is a bit mask wherein bit N - set means bytes [4*n, 4*n+3] are passed in %fN. - - We encode both the (running) size (maximum 32) and mask (maxumum 255) - into one integer. The size is placed in the low byte, so that align - and addition work correctly. The mask is placed in the second byte. */ - -static int -ffi_struct_float_mask (ffi_type *outer_type, int size_mask) -{ - ffi_type **elts; - ffi_type *t; - - if (outer_type->type == FFI_TYPE_COMPLEX) - { - int m = 0, tt = outer_type->elements[0]->type; - size_t z = outer_type->size; - - if (tt == FFI_TYPE_FLOAT - || tt == FFI_TYPE_DOUBLE - || tt == FFI_TYPE_LONGDOUBLE) - m = (1 << (z / 4)) - 1; - return (m << 8) | z; - } - FFI_ASSERT (outer_type->type == FFI_TYPE_STRUCT); - - for (elts = outer_type->elements; (t = *elts) != NULL; elts++) - { - size_t z = t->size; - int o, m, tt; - - size_mask = ALIGN(size_mask, t->alignment); - switch (t->type) - { - case FFI_TYPE_STRUCT: - size_mask = ffi_struct_float_mask (t, size_mask); - continue; - case FFI_TYPE_COMPLEX: - tt = t->elements[0]->type; - if (tt != FFI_TYPE_FLOAT - && tt != FFI_TYPE_DOUBLE - && tt != FFI_TYPE_LONGDOUBLE) - break; - /* FALLTHRU */ - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - m = (1 << (z / 4)) - 1; /* compute mask for type */ - o = (size_mask >> 2) & 0x3f; /* extract word offset */ - size_mask |= m << (o + 8); /* insert mask into place */ - break; - } - size_mask += z; - } - - size_mask = ALIGN(size_mask, outer_type->alignment); - FFI_ASSERT ((size_mask & 0xff) == outer_type->size); - - return size_mask; -} - -/* Merge floating point data into integer data. If the structure is - entirely floating point, simply return a pointer to the fp data. */ - -static void * -ffi_struct_float_merge (int size_mask, void *vi, void *vf) -{ - int size = size_mask & 0xff; - int mask = size_mask >> 8; - int n = size >> 2; - - if (mask == 0) - return vi; - else if (mask == (1 << n) - 1) - return vf; - else - { - unsigned int *wi = vi, *wf = vf; - int i; - - for (i = 0; i < n; ++i) - if ((mask >> i) & 1) - wi[i] = wf[i]; - - return vi; - } -} - -/* Similar, but place the data into VD in the end. */ - -void FFI_HIDDEN -ffi_struct_float_copy (int size_mask, void *vd, void *vi, void *vf) -{ - int size = size_mask & 0xff; - int mask = size_mask >> 8; - int n = size >> 2; - - if (mask == 0) - ; - else if (mask == (1 << n) - 1) - vi = vf; - else - { - unsigned int *wd = vd, *wi = vi, *wf = vf; - int i; - - for (i = 0; i < n; ++i) - wd[i] = ((mask >> i) & 1 ? wf : wi)[i]; - return; - } - memcpy (vd, vi, size); -} - -/* Perform machine dependent cif processing */ - -static ffi_status -ffi_prep_cif_machdep_core(ffi_cif *cif) -{ - ffi_type *rtype = cif->rtype; - int rtt = rtype->type; - size_t bytes = 0; - int i, n, flags; - - /* Set the return type flag */ - switch (rtt) - { - case FFI_TYPE_VOID: - flags = SPARC_RET_VOID; - break; - case FFI_TYPE_FLOAT: - flags = SPARC_RET_F_1; - break; - case FFI_TYPE_DOUBLE: - flags = SPARC_RET_F_2; - break; - case FFI_TYPE_LONGDOUBLE: - flags = SPARC_RET_F_4; - break; - - case FFI_TYPE_COMPLEX: - case FFI_TYPE_STRUCT: - if (rtype->size > 32) - { - flags = SPARC_RET_VOID | SPARC_FLAG_RET_IN_MEM; - bytes = 8; - } - else - { - int size_mask = ffi_struct_float_mask (rtype, 0); - int word_size = (size_mask >> 2) & 0x3f; - int all_mask = (1 << word_size) - 1; - int fp_mask = size_mask >> 8; - - flags = (size_mask << SPARC_SIZEMASK_SHIFT) | SPARC_RET_STRUCT; - - /* For special cases of all-int or all-fp, we can return - the value directly without popping through a struct copy. */ - if (fp_mask == 0) - { - if (rtype->alignment >= 8) - { - if (rtype->size == 8) - flags = SPARC_RET_INT64; - else if (rtype->size == 16) - flags = SPARC_RET_INT128; - } - } - else if (fp_mask == all_mask) - switch (word_size) - { - case 1: flags = SPARC_RET_F_1; break; - case 2: flags = SPARC_RET_F_2; break; - case 3: flags = SP_V9_RET_F_3; break; - case 4: flags = SPARC_RET_F_4; break; - /* 5 word structures skipped; handled via RET_STRUCT. */ - case 6: flags = SPARC_RET_F_6; break; - /* 7 word structures skipped; handled via RET_STRUCT. */ - case 8: flags = SPARC_RET_F_8; break; - } - } - break; - - case FFI_TYPE_SINT8: - flags = SPARC_RET_SINT8; - break; - case FFI_TYPE_UINT8: - flags = SPARC_RET_UINT8; - break; - case FFI_TYPE_SINT16: - flags = SPARC_RET_SINT16; - break; - case FFI_TYPE_UINT16: - flags = SPARC_RET_UINT16; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - flags = SP_V9_RET_SINT32; - break; - case FFI_TYPE_UINT32: - flags = SPARC_RET_UINT32; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - flags = SPARC_RET_INT64; - break; - - default: - abort(); - } - - bytes = 0; - for (i = 0, n = cif->nargs; i < n; ++i) - { - ffi_type *ty = cif->arg_types[i]; - size_t z = ty->size; - size_t a = ty->alignment; - - switch (ty->type) - { - case FFI_TYPE_COMPLEX: - case FFI_TYPE_STRUCT: - /* Large structs passed by reference. */ - if (z > 16) - { - a = z = 8; - break; - } - /* Small structs may be passed in integer or fp regs or both. */ - if (bytes >= 16*8) - break; - if ((ffi_struct_float_mask (ty, 0) & 0xff00) == 0) - break; - /* FALLTHRU */ - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - flags |= SPARC_FLAG_FP_ARGS; - break; - } - bytes = ALIGN(bytes, a); - bytes += ALIGN(z, 8); - } - - /* Sparc call frames require that space is allocated for 6 args, - even if they aren't used. Make that space if necessary. */ - if (bytes < 6 * 8) - bytes = 6 * 8; - - /* The stack must be 2 word aligned, so round bytes up appropriately. */ - bytes = ALIGN(bytes, 16); - - /* Include the call frame to prep_args. */ - bytes += 8*16 + 8*8; - - cif->bytes = bytes; - cif->flags = flags; - return FFI_OK; -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep(ffi_cif *cif) -{ - cif->nfixedargs = cif->nargs; - return ffi_prep_cif_machdep_core(cif); -} - -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned nfixedargs, unsigned ntotalargs) -{ - cif->nfixedargs = nfixedargs; - return ffi_prep_cif_machdep_core(cif); -} - -extern void ffi_call_v9(ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, size_t bytes, void *closure) FFI_HIDDEN; - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -int FFI_HIDDEN -ffi_prep_args_v9(ffi_cif *cif, unsigned long *argp, void *rvalue, void **avalue) -{ - ffi_type **p_arg; - int flags = cif->flags; - int i, nargs; - - if (rvalue == NULL) - { - if (flags & SPARC_FLAG_RET_IN_MEM) - { - /* Since we pass the pointer to the callee, we need a value. - We allowed for this space in ffi_call, before ffi_call_v8 - alloca'd the space. */ - rvalue = (char *)argp + cif->bytes; - } - else - { - /* Otherwise, we can ignore the return value. */ - flags = SPARC_RET_VOID; - } - } - -#ifdef USING_PURIFY - /* Purify will probably complain in our assembly routine, - unless we zero out this memory. */ - memset(argp, 0, 6*8); -#endif - - if (flags & SPARC_FLAG_RET_IN_MEM) - *argp++ = (unsigned long)rvalue; - - p_arg = cif->arg_types; - for (i = 0, nargs = cif->nargs; i < nargs; i++) - { - ffi_type *ty = p_arg[i]; - void *a = avalue[i]; - size_t z; - - switch (ty->type) - { - case FFI_TYPE_SINT8: - *argp++ = *(SINT8 *)a; - break; - case FFI_TYPE_UINT8: - *argp++ = *(UINT8 *)a; - break; - case FFI_TYPE_SINT16: - *argp++ = *(SINT16 *)a; - break; - case FFI_TYPE_UINT16: - *argp++ = *(UINT16 *)a; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - *argp++ = *(SINT32 *)a; - break; - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - *argp++ = *(UINT32 *)a; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - case FFI_TYPE_DOUBLE: - *argp++ = *(UINT64 *)a; - break; - - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_COMPLEX: - case FFI_TYPE_STRUCT: - z = ty->size; - if (z > 16) - { - /* For structures larger than 16 bytes we pass reference. */ - *argp++ = (unsigned long)a; - break; - } - if (((unsigned long)argp & 15) && ty->alignment > 8) - argp++; - memcpy(argp, a, z); - argp += ALIGN(z, 8) / 8; - break; - - default: - abort(); - } - } - - return flags; -} - -static void -ffi_call_int(ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - size_t bytes = cif->bytes; - - FFI_ASSERT (cif->abi == FFI_V9); - - if (rvalue == NULL && (cif->flags & SPARC_FLAG_RET_IN_MEM)) - bytes += ALIGN (cif->rtype->size, 16); - - ffi_call_v9(cif, fn, rvalue, avalue, -bytes, closure); -} - -void -ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int(cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go(ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int(cif, fn, rvalue, avalue, closure); -} - -#ifdef __GNUC__ -static inline void -ffi_flush_icache (void *p) -{ - asm volatile ("flush %0; flush %0+8" : : "r" (p) : "memory"); -} -#else -extern void ffi_flush_icache (void *) FFI_HIDDEN; -#endif - -extern void ffi_closure_v9(void) FFI_HIDDEN; -extern void ffi_go_closure_v9(void) FFI_HIDDEN; - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - unsigned int *tramp = (unsigned int *) &closure->tramp[0]; - unsigned long fn; - - if (cif->abi != FFI_V9) - return FFI_BAD_ABI; - - /* Trampoline address is equal to the closure address. We take advantage - of that to reduce the trampoline size by 8 bytes. */ - fn = (unsigned long) ffi_closure_v9; - tramp[0] = 0x83414000; /* rd %pc, %g1 */ - tramp[1] = 0xca586010; /* ldx [%g1+16], %g5 */ - tramp[2] = 0x81c14000; /* jmp %g5 */ - tramp[3] = 0x01000000; /* nop */ - *((unsigned long *) &tramp[4]) = fn; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - ffi_flush_icache (closure); - - return FFI_OK; -} - -ffi_status -ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*)) -{ - if (cif->abi != FFI_V9) - return FFI_BAD_ABI; - - closure->tramp = ffi_go_closure_v9; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -int FFI_HIDDEN -ffi_closure_sparc_inner_v9(ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, void *rvalue, - unsigned long *gpr, unsigned long *fpr) -{ - ffi_type **arg_types; - void **avalue; - int i, argn, argx, nargs, flags, nfixedargs; - - arg_types = cif->arg_types; - nargs = cif->nargs; - flags = cif->flags; - nfixedargs = cif->nfixedargs; - - avalue = alloca(nargs * sizeof(void *)); - - /* Copy the caller's structure return address so that the closure - returns the data directly to the caller. */ - if (flags & SPARC_FLAG_RET_IN_MEM) - { - rvalue = (void *) gpr[0]; - /* Skip the structure return address. */ - argn = 1; - } - else - argn = 0; - - /* Grab the addresses of the arguments from the stack frame. */ - for (i = 0; i < nargs; i++, argn = argx) - { - int named = i < nfixedargs; - ffi_type *ty = arg_types[i]; - void *a = &gpr[argn]; - size_t z; - - argx = argn + 1; - switch (ty->type) - { - case FFI_TYPE_COMPLEX: - case FFI_TYPE_STRUCT: - z = ty->size; - if (z > 16) - a = *(void **)a; - else - { - argx = argn + ALIGN (z, 8) / 8; - if (named && argn < 16) - { - int size_mask = ffi_struct_float_mask (ty, 0); - int argn_mask = (0xffff00 >> argn) & 0xff00; - - /* Eliminate fp registers off the end. */ - size_mask = (size_mask & 0xff) | (size_mask & argn_mask); - a = ffi_struct_float_merge (size_mask, gpr+argn, fpr+argn); - } - } - break; - - case FFI_TYPE_LONGDOUBLE: - argn = ALIGN (argn, 2); - a = (named && argn < 16 ? fpr : gpr) + argn; - argx = argn + 2; - break; - case FFI_TYPE_DOUBLE: - if (named && argn < 16) - a = fpr + argn; - break; - case FFI_TYPE_FLOAT: - if (named && argn < 16) - a = fpr + argn; - a += 4; - break; - - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_POINTER: - break; - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - a += 4; - break; - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - a += 6; - break; - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - a += 7; - break; - - default: - abort(); - } - avalue[i] = a; - } - - /* Invoke the closure. */ - fun (cif, rvalue, avalue, user_data); - - /* Tell ffi_closure_sparc how to perform return type promotions. */ - return flags; -} -#endif /* SPARC64 */ diff --git a/user/mpy/lib/libffi/src/sparc/ffitarget.h b/user/mpy/lib/libffi/src/sparc/ffitarget.h deleted file mode 100644 index 2f4cd9a..0000000 --- a/user/mpy/lib/libffi/src/sparc/ffitarget.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for SPARC. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -#if defined(__arch64__) || defined(__sparcv9) -#ifndef SPARC64 -#define SPARC64 -#endif -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, -#ifdef SPARC64 - FFI_V9, - FFI_DEFAULT_ABI = FFI_V9, -#else - FFI_V8, - FFI_DEFAULT_ABI = FFI_V8, -#endif - FFI_LAST_ABI -} ffi_abi; -#endif - -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION 1 -#define FFI_TARGET_HAS_COMPLEX_TYPE 1 - -#ifdef SPARC64 -# define FFI_TARGET_SPECIFIC_VARIADIC 1 -# define FFI_EXTRA_CIF_FIELDS unsigned int nfixedargs -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_GO_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -#ifdef SPARC64 -#define FFI_TRAMPOLINE_SIZE 24 -#else -#define FFI_TRAMPOLINE_SIZE 16 -#endif - -#endif - diff --git a/user/mpy/lib/libffi/src/sparc/internal.h b/user/mpy/lib/libffi/src/sparc/internal.h deleted file mode 100644 index 0a66472..0000000 --- a/user/mpy/lib/libffi/src/sparc/internal.h +++ /dev/null @@ -1,26 +0,0 @@ -#define SPARC_RET_VOID 0 -#define SPARC_RET_STRUCT 1 -#define SPARC_RET_UINT8 2 -#define SPARC_RET_SINT8 3 -#define SPARC_RET_UINT16 4 -#define SPARC_RET_SINT16 5 -#define SPARC_RET_UINT32 6 -#define SP_V9_RET_SINT32 7 /* v9 only */ -#define SP_V8_RET_CPLX16 7 /* v8 only */ -#define SPARC_RET_INT64 8 -#define SPARC_RET_INT128 9 - -/* Note that F_7 is missing, and is handled by SPARC_RET_STRUCT. */ -#define SPARC_RET_F_8 10 -#define SPARC_RET_F_6 11 -#define SPARC_RET_F_4 12 -#define SPARC_RET_F_2 13 -#define SP_V9_RET_F_3 14 /* v9 only */ -#define SP_V8_RET_CPLX8 14 /* v8 only */ -#define SPARC_RET_F_1 15 - -#define SPARC_FLAG_RET_MASK 15 -#define SPARC_FLAG_RET_IN_MEM 32 -#define SPARC_FLAG_FP_ARGS 64 - -#define SPARC_SIZEMASK_SHIFT 8 diff --git a/user/mpy/lib/libffi/src/sparc/v8.S b/user/mpy/lib/libffi/src/sparc/v8.S deleted file mode 100644 index a2e4908..0000000 --- a/user/mpy/lib/libffi/src/sparc/v8.S +++ /dev/null @@ -1,443 +0,0 @@ -/* ----------------------------------------------------------------------- - v8.S - Copyright (c) 2013 The Written Word, Inc. - Copyright (c) 1996, 1997, 2003, 2004, 2008 Red Hat, Inc. - - SPARC Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#include "internal.h" - -#ifndef SPARC64 - -#define C2(X, Y) X ## Y -#define C1(X, Y) C2(X, Y) - -#ifdef __USER_LABEL_PREFIX__ -# define C(Y) C1(__USER_LABEL_PREFIX__, Y) -#else -# define C(Y) Y -#endif -#define L(Y) C1(.L, Y) - - .text - -#ifndef __GNUC__ - .align 8 - .globl C(ffi_flush_icache) - .type C(ffi_flush_icache),#function - FFI_HIDDEN(C(ffi_flush_icache)) - -C(ffi_flush_icache): -1: iflush %o0 - iflush %o+8 - nop - nop - nop - nop - nop - retl - nop - .size C(ffi_flush_icache), . - C(ffi_flush_icache) -#endif - -#if defined(__sun__) && defined(__svr4__) -# define E(INDEX) .align 16 -#else -# define E(INDEX) .align 16; .org 2b + INDEX * 16 -#endif - - .align 8 - .globl C(ffi_call_v8) - .type C(ffi_call_v8),#function - FFI_HIDDEN(C(ffi_call_v8)) - -C(ffi_call_v8): -.LUW0: - ! Allocate a stack frame sized by ffi_call. - save %sp, %o4, %sp -.LUW1: - mov %i0, %o0 ! copy cif - add %sp, 64+32, %o1 ! load args area - mov %i2, %o2 ! copy rvalue - call C(ffi_prep_args_v8) - mov %i3, %o3 ! copy avalue - - add %sp, 32, %sp ! deallocate prep frame - and %o0, SPARC_FLAG_RET_MASK, %l0 ! save return type - srl %o0, SPARC_SIZEMASK_SHIFT, %l1 ! save return size - ld [%sp+64+4], %o0 ! load all argument registers - ld [%sp+64+8], %o1 - ld [%sp+64+12], %o2 - ld [%sp+64+16], %o3 - cmp %l0, SPARC_RET_STRUCT ! struct return needs an unimp 4 - ld [%sp+64+20], %o4 - be 8f - ld [%sp+64+24], %o5 - - ! Call foreign function - call %i1 - mov %i5, %g2 ! load static chain - -0: call 1f ! load pc in %o7 - sll %l0, 4, %l0 -1: add %o7, %l0, %o7 ! o7 = 0b + ret_type*16 - jmp %o7+(2f-0b) - nop - - ! Note that each entry is 4 insns, enforced by the E macro. - .align 16 -2: -E(SPARC_RET_VOID) - ret - restore -E(SPARC_RET_STRUCT) - unimp -E(SPARC_RET_UINT8) - and %o0, 0xff, %o0 - st %o0, [%i2] - ret - restore -E(SPARC_RET_SINT8) - sll %o0, 24, %o0 - b 7f - sra %o0, 24, %o0 -E(SPARC_RET_UINT16) - sll %o0, 16, %o0 - b 7f - srl %o0, 16, %o0 -E(SPARC_RET_SINT16) - sll %o0, 16, %o0 - b 7f - sra %o0, 16, %o0 -E(SPARC_RET_UINT32) -7: st %o0, [%i2] - ret - restore -E(SP_V8_RET_CPLX16) - sth %o0, [%i2+2] - b 9f - srl %o0, 16, %o0 -E(SPARC_RET_INT64) - st %o0, [%i2] - st %o1, [%i2+4] - ret - restore -E(SPARC_RET_INT128) - std %o0, [%i2] - std %o2, [%i2+8] - ret - restore -E(SPARC_RET_F_8) - st %f7, [%i2+7*4] - nop - st %f6, [%i2+6*4] - nop -E(SPARC_RET_F_6) - st %f5, [%i2+5*4] - nop - st %f4, [%i2+4*4] - nop -E(SPARC_RET_F_4) - st %f3, [%i2+3*4] - nop - st %f2, [%i2+2*4] - nop -E(SPARC_RET_F_2) - st %f1, [%i2+4] - st %f0, [%i2] - ret - restore -E(SP_V8_RET_CPLX8) - stb %o0, [%i2+1] - b 0f - srl %o0, 8, %o0 -E(SPARC_RET_F_1) - st %f0, [%i2] - ret - restore - - .align 8 -9: sth %o0, [%i2] - ret - restore - .align 8 -0: stb %o0, [%i2] - ret - restore - - ! Struct returning functions expect and skip the unimp here. - ! To make it worse, conforming callees examine the unimp and - ! make sure the low 12 bits of the unimp match the size of - ! the struct being returned. - .align 8 -8: call 1f ! load pc in %o7 - sll %l1, 2, %l0 ! size * 4 -1: sll %l1, 4, %l1 ! size * 16 - add %l0, %l1, %l0 ! size * 20 - add %o7, %l0, %o7 ! o7 = 8b + size*20 - jmp %o7+(2f-8b) - mov %i5, %g2 ! load static chain -2: - -/* The Sun assembler doesn't understand .rept 0x1000. */ -#define rept1 \ - call %i1; \ - nop; \ - unimp (. - 2b) / 20; \ - ret; \ - restore - -#define rept16 \ - rept1; rept1; rept1; rept1; \ - rept1; rept1; rept1; rept1; \ - rept1; rept1; rept1; rept1; \ - rept1; rept1; rept1; rept1 - -#define rept256 \ - rept16; rept16; rept16; rept16; \ - rept16; rept16; rept16; rept16; \ - rept16; rept16; rept16; rept16; \ - rept16; rept16; rept16; rept16 - - rept256; rept256; rept256; rept256 - rept256; rept256; rept256; rept256 - rept256; rept256; rept256; rept256 - rept256; rept256; rept256; rept256 - -.LUW2: - .size C(ffi_call_v8),. - C(ffi_call_v8) - - -/* 16*4 register window + 1*4 struct return + 6*4 args backing store - + 8*4 return storage + 1*4 alignment. */ -#define STACKFRAME (16*4 + 4 + 6*4 + 8*4 + 4) - -/* ffi_closure_v8(...) - - Receives the closure argument in %g2. */ - -#ifdef HAVE_AS_REGISTER_PSEUDO_OP - .register %g2, #scratch -#endif - - .align 8 - .globl C(ffi_go_closure_v8) - .type C(ffi_go_closure_v8),#function - FFI_HIDDEN(C(ffi_go_closure_v8)) - -C(ffi_go_closure_v8): -.LUW3: - save %sp, -STACKFRAME, %sp -.LUW4: - ld [%g2+4], %o0 ! load cif - ld [%g2+8], %o1 ! load fun - b 0f - mov %g2, %o2 ! load user_data -.LUW5: - .size C(ffi_go_closure_v8), . - C(ffi_go_closure_v8) - - .align 8 - .globl C(ffi_closure_v8) - .type C(ffi_closure_v8),#function - FFI_HIDDEN(C(ffi_closure_v8)) - -C(ffi_closure_v8): -.LUW6: - save %sp, -STACKFRAME, %sp -.LUW7: - ld [%g2+FFI_TRAMPOLINE_SIZE], %o0 ! load cif - ld [%g2+FFI_TRAMPOLINE_SIZE+4], %o1 ! load fun - ld [%g2+FFI_TRAMPOLINE_SIZE+8], %o2 ! load user_data -0: - ! Store all of the potential argument registers in va_list format. - st %i0, [%fp+68+0] - st %i1, [%fp+68+4] - st %i2, [%fp+68+8] - st %i3, [%fp+68+12] - st %i4, [%fp+68+16] - st %i5, [%fp+68+20] - - ! Call ffi_closure_sparc_inner to do the bulk of the work. - add %fp, -8*4, %o3 - call ffi_closure_sparc_inner_v8 - add %fp, 64, %o4 - -0: call 1f - and %o0, SPARC_FLAG_RET_MASK, %o0 -1: sll %o0, 4, %o0 ! o0 = o0 * 16 - add %o7, %o0, %o7 ! o7 = 0b + o0*16 - jmp %o7+(2f-0b) - add %fp, -8*4, %i2 - - ! Note that each entry is 4 insns, enforced by the E macro. - .align 16 -2: -E(SPARC_RET_VOID) - ret - restore -E(SPARC_RET_STRUCT) - ld [%i2], %i0 - jmp %i7+12 - restore -E(SPARC_RET_UINT8) - ldub [%i2+3], %i0 - ret - restore -E(SPARC_RET_SINT8) - ldsb [%i2+3], %i0 - ret - restore -E(SPARC_RET_UINT16) - lduh [%i2+2], %i0 - ret - restore -E(SPARC_RET_SINT16) - ldsh [%i2+2], %i0 - ret - restore -E(SPARC_RET_UINT32) - ld [%i2], %i0 - ret - restore -E(SP_V8_RET_CPLX16) - ld [%i2], %i0 - ret - restore -E(SPARC_RET_INT64) - ldd [%i2], %i0 - ret - restore -E(SPARC_RET_INT128) - ldd [%i2], %i0 - ldd [%i2+8], %i2 - ret - restore -E(SPARC_RET_F_8) - ld [%i2+7*4], %f7 - nop - ld [%i2+6*4], %f6 - nop -E(SPARC_RET_F_6) - ld [%i2+5*4], %f5 - nop - ld [%i2+4*4], %f4 - nop -E(SPARC_RET_F_4) - ld [%i2+3*4], %f3 - nop - ld [%i2+2*4], %f2 - nop -E(SPARC_RET_F_2) - ldd [%i2], %f0 - ret - restore -E(SP_V8_RET_CPLX8) - lduh [%i2], %i0 - ret - restore -E(SPARC_RET_F_1) - ld [%i2], %f0 - ret - restore - -.LUW8: - .size C(ffi_closure_v8), . - C(ffi_closure_v8) - -#ifdef HAVE_RO_EH_FRAME - .section ".eh_frame",#alloc -#else - .section ".eh_frame",#alloc,#write -#endif - -#ifdef HAVE_AS_SPARC_UA_PCREL -# define FDE_ADDR(X) %r_disp32(X) -#else -# define FDE_ADDR(X) X -#endif - - .align 4 -.LCIE: - .long .LECIE - .LSCIE ! CIE Length -.LSCIE: - .long 0 ! CIE Identifier Tag - .byte 1 ! CIE Version - .ascii "zR\0" ! CIE Augmentation - .byte 4 ! CIE Code Alignment Factor - .byte 0x7c ! CIE Data Alignment Factor - .byte 15 ! CIE RA Column - .byte 1 ! Augmentation size -#ifdef HAVE_AS_SPARC_UA_PCREL - .byte 0x1b ! FDE Encoding (pcrel sdata4) -#else - .byte 0x50 ! FDE Encoding (aligned absolute) -#endif - .byte 0xc, 14, 0 ! DW_CFA_def_cfa, %o6, offset 0 - .align 4 -.LECIE: - - .long .LEFDE1 - .LSFDE1 ! FDE Length -.LSFDE1: - .long .LSFDE1 - .LCIE ! FDE CIE offset - .long FDE_ADDR(.LUW0) ! Initial location - .long .LUW2 - .LUW0 ! Address range - .byte 0 ! Augmentation size - .byte 0x40+1 ! DW_CFA_advance_loc 4 - .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 - .byte 0x2d ! DW_CFA_GNU_window_save - .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 - .align 4 -.LEFDE1: - - .long .LEFDE2 - .LSFDE2 ! FDE Length -.LSFDE2: - .long .LSFDE2 - .LCIE ! FDE CIE offset - .long FDE_ADDR(.LUW3) ! Initial location - .long .LUW5 - .LUW3 ! Address range - .byte 0 ! Augmentation size - .byte 0x40+1 ! DW_CFA_advance_loc 4 - .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 - .byte 0x2d ! DW_CFA_GNU_window_save - .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 - .align 4 -.LEFDE2: - - .long .LEFDE3 - .LSFDE3 ! FDE Length -.LSFDE3: - .long .LSFDE3 - .LCIE ! FDE CIE offset - .long FDE_ADDR(.LUW6) ! Initial location - .long .LUW8 - .LUW6 ! Address range - .byte 0 ! Augmentation size - .byte 0x40+1 ! DW_CFA_advance_loc 4 - .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 - .byte 0x2d ! DW_CFA_GNU_window_save - .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 - .align 4 -.LEFDE3: - -#endif /* !SPARC64 */ -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/sparc/v9.S b/user/mpy/lib/libffi/src/sparc/v9.S deleted file mode 100644 index 55f8f43..0000000 --- a/user/mpy/lib/libffi/src/sparc/v9.S +++ /dev/null @@ -1,440 +0,0 @@ -/* ----------------------------------------------------------------------- - v9.S - Copyright (c) 2000, 2003, 2004, 2008 Red Hat, Inc. - - SPARC 64-bit Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#include "internal.h" - -#ifdef SPARC64 - -#define C2(X, Y) X ## Y -#define C1(X, Y) C2(X, Y) - -#ifdef __USER_LABEL_PREFIX__ -# define C(Y) C1(__USER_LABEL_PREFIX__, Y) -#else -# define C(Y) Y -#endif -#define L(Y) C1(.L, Y) - -#if defined(__sun__) && defined(__svr4__) -# define E(INDEX) .align 16 -#else -# define E(INDEX) .align 16; .org 2b + INDEX * 16 -#endif - -#define STACK_BIAS 2047 - - .text - .align 8 - .globl C(ffi_call_v9) - .type C(ffi_call_v9),#function - FFI_HIDDEN(C(ffi_call_v9)) - -C(ffi_call_v9): -.LUW0: - save %sp, %o4, %sp -.LUW1: - mov %i0, %o0 ! copy cif - add %sp, STACK_BIAS+128+48, %o1 ! load args area - mov %i2, %o2 ! copy rvalue - call C(ffi_prep_args_v9) - mov %i3, %o3 ! copy avalue - - andcc %o0, SPARC_FLAG_FP_ARGS, %g0 ! need fp regs? - add %sp, 48, %sp ! deallocate prep frame - be,pt %xcc, 1f - mov %o0, %l0 ! save flags - - ldd [%sp+STACK_BIAS+128], %f0 ! load all fp arg regs - ldd [%sp+STACK_BIAS+128+8], %f2 - ldd [%sp+STACK_BIAS+128+16], %f4 - ldd [%sp+STACK_BIAS+128+24], %f6 - ldd [%sp+STACK_BIAS+128+32], %f8 - ldd [%sp+STACK_BIAS+128+40], %f10 - ldd [%sp+STACK_BIAS+128+48], %f12 - ldd [%sp+STACK_BIAS+128+56], %f14 - ldd [%sp+STACK_BIAS+128+64], %f16 - ldd [%sp+STACK_BIAS+128+72], %f18 - ldd [%sp+STACK_BIAS+128+80], %f20 - ldd [%sp+STACK_BIAS+128+88], %f22 - ldd [%sp+STACK_BIAS+128+96], %f24 - ldd [%sp+STACK_BIAS+128+104], %f26 - ldd [%sp+STACK_BIAS+128+112], %f28 - ldd [%sp+STACK_BIAS+128+120], %f30 - -1: ldx [%sp+STACK_BIAS+128], %o0 ! load all int arg regs - ldx [%sp+STACK_BIAS+128+8], %o1 - ldx [%sp+STACK_BIAS+128+16], %o2 - ldx [%sp+STACK_BIAS+128+24], %o3 - ldx [%sp+STACK_BIAS+128+32], %o4 - ldx [%sp+STACK_BIAS+128+40], %o5 - call %i1 - mov %i5, %g5 ! load static chain - -0: call 1f ! load pc in %o7 - and %l0, SPARC_FLAG_RET_MASK, %l1 -1: sll %l1, 4, %l1 - add %o7, %l1, %o7 ! o7 = 0b + ret_type*16 - jmp %o7+(2f-0b) - nop - - .align 16 -2: -E(SPARC_RET_VOID) - return %i7+8 - nop -E(SPARC_RET_STRUCT) - add %sp, STACK_BIAS-64+128+48, %l2 - sub %sp, 64, %sp - b 8f - stx %o0, [%l2] -E(SPARC_RET_UINT8) - and %o0, 0xff, %i0 - return %i7+8 - stx %o0, [%o2] -E(SPARC_RET_SINT8) - sll %o0, 24, %o0 - sra %o0, 24, %i0 - return %i7+8 - stx %o0, [%o2] -E(SPARC_RET_UINT16) - sll %o0, 16, %o0 - srl %o0, 16, %i0 - return %i7+8 - stx %o0, [%o2] -E(SPARC_RET_SINT16) - sll %o0, 16, %o0 - sra %o0, 16, %i0 - return %i7+8 - stx %o0, [%o2] -E(SPARC_RET_UINT32) - srl %o0, 0, %i0 - return %i7+8 - stx %o0, [%o2] -E(SP_V9_RET_SINT32) - sra %o0, 0, %i0 - return %i7+8 - stx %o0, [%o2] -E(SPARC_RET_INT64) - stx %o0, [%i2] - return %i7+8 - nop -E(SPARC_RET_INT128) - stx %o0, [%i2] - stx %o1, [%i2+8] - return %i7+8 - nop -E(SPARC_RET_F_8) - st %f7, [%i2+7*4] - nop - st %f6, [%i2+6*4] - nop -E(SPARC_RET_F_6) - st %f5, [%i2+5*4] - nop - st %f4, [%i2+4*4] - nop -E(SPARC_RET_F_4) - std %f2, [%i2+2*4] - return %i7+8 - std %f0, [%o2] -E(SPARC_RET_F_2) - return %i7+8 - std %f0, [%o2] -E(SP_V9_RET_F_3) - st %f2, [%i2+2*4] - nop - st %f1, [%i2+1*4] - nop -E(SPARC_RET_F_1) - return %i7+8 - st %f0, [%o2] - - ! Finish the SPARC_RET_STRUCT sequence. - .align 8 -8: stx %o1, [%l2+8] - stx %o2, [%l2+16] - stx %o3, [%l2+24] - std %f0, [%l2+32] - std %f2, [%l2+40] - std %f4, [%l2+48] - std %f6, [%l2+56] - - ! Copy the structure into place. - srl %l0, SPARC_SIZEMASK_SHIFT, %o0 ! load size_mask - mov %i2, %o1 ! load dst - mov %l2, %o2 ! load src_gp - call C(ffi_struct_float_copy) - add %l2, 32, %o3 ! load src_fp - - return %i7+8 - nop - -.LUW2: - .size C(ffi_call_v9), . - C(ffi_call_v9) - - -#undef STACKFRAME -#define STACKFRAME 336 /* 16*8 register window + - 6*8 args backing store + - 20*8 locals */ -#define FP %fp+STACK_BIAS - -/* ffi_closure_v9(...) - - Receives the closure argument in %g1. */ - - .align 8 - .globl C(ffi_go_closure_v9) - .type C(ffi_go_closure_v9),#function - FFI_HIDDEN(C(ffi_go_closure_v9)) - -C(ffi_go_closure_v9): -.LUW3: - save %sp, -STACKFRAME, %sp -.LUW4: - ldx [%g5+8], %o0 - ldx [%g5+16], %o1 - b 0f - mov %g5, %o2 - -.LUW5: - .size C(ffi_go_closure_v9), . - C(ffi_go_closure_v9) - - .align 8 - .globl C(ffi_closure_v9) - .type C(ffi_closure_v9),#function - FFI_HIDDEN(C(ffi_closure_v9)) - -C(ffi_closure_v9): -.LUW6: - save %sp, -STACKFRAME, %sp -.LUW7: - ldx [%g1+FFI_TRAMPOLINE_SIZE], %o0 - ldx [%g1+FFI_TRAMPOLINE_SIZE+8], %o1 - ldx [%g1+FFI_TRAMPOLINE_SIZE+16], %o2 -0: - ! Store all of the potential argument registers in va_list format. - stx %i0, [FP+128+0] - stx %i1, [FP+128+8] - stx %i2, [FP+128+16] - stx %i3, [FP+128+24] - stx %i4, [FP+128+32] - stx %i5, [FP+128+40] - - ! Store possible floating point argument registers too. - std %f0, [FP-128] - std %f2, [FP-120] - std %f4, [FP-112] - std %f6, [FP-104] - std %f8, [FP-96] - std %f10, [FP-88] - std %f12, [FP-80] - std %f14, [FP-72] - std %f16, [FP-64] - std %f18, [FP-56] - std %f20, [FP-48] - std %f22, [FP-40] - std %f24, [FP-32] - std %f26, [FP-24] - std %f28, [FP-16] - std %f30, [FP-8] - - ! Call ffi_closure_sparc_inner to do the bulk of the work. - add %fp, STACK_BIAS-160, %o3 - add %fp, STACK_BIAS+128, %o4 - call C(ffi_closure_sparc_inner_v9) - add %fp, STACK_BIAS-128, %o5 - -0: call 1f ! load pc in %o7 - and %o0, SPARC_FLAG_RET_MASK, %o0 -1: sll %o0, 4, %o0 ! o2 = i2 * 16 - add %o7, %o0, %o7 ! o7 = 0b + i2*16 - jmp %o7+(2f-0b) - nop - - ! Note that we cannot load the data in the delay slot of - ! the return insn because the data is in the stack frame - ! that is deallocated by the return. - .align 16 -2: -E(SPARC_RET_VOID) - return %i7+8 - nop -E(SPARC_RET_STRUCT) - ldx [FP-160], %i0 - ldd [FP-160], %f0 - b 8f - ldx [FP-152], %i1 -E(SPARC_RET_UINT8) - ldub [FP-160+7], %i0 - return %i7+8 - nop -E(SPARC_RET_SINT8) - ldsb [FP-160+7], %i0 - return %i7+8 - nop -E(SPARC_RET_UINT16) - lduh [FP-160+6], %i0 - return %i7+8 - nop -E(SPARC_RET_SINT16) - ldsh [FP-160+6], %i0 - return %i7+8 - nop -E(SPARC_RET_UINT32) - lduw [FP-160+4], %i0 - return %i7+8 - nop -E(SP_V9_RET_SINT32) - ldsw [FP-160+4], %i0 - return %i7+8 - nop -E(SPARC_RET_INT64) - ldx [FP-160], %i0 - return %i7+8 - nop -E(SPARC_RET_INT128) - ldx [FP-160], %i0 - ldx [FP-160+8], %i1 - return %i7+8 - nop -E(SPARC_RET_F_8) - ld [FP-160+7*4], %f7 - nop - ld [FP-160+6*4], %f6 - nop -E(SPARC_RET_F_6) - ld [FP-160+5*4], %f5 - nop - ld [FP-160+4*4], %f4 - nop -E(SPARC_RET_F_4) - ldd [FP-160], %f0 - ldd [FP-160+8], %f2 - return %i7+8 - nop -E(SPARC_RET_F_2) - ldd [FP-160], %f0 - return %i7+8 - nop -E(SP_V9_RET_F_3) - ld [FP-160+2*4], %f2 - nop - ld [FP-160+1*4], %f1 - nop -E(SPARC_RET_F_1) - ld [FP-160], %f0 - return %i7+8 - nop - - ! Finish the SPARC_RET_STRUCT sequence. - .align 8 -8: ldd [FP-152], %f2 - ldx [FP-144], %i2 - ldd [FP-144], %f4 - ldx [FP-136], %i3 - ldd [FP-136], %f6 - return %i7+8 - nop - -.LUW8: - .size C(ffi_closure_v9), . - C(ffi_closure_v9) - -#ifdef HAVE_RO_EH_FRAME - .section ".eh_frame",#alloc -#else - .section ".eh_frame",#alloc,#write -#endif - -#ifdef HAVE_AS_SPARC_UA_PCREL -# define FDE_RANGE(B, E) .long %r_disp32(B), E - B -#else -# define FDE_RANGE(B, E) .align 8; .xword B, E - B -#endif - - .align 8 -.LCIE: - .long .LECIE - .LSCIE ! CIE Length -.LSCIE: - .long 0 ! CIE Identifier Tag - .byte 1 ! CIE Version - .ascii "zR\0" ! CIE Augmentation - .byte 4 ! CIE Code Alignment Factor - .byte 0x78 ! CIE Data Alignment Factor - .byte 15 ! CIE RA Column - .byte 1 ! Augmentation size -#ifdef HAVE_AS_SPARC_UA_PCREL - .byte 0x1b ! FDE Encoding (pcrel sdata4) -#else - .byte 0x50 ! FDE Encoding (aligned absolute) -#endif - .byte 0xc, 14, 0xff, 0xf ! DW_CFA_def_cfa, %o6, offset 0x7ff - .align 8 -.LECIE: - - .long .LEFDE1 - .LSFDE1 ! FDE Length -.LSFDE1: - .long .LSFDE1 - .LCIE ! FDE CIE offset - FDE_RANGE(.LUW0, .LUW2) - .byte 0 ! Augmentation size - .byte 0x40+1 ! DW_CFA_advance_loc 4 - .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 - .byte 0x2d ! DW_CFA_GNU_window_save - .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 - .align 8 -.LEFDE1: - - .long .LEFDE2 - .LSFDE2 ! FDE Length -.LSFDE2: - .long .LSFDE2 - .LCIE ! FDE CIE offset - FDE_RANGE(.LUW3, .LUW5) - .byte 0 ! Augmentation size - .byte 0x40+1 ! DW_CFA_advance_loc 4 - .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 - .byte 0x2d ! DW_CFA_GNU_window_save - .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 - .align 8 -.LEFDE2: - - .long .LEFDE3 - .LSFDE3 ! FDE Length -.LSFDE3: - .long .LSFDE3 - .LCIE ! FDE CIE offset - FDE_RANGE(.LUW6, .LUW8) - .byte 0 ! Augmentation size - .byte 0x40+1 ! DW_CFA_advance_loc 4 - .byte 0xd, 30 ! DW_CFA_def_cfa_register, %i6 - .byte 0x2d ! DW_CFA_GNU_window_save - .byte 0x9, 15, 31 ! DW_CFA_register, %o7, %i7 - .align 8 -.LEFDE3: - -#endif /* SPARC64 */ -#ifdef __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/tile/ffi.c b/user/mpy/lib/libffi/src/tile/ffi.c deleted file mode 100644 index 3a94469..0000000 --- a/user/mpy/lib/libffi/src/tile/ffi.c +++ /dev/null @@ -1,355 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012 Tilera Corp. - - TILE Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -/* The first 10 registers are used to pass arguments and return values. */ -#define NUM_ARG_REGS 10 - -/* Performs a raw function call with the given NUM_ARG_REGS register arguments - and the specified additional stack arguments (if any). */ -extern void ffi_call_tile(ffi_sarg reg_args[NUM_ARG_REGS], - const ffi_sarg *stack_args, - size_t stack_args_bytes, - void (*fnaddr)(void)) - FFI_HIDDEN; - -/* This handles the raw call from the closure stub, cleaning up the - parameters and delegating to ffi_closure_tile_inner. */ -extern void ffi_closure_tile(void) FFI_HIDDEN; - - -ffi_status -ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* We always allocate room for all registers. Even if we don't - use them as parameters, they get returned in the same array - as struct return values so we need to make room. */ - if (cif->bytes < NUM_ARG_REGS * FFI_SIZEOF_ARG) - cif->bytes = NUM_ARG_REGS * FFI_SIZEOF_ARG; - - if (cif->rtype->size > NUM_ARG_REGS * FFI_SIZEOF_ARG) - cif->flags = FFI_TYPE_STRUCT; - else - cif->flags = FFI_TYPE_INT; - - /* Nothing to do. */ - return FFI_OK; -} - - -static long -assign_to_ffi_arg(ffi_sarg *out, void *in, const ffi_type *type, - int write_to_reg) -{ - switch (type->type) - { - case FFI_TYPE_SINT8: - *out = *(SINT8 *)in; - return 1; - - case FFI_TYPE_UINT8: - *out = *(UINT8 *)in; - return 1; - - case FFI_TYPE_SINT16: - *out = *(SINT16 *)in; - return 1; - - case FFI_TYPE_UINT16: - *out = *(UINT16 *)in; - return 1; - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: -#ifndef __LP64__ - case FFI_TYPE_POINTER: -#endif - /* Note that even unsigned 32-bit quantities are sign extended - on tilegx when stored in a register. */ - *out = *(SINT32 *)in; - return 1; - - case FFI_TYPE_FLOAT: -#ifdef __tilegx__ - if (write_to_reg) - { - /* Properly sign extend the value. */ - union { float f; SINT32 s32; } val; - val.f = *(float *)in; - *out = val.s32; - } - else -#endif - { - *(float *)out = *(float *)in; - } - return 1; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: -#ifdef __LP64__ - case FFI_TYPE_POINTER: -#endif - *(UINT64 *)out = *(UINT64 *)in; - return sizeof(UINT64) / FFI_SIZEOF_ARG; - - case FFI_TYPE_STRUCT: - memcpy(out, in, type->size); - return (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; - - case FFI_TYPE_VOID: - /* Must be a return type. Nothing to do. */ - return 0; - - default: - FFI_ASSERT(0); - return -1; - } -} - - -void -ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_sarg * const arg_mem = alloca(cif->bytes); - ffi_sarg * const reg_args = arg_mem; - ffi_sarg * const stack_args = ®_args[NUM_ARG_REGS]; - ffi_sarg *argp = arg_mem; - ffi_type ** const arg_types = cif->arg_types; - const long num_args = cif->nargs; - long i; - - if (cif->flags == FFI_TYPE_STRUCT) - { - /* Pass a hidden pointer to the return value. We make sure there - is scratch space for the callee to store the return value even if - our caller doesn't care about it. */ - *argp++ = (intptr_t)(rvalue ? rvalue : alloca(cif->rtype->size)); - - /* No more work needed to return anything. */ - rvalue = NULL; - } - - for (i = 0; i < num_args; i++) - { - ffi_type *type = arg_types[i]; - void * const arg_in = avalue[i]; - ptrdiff_t arg_word = argp - arg_mem; - -#ifndef __tilegx__ - /* Doubleword-aligned values are always in an even-number register - pair, or doubleword-aligned stack slot if out of registers. */ - long align = arg_word & (type->alignment > FFI_SIZEOF_ARG); - argp += align; - arg_word += align; -#endif - - if (type->type == FFI_TYPE_STRUCT) - { - const size_t arg_size_in_words = - (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; - - if (arg_word < NUM_ARG_REGS && - arg_word + arg_size_in_words > NUM_ARG_REGS) - { - /* Args are not allowed to span registers and the stack. */ - argp = stack_args; - } - - memcpy(argp, arg_in, type->size); - argp += arg_size_in_words; - } - else - { - argp += assign_to_ffi_arg(argp, arg_in, arg_types[i], 1); - } - } - - /* Actually do the call. */ - ffi_call_tile(reg_args, stack_args, - cif->bytes - (NUM_ARG_REGS * FFI_SIZEOF_ARG), fn); - - if (rvalue != NULL) - assign_to_ffi_arg(rvalue, reg_args, cif->rtype, 0); -} - - -/* Template code for closure. */ -extern const UINT64 ffi_template_tramp_tile[] FFI_HIDDEN; - - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ -#ifdef __tilegx__ - /* TILE-Gx */ - SINT64 c; - SINT64 h; - int s; - UINT64 *out; - - if (cif->abi != FFI_UNIX) - return FFI_BAD_ABI; - - out = (UINT64 *)closure->tramp; - - c = (intptr_t)closure; - h = (intptr_t)ffi_closure_tile; - s = 0; - - /* Find the smallest shift count that doesn't lose information - (i.e. no need to explicitly insert high bits of the address that - are just the sign extension of the low bits). */ - while ((c >> s) != (SINT16)(c >> s) || (h >> s) != (SINT16)(h >> s)) - s += 16; - -#define OPS(a, b, shift) \ - (create_Imm16_X0((a) >> (shift)) | create_Imm16_X1((b) >> (shift))) - - /* Emit the moveli. */ - *out++ = ffi_template_tramp_tile[0] | OPS(c, h, s); - for (s -= 16; s >= 0; s -= 16) - *out++ = ffi_template_tramp_tile[1] | OPS(c, h, s); - -#undef OPS - - *out++ = ffi_template_tramp_tile[2]; - -#else - /* TILEPro */ - UINT64 *out; - intptr_t delta; - - if (cif->abi != FFI_UNIX) - return FFI_BAD_ABI; - - out = (UINT64 *)closure->tramp; - delta = (intptr_t)ffi_closure_tile - (intptr_t)codeloc; - - *out++ = ffi_template_tramp_tile[0] | create_JOffLong_X1(delta >> 3); -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - invalidate_icache(closure->tramp, (char *)out - closure->tramp, - getpagesize()); - - return FFI_OK; -} - - -/* This is called by the assembly wrapper for closures. This does - all of the work. On entry reg_args[0] holds the values the registers - had when the closure was invoked. On return reg_args[1] holds the register - values to be returned to the caller (many of which may be garbage). */ -void FFI_HIDDEN -ffi_closure_tile_inner(ffi_closure *closure, - ffi_sarg reg_args[2][NUM_ARG_REGS], - ffi_sarg *stack_args) -{ - ffi_cif * const cif = closure->cif; - void ** const avalue = alloca(cif->nargs * sizeof(void *)); - void *rvalue; - ffi_type ** const arg_types = cif->arg_types; - ffi_sarg * const reg_args_in = reg_args[0]; - ffi_sarg * const reg_args_out = reg_args[1]; - ffi_sarg * argp; - long i, arg_word, nargs = cif->nargs; - /* Use a union to guarantee proper alignment for double. */ - union { ffi_sarg arg[NUM_ARG_REGS]; double d; UINT64 u64; } closure_ret; - - /* Start out reading register arguments. */ - argp = reg_args_in; - - /* Copy the caller's structure return address to that the closure - returns the data directly to the caller. */ - if (cif->flags == FFI_TYPE_STRUCT) - { - /* Return by reference via hidden pointer. */ - rvalue = (void *)(intptr_t)*argp++; - arg_word = 1; - } - else - { - /* Return the value in registers. */ - rvalue = &closure_ret; - arg_word = 0; - } - - /* Grab the addresses of the arguments. */ - for (i = 0; i < nargs; i++) - { - ffi_type * const type = arg_types[i]; - const size_t arg_size_in_words = - (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; - -#ifndef __tilegx__ - /* Doubleword-aligned values are always in an even-number register - pair, or doubleword-aligned stack slot if out of registers. */ - long align = arg_word & (type->alignment > FFI_SIZEOF_ARG); - argp += align; - arg_word += align; -#endif - - if (arg_word == NUM_ARG_REGS || - (arg_word < NUM_ARG_REGS && - arg_word + arg_size_in_words > NUM_ARG_REGS)) - { - /* Switch to reading arguments from the stack. */ - argp = stack_args; - arg_word = NUM_ARG_REGS; - } - - avalue[i] = argp; - argp += arg_size_in_words; - arg_word += arg_size_in_words; - } - - /* Invoke the closure. */ - closure->fun(cif, rvalue, avalue, closure->user_data); - - if (cif->flags != FFI_TYPE_STRUCT) - { - /* Canonicalize for register representation. */ - assign_to_ffi_arg(reg_args_out, &closure_ret, cif->rtype, 1); - } -} diff --git a/user/mpy/lib/libffi/src/tile/ffitarget.h b/user/mpy/lib/libffi/src/tile/ffitarget.h deleted file mode 100644 index 679fb5d..0000000 --- a/user/mpy/lib/libffi/src/tile/ffitarget.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Tilera Corp. - Target configuration macros for TILE. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM - -#include - -typedef uint_reg_t ffi_arg; -typedef int_reg_t ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_UNIX, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_UNIX -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ -#define FFI_CLOSURES 1 - -#ifdef __tilegx__ -/* We always pass 8-byte values, even in -m32 mode. */ -# define FFI_SIZEOF_ARG 8 -# ifdef __LP64__ -# define FFI_TRAMPOLINE_SIZE (8 * 5) /* 5 bundles */ -# else -# define FFI_TRAMPOLINE_SIZE (8 * 3) /* 3 bundles */ -# endif -#else -# define FFI_SIZEOF_ARG 4 -# define FFI_TRAMPOLINE_SIZE 8 /* 1 bundle */ -#endif -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/tile/tile.S b/user/mpy/lib/libffi/src/tile/tile.S deleted file mode 100644 index d1f82cb..0000000 --- a/user/mpy/lib/libffi/src/tile/tile.S +++ /dev/null @@ -1,360 +0,0 @@ -/* ----------------------------------------------------------------------- - tile.S - Copyright (c) 2011 Tilera Corp. - - Tilera TILEPro and TILE-Gx Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -/* Number of bytes in a register. */ -#define REG_SIZE FFI_SIZEOF_ARG - -/* Number of bytes in stack linkage area for backtracing. - - A note about the ABI: on entry to a procedure, sp points to a stack - slot where it must spill the return address if it's not a leaf. - REG_SIZE bytes beyond that is a slot owned by the caller which - contains the sp value that the caller had when it was originally - entered (i.e. the caller's frame pointer). */ -#define LINKAGE_SIZE (2 * REG_SIZE) - -/* The first 10 registers are used to pass arguments and return values. */ -#define NUM_ARG_REGS 10 - -#ifdef __tilegx__ -#define SW st -#define LW ld -#define BGZT bgtzt -#else -#define SW sw -#define LW lw -#define BGZT bgzt -#endif - - -/* void ffi_call_tile (int_reg_t reg_args[NUM_ARG_REGS], - const int_reg_t *stack_args, - unsigned long stack_args_bytes, - void (*fnaddr)(void)); - - On entry, REG_ARGS contain the outgoing register values, - and STACK_ARGS contains STACK_ARG_BYTES of additional values - to be passed on the stack. If STACK_ARG_BYTES is zero, then - STACK_ARGS is ignored. - - When the invoked function returns, the values of r0-r9 are - blindly stored back into REG_ARGS for the caller to examine. */ - - .section .text.ffi_call_tile, "ax", @progbits - .align 8 - .globl ffi_call_tile - FFI_HIDDEN(ffi_call_tile) -ffi_call_tile: - -/* Incoming arguments. */ -#define REG_ARGS r0 -#define INCOMING_STACK_ARGS r1 -#define STACK_ARG_BYTES r2 -#define ORIG_FNADDR r3 - -/* Temporary values. */ -#define FRAME_SIZE r10 -#define TMP r11 -#define TMP2 r12 -#define OUTGOING_STACK_ARGS r13 -#define REG_ADDR_PTR r14 -#define RETURN_REG_ADDR r15 -#define FNADDR r16 - - .cfi_startproc - { - /* Save return address. */ - SW sp, lr - .cfi_offset lr, 0 - /* Prepare to spill incoming r52. */ - addi TMP, sp, -REG_SIZE - /* Increase frame size to have room to spill r52 and REG_ARGS. - The +7 is to round up mod 8. */ - addi FRAME_SIZE, STACK_ARG_BYTES, \ - REG_SIZE + REG_SIZE + LINKAGE_SIZE + 7 - } - { - /* Round stack frame size to a multiple of 8 to satisfy ABI. */ - andi FRAME_SIZE, FRAME_SIZE, -8 - /* Compute where to spill REG_ARGS value. */ - addi TMP2, sp, -(REG_SIZE * 2) - } - { - /* Spill incoming r52. */ - SW TMP, r52 - .cfi_offset r52, -REG_SIZE - /* Set up our frame pointer. */ - move r52, sp - .cfi_def_cfa_register r52 - /* Push stack frame. */ - sub sp, sp, FRAME_SIZE - } - { - /* Prepare to set up stack linkage. */ - addi TMP, sp, REG_SIZE - /* Prepare to memcpy stack args. */ - addi OUTGOING_STACK_ARGS, sp, LINKAGE_SIZE - /* Save REG_ARGS which we will need after we call the subroutine. */ - SW TMP2, REG_ARGS - } - { - /* Set up linkage info to hold incoming stack pointer. */ - SW TMP, r52 - } - { - /* Skip stack args memcpy if we don't have any stack args (common). */ - blezt STACK_ARG_BYTES, .Ldone_stack_args_memcpy - } - -.Lmemcpy_stack_args: - { - /* Load incoming argument from stack_args. */ - LW TMP, INCOMING_STACK_ARGS - addi INCOMING_STACK_ARGS, INCOMING_STACK_ARGS, REG_SIZE - } - { - /* Store stack argument into outgoing stack argument area. */ - SW OUTGOING_STACK_ARGS, TMP - addi OUTGOING_STACK_ARGS, OUTGOING_STACK_ARGS, REG_SIZE - addi STACK_ARG_BYTES, STACK_ARG_BYTES, -REG_SIZE - } - { - BGZT STACK_ARG_BYTES, .Lmemcpy_stack_args - } -.Ldone_stack_args_memcpy: - - { - /* Copy aside ORIG_FNADDR so we can overwrite its register. */ - move FNADDR, ORIG_FNADDR - /* Prepare to load argument registers. */ - addi REG_ADDR_PTR, r0, REG_SIZE - /* Load outgoing r0. */ - LW r0, r0 - } - - /* Load up argument registers from the REG_ARGS array. */ -#define LOAD_REG(REG, PTR) \ - { \ - LW REG, PTR ; \ - addi PTR, PTR, REG_SIZE \ - } - - LOAD_REG(r1, REG_ADDR_PTR) - LOAD_REG(r2, REG_ADDR_PTR) - LOAD_REG(r3, REG_ADDR_PTR) - LOAD_REG(r4, REG_ADDR_PTR) - LOAD_REG(r5, REG_ADDR_PTR) - LOAD_REG(r6, REG_ADDR_PTR) - LOAD_REG(r7, REG_ADDR_PTR) - LOAD_REG(r8, REG_ADDR_PTR) - LOAD_REG(r9, REG_ADDR_PTR) - - { - /* Call the subroutine. */ - jalr FNADDR - } - - { - /* Restore original lr. */ - LW lr, r52 - /* Prepare to recover ARGS, which we spilled earlier. */ - addi TMP, r52, -(2 * REG_SIZE) - } - { - /* Restore ARGS, so we can fill it in with the return regs r0-r9. */ - LW RETURN_REG_ADDR, TMP - /* Prepare to restore original r52. */ - addi TMP, r52, -REG_SIZE - } - - { - /* Pop stack frame. */ - move sp, r52 - /* Restore original r52. */ - LW r52, TMP - } - -#define STORE_REG(REG, PTR) \ - { \ - SW PTR, REG ; \ - addi PTR, PTR, REG_SIZE \ - } - - /* Return all register values by reference. */ - STORE_REG(r0, RETURN_REG_ADDR) - STORE_REG(r1, RETURN_REG_ADDR) - STORE_REG(r2, RETURN_REG_ADDR) - STORE_REG(r3, RETURN_REG_ADDR) - STORE_REG(r4, RETURN_REG_ADDR) - STORE_REG(r5, RETURN_REG_ADDR) - STORE_REG(r6, RETURN_REG_ADDR) - STORE_REG(r7, RETURN_REG_ADDR) - STORE_REG(r8, RETURN_REG_ADDR) - STORE_REG(r9, RETURN_REG_ADDR) - - { - jrp lr - } - - .cfi_endproc - .size ffi_call_tile, .-ffi_call_tile - -/* ffi_closure_tile(...) - - On entry, lr points to the closure plus 8 bytes, and r10 - contains the actual return address. - - This function simply dumps all register parameters into a stack array - and passes the closure, the registers array, and the stack arguments - to C code that does all of the actual closure processing. */ - - .section .text.ffi_closure_tile, "ax", @progbits - .align 8 - .globl ffi_closure_tile - FFI_HIDDEN(ffi_closure_tile) - - .cfi_startproc -/* Room to spill all NUM_ARG_REGS incoming registers, plus frame linkage. */ -#define CLOSURE_FRAME_SIZE (((NUM_ARG_REGS * REG_SIZE * 2 + LINKAGE_SIZE) + 7) & -8) -ffi_closure_tile: - { -#ifdef __tilegx__ - st sp, lr - .cfi_offset lr, 0 -#else - /* Save return address (in r10 due to closure stub wrapper). */ - SW sp, r10 - .cfi_return_column r10 - .cfi_offset r10, 0 -#endif - /* Compute address for stack frame linkage. */ - addli r10, sp, -(CLOSURE_FRAME_SIZE - REG_SIZE) - } - { - /* Save incoming stack pointer in linkage area. */ - SW r10, sp - .cfi_offset sp, -(CLOSURE_FRAME_SIZE - REG_SIZE) - /* Push a new stack frame. */ - addli sp, sp, -CLOSURE_FRAME_SIZE - .cfi_adjust_cfa_offset CLOSURE_FRAME_SIZE - } - - { - /* Create pointer to where to start spilling registers. */ - addi r10, sp, LINKAGE_SIZE - } - - /* Spill all the incoming registers. */ - STORE_REG(r0, r10) - STORE_REG(r1, r10) - STORE_REG(r2, r10) - STORE_REG(r3, r10) - STORE_REG(r4, r10) - STORE_REG(r5, r10) - STORE_REG(r6, r10) - STORE_REG(r7, r10) - STORE_REG(r8, r10) - { - /* Save r9. */ - SW r10, r9 -#ifdef __tilegx__ - /* Pointer to closure is passed in r11. */ - move r0, r11 -#else - /* Compute pointer to the closure object. Because the closure - starts with a "jal ffi_closure_tile", we can just take the - value of lr (a phony return address pointing into the closure) - and subtract 8. */ - addi r0, lr, -8 -#endif - /* Compute a pointer to the register arguments we just spilled. */ - addi r1, sp, LINKAGE_SIZE - } - { - /* Compute a pointer to the extra stack arguments (if any). */ - addli r2, sp, CLOSURE_FRAME_SIZE + LINKAGE_SIZE - /* Call C code to deal with all of the grotty details. */ - jal ffi_closure_tile_inner - } - { - addli r10, sp, CLOSURE_FRAME_SIZE - } - { - /* Restore the return address. */ - LW lr, r10 - /* Compute pointer to registers array. */ - addli r10, sp, LINKAGE_SIZE + (NUM_ARG_REGS * REG_SIZE) - } - /* Return all the register values, which C code may have set. */ - LOAD_REG(r0, r10) - LOAD_REG(r1, r10) - LOAD_REG(r2, r10) - LOAD_REG(r3, r10) - LOAD_REG(r4, r10) - LOAD_REG(r5, r10) - LOAD_REG(r6, r10) - LOAD_REG(r7, r10) - LOAD_REG(r8, r10) - LOAD_REG(r9, r10) - { - /* Pop the frame. */ - addli sp, sp, CLOSURE_FRAME_SIZE - jrp lr - } - - .cfi_endproc - .size ffi_closure_tile, . - ffi_closure_tile - - -/* What follows are code template instructions that get copied to the - closure trampoline by ffi_prep_closure_loc. The zeroed operands - get replaced by their proper values at runtime. */ - - .section .text.ffi_template_tramp_tile, "ax", @progbits - .align 8 - .globl ffi_template_tramp_tile - FFI_HIDDEN(ffi_template_tramp_tile) -ffi_template_tramp_tile: -#ifdef __tilegx__ - { - moveli r11, 0 /* backpatched to address of containing closure. */ - moveli r10, 0 /* backpatched to ffi_closure_tile. */ - } - /* Note: the following bundle gets generated multiple times - depending on the pointer value (esp. useful for -m32 mode). */ - { shl16insli r11, r11, 0 ; shl16insli r10, r10, 0 } - { info 2+8 /* for backtracer: -> pc in lr, frame size 0 */ ; jr r10 } -#else - /* 'jal .' yields a PC-relative offset of zero so we can OR in the - right offset at runtime. */ - { move r10, lr ; jal . /* ffi_closure_tile */ } -#endif - - .size ffi_template_tramp_tile, . - ffi_template_tramp_tile diff --git a/user/mpy/lib/libffi/src/types.c b/user/mpy/lib/libffi/src/types.c deleted file mode 100644 index 7e80aec..0000000 --- a/user/mpy/lib/libffi/src/types.c +++ /dev/null @@ -1,106 +0,0 @@ -/* ----------------------------------------------------------------------- - types.c - Copyright (c) 1996, 1998 Red Hat, Inc. - - Predefined ffi_types needed by libffi. - - 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. - ----------------------------------------------------------------------- */ - -/* Hide the basic type definitions from the header file, so that we - can redefine them here as "const". */ -#define LIBFFI_HIDE_BASIC_TYPES - -#include -#include - -/* Type definitions */ - -#define FFI_TYPEDEF(name, type, id, maybe_const)\ -struct struct_align_##name { \ - char c; \ - type x; \ -}; \ -maybe_const ffi_type ffi_type_##name = { \ - sizeof(type), \ - offsetof(struct struct_align_##name, x), \ - id, NULL \ -} - -#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \ -static ffi_type *ffi_elements_complex_##name [2] = { \ - (ffi_type *)(&ffi_type_##name), NULL \ -}; \ -struct struct_align_complex_##name { \ - char c; \ - _Complex type x; \ -}; \ -maybe_const ffi_type ffi_type_complex_##name = { \ - sizeof(_Complex type), \ - offsetof(struct struct_align_complex_##name, x), \ - FFI_TYPE_COMPLEX, \ - (ffi_type **)ffi_elements_complex_##name \ -} - -/* Size and alignment are fake here. They must not be 0. */ -const ffi_type ffi_type_void = { - 1, 1, FFI_TYPE_VOID, NULL -}; - -FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8, const); -FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8, const); -FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16, const); -FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16, const); -FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32, const); -FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32, const); -FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64, const); -FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64, const); - -FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER, const); - -FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT, const); -FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE, const); - -#if !defined HAVE_LONG_DOUBLE_VARIANT || defined __alpha__ -#define FFI_LDBL_CONST const -#else -#define FFI_LDBL_CONST -#endif - -#ifdef __alpha__ -/* Even if we're not configured to default to 128-bit long double, - maintain binary compatibility, as -mlong-double-128 can be used - at any time. */ -/* Validate the hard-coded number below. */ -# if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4 -# error FFI_TYPE_LONGDOUBLE out of date -# endif -const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL }; -#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST); -#endif - -#ifdef FFI_TARGET_HAS_COMPLEX_TYPE -FFI_COMPLEX_TYPEDEF(float, float, const); -FFI_COMPLEX_TYPEDEF(double, double, const); -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST); -#endif -#endif diff --git a/user/mpy/lib/libffi/src/vax/elfbsd.S b/user/mpy/lib/libffi/src/vax/elfbsd.S deleted file mode 100644 index 01ca313..0000000 --- a/user/mpy/lib/libffi/src/vax/elfbsd.S +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2013 Miodrag Vallat. - * - * 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. - */ - -/* - * vax Foreign Function Interface - */ - -#define LIBFFI_ASM -#include -#include - - .text - -/* - * void * %r0 - * ffi_call_elfbsd(extended_cif *ecif, 4(%ap) - * unsigned bytes, 8(%ap) - * unsigned flags, 12(%ap) - * void *rvalue, 16(%ap) - * void (*fn)()); 20(%ap) - */ - .globl ffi_call_elfbsd - .type ffi_call_elfbsd,@function - .align 2 -ffi_call_elfbsd: - .word 0x00c # save R2 and R3 - - # Allocate stack space for the args - subl2 8(%ap), %sp - - # Call ffi_prep_args - pushl %sp - pushl 4(%ap) - calls $2, ffi_prep_args - - # Get function pointer - movl 20(%ap), %r1 - - # Build a CALLS frame - ashl $-2, 8(%ap), %r0 - pushl %r0 # argument stack usage - movl %sp, %r0 # future %ap - # saved registers - bbc $11, 0(%r1), 1f - pushl %r11 -1: bbc $10, 0(%r1), 1f - pushl %r10 -1: bbc $9, 0(%r1), 1f - pushl %r9 -1: bbc $8, 0(%r1), 1f - pushl %r8 -1: bbc $7, 0(%r1), 1f - pushl %r7 -1: bbc $6, 0(%r1), 1f - pushl %r6 -1: bbc $5, 0(%r1), 1f - pushl %r5 -1: bbc $4, 0(%r1), 1f - pushl %r4 -1: bbc $3, 0(%r1), 1f - pushl %r3 -1: bbc $2, 0(%r1), 1f - pushl %r2 -1: - pushal 9f - pushl %fp - pushl %ap - movl 16(%ap), %r3 # struct return address, if needed - movl %r0, %ap - movzwl 4(%fp), %r0 # previous PSW, without the saved registers mask - bisl2 $0x20000000, %r0 # calls frame - movzwl 0(%r1), %r2 - bicw2 $0xf003, %r2 # only keep R11-R2 - ashl $16, %r2, %r2 - bisl2 %r2, %r0 # saved register mask of the called function - pushl %r0 - pushl $0 - movl %sp, %fp - - # Invoke the function - pushal 2(%r1) # skip procedure entry mask - movl %r3, %r1 - bicpsw $0x000f - rsb - -9: - # Copy return value if necessary - tstl 16(%ap) - jeql 9f - movl 16(%ap), %r2 - - bbc $0, 12(%ap), 1f # CIF_FLAGS_CHAR - movb %r0, 0(%r2) - brb 9f -1: - bbc $1, 12(%ap), 1f # CIF_FLAGS_SHORT - movw %r0, 0(%r2) - brb 9f -1: - bbc $2, 12(%ap), 1f # CIF_FLAGS_INT - movl %r0, 0(%r2) - brb 9f -1: - bbc $3, 12(%ap), 1f # CIF_FLAGS_DINT - movq %r0, 0(%r2) - brb 9f -1: - movl %r1, %r0 # might have been a struct - #brb 9f - -9: - ret - -/* - * ffi_closure_elfbsd(void); - * invoked with %r0: ffi_closure *closure - */ - .globl ffi_closure_elfbsd - .type ffi_closure_elfbsd, @function - .align 2 -ffi_closure_elfbsd: - .word 0 - - # Allocate room on stack for return value - subl2 $8, %sp - - # Invoke the closure function - pushal 4(%ap) # calling stack - pushal 4(%sp) # return value - pushl %r0 # closure - calls $3, ffi_closure_elfbsd_inner - - # Copy return value if necessary - bitb $1, %r0 # CIF_FLAGS_CHAR - beql 1f - movb 0(%sp), %r0 - brb 9f -1: - bitb $2, %r0 # CIF_FLAGS_SHORT - beql 1f - movw 0(%sp), %r0 - brb 9f -1: - bitb $4, %r0 # CIF_FLAGS_INT - beql 1f - movl 0(%sp), %r0 - brb 9f -1: - bitb $8, %r0 # CIF_FLAGS_DINT - beql 1f - movq 0(%sp), %r0 - #brb 9f -1: - -9: - ret - -/* - * ffi_closure_struct_elfbsd(void); - * invoked with %r0: ffi_closure *closure - * %r1: struct return address - */ - .globl ffi_closure_struct_elfbsd - .type ffi_closure_struct_elfbsd, @function - .align 2 -ffi_closure_struct_elfbsd: - .word 0 - - # Invoke the closure function - pushal 4(%ap) # calling stack - pushl %r1 # return value - pushl %r0 # closure - calls $3, ffi_closure_elfbsd_inner - - ret diff --git a/user/mpy/lib/libffi/src/vax/ffi.c b/user/mpy/lib/libffi/src/vax/ffi.c deleted file mode 100644 index f4d6bbb..0000000 --- a/user/mpy/lib/libffi/src/vax/ffi.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (c) 2013 Miodrag Vallat. - * - * 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. - */ - -/* - * vax Foreign Function Interface - * - * This file attempts to provide all the FFI entry points which can reliably - * be implemented in C. - */ - -#include -#include - -#include -#include - -#define CIF_FLAGS_CHAR 1 /* for struct only */ -#define CIF_FLAGS_SHORT 2 /* for struct only */ -#define CIF_FLAGS_INT 4 -#define CIF_FLAGS_DINT 8 - -/* - * Foreign Function Interface API - */ - -void ffi_call_elfbsd (extended_cif *, unsigned, unsigned, void *, - void (*) ()); -void *ffi_prep_args (extended_cif *ecif, void *stack); - -void * -ffi_prep_args (extended_cif *ecif, void *stack) -{ - unsigned int i; - void **p_argv; - char *argp; - ffi_type **p_arg; - void *struct_value_ptr; - - argp = stack; - - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT - && !ecif->cif->flags) - struct_value_ptr = ecif->rvalue; - else - struct_value_ptr = NULL; - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - i != 0; - i--, p_arg++) - { - size_t z; - - z = (*p_arg)->size; - if (z < sizeof (int)) - { - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv; - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) *(SINT16 *) *p_argv; - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv; - break; - - case FFI_TYPE_STRUCT: - memcpy (argp, *p_argv, z); - break; - - default: - FFI_ASSERT (0); - } - z = sizeof (int); - } - else - { - memcpy (argp, *p_argv, z); - - /* Align if necessary. */ - if ((sizeof(int) - 1) & z) - z = ALIGN(z, sizeof(int)); - } - - p_argv++; - argp += z; - } - - return struct_value_ptr; -} - -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - cif->flags = 0; - break; - - case FFI_TYPE_STRUCT: - if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT && - cif->rtype->elements[1]) - { - cif->flags = 0; - break; - } - - if (cif->rtype->size == sizeof (char)) - cif->flags = CIF_FLAGS_CHAR; - else if (cif->rtype->size == sizeof (short)) - cif->flags = CIF_FLAGS_SHORT; - else if (cif->rtype->size == sizeof (int)) - cif->flags = CIF_FLAGS_INT; - else if (cif->rtype->size == 2 * sizeof (int)) - cif->flags = CIF_FLAGS_DINT; - else - cif->flags = 0; - break; - - default: - if (cif->rtype->size <= sizeof (int)) - cif->flags = CIF_FLAGS_INT; - else - cif->flags = CIF_FLAGS_DINT; - break; - } - - return FFI_OK; -} - -void -ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return value - address then we need to make one. */ - - if (rvalue == NULL - && cif->rtype->type == FFI_TYPE_STRUCT - && cif->flags == 0) - ecif.rvalue = alloca (cif->rtype->size); - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_ELFBSD: - ffi_call_elfbsd (&ecif, cif->bytes, cif->flags, ecif.rvalue, fn); - break; - - default: - FFI_ASSERT (0); - break; - } -} - -/* - * Closure API - */ - -void ffi_closure_elfbsd (void); -void ffi_closure_struct_elfbsd (void); -unsigned int ffi_closure_elfbsd_inner (ffi_closure *, void *, char *); - -static void -ffi_prep_closure_elfbsd (ffi_cif *cif, void **avalue, char *stackp) -{ - unsigned int i; - void **p_argv; - ffi_type **p_arg; - - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++) - { - size_t z; - - z = (*p_arg)->size; - *p_argv = stackp; - - /* Align if necessary */ - if ((sizeof (int) - 1) & z) - z = ALIGN(z, sizeof (int)); - - p_argv++; - stackp += z; - } -} - -unsigned int -ffi_closure_elfbsd_inner (ffi_closure *closure, void *resp, char *stack) -{ - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void **) alloca (cif->nargs * sizeof (void *)); - - ffi_prep_closure_elfbsd (cif, arg_area, stack); - - (closure->fun) (cif, resp, arg_area, closure->user_data); - - return cif->flags; -} - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif, - void (*fun)(ffi_cif *, void *, void **, void *), - void *user_data, void *codeloc) -{ - char *tramp = (char *) codeloc; - void *fn; - - FFI_ASSERT (cif->abi == FFI_ELFBSD); - - /* entry mask */ - *(unsigned short *)(tramp + 0) = 0x0000; - /* movl #closure, r0 */ - tramp[2] = 0xd0; - tramp[3] = 0x8f; - *(unsigned int *)(tramp + 4) = (unsigned int) closure; - tramp[8] = 0x50; - - if (cif->rtype->type == FFI_TYPE_STRUCT - && !cif->flags) - fn = &ffi_closure_struct_elfbsd; - else - fn = &ffi_closure_elfbsd; - - /* jmpl #fn */ - tramp[9] = 0x17; - tramp[10] = 0xef; - *(unsigned int *)(tramp + 11) = (unsigned int)fn + 2 - - (unsigned int)tramp - 9 - 6; - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} diff --git a/user/mpy/lib/libffi/src/vax/ffitarget.h b/user/mpy/lib/libffi/src/vax/ffitarget.h deleted file mode 100644 index 2fc9488..0000000 --- a/user/mpy/lib/libffi/src/vax/ffitarget.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2013 Miodrag Vallat. - * - * 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. - */ - -/* - * vax Foreign Function Interface - */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_ELFBSD, - FFI_DEFAULT_ABI = FFI_ELFBSD, - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 15 -#define FFI_NATIVE_RAW_API 0 - -#endif diff --git a/user/mpy/lib/libffi/src/x86/ffi.c b/user/mpy/lib/libffi/src/x86/ffi.c deleted file mode 100644 index feb5cbb..0000000 --- a/user/mpy/lib/libffi/src/x86/ffi.c +++ /dev/null @@ -1,729 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc. - Copyright (c) 2002 Ranjit Mathew - Copyright (c) 2002 Bo Thorsen - Copyright (c) 2002 Roger Sayle - Copyright (C) 2008, 2010 Free Software Foundation, Inc. - - x86 Foreign Function Interface - - 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 __x86_64__ -#include -#include -#include -#include "internal.h" - -/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; - all further uses in this file will refer to the 80-bit type. */ -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -# if FFI_TYPE_LONGDOUBLE != 4 -# error FFI_TYPE_LONGDOUBLE out of date -# endif -#else -# undef FFI_TYPE_LONGDOUBLE -# define FFI_TYPE_LONGDOUBLE 4 -#endif - -#if defined(__GNUC__) && !defined(__declspec) -# define __declspec(x) __attribute__((x)) -#endif - -/* Perform machine dependent cif processing. */ -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep(ffi_cif *cif) -{ - size_t bytes = 0; - int i, n, flags, cabi = cif->abi; - - switch (cabi) - { - case FFI_SYSV: - case FFI_STDCALL: - case FFI_THISCALL: - case FFI_FASTCALL: - case FFI_MS_CDECL: - case FFI_PASCAL: - case FFI_REGISTER: - break; - default: - return FFI_BAD_ABI; - } - - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - flags = X86_RET_VOID; - break; - case FFI_TYPE_FLOAT: - flags = X86_RET_FLOAT; - break; - case FFI_TYPE_DOUBLE: - flags = X86_RET_DOUBLE; - break; - case FFI_TYPE_LONGDOUBLE: - flags = X86_RET_LDOUBLE; - break; - case FFI_TYPE_UINT8: - flags = X86_RET_UINT8; - break; - case FFI_TYPE_UINT16: - flags = X86_RET_UINT16; - break; - case FFI_TYPE_SINT8: - flags = X86_RET_SINT8; - break; - case FFI_TYPE_SINT16: - flags = X86_RET_SINT16; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - flags = X86_RET_INT32; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - flags = X86_RET_INT64; - break; - case FFI_TYPE_STRUCT: -#ifndef X86 - /* ??? This should be a different ABI rather than an ifdef. */ - if (cif->rtype->size == 1) - flags = X86_RET_STRUCT_1B; - else if (cif->rtype->size == 2) - flags = X86_RET_STRUCT_2B; - else if (cif->rtype->size == 4) - flags = X86_RET_INT32; - else if (cif->rtype->size == 8) - flags = X86_RET_INT64; - else -#endif - { - do_struct: - switch (cabi) - { - case FFI_THISCALL: - case FFI_FASTCALL: - case FFI_STDCALL: - case FFI_MS_CDECL: - flags = X86_RET_STRUCTARG; - break; - default: - flags = X86_RET_STRUCTPOP; - break; - } - /* Allocate space for return value pointer. */ - bytes += ALIGN (sizeof(void*), FFI_SIZEOF_ARG); - } - break; - case FFI_TYPE_COMPLEX: - switch (cif->rtype->elements[0]->type) - { - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - goto do_struct; - case FFI_TYPE_FLOAT: - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - flags = X86_RET_INT64; - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - flags = X86_RET_INT32; - break; - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - flags = X86_RET_STRUCT_2B; - break; - default: - return FFI_BAD_TYPEDEF; - } - break; - default: - return FFI_BAD_TYPEDEF; - } - cif->flags = flags; - - for (i = 0, n = cif->nargs; i < n; i++) - { - ffi_type *t = cif->arg_types[i]; - - bytes = ALIGN (bytes, t->alignment); - bytes += ALIGN (t->size, FFI_SIZEOF_ARG); - } - cif->bytes = ALIGN (bytes, 16); - - return FFI_OK; -} - -static ffi_arg -extend_basic_type(void *arg, int type) -{ - switch (type) - { - case FFI_TYPE_SINT8: - return *(SINT8 *)arg; - case FFI_TYPE_UINT8: - return *(UINT8 *)arg; - case FFI_TYPE_SINT16: - return *(SINT16 *)arg; - case FFI_TYPE_UINT16: - return *(UINT16 *)arg; - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - case FFI_TYPE_FLOAT: - return *(UINT32 *)arg; - - default: - abort(); - } -} - -struct call_frame -{ - void *ebp; /* 0 */ - void *retaddr; /* 4 */ - void (*fn)(void); /* 8 */ - int flags; /* 12 */ - void *rvalue; /* 16 */ - unsigned regs[3]; /* 20-28 */ -}; - -struct abi_params -{ - int dir; /* parameter growth direction */ - int static_chain; /* the static chain register used by gcc */ - int nregs; /* number of register parameters */ - int regs[3]; -}; - -static const struct abi_params abi_params[FFI_LAST_ABI] = { - [FFI_SYSV] = { 1, R_ECX, 0 }, - [FFI_THISCALL] = { 1, R_EAX, 1, { R_ECX } }, - [FFI_FASTCALL] = { 1, R_EAX, 2, { R_ECX, R_EDX } }, - [FFI_STDCALL] = { 1, R_ECX, 0 }, - [FFI_PASCAL] = { -1, R_ECX, 0 }, - /* ??? No defined static chain; gcc does not support REGISTER. */ - [FFI_REGISTER] = { -1, R_ECX, 3, { R_EAX, R_EDX, R_ECX } }, - [FFI_MS_CDECL] = { 1, R_ECX, 0 } -}; - -extern void ffi_call_i386(struct call_frame *, char *) -#if HAVE_FASTCALL - __declspec(fastcall) -#endif - FFI_HIDDEN; - -static void -ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - size_t rsize, bytes; - struct call_frame *frame; - char *stack, *argp; - ffi_type **arg_types; - int flags, cabi, i, n, dir, narg_reg; - const struct abi_params *pabi; - - flags = cif->flags; - cabi = cif->abi; - pabi = &abi_params[cabi]; - dir = pabi->dir; - - rsize = 0; - if (rvalue == NULL) - { - switch (flags) - { - case X86_RET_FLOAT: - case X86_RET_DOUBLE: - case X86_RET_LDOUBLE: - case X86_RET_STRUCTPOP: - case X86_RET_STRUCTARG: - /* The float cases need to pop the 387 stack. - The struct cases need to pass a valid pointer to the callee. */ - rsize = cif->rtype->size; - break; - default: - /* We can pretend that the callee returns nothing. */ - flags = X86_RET_VOID; - break; - } - } - - bytes = cif->bytes; - stack = alloca(bytes + sizeof(*frame) + rsize); - argp = (dir < 0 ? stack + bytes : stack); - frame = (struct call_frame *)(stack + bytes); - if (rsize) - rvalue = frame + 1; - - frame->fn = fn; - frame->flags = flags; - frame->rvalue = rvalue; - frame->regs[pabi->static_chain] = (unsigned)closure; - - narg_reg = 0; - switch (flags) - { - case X86_RET_STRUCTARG: - /* The pointer is passed as the first argument. */ - if (pabi->nregs > 0) - { - frame->regs[pabi->regs[0]] = (unsigned)rvalue; - narg_reg = 1; - break; - } - /* fallthru */ - case X86_RET_STRUCTPOP: - *(void **)argp = rvalue; - argp += sizeof(void *); - break; - } - - arg_types = cif->arg_types; - for (i = 0, n = cif->nargs; i < n; i++) - { - ffi_type *ty = arg_types[i]; - void *valp = avalue[i]; - size_t z = ty->size; - int t = ty->type; - - if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT) - { - ffi_arg val = extend_basic_type (valp, t); - - if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs) - frame->regs[pabi->regs[narg_reg++]] = val; - else if (dir < 0) - { - argp -= 4; - *(ffi_arg *)argp = val; - } - else - { - *(ffi_arg *)argp = val; - argp += 4; - } - } - else - { - size_t za = ALIGN (z, FFI_SIZEOF_ARG); - size_t align = FFI_SIZEOF_ARG; - - /* Alignment rules for arguments are quite complex. Vectors and - structures with 16 byte alignment get it. Note that long double - on Darwin does have 16 byte alignment, and does not get this - alignment if passed directly; a structure with a long double - inside, however, would get 16 byte alignment. Since libffi does - not support vectors, we need non concern ourselves with other - cases. */ - if (t == FFI_TYPE_STRUCT && ty->alignment >= 16) - align = 16; - - if (dir < 0) - { - /* ??? These reverse argument ABIs are probably too old - to have cared about alignment. Someone should check. */ - argp -= za; - memcpy (argp, valp, z); - } - else - { - argp = (char *)ALIGN (argp, align); - memcpy (argp, valp, z); - argp += za; - } - } - } - FFI_ASSERT (dir > 0 || argp == stack); - - ffi_call_i386 (frame, stack); -} - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} - -/** private members **/ - -void FFI_HIDDEN ffi_closure_i386(void); -void FFI_HIDDEN ffi_closure_STDCALL(void); -void FFI_HIDDEN ffi_closure_REGISTER(void); - -struct closure_frame -{ - unsigned rettemp[4]; /* 0 */ - unsigned regs[3]; /* 16-24 */ - ffi_cif *cif; /* 28 */ - void (*fun)(ffi_cif*,void*,void**,void*); /* 32 */ - void *user_data; /* 36 */ -}; - -int FFI_HIDDEN -#if HAVE_FASTCALL -__declspec(fastcall) -#endif -ffi_closure_inner (struct closure_frame *frame, char *stack) -{ - ffi_cif *cif = frame->cif; - int cabi, i, n, flags, dir, narg_reg; - const struct abi_params *pabi; - ffi_type **arg_types; - char *argp; - void *rvalue; - void **avalue; - - cabi = cif->abi; - flags = cif->flags; - narg_reg = 0; - rvalue = frame->rettemp; - pabi = &abi_params[cabi]; - dir = pabi->dir; - argp = (dir < 0 ? stack + cif->bytes : stack); - - switch (flags) - { - case X86_RET_STRUCTARG: - if (pabi->nregs > 0) - { - rvalue = (void *)frame->regs[pabi->regs[0]]; - narg_reg = 1; - frame->rettemp[0] = (unsigned)rvalue; - break; - } - /* fallthru */ - case X86_RET_STRUCTPOP: - rvalue = *(void **)argp; - argp += sizeof(void *); - frame->rettemp[0] = (unsigned)rvalue; - break; - } - - n = cif->nargs; - avalue = alloca(sizeof(void *) * n); - - arg_types = cif->arg_types; - for (i = 0; i < n; ++i) - { - ffi_type *ty = arg_types[i]; - size_t z = ty->size; - int t = ty->type; - void *valp; - - if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT) - { - if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs) - valp = &frame->regs[pabi->regs[narg_reg++]]; - else if (dir < 0) - { - argp -= 4; - valp = argp; - } - else - { - valp = argp; - argp += 4; - } - } - else - { - size_t za = ALIGN (z, FFI_SIZEOF_ARG); - size_t align = FFI_SIZEOF_ARG; - - /* See the comment in ffi_call_int. */ - if (t == FFI_TYPE_STRUCT && ty->alignment >= 16) - align = 16; - - if (dir < 0) - { - /* ??? These reverse argument ABIs are probably too old - to have cared about alignment. Someone should check. */ - argp -= za; - valp = argp; - } - else - { - argp = (char *)ALIGN (argp, align); - valp = argp; - argp += za; - } - } - - avalue[i] = valp; - } - - frame->fun (cif, rvalue, avalue, frame->user_data); - - if (cabi == FFI_STDCALL) - return flags + (cif->bytes << X86_RET_POP_SHIFT); - else - return flags; -} - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - char *tramp = closure->tramp; - void (*dest)(void); - int op = 0xb8; /* movl imm, %eax */ - - switch (cif->abi) - { - case FFI_SYSV: - case FFI_THISCALL: - case FFI_FASTCALL: - case FFI_MS_CDECL: - dest = ffi_closure_i386; - break; - case FFI_STDCALL: - case FFI_PASCAL: - dest = ffi_closure_STDCALL; - break; - case FFI_REGISTER: - dest = ffi_closure_REGISTER; - op = 0x68; /* pushl imm */ - default: - return FFI_BAD_ABI; - } - - /* movl or pushl immediate. */ - tramp[0] = op; - *(void **)(tramp + 1) = codeloc; - - /* jmp dest */ - tramp[5] = 0xe9; - *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10); - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -void FFI_HIDDEN ffi_go_closure_EAX(void); -void FFI_HIDDEN ffi_go_closure_ECX(void); -void FFI_HIDDEN ffi_go_closure_STDCALL(void); - -ffi_status -ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*)) -{ - void (*dest)(void); - - switch (cif->abi) - { - case FFI_SYSV: - case FFI_MS_CDECL: - dest = ffi_go_closure_ECX; - break; - case FFI_THISCALL: - case FFI_FASTCALL: - dest = ffi_go_closure_EAX; - break; - case FFI_STDCALL: - case FFI_PASCAL: - dest = ffi_go_closure_STDCALL; - break; - case FFI_REGISTER: - default: - return FFI_BAD_ABI; - } - - closure->tramp = dest; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -/* ------- Native raw API support -------------------------------- */ - -#if !FFI_NO_RAW_API - -void FFI_HIDDEN ffi_closure_raw_SYSV(void); -void FFI_HIDDEN ffi_closure_raw_THISCALL(void); - -ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure *closure, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc) -{ - char *tramp = closure->tramp; - void (*dest)(void); - int i; - - /* We currently don't support certain kinds of arguments for raw - closures. This should be implemented by a separate assembly - language routine, since it would require argument processing, - something we don't do now for performance. */ - for (i = cif->nargs-1; i >= 0; i--) - switch (cif->arg_types[i]->type) - { - case FFI_TYPE_STRUCT: - case FFI_TYPE_LONGDOUBLE: - return FFI_BAD_TYPEDEF; - } - - switch (cif->abi) - { - case FFI_THISCALL: - dest = ffi_closure_raw_THISCALL; - break; - case FFI_SYSV: - dest = ffi_closure_raw_SYSV; - break; - default: - return FFI_BAD_ABI; - } - - /* movl imm, %eax. */ - tramp[0] = 0xb8; - *(void **)(tramp + 1) = codeloc; - - /* jmp dest */ - tramp[5] = 0xe9; - *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10); - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -void -ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue) -{ - size_t rsize, bytes; - struct call_frame *frame; - char *stack, *argp; - ffi_type **arg_types; - int flags, cabi, i, n, narg_reg; - const struct abi_params *pabi; - - flags = cif->flags; - cabi = cif->abi; - pabi = &abi_params[cabi]; - - rsize = 0; - if (rvalue == NULL) - { - switch (flags) - { - case X86_RET_FLOAT: - case X86_RET_DOUBLE: - case X86_RET_LDOUBLE: - case X86_RET_STRUCTPOP: - case X86_RET_STRUCTARG: - /* The float cases need to pop the 387 stack. - The struct cases need to pass a valid pointer to the callee. */ - rsize = cif->rtype->size; - break; - default: - /* We can pretend that the callee returns nothing. */ - flags = X86_RET_VOID; - break; - } - } - - bytes = cif->bytes; - argp = stack = alloca(bytes + sizeof(*frame) + rsize); - frame = (struct call_frame *)(stack + bytes); - if (rsize) - rvalue = frame + 1; - - frame->fn = fn; - frame->flags = flags; - frame->rvalue = rvalue; - - narg_reg = 0; - switch (flags) - { - case X86_RET_STRUCTARG: - /* The pointer is passed as the first argument. */ - if (pabi->nregs > 0) - { - frame->regs[pabi->regs[0]] = (unsigned)rvalue; - narg_reg = 1; - break; - } - /* fallthru */ - case X86_RET_STRUCTPOP: - *(void **)argp = rvalue; - argp += sizeof(void *); - bytes -= sizeof(void *); - break; - } - - arg_types = cif->arg_types; - for (i = 0, n = cif->nargs; narg_reg < pabi->nregs && i < n; i++) - { - ffi_type *ty = arg_types[i]; - size_t z = ty->size; - int t = ty->type; - - if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT && t != FFI_TYPE_FLOAT) - { - ffi_arg val = extend_basic_type (avalue, t); - frame->regs[pabi->regs[narg_reg++]] = val; - z = FFI_SIZEOF_ARG; - } - else - { - memcpy (argp, avalue, z); - z = ALIGN (z, FFI_SIZEOF_ARG); - argp += z; - } - avalue += z; - bytes -= z; - } - if (i < n) - memcpy (argp, avalue, bytes); - - ffi_call_i386 (frame, stack); -} -#endif /* !FFI_NO_RAW_API */ -#endif /* !__x86_64__ */ diff --git a/user/mpy/lib/libffi/src/x86/ffi64.c b/user/mpy/lib/libffi/src/x86/ffi64.c deleted file mode 100644 index 131b5e3..0000000 --- a/user/mpy/lib/libffi/src/x86/ffi64.c +++ /dev/null @@ -1,824 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi64.c - Copyright (c) 2013 The Written Word, Inc. - Copyright (c) 2011 Anthony Green - Copyright (c) 2008, 2010 Red Hat, Inc. - Copyright (c) 2002, 2007 Bo Thorsen - - x86-64 Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -#include -#include -#include -#include "internal64.h" - -#ifdef __x86_64__ - -#define MAX_GPR_REGS 6 -#define MAX_SSE_REGS 8 - -#if defined(__INTEL_COMPILER) -#include "xmmintrin.h" -#define UINT128 __m128 -#else -#if defined(__SUNPRO_C) -#include -#define UINT128 __m128i -#else -#define UINT128 __int128_t -#endif -#endif - -union big_int_union -{ - UINT32 i32; - UINT64 i64; - UINT128 i128; -}; - -struct register_args -{ - /* Registers for argument passing. */ - UINT64 gpr[MAX_GPR_REGS]; - union big_int_union sse[MAX_SSE_REGS]; - UINT64 rax; /* ssecount */ - UINT64 r10; /* static chain */ -}; - -extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, - void *raddr, void (*fnaddr)(void)) FFI_HIDDEN; - -/* All reference to register classes here is identical to the code in - gcc/config/i386/i386.c. Do *not* change one without the other. */ - -/* Register class used for passing given 64bit part of the argument. - These represent classes as documented by the PS ABI, with the - exception of SSESF, SSEDF classes, that are basically SSE class, - just gcc will use SF or DFmode move instead of DImode to avoid - reformatting penalties. - - Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves - whenever possible (upper half does contain padding). */ -enum x86_64_reg_class - { - X86_64_NO_CLASS, - X86_64_INTEGER_CLASS, - X86_64_INTEGERSI_CLASS, - X86_64_SSE_CLASS, - X86_64_SSESF_CLASS, - X86_64_SSEDF_CLASS, - X86_64_SSEUP_CLASS, - X86_64_X87_CLASS, - X86_64_X87UP_CLASS, - X86_64_COMPLEX_X87_CLASS, - X86_64_MEMORY_CLASS - }; - -#define MAX_CLASSES 4 - -#define SSE_CLASS_P(X) ((X) >= X86_64_SSE_CLASS && X <= X86_64_SSEUP_CLASS) - -/* x86-64 register passing implementation. See x86-64 ABI for details. Goal - of this code is to classify each 8bytes of incoming argument by the register - class and assign registers accordingly. */ - -/* Return the union class of CLASS1 and CLASS2. - See the x86-64 PS ABI for details. */ - -static enum x86_64_reg_class -merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2) -{ - /* Rule #1: If both classes are equal, this is the resulting class. */ - if (class1 == class2) - return class1; - - /* Rule #2: If one of the classes is NO_CLASS, the resulting class is - the other class. */ - if (class1 == X86_64_NO_CLASS) - return class2; - if (class2 == X86_64_NO_CLASS) - return class1; - - /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */ - if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS) - return X86_64_MEMORY_CLASS; - - /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */ - if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS) - || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS)) - return X86_64_INTEGERSI_CLASS; - if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS - || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS) - return X86_64_INTEGER_CLASS; - - /* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class, - MEMORY is used. */ - if (class1 == X86_64_X87_CLASS - || class1 == X86_64_X87UP_CLASS - || class1 == X86_64_COMPLEX_X87_CLASS - || class2 == X86_64_X87_CLASS - || class2 == X86_64_X87UP_CLASS - || class2 == X86_64_COMPLEX_X87_CLASS) - return X86_64_MEMORY_CLASS; - - /* Rule #6: Otherwise class SSE is used. */ - return X86_64_SSE_CLASS; -} - -/* Classify the argument of type TYPE and mode MODE. - CLASSES will be filled by the register class used to pass each word - of the operand. The number of words is returned. In case the parameter - should be passed in memory, 0 is returned. As a special case for zero - sized containers, classes[0] will be NO_CLASS and 1 is returned. - - See the x86-64 PS ABI for details. -*/ -static size_t -classify_argument (ffi_type *type, enum x86_64_reg_class classes[], - size_t byte_offset) -{ - switch (type->type) - { - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_POINTER: - do_integer: - { - size_t size = byte_offset + type->size; - - if (size <= 4) - { - classes[0] = X86_64_INTEGERSI_CLASS; - return 1; - } - else if (size <= 8) - { - classes[0] = X86_64_INTEGER_CLASS; - return 1; - } - else if (size <= 12) - { - classes[0] = X86_64_INTEGER_CLASS; - classes[1] = X86_64_INTEGERSI_CLASS; - return 2; - } - else if (size <= 16) - { - classes[0] = classes[1] = X86_64_INTEGER_CLASS; - return 2; - } - else - FFI_ASSERT (0); - } - case FFI_TYPE_FLOAT: - if (!(byte_offset % 8)) - classes[0] = X86_64_SSESF_CLASS; - else - classes[0] = X86_64_SSE_CLASS; - return 1; - case FFI_TYPE_DOUBLE: - classes[0] = X86_64_SSEDF_CLASS; - return 1; -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - classes[0] = X86_64_X87_CLASS; - classes[1] = X86_64_X87UP_CLASS; - return 2; -#endif - case FFI_TYPE_STRUCT: - { - const size_t UNITS_PER_WORD = 8; - size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; - ffi_type **ptr; - int i; - enum x86_64_reg_class subclasses[MAX_CLASSES]; - - /* If the struct is larger than 32 bytes, pass it on the stack. */ - if (type->size > 32) - return 0; - - for (i = 0; i < words; i++) - classes[i] = X86_64_NO_CLASS; - - /* Zero sized arrays or structures are NO_CLASS. We return 0 to - signalize memory class, so handle it as special case. */ - if (!words) - { - case FFI_TYPE_VOID: - classes[0] = X86_64_NO_CLASS; - return 1; - } - - /* Merge the fields of structure. */ - for (ptr = type->elements; *ptr != NULL; ptr++) - { - size_t num; - - byte_offset = ALIGN (byte_offset, (*ptr)->alignment); - - num = classify_argument (*ptr, subclasses, byte_offset % 8); - if (num == 0) - return 0; - for (i = 0; i < num; i++) - { - size_t pos = byte_offset / 8; - classes[i + pos] = - merge_classes (subclasses[i], classes[i + pos]); - } - - byte_offset += (*ptr)->size; - } - - if (words > 2) - { - /* When size > 16 bytes, if the first one isn't - X86_64_SSE_CLASS or any other ones aren't - X86_64_SSEUP_CLASS, everything should be passed in - memory. */ - if (classes[0] != X86_64_SSE_CLASS) - return 0; - - for (i = 1; i < words; i++) - if (classes[i] != X86_64_SSEUP_CLASS) - return 0; - } - - /* Final merger cleanup. */ - for (i = 0; i < words; i++) - { - /* If one class is MEMORY, everything should be passed in - memory. */ - if (classes[i] == X86_64_MEMORY_CLASS) - return 0; - - /* The X86_64_SSEUP_CLASS should be always preceded by - X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */ - if (classes[i] == X86_64_SSEUP_CLASS - && classes[i - 1] != X86_64_SSE_CLASS - && classes[i - 1] != X86_64_SSEUP_CLASS) - { - /* The first one should never be X86_64_SSEUP_CLASS. */ - FFI_ASSERT (i != 0); - classes[i] = X86_64_SSE_CLASS; - } - - /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS, - everything should be passed in memory. */ - if (classes[i] == X86_64_X87UP_CLASS - && (classes[i - 1] != X86_64_X87_CLASS)) - { - /* The first one should never be X86_64_X87UP_CLASS. */ - FFI_ASSERT (i != 0); - return 0; - } - } - return words; - } - case FFI_TYPE_COMPLEX: - { - ffi_type *inner = type->elements[0]; - switch (inner->type) - { - case FFI_TYPE_INT: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - goto do_integer; - - case FFI_TYPE_FLOAT: - classes[0] = X86_64_SSE_CLASS; - if (byte_offset % 8) - { - classes[1] = X86_64_SSESF_CLASS; - return 2; - } - return 1; - case FFI_TYPE_DOUBLE: - classes[0] = classes[1] = X86_64_SSEDF_CLASS; - return 2; -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - classes[0] = X86_64_COMPLEX_X87_CLASS; - return 1; -#endif - } - } - } - abort(); -} - -/* Examine the argument and return set number of register required in each - class. Return zero iff parameter should be passed in memory, otherwise - the number of registers. */ - -static size_t -examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES], - _Bool in_return, int *pngpr, int *pnsse) -{ - size_t n; - int i, ngpr, nsse; - - n = classify_argument (type, classes, 0); - if (n == 0) - return 0; - - ngpr = nsse = 0; - for (i = 0; i < n; ++i) - switch (classes[i]) - { - case X86_64_INTEGER_CLASS: - case X86_64_INTEGERSI_CLASS: - ngpr++; - break; - case X86_64_SSE_CLASS: - case X86_64_SSESF_CLASS: - case X86_64_SSEDF_CLASS: - nsse++; - break; - case X86_64_NO_CLASS: - case X86_64_SSEUP_CLASS: - break; - case X86_64_X87_CLASS: - case X86_64_X87UP_CLASS: - case X86_64_COMPLEX_X87_CLASS: - return in_return != 0; - default: - abort (); - } - - *pngpr = ngpr; - *pnsse = nsse; - - return n; -} - -/* Perform machine dependent cif processing. */ - -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - int gprcount, ssecount, i, avn, ngpr, nsse, flags; - enum x86_64_reg_class classes[MAX_CLASSES]; - size_t bytes, n, rtype_size; - ffi_type *rtype; - - if (cif->abi != FFI_UNIX64) - return FFI_BAD_ABI; - - gprcount = ssecount = 0; - - rtype = cif->rtype; - rtype_size = rtype->size; - switch (rtype->type) - { - case FFI_TYPE_VOID: - flags = UNIX64_RET_VOID; - break; - case FFI_TYPE_UINT8: - flags = UNIX64_RET_UINT8; - break; - case FFI_TYPE_SINT8: - flags = UNIX64_RET_SINT8; - break; - case FFI_TYPE_UINT16: - flags = UNIX64_RET_UINT16; - break; - case FFI_TYPE_SINT16: - flags = UNIX64_RET_SINT16; - break; - case FFI_TYPE_UINT32: - flags = UNIX64_RET_UINT32; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - flags = UNIX64_RET_SINT32; - break; - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - flags = UNIX64_RET_INT64; - break; - case FFI_TYPE_POINTER: - flags = (sizeof(void *) == 4 ? UNIX64_RET_UINT32 : UNIX64_RET_INT64); - break; - case FFI_TYPE_FLOAT: - flags = UNIX64_RET_XMM32; - break; - case FFI_TYPE_DOUBLE: - flags = UNIX64_RET_XMM64; - break; - case FFI_TYPE_LONGDOUBLE: - flags = UNIX64_RET_X87; - break; - case FFI_TYPE_STRUCT: - n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse); - if (n == 0) - { - /* The return value is passed in memory. A pointer to that - memory is the first argument. Allocate a register for it. */ - gprcount++; - /* We don't have to do anything in asm for the return. */ - flags = UNIX64_RET_VOID | UNIX64_FLAG_RET_IN_MEM; - } - else - { - _Bool sse0 = SSE_CLASS_P (classes[0]); - - if (rtype_size == 4 && sse0) - flags = UNIX64_RET_XMM32; - else if (rtype_size == 8) - flags = sse0 ? UNIX64_RET_XMM64 : UNIX64_RET_INT64; - else - { - _Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]); - if (sse0 && sse1) - flags = UNIX64_RET_ST_XMM0_XMM1; - else if (sse0) - flags = UNIX64_RET_ST_XMM0_RAX; - else if (sse1) - flags = UNIX64_RET_ST_RAX_XMM0; - else - flags = UNIX64_RET_ST_RAX_RDX; - flags |= rtype_size << UNIX64_SIZE_SHIFT; - } - } - break; - case FFI_TYPE_COMPLEX: - switch (rtype->elements[0]->type) - { - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - flags = UNIX64_RET_ST_RAX_RDX | (rtype_size << UNIX64_SIZE_SHIFT); - break; - case FFI_TYPE_FLOAT: - flags = UNIX64_RET_XMM64; - break; - case FFI_TYPE_DOUBLE: - flags = UNIX64_RET_ST_XMM0_XMM1 | (16 << UNIX64_SIZE_SHIFT); - break; -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - flags = UNIX64_RET_X87_2; - break; -#endif - default: - return FFI_BAD_TYPEDEF; - } - break; - default: - return FFI_BAD_TYPEDEF; - } - - /* Go over all arguments and determine the way they should be passed. - If it's in a register and there is space for it, let that be so. If - not, add it's size to the stack byte count. */ - for (bytes = 0, i = 0, avn = cif->nargs; i < avn; i++) - { - if (examine_argument (cif->arg_types[i], classes, 0, &ngpr, &nsse) == 0 - || gprcount + ngpr > MAX_GPR_REGS - || ssecount + nsse > MAX_SSE_REGS) - { - long align = cif->arg_types[i]->alignment; - - if (align < 8) - align = 8; - - bytes = ALIGN (bytes, align); - bytes += cif->arg_types[i]->size; - } - else - { - gprcount += ngpr; - ssecount += nsse; - } - } - if (ssecount) - flags |= UNIX64_FLAG_XMM_ARGS; - - cif->flags = flags; - cif->bytes = ALIGN (bytes, 8); - - return FFI_OK; -} - -static void -ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - enum x86_64_reg_class classes[MAX_CLASSES]; - char *stack, *argp; - ffi_type **arg_types; - int gprcount, ssecount, ngpr, nsse, i, avn, flags; - struct register_args *reg_args; - - /* Can't call 32-bit mode from 64-bit mode. */ - FFI_ASSERT (cif->abi == FFI_UNIX64); - - /* If the return value is a struct and we don't have a return value - address then we need to make one. Otherwise we can ignore it. */ - flags = cif->flags; - if (rvalue == NULL) - { - if (flags & UNIX64_FLAG_RET_IN_MEM) - rvalue = alloca (cif->rtype->size); - else - flags = UNIX64_RET_VOID; - } - - /* Allocate the space for the arguments, plus 4 words of temp space. */ - stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8); - reg_args = (struct register_args *) stack; - argp = stack + sizeof (struct register_args); - - reg_args->r10 = (uintptr_t) closure; - - gprcount = ssecount = 0; - - /* If the return value is passed in memory, add the pointer as the - first integer argument. */ - if (flags & UNIX64_FLAG_RET_IN_MEM) - reg_args->gpr[gprcount++] = (unsigned long) rvalue; - - avn = cif->nargs; - arg_types = cif->arg_types; - - for (i = 0; i < avn; ++i) - { - size_t n, size = arg_types[i]->size; - - n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse); - if (n == 0 - || gprcount + ngpr > MAX_GPR_REGS - || ssecount + nsse > MAX_SSE_REGS) - { - long align = arg_types[i]->alignment; - - /* Stack arguments are *always* at least 8 byte aligned. */ - if (align < 8) - align = 8; - - /* Pass this argument in memory. */ - argp = (void *) ALIGN (argp, align); - memcpy (argp, avalue[i], size); - argp += size; - } - else - { - /* The argument is passed entirely in registers. */ - char *a = (char *) avalue[i]; - int j; - - for (j = 0; j < n; j++, a += 8, size -= 8) - { - switch (classes[j]) - { - case X86_64_NO_CLASS: - case X86_64_SSEUP_CLASS: - break; - case X86_64_INTEGER_CLASS: - case X86_64_INTEGERSI_CLASS: - /* Sign-extend integer arguments passed in general - purpose registers, to cope with the fact that - LLVM incorrectly assumes that this will be done - (the x86-64 PS ABI does not specify this). */ - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - reg_args->gpr[gprcount] = (SINT64) *((SINT8 *) a); - break; - case FFI_TYPE_SINT16: - reg_args->gpr[gprcount] = (SINT64) *((SINT16 *) a); - break; - case FFI_TYPE_SINT32: - reg_args->gpr[gprcount] = (SINT64) *((SINT32 *) a); - break; - default: - reg_args->gpr[gprcount] = 0; - memcpy (®_args->gpr[gprcount], a, size); - } - gprcount++; - break; - case X86_64_SSE_CLASS: - case X86_64_SSEDF_CLASS: - reg_args->sse[ssecount++].i64 = *(UINT64 *) a; - break; - case X86_64_SSESF_CLASS: - reg_args->sse[ssecount++].i32 = *(UINT32 *) a; - break; - default: - abort(); - } - } - } - } - reg_args->rax = ssecount; - - ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args), - flags, rvalue, fn); -} - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} - -extern void ffi_closure_unix64(void) FFI_HIDDEN; -extern void ffi_closure_unix64_sse(void) FFI_HIDDEN; - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - static const unsigned char trampoline[16] = { - /* leaq -0x7(%rip),%r10 # 0x0 */ - 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff, - /* jmpq *0x3(%rip) # 0x10 */ - 0xff, 0x25, 0x03, 0x00, 0x00, 0x00, - /* nopl (%rax) */ - 0x0f, 0x1f, 0x00 - }; - void (*dest)(void); - char *tramp = closure->tramp; - - if (cif->abi != FFI_UNIX64) - return FFI_BAD_ABI; - - if (cif->flags & UNIX64_FLAG_XMM_ARGS) - dest = ffi_closure_unix64_sse; - else - dest = ffi_closure_unix64; - - memcpy (tramp, trampoline, sizeof(trampoline)); - *(UINT64 *)(tramp + 16) = (uintptr_t)dest; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -int FFI_HIDDEN -ffi_closure_unix64_inner(ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *rvalue, - struct register_args *reg_args, - char *argp) -{ - void **avalue; - ffi_type **arg_types; - long i, avn; - int gprcount, ssecount, ngpr, nsse; - int flags; - - avn = cif->nargs; - flags = cif->flags; - avalue = alloca(avn * sizeof(void *)); - gprcount = ssecount = 0; - - if (flags & UNIX64_FLAG_RET_IN_MEM) - { - /* On return, %rax will contain the address that was passed - by the caller in %rdi. */ - void *r = (void *)(uintptr_t)reg_args->gpr[gprcount++]; - *(void **)rvalue = r; - rvalue = r; - flags = (sizeof(void *) == 4 ? UNIX64_RET_UINT32 : UNIX64_RET_INT64); - } - - arg_types = cif->arg_types; - for (i = 0; i < avn; ++i) - { - enum x86_64_reg_class classes[MAX_CLASSES]; - size_t n; - - n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse); - if (n == 0 - || gprcount + ngpr > MAX_GPR_REGS - || ssecount + nsse > MAX_SSE_REGS) - { - long align = arg_types[i]->alignment; - - /* Stack arguments are *always* at least 8 byte aligned. */ - if (align < 8) - align = 8; - - /* Pass this argument in memory. */ - argp = (void *) ALIGN (argp, align); - avalue[i] = argp; - argp += arg_types[i]->size; - } - /* If the argument is in a single register, or two consecutive - integer registers, then we can use that address directly. */ - else if (n == 1 - || (n == 2 && !(SSE_CLASS_P (classes[0]) - || SSE_CLASS_P (classes[1])))) - { - /* The argument is in a single register. */ - if (SSE_CLASS_P (classes[0])) - { - avalue[i] = ®_args->sse[ssecount]; - ssecount += n; - } - else - { - avalue[i] = ®_args->gpr[gprcount]; - gprcount += n; - } - } - /* Otherwise, allocate space to make them consecutive. */ - else - { - char *a = alloca (16); - int j; - - avalue[i] = a; - for (j = 0; j < n; j++, a += 8) - { - if (SSE_CLASS_P (classes[j])) - memcpy (a, ®_args->sse[ssecount++], 8); - else - memcpy (a, ®_args->gpr[gprcount++], 8); - } - } - } - - /* Invoke the closure. */ - fun (cif, rvalue, avalue, user_data); - - /* Tell assembly how to perform return type promotions. */ - return flags; -} - -extern void ffi_go_closure_unix64(void) FFI_HIDDEN; -extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN; - -ffi_status -ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*)) -{ - if (cif->abi != FFI_UNIX64) - return FFI_BAD_ABI; - - closure->tramp = (cif->flags & UNIX64_FLAG_XMM_ARGS - ? ffi_go_closure_unix64_sse - : ffi_go_closure_unix64); - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -#endif /* __x86_64__ */ diff --git a/user/mpy/lib/libffi/src/x86/ffitarget.h b/user/mpy/lib/libffi/src/x86/ffitarget.h deleted file mode 100644 index 8c1dcac..0000000 --- a/user/mpy/lib/libffi/src/x86/ffitarget.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012, 2014 Anthony Green - Copyright (c) 1996-2003, 2010 Red Hat, Inc. - Copyright (C) 2008 Free Software Foundation, Inc. - - Target configuration macros for x86 and x86-64. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -/* For code common to all platforms on x86 and x86_64. */ -#define X86_ANY - -#if defined (X86_64) && defined (__i386__) -#undef X86_64 -#define X86 -#endif - -#ifdef X86_WIN64 -#define FFI_SIZEOF_ARG 8 -#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ -#endif - -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION -#ifndef _MSC_VER -#define FFI_TARGET_HAS_COMPLEX_TYPE -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -#ifdef X86_WIN64 -#ifdef _MSC_VER -typedef unsigned __int64 ffi_arg; -typedef __int64 ffi_sarg; -#else -typedef unsigned long long ffi_arg; -typedef long long ffi_sarg; -#endif -#else -#if defined __x86_64__ && defined __ILP32__ -#define FFI_SIZEOF_ARG 8 -#define FFI_SIZEOF_JAVA_RAW 4 -typedef unsigned long long ffi_arg; -typedef long long ffi_sarg; -#else -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; -#endif -#endif - -typedef enum ffi_abi { -#if defined(X86_WIN64) - FFI_FIRST_ABI = 0, - FFI_WIN64, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_WIN64 - -#elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) - FFI_FIRST_ABI = 1, - FFI_UNIX64, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_UNIX64 - -#elif defined(X86_WIN32) - FFI_FIRST_ABI = 0, - FFI_SYSV = 1, - FFI_STDCALL = 2, - FFI_THISCALL = 3, - FFI_FASTCALL = 4, - FFI_MS_CDECL = 5, - FFI_PASCAL = 6, - FFI_REGISTER = 7, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_MS_CDECL -#else - FFI_FIRST_ABI = 0, - FFI_SYSV = 1, - FFI_THISCALL = 3, - FFI_FASTCALL = 4, - FFI_STDCALL = 5, - FFI_PASCAL = 6, - FFI_REGISTER = 7, - FFI_MS_CDECL = 8, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -#endif -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_GO_CLOSURES 1 - -#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) -#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) -#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) -#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) - -#if defined (X86_64) || defined(X86_WIN64) \ - || (defined (__x86_64__) && defined (X86_DARWIN)) -# define FFI_TRAMPOLINE_SIZE 24 -# define FFI_NATIVE_RAW_API 0 -#else -# define FFI_TRAMPOLINE_SIZE 12 -# define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ -#endif - -#endif - diff --git a/user/mpy/lib/libffi/src/x86/ffiw64.c b/user/mpy/lib/libffi/src/x86/ffiw64.c deleted file mode 100644 index 8a33a6c..0000000 --- a/user/mpy/lib/libffi/src/x86/ffiw64.c +++ /dev/null @@ -1,281 +0,0 @@ -/* ----------------------------------------------------------------------- - ffiw64.c - Copyright (c) 2014 Red Hat, Inc. - - x86 win64 Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include - -#ifdef X86_WIN64 - -struct win64_call_frame -{ - UINT64 rbp; /* 0 */ - UINT64 retaddr; /* 8 */ - UINT64 fn; /* 16 */ - UINT64 flags; /* 24 */ - UINT64 rvalue; /* 32 */ -}; - -extern void ffi_call_win64 (void *stack, struct win64_call_frame *, - void *closure) FFI_HIDDEN; - -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - int flags, n; - - if (cif->abi != FFI_WIN64) - return FFI_BAD_ABI; - - flags = cif->rtype->type; - switch (flags) - { - default: - break; - case FFI_TYPE_LONGDOUBLE: - flags = FFI_TYPE_STRUCT; - break; - case FFI_TYPE_COMPLEX: - flags = FFI_TYPE_STRUCT; - /* FALLTHRU */ - case FFI_TYPE_STRUCT: - switch (cif->rtype->size) - { - case 8: - flags = FFI_TYPE_UINT64; - break; - case 4: - flags = FFI_TYPE_SMALL_STRUCT_4B; - break; - case 2: - flags = FFI_TYPE_SMALL_STRUCT_2B; - break; - case 1: - flags = FFI_TYPE_SMALL_STRUCT_1B; - break; - } - break; - } - cif->flags = flags; - - /* Each argument either fits in a register, an 8 byte slot, or is - passed by reference with the pointer in the 8 byte slot. */ - n = cif->nargs; - n += (flags == FFI_TYPE_STRUCT); - if (n < 4) - n = 4; - cif->bytes = n * 8; - - return FFI_OK; -} - -static void -ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - int i, j, n, flags; - UINT64 *stack; - size_t rsize; - struct win64_call_frame *frame; - - FFI_ASSERT(cif->abi == FFI_WIN64); - - flags = cif->flags; - rsize = 0; - - /* If we have no return value for a structure, we need to create one. - Otherwise we can ignore the return type entirely. */ - if (rvalue == NULL) - { - if (flags == FFI_TYPE_STRUCT) - rsize = cif->rtype->size; - else - flags = FFI_TYPE_VOID; - } - - stack = alloca(cif->bytes + sizeof(struct win64_call_frame) + rsize); - frame = (struct win64_call_frame *)((char *)stack + cif->bytes); - if (rsize) - rvalue = frame + 1; - - frame->fn = (uintptr_t)fn; - frame->flags = flags; - frame->rvalue = (uintptr_t)rvalue; - - j = 0; - if (flags == FFI_TYPE_STRUCT) - { - stack[0] = (uintptr_t)rvalue; - j = 1; - } - - for (i = 0, n = cif->nargs; i < n; ++i, ++j) - { - switch (cif->arg_types[i]->size) - { - case 8: - stack[j] = *(UINT64 *)avalue[i]; - break; - case 4: - stack[j] = *(UINT32 *)avalue[i]; - break; - case 2: - stack[j] = *(UINT16 *)avalue[i]; - break; - case 1: - stack[j] = *(UINT8 *)avalue[i]; - break; - default: - stack[j] = (uintptr_t)avalue[i]; - break; - } - } - - ffi_call_win64 (stack, frame, closure); -} - -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_call_int (cif, fn, rvalue, avalue, NULL); -} - -void -ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure) -{ - ffi_call_int (cif, fn, rvalue, avalue, closure); -} - - -extern void ffi_closure_win64(void) FFI_HIDDEN; -extern void ffi_go_closure_win64(void) FFI_HIDDEN; - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - static const unsigned char trampoline[16] = { - /* leaq -0x7(%rip),%r10 # 0x0 */ - 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff, - /* jmpq *0x3(%rip) # 0x10 */ - 0xff, 0x25, 0x03, 0x00, 0x00, 0x00, - /* nopl (%rax) */ - 0x0f, 0x1f, 0x00 - }; - unsigned char *tramp = closure->tramp; - - if (cif->abi != FFI_WIN64) - return FFI_BAD_ABI; - - memcpy (tramp, trampoline, sizeof(trampoline)); - *(UINT64 *)(tramp + 16) = (uintptr_t)ffi_closure_win64; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - return FFI_OK; -} - -ffi_status -ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*)) -{ - if (cif->abi != FFI_WIN64) - return FFI_BAD_ABI; - - closure->tramp = ffi_go_closure_win64; - closure->cif = cif; - closure->fun = fun; - - return FFI_OK; -} - -struct win64_closure_frame -{ - UINT64 rvalue[2]; - UINT64 fargs[4]; - UINT64 retaddr; - UINT64 args[]; -}; - -int FFI_HIDDEN -ffi_closure_win64_inner(ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - struct win64_closure_frame *frame) -{ - void **avalue; - void *rvalue; - int i, n, nreg, flags; - - avalue = alloca(cif->nargs * sizeof(void *)); - rvalue = frame->rvalue; - nreg = 0; - - /* When returning a structure, the address is in the first argument. - We must also be prepared to return the same address in eax, so - install that address in the frame and pretend we return a pointer. */ - flags = cif->flags; - if (flags == FFI_TYPE_STRUCT) - { - rvalue = (void *)(uintptr_t)frame->args[0]; - frame->rvalue[0] = frame->args[0]; - nreg = 1; - } - - for (i = 0, n = cif->nargs; i < n; ++i, ++nreg) - { - size_t size = cif->arg_types[i]->size; - size_t type = cif->arg_types[i]->type; - void *a; - - if (type == FFI_TYPE_DOUBLE || type == FFI_TYPE_FLOAT) - { - if (nreg < 4) - a = &frame->fargs[nreg]; - else - a = &frame->args[nreg]; - } - else if (size == 1 || size == 2 || size == 4 || size == 8) - a = &frame->args[nreg]; - else - a = (void *)(uintptr_t)frame->args[nreg]; - - avalue[i] = a; - } - - /* Invoke the closure. */ - fun (cif, rvalue, avalue, user_data); - return flags; -} - -#endif /* X86_WIN64 */ diff --git a/user/mpy/lib/libffi/src/x86/internal.h b/user/mpy/lib/libffi/src/x86/internal.h deleted file mode 100644 index 09771ba..0000000 --- a/user/mpy/lib/libffi/src/x86/internal.h +++ /dev/null @@ -1,29 +0,0 @@ -#define X86_RET_FLOAT 0 -#define X86_RET_DOUBLE 1 -#define X86_RET_LDOUBLE 2 -#define X86_RET_SINT8 3 -#define X86_RET_SINT16 4 -#define X86_RET_UINT8 5 -#define X86_RET_UINT16 6 -#define X86_RET_INT64 7 -#define X86_RET_INT32 8 -#define X86_RET_VOID 9 -#define X86_RET_STRUCTPOP 10 -#define X86_RET_STRUCTARG 11 -#define X86_RET_STRUCT_1B 12 -#define X86_RET_STRUCT_2B 13 -#define X86_RET_UNUSED14 14 -#define X86_RET_UNUSED15 15 - -#define X86_RET_TYPE_MASK 15 -#define X86_RET_POP_SHIFT 4 - -#define R_EAX 0 -#define R_EDX 1 -#define R_ECX 2 - -#ifdef __PCC__ -# define HAVE_FASTCALL 0 -#else -# define HAVE_FASTCALL 1 -#endif diff --git a/user/mpy/lib/libffi/src/x86/internal64.h b/user/mpy/lib/libffi/src/x86/internal64.h deleted file mode 100644 index 512e955..0000000 --- a/user/mpy/lib/libffi/src/x86/internal64.h +++ /dev/null @@ -1,22 +0,0 @@ -#define UNIX64_RET_VOID 0 -#define UNIX64_RET_UINT8 1 -#define UNIX64_RET_UINT16 2 -#define UNIX64_RET_UINT32 3 -#define UNIX64_RET_SINT8 4 -#define UNIX64_RET_SINT16 5 -#define UNIX64_RET_SINT32 6 -#define UNIX64_RET_INT64 7 -#define UNIX64_RET_XMM32 8 -#define UNIX64_RET_XMM64 9 -#define UNIX64_RET_X87 10 -#define UNIX64_RET_X87_2 11 -#define UNIX64_RET_ST_XMM0_RAX 12 -#define UNIX64_RET_ST_RAX_XMM0 13 -#define UNIX64_RET_ST_XMM0_XMM1 14 -#define UNIX64_RET_ST_RAX_RDX 15 - -#define UNIX64_RET_LAST 15 - -#define UNIX64_FLAG_RET_IN_MEM (1 << 10) -#define UNIX64_FLAG_XMM_ARGS (1 << 11) -#define UNIX64_SIZE_SHIFT 12 diff --git a/user/mpy/lib/libffi/src/x86/sysv.S b/user/mpy/lib/libffi/src/x86/sysv.S deleted file mode 100644 index 78f245b..0000000 --- a/user/mpy/lib/libffi/src/x86/sysv.S +++ /dev/null @@ -1,1040 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2013 The Written Word, Inc. - - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc. - - X86 Foreign Function Interface - - 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 __x86_64__ - -#define LIBFFI_ASM -#include -#include -#include "internal.h" - -#define C2(X, Y) X ## Y -#define C1(X, Y) C2(X, Y) -#ifdef __USER_LABEL_PREFIX__ -# define C(X) C1(__USER_LABEL_PREFIX__, X) -#else -# define C(X) X -#endif - -#ifdef X86_DARWIN -# define L(X) C1(L, X) -#else -# define L(X) C1(.L, X) -#endif - -#ifdef __ELF__ -# define ENDF(X) .type X,@function; .size X, . - X -#else -# define ENDF(X) -#endif - -/* Handle win32 fastcall name mangling. */ -#ifdef X86_WIN32 -# define ffi_call_i386 @ffi_call_i386@8 -# define ffi_closure_inner @ffi_closure_inner@8 -#else -# define ffi_call_i386 C(ffi_call_i386) -# define ffi_closure_inner C(ffi_closure_inner) -#endif - -/* This macro allows the safe creation of jump tables without an - actual table. The entry points into the table are all 8 bytes. - The use of ORG asserts that we're at the correct location. */ -/* ??? The clang assembler doesn't handle .org with symbolic expressions. */ -#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) -# define E(BASE, X) .balign 8 -#else -# define E(BASE, X) .balign 8; .org BASE + X * 8 -#endif - - .text - .balign 16 - .globl ffi_call_i386 - FFI_HIDDEN(ffi_call_i386) - -/* This is declared as - - void ffi_call_i386(struct call_frame *frame, char *argp) - __attribute__((fastcall)); - - Thus the arguments are present in - - ecx: frame - edx: argp -*/ - -ffi_call_i386: -L(UW0): - # cfi_startproc -#if !HAVE_FASTCALL - movl 4(%esp), %ecx - movl 8(%esp), %edx -#endif - movl (%esp), %eax /* move the return address */ - movl %ebp, (%ecx) /* store %ebp into local frame */ - movl %eax, 4(%ecx) /* store retaddr into local frame */ - - /* New stack frame based off ebp. This is a itty bit of unwind - trickery in that the CFA *has* changed. There is no easy way - to describe it correctly on entry to the function. Fortunately, - it doesn't matter too much since at all points we can correctly - unwind back to ffi_call. Note that the location to which we - moved the return address is (the new) CFA-4, so from the - perspective of the unwind info, it hasn't moved. */ - movl %ecx, %ebp -L(UW1): - # cfi_def_cfa(%ebp, 8) - # cfi_rel_offset(%ebp, 0) - - movl %edx, %esp /* set outgoing argument stack */ - movl 20+R_EAX*4(%ebp), %eax /* set register arguments */ - movl 20+R_EDX*4(%ebp), %edx - movl 20+R_ECX*4(%ebp), %ecx - - call *8(%ebp) - - movl 12(%ebp), %ecx /* load return type code */ - movl %ebx, 8(%ebp) /* preserve %ebx */ -L(UW2): - # cfi_rel_offset(%ebx, 8) - - andl $X86_RET_TYPE_MASK, %ecx -#ifdef __PIC__ - call C(__x86.get_pc_thunk.bx) -L(pc1): - leal L(store_table)-L(pc1)(%ebx, %ecx, 8), %ebx -#else - leal L(store_table)(,%ecx, 8), %ebx -#endif - movl 16(%ebp), %ecx /* load result address */ - jmp *%ebx - - .balign 8 -L(store_table): -E(L(store_table), X86_RET_FLOAT) - fstps (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_DOUBLE) - fstpl (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_LDOUBLE) - fstpt (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_SINT8) - movsbl %al, %eax - mov %eax, (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_SINT16) - movswl %ax, %eax - mov %eax, (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_UINT8) - movzbl %al, %eax - mov %eax, (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_UINT16) - movzwl %ax, %eax - mov %eax, (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_INT64) - movl %edx, 4(%ecx) - /* fallthru */ -E(L(store_table), X86_RET_INT32) - movl %eax, (%ecx) - /* fallthru */ -E(L(store_table), X86_RET_VOID) -L(e1): - movl 8(%ebp), %ebx - movl %ebp, %esp - popl %ebp -L(UW3): - # cfi_remember_state - # cfi_def_cfa(%esp, 4) - # cfi_restore(%ebx) - # cfi_restore(%ebp) - ret -L(UW4): - # cfi_restore_state - -E(L(store_table), X86_RET_STRUCTPOP) - jmp L(e1) -E(L(store_table), X86_RET_STRUCTARG) - jmp L(e1) -E(L(store_table), X86_RET_STRUCT_1B) - movb %al, (%ecx) - jmp L(e1) -E(L(store_table), X86_RET_STRUCT_2B) - movw %ax, (%ecx) - jmp L(e1) - - /* Fill out the table so that bad values are predictable. */ -E(L(store_table), X86_RET_UNUSED14) - ud2 -E(L(store_table), X86_RET_UNUSED15) - ud2 - -L(UW5): - # cfi_endproc -ENDF(ffi_call_i386) - -/* The inner helper is declared as - - void ffi_closure_inner(struct closure_frame *frame, char *argp) - __attribute_((fastcall)) - - Thus the arguments are placed in - - ecx: frame - edx: argp -*/ - -/* Macros to help setting up the closure_data structure. */ - -#if HAVE_FASTCALL -# define closure_FS (40 + 4) -# define closure_CF 0 -#else -# define closure_FS (8 + 40 + 12) -# define closure_CF 8 -#endif - -#define FFI_CLOSURE_SAVE_REGS \ - movl %eax, closure_CF+16+R_EAX*4(%esp); \ - movl %edx, closure_CF+16+R_EDX*4(%esp); \ - movl %ecx, closure_CF+16+R_ECX*4(%esp) - -#define FFI_CLOSURE_COPY_TRAMP_DATA \ - movl FFI_TRAMPOLINE_SIZE(%eax), %edx; /* copy cif */ \ - movl FFI_TRAMPOLINE_SIZE+4(%eax), %ecx; /* copy fun */ \ - movl FFI_TRAMPOLINE_SIZE+8(%eax), %eax; /* copy user_data */ \ - movl %edx, closure_CF+28(%esp); \ - movl %ecx, closure_CF+32(%esp); \ - movl %eax, closure_CF+36(%esp) - -#if HAVE_FASTCALL -# define FFI_CLOSURE_PREP_CALL \ - movl %esp, %ecx; /* load closure_data */ \ - leal closure_FS+4(%esp), %edx; /* load incoming stack */ -#else -# define FFI_CLOSURE_PREP_CALL \ - leal closure_CF(%esp), %ecx; /* load closure_data */ \ - leal closure_FS+4(%esp), %edx; /* load incoming stack */ \ - movl %ecx, (%esp); \ - movl %edx, 4(%esp) -#endif - -#define FFI_CLOSURE_CALL_INNER(UWN) \ - call ffi_closure_inner - -#define FFI_CLOSURE_MASK_AND_JUMP(N, UW) \ - andl $X86_RET_TYPE_MASK, %eax; \ - leal L(C1(load_table,N))(, %eax, 8), %edx; \ - movl closure_CF(%esp), %eax; /* optimiztic load */ \ - jmp *%edx - -#ifdef __PIC__ -# if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE -# undef FFI_CLOSURE_MASK_AND_JUMP -# define FFI_CLOSURE_MASK_AND_JUMP(N, UW) \ - andl $X86_RET_TYPE_MASK, %eax; \ - call C(__x86.get_pc_thunk.dx); \ -L(C1(pc,N)): \ - leal L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %edx; \ - movl closure_CF(%esp), %eax; /* optimiztic load */ \ - jmp *%edx -# else -# define FFI_CLOSURE_CALL_INNER_SAVE_EBX -# undef FFI_CLOSURE_CALL_INNER -# define FFI_CLOSURE_CALL_INNER(UWN) \ - movl %ebx, 40(%esp); /* save ebx */ \ -L(C1(UW,UWN)): \ - # cfi_rel_offset(%ebx, 40); \ - call C(__x86.get_pc_thunk.bx); /* load got register */ \ - addl $C(_GLOBAL_OFFSET_TABLE_), %ebx; \ - call ffi_closure_inner@PLT -# undef FFI_CLOSURE_MASK_AND_JUMP -# define FFI_CLOSURE_MASK_AND_JUMP(N, UWN) \ - andl $X86_RET_TYPE_MASK, %eax; \ - leal L(C1(load_table,N))@GOTOFF(%ebx, %eax, 8), %edx; \ - movl 40(%esp), %ebx; /* restore ebx */ \ -L(C1(UW,UWN)): \ - # cfi_restore(%ebx); \ - movl closure_CF(%esp), %eax; /* optimiztic load */ \ - jmp *%edx -# endif /* DARWIN || HIDDEN */ -#endif /* __PIC__ */ - - .balign 16 - .globl C(ffi_go_closure_EAX) - FFI_HIDDEN(C(ffi_go_closure_EAX)) -C(ffi_go_closure_EAX): -L(UW6): - # cfi_startproc - subl $closure_FS, %esp -L(UW7): - # cfi_def_cfa_offset(closure_FS + 4) - FFI_CLOSURE_SAVE_REGS - movl 4(%eax), %edx /* copy cif */ - movl 8(%eax), %ecx /* copy fun */ - movl %edx, closure_CF+28(%esp) - movl %ecx, closure_CF+32(%esp) - movl %eax, closure_CF+36(%esp) /* closure is user_data */ - jmp L(do_closure_i386) -L(UW8): - # cfi_endproc -ENDF(C(ffi_go_closure_EAX)) - - .balign 16 - .globl C(ffi_go_closure_ECX) - FFI_HIDDEN(C(ffi_go_closure_ECX)) -C(ffi_go_closure_ECX): -L(UW9): - # cfi_startproc - subl $closure_FS, %esp -L(UW10): - # cfi_def_cfa_offset(closure_FS + 4) - FFI_CLOSURE_SAVE_REGS - movl 4(%ecx), %edx /* copy cif */ - movl 8(%ecx), %eax /* copy fun */ - movl %edx, closure_CF+28(%esp) - movl %eax, closure_CF+32(%esp) - movl %ecx, closure_CF+36(%esp) /* closure is user_data */ - jmp L(do_closure_i386) -L(UW11): - # cfi_endproc -ENDF(C(ffi_go_closure_ECX)) - -/* The closure entry points are reached from the ffi_closure trampoline. - On entry, %eax contains the address of the ffi_closure. */ - - .balign 16 - .globl C(ffi_closure_i386) - FFI_HIDDEN(C(ffi_closure_i386)) - -C(ffi_closure_i386): -L(UW12): - # cfi_startproc - subl $closure_FS, %esp -L(UW13): - # cfi_def_cfa_offset(closure_FS + 4) - - FFI_CLOSURE_SAVE_REGS - FFI_CLOSURE_COPY_TRAMP_DATA - - /* Entry point from preceeding Go closures. */ -L(do_closure_i386): - - FFI_CLOSURE_PREP_CALL - FFI_CLOSURE_CALL_INNER(14) - FFI_CLOSURE_MASK_AND_JUMP(2, 15) - - .balign 8 -L(load_table2): -E(L(load_table2), X86_RET_FLOAT) - flds closure_CF(%esp) - jmp L(e2) -E(L(load_table2), X86_RET_DOUBLE) - fldl closure_CF(%esp) - jmp L(e2) -E(L(load_table2), X86_RET_LDOUBLE) - fldt closure_CF(%esp) - jmp L(e2) -E(L(load_table2), X86_RET_SINT8) - movsbl %al, %eax - jmp L(e2) -E(L(load_table2), X86_RET_SINT16) - movswl %ax, %eax - jmp L(e2) -E(L(load_table2), X86_RET_UINT8) - movzbl %al, %eax - jmp L(e2) -E(L(load_table2), X86_RET_UINT16) - movzwl %ax, %eax - jmp L(e2) -E(L(load_table2), X86_RET_INT64) - movl closure_CF+4(%esp), %edx - jmp L(e2) -E(L(load_table2), X86_RET_INT32) - nop - /* fallthru */ -E(L(load_table2), X86_RET_VOID) -L(e2): - addl $closure_FS, %esp -L(UW16): - # cfi_adjust_cfa_offset(-closure_FS) - ret -L(UW17): - # cfi_adjust_cfa_offset(closure_FS) -E(L(load_table2), X86_RET_STRUCTPOP) - addl $closure_FS, %esp -L(UW18): - # cfi_adjust_cfa_offset(-closure_FS) - ret $4 -L(UW19): - # cfi_adjust_cfa_offset(closure_FS) -E(L(load_table2), X86_RET_STRUCTARG) - jmp L(e2) -E(L(load_table2), X86_RET_STRUCT_1B) - movzbl %al, %eax - jmp L(e2) -E(L(load_table2), X86_RET_STRUCT_2B) - movzwl %ax, %eax - jmp L(e2) - - /* Fill out the table so that bad values are predictable. */ -E(L(load_table2), X86_RET_UNUSED14) - ud2 -E(L(load_table2), X86_RET_UNUSED15) - ud2 - -L(UW20): - # cfi_endproc -ENDF(C(ffi_closure_i386)) - - .balign 16 - .globl C(ffi_go_closure_STDCALL) - FFI_HIDDEN(C(ffi_go_closure_STDCALL)) -C(ffi_go_closure_STDCALL): -L(UW21): - # cfi_startproc - subl $closure_FS, %esp -L(UW22): - # cfi_def_cfa_offset(closure_FS + 4) - FFI_CLOSURE_SAVE_REGS - movl 4(%ecx), %edx /* copy cif */ - movl 8(%ecx), %eax /* copy fun */ - movl %edx, closure_CF+28(%esp) - movl %eax, closure_CF+32(%esp) - movl %ecx, closure_CF+36(%esp) /* closure is user_data */ - jmp L(do_closure_STDCALL) -L(UW23): - # cfi_endproc -ENDF(C(ffi_go_closure_STDCALL)) - -/* For REGISTER, we have no available parameter registers, and so we - enter here having pushed the closure onto the stack. */ - - .balign 16 - .globl C(ffi_closure_REGISTER) - FFI_HIDDEN(C(ffi_closure_REGISTER)) -C(ffi_closure_REGISTER): -L(UW24): - # cfi_startproc - # cfi_def_cfa(%esp, 8) - # cfi_offset(%eip, -8) - subl $closure_FS-4, %esp -L(UW25): - # cfi_def_cfa_offset(closure_FS + 4) - FFI_CLOSURE_SAVE_REGS - movl closure_FS-4(%esp), %ecx /* load retaddr */ - movl closure_FS(%esp), %eax /* load closure */ - movl %ecx, closure_FS(%esp) /* move retaddr */ - jmp L(do_closure_REGISTER) -L(UW26): - # cfi_endproc -ENDF(C(ffi_closure_REGISTER)) - -/* For STDCALL (and others), we need to pop N bytes of arguments off - the stack following the closure. The amount needing to be popped - is returned to us from ffi_closure_inner. */ - - .balign 16 - .globl C(ffi_closure_STDCALL) - FFI_HIDDEN(C(ffi_closure_STDCALL)) -C(ffi_closure_STDCALL): -L(UW27): - # cfi_startproc - subl $closure_FS, %esp -L(UW28): - # cfi_def_cfa_offset(closure_FS + 4) - - FFI_CLOSURE_SAVE_REGS - - /* Entry point from ffi_closure_REGISTER. */ -L(do_closure_REGISTER): - - FFI_CLOSURE_COPY_TRAMP_DATA - - /* Entry point from preceeding Go closure. */ -L(do_closure_STDCALL): - - FFI_CLOSURE_PREP_CALL - FFI_CLOSURE_CALL_INNER(29) - - movl %eax, %ecx - shrl $X86_RET_POP_SHIFT, %ecx /* isolate pop count */ - leal closure_FS(%esp, %ecx), %ecx /* compute popped esp */ - movl closure_FS(%esp), %edx /* move return address */ - movl %edx, (%ecx) - - /* From this point on, the value of %esp upon return is %ecx+4, - and we've copied the return address to %ecx to make return easy. - There's no point in representing this in the unwind info, as - there is always a window between the mov and the ret which - will be wrong from one point of view or another. */ - - FFI_CLOSURE_MASK_AND_JUMP(3, 30) - - .balign 8 -L(load_table3): -E(L(load_table3), X86_RET_FLOAT) - flds closure_CF(%esp) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_DOUBLE) - fldl closure_CF(%esp) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_LDOUBLE) - fldt closure_CF(%esp) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_SINT8) - movsbl %al, %eax - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_SINT16) - movswl %ax, %eax - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_UINT8) - movzbl %al, %eax - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_UINT16) - movzwl %ax, %eax - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_INT64) - movl closure_CF+4(%esp), %edx - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_INT32) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_VOID) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_STRUCTPOP) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_STRUCTARG) - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_STRUCT_1B) - movzbl %al, %eax - movl %ecx, %esp - ret -E(L(load_table3), X86_RET_STRUCT_2B) - movzwl %ax, %eax - movl %ecx, %esp - ret - - /* Fill out the table so that bad values are predictable. */ -E(L(load_table3), X86_RET_UNUSED14) - ud2 -E(L(load_table3), X86_RET_UNUSED15) - ud2 - -L(UW31): - # cfi_endproc -ENDF(C(ffi_closure_STDCALL)) - -#if !FFI_NO_RAW_API - -#define raw_closure_S_FS (16+16+12) - - .balign 16 - .globl C(ffi_closure_raw_SYSV) - FFI_HIDDEN(C(ffi_closure_raw_SYSV)) -C(ffi_closure_raw_SYSV): -L(UW32): - # cfi_startproc - subl $raw_closure_S_FS, %esp -L(UW33): - # cfi_def_cfa_offset(raw_closure_S_FS + 4) - movl %ebx, raw_closure_S_FS-4(%esp) -L(UW34): - # cfi_rel_offset(%ebx, raw_closure_S_FS-4) - - movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */ - movl %edx, 12(%esp) - leal raw_closure_S_FS+4(%esp), %edx /* load raw_args */ - movl %edx, 8(%esp) - leal 16(%esp), %edx /* load &res */ - movl %edx, 4(%esp) - movl FFI_TRAMPOLINE_SIZE(%eax), %ebx /* load cl->cif */ - movl %ebx, (%esp) - call *FFI_TRAMPOLINE_SIZE+4(%eax) /* call cl->fun */ - - movl 20(%ebx), %eax /* load cif->flags */ - andl $X86_RET_TYPE_MASK, %eax -#ifdef __PIC__ - call C(__x86.get_pc_thunk.bx) -L(pc4): - leal L(load_table4)-L(pc4)(%ebx, %eax, 8), %ecx -#else - leal L(load_table4)(,%eax, 8), %ecx -#endif - movl raw_closure_S_FS-4(%esp), %ebx -L(UW35): - # cfi_restore(%ebx) - movl 16(%esp), %eax /* Optimistic load */ - jmp *%ecx - - .balign 8 -L(load_table4): -E(L(load_table4), X86_RET_FLOAT) - flds 16(%esp) - jmp L(e4) -E(L(load_table4), X86_RET_DOUBLE) - fldl 16(%esp) - jmp L(e4) -E(L(load_table4), X86_RET_LDOUBLE) - fldt 16(%esp) - jmp L(e4) -E(L(load_table4), X86_RET_SINT8) - movsbl %al, %eax - jmp L(e4) -E(L(load_table4), X86_RET_SINT16) - movswl %ax, %eax - jmp L(e4) -E(L(load_table4), X86_RET_UINT8) - movzbl %al, %eax - jmp L(e4) -E(L(load_table4), X86_RET_UINT16) - movzwl %ax, %eax - jmp L(e4) -E(L(load_table4), X86_RET_INT64) - movl 16+4(%esp), %edx - jmp L(e4) -E(L(load_table4), X86_RET_INT32) - nop - /* fallthru */ -E(L(load_table4), X86_RET_VOID) -L(e4): - addl $raw_closure_S_FS, %esp -L(UW36): - # cfi_adjust_cfa_offset(-raw_closure_S_FS) - ret -L(UW37): - # cfi_adjust_cfa_offset(raw_closure_S_FS) -E(L(load_table4), X86_RET_STRUCTPOP) - addl $raw_closure_S_FS, %esp -L(UW38): - # cfi_adjust_cfa_offset(-raw_closure_S_FS) - ret $4 -L(UW39): - # cfi_adjust_cfa_offset(raw_closure_S_FS) -E(L(load_table4), X86_RET_STRUCTARG) - jmp L(e4) -E(L(load_table4), X86_RET_STRUCT_1B) - movzbl %al, %eax - jmp L(e4) -E(L(load_table4), X86_RET_STRUCT_2B) - movzwl %ax, %eax - jmp L(e4) - - /* Fill out the table so that bad values are predictable. */ -E(L(load_table4), X86_RET_UNUSED14) - ud2 -E(L(load_table4), X86_RET_UNUSED15) - ud2 - -L(UW40): - # cfi_endproc -ENDF(C(ffi_closure_raw_SYSV)) - -#define raw_closure_T_FS (16+16+8) - - .balign 16 - .globl C(ffi_closure_raw_THISCALL) - FFI_HIDDEN(C(ffi_closure_raw_THISCALL)) -C(ffi_closure_raw_THISCALL): -L(UW41): - # cfi_startproc - /* Rearrange the stack such that %ecx is the first argument. - This means moving the return address. */ - popl %edx -L(UW42): - # cfi_def_cfa_offset(0) - # cfi_register(%eip, %edx) - pushl %ecx -L(UW43): - # cfi_adjust_cfa_offset(4) - pushl %edx -L(UW44): - # cfi_adjust_cfa_offset(4) - # cfi_rel_offset(%eip, 0) - subl $raw_closure_T_FS, %esp -L(UW45): - # cfi_adjust_cfa_offset(raw_closure_T_FS) - movl %ebx, raw_closure_T_FS-4(%esp) -L(UW46): - # cfi_rel_offset(%ebx, raw_closure_T_FS-4) - - movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */ - movl %edx, 12(%esp) - leal raw_closure_T_FS+4(%esp), %edx /* load raw_args */ - movl %edx, 8(%esp) - leal 16(%esp), %edx /* load &res */ - movl %edx, 4(%esp) - movl FFI_TRAMPOLINE_SIZE(%eax), %ebx /* load cl->cif */ - movl %ebx, (%esp) - call *FFI_TRAMPOLINE_SIZE+4(%eax) /* call cl->fun */ - - movl 20(%ebx), %eax /* load cif->flags */ - andl $X86_RET_TYPE_MASK, %eax -#ifdef __PIC__ - call C(__x86.get_pc_thunk.bx) -L(pc5): - leal L(load_table5)-L(pc5)(%ebx, %eax, 8), %ecx -#else - leal L(load_table5)(,%eax, 8), %ecx -#endif - movl raw_closure_T_FS-4(%esp), %ebx -L(UW47): - # cfi_restore(%ebx) - movl 16(%esp), %eax /* Optimistic load */ - jmp *%ecx - - .balign 8 -L(load_table5): -E(L(load_table5), X86_RET_FLOAT) - flds 16(%esp) - jmp L(e5) -E(L(load_table5), X86_RET_DOUBLE) - fldl 16(%esp) - jmp L(e5) -E(L(load_table5), X86_RET_LDOUBLE) - fldt 16(%esp) - jmp L(e5) -E(L(load_table5), X86_RET_SINT8) - movsbl %al, %eax - jmp L(e5) -E(L(load_table5), X86_RET_SINT16) - movswl %ax, %eax - jmp L(e5) -E(L(load_table5), X86_RET_UINT8) - movzbl %al, %eax - jmp L(e5) -E(L(load_table5), X86_RET_UINT16) - movzwl %ax, %eax - jmp L(e5) -E(L(load_table5), X86_RET_INT64) - movl 16+4(%esp), %edx - jmp L(e5) -E(L(load_table5), X86_RET_INT32) - nop - /* fallthru */ -E(L(load_table5), X86_RET_VOID) -L(e5): - addl $raw_closure_T_FS, %esp -L(UW48): - # cfi_adjust_cfa_offset(-raw_closure_T_FS) - /* Remove the extra %ecx argument we pushed. */ - ret $4 -L(UW49): - # cfi_adjust_cfa_offset(raw_closure_T_FS) -E(L(load_table5), X86_RET_STRUCTPOP) - addl $raw_closure_T_FS, %esp -L(UW50): - # cfi_adjust_cfa_offset(-raw_closure_T_FS) - ret $8 -L(UW51): - # cfi_adjust_cfa_offset(raw_closure_T_FS) -E(L(load_table5), X86_RET_STRUCTARG) - jmp L(e5) -E(L(load_table5), X86_RET_STRUCT_1B) - movzbl %al, %eax - jmp L(e5) -E(L(load_table5), X86_RET_STRUCT_2B) - movzwl %ax, %eax - jmp L(e5) - - /* Fill out the table so that bad values are predictable. */ -E(L(load_table5), X86_RET_UNUSED14) - ud2 -E(L(load_table5), X86_RET_UNUSED15) - ud2 - -L(UW52): - # cfi_endproc -ENDF(C(ffi_closure_raw_THISCALL)) - -#endif /* !FFI_NO_RAW_API */ - -#ifdef X86_DARWIN -# define COMDAT(X) \ - .section __TEXT,__textcoal_nt,coalesced,pure_instructions; \ - .weak_definition X; \ - .private_extern X -#elif defined __ELF__ && !(defined(__sun__) && defined(__svr4__)) -# define COMDAT(X) \ - .section .text.X,"axG",@progbits,X,comdat; \ - .globl X; \ - FFI_HIDDEN(X) -#else -# define COMDAT(X) -#endif - -#if defined(__PIC__) - COMDAT(C(__x86.get_pc_thunk.bx)) -C(__x86.get_pc_thunk.bx): - movl (%esp), %ebx - ret -ENDF(C(__x86.get_pc_thunk.bx)) -# if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE - COMDAT(C(__x86.get_pc_thunk.dx)) -C(__x86.get_pc_thunk.dx): - movl (%esp), %edx - ret -ENDF(C(__x86.get_pc_thunk.dx)) -#endif /* DARWIN || HIDDEN */ -#endif /* __PIC__ */ - -/* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */ - -#ifdef __APPLE__ -.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support -EHFrame0: -#elif defined(X86_WIN32) -.section .eh_frame,"r" -#elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) -.section .eh_frame,EH_FRAME_FLAGS,@unwind -#else -.section .eh_frame,EH_FRAME_FLAGS,@progbits -#endif - -#ifdef HAVE_AS_X86_PCREL -# define PCREL(X) X - . -#else -# define PCREL(X) X@rel -#endif - -/* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */ -#define ADV(N, P) .byte 2, L(N)-L(P) - - .balign 4 -L(CIE): - .set L(set0),L(ECIE)-L(SCIE) - .long L(set0) /* CIE Length */ -L(SCIE): - .long 0 /* CIE Identifier Tag */ - .byte 1 /* CIE Version */ - .ascii "zR\0" /* CIE Augmentation */ - .byte 1 /* CIE Code Alignment Factor */ - .byte 0x7c /* CIE Data Alignment Factor */ - .byte 0x8 /* CIE RA Column */ - .byte 1 /* Augmentation size */ - .byte 0x1b /* FDE Encoding (pcrel sdata4) */ - .byte 0xc, 4, 4 /* DW_CFA_def_cfa, %esp offset 4 */ - .byte 0x80+8, 1 /* DW_CFA_offset, %eip offset 1*-4 */ - .balign 4 -L(ECIE): - - .set L(set1),L(EFDE1)-L(SFDE1) - .long L(set1) /* FDE Length */ -L(SFDE1): - .long L(SFDE1)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW0)) /* Initial location */ - .long L(UW5)-L(UW0) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW1, UW0) - .byte 0xc, 5, 8 /* DW_CFA_def_cfa, %ebp 8 */ - .byte 0x80+5, 2 /* DW_CFA_offset, %ebp 2*-4 */ - ADV(UW2, UW1) - .byte 0x80+3, 0 /* DW_CFA_offset, %ebx 0*-4 */ - ADV(UW3, UW2) - .byte 0xa /* DW_CFA_remember_state */ - .byte 0xc, 4, 4 /* DW_CFA_def_cfa, %esp 4 */ - .byte 0xc0+3 /* DW_CFA_restore, %ebx */ - .byte 0xc0+5 /* DW_CFA_restore, %ebp */ - ADV(UW4, UW3) - .byte 0xb /* DW_CFA_restore_state */ - .balign 4 -L(EFDE1): - - .set L(set2),L(EFDE2)-L(SFDE2) - .long L(set2) /* FDE Length */ -L(SFDE2): - .long L(SFDE2)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW6)) /* Initial location */ - .long L(UW8)-L(UW6) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW7, UW6) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE2): - - .set L(set3),L(EFDE3)-L(SFDE3) - .long L(set3) /* FDE Length */ -L(SFDE3): - .long L(SFDE3)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW9)) /* Initial location */ - .long L(UW11)-L(UW9) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW10, UW9) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE3): - - .set L(set4),L(EFDE4)-L(SFDE4) - .long L(set4) /* FDE Length */ -L(SFDE4): - .long L(SFDE4)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW12)) /* Initial location */ - .long L(UW20)-L(UW12) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW13, UW12) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ -#ifdef FFI_CLOSURE_CALL_INNER_SAVE_EBX - ADV(UW14, UW13) - .byte 0x80+3, (40-(closure_FS+4))/-4 /* DW_CFA_offset %ebx */ - ADV(UW15, UW14) - .byte 0xc0+3 /* DW_CFA_restore %ebx */ - ADV(UW16, UW15) -#else - ADV(UW16, UW13) -#endif - .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ - ADV(UW17, UW16) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ - ADV(UW18, UW17) - .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ - ADV(UW19, UW18) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE4): - - .set L(set5),L(EFDE5)-L(SFDE5) - .long L(set5) /* FDE Length */ -L(SFDE5): - .long L(SFDE5)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW21)) /* Initial location */ - .long L(UW23)-L(UW21) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW22, UW21) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE5): - - .set L(set6),L(EFDE6)-L(SFDE6) - .long L(set6) /* FDE Length */ -L(SFDE6): - .long L(SFDE6)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW24)) /* Initial location */ - .long L(UW26)-L(UW24) /* Address range */ - .byte 0 /* Augmentation size */ - .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ - .byte 0x80+8, 2 /* DW_CFA_offset %eip, 2*-4 */ - ADV(UW25, UW24) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE6): - - .set L(set7),L(EFDE7)-L(SFDE7) - .long L(set7) /* FDE Length */ -L(SFDE7): - .long L(SFDE7)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW27)) /* Initial location */ - .long L(UW31)-L(UW27) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW28, UW27) - .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */ -#ifdef FFI_CLOSURE_CALL_INNER_SAVE_EBX - ADV(UW29, UW28) - .byte 0x80+3, (40-(closure_FS+4))/-4 /* DW_CFA_offset %ebx */ - ADV(UW30, UW29) - .byte 0xc0+3 /* DW_CFA_restore %ebx */ -#endif - .balign 4 -L(EFDE7): - -#if !FFI_NO_RAW_API - .set L(set8),L(EFDE8)-L(SFDE8) - .long L(set8) /* FDE Length */ -L(SFDE8): - .long L(SFDE8)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW32)) /* Initial location */ - .long L(UW40)-L(UW32) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW33, UW32) - .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */ - ADV(UW34, UW33) - .byte 0x80+3, 2 /* DW_CFA_offset %ebx 2*-4 */ - ADV(UW35, UW34) - .byte 0xc0+3 /* DW_CFA_restore %ebx */ - ADV(UW36, UW35) - .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ - ADV(UW37, UW36) - .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */ - ADV(UW38, UW37) - .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ - ADV(UW39, UW38) - .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE8): - - .set L(set9),L(EFDE9)-L(SFDE9) - .long L(set9) /* FDE Length */ -L(SFDE9): - .long L(SFDE9)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW41)) /* Initial location */ - .long L(UW52)-L(UW41) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW42, UW41) - .byte 0xe, 0 /* DW_CFA_def_cfa_offset */ - .byte 0x9, 8, 2 /* DW_CFA_register %eip, %edx */ - ADV(UW43, UW42) - .byte 0xe, 4 /* DW_CFA_def_cfa_offset */ - ADV(UW44, UW43) - .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ - .byte 0x80+8, 2 /* DW_CFA_offset %eip 2*-4 */ - ADV(UW45, UW44) - .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */ - ADV(UW46, UW45) - .byte 0x80+3, 3 /* DW_CFA_offset %ebx 3*-4 */ - ADV(UW47, UW46) - .byte 0xc0+3 /* DW_CFA_restore %ebx */ - ADV(UW48, UW47) - .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ - ADV(UW49, UW48) - .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */ - ADV(UW50, UW49) - .byte 0xe, 8 /* DW_CFA_def_cfa_offset */ - ADV(UW51, UW50) - .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */ - .balign 4 -L(EFDE9): -#endif /* !FFI_NO_RAW_API */ - -#endif /* ifndef __x86_64__ */ - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/x86/unix64.S b/user/mpy/lib/libffi/src/x86/unix64.S deleted file mode 100644 index c83010c..0000000 --- a/user/mpy/lib/libffi/src/x86/unix64.S +++ /dev/null @@ -1,546 +0,0 @@ -/* ----------------------------------------------------------------------- - unix64.S - Copyright (c) 2013 The Written Word, Inc. - - Copyright (c) 2008 Red Hat, Inc - - Copyright (c) 2002 Bo Thorsen - - x86-64 Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#ifdef __x86_64__ -#define LIBFFI_ASM -#include -#include -#include "internal64.h" - - .text - -#define C2(X, Y) X ## Y -#define C1(X, Y) C2(X, Y) -#ifdef __USER_LABEL_PREFIX__ -# define C(X) C1(__USER_LABEL_PREFIX__, X) -#else -# define C(X) X -#endif - -#ifdef __APPLE__ -# define L(X) C1(L, X) -#else -# define L(X) C1(.L, X) -#endif - -#ifdef __ELF__ -# define PLT(X) X@PLT -# define ENDF(X) .type X,@function; .size X, . - X -#else -# define PLT(X) X -# define ENDF(X) -#endif - -/* This macro allows the safe creation of jump tables without an - actual table. The entry points into the table are all 8 bytes. - The use of ORG asserts that we're at the correct location. */ -/* ??? The clang assembler doesn't handle .org with symbolic expressions. */ -#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) -# define E(BASE, X) .balign 8 -#else -# define E(BASE, X) .balign 8; .org BASE + X * 8 -#endif - -/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, - void *raddr, void (*fnaddr)(void)); - - Bit o trickiness here -- ARGS+BYTES is the base of the stack frame - for this function. This has been allocated by ffi_call. We also - deallocate some of the stack that has been alloca'd. */ - - .balign 8 - .globl C(ffi_call_unix64) - FFI_HIDDEN(C(ffi_call_unix64)) - -C(ffi_call_unix64): -L(UW0): - movq (%rsp), %r10 /* Load return address. */ - leaq (%rdi, %rsi), %rax /* Find local stack base. */ - movq %rdx, (%rax) /* Save flags. */ - movq %rcx, 8(%rax) /* Save raddr. */ - movq %rbp, 16(%rax) /* Save old frame pointer. */ - movq %r10, 24(%rax) /* Relocate return address. */ - movq %rax, %rbp /* Finalize local stack frame. */ - - /* New stack frame based off rbp. This is a itty bit of unwind - trickery in that the CFA *has* changed. There is no easy way - to describe it correctly on entry to the function. Fortunately, - it doesn't matter too much since at all points we can correctly - unwind back to ffi_call. Note that the location to which we - moved the return address is (the new) CFA-8, so from the - perspective of the unwind info, it hasn't moved. */ -L(UW1): - /* cfi_def_cfa(%rbp, 32) */ - /* cfi_rel_offset(%rbp, 16) */ - - movq %rdi, %r10 /* Save a copy of the register area. */ - movq %r8, %r11 /* Save a copy of the target fn. */ - movl %r9d, %eax /* Set number of SSE registers. */ - - /* Load up all argument registers. */ - movq (%r10), %rdi - movq 0x08(%r10), %rsi - movq 0x10(%r10), %rdx - movq 0x18(%r10), %rcx - movq 0x20(%r10), %r8 - movq 0x28(%r10), %r9 - movl 0xb0(%r10), %eax - testl %eax, %eax - jnz L(load_sse) -L(ret_from_load_sse): - - /* Deallocate the reg arg area, except for r10, then load via pop. */ - leaq 0xb8(%r10), %rsp - popq %r10 - - /* Call the user function. */ - call *%r11 - - /* Deallocate stack arg area; local stack frame in redzone. */ - leaq 24(%rbp), %rsp - - movq 0(%rbp), %rcx /* Reload flags. */ - movq 8(%rbp), %rdi /* Reload raddr. */ - movq 16(%rbp), %rbp /* Reload old frame pointer. */ -L(UW2): - /* cfi_remember_state */ - /* cfi_def_cfa(%rsp, 8) */ - /* cfi_restore(%rbp) */ - - /* The first byte of the flags contains the FFI_TYPE. */ - cmpb $UNIX64_RET_LAST, %cl - movzbl %cl, %r10d - leaq L(store_table)(%rip), %r11 - ja L(sa) - leaq (%r11, %r10, 8), %r10 - - /* Prep for the structure cases: scratch area in redzone. */ - leaq -20(%rsp), %rsi - jmp *%r10 - - .balign 8 -L(store_table): -E(L(store_table), UNIX64_RET_VOID) - ret -E(L(store_table), UNIX64_RET_UINT8) - movzbl %al, %eax - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_UINT16) - movzwl %ax, %eax - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_UINT32) - movl %eax, %eax - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_SINT8) - movsbq %al, %rax - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_SINT16) - movswq %ax, %rax - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_SINT32) - cltq - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_INT64) - movq %rax, (%rdi) - ret -E(L(store_table), UNIX64_RET_XMM32) - movd %xmm0, (%rdi) - ret -E(L(store_table), UNIX64_RET_XMM64) - movq %xmm0, (%rdi) - ret -E(L(store_table), UNIX64_RET_X87) - fstpt (%rdi) - ret -E(L(store_table), UNIX64_RET_X87_2) - fstpt (%rdi) - fstpt 16(%rdi) - ret -E(L(store_table), UNIX64_RET_ST_XMM0_RAX) - movq %rax, 8(%rsi) - jmp L(s3) -E(L(store_table), UNIX64_RET_ST_RAX_XMM0) - movq %xmm0, 8(%rsi) - jmp L(s2) -E(L(store_table), UNIX64_RET_ST_XMM0_XMM1) - movq %xmm1, 8(%rsi) - jmp L(s3) -E(L(store_table), UNIX64_RET_ST_RAX_RDX) - movq %rdx, 8(%rsi) -L(s2): - movq %rax, (%rsi) - shrl $UNIX64_SIZE_SHIFT, %ecx - rep movsb - ret - .balign 8 -L(s3): - movq %xmm0, (%rsi) - shrl $UNIX64_SIZE_SHIFT, %ecx - rep movsb - ret - -L(sa): call PLT(C(abort)) - - /* Many times we can avoid loading any SSE registers at all. - It's not worth an indirect jump to load the exact set of - SSE registers needed; zero or all is a good compromise. */ - .balign 2 -L(UW3): - /* cfi_restore_state */ -L(load_sse): - movdqa 0x30(%r10), %xmm0 - movdqa 0x40(%r10), %xmm1 - movdqa 0x50(%r10), %xmm2 - movdqa 0x60(%r10), %xmm3 - movdqa 0x70(%r10), %xmm4 - movdqa 0x80(%r10), %xmm5 - movdqa 0x90(%r10), %xmm6 - movdqa 0xa0(%r10), %xmm7 - jmp L(ret_from_load_sse) - -L(UW4): -ENDF(C(ffi_call_unix64)) - -/* 6 general registers, 8 vector registers, - 32 bytes of rvalue, 8 bytes of alignment. */ -#define ffi_closure_OFS_G 0 -#define ffi_closure_OFS_V (6*8) -#define ffi_closure_OFS_RVALUE (ffi_closure_OFS_V + 8*16) -#define ffi_closure_FS (ffi_closure_OFS_RVALUE + 32 + 8) - -/* The location of rvalue within the red zone after deallocating the frame. */ -#define ffi_closure_RED_RVALUE (ffi_closure_OFS_RVALUE - ffi_closure_FS) - - .balign 2 - .globl C(ffi_closure_unix64_sse) - FFI_HIDDEN(C(ffi_closure_unix64_sse)) - -C(ffi_closure_unix64_sse): -L(UW5): - subq $ffi_closure_FS, %rsp -L(UW6): - /* cfi_adjust_cfa_offset(ffi_closure_FS) */ - - movdqa %xmm0, ffi_closure_OFS_V+0x00(%rsp) - movdqa %xmm1, ffi_closure_OFS_V+0x10(%rsp) - movdqa %xmm2, ffi_closure_OFS_V+0x20(%rsp) - movdqa %xmm3, ffi_closure_OFS_V+0x30(%rsp) - movdqa %xmm4, ffi_closure_OFS_V+0x40(%rsp) - movdqa %xmm5, ffi_closure_OFS_V+0x50(%rsp) - movdqa %xmm6, ffi_closure_OFS_V+0x60(%rsp) - movdqa %xmm7, ffi_closure_OFS_V+0x70(%rsp) - jmp L(sse_entry1) - -L(UW7): -ENDF(C(ffi_closure_unix64_sse)) - - .balign 2 - .globl C(ffi_closure_unix64) - FFI_HIDDEN(C(ffi_closure_unix64)) - -C(ffi_closure_unix64): -L(UW8): - subq $ffi_closure_FS, %rsp -L(UW9): - /* cfi_adjust_cfa_offset(ffi_closure_FS) */ -L(sse_entry1): - movq %rdi, ffi_closure_OFS_G+0x00(%rsp) - movq %rsi, ffi_closure_OFS_G+0x08(%rsp) - movq %rdx, ffi_closure_OFS_G+0x10(%rsp) - movq %rcx, ffi_closure_OFS_G+0x18(%rsp) - movq %r8, ffi_closure_OFS_G+0x20(%rsp) - movq %r9, ffi_closure_OFS_G+0x28(%rsp) - -#ifdef __ILP32__ - movl FFI_TRAMPOLINE_SIZE(%r10), %edi /* Load cif */ - movl FFI_TRAMPOLINE_SIZE+4(%r10), %esi /* Load fun */ - movl FFI_TRAMPOLINE_SIZE+8(%r10), %edx /* Load user_data */ -#else - movq FFI_TRAMPOLINE_SIZE(%r10), %rdi /* Load cif */ - movq FFI_TRAMPOLINE_SIZE+8(%r10), %rsi /* Load fun */ - movq FFI_TRAMPOLINE_SIZE+16(%r10), %rdx /* Load user_data */ -#endif -L(do_closure): - leaq ffi_closure_OFS_RVALUE(%rsp), %rcx /* Load rvalue */ - movq %rsp, %r8 /* Load reg_args */ - leaq ffi_closure_FS+8(%rsp), %r9 /* Load argp */ - call C(ffi_closure_unix64_inner) - - /* Deallocate stack frame early; return value is now in redzone. */ - addq $ffi_closure_FS, %rsp -L(UW10): - /* cfi_adjust_cfa_offset(-ffi_closure_FS) */ - - /* The first byte of the return value contains the FFI_TYPE. */ - cmpb $UNIX64_RET_LAST, %al - movzbl %al, %r10d - leaq L(load_table)(%rip), %r11 - ja L(la) - leaq (%r11, %r10, 8), %r10 - leaq ffi_closure_RED_RVALUE(%rsp), %rsi - jmp *%r10 - - .balign 8 -L(load_table): -E(L(load_table), UNIX64_RET_VOID) - ret -E(L(load_table), UNIX64_RET_UINT8) - movzbl (%rsi), %eax - ret -E(L(load_table), UNIX64_RET_UINT16) - movzwl (%rsi), %eax - ret -E(L(load_table), UNIX64_RET_UINT32) - movl (%rsi), %eax - ret -E(L(load_table), UNIX64_RET_SINT8) - movsbl (%rsi), %eax - ret -E(L(load_table), UNIX64_RET_SINT16) - movswl (%rsi), %eax - ret -E(L(load_table), UNIX64_RET_SINT32) - movl (%rsi), %eax - ret -E(L(load_table), UNIX64_RET_INT64) - movq (%rsi), %rax - ret -E(L(load_table), UNIX64_RET_XMM32) - movd (%rsi), %xmm0 - ret -E(L(load_table), UNIX64_RET_XMM64) - movq (%rsi), %xmm0 - ret -E(L(load_table), UNIX64_RET_X87) - fldt (%rsi) - ret -E(L(load_table), UNIX64_RET_X87_2) - fldt 16(%rsi) - fldt (%rsi) - ret -E(L(load_table), UNIX64_RET_ST_XMM0_RAX) - movq 8(%rsi), %rax - jmp L(l3) -E(L(load_table), UNIX64_RET_ST_RAX_XMM0) - movq 8(%rsi), %xmm0 - jmp L(l2) -E(L(load_table), UNIX64_RET_ST_XMM0_XMM1) - movq 8(%rsi), %xmm1 - jmp L(l3) -E(L(load_table), UNIX64_RET_ST_RAX_RDX) - movq 8(%rsi), %rdx -L(l2): - movq (%rsi), %rax - ret - .balign 8 -L(l3): - movq (%rsi), %xmm0 - ret - -L(la): call PLT(C(abort)) - -L(UW11): -ENDF(C(ffi_closure_unix64)) - - .balign 2 - .globl C(ffi_go_closure_unix64_sse) - FFI_HIDDEN(C(ffi_go_closure_unix64_sse)) - -C(ffi_go_closure_unix64_sse): -L(UW12): - subq $ffi_closure_FS, %rsp -L(UW13): - /* cfi_adjust_cfa_offset(ffi_closure_FS) */ - - movdqa %xmm0, ffi_closure_OFS_V+0x00(%rsp) - movdqa %xmm1, ffi_closure_OFS_V+0x10(%rsp) - movdqa %xmm2, ffi_closure_OFS_V+0x20(%rsp) - movdqa %xmm3, ffi_closure_OFS_V+0x30(%rsp) - movdqa %xmm4, ffi_closure_OFS_V+0x40(%rsp) - movdqa %xmm5, ffi_closure_OFS_V+0x50(%rsp) - movdqa %xmm6, ffi_closure_OFS_V+0x60(%rsp) - movdqa %xmm7, ffi_closure_OFS_V+0x70(%rsp) - jmp L(sse_entry2) - -L(UW14): -ENDF(C(ffi_go_closure_unix64_sse)) - - .balign 2 - .globl C(ffi_go_closure_unix64) - FFI_HIDDEN(C(ffi_go_closure_unix64)) - -C(ffi_go_closure_unix64): -L(UW15): - subq $ffi_closure_FS, %rsp -L(UW16): - /* cfi_adjust_cfa_offset(ffi_closure_FS) */ -L(sse_entry2): - movq %rdi, ffi_closure_OFS_G+0x00(%rsp) - movq %rsi, ffi_closure_OFS_G+0x08(%rsp) - movq %rdx, ffi_closure_OFS_G+0x10(%rsp) - movq %rcx, ffi_closure_OFS_G+0x18(%rsp) - movq %r8, ffi_closure_OFS_G+0x20(%rsp) - movq %r9, ffi_closure_OFS_G+0x28(%rsp) - -#ifdef __ILP32__ - movl 4(%r10), %edi /* Load cif */ - movl 8(%r10), %esi /* Load fun */ - movl %r10d, %edx /* Load closure (user_data) */ -#else - movq 8(%r10), %rdi /* Load cif */ - movq 16(%r10), %rsi /* Load fun */ - movq %r10, %rdx /* Load closure (user_data) */ -#endif - jmp L(do_closure) - -L(UW17): -ENDF(C(ffi_go_closure_unix64)) - -/* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */ - -#ifdef __APPLE__ -.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support -EHFrame0: -#elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) -.section .eh_frame,"a",@unwind -#else -.section .eh_frame,"a",@progbits -#endif - -#ifdef HAVE_AS_X86_PCREL -# define PCREL(X) X - . -#else -# define PCREL(X) X@rel -#endif - -/* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */ -#define ADV(N, P) .byte 2, L(N)-L(P) - - .balign 8 -L(CIE): - .set L(set0),L(ECIE)-L(SCIE) - .long L(set0) /* CIE Length */ -L(SCIE): - .long 0 /* CIE Identifier Tag */ - .byte 1 /* CIE Version */ - .ascii "zR\0" /* CIE Augmentation */ - .byte 1 /* CIE Code Alignment Factor */ - .byte 0x78 /* CIE Data Alignment Factor */ - .byte 0x10 /* CIE RA Column */ - .byte 1 /* Augmentation size */ - .byte 0x1b /* FDE Encoding (pcrel sdata4) */ - .byte 0xc, 7, 8 /* DW_CFA_def_cfa, %rsp offset 8 */ - .byte 0x80+16, 1 /* DW_CFA_offset, %rip offset 1*-8 */ - .balign 8 -L(ECIE): - - .set L(set1),L(EFDE1)-L(SFDE1) - .long L(set1) /* FDE Length */ -L(SFDE1): - .long L(SFDE1)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW0)) /* Initial location */ - .long L(UW4)-L(UW0) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW1, UW0) - .byte 0xc, 6, 32 /* DW_CFA_def_cfa, %rbp 32 */ - .byte 0x80+6, 2 /* DW_CFA_offset, %rbp 2*-8 */ - ADV(UW2, UW1) - .byte 0xa /* DW_CFA_remember_state */ - .byte 0xc, 7, 8 /* DW_CFA_def_cfa, %rsp 8 */ - .byte 0xc0+6 /* DW_CFA_restore, %rbp */ - ADV(UW3, UW2) - .byte 0xb /* DW_CFA_restore_state */ - .balign 8 -L(EFDE1): - - .set L(set2),L(EFDE2)-L(SFDE2) - .long L(set2) /* FDE Length */ -L(SFDE2): - .long L(SFDE2)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW5)) /* Initial location */ - .long L(UW7)-L(UW5) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW6, UW5) - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ - .balign 8 -L(EFDE2): - - .set L(set3),L(EFDE3)-L(SFDE3) - .long L(set3) /* FDE Length */ -L(SFDE3): - .long L(SFDE3)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW8)) /* Initial location */ - .long L(UW11)-L(UW8) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW9, UW8) - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ - ADV(UW10, UW9) - .byte 0xe, 8 /* DW_CFA_def_cfa_offset 8 */ -L(EFDE3): - - .set L(set4),L(EFDE4)-L(SFDE4) - .long L(set4) /* FDE Length */ -L(SFDE4): - .long L(SFDE4)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW12)) /* Initial location */ - .long L(UW14)-L(UW12) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW13, UW12) - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ - .balign 8 -L(EFDE4): - - .set L(set5),L(EFDE5)-L(SFDE5) - .long L(set5) /* FDE Length */ -L(SFDE5): - .long L(SFDE5)-L(CIE) /* FDE CIE offset */ - .long PCREL(L(UW15)) /* Initial location */ - .long L(UW17)-L(UW15) /* Address range */ - .byte 0 /* Augmentation size */ - ADV(UW16, UW15) - .byte 0xe /* DW_CFA_def_cfa_offset */ - .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */ - .balign 8 -L(EFDE5): -#ifdef __APPLE__ - .subsections_via_symbols -#endif - -#endif /* __x86_64__ */ -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/user/mpy/lib/libffi/src/x86/win64.S b/user/mpy/lib/libffi/src/x86/win64.S deleted file mode 100644 index a5a20b6..0000000 --- a/user/mpy/lib/libffi/src/x86/win64.S +++ /dev/null @@ -1,219 +0,0 @@ -#define LIBFFI_ASM -#include -#include -#include - -#if defined(HAVE_AS_CFI_PSEUDO_OP) - .cfi_sections .debug_frame -#endif - -#define arg0 %rcx -#define arg1 %rdx -#define arg2 %r8 -#define arg3 %r9 - -#ifdef SYMBOL_UNDERSCORE -#define SYMBOL_NAME(name) _##name -#else -#define SYMBOL_NAME(name) name -#endif - -.macro E which - .align 8 - .org 0b + \which * 8 -.endm - - .text - -/* ffi_call_win64 (void *stack, struct win64_call_frame *frame, void *r10) - - Bit o trickiness here -- FRAME is the base of the stack frame - for this function. This has been allocated by ffi_call. We also - deallocate some of the stack that has been alloca'd. */ - - .align 8 - .globl ffi_call_win64 - - .seh_proc ffi_call_win64 -ffi_call_win64: - cfi_startproc - /* Set up the local stack frame and install it in rbp/rsp. */ - movq (%rsp), %rax - movq %rbp, (arg1) - movq %rax, 8(arg1) - movq arg1, %rbp - cfi_def_cfa(%rbp, 16) - cfi_rel_offset(%rbp, 0) - .seh_pushreg %rbp - .seh_setframe %rbp, 0 - .seh_endprologue - movq arg0, %rsp - - movq arg2, %r10 - - /* Load all slots into both general and xmm registers. */ - movq (%rsp), %rcx - movsd (%rsp), %xmm0 - movq 8(%rsp), %rdx - movsd 8(%rsp), %xmm1 - movq 16(%rsp), %r8 - movsd 16(%rsp), %xmm2 - movq 24(%rsp), %r9 - movsd 24(%rsp), %xmm3 - - call *16(%rbp) - - movl 24(%rbp), %ecx - movq 32(%rbp), %r8 - leaq 0f(%rip), %r10 - cmpl $FFI_TYPE_SMALL_STRUCT_4B, %ecx - leaq (%r10, %rcx, 8), %r10 - ja 99f - jmp *%r10 - -/* Below, we're space constrained most of the time. Thus we eschew the - modern "mov, pop, ret" sequence (5 bytes) for "leave, ret" (2 bytes). */ -.macro epilogue - leaveq - cfi_remember_state - cfi_def_cfa(%rsp, 8) - cfi_restore(%rbp) - ret - cfi_restore_state -.endm - - .align 8 -0: -E FFI_TYPE_VOID - epilogue -E FFI_TYPE_INT - movslq %eax, %rax - movq %rax, (%r8) - epilogue -E FFI_TYPE_FLOAT - movss %xmm0, (%r8) - epilogue -E FFI_TYPE_DOUBLE - movsd %xmm0, (%r8) - epilogue -E FFI_TYPE_LONGDOUBLE - call abort -E FFI_TYPE_UINT8 - movzbl %al, %eax - movq %rax, (%r8) - epilogue -E FFI_TYPE_SINT8 - movsbq %al, %rax - jmp 98f -E FFI_TYPE_UINT16 - movzwl %ax, %eax - movq %rax, (%r8) - epilogue -E FFI_TYPE_SINT16 - movswq %ax, %rax - jmp 98f -E FFI_TYPE_UINT32 - movl %eax, %eax - movq %rax, (%r8) - epilogue -E FFI_TYPE_SINT32 - movslq %eax, %rax - movq %rax, (%r8) - epilogue -E FFI_TYPE_UINT64 -98: movq %rax, (%r8) - epilogue -E FFI_TYPE_SINT64 - movq %rax, (%r8) - epilogue -E FFI_TYPE_STRUCT - epilogue -E FFI_TYPE_POINTER - movq %rax, (%r8) - epilogue -E FFI_TYPE_COMPLEX - call abort -E FFI_TYPE_SMALL_STRUCT_1B - movb %al, (%r8) - epilogue -E FFI_TYPE_SMALL_STRUCT_2B - movw %ax, (%r8) - epilogue -E FFI_TYPE_SMALL_STRUCT_4B - movl %eax, (%r8) - epilogue - - .align 8 -99: call abort - -.purgem epilogue - - cfi_endproc - .seh_endproc - - -/* 32 bytes of outgoing register stack space, 8 bytes of alignment, - 16 bytes of result, 32 bytes of xmm registers. */ -#define ffi_clo_FS (32+8+16+32) -#define ffi_clo_OFF_R (32+8) -#define ffi_clo_OFF_X (32+8+16) - - .align 8 - .globl ffi_go_closure_win64 - - .seh_proc ffi_go_closure_win64 -ffi_go_closure_win64: - cfi_startproc - /* Save all integer arguments into the incoming reg stack space. */ - movq arg0, 8(%rsp) - movq arg1, 16(%rsp) - movq arg2, 24(%rsp) - movq arg3, 32(%rsp) - - movq 8(%r10), arg0 /* load cif */ - movq 16(%r10), arg1 /* load fun */ - movq %r10, arg2 /* closure is user_data */ - jmp 0f - cfi_endproc - .seh_endproc - - .align 8 - .globl ffi_closure_win64 - - .seh_proc ffi_closure_win64 -ffi_closure_win64: - cfi_startproc - /* Save all integer arguments into the incoming reg stack space. */ - movq arg0, 8(%rsp) - movq arg1, 16(%rsp) - movq arg2, 24(%rsp) - movq arg3, 32(%rsp) - - movq FFI_TRAMPOLINE_SIZE(%r10), arg0 /* load cif */ - movq FFI_TRAMPOLINE_SIZE+8(%r10), arg1 /* load fun */ - movq FFI_TRAMPOLINE_SIZE+16(%r10), arg2 /* load user_data */ -0: - subq $ffi_clo_FS, %rsp - cfi_adjust_cfa_offset(ffi_clo_FS) - .seh_stackalloc ffi_clo_FS - .seh_endprologue - - /* Save all sse arguments into the stack frame. */ - movsd %xmm0, ffi_clo_OFF_X(%rsp) - movsd %xmm1, ffi_clo_OFF_X+8(%rsp) - movsd %xmm2, ffi_clo_OFF_X+16(%rsp) - movsd %xmm3, ffi_clo_OFF_X+24(%rsp) - - leaq ffi_clo_OFF_R(%rsp), arg3 - call ffi_closure_win64_inner - - /* Load the result into both possible result registers. */ - movq ffi_clo_OFF_R(%rsp), %rax - movsd ffi_clo_OFF_R(%rsp), %xmm0 - - addq $ffi_clo_FS, %rsp - cfi_adjust_cfa_offset(-ffi_clo_FS) - ret - - cfi_endproc - .seh_endproc diff --git a/user/mpy/lib/libffi/src/xtensa/ffi.c b/user/mpy/lib/libffi/src/xtensa/ffi.c deleted file mode 100644 index fd94daf..0000000 --- a/user/mpy/lib/libffi/src/xtensa/ffi.c +++ /dev/null @@ -1,298 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2013 Tensilica, Inc. - - XTENSA Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#include -#include - -/* - |----------------------------------------| - | | - on entry to ffi_call ----> |----------------------------------------| - | caller stack frame for registers a0-a3 | - |----------------------------------------| - | | - | additional arguments | - entry of the function ---> |----------------------------------------| - | copy of function arguments a2-a7 | - | - - - - - - - - - - - - - | - | | - - The area below the entry line becomes the new stack frame for the function. - -*/ - - -#define FFI_TYPE_STRUCT_REGS FFI_TYPE_LAST - - -extern void ffi_call_SYSV(void *rvalue, unsigned rsize, unsigned flags, - void(*fn)(void), unsigned nbytes, extended_cif*); -extern void ffi_closure_SYSV(void) FFI_HIDDEN; - -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - switch(cif->rtype->type) { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - cif->flags = cif->rtype->type; - break; - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - cif->flags = FFI_TYPE_UINT32; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - cif->flags = FFI_TYPE_UINT64; // cif->rtype->type; - break; - case FFI_TYPE_STRUCT: - cif->flags = FFI_TYPE_STRUCT; //_REGS; - /* Up to 16 bytes are returned in registers */ - if (cif->rtype->size > 4 * 4) { - /* returned structure is referenced by a register; use 8 bytes - (including 4 bytes for potential additional alignment) */ - cif->flags = FFI_TYPE_STRUCT; - cif->bytes += 8; - } - break; - - default: - cif->flags = FFI_TYPE_UINT32; - break; - } - - /* Round the stack up to a full 4 register frame, just in case - (we use this size in movsp). This way, it's also a multiple of - 8 bytes for 64-bit arguments. */ - cif->bytes = ALIGN(cif->bytes, 16); - - return FFI_OK; -} - -void ffi_prep_args(extended_cif *ecif, unsigned char* stack) -{ - unsigned int i; - unsigned long *addr; - ffi_type **ptr; - - union { - void **v; - char **c; - signed char **sc; - unsigned char **uc; - signed short **ss; - unsigned short **us; - unsigned int **i; - long long **ll; - float **f; - double **d; - } p_argv; - - /* Verify that everything is aligned up properly */ - FFI_ASSERT (((unsigned long) stack & 0x7) == 0); - - p_argv.v = ecif->avalue; - addr = (unsigned long*)stack; - - /* structures with a size greater than 16 bytes are passed in memory */ - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 16) - { - *addr++ = (unsigned long)ecif->rvalue; - } - - for (i = ecif->cif->nargs, ptr = ecif->cif->arg_types; - i > 0; - i--, ptr++, p_argv.v++) - { - switch ((*ptr)->type) - { - case FFI_TYPE_SINT8: - *addr++ = **p_argv.sc; - break; - case FFI_TYPE_UINT8: - *addr++ = **p_argv.uc; - break; - case FFI_TYPE_SINT16: - *addr++ = **p_argv.ss; - break; - case FFI_TYPE_UINT16: - *addr++ = **p_argv.us; - break; - case FFI_TYPE_FLOAT: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - *addr++ = **p_argv.i; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - if (((unsigned long)addr & 4) != 0) - addr++; - *(unsigned long long*)addr = **p_argv.ll; - addr += sizeof(unsigned long long) / sizeof (addr); - break; - - case FFI_TYPE_STRUCT: - { - unsigned long offs; - unsigned long size; - - if (((unsigned long)addr & 4) != 0 && (*ptr)->alignment > 4) - addr++; - - offs = (unsigned long) addr - (unsigned long) stack; - size = (*ptr)->size; - - /* Entire structure must fit the argument registers or referenced */ - if (offs < FFI_REGISTER_NARGS * 4 - && offs + size > FFI_REGISTER_NARGS * 4) - addr = (unsigned long*) (stack + FFI_REGISTER_NARGS * 4); - - memcpy((char*) addr, *p_argv.c, size); - addr += (size + 3) / 4; - break; - } - - default: - FFI_ASSERT(0); - } - } -} - - -void ffi_call(ffi_cif* cif, void(*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - unsigned long rsize = cif->rtype->size; - int flags = cif->flags; - void *alloc = NULL; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* Note that for structures that are returned in registers (size <= 16 bytes) - we allocate a temporary buffer and use memcpy to copy it to the final - destination. The reason is that the target address might be misaligned or - the length not a multiple of 4 bytes. Handling all those cases would be - very complex. */ - - if (flags == FFI_TYPE_STRUCT && (rsize <= 16 || rvalue == NULL)) - { - alloc = alloca(ALIGN(rsize, 4)); - ecif.rvalue = alloc; - } - else - { - ecif.rvalue = rvalue; - } - - if (cif->abi != FFI_SYSV) - FFI_ASSERT(0); - - ffi_call_SYSV (ecif.rvalue, rsize, cif->flags, fn, cif->bytes, &ecif); - - if (alloc != NULL && rvalue != NULL) - memcpy(rvalue, alloc, rsize); -} - -extern void ffi_trampoline(); -extern void ffi_cacheflush(void* start, void* end); - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - /* copye trampoline to stack and patch 'ffi_closure_SYSV' pointer */ - memcpy(closure->tramp, ffi_trampoline, FFI_TRAMPOLINE_SIZE); - *(unsigned int*)(&closure->tramp[8]) = (unsigned int)ffi_closure_SYSV; - - // Do we have this function? - // __builtin___clear_cache(closer->tramp, closer->tramp + FFI_TRAMPOLINE_SIZE) - ffi_cacheflush(closure->tramp, closure->tramp + FFI_TRAMPOLINE_SIZE); - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - return FFI_OK; -} - - -long FFI_HIDDEN -ffi_closure_SYSV_inner(ffi_closure *closure, void **values, void *rvalue) -{ - ffi_cif *cif; - ffi_type **arg_types; - void **avalue; - int i, areg; - - cif = closure->cif; - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - areg = 0; - - int rtype = cif->rtype->type; - if (rtype == FFI_TYPE_STRUCT && cif->rtype->size > 4 * 4) - { - rvalue = *values; - areg++; - } - - cif = closure->cif; - arg_types = cif->arg_types; - avalue = alloca(cif->nargs * sizeof(void *)); - - for (i = 0; i < cif->nargs; i++) - { - if (arg_types[i]->alignment == 8 && (areg & 1) != 0) - areg++; - - // skip the entry 16,a1 framework, add 16 bytes (4 registers) - if (areg == FFI_REGISTER_NARGS) - areg += 4; - - if (arg_types[i]->type == FFI_TYPE_STRUCT) - { - int numregs = ((arg_types[i]->size + 3) & ~3) / 4; - if (areg < FFI_REGISTER_NARGS && areg + numregs > FFI_REGISTER_NARGS) - areg = FFI_REGISTER_NARGS + 4; - } - - avalue[i] = &values[areg]; - areg += (arg_types[i]->size + 3) / 4; - } - - (closure->fun)(cif, rvalue, avalue, closure->user_data); - - return rtype; -} diff --git a/user/mpy/lib/libffi/src/xtensa/ffitarget.h b/user/mpy/lib/libffi/src/xtensa/ffitarget.h deleted file mode 100644 index 0ba728b..0000000 --- a/user/mpy/lib/libffi/src/xtensa/ffitarget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2013 Tensilica, Inc. - Target configuration macros for XTENSA. - - 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 LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#define FFI_REGISTER_NARGS 6 - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 -#define FFI_TRAMPOLINE_SIZE 24 - -#endif diff --git a/user/mpy/lib/libffi/src/xtensa/sysv.S b/user/mpy/lib/libffi/src/xtensa/sysv.S deleted file mode 100644 index 64e6a09..0000000 --- a/user/mpy/lib/libffi/src/xtensa/sysv.S +++ /dev/null @@ -1,253 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2013 Tensilica, Inc. - - XTENSA Foreign Function Interface - - 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. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -#define ENTRY(name) .text; .globl name; .type name,@function; .align 4; name: -#define END(name) .size name , . - name - -/* Assert that the table below is in sync with ffi.h. */ - -#if FFI_TYPE_UINT8 != 5 \ - || FFI_TYPE_SINT8 != 6 \ - || FFI_TYPE_UINT16 != 7 \ - || FFI_TYPE_SINT16 != 8 \ - || FFI_TYPE_UINT32 != 9 \ - || FFI_TYPE_SINT32 != 10 \ - || FFI_TYPE_UINT64 != 11 -#error "xtensa/sysv.S out of sync with ffi.h" -#endif - - -/* ffi_call_SYSV (rvalue, rbytes, flags, (*fnaddr)(), bytes, ecif) - void *rvalue; a2 - unsigned long rbytes; a3 - unsigned flags; a4 - void (*fnaddr)(); a5 - unsigned long bytes; a6 - extended_cif* ecif) a7 -*/ - -ENTRY(ffi_call_SYSV) - - entry a1, 32 # 32 byte frame for using call8 below - - mov a10, a7 # a10(->arg0): ecif - sub a11, a1, a6 # a11(->arg1): stack pointer - mov a7, a1 # fp - movsp a1, a11 # set new sp = old_sp - bytes - - movi a8, ffi_prep_args - callx8 a8 # ffi_prep_args(ecif, stack) - - # prepare to move stack pointer back up to 6 arguments - # note that 'bytes' is already aligned - - movi a10, 6*4 - sub a11, a6, a10 - movgez a6, a10, a11 - add a6, a1, a6 - - - # we can pass up to 6 arguments in registers - # for simplicity, just load 6 arguments - # (the stack size is at least 32 bytes, so no risk to cross boundaries) - - l32i a10, a1, 0 - l32i a11, a1, 4 - l32i a12, a1, 8 - l32i a13, a1, 12 - l32i a14, a1, 16 - l32i a15, a1, 20 - - # move stack pointer - - movsp a1, a6 - - callx8 a5 # (*fn)(args...) - - # Handle return value(s) - - beqz a2, .Lexit - - movi a5, FFI_TYPE_STRUCT - bne a4, a5, .Lstore - movi a5, 16 - blt a5, a3, .Lexit - - s32i a10, a2, 0 - blti a3, 5, .Lexit - addi a3, a3, -1 - s32i a11, a2, 4 - blti a3, 8, .Lexit - s32i a12, a2, 8 - blti a3, 12, .Lexit - s32i a13, a2, 12 - -.Lexit: retw - -.Lstore: - addi a4, a4, -FFI_TYPE_UINT8 - bgei a4, 7, .Lexit # should never happen - movi a6, store_calls - add a4, a4, a4 - addx4 a6, a4, a6 # store_table + idx * 8 - jx a6 - - .align 8 -store_calls: - # UINT8 - s8i a10, a2, 0 - retw - - # SINT8 - .align 8 - s8i a10, a2, 0 - retw - - # UINT16 - .align 8 - s16i a10, a2, 0 - retw - - # SINT16 - .align 8 - s16i a10, a2, 0 - retw - - # UINT32 - .align 8 - s32i a10, a2, 0 - retw - - # SINT32 - .align 8 - s32i a10, a2, 0 - retw - - # UINT64 - .align 8 - s32i a10, a2, 0 - s32i a11, a2, 4 - retw - -END(ffi_call_SYSV) - - -/* - * void ffi_cacheflush (unsigned long start, unsigned long end) - */ - -#define EXTRA_ARGS_SIZE 24 - -ENTRY(ffi_cacheflush) - - entry a1, 16 - -1: dhwbi a2, 0 - ihi a2, 0 - addi a2, a2, 4 - blt a2, a3, 1b - - retw - -END(ffi_cacheflush) - -/* ffi_trampoline is copied to the stack */ - -ENTRY(ffi_trampoline) - - entry a1, 16 + (FFI_REGISTER_NARGS * 4) + (4 * 4) # [ 0] - j 2f # [ 3] - .align 4 # [ 6] -1: .long 0 # [ 8] -2: l32r a15, 1b # [12] - _mov a14, a0 # [15] - callx0 a15 # [18] - # [21] -END(ffi_trampoline) - -/* - * ffi_closure() - * - * a0: closure + 21 - * a14: return address (a0) - */ - -ENTRY(ffi_closure_SYSV) - - /* intentionally omitting entry here */ - - # restore return address (a0) and move pointer to closure to a10 - addi a10, a0, -21 - mov a0, a14 - - # allow up to 4 arguments as return values - addi a11, a1, 4 * 4 - - # save up to 6 arguments to stack (allocated by entry below) - s32i a2, a11, 0 - s32i a3, a11, 4 - s32i a4, a11, 8 - s32i a5, a11, 12 - s32i a6, a11, 16 - s32i a7, a11, 20 - - movi a8, ffi_closure_SYSV_inner - mov a12, a1 - callx8 a8 # .._inner(*closure, **avalue, *rvalue) - - # load up to four return arguments - l32i a2, a1, 0 - l32i a3, a1, 4 - l32i a4, a1, 8 - l32i a5, a1, 12 - - # (sign-)extend return value - movi a11, FFI_TYPE_UINT8 - bne a10, a11, 1f - extui a2, a2, 0, 8 - retw - -1: movi a11, FFI_TYPE_SINT8 - bne a10, a11, 1f - sext a2, a2, 7 - retw - -1: movi a11, FFI_TYPE_UINT16 - bne a10, a11, 1f - extui a2, a2, 0, 16 - retw - -1: movi a11, FFI_TYPE_SINT16 - bne a10, a11, 1f - sext a2, a2, 15 - -1: retw - -END(ffi_closure_SYSV) diff --git a/user/mpy/lib/libffi/stamp-h.in b/user/mpy/lib/libffi/stamp-h.in deleted file mode 100644 index 9788f70..0000000 --- a/user/mpy/lib/libffi/stamp-h.in +++ /dev/null @@ -1 +0,0 @@ -timestamp diff --git a/user/mpy/lib/libffi/testsuite/Makefile.am b/user/mpy/lib/libffi/testsuite/Makefile.am deleted file mode 100644 index da10465..0000000 --- a/user/mpy/lib/libffi/testsuite/Makefile.am +++ /dev/null @@ -1,85 +0,0 @@ -## Process this file with automake to produce Makefile.in. - -AUTOMAKE_OPTIONS = foreign dejagnu - -EXTRA_DEJAGNU_SITE_CONFIG=../local.exp - -CLEANFILES = *.exe core* *.log *.sum - -EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \ -libffi.call/cls_align_longdouble_split.c \ -libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \ -libffi.call/closure_fn1.c \ -libffi.call/return_ul.c libffi.call/cls_align_double.c \ -libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \ -libffi.call/cls_64byte.c libffi.call/nested_struct7.c \ -libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \ -libffi.call/ffitest.h libffi.call/nested_struct4.c \ -libffi.call/cls_multi_ushort.c libffi.call/struct3.c \ -libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \ -libffi.call/struct8.c libffi.call/nested_struct8.c \ -libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \ -libffi.call/cls_pointer.c \ -libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ -libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \ -libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \ -libffi.call/call.exp libffi.call/cls_double.c \ -libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \ -libffi.call/return_ll1.c libffi.call/nested_struct3.c \ -libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \ -libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \ -libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \ -libffi.call/return_fl.c libffi.call/struct5.c \ -libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \ -libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \ -libffi.call/return_fl3.c libffi.call/stret_medium.c \ -libffi.call/nested_struct6.c libffi.call/closure_fn3.c \ -libffi.call/float3.c libffi.call/many2.c \ -libffi.call/closure_simple.c libffi.call/cls_align_uint16.c \ -libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \ -libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \ -libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \ -libffi.call/cls_sshort.c \ -libffi.call/nested_struct.c libffi.call/cls_20byte.c \ -libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \ -libffi.call/return_uc.c \ -libffi.call/cls_18byte.c libffi.call/cls_8byte.c \ -libffi.call/promotion.c \ -libffi.call/return_dbl.c libffi.call/cls_24byte.c \ -libffi.call/struct4.c libffi.call/cls_6byte.c \ -libffi.call/cls_align_uint32.c libffi.call/float.c \ -libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \ -libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \ -libffi.call/cls_align_float.c libffi.call/return_fl1.c \ -libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ -libffi.call/cls_align_sint64.c \ -libffi.call/stret_large2.c libffi.call/return_sl.c \ -libffi.call/closure_fn0.c libffi.call/cls_5byte.c \ -libffi.call/cls_2byte.c libffi.call/float2.c \ -libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \ -libffi.call/stret_large.c libffi.call/cls_ulonglong.c \ -libffi.call/cls_ushort.c libffi.call/nested_struct1.c \ -libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \ -libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \ -libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \ -libffi.call/struct1.c libffi.call/nested_struct9.c \ -libffi.call/huge_struct.c libffi.call/problem1.c \ -libffi.call/float4.c \ -libffi.call/return_ldl.c \ -libffi.call/closure_fn5.c \ -libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \ -libffi.call/return_sc.c libffi.call/struct7.c \ -libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ -libffi.call/cls_6_1_byte.c \ -libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \ -libffi.call/unwindtest_ffi_call.cc \ -lib/wrapper.exp lib/target-libpath.exp \ -lib/libffi.exp libffi.call/cls_struct_va1.c \ -libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ -libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ -libffi.call/nested_struct11.c libffi.call/uninitialized.c \ -libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \ -libffi.call/va_struct3.c \ -libffi.call/strlen2.c \ -libffi.call/strlen3.c \ -libffi.call/strlen4.c diff --git a/user/mpy/lib/libffi/testsuite/config/default.exp b/user/mpy/lib/libffi/testsuite/config/default.exp deleted file mode 100644 index 90967cc..0000000 --- a/user/mpy/lib/libffi/testsuite/config/default.exp +++ /dev/null @@ -1 +0,0 @@ -load_lib "standard.exp" diff --git a/user/mpy/lib/libffi/testsuite/lib/libffi.exp b/user/mpy/lib/libffi/testsuite/lib/libffi.exp deleted file mode 100644 index 1b8b008..0000000 --- a/user/mpy/lib/libffi/testsuite/lib/libffi.exp +++ /dev/null @@ -1,431 +0,0 @@ -# Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011, 2014 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING3. If not see -# . - -proc load_gcc_lib { filename } { - global srcdir - load_file $srcdir/lib/$filename -} - -load_lib dg.exp -load_lib libgloss.exp -load_gcc_lib target-libpath.exp -load_gcc_lib wrapper.exp - - -# Define libffi callbacks for dg.exp. - -proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } { - - # To get all \n in dg-output test strings to match printf output - # in a system that outputs it as \015\012 (i.e. not just \012), we - # need to change all \n into \r?\n. As there is no dejagnu flag - # or hook to do that, we simply change the text being tested. - # Unfortunately, we have to know that the variable is called - # dg-output-text and lives in the caller of libffi-dg-test, which - # is two calls up. Overriding proc dg-output would be longer and - # would necessarily have the same assumption. - upvar 2 dg-output-text output_match - - if { [llength $output_match] > 1 } { - regsub -all "\n" [lindex $output_match 1] "\r?\n" x - set output_match [lreplace $output_match 1 1 $x] - } - - # Set up the compiler flags, based on what we're going to do. - - set options [list] - switch $do_what { - "compile" { - set compile_type "assembly" - set output_file "[file rootname [file tail $prog]].s" - } - "link" { - set compile_type "executable" - set output_file "[file rootname [file tail $prog]].exe" - # The following line is needed for targets like the i960 where - # the default output file is b.out. Sigh. - } - "run" { - set compile_type "executable" - # FIXME: "./" is to cope with "." not being in $PATH. - # Should this be handled elsewhere? - # YES. - set output_file "./[file rootname [file tail $prog]].exe" - # This is the only place where we care if an executable was - # created or not. If it was, dg.exp will try to run it. - remote_file build delete $output_file; - } - default { - perror "$do_what: not a valid dg-do keyword" - return "" - } - } - - if { $extra_tool_flags != "" } { - lappend options "additional_flags=$extra_tool_flags" - } - - set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options]; - - - return [list $comp_output $output_file] -} - - -proc libffi-dg-test { prog do_what extra_tool_flags } { - return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags] -} - -proc libffi-init { args } { - global gluefile wrap_flags; - global srcdir - global blddirffi - global objdir - global TOOL_OPTIONS - global tool - global libffi_include - global libffi_link_flags - global tool_root_dir - global ld_library_path - global compiler_vendor - - set blddirffi [pwd]/.. - verbose "libffi $blddirffi" - - # Which compiler are we building with? - set tmp [grep ../config.log "^ax_cv_c_compiler_vendor.*$"] - regexp -- {^[^=]*=(.*)$} $tmp nil compiler_vendor - - if { [string match $compiler_vendor "gnu"] } { - set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] - if {$gccdir != ""} { - set gccdir [file dirname $gccdir] - } - verbose "gccdir $gccdir" - - set ld_library_path "." - append ld_library_path ":${gccdir}" - - set compiler "${gccdir}/xgcc" - if { [is_remote host] == 0 && [which $compiler] != 0 } { - foreach i "[exec $compiler --print-multi-lib]" { - set mldir "" - regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir - set mldir [string trimright $mldir "\;@"] - if { "$mldir" == "." } { - continue - } - if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { - append ld_library_path ":${gccdir}/${mldir}" - } - } - } - } - - # add the library path for libffi. - append ld_library_path ":${blddirffi}/.libs" - - verbose "ld_library_path: $ld_library_path" - - # Point to the Libffi headers in libffi. - set libffi_include "${blddirffi}/include" - verbose "libffi_include $libffi_include" - - set libffi_dir "${blddirffi}/.libs" - verbose "libffi_dir $libffi_dir" - if { $libffi_dir != "" } { - set libffi_dir [file dirname ${libffi_dir}] - set libffi_link_flags "-L${libffi_dir}/.libs" - } - - set_ld_library_path_env_vars - libffi_maybe_build_wrapper "${objdir}/testglue.o" -} - -proc libffi_exit { } { - global gluefile; - - if [info exists gluefile] { - file_on_build delete $gluefile; - unset gluefile; - } -} - -proc libffi_target_compile { source dest type options } { - global gluefile wrap_flags; - global srcdir - global blddirffi - global TOOL_OPTIONS - global libffi_link_flags - global libffi_include - global target_triplet - - - if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { - lappend options "libs=${gluefile}" - lappend options "ldflags=$wrap_flags" - } - - # TOOL_OPTIONS must come first, so that it doesn't override testcase - # specific options. - if [info exists TOOL_OPTIONS] { - lappend options [concat "additional_flags=$TOOL_OPTIONS" $options]; - } - - # search for ffi_mips.h in srcdir, too - lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.." - lappend options "additional_flags=${libffi_link_flags}" - - # Darwin needs a stack execution allowed flag. - - if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"] - || [istarget "*-*-darwin2*"] } { - lappend options "additional_flags=-Wl,-allow_stack_execute" - } - - # If you're building the compiler with --prefix set to a place - # where it's not yet installed, then the linker won't be able to - # find the libgcc used by libffi.dylib. We could pass the - # -dylib_file option, but that's complicated, and it's much easier - # to just make the linker find libgcc using -L options. - if { [string match "*-*-darwin*" $target_triplet] } { - lappend options "libs= -shared-libgcc" - } - - if { [string match "*-*-openbsd*" $target_triplet] } { - lappend options "libs= -lpthread" - } - - lappend options "libs= -lffi" - - if { [string match "aarch64*-*-linux*" $target_triplet] } { - lappend options "libs= -lpthread" - } - - if { [string match "*.cc" $source] } { - lappend options "c++" - } - - verbose "options: $options" - return [target_compile $source $dest $type $options] -} - -# TEST should be a preprocessor condition. Returns true if it holds. -proc libffi_feature_test { test } { - set src "ffitest.c" - - set f [open $src "w"] - puts $f "#include " - puts $f $test - puts $f "xyzzy" - puts $f "#endif" - close $f - - set lines [libffi_target_compile $src "" "preprocess" ""] - file delete $src - - set last [lindex $lines end] - return [regexp -- "xyzzy" $last] -} - -# Utility routines. - -# -# search_for -- looks for a string match in a file -# -proc search_for { file pattern } { - set fd [open $file r] - while { [gets $fd cur_line]>=0 } { - if [string match "*$pattern*" $cur_line] then { - close $fd - return 1 - } - } - close $fd - return 0 -} - -# Modified dg-runtest that can cycle through a list of optimization options -# as c-torture does. -proc libffi-dg-runtest { testcases default-extra-flags } { - global runtests - - foreach test $testcases { - # If we're only testing specific files and this isn't one of - # them, skip it. - if ![runtest_file_p $runtests $test] { - continue - } - - # Look for a loop within the source code - if we don't find one, - # don't pass -funroll[-all]-loops. - global torture_with_loops torture_without_loops - if [expr [search_for $test "for*("]+[search_for $test "while*("]] { - set option_list $torture_with_loops - } else { - set option_list $torture_without_loops - } - - set nshort [file tail [file dirname $test]]/[file tail $test] - - foreach flags $option_list { - verbose "Testing $nshort, $flags" 1 - dg-test $test $flags ${default-extra-flags} - } - } -} - -proc run-many-tests { testcases extra_flags } { - global compiler_vendor - switch $compiler_vendor { - "clang" { - set common "-W -Wall" - set optimizations { "-O0" "-O1" "-O2" "-O3" "-Os" } - } - "gnu" { - set common "-W -Wall -Wno-psabi" - set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" } - } - default { - # Assume we are using the vendor compiler. - set common "" - set optimizations { "" } - } - } - - set targetabis { "" } - if [string match $compiler_vendor "gnu"] { - if [istarget "i?86-*-*"] { - set targetabis { - "" - "-DABI_NUM=FFI_STDCALL -DABI_ATTR=__STDCALL__" - "-DABI_NUM=FFI_THISCALL -DABI_ATTR=__THISCALL__" - "-DABI_NUM=FFI_FASTCALL -DABI_ATTR=__FASTCALL__" - } - } - } - - set common [ concat $common $extra_flags ] - foreach test $testcases { - set testname [file tail $test] - if [search_for $test "ABI_NUM"] { - set abis $targetabis - } else { - set abis { "" } - } - foreach opt $optimizations { - foreach abi $abis { - set options [concat $common $opt $abi] - verbose "Testing $testname, $options" 1 - dg-test $test $options "" - } - } - } -} - -# Like check_conditional_xfail, but callable from a dg test. - -proc dg-xfail-if { args } { - set args [lreplace $args 0 0] - set selector "target [join [lindex $args 1]]" - if { [dg-process-target $selector] == "S" } { - global compiler_conditional_xfail_data - set compiler_conditional_xfail_data $args - } -} - -proc check-flags { args } { - - # The args are within another list; pull them out. - set args [lindex $args 0] - - # The next two arguments are optional. If they were not specified, - # use the defaults. - if { [llength $args] == 2 } { - lappend $args [list "*"] - } - if { [llength $args] == 3 } { - lappend $args [list ""] - } - - # If the option strings are the defaults, or the same as the - # defaults, there is no need to call check_conditional_xfail to - # compare them to the actual options. - if { [string compare [lindex $args 2] "*"] == 0 - && [string compare [lindex $args 3] "" ] == 0 } { - set result 1 - } else { - # The target list might be an effective-target keyword, so replace - # the original list with "*-*-*", since we already know it matches. - set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]] - } - - return $result -} - -proc dg-skip-if { args } { - # Verify the number of arguments. The last two are optional. - set args [lreplace $args 0 0] - if { [llength $args] < 2 || [llength $args] > 4 } { - error "dg-skip-if 2: need 2, 3, or 4 arguments" - } - - # Don't bother if we're already skipping the test. - upvar dg-do-what dg-do-what - if { [lindex ${dg-do-what} 1] == "N" } { - return - } - - set selector [list target [lindex $args 1]] - if { [dg-process-target $selector] == "S" } { - if [check-flags $args] { - upvar dg-do-what dg-do-what - set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] - } - } -} - -# We need to make sure that additional_files and additional_sources -# are both cleared out after every test. It is not enough to clear -# them out *before* the next test run because gcc-target-compile gets -# run directly from some .exp files (outside of any test). (Those -# uses should eventually be eliminated.) - -# Because the DG framework doesn't provide a hook that is run at the -# end of a test, we must replace dg-test with a wrapper. - -if { [info procs saved-dg-test] == [list] } { - rename dg-test saved-dg-test - - proc dg-test { args } { - global additional_files - global additional_sources - global errorInfo - - if { [ catch { eval saved-dg-test $args } errmsg ] } { - set saved_info $errorInfo - set additional_files "" - set additional_sources "" - error $errmsg $saved_info - } - set additional_files "" - set additional_sources "" - } -} - -# Local Variables: -# tcl-indent-level:4 -# End: diff --git a/user/mpy/lib/libffi/testsuite/lib/target-libpath.exp b/user/mpy/lib/libffi/testsuite/lib/target-libpath.exp deleted file mode 100644 index 6b7beba..0000000 --- a/user/mpy/lib/libffi/testsuite/lib/target-libpath.exp +++ /dev/null @@ -1,283 +0,0 @@ -# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca) - -set orig_environment_saved 0 -set orig_ld_library_path_saved 0 -set orig_ld_run_path_saved 0 -set orig_shlib_path_saved 0 -set orig_ld_libraryn32_path_saved 0 -set orig_ld_library64_path_saved 0 -set orig_ld_library_path_32_saved 0 -set orig_ld_library_path_64_saved 0 -set orig_dyld_library_path_saved 0 -set orig_path_saved 0 - -####################################### -# proc set_ld_library_path_env_vars { } -####################################### - -proc set_ld_library_path_env_vars { } { - global ld_library_path - global orig_environment_saved - global orig_ld_library_path_saved - global orig_ld_run_path_saved - global orig_shlib_path_saved - global orig_ld_libraryn32_path_saved - global orig_ld_library64_path_saved - global orig_ld_library_path_32_saved - global orig_ld_library_path_64_saved - global orig_dyld_library_path_saved - global orig_path_saved - global orig_ld_library_path - global orig_ld_run_path - global orig_shlib_path - global orig_ld_libraryn32_path - global orig_ld_library64_path - global orig_ld_library_path_32 - global orig_ld_library_path_64 - global orig_dyld_library_path - global orig_path - global GCC_EXEC_PREFIX - - # Set the relocated compiler prefix, but only if the user hasn't specified one. - if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } { - setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX" - } - - # Setting the ld library path causes trouble when testing cross-compilers. - if { [is_remote target] } { - return - } - - if { $orig_environment_saved == 0 } { - global env - - set orig_environment_saved 1 - - # Save the original environment. - if [info exists env(LD_LIBRARY_PATH)] { - set orig_ld_library_path "$env(LD_LIBRARY_PATH)" - set orig_ld_library_path_saved 1 - } - if [info exists env(LD_RUN_PATH)] { - set orig_ld_run_path "$env(LD_RUN_PATH)" - set orig_ld_run_path_saved 1 - } - if [info exists env(SHLIB_PATH)] { - set orig_shlib_path "$env(SHLIB_PATH)" - set orig_shlib_path_saved 1 - } - if [info exists env(LD_LIBRARYN32_PATH)] { - set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)" - set orig_ld_libraryn32_path_saved 1 - } - if [info exists env(LD_LIBRARY64_PATH)] { - set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)" - set orig_ld_library64_path_saved 1 - } - if [info exists env(LD_LIBRARY_PATH_32)] { - set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)" - set orig_ld_library_path_32_saved 1 - } - if [info exists env(LD_LIBRARY_PATH_64)] { - set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)" - set orig_ld_library_path_64_saved 1 - } - if [info exists env(DYLD_LIBRARY_PATH)] { - set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)" - set orig_dyld_library_path_saved 1 - } - if [info exists env(PATH)] { - set orig_path "$env(PATH)" - set orig_path_saved 1 - } - } - - # We need to set ld library path in the environment. Currently, - # unix.exp doesn't set the environment correctly for all systems. - # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a - # program. We also need the environment set for compilations, etc. - # - # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but - # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH - # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH), - # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64), - # and HP-UX (SHLIB_PATH). In some cases, the variables are independent - # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the - # variable is not defined. - # - # Doing this is somewhat of a hack as ld_library_path gets repeated in - # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables. - if { $orig_ld_library_path_saved } { - setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path" - } else { - setenv LD_LIBRARY_PATH "$ld_library_path" - } - if { $orig_ld_run_path_saved } { - setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path" - } else { - setenv LD_RUN_PATH "$ld_library_path" - } - # The default shared library dynamic path search for 64-bit - # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH. - # LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we - # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent. - if { $orig_shlib_path_saved } { - setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path" - } else { - setenv SHLIB_PATH "$ld_library_path" - } - if { $orig_ld_libraryn32_path_saved } { - setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path" - } elseif { $orig_ld_library_path_saved } { - setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path" - } else { - setenv LD_LIBRARYN32_PATH "$ld_library_path" - } - if { $orig_ld_library64_path_saved } { - setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path" - } elseif { $orig_ld_library_path_saved } { - setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path" - } else { - setenv LD_LIBRARY64_PATH "$ld_library_path" - } - if { $orig_ld_library_path_32_saved } { - setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32" - } elseif { $orig_ld_library_path_saved } { - setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path" - } else { - setenv LD_LIBRARY_PATH_32 "$ld_library_path" - } - if { $orig_ld_library_path_64_saved } { - setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64" - } elseif { $orig_ld_library_path_saved } { - setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path" - } else { - setenv LD_LIBRARY_PATH_64 "$ld_library_path" - } - if { $orig_dyld_library_path_saved } { - setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path" - } else { - setenv DYLD_LIBRARY_PATH "$ld_library_path" - } - if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } { - if { $orig_path_saved } { - setenv PATH "$ld_library_path:$orig_path" - } else { - setenv PATH "$ld_library_path" - } - } - - verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path" -} - -####################################### -# proc restore_ld_library_path_env_vars { } -####################################### - -proc restore_ld_library_path_env_vars { } { - global orig_environment_saved - global orig_ld_library_path_saved - global orig_ld_run_path_saved - global orig_shlib_path_saved - global orig_ld_libraryn32_path_saved - global orig_ld_library64_path_saved - global orig_ld_library_path_32_saved - global orig_ld_library_path_64_saved - global orig_dyld_library_path_saved - global orig_path_saved - global orig_ld_library_path - global orig_ld_run_path - global orig_shlib_path - global orig_ld_libraryn32_path - global orig_ld_library64_path - global orig_ld_library_path_32 - global orig_ld_library_path_64 - global orig_dyld_library_path - global orig_path - - if { $orig_environment_saved == 0 } { - return - } - - if { $orig_ld_library_path_saved } { - setenv LD_LIBRARY_PATH "$orig_ld_library_path" - } elseif [info exists env(LD_LIBRARY_PATH)] { - unsetenv LD_LIBRARY_PATH - } - if { $orig_ld_run_path_saved } { - setenv LD_RUN_PATH "$orig_ld_run_path" - } elseif [info exists env(LD_RUN_PATH)] { - unsetenv LD_RUN_PATH - } - if { $orig_shlib_path_saved } { - setenv SHLIB_PATH "$orig_shlib_path" - } elseif [info exists env(SHLIB_PATH)] { - unsetenv SHLIB_PATH - } - if { $orig_ld_libraryn32_path_saved } { - setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path" - } elseif [info exists env(LD_LIBRARYN32_PATH)] { - unsetenv LD_LIBRARYN32_PATH - } - if { $orig_ld_library64_path_saved } { - setenv LD_LIBRARY64_PATH "$orig_ld_library64_path" - } elseif [info exists env(LD_LIBRARY64_PATH)] { - unsetenv LD_LIBRARY64_PATH - } - if { $orig_ld_library_path_32_saved } { - setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32" - } elseif [info exists env(LD_LIBRARY_PATH_32)] { - unsetenv LD_LIBRARY_PATH_32 - } - if { $orig_ld_library_path_64_saved } { - setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64" - } elseif [info exists env(LD_LIBRARY_PATH_64)] { - unsetenv LD_LIBRARY_PATH_64 - } - if { $orig_dyld_library_path_saved } { - setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path" - } elseif [info exists env(DYLD_LIBRARY_PATH)] { - unsetenv DYLD_LIBRARY_PATH - } - if { $orig_path_saved } { - setenv PATH "$orig_path" - } elseif [info exists env(PATH)] { - unsetenv PATH - } -} - -####################################### -# proc get_shlib_extension { } -####################################### - -proc get_shlib_extension { } { - global shlib_ext - - if { [ istarget *-*-darwin* ] } { - set shlib_ext "dylib" - } elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } { - set shlib_ext "dll" - } elseif { [ istarget hppa*-*-hpux* ] } { - set shlib_ext "sl" - } else { - set shlib_ext "so" - } - return $shlib_ext -} - diff --git a/user/mpy/lib/libffi/testsuite/lib/wrapper.exp b/user/mpy/lib/libffi/testsuite/lib/wrapper.exp deleted file mode 100644 index 4e5ae43..0000000 --- a/user/mpy/lib/libffi/testsuite/lib/wrapper.exp +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (C) 2004, 2007 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# . - -# This file contains GCC-specifics for status wrappers for test programs. - -# ${tool}_maybe_build_wrapper -- Build wrapper object if the target -# needs it. FILENAME is the path to the wrapper file. If there are -# additional arguments, they are command-line options to provide to -# the compiler when compiling FILENAME. - -proc ${tool}_maybe_build_wrapper { filename args } { - global gluefile wrap_flags - - if { [target_info needs_status_wrapper] != "" \ - && [target_info needs_status_wrapper] != "0" \ - && ![info exists gluefile] } { - set saved_wrap_compile_flags [target_info wrap_compile_flags] - set flags [join $args " "] - # The wrapper code may contain code that gcc objects on. This - # became true for dejagnu-1.4.4. The set of warnings and code - # that gcc objects on may change, so just make sure -w is always - # passed to turn off all warnings. - set_currtarget_info wrap_compile_flags \ - "$saved_wrap_compile_flags -w $flags" - set result [build_wrapper $filename] - set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags" - if { $result != "" } { - set gluefile [lindex $result 0] - set wrap_flags [lindex $result 1] - } - } -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/call.exp b/user/mpy/lib/libffi/testsuite/libffi.call/call.exp deleted file mode 100644 index 46fb1eb..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/call.exp +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING3. If not see -# . - -dg-init -libffi-init - -global srcdir subdir - -set tlist [lsearch -inline -all -not -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*] - -run-many-tests $tlist "" - -dg-finish - -# Local Variables: -# tcl-indent-level:4 -# End: diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c deleted file mode 100644 index a579ff6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn0.c +++ /dev/null @@ -1,89 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple values passing from different type. - Also, exceed the limit of gpr and fpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20030828 */ - - - - -/* { dg-do run } */ -#include "ffitest.h" - -static void -closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) + - (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] + - (int)(*(signed short *)args[4]) + - (int)(*(unsigned long long *)args[5]) + - (int)*(int *)args[6] + (int)(*(int *)args[7]) + - (int)(*(double *)args[8]) + (int)*(int *)args[9] + - (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(int *)args[13]) + - (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]), - (int)(*(unsigned long long *)args[2]), - (int)*(int *)args[3], (int)(*(signed short *)args[4]), - (int)(*(unsigned long long *)args[5]), - (int)*(int *)args[6], (int)(*(int *)args[7]), - (int)(*(double *)args[8]), (int)*(int *)args[9], - (int)(*(int *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(int *)args[13]), - (int)(*(int *)args[14]),*(int *)args[15], - (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - -} - -typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long, - int, signed short, unsigned long long, int, - int, double, int, int, float, int, int, - int, int); - -int main (void) -{ - ffi_cif cif; - void * code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - - cl_arg_types[0] = &ffi_type_uint64; - cl_arg_types[1] = &ffi_type_sint; - cl_arg_types[2] = &ffi_type_uint64; - cl_arg_types[3] = &ffi_type_sint; - cl_arg_types[4] = &ffi_type_sshort; - cl_arg_types[5] = &ffi_type_uint64; - cl_arg_types[6] = &ffi_type_sint; - cl_arg_types[7] = &ffi_type_sint; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_sint; - cl_arg_types[10] = &ffi_type_sint; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_sint; - cl_arg_types[13] = &ffi_type_sint; - cl_arg_types[14] = &ffi_type_sint; - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type0)code)) - (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, - 19, 21, 1); - /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 680" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c deleted file mode 100644 index 9123173..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn1.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Area: closure_call. - Purpose: Check multiple values passing from different type. - Also, exceed the limit of gpr and fpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - - -static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(float *)args[0] +(int)(*(float *)args[1]) + - (int)(*(float *)args[2]) + (int)*(float *)args[3] + - (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) + - (int)*(float *)args[6] + (int)(*(int *)args[7]) + - (int)(*(double*)args[8]) + (int)*(int *)args[9] + - (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(int *)args[13]) + - (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(float *)args[0], (int)(*(float *)args[1]), - (int)(*(float *)args[2]), (int)*(float *)args[3], - (int)(*(signed short *)args[4]), (int)(*(float *)args[5]), - (int)*(float *)args[6], (int)(*(int *)args[7]), - (int)(*(double *)args[8]), (int)*(int *)args[9], - (int)(*(int *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(int *)args[13]), - (int)(*(int *)args[14]), *(int *)args[15], - (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); -} - -typedef int (*closure_test_type1)(float, float, float, float, signed short, - float, float, int, double, int, int, float, - int, int, int, int); -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - - cl_arg_types[0] = &ffi_type_float; - cl_arg_types[1] = &ffi_type_float; - cl_arg_types[2] = &ffi_type_float; - cl_arg_types[3] = &ffi_type_float; - cl_arg_types[4] = &ffi_type_sshort; - cl_arg_types[5] = &ffi_type_float; - cl_arg_types[6] = &ffi_type_float; - cl_arg_types[7] = &ffi_type_sint; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_sint; - cl_arg_types[10] = &ffi_type_sint; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_sint; - cl_arg_types[13] = &ffi_type_sint; - cl_arg_types[14] = &ffi_type_sint; - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type1)code)) - (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13, - 19, 21, 1); - /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 255" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c deleted file mode 100644 index 08ff9d9..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn2.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple values passing from different type. - Also, exceed the limit of gpr and fpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(double *)args[0] +(int)(*(double *)args[1]) + - (int)(*(double *)args[2]) + (int)*(double *)args[3] + - (int)(*(signed short *)args[4]) + (int)(*(double *)args[5]) + - (int)*(double *)args[6] + (int)(*(int *)args[7]) + - (int)(*(double *)args[8]) + (int)*(int *)args[9] + - (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(float *)args[13]) + - (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(double *)args[0], (int)(*(double *)args[1]), - (int)(*(double *)args[2]), (int)*(double *)args[3], - (int)(*(signed short *)args[4]), (int)(*(double *)args[5]), - (int)*(double *)args[6], (int)(*(int *)args[7]), - (int)(*(double*)args[8]), (int)*(int *)args[9], - (int)(*(int *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(float *)args[13]), - (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, - (int)*(ffi_arg *)resp); -} - -typedef int (*closure_test_type2)(double, double, double, double, signed short, - double, double, int, double, int, int, float, - int, float, int, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - - cl_arg_types[0] = &ffi_type_double; - cl_arg_types[1] = &ffi_type_double; - cl_arg_types[2] = &ffi_type_double; - cl_arg_types[3] = &ffi_type_double; - cl_arg_types[4] = &ffi_type_sshort; - cl_arg_types[5] = &ffi_type_double; - cl_arg_types[6] = &ffi_type_double; - cl_arg_types[7] = &ffi_type_sint; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_sint; - cl_arg_types[10] = &ffi_type_sint; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_sint; - cl_arg_types[13] = &ffi_type_float; - cl_arg_types[14] = &ffi_type_sint; - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn2, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type2)code)) - (1, 2, 3, 4, 127, 5, 6, 8, 9, 10, 11, 12.0, 13, - 19.0, 21, 1); - /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 255" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c deleted file mode 100644 index 9b54d80..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn3.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple values passing from different type. - Also, exceed the limit of gpr and fpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) - { - *(ffi_arg*)resp = - (int)*(float *)args[0] +(int)(*(float *)args[1]) + - (int)(*(float *)args[2]) + (int)*(float *)args[3] + - (int)(*(float *)args[4]) + (int)(*(float *)args[5]) + - (int)*(float *)args[6] + (int)(*(float *)args[7]) + - (int)(*(double *)args[8]) + (int)*(int *)args[9] + - (int)(*(float *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(float *)args[13]) + - (int)(*(float *)args[14]) + *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(float *)args[0], (int)(*(float *)args[1]), - (int)(*(float *)args[2]), (int)*(float *)args[3], - (int)(*(float *)args[4]), (int)(*(float *)args[5]), - (int)*(float *)args[6], (int)(*(float *)args[7]), - (int)(*(double *)args[8]), (int)*(int *)args[9], - (int)(*(float *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(float *)args[13]), - (int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, - (int)*(ffi_arg *)resp); - - } - -typedef int (*closure_test_type3)(float, float, float, float, float, float, - float, float, double, int, float, float, int, - float, float, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - - cl_arg_types[0] = &ffi_type_float; - cl_arg_types[1] = &ffi_type_float; - cl_arg_types[2] = &ffi_type_float; - cl_arg_types[3] = &ffi_type_float; - cl_arg_types[4] = &ffi_type_float; - cl_arg_types[5] = &ffi_type_float; - cl_arg_types[6] = &ffi_type_float; - cl_arg_types[7] = &ffi_type_float; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_sint; - cl_arg_types[10] = &ffi_type_float; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_sint; - cl_arg_types[13] = &ffi_type_float; - cl_arg_types[14] = &ffi_type_float; - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn3, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type3)code)) - (1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13, - 19.19, 21.21, 1); - /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 135" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c deleted file mode 100644 index d4a1530..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn4.c +++ /dev/null @@ -1,89 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple long long values passing. - Also, exceed the limit of gpr and fpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20031026 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static void -closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] + - (int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] + - (int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] + - (int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] + - (int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] + - (int)*(unsigned long long *)args[10] + - (int)*(unsigned long long *)args[11] + - (int)*(unsigned long long *)args[12] + - (int)*(unsigned long long *)args[13] + - (int)*(unsigned long long *)args[14] + - *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(unsigned long long *)args[0], - (int)*(unsigned long long *)args[1], - (int)*(unsigned long long *)args[2], - (int)*(unsigned long long *)args[3], - (int)*(unsigned long long *)args[4], - (int)*(unsigned long long *)args[5], - (int)*(unsigned long long *)args[6], - (int)*(unsigned long long *)args[7], - (int)*(unsigned long long *)args[8], - (int)*(unsigned long long *)args[9], - (int)*(unsigned long long *)args[10], - (int)*(unsigned long long *)args[11], - (int)*(unsigned long long *)args[12], - (int)*(unsigned long long *)args[13], - (int)*(unsigned long long *)args[14], - *(int *)args[15], - (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - -} - -typedef int (*closure_test_type0)(unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int i, res; - - for (i = 0; i < 15; i++) { - cl_arg_types[i] = &ffi_type_uint64; - } - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type0)code)) - (1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11LL, 12LL, - 13LL, 19LL, 21LL, 1); - /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 680" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c deleted file mode 100644 index 9907442..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn5.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple long long values passing. - Exceed the limit of gpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20031026 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void -closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] + - (int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] + - (int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] + - (int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] + - (int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] + - (int)*(int *)args[10] + - (int)*(unsigned long long *)args[11] + - (int)*(unsigned long long *)args[12] + - (int)*(unsigned long long *)args[13] + - (int)*(unsigned long long *)args[14] + - *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(unsigned long long *)args[0], - (int)*(unsigned long long *)args[1], - (int)*(unsigned long long *)args[2], - (int)*(unsigned long long *)args[3], - (int)*(unsigned long long *)args[4], - (int)*(unsigned long long *)args[5], - (int)*(unsigned long long *)args[6], - (int)*(unsigned long long *)args[7], - (int)*(unsigned long long *)args[8], - (int)*(unsigned long long *)args[9], - (int)*(int *)args[10], - (int)*(unsigned long long *)args[11], - (int)*(unsigned long long *)args[12], - (int)*(unsigned long long *)args[13], - (int)*(unsigned long long *)args[14], - *(int *)args[15], - (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - -} - -typedef int (*closure_test_type0)(unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, unsigned long long, - int, unsigned long long, - unsigned long long, unsigned long long, - unsigned long long, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int i, res; - - for (i = 0; i < 10; i++) { - cl_arg_types[i] = &ffi_type_uint64; - } - cl_arg_types[10] = &ffi_type_sint; - for (i = 11; i < 15; i++) { - cl_arg_types[i] = &ffi_type_uint64; - } - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn5, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type0)code)) - (1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11, 12LL, - 13LL, 19LL, 21LL, 1); - /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 680" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c deleted file mode 100644 index 73c54fd..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_fn6.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple values passing from different type. - Also, exceed the limit of gpr and fpr registers on PowerPC. - Limitations: none. - PR: PR23404 - Originator: 20050830 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void -closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(unsigned long long *)args[0] + - (int)(*(unsigned long long *)args[1]) + - (int)(*(unsigned long long *)args[2]) + - (int)*(unsigned long long *)args[3] + - (int)(*(int *)args[4]) + (int)(*(double *)args[5]) + - (int)*(double *)args[6] + (int)(*(float *)args[7]) + - (int)(*(double *)args[8]) + (int)*(double *)args[9] + - (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(int *)args[13]) + - (int)(*(double *)args[14]) + (int)*(double *)args[15] + - (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(unsigned long long *)args[0], - (int)(*(unsigned long long *)args[1]), - (int)(*(unsigned long long *)args[2]), - (int)*(unsigned long long *)args[3], - (int)(*(int *)args[4]), (int)(*(double *)args[5]), - (int)*(double *)args[6], (int)(*(float *)args[7]), - (int)(*(double *)args[8]), (int)*(double *)args[9], - (int)(*(int *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(int *)args[13]), - (int)(*(double *)args[14]), (int)(*(double *)args[15]), - (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - -} - -typedef int (*closure_test_type0)(unsigned long long, - unsigned long long, - unsigned long long, - unsigned long long, - int, double, double, float, double, double, - int, float, int, int, double, double); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - - cl_arg_types[0] = &ffi_type_uint64; - cl_arg_types[1] = &ffi_type_uint64; - cl_arg_types[2] = &ffi_type_uint64; - cl_arg_types[3] = &ffi_type_uint64; - cl_arg_types[4] = &ffi_type_sint; - cl_arg_types[5] = &ffi_type_double; - cl_arg_types[6] = &ffi_type_double; - cl_arg_types[7] = &ffi_type_float; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_double; - cl_arg_types[10] = &ffi_type_sint; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_sint; - cl_arg_types[13] = &ffi_type_sint; - cl_arg_types[14] = &ffi_type_double; - cl_arg_types[15] = &ffi_type_double; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*((closure_test_type0)code)) - (1, 2, 3, 4, 127, 429., 7., 8., 9.5, 10., 11, 12., 13, - 19, 21., 1.); - /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 680" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c deleted file mode 100644 index b3afa0b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_loc_fn0.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Area: closure_call - Purpose: Check multiple values passing from different type. - Also, exceed the limit of gpr and fpr registers on PowerPC - Darwin. - Limitations: none. - PR: none. - Originator: 20030828 */ - - - - -/* { dg-do run } */ -#include "ffitest.h" - -static void -closure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) + - (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] + - (int)(*(signed short *)args[4]) + - (int)(*(unsigned long long *)args[5]) + - (int)*(int *)args[6] + (int)(*(int *)args[7]) + - (int)(*(double *)args[8]) + (int)*(int *)args[9] + - (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(int *)args[13]) + - (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]), - (int)(*(unsigned long long *)args[2]), - (int)*(int *)args[3], (int)(*(signed short *)args[4]), - (int)(*(unsigned long long *)args[5]), - (int)*(int *)args[6], (int)(*(int *)args[7]), - (int)(*(double *)args[8]), (int)*(int *)args[9], - (int)(*(int *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(int *)args[13]), - (int)(*(int *)args[14]),*(int *)args[15], - (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - -} - -typedef int (*closure_loc_test_type0)(unsigned long long, int, unsigned long long, - int, signed short, unsigned long long, int, - int, double, int, int, float, int, int, - int, int); - -int main (void) -{ - ffi_cif cif; - ffi_closure *pcl; - ffi_type * cl_arg_types[17]; - int res; - void *codeloc; - - cl_arg_types[0] = &ffi_type_uint64; - cl_arg_types[1] = &ffi_type_sint; - cl_arg_types[2] = &ffi_type_uint64; - cl_arg_types[3] = &ffi_type_sint; - cl_arg_types[4] = &ffi_type_sshort; - cl_arg_types[5] = &ffi_type_uint64; - cl_arg_types[6] = &ffi_type_sint; - cl_arg_types[7] = &ffi_type_sint; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_sint; - cl_arg_types[10] = &ffi_type_sint; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_sint; - cl_arg_types[13] = &ffi_type_sint; - cl_arg_types[14] = &ffi_type_sint; - cl_arg_types[15] = &ffi_type_sint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - pcl = ffi_closure_alloc(sizeof(ffi_closure), &codeloc); - CHECK(pcl != NULL); - CHECK(codeloc != NULL); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0, - (void *) 3 /* userdata */, codeloc) == FFI_OK); - - CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0); - - res = (*((closure_loc_test_type0)codeloc)) - (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, - 19, 21, 1); - /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 680" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c b/user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c deleted file mode 100644 index 5a4e728..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/closure_simple.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Area: closure_call - Purpose: Check simple closure handling with all ABIs - Limitations: none. - PR: none. - Originator: */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void -closure_test(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata) -{ - *(ffi_arg*)resp = - (int)*(int *)args[0] + (int)(*(int *)args[1]) - + (int)(*(int *)args[2]) + (int)(*(int *)args[3]) - + (int)(intptr_t)userdata; - - printf("%d %d %d %d: %d\n", - (int)*(int *)args[0], (int)(*(int *)args[1]), - (int)(*(int *)args[2]), (int)(*(int *)args[3]), - (int)*(ffi_arg *)resp); - -} - -typedef int (ABI_ATTR *closure_test_type0)(int, int, int, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - - cl_arg_types[0] = &ffi_type_uint; - cl_arg_types[1] = &ffi_type_uint; - cl_arg_types[2] = &ffi_type_uint; - cl_arg_types[3] = &ffi_type_uint; - cl_arg_types[4] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 4, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test, - (void *) 3 /* userdata */, code) == FFI_OK); - - res = (*(closure_test_type0)code)(0, 1, 2, 3); - /* { dg-output "0 1 2 3: 9" } */ - - printf("res: %d\n",res); - /* { dg-output "\nres: 9" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c deleted file mode 100644 index ea0825d..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_12byte.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_12byte { - int a; - int b; - int c; -} cls_struct_12byte; - -cls_struct_12byte cls_struct_12byte_fn(struct cls_struct_12byte b1, - struct cls_struct_12byte b2) -{ - struct cls_struct_12byte result; - - result.a = b1.a + b2.a; - result.b = b1.b + b2.b; - result.c = b1.c + b2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, - result.a, result.b, result.c); - - return result; -} - -static void cls_struct_12byte_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args , void* userdata __UNUSED__) -{ - struct cls_struct_12byte b1, b2; - - b1 = *(struct cls_struct_12byte*)(args[0]); - b2 = *(struct cls_struct_12byte*)(args[1]); - - *(cls_struct_12byte*)resp = cls_struct_12byte_fn(b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_12byte h_dbl = { 7, 4, 9 }; - struct cls_struct_12byte j_dbl = { 1, 5, 3 }; - struct cls_struct_12byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_sint; - cls_struct_fields[1] = &ffi_type_sint; - cls_struct_fields[2] = &ffi_type_sint; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &h_dbl; - args_dbl[1] = &j_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_12byte_fn), &res_dbl, args_dbl); - /* { dg-output "7 4 9 1 5 3: 8 9 12" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 8 9 12" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_12byte_gn, NULL, code) == FFI_OK); - - res_dbl.a = 0; - res_dbl.b = 0; - res_dbl.c = 0; - - res_dbl = ((cls_struct_12byte(*)(cls_struct_12byte, cls_struct_12byte))(code))(h_dbl, j_dbl); - /* { dg-output "\n7 4 9 1 5 3: 8 9 12" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 8 9 12" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c deleted file mode 100644 index 89a08a2..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_16byte.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_16byte { - int a; - double b; - int c; -} cls_struct_16byte; - -cls_struct_16byte cls_struct_16byte_fn(struct cls_struct_16byte b1, - struct cls_struct_16byte b2) -{ - struct cls_struct_16byte result; - - result.a = b1.a + b2.a; - result.b = b1.b + b2.b; - result.c = b1.c + b2.c; - - printf("%d %g %d %d %g %d: %d %g %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, - result.a, result.b, result.c); - - return result; -} - -static void cls_struct_16byte_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - struct cls_struct_16byte b1, b2; - - b1 = *(struct cls_struct_16byte*)(args[0]); - b2 = *(struct cls_struct_16byte*)(args[1]); - - *(cls_struct_16byte*)resp = cls_struct_16byte_fn(b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_16byte h_dbl = { 7, 8.0, 9 }; - struct cls_struct_16byte j_dbl = { 1, 9.0, 3 }; - struct cls_struct_16byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_sint; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_sint; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &h_dbl; - args_dbl[1] = &j_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_16byte_fn), &res_dbl, args_dbl); - /* { dg-output "7 8 9 1 9 3: 8 17 12" } */ - printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 8 17 12" } */ - - res_dbl.a = 0; - res_dbl.b = 0.0; - res_dbl.c = 0; - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_16byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_16byte(*)(cls_struct_16byte, cls_struct_16byte))(code))(h_dbl, j_dbl); - /* { dg-output "\n7 8 9 1 9 3: 8 17 12" } */ - printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 8 17 12" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c deleted file mode 100644 index 9f75da8..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_18byte.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Double alignment check on darwin. - Limitations: none. - PR: none. - Originator: 20030915 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_18byte { - double a; - unsigned char b; - unsigned char c; - double d; -} cls_struct_18byte; - -cls_struct_18byte cls_struct_18byte_fn(struct cls_struct_18byte a1, - struct cls_struct_18byte a2) -{ - struct cls_struct_18byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - - - printf("%g %d %d %g %g %d %d %g: %g %d %d %g\n", a1.a, a1.b, a1.c, a1.d, - a2.a, a2.b, a2.c, a2.d, - result.a, result.b, result.c, result.d); - return result; -} - -static void -cls_struct_18byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_18byte a1, a2; - - a1 = *(struct cls_struct_18byte*)(args[0]); - a2 = *(struct cls_struct_18byte*)(args[1]); - - *(cls_struct_18byte*)resp = cls_struct_18byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[5]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 }; - struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 }; - struct cls_struct_18byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_18byte_fn), &res_dbl, args_dbl); - /* { dg-output "1 127 126 3 4 125 124 5: 5 252 250 8" } */ - printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 5 252 250 8" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_18byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_18byte(*)(cls_struct_18byte, cls_struct_18byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 127 126 3 4 125 124 5: 5 252 250 8" } */ - printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 5 252 250 8" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c deleted file mode 100644 index 278794b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_19byte.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Double alignment check on darwin. - Limitations: none. - PR: none. - Originator: 20030915 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_19byte { - double a; - unsigned char b; - unsigned char c; - double d; - unsigned char e; -} cls_struct_19byte; - -cls_struct_19byte cls_struct_19byte_fn(struct cls_struct_19byte a1, - struct cls_struct_19byte a2) -{ - struct cls_struct_19byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - result.e = a1.e + a2.e; - - - printf("%g %d %d %g %d %g %d %d %g %d: %g %d %d %g %d\n", - a1.a, a1.b, a1.c, a1.d, a1.e, - a2.a, a2.b, a2.c, a2.d, a2.e, - result.a, result.b, result.c, result.d, result.e); - return result; -} - -static void -cls_struct_19byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_19byte a1, a2; - - a1 = *(struct cls_struct_19byte*)(args[0]); - a2 = *(struct cls_struct_19byte*)(args[1]); - - *(cls_struct_19byte*)resp = cls_struct_19byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[6]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 }; - struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 }; - struct cls_struct_19byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = &ffi_type_uchar; - cls_struct_fields[5] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_19byte_fn), &res_dbl, args_dbl); - /* { dg-output "1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */ - printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e); - /* { dg-output "\nres: 5 252 250 8 239" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_19byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_19byte(*)(cls_struct_19byte, cls_struct_19byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */ - printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e); - /* { dg-output "\nres: 5 252 250 8 239" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c deleted file mode 100644 index 82492c0..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_1_1byte.c +++ /dev/null @@ -1,89 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Especially with small structures which may fit in one - register. Depending on the ABI. - Limitations: none. - PR: none. - Originator: 20030902 */ - - - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_1_1byte { - unsigned char a; -} cls_struct_1_1byte; - -cls_struct_1_1byte cls_struct_1_1byte_fn(struct cls_struct_1_1byte a1, - struct cls_struct_1_1byte a2) -{ - struct cls_struct_1_1byte result; - - result.a = a1.a + a2.a; - - printf("%d %d: %d\n", a1.a, a2.a, result.a); - - return result; -} - -static void -cls_struct_1_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_1_1byte a1, a2; - - a1 = *(struct cls_struct_1_1byte*)(args[0]); - a2 = *(struct cls_struct_1_1byte*)(args[1]); - - *(cls_struct_1_1byte*)resp = cls_struct_1_1byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[2]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_1_1byte g_dbl = { 12 }; - struct cls_struct_1_1byte f_dbl = { 178 }; - struct cls_struct_1_1byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_1_1byte_fn), &res_dbl, args_dbl); - /* { dg-output "12 178: 190" } */ - printf("res: %d\n", res_dbl.a); - /* { dg-output "\nres: 190" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_1_1byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_1_1byte(*)(cls_struct_1_1byte, cls_struct_1_1byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 178: 190" } */ - printf("res: %d\n", res_dbl.a); - /* { dg-output "\nres: 190" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c deleted file mode 100644 index 3f8bb28..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_20byte { - double a; - double b; - int c; -} cls_struct_20byte; - -cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, - struct cls_struct_20byte a2) -{ - struct cls_struct_20byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%g %g %d %g %g %d: %g %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, - result.a, result.b, result.c); - return result; -} - -static void -cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_20byte a1, a2; - - a1 = *(struct cls_struct_20byte*)(args[0]); - a2 = *(struct cls_struct_20byte*)(args[1]); - - *(cls_struct_20byte*)resp = cls_struct_20byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 }; - struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 }; - struct cls_struct_20byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_sint; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_20byte_fn), &res_dbl, args_dbl); - /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ - printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 5 7 10" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */ - printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 5 7 10" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c deleted file mode 100644 index 6562727..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_20byte1.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - - - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_20byte { - int a; - double b; - double c; -} cls_struct_20byte; - -cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, - struct cls_struct_20byte a2) -{ - struct cls_struct_20byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %g %g %d %g %g: %d %g %g\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, - result.a, result.b, result.c); - return result; -} - -static void -cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_20byte a1, a2; - - a1 = *(struct cls_struct_20byte*)(args[0]); - a2 = *(struct cls_struct_20byte*)(args[1]); - - *(cls_struct_20byte*)resp = cls_struct_20byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 }; - struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 }; - struct cls_struct_20byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_sint; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_double; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_20byte_fn), &res_dbl, args_dbl); - /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ - printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 5 7 10" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */ - printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 5 7 10" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c deleted file mode 100644 index 1d82f6e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_24byte.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_24byte { - double a; - double b; - int c; - float d; -} cls_struct_24byte; - -cls_struct_24byte cls_struct_24byte_fn(struct cls_struct_24byte b0, - struct cls_struct_24byte b1, - struct cls_struct_24byte b2, - struct cls_struct_24byte b3) -{ - struct cls_struct_24byte result; - - result.a = b0.a + b1.a + b2.a + b3.a; - result.b = b0.b + b1.b + b2.b + b3.b; - result.c = b0.c + b1.c + b2.c + b3.c; - result.d = b0.d + b1.d + b2.d + b3.d; - - printf("%g %g %d %g %g %g %d %g %g %g %d %g %g %g %d %g: %g %g %d %g\n", - b0.a, b0.b, b0.c, b0.d, - b1.a, b1.b, b1.c, b1.d, - b2.a, b2.b, b2.c, b2.d, - b3.a, b3.b, b3.c, b2.d, - result.a, result.b, result.c, result.d); - - return result; -} - -static void -cls_struct_24byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_24byte b0, b1, b2, b3; - - b0 = *(struct cls_struct_24byte*)(args[0]); - b1 = *(struct cls_struct_24byte*)(args[1]); - b2 = *(struct cls_struct_24byte*)(args[2]); - b3 = *(struct cls_struct_24byte*)(args[3]); - - *(cls_struct_24byte*)resp = cls_struct_24byte_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[5]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_24byte e_dbl = { 9.0, 2.0, 6, 5.0 }; - struct cls_struct_24byte f_dbl = { 1.0, 2.0, 3, 7.0 }; - struct cls_struct_24byte g_dbl = { 4.0, 5.0, 7, 9.0 }; - struct cls_struct_24byte h_dbl = { 8.0, 6.0, 1, 4.0 }; - struct cls_struct_24byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_sint; - cls_struct_fields[3] = &ffi_type_float; - cls_struct_fields[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = &cls_struct_type; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_24byte_fn), &res_dbl, args_dbl); - /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */ - printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 22 15 17 25" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_24byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_24byte(*)(cls_struct_24byte, - cls_struct_24byte, - cls_struct_24byte, - cls_struct_24byte)) - (code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */ - printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 22 15 17 25" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c deleted file mode 100644 index 81bb0a6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_2byte.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Especially with small structures which may fit in one - register. Depending on the ABI. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_2byte { - unsigned char a; - unsigned char b; -} cls_struct_2byte; - -cls_struct_2byte cls_struct_2byte_fn(struct cls_struct_2byte a1, - struct cls_struct_2byte a2) -{ - struct cls_struct_2byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - - printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); - - return result; -} - -static void -cls_struct_2byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_2byte a1, a2; - - a1 = *(struct cls_struct_2byte*)(args[0]); - a2 = *(struct cls_struct_2byte*)(args[1]); - - *(cls_struct_2byte*)resp = cls_struct_2byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_2byte g_dbl = { 12, 127 }; - struct cls_struct_2byte f_dbl = { 1, 13 }; - struct cls_struct_2byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_2byte_fn), &res_dbl, args_dbl); - /* { dg-output "12 127 1 13: 13 140" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 13 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_2byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_2byte(*)(cls_struct_2byte, cls_struct_2byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 127 1 13: 13 140" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 13 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c deleted file mode 100644 index b782746..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3_1byte.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Especially with small structures which may fit in one - register. Depending on the ABI. - Limitations: none. - PR: none. - Originator: 20030902 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_3_1byte { - unsigned char a; - unsigned char b; - unsigned char c; -} cls_struct_3_1byte; - -cls_struct_3_1byte cls_struct_3_1byte_fn(struct cls_struct_3_1byte a1, - struct cls_struct_3_1byte a2) -{ - struct cls_struct_3_1byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, - a2.a, a2.b, a2.c, - result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_3_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_3_1byte a1, a2; - - a1 = *(struct cls_struct_3_1byte*)(args[0]); - a2 = *(struct cls_struct_3_1byte*)(args[1]); - - *(cls_struct_3_1byte*)resp = cls_struct_3_1byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_3_1byte g_dbl = { 12, 13, 14 }; - struct cls_struct_3_1byte f_dbl = { 178, 179, 180 }; - struct cls_struct_3_1byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_3_1byte_fn), &res_dbl, args_dbl); - /* { dg-output "12 13 14 178 179 180: 190 192 194" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 190 192 194" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3_1byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_3_1byte(*)(cls_struct_3_1byte, cls_struct_3_1byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 13 14 178 179 180: 190 192 194" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 190 192 194" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c deleted file mode 100644 index a02c463..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte1.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Especially with small structures which may fit in one - register. Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_3byte { - unsigned short a; - unsigned char b; -} cls_struct_3byte; - -cls_struct_3byte cls_struct_3byte_fn(struct cls_struct_3byte a1, - struct cls_struct_3byte a2) -{ - struct cls_struct_3byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - - printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); - - return result; -} - -static void -cls_struct_3byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_3byte a1, a2; - - a1 = *(struct cls_struct_3byte*)(args[0]); - a2 = *(struct cls_struct_3byte*)(args[1]); - - *(cls_struct_3byte*)resp = cls_struct_3byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_3byte g_dbl = { 12, 119 }; - struct cls_struct_3byte f_dbl = { 1, 15 }; - struct cls_struct_3byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_ushort; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_3byte_fn), &res_dbl, args_dbl); - /* { dg-output "12 119 1 15: 13 134" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 13 134" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_3byte(*)(cls_struct_3byte, cls_struct_3byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 119 1 15: 13 134" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 13 134" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c deleted file mode 100644 index c7251ce..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_3byte2.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Especially with small structures which may fit in one - register. Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_3byte_1 { - unsigned char a; - unsigned short b; -} cls_struct_3byte_1; - -cls_struct_3byte_1 cls_struct_3byte_fn1(struct cls_struct_3byte_1 a1, - struct cls_struct_3byte_1 a2) -{ - struct cls_struct_3byte_1 result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - - printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); - - return result; -} - -static void -cls_struct_3byte_gn1(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_3byte_1 a1, a2; - - a1 = *(struct cls_struct_3byte_1*)(args[0]); - a2 = *(struct cls_struct_3byte_1*)(args[1]); - - *(cls_struct_3byte_1*)resp = cls_struct_3byte_fn1(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_3byte_1 g_dbl = { 15, 125 }; - struct cls_struct_3byte_1 f_dbl = { 9, 19 }; - struct cls_struct_3byte_1 res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_ushort; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_3byte_fn1), &res_dbl, args_dbl); - /* { dg-output "15 125 9 19: 24 144" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 24 144" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn1, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_3byte_1(*)(cls_struct_3byte_1, cls_struct_3byte_1))(code))(g_dbl, f_dbl); - /* { dg-output "\n15 125 9 19: 24 144" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 24 144" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c deleted file mode 100644 index 2d6d8b6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_4_1byte.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Especially with small structures which may fit in one - register. Depending on the ABI. - Limitations: none. - PR: none. - Originator: 20030902 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_4_1byte { - unsigned char a; - unsigned char b; - unsigned char c; - unsigned char d; -} cls_struct_4_1byte; - -cls_struct_4_1byte cls_struct_4_1byte_fn(struct cls_struct_4_1byte a1, - struct cls_struct_4_1byte a2) -{ - struct cls_struct_4_1byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - - printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, - a2.a, a2.b, a2.c, a2.d, - result.a, result.b, result.c, result.d); - - return result; -} - -static void -cls_struct_4_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_4_1byte a1, a2; - - a1 = *(struct cls_struct_4_1byte*)(args[0]); - a2 = *(struct cls_struct_4_1byte*)(args[1]); - - *(cls_struct_4_1byte*)resp = cls_struct_4_1byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[5]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 }; - struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 }; - struct cls_struct_4_1byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_uchar; - cls_struct_fields[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_4_1byte_fn), &res_dbl, args_dbl); - /* { dg-output "12 13 14 15 178 179 180 181: 190 192 194 196" } */ - printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 190 192 194 196" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4_1byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_4_1byte(*)(cls_struct_4_1byte, cls_struct_4_1byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 13 14 15 178 179 180 181: 190 192 194 196" } */ - printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 190 192 194 196" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c deleted file mode 100644 index 4ac3787..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_4byte.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef struct cls_struct_4byte { - unsigned short a; - unsigned short b; -} cls_struct_4byte; - -cls_struct_4byte cls_struct_4byte_fn(struct cls_struct_4byte a1, - struct cls_struct_4byte a2) -{ - struct cls_struct_4byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - - printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); - - return result; -} - -static void -cls_struct_4byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_4byte a1, a2; - - a1 = *(struct cls_struct_4byte*)(args[0]); - a2 = *(struct cls_struct_4byte*)(args[1]); - - *(cls_struct_4byte*)resp = cls_struct_4byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_4byte g_dbl = { 127, 120 }; - struct cls_struct_4byte f_dbl = { 12, 128 }; - struct cls_struct_4byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_ushort; - cls_struct_fields[1] = &ffi_type_ushort; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_4byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 12 128: 139 248" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 139 248" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_4byte(*)(cls_struct_4byte, cls_struct_4byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 12 128: 139 248" } */ - printf("res: %d %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 139 248" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c deleted file mode 100644 index ad9d51c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_5_1_byte.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20050708 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_5byte { - unsigned char a; - unsigned char b; - unsigned char c; - unsigned char d; - unsigned char e; -} cls_struct_5byte; - -cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, - struct cls_struct_5byte a2) -{ - struct cls_struct_5byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - result.e = a1.e + a2.e; - - printf("%d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d\n", - a1.a, a1.b, a1.c, a1.d, a1.e, - a2.a, a2.b, a2.c, a2.d, a2.e, - result.a, result.b, result.c, result.d, result.e); - - return result; -} - -static void -cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_5byte a1, a2; - - a1 = *(struct cls_struct_5byte*)(args[0]); - a2 = *(struct cls_struct_5byte*)(args[1]); - - *(cls_struct_5byte*)resp = cls_struct_5byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[6]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 }; - struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 }; - struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 }; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_uchar; - cls_struct_fields[4] = &ffi_type_uchar; - cls_struct_fields[5] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_5byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */ - printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e); - /* { dg-output "\nres: 139 248 10 6 8" } */ - - res_dbl.a = 0; - res_dbl.b = 0; - res_dbl.c = 0; - res_dbl.d = 0; - res_dbl.e = 0; - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */ - printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e); - /* { dg-output "\nres: 139 248 10 6 8" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c deleted file mode 100644 index 4e0c000..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_5byte.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_5byte { - unsigned short a; - unsigned short b; - unsigned char c; -} cls_struct_5byte; - -cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, - struct cls_struct_5byte a2) -{ - struct cls_struct_5byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, - a2.a, a2.b, a2.c, - result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_5byte a1, a2; - - a1 = *(struct cls_struct_5byte*)(args[0]); - a2 = *(struct cls_struct_5byte*)(args[1]); - - *(cls_struct_5byte*)resp = cls_struct_5byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_5byte g_dbl = { 127, 120, 1 }; - struct cls_struct_5byte f_dbl = { 12, 128, 9 }; - struct cls_struct_5byte res_dbl = { 0, 0, 0 }; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_ushort; - cls_struct_fields[1] = &ffi_type_ushort; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_5byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 1 12 128 9: 139 248 10" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 139 248 10" } */ - - res_dbl.a = 0; - res_dbl.b = 0; - res_dbl.c = 0; - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 1 12 128 9: 139 248 10" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 139 248 10" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c deleted file mode 100644 index a55edc2..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_64byte.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check bigger struct which overlaps - the gp and fp register count on Darwin/AIX/ppc64. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_64byte { - double a; - double b; - double c; - double d; - double e; - double f; - double g; - double h; -} cls_struct_64byte; - -cls_struct_64byte cls_struct_64byte_fn(struct cls_struct_64byte b0, - struct cls_struct_64byte b1, - struct cls_struct_64byte b2, - struct cls_struct_64byte b3) -{ - struct cls_struct_64byte result; - - result.a = b0.a + b1.a + b2.a + b3.a; - result.b = b0.b + b1.b + b2.b + b3.b; - result.c = b0.c + b1.c + b2.c + b3.c; - result.d = b0.d + b1.d + b2.d + b3.d; - result.e = b0.e + b1.e + b2.e + b3.e; - result.f = b0.f + b1.f + b2.f + b3.f; - result.g = b0.g + b1.g + b2.g + b3.g; - result.h = b0.h + b1.h + b2.h + b3.h; - - printf("%g %g %g %g %g %g %g %g\n", result.a, result.b, result.c, - result.d, result.e, result.f, result.g, result.h); - - return result; -} - -static void -cls_struct_64byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_64byte b0, b1, b2, b3; - - b0 = *(struct cls_struct_64byte*)(args[0]); - b1 = *(struct cls_struct_64byte*)(args[1]); - b2 = *(struct cls_struct_64byte*)(args[2]); - b3 = *(struct cls_struct_64byte*)(args[3]); - - *(cls_struct_64byte*)resp = cls_struct_64byte_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[9]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_64byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0 }; - struct cls_struct_64byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0 }; - struct cls_struct_64byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0 }; - struct cls_struct_64byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0 }; - struct cls_struct_64byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_double; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = &ffi_type_double; - cls_struct_fields[5] = &ffi_type_double; - cls_struct_fields[6] = &ffi_type_double; - cls_struct_fields[7] = &ffi_type_double; - cls_struct_fields[8] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = &cls_struct_type; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_64byte_fn), &res_dbl, args_dbl); - /* { dg-output "22 15 17 25 6 13 19 18" } */ - printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_64byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_64byte(*)(cls_struct_64byte, - cls_struct_64byte, - cls_struct_64byte, - cls_struct_64byte)) - (code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n22 15 17 25 6 13 19 18" } */ - printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c deleted file mode 100644 index b4dcdba..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_6_1_byte.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20050708 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_6byte { - unsigned char a; - unsigned char b; - unsigned char c; - unsigned char d; - unsigned char e; - unsigned char f; -} cls_struct_6byte; - -cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, - struct cls_struct_6byte a2) -{ - struct cls_struct_6byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - result.e = a1.e + a2.e; - result.f = a1.f + a2.f; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d %d\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, - a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, - result.a, result.b, result.c, result.d, result.e, result.f); - - return result; -} - -static void -cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_6byte a1, a2; - - a1 = *(struct cls_struct_6byte*)(args[0]); - a2 = *(struct cls_struct_6byte*)(args[1]); - - *(cls_struct_6byte*)resp = cls_struct_6byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[7]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 }; - struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 }; - struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 }; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_uchar; - cls_struct_fields[4] = &ffi_type_uchar; - cls_struct_fields[5] = &ffi_type_uchar; - cls_struct_fields[6] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_6byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */ - printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f); - /* { dg-output "\nres: 139 248 10 6 8 10" } */ - - res_dbl.a = 0; - res_dbl.b = 0; - res_dbl.c = 0; - res_dbl.d = 0; - res_dbl.e = 0; - res_dbl.f = 0; - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */ - printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f); - /* { dg-output "\nres: 139 248 10 6 8 10" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c deleted file mode 100644 index 7406780..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_6byte.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_6byte { - unsigned short a; - unsigned short b; - unsigned char c; - unsigned char d; -} cls_struct_6byte; - -cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, - struct cls_struct_6byte a2) -{ - struct cls_struct_6byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - - printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, - a2.a, a2.b, a2.c, a2.d, - result.a, result.b, result.c, result.d); - - return result; -} - -static void -cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_6byte a1, a2; - - a1 = *(struct cls_struct_6byte*)(args[0]); - a2 = *(struct cls_struct_6byte*)(args[1]); - - *(cls_struct_6byte*)resp = cls_struct_6byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[5]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 }; - struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 }; - struct cls_struct_6byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_ushort; - cls_struct_fields[1] = &ffi_type_ushort; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_uchar; - cls_struct_fields[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_6byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 1 128 12 128 9 127: 139 248 10 255" } */ - printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 139 248 10 255" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 1 128 12 128 9 127: 139 248 10 255" } */ - printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 139 248 10 255" } */ - - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c deleted file mode 100644 index 14a7e96..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_7_1_byte.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20050708 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_7byte { - unsigned char a; - unsigned char b; - unsigned char c; - unsigned char d; - unsigned char e; - unsigned char f; - unsigned char g; -} cls_struct_7byte; - -cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, - struct cls_struct_7byte a2) -{ - struct cls_struct_7byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - result.e = a1.e + a2.e; - result.f = a1.f + a2.f; - result.g = a1.g + a2.g; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d %d %d\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, - a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, - result.a, result.b, result.c, result.d, result.e, result.f, result.g); - - return result; -} - -static void -cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_7byte a1, a2; - - a1 = *(struct cls_struct_7byte*)(args[0]); - a2 = *(struct cls_struct_7byte*)(args[1]); - - *(cls_struct_7byte*)resp = cls_struct_7byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[8]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 }; - struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 }; - struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 }; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_uchar; - cls_struct_fields[4] = &ffi_type_uchar; - cls_struct_fields[5] = &ffi_type_uchar; - cls_struct_fields[6] = &ffi_type_uchar; - cls_struct_fields[7] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_7byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */ - printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); - /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ - - res_dbl.a = 0; - res_dbl.b = 0; - res_dbl.c = 0; - res_dbl.d = 0; - res_dbl.e = 0; - res_dbl.f = 0; - res_dbl.g = 0; - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */ - printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); - /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c deleted file mode 100644 index 1645cc6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_7byte.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_7byte { - unsigned short a; - unsigned short b; - unsigned char c; - unsigned short d; -} cls_struct_7byte; - -cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, - struct cls_struct_7byte a2) -{ - struct cls_struct_7byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - result.d = a1.d + a2.d; - - printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, - a2.a, a2.b, a2.c, a2.d, - result.a, result.b, result.c, result.d); - - return result; -} - -static void -cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_7byte a1, a2; - - a1 = *(struct cls_struct_7byte*)(args[0]); - a2 = *(struct cls_struct_7byte*)(args[1]); - - *(cls_struct_7byte*)resp = cls_struct_7byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[5]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 }; - struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 }; - struct cls_struct_7byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_ushort; - cls_struct_fields[1] = &ffi_type_ushort; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = &ffi_type_ushort; - cls_struct_fields[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_7byte_fn), &res_dbl, args_dbl); - /* { dg-output "127 120 1 254 12 128 9 255: 139 248 10 509" } */ - printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 139 248 10 509" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n127 120 1 254 12 128 9 255: 139 248 10 509" } */ - printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); - /* { dg-output "\nres: 139 248 10 509" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c deleted file mode 100644 index f6c1ea5..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_8byte.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Check overlapping. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_8byte { - int a; - float b; -} cls_struct_8byte; - -cls_struct_8byte cls_struct_8byte_fn(struct cls_struct_8byte a1, - struct cls_struct_8byte a2) -{ - struct cls_struct_8byte result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - - printf("%d %g %d %g: %d %g\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); - - return result; -} - -static void -cls_struct_8byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_8byte a1, a2; - - a1 = *(struct cls_struct_8byte*)(args[0]); - a2 = *(struct cls_struct_8byte*)(args[1]); - - *(cls_struct_8byte*)resp = cls_struct_8byte_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_8byte g_dbl = { 1, 2.0 }; - struct cls_struct_8byte f_dbl = { 4, 5.0 }; - struct cls_struct_8byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_sint; - cls_struct_fields[1] = &ffi_type_float; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_8byte_fn), &res_dbl, args_dbl); - /* { dg-output "1 2 4 5: 5 7" } */ - printf("res: %d %g\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 5 7" } */ - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_8byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_8byte(*)(cls_struct_8byte, cls_struct_8byte))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 2 4 5: 5 7" } */ - printf("res: %d %g\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 5 7" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c deleted file mode 100644 index 0b85722..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte1.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Darwin/AIX do double-word - alignment of the struct if the first element is a double. - Check that it does not here. - Limitations: none. - PR: none. - Originator: 20030914 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_9byte { - int a; - double b; -} cls_struct_9byte; - -cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, - struct cls_struct_9byte b2) -{ - struct cls_struct_9byte result; - - result.a = b1.a + b2.a; - result.b = b1.b + b2.b; - - printf("%d %g %d %g: %d %g\n", b1.a, b1.b, b2.a, b2.b, - result.a, result.b); - - return result; -} - -static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - struct cls_struct_9byte b1, b2; - - b1 = *(struct cls_struct_9byte*)(args[0]); - b2 = *(struct cls_struct_9byte*)(args[1]); - - *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_9byte h_dbl = { 7, 8.0}; - struct cls_struct_9byte j_dbl = { 1, 9.0}; - struct cls_struct_9byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_sint; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &h_dbl; - args_dbl[1] = &j_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl); - /* { dg-output "7 8 1 9: 8 17" } */ - printf("res: %d %g\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 8 17" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl); - /* { dg-output "\n7 8 1 9: 8 17" } */ - printf("res: %d %g\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 8 17" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c deleted file mode 100644 index edf991d..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_9byte2.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Depending on the ABI. Darwin/AIX do double-word - alignment of the struct if the first element is a double. - Check that it does here. - Limitations: none. - PR: none. - Originator: 20030914 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_9byte { - double a; - int b; -} cls_struct_9byte; - -cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, - struct cls_struct_9byte b2) -{ - struct cls_struct_9byte result; - - result.a = b1.a + b2.a; - result.b = b1.b + b2.b; - - printf("%g %d %g %d: %g %d\n", b1.a, b1.b, b2.a, b2.b, - result.a, result.b); - - return result; -} - -static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - struct cls_struct_9byte b1, b2; - - b1 = *(struct cls_struct_9byte*)(args[0]); - b2 = *(struct cls_struct_9byte*)(args[1]); - - *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_9byte h_dbl = { 7.0, 8}; - struct cls_struct_9byte j_dbl = { 1.0, 9}; - struct cls_struct_9byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_sint; - cls_struct_fields[2] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &h_dbl; - args_dbl[1] = &j_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl); - /* { dg-output "7 8 1 9: 8 17" } */ - printf("res: %g %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 8 17" } */ - - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl); - /* { dg-output "\n7 8 1 9: 8 17" } */ - printf("res: %g %d\n", res_dbl.a, res_dbl.b); - /* { dg-output "\nres: 8 17" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c deleted file mode 100644 index aad5f3c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_double.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of double. - Limitations: none. - PR: none. - Originator: 20031203 */ - - - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - double b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c deleted file mode 100644 index 37e0855..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_float.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of float. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - float b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_float; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c deleted file mode 100644 index b3322d8..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of long double. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - long double b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_longdouble; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c deleted file mode 100644 index cc1c43b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of long double. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ - -#include "ffitest.h" - -typedef struct cls_struct_align { - long double a; - long double b; - long double c; - long double d; - long double e; - long double f; - long double g; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn( - cls_struct_align a1, - cls_struct_align a2) -{ - struct cls_struct_align r; - - r.a = a1.a + a2.a; - r.b = a1.b + a2.b; - r.c = a1.c + a2.c; - r.d = a1.d + a2.d; - r.e = a1.e + a2.e; - r.f = a1.f + a2.f; - r.g = a1.g + a2.g; - - printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: " - "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, - a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, - r.a, r.b, r.c, r.d, r.e, r.f, r.g); - - return r; -} - -cls_struct_align cls_struct_align_fn2( - cls_struct_align a1) -{ - struct cls_struct_align r; - - r.a = a1.a + 1; - r.b = a1.b + 1; - r.c = a1.c + 1; - r.d = a1.d + 1; - r.e = a1.e + 1; - r.f = a1.f + 1; - r.g = a1.g + 1; - - printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg: " - "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, - r.a, r.b, r.c, r.d, r.e, r.f, r.g); - - return r; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[8]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; - struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_longdouble; - cls_struct_fields[1] = &ffi_type_longdouble; - cls_struct_fields[2] = &ffi_type_longdouble; - cls_struct_fields[3] = &ffi_type_longdouble; - cls_struct_fields[4] = &ffi_type_longdouble; - cls_struct_fields[5] = &ffi_type_longdouble; - cls_struct_fields[6] = &ffi_type_longdouble; - cls_struct_fields[7] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ - printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); - /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ - printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); - /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c deleted file mode 100644 index 5d3bec0..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +++ /dev/null @@ -1,115 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of long double. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/18/2007 -*/ - -/* { dg-do run { xfail strongarm*-*-* } } */ -/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ - -#include "ffitest.h" - -typedef struct cls_struct_align { - long double a; - long double b; - long double c; - long double d; - long double e; - double f; - long double g; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn( - cls_struct_align a1, - cls_struct_align a2) -{ - struct cls_struct_align r; - - r.a = a1.a + a2.a; - r.b = a1.b + a2.b; - r.c = a1.c + a2.c; - r.d = a1.d + a2.d; - r.e = a1.e + a2.e; - r.f = a1.f + a2.f; - r.g = a1.g + a2.g; - - printf("%Lg %Lg %Lg %Lg %Lg %g %Lg %Lg %Lg %Lg %Lg %Lg %g %Lg: " - "%Lg %Lg %Lg %Lg %Lg %g %Lg\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, - a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, - r.a, r.b, r.c, r.d, r.e, r.f, r.g); - - return r; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[8]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[3]; - - struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; - struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_longdouble; - cls_struct_fields[1] = &ffi_type_longdouble; - cls_struct_fields[2] = &ffi_type_longdouble; - cls_struct_fields[3] = &ffi_type_longdouble; - cls_struct_fields[4] = &ffi_type_longdouble; - cls_struct_fields[5] = &ffi_type_double; - cls_struct_fields[6] = &ffi_type_longdouble; - cls_struct_fields[7] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ - printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); - /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */ - printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); - /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - - exit(0); -} - - - diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c deleted file mode 100644 index 8fbf36a..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_pointer.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of pointer. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - void *b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = (void *)((uintptr_t)a1.b + (uintptr_t)a2.b); - result.c = a1.c + a2.c; - - printf("%d %" PRIuPTR " %d %d %" PRIuPTR " %d: %d %" PRIuPTR " %d\n", - a1.a, (uintptr_t)a1.b, a1.c, - a2.a, (uintptr_t)a2.b, a2.c, - result.a, (uintptr_t)result.b, - result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, (void *)4951, 127 }; - struct cls_struct_align f_dbl = { 1, (void *)9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_pointer; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c deleted file mode 100644 index 039b874..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint16.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of sint16. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - signed short b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_sshort; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c deleted file mode 100644 index c96c6d1..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint32.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of sint32. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - signed int b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_sint; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c deleted file mode 100644 index 9aa7bdd..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_sint64.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of sint64. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - signed long long b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_sint64; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c deleted file mode 100644 index 97620b7..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint16.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of uint16. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - unsigned short b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_ushort; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c deleted file mode 100644 index 5766fad..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint32.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of uint32. - Limitations: none. - PR: none. - Originator: 20031203 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - unsigned int b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uint; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c deleted file mode 100644 index a52cb89..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_align_uint64.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of uint64. - Limitations: none. - PR: none. - Originator: 20031203 */ - - -/* { dg-do run } */ -/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ -#include "ffitest.h" - -typedef struct cls_struct_align { - unsigned char a; - unsigned long long b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, - struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uint64; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &g_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl); - /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); - /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ - printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); - /* { dg-output "\nres: 13 14271 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c deleted file mode 100644 index d663791..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_dbls_struct.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check double arguments in structs. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/23/2007 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef struct Dbls { - double x; - double y; -} Dbls; - -void -closure_test_fn(Dbls p) -{ - printf("%.1f %.1f\n", p.x, p.y); -} - -void -closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, - void** args, void* userdata __UNUSED__) -{ - closure_test_fn(*(Dbls*)args[0]); -} - -int main(int argc __UNUSED__, char** argv __UNUSED__) -{ - ffi_cif cif; - - void *code; - ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type* cl_arg_types[1]; - - ffi_type ts1_type; - ffi_type* ts1_type_elements[4]; - - Dbls arg = { 1.0, 2.0 }; - - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - - ts1_type_elements[0] = &ffi_type_double; - ts1_type_elements[1] = &ffi_type_double; - ts1_type_elements[2] = NULL; - - cl_arg_types[0] = &ts1_type; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_void, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK); - - ((void*(*)(Dbls))(code))(arg); - /* { dg-output "1.0 2.0\n" } */ - - closure_test_fn(arg); - /* { dg-output "1.0 2.0\n" } */ - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c deleted file mode 100644 index 84ad4cb..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_double.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Area: closure_call - Purpose: Check return value double. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(double *)resp = *(double *)args[0]; - - printf("%f: %f\n",*(double *)args[0], - *(double *)resp); - } -typedef double (*cls_ret_double)(double); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - double res; - - cl_arg_types[0] = &ffi_type_double; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_double, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_double)code))(21474.789); - /* { dg-output "21474.789000: 21474.789000" } */ - printf("res: %.6f\n", res); - /* { dg-output "\nres: 21474.789000" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c deleted file mode 100644 index e077f92..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_double_va.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test doubles passed in variable argument lists. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-output "" { xfail avr32*-*-* } } */ -/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ - -#include "ffitest.h" - -static void -cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - char* format = *(char**)args[0]; - double doubleValue = *(double*)args[1]; - - *(ffi_arg*)resp = printf(format, doubleValue); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[3]; - ffi_type* arg_types[3]; - - char* format = "%.1f\n"; - double doubleArg = 7; - ffi_arg res = 0; - - arg_types[0] = &ffi_type_pointer; - arg_types[1] = &ffi_type_double; - arg_types[2] = NULL; - - /* This printf call is variadic */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint, - arg_types) == FFI_OK); - - args[0] = &format; - args[1] = &doubleArg; - args[2] = NULL; - - ffi_call(&cif, FFI_FN(printf), &res, args); - /* { dg-output "7.0" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, - code) == FFI_OK); - - res = ((int(*)(char*, ...))(code))(format, doubleArg); - /* { dg-output "\n7.0" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c deleted file mode 100644 index 0090fed..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_float.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Area: closure_call - Purpose: Check return value float. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_float_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(float *)resp = *(float *)args[0]; - - printf("%g: %g\n",*(float *)args[0], - *(float *)resp); - } - -typedef float (*cls_ret_float)(float); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - float res; - - cl_arg_types[0] = &ffi_type_float; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_float, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_float_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_float)code)(-2122.12))); - /* { dg-output "\\-2122.12: \\-2122.12" } */ - printf("res: %.6f\n", res); - /* { dg-output "\nres: \-2122.120117" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c deleted file mode 100644 index d24e72e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check long double arguments. - Limitations: none. - PR: none. - Originator: Blake Chaffin */ - -/* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have - remove the xfail for arm*-*-* below, until we know more. */ -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ - -#include "ffitest.h" - -long double cls_ldouble_fn( - long double a1, - long double a2, - long double a3, - long double a4, - long double a5, - long double a6, - long double a7, - long double a8) -{ - long double r = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; - - printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: %Lg\n", - a1, a2, a3, a4, a5, a6, a7, a8, r); - - return r; -} - -static void -cls_ldouble_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - long double a1 = *(long double*)args[0]; - long double a2 = *(long double*)args[1]; - long double a3 = *(long double*)args[2]; - long double a4 = *(long double*)args[3]; - long double a5 = *(long double*)args[4]; - long double a6 = *(long double*)args[5]; - long double a7 = *(long double*)args[6]; - long double a8 = *(long double*)args[7]; - - *(long double*)resp = cls_ldouble_fn( - a1, a2, a3, a4, a5, a6, a7, a8); -} - -int main(void) -{ - ffi_cif cif; - void* code; - ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[9]; - ffi_type* arg_types[9]; - long double res = 0; - - long double arg1 = 1; - long double arg2 = 2; - long double arg3 = 3; - long double arg4 = 4; - long double arg5 = 5; - long double arg6 = 6; - long double arg7 = 7; - long double arg8 = 8; - - arg_types[0] = &ffi_type_longdouble; - arg_types[1] = &ffi_type_longdouble; - arg_types[2] = &ffi_type_longdouble; - arg_types[3] = &ffi_type_longdouble; - arg_types[4] = &ffi_type_longdouble; - arg_types[5] = &ffi_type_longdouble; - arg_types[6] = &ffi_type_longdouble; - arg_types[7] = &ffi_type_longdouble; - arg_types[8] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 8, &ffi_type_longdouble, - arg_types) == FFI_OK); - - args[0] = &arg1; - args[1] = &arg2; - args[2] = &arg3; - args[3] = &arg4; - args[4] = &arg5; - args[5] = &arg6; - args[6] = &arg7; - args[7] = &arg8; - args[8] = NULL; - - ffi_call(&cif, FFI_FN(cls_ldouble_fn), &res, args); - /* { dg-output "1 2 3 4 5 6 7 8: 36" } */ - printf("res: %Lg\n", res); - /* { dg-output "\nres: 36" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ldouble_gn, NULL, code) == FFI_OK); - - res = ((long double(*)(long double, long double, long double, long double, - long double, long double, long double, long double))(code))(arg1, arg2, - arg3, arg4, arg5, arg6, arg7, arg8); - /* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */ - printf("res: %Lg\n", res); - /* { dg-output "\nres: 36" } */ - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c deleted file mode 100644 index 39b438b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_longdouble_va.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test long doubles passed in variable argument lists. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */ -/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ - -#include "ffitest.h" - -static void -cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - char* format = *(char**)args[0]; - long double ldValue = *(long double*)args[1]; - - *(ffi_arg*)resp = printf(format, ldValue); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[3]; - ffi_type* arg_types[3]; - - char* format = "%.1Lf\n"; - long double ldArg = 7; - ffi_arg res = 0; - - arg_types[0] = &ffi_type_pointer; - arg_types[1] = &ffi_type_longdouble; - arg_types[2] = NULL; - - /* This printf call is variadic */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint, - arg_types) == FFI_OK); - - args[0] = &format; - args[1] = &ldArg; - args[2] = NULL; - - ffi_call(&cif, FFI_FN(printf), &res, args); - /* { dg-output "7.0" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, - code) == FFI_OK); - - res = ((int(*)(char*, ...))(code))(format, ldArg); - /* { dg-output "\n7.0" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c deleted file mode 100644 index 7fd6c82..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_args.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Area: closure_call - Purpose: Check closures called with many args of mixed types - Limitations: none. - PR: none. - Originator: */ - -/* { dg-do run } */ -#include "ffitest.h" -#include -#include - -#define NARGS 16 - -static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - int i; - double r = 0; - double t; - for(i = 0; i < NARGS; i++) - { - if(i == 4 || i == 9 || i == 11 || i == 13 || i == 15) - { - t = *(long int *)args[i]; - CHECK(t == i+1); - } - else - { - t = *(double *)args[i]; - CHECK(fabs(t - ((i+1) * 0.1)) < FLT_EPSILON); - } - r += t; - } - *(double *)resp = r; -} -typedef double (*cls_ret_double)(double, double, double, double, long int, -double, double, double, double, long int, double, long int, double, long int, -double, long int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[NARGS]; - double res; - int i; - double expected = 64.9; - - for(i = 0; i < NARGS; i++) - { - if(i == 4 || i == 9 || i == 11 || i == 13 || i == 15) - cl_arg_types[i] = &ffi_type_slong; - else - cl_arg_types[i] = &ffi_type_double; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NARGS, - &ffi_type_double, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK); - - res = (((cls_ret_double)code))(0.1, 0.2, 0.3, 0.4, 5, 0.6, 0.7, 0.8, 0.9, 10, - 1.1, 12, 1.3, 14, 1.5, 16); - if (fabs(res - expected) < FLT_EPSILON) - exit(0); - else - abort(); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c deleted file mode 100644 index 62b0697..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Area: closure_call - Purpose: Check register allocation for closure calls with many float and double arguments - Limitations: none. - PR: none. - Originator: */ - -/* { dg-do run } */ -#include "ffitest.h" -#include -#include - -#define NARGS 16 - -static void cls_mixed_float_double_fn(ffi_cif* cif , void* ret, void** args, - void* userdata __UNUSED__) -{ - double r = 0; - unsigned int i; - double t; - for(i=0; i < cif->nargs; i++) - { - if(cif->arg_types[i] == &ffi_type_double) { - t = *(((double**)(args))[i]); - } else { - t = *(((float**)(args))[i]); - } - r += t; - } - *((double*)ret) = r; -} -typedef double (*cls_mixed)(double, float, double, double, double, double, double, float, float, double, float, float); - -int main (void) -{ - ffi_cif cif; - ffi_closure *closure; - void* code; - ffi_type *argtypes[12] = {&ffi_type_double, &ffi_type_float, &ffi_type_double, - &ffi_type_double, &ffi_type_double, &ffi_type_double, - &ffi_type_double, &ffi_type_float, &ffi_type_float, - &ffi_type_double, &ffi_type_float, &ffi_type_float}; - - - closure = ffi_closure_alloc(sizeof(ffi_closure), (void**)&code); - if(closure ==NULL) - abort(); - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 12, &ffi_type_double, argtypes) == FFI_OK); - CHECK(ffi_prep_closure_loc(closure, &cif, cls_mixed_float_double_fn, NULL, code) == FFI_OK); - double ret = ((cls_mixed)code)(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2); - ffi_closure_free(closure); - if(fabs(ret - 7.8) < FLT_EPSILON) - exit(0); - else - abort(); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c deleted file mode 100644 index 71df7b6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_schar.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check passing of multiple signed char values. - Limitations: none. - PR: PR13221. - Originator: 20031129 */ - -/* { dg-do run } */ -#include "ffitest.h" - -signed char test_func_fn(signed char a1, signed char a2) -{ - signed char result; - - result = a1 + a2; - - printf("%d %d: %d\n", a1, a2, result); - - return result; - -} - -static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, - void *data __UNUSED__) -{ - signed char a1, a2; - - a1 = *(signed char *)avals[0]; - a2 = *(signed char *)avals[1]; - - *(ffi_arg *)rval = test_func_fn(a1, a2); - -} - -typedef signed char (*test_type)(signed char, signed char); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void * args_dbl[3]; - ffi_type * cl_arg_types[3]; - ffi_arg res_call; - signed char a, b, res_closure; - - a = 2; - b = 125; - - args_dbl[0] = &a; - args_dbl[1] = &b; - args_dbl[2] = NULL; - - cl_arg_types[0] = &ffi_type_schar; - cl_arg_types[1] = &ffi_type_schar; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, - &ffi_type_schar, cl_arg_types) == FFI_OK); - - ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); - /* { dg-output "2 125: 127" } */ - printf("res: %d\n", (signed char)res_call); - /* { dg-output "\nres: 127" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); - - res_closure = (*((test_type)code))(2, 125); - /* { dg-output "\n2 125: 127" } */ - printf("res: %d\n", res_closure); - /* { dg-output "\nres: 127" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c deleted file mode 100644 index 4c39153..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshort.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check passing of multiple signed short values. - Limitations: none. - PR: PR13221. - Originator: 20031129 */ - -/* { dg-do run } */ -#include "ffitest.h" - -signed short test_func_fn(signed short a1, signed short a2) -{ - signed short result; - - result = a1 + a2; - - printf("%d %d: %d\n", a1, a2, result); - - return result; - -} - -static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, - void *data __UNUSED__) -{ - signed short a1, a2; - - a1 = *(signed short *)avals[0]; - a2 = *(signed short *)avals[1]; - - *(ffi_arg *)rval = test_func_fn(a1, a2); - -} - -typedef signed short (*test_type)(signed short, signed short); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void * args_dbl[3]; - ffi_type * cl_arg_types[3]; - ffi_arg res_call; - unsigned short a, b, res_closure; - - a = 2; - b = 32765; - - args_dbl[0] = &a; - args_dbl[1] = &b; - args_dbl[2] = NULL; - - cl_arg_types[0] = &ffi_type_sshort; - cl_arg_types[1] = &ffi_type_sshort; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, - &ffi_type_sshort, cl_arg_types) == FFI_OK); - - ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); - /* { dg-output "2 32765: 32767" } */ - printf("res: %d\n", (unsigned short)res_call); - /* { dg-output "\nres: 32767" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); - - res_closure = (*((test_type)code))(2, 32765); - /* { dg-output "\n2 32765: 32767" } */ - printf("res: %d\n", res_closure); - /* { dg-output "\nres: 32767" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c deleted file mode 100644 index 1c3aeb5..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check passing of multiple signed short/char values. - Limitations: none. - PR: PR13221. - Originator: 20031129 */ - -/* { dg-do run } */ -#include "ffitest.h" - -signed short test_func_fn(signed char a1, signed short a2, - signed char a3, signed short a4) -{ - signed short result; - - result = a1 + a2 + a3 + a4; - - printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); - - return result; - -} - -static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, - void *data __UNUSED__) -{ - signed char a1, a3; - signed short a2, a4; - - a1 = *(signed char *)avals[0]; - a2 = *(signed short *)avals[1]; - a3 = *(signed char *)avals[2]; - a4 = *(signed short *)avals[3]; - - *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4); - -} - -typedef signed short (*test_type)(signed char, signed short, - signed char, signed short); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void * args_dbl[5]; - ffi_type * cl_arg_types[5]; - ffi_arg res_call; - signed char a, c; - signed short b, d, res_closure; - - a = 1; - b = 32765; - c = 127; - d = -128; - - args_dbl[0] = &a; - args_dbl[1] = &b; - args_dbl[2] = &c; - args_dbl[3] = &d; - args_dbl[4] = NULL; - - cl_arg_types[0] = &ffi_type_schar; - cl_arg_types[1] = &ffi_type_sshort; - cl_arg_types[2] = &ffi_type_schar; - cl_arg_types[3] = &ffi_type_sshort; - cl_arg_types[4] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_sshort, cl_arg_types) == FFI_OK); - - ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); - /* { dg-output "1 32765 127 -128: 32765" } */ - printf("res: %d\n", (signed short)res_call); - /* { dg-output "\nres: 32765" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); - - res_closure = (*((test_type)code))(1, 32765, 127, -128); - /* { dg-output "\n1 32765 127 -128: 32765" } */ - printf("res: %d\n", res_closure); - /* { dg-output "\nres: 32765" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c deleted file mode 100644 index 009c02c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_uchar.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check passing of multiple unsigned char values. - Limitations: none. - PR: PR13221. - Originator: 20031129 */ - -/* { dg-do run } */ -#include "ffitest.h" - -unsigned char test_func_fn(unsigned char a1, unsigned char a2, - unsigned char a3, unsigned char a4) -{ - unsigned char result; - - result = a1 + a2 + a3 + a4; - - printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); - - return result; - -} - -static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, - void *data __UNUSED__) -{ - unsigned char a1, a2, a3, a4; - - a1 = *(unsigned char *)avals[0]; - a2 = *(unsigned char *)avals[1]; - a3 = *(unsigned char *)avals[2]; - a4 = *(unsigned char *)avals[3]; - - *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4); - -} - -typedef unsigned char (*test_type)(unsigned char, unsigned char, - unsigned char, unsigned char); - -void test_func(ffi_cif *cif __UNUSED__, void *rval __UNUSED__, void **avals, - void *data __UNUSED__) -{ - printf("%d %d %d %d\n", *(unsigned char *)avals[0], - *(unsigned char *)avals[1], *(unsigned char *)avals[2], - *(unsigned char *)avals[3]); -} -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void * args_dbl[5]; - ffi_type * cl_arg_types[5]; - ffi_arg res_call; - unsigned char a, b, c, d, res_closure; - - a = 1; - b = 2; - c = 127; - d = 125; - - args_dbl[0] = &a; - args_dbl[1] = &b; - args_dbl[2] = &c; - args_dbl[3] = &d; - args_dbl[4] = NULL; - - cl_arg_types[0] = &ffi_type_uchar; - cl_arg_types[1] = &ffi_type_uchar; - cl_arg_types[2] = &ffi_type_uchar; - cl_arg_types[3] = &ffi_type_uchar; - cl_arg_types[4] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_uchar, cl_arg_types) == FFI_OK); - - ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); - /* { dg-output "1 2 127 125: 255" } */ - printf("res: %d\n", (unsigned char)res_call); - /* { dg-output "\nres: 255" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); - - res_closure = (*((test_type)code))(1, 2, 127, 125); - /* { dg-output "\n1 2 127 125: 255" } */ - printf("res: %d\n", res_closure); - /* { dg-output "\nres: 255" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c deleted file mode 100644 index dd10ca7..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushort.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check passing of multiple unsigned short values. - Limitations: none. - PR: PR13221. - Originator: 20031129 */ - -/* { dg-do run } */ -#include "ffitest.h" - -unsigned short test_func_fn(unsigned short a1, unsigned short a2) -{ - unsigned short result; - - result = a1 + a2; - - printf("%d %d: %d\n", a1, a2, result); - - return result; - -} - -static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, - void *data __UNUSED__) -{ - unsigned short a1, a2; - - a1 = *(unsigned short *)avals[0]; - a2 = *(unsigned short *)avals[1]; - - *(ffi_arg *)rval = test_func_fn(a1, a2); - -} - -typedef unsigned short (*test_type)(unsigned short, unsigned short); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void * args_dbl[3]; - ffi_type * cl_arg_types[3]; - ffi_arg res_call; - unsigned short a, b, res_closure; - - a = 2; - b = 32765; - - args_dbl[0] = &a; - args_dbl[1] = &b; - args_dbl[2] = NULL; - - cl_arg_types[0] = &ffi_type_ushort; - cl_arg_types[1] = &ffi_type_ushort; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, - &ffi_type_ushort, cl_arg_types) == FFI_OK); - - ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); - /* { dg-output "2 32765: 32767" } */ - printf("res: %d\n", (unsigned short)res_call); - /* { dg-output "\nres: 32767" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); - - res_closure = (*((test_type)code))(2, 32765); - /* { dg-output "\n2 32765: 32767" } */ - printf("res: %d\n", res_closure); - /* { dg-output "\nres: 32767" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c deleted file mode 100644 index 2588e97..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check passing of multiple unsigned short/char values. - Limitations: none. - PR: PR13221. - Originator: 20031129 */ - -/* { dg-do run } */ -#include "ffitest.h" - -unsigned short test_func_fn(unsigned char a1, unsigned short a2, - unsigned char a3, unsigned short a4) -{ - unsigned short result; - - result = a1 + a2 + a3 + a4; - - printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); - - return result; - -} - -static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, - void *data __UNUSED__) -{ - unsigned char a1, a3; - unsigned short a2, a4; - - a1 = *(unsigned char *)avals[0]; - a2 = *(unsigned short *)avals[1]; - a3 = *(unsigned char *)avals[2]; - a4 = *(unsigned short *)avals[3]; - - *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4); - -} - -typedef unsigned short (*test_type)(unsigned char, unsigned short, - unsigned char, unsigned short); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void * args_dbl[5]; - ffi_type * cl_arg_types[5]; - ffi_arg res_call; - unsigned char a, c; - unsigned short b, d, res_closure; - - a = 1; - b = 2; - c = 127; - d = 128; - - args_dbl[0] = &a; - args_dbl[1] = &b; - args_dbl[2] = &c; - args_dbl[3] = &d; - args_dbl[4] = NULL; - - cl_arg_types[0] = &ffi_type_uchar; - cl_arg_types[1] = &ffi_type_ushort; - cl_arg_types[2] = &ffi_type_uchar; - cl_arg_types[3] = &ffi_type_ushort; - cl_arg_types[4] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_ushort, cl_arg_types) == FFI_OK); - - ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl); - /* { dg-output "1 2 127 128: 258" } */ - printf("res: %d\n", (unsigned short)res_call); - /* { dg-output "\nres: 258" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); - - res_closure = (*((test_type)code))(1, 2, 127, 128); - /* { dg-output "\n1 2 127 128: 258" } */ - printf("res: %d\n", res_closure); - /* { dg-output "\nres: 258" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c deleted file mode 100644 index d82a87a..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check pointer arguments. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -#include "ffitest.h" - -void* cls_pointer_fn(void* a1, void* a2) -{ - void* result = (void*)((intptr_t)a1 + (intptr_t)a2); - - printf("0x%08x 0x%08x: 0x%08x\n", - (unsigned int)(uintptr_t) a1, - (unsigned int)(uintptr_t) a2, - (unsigned int)(uintptr_t) result); - - return result; -} - -static void -cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - void* a1 = *(void**)(args[0]); - void* a2 = *(void**)(args[1]); - - *(void**)resp = cls_pointer_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[3]; - /* ffi_type cls_pointer_type; */ - ffi_type* arg_types[3]; - -/* cls_pointer_type.size = sizeof(void*); - cls_pointer_type.alignment = 0; - cls_pointer_type.type = FFI_TYPE_POINTER; - cls_pointer_type.elements = NULL;*/ - - void* arg1 = (void*)0x12345678; - void* arg2 = (void*)0x89abcdef; - ffi_arg res = 0; - - arg_types[0] = &ffi_type_pointer; - arg_types[1] = &ffi_type_pointer; - arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer, - arg_types) == FFI_OK); - - args[0] = &arg1; - args[1] = &arg2; - args[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_pointer_fn), &res, args); - /* { dg-output "0x12345678 0x89abcdef: 0x9be02467" } */ - printf("res: 0x%08x\n", (unsigned int) res); - /* { dg-output "\nres: 0x9be02467" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); - - res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2); - /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */ - printf("res: 0x%08x\n", (unsigned int) res); - /* { dg-output "\nres: 0x9be02467" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c deleted file mode 100644 index 1f1d915..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_pointer_stack.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check pointer arguments across multiple hideous stack frames. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/7/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -#include "ffitest.h" - -static long dummyVar; - -long dummy_func( - long double a1, char b1, - long double a2, char b2, - long double a3, char b3, - long double a4, char b4) -{ - return a1 + b1 + a2 + b2 + a3 + b3 + a4 + b4; -} - -void* cls_pointer_fn2(void* a1, void* a2) -{ - long double trample1 = (intptr_t)a1 + (intptr_t)a2; - char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0]; - long double trample3 = (intptr_t)trample1 + (intptr_t)a1; - char trample4 = trample2 + ((char*)&a1)[1]; - long double trample5 = (intptr_t)trample3 + (intptr_t)a2; - char trample6 = trample4 + ((char*)&a2)[1]; - long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; - char trample8 = trample6 + trample2; - void* result; - - dummyVar = dummy_func(trample1, trample2, trample3, trample4, - trample5, trample6, trample7, trample8); - - result = (void*)((intptr_t)a1 + (intptr_t)a2); - - printf("0x%08x 0x%08x: 0x%08x\n", - (unsigned int)(uintptr_t) a1, - (unsigned int)(uintptr_t) a2, - (unsigned int)(uintptr_t) result); - - return result; -} - -void* cls_pointer_fn1(void* a1, void* a2) -{ - long double trample1 = (intptr_t)a1 + (intptr_t)a2; - char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0]; - long double trample3 = (intptr_t)trample1 + (intptr_t)a1; - char trample4 = trample2 + ((char*)&a1)[1]; - long double trample5 = (intptr_t)trample3 + (intptr_t)a2; - char trample6 = trample4 + ((char*)&a2)[1]; - long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; - char trample8 = trample6 + trample2; - void* result; - - dummyVar = dummy_func(trample1, trample2, trample3, trample4, - trample5, trample6, trample7, trample8); - - result = (void*)((intptr_t)a1 + (intptr_t)a2); - - printf("0x%08x 0x%08x: 0x%08x\n", - (unsigned int)(intptr_t) a1, - (unsigned int)(intptr_t) a2, - (unsigned int)(intptr_t) result); - - result = cls_pointer_fn2(result, a1); - - return result; -} - -static void -cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - void* a1 = *(void**)(args[0]); - void* a2 = *(void**)(args[1]); - - long double trample1 = (intptr_t)a1 + (intptr_t)a2; - char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0]; - long double trample3 = (intptr_t)trample1 + (intptr_t)a1; - char trample4 = trample2 + ((char*)&a1)[1]; - long double trample5 = (intptr_t)trample3 + (intptr_t)a2; - char trample6 = trample4 + ((char*)&a2)[1]; - long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; - char trample8 = trample6 + trample2; - - dummyVar = dummy_func(trample1, trample2, trample3, trample4, - trample5, trample6, trample7, trample8); - - *(void**)resp = cls_pointer_fn1(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[3]; - /* ffi_type cls_pointer_type; */ - ffi_type* arg_types[3]; - -/* cls_pointer_type.size = sizeof(void*); - cls_pointer_type.alignment = 0; - cls_pointer_type.type = FFI_TYPE_POINTER; - cls_pointer_type.elements = NULL;*/ - - void* arg1 = (void*)0x01234567; - void* arg2 = (void*)0x89abcdef; - ffi_arg res = 0; - - arg_types[0] = &ffi_type_pointer; - arg_types[1] = &ffi_type_pointer; - arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer, - arg_types) == FFI_OK); - - args[0] = &arg1; - args[1] = &arg2; - args[2] = NULL; - - printf("\n"); - ffi_call(&cif, FFI_FN(cls_pointer_fn1), &res, args); - - printf("res: 0x%08x\n", (unsigned int) res); - /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ - /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ - /* { dg-output "\nres: 0x8bf258bd" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); - - res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2); - - printf("res: 0x%08x\n", (unsigned int) res); - /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ - /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ - /* { dg-output "\nres: 0x8bf258bd" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c deleted file mode 100644 index 82986b1..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_schar.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Area: closure_call - Purpose: Check return value schar. - Limitations: none. - PR: none. - Originator: 20031108 */ - - - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - *(ffi_arg*)resp = *(signed char *)args[0]; - printf("%d: %d\n",*(signed char *)args[0], - (int)*(ffi_arg *)(resp)); -} -typedef signed char (*cls_ret_schar)(signed char); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - signed char res; - - cl_arg_types[0] = &ffi_type_schar; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_schar, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_schar_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_schar)code))(127); - /* { dg-output "127: 127" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 127" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c deleted file mode 100644 index c7e13b7..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_sint.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Area: closure_call - Purpose: Check return value sint32. - Limitations: none. - PR: none. - Originator: 20031108 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - *(ffi_arg*)resp = *(signed int *)args[0]; - printf("%d: %d\n",*(signed int *)args[0], - (int)*(ffi_arg *)(resp)); -} -typedef signed int (*cls_ret_sint)(signed int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - signed int res; - - cl_arg_types[0] = &ffi_type_sint; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sint_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_sint)code))(65534); - /* { dg-output "65534: 65534" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 65534" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c deleted file mode 100644 index 846d57e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_sshort.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Area: closure_call - Purpose: Check return value sshort. - Limitations: none. - PR: none. - Originator: 20031108 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - *(ffi_arg*)resp = *(signed short *)args[0]; - printf("%d: %d\n",*(signed short *)args[0], - (int)*(ffi_arg *)(resp)); -} -typedef signed short (*cls_ret_sshort)(signed short); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - signed short res; - - cl_arg_types[0] = &ffi_type_sshort; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_sshort, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sshort_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_sshort)code))(255); - /* { dg-output "255: 255" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 255" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c deleted file mode 100644 index 6d1fdae..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_struct_va1.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test doubles passed in variable argument lists. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ -#include "ffitest.h" - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static void -test_fn (ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - int n = *(int*)args[0]; - struct small_tag s1 = * (struct small_tag *) args[1]; - struct large_tag l1 = * (struct large_tag *) args[2]; - struct small_tag s2 = * (struct small_tag *) args[3]; - - printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b, - l1.a, l1.b, l1.c, l1.d, l1.e, - s2.a, s2.b); - * (ffi_arg*) resp = 42; -} - -int -main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc (sizeof (ffi_closure), &code); - ffi_type* arg_types[5]; - - ffi_arg res = 0; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int si; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, - arg_types) == FFI_OK); - - si = 4; - s1.a = 5; - s1.b = 6; - - s2.a = 20; - s2.b = 21; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_fn, NULL, code) == FFI_OK); - - res = ((int (*)(int, ...))(code))(si, s1, l1, s2); - /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 42" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c deleted file mode 100644 index c1317e7..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Area: closure_call - Purpose: Check return value uchar. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - *(ffi_arg*)resp = *(unsigned char *)args[0]; - printf("%d: %d\n",*(unsigned char *)args[0], - (int)*(ffi_arg *)(resp)); -} -typedef unsigned char (*cls_ret_uchar)(unsigned char); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - unsigned char res; - - cl_arg_types[0] = &ffi_type_uchar; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_uchar, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uchar_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_uchar)code))(127); - /* { dg-output "127: 127" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 127" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c deleted file mode 100644 index 6491c5b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uchar_va.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned char argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef unsigned char T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_uchar; - cl_arg_types[1] = &ffi_type_uchar; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_uchar, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c deleted file mode 100644 index 885cff5..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Area: closure_call - Purpose: Check return value uint. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - *(ffi_arg *)resp = *(unsigned int *)args[0]; - - printf("%d: %d\n",*(unsigned int *)args[0], - (int)*(ffi_arg *)(resp)); -} -typedef unsigned int (*cls_ret_uint)(unsigned int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - unsigned int res; - - cl_arg_types[0] = &ffi_type_uint; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_uint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uint_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_uint)code))(2147483647); - /* { dg-output "2147483647: 2147483647" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 2147483647" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c deleted file mode 100644 index b04cfd1..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_uint_va.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned int argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef unsigned int T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_uint; - cl_arg_types[1] = &ffi_type_uint; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_uint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c deleted file mode 100644 index 0315082..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulong_va.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned long argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef unsigned long T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(T *)resp = *(T *)args[0]; - - printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_ulong; - cl_arg_types[1] = &ffi_type_ulong; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_ulong, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %ld\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c deleted file mode 100644 index 62f2cae..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ulonglong.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Area: closure_call - Purpose: Check return value long long. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ -#include "ffitest.h" - -static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - *(unsigned long long *)resp= 0xfffffffffffffffLL ^ *(unsigned long long *)args[0]; - - printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0], - *(unsigned long long *)(resp)); -} -typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - unsigned long long res; - - cl_arg_types[0] = &ffi_type_uint64; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_uint64, cl_arg_types) == FFI_OK); - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK); - res = (*((cls_ret_ulonglong)code))(214LL); - /* { dg-output "214: 1152921504606846761" } */ - printf("res: %" PRIdLL "\n", res); - /* { dg-output "\nres: 1152921504606846761" } */ - - res = (*((cls_ret_ulonglong)code))(9223372035854775808LL); - /* { dg-output "\n9223372035854775808: 8070450533247928831" } */ - printf("res: %" PRIdLL "\n", res); - /* { dg-output "\nres: 8070450533247928831" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c deleted file mode 100644 index a00100e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Area: closure_call - Purpose: Check return value ushort. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - *(ffi_arg*)resp = *(unsigned short *)args[0]; - - printf("%d: %d\n",*(unsigned short *)args[0], - (int)*(ffi_arg *)(resp)); -} -typedef unsigned short (*cls_ret_ushort)(unsigned short); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - unsigned short res; - - cl_arg_types[0] = &ffi_type_ushort; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_ushort, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ushort_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_ushort)code))(65535); - /* { dg-output "65535: 65535" } */ - printf("res: %d\n",res); - /* { dg-output "\nres: 65535" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c deleted file mode 100644 index 37aa106..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/cls_ushort_va.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned short argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef unsigned short T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_ushort; - cl_arg_types[1] = &ffi_type_ushort; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_ushort, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c b/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c deleted file mode 100644 index f5a7317..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_abi.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Area: ffi_prep_cif, ffi_prep_closure - Purpose: Test error return for bad ABIs. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static void -dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, - void** args __UNUSED__, void* userdata __UNUSED__) -{} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type* arg_types[1]; - - arg_types[0] = NULL; - - CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void, - arg_types) == FFI_BAD_ABI); - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void, - arg_types) == FFI_OK); - - cif.abi= 255; - - CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c b/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c deleted file mode 100644 index bf60161..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/err_bad_typedef.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Area: ffi_prep_cif - Purpose: Test error return for bad typedefs. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -int main (void) -{ - ffi_cif cif; - ffi_type* arg_types[1]; - - ffi_type badType = ffi_type_void; - - arg_types[0] = NULL; - - badType.size = 0; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType, - arg_types) == FFI_BAD_TYPEDEF); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h b/user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h deleted file mode 100644 index 15d5e44..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/ffitest.h +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include -#include "fficonfig.h" - -#if defined HAVE_STDINT_H -#include -#endif - -#if defined HAVE_INTTYPES_H -#include -#endif - -#define MAX_ARGS 256 - -#define CHECK(x) (void)(!(x) ? (abort(), 1) : 0) - -/* Define macros so that compilers other than gcc can run the tests. */ -#undef __UNUSED__ -#if defined(__GNUC__) -#define __UNUSED__ __attribute__((__unused__)) -#define __STDCALL__ __attribute__((stdcall)) -#define __THISCALL__ __attribute__((thiscall)) -#define __FASTCALL__ __attribute__((fastcall)) -#else -#define __UNUSED__ -#define __STDCALL__ __stdcall -#define __THISCALL__ __thiscall -#define __FASTCALL__ __fastcall -#endif - -#ifndef ABI_NUM -#define ABI_NUM FFI_DEFAULT_ABI -#define ABI_ATTR -#endif - -/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a - file open. */ -#ifdef HAVE_MMAP_ANON -# undef HAVE_MMAP_DEV_ZERO - -# include -# ifndef MAP_FAILED -# define MAP_FAILED -1 -# endif -# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) -# define MAP_ANONYMOUS MAP_ANON -# endif -# define USING_MMAP - -#endif - -#ifdef HAVE_MMAP_DEV_ZERO - -# include -# ifndef MAP_FAILED -# define MAP_FAILED -1 -# endif -# define USING_MMAP - -#endif - -/* MinGW kludge. */ -#ifdef _WIN64 -#define PRIdLL "I64d" -#define PRIuLL "I64u" -#else -#define PRIdLL "lld" -#define PRIuLL "llu" -#endif - -/* Tru64 UNIX kludge. */ -#if defined(__alpha__) && defined(__osf__) -/* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit. */ -#undef PRIdLL -#define PRIdLL "ld" -#undef PRIuLL -#define PRIuLL "lu" -#define PRId8 "hd" -#define PRIu8 "hu" -#define PRId64 "ld" -#define PRIu64 "lu" -#define PRIuPTR "lu" -#endif - -/* PA HP-UX kludge. */ -#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR) -#define PRIuPTR "lu" -#endif - -/* IRIX kludge. */ -#if defined(__sgi) -/* IRIX 6.5 provides all definitions, but only for C99 - compilations. */ -#define PRId8 "hhd" -#define PRIu8 "hhu" -#if (_MIPS_SZLONG == 32) -#define PRId64 "lld" -#define PRIu64 "llu" -#endif -/* This doesn't match , which always has "lld" here, but the - arguments are uint64_t, int64_t, which are unsigned long, long for - 64-bit in . */ -#if (_MIPS_SZLONG == 64) -#define PRId64 "ld" -#define PRIu64 "lu" -#endif -/* This doesn't match , which has "u" here, but the arguments - are uintptr_t, which is always unsigned long. */ -#define PRIuPTR "lu" -#endif - -/* Solaris < 10 kludge. */ -#if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR) -#if defined(__arch64__) || defined (__x86_64__) -#define PRIuPTR "lu" -#else -#define PRIuPTR "u" -#endif -#endif - -/* MSVC kludge. */ -#if defined _MSC_VER -#define PRIuPTR "lu" -#define PRIu8 "u" -#define PRId8 "d" -#define PRIu64 "I64u" -#define PRId64 "I64d" -#endif - -#ifndef PRIuPTR -#define PRIuPTR "u" -#endif diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float.c b/user/mpy/lib/libffi/testsuite/libffi.call/float.c deleted file mode 100644 index fbc272d..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/float.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value float. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static int floating(int a, float b, double c, long double d) -{ - int i; - - i = (int) ((float)a/b + ((float)c/(float)d)); - - return i; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - - float f; - signed int si1; - double d; - long double ld; - - args[0] = &ffi_type_sint; - values[0] = &si1; - args[1] = &ffi_type_float; - values[1] = &f; - args[2] = &ffi_type_double; - values[2] = &d; - args[3] = &ffi_type_longdouble; - values[3] = &ld; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_sint, args) == FFI_OK); - - si1 = 6; - f = 3.14159; - d = (double)1.0/(double)3.0; - ld = 2.71828182846L; - - floating (si1, f, d, ld); - - ffi_call(&cif, FFI_FN(floating), &rint, values); - - printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld)); - - CHECK((int)rint == floating(si1, f, d, ld)); - - exit (0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float1.c b/user/mpy/lib/libffi/testsuite/libffi.call/float1.c deleted file mode 100644 index c48493c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/float1.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value double. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -#include "float.h" - -#include - -typedef union -{ - double d; - unsigned char c[sizeof (double)]; -} value_type; - -#define CANARY 0xba - -static double dblit(float f) -{ - return f/3.0; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - float f; - value_type result[2]; - unsigned int i; - - args[0] = &ffi_type_float; - values[0] = &f; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_double, args) == FFI_OK); - - f = 3.14159; - - /* Put a canary in the return array. This is a regression test for - a buffer overrun. */ - memset(result[1].c, CANARY, sizeof (double)); - - ffi_call(&cif, FFI_FN(dblit), &result[0].d, values); - - /* These are not always the same!! Check for a reasonable delta */ - - CHECK(fabs(result[0].d - dblit(f)) < DBL_EPSILON); - - /* Check the canary. */ - for (i = 0; i < sizeof (double); ++i) - CHECK(result[1].c[i] == CANARY); - - exit(0); - -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float2.c b/user/mpy/lib/libffi/testsuite/libffi.call/float2.c deleted file mode 100644 index 20a8c40..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/float2.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value long double. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ -/* { dg-do run } */ - -#include "ffitest.h" -#include "float.h" - -#include - -static long double ldblit(float f) -{ - return (long double) (((long double) f)/ (long double) 3.0); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - float f; - long double ld; - - args[0] = &ffi_type_float; - values[0] = &f; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_longdouble, args) == FFI_OK); - - f = 3.14159; - -#if 1 - /* This is ifdef'd out for now. long double support under SunOS/gcc - is pretty much non-existent. You'll get the odd bus error in library - routines like printf(). */ - printf ("%Lf\n", ldblit(f)); -#endif - ld = 666; - ffi_call(&cif, FFI_FN(ldblit), &ld, values); - -#if 1 - /* This is ifdef'd out for now. long double support under SunOS/gcc - is pretty much non-existent. You'll get the odd bus error in library - routines like printf(). */ - printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON); -#endif - - /* These are not always the same!! Check for a reasonable delta */ - if (fabsl(ld - ldblit(f)) < LDBL_EPSILON) - puts("long double return value tests ok!"); - else - CHECK(0); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float3.c b/user/mpy/lib/libffi/testsuite/libffi.call/float3.c deleted file mode 100644 index bab3206..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/float3.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Area: ffi_call - Purpose: Check float arguments with different orders. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ - -#include "ffitest.h" -#include "float.h" - -#include - -static double floating_1(float a, double b, long double c) -{ - return (double) a + b + (double) c; -} - -static double floating_2(long double a, double b, float c) -{ - return (double) a + b + (double) c; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - double rd; - - float f; - double d; - long double ld; - - args[0] = &ffi_type_float; - values[0] = &f; - args[1] = &ffi_type_double; - values[1] = &d; - args[2] = &ffi_type_longdouble; - values[2] = &ld; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &ffi_type_double, args) == FFI_OK); - - f = 3.14159; - d = (double)1.0/(double)3.0; - ld = 2.71828182846L; - - floating_1 (f, d, ld); - - ffi_call(&cif, FFI_FN(floating_1), &rd, values); - - CHECK(fabs(rd - floating_1(f, d, ld)) < DBL_EPSILON); - - args[0] = &ffi_type_longdouble; - values[0] = &ld; - args[1] = &ffi_type_double; - values[1] = &d; - args[2] = &ffi_type_float; - values[2] = &f; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &ffi_type_double, args) == FFI_OK); - - floating_2 (ld, d, f); - - ffi_call(&cif, FFI_FN(floating_2), &rd, values); - - CHECK(fabs(rd - floating_2(ld, d, f)) < DBL_EPSILON); - - exit (0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float4.c b/user/mpy/lib/libffi/testsuite/libffi.call/float4.c deleted file mode 100644 index 0dd6d85..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/float4.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Area: ffi_call - Purpose: Check denorm double value. - Limitations: none. - PR: PR26483. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -/* { dg-options "-mieee" { target alpha*-*-* } } */ - -#include "ffitest.h" -#include "float.h" - -typedef union -{ - double d; - unsigned char c[sizeof (double)]; -} value_type; - -#define CANARY 0xba - -static double dblit(double d) -{ - return d; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - double d; - value_type result[2]; - unsigned int i; - - args[0] = &ffi_type_double; - values[0] = &d; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_double, args) == FFI_OK); - - d = DBL_MIN / 2; - - /* Put a canary in the return array. This is a regression test for - a buffer overrun. */ - memset(result[1].c, CANARY, sizeof (double)); - - ffi_call(&cif, FFI_FN(dblit), &result[0].d, values); - - /* The standard delta check doesn't work for denorms. Since we didn't do - any arithmetic, we should get the original result back, and hence an - exact check should be OK here. */ - - CHECK(result[0].d == dblit(d)); - - /* Check the canary. */ - for (i = 0; i < sizeof (double); ++i) - CHECK(result[1].c[i] == CANARY); - - exit(0); - -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/float_va.c b/user/mpy/lib/libffi/testsuite/libffi.call/float_va.c deleted file mode 100644 index 5acff91..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/float_va.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Area: fp and variadics - Purpose: check fp inputs and returns work on variadics, even the fixed params - Limitations: None - PR: none - Originator: 2011-01-25 - - Intended to stress the difference in ABI on ARM vfp -*/ - -/* { dg-do run } */ - -#include - -#include "ffitest.h" - -/* prints out all the parameters, and returns the sum of them all. - * 'x' is the number of variadic parameters all of which are double in this test - */ -double float_va_fn(unsigned int x, double y,...) -{ - double total=0.0; - va_list ap; - unsigned int i; - - total+=(double)x; - total+=y; - - printf("%u: %.1f :", x, y); - - va_start(ap, y); - for(i=0;i -#include -#include - -static float ABI_ATTR many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13) -{ -#if 0 - printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n", - (double) f1, (double) f2, (double) f3, (double) f4, (double) f5, - (double) f6, (double) f7, (double) f8, (double) f9, (double) f10, - (double) f11, (double) f12, (double) f13); -#endif - - return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[13]; - void *values[13]; - float fa[13]; - float f, ff; - int i; - - for (i = 0; i < 13; i++) - { - args[i] = &ffi_type_float; - values[i] = &fa[i]; - fa[i] = (float) i; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 13, - &ffi_type_float, args) == FFI_OK); - - ffi_call(&cif, FFI_FN(many), &f, values); - - ff = many(fa[0], fa[1], - fa[2], fa[3], - fa[4], fa[5], - fa[6], fa[7], - fa[8], fa[9], - fa[10],fa[11],fa[12]); - - if (fabs(f - ff) < FLT_EPSILON) - exit(0); - else - abort(); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/many2.c b/user/mpy/lib/libffi/testsuite/libffi.call/many2.c deleted file mode 100644 index 1c85746..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/many2.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Area: ffi_call - Purpose: Check uint8_t arguments. - Limitations: none. - PR: PR45677. - Originator: Dan Witte 20100916 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -#define NARGS 7 - -typedef unsigned char u8; - -#ifdef __GNUC__ -__attribute__((noinline)) -#endif -uint8_t -foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d, - uint8_t e, uint8_t f, uint8_t g) -{ - return a + b + c + d + e + f + g; -} - -uint8_t ABI_ATTR -bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d, - uint8_t e, uint8_t f, uint8_t g) -{ - return foo (a, b, c, d, e, f, g); -} - -int -main (void) -{ - ffi_type *ffitypes[NARGS]; - int i; - ffi_cif cif; - ffi_arg result = 0; - uint8_t args[NARGS]; - void *argptrs[NARGS]; - - for (i = 0; i < NARGS; ++i) - ffitypes[i] = &ffi_type_uint8; - - CHECK (ffi_prep_cif (&cif, ABI_NUM, NARGS, - &ffi_type_uint8, ffitypes) == FFI_OK); - - for (i = 0; i < NARGS; ++i) - { - args[i] = i; - argptrs[i] = &args[i]; - } - ffi_call (&cif, FFI_FN (bar), &result, argptrs); - - CHECK (result == 21); - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/many_double.c b/user/mpy/lib/libffi/testsuite/libffi.call/many_double.c deleted file mode 100644 index 4ef8c8a..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/many_double.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value double, with many arguments - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -#include -#include -#include - -static double many(double f1, - double f2, - double f3, - double f4, - double f5, - double f6, - double f7, - double f8, - double f9, - double f10, - double f11, - double f12, - double f13) -{ -#if 0 - printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n", - (double) f1, (double) f2, (double) f3, (double) f4, (double) f5, - (double) f6, (double) f7, (double) f8, (double) f9, (double) f10, - (double) f11, (double) f12, (double) f13); -#endif - - return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[13]; - void *values[13]; - double fa[13]; - double f, ff; - int i; - - for (i = 0; i < 13; i++) - { - args[i] = &ffi_type_double; - values[i] = &fa[i]; - fa[i] = (double) i; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, - &ffi_type_double, args) == FFI_OK); - - ffi_call(&cif, FFI_FN(many), &f, values); - - ff = many(fa[0], fa[1], - fa[2], fa[3], - fa[4], fa[5], - fa[6], fa[7], - fa[8], fa[9], - fa[10],fa[11],fa[12]); - if (fabs(f - ff) < FLT_EPSILON) - exit(0); - else - abort(); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c b/user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c deleted file mode 100644 index 85ec36e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/many_mixed.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value double, with many arguments - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -#include -#include -#include - -static double many(double f1, - double f2, - long int i1, - double f3, - double f4, - long int i2, - double f5, - double f6, - long int i3, - double f7, - double f8, - long int i4, - double f9, - double f10, - long int i5, - double f11, - double f12, - long int i6, - double f13) -{ - return ((double) (i1 + i2 + i3 + i4 + i5 + i6) + (f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[19]; - void *values[19]; - double fa[19]; - long int la[19]; - double f, ff; - int i; - - for (i = 0; i < 19; i++) - { - if( (i - 2) % 3 == 0) { - args[i] = &ffi_type_slong; - la[i] = (long int) i; - values[i] = &la[i]; - } - else { - args[i] = &ffi_type_double; - fa[i] = (double) i; - values[i] = &fa[i]; - } - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 19, - &ffi_type_double, args) == FFI_OK); - - ffi_call(&cif, FFI_FN(many), &f, values); - - ff = many(fa[0], fa[1], la[2], - fa[3], fa[4], la[5], - fa[6], fa[7], la[8], - fa[9], fa[10], la[11], - fa[12], fa[13], la[14], - fa[15], fa[16], la[17], - fa[18]); - if (fabs(f - ff) < FLT_EPSILON) - exit(0); - else - abort(); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/negint.c b/user/mpy/lib/libffi/testsuite/libffi.call/negint.c deleted file mode 100644 index 6e2f26f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/negint.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Area: ffi_call - Purpose: Check that negative integers are passed correctly. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static int checking(int a, short b, signed char c) -{ - - return (a < 0 && b < 0 && c < 0); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - - signed int si; - signed short ss; - signed char sc; - - args[0] = &ffi_type_sint; - values[0] = &si; - args[1] = &ffi_type_sshort; - values[1] = &ss; - args[2] = &ffi_type_schar; - values[2] = ≻ - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &ffi_type_sint, args) == FFI_OK); - - si = -6; - ss = -12; - sc = -1; - - checking (si, ss, sc); - - ffi_call(&cif, FFI_FN(checking), &rint, values); - - printf ("%d vs %d\n", (int)rint, checking (si, ss, sc)); - - CHECK(rint != 0); - - exit (0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c deleted file mode 100644 index c15e3a0..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_16byte1 { - double a; - float b; - int c; -} cls_struct_16byte1; - -typedef struct cls_struct_16byte2 { - int ii; - double dd; - float ff; -} cls_struct_16byte2; - -typedef struct cls_struct_combined { - cls_struct_16byte1 d; - cls_struct_16byte2 e; -} cls_struct_combined; - -cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, - struct cls_struct_16byte2 b1, - struct cls_struct_combined b2) -{ - struct cls_struct_combined result; - - result.d.a = b0.a + b1.dd + b2.d.a; - result.d.b = b0.b + b1.ff + b2.d.b; - result.d.c = b0.c + b1.ii + b2.d.c; - result.e.ii = b0.c + b1.ii + b2.e.ii; - result.e.dd = b0.a + b1.dd + b2.e.dd; - result.e.ff = b0.b + b1.ff + b2.e.ff; - - printf("%g %g %d %d %g %g %g %g %d %d %g %g: %g %g %d %d %g %g\n", - b0.a, b0.b, b0.c, - b1.ii, b1.dd, b1.ff, - b2.d.a, b2.d.b, b2.d.c, - b2.e.ii, b2.e.dd, b2.e.ff, - result.d.a, result.d.b, result.d.c, - result.e.ii, result.e.dd, result.e.ff); - - return result; -} - -static void -cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_16byte1 b0; - struct cls_struct_16byte2 b1; - struct cls_struct_combined b2; - - b0 = *(struct cls_struct_16byte1*)(args[0]); - b1 = *(struct cls_struct_16byte2*)(args[1]); - b2 = *(struct cls_struct_combined*)(args[2]); - - - *(cls_struct_combined*)resp = cls_struct_combined_fn(b0, b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[5]; - ffi_type* cls_struct_fields1[5]; - ffi_type* cls_struct_fields2[5]; - ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; - struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; - struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, - {3, 1.0, 8.0}}; - struct cls_struct_combined res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_type2.size = 0; - cls_struct_type2.alignment = 0; - cls_struct_type2.type = FFI_TYPE_STRUCT; - cls_struct_type2.elements = cls_struct_fields2; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_float; - cls_struct_fields[2] = &ffi_type_sint; - cls_struct_fields[3] = NULL; - - cls_struct_fields1[0] = &ffi_type_sint; - cls_struct_fields1[1] = &ffi_type_double; - cls_struct_fields1[2] = &ffi_type_float; - cls_struct_fields1[3] = NULL; - - cls_struct_fields2[0] = &cls_struct_type; - cls_struct_fields2[1] = &cls_struct_type1; - cls_struct_fields2[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = &cls_struct_type2; - dbl_arg_types[3] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type2, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl); - /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); - CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); - CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1, - cls_struct_16byte2, - cls_struct_combined)) - (code))(e_dbl, f_dbl, g_dbl); - /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); - CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); - CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c deleted file mode 100644 index 477a6b9..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct1.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_16byte1 { - double a; - float b; - int c; -} cls_struct_16byte1; - -typedef struct cls_struct_16byte2 { - int ii; - double dd; - float ff; -} cls_struct_16byte2; - -typedef struct cls_struct_combined { - cls_struct_16byte1 d; - cls_struct_16byte2 e; -} cls_struct_combined; - -cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, - struct cls_struct_16byte2 b1, - struct cls_struct_combined b2, - struct cls_struct_16byte1 b3) -{ - struct cls_struct_combined result; - - result.d.a = b0.a + b1.dd + b2.d.a; - result.d.b = b0.b + b1.ff + b2.d.b; - result.d.c = b0.c + b1.ii + b2.d.c; - result.e.ii = b0.c + b1.ii + b2.e.ii; - result.e.dd = b0.a + b1.dd + b2.e.dd; - result.e.ff = b0.b + b1.ff + b2.e.ff; - - printf("%g %g %d %d %g %g %g %g %d %d %g %g %g %g %d: %g %g %d %d %g %g\n", - b0.a, b0.b, b0.c, - b1.ii, b1.dd, b1.ff, - b2.d.a, b2.d.b, b2.d.c, - b2.e.ii, b2.e.dd, b2.e.ff, - b3.a, b3.b, b3.c, - result.d.a, result.d.b, result.d.c, - result.e.ii, result.e.dd, result.e.ff); - - return result; -} - -static void -cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct cls_struct_16byte1 b0; - struct cls_struct_16byte2 b1; - struct cls_struct_combined b2; - struct cls_struct_16byte1 b3; - - b0 = *(struct cls_struct_16byte1*)(args[0]); - b1 = *(struct cls_struct_16byte2*)(args[1]); - b2 = *(struct cls_struct_combined*)(args[2]); - b3 = *(struct cls_struct_16byte1*)(args[3]); - - - *(cls_struct_combined*)resp = cls_struct_combined_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[5]; - ffi_type* cls_struct_fields1[5]; - ffi_type* cls_struct_fields2[5]; - ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; - struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; - struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, - {3, 1.0, 8.0}}; - struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4}; - struct cls_struct_combined res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_type2.size = 0; - cls_struct_type2.alignment = 0; - cls_struct_type2.type = FFI_TYPE_STRUCT; - cls_struct_type2.elements = cls_struct_fields2; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_float; - cls_struct_fields[2] = &ffi_type_sint; - cls_struct_fields[3] = NULL; - - cls_struct_fields1[0] = &ffi_type_sint; - cls_struct_fields1[1] = &ffi_type_double; - cls_struct_fields1[2] = &ffi_type_float; - cls_struct_fields1[3] = NULL; - - cls_struct_fields2[0] = &cls_struct_type; - cls_struct_fields2[1] = &cls_struct_type1; - cls_struct_fields2[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = &cls_struct_type2; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type2, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl); - /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); - CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); - CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); - - res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1, - cls_struct_16byte2, - cls_struct_combined, - cls_struct_16byte1)) - (code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); - CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); - CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); - /* CHECK( 1 == 0); */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c deleted file mode 100644 index 34a74e7..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct10.c +++ /dev/null @@ -1,133 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - unsigned long long a; - unsigned char b; -} A; - -typedef struct B { - unsigned char y; - struct A x; - unsigned int z; -} B; - -typedef struct C { - unsigned long long d; - unsigned char e; -} C; - -static B B_fn(struct A b2, struct B b3, struct C b4) -{ - struct B result; - - result.x.a = b2.a + b3.x.a + b3.z + b4.d; - result.x.b = b2.b + b3.x.b + b3.y + b4.e; - result.y = b2.b + b3.x.b + b4.e; - - printf("%d %d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, - (int)b3.x.a, b3.x.b, b3.y, b3.z, (int)b4.d, b4.e, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - struct C b2; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - b2 = *(struct C*)(args[2]); - - *(B*)resp = B_fn(b0, b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[4]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[4]; - ffi_type* cls_struct_fields2[3]; - ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; - ffi_type* dbl_arg_types[4]; - - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = { 99, {12LL , 127}, 255}; - struct C g_dbl = { 2LL, 9}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_type2.size = 0; - cls_struct_type2.alignment = 0; - cls_struct_type2.type = FFI_TYPE_STRUCT; - cls_struct_type2.elements = cls_struct_fields2; - - cls_struct_fields[0] = &ffi_type_uint64; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &ffi_type_uchar; - cls_struct_fields1[1] = &cls_struct_type; - cls_struct_fields1[2] = &ffi_type_uint; - cls_struct_fields1[3] = NULL; - - cls_struct_fields2[0] = &ffi_type_uint64; - cls_struct_fields2[1] = &ffi_type_uchar; - cls_struct_fields2[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = &cls_struct_type2; - dbl_arg_types[3] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99 255 2 9: 270 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); - /* { dg-output "\n1 7 12 127 99 255 2 9: 270 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c deleted file mode 100644 index 3510493..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct11.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check parameter passing with nested structs - of a single type. This tests the special cases - for homogeneous floating-point aggregates in the - AArch64 PCS. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - float a_x; - float a_y; -} A; - -typedef struct B { - float b_x; - float b_y; -} B; - -typedef struct C { - A a; - B b; -} C; - -static C C_fn (int x, int y, int z, C source, int i, int j, int k) -{ - C result; - result.a.a_x = source.a.a_x; - result.a.a_y = source.a.a_y; - result.b.b_x = source.b.b_x; - result.b.b_y = source.b.b_y; - - printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k); - - printf ("%.1f, %.1f, %.1f, %.1f, " - "%.1f, %.1f, %.1f, %.1f\n", - source.a.a_x, source.a.a_y, - source.b.b_x, source.b.b_y, - result.a.a_x, result.a.a_y, - result.b.b_x, result.b.b_y); - - return result; -} - -int main (void) -{ - ffi_cif cif; - - ffi_type* struct_fields_source_a[3]; - ffi_type* struct_fields_source_b[3]; - ffi_type* struct_fields_source_c[3]; - ffi_type* arg_types[8]; - - ffi_type struct_type_a, struct_type_b, struct_type_c; - - struct A source_fld_a = {1.0, 2.0}; - struct B source_fld_b = {4.0, 8.0}; - int k = 1; - - struct C result; - struct C source = {source_fld_a, source_fld_b}; - - struct_type_a.size = 0; - struct_type_a.alignment = 0; - struct_type_a.type = FFI_TYPE_STRUCT; - struct_type_a.elements = struct_fields_source_a; - - struct_type_b.size = 0; - struct_type_b.alignment = 0; - struct_type_b.type = FFI_TYPE_STRUCT; - struct_type_b.elements = struct_fields_source_b; - - struct_type_c.size = 0; - struct_type_c.alignment = 0; - struct_type_c.type = FFI_TYPE_STRUCT; - struct_type_c.elements = struct_fields_source_c; - - struct_fields_source_a[0] = &ffi_type_float; - struct_fields_source_a[1] = &ffi_type_float; - struct_fields_source_a[2] = NULL; - - struct_fields_source_b[0] = &ffi_type_float; - struct_fields_source_b[1] = &ffi_type_float; - struct_fields_source_b[2] = NULL; - - struct_fields_source_c[0] = &struct_type_a; - struct_fields_source_c[1] = &struct_type_b; - struct_fields_source_c[2] = NULL; - - arg_types[0] = &ffi_type_sint32; - arg_types[1] = &ffi_type_sint32; - arg_types[2] = &ffi_type_sint32; - arg_types[3] = &struct_type_c; - arg_types[4] = &ffi_type_sint32; - arg_types[5] = &ffi_type_sint32; - arg_types[6] = &ffi_type_sint32; - arg_types[7] = NULL; - - void *args[7]; - args[0] = &k; - args[1] = &k; - args[2] = &k; - args[3] = &source; - args[4] = &k; - args[5] = &k; - args[6] = &k; - CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, 7, &struct_type_c, - arg_types) == FFI_OK); - - ffi_call (&cif, FFI_FN (C_fn), &result, args); - /* { dg-output "1, 1, 1, 1, 1, 1\n" } */ - /* { dg-output "1.0, 2.0, 4.0, 8.0, 1.0, 2.0, 4.0, 8.0" } */ - CHECK (result.a.a_x == source.a.a_x); - CHECK (result.a.a_y == source.a.a_y); - CHECK (result.b.b_x == source.b.b_x); - CHECK (result.b.b_y == source.b.b_y); - exit (0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c deleted file mode 100644 index 69268cd..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct2.c +++ /dev/null @@ -1,110 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20030911 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - unsigned long a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -B B_fn(struct A b0, struct B b1) -{ - struct B result; - - result.x.a = b0.a + b1.x.a; - result.x.b = b0.b + b1.x.b + b1.y; - result.y = b0.b + b1.x.b; - - printf("%lu %d %lu %d %d: %lu %d %d\n", b0.a, b0.b, b1.x.a, b1.x.b, b1.y, - result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - - *(B*)resp = B_fn(b0, b1); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type cls_struct_type, cls_struct_type1; - ffi_type* dbl_arg_types[3]; - - struct A e_dbl = { 1, 7}; - struct B f_dbl = {{12 , 127}, 99}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_fields[0] = &ffi_type_ulong; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); - /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c deleted file mode 100644 index ab18cad..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct3.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20030911 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - unsigned long long a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -B B_fn(struct A b0, struct B b1) -{ - struct B result; - - result.x.a = b0.a + b1.x.a; - result.x.b = b0.b + b1.x.b + b1.y; - result.y = b0.b + b1.x.b; - - printf("%d %d %d %d %d: %d %d %d\n", (int)b0.a, b0.b, - (int)b1.x.a, b1.x.b, b1.y, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - - *(B*)resp = B_fn(b0, b1); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type cls_struct_type, cls_struct_type1; - ffi_type* dbl_arg_types[3]; - - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12LL , 127}, 99}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_fields[0] = &ffi_type_uint64; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); - /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c deleted file mode 100644 index 2ffb4d6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct4.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: PR 25630. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - double a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -static B B_fn(struct A b2, struct B b3) -{ - struct B result; - - result.x.a = b2.a + b3.x.a; - result.x.b = b2.b + b3.x.b + b3.y; - result.y = b2.b + b3.x.b; - - printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, - (int)b3.x.a, b3.x.b, b3.y, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - - *(B*)resp = B_fn(b0, b1); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type cls_struct_type, cls_struct_type1; - ffi_type* dbl_arg_types[3]; - - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); - /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c deleted file mode 100644 index 6c79845..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct5.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - long double a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -static B B_fn(struct A b2, struct B b3) -{ - struct B result; - - result.x.a = b2.a + b3.x.a; - result.x.b = b2.b + b3.x.b + b3.y; - result.y = b2.b + b3.x.b; - - printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, - (int)b3.x.a, b3.x.b, b3.y, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - - *(B*)resp = B_fn(b0, b1); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type cls_struct_type, cls_struct_type1; - ffi_type* dbl_arg_types[3]; - - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_fields[0] = &ffi_type_longdouble; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); - /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c deleted file mode 100644 index 59d3579..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct6.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: PR 25630. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - double a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -typedef struct C { - long d; - unsigned char e; -} C; - -static B B_fn(struct A b2, struct B b3, struct C b4) -{ - struct B result; - - result.x.a = b2.a + b3.x.a + b4.d; - result.x.b = b2.b + b3.x.b + b3.y + b4.e; - result.y = b2.b + b3.x.b + b4.e; - - printf("%d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, - (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - struct C b2; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - b2 = *(struct C*)(args[2]); - - *(B*)resp = B_fn(b0, b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[4]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type* cls_struct_fields2[3]; - ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; - ffi_type* dbl_arg_types[4]; - - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - struct C g_dbl = { 2, 9}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_type2.size = 0; - cls_struct_type2.alignment = 0; - cls_struct_type2.type = FFI_TYPE_STRUCT; - cls_struct_type2.elements = cls_struct_fields2; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - cls_struct_fields2[0] = &ffi_type_slong; - cls_struct_fields2[1] = &ffi_type_uchar; - cls_struct_fields2[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = &cls_struct_type2; - dbl_arg_types[3] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); - /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c deleted file mode 100644 index 27595e6..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct7.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - unsigned long long a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -static B B_fn(struct A b2, struct B b3) -{ - struct B result; - - result.x.a = b2.a + b3.x.a; - result.x.b = b2.b + b3.x.b + b3.y; - result.y = b2.b + b3.x.b; - - printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, - (int)b3.x.a, b3.x.b, b3.y, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - - *(B*)resp = B_fn(b0, b1); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[3]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type cls_struct_type, cls_struct_type1; - ffi_type* dbl_arg_types[3]; - - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_fields[0] = &ffi_type_uint64; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl); - /* { dg-output "\n1 7 12 127 99: 13 233 134" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c deleted file mode 100644 index 0e6c682..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct8.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - unsigned long long a; - unsigned char b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -typedef struct C { - unsigned long long d; - unsigned char e; -} C; - -static B B_fn(struct A b2, struct B b3, struct C b4) -{ - struct B result; - - result.x.a = b2.a + b3.x.a + b4.d; - result.x.b = b2.b + b3.x.b + b3.y + b4.e; - result.y = b2.b + b3.x.b + b4.e; - - printf("%d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b, - (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, - (int)result.x.a, result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - struct C b2; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - b2 = *(struct C*)(args[2]); - - *(B*)resp = B_fn(b0, b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[4]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type* cls_struct_fields2[3]; - ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; - ffi_type* dbl_arg_types[4]; - - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12LL , 127}, 99}; - struct C g_dbl = { 2LL, 9}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_type2.size = 0; - cls_struct_type2.alignment = 0; - cls_struct_type2.type = FFI_TYPE_STRUCT; - cls_struct_type2.elements = cls_struct_fields2; - - cls_struct_fields[0] = &ffi_type_uint64; - cls_struct_fields[1] = &ffi_type_uchar; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - cls_struct_fields2[0] = &ffi_type_uint64; - cls_struct_fields2[1] = &ffi_type_uchar; - cls_struct_fields2[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = &cls_struct_type2; - dbl_arg_types[3] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); - /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c b/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c deleted file mode 100644 index 5f7ac67..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/nested_struct9.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Contains structs as parameter of the struct itself. - Sample taken from Alan Modras patch to src/prep_cif.c. - Limitations: none. - PR: none. - Originator: 20051010 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - unsigned char a; - unsigned long long b; -} A; - -typedef struct B { - struct A x; - unsigned char y; -} B; - -typedef struct C { - unsigned long d; - unsigned char e; -} C; - -static B B_fn(struct A b2, struct B b3, struct C b4) -{ - struct B result; - - result.x.a = b2.a + b3.x.a + b4.d; - result.x.b = b2.b + b3.x.b + b3.y + b4.e; - result.y = b2.b + b3.x.b + b4.e; - - printf("%d %d %d %d %d %d %d: %d %d %d\n", b2.a, (int)b2.b, - b3.x.a, (int)b3.x.b, b3.y, (int)b4.d, b4.e, - result.x.a, (int)result.x.b, result.y); - - return result; -} - -static void -B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct A b0; - struct B b1; - struct C b2; - - b0 = *(struct A*)(args[0]); - b1 = *(struct B*)(args[1]); - b2 = *(struct C*)(args[2]); - - *(B*)resp = B_fn(b0, b1, b2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[4]; - ffi_type* cls_struct_fields[3]; - ffi_type* cls_struct_fields1[3]; - ffi_type* cls_struct_fields2[3]; - ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; - ffi_type* dbl_arg_types[4]; - - struct A e_dbl = { 1, 7LL}; - struct B f_dbl = {{12.0 , 127}, 99}; - struct C g_dbl = { 2, 9}; - - struct B res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_type1.size = 0; - cls_struct_type1.alignment = 0; - cls_struct_type1.type = FFI_TYPE_STRUCT; - cls_struct_type1.elements = cls_struct_fields1; - - cls_struct_type2.size = 0; - cls_struct_type2.alignment = 0; - cls_struct_type2.type = FFI_TYPE_STRUCT; - cls_struct_type2.elements = cls_struct_fields2; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &ffi_type_uint64; - cls_struct_fields[2] = NULL; - - cls_struct_fields1[0] = &cls_struct_type; - cls_struct_fields1[1] = &ffi_type_uchar; - cls_struct_fields1[2] = NULL; - - cls_struct_fields2[0] = &ffi_type_ulong; - cls_struct_fields2[1] = &ffi_type_uchar; - cls_struct_fields2[2] = NULL; - - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type1; - dbl_arg_types[2] = &cls_struct_type2; - dbl_arg_types[3] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = NULL; - - ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); - /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); - - res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl); - /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */ - CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d)); - CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e)); - CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c b/user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c deleted file mode 100644 index 7da1621..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/pr1172638.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Area: ffi_call - Purpose: Reproduce bug found in python ctypes - Limitations: none. - PR: Fedora 1174037 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct { - long x; - long y; -} POINT; - -typedef struct { - long left; - long top; - long right; - long bottom; -} RECT; - -static RECT ABI_ATTR pr_test(int i __UNUSED__, RECT ar __UNUSED__, - RECT* br __UNUSED__, POINT cp __UNUSED__, - RECT dr __UNUSED__, RECT *er __UNUSED__, - POINT fp, RECT gr __UNUSED__) -{ - RECT result; - - result.left = fp.x; - result.right = fp.y; - result.top = fp.x; - result.bottom = fp.y; - - return result; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type point_type, rect_type; - ffi_type *point_type_elements[3]; - ffi_type *rect_type_elements[5]; - - int i; - POINT cp, fp; - RECT ar, br, dr, er, gr; - RECT *p1, *p2; - - /* This is a hack to get a properly aligned result buffer */ - RECT *rect_result = - (RECT *) malloc (sizeof(RECT)); - - point_type.size = 0; - point_type.alignment = 0; - point_type.type = FFI_TYPE_STRUCT; - point_type.elements = point_type_elements; - point_type_elements[0] = &ffi_type_slong; - point_type_elements[1] = &ffi_type_slong; - point_type_elements[2] = NULL; - - rect_type.size = 0; - rect_type.alignment = 0; - rect_type.type = FFI_TYPE_STRUCT; - rect_type.elements = rect_type_elements; - rect_type_elements[0] = &ffi_type_slong; - rect_type_elements[1] = &ffi_type_slong; - rect_type_elements[2] = &ffi_type_slong; - rect_type_elements[3] = &ffi_type_slong; - rect_type_elements[4] = NULL; - - args[0] = &ffi_type_sint; - args[1] = &rect_type; - args[2] = &ffi_type_pointer; - args[3] = &point_type; - args[4] = &rect_type; - args[5] = &ffi_type_pointer; - args[6] = &point_type; - args[7] = &rect_type; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 8, &rect_type, args) == FFI_OK); - - i = 1; - ar.left = 2; - ar.right = 3; - ar.top = 4; - ar.bottom = 5; - br.left = 6; - br.right = 7; - br.top = 8; - br.bottom = 9; - cp.x = 10; - cp.y = 11; - dr.left = 12; - dr.right = 13; - dr.top = 14; - dr.bottom = 15; - er.left = 16; - er.right = 17; - er.top = 18; - er.bottom = 19; - fp.x = 20; - fp.y = 21; - gr.left = 22; - gr.right = 23; - gr.top = 24; - gr.bottom = 25; - - values[0] = &i; - values[1] = &ar; - p1 = &br; - values[2] = &p1; - values[3] = &cp; - values[4] = &dr; - p2 = &er; - values[5] = &p2; - values[6] = &fp; - values[7] = &gr; - - ffi_call (&cif, FFI_FN(pr_test), rect_result, values); - - CHECK(rect_result->top == 20); - - free (rect_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/problem1.c b/user/mpy/lib/libffi/testsuite/libffi.call/problem1.c deleted file mode 100644 index 6a91555..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/problem1.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure passing with different structure size. - Limitations: none. - PR: none. - Originator: 20030828 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct my_ffi_struct { - double a; - double b; - double c; -} my_ffi_struct; - -my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2) -{ - struct my_ffi_struct result; - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - - printf("%g %g %g %g %g %g: %g %g %g\n", a1.a, a1.b, a1.c, - a2.a, a2.b, a2.c, result.a, result.b, result.c); - - return result; -} - -void stub(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - struct my_ffi_struct a1; - struct my_ffi_struct a2; - - a1 = *(struct my_ffi_struct*)(args[0]); - a2 = *(struct my_ffi_struct*)(args[1]); - - *(my_ffi_struct *)resp = callee(a1, a2); -} - - -int main(void) -{ - ffi_type* my_ffi_struct_fields[4]; - ffi_type my_ffi_struct_type; - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[4]; - ffi_type* arg_types[3]; - - struct my_ffi_struct g = { 1.0, 2.0, 3.0 }; - struct my_ffi_struct f = { 1.0, 2.0, 3.0 }; - struct my_ffi_struct res; - - my_ffi_struct_type.size = 0; - my_ffi_struct_type.alignment = 0; - my_ffi_struct_type.type = FFI_TYPE_STRUCT; - my_ffi_struct_type.elements = my_ffi_struct_fields; - - my_ffi_struct_fields[0] = &ffi_type_double; - my_ffi_struct_fields[1] = &ffi_type_double; - my_ffi_struct_fields[2] = &ffi_type_double; - my_ffi_struct_fields[3] = NULL; - - arg_types[0] = &my_ffi_struct_type; - arg_types[1] = &my_ffi_struct_type; - arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type, - arg_types) == FFI_OK); - - args[0] = &g; - args[1] = &f; - args[2] = NULL; - ffi_call(&cif, FFI_FN(callee), &res, args); - /* { dg-output "1 2 3 1 2 3: 2 4 6" } */ - printf("res: %g %g %g\n", res.a, res.b, res.c); - /* { dg-output "\nres: 2 4 6" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, stub, NULL, code) == FFI_OK); - - res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(code))(g, f); - /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ - printf("res: %g %g %g\n", res.a, res.b, res.c); - /* { dg-output "\nres: 2 4 6" } */ - - exit(0);; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/promotion.c b/user/mpy/lib/libffi/testsuite/libffi.call/promotion.c deleted file mode 100644 index 4456161..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/promotion.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Area: ffi_call - Purpose: Promotion test. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -static int promotion(signed char sc, signed short ss, - unsigned char uc, unsigned short us) -{ - int r = (int) sc + (int) ss + (int) uc + (int) us; - - return r; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - signed char sc; - unsigned char uc; - signed short ss; - unsigned short us; - unsigned long ul; - - args[0] = &ffi_type_schar; - args[1] = &ffi_type_sshort; - args[2] = &ffi_type_uchar; - args[3] = &ffi_type_ushort; - values[0] = ≻ - values[1] = &ss; - values[2] = &uc; - values[3] = &us; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_sint, args) == FFI_OK); - - us = 0; - ul = 0; - - for (sc = (signed char) -127; - sc <= (signed char) 120; sc += 1) - for (ss = -30000; ss <= 30000; ss += 10000) - for (uc = (unsigned char) 0; - uc <= (unsigned char) 200; uc += 20) - for (us = 0; us <= 60000; us += 10000) - { - ul++; - ffi_call(&cif, FFI_FN(promotion), &rint, values); - CHECK((int)rint == (signed char) sc + (signed short) ss + - (unsigned char) uc + (unsigned short) us); - } - printf("%lu promotion tests run\n", ul); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c b/user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c deleted file mode 100644 index e29bd6c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/pyobjc-tc.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Area: ffi_call - Purpose: Check different structures. - Limitations: none. - PR: none. - Originator: Ronald Oussoren 20030824 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct Point { - float x; - float y; -} Point; - -typedef struct Size { - float h; - float w; -} Size; - -typedef struct Rect { - Point o; - Size s; -} Rect; - -int doit(int o, char* s, Point p, Rect r, int last) -{ - printf("CALLED WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", - o, s, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, last); - return 42; -} - - -int main(void) -{ - ffi_type point_type; - ffi_type size_type; - ffi_type rect_type; - ffi_cif cif; - ffi_type* arglist[6]; - void* values[6]; - int r; - - /* - * First set up FFI types for the 3 struct types - */ - - point_type.size = 0; /*sizeof(Point);*/ - point_type.alignment = 0; /*__alignof__(Point);*/ - point_type.type = FFI_TYPE_STRUCT; - point_type.elements = malloc(3 * sizeof(ffi_type*)); - point_type.elements[0] = &ffi_type_float; - point_type.elements[1] = &ffi_type_float; - point_type.elements[2] = NULL; - - size_type.size = 0;/* sizeof(Size);*/ - size_type.alignment = 0;/* __alignof__(Size);*/ - size_type.type = FFI_TYPE_STRUCT; - size_type.elements = malloc(3 * sizeof(ffi_type*)); - size_type.elements[0] = &ffi_type_float; - size_type.elements[1] = &ffi_type_float; - size_type.elements[2] = NULL; - - rect_type.size = 0;/*sizeof(Rect);*/ - rect_type.alignment =0;/* __alignof__(Rect);*/ - rect_type.type = FFI_TYPE_STRUCT; - rect_type.elements = malloc(3 * sizeof(ffi_type*)); - rect_type.elements[0] = &point_type; - rect_type.elements[1] = &size_type; - rect_type.elements[2] = NULL; - - /* - * Create a CIF - */ - arglist[0] = &ffi_type_sint; - arglist[1] = &ffi_type_pointer; - arglist[2] = &point_type; - arglist[3] = &rect_type; - arglist[4] = &ffi_type_sint; - arglist[5] = NULL; - - r = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, - 5, &ffi_type_sint, arglist); - if (r != FFI_OK) { - abort(); - } - - - /* And call the function through the CIF */ - - { - Point p = { 1.0, 2.0 }; - Rect r = { { 9.0, 10.0}, { -1.0, -2.0 } }; - int o = 0; - int l = 42; - char* m = "myMethod"; - ffi_arg result; - - values[0] = &o; - values[1] = &m; - values[2] = &p; - values[3] = &r; - values[4] = &l; - values[5] = NULL; - - printf("CALLING WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", - o, m, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, l); - - ffi_call(&cif, FFI_FN(doit), &result, values); - - printf ("The result is %d\n", (int)result); - - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c deleted file mode 100644 index fd07e50..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value double. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static double return_dbl(double dbl) -{ - printf ("%f\n", dbl); - return 2 * dbl; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - double dbl, rdbl; - - args[0] = &ffi_type_double; - values[0] = &dbl; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_double, args) == FFI_OK); - - for (dbl = -127.3; dbl < 127; dbl++) - { - ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values); - printf ("%f vs %f\n", rdbl, return_dbl(dbl)); - CHECK(rdbl == 2 * dbl); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c deleted file mode 100644 index 0ea5d50..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl1.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value double. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static double return_dbl(double dbl1, float fl2, unsigned int in3, double dbl4) -{ - return dbl1 + fl2 + in3 + dbl4; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - double dbl1, dbl4, rdbl; - float fl2; - unsigned int in3; - args[0] = &ffi_type_double; - args[1] = &ffi_type_float; - args[2] = &ffi_type_uint; - args[3] = &ffi_type_double; - values[0] = &dbl1; - values[1] = &fl2; - values[2] = &in3; - values[3] = &dbl4; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_double, args) == FFI_OK); - dbl1 = 127.0; - fl2 = 128.0; - in3 = 255; - dbl4 = 512.7; - - ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values); - printf ("%f vs %f\n", rdbl, return_dbl(dbl1, fl2, in3, dbl4)); - CHECK(rdbl == dbl1 + fl2 + in3 + dbl4); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c deleted file mode 100644 index b3818f8..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_dbl2.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value double. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static double return_dbl(double dbl1, double dbl2, unsigned int in3, double dbl4) -{ - return dbl1 + dbl2 + in3 + dbl4; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - double dbl1, dbl2, dbl4, rdbl; - unsigned int in3; - args[0] = &ffi_type_double; - args[1] = &ffi_type_double; - args[2] = &ffi_type_uint; - args[3] = &ffi_type_double; - values[0] = &dbl1; - values[1] = &dbl2; - values[2] = &in3; - values[3] = &dbl4; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_double, args) == FFI_OK); - dbl1 = 127.0; - dbl2 = 128.0; - in3 = 255; - dbl4 = 512.7; - - ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values); - printf ("%f vs %f\n", rdbl, return_dbl(dbl1, dbl2, in3, dbl4)); - CHECK(rdbl == dbl1 + dbl2 + in3 + dbl4); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c deleted file mode 100644 index fb8a09e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value float. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static float return_fl(float fl) -{ - return 2 * fl; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - float fl, rfl; - - args[0] = &ffi_type_float; - values[0] = &fl; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_float, args) == FFI_OK); - - for (fl = -127.0; fl < 127; fl++) - { - ffi_call(&cif, FFI_FN(return_fl), &rfl, values); - printf ("%f vs %f\n", rfl, return_fl(fl)); - CHECK(rfl == 2 * fl); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c deleted file mode 100644 index c3d92c2..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl1.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value float. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static float return_fl(float fl1, float fl2) -{ - return fl1 + fl2; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - float fl1, fl2, rfl; - - args[0] = &ffi_type_float; - args[1] = &ffi_type_float; - values[0] = &fl1; - values[1] = &fl2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, - &ffi_type_float, args) == FFI_OK); - fl1 = 127.0; - fl2 = 128.0; - - ffi_call(&cif, FFI_FN(return_fl), &rfl, values); - printf ("%f vs %f\n", rfl, return_fl(fl1, fl2)); - CHECK(rfl == fl1 + fl2); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c deleted file mode 100644 index ddb976c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl2.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value float. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -/* Use volatile float to avoid false negative on ix86. See PR target/323. */ -static float return_fl(float fl1, float fl2, float fl3, float fl4) -{ - volatile float sum; - - sum = fl1 + fl2 + fl3 + fl4; - return sum; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - float fl1, fl2, fl3, fl4, rfl; - volatile float sum; - - args[0] = &ffi_type_float; - args[1] = &ffi_type_float; - args[2] = &ffi_type_float; - args[3] = &ffi_type_float; - values[0] = &fl1; - values[1] = &fl2; - values[2] = &fl3; - values[3] = &fl4; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_float, args) == FFI_OK); - fl1 = 127.0; - fl2 = 128.0; - fl3 = 255.1; - fl4 = 512.7; - - ffi_call(&cif, FFI_FN(return_fl), &rfl, values); - printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, fl3, fl4)); - - sum = fl1 + fl2 + fl3 + fl4; - CHECK(rfl == sum); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c deleted file mode 100644 index c37877b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_fl3.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value float. - Limitations: none. - PR: none. - Originator: 20050212 */ - -/* { dg-do run } */ -#include "ffitest.h" - -static float return_fl(float fl1, float fl2, unsigned int in3, float fl4) -{ - return fl1 + fl2 + in3 + fl4; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - float fl1, fl2, fl4, rfl; - unsigned int in3; - args[0] = &ffi_type_float; - args[1] = &ffi_type_float; - args[2] = &ffi_type_uint; - args[3] = &ffi_type_float; - values[0] = &fl1; - values[1] = &fl2; - values[2] = &in3; - values[3] = &fl4; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &ffi_type_float, args) == FFI_OK); - fl1 = 127.0; - fl2 = 128.0; - in3 = 255; - fl4 = 512.7; - - ffi_call(&cif, FFI_FN(return_fl), &rfl, values); - printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, in3, fl4)); - CHECK(rfl == fl1 + fl2 + in3 + fl4); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c deleted file mode 100644 index 52a92fe..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_ldl.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value long double. - Limitations: none. - PR: none. - Originator: 20071113 */ -/* { dg-do run } */ - -#include "ffitest.h" - -static long double return_ldl(long double ldl) -{ - return 2*ldl; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - long double ldl, rldl; - - args[0] = &ffi_type_longdouble; - values[0] = &ldl; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_longdouble, args) == FFI_OK); - - for (ldl = -127.0; ldl < 127.0; ldl++) - { - ffi_call(&cif, FFI_FN(return_ldl), &rldl, values); - CHECK(rldl == 2 * ldl); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c deleted file mode 100644 index ea4a1e4..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_ll.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value long long. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -static long long return_ll(long long ll) -{ - return ll; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - long long rlonglong; - long long ll; - - args[0] = &ffi_type_sint64; - values[0] = ≪ - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_sint64, args) == FFI_OK); - - for (ll = 0LL; ll < 100LL; ll++) - { - ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); - CHECK(rlonglong == ll); - } - - for (ll = 55555555555000LL; ll < 55555555555100LL; ll++) - { - ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); - CHECK(rlonglong == ll); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c deleted file mode 100644 index 593e8a3..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_ll1.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Area: ffi_call - Purpose: Check if long long are passed in the corresponding regs on ppc. - Limitations: none. - PR: 20104. - Originator: 20050222 */ - -/* { dg-do run } */ -/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ -#include "ffitest.h" -static long long return_ll(int ll0, long long ll1, int ll2) -{ - return ll0 + ll1 + ll2; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - long long rlonglong; - long long ll1; - unsigned ll0, ll2; - - args[0] = &ffi_type_sint; - args[1] = &ffi_type_sint64; - args[2] = &ffi_type_sint; - values[0] = &ll0; - values[1] = &ll1; - values[2] = &ll2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &ffi_type_sint64, args) == FFI_OK); - - ll0 = 11111111; - ll1 = 11111111111000LL; - ll2 = 11111111; - - ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); - printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2); - /* { dg-output "res: 11111133333222, 11111133333222" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c deleted file mode 100644 index a36cf3e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_sc.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value signed char. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -static signed char return_sc(signed char sc) -{ - return sc; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - signed char sc; - - args[0] = &ffi_type_schar; - values[0] = ≻ - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_schar, args) == FFI_OK); - - for (sc = (signed char) -127; - sc < (signed char) 127; sc++) - { - ffi_call(&cif, FFI_FN(return_sc), &rint, values); - CHECK((signed char)rint == sc); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c deleted file mode 100644 index f0fd345..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_sl.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Area: ffi_call - Purpose: Check if long as return type is handled correctly. - Limitations: none. - PR: none. - */ - -/* { dg-do run } */ -#include "ffitest.h" -static long return_sl(long l1, long l2) -{ - return l1 - l2; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg res; - unsigned long l1, l2; - - args[0] = &ffi_type_slong; - args[1] = &ffi_type_slong; - values[0] = &l1; - values[1] = &l2; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, - &ffi_type_slong, args) == FFI_OK); - - l1 = 1073741823L; - l2 = 1073741824L; - - ffi_call(&cif, FFI_FN(return_sl), &res, values); - printf("res: %ld, %ld\n", (long)res, l1 - l2); - /* { dg-output "res: -1, -1" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c deleted file mode 100644 index 6fe5546..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_uc.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value unsigned char. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -static unsigned char return_uc(unsigned char uc) -{ - return uc; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - - unsigned char uc; - - args[0] = &ffi_type_uchar; - values[0] = &uc; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_uchar, args) == FFI_OK); - - for (uc = (unsigned char) '\x00'; - uc < (unsigned char) '\xff'; uc++) - { - ffi_call(&cif, FFI_FN(return_uc), &rint, values); - CHECK((unsigned char)rint == uc); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c b/user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c deleted file mode 100644 index 12b266f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/return_ul.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Area: ffi_call - Purpose: Check if unsigned long as return type is handled correctly. - Limitations: none. - PR: none. - Originator: 20060724 */ - -/* { dg-do run } */ -#include "ffitest.h" -static unsigned long return_ul(unsigned long ul1, unsigned long ul2) -{ - return ul1 + ul2; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg res; - unsigned long ul1, ul2; - - args[0] = &ffi_type_ulong; - args[1] = &ffi_type_ulong; - values[0] = &ul1; - values[1] = &ul2; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, - &ffi_type_ulong, args) == FFI_OK); - - ul1 = 1073741823L; - ul2 = 1073741824L; - - ffi_call(&cif, FFI_FN(return_ul), &res, values); - printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2); - /* { dg-output "res: 2147483647, 2147483647" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c deleted file mode 100644 index 71c2469..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/stret_large.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure returning with different structure size. - Depending on the ABI. Check bigger struct which overlaps - the gp and fp register count on Darwin/AIX/ppc64. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/21/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -#include "ffitest.h" - -/* 13 FPRs: 104 bytes */ -/* 14 FPRs: 112 bytes */ - -typedef struct struct_108byte { - double a; - double b; - double c; - double d; - double e; - double f; - double g; - double h; - double i; - double j; - double k; - double l; - double m; - int n; -} struct_108byte; - -struct_108byte cls_struct_108byte_fn( - struct_108byte b0, - struct_108byte b1, - struct_108byte b2, - struct_108byte b3) -{ - struct_108byte result; - - result.a = b0.a + b1.a + b2.a + b3.a; - result.b = b0.b + b1.b + b2.b + b3.b; - result.c = b0.c + b1.c + b2.c + b3.c; - result.d = b0.d + b1.d + b2.d + b3.d; - result.e = b0.e + b1.e + b2.e + b3.e; - result.f = b0.f + b1.f + b2.f + b3.f; - result.g = b0.g + b1.g + b2.g + b3.g; - result.h = b0.h + b1.h + b2.h + b3.h; - result.i = b0.i + b1.i + b2.i + b3.i; - result.j = b0.j + b1.j + b2.j + b3.j; - result.k = b0.k + b1.k + b2.k + b3.k; - result.l = b0.l + b1.l + b2.l + b3.l; - result.m = b0.m + b1.m + b2.m + b3.m; - result.n = b0.n + b1.n + b2.n + b3.n; - - printf("%g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", result.a, result.b, result.c, - result.d, result.e, result.f, result.g, result.h, result.i, - result.j, result.k, result.l, result.m, result.n); - - return result; -} - -static void -cls_struct_108byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) -{ - struct_108byte b0, b1, b2, b3; - - b0 = *(struct_108byte*)(args[0]); - b1 = *(struct_108byte*)(args[1]); - b2 = *(struct_108byte*)(args[2]); - b3 = *(struct_108byte*)(args[3]); - - *(struct_108byte*)resp = cls_struct_108byte_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[15]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct_108byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 7 }; - struct_108byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 4 }; - struct_108byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 3 }; - struct_108byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 2 }; - struct_108byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_double; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = &ffi_type_double; - cls_struct_fields[5] = &ffi_type_double; - cls_struct_fields[6] = &ffi_type_double; - cls_struct_fields[7] = &ffi_type_double; - cls_struct_fields[8] = &ffi_type_double; - cls_struct_fields[9] = &ffi_type_double; - cls_struct_fields[10] = &ffi_type_double; - cls_struct_fields[11] = &ffi_type_double; - cls_struct_fields[12] = &ffi_type_double; - cls_struct_fields[13] = &ffi_type_sint32; - cls_struct_fields[14] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = &cls_struct_type; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_108byte_fn), &res_dbl, args_dbl); - /* { dg-output "22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ - printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, - res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_108byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((struct_108byte(*)(struct_108byte, struct_108byte, - struct_108byte, struct_108byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ - printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, - res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c deleted file mode 100644 index d9c750e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/stret_large2.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure returning with different structure size. - Depending on the ABI. Check bigger struct which overlaps - the gp and fp register count on Darwin/AIX/ppc64. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/21/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -#include "ffitest.h" - -/* 13 FPRs: 104 bytes */ -/* 14 FPRs: 112 bytes */ - -typedef struct struct_116byte { - double a; - double b; - double c; - double d; - double e; - double f; - double g; - double h; - double i; - double j; - double k; - double l; - double m; - double n; - int o; -} struct_116byte; - -struct_116byte cls_struct_116byte_fn( - struct_116byte b0, - struct_116byte b1, - struct_116byte b2, - struct_116byte b3) -{ - struct_116byte result; - - result.a = b0.a + b1.a + b2.a + b3.a; - result.b = b0.b + b1.b + b2.b + b3.b; - result.c = b0.c + b1.c + b2.c + b3.c; - result.d = b0.d + b1.d + b2.d + b3.d; - result.e = b0.e + b1.e + b2.e + b3.e; - result.f = b0.f + b1.f + b2.f + b3.f; - result.g = b0.g + b1.g + b2.g + b3.g; - result.h = b0.h + b1.h + b2.h + b3.h; - result.i = b0.i + b1.i + b2.i + b3.i; - result.j = b0.j + b1.j + b2.j + b3.j; - result.k = b0.k + b1.k + b2.k + b3.k; - result.l = b0.l + b1.l + b2.l + b3.l; - result.m = b0.m + b1.m + b2.m + b3.m; - result.n = b0.n + b1.n + b2.n + b3.n; - result.o = b0.o + b1.o + b2.o + b3.o; - - printf("%g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", result.a, result.b, result.c, - result.d, result.e, result.f, result.g, result.h, result.i, - result.j, result.k, result.l, result.m, result.n, result.o); - - return result; -} - -static void -cls_struct_116byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) -{ - struct_116byte b0, b1, b2, b3; - - b0 = *(struct_116byte*)(args[0]); - b1 = *(struct_116byte*)(args[1]); - b2 = *(struct_116byte*)(args[2]); - b3 = *(struct_116byte*)(args[3]); - - *(struct_116byte*)resp = cls_struct_116byte_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[16]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct_116byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 7 }; - struct_116byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 6.0, 4 }; - struct_116byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 7.0, 3 }; - struct_116byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 8.0, 2 }; - struct_116byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_double; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = &ffi_type_double; - cls_struct_fields[5] = &ffi_type_double; - cls_struct_fields[6] = &ffi_type_double; - cls_struct_fields[7] = &ffi_type_double; - cls_struct_fields[8] = &ffi_type_double; - cls_struct_fields[9] = &ffi_type_double; - cls_struct_fields[10] = &ffi_type_double; - cls_struct_fields[11] = &ffi_type_double; - cls_struct_fields[12] = &ffi_type_double; - cls_struct_fields[13] = &ffi_type_double; - cls_struct_fields[14] = &ffi_type_sint32; - cls_struct_fields[15] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = &cls_struct_type; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_116byte_fn), &res_dbl, args_dbl); - /* { dg-output "22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ - printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, - res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_116byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((struct_116byte(*)(struct_116byte, struct_116byte, - struct_116byte, struct_116byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ - printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b, - res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i, - res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c deleted file mode 100644 index 973ee02..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure returning with different structure size. - Depending on the ABI. Check bigger struct which overlaps - the gp and fp register count on Darwin/AIX/ppc64. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/21/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -#include "ffitest.h" - -typedef struct struct_72byte { - double a; - double b; - double c; - double d; - double e; - double f; - double g; - double h; - double i; -} struct_72byte; - -struct_72byte cls_struct_72byte_fn( - struct_72byte b0, - struct_72byte b1, - struct_72byte b2, - struct_72byte b3) -{ - struct_72byte result; - - result.a = b0.a + b1.a + b2.a + b3.a; - result.b = b0.b + b1.b + b2.b + b3.b; - result.c = b0.c + b1.c + b2.c + b3.c; - result.d = b0.d + b1.d + b2.d + b3.d; - result.e = b0.e + b1.e + b2.e + b3.e; - result.f = b0.f + b1.f + b2.f + b3.f; - result.g = b0.g + b1.g + b2.g + b3.g; - result.h = b0.h + b1.h + b2.h + b3.h; - result.i = b0.i + b1.i + b2.i + b3.i; - - printf("%g %g %g %g %g %g %g %g %g\n", result.a, result.b, result.c, - result.d, result.e, result.f, result.g, result.h, result.i); - - return result; -} - -static void -cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) -{ - struct_72byte b0, b1, b2, b3; - - b0 = *(struct_72byte*)(args[0]); - b1 = *(struct_72byte*)(args[1]); - b2 = *(struct_72byte*)(args[2]); - b3 = *(struct_72byte*)(args[3]); - - *(struct_72byte*)resp = cls_struct_72byte_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[10]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7.0 }; - struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0 }; - struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3.0 }; - struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2.0 }; - struct_72byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_double; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = &ffi_type_double; - cls_struct_fields[5] = &ffi_type_double; - cls_struct_fields[6] = &ffi_type_double; - cls_struct_fields[7] = &ffi_type_double; - cls_struct_fields[8] = &ffi_type_double; - cls_struct_fields[9] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = &cls_struct_type; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_72byte_fn), &res_dbl, args_dbl); - /* { dg-output "22 15 17 25 6 13 19 18 16" } */ - printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte, - struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n22 15 17 25 6 13 19 18 16" } */ - printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c b/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c deleted file mode 100644 index 84323d1..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/stret_medium2.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure returning with different structure size. - Depending on the ABI. Check bigger struct which overlaps - the gp and fp register count on Darwin/AIX/ppc64. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/21/2007 */ - -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */ -#include "ffitest.h" - -typedef struct struct_72byte { - double a; - double b; - double c; - double d; - double e; - double f; - double g; - double h; - long long i; -} struct_72byte; - -struct_72byte cls_struct_72byte_fn( - struct_72byte b0, - struct_72byte b1, - struct_72byte b2, - struct_72byte b3) -{ - struct_72byte result; - - result.a = b0.a + b1.a + b2.a + b3.a; - result.b = b0.b + b1.b + b2.b + b3.b; - result.c = b0.c + b1.c + b2.c + b3.c; - result.d = b0.d + b1.d + b2.d + b3.d; - result.e = b0.e + b1.e + b2.e + b3.e; - result.f = b0.f + b1.f + b2.f + b3.f; - result.g = b0.g + b1.g + b2.g + b3.g; - result.h = b0.h + b1.h + b2.h + b3.h; - result.i = b0.i + b1.i + b2.i + b3.i; - - printf("%g %g %g %g %g %g %g %g %" PRIdLL "\n", result.a, result.b, result.c, - result.d, result.e, result.f, result.g, result.h, result.i); - - return result; -} - -static void -cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) -{ - struct_72byte b0, b1, b2, b3; - - b0 = *(struct_72byte*)(args[0]); - b1 = *(struct_72byte*)(args[1]); - b2 = *(struct_72byte*)(args[2]); - b3 = *(struct_72byte*)(args[3]); - - *(struct_72byte*)resp = cls_struct_72byte_fn(b0, b1, b2, b3); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_dbl[5]; - ffi_type* cls_struct_fields[10]; - ffi_type cls_struct_type; - ffi_type* dbl_arg_types[5]; - - struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7 }; - struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4 }; - struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3 }; - struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2 }; - struct_72byte res_dbl; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_double; - cls_struct_fields[1] = &ffi_type_double; - cls_struct_fields[2] = &ffi_type_double; - cls_struct_fields[3] = &ffi_type_double; - cls_struct_fields[4] = &ffi_type_double; - cls_struct_fields[5] = &ffi_type_double; - cls_struct_fields[6] = &ffi_type_double; - cls_struct_fields[7] = &ffi_type_double; - cls_struct_fields[8] = &ffi_type_sint64; - cls_struct_fields[9] = NULL; - - dbl_arg_types[0] = &cls_struct_type; - dbl_arg_types[1] = &cls_struct_type; - dbl_arg_types[2] = &cls_struct_type; - dbl_arg_types[3] = &cls_struct_type; - dbl_arg_types[4] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type, - dbl_arg_types) == FFI_OK); - - args_dbl[0] = &e_dbl; - args_dbl[1] = &f_dbl; - args_dbl[2] = &g_dbl; - args_dbl[3] = &h_dbl; - args_dbl[4] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_72byte_fn), &res_dbl, args_dbl); - /* { dg-output "22 15 17 25 6 13 19 18 16" } */ - printf("res: %g %g %g %g %g %g %g %g %" PRIdLL "\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK); - - res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte, - struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n22 15 17 25 6 13 19 18 16" } */ - printf("res: %g %g %g %g %g %g %g %g %" PRIdLL "\n", res_dbl.a, res_dbl.b, res_dbl.c, - res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i); - /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen.c deleted file mode 100644 index 35b70ea..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/strlen.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Area: ffi_call - Purpose: Check strlen function call. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -static size_t ABI_ATTR my_strlen(char *s) -{ - return (strlen(s)); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - - args[0] = &ffi_type_pointer; - values[0] = (void*) &s; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - ffi_call(&cif, FFI_FN(my_strlen), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - ffi_call(&cif, FFI_FN(my_strlen), &rint, values); - CHECK(rint == 7); - - s = "1234567890123456789012345"; - ffi_call(&cif, FFI_FN(my_strlen), &rint, values); - CHECK(rint == 25); - - exit (0); -} - diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c deleted file mode 100644 index 96282bc..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/strlen2.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Area: ffi_call - Purpose: Check strlen function call with additional arguments. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static size_t ABI_ATTR my_f(char *s, float a) -{ - return (size_t) ((int) strlen(s) + (int) a); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - float v2; - args[0] = &ffi_type_pointer; - args[1] = &ffi_type_float; - values[0] = (void*) &s; - values[1] = (void*) &v2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - v2 = 0.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - v2 = -1.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 6); - - s = "1234567890123456789012345"; - v2 = 1.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 26); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c deleted file mode 100644 index beba86e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/strlen3.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Area: ffi_call - Purpose: Check strlen function call with additional arguments. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static size_t ABI_ATTR my_f(float a, char *s) -{ - return (size_t) ((int) strlen(s) + (int) a); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - float v2; - args[1] = &ffi_type_pointer; - args[0] = &ffi_type_float; - values[1] = (void*) &s; - values[0] = (void*) &v2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - v2 = 0.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - v2 = -1.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 6); - - s = "1234567890123456789012345"; - v2 = 1.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 26); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c b/user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c deleted file mode 100644 index d5d42b4..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/strlen4.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Area: ffi_call - Purpose: Check strlen function call with additional arguments. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static size_t ABI_ATTR my_f(float a, char *s, int i) -{ - return (size_t) ((int) strlen(s) + (int) a + i); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - int v1; - float v2; - args[2] = &ffi_type_sint; - args[1] = &ffi_type_pointer; - args[0] = &ffi_type_float; - values[2] = (void*) &v1; - values[1] = (void*) &s; - values[0] = (void*) &v2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 3, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - v1 = 1; - v2 = 0.0; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 2); - - s = "1234567"; - v2 = -1.0; - v1 = -2; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 4); - - s = "1234567890123456789012345"; - v2 = 1.0; - v1 = 2; - ffi_call(&cif, FFI_FN(my_f), &rint, values); - CHECK(rint == 28); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct1.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct1.c deleted file mode 100644 index c13e23f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct1.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - unsigned char uc; - double d; - unsigned int ui; -} test_structure_1; - -static test_structure_1 ABI_ATTR struct1(test_structure_1 ts) -{ - ts.uc++; - ts.d--; - ts.ui++; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts1_type; - ffi_type *ts1_type_elements[4]; - - test_structure_1 ts1_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_1 *ts1_result = - (test_structure_1 *) malloc (sizeof(test_structure_1)); - - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - ts1_type_elements[0] = &ffi_type_uchar; - ts1_type_elements[1] = &ffi_type_double; - ts1_type_elements[2] = &ffi_type_uint; - ts1_type_elements[3] = NULL; - - args[0] = &ts1_type; - values[0] = &ts1_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, - &ts1_type, args) == FFI_OK); - - ts1_arg.uc = '\x01'; - ts1_arg.d = 3.14159; - ts1_arg.ui = 555; - - ffi_call(&cif, FFI_FN(struct1), ts1_result, values); - - CHECK(ts1_result->ui == 556); - CHECK(ts1_result->d == 3.14159 - 1); - - free (ts1_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct2.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct2.c deleted file mode 100644 index 5077a5e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct2.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - double d1; - double d2; -} test_structure_2; - -static test_structure_2 ABI_ATTR struct2(test_structure_2 ts) -{ - ts.d1--; - ts.d2--; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - test_structure_2 ts2_arg; - ffi_type ts2_type; - ffi_type *ts2_type_elements[3]; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_2 *ts2_result = - (test_structure_2 *) malloc (sizeof(test_structure_2)); - - ts2_type.size = 0; - ts2_type.alignment = 0; - ts2_type.type = FFI_TYPE_STRUCT; - ts2_type.elements = ts2_type_elements; - ts2_type_elements[0] = &ffi_type_double; - ts2_type_elements[1] = &ffi_type_double; - ts2_type_elements[2] = NULL; - - args[0] = &ts2_type; - values[0] = &ts2_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts2_type, args) == FFI_OK); - - ts2_arg.d1 = 5.55; - ts2_arg.d2 = 6.66; - - printf ("%g\n", ts2_arg.d1); - printf ("%g\n", ts2_arg.d2); - - ffi_call(&cif, FFI_FN(struct2), ts2_result, values); - - printf ("%g\n", ts2_result->d1); - printf ("%g\n", ts2_result->d2); - - CHECK(ts2_result->d1 == 5.55 - 1); - CHECK(ts2_result->d2 == 6.66 - 1); - - free (ts2_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct3.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct3.c deleted file mode 100644 index 7eba0ea..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct3.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - int si; -} test_structure_3; - -static test_structure_3 ABI_ATTR struct3(test_structure_3 ts) -{ - ts.si = -(ts.si*2); - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - int compare_value; - ffi_type ts3_type; - ffi_type *ts3_type_elements[2]; - - test_structure_3 ts3_arg; - test_structure_3 *ts3_result = - (test_structure_3 *) malloc (sizeof(test_structure_3)); - - ts3_type.size = 0; - ts3_type.alignment = 0; - ts3_type.type = FFI_TYPE_STRUCT; - ts3_type.elements = ts3_type_elements; - ts3_type_elements[0] = &ffi_type_sint; - ts3_type_elements[1] = NULL; - - args[0] = &ts3_type; - values[0] = &ts3_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, - &ts3_type, args) == FFI_OK); - - ts3_arg.si = -123; - compare_value = ts3_arg.si; - - ffi_call(&cif, FFI_FN(struct3), ts3_result, values); - - printf ("%d %d\n", ts3_result->si, -(compare_value*2)); - - CHECK(ts3_result->si == -(compare_value*2)); - - free (ts3_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct4.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct4.c deleted file mode 100644 index 66a9551..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct4.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - unsigned ui1; - unsigned ui2; - unsigned ui3; -} test_structure_4; - -static test_structure_4 ABI_ATTR struct4(test_structure_4 ts) -{ - ts.ui3 = ts.ui1 * ts.ui2 * ts.ui3; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts4_type; - ffi_type *ts4_type_elements[4]; - - test_structure_4 ts4_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_4 *ts4_result = - (test_structure_4 *) malloc (sizeof(test_structure_4)); - - ts4_type.size = 0; - ts4_type.alignment = 0; - ts4_type.type = FFI_TYPE_STRUCT; - ts4_type.elements = ts4_type_elements; - ts4_type_elements[0] = &ffi_type_uint; - ts4_type_elements[1] = &ffi_type_uint; - ts4_type_elements[2] = &ffi_type_uint; - ts4_type_elements[3] = NULL; - - args[0] = &ts4_type; - values[0] = &ts4_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts4_type, args) == FFI_OK); - - ts4_arg.ui1 = 2; - ts4_arg.ui2 = 3; - ts4_arg.ui3 = 4; - - ffi_call (&cif, FFI_FN(struct4), ts4_result, values); - - CHECK(ts4_result->ui3 == 2U * 3U * 4U); - - - free (ts4_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct5.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct5.c deleted file mode 100644 index 23e2a3f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct5.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -typedef struct -{ - char c1; - char c2; -} test_structure_5; - -static test_structure_5 ABI_ATTR struct5(test_structure_5 ts1, test_structure_5 ts2) -{ - ts1.c1 += ts2.c1; - ts1.c2 -= ts2.c2; - - return ts1; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts5_type; - ffi_type *ts5_type_elements[3]; - - test_structure_5 ts5_arg1, ts5_arg2; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_5 *ts5_result = - (test_structure_5 *) malloc (sizeof(test_structure_5)); - - ts5_type.size = 0; - ts5_type.alignment = 0; - ts5_type.type = FFI_TYPE_STRUCT; - ts5_type.elements = ts5_type_elements; - ts5_type_elements[0] = &ffi_type_schar; - ts5_type_elements[1] = &ffi_type_schar; - ts5_type_elements[2] = NULL; - - args[0] = &ts5_type; - args[1] = &ts5_type; - values[0] = &ts5_arg1; - values[1] = &ts5_arg2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &ts5_type, args) == FFI_OK); - - ts5_arg1.c1 = 2; - ts5_arg1.c2 = 6; - ts5_arg2.c1 = 5; - ts5_arg2.c2 = 3; - - ffi_call (&cif, FFI_FN(struct5), ts5_result, values); - - CHECK(ts5_result->c1 == 7); - CHECK(ts5_result->c2 == 3); - - - free (ts5_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct6.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct6.c deleted file mode 100644 index 173c66e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct6.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -typedef struct -{ - float f; - double d; -} test_structure_6; - -static test_structure_6 ABI_ATTR struct6 (test_structure_6 ts) -{ - ts.f += 1; - ts.d += 1; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts6_type; - ffi_type *ts6_type_elements[3]; - - test_structure_6 ts6_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_6 *ts6_result = - (test_structure_6 *) malloc (sizeof(test_structure_6)); - - ts6_type.size = 0; - ts6_type.alignment = 0; - ts6_type.type = FFI_TYPE_STRUCT; - ts6_type.elements = ts6_type_elements; - ts6_type_elements[0] = &ffi_type_float; - ts6_type_elements[1] = &ffi_type_double; - ts6_type_elements[2] = NULL; - - args[0] = &ts6_type; - values[0] = &ts6_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts6_type, args) == FFI_OK); - - ts6_arg.f = 5.55f; - ts6_arg.d = 6.66; - - printf ("%g\n", ts6_arg.f); - printf ("%g\n", ts6_arg.d); - - ffi_call(&cif, FFI_FN(struct6), ts6_result, values); - - CHECK(ts6_result->f == 5.55f + 1); - CHECK(ts6_result->d == 6.66 + 1); - - free (ts6_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct7.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct7.c deleted file mode 100644 index badc7e0..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct7.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -typedef struct -{ - float f1; - float f2; - double d; -} test_structure_7; - -static test_structure_7 ABI_ATTR struct7 (test_structure_7 ts) -{ - ts.f1 += 1; - ts.f2 += 1; - ts.d += 1; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts7_type; - ffi_type *ts7_type_elements[4]; - - test_structure_7 ts7_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_7 *ts7_result = - (test_structure_7 *) malloc (sizeof(test_structure_7)); - - ts7_type.size = 0; - ts7_type.alignment = 0; - ts7_type.type = FFI_TYPE_STRUCT; - ts7_type.elements = ts7_type_elements; - ts7_type_elements[0] = &ffi_type_float; - ts7_type_elements[1] = &ffi_type_float; - ts7_type_elements[2] = &ffi_type_double; - ts7_type_elements[3] = NULL; - - args[0] = &ts7_type; - values[0] = &ts7_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts7_type, args) == FFI_OK); - - ts7_arg.f1 = 5.55f; - ts7_arg.f2 = 55.5f; - ts7_arg.d = 6.66; - - printf ("%g\n", ts7_arg.f1); - printf ("%g\n", ts7_arg.f2); - printf ("%g\n", ts7_arg.d); - - ffi_call(&cif, FFI_FN(struct7), ts7_result, values); - - printf ("%g\n", ts7_result->f1); - printf ("%g\n", ts7_result->f2); - printf ("%g\n", ts7_result->d); - - CHECK(ts7_result->f1 == 5.55f + 1); - CHECK(ts7_result->f2 == 55.5f + 1); - CHECK(ts7_result->d == 6.66 + 1); - - free (ts7_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct8.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct8.c deleted file mode 100644 index ef204ec..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct8.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" -typedef struct -{ - float f1; - float f2; - float f3; - float f4; -} test_structure_8; - -static test_structure_8 ABI_ATTR struct8 (test_structure_8 ts) -{ - ts.f1 += 1; - ts.f2 += 1; - ts.f3 += 1; - ts.f4 += 1; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts8_type; - ffi_type *ts8_type_elements[5]; - - test_structure_8 ts8_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_8 *ts8_result = - (test_structure_8 *) malloc (sizeof(test_structure_8)); - - ts8_type.size = 0; - ts8_type.alignment = 0; - ts8_type.type = FFI_TYPE_STRUCT; - ts8_type.elements = ts8_type_elements; - ts8_type_elements[0] = &ffi_type_float; - ts8_type_elements[1] = &ffi_type_float; - ts8_type_elements[2] = &ffi_type_float; - ts8_type_elements[3] = &ffi_type_float; - ts8_type_elements[4] = NULL; - - args[0] = &ts8_type; - values[0] = &ts8_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts8_type, args) == FFI_OK); - - ts8_arg.f1 = 5.55f; - ts8_arg.f2 = 55.5f; - ts8_arg.f3 = -5.55f; - ts8_arg.f4 = -55.5f; - - printf ("%g\n", ts8_arg.f1); - printf ("%g\n", ts8_arg.f2); - printf ("%g\n", ts8_arg.f3); - printf ("%g\n", ts8_arg.f4); - - ffi_call(&cif, FFI_FN(struct8), ts8_result, values); - - printf ("%g\n", ts8_result->f1); - printf ("%g\n", ts8_result->f2); - printf ("%g\n", ts8_result->f3); - printf ("%g\n", ts8_result->f4); - - CHECK(ts8_result->f1 == 5.55f + 1); - CHECK(ts8_result->f2 == 55.5f + 1); - CHECK(ts8_result->f3 == -5.55f + 1); - CHECK(ts8_result->f4 == -55.5f + 1); - - free (ts8_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/struct9.c b/user/mpy/lib/libffi/testsuite/libffi.call/struct9.c deleted file mode 100644 index 4a13b81..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/struct9.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - float f; - int i; -} test_structure_9; - -static test_structure_9 ABI_ATTR struct9 (test_structure_9 ts) -{ - ts.f += 1; - ts.i += 1; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts9_type; - ffi_type *ts9_type_elements[3]; - - test_structure_9 ts9_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_9 *ts9_result = - (test_structure_9 *) malloc (sizeof(test_structure_9)); - - ts9_type.size = 0; - ts9_type.alignment = 0; - ts9_type.type = FFI_TYPE_STRUCT; - ts9_type.elements = ts9_type_elements; - ts9_type_elements[0] = &ffi_type_float; - ts9_type_elements[1] = &ffi_type_sint; - ts9_type_elements[2] = NULL; - - args[0] = &ts9_type; - values[0] = &ts9_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts9_type, args) == FFI_OK); - - ts9_arg.f = 5.55f; - ts9_arg.i = 5; - - printf ("%g\n", ts9_arg.f); - printf ("%d\n", ts9_arg.i); - - ffi_call(&cif, FFI_FN(struct9), ts9_result, values); - - printf ("%g\n", ts9_result->f); - printf ("%d\n", ts9_result->i); - - CHECK(ts9_result->f == 5.55f + 1); - CHECK(ts9_result->i == 5 + 1); - - free (ts9_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c b/user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c deleted file mode 100644 index ca31056..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/testclosure.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Area: closure_call - Purpose: Check return value float. - Limitations: none. - PR: 41908. - Originator: 20091102 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct cls_struct_combined { - float a; - float b; - float c; - float d; -} cls_struct_combined; - -void cls_struct_combined_fn(struct cls_struct_combined arg) -{ - printf("%g %g %g %g\n", - arg.a, arg.b, - arg.c, arg.d); - fflush(stdout); -} - -static void -cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, - void** args, void* userdata __UNUSED__) -{ - struct cls_struct_combined a0; - - a0 = *(struct cls_struct_combined*)(args[0]); - - cls_struct_combined_fn(a0); -} - - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type* cls_struct_fields0[5]; - ffi_type cls_struct_type0; - ffi_type* dbl_arg_types[5]; - - struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; - - cls_struct_type0.size = 0; - cls_struct_type0.alignment = 0; - cls_struct_type0.type = FFI_TYPE_STRUCT; - cls_struct_type0.elements = cls_struct_fields0; - - cls_struct_fields0[0] = &ffi_type_float; - cls_struct_fields0[1] = &ffi_type_float; - cls_struct_fields0[2] = &ffi_type_float; - cls_struct_fields0[3] = &ffi_type_float; - cls_struct_fields0[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type0; - dbl_arg_types[1] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void, - dbl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); - - ((void(*)(cls_struct_combined)) (code))(g_dbl); - /* { dg-output "4 5 1 8" } */ - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c b/user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c deleted file mode 100644 index f00d830..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/uninitialized.c +++ /dev/null @@ -1,61 +0,0 @@ -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - unsigned char uc; - double d; - unsigned int ui; -} test_structure_1; - -static test_structure_1 struct1(test_structure_1 ts) -{ - ts.uc++; - ts.d--; - ts.ui++; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts1_type; - ffi_type *ts1_type_elements[4]; - - memset(&cif, 1, sizeof(cif)); - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - ts1_type_elements[0] = &ffi_type_uchar; - ts1_type_elements[1] = &ffi_type_double; - ts1_type_elements[2] = &ffi_type_uint; - ts1_type_elements[3] = NULL; - - test_structure_1 ts1_arg; - /* This is a hack to get a properly aligned result buffer */ - test_structure_1 *ts1_result = - (test_structure_1 *) malloc (sizeof(test_structure_1)); - - args[0] = &ts1_type; - values[0] = &ts1_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ts1_type, args) == FFI_OK); - - ts1_arg.uc = '\x01'; - ts1_arg.d = 3.14159; - ts1_arg.ui = 555; - - ffi_call(&cif, FFI_FN(struct1), ts1_result, values); - - CHECK(ts1_result->ui == 556); - CHECK(ts1_result->d == 3.14159 - 1); - - free (ts1_result); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc b/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc deleted file mode 100644 index 67cfefe..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* Area: ffi_closure, unwind info - Purpose: Check if the unwind information is passed correctly. - Limitations: none. - PR: none. - Originator: Jeff Sturm */ - -/* { dg-do run } */ - -#include "ffitest.h" - -void ABI_ATTR -closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, - void** args __UNUSED__, void* userdata __UNUSED__) -{ - throw 9; -} - -typedef void (*closure_test_type)(); - -void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) - { - *(ffi_arg*)resp = - (int)*(float *)args[0] +(int)(*(float *)args[1]) + - (int)(*(float *)args[2]) + (int)*(float *)args[3] + - (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) + - (int)*(float *)args[6] + (int)(*(int *)args[7]) + - (int)(*(double*)args[8]) + (int)*(int *)args[9] + - (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + - (int)*(int *)args[12] + (int)(*(int *)args[13]) + - (int)(*(int *)args[14]) + *(int *)args[15] + (int)(intptr_t)userdata; - - printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", - (int)*(float *)args[0], (int)(*(float *)args[1]), - (int)(*(float *)args[2]), (int)*(float *)args[3], - (int)(*(signed short *)args[4]), (int)(*(float *)args[5]), - (int)*(float *)args[6], (int)(*(int *)args[7]), - (int)(*(double *)args[8]), (int)*(int *)args[9], - (int)(*(int *)args[10]), (int)(*(float *)args[11]), - (int)*(int *)args[12], (int)(*(int *)args[13]), - (int)(*(int *)args[14]), *(int *)args[15], - (int)(intptr_t)userdata, (int)*(ffi_arg*)resp); - - throw (int)*(ffi_arg*)resp; -} - -typedef int (*closure_test_type1)(float, float, float, float, signed short, - float, float, int, double, int, int, float, - int, int, int, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = (ffi_closure *)ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - - { - cl_arg_types[1] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, - &ffi_type_void, cl_arg_types) == FFI_OK); - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn, NULL, code) == FFI_OK); - - try - { - (*((closure_test_type)(code)))(); - } catch (int exception_code) - { - CHECK(exception_code == 9); - } - - printf("part one OK\n"); - /* { dg-output "part one OK" } */ - } - - { - - cl_arg_types[0] = &ffi_type_float; - cl_arg_types[1] = &ffi_type_float; - cl_arg_types[2] = &ffi_type_float; - cl_arg_types[3] = &ffi_type_float; - cl_arg_types[4] = &ffi_type_sshort; - cl_arg_types[5] = &ffi_type_float; - cl_arg_types[6] = &ffi_type_float; - cl_arg_types[7] = &ffi_type_uint; - cl_arg_types[8] = &ffi_type_double; - cl_arg_types[9] = &ffi_type_uint; - cl_arg_types[10] = &ffi_type_uint; - cl_arg_types[11] = &ffi_type_float; - cl_arg_types[12] = &ffi_type_uint; - cl_arg_types[13] = &ffi_type_uint; - cl_arg_types[14] = &ffi_type_uint; - cl_arg_types[15] = &ffi_type_uint; - cl_arg_types[16] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1, - (void *) 3 /* userdata */, code) == FFI_OK); - try - { - (*((closure_test_type1)code)) - (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13, - 19, 21, 1); - /* { dg-output "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ - } catch (int exception_code) - { - CHECK(exception_code == 255); - } - printf("part two OK\n"); - /* { dg-output "\npart two OK" } */ - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc b/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc deleted file mode 100644 index ec61164..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* Area: ffi_call, unwind info - Purpose: Check if the unwind information is passed correctly. - Limitations: none. - PR: none. - Originator: Andreas Tobler 20061213 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -static int checking(int a __UNUSED__, short b __UNUSED__, - signed char c __UNUSED__) -{ - throw 9; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - - signed int si; - signed short ss; - signed char sc; - - args[0] = &ffi_type_sint; - values[0] = &si; - args[1] = &ffi_type_sshort; - values[1] = &ss; - args[2] = &ffi_type_schar; - values[2] = ≻ - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &ffi_type_sint, args) == FFI_OK); - - si = -6; - ss = -12; - sc = -1; - { - try - { - ffi_call(&cif, FFI_FN(checking), &rint, values); - } catch (int exception_code) - { - CHECK(exception_code == 9); - } - printf("part one OK\n"); - /* { dg-output "part one OK" } */ - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_1.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_1.c deleted file mode 100644 index 7f96809..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/va_1.c +++ /dev/null @@ -1,196 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static int -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - unsigned char uc; - signed char sc; - unsigned short us; - signed short ss; - unsigned int ui; - signed int si; - unsigned long ul; - signed long sl; - float f; - double d; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - - uc = va_arg (ap, unsigned); - sc = va_arg (ap, signed); - - us = va_arg (ap, unsigned); - ss = va_arg (ap, signed); - - ui = va_arg (ap, unsigned int); - si = va_arg (ap, signed int); - - ul = va_arg (ap, unsigned long); - sl = va_arg (ap, signed long); - - f = va_arg (ap, double); /* C standard promotes float->double - when anonymous */ - d = va_arg (ap, double); - - printf ("%u %u %u %u %u %u %u %u %u uc=%u sc=%d %u %d %u %d %lu %ld %f %f\n", - s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b, - uc, sc, - us, ss, - ui, si, - ul, sl, - f, d); - va_end (ap); - return n + 1; -} - -int -main (void) -{ - ffi_cif cif; - void* args[15]; - ffi_type* arg_types[15]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - ffi_arg res; - - unsigned char uc; - signed char sc; - unsigned short us; - signed short ss; - unsigned int ui; - signed int si; - unsigned long ul; - signed long sl; - double d1; - double f1; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = &ffi_type_uchar; - arg_types[5] = &ffi_type_schar; - arg_types[6] = &ffi_type_ushort; - arg_types[7] = &ffi_type_sshort; - arg_types[8] = &ffi_type_uint; - arg_types[9] = &ffi_type_sint; - arg_types[10] = &ffi_type_ulong; - arg_types[11] = &ffi_type_slong; - arg_types[12] = &ffi_type_double; - arg_types[13] = &ffi_type_double; - arg_types[14] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - uc = 9; - sc = 10; - us = 11; - ss = 12; - ui = 13; - si = 14; - ul = 15; - sl = 16; - f1 = 2.12; - d1 = 3.13; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = &uc; - args[5] = ≻ - args[6] = &us; - args[7] = &ss; - args[8] = &ui; - args[9] = &si; - args[10] = &ul; - args[11] = &sl; - args[12] = &f1; - args[13] = &d1; - args[14] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 42" } */ - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c deleted file mode 100644 index e645206..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct1.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static int -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b); - va_end (ap); - return n + 1; -} - -int -main (void) -{ - ffi_cif cif; - void* args[5]; - ffi_type* arg_types[5]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - ffi_arg res; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 42" } */ - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c deleted file mode 100644 index 56f5b9c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct2.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static struct small_tag -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b); - va_end (ap); - s1.a += s2.a; - s1.b += s2.b; - return s1; -} - -int -main (void) -{ - ffi_cif cif; - void* args[5]; - ffi_type* arg_types[5]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - struct small_tag res; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &s_type, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8" } */ - printf("res: %d %d\n", res.a, res.b); - /* { dg-output "\nres: 12 14" } */ - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c b/user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c deleted file mode 100644 index 9a27e7f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.call/va_struct3.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static struct large_tag -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b); - va_end (ap); - l.a += s1.a; - l.b += s1.b; - l.c += s2.a; - l.d += s2.b; - return l; -} - -int -main (void) -{ - ffi_cif cif; - void* args[5]; - ffi_type* arg_types[5]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - struct large_tag res; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &l_type, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8" } */ - printf("res: %d %d %d %d %d\n", res.a, res.b, res.c, res.d, res.e); - /* { dg-output "\nres: 15 17 19 21 14" } */ - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc deleted file mode 100644 index 4a812ed..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex.inc +++ /dev/null @@ -1,91 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include - -typedef struct cls_struct_align { - unsigned char a; - _Complex T_C_TYPE b; - unsigned char c; -} cls_struct_align; - -cls_struct_align cls_struct_align_fn( - struct cls_struct_align a1, struct cls_struct_align a2) -{ - struct cls_struct_align result; - - result.a = a1.a + a2.a; - result.b = a1.b + a2.b; - result.c = a1.c + a2.c; - - printf("%d %f,%fi %d %d %f,%fi %d: %d %f,%fi %d\n", - a1.a, T_CONV creal (a1.b), T_CONV cimag (a1.b), a1.c, - a2.a, T_CONV creal (a2.b), T_CONV cimag (a2.b), a2.c, - result.a, T_CONV creal (result.b), T_CONV cimag (result.b), result.c); - - return result; -} - -static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) -{ - - struct cls_struct_align a1, a2; - - a1 = *(struct cls_struct_align*)(args[0]); - a2 = *(struct cls_struct_align*)(args[1]); - - *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args_c[5]; - ffi_type* cls_struct_fields[4]; - ffi_type cls_struct_type; - ffi_type* c_arg_types[5]; - - struct cls_struct_align g_c = { 12, 4951 + 7 * I, 127 }; - struct cls_struct_align f_c = { 1, 9320 + 1 * I, 13 }; - struct cls_struct_align res_c; - - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - - cls_struct_fields[0] = &ffi_type_uchar; - cls_struct_fields[1] = &T_FFI_TYPE; - cls_struct_fields[2] = &ffi_type_uchar; - cls_struct_fields[3] = NULL; - - c_arg_types[0] = &cls_struct_type; - c_arg_types[1] = &cls_struct_type; - c_arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, - c_arg_types) == FFI_OK); - - args_c[0] = &g_c; - args_c[1] = &f_c; - args_c[2] = NULL; - - ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_c, args_c); - /* { dg-output "12 4951,7i 127 1 9320,1i 13: 13 14271,8i 140" } */ - printf("res: %d %f,%fi %d\n", - res_c.a, T_CONV creal (res_c.b), T_CONV cimag (res_c.b), res_c.c); - /* { dg-output "\nres: 13 14271,8i 140" } */ - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); - - res_c = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_c, f_c); - /* { dg-output "\n12 4951,7i 127 1 9320,1i 13: 13 14271,8i 140" } */ - printf("res: %d %f,%fi %d\n", - res_c.a, T_CONV creal (res_c.b), T_CONV cimag (res_c.b), res_c.c); - /* { dg-output "\nres: 13 14271,8i 140" } */ - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c deleted file mode 100644 index 0dff23a..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "cls_align_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c deleted file mode 100644 index 0affbd0..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "cls_align_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c deleted file mode 100644 index 7889ba8..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check structure alignment of complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "cls_align_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc deleted file mode 100644 index f937404..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex.inc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include - -static void cls_ret_complex_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - _Complex T_C_TYPE *pa; - _Complex T_C_TYPE *pr; - pa = (_Complex T_C_TYPE *)args[0]; - pr = (_Complex T_C_TYPE *)resp; - *pr = *pa; - - printf("%.6f,%.6fi: %.6f,%.6fi\n", - T_CONV creal (*pa), T_CONV cimag (*pa), - T_CONV creal (*pr), T_CONV cimag (*pr)); - } -typedef _Complex T_C_TYPE (*cls_ret_complex)(_Complex T_C_TYPE); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[2]; - _Complex T_C_TYPE res; - - cl_arg_types[0] = &T_FFI_TYPE; - cl_arg_types[1] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &T_FFI_TYPE, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_complex_fn, NULL, code) == FFI_OK); - - res = (*((cls_ret_complex)code))(0.125 + 128.0 * I); - printf("res: %.6f,%.6fi\n", T_CONV creal (res), T_CONV cimag (res)); - CHECK (res == (0.125 + 128.0 * I)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c deleted file mode 100644 index 05e3534..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: closure_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "cls_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c deleted file mode 100644 index 5df7849..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: closure_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "cls_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c deleted file mode 100644 index 2b1c320..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: closure_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "cls_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc deleted file mode 100644 index df8708d..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct.inc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include - -typedef struct Cs { - _Complex T_C_TYPE x; - _Complex T_C_TYPE y; -} Cs; - -Cs gc; - -void -closure_test_fn(Cs p) -{ - printf("%.1f,%.1fi %.1f,%.1fi\n", - T_CONV creal (p.x), T_CONV cimag (p.x), - T_CONV creal (p.y), T_CONV cimag (p.y)); - gc = p; -} - -void -closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, - void** args, void* userdata __UNUSED__) -{ - closure_test_fn(*(Cs*)args[0]); -} - -int main(int argc __UNUSED__, char** argv __UNUSED__) -{ - ffi_cif cif; - - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type *cl_arg_types[1]; - - ffi_type ts1_type; - ffi_type* ts1_type_elements[4]; - - Cs arg = { 1.0 + 11.0 * I, 2.0 + 22.0 * I}; - - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - - ts1_type_elements[0] = &T_FFI_TYPE; - ts1_type_elements[1] = &T_FFI_TYPE; - ts1_type_elements[2] = NULL; - - cl_arg_types[0] = &ts1_type; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ffi_type_void, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK); - - gc.x = 0.0 + 0.0 * I; - gc.y = 0.0 + 0.0 * I; - ((void*(*)(Cs))(code))(arg); - /* { dg-output "1.0,11.0i 2.0,22.0i\n" } */ - CHECK (gc.x == arg.x && gc.y == arg.y); - - gc.x = 0.0 + 0.0 * I; - gc.y = 0.0 + 0.0 * I; - closure_test_fn(arg); - /* { dg-output "1.0,11.0i 2.0,22.0i\n" } */ - CHECK (gc.x == arg.x && gc.y == arg.y); - - return 0; -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c deleted file mode 100644 index ec71346..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check complex arguments in structs. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "cls_complex_struct.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c deleted file mode 100644 index 96fdf75..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check complex arguments in structs. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "cls_complex_struct.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c deleted file mode 100644 index 005b467..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check complex arguments in structs. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "cls_complex_struct.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc deleted file mode 100644 index 8a3e15f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va.inc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include -#include -#include -#include - -static _Complex T_C_TYPE gComplexValue1 = 1 + 2 * I; -static _Complex T_C_TYPE gComplexValue2 = 3 + 4 * I; - -static int cls_variadic(const char *format, ...) -{ - va_list ap; - _Complex T_C_TYPE p1, p2; - - va_start (ap, format); - p1 = va_arg (ap, _Complex T_C_TYPE); - p2 = va_arg (ap, _Complex T_C_TYPE); - va_end (ap); - - return printf(format, T_CONV creal (p1), T_CONV cimag (p1), - T_CONV creal (p2), T_CONV cimag (p2)); -} - -static void -cls_complex_va_fn(ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - char* format = *(char**)args[0]; - gComplexValue1 = *(_Complex T_C_TYPE*)args[1]; - gComplexValue2 = *(_Complex T_C_TYPE*)args[2]; - - *(ffi_arg*)resp = - printf(format, - T_CONV creal (gComplexValue1), T_CONV cimag (gComplexValue1), - T_CONV creal (gComplexValue2), T_CONV cimag (gComplexValue2)); -} - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - void* args[4]; - ffi_type* arg_types[4]; - char *format = "%.1f,%.1fi %.1f,%.1fi\n"; - - _Complex T_C_TYPE complexArg1 = 1.0 + 22.0 *I; - _Complex T_C_TYPE complexArg2 = 333.0 + 4444.0 *I; - ffi_arg res = 0; - - arg_types[0] = &ffi_type_pointer; - arg_types[1] = &T_FFI_TYPE; - arg_types[2] = &T_FFI_TYPE; - arg_types[3] = NULL; - - /* This printf call is variadic */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 3, &ffi_type_sint, - arg_types) == FFI_OK); - - args[0] = &format; - args[1] = &complexArg1; - args[2] = &complexArg2; - args[3] = NULL; - - ffi_call(&cif, FFI_FN(cls_variadic), &res, args); - printf("res: %d\n", (int) res); - CHECK (res == 24); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_complex_va_fn, NULL, code) - == FFI_OK); - - res = ((int(*)(char *, ...))(code))(format, complexArg1, complexArg2); - CHECK (gComplexValue1 == complexArg1); - CHECK (gComplexValue2 == complexArg2); - printf("res: %d\n", (int) res); - CHECK (res == 24); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c deleted file mode 100644 index 879ccf3..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test complex' passed in variable argument lists. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "cls_complex_va.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c deleted file mode 100644 index 2b17826..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_float.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test complex' passed in variable argument lists. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -/* Alpha splits _Complex into two arguments. It's illegal to pass - float through varargs, so _Complex float goes badly. In sort of - gets passed as _Complex double, but the compiler doesn't agree - with itself on this issue. */ -/* { dg-do run { xfail alpha*-*-* } } */ - -#include "complex_defs_float.inc" -#include "cls_complex_va.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c deleted file mode 100644 index 6eca965..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test complex' passed in variable argument lists. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "cls_complex_va.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp b/user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp deleted file mode 100644 index 4631db2..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex.exp +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING3. If not see -# . - -dg-init -libffi-init - -global srcdir subdir - -set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] - -if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } { - run-many-tests $tlist "" -} else { - foreach test $tlist { - unsupported "$test" - } -} - -dg-finish - -# Local Variables: -# tcl-indent-level:4 -# End: diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc deleted file mode 100644 index 515ae3e..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex.inc +++ /dev/null @@ -1,51 +0,0 @@ -/* -*-c-*-*/ -#include "ffitest.h" -#include - -static _Complex T_C_TYPE f_complex(_Complex T_C_TYPE c, int x, int *py) -{ - c = -(2 * creal (c)) + (cimag (c) + 1)* I; - *py += x; - - return c; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - - _Complex T_C_TYPE tc_arg; - _Complex T_C_TYPE tc_result; - int tc_int_arg_x; - int tc_y; - int *tc_ptr_arg_y = &tc_y; - - args[0] = &T_FFI_TYPE; - args[1] = &ffi_type_sint; - args[2] = &ffi_type_pointer; - values[0] = &tc_arg; - values[1] = &tc_int_arg_x; - values[2] = &tc_ptr_arg_y; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, - &T_FFI_TYPE, args) == FFI_OK); - - tc_arg = 1 + 7 * I; - tc_int_arg_x = 1234; - tc_y = 9876; - ffi_call(&cif, FFI_FN(f_complex), &tc_result, values); - - printf ("%f,%fi %f,%fi, x %d 1234, y %d 11110\n", - T_CONV creal (tc_result), T_CONV cimag (tc_result), - T_CONV creal (2.0), T_CONV creal (8.0), tc_int_arg_x, tc_y); - - CHECK (creal (tc_result) == -2); - CHECK (cimag (tc_result) == 8); - CHECK (tc_int_arg_x == 1234); - CHECK (*tc_ptr_arg_y == 11110); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc deleted file mode 100644 index 3583e16..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_double.inc +++ /dev/null @@ -1,7 +0,0 @@ -/* -*-c-*- */ -/* Complex base type. */ -#define T_FFI_TYPE ffi_type_complex_double -/* C type corresponding to the base type. */ -#define T_C_TYPE double -/* C cast for a value of type T_C_TYPE that is passed to printf. */ -#define T_CONV diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc deleted file mode 100644 index bbd9375..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_float.inc +++ /dev/null @@ -1,7 +0,0 @@ -/* -*-c-*- */ -/* Complex base type. */ -#define T_FFI_TYPE ffi_type_complex_float -/* C type corresponding to the base type. */ -#define T_C_TYPE float -/* C cast for a value of type T_C_TYPE that is passed to printf. */ -#define T_CONV (double) diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc deleted file mode 100644 index 14b9f24..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +++ /dev/null @@ -1,7 +0,0 @@ -/* -*-c-*- */ -/* Complex base type. */ -#define T_FFI_TYPE ffi_type_complex_longdouble -/* C type corresponding to the base type. */ -#define T_C_TYPE long double -/* C cast for a value of type T_C_TYPE that is passed to printf. */ -#define T_CONV diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c deleted file mode 100644 index 8a3297b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check complex types. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c deleted file mode 100644 index 5044ebb..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check complex types. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c deleted file mode 100644 index bac3190..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_int.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Area: ffi_call - Purpose: Check non-standard complex types. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "ffitest.h" -#include "ffi.h" -#include - -_Complex int f_complex(_Complex int c, int x, int *py) -{ - __real__ c = -2 * __real__ c; - __imag__ c = __imag__ c + 1; - *py += x; - return c; -} - -/* - * This macro can be used to define new complex type descriptors - * in a platform independent way. - * - * name: Name of the new descriptor is ffi_type_complex_. - * type: The C base type of the complex type. - */ -#define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \ - static ffi_type *ffi_elements_complex_##name [2] = { \ - (ffi_type *)(&ffitype), NULL \ - }; \ - struct struct_align_complex_##name { \ - char c; \ - _Complex type x; \ - }; \ - ffi_type ffi_type_complex_##name = { \ - sizeof(_Complex type), \ - offsetof(struct struct_align_complex_##name, x), \ - FFI_TYPE_COMPLEX, \ - (ffi_type **)ffi_elements_complex_##name \ - } - -/* Define new complex type descriptors using the macro: */ -/* ffi_type_complex_sint */ -FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint); -/* ffi_type_complex_uchar */ -FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8); - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - - _Complex int tc_arg; - _Complex int tc_result; - int tc_int_arg_x; - int tc_y; - int *tc_ptr_arg_y = &tc_y; - - args[0] = &ffi_type_complex_sint; - args[1] = &ffi_type_sint; - args[2] = &ffi_type_pointer; - values[0] = &tc_arg; - values[1] = &tc_int_arg_x; - values[2] = &tc_ptr_arg_y; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &ffi_type_complex_sint, args) - == FFI_OK); - - tc_arg = 1 + 7 * I; - tc_int_arg_x = 1234; - tc_y = 9876; - ffi_call(&cif, FFI_FN(f_complex), &tc_result, values); - - printf ("%d,%di %d,%di, x %d 1234, y %d 11110\n", - (int)tc_result, (int)(tc_result * -I), 2, 8, tc_int_arg_x, tc_y); - /* dg-output "-2,8i 2,8i, x 1234 1234, y 11110 11110" */ - CHECK (creal (tc_result) == -2); - CHECK (cimag (tc_result) == 8); - CHECK (tc_int_arg_x == 1234); - CHECK (*tc_ptr_arg_y == 11110); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c deleted file mode 100644 index 7e78366..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/complex_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check complex types. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h b/user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h deleted file mode 100644 index d27d362..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/ffitest.h +++ /dev/null @@ -1 +0,0 @@ -#include "../libffi.call/ffitest.h" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc deleted file mode 100644 index e37a774..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex.inc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" - -#include -#include - -static _Complex T_C_TYPE many(_Complex T_C_TYPE c1, - _Complex T_C_TYPE c2, - _Complex T_C_TYPE c3, - _Complex T_C_TYPE c4, - _Complex T_C_TYPE c5, - _Complex T_C_TYPE c6, - _Complex T_C_TYPE c7, - _Complex T_C_TYPE c8, - _Complex T_C_TYPE c9, - _Complex T_C_TYPE c10, - _Complex T_C_TYPE c11, - _Complex T_C_TYPE c12, - _Complex T_C_TYPE c13) -{ - printf("0 :%f,%fi\n" - "1 :%f,%fi\n" - "2 :%f,%fi\n" - "3 :%f,%fi\n" - "4 :%f,%fi\n" - "5 :%f,%fi\n" - "6 :%f,%fi\n" - "7 :%f,%fi\n" - "8 :%f,%fi\n" - "9 :%f,%fi\n" - "10:%f,%fi\n" - "11:%f,%fi\n" - "12:%f,%fi\n", - T_CONV creal (c1), T_CONV cimag (c1), - T_CONV creal (c2), T_CONV cimag (c2), - T_CONV creal (c3), T_CONV cimag (c3), - T_CONV creal (c4), T_CONV cimag (c4), - T_CONV creal (c5), T_CONV cimag (c5), - T_CONV creal (c6), T_CONV cimag (c6), - T_CONV creal (c7), T_CONV cimag (c7), - T_CONV creal (c8), T_CONV cimag (c8), - T_CONV creal (c9), T_CONV cimag (c9), - T_CONV creal (c10), T_CONV cimag (c10), - T_CONV creal (c11), T_CONV cimag (c11), - T_CONV creal (c12), T_CONV cimag (c12), - T_CONV creal (c13), T_CONV cimag (c13)); - - return (c1+c2-c3-c4+c5+c6+c7-c8-c9-c10-c11+c12+c13); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[13]; - void *values[13]; - _Complex T_C_TYPE ca[13]; - _Complex T_C_TYPE c, cc; - int i; - - for (i = 0; i < 13; i++) - { - args[i] = &T_FFI_TYPE; - values[i] = &ca[i]; - ca[i] = i + (-20 - i) * I; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, &T_FFI_TYPE, args) == FFI_OK); - - ffi_call(&cif, FFI_FN(many), &c, values); - - cc = many(ca[0], ca[1], ca[2], ca[3], ca[4], ca[5], ca[6], ca[7], ca[8], - ca[9], ca[10], ca[11], ca[12]); - CHECK(creal (cc) == creal (c)); - CHECK(cimag (cc) == cimag (c)); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c deleted file mode 100644 index 3fd53c3..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex, with many arguments - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "many_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c deleted file mode 100644 index c43d21c..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex, with many arguments - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "many_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c deleted file mode 100644 index dbab723..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/many_complex_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex, with many arguments - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "many_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc deleted file mode 100644 index 8bf0c1f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex.inc +++ /dev/null @@ -1,37 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include - -static _Complex T_C_TYPE return_c(_Complex T_C_TYPE c) -{ - printf ("%f,%fi\n", T_CONV creal (c), T_CONV cimag (c)); - return 2 * c; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - _Complex T_C_TYPE c, rc, rc2; - T_C_TYPE cr, ci; - - args[0] = &T_FFI_TYPE; - values[0] = &c; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &T_FFI_TYPE, args) == FFI_OK); - - for (cr = -127.0; cr < 127; cr++) - { - ci = 1000.0 - cr; - c = cr + ci * I; - ffi_call(&cif, FFI_FN(return_c), &rc, values); - rc2 = return_c(c); - printf ("%f,%fi vs %f,%fi\n", - T_CONV creal (rc), T_CONV cimag (rc), - T_CONV creal (rc2), T_CONV cimag (rc2)); - CHECK(rc == 2 * c); - } - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc deleted file mode 100644 index 7cecc0f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1.inc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include - -static _Complex T_C_TYPE return_c(_Complex T_C_TYPE c1, float fl2, unsigned int in3, _Complex T_C_TYPE c4) -{ - return c1 + fl2 + in3 + c4; -} -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - _Complex T_C_TYPE c1, c4, rc, rc2; - float fl2; - unsigned int in3; - args[0] = &T_FFI_TYPE; - args[1] = &ffi_type_float; - args[2] = &ffi_type_uint; - args[3] = &T_FFI_TYPE; - values[0] = &c1; - values[1] = &fl2; - values[2] = &in3; - values[3] = &c4; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &T_FFI_TYPE, args) == FFI_OK); - c1 = 127.0 + 255.0 * I; - fl2 = 128.0; - in3 = 255; - c4 = 512.7 + 1024.1 * I; - - ffi_call(&cif, FFI_FN(return_c), &rc, values); - rc2 = return_c(c1, fl2, in3, c4); - printf ("%f,%fi vs %f,%fi\n", - T_CONV creal (rc), T_CONV cimag (rc), - T_CONV creal (rc2), T_CONV cimag (rc2)); - CHECK(rc == rc2); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c deleted file mode 100644 index 727410d..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "return_complex1.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c deleted file mode 100644 index a2aeada..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "return_complex1.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c deleted file mode 100644 index 103504b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "return_complex1.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc deleted file mode 100644 index 265170b..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2.inc +++ /dev/null @@ -1,44 +0,0 @@ -/* -*-c-*- */ -#include "ffitest.h" -#include - -_Complex T_C_TYPE -return_c(_Complex T_C_TYPE c1, _Complex T_C_TYPE c2, - unsigned int in3, _Complex T_C_TYPE c4) -{ - volatile _Complex T_C_TYPE r = c1 + c2 + in3 + c4; - return r; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - _Complex T_C_TYPE c1, c2, c4, rc, rc2; - unsigned int in3; - args[0] = &T_FFI_TYPE; - args[1] = &T_FFI_TYPE; - args[2] = &ffi_type_uint; - args[3] = &T_FFI_TYPE; - values[0] = &c1; - values[1] = &c2; - values[2] = &in3; - values[3] = &c4; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, - &T_FFI_TYPE, args) == FFI_OK); - c1 = 127.0 + 255.0 * I; - c2 = 128.0 + 256.0; - in3 = 255; - c4 = 512.7 + 1024.1 * I; - - ffi_call(&cif, FFI_FN(return_c), &rc, values); - rc2 = return_c(c1, c2, in3, c4); - printf ("%f,%fi vs %f,%fi\n", - T_CONV creal (rc), T_CONV cimag (rc), - T_CONV creal (rc2), T_CONV cimag (rc2)); - CHECK(rc == rc2); - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c deleted file mode 100644 index ab9efac..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "return_complex2.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c deleted file mode 100644 index d7f22c2..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "return_complex2.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c deleted file mode 100644 index 3edea62..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "return_complex2.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c deleted file mode 100644 index e2497cc..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_double.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_double.inc" -#include "return_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c deleted file mode 100644 index a35528f..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_float.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_float.inc" -#include "return_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c b/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c deleted file mode 100644 index 142d7be..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.complex/return_complex_longdouble.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Area: ffi_call - Purpose: Check return value complex. - Limitations: none. - PR: none. - Originator: . */ - -/* { dg-do run } */ - -#include "complex_defs_longdouble.inc" -#include "return_complex.inc" diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c b/user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c deleted file mode 100644 index b00c404..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.go/aa-direct.c +++ /dev/null @@ -1,34 +0,0 @@ -/* { dg-do run } */ - -#include "static-chain.h" - -#if defined(__GNUC__) && !defined(__clang__) && defined(STATIC_CHAIN_REG) - -#include "ffitest.h" - -/* Blatent assumption here that the prologue doesn't clobber the - static chain for trivial functions. If this is not true, don't - define STATIC_CHAIN_REG, and we'll test what we can via other tests. */ -void *doit(void) -{ - register void *chain __asm__(STATIC_CHAIN_REG); - return chain; -} - -int main() -{ - ffi_cif cif; - void *result; - - CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK); - - ffi_call_go(&cif, FFI_FN(doit), &result, NULL, &result); - - CHECK(result == &result); - - return 0; -} - -#else /* UNSUPPORTED */ -int main() { return 0; } -#endif diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/closure1.c b/user/mpy/lib/libffi/testsuite/libffi.go/closure1.c deleted file mode 100644 index 7b34afc..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.go/closure1.c +++ /dev/null @@ -1,28 +0,0 @@ -/* { dg-do run } */ - -#include "ffitest.h" - -void doit(ffi_cif *cif, void *rvalue, void **avalue, void *closure) -{ - (void)cif; - (void)avalue; - *(void **)rvalue = closure; -} - -typedef void * (*FN)(void); - -int main() -{ - ffi_cif cif; - ffi_go_closure cl; - void *result; - - CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK); - CHECK(ffi_prep_go_closure(&cl, &cif, doit) == FFI_OK); - - ffi_call_go(&cif, FFI_FN(*(FN *)&cl), &result, NULL, &cl); - - CHECK(result == &cl); - - exit(0); -} diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h b/user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h deleted file mode 100644 index d27d362..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.go/ffitest.h +++ /dev/null @@ -1 +0,0 @@ -#include "../libffi.call/ffitest.h" diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/go.exp b/user/mpy/lib/libffi/testsuite/libffi.go/go.exp deleted file mode 100644 index 100c5e7..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.go/go.exp +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING3. If not see -# . - -dg-init -libffi-init - -global srcdir subdir - -set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] - -if { [libffi_feature_test "#ifdef FFI_GO_CLOSURES"] } { - run-many-tests $tlist "" -} else { - foreach test $tlist { - unsupported "$test" - } -} - -dg-finish - -# Local Variables: -# tcl-indent-level:4 -# End: diff --git a/user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h b/user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h deleted file mode 100644 index 3675b40..0000000 --- a/user/mpy/lib/libffi/testsuite/libffi.go/static-chain.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef __aarch64__ -# define STATIC_CHAIN_REG "x18" -#elif defined(__alpha__) -# define STATIC_CHAIN_REG "$1" -#elif defined(__arm__) -# define STATIC_CHAIN_REG "ip" -#elif defined(__sparc__) -# if defined(__arch64__) || defined(__sparcv9) -# define STATIC_CHAIN_REG "g5" -# else -# define STATIC_CHAIN_REG "g2" -# endif -#elif defined(__x86_64__) -# define STATIC_CHAIN_REG "r10" -#elif defined(__i386__) -# ifndef ABI_NUM -# define STATIC_CHAIN_REG "ecx" /* FFI_DEFAULT_ABI only */ -# endif -#endif diff --git a/user/mpy/lib/libffi/texinfo.tex b/user/mpy/lib/libffi/texinfo.tex deleted file mode 100644 index 85f184c..0000000 --- a/user/mpy/lib/libffi/texinfo.tex +++ /dev/null @@ -1,10079 +0,0 @@ -% texinfo.tex -- TeX macros to handle Texinfo files. -% -% Load plain if necessary, i.e., if running under initex. -\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi -% -\def\texinfoversion{2013-02-01.11} -% -% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, -% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -% 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. -% -% This texinfo.tex file is free software: you can redistribute it and/or -% modify it under the terms of the GNU General Public License as -% published by the Free Software Foundation, either version 3 of the -% License, or (at your option) any later version. -% -% This texinfo.tex file is distributed in the hope that it will be -% useful, but WITHOUT ANY WARRANTY; without even the implied warranty -% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -% General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this program. If not, see . -% -% As a special exception, when this file is read by TeX when processing -% a Texinfo source document, you may use the result without -% restriction. This Exception is an additional permission under section 7 -% of the GNU General Public License, version 3 ("GPLv3"). -% -% Please try the latest version of texinfo.tex before submitting bug -% reports; you can get the latest version from: -% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or -% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or -% http://www.gnu.org/software/texinfo/ (the Texinfo home page) -% The texinfo.tex in any given distribution could well be out -% of date, so if that's what you're using, please check. -% -% Send bug reports to bug-texinfo@gnu.org. Please include including a -% complete document in each bug report with which we can reproduce the -% problem. Patches are, of course, greatly appreciated. -% -% To process a Texinfo manual with TeX, it's most reliable to use the -% texi2dvi shell script that comes with the distribution. For a simple -% manual foo.texi, however, you can get away with this: -% tex foo.texi -% texindex foo.?? -% tex foo.texi -% tex foo.texi -% dvips foo.dvi -o # or whatever; this makes foo.ps. -% The extra TeX runs get the cross-reference information correct. -% Sometimes one run after texindex suffices, and sometimes you need more -% than two; texi2dvi does it as many times as necessary. -% -% It is possible to adapt texinfo.tex for other languages, to some -% extent. You can get the existing language-specific files from the -% full Texinfo distribution. -% -% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. - - -\message{Loading texinfo [version \texinfoversion]:} - -% If in a .fmt file, print the version number -% and turn on active characters that we couldn't do earlier because -% they might have appeared in the input file name. -\everyjob{\message{[Texinfo version \texinfoversion]}% - \catcode`+=\active \catcode`\_=\active} - -\chardef\other=12 - -% We never want plain's \outer definition of \+ in Texinfo. -% For @tex, we can use \tabalign. -\let\+ = \relax - -% Save some plain tex macros whose names we will redefine. -\let\ptexb=\b -\let\ptexbullet=\bullet -\let\ptexc=\c -\let\ptexcomma=\, -\let\ptexdot=\. -\let\ptexdots=\dots -\let\ptexend=\end -\let\ptexequiv=\equiv -\let\ptexexclam=\! -\let\ptexfootnote=\footnote -\let\ptexgtr=> -\let\ptexhat=^ -\let\ptexi=\i -\let\ptexindent=\indent -\let\ptexinsert=\insert -\let\ptexlbrace=\{ -\let\ptexless=< -\let\ptexnewwrite\newwrite -\let\ptexnoindent=\noindent -\let\ptexplus=+ -\let\ptexraggedright=\raggedright -\let\ptexrbrace=\} -\let\ptexslash=\/ -\let\ptexstar=\* -\let\ptext=\t -\let\ptextop=\top -{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Pre-3.0. -\else - \def\linenumber{l.\the\inputlineno:\space} -\fi - -% Set up fixed words for English if not already set. -\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi -\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi -\ifx\putworderror\undefined \gdef\putworderror{error}\fi -\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi -\ifx\putwordin\undefined \gdef\putwordin{in}\fi -\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi -\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi -\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi -\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi -\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi -\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi -\ifx\putwordof\undefined \gdef\putwordof{of}\fi -\ifx\putwordon\undefined \gdef\putwordon{on}\fi -\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi -\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi -\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi -\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi -\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi -\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi -\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi -% -\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi -\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi -\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi -\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi -\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi -\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi -\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi -\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi -\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi -\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi -\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi -\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi -% -\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi -\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi -\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi -\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi -\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi - -% Since the category of space is not known, we have to be careful. -\chardef\spacecat = 10 -\def\spaceisspace{\catcode`\ =\spacecat} - -% sometimes characters are active, so we need control sequences. -\chardef\ampChar = `\& -\chardef\colonChar = `\: -\chardef\commaChar = `\, -\chardef\dashChar = `\- -\chardef\dotChar = `\. -\chardef\exclamChar= `\! -\chardef\hashChar = `\# -\chardef\lquoteChar= `\` -\chardef\questChar = `\? -\chardef\rquoteChar= `\' -\chardef\semiChar = `\; -\chardef\slashChar = `\/ -\chardef\underChar = `\_ - -% Ignore a token. -% -\def\gobble#1{} - -% The following is used inside several \edef's. -\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} - -% Hyphenation fixes. -\hyphenation{ - Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script - ap-pen-dix bit-map bit-maps - data-base data-bases eshell fall-ing half-way long-est man-u-script - man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm - par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces - spell-ing spell-ings - stand-alone strong-est time-stamp time-stamps which-ever white-space - wide-spread wrap-around -} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen\bindingoffset -\newdimen\normaloffset -\newdimen\pagewidth \newdimen\pageheight - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt } - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. We also make -% some effort to order the tracing commands to reduce output in the log -% file; cf. trace.sty in LaTeX. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\def\loggingall{% - \tracingstats2 - \tracingpages1 - \tracinglostchars2 % 2 gives us more in etex - \tracingparagraphs1 - \tracingoutput1 - \tracingmacros2 - \tracingrestores1 - \showboxbreadth\maxdimen \showboxdepth\maxdimen - \ifx\eTeXversion\thisisundefined\else % etex gives us more logging - \tracingscantokens1 - \tracingifs1 - \tracinggroups1 - \tracingnesting2 - \tracingassigns1 - \fi - \tracingcommands3 % 3 gives us more in etex - \errorcontextlines16 -}% - -% @errormsg{MSG}. Do the index-like expansions on MSG, but if things -% aren't perfect, it's not the end of the world, being an error message, -% after all. -% -\def\errormsg{\begingroup \indexnofonts \doerrormsg} -\def\doerrormsg#1{\errmessage{#1}} - -% add check for \lastpenalty to plain's definitions. If the last thing -% we did was a \nobreak, we don't want to insert more space. -% -\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount - \removelastskip\penalty-50\smallskip\fi\fi} -\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount - \removelastskip\penalty-100\medskip\fi\fi} -\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount - \removelastskip\penalty-200\bigskip\fi\fi} - -% Do @cropmarks to get crop marks. -% -\newif\ifcropmarks -\let\cropmarks = \cropmarkstrue -% -% Dimensions to add cropmarks at corners. -% Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines -\newdimen\cornerlong \cornerlong=1pc -\newdimen\cornerthick \cornerthick=.3pt -\newdimen\topandbottommargin \topandbottommargin=.75in - -% Output a mark which sets \thischapter, \thissection and \thiscolor. -% We dump everything together because we only have one kind of mark. -% This works because we only use \botmark / \topmark, not \firstmark. -% -% A mark contains a subexpression of the \ifcase ... \fi construct. -% \get*marks macros below extract the needed part using \ifcase. -% -% Another complication is to let the user choose whether \thischapter -% (\thissection) refers to the chapter (section) in effect at the top -% of a page, or that at the bottom of a page. The solution is -% described on page 260 of The TeXbook. It involves outputting two -% marks for the sectioning macros, one before the section break, and -% one after. I won't pretend I can describe this better than DEK... -\def\domark{% - \toks0=\expandafter{\lastchapterdefs}% - \toks2=\expandafter{\lastsectiondefs}% - \toks4=\expandafter{\prevchapterdefs}% - \toks6=\expandafter{\prevsectiondefs}% - \toks8=\expandafter{\lastcolordefs}% - \mark{% - \the\toks0 \the\toks2 - \noexpand\or \the\toks4 \the\toks6 - \noexpand\else \the\toks8 - }% -} -% \topmark doesn't work for the very first chapter (after the title -% page or the contents), so we use \firstmark there -- this gets us -% the mark with the chapter defs, unless the user sneaks in, e.g., -% @setcolor (or @url, or @link, etc.) between @contents and the very -% first @chapter. -\def\gettopheadingmarks{% - \ifcase0\topmark\fi - \ifx\thischapter\empty \ifcase0\firstmark\fi \fi -} -\def\getbottomheadingmarks{\ifcase1\botmark\fi} -\def\getcolormarks{\ifcase2\topmark\fi} - -% Avoid "undefined control sequence" errors. -\def\lastchapterdefs{} -\def\lastsectiondefs{} -\def\prevchapterdefs{} -\def\prevsectiondefs{} -\def\lastcolordefs{} - -% Main output routine. -\chardef\PAGE = 255 -\output = {\onepageout{\pagecontents\PAGE}} - -\newbox\headlinebox -\newbox\footlinebox - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions, but you have to call it yourself. -\def\onepageout#1{% - \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi - % - \ifodd\pageno \advance\hoffset by \bindingoffset - \else \advance\hoffset by -\bindingoffset\fi - % - % Do this outside of the \shipout so @code etc. will be expanded in - % the headline as they should be, not taken literally (outputting ''code). - \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi - \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% - \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi - \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% - % - {% - % Have to do this stuff outside the \shipout because we want it to - % take effect in \write's, yet the group defined by the \vbox ends - % before the \shipout runs. - % - \indexdummies % don't expand commands in the output. - \normalturnoffactive % \ in index entries must not stay \, e.g., if - % the page break happens to be in the middle of an example. - % We don't want .vr (or whatever) entries like this: - % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} - % "\acronym" won't work when it's read back in; - % it needs to be - % {\code {{\tt \backslashcurfont }acronym} - \shipout\vbox{% - % Do this early so pdf references go to the beginning of the page. - \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi - % - \ifcropmarks \vbox to \outervsize\bgroup - \hsize = \outerhsize - \vskip-\topandbottommargin - \vtop to0pt{% - \line{\ewtop\hfil\ewtop}% - \nointerlineskip - \line{% - \vbox{\moveleft\cornerthick\nstop}% - \hfill - \vbox{\moveright\cornerthick\nstop}% - }% - \vss}% - \vskip\topandbottommargin - \line\bgroup - \hfil % center the page within the outer (page) hsize. - \ifodd\pageno\hskip\bindingoffset\fi - \vbox\bgroup - \fi - % - \unvbox\headlinebox - \pagebody{#1}% - \ifdim\ht\footlinebox > 0pt - % Only leave this space if the footline is nonempty. - % (We lessened \vsize for it in \oddfootingyyy.) - % The \baselineskip=24pt in plain's \makefootline has no effect. - \vskip 24pt - \unvbox\footlinebox - \fi - % - \ifcropmarks - \egroup % end of \vbox\bgroup - \hfil\egroup % end of (centering) \line\bgroup - \vskip\topandbottommargin plus1fill minus1fill - \boxmaxdepth = \cornerthick - \vbox to0pt{\vss - \line{% - \vbox{\moveleft\cornerthick\nsbot}% - \hfill - \vbox{\moveright\cornerthick\nsbot}% - }% - \nointerlineskip - \line{\ewbot\hfil\ewbot}% - }% - \egroup % \vbox from first cropmarks clause - \fi - }% end of \shipout\vbox - }% end of group with \indexdummies - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi -} - -\newinsert\margin \dimen\margin=\maxdimen - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -% marginal hacks, juha@viisa.uucp (Juha Takala) -\ifvoid\margin\else % marginal info is present - \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi -\dimen@=\dp#1\relax \unvbox#1\relax -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. The argument is the rest of -% the input line (except we remove a trailing comment). #1 should be a -% macro which expects an ordinary undelimited TeX argument. -% -\def\parsearg{\parseargusing{}} -\def\parseargusing#1#2{% - \def\argtorun{#2}% - \begingroup - \obeylines - \spaceisspace - #1% - \parseargline\empty% Insert the \empty token, see \finishparsearg below. -} - -{\obeylines % - \gdef\parseargline#1^^M{% - \endgroup % End of the group started in \parsearg. - \argremovecomment #1\comment\ArgTerm% - }% -} - -% First remove any @comment, then any @c comment. -\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} -\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} - -% Each occurrence of `\^^M' or `\^^M' is replaced by a single space. -% -% \argremovec might leave us with trailing space, e.g., -% @end itemize @c foo -% This space token undergoes the same procedure and is eventually removed -% by \finishparsearg. -% -\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} -\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} -\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% - \def\temp{#3}% - \ifx\temp\empty - % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: - \let\temp\finishparsearg - \else - \let\temp\argcheckspaces - \fi - % Put the space token in: - \temp#1 #3\ArgTerm -} - -% If a _delimited_ argument is enclosed in braces, they get stripped; so -% to get _exactly_ the rest of the line, we had to prevent such situation. -% We prepended an \empty token at the very beginning and we expand it now, -% just before passing the control to \argtorun. -% (Similarly, we have to think about #3 of \argcheckspacesY above: it is -% either the null string, or it ends with \^^M---thus there is no danger -% that a pair of braces would be stripped. -% -% But first, we have to remove the trailing space token. -% -\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} - -% \parseargdef\foo{...} -% is roughly equivalent to -% \def\foo{\parsearg\Xfoo} -% \def\Xfoo#1{...} -% -% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my -% favourite TeX trick. --kasal, 16nov03 - -\def\parseargdef#1{% - \expandafter \doparseargdef \csname\string#1\endcsname #1% -} -\def\doparseargdef#1#2{% - \def#2{\parsearg#1}% - \def#1##1% -} - -% Several utility definitions with active space: -{ - \obeyspaces - \gdef\obeyedspace{ } - - % Make each space character in the input produce a normal interword - % space in the output. Don't allow a line break at this space, as this - % is used only in environments like @example, where each line of input - % should produce a line of output anyway. - % - \gdef\sepspaces{\obeyspaces\let =\tie} - - % If an index command is used in an @example environment, any spaces - % therein should become regular spaces in the raw index file, not the - % expansion of \tie (\leavevmode \penalty \@M \ ). - \gdef\unsepspaces{\let =\space} -} - - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -% Define the framework for environments in texinfo.tex. It's used like this: -% -% \envdef\foo{...} -% \def\Efoo{...} -% -% It's the responsibility of \envdef to insert \begingroup before the -% actual body; @end closes the group after calling \Efoo. \envdef also -% defines \thisenv, so the current environment is known; @end checks -% whether the environment name matches. The \checkenv macro can also be -% used to check whether the current environment is the one expected. -% -% Non-false conditionals (@iftex, @ifset) don't fit into this, so they -% are not treated as environments; they don't open a group. (The -% implementation of @end takes care not to call \endgroup in this -% special case.) - - -% At run-time, environments start with this: -\def\startenvironment#1{\begingroup\def\thisenv{#1}} -% initialize -\let\thisenv\empty - -% ... but they get defined via ``\envdef\foo{...}'': -\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} -\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} - -% Check whether we're in the right environment: -\def\checkenv#1{% - \def\temp{#1}% - \ifx\thisenv\temp - \else - \badenverr - \fi -} - -% Environment mismatch, #1 expected: -\def\badenverr{% - \errhelp = \EMsimple - \errmessage{This command can appear only \inenvironment\temp, - not \inenvironment\thisenv}% -} -\def\inenvironment#1{% - \ifx#1\empty - outside of any environment% - \else - in environment \expandafter\string#1% - \fi -} - -% @end foo executes the definition of \Efoo. -% But first, it executes a specialized version of \checkenv -% -\parseargdef\end{% - \if 1\csname iscond.#1\endcsname - \else - % The general wording of \badenverr may not be ideal. - \expandafter\checkenv\csname#1\endcsname - \csname E#1\endcsname - \endgroup - \fi -} - -\newhelp\EMsimple{Press RETURN to continue.} - - -% Be sure we're in horizontal mode when doing a tie, since we make space -% equivalent to this in @example-like environments. Otherwise, a space -% at the beginning of a line will start with \penalty -- and -% since \penalty is valid in vertical mode, we'd end up putting the -% penalty on the vertical list instead of in the new paragraph. -{\catcode`@ = 11 - % Avoid using \@M directly, because that causes trouble - % if the definition is written into an index file. - \global\let\tiepenalty = \@M - \gdef\tie{\leavevmode\penalty\tiepenalty\ } -} - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\unskip\hfil\break\hbox{}\ignorespaces} - -% @/ allows a line break. -\let\/=\allowbreak - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=\endofsentencespacefactor\space} - -% @! is an end-of-sentence bang. -\def\!{!\spacefactor=\endofsentencespacefactor\space} - -% @? is an end-of-sentence query. -\def\?{?\spacefactor=\endofsentencespacefactor\space} - -% @frenchspacing on|off says whether to put extra space after punctuation. -% -\def\onword{on} -\def\offword{off} -% -\parseargdef\frenchspacing{% - \def\temp{#1}% - \ifx\temp\onword \plainfrenchspacing - \else\ifx\temp\offword \plainnonfrenchspacing - \else - \errhelp = \EMsimple - \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% - \fi\fi -} - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -% Another complication is that the group might be very large. This can -% cause the glue on the previous page to be unduly stretched, because it -% does not have much material. In this case, it's better to add an -% explicit \vfill so that the extra space is at the bottom. The -% threshold for doing this is if the group is more than \vfilllimit -% percent of a page (\vfilllimit can be changed inside of @tex). -% -\newbox\groupbox -\def\vfilllimit{0.7} -% -\envdef\group{% - \ifnum\catcode`\^^M=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - \startsavinginserts - % - \setbox\groupbox = \vtop\bgroup - % Do @comment since we are called inside an environment such as - % @example, where each end-of-line in the input causes an - % end-of-line in the output. We don't want the end-of-line after - % the `@group' to put extra space in the output. Since @group - % should appear on a line by itself (according to the Texinfo - % manual), we don't worry about eating any user text. - \comment -} -% -% The \vtop produces a box with normal height and large depth; thus, TeX puts -% \baselineskip glue before it, and (when the next line of text is done) -% \lineskip glue after it. Thus, space below is not quite equal to space -% above. But it's pretty close. -\def\Egroup{% - % To get correct interline space between the last line of the group - % and the first line afterwards, we have to propagate \prevdepth. - \endgraf % Not \par, as it may have been set to \lisppar. - \global\dimen1 = \prevdepth - \egroup % End the \vtop. - % \dimen0 is the vertical size of the group's box. - \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox - % \dimen2 is how much space is left on the page (more or less). - \dimen2 = \pageheight \advance\dimen2 by -\pagetotal - % if the group doesn't fit on the current page, and it's a big big - % group, force a page break. - \ifdim \dimen0 > \dimen2 - \ifdim \pagetotal < \vfilllimit\pageheight - \page - \fi - \fi - \box\groupbox - \prevdepth = \dimen1 - \checkinserts -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -\parseargdef\need{% - % Ensure vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % If the @need value is less than one line space, it's useless. - \dimen0 = #1\mil - \dimen2 = \ht\strutbox - \advance\dimen2 by \dp\strutbox - \ifdim\dimen0 > \dimen2 - % - % Do a \strut just to make the height of this box be normal, so the - % normal leading is inserted relative to the preceding line. - % And a page break here is fine. - \vtop to #1\mil{\strut\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak - \fi -} - -% @br forces paragraph break (and is undocumented). - -\let\br = \par - -% @page forces the start of a new page. -% -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} - -% This defn is used inside nofill environments such as @example. -\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount - \leftline{\hskip\leftskip{\rm#1}}}} - -% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current -% paragraph. For more general purposes, use the \margin insertion -% class. WHICH is `l' or `r'. Not documented, written for gawk manual. -% -\newskip\inmarginspacing \inmarginspacing=1cm -\def\strutdepth{\dp\strutbox} -% -\def\doinmargin#1#2{\strut\vadjust{% - \nobreak - \kern-\strutdepth - \vtop to \strutdepth{% - \baselineskip=\strutdepth - \vss - % if you have multiple lines of stuff to put here, you'll need to - % make the vbox yourself of the appropriate size. - \ifx#1l% - \llap{\ignorespaces #2\hskip\inmarginspacing}% - \else - \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% - \fi - \null - }% -}} -\def\inleftmargin{\doinmargin l} -\def\inrightmargin{\doinmargin r} -% -% @inmargin{TEXT [, RIGHT-TEXT]} -% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; -% else use TEXT for both). -% -\def\inmargin#1{\parseinmargin #1,,\finish} -\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \def\lefttext{#1}% have both texts - \def\righttext{#2}% - \else - \def\lefttext{#1}% have only one text - \def\righttext{#1}% - \fi - % - \ifodd\pageno - \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin - \else - \def\temp{\inleftmargin\lefttext}% - \fi - \temp -} - -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). This command -% is not documented, not supported, and doesn't work. -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% @include FILE -- \input text of FILE. -% -\def\include{\parseargusing\filenamecatcodes\includezzz} -\def\includezzz#1{% - \pushthisfilestack - \def\thisfile{#1}% - {% - \makevalueexpandable % we want to expand any @value in FILE. - \turnoffactive % and allow special characters in the expansion - \indexnofonts % Allow `@@' and other weird things in file names. - \wlog{texinfo.tex: doing @include of #1^^J}% - \edef\temp{\noexpand\input #1 }% - % - % This trickery is to read FILE outside of a group, in case it makes - % definitions, etc. - \expandafter - }\temp - \popthisfilestack -} -\def\filenamecatcodes{% - \catcode`\\=\other - \catcode`~=\other - \catcode`^=\other - \catcode`_=\other - \catcode`|=\other - \catcode`<=\other - \catcode`>=\other - \catcode`+=\other - \catcode`-=\other - \catcode`\`=\other - \catcode`\'=\other -} - -\def\pushthisfilestack{% - \expandafter\pushthisfilestackX\popthisfilestack\StackTerm -} -\def\pushthisfilestackX{% - \expandafter\pushthisfilestackY\thisfile\StackTerm -} -\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% - \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% -} - -\def\popthisfilestack{\errthisfilestackempty} -\def\errthisfilestackempty{\errmessage{Internal error: - the stack of filenames is empty.}} -% -\def\thisfile{} - -% @center line -% outputs that line, centered. -% -\parseargdef\center{% - \ifhmode - \let\centersub\centerH - \else - \let\centersub\centerV - \fi - \centersub{\hfil \ignorespaces#1\unskip \hfil}% - \let\centersub\relax % don't let the definition persist, just in case -} -\def\centerH#1{{% - \hfil\break - \advance\hsize by -\leftskip - \advance\hsize by -\rightskip - \line{#1}% - \break -}} -% -\newcount\centerpenalty -\def\centerV#1{% - % The idea here is the same as in \startdefun, \cartouche, etc.: if - % @center is the first thing after a section heading, we need to wipe - % out the negative parskip inserted by \sectionheading, but still - % prevent a page break here. - \centerpenalty = \lastpenalty - \ifnum\centerpenalty>10000 \vskip\parskip \fi - \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi - \line{\kern\leftskip #1\kern\rightskip}% -} - -% @sp n outputs n lines of vertical space -% -\parseargdef\sp{\vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment -% -\def\comment{\begingroup \catcode`\^^M=\other% -\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% -\commentxxx} -{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} -% -\let\c=\comment - -% @paragraphindent NCHARS -% We'll use ems for NCHARS, close enough. -% NCHARS can also be the word `asis' or `none'. -% We cannot feasibly implement @paragraphindent asis, though. -% -\def\asisword{asis} % no translation, these are keywords -\def\noneword{none} -% -\parseargdef\paragraphindent{% - \def\temp{#1}% - \ifx\temp\asisword - \else - \ifx\temp\noneword - \defaultparindent = 0pt - \else - \defaultparindent = #1em - \fi - \fi - \parindent = \defaultparindent -} - -% @exampleindent NCHARS -% We'll use ems for NCHARS like @paragraphindent. -% It seems @exampleindent asis isn't necessary, but -% I preserve it to make it similar to @paragraphindent. -\parseargdef\exampleindent{% - \def\temp{#1}% - \ifx\temp\asisword - \else - \ifx\temp\noneword - \lispnarrowing = 0pt - \else - \lispnarrowing = #1em - \fi - \fi -} - -% @firstparagraphindent WORD -% If WORD is `none', then suppress indentation of the first paragraph -% after a section heading. If WORD is `insert', then do indent at such -% paragraphs. -% -% The paragraph indentation is suppressed or not by calling -% \suppressfirstparagraphindent, which the sectioning commands do. -% We switch the definition of this back and forth according to WORD. -% By default, we suppress indentation. -% -\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} -\def\insertword{insert} -% -\parseargdef\firstparagraphindent{% - \def\temp{#1}% - \ifx\temp\noneword - \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent - \else\ifx\temp\insertword - \let\suppressfirstparagraphindent = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @firstparagraphindent option `\temp'}% - \fi\fi -} - -% Here is how we actually suppress indentation. Redefine \everypar to -% \kern backwards by \parindent, and then reset itself to empty. -% -% We also make \indent itself not actually do anything until the next -% paragraph. -% -\gdef\dosuppressfirstparagraphindent{% - \gdef\indent{% - \restorefirstparagraphindent - \indent - }% - \gdef\noindent{% - \restorefirstparagraphindent - \noindent - }% - \global\everypar = {% - \kern -\parindent - \restorefirstparagraphindent - }% -} - -\gdef\restorefirstparagraphindent{% - \global \let \indent = \ptexindent - \global \let \noindent = \ptexnoindent - \global \everypar = {}% -} - - -% @refill is a no-op. -\let\refill=\relax - -% If working on a large document in chapters, it is convenient to -% be able to disable indexing, cross-referencing, and contents, for test runs. -% This is done with @novalidate (before @setfilename). -% -\newif\iflinks \linkstrue % by default we want the aux files. -\let\novalidate = \linksfalse - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \iflinks - \tryauxfile - % Open the new aux file. TeX will close it automatically at exit. - \immediate\openout\auxfile=\jobname.aux - \fi % \openindices needs to do some work in any case. - \openindices - \let\setfilename=\comment % Ignore extra @setfilename cmds. - % - % If texinfo.cnf is present on the system, read it. - % Useful for site-wide @afourpaper, etc. - \openin 1 texinfo.cnf - \ifeof 1 \else \input texinfo.cnf \fi - \closein 1 - % - \comment % Ignore the actual filename. -} - -% Called from \setfilename. -% -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% @bye. -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - - -\message{pdf,} -% adobe `portable' document format -\newcount\tempnum -\newcount\lnkcount -\newtoks\filename -\newcount\filenamelength -\newcount\pgn -\newtoks\toksA -\newtoks\toksB -\newtoks\toksC -\newtoks\toksD -\newbox\boxA -\newcount\countA -\newif\ifpdf -\newif\ifpdfmakepagedest - -% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 -% can be set). So we test for \relax and 0 as well as being undefined. -\ifx\pdfoutput\thisisundefined -\else - \ifx\pdfoutput\relax - \else - \ifcase\pdfoutput - \else - \pdftrue - \fi - \fi -\fi - -% PDF uses PostScript string constants for the names of xref targets, -% for display in the outlines, and in other places. Thus, we have to -% double any backslashes. Otherwise, a name like "\node" will be -% interpreted as a newline (\n), followed by o, d, e. Not good. -% -% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and -% related messages. The final outcome is that it is up to the TeX user -% to double the backslashes and otherwise make the string valid, so -% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to -% do this reliably, so we use it. - -% #1 is a control sequence in which to do the replacements, -% which we \xdef. -\def\txiescapepdf#1{% - \ifx\pdfescapestring\thisisundefined - % No primitive available; should we give a warning or log? - % Many times it won't matter. - \else - % The expandable \pdfescapestring primitive escapes parentheses, - % backslashes, and other special chars. - \xdef#1{\pdfescapestring{#1}}% - \fi -} - -\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images -with PDF output, and none of those formats could be found. (.eps cannot -be supported due to the design of the PDF format; use regular TeX (DVI -output) for that.)} - -\ifpdf - % - % Color manipulation macros based on pdfcolor.tex, - % except using rgb instead of cmyk; the latter is said to render as a - % very dark gray on-screen and a very dark halftone in print, instead - % of actual black. - \def\rgbDarkRed{0.50 0.09 0.12} - \def\rgbBlack{0 0 0} - % - % k sets the color for filling (usual text, etc.); - % K sets the color for stroking (thin rules, e.g., normal _'s). - \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} - % - % Set color, and create a mark which defines \thiscolor accordingly, - % so that \makeheadline knows which color to restore. - \def\setcolor#1{% - \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% - \domark - \pdfsetcolor{#1}% - } - % - \def\maincolor{\rgbBlack} - \pdfsetcolor{\maincolor} - \edef\thiscolor{\maincolor} - \def\lastcolordefs{} - % - \def\makefootline{% - \baselineskip24pt - \line{\pdfsetcolor{\maincolor}\the\footline}% - } - % - \def\makeheadline{% - \vbox to 0pt{% - \vskip-22.5pt - \line{% - \vbox to8.5pt{}% - % Extract \thiscolor definition from the marks. - \getcolormarks - % Typeset the headline with \maincolor, then restore the color. - \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% - }% - \vss - }% - \nointerlineskip - } - % - % - \pdfcatalog{/PageMode /UseOutlines} - % - % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). - \def\dopdfimage#1#2#3{% - \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% - \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% - % - % pdftex (and the PDF format) support .pdf, .png, .jpg (among - % others). Let's try in that order, PDF first since if - % someone has a scalable image, presumably better to use that than a - % bitmap. - \let\pdfimgext=\empty - \begingroup - \openin 1 #1.pdf \ifeof 1 - \openin 1 #1.PDF \ifeof 1 - \openin 1 #1.png \ifeof 1 - \openin 1 #1.jpg \ifeof 1 - \openin 1 #1.jpeg \ifeof 1 - \openin 1 #1.JPG \ifeof 1 - \errhelp = \nopdfimagehelp - \errmessage{Could not find image file #1 for pdf}% - \else \gdef\pdfimgext{JPG}% - \fi - \else \gdef\pdfimgext{jpeg}% - \fi - \else \gdef\pdfimgext{jpg}% - \fi - \else \gdef\pdfimgext{png}% - \fi - \else \gdef\pdfimgext{PDF}% - \fi - \else \gdef\pdfimgext{pdf}% - \fi - \closein 1 - \endgroup - % - % without \immediate, ancient pdftex seg faults when the same image is - % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) - \ifnum\pdftexversion < 14 - \immediate\pdfimage - \else - \immediate\pdfximage - \fi - \ifdim \wd0 >0pt width \pdfimagewidth \fi - \ifdim \wd2 >0pt height \pdfimageheight \fi - \ifnum\pdftexversion<13 - #1.\pdfimgext - \else - {#1.\pdfimgext}% - \fi - \ifnum\pdftexversion < 14 \else - \pdfrefximage \pdflastximage - \fi} - % - \def\pdfmkdest#1{{% - % We have to set dummies so commands such as @code, and characters - % such as \, aren't expanded when present in a section title. - \indexnofonts - \turnoffactive - \makevalueexpandable - \def\pdfdestname{#1}% - \txiescapepdf\pdfdestname - \safewhatsit{\pdfdest name{\pdfdestname} xyz}% - }} - % - % used to mark target names; must be expandable. - \def\pdfmkpgn#1{#1} - % - % by default, use a color that is dark enough to print on paper as - % nearly black, but still distinguishable for online viewing. - \def\urlcolor{\rgbDarkRed} - \def\linkcolor{\rgbDarkRed} - \def\endlink{\setcolor{\maincolor}\pdfendlink} - % - % Adding outlines to PDF; macros for calculating structure of outlines - % come from Petr Olsak - \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% - \else \csname#1\endcsname \fi} - \def\advancenumber#1{\tempnum=\expnumber{#1}\relax - \advance\tempnum by 1 - \expandafter\xdef\csname#1\endcsname{\the\tempnum}} - % - % #1 is the section text, which is what will be displayed in the - % outline by the pdf viewer. #2 is the pdf expression for the number - % of subentries (or empty, for subsubsections). #3 is the node text, - % which might be empty if this toc entry had no corresponding node. - % #4 is the page number - % - \def\dopdfoutline#1#2#3#4{% - % Generate a link to the node text if that exists; else, use the - % page number. We could generate a destination for the section - % text in the case where a section has no node, but it doesn't - % seem worth the trouble, since most documents are normally structured. - \edef\pdfoutlinedest{#3}% - \ifx\pdfoutlinedest\empty - \def\pdfoutlinedest{#4}% - \else - \txiescapepdf\pdfoutlinedest - \fi - % - % Also escape PDF chars in the display string. - \edef\pdfoutlinetext{#1}% - \txiescapepdf\pdfoutlinetext - % - \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% - } - % - \def\pdfmakeoutlines{% - \begingroup - % Read toc silently, to get counts of subentries for \pdfoutline. - \def\partentry##1##2##3##4{}% ignore parts in the outlines - \def\numchapentry##1##2##3##4{% - \def\thischapnum{##2}% - \def\thissecnum{0}% - \def\thissubsecnum{0}% - }% - \def\numsecentry##1##2##3##4{% - \advancenumber{chap\thischapnum}% - \def\thissecnum{##2}% - \def\thissubsecnum{0}% - }% - \def\numsubsecentry##1##2##3##4{% - \advancenumber{sec\thissecnum}% - \def\thissubsecnum{##2}% - }% - \def\numsubsubsecentry##1##2##3##4{% - \advancenumber{subsec\thissubsecnum}% - }% - \def\thischapnum{0}% - \def\thissecnum{0}% - \def\thissubsecnum{0}% - % - % use \def rather than \let here because we redefine \chapentry et - % al. a second time, below. - \def\appentry{\numchapentry}% - \def\appsecentry{\numsecentry}% - \def\appsubsecentry{\numsubsecentry}% - \def\appsubsubsecentry{\numsubsubsecentry}% - \def\unnchapentry{\numchapentry}% - \def\unnsecentry{\numsecentry}% - \def\unnsubsecentry{\numsubsecentry}% - \def\unnsubsubsecentry{\numsubsubsecentry}% - \readdatafile{toc}% - % - % Read toc second time, this time actually producing the outlines. - % The `-' means take the \expnumber as the absolute number of - % subentries, which we calculated on our first read of the .toc above. - % - % We use the node names as the destinations. - \def\numchapentry##1##2##3##4{% - \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% - \def\numsecentry##1##2##3##4{% - \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% - \def\numsubsecentry##1##2##3##4{% - \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% - \def\numsubsubsecentry##1##2##3##4{% count is always zero - \dopdfoutline{##1}{}{##3}{##4}}% - % - % PDF outlines are displayed using system fonts, instead of - % document fonts. Therefore we cannot use special characters, - % since the encoding is unknown. For example, the eogonek from - % Latin 2 (0xea) gets translated to a | character. Info from - % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. - % - % TODO this right, we have to translate 8-bit characters to - % their "best" equivalent, based on the @documentencoding. Too - % much work for too little return. Just use the ASCII equivalents - % we use for the index sort strings. - % - \indexnofonts - \setupdatafile - % We can have normal brace characters in the PDF outlines, unlike - % Texinfo index files. So set that up. - \def\{{\lbracecharliteral}% - \def\}{\rbracecharliteral}% - \catcode`\\=\active \otherbackslash - \input \tocreadfilename - \endgroup - } - {\catcode`[=1 \catcode`]=2 - \catcode`{=\other \catcode`}=\other - \gdef\lbracecharliteral[{]% - \gdef\rbracecharliteral[}]% - ] - % - \def\skipspaces#1{\def\PP{#1}\def\D{|}% - \ifx\PP\D\let\nextsp\relax - \else\let\nextsp\skipspaces - \addtokens{\filename}{\PP}% - \advance\filenamelength by 1 - \fi - \nextsp} - \def\getfilename#1{% - \filenamelength=0 - % If we don't expand the argument now, \skipspaces will get - % snagged on things like "@value{foo}". - \edef\temp{#1}% - \expandafter\skipspaces\temp|\relax - } - \ifnum\pdftexversion < 14 - \let \startlink \pdfannotlink - \else - \let \startlink \pdfstartlink - \fi - % make a live url in pdf output. - \def\pdfurl#1{% - \begingroup - % it seems we really need yet another set of dummies; have not - % tried to figure out what each command should do in the context - % of @url. for now, just make @/ a no-op, that's the only one - % people have actually reported a problem with. - % - \normalturnoffactive - \def\@{@}% - \let\/=\empty - \makevalueexpandable - % do we want to go so far as to use \indexnofonts instead of just - % special-casing \var here? - \def\var##1{##1}% - % - \leavevmode\setcolor{\urlcolor}% - \startlink attr{/Border [0 0 0]}% - user{/Subtype /Link /A << /S /URI /URI (#1) >>}% - \endgroup} - \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} - \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} - \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} - \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} - \def\maketoks{% - \expandafter\poptoks\the\toksA|ENDTOKS|\relax - \ifx\first0\adn0 - \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 - \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 - \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 - \else - \ifnum0=\countA\else\makelink\fi - \ifx\first.\let\next=\done\else - \let\next=\maketoks - \addtokens{\toksB}{\the\toksD} - \ifx\first,\addtokens{\toksB}{\space}\fi - \fi - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \next} - \def\makelink{\addtokens{\toksB}% - {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} - \def\pdflink#1{% - \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} - \setcolor{\linkcolor}#1\endlink} - \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -\else - % non-pdf mode - \let\pdfmkdest = \gobble - \let\pdfurl = \gobble - \let\endlink = \relax - \let\setcolor = \gobble - \let\pdfsetcolor = \gobble - \let\pdfmakeoutlines = \relax -\fi % \ifx\pdfoutput - - -\message{fonts,} - -% Change the current font style to #1, remembering it in \curfontstyle. -% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in -% italics, not bold italics. -% -\def\setfontstyle#1{% - \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. - \csname ten#1\endcsname % change the current font -} - -% Select #1 fonts with the current style. -% -\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} - -\def\rm{\fam=0 \setfontstyle{rm}} -\def\it{\fam=\itfam \setfontstyle{it}} -\def\sl{\fam=\slfam \setfontstyle{sl}} -\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} -\def\tt{\fam=\ttfam \setfontstyle{tt}} - -% Unfortunately, we have to override this for titles and the like, since -% in those cases "rm" is bold. Sigh. -\def\rmisbold{\rm\def\curfontstyle{bf}} - -% Texinfo sort of supports the sans serif font style, which plain TeX does not. -% So we set up a \sf. -\newfam\sffam -\def\sf{\fam=\sffam \setfontstyle{sf}} -\let\li = \sf % Sometimes we call it \li, not \sf. - -% We don't need math for this font style. -\def\ttsl{\setfontstyle{ttsl}} - - -% Set the baselineskip to #1, and the lineskip and strut size -% correspondingly. There is no deep meaning behind these magic numbers -% used as factors; they just match (closely enough) what Knuth defined. -% -\def\lineskipfactor{.08333} -\def\strutheightpercent{.70833} -\def\strutdepthpercent {.29167} -% -% can get a sort of poor man's double spacing by redefining this. -\def\baselinefactor{1} -% -\newdimen\textleading -\def\setleading#1{% - \dimen0 = #1\relax - \normalbaselineskip = \baselinefactor\dimen0 - \normallineskip = \lineskipfactor\normalbaselineskip - \normalbaselines - \setbox\strutbox =\hbox{% - \vrule width0pt height\strutheightpercent\baselineskip - depth \strutdepthpercent \baselineskip - }% -} - -% PDF CMaps. See also LaTeX's t1.cmap. -% -% do nothing with this by default. -\expandafter\let\csname cmapOT1\endcsname\gobble -\expandafter\let\csname cmapOT1IT\endcsname\gobble -\expandafter\let\csname cmapOT1TT\endcsname\gobble - -% if we are producing pdf, and we have \pdffontattr, then define cmaps. -% (\pdffontattr was introduced many years ago, but people still run -% older pdftex's; it's easy to conditionalize, so we do.) -\ifpdf \ifx\pdffontattr\thisisundefined \else - \begingroup - \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. - \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap -%%DocumentNeededResources: ProcSet (CIDInit) -%%IncludeResource: ProcSet (CIDInit) -%%BeginResource: CMap (TeX-OT1-0) -%%Title: (TeX-OT1-0 TeX OT1 0) -%%Version: 1.000 -%%EndComments -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<< /Registry (TeX) -/Ordering (OT1) -/Supplement 0 ->> def -/CMapName /TeX-OT1-0 def -/CMapType 2 def -1 begincodespacerange -<00> <7F> -endcodespacerange -8 beginbfrange -<00> <01> <0393> -<09> <0A> <03A8> -<23> <26> <0023> -<28> <3B> <0028> -<3F> <5B> <003F> -<5D> <5E> <005D> -<61> <7A> <0061> -<7B> <7C> <2013> -endbfrange -40 beginbfchar -<02> <0398> -<03> <039B> -<04> <039E> -<05> <03A0> -<06> <03A3> -<07> <03D2> -<08> <03A6> -<0B> <00660066> -<0C> <00660069> -<0D> <0066006C> -<0E> <006600660069> -<0F> <00660066006C> -<10> <0131> -<11> <0237> -<12> <0060> -<13> <00B4> -<14> <02C7> -<15> <02D8> -<16> <00AF> -<17> <02DA> -<18> <00B8> -<19> <00DF> -<1A> <00E6> -<1B> <0153> -<1C> <00F8> -<1D> <00C6> -<1E> <0152> -<1F> <00D8> -<21> <0021> -<22> <201D> -<27> <2019> -<3C> <00A1> -<3D> <003D> -<3E> <00BF> -<5C> <201C> -<5F> <02D9> -<60> <2018> -<7D> <02DD> -<7E> <007E> -<7F> <00A8> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -%%EndResource -%%EOF - }\endgroup - \expandafter\edef\csname cmapOT1\endcsname#1{% - \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% - }% -% -% \cmapOT1IT - \begingroup - \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. - \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap -%%DocumentNeededResources: ProcSet (CIDInit) -%%IncludeResource: ProcSet (CIDInit) -%%BeginResource: CMap (TeX-OT1IT-0) -%%Title: (TeX-OT1IT-0 TeX OT1IT 0) -%%Version: 1.000 -%%EndComments -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<< /Registry (TeX) -/Ordering (OT1IT) -/Supplement 0 ->> def -/CMapName /TeX-OT1IT-0 def -/CMapType 2 def -1 begincodespacerange -<00> <7F> -endcodespacerange -8 beginbfrange -<00> <01> <0393> -<09> <0A> <03A8> -<25> <26> <0025> -<28> <3B> <0028> -<3F> <5B> <003F> -<5D> <5E> <005D> -<61> <7A> <0061> -<7B> <7C> <2013> -endbfrange -42 beginbfchar -<02> <0398> -<03> <039B> -<04> <039E> -<05> <03A0> -<06> <03A3> -<07> <03D2> -<08> <03A6> -<0B> <00660066> -<0C> <00660069> -<0D> <0066006C> -<0E> <006600660069> -<0F> <00660066006C> -<10> <0131> -<11> <0237> -<12> <0060> -<13> <00B4> -<14> <02C7> -<15> <02D8> -<16> <00AF> -<17> <02DA> -<18> <00B8> -<19> <00DF> -<1A> <00E6> -<1B> <0153> -<1C> <00F8> -<1D> <00C6> -<1E> <0152> -<1F> <00D8> -<21> <0021> -<22> <201D> -<23> <0023> -<24> <00A3> -<27> <2019> -<3C> <00A1> -<3D> <003D> -<3E> <00BF> -<5C> <201C> -<5F> <02D9> -<60> <2018> -<7D> <02DD> -<7E> <007E> -<7F> <00A8> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -%%EndResource -%%EOF - }\endgroup - \expandafter\edef\csname cmapOT1IT\endcsname#1{% - \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% - }% -% -% \cmapOT1TT - \begingroup - \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. - \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap -%%DocumentNeededResources: ProcSet (CIDInit) -%%IncludeResource: ProcSet (CIDInit) -%%BeginResource: CMap (TeX-OT1TT-0) -%%Title: (TeX-OT1TT-0 TeX OT1TT 0) -%%Version: 1.000 -%%EndComments -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<< /Registry (TeX) -/Ordering (OT1TT) -/Supplement 0 ->> def -/CMapName /TeX-OT1TT-0 def -/CMapType 2 def -1 begincodespacerange -<00> <7F> -endcodespacerange -5 beginbfrange -<00> <01> <0393> -<09> <0A> <03A8> -<21> <26> <0021> -<28> <5F> <0028> -<61> <7E> <0061> -endbfrange -32 beginbfchar -<02> <0398> -<03> <039B> -<04> <039E> -<05> <03A0> -<06> <03A3> -<07> <03D2> -<08> <03A6> -<0B> <2191> -<0C> <2193> -<0D> <0027> -<0E> <00A1> -<0F> <00BF> -<10> <0131> -<11> <0237> -<12> <0060> -<13> <00B4> -<14> <02C7> -<15> <02D8> -<16> <00AF> -<17> <02DA> -<18> <00B8> -<19> <00DF> -<1A> <00E6> -<1B> <0153> -<1C> <00F8> -<1D> <00C6> -<1E> <0152> -<1F> <00D8> -<20> <2423> -<27> <2019> -<60> <2018> -<7F> <00A8> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -%%EndResource -%%EOF - }\endgroup - \expandafter\edef\csname cmapOT1TT\endcsname#1{% - \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% - }% -\fi\fi - - -% Set the font macro #1 to the font named \fontprefix#2. -% #3 is the font's design size, #4 is a scale factor, #5 is the CMap -% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). -% Example: -% #1 = \textrm -% #2 = \rmshape -% #3 = 10 -% #4 = \mainmagstep -% #5 = OT1 -% -\def\setfont#1#2#3#4#5{% - \font#1=\fontprefix#2#3 scaled #4 - \csname cmap#5\endcsname#1% -} -% This is what gets called when #5 of \setfont is empty. -\let\cmap\gobble -% -% (end of cmaps) - -% Use cm as the default font prefix. -% To specify the font prefix, you must define \fontprefix -% before you read in texinfo.tex. -\ifx\fontprefix\thisisundefined -\def\fontprefix{cm} -\fi -% Support font families that don't use the same naming scheme as CM. -\def\rmshape{r} -\def\rmbshape{bx} % where the normal face is bold -\def\bfshape{b} -\def\bxshape{bx} -\def\ttshape{tt} -\def\ttbshape{tt} -\def\ttslshape{sltt} -\def\itshape{ti} -\def\itbshape{bxti} -\def\slshape{sl} -\def\slbshape{bxsl} -\def\sfshape{ss} -\def\sfbshape{ss} -\def\scshape{csc} -\def\scbshape{csc} - -% Definitions for a main text size of 11pt. (The default in Texinfo.) -% -\def\definetextfontsizexi{% -% Text fonts (11.2pt, magstep1). -\def\textnominalsize{11pt} -\edef\mainmagstep{\magstephalf} -\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} -\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} -\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} -\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} -\setfont\textsl\slshape{10}{\mainmagstep}{OT1} -\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} -\setfont\textsc\scshape{10}{\mainmagstep}{OT1} -\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep -\def\textecsize{1095} - -% A few fonts for @defun names and args. -\setfont\defbf\bfshape{10}{\magstep1}{OT1} -\setfont\deftt\ttshape{10}{\magstep1}{OT1TT} -\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} - -% Fonts for indices, footnotes, small examples (9pt). -\def\smallnominalsize{9pt} -\setfont\smallrm\rmshape{9}{1000}{OT1} -\setfont\smalltt\ttshape{9}{1000}{OT1TT} -\setfont\smallbf\bfshape{10}{900}{OT1} -\setfont\smallit\itshape{9}{1000}{OT1IT} -\setfont\smallsl\slshape{9}{1000}{OT1} -\setfont\smallsf\sfshape{9}{1000}{OT1} -\setfont\smallsc\scshape{10}{900}{OT1} -\setfont\smallttsl\ttslshape{10}{900}{OT1TT} -\font\smalli=cmmi9 -\font\smallsy=cmsy9 -\def\smallecsize{0900} - -% Fonts for small examples (8pt). -\def\smallernominalsize{8pt} -\setfont\smallerrm\rmshape{8}{1000}{OT1} -\setfont\smallertt\ttshape{8}{1000}{OT1TT} -\setfont\smallerbf\bfshape{10}{800}{OT1} -\setfont\smallerit\itshape{8}{1000}{OT1IT} -\setfont\smallersl\slshape{8}{1000}{OT1} -\setfont\smallersf\sfshape{8}{1000}{OT1} -\setfont\smallersc\scshape{10}{800}{OT1} -\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} -\font\smalleri=cmmi8 -\font\smallersy=cmsy8 -\def\smallerecsize{0800} - -% Fonts for title page (20.4pt): -\def\titlenominalsize{20pt} -\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} -\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} -\setfont\titlesl\slbshape{10}{\magstep4}{OT1} -\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} -\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} -\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} -\let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4}{OT1} -\font\titlei=cmmi12 scaled \magstep3 -\font\titlesy=cmsy10 scaled \magstep4 -\def\titleecsize{2074} - -% Chapter (and unnumbered) fonts (17.28pt). -\def\chapnominalsize{17pt} -\setfont\chaprm\rmbshape{12}{\magstep2}{OT1} -\setfont\chapit\itbshape{10}{\magstep3}{OT1IT} -\setfont\chapsl\slbshape{10}{\magstep3}{OT1} -\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} -\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} -\setfont\chapsf\sfbshape{17}{1000}{OT1} -\let\chapbf=\chaprm -\setfont\chapsc\scbshape{10}{\magstep3}{OT1} -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 -\def\chapecsize{1728} - -% Section fonts (14.4pt). -\def\secnominalsize{14pt} -\setfont\secrm\rmbshape{12}{\magstep1}{OT1} -\setfont\secit\itbshape{10}{\magstep2}{OT1IT} -\setfont\secsl\slbshape{10}{\magstep2}{OT1} -\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} -\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} -\setfont\secsf\sfbshape{12}{\magstep1}{OT1} -\let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep2}{OT1} -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 -\def\sececsize{1440} - -% Subsection fonts (13.15pt). -\def\ssecnominalsize{13pt} -\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} -\setfont\ssecit\itbshape{10}{1315}{OT1IT} -\setfont\ssecsl\slbshape{10}{1315}{OT1} -\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} -\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} -\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} -\let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{1315}{OT1} -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled 1315 -\def\ssececsize{1200} - -% Reduced fonts for @acro in text (10pt). -\def\reducednominalsize{10pt} -\setfont\reducedrm\rmshape{10}{1000}{OT1} -\setfont\reducedtt\ttshape{10}{1000}{OT1TT} -\setfont\reducedbf\bfshape{10}{1000}{OT1} -\setfont\reducedit\itshape{10}{1000}{OT1IT} -\setfont\reducedsl\slshape{10}{1000}{OT1} -\setfont\reducedsf\sfshape{10}{1000}{OT1} -\setfont\reducedsc\scshape{10}{1000}{OT1} -\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} -\font\reducedi=cmmi10 -\font\reducedsy=cmsy10 -\def\reducedecsize{1000} - -\textleading = 13.2pt % line spacing for 11pt CM -\textfonts % reset the current fonts -\rm -} % end of 11pt text font size definitions, \definetextfontsizexi - - -% Definitions to make the main text be 10pt Computer Modern, with -% section, chapter, etc., sizes following suit. This is for the GNU -% Press printing of the Emacs 22 manual. Maybe other manuals in the -% future. Used with @smallbook, which sets the leading to 12pt. -% -\def\definetextfontsizex{% -% Text fonts (10pt). -\def\textnominalsize{10pt} -\edef\mainmagstep{1000} -\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} -\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} -\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} -\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} -\setfont\textsl\slshape{10}{\mainmagstep}{OT1} -\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} -\setfont\textsc\scshape{10}{\mainmagstep}{OT1} -\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep -\def\textecsize{1000} - -% A few fonts for @defun names and args. -\setfont\defbf\bfshape{10}{\magstephalf}{OT1} -\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} -\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} - -% Fonts for indices, footnotes, small examples (9pt). -\def\smallnominalsize{9pt} -\setfont\smallrm\rmshape{9}{1000}{OT1} -\setfont\smalltt\ttshape{9}{1000}{OT1TT} -\setfont\smallbf\bfshape{10}{900}{OT1} -\setfont\smallit\itshape{9}{1000}{OT1IT} -\setfont\smallsl\slshape{9}{1000}{OT1} -\setfont\smallsf\sfshape{9}{1000}{OT1} -\setfont\smallsc\scshape{10}{900}{OT1} -\setfont\smallttsl\ttslshape{10}{900}{OT1TT} -\font\smalli=cmmi9 -\font\smallsy=cmsy9 -\def\smallecsize{0900} - -% Fonts for small examples (8pt). -\def\smallernominalsize{8pt} -\setfont\smallerrm\rmshape{8}{1000}{OT1} -\setfont\smallertt\ttshape{8}{1000}{OT1TT} -\setfont\smallerbf\bfshape{10}{800}{OT1} -\setfont\smallerit\itshape{8}{1000}{OT1IT} -\setfont\smallersl\slshape{8}{1000}{OT1} -\setfont\smallersf\sfshape{8}{1000}{OT1} -\setfont\smallersc\scshape{10}{800}{OT1} -\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} -\font\smalleri=cmmi8 -\font\smallersy=cmsy8 -\def\smallerecsize{0800} - -% Fonts for title page (20.4pt): -\def\titlenominalsize{20pt} -\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} -\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} -\setfont\titlesl\slbshape{10}{\magstep4}{OT1} -\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} -\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} -\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} -\let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4}{OT1} -\font\titlei=cmmi12 scaled \magstep3 -\font\titlesy=cmsy10 scaled \magstep4 -\def\titleecsize{2074} - -% Chapter fonts (14.4pt). -\def\chapnominalsize{14pt} -\setfont\chaprm\rmbshape{12}{\magstep1}{OT1} -\setfont\chapit\itbshape{10}{\magstep2}{OT1IT} -\setfont\chapsl\slbshape{10}{\magstep2}{OT1} -\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} -\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} -\setfont\chapsf\sfbshape{12}{\magstep1}{OT1} -\let\chapbf\chaprm -\setfont\chapsc\scbshape{10}{\magstep2}{OT1} -\font\chapi=cmmi12 scaled \magstep1 -\font\chapsy=cmsy10 scaled \magstep2 -\def\chapecsize{1440} - -% Section fonts (12pt). -\def\secnominalsize{12pt} -\setfont\secrm\rmbshape{12}{1000}{OT1} -\setfont\secit\itbshape{10}{\magstep1}{OT1IT} -\setfont\secsl\slbshape{10}{\magstep1}{OT1} -\setfont\sectt\ttbshape{12}{1000}{OT1TT} -\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} -\setfont\secsf\sfbshape{12}{1000}{OT1} -\let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep1}{OT1} -\font\seci=cmmi12 -\font\secsy=cmsy10 scaled \magstep1 -\def\sececsize{1200} - -% Subsection fonts (10pt). -\def\ssecnominalsize{10pt} -\setfont\ssecrm\rmbshape{10}{1000}{OT1} -\setfont\ssecit\itbshape{10}{1000}{OT1IT} -\setfont\ssecsl\slbshape{10}{1000}{OT1} -\setfont\ssectt\ttbshape{10}{1000}{OT1TT} -\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} -\setfont\ssecsf\sfbshape{10}{1000}{OT1} -\let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{1000}{OT1} -\font\sseci=cmmi10 -\font\ssecsy=cmsy10 -\def\ssececsize{1000} - -% Reduced fonts for @acro in text (9pt). -\def\reducednominalsize{9pt} -\setfont\reducedrm\rmshape{9}{1000}{OT1} -\setfont\reducedtt\ttshape{9}{1000}{OT1TT} -\setfont\reducedbf\bfshape{10}{900}{OT1} -\setfont\reducedit\itshape{9}{1000}{OT1IT} -\setfont\reducedsl\slshape{9}{1000}{OT1} -\setfont\reducedsf\sfshape{9}{1000}{OT1} -\setfont\reducedsc\scshape{10}{900}{OT1} -\setfont\reducedttsl\ttslshape{10}{900}{OT1TT} -\font\reducedi=cmmi9 -\font\reducedsy=cmsy9 -\def\reducedecsize{0900} - -\divide\parskip by 2 % reduce space between paragraphs -\textleading = 12pt % line spacing for 10pt CM -\textfonts % reset the current fonts -\rm -} % end of 10pt text font size definitions, \definetextfontsizex - - -% We provide the user-level command -% @fonttextsize 10 -% (or 11) to redefine the text font size. pt is assumed. -% -\def\xiword{11} -\def\xword{10} -\def\xwordpt{10pt} -% -\parseargdef\fonttextsize{% - \def\textsizearg{#1}% - %\wlog{doing @fonttextsize \textsizearg}% - % - % Set \globaldefs so that documents can use this inside @tex, since - % makeinfo 4.8 does not support it, but we need it nonetheless. - % - \begingroup \globaldefs=1 - \ifx\textsizearg\xword \definetextfontsizex - \else \ifx\textsizearg\xiword \definetextfontsizexi - \else - \errhelp=\EMsimple - \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} - \fi\fi - \endgroup -} - - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts except -% in the main text, we don't bother to reset \scriptfont and -% \scriptscriptfont (which would also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy - \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf - \textfont\ttfam=\tentt \textfont\sffam=\tensf -} - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this because \STYLE needs to also set the -% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire -% \tenSTYLE to set the current font. -% -% Each font-changing command also sets the names \lsize (one size lower) -% and \lllsize (three sizes lower). These relative commands are used in -% the LaTeX logo and acronyms. -% -% This all needs generalizing, badly. -% -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy - \let\tenttsl=\textttsl - \def\curfontsize{text}% - \def\lsize{reduced}\def\lllsize{smaller}% - \resetmathfonts \setleading{\textleading}} -\def\titlefonts{% - \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl - \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc - \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy - \let\tenttsl=\titlettsl - \def\curfontsize{title}% - \def\lsize{chap}\def\lllsize{subsec}% - \resetmathfonts \setleading{27pt}} -\def\titlefont#1{{\titlefonts\rmisbold #1}} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy - \let\tenttsl=\chapttsl - \def\curfontsize{chap}% - \def\lsize{sec}\def\lllsize{text}% - \resetmathfonts \setleading{19pt}} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy - \let\tenttsl=\secttsl - \def\curfontsize{sec}% - \def\lsize{subsec}\def\lllsize{reduced}% - \resetmathfonts \setleading{16pt}} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy - \let\tenttsl=\ssecttsl - \def\curfontsize{ssec}% - \def\lsize{text}\def\lllsize{small}% - \resetmathfonts \setleading{15pt}} -\let\subsubsecfonts = \subsecfonts -\def\reducedfonts{% - \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl - \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc - \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy - \let\tenttsl=\reducedttsl - \def\curfontsize{reduced}% - \def\lsize{small}\def\lllsize{smaller}% - \resetmathfonts \setleading{10.5pt}} -\def\smallfonts{% - \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl - \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc - \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy - \let\tenttsl=\smallttsl - \def\curfontsize{small}% - \def\lsize{smaller}\def\lllsize{smaller}% - \resetmathfonts \setleading{10.5pt}} -\def\smallerfonts{% - \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl - \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc - \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy - \let\tenttsl=\smallerttsl - \def\curfontsize{smaller}% - \def\lsize{smaller}\def\lllsize{smaller}% - \resetmathfonts \setleading{9.5pt}} - -% Fonts for short table of contents. -\setfont\shortcontrm\rmshape{12}{1000}{OT1} -\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 -\setfont\shortcontsl\slshape{12}{1000}{OT1} -\setfont\shortconttt\ttshape{12}{1000}{OT1TT} - -% Define these just so they can be easily changed for other fonts. -\def\angleleft{$\langle$} -\def\angleright{$\rangle$} - -% Set the fonts to use with the @small... environments. -\let\smallexamplefonts = \smallfonts - -% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample -% can fit this many characters: -% 8.5x11=86 smallbook=72 a4=90 a5=69 -% If we use \scriptfonts (8pt), then we can fit this many characters: -% 8.5x11=90+ smallbook=80 a4=90+ a5=77 -% For me, subjectively, the few extra characters that fit aren't worth -% the additional smallness of 8pt. So I'm making the default 9pt. -% -% By the way, for comparison, here's what fits with @example (10pt): -% 8.5x11=71 smallbook=60 a4=75 a5=58 -% --karl, 24jan03. - -% Set up the default fonts, so we can use them for creating boxes. -% -\definetextfontsizexi - - -\message{markup,} - -% Check if we are currently using a typewriter font. Since all the -% Computer Modern typewriter fonts have zero interword stretch (and -% shrink), and it is reasonable to expect all typewriter fonts to have -% this property, we can check that font parameter. -% -\def\ifmonospace{\ifdim\fontdimen3\font=0pt } - -% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will -% define and register \INITMACRO to be called on markup style changes. -% \INITMACRO can check \currentmarkupstyle for the innermost -% style and the set of \ifmarkupSTYLE switches for all styles -% currently in effect. -\newif\ifmarkupvar -\newif\ifmarkupsamp -\newif\ifmarkupkey -%\newif\ifmarkupfile % @file == @samp. -%\newif\ifmarkupoption % @option == @samp. -\newif\ifmarkupcode -\newif\ifmarkupkbd -%\newif\ifmarkupenv % @env == @code. -%\newif\ifmarkupcommand % @command == @code. -\newif\ifmarkuptex % @tex (and part of @math, for now). -\newif\ifmarkupexample -\newif\ifmarkupverb -\newif\ifmarkupverbatim - -\let\currentmarkupstyle\empty - -\def\setupmarkupstyle#1{% - \csname markup#1true\endcsname - \def\currentmarkupstyle{#1}% - \markupstylesetup -} - -\let\markupstylesetup\empty - -\def\defmarkupstylesetup#1{% - \expandafter\def\expandafter\markupstylesetup - \expandafter{\markupstylesetup #1}% - \def#1% -} - -% Markup style setup for left and right quotes. -\defmarkupstylesetup\markupsetuplq{% - \expandafter\let\expandafter \temp - \csname markupsetuplq\currentmarkupstyle\endcsname - \ifx\temp\relax \markupsetuplqdefault \else \temp \fi -} - -\defmarkupstylesetup\markupsetuprq{% - \expandafter\let\expandafter \temp - \csname markupsetuprq\currentmarkupstyle\endcsname - \ifx\temp\relax \markupsetuprqdefault \else \temp \fi -} - -{ -\catcode`\'=\active -\catcode`\`=\active - -\gdef\markupsetuplqdefault{\let`\lq} -\gdef\markupsetuprqdefault{\let'\rq} - -\gdef\markupsetcodequoteleft{\let`\codequoteleft} -\gdef\markupsetcodequoteright{\let'\codequoteright} -} - -\let\markupsetuplqcode \markupsetcodequoteleft -\let\markupsetuprqcode \markupsetcodequoteright -% -\let\markupsetuplqexample \markupsetcodequoteleft -\let\markupsetuprqexample \markupsetcodequoteright -% -\let\markupsetuplqkbd \markupsetcodequoteleft -\let\markupsetuprqkbd \markupsetcodequoteright -% -\let\markupsetuplqsamp \markupsetcodequoteleft -\let\markupsetuprqsamp \markupsetcodequoteright -% -\let\markupsetuplqverb \markupsetcodequoteleft -\let\markupsetuprqverb \markupsetcodequoteright -% -\let\markupsetuplqverbatim \markupsetcodequoteleft -\let\markupsetuprqverbatim \markupsetcodequoteright - -% Allow an option to not use regular directed right quote/apostrophe -% (char 0x27), but instead the undirected quote from cmtt (char 0x0d). -% The undirected quote is ugly, so don't make it the default, but it -% works for pasting with more pdf viewers (at least evince), the -% lilypond developers report. xpdf does work with the regular 0x27. -% -\def\codequoteright{% - \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax - \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax - '% - \else \char'15 \fi - \else \char'15 \fi -} -% -% and a similar option for the left quote char vs. a grave accent. -% Modern fonts display ASCII 0x60 as a grave accent, so some people like -% the code environments to do likewise. -% -\def\codequoteleft{% - \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax - \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax - % [Knuth] pp. 380,381,391 - % \relax disables Spanish ligatures ?` and !` of \tt font. - \relax`% - \else \char'22 \fi - \else \char'22 \fi -} - -% Commands to set the quote options. -% -\parseargdef\codequoteundirected{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxicodequoteundirected\endcsname - = t% - \else\ifx\temp\offword - \expandafter\let\csname SETtxicodequoteundirected\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% - \fi\fi -} -% -\parseargdef\codequotebacktick{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxicodequotebacktick\endcsname - = t% - \else\ifx\temp\offword - \expandafter\let\csname SETtxicodequotebacktick\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% - \fi\fi -} - -% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. -\def\noligaturesquoteleft{\relax\lq} - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Font commands. - -% #1 is the font command (\sl or \it), #2 is the text to slant. -% If we are in a monospaced environment, however, 1) always use \ttsl, -% and 2) do not add an italic correction. -\def\dosmartslant#1#2{% - \ifusingtt - {{\ttsl #2}\let\next=\relax}% - {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% - \next -} -\def\smartslanted{\dosmartslant\sl} -\def\smartitalic{\dosmartslant\it} - -% Output an italic correction unless \next (presumed to be the following -% character) is such as not to need one. -\def\smartitaliccorrection{% - \ifx\next,% - \else\ifx\next-% - \else\ifx\next.% - \else\ptexslash - \fi\fi\fi - \aftersmartic -} - -% Unconditional use \ttsl, and no ic. @var is set to this for defuns. -\def\ttslanted#1{{\ttsl #1}} - -% @cite is like \smartslanted except unconditionally use \sl. We never want -% ttsl for book titles, do we? -\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} - -\def\aftersmartic{} -\def\var#1{% - \let\saveaftersmartic = \aftersmartic - \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% - \smartslanted{#1}% -} - -\let\i=\smartitalic -\let\slanted=\smartslanted -\let\dfn=\smartslanted -\let\emph=\smartitalic - -% Explicit font changes: @r, @sc, undocumented @ii. -\def\r#1{{\rm #1}} % roman font -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -% @b, explicit bold. Also @strong. -\def\b#1{{\bf #1}} -\let\strong=\b - -% @sansserif, explicit sans. -\def\sansserif#1{{\sf #1}} - -% We can't just use \exhyphenpenalty, because that only has effect at -% the end of a paragraph. Restore normal hyphenation at the end of the -% group within which \nohyphenation is presumably called. -% -\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} -\def\restorehyphenation{\hyphenchar\font = `- } - -% Set sfcode to normal for the chars that usually have another value. -% Can't use plain's \frenchspacing because it uses the `\x notation, and -% sometimes \x has an active definition that messes things up. -% -\catcode`@=11 - \def\plainfrenchspacing{% - \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m - \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m - \def\endofsentencespacefactor{1000}% for @. and friends - } - \def\plainnonfrenchspacing{% - \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 - \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 - \def\endofsentencespacefactor{3000}% for @. and friends - } -\catcode`@=\other -\def\endofsentencespacefactor{3000}% default - -% @t, explicit typewriter. -\def\t#1{% - {\tt \rawbackslash \plainfrenchspacing #1}% - \null -} - -% @samp. -\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} - -% @indicateurl is \samp, that is, with quotes. -\let\indicateurl=\samp - -% @code (and similar) prints in typewriter, but with spaces the same -% size as normal in the surrounding text, without hyphenation, etc. -% This is a subroutine for that. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \plainfrenchspacing - #1% - }% - \null % reset spacefactor to 1000 -} - -% We *must* turn on hyphenation at `-' and `_' in @code. -% Otherwise, it is too hard to avoid overfull hboxes -% in the Emacs manual, the Library manual, etc. -% -% Unfortunately, TeX uses one parameter (\hyphenchar) to control -% both hyphenation at - and hyphenation within words. -% We must therefore turn them both off (\tclose does that) -% and arrange explicitly to hyphenate at a dash. -% -- rms. -{ - \catcode`\-=\active \catcode`\_=\active - \catcode`\'=\active \catcode`\`=\active - \global\let'=\rq \global\let`=\lq % default definitions - % - \global\def\code{\begingroup - \setupmarkupstyle{code}% - % The following should really be moved into \setupmarkupstyle handlers. - \catcode\dashChar=\active \catcode\underChar=\active - \ifallowcodebreaks - \let-\codedash - \let_\codeunder - \else - \let-\normaldash - \let_\realunder - \fi - \codex - } -} - -\def\codex #1{\tclose{#1}\endgroup} - -\def\normaldash{-} -\def\codedash{-\discretionary{}{}{}} -\def\codeunder{% - % this is all so @math{@code{var_name}+1} can work. In math mode, _ - % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) - % will therefore expand the active definition of _, which is us - % (inside @code that is), therefore an endless loop. - \ifusingtt{\ifmmode - \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. - \else\normalunderscore \fi - \discretionary{}{}{}}% - {\_}% -} - -% An additional complication: the above will allow breaks after, e.g., -% each of the four underscores in __typeof__. This is bad. -% @allowcodebreaks provides a document-level way to turn breaking at - -% and _ on and off. -% -\newif\ifallowcodebreaks \allowcodebreakstrue - -\def\keywordtrue{true} -\def\keywordfalse{false} - -\parseargdef\allowcodebreaks{% - \def\txiarg{#1}% - \ifx\txiarg\keywordtrue - \allowcodebreakstrue - \else\ifx\txiarg\keywordfalse - \allowcodebreaksfalse - \else - \errhelp = \EMsimple - \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% - \fi\fi -} - -% For @command, @env, @file, @option quotes seem unnecessary, -% so use \code rather than \samp. -\let\command=\code -\let\env=\code -\let\file=\code -\let\option=\code - -% @uref (abbreviation for `urlref') takes an optional (comma-separated) -% second argument specifying the text to display and an optional third -% arg as text to display instead of (rather than in addition to) the url -% itself. First (mandatory) arg is the url. -% (This \urefnobreak definition isn't used now, leaving it for a while -% for comparison.) -\def\urefnobreak#1{\dourefnobreak #1,,,\finish} -\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup - \unsepspaces - \pdfurl{#1}% - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt - \unhbox0 % third arg given, show only that - \else - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \ifpdf - \unhbox0 % PDF: 2nd arg given, show only it - \else - \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url - \fi - \else - \code{#1}% only url given, so show it - \fi - \fi - \endlink -\endgroup} - -% This \urefbreak definition is the active one. -\def\urefbreak{\begingroup \urefcatcodes \dourefbreak} -\let\uref=\urefbreak -\def\dourefbreak#1{\urefbreakfinish #1,,,\finish} -\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example - \unsepspaces - \pdfurl{#1}% - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt - \unhbox0 % third arg given, show only that - \else - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \ifpdf - \unhbox0 % PDF: 2nd arg given, show only it - \else - \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url - \fi - \else - \urefcode{#1}% only url given, so show it - \fi - \fi - \endlink -\endgroup} - -% Allow line breaks around only a few characters (only). -\def\urefcatcodes{% - \catcode\ampChar=\active \catcode\dotChar=\active - \catcode\hashChar=\active \catcode\questChar=\active - \catcode\slashChar=\active -} -{ - \urefcatcodes - % - \global\def\urefcode{\begingroup - \setupmarkupstyle{code}% - \urefcatcodes - \let&\urefcodeamp - \let.\urefcodedot - \let#\urefcodehash - \let?\urefcodequest - \let/\urefcodeslash - \codex - } - % - % By default, they are just regular characters. - \global\def&{\normalamp} - \global\def.{\normaldot} - \global\def#{\normalhash} - \global\def?{\normalquest} - \global\def/{\normalslash} -} - -% we put a little stretch before and after the breakable chars, to help -% line breaking of long url's. The unequal skips make look better in -% cmtt at least, especially for dots. -\def\urefprestretch{\urefprebreak \hskip0pt plus.13em } -\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em } -% -\def\urefcodeamp{\urefprestretch \&\urefpoststretch} -\def\urefcodedot{\urefprestretch .\urefpoststretch} -\def\urefcodehash{\urefprestretch \#\urefpoststretch} -\def\urefcodequest{\urefprestretch ?\urefpoststretch} -\def\urefcodeslash{\futurelet\next\urefcodeslashfinish} -{ - \catcode`\/=\active - \global\def\urefcodeslashfinish{% - \urefprestretch \slashChar - % Allow line break only after the final / in a sequence of - % slashes, to avoid line break between the slashes in http://. - \ifx\next/\else \urefpoststretch \fi - } -} - -% One more complication: by default we'll break after the special -% characters, but some people like to break before the special chars, so -% allow that. Also allow no breaking at all, for manual control. -% -\parseargdef\urefbreakstyle{% - \def\txiarg{#1}% - \ifx\txiarg\wordnone - \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} - \else\ifx\txiarg\wordbefore - \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} - \else\ifx\txiarg\wordafter - \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} - \else - \errhelp = \EMsimple - \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% - \fi\fi\fi -} -\def\wordafter{after} -\def\wordbefore{before} -\def\wordnone{none} - -\urefbreakstyle after - -% @url synonym for @uref, since that's how everyone uses it. -% -\let\url=\uref - -% rms does not like angle brackets --karl, 17may97. -% So now @email is just like @uref, unless we are pdf. -% -%\def\email#1{\angleleft{\tt #1}\angleright} -\ifpdf - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{\begingroup - \unsepspaces - \pdfurl{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \endlink - \endgroup} -\else - \let\email=\uref -\fi - -% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), -% `example' (@kbd uses ttsl only inside of @example and friends), -% or `code' (@kbd uses normal tty font always). -\parseargdef\kbdinputstyle{% - \def\txiarg{#1}% - \ifx\txiarg\worddistinct - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% - \else\ifx\txiarg\wordexample - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% - \else\ifx\txiarg\wordcode - \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% - \else - \errhelp = \EMsimple - \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% - \fi\fi\fi -} -\def\worddistinct{distinct} -\def\wordexample{example} -\def\wordcode{code} - -% Default is `distinct'. -\kbdinputstyle distinct - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. -\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} - -\def\xkey{\key} -\def\kbdsub#1#2#3\par{% - \def\one{#1}\def\three{#3}\def\threex{??}% - \ifx\one\xkey\ifx\threex\three \key{#2}% - \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi - \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi -} - -% definition of @key that produces a lozenge. Doesn't adjust to text size. -%\setfont\keyrm\rmshape{8}{1000}{OT1} -%\font\keysy=cmsy9 -%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% -% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% -% \vbox{\hrule\kern-0.4pt -% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% -% \kern-0.4pt\hrule}% -% \kern-.06em\raise0.4pt\hbox{\angleright}}}} - -% definition of @key with no lozenge. If the current font is already -% monospace, don't change it; that way, we respect @kbdinputstyle. But -% if it isn't monospace, then use \tt. -% -\def\key#1{{\setupmarkupstyle{key}% - \nohyphenation - \ifmonospace\else\tt\fi - #1}\null} - -% @clicksequence{File @click{} Open ...} -\def\clicksequence#1{\begingroup #1\endgroup} - -% @clickstyle @arrow (by default) -\parseargdef\clickstyle{\def\click{#1}} -\def\click{\arrow} - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -% @l was never documented to mean ``switch to the Lisp font'', -% and it is not used as such in any manual I can find. We need it for -% Polish suppressed-l. --karl, 22sep96. -%\def\l#1{{\li #1}\null} - -% @acronym for "FBI", "NATO", and the like. -% We print this one point size smaller, since it's intended for -% all-uppercase. -% -\def\acronym#1{\doacronym #1,,\finish} -\def\doacronym#1,#2,#3\finish{% - {\selectfonts\lsize #1}% - \def\temp{#2}% - \ifx\temp\empty \else - \space ({\unsepspaces \ignorespaces \temp \unskip})% - \fi - \null % reset \spacefactor=1000 -} - -% @abbr for "Comput. J." and the like. -% No font change, but don't do end-of-sentence spacing. -% -\def\abbr#1{\doabbr #1,,\finish} -\def\doabbr#1,#2,#3\finish{% - {\plainfrenchspacing #1}% - \def\temp{#2}% - \ifx\temp\empty \else - \space ({\unsepspaces \ignorespaces \temp \unskip})% - \fi - \null % reset \spacefactor=1000 -} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math outputs its argument in math mode. -% -% One complication: _ usually means subscripts, but it could also mean -% an actual _ character, as in @math{@var{some_variable} + 1}. So make -% _ active, and distinguish by seeing if the current family is \slfam, -% which is what @var uses. -{ - \catcode`\_ = \active - \gdef\mathunderscore{% - \catcode`\_=\active - \def_{\ifnum\fam=\slfam \_\else\sb\fi}% - } -} -% Another complication: we want \\ (and @\) to output a math (or tt) \. -% FYI, plain.tex uses \\ as a temporary control sequence (for no -% particular reason), but this is not advertised and we don't care. -% -% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. -\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} -% -\def\math{% - \tex - \mathunderscore - \let\\ = \mathbackslash - \mathactive - % make the texinfo accent commands work in math mode - \let\"=\ddot - \let\'=\acute - \let\==\bar - \let\^=\hat - \let\`=\grave - \let\u=\breve - \let\v=\check - \let\~=\tilde - \let\dotaccent=\dot - $\finishmath -} -\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. - -% Some active characters (such as <) are spaced differently in math. -% We have to reset their definitions in case the @math was an argument -% to a command which sets the catcodes (such as @item or @section). -% -{ - \catcode`^ = \active - \catcode`< = \active - \catcode`> = \active - \catcode`+ = \active - \catcode`' = \active - \gdef\mathactive{% - \let^ = \ptexhat - \let< = \ptexless - \let> = \ptexgtr - \let+ = \ptexplus - \let' = \ptexquoteright - } -} - -% ctrl is no longer a Texinfo command, but leave this definition for fun. -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. -% Ignore unless FMTNAME == tex; then it is like @iftex and @tex, -% except specified as a normal braced arg, so no newlines to worry about. -% -\def\outfmtnametex{tex} -% -\long\def\inlinefmt#1{\doinlinefmt #1,\finish} -\long\def\doinlinefmt#1,#2,\finish{% - \def\inlinefmtname{#1}% - \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi -} -% For raw, must switch into @tex before parsing the argument, to avoid -% setting catcodes prematurely. Doing it this way means that, for -% example, @inlineraw{html, foo{bar} gets a parse error instead of being -% ignored. But this isn't important because if people want a literal -% *right* brace they would have to use a command anyway, so they may as -% well use a command to get a left brace too. We could re-use the -% delimiter character idea from \verb, but it seems like overkill. -% -\long\def\inlineraw{\tex \doinlineraw} -\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} -\def\doinlinerawtwo#1,#2,\finish{% - \def\inlinerawname{#1}% - \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi - \endgroup % close group opened by \tex. -} - - -\message{glyphs,} -% and logos. - -% @@ prints an @, as does @atchar{}. -\def\@{\char64 } -\let\atchar=\@ - -% @{ @} @lbracechar{} @rbracechar{} all generate brace characters. -% Unless we're in typewriter, use \ecfont because the CM text fonts do -% not have braces, and we don't want to switch into math. -\def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}} -\def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}} -\let\{=\mylbrace \let\lbracechar=\{ -\let\}=\myrbrace \let\rbracechar=\} -\begingroup - % Definitions to produce \{ and \} commands for indices, - % and @{ and @} for the aux/toc files. - \catcode`\{ = \other \catcode`\} = \other - \catcode`\[ = 1 \catcode`\] = 2 - \catcode`\! = 0 \catcode`\\ = \other - !gdef!lbracecmd[\{]% - !gdef!rbracecmd[\}]% - !gdef!lbraceatcmd[@{]% - !gdef!rbraceatcmd[@}]% -!endgroup - -% @comma{} to avoid , parsing problems. -\let\comma = , - -% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent -% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. -\let\, = \ptexc -\let\dotaccent = \ptexdot -\def\ringaccent#1{{\accent23 #1}} -\let\tieaccent = \ptext -\let\ubaraccent = \ptexb -\let\udotaccent = \d - -% Other special characters: @questiondown @exclamdown @ordf @ordm -% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. -\def\questiondown{?`} -\def\exclamdown{!`} -\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} -\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} - -% Dotless i and dotless j, used for accents. -\def\imacro{i} -\def\jmacro{j} -\def\dotless#1{% - \def\temp{#1}% - \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi - \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi - \else \errmessage{@dotless can be used only with i or j}% - \fi\fi -} - -% The \TeX{} logo, as in plain, but resetting the spacing so that a -% period following counts as ending a sentence. (Idea found in latex.) -% -\edef\TeX{\TeX \spacefactor=1000 } - -% @LaTeX{} logo. Not quite the same results as the definition in -% latex.ltx, since we use a different font for the raised A; it's most -% convenient for us to use an explicitly smaller font, rather than using -% the \scriptstyle font (since we don't reset \scriptstyle and -% \scriptscriptstyle). -% -\def\LaTeX{% - L\kern-.36em - {\setbox0=\hbox{T}% - \vbox to \ht0{\hbox{% - \ifx\textnominalsize\xwordpt - % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX. - % Revert to plain's \scriptsize, which is 7pt. - \count255=\the\fam $\fam\count255 \scriptstyle A$% - \else - % For 11pt, we can use our lllsize. - \selectfonts\lllsize A% - \fi - }% - \vss - }}% - \kern-.15em - \TeX -} - -% Some math mode symbols. -\def\bullet{$\ptexbullet$} -\def\geq{\ifmmode \ge\else $\ge$\fi} -\def\leq{\ifmmode \le\else $\le$\fi} -\def\minus{\ifmmode -\else $-$\fi} - -% @dots{} outputs an ellipsis using the current font. -% We do .5em per period so that it has the same spacing in the cm -% typewriter fonts as three actual period characters; on the other hand, -% in other typewriter fonts three periods are wider than 1.5em. So do -% whichever is larger. -% -\def\dots{% - \leavevmode - \setbox0=\hbox{...}% get width of three periods - \ifdim\wd0 > 1.5em - \dimen0 = \wd0 - \else - \dimen0 = 1.5em - \fi - \hbox to \dimen0{% - \hskip 0pt plus.25fil - .\hskip 0pt plus1fil - .\hskip 0pt plus1fil - .\hskip 0pt plus.5fil - }% -} - -% @enddots{} is an end-of-sentence ellipsis. -% -\def\enddots{% - \dots - \spacefactor=\endofsentencespacefactor -} - -% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. -% -% Since these characters are used in examples, they should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% -\def\point{$\star$} -\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} -\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} -\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% The @error{} command. -% Adapted from the TeXbook's \boxit. -% -\newbox\errorbox -% -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} -% -\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{% - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} -% -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @pounds{} is a sterling sign, which Knuth put in the CM italic font. -% -\def\pounds{{\it\$}} - -% @euro{} comes from a separate font, depending on the current style. -% We use the free feym* fonts from the eurosym package by Henrik -% Theiling, which support regular, slanted, bold and bold slanted (and -% "outlined" (blackboard board, sort of) versions, which we don't need). -% It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% -% Although only regular is the truly official Euro symbol, we ignore -% that. The Euro is designed to be slightly taller than the regular -% font height. -% -% feymr - regular -% feymo - slanted -% feybr - bold -% feybo - bold slanted -% -% There is no good (free) typewriter version, to my knowledge. -% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. -% Hmm. -% -% Also doesn't work in math. Do we need to do math with euro symbols? -% Hope not. -% -% -\def\euro{{\eurofont e}} -\def\eurofont{% - % We set the font at each command, rather than predefining it in - % \textfonts and the other font-switching commands, so that - % installations which never need the symbol don't have to have the - % font installed. - % - % There is only one designed size (nominal 10pt), so we always scale - % that to the current nominal size. - % - % By the way, simply using "at 1em" works for cmr10 and the like, but - % does not work for cmbx10 and other extended/shrunken fonts. - % - \def\eurosize{\csname\curfontsize nominalsize\endcsname}% - % - \ifx\curfontstyle\bfstylename - % bold: - \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else - % regular: - \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize - \fi - \thiseurofont -} - -% Glyphs from the EC fonts. We don't use \let for the aliases, because -% sometimes we redefine the original macro, and the alias should reflect -% the redefinition. -% -% Use LaTeX names for the Icelandic letters. -\def\DH{{\ecfont \char"D0}} % Eth -\def\dh{{\ecfont \char"F0}} % eth -\def\TH{{\ecfont \char"DE}} % Thorn -\def\th{{\ecfont \char"FE}} % thorn -% -\def\guillemetleft{{\ecfont \char"13}} -\def\guillemotleft{\guillemetleft} -\def\guillemetright{{\ecfont \char"14}} -\def\guillemotright{\guillemetright} -\def\guilsinglleft{{\ecfont \char"0E}} -\def\guilsinglright{{\ecfont \char"0F}} -\def\quotedblbase{{\ecfont \char"12}} -\def\quotesinglbase{{\ecfont \char"0D}} -% -% This positioning is not perfect (see the ogonek LaTeX package), but -% we have the precomposed glyphs for the most common cases. We put the -% tests to use those glyphs in the single \ogonek macro so we have fewer -% dummy definitions to worry about for index entries, etc. -% -% ogonek is also used with other letters in Lithuanian (IOU), but using -% the precomposed glyphs for those is not so easy since they aren't in -% the same EC font. -\def\ogonek#1{{% - \def\temp{#1}% - \ifx\temp\macrocharA\Aogonek - \else\ifx\temp\macrochara\aogonek - \else\ifx\temp\macrocharE\Eogonek - \else\ifx\temp\macrochare\eogonek - \else - \ecfont \setbox0=\hbox{#1}% - \ifdim\ht0=1ex\accent"0C #1% - \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% - \fi - \fi\fi\fi\fi - }% -} -\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} -\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} -\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} -\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} -% -% Use the ec* fonts (cm-super in outline format) for non-CM glyphs. -\def\ecfont{% - % We can't distinguish serif/sans and italic/slanted, but this - % is used for crude hacks anyway (like adding French and German - % quotes to documents typeset with CM, where we lose kerning), so - % hopefully nobody will notice/care. - \edef\ecsize{\csname\curfontsize ecsize\endcsname}% - \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% - \ifmonospace - % typewriter: - \font\thisecfont = ectt\ecsize \space at \nominalsize - \else - \ifx\curfontstyle\bfstylename - % bold: - \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize - \else - % regular: - \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize - \fi - \fi - \thisecfont -} - -% @registeredsymbol - R in a circle. The font for the R should really -% be smaller yet, but lllsize is the best we can do for now. -% Adapted from the plain.tex definition of \copyright. -% -\def\registeredsymbol{% - $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% - \hfil\crcr\Orb}}% - }$% -} - -% @textdegree - the normal degrees sign. -% -\def\textdegree{$^\circ$} - -% Laurent Siebenmann reports \Orb undefined with: -% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 -% so we'll define it if necessary. -% -\ifx\Orb\thisisundefined -\def\Orb{\mathhexbox20D} -\fi - -% Quotes. -\chardef\quotedblleft="5C -\chardef\quotedblright=`\" -\chardef\quoteleft=`\` -\chardef\quoteright=`\' - - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\newif\ifseenauthor -\newif\iffinishedtitlepage - -% Do an implicit @contents or @shortcontents after @end titlepage if the -% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. -% -\newif\ifsetcontentsaftertitlepage - \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue -\newif\ifsetshortcontentsaftertitlepage - \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue - -\parseargdef\shorttitlepage{% - \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} - -\envdef\titlepage{% - % Open one extra group, as we want to close it in the middle of \Etitlepage. - \begingroup - \parindent=0pt \textfonts - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \let\page = \oldpage - \page - \null - }% -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - % - % Need this before the \...aftertitlepage checks so that if they are - % in effect the toc pages will come out with page numbers. - \HEADINGSon - % - % If they want short, they certainly want long too. - \ifsetshortcontentsaftertitlepage - \shortcontents - \contents - \global\let\shortcontents = \relax - \global\let\contents = \relax - \fi - % - \ifsetcontentsaftertitlepage - \contents - \global\let\contents = \relax - \global\let\shortcontents = \relax - \fi -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt width \hsize - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -% Settings used for typesetting titles: no hyphenation, no indentation, -% don't worry much about spacing, ragged right. This should be used -% inside a \vbox, and fonts need to be set appropriately first. Because -% it is always used for titles, nothing else, we call \rmisbold. \par -% should be specified before the end of the \vbox, since a vbox is a group. -% -\def\raggedtitlesettings{% - \rmisbold - \hyphenpenalty=10000 - \parindent=0pt - \tolerance=5000 - \ptexraggedright -} - -% Macros to be used within @titlepage: - -\let\subtitlerm=\tenrm -\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} - -\parseargdef\title{% - \checkenv\titlepage - \vbox{\titlefonts \raggedtitlesettings #1\par}% - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt width \hsize \vskip4pt -} - -\parseargdef\subtitle{% - \checkenv\titlepage - {\subtitlefont \rightline{#1}}% -} - -% @author should come last, but may come many times. -% It can also be used inside @quotation. -% -\parseargdef\author{% - \def\temp{\quotation}% - \ifx\thisenv\temp - \def\quotationauthor{#1}% printed in \Equotation. - \else - \checkenv\titlepage - \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi - {\secfonts\rmisbold \leftline{#1}}% - \fi -} - - -% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks\evenheadline % headline on even pages -\newtoks\oddheadline % headline on odd pages -\newtoks\evenfootline % footline on even pages -\newtoks\oddfootline % footline on odd pages - -% Now make TeX use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - - -\def\evenheading{\parsearg\evenheadingxxx} -\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} -\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\def\oddheading{\parsearg\oddheadingxxx} -\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} -\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} -\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\def\oddfooting{\parsearg\oddfootingxxx} -\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} -\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% - \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% - % - % Leave some space for the footline. Hopefully ok to assume - % @evenfooting will not be used by itself. - \global\advance\pageheight by -12pt - \global\advance\vsize by -12pt -} - -\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} - -% @evenheadingmarks top \thischapter <- chapter at the top of a page -% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page -% -% The same set of arguments for: -% -% @oddheadingmarks -% @evenfootingmarks -% @oddfootingmarks -% @everyheadingmarks -% @everyfootingmarks - -\def\evenheadingmarks{\headingmarks{even}{heading}} -\def\oddheadingmarks{\headingmarks{odd}{heading}} -\def\evenfootingmarks{\headingmarks{even}{footing}} -\def\oddfootingmarks{\headingmarks{odd}{footing}} -\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} - \headingmarks{odd}{heading}{#1} } -\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} - \headingmarks{odd}{footing}{#1} } -% #1 = even/odd, #2 = heading/footing, #3 = top/bottom. -\def\headingmarks#1#2#3 {% - \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname - \global\expandafter\let\csname get#1#2marks\endcsname \temp -} - -\everyheadingmarks bottom -\everyfootingmarks bottom - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off at the start of a document, -% and turned `on' after @end titlepage. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\headingsoff{% non-global headings elimination - \evenheadline={\hfil}\evenfootline={\hfil}% - \oddheadline={\hfil}\oddfootline={\hfil}% -} - -\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting -\HEADINGSoff % it's the default - -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{% -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chapoddpage -} -\let\contentsalignmacro = \chappager - -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{% -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chappager -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chapoddpage -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chappager -} - -% Subroutines used in generating headings -% This produces Day Month Year style of output. -% Only define if not already defined, in case a txi-??.tex file has set -% up a different format (e.g., txi-cs.tex does this). -\ifx\today\thisisundefined -\def\today{% - \number\day\space - \ifcase\month - \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr - \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug - \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec - \fi - \space\number\year} -\fi - -% @settitle line... specifies the title of the document, for headings. -% It generates no output of its own. -\def\thistitle{\putwordNoTitle} -\def\settitle{\parsearg{\gdef\thistitle}} - - -\message{tables,} -% Tables -- @table, @ftable, @vtable, @item(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @ftable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\newif\ifitemxneedsnegativevskip - -\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\itemxpar \parsearg\itemzzz} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemindicate{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - % - % Make this a paragraph so we get the \parskip glue and wrapping, - % but leave it ragged-right. - \begingroup - \advance\leftskip by-\tableindent - \advance\hsize by\tableindent - \advance\rightskip by0pt plus1fil\relax - \leavevmode\unhbox0\par - \endgroup - % - % We're going to be starting a paragraph, but we don't want the - % \parskip glue -- logically it's part of the @item we just started. - \nobreak \vskip-\parskip - % - % Stop a page break at the \parskip glue coming up. However, if - % what follows is an environment such as @example, there will be no - % \parskip glue; then the negative vskip we just inserted would - % cause the example and the item to crash together. So we use this - % bizarre value of 10001 as a signal to \aboveenvbreak to insert - % \parskip glue after all. Section titles are handled this way also. - % - \penalty 10001 - \endgroup - \itemxneedsnegativevskipfalse - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. - \noindent - % Do this with kerns and \unhbox so that if there is a footnote in - % the item text, it can migrate to the main vertical list and - % eventually be printed. - \nobreak\kern-\tableindent - \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 - \unhbox0 - \nobreak\kern\dimen0 - \endgroup - \itemxneedsnegativevskiptrue - \fi -} - -\def\item{\errmessage{@item while not in a list environment}} -\def\itemx{\errmessage{@itemx while not in a list environment}} - -% @table, @ftable, @vtable. -\envdef\table{% - \let\itemindex\gobble - \tablecheck{table}% -} -\envdef\ftable{% - \def\itemindex ##1{\doind {fn}{\code{##1}}}% - \tablecheck{ftable}% -} -\envdef\vtable{% - \def\itemindex ##1{\doind {vr}{\code{##1}}}% - \tablecheck{vtable}% -} -\def\tablecheck#1{% - \ifnum \the\catcode`\^^M=\active - \endgroup - \errmessage{This command won't work in this context; perhaps the problem is - that we are \inenvironment\thisenv}% - \def\next{\doignore{#1}}% - \else - \let\next\tablex - \fi - \next -} -\def\tablex#1{% - \def\itemindicate{#1}% - \parsearg\tabley -} -\def\tabley#1{% - {% - \makevalueexpandable - \edef\temp{\noexpand\tablez #1\space\space\space}% - \expandafter - }\temp \endtablez -} -\def\tablez #1 #2 #3 #4\endtablez{% - \aboveenvbreak - \ifnum 0#1>0 \advance \leftskip by #1\mil \fi - \ifnum 0#2>0 \tableindent=#2\mil \fi - \ifnum 0#3>0 \advance \rightskip by #3\mil \fi - \itemmax=\tableindent - \advance \itemmax by -\itemmargin - \advance \leftskip by \tableindent - \exdentamount=\tableindent - \parindent = 0pt - \parskip = \smallskipamount - \ifdim \parskip=0pt \parskip=2pt \fi - \let\item = \internalBitem - \let\itemx = \internalBitemx -} -\def\Etable{\endgraf\afterenvbreak} -\let\Eftable\Etable -\let\Evtable\Etable -\let\Eitemize\Etable -\let\Eenumerate\Etable - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\envdef\itemize{\parsearg\doitemize} - -\def\doitemize#1{% - \aboveenvbreak - \itemmax=\itemindent - \advance\itemmax by -\itemmargin - \advance\leftskip by \itemindent - \exdentamount=\itemindent - \parindent=0pt - \parskip=\smallskipamount - \ifdim\parskip=0pt \parskip=2pt \fi - % - % Try typesetting the item mark that if the document erroneously says - % something like @itemize @samp (intending @table), there's an error - % right away at the @itemize. It's not the best error message in the - % world, but it's better than leaving it to the @item. This means if - % the user wants an empty mark, they have to say @w{} not just @w. - \def\itemcontents{#1}% - \setbox0 = \hbox{\itemcontents}% - % - % @itemize with no arg is equivalent to @itemize @bullet. - \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi - % - \let\item=\itemizeitem -} - -% Definition of @item while inside @itemize and @enumerate. -% -\def\itemizeitem{% - \advance\itemno by 1 % for enumerations - {\let\par=\endgraf \smallbreak}% reasonable place to break - {% - % If the document has an @itemize directly after a section title, a - % \nobreak will be last on the list, and \sectionheading will have - % done a \vskip-\parskip. In that case, we don't want to zero - % parskip, or the item text will crash with the heading. On the - % other hand, when there is normal text preceding the item (as there - % usually is), we do want to zero parskip, or there would be too much - % space. In that case, we won't have a \nobreak before. At least - % that's the theory. - \ifnum\lastpenalty<10000 \parskip=0in \fi - \noindent - \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% - % - \vadjust{\penalty 1200}}% not good to break after first line of item. - \flushcr -} - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a . - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call \doitemize, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \doitemize{#1.}\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - - -% @multitable macros -% Amy Hendrickson, 8/18/94, 3/6/96 -% -% @multitable ... @end multitable will make as many columns as desired. -% Contents of each column will wrap at width given in preamble. Width -% can be specified either with sample text given in a template line, -% or in percent of \hsize, the current width of text on page. - -% Table can continue over pages but will only break between lines. - -% To make preamble: -% -% Either define widths of columns in terms of percent of \hsize: -% @multitable @columnfractions .25 .3 .45 -% @item ... -% -% Numbers following @columnfractions are the percent of the total -% current hsize to be used for each column. You may use as many -% columns as desired. - - -% Or use a template: -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item ... -% using the widest term desired in each column. - -% Each new table line starts with @item, each subsequent new column -% starts with @tab. Empty columns may be produced by supplying @tab's -% with nothing between them for as many times as empty columns are needed, -% ie, @tab@tab@tab will produce two empty columns. - -% @item, @tab do not need to be on their own lines, but it will not hurt -% if they are. - -% Sample multitable: - -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item first col stuff @tab second col stuff @tab third col -% @item -% first col stuff -% @tab -% second col stuff -% @tab -% third col -% @item first col stuff @tab second col stuff -% @tab Many paragraphs of text may be used in any column. -% -% They will wrap at the width determined by the template. -% @item@tab@tab This will be in third column. -% @end multitable - -% Default dimensions may be reset by user. -% @multitableparskip is vertical space between paragraphs in table. -% @multitableparindent is paragraph indent in table. -% @multitablecolmargin is horizontal space to be left between columns. -% @multitablelinespace is space to leave between table items, baseline -% to baseline. -% 0pt means it depends on current normal line spacing. -% -\newskip\multitableparskip -\newskip\multitableparindent -\newdimen\multitablecolspace -\newskip\multitablelinespace -\multitableparskip=0pt -\multitableparindent=6pt -\multitablecolspace=12pt -\multitablelinespace=0pt - -% Macros used to set up halign preamble: -% -\let\endsetuptable\relax -\def\xendsetuptable{\endsetuptable} -\let\columnfractions\relax -\def\xcolumnfractions{\columnfractions} -\newif\ifsetpercent - -% #1 is the @columnfraction, usually a decimal number like .5, but might -% be just 1. We just use it, whatever it is. -% -\def\pickupwholefraction#1 {% - \global\advance\colcount by 1 - \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% - \setuptable -} - -\newcount\colcount -\def\setuptable#1{% - \def\firstarg{#1}% - \ifx\firstarg\xendsetuptable - \let\go = \relax - \else - \ifx\firstarg\xcolumnfractions - \global\setpercenttrue - \else - \ifsetpercent - \let\go\pickupwholefraction - \else - \global\advance\colcount by 1 - \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a - % separator; typically that is always in the input, anyway. - \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% - \fi - \fi - \ifx\go\pickupwholefraction - % Put the argument back for the \pickupwholefraction call, so - % we'll always have a period there to be parsed. - \def\go{\pickupwholefraction#1}% - \else - \let\go = \setuptable - \fi% - \fi - \go -} - -% multitable-only commands. -% -% @headitem starts a heading row, which we typeset in bold. -% Assignments have to be global since we are inside the implicit group -% of an alignment entry. \everycr resets \everytab so we don't have to -% undo it ourselves. -\def\headitemfont{\b}% for people to use in the template row; not changeable -\def\headitem{% - \checkenv\multitable - \crcr - \global\everytab={\bf}% can't use \headitemfont since the parsing differs - \the\everytab % for the first item -}% -% -% A \tab used to include \hskip1sp. But then the space in a template -% line is not enough. That is bad. So let's go back to just `&' until -% we again encounter the problem the 1sp was intended to solve. -% --karl, nathan@acm.org, 20apr99. -\def\tab{\checkenv\multitable &\the\everytab}% - -% @multitable ... @end multitable definitions: -% -\newtoks\everytab % insert after every tab. -% -\envdef\multitable{% - \vskip\parskip - \startsavinginserts - % - % @item within a multitable starts a normal row. - % We use \def instead of \let so that if one of the multitable entries - % contains an @itemize, we don't choke on the \item (seen as \crcr aka - % \endtemplate) expanding \doitemize. - \def\item{\crcr}% - % - \tolerance=9500 - \hbadness=9500 - \setmultitablespacing - \parskip=\multitableparskip - \parindent=\multitableparindent - \overfullrule=0pt - \global\colcount=0 - % - \everycr = {% - \noalign{% - \global\everytab={}% - \global\colcount=0 % Reset the column counter. - % Check for saved footnotes, etc. - \checkinserts - % Keeps underfull box messages off when table breaks over pages. - %\filbreak - % Maybe so, but it also creates really weird page breaks when the - % table breaks over pages. Wouldn't \vfil be better? Wait until the - % problem manifests itself, so it can be fixed for real --karl. - }% - }% - % - \parsearg\domultitable -} -\def\domultitable#1{% - % To parse everything between @multitable and @item: - \setuptable#1 \endsetuptable - % - % This preamble sets up a generic column definition, which will - % be used as many times as user calls for columns. - % \vtop will set a single line and will also let text wrap and - % continue for many paragraphs if desired. - \halign\bgroup &% - \global\advance\colcount by 1 - \multistrut - \vtop{% - % Use the current \colcount to find the correct column width: - \hsize=\expandafter\csname col\the\colcount\endcsname - % - % In order to keep entries from bumping into each other - % we will add a \leftskip of \multitablecolspace to all columns after - % the first one. - % - % If a template has been used, we will add \multitablecolspace - % to the width of each template entry. - % - % If the user has set preamble in terms of percent of \hsize we will - % use that dimension as the width of the column, and the \leftskip - % will keep entries from bumping into each other. Table will start at - % left margin and final column will justify at right margin. - % - % Make sure we don't inherit \rightskip from the outer environment. - \rightskip=0pt - \ifnum\colcount=1 - % The first column will be indented with the surrounding text. - \advance\hsize by\leftskip - \else - \ifsetpercent \else - % If user has not set preamble in terms of percent of \hsize - % we will advance \hsize by \multitablecolspace. - \advance\hsize by \multitablecolspace - \fi - % In either case we will make \leftskip=\multitablecolspace: - \leftskip=\multitablecolspace - \fi - % Ignoring space at the beginning and end avoids an occasional spurious - % blank line, when TeX decides to break the line at the space before the - % box from the multistrut, so the strut ends up on a line by itself. - % For example: - % @multitable @columnfractions .11 .89 - % @item @code{#} - % @tab Legal holiday which is valid in major parts of the whole country. - % Is automatically provided with highlighting sequences respectively - % marking characters. - \noindent\ignorespaces##\unskip\multistrut - }\cr -} -\def\Emultitable{% - \crcr - \egroup % end the \halign - \global\setpercentfalse -} - -\def\setmultitablespacing{% - \def\multistrut{\strut}% just use the standard line spacing - % - % Compute \multitablelinespace (if not defined by user) for use in - % \multitableparskip calculation. We used define \multistrut based on - % this, but (ironically) that caused the spacing to be off. - % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. -\ifdim\multitablelinespace=0pt -\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip -\global\advance\multitablelinespace by-\ht0 -\fi -% Test to see if parskip is larger than space between lines of -% table. If not, do nothing. -% If so, set to same dimension as multitablelinespace. -\ifdim\multitableparskip>\multitablelinespace -\global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller - % than skip between lines in the table. -\fi% -\ifdim\multitableparskip=0pt -\global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller - % than skip between lines in the table. -\fi} - - -\message{conditionals,} - -% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, -% @ifnotxml always succeed. They currently do nothing; we don't -% attempt to check whether the conditionals are properly nested. But we -% have to remember that they are conditionals, so that @end doesn't -% attempt to close an environment group. -% -\def\makecond#1{% - \expandafter\let\csname #1\endcsname = \relax - \expandafter\let\csname iscond.#1\endcsname = 1 -} -\makecond{iftex} -\makecond{ifnotdocbook} -\makecond{ifnothtml} -\makecond{ifnotinfo} -\makecond{ifnotplaintext} -\makecond{ifnotxml} - -% Ignore @ignore, @ifhtml, @ifinfo, and the like. -% -\def\direntry{\doignore{direntry}} -\def\documentdescription{\doignore{documentdescription}} -\def\docbook{\doignore{docbook}} -\def\html{\doignore{html}} -\def\ifdocbook{\doignore{ifdocbook}} -\def\ifhtml{\doignore{ifhtml}} -\def\ifinfo{\doignore{ifinfo}} -\def\ifnottex{\doignore{ifnottex}} -\def\ifplaintext{\doignore{ifplaintext}} -\def\ifxml{\doignore{ifxml}} -\def\ignore{\doignore{ignore}} -\def\menu{\doignore{menu}} -\def\xml{\doignore{xml}} - -% Ignore text until a line `@end #1', keeping track of nested conditionals. -% -% A count to remember the depth of nesting. -\newcount\doignorecount - -\def\doignore#1{\begingroup - % Scan in ``verbatim'' mode: - \obeylines - \catcode`\@ = \other - \catcode`\{ = \other - \catcode`\} = \other - % - % Make sure that spaces turn into tokens that match what \doignoretext wants. - \spaceisspace - % - % Count number of #1's that we've seen. - \doignorecount = 0 - % - % Swallow text until we reach the matching `@end #1'. - \dodoignore{#1}% -} - -{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. - \obeylines % - % - \gdef\dodoignore#1{% - % #1 contains the command name as a string, e.g., `ifinfo'. - % - % Define a command to find the next `@end #1'. - \long\def\doignoretext##1^^M@end #1{% - \doignoretextyyy##1^^M@#1\_STOP_}% - % - % And this command to find another #1 command, at the beginning of a - % line. (Otherwise, we would consider a line `@c @ifset', for - % example, to count as an @ifset for nesting.) - \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% - % - % And now expand that command. - \doignoretext ^^M% - }% -} - -\def\doignoreyyy#1{% - \def\temp{#1}% - \ifx\temp\empty % Nothing found. - \let\next\doignoretextzzz - \else % Found a nested condition, ... - \advance\doignorecount by 1 - \let\next\doignoretextyyy % ..., look for another. - % If we're here, #1 ends with ^^M\ifinfo (for example). - \fi - \next #1% the token \_STOP_ is present just after this macro. -} - -% We have to swallow the remaining "\_STOP_". -% -\def\doignoretextzzz#1{% - \ifnum\doignorecount = 0 % We have just found the outermost @end. - \let\next\enddoignore - \else % Still inside a nested condition. - \advance\doignorecount by -1 - \let\next\doignoretext % Look for the next @end. - \fi - \next -} - -% Finish off ignored text. -{ \obeylines% - % Ignore anything after the last `@end #1'; this matters in verbatim - % environments, where otherwise the newline after an ignored conditional - % would result in a blank line in the output. - \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% -} - - -% @set VAR sets the variable VAR to an empty value. -% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. -% -% Since we want to separate VAR from REST-OF-LINE (which might be -% empty), we can't just use \parsearg; we have to insert a space of our -% own to delimit the rest of the line, and then take it out again if we -% didn't need it. -% We rely on the fact that \parsearg sets \catcode`\ =10. -% -\parseargdef\set{\setyyy#1 \endsetyyy} -\def\setyyy#1 #2\endsetyyy{% - {% - \makevalueexpandable - \def\temp{#2}% - \edef\next{\gdef\makecsname{SET#1}}% - \ifx\temp\empty - \next{}% - \else - \setzzz#2\endsetzzz - \fi - }% -} -% Remove the trailing space \setxxx inserted. -\def\setzzz#1 \endsetzzz{\next{#1}} - -% @clear VAR clears (i.e., unsets) the variable VAR. -% -\parseargdef\clear{% - {% - \makevalueexpandable - \global\expandafter\let\csname SET#1\endcsname=\relax - }% -} - -% @value{foo} gets the text saved in variable foo. -\def\value{\begingroup\makevalueexpandable\valuexxx} -\def\valuexxx#1{\expandablevalue{#1}\endgroup} -{ - \catcode`\- = \active \catcode`\_ = \active - % - \gdef\makevalueexpandable{% - \let\value = \expandablevalue - % We don't want these characters active, ... - \catcode`\-=\other \catcode`\_=\other - % ..., but we might end up with active ones in the argument if - % we're called from @code, as @code{@value{foo-bar_}}, though. - % So \let them to their normal equivalents. - \let-\normaldash \let_\normalunderscore - } -} - -% We have this subroutine so that we can handle at least some @value's -% properly in indexes (we call \makevalueexpandable in \indexdummies). -% The command has to be fully expandable (if the variable is set), since -% the result winds up in the index file. This means that if the -% variable's value contains other Texinfo commands, it's almost certain -% it will fail (although perhaps we could fix that with sufficient work -% to do a one-level expansion on the result, instead of complete). -% -\def\expandablevalue#1{% - \expandafter\ifx\csname SET#1\endcsname\relax - {[No value for ``#1'']}% - \message{Variable `#1', used in @value, is not set.}% - \else - \csname SET#1\endcsname - \fi -} - -% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined -% with @set. -% -% To get special treatment of `@end ifset,' call \makeond and the redefine. -% -\makecond{ifset} -\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} -\def\doifset#1#2{% - {% - \makevalueexpandable - \let\next=\empty - \expandafter\ifx\csname SET#2\endcsname\relax - #1% If not set, redefine \next. - \fi - \expandafter - }\next -} -\def\ifsetfail{\doignore{ifset}} - -% @ifclear VAR ... @end executes the `...' iff VAR has never been -% defined with @set, or has been undefined with @clear. -% -% The `\else' inside the `\doifset' parameter is a trick to reuse the -% above code: if the variable is not set, do nothing, if it is set, -% then redefine \next to \ifclearfail. -% -\makecond{ifclear} -\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} -\def\ifclearfail{\doignore{ifclear}} - -% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written -% without the @) is in fact defined. We can only feasibly check at the -% TeX level, so something like `mathcode' is going to considered -% defined even though it is not a Texinfo command. -% -\makecond{ifcommanddefined} -\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} -% -\def\doifcmddefined#1#2{{% - \makevalueexpandable - \let\next=\empty - \expandafter\ifx\csname #2\endcsname\relax - #1% If not defined, \let\next as above. - \fi - \expandafter - }\next -} -\def\ifcmddefinedfail{\doignore{ifcommanddefined}} - -% @ifcommandnotdefined CMD ... handled similar to @ifclear above. -\makecond{ifcommandnotdefined} -\def\ifcommandnotdefined{% - \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} -\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} - -% Set the `txicommandconditionals' variable, so documents have a way to -% test if the @ifcommand...defined conditionals are available. -\set txicommandconditionals - -% @dircategory CATEGORY -- specify a category of the dir file -% which this file should belong to. Ignore this in TeX. -\let\dircategory=\comment - -% @defininfoenclose. -\let\definfoenclose=\comment - - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within macros and \if's. -\edef\newwrite{\makecsname{ptexnewwrite}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. -% -\def\newindex#1{% - \iflinks - \expandafter\newwrite \csname#1indfile\endcsname - \openout \csname#1indfile\endcsname \jobname.#1 % Open the file - \fi - \expandafter\xdef\csname#1index\endcsname{% % Define @#1index - \noexpand\doindex{#1}} -} - -% @defindex foo == \newindex{foo} -% -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. -% -\def\defcodeindex{\parsearg\newcodeindex} -% -\def\newcodeindex#1{% - \iflinks - \expandafter\newwrite \csname#1indfile\endcsname - \openout \csname#1indfile\endcsname \jobname.#1 - \fi - \expandafter\xdef\csname#1index\endcsname{% - \noexpand\docodeindex{#1}}% -} - - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -% -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -% -\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} -\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} - -% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), -% #3 the target index (bar). -\def\dosynindex#1#2#3{% - % Only do \closeout if we haven't already done it, else we'll end up - % closing the target index. - \expandafter \ifx\csname donesynindex#2\endcsname \relax - % The \closeout helps reduce unnecessary open files; the limit on the - % Acorn RISC OS is a mere 16 files. - \expandafter\closeout\csname#2indfile\endcsname - \expandafter\let\csname donesynindex#2\endcsname = 1 - \fi - % redefine \fooindfile: - \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname - \expandafter\let\csname#2indfile\endcsname=\temp - % redefine \fooindex: - \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -% Take care of Texinfo commands that can appear in an index entry. -% Since there are some commands we want to expand, and others we don't, -% we have to laboriously prevent expansion for those that we don't. -% -\def\indexdummies{% - \escapechar = `\\ % use backslash in output files. - \def\@{@}% change to @@ when we switch to @ as escape char in index files. - \def\ {\realbackslash\space }% - % - % Need these unexpandable (because we define \tt as a dummy) - % definitions when @{ or @} appear in index entry text. Also, more - % complicated, when \tex is in effect and \{ is a \delimiter again. - % We can't use \lbracecmd and \rbracecmd because texindex assumes - % braces and backslashes are used only as delimiters. Perhaps we - % should define @lbrace and @rbrace commands a la @comma. - \def\{{{\tt\char123}}% - \def\}{{\tt\char125}}% - % - % I don't entirely understand this, but when an index entry is - % generated from a macro call, the \endinput which \scanmacro inserts - % causes processing to be prematurely terminated. This is, - % apparently, because \indexsorttmp is fully expanded, and \endinput - % is an expandable command. The redefinition below makes \endinput - % disappear altogether for that purpose -- although logging shows that - % processing continues to some further point. On the other hand, it - % seems \endinput does not hurt in the printed index arg, since that - % is still getting written without apparent harm. - % - % Sample source (mac-idx3.tex, reported by Graham Percival to - % help-texinfo, 22may06): - % @macro funindex {WORD} - % @findex xyz - % @end macro - % ... - % @funindex commtest - % - % The above is not enough to reproduce the bug, but it gives the flavor. - % - % Sample whatsit resulting: - % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} - % - % So: - \let\endinput = \empty - % - % Do the redefinitions. - \commondummies -} - -% For the aux and toc files, @ is the escape character. So we want to -% redefine everything using @ as the escape character (instead of -% \realbackslash, still used for index files). When everything uses @, -% this will be simpler. -% -\def\atdummies{% - \def\@{@@}% - \def\ {@ }% - \let\{ = \lbraceatcmd - \let\} = \rbraceatcmd - % - % Do the redefinitions. - \commondummies - \otherbackslash -} - -% Called from \indexdummies and \atdummies. -% -\def\commondummies{% - % - % \definedummyword defines \#1 as \string\#1\space, thus effectively - % preventing its expansion. This is used only for control words, - % not control letters, because the \space would be incorrect for - % control characters, but is needed to separate the control word - % from whatever follows. - % - % For control letters, we have \definedummyletter, which omits the - % space. - % - % These can be used both for control words that take an argument and - % those that do not. If it is followed by {arg} in the input, then - % that will dutifully get written to the index (or wherever). - % - \def\definedummyword ##1{\def##1{\string##1\space}}% - \def\definedummyletter##1{\def##1{\string##1}}% - \let\definedummyaccent\definedummyletter - % - \commondummiesnofonts - % - \definedummyletter\_% - \definedummyletter\-% - % - % Non-English letters. - \definedummyword\AA - \definedummyword\AE - \definedummyword\DH - \definedummyword\L - \definedummyword\O - \definedummyword\OE - \definedummyword\TH - \definedummyword\aa - \definedummyword\ae - \definedummyword\dh - \definedummyword\exclamdown - \definedummyword\l - \definedummyword\o - \definedummyword\oe - \definedummyword\ordf - \definedummyword\ordm - \definedummyword\questiondown - \definedummyword\ss - \definedummyword\th - % - % Although these internal commands shouldn't show up, sometimes they do. - \definedummyword\bf - \definedummyword\gtr - \definedummyword\hat - \definedummyword\less - \definedummyword\sf - \definedummyword\sl - \definedummyword\tclose - \definedummyword\tt - % - \definedummyword\LaTeX - \definedummyword\TeX - % - % Assorted special characters. - \definedummyword\arrow - \definedummyword\bullet - \definedummyword\comma - \definedummyword\copyright - \definedummyword\registeredsymbol - \definedummyword\dots - \definedummyword\enddots - \definedummyword\entrybreak - \definedummyword\equiv - \definedummyword\error - \definedummyword\euro - \definedummyword\expansion - \definedummyword\geq - \definedummyword\guillemetleft - \definedummyword\guillemetright - \definedummyword\guilsinglleft - \definedummyword\guilsinglright - \definedummyword\lbracechar - \definedummyword\leq - \definedummyword\minus - \definedummyword\ogonek - \definedummyword\pounds - \definedummyword\point - \definedummyword\print - \definedummyword\quotedblbase - \definedummyword\quotedblleft - \definedummyword\quotedblright - \definedummyword\quoteleft - \definedummyword\quoteright - \definedummyword\quotesinglbase - \definedummyword\rbracechar - \definedummyword\result - \definedummyword\textdegree - % - % We want to disable all macros so that they are not expanded by \write. - \macrolist - % - \normalturnoffactive - % - % Handle some cases of @value -- where it does not contain any - % (non-fully-expandable) commands. - \makevalueexpandable -} - -% \commondummiesnofonts: common to \commondummies and \indexnofonts. -% -\def\commondummiesnofonts{% - % Control letters and accents. - \definedummyletter\!% - \definedummyaccent\"% - \definedummyaccent\'% - \definedummyletter\*% - \definedummyaccent\,% - \definedummyletter\.% - \definedummyletter\/% - \definedummyletter\:% - \definedummyaccent\=% - \definedummyletter\?% - \definedummyaccent\^% - \definedummyaccent\`% - \definedummyaccent\~% - \definedummyword\u - \definedummyword\v - \definedummyword\H - \definedummyword\dotaccent - \definedummyword\ogonek - \definedummyword\ringaccent - \definedummyword\tieaccent - \definedummyword\ubaraccent - \definedummyword\udotaccent - \definedummyword\dotless - % - % Texinfo font commands. - \definedummyword\b - \definedummyword\i - \definedummyword\r - \definedummyword\sansserif - \definedummyword\sc - \definedummyword\slanted - \definedummyword\t - % - % Commands that take arguments. - \definedummyword\abbr - \definedummyword\acronym - \definedummyword\anchor - \definedummyword\cite - \definedummyword\code - \definedummyword\command - \definedummyword\dfn - \definedummyword\dmn - \definedummyword\email - \definedummyword\emph - \definedummyword\env - \definedummyword\file - \definedummyword\image - \definedummyword\indicateurl - \definedummyword\inforef - \definedummyword\kbd - \definedummyword\key - \definedummyword\math - \definedummyword\option - \definedummyword\pxref - \definedummyword\ref - \definedummyword\samp - \definedummyword\strong - \definedummyword\tie - \definedummyword\uref - \definedummyword\url - \definedummyword\var - \definedummyword\verb - \definedummyword\w - \definedummyword\xref -} - -% \indexnofonts is used when outputting the strings to sort the index -% by, and when constructing control sequence names. It eliminates all -% control sequences and just writes whatever the best ASCII sort string -% would be for a given command (usually its argument). -% -\def\indexnofonts{% - % Accent commands should become @asis. - \def\definedummyaccent##1{\let##1\asis}% - % We can just ignore other control letters. - \def\definedummyletter##1{\let##1\empty}% - % All control words become @asis by default; overrides below. - \let\definedummyword\definedummyaccent - % - \commondummiesnofonts - % - % Don't no-op \tt, since it isn't a user-level command - % and is used in the definitions of the active chars like <, >, |, etc. - % Likewise with the other plain tex font commands. - %\let\tt=\asis - % - \def\ { }% - \def\@{@}% - \def\_{\normalunderscore}% - \def\-{}% @- shouldn't affect sorting - % - % Unfortunately, texindex is not prepared to handle braces in the - % content at all. So for index sorting, we map @{ and @} to strings - % starting with |, since that ASCII character is between ASCII { and }. - \def\{{|a}% - \def\lbracechar{|a}% - % - \def\}{|b}% - \def\rbracechar{|b}% - % - % Non-English letters. - \def\AA{AA}% - \def\AE{AE}% - \def\DH{DZZ}% - \def\L{L}% - \def\OE{OE}% - \def\O{O}% - \def\TH{ZZZ}% - \def\aa{aa}% - \def\ae{ae}% - \def\dh{dzz}% - \def\exclamdown{!}% - \def\l{l}% - \def\oe{oe}% - \def\ordf{a}% - \def\ordm{o}% - \def\o{o}% - \def\questiondown{?}% - \def\ss{ss}% - \def\th{zzz}% - % - \def\LaTeX{LaTeX}% - \def\TeX{TeX}% - % - % Assorted special characters. - % (The following {} will end up in the sort string, but that's ok.) - \def\arrow{->}% - \def\bullet{bullet}% - \def\comma{,}% - \def\copyright{copyright}% - \def\dots{...}% - \def\enddots{...}% - \def\equiv{==}% - \def\error{error}% - \def\euro{euro}% - \def\expansion{==>}% - \def\geq{>=}% - \def\guillemetleft{<<}% - \def\guillemetright{>>}% - \def\guilsinglleft{<}% - \def\guilsinglright{>}% - \def\leq{<=}% - \def\minus{-}% - \def\point{.}% - \def\pounds{pounds}% - \def\print{-|}% - \def\quotedblbase{"}% - \def\quotedblleft{"}% - \def\quotedblright{"}% - \def\quoteleft{`}% - \def\quoteright{'}% - \def\quotesinglbase{,}% - \def\registeredsymbol{R}% - \def\result{=>}% - \def\textdegree{o}% - % - \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax - \else \indexlquoteignore \fi - % - % We need to get rid of all macros, leaving only the arguments (if present). - % Of course this is not nearly correct, but it is the best we can do for now. - % makeinfo does not expand macros in the argument to @deffn, which ends up - % writing an index entry, and texindex isn't prepared for an index sort entry - % that starts with \. - % - % Since macro invocations are followed by braces, we can just redefine them - % to take a single TeX argument. The case of a macro invocation that - % goes to end-of-line is not handled. - % - \macrolist -} - -% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us -% ignore left quotes in the sort term. -{\catcode`\`=\active - \gdef\indexlquoteignore{\let`=\empty}} - -\let\indexbackslash=0 %overridden during \printindex. -\let\SETmarginindex=\relax % put index entries in margin (undocumented)? - -% Most index entries go through here, but \dosubind is the general case. -% #1 is the index name, #2 is the entry text. -\def\doind#1#2{\dosubind{#1}{#2}{}} - -% Workhorse for all \fooindexes. -% #1 is name of index, #2 is stuff to put there, #3 is subentry -- -% empty if called from \doind, as we usually are (the main exception -% is with most defuns, which call us directly). -% -\def\dosubind#1#2#3{% - \iflinks - {% - % Store the main index entry text (including the third arg). - \toks0 = {#2}% - % If third arg is present, precede it with a space. - \def\thirdarg{#3}% - \ifx\thirdarg\empty \else - \toks0 = \expandafter{\the\toks0 \space #3}% - \fi - % - \edef\writeto{\csname#1indfile\endcsname}% - % - \safewhatsit\dosubindwrite - }% - \fi -} - -% Write the entry in \toks0 to the index file: -% -\def\dosubindwrite{% - % Put the index entry in the margin if desired. - \ifx\SETmarginindex\relax\else - \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% - \fi - % - % Remember, we are within a group. - \indexdummies % Must do this here, since \bf, etc expand at this stage - \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now - % so it will be output as is; and it will print as backslash. - % - % Process the index entry with all font commands turned off, to - % get the string to sort by. - {\indexnofonts - \edef\temp{\the\toks0}% need full expansion - \xdef\indexsorttmp{\temp}% - }% - % - % Set up the complete index entry, with both the sort key and - % the original text, including any font commands. We write - % three arguments to \entry to the .?? file (four in the - % subentry case), texindex reduces to two when writing the .??s - % sorted result. - \edef\temp{% - \write\writeto{% - \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% - }% - \temp -} - -% Take care of unwanted page breaks/skips around a whatsit: -% -% If a skip is the last thing on the list now, preserve it -% by backing up by \lastskip, doing the \write, then inserting -% the skip again. Otherwise, the whatsit generated by the -% \write or \pdfdest will make \lastskip zero. The result is that -% sequences like this: -% @end defun -% @tindex whatever -% @defun ... -% will have extra space inserted, because the \medbreak in the -% start of the @defun won't see the skip inserted by the @end of -% the previous defun. -% -% But don't do any of this if we're not in vertical mode. We -% don't want to do a \vskip and prematurely end a paragraph. -% -% Avoid page breaks due to these extra skips, too. -% -% But wait, there is a catch there: -% We'll have to check whether \lastskip is zero skip. \ifdim is not -% sufficient for this purpose, as it ignores stretch and shrink parts -% of the skip. The only way seems to be to check the textual -% representation of the skip. -% -% The following is almost like \def\zeroskipmacro{0.0pt} except that -% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). -% -\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} -% -\newskip\whatsitskip -\newcount\whatsitpenalty -% -% ..., ready, GO: -% -\def\safewhatsit#1{\ifhmode - #1% - \else - % \lastskip and \lastpenalty cannot both be nonzero simultaneously. - \whatsitskip = \lastskip - \edef\lastskipmacro{\the\lastskip}% - \whatsitpenalty = \lastpenalty - % - % If \lastskip is nonzero, that means the last item was a - % skip. And since a skip is discardable, that means this - % -\whatsitskip glue we're inserting is preceded by a - % non-discardable item, therefore it is not a potential - % breakpoint, therefore no \nobreak needed. - \ifx\lastskipmacro\zeroskipmacro - \else - \vskip-\whatsitskip - \fi - % - #1% - % - \ifx\lastskipmacro\zeroskipmacro - % If \lastskip was zero, perhaps the last item was a penalty, and - % perhaps it was >=10000, e.g., a \nobreak. In that case, we want - % to re-insert the same penalty (values >10000 are used for various - % signals); since we just inserted a non-discardable item, any - % following glue (such as a \parskip) would be a breakpoint. For example: - % @deffn deffn-whatever - % @vindex index-whatever - % Description. - % would allow a break between the index-whatever whatsit - % and the "Description." paragraph. - \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi - \else - % On the other hand, if we had a nonzero \lastskip, - % this make-up glue would be preceded by a non-discardable item - % (the whatsit from the \write), so we must insert a \nobreak. - \nobreak\vskip\whatsitskip - \fi -\fi} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% @printindex causes a particular index (the ??s file) to get printed. -% It does not print any chapter heading (usually an @unnumbered). -% -\parseargdef\printindex{\begingroup - \dobreak \chapheadingskip{10000}% - % - \smallfonts \rm - \tolerance = 9500 - \plainfrenchspacing - \everypar = {}% don't want the \kern\-parindent from indentation suppression. - % - % See if the index file exists and is nonempty. - % Change catcode of @ here so that if the index file contains - % \initial {@} - % as its first line, TeX doesn't complain about mismatched braces - % (because it thinks @} is a control sequence). - \catcode`\@ = 11 - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - \putwordIndexNonexistent - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - \putwordIndexIsEmpty - \else - % Index files are almost Texinfo source, but we use \ as the escape - % character. It would be better to use @, but that's too big a change - % to make right now. - \def\indexbackslash{\backslashcurfont}% - \catcode`\\ = 0 - \escapechar = `\\ - \begindoublecolumns - \input \jobname.#1s - \enddoublecolumns - \fi - \fi - \closein 1 -\endgroup} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -\def\initial#1{{% - % Some minor font changes for the special characters. - \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt - % - % Remove any glue we may have, we'll be inserting our own. - \removelastskip - % - % We like breaks before the index initials, so insert a bonus. - \nobreak - \vskip 0pt plus 3\baselineskip - \penalty 0 - \vskip 0pt plus -3\baselineskip - % - % Typeset the initial. Making this add up to a whole number of - % baselineskips increases the chance of the dots lining up from column - % to column. It still won't often be perfect, because of the stretch - % we need before each entry, but it's better. - % - % No shrink because it confuses \balancecolumns. - \vskip 1.67\baselineskip plus .5\baselineskip - \leftline{\secbf #1}% - % Do our best not to break after the initial. - \nobreak - \vskip .33\baselineskip plus .1\baselineskip -}} - -% \entry typesets a paragraph consisting of the text (#1), dot leaders, and -% then page number (#2) flushed to the right margin. It is used for index -% and table of contents entries. The paragraph is indented by \leftskip. -% -% A straightforward implementation would start like this: -% \def\entry#1#2{... -% But this freezes the catcodes in the argument, and can cause problems to -% @code, which sets - active. This problem was fixed by a kludge--- -% ``-'' was active throughout whole index, but this isn't really right. -% The right solution is to prevent \entry from swallowing the whole text. -% --kasal, 21nov03 -\def\entry{% - \begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent = 2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % A bit of stretch before each entry for the benefit of balancing - % columns. - \vskip 0pt plus1pt - % - % When reading the text of entry, convert explicit line breaks - % from @* into spaces. The user might give these in long section - % titles, for instance. - \def\*{\unskip\space\ignorespaces}% - \def\entrybreak{\hfil\break}% - % - % Swallow the left brace of the text (first parameter): - \afterassignment\doentry - \let\temp = -} -\def\entrybreak{\unskip\space\ignorespaces}% -\def\doentry{% - \bgroup % Instead of the swallowed brace. - \noindent - \aftergroup\finishentry - % And now comes the text of the entry. -} -\def\finishentry#1{% - % #1 is the page number. - % - % The following is kludged to not output a line of dots in the index if - % there are no page numbers. The next person who breaks this will be - % cursed by a Unix daemon. - \setbox\boxA = \hbox{#1}% - \ifdim\wd\boxA = 0pt - \ % - \else - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ifpdf - \pdfgettoks#1.% - \ \the\toksA - \else - \ #1% - \fi - \fi - \par - \endgroup -} - -% Like plain.tex's \dotfill, except uses up at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm -\def\secondary#1#2{{% - \parfillskip=0in - \parskip=0in - \hangindent=1in - \hangafter=1 - \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill - \ifpdf - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \else - #2 - \fi - \par -}} - -% Define two-column mode, which we use to typeset indexes. -% Adapted from the TeXbook, page 416, which is to say, -% the manmac.tex format used to print the TeXbook itself. -\catcode`\@=11 - -\newbox\partialpage -\newdimen\doublecolumnhsize - -\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns - % Grab any single-column material above us. - \output = {% - % - % Here is a possibility not foreseen in manmac: if we accumulate a - % whole lot of material, we might end up calling this \output - % routine twice in a row (see the doublecol-lose test, which is - % essentially a couple of indexes with @setchapternewpage off). In - % that case we just ship out what is in \partialpage with the normal - % output routine. Generally, \partialpage will be empty when this - % runs and this will be a no-op. See the indexspread.tex test case. - \ifvoid\partialpage \else - \onepageout{\pagecontents\partialpage}% - \fi - % - \global\setbox\partialpage = \vbox{% - % Unvbox the main output page. - \unvbox\PAGE - \kern-\topskip \kern\baselineskip - }% - }% - \eject % run that output routine to set \partialpage - % - % Use the double-column output routine for subsequent pages. - \output = {\doublecolumnout}% - % - % Change the page size parameters. We could do this once outside this - % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 - % format, but then we repeat the same computation. Repeating a couple - % of assignments once per index is clearly meaningless for the - % execution time, so we may as well do it in one place. - % - % First we halve the line length, less a little for the gutter between - % the columns. We compute the gutter based on the line length, so it - % changes automatically with the paper format. The magic constant - % below is chosen so that the gutter has the same value (well, +-<1pt) - % as it did when we hard-coded it. - % - % We put the result in a separate register, \doublecolumhsize, so we - % can restore it in \pagesofar, after \hsize itself has (potentially) - % been clobbered. - % - \doublecolumnhsize = \hsize - \advance\doublecolumnhsize by -.04154\hsize - \divide\doublecolumnhsize by 2 - \hsize = \doublecolumnhsize - % - % Double the \vsize as well. (We don't need a separate register here, - % since nobody clobbers \vsize.) - \vsize = 2\vsize -} - -% The double-column output routine for all double-column pages except -% the last. -% -\def\doublecolumnout{% - \splittopskip=\topskip \splitmaxdepth=\maxdepth - % Get the available space for the double columns -- the normal - % (undoubled) page height minus any material left over from the - % previous page. - \dimen@ = \vsize - \divide\dimen@ by 2 - \advance\dimen@ by -\ht\partialpage - % - % box0 will be the left-hand column, box2 the right. - \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ - \onepageout\pagesofar - \unvbox255 - \penalty\outputpenalty -} -% -% Re-output the contents of the output page -- any previous material, -% followed by the two boxes we just split, in box0 and box2. -\def\pagesofar{% - \unvbox\partialpage - % - \hsize = \doublecolumnhsize - \wd0=\hsize \wd2=\hsize - \hbox to\pagewidth{\box0\hfil\box2}% -} -% -% All done with double columns. -\def\enddoublecolumns{% - % The following penalty ensures that the page builder is exercised - % _before_ we change the output routine. This is necessary in the - % following situation: - % - % The last section of the index consists only of a single entry. - % Before this section, \pagetotal is less than \pagegoal, so no - % break occurs before the last section starts. However, the last - % section, consisting of \initial and the single \entry, does not - % fit on the page and has to be broken off. Without the following - % penalty the page builder will not be exercised until \eject - % below, and by that time we'll already have changed the output - % routine to the \balancecolumns version, so the next-to-last - % double-column page will be processed with \balancecolumns, which - % is wrong: The two columns will go to the main vertical list, with - % the broken-off section in the recent contributions. As soon as - % the output routine finishes, TeX starts reconsidering the page - % break. The two columns and the broken-off section both fit on the - % page, because the two columns now take up only half of the page - % goal. When TeX sees \eject from below which follows the final - % section, it invokes the new output routine that we've set after - % \balancecolumns below; \onepageout will try to fit the two columns - % and the final section into the vbox of \pageheight (see - % \pagebody), causing an overfull box. - % - % Note that glue won't work here, because glue does not exercise the - % page builder, unlike penalties (see The TeXbook, pp. 280-281). - \penalty0 - % - \output = {% - % Split the last of the double-column material. Leave it on the - % current page, no automatic page break. - \balancecolumns - % - % If we end up splitting too much material for the current page, - % though, there will be another page break right after this \output - % invocation ends. Having called \balancecolumns once, we do not - % want to call it again. Therefore, reset \output to its normal - % definition right away. (We hope \balancecolumns will never be - % called on to balance too much material, but if it is, this makes - % the output somewhat more palatable.) - \global\output = {\onepageout{\pagecontents\PAGE}}% - }% - \eject - \endgroup % started in \begindoublecolumns - % - % \pagegoal was set to the doubled \vsize above, since we restarted - % the current page. We're now back to normal single-column - % typesetting, so reset \pagegoal to the normal \vsize (after the - % \endgroup where \vsize got restored). - \pagegoal = \vsize -} -% -% Called at the end of the double column material. -\def\balancecolumns{% - \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. - \dimen@ = \ht0 - \advance\dimen@ by \topskip - \advance\dimen@ by-\baselineskip - \divide\dimen@ by 2 % target to split to - %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% - \splittopskip = \topskip - % Loop until we get a decent breakpoint. - {% - \vbadness = 10000 - \loop - \global\setbox3 = \copy0 - \global\setbox1 = \vsplit3 to \dimen@ - \ifdim\ht3>\dimen@ - \global\advance\dimen@ by 1pt - \repeat - }% - %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% - \setbox0=\vbox to\dimen@{\unvbox1}% - \setbox2=\vbox to\dimen@{\unvbox3}% - % - \pagesofar -} -\catcode`\@ = \other - - -\message{sectioning,} -% Chapters, sections, etc. - -% Let's start with @part. -\outer\parseargdef\part{\partzzz{#1}} -\def\partzzz#1{% - \chapoddpage - \null - \vskip.3\vsize % move it down on the page a bit - \begingroup - \noindent \titlefonts\rmisbold #1\par % the text - \let\lastnode=\empty % no node to associate with - \writetocentry{part}{#1}{}% but put it in the toc - \headingsoff % no headline or footline on the part page - \chapoddpage - \endgroup -} - -% \unnumberedno is an oxymoron. But we count the unnumbered -% sections so that we can refer to them unambiguously in the pdf -% outlines by their "section number". We avoid collisions with chapter -% numbers by starting them at 10000. (If a document ever has 10000 -% chapters, we're in trouble anyway, I'm sure.) -\newcount\unnumberedno \unnumberedno = 10000 -\newcount\chapno -\newcount\secno \secno=0 -\newcount\subsecno \subsecno=0 -\newcount\subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -\newcount\appendixno \appendixno = `\@ -% -% \def\appendixletter{\char\the\appendixno} -% We do the following ugly conditional instead of the above simple -% construct for the sake of pdftex, which needs the actual -% letter in the expansion, not just typeset. -% -\def\appendixletter{% - \ifnum\appendixno=`A A% - \else\ifnum\appendixno=`B B% - \else\ifnum\appendixno=`C C% - \else\ifnum\appendixno=`D D% - \else\ifnum\appendixno=`E E% - \else\ifnum\appendixno=`F F% - \else\ifnum\appendixno=`G G% - \else\ifnum\appendixno=`H H% - \else\ifnum\appendixno=`I I% - \else\ifnum\appendixno=`J J% - \else\ifnum\appendixno=`K K% - \else\ifnum\appendixno=`L L% - \else\ifnum\appendixno=`M M% - \else\ifnum\appendixno=`N N% - \else\ifnum\appendixno=`O O% - \else\ifnum\appendixno=`P P% - \else\ifnum\appendixno=`Q Q% - \else\ifnum\appendixno=`R R% - \else\ifnum\appendixno=`S S% - \else\ifnum\appendixno=`T T% - \else\ifnum\appendixno=`U U% - \else\ifnum\appendixno=`V V% - \else\ifnum\appendixno=`W W% - \else\ifnum\appendixno=`X X% - \else\ifnum\appendixno=`Y Y% - \else\ifnum\appendixno=`Z Z% - % The \the is necessary, despite appearances, because \appendixletter is - % expanded while writing the .toc file. \char\appendixno is not - % expandable, thus it is written literally, thus all appendixes come out - % with the same letter (or @) in the toc without it. - \else\char\the\appendixno - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} - -% Each @chapter defines these (using marks) as the number+name, number -% and name of the chapter. Page headings and footings can use -% these. @section does likewise. -\def\thischapter{} -\def\thischapternum{} -\def\thischaptername{} -\def\thissection{} -\def\thissectionnum{} -\def\thissectionname{} - -\newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count - -% @raisesections: treat @section as chapter, @subsection as section, etc. -\def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name - -% @lowersections: treat @chapter as section, @section as subsection, etc. -\def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name - -% we only have subsub. -\chardef\maxseclevel = 3 -% -% A numbered section within an unnumbered changes to unnumbered too. -% To achieve this, remember the "biggest" unnum. sec. we are currently in: -\chardef\unnlevel = \maxseclevel -% -% Trace whether the current chapter is an appendix or not: -% \chapheadtype is "N" or "A", unnumbered chapters are ignored. -\def\chapheadtype{N} - -% Choose a heading macro -% #1 is heading type -% #2 is heading level -% #3 is text for heading -\def\genhead#1#2#3{% - % Compute the abs. sec. level: - \absseclevel=#2 - \advance\absseclevel by \secbase - % Make sure \absseclevel doesn't fall outside the range: - \ifnum \absseclevel < 0 - \absseclevel = 0 - \else - \ifnum \absseclevel > 3 - \absseclevel = 3 - \fi - \fi - % The heading type: - \def\headtype{#1}% - \if \headtype U% - \ifnum \absseclevel < \unnlevel - \chardef\unnlevel = \absseclevel - \fi - \else - % Check for appendix sections: - \ifnum \absseclevel = 0 - \edef\chapheadtype{\headtype}% - \else - \if \headtype A\if \chapheadtype N% - \errmessage{@appendix... within a non-appendix chapter}% - \fi\fi - \fi - % Check for numbered within unnumbered: - \ifnum \absseclevel > \unnlevel - \def\headtype{U}% - \else - \chardef\unnlevel = 3 - \fi - \fi - % Now print the heading: - \if \headtype U% - \ifcase\absseclevel - \unnumberedzzz{#3}% - \or \unnumberedseczzz{#3}% - \or \unnumberedsubseczzz{#3}% - \or \unnumberedsubsubseczzz{#3}% - \fi - \else - \if \headtype A% - \ifcase\absseclevel - \appendixzzz{#3}% - \or \appendixsectionzzz{#3}% - \or \appendixsubseczzz{#3}% - \or \appendixsubsubseczzz{#3}% - \fi - \else - \ifcase\absseclevel - \chapterzzz{#3}% - \or \seczzz{#3}% - \or \numberedsubseczzz{#3}% - \or \numberedsubsubseczzz{#3}% - \fi - \fi - \fi - \suppressfirstparagraphindent -} - -% an interface: -\def\numhead{\genhead N} -\def\apphead{\genhead A} -\def\unnmhead{\genhead U} - -% @chapter, @appendix, @unnumbered. Increment top-level counter, reset -% all lower-level sectioning counters to zero. -% -% Also set \chaplevelprefix, which we prepend to @float sequence numbers -% (e.g., figures), q.v. By default (before any chapter), that is empty. -\let\chaplevelprefix = \empty -% -\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz#1{% - % section resetting is \global in case the chapter is in a group, such - % as an @include file. - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\chapno by 1 - % - % Used for \float. - \gdef\chaplevelprefix{\the\chapno.}% - \resetallfloatnos - % - % \putwordChapter can contain complex things in translations. - \toks0=\expandafter{\putwordChapter}% - \message{\the\toks0 \space \the\chapno}% - % - % Write the actual heading. - \chapmacro{#1}{Ynumbered}{\the\chapno}% - % - % So @section and the like are numbered underneath this chapter. - \global\let\section = \numberedsec - \global\let\subsection = \numberedsubsec - \global\let\subsubsection = \numberedsubsubsec -} - -\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz -% -\def\appendixzzz#1{% - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\appendixno by 1 - \gdef\chaplevelprefix{\appendixletter.}% - \resetallfloatnos - % - % \putwordAppendix can contain complex things in translations. - \toks0=\expandafter{\putwordAppendix}% - \message{\the\toks0 \space \appendixletter}% - % - \chapmacro{#1}{Yappendix}{\appendixletter}% - % - \global\let\section = \appendixsec - \global\let\subsection = \appendixsubsec - \global\let\subsubsection = \appendixsubsubsec -} - -% normally unnmhead0 calls unnumberedzzz: -\outer\parseargdef\unnumbered{\unnmhead0{#1}} -\def\unnumberedzzz#1{% - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\unnumberedno by 1 - % - % Since an unnumbered has no number, no prefix for figures. - \global\let\chaplevelprefix = \empty - \resetallfloatnos - % - % This used to be simply \message{#1}, but TeX fully expands the - % argument to \message. Therefore, if #1 contained @-commands, TeX - % expanded them. For example, in `@unnumbered The @cite{Book}', TeX - % expanded @cite (which turns out to cause errors because \cite is meant - % to be executed, not expanded). - % - % Anyway, we don't want the fully-expanded definition of @cite to appear - % as a result of the \message, we just want `@cite' itself. We use - % \the to achieve this: TeX expands \the only once, - % simply yielding the contents of . (We also do this for - % the toc entries.) - \toks0 = {#1}% - \message{(\the\toks0)}% - % - \chapmacro{#1}{Ynothing}{\the\unnumberedno}% - % - \global\let\section = \unnumberedsec - \global\let\subsection = \unnumberedsubsec - \global\let\subsubsection = \unnumberedsubsubsec -} - -% @centerchap is like @unnumbered, but the heading is centered. -\outer\parseargdef\centerchap{% - % Well, we could do the following in a group, but that would break - % an assumption that \chapmacro is called at the outermost level. - % Thus we are safer this way: --kasal, 24feb04 - \let\centerparametersmaybe = \centerparameters - \unnmhead0{#1}% - \let\centerparametersmaybe = \relax -} - -% @top is like @unnumbered. -\let\top\unnumbered - -% Sections. -% -\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz -\def\seczzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% -} - -% normally calls appendixsectionzzz: -\outer\parseargdef\appendixsection{\apphead1{#1}} -\def\appendixsectionzzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% -} -\let\appendixsec\appendixsection - -% normally calls unnumberedseczzz: -\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} -\def\unnumberedseczzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% -} - -% Subsections. -% -% normally calls numberedsubseczzz: -\outer\parseargdef\numberedsubsec{\numhead2{#1}} -\def\numberedsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% -} - -% normally calls appendixsubseczzz: -\outer\parseargdef\appendixsubsec{\apphead2{#1}} -\def\appendixsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Yappendix}% - {\appendixletter.\the\secno.\the\subsecno}% -} - -% normally calls unnumberedsubseczzz: -\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} -\def\unnumberedsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Ynothing}% - {\the\unnumberedno.\the\secno.\the\subsecno}% -} - -% Subsubsections. -% -% normally numberedsubsubseczzz: -\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} -\def\numberedsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Ynumbered}% - {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% -} - -% normally appendixsubsubseczzz: -\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} -\def\appendixsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Yappendix}% - {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% -} - -% normally unnumberedsubsubseczzz: -\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} -\def\unnumberedsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Ynothing}% - {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% -} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\let\section = \numberedsec -\let\subsection = \numberedsubsec -\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -\def\majorheading{% - {\advance\chapheadingskip by 10pt \chapbreak }% - \parsearg\chapheadingzzz -} - -\def\chapheading{\chapbreak \parsearg\chapheadingzzz} -\def\chapheadingzzz#1{% - \vbox{\chapfonts \raggedtitlesettings #1\par}% - \nobreak\bigskip \nobreak - \suppressfirstparagraphindent -} - -% @heading, @subheading, @subsubheading. -\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} - \suppressfirstparagraphindent} -\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} - \suppressfirstparagraphindent} -\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} - \suppressfirstparagraphindent} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -% Parameter controlling skip before chapter headings (if needed) -\newskip\chapheadingskip - -% Define plain chapter starts, and page on/off switching for it. -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -% Because \domark is called before \chapoddpage, the filler page will -% get the headings for the next chapter, which is wrong. But we don't -% care -- we just disable all headings on the filler page. -\def\chapoddpage{% - \chappager - \ifodd\pageno \else - \begingroup - \headingsoff - \null - \chappager - \endgroup - \fi -} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{% -\global\let\contentsalignmacro = \chappager -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{% -\global\let\contentsalignmacro = \chappager -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{% -\global\let\contentsalignmacro = \chapoddpage -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -% Chapter opening. -% -% #1 is the text, #2 is the section type (Ynumbered, Ynothing, -% Yappendix, Yomitfromtoc), #3 the chapter number. -% -% To test against our argument. -\def\Ynothingkeyword{Ynothing} -\def\Yomitfromtockeyword{Yomitfromtoc} -\def\Yappendixkeyword{Yappendix} -% -\def\chapmacro#1#2#3{% - % Insert the first mark before the heading break (see notes for \domark). - \let\prevchapterdefs=\lastchapterdefs - \let\prevsectiondefs=\lastsectiondefs - \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% - \gdef\thissection{}}% - % - \def\temptype{#2}% - \ifx\temptype\Ynothingkeyword - \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% - \gdef\thischapter{\thischaptername}}% - \else\ifx\temptype\Yomitfromtockeyword - \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% - \gdef\thischapter{}}% - \else\ifx\temptype\Yappendixkeyword - \toks0={#1}% - \xdef\lastchapterdefs{% - \gdef\noexpand\thischaptername{\the\toks0}% - \gdef\noexpand\thischapternum{\appendixletter}% - % \noexpand\putwordAppendix avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} - \noexpand\thischapternum: - \noexpand\thischaptername}% - }% - \else - \toks0={#1}% - \xdef\lastchapterdefs{% - \gdef\noexpand\thischaptername{\the\toks0}% - \gdef\noexpand\thischapternum{\the\chapno}% - % \noexpand\putwordChapter avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thischapter{\noexpand\putwordChapter{} - \noexpand\thischapternum: - \noexpand\thischaptername}% - }% - \fi\fi\fi - % - % Output the mark. Pass it through \safewhatsit, to take care of - % the preceding space. - \safewhatsit\domark - % - % Insert the chapter heading break. - \pchapsepmacro - % - % Now the second mark, after the heading break. No break points - % between here and the heading. - \let\prevchapterdefs=\lastchapterdefs - \let\prevsectiondefs=\lastsectiondefs - \domark - % - {% - \chapfonts \rmisbold - % - % Have to define \lastsection before calling \donoderef, because the - % xref code eventually uses it. On the other hand, it has to be called - % after \pchapsepmacro, or the headline will change too soon. - \gdef\lastsection{#1}% - % - % Only insert the separating space if we have a chapter/appendix - % number, and don't print the unnumbered ``number''. - \ifx\temptype\Ynothingkeyword - \setbox0 = \hbox{}% - \def\toctype{unnchap}% - \else\ifx\temptype\Yomitfromtockeyword - \setbox0 = \hbox{}% contents like unnumbered, but no toc entry - \def\toctype{omit}% - \else\ifx\temptype\Yappendixkeyword - \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% - \def\toctype{app}% - \else - \setbox0 = \hbox{#3\enspace}% - \def\toctype{numchap}% - \fi\fi\fi - % - % Write the toc entry for this chapter. Must come before the - % \donoderef, because we include the current node name in the toc - % entry, and \donoderef resets it to empty. - \writetocentry{\toctype}{#1}{#3}% - % - % For pdftex, we have to write out the node definition (aka, make - % the pdfdest) after any page break, but before the actual text has - % been typeset. If the destination for the pdf outline is after the - % text, then jumping from the outline may wind up with the text not - % being visible, for instance under high magnification. - \donoderef{#2}% - % - % Typeset the actual heading. - \nobreak % Avoid page breaks at the interline glue. - \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe - \unhbox0 #1\par}% - }% - \nobreak\bigskip % no page break after a chapter title - \nobreak -} - -% @centerchap -- centered and unnumbered. -\let\centerparametersmaybe = \relax -\def\centerparameters{% - \advance\rightskip by 3\rightskip - \leftskip = \rightskip - \parfillskip = 0pt -} - - -% I don't think this chapter style is supported any more, so I'm not -% updating it with the new noderef stuff. We'll see. --karl, 11aug03. -% -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} -% -\def\unnchfopen #1{% - \chapoddpage - \vbox{\chapfonts \raggedtitlesettings #1\par}% - \nobreak\bigskip\nobreak -} -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} -\def\centerchfopen #1{% - \chapoddpage - \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}% - \nobreak\bigskip \nobreak -} -\def\CHAPFopen{% - \global\let\chapmacro=\chfopen - \global\let\centerchapmacro=\centerchfopen} - - -% Section titles. These macros combine the section number parts and -% call the generic \sectionheading to do the printing. -% -\newskip\secheadingskip -\def\secheadingbreak{\dobreak \secheadingskip{-1000}} - -% Subsection titles. -\newskip\subsecheadingskip -\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} - -% Subsubsection titles. -\def\subsubsecheadingskip{\subsecheadingskip} -\def\subsubsecheadingbreak{\subsecheadingbreak} - - -% Print any size, any type, section title. -% -% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is -% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the -% section number. -% -\def\seckeyword{sec} -% -\def\sectionheading#1#2#3#4{% - {% - \checkenv{}% should not be in an environment. - % - % Switch to the right set of fonts. - \csname #2fonts\endcsname \rmisbold - % - \def\sectionlevel{#2}% - \def\temptype{#3}% - % - % Insert first mark before the heading break (see notes for \domark). - \let\prevsectiondefs=\lastsectiondefs - \ifx\temptype\Ynothingkeyword - \ifx\sectionlevel\seckeyword - \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% - \gdef\thissection{\thissectionname}}% - \fi - \else\ifx\temptype\Yomitfromtockeyword - % Don't redefine \thissection. - \else\ifx\temptype\Yappendixkeyword - \ifx\sectionlevel\seckeyword - \toks0={#1}% - \xdef\lastsectiondefs{% - \gdef\noexpand\thissectionname{\the\toks0}% - \gdef\noexpand\thissectionnum{#4}% - % \noexpand\putwordSection avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thissection{\noexpand\putwordSection{} - \noexpand\thissectionnum: - \noexpand\thissectionname}% - }% - \fi - \else - \ifx\sectionlevel\seckeyword - \toks0={#1}% - \xdef\lastsectiondefs{% - \gdef\noexpand\thissectionname{\the\toks0}% - \gdef\noexpand\thissectionnum{#4}% - % \noexpand\putwordSection avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thissection{\noexpand\putwordSection{} - \noexpand\thissectionnum: - \noexpand\thissectionname}% - }% - \fi - \fi\fi\fi - % - % Go into vertical mode. Usually we'll already be there, but we - % don't want the following whatsit to end up in a preceding paragraph - % if the document didn't happen to have a blank line. - \par - % - % Output the mark. Pass it through \safewhatsit, to take care of - % the preceding space. - \safewhatsit\domark - % - % Insert space above the heading. - \csname #2headingbreak\endcsname - % - % Now the second mark, after the heading break. No break points - % between here and the heading. - \let\prevsectiondefs=\lastsectiondefs - \domark - % - % Only insert the space after the number if we have a section number. - \ifx\temptype\Ynothingkeyword - \setbox0 = \hbox{}% - \def\toctype{unn}% - \gdef\lastsection{#1}% - \else\ifx\temptype\Yomitfromtockeyword - % for @headings -- no section number, don't include in toc, - % and don't redefine \lastsection. - \setbox0 = \hbox{}% - \def\toctype{omit}% - \let\sectionlevel=\empty - \else\ifx\temptype\Yappendixkeyword - \setbox0 = \hbox{#4\enspace}% - \def\toctype{app}% - \gdef\lastsection{#1}% - \else - \setbox0 = \hbox{#4\enspace}% - \def\toctype{num}% - \gdef\lastsection{#1}% - \fi\fi\fi - % - % Write the toc entry (before \donoderef). See comments in \chapmacro. - \writetocentry{\toctype\sectionlevel}{#1}{#4}% - % - % Write the node reference (= pdf destination for pdftex). - % Again, see comments in \chapmacro. - \donoderef{#3}% - % - % Interline glue will be inserted when the vbox is completed. - % That glue will be a valid breakpoint for the page, since it'll be - % preceded by a whatsit (usually from the \donoderef, or from the - % \writetocentry if there was no node). We don't want to allow that - % break, since then the whatsits could end up on page n while the - % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. - \nobreak - % - % Output the actual section heading. - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright - \hangindent=\wd0 % zero if no section number - \unhbox0 #1}% - }% - % Add extra space after the heading -- half of whatever came above it. - % Don't allow stretch, though. - \kern .5 \csname #2headingskip\endcsname - % - % Do not let the kern be a potential breakpoint, as it would be if it - % was followed by glue. - \nobreak - % - % We'll almost certainly start a paragraph next, so don't let that - % glue accumulate. (Not a breakpoint because it's preceded by a - % discardable item.) However, when a paragraph is not started next - % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out - % or the negative glue will cause weirdly wrong output, typically - % obscuring the section heading with something else. - \vskip-\parskip - % - % This is so the last item on the main vertical list is a known - % \penalty > 10000, so \startdefun, etc., can recognize the situation - % and do the needful. - \penalty 10001 -} - - -\message{toc,} -% Table of contents. -\newwrite\tocfile - -% Write an entry to the toc file, opening it if necessary. -% Called from @chapter, etc. -% -% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} -% We append the current node name (if any) and page number as additional -% arguments for the \{chap,sec,...}entry macros which will eventually -% read this. The node name is used in the pdf outlines as the -% destination to jump to. -% -% We open the .toc file for writing here instead of at @setfilename (or -% any other fixed time) so that @contents can be anywhere in the document. -% But if #1 is `omit', then we don't do anything. This is used for the -% table of contents chapter openings themselves. -% -\newif\iftocfileopened -\def\omitkeyword{omit}% -% -\def\writetocentry#1#2#3{% - \edef\writetoctype{#1}% - \ifx\writetoctype\omitkeyword \else - \iftocfileopened\else - \immediate\openout\tocfile = \jobname.toc - \global\tocfileopenedtrue - \fi - % - \iflinks - {\atdummies - \edef\temp{% - \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% - \temp - }% - \fi - \fi - % - % Tell \shipout to create a pdf destination on each page, if we're - % writing pdf. These are used in the table of contents. We can't - % just write one on every page because the title pages are numbered - % 1 and 2 (the page numbers aren't printed), and so are the first - % two pages of the document. Thus, we'd have two destinations named - % `1', and two named `2'. - \ifpdf \global\pdfmakepagedesttrue \fi -} - - -% These characters do not print properly in the Computer Modern roman -% fonts, so we must take special care. This is more or less redundant -% with the Texinfo input format setup at the end of this file. -% -\def\activecatcodes{% - \catcode`\"=\active - \catcode`\$=\active - \catcode`\<=\active - \catcode`\>=\active - \catcode`\\=\active - \catcode`\^=\active - \catcode`\_=\active - \catcode`\|=\active - \catcode`\~=\active -} - - -% Read the toc file, which is essentially Texinfo input. -\def\readtocfile{% - \setupdatafile - \activecatcodes - \input \tocreadfilename -} - -\newskip\contentsrightmargin \contentsrightmargin=1in -\newcount\savepageno -\newcount\lastnegativepageno \lastnegativepageno = -1 - -% Prepare to read what we've written to \tocfile. -% -\def\startcontents#1{% - % If @setchapternewpage on, and @headings double, the contents should - % start on an odd page, unlike chapters. Thus, we maintain - % \contentsalignmacro in parallel with \pagealignmacro. - % From: Torbjorn Granlund - \contentsalignmacro - \immediate\closeout\tocfile - % - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \chapmacro{#1}{Yomitfromtoc}{}% - % - \savepageno = \pageno - \begingroup % Set up to handle contents files properly. - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. - % - % Roman numerals for page numbers. - \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi -} - -% redefined for the two-volume lispref. We always output on -% \jobname.toc even if this is redefined. -% -\def\tocreadfilename{\jobname.toc} - -% Normal (long) toc. -% -\def\contents{% - \startcontents{\putwordTOC}% - \openin 1 \tocreadfilename\space - \ifeof 1 \else - \readtocfile - \fi - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \ifeof 1 \else - \pdfmakeoutlines - \fi - \closein 1 - \endgroup - \lastnegativepageno = \pageno - \global\pageno = \savepageno -} - -% And just the chapters. -\def\summarycontents{% - \startcontents{\putwordShortTOC}% - % - \let\partentry = \shortpartentry - \let\numchapentry = \shortchapentry - \let\appentry = \shortchapentry - \let\unnchapentry = \shortunnchapentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf - \let\sl=\shortcontsl \let\tt=\shortconttt - \rm - \hyphenpenalty = 10000 - \advance\baselineskip by 1pt % Open it up a little. - \def\numsecentry##1##2##3##4{} - \let\appsecentry = \numsecentry - \let\unnsecentry = \numsecentry - \let\numsubsecentry = \numsecentry - \let\appsubsecentry = \numsecentry - \let\unnsubsecentry = \numsecentry - \let\numsubsubsecentry = \numsecentry - \let\appsubsubsecentry = \numsecentry - \let\unnsubsubsecentry = \numsecentry - \openin 1 \tocreadfilename\space - \ifeof 1 \else - \readtocfile - \fi - \closein 1 - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \endgroup - \lastnegativepageno = \pageno - \global\pageno = \savepageno -} -\let\shortcontents = \summarycontents - -% Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g., `A' for an appendix, or `3' for a chapter. -% -\def\shortchaplabel#1{% - % This space should be enough, since a single number is .5em, and the - % widest letter (M) is 1em, at least in the Computer Modern fonts. - % But use \hss just in case. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in by \shortchapentry above.) - % - % We'd like to right-justify chapter numbers, but that looks strange - % with appendix letters. And right-justifying numbers and - % left-justifying letters looks strange when there is less than 10 - % chapters. Have to read the whole toc once to know how many chapters - % there are before deciding ... - \hbox to 1em{#1\hss}% -} - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Parts, in the main contents. Replace the part number, which doesn't -% exist, with an empty box. Let's hope all the numbers have the same width. -% Also ignore the page number, which is conventionally not printed. -\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} -\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} -% -% Parts, in the short toc. -\def\shortpartentry#1#2#3#4{% - \penalty-300 - \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip - \shortchapentry{{\bf #1}}{\numeralbox}{}{}% -} - -% Chapters, in the main contents. -\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} -% -% Chapters, in the short toc. -% See comments in \dochapentry re vbox and related settings. -\def\shortchapentry#1#2#3#4{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% -} - -% Appendices, in the main contents. -% Need the word Appendix, and a fixed-size box. -% -\def\appendixbox#1{% - % We use M since it's probably the widest letter. - \setbox0 = \hbox{\putwordAppendix{} M}% - \hbox to \wd0{\putwordAppendix{} #1\hss}} -% -\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} - -% Unnumbered chapters. -\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} -\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} - -% Sections. -\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} -\let\appsecentry=\numsecentry -\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} - -% Subsections. -\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} -\let\appsubsecentry=\numsubsecentry -\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} - -% And subsubsections. -\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} -\let\appsubsubsecentry=\numsubsubsecentry -\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} - -% This parameter controls the indentation of the various levels. -% Same as \defaultparindent. -\newdimen\tocindent \tocindent = 15pt - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we want it to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip - \begingroup - \chapentryfonts - \tocentry{#1}{\dopageno\bgroup#2\egroup}% - \endgroup - \nobreak\vskip .25\baselineskip plus.1\baselineskip -} - -\def\dosecentry#1#2{\begingroup - \secentryfonts \leftskip=\tocindent - \tocentry{#1}{\dopageno\bgroup#2\egroup}% -\endgroup} - -\def\dosubsecentry#1#2{\begingroup - \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{\dopageno\bgroup#2\egroup}% -\endgroup} - -\def\dosubsubsecentry#1#2{\begingroup - \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{\dopageno\bgroup#2\egroup}% -\endgroup} - -% We use the same \entry macro as for the index entries. -\let\tocentry = \entry - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\def\subsecentryfonts{\textfonts} -\def\subsubsecentryfonts{\textfonts} - - -\message{environments,} -% @foo ... @end foo. - -% @tex ... @end tex escapes into raw TeX temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain @ character. - -\envdef\tex{% - \setupmarkupstyle{tex}% - \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 - \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 - \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie - \catcode `\%=14 - \catcode `\+=\other - \catcode `\"=\other - \catcode `\|=\other - \catcode `\<=\other - \catcode `\>=\other - \catcode`\`=\other - \catcode`\'=\other - \escapechar=`\\ - % - % ' is active in math mode (mathcode"8000). So reset it, and all our - % other math active characters (just in case), to plain's definitions. - \mathactive - % - \let\b=\ptexb - \let\bullet=\ptexbullet - \let\c=\ptexc - \let\,=\ptexcomma - \let\.=\ptexdot - \let\dots=\ptexdots - \let\equiv=\ptexequiv - \let\!=\ptexexclam - \let\i=\ptexi - \let\indent=\ptexindent - \let\noindent=\ptexnoindent - \let\{=\ptexlbrace - \let\+=\tabalign - \let\}=\ptexrbrace - \let\/=\ptexslash - \let\*=\ptexstar - \let\t=\ptext - \expandafter \let\csname top\endcsname=\ptextop % outer - \let\frenchspacing=\plainfrenchspacing - % - \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% - \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% - \def\@{@}% -} -% There is no need to define \Etex. - -% Define @lisp ... @end lisp. -% @lisp environment forms a group so it can rebind things, -% including the definition of @end lisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^^M gets inside @lisp, @example, and other -% such environments. \null is better than a space, since it doesn't -% have any width. -\def\lisppar{\null\endgraf} - -% This space is always present above and below environments. -\newskip\envskipamount \envskipamount = 0pt - -% Make spacing and below environment symmetrical. We use \parskip here -% to help in doing that, since in @example-like environments \parskip -% is reset to zero; thus the \afterenvbreak inserts no space -- but the -% start of the next paragraph will insert \parskip. -% -\def\aboveenvbreak{{% - % =10000 instead of <10000 because of a special case in \itemzzz and - % \sectionheading, q.v. - \ifnum \lastpenalty=10000 \else - \advance\envskipamount by \parskip - \endgraf - \ifdim\lastskip<\envskipamount - \removelastskip - % it's not a good place to break if the last penalty was \nobreak - % or better ... - \ifnum\lastpenalty<10000 \penalty-50 \fi - \vskip\envskipamount - \fi - \fi -}} - -\let\afterenvbreak = \aboveenvbreak - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will -% also clear it, so that its embedded environments do the narrowing again. -\let\nonarrowing=\relax - -% @cartouche ... @end cartouche: draw rectangle w/rounded corners around -% environment contents. -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\envdef\cartouche{% - \ifhmode\par\fi % can't be in the midst of a paragraph. - \startsavinginserts - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt % we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18.4pt % allow for 3pt kerns on either - % side, and for 6pt waste from - % each corner char, and rule thickness - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing = t% - % - % If this cartouche directly follows a sectioning command, we need the - % \parskip glue (backspaced over by default) or the cartouche can - % collide with the section heading. - \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi - % - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \kern3pt - \hsize=\cartinner - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip - \comment % For explanation, see the end of def\group. -} -\def\Ecartouche{% - \ifhmode\par\fi - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup - \checkinserts -} - - -% This macro is called at the beginning of all the @example variants, -% inside a group. -\newdimen\nonfillparindent -\def\nonfillstart{% - \aboveenvbreak - \hfuzz = 12pt % Don't be fussy - \sepspaces % Make spaces be word-separators rather than space tokens. - \let\par = \lisppar % don't ignore blank lines - \obeylines % each line of input is a line of output - \parskip = 0pt - % Turn off paragraph indentation but redefine \indent to emulate - % the normal \indent. - \nonfillparindent=\parindent - \parindent = 0pt - \let\indent\nonfillindent - % - \emergencystretch = 0pt % don't try to avoid overfull boxes - \ifx\nonarrowing\relax - \advance \leftskip by \lispnarrowing - \exdentamount=\lispnarrowing - \else - \let\nonarrowing = \relax - \fi - \let\exdent=\nofillexdent -} - -\begingroup -\obeyspaces -% We want to swallow spaces (but not other tokens) after the fake -% @indent in our nonfill-environments, where spaces are normally -% active and set to @tie, resulting in them not being ignored after -% @indent. -\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% -\gdef\nonfillindentcheck{% -\ifx\temp % -\expandafter\nonfillindentgobble% -\else% -\leavevmode\nonfillindentbox% -\fi% -}% -\endgroup -\def\nonfillindentgobble#1{\nonfillindent} -\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} - -% If you want all examples etc. small: @set dispenvsize small. -% If you want even small examples the full size: @set dispenvsize nosmall. -% This affects the following displayed environments: -% @example, @display, @format, @lisp -% -\def\smallword{small} -\def\nosmallword{nosmall} -\let\SETdispenvsize\relax -\def\setnormaldispenv{% - \ifx\SETdispenvsize\smallword - % end paragraph for sake of leading, in case document has no blank - % line. This is redundant with what happens in \aboveenvbreak, but - % we need to do it before changing the fonts, and it's inconvenient - % to change the fonts afterward. - \ifnum \lastpenalty=10000 \else \endgraf \fi - \smallexamplefonts \rm - \fi -} -\def\setsmalldispenv{% - \ifx\SETdispenvsize\nosmallword - \else - \ifnum \lastpenalty=10000 \else \endgraf \fi - \smallexamplefonts \rm - \fi -} - -% We often define two environments, @foo and @smallfoo. -% Let's do it in one command. #1 is the env name, #2 the definition. -\def\makedispenvdef#1#2{% - \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% - \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% - \expandafter\let\csname E#1\endcsname \afterenvbreak - \expandafter\let\csname Esmall#1\endcsname \afterenvbreak -} - -% Define two environment synonyms (#1 and #2) for an environment. -\def\maketwodispenvdef#1#2#3{% - \makedispenvdef{#1}{#3}% - \makedispenvdef{#2}{#3}% -} -% -% @lisp: indented, narrowed, typewriter font; -% @example: same as @lisp. -% -% @smallexample and @smalllisp: use smaller fonts. -% Originally contributed by Pavel@xerox. -% -\maketwodispenvdef{lisp}{example}{% - \nonfillstart - \tt\setupmarkupstyle{example}% - \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. - \gobble % eat return -} -% @display/@smalldisplay: same as @lisp except keep current font. -% -\makedispenvdef{display}{% - \nonfillstart - \gobble -} - -% @format/@smallformat: same as @display except don't narrow margins. -% -\makedispenvdef{format}{% - \let\nonarrowing = t% - \nonfillstart - \gobble -} - -% @flushleft: same as @format, but doesn't obey \SETdispenvsize. -\envdef\flushleft{% - \let\nonarrowing = t% - \nonfillstart - \gobble -} -\let\Eflushleft = \afterenvbreak - -% @flushright. -% -\envdef\flushright{% - \let\nonarrowing = t% - \nonfillstart - \advance\leftskip by 0pt plus 1fill\relax - \gobble -} -\let\Eflushright = \afterenvbreak - - -% @raggedright does more-or-less normal line breaking but no right -% justification. From plain.tex. -\envdef\raggedright{% - \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax -} -\let\Eraggedright\par - -\envdef\raggedleft{% - \parindent=0pt \leftskip0pt plus2em - \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt - \hbadness=10000 % Last line will usually be underfull, so turn off - % badness reporting. -} -\let\Eraggedleft\par - -\envdef\raggedcenter{% - \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em - \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt - \hbadness=10000 % Last line will usually be underfull, so turn off - % badness reporting. -} -\let\Eraggedcenter\par - - -% @quotation does normal linebreaking (hence we can't use \nonfillstart) -% and narrows the margins. We keep \parskip nonzero in general, since -% we're doing normal filling. So, when using \aboveenvbreak and -% \afterenvbreak, temporarily make \parskip 0. -% -\makedispenvdef{quotation}{\quotationstart} -% -\def\quotationstart{% - \indentedblockstart % same as \indentedblock, but increase right margin too. - \ifx\nonarrowing\relax - \advance\rightskip by \lispnarrowing - \fi - \parsearg\quotationlabel -} - -% We have retained a nonzero parskip for the environment, since we're -% doing normal filling. -% -\def\Equotation{% - \par - \ifx\quotationauthor\thisisundefined\else - % indent a bit. - \leftline{\kern 2\leftskip \sl ---\quotationauthor}% - \fi - {\parskip=0pt \afterenvbreak}% -} -\def\Esmallquotation{\Equotation} - -% If we're given an argument, typeset it in bold with a colon after. -\def\quotationlabel#1{% - \def\temp{#1}% - \ifx\temp\empty \else - {\bf #1: }% - \fi -} - -% @indentedblock is like @quotation, but indents only on the left and -% has no optional argument. -% -\makedispenvdef{indentedblock}{\indentedblockstart} -% -\def\indentedblockstart{% - {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \parindent=0pt - % - % @cartouche defines \nonarrowing to inhibit narrowing at next level down. - \ifx\nonarrowing\relax - \advance\leftskip by \lispnarrowing - \exdentamount = \lispnarrowing - \else - \let\nonarrowing = \relax - \fi -} - -% Keep a nonzero parskip for the environment, since we're doing normal filling. -% -\def\Eindentedblock{% - \par - {\parskip=0pt \afterenvbreak}% -} -\def\Esmallindentedblock{\Eindentedblock} - - -% LaTeX-like @verbatim...@end verbatim and @verb{...} -% If we want to allow any as delimiter, -% we need the curly braces so that makeinfo sees the @verb command, eg: -% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org -% -% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. -% -% [Knuth] p.344; only we need to do the other characters Texinfo sets -% active too. Otherwise, they get lost as the first character on a -% verbatim line. -\def\dospecials{% - \do\ \do\\\do\{\do\}\do\$\do\&% - \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% - \do\<\do\>\do\|\do\@\do+\do\"% - % Don't do the quotes -- if we do, @set txicodequoteundirected and - % @set txicodequotebacktick will not have effect on @verb and - % @verbatim, and ?` and !` ligatures won't get disabled. - %\do\`\do\'% -} -% -% [Knuth] p. 380 -\def\uncatcodespecials{% - \def\do##1{\catcode`##1=\other}\dospecials} -% -% Setup for the @verb command. -% -% Eight spaces for a tab -\begingroup - \catcode`\^^I=\active - \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} -\endgroup -% -\def\setupverb{% - \tt % easiest (and conventionally used) font for verbatim - \def\par{\leavevmode\endgraf}% - \setupmarkupstyle{verb}% - \tabeightspaces - % Respect line breaks, - % print special symbols as themselves, and - % make each space count - % must do in this order: - \obeylines \uncatcodespecials \sepspaces -} - -% Setup for the @verbatim environment -% -% Real tab expansion. -\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount -% -% We typeset each line of the verbatim in an \hbox, so we can handle -% tabs. The \global is in case the verbatim line starts with an accent, -% or some other command that starts with a begin-group. Otherwise, the -% entire \verbbox would disappear at the corresponding end-group, before -% it is typeset. Meanwhile, we can't have nested verbatim commands -% (can we?), so the \global won't be overwriting itself. -\newbox\verbbox -\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} -% -\begingroup - \catcode`\^^I=\active - \gdef\tabexpand{% - \catcode`\^^I=\active - \def^^I{\leavevmode\egroup - \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab - \divide\dimen\verbbox by\tabw - \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw - \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw - \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox - }% - } -\endgroup - -% start the verbatim environment. -\def\setupverbatim{% - \let\nonarrowing = t% - \nonfillstart - \tt % easiest (and conventionally used) font for verbatim - % The \leavevmode here is for blank lines. Otherwise, we would - % never \starttabox and the \egroup would end verbatim mode. - \def\par{\leavevmode\egroup\box\verbbox\endgraf}% - \tabexpand - \setupmarkupstyle{verbatim}% - % Respect line breaks, - % print special symbols as themselves, and - % make each space count. - % Must do in this order: - \obeylines \uncatcodespecials \sepspaces - \everypar{\starttabbox}% -} - -% Do the @verb magic: verbatim text is quoted by unique -% delimiter characters. Before first delimiter expect a -% right brace, after last delimiter expect closing brace: -% -% \def\doverb'{'#1'}'{#1} -% -% [Knuth] p. 382; only eat outer {} -\begingroup - \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other - \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] -\endgroup -% -\def\verb{\begingroup\setupverb\doverb} -% -% -% Do the @verbatim magic: define the macro \doverbatim so that -% the (first) argument ends when '@end verbatim' is reached, ie: -% -% \def\doverbatim#1@end verbatim{#1} -% -% For Texinfo it's a lot easier than for LaTeX, -% because texinfo's \verbatim doesn't stop at '\end{verbatim}': -% we need not redefine '\', '{' and '}'. -% -% Inspired by LaTeX's verbatim command set [latex.ltx] -% -\begingroup - \catcode`\ =\active - \obeylines % - % ignore everything up to the first ^^M, that's the newline at the end - % of the @verbatim input line itself. Otherwise we get an extra blank - % line in the output. - \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% - % We really want {...\end verbatim} in the body of the macro, but - % without the active space; thus we have to use \xdef and \gobble. -\endgroup -% -\envdef\verbatim{% - \setupverbatim\doverbatim -} -\let\Everbatim = \afterenvbreak - - -% @verbatiminclude FILE - insert text of file in verbatim environment. -% -\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} -% -\def\doverbatiminclude#1{% - {% - \makevalueexpandable - \setupverbatim - \indexnofonts % Allow `@@' and other weird things in file names. - \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% - \input #1 - \afterenvbreak - }% -} - -% @copying ... @end copying. -% Save the text away for @insertcopying later. -% -% We save the uninterpreted tokens, rather than creating a box. -% Saving the text in a box would be much easier, but then all the -% typesetting commands (@smallbook, font changes, etc.) have to be done -% beforehand -- and a) we want @copying to be done first in the source -% file; b) letting users define the frontmatter in as flexible order as -% possible is very desirable. -% -\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} -\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} -% -\def\insertcopying{% - \begingroup - \parindent = 0pt % paragraph indentation looks wrong on title page - \scanexp\copyingtext - \endgroup -} - - -\message{defuns,} -% @defun etc. - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deflastargmargin \deflastargmargin=18pt -\newcount\defunpenalty - -% Start the processing of @deffn: -\def\startdefun{% - \ifnum\lastpenalty<10000 - \medbreak - \defunpenalty=10003 % Will keep this @deffn together with the - % following @def command, see below. - \else - % If there are two @def commands in a row, we'll have a \nobreak, - % which is there to keep the function description together with its - % header. But if there's nothing but headers, we need to allow a - % break somewhere. Check specifically for penalty 10002, inserted - % by \printdefunline, instead of 10000, since the sectioning - % commands also insert a nobreak penalty, and we don't want to allow - % a break between a section heading and a defun. - % - % As a further refinement, we avoid "club" headers by signalling - % with penalty of 10003 after the very first @deffn in the - % sequence (see above), and penalty of 10002 after any following - % @def command. - \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi - % - % Similarly, after a section heading, do not allow a break. - % But do insert the glue. - \medskip % preceded by discardable penalty, so not a breakpoint - \fi - % - \parindent=0in - \advance\leftskip by \defbodyindent - \exdentamount=\defbodyindent -} - -\def\dodefunx#1{% - % First, check whether we are in the right environment: - \checkenv#1% - % - % As above, allow line break if we have multiple x headers in a row. - % It's not a great place, though. - \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi - % - % And now, it's time to reuse the body of the original defun: - \expandafter\gobbledefun#1% -} -\def\gobbledefun#1\startdefun{} - -% \printdefunline \deffnheader{text} -% -\def\printdefunline#1#2{% - \begingroup - % call \deffnheader: - #1#2 \endheader - % common ending: - \interlinepenalty = 10000 - \advance\rightskip by 0pt plus 1fil\relax - \endgraf - \nobreak\vskip -\parskip - \penalty\defunpenalty % signal to \startdefun and \dodefunx - % Some of the @defun-type tags do not enable magic parentheses, - % rendering the following check redundant. But we don't optimize. - \checkparencounts - \endgroup -} - -\def\Edefun{\endgraf\medbreak} - -% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; -% the only thing remaining is to define \deffnheader. -% -\def\makedefun#1{% - \expandafter\let\csname E#1\endcsname = \Edefun - \edef\temp{\noexpand\domakedefun - \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% - \temp -} - -% \domakedefun \deffn \deffnx \deffnheader -% -% Define \deffn and \deffnx, without parameters. -% \deffnheader has to be defined explicitly. -% -\def\domakedefun#1#2#3{% - \envdef#1{% - \startdefun - \doingtypefnfalse % distinguish typed functions from all else - \parseargusing\activeparens{\printdefunline#3}% - }% - \def#2{\dodefunx#1}% - \def#3% -} - -\newif\ifdoingtypefn % doing typed function? -\newif\ifrettypeownline % typeset return type on its own line? - -% @deftypefnnewline on|off says whether the return type of typed functions -% are printed on their own line. This affects @deftypefn, @deftypefun, -% @deftypeop, and @deftypemethod. -% -\parseargdef\deftypefnnewline{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxideftypefnnl\endcsname - = \empty - \else\ifx\temp\offword - \expandafter\let\csname SETtxideftypefnnl\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @txideftypefnnl value `\temp', - must be on|off}% - \fi\fi -} - -% Untyped functions: - -% @deffn category name args -\makedefun{deffn}{\deffngeneral{}} - -% @deffn category class name args -\makedefun{defop}#1 {\defopon{#1\ \putwordon}} - -% \defopon {category on}class name args -\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } - -% \deffngeneral {subind}category name args -% -\def\deffngeneral#1#2 #3 #4\endheader{% - % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. - \dosubind{fn}{\code{#3}}{#1}% - \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% -} - -% Typed functions: - -% @deftypefn category type name args -\makedefun{deftypefn}{\deftypefngeneral{}} - -% @deftypeop category class type name args -\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} - -% \deftypeopon {category on}class type name args -\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } - -% \deftypefngeneral {subind}category type name args -% -\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% - \dosubind{fn}{\code{#4}}{#1}% - \doingtypefntrue - \defname{#2}{#3}{#4}\defunargs{#5\unskip}% -} - -% Typed variables: - -% @deftypevr category type var args -\makedefun{deftypevr}{\deftypecvgeneral{}} - -% @deftypecv category class type var args -\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} - -% \deftypecvof {category of}class type var args -\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } - -% \deftypecvgeneral {subind}category type var args -% -\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% - \dosubind{vr}{\code{#4}}{#1}% - \defname{#2}{#3}{#4}\defunargs{#5\unskip}% -} - -% Untyped variables: - -% @defvr category var args -\makedefun{defvr}#1 {\deftypevrheader{#1} {} } - -% @defcv category class var args -\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} - -% \defcvof {category of}class var args -\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } - -% Types: - -% @deftp category name args -\makedefun{deftp}#1 #2 #3\endheader{% - \doind{tp}{\code{#2}}% - \defname{#1}{}{#2}\defunargs{#3\unskip}% -} - -% Remaining @defun-like shortcuts: -\makedefun{defun}{\deffnheader{\putwordDeffunc} } -\makedefun{defmac}{\deffnheader{\putwordDefmac} } -\makedefun{defspec}{\deffnheader{\putwordDefspec} } -\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } -\makedefun{defvar}{\defvrheader{\putwordDefvar} } -\makedefun{defopt}{\defvrheader{\putwordDefopt} } -\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } -\makedefun{defmethod}{\defopon\putwordMethodon} -\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} -\makedefun{defivar}{\defcvof\putwordInstanceVariableof} -\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} - -% \defname, which formats the name of the @def (not the args). -% #1 is the category, such as "Function". -% #2 is the return type, if any. -% #3 is the function name. -% -% We are followed by (but not passed) the arguments, if any. -% -\def\defname#1#2#3{% - \par - % Get the values of \leftskip and \rightskip as they were outside the @def... - \advance\leftskip by -\defbodyindent - % - % Determine if we are typesetting the return type of a typed function - % on a line by itself. - \rettypeownlinefalse - \ifdoingtypefn % doing a typed function specifically? - % then check user option for putting return type on its own line: - \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else - \rettypeownlinetrue - \fi - \fi - % - % How we'll format the category name. Putting it in brackets helps - % distinguish it from the body text that may end up on the next line - % just below it. - \def\temp{#1}% - \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} - % - % Figure out line sizes for the paragraph shape. We'll always have at - % least two. - \tempnum = 2 - % - % The first line needs space for \box0; but if \rightskip is nonzero, - % we need only space for the part of \box0 which exceeds it: - \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip - % - % If doing a return type on its own line, we'll have another line. - \ifrettypeownline - \advance\tempnum by 1 - \def\maybeshapeline{0in \hsize}% - \else - \def\maybeshapeline{}% - \fi - % - % The continuations: - \dimen2=\hsize \advance\dimen2 by -\defargsindent - % - % The final paragraph shape: - \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 - % - % Put the category name at the right margin. - \noindent - \hbox to 0pt{% - \hfil\box0 \kern-\hsize - % \hsize has to be shortened this way: - \kern\leftskip - % Intentionally do not respect \rightskip, since we need the space. - }% - % - % Allow all lines to be underfull without complaint: - \tolerance=10000 \hbadness=10000 - \exdentamount=\defbodyindent - {% - % defun fonts. We use typewriter by default (used to be bold) because: - % . we're printing identifiers, they should be in tt in principle. - % . in languages with many accents, such as Czech or French, it's - % common to leave accents off identifiers. The result looks ok in - % tt, but exceedingly strange in rm. - % . we don't want -- and --- to be treated as ligatures. - % . this still does not fix the ?` and !` ligatures, but so far no - % one has made identifiers using them :). - \df \tt - \def\temp{#2}% text of the return type - \ifx\temp\empty\else - \tclose{\temp}% typeset the return type - \ifrettypeownline - % put return type on its own line; prohibit line break following: - \hfil\vadjust{\nobreak}\break - \else - \space % type on same line, so just followed by a space - \fi - \fi % no return type - #3% output function name - }% - {\rm\enskip}% hskip 0.5 em of \tenrm - % - \boldbrax - % arguments will be output next, if any. -} - -% Print arguments in slanted roman (not ttsl), inconsistently with using -% tt for the name. This is because literal text is sometimes needed in -% the argument list (groff manual), and ttsl and tt are not very -% distinguishable. Prevent hyphenation at `-' chars. -% -\def\defunargs#1{% - % use sl by default (not ttsl), - % tt for the names. - \df \sl \hyphenchar\font=0 - % - % On the other hand, if an argument has two dashes (for instance), we - % want a way to get ttsl. We used to recommend @var for that, so - % leave the code in, but it's strange for @var to lead to typewriter. - % Nowadays we recommend @code, since the difference between a ttsl hyphen - % and a tt hyphen is pretty tiny. @code also disables ?` !`. - \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% - #1% - \sl\hyphenchar\font=45 -} - -% We want ()&[] to print specially on the defun line. -% -\def\activeparens{% - \catcode`\(=\active \catcode`\)=\active - \catcode`\[=\active \catcode`\]=\active - \catcode`\&=\active -} - -% Make control sequences which act like normal parenthesis chars. -\let\lparen = ( \let\rparen = ) - -% Be sure that we always have a definition for `(', etc. For example, -% if the fn name has parens in it, \boldbrax will not be in effect yet, -% so TeX would otherwise complain about undefined control sequence. -{ - \activeparens - \global\let(=\lparen \global\let)=\rparen - \global\let[=\lbrack \global\let]=\rbrack - \global\let& = \& - - \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} - \gdef\magicamp{\let&=\amprm} -} - -\newcount\parencount - -% If we encounter &foo, then turn on ()-hacking afterwards -\newif\ifampseen -\def\amprm#1 {\ampseentrue{\bf\ }} - -\def\parenfont{% - \ifampseen - % At the first level, print parens in roman, - % otherwise use the default font. - \ifnum \parencount=1 \rm \fi - \else - % The \sf parens (in \boldbrax) actually are a little bolder than - % the contained text. This is especially needed for [ and ] . - \sf - \fi -} -\def\infirstlevel#1{% - \ifampseen - \ifnum\parencount=1 - #1% - \fi - \fi -} -\def\bfafterword#1 {#1 \bf} - -\def\opnr{% - \global\advance\parencount by 1 - {\parenfont(}% - \infirstlevel \bfafterword -} -\def\clnr{% - {\parenfont)}% - \infirstlevel \sl - \global\advance\parencount by -1 -} - -\newcount\brackcount -\def\lbrb{% - \global\advance\brackcount by 1 - {\bf[}% -} -\def\rbrb{% - {\bf]}% - \global\advance\brackcount by -1 -} - -\def\checkparencounts{% - \ifnum\parencount=0 \else \badparencount \fi - \ifnum\brackcount=0 \else \badbrackcount \fi -} -% these should not use \errmessage; the glibc manual, at least, actually -% has such constructs (when documenting function pointers). -\def\badparencount{% - \message{Warning: unbalanced parentheses in @def...}% - \global\parencount=0 -} -\def\badbrackcount{% - \message{Warning: unbalanced square brackets in @def...}% - \global\brackcount=0 -} - - -\message{macros,} -% @macro. - -% To do this right we need a feature of e-TeX, \scantokens, -% which we arrange to emulate with a temporary file in ordinary TeX. -\ifx\eTeXversion\thisisundefined - \newwrite\macscribble - \def\scantokens#1{% - \toks0={#1}% - \immediate\openout\macscribble=\jobname.tmp - \immediate\write\macscribble{\the\toks0}% - \immediate\closeout\macscribble - \input \jobname.tmp - } -\fi - -\def\scanmacro#1{\begingroup - \newlinechar`\^^M - \let\xeatspaces\eatspaces - % - % Undo catcode changes of \startcontents and \doprintindex - % When called from @insertcopying or (short)caption, we need active - % backslash to get it printed correctly. Previously, we had - % \catcode`\\=\other instead. We'll see whether a problem appears - % with macro expansion. --kasal, 19aug04 - \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ - % - % ... and for \example: - \spaceisspace - % - % The \empty here causes a following catcode 5 newline to be eaten as - % part of reading whitespace after a control sequence. It does not - % eat a catcode 13 newline. There's no good way to handle the two - % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX - % would then have different behavior). See the Macro Details node in - % the manual for the workaround we recommend for macros and - % line-oriented commands. - % - \scantokens{#1\empty}% -\endgroup} - -\def\scanexp#1{% - \edef\temp{\noexpand\scanmacro{#1}}% - \temp -} - -\newcount\paramno % Count of parameters -\newtoks\macname % Macro name -\newif\ifrecursive % Is it recursive? - -% List of all defined macros in the form -% \definedummyword\macro1\definedummyword\macro2... -% Currently is also contains all @aliases; the list can be split -% if there is a need. -\def\macrolist{} - -% Add the macro to \macrolist -\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} -\def\addtomacrolistxxx#1{% - \toks0 = \expandafter{\macrolist\definedummyword#1}% - \xdef\macrolist{\the\toks0}% -} - -% Utility routines. -% This does \let #1 = #2, with \csnames; that is, -% \let \csname#1\endcsname = \csname#2\endcsname -% (except of course we have to play expansion games). -% -\def\cslet#1#2{% - \expandafter\let - \csname#1\expandafter\endcsname - \csname#2\endcsname -} - -% Trim leading and trailing spaces off a string. -% Concepts from aro-bend problem 15 (see CTAN). -{\catcode`\@=11 -\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} -\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} -\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} -\def\unbrace#1{#1} -\unbrace{\gdef\trim@@@ #1 } #2@{#1} -} - -% Trim a single trailing ^^M off a string. -{\catcode`\^^M=\other \catcode`\Q=3% -\gdef\eatcr #1{\eatcra #1Q^^MQ}% -\gdef\eatcra#1^^MQ{\eatcrb#1Q}% -\gdef\eatcrb#1Q#2Q{#1}% -} - -% Macro bodies are absorbed as an argument in a context where -% all characters are catcode 10, 11 or 12, except \ which is active -% (as in normal texinfo). It is necessary to change the definition of \ -% to recognize macro arguments; this is the job of \mbodybackslash. -% -% Non-ASCII encodings make 8-bit characters active, so un-activate -% them to avoid their expansion. Must do this non-globally, to -% confine the change to the current group. -% -% It's necessary to have hard CRs when the macro is executed. This is -% done by making ^^M (\endlinechar) catcode 12 when reading the macro -% body, and then making it the \newlinechar in \scanmacro. -% -\def\scanctxt{% used as subroutine - \catcode`\"=\other - \catcode`\+=\other - \catcode`\<=\other - \catcode`\>=\other - \catcode`\@=\other - \catcode`\^=\other - \catcode`\_=\other - \catcode`\|=\other - \catcode`\~=\other - \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi -} - -\def\scanargctxt{% used for copying and captions, not macros. - \scanctxt - \catcode`\\=\other - \catcode`\^^M=\other -} - -\def\macrobodyctxt{% used for @macro definitions - \scanctxt - \catcode`\{=\other - \catcode`\}=\other - \catcode`\^^M=\other - \usembodybackslash -} - -\def\macroargctxt{% used when scanning invocations - \scanctxt - \catcode`\\=0 -} -% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes" -% for the single characters \ { }. Thus, we end up with the "commands" -% that would be written @\ @{ @} in a Texinfo document. -% -% We already have @{ and @}. For @\, we define it here, and only for -% this purpose, to produce a typewriter backslash (so, the @\ that we -% define for @math can't be used with @macro calls): -% -\def\\{\normalbackslash}% -% -% We would like to do this for \, too, since that is what makeinfo does. -% But it is not possible, because Texinfo already has a command @, for a -% cedilla accent. Documents must use @comma{} instead. -% -% \anythingelse will almost certainly be an error of some kind. - - -% \mbodybackslash is the definition of \ in @macro bodies. -% It maps \foo\ => \csname macarg.foo\endcsname => #N -% where N is the macro parameter number. -% We define \csname macarg.\endcsname to be \realbackslash, so -% \\ in macro replacement text gets you a backslash. -% -{\catcode`@=0 @catcode`@\=@active - @gdef@usembodybackslash{@let\=@mbodybackslash} - @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} -} -\expandafter\def\csname macarg.\endcsname{\realbackslash} - -\def\margbackslash#1{\char`\#1 } - -\def\macro{\recursivefalse\parsearg\macroxxx} -\def\rmacro{\recursivetrue\parsearg\macroxxx} - -\def\macroxxx#1{% - \getargs{#1}% now \macname is the macname and \argl the arglist - \ifx\argl\empty % no arguments - \paramno=0\relax - \else - \expandafter\parsemargdef \argl;% - \if\paramno>256\relax - \ifx\eTeXversion\thisisundefined - \errhelp = \EMsimple - \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} - \fi - \fi - \fi - \if1\csname ismacro.\the\macname\endcsname - \message{Warning: redefining \the\macname}% - \else - \expandafter\ifx\csname \the\macname\endcsname \relax - \else \errmessage{Macro name \the\macname\space already defined}\fi - \global\cslet{macsave.\the\macname}{\the\macname}% - \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% - \addtomacrolist{\the\macname}% - \fi - \begingroup \macrobodyctxt - \ifrecursive \expandafter\parsermacbody - \else \expandafter\parsemacbody - \fi} - -\parseargdef\unmacro{% - \if1\csname ismacro.#1\endcsname - \global\cslet{#1}{macsave.#1}% - \global\expandafter\let \csname ismacro.#1\endcsname=0% - % Remove the macro name from \macrolist: - \begingroup - \expandafter\let\csname#1\endcsname \relax - \let\definedummyword\unmacrodo - \xdef\macrolist{\macrolist}% - \endgroup - \else - \errmessage{Macro #1 not defined}% - \fi -} - -% Called by \do from \dounmacro on each macro. The idea is to omit any -% macro definitions that have been changed to \relax. -% -\def\unmacrodo#1{% - \ifx #1\relax - % remove this - \else - \noexpand\definedummyword \noexpand#1% - \fi -} - -% This makes use of the obscure feature that if the last token of a -% is #, then the preceding argument is delimited by -% an opening brace, and that opening brace is not consumed. -\def\getargs#1{\getargsxxx#1{}} -\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} -\def\getmacname#1 #2\relax{\macname={#1}} -\def\getmacargs#1{\def\argl{#1}} - -% For macro processing make @ a letter so that we can make Texinfo private macro names. -\edef\texiatcatcode{\the\catcode`\@} -\catcode `@=11\relax - -% Parse the optional {params} list. Set up \paramno and \paramlist -% so \defmacro knows what to do. Define \macarg.BLAH for each BLAH -% in the params list to some hook where the argument si to be expanded. If -% there are less than 10 arguments that hook is to be replaced by ##N where N -% is the position in that list, that is to say the macro arguments are to be -% defined `a la TeX in the macro body. -% -% That gets used by \mbodybackslash (above). -% -% We need to get `macro parameter char #' into several definitions. -% The technique used is stolen from LaTeX: let \hash be something -% unexpandable, insert that wherever you need a #, and then redefine -% it to # just before using the token list produced. -% -% The same technique is used to protect \eatspaces till just before -% the macro is used. -% -% If there are 10 or more arguments, a different technique is used, where the -% hook remains in the body, and when macro is to be expanded the body is -% processed again to replace the arguments. -% -% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the -% argument N value and then \edef the body (nothing else will expand because of -% the catcode regime underwhich the body was input). -% -% If you compile with TeX (not eTeX), and you have macros with 10 or more -% arguments, you need that no macro has more than 256 arguments, otherwise an -% error is produced. -\def\parsemargdef#1;{% - \paramno=0\def\paramlist{}% - \let\hash\relax - \let\xeatspaces\relax - \parsemargdefxxx#1,;,% - % In case that there are 10 or more arguments we parse again the arguments - % list to set new definitions for the \macarg.BLAH macros corresponding to - % each BLAH argument. It was anyhow needed to parse already once this list - % in order to count the arguments, and as macros with at most 9 arguments - % are by far more frequent than macro with 10 or more arguments, defining - % twice the \macarg.BLAH macros does not cost too much processing power. - \ifnum\paramno<10\relax\else - \paramno0\relax - \parsemmanyargdef@@#1,;,% 10 or more arguments - \fi -} -\def\parsemargdefxxx#1,{% - \if#1;\let\next=\relax - \else \let\next=\parsemargdefxxx - \advance\paramno by 1 - \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname - {\xeatspaces{\hash\the\paramno}}% - \edef\paramlist{\paramlist\hash\the\paramno,}% - \fi\next} - -\def\parsemmanyargdef@@#1,{% - \if#1;\let\next=\relax - \else - \let\next=\parsemmanyargdef@@ - \edef\tempb{\eatspaces{#1}}% - \expandafter\def\expandafter\tempa - \expandafter{\csname macarg.\tempb\endcsname}% - % Note that we need some extra \noexpand\noexpand, this is because we - % don't want \the to be expanded in the \parsermacbody as it uses an - % \xdef . - \expandafter\edef\tempa - {\noexpand\noexpand\noexpand\the\toks\the\paramno}% - \advance\paramno by 1\relax - \fi\next} - -% These two commands read recursive and nonrecursive macro bodies. -% (They're different since rec and nonrec macros end differently.) -% - -\catcode `\@\texiatcatcode -\long\def\parsemacbody#1@end macro% -{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% -\long\def\parsermacbody#1@end rmacro% -{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% -\catcode `\@=11\relax - -\let\endargs@\relax -\let\nil@\relax -\def\nilm@{\nil@}% -\long\def\nillm@{\nil@}% - -% This macro is expanded during the Texinfo macro expansion, not during its -% definition. It gets all the arguments values and assigns them to macros -% macarg.ARGNAME -% -% #1 is the macro name -% #2 is the list of argument names -% #3 is the list of argument values -\def\getargvals@#1#2#3{% - \def\macargdeflist@{}% - \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. - \def\paramlist{#2,\nil@}% - \def\macroname{#1}% - \begingroup - \macroargctxt - \def\argvaluelist{#3,\nil@}% - \def\@tempa{#3}% - \ifx\@tempa\empty - \setemptyargvalues@ - \else - \getargvals@@ - \fi -} - -% -\def\getargvals@@{% - \ifx\paramlist\nilm@ - % Some sanity check needed here that \argvaluelist is also empty. - \ifx\argvaluelist\nillm@ - \else - \errhelp = \EMsimple - \errmessage{Too many arguments in macro `\macroname'!}% - \fi - \let\next\macargexpandinbody@ - \else - \ifx\argvaluelist\nillm@ - % No more arguments values passed to macro. Set remaining named-arg - % macros to empty. - \let\next\setemptyargvalues@ - \else - % pop current arg name into \@tempb - \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% - \expandafter\@tempa\expandafter{\paramlist}% - % pop current argument value into \@tempc - \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% - \expandafter\@tempa\expandafter{\argvaluelist}% - % Here \@tempb is the current arg name and \@tempc is the current arg value. - % First place the new argument macro definition into \@tempd - \expandafter\macname\expandafter{\@tempc}% - \expandafter\let\csname macarg.\@tempb\endcsname\relax - \expandafter\def\expandafter\@tempe\expandafter{% - \csname macarg.\@tempb\endcsname}% - \edef\@tempd{\long\def\@tempe{\the\macname}}% - \push@\@tempd\macargdeflist@ - \let\next\getargvals@@ - \fi - \fi - \next -} - -\def\push@#1#2{% - \expandafter\expandafter\expandafter\def - \expandafter\expandafter\expandafter#2% - \expandafter\expandafter\expandafter{% - \expandafter#1#2}% -} - -% Replace arguments by their values in the macro body, and place the result -% in macro \@tempa -\def\macvalstoargs@{% - % To do this we use the property that token registers that are \the'ed - % within an \edef expand only once. So we are going to place all argument - % values into respective token registers. - % - % First we save the token context, and initialize argument numbering. - \begingroup - \paramno0\relax - % Then, for each argument number #N, we place the corresponding argument - % value into a new token list register \toks#N - \expandafter\putargsintokens@\saveparamlist@,;,% - % Then, we expand the body so that argument are replaced by their - % values. The trick for values not to be expanded themselves is that they - % are within tokens and that tokens expand only once in an \edef . - \edef\@tempc{\csname mac.\macroname .body\endcsname}% - % Now we restore the token stack pointer to free the token list registers - % which we have used, but we make sure that expanded body is saved after - % group. - \expandafter - \endgroup - \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% - } - -\def\macargexpandinbody@{% - %% Define the named-macro outside of this group and then close this group. - \expandafter - \endgroup - \macargdeflist@ - % First the replace in body the macro arguments by their values, the result - % is in \@tempa . - \macvalstoargs@ - % Then we point at the \norecurse or \gobble (for recursive) macro value - % with \@tempb . - \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname - % Depending on whether it is recursive or not, we need some tailing - % \egroup . - \ifx\@tempb\gobble - \let\@tempc\relax - \else - \let\@tempc\egroup - \fi - % And now we do the real job: - \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% - \@tempd -} - -\def\putargsintokens@#1,{% - \if#1;\let\next\relax - \else - \let\next\putargsintokens@ - % First we allocate the new token list register, and give it a temporary - % alias \@tempb . - \toksdef\@tempb\the\paramno - % Then we place the argument value into that token list register. - \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname - \expandafter\@tempb\expandafter{\@tempa}% - \advance\paramno by 1\relax - \fi - \next -} - -% Save the token stack pointer into macro #1 -\def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}} -% Restore the token stack pointer from number in macro #1 -\def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax} -% newtoks that can be used non \outer . -\def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi} - -% Tailing missing arguments are set to empty -\def\setemptyargvalues@{% - \ifx\paramlist\nilm@ - \let\next\macargexpandinbody@ - \else - \expandafter\setemptyargvaluesparser@\paramlist\endargs@ - \let\next\setemptyargvalues@ - \fi - \next -} - -\def\setemptyargvaluesparser@#1,#2\endargs@{% - \expandafter\def\expandafter\@tempa\expandafter{% - \expandafter\def\csname macarg.#1\endcsname{}}% - \push@\@tempa\macargdeflist@ - \def\paramlist{#2}% -} - -% #1 is the element target macro -% #2 is the list macro -% #3,#4\endargs@ is the list value -\def\pop@#1#2#3,#4\endargs@{% - \def#1{#3}% - \def#2{#4}% -} -\long\def\longpop@#1#2#3,#4\endargs@{% - \long\def#1{#3}% - \long\def#2{#4}% -} - -% This defines a Texinfo @macro. There are eight cases: recursive and -% nonrecursive macros of zero, one, up to nine, and many arguments. -% Much magic with \expandafter here. -% \xdef is used so that macro definitions will survive the file -% they're defined in; @include reads the file inside a group. -% -\def\defmacro{% - \let\hash=##% convert placeholders to macro parameter chars - \ifrecursive - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\scanmacro{\temp}}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname xxx\endcsname}% - \expandafter\xdef\csname\the\macname xxx\endcsname##1{% - \egroup\noexpand\scanmacro{\temp}}% - \else - \ifnum\paramno<10\relax % at most 9 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{\egroup\noexpand\scanmacro{\temp}}% - \else % 10 or more - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\getargvals@{\the\macname}{\argl}% - }% - \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp - \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble - \fi - \fi - \else - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname xxx\endcsname}% - \expandafter\xdef\csname\the\macname xxx\endcsname##1{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \else % at most 9 - \ifnum\paramno<10\relax - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \expandafter\noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \else % 10 or more: - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\getargvals@{\the\macname}{\argl}% - }% - \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp - \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse - \fi - \fi - \fi} - -\catcode `\@\texiatcatcode\relax - -\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} - -% \braceorline decides whether the next nonwhitespace character is a -% {. If so it reads up to the closing }, if not, it reads the whole -% line. Whatever was read is then fed to the next control sequence -% as an argument (by \parsebrace or \parsearg). -% -\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} -\def\braceorlinexxx{% - \ifx\nchar\bgroup\else - \expandafter\parsearg - \fi \macnamexxx} - - -% @alias. -% We need some trickery to remove the optional spaces around the equal -% sign. Make them active and then expand them all to nothing. -% -\def\alias{\parseargusing\obeyspaces\aliasxxx} -\def\aliasxxx #1{\aliasyyy#1\relax} -\def\aliasyyy #1=#2\relax{% - {% - \expandafter\let\obeyedspace=\empty - \addtomacrolist{#1}% - \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% - }% - \next -} - - -\message{cross references,} - -\newwrite\auxfile -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% @inforef is relatively simple. -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{% - \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, - node \samp{\ignorespaces#1{}}} - -% @node's only job in TeX is to define \lastnode, which is used in -% cross-references. The @node line might or might not have commas, and -% might or might not have spaces before the first comma, like: -% @node foo , bar , ... -% We don't want such trailing spaces in the node name. -% -\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} -% -% also remove a trailing comma, in case of something like this: -% @node Help-Cross, , , Cross-refs -\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} -\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} - -\let\nwnode=\node -\let\lastnode=\empty - -% Write a cross-reference definition for the current node. #1 is the -% type (Ynumbered, Yappendix, Ynothing). -% -\def\donoderef#1{% - \ifx\lastnode\empty\else - \setref{\lastnode}{#1}% - \global\let\lastnode=\empty - \fi -} - -% @anchor{NAME} -- define xref target at arbitrary point. -% -\newcount\savesfregister -% -\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} -\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} -\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} - -% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an -% anchor), which consists of three parts: -% 1) NAME-title - the current sectioning name taken from \lastsection, -% or the anchor name. -% 2) NAME-snt - section number and type, passed as the SNT arg, or -% empty for anchors. -% 3) NAME-pg - the page number. -% -% This is called from \donoderef, \anchor, and \dofloat. In the case of -% floats, there is an additional part, which is not written here: -% 4) NAME-lof - the text as it should appear in a @listoffloats. -% -\def\setref#1#2{% - \pdfmkdest{#1}% - \iflinks - {% - \atdummies % preserve commands, but don't expand them - \edef\writexrdef##1##2{% - \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef - ##1}{##2}}% these are parameters of \writexrdef - }% - \toks0 = \expandafter{\lastsection}% - \immediate \writexrdef{title}{\the\toks0 }% - \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. - \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout - }% - \fi -} - -% @xrefautosectiontitle on|off says whether @section(ing) names are used -% automatically in xrefs, if the third arg is not explicitly specified. -% This was provided as a "secret" @set xref-automatic-section-title -% variable, now it's official. -% -\parseargdef\xrefautomaticsectiontitle{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETxref-automatic-section-title\endcsname - = \empty - \else\ifx\temp\offword - \expandafter\let\csname SETxref-automatic-section-title\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', - must be on|off}% - \fi\fi -} - -% -% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is -% the node name, #2 the name of the Info cross-reference, #3 the printed -% node name, #4 the name of the Info file, #5 the name of the printed -% manual. All but the node name can be omitted. -% -\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} -\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -% -\newbox\toprefbox -\newbox\printedrefnamebox -\newbox\infofilenamebox -\newbox\printedmanualbox -% -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup - \unsepspaces - % - % Get args without leading/trailing spaces. - \def\printedrefname{\ignorespaces #3}% - \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% - % - \def\infofilename{\ignorespaces #4}% - \setbox\infofilenamebox = \hbox{\infofilename\unskip}% - % - \def\printedmanual{\ignorespaces #5}% - \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% - % - % If the printed reference name (arg #3) was not explicitly given in - % the @xref, figure out what we want to use. - \ifdim \wd\printedrefnamebox = 0pt - % No printed node name was explicitly given. - \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax - % Not auto section-title: use node name inside the square brackets. - \def\printedrefname{\ignorespaces #1}% - \else - % Auto section-title: use chapter/section title inside - % the square brackets if we have it. - \ifdim \wd\printedmanualbox > 0pt - % It is in another manual, so we don't have it; use node name. - \def\printedrefname{\ignorespaces #1}% - \else - \ifhavexrefs - % We (should) know the real title if we have the xref values. - \def\printedrefname{\refx{#1-title}{}}% - \else - % Otherwise just copy the Info node name. - \def\printedrefname{\ignorespaces #1}% - \fi% - \fi - \fi - \fi - % - % Make link in pdf output. - \ifpdf - {\indexnofonts - \turnoffactive - \makevalueexpandable - % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. This ignores all spaces in - % #4, including (wrongly) those in the middle of the filename. - \getfilename{#4}% - % - % This (wrongly) does not take account of leading or trailing - % spaces in #1, which should be ignored. - \edef\pdfxrefdest{#1}% - \ifx\pdfxrefdest\empty - \def\pdfxrefdest{Top}% no empty targets - \else - \txiescapepdf\pdfxrefdest % escape PDF special chars - \fi - % - \leavevmode - \startlink attr{/Border [0 0 0]}% - \ifnum\filenamelength>0 - goto file{\the\filename.pdf} name{\pdfxrefdest}% - \else - goto name{\pdfmkpgn{\pdfxrefdest}}% - \fi - }% - \setcolor{\linkcolor}% - \fi - % - % Float references are printed completely differently: "Figure 1.2" - % instead of "[somenode], p.3". We distinguish them by the - % LABEL-title being set to a magic string. - {% - % Have to otherify everything special to allow the \csname to - % include an _ in the xref name, etc. - \indexnofonts - \turnoffactive - \expandafter\global\expandafter\let\expandafter\Xthisreftitle - \csname XR#1-title\endcsname - }% - \iffloat\Xthisreftitle - % If the user specified the print name (third arg) to the ref, - % print it instead of our usual "Figure 1.2". - \ifdim\wd\printedrefnamebox = 0pt - \refx{#1-snt}{}% - \else - \printedrefname - \fi - % - % If the user also gave the printed manual name (fifth arg), append - % "in MANUALNAME". - \ifdim \wd\printedmanualbox > 0pt - \space \putwordin{} \cite{\printedmanual}% - \fi - \else - % node/anchor (non-float) references. - % - % If we use \unhbox to print the node names, TeX does not insert - % empty discretionaries after hyphens, which means that it will not - % find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, - % this is a loss. Therefore, we give the text of the node name - % again, so it is as if TeX is seeing it for the first time. - % - \ifdim \wd\printedmanualbox > 0pt - % Cross-manual reference with a printed manual name. - % - \crossmanualxref{\cite{\printedmanual\unskip}}% - % - \else\ifdim \wd\infofilenamebox > 0pt - % Cross-manual reference with only an info filename (arg 4), no - % printed manual name (arg 5). This is essentially the same as - % the case above; we output the filename, since we have nothing else. - % - \crossmanualxref{\code{\infofilename\unskip}}% - % - \else - % Reference within this manual. - % - % _ (for example) has to be the character _ for the purposes of the - % control sequence corresponding to the node, but it has to expand - % into the usual \leavevmode...\vrule stuff for purposes of - % printing. So we \turnoffactive for the \refx-snt, back on for the - % printing, back off for the \refx-pg. - {\turnoffactive - % Only output a following space if the -snt ref is nonempty; for - % @unnumbered and @anchor, it won't be. - \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% - \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi - }% - % output the `[mynode]' via the macro below so it can be overridden. - \xrefprintnodename\printedrefname - % - % But we always want a comma and a space: - ,\space - % - % output the `page 3'. - \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - \fi\fi - \fi - \endlink -\endgroup} - -% Output a cross-manual xref to #1. Used just above (twice). -% -% Only include the text "Section ``foo'' in" if the foo is neither -% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply -% "see The Foo Manual", the idea being to refer to the whole manual. -% -% But, this being TeX, we can't easily compare our node name against the -% string "Top" while ignoring the possible spaces before and after in -% the input. By adding the arbitrary 7sp below, we make it much less -% likely that a real node name would have the same width as "Top" (e.g., -% in a monospaced font). Hopefully it will never happen in practice. -% -% For the same basic reason, we retypeset the "Top" at every -% reference, since the current font is indeterminate. -% -\def\crossmanualxref#1{% - \setbox\toprefbox = \hbox{Top\kern7sp}% - \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% - \ifdim \wd2 > 7sp % nonempty? - \ifdim \wd2 = \wd\toprefbox \else % same as Top? - \putwordSection{} ``\printedrefname'' \putwordin{}\space - \fi - \fi - #1% -} - -% This macro is called from \xrefX for the `[nodename]' part of xref -% output. It's a separate macro only so it can be changed more easily, -% since square brackets don't work well in some documents. Particularly -% one that Bob is working on :). -% -\def\xrefprintnodename#1{[#1]} - -% Things referred to by \setref. -% -\def\Ynothing{} -\def\Yomitfromtoc{} -\def\Ynumbered{% - \ifnum\secno=0 - \putwordChapter@tie \the\chapno - \else \ifnum\subsecno=0 - \putwordSection@tie \the\chapno.\the\secno - \else \ifnum\subsubsecno=0 - \putwordSection@tie \the\chapno.\the\secno.\the\subsecno - \else - \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno - \fi\fi\fi -} -\def\Yappendix{% - \ifnum\secno=0 - \putwordAppendix@tie @char\the\appendixno{}% - \else \ifnum\subsecno=0 - \putwordSection@tie @char\the\appendixno.\the\secno - \else \ifnum\subsubsecno=0 - \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno - \else - \putwordSection@tie - @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno - \fi\fi\fi -} - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. -% -\def\refx#1#2{% - {% - \indexnofonts - \otherbackslash - \expandafter\global\expandafter\let\expandafter\thisrefX - \csname XR#1\endcsname - }% - \ifx\thisrefX\relax - % If not defined, say something at least. - \angleleft un\-de\-fined\angleright - \iflinks - \ifhavexrefs - {\toks0 = {#1}% avoid expansion of possibly-complex value - \message{\linenumber Undefined cross reference `\the\toks0'.}}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \fi - \else - % It's defined, so just use it. - \thisrefX - \fi - #2% Output the suffix in any case. -} - -% This is the macro invoked by entries in the aux file. Usually it's -% just a \def (we prepend XR to the control sequence name to avoid -% collisions). But if this is a float type, we have more work to do. -% -\def\xrdef#1#2{% - {% The node name might contain 8-bit characters, which in our current - % implementation are changed to commands like @'e. Don't let these - % mess up the control sequence name. - \indexnofonts - \turnoffactive - \xdef\safexrefname{#1}% - }% - % - \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref - % - % Was that xref control sequence that we just defined for a float? - \expandafter\iffloat\csname XR\safexrefname\endcsname - % it was a float, and we have the (safe) float type in \iffloattype. - \expandafter\let\expandafter\floatlist - \csname floatlist\iffloattype\endcsname - % - % Is this the first time we've seen this float type? - \expandafter\ifx\floatlist\relax - \toks0 = {\do}% yes, so just \do - \else - % had it before, so preserve previous elements in list. - \toks0 = \expandafter{\floatlist\do}% - \fi - % - % Remember this xref in the control sequence \floatlistFLOATTYPE, - % for later use in \listoffloats. - \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 - {\safexrefname}}% - \fi -} - -% Read the last existing aux file, if any. No error if none exists. -% -\def\tryauxfile{% - \openin 1 \jobname.aux - \ifeof 1 \else - \readdatafile{aux}% - \global\havexrefstrue - \fi - \closein 1 -} - -\def\setupdatafile{% - \catcode`\^^@=\other - \catcode`\^^A=\other - \catcode`\^^B=\other - \catcode`\^^C=\other - \catcode`\^^D=\other - \catcode`\^^E=\other - \catcode`\^^F=\other - \catcode`\^^G=\other - \catcode`\^^H=\other - \catcode`\^^K=\other - \catcode`\^^L=\other - \catcode`\^^N=\other - \catcode`\^^P=\other - \catcode`\^^Q=\other - \catcode`\^^R=\other - \catcode`\^^S=\other - \catcode`\^^T=\other - \catcode`\^^U=\other - \catcode`\^^V=\other - \catcode`\^^W=\other - \catcode`\^^X=\other - \catcode`\^^Z=\other - \catcode`\^^[=\other - \catcode`\^^\=\other - \catcode`\^^]=\other - \catcode`\^^^=\other - \catcode`\^^_=\other - % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. - % in xref tags, i.e., node names. But since ^^e4 notation isn't - % supported in the main text, it doesn't seem desirable. Furthermore, - % that is not enough: for node names that actually contain a ^ - % character, we would end up writing a line like this: 'xrdef {'hat - % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first - % argument, and \hat is not an expandable control sequence. It could - % all be worked out, but why? Either we support ^^ or we don't. - % - % The other change necessary for this was to define \auxhat: - % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter - % and then to call \auxhat in \setq. - % - \catcode`\^=\other - % - % Special characters. Should be turned off anyway, but... - \catcode`\~=\other - \catcode`\[=\other - \catcode`\]=\other - \catcode`\"=\other - \catcode`\_=\other - \catcode`\|=\other - \catcode`\<=\other - \catcode`\>=\other - \catcode`\$=\other - \catcode`\#=\other - \catcode`\&=\other - \catcode`\%=\other - \catcode`+=\other % avoid \+ for paranoia even though we've turned it off - % - % This is to support \ in node names and titles, since the \ - % characters end up in a \csname. It's easier than - % leaving it active and making its active definition an actual \ - % character. What I don't understand is why it works in the *value* - % of the xrdef. Seems like it should be a catcode12 \, and that - % should not typeset properly. But it works, so I'm moving on for - % now. --karl, 15jan04. - \catcode`\\=\other - % - % Make the characters 128-255 be printing characters. - {% - \count1=128 - \def\loop{% - \catcode\count1=\other - \advance\count1 by 1 - \ifnum \count1<256 \loop \fi - }% - }% - % - % @ is our escape character in .aux files, and we need braces. - \catcode`\{=1 - \catcode`\}=2 - \catcode`\@=0 -} - -\def\readdatafile#1{% -\begingroup - \setupdatafile - \input\jobname.#1 -\endgroup} - - -\message{insertions,} -% including footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. (Generally, numeric constants should always be followed by a -% space to prevent strange expansion errors.) -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for Info output only. -\let\footnotestyle=\comment - -{\catcode `\@=11 -% -% Auto-number footnotes. Otherwise like plain. -\gdef\footnote{% - \let\indent=\ptexindent - \let\noindent=\ptexnoindent - \global\advance\footnoteno by \@ne - \edef\thisfootno{$^{\the\footnoteno}$}% - % - % In case the footnote comes at the end of a sentence, preserve the - % extra spacing after we do the footnote number. - \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi - % - % Remove inadvertent blank space before typesetting the footnote number. - \unskip - \thisfootno\@sf - \dofootnote -}% - -% Don't bother with the trickery in plain.tex to not require the -% footnote text as a parameter. Our footnotes don't need to be so general. -% -% Oh yes, they do; otherwise, @ifset (and anything else that uses -% \parseargline) fails inside footnotes because the tokens are fixed when -% the footnote is read. --karl, 16nov96. -% -\gdef\dofootnote{% - \insert\footins\bgroup - % We want to typeset this text as a normal paragraph, even if the - % footnote reference occurs in (for example) a display environment. - % So reset some parameters. - \hsize=\pagewidth - \interlinepenalty\interfootnotelinepenalty - \splittopskip\ht\strutbox % top baseline for broken footnotes - \splitmaxdepth\dp\strutbox - \floatingpenalty\@MM - \leftskip\z@skip - \rightskip\z@skip - \spaceskip\z@skip - \xspaceskip\z@skip - \parindent\defaultparindent - % - \smallfonts \rm - % - % Because we use hanging indentation in footnotes, a @noindent appears - % to exdent this text, so make it be a no-op. makeinfo does not use - % hanging indentation so @noindent can still be needed within footnote - % text after an @example or the like (not that this is good style). - \let\noindent = \relax - % - % Hang the footnote text off the number. Use \everypar in case the - % footnote extends for more than one paragraph. - \everypar = {\hang}% - \textindent{\thisfootno}% - % - % Don't crash into the line above the footnote text. Since this - % expands into a box, it must come within the paragraph, lest it - % provide a place where TeX can split the footnote. - \footstrut - % - % Invoke rest of plain TeX footnote routine. - \futurelet\next\fo@t -} -}%end \catcode `\@=11 - -% In case a @footnote appears in a vbox, save the footnote text and create -% the real \insert just after the vbox finished. Otherwise, the insertion -% would be lost. -% Similarly, if a @footnote appears inside an alignment, save the footnote -% text to a box and make the \insert when a row of the table is finished. -% And the same can be done for other insert classes. --kasal, 16nov03. - -% Replace the \insert primitive by a cheating macro. -% Deeper inside, just make sure that the saved insertions are not spilled -% out prematurely. -% -\def\startsavinginserts{% - \ifx \insert\ptexinsert - \let\insert\saveinsert - \else - \let\checkinserts\relax - \fi -} - -% This \insert replacement works for both \insert\footins{foo} and -% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. -% -\def\saveinsert#1{% - \edef\next{\noexpand\savetobox \makeSAVEname#1}% - \afterassignment\next - % swallow the left brace - \let\temp = -} -\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} -\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} - -\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} - -\def\placesaveins#1{% - \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname - {\box#1}% -} - -% eat @SAVE -- beware, all of them have catcode \other: -{ - \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) - \gdef\gobblesave @SAVE{} -} - -% initialization: -\def\newsaveins #1{% - \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% - \next -} -\def\newsaveinsX #1{% - \csname newbox\endcsname #1% - \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts - \checksaveins #1}% -} - -% initialize: -\let\checkinserts\empty -\newsaveins\footins -\newsaveins\margin - - -% @image. We use the macros from epsf.tex to support this. -% If epsf.tex is not installed and @image is used, we complain. -% -% Check for and read epsf.tex up front. If we read it only at @image -% time, we might be inside a group, and then its definitions would get -% undone and the next image would fail. -\openin 1 = epsf.tex -\ifeof 1 \else - % Do not bother showing banner with epsf.tex v2.7k (available in - % doc/epsf.tex and on ctan). - \def\epsfannounce{\toks0 = }% - \input epsf.tex -\fi -\closein 1 -% -% We will only complain once about lack of epsf.tex. -\newif\ifwarnednoepsf -\newhelp\noepsfhelp{epsf.tex must be installed for images to - work. It is also included in the Texinfo distribution, or you can get - it from ftp://tug.org/tex/epsf.tex.} -% -\def\image#1{% - \ifx\epsfbox\thisisundefined - \ifwarnednoepsf \else - \errhelp = \noepsfhelp - \errmessage{epsf.tex not found, images will be ignored}% - \global\warnednoepsftrue - \fi - \else - \imagexxx #1,,,,,\finish - \fi -} -% -% Arguments to @image: -% #1 is (mandatory) image filename; we tack on .eps extension. -% #2 is (optional) width, #3 is (optional) height. -% #4 is (ignored optional) html alt text. -% #5 is (ignored optional) extension. -% #6 is just the usual extra ignored arg for parsing stuff. -\newif\ifimagevmode -\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup - \catcode`\^^M = 5 % in case we're inside an example - \normalturnoffactive % allow _ et al. in names - % If the image is by itself, center it. - \ifvmode - \imagevmodetrue - \else \ifx\centersub\centerV - % for @center @image, we need a vbox so we can have our vertical space - \imagevmodetrue - \vbox\bgroup % vbox has better behavior than vtop herev - \fi\fi - % - \ifimagevmode - \nobreak\medskip - % Usually we'll have text after the image which will insert - % \parskip glue, so insert it here too to equalize the space - % above and below. - \nobreak\vskip\parskip - \nobreak - \fi - % - % Leave vertical mode so that indentation from an enclosing - % environment such as @quotation is respected. - % However, if we're at the top level, we don't want the - % normal paragraph indentation. - % On the other hand, if we are in the case of @center @image, we don't - % want to start a paragraph, which will create a hsize-width box and - % eradicate the centering. - \ifx\centersub\centerV\else \noindent \fi - % - % Output the image. - \ifpdf - \dopdfimage{#1}{#2}{#3}% - \else - % \epsfbox itself resets \epsf?size at each figure. - \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi - \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi - \epsfbox{#1.eps}% - \fi - % - \ifimagevmode - \medskip % space after a standalone image - \fi - \ifx\centersub\centerV \egroup \fi -\endgroup} - - -% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, -% etc. We don't actually implement floating yet, we always include the -% float "here". But it seemed the best name for the future. -% -\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} - -% There may be a space before second and/or third parameter; delete it. -\def\eatcommaspace#1, {#1,} - -% #1 is the optional FLOATTYPE, the text label for this float, typically -% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, -% this float will not be numbered and cannot be referred to. -% -% #2 is the optional xref label. Also must be present for the float to -% be referable. -% -% #3 is the optional positioning argument; for now, it is ignored. It -% will somehow specify the positions allowed to float to (here, top, bottom). -% -% We keep a separate counter for each FLOATTYPE, which we reset at each -% chapter-level command. -\let\resetallfloatnos=\empty -% -\def\dofloat#1,#2,#3,#4\finish{% - \let\thiscaption=\empty - \let\thisshortcaption=\empty - % - % don't lose footnotes inside @float. - % - % BEWARE: when the floats start float, we have to issue warning whenever an - % insert appears inside a float which could possibly float. --kasal, 26may04 - % - \startsavinginserts - % - % We can't be used inside a paragraph. - \par - % - \vtop\bgroup - \def\floattype{#1}% - \def\floatlabel{#2}% - \def\floatloc{#3}% we do nothing with this yet. - % - \ifx\floattype\empty - \let\safefloattype=\empty - \else - {% - % the floattype might have accents or other special characters, - % but we need to use it in a control sequence name. - \indexnofonts - \turnoffactive - \xdef\safefloattype{\floattype}% - }% - \fi - % - % If label is given but no type, we handle that as the empty type. - \ifx\floatlabel\empty \else - % We want each FLOATTYPE to be numbered separately (Figure 1, - % Table 1, Figure 2, ...). (And if no label, no number.) - % - \expandafter\getfloatno\csname\safefloattype floatno\endcsname - \global\advance\floatno by 1 - % - {% - % This magic value for \lastsection is output by \setref as the - % XREFLABEL-title value. \xrefX uses it to distinguish float - % labels (which have a completely different output format) from - % node and anchor labels. And \xrdef uses it to construct the - % lists of floats. - % - \edef\lastsection{\floatmagic=\safefloattype}% - \setref{\floatlabel}{Yfloat}% - }% - \fi - % - % start with \parskip glue, I guess. - \vskip\parskip - % - % Don't suppress indentation if a float happens to start a section. - \restorefirstparagraphindent -} - -% we have these possibilities: -% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap -% @float Foo,lbl & no caption: Foo 1.1 -% @float Foo & @caption{Cap}: Foo: Cap -% @float Foo & no caption: Foo -% @float ,lbl & Caption{Cap}: 1.1: Cap -% @float ,lbl & no caption: 1.1 -% @float & @caption{Cap}: Cap -% @float & no caption: -% -\def\Efloat{% - \let\floatident = \empty - % - % In all cases, if we have a float type, it comes first. - \ifx\floattype\empty \else \def\floatident{\floattype}\fi - % - % If we have an xref label, the number comes next. - \ifx\floatlabel\empty \else - \ifx\floattype\empty \else % if also had float type, need tie first. - \appendtomacro\floatident{\tie}% - \fi - % the number. - \appendtomacro\floatident{\chaplevelprefix\the\floatno}% - \fi - % - % Start the printed caption with what we've constructed in - % \floatident, but keep it separate; we need \floatident again. - \let\captionline = \floatident - % - \ifx\thiscaption\empty \else - \ifx\floatident\empty \else - \appendtomacro\captionline{: }% had ident, so need a colon between - \fi - % - % caption text. - \appendtomacro\captionline{\scanexp\thiscaption}% - \fi - % - % If we have anything to print, print it, with space before. - % Eventually this needs to become an \insert. - \ifx\captionline\empty \else - \vskip.5\parskip - \captionline - % - % Space below caption. - \vskip\parskip - \fi - % - % If have an xref label, write the list of floats info. Do this - % after the caption, to avoid chance of it being a breakpoint. - \ifx\floatlabel\empty \else - % Write the text that goes in the lof to the aux file as - % \floatlabel-lof. Besides \floatident, we include the short - % caption if specified, else the full caption if specified, else nothing. - {% - \atdummies - % - % since we read the caption text in the macro world, where ^^M - % is turned into a normal character, we have to scan it back, so - % we don't write the literal three characters "^^M" into the aux file. - \scanexp{% - \xdef\noexpand\gtemp{% - \ifx\thisshortcaption\empty - \thiscaption - \else - \thisshortcaption - \fi - }% - }% - \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident - \ifx\gtemp\empty \else : \gtemp \fi}}% - }% - \fi - \egroup % end of \vtop - % - % place the captured inserts - % - % BEWARE: when the floats start floating, we have to issue warning - % whenever an insert appears inside a float which could possibly - % float. --kasal, 26may04 - % - \checkinserts -} - -% Append the tokens #2 to the definition of macro #1, not expanding either. -% -\def\appendtomacro#1#2{% - \expandafter\def\expandafter#1\expandafter{#1#2}% -} - -% @caption, @shortcaption -% -\def\caption{\docaption\thiscaption} -\def\shortcaption{\docaption\thisshortcaption} -\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} -\def\defcaption#1#2{\egroup \def#1{#2}} - -% The parameter is the control sequence identifying the counter we are -% going to use. Create it if it doesn't exist and assign it to \floatno. -\def\getfloatno#1{% - \ifx#1\relax - % Haven't seen this figure type before. - \csname newcount\endcsname #1% - % - % Remember to reset this floatno at the next chap. - \expandafter\gdef\expandafter\resetallfloatnos - \expandafter{\resetallfloatnos #1=0 }% - \fi - \let\floatno#1% -} - -% \setref calls this to get the XREFLABEL-snt value. We want an @xref -% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we -% first read the @float command. -% -\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% - -% Magic string used for the XREFLABEL-title value, so \xrefX can -% distinguish floats from other xref types. -\def\floatmagic{!!float!!} - -% #1 is the control sequence we are passed; we expand into a conditional -% which is true if #1 represents a float ref. That is, the magic -% \lastsection value which we \setref above. -% -\def\iffloat#1{\expandafter\doiffloat#1==\finish} -% -% #1 is (maybe) the \floatmagic string. If so, #2 will be the -% (safe) float type for this float. We set \iffloattype to #2. -% -\def\doiffloat#1=#2=#3\finish{% - \def\temp{#1}% - \def\iffloattype{#2}% - \ifx\temp\floatmagic -} - -% @listoffloats FLOATTYPE - print a list of floats like a table of contents. -% -\parseargdef\listoffloats{% - \def\floattype{#1}% floattype - {% - % the floattype might have accents or other special characters, - % but we need to use it in a control sequence name. - \indexnofonts - \turnoffactive - \xdef\safefloattype{\floattype}% - }% - % - % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. - \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax - \ifhavexrefs - % if the user said @listoffloats foo but never @float foo. - \message{\linenumber No `\safefloattype' floats to list.}% - \fi - \else - \begingroup - \leftskip=\tocindent % indent these entries like a toc - \let\do=\listoffloatsdo - \csname floatlist\safefloattype\endcsname - \endgroup - \fi -} - -% This is called on each entry in a list of floats. We're passed the -% xref label, in the form LABEL-title, which is how we save it in the -% aux file. We strip off the -title and look up \XRLABEL-lof, which -% has the text we're supposed to typeset here. -% -% Figures without xref labels will not be included in the list (since -% they won't appear in the aux file). -% -\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} -\def\listoffloatsdoentry#1-title\finish{{% - % Can't fully expand XR#1-lof because it can contain anything. Just - % pass the control sequence. On the other hand, XR#1-pg is just the - % page number, and we want to fully expand that so we can get a link - % in pdf output. - \toksA = \expandafter{\csname XR#1-lof\endcsname}% - % - % use the same \entry macro we use to generate the TOC and index. - \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% - \writeentry -}} - - -\message{localization,} - -% For single-language documents, @documentlanguage is usually given very -% early, just after @documentencoding. Single argument is the language -% (de) or locale (de_DE) abbreviation. -% -{ - \catcode`\_ = \active - \globaldefs=1 -\parseargdef\documentlanguage{\begingroup - \let_=\normalunderscore % normal _ character for filenames - \tex % read txi-??.tex file in plain TeX. - % Read the file by the name they passed if it exists. - \openin 1 txi-#1.tex - \ifeof 1 - \documentlanguagetrywithoutunderscore{#1_\finish}% - \else - \globaldefs = 1 % everything in the txi-LL files needs to persist - \input txi-#1.tex - \fi - \closein 1 - \endgroup % end raw TeX -\endgroup} -% -% If they passed de_DE, and txi-de_DE.tex doesn't exist, -% try txi-de.tex. -% -\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% - \openin 1 txi-#1.tex - \ifeof 1 - \errhelp = \nolanghelp - \errmessage{Cannot read language file txi-#1.tex}% - \else - \globaldefs = 1 % everything in the txi-LL files needs to persist - \input txi-#1.tex - \fi - \closein 1 -} -}% end of special _ catcode -% -\newhelp\nolanghelp{The given language definition file cannot be found or -is empty. Maybe you need to install it? Putting it in the current -directory should work if nowhere else does.} - -% This macro is called from txi-??.tex files; the first argument is the -% \language name to set (without the "\lang@" prefix), the second and -% third args are \{left,right}hyphenmin. -% -% The language names to pass are determined when the format is built. -% See the etex.log file created at that time, e.g., -% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. -% -% With TeX Live 2008, etex now includes hyphenation patterns for all -% available languages. This means we can support hyphenation in -% Texinfo, at least to some extent. (This still doesn't solve the -% accented characters problem.) -% -\catcode`@=11 -\def\txisetlanguage#1#2#3{% - % do not set the language if the name is undefined in the current TeX. - \expandafter\ifx\csname lang@#1\endcsname \relax - \message{no patterns for #1}% - \else - \global\language = \csname lang@#1\endcsname - \fi - % but there is no harm in adjusting the hyphenmin values regardless. - \global\lefthyphenmin = #2\relax - \global\righthyphenmin = #3\relax -} - -% Helpers for encodings. -% Set the catcode of characters 128 through 255 to the specified number. -% -\def\setnonasciicharscatcode#1{% - \count255=128 - \loop\ifnum\count255<256 - \global\catcode\count255=#1\relax - \advance\count255 by 1 - \repeat -} - -\def\setnonasciicharscatcodenonglobal#1{% - \count255=128 - \loop\ifnum\count255<256 - \catcode\count255=#1\relax - \advance\count255 by 1 - \repeat -} - -% @documentencoding sets the definition of non-ASCII characters -% according to the specified encoding. -% -\parseargdef\documentencoding{% - % Encoding being declared for the document. - \def\declaredencoding{\csname #1.enc\endcsname}% - % - % Supported encodings: names converted to tokens in order to be able - % to compare them with \ifx. - \def\ascii{\csname US-ASCII.enc\endcsname}% - \def\latnine{\csname ISO-8859-15.enc\endcsname}% - \def\latone{\csname ISO-8859-1.enc\endcsname}% - \def\lattwo{\csname ISO-8859-2.enc\endcsname}% - \def\utfeight{\csname UTF-8.enc\endcsname}% - % - \ifx \declaredencoding \ascii - \asciichardefs - % - \else \ifx \declaredencoding \lattwo - \setnonasciicharscatcode\active - \lattwochardefs - % - \else \ifx \declaredencoding \latone - \setnonasciicharscatcode\active - \latonechardefs - % - \else \ifx \declaredencoding \latnine - \setnonasciicharscatcode\active - \latninechardefs - % - \else \ifx \declaredencoding \utfeight - \setnonasciicharscatcode\active - \utfeightchardefs - % - \else - \message{Unknown document encoding #1, ignoring.}% - % - \fi % utfeight - \fi % latnine - \fi % latone - \fi % lattwo - \fi % ascii -} - -% A message to be logged when using a character that isn't available -% the default font encoding (OT1). -% -\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} - -% Take account of \c (plain) vs. \, (Texinfo) difference. -\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} - -% First, make active non-ASCII characters in order for them to be -% correctly categorized when TeX reads the replacement text of -% macros containing the character definitions. -\setnonasciicharscatcode\active -% -% Latin1 (ISO-8859-1) character definitions. -\def\latonechardefs{% - \gdef^^a0{\tie} - \gdef^^a1{\exclamdown} - \gdef^^a2{\missingcharmsg{CENT SIGN}} - \gdef^^a3{{\pounds}} - \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} - \gdef^^a5{\missingcharmsg{YEN SIGN}} - \gdef^^a6{\missingcharmsg{BROKEN BAR}} - \gdef^^a7{\S} - \gdef^^a8{\"{}} - \gdef^^a9{\copyright} - \gdef^^aa{\ordf} - \gdef^^ab{\guillemetleft} - \gdef^^ac{$\lnot$} - \gdef^^ad{\-} - \gdef^^ae{\registeredsymbol} - \gdef^^af{\={}} - % - \gdef^^b0{\textdegree} - \gdef^^b1{$\pm$} - \gdef^^b2{$^2$} - \gdef^^b3{$^3$} - \gdef^^b4{\'{}} - \gdef^^b5{$\mu$} - \gdef^^b6{\P} - % - \gdef^^b7{$^.$} - \gdef^^b8{\cedilla\ } - \gdef^^b9{$^1$} - \gdef^^ba{\ordm} - % - \gdef^^bb{\guillemetright} - \gdef^^bc{$1\over4$} - \gdef^^bd{$1\over2$} - \gdef^^be{$3\over4$} - \gdef^^bf{\questiondown} - % - \gdef^^c0{\`A} - \gdef^^c1{\'A} - \gdef^^c2{\^A} - \gdef^^c3{\~A} - \gdef^^c4{\"A} - \gdef^^c5{\ringaccent A} - \gdef^^c6{\AE} - \gdef^^c7{\cedilla C} - \gdef^^c8{\`E} - \gdef^^c9{\'E} - \gdef^^ca{\^E} - \gdef^^cb{\"E} - \gdef^^cc{\`I} - \gdef^^cd{\'I} - \gdef^^ce{\^I} - \gdef^^cf{\"I} - % - \gdef^^d0{\DH} - \gdef^^d1{\~N} - \gdef^^d2{\`O} - \gdef^^d3{\'O} - \gdef^^d4{\^O} - \gdef^^d5{\~O} - \gdef^^d6{\"O} - \gdef^^d7{$\times$} - \gdef^^d8{\O} - \gdef^^d9{\`U} - \gdef^^da{\'U} - \gdef^^db{\^U} - \gdef^^dc{\"U} - \gdef^^dd{\'Y} - \gdef^^de{\TH} - \gdef^^df{\ss} - % - \gdef^^e0{\`a} - \gdef^^e1{\'a} - \gdef^^e2{\^a} - \gdef^^e3{\~a} - \gdef^^e4{\"a} - \gdef^^e5{\ringaccent a} - \gdef^^e6{\ae} - \gdef^^e7{\cedilla c} - \gdef^^e8{\`e} - \gdef^^e9{\'e} - \gdef^^ea{\^e} - \gdef^^eb{\"e} - \gdef^^ec{\`{\dotless i}} - \gdef^^ed{\'{\dotless i}} - \gdef^^ee{\^{\dotless i}} - \gdef^^ef{\"{\dotless i}} - % - \gdef^^f0{\dh} - \gdef^^f1{\~n} - \gdef^^f2{\`o} - \gdef^^f3{\'o} - \gdef^^f4{\^o} - \gdef^^f5{\~o} - \gdef^^f6{\"o} - \gdef^^f7{$\div$} - \gdef^^f8{\o} - \gdef^^f9{\`u} - \gdef^^fa{\'u} - \gdef^^fb{\^u} - \gdef^^fc{\"u} - \gdef^^fd{\'y} - \gdef^^fe{\th} - \gdef^^ff{\"y} -} - -% Latin9 (ISO-8859-15) encoding character definitions. -\def\latninechardefs{% - % Encoding is almost identical to Latin1. - \latonechardefs - % - \gdef^^a4{\euro} - \gdef^^a6{\v S} - \gdef^^a8{\v s} - \gdef^^b4{\v Z} - \gdef^^b8{\v z} - \gdef^^bc{\OE} - \gdef^^bd{\oe} - \gdef^^be{\"Y} -} - -% Latin2 (ISO-8859-2) character definitions. -\def\lattwochardefs{% - \gdef^^a0{\tie} - \gdef^^a1{\ogonek{A}} - \gdef^^a2{\u{}} - \gdef^^a3{\L} - \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} - \gdef^^a5{\v L} - \gdef^^a6{\'S} - \gdef^^a7{\S} - \gdef^^a8{\"{}} - \gdef^^a9{\v S} - \gdef^^aa{\cedilla S} - \gdef^^ab{\v T} - \gdef^^ac{\'Z} - \gdef^^ad{\-} - \gdef^^ae{\v Z} - \gdef^^af{\dotaccent Z} - % - \gdef^^b0{\textdegree} - \gdef^^b1{\ogonek{a}} - \gdef^^b2{\ogonek{ }} - \gdef^^b3{\l} - \gdef^^b4{\'{}} - \gdef^^b5{\v l} - \gdef^^b6{\'s} - \gdef^^b7{\v{}} - \gdef^^b8{\cedilla\ } - \gdef^^b9{\v s} - \gdef^^ba{\cedilla s} - \gdef^^bb{\v t} - \gdef^^bc{\'z} - \gdef^^bd{\H{}} - \gdef^^be{\v z} - \gdef^^bf{\dotaccent z} - % - \gdef^^c0{\'R} - \gdef^^c1{\'A} - \gdef^^c2{\^A} - \gdef^^c3{\u A} - \gdef^^c4{\"A} - \gdef^^c5{\'L} - \gdef^^c6{\'C} - \gdef^^c7{\cedilla C} - \gdef^^c8{\v C} - \gdef^^c9{\'E} - \gdef^^ca{\ogonek{E}} - \gdef^^cb{\"E} - \gdef^^cc{\v E} - \gdef^^cd{\'I} - \gdef^^ce{\^I} - \gdef^^cf{\v D} - % - \gdef^^d0{\DH} - \gdef^^d1{\'N} - \gdef^^d2{\v N} - \gdef^^d3{\'O} - \gdef^^d4{\^O} - \gdef^^d5{\H O} - \gdef^^d6{\"O} - \gdef^^d7{$\times$} - \gdef^^d8{\v R} - \gdef^^d9{\ringaccent U} - \gdef^^da{\'U} - \gdef^^db{\H U} - \gdef^^dc{\"U} - \gdef^^dd{\'Y} - \gdef^^de{\cedilla T} - \gdef^^df{\ss} - % - \gdef^^e0{\'r} - \gdef^^e1{\'a} - \gdef^^e2{\^a} - \gdef^^e3{\u a} - \gdef^^e4{\"a} - \gdef^^e5{\'l} - \gdef^^e6{\'c} - \gdef^^e7{\cedilla c} - \gdef^^e8{\v c} - \gdef^^e9{\'e} - \gdef^^ea{\ogonek{e}} - \gdef^^eb{\"e} - \gdef^^ec{\v e} - \gdef^^ed{\'{\dotless{i}}} - \gdef^^ee{\^{\dotless{i}}} - \gdef^^ef{\v d} - % - \gdef^^f0{\dh} - \gdef^^f1{\'n} - \gdef^^f2{\v n} - \gdef^^f3{\'o} - \gdef^^f4{\^o} - \gdef^^f5{\H o} - \gdef^^f6{\"o} - \gdef^^f7{$\div$} - \gdef^^f8{\v r} - \gdef^^f9{\ringaccent u} - \gdef^^fa{\'u} - \gdef^^fb{\H u} - \gdef^^fc{\"u} - \gdef^^fd{\'y} - \gdef^^fe{\cedilla t} - \gdef^^ff{\dotaccent{}} -} - -% UTF-8 character definitions. -% -% This code to support UTF-8 is based on LaTeX's utf8.def, with some -% changes for Texinfo conventions. It is included here under the GPL by -% permission from Frank Mittelbach and the LaTeX team. -% -\newcount\countUTFx -\newcount\countUTFy -\newcount\countUTFz - -\gdef\UTFviiiTwoOctets#1#2{\expandafter - \UTFviiiDefined\csname u8:#1\string #2\endcsname} -% -\gdef\UTFviiiThreeOctets#1#2#3{\expandafter - \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} -% -\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter - \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} - -\gdef\UTFviiiDefined#1{% - \ifx #1\relax - \message{\linenumber Unicode char \string #1 not defined for Texinfo}% - \else - \expandafter #1% - \fi -} - -\begingroup - \catcode`\~13 - \catcode`\"12 - - \def\UTFviiiLoop{% - \global\catcode\countUTFx\active - \uccode`\~\countUTFx - \uppercase\expandafter{\UTFviiiTmp}% - \advance\countUTFx by 1 - \ifnum\countUTFx < \countUTFy - \expandafter\UTFviiiLoop - \fi} - - \countUTFx = "C2 - \countUTFy = "E0 - \def\UTFviiiTmp{% - \xdef~{\noexpand\UTFviiiTwoOctets\string~}} - \UTFviiiLoop - - \countUTFx = "E0 - \countUTFy = "F0 - \def\UTFviiiTmp{% - \xdef~{\noexpand\UTFviiiThreeOctets\string~}} - \UTFviiiLoop - - \countUTFx = "F0 - \countUTFy = "F4 - \def\UTFviiiTmp{% - \xdef~{\noexpand\UTFviiiFourOctets\string~}} - \UTFviiiLoop -\endgroup - -\begingroup - \catcode`\"=12 - \catcode`\<=12 - \catcode`\.=12 - \catcode`\,=12 - \catcode`\;=12 - \catcode`\!=12 - \catcode`\~=13 - - \gdef\DeclareUnicodeCharacter#1#2{% - \countUTFz = "#1\relax - %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% - \begingroup - \parseXMLCharref - \def\UTFviiiTwoOctets##1##2{% - \csname u8:##1\string ##2\endcsname}% - \def\UTFviiiThreeOctets##1##2##3{% - \csname u8:##1\string ##2\string ##3\endcsname}% - \def\UTFviiiFourOctets##1##2##3##4{% - \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% - \expandafter\expandafter\expandafter\expandafter - \expandafter\expandafter\expandafter - \gdef\UTFviiiTmp{#2}% - \endgroup} - - \gdef\parseXMLCharref{% - \ifnum\countUTFz < "A0\relax - \errhelp = \EMsimple - \errmessage{Cannot define Unicode char value < 00A0}% - \else\ifnum\countUTFz < "800\relax - \parseUTFviiiA,% - \parseUTFviiiB C\UTFviiiTwoOctets.,% - \else\ifnum\countUTFz < "10000\relax - \parseUTFviiiA;% - \parseUTFviiiA,% - \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% - \else - \parseUTFviiiA;% - \parseUTFviiiA,% - \parseUTFviiiA!% - \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% - \fi\fi\fi - } - - \gdef\parseUTFviiiA#1{% - \countUTFx = \countUTFz - \divide\countUTFz by 64 - \countUTFy = \countUTFz - \multiply\countUTFz by 64 - \advance\countUTFx by -\countUTFz - \advance\countUTFx by 128 - \uccode `#1\countUTFx - \countUTFz = \countUTFy} - - \gdef\parseUTFviiiB#1#2#3#4{% - \advance\countUTFz by "#10\relax - \uccode `#3\countUTFz - \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} -\endgroup - -\def\utfeightchardefs{% - \DeclareUnicodeCharacter{00A0}{\tie} - \DeclareUnicodeCharacter{00A1}{\exclamdown} - \DeclareUnicodeCharacter{00A3}{\pounds} - \DeclareUnicodeCharacter{00A8}{\"{ }} - \DeclareUnicodeCharacter{00A9}{\copyright} - \DeclareUnicodeCharacter{00AA}{\ordf} - \DeclareUnicodeCharacter{00AB}{\guillemetleft} - \DeclareUnicodeCharacter{00AD}{\-} - \DeclareUnicodeCharacter{00AE}{\registeredsymbol} - \DeclareUnicodeCharacter{00AF}{\={ }} - - \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} - \DeclareUnicodeCharacter{00B4}{\'{ }} - \DeclareUnicodeCharacter{00B8}{\cedilla{ }} - \DeclareUnicodeCharacter{00BA}{\ordm} - \DeclareUnicodeCharacter{00BB}{\guillemetright} - \DeclareUnicodeCharacter{00BF}{\questiondown} - - \DeclareUnicodeCharacter{00C0}{\`A} - \DeclareUnicodeCharacter{00C1}{\'A} - \DeclareUnicodeCharacter{00C2}{\^A} - \DeclareUnicodeCharacter{00C3}{\~A} - \DeclareUnicodeCharacter{00C4}{\"A} - \DeclareUnicodeCharacter{00C5}{\AA} - \DeclareUnicodeCharacter{00C6}{\AE} - \DeclareUnicodeCharacter{00C7}{\cedilla{C}} - \DeclareUnicodeCharacter{00C8}{\`E} - \DeclareUnicodeCharacter{00C9}{\'E} - \DeclareUnicodeCharacter{00CA}{\^E} - \DeclareUnicodeCharacter{00CB}{\"E} - \DeclareUnicodeCharacter{00CC}{\`I} - \DeclareUnicodeCharacter{00CD}{\'I} - \DeclareUnicodeCharacter{00CE}{\^I} - \DeclareUnicodeCharacter{00CF}{\"I} - - \DeclareUnicodeCharacter{00D0}{\DH} - \DeclareUnicodeCharacter{00D1}{\~N} - \DeclareUnicodeCharacter{00D2}{\`O} - \DeclareUnicodeCharacter{00D3}{\'O} - \DeclareUnicodeCharacter{00D4}{\^O} - \DeclareUnicodeCharacter{00D5}{\~O} - \DeclareUnicodeCharacter{00D6}{\"O} - \DeclareUnicodeCharacter{00D8}{\O} - \DeclareUnicodeCharacter{00D9}{\`U} - \DeclareUnicodeCharacter{00DA}{\'U} - \DeclareUnicodeCharacter{00DB}{\^U} - \DeclareUnicodeCharacter{00DC}{\"U} - \DeclareUnicodeCharacter{00DD}{\'Y} - \DeclareUnicodeCharacter{00DE}{\TH} - \DeclareUnicodeCharacter{00DF}{\ss} - - \DeclareUnicodeCharacter{00E0}{\`a} - \DeclareUnicodeCharacter{00E1}{\'a} - \DeclareUnicodeCharacter{00E2}{\^a} - \DeclareUnicodeCharacter{00E3}{\~a} - \DeclareUnicodeCharacter{00E4}{\"a} - \DeclareUnicodeCharacter{00E5}{\aa} - \DeclareUnicodeCharacter{00E6}{\ae} - \DeclareUnicodeCharacter{00E7}{\cedilla{c}} - \DeclareUnicodeCharacter{00E8}{\`e} - \DeclareUnicodeCharacter{00E9}{\'e} - \DeclareUnicodeCharacter{00EA}{\^e} - \DeclareUnicodeCharacter{00EB}{\"e} - \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} - \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} - \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} - \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} - - \DeclareUnicodeCharacter{00F0}{\dh} - \DeclareUnicodeCharacter{00F1}{\~n} - \DeclareUnicodeCharacter{00F2}{\`o} - \DeclareUnicodeCharacter{00F3}{\'o} - \DeclareUnicodeCharacter{00F4}{\^o} - \DeclareUnicodeCharacter{00F5}{\~o} - \DeclareUnicodeCharacter{00F6}{\"o} - \DeclareUnicodeCharacter{00F8}{\o} - \DeclareUnicodeCharacter{00F9}{\`u} - \DeclareUnicodeCharacter{00FA}{\'u} - \DeclareUnicodeCharacter{00FB}{\^u} - \DeclareUnicodeCharacter{00FC}{\"u} - \DeclareUnicodeCharacter{00FD}{\'y} - \DeclareUnicodeCharacter{00FE}{\th} - \DeclareUnicodeCharacter{00FF}{\"y} - - \DeclareUnicodeCharacter{0100}{\=A} - \DeclareUnicodeCharacter{0101}{\=a} - \DeclareUnicodeCharacter{0102}{\u{A}} - \DeclareUnicodeCharacter{0103}{\u{a}} - \DeclareUnicodeCharacter{0104}{\ogonek{A}} - \DeclareUnicodeCharacter{0105}{\ogonek{a}} - \DeclareUnicodeCharacter{0106}{\'C} - \DeclareUnicodeCharacter{0107}{\'c} - \DeclareUnicodeCharacter{0108}{\^C} - \DeclareUnicodeCharacter{0109}{\^c} - \DeclareUnicodeCharacter{0118}{\ogonek{E}} - \DeclareUnicodeCharacter{0119}{\ogonek{e}} - \DeclareUnicodeCharacter{010A}{\dotaccent{C}} - \DeclareUnicodeCharacter{010B}{\dotaccent{c}} - \DeclareUnicodeCharacter{010C}{\v{C}} - \DeclareUnicodeCharacter{010D}{\v{c}} - \DeclareUnicodeCharacter{010E}{\v{D}} - - \DeclareUnicodeCharacter{0112}{\=E} - \DeclareUnicodeCharacter{0113}{\=e} - \DeclareUnicodeCharacter{0114}{\u{E}} - \DeclareUnicodeCharacter{0115}{\u{e}} - \DeclareUnicodeCharacter{0116}{\dotaccent{E}} - \DeclareUnicodeCharacter{0117}{\dotaccent{e}} - \DeclareUnicodeCharacter{011A}{\v{E}} - \DeclareUnicodeCharacter{011B}{\v{e}} - \DeclareUnicodeCharacter{011C}{\^G} - \DeclareUnicodeCharacter{011D}{\^g} - \DeclareUnicodeCharacter{011E}{\u{G}} - \DeclareUnicodeCharacter{011F}{\u{g}} - - \DeclareUnicodeCharacter{0120}{\dotaccent{G}} - \DeclareUnicodeCharacter{0121}{\dotaccent{g}} - \DeclareUnicodeCharacter{0124}{\^H} - \DeclareUnicodeCharacter{0125}{\^h} - \DeclareUnicodeCharacter{0128}{\~I} - \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} - \DeclareUnicodeCharacter{012A}{\=I} - \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} - \DeclareUnicodeCharacter{012C}{\u{I}} - \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} - - \DeclareUnicodeCharacter{0130}{\dotaccent{I}} - \DeclareUnicodeCharacter{0131}{\dotless{i}} - \DeclareUnicodeCharacter{0132}{IJ} - \DeclareUnicodeCharacter{0133}{ij} - \DeclareUnicodeCharacter{0134}{\^J} - \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} - \DeclareUnicodeCharacter{0139}{\'L} - \DeclareUnicodeCharacter{013A}{\'l} - - \DeclareUnicodeCharacter{0141}{\L} - \DeclareUnicodeCharacter{0142}{\l} - \DeclareUnicodeCharacter{0143}{\'N} - \DeclareUnicodeCharacter{0144}{\'n} - \DeclareUnicodeCharacter{0147}{\v{N}} - \DeclareUnicodeCharacter{0148}{\v{n}} - \DeclareUnicodeCharacter{014C}{\=O} - \DeclareUnicodeCharacter{014D}{\=o} - \DeclareUnicodeCharacter{014E}{\u{O}} - \DeclareUnicodeCharacter{014F}{\u{o}} - - \DeclareUnicodeCharacter{0150}{\H{O}} - \DeclareUnicodeCharacter{0151}{\H{o}} - \DeclareUnicodeCharacter{0152}{\OE} - \DeclareUnicodeCharacter{0153}{\oe} - \DeclareUnicodeCharacter{0154}{\'R} - \DeclareUnicodeCharacter{0155}{\'r} - \DeclareUnicodeCharacter{0158}{\v{R}} - \DeclareUnicodeCharacter{0159}{\v{r}} - \DeclareUnicodeCharacter{015A}{\'S} - \DeclareUnicodeCharacter{015B}{\'s} - \DeclareUnicodeCharacter{015C}{\^S} - \DeclareUnicodeCharacter{015D}{\^s} - \DeclareUnicodeCharacter{015E}{\cedilla{S}} - \DeclareUnicodeCharacter{015F}{\cedilla{s}} - - \DeclareUnicodeCharacter{0160}{\v{S}} - \DeclareUnicodeCharacter{0161}{\v{s}} - \DeclareUnicodeCharacter{0162}{\cedilla{t}} - \DeclareUnicodeCharacter{0163}{\cedilla{T}} - \DeclareUnicodeCharacter{0164}{\v{T}} - - \DeclareUnicodeCharacter{0168}{\~U} - \DeclareUnicodeCharacter{0169}{\~u} - \DeclareUnicodeCharacter{016A}{\=U} - \DeclareUnicodeCharacter{016B}{\=u} - \DeclareUnicodeCharacter{016C}{\u{U}} - \DeclareUnicodeCharacter{016D}{\u{u}} - \DeclareUnicodeCharacter{016E}{\ringaccent{U}} - \DeclareUnicodeCharacter{016F}{\ringaccent{u}} - - \DeclareUnicodeCharacter{0170}{\H{U}} - \DeclareUnicodeCharacter{0171}{\H{u}} - \DeclareUnicodeCharacter{0174}{\^W} - \DeclareUnicodeCharacter{0175}{\^w} - \DeclareUnicodeCharacter{0176}{\^Y} - \DeclareUnicodeCharacter{0177}{\^y} - \DeclareUnicodeCharacter{0178}{\"Y} - \DeclareUnicodeCharacter{0179}{\'Z} - \DeclareUnicodeCharacter{017A}{\'z} - \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} - \DeclareUnicodeCharacter{017C}{\dotaccent{z}} - \DeclareUnicodeCharacter{017D}{\v{Z}} - \DeclareUnicodeCharacter{017E}{\v{z}} - - \DeclareUnicodeCharacter{01C4}{D\v{Z}} - \DeclareUnicodeCharacter{01C5}{D\v{z}} - \DeclareUnicodeCharacter{01C6}{d\v{z}} - \DeclareUnicodeCharacter{01C7}{LJ} - \DeclareUnicodeCharacter{01C8}{Lj} - \DeclareUnicodeCharacter{01C9}{lj} - \DeclareUnicodeCharacter{01CA}{NJ} - \DeclareUnicodeCharacter{01CB}{Nj} - \DeclareUnicodeCharacter{01CC}{nj} - \DeclareUnicodeCharacter{01CD}{\v{A}} - \DeclareUnicodeCharacter{01CE}{\v{a}} - \DeclareUnicodeCharacter{01CF}{\v{I}} - - \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} - \DeclareUnicodeCharacter{01D1}{\v{O}} - \DeclareUnicodeCharacter{01D2}{\v{o}} - \DeclareUnicodeCharacter{01D3}{\v{U}} - \DeclareUnicodeCharacter{01D4}{\v{u}} - - \DeclareUnicodeCharacter{01E2}{\={\AE}} - \DeclareUnicodeCharacter{01E3}{\={\ae}} - \DeclareUnicodeCharacter{01E6}{\v{G}} - \DeclareUnicodeCharacter{01E7}{\v{g}} - \DeclareUnicodeCharacter{01E8}{\v{K}} - \DeclareUnicodeCharacter{01E9}{\v{k}} - - \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} - \DeclareUnicodeCharacter{01F1}{DZ} - \DeclareUnicodeCharacter{01F2}{Dz} - \DeclareUnicodeCharacter{01F3}{dz} - \DeclareUnicodeCharacter{01F4}{\'G} - \DeclareUnicodeCharacter{01F5}{\'g} - \DeclareUnicodeCharacter{01F8}{\`N} - \DeclareUnicodeCharacter{01F9}{\`n} - \DeclareUnicodeCharacter{01FC}{\'{\AE}} - \DeclareUnicodeCharacter{01FD}{\'{\ae}} - \DeclareUnicodeCharacter{01FE}{\'{\O}} - \DeclareUnicodeCharacter{01FF}{\'{\o}} - - \DeclareUnicodeCharacter{021E}{\v{H}} - \DeclareUnicodeCharacter{021F}{\v{h}} - - \DeclareUnicodeCharacter{0226}{\dotaccent{A}} - \DeclareUnicodeCharacter{0227}{\dotaccent{a}} - \DeclareUnicodeCharacter{0228}{\cedilla{E}} - \DeclareUnicodeCharacter{0229}{\cedilla{e}} - \DeclareUnicodeCharacter{022E}{\dotaccent{O}} - \DeclareUnicodeCharacter{022F}{\dotaccent{o}} - - \DeclareUnicodeCharacter{0232}{\=Y} - \DeclareUnicodeCharacter{0233}{\=y} - \DeclareUnicodeCharacter{0237}{\dotless{j}} - - \DeclareUnicodeCharacter{02DB}{\ogonek{ }} - - \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} - \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} - \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} - \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} - \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} - \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} - \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} - \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} - \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} - \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} - \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} - \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} - - \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} - \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} - - \DeclareUnicodeCharacter{1E20}{\=G} - \DeclareUnicodeCharacter{1E21}{\=g} - \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} - \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} - \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} - \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} - \DeclareUnicodeCharacter{1E26}{\"H} - \DeclareUnicodeCharacter{1E27}{\"h} - - \DeclareUnicodeCharacter{1E30}{\'K} - \DeclareUnicodeCharacter{1E31}{\'k} - \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} - \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} - \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} - \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} - \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} - \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} - \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} - \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} - \DeclareUnicodeCharacter{1E3E}{\'M} - \DeclareUnicodeCharacter{1E3F}{\'m} - - \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} - \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} - \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} - \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} - \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} - \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} - \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} - \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} - \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} - \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} - - \DeclareUnicodeCharacter{1E54}{\'P} - \DeclareUnicodeCharacter{1E55}{\'p} - \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} - \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} - \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} - \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} - \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} - \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} - \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} - \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} - - \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} - \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} - \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} - \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} - \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} - \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} - \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} - \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} - \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} - \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} - - \DeclareUnicodeCharacter{1E7C}{\~V} - \DeclareUnicodeCharacter{1E7D}{\~v} - \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} - \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} - - \DeclareUnicodeCharacter{1E80}{\`W} - \DeclareUnicodeCharacter{1E81}{\`w} - \DeclareUnicodeCharacter{1E82}{\'W} - \DeclareUnicodeCharacter{1E83}{\'w} - \DeclareUnicodeCharacter{1E84}{\"W} - \DeclareUnicodeCharacter{1E85}{\"w} - \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} - \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} - \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} - \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} - \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} - \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} - \DeclareUnicodeCharacter{1E8C}{\"X} - \DeclareUnicodeCharacter{1E8D}{\"x} - \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} - \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} - - \DeclareUnicodeCharacter{1E90}{\^Z} - \DeclareUnicodeCharacter{1E91}{\^z} - \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} - \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} - \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} - \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} - \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} - \DeclareUnicodeCharacter{1E97}{\"t} - \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} - \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} - - \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} - \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} - - \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} - \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} - \DeclareUnicodeCharacter{1EBC}{\~E} - \DeclareUnicodeCharacter{1EBD}{\~e} - - \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} - \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} - \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} - \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} - - \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} - \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} - - \DeclareUnicodeCharacter{1EF2}{\`Y} - \DeclareUnicodeCharacter{1EF3}{\`y} - \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} - - \DeclareUnicodeCharacter{1EF8}{\~Y} - \DeclareUnicodeCharacter{1EF9}{\~y} - - \DeclareUnicodeCharacter{2013}{--} - \DeclareUnicodeCharacter{2014}{---} - \DeclareUnicodeCharacter{2018}{\quoteleft} - \DeclareUnicodeCharacter{2019}{\quoteright} - \DeclareUnicodeCharacter{201A}{\quotesinglbase} - \DeclareUnicodeCharacter{201C}{\quotedblleft} - \DeclareUnicodeCharacter{201D}{\quotedblright} - \DeclareUnicodeCharacter{201E}{\quotedblbase} - \DeclareUnicodeCharacter{2022}{\bullet} - \DeclareUnicodeCharacter{2026}{\dots} - \DeclareUnicodeCharacter{2039}{\guilsinglleft} - \DeclareUnicodeCharacter{203A}{\guilsinglright} - \DeclareUnicodeCharacter{20AC}{\euro} - - \DeclareUnicodeCharacter{2192}{\expansion} - \DeclareUnicodeCharacter{21D2}{\result} - - \DeclareUnicodeCharacter{2212}{\minus} - \DeclareUnicodeCharacter{2217}{\point} - \DeclareUnicodeCharacter{2261}{\equiv} -}% end of \utfeightchardefs - - -% US-ASCII character definitions. -\def\asciichardefs{% nothing need be done - \relax -} - -% Make non-ASCII characters printable again for compatibility with -% existing Texinfo documents that may use them, even without declaring a -% document encoding. -% -\setnonasciicharscatcode \other - - -\message{formatting,} - -\newdimen\defaultparindent \defaultparindent = 15pt - -\chapheadingskip = 15pt plus 4pt minus 2pt -\secheadingskip = 12pt plus 3pt minus 2pt -\subsecheadingskip = 9pt plus 2pt minus 2pt - -% Prevent underfull vbox error messages. -\vbadness = 10000 - -% Don't be very finicky about underfull hboxes, either. -\hbadness = 6666 - -% Following George Bush, get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. We call this whenever the paper size is set. -% -\def\setemergencystretch{% - \ifx\emergencystretch\thisisundefined - % Allow us to assign to \emergencystretch anyway. - \def\emergencystretch{\dimen0}% - \else - \emergencystretch = .15\hsize - \fi -} - -% Parameters in order: 1) textheight; 2) textwidth; -% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; -% 7) physical page height; 8) physical page width. -% -% We also call \setleading{\textleading}, so the caller should define -% \textleading. The caller should also set \parskip. -% -\def\internalpagesizes#1#2#3#4#5#6#7#8{% - \voffset = #3\relax - \topskip = #6\relax - \splittopskip = \topskip - % - \vsize = #1\relax - \advance\vsize by \topskip - \outervsize = \vsize - \advance\outervsize by 2\topandbottommargin - \pageheight = \vsize - % - \hsize = #2\relax - \outerhsize = \hsize - \advance\outerhsize by 0.5in - \pagewidth = \hsize - % - \normaloffset = #4\relax - \bindingoffset = #5\relax - % - \ifpdf - \pdfpageheight #7\relax - \pdfpagewidth #8\relax - % if we don't reset these, they will remain at "1 true in" of - % whatever layout pdftex was dumped with. - \pdfhorigin = 1 true in - \pdfvorigin = 1 true in - \fi - % - \setleading{\textleading} - % - \parindent = \defaultparindent - \setemergencystretch -} - -% @letterpaper (the default). -\def\letterpaper{{\globaldefs = 1 - \parskip = 3pt plus 2pt minus 1pt - \textleading = 13.2pt - % - % If page is nothing but text, make it come out even. - \internalpagesizes{607.2pt}{6in}% that's 46 lines - {\voffset}{.25in}% - {\bindingoffset}{36pt}% - {11in}{8.5in}% -}} - -% Use @smallbook to reset parameters for 7x9.25 trim size. -\def\smallbook{{\globaldefs = 1 - \parskip = 2pt plus 1pt - \textleading = 12pt - % - \internalpagesizes{7.5in}{5in}% - {-.2in}{0in}% - {\bindingoffset}{16pt}% - {9.25in}{7in}% - % - \lispnarrowing = 0.3in - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \defbodyindent = .5cm -}} - -% Use @smallerbook to reset parameters for 6x9 trim size. -% (Just testing, parameters still in flux.) -\def\smallerbook{{\globaldefs = 1 - \parskip = 1.5pt plus 1pt - \textleading = 12pt - % - \internalpagesizes{7.4in}{4.8in}% - {-.2in}{-.4in}% - {0pt}{14pt}% - {9in}{6in}% - % - \lispnarrowing = 0.25in - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \defbodyindent = .4cm -}} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{{\globaldefs = 1 - \parskip = 3pt plus 2pt minus 1pt - \textleading = 13.2pt - % - % Double-side printing via postscript on Laserjet 4050 - % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. - % To change the settings for a different printer or situation, adjust - % \normaloffset until the front-side and back-side texts align. Then - % do the same for \bindingoffset. You can set these for testing in - % your texinfo source file like this: - % @tex - % \global\normaloffset = -6mm - % \global\bindingoffset = 10mm - % @end tex - \internalpagesizes{673.2pt}{160mm}% that's 51 lines - {\voffset}{\hoffset}% - {\bindingoffset}{44pt}% - {297mm}{210mm}% - % - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \defbodyindent = 5mm -}} - -% Use @afivepaper to print on European A5 paper. -% From romildo@urano.iceb.ufop.br, 2 July 2000. -% He also recommends making @example and @lisp be small. -\def\afivepaper{{\globaldefs = 1 - \parskip = 2pt plus 1pt minus 0.1pt - \textleading = 12.5pt - % - \internalpagesizes{160mm}{120mm}% - {\voffset}{\hoffset}% - {\bindingoffset}{8pt}% - {210mm}{148mm}% - % - \lispnarrowing = 0.2in - \tolerance = 800 - \hfuzz = 1.2pt - \contentsrightmargin = 0pt - \defbodyindent = 2mm - \tableindent = 12mm -}} - -% A specific text layout, 24x15cm overall, intended for A4 paper. -\def\afourlatex{{\globaldefs = 1 - \afourpaper - \internalpagesizes{237mm}{150mm}% - {\voffset}{4.6mm}% - {\bindingoffset}{7mm}% - {297mm}{210mm}% - % - % Must explicitly reset to 0 because we call \afourpaper. - \globaldefs = 0 -}} - -% Use @afourwide to print on A4 paper in landscape format. -\def\afourwide{{\globaldefs = 1 - \afourpaper - \internalpagesizes{241mm}{165mm}% - {\voffset}{-2.95mm}% - {\bindingoffset}{7mm}% - {297mm}{210mm}% - \globaldefs = 0 -}} - -% @pagesizes TEXTHEIGHT[,TEXTWIDTH] -% Perhaps we should allow setting the margins, \topskip, \parskip, -% and/or leading, also. Or perhaps we should compute them somehow. -% -\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} -\def\pagesizesyyy#1,#2,#3\finish{{% - \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi - \globaldefs = 1 - % - \parskip = 3pt plus 2pt minus 1pt - \setleading{\textleading}% - % - \dimen0 = #1\relax - \advance\dimen0 by \voffset - % - \dimen2 = \hsize - \advance\dimen2 by \normaloffset - % - \internalpagesizes{#1}{\hsize}% - {\voffset}{\normaloffset}% - {\bindingoffset}{44pt}% - {\dimen0}{\dimen2}% -}} - -% Set default to letter. -% -\letterpaper - - -\message{and turning on texinfo input format.} - -\def^^L{\par} % remove \outer, so ^L can appear in an @comment - -% DEL is a comment character, in case @c does not suffice. -\catcode`\^^? = 14 - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other \def\normaldoublequote{"} -\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix -\catcode`\+=\other \def\normalplus{+} -\catcode`\<=\other \def\normalless{<} -\catcode`\>=\other \def\normalgreater{>} -\catcode`\^=\other \def\normalcaret{^} -\catcode`\_=\other \def\normalunderscore{_} -\catcode`\|=\other \def\normalverticalbar{|} -\catcode`\~=\other \def\normaltilde{~} - -% This macro is used to make a character print one way in \tt -% (where it can probably be output as-is), and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} - -% Same as above, but check for italic font. Actually this also catches -% non-italic slanted fonts since it is impossible to distinguish them from -% italic fonts. But since this is only used by $ and it uses \sl anyway -% this is not a problem. -\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt\char34}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt\char126}} -\chardef\hat=`\^ -\catcode`\^=\active -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -\let\realunder=_ -% Subroutine for the previous macro. -\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } - -\catcode`\|=\active -\def|{{\tt\char124}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -\catcode`\$=\active -\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix - -% If a .fmt file is being used, characters that might appear in a file -% name cannot be active until we have parsed the command line. -% So turn them off again, and have \everyjob (or @setfilename) turn them on. -% \otherifyactive is called near the end of this file. -\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} - -% Used sometimes to turn off (effectively) the active characters even after -% parsing them. -\def\turnoffactive{% - \normalturnoffactive - \otherbackslash -} - -\catcode`\@=0 - -% \backslashcurfont outputs one backslash character in current font, -% as in \char`\\. -\global\chardef\backslashcurfont=`\\ -\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work - -% \realbackslash is an actual character `\' with catcode other, and -% \doublebackslash is two of them (for the pdf outlines). -{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} - -% In texinfo, backslash is an active character; it prints the backslash -% in fixed width font. -\catcode`\\=\active % @ for escape char from now on. - -% The story here is that in math mode, the \char of \backslashcurfont -% ends up printing the roman \ from the math symbol font (because \char -% in math mode uses the \mathcode, and plain.tex sets -% \mathcode`\\="026E). It seems better for @backslashchar{} to always -% print a typewriter backslash, hence we use an explicit \mathchar, -% which is the decimal equivalent of "715c (class 7, e.g., use \fam; -% ignored family value; char position "5C). We can't use " for the -% usual hex value because it has already been made active. -@def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} -@let@backslashchar = @normalbackslash % @backslashchar{} is for user documents. - -% On startup, @fixbackslash assigns: -% @let \ = @normalbackslash -% \rawbackslash defines an active \ to do \backslashcurfont. -% \otherbackslash defines an active \ to be a literal `\' character with -% catcode other. We switch back and forth between these. -@gdef@rawbackslash{@let\=@backslashcurfont} -@gdef@otherbackslash{@let\=@realbackslash} - -% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of -% the literal character `\'. Also revert - to its normal character, in -% case the active - from code has slipped in. -% -{@catcode`- = @active - @gdef@normalturnoffactive{% - @let-=@normaldash - @let"=@normaldoublequote - @let$=@normaldollar %$ font-lock fix - @let+=@normalplus - @let<=@normalless - @let>=@normalgreater - @let\=@normalbackslash - @let^=@normalcaret - @let_=@normalunderscore - @let|=@normalverticalbar - @let~=@normaltilde - @markupsetuplqdefault - @markupsetuprqdefault - @unsepspaces - } -} - -% Make _ and + \other characters, temporarily. -% This is canceled by @fixbackslash. -@otherifyactive - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\' in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% Also turn back on active characters that might appear in the input -% file name, in case not using a pre-dumped format. -% -@gdef@fixbackslash{% - @ifx\@eatinput @let\ = @normalbackslash @fi - @catcode`+=@active - @catcode`@_=@active -} - -% Say @foo, not \foo, in error messages. -@escapechar = `@@ - -% These (along with & and #) are made active for url-breaking, so need -% active definitions as the normal characters. -@def@normaldot{.} -@def@normalquest{?} -@def@normalslash{/} - -% These look ok in all fonts, so just make them not special. -% @hashchar{} gets its own user-level command, because of #line. -@catcode`@& = @other @def@normalamp{&} -@catcode`@# = @other @def@normalhash{#} -@catcode`@% = @other @def@normalpercent{%} - -@let @hashchar = @normalhash - -@c Finally, make ` and ' active, so that txicodequoteundirected and -@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we -@c don't make ` and ' active, @code will not get them as active chars. -@c Do this last of all since we use ` in the previous @catcode assignments. -@catcode`@'=@active -@catcode`@`=@active -@markupsetuplqdefault -@markupsetuprqdefault - -@c Local variables: -@c eval: (add-hook 'write-file-hooks 'time-stamp) -@c page-delimiter: "^\\\\message" -@c time-stamp-start: "def\\\\texinfoversion{" -@c time-stamp-format: "%:y-%02m-%02d.%02H" -@c time-stamp-end: "}" -@c End: - -@c vim:sw=2: - -@ignore - arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 -@end ignore diff --git a/user/mpy/lib/libm/acoshf.c b/user/mpy/lib/libm/acoshf.c deleted file mode 100644 index 8a8409f..0000000 --- a/user/mpy/lib/libm/acoshf.c +++ /dev/null @@ -1,32 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// acoshf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -#include "libm.h" - -#if FLT_EVAL_METHOD==2 -#undef sqrtf -#define sqrtf sqrtl -#elif FLT_EVAL_METHOD==1 -#undef sqrtf -#define sqrtf sqrt -#endif - -/* acosh(x) = log(x + sqrt(x*x-1)) */ -float acoshf(float x) -{ - union {float f; uint32_t i;} u = {x}; - uint32_t a = u.i & 0x7fffffff; - - if (a < 0x3f800000+(1<<23)) - /* |x| < 2, invalid if x < 1 or nan */ - /* up to 2ulp error in [1,1.125] */ - return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1))); - if (a < 0x3f800000+(12<<23)) - /* |x| < 0x1p12 */ - return logf(2*x - 1/(x+sqrtf(x*x-1))); - /* x >= 0x1p12 */ - return logf(x) + 0.693147180559945309417232121458176568f; -} diff --git a/user/mpy/lib/libm/asinfacosf.c b/user/mpy/lib/libm/asinfacosf.c deleted file mode 100644 index 07ecad3..0000000 --- a/user/mpy/lib/libm/asinfacosf.c +++ /dev/null @@ -1,130 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// asinf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/e_asinf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "libm.h" - -// dpgeorge: pio2 was double in original implementation of asinf -static const float -pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ -pio2_lo = 7.5497894159e-08; /* 0x33a22168 */ - -static const float -/* coefficients for R(x^2) */ -pS0 = 1.6666586697e-01, -pS1 = -4.2743422091e-02, -pS2 = -8.6563630030e-03, -qS1 = -7.0662963390e-01; - -static float R(float z) -{ - float_t p, q; - p = z*(pS0+z*(pS1+z*pS2)); - q = 1.0f+z*qS1; - return p/q; -} - -float asinf(float x) -{ - // dpgeorge: s was double in original implementation - float s,z; - uint32_t hx,ix; - - GET_FLOAT_WORD(hx, x); - ix = hx & 0x7fffffff; - if (ix >= 0x3f800000) { /* |x| >= 1 */ - if (ix == 0x3f800000) /* |x| == 1 */ - return x*pio2_hi + 0x1p-120f; /* asin(+-1) = +-pi/2 with inexact */ - return 0/(x-x); /* asin(|x|>1) is NaN */ - } - if (ix < 0x3f000000) { /* |x| < 0.5 */ - /* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */ - if (ix < 0x39800000 && ix >= 0x00800000) - return x; - return x + x*R(x*x); - } - /* 1 > |x| >= 0.5 */ - z = (1 - fabsf(x))*0.5f; - s = sqrtf(z); - x = pio2_hi - (2*(s+s*R(z)) - pio2_lo); // dpgeorge: use pio2_hi and pio2_lo - if (hx >> 31) - return -x; - return x; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// acosf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/e_acosf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -float acosf(float x) -{ - float z,w,s,c,df; - uint32_t hx,ix; - - GET_FLOAT_WORD(hx, x); - ix = hx & 0x7fffffff; - /* |x| >= 1 or nan */ - if (ix >= 0x3f800000) { - if (ix == 0x3f800000) { - if (hx >> 31) - return 2*pio2_hi + 0x1p-120f; - return 0; - } - return 0/(x-x); - } - /* |x| < 0.5 */ - if (ix < 0x3f000000) { - if (ix <= 0x32800000) /* |x| < 2**-26 */ - return pio2_hi + 0x1p-120f; - return pio2_hi - (x - (pio2_lo-x*R(x*x))); - } - /* x < -0.5 */ - if (hx >> 31) { - z = (1+x)*0.5f; - s = sqrtf(z); - w = R(z)*s-pio2_lo; - return 2*(pio2_hi - (s+w)); - } - /* x > 0.5 */ - z = (1-x)*0.5f; - s = sqrtf(z); - GET_FLOAT_WORD(hx,s); - SET_FLOAT_WORD(df,hx&0xfffff000); - c = (z-df*df)/(s+df); - w = R(z)*s+c; - return 2*(df+w); -} diff --git a/user/mpy/lib/libm/asinhf.c b/user/mpy/lib/libm/asinhf.c deleted file mode 100644 index 4bcb3f9..0000000 --- a/user/mpy/lib/libm/asinhf.c +++ /dev/null @@ -1,34 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// asinhf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -#include "libm.h" - -/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ -float asinhf(float x) -{ - union {float f; uint32_t i;} u = {.f = x}; - uint32_t i = u.i & 0x7fffffff; - unsigned s = u.i >> 31; - - /* |x| */ - u.i = i; - x = u.f; - - if (i >= 0x3f800000 + (12<<23)) { - /* |x| >= 0x1p12 or inf or nan */ - x = logf(x) + 0.693147180559945309417232121458176568f; - } else if (i >= 0x3f800000 + (1<<23)) { - /* |x| >= 2 */ - x = logf(2*x + 1/(sqrtf(x*x+1)+x)); - } else if (i >= 0x3f800000 - (12<<23)) { - /* |x| >= 0x1p-12, up to 1.6ulp error in [0.125,0.5] */ - x = log1pf(x + x*x/(sqrtf(x*x+1)+1)); - } else { - /* |x| < 0x1p-12, raise inexact if x!=0 */ - FORCE_EVAL(x + 0x1p120f); - } - return s ? -x : x; -} diff --git a/user/mpy/lib/libm/atan2f.c b/user/mpy/lib/libm/atan2f.c deleted file mode 100644 index 03d000c..0000000 --- a/user/mpy/lib/libm/atan2f.c +++ /dev/null @@ -1,89 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// atan2f from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2f.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "libm.h" - -static const float -pi = 3.1415927410e+00, /* 0x40490fdb */ -pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */ - -float atan2f(float y, float x) -{ - float z; - uint32_t m,ix,iy; - - if (isnan(x) || isnan(y)) - return x+y; - GET_FLOAT_WORD(ix, x); - GET_FLOAT_WORD(iy, y); - if (ix == 0x3f800000) /* x=1.0 */ - return atanf(y); - m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ - ix &= 0x7fffffff; - iy &= 0x7fffffff; - - /* when y = 0 */ - if (iy == 0) { - switch (m) { - case 0: - case 1: return y; /* atan(+-0,+anything)=+-0 */ - case 2: return pi; /* atan(+0,-anything) = pi */ - case 3: return -pi; /* atan(-0,-anything) =-pi */ - } - } - /* when x = 0 */ - if (ix == 0) - return m&1 ? -pi/2 : pi/2; - /* when x is INF */ - if (ix == 0x7f800000) { - if (iy == 0x7f800000) { - switch (m) { - case 0: return pi/4; /* atan(+INF,+INF) */ - case 1: return -pi/4; /* atan(-INF,+INF) */ - case 2: return 3*pi/4; /*atan(+INF,-INF)*/ - case 3: return -3*pi/4; /*atan(-INF,-INF)*/ - } - } else { - switch (m) { - case 0: return 0.0f; /* atan(+...,+INF) */ - case 1: return -0.0f; /* atan(-...,+INF) */ - case 2: return pi; /* atan(+...,-INF) */ - case 3: return -pi; /* atan(-...,-INF) */ - } - } - } - /* |y/x| > 0x1p26 */ - if (ix+(26<<23) < iy || iy == 0x7f800000) - return m&1 ? -pi/2 : pi/2; - - /* z = atan(|y/x|) with correct underflow */ - if ((m&2) && iy+(26<<23) < ix) /*|y/x| < 0x1p-26, x < 0 */ - z = 0.0; - else - z = atanf(fabsf(y/x)); - switch (m) { - case 0: return z; /* atan(+,+) */ - case 1: return -z; /* atan(-,+) */ - case 2: return pi - (z-pi_lo); /* atan(+,-) */ - default: /* case 3 */ - return (z-pi_lo) - pi; /* atan(-,-) */ - } -} diff --git a/user/mpy/lib/libm/atanf.c b/user/mpy/lib/libm/atanf.c deleted file mode 100644 index 053fc1b..0000000 --- a/user/mpy/lib/libm/atanf.c +++ /dev/null @@ -1,100 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// atanf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/s_atanf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - - -#include "libm.h" - -static const float atanhi[] = { - 4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */ - 7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */ - 9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */ - 1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */ -}; - -static const float atanlo[] = { - 5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */ - 3.7748947079e-08, /* atan(1.0)lo 0x33222168 */ - 3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */ - 7.5497894159e-08, /* atan(inf)lo 0x33a22168 */ -}; - -static const float aT[] = { - 3.3333328366e-01, - -1.9999158382e-01, - 1.4253635705e-01, - -1.0648017377e-01, - 6.1687607318e-02, -}; - -float atanf(float x) -{ - float_t w,s1,s2,z; - uint32_t ix,sign; - int id; - - GET_FLOAT_WORD(ix, x); - sign = ix>>31; - ix &= 0x7fffffff; - if (ix >= 0x4c800000) { /* if |x| >= 2**26 */ - if (isnan(x)) - return x; - z = atanhi[3] + 0x1p-120f; - return sign ? -z : z; - } - if (ix < 0x3ee00000) { /* |x| < 0.4375 */ - if (ix < 0x39800000) { /* |x| < 2**-12 */ - if (ix < 0x00800000) - /* raise underflow for subnormal x */ - FORCE_EVAL(x*x); - return x; - } - id = -1; - } else { - x = fabsf(x); - if (ix < 0x3f980000) { /* |x| < 1.1875 */ - if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */ - id = 0; - x = (2.0f*x - 1.0f)/(2.0f + x); - } else { /* 11/16 <= |x| < 19/16 */ - id = 1; - x = (x - 1.0f)/(x + 1.0f); - } - } else { - if (ix < 0x401c0000) { /* |x| < 2.4375 */ - id = 2; - x = (x - 1.5f)/(1.0f + 1.5f*x); - } else { /* 2.4375 <= |x| < 2**26 */ - id = 3; - x = -1.0f/x; - } - } - } - /* end of argument reduction */ - z = x*x; - w = z*z; - /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ - s1 = z*(aT[0]+w*(aT[2]+w*aT[4])); - s2 = w*(aT[1]+w*aT[3]); - if (id < 0) - return x - x*(s1+s2); - z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); - return sign ? -z : z; -} diff --git a/user/mpy/lib/libm/atanhf.c b/user/mpy/lib/libm/atanhf.c deleted file mode 100644 index 6f95f49..0000000 --- a/user/mpy/lib/libm/atanhf.c +++ /dev/null @@ -1,34 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// atanhf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -#include "libm.h" - -/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ -float atanhf(float x) -{ - union {float f; uint32_t i;} u = {.f = x}; - unsigned s = u.i >> 31; - float_t y; - - /* |x| */ - u.i &= 0x7fffffff; - y = u.f; - - if (u.i < 0x3f800000 - (1<<23)) { - if (u.i < 0x3f800000 - (32<<23)) { - /* handle underflow */ - if (u.i < (1<<23)) - FORCE_EVAL((float)(y*y)); - } else { - /* |x| < 0.5, up to 1.7ulp error */ - y = 0.5f*log1pf(2*y + 2*y*y/(1-y)); - } - } else { - /* avoid overflow */ - y = 0.5f*log1pf(2*(y/(1-y))); - } - return s ? -y : y; -} diff --git a/user/mpy/lib/libm/ef_rem_pio2.c b/user/mpy/lib/libm/ef_rem_pio2.c deleted file mode 100644 index ca55243..0000000 --- a/user/mpy/lib/libm/ef_rem_pio2.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* ef_rem_pio2.c -- float version of e_rem_pio2.c - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_rem_pio2f(x,y) - * - * return the remainder of x rem pi/2 in y[0]+y[1] - * use __kernel_rem_pio2f() - */ - -#include "fdlibm.h" - -/* - * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi - */ -#ifdef __STDC__ -static const __int32_t two_over_pi[] = { -#else -static __int32_t two_over_pi[] = { -#endif -0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC, -0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62, -0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63, -0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A, -0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09, -0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29, -0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44, -0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41, -0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C, -0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8, -0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11, -0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF, -0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E, -0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5, -0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92, -0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08, -0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0, -0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3, -0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85, -0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80, -0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA, -0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B, -}; - -/* This array is like the one in e_rem_pio2.c, but the numbers are - single precision and the last 8 bits are forced to 0. */ -#ifdef __STDC__ -static const __int32_t npio2_hw[] = { -#else -static __int32_t npio2_hw[] = { -#endif -0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00, -0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00, -0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100, -0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00, -0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00, -0x4242c700, 0x42490f00 -}; - -/* - * invpio2: 24 bits of 2/pi - * pio2_1: first 17 bit of pi/2 - * pio2_1t: pi/2 - pio2_1 - * pio2_2: second 17 bit of pi/2 - * pio2_2t: pi/2 - (pio2_1+pio2_2) - * pio2_3: third 17 bit of pi/2 - * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) - */ - -#ifdef __STDC__ -static const float -#else -static float -#endif -zero = 0.0000000000e+00, /* 0x00000000 */ -half = 5.0000000000e-01, /* 0x3f000000 */ -two8 = 2.5600000000e+02, /* 0x43800000 */ -invpio2 = 6.3661980629e-01, /* 0x3f22f984 */ -pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */ -pio2_1t = 1.0804334124e-05, /* 0x37354443 */ -pio2_2 = 1.0804273188e-05, /* 0x37354400 */ -pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */ -pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */ -pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ - -#ifdef __STDC__ - __int32_t __ieee754_rem_pio2f(float x, float *y) -#else - __int32_t __ieee754_rem_pio2f(x,y) - float x,y[]; -#endif -{ - float z,w,t,r,fn; - float tx[3]; - __int32_t i,j,n,ix,hx; - int e0,nx; - - GET_FLOAT_WORD(hx,x); - ix = hx&0x7fffffff; - if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */ - {y[0] = x; y[1] = 0; return 0;} - if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */ - if(hx>0) { - z = x - pio2_1; - if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ - y[0] = z - pio2_1t; - y[1] = (z-y[0])-pio2_1t; - } else { /* near pi/2, use 24+24+24 bit pi */ - z -= pio2_2; - y[0] = z - pio2_2t; - y[1] = (z-y[0])-pio2_2t; - } - return 1; - } else { /* negative x */ - z = x + pio2_1; - if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ - y[0] = z + pio2_1t; - y[1] = (z-y[0])+pio2_1t; - } else { /* near pi/2, use 24+24+24 bit pi */ - z += pio2_2; - y[0] = z + pio2_2t; - y[1] = (z-y[0])+pio2_2t; - } - return -1; - } - } - if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */ - t = fabsf(x); - n = (__int32_t) (t*invpio2+half); - fn = (float)n; - r = t-fn*pio2_1; - w = fn*pio2_1t; /* 1st round good to 40 bit */ - if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) { - y[0] = r-w; /* quick check no cancellation */ - } else { - __uint32_t high; - j = ix>>23; - y[0] = r-w; - GET_FLOAT_WORD(high,y[0]); - i = j-((high>>23)&0xff); - if(i>8) { /* 2nd iteration needed, good to 57 */ - t = r; - w = fn*pio2_2; - r = t-w; - w = fn*pio2_2t-((t-r)-w); - y[0] = r-w; - GET_FLOAT_WORD(high,y[0]); - i = j-((high>>23)&0xff); - if(i>25) { /* 3rd iteration need, 74 bits acc */ - t = r; /* will cover all possible cases */ - w = fn*pio2_3; - r = t-w; - w = fn*pio2_3t-((t-r)-w); - y[0] = r-w; - } - } - } - y[1] = (r-y[0])-w; - if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} - else return n; - } - /* - * all other (large) arguments - */ - if(!FLT_UWORD_IS_FINITE(ix)) { - y[0]=y[1]=x-x; return 0; - } - /* set z = scalbn(|x|,ilogb(x)-7) */ - e0 = (int)((ix>>23)-134); /* e0 = ilogb(z)-7; */ - SET_FLOAT_WORD(z, ix - ((__int32_t)e0<<23)); - for(i=0;i<2;i++) { - tx[i] = (float)((__int32_t)(z)); - z = (z-tx[i])*two8; - } - tx[2] = z; - nx = 3; - while(tx[nx-1]==zero) nx--; /* skip zero term */ - n = __kernel_rem_pio2f(tx,y,e0,nx,2,two_over_pi); - if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} - return n; -} diff --git a/user/mpy/lib/libm/ef_sqrt.c b/user/mpy/lib/libm/ef_sqrt.c deleted file mode 100644 index 87484d0..0000000 --- a/user/mpy/lib/libm/ef_sqrt.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* ef_sqrtf.c -- float version of e_sqrt.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ -static const float one = 1.0, tiny=1.0e-30; -#else -static float one = 1.0, tiny=1.0e-30; -#endif - -// sqrtf is exactly __ieee754_sqrtf when _IEEE_LIBM defined -float sqrtf(float x) -/* -#ifdef __STDC__ - float __ieee754_sqrtf(float x) -#else - float __ieee754_sqrtf(x) - float x; -#endif -*/ -{ - float z; - __uint32_t r,hx; - __int32_t ix,s,q,m,t,i; - - GET_FLOAT_WORD(ix,x); - hx = ix&0x7fffffff; - - /* take care of Inf and NaN */ - if(!FLT_UWORD_IS_FINITE(hx)) - return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf - sqrt(-inf)=sNaN */ - /* take care of zero and -ves */ - if(FLT_UWORD_IS_ZERO(hx)) return x;/* sqrt(+-0) = +-0 */ - if(ix<0) return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ - - /* normalize x */ - m = (ix>>23); - if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ - for(i=0;(ix&0x00800000L)==0;i++) ix<<=1; - m -= i-1; - } - m -= 127; /* unbias exponent */ - ix = (ix&0x007fffffL)|0x00800000L; - if(m&1) /* odd m, double x to make it even */ - ix += ix; - m >>= 1; /* m = [m/2] */ - - /* generate sqrt(x) bit by bit */ - ix += ix; - q = s = 0; /* q = sqrt(x) */ - r = 0x01000000L; /* r = moving bit from right to left */ - - while(r!=0) { - t = s+r; - if(t<=ix) { - s = t+r; - ix -= t; - q += r; - } - ix += ix; - r>>=1; - } - - /* use floating add to find out rounding direction */ - if(ix!=0) { - z = one-tiny; /* trigger inexact flag */ - if (z>=one) { - z = one+tiny; - if (z>one) - q += 2; - else - q += (q&1); - } - } - ix = (q>>1)+0x3f000000L; - ix += (m <<23); - SET_FLOAT_WORD(z,ix); - return z; -} diff --git a/user/mpy/lib/libm/erf_lgamma.c b/user/mpy/lib/libm/erf_lgamma.c deleted file mode 100644 index 877816a..0000000 --- a/user/mpy/lib/libm/erf_lgamma.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* erf_lgamma.c -- float version of er_lgamma.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -#include "fdlibm.h" - -#define __ieee754_logf logf - -#ifdef __STDC__ -static const float -#else -static float -#endif -two23= 8.3886080000e+06, /* 0x4b000000 */ -half= 5.0000000000e-01, /* 0x3f000000 */ -one = 1.0000000000e+00, /* 0x3f800000 */ -pi = 3.1415927410e+00, /* 0x40490fdb */ -a0 = 7.7215664089e-02, /* 0x3d9e233f */ -a1 = 3.2246702909e-01, /* 0x3ea51a66 */ -a2 = 6.7352302372e-02, /* 0x3d89f001 */ -a3 = 2.0580807701e-02, /* 0x3ca89915 */ -a4 = 7.3855509982e-03, /* 0x3bf2027e */ -a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */ -a6 = 1.1927076848e-03, /* 0x3a9c54a1 */ -a7 = 5.1006977446e-04, /* 0x3a05b634 */ -a8 = 2.2086278477e-04, /* 0x39679767 */ -a9 = 1.0801156895e-04, /* 0x38e28445 */ -a10 = 2.5214456400e-05, /* 0x37d383a2 */ -a11 = 4.4864096708e-05, /* 0x383c2c75 */ -tc = 1.4616321325e+00, /* 0x3fbb16c3 */ -tf = -1.2148628384e-01, /* 0xbdf8cdcd */ -/* tt = -(tail of tf) */ -tt = 6.6971006518e-09, /* 0x31e61c52 */ -t0 = 4.8383611441e-01, /* 0x3ef7b95e */ -t1 = -1.4758771658e-01, /* 0xbe17213c */ -t2 = 6.4624942839e-02, /* 0x3d845a15 */ -t3 = -3.2788541168e-02, /* 0xbd064d47 */ -t4 = 1.7970675603e-02, /* 0x3c93373d */ -t5 = -1.0314224288e-02, /* 0xbc28fcfe */ -t6 = 6.1005386524e-03, /* 0x3bc7e707 */ -t7 = -3.6845202558e-03, /* 0xbb7177fe */ -t8 = 2.2596477065e-03, /* 0x3b141699 */ -t9 = -1.4034647029e-03, /* 0xbab7f476 */ -t10 = 8.8108185446e-04, /* 0x3a66f867 */ -t11 = -5.3859531181e-04, /* 0xba0d3085 */ -t12 = 3.1563205994e-04, /* 0x39a57b6b */ -t13 = -3.1275415677e-04, /* 0xb9a3f927 */ -t14 = 3.3552918467e-04, /* 0x39afe9f7 */ -u0 = -7.7215664089e-02, /* 0xbd9e233f */ -u1 = 6.3282704353e-01, /* 0x3f2200f4 */ -u2 = 1.4549225569e+00, /* 0x3fba3ae7 */ -u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */ -u4 = 2.2896373272e-01, /* 0x3e6a7578 */ -u5 = 1.3381091878e-02, /* 0x3c5b3c5e */ -v1 = 2.4559779167e+00, /* 0x401d2ebe */ -v2 = 2.1284897327e+00, /* 0x4008392d */ -v3 = 7.6928514242e-01, /* 0x3f44efdf */ -v4 = 1.0422264785e-01, /* 0x3dd572af */ -v5 = 3.2170924824e-03, /* 0x3b52d5db */ -s0 = -7.7215664089e-02, /* 0xbd9e233f */ -s1 = 2.1498242021e-01, /* 0x3e5c245a */ -s2 = 3.2577878237e-01, /* 0x3ea6cc7a */ -s3 = 1.4635047317e-01, /* 0x3e15dce6 */ -s4 = 2.6642270386e-02, /* 0x3cda40e4 */ -s5 = 1.8402845599e-03, /* 0x3af135b4 */ -s6 = 3.1947532989e-05, /* 0x3805ff67 */ -r1 = 1.3920053244e+00, /* 0x3fb22d3b */ -r2 = 7.2193557024e-01, /* 0x3f38d0c5 */ -r3 = 1.7193385959e-01, /* 0x3e300f6e */ -r4 = 1.8645919859e-02, /* 0x3c98bf54 */ -r5 = 7.7794247773e-04, /* 0x3a4beed6 */ -r6 = 7.3266842264e-06, /* 0x36f5d7bd */ -w0 = 4.1893854737e-01, /* 0x3ed67f1d */ -w1 = 8.3333335817e-02, /* 0x3daaaaab */ -w2 = -2.7777778450e-03, /* 0xbb360b61 */ -w3 = 7.9365057172e-04, /* 0x3a500cfd */ -w4 = -5.9518753551e-04, /* 0xba1c065c */ -w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */ -w6 = -1.6309292987e-03; /* 0xbad5c4e8 */ - -#ifdef __STDC__ -static const float zero= 0.0000000000e+00; -#else -static float zero= 0.0000000000e+00; -#endif - -#ifdef __STDC__ - static float sin_pif(float x) -#else - static float sin_pif(x) - float x; -#endif -{ - float y,z; - __int32_t n,ix; - - GET_FLOAT_WORD(ix,x); - ix &= 0x7fffffff; - - if(ix<0x3e800000) return __kernel_sinf(pi*x,zero,0); - y = -x; /* x is assume negative */ - - /* - * argument reduction, make sure inexact flag not raised if input - * is an integer - */ - z = floorf(y); - if(z!=y) { /* inexact anyway */ - y *= (float)0.5; - y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */ - n = (__int32_t) (y*(float)4.0); - } else { - if(ix>=0x4b800000) { - y = zero; n = 0; /* y must be even */ - } else { - if(ix<0x4b000000) z = y+two23; /* exact */ - GET_FLOAT_WORD(n,z); - n &= 1; - y = n; - n<<= 2; - } - } - switch (n) { - case 0: y = __kernel_sinf(pi*y,zero,0); break; - case 1: - case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break; - case 3: - case 4: y = __kernel_sinf(pi*(one-y),zero,0); break; - case 5: - case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break; - default: y = __kernel_sinf(pi*(y-(float)2.0),zero,0); break; - } - return -y; -} - - -#ifdef __STDC__ - float __ieee754_lgammaf_r(float x, int *signgamp) -#else - float __ieee754_lgammaf_r(x,signgamp) - float x; int *signgamp; -#endif -{ - float t,y,z,nadj = 0.0,p,p1,p2,p3,q,r,w; - __int32_t i,hx,ix; - - GET_FLOAT_WORD(hx,x); - - /* purge off +-inf, NaN, +-0, and negative arguments */ - *signgamp = 1; - ix = hx&0x7fffffff; - if(ix>=0x7f800000) return x*x; - if(ix==0) return one/zero; - if(ix<0x1c800000) { /* |x|<2**-70, return -log(|x|) */ - if(hx<0) { - *signgamp = -1; - return -__ieee754_logf(-x); - } else return -__ieee754_logf(x); - } - if(hx<0) { - if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */ - return one/zero; - t = sin_pif(x); - if(t==zero) return one/zero; /* -integer */ - nadj = __ieee754_logf(pi/fabsf(t*x)); - if(t=0x3f3b4a20) {y = one-x; i= 0;} - else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;} - else {y = x; i=2;} - } else { - r = zero; - if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */ - else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */ - else {y=x-one;i=2;} - } - switch(i) { - case 0: - z = y*y; - p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); - p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); - p = y*p1+p2; - r += (p-(float)0.5*y); break; - case 1: - z = y*y; - w = z*y; - p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ - p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); - p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); - p = z*p1-(tt-w*(p2+y*p3)); - r += (tf + p); break; - case 2: - p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); - p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); - r += (-(float)0.5*y + p1/p2); - } - } - else if(ix<0x41000000) { /* x < 8.0 */ - i = (__int32_t)x; - t = zero; - y = x-(float)i; - p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); - q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); - r = half*y+p/q; - z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ - switch(i) { - case 7: z *= (y+(float)6.0); /* FALLTHRU */ - case 6: z *= (y+(float)5.0); /* FALLTHRU */ - case 5: z *= (y+(float)4.0); /* FALLTHRU */ - case 4: z *= (y+(float)3.0); /* FALLTHRU */ - case 3: z *= (y+(float)2.0); /* FALLTHRU */ - r += __ieee754_logf(z); break; - } - /* 8.0 <= x < 2**58 */ - } else if (ix < 0x5c800000) { - t = __ieee754_logf(x); - z = one/x; - y = z*z; - w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); - r = (x-half)*(t-one)+w; - } else - /* 2**58 <= x <= inf */ - r = x*(__ieee754_logf(x)-one); - if(hx<0) r = nadj - r; - return r; -} diff --git a/user/mpy/lib/libm/fdlibm.h b/user/mpy/lib/libm/fdlibm.h deleted file mode 100644 index ace3b2d..0000000 --- a/user/mpy/lib/libm/fdlibm.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * This file is adapted from from newlib-nano-2, the newlib/libm/common/fdlib.h, - * available from https://github.com/32bitmicro/newlib-nano-2. The main change - * is removal of anything to do with double precision. - * - * Appropriate copyright headers are reproduced below. - */ - -/* @(#)fdlibm.h 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include - -/* Default to XOPEN_MODE. */ -#define _XOPEN_MODE - -/* Most routines need to check whether a float is finite, infinite, or not a - number, and many need to know whether the result of an operation will - overflow. These conditions depend on whether the largest exponent is - used for NaNs & infinities, or whether it's used for finite numbers. The - macros below wrap up that kind of information: - - FLT_UWORD_IS_FINITE(X) - True if a positive float with bitmask X is finite. - - FLT_UWORD_IS_NAN(X) - True if a positive float with bitmask X is not a number. - - FLT_UWORD_IS_INFINITE(X) - True if a positive float with bitmask X is +infinity. - - FLT_UWORD_MAX - The bitmask of FLT_MAX. - - FLT_UWORD_HALF_MAX - The bitmask of FLT_MAX/2. - - FLT_UWORD_EXP_MAX - The bitmask of the largest finite exponent (129 if the largest - exponent is used for finite numbers, 128 otherwise). - - FLT_UWORD_LOG_MAX - The bitmask of log(FLT_MAX), rounded down. This value is the largest - input that can be passed to exp() without producing overflow. - - FLT_UWORD_LOG_2MAX - The bitmask of log(2*FLT_MAX), rounded down. This value is the - largest input than can be passed to cosh() without producing - overflow. - - FLT_LARGEST_EXP - The largest biased exponent that can be used for finite numbers - (255 if the largest exponent is used for finite numbers, 254 - otherwise) */ - -#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL -#define FLT_UWORD_IS_FINITE(x) 1 -#define FLT_UWORD_IS_NAN(x) 0 -#define FLT_UWORD_IS_INFINITE(x) 0 -#define FLT_UWORD_MAX 0x7fffffff -#define FLT_UWORD_EXP_MAX 0x43010000 -#define FLT_UWORD_LOG_MAX 0x42b2d4fc -#define FLT_UWORD_LOG_2MAX 0x42b437e0 -#define HUGE ((float)0X1.FFFFFEP128) -#else -#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L) -#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L) -#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L) -#define FLT_UWORD_MAX 0x7f7fffffL -#define FLT_UWORD_EXP_MAX 0x43000000 -#define FLT_UWORD_LOG_MAX 0x42b17217 -#define FLT_UWORD_LOG_2MAX 0x42b2d4fc -#define HUGE ((float)3.40282346638528860e+38) -#endif -#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23)) -#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23) - -/* Many routines check for zero and subnormal numbers. Such things depend - on whether the target supports denormals or not: - - FLT_UWORD_IS_ZERO(X) - True if a positive float with bitmask X is +0. Without denormals, - any float with a zero exponent is a +0 representation. With - denormals, the only +0 representation is a 0 bitmask. - - FLT_UWORD_IS_SUBNORMAL(X) - True if a non-zero positive float with bitmask X is subnormal. - (Routines should check for zeros first.) - - FLT_UWORD_MIN - The bitmask of the smallest float above +0. Call this number - REAL_FLT_MIN... - - FLT_UWORD_EXP_MIN - The bitmask of the float representation of REAL_FLT_MIN's exponent. - - FLT_UWORD_LOG_MIN - The bitmask of |log(REAL_FLT_MIN)|, rounding down. - - FLT_SMALLEST_EXP - REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported, - -22 if they are). -*/ - -#ifdef _FLT_NO_DENORMALS -#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L) -#define FLT_UWORD_IS_SUBNORMAL(x) 0 -#define FLT_UWORD_MIN 0x00800000 -#define FLT_UWORD_EXP_MIN 0x42fc0000 -#define FLT_UWORD_LOG_MIN 0x42aeac50 -#define FLT_SMALLEST_EXP 1 -#else -#define FLT_UWORD_IS_ZERO(x) ((x)==0) -#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L) -#define FLT_UWORD_MIN 0x00000001 -#define FLT_UWORD_EXP_MIN 0x43160000 -#define FLT_UWORD_LOG_MIN 0x42cff1b5 -#define FLT_SMALLEST_EXP -22 -#endif - -#ifdef __STDC__ -#undef __P -#define __P(p) p -#else -#define __P(p) () -#endif - -/* - * set X_TLOSS = pi*2**52, which is possibly defined in - * (one may replace the following line by "#include ") - */ - -#define X_TLOSS 1.41484755040568800000e+16 - -/* Functions that are not documented, and are not in . */ - -/* Undocumented float functions. */ -#ifdef _SCALB_INT -extern float scalbf __P((float, int)); -#else -extern float scalbf __P((float, float)); -#endif -extern float significandf __P((float)); - -/* ieee style elementary float functions */ -extern float __ieee754_sqrtf __P((float)); -extern float __ieee754_acosf __P((float)); -extern float __ieee754_acoshf __P((float)); -extern float __ieee754_logf __P((float)); -extern float __ieee754_atanhf __P((float)); -extern float __ieee754_asinf __P((float)); -extern float __ieee754_atan2f __P((float,float)); -extern float __ieee754_expf __P((float)); -extern float __ieee754_coshf __P((float)); -extern float __ieee754_fmodf __P((float,float)); -extern float __ieee754_powf __P((float,float)); -extern float __ieee754_lgammaf_r __P((float,int *)); -extern float __ieee754_gammaf_r __P((float,int *)); -extern float __ieee754_log10f __P((float)); -extern float __ieee754_sinhf __P((float)); -extern float __ieee754_hypotf __P((float,float)); -extern float __ieee754_j0f __P((float)); -extern float __ieee754_j1f __P((float)); -extern float __ieee754_y0f __P((float)); -extern float __ieee754_y1f __P((float)); -extern float __ieee754_jnf __P((int,float)); -extern float __ieee754_ynf __P((int,float)); -extern float __ieee754_remainderf __P((float,float)); -extern __int32_t __ieee754_rem_pio2f __P((float,float*)); -#ifdef _SCALB_INT -extern float __ieee754_scalbf __P((float,int)); -#else -extern float __ieee754_scalbf __P((float,float)); -#endif - -/* float versions of fdlibm kernel functions */ -extern float __kernel_sinf __P((float,float,int)); -extern float __kernel_cosf __P((float,float)); -extern float __kernel_tanf __P((float,float,int)); -extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*)); - -/* A union which permits us to convert between a float and a 32 bit - int. */ - -typedef union -{ - float value; - __uint32_t word; -} ieee_float_shape_type; - -/* Get a 32 bit int from a float. */ - -#define GET_FLOAT_WORD(i,d) \ -do { \ - ieee_float_shape_type gf_u; \ - gf_u.value = (d); \ - (i) = gf_u.word; \ -} while (0) - -/* Set a float from a 32 bit int. */ - -#define SET_FLOAT_WORD(d,i) \ -do { \ - ieee_float_shape_type sf_u; \ - sf_u.word = (i); \ - (d) = sf_u.value; \ -} while (0) - -/* Macros to avoid undefined behaviour that can arise if the amount - of a shift is exactly equal to the size of the shifted operand. */ - -#define SAFE_LEFT_SHIFT(op,amt) \ - (((amt) < 8 * sizeof(op)) ? ((op) << (amt)) : 0) - -#define SAFE_RIGHT_SHIFT(op,amt) \ - (((amt) < 8 * sizeof(op)) ? ((op) >> (amt)) : 0) diff --git a/user/mpy/lib/libm/fmodf.c b/user/mpy/lib/libm/fmodf.c deleted file mode 100644 index 69a9ad9..0000000 --- a/user/mpy/lib/libm/fmodf.c +++ /dev/null @@ -1,70 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// fmodf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -#include "libm.h" - -float fmodf(float x, float y) -{ - union {float f; uint32_t i;} ux = {x}, uy = {y}; - int ex = ux.i>>23 & 0xff; - int ey = uy.i>>23 & 0xff; - uint32_t sx = ux.i & 0x80000000; - uint32_t i; - uint32_t uxi = ux.i; - - if (uy.i<<1 == 0 || isnan(y) || ex == 0xff) - return (x*y)/(x*y); - if (uxi<<1 <= uy.i<<1) { - if (uxi<<1 == uy.i<<1) - return 0*x; - return x; - } - - /* normalize x and y */ - if (!ex) { - for (i = uxi<<9; i>>31 == 0; ex--, i <<= 1); - uxi <<= -ex + 1; - } else { - uxi &= -1U >> 9; - uxi |= 1U << 23; - } - if (!ey) { - for (i = uy.i<<9; i>>31 == 0; ey--, i <<= 1); - uy.i <<= -ey + 1; - } else { - uy.i &= -1U >> 9; - uy.i |= 1U << 23; - } - - /* x mod y */ - for (; ex > ey; ex--) { - i = uxi - uy.i; - if (i >> 31 == 0) { - if (i == 0) - return 0*x; - uxi = i; - } - uxi <<= 1; - } - i = uxi - uy.i; - if (i >> 31 == 0) { - if (i == 0) - return 0*x; - uxi = i; - } - for (; uxi>>23 == 0; uxi <<= 1, ex--); - - /* scale result up */ - if (ex > 0) { - uxi -= 1U << 23; - uxi |= (uint32_t)ex << 23; - } else { - uxi >>= -ex + 1; - } - uxi |= sx; - ux.i = uxi; - return ux.f; -} diff --git a/user/mpy/lib/libm/kf_cos.c b/user/mpy/lib/libm/kf_cos.c deleted file mode 100644 index 691f984..0000000 --- a/user/mpy/lib/libm/kf_cos.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* kf_cos.c -- float version of k_cos.c - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ -static const float -#else -static float -#endif -one = 1.0000000000e+00, /* 0x3f800000 */ -C1 = 4.1666667908e-02, /* 0x3d2aaaab */ -C2 = -1.3888889225e-03, /* 0xbab60b61 */ -C3 = 2.4801587642e-05, /* 0x37d00d01 */ -C4 = -2.7557314297e-07, /* 0xb493f27c */ -C5 = 2.0875723372e-09, /* 0x310f74f6 */ -C6 = -1.1359647598e-11; /* 0xad47d74e */ - -#ifdef __STDC__ - float __kernel_cosf(float x, float y) -#else - float __kernel_cosf(x, y) - float x,y; -#endif -{ - float a,hz,z,r,qx; - __int32_t ix; - GET_FLOAT_WORD(ix,x); - ix &= 0x7fffffff; /* ix = |x|'s high word*/ - if(ix<0x32000000) { /* if x < 2**27 */ - if(((int)x)==0) return one; /* generate inexact */ - } - z = x*x; - r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); - if(ix < 0x3e99999a) /* if |x| < 0.3 */ - return one - ((float)0.5*z - (z*r - x*y)); - else { - if(ix > 0x3f480000) { /* x > 0.78125 */ - qx = (float)0.28125; - } else { - SET_FLOAT_WORD(qx,ix-0x01000000); /* x/4 */ - } - hz = (float)0.5*z-qx; - a = one-qx; - return a - (hz - (z*r-x*y)); - } -} diff --git a/user/mpy/lib/libm/kf_rem_pio2.c b/user/mpy/lib/libm/kf_rem_pio2.c deleted file mode 100644 index c7e9479..0000000 --- a/user/mpy/lib/libm/kf_rem_pio2.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* kf_rem_pio2.c -- float version of k_rem_pio2.c - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -/* In the float version, the input parameter x contains 8 bit - integers, not 24 bit integers. 113 bit precision is not supported. */ - -#ifdef __STDC__ -static const int init_jk[] = {4,7,9}; /* initial value for jk */ -#else -static int init_jk[] = {4,7,9}; -#endif - -#ifdef __STDC__ -static const float PIo2[] = { -#else -static float PIo2[] = { -#endif - 1.5703125000e+00, /* 0x3fc90000 */ - 4.5776367188e-04, /* 0x39f00000 */ - 2.5987625122e-05, /* 0x37da0000 */ - 7.5437128544e-08, /* 0x33a20000 */ - 6.0026650317e-11, /* 0x2e840000 */ - 7.3896444519e-13, /* 0x2b500000 */ - 5.3845816694e-15, /* 0x27c20000 */ - 5.6378512969e-18, /* 0x22d00000 */ - 8.3009228831e-20, /* 0x1fc40000 */ - 3.2756352257e-22, /* 0x1bc60000 */ - 6.3331015649e-25, /* 0x17440000 */ -}; - -#ifdef __STDC__ -static const float -#else -static float -#endif -zero = 0.0, -one = 1.0, -two8 = 2.5600000000e+02, /* 0x43800000 */ -twon8 = 3.9062500000e-03; /* 0x3b800000 */ - -#ifdef __STDC__ - int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2) -#else - int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2) - float x[], y[]; int e0,nx,prec; __int32_t ipio2[]; -#endif -{ - __int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; - float z,fw,f[20],fq[20],q[20]; - - /* initialize jk*/ - jk = init_jk[prec]; - jp = jk; - - /* determine jx,jv,q0, note that 3>q0 */ - jx = nx-1; - jv = (e0-3)/8; if(jv<0) jv=0; - q0 = e0-8*(jv+1); - - /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ - j = jv-jx; m = jx+jk; - for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j]; - - /* compute q[0],q[1],...q[jk] */ - for (i=0;i<=jk;i++) { - for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; - q[i] = fw; - } - - jz = jk; -recompute: - /* distill q[] into iq[] reversingly */ - for(i=0,j=jz,z=q[jz];j>0;i++,j--) { - fw = (float)((__int32_t)(twon8* z)); - iq[i] = (__int32_t)(z-two8*fw); - z = q[j-1]+fw; - } - - /* compute n */ - z = scalbnf(z,(int)q0); /* actual value of z */ - z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */ - n = (__int32_t) z; - z -= (float)n; - ih = 0; - if(q0>0) { /* need iq[jz-1] to determine n */ - i = (iq[jz-1]>>(8-q0)); n += i; - iq[jz-1] -= i<<(8-q0); - ih = iq[jz-1]>>(7-q0); - } - else if(q0==0) ih = iq[jz-1]>>8; - else if(z>=(float)0.5) ih=2; - - if(ih>0) { /* q > 0.5 */ - n += 1; carry = 0; - for(i=0;i0) { /* rare case: chance is 1 in 12 */ - switch(q0) { - case 1: - iq[jz-1] &= 0x7f; break; - case 2: - iq[jz-1] &= 0x3f; break; - } - } - if(ih==2) { - z = one - z; - if(carry!=0) z -= scalbnf(one,(int)q0); - } - } - - /* check if recomputation is needed */ - if(z==zero) { - j = 0; - for (i=jz-1;i>=jk;i--) j |= iq[i]; - if(j==0) { /* need recomputation */ - for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ - - for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ - f[jx+i] = (float) ipio2[jv+i]; - for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; - q[i] = fw; - } - jz += k; - goto recompute; - } - } - - /* chop off zero terms */ - if(z==(float)0.0) { - jz -= 1; q0 -= 8; - while(iq[jz]==0) { jz--; q0-=8;} - } else { /* break z into 8-bit if necessary */ - z = scalbnf(z,-(int)q0); - if(z>=two8) { - fw = (float)((__int32_t)(twon8*z)); - iq[jz] = (__int32_t)(z-two8*fw); - jz += 1; q0 += 8; - iq[jz] = (__int32_t) fw; - } else iq[jz] = (__int32_t) z ; - } - - /* convert integer "bit" chunk to floating-point value */ - fw = scalbnf(one,(int)q0); - for(i=jz;i>=0;i--) { - q[i] = fw*(float)iq[i]; fw*=twon8; - } - - /* compute PIo2[0,...,jp]*q[jz,...,0] */ - for(i=jz;i>=0;i--) { - for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; - fq[jz-i] = fw; - } - - /* compress fq[] into y[] */ - switch(prec) { - case 0: - fw = 0.0; - for (i=jz;i>=0;i--) fw += fq[i]; - y[0] = (ih==0)? fw: -fw; - break; - case 1: - case 2: - fw = 0.0; - for (i=jz;i>=0;i--) fw += fq[i]; - y[0] = (ih==0)? fw: -fw; - fw = fq[0]-fw; - for (i=1;i<=jz;i++) fw += fq[i]; - y[1] = (ih==0)? fw: -fw; - break; - case 3: /* painful */ - for (i=jz;i>0;i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; - } - for (i=jz;i>1;i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; - } - for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; - if(ih==0) { - y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; - } else { - y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; - } - } - return n&7; -} diff --git a/user/mpy/lib/libm/kf_sin.c b/user/mpy/lib/libm/kf_sin.c deleted file mode 100644 index 07ea993..0000000 --- a/user/mpy/lib/libm/kf_sin.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* kf_sin.c -- float version of k_sin.c - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ -static const float -#else -static float -#endif -half = 5.0000000000e-01,/* 0x3f000000 */ -S1 = -1.6666667163e-01, /* 0xbe2aaaab */ -S2 = 8.3333337680e-03, /* 0x3c088889 */ -S3 = -1.9841270114e-04, /* 0xb9500d01 */ -S4 = 2.7557314297e-06, /* 0x3638ef1b */ -S5 = -2.5050759689e-08, /* 0xb2d72f34 */ -S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */ - -#ifdef __STDC__ - float __kernel_sinf(float x, float y, int iy) -#else - float __kernel_sinf(x, y, iy) - float x,y; int iy; /* iy=0 if y is zero */ -#endif -{ - float z,r,v; - __int32_t ix; - GET_FLOAT_WORD(ix,x); - ix &= 0x7fffffff; /* high word of x */ - if(ix<0x32000000) /* |x| < 2**-27 */ - {if((int)x==0) return x;} /* generate inexact */ - z = x*x; - v = z*x; - r = S2+z*(S3+z*(S4+z*(S5+z*S6))); - if(iy==0) return x+v*(S1+z*r); - else return x-((z*(half*y-v*r)-y)-v*S1); -} diff --git a/user/mpy/lib/libm/kf_tan.c b/user/mpy/lib/libm/kf_tan.c deleted file mode 100644 index 6da9bd8..0000000 --- a/user/mpy/lib/libm/kf_tan.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* kf_tan.c -- float version of k_tan.c - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "libm.h" -#ifdef __STDC__ -static const float -#else -static float -#endif -one = 1.0000000000e+00, /* 0x3f800000 */ -pio4 = 7.8539812565e-01, /* 0x3f490fda */ -pio4lo= 3.7748947079e-08, /* 0x33222168 */ -T[] = { - 3.3333334327e-01, /* 0x3eaaaaab */ - 1.3333334029e-01, /* 0x3e088889 */ - 5.3968254477e-02, /* 0x3d5d0dd1 */ - 2.1869488060e-02, /* 0x3cb327a4 */ - 8.8632395491e-03, /* 0x3c11371f */ - 3.5920790397e-03, /* 0x3b6b6916 */ - 1.4562094584e-03, /* 0x3abede48 */ - 5.8804126456e-04, /* 0x3a1a26c8 */ - 2.4646313977e-04, /* 0x398137b9 */ - 7.8179444245e-05, /* 0x38a3f445 */ - 7.1407252108e-05, /* 0x3895c07a */ - -1.8558637748e-05, /* 0xb79bae5f */ - 2.5907305826e-05, /* 0x37d95384 */ -}; - -#ifdef __STDC__ - float __kernel_tanf(float x, float y, int iy) -#else - float __kernel_tanf(x, y, iy) - float x,y; int iy; -#endif -{ - float z,r,v,w,s; - __int32_t ix,hx; - GET_FLOAT_WORD(hx,x); - ix = hx&0x7fffffff; /* high word of |x| */ - if(ix<0x31800000) /* x < 2**-28 */ - {if((int)x==0) { /* generate inexact */ - if((ix|(iy+1))==0) return one/fabsf(x); - else return (iy==1)? x: -one/x; - } - } - if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ - if(hx<0) {x = -x; y = -y;} - z = pio4-x; - w = pio4lo-y; - x = z+w; y = 0.0; - } - z = x*x; - w = z*z; - /* Break x^5*(T[1]+x^2*T[2]+...) into - * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + - * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) - */ - r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); - v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); - s = z*x; - r = y + z*(s*(r+v)+y); - r += T[0]*s; - w = x+r; - if(ix>=0x3f2ca140) { - v = (float)iy; - return (float)(1-((hx>>30)&2))*(v-(float)2.0*(x-(w*w/(w+v)-r))); - } - if(iy==1) return w; - else { /* if allow error up to 2 ulp, - simply return -1.0/(x+r) here */ - /* compute -1.0/(x+r) accurately */ - float a,t; - __int32_t i; - z = w; - GET_FLOAT_WORD(i,z); - SET_FLOAT_WORD(z,i&0xfffff000); - v = r-(z - x); /* z+v = r+x */ - t = a = -(float)1.0/w; /* a = -1.0/w */ - GET_FLOAT_WORD(i,t); - SET_FLOAT_WORD(t,i&0xfffff000); - s = (float)1.0+t*z; - return t+a*(s+t*v); - } -} diff --git a/user/mpy/lib/libm/libm.h b/user/mpy/lib/libm/libm.h deleted file mode 100644 index f782249..0000000 --- a/user/mpy/lib/libm/libm.h +++ /dev/null @@ -1,54 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// portions extracted from musl-0.9.15 libm.h -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include -#include - -#define FLT_EVAL_METHOD 0 - -#define FORCE_EVAL(x) do { \ - if (sizeof(x) == sizeof(float)) { \ - volatile float __x; \ - __x = (x); \ - (void)__x; \ - } else if (sizeof(x) == sizeof(double)) { \ - volatile double __x; \ - __x = (x); \ - (void)__x; \ - } else { \ - volatile long double __x; \ - __x = (x); \ - (void)__x; \ - } \ -} while(0) - -/* Get a 32 bit int from a float. */ -#define GET_FLOAT_WORD(w,d) \ -do { \ - union {float f; uint32_t i;} __u; \ - __u.f = (d); \ - (w) = __u.i; \ -} while (0) - -/* Set a float from a 32 bit int. */ -#define SET_FLOAT_WORD(d,w) \ -do { \ - union {float f; uint32_t i;} __u; \ - __u.i = (w); \ - (d) = __u.f; \ -} while (0) diff --git a/user/mpy/lib/libm/log1pf.c b/user/mpy/lib/libm/log1pf.c deleted file mode 100644 index 0d32b0a..0000000 --- a/user/mpy/lib/libm/log1pf.c +++ /dev/null @@ -1,83 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// log1pf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/s_log1pf.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "libm.h" - -static const float -ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ -ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ -/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ -Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ -Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ -Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ -Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ - -float log1pf(float x) -{ - union {float f; uint32_t i;} u = {x}; - float_t hfsq,f,c,s,z,R,w,t1,t2,dk; - uint32_t ix,iu; - int k; - - ix = u.i; - k = 1; - if (ix < 0x3ed413d0 || ix>>31) { /* 1+x < sqrt(2)+ */ - if (ix >= 0xbf800000) { /* x <= -1.0 */ - if (x == -1) - return x/0.0f; /* log1p(-1)=+inf */ - return (x-x)/0.0f; /* log1p(x<-1)=NaN */ - } - if (ix<<1 < 0x33800000<<1) { /* |x| < 2**-24 */ - /* underflow if subnormal */ - if ((ix&0x7f800000) == 0) - FORCE_EVAL(x*x); - return x; - } - if (ix <= 0xbe95f619) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */ - k = 0; - c = 0; - f = x; - } - } else if (ix >= 0x7f800000) - return x; - if (k) { - u.f = 1 + x; - iu = u.i; - iu += 0x3f800000 - 0x3f3504f3; - k = (int)(iu>>23) - 0x7f; - /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ - if (k < 25) { - c = k >= 2 ? 1-(u.f-x) : x-(u.f-1); - c /= u.f; - } else - c = 0; - /* reduce u into [sqrt(2)/2, sqrt(2)] */ - iu = (iu&0x007fffff) + 0x3f3504f3; - u.i = iu; - f = u.f - 1; - } - s = f/(2.0f + f); - z = s*s; - w = z*z; - t1= w*(Lg2+w*Lg4); - t2= z*(Lg1+w*Lg3); - R = t2 + t1; - hfsq = 0.5f*f*f; - dk = k; - return s*(hfsq+R) + (dk*ln2_lo+c) - hfsq + f + dk*ln2_hi; -} diff --git a/user/mpy/lib/libm/math.c b/user/mpy/lib/libm/math.c deleted file mode 100644 index 9846366..0000000 --- a/user/mpy/lib/libm/math.c +++ /dev/null @@ -1,822 +0,0 @@ -/* - * 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. - */ - -#include "libm.h" - -typedef float float_t; -typedef union { - float f; - struct { - uint64_t m : 23; - uint64_t e : 8; - uint64_t s : 1; - }; -} float_s_t; - -#ifndef NDEBUG -float copysignf(float x, float y) { - float_s_t fx={.f = x}; - float_s_t fy={.f = y}; - - // copy sign bit; - fx.s = fy.s; - - return fx.f; -} -#endif - -// some compilers define log2f in terms of logf -#ifdef log2f -#undef log2f -#endif -// some compilers have _M_LN2 defined in math.h, some don't -#ifndef _M_LN2 -#define _M_LN2 (0.69314718055994530942) -#endif -float log2f(float x) { return logf(x) / (float)_M_LN2; } - -static const float _M_LN10 = 2.30258509299404; // 0x40135d8e -float log10f(float x) { return logf(x) / (float)_M_LN10; } - -float tanhf(float x) { return sinhf(x) / coshf(x); } - -/*****************************************************************************/ -/*****************************************************************************/ -// __fpclassifyf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -int __fpclassifyf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = u.i>>23 & 0xff; - if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; - if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE; - return FP_NORMAL; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// scalbnf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -float scalbnf(float x, int n) -{ - union {float f; uint32_t i;} u; - float_t y = x; - - if (n > 127) { - y *= 0x1p127f; - n -= 127; - if (n > 127) { - y *= 0x1p127f; - n -= 127; - if (n > 127) - n = 127; - } - } else if (n < -126) { - y *= 0x1p-126f; - n += 126; - if (n < -126) { - y *= 0x1p-126f; - n += 126; - if (n < -126) - n = -126; - } - } - u.i = (uint32_t)(0x7f+n)<<23; - x = y * u.f; - return x; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// powf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/e_powf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -static const float -bp[] = {1.0, 1.5,}, -dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ -dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ -two24 = 16777216.0, /* 0x4b800000 */ -huge = 1.0e30, -tiny = 1.0e-30, -/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ -L1 = 6.0000002384e-01, /* 0x3f19999a */ -L2 = 4.2857143283e-01, /* 0x3edb6db7 */ -L3 = 3.3333334327e-01, /* 0x3eaaaaab */ -L4 = 2.7272811532e-01, /* 0x3e8ba305 */ -L5 = 2.3066075146e-01, /* 0x3e6c3255 */ -L6 = 2.0697501302e-01, /* 0x3e53f142 */ -P1 = 1.6666667163e-01, /* 0x3e2aaaab */ -P2 = -2.7777778450e-03, /* 0xbb360b61 */ -P3 = 6.6137559770e-05, /* 0x388ab355 */ -P4 = -1.6533901999e-06, /* 0xb5ddea0e */ -P5 = 4.1381369442e-08, /* 0x3331bb4c */ -lg2 = 6.9314718246e-01, /* 0x3f317218 */ -lg2_h = 6.93145752e-01, /* 0x3f317200 */ -lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ -ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ -cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ -cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */ -cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */ -ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ -ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ -ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ - -float powf(float x, float y) -{ - float z,ax,z_h,z_l,p_h,p_l; - float y1,t1,t2,r,s,sn,t,u,v,w; - int32_t i,j,k,yisint,n; - int32_t hx,hy,ix,iy,is; - - GET_FLOAT_WORD(hx, x); - GET_FLOAT_WORD(hy, y); - ix = hx & 0x7fffffff; - iy = hy & 0x7fffffff; - - /* x**0 = 1, even if x is NaN */ - if (iy == 0) - return 1.0f; - /* 1**y = 1, even if y is NaN */ - if (hx == 0x3f800000) - return 1.0f; - /* NaN if either arg is NaN */ - if (ix > 0x7f800000 || iy > 0x7f800000) - return x + y; - - /* determine if y is an odd int when x < 0 - * yisint = 0 ... y is not an integer - * yisint = 1 ... y is an odd int - * yisint = 2 ... y is an even int - */ - yisint = 0; - if (hx < 0) { - if (iy >= 0x4b800000) - yisint = 2; /* even integer y */ - else if (iy >= 0x3f800000) { - k = (iy>>23) - 0x7f; /* exponent */ - j = iy>>(23-k); - if ((j<<(23-k)) == iy) - yisint = 2 - (j & 1); - } - } - - /* special value of y */ - if (iy == 0x7f800000) { /* y is +-inf */ - if (ix == 0x3f800000) /* (-1)**+-inf is 1 */ - return 1.0f; - else if (ix > 0x3f800000) /* (|x|>1)**+-inf = inf,0 */ - return hy >= 0 ? y : 0.0f; - else if (ix != 0) /* (|x|<1)**+-inf = 0,inf if x!=0 */ - return hy >= 0 ? 0.0f: -y; - } - if (iy == 0x3f800000) /* y is +-1 */ - return hy >= 0 ? x : 1.0f/x; - if (hy == 0x40000000) /* y is 2 */ - return x*x; - if (hy == 0x3f000000) { /* y is 0.5 */ - if (hx >= 0) /* x >= +0 */ - return sqrtf(x); - } - - ax = fabsf(x); - /* special value of x */ - if (ix == 0x7f800000 || ix == 0 || ix == 0x3f800000) { /* x is +-0,+-inf,+-1 */ - z = ax; - if (hy < 0) /* z = (1/|x|) */ - z = 1.0f/z; - if (hx < 0) { - if (((ix-0x3f800000)|yisint) == 0) { - z = (z-z)/(z-z); /* (-1)**non-int is NaN */ - } else if (yisint == 1) - z = -z; /* (x<0)**odd = -(|x|**odd) */ - } - return z; - } - - sn = 1.0f; /* sign of result */ - if (hx < 0) { - if (yisint == 0) /* (x<0)**(non-int) is NaN */ - return (x-x)/(x-x); - if (yisint == 1) /* (x<0)**(odd int) */ - sn = -1.0f; - } - - /* |y| is huge */ - if (iy > 0x4d000000) { /* if |y| > 2**27 */ - /* over/underflow if x is not close to one */ - if (ix < 0x3f7ffff8) - return hy < 0 ? sn*huge*huge : sn*tiny*tiny; - if (ix > 0x3f800007) - return hy > 0 ? sn*huge*huge : sn*tiny*tiny; - /* now |1-x| is tiny <= 2**-20, suffice to compute - log(x) by x-x^2/2+x^3/3-x^4/4 */ - t = ax - 1; /* t has 20 trailing zeros */ - w = (t*t)*(0.5f - t*(0.333333333333f - t*0.25f)); - u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ - v = t*ivln2_l - w*ivln2; - t1 = u + v; - GET_FLOAT_WORD(is, t1); - SET_FLOAT_WORD(t1, is & 0xfffff000); - t2 = v - (t1-u); - } else { - float s2,s_h,s_l,t_h,t_l; - n = 0; - /* take care subnormal number */ - if (ix < 0x00800000) { - ax *= two24; - n -= 24; - GET_FLOAT_WORD(ix, ax); - } - n += ((ix)>>23) - 0x7f; - j = ix & 0x007fffff; - /* determine interval */ - ix = j | 0x3f800000; /* normalize ix */ - if (j <= 0x1cc471) /* |x|>1) & 0xfffff000) | 0x20000000; - SET_FLOAT_WORD(t_h, is + 0x00400000 + (k<<21)); - t_l = ax - (t_h - bp[k]); - s_l = v*((u - s_h*t_h) - s_h*t_l); - /* compute log(ax) */ - s2 = s*s; - r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); - r += s_l*(s_h+s); - s2 = s_h*s_h; - t_h = 3.0f + s2 + r; - GET_FLOAT_WORD(is, t_h); - SET_FLOAT_WORD(t_h, is & 0xfffff000); - t_l = r - ((t_h - 3.0f) - s2); - /* u+v = s*(1+...) */ - u = s_h*t_h; - v = s_l*t_h + t_l*s; - /* 2/(3log2)*(s+...) */ - p_h = u + v; - GET_FLOAT_WORD(is, p_h); - SET_FLOAT_WORD(p_h, is & 0xfffff000); - p_l = v - (p_h - u); - z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ - z_l = cp_l*p_h + p_l*cp+dp_l[k]; - /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ - t = (float)n; - t1 = (((z_h + z_l) + dp_h[k]) + t); - GET_FLOAT_WORD(is, t1); - SET_FLOAT_WORD(t1, is & 0xfffff000); - t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); - } - - /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ - GET_FLOAT_WORD(is, y); - SET_FLOAT_WORD(y1, is & 0xfffff000); - p_l = (y-y1)*t1 + y*t2; - p_h = y1*t1; - z = p_l + p_h; - GET_FLOAT_WORD(j, z); - if (j > 0x43000000) /* if z > 128 */ - return sn*huge*huge; /* overflow */ - else if (j == 0x43000000) { /* if z == 128 */ - if (p_l + ovt > z - p_h) - return sn*huge*huge; /* overflow */ - } else if ((j&0x7fffffff) > 0x43160000) /* z < -150 */ // FIXME: check should be (uint32_t)j > 0xc3160000 - return sn*tiny*tiny; /* underflow */ - else if (j == 0xc3160000) { /* z == -150 */ - if (p_l <= z-p_h) - return sn*tiny*tiny; /* underflow */ - } - /* - * compute 2**(p_h+p_l) - */ - i = j & 0x7fffffff; - k = (i>>23) - 0x7f; - n = 0; - if (i > 0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */ - n = j + (0x00800000>>(k+1)); - k = ((n&0x7fffffff)>>23) - 0x7f; /* new k for n */ - SET_FLOAT_WORD(t, n & ~(0x007fffff>>k)); - n = ((n&0x007fffff)|0x00800000)>>(23-k); - if (j < 0) - n = -n; - p_h -= t; - } - t = p_l + p_h; - GET_FLOAT_WORD(is, t); - SET_FLOAT_WORD(t, is & 0xffff8000); - u = t*lg2_h; - v = (p_l-(t-p_h))*lg2 + t*lg2_l; - z = u + v; - w = v - (z - u); - t = z*z; - t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - r = (z*t1)/(t1-2.0f) - (w+z*w); - z = 1.0f - (r - z); - GET_FLOAT_WORD(j, z); - j += n<<23; - if ((j>>23) <= 0) /* subnormal output */ - z = scalbnf(z, n); - else - SET_FLOAT_WORD(z, j); - return sn*z; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// expf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/e_expf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -static const float -half[2] = {0.5,-0.5}, -ln2hi = 6.9314575195e-1f, /* 0x3f317200 */ -ln2lo = 1.4286067653e-6f, /* 0x35bfbe8e */ -invln2 = 1.4426950216e+0f, /* 0x3fb8aa3b */ -/* - * Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]: - * |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74 - */ -expf_P1 = 1.6666625440e-1f, /* 0xaaaa8f.0p-26 */ -expf_P2 = -2.7667332906e-3f; /* -0xb55215.0p-32 */ - -float expf(float x) -{ - float_t hi, lo, c, xx, y; - int k, sign; - uint32_t hx; - - GET_FLOAT_WORD(hx, x); - sign = hx >> 31; /* sign bit of x */ - hx &= 0x7fffffff; /* high word of |x| */ - - /* special cases */ - if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */ - if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */ - /* overflow */ - x *= 0x1p127f; - return x; - } - if (sign) { - /* underflow */ - FORCE_EVAL(-0x1p-149f/x); - if (hx >= 0x42cff1b5) /* x <= -103.972084f */ - return 0; - } - } - - /* argument reduction */ - if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ - if (hx > 0x3f851592) /* if |x| > 1.5 ln2 */ - k = invln2*x + half[sign]; - else - k = 1 - sign - sign; - hi = x - k*ln2hi; /* k*ln2hi is exact here */ - lo = k*ln2lo; - x = hi - lo; - } else if (hx > 0x39000000) { /* |x| > 2**-14 */ - k = 0; - hi = x; - lo = 0; - } else { - /* raise inexact */ - FORCE_EVAL(0x1p127f + x); - return 1 + x; - } - - /* x is now in primary range */ - xx = x*x; - c = x - xx*(expf_P1+xx*expf_P2); - y = 1 + (x*c/(2-c) - lo + hi); - if (k == 0) - return y; - return scalbnf(y, k); -} - -/*****************************************************************************/ -/*****************************************************************************/ -// expm1f from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/s_expm1f.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -static const float -o_threshold = 8.8721679688e+01, /* 0x42b17180 */ -ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ -ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ -//invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */ -/* - * Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]: - * |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04 - * Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c): - */ -Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */ -Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */ - -float expm1f(float x) -{ - float_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk; - union {float f; uint32_t i;} u = {x}; - uint32_t hx = u.i & 0x7fffffff; - int k, sign = u.i >> 31; - - /* filter out huge and non-finite argument */ - if (hx >= 0x4195b844) { /* if |x|>=27*ln2 */ - if (hx > 0x7f800000) /* NaN */ - return x; - if (sign) - return -1; - if (x > o_threshold) { - x *= 0x1p127f; - return x; - } - } - - /* argument reduction */ - if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ - if (hx < 0x3F851592) { /* and |x| < 1.5 ln2 */ - if (!sign) { - hi = x - ln2_hi; - lo = ln2_lo; - k = 1; - } else { - hi = x + ln2_hi; - lo = -ln2_lo; - k = -1; - } - } else { - k = invln2*x + (sign ? -0.5f : 0.5f); - t = k; - hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ - lo = t*ln2_lo; - } - x = hi-lo; - c = (hi-x)-lo; - } else if (hx < 0x33000000) { /* when |x|<2**-25, return x */ - if (hx < 0x00800000) - FORCE_EVAL(x*x); - return x; - } else - k = 0; - - /* x is now in primary range */ - hfx = 0.5f*x; - hxs = x*hfx; - r1 = 1.0f+hxs*(Q1+hxs*Q2); - t = 3.0f - r1*hfx; - e = hxs*((r1-t)/(6.0f - x*t)); - if (k == 0) /* c is 0 */ - return x - (x*e-hxs); - e = x*(e-c) - c; - e -= hxs; - /* exp(x) ~ 2^k (x_reduced - e + 1) */ - if (k == -1) - return 0.5f*(x-e) - 0.5f; - if (k == 1) { - if (x < -0.25f) - return -2.0f*(e-(x+0.5f)); - return 1.0f + 2.0f*(x-e); - } - u.i = (0x7f+k)<<23; /* 2^k */ - twopk = u.f; - if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */ - y = x - e + 1.0f; - if (k == 128) - y = y*2.0f*0x1p127f; - else - y = y*twopk; - return y - 1.0f; - } - u.i = (0x7f-k)<<23; /* 2^-k */ - if (k < 23) - y = (x-e+(1-u.f))*twopk; - else - y = (x-(e+u.f)+1)*twopk; - return y; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// __expo2f from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN) */ -static const int k = 235; -static const float kln2 = 0x1.45c778p+7f; - -/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ -float __expo2f(float x) -{ - float scale; - - /* note that k is odd and scale*scale overflows */ - SET_FLOAT_WORD(scale, (uint32_t)(0x7f + k/2) << 23); - /* exp(x - k ln2) * 2**(k-1) */ - return expf(x - kln2) * scale * scale; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// logf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -/* origin: FreeBSD /usr/src/lib/msun/src/e_logf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -static const float -/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ -Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ -Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ -Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ -Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ - -float logf(float x) -{ - union {float f; uint32_t i;} u = {x}; - float_t hfsq,f,s,z,R,w,t1,t2,dk; - uint32_t ix; - int k; - - ix = u.i; - k = 0; - if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */ - if (ix<<1 == 0) - return -1/(x*x); /* log(+-0)=-inf */ - if (ix>>31) - return (x-x)/0.0f; /* log(-#) = NaN */ - /* subnormal number, scale up x */ - k -= 25; - x *= 0x1p25f; - u.f = x; - ix = u.i; - } else if (ix >= 0x7f800000) { - return x; - } else if (ix == 0x3f800000) - return 0; - - /* reduce x into [sqrt(2)/2, sqrt(2)] */ - ix += 0x3f800000 - 0x3f3504f3; - k += (int)(ix>>23) - 0x7f; - ix = (ix&0x007fffff) + 0x3f3504f3; - u.i = ix; - x = u.f; - - f = x - 1.0f; - s = f/(2.0f + f); - z = s*s; - w = z*z; - t1= w*(Lg2+w*Lg4); - t2= z*(Lg1+w*Lg3); - R = t2 + t1; - hfsq = 0.5f*f*f; - dk = k; - return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// coshf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -float coshf(float x) -{ - union {float f; uint32_t i;} u = {.f = x}; - uint32_t w; - float t; - - /* |x| */ - u.i &= 0x7fffffff; - x = u.f; - w = u.i; - - /* |x| < log(2) */ - if (w < 0x3f317217) { - if (w < 0x3f800000 - (12<<23)) { - FORCE_EVAL(x + 0x1p120f); - return 1; - } - t = expm1f(x); - return 1 + t*t/(2*(1+t)); - } - - /* |x| < log(FLT_MAX) */ - if (w < 0x42b17217) { - t = expf(x); - return 0.5f*(t + 1/t); - } - - /* |x| > log(FLT_MAX) or nan */ - t = __expo2f(x); - return t; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// sinhf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -float sinhf(float x) -{ - union {float f; uint32_t i;} u = {.f = x}; - uint32_t w; - float t, h, absx; - - h = 0.5; - if (u.i >> 31) - h = -h; - /* |x| */ - u.i &= 0x7fffffff; - absx = u.f; - w = u.i; - - /* |x| < log(FLT_MAX) */ - if (w < 0x42b17217) { - t = expm1f(absx); - if (w < 0x3f800000) { - if (w < 0x3f800000 - (12<<23)) - return x; - return h*(2*t - t*t/(t+1)); - } - return h*(t + t/(t+1)); - } - - /* |x| > logf(FLT_MAX) or nan */ - t = 2*h*__expo2f(absx); - return t; -} - -/*****************************************************************************/ -/*****************************************************************************/ -// ceilf, floorf and truncf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -float ceilf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = (int)(u.i >> 23 & 0xff) - 0x7f; - uint32_t m; - - if (e >= 23) - return x; - if (e >= 0) { - m = 0x007fffff >> e; - if ((u.i & m) == 0) - return x; - FORCE_EVAL(x + 0x1p120f); - if (u.i >> 31 == 0) - u.i += m; - u.i &= ~m; - } else { - FORCE_EVAL(x + 0x1p120f); - if (u.i >> 31) - u.f = -0.0; - else if (u.i << 1) - u.f = 1.0; - } - return u.f; -} - -float floorf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = (int)(u.i >> 23 & 0xff) - 0x7f; - uint32_t m; - - if (e >= 23) - return x; - if (e >= 0) { - m = 0x007fffff >> e; - if ((u.i & m) == 0) - return x; - FORCE_EVAL(x + 0x1p120f); - if (u.i >> 31) - u.i += m; - u.i &= ~m; - } else { - FORCE_EVAL(x + 0x1p120f); - if (u.i >> 31 == 0) - u.i = 0; - else if (u.i << 1) - u.f = -1.0; - } - return u.f; -} - -float truncf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9; - uint32_t m; - - if (e >= 23 + 9) - return x; - if (e < 9) - e = 1; - m = -1U >> e; - if ((u.i & m) == 0) - return x; - FORCE_EVAL(x + 0x1p120f); - u.i &= ~m; - return u.f; -} diff --git a/user/mpy/lib/libm/nearbyintf.c b/user/mpy/lib/libm/nearbyintf.c deleted file mode 100644 index 1c35459..0000000 --- a/user/mpy/lib/libm/nearbyintf.c +++ /dev/null @@ -1,21 +0,0 @@ -// adapted from the rintf() function from musl-1.1.16 - -#include "libm.h" - -float nearbyintf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = u.i>>23 & 0xff; - int s = u.i>>31; - float_t y; - - if (e >= 0x7f+23) - return x; - if (s) - y = x - 0x1p23f + 0x1p23f; - else - y = x + 0x1p23f - 0x1p23f; - if (y == 0) - return s ? -0.0f : 0.0f; - return y; -} diff --git a/user/mpy/lib/libm/roundf.c b/user/mpy/lib/libm/roundf.c deleted file mode 100644 index 3da1f05..0000000 --- a/user/mpy/lib/libm/roundf.c +++ /dev/null @@ -1,33 +0,0 @@ -/*****************************************************************************/ -/*****************************************************************************/ -// roundf from musl-0.9.15 -/*****************************************************************************/ -/*****************************************************************************/ - -#include "libm.h" - -float roundf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = u.i >> 23 & 0xff; - float_t y; - - if (e >= 0x7f+23) - return x; - if (u.i >> 31) - x = -x; - if (e < 0x7f-1) { - FORCE_EVAL(x + 0x1p23f); - return 0*u.f; - } - y = (float)(x + 0x1p23f) - 0x1p23f - x; - if (y > 0.5f) - y = y + x - 1; - else if (y <= -0.5f) - y = y + x + 1; - else - y = y + x; - if (u.i >> 31) - y = -y; - return y; -} diff --git a/user/mpy/lib/libm/sf_cos.c b/user/mpy/lib/libm/sf_cos.c deleted file mode 100644 index fabb129..0000000 --- a/user/mpy/lib/libm/sf_cos.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_cos.c -- float version of s_cos.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ - float cosf(float x) -#else - float cosf(x) - float x; -#endif -{ - float y[2],z=0.0; - __int32_t n,ix; - - GET_FLOAT_WORD(ix,x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if(ix <= 0x3f490fd8) return __kernel_cosf(x,z); - - /* cos(Inf or NaN) is NaN */ - else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; - - /* argument reduction needed */ - else { - n = __ieee754_rem_pio2f(x,y); - switch(n&3) { - case 0: return __kernel_cosf(y[0],y[1]); - case 1: return -__kernel_sinf(y[0],y[1],1); - case 2: return -__kernel_cosf(y[0],y[1]); - default: - return __kernel_sinf(y[0],y[1],1); - } - } -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double cos(double x) -#else - double cos(x) - double x; -#endif -{ - return (double) cosf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_erf.c b/user/mpy/lib/libm/sf_erf.c deleted file mode 100644 index 3f0172c..0000000 --- a/user/mpy/lib/libm/sf_erf.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_erf.c -- float version of s_erf.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#define __ieee754_expf expf - -#ifdef __v810__ -#define const -#endif - -#ifdef __STDC__ -static const float -#else -static float -#endif -tiny = 1e-30, -half= 5.0000000000e-01, /* 0x3F000000 */ -one = 1.0000000000e+00, /* 0x3F800000 */ -two = 2.0000000000e+00, /* 0x40000000 */ - /* c = (subfloat)0.84506291151 */ -erx = 8.4506291151e-01, /* 0x3f58560b */ -/* - * Coefficients for approximation to erf on [0,0.84375] - */ -efx = 1.2837916613e-01, /* 0x3e0375d4 */ -efx8= 1.0270333290e+00, /* 0x3f8375d4 */ -pp0 = 1.2837916613e-01, /* 0x3e0375d4 */ -pp1 = -3.2504209876e-01, /* 0xbea66beb */ -pp2 = -2.8481749818e-02, /* 0xbce9528f */ -pp3 = -5.7702702470e-03, /* 0xbbbd1489 */ -pp4 = -2.3763017452e-05, /* 0xb7c756b1 */ -qq1 = 3.9791721106e-01, /* 0x3ecbbbce */ -qq2 = 6.5022252500e-02, /* 0x3d852a63 */ -qq3 = 5.0813062117e-03, /* 0x3ba68116 */ -qq4 = 1.3249473704e-04, /* 0x390aee49 */ -qq5 = -3.9602282413e-06, /* 0xb684e21a */ -/* - * Coefficients for approximation to erf in [0.84375,1.25] - */ -pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */ -pa1 = 4.1485610604e-01, /* 0x3ed46805 */ -pa2 = -3.7220788002e-01, /* 0xbebe9208 */ -pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */ -pa4 = -1.1089469492e-01, /* 0xbde31cc2 */ -pa5 = 3.5478305072e-02, /* 0x3d1151b3 */ -pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */ -qa1 = 1.0642088205e-01, /* 0x3dd9f331 */ -qa2 = 5.4039794207e-01, /* 0x3f0a5785 */ -qa3 = 7.1828655899e-02, /* 0x3d931ae7 */ -qa4 = 1.2617121637e-01, /* 0x3e013307 */ -qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */ -qa6 = 1.1984500103e-02, /* 0x3c445aa3 */ -/* - * Coefficients for approximation to erfc in [1.25,1/0.35] - */ -ra0 = -9.8649440333e-03, /* 0xbc21a093 */ -ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */ -ra2 = -1.0558626175e+01, /* 0xc128f022 */ -ra3 = -6.2375331879e+01, /* 0xc2798057 */ -ra4 = -1.6239666748e+02, /* 0xc322658c */ -ra5 = -1.8460508728e+02, /* 0xc3389ae7 */ -ra6 = -8.1287437439e+01, /* 0xc2a2932b */ -ra7 = -9.8143291473e+00, /* 0xc11d077e */ -sa1 = 1.9651271820e+01, /* 0x419d35ce */ -sa2 = 1.3765776062e+02, /* 0x4309a863 */ -sa3 = 4.3456588745e+02, /* 0x43d9486f */ -sa4 = 6.4538726807e+02, /* 0x442158c9 */ -sa5 = 4.2900814819e+02, /* 0x43d6810b */ -sa6 = 1.0863500214e+02, /* 0x42d9451f */ -sa7 = 6.5702495575e+00, /* 0x40d23f7c */ -sa8 = -6.0424413532e-02, /* 0xbd777f97 */ -/* - * Coefficients for approximation to erfc in [1/.35,28] - */ -rb0 = -9.8649431020e-03, /* 0xbc21a092 */ -rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */ -rb2 = -1.7757955551e+01, /* 0xc18e104b */ -rb3 = -1.6063638306e+02, /* 0xc320a2ea */ -rb4 = -6.3756646729e+02, /* 0xc41f6441 */ -rb5 = -1.0250950928e+03, /* 0xc480230b */ -rb6 = -4.8351919556e+02, /* 0xc3f1c275 */ -sb1 = 3.0338060379e+01, /* 0x41f2b459 */ -sb2 = 3.2579251099e+02, /* 0x43a2e571 */ -sb3 = 1.5367296143e+03, /* 0x44c01759 */ -sb4 = 3.1998581543e+03, /* 0x4547fdbb */ -sb5 = 2.5530502930e+03, /* 0x451f90ce */ -sb6 = 4.7452853394e+02, /* 0x43ed43a7 */ -sb7 = -2.2440952301e+01; /* 0xc1b38712 */ - -#ifdef __STDC__ - float erff(float x) -#else - float erff(x) - float x; -#endif -{ - __int32_t hx,ix,i; - float R,S,P,Q,s,y,z,r; - GET_FLOAT_WORD(hx,x); - ix = hx&0x7fffffff; - if(!FLT_UWORD_IS_FINITE(ix)) { /* erf(nan)=nan */ - i = ((__uint32_t)hx>>31)<<1; - return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */ - } - - if(ix < 0x3f580000) { /* |x|<0.84375 */ - if(ix < 0x31800000) { /* |x|<2**-28 */ - if (ix < 0x04000000) - /*avoid underflow */ - return (float)0.125*((float)8.0*x+efx8*x); - return x + efx*x; - } - z = x*x; - r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); - s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); - y = r/s; - return x + x*y; - } - if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ - s = fabsf(x)-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if(hx>=0) return erx + P/Q; else return -erx - P/Q; - } - if (ix >= 0x40c00000) { /* inf>|x|>=6 */ - if(hx>=0) return one-tiny; else return tiny-one; - } - x = fabsf(x); - s = one/(x*x); - if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */ - R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( - ra5+s*(ra6+s*ra7)))))); - S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( - sa5+s*(sa6+s*(sa7+s*sa8))))))); - } else { /* |x| >= 1/0.35 */ - R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( - rb5+s*rb6))))); - S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( - sb5+s*(sb6+s*sb7)))))); - } - GET_FLOAT_WORD(ix,x); - SET_FLOAT_WORD(z,ix&0xfffff000); - r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S); - if(hx>=0) return one-r/x; else return r/x-one; -} - -#ifdef __STDC__ - float erfcf(float x) -#else - float erfcf(x) - float x; -#endif -{ - __int32_t hx,ix; - float R,S,P,Q,s,y,z,r; - GET_FLOAT_WORD(hx,x); - ix = hx&0x7fffffff; - if(!FLT_UWORD_IS_FINITE(ix)) { /* erfc(nan)=nan */ - /* erfc(+-inf)=0,2 */ - return (float)(((__uint32_t)hx>>31)<<1)+one/x; - } - - if(ix < 0x3f580000) { /* |x|<0.84375 */ - if(ix < 0x23800000) /* |x|<2**-56 */ - return one-x; - z = x*x; - r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); - s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); - y = r/s; - if(hx < 0x3e800000) { /* x<1/4 */ - return one-(x+x*y); - } else { - r = x*y; - r += (x-half); - return half - r ; - } - } - if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ - s = fabsf(x)-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if(hx>=0) { - z = one-erx; return z - P/Q; - } else { - z = erx+P/Q; return one+z; - } - } - if (ix < 0x41e00000) { /* |x|<28 */ - x = fabsf(x); - s = one/(x*x); - if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/ - R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( - ra5+s*(ra6+s*ra7)))))); - S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( - sa5+s*(sa6+s*(sa7+s*sa8))))))); - } else { /* |x| >= 1/.35 ~ 2.857143 */ - if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */ - R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( - rb5+s*rb6))))); - S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( - sb5+s*(sb6+s*sb7)))))); - } - GET_FLOAT_WORD(ix,x); - SET_FLOAT_WORD(z,ix&0xfffff000); - r = __ieee754_expf(-z*z-(float)0.5625)* - __ieee754_expf((z-x)*(z+x)+R/S); - if(hx>0) return r/x; else return two-r/x; - } else { - if(hx>0) return tiny*tiny; else return two-tiny; - } -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double erf(double x) -#else - double erf(x) - double x; -#endif -{ - return (double) erff((float) x); -} - -#ifdef __STDC__ - double erfc(double x) -#else - double erfc(x) - double x; -#endif -{ - return (double) erfcf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_frexp.c b/user/mpy/lib/libm/sf_frexp.c deleted file mode 100644 index df50fb7..0000000 --- a/user/mpy/lib/libm/sf_frexp.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_frexp.c -- float version of s_frexp.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ -static const float -#else -static float -#endif -two25 = 3.3554432000e+07; /* 0x4c000000 */ - -#ifdef __STDC__ - float frexpf(float x, int *eptr) -#else - float frexpf(x, eptr) - float x; int *eptr; -#endif -{ - __int32_t hx, ix; - GET_FLOAT_WORD(hx,x); - ix = 0x7fffffff&hx; - *eptr = 0; - if(!FLT_UWORD_IS_FINITE(ix)||FLT_UWORD_IS_ZERO(ix)) return x; /* 0,inf,nan */ - if (FLT_UWORD_IS_SUBNORMAL(ix)) { /* subnormal */ - x *= two25; - GET_FLOAT_WORD(hx,x); - ix = hx&0x7fffffff; - *eptr = -25; - } - *eptr += (ix>>23)-126; - hx = (hx&0x807fffff)|0x3f000000; - SET_FLOAT_WORD(x,hx); - return x; -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double frexp(double x, int *eptr) -#else - double frexp(x, eptr) - double x; int *eptr; -#endif -{ - return (double) frexpf((float) x, eptr); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_ldexp.c b/user/mpy/lib/libm/sf_ldexp.c deleted file mode 100644 index 37968d4..0000000 --- a/user/mpy/lib/libm/sf_ldexp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_ldexp.c -- float version of s_ldexp.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" -//#include - -#ifdef __STDC__ - float ldexpf(float value, int exp) -#else - float ldexpf(value, exp) - float value; int exp; -#endif -{ - if(!isfinite(value)||value==(float)0.0) return value; - value = scalbnf(value,exp); - //if(!finitef(value)||value==(float)0.0) errno = ERANGE; - return value; -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double ldexp(double value, int exp) -#else - double ldexp(value, exp) - double value; int exp; -#endif -{ - return (double) ldexpf((float) value, exp); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_modf.c b/user/mpy/lib/libm/sf_modf.c deleted file mode 100644 index 410db2a..0000000 --- a/user/mpy/lib/libm/sf_modf.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/common - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_modf.c -- float version of s_modf.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ -static const float one = 1.0; -#else -static float one = 1.0; -#endif - -#ifdef __STDC__ - float modff(float x, float *iptr) -#else - float modff(x, iptr) - float x,*iptr; -#endif -{ - __int32_t i0,j0; - __uint32_t i; - GET_FLOAT_WORD(i0,x); - j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ - if(j0<23) { /* integer part in x */ - if(j0<0) { /* |x|<1 */ - SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ - return x; - } else { - i = (0x007fffff)>>j0; - if((i0&i)==0) { /* x is integral */ - __uint32_t ix; - *iptr = x; - GET_FLOAT_WORD(ix,x); - SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ - return x; - } else { - SET_FLOAT_WORD(*iptr,i0&(~i)); - return x - *iptr; - } - } - } else { /* no fraction part */ - __uint32_t ix; - *iptr = x*one; - GET_FLOAT_WORD(ix,x); - SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ - return x; - } -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double modf(double x, double *iptr) -#else - double modf(x, iptr) - double x,*iptr; -#endif -{ - return (double) modff((float) x, (float *) iptr); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_sin.c b/user/mpy/lib/libm/sf_sin.c deleted file mode 100644 index d270507..0000000 --- a/user/mpy/lib/libm/sf_sin.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_sin.c -- float version of s_sin.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ - float sinf(float x) -#else - float sinf(x) - float x; -#endif -{ - float y[2],z=0.0; - __int32_t n,ix; - - GET_FLOAT_WORD(ix,x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0); - - /* sin(Inf or NaN) is NaN */ - else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; - - /* argument reduction needed */ - else { - n = __ieee754_rem_pio2f(x,y); - switch(n&3) { - case 0: return __kernel_sinf(y[0],y[1],1); - case 1: return __kernel_cosf(y[0],y[1]); - case 2: return -__kernel_sinf(y[0],y[1],1); - default: - return -__kernel_cosf(y[0],y[1]); - } - } -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double sin(double x) -#else - double sin(x) - double x; -#endif -{ - return (double) sinf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/sf_tan.c b/user/mpy/lib/libm/sf_tan.c deleted file mode 100644 index 148b16d..0000000 --- a/user/mpy/lib/libm/sf_tan.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* sf_tan.c -- float version of s_tan.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ - float tanf(float x) -#else - float tanf(x) - float x; -#endif -{ - float y[2],z=0.0; - __int32_t n,ix; - - GET_FLOAT_WORD(ix,x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1); - - /* tan(Inf or NaN) is NaN */ - else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; /* NaN */ - - /* argument reduction needed */ - else { - n = __ieee754_rem_pio2f(x,y); - return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even - -1 -- n odd */ - } -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double tan(double x) -#else - double tan(x) - double x; -#endif -{ - return (double) tanf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/thumb_vfp_sqrtf.c b/user/mpy/lib/libm/thumb_vfp_sqrtf.c deleted file mode 100644 index 12ffebf..0000000 --- a/user/mpy/lib/libm/thumb_vfp_sqrtf.c +++ /dev/null @@ -1,11 +0,0 @@ -// an implementation of sqrtf for Thumb using hardware VFP instructions - -#include - -float sqrtf(float x) { - asm volatile ( - "vsqrt.f32 %[r], %[x]\n" - : [r] "=t" (x) - : [x] "t" (x)); - return x; -} diff --git a/user/mpy/lib/libm/wf_lgamma.c b/user/mpy/lib/libm/wf_lgamma.c deleted file mode 100644 index d86ede7..0000000 --- a/user/mpy/lib/libm/wf_lgamma.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* wf_lgamma.c -- float version of w_lgamma.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -#include "fdlibm.h" -#define _IEEE_LIBM 1 -//#include -//#include - -#ifdef __STDC__ - float lgammaf(float x) -#else - float lgammaf(x) - float x; -#endif -{ -#ifdef _IEEE_LIBM - int sign; - return __ieee754_lgammaf_r(x,&sign); -#else - float y; - struct exception exc; - y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT))); - if(_LIB_VERSION == _IEEE_) return y; - if(!finitef(y)&&finitef(x)) { -#ifndef HUGE_VAL -#define HUGE_VAL inf - double inf = 0.0; - - SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ -#endif - exc.name = "lgammaf"; - exc.err = 0; - exc.arg1 = exc.arg2 = (double)x; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if(floorf(x)==x&&x<=(float)0.0) { - /* lgammaf(-integer) */ - exc.type = SING; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - - } else { - /* lgammaf(finite) overflow */ - exc.type = OVERFLOW; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - } - if (exc.err != 0) - errno = exc.err; - return (float)exc.retval; - } else - return y; -#endif -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double lgamma(double x) -#else - double lgamma(x) - double x; -#endif -{ - return (double) lgammaf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm/wf_tgamma.c b/user/mpy/lib/libm/wf_tgamma.c deleted file mode 100644 index 64b2488..0000000 --- a/user/mpy/lib/libm/wf_tgamma.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * These math functions are taken from newlib-nano-2, the newlib/libm/math - * directory, available from https://github.com/32bitmicro/newlib-nano-2. - * - * Appropriate copyright headers are reproduced below. - */ - -/* w_gammaf.c -- float version of w_gamma.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "math.h" -#include "fdlibm.h" -#define _IEEE_LIBM 1 - -#ifdef __STDC__ - float tgammaf(float x) -#else - float tgammaf(x) - float x; -#endif -{ - float y; - int local_signgam; - y = expf(__ieee754_lgammaf_r(x,&local_signgam)); - if (local_signgam < 0) y = -y; -#ifdef _IEEE_LIBM - return y; -#else - if(_LIB_VERSION == _IEEE_) return y; - - if(!finitef(y)&&finitef(x)) { - if(floorf(x)==x&&x<=(float)0.0) - /* tgammaf pole */ - return (float)__kernel_standard((double)x,(double)x,141); - else - /* tgammaf overflow */ - return (float)__kernel_standard((double)x,(double)x,140); - } - return y; -#endif -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double tgamma(double x) -#else - double tgamma(x) - double x; -#endif -{ - return (double) tgammaf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/user/mpy/lib/libm_dbl/README b/user/mpy/lib/libm_dbl/README deleted file mode 100644 index 512b328..0000000 --- a/user/mpy/lib/libm_dbl/README +++ /dev/null @@ -1,32 +0,0 @@ -This directory contains source code for the standard double-precision math -functions. - -The files lgamma.c, log10.c and tanh.c are too small to have a meaningful -copyright or license. - -The rest of the files in this directory are copied from the musl library, -v1.1.16, and, unless otherwise stated in the individual file, have the -following copyright and MIT license: - ----------------------------------------------------------------------- -Copyright © 2005-2014 Rich Felker, et al. - -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. ----------------------------------------------------------------------- diff --git a/user/mpy/lib/libm_dbl/__cos.c b/user/mpy/lib/libm_dbl/__cos.c deleted file mode 100644 index 46cefb3..0000000 --- a/user/mpy/lib/libm_dbl/__cos.c +++ /dev/null @@ -1,71 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/k_cos.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* - * __cos( x, y ) - * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 - * Input x is assumed to be bounded by ~pi/4 in magnitude. - * Input y is the tail of x. - * - * Algorithm - * 1. Since cos(-x) = cos(x), we need only to consider positive x. - * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0. - * 3. cos(x) is approximated by a polynomial of degree 14 on - * [0,pi/4] - * 4 14 - * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x - * where the remez error is - * - * | 2 4 6 8 10 12 14 | -58 - * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 - * | | - * - * 4 6 8 10 12 14 - * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then - * cos(x) ~ 1 - x*x/2 + r - * since cos(x+y) ~ cos(x) - sin(x)*y - * ~ cos(x) - x*y, - * a correction term is necessary in cos(x) and hence - * cos(x+y) = 1 - (x*x/2 - (r - x*y)) - * For better accuracy, rearrange to - * cos(x+y) ~ w + (tmp + (r-x*y)) - * where w = 1 - x*x/2 and tmp is a tiny correction term - * (1 - x*x/2 == w + tmp exactly in infinite precision). - * The exactness of w + tmp in infinite precision depends on w - * and tmp having the same precision as x. If they have extra - * precision due to compiler bugs, then the extra precision is - * only good provided it is retained in all terms of the final - * expression for cos(). Retention happens in all cases tested - * under FreeBSD, so don't pessimize things by forcibly clipping - * any extra precision in w. - */ - -#include "libm.h" - -static const double -C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ -C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ -C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ -C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ -C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ -C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ - -double __cos(double x, double y) -{ - double_t hz,z,r,w; - - z = x*x; - w = z*z; - r = z*(C1+z*(C2+z*C3)) + w*w*(C4+z*(C5+z*C6)); - hz = 0.5*z; - w = 1.0-hz; - return w + (((1.0-w)-hz) + (z*r-x*y)); -} diff --git a/user/mpy/lib/libm_dbl/__expo2.c b/user/mpy/lib/libm_dbl/__expo2.c deleted file mode 100644 index 740ac68..0000000 --- a/user/mpy/lib/libm_dbl/__expo2.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "libm.h" - -/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ -static const int k = 2043; -static const double kln2 = 0x1.62066151add8bp+10; - -/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ -double __expo2(double x) -{ - double scale; - - /* note that k is odd and scale*scale overflows */ - INSERT_WORDS(scale, (uint32_t)(0x3ff + k/2) << 20, 0); - /* exp(x - k ln2) * 2**(k-1) */ - return exp(x - kln2) * scale * scale; -} diff --git a/user/mpy/lib/libm_dbl/__fpclassify.c b/user/mpy/lib/libm_dbl/__fpclassify.c deleted file mode 100644 index 5c908ba..0000000 --- a/user/mpy/lib/libm_dbl/__fpclassify.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int __fpclassifyd(double x) -{ - union {double f; uint64_t i;} u = {x}; - int e = u.i>>52 & 0x7ff; - if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; - if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE; - return FP_NORMAL; -} diff --git a/user/mpy/lib/libm_dbl/__rem_pio2.c b/user/mpy/lib/libm_dbl/__rem_pio2.c deleted file mode 100644 index d403f81..0000000 --- a/user/mpy/lib/libm_dbl/__rem_pio2.c +++ /dev/null @@ -1,177 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - * Optimized by Bruce D. Evans. - */ -/* __rem_pio2(x,y) - * - * return the remainder of x rem pi/2 in y[0]+y[1] - * use __rem_pio2_large() for large x - */ - -#include "libm.h" - -#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 -#define EPS DBL_EPSILON -#elif FLT_EVAL_METHOD==2 -#define EPS LDBL_EPSILON -#endif - -/* - * invpio2: 53 bits of 2/pi - * pio2_1: first 33 bit of pi/2 - * pio2_1t: pi/2 - pio2_1 - * pio2_2: second 33 bit of pi/2 - * pio2_2t: pi/2 - (pio2_1+pio2_2) - * pio2_3: third 33 bit of pi/2 - * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) - */ -static const double -toint = 1.5/EPS, -invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ -pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */ -pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */ -pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */ -pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ -pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ -pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ - -/* caller must handle the case when reduction is not needed: |x| ~<= pi/4 */ -int __rem_pio2(double x, double *y) -{ - union {double f; uint64_t i;} u = {x}; - double_t z,w,t,r,fn; - double tx[3],ty[2]; - uint32_t ix; - int sign, n, ex, ey, i; - - sign = u.i>>63; - ix = u.i>>32 & 0x7fffffff; - if (ix <= 0x400f6a7a) { /* |x| ~<= 5pi/4 */ - if ((ix & 0xfffff) == 0x921fb) /* |x| ~= pi/2 or 2pi/2 */ - goto medium; /* cancellation -- use medium case */ - if (ix <= 0x4002d97c) { /* |x| ~<= 3pi/4 */ - if (!sign) { - z = x - pio2_1; /* one round good to 85 bits */ - y[0] = z - pio2_1t; - y[1] = (z-y[0]) - pio2_1t; - return 1; - } else { - z = x + pio2_1; - y[0] = z + pio2_1t; - y[1] = (z-y[0]) + pio2_1t; - return -1; - } - } else { - if (!sign) { - z = x - 2*pio2_1; - y[0] = z - 2*pio2_1t; - y[1] = (z-y[0]) - 2*pio2_1t; - return 2; - } else { - z = x + 2*pio2_1; - y[0] = z + 2*pio2_1t; - y[1] = (z-y[0]) + 2*pio2_1t; - return -2; - } - } - } - if (ix <= 0x401c463b) { /* |x| ~<= 9pi/4 */ - if (ix <= 0x4015fdbc) { /* |x| ~<= 7pi/4 */ - if (ix == 0x4012d97c) /* |x| ~= 3pi/2 */ - goto medium; - if (!sign) { - z = x - 3*pio2_1; - y[0] = z - 3*pio2_1t; - y[1] = (z-y[0]) - 3*pio2_1t; - return 3; - } else { - z = x + 3*pio2_1; - y[0] = z + 3*pio2_1t; - y[1] = (z-y[0]) + 3*pio2_1t; - return -3; - } - } else { - if (ix == 0x401921fb) /* |x| ~= 4pi/2 */ - goto medium; - if (!sign) { - z = x - 4*pio2_1; - y[0] = z - 4*pio2_1t; - y[1] = (z-y[0]) - 4*pio2_1t; - return 4; - } else { - z = x + 4*pio2_1; - y[0] = z + 4*pio2_1t; - y[1] = (z-y[0]) + 4*pio2_1t; - return -4; - } - } - } - if (ix < 0x413921fb) { /* |x| ~< 2^20*(pi/2), medium size */ -medium: - /* rint(x/(pi/2)), Assume round-to-nearest. */ - fn = (double_t)x*invpio2 + toint - toint; - n = (int32_t)fn; - r = x - fn*pio2_1; - w = fn*pio2_1t; /* 1st round, good to 85 bits */ - y[0] = r - w; - u.f = y[0]; - ey = u.i>>52 & 0x7ff; - ex = ix>>20; - if (ex - ey > 16) { /* 2nd round, good to 118 bits */ - t = r; - w = fn*pio2_2; - r = t - w; - w = fn*pio2_2t - ((t-r)-w); - y[0] = r - w; - u.f = y[0]; - ey = u.i>>52 & 0x7ff; - if (ex - ey > 49) { /* 3rd round, good to 151 bits, covers all cases */ - t = r; - w = fn*pio2_3; - r = t - w; - w = fn*pio2_3t - ((t-r)-w); - y[0] = r - w; - } - } - y[1] = (r - y[0]) - w; - return n; - } - /* - * all other (large) arguments - */ - if (ix >= 0x7ff00000) { /* x is inf or NaN */ - y[0] = y[1] = x - x; - return 0; - } - /* set z = scalbn(|x|,-ilogb(x)+23) */ - u.f = x; - u.i &= (uint64_t)-1>>12; - u.i |= (uint64_t)(0x3ff + 23)<<52; - z = u.f; - for (i=0; i < 2; i++) { - tx[i] = (double)(int32_t)z; - z = (z-tx[i])*0x1p24; - } - tx[i] = z; - /* skip zero terms, first term is non-zero */ - while (tx[i] == 0.0) - i--; - n = __rem_pio2_large(tx,ty,(int)(ix>>20)-(0x3ff+23),i+1,1); - if (sign) { - y[0] = -ty[0]; - y[1] = -ty[1]; - return -n; - } - y[0] = ty[0]; - y[1] = ty[1]; - return n; -} diff --git a/user/mpy/lib/libm_dbl/__rem_pio2_large.c b/user/mpy/lib/libm_dbl/__rem_pio2_large.c deleted file mode 100644 index 958f28c..0000000 --- a/user/mpy/lib/libm_dbl/__rem_pio2_large.c +++ /dev/null @@ -1,442 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/k_rem_pio2.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* - * __rem_pio2_large(x,y,e0,nx,prec) - * double x[],y[]; int e0,nx,prec; - * - * __rem_pio2_large return the last three digits of N with - * y = x - N*pi/2 - * so that |y| < pi/2. - * - * The method is to compute the integer (mod 8) and fraction parts of - * (2/pi)*x without doing the full multiplication. In general we - * skip the part of the product that are known to be a huge integer ( - * more accurately, = 0 mod 8 ). Thus the number of operations are - * independent of the exponent of the input. - * - * (2/pi) is represented by an array of 24-bit integers in ipio2[]. - * - * Input parameters: - * x[] The input value (must be positive) is broken into nx - * pieces of 24-bit integers in double precision format. - * x[i] will be the i-th 24 bit of x. The scaled exponent - * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 - * match x's up to 24 bits. - * - * Example of breaking a double positive z into x[0]+x[1]+x[2]: - * e0 = ilogb(z)-23 - * z = scalbn(z,-e0) - * for i = 0,1,2 - * x[i] = floor(z) - * z = (z-x[i])*2**24 - * - * - * y[] ouput result in an array of double precision numbers. - * The dimension of y[] is: - * 24-bit precision 1 - * 53-bit precision 2 - * 64-bit precision 2 - * 113-bit precision 3 - * The actual value is the sum of them. Thus for 113-bit - * precison, one may have to do something like: - * - * long double t,w,r_head, r_tail; - * t = (long double)y[2] + (long double)y[1]; - * w = (long double)y[0]; - * r_head = t+w; - * r_tail = w - (r_head - t); - * - * e0 The exponent of x[0]. Must be <= 16360 or you need to - * expand the ipio2 table. - * - * nx dimension of x[] - * - * prec an integer indicating the precision: - * 0 24 bits (single) - * 1 53 bits (double) - * 2 64 bits (extended) - * 3 113 bits (quad) - * - * External function: - * double scalbn(), floor(); - * - * - * Here is the description of some local variables: - * - * jk jk+1 is the initial number of terms of ipio2[] needed - * in the computation. The minimum and recommended value - * for jk is 3,4,4,6 for single, double, extended, and quad. - * jk+1 must be 2 larger than you might expect so that our - * recomputation test works. (Up to 24 bits in the integer - * part (the 24 bits of it that we compute) and 23 bits in - * the fraction part may be lost to cancelation before we - * recompute.) - * - * jz local integer variable indicating the number of - * terms of ipio2[] used. - * - * jx nx - 1 - * - * jv index for pointing to the suitable ipio2[] for the - * computation. In general, we want - * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8 - * is an integer. Thus - * e0-3-24*jv >= 0 or (e0-3)/24 >= jv - * Hence jv = max(0,(e0-3)/24). - * - * jp jp+1 is the number of terms in PIo2[] needed, jp = jk. - * - * q[] double array with integral value, representing the - * 24-bits chunk of the product of x and 2/pi. - * - * q0 the corresponding exponent of q[0]. Note that the - * exponent for q[i] would be q0-24*i. - * - * PIo2[] double precision array, obtained by cutting pi/2 - * into 24 bits chunks. - * - * f[] ipio2[] in floating point - * - * iq[] integer array by breaking up q[] in 24-bits chunk. - * - * fq[] final product of x*(2/pi) in fq[0],..,fq[jk] - * - * ih integer. If >0 it indicates q[] is >= 0.5, hence - * it also indicates the *sign* of the result. - * - */ -/* - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "libm.h" - -static const int init_jk[] = {3,4,4,6}; /* initial value for jk */ - -/* - * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi - * - * integer array, contains the (24*i)-th to (24*i+23)-th - * bit of 2/pi after binary point. The corresponding - * floating value is - * - * ipio2[i] * 2^(-24(i+1)). - * - * NB: This table must have at least (e0-3)/24 + jk terms. - * For quad precision (e0 <= 16360, jk = 6), this is 686. - */ -static const int32_t ipio2[] = { -0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, -0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, -0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, -0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, -0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, -0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, -0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, -0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, -0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, -0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, -0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, - -#if LDBL_MAX_EXP > 1024 -0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6, -0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2, -0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35, -0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30, -0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C, -0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4, -0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770, -0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7, -0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19, -0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522, -0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16, -0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6, -0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E, -0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48, -0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3, -0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF, -0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55, -0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612, -0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929, -0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC, -0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B, -0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C, -0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4, -0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB, -0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC, -0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C, -0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F, -0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5, -0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437, -0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B, -0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA, -0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD, -0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3, -0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3, -0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717, -0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F, -0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61, -0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB, -0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51, -0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0, -0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C, -0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6, -0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC, -0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED, -0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328, -0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D, -0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0, -0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B, -0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4, -0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3, -0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F, -0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD, -0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B, -0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4, -0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761, -0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31, -0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30, -0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262, -0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E, -0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1, -0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C, -0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4, -0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08, -0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196, -0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9, -0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4, -0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC, -0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C, -0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0, -0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C, -0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0, -0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC, -0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22, -0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893, -0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7, -0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5, -0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F, -0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4, -0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF, -0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B, -0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2, -0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138, -0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E, -0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569, -0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34, -0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9, -0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D, -0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F, -0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855, -0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569, -0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B, -0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE, -0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41, -0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49, -0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F, -0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110, -0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8, -0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365, -0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A, -0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270, -0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5, -0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616, -0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B, -0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0, -#endif -}; - -static const double PIo2[] = { - 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ - 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ - 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ - 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */ - 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */ - 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */ - 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */ - 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ -}; - -int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec) -{ - int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; - double z,fw,f[20],fq[20],q[20]; - - /* initialize jk*/ - jk = init_jk[prec]; - jp = jk; - - /* determine jx,jv,q0, note that 3>q0 */ - jx = nx-1; - jv = (e0-3)/24; if(jv<0) jv=0; - q0 = e0-24*(jv+1); - - /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ - j = jv-jx; m = jx+jk; - for (i=0; i<=m; i++,j++) - f[i] = j<0 ? 0.0 : (double)ipio2[j]; - - /* compute q[0],q[1],...q[jk] */ - for (i=0; i<=jk; i++) { - for (j=0,fw=0.0; j<=jx; j++) - fw += x[j]*f[jx+i-j]; - q[i] = fw; - } - - jz = jk; -recompute: - /* distill q[] into iq[] reversingly */ - for (i=0,j=jz,z=q[jz]; j>0; i++,j--) { - fw = (double)(int32_t)(0x1p-24*z); - iq[i] = (int32_t)(z - 0x1p24*fw); - z = q[j-1]+fw; - } - - /* compute n */ - z = scalbn(z,q0); /* actual value of z */ - z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */ - n = (int32_t)z; - z -= (double)n; - ih = 0; - if (q0 > 0) { /* need iq[jz-1] to determine n */ - i = iq[jz-1]>>(24-q0); n += i; - iq[jz-1] -= i<<(24-q0); - ih = iq[jz-1]>>(23-q0); - } - else if (q0 == 0) ih = iq[jz-1]>>23; - else if (z >= 0.5) ih = 2; - - if (ih > 0) { /* q > 0.5 */ - n += 1; carry = 0; - for (i=0; i 0) { /* rare case: chance is 1 in 12 */ - switch(q0) { - case 1: - iq[jz-1] &= 0x7fffff; break; - case 2: - iq[jz-1] &= 0x3fffff; break; - } - } - if (ih == 2) { - z = 1.0 - z; - if (carry != 0) - z -= scalbn(1.0,q0); - } - } - - /* check if recomputation is needed */ - if (z == 0.0) { - j = 0; - for (i=jz-1; i>=jk; i--) j |= iq[i]; - if (j == 0) { /* need recomputation */ - for (k=1; iq[jk-k]==0; k++); /* k = no. of terms needed */ - - for (i=jz+1; i<=jz+k; i++) { /* add q[jz+1] to q[jz+k] */ - f[jx+i] = (double)ipio2[jv+i]; - for (j=0,fw=0.0; j<=jx; j++) - fw += x[j]*f[jx+i-j]; - q[i] = fw; - } - jz += k; - goto recompute; - } - } - - /* chop off zero terms */ - if (z == 0.0) { - jz -= 1; - q0 -= 24; - while (iq[jz] == 0) { - jz--; - q0 -= 24; - } - } else { /* break z into 24-bit if necessary */ - z = scalbn(z,-q0); - if (z >= 0x1p24) { - fw = (double)(int32_t)(0x1p-24*z); - iq[jz] = (int32_t)(z - 0x1p24*fw); - jz += 1; - q0 += 24; - iq[jz] = (int32_t)fw; - } else - iq[jz] = (int32_t)z; - } - - /* convert integer "bit" chunk to floating-point value */ - fw = scalbn(1.0,q0); - for (i=jz; i>=0; i--) { - q[i] = fw*(double)iq[i]; - fw *= 0x1p-24; - } - - /* compute PIo2[0,...,jp]*q[jz,...,0] */ - for(i=jz; i>=0; i--) { - for (fw=0.0,k=0; k<=jp && k<=jz-i; k++) - fw += PIo2[k]*q[i+k]; - fq[jz-i] = fw; - } - - /* compress fq[] into y[] */ - switch(prec) { - case 0: - fw = 0.0; - for (i=jz; i>=0; i--) - fw += fq[i]; - y[0] = ih==0 ? fw : -fw; - break; - case 1: - case 2: - fw = 0.0; - for (i=jz; i>=0; i--) - fw += fq[i]; - // TODO: drop excess precision here once double_t is used - fw = (double)fw; - y[0] = ih==0 ? fw : -fw; - fw = fq[0]-fw; - for (i=1; i<=jz; i++) - fw += fq[i]; - y[1] = ih==0 ? fw : -fw; - break; - case 3: /* painful */ - for (i=jz; i>0; i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; - } - for (i=jz; i>1; i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; - } - for (fw=0.0,i=jz; i>=2; i--) - fw += fq[i]; - if (ih==0) { - y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; - } else { - y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; - } - } - return n&7; -} diff --git a/user/mpy/lib/libm_dbl/__signbit.c b/user/mpy/lib/libm_dbl/__signbit.c deleted file mode 100644 index 18c6728..0000000 --- a/user/mpy/lib/libm_dbl/__signbit.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "libm.h" - -int __signbitd(double x) -{ - union { - double d; - uint64_t i; - } y = { x }; - return y.i>>63; -} - - diff --git a/user/mpy/lib/libm_dbl/__sin.c b/user/mpy/lib/libm_dbl/__sin.c deleted file mode 100644 index 4030949..0000000 --- a/user/mpy/lib/libm_dbl/__sin.c +++ /dev/null @@ -1,64 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/k_sin.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* __sin( x, y, iy) - * kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854 - * Input x is assumed to be bounded by ~pi/4 in magnitude. - * Input y is the tail of x. - * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). - * - * Algorithm - * 1. Since sin(-x) = -sin(x), we need only to consider positive x. - * 2. Callers must return sin(-0) = -0 without calling here since our - * odd polynomial is not evaluated in a way that preserves -0. - * Callers may do the optimization sin(x) ~ x for tiny x. - * 3. sin(x) is approximated by a polynomial of degree 13 on - * [0,pi/4] - * 3 13 - * sin(x) ~ x + S1*x + ... + S6*x - * where - * - * |sin(x) 2 4 6 8 10 12 | -58 - * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 - * | x | - * - * 4. sin(x+y) = sin(x) + sin'(x')*y - * ~ sin(x) + (1-x*x/2)*y - * For better accuracy, let - * 3 2 2 2 2 - * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) - * then 3 2 - * sin(x) = x + (S1*x + (x *(r-y/2)+y)) - */ - -#include "libm.h" - -static const double -S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ -S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ -S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ -S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ -S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ -S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ - -double __sin(double x, double y, int iy) -{ - double_t z,r,v,w; - - z = x*x; - w = z*z; - r = S2 + z*(S3 + z*S4) + z*w*(S5 + z*S6); - v = z*x; - if (iy == 0) - return x + v*(S1 + z*r); - else - return x - ((z*(0.5*y - v*r) - y) - v*S1); -} diff --git a/user/mpy/lib/libm_dbl/__tan.c b/user/mpy/lib/libm_dbl/__tan.c deleted file mode 100644 index 8019844..0000000 --- a/user/mpy/lib/libm_dbl/__tan.c +++ /dev/null @@ -1,110 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/k_tan.c */ -/* - * ==================================================== - * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. - * - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* __tan( x, y, k ) - * kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854 - * Input x is assumed to be bounded by ~pi/4 in magnitude. - * Input y is the tail of x. - * Input odd indicates whether tan (if odd = 0) or -1/tan (if odd = 1) is returned. - * - * Algorithm - * 1. Since tan(-x) = -tan(x), we need only to consider positive x. - * 2. Callers must return tan(-0) = -0 without calling here since our - * odd polynomial is not evaluated in a way that preserves -0. - * Callers may do the optimization tan(x) ~ x for tiny x. - * 3. tan(x) is approximated by a odd polynomial of degree 27 on - * [0,0.67434] - * 3 27 - * tan(x) ~ x + T1*x + ... + T13*x - * where - * - * |tan(x) 2 4 26 | -59.2 - * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 - * | x | - * - * Note: tan(x+y) = tan(x) + tan'(x)*y - * ~ tan(x) + (1+x*x)*y - * Therefore, for better accuracy in computing tan(x+y), let - * 3 2 2 2 2 - * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) - * then - * 3 2 - * tan(x+y) = x + (T1*x + (x *(r+y)+y)) - * - * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then - * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) - * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) - */ - -#include "libm.h" - -static const double T[] = { - 3.33333333333334091986e-01, /* 3FD55555, 55555563 */ - 1.33333333333201242699e-01, /* 3FC11111, 1110FE7A */ - 5.39682539762260521377e-02, /* 3FABA1BA, 1BB341FE */ - 2.18694882948595424599e-02, /* 3F9664F4, 8406D637 */ - 8.86323982359930005737e-03, /* 3F8226E3, E96E8493 */ - 3.59207910759131235356e-03, /* 3F6D6D22, C9560328 */ - 1.45620945432529025516e-03, /* 3F57DBC8, FEE08315 */ - 5.88041240820264096874e-04, /* 3F4344D8, F2F26501 */ - 2.46463134818469906812e-04, /* 3F3026F7, 1A8D1068 */ - 7.81794442939557092300e-05, /* 3F147E88, A03792A6 */ - 7.14072491382608190305e-05, /* 3F12B80F, 32F0A7E9 */ - -1.85586374855275456654e-05, /* BEF375CB, DB605373 */ - 2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */ -}, -pio4 = 7.85398163397448278999e-01, /* 3FE921FB, 54442D18 */ -pio4lo = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */ - -double __tan(double x, double y, int odd) -{ - double_t z, r, v, w, s, a; - double w0, a0; - uint32_t hx; - int big, sign; - - GET_HIGH_WORD(hx,x); - big = (hx&0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */ - if (big) { - sign = hx>>31; - if (sign) { - x = -x; - y = -y; - } - x = (pio4 - x) + (pio4lo - y); - y = 0.0; - } - z = x * x; - w = z * z; - /* - * Break x^5*(T[1]+x^2*T[2]+...) into - * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + - * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) - */ - r = T[1] + w*(T[3] + w*(T[5] + w*(T[7] + w*(T[9] + w*T[11])))); - v = z*(T[2] + w*(T[4] + w*(T[6] + w*(T[8] + w*(T[10] + w*T[12]))))); - s = z * x; - r = y + z*(s*(r + v) + y) + s*T[0]; - w = x + r; - if (big) { - s = 1 - 2*odd; - v = s - 2.0 * (x + (r - w*w/(w + s))); - return sign ? -v : v; - } - if (!odd) - return w; - /* -1.0/(x+r) has up to 2ulp error, so compute it accurately */ - w0 = w; - SET_LOW_WORD(w0, 0); - v = r - (w0 - x); /* w0+v = r+x */ - a0 = a = -1.0 / w; - SET_LOW_WORD(a0, 0); - return a0 + a*(1.0 + a0*w0 + a0*v); -} diff --git a/user/mpy/lib/libm_dbl/acos.c b/user/mpy/lib/libm_dbl/acos.c deleted file mode 100644 index 6104a32..0000000 --- a/user/mpy/lib/libm_dbl/acos.c +++ /dev/null @@ -1,101 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_acos.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* acos(x) - * Method : - * acos(x) = pi/2 - asin(x) - * acos(-x) = pi/2 + asin(x) - * For |x|<=0.5 - * acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c) - * For x>0.5 - * acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2))) - * = 2asin(sqrt((1-x)/2)) - * = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z) - * = 2f + (2c + 2s*z*R(z)) - * where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term - * for f so that f+c ~ sqrt(z). - * For x<-0.5 - * acos(x) = pi - 2asin(sqrt((1-|x|)/2)) - * = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z) - * - * Special cases: - * if x is NaN, return x itself; - * if |x|>1, return NaN with invalid signal. - * - * Function needed: sqrt - */ - -#include "libm.h" - -static const double -pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ -pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ -pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ -pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ -pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ -pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ -pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ -pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ -qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ -qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ -qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ -qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ - -static double R(double z) -{ - double_t p, q; - p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); - q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4))); - return p/q; -} - -double acos(double x) -{ - double z,w,s,c,df; - uint32_t hx,ix; - - GET_HIGH_WORD(hx, x); - ix = hx & 0x7fffffff; - /* |x| >= 1 or nan */ - if (ix >= 0x3ff00000) { - uint32_t lx; - - GET_LOW_WORD(lx,x); - if (((ix-0x3ff00000) | lx) == 0) { - /* acos(1)=0, acos(-1)=pi */ - if (hx >> 31) - return 2*pio2_hi + 0x1p-120f; - return 0; - } - return 0/(x-x); - } - /* |x| < 0.5 */ - if (ix < 0x3fe00000) { - if (ix <= 0x3c600000) /* |x| < 2**-57 */ - return pio2_hi + 0x1p-120f; - return pio2_hi - (x - (pio2_lo-x*R(x*x))); - } - /* x < -0.5 */ - if (hx >> 31) { - z = (1.0+x)*0.5; - s = sqrt(z); - w = R(z)*s-pio2_lo; - return 2*(pio2_hi - (s+w)); - } - /* x > 0.5 */ - z = (1.0-x)*0.5; - s = sqrt(z); - df = s; - SET_LOW_WORD(df,0); - c = (z-df*df)/(s+df); - w = R(z)*s+c; - return 2*(df+w); -} diff --git a/user/mpy/lib/libm_dbl/acosh.c b/user/mpy/lib/libm_dbl/acosh.c deleted file mode 100644 index badbf90..0000000 --- a/user/mpy/lib/libm_dbl/acosh.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "libm.h" - -#if FLT_EVAL_METHOD==2 -#undef sqrt -#define sqrt sqrtl -#endif - -/* acosh(x) = log(x + sqrt(x*x-1)) */ -double acosh(double x) -{ - union {double f; uint64_t i;} u = {.f = x}; - unsigned e = u.i >> 52 & 0x7ff; - - /* x < 1 domain error is handled in the called functions */ - - if (e < 0x3ff + 1) - /* |x| < 2, up to 2ulp error in [1,1.125] */ - return log1p(x-1 + sqrt((x-1)*(x-1)+2*(x-1))); - if (e < 0x3ff + 26) - /* |x| < 0x1p26 */ - return log(2*x - 1/(x+sqrt(x*x-1))); - /* |x| >= 0x1p26 or nan */ - return log(x) + 0.693147180559945309417232121458176568; -} diff --git a/user/mpy/lib/libm_dbl/asin.c b/user/mpy/lib/libm_dbl/asin.c deleted file mode 100644 index 96b4cdf..0000000 --- a/user/mpy/lib/libm_dbl/asin.c +++ /dev/null @@ -1,107 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_asin.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* asin(x) - * Method : - * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... - * we approximate asin(x) on [0,0.5] by - * asin(x) = x + x*x^2*R(x^2) - * where - * R(x^2) is a rational approximation of (asin(x)-x)/x^3 - * and its remez error is bounded by - * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75) - * - * For x in [0.5,1] - * asin(x) = pi/2-2*asin(sqrt((1-x)/2)) - * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; - * then for x>0.98 - * asin(x) = pi/2 - 2*(s+s*z*R(z)) - * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) - * For x<=0.98, let pio4_hi = pio2_hi/2, then - * f = hi part of s; - * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) - * and - * asin(x) = pi/2 - 2*(s+s*z*R(z)) - * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) - * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) - * - * Special cases: - * if x is NaN, return x itself; - * if |x|>1, return NaN with invalid signal. - * - */ - -#include "libm.h" - -static const double -pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ -pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ -/* coefficients for R(x^2) */ -pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ -pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ -pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ -pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ -pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ -pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ -qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ -qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ -qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ -qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ - -static double R(double z) -{ - double_t p, q; - p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); - q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4))); - return p/q; -} - -double asin(double x) -{ - double z,r,s; - uint32_t hx,ix; - - GET_HIGH_WORD(hx, x); - ix = hx & 0x7fffffff; - /* |x| >= 1 or nan */ - if (ix >= 0x3ff00000) { - uint32_t lx; - GET_LOW_WORD(lx, x); - if (((ix-0x3ff00000) | lx) == 0) - /* asin(1) = +-pi/2 with inexact */ - return x*pio2_hi + 0x1p-120f; - return 0/(x-x); - } - /* |x| < 0.5 */ - if (ix < 0x3fe00000) { - /* if 0x1p-1022 <= |x| < 0x1p-26, avoid raising underflow */ - if (ix < 0x3e500000 && ix >= 0x00100000) - return x; - return x + x*R(x*x); - } - /* 1 > |x| >= 0.5 */ - z = (1 - fabs(x))*0.5; - s = sqrt(z); - r = R(z); - if (ix >= 0x3fef3333) { /* if |x| > 0.975 */ - x = pio2_hi-(2*(s+s*r)-pio2_lo); - } else { - double f,c; - /* f+c = sqrt(z) */ - f = s; - SET_LOW_WORD(f,0); - c = (z-f*f)/(s+f); - x = 0.5*pio2_hi - (2*s*r - (pio2_lo-2*c) - (0.5*pio2_hi-2*f)); - } - if (hx >> 31) - return -x; - return x; -} diff --git a/user/mpy/lib/libm_dbl/asinh.c b/user/mpy/lib/libm_dbl/asinh.c deleted file mode 100644 index 0829f22..0000000 --- a/user/mpy/lib/libm_dbl/asinh.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "libm.h" - -/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ -double asinh(double x) -{ - union {double f; uint64_t i;} u = {.f = x}; - unsigned e = u.i >> 52 & 0x7ff; - unsigned s = u.i >> 63; - - /* |x| */ - u.i &= (uint64_t)-1/2; - x = u.f; - - if (e >= 0x3ff + 26) { - /* |x| >= 0x1p26 or inf or nan */ - x = log(x) + 0.693147180559945309417232121458176568; - } else if (e >= 0x3ff + 1) { - /* |x| >= 2 */ - x = log(2*x + 1/(sqrt(x*x+1)+x)); - } else if (e >= 0x3ff - 26) { - /* |x| >= 0x1p-26, up to 1.6ulp error in [0.125,0.5] */ - x = log1p(x + x*x/(sqrt(x*x+1)+1)); - } else { - /* |x| < 0x1p-26, raise inexact if x != 0 */ - FORCE_EVAL(x + 0x1p120f); - } - return s ? -x : x; -} diff --git a/user/mpy/lib/libm_dbl/atan.c b/user/mpy/lib/libm_dbl/atan.c deleted file mode 100644 index 63b0ab2..0000000 --- a/user/mpy/lib/libm_dbl/atan.c +++ /dev/null @@ -1,116 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_atan.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* atan(x) - * Method - * 1. Reduce x to positive by atan(x) = -atan(-x). - * 2. According to the integer k=4t+0.25 chopped, t=x, the argument - * is further reduced to one of the following intervals and the - * arctangent of t is evaluated by the corresponding formula: - * - * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...) - * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) ) - * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) ) - * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) ) - * [39/16,INF] atan(x) = atan(INF) + atan( -1/t ) - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - - -#include "libm.h" - -static const double atanhi[] = { - 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ - 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */ - 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */ - 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */ -}; - -static const double atanlo[] = { - 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */ - 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */ - 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */ - 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ -}; - -static const double aT[] = { - 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ - -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ - 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ - -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */ - 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */ - -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */ - 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */ - -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */ - 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */ - -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */ - 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ -}; - -double atan(double x) -{ - double_t w,s1,s2,z; - uint32_t ix,sign; - int id; - - GET_HIGH_WORD(ix, x); - sign = ix >> 31; - ix &= 0x7fffffff; - if (ix >= 0x44100000) { /* if |x| >= 2^66 */ - if (isnan(x)) - return x; - z = atanhi[3] + 0x1p-120f; - return sign ? -z : z; - } - if (ix < 0x3fdc0000) { /* |x| < 0.4375 */ - if (ix < 0x3e400000) { /* |x| < 2^-27 */ - if (ix < 0x00100000) - /* raise underflow for subnormal x */ - FORCE_EVAL((float)x); - return x; - } - id = -1; - } else { - x = fabs(x); - if (ix < 0x3ff30000) { /* |x| < 1.1875 */ - if (ix < 0x3fe60000) { /* 7/16 <= |x| < 11/16 */ - id = 0; - x = (2.0*x-1.0)/(2.0+x); - } else { /* 11/16 <= |x| < 19/16 */ - id = 1; - x = (x-1.0)/(x+1.0); - } - } else { - if (ix < 0x40038000) { /* |x| < 2.4375 */ - id = 2; - x = (x-1.5)/(1.0+1.5*x); - } else { /* 2.4375 <= |x| < 2^66 */ - id = 3; - x = -1.0/x; - } - } - } - /* end of argument reduction */ - z = x*x; - w = z*z; - /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ - s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); - s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); - if (id < 0) - return x - x*(s1+s2); - z = atanhi[id] - (x*(s1+s2) - atanlo[id] - x); - return sign ? -z : z; -} diff --git a/user/mpy/lib/libm_dbl/atan2.c b/user/mpy/lib/libm_dbl/atan2.c deleted file mode 100644 index 91378b9..0000000 --- a/user/mpy/lib/libm_dbl/atan2.c +++ /dev/null @@ -1,107 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ -/* atan2(y,x) - * Method : - * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). - * 2. Reduce x to positive by (if x and y are unexceptional): - * ARG (x+iy) = arctan(y/x) ... if x > 0, - * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, - * - * Special cases: - * - * ATAN2((anything), NaN ) is NaN; - * ATAN2(NAN , (anything) ) is NaN; - * ATAN2(+-0, +(anything but NaN)) is +-0 ; - * ATAN2(+-0, -(anything but NaN)) is +-pi ; - * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; - * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; - * ATAN2(+-(anything but INF and NaN), -INF) is +-pi; - * ATAN2(+-INF,+INF ) is +-pi/4 ; - * ATAN2(+-INF,-INF ) is +-3pi/4; - * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "libm.h" - -static const double -pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ -pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ - -double atan2(double y, double x) -{ - double z; - uint32_t m,lx,ly,ix,iy; - - if (isnan(x) || isnan(y)) - return x+y; - EXTRACT_WORDS(ix, lx, x); - EXTRACT_WORDS(iy, ly, y); - if (((ix-0x3ff00000) | lx) == 0) /* x = 1.0 */ - return atan(y); - m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ - ix = ix & 0x7fffffff; - iy = iy & 0x7fffffff; - - /* when y = 0 */ - if ((iy|ly) == 0) { - switch(m) { - case 0: - case 1: return y; /* atan(+-0,+anything)=+-0 */ - case 2: return pi; /* atan(+0,-anything) = pi */ - case 3: return -pi; /* atan(-0,-anything) =-pi */ - } - } - /* when x = 0 */ - if ((ix|lx) == 0) - return m&1 ? -pi/2 : pi/2; - /* when x is INF */ - if (ix == 0x7ff00000) { - if (iy == 0x7ff00000) { - switch(m) { - case 0: return pi/4; /* atan(+INF,+INF) */ - case 1: return -pi/4; /* atan(-INF,+INF) */ - case 2: return 3*pi/4; /* atan(+INF,-INF) */ - case 3: return -3*pi/4; /* atan(-INF,-INF) */ - } - } else { - switch(m) { - case 0: return 0.0; /* atan(+...,+INF) */ - case 1: return -0.0; /* atan(-...,+INF) */ - case 2: return pi; /* atan(+...,-INF) */ - case 3: return -pi; /* atan(-...,-INF) */ - } - } - } - /* |y/x| > 0x1p64 */ - if (ix+(64<<20) < iy || iy == 0x7ff00000) - return m&1 ? -pi/2 : pi/2; - - /* z = atan(|y/x|) without spurious underflow */ - if ((m&2) && iy+(64<<20) < ix) /* |y/x| < 0x1p-64, x<0 */ - z = 0; - else - z = atan(fabs(y/x)); - switch (m) { - case 0: return z; /* atan(+,+) */ - case 1: return -z; /* atan(-,+) */ - case 2: return pi - (z-pi_lo); /* atan(+,-) */ - default: /* case 3 */ - return (z-pi_lo) - pi; /* atan(-,-) */ - } -} diff --git a/user/mpy/lib/libm_dbl/atanh.c b/user/mpy/lib/libm_dbl/atanh.c deleted file mode 100644 index 63a035d..0000000 --- a/user/mpy/lib/libm_dbl/atanh.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "libm.h" - -/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ -double atanh(double x) -{ - union {double f; uint64_t i;} u = {.f = x}; - unsigned e = u.i >> 52 & 0x7ff; - unsigned s = u.i >> 63; - double_t y; - - /* |x| */ - u.i &= (uint64_t)-1/2; - y = u.f; - - if (e < 0x3ff - 1) { - if (e < 0x3ff - 32) { - /* handle underflow */ - if (e == 0) - FORCE_EVAL((float)y); - } else { - /* |x| < 0.5, up to 1.7ulp error */ - y = 0.5*log1p(2*y + 2*y*y/(1-y)); - } - } else { - /* avoid overflow */ - y = 0.5*log1p(2*(y/(1-y))); - } - return s ? -y : y; -} diff --git a/user/mpy/lib/libm_dbl/ceil.c b/user/mpy/lib/libm_dbl/ceil.c deleted file mode 100644 index b13e6f2..0000000 --- a/user/mpy/lib/libm_dbl/ceil.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "libm.h" - -#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 -#define EPS DBL_EPSILON -#elif FLT_EVAL_METHOD==2 -#define EPS LDBL_EPSILON -#endif -static const double_t toint = 1/EPS; - -double ceil(double x) -{ - union {double f; uint64_t i;} u = {x}; - int e = u.i >> 52 & 0x7ff; - double_t y; - - if (e >= 0x3ff+52 || x == 0) - return x; - /* y = int(x) - x, where int(x) is an integer neighbor of x */ - if (u.i >> 63) - y = x - toint + toint - x; - else - y = x + toint - toint - x; - /* special case because of non-nearest rounding modes */ - if (e <= 0x3ff-1) { - FORCE_EVAL(y); - return u.i >> 63 ? -0.0 : 1; - } - if (y < 0) - return x + y + 1; - return x + y; -} diff --git a/user/mpy/lib/libm_dbl/cos.c b/user/mpy/lib/libm_dbl/cos.c deleted file mode 100644 index ee97f68..0000000 --- a/user/mpy/lib/libm_dbl/cos.c +++ /dev/null @@ -1,77 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* cos(x) - * Return cosine function of x. - * - * kernel function: - * __sin ... sine function on [-pi/4,pi/4] - * __cos ... cosine function on [-pi/4,pi/4] - * __rem_pio2 ... argument reduction routine - * - * Method. - * Let S,C and T denote the sin, cos and tan respectively on - * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 - * in [-pi/4 , +pi/4], and let n = k mod 4. - * We have - * - * n sin(x) cos(x) tan(x) - * ---------------------------------------------------------- - * 0 S C T - * 1 C -S -1/T - * 2 -S -C T - * 3 -C S -1/T - * ---------------------------------------------------------- - * - * Special cases: - * Let trig be any of sin, cos, or tan. - * trig(+-INF) is NaN, with signals; - * trig(NaN) is that NaN; - * - * Accuracy: - * TRIG(x) returns trig(x) nearly rounded - */ - -#include "libm.h" - -double cos(double x) -{ - double y[2]; - uint32_t ix; - unsigned n; - - GET_HIGH_WORD(ix, x); - ix &= 0x7fffffff; - - /* |x| ~< pi/4 */ - if (ix <= 0x3fe921fb) { - if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */ - /* raise inexact if x!=0 */ - FORCE_EVAL(x + 0x1p120f); - return 1.0; - } - return __cos(x, 0); - } - - /* cos(Inf or NaN) is NaN */ - if (ix >= 0x7ff00000) - return x-x; - - /* argument reduction */ - n = __rem_pio2(x, y); - switch (n&3) { - case 0: return __cos(y[0], y[1]); - case 1: return -__sin(y[0], y[1], 1); - case 2: return -__cos(y[0], y[1]); - default: - return __sin(y[0], y[1], 1); - } -} diff --git a/user/mpy/lib/libm_dbl/cosh.c b/user/mpy/lib/libm_dbl/cosh.c deleted file mode 100644 index 100f823..0000000 --- a/user/mpy/lib/libm_dbl/cosh.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "libm.h" - -/* cosh(x) = (exp(x) + 1/exp(x))/2 - * = 1 + 0.5*(exp(x)-1)*(exp(x)-1)/exp(x) - * = 1 + x*x/2 + o(x^4) - */ -double cosh(double x) -{ - union {double f; uint64_t i;} u = {.f = x}; - uint32_t w; - double t; - - /* |x| */ - u.i &= (uint64_t)-1/2; - x = u.f; - w = u.i >> 32; - - /* |x| < log(2) */ - if (w < 0x3fe62e42) { - if (w < 0x3ff00000 - (26<<20)) { - /* raise inexact if x!=0 */ - FORCE_EVAL(x + 0x1p120f); - return 1; - } - t = expm1(x); - return 1 + t*t/(2*(1+t)); - } - - /* |x| < log(DBL_MAX) */ - if (w < 0x40862e42) { - t = exp(x); - /* note: if x>log(0x1p26) then the 1/t is not needed */ - return 0.5*(t + 1/t); - } - - /* |x| > log(DBL_MAX) or nan */ - /* note: the result is stored to handle overflow */ - t = __expo2(x); - return t; -} diff --git a/user/mpy/lib/libm_dbl/erf.c b/user/mpy/lib/libm_dbl/erf.c deleted file mode 100644 index 2f30a29..0000000 --- a/user/mpy/lib/libm_dbl/erf.c +++ /dev/null @@ -1,273 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_erf.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* double erf(double x) - * double erfc(double x) - * x - * 2 |\ - * erf(x) = --------- | exp(-t*t)dt - * sqrt(pi) \| - * 0 - * - * erfc(x) = 1-erf(x) - * Note that - * erf(-x) = -erf(x) - * erfc(-x) = 2 - erfc(x) - * - * Method: - * 1. For |x| in [0, 0.84375] - * erf(x) = x + x*R(x^2) - * erfc(x) = 1 - erf(x) if x in [-.84375,0.25] - * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] - * where R = P/Q where P is an odd poly of degree 8 and - * Q is an odd poly of degree 10. - * -57.90 - * | R - (erf(x)-x)/x | <= 2 - * - * - * Remark. The formula is derived by noting - * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) - * and that - * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 - * is close to one. The interval is chosen because the fix - * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is - * near 0.6174), and by some experiment, 0.84375 is chosen to - * guarantee the error is less than one ulp for erf. - * - * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and - * c = 0.84506291151 rounded to single (24 bits) - * erf(x) = sign(x) * (c + P1(s)/Q1(s)) - * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0 - * 1+(c+P1(s)/Q1(s)) if x < 0 - * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06 - * Remark: here we use the taylor series expansion at x=1. - * erf(1+s) = erf(1) + s*Poly(s) - * = 0.845.. + P1(s)/Q1(s) - * That is, we use rational approximation to approximate - * erf(1+s) - (c = (single)0.84506291151) - * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] - * where - * P1(s) = degree 6 poly in s - * Q1(s) = degree 6 poly in s - * - * 3. For x in [1.25,1/0.35(~2.857143)], - * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1) - * erf(x) = 1 - erfc(x) - * where - * R1(z) = degree 7 poly in z, (z=1/x^2) - * S1(z) = degree 8 poly in z - * - * 4. For x in [1/0.35,28] - * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0 - * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6 x >= 28 - * erf(x) = sign(x) *(1 - tiny) (raise inexact) - * erfc(x) = tiny*tiny (raise underflow) if x > 0 - * = 2 - tiny if x<0 - * - * 7. Special case: - * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, - * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, - * erfc/erf(NaN) is NaN - */ - -#include "libm.h" - -static const double -erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ -/* - * Coefficients for approximation to erf on [0,0.84375] - */ -efx8 = 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ -pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */ -pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */ -pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */ -pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */ -pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */ -qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */ -qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */ -qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */ -qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */ -qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */ -/* - * Coefficients for approximation to erf in [0.84375,1.25] - */ -pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */ -pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */ -pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */ -pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */ -pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */ -pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */ -pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */ -qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */ -qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */ -qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */ -qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */ -qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */ -qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */ -/* - * Coefficients for approximation to erfc in [1.25,1/0.35] - */ -ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */ -ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */ -ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */ -ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */ -ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */ -ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */ -ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */ -ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */ -sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */ -sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */ -sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */ -sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */ -sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */ -sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */ -sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */ -sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */ -/* - * Coefficients for approximation to erfc in [1/.35,28] - */ -rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */ -rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */ -rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */ -rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */ -rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */ -rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */ -rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */ -sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ -sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */ -sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */ -sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */ -sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */ -sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ -sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ - -static double erfc1(double x) -{ - double_t s,P,Q; - - s = fabs(x) - 1; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = 1+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - return 1 - erx - P/Q; -} - -static double erfc2(uint32_t ix, double x) -{ - double_t s,R,S; - double z; - - if (ix < 0x3ff40000) /* |x| < 1.25 */ - return erfc1(x); - - x = fabs(x); - s = 1/(x*x); - if (ix < 0x4006db6d) { /* |x| < 1/.35 ~ 2.85714 */ - R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( - ra5+s*(ra6+s*ra7)))))); - S = 1.0+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( - sa5+s*(sa6+s*(sa7+s*sa8))))))); - } else { /* |x| > 1/.35 */ - R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( - rb5+s*rb6))))); - S = 1.0+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( - sb5+s*(sb6+s*sb7)))))); - } - z = x; - SET_LOW_WORD(z,0); - return exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S)/x; -} - -double erf(double x) -{ - double r,s,z,y; - uint32_t ix; - int sign; - - GET_HIGH_WORD(ix, x); - sign = ix>>31; - ix &= 0x7fffffff; - if (ix >= 0x7ff00000) { - /* erf(nan)=nan, erf(+-inf)=+-1 */ - return 1-2*sign + 1/x; - } - if (ix < 0x3feb0000) { /* |x| < 0.84375 */ - if (ix < 0x3e300000) { /* |x| < 2**-28 */ - /* avoid underflow */ - return 0.125*(8*x + efx8*x); - } - z = x*x; - r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); - s = 1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); - y = r/s; - return x + x*y; - } - if (ix < 0x40180000) /* 0.84375 <= |x| < 6 */ - y = 1 - erfc2(ix,x); - else - y = 1 - 0x1p-1022; - return sign ? -y : y; -} - -double erfc(double x) -{ - double r,s,z,y; - uint32_t ix; - int sign; - - GET_HIGH_WORD(ix, x); - sign = ix>>31; - ix &= 0x7fffffff; - if (ix >= 0x7ff00000) { - /* erfc(nan)=nan, erfc(+-inf)=0,2 */ - return 2*sign + 1/x; - } - if (ix < 0x3feb0000) { /* |x| < 0.84375 */ - if (ix < 0x3c700000) /* |x| < 2**-56 */ - return 1.0 - x; - z = x*x; - r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); - s = 1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); - y = r/s; - if (sign || ix < 0x3fd00000) { /* x < 1/4 */ - return 1.0 - (x+x*y); - } - return 0.5 - (x - 0.5 + x*y); - } - if (ix < 0x403c0000) { /* 0.84375 <= |x| < 28 */ - return sign ? 2 - erfc2(ix,x) : erfc2(ix,x); - } - return sign ? 2 - 0x1p-1022 : 0x1p-1022*0x1p-1022; -} diff --git a/user/mpy/lib/libm_dbl/exp.c b/user/mpy/lib/libm_dbl/exp.c deleted file mode 100644 index 9ea672f..0000000 --- a/user/mpy/lib/libm_dbl/exp.c +++ /dev/null @@ -1,134 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_exp.c */ -/* - * ==================================================== - * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. - * - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* exp(x) - * Returns the exponential of x. - * - * Method - * 1. Argument reduction: - * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. - * Given x, find r and integer k such that - * - * x = k*ln2 + r, |r| <= 0.5*ln2. - * - * Here r will be represented as r = hi-lo for better - * accuracy. - * - * 2. Approximation of exp(r) by a special rational function on - * the interval [0,0.34658]: - * Write - * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ... - * We use a special Remez algorithm on [0,0.34658] to generate - * a polynomial of degree 5 to approximate R. The maximum error - * of this polynomial approximation is bounded by 2**-59. In - * other words, - * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5 - * (where z=r*r, and the values of P1 to P5 are listed below) - * and - * | 5 | -59 - * | 2.0+P1*z+...+P5*z - R(z) | <= 2 - * | | - * The computation of exp(r) thus becomes - * 2*r - * exp(r) = 1 + ---------- - * R(r) - r - * r*c(r) - * = 1 + r + ----------- (for better accuracy) - * 2 - c(r) - * where - * 2 4 10 - * c(r) = r - (P1*r + P2*r + ... + P5*r ). - * - * 3. Scale back to obtain exp(x): - * From step 1, we have - * exp(x) = 2^k * exp(r) - * - * Special cases: - * exp(INF) is INF, exp(NaN) is NaN; - * exp(-INF) is 0, and - * for finite argument, only exp(0)=1 is exact. - * - * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). - * - * Misc. info. - * For IEEE double - * if x > 709.782712893383973096 then exp(x) overflows - * if x < -745.133219101941108420 then exp(x) underflows - */ - -#include "libm.h" - -static const double -half[2] = {0.5,-0.5}, -ln2hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ -ln2lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ -invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ -P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ -P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ -P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ -P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ -P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ - -double exp(double x) -{ - double_t hi, lo, c, xx, y; - int k, sign; - uint32_t hx; - - GET_HIGH_WORD(hx, x); - sign = hx>>31; - hx &= 0x7fffffff; /* high word of |x| */ - - /* special cases */ - if (hx >= 0x4086232b) { /* if |x| >= 708.39... */ - if (isnan(x)) - return x; - if (x > 709.782712893383973096) { - /* overflow if x!=inf */ - x *= 0x1p1023; - return x; - } - if (x < -708.39641853226410622) { - /* underflow if x!=-inf */ - FORCE_EVAL((float)(-0x1p-149/x)); - if (x < -745.13321910194110842) - return 0; - } - } - - /* argument reduction */ - if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ - if (hx >= 0x3ff0a2b2) /* if |x| >= 1.5 ln2 */ - k = (int)(invln2*x + half[sign]); - else - k = 1 - sign - sign; - hi = x - k*ln2hi; /* k*ln2hi is exact here */ - lo = k*ln2lo; - x = hi - lo; - } else if (hx > 0x3e300000) { /* if |x| > 2**-28 */ - k = 0; - hi = x; - lo = 0; - } else { - /* inexact if x!=0 */ - FORCE_EVAL(0x1p1023 + x); - return 1 + x; - } - - /* x is now in primary range */ - xx = x*x; - c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5)))); - y = 1 + (x*c/(2-c) - lo + hi); - if (k == 0) - return y; - return scalbn(y, k); -} diff --git a/user/mpy/lib/libm_dbl/expm1.c b/user/mpy/lib/libm_dbl/expm1.c deleted file mode 100644 index ac1e61e..0000000 --- a/user/mpy/lib/libm_dbl/expm1.c +++ /dev/null @@ -1,201 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_expm1.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* expm1(x) - * Returns exp(x)-1, the exponential of x minus 1. - * - * Method - * 1. Argument reduction: - * Given x, find r and integer k such that - * - * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658 - * - * Here a correction term c will be computed to compensate - * the error in r when rounded to a floating-point number. - * - * 2. Approximating expm1(r) by a special rational function on - * the interval [0,0.34658]: - * Since - * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... - * we define R1(r*r) by - * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) - * That is, - * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r) - * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) - * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ... - * We use a special Remez algorithm on [0,0.347] to generate - * a polynomial of degree 5 in r*r to approximate R1. The - * maximum error of this polynomial approximation is bounded - * by 2**-61. In other words, - * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5 - * where Q1 = -1.6666666666666567384E-2, - * Q2 = 3.9682539681370365873E-4, - * Q3 = -9.9206344733435987357E-6, - * Q4 = 2.5051361420808517002E-7, - * Q5 = -6.2843505682382617102E-9; - * z = r*r, - * with error bounded by - * | 5 | -61 - * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 - * | | - * - * expm1(r) = exp(r)-1 is then computed by the following - * specific way which minimize the accumulation rounding error: - * 2 3 - * r r [ 3 - (R1 + R1*r/2) ] - * expm1(r) = r + --- + --- * [--------------------] - * 2 2 [ 6 - r*(3 - R1*r/2) ] - * - * To compensate the error in the argument reduction, we use - * expm1(r+c) = expm1(r) + c + expm1(r)*c - * ~ expm1(r) + c + r*c - * Thus c+r*c will be added in as the correction terms for - * expm1(r+c). Now rearrange the term to avoid optimization - * screw up: - * ( 2 2 ) - * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r ) - * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) - * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) - * ( ) - * - * = r - E - * 3. Scale back to obtain expm1(x): - * From step 1, we have - * expm1(x) = either 2^k*[expm1(r)+1] - 1 - * = or 2^k*[expm1(r) + (1-2^-k)] - * 4. Implementation notes: - * (A). To save one multiplication, we scale the coefficient Qi - * to Qi*2^i, and replace z by (x^2)/2. - * (B). To achieve maximum accuracy, we compute expm1(x) by - * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf) - * (ii) if k=0, return r-E - * (iii) if k=-1, return 0.5*(r-E)-0.5 - * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) - * else return 1.0+2.0*(r-E); - * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) - * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else - * (vii) return 2^k(1-((E+2^-k)-r)) - * - * Special cases: - * expm1(INF) is INF, expm1(NaN) is NaN; - * expm1(-INF) is -1, and - * for finite argument, only expm1(0)=0 is exact. - * - * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). - * - * Misc. info. - * For IEEE double - * if x > 7.09782712893383973096e+02 then expm1(x) overflow - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "libm.h" - -static const double -o_threshold = 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ -ln2_hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ -ln2_lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ -invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ -/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */ -Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */ -Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */ -Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */ -Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */ -Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */ - -double expm1(double x) -{ - double_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk; - union {double f; uint64_t i;} u = {x}; - uint32_t hx = u.i>>32 & 0x7fffffff; - int k, sign = u.i>>63; - - /* filter out huge and non-finite argument */ - if (hx >= 0x4043687A) { /* if |x|>=56*ln2 */ - if (isnan(x)) - return x; - if (sign) - return -1; - if (x > o_threshold) { - x *= 0x1p1023; - return x; - } - } - - /* argument reduction */ - if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ - if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ - if (!sign) { - hi = x - ln2_hi; - lo = ln2_lo; - k = 1; - } else { - hi = x + ln2_hi; - lo = -ln2_lo; - k = -1; - } - } else { - k = invln2*x + (sign ? -0.5 : 0.5); - t = k; - hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ - lo = t*ln2_lo; - } - x = hi-lo; - c = (hi-x)-lo; - } else if (hx < 0x3c900000) { /* |x| < 2**-54, return x */ - if (hx < 0x00100000) - FORCE_EVAL((float)x); - return x; - } else - k = 0; - - /* x is now in primary range */ - hfx = 0.5*x; - hxs = x*hfx; - r1 = 1.0+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); - t = 3.0-r1*hfx; - e = hxs*((r1-t)/(6.0 - x*t)); - if (k == 0) /* c is 0 */ - return x - (x*e-hxs); - e = x*(e-c) - c; - e -= hxs; - /* exp(x) ~ 2^k (x_reduced - e + 1) */ - if (k == -1) - return 0.5*(x-e) - 0.5; - if (k == 1) { - if (x < -0.25) - return -2.0*(e-(x+0.5)); - return 1.0+2.0*(x-e); - } - u.i = (uint64_t)(0x3ff + k)<<52; /* 2^k */ - twopk = u.f; - if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */ - y = x - e + 1.0; - if (k == 1024) - y = y*2.0*0x1p1023; - else - y = y*twopk; - return y - 1.0; - } - u.i = (uint64_t)(0x3ff - k)<<52; /* 2^-k */ - if (k < 20) - y = (x-e+(1-u.f))*twopk; - else - y = (x-(e+u.f)+1)*twopk; - return y; -} diff --git a/user/mpy/lib/libm_dbl/floor.c b/user/mpy/lib/libm_dbl/floor.c deleted file mode 100644 index 14a31cd..0000000 --- a/user/mpy/lib/libm_dbl/floor.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "libm.h" - -#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 -#define EPS DBL_EPSILON -#elif FLT_EVAL_METHOD==2 -#define EPS LDBL_EPSILON -#endif -static const double_t toint = 1/EPS; - -double floor(double x) -{ - union {double f; uint64_t i;} u = {x}; - int e = u.i >> 52 & 0x7ff; - double_t y; - - if (e >= 0x3ff+52 || x == 0) - return x; - /* y = int(x) - x, where int(x) is an integer neighbor of x */ - if (u.i >> 63) - y = x - toint + toint - x; - else - y = x + toint - toint - x; - /* special case because of non-nearest rounding modes */ - if (e <= 0x3ff-1) { - FORCE_EVAL(y); - return u.i >> 63 ? -1 : 0; - } - if (y > 0) - return x + y - 1; - return x + y; -} diff --git a/user/mpy/lib/libm_dbl/fmod.c b/user/mpy/lib/libm_dbl/fmod.c deleted file mode 100644 index 6849722..0000000 --- a/user/mpy/lib/libm_dbl/fmod.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include - -double fmod(double x, double y) -{ - union {double f; uint64_t i;} ux = {x}, uy = {y}; - int ex = ux.i>>52 & 0x7ff; - int ey = uy.i>>52 & 0x7ff; - int sx = ux.i>>63; - uint64_t i; - - /* in the followings uxi should be ux.i, but then gcc wrongly adds */ - /* float load/store to inner loops ruining performance and code size */ - uint64_t uxi = ux.i; - - if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff) - return (x*y)/(x*y); - if (uxi<<1 <= uy.i<<1) { - if (uxi<<1 == uy.i<<1) - return 0*x; - return x; - } - - /* normalize x and y */ - if (!ex) { - for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1); - uxi <<= -ex + 1; - } else { - uxi &= -1ULL >> 12; - uxi |= 1ULL << 52; - } - if (!ey) { - for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1); - uy.i <<= -ey + 1; - } else { - uy.i &= -1ULL >> 12; - uy.i |= 1ULL << 52; - } - - /* x mod y */ - for (; ex > ey; ex--) { - i = uxi - uy.i; - if (i >> 63 == 0) { - if (i == 0) - return 0*x; - uxi = i; - } - uxi <<= 1; - } - i = uxi - uy.i; - if (i >> 63 == 0) { - if (i == 0) - return 0*x; - uxi = i; - } - for (; uxi>>52 == 0; uxi <<= 1, ex--); - - /* scale result */ - if (ex > 0) { - uxi -= 1ULL << 52; - uxi |= (uint64_t)ex << 52; - } else { - uxi >>= -ex + 1; - } - uxi |= (uint64_t)sx << 63; - ux.i = uxi; - return ux.f; -} diff --git a/user/mpy/lib/libm_dbl/frexp.c b/user/mpy/lib/libm_dbl/frexp.c deleted file mode 100644 index 27b6266..0000000 --- a/user/mpy/lib/libm_dbl/frexp.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -double frexp(double x, int *e) -{ - union { double d; uint64_t i; } y = { x }; - int ee = y.i>>52 & 0x7ff; - - if (!ee) { - if (x) { - x = frexp(x*0x1p64, e); - *e -= 64; - } else *e = 0; - return x; - } else if (ee == 0x7ff) { - return x; - } - - *e = ee - 0x3fe; - y.i &= 0x800fffffffffffffull; - y.i |= 0x3fe0000000000000ull; - return y.d; -} diff --git a/user/mpy/lib/libm_dbl/ldexp.c b/user/mpy/lib/libm_dbl/ldexp.c deleted file mode 100644 index f4d1cd6..0000000 --- a/user/mpy/lib/libm_dbl/ldexp.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -double ldexp(double x, int n) -{ - return scalbn(x, n); -} diff --git a/user/mpy/lib/libm_dbl/lgamma.c b/user/mpy/lib/libm_dbl/lgamma.c deleted file mode 100644 index ed193da..0000000 --- a/user/mpy/lib/libm_dbl/lgamma.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -double __lgamma_r(double, int*); - -double lgamma(double x) { - int sign; - return __lgamma_r(x, &sign); -} diff --git a/user/mpy/lib/libm_dbl/libm.h b/user/mpy/lib/libm_dbl/libm.h deleted file mode 100644 index dc0b431..0000000 --- a/user/mpy/lib/libm_dbl/libm.h +++ /dev/null @@ -1,96 +0,0 @@ -// Portions of this file are extracted from musl-1.1.16 src/internal/libm.h - -/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include -#include - -#define FLT_EVAL_METHOD 0 - -#define FORCE_EVAL(x) do { \ - if (sizeof(x) == sizeof(float)) { \ - volatile float __x; \ - __x = (x); \ - (void)__x; \ - } else if (sizeof(x) == sizeof(double)) { \ - volatile double __x; \ - __x = (x); \ - (void)__x; \ - } else { \ - volatile long double __x; \ - __x = (x); \ - (void)__x; \ - } \ -} while(0) - -/* Get two 32 bit ints from a double. */ -#define EXTRACT_WORDS(hi,lo,d) \ -do { \ - union {double f; uint64_t i;} __u; \ - __u.f = (d); \ - (hi) = __u.i >> 32; \ - (lo) = (uint32_t)__u.i; \ -} while (0) - -/* Get the more significant 32 bit int from a double. */ -#define GET_HIGH_WORD(hi,d) \ -do { \ - union {double f; uint64_t i;} __u; \ - __u.f = (d); \ - (hi) = __u.i >> 32; \ -} while (0) - -/* Get the less significant 32 bit int from a double. */ -#define GET_LOW_WORD(lo,d) \ -do { \ - union {double f; uint64_t i;} __u; \ - __u.f = (d); \ - (lo) = (uint32_t)__u.i; \ -} while (0) - -/* Set a double from two 32 bit ints. */ -#define INSERT_WORDS(d,hi,lo) \ -do { \ - union {double f; uint64_t i;} __u; \ - __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \ - (d) = __u.f; \ -} while (0) - -/* Set the more significant 32 bits of a double from an int. */ -#define SET_HIGH_WORD(d,hi) \ -do { \ - union {double f; uint64_t i;} __u; \ - __u.f = (d); \ - __u.i &= 0xffffffff; \ - __u.i |= (uint64_t)(hi) << 32; \ - (d) = __u.f; \ -} while (0) - -/* Set the less significant 32 bits of a double from an int. */ -#define SET_LOW_WORD(d,lo) \ -do { \ - union {double f; uint64_t i;} __u; \ - __u.f = (d); \ - __u.i &= 0xffffffff00000000ull; \ - __u.i |= (uint32_t)(lo); \ - (d) = __u.f; \ -} while (0) - -#define DBL_EPSILON 2.22044604925031308085e-16 - -int __rem_pio2(double, double*); -int __rem_pio2_large(double*, double*, int, int, int); -double __sin(double, double, int); -double __cos(double, double); -double __tan(double, double, int); -double __expo2(double); diff --git a/user/mpy/lib/libm_dbl/log.c b/user/mpy/lib/libm_dbl/log.c deleted file mode 100644 index e61e113..0000000 --- a/user/mpy/lib/libm_dbl/log.c +++ /dev/null @@ -1,118 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_log.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* log(x) - * Return the logarithm of x - * - * Method : - * 1. Argument Reduction: find k and f such that - * x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * 2. Approximation of log(1+f). - * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * = 2s + s*R - * We use a special Remez algorithm on [0,0.1716] to generate - * a polynomial of degree 14 to approximate R The maximum error - * of this polynomial approximation is bounded by 2**-58.45. In - * other words, - * 2 4 6 8 10 12 14 - * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s - * (the values of Lg1 to Lg7 are listed in the program) - * and - * | 2 14 | -58.45 - * | Lg1*s +...+Lg7*s - R(z) | <= 2 - * | | - * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. - * In order to guarantee error in log below 1ulp, we compute log - * by - * log(1+f) = f - s*(f - R) (if f is not too large) - * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) - * - * 3. Finally, log(x) = k*ln2 + log(1+f). - * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) - * Here ln2 is split into two floating point number: - * ln2_hi + ln2_lo, - * where n*ln2_hi is always exact for |n| < 2000. - * - * Special cases: - * log(x) is NaN with signal if x < 0 (including -INF) ; - * log(+INF) is +INF; log(0) is -INF with signal; - * log(NaN) is that NaN with no signal. - * - * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include -#include - -static const double -ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ -ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ -Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ -Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ -Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ -Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ -Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ -Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ -Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ - -double log(double x) -{ - union {double f; uint64_t i;} u = {x}; - double_t hfsq,f,s,z,R,w,t1,t2,dk; - uint32_t hx; - int k; - - hx = u.i>>32; - k = 0; - if (hx < 0x00100000 || hx>>31) { - if (u.i<<1 == 0) - return -1/(x*x); /* log(+-0)=-inf */ - if (hx>>31) - return (x-x)/0.0; /* log(-#) = NaN */ - /* subnormal number, scale x up */ - k -= 54; - x *= 0x1p54; - u.f = x; - hx = u.i>>32; - } else if (hx >= 0x7ff00000) { - return x; - } else if (hx == 0x3ff00000 && u.i<<32 == 0) - return 0; - - /* reduce x into [sqrt(2)/2, sqrt(2)] */ - hx += 0x3ff00000 - 0x3fe6a09e; - k += (int)(hx>>20) - 0x3ff; - hx = (hx&0x000fffff) + 0x3fe6a09e; - u.i = (uint64_t)hx<<32 | (u.i&0xffffffff); - x = u.f; - - f = x - 1.0; - hfsq = 0.5*f*f; - s = f/(2.0+f); - z = s*s; - w = z*z; - t1 = w*(Lg2+w*(Lg4+w*Lg6)); - t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); - R = t2 + t1; - dk = k; - return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi; -} diff --git a/user/mpy/lib/libm_dbl/log10.c b/user/mpy/lib/libm_dbl/log10.c deleted file mode 100644 index bddedd6..0000000 --- a/user/mpy/lib/libm_dbl/log10.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -static const double _M_LN10 = 2.302585092994046; - -double log10(double x) { - return log(x) / (double)_M_LN10; -} diff --git a/user/mpy/lib/libm_dbl/log1p.c b/user/mpy/lib/libm_dbl/log1p.c deleted file mode 100644 index 0097134..0000000 --- a/user/mpy/lib/libm_dbl/log1p.c +++ /dev/null @@ -1,122 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_log1p.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* double log1p(double x) - * Return the natural logarithm of 1+x. - * - * Method : - * 1. Argument Reduction: find k and f such that - * 1+x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * Note. If k=0, then f=x is exact. However, if k!=0, then f - * may not be representable exactly. In that case, a correction - * term is need. Let u=1+x rounded. Let c = (1+x)-u, then - * log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u), - * and add back the correction term c/u. - * (Note: when x > 2**53, one can simply return log(x)) - * - * 2. Approximation of log(1+f): See log.c - * - * 3. Finally, log1p(x) = k*ln2 + log(1+f) + c/u. See log.c - * - * Special cases: - * log1p(x) is NaN with signal if x < -1 (including -INF) ; - * log1p(+INF) is +INF; log1p(-1) is -INF with signal; - * log1p(NaN) is that NaN with no signal. - * - * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - * - * Note: Assuming log() return accurate answer, the following - * algorithm can be used to compute log1p(x) to within a few ULP: - * - * u = 1+x; - * if(u==1.0) return x ; else - * return log(u)*(x/(u-1.0)); - * - * See HP-15C Advanced Functions Handbook, p.193. - */ - -#include "libm.h" - -static const double -ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ -ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ -Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ -Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ -Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ -Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ -Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ -Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ -Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ - -double log1p(double x) -{ - union {double f; uint64_t i;} u = {x}; - double_t hfsq,f,c,s,z,R,w,t1,t2,dk; - uint32_t hx,hu; - int k; - - hx = u.i>>32; - k = 1; - if (hx < 0x3fda827a || hx>>31) { /* 1+x < sqrt(2)+ */ - if (hx >= 0xbff00000) { /* x <= -1.0 */ - if (x == -1) - return x/0.0; /* log1p(-1) = -inf */ - return (x-x)/0.0; /* log1p(x<-1) = NaN */ - } - if (hx<<1 < 0x3ca00000<<1) { /* |x| < 2**-53 */ - /* underflow if subnormal */ - if ((hx&0x7ff00000) == 0) - FORCE_EVAL((float)x); - return x; - } - if (hx <= 0xbfd2bec4) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */ - k = 0; - c = 0; - f = x; - } - } else if (hx >= 0x7ff00000) - return x; - if (k) { - u.f = 1 + x; - hu = u.i>>32; - hu += 0x3ff00000 - 0x3fe6a09e; - k = (int)(hu>>20) - 0x3ff; - /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ - if (k < 54) { - c = k >= 2 ? 1-(u.f-x) : x-(u.f-1); - c /= u.f; - } else - c = 0; - /* reduce u into [sqrt(2)/2, sqrt(2)] */ - hu = (hu&0x000fffff) + 0x3fe6a09e; - u.i = (uint64_t)hu<<32 | (u.i&0xffffffff); - f = u.f - 1; - } - hfsq = 0.5*f*f; - s = f/(2.0+f); - z = s*s; - w = z*z; - t1 = w*(Lg2+w*(Lg4+w*Lg6)); - t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); - R = t2 + t1; - dk = k; - return s*(hfsq+R) + (dk*ln2_lo+c) - hfsq + f + dk*ln2_hi; -} diff --git a/user/mpy/lib/libm_dbl/modf.c b/user/mpy/lib/libm_dbl/modf.c deleted file mode 100644 index 1c8a1db..0000000 --- a/user/mpy/lib/libm_dbl/modf.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "libm.h" - -double modf(double x, double *iptr) -{ - union {double f; uint64_t i;} u = {x}; - uint64_t mask; - int e = (int)(u.i>>52 & 0x7ff) - 0x3ff; - - /* no fractional part */ - if (e >= 52) { - *iptr = x; - if (e == 0x400 && u.i<<12 != 0) /* nan */ - return x; - u.i &= 1ULL<<63; - return u.f; - } - - /* no integral part*/ - if (e < 0) { - u.i &= 1ULL<<63; - *iptr = u.f; - return x; - } - - mask = -1ULL>>12>>e; - if ((u.i & mask) == 0) { - *iptr = x; - u.i &= 1ULL<<63; - return u.f; - } - u.i &= ~mask; - *iptr = u.f; - return x - u.f; -} diff --git a/user/mpy/lib/libm_dbl/nearbyint.c b/user/mpy/lib/libm_dbl/nearbyint.c deleted file mode 100644 index 6e9b0c1..0000000 --- a/user/mpy/lib/libm_dbl/nearbyint.c +++ /dev/null @@ -1,20 +0,0 @@ -//#include -#include - -/* nearbyint is the same as rint, but it must not raise the inexact exception */ - -double nearbyint(double x) -{ -#ifdef FE_INEXACT - #pragma STDC FENV_ACCESS ON - int e; - - e = fetestexcept(FE_INEXACT); -#endif - x = rint(x); -#ifdef FE_INEXACT - if (!e) - feclearexcept(FE_INEXACT); -#endif - return x; -} diff --git a/user/mpy/lib/libm_dbl/pow.c b/user/mpy/lib/libm_dbl/pow.c deleted file mode 100644 index 3ddc1b6..0000000 --- a/user/mpy/lib/libm_dbl/pow.c +++ /dev/null @@ -1,328 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_pow.c */ -/* - * ==================================================== - * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. - * - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* pow(x,y) return x**y - * - * n - * Method: Let x = 2 * (1+f) - * 1. Compute and return log2(x) in two pieces: - * log2(x) = w1 + w2, - * where w1 has 53-24 = 29 bit trailing zeros. - * 2. Perform y*log2(x) = n+y' by simulating muti-precision - * arithmetic, where |y'|<=0.5. - * 3. Return x**y = 2**n*exp(y'*log2) - * - * Special cases: - * 1. (anything) ** 0 is 1 - * 2. 1 ** (anything) is 1 - * 3. (anything except 1) ** NAN is NAN - * 4. NAN ** (anything except 0) is NAN - * 5. +-(|x| > 1) ** +INF is +INF - * 6. +-(|x| > 1) ** -INF is +0 - * 7. +-(|x| < 1) ** +INF is +0 - * 8. +-(|x| < 1) ** -INF is +INF - * 9. -1 ** +-INF is 1 - * 10. +0 ** (+anything except 0, NAN) is +0 - * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 - * 12. +0 ** (-anything except 0, NAN) is +INF, raise divbyzero - * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF, raise divbyzero - * 14. -0 ** (+odd integer) is -0 - * 15. -0 ** (-odd integer) is -INF, raise divbyzero - * 16. +INF ** (+anything except 0,NAN) is +INF - * 17. +INF ** (-anything except 0,NAN) is +0 - * 18. -INF ** (+odd integer) is -INF - * 19. -INF ** (anything) = -0 ** (-anything), (anything except odd integer) - * 20. (anything) ** 1 is (anything) - * 21. (anything) ** -1 is 1/(anything) - * 22. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) - * 23. (-anything except 0 and inf) ** (non-integer) is NAN - * - * Accuracy: - * pow(x,y) returns x**y nearly rounded. In particular - * pow(integer,integer) - * always returns the correct integer provided it is - * representable. - * - * Constants : - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "libm.h" - -static const double -bp[] = {1.0, 1.5,}, -dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ -dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ -two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ -huge = 1.0e300, -tiny = 1.0e-300, -/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ -L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ -L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ -L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ -L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ -L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ -L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ -P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ -P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ -P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ -P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ -P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ -lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ -lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ -lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ -ovt = 8.0085662595372944372e-017, /* -(1024-log2(ovfl+.5ulp)) */ -cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ -cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ -cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ -ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ -ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ -ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ - -double pow(double x, double y) -{ - double z,ax,z_h,z_l,p_h,p_l; - double y1,t1,t2,r,s,t,u,v,w; - int32_t i,j,k,yisint,n; - int32_t hx,hy,ix,iy; - uint32_t lx,ly; - - EXTRACT_WORDS(hx, lx, x); - EXTRACT_WORDS(hy, ly, y); - ix = hx & 0x7fffffff; - iy = hy & 0x7fffffff; - - /* x**0 = 1, even if x is NaN */ - if ((iy|ly) == 0) - return 1.0; - /* 1**y = 1, even if y is NaN */ - if (hx == 0x3ff00000 && lx == 0) - return 1.0; - /* NaN if either arg is NaN */ - if (ix > 0x7ff00000 || (ix == 0x7ff00000 && lx != 0) || - iy > 0x7ff00000 || (iy == 0x7ff00000 && ly != 0)) - return x + y; - - /* determine if y is an odd int when x < 0 - * yisint = 0 ... y is not an integer - * yisint = 1 ... y is an odd int - * yisint = 2 ... y is an even int - */ - yisint = 0; - if (hx < 0) { - if (iy >= 0x43400000) - yisint = 2; /* even integer y */ - else if (iy >= 0x3ff00000) { - k = (iy>>20) - 0x3ff; /* exponent */ - if (k > 20) { - uint32_t j = ly>>(52-k); - if ((j<<(52-k)) == ly) - yisint = 2 - (j&1); - } else if (ly == 0) { - uint32_t j = iy>>(20-k); - if ((j<<(20-k)) == iy) - yisint = 2 - (j&1); - } - } - } - - /* special value of y */ - if (ly == 0) { - if (iy == 0x7ff00000) { /* y is +-inf */ - if (((ix-0x3ff00000)|lx) == 0) /* (-1)**+-inf is 1 */ - return 1.0; - else if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */ - return hy >= 0 ? y : 0.0; - else /* (|x|<1)**+-inf = 0,inf */ - return hy >= 0 ? 0.0 : -y; - } - if (iy == 0x3ff00000) { /* y is +-1 */ - if (hy >= 0) - return x; - y = 1/x; -#if FLT_EVAL_METHOD!=0 - { - union {double f; uint64_t i;} u = {y}; - uint64_t i = u.i & -1ULL/2; - if (i>>52 == 0 && (i&(i-1))) - FORCE_EVAL((float)y); - } -#endif - return y; - } - if (hy == 0x40000000) /* y is 2 */ - return x*x; - if (hy == 0x3fe00000) { /* y is 0.5 */ - if (hx >= 0) /* x >= +0 */ - return sqrt(x); - } - } - - ax = fabs(x); - /* special value of x */ - if (lx == 0) { - if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) { /* x is +-0,+-inf,+-1 */ - z = ax; - if (hy < 0) /* z = (1/|x|) */ - z = 1.0/z; - if (hx < 0) { - if (((ix-0x3ff00000)|yisint) == 0) { - z = (z-z)/(z-z); /* (-1)**non-int is NaN */ - } else if (yisint == 1) - z = -z; /* (x<0)**odd = -(|x|**odd) */ - } - return z; - } - } - - s = 1.0; /* sign of result */ - if (hx < 0) { - if (yisint == 0) /* (x<0)**(non-int) is NaN */ - return (x-x)/(x-x); - if (yisint == 1) /* (x<0)**(odd int) */ - s = -1.0; - } - - /* |y| is huge */ - if (iy > 0x41e00000) { /* if |y| > 2**31 */ - if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */ - if (ix <= 0x3fefffff) - return hy < 0 ? huge*huge : tiny*tiny; - if (ix >= 0x3ff00000) - return hy > 0 ? huge*huge : tiny*tiny; - } - /* over/underflow if x is not close to one */ - if (ix < 0x3fefffff) - return hy < 0 ? s*huge*huge : s*tiny*tiny; - if (ix > 0x3ff00000) - return hy > 0 ? s*huge*huge : s*tiny*tiny; - /* now |1-x| is tiny <= 2**-20, suffice to compute - log(x) by x-x^2/2+x^3/3-x^4/4 */ - t = ax - 1.0; /* t has 20 trailing zeros */ - w = (t*t)*(0.5 - t*(0.3333333333333333333333-t*0.25)); - u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ - v = t*ivln2_l - w*ivln2; - t1 = u + v; - SET_LOW_WORD(t1, 0); - t2 = v - (t1-u); - } else { - double ss,s2,s_h,s_l,t_h,t_l; - n = 0; - /* take care subnormal number */ - if (ix < 0x00100000) { - ax *= two53; - n -= 53; - GET_HIGH_WORD(ix,ax); - } - n += ((ix)>>20) - 0x3ff; - j = ix & 0x000fffff; - /* determine interval */ - ix = j | 0x3ff00000; /* normalize ix */ - if (j <= 0x3988E) /* |x|>1)|0x20000000) + 0x00080000 + (k<<18)); - t_l = ax - (t_h-bp[k]); - s_l = v*((u-s_h*t_h)-s_h*t_l); - /* compute log(ax) */ - s2 = ss*ss; - r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); - r += s_l*(s_h+ss); - s2 = s_h*s_h; - t_h = 3.0 + s2 + r; - SET_LOW_WORD(t_h, 0); - t_l = r - ((t_h-3.0)-s2); - /* u+v = ss*(1+...) */ - u = s_h*t_h; - v = s_l*t_h + t_l*ss; - /* 2/(3log2)*(ss+...) */ - p_h = u + v; - SET_LOW_WORD(p_h, 0); - p_l = v - (p_h-u); - z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ - z_l = cp_l*p_h+p_l*cp + dp_l[k]; - /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */ - t = (double)n; - t1 = ((z_h + z_l) + dp_h[k]) + t; - SET_LOW_WORD(t1, 0); - t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); - } - - /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ - y1 = y; - SET_LOW_WORD(y1, 0); - p_l = (y-y1)*t1 + y*t2; - p_h = y1*t1; - z = p_l + p_h; - EXTRACT_WORDS(j, i, z); - if (j >= 0x40900000) { /* z >= 1024 */ - if (((j-0x40900000)|i) != 0) /* if z > 1024 */ - return s*huge*huge; /* overflow */ - if (p_l + ovt > z - p_h) - return s*huge*huge; /* overflow */ - } else if ((j&0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */ // FIXME: instead of abs(j) use unsigned j - if (((j-0xc090cc00)|i) != 0) /* z < -1075 */ - return s*tiny*tiny; /* underflow */ - if (p_l <= z - p_h) - return s*tiny*tiny; /* underflow */ - } - /* - * compute 2**(p_h+p_l) - */ - i = j & 0x7fffffff; - k = (i>>20) - 0x3ff; - n = 0; - if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ - n = j + (0x00100000>>(k+1)); - k = ((n&0x7fffffff)>>20) - 0x3ff; /* new k for n */ - t = 0.0; - SET_HIGH_WORD(t, n & ~(0x000fffff>>k)); - n = ((n&0x000fffff)|0x00100000)>>(20-k); - if (j < 0) - n = -n; - p_h -= t; - } - t = p_l + p_h; - SET_LOW_WORD(t, 0); - u = t*lg2_h; - v = (p_l-(t-p_h))*lg2 + t*lg2_l; - z = u + v; - w = v - (z-u); - t = z*z; - t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - r = (z*t1)/(t1-2.0) - (w + z*w); - z = 1.0 - (r-z); - GET_HIGH_WORD(j, z); - j += n<<20; - if ((j>>20) <= 0) /* subnormal output */ - z = scalbn(z,n); - else - SET_HIGH_WORD(z, j); - return s*z; -} diff --git a/user/mpy/lib/libm_dbl/rint.c b/user/mpy/lib/libm_dbl/rint.c deleted file mode 100644 index fbba390..0000000 --- a/user/mpy/lib/libm_dbl/rint.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 -#define EPS DBL_EPSILON -#elif FLT_EVAL_METHOD==2 -#define EPS LDBL_EPSILON -#endif -static const double_t toint = 1/EPS; - -double rint(double x) -{ - union {double f; uint64_t i;} u = {x}; - int e = u.i>>52 & 0x7ff; - int s = u.i>>63; - double_t y; - - if (e >= 0x3ff+52) - return x; - if (s) - y = x - toint + toint; - else - y = x + toint - toint; - if (y == 0) - return s ? -0.0 : 0; - return y; -} diff --git a/user/mpy/lib/libm_dbl/scalbn.c b/user/mpy/lib/libm_dbl/scalbn.c deleted file mode 100644 index 182f561..0000000 --- a/user/mpy/lib/libm_dbl/scalbn.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -double scalbn(double x, int n) -{ - union {double f; uint64_t i;} u; - double_t y = x; - - if (n > 1023) { - y *= 0x1p1023; - n -= 1023; - if (n > 1023) { - y *= 0x1p1023; - n -= 1023; - if (n > 1023) - n = 1023; - } - } else if (n < -1022) { - /* make sure final n < -53 to avoid double - rounding in the subnormal range */ - y *= 0x1p-1022 * 0x1p53; - n += 1022 - 53; - if (n < -1022) { - y *= 0x1p-1022 * 0x1p53; - n += 1022 - 53; - if (n < -1022) - n = -1022; - } - } - u.i = (uint64_t)(0x3ff+n)<<52; - x = y * u.f; - return x; -} diff --git a/user/mpy/lib/libm_dbl/sin.c b/user/mpy/lib/libm_dbl/sin.c deleted file mode 100644 index 055e215..0000000 --- a/user/mpy/lib/libm_dbl/sin.c +++ /dev/null @@ -1,78 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* sin(x) - * Return sine function of x. - * - * kernel function: - * __sin ... sine function on [-pi/4,pi/4] - * __cos ... cose function on [-pi/4,pi/4] - * __rem_pio2 ... argument reduction routine - * - * Method. - * Let S,C and T denote the sin, cos and tan respectively on - * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 - * in [-pi/4 , +pi/4], and let n = k mod 4. - * We have - * - * n sin(x) cos(x) tan(x) - * ---------------------------------------------------------- - * 0 S C T - * 1 C -S -1/T - * 2 -S -C T - * 3 -C S -1/T - * ---------------------------------------------------------- - * - * Special cases: - * Let trig be any of sin, cos, or tan. - * trig(+-INF) is NaN, with signals; - * trig(NaN) is that NaN; - * - * Accuracy: - * TRIG(x) returns trig(x) nearly rounded - */ - -#include "libm.h" - -double sin(double x) -{ - double y[2]; - uint32_t ix; - unsigned n; - - /* High word of x. */ - GET_HIGH_WORD(ix, x); - ix &= 0x7fffffff; - - /* |x| ~< pi/4 */ - if (ix <= 0x3fe921fb) { - if (ix < 0x3e500000) { /* |x| < 2**-26 */ - /* raise inexact if x != 0 and underflow if subnormal*/ - FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); - return x; - } - return __sin(x, 0.0, 0); - } - - /* sin(Inf or NaN) is NaN */ - if (ix >= 0x7ff00000) - return x - x; - - /* argument reduction needed */ - n = __rem_pio2(x, y); - switch (n&3) { - case 0: return __sin(y[0], y[1], 1); - case 1: return __cos(y[0], y[1]); - case 2: return -__sin(y[0], y[1], 1); - default: - return -__cos(y[0], y[1]); - } -} diff --git a/user/mpy/lib/libm_dbl/sinh.c b/user/mpy/lib/libm_dbl/sinh.c deleted file mode 100644 index 00022c4..0000000 --- a/user/mpy/lib/libm_dbl/sinh.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "libm.h" - -/* sinh(x) = (exp(x) - 1/exp(x))/2 - * = (exp(x)-1 + (exp(x)-1)/exp(x))/2 - * = x + x^3/6 + o(x^5) - */ -double sinh(double x) -{ - union {double f; uint64_t i;} u = {.f = x}; - uint32_t w; - double t, h, absx; - - h = 0.5; - if (u.i >> 63) - h = -h; - /* |x| */ - u.i &= (uint64_t)-1/2; - absx = u.f; - w = u.i >> 32; - - /* |x| < log(DBL_MAX) */ - if (w < 0x40862e42) { - t = expm1(absx); - if (w < 0x3ff00000) { - if (w < 0x3ff00000 - (26<<20)) - /* note: inexact and underflow are raised by expm1 */ - /* note: this branch avoids spurious underflow */ - return x; - return h*(2*t - t*t/(t+1)); - } - /* note: |x|>log(0x1p26)+eps could be just h*exp(x) */ - return h*(t + t/(t+1)); - } - - /* |x| > log(DBL_MAX) or nan */ - /* note: the result is stored to handle overflow */ - t = 2*h*__expo2(absx); - return t; -} diff --git a/user/mpy/lib/libm_dbl/sqrt.c b/user/mpy/lib/libm_dbl/sqrt.c deleted file mode 100644 index b277567..0000000 --- a/user/mpy/lib/libm_dbl/sqrt.c +++ /dev/null @@ -1,185 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrt.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* sqrt(x) - * Return correctly rounded sqrt. - * ------------------------------------------ - * | Use the hardware sqrt if you have one | - * ------------------------------------------ - * Method: - * Bit by bit method using integer arithmetic. (Slow, but portable) - * 1. Normalization - * Scale x to y in [1,4) with even powers of 2: - * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then - * sqrt(x) = 2^k * sqrt(y) - * 2. Bit by bit computation - * Let q = sqrt(y) truncated to i bit after binary point (q = 1), - * i 0 - * i+1 2 - * s = 2*q , and y = 2 * ( y - q ). (1) - * i i i i - * - * To compute q from q , one checks whether - * i+1 i - * - * -(i+1) 2 - * (q + 2 ) <= y. (2) - * i - * -(i+1) - * If (2) is false, then q = q ; otherwise q = q + 2 . - * i+1 i i+1 i - * - * With some algebric manipulation, it is not difficult to see - * that (2) is equivalent to - * -(i+1) - * s + 2 <= y (3) - * i i - * - * The advantage of (3) is that s and y can be computed by - * i i - * the following recurrence formula: - * if (3) is false - * - * s = s , y = y ; (4) - * i+1 i i+1 i - * - * otherwise, - * -i -(i+1) - * s = s + 2 , y = y - s - 2 (5) - * i+1 i i+1 i i - * - * One may easily use induction to prove (4) and (5). - * Note. Since the left hand side of (3) contain only i+2 bits, - * it does not necessary to do a full (53-bit) comparison - * in (3). - * 3. Final rounding - * After generating the 53 bits result, we compute one more bit. - * Together with the remainder, we can decide whether the - * result is exact, bigger than 1/2ulp, or less than 1/2ulp - * (it will never equal to 1/2ulp). - * The rounding mode can be detected by checking whether - * huge + tiny is equal to huge, and whether huge - tiny is - * equal to huge for some floating point number "huge" and "tiny". - * - * Special cases: - * sqrt(+-0) = +-0 ... exact - * sqrt(inf) = inf - * sqrt(-ve) = NaN ... with invalid signal - * sqrt(NaN) = NaN ... with invalid signal for signaling NaN - */ - -#include "libm.h" - -static const double tiny = 1.0e-300; - -double sqrt(double x) -{ - double z; - int32_t sign = (int)0x80000000; - int32_t ix0,s0,q,m,t,i; - uint32_t r,t1,s1,ix1,q1; - - EXTRACT_WORDS(ix0, ix1, x); - - /* take care of Inf and NaN */ - if ((ix0&0x7ff00000) == 0x7ff00000) { - return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */ - } - /* take care of zero */ - if (ix0 <= 0) { - if (((ix0&~sign)|ix1) == 0) - return x; /* sqrt(+-0) = +-0 */ - if (ix0 < 0) - return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ - } - /* normalize x */ - m = ix0>>20; - if (m == 0) { /* subnormal x */ - while (ix0 == 0) { - m -= 21; - ix0 |= (ix1>>11); - ix1 <<= 21; - } - for (i=0; (ix0&0x00100000) == 0; i++) - ix0<<=1; - m -= i - 1; - ix0 |= ix1>>(32-i); - ix1 <<= i; - } - m -= 1023; /* unbias exponent */ - ix0 = (ix0&0x000fffff)|0x00100000; - if (m & 1) { /* odd m, double x to make it even */ - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - } - m >>= 1; /* m = [m/2] */ - - /* generate sqrt(x) bit by bit */ - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ - r = 0x00200000; /* r = moving bit from right to left */ - - while (r != 0) { - t = s0 + r; - if (t <= ix0) { - s0 = t + r; - ix0 -= t; - q += r; - } - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - r >>= 1; - } - - r = sign; - while (r != 0) { - t1 = s1 + r; - t = s0; - if (t < ix0 || (t == ix0 && t1 <= ix1)) { - s1 = t1 + r; - if ((t1&sign) == sign && (s1&sign) == 0) - s0++; - ix0 -= t; - if (ix1 < t1) - ix0--; - ix1 -= t1; - q1 += r; - } - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - r >>= 1; - } - - /* use floating add to find out rounding direction */ - if ((ix0|ix1) != 0) { - z = 1.0 - tiny; /* raise inexact flag */ - if (z >= 1.0) { - z = 1.0 + tiny; - if (q1 == (uint32_t)0xffffffff) { - q1 = 0; - q++; - } else if (z > 1.0) { - if (q1 == (uint32_t)0xfffffffe) - q++; - q1 += 2; - } else - q1 += q1 & 1; - } - } - ix0 = (q>>1) + 0x3fe00000; - ix1 = q1>>1; - if (q&1) - ix1 |= sign; - ix0 += m << 20; - INSERT_WORDS(z, ix0, ix1); - return z; -} diff --git a/user/mpy/lib/libm_dbl/tan.c b/user/mpy/lib/libm_dbl/tan.c deleted file mode 100644 index 9c724a4..0000000 --- a/user/mpy/lib/libm_dbl/tan.c +++ /dev/null @@ -1,70 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* tan(x) - * Return tangent function of x. - * - * kernel function: - * __tan ... tangent function on [-pi/4,pi/4] - * __rem_pio2 ... argument reduction routine - * - * Method. - * Let S,C and T denote the sin, cos and tan respectively on - * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 - * in [-pi/4 , +pi/4], and let n = k mod 4. - * We have - * - * n sin(x) cos(x) tan(x) - * ---------------------------------------------------------- - * 0 S C T - * 1 C -S -1/T - * 2 -S -C T - * 3 -C S -1/T - * ---------------------------------------------------------- - * - * Special cases: - * Let trig be any of sin, cos, or tan. - * trig(+-INF) is NaN, with signals; - * trig(NaN) is that NaN; - * - * Accuracy: - * TRIG(x) returns trig(x) nearly rounded - */ - -#include "libm.h" - -double tan(double x) -{ - double y[2]; - uint32_t ix; - unsigned n; - - GET_HIGH_WORD(ix, x); - ix &= 0x7fffffff; - - /* |x| ~< pi/4 */ - if (ix <= 0x3fe921fb) { - if (ix < 0x3e400000) { /* |x| < 2**-27 */ - /* raise inexact if x!=0 and underflow if subnormal */ - FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f); - return x; - } - return __tan(x, 0.0, 0); - } - - /* tan(Inf or NaN) is NaN */ - if (ix >= 0x7ff00000) - return x - x; - - /* argument reduction */ - n = __rem_pio2(x, y); - return __tan(y[0], y[1], n&1); -} diff --git a/user/mpy/lib/libm_dbl/tanh.c b/user/mpy/lib/libm_dbl/tanh.c deleted file mode 100644 index 89743ba..0000000 --- a/user/mpy/lib/libm_dbl/tanh.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -double tanh(double x) { - return sinh(x) / cosh(x); -} diff --git a/user/mpy/lib/libm_dbl/tgamma.c b/user/mpy/lib/libm_dbl/tgamma.c deleted file mode 100644 index d1d0a04..0000000 --- a/user/mpy/lib/libm_dbl/tgamma.c +++ /dev/null @@ -1,222 +0,0 @@ -/* -"A Precision Approximation of the Gamma Function" - Cornelius Lanczos (1964) -"Lanczos Implementation of the Gamma Function" - Paul Godfrey (2001) -"An Analysis of the Lanczos Gamma Approximation" - Glendon Ralph Pugh (2004) - -approximation method: - - (x - 0.5) S(x) -Gamma(x) = (x + g - 0.5) * ---------------- - exp(x + g - 0.5) - -with - a1 a2 a3 aN -S(x) ~= [ a0 + ----- + ----- + ----- + ... + ----- ] - x + 1 x + 2 x + 3 x + N - -with a0, a1, a2, a3,.. aN constants which depend on g. - -for x < 0 the following reflection formula is used: - -Gamma(x)*Gamma(-x) = -pi/(x sin(pi x)) - -most ideas and constants are from boost and python -*/ -#include "libm.h" - -static const double pi = 3.141592653589793238462643383279502884; - -/* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */ -static double sinpi(double x) -{ - int n; - - /* argument reduction: x = |x| mod 2 */ - /* spurious inexact when x is odd int */ - x = x * 0.5; - x = 2 * (x - floor(x)); - - /* reduce x into [-.25,.25] */ - n = 4 * x; - n = (n+1)/2; - x -= n * 0.5; - - x *= pi; - switch (n) { - default: /* case 4 */ - case 0: - return __sin(x, 0, 0); - case 1: - return __cos(x, 0); - case 2: - return __sin(-x, 0, 0); - case 3: - return -__cos(x, 0); - } -} - -#define N 12 -//static const double g = 6.024680040776729583740234375; -static const double gmhalf = 5.524680040776729583740234375; -static const double Snum[N+1] = { - 23531376880.410759688572007674451636754734846804940, - 42919803642.649098768957899047001988850926355848959, - 35711959237.355668049440185451547166705960488635843, - 17921034426.037209699919755754458931112671403265390, - 6039542586.3520280050642916443072979210699388420708, - 1439720407.3117216736632230727949123939715485786772, - 248874557.86205415651146038641322942321632125127801, - 31426415.585400194380614231628318205362874684987640, - 2876370.6289353724412254090516208496135991145378768, - 186056.26539522349504029498971604569928220784236328, - 8071.6720023658162106380029022722506138218516325024, - 210.82427775157934587250973392071336271166969580291, - 2.5066282746310002701649081771338373386264310793408, -}; -static const double Sden[N+1] = { - 0, 39916800, 120543840, 150917976, 105258076, 45995730, 13339535, - 2637558, 357423, 32670, 1925, 66, 1, -}; -/* n! for small integer n */ -static const double fact[] = { - 1, 1, 2, 6, 24, 120, 720, 5040.0, 40320.0, 362880.0, 3628800.0, 39916800.0, - 479001600.0, 6227020800.0, 87178291200.0, 1307674368000.0, 20922789888000.0, - 355687428096000.0, 6402373705728000.0, 121645100408832000.0, - 2432902008176640000.0, 51090942171709440000.0, 1124000727777607680000.0, -}; - -/* S(x) rational function for positive x */ -static double S(double x) -{ - double_t num = 0, den = 0; - int i; - - /* to avoid overflow handle large x differently */ - if (x < 8) - for (i = N; i >= 0; i--) { - num = num * x + Snum[i]; - den = den * x + Sden[i]; - } - else - for (i = 0; i <= N; i++) { - num = num / x + Snum[i]; - den = den / x + Sden[i]; - } - return num/den; -} - -double tgamma(double x) -{ - union {double f; uint64_t i;} u = {x}; - double absx, y; - double_t dy, z, r; - uint32_t ix = u.i>>32 & 0x7fffffff; - int sign = u.i>>63; - - /* special cases */ - if (ix >= 0x7ff00000) - /* tgamma(nan)=nan, tgamma(inf)=inf, tgamma(-inf)=nan with invalid */ - return x + INFINITY; - if (ix < (0x3ff-54)<<20) - /* |x| < 2^-54: tgamma(x) ~ 1/x, +-0 raises div-by-zero */ - return 1/x; - - /* integer arguments */ - /* raise inexact when non-integer */ - if (x == floor(x)) { - if (sign) - return 0/0.0; - if (x <= sizeof fact/sizeof *fact) - return fact[(int)x - 1]; - } - - /* x >= 172: tgamma(x)=inf with overflow */ - /* x =< -184: tgamma(x)=+-0 with underflow */ - if (ix >= 0x40670000) { /* |x| >= 184 */ - if (sign) { - FORCE_EVAL((float)(0x1p-126/x)); - if (floor(x) * 0.5 == floor(x * 0.5)) - return 0; - return -0.0; - } - x *= 0x1p1023; - return x; - } - - absx = sign ? -x : x; - - /* handle the error of x + g - 0.5 */ - y = absx + gmhalf; - if (absx > gmhalf) { - dy = y - absx; - dy -= gmhalf; - } else { - dy = y - gmhalf; - dy -= absx; - } - - z = absx - 0.5; - r = S(absx) * exp(-y); - if (x < 0) { - /* reflection formula for negative x */ - /* sinpi(absx) is not 0, integers are already handled */ - r = -pi / (sinpi(absx) * absx * r); - dy = -dy; - z = -z; - } - r += dy * (gmhalf+0.5) * r / y; - z = pow(y, 0.5*z); - y = r * z * z; - return y; -} - -#if 1 -double __lgamma_r(double x, int *sign) -{ - double r, absx; - - *sign = 1; - - /* special cases */ - if (!isfinite(x)) - /* lgamma(nan)=nan, lgamma(+-inf)=inf */ - return x*x; - - /* integer arguments */ - if (x == floor(x) && x <= 2) { - /* n <= 0: lgamma(n)=inf with divbyzero */ - /* n == 1,2: lgamma(n)=0 */ - if (x <= 0) - return 1/0.0; - return 0; - } - - absx = fabs(x); - - /* lgamma(x) ~ -log(|x|) for tiny |x| */ - if (absx < 0x1p-54) { - *sign = 1 - 2*!!signbit(x); - return -log(absx); - } - - /* use tgamma for smaller |x| */ - if (absx < 128) { - x = tgamma(x); - *sign = 1 - 2*!!signbit(x); - return log(fabs(x)); - } - - /* second term (log(S)-g) could be more precise here.. */ - /* or with stirling: (|x|-0.5)*(log(|x|)-1) + poly(1/|x|) */ - r = (absx-0.5)*(log(absx+gmhalf)-1) + (log(S(absx)) - (gmhalf+0.5)); - if (x < 0) { - /* reflection formula for negative x */ - x = sinpi(absx); - *sign = 2*!!signbit(x) - 1; - r = log(pi/(fabs(x)*absx)) - r; - } - return r; -} - -//weak_alias(__lgamma_r, lgamma_r); -#endif diff --git a/user/mpy/lib/libm_dbl/trunc.c b/user/mpy/lib/libm_dbl/trunc.c deleted file mode 100644 index d13711b..0000000 --- a/user/mpy/lib/libm_dbl/trunc.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "libm.h" - -double trunc(double x) -{ - union {double f; uint64_t i;} u = {x}; - int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12; - uint64_t m; - - if (e >= 52 + 12) - return x; - if (e < 12) - e = 1; - m = -1ULL >> e; - if ((u.i & m) == 0) - return x; - FORCE_EVAL(x + 0x1p120f); - u.i &= ~m; - return u.f; -} diff --git a/user/mpy/lib/lwip/CHANGELOG b/user/mpy/lib/lwip/CHANGELOG deleted file mode 100644 index c502b00..0000000 --- a/user/mpy/lib/lwip/CHANGELOG +++ /dev/null @@ -1,3339 +0,0 @@ -HISTORY - -(CVS HEAD) - - * [Enter new changes just after this line - do not remove this line] - - ++ New features: - - 2012-03-25: Simon Goldschmidt (idea by Mason) - * posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h - which are a simple wrapper to the correct lwIP include files. - - 2012-01-16: Simon Goldschmidt - * opt.h, icmp.c: Added option CHECKSUM_GEN_ICMP - - 2011-12-17: Simon Goldschmidt - * ip.h: implemented API functions to access so_options of IP pcbs (UDP, TCP, RAW) - (fixes bug #35061) - - 2011-09-27: Simon Goldschmidt - * opt.h, tcp.c, tcp_in.c: Implemented limiting data on ooseq queue (task #9989) - (define TCP_OOSEQ_MAX_BYTES / TCP_OOSEQ_MAX_PBUFS in lwipopts.h) - - 2011-09-21: Simon Goldschmidt - * opt.h, api.h, api_lib.c, api_msg.h/.c, sockets.c: Implemented timeout on - send (TCP only, bug #33820) - - 2011-09-21: Simon Goldschmidt - * init.c: Converted runtime-sanity-checks into compile-time checks that can - be disabled (since runtime checks can often not be seen on embedded targets) - - 2011-09-11: Simon Goldschmidt - * ppp.h, ppp_impl.h: splitted ppp.h to an internal and external header file - to get a clear separation of which functions an application or port may use - (task #11281) - - 2011-09-11: Simon Goldschmidt - * opt.h, tcp_impl.h, tcp.c, udp.h/.c: Added a config option to randomize - initial local TCP/UDP ports (so that different port ranges are used after - a reboot; bug #33818; this one added tcp_init/udp_init functions again) - - 2011-09-03: Simon Goldschmidt - * dhcp.c: DHCP uses LWIP_RAND() for xid's (bug #30302) - - 2011-08-24: Simon Goldschmidt - * opt.h, netif.h/.c: added netif remove callback (bug #32397) - - 2011-07-26: Simon Goldschmidt - * etharp.c: ETHARP_SUPPORT_VLAN: add support for an external VLAN filter - function instead of only checking for one VLAN (define ETHARP_VLAN_CHECK_FN) - - 2011-07-21: Simon Goldschmidt (patch by hanhui) - * ip4.c, etharp.c, pbuf.h: bug #33634 ip_forward() have a faulty behaviour: - Added pbuf flags to mark incoming packets as link-layer broadcast/multicast. - Also added code to allow ip_forward() to forward non-broadcast packets to - the input netif (set IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1). - - 2011-06-26: Simon Goldschmidt (patch by Cameron Gutman) - * tcp.c, tcp_out.c: bug #33604: added some more asserts to check that - pcb->state != LISTEN - - 2011-05-14: Simon Goldschmidt (patch by Stéphane Lesage) - * tcpip.c/.h: patch #7449 allow tcpip callback from interrupt with static - memory message - - - ++ Bugfixes: - - 2012-09-26: Simon Goldschmidt - * api_msg.c: fixed bug #37405 'err_tcp()' uses already freed 'netconn' object - - 2012-09-26: patch by Henrik Persson - * dhcp.c: patch #7843 Fix corner case with dhcp timeouts - - 2012-09-26: patch by Henrik Persson - * dhcp.c: patch #7840 Segfault in dhcp_parse_reply if no end marker in dhcp packet - - 2012-08-22: Simon Goldschmidt - * memp.c: fixed bug #37166: memp_sanity check loops itself - - 2012-05-08: Simon Goldschmidt - * tcp_out.c: fixed bug: #36380 unsent_oversize mismatch in 1.4.1RC1 (this was - a debug-check issue only) - - 2012-03-27: Simon Goldschmidt - * vj.c: fixed bug #35756 header length calculation problem in ppp/vj.c - - 2012-03-27: Simon Goldschmidt (patch by Mason) - * tcp_out.c: fixed bug #35945: SYN packet should provide the recv MSS not the - send MSS - - 2012-03-22: Simon Goldschmidt - * ip4.c: fixed bug #35927: missing refragmentaion in ip_forward - - 2012-03-20: Simon Goldschmidt (patch by Mason) - * netdb.c: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list - - 2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic) - * ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian, - possible bug on little endian system - - 2012-02-23: Simon Goldschmidt - * etharp.c: fixed bug #35595: Impossible to send broadcast without a gateway - (introduced when fixing bug# 33551) - - 2012-02-16: Simon Goldschmidt - * ppp.c: fixed pbuf leak when PPP session is aborted through pppSigHUP() - (bug #35541: PPP Memory Leak) - - 2012-02-16: Simon Goldschmidt - * etharp.c: fixed bug #35531: Impossible to send multicast without a gateway - (introduced when fixing bug# 33551) - - 2012-02-16: Simon Goldschmidt (patch by Stéphane Lesage) - * msg_in.c, msg_out.c: fixed bug #35536 SNMP: error too big response is malformed - - 2012-02-15: Simon Goldschmidt - * init.c: fixed bug #35537: MEMP_NUM_* sanity checks should be disabled with - MEMP_MEM_MALLOC==1 - - 2012-02-12: Simon Goldschmidt - * tcp.h, tcp_in.c, tcp_out.c: partly fixed bug #25882: TCP hangs on - MSS > pcb->snd_wnd (by not creating segments bigger than half the window) - - 2012-02-11: Simon Goldschmidt - * tcp.c: fixed bug #35435: No pcb state check before adding it to time-wait - queue while closing - - 2012-01-22: Simon Goldschmidt - * tcp.c, tcp_in.c: fixed bug #35305: pcb may be freed too early on shutdown(WR) - - 2012-01-21: Simon Goldschmidt - * tcp.c: fixed bug #34636: FIN_WAIT_2 - Incorrect shutdown of TCP pcb - - 2012-01-20: Simon Goldschmidt - * dhcp.c: fixed bug #35151: DHCP asserts on incoming option lengths - - 2012-01-20: Simon Goldschmidt - * pbuf.c: fixed bug #35291: NULL pointer in pbuf_copy - - 2011-11-25: Simon Goldschmidt - * tcp.h/.c, tcp_impl.h, tcp_in.c: fixed bug #31177: tcp timers can corrupt - tcp_active_pcbs in some cases - - 2011-11-23: Simon Goldschmidt - * sys.c: fixed bug #34884: sys_msleep() body needs to be surrounded with - '#ifndef sys_msleep' - - 2011-11-22: Simon Goldschmidt - * netif.c, etharp.h/.c: fixed bug #34684: Clear the arp table cache when - netif is brought down - - 2011-10-28: Simon Goldschmidt - * tcp_in.c: fixed bug #34638: Dead code in tcp_receive - pcb->dupacks - - 2011-10-23: Simon Goldschmidt - * mem.c: fixed bug #34429: possible memory corruption with - LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT set to 1 - - 2011-10-18: Simon Goldschmidt - * arch.h, netdb.c: fixed bug #34592: lwip_gethostbyname_r uses nonstandard - error value - - 2011-10-18: Simon Goldschmidt - * opt.h: fixed default values of TCP_SNDLOWAT and TCP_SNDQUEUELOWAT for small - windows (bug #34176 select after non-blocking send times out) - - 2011-10-18: Simon Goldschmidt - * tcp_impl.h, tcp_out.c: fixed bug #34587: TCP_BUILD_MSS_OPTION doesn't - consider netif->mtu, causes slow network - - 2011-10-18: Simon Goldschmidt - * sockets.c: fixed bug #34581 missing parentheses in udplite sockets code - - 2011-10-18: Simon Goldschmidt - * sockets.h: fixed bug #34580 fcntl() is missing in LWIP_COMPAT_SOCKETS - - 2011-10-17: Simon Goldschmidt - * api_msg.c: fixed bug #34569: shutdown(SHUT_WR) crashes netconn/socket api - - 2011-10-13: Simon Goldschmidt - * tcp_in.c, tcp_out.c: fixed bug #34517 (persist timer is started although no - zero window is received) by starting the persist timer when a zero window is - received, not when we have more data queued for sending than fits into the - window - - 2011-10-13: Simon Goldschmidt - * def.h, timers.c: fixed bug #34541: LWIP_U32_DIFF is unnecessarily complex - - 2011-10-13: Simon Goldschmidt - * sockets.c, api_lib.c: fixed bug #34540: compiler error when CORE_LOCKING is - used and not all protocols are enabled - - 2011-10-12: Simon Goldschmidt - * pbuf.c: fixed bug #34534: Error in sending fragmented IP if MEM_ALIGNMENT > 4 - - 2011-10-09: Simon Goldschmidt - * tcp_out.c: fixed bug #34426: tcp_zero_window_probe() transmits incorrect - byte value when pcb->unacked != NULL - - 2011-10-09: Simon Goldschmidt - * ip4.c: fixed bug #34447 LWIP_IP_ACCEPT_UDP_PORT(dst_port) wrong - - 2011-09-27: Simon Goldschmidt - * tcp_in.c, tcp_out.c: Reset pcb->unsent_oversize in 2 more places... - - 2011-09-27: Simon Goldschmidt - * tcp_in.c: fixed bug #28288: Data after FIN in oos queue - - 2011-09-27: Simon Goldschmidt - * dhcp.c: fixed bug #34406 dhcp_option_hostname() can overflow the pbuf - - 2011-09-24: Simon Goldschmidt - * mem.h: fixed bug #34377 MEM_SIZE_F is not defined if MEM_LIBC_MALLOC==1 - - 2011-09-23: Simon Goldschmidt - * pbuf.h, tcp.c, tcp_in.c: fixed bug #33871: rejecting TCP_EVENT_RECV() for - the last packet including FIN can lose data - - 2011-09-22: Simon Goldschmidt - * tcp_impl.h: fixed bug #34355: nagle does not take snd_buf/snd_queuelen into - account - - 2011-09-21: Simon Goldschmidt - * opt.h: fixed default value of TCP_SND_BUF to not violate the sanity checks - in init.c - - 2011-09-20: Simon Goldschmidt - * timers.c: fixed bug #34337 (possible NULL pointer in sys_check_timeouts) - - 2011-09-11: Simon Goldschmidt - * tcp_out.c: use pcb->mss instead of TCP_MSS for preallocate mss-sized pbufs - (bug #34019) - - 2011-09-09: Simon Goldschmidt - * udp.c: fixed bug #34072: UDP broadcast is received from wrong UDP pcb if - udp port matches - - 2011-09-03: Simon Goldschmidt - * tcp_in.c: fixed bug #33952 PUSH flag in incoming packet is lost when packet - is aggregated and sent to application - - 2011-09-01: Simon Goldschmidt - * opt.h: fixed bug #31809 LWIP_EVENT_API in opts.h is inconsistent compared - to other options - - 2011-09-01: Simon Goldschmidt - * tcp_in.c: fixed bug #34111 RST for ACK to listening pcb has wrong seqno - - 2011-08-24: Simon Goldschmidt - * api_msg.c, sockets.c: fixed bug #33956 Wrong error returned when calling - accept() on UDP connections - - 2011-08-24: Simon Goldschmidt - * sockets.h: fixed bug #34057 socklen_t should be a typedef - - 2011-08-24: Simon Goldschmidt - * pbuf.c: fixed bug #34112 Odd check in pbuf_alloced_custom (typo) - - 2011-08-24: Simon Goldschmidt - * dhcp.c: fixed bug #34122 dhcp: hostname can overflow - - 2011-08-24: Simon Goldschmidt - * netif.c: fixed bug #34121 netif_add/netif_set_ipaddr fail on NULL ipaddr - - 2011-08-22: Simon Goldschmidt - * tcp_out.c: fixed bug #33962 TF_FIN not always set after FIN is sent. (This - merely prevents nagle from not transmitting fast after closing.) - - 2011-07-22: Simon Goldschmidt - * api_lib.c, api_msg.c, sockets.c, api.h: fixed bug #31084 (socket API returns - always EMSGSIZE on non-blocking sockets if data size > send buffers) -> now - lwip_send() sends as much as possible for non-blocking sockets - - 2011-07-22: Simon Goldschmidt - * pbuf.c/.h, timers.c: freeing ooseq pbufs when the pbuf pool is empty implemented - for NO_SYS==1: when not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() - at regular intervals from main level. - - 2011-07-21: Simon Goldschmidt - * etharp.c: fixed bug #33551 (ARP entries may time out although in use) by - sending an ARP request when an ARP entry is used in the last minute before - it would time out. - - 2011-07-04: Simon Goldschmidt - * sys_arch.txt: Fixed documentation after changing sys arch prototypes for 1.4.0. - - 2011-06-26: Simon Goldschmidt - * tcp.c: fixed bug #31723 (tcp_kill_prio() kills pcbs with the same prio) by - updating its documentation only. - - 2011-06-26: Simon Goldschmidt - * mem.c: fixed bug #33545: With MEM_USE_POOLS==1, mem_malloc can return an - unaligned pointer. - - 2011-06-26: Simon Goldschmidt - * mem.c: fixed bug #33544 "warning in mem.c in lwip 1.4.0 with NO_SYS=1" - - 2011-05-25: Simon Goldschmidt - * tcp.c: fixed bug #33398 (pointless conversion when checking TCP port range) - - - -(STABLE-1.4.0) - - ++ New features: - - 2011-03-27: Simon Goldschmidt - * tcp_impl.h, tcp_in.c, tcp_out.c: Removed 'dataptr' from 'struct tcp_seg' and - calculate it in tcp_zero_window_probe (the only place where it was used). - - 2010-11-21: Simon Goldschmidt - * dhcp.c/.h: Added a function to deallocate the struct dhcp from a netif - (fixes bug #31525). - - 2010-07-12: Simon Goldschmidt (patch by Stephane Lesage) - * ip.c, udp.c/.h, pbuf.h, sockets.c: task #10495: Added support for - IP_MULTICAST_LOOP at socket- and raw-API level. - - 2010-06-16: Simon Goldschmidt - * ip.c: Added an optional define (LWIP_IP_ACCEPT_UDP_PORT) that can allow - link-layer-addressed UDP traffic to be received while a netif is down (just - like DHCP during configuration) - - 2010-05-22: Simon Goldschmidt - * many many files: bug #27352: removed packing from ip_addr_t, the packed - version is now only used in protocol headers. Added global storage for - current src/dest IP address while in input functions. - - 2010-05-16: Simon Goldschmidt - * def.h: task #10391: Add preprocessor-macros for compile-time htonl - calculation (and use them throughout the stack where applicable) - - 2010-05-16: Simon Goldschmidt - * opt.h, memp_std.h, memp.c, ppp_oe.h/.c: PPPoE now uses its own MEMP pool - instead of the heap (moved struct pppoe_softc from ppp_oe.c to ppp_oe.h) - - 2010-05-16: Simon Goldschmidt - * opt.h, memp_std.h, dns.h/.c: DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses its own - MEMP pool instead of the heap - - 2010-05-13: Simon Goldschmidt - * tcp.c, udp.c: task #6995: Implement SO_REUSEADDR (correctly), added - new option SO_REUSE_RXTOALL to pass received UDP broadcast/multicast - packets to more than one pcb. - - 2010-05-02: Simon Goldschmidt - * netbuf.h/.c, sockets.c, api_msg.c: use checksum-on-copy for sending - UDP data for LWIP_NETIF_TX_SINGLE_PBUF==1 - - 2010-04-30: Simon Goldschmidt - * udp.h/.c, pbuf.h/.c: task #6849: added udp_send(_to/_if) functions that - take a precalculated checksum, added pbuf_fill_chksum() to copy data - into a pbuf and at the same time calculating the checksum for that data - - 2010-04-29: Simon Goldschmidt - * ip_addr.h, etharp.h/.c, autoip.c: Create overridable macros for copying - 2-byte-aligned IP addresses and MAC addresses - - 2010-04-28: Patch by Bill Auerbach - * ip.c: Inline generating IP checksum to save a function call - - 2010-04-14: Simon Goldschmidt - * tcpip.h/.c, timers.c: Added an overridable define to get informed when the - tcpip_thread processes messages or timeouts to implement a watchdog. - - 2010-03-28: Simon Goldschmidt - * ip_frag.c: create a new (contiguous) PBUF_RAM for every outgoing - fragment if LWIP_NETIF_TX_SINGLE_PBUF==1 - - 2010-03-27: Simon Goldschmidt - * etharp.c: Speedup TX by moving code from find_entry to etharp_output/ - etharp_query to prevent unnecessary function calls (inspired by - patch #7135). - - 2010-03-20: Simon Goldschmidt - * opt.h, tcpip.c/.h: Added an option to disable tcpip_(un)timeout code - since the linker cannot do this automatically to save space. - - 2010-03-20: Simon Goldschmidt - * opt.h, etharp.c/.h: Added support for static ARP table entries - - 2010-03-14: Simon Goldschmidt - * tcp_impl.h, tcp_out.c, inet_chksum.h/.c: task #6849: Calculate checksum - when creating TCP segments, not when (re-)transmitting them. - - 2010-03-07: Simon Goldschmidt - * sockets.c: bug #28775 (select/event_callback: only check select_cb_list - on change) plus use SYS_LIGHTWEIGHT_PROT to protect the select code. - This should speed up receiving data on sockets as the select code in - event_callback is only executed when select is waiting. - - 2010-03-06: Simon Goldschmidt - * tcp_out.c: task #7013 (Create option to have all packets delivered to - netif->output in one piece): Always copy to try to create single pbufs - in tcp_write. - - 2010-03-06: Simon Goldschmidt - * api.h, api_lib.c, sockets.c: task #10167 (sockets: speed up TCP recv - by not allocating a netbuf): added function netconn_recv_tcp_pbuf() - for tcp netconns to receive pbufs, not netbufs; use that function - for tcp sockets. - - 2010-03-05: Jakob Ole Stoklundsen / Simon Goldschmidt - * opt.h, tcp.h, tcp_impl.h, tcp.c, tcp_in.c, tcp_out.c: task #7040: - Work on tcp_enqueue: Don't waste memory when chaining segments, - added option TCP_OVERSIZE to prevent creating many small pbufs when - calling tcp_write with many small blocks of data. Instead, pbufs are - allocated larger than needed and the space is used for later calls to - tcp_write. - - 2010-02-21: Simon Goldschmidt - * stats.c/.h: Added const char* name to mem- and memp-stats for easier - debugging. - - 2010-02-21: Simon Goldschmidt - * tcp.h (and usages), added tcp_impl.h: Splitted API and internal - implementation of tcp to make API usage cleare to application programmers - - 2010-02-14: Simon Goldschmidt/Stephane Lesage - * ip_addr.h: Improved some defines working on ip addresses, added faster - macro to copy addresses that cannot be NULL - - 2010-02-13: Simon Goldschmidt - * api.h, api_lib.c, api_msg.c, sockets.c: task #7865 (implement non- - blocking send operation) - - 2010-02-12: Simon Goldschmidt - * sockets.c/.h: Added a minimal version of posix fctl() to have a - standardised way to set O_NONBLOCK for nonblocking sockets. - - 2010-02-12: Simon Goldschmidt - * dhcp.c/.h, autoip.c/.h: task #10139 (Prefer statically allocated - memory): added autoip_set_struct() and dhcp_set_struct() to let autoip - and dhcp work with user-allocated structs instead of callin mem_malloc - - 2010-02-12: Simon Goldschmidt/Jeff Barber - * tcp.c/h: patch #6865 (SO_REUSEADDR for TCP): if pcb.so_options has - SOF_REUSEADDR set, allow binding to endpoint in TIME_WAIT - - 2010-02-12: Simon Goldschmidt - * sys layer: task #10139 (Prefer statically allocated memory): converted - mbox and semaphore functions to take pointers to sys_mbox_t/sys_sem_t; - converted sys_mbox_new/sys_sem_new to take pointers and return err_t; - task #7212: Add Mutex concept in sys_arch (define LWIP_COMPAT_MUTEX - to let sys.h use binary semaphores instead of mutexes - as before) - - 2010-02-09: Simon Goldschmidt (Simon Kallweit) - * timers.c/.h: Added function sys_restart_timeouts() from patch #7085 - (Restart system timeout handling) - - 2010-02-09: Simon Goldschmidt - * netif.c/.h, removed loopif.c/.h: task #10153 (Integrate loopif into - netif.c) - loopif does not have to be created by the port any more, - just define LWIP_HAVE_LOOPIF to 1. - - 2010-02-08: Simon Goldschmidt - * inet.h, ip_addr.c/.h: Added reentrant versions of inet_ntoa/ipaddr_ntoa - inet_ntoa_r/ipaddr_ntoa_r - - 2010-02-08: Simon Goldschmidt - * netif.h: Added netif_s/get_igmp_mac_filter() macros - - 2010-02-05: Simon Goldschmidt - * netif.h: Added function-like macros to get/set the hostname on a netif - - 2010-02-04: Simon Goldschmidt - * nearly every file: Replaced struct ip_addr by typedef ip_addr_t to - make changing the actual implementation behind the typedef easier. - - 2010-02-01: Simon Goldschmidt - * opt.h, memp_std.h, dns.h, netdb.c, memp.c: Let netdb use a memp pool - for allocating memory when getaddrinfo() is called. - - 2010-01-31: Simon Goldschmidt - * dhcp.h, dhcp.c: Reworked the code that parses DHCP options: parse - them once instead of parsing for every option. This also removes - the need for mem_malloc from dhcp_recv and makes it possible to - correctly retrieve the BOOTP file. - - 2010-01-30: simon Goldschmidt - * sockets.c: Use SYS_LIGHTWEIGHT_PROT instead of a semaphore to protect - the sockets array. - - 2010-01-29: Simon Goldschmidt (patch by Laura Garrett) - * api.h, api_msg.c, sockets.c: Added except set support in select - (patch #6860) - - 2010-01-29: Simon Goldschmidt (patch by Laura Garrett) - * api.h, sockets.h, err.h, api_lib.c, api_msg.c, sockets.c, err.c: - Add non-blocking support for connect (partly from patch #6860), - plus many cleanups in socket & netconn API. - - 2010-01-27: Simon Goldschmidt - * opt.h, tcp.h, init.c, api_msg.c: Added TCP_SNDQUEUELOWAT corresponding - to TCP_SNDLOWAT and added tcp_sndqueuelen() - this fixes bug #28605 - - 2010-01-26: Simon Goldschmidt - * snmp: Use memp pools for snmp instead of the heap; added 4 new pools. - - 2010-01-14: Simon Goldschmidt - * ppp.c/.h: Fixed bug #27856: PPP: Set netif link- and status-callback - by adding ppp_set_netif_statuscallback()/ppp_set_netif_linkcallback() - - 2010-01-13: Simon Goldschmidt - * mem.c: The heap now may be moved to user-defined memory by defining - LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address - (patch #6966 and bug #26133) - - 2010-01-10: Simon Goldschmidt (Bill Auerbach) - * opt.h, memp.c: patch #6822 (Add option to place memory pools in - separate arrays) - - 2010-01-10: Simon Goldschmidt - * init.c, igmp.c: patch #6463 (IGMP - Adding Random Delay): added define - LWIP_RAND() for lwip-wide randomization (to be defined in cc.h) - - 2009-12-31: Simon Goldschmidt - * tcpip.c, init.c, memp.c, sys.c, memp_std.h, sys.h, tcpip.h - added timers.c/.h: Separated timer implementation from semaphore/mbox - implementation, moved timer implementation to timers.c/.h, timers are - now only called from tcpip_thread or by explicitly checking them. - (TASK#7235) - - 2009-12-27: Simon Goldschmidt - * opt.h, etharp.h/.c, init.c, tcpip.c: Added an additional option - LWIP_ETHERNET to support ethernet without ARP (necessary for pure PPPoE) - - - ++ Bugfixes: - - 2011-04-20: Simon Goldschmidt - * sys_arch.txt: sys_arch_timeouts() is not needed any more. - - 2011-04-13: Simon Goldschmidt - * tcp.c, udp.c: Fixed bug #33048 (Bad range for IP source port numbers) by - using ports in the IANA private/dynamic range (49152 through 65535). - - 2011-03-29: Simon Goldschmidt, patch by Emil Lhungdahl: - * etharp.h/.c: Fixed broken VLAN support. - - 2011-03-27: Simon Goldschmidt - * tcp.c: Fixed bug #32926 (TCP_RMV(&tcp_bound_pcbs) is called on unbound tcp - pcbs) by checking if the pcb was bound (local_port != 0). - - 2011-03-27: Simon Goldschmidt - * ppp.c: Fixed bug #32280 (ppp: a pbuf is freed twice) - - 2011-03-27: Simon Goldschmidt - * sockets.c: Fixed bug #32906: lwip_connect+lwip_send did not work for udp and - raw pcbs with LWIP_TCPIP_CORE_LOCKING==1. - - 2011-03-27: Simon Goldschmidt - * tcp_out.c: Fixed bug #32820 (Outgoing TCP connections created before route - is present never times out) by starting retransmission timer before checking - route. - - 2011-03-22: Simon Goldschmidt - * ppp.c: Fixed bug #32648 (PPP code crashes when terminating a link) by only - calling sio_read_abort() if the file descriptor is valid. - - 2011-03-14: Simon Goldschmidt - * err.h/.c, sockets.c, api_msg.c: fixed bug #31748 (Calling non-blocking connect - more than once can render a socket useless) since it mainly involves changing - "FATAL" classification of error codes: ERR_USE and ERR_ISCONN just aren't fatal. - - 2011-03-13: Simon Goldschmidt - * sockets.c: fixed bug #32769 (ESHUTDOWN is linux-specific) by fixing - err_to_errno_table (ERR_CLSD: ENOTCONN instead of ESHUTDOWN), ERR_ISCONN: - use EALRADY instead of -1 - - 2011-03-13: Simon Goldschmidt - * api_lib.c: netconn_accept: return ERR_ABRT instead of ERR_CLSD if the - connection has been aborted by err_tcp (since this is not a normal closing - procedure). - - 2011-03-13: Simon Goldschmidt - * tcp.c: tcp_bind: return ERR_VAL instead of ERR_ISCONN when trying to bind - with pcb->state != CLOSED - - 2011-02-17: Simon Goldschmidt - * rawapi.txt: Fixed bug #32561 tcp_poll argument definition out-of-order in - documentation - - 2011-02-17: Simon Goldschmidt - * many files: Added missing U/UL modifiers to fix 16-bit-arch portability. - - 2011-01-24: Simon Goldschmidt - * sockets.c: Fixed bug #31741: lwip_select seems to have threading problems - - 2010-12-02: Simon Goldschmidt - * err.h: Fixed ERR_IS_FATAL so that ERR_WOULDBLOCK is not fatal. - - 2010-11-23: Simon Goldschmidt - * api.h, api_lib.c, api_msg.c, sockets.c: netconn.recv_avail is only used for - LWIP_SO_RCVBUF and ioctl/FIONREAD. - - 2010-11-23: Simon Goldschmidt - * etharp.c: Fixed bug #31720: ARP-queueing: RFC 1122 recommends to queue at - least 1 packet -> ARP_QUEUEING==0 now queues the most recent packet. - - 2010-11-23: Simon Goldschmidt - * tcp_in.c: Fixed bug #30577: tcp_input: don't discard ACK-only packets after - refusing 'refused_data' again. - - 2010-11-22: Simon Goldschmidt - * sockets.c: Fixed bug #31590: getsockopt(... SO_ERROR ...) gives EINPROGRESS - after a successful nonblocking connection. - - 2010-11-22: Simon Goldschmidt - * etharp.c: Fixed bug #31722: IP packets sent with an AutoIP source addr - must be sent link-local - - 2010-11-22: Simon Goldschmidt - * timers.c: patch #7329: tcp_timer_needed prototype was ifdef'ed out for - LWIP_TIMERS==0 - - 2010-11-20: Simon Goldschmidt - * sockets.c: Fixed bug #31170: lwip_setsockopt() does not set socket number - - 2010-11-20: Simon Goldschmidt - * sockets.h: Fixed bug #31304: Changed SHUT_RD, SHUT_WR and SHUT_RDWR to - resemble other stacks. - - 2010-11-20: Simon Goldschmidt - * dns.c: Fixed bug #31535: TCP_SND_QUEUELEN must be at least 2 or else - no-copy TCP writes will never succeed. - - 2010-11-20: Simon Goldschmidt - * dns.c: Fixed bug #31701: Error return value from dns_gethostbyname() does - not match documentation: return ERR_ARG instead of ERR_VAL if not - initialized or wrong argument. - - 2010-10-20: Simon Goldschmidt - * sockets.h: Fixed bug #31385: sizeof(struct sockaddr) is 30 but should be 16 - - 2010-10-05: Simon Goldschmidt - * dhcp.c: Once again fixed #30038: DHCP/AutoIP cooperation failed when - replugging the network cable after an AutoIP address was assigned. - - 2010-08-10: Simon Goldschmidt - * tcp.c: Fixed bug #30728: tcp_new_port() did not check listen pcbs - - 2010-08-03: Simon Goldschmidt - * udp.c, raw.c: Don't chain empty pbufs when sending them (fixes bug #30625) - - 2010-08-01: Simon Goldschmidt (patch by Greg Renda) - * ppp.c: Applied patch #7264 (PPP protocols are rejected incorrectly on big - endian architectures) - - 2010-07-28: Simon Goldschmidt - * api_lib.c, api_msg.c, sockets.c, mib2.c: Fixed compilation with TCP or UDP - disabled. - - 2010-07-27: Simon Goldschmidt - * tcp.c: Fixed bug #30565 (tcp_connect() check bound list): that check did no - harm but never did anything - - 2010-07-21: Simon Goldschmidt - * ip.c: Fixed invalid fix for bug #30402 (CHECKSUM_GEN_IP_INLINE does not - add IP options) - - 2010-07-16: Kieran Mansley - * msg_in.c: Fixed SNMP ASN constant defines to not use ! operator - - 2010-07-10: Simon Goldschmidt - * ip.c: Fixed bug #30402: CHECKSUM_GEN_IP_INLINE does not add IP options - - 2010-06-30: Simon Goldschmidt - * api_msg.c: fixed bug #30300 (shutdown parameter was not initialized in - netconn_delete) - - 2010-06-28: Kieran Mansley - * timers.c remove unportable printing of C function pointers - - 2010-06-24: Simon Goldschmidt - * init.c, timers.c/.h, opt.h, memp_std.h: From patch #7221: added flag - NO_SYS_NO_TIMERS to drop timer support for NO_SYS==1 for easier upgrading - - 2010-06-24: Simon Goldschmidt - * api(_lib).c/.h, api_msg.c/.h, sockets.c/.h: Fixed bug #10088: Correctly - implemented shutdown at socket level. - - 2010-06-21: Simon Goldschmidt - * pbuf.c/.h, ip_frag.c/.h, opt.h, memp_std.h: Fixed bug #29361 (ip_frag has - problems with zero-copy DMA MACs) by adding custom pbufs and implementing - custom pbufs that reference other (original) pbufs. Additionally set - IP_FRAG_USES_STATIC_BUF=0 as default to be on the safe side. - - 2010-06-15: Simon Goldschmidt - * dhcp.c: Fixed bug #29970: DHCP endian issue parsing option responses - - 2010-06-14: Simon Goldschmidt - * autoip.c: Fixed bug #30039: AutoIP does not reuse previous addresses - - 2010-06-12: Simon Goldschmidt - * dhcp.c: Fixed bug #30038: dhcp_network_changed doesn't reset AUTOIP coop - state - - 2010-05-17: Simon Goldschmidt - * netdb.c: Correctly NULL-terminate h_addr_list - - 2010-05-16: Simon Goldschmidt - * def.h/.c: changed the semantics of LWIP_PREFIX_BYTEORDER_FUNCS to prevent - "symbol already defined" i.e. when linking to winsock - - 2010-05-05: Simon Goldschmidt - * def.h, timers.c: Fixed bug #29769 (sys_check_timeouts: sys_now() may - overflow) - - 2010-04-21: Simon Goldschmidt - * api_msg.c: Fixed bug #29617 (sometime cause stall on delete listening - connection) - - 2010-03-28: Luca Ceresoli - * ip_addr.c/.h: patch #7143: Add a few missing const qualifiers - - 2010-03-27: Luca Ceresoli - * mib2.c: patch #7130: remove meaningless const qualifiers - - 2010-03-26: Simon Goldschmidt - * tcp_out.c: Make LWIP_NETIF_TX_SINGLE_PBUF work for TCP, too - - 2010-03-26: Simon Goldschmidt - * various files: Fixed compiling with different options disabled (TCP/UDP), - triggered by bug #29345; don't allocate acceptmbox if LWIP_TCP is disabled - - 2010-03-25: Simon Goldschmidt - * sockets.c: Fixed bug #29332: lwip_select() processes readset incorrectly - - 2010-03-25: Simon Goldschmidt - * tcp_in.c, test_tcp_oos.c: Fixed bug #29080: Correctly handle remote side - overrunning our rcv_wnd in ooseq case. - - 2010-03-22: Simon Goldschmidt - * tcp.c: tcp_listen() did not copy the pcb's prio. - - 2010-03-19: Simon Goldschmidt - * snmp_msg.c: Fixed bug #29256: SNMP Trap address was not correctly set - - 2010-03-14: Simon Goldschmidt - * opt.h, etharp.h: Fixed bug #29148 (Incorrect PBUF_POOL_BUFSIZE for ports - where ETH_PAD_SIZE > 0) by moving definition of ETH_PAD_SIZE to opt.h - and basing PBUF_LINK_HLEN on it. - - 2010-03-08: Simon Goldschmidt - * netif.c, ipv4/ip.c: task #10241 (AutoIP: don't break existing connections - when assiging routable address): when checking incoming packets and - aborting existing connection on address change, filter out link-local - addresses. - - 2010-03-06: Simon Goldschmidt - * sockets.c: Fixed LWIP_NETIF_TX_SINGLE_PBUF for LWIP_TCPIP_CORE_LOCKING - - 2010-03-06: Simon Goldschmidt - * ipv4/ip.c: Don't try to forward link-local addresses - - 2010-03-06: Simon Goldschmidt - * etharp.c: Fixed bug #29087: etharp: don't send packets for LinkLocal- - addresses to gw - - 2010-03-05: Simon Goldschmidt - * dhcp.c: Fixed bug #29072: Correctly set ciaddr based on message-type - and state. - - 2010-03-05: Simon Goldschmidt - * api_msg.c: Correctly set TCP_WRITE_FLAG_MORE when netconn_write is split - into multiple calls to tcp_write. - - 2010-02-21: Simon Goldschmidt - * opt.h, mem.h, dns.c: task #10140: Remove DNS_USES_STATIC_BUF (keep - the implementation of DNS_USES_STATIC_BUF==1) - - 2010-02-20: Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c, tcp_out.c: Task #10088: Correctly implement - close() vs. shutdown(). Now the application does not get any more - recv callbacks after calling tcp_close(). Added tcp_shutdown(). - - 2010-02-19: Simon Goldschmidt - * mem.c/.h, pbuf.c: Renamed mem_realloc() to mem_trim() to prevent - confusion with realloc() - - 2010-02-15: Simon Goldschmidt/Stephane Lesage - * netif.c/.h: Link status does not depend on LWIP_NETIF_LINK_CALLBACK - (fixes bug #28899) - - 2010-02-14: Simon Goldschmidt - * netif.c: Fixed bug #28877 (Duplicate ARP gratuitous packet with - LWIP_NETIF_LINK_CALLBACK set on) by only sending if both link- and - admin-status of a netif are up - - 2010-02-14: Simon Goldschmidt - * opt.h: Disable ETHARP_TRUST_IP_MAC by default since it slows down packet - reception and is not really necessary - - 2010-02-14: Simon Goldschmidt - * etharp.c/.h: Fixed ARP input processing: only add a new entry if a - request was directed as us (RFC 826, Packet Reception), otherwise - only update existing entries; internalized some functions - - 2010-02-14: Simon Goldschmidt - * netif.h, etharp.c, tcpip.c: Fixed bug #28183 (ARP and TCP/IP cannot be - disabled on netif used for PPPoE) by adding a new netif flag - (NETIF_FLAG_ETHERNET) that tells the stack the device is an ethernet - device but prevents usage of ARP (so that ethernet_input can be used - for PPPoE). - - 2010-02-12: Simon Goldschmidt - * netif.c: netif_set_link_up/down: only do something if the link state - actually changes - - 2010-02-12: Simon Goldschmidt/Stephane Lesage - * api_msg.c: Fixed bug #28865 (Cannot close socket/netconn in non-blocking - connect) - - 2010-02-12: Simon Goldschmidt - * mem.h: Fixed bug #28866 (mem_realloc function defined in mem.h) - - 2010-02-09: Simon Goldschmidt - * api_lib.c, api_msg.c, sockets.c, api.h, api_msg.h: Fixed bug #22110 - (recv() makes receive window update for data that wasn't received by - application) - - 2010-02-09: Simon Goldschmidt/Stephane Lesage - * sockets.c: Fixed bug #28853 (lwip_recvfrom() returns 0 on receive time-out - or any netconn_recv() error) - - 2010-02-09: Simon Goldschmidt - * ppp.c: task #10154 (PPP: Update snmp in/out counters for tx/rx packets) - - 2010-02-09: Simon Goldschmidt - * netif.c: For loopback packets, adjust the stats- and snmp-counters - for the loopback netif. - - 2010-02-08: Simon Goldschmidt - * igmp.c/.h, ip.h: Moved most defines from igmp.h to igmp.c for clarity - since they are not used anywhere else. - - 2010-02-08: Simon Goldschmidt (Stéphane Lesage) - * igmp.c, igmp.h, stats.c, stats.h: Improved IGMP stats - (patch from bug #28798) - - 2010-02-08: Simon Goldschmidt (Stéphane Lesage) - * igmp.c: Fixed bug #28798 (Error in "Max Response Time" processing) and - another bug when LWIP_RAND() returns zero. - - 2010-02-04: Simon Goldschmidt - * nearly every file: Use macros defined in ip_addr.h (some of them new) - to work with IP addresses (preparation for bug #27352 - Change ip_addr - from struct to typedef (u32_t) - and better code). - - 2010-01-31: Simon Goldschmidt - * netif.c: Don't call the link-callback from netif_set_up/down() since - this invalidly retriggers DHCP. - - 2010-01-29: Simon Goldschmidt - * ip_addr.h, inet.h, def.h, inet.c, def.c, more: Cleanly separate the - portability file inet.h and its contents from the stack: moved htonX- - functions to def.h (and the new def.c - they are not ipv4 dependent), - let inet.h depend on ip_addr.h and not the other way round. - This fixes bug #28732. - - 2010-01-28: Kieran Mansley - * tcp.c: Ensure ssthresh >= 2*MSS - - 2010-01-27: Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c: Fixed bug #27871: Calling tcp_abort() in recv - callback can lead to accessing unallocated memory. As a consequence, - ERR_ABRT means the application has called tcp_abort()! - - 2010-01-25: Simon Goldschmidt - * snmp_structs.h, msg_in.c: Partly fixed bug #22070 (MIB_OBJECT_WRITE_ONLY - not implemented in SNMP): write-only or not-accessible are still - returned by getnext (though not by get) - - 2010-01-24: Simon Goldschmidt - * snmp: Renamed the private mib node from 'private' to 'mib_private' to - not use reserved C/C++ keywords - - 2010-01-23: Simon Goldschmidt - * sockets.c: Fixed bug #28716: select() returns 0 after waiting for less - than 1 ms - - 2010-01-21: Simon Goldschmidt - * tcp.c, api_msg.c: Fixed bug #28651 (tcp_connect: no callbacks called - if tcp_enqueue fails) both in raw- and netconn-API - - 2010-01-19: Simon Goldschmidt - * api_msg.c: Fixed bug #27316: netconn: Possible deadlock in err_tcp - - 2010-01-18: Iordan Neshev/Simon Goldschmidt - * src/netif/ppp: reorganised PPP sourcecode to 2.3.11 including some - bugfix backports from 2.4.x. - - 2010-01-18: Simon Goldschmidt - * mem.c: Fixed bug #28679: mem_realloc calculates mem_stats wrong - - 2010-01-17: Simon Goldschmidt - * api_lib.c, api_msg.c, (api_msg.h, api.h, sockets.c, tcpip.c): - task #10102: "netconn: clean up conn->err threading issues" by adding - error return value to struct api_msg_msg - - 2010-01-17: Simon Goldschmidt - * api.h, api_lib.c, sockets.c: Changed netconn_recv() and netconn_accept() - to return err_t (bugs #27709 and #28087) - - 2010-01-14: Simon Goldschmidt - * ...: Use typedef for function prototypes throughout the stack. - - 2010-01-13: Simon Goldschmidt - * api_msg.h/.c, api_lib.c: Fixed bug #26672 (close connection when receive - window = 0) by correctly draining recvmbox/acceptmbox - - 2010-01-11: Simon Goldschmidt - * pap.c: Fixed bug #13315 (PPP PAP authentication can result in - erroneous callbacks) by copying the code from recent pppd - - 2010-01-10: Simon Goldschmidt - * raw.c: Fixed bug #28506 (raw_bind should filter received packets) - - 2010-01-10: Simon Goldschmidt - * tcp.h/.c: bug #28127 (remove call to tcp_output() from tcp_ack(_now)()) - - 2010-01-08: Simon Goldschmidt - * sockets.c: Fixed bug #28519 (lwip_recvfrom bug with len > 65535) - - 2010-01-08: Simon Goldschmidt - * dns.c: Copy hostname for DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1 since string - passed to dns_local_addhost() might be volatile - - 2010-01-07: Simon Goldschmidt - * timers.c, tcp.h: Call tcp_timer_needed() with NO_SYS==1, too - - 2010-01-06: Simon Goldschmidt - * netdb.h: Fixed bug #28496: missing include guards in netdb.h - - 2009-12-31: Simon Goldschmidt - * many ppp files: Reorganised PPP source code from ucip structure to pppd - structure to easily compare our code against the pppd code (around v2.3.1) - - 2009-12-27: Simon Goldschmidt - * tcp_in.c: Another fix for bug #28241 (ooseq processing) and adapted - unit test - - -(STABLE-1.3.2) - - ++ New features: - - 2009-10-27 Simon Goldschmidt/Stephan Lesage - * netifapi.c/.h: Added netifapi_netif_set_addr() - - 2009-10-07 Simon Goldschmidt/Fabian Koch - * api_msg.c, netbuf.c/.h, opt.h: patch #6888: Patch for UDP Netbufs to - support dest-addr and dest-port (optional: LWIP_NETBUF_RECVINFO) - - 2009-08-26 Simon Goldschmidt/Simon Kallweit - * slipif.c/.h: bug #26397: SLIP polling support - - 2009-08-25 Simon Goldschmidt - * opt.h, etharp.h/.c: task #9033: Support IEEE 802.1q tagged frame (VLAN), - New configuration options ETHARP_SUPPORT_VLAN and ETHARP_VLAN_CHECK. - - 2009-08-25 Simon Goldschmidt - * ip_addr.h, netdb.c: patch #6900: added define ip_ntoa(struct ip_addr*) - - 2009-08-24 Jakob Stoklund Olesen - * autoip.c, dhcp.c, netif.c: patch #6725: Teach AutoIP and DHCP to respond - to netif_set_link_up(). - - 2009-08-23 Simon Goldschmidt - * tcp.h/.c: Added function tcp_debug_state_str() to convert a tcp state - to a human-readable string. - - ++ Bugfixes: - - 2009-12-24: Kieran Mansley - * tcp_in.c Apply patches from Oleg Tyshev to improve OOS processing - (BUG#28241) - - 2009-12-06: Simon Goldschmidt - * ppp.h/.c: Fixed bug #27079 (Yet another leak in PPP): outpacket_buf can - be statically allocated (like in ucip) - - 2009-12-04: Simon Goldschmidt (patch by Ioardan Neshev) - * pap.c: patch #6969: PPP: missing PAP authentication UNTIMEOUT - - 2009-12-03: Simon Goldschmidt - * tcp.h, tcp_in.c, tcp_out.c: Fixed bug #28106: dup ack for fast retransmit - could have non-zero length - - 2009-12-02: Simon Goldschmidt - * tcp_in.c: Fixed bug #27904: TCP sends too many ACKs: delay resetting - tcp_input_pcb until after calling the pcb's callbacks - - 2009-11-29: Simon Goldschmidt - * tcp_in.c: Fixed bug #28054: Two segments with FIN flag on the out-of- - sequence queue, also fixed PBUF_POOL leak in the out-of-sequence code - - 2009-11-29: Simon Goldschmidt - * pbuf.c: Fixed bug #28064: pbuf_alloc(PBUF_POOL) is not thread-safe by - queueing a call into tcpip_thread to free ooseq-bufs if the pool is empty - - 2009-11-26: Simon Goldschmidt - * tcp.h: Fixed bug #28098: Nagle can prevent fast retransmit from sending - segment - - 2009-11-26: Simon Goldschmidt - * tcp.h, sockets.c: Fixed bug #28099: API required to disable Nagle - algorithm at PCB level - - 2009-11-22: Simon Goldschmidt - * tcp_out.c: Fixed bug #27905: FIN isn't combined with data on unsent - - 2009-11-22: Simon Goldschmidt (suggested by Bill Auerbach) - * tcp.c: tcp_alloc: prevent increasing stats.err for MEMP_TCP_PCB when - reusing time-wait pcb - - 2009-11-20: Simon Goldschmidt (patch by Albert Bartel) - * sockets.c: Fixed bug #28062: Data received directly after accepting - does not wake up select - - 2009-11-11: Simon Goldschmidt - * netdb.h: Fixed bug #27994: incorrect define for freeaddrinfo(addrinfo) - - 2009-10-30: Simon Goldschmidt - * opt.h: Increased default value for TCP_MSS to 536, updated default - value for TCP_WND to 4*TCP_MSS to keep delayed ACK working. - - 2009-10-28: Kieran Mansley - * tcp_in.c, tcp_out.c, tcp.h: re-work the fast retransmission code - to follow algorithm from TCP/IP Illustrated - - 2009-10-27: Kieran Mansley - * tcp_in.c: fix BUG#27445: grow cwnd with every duplicate ACK - - 2009-10-25: Simon Goldschmidt - * tcp.h: bug-fix in the TCP_EVENT_RECV macro (has to call tcp_recved if - pcb->recv is NULL to keep rcv_wnd correct) - - 2009-10-25: Simon Goldschmidt - * tcp_in.c: Fixed bug #26251: RST process in TIME_WAIT TCP state - - 2009-10-23: Simon Goldschmidt (David Empson) - * tcp.c: Fixed bug #27783: Silly window avoidance for small window sizes - - 2009-10-21: Simon Goldschmidt - * tcp_in.c: Fixed bug #27215: TCP sent() callback gives leading and - trailing 1 byte len (SYN/FIN) - - 2009-10-21: Simon Goldschmidt - * tcp_out.c: Fixed bug #27315: zero window probe and FIN - - 2009-10-19: Simon Goldschmidt - * dhcp.c/.h: Minor code simplification (don't store received pbuf, change - conditional code to assert where applicable), check pbuf length before - testing for valid reply - - 2009-10-19: Simon Goldschmidt - * dhcp.c: Removed most calls to udp_connect since they aren't necessary - when using udp_sendto_if() - always stay connected to IP_ADDR_ANY. - - 2009-10-16: Simon Goldschmidt - * ip.c: Fixed bug #27390: Source IP check in ip_input() causes it to drop - valid DHCP packets -> allow 0.0.0.0 as source address when LWIP_DHCP is - enabled - - 2009-10-15: Simon Goldschmidt (Oleg Tyshev) - * tcp_in.c: Fixed bug #27329: dupacks by unidirectional data transmit - - 2009-10-15: Simon Goldschmidt - * api_lib.c: Fixed bug #27709: conn->err race condition on netconn_recv() - timeout - - 2009-10-15: Simon Goldschmidt - * autoip.c: Fixed bug #27704: autoip starts with wrong address - LWIP_AUTOIP_CREATE_SEED_ADDR() returned address in host byte order instead - of network byte order - - 2009-10-11 Simon Goldschmidt (Jörg Kesten) - * tcp_out.c: Fixed bug #27504: tcp_enqueue wrongly concatenates segments - which are not consecutive when retransmitting unacked segments - - 2009-10-09 Simon Goldschmidt - * opt.h: Fixed default values of some stats to only be enabled if used - Fixes bug #27338: sys_stats is defined when NO_SYS = 1 - - 2009-08-30 Simon Goldschmidt - * ip.c: Fixed bug bug #27345: "ip_frag() does not use the LWIP_NETIF_LOOPBACK - function" by checking for loopback before calling ip_frag - - 2009-08-25 Simon Goldschmidt - * dhcp.c: fixed invalid dependency to etharp_query if DHCP_DOES_ARP_CHECK==0 - - 2009-08-23 Simon Goldschmidt - * ppp.c: bug #27078: Possible memory leak in pppInit() - - 2009-08-23 Simon Goldschmidt - * netdb.c, dns.c: bug #26657: DNS, if host name is "localhost", result - is error. - - 2009-08-23 Simon Goldschmidt - * opt.h, init.c: bug #26649: TCP fails when TCP_MSS > TCP_SND_BUF - Fixed wrong parenthesis, added check in init.c - - 2009-08-23 Simon Goldschmidt - * ppp.c: bug #27266: wait-state debug message in pppMain occurs every ms - - 2009-08-23 Simon Goldschmidt - * many ppp files: bug #27267: Added include to string.h where needed - - 2009-08-23 Simon Goldschmidt - * tcp.h: patch #6843: tcp.h macro optimization patch (for little endian) - - -(STABLE-1.3.1) - - ++ New features: - - 2009-05-10 Simon Goldschmidt - * opt.h, sockets.c, pbuf.c, netbuf.h, pbuf.h: task #7013: Added option - LWIP_NETIF_TX_SINGLE_PBUF to try to create transmit packets from only - one pbuf to help MACs that don't support scatter-gather DMA. - - 2009-05-09 Simon Goldschmidt - * icmp.h, icmp.c: Shrinked ICMP code, added option to NOT check icoming - ECHO pbuf for size (just use it): LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN - - 2009-05-05 Simon Goldschmidt, Jakob Stoklund Olesen - * ip.h, ip.c: Added ip_current_netif() & ip_current_header() to receive - extended info about the currently received packet. - - 2009-04-27 Simon Goldschmidt - * sys.h: Made SYS_LIGHTWEIGHT_PROT and sys_now() work with NO_SYS=1 - - 2009-04-25 Simon Goldschmidt - * mem.c, opt.h: Added option MEM_USE_POOLS_TRY_BIGGER_POOL to try the next - bigger malloc pool if one is empty (only usable with MEM_USE_POOLS). - - 2009-04-21 Simon Goldschmidt - * dns.c, init.c, dns.h, opt.h: task #7507, patch #6786: DNS supports static - hosts table. New configuration options DNS_LOCAL_HOSTLIST and - DNS_LOCAL_HOSTLIST_IS_DYNAMIC. Also, DNS_LOOKUP_LOCAL_EXTERN() can be defined - as an external function for lookup. - - 2009-04-15 Simon Goldschmidt - * dhcp.c: patch #6763: Global DHCP XID can be redefined to something more unique - - 2009-03-31 Kieran Mansley - * tcp.c, tcp_out.c, tcp_in.c, sys.h, tcp.h, opts.h: add support for - TCP timestamp options, off by default. Rework tcp_enqueue() to - take option flags rather than specified option data - - 2009-02-18 Simon Goldschmidt - * cc.h: Added printf formatter for size_t: SZT_F - - 2009-02-16 Simon Goldschmidt (patch by Rishi Khan) - * icmp.c, opt.h: patch #6539: (configurable) response to broadcast- and multicast - pings - - 2009-02-12 Simon Goldschmidt - * init.h: Added LWIP_VERSION to get the current version of the stack - - 2009-02-11 Simon Goldschmidt (suggested by Gottfried Spitaler) - * opt.h, memp.h/.c: added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead - of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc - is otherwise used) - - 2009-01-28 Jonathan Larmour (suggested by Bill Bauerbach) - * ipv4/inet_chksum.c, ipv4/lwip/inet_chksum.h: inet_chksum_pseudo_partial() - is only used by UDPLITE at present, so conditionalise it. - - 2008-12-03 Simon Goldschmidt (base on patch from Luca Ceresoli) - * autoip.c: checked in (slightly modified) patch #6683: Customizable AUTOIP - "seed" address. This should reduce AUTOIP conflicts if - LWIP_AUTOIP_CREATE_SEED_ADDR is overridden. - - 2008-10-02 Jonathan Larmour and Rishi Khan - * sockets.c (lwip_accept): Return EWOULDBLOCK if would block on non-blocking - socket. - - 2008-06-30 Simon Goldschmidt - * mem.c, opt.h, stats.h: fixed bug #21433: Calling mem_free/pbuf_free from - interrupt context isn't safe: LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT allows - mem_free to run between mem_malloc iterations. Added illegal counter for - mem stats. - - 2008-06-27 Simon Goldschmidt - * stats.h/.c, some other files: patch #6483: stats module improvement: - Added defines to display each module's statistic individually, added stats - defines for MEM, MEMP and SYS modules, removed (unused) rexmit counter. - - 2008-06-17 Simon Goldschmidt - * err.h: patch #6459: Made err_t overridable to use a more efficient type - (define LWIP_ERR_T in cc.h) - - 2008-06-17 Simon Goldschmidt - * slipif.c: patch #6480: Added a configuration option for slipif for symmetry - to loopif - - 2008-06-17 Simon Goldschmidt (patch by Luca Ceresoli) - * netif.c, loopif.c, ip.c, netif.h, loopif.h, opt.h: Checked in slightly - modified version of patch # 6370: Moved loopif code to netif.c so that - loopback traffic is supported on all netifs (all local IPs). - Added option to limit loopback packets for each netifs. - - - ++ Bugfixes: - 2009-08-12 Kieran Mansley - * tcp_in.c, tcp.c: Fix bug #27209: handle trimming of segments when - out of window or out of order properly - - 2009-08-12 Kieran Mansley - * tcp_in.c: Fix bug #27199: use snd_wl2 instead of snd_wl1 - - 2009-07-28 Simon Goldschmidt - * mem.h: Fixed bug #27105: "realloc() cannot replace mem_realloc()"s - - 2009-07-27 Kieran Mansley - * api.h api_msg.h netdb.h sockets.h: add missing #include directives - - 2009-07-09 Kieran Mansley - * api_msg.c, sockets.c, api.h: BUG23240 use signed counters for - recv_avail and don't increment counters until message successfully - sent to mbox - - 2009-06-25 Kieran Mansley - * api_msg.c api.h: BUG26722: initialise netconn write variables - in netconn_alloc - - 2009-06-25 Kieran Mansley - * tcp.h: BUG26879: set ret value in TCP_EVENT macros when function is not set - - 2009-06-25 Kieran Mansley - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: BUG26301 and BUG26267: correct - simultaneous close behaviour, and make snd_nxt have the same meaning - as in the RFCs. - - 2009-05-12 Simon Goldschmidt - * etharp.h, etharp.c, netif.c: fixed bug #26507: "Gratuitous ARP depends on - arp_table / uses etharp_query" by adding etharp_gratuitous() - - 2009-05-12 Simon Goldschmidt - * ip.h, ip.c, igmp.c: bug #26487: Added ip_output_if_opt that can add IP options - to the IP header (used by igmp_ip_output_if) - - 2009-05-06 Simon Goldschmidt - * inet_chksum.c: On little endian architectures, use LWIP_PLATFORM_HTONS (if - defined) for SWAP_BYTES_IN_WORD to speed up checksumming. - - 2009-05-05 Simon Goldschmidt - * sockets.c: bug #26405: Prematurely released semaphore causes lwip_select() - to crash - - 2009-05-04 Simon Goldschmidt - * init.c: snmp was not initialized in lwip_init() - - 2009-05-04 Frédéric Bernon - * dhcp.c, netbios.c: Changes if IP_SOF_BROADCAST is enabled. - - 2009-05-03 Simon Goldschmidt - * tcp.h: bug #26349: Nagle algorithm doesn't send although segment is full - (and unsent->next == NULL) - - 2009-05-02 Simon Goldschmidt - * tcpip.h, tcpip.c: fixed tcpip_untimeout (does not need the time, broken after - 1.3.0 in CVS only) - fixes compilation of ppp_oe.c - - 2009-05-02 Simon Goldschmidt - * msg_in.c: fixed bug #25636: SNMPSET value is ignored for integer fields - - 2009-05-01 Simon Goldschmidt - * pap.c: bug #21680: PPP upap_rauthnak() drops legal NAK packets - - 2009-05-01 Simon Goldschmidt - * ppp.c: bug #24228: Memory corruption with PPP and DHCP - - 2009-04-29 Frédéric Bernon - * raw.c, udp.c, init.c, opt.h, ip.h, sockets.h: bug #26309: Implement the - SO(F)_BROADCAST filter for all API layers. Avoid the unindented reception - of broadcast packets even when this option wasn't set. Port maintainers - which want to enable this filter have to set IP_SOF_BROADCAST=1 in opt.h. - If you want this option also filter broadcast on recv operations, you also - have to set IP_SOF_BROADCAST_RECV=1 in opt.h. - - 2009-04-28 Simon Goldschmidt, Jakob Stoklund Olesen - * dhcp.c: patch #6721, bugs #25575, #25576: Some small fixes to DHCP and - DHCP/AUTOIP cooperation - - 2009-04-25 Simon Goldschmidt, Oleg Tyshev - * tcp_out.c: bug #24212: Deadlocked tcp_retransmit due to exceeded pcb->cwnd - Fixed by sorting the unsent and unacked queues (segments are inserted at the - right place in tcp_output and tcp_rexmit). - - 2009-04-25 Simon Goldschmidt - * memp.c, mem.c, memp.h, mem_std.h: bug #26213 "Problem with memory allocation - when debugging": memp_sizes contained the wrong sizes (including sanity - regions); memp pools for MEM_USE_POOLS were too small - - 2009-04-24 Simon Goldschmidt, Frédéric Bernon - * inet.c: patch #6765: Fix a small problem with the last changes (incorrect - behavior, with with ip address string not ended by a '\0', a space or a - end of line) - - 2009-04-19 Simon Goldschmidt - * rawapi.txt: Fixed bug #26069: Corrected documentation: if tcp_connect fails, - pcb->err is called, not pcb->connected (with an error code). - - 2009-04-19 Simon Goldschmidt - * tcp_out.c: Fixed bug #26236: "TCP options (timestamp) don't work with - no-copy-tcpwrite": deallocate option data, only concat segments with same flags - - 2009-04-19 Simon Goldschmidt - * tcp_out.c: Fixed bug #25094: "Zero-length pbuf" (options are now allocated - in the header pbuf, not the data pbuf) - - 2009-04-18 Simon Goldschmidt - * api_msg.c: fixed bug #25695: Segmentation fault in do_writemore() - - 2009-04-15 Simon Goldschmidt - * sockets.c: tried to fix bug #23559: lwip_recvfrom problem with tcp - - 2009-04-15 Simon Goldschmidt - * dhcp.c: task #9192: mem_free of dhcp->options_in and dhcp->msg_in - - 2009-04-15 Simon Goldschmidt - * ip.c, ip6.c, tcp_out.c, ip.h: patch #6808: Add a utility function - ip_hinted_output() (for smaller code mainly) - - 2009-04-15 Simon Goldschmidt - * inet.c: patch #6765: Supporting new line characters in inet_aton() - - 2009-04-15 Simon Goldschmidt - * dhcp.c: patch #6764: DHCP rebind and renew did not send hostnam option; - Converted constant OPTION_MAX_MSG_SIZE to netif->mtu, check if netif->mtu - is big enough in dhcp_start - - 2009-04-15 Simon Goldschmidt - * netbuf.c: bug #26027: netbuf_chain resulted in pbuf memory leak - - 2009-04-15 Simon Goldschmidt - * sockets.c, ppp.c: bug #25763: corrected 4 occurrences of SMEMCPY to MEMCPY - - 2009-04-15 Simon Goldschmidt - * sockets.c: bug #26121: set_errno can be overridden - - 2009-04-09 Kieran Mansley (patch from Luca Ceresoli ) - * init.c, opt.h: Patch#6774 TCP_QUEUE_OOSEQ breaks compilation when - LWIP_TCP==0 - - 2009-04-09 Kieran Mansley (patch from Roy Lee ) - * tcp.h: Patch#6802 Add do-while-clauses to those function like - macros in tcp.h - - 2009-03-31 Kieran Mansley - * tcp.c, tcp_in.c, tcp_out.c, tcp.h, opt.h: Rework the way window - updates are calculated and sent (BUG20515) - - * tcp_in.c: cope with SYN packets received during established states, - and retransmission of initial SYN. - - * tcp_out.c: set push bit correctly when tcp segments are merged - - 2009-03-27 Kieran Mansley - * tcp_out.c set window correctly on probes (correcting change made - yesterday) - - 2009-03-26 Kieran Mansley - * tcp.c, tcp_in.c, tcp.h: add tcp_abandon() to cope with dropping - connections where no reset required (bug #25622) - - * tcp_out.c: set TCP_ACK flag on keepalive and zero window probes - (bug #20779) - - 2009-02-18 Simon Goldschmidt (Jonathan Larmour and Bill Auerbach) - * ip_frag.c: patch #6528: the buffer used for IP_FRAG_USES_STATIC_BUF could be - too small depending on MEM_ALIGNMENT - - 2009-02-16 Simon Goldschmidt - * sockets.h/.c, api_*.h/.c: fixed arguments of socket functions to match the standard; - converted size argument of netconn_write to 'size_t' - - 2009-02-16 Simon Goldschmidt - * tcp.h, tcp.c: fixed bug #24440: TCP connection close problem on 64-bit host - by moving accept callback function pointer to TCP_PCB_COMMON - - 2009-02-12 Simon Goldschmidt - * dhcp.c: fixed bug #25345 (DHCPDECLINE is sent with "Maximum message size" - option) - - 2009-02-11 Simon Goldschmidt - * dhcp.c: fixed bug #24480 (releasing old udp_pdb and pbuf in dhcp_start) - - 2009-02-11 Simon Goldschmidt - * opt.h, api_msg.c: added configurable default valud for netconn->recv_bufsize: - RECV_BUFSIZE_DEFAULT (fixes bug #23726: pbuf pool exhaustion on slow recv()) - - 2009-02-10 Simon Goldschmidt - * tcp.c: fixed bug #25467: Listen backlog is not reset on timeout in SYN_RCVD: - Accepts_pending is decrease on a corresponding listen pcb when a connection - in state SYN_RCVD is close. - - 2009-01-28 Jonathan Larmour - * pbuf.c: reclaim pbufs from TCP out-of-sequence segments if we run - out of pool pbufs. - - 2008-12-19 Simon Goldschmidt - * many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2 - - 2008-12-10 Tamas Somogyi, Frédéric Bernon - * sockets.c: fixed bug #25051: lwip_recvfrom problem with udp: fromaddr and - port uses deleted netbuf. - - 2008-10-18 Simon Goldschmidt - * tcp_in.c: fixed bug ##24596: Vulnerability on faulty TCP options length - in tcp_parseopt - - 2008-10-15 Simon Goldschmidt - * ip_frag.c: fixed bug #24517: IP reassembly crashes on unaligned IP headers - by packing the struct ip_reass_helper. - - 2008-10-03 David Woodhouse, Jonathan Larmour - * etharp.c (etharp_arp_input): Fix type aliasing problem copying ip address. - - 2008-10-02 Jonathan Larmour - * dns.c: Hard-code structure sizes, to avoid issues on some compilers where - padding is included. - - 2008-09-30 Jonathan Larmour - * sockets.c (lwip_accept): check addr isn't NULL. If it's valid, do an - assertion check that addrlen isn't NULL. - - 2008-09-30 Jonathan Larmour - * tcp.c: Fix bug #24227, wrong error message in tcp_bind. - - 2008-08-26 Simon Goldschmidt - * inet.h, ip_addr.h: fixed bug #24132: Cross-dependency between ip_addr.h and - inet.h -> moved declaration of struct in_addr from ip_addr.h to inet.h - - 2008-08-14 Simon Goldschmidt - * api_msg.c: fixed bug #23847: do_close_internal references freed memory (when - tcp_close returns != ERR_OK) - - 2008-07-08 Frédéric Bernon - * stats.h: Fix some build bugs introduced with patch #6483 (missing some parameters - in macros, mainly if MEM_STATS=0 and MEMP_STATS=0). - - 2008-06-24 Jonathan Larmour - * tcp_in.c: Fix for bug #23693 as suggested by Art R. Ensure cseg is unused - if tcp_seg_copy fails. - - 2008-06-17 Simon Goldschmidt - * inet_chksum.c: Checked in some ideas of patch #6460 (loop optimizations) - and created defines for swapping bytes and folding u32 to u16. - - 2008-05-30 Kieran Mansley - * tcp_in.c Remove redundant "if" statement, and use real rcv_wnd - rather than rcv_ann_wnd when deciding if packets are in-window. - Contributed by - - 2008-05-30 Kieran Mansley - * mem.h: Fix BUG#23254. Change macro definition of mem_* to allow - passing as function pointers when MEM_LIBC_MALLOC is defined. - - 2008-05-09 Jonathan Larmour - * err.h, err.c, sockets.c: Fix bug #23119: Reorder timeout error code to - stop it being treated as a fatal error. - - 2008-04-15 Simon Goldschmidt - * dhcp.c: fixed bug #22804: dhcp_stop doesn't clear NETIF_FLAG_DHCP - (flag now cleared) - - 2008-03-27 Simon Goldschmidt - * mem.c, tcpip.c, tcpip.h, opt.h: fixed bug #21433 (Calling mem_free/pbuf_free - from interrupt context isn't safe): set LWIP_USE_HEAP_FROM_INTERRUPT to 1 - in lwipopts.h or use pbuf_free_callback(p)/mem_free_callback(m) to free pbufs - or heap memory from interrupt context - - 2008-03-26 Simon Goldschmidt - * tcp_in.c, tcp.c: fixed bug #22249: division by zero could occur if a remote - host sent a zero mss as TCP option. - - -(STABLE-1.3.0) - - ++ New features: - - 2008-03-10 Jonathan Larmour - * inet_chksum.c: Allow choice of one of the sample algorithms to be - made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM. - - 2008-01-22 Frédéric Bernon - * tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in - TCP_CALCULATE_EFF_SEND_MSS to have coherent TCP options names. - - 2008-01-14 Frédéric Bernon - * rawapi.txt, api_msg.c, tcp.c, tcp_in.c, tcp.h: changes for task #7675 "Enable - to refuse data on a TCP_EVENT_RECV call". Important, behavior changes for the - tcp_recv callback (see rawapi.txt). - - 2008-01-14 Frédéric Bernon, Marc Chaland - * ip.c: Integrate patch #6369" ip_input : checking before realloc". - - 2008-01-12 Frédéric Bernon - * tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field - netconn::sem per netconn::op_completed like suggested for the task #7490 - "Add return value to sys_mbox_post". - - 2008-01-12 Frédéric Bernon - * api_msg.c, opt.h: replace DEFAULT_RECVMBOX_SIZE per DEFAULT_TCP_RECVMBOX_SIZE, - DEFAULT_UDP_RECVMBOX_SIZE and DEFAULT_RAW_RECVMBOX_SIZE (to optimize queues - sizes), like suggested for the task #7490 "Add return value to sys_mbox_post". - - 2008-01-10 Frédéric Bernon - * tcpip.h, tcpip.c: add tcpip_callback_with_block function for the task #7490 - "Add return value to sys_mbox_post". tcpip_callback is always defined as - "blocking" ("block" parameter = 1). - - 2008-01-10 Frédéric Bernon - * tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field - netconn::mbox (sys_mbox_t) per netconn::sem (sys_sem_t) for the task #7490 - "Add return value to sys_mbox_post". - - 2008-01-05 Frédéric Bernon - * sys_arch.txt, api.h, api_lib.c, api_msg.h, api_msg.c, tcpip.c, sys.h, opt.h: - Introduce changes for task #7490 "Add return value to sys_mbox_post" with some - modifications in the sys_mbox api: sys_mbox_new take a "size" parameters which - indicate the number of pointers query by the mailbox. There is three defines - in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the - netconn::acceptmbox. Port maintainers, you can decide to just add this new - parameter in your implementation, but to ignore it to keep the previous behavior. - The new sys_mbox_trypost function return a value to know if the mailbox is - full or if the message is posted. Take a look to sys_arch.txt for more details. - This new function is used in tcpip_input (so, can be called in an interrupt - context since the function is not blocking), and in recv_udp and recv_raw. - - 2008-01-04 Frédéric Bernon, Simon Goldschmidt, Jonathan Larmour - * rawapi.txt, api.h, api_lib.c, api_msg.h, api_msg.c, sockets.c, tcp.h, tcp.c, - tcp_in.c, init.c, opt.h: rename backlog options with TCP_ prefix, limit the - "backlog" parameter in an u8_t, 0 is interpreted as "smallest queue", add - documentation in the rawapi.txt file. - - 2007-12-31 Kieran Mansley (based on patch from Per-Henrik Lundbolm) - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: Add TCP persist timer - - 2007-12-31 Frédéric Bernon, Luca Ceresoli - * autoip.c, etharp.c: ip_addr.h: Integrate patch #6348: "Broadcast ARP packets - in autoip". The change in etharp_raw could be removed, since all calls to - etharp_raw use ethbroadcast for the "ethdst_addr" parameter. But it could be - wrong in the future. - - 2007-12-30 Frédéric Bernon, Tom Evans - * ip.c: Fix bug #21846 "LwIP doesn't appear to perform any IP Source Address - Filtering" reported by Tom Evans. - - 2007-12-21 Frédéric Bernon, Simon Goldschmidt, Jonathan Larmour - * tcp.h, opt.h, api.h, api_msg.h, tcp.c, tcp_in.c, api_lib.c, api_msg.c, - sockets.c, init.c: task #7252: Implement TCP listen backlog: Warning: raw API - applications have to call 'tcp_accepted(pcb)' in their accept callback to - keep accepting new connections. - - 2007-12-13 Frédéric Bernon - * api_msg.c, err.h, err.c, sockets.c, dns.c, dns.h: replace "enum dns_result" - by err_t type. Add a new err_t code "ERR_INPROGRESS". - - 2007-12-12 Frédéric Bernon - * dns.h, dns.c, opt.h: move DNS options to the "right" place. Most visibles - are the one which have ram usage. - - 2007-12-05 Frédéric Bernon - * netdb.c: add a LWIP_DNS_API_HOSTENT_STORAGE option to decide to use a static - set of variables (=0) or a local one (=1). In this last case, your port should - provide a function "struct hostent* sys_thread_hostent( struct hostent* h)" - which have to do a copy of "h" and return a pointer ont the "per-thread" copy. - - 2007-12-03 Simon Goldschmidt - * ip.c: ip_input: check if a packet is for inp first before checking all other - netifs on netif_list (speeds up packet receiving in most cases) - - 2007-11-30 Simon Goldschmidt - * udp.c, raw.c: task #7497: Sort lists (pcb, netif, ...) for faster access - UDP: move a (connected) pcb selected for input to the front of the list of - pcbs so that it is found faster next time. Same for RAW pcbs that have eaten - a packet. - - 2007-11-28 Simon Goldschmidt - * etharp.c, stats.c, stats.h, opt.h: Introduced ETHARP_STATS - - 2007-11-25 Simon Goldschmidt - * dhcp.c: dhcp_unfold_reply() uses pbuf_copy_partial instead of its own copy - algorithm. - - 2007-11-24 Simon Goldschmidt - * netdb.h, netdb.c, sockets.h/.c: Moved lwip_gethostbyname from sockets.c - to the new file netdb.c; included lwip_getaddrinfo. - - 2007-11-21 Simon Goldschmidt - * tcp.h, opt.h, tcp.c, tcp_in.c: implemented calculating the effective send-mss - based on the MTU of the netif used to send. Enabled by default. Disable by - setting LWIP_CALCULATE_EFF_SEND_MSS to 0. This fixes bug #21492. - - 2007-11-19 Frédéric Bernon - * api_msg.c, dns.h, dns.c: Implement DNS_DOES_NAME_CHECK option (check if name - received match the name query), implement DNS_USES_STATIC_BUF (the place where - copy dns payload to parse the response), return an error if there is no place - for a new query, and fix some minor problems. - - 2007-11-16 Simon Goldschmidt - * new files: ipv4/inet.c, ipv4/inet_chksum.c, ipv6/inet6.c - removed files: core/inet.c, core/inet6.c - Moved inet files into ipv4/ipv6 directory; splitted inet.c/inet.h into - inet and chksum part; changed includes in all lwIP files as appropriate - - 2007-11-16 Simon Goldschmidt - * api.h, api_msg.h, api_lib.c, api_msg.c, socket.h, socket.c: Added sequential - dns resolver function for netconn api (netconn_gethostbyname) and socket api - (gethostbyname/gethostbyname_r). - - 2007-11-15 Jim Pettinato, Frédéric Bernon - * opt.h, init.c, tcpip.c, dhcp.c, dns.h, dns.c: add DNS client for simple name - requests with RAW api interface. Initialization is done in lwip_init() with - build time options. DNS timer is added in tcpip_thread context. DHCP can set - DNS server ip addresses when options are received. You need to set LWIP_DNS=1 - in your lwipopts.h file (LWIP_DNS=0 in opt.h). DNS_DEBUG can be set to get - some traces with LWIP_DEBUGF. Sanity check have been added. There is a "todo" - list with points to improve. - - 2007-11-06 Simon Goldschmidt - * opt.h, mib2.c: Patch #6215: added ifAdminStatus write support (if explicitly - enabled by defining SNMP_SAFE_REQUESTS to 0); added code to check link status - for ifOperStatus if LWIP_NETIF_LINK_CALLBACK is defined. - - 2007-11-06 Simon Goldschmidt - * api.h, api_msg.h and dependent files: Task #7410: Removed the need to include - core header files in api.h (ip/tcp/udp/raw.h) to hide the internal - implementation from netconn api applications. - - 2007-11-03 Frédéric Bernon - * api.h, api_lib.c, api_msg.c, sockets.c, opt.h: add SO_RCVBUF option for UDP & - RAW netconn. You need to set LWIP_SO_RCVBUF=1 in your lwipopts.h (it's disabled - by default). Netconn API users can use the netconn_recv_bufsize macro to access - it. This is a first release which have to be improve for TCP. Note it used the - netconn::recv_avail which need to be more "thread-safe" (note there is already - the problem for FIONREAD with lwip_ioctl/ioctlsocket). - - 2007-11-01 Frédéric Bernon, Marc Chaland - * sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, tcp.h, tcp_out.c: - Integrate "patch #6250 : MSG_MORE flag for send". MSG_MORE is used at socket api - layer, NETCONN_MORE at netconn api layer, and TCP_WRITE_FLAG_MORE at raw api - layer. This option enable to delayed TCP PUSH flag on multiple "write" calls. - Note that previous "copy" parameter for "write" APIs is now called "apiflags". - - 2007-10-24 Frédéric Bernon - * api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than - TCP_EVENT_xxx macros to get a code more readable. It could also help to remove - some code (like we have talk in "patch #5919 : Create compile switch to remove - select code"), but it could be done later. - - 2007-10-08 Simon Goldschmidt - * many files: Changed initialization: many init functions are not needed any - more since we now rely on the compiler initializing global and static - variables to zero! - - 2007-10-06 Simon Goldschmidt - * ip_frag.c, memp.c, mib2.c, ip_frag.h, memp_std.h, opt.h: Changed IP_REASSEMBLY - to enqueue the received pbufs so that multiple packets can be reassembled - simultaneously and no static reassembly buffer is needed. - - 2007-10-05 Simon Goldschmidt - * tcpip.c, etharp.h, etharp.c: moved ethernet_input from tcpip.c to etharp.c so - all netifs (or ports) can use it. - - 2007-10-05 Frédéric Bernon - * netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the - common function to reduce a little bit the footprint (for all functions using - only the "netif" parameter). - - 2007-10-03 Frédéric Bernon - * netifapi.h, netifapi.c: add functions netifapi_netif_set_up, netifapi_netif_set_down, - netifapi_autoip_start and netifapi_autoip_stop. Use a common function to reduce - a little bit the footprint (for all functions using only the "netif" parameter). - - 2007-09-15 Frédéric Bernon - * udp.h, udp.c, sockets.c: Changes for "#20503 IGMP Improvement". Add IP_MULTICAST_IF - option in socket API, and a new field "multicast_ip" in "struct udp_pcb" (for - netconn and raw API users), only if LWIP_IGMP=1. Add getsockopt processing for - IP_MULTICAST_TTL and IP_MULTICAST_IF. - - 2007-09-10 Frédéric Bernon - * snmp.h, mib2.c: enable to remove SNMP timer (which consumne several cycles - even when it's not necessary). snmp_agent.txt tell to call snmp_inc_sysuptime() - each 10ms (but, it's intrusive if you use sys_timeout feature). Now, you can - decide to call snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but - call to a lower frequency). Or, you can decide to not call snmp_inc_sysuptime() - or snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro. - This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside - snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only - when it's queried (any direct call to "sysuptime" is changed by a call to - snmp_get_sysuptime). - - 2007-09-09 Frédéric Bernon, Bill Florac - * igmp.h, igmp.c, netif.h, netif.c, ip.c: To enable to have interfaces with IGMP, - and others without it, there is a new NETIF_FLAG_IGMP flag to set in netif->flags - if you want IGMP on an interface. igmp_stop() is now called inside netif_remove(). - igmp_report_groups() is now called inside netif_set_link_up() (need to have - LWIP_NETIF_LINK_CALLBACK=1) to resend reports once the link is up (avoid to wait - the next query message to receive the matching multicast streams). - - 2007-09-08 Frédéric Bernon - * sockets.c, ip.h, api.h, tcp.h: declare a "struct ip_pcb" which only contains - IP_PCB. Add in the netconn's "pcb" union a "struct ip_pcb *ip;" (no size change). - Use this new field to access to common pcb fields (ttl, tos, so_options, etc...). - Enable to access to these fields with LWIP_TCP=0. - - 2007-09-05 Frédéric Bernon - * udp.c, ipv4/icmp.c, ipv4/ip.c, ipv6/icmp.c, ipv6/ip6.c, ipv4/icmp.h, - ipv6/icmp.h, opt.h: Integrate "task #7272 : LWIP_ICMP option". The new option - LWIP_ICMP enable/disable ICMP module inside the IP stack (enable per default). - Be careful, disabling ICMP make your product non-compliant to RFC1122, but - help to reduce footprint, and to reduce "visibility" on the Internet. - - 2007-09-05 Frédéric Bernon, Bill Florac - * opt.h, sys.h, tcpip.c, slipif.c, ppp.c, sys_arch.txt: Change parameters list - for sys_thread_new (see "task #7252 : Create sys_thread_new_ex()"). Two new - parameters have to be provided: a task name, and a task stack size. For this - one, since it's platform dependant, you could define the best one for you in - your lwipopts.h. For port maintainers, you can just add these new parameters - in your sys_arch.c file, and but it's not mandatory, use them in your OS - specific functions. - - 2007-09-05 Frédéric Bernon - * inet.c, autoip.c, msg_in.c, msg_out.c, init.c: Move some build time checkings - inside init.c for task #7142 "Sanity check user-configurable values". - - 2007-09-04 Frédéric Bernon, Bill Florac - * igmp.h, igmp.c, memp_std.h, memp.c, init.c, opt.h: Replace mem_malloc call by - memp_malloc, and use a new MEMP_NUM_IGMP_GROUP option (see opt.h to define the - value). It will avoid potential fragmentation problems, use a counter to know - how many times a group is used on an netif, and free it when all applications - leave it. MEMP_NUM_IGMP_GROUP got 8 as default value (and init.c got a sanity - check if LWIP_IGMP!=0). - - 2007-09-03 Frédéric Bernon - * igmp.h, igmp.c, sockets.c, api_msg.c: Changes for "#20503 IGMP Improvement". - Initialize igmp_mac_filter to NULL in netif_add (this field should be set in - the netif's "init" function). Use the "imr_interface" field (for socket layer) - and/or the "interface" field (for netconn layer), for join/leave operations. - The igmp_join/leavegroup first parameter change from a netif to an ipaddr. - This field could be a netif's ipaddr, or "any" (same meaning than ip_addr_isany). - - 2007-08-30 Frédéric Bernon - * Add netbuf.h, netbuf.c, Change api.h, api_lib.c: #7249 "Split netbuf functions - from api/api_lib". Now netbuf API is independant of netconn, and can be used - with other API (application based on raw API, or future "socket2" API). Ports - maintainers just have to add src/api/netbuf.c in their makefile/projects. - - 2007-08-30 Frédéric Bernon, Jonathan Larmour - * init.c: Add first version of lwip_sanity_check for task #7142 "Sanity check - user-configurable values". - - 2007-08-29 Frédéric Bernon - * igmp.h, igmp.c, tcpip.c, init.c, netif.c: change igmp_init and add igmp_start. - igmp_start is call inside netif_add. Now, igmp initialization is in the same - spirit than the others modules. Modify some IGMP debug traces. - - 2007-08-29 Frédéric Bernon - * Add init.h, init.c, Change opt.h, tcpip.c: Task #7213 "Add a lwip_init function" - Add lwip_init function to regroup all modules initializations, and to provide - a place to add code for task #7142 "Sanity check user-configurable values". - Ports maintainers should remove direct initializations calls from their code, - and add init.c in their makefiles. Note that lwip_init() function is called - inside tcpip_init, but can also be used by raw api users since all calls are - disabled when matching options are disabled. Also note that their is new options - in opt.h, you should configure in your lwipopts.h (they are enabled per default). - - 2007-08-26 Marc Boucher - * api_msg.c: do_close_internal(): Reset the callbacks and arg (conn) to NULL - since they can under certain circumstances be called with an invalid conn - pointer after the connection has been closed (and conn has been freed). - - 2007-08-25 Frédéric Bernon (Artem Migaev's Patch) - * netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up". - Add a netif_is_link_up() function if LWIP_NETIF_LINK_CALLBACK option is set. - - 2007-08-22 Frédéric Bernon - * netif.h, netif.c, opt.h: Rename LWIP_NETIF_CALLBACK in LWIP_NETIF_STATUS_CALLBACK - to be coherent with new LWIP_NETIF_LINK_CALLBACK option before next release. - - 2007-08-22 Frédéric Bernon - * tcpip.h, tcpip.c, ethernetif.c, opt.h: remove options ETHARP_TCPIP_INPUT & - ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the - name is tcpip_input (we keep the name of 1.2.0 function). - - 2007-08-17 Jared Grubb - * memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool - settings into new memp_std.h and optional user file lwippools.h. This adds - more dynamic mempools, and allows the user to create an arbitrary number of - mempools for mem_malloc. - - 2007-08-16 Marc Boucher - * api_msg.c: Initialize newconn->state to NETCONN_NONE in accept_function; - otherwise it was left to NETCONN_CLOSE and sent_tcp() could prematurely - close the connection. - - 2007-08-16 Marc Boucher - * sockets.c: lwip_accept(): check netconn_peer() error return. - - 2007-08-16 Marc Boucher - * mem.c, mem.h: Added mem_calloc(). - - 2007-08-16 Marc Boucher - * tcpip.c, tcpip.h memp.c, memp.h: Added distinct memp (MEMP_TCPIP_MSG_INPKT) - for input packets to prevent floods from consuming all of MEMP_TCPIP_MSG - and starving other message types. - Renamed MEMP_TCPIP_MSG to MEMP_TCPIP_MSG_API - - 2007-08-16 Marc Boucher - * pbuf.c, pbuf.h, etharp.c, tcp_in.c, sockets.c: Split pbuf flags in pbuf - type and flgs (later renamed to flags). - Use enum pbuf_flag as pbuf_type. Renumber PBUF_FLAG_*. - Improved lwip_recvfrom(). TCP push now propagated. - - 2007-08-16 Marc Boucher - * ethernetif.c, contrib/ports/various: ethbroadcast now a shared global - provided by etharp. - - 2007-08-16 Marc Boucher - * ppp_oe.c ppp_oe.h, auth.c chap.c fsm.c lcp.c ppp.c ppp.h, - etharp.c ethernetif.c, etharp.h, opt.h tcpip.h, tcpip.c: - Added PPPoE support and various PPP improvements. - - 2007-07-25 Simon Goldschmidt - * api_lib.c, ip_frag.c, pbuf.c, api.h, pbuf.h: Introduced pbuf_copy_partial, - making netbuf_copy_partial use this function. - - 2007-07-25 Simon Goldschmidt - * tcp_in.c: Fix bug #20506: Slow start / initial congestion window starts with - 2 * mss (instead of 1 * mss previously) to comply with some newer RFCs and - other stacks. - - 2007-07-13 Jared Grubb (integrated by Frédéric Bernon) - * opt.h, netif.h, netif.c, ethernetif.c: Add new configuration option to add - a link callback in the netif struct, and functions to handle it. Be carefull - for port maintainers to add the NETIF_FLAG_LINK_UP flag (like in ethernetif.c) - if you want to be sure to be compatible with future changes... - - 2007-06-30 Frédéric Bernon - * sockets.h, sockets.c: Implement MSG_PEEK flag for recv/recvfrom functions. - - 2007-06-21 Simon Goldschmidt - * etharp.h, etharp.c: Combined etharp_request with etharp_raw for both - LWIP_AUTOIP =0 and =1 to remove redundant code. - - 2007-06-21 Simon Goldschmidt - * mem.c, memp.c, mem.h, memp.h, opt.h: task #6863: Introduced the option - MEM_USE_POOLS to use 4 pools with different sized elements instead of a - heap. This both prevents memory fragmentation and gives a higher speed - at the cost of more memory consumption. Turned off by default. - - 2007-06-21 Simon Goldschmidt - * api_lib.c, api_msg.c, api.h, api_msg.h: Converted the length argument of - netconn_write (and therefore also api_msg_msg.msg.w.len) from u16_t into - int to be able to send a bigger buffer than 64K with one time (mainly - used from lwip_send). - - 2007-06-21 Simon Goldschmidt - * tcp.h, api_msg.c: Moved the nagle algorithm from netconn_write/do_write - into a define (tcp_output_nagle) in tcp.h to provide it to raw api users, too. - - 2007-06-21 Simon Goldschmidt - * api.h, api_lib.c, api_msg.c: Fixed bug #20021: Moved sendbuf-processing in - netconn_write from api_lib.c to api_msg.c to also prevent multiple context- - changes on low memory or empty send-buffer. - - 2007-06-18 Simon Goldschmidt - * etharp.c, etharp.h: Changed etharp to use a defined hardware address length - of 6 to avoid loading netif->hwaddr_len every time (since this file is only - used for ethernet and struct eth_addr already had a defined length of 6). - - 2007-06-17 Simon Goldschmidt - * sockets.c, sockets.h: Implemented socket options SO_NO_CHECK for UDP sockets - to disable UDP checksum generation on transmit. - - 2007-06-13 Frédéric Bernon, Simon Goldschmidt - * debug.h, api_msg.c: change LWIP_ERROR to use it to check errors like invalid - pointers or parameters, and let the possibility to redefined it in cc.h. Use - this macro to check "conn" parameter in api_msg.c functions. - - 2007-06-11 Simon Goldschmidt - * sockets.c, sockets.h: Added UDP lite support for sockets - - 2007-06-10 Simon Goldschmidt - * udp.h, opt.h, api_msg.c, ip.c, udp.c: Included switch LWIP_UDPLITE (enabled - by default) to switch off UDP-Lite support if not needed (reduces udp.c code - size) - - 2007-06-09 Dominik Spies (integrated by Frédéric Bernon) - * autoip.h, autoip.c, dhcp.h, dhcp.c, netif.h, netif.c, etharp.h, etharp.c, opt.h: - AutoIP implementation available for IPv4, with new options LWIP_AUTOIP and - LWIP_DHCP_AUTOIP_COOP if you want to cooperate with DHCP. Some tips to adapt - (see TODO mark in the source code). - - 2007-06-09 Simon Goldschmidt - * etharp.h, etharp.c, ethernetif.c: Modified order of parameters for - etharp_output() to match netif->output so etharp_output() can be used - directly as netif->output to save one function call. - - 2007-06-08 Simon Goldschmidt - * netif.h, ethernetif.c, slipif.c, loopif.c: Added define - NETIF_INIT_SNMP(netif, type, speed) to initialize per-netif snmp variables, - added initialization of those to ethernetif, slipif and loopif. - - 2007-05-18 Simon Goldschmidt - * opt.h, ip_frag.c, ip_frag.h, ip.c: Added option IP_FRAG_USES_STATIC_BUF - (defaulting to off for now) that can be set to 0 to send fragmented - packets by passing PBUF_REFs down the stack. - - 2007-05-23 Frédéric Bernon - * api_lib.c: Implement SO_RCVTIMEO for accept and recv on TCP - connections, such present in patch #5959. - - 2007-05-23 Frédéric Bernon - * api.h, api_lib.c, api_msg.c, sockets.c: group the different NETCONN_UDPxxx - code in only one part... - - 2007-05-18 Simon Goldschmidt - * opt.h, memp.h, memp.c: Added option MEMP_OVERFLOW_CHECK to check for memp - elements to overflow. This is achieved by adding some bytes before and after - each pool element (increasing their size, of course), filling them with a - prominent value and checking them on freeing the element. - Set it to 2 to also check every element in every pool each time memp_malloc() - or memp_free() is called (slower but more helpful). - - 2007-05-10 Simon Goldschmidt - * opt.h, memp.h, memp.c, pbuf.c (see task #6831): use a new memp pool for - PBUF_POOL pbufs instead of the old pool implementation in pbuf.c to reduce - code size. - - 2007-05-11 Frédéric Bernon - * sockets.c, api_lib.c, api_msg.h, api_msg.c, netifapi.h, netifapi.c, tcpip.c: - Include a function pointer instead of a table index in the message to reduce - footprint. Disable some part of lwip_send and lwip_sendto if some options are - not set (LWIP_TCP, LWIP_UDP, LWIP_RAW). - - 2007-05-10 Simon Goldschmidt - * *.h (except netif/ppp/*.h): Included patch #5448: include '#ifdef __cplusplus - \ extern "C" {' in all header files. Now you can write your application using - the lwIP stack in C++ and simply #include the core files. Note I have left - out the netif/ppp/*h header files for now, since I don't know which files are - included by applications and which are for internal use only. - - 2007-05-09 Simon Goldschmidt - * opt.h, *.c/*.h: Included patch #5920: Create define to override C-library - memcpy. 2 Defines are created: MEMCPY() for normal memcpy, SMEMCPY() for - situations where some compilers might inline the copy and save a function - call. Also replaced all calls to memcpy() with calls to (S)MEMCPY(). - - 2007-05-08 Simon Goldschmidt - * mem.h: If MEM_LIBC_MALLOC==1, allow the defines (e.g. mem_malloc() -> malloc()) - to be overriden in case the C-library malloc implementation is not protected - against concurrent access. - - 2007-05-04 Simon Goldschmidt (Atte Kojo) - * etharp.c: Introduced fast one-entry-cache to speed up ARP lookup when sending - multiple packets to the same host. - - 2007-05-04 Frédéric Bernon, Jonathan Larmour - * sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fix bug #19162 "lwip_sento: a possible - to corrupt remote addr/port connection state". Reduce problems "not enought memory" with - netbuf (if we receive lot of datagrams). Improve lwip_sendto (only one exchange between - sockets api and api_msg which run in tcpip_thread context). Add netconn_sento function. - Warning, if you directly access to "fromaddr" & "fromport" field from netbuf struct, - these fields are now renamed "addr" & "port". - - 2007-04-11 Jonathan Larmour - * sys.h, api_lib.c: Provide new sys_mbox_tryfetch function. Require ports to provide new - sys_arch_mbox_tryfetch function to get a message if one is there, otherwise return - with SYS_MBOX_EMPTY. sys_arch_mbox_tryfetch can be implemented as a function-like macro - by the port in sys_arch.h if desired. - - 2007-04-06 Frédéric Bernon, Simon Goldschmidt - * opt.h, tcpip.h, tcpip.c, netifapi.h, netifapi.c: New configuration option LWIP_NETIF_API - allow to use thread-safe functions to add/remove netif in list, and to start/stop dhcp - clients, using new functions from netifapi.h. Disable as default (no port change to do). - - 2007-04-05 Frédéric Bernon - * sockets.c: remplace ENOBUFS errors on alloc_socket by ENFILE to be more BSD compliant. - - 2007-04-04 Simon Goldschmidt - * arch.h, api_msg.c, dhcp.c, msg_in.c, sockets.c: Introduced #define LWIP_UNUSED_ARG(x) - use this for and architecture-independent form to tell the compiler you intentionally - are not using this variable. Can be overriden in cc.h. - - 2007-03-28 Frédéric Bernon - * opt.h, netif.h, dhcp.h, dhcp.c: New configuration option LWIP_NETIF_HOSTNAME allow to - define a hostname in netif struct (this is just a pointer, so, you can use a hardcoded - string, point on one of your's ethernetif field, or alloc a string you will free yourself). - It will be used by DHCP to register a client hostname, but can also be use when you call - snmp_set_sysname. - - 2007-03-28 Frédéric Bernon - * netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to - initialize a network interface's flag with. It tell this interface is an ethernet - device, and we can use ARP with it to do a "gratuitous ARP" (RFC 3220 "IP Mobility - Support for IPv4" section 4.6) when interface is "up" with netif_set_up(). - - 2007-03-26 Frédéric Bernon, Jonathan Larmour - * opt.h, tcpip.c: New configuration option LWIP_ARP allow to disable ARP init at build - time if you only use PPP or SLIP. The default is enable. Note we don't have to call - etharp_init in your port's initilization sequence if you use tcpip.c, because this call - is done in tcpip_init function. - - 2007-03-22 Frédéric Bernon - * stats.h, stats.c, msg_in.c: Stats counters can be change to u32_t if necessary with the - new option LWIP_STATS_LARGE. If you need this option, define LWIP_STATS_LARGE to 1 in - your lwipopts.h. More, unused counters are not defined in the stats structs, and not - display by stats_display(). Note that some options (SYS_STATS and RAW_STATS) are defined - but never used. Fix msg_in.c with the correct #if test for a stat display. - - 2007-03-21 Kieran Mansley - * netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com). - Provides callback on netif up/down state change. - - 2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds - * sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c, - ip.c, netif.h, tcpip.c, opt.h: - New configuration option LWIP_IGMP to enable IGMP processing. Based on only one - filter per all network interfaces. Declare a new function in netif to enable to - control the MAC filter (to reduce lwIP traffic processing). - - 2007-03-11 Frédéric Bernon - * tcp.h, tcp.c, sockets.c, tcp_out.c, tcp_in.c, opt.h: Keepalive values can - be configured at run time with LWIP_TCP_KEEPALIVE, but don't change this - unless you know what you're doing (default are RFC1122 compliant). Note - that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set in seconds. - - 2007-03-08 Frédéric Bernon - * tcp.h: Keepalive values can be configured at compile time, but don't change - this unless you know what you're doing (default are RFC1122 compliant). - - 2007-03-08 Frédéric Bernon - * sockets.c, api.h, api_lib.c, tcpip.c, sys.h, sys.c, err.c, opt.h: - Implement LWIP_SO_RCVTIMEO configuration option to enable/disable SO_RCVTIMEO - on UDP sockets/netconn. - - 2007-03-08 Simon Goldschmidt - * snmp_msg.h, msg_in.c: SNMP UDP ports can be configured at compile time. - - 2007-03-06 Frédéric Bernon - * api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h: - Implement SO_RCVTIMEO on UDP sockets/netconn. - - 2007-02-28 Kieran Mansley (based on patch from Simon Goldschmidt) - * api_lib.c, tcpip.c, memp.c, memp.h: make API msg structs allocated - on the stack and remove the API msg type from memp - - 2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt) - * sockets.h, sockets.c: Move socket initialization to new - lwip_socket_init() function. - NOTE: this changes the API with ports. Ports will have to be - updated to call lwip_socket_init() now. - - 2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt) - * api_lib.c: Use memcpy in netbuf_copy_partial. - - - ++ Bug fixes: - - 2008-03-17 Frédéric Bernon, Ed Kerekes - * igmp.h, igmp.c: Fix bug #22613 "IGMP iphdr problem" (could have - some problems to fill the IP header on some targets, use now the - ip.h macros to do it). - - 2008-03-13 Frédéric Bernon - * sockets.c: Fix bug #22435 "lwip_recvfrom with TCP break;". Using - (lwip_)recvfrom with valid "from" and "fromlen" parameters, on a - TCP connection caused a crash. Note that using (lwip_)recvfrom - like this is a bit slow and that using (lwip)getpeername is the - good lwip way to do it (so, using recv is faster on tcp sockets). - - 2008-03-12 Frédéric Bernon, Jonathan Larmour - * api_msg.c, contrib/apps/ping.c: Fix bug #22530 "api_msg.c's - recv_raw() does not consume data", and the ping sample (with - LWIP_SOCKET=1, the code did the wrong supposition that lwip_recvfrom - returned the IP payload, without the IP header). - - 2008-03-04 Jonathan Larmour - * mem.c, stats.c, mem.h: apply patch #6414 to avoid compiler errors - and/or warnings on some systems where mem_size_t and size_t differ. - * pbuf.c, ppp.c: Fix warnings on some systems with mem_malloc. - - 2008-03-04 Kieran Mansley (contributions by others) - * Numerous small compiler error/warning fixes from contributions to - mailing list after 1.3.0 release candidate made. - - 2008-01-25 Cui hengbin (integrated by Frédéric Bernon) - * dns.c: Fix bug #22108 "DNS problem" caused by unaligned structures. - - 2008-01-15 Kieran Mansley - * tcp_out.c: BUG20511. Modify persist timer to start when we are - prevented from sending by a small send window, not just a zero - send window. - - 2008-01-09 Jonathan Larmour - * opt.h, ip.c: Rename IP_OPTIONS define to IP_OPTIONS_ALLOWED to avoid - conflict with Linux system headers. - - 2008-01-06 Jonathan Larmour - * dhcp.c: fix bug #19927: "DHCP NACK problem" by clearing any existing set IP - address entirely on receiving a DHCPNAK, and restarting discovery. - - 2007-12-21 Simon Goldschmidt - * sys.h, api_lib.c, api_msg.c, sockets.c: fix bug #21698: "netconn->recv_avail - is not protected" by using new macros for interlocked access to modify/test - netconn->recv_avail. - - 2007-12-20 Kieran Mansley (based on patch from Oleg Tyshev) - * tcp_in.c: fix bug# 21535 (nrtx not reset correctly in SYN_SENT state) - - 2007-12-20 Kieran Mansley (based on patch from Per-Henrik Lundbolm) - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: fix bug #20199 (better handling - of silly window avoidance and prevent lwIP from shrinking the window) - - 2007-12-04 Simon Goldschmidt - * tcp.c, tcp_in.c: fix bug #21699 (segment leak in ooseq processing when last - data packet was lost): add assert that all segment lists are empty in - tcp_pcb_remove before setting pcb to CLOSED state; don't directly set CLOSED - state from LAST_ACK in tcp_process - - 2007-12-02 Simon Goldschmidt - * sockets.h: fix bug #21654: exclude definition of struct timeval from #ifndef FD_SET - If including for system-struct timeval, LWIP_TIMEVAL_PRIVATE now - has to be set to 0 in lwipopts.h - - 2007-12-02 Simon Goldschmidt - * api_msg.c, api_lib.c: fix bug #21656 (recvmbox problem in netconn API): always - allocate a recvmbox in netconn_new_with_proto_and_callback. For a tcp-listen - netconn, this recvmbox is later freed and a new mbox is allocated for acceptmbox. - This is a fix for thread-safety and allocates all items needed for a netconn - when the netconn is created. - - 2007-11-30 Simon Goldschmidt - * udp.c: first attempt to fix bug #21655 (DHCP doesn't work reliably with multiple - netifs): if LWIP_DHCP is enabled, UDP packets to DHCP_CLIENT_PORT are passed - to netif->dhcp->pcb only (if that exists) and not to any other pcb for the same - port (only solution to let UDP pcbs 'bind' to a netif instead of an IP address) - - 2007-11-27 Simon Goldschmidt - * ip.c: fixed bug #21643 (udp_send/raw_send don't fail if netif is down) by - letting ip_route only use netifs that are up. - - 2007-11-27 Simon Goldschmidt - * err.h, api_lib.c, api_msg.c, sockets.c: Changed error handling: ERR_MEM, ERR_BUF - and ERR_RTE are seen as non-fatal, all other errors are fatal. netconns and - sockets block most operations once they have seen a fatal error. - - 2007-11-27 Simon Goldschmidt - * udp.h, udp.c, dhcp.c: Implemented new function udp_sendto_if which takes the - netif to send as an argument (to be able to send on netifs that are down). - - 2007-11-26 Simon Goldschmidt - * tcp_in.c: Fixed bug #21582: pcb->acked accounting can be wrong when ACKs - arrive out-of-order - - 2007-11-21 Simon Goldschmidt - * tcp.h, tcp_out.c, api_msg.c: Fixed bug #20287: tcp_output_nagle sends too early - Fixed the nagle algorithm; nagle now also works for all raw API applications - and has to be explicitly disabled with 'tcp_pcb->flags |= TF_NODELAY' - - 2007-11-12 Frédéric Bernon - * sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fixed bug #20900. Now, most - of the netconn_peer and netconn_addr processing is done inside tcpip_thread - context in do_getaddr. - - 2007-11-10 Simon Goldschmidt - * etharp.c: Fixed bug: assert fired when MEMP_ARP_QUEUE was empty (which can - happen any time). Now the packet simply isn't enqueued when out of memory. - - 2007-11-01 Simon Goldschmidt - * tcp.c, tcp_in.c: Fixed bug #21494: The send mss (pcb->mss) is set to 536 (or - TCP_MSS if that is smaller) as long as no MSS option is received from the - remote host. - - 2007-11-01 Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c: Fixed bug #21491: The MSS option sent (with SYN) - is now based on TCP_MSS instead of pcb->mss (on passive open now effectively - sending our configured TCP_MSS instead of the one received). - - 2007-11-01 Simon Goldschmidt - * tcp_in.c: Fixed bug #21181: On active open, the initial congestion window was - calculated based on the configured TCP_MSS, not on the MSS option received - with SYN+ACK. - - 2007-10-09 Simon Goldschmidt - * udp.c, inet.c, inet.h: Fixed UDPLite: send: Checksum was always generated too - short and also was generated wrong if checksum coverage != tot_len; - receive: checksum was calculated wrong if checksum coverage != tot_len - - 2007-10-08 Simon Goldschmidt - * mem.c: lfree was not updated in mem_realloc! - - 2007-10-07 Frédéric Bernon - * sockets.c, api.h, api_lib.c: First step to fix "bug #20900 : Potential - crash error problem with netconn_peer & netconn_addr". VERY IMPORTANT: - this change cause an API breakage for netconn_addr, since a parameter - type change. Any compiler should cause an error without any changes in - yours netconn_peer calls (so, it can't be a "silent change"). It also - reduce a little bit the footprint for socket layer (lwip_getpeername & - lwip_getsockname use now a common lwip_getaddrname function since - netconn_peer & netconn_addr have the same parameters). - - 2007-09-20 Simon Goldschmidt - * tcp.c: Fixed bug #21080 (tcp_bind without check pcbs in TIME_WAIT state) - by checking tcp_tw_pcbs also - - 2007-09-19 Simon Goldschmidt - * icmp.c: Fixed bug #21107 (didn't reset IP TTL in ICMP echo replies) - - 2007-09-15 Mike Kleshov - * mem.c: Fixed bug #21077 (inaccuracy in calculation of lwip_stat.mem.used) - - 2007-09-06 Frédéric Bernon - * several-files: replace some #include "arch/cc.h" by "lwip/arch.h", or simply remove - it as long as "lwip/opt.h" is included before (this one include "lwip/debug.h" which - already include "lwip/arch.h"). Like that, default defines are provided by "lwip/arch.h" - if they are not defined in cc.h, in the same spirit than "lwip/opt.h" for lwipopts.h. - - 2007-08-30 Frédéric Bernon - * igmp.h, igmp.c: Some changes to remove some redundant code, add some traces, - and fix some coding style. - - 2007-08-28 Frédéric Bernon - * tcpip.c: Fix TCPIP_MSG_INPKT processing: now, tcpip_input can be used for any - kind of packets. These packets are considered like Ethernet packets (payload - pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets - are considered like IP packets (payload pointing to iphdr). - - 2007-08-27 Frédéric Bernon - * api.h, api_lib.c, api_msg.c: First fix for "bug #20900 : Potential crash error - problem with netconn_peer & netconn_addr". Introduce NETCONN_LISTEN netconn_state - and remove obsolete ones (NETCONN_RECV & NETCONN_ACCEPT). - - 2007-08-24 Kieran Mansley - * inet.c Modify (acc >> 16) test to ((acc >> 16) != 0) to help buggy - compiler (Paradigm C++) - - 2007-08-09 Frédéric Bernon, Bill Florac - * stats.h, stats.c, igmp.h, igmp.c, opt.h: Fix for bug #20503 : IGMP Improvement. - Introduce IGMP_STATS to centralize statistics management. - - 2007-08-09 Frédéric Bernon, Bill Florac - * udp.c: Fix for bug #20503 : IGMP Improvement. Enable to receive a multicast - packet on a udp pcb binded on an netif's IP address, and not on "any". - - 2007-08-09 Frédéric Bernon, Bill Florac - * igmp.h, igmp.c, ip.c: Fix minor changes from bug #20503 : IGMP Improvement. - This is mainly on using lookup/lookfor, and some coding styles... - - 2007-07-26 Frédéric Bernon (and "thedoctor") - * igmp.c: Fix bug #20595 to accept IGMPv3 "Query" messages. - - 2007-07-25 Simon Goldschmidt - * api_msg.c, tcp.c: Another fix for bug #20021: by not returning an error if - tcp_output fails in tcp_close, the code in do_close_internal gets simpler - (tcp_output is called again later from tcp timers). - - 2007-07-25 Simon Goldschmidt - * ip_frag.c: Fixed bug #20429: use the new pbuf_copy_partial instead of the old - copy_from_pbuf, which illegally modified the given pbuf. - - 2007-07-25 Simon Goldschmidt - * tcp_out.c: tcp_enqueue: pcb->snd_queuelen didn't work for chaine PBUF_RAMs: - changed snd_queuelen++ to snd_queuelen += pbuf_clen(p). - - 2007-07-24 Simon Goldschmidt - * api_msg.c, tcp.c: Fix bug #20480: Check the pcb passed to tcp_listen() for the - correct state (must be CLOSED). - - 2007-07-13 Thomas Taranowski (commited by Jared Grubb) - * memp.c: Fix bug #20478: memp_malloc returned NULL+MEMP_SIZE on failed - allocation. It now returns NULL. - - 2007-07-13 Frédéric Bernon - * api_msg.c: Fix bug #20318: api_msg "recv" callbacks don't call pbuf_free in - all error cases. - - 2007-07-13 Frédéric Bernon - * api_msg.c: Fix bug #20315: possible memory leak problem if tcp_listen failed, - because current code doesn't follow rawapi.txt documentation. - - 2007-07-13 Kieran Mansley - * src/core/tcp_in.c Apply patch#5741 from Oleg Tyshev to fix bug in - out of sequence processing of received packets - - 2007-07-03 Simon Goldschmidt - * nearly-all-files: Added assertions where PBUF_RAM pbufs are used and an - assumption is made that this pbuf is in one piece (i.e. not chained). These - assumptions clash with the possibility of converting to fully pool-based - pbuf implementations, where PBUF_RAM pbufs might be chained. - - 2007-07-03 Simon Goldschmidt - * api.h, api_lib.c, api_msg.c: Final fix for bug #20021 and some other problems - when closing tcp netconns: removed conn->sem, less context switches when - closing, both netconn_close and netconn_delete should safely close tcp - connections. - - 2007-07-02 Simon Goldschmidt - * ipv4/ip.h, ipv6/ip.h, opt.h, netif.h, etharp.h, ipv4/ip.c, netif.c, raw.c, - tcp_out.c, udp.c, etharp.c: Added option LWIP_NETIF_HWADDRHINT (default=off) - to cache ARP table indices with each pcb instead of single-entry cache for - the complete stack. - - 2007-07-02 Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c, tcp_out.c: Added some ASSERTS and casts to prevent - warnings when assigning to smaller types. - - 2007-06-28 Simon Goldschmidt - * tcp_out.c: Added check to prevent tcp_pcb->snd_queuelen from overflowing. - - 2007-06-28 Simon Goldschmidt - * tcp.h: Fixed bug #20287: Fixed nagle algorithm (sending was done too early if - a segment contained chained pbufs) - - 2007-06-28 Frédéric Bernon - * autoip.c: replace most of rand() calls by a macro LWIP_AUTOIP_RAND which compute - a "pseudo-random" value based on netif's MAC and some autoip fields. It's always - possible to define this macro in your own lwipopts.h to always use C library's - rand(). Note that autoip_create_rand_addr doesn't use this macro. - - 2007-06-28 Frédéric Bernon - * netifapi.h, netifapi.c, tcpip.h, tcpip.c: Update code to handle the option - LWIP_TCPIP_CORE_LOCKING, and do some changes to be coherent with last modifications - in api_lib/api_msg (use pointers and not type with table, etc...) - - 2007-06-26 Simon Goldschmidt - * udp.h: Fixed bug #20259: struct udp_hdr was lacking the packin defines. - - 2007-06-25 Simon Goldschmidt - * udp.c: Fixed bug #20253: icmp_dest_unreach was called with a wrong p->payload - for udp packets with no matching pcb. - - 2007-06-25 Simon Goldschmidt - * udp.c: Fixed bug #20220: UDP PCB search in udp_input(): a non-local match - could get udp input packets if the remote side matched. - - 2007-06-13 Simon Goldschmidt - * netif.c: Fixed bug #20180 (TCP pcbs listening on IP_ADDR_ANY could get - changed in netif_set_ipaddr if previous netif->ip_addr.addr was 0. - - 2007-06-13 Simon Goldschmidt - * api_msg.c: pcb_new sets conn->err if protocol is not implemented - -> netconn_new_..() does not allocate a new connection for unsupported - protocols. - - 2007-06-13 Frédéric Bernon, Simon Goldschmidt - * api_lib.c: change return expression in netconn_addr and netconn_peer, because - conn->err was reset to ERR_OK without any reasons (and error was lost)... - - 2007-06-13 Frédéric Bernon, Matthias Weisser - * opt.h, mem.h, mem.c, memp.c, pbuf.c, ip_frag.c, vj.c: Fix bug #20162. Rename - MEM_ALIGN in LWIP_MEM_ALIGN and MEM_ALIGN_SIZE in LWIP_MEM_ALIGN_SIZE to avoid - some macro names collision with some OS macros. - - 2007-06-11 Simon Goldschmidt - * udp.c: UDP Lite: corrected the use of chksum_len (based on RFC3828: if it's 0, - create checksum over the complete packet. On RX, if it's < 8 (and not 0), - discard the packet. Also removed the duplicate 'udphdr->chksum = 0' for both - UDP & UDP Lite. - - 2007-06-11 Srinivas Gollakota & Oleg Tyshev - * tcp_out.c: Fix for bug #20075 : "A problem with keep-alive timer and TCP flags" - where TCP flags wasn't initialized in tcp_keepalive. - - 2007-06-03 Simon Goldschmidt - * udp.c: udp_input(): Input pbuf was not freed if pcb had no recv function - registered, p->payload was modified without modifying p->len if sending - icmp_dest_unreach() (had no negative effect but was definitively wrong). - - 2007-06-03 Simon Goldschmidt - * icmp.c: Corrected bug #19937: For responding to an icmp echo request, icmp - re-used the input pbuf even if that didn't have enough space to include the - link headers. Now the space is tested and a new pbuf is allocated for the - echo response packet if the echo request pbuf isn't big enough. - - 2007-06-01 Simon Goldschmidt - * sockets.c: Checked in patch #5914: Moved sockopt processing into tcpip_thread. - - 2007-05-23 Frédéric Bernon - * api_lib.c, sockets.c: Fixed bug #5958 for netconn_listen (acceptmbox only - allocated by do_listen if success) and netconn_accept errors handling. In - most of api_lib functions, we replace some errors checkings like "if (conn==NULL)" - by ASSERT, except for netconn_delete. - - 2007-05-23 Frédéric Bernon - * api_lib.c: Fixed bug #5957 "Safe-thread problem inside netconn_recv" to return - an error code if it's impossible to fetch a pbuf on a TCP connection (and not - directly close the recvmbox). - - 2007-05-22 Simon Goldschmidt - * tcp.c: Fixed bug #1895 (tcp_bind not correct) by introducing a list of - bound but unconnected (and non-listening) tcp_pcbs. - - 2007-05-22 Frédéric Bernon - * sys.h, sys.c, api_lib.c, tcpip.c: remove sys_mbox_fetch_timeout() (was only - used for LWIP_SO_RCVTIMEO option) and use sys_arch_mbox_fetch() instead of - sys_mbox_fetch() in api files. Now, users SHOULD NOT use internal lwIP features - like "sys_timeout" in their application threads. - - 2007-05-22 Frédéric Bernon - * api.h, api_lib.c, api_msg.h, api_msg.c: change the struct api_msg_msg to see - which parameters are used by which do_xxx function, and to avoid "misusing" - parameters (patch #5938). - - 2007-05-22 Simon Goldschmidt - * api_lib.c, api_msg.c, raw.c, api.h, api_msg.h, raw.h: Included patch #5938: - changed raw_pcb.protocol from u16_t to u8_t since for IPv4 and IPv6, proto - is only 8 bits wide. This affects the api, as there, the protocol was - u16_t, too. - - 2007-05-18 Simon Goldschmidt - * memp.c: addition to patch #5913: smaller pointer was returned but - memp_memory was the same size -> did not save memory. - - 2007-05-16 Simon Goldschmidt - * loopif.c, slipif.c: Fix bug #19729: free pbuf if netif->input() returns - != ERR_OK. - - 2007-05-16 Simon Goldschmidt - * api_msg.c, udp.c: If a udp_pcb has a local_ip set, check if it is the same - as the one of the netif used for sending to prevent sending from old - addresses after a netif address gets changed (partly fixes bug #3168). - - 2007-05-16 Frédéric Bernon - * tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work - with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in - tcpip_init) because we have to be sure that network interfaces are already - added (mac filter is updated only in igmp_init for the moment). - - 2007-05-16 Simon Goldschmidt - * mem.c, memp.c: Removed semaphores from memp, changed sys_sem_wait calls - into sys_arch_sem_wait calls to prevent timers from running while waiting - for the heap. This fixes bug #19167. - - 2007-05-13 Simon Goldschmidt - * tcp.h, sockets.h, sockets.c: Fixed bug from patch #5865 by moving the defines - for socket options (lwip_set/-getsockopt) used with level IPPROTO_TCP from - tcp.h to sockets.h. - - 2007-05-07 Simon Goldschmidt - * mem.c: Another attempt to fix bug #17922. - - 2007-05-04 Simon Goldschmidt - * pbuf.c, pbuf.h, etharp.c: Further update to ARP queueing: Changed pbuf_copy() - implementation so that it can be reused (don't allocate the target - pbuf inside pbuf_copy()). - - 2007-05-04 Simon Goldschmidt - * memp.c: checked in patch #5913: in memp_malloc() we can return memp as mem - to save a little RAM (next pointer of memp is not used while not in pool). - - 2007-05-03 "maq" - * sockets.c: Fix ioctl FIONREAD when some data remains from last recv. - (patch #3574). - - 2007-04-23 Simon Goldschmidt - * loopif.c, loopif.h, opt.h, src/netif/FILES: fix bug #2595: "loopif results - in NULL reference for incoming TCP packets". Loopif has to be configured - (using LWIP_LOOPIF_MULTITHREADING) to directly call netif->input() - (multithreading environments, e.g. netif->input() = tcpip_input()) or - putting packets on a list that is fed to the stack by calling loopif_poll() - (single-thread / NO_SYS / polling environment where e.g. - netif->input() = ip_input). - - 2007-04-17 Jonathan Larmour - * pbuf.c: Use s32_t in pbuf_realloc(), as an s16_t can't reliably hold - the difference between two u16_t's. - * sockets.h: FD_SETSIZE needs to match number of sockets, which is - MEMP_NUM_NETCONN in sockets.c right now. - - 2007-04-12 Jonathan Larmour - * icmp.c: Reset IP header TTL in ICMP ECHO responses (bug #19580). - - 2007-04-12 Kieran Mansley - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: Modify way the retransmission - timer is reset to fix bug#19434, with help from Oleg Tyshev. - - 2007-04-11 Simon Goldschmidt - * etharp.c, pbuf.c, pbuf.h: 3rd fix for bug #11400 (arp-queuing): More pbufs than - previously thought need to be copied (everything but PBUF_ROM!). Cleaned up - pbuf.c: removed functions no needed any more (by etharp). - - 2007-04-11 Kieran Mansley - * inet.c, ip_addr.h, sockets.h, sys.h, tcp.h: Apply patch #5745: Fix - "Constant is long" warnings with 16bit compilers. Contributed by - avatar@mmlab.cse.yzu.edu.tw - - 2007-04-05 Frédéric Bernon, Jonathan Larmour - * api_msg.c: Fix bug #16830: "err_tcp() posts to connection mailbox when no pend on - the mailbox is active". Now, the post is only done during a connect, and do_send, - do_write and do_join_leave_group don't do anything if a previous error was signaled. - - 2007-04-03 Frédéric Bernon - * ip.c: Don't set the IP_DF ("Don't fragment") flag in the IP header in IP output - packets. See patch #5834. - - 2007-03-30 Frédéric Bernon - * api_msg.c: add a "pcb_new" helper function to avoid redundant code, and to add - missing pcb allocations checking (in do_bind, and for each raw_new). Fix style. - - 2007-03-30 Frédéric Bernon - * most of files: prefix all debug.h define with "LWIP_" to avoid any conflict with - others environment defines (these were too "generic"). - - 2007-03-28 Frédéric Bernon - * api.h, api_lib.c, sockets.c: netbuf_ref doesn't check its internal pbuf_alloc call - result and can cause a crash. lwip_send now check netbuf_ref result. - - 2007-03-28 Simon Goldschmidt - * sockets.c Remove "#include " from sockets.c to avoid multiple - definition of macros (in errno.h and lwip/arch.h) if LWIP_PROVIDE_ERRNO is - defined. This is the way it should have been already (looking at - doc/sys_arch.txt) - - 2007-03-28 Kieran Mansley - * opt.h Change default PBUF_POOL_BUFSIZE (again) to accomodate default MSS + - IP and TCP headers *and* physical link headers - - 2007-03-26 Frédéric Bernon (based on patch from Dmitry Potapov) - * api_lib.c: patch for netconn_write(), fixes a possible race condition which cause - to send some garbage. It is not a definitive solution, but the patch does solve - the problem for most cases. - - 2007-03-22 Frédéric Bernon - * api_msg.h, api_msg.c: Remove obsolete API_MSG_ACCEPT and do_accept (never used). - - 2007-03-22 Frédéric Bernon - * api_lib.c: somes resources couldn't be freed if there was errors during - netconn_new_with_proto_and_callback. - - 2007-03-22 Frédéric Bernon - * ethernetif.c: update netif->input calls to check return value. In older ports, - it's a good idea to upgrade them, even if before, there could be another problem - (access to an uninitialized mailbox). - - 2007-03-21 Simon Goldschmidt - * sockets.c: fixed bug #5067 (essentialy a signed/unsigned warning fixed - by casting to unsigned). - - 2007-03-21 Frédéric Bernon - * api_lib.c, api_msg.c, tcpip.c: integrate sys_mbox_fetch(conn->mbox, NULL) calls from - api_lib.c to tcpip.c's tcpip_apimsg(). Now, use a local variable and not a - dynamic one from memp to send tcpip_msg to tcpip_thread in a synchrone call. - Free tcpip_msg from tcpip_apimsg is not done in tcpip_thread. This give a - faster and more reliable communication between api_lib and tcpip. - - 2007-03-21 Frédéric Bernon - * opt.h: Add LWIP_NETIF_CALLBACK (to avoid compiler warning) and set it to 0. - - 2007-03-21 Frédéric Bernon - * api_msg.c, igmp.c, igmp.h: Fix C++ style comments - - 2007-03-21 Kieran Mansley - * opt.h Change default PBUF_POOL_BUFSIZE to accomodate default MSS + - IP and TCP headers - - 2007-03-21 Kieran Mansley - * Fix all uses of pbuf_header to check the return value. In some - cases just assert if it fails as I'm not sure how to fix them, but - this is no worse than before when they would carry on regardless - of the failure. - - 2007-03-21 Kieran Mansley - * sockets.c, igmp.c, igmp.h, memp.h: Fix C++ style comments and - comment out missing header include in icmp.c - - 2007-03-20 Frédéric Bernon - * memp.h, stats.c: Fix stats_display function where memp_names table wasn't - synchronized with memp.h. - - 2007-03-20 Frédéric Bernon - * tcpip.c: Initialize tcpip's mbox, and verify if initialized in tcpip_input, - tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with - network interfaces. Also fix a compiler warning. - - 2007-03-20 Kieran Mansley - * udp.c: Only try and use pbuf_header() to make space for headers if - not a ROM or REF pbuf. - - 2007-03-19 Frédéric Bernon - * api_msg.h, api_msg.c, tcpip.h, tcpip.c: Add return types to tcpip_apimsg() - and api_msg_post(). - - 2007-03-19 Frédéric Bernon - * Remove unimplemented "memp_realloc" function from memp.h. - - 2007-03-11 Simon Goldschmidt - * pbuf.c: checked in patch #5796: pbuf_alloc: len field claculation caused - memory corruption. - - 2007-03-11 Simon Goldschmidt (based on patch from Dmitry Potapov) - * api_lib.c, sockets.c, api.h, api_msg.h, sockets.h: Fixed bug #19251 - (missing `const' qualifier in socket functions), to get more compatible to - standard POSIX sockets. - - 2007-03-11 Frédéric Bernon (based on patch from Dmitry Potapov) - * sockets.c: Add asserts inside bind, connect and sendto to check input - parameters. Remove excessive set_errno() calls after get_socket(), because - errno is set inside of get_socket(). Move last sock_set_errno() inside - lwip_close. - - 2007-03-09 Simon Goldschmidt - * memp.c: Fixed bug #11400: New etharp queueing introduced bug: memp_memory - was allocated too small. - - 2007-03-06 Simon Goldschmidt - * tcpip.c: Initialize dhcp timers in tcpip_thread (if LWIP_DHCP) to protect - the stack from concurrent access. - - 2007-03-06 Frédéric Bernon, Dmitry Potapov - * tcpip.c, ip_frag.c, ethernetif.c: Fix some build problems, and a redundancy - call to "lwip_stats.link.recv++;" in low_level_input() & ethernetif_input(). - - 2007-03-06 Simon Goldschmidt - * ip_frag.c, ip_frag.h: Reduce code size: don't include code in those files - if IP_FRAG == 0 and IP_REASSEMBLY == 0 - - 2007-03-06 Frédéric Bernon, Simon Goldschmidt - * opt.h, ip_frag.h, tcpip.h, tcpip.c, ethernetif.c: add new configuration - option named ETHARP_TCPIP_ETHINPUT, which enable the new tcpip_ethinput. - Allow to do ARP processing for incoming packets inside tcpip_thread - (protecting ARP layer against concurrent access). You can also disable - old code using tcp_input with new define ETHARP_TCPIP_INPUT set to 0. - Older ports have to use tcpip_ethinput. - - 2007-03-06 Simon Goldschmidt (based on patch from Dmitry Potapov) - * err.h, err.c: fixed compiler warning "initialization dircards qualifiers - from pointer target type" - - 2007-03-05 Frédéric Bernon - * opt.h, sockets.h: add new configuration options (LWIP_POSIX_SOCKETS_IO_NAMES, - ETHARP_TRUST_IP_MAC, review SO_REUSE) - - 2007-03-04 Frédéric Bernon - * api_msg.c: Remove some compiler warnings : parameter "pcb" was never - referenced. - - 2007-03-04 Frédéric Bernon - * api_lib.c: Fix "[patch #5764] api_lib.c cleanup: after patch #5687" (from - Dmitry Potapov). - The api_msg struct stay on the stack (not moved to netconn struct). - - 2007-03-04 Simon Goldschmidt (based on patch from Dmitry Potapov) - * pbuf.c: Fix BUG#19168 - pbuf_free can cause deadlock (if - SYS_LIGHTWEIGHT_PROT=1 & freeing PBUF_RAM when mem_sem is not available) - Also fixed cast warning in pbuf_alloc() - - 2007-03-04 Simon Goldschmidt - * etharp.c, etharp.h, memp.c, memp.h, opt.h: Fix BUG#11400 - don't corrupt - existing pbuf chain when enqueuing multiple pbufs to a pending ARP request - - 2007-03-03 Frédéric Bernon - * udp.c: remove obsolete line "static struct udp_pcb *pcb_cache = NULL;" - It is static, and never used in udp.c except udp_init(). - - 2007-03-02 Simon Goldschmidt - * tcpip.c: Moved call to ip_init(), udp_init() and tcp_init() from - tcpip_thread() to tcpip_init(). This way, raw API connections can be - initialized before tcpip_thread is running (e.g. before OS is started) - - 2007-03-02 Frédéric Bernon - * rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call - interval. - - 2007-02-28 Kieran Mansley - * pbuf.c: Fix BUG#17645 - ensure pbuf payload pointer is not moved - outside the region of the pbuf by pbuf_header() - - 2007-02-28 Kieran Mansley - * sockets.c: Fix BUG#19161 - ensure milliseconds timeout is non-zero - when supplied timeout is also non-zero - -(STABLE-1.2.0) - - 2006-12-05 Leon Woestenberg - * CHANGELOG: Mention STABLE-1.2.0 release. - - ++ New features: - - 2006-12-01 Christiaan Simons - * mem.h, opt.h: Added MEM_LIBC_MALLOC option. - Note this is a workaround. Currently I have no other options left. - - 2006-10-26 Christiaan Simons (accepted patch by Jonathan Larmour) - * ipv4/ip_frag.c: rename MAX_MTU to IP_FRAG_MAX_MTU and move define - to include/lwip/opt.h. - * ipv4/lwip/ip_frag.h: Remove unused IP_REASS_INTERVAL. - Move IP_REASS_MAXAGE and IP_REASS_BUFSIZE to include/lwip/opt.h. - * opt.h: Add above new options. - - 2006-08-18 Christiaan Simons - * tcp_{in,out}.c: added SNMP counters. - * ipv4/ip.c: added SNMP counters. - * ipv4/ip_frag.c: added SNMP counters. - - 2006-08-08 Christiaan Simons - * etharp.{c,h}: added etharp_find_addr() to read - (stable) ethernet/IP address pair from ARP table - - 2006-07-14 Christiaan Simons - * mib_structs.c: added - * include/lwip/snmp_structs.h: added - * netif.{c,h}, netif/ethernetif.c: added SNMP statistics to netif struct - - 2006-07-06 Christiaan Simons - * snmp/asn1_{enc,dec}.c added - * snmp/mib2.c added - * snmp/msg_{in,out}.c added - * include/lwip/snmp_asn1.h added - * include/lwip/snmp_msg.h added - * doc/snmp_agent.txt added - - 2006-03-29 Christiaan Simons - * inet.c, inet.h: Added platform byteswap support. - Added LWIP_PLATFORM_BYTESWAP define (defaults to 0) and - optional LWIP_PLATFORM_HTONS(), LWIP_PLATFORM_HTONL() macros. - - ++ Bug fixes: - - 2006-11-30 Christiaan Simons - * dhcp.c: Fixed false triggers of request_timeout. - - 2006-11-28 Christiaan Simons - * netif.c: In netif_add() fixed missing clear of ip_addr, netmask, gw and flags. - - 2006-10-11 Christiaan Simons - * api_lib.c etharp.c, ip.c, memp.c, stats.c, sys.{c,h} tcp.h: - Partially accepted patch #5449 for ANSI C compatibility / build fixes. - * ipv4/lwip/ip.h ipv6/lwip/ip.h: Corrected UDP-Lite protocol - identifier from 170 to 136 (bug #17574). - - 2006-10-10 Christiaan Simons - * api_msg.c: Fixed Nagle algorithm as reported by Bob Grice. - - 2006-08-17 Christiaan Simons - * udp.c: Fixed bug #17200, added check for broadcast - destinations for PCBs bound to a unicast address. - - 2006-08-07 Christiaan Simons - * api_msg.c: Flushing TCP output in do_close() (bug #15926). - - 2006-06-27 Christiaan Simons - * api_msg.c: Applied patch for cold case (bug #11135). - In accept_function() ensure newconn->callback is always initialized. - - 2006-06-15 Christiaan Simons - * mem.h: added MEM_SIZE_F alias to fix an ancient cold case (bug #1748), - facilitate printing of mem_size_t and u16_t statistics. - - 2006-06-14 Christiaan Simons - * api_msg.c: Applied patch #5146 to handle allocation failures - in accept() by Kevin Lawson. - - 2006-05-26 Christiaan Simons - * api_lib.c: Removed conn->sem creation and destruction - from netconn_write() and added sys_sem_new to netconn_new_*. - -(STABLE-1_1_1) - - 2006-03-03 Christiaan Simons - * ipv4/ip_frag.c: Added bound-checking assertions on ip_reassbitmap - access and added pbuf_alloc() return value checks. - - 2006-01-01 Leon Woestenberg - * tcp_{in,out}.c, tcp_out.c: Removed 'even sndbuf' fix in TCP, which is - now handled by the checksum routine properly. - - 2006-02-27 Leon Woestenberg - * pbuf.c: Fix alignment; pbuf_init() would not work unless - pbuf_pool_memory[] was properly aligned. (Patch by Curt McDowell.) - - 2005-12-20 Leon Woestenberg - * tcp.c: Remove PCBs which stay in LAST_ACK state too long. Patch - submitted by Mitrani Hiroshi. - - 2005-12-15 Christiaan Simons - * inet.c: Disabled the added summing routine to preserve code space. - - 2005-12-14 Leon Woestenberg - * tcp_in.c: Duplicate FIN ACK race condition fix by Kelvin Lawson. - Added Curt McDowell's optimized checksumming routine for future - inclusion. Need to create test case for unaliged, aligned, odd, - even length combination of cases on various endianess machines. - - 2005-12-09 Christiaan Simons - * inet.c: Rewrote standard checksum routine in proper portable C. - - 2005-11-25 Christiaan Simons - * udp.c tcp.c: Removed SO_REUSE hack. Should reside in socket code only. - * *.c: introduced cc.h LWIP_DEBUG formatters matching the u16_t, s16_t, - u32_t, s32_t typedefs. This solves most debug word-length assumes. - - 2005-07-17 Leon Woestenberg - * inet.c: Fixed unaligned 16-bit access in the standard checksum - routine by Peter Jolasson. - * slipif.c: Fixed implementation assumption of single-pbuf datagrams. - - 2005-02-04 Leon Woestenberg - * tcp_out.c: Fixed uninitialized 'queue' referenced in memerr branch. - * tcp_{out|in}.c: Applied patch fixing unaligned access. - - 2005-01-04 Leon Woestenberg - * pbuf.c: Fixed missing semicolon after LWIP_DEBUG statement. - - 2005-01-03 Leon Woestenberg - * udp.c: UDP pcb->recv() was called even when it was NULL. - -(STABLE-1_1_0) - - 2004-12-28 Leon Woestenberg - * etharp.*: Disabled multiple packets on the ARP queue. - This clashes with TCP queueing. - - 2004-11-28 Leon Woestenberg - * etharp.*: Fixed race condition from ARP request to ARP timeout. - Halved the ARP period, doubled the period counts. - ETHARP_MAX_PENDING now should be at least 2. This prevents - the counter from reaching 0 right away (which would allow - too little time for ARP responses to be received). - - 2004-11-25 Leon Woestenberg - * dhcp.c: Decline messages were not multicast but unicast. - * etharp.c: ETHARP_CREATE is renamed to ETHARP_TRY_HARD. - Do not try hard to insert arbitrary packet's source address, - etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD. - etharp_query() now always DOES call ETHARP_TRY_HARD so that users - querying an address will see it appear in the cache (DHCP could - suffer from this when a server invalidly gave an in-use address.) - * ipv4/ip_addr.h: Renamed ip_addr_maskcmp() to _netcmp() as we are - comparing network addresses (identifiers), not the network masks - themselves. - * ipv4/ip_addr.c: ip_addr_isbroadcast() now checks that the given - IP address actually belongs to the network of the given interface. - - 2004-11-24 Kieran Mansley - * tcp.c: Increment pcb->snd_buf when ACK is received in SYN_SENT state. - -(STABLE-1_1_0-RC1) - - 2004-10-16 Kieran Mansley - * tcp.c: Add code to tcp_recved() to send an ACK (window update) immediately, - even if one is already pending, if the rcv_wnd is above a threshold - (currently TCP_WND/2). This avoids waiting for a timer to expire to send a - delayed ACK in order to open the window if the stack is only receiving data. - - 2004-09-12 Kieran Mansley - * tcp*.*: Retransmit time-out handling improvement by Sam Jansen. - - 2004-08-20 Tony Mountifield - * etharp.c: Make sure the first pbuf queued on an ARP entry - is properly ref counted. - - 2004-07-27 Tony Mountifield - * debug.h: Added (int) cast in LWIP_DEBUGF() to avoid compiler - warnings about comparison. - * pbuf.c: Stopped compiler complaining of empty if statement - when LWIP_DEBUGF() empty. Closed an unclosed comment. - * tcp.c: Stopped compiler complaining of empty if statement - when LWIP_DEBUGF() empty. - * ip.h Corrected IPH_TOS() macro: returns a byte, so doesn't need htons(). - * inet.c: Added a couple of casts to quiet the compiler. - No need to test isascii(c) before isdigit(c) or isxdigit(c). - - 2004-07-22 Tony Mountifield - * inet.c: Made data types consistent in inet_ntoa(). - Added casts for return values of checksum routines, to pacify compiler. - * ip_frag.c, tcp_out.c, sockets.c, pbuf.c - Small corrections to some debugging statements, to pacify compiler. - - 2004-07-21 Tony Mountifield - * etharp.c: Removed spurious semicolon and added missing end-of-comment. - * ethernetif.c Updated low_level_output() to match prototype for - netif->linkoutput and changed low_level_input() similarly for consistency. - * api_msg.c: Changed recv_raw() from int to u8_t, to match prototype - of raw_recv() in raw.h and so avoid compiler error. - * sockets.c: Added trivial (int) cast to keep compiler happier. - * ip.c, netif.c Changed debug statements to use the tidier ip4_addrN() macros. - -(STABLE-1_0_0) - - ++ Changes: - - 2004-07-05 Leon Woestenberg - * sockets.*: Restructured LWIP_PRIVATE_TIMEVAL. Make sure - your cc.h file defines this either 1 or 0. If non-defined, - defaults to 1. - * .c: Added and includes where used. - * etharp.c: Made some array indices unsigned. - - 2004-06-27 Leon Woestenberg - * netif.*: Added netif_set_up()/down(). - * dhcp.c: Changes to restart program flow. - - 2004-05-07 Leon Woestenberg - * etharp.c: In find_entry(), instead of a list traversal per candidate, do a - single-pass lookup for different candidates. Should exploit locality. - - 2004-04-29 Leon Woestenberg - * tcp*.c: Cleaned up source comment documentation for Doxygen processing. - * opt.h: ETHARP_ALWAYS_INSERT option removed to comply with ARP RFC. - * etharp.c: update_arp_entry() only adds new ARP entries when adviced to by - the caller. This deprecates the ETHARP_ALWAYS_INSERT overrule option. - - ++ Bug fixes: - - 2004-04-27 Leon Woestenberg - * etharp.c: Applied patch of bug #8708 by Toni Mountifield with a solution - suggested by Timmy Brolin. Fix for 32-bit processors that cannot access - non-aligned 32-bit words, such as soms 32-bit TCP/IP header fields. Fix - is to prefix the 14-bit Ethernet headers with two padding bytes. - - 2004-04-23 Leon Woestenberg - * ip_addr.c: Fix in the ip_addr_isbroadcast() check. - * etharp.c: Fixed the case where the packet that initiates the ARP request - is not queued, and gets lost. Fixed the case where the packets destination - address is already known; we now always queue the packet and perform an ARP - request. - -(STABLE-0_7_0) - - ++ Bug fixes: - - * Fixed TCP bug for SYN_SENT to ESTABLISHED state transition. - * Fixed TCP bug in dequeueing of FIN from out of order segment queue. - * Fixed two possible NULL references in rare cases. - -(STABLE-0_6_6) - - ++ Bug fixes: - - * Fixed DHCP which did not include the IP address in DECLINE messages. - - ++ Changes: - - * etharp.c has been hauled over a bit. - -(STABLE-0_6_5) - - ++ Bug fixes: - - * Fixed TCP bug induced by bad window resizing with unidirectional TCP traffic. - * Packets sent from ARP queue had invalid source hardware address. - - ++ Changes: - - * Pass-by ARP requests do now update the cache. - - ++ New features: - - * No longer dependent on ctype.h. - * New socket options. - * Raw IP pcb support. - -(STABLE-0_6_4) - - ++ Bug fixes: - - * Some debug formatters and casts fixed. - * Numereous fixes in PPP. - - ++ Changes: - - * DEBUGF now is LWIP_DEBUGF - * pbuf_dechain() has been re-enabled. - * Mentioned the changed use of CVS branches in README. - -(STABLE-0_6_3) - - ++ Bug fixes: - - * Fixed pool pbuf memory leak in pbuf_alloc(). - Occured if not enough PBUF_POOL pbufs for a packet pbuf chain. - Reported by Savin Zlobec. - - * PBUF_POOL chains had their tot_len field not set for non-first - pbufs. Fixed in pbuf_alloc(). - - ++ New features: - - * Added PPP stack contributed by Marc Boucher - - ++ Changes: - - * Now drops short packets for ICMP/UDP/TCP protocols. More robust. - - * ARP queueuing now queues the latest packet instead of the first. - This is the RFC recommended behaviour, but can be overridden in - lwipopts.h. - -(0.6.2) - - ++ Bugfixes: - - * TCP has been fixed to deal with the new use of the pbuf->ref - counter. - - * DHCP dhcp_inform() crash bug fixed. - - ++ Changes: - - * Removed pbuf_pool_free_cache and pbuf_pool_alloc_cache. Also removed - pbuf_refresh(). This has sped up pbuf pool operations considerably. - Implemented by David Haas. - -(0.6.1) - - ++ New features: - - * The packet buffer implementation has been enhanced to support - zero-copy and copy-on-demand for packet buffers which have their - payloads in application-managed memory. - Implemented by David Haas. - - Use PBUF_REF to make a pbuf refer to RAM. lwIP will use zero-copy - if an outgoing packet can be directly sent on the link, or perform - a copy-on-demand when necessary. - - The application can safely assume the packet is sent, and the RAM - is available to the application directly after calling udp_send() - or similar function. - - ++ Bugfixes: - - * ARP_QUEUEING should now correctly work for all cases, including - PBUF_REF. - Implemented by Leon Woestenberg. - - ++ Changes: - - * IP_ADDR_ANY is no longer a NULL pointer. Instead, it is a pointer - to a '0.0.0.0' IP address. - - * The packet buffer implementation is changed. The pbuf->ref counter - meaning has changed, and several pbuf functions have been - adapted accordingly. - - * netif drivers have to be changed to set the hardware address length field - that must be initialized correctly by the driver (hint: 6 for Ethernet MAC). - See the contrib/ports/c16x cs8900 driver as a driver example. - - * netif's have a dhcp field that must be initialized to NULL by the driver. - See the contrib/ports/c16x cs8900 driver as a driver example. - -(0.5.x) This file has been unmaintained up to 0.6.1. All changes are - logged in CVS but have not been explained here. - -(0.5.3) Changes since version 0.5.2 - - ++ Bugfixes: - - * memp_malloc(MEMP_API_MSG) could fail with multiple application - threads because it wasn't protected by semaphores. - - ++ Other changes: - - * struct ip_addr now packed. - - * The name of the time variable in arp.c has been changed to ctime - to avoid conflicts with the time() function. - -(0.5.2) Changes since version 0.5.1 - - ++ New features: - - * A new TCP function, tcp_tmr(), now handles both TCP timers. - - ++ Bugfixes: - - * A bug in tcp_parseopt() could cause the stack to hang because of a - malformed TCP option. - - * The address of new connections in the accept() function in the BSD - socket library was not handled correctly. - - * pbuf_dechain() did not update the ->tot_len field of the tail. - - * Aborted TCP connections were not handled correctly in all - situations. - - ++ Other changes: - - * All protocol header structs are now packed. - - * The ->len field in the tcp_seg structure now counts the actual - amount of data, and does not add one for SYN and FIN segments. - -(0.5.1) Changes since version 0.5.0 - - ++ New features: - - * Possible to run as a user process under Linux. - - * Preliminary support for cross platform packed structs. - - * ARP timer now implemented. - - ++ Bugfixes: - - * TCP output queue length was badly initialized when opening - connections. - - * TCP delayed ACKs were not sent correctly. - - * Explicit initialization of BSS segment variables. - - * read() in BSD socket library could drop data. - - * Problems with memory alignment. - - * Situations when all TCP buffers were used could lead to - starvation. - - * TCP MSS option wasn't parsed correctly. - - * Problems with UDP checksum calculation. - - * IP multicast address tests had endianess problems. - - * ARP requests had wrong destination hardware address. - - ++ Other changes: - - * struct eth_addr changed from u16_t[3] array to u8_t[6]. - - * A ->linkoutput() member was added to struct netif. - - * TCP and UDP ->dest_* struct members where changed to ->remote_*. - - * ntoh* macros are now null definitions for big endian CPUs. - -(0.5.0) Changes since version 0.4.2 - - ++ New features: - - * Redesigned operating system emulation layer to make porting easier. - - * Better control over TCP output buffers. - - * Documenation added. - - ++ Bugfixes: - - * Locking issues in buffer management. - - * Bugfixes in the sequential API. - - * IP forwarding could cause memory leakage. This has been fixed. - - ++ Other changes: - - * Directory structure somewhat changed; the core/ tree has been - collapsed. - -(0.4.2) Changes since version 0.4.1 - - ++ New features: - - * Experimental ARP implementation added. - - * Skeleton Ethernet driver added. - - * Experimental BSD socket API library added. - - ++ Bugfixes: - - * In very intense situations, memory leakage could occur. This has - been fixed. - - ++ Other changes: - - * Variables named "data" and "code" have been renamed in order to - avoid name conflicts in certain compilers. - - * Variable++ have in appliciable cases been translated to ++variable - since some compilers generate better code in the latter case. - -(0.4.1) Changes since version 0.4 - - ++ New features: - - * TCP: Connection attempts time out earlier than data - transmissions. Nagle algorithm implemented. Push flag set on the - last segment in a burst. - - * UDP: experimental support for UDP-Lite extensions. - - ++ Bugfixes: - - * TCP: out of order segments were in some cases handled incorrectly, - and this has now been fixed. Delayed acknowledgements was broken - in 0.4, has now been fixed. Binding to an address that is in use - now results in an error. Reset connections sometimes hung an - application; this has been fixed. - - * Checksum calculation sometimes failed for chained pbufs with odd - lengths. This has been fixed. - - * API: a lot of bug fixes in the API. The UDP API has been improved - and tested. Error reporting and handling has been - improved. Logical flaws and race conditions for incoming TCP - connections has been found and removed. - - * Memory manager: alignment issues. Reallocating memory sometimes - failed, this has been fixed. - - * Generic library: bcopy was flawed and has been fixed. - - ++ Other changes: - - * API: all datatypes has been changed from generic ones such as - ints, to specified ones such as u16_t. Functions that return - errors now have the correct type (err_t). - - * General: A lot of code cleaned up and debugging code removed. Many - portability issues have been fixed. - - * The license was changed; the advertising clause was removed. - - * C64 port added. - - * Thanks: Huge thanks go to Dagan Galarneau, Horst Garnetzke, Petri - Kosunen, Mikael Caleres, and Frits Wilmink for reporting and - fixing bugs! - -(0.4) Changes since version 0.3.1 - - * Memory management has been radically changed; instead of - allocating memory from a shared heap, memory for objects that are - rapidly allocated and deallocated is now kept in pools. Allocation - and deallocation from those memory pools is very fast. The shared - heap is still present but is used less frequently. - - * The memory, memory pool, and packet buffer subsystems now support - 4-, 2-, or 1-byte alignment. - - * "Out of memory" situations are handled in a more robust way. - - * Stack usage has been reduced. - - * Easier configuration of lwIP parameters such as memory usage, - TTLs, statistics gathering, etc. All configuration parameters are - now kept in a single header file "lwipopts.h". - - * The directory structure has been changed slightly so that all - architecture specific files are kept under the src/arch - hierarchy. - - * Error propagation has been improved, both in the protocol modules - and in the API. - - * The code for the RTXC architecture has been implemented, tested - and put to use. - - * Bugs have been found and corrected in the TCP, UDP, IP, API, and - the Internet checksum modules. - - * Bugs related to porting between a 32-bit and a 16-bit architecture - have been found and corrected. - - * The license has been changed slightly to conform more with the - original BSD license, including the advertisement clause. - -(0.3.1) Changes since version 0.3 - - * Fix of a fatal bug in the buffer management. Pbufs with allocated - RAM never returned the RAM when the pbuf was deallocated. - - * TCP congestion control, window updates and retransmissions did not - work correctly. This has now been fixed. - - * Bugfixes in the API. - -(0.3) Changes since version 0.2 - - * New and improved directory structure. All include files are now - kept in a dedicated include/ directory. - - * The API now has proper error handling. A new function, - netconn_err(), now returns an error code for the connection in - case of errors. - - * Improvements in the memory management subsystem. The system now - keeps a pointer to the lowest free memory block. A new function, - mem_malloc2() tries to allocate memory once, and if it fails tries - to free some memory and retry the allocation. - - * Much testing has been done with limited memory - configurations. lwIP now does a better job when overloaded. - - * Some bugfixes and improvements to the buffer (pbuf) subsystem. - - * Many bugfixes in the TCP code: - - - Fixed a bug in tcp_close(). - - - The TCP receive window was incorrectly closed when out of - sequence segments was received. This has been fixed. - - - Connections are now timed-out of the FIN-WAIT-2 state. - - - The initial congestion window could in some cases be too - large. This has been fixed. - - - The retransmission queue could in some cases be screwed up. This - has been fixed. - - - TCP RST flag now handled correctly. - - - Out of sequence data was in some cases never delivered to the - application. This has been fixed. - - - Retransmitted segments now contain the correct acknowledgment - number and advertised window. - - - TCP retransmission timeout backoffs are not correctly computed - (ala BSD). After a number of retransmissions, TCP now gives up - the connection. - - * TCP connections now are kept on three lists, one for active - connections, one for listening connections, and one for - connections that are in TIME-WAIT. This greatly speeds up the fast - timeout processing for sending delayed ACKs. - - * TCP now provides proper feedback to the application when a - connection has been successfully set up. - - * More comments have been added to the code. The code has also been - somewhat cleaned up. - -(0.2) Initial public release. diff --git a/user/mpy/lib/lwip/COPYING b/user/mpy/lib/lwip/COPYING deleted file mode 100644 index e23898b..0000000 --- a/user/mpy/lib/lwip/COPYING +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - diff --git a/user/mpy/lib/lwip/FILES b/user/mpy/lib/lwip/FILES deleted file mode 100644 index 6625319..0000000 --- a/user/mpy/lib/lwip/FILES +++ /dev/null @@ -1,4 +0,0 @@ -src/ - The source code for the lwIP TCP/IP stack. -doc/ - The documentation for lwIP. - -See also the FILES file in each subdirectory. diff --git a/user/mpy/lib/lwip/README b/user/mpy/lib/lwip/README deleted file mode 100644 index a62cc4f..0000000 --- a/user/mpy/lib/lwip/README +++ /dev/null @@ -1,89 +0,0 @@ -INTRODUCTION - -lwIP is a small independent implementation of the TCP/IP protocol -suite that has been developed by Adam Dunkels at the Computer and -Networks Architectures (CNA) lab at the Swedish Institute of Computer -Science (SICS). - -The focus of the lwIP TCP/IP implementation is to reduce the RAM usage -while still having a full scale TCP. This making lwIP suitable for use -in embedded systems with tens of kilobytes of free RAM and room for -around 40 kilobytes of code ROM. - -FEATURES - - * IP (Internet Protocol) including packet forwarding over multiple network - interfaces - * ICMP (Internet Control Message Protocol) for network maintenance and debugging - * IGMP (Internet Group Management Protocol) for multicast traffic management - * UDP (User Datagram Protocol) including experimental UDP-lite extensions - * TCP (Transmission Control Protocol) with congestion control, RTT estimation - and fast recovery/fast retransmit - * Specialized raw/native API for enhanced performance - * Optional Berkeley-like socket API - * DNS (Domain names resolver) - * SNMP (Simple Network Management Protocol) - * DHCP (Dynamic Host Configuration Protocol) - * AUTOIP (for IPv4, conform with RFC 3927) - * PPP (Point-to-Point Protocol) - * ARP (Address Resolution Protocol) for Ethernet - -LICENSE - -lwIP is freely available under a BSD license. - -DEVELOPMENT - -lwIP has grown into an excellent TCP/IP stack for embedded devices, -and developers using the stack often submit bug fixes, improvements, -and additions to the stack to further increase its usefulness. - -Development of lwIP is hosted on Savannah, a central point for -software development, maintenance and distribution. Everyone can -help improve lwIP by use of Savannah's interface, CVS and the -mailing list. A core team of developers will commit changes to the -CVS source tree. - -The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and -contributions (such as platform ports) are in the 'contrib' module. - -See doc/savannah.txt for details on CVS server access for users and -developers. - -Last night's CVS tar ball can be downloaded from: - http://savannah.gnu.org/cvs.backups/lwip.tar.gz [CHANGED - NEEDS FIXING] - -The current CVS trees are web-browsable: - http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/lwip/ - http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/ - -Submit patches and bugs via the lwIP project page: - http://savannah.nongnu.org/projects/lwip/ - - -DOCUMENTATION - -The original out-dated homepage of lwIP and Adam Dunkels' papers on -lwIP are at the official lwIP home page: - http://www.sics.se/~adam/lwip/ - -Self documentation of the source code is regularly extracted from the -current CVS sources and is available from this web page: - http://www.nongnu.org/lwip/ - -There is now a constantly growin wiki about lwIP at - http://lwip.wikia.com/wiki/LwIP_Wiki - -Also, there are mailing lists you can subscribe at - http://savannah.nongnu.org/mail/?group=lwip -plus searchable archives: - http://lists.nongnu.org/archive/html/lwip-users/ - http://lists.nongnu.org/archive/html/lwip-devel/ - -Reading Adam's papers, the files in docs/, browsing the source code -documentation and browsing the mailing list archives is a good way to -become familiar with the design of lwIP. - -Adam Dunkels -Leon Woestenberg - diff --git a/user/mpy/lib/lwip/UPGRADING b/user/mpy/lib/lwip/UPGRADING deleted file mode 100644 index 6501107..0000000 --- a/user/mpy/lib/lwip/UPGRADING +++ /dev/null @@ -1,144 +0,0 @@ -This file lists major changes between release versions that require -ports or applications to be changed. Use it to update a port or an -application written for an older version of lwIP to correctly work -with newer versions. - - -(CVS HEAD) - - * [Enter new changes just after this line - do not remove this line] - - ++ Application changes: - - * Replaced struct ip_addr by typedef ip_addr_t (struct ip_addr is kept for - compatibility to old applications, but will be removed in the future). - - * Renamed mem_realloc() to mem_trim() to prevent confusion with realloc() - - +++ Raw API: - * Changed the semantics of tcp_close() (since it was rather a - shutdown before): Now the application does *NOT* get any calls to the recv - callback (aside from NULL/closed) after calling tcp_close() - - * When calling tcp_abort() from a raw API TCP callback function, - make sure you return ERR_ABRT to prevent accessing unallocated memory. - (ERR_ABRT now means the applicaiton has called tcp_abort!) - - +++ Netconn API: - * Changed netconn_receive() and netconn_accept() to return - err_t, not a pointer to new data/netconn. - - +++ Socket API: - * LWIP_SO_RCVTIMEO: when accept() or recv() time out, they - now set errno to EWOULDBLOCK/EAGAIN, not ETIMEDOUT. - - * Added a minimal version of posix fctl() to have a - standardised way to set O_NONBLOCK for nonblocking sockets. - - +++ all APIs: - * correctly implemented SO(F)_REUSEADDR - - ++ Port changes - - +++ new files: - - * Added 4 new files: def.c, timers.c, timers.h, tcp_impl.h: - - * Moved stack-internal parts of tcp.h to tcp_impl.h, tcp.h now only contains - the actual application programmer's API - - * Separated timer implementation from sys.h/.c, moved to timers.h/.c; - Added timer implementation for NO_SYS==1, set NO_SYS_NO_TIMERS==1 if you - still want to use your own timer implementation for NO_SYS==0 (as before). - - +++ sys layer: - - * Converted mbox- and semaphore-functions to take pointers to sys_mbox_t/ - sys_sem_t; - - * Converted sys_mbox_new/sys_sem_new to take pointers and return err_t; - - * Added Mutex concept in sys_arch (define LWIP_COMPAT_MUTEX to let sys.h use - binary semaphores instead of mutexes - as before) - - +++ new options: - - * Don't waste memory when chaining segments, added option TCP_OVERSIZE to - prevent creating many small pbufs when calling tcp_write with many small - blocks of data. Instead, pbufs are allocated larger than needed and the - space is used for later calls to tcp_write. - - * Added LWIP_NETIF_TX_SINGLE_PBUF to always copy to try to create single pbufs - in tcp_write/udp_send. - - * Added an additional option LWIP_ETHERNET to support ethernet without ARP - (necessary for pure PPPoE) - - * Add MEMP_SEPARATE_POOLS to place memory pools in separate arrays. This may - be used to place these pools into user-defined memory by using external - declaration. - - * Added TCP_SNDQUEUELOWAT corresponding to TCP_SNDLOWAT - - +++ new pools: - - * Netdb uses a memp pool for allocating memory when getaddrinfo() is called, - so MEMP_NUM_NETDB has to be set accordingly. - - * DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses a memp pool instead of the heap, so - MEMP_NUM_LOCALHOSTLIST has to be set accordingly. - - * Snmp-agent uses a memp pools instead of the heap, so MEMP_NUM_SNMP_* have - to be set accordingly. - - * PPPoE uses a MEMP pool instead of the heap, so MEMP_NUM_PPPOE_INTERFACES - has to be set accordingly - - * Integrated loopif into netif.c - loopif does not have to be created by the - port any more, just define LWIP_HAVE_LOOPIF to 1. - - * Added define LWIP_RAND() for lwip-wide randomization (needs to be defined - in cc.h, e.g. used by igmp) - - * Added printf-formatter X8_F to printf u8_t as hex - - * The heap now may be moved to user-defined memory by defining - LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address - - * added autoip_set_struct() and dhcp_set_struct() to let autoip and dhcp work - with user-allocated structs instead of calling mem_malloc - - * Added const char* name to mem- and memp-stats for easier debugging. - - * Calculate the TCP/UDP checksum while copying to only fetch data once: - Define LWIP_CHKSUM_COPY to a memcpy-like function that returns the checksum - - * Added SO_REUSE_RXTOALL to pass received UDP broadcast/multicast packets to - more than one pcb. - - * Changed the semantics of ARP_QUEUEING==0: ARP_QUEUEING now cannot be turned - off any more, if this is set to 0, only one packet (the most recent one) is - queued (like demanded by RFC 1122). - - - ++ Major bugfixes/improvements - - * Implemented tcp_shutdown() to only shut down one end of a connection - * Implemented shutdown() at socket- and netconn-level - * Added errorset support to select() + improved select speed overhead - * Merged pppd to v2.3.11 (including some backported bugfixes from 2.4.x) - * Added timer implementation for NO_SYS==1 (may be disabled with NO_SYS_NO_TIMERS==1 - * Use macros defined in ip_addr.h to work with IP addresses - * Implemented many nonblocking socket/netconn functions - * Fixed ARP input processing: only add a new entry if a request was directed as us - * mem_realloc() to mem_trim() to prevent confusion with realloc() - * Some improvements for AutoIP (don't route/forward link-local addresses, don't break - existing connections when assigning a routable address) - * Correctly handle remote side overrunning our rcv_wnd in ooseq case - * Removed packing from ip_addr_t, the packed version is now only used in protocol headers - * Corrected PBUF_POOL_BUFSIZE for ports where ETH_PAD_SIZE > 0 - * Added support for static ARP table entries - -(STABLE-1.3.2) - - * initial version of this file diff --git a/user/mpy/lib/lwip/doc/FILES b/user/mpy/lib/lwip/doc/FILES deleted file mode 100644 index 05d356f..0000000 --- a/user/mpy/lib/lwip/doc/FILES +++ /dev/null @@ -1,6 +0,0 @@ -savannah.txt - How to obtain the current development source code. -contrib.txt - How to contribute to lwIP as a developer. -rawapi.txt - The documentation for the core API of lwIP. - Also provides an overview about the other APIs and multithreading. -snmp_agent.txt - The documentation for the lwIP SNMP agent. -sys_arch.txt - The documentation for a system abstraction layer of lwIP. diff --git a/user/mpy/lib/lwip/doc/contrib.txt b/user/mpy/lib/lwip/doc/contrib.txt deleted file mode 100644 index 39596fc..0000000 --- a/user/mpy/lib/lwip/doc/contrib.txt +++ /dev/null @@ -1,63 +0,0 @@ -1 Introduction - -This document describes some guidelines for people participating -in lwIP development. - -2 How to contribute to lwIP - -Here is a short list of suggestions to anybody working with lwIP and -trying to contribute bug reports, fixes, enhancements, platform ports etc. -First of all as you may already know lwIP is a volunteer project so feedback -to fixes or questions might often come late. Hopefully the bug and patch tracking -features of Savannah help us not lose users' input. - -2.1 Source code style: - -1. do not use tabs. -2. indentation is two spaces per level (i.e. per tab). -3. end debug messages with a trailing newline (\n). -4. one space between keyword and opening bracket. -5. no space between function and opening bracket. -6. one space and no newline before opening curly braces of a block. -7. closing curly brace on a single line. -8. spaces surrounding assignment and comparisons. -9. don't initialize static and/or global variables to zero, the compiler takes care of that. -10. use current source code style as further reference. - -2.2 Source code documentation style: - -1. JavaDoc compliant and Doxygen compatible. -2. Function documentation above functions in .c files, not .h files. - (This forces you to synchronize documentation and implementation.) -3. Use current documentation style as further reference. - -2.3 Bug reports and patches: - -1. Make sure you are reporting bugs or send patches against the latest - sources. (From the latest release and/or the current CVS sources.) -2. If you think you found a bug make sure it's not already filed in the - bugtracker at Savannah. -3. If you have a fix put the patch on Savannah. If it is a patch that affects - both core and arch specific stuff please separate them so that the core can - be applied separately while leaving the other patch 'open'. The prefered way - is to NOT touch archs you can't test and let maintainers take care of them. - This is a good way to see if they are used at all - the same goes for unix - netifs except tapif. -4. Do not file a bug and post a fix to it to the patch area. Either a bug report - or a patch will be enough. - If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area. -5. Trivial patches (compiler warning, indentation and spelling fixes or anything obvious which takes a line or two) - can go to the lwip-users list. This is still the fastest way of interaction and the list is not so crowded - as to allow for loss of fixes. Putting bugs on Savannah and subsequently closing them is too much an overhead - for reporting a compiler warning fix. -6. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other - trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you - change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than - if it's not to the point and long :) so the chances for it to be applied are greater. - -2.4 Platform porters: - -1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and - you think it could benefit others[1] you might want discuss this on the mailing list. You - can also ask for CVS access to submit and maintain your port in the contrib CVS module. - \ No newline at end of file diff --git a/user/mpy/lib/lwip/doc/rawapi.txt b/user/mpy/lib/lwip/doc/rawapi.txt deleted file mode 100644 index 8c19030..0000000 --- a/user/mpy/lib/lwip/doc/rawapi.txt +++ /dev/null @@ -1,511 +0,0 @@ -Raw TCP/IP interface for lwIP - -Authors: Adam Dunkels, Leon Woestenberg, Christiaan Simons - -lwIP provides three Application Program's Interfaces (APIs) for programs -to use for communication with the TCP/IP code: -* low-level "core" / "callback" or "raw" API. -* higher-level "sequential" API. -* BSD-style socket API. - -The sequential API provides a way for ordinary, sequential, programs -to use the lwIP stack. It is quite similar to the BSD socket API. The -model of execution is based on the blocking open-read-write-close -paradigm. Since the TCP/IP stack is event based by nature, the TCP/IP -code and the application program must reside in different execution -contexts (threads). - -The socket API is a compatibility API for existing applications, -currently it is built on top of the sequential API. It is meant to -provide all functions needed to run socket API applications running -on other platforms (e.g. unix / windows etc.). However, due to limitations -in the specification of this API, there might be incompatibilities -that require small modifications of existing programs. - -** Threading - -lwIP started targeting single-threaded environments. When adding multi- -threading support, instead of making the core thread-safe, another -approach was chosen: there is one main thread running the lwIP core -(also known as the "tcpip_thread"). The raw API may only be used from -this thread! Application threads using the sequential- or socket API -communicate with this main thread through message passing. - - As such, the list of functions that may be called from - other threads or an ISR is very limited! Only functions - from these API header files are thread-safe: - - api.h - - netbuf.h - - netdb.h - - netifapi.h - - sockets.h - - sys.h - - Additionaly, memory (de-)allocation functions may be - called from multiple threads (not ISR!) with NO_SYS=0 - since they are protected by SYS_LIGHTWEIGHT_PROT and/or - semaphores. - - Only since 1.3.0, if SYS_LIGHTWEIGHT_PROT is set to 1 - and LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT is set to 1, - pbuf_free() may also be called from another thread or - an ISR (since only then, mem_free - for PBUF_RAM - may - be called from an ISR: otherwise, the HEAP is only - protected by semaphores). - - -** The remainder of this document discusses the "raw" API. ** - -The raw TCP/IP interface allows the application program to integrate -better with the TCP/IP code. Program execution is event based by -having callback functions being called from within the TCP/IP -code. The TCP/IP code and the application program both run in the same -thread. The sequential API has a much higher overhead and is not very -well suited for small systems since it forces a multithreaded paradigm -on the application. - -The raw TCP/IP interface is not only faster in terms of code execution -time but is also less memory intensive. The drawback is that program -development is somewhat harder and application programs written for -the raw TCP/IP interface are more difficult to understand. Still, this -is the preferred way of writing applications that should be small in -code size and memory usage. - -Both APIs can be used simultaneously by different application -programs. In fact, the sequential API is implemented as an application -program using the raw TCP/IP interface. - ---- Callbacks - -Program execution is driven by callbacks. Each callback is an ordinary -C function that is called from within the TCP/IP code. Every callback -function is passed the current TCP or UDP connection state as an -argument. Also, in order to be able to keep program specific state, -the callback functions are called with a program specified argument -that is independent of the TCP/IP state. - -The function for setting the application connection state is: - -- void tcp_arg(struct tcp_pcb *pcb, void *arg) - - Specifies the program specific state that should be passed to all - other callback functions. The "pcb" argument is the current TCP - connection control block, and the "arg" argument is the argument - that will be passed to the callbacks. - - ---- TCP connection setup - -The functions used for setting up connections is similar to that of -the sequential API and of the BSD socket API. A new TCP connection -identifier (i.e., a protocol control block - PCB) is created with the -tcp_new() function. This PCB can then be either set to listen for new -incoming connections or be explicitly connected to another host. - -- struct tcp_pcb *tcp_new(void) - - Creates a new connection identifier (PCB). If memory is not - available for creating the new pcb, NULL is returned. - -- err_t tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port) - - Binds the pcb to a local IP address and port number. The IP address - can be specified as IP_ADDR_ANY in order to bind the connection to - all local IP addresses. - - If another connection is bound to the same port, the function will - return ERR_USE, otherwise ERR_OK is returned. - -- struct tcp_pcb *tcp_listen(struct tcp_pcb *pcb) - - Commands a pcb to start listening for incoming connections. When an - incoming connection is accepted, the function specified with the - tcp_accept() function will be called. The pcb will have to be bound - to a local port with the tcp_bind() function. - - The tcp_listen() function returns a new connection identifier, and - the one passed as an argument to the function will be - deallocated. The reason for this behavior is that less memory is - needed for a connection that is listening, so tcp_listen() will - reclaim the memory needed for the original connection and allocate a - new smaller memory block for the listening connection. - - tcp_listen() may return NULL if no memory was available for the - listening connection. If so, the memory associated with the pcb - passed as an argument to tcp_listen() will not be deallocated. - -- struct tcp_pcb *tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) - - Same as tcp_listen, but limits the number of outstanding connections - in the listen queue to the value specified by the backlog argument. - To use it, your need to set TCP_LISTEN_BACKLOG=1 in your lwipopts.h. - -- void tcp_accepted(struct tcp_pcb *pcb) - - Inform lwIP that an incoming connection has been accepted. This would - usually be called from the accept callback. This allows lwIP to perform - housekeeping tasks, such as allowing further incoming connections to be - queued in the listen backlog. - ATTENTION: the PCB passed in must be the listening pcb, not the pcb passed - into the accept callback! - -- void tcp_accept(struct tcp_pcb *pcb, - err_t (* accept)(void *arg, struct tcp_pcb *newpcb, - err_t err)) - - Specified the callback function that should be called when a new - connection arrives on a listening connection. - -- err_t tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port, err_t (* connected)(void *arg, - struct tcp_pcb *tpcb, - err_t err)); - - Sets up the pcb to connect to the remote host and sends the - initial SYN segment which opens the connection. - - The tcp_connect() function returns immediately; it does not wait for - the connection to be properly setup. Instead, it will call the - function specified as the fourth argument (the "connected" argument) - when the connection is established. If the connection could not be - properly established, either because the other host refused the - connection or because the other host didn't answer, the "err" - callback function of this pcb (registered with tcp_err, see below) - will be called. - - The tcp_connect() function can return ERR_MEM if no memory is - available for enqueueing the SYN segment. If the SYN indeed was - enqueued successfully, the tcp_connect() function returns ERR_OK. - - ---- Sending TCP data - -TCP data is sent by enqueueing the data with a call to -tcp_write(). When the data is successfully transmitted to the remote -host, the application will be notified with a call to a specified -callback function. - -- err_t tcp_write(struct tcp_pcb *pcb, const void *dataptr, u16_t len, - u8_t apiflags) - - Enqueues the data pointed to by the argument dataptr. The length of - the data is passed as the len parameter. The apiflags can be one or more of: - - TCP_WRITE_FLAG_COPY: indicates whether the new memory should be allocated - for the data to be copied into. If this flag is not given, no new memory - should be allocated and the data should only be referenced by pointer. This - also means that the memory behind dataptr must not change until the data is - ACKed by the remote host - - TCP_WRITE_FLAG_MORE: indicates that more data follows. If this is given, - the PSH flag is set in the last segment created by this call to tcp_write. - If this flag is given, the PSH flag is not set. - - The tcp_write() function will fail and return ERR_MEM if the length - of the data exceeds the current send buffer size or if the length of - the queue of outgoing segment is larger than the upper limit defined - in lwipopts.h. The number of bytes available in the output queue can - be retrieved with the tcp_sndbuf() function. - - The proper way to use this function is to call the function with at - most tcp_sndbuf() bytes of data. If the function returns ERR_MEM, - the application should wait until some of the currently enqueued - data has been successfully received by the other host and try again. - -- void tcp_sent(struct tcp_pcb *pcb, - err_t (* sent)(void *arg, struct tcp_pcb *tpcb, - u16_t len)) - - Specifies the callback function that should be called when data has - successfully been received (i.e., acknowledged) by the remote - host. The len argument passed to the callback function gives the - amount bytes that was acknowledged by the last acknowledgment. - - ---- Receiving TCP data - -TCP data reception is callback based - an application specified -callback function is called when new data arrives. When the -application has taken the data, it has to call the tcp_recved() -function to indicate that TCP can advertise increase the receive -window. - -- void tcp_recv(struct tcp_pcb *pcb, - err_t (* recv)(void *arg, struct tcp_pcb *tpcb, - struct pbuf *p, err_t err)) - - Sets the callback function that will be called when new data - arrives. The callback function will be passed a NULL pbuf to - indicate that the remote host has closed the connection. If - there are no errors and the callback function is to return - ERR_OK, then it must free the pbuf. Otherwise, it must not - free the pbuf so that lwIP core code can store it. - -- void tcp_recved(struct tcp_pcb *pcb, u16_t len) - - Must be called when the application has received the data. The len - argument indicates the length of the received data. - - ---- Application polling - -When a connection is idle (i.e., no data is either transmitted or -received), lwIP will repeatedly poll the application by calling a -specified callback function. This can be used either as a watchdog -timer for killing connections that have stayed idle for too long, or -as a method of waiting for memory to become available. For instance, -if a call to tcp_write() has failed because memory wasn't available, -the application may use the polling functionality to call tcp_write() -again when the connection has been idle for a while. - -- void tcp_poll(struct tcp_pcb *pcb, - err_t (* poll)(void *arg, struct tcp_pcb *tpcb), - u8_t interval) - - Specifies the polling interval and the callback function that should - be called to poll the application. The interval is specified in - number of TCP coarse grained timer shots, which typically occurs - twice a second. An interval of 10 means that the application would - be polled every 5 seconds. - - ---- Closing and aborting connections - -- err_t tcp_close(struct tcp_pcb *pcb) - - Closes the connection. The function may return ERR_MEM if no memory - was available for closing the connection. If so, the application - should wait and try again either by using the acknowledgment - callback or the polling functionality. If the close succeeds, the - function returns ERR_OK. - - The pcb is deallocated by the TCP code after a call to tcp_close(). - -- void tcp_abort(struct tcp_pcb *pcb) - - Aborts the connection by sending a RST (reset) segment to the remote - host. The pcb is deallocated. This function never fails. - - ATTENTION: When calling this from one of the TCP callbacks, make - sure you always return ERR_ABRT (and never return ERR_ABRT otherwise - or you will risk accessing deallocated memory or memory leaks! - - -If a connection is aborted because of an error, the application is -alerted of this event by the err callback. Errors that might abort a -connection are when there is a shortage of memory. The callback -function to be called is set using the tcp_err() function. - -- void tcp_err(struct tcp_pcb *pcb, void (* err)(void *arg, - err_t err)) - - The error callback function does not get the pcb passed to it as a - parameter since the pcb may already have been deallocated. - - ---- Lower layer TCP interface - -TCP provides a simple interface to the lower layers of the -system. During system initialization, the function tcp_init() has -to be called before any other TCP function is called. When the system -is running, the two timer functions tcp_fasttmr() and tcp_slowtmr() -must be called with regular intervals. The tcp_fasttmr() should be -called every TCP_FAST_INTERVAL milliseconds (defined in tcp.h) and -tcp_slowtmr() should be called every TCP_SLOW_INTERVAL milliseconds. - - ---- UDP interface - -The UDP interface is similar to that of TCP, but due to the lower -level of complexity of UDP, the interface is significantly simpler. - -- struct udp_pcb *udp_new(void) - - Creates a new UDP pcb which can be used for UDP communication. The - pcb is not active until it has either been bound to a local address - or connected to a remote address. - -- void udp_remove(struct udp_pcb *pcb) - - Removes and deallocates the pcb. - -- err_t udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port) - - Binds the pcb to a local address. The IP-address argument "ipaddr" - can be IP_ADDR_ANY to indicate that it should listen to any local IP - address. The function currently always return ERR_OK. - -- err_t udp_connect(struct udp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port) - - Sets the remote end of the pcb. This function does not generate any - network traffic, but only set the remote address of the pcb. - -- err_t udp_disconnect(struct udp_pcb *pcb) - - Remove the remote end of the pcb. This function does not generate - any network traffic, but only removes the remote address of the pcb. - -- err_t udp_send(struct udp_pcb *pcb, struct pbuf *p) - - Sends the pbuf p. The pbuf is not deallocated. - -- void udp_recv(struct udp_pcb *pcb, - void (* recv)(void *arg, struct udp_pcb *upcb, - struct pbuf *p, - ip_addr_t *addr, - u16_t port), - void *recv_arg) - - Specifies a callback function that should be called when a UDP - datagram is received. - - ---- System initalization - -A truly complete and generic sequence for initializing the lwip stack -cannot be given because it depends on the build configuration (lwipopts.h) -and additional initializations for your runtime environment (e.g. timers). - -We can give you some idea on how to proceed when using the raw API. -We assume a configuration using a single Ethernet netif and the -UDP and TCP transport layers, IPv4 and the DHCP client. - -Call these functions in the order of appearance: - -- stats_init() - - Clears the structure where runtime statistics are gathered. - -- sys_init() - - Not of much use since we set the NO_SYS 1 option in lwipopts.h, - to be called for easy configuration changes. - -- mem_init() - - Initializes the dynamic memory heap defined by MEM_SIZE. - -- memp_init() - - Initializes the memory pools defined by MEMP_NUM_x. - -- pbuf_init() - - Initializes the pbuf memory pool defined by PBUF_POOL_SIZE. - -- etharp_init() - - Initializes the ARP table and queue. - Note: you must call etharp_tmr at a ARP_TMR_INTERVAL (5 seconds) regular interval - after this initialization. - -- ip_init() - - Doesn't do much, it should be called to handle future changes. - -- udp_init() - - Clears the UDP PCB list. - -- tcp_init() - - Clears the TCP PCB list and clears some internal TCP timers. - Note: you must call tcp_fasttmr() and tcp_slowtmr() at the - predefined regular intervals after this initialization. - -- netif_add(struct netif *netif, ip_addr_t *ipaddr, - ip_addr_t *netmask, ip_addr_t *gw, - void *state, err_t (* init)(struct netif *netif), - err_t (* input)(struct pbuf *p, struct netif *netif)) - - Adds your network interface to the netif_list. Allocate a struct - netif and pass a pointer to this structure as the first argument. - Give pointers to cleared ip_addr structures when using DHCP, - or fill them with sane numbers otherwise. The state pointer may be NULL. - - The init function pointer must point to a initialization function for - your ethernet netif interface. The following code illustrates it's use. - - err_t netif_if_init(struct netif *netif) - { - u8_t i; - - for(i = 0; i < ETHARP_HWADDR_LEN; i++) netif->hwaddr[i] = some_eth_addr[i]; - init_my_eth_device(); - return ERR_OK; - } - - For ethernet drivers, the input function pointer must point to the lwip - function ethernet_input() declared in "netif/etharp.h". Other drivers - must use ip_input() declared in "lwip/ip.h". - -- netif_set_default(struct netif *netif) - - Registers the default network interface. - -- netif_set_up(struct netif *netif) - - When the netif is fully configured this function must be called. - -- dhcp_start(struct netif *netif) - - Creates a new DHCP client for this interface on the first call. - Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at - the predefined regular intervals after starting the client. - - You can peek in the netif->dhcp struct for the actual DHCP status. - - ---- Optimalization hints - -The first thing you want to optimize is the lwip_standard_checksum() -routine from src/core/inet.c. You can override this standard -function with the #define LWIP_CHKSUM . - -There are C examples given in inet.c or you might want to -craft an assembly function for this. RFC1071 is a good -introduction to this subject. - -Other significant improvements can be made by supplying -assembly or inline replacements for htons() and htonl() -if you're using a little-endian architecture. -#define LWIP_PLATFORM_BYTESWAP 1 -#define LWIP_PLATFORM_HTONS(x) -#define LWIP_PLATFORM_HTONL(x) - -Check your network interface driver if it reads at -a higher speed than the maximum wire-speed. If the -hardware isn't serviced frequently and fast enough -buffer overflows are likely to occur. - -E.g. when using the cs8900 driver, call cs8900if_service(ethif) -as frequently as possible. When using an RTOS let the cs8900 interrupt -wake a high priority task that services your driver using a binary -semaphore or event flag. Some drivers might allow additional tuning -to match your application and network. - -For a production release it is recommended to set LWIP_STATS to 0. -Note that speed performance isn't influenced much by simply setting -high values to the memory options. - -For more optimization hints take a look at the lwIP wiki. - ---- Zero-copy MACs - -To achieve zero-copy on transmit, the data passed to the raw API must -remain unchanged until sent. Because the send- (or write-)functions return -when the packets have been enqueued for sending, data must be kept stable -after that, too. - -This implies that PBUF_RAM/PBUF_POOL pbufs passed to raw-API send functions -must *not* be reused by the application unless their ref-count is 1. - -For no-copy pbufs (PBUF_ROM/PBUF_REF), data must be kept unchanged, too, -but the stack/driver will/must copy PBUF_REF'ed data when enqueueing, while -PBUF_ROM-pbufs are just enqueued (as ROM-data is expected to never change). - -Also, data passed to tcp_write without the copy-flag must not be changed! - -Therefore, be careful which type of PBUF you use and if you copy TCP data -or not! diff --git a/user/mpy/lib/lwip/doc/savannah.txt b/user/mpy/lib/lwip/doc/savannah.txt deleted file mode 100644 index 409905b..0000000 --- a/user/mpy/lib/lwip/doc/savannah.txt +++ /dev/null @@ -1,135 +0,0 @@ -Daily Use Guide for using Savannah for lwIP - -Table of Contents: - -1 - Obtaining lwIP from the CVS repository -2 - Committers/developers CVS access using SSH (to be written) -3 - Merging from DEVEL branch to main trunk (stable branch) -4 - How to release lwIP - - - -1 Obtaining lwIP from the CVS repository ----------------------------------------- - -To perform an anonymous CVS checkout of the main trunk (this is where -bug fixes and incremental enhancements occur), do this: - -cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout lwip - -Or, obtain a stable branch (updated with bug fixes only) as follows: -cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ - -r STABLE-0_7 -d lwip-0.7 lwip - -Or, obtain a specific (fixed) release as follows: -cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ - -r STABLE-0_7_0 -d lwip-0.7.0 lwip - -3 Committers/developers CVS access using SSH --------------------------------------------- - -The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption. -As such, CVS commits to the server occur through a SSH tunnel for project members. -To create a SSH2 key pair in UNIX-like environments, do this: - -ssh-keygen -t dsa - -Under Windows, a recommended SSH client is "PuTTY", freely available with good -documentation and a graphic user interface. Use its key generator. - -Now paste the id_dsa.pub contents into your Savannah account public key list. Wait -a while so that Savannah can update its configuration (This can take minutes). - -Try to login using SSH: - -ssh -v your_login@cvs.sv.gnu.org - -If it tells you: - -Authenticating with public key "your_key_name"... -Server refused to allocate pty - -then you could login; Savannah refuses to give you a shell - which is OK, as we -are allowed to use SSH for CVS only. Now, you should be able to do this: - -export CVS_RSH=ssh -cvs -z3 -d:ext:your_login@cvs.sv.gnu.org:/sources/lwip co lwip - -after which you can edit your local files with bug fixes or new features and -commit them. Make sure you know what you are doing when using CVS to make -changes on the repository. If in doubt, ask on the lwip-members mailing list. - -(If SSH asks about authenticity of the host, you can check the key - fingerprint against http://savannah.nongnu.org/cvs/?group=lwip) - - -3 Merging from DEVEL branch to main trunk (stable) --------------------------------------------------- - -Merging is a delicate process in CVS and requires the -following disciplined steps in order to prevent conflicts -in the future. Conflicts can be hard to solve! - -Merging from branch A to branch B requires that the A branch -has a tag indicating the previous merger. This tag is called -'merged_from_A_to_B'. After merging, the tag is moved in the -A branch to remember this merger for future merge actions. - -IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE -REPOSITORY, THE TAG MUST BE SET ON THE SOURCE BRANCH OF THE -MERGE ACTION (REPLACING EXISTING TAGS WITH THE SAME NAME). - -Merge all changes in DEVEL since our last merge to main: - -In the working copy of the main trunk: -cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL - -(This will apply the changes between 'merged_from_DEVEL_to_main' -and 'DEVEL' to your work set of files) - -We can now commit the merge result. -cvs commit -R -m "Merged from DEVEL to main." - -If this worked out OK, we now move the tag in the DEVEL branch -to this merge point, so we can use this point for future merges: - -cvs rtag -F -r DEVEL merged_from_DEVEL_to_main lwip - -4 How to release lwIP ---------------------- - -First, checkout a clean copy of the branch to be released. Tag this set with -tag name "STABLE-0_6_3". (I use release number 0.6.3 throughout this example). - -Login CVS using pserver authentication, then export a clean copy of the -tagged tree. Export is similar to a checkout, except that the CVS metadata -is not created locally. - -export CVS_RSH=ssh -cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ - -r STABLE-0_6_3 -d lwip-0.6.3 lwip - -Archive this directory using tar, gzip'd, bzip2'd and zip'd. - -tar czvf lwip-0.6.3.tar.gz lwip-0.6.3 -tar cjvf lwip-0.6.3.tar.bz2 lwip-0.6.3 -zip -r lwip-0.6.3.zip lwip-0.6.3 - -Now, sign the archives with a detached GPG binary signature as follows: - -gpg -b lwip-0.6.3.tar.gz -gpg -b lwip-0.6.3.tar.bz2 -gpg -b lwip-0.6.3.zip - -Upload these files using anonymous FTP: -ncftp ftp://savannah.gnu.org/incoming/savannah/lwip - -ncftp>mput *0.6.3.* - -Additionally, you may post a news item on Savannah, like this: - -A new 0.6.3 release is now available here: -http://savannah.nongnu.org/files/?group=lwip&highlight=0.6.3 - -You will have to submit this via the user News interface, then approve -this via the Administrator News interface. \ No newline at end of file diff --git a/user/mpy/lib/lwip/doc/snmp_agent.txt b/user/mpy/lib/lwip/doc/snmp_agent.txt deleted file mode 100644 index 2653230..0000000 --- a/user/mpy/lib/lwip/doc/snmp_agent.txt +++ /dev/null @@ -1,181 +0,0 @@ -SNMPv1 agent for lwIP - -Author: Christiaan Simons - -This is a brief introduction how to use and configure the SNMP agent. -Note the agent uses the raw-API UDP interface so you may also want to -read rawapi.txt to gain a better understanding of the SNMP message handling. - -0 Agent Capabilities -==================== - -SNMPv1 per RFC1157 - This is an old(er) standard but is still widely supported. - For SNMPv2c and v3 have a greater complexity and need many - more lines of code. IMHO this breaks the idea of "lightweight IP". - - Note the S in SNMP stands for "Simple". Note that "Simple" is - relative. SNMP is simple compared to the complex ISO network - management protocols CMIP (Common Management Information Protocol) - and CMOT (CMip Over Tcp). - -MIB II per RFC1213 - The standard lwIP stack management information base. - This is a required MIB, so this is always enabled. - When builing lwIP without TCP, the mib-2.tcp group is omitted. - The groups EGP, CMOT and transmission are disabled by default. - - Most mib-2 objects are not writable except: - sysName, sysLocation, sysContact, snmpEnableAuthenTraps. - Writing to or changing the ARP and IP address and route - tables is not possible. - - Note lwIP has a very limited notion of IP routing. It currently - doen't have a route table and doesn't have a notion of the U,G,H flags. - Instead lwIP uses the interface list with only one default interface - acting as a single gateway interface (G) for the default route. - - The agent returns a "virtual table" with the default route 0.0.0.0 - for the default interface and network routes (no H) for each - network interface in the netif_list. - All routes are considered to be up (U). - -Loading additional MIBs - MIBs can only be added in compile-time, not in run-time. - There is no MIB compiler thus additional MIBs must be hand coded. - -Large SNMP message support - The packet decoding and encoding routines are designed - to use pbuf-chains. Larger payloads than the minimum - SNMP requirement of 484 octets are supported if the - PBUF_POOL_SIZE and IP_REASS_BUFSIZE are set to match your - local requirement. - -1 Building the Agent -==================== - -First of all you'll need to add the following define -to your local lwipopts.h: - -#define LWIP_SNMP 1 - -and add the source files in lwip/src/core/snmp -and some snmp headers in lwip/src/include/lwip to your makefile. - -Note you'll might need to adapt you network driver to update -the mib2 variables for your interface. - -2 Running the Agent -=================== - -The following function calls must be made in your program to -actually get the SNMP agent running. - -Before starting the agent you should supply pointers -to non-volatile memory for sysContact, sysLocation, -and snmpEnableAuthenTraps. You can do this by calling - -snmp_set_syscontact() -snmp_set_syslocation() -snmp_set_snmpenableauthentraps() - -Additionally you may want to set - -snmp_set_sysdescr() -snmp_set_sysobjid() (if you have a private MIB) -snmp_set_sysname() - -Also before starting the agent you need to setup -one or more trap destinations using these calls: - -snmp_trap_dst_enable(); -snmp_trap_dst_ip_set(); - -In the lwIP initialisation sequence call snmp_init() just after -the call to udp_init(). - -Exactly every 10 msec the SNMP uptime timestamp must be updated with -snmp_inc_sysuptime(). You should call this from a timer interrupt -or a timer signal handler depending on your runtime environment. - -An alternative way to update the SNMP uptime timestamp is to do a call like -snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but call to -a lower frequency). Another one is to not call snmp_inc_sysuptime() or -snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro. -This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside -snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only -when it's queried (any function which need "sysuptime" have to call -snmp_get_sysuptime). - - -3 Private MIBs -============== - -If want to extend the agent with your own private MIB you'll need to -add the following define to your local lwipopts.h: - -#define SNMP_PRIVATE_MIB 1 - -You must provide the private_mib.h and associated files yourself. -Note we don't have a "MIB compiler" that generates C source from a MIB, -so you're required to do some serious coding if you enable this! - -Note the lwIP enterprise ID (26381) is assigned to the lwIP project, -ALL OBJECT IDENTIFIERS LIVING UNDER THIS ID ARE ASSIGNED BY THE lwIP -MAINTAINERS! - -If you need to create your own private MIB you'll need -to apply for your own enterprise ID with IANA: http://www.iana.org/numbers.html - -You can set it by passing a struct snmp_obj_id to the agent -using snmp_set_sysobjid(&my_object_id), just before snmp_init(). - -Note the object identifiers for thes MIB-2 and your private MIB -tree must be kept in sorted ascending (lexicographical) order. -This to ensure correct getnext operation. - -An example for a private MIB is part of the "minimal Unix" project: -contrib/ports/unix/proj/minimal/lwip_prvmib.c - -The next chapter gives a more detailed description of the -MIB-2 tree and the optional private MIB. - -4 The Gory Details -================== - -4.0 Object identifiers and the MIB tree. - -We have three distinct parts for all object identifiers: - -The prefix - .iso.org.dod.internet - -the middle part - .mgmt.mib-2.ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress - -and the index part - .1.192.168.0.1 - -Objects located above the .internet hierarchy aren't supported. -Currently only the .mgmt sub-tree is available and -when the SNMP_PRIVATE_MIB is enabled the .private tree -becomes available too. - -Object identifiers from incoming requests are checked -for a matching prefix, middle part and index part -or are expanded(*) for GetNext requests with short -or inexisting names in the request. -(* we call this "expansion" but this also -resembles the "auto-completion" operation) - -The middle part is usually located in ROM (const) -to preserve precious RAM on small microcontrollers. -However RAM location is possible for a dynamically -changing private tree. - -The index part is handled by functions which in -turn use dynamically allocated index trees from RAM. -These trees are updated by e.g. the etharp code -when new entries are made or removed form the ARP cache. - -/** @todo more gory details */ diff --git a/user/mpy/lib/lwip/doc/sys_arch.txt b/user/mpy/lib/lwip/doc/sys_arch.txt deleted file mode 100644 index 847cd77..0000000 --- a/user/mpy/lib/lwip/doc/sys_arch.txt +++ /dev/null @@ -1,267 +0,0 @@ -sys_arch interface for lwIP 0.6++ - -Author: Adam Dunkels - -The operating system emulation layer provides a common interface -between the lwIP code and the underlying operating system kernel. The -general idea is that porting lwIP to new architectures requires only -small changes to a few header files and a new sys_arch -implementation. It is also possible to do a sys_arch implementation -that does not rely on any underlying operating system. - -The sys_arch provides semaphores and mailboxes to lwIP. For the full -lwIP functionality, multiple threads support can be implemented in the -sys_arch, but this is not required for the basic lwIP -functionality. Previous versions of lwIP required the sys_arch to -implement timer scheduling as well but as of lwIP 0.5 this is -implemented in a higher layer. - -In addition to the source file providing the functionality of sys_arch, -the OS emulation layer must provide several header files defining -macros used throughout lwip. The files required and the macros they -must define are listed below the sys_arch description. - -Semaphores can be either counting or binary - lwIP works with both -kinds. Mailboxes are used for message passing and can be implemented -either as a queue which allows multiple messages to be posted to a -mailbox, or as a rendez-vous point where only one message can be -posted at a time. lwIP works with both kinds, but the former type will -be more efficient. A message in a mailbox is just a pointer, nothing -more. - -Semaphores are represented by the type "sys_sem_t" which is typedef'd -in the sys_arch.h file. Mailboxes are equivalently represented by the -type "sys_mbox_t". lwIP does not place any restrictions on how -sys_sem_t or sys_mbox_t are represented internally. - -Since lwIP 1.4.0, semaphore and mailbox functions are prototyped in a way that -allows both using pointers or actual OS structures to be used. This way, memory -required for such types can be either allocated in place (globally or on the -stack) or on the heap (allocated internally in the "*_new()" functions). - -The following functions must be implemented by the sys_arch: - -- void sys_init(void) - - Is called to initialize the sys_arch layer. - -- err_t sys_sem_new(sys_sem_t *sem, u8_t count) - - Creates a new semaphore. The semaphore is allocated to the memory that 'sem' - points to (which can be both a pointer or the actual OS structure). - The "count" argument specifies the initial state of the semaphore (which is - either 0 or 1). - If the semaphore has been created, ERR_OK should be returned. Returning any - other error will provide a hint what went wrong, but except for assertions, - no real error handling is implemented. - -- void sys_sem_free(sys_sem_t *sem) - - Deallocates a semaphore. - -- void sys_sem_signal(sys_sem_t *sem) - - Signals a semaphore. - -- u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) - - Blocks the thread while waiting for the semaphore to be - signaled. If the "timeout" argument is non-zero, the thread should - only be blocked for the specified time (measured in - milliseconds). If the "timeout" argument is zero, the thread should be - blocked until the semaphore is signalled. - - If the timeout argument is non-zero, the return value is the number of - milliseconds spent waiting for the semaphore to be signaled. If the - semaphore wasn't signaled within the specified time, the return value is - SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore - (i.e., it was already signaled), the function may return zero. - - Notice that lwIP implements a function with a similar name, - sys_sem_wait(), that uses the sys_arch_sem_wait() function. - -- int sys_sem_valid(sys_sem_t *sem) - - Returns 1 if the semaphore is valid, 0 if it is not valid. - When using pointers, a simple way is to check the pointer for != NULL. - When directly using OS structures, implementing this may be more complex. - This may also be a define, in which case the function is not prototyped. - -- void sys_sem_set_invalid(sys_sem_t *sem) - - Invalidate a semaphore so that sys_sem_valid() returns 0. - ATTENTION: This does NOT mean that the semaphore shall be deallocated: - sys_sem_free() is always called before calling this function! - This may also be a define, in which case the function is not prototyped. - -- err_t sys_mbox_new(sys_mbox_t *mbox, int size) - - Creates an empty mailbox for maximum "size" elements. Elements stored - in mailboxes are pointers. You have to define macros "_MBOX_SIZE" - in your lwipopts.h, or ignore this parameter in your implementation - and use a default size. - If the mailbox has been created, ERR_OK should be returned. Returning any - other error will provide a hint what went wrong, but except for assertions, - no real error handling is implemented. - -- void sys_mbox_free(sys_mbox_t *mbox) - - Deallocates a mailbox. If there are messages still present in the - mailbox when the mailbox is deallocated, it is an indication of a - programming error in lwIP and the developer should be notified. - -- void sys_mbox_post(sys_mbox_t *mbox, void *msg) - - Posts the "msg" to the mailbox. This function have to block until - the "msg" is really posted. - -- err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) - - Try to post the "msg" to the mailbox. Returns ERR_MEM if this one - is full, else, ERR_OK if the "msg" is posted. - -- u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) - - Blocks the thread until a message arrives in the mailbox, but does - not block the thread longer than "timeout" milliseconds (similar to - the sys_arch_sem_wait() function). If "timeout" is 0, the thread should - be blocked until a message arrives. The "msg" argument is a result - parameter that is set by the function (i.e., by doing "*msg = - ptr"). The "msg" parameter maybe NULL to indicate that the message - should be dropped. - - The return values are the same as for the sys_arch_sem_wait() function: - Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a - timeout. - - Note that a function with a similar name, sys_mbox_fetch(), is - implemented by lwIP. - -- u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) - - This is similar to sys_arch_mbox_fetch, however if a message is not - present in the mailbox, it immediately returns with the code - SYS_MBOX_EMPTY. On success 0 is returned. - - To allow for efficient implementations, this can be defined as a - function-like macro in sys_arch.h instead of a normal function. For - example, a naive implementation could be: - #define sys_arch_mbox_tryfetch(mbox,msg) \ - sys_arch_mbox_fetch(mbox,msg,1) - although this would introduce unnecessary delays. - -- int sys_mbox_valid(sys_mbox_t *mbox) - - Returns 1 if the mailbox is valid, 0 if it is not valid. - When using pointers, a simple way is to check the pointer for != NULL. - When directly using OS structures, implementing this may be more complex. - This may also be a define, in which case the function is not prototyped. - -- void sys_mbox_set_invalid(sys_mbox_t *mbox) - - Invalidate a mailbox so that sys_mbox_valid() returns 0. - ATTENTION: This does NOT mean that the mailbox shall be deallocated: - sys_mbox_free() is always called before calling this function! - This may also be a define, in which case the function is not prototyped. - -If threads are supported by the underlying operating system and if -such functionality is needed in lwIP, the following function will have -to be implemented as well: - -- sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio) - - Starts a new thread named "name" with priority "prio" that will begin its - execution in the function "thread()". The "arg" argument will be passed as an - argument to the thread() function. The stack size to used for this thread is - the "stacksize" parameter. The id of the new thread is returned. Both the id - and the priority are system dependent. - -- sys_prot_t sys_arch_protect(void) - - This optional function does a "fast" critical region protection and returns - the previous protection level. This function is only called during very short - critical regions. An embedded system which supports ISR-based drivers might - want to implement this function by disabling interrupts. Task-based systems - might want to implement this by using a mutex or disabling tasking. This - function should support recursive calls from the same task or interrupt. In - other words, sys_arch_protect() could be called while already protected. In - that case the return value indicates that it is already protected. - - sys_arch_protect() is only required if your port is supporting an operating - system. - -- void sys_arch_unprotect(sys_prot_t pval) - - This optional function does a "fast" set of critical region protection to the - value specified by pval. See the documentation for sys_arch_protect() for - more information. This function is only required if your port is supporting - an operating system. - -For some configurations, you also need: - -- u32_t sys_now(void) - - This optional function returns the current time in milliseconds (don't care - for wraparound, this is only used for time diffs). - Not implementing this function means you cannot use some modules (e.g. TCP - timestamps, internal timeouts for NO_SYS==1). - - -Note: - -Be carefull with using mem_malloc() in sys_arch. When malloc() refers to -mem_malloc() you can run into a circular function call problem. In mem.c -mem_init() tries to allcate a semaphore using mem_malloc, which of course -can't be performed when sys_arch uses mem_malloc. - -------------------------------------------------------------------------------- -Additional files required for the "OS support" emulation layer: -------------------------------------------------------------------------------- - -cc.h - Architecture environment, some compiler specific, some - environment specific (probably should move env stuff - to sys_arch.h.) - - Typedefs for the types used by lwip - - u8_t, s8_t, u16_t, s16_t, u32_t, s32_t, mem_ptr_t - - Compiler hints for packing lwip's structures - - PACK_STRUCT_FIELD(x) - PACK_STRUCT_STRUCT - PACK_STRUCT_BEGIN - PACK_STRUCT_END - - Platform specific diagnostic output - - LWIP_PLATFORM_DIAG(x) - non-fatal, print a message. - LWIP_PLATFORM_ASSERT(x) - fatal, print message and abandon execution. - Portability defines for printf formatters: - U16_F, S16_F, X16_F, U32_F, S32_F, X32_F, SZT_F - - "lightweight" synchronization mechanisms - - SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable. - SYS_ARCH_PROTECT(x) - enter protection mode. - SYS_ARCH_UNPROTECT(x) - leave protection mode. - - If the compiler does not provide memset() this file must include a - definition of it, or include a file which defines it. - - This file must either include a system-local which defines - the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO - to make lwip/arch.h define the codes which are used throughout. - - -perf.h - Architecture specific performance measurement. - Measurement calls made throughout lwip, these can be defined to nothing. - PERF_START - start measuring something. - PERF_STOP(x) - stop measuring something, and record the result. - -sys_arch.h - Tied to sys_arch.c - - Arch dependent types for the following objects: - sys_sem_t, sys_mbox_t, sys_thread_t, - And, optionally: - sys_prot_t - - Defines to set vars of sys_mbox_t and sys_sem_t to NULL. - SYS_MBOX_NULL NULL - SYS_SEM_NULL NULL diff --git a/user/mpy/lib/lwip/src/FILES b/user/mpy/lib/lwip/src/FILES deleted file mode 100644 index 952aeab..0000000 --- a/user/mpy/lib/lwip/src/FILES +++ /dev/null @@ -1,13 +0,0 @@ -api/ - The code for the high-level wrapper API. Not needed if - you use the lowel-level call-back/raw API. - -core/ - The core of the TPC/IP stack; protocol implementations, - memory and buffer management, and the low-level raw API. - -include/ - lwIP include files. - -netif/ - Generic network interface device drivers are kept here, - as well as the ARP module. - -For more information on the various subdirectories, check the FILES -file in each directory. diff --git a/user/mpy/lib/lwip/src/api/api_lib.c b/user/mpy/lib/lwip/src/api/api_lib.c deleted file mode 100644 index 4bdf08e..0000000 --- a/user/mpy/lib/lwip/src/api/api_lib.c +++ /dev/null @@ -1,780 +0,0 @@ -/** - * @file - * Sequential API External module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -/* This is the part of the API that is linked with - the application */ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/api.h" -#include "lwip/tcpip.h" -#include "lwip/memp.h" - -#include "lwip/ip.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcp.h" - -#include - -/** - * Create a new netconn (of a specific type) that has a callback function. - * The corresponding pcb is also created. - * - * @param t the type of 'connection' to create (@see enum netconn_type) - * @param proto the IP protocol for RAW IP pcbs - * @param callback a function to call on status changes (RX available, TX'ed) - * @return a newly allocated struct netconn or - * NULL on memory error - */ -struct netconn* -netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_callback callback) -{ - struct netconn *conn; - struct api_msg msg; - - conn = netconn_alloc(t, callback); - if (conn != NULL) { - msg.function = do_newconn; - msg.msg.msg.n.proto = proto; - msg.msg.conn = conn; - if (TCPIP_APIMSG(&msg) != ERR_OK) { - LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL); - LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed)); - LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox)); -#if LWIP_TCP - LWIP_ASSERT("conn->acceptmbox shouldn't exist", !sys_mbox_valid(&conn->acceptmbox)); -#endif /* LWIP_TCP */ - sys_sem_free(&conn->op_completed); - sys_mbox_free(&conn->recvmbox); - memp_free(MEMP_NETCONN, conn); - return NULL; - } - } - return conn; -} - -/** - * Close a netconn 'connection' and free its resources. - * UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate - * after this returns. - * - * @param conn the netconn to delete - * @return ERR_OK if the connection was deleted - */ -err_t -netconn_delete(struct netconn *conn) -{ - struct api_msg msg; - - /* No ASSERT here because possible to get a (conn == NULL) if we got an accept error */ - if (conn == NULL) { - return ERR_OK; - } - - msg.function = do_delconn; - msg.msg.conn = conn; - tcpip_apimsg(&msg); - - netconn_free(conn); - - /* don't care for return value of do_delconn since it only calls void functions */ - - return ERR_OK; -} - -/** - * Get the local or remote IP address and port of a netconn. - * For RAW netconns, this returns the protocol instead of a port! - * - * @param conn the netconn to query - * @param addr a pointer to which to save the IP address - * @param port a pointer to which to save the port (or protocol for RAW) - * @param local 1 to get the local IP address, 0 to get the remote one - * @return ERR_CONN for invalid connections - * ERR_OK if the information was retrieved - */ -err_t -netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_getaddr: invalid conn", (conn != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_getaddr: invalid addr", (addr != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_getaddr: invalid port", (port != NULL), return ERR_ARG;); - - msg.function = do_getaddr; - msg.msg.conn = conn; - msg.msg.msg.ad.ipaddr = addr; - msg.msg.msg.ad.port = port; - msg.msg.msg.ad.local = local; - err = TCPIP_APIMSG(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Bind a netconn to a specific local IP address and port. - * Binding one netconn twice might not always be checked correctly! - * - * @param conn the netconn to bind - * @param addr the local IP address to bind the netconn to (use IP_ADDR_ANY - * to bind to all addresses) - * @param port the local port to bind the netconn to (not used for RAW) - * @return ERR_OK if bound, any other err_t on failure - */ -err_t -netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_bind: invalid conn", (conn != NULL), return ERR_ARG;); - - msg.function = do_bind; - msg.msg.conn = conn; - msg.msg.msg.bc.ipaddr = addr; - msg.msg.msg.bc.port = port; - err = TCPIP_APIMSG(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Connect a netconn to a specific remote IP address and port. - * - * @param conn the netconn to connect - * @param addr the remote IP address to connect to - * @param port the remote port to connect to (no used for RAW) - * @return ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise - */ -err_t -netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_connect: invalid conn", (conn != NULL), return ERR_ARG;); - - msg.function = do_connect; - msg.msg.conn = conn; - msg.msg.msg.bc.ipaddr = addr; - msg.msg.msg.bc.port = port; - /* This is the only function which need to not block tcpip_thread */ - err = tcpip_apimsg(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Disconnect a netconn from its current peer (only valid for UDP netconns). - * - * @param conn the netconn to disconnect - * @return TODO: return value is not set here... - */ -err_t -netconn_disconnect(struct netconn *conn) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;); - - msg.function = do_disconnect; - msg.msg.conn = conn; - err = TCPIP_APIMSG(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Set a TCP netconn into listen mode - * - * @param conn the tcp netconn to set to listen mode - * @param backlog the listen backlog, only used if TCP_LISTEN_BACKLOG==1 - * @return ERR_OK if the netconn was set to listen (UDP and RAW netconns - * don't return any error (yet?)) - */ -err_t -netconn_listen_with_backlog(struct netconn *conn, u8_t backlog) -{ -#if LWIP_TCP - struct api_msg msg; - err_t err; - - /* This does no harm. If TCP_LISTEN_BACKLOG is off, backlog is unused. */ - LWIP_UNUSED_ARG(backlog); - - LWIP_ERROR("netconn_listen: invalid conn", (conn != NULL), return ERR_ARG;); - - msg.function = do_listen; - msg.msg.conn = conn; -#if TCP_LISTEN_BACKLOG - msg.msg.msg.lb.backlog = backlog; -#endif /* TCP_LISTEN_BACKLOG */ - err = TCPIP_APIMSG(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -#else /* LWIP_TCP */ - LWIP_UNUSED_ARG(conn); - LWIP_UNUSED_ARG(backlog); - return ERR_ARG; -#endif /* LWIP_TCP */ -} - -/** - * Accept a new connection on a TCP listening netconn. - * - * @param conn the TCP listen netconn - * @param new_conn pointer where the new connection is stored - * @return ERR_OK if a new connection has been received or an error - * code otherwise - */ -err_t -netconn_accept(struct netconn *conn, struct netconn **new_conn) -{ -#if LWIP_TCP - struct netconn *newconn; - err_t err; -#if TCP_LISTEN_BACKLOG - struct api_msg msg; -#endif /* TCP_LISTEN_BACKLOG */ - - LWIP_ERROR("netconn_accept: invalid pointer", (new_conn != NULL), return ERR_ARG;); - *new_conn = NULL; - LWIP_ERROR("netconn_accept: invalid conn", (conn != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_accept: invalid acceptmbox", sys_mbox_valid(&conn->acceptmbox), return ERR_ARG;); - - err = conn->last_err; - if (ERR_IS_FATAL(err)) { - /* don't recv on fatal errors: this might block the application task - waiting on acceptmbox forever! */ - return err; - } - -#if LWIP_SO_RCVTIMEO - if (sys_arch_mbox_fetch(&conn->acceptmbox, (void **)&newconn, conn->recv_timeout) == SYS_ARCH_TIMEOUT) { - NETCONN_SET_SAFE_ERR(conn, ERR_TIMEOUT); - return ERR_TIMEOUT; - } -#else - sys_arch_mbox_fetch(&conn->acceptmbox, (void **)&newconn, 0); -#endif /* LWIP_SO_RCVTIMEO*/ - /* Register event with callback */ - API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0); - - if (newconn == NULL) { - /* connection has been aborted */ - NETCONN_SET_SAFE_ERR(conn, ERR_ABRT); - return ERR_ABRT; - } -#if TCP_LISTEN_BACKLOG - /* Let the stack know that we have accepted the connection. */ - msg.function = do_recv; - msg.msg.conn = conn; - /* don't care for the return value of do_recv */ - TCPIP_APIMSG(&msg); -#endif /* TCP_LISTEN_BACKLOG */ - - *new_conn = newconn; - /* don't set conn->last_err: it's only ERR_OK, anyway */ - return ERR_OK; -#else /* LWIP_TCP */ - LWIP_UNUSED_ARG(conn); - LWIP_UNUSED_ARG(new_conn); - return ERR_ARG; -#endif /* LWIP_TCP */ -} - -/** - * Receive data: actual implementation that doesn't care whether pbuf or netbuf - * is received - * - * @param conn the netconn from which to receive data - * @param new_buf pointer where a new pbuf/netbuf is stored when received data - * @return ERR_OK if data has been received, an error code otherwise (timeout, - * memory error or another error) - */ -static err_t -netconn_recv_data(struct netconn *conn, void **new_buf) -{ - void *buf = NULL; - u16_t len; - err_t err; -#if LWIP_TCP - struct api_msg msg; -#endif /* LWIP_TCP */ - - LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;); - *new_buf = NULL; - LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;); - - err = conn->last_err; - if (ERR_IS_FATAL(err)) { - /* don't recv on fatal errors: this might block the application task - waiting on recvmbox forever! */ - /* @todo: this does not allow us to fetch data that has been put into recvmbox - before the fatal error occurred - is that a problem? */ - return err; - } - -#if LWIP_SO_RCVTIMEO - if (sys_arch_mbox_fetch(&conn->recvmbox, &buf, conn->recv_timeout) == SYS_ARCH_TIMEOUT) { - NETCONN_SET_SAFE_ERR(conn, ERR_TIMEOUT); - return ERR_TIMEOUT; - } -#else - sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); -#endif /* LWIP_SO_RCVTIMEO*/ - -#if LWIP_TCP -#if (LWIP_UDP || LWIP_RAW) - if (conn->type == NETCONN_TCP) -#endif /* (LWIP_UDP || LWIP_RAW) */ - { - if (!netconn_get_noautorecved(conn) || (buf == NULL)) { - /* Let the stack know that we have taken the data. */ - /* TODO: Speedup: Don't block and wait for the answer here - (to prevent multiple thread-switches). */ - msg.function = do_recv; - msg.msg.conn = conn; - if (buf != NULL) { - msg.msg.msg.r.len = ((struct pbuf *)buf)->tot_len; - } else { - msg.msg.msg.r.len = 1; - } - /* don't care for the return value of do_recv */ - TCPIP_APIMSG(&msg); - } - - /* If we are closed, we indicate that we no longer wish to use the socket */ - if (buf == NULL) { - API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0); - /* Avoid to lose any previous error code */ - NETCONN_SET_SAFE_ERR(conn, ERR_CLSD); - return ERR_CLSD; - } - len = ((struct pbuf *)buf)->tot_len; - } -#endif /* LWIP_TCP */ -#if LWIP_TCP && (LWIP_UDP || LWIP_RAW) - else -#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */ -#if (LWIP_UDP || LWIP_RAW) - { - LWIP_ASSERT("buf != NULL", buf != NULL); - len = netbuf_len((struct netbuf *)buf); - } -#endif /* (LWIP_UDP || LWIP_RAW) */ - -#if LWIP_SO_RCVBUF - SYS_ARCH_DEC(conn->recv_avail, len); -#endif /* LWIP_SO_RCVBUF */ - /* Register event with callback */ - API_EVENT(conn, NETCONN_EVT_RCVMINUS, len); - - LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_recv_data: received %p, len=%"U16_F"\n", buf, len)); - - *new_buf = buf; - /* don't set conn->last_err: it's only ERR_OK, anyway */ - return ERR_OK; -} - -/** - * Receive data (in form of a pbuf) from a TCP netconn - * - * @param conn the netconn from which to receive data - * @param new_buf pointer where a new pbuf is stored when received data - * @return ERR_OK if data has been received, an error code otherwise (timeout, - * memory error or another error) - * ERR_ARG if conn is not a TCP netconn - */ -err_t -netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf) -{ - LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL) && - netconn_type(conn) == NETCONN_TCP, return ERR_ARG;); - - return netconn_recv_data(conn, (void **)new_buf); -} - -/** - * Receive data (in form of a netbuf containing a packet buffer) from a netconn - * - * @param conn the netconn from which to receive data - * @param new_buf pointer where a new netbuf is stored when received data - * @return ERR_OK if data has been received, an error code otherwise (timeout, - * memory error or another error) - */ -err_t -netconn_recv(struct netconn *conn, struct netbuf **new_buf) -{ -#if LWIP_TCP - struct netbuf *buf = NULL; - err_t err; -#endif /* LWIP_TCP */ - - LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;); - *new_buf = NULL; - LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;); - -#if LWIP_TCP -#if (LWIP_UDP || LWIP_RAW) - if (conn->type == NETCONN_TCP) -#endif /* (LWIP_UDP || LWIP_RAW) */ - { - struct pbuf *p = NULL; - /* This is not a listening netconn, since recvmbox is set */ - - buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); - if (buf == NULL) { - NETCONN_SET_SAFE_ERR(conn, ERR_MEM); - return ERR_MEM; - } - - err = netconn_recv_data(conn, (void **)&p); - if (err != ERR_OK) { - memp_free(MEMP_NETBUF, buf); - return err; - } - LWIP_ASSERT("p != NULL", p != NULL); - - buf->p = p; - buf->ptr = p; - buf->port = 0; - ip_addr_set_any(&buf->addr); - *new_buf = buf; - /* don't set conn->last_err: it's only ERR_OK, anyway */ - return ERR_OK; - } -#endif /* LWIP_TCP */ -#if LWIP_TCP && (LWIP_UDP || LWIP_RAW) - else -#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */ - { -#if (LWIP_UDP || LWIP_RAW) - return netconn_recv_data(conn, (void **)new_buf); -#endif /* (LWIP_UDP || LWIP_RAW) */ - } -} - -/** - * TCP: update the receive window: by calling this, the application - * tells the stack that it has processed data and is able to accept - * new data. - * ATTENTION: use with care, this is mainly used for sockets! - * Can only be used when calling netconn_set_noautorecved(conn, 1) before. - * - * @param conn the netconn for which to update the receive window - * @param length amount of data processed (ATTENTION: this must be accurate!) - */ -void -netconn_recved(struct netconn *conn, u32_t length) -{ -#if LWIP_TCP - if ((conn != NULL) && (conn->type == NETCONN_TCP) && - (netconn_get_noautorecved(conn))) { - struct api_msg msg; - /* Let the stack know that we have taken the data. */ - /* TODO: Speedup: Don't block and wait for the answer here - (to prevent multiple thread-switches). */ - msg.function = do_recv; - msg.msg.conn = conn; - msg.msg.msg.r.len = length; - /* don't care for the return value of do_recv */ - TCPIP_APIMSG(&msg); - } -#else /* LWIP_TCP */ - LWIP_UNUSED_ARG(conn); - LWIP_UNUSED_ARG(length); -#endif /* LWIP_TCP */ -} - -/** - * Send data (in form of a netbuf) to a specific remote IP address and port. - * Only to be used for UDP and RAW netconns (not TCP). - * - * @param conn the netconn over which to send data - * @param buf a netbuf containing the data to send - * @param addr the remote IP address to which to send the data - * @param port the remote port to which to send the data - * @return ERR_OK if data was sent, any other err_t on error - */ -err_t -netconn_sendto(struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port) -{ - if (buf != NULL) { - ip_addr_set(&buf->addr, addr); - buf->port = port; - return netconn_send(conn, buf); - } - return ERR_VAL; -} - -/** - * Send data over a UDP or RAW netconn (that is already connected). - * - * @param conn the UDP or RAW netconn over which to send data - * @param buf a netbuf containing the data to send - * @return ERR_OK if data was sent, any other err_t on error - */ -err_t -netconn_send(struct netconn *conn, struct netbuf *buf) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_send: invalid conn", (conn != NULL), return ERR_ARG;); - - LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %"U16_F" bytes\n", buf->p->tot_len)); - msg.function = do_send; - msg.msg.conn = conn; - msg.msg.msg.b = buf; - err = TCPIP_APIMSG(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Send data over a TCP netconn. - * - * @param conn the TCP netconn over which to send data - * @param dataptr pointer to the application buffer that contains the data to send - * @param size size of the application data to send - * @param apiflags combination of following flags : - * - NETCONN_COPY: data will be copied into memory belonging to the stack - * - NETCONN_MORE: for TCP connection, PSH flag will be set on last segment sent - * - NETCONN_DONTBLOCK: only write the data if all dat can be written at once - * @param bytes_written pointer to a location that receives the number of written bytes - * @return ERR_OK if data was sent, any other err_t on error - */ -err_t -netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, - u8_t apiflags, size_t *bytes_written) -{ - struct api_msg msg; - err_t err; - u8_t dontblock; - - LWIP_ERROR("netconn_write: invalid conn", (conn != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_write: invalid conn->type", (conn->type == NETCONN_TCP), return ERR_VAL;); - if (size == 0) { - return ERR_OK; - } - dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK); - if (dontblock && !bytes_written) { - /* This implies netconn_write() cannot be used for non-blocking send, since - it has no way to return the number of bytes written. */ - return ERR_VAL; - } - - /* non-blocking write sends as much */ - msg.function = do_write; - msg.msg.conn = conn; - msg.msg.msg.w.dataptr = dataptr; - msg.msg.msg.w.apiflags = apiflags; - msg.msg.msg.w.len = size; -#if LWIP_SO_SNDTIMEO - if (conn->send_timeout != 0) { - /* get the time we started, which is later compared to - sys_now() + conn->send_timeout */ - msg.msg.msg.w.time_started = sys_now(); - } else { - msg.msg.msg.w.time_started = 0; - } -#endif /* LWIP_SO_SNDTIMEO */ - - /* For locking the core: this _can_ be delayed on low memory/low send buffer, - but if it is, this is done inside api_msg.c:do_write(), so we can use the - non-blocking version here. */ - err = TCPIP_APIMSG(&msg); - if ((err == ERR_OK) && (bytes_written != NULL)) { - if (dontblock -#if LWIP_SO_SNDTIMEO - || (conn->send_timeout != 0) -#endif /* LWIP_SO_SNDTIMEO */ - ) { - /* nonblocking write: maybe the data has been sent partly */ - *bytes_written = msg.msg.msg.w.len; - } else { - /* blocking call succeeded: all data has been sent if it */ - *bytes_written = size; - } - } - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Close ot shutdown a TCP netconn (doesn't delete it). - * - * @param conn the TCP netconn to close or shutdown - * @param how fully close or only shutdown one side? - * @return ERR_OK if the netconn was closed, any other err_t on error - */ -static err_t -netconn_close_shutdown(struct netconn *conn, u8_t how) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_close: invalid conn", (conn != NULL), return ERR_ARG;); - - msg.function = do_close; - msg.msg.conn = conn; - /* shutting down both ends is the same as closing */ - msg.msg.msg.sd.shut = how; - /* because of the LWIP_TCPIP_CORE_LOCKING implementation of do_close, - don't use TCPIP_APIMSG here */ - err = tcpip_apimsg(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} - -/** - * Close a TCP netconn (doesn't delete it). - * - * @param conn the TCP netconn to close - * @return ERR_OK if the netconn was closed, any other err_t on error - */ -err_t -netconn_close(struct netconn *conn) -{ - /* shutting down both ends is the same as closing */ - return netconn_close_shutdown(conn, NETCONN_SHUT_RDWR); -} - -/** - * Shut down one or both sides of a TCP netconn (doesn't delete it). - * - * @param conn the TCP netconn to shut down - * @return ERR_OK if the netconn was closed, any other err_t on error - */ -err_t -netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx) -{ - return netconn_close_shutdown(conn, (shut_rx ? NETCONN_SHUT_RD : 0) | (shut_tx ? NETCONN_SHUT_WR : 0)); -} - -#if LWIP_IGMP -/** - * Join multicast groups for UDP netconns. - * - * @param conn the UDP netconn for which to change multicast addresses - * @param multiaddr IP address of the multicast group to join or leave - * @param netif_addr the IP address of the network interface on which to send - * the igmp message - * @param join_or_leave flag whether to send a join- or leave-message - * @return ERR_OK if the action was taken, any err_t on error - */ -err_t -netconn_join_leave_group(struct netconn *conn, - ip_addr_t *multiaddr, - ip_addr_t *netif_addr, - enum netconn_igmp join_or_leave) -{ - struct api_msg msg; - err_t err; - - LWIP_ERROR("netconn_join_leave_group: invalid conn", (conn != NULL), return ERR_ARG;); - - msg.function = do_join_leave_group; - msg.msg.conn = conn; - msg.msg.msg.jl.multiaddr = multiaddr; - msg.msg.msg.jl.netif_addr = netif_addr; - msg.msg.msg.jl.join_or_leave = join_or_leave; - err = TCPIP_APIMSG(&msg); - - NETCONN_SET_SAFE_ERR(conn, err); - return err; -} -#endif /* LWIP_IGMP */ - -#if LWIP_DNS -/** - * Execute a DNS query, only one IP address is returned - * - * @param name a string representation of the DNS host name to query - * @param addr a preallocated ip_addr_t where to store the resolved IP address - * @return ERR_OK: resolving succeeded - * ERR_MEM: memory error, try again later - * ERR_ARG: dns client not initialized or invalid hostname - * ERR_VAL: dns server response was invalid - */ -err_t -netconn_gethostbyname(const char *name, ip_addr_t *addr) -{ - struct dns_api_msg msg; - err_t err; - sys_sem_t sem; - - LWIP_ERROR("netconn_gethostbyname: invalid name", (name != NULL), return ERR_ARG;); - LWIP_ERROR("netconn_gethostbyname: invalid addr", (addr != NULL), return ERR_ARG;); - - err = sys_sem_new(&sem, 0); - if (err != ERR_OK) { - return err; - } - - msg.name = name; - msg.addr = addr; - msg.err = &err; - msg.sem = &sem; - - tcpip_callback(do_gethostbyname, &msg); - sys_sem_wait(&sem); - sys_sem_free(&sem); - - return err; -} -#endif /* LWIP_DNS*/ - -#endif /* LWIP_NETCONN */ diff --git a/user/mpy/lib/lwip/src/api/api_msg.c b/user/mpy/lib/lwip/src/api/api_msg.c deleted file mode 100644 index d4e44b9..0000000 --- a/user/mpy/lib/lwip/src/api/api_msg.c +++ /dev/null @@ -1,1565 +0,0 @@ -/** - * @file - * Sequential API Internal module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/api_msg.h" - -#include "lwip/ip.h" -#include "lwip/udp.h" -#include "lwip/tcp.h" -#include "lwip/raw.h" - -#include "lwip/memp.h" -#include "lwip/tcpip.h" -#include "lwip/igmp.h" -#include "lwip/dns.h" - -#include - -#define SET_NONBLOCKING_CONNECT(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_IN_NONBLOCKING_CONNECT; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_IN_NONBLOCKING_CONNECT; }} while(0) -#define IN_NONBLOCKING_CONNECT(conn) (((conn)->flags & NETCONN_FLAG_IN_NONBLOCKING_CONNECT) != 0) - -/* forward declarations */ -#if LWIP_TCP -static err_t do_writemore(struct netconn *conn); -static void do_close_internal(struct netconn *conn); -#endif - -#if LWIP_RAW -/** - * Receive callback function for RAW netconns. - * Doesn't 'eat' the packet, only references it and sends it to - * conn->recvmbox - * - * @see raw.h (struct raw_pcb.recv) for parameters and return value - */ -static u8_t -recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, - ip_addr_t *addr) -{ - struct pbuf *q; - struct netbuf *buf; - struct netconn *conn; - - LWIP_UNUSED_ARG(addr); - conn = (struct netconn *)arg; - - if ((conn != NULL) && sys_mbox_valid(&conn->recvmbox)) { -#if LWIP_SO_RCVBUF - int recv_avail; - SYS_ARCH_GET(conn->recv_avail, recv_avail); - if ((recv_avail + (int)(p->tot_len)) > conn->recv_bufsize) { - return 0; - } -#endif /* LWIP_SO_RCVBUF */ - /* copy the whole packet into new pbufs */ - q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); - if(q != NULL) { - if (pbuf_copy(q, p) != ERR_OK) { - pbuf_free(q); - q = NULL; - } - } - - if (q != NULL) { - u16_t len; - buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); - if (buf == NULL) { - pbuf_free(q); - return 0; - } - - buf->p = q; - buf->ptr = q; - ip_addr_copy(buf->addr, *ip_current_src_addr()); - buf->port = pcb->protocol; - - len = q->tot_len; - if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) { - netbuf_delete(buf); - return 0; - } else { -#if LWIP_SO_RCVBUF - SYS_ARCH_INC(conn->recv_avail, len); -#endif /* LWIP_SO_RCVBUF */ - /* Register event with callback */ - API_EVENT(conn, NETCONN_EVT_RCVPLUS, len); - } - } - } - - return 0; /* do not eat the packet */ -} -#endif /* LWIP_RAW*/ - -#if LWIP_UDP -/** - * Receive callback function for UDP netconns. - * Posts the packet to conn->recvmbox or deletes it on memory error. - * - * @see udp.h (struct udp_pcb.recv) for parameters - */ -static void -recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *addr, u16_t port) -{ - struct netbuf *buf; - struct netconn *conn; - u16_t len; -#if LWIP_SO_RCVBUF - int recv_avail; -#endif /* LWIP_SO_RCVBUF */ - - LWIP_UNUSED_ARG(pcb); /* only used for asserts... */ - LWIP_ASSERT("recv_udp must have a pcb argument", pcb != NULL); - LWIP_ASSERT("recv_udp must have an argument", arg != NULL); - conn = (struct netconn *)arg; - LWIP_ASSERT("recv_udp: recv for wrong pcb!", conn->pcb.udp == pcb); - -#if LWIP_SO_RCVBUF - SYS_ARCH_GET(conn->recv_avail, recv_avail); - if ((conn == NULL) || !sys_mbox_valid(&conn->recvmbox) || - ((recv_avail + (int)(p->tot_len)) > conn->recv_bufsize)) { -#else /* LWIP_SO_RCVBUF */ - if ((conn == NULL) || !sys_mbox_valid(&conn->recvmbox)) { -#endif /* LWIP_SO_RCVBUF */ - pbuf_free(p); - return; - } - - buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); - if (buf == NULL) { - pbuf_free(p); - return; - } else { - buf->p = p; - buf->ptr = p; - ip_addr_set(&buf->addr, addr); - buf->port = port; -#if LWIP_NETBUF_RECVINFO - { - const struct ip_hdr* iphdr = ip_current_header(); - /* get the UDP header - always in the first pbuf, ensured by udp_input */ - const struct udp_hdr* udphdr = (void*)(((char*)iphdr) + IPH_LEN(iphdr)); -#if LWIP_CHECKSUM_ON_COPY - buf->flags = NETBUF_FLAG_DESTADDR; -#endif /* LWIP_CHECKSUM_ON_COPY */ - ip_addr_set(&buf->toaddr, ip_current_dest_addr()); - buf->toport_chksum = udphdr->dest; - } -#endif /* LWIP_NETBUF_RECVINFO */ - } - - len = p->tot_len; - if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) { - netbuf_delete(buf); - return; - } else { -#if LWIP_SO_RCVBUF - SYS_ARCH_INC(conn->recv_avail, len); -#endif /* LWIP_SO_RCVBUF */ - /* Register event with callback */ - API_EVENT(conn, NETCONN_EVT_RCVPLUS, len); - } -} -#endif /* LWIP_UDP */ - -#if LWIP_TCP -/** - * Receive callback function for TCP netconns. - * Posts the packet to conn->recvmbox, but doesn't delete it on errors. - * - * @see tcp.h (struct tcp_pcb.recv) for parameters and return value - */ -static err_t -recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) -{ - struct netconn *conn; - u16_t len; - - LWIP_UNUSED_ARG(pcb); - LWIP_ASSERT("recv_tcp must have a pcb argument", pcb != NULL); - LWIP_ASSERT("recv_tcp must have an argument", arg != NULL); - conn = (struct netconn *)arg; - LWIP_ASSERT("recv_tcp: recv for wrong pcb!", conn->pcb.tcp == pcb); - - if (conn == NULL) { - return ERR_VAL; - } - if (!sys_mbox_valid(&conn->recvmbox)) { - /* recvmbox already deleted */ - if (p != NULL) { - tcp_recved(pcb, p->tot_len); - pbuf_free(p); - } - return ERR_OK; - } - /* Unlike for UDP or RAW pcbs, don't check for available space - using recv_avail since that could break the connection - (data is already ACKed) */ - - /* don't overwrite fatal errors! */ - NETCONN_SET_SAFE_ERR(conn, err); - - if (p != NULL) { - len = p->tot_len; - } else { - len = 0; - } - - if (sys_mbox_trypost(&conn->recvmbox, p) != ERR_OK) { - /* don't deallocate p: it is presented to us later again from tcp_fasttmr! */ - return ERR_MEM; - } else { -#if LWIP_SO_RCVBUF - SYS_ARCH_INC(conn->recv_avail, len); -#endif /* LWIP_SO_RCVBUF */ - /* Register event with callback */ - API_EVENT(conn, NETCONN_EVT_RCVPLUS, len); - } - - return ERR_OK; -} - -/** - * Poll callback function for TCP netconns. - * Wakes up an application thread that waits for a connection to close - * or data to be sent. The application thread then takes the - * appropriate action to go on. - * - * Signals the conn->sem. - * netconn_close waits for conn->sem if closing failed. - * - * @see tcp.h (struct tcp_pcb.poll) for parameters and return value - */ -static err_t -poll_tcp(void *arg, struct tcp_pcb *pcb) -{ - struct netconn *conn = (struct netconn *)arg; - - LWIP_UNUSED_ARG(pcb); - LWIP_ASSERT("conn != NULL", (conn != NULL)); - - if (conn->state == NETCONN_WRITE) { - do_writemore(conn); - } else if (conn->state == NETCONN_CLOSE) { - do_close_internal(conn); - } - /* @todo: implement connect timeout here? */ - - /* Did a nonblocking write fail before? Then check available write-space. */ - if (conn->flags & NETCONN_FLAG_CHECK_WRITESPACE) { - /* If the queued byte- or pbuf-count drops below the configured low-water limit, - let select mark this pcb as writable again. */ - if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) && - (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) { - conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE; - API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); - } - } - - return ERR_OK; -} - -/** - * Sent callback function for TCP netconns. - * Signals the conn->sem and calls API_EVENT. - * netconn_write waits for conn->sem if send buffer is low. - * - * @see tcp.h (struct tcp_pcb.sent) for parameters and return value - */ -static err_t -sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len) -{ - struct netconn *conn = (struct netconn *)arg; - - LWIP_UNUSED_ARG(pcb); - LWIP_ASSERT("conn != NULL", (conn != NULL)); - - if (conn->state == NETCONN_WRITE) { - do_writemore(conn); - } else if (conn->state == NETCONN_CLOSE) { - do_close_internal(conn); - } - - if (conn) { - /* If the queued byte- or pbuf-count drops below the configured low-water limit, - let select mark this pcb as writable again. */ - if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) && - (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) { - conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE; - API_EVENT(conn, NETCONN_EVT_SENDPLUS, len); - } - } - - return ERR_OK; -} - -/** - * Error callback function for TCP netconns. - * Signals conn->sem, posts to all conn mboxes and calls API_EVENT. - * The application thread has then to decide what to do. - * - * @see tcp.h (struct tcp_pcb.err) for parameters - */ -static void -err_tcp(void *arg, err_t err) -{ - struct netconn *conn; - enum netconn_state old_state; - SYS_ARCH_DECL_PROTECT(lev); - - conn = (struct netconn *)arg; - LWIP_ASSERT("conn != NULL", (conn != NULL)); - - conn->pcb.tcp = NULL; - - /* no check since this is always fatal! */ - SYS_ARCH_PROTECT(lev); - conn->last_err = err; - SYS_ARCH_UNPROTECT(lev); - - /* reset conn->state now before waking up other threads */ - old_state = conn->state; - conn->state = NETCONN_NONE; - - /* Notify the user layer about a connection error. Used to signal - select. */ - API_EVENT(conn, NETCONN_EVT_ERROR, 0); - /* Try to release selects pending on 'read' or 'write', too. - They will get an error if they actually try to read or write. */ - API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0); - API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); - - /* pass NULL-message to recvmbox to wake up pending recv */ - if (sys_mbox_valid(&conn->recvmbox)) { - /* use trypost to prevent deadlock */ - sys_mbox_trypost(&conn->recvmbox, NULL); - } - /* pass NULL-message to acceptmbox to wake up pending accept */ - if (sys_mbox_valid(&conn->acceptmbox)) { - /* use trypost to preven deadlock */ - sys_mbox_trypost(&conn->acceptmbox, NULL); - } - - if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) || - (old_state == NETCONN_CONNECT)) { - /* calling do_writemore/do_close_internal is not necessary - since the pcb has already been deleted! */ - int was_nonblocking_connect = IN_NONBLOCKING_CONNECT(conn); - SET_NONBLOCKING_CONNECT(conn, 0); - - if (!was_nonblocking_connect) { - /* set error return code */ - LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL); - conn->current_msg->err = err; - conn->current_msg = NULL; - /* wake up the waiting task */ - sys_sem_signal(&conn->op_completed); - } - } else { - LWIP_ASSERT("conn->current_msg == NULL", conn->current_msg == NULL); - } -} - -/** - * Setup a tcp_pcb with the correct callback function pointers - * and their arguments. - * - * @param conn the TCP netconn to setup - */ -static void -setup_tcp(struct netconn *conn) -{ - struct tcp_pcb *pcb; - - pcb = conn->pcb.tcp; - tcp_arg(pcb, conn); - tcp_recv(pcb, recv_tcp); - tcp_sent(pcb, sent_tcp); - tcp_poll(pcb, poll_tcp, 4); - tcp_err(pcb, err_tcp); -} - -/** - * Accept callback function for TCP netconns. - * Allocates a new netconn and posts that to conn->acceptmbox. - * - * @see tcp.h (struct tcp_pcb_listen.accept) for parameters and return value - */ -static err_t -accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) -{ - struct netconn *newconn; - struct netconn *conn = (struct netconn *)arg; - - LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: newpcb->tate: %s\n", tcp_debug_state_str(newpcb->state))); - - if (!sys_mbox_valid(&conn->acceptmbox)) { - LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: acceptmbox already deleted\n")); - return ERR_VAL; - } - - /* We have to set the callback here even though - * the new socket is unknown. conn->socket is marked as -1. */ - newconn = netconn_alloc(conn->type, conn->callback); - if (newconn == NULL) { - return ERR_MEM; - } - newconn->pcb.tcp = newpcb; - setup_tcp(newconn); - /* no protection: when creating the pcb, the netconn is not yet known - to the application thread */ - newconn->last_err = err; - - if (sys_mbox_trypost(&conn->acceptmbox, newconn) != ERR_OK) { - /* When returning != ERR_OK, the pcb is aborted in tcp_process(), - so do nothing here! */ - /* remove all references to this netconn from the pcb */ - struct tcp_pcb* pcb = newconn->pcb.tcp; - tcp_arg(pcb, NULL); - tcp_recv(pcb, NULL); - tcp_sent(pcb, NULL); - tcp_poll(pcb, NULL, 4); - tcp_err(pcb, NULL); - /* remove reference from to the pcb from this netconn */ - newconn->pcb.tcp = NULL; - /* no need to drain since we know the recvmbox is empty. */ - sys_mbox_free(&newconn->recvmbox); - sys_mbox_set_invalid(&newconn->recvmbox); - netconn_free(newconn); - return ERR_MEM; - } else { - /* Register event with callback */ - API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0); - } - - return ERR_OK; -} -#endif /* LWIP_TCP */ - -/** - * Create a new pcb of a specific type. - * Called from do_newconn(). - * - * @param msg the api_msg_msg describing the connection type - * @return msg->conn->err, but the return value is currently ignored - */ -static void -pcb_new(struct api_msg_msg *msg) -{ - LWIP_ASSERT("pcb_new: pcb already allocated", msg->conn->pcb.tcp == NULL); - - /* Allocate a PCB for this connection */ - switch(NETCONNTYPE_GROUP(msg->conn->type)) { -#if LWIP_RAW - case NETCONN_RAW: - msg->conn->pcb.raw = raw_new(msg->msg.n.proto); - if(msg->conn->pcb.raw == NULL) { - msg->err = ERR_MEM; - break; - } - raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn); - break; -#endif /* LWIP_RAW */ -#if LWIP_UDP - case NETCONN_UDP: - msg->conn->pcb.udp = udp_new(); - if(msg->conn->pcb.udp == NULL) { - msg->err = ERR_MEM; - break; - } -#if LWIP_UDPLITE - if (msg->conn->type==NETCONN_UDPLITE) { - udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); - } -#endif /* LWIP_UDPLITE */ - if (msg->conn->type==NETCONN_UDPNOCHKSUM) { - udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); - } - udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case NETCONN_TCP: - msg->conn->pcb.tcp = tcp_new(); - if(msg->conn->pcb.tcp == NULL) { - msg->err = ERR_MEM; - break; - } - setup_tcp(msg->conn); - break; -#endif /* LWIP_TCP */ - default: - /* Unsupported netconn type, e.g. protocol disabled */ - msg->err = ERR_VAL; - break; - } -} - -/** - * Create a new pcb of a specific type inside a netconn. - * Called from netconn_new_with_proto_and_callback. - * - * @param msg the api_msg_msg describing the connection type - */ -void -do_newconn(struct api_msg_msg *msg) -{ - msg->err = ERR_OK; - if(msg->conn->pcb.tcp == NULL) { - pcb_new(msg); - } - /* Else? This "new" connection already has a PCB allocated. */ - /* Is this an error condition? Should it be deleted? */ - /* We currently just are happy and return. */ - - TCPIP_APIMSG_ACK(msg); -} - -/** - * Create a new netconn (of a specific type) that has a callback function. - * The corresponding pcb is NOT created! - * - * @param t the type of 'connection' to create (@see enum netconn_type) - * @param proto the IP protocol for RAW IP pcbs - * @param callback a function to call on status changes (RX available, TX'ed) - * @return a newly allocated struct netconn or - * NULL on memory error - */ -struct netconn* -netconn_alloc(enum netconn_type t, netconn_callback callback) -{ - struct netconn *conn; - int size; - - conn = (struct netconn *)memp_malloc(MEMP_NETCONN); - if (conn == NULL) { - return NULL; - } - - conn->last_err = ERR_OK; - conn->type = t; - conn->pcb.tcp = NULL; - -#if (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_UDP_RECVMBOX_SIZE) && \ - (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_TCP_RECVMBOX_SIZE) - size = DEFAULT_RAW_RECVMBOX_SIZE; -#else - switch(NETCONNTYPE_GROUP(t)) { -#if LWIP_RAW - case NETCONN_RAW: - size = DEFAULT_RAW_RECVMBOX_SIZE; - break; -#endif /* LWIP_RAW */ -#if LWIP_UDP - case NETCONN_UDP: - size = DEFAULT_UDP_RECVMBOX_SIZE; - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case NETCONN_TCP: - size = DEFAULT_TCP_RECVMBOX_SIZE; - break; -#endif /* LWIP_TCP */ - default: - LWIP_ASSERT("netconn_alloc: undefined netconn_type", 0); - goto free_and_return; - } -#endif - - if (sys_sem_new(&conn->op_completed, 0) != ERR_OK) { - goto free_and_return; - } - if (sys_mbox_new(&conn->recvmbox, size) != ERR_OK) { - sys_sem_free(&conn->op_completed); - goto free_and_return; - } - -#if LWIP_TCP - sys_mbox_set_invalid(&conn->acceptmbox); -#endif - conn->state = NETCONN_NONE; -#if LWIP_SOCKET - /* initialize socket to -1 since 0 is a valid socket */ - conn->socket = -1; -#endif /* LWIP_SOCKET */ - conn->callback = callback; -#if LWIP_TCP - conn->current_msg = NULL; - conn->write_offset = 0; -#endif /* LWIP_TCP */ -#if LWIP_SO_SNDTIMEO - conn->send_timeout = 0; -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO - conn->recv_timeout = 0; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - conn->recv_bufsize = RECV_BUFSIZE_DEFAULT; - conn->recv_avail = 0; -#endif /* LWIP_SO_RCVBUF */ - conn->flags = 0; - return conn; -free_and_return: - memp_free(MEMP_NETCONN, conn); - return NULL; -} - -/** - * Delete a netconn and all its resources. - * The pcb is NOT freed (since we might not be in the right thread context do this). - * - * @param conn the netconn to free - */ -void -netconn_free(struct netconn *conn) -{ - LWIP_ASSERT("PCB must be deallocated outside this function", conn->pcb.tcp == NULL); - LWIP_ASSERT("recvmbox must be deallocated before calling this function", - !sys_mbox_valid(&conn->recvmbox)); -#if LWIP_TCP - LWIP_ASSERT("acceptmbox must be deallocated before calling this function", - !sys_mbox_valid(&conn->acceptmbox)); -#endif /* LWIP_TCP */ - - sys_sem_free(&conn->op_completed); - sys_sem_set_invalid(&conn->op_completed); - - memp_free(MEMP_NETCONN, conn); -} - -/** - * Delete rcvmbox and acceptmbox of a netconn and free the left-over data in - * these mboxes - * - * @param conn the netconn to free - * @bytes_drained bytes drained from recvmbox - * @accepts_drained pending connections drained from acceptmbox - */ -static void -netconn_drain(struct netconn *conn) -{ - void *mem; -#if LWIP_TCP - struct pbuf *p; -#endif /* LWIP_TCP */ - - /* This runs in tcpip_thread, so we don't need to lock against rx packets */ - - /* Delete and drain the recvmbox. */ - if (sys_mbox_valid(&conn->recvmbox)) { - while (sys_mbox_tryfetch(&conn->recvmbox, &mem) != SYS_MBOX_EMPTY) { -#if LWIP_TCP - if (conn->type == NETCONN_TCP) { - if(mem != NULL) { - p = (struct pbuf*)mem; - /* pcb might be set to NULL already by err_tcp() */ - if (conn->pcb.tcp != NULL) { - tcp_recved(conn->pcb.tcp, p->tot_len); - } - pbuf_free(p); - } - } else -#endif /* LWIP_TCP */ - { - netbuf_delete((struct netbuf *)mem); - } - } - sys_mbox_free(&conn->recvmbox); - sys_mbox_set_invalid(&conn->recvmbox); - } - - /* Delete and drain the acceptmbox. */ -#if LWIP_TCP - if (sys_mbox_valid(&conn->acceptmbox)) { - while (sys_mbox_tryfetch(&conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) { - struct netconn *newconn = (struct netconn *)mem; - /* Only tcp pcbs have an acceptmbox, so no need to check conn->type */ - /* pcb might be set to NULL already by err_tcp() */ - if (conn->pcb.tcp != NULL) { - tcp_accepted(conn->pcb.tcp); - } - /* drain recvmbox */ - netconn_drain(newconn); - if (newconn->pcb.tcp != NULL) { - tcp_abort(newconn->pcb.tcp); - newconn->pcb.tcp = NULL; - } - netconn_free(newconn); - } - sys_mbox_free(&conn->acceptmbox); - sys_mbox_set_invalid(&conn->acceptmbox); - } -#endif /* LWIP_TCP */ -} - -#if LWIP_TCP -/** - * Internal helper function to close a TCP netconn: since this sometimes - * doesn't work at the first attempt, this function is called from multiple - * places. - * - * @param conn the TCP netconn to close - */ -static void -do_close_internal(struct netconn *conn) -{ - err_t err; - u8_t shut, shut_rx, shut_tx, close; - - LWIP_ASSERT("invalid conn", (conn != NULL)); - LWIP_ASSERT("this is for tcp netconns only", (conn->type == NETCONN_TCP)); - LWIP_ASSERT("conn must be in state NETCONN_CLOSE", (conn->state == NETCONN_CLOSE)); - LWIP_ASSERT("pcb already closed", (conn->pcb.tcp != NULL)); - LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL); - - shut = conn->current_msg->msg.sd.shut; - shut_rx = shut & NETCONN_SHUT_RD; - shut_tx = shut & NETCONN_SHUT_WR; - /* shutting down both ends is the same as closing */ - close = shut == NETCONN_SHUT_RDWR; - - /* Set back some callback pointers */ - if (close) { - tcp_arg(conn->pcb.tcp, NULL); - } - if (conn->pcb.tcp->state == LISTEN) { - tcp_accept(conn->pcb.tcp, NULL); - } else { - /* some callbacks have to be reset if tcp_close is not successful */ - if (shut_rx) { - tcp_recv(conn->pcb.tcp, NULL); - tcp_accept(conn->pcb.tcp, NULL); - } - if (shut_tx) { - tcp_sent(conn->pcb.tcp, NULL); - } - if (close) { - tcp_poll(conn->pcb.tcp, NULL, 4); - tcp_err(conn->pcb.tcp, NULL); - } - } - /* Try to close the connection */ - if (close) { - err = tcp_close(conn->pcb.tcp); - } else { - err = tcp_shutdown(conn->pcb.tcp, shut_rx, shut_tx); - } - if (err == ERR_OK) { - /* Closing succeeded */ - conn->current_msg->err = ERR_OK; - conn->current_msg = NULL; - conn->state = NETCONN_NONE; - if (close) { - /* Set back some callback pointers as conn is going away */ - conn->pcb.tcp = NULL; - /* Trigger select() in socket layer. Make sure everybody notices activity - on the connection, error first! */ - API_EVENT(conn, NETCONN_EVT_ERROR, 0); - } - if (shut_rx) { - API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0); - } - if (shut_tx) { - API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); - } - /* wake up the application task */ - sys_sem_signal(&conn->op_completed); - } else { - /* Closing failed, restore some of the callbacks */ - /* Closing of listen pcb will never fail! */ - LWIP_ASSERT("Closing a listen pcb may not fail!", (conn->pcb.tcp->state != LISTEN)); - tcp_sent(conn->pcb.tcp, sent_tcp); - tcp_poll(conn->pcb.tcp, poll_tcp, 4); - tcp_err(conn->pcb.tcp, err_tcp); - tcp_arg(conn->pcb.tcp, conn); - /* don't restore recv callback: we don't want to receive any more data */ - } - /* If closing didn't succeed, we get called again either - from poll_tcp or from sent_tcp */ -} -#endif /* LWIP_TCP */ - -/** - * Delete the pcb inside a netconn. - * Called from netconn_delete. - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_delconn(struct api_msg_msg *msg) -{ - /* @todo TCP: abort running write/connect? */ - if ((msg->conn->state != NETCONN_NONE) && - (msg->conn->state != NETCONN_LISTEN) && - (msg->conn->state != NETCONN_CONNECT)) { - /* this only happens for TCP netconns */ - LWIP_ASSERT("msg->conn->type == NETCONN_TCP", msg->conn->type == NETCONN_TCP); - msg->err = ERR_INPROGRESS; - } else { - LWIP_ASSERT("blocking connect in progress", - (msg->conn->state != NETCONN_CONNECT) || IN_NONBLOCKING_CONNECT(msg->conn)); - /* Drain and delete mboxes */ - netconn_drain(msg->conn); - - if (msg->conn->pcb.tcp != NULL) { - - switch (NETCONNTYPE_GROUP(msg->conn->type)) { -#if LWIP_RAW - case NETCONN_RAW: - raw_remove(msg->conn->pcb.raw); - break; -#endif /* LWIP_RAW */ -#if LWIP_UDP - case NETCONN_UDP: - msg->conn->pcb.udp->recv_arg = NULL; - udp_remove(msg->conn->pcb.udp); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case NETCONN_TCP: - LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && - msg->conn->write_offset == 0); - msg->conn->state = NETCONN_CLOSE; - msg->msg.sd.shut = NETCONN_SHUT_RDWR; - msg->conn->current_msg = msg; - do_close_internal(msg->conn); - /* API_EVENT is called inside do_close_internal, before releasing - the application thread, so we can return at this point! */ - return; -#endif /* LWIP_TCP */ - default: - break; - } - msg->conn->pcb.tcp = NULL; - } - /* tcp netconns don't come here! */ - - /* @todo: this lets select make the socket readable and writable, - which is wrong! errfd instead? */ - API_EVENT(msg->conn, NETCONN_EVT_RCVPLUS, 0); - API_EVENT(msg->conn, NETCONN_EVT_SENDPLUS, 0); - } - if (sys_sem_valid(&msg->conn->op_completed)) { - sys_sem_signal(&msg->conn->op_completed); - } -} - -/** - * Bind a pcb contained in a netconn - * Called from netconn_bind. - * - * @param msg the api_msg_msg pointing to the connection and containing - * the IP address and port to bind to - */ -void -do_bind(struct api_msg_msg *msg) -{ - if (ERR_IS_FATAL(msg->conn->last_err)) { - msg->err = msg->conn->last_err; - } else { - msg->err = ERR_VAL; - if (msg->conn->pcb.tcp != NULL) { - switch (NETCONNTYPE_GROUP(msg->conn->type)) { -#if LWIP_RAW - case NETCONN_RAW: - msg->err = raw_bind(msg->conn->pcb.raw, msg->msg.bc.ipaddr); - break; -#endif /* LWIP_RAW */ -#if LWIP_UDP - case NETCONN_UDP: - msg->err = udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case NETCONN_TCP: - msg->err = tcp_bind(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port); - break; -#endif /* LWIP_TCP */ - default: - break; - } - } - } - TCPIP_APIMSG_ACK(msg); -} - -#if LWIP_TCP -/** - * TCP callback function if a connection (opened by tcp_connect/do_connect) has - * been established (or reset by the remote host). - * - * @see tcp.h (struct tcp_pcb.connected) for parameters and return values - */ -static err_t -do_connected(void *arg, struct tcp_pcb *pcb, err_t err) -{ - struct netconn *conn; - int was_blocking; - - LWIP_UNUSED_ARG(pcb); - - conn = (struct netconn *)arg; - - if (conn == NULL) { - return ERR_VAL; - } - - LWIP_ASSERT("conn->state == NETCONN_CONNECT", conn->state == NETCONN_CONNECT); - LWIP_ASSERT("(conn->current_msg != NULL) || conn->in_non_blocking_connect", - (conn->current_msg != NULL) || IN_NONBLOCKING_CONNECT(conn)); - - if (conn->current_msg != NULL) { - conn->current_msg->err = err; - } - if ((conn->type == NETCONN_TCP) && (err == ERR_OK)) { - setup_tcp(conn); - } - was_blocking = !IN_NONBLOCKING_CONNECT(conn); - SET_NONBLOCKING_CONNECT(conn, 0); - conn->current_msg = NULL; - conn->state = NETCONN_NONE; - if (!was_blocking) { - NETCONN_SET_SAFE_ERR(conn, ERR_OK); - } - API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); - - if (was_blocking) { - sys_sem_signal(&conn->op_completed); - } - return ERR_OK; -} -#endif /* LWIP_TCP */ - -/** - * Connect a pcb contained inside a netconn - * Called from netconn_connect. - * - * @param msg the api_msg_msg pointing to the connection and containing - * the IP address and port to connect to - */ -void -do_connect(struct api_msg_msg *msg) -{ - if (msg->conn->pcb.tcp == NULL) { - /* This may happen when calling netconn_connect() a second time */ - msg->err = ERR_CLSD; - } else { - switch (NETCONNTYPE_GROUP(msg->conn->type)) { -#if LWIP_RAW - case NETCONN_RAW: - msg->err = raw_connect(msg->conn->pcb.raw, msg->msg.bc.ipaddr); - break; -#endif /* LWIP_RAW */ -#if LWIP_UDP - case NETCONN_UDP: - msg->err = udp_connect(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case NETCONN_TCP: - /* Prevent connect while doing any other action. */ - if (msg->conn->state != NETCONN_NONE) { - msg->err = ERR_ISCONN; - } else { - setup_tcp(msg->conn); - msg->err = tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, - msg->msg.bc.port, do_connected); - if (msg->err == ERR_OK) { - u8_t non_blocking = netconn_is_nonblocking(msg->conn); - msg->conn->state = NETCONN_CONNECT; - SET_NONBLOCKING_CONNECT(msg->conn, non_blocking); - if (non_blocking) { - msg->err = ERR_INPROGRESS; - } else { - msg->conn->current_msg = msg; - /* sys_sem_signal() is called from do_connected (or err_tcp()), - * when the connection is established! */ - return; - } - } - } - break; -#endif /* LWIP_TCP */ - default: - LWIP_ERROR("Invalid netconn type", 0, do{ msg->err = ERR_VAL; }while(0)); - break; - } - } - sys_sem_signal(&msg->conn->op_completed); -} - -/** - * Connect a pcb contained inside a netconn - * Only used for UDP netconns. - * Called from netconn_disconnect. - * - * @param msg the api_msg_msg pointing to the connection to disconnect - */ -void -do_disconnect(struct api_msg_msg *msg) -{ -#if LWIP_UDP - if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) { - udp_disconnect(msg->conn->pcb.udp); - msg->err = ERR_OK; - } else -#endif /* LWIP_UDP */ - { - msg->err = ERR_VAL; - } - TCPIP_APIMSG_ACK(msg); -} - -#if LWIP_TCP -/** - * Set a TCP pcb contained in a netconn into listen mode - * Called from netconn_listen. - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_listen(struct api_msg_msg *msg) -{ - if (ERR_IS_FATAL(msg->conn->last_err)) { - msg->err = msg->conn->last_err; - } else { - msg->err = ERR_CONN; - if (msg->conn->pcb.tcp != NULL) { - if (msg->conn->type == NETCONN_TCP) { - if (msg->conn->state == NETCONN_NONE) { -#if TCP_LISTEN_BACKLOG - struct tcp_pcb* lpcb = tcp_listen_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog); -#else /* TCP_LISTEN_BACKLOG */ - struct tcp_pcb* lpcb = tcp_listen(msg->conn->pcb.tcp); -#endif /* TCP_LISTEN_BACKLOG */ - if (lpcb == NULL) { - /* in this case, the old pcb is still allocated */ - msg->err = ERR_MEM; - } else { - /* delete the recvmbox and allocate the acceptmbox */ - if (sys_mbox_valid(&msg->conn->recvmbox)) { - /** @todo: should we drain the recvmbox here? */ - sys_mbox_free(&msg->conn->recvmbox); - sys_mbox_set_invalid(&msg->conn->recvmbox); - } - msg->err = ERR_OK; - if (!sys_mbox_valid(&msg->conn->acceptmbox)) { - msg->err = sys_mbox_new(&msg->conn->acceptmbox, DEFAULT_ACCEPTMBOX_SIZE); - } - if (msg->err == ERR_OK) { - msg->conn->state = NETCONN_LISTEN; - msg->conn->pcb.tcp = lpcb; - tcp_arg(msg->conn->pcb.tcp, msg->conn); - tcp_accept(msg->conn->pcb.tcp, accept_function); - } else { - /* since the old pcb is already deallocated, free lpcb now */ - tcp_close(lpcb); - msg->conn->pcb.tcp = NULL; - } - } - } - } else { - msg->err = ERR_ARG; - } - } - } - TCPIP_APIMSG_ACK(msg); -} -#endif /* LWIP_TCP */ - -/** - * Send some data on a RAW or UDP pcb contained in a netconn - * Called from netconn_send - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_send(struct api_msg_msg *msg) -{ - if (ERR_IS_FATAL(msg->conn->last_err)) { - msg->err = msg->conn->last_err; - } else { - msg->err = ERR_CONN; - if (msg->conn->pcb.tcp != NULL) { - switch (NETCONNTYPE_GROUP(msg->conn->type)) { -#if LWIP_RAW - case NETCONN_RAW: - if (ip_addr_isany(&msg->msg.b->addr)) { - msg->err = raw_send(msg->conn->pcb.raw, msg->msg.b->p); - } else { - msg->err = raw_sendto(msg->conn->pcb.raw, msg->msg.b->p, &msg->msg.b->addr); - } - break; -#endif -#if LWIP_UDP - case NETCONN_UDP: -#if LWIP_CHECKSUM_ON_COPY - if (ip_addr_isany(&msg->msg.b->addr)) { - msg->err = udp_send_chksum(msg->conn->pcb.udp, msg->msg.b->p, - msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum); - } else { - msg->err = udp_sendto_chksum(msg->conn->pcb.udp, msg->msg.b->p, - &msg->msg.b->addr, msg->msg.b->port, - msg->msg.b->flags & NETBUF_FLAG_CHKSUM, msg->msg.b->toport_chksum); - } -#else /* LWIP_CHECKSUM_ON_COPY */ - if (ip_addr_isany(&msg->msg.b->addr)) { - msg->err = udp_send(msg->conn->pcb.udp, msg->msg.b->p); - } else { - msg->err = udp_sendto(msg->conn->pcb.udp, msg->msg.b->p, &msg->msg.b->addr, msg->msg.b->port); - } -#endif /* LWIP_CHECKSUM_ON_COPY */ - break; -#endif /* LWIP_UDP */ - default: - break; - } - } - } - TCPIP_APIMSG_ACK(msg); -} - -#if LWIP_TCP -/** - * Indicate data has been received from a TCP pcb contained in a netconn - * Called from netconn_recv - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_recv(struct api_msg_msg *msg) -{ - msg->err = ERR_OK; - if (msg->conn->pcb.tcp != NULL) { - if (msg->conn->type == NETCONN_TCP) { -#if TCP_LISTEN_BACKLOG - if (msg->conn->pcb.tcp->state == LISTEN) { - tcp_accepted(msg->conn->pcb.tcp); - } else -#endif /* TCP_LISTEN_BACKLOG */ - { - u32_t remaining = msg->msg.r.len; - do { - u16_t recved = (remaining > 0xffff) ? 0xffff : (u16_t)remaining; - tcp_recved(msg->conn->pcb.tcp, recved); - remaining -= recved; - }while(remaining != 0); - } - } - } - TCPIP_APIMSG_ACK(msg); -} - -/** - * See if more data needs to be written from a previous call to netconn_write. - * Called initially from do_write. If the first call can't send all data - * (because of low memory or empty send-buffer), this function is called again - * from sent_tcp() or poll_tcp() to send more data. If all data is sent, the - * blocking application thread (waiting in netconn_write) is released. - * - * @param conn netconn (that is currently in state NETCONN_WRITE) to process - * @return ERR_OK - * ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished - */ -static err_t -do_writemore(struct netconn *conn) -{ - err_t err; - void *dataptr; - u16_t len, available; - u8_t write_finished = 0; - size_t diff; - u8_t dontblock = netconn_is_nonblocking(conn) || - (conn->current_msg->msg.w.apiflags & NETCONN_DONTBLOCK); - u8_t apiflags = conn->current_msg->msg.w.apiflags; - - LWIP_ASSERT("conn != NULL", conn != NULL); - LWIP_ASSERT("conn->state == NETCONN_WRITE", (conn->state == NETCONN_WRITE)); - LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL); - LWIP_ASSERT("conn->pcb.tcp != NULL", conn->pcb.tcp != NULL); - LWIP_ASSERT("conn->write_offset < conn->current_msg->msg.w.len", - conn->write_offset < conn->current_msg->msg.w.len); - -#if LWIP_SO_SNDTIMEO - if ((conn->send_timeout != 0) && - ((s32_t)(sys_now() - conn->current_msg->msg.w.time_started) >= conn->send_timeout)) { - write_finished = 1; - if (conn->write_offset == 0) { - /* nothing has been written */ - err = ERR_WOULDBLOCK; - conn->current_msg->msg.w.len = 0; - } else { - /* partial write */ - err = ERR_OK; - conn->current_msg->msg.w.len = conn->write_offset; - } - } else -#endif /* LWIP_SO_SNDTIMEO */ - { - dataptr = (u8_t*)conn->current_msg->msg.w.dataptr + conn->write_offset; - diff = conn->current_msg->msg.w.len - conn->write_offset; - if (diff > 0xffffUL) { /* max_u16_t */ - len = 0xffff; -#if LWIP_TCPIP_CORE_LOCKING - conn->flags |= NETCONN_FLAG_WRITE_DELAYED; -#endif - apiflags |= TCP_WRITE_FLAG_MORE; - } else { - len = (u16_t)diff; - } - available = tcp_sndbuf(conn->pcb.tcp); - if (available < len) { - /* don't try to write more than sendbuf */ - len = available; - if (dontblock){ - if (!len) { - err = ERR_WOULDBLOCK; - goto err_mem; - } - } else { -#if LWIP_TCPIP_CORE_LOCKING - conn->flags |= NETCONN_FLAG_WRITE_DELAYED; -#endif - apiflags |= TCP_WRITE_FLAG_MORE; - } - } - LWIP_ASSERT("do_writemore: invalid length!", ((conn->write_offset + len) <= conn->current_msg->msg.w.len)); - err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags); - /* if OK or memory error, check available space */ - if ((err == ERR_OK) || (err == ERR_MEM)) { -err_mem: - if (dontblock && (len < conn->current_msg->msg.w.len)) { - /* non-blocking write did not write everything: mark the pcb non-writable - and let poll_tcp check writable space to mark the pcb writable again */ - API_EVENT(conn, NETCONN_EVT_SENDMINUS, len); - conn->flags |= NETCONN_FLAG_CHECK_WRITESPACE; - } else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT) || - (tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT)) { - /* The queued byte- or pbuf-count exceeds the configured low-water limit, - let select mark this pcb as non-writable. */ - API_EVENT(conn, NETCONN_EVT_SENDMINUS, len); - } - } - - if (err == ERR_OK) { - conn->write_offset += len; - if ((conn->write_offset == conn->current_msg->msg.w.len) || dontblock) { - /* return sent length */ - conn->current_msg->msg.w.len = conn->write_offset; - /* everything was written */ - write_finished = 1; - conn->write_offset = 0; - } - tcp_output(conn->pcb.tcp); - } else if ((err == ERR_MEM) && !dontblock) { - /* If ERR_MEM, we wait for sent_tcp or poll_tcp to be called - we do NOT return to the application thread, since ERR_MEM is - only a temporary error! */ - - /* tcp_write returned ERR_MEM, try tcp_output anyway */ - tcp_output(conn->pcb.tcp); - -#if LWIP_TCPIP_CORE_LOCKING - conn->flags |= NETCONN_FLAG_WRITE_DELAYED; -#endif - } else { - /* On errors != ERR_MEM, we don't try writing any more but return - the error to the application thread. */ - write_finished = 1; - conn->current_msg->msg.w.len = 0; - } - } - if (write_finished) { - /* everything was written: set back connection state - and back to application task */ - conn->current_msg->err = err; - conn->current_msg = NULL; - conn->state = NETCONN_NONE; -#if LWIP_TCPIP_CORE_LOCKING - if ((conn->flags & NETCONN_FLAG_WRITE_DELAYED) != 0) -#endif - { - sys_sem_signal(&conn->op_completed); - } - } -#if LWIP_TCPIP_CORE_LOCKING - else - return ERR_MEM; -#endif - return ERR_OK; -} -#endif /* LWIP_TCP */ - -/** - * Send some data on a TCP pcb contained in a netconn - * Called from netconn_write - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_write(struct api_msg_msg *msg) -{ - if (ERR_IS_FATAL(msg->conn->last_err)) { - msg->err = msg->conn->last_err; - } else { - if (msg->conn->type == NETCONN_TCP) { -#if LWIP_TCP - if (msg->conn->state != NETCONN_NONE) { - /* netconn is connecting, closing or in blocking write */ - msg->err = ERR_INPROGRESS; - } else if (msg->conn->pcb.tcp != NULL) { - msg->conn->state = NETCONN_WRITE; - /* set all the variables used by do_writemore */ - LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && - msg->conn->write_offset == 0); - LWIP_ASSERT("msg->msg.w.len != 0", msg->msg.w.len != 0); - msg->conn->current_msg = msg; - msg->conn->write_offset = 0; -#if LWIP_TCPIP_CORE_LOCKING - msg->conn->flags &= ~NETCONN_FLAG_WRITE_DELAYED; - if (do_writemore(msg->conn) != ERR_OK) { - LWIP_ASSERT("state!", msg->conn->state == NETCONN_WRITE); - UNLOCK_TCPIP_CORE(); - sys_arch_sem_wait(&msg->conn->op_completed, 0); - LOCK_TCPIP_CORE(); - LWIP_ASSERT("state!", msg->conn->state == NETCONN_NONE); - } -#else /* LWIP_TCPIP_CORE_LOCKING */ - do_writemore(msg->conn); -#endif /* LWIP_TCPIP_CORE_LOCKING */ - /* for both cases: if do_writemore was called, don't ACK the APIMSG - since do_writemore ACKs it! */ - return; - } else { - msg->err = ERR_CONN; - } -#else /* LWIP_TCP */ - msg->err = ERR_VAL; -#endif /* LWIP_TCP */ -#if (LWIP_UDP || LWIP_RAW) - } else { - msg->err = ERR_VAL; -#endif /* (LWIP_UDP || LWIP_RAW) */ - } - } - TCPIP_APIMSG_ACK(msg); -} - -/** - * Return a connection's local or remote address - * Called from netconn_getaddr - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_getaddr(struct api_msg_msg *msg) -{ - if (msg->conn->pcb.ip != NULL) { - *(msg->msg.ad.ipaddr) = (msg->msg.ad.local ? msg->conn->pcb.ip->local_ip : - msg->conn->pcb.ip->remote_ip); - - msg->err = ERR_OK; - switch (NETCONNTYPE_GROUP(msg->conn->type)) { -#if LWIP_RAW - case NETCONN_RAW: - if (msg->msg.ad.local) { - *(msg->msg.ad.port) = msg->conn->pcb.raw->protocol; - } else { - /* return an error as connecting is only a helper for upper layers */ - msg->err = ERR_CONN; - } - break; -#endif /* LWIP_RAW */ -#if LWIP_UDP - case NETCONN_UDP: - if (msg->msg.ad.local) { - *(msg->msg.ad.port) = msg->conn->pcb.udp->local_port; - } else { - if ((msg->conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0) { - msg->err = ERR_CONN; - } else { - *(msg->msg.ad.port) = msg->conn->pcb.udp->remote_port; - } - } - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case NETCONN_TCP: - *(msg->msg.ad.port) = (msg->msg.ad.local?msg->conn->pcb.tcp->local_port:msg->conn->pcb.tcp->remote_port); - break; -#endif /* LWIP_TCP */ - default: - LWIP_ASSERT("invalid netconn_type", 0); - break; - } - } else { - msg->err = ERR_CONN; - } - TCPIP_APIMSG_ACK(msg); -} - -/** - * Close a TCP pcb contained in a netconn - * Called from netconn_close - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_close(struct api_msg_msg *msg) -{ -#if LWIP_TCP - /* @todo: abort running write/connect? */ - if ((msg->conn->state != NETCONN_NONE) && (msg->conn->state != NETCONN_LISTEN)) { - /* this only happens for TCP netconns */ - LWIP_ASSERT("msg->conn->type == NETCONN_TCP", msg->conn->type == NETCONN_TCP); - msg->err = ERR_INPROGRESS; - } else if ((msg->conn->pcb.tcp != NULL) && (msg->conn->type == NETCONN_TCP)) { - if ((msg->msg.sd.shut != NETCONN_SHUT_RDWR) && (msg->conn->state == NETCONN_LISTEN)) { - /* LISTEN doesn't support half shutdown */ - msg->err = ERR_CONN; - } else { - if (msg->msg.sd.shut & NETCONN_SHUT_RD) { - /* Drain and delete mboxes */ - netconn_drain(msg->conn); - } - LWIP_ASSERT("already writing or closing", msg->conn->current_msg == NULL && - msg->conn->write_offset == 0); - msg->conn->state = NETCONN_CLOSE; - msg->conn->current_msg = msg; - do_close_internal(msg->conn); - /* for tcp netconns, do_close_internal ACKs the message */ - return; - } - } else -#endif /* LWIP_TCP */ - { - msg->err = ERR_VAL; - } - sys_sem_signal(&msg->conn->op_completed); -} - -#if LWIP_IGMP -/** - * Join multicast groups for UDP netconns. - * Called from netconn_join_leave_group - * - * @param msg the api_msg_msg pointing to the connection - */ -void -do_join_leave_group(struct api_msg_msg *msg) -{ - if (ERR_IS_FATAL(msg->conn->last_err)) { - msg->err = msg->conn->last_err; - } else { - if (msg->conn->pcb.tcp != NULL) { - if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) { -#if LWIP_UDP - if (msg->msg.jl.join_or_leave == NETCONN_JOIN) { - msg->err = igmp_joingroup(msg->msg.jl.netif_addr, msg->msg.jl.multiaddr); - } else { - msg->err = igmp_leavegroup(msg->msg.jl.netif_addr, msg->msg.jl.multiaddr); - } -#endif /* LWIP_UDP */ -#if (LWIP_TCP || LWIP_RAW) - } else { - msg->err = ERR_VAL; -#endif /* (LWIP_TCP || LWIP_RAW) */ - } - } else { - msg->err = ERR_CONN; - } - } - TCPIP_APIMSG_ACK(msg); -} -#endif /* LWIP_IGMP */ - -#if LWIP_DNS -/** - * Callback function that is called when DNS name is resolved - * (or on timeout). A waiting application thread is waked up by - * signaling the semaphore. - */ -static void -do_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) -{ - struct dns_api_msg *msg = (struct dns_api_msg*)arg; - - LWIP_ASSERT("DNS response for wrong host name", strcmp(msg->name, name) == 0); - LWIP_UNUSED_ARG(name); - - if (ipaddr == NULL) { - /* timeout or memory error */ - *msg->err = ERR_VAL; - } else { - /* address was resolved */ - *msg->err = ERR_OK; - *msg->addr = *ipaddr; - } - /* wake up the application task waiting in netconn_gethostbyname */ - sys_sem_signal(msg->sem); -} - -/** - * Execute a DNS query - * Called from netconn_gethostbyname - * - * @param arg the dns_api_msg pointing to the query - */ -void -do_gethostbyname(void *arg) -{ - struct dns_api_msg *msg = (struct dns_api_msg*)arg; - - *msg->err = dns_gethostbyname(msg->name, msg->addr, do_dns_found, msg); - if (*msg->err != ERR_INPROGRESS) { - /* on error or immediate success, wake up the application - * task waiting in netconn_gethostbyname */ - sys_sem_signal(msg->sem); - } -} -#endif /* LWIP_DNS */ - -#endif /* LWIP_NETCONN */ diff --git a/user/mpy/lib/lwip/src/api/err.c b/user/mpy/lib/lwip/src/api/err.c deleted file mode 100644 index 92fa8b7..0000000 --- a/user/mpy/lib/lwip/src/api/err.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file - * Error Management module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/err.h" - -#ifdef LWIP_DEBUG - -static const char *err_strerr[] = { - "Ok.", /* ERR_OK 0 */ - "Out of memory error.", /* ERR_MEM -1 */ - "Buffer error.", /* ERR_BUF -2 */ - "Timeout.", /* ERR_TIMEOUT -3 */ - "Routing problem.", /* ERR_RTE -4 */ - "Operation in progress.", /* ERR_INPROGRESS -5 */ - "Illegal value.", /* ERR_VAL -6 */ - "Operation would block.", /* ERR_WOULDBLOCK -7 */ - "Address in use.", /* ERR_USE -8 */ - "Already connected.", /* ERR_ISCONN -9 */ - "Connection aborted.", /* ERR_ABRT -10 */ - "Connection reset.", /* ERR_RST -11 */ - "Connection closed.", /* ERR_CLSD -12 */ - "Not connected.", /* ERR_CONN -13 */ - "Illegal argument.", /* ERR_ARG -14 */ - "Low-level netif error.", /* ERR_IF -15 */ -}; - -/** - * Convert an lwip internal error to a string representation. - * - * @param err an lwip internal err_t - * @return a string representation for err - */ -const char * -lwip_strerr(err_t err) -{ - return err_strerr[-err]; - -} - -#endif /* LWIP_DEBUG */ diff --git a/user/mpy/lib/lwip/src/api/netbuf.c b/user/mpy/lib/lwip/src/api/netbuf.c deleted file mode 100644 index 9390c9e..0000000 --- a/user/mpy/lib/lwip/src/api/netbuf.c +++ /dev/null @@ -1,245 +0,0 @@ -/** - * @file - * Network buffer management - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/netbuf.h" -#include "lwip/memp.h" - -#include - -/** - * Create (allocate) and initialize a new netbuf. - * The netbuf doesn't yet contain a packet buffer! - * - * @return a pointer to a new netbuf - * NULL on lack of memory - */ -struct -netbuf *netbuf_new(void) -{ - struct netbuf *buf; - - buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); - if (buf != NULL) { - buf->p = NULL; - buf->ptr = NULL; - ip_addr_set_any(&buf->addr); - buf->port = 0; -#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY -#if LWIP_CHECKSUM_ON_COPY - buf->flags = 0; -#endif /* LWIP_CHECKSUM_ON_COPY */ - buf->toport_chksum = 0; -#if LWIP_NETBUF_RECVINFO - ip_addr_set_any(&buf->toaddr); -#endif /* LWIP_NETBUF_RECVINFO */ -#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ - return buf; - } else { - return NULL; - } -} - -/** - * Deallocate a netbuf allocated by netbuf_new(). - * - * @param buf pointer to a netbuf allocated by netbuf_new() - */ -void -netbuf_delete(struct netbuf *buf) -{ - if (buf != NULL) { - if (buf->p != NULL) { - pbuf_free(buf->p); - buf->p = buf->ptr = NULL; - } - memp_free(MEMP_NETBUF, buf); - } -} - -/** - * Allocate memory for a packet buffer for a given netbuf. - * - * @param buf the netbuf for which to allocate a packet buffer - * @param size the size of the packet buffer to allocate - * @return pointer to the allocated memory - * NULL if no memory could be allocated - */ -void * -netbuf_alloc(struct netbuf *buf, u16_t size) -{ - LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;); - - /* Deallocate any previously allocated memory. */ - if (buf->p != NULL) { - pbuf_free(buf->p); - } - buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM); - if (buf->p == NULL) { - return NULL; - } - LWIP_ASSERT("check that first pbuf can hold size", - (buf->p->len >= size)); - buf->ptr = buf->p; - return buf->p->payload; -} - -/** - * Free the packet buffer included in a netbuf - * - * @param buf pointer to the netbuf which contains the packet buffer to free - */ -void -netbuf_free(struct netbuf *buf) -{ - LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); - if (buf->p != NULL) { - pbuf_free(buf->p); - } - buf->p = buf->ptr = NULL; -} - -/** - * Let a netbuf reference existing (non-volatile) data. - * - * @param buf netbuf which should reference the data - * @param dataptr pointer to the data to reference - * @param size size of the data - * @return ERR_OK if data is referenced - * ERR_MEM if data couldn't be referenced due to lack of memory - */ -err_t -netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size) -{ - LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;); - if (buf->p != NULL) { - pbuf_free(buf->p); - } - buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF); - if (buf->p == NULL) { - buf->ptr = NULL; - return ERR_MEM; - } - buf->p->payload = (void*)dataptr; - buf->p->len = buf->p->tot_len = size; - buf->ptr = buf->p; - return ERR_OK; -} - -/** - * Chain one netbuf to another (@see pbuf_chain) - * - * @param head the first netbuf - * @param tail netbuf to chain after head, freed by this function, may not be reference after returning - */ -void -netbuf_chain(struct netbuf *head, struct netbuf *tail) -{ - LWIP_ERROR("netbuf_ref: invalid head", (head != NULL), return;); - LWIP_ERROR("netbuf_chain: invalid tail", (tail != NULL), return;); - pbuf_cat(head->p, tail->p); - head->ptr = head->p; - memp_free(MEMP_NETBUF, tail); -} - -/** - * Get the data pointer and length of the data inside a netbuf. - * - * @param buf netbuf to get the data from - * @param dataptr pointer to a void pointer where to store the data pointer - * @param len pointer to an u16_t where the length of the data is stored - * @return ERR_OK if the information was retreived, - * ERR_BUF on error. - */ -err_t -netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len) -{ - LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;); - LWIP_ERROR("netbuf_data: invalid dataptr", (dataptr != NULL), return ERR_ARG;); - LWIP_ERROR("netbuf_data: invalid len", (len != NULL), return ERR_ARG;); - - if (buf->ptr == NULL) { - return ERR_BUF; - } - *dataptr = buf->ptr->payload; - *len = buf->ptr->len; - return ERR_OK; -} - -/** - * Move the current data pointer of a packet buffer contained in a netbuf - * to the next part. - * The packet buffer itself is not modified. - * - * @param buf the netbuf to modify - * @return -1 if there is no next part - * 1 if moved to the next part but now there is no next part - * 0 if moved to the next part and there are still more parts - */ -s8_t -netbuf_next(struct netbuf *buf) -{ - LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return -1;); - if (buf->ptr->next == NULL) { - return -1; - } - buf->ptr = buf->ptr->next; - if (buf->ptr->next == NULL) { - return 1; - } - return 0; -} - -/** - * Move the current data pointer of a packet buffer contained in a netbuf - * to the beginning of the packet. - * The packet buffer itself is not modified. - * - * @param buf the netbuf to modify - */ -void -netbuf_first(struct netbuf *buf) -{ - LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); - buf->ptr = buf->p; -} - -#endif /* LWIP_NETCONN */ diff --git a/user/mpy/lib/lwip/src/api/netdb.c b/user/mpy/lib/lwip/src/api/netdb.c deleted file mode 100644 index 6a4bac5..0000000 --- a/user/mpy/lib/lwip/src/api/netdb.c +++ /dev/null @@ -1,353 +0,0 @@ -/** - * @file - * API functions for name resolving - * - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ - -#include "lwip/netdb.h" - -#if LWIP_DNS && LWIP_SOCKET - -#include "lwip/err.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/ip_addr.h" -#include "lwip/api.h" -#include "lwip/dns.h" - -#include -#include - -/** helper struct for gethostbyname_r to access the char* buffer */ -struct gethostbyname_r_helper { - ip_addr_t *addr_list[2]; - ip_addr_t addr; - char *aliases; -}; - -/** h_errno is exported in netdb.h for access by applications. */ -#if LWIP_DNS_API_DECLARE_H_ERRNO -int h_errno; -#endif /* LWIP_DNS_API_DECLARE_H_ERRNO */ - -/** define "hostent" variables storage: 0 if we use a static (but unprotected) - * set of variables for lwip_gethostbyname, 1 if we use a local storage */ -#ifndef LWIP_DNS_API_HOSTENT_STORAGE -#define LWIP_DNS_API_HOSTENT_STORAGE 0 -#endif - -/** define "hostent" variables storage */ -#if LWIP_DNS_API_HOSTENT_STORAGE -#define HOSTENT_STORAGE -#else -#define HOSTENT_STORAGE static -#endif /* LWIP_DNS_API_STATIC_HOSTENT */ - -/** - * Returns an entry containing addresses of address family AF_INET - * for the host with name name. - * Due to dns_gethostbyname limitations, only one address is returned. - * - * @param name the hostname to resolve - * @return an entry containing addresses of address family AF_INET - * for the host with name name - */ -struct hostent* -lwip_gethostbyname(const char *name) -{ - err_t err; - ip_addr_t addr; - - /* buffer variables for lwip_gethostbyname() */ - HOSTENT_STORAGE struct hostent s_hostent; - HOSTENT_STORAGE char *s_aliases; - HOSTENT_STORAGE ip_addr_t s_hostent_addr; - HOSTENT_STORAGE ip_addr_t *s_phostent_addr[2]; - - /* query host IP address */ - err = netconn_gethostbyname(name, &addr); - if (err != ERR_OK) { - LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err)); - h_errno = HOST_NOT_FOUND; - return NULL; - } - - /* fill hostent */ - s_hostent_addr = addr; - s_phostent_addr[0] = &s_hostent_addr; - s_phostent_addr[1] = NULL; - s_hostent.h_name = (char*)name; - s_hostent.h_aliases = &s_aliases; - s_hostent.h_addrtype = AF_INET; - s_hostent.h_length = sizeof(ip_addr_t); - s_hostent.h_addr_list = (char**)&s_phostent_addr; - -#if DNS_DEBUG - /* dump hostent */ - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_name == %s\n", s_hostent.h_name)); - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases == %p\n", s_hostent.h_aliases)); - if (s_hostent.h_aliases != NULL) { - u8_t idx; - for ( idx=0; s_hostent.h_aliases[idx]; idx++) { - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]-> == %p\n", idx, s_hostent.h_aliases[idx])); - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]-> == %s\n", idx, s_hostent.h_aliases[idx])); - } - } - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addrtype == %d\n", s_hostent.h_addrtype)); - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_length == %d\n", s_hostent.h_length)); - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list == %p\n", s_hostent.h_addr_list)); - if (s_hostent.h_addr_list != NULL) { - u8_t idx; - for ( idx=0; s_hostent.h_addr_list[idx]; idx++) { - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i] == %p\n", idx, s_hostent.h_addr_list[idx])); - LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ip_ntoa((ip_addr_t*)s_hostent.h_addr_list[idx]))); - } - } -#endif /* DNS_DEBUG */ - -#if LWIP_DNS_API_HOSTENT_STORAGE - /* this function should return the "per-thread" hostent after copy from s_hostent */ - return sys_thread_hostent(&s_hostent); -#else - return &s_hostent; -#endif /* LWIP_DNS_API_HOSTENT_STORAGE */ -} - -/** - * Thread-safe variant of lwip_gethostbyname: instead of using a static - * buffer, this function takes buffer and errno pointers as arguments - * and uses these for the result. - * - * @param name the hostname to resolve - * @param ret pre-allocated struct where to store the result - * @param buf pre-allocated buffer where to store additional data - * @param buflen the size of buf - * @param result pointer to a hostent pointer that is set to ret on success - * and set to zero on error - * @param h_errnop pointer to an int where to store errors (instead of modifying - * the global h_errno) - * @return 0 on success, non-zero on error, additional error information - * is stored in *h_errnop instead of h_errno to be thread-safe - */ -int -lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, - size_t buflen, struct hostent **result, int *h_errnop) -{ - err_t err; - struct gethostbyname_r_helper *h; - char *hostname; - size_t namelen; - int lh_errno; - - if (h_errnop == NULL) { - /* ensure h_errnop is never NULL */ - h_errnop = &lh_errno; - } - - if (result == NULL) { - /* not all arguments given */ - *h_errnop = EINVAL; - return -1; - } - /* first thing to do: set *result to nothing */ - *result = NULL; - if ((name == NULL) || (ret == NULL) || (buf == NULL)) { - /* not all arguments given */ - *h_errnop = EINVAL; - return -1; - } - - namelen = strlen(name); - if (buflen < (sizeof(struct gethostbyname_r_helper) + namelen + 1 + (MEM_ALIGNMENT - 1))) { - /* buf can't hold the data needed + a copy of name */ - *h_errnop = ERANGE; - return -1; - } - - h = (struct gethostbyname_r_helper*)LWIP_MEM_ALIGN(buf); - hostname = ((char*)h) + sizeof(struct gethostbyname_r_helper); - - /* query host IP address */ - err = netconn_gethostbyname(name, &h->addr); - if (err != ERR_OK) { - LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err)); - *h_errnop = HOST_NOT_FOUND; - return -1; - } - - /* copy the hostname into buf */ - MEMCPY(hostname, name, namelen); - hostname[namelen] = 0; - - /* fill hostent */ - h->addr_list[0] = &h->addr; - h->addr_list[1] = NULL; - h->aliases = NULL; - ret->h_name = hostname; - ret->h_aliases = &h->aliases; - ret->h_addrtype = AF_INET; - ret->h_length = sizeof(ip_addr_t); - ret->h_addr_list = (char**)&h->addr_list; - - /* set result != NULL */ - *result = ret; - - /* return success */ - return 0; -} - -/** - * Frees one or more addrinfo structures returned by getaddrinfo(), along with - * any additional storage associated with those structures. If the ai_next field - * of the structure is not null, the entire list of structures is freed. - * - * @param ai struct addrinfo to free - */ -void -lwip_freeaddrinfo(struct addrinfo *ai) -{ - struct addrinfo *next; - - while (ai != NULL) { - next = ai->ai_next; - memp_free(MEMP_NETDB, ai); - ai = next; - } -} - -/** - * Translates the name of a service location (for example, a host name) and/or - * a service name and returns a set of socket addresses and associated - * information to be used in creating a socket with which to address the - * specified service. - * Memory for the result is allocated internally and must be freed by calling - * lwip_freeaddrinfo()! - * - * Due to a limitation in dns_gethostbyname, only the first address of a - * host is returned. - * Also, service names are not supported (only port numbers)! - * - * @param nodename descriptive name or address string of the host - * (may be NULL -> local address) - * @param servname port number as string of NULL - * @param hints structure containing input values that set socktype and protocol - * @param res pointer to a pointer where to store the result (set to NULL on failure) - * @return 0 on success, non-zero on failure - */ -int -lwip_getaddrinfo(const char *nodename, const char *servname, - const struct addrinfo *hints, struct addrinfo **res) -{ - err_t err; - ip_addr_t addr; - struct addrinfo *ai; - struct sockaddr_in *sa = NULL; - int port_nr = 0; - size_t total_size; - size_t namelen = 0; - - if (res == NULL) { - return EAI_FAIL; - } - *res = NULL; - if ((nodename == NULL) && (servname == NULL)) { - return EAI_NONAME; - } - - if (servname != NULL) { - /* service name specified: convert to port number - * @todo?: currently, only ASCII integers (port numbers) are supported! */ - port_nr = atoi(servname); - if ((port_nr <= 0) || (port_nr > 0xffff)) { - return EAI_SERVICE; - } - } - - if (nodename != NULL) { - /* service location specified, try to resolve */ - err = netconn_gethostbyname(nodename, &addr); - if (err != ERR_OK) { - return EAI_FAIL; - } - } else { - /* service location specified, use loopback address */ - ip_addr_set_loopback(&addr); - } - - total_size = sizeof(struct addrinfo) + sizeof(struct sockaddr_in); - if (nodename != NULL) { - namelen = strlen(nodename); - LWIP_ASSERT("namelen is too long", (namelen + 1) <= (mem_size_t)-1); - total_size += namelen + 1; - } - /* If this fails, please report to lwip-devel! :-) */ - LWIP_ASSERT("total_size <= NETDB_ELEM_SIZE: please report this!", - total_size <= NETDB_ELEM_SIZE); - ai = (struct addrinfo *)memp_malloc(MEMP_NETDB); - if (ai == NULL) { - goto memerr; - } - memset(ai, 0, total_size); - sa = (struct sockaddr_in*)((u8_t*)ai + sizeof(struct addrinfo)); - /* set up sockaddr */ - inet_addr_from_ipaddr(&sa->sin_addr, &addr); - sa->sin_family = AF_INET; - sa->sin_len = sizeof(struct sockaddr_in); - sa->sin_port = htons((u16_t)port_nr); - - /* set up addrinfo */ - ai->ai_family = AF_INET; - if (hints != NULL) { - /* copy socktype & protocol from hints if specified */ - ai->ai_socktype = hints->ai_socktype; - ai->ai_protocol = hints->ai_protocol; - } - if (nodename != NULL) { - /* copy nodename to canonname if specified */ - ai->ai_canonname = ((char*)ai + sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); - MEMCPY(ai->ai_canonname, nodename, namelen); - ai->ai_canonname[namelen] = 0; - } - ai->ai_addrlen = sizeof(struct sockaddr_in); - ai->ai_addr = (struct sockaddr*)sa; - - *res = ai; - - return 0; -memerr: - if (ai != NULL) { - memp_free(MEMP_NETDB, ai); - } - return EAI_MEMORY; -} - -#endif /* LWIP_DNS && LWIP_SOCKET */ diff --git a/user/mpy/lib/lwip/src/api/netifapi.c b/user/mpy/lib/lwip/src/api/netifapi.c deleted file mode 100644 index 43e4720..0000000 --- a/user/mpy/lib/lwip/src/api/netifapi.c +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @file - * Network Interface Sequential API module - * - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "lwip/opt.h" - -#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/netifapi.h" -#include "lwip/tcpip.h" - -/** - * Call netif_add() inside the tcpip_thread context. - */ -void -do_netifapi_netif_add(struct netifapi_msg_msg *msg) -{ - if (!netif_add( msg->netif, - msg->msg.add.ipaddr, - msg->msg.add.netmask, - msg->msg.add.gw, - msg->msg.add.state, - msg->msg.add.init, - msg->msg.add.input)) { - msg->err = ERR_IF; - } else { - msg->err = ERR_OK; - } - TCPIP_NETIFAPI_ACK(msg); -} - -/** - * Call netif_set_addr() inside the tcpip_thread context. - */ -void -do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg) -{ - netif_set_addr( msg->netif, - msg->msg.add.ipaddr, - msg->msg.add.netmask, - msg->msg.add.gw); - msg->err = ERR_OK; - TCPIP_NETIFAPI_ACK(msg); -} - -/** - * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the - * tcpip_thread context. - */ -void -do_netifapi_netif_common(struct netifapi_msg_msg *msg) -{ - if (msg->msg.common.errtfunc != NULL) { - msg->err = msg->msg.common.errtfunc(msg->netif); - } else { - msg->err = ERR_OK; - msg->msg.common.voidfunc(msg->netif); - } - TCPIP_NETIFAPI_ACK(msg); -} - -/** - * Call netif_add() in a thread-safe way by running that function inside the - * tcpip_thread context. - * - * @note for params @see netif_add() - */ -err_t -netifapi_netif_add(struct netif *netif, - ip_addr_t *ipaddr, - ip_addr_t *netmask, - ip_addr_t *gw, - void *state, - netif_init_fn init, - netif_input_fn input) -{ - struct netifapi_msg msg; - msg.function = do_netifapi_netif_add; - msg.msg.netif = netif; - msg.msg.msg.add.ipaddr = ipaddr; - msg.msg.msg.add.netmask = netmask; - msg.msg.msg.add.gw = gw; - msg.msg.msg.add.state = state; - msg.msg.msg.add.init = init; - msg.msg.msg.add.input = input; - TCPIP_NETIFAPI(&msg); - return msg.msg.err; -} - -/** - * Call netif_set_addr() in a thread-safe way by running that function inside the - * tcpip_thread context. - * - * @note for params @see netif_set_addr() - */ -err_t -netifapi_netif_set_addr(struct netif *netif, - ip_addr_t *ipaddr, - ip_addr_t *netmask, - ip_addr_t *gw) -{ - struct netifapi_msg msg; - msg.function = do_netifapi_netif_set_addr; - msg.msg.netif = netif; - msg.msg.msg.add.ipaddr = ipaddr; - msg.msg.msg.add.netmask = netmask; - msg.msg.msg.add.gw = gw; - TCPIP_NETIFAPI(&msg); - return msg.msg.err; -} - -/** - * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe - * way by running that function inside the tcpip_thread context. - * - * @note use only for functions where there is only "netif" parameter. - */ -err_t -netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc, - netifapi_errt_fn errtfunc) -{ - struct netifapi_msg msg; - msg.function = do_netifapi_netif_common; - msg.msg.netif = netif; - msg.msg.msg.common.voidfunc = voidfunc; - msg.msg.msg.common.errtfunc = errtfunc; - TCPIP_NETIFAPI(&msg); - return msg.msg.err; -} - -#endif /* LWIP_NETIF_API */ diff --git a/user/mpy/lib/lwip/src/api/sockets.c b/user/mpy/lib/lwip/src/api/sockets.c deleted file mode 100644 index 359919e..0000000 --- a/user/mpy/lib/lwip/src/api/sockets.c +++ /dev/null @@ -1,2374 +0,0 @@ -/** - * @file - * Sockets BSD-Like API module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - * Improved by Marc Boucher and David Haas - * - */ - -#include "lwip/opt.h" - -#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/sockets.h" -#include "lwip/api.h" -#include "lwip/sys.h" -#include "lwip/igmp.h" -#include "lwip/inet.h" -#include "lwip/tcp.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcpip.h" -#include "lwip/pbuf.h" -#if LWIP_CHECKSUM_ON_COPY -#include "lwip/inet_chksum.h" -#endif - -#include - -#define NUM_SOCKETS MEMP_NUM_NETCONN - -/** Contains all internal pointers and states used for a socket */ -struct lwip_sock { - /** sockets currently are built on netconns, each socket has one netconn */ - struct netconn *conn; - /** data that was left from the previous read */ - void *lastdata; - /** offset in the data that was left from the previous read */ - u16_t lastoffset; - /** number of times data was received, set by event_callback(), - tested by the receive and select functions */ - s16_t rcvevent; - /** number of times data was ACKed (free send buffer), set by event_callback(), - tested by select */ - u16_t sendevent; - /** error happened for this socket, set by event_callback(), tested by select */ - u16_t errevent; - /** last error that occurred on this socket */ - int err; - /** counter of how many threads are waiting for this socket using select */ - int select_waiting; -}; - -/** Description for a task waiting in select */ -struct lwip_select_cb { - /** Pointer to the next waiting task */ - struct lwip_select_cb *next; - /** Pointer to the previous waiting task */ - struct lwip_select_cb *prev; - /** readset passed to select */ - fd_set *readset; - /** writeset passed to select */ - fd_set *writeset; - /** unimplemented: exceptset passed to select */ - fd_set *exceptset; - /** don't signal the same semaphore twice: set to 1 when signalled */ - int sem_signalled; - /** semaphore to wake up a task waiting for select */ - sys_sem_t sem; -}; - -/** This struct is used to pass data to the set/getsockopt_internal - * functions running in tcpip_thread context (only a void* is allowed) */ -struct lwip_setgetsockopt_data { - /** socket struct for which to change options */ - struct lwip_sock *sock; -#ifdef LWIP_DEBUG - /** socket index for which to change options */ - int s; -#endif /* LWIP_DEBUG */ - /** level of the option to process */ - int level; - /** name of the option to process */ - int optname; - /** set: value to set the option to - * get: value of the option is stored here */ - void *optval; - /** size of *optval */ - socklen_t *optlen; - /** if an error occures, it is temporarily stored here */ - err_t err; -}; - -/** The global array of available sockets */ -static struct lwip_sock sockets[NUM_SOCKETS]; -/** The global list of tasks waiting for select */ -static struct lwip_select_cb *select_cb_list; -/** This counter is increased from lwip_select when the list is chagned - and checked in event_callback to see if it has changed. */ -static volatile int select_cb_ctr; - -/** Table to quickly map an lwIP error (err_t) to a socket error - * by using -err as an index */ -static const int err_to_errno_table[] = { - 0, /* ERR_OK 0 No error, everything OK. */ - ENOMEM, /* ERR_MEM -1 Out of memory error. */ - ENOBUFS, /* ERR_BUF -2 Buffer error. */ - EWOULDBLOCK, /* ERR_TIMEOUT -3 Timeout */ - EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ - EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ - EINVAL, /* ERR_VAL -6 Illegal value. */ - EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ - EADDRINUSE, /* ERR_USE -8 Address in use. */ - EALREADY, /* ERR_ISCONN -9 Already connected. */ - ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */ - ECONNRESET, /* ERR_RST -11 Connection reset. */ - ENOTCONN, /* ERR_CLSD -12 Connection closed. */ - ENOTCONN, /* ERR_CONN -13 Not connected. */ - EIO, /* ERR_ARG -14 Illegal argument. */ - -1, /* ERR_IF -15 Low-level netif error */ -}; - -#define ERR_TO_ERRNO_TABLE_SIZE \ - (sizeof(err_to_errno_table)/sizeof(err_to_errno_table[0])) - -#define err_to_errno(err) \ - ((unsigned)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ? \ - err_to_errno_table[-(err)] : EIO) - -#ifdef ERRNO -#ifndef set_errno -#define set_errno(err) errno = (err) -#endif -#else /* ERRNO */ -#define set_errno(err) -#endif /* ERRNO */ - -#define sock_set_errno(sk, e) do { \ - sk->err = (e); \ - set_errno(sk->err); \ -} while (0) - -/* Forward delcaration of some functions */ -static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len); -static void lwip_getsockopt_internal(void *arg); -static void lwip_setsockopt_internal(void *arg); - -/** - * Initialize this module. This function has to be called before any other - * functions in this module! - */ -void -lwip_socket_init(void) -{ -} - -/** - * Map a externally used socket index to the internal socket representation. - * - * @param s externally used socket index - * @return struct lwip_sock for the socket or NULL if not found - */ -static struct lwip_sock * -get_socket(int s) -{ - struct lwip_sock *sock; - - if ((s < 0) || (s >= NUM_SOCKETS)) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s)); - set_errno(EBADF); - return NULL; - } - - sock = &sockets[s]; - - if (!sock->conn) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s)); - set_errno(EBADF); - return NULL; - } - - return sock; -} - -/** - * Same as get_socket but doesn't set errno - * - * @param s externally used socket index - * @return struct lwip_sock for the socket or NULL if not found - */ -static struct lwip_sock * -tryget_socket(int s) -{ - if ((s < 0) || (s >= NUM_SOCKETS)) { - return NULL; - } - if (!sockets[s].conn) { - return NULL; - } - return &sockets[s]; -} - -/** - * Allocate a new socket for a given netconn. - * - * @param newconn the netconn for which to allocate a socket - * @param accepted 1 if socket has been created by accept(), - * 0 if socket has been created by socket() - * @return the index of the new socket; -1 on error - */ -static int -alloc_socket(struct netconn *newconn, int accepted) -{ - int i; - SYS_ARCH_DECL_PROTECT(lev); - - /* allocate a new socket identifier */ - for (i = 0; i < NUM_SOCKETS; ++i) { - /* Protect socket array */ - SYS_ARCH_PROTECT(lev); - if (!sockets[i].conn) { - sockets[i].conn = newconn; - /* The socket is not yet known to anyone, so no need to protect - after having marked it as used. */ - SYS_ARCH_UNPROTECT(lev); - sockets[i].lastdata = NULL; - sockets[i].lastoffset = 0; - sockets[i].rcvevent = 0; - /* TCP sendbuf is empty, but the socket is not yet writable until connected - * (unless it has been created by accept()). */ - sockets[i].sendevent = (newconn->type == NETCONN_TCP ? (accepted != 0) : 1); - sockets[i].errevent = 0; - sockets[i].err = 0; - sockets[i].select_waiting = 0; - return i; - } - SYS_ARCH_UNPROTECT(lev); - } - return -1; -} - -/** Free a socket. The socket's netconn must have been - * delete before! - * - * @param sock the socket to free - * @param is_tcp != 0 for TCP sockets, used to free lastdata - */ -static void -free_socket(struct lwip_sock *sock, int is_tcp) -{ - void *lastdata; - SYS_ARCH_DECL_PROTECT(lev); - - lastdata = sock->lastdata; - sock->lastdata = NULL; - sock->lastoffset = 0; - sock->err = 0; - - /* Protect socket array */ - SYS_ARCH_PROTECT(lev); - sock->conn = NULL; - SYS_ARCH_UNPROTECT(lev); - /* don't use 'sock' after this line, as another task might have allocated it */ - - if (lastdata != NULL) { - if (is_tcp) { - pbuf_free((struct pbuf *)lastdata); - } else { - netbuf_delete((struct netbuf *)lastdata); - } - } -} - -/* Below this, the well-known socket functions are implemented. - * Use google.com or opengroup.org to get a good description :-) - * - * Exceptions are documented! - */ - -int -lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) -{ - struct lwip_sock *sock, *nsock; - struct netconn *newconn; - ip_addr_t naddr; - u16_t port; - int newsock; - struct sockaddr_in sin; - err_t err; - SYS_ARCH_DECL_PROTECT(lev); - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s)); - sock = get_socket(s); - if (!sock) { - return -1; - } - - if (netconn_is_nonblocking(sock->conn) && (sock->rcvevent <= 0)) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): returning EWOULDBLOCK\n", s)); - sock_set_errno(sock, EWOULDBLOCK); - return -1; - } - - /* wait for a new connection */ - err = netconn_accept(sock->conn, &newconn); - if (err != ERR_OK) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_acept failed, err=%d\n", s, err)); - if (netconn_type(sock->conn) != NETCONN_TCP) { - sock_set_errno(sock, EOPNOTSUPP); - return EOPNOTSUPP; - } - sock_set_errno(sock, err_to_errno(err)); - return -1; - } - LWIP_ASSERT("newconn != NULL", newconn != NULL); - /* Prevent automatic window updates, we do this on our own! */ - netconn_set_noautorecved(newconn, 1); - - /* get the IP address and port of the remote host */ - err = netconn_peer(newconn, &naddr, &port); - if (err != ERR_OK) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err)); - netconn_delete(newconn); - sock_set_errno(sock, err_to_errno(err)); - return -1; - } - - /* Note that POSIX only requires us to check addr is non-NULL. addrlen must - * not be NULL if addr is valid. - */ - if (NULL != addr) { - LWIP_ASSERT("addr valid but addrlen NULL", addrlen != NULL); - memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_port = htons(port); - inet_addr_from_ipaddr(&sin.sin_addr, &naddr); - - if (*addrlen > sizeof(sin)) - *addrlen = sizeof(sin); - - MEMCPY(addr, &sin, *addrlen); - } - - newsock = alloc_socket(newconn, 1); - if (newsock == -1) { - netconn_delete(newconn); - sock_set_errno(sock, ENFILE); - return -1; - } - LWIP_ASSERT("invalid socket index", (newsock >= 0) && (newsock < NUM_SOCKETS)); - LWIP_ASSERT("newconn->callback == event_callback", newconn->callback == event_callback); - nsock = &sockets[newsock]; - - /* See event_callback: If data comes in right away after an accept, even - * though the server task might not have created a new socket yet. - * In that case, newconn->socket is counted down (newconn->socket--), - * so nsock->rcvevent is >= 1 here! - */ - SYS_ARCH_PROTECT(lev); - nsock->rcvevent += (s16_t)(-1 - newconn->socket); - newconn->socket = newsock; - SYS_ARCH_UNPROTECT(lev); - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); - ip_addr_debug_print(SOCKETS_DEBUG, &naddr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", port)); - - sock_set_errno(sock, 0); - return newsock; -} - -int -lwip_bind(int s, const struct sockaddr *name, socklen_t namelen) -{ - struct lwip_sock *sock; - ip_addr_t local_addr; - u16_t local_port; - err_t err; - const struct sockaddr_in *name_in; - - sock = get_socket(s); - if (!sock) { - return -1; - } - - /* check size, familiy and alignment of 'name' */ - LWIP_ERROR("lwip_bind: invalid address", ((namelen == sizeof(struct sockaddr_in)) && - ((name->sa_family) == AF_INET) && ((((mem_ptr_t)name) % 4) == 0)), - sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); - name_in = (const struct sockaddr_in *)(void*)name; - - inet_addr_to_ipaddr(&local_addr, &name_in->sin_addr); - local_port = name_in->sin_port; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s)); - ip_addr_debug_print(SOCKETS_DEBUG, &local_addr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", ntohs(local_port))); - - err = netconn_bind(sock->conn, &local_addr, ntohs(local_port)); - - if (err != ERR_OK) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err)); - sock_set_errno(sock, err_to_errno(err)); - return -1; - } - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s)); - sock_set_errno(sock, 0); - return 0; -} - -int -lwip_close(int s) -{ - struct lwip_sock *sock; - int is_tcp = 0; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s)); - - sock = get_socket(s); - if (!sock) { - return -1; - } - - if(sock->conn != NULL) { - is_tcp = netconn_type(sock->conn) == NETCONN_TCP; - } else { - LWIP_ASSERT("sock->lastdata == NULL", sock->lastdata == NULL); - } - - netconn_delete(sock->conn); - - free_socket(sock, is_tcp); - set_errno(0); - return 0; -} - -int -lwip_connect(int s, const struct sockaddr *name, socklen_t namelen) -{ - struct lwip_sock *sock; - err_t err; - const struct sockaddr_in *name_in; - - sock = get_socket(s); - if (!sock) { - return -1; - } - - /* check size, familiy and alignment of 'name' */ - LWIP_ERROR("lwip_connect: invalid address", ((namelen == sizeof(struct sockaddr_in)) && - ((name->sa_family) == AF_INET) && ((((mem_ptr_t)name) % 4) == 0)), - sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); - name_in = (const struct sockaddr_in *)(void*)name; - - if (name_in->sin_family == AF_UNSPEC) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); - err = netconn_disconnect(sock->conn); - } else { - ip_addr_t remote_addr; - u16_t remote_port; - - inet_addr_to_ipaddr(&remote_addr, &name_in->sin_addr); - remote_port = name_in->sin_port; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); - ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", ntohs(remote_port))); - - err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); - } - - if (err != ERR_OK) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err)); - sock_set_errno(sock, err_to_errno(err)); - return -1; - } - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s)); - sock_set_errno(sock, 0); - return 0; -} - -/** - * Set a socket into listen mode. - * The socket may not have been used for another connection previously. - * - * @param s the socket to set to listening mode - * @param backlog (ATTENTION: needs TCP_LISTEN_BACKLOG=1) - * @return 0 on success, non-zero on failure - */ -int -lwip_listen(int s, int backlog) -{ - struct lwip_sock *sock; - err_t err; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog)); - - sock = get_socket(s); - if (!sock) { - return -1; - } - - /* limit the "backlog" parameter to fit in an u8_t */ - backlog = LWIP_MIN(LWIP_MAX(backlog, 0), 0xff); - - err = netconn_listen_with_backlog(sock->conn, (u8_t)backlog); - - if (err != ERR_OK) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); - if (netconn_type(sock->conn) != NETCONN_TCP) { - sock_set_errno(sock, EOPNOTSUPP); - return EOPNOTSUPP; - } - sock_set_errno(sock, err_to_errno(err)); - return -1; - } - - sock_set_errno(sock, 0); - return 0; -} - -int -lwip_recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen) -{ - struct lwip_sock *sock; - void *buf = NULL; - struct pbuf *p; - u16_t buflen, copylen; - int off = 0; - ip_addr_t *addr; - u16_t port; - u8_t done = 0; - err_t err; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %"SZT_F", 0x%x, ..)\n", s, mem, len, flags)); - sock = get_socket(s); - if (!sock) { - return -1; - } - - do { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: top while sock->lastdata=%p\n", sock->lastdata)); - /* Check if there is data left from the last recv operation. */ - if (sock->lastdata) { - buf = sock->lastdata; - } else { - /* If this is non-blocking call, then check first */ - if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) && - (sock->rcvevent <= 0)) { - if (off > 0) { - /* update receive window */ - netconn_recved(sock->conn, (u32_t)off); - /* already received data, return that */ - sock_set_errno(sock, 0); - return off; - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s)); - sock_set_errno(sock, EWOULDBLOCK); - return -1; - } - - /* No data was left from the previous operation, so we try to get - some from the network. */ - if (netconn_type(sock->conn) == NETCONN_TCP) { - err = netconn_recv_tcp_pbuf(sock->conn, (struct pbuf **)&buf); - } else { - err = netconn_recv(sock->conn, (struct netbuf **)&buf); - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: netconn_recv err=%d, netbuf=%p\n", - err, buf)); - - if (err != ERR_OK) { - if (off > 0) { - /* update receive window */ - netconn_recved(sock->conn, (u32_t)off); - /* already received data, return that */ - sock_set_errno(sock, 0); - return off; - } - /* We should really do some error checking here. */ - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL, error is \"%s\"!\n", - s, lwip_strerr(err))); - sock_set_errno(sock, err_to_errno(err)); - if (err == ERR_CLSD) { - return 0; - } else { - return -1; - } - } - LWIP_ASSERT("buf != NULL", buf != NULL); - sock->lastdata = buf; - } - - if (netconn_type(sock->conn) == NETCONN_TCP) { - p = (struct pbuf *)buf; - } else { - p = ((struct netbuf *)buf)->p; - } - buflen = p->tot_len; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: buflen=%"U16_F" len=%"SZT_F" off=%d sock->lastoffset=%"U16_F"\n", - buflen, len, off, sock->lastoffset)); - - buflen -= sock->lastoffset; - - if (len > buflen) { - copylen = buflen; - } else { - copylen = (u16_t)len; - } - - /* copy the contents of the received buffer into - the supplied memory pointer mem */ - pbuf_copy_partial(p, (u8_t*)mem + off, copylen, sock->lastoffset); - - off += copylen; - - if (netconn_type(sock->conn) == NETCONN_TCP) { - LWIP_ASSERT("invalid copylen, len would underflow", len >= copylen); - len -= copylen; - if ( (len <= 0) || - (p->flags & PBUF_FLAG_PUSH) || - (sock->rcvevent <= 0) || - ((flags & MSG_PEEK)!=0)) { - done = 1; - } - } else { - done = 1; - } - - /* Check to see from where the data was.*/ - if (done) { - ip_addr_t fromaddr; - if (from && fromlen) { - struct sockaddr_in sin; - - if (netconn_type(sock->conn) == NETCONN_TCP) { - addr = &fromaddr; - netconn_getaddr(sock->conn, addr, &port, 0); - } else { - addr = netbuf_fromaddr((struct netbuf *)buf); - port = netbuf_fromport((struct netbuf *)buf); - } - - memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_port = htons(port); - inet_addr_from_ipaddr(&sin.sin_addr, addr); - - if (*fromlen > sizeof(sin)) { - *fromlen = sizeof(sin); - } - - MEMCPY(from, &sin, *fromlen); - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); - ip_addr_debug_print(SOCKETS_DEBUG, addr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off)); - } else { -#if SOCKETS_DEBUG - if (netconn_type(sock->conn) == NETCONN_TCP) { - addr = &fromaddr; - netconn_getaddr(sock->conn, addr, &port, 0); - } else { - addr = netbuf_fromaddr((struct netbuf *)buf); - port = netbuf_fromport((struct netbuf *)buf); - } - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); - ip_addr_debug_print(SOCKETS_DEBUG, addr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off)); -#endif /* SOCKETS_DEBUG */ - } - } - - /* If we don't peek the incoming message... */ - if ((flags & MSG_PEEK) == 0) { - /* If this is a TCP socket, check if there is data left in the - buffer. If so, it should be saved in the sock structure for next - time around. */ - if ((netconn_type(sock->conn) == NETCONN_TCP) && (buflen - copylen > 0)) { - sock->lastdata = buf; - sock->lastoffset += copylen; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: lastdata now netbuf=%p\n", buf)); - } else { - sock->lastdata = NULL; - sock->lastoffset = 0; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: deleting netbuf=%p\n", buf)); - if (netconn_type(sock->conn) == NETCONN_TCP) { - pbuf_free((struct pbuf *)buf); - } else { - netbuf_delete((struct netbuf *)buf); - } - } - } - } while (!done); - - if (off > 0) { - /* update receive window */ - netconn_recved(sock->conn, (u32_t)off); - } - sock_set_errno(sock, 0); - return off; -} - -int -lwip_read(int s, void *mem, size_t len) -{ - return lwip_recvfrom(s, mem, len, 0, NULL, NULL); -} - -int -lwip_recv(int s, void *mem, size_t len, int flags) -{ - return lwip_recvfrom(s, mem, len, flags, NULL, NULL); -} - -int -lwip_send(int s, const void *data, size_t size, int flags) -{ - struct lwip_sock *sock; - err_t err; - u8_t write_flags; - size_t written; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%"SZT_F", flags=0x%x)\n", - s, data, size, flags)); - - sock = get_socket(s); - if (!sock) { - return -1; - } - - if (sock->conn->type != NETCONN_TCP) { -#if (LWIP_UDP || LWIP_RAW) - return lwip_sendto(s, data, size, flags, NULL, 0); -#else /* (LWIP_UDP || LWIP_RAW) */ - sock_set_errno(sock, err_to_errno(ERR_ARG)); - return -1; -#endif /* (LWIP_UDP || LWIP_RAW) */ - } - - write_flags = NETCONN_COPY | - ((flags & MSG_MORE) ? NETCONN_MORE : 0) | - ((flags & MSG_DONTWAIT) ? NETCONN_DONTBLOCK : 0); - written = 0; - err = netconn_write_partly(sock->conn, data, size, write_flags, &written); - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d written=%"SZT_F"\n", s, err, written)); - sock_set_errno(sock, err_to_errno(err)); - return (err == ERR_OK ? (int)written : -1); -} - -int -lwip_sendto(int s, const void *data, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen) -{ - struct lwip_sock *sock; - err_t err; - u16_t short_size; - const struct sockaddr_in *to_in; - u16_t remote_port; -#if !LWIP_TCPIP_CORE_LOCKING - struct netbuf buf; -#endif - - sock = get_socket(s); - if (!sock) { - return -1; - } - - if (sock->conn->type == NETCONN_TCP) { -#if LWIP_TCP - return lwip_send(s, data, size, flags); -#else /* LWIP_TCP */ - LWIP_UNUSED_ARG(flags); - sock_set_errno(sock, err_to_errno(ERR_ARG)); - return -1; -#endif /* LWIP_TCP */ - } - - /* @todo: split into multiple sendto's? */ - LWIP_ASSERT("lwip_sendto: size must fit in u16_t", size <= 0xffff); - short_size = (u16_t)size; - LWIP_ERROR("lwip_sendto: invalid address", (((to == NULL) && (tolen == 0)) || - ((tolen == sizeof(struct sockaddr_in)) && - ((to->sa_family) == AF_INET) && ((((mem_ptr_t)to) % 4) == 0))), - sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); - to_in = (const struct sockaddr_in *)(void*)to; - -#if LWIP_TCPIP_CORE_LOCKING - /* Should only be consider like a sample or a simple way to experiment this option (no check of "to" field...) */ - { - struct pbuf* p; - ip_addr_t *remote_addr; - -#if LWIP_NETIF_TX_SINGLE_PBUF - p = pbuf_alloc(PBUF_TRANSPORT, short_size, PBUF_RAM); - if (p != NULL) { -#if LWIP_CHECKSUM_ON_COPY - u16_t chksum = 0; - if (sock->conn->type != NETCONN_RAW) { - chksum = LWIP_CHKSUM_COPY(p->payload, data, short_size); - } else -#endif /* LWIP_CHECKSUM_ON_COPY */ - MEMCPY(p->payload, data, size); -#else /* LWIP_NETIF_TX_SINGLE_PBUF */ - p = pbuf_alloc(PBUF_TRANSPORT, short_size, PBUF_REF); - if (p != NULL) { - p->payload = (void*)data; -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - - if (to_in != NULL) { - inet_addr_to_ipaddr_p(remote_addr, &to_in->sin_addr); - remote_port = ntohs(to_in->sin_port); - } else { - remote_addr = &sock->conn->pcb.ip->remote_ip; -#if LWIP_UDP - if (NETCONNTYPE_GROUP(sock->conn->type) == NETCONN_UDP) { - remote_port = sock->conn->pcb.udp->remote_port; - } else -#endif /* LWIP_UDP */ - { - remote_port = 0; - } - } - - LOCK_TCPIP_CORE(); - if (netconn_type(sock->conn) == NETCONN_RAW) { -#if LWIP_RAW - err = sock->conn->last_err = raw_sendto(sock->conn->pcb.raw, p, remote_addr); -#else /* LWIP_RAW */ - err = ERR_ARG; -#endif /* LWIP_RAW */ - } -#if LWIP_UDP && LWIP_RAW - else -#endif /* LWIP_UDP && LWIP_RAW */ - { -#if LWIP_UDP -#if LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF - err = sock->conn->last_err = udp_sendto_chksum(sock->conn->pcb.udp, p, - remote_addr, remote_port, 1, chksum); -#else /* LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF */ - err = sock->conn->last_err = udp_sendto(sock->conn->pcb.udp, p, - remote_addr, remote_port); -#endif /* LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF */ -#else /* LWIP_UDP */ - err = ERR_ARG; -#endif /* LWIP_UDP */ - } - UNLOCK_TCPIP_CORE(); - - pbuf_free(p); - } else { - err = ERR_MEM; - } - } -#else /* LWIP_TCPIP_CORE_LOCKING */ - /* initialize a buffer */ - buf.p = buf.ptr = NULL; -#if LWIP_CHECKSUM_ON_COPY - buf.flags = 0; -#endif /* LWIP_CHECKSUM_ON_COPY */ - if (to) { - inet_addr_to_ipaddr(&buf.addr, &to_in->sin_addr); - remote_port = ntohs(to_in->sin_port); - netbuf_fromport(&buf) = remote_port; - } else { - remote_port = 0; - ip_addr_set_any(&buf.addr); - netbuf_fromport(&buf) = 0; - } - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, short_size=%"U16_F", flags=0x%x to=", - s, data, short_size, flags)); - ip_addr_debug_print(SOCKETS_DEBUG, &buf.addr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", remote_port)); - - /* make the buffer point to the data that should be sent */ -#if LWIP_NETIF_TX_SINGLE_PBUF - /* Allocate a new netbuf and copy the data into it. */ - if (netbuf_alloc(&buf, short_size) == NULL) { - err = ERR_MEM; - } else { -#if LWIP_CHECKSUM_ON_COPY - if (sock->conn->type != NETCONN_RAW) { - u16_t chksum = LWIP_CHKSUM_COPY(buf.p->payload, data, short_size); - netbuf_set_chksum(&buf, chksum); - err = ERR_OK; - } else -#endif /* LWIP_CHECKSUM_ON_COPY */ - { - err = netbuf_take(&buf, data, short_size); - } - } -#else /* LWIP_NETIF_TX_SINGLE_PBUF */ - err = netbuf_ref(&buf, data, short_size); -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - if (err == ERR_OK) { - /* send the data */ - err = netconn_send(sock->conn, &buf); - } - - /* deallocated the buffer */ - netbuf_free(&buf); -#endif /* LWIP_TCPIP_CORE_LOCKING */ - sock_set_errno(sock, err_to_errno(err)); - return (err == ERR_OK ? short_size : -1); -} - -int -lwip_socket(int domain, int type, int protocol) -{ - struct netconn *conn; - int i; - - LWIP_UNUSED_ARG(domain); - - /* create a netconn */ - switch (type) { - case SOCK_RAW: - conn = netconn_new_with_proto_and_callback(NETCONN_RAW, (u8_t)protocol, event_callback); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %d) = ", - domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); - break; - case SOCK_DGRAM: - conn = netconn_new_with_callback( (protocol == IPPROTO_UDPLITE) ? - NETCONN_UDPLITE : NETCONN_UDP, event_callback); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", - domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); - break; - case SOCK_STREAM: - conn = netconn_new_with_callback(NETCONN_TCP, event_callback); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", - domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); - if (conn != NULL) { - /* Prevent automatic window updates, we do this on our own! */ - netconn_set_noautorecved(conn, 1); - } - break; - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", - domain, type, protocol)); - set_errno(EINVAL); - return -1; - } - - if (!conn) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n")); - set_errno(ENOBUFS); - return -1; - } - - i = alloc_socket(conn, 0); - - if (i == -1) { - netconn_delete(conn); - set_errno(ENFILE); - return -1; - } - conn->socket = i; - LWIP_DEBUGF(SOCKETS_DEBUG, ("%d\n", i)); - set_errno(0); - return i; -} - -int -lwip_write(int s, const void *data, size_t size) -{ - return lwip_send(s, data, size, 0); -} - -/** - * Go through the readset and writeset lists and see which socket of the sockets - * set in the sets has events. On return, readset, writeset and exceptset have - * the sockets enabled that had events. - * - * exceptset is not used for now!!! - * - * @param maxfdp1 the highest socket index in the sets - * @param readset_in: set of sockets to check for read events - * @param writeset_in: set of sockets to check for write events - * @param exceptset_in: set of sockets to check for error events - * @param readset_out: set of sockets that had read events - * @param writeset_out: set of sockets that had write events - * @param exceptset_out: set os sockets that had error events - * @return number of sockets that had events (read/write/exception) (>= 0) - */ -static int -lwip_selscan(int maxfdp1, fd_set *readset_in, fd_set *writeset_in, fd_set *exceptset_in, - fd_set *readset_out, fd_set *writeset_out, fd_set *exceptset_out) -{ - int i, nready = 0; - fd_set lreadset, lwriteset, lexceptset; - struct lwip_sock *sock; - SYS_ARCH_DECL_PROTECT(lev); - - FD_ZERO(&lreadset); - FD_ZERO(&lwriteset); - FD_ZERO(&lexceptset); - - /* Go through each socket in each list to count number of sockets which - currently match */ - for(i = 0; i < maxfdp1; i++) { - void* lastdata = NULL; - s16_t rcvevent = 0; - u16_t sendevent = 0; - u16_t errevent = 0; - /* First get the socket's status (protected)... */ - SYS_ARCH_PROTECT(lev); - sock = tryget_socket(i); - if (sock != NULL) { - lastdata = sock->lastdata; - rcvevent = sock->rcvevent; - sendevent = sock->sendevent; - errevent = sock->errevent; - } - SYS_ARCH_UNPROTECT(lev); - /* ... then examine it: */ - /* See if netconn of this socket is ready for read */ - if (readset_in && FD_ISSET(i, readset_in) && ((lastdata != NULL) || (rcvevent > 0))) { - FD_SET(i, &lreadset); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i)); - nready++; - } - /* See if netconn of this socket is ready for write */ - if (writeset_in && FD_ISSET(i, writeset_in) && (sendevent != 0)) { - FD_SET(i, &lwriteset); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i)); - nready++; - } - /* See if netconn of this socket had an error */ - if (exceptset_in && FD_ISSET(i, exceptset_in) && (errevent != 0)) { - FD_SET(i, &lexceptset); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for exception\n", i)); - nready++; - } - } - /* copy local sets to the ones provided as arguments */ - *readset_out = lreadset; - *writeset_out = lwriteset; - *exceptset_out = lexceptset; - - LWIP_ASSERT("nready >= 0", nready >= 0); - return nready; -} - -/** - * Processing exceptset is not yet implemented. - */ -int -lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, - struct timeval *timeout) -{ - u32_t waitres = 0; - int nready; - fd_set lreadset, lwriteset, lexceptset; - u32_t msectimeout; - struct lwip_select_cb select_cb; - err_t err; - int i; - SYS_ARCH_DECL_PROTECT(lev); - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%"S32_F" tvusec=%"S32_F")\n", - maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, - timeout ? (s32_t)timeout->tv_sec : (s32_t)-1, - timeout ? (s32_t)timeout->tv_usec : (s32_t)-1)); - - /* Go through each socket in each list to count number of sockets which - currently match */ - nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); - - /* If we don't have any current events, then suspend if we are supposed to */ - if (!nready) { - if (timeout && timeout->tv_sec == 0 && timeout->tv_usec == 0) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n")); - /* This is OK as the local fdsets are empty and nready is zero, - or we would have returned earlier. */ - goto return_copy_fdsets; - } - - /* None ready: add our semaphore to list: - We don't actually need any dynamic memory. Our entry on the - list is only valid while we are in this function, so it's ok - to use local variables. */ - - select_cb.next = NULL; - select_cb.prev = NULL; - select_cb.readset = readset; - select_cb.writeset = writeset; - select_cb.exceptset = exceptset; - select_cb.sem_signalled = 0; - err = sys_sem_new(&select_cb.sem, 0); - if (err != ERR_OK) { - /* failed to create semaphore */ - set_errno(ENOMEM); - return -1; - } - - /* Protect the select_cb_list */ - SYS_ARCH_PROTECT(lev); - - /* Put this select_cb on top of list */ - select_cb.next = select_cb_list; - if (select_cb_list != NULL) { - select_cb_list->prev = &select_cb; - } - select_cb_list = &select_cb; - /* Increasing this counter tells even_callback that the list has changed. */ - select_cb_ctr++; - - /* Now we can safely unprotect */ - SYS_ARCH_UNPROTECT(lev); - - /* Increase select_waiting for each socket we are interested in */ - for(i = 0; i < maxfdp1; i++) { - if ((readset && FD_ISSET(i, readset)) || - (writeset && FD_ISSET(i, writeset)) || - (exceptset && FD_ISSET(i, exceptset))) { - struct lwip_sock *sock = tryget_socket(i); - LWIP_ASSERT("sock != NULL", sock != NULL); - SYS_ARCH_PROTECT(lev); - sock->select_waiting++; - LWIP_ASSERT("sock->select_waiting > 0", sock->select_waiting > 0); - SYS_ARCH_UNPROTECT(lev); - } - } - - /* Call lwip_selscan again: there could have been events between - the last scan (whithout us on the list) and putting us on the list! */ - nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); - if (!nready) { - /* Still none ready, just wait to be woken */ - if (timeout == 0) { - /* Wait forever */ - msectimeout = 0; - } else { - msectimeout = ((timeout->tv_sec * 1000) + ((timeout->tv_usec + 500)/1000)); - if (msectimeout == 0) { - /* Wait 1ms at least (0 means wait forever) */ - msectimeout = 1; - } - } - - waitres = sys_arch_sem_wait(&select_cb.sem, msectimeout); - } - /* Increase select_waiting for each socket we are interested in */ - for(i = 0; i < maxfdp1; i++) { - if ((readset && FD_ISSET(i, readset)) || - (writeset && FD_ISSET(i, writeset)) || - (exceptset && FD_ISSET(i, exceptset))) { - struct lwip_sock *sock = tryget_socket(i); - LWIP_ASSERT("sock != NULL", sock != NULL); - SYS_ARCH_PROTECT(lev); - sock->select_waiting--; - LWIP_ASSERT("sock->select_waiting >= 0", sock->select_waiting >= 0); - SYS_ARCH_UNPROTECT(lev); - } - } - /* Take us off the list */ - SYS_ARCH_PROTECT(lev); - if (select_cb.next != NULL) { - select_cb.next->prev = select_cb.prev; - } - if (select_cb_list == &select_cb) { - LWIP_ASSERT("select_cb.prev == NULL", select_cb.prev == NULL); - select_cb_list = select_cb.next; - } else { - LWIP_ASSERT("select_cb.prev != NULL", select_cb.prev != NULL); - select_cb.prev->next = select_cb.next; - } - /* Increasing this counter tells even_callback that the list has changed. */ - select_cb_ctr++; - SYS_ARCH_UNPROTECT(lev); - - sys_sem_free(&select_cb.sem); - if (waitres == SYS_ARCH_TIMEOUT) { - /* Timeout */ - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n")); - /* This is OK as the local fdsets are empty and nready is zero, - or we would have returned earlier. */ - goto return_copy_fdsets; - } - - /* See what's set */ - nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); - } - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready)); -return_copy_fdsets: - set_errno(0); - if (readset) { - *readset = lreadset; - } - if (writeset) { - *writeset = lwriteset; - } - if (exceptset) { - *exceptset = lexceptset; - } - - - return nready; -} - -/** - * Callback registered in the netconn layer for each socket-netconn. - * Processes recvevent (data available) and wakes up tasks waiting for select. - */ -static void -event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) -{ - int s; - struct lwip_sock *sock; - struct lwip_select_cb *scb; - int last_select_cb_ctr; - SYS_ARCH_DECL_PROTECT(lev); - - LWIP_UNUSED_ARG(len); - - /* Get socket */ - if (conn) { - s = conn->socket; - if (s < 0) { - /* Data comes in right away after an accept, even though - * the server task might not have created a new socket yet. - * Just count down (or up) if that's the case and we - * will use the data later. Note that only receive events - * can happen before the new socket is set up. */ - SYS_ARCH_PROTECT(lev); - if (conn->socket < 0) { - if (evt == NETCONN_EVT_RCVPLUS) { - conn->socket--; - } - SYS_ARCH_UNPROTECT(lev); - return; - } - s = conn->socket; - SYS_ARCH_UNPROTECT(lev); - } - - sock = get_socket(s); - if (!sock) { - return; - } - } else { - return; - } - - SYS_ARCH_PROTECT(lev); - /* Set event as required */ - switch (evt) { - case NETCONN_EVT_RCVPLUS: - sock->rcvevent++; - break; - case NETCONN_EVT_RCVMINUS: - sock->rcvevent--; - break; - case NETCONN_EVT_SENDPLUS: - sock->sendevent = 1; - break; - case NETCONN_EVT_SENDMINUS: - sock->sendevent = 0; - break; - case NETCONN_EVT_ERROR: - sock->errevent = 1; - break; - default: - LWIP_ASSERT("unknown event", 0); - break; - } - - if (sock->select_waiting == 0) { - /* noone is waiting for this socket, no need to check select_cb_list */ - SYS_ARCH_UNPROTECT(lev); - return; - } - - /* Now decide if anyone is waiting for this socket */ - /* NOTE: This code goes through the select_cb_list list multiple times - ONLY IF a select was actually waiting. We go through the list the number - of waiting select calls + 1. This list is expected to be small. */ - - /* At this point, SYS_ARCH is still protected! */ -again: - for (scb = select_cb_list; scb != NULL; scb = scb->next) { - if (scb->sem_signalled == 0) { - /* semaphore not signalled yet */ - int do_signal = 0; - /* Test this select call for our socket */ - if (sock->rcvevent > 0) { - if (scb->readset && FD_ISSET(s, scb->readset)) { - do_signal = 1; - } - } - if (sock->sendevent != 0) { - if (!do_signal && scb->writeset && FD_ISSET(s, scb->writeset)) { - do_signal = 1; - } - } - if (sock->errevent != 0) { - if (!do_signal && scb->exceptset && FD_ISSET(s, scb->exceptset)) { - do_signal = 1; - } - } - if (do_signal) { - scb->sem_signalled = 1; - /* Don't call SYS_ARCH_UNPROTECT() before signaling the semaphore, as this might - lead to the select thread taking itself off the list, invalidagin the semaphore. */ - sys_sem_signal(&scb->sem); - } - } - /* unlock interrupts with each step */ - last_select_cb_ctr = select_cb_ctr; - SYS_ARCH_UNPROTECT(lev); - /* this makes sure interrupt protection time is short */ - SYS_ARCH_PROTECT(lev); - if (last_select_cb_ctr != select_cb_ctr) { - /* someone has changed select_cb_list, restart at the beginning */ - goto again; - } - } - SYS_ARCH_UNPROTECT(lev); -} - -/** - * Unimplemented: Close one end of a full-duplex connection. - * Currently, the full connection is closed. - */ -int -lwip_shutdown(int s, int how) -{ - struct lwip_sock *sock; - err_t err; - u8_t shut_rx = 0, shut_tx = 0; - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how)); - - sock = get_socket(s); - if (!sock) { - return -1; - } - - if (sock->conn != NULL) { - if (netconn_type(sock->conn) != NETCONN_TCP) { - sock_set_errno(sock, EOPNOTSUPP); - return EOPNOTSUPP; - } - } else { - sock_set_errno(sock, ENOTCONN); - return ENOTCONN; - } - - if (how == SHUT_RD) { - shut_rx = 1; - } else if (how == SHUT_WR) { - shut_tx = 1; - } else if(how == SHUT_RDWR) { - shut_rx = 1; - shut_tx = 1; - } else { - sock_set_errno(sock, EINVAL); - return EINVAL; - } - err = netconn_shutdown(sock->conn, shut_rx, shut_tx); - - sock_set_errno(sock, err_to_errno(err)); - return (err == ERR_OK ? 0 : -1); -} - -static int -lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local) -{ - struct lwip_sock *sock; - struct sockaddr_in sin; - ip_addr_t naddr; - - sock = get_socket(s); - if (!sock) { - return -1; - } - - memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - - /* get the IP address and port */ - netconn_getaddr(sock->conn, &naddr, &sin.sin_port, local); - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s)); - ip_addr_debug_print(SOCKETS_DEBUG, &naddr); - LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", sin.sin_port)); - - sin.sin_port = htons(sin.sin_port); - inet_addr_from_ipaddr(&sin.sin_addr, &naddr); - - if (*namelen > sizeof(sin)) { - *namelen = sizeof(sin); - } - - MEMCPY(name, &sin, *namelen); - sock_set_errno(sock, 0); - return 0; -} - -int -lwip_getpeername(int s, struct sockaddr *name, socklen_t *namelen) -{ - return lwip_getaddrname(s, name, namelen, 0); -} - -int -lwip_getsockname(int s, struct sockaddr *name, socklen_t *namelen) -{ - return lwip_getaddrname(s, name, namelen, 1); -} - -int -lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) -{ - err_t err = ERR_OK; - struct lwip_sock *sock = get_socket(s); - struct lwip_setgetsockopt_data data; - - if (!sock) { - return -1; - } - - if ((NULL == optval) || (NULL == optlen)) { - sock_set_errno(sock, EFAULT); - return -1; - } - - /* Do length and type checks for the various options first, to keep it readable. */ - switch (level) { - -/* Level: SOL_SOCKET */ - case SOL_SOCKET: - switch (optname) { - - case SO_ACCEPTCONN: - case SO_BROADCAST: - /* UNIMPL case SO_DEBUG: */ - /* UNIMPL case SO_DONTROUTE: */ - case SO_ERROR: - case SO_KEEPALIVE: - /* UNIMPL case SO_CONTIMEO: */ -#if LWIP_SO_SNDTIMEO - case SO_SNDTIMEO: -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO - case SO_RCVTIMEO: -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - case SO_RCVBUF: -#endif /* LWIP_SO_RCVBUF */ - /* UNIMPL case SO_OOBINLINE: */ - /* UNIMPL case SO_SNDBUF: */ - /* UNIMPL case SO_RCVLOWAT: */ - /* UNIMPL case SO_SNDLOWAT: */ -#if SO_REUSE - case SO_REUSEADDR: - case SO_REUSEPORT: -#endif /* SO_REUSE */ - case SO_TYPE: - /* UNIMPL case SO_USELOOPBACK: */ - if (*optlen < sizeof(int)) { - err = EINVAL; - } - break; - - case SO_NO_CHECK: - if (*optlen < sizeof(int)) { - err = EINVAL; - } -#if LWIP_UDP - if ((sock->conn->type != NETCONN_UDP) || - ((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_UDPLITE) != 0)) { - /* this flag is only available for UDP, not for UDP lite */ - err = EAFNOSUPPORT; - } -#endif /* LWIP_UDP */ - break; - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; - -/* Level: IPPROTO_IP */ - case IPPROTO_IP: - switch (optname) { - /* UNIMPL case IP_HDRINCL: */ - /* UNIMPL case IP_RCVDSTADDR: */ - /* UNIMPL case IP_RCVIF: */ - case IP_TTL: - case IP_TOS: - if (*optlen < sizeof(int)) { - err = EINVAL; - } - break; -#if LWIP_IGMP - case IP_MULTICAST_TTL: - if (*optlen < sizeof(u8_t)) { - err = EINVAL; - } - break; - case IP_MULTICAST_IF: - if (*optlen < sizeof(struct in_addr)) { - err = EINVAL; - } - break; - case IP_MULTICAST_LOOP: - if (*optlen < sizeof(u8_t)) { - err = EINVAL; - } - if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { - err = EAFNOSUPPORT; - } - break; -#endif /* LWIP_IGMP */ - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; - -#if LWIP_TCP -/* Level: IPPROTO_TCP */ - case IPPROTO_TCP: - if (*optlen < sizeof(int)) { - err = EINVAL; - break; - } - - /* If this is no TCP socket, ignore any options. */ - if (sock->conn->type != NETCONN_TCP) - return 0; - - switch (optname) { - case TCP_NODELAY: - case TCP_KEEPALIVE: -#if LWIP_TCP_KEEPALIVE - case TCP_KEEPIDLE: - case TCP_KEEPINTVL: - case TCP_KEEPCNT: -#endif /* LWIP_TCP_KEEPALIVE */ - break; - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; -#endif /* LWIP_TCP */ -#if LWIP_UDP && LWIP_UDPLITE -/* Level: IPPROTO_UDPLITE */ - case IPPROTO_UDPLITE: - if (*optlen < sizeof(int)) { - err = EINVAL; - break; - } - - /* If this is no UDP lite socket, ignore any options. */ - if (sock->conn->type != NETCONN_UDPLITE) { - return 0; - } - - switch (optname) { - case UDPLITE_SEND_CSCOV: - case UDPLITE_RECV_CSCOV: - break; - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; -#endif /* LWIP_UDP && LWIP_UDPLITE*/ -/* UNDEFINED LEVEL */ - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", - s, level, optname)); - err = ENOPROTOOPT; - } /* switch */ - - - if (err != ERR_OK) { - sock_set_errno(sock, err); - return -1; - } - - /* Now do the actual option processing */ - data.sock = sock; -#ifdef LWIP_DEBUG - data.s = s; -#endif /* LWIP_DEBUG */ - data.level = level; - data.optname = optname; - data.optval = optval; - data.optlen = optlen; - data.err = err; - tcpip_callback(lwip_getsockopt_internal, &data); - sys_arch_sem_wait(&sock->conn->op_completed, 0); - /* maybe lwip_getsockopt_internal has changed err */ - err = data.err; - - sock_set_errno(sock, err); - return err ? -1 : 0; -} - -static void -lwip_getsockopt_internal(void *arg) -{ - struct lwip_sock *sock; -#ifdef LWIP_DEBUG - int s; -#endif /* LWIP_DEBUG */ - int level, optname; - void *optval; - struct lwip_setgetsockopt_data *data; - - LWIP_ASSERT("arg != NULL", arg != NULL); - - data = (struct lwip_setgetsockopt_data*)arg; - sock = data->sock; -#ifdef LWIP_DEBUG - s = data->s; -#endif /* LWIP_DEBUG */ - level = data->level; - optname = data->optname; - optval = data->optval; - - switch (level) { - -/* Level: SOL_SOCKET */ - case SOL_SOCKET: - switch (optname) { - - /* The option flags */ - case SO_ACCEPTCONN: - case SO_BROADCAST: - /* UNIMPL case SO_DEBUG: */ - /* UNIMPL case SO_DONTROUTE: */ - case SO_KEEPALIVE: - /* UNIMPL case SO_OOBINCLUDE: */ -#if SO_REUSE - case SO_REUSEADDR: - case SO_REUSEPORT: -#endif /* SO_REUSE */ - /*case SO_USELOOPBACK: UNIMPL */ - *(int*)optval = ip_get_option(sock->conn->pcb.ip, optname); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, optname=0x%x, ..) = %s\n", - s, optname, (*(int*)optval?"on":"off"))); - break; - - case SO_TYPE: - switch (NETCONNTYPE_GROUP(sock->conn->type)) { - case NETCONN_RAW: - *(int*)optval = SOCK_RAW; - break; - case NETCONN_TCP: - *(int*)optval = SOCK_STREAM; - break; - case NETCONN_UDP: - *(int*)optval = SOCK_DGRAM; - break; - default: /* unrecognized socket type */ - *(int*)optval = sock->conn->type; - LWIP_DEBUGF(SOCKETS_DEBUG, - ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE): unrecognized socket type %d\n", - s, *(int *)optval)); - } /* switch (sock->conn->type) */ - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE) = %d\n", - s, *(int *)optval)); - break; - - case SO_ERROR: - /* only overwrite ERR_OK or tempoary errors */ - if ((sock->err == 0) || (sock->err == EINPROGRESS)) { - sock_set_errno(sock, err_to_errno(sock->conn->last_err)); - } - *(int *)optval = sock->err; - sock->err = 0; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", - s, *(int *)optval)); - break; - -#if LWIP_SO_SNDTIMEO - case SO_SNDTIMEO: - *(int *)optval = netconn_get_sendtimeout(sock->conn); - break; -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO - case SO_RCVTIMEO: - *(int *)optval = netconn_get_recvtimeout(sock->conn); - break; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - case SO_RCVBUF: - *(int *)optval = netconn_get_recvbufsize(sock->conn); - break; -#endif /* LWIP_SO_RCVBUF */ -#if LWIP_UDP - case SO_NO_CHECK: - *(int*)optval = (udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_NOCHKSUM) ? 1 : 0; - break; -#endif /* LWIP_UDP*/ - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; - -/* Level: IPPROTO_IP */ - case IPPROTO_IP: - switch (optname) { - case IP_TTL: - *(int*)optval = sock->conn->pcb.ip->ttl; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TTL) = %d\n", - s, *(int *)optval)); - break; - case IP_TOS: - *(int*)optval = sock->conn->pcb.ip->tos; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TOS) = %d\n", - s, *(int *)optval)); - break; -#if LWIP_IGMP - case IP_MULTICAST_TTL: - *(u8_t*)optval = sock->conn->pcb.ip->ttl; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_TTL) = %d\n", - s, *(int *)optval)); - break; - case IP_MULTICAST_IF: - inet_addr_from_ipaddr((struct in_addr*)optval, &sock->conn->pcb.udp->multicast_ip); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_IF) = 0x%"X32_F"\n", - s, *(u32_t *)optval)); - break; - case IP_MULTICAST_LOOP: - if ((sock->conn->pcb.udp->flags & UDP_FLAGS_MULTICAST_LOOP) != 0) { - *(u8_t*)optval = 1; - } else { - *(u8_t*)optval = 0; - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_LOOP) = %d\n", - s, *(int *)optval)); - break; -#endif /* LWIP_IGMP */ - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; - -#if LWIP_TCP -/* Level: IPPROTO_TCP */ - case IPPROTO_TCP: - switch (optname) { - case TCP_NODELAY: - *(int*)optval = tcp_nagle_disabled(sock->conn->pcb.tcp); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, TCP_NODELAY) = %s\n", - s, (*(int*)optval)?"on":"off") ); - break; - case TCP_KEEPALIVE: - *(int*)optval = (int)sock->conn->pcb.tcp->keep_idle; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPALIVE) = %d\n", - s, *(int *)optval)); - break; - -#if LWIP_TCP_KEEPALIVE - case TCP_KEEPIDLE: - *(int*)optval = (int)(sock->conn->pcb.tcp->keep_idle/1000); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPIDLE) = %d\n", - s, *(int *)optval)); - break; - case TCP_KEEPINTVL: - *(int*)optval = (int)(sock->conn->pcb.tcp->keep_intvl/1000); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPINTVL) = %d\n", - s, *(int *)optval)); - break; - case TCP_KEEPCNT: - *(int*)optval = (int)sock->conn->pcb.tcp->keep_cnt; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPCNT) = %d\n", - s, *(int *)optval)); - break; -#endif /* LWIP_TCP_KEEPALIVE */ - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; -#endif /* LWIP_TCP */ -#if LWIP_UDP && LWIP_UDPLITE - /* Level: IPPROTO_UDPLITE */ - case IPPROTO_UDPLITE: - switch (optname) { - case UDPLITE_SEND_CSCOV: - *(int*)optval = sock->conn->pcb.udp->chksum_len_tx; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) = %d\n", - s, (*(int*)optval)) ); - break; - case UDPLITE_RECV_CSCOV: - *(int*)optval = sock->conn->pcb.udp->chksum_len_rx; - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) = %d\n", - s, (*(int*)optval)) ); - break; - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; -#endif /* LWIP_UDP */ - default: - LWIP_ASSERT("unhandled level", 0); - break; - } /* switch (level) */ - sys_sem_signal(&sock->conn->op_completed); -} - -int -lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) -{ - struct lwip_sock *sock = get_socket(s); - err_t err = ERR_OK; - struct lwip_setgetsockopt_data data; - - if (!sock) { - return -1; - } - - if (NULL == optval) { - sock_set_errno(sock, EFAULT); - return -1; - } - - /* Do length and type checks for the various options first, to keep it readable. */ - switch (level) { - -/* Level: SOL_SOCKET */ - case SOL_SOCKET: - switch (optname) { - - case SO_BROADCAST: - /* UNIMPL case SO_DEBUG: */ - /* UNIMPL case SO_DONTROUTE: */ - case SO_KEEPALIVE: - /* UNIMPL case case SO_CONTIMEO: */ -#if LWIP_SO_SNDTIMEO - case SO_SNDTIMEO: -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO - case SO_RCVTIMEO: -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - case SO_RCVBUF: -#endif /* LWIP_SO_RCVBUF */ - /* UNIMPL case SO_OOBINLINE: */ - /* UNIMPL case SO_SNDBUF: */ - /* UNIMPL case SO_RCVLOWAT: */ - /* UNIMPL case SO_SNDLOWAT: */ -#if SO_REUSE - case SO_REUSEADDR: - case SO_REUSEPORT: -#endif /* SO_REUSE */ - /* UNIMPL case SO_USELOOPBACK: */ - if (optlen < sizeof(int)) { - err = EINVAL; - } - break; - case SO_NO_CHECK: - if (optlen < sizeof(int)) { - err = EINVAL; - } -#if LWIP_UDP - if ((sock->conn->type != NETCONN_UDP) || - ((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_UDPLITE) != 0)) { - /* this flag is only available for UDP, not for UDP lite */ - err = EAFNOSUPPORT; - } -#endif /* LWIP_UDP */ - break; - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; - -/* Level: IPPROTO_IP */ - case IPPROTO_IP: - switch (optname) { - /* UNIMPL case IP_HDRINCL: */ - /* UNIMPL case IP_RCVDSTADDR: */ - /* UNIMPL case IP_RCVIF: */ - case IP_TTL: - case IP_TOS: - if (optlen < sizeof(int)) { - err = EINVAL; - } - break; -#if LWIP_IGMP - case IP_MULTICAST_TTL: - if (optlen < sizeof(u8_t)) { - err = EINVAL; - } - if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { - err = EAFNOSUPPORT; - } - break; - case IP_MULTICAST_IF: - if (optlen < sizeof(struct in_addr)) { - err = EINVAL; - } - if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { - err = EAFNOSUPPORT; - } - break; - case IP_MULTICAST_LOOP: - if (optlen < sizeof(u8_t)) { - err = EINVAL; - } - if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { - err = EAFNOSUPPORT; - } - break; - case IP_ADD_MEMBERSHIP: - case IP_DROP_MEMBERSHIP: - if (optlen < sizeof(struct ip_mreq)) { - err = EINVAL; - } - if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP) { - err = EAFNOSUPPORT; - } - break; -#endif /* LWIP_IGMP */ - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; - -#if LWIP_TCP -/* Level: IPPROTO_TCP */ - case IPPROTO_TCP: - if (optlen < sizeof(int)) { - err = EINVAL; - break; - } - - /* If this is no TCP socket, ignore any options. */ - if (sock->conn->type != NETCONN_TCP) - return 0; - - switch (optname) { - case TCP_NODELAY: - case TCP_KEEPALIVE: -#if LWIP_TCP_KEEPALIVE - case TCP_KEEPIDLE: - case TCP_KEEPINTVL: - case TCP_KEEPCNT: -#endif /* LWIP_TCP_KEEPALIVE */ - break; - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; -#endif /* LWIP_TCP */ -#if LWIP_UDP && LWIP_UDPLITE -/* Level: IPPROTO_UDPLITE */ - case IPPROTO_UDPLITE: - if (optlen < sizeof(int)) { - err = EINVAL; - break; - } - - /* If this is no UDP lite socket, ignore any options. */ - if (sock->conn->type != NETCONN_UDPLITE) - return 0; - - switch (optname) { - case UDPLITE_SEND_CSCOV: - case UDPLITE_RECV_CSCOV: - break; - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n", - s, optname)); - err = ENOPROTOOPT; - } /* switch (optname) */ - break; -#endif /* LWIP_UDP && LWIP_UDPLITE */ -/* UNDEFINED LEVEL */ - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", - s, level, optname)); - err = ENOPROTOOPT; - } /* switch (level) */ - - - if (err != ERR_OK) { - sock_set_errno(sock, err); - return -1; - } - - - /* Now do the actual option processing */ - data.sock = sock; -#ifdef LWIP_DEBUG - data.s = s; -#endif /* LWIP_DEBUG */ - data.level = level; - data.optname = optname; - data.optval = (void*)optval; - data.optlen = &optlen; - data.err = err; - tcpip_callback(lwip_setsockopt_internal, &data); - sys_arch_sem_wait(&sock->conn->op_completed, 0); - /* maybe lwip_setsockopt_internal has changed err */ - err = data.err; - - sock_set_errno(sock, err); - return err ? -1 : 0; -} - -static void -lwip_setsockopt_internal(void *arg) -{ - struct lwip_sock *sock; -#ifdef LWIP_DEBUG - int s; -#endif /* LWIP_DEBUG */ - int level, optname; - const void *optval; - struct lwip_setgetsockopt_data *data; - - LWIP_ASSERT("arg != NULL", arg != NULL); - - data = (struct lwip_setgetsockopt_data*)arg; - sock = data->sock; -#ifdef LWIP_DEBUG - s = data->s; -#endif /* LWIP_DEBUG */ - level = data->level; - optname = data->optname; - optval = data->optval; - - switch (level) { - -/* Level: SOL_SOCKET */ - case SOL_SOCKET: - switch (optname) { - - /* The option flags */ - case SO_BROADCAST: - /* UNIMPL case SO_DEBUG: */ - /* UNIMPL case SO_DONTROUTE: */ - case SO_KEEPALIVE: - /* UNIMPL case SO_OOBINCLUDE: */ -#if SO_REUSE - case SO_REUSEADDR: - case SO_REUSEPORT: -#endif /* SO_REUSE */ - /* UNIMPL case SO_USELOOPBACK: */ - if (*(int*)optval) { - ip_set_option(sock->conn->pcb.ip, optname); - } else { - ip_reset_option(sock->conn->pcb.ip, optname); - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n", - s, optname, (*(int*)optval?"on":"off"))); - break; -#if LWIP_SO_SNDTIMEO - case SO_SNDTIMEO: - netconn_set_sendtimeout(sock->conn, (s32_t)*(int*)optval); - break; -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO - case SO_RCVTIMEO: - netconn_set_recvtimeout(sock->conn, *(int*)optval); - break; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - case SO_RCVBUF: - netconn_set_recvbufsize(sock->conn, *(int*)optval); - break; -#endif /* LWIP_SO_RCVBUF */ -#if LWIP_UDP - case SO_NO_CHECK: - if (*(int*)optval) { - udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_NOCHKSUM); - } else { - udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_NOCHKSUM); - } - break; -#endif /* LWIP_UDP */ - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; - -/* Level: IPPROTO_IP */ - case IPPROTO_IP: - switch (optname) { - case IP_TTL: - sock->conn->pcb.ip->ttl = (u8_t)(*(int*)optval); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %d\n", - s, sock->conn->pcb.ip->ttl)); - break; - case IP_TOS: - sock->conn->pcb.ip->tos = (u8_t)(*(int*)optval); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %d\n", - s, sock->conn->pcb.ip->tos)); - break; -#if LWIP_IGMP - case IP_MULTICAST_TTL: - sock->conn->pcb.udp->ttl = (u8_t)(*(u8_t*)optval); - break; - case IP_MULTICAST_IF: - inet_addr_to_ipaddr(&sock->conn->pcb.udp->multicast_ip, (struct in_addr*)optval); - break; - case IP_MULTICAST_LOOP: - if (*(u8_t*)optval) { - udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_MULTICAST_LOOP); - } else { - udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_MULTICAST_LOOP); - } - break; - case IP_ADD_MEMBERSHIP: - case IP_DROP_MEMBERSHIP: - { - /* If this is a TCP or a RAW socket, ignore these options. */ - struct ip_mreq *imr = (struct ip_mreq *)optval; - ip_addr_t if_addr; - ip_addr_t multi_addr; - inet_addr_to_ipaddr(&if_addr, &imr->imr_interface); - inet_addr_to_ipaddr(&multi_addr, &imr->imr_multiaddr); - if(optname == IP_ADD_MEMBERSHIP){ - data->err = igmp_joingroup(&if_addr, &multi_addr); - } else { - data->err = igmp_leavegroup(&if_addr, &multi_addr); - } - if(data->err != ERR_OK) { - data->err = EADDRNOTAVAIL; - } - } - break; -#endif /* LWIP_IGMP */ - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; - -#if LWIP_TCP -/* Level: IPPROTO_TCP */ - case IPPROTO_TCP: - switch (optname) { - case TCP_NODELAY: - if (*(int*)optval) { - tcp_nagle_disable(sock->conn->pcb.tcp); - } else { - tcp_nagle_enable(sock->conn->pcb.tcp); - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n", - s, (*(int *)optval)?"on":"off") ); - break; - case TCP_KEEPALIVE: - sock->conn->pcb.tcp->keep_idle = (u32_t)(*(int*)optval); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %"U32_F"\n", - s, sock->conn->pcb.tcp->keep_idle)); - break; - -#if LWIP_TCP_KEEPALIVE - case TCP_KEEPIDLE: - sock->conn->pcb.tcp->keep_idle = 1000*(u32_t)(*(int*)optval); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPIDLE) -> %"U32_F"\n", - s, sock->conn->pcb.tcp->keep_idle)); - break; - case TCP_KEEPINTVL: - sock->conn->pcb.tcp->keep_intvl = 1000*(u32_t)(*(int*)optval); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPINTVL) -> %"U32_F"\n", - s, sock->conn->pcb.tcp->keep_intvl)); - break; - case TCP_KEEPCNT: - sock->conn->pcb.tcp->keep_cnt = (u32_t)(*(int*)optval); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPCNT) -> %"U32_F"\n", - s, sock->conn->pcb.tcp->keep_cnt)); - break; -#endif /* LWIP_TCP_KEEPALIVE */ - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; -#endif /* LWIP_TCP*/ -#if LWIP_UDP && LWIP_UDPLITE - /* Level: IPPROTO_UDPLITE */ - case IPPROTO_UDPLITE: - switch (optname) { - case UDPLITE_SEND_CSCOV: - if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) { - /* don't allow illegal values! */ - sock->conn->pcb.udp->chksum_len_tx = 8; - } else { - sock->conn->pcb.udp->chksum_len_tx = (u16_t)*(int*)optval; - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n", - s, (*(int*)optval)) ); - break; - case UDPLITE_RECV_CSCOV: - if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) { - /* don't allow illegal values! */ - sock->conn->pcb.udp->chksum_len_rx = 8; - } else { - sock->conn->pcb.udp->chksum_len_rx = (u16_t)*(int*)optval; - } - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n", - s, (*(int*)optval)) ); - break; - default: - LWIP_ASSERT("unhandled optname", 0); - break; - } /* switch (optname) */ - break; -#endif /* LWIP_UDP */ - default: - LWIP_ASSERT("unhandled level", 0); - break; - } /* switch (level) */ - sys_sem_signal(&sock->conn->op_completed); -} - -int -lwip_ioctl(int s, long cmd, void *argp) -{ - struct lwip_sock *sock = get_socket(s); - u8_t val; -#if LWIP_SO_RCVBUF - u16_t buflen = 0; - s16_t recv_avail; -#endif /* LWIP_SO_RCVBUF */ - - if (!sock) { - return -1; - } - - switch (cmd) { -#if LWIP_SO_RCVBUF - case FIONREAD: - if (!argp) { - sock_set_errno(sock, EINVAL); - return -1; - } - - SYS_ARCH_GET(sock->conn->recv_avail, recv_avail); - if (recv_avail < 0) { - recv_avail = 0; - } - *((u16_t*)argp) = (u16_t)recv_avail; - - /* Check if there is data left from the last recv operation. /maq 041215 */ - if (sock->lastdata) { - struct pbuf *p = (struct pbuf *)sock->lastdata; - if (netconn_type(sock->conn) != NETCONN_TCP) { - p = ((struct netbuf *)p)->p; - } - buflen = p->tot_len; - buflen -= sock->lastoffset; - - *((u16_t*)argp) += buflen; - } - - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %"U16_F"\n", s, argp, *((u16_t*)argp))); - sock_set_errno(sock, 0); - return 0; -#endif /* LWIP_SO_RCVBUF */ - - case FIONBIO: - val = 0; - if (argp && *(u32_t*)argp) { - val = 1; - } - netconn_set_nonblocking(sock->conn, val); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, val)); - sock_set_errno(sock, 0); - return 0; - - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp)); - sock_set_errno(sock, ENOSYS); /* not yet implemented */ - return -1; - } /* switch (cmd) */ -} - -/** A minimal implementation of fcntl. - * Currently only the commands F_GETFL and F_SETFL are implemented. - * Only the flag O_NONBLOCK is implemented. - */ -int -lwip_fcntl(int s, int cmd, int val) -{ - struct lwip_sock *sock = get_socket(s); - int ret = -1; - - if (!sock || !sock->conn) { - return -1; - } - - switch (cmd) { - case F_GETFL: - ret = netconn_is_nonblocking(sock->conn) ? O_NONBLOCK : 0; - break; - case F_SETFL: - if ((val & ~O_NONBLOCK) == 0) { - /* only O_NONBLOCK, all other bits are zero */ - netconn_set_nonblocking(sock->conn, val & O_NONBLOCK); - ret = 0; - } - break; - default: - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_fcntl(%d, UNIMPL: %d, %d)\n", s, cmd, val)); - break; - } - return ret; -} - -#endif /* LWIP_SOCKET */ diff --git a/user/mpy/lib/lwip/src/api/tcpip.c b/user/mpy/lib/lwip/src/api/tcpip.c deleted file mode 100644 index 18d5f67..0000000 --- a/user/mpy/lib/lwip/src/api/tcpip.c +++ /dev/null @@ -1,511 +0,0 @@ -/** - * @file - * Sequential API Main thread module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/sys.h" -#include "lwip/memp.h" -#include "lwip/mem.h" -#include "lwip/pbuf.h" -#include "lwip/tcpip.h" -#include "lwip/init.h" -#include "netif/etharp.h" -#include "netif/ppp_oe.h" - -/* global variables */ -static tcpip_init_done_fn tcpip_init_done; -static void *tcpip_init_done_arg; -static sys_mbox_t mbox; - -#if LWIP_TCPIP_CORE_LOCKING -/** The global semaphore to lock the stack. */ -sys_mutex_t lock_tcpip_core; -#endif /* LWIP_TCPIP_CORE_LOCKING */ - - -/** - * The main lwIP thread. This thread has exclusive access to lwIP core functions - * (unless access to them is not locked). Other threads communicate with this - * thread using message boxes. - * - * It also starts all the timers to make sure they are running in the right - * thread context. - * - * @param arg unused argument - */ -static void -tcpip_thread(void *arg) -{ - struct tcpip_msg *msg; - LWIP_UNUSED_ARG(arg); - - if (tcpip_init_done != NULL) { - tcpip_init_done(tcpip_init_done_arg); - } - - LOCK_TCPIP_CORE(); - while (1) { /* MAIN Loop */ - UNLOCK_TCPIP_CORE(); - LWIP_TCPIP_THREAD_ALIVE(); - /* wait for a message, timeouts are processed while waiting */ - sys_timeouts_mbox_fetch(&mbox, (void **)&msg); - LOCK_TCPIP_CORE(); - switch (msg->type) { -#if LWIP_NETCONN - case TCPIP_MSG_API: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg)); - msg->msg.apimsg->function(&(msg->msg.apimsg->msg)); - break; -#endif /* LWIP_NETCONN */ - -#if !LWIP_TCPIP_CORE_LOCKING_INPUT - case TCPIP_MSG_INPKT: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg)); -#if LWIP_ETHERNET - if (msg->msg.inp.netif->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) { - ethernet_input(msg->msg.inp.p, msg->msg.inp.netif); - } else -#endif /* LWIP_ETHERNET */ - { - ip_input(msg->msg.inp.p, msg->msg.inp.netif); - } - memp_free(MEMP_TCPIP_MSG_INPKT, msg); - break; -#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */ - -#if LWIP_NETIF_API - case TCPIP_MSG_NETIFAPI: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: Netif API message %p\n", (void *)msg)); - msg->msg.netifapimsg->function(&(msg->msg.netifapimsg->msg)); - break; -#endif /* LWIP_NETIF_API */ - -#if LWIP_TCPIP_TIMEOUT - case TCPIP_MSG_TIMEOUT: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg)); - sys_timeout(msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg); - memp_free(MEMP_TCPIP_MSG_API, msg); - break; - case TCPIP_MSG_UNTIMEOUT: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: UNTIMEOUT %p\n", (void *)msg)); - sys_untimeout(msg->msg.tmo.h, msg->msg.tmo.arg); - memp_free(MEMP_TCPIP_MSG_API, msg); - break; -#endif /* LWIP_TCPIP_TIMEOUT */ - - case TCPIP_MSG_CALLBACK: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); - msg->msg.cb.function(msg->msg.cb.ctx); - memp_free(MEMP_TCPIP_MSG_API, msg); - break; - - case TCPIP_MSG_CALLBACK_STATIC: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK_STATIC %p\n", (void *)msg)); - msg->msg.cb.function(msg->msg.cb.ctx); - break; - - default: - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: %d\n", msg->type)); - LWIP_ASSERT("tcpip_thread: invalid message", 0); - break; - } - } -} - -/** - * Pass a received packet to tcpip_thread for input processing - * - * @param p the received packet, p->payload pointing to the Ethernet header or - * to an IP header (if inp doesn't have NETIF_FLAG_ETHARP or - * NETIF_FLAG_ETHERNET flags) - * @param inp the network interface on which the packet was received - */ -err_t -tcpip_input(struct pbuf *p, struct netif *inp) -{ -#if LWIP_TCPIP_CORE_LOCKING_INPUT - err_t ret; - LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_input: PACKET %p/%p\n", (void *)p, (void *)inp)); - LOCK_TCPIP_CORE(); -#if LWIP_ETHERNET - if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) { - ret = ethernet_input(p, inp); - } else -#endif /* LWIP_ETHERNET */ - { - ret = ip_input(p, inp); - } - UNLOCK_TCPIP_CORE(); - return ret; -#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */ - struct tcpip_msg *msg; - - if (!sys_mbox_valid(&mbox)) { - return ERR_VAL; - } - msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT); - if (msg == NULL) { - return ERR_MEM; - } - - msg->type = TCPIP_MSG_INPKT; - msg->msg.inp.p = p; - msg->msg.inp.netif = inp; - if (sys_mbox_trypost(&mbox, msg) != ERR_OK) { - memp_free(MEMP_TCPIP_MSG_INPKT, msg); - return ERR_MEM; - } - return ERR_OK; -#endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */ -} - -/** - * Call a specific function in the thread context of - * tcpip_thread for easy access synchronization. - * A function called in that way may access lwIP core code - * without fearing concurrent access. - * - * @param f the function to call - * @param ctx parameter passed to f - * @param block 1 to block until the request is posted, 0 to non-blocking mode - * @return ERR_OK if the function was called, another err_t if not - */ -err_t -tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block) -{ - struct tcpip_msg *msg; - - if (sys_mbox_valid(&mbox)) { - msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); - if (msg == NULL) { - return ERR_MEM; - } - - msg->type = TCPIP_MSG_CALLBACK; - msg->msg.cb.function = function; - msg->msg.cb.ctx = ctx; - if (block) { - sys_mbox_post(&mbox, msg); - } else { - if (sys_mbox_trypost(&mbox, msg) != ERR_OK) { - memp_free(MEMP_TCPIP_MSG_API, msg); - return ERR_MEM; - } - } - return ERR_OK; - } - return ERR_VAL; -} - -#if LWIP_TCPIP_TIMEOUT -/** - * call sys_timeout in tcpip_thread - * - * @param msec time in milliseconds for timeout - * @param h function to be called on timeout - * @param arg argument to pass to timeout function h - * @return ERR_MEM on memory error, ERR_OK otherwise - */ -err_t -tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg) -{ - struct tcpip_msg *msg; - - if (sys_mbox_valid(&mbox)) { - msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); - if (msg == NULL) { - return ERR_MEM; - } - - msg->type = TCPIP_MSG_TIMEOUT; - msg->msg.tmo.msecs = msecs; - msg->msg.tmo.h = h; - msg->msg.tmo.arg = arg; - sys_mbox_post(&mbox, msg); - return ERR_OK; - } - return ERR_VAL; -} - -/** - * call sys_untimeout in tcpip_thread - * - * @param msec time in milliseconds for timeout - * @param h function to be called on timeout - * @param arg argument to pass to timeout function h - * @return ERR_MEM on memory error, ERR_OK otherwise - */ -err_t -tcpip_untimeout(sys_timeout_handler h, void *arg) -{ - struct tcpip_msg *msg; - - if (sys_mbox_valid(&mbox)) { - msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); - if (msg == NULL) { - return ERR_MEM; - } - - msg->type = TCPIP_MSG_UNTIMEOUT; - msg->msg.tmo.h = h; - msg->msg.tmo.arg = arg; - sys_mbox_post(&mbox, msg); - return ERR_OK; - } - return ERR_VAL; -} -#endif /* LWIP_TCPIP_TIMEOUT */ - -#if LWIP_NETCONN -/** - * Call the lower part of a netconn_* function - * This function is then running in the thread context - * of tcpip_thread and has exclusive access to lwIP core code. - * - * @param apimsg a struct containing the function to call and its parameters - * @return ERR_OK if the function was called, another err_t if not - */ -err_t -tcpip_apimsg(struct api_msg *apimsg) -{ - struct tcpip_msg msg; -#ifdef LWIP_DEBUG - /* catch functions that don't set err */ - apimsg->msg.err = ERR_VAL; -#endif - - if (sys_mbox_valid(&mbox)) { - msg.type = TCPIP_MSG_API; - msg.msg.apimsg = apimsg; - sys_mbox_post(&mbox, &msg); - sys_arch_sem_wait(&apimsg->msg.conn->op_completed, 0); - return apimsg->msg.err; - } - return ERR_VAL; -} - -#if LWIP_TCPIP_CORE_LOCKING -/** - * Call the lower part of a netconn_* function - * This function has exclusive access to lwIP core code by locking it - * before the function is called. - * - * @param apimsg a struct containing the function to call and its parameters - * @return ERR_OK (only for compatibility fo tcpip_apimsg()) - */ -err_t -tcpip_apimsg_lock(struct api_msg *apimsg) -{ -#ifdef LWIP_DEBUG - /* catch functions that don't set err */ - apimsg->msg.err = ERR_VAL; -#endif - - LOCK_TCPIP_CORE(); - apimsg->function(&(apimsg->msg)); - UNLOCK_TCPIP_CORE(); - return apimsg->msg.err; - -} -#endif /* LWIP_TCPIP_CORE_LOCKING */ -#endif /* LWIP_NETCONN */ - -#if LWIP_NETIF_API -#if !LWIP_TCPIP_CORE_LOCKING -/** - * Much like tcpip_apimsg, but calls the lower part of a netifapi_* - * function. - * - * @param netifapimsg a struct containing the function to call and its parameters - * @return error code given back by the function that was called - */ -err_t -tcpip_netifapi(struct netifapi_msg* netifapimsg) -{ - struct tcpip_msg msg; - - if (sys_mbox_valid(&mbox)) { - err_t err = sys_sem_new(&netifapimsg->msg.sem, 0); - if (err != ERR_OK) { - netifapimsg->msg.err = err; - return err; - } - - msg.type = TCPIP_MSG_NETIFAPI; - msg.msg.netifapimsg = netifapimsg; - sys_mbox_post(&mbox, &msg); - sys_sem_wait(&netifapimsg->msg.sem); - sys_sem_free(&netifapimsg->msg.sem); - return netifapimsg->msg.err; - } - return ERR_VAL; -} -#else /* !LWIP_TCPIP_CORE_LOCKING */ -/** - * Call the lower part of a netifapi_* function - * This function has exclusive access to lwIP core code by locking it - * before the function is called. - * - * @param netifapimsg a struct containing the function to call and its parameters - * @return ERR_OK (only for compatibility fo tcpip_netifapi()) - */ -err_t -tcpip_netifapi_lock(struct netifapi_msg* netifapimsg) -{ - LOCK_TCPIP_CORE(); - netifapimsg->function(&(netifapimsg->msg)); - UNLOCK_TCPIP_CORE(); - return netifapimsg->msg.err; -} -#endif /* !LWIP_TCPIP_CORE_LOCKING */ -#endif /* LWIP_NETIF_API */ - -/** - * Allocate a structure for a static callback message and initialize it. - * This is intended to be used to send "static" messages from interrupt context. - * - * @param function the function to call - * @param ctx parameter passed to function - * @return a struct pointer to pass to tcpip_trycallback(). - */ -struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx) -{ - struct tcpip_msg *msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); - if (msg == NULL) { - return NULL; - } - msg->type = TCPIP_MSG_CALLBACK_STATIC; - msg->msg.cb.function = function; - msg->msg.cb.ctx = ctx; - return (struct tcpip_callback_msg*)msg; -} - -/** - * Free a callback message allocated by tcpip_callbackmsg_new(). - * - * @param msg the message to free - */ -void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg) -{ - memp_free(MEMP_TCPIP_MSG_API, msg); -} - -/** - * Try to post a callback-message to the tcpip_thread mbox - * This is intended to be used to send "static" messages from interrupt context. - * - * @param msg pointer to the message to post - * @return sys_mbox_trypost() return code - */ -err_t -tcpip_trycallback(struct tcpip_callback_msg* msg) -{ - if (!sys_mbox_valid(&mbox)) { - return ERR_VAL; - } - return sys_mbox_trypost(&mbox, msg); -} - -/** - * Initialize this module: - * - initialize all sub modules - * - start the tcpip_thread - * - * @param initfunc a function to call when tcpip_thread is running and finished initializing - * @param arg argument to pass to initfunc - */ -void -tcpip_init(tcpip_init_done_fn initfunc, void *arg) -{ - lwip_init(); - - tcpip_init_done = initfunc; - tcpip_init_done_arg = arg; - if(sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) { - LWIP_ASSERT("failed to create tcpip_thread mbox", 0); - } -#if LWIP_TCPIP_CORE_LOCKING - if(sys_mutex_new(&lock_tcpip_core) != ERR_OK) { - LWIP_ASSERT("failed to create lock_tcpip_core", 0); - } -#endif /* LWIP_TCPIP_CORE_LOCKING */ - - sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); -} - -/** - * Simple callback function used with tcpip_callback to free a pbuf - * (pbuf_free has a wrong signature for tcpip_callback) - * - * @param p The pbuf (chain) to be dereferenced. - */ -static void -pbuf_free_int(void *p) -{ - struct pbuf *q = (struct pbuf *)p; - pbuf_free(q); -} - -/** - * A simple wrapper function that allows you to free a pbuf from interrupt context. - * - * @param p The pbuf (chain) to be dereferenced. - * @return ERR_OK if callback could be enqueued, an err_t if not - */ -err_t -pbuf_free_callback(struct pbuf *p) -{ - return tcpip_callback_with_block(pbuf_free_int, p, 0); -} - -/** - * A simple wrapper function that allows you to free heap memory from - * interrupt context. - * - * @param m the heap memory to free - * @return ERR_OK if callback could be enqueued, an err_t if not - */ -err_t -mem_free_callback(void *m) -{ - return tcpip_callback_with_block(mem_free, m, 0); -} - -#endif /* !NO_SYS */ diff --git a/user/mpy/lib/lwip/src/core/def.c b/user/mpy/lib/lwip/src/core/def.c deleted file mode 100644 index 352b552..0000000 --- a/user/mpy/lib/lwip/src/core/def.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file - * Common functions used throughout the stack. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ - -#include "lwip/opt.h" -#include "lwip/def.h" - -/** - * These are reference implementations of the byte swapping functions. - * Again with the aim of being simple, correct and fully portable. - * Byte swapping is the second thing you would want to optimize. You will - * need to port it to your architecture and in your cc.h: - * - * #define LWIP_PLATFORM_BYTESWAP 1 - * #define LWIP_PLATFORM_HTONS(x) - * #define LWIP_PLATFORM_HTONL(x) - * - * Note ntohs() and ntohl() are merely references to the htonx counterparts. - */ - -#if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) - -/** - * Convert an u16_t from host- to network byte order. - * - * @param n u16_t in host byte order - * @return n in network byte order - */ -u16_t -lwip_htons(u16_t n) -{ - return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); -} - -/** - * Convert an u16_t from network- to host byte order. - * - * @param n u16_t in network byte order - * @return n in host byte order - */ -u16_t -lwip_ntohs(u16_t n) -{ - return lwip_htons(n); -} - -/** - * Convert an u32_t from host- to network byte order. - * - * @param n u32_t in host byte order - * @return n in network byte order - */ -u32_t -lwip_htonl(u32_t n) -{ - return ((n & 0xff) << 24) | - ((n & 0xff00) << 8) | - ((n & 0xff0000UL) >> 8) | - ((n & 0xff000000UL) >> 24); -} - -/** - * Convert an u32_t from network- to host byte order. - * - * @param n u32_t in network byte order - * @return n in host byte order - */ -u32_t -lwip_ntohl(u32_t n) -{ - return lwip_htonl(n); -} - -#endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ diff --git a/user/mpy/lib/lwip/src/core/dhcp.c b/user/mpy/lib/lwip/src/core/dhcp.c deleted file mode 100644 index eb12c55..0000000 --- a/user/mpy/lib/lwip/src/core/dhcp.c +++ /dev/null @@ -1,1770 +0,0 @@ -/** - * @file - * Dynamic Host Configuration Protocol client - * - */ - -/* - * - * Copyright (c) 2001-2004 Leon Woestenberg - * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is a contribution to the lwIP TCP/IP stack. - * The Swedish Institute of Computer Science and Adam Dunkels - * are specifically granted permission to redistribute this - * source code. - * - * Author: Leon Woestenberg - * - * This is a DHCP client for the lwIP TCP/IP stack. It aims to conform - * with RFC 2131 and RFC 2132. - * - * TODO: - * - Support for interfaces other than Ethernet (SLIP, PPP, ...) - * - * Please coordinate changes and requests with Leon Woestenberg - * - * - * Integration with your code: - * - * In lwip/dhcp.h - * #define DHCP_COARSE_TIMER_SECS (recommended 60 which is a minute) - * #define DHCP_FINE_TIMER_MSECS (recommended 500 which equals TCP coarse timer) - * - * Then have your application call dhcp_coarse_tmr() and - * dhcp_fine_tmr() on the defined intervals. - * - * dhcp_start(struct netif *netif); - * starts a DHCP client instance which configures the interface by - * obtaining an IP address lease and maintaining it. - * - * Use dhcp_release(netif) to end the lease and use dhcp_stop(netif) - * to remove the DHCP client. - * - */ - -#include "lwip/opt.h" - -#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/stats.h" -#include "lwip/mem.h" -#include "lwip/udp.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/def.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" -#include "lwip/dns.h" -#include "netif/etharp.h" - -#include - -/** DHCP_CREATE_RAND_XID: if this is set to 1, the xid is created using - * LWIP_RAND() (this overrides DHCP_GLOBAL_XID) - */ -#ifndef DHCP_CREATE_RAND_XID -#define DHCP_CREATE_RAND_XID 1 -#endif - -/** Default for DHCP_GLOBAL_XID is 0xABCD0000 - * This can be changed by defining DHCP_GLOBAL_XID and DHCP_GLOBAL_XID_HEADER, e.g. - * #define DHCP_GLOBAL_XID_HEADER "stdlib.h" - * #define DHCP_GLOBAL_XID rand() - */ -#ifdef DHCP_GLOBAL_XID_HEADER -#include DHCP_GLOBAL_XID_HEADER /* include optional starting XID generation prototypes */ -#endif - -/** DHCP_OPTION_MAX_MSG_SIZE is set to the MTU - * MTU is checked to be big enough in dhcp_start */ -#define DHCP_MAX_MSG_LEN(netif) (netif->mtu) -#define DHCP_MAX_MSG_LEN_MIN_REQUIRED 576 -/** Minimum length for reply before packet is parsed */ -#define DHCP_MIN_REPLY_LEN 44 - -#define REBOOT_TRIES 2 - -/** Option handling: options are parsed in dhcp_parse_reply - * and saved in an array where other functions can load them from. - * This might be moved into the struct dhcp (not necessarily since - * lwIP is single-threaded and the array is only used while in recv - * callback). */ -#define DHCP_OPTION_IDX_OVERLOAD 0 -#define DHCP_OPTION_IDX_MSG_TYPE 1 -#define DHCP_OPTION_IDX_SERVER_ID 2 -#define DHCP_OPTION_IDX_LEASE_TIME 3 -#define DHCP_OPTION_IDX_T1 4 -#define DHCP_OPTION_IDX_T2 5 -#define DHCP_OPTION_IDX_SUBNET_MASK 6 -#define DHCP_OPTION_IDX_ROUTER 7 -#define DHCP_OPTION_IDX_DNS_SERVER 8 -#define DHCP_OPTION_IDX_MAX (DHCP_OPTION_IDX_DNS_SERVER + DNS_MAX_SERVERS) - -/** Holds the decoded option values, only valid while in dhcp_recv. - @todo: move this into struct dhcp? */ -u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX]; -/** Holds a flag which option was received and is contained in dhcp_rx_options_val, - only valid while in dhcp_recv. - @todo: move this into struct dhcp? */ -u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX]; - -#ifdef DHCP_GLOBAL_XID -static u32_t xid; -static u8_t xid_initialised; -#endif /* DHCP_GLOBAL_XID */ - -#define dhcp_option_given(dhcp, idx) (dhcp_rx_options_given[idx] != 0) -#define dhcp_got_option(dhcp, idx) (dhcp_rx_options_given[idx] = 1) -#define dhcp_clear_option(dhcp, idx) (dhcp_rx_options_given[idx] = 0) -#define dhcp_clear_all_options(dhcp) (memset(dhcp_rx_options_given, 0, sizeof(dhcp_rx_options_given))) -#define dhcp_get_option_value(dhcp, idx) (dhcp_rx_options_val[idx]) -#define dhcp_set_option_value(dhcp, idx, val) (dhcp_rx_options_val[idx] = (val)) - - -/* DHCP client state machine functions */ -static err_t dhcp_discover(struct netif *netif); -static err_t dhcp_select(struct netif *netif); -static void dhcp_bind(struct netif *netif); -#if DHCP_DOES_ARP_CHECK -static err_t dhcp_decline(struct netif *netif); -#endif /* DHCP_DOES_ARP_CHECK */ -static err_t dhcp_rebind(struct netif *netif); -static err_t dhcp_reboot(struct netif *netif); -static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state); - -/* receive, unfold, parse and free incoming messages */ -static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); - -/* set the DHCP timers */ -static void dhcp_timeout(struct netif *netif); -static void dhcp_t1_timeout(struct netif *netif); -static void dhcp_t2_timeout(struct netif *netif); - -/* build outgoing messages */ -/* create a DHCP message, fill in common headers */ -static err_t dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type); -/* free a DHCP request */ -static void dhcp_delete_msg(struct dhcp *dhcp); -/* add a DHCP option (type, then length in bytes) */ -static void dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len); -/* add option values */ -static void dhcp_option_byte(struct dhcp *dhcp, u8_t value); -static void dhcp_option_short(struct dhcp *dhcp, u16_t value); -static void dhcp_option_long(struct dhcp *dhcp, u32_t value); -#if LWIP_NETIF_HOSTNAME -static void dhcp_option_hostname(struct dhcp *dhcp, struct netif *netif); -#endif /* LWIP_NETIF_HOSTNAME */ -/* always add the DHCP options trailer to end and pad */ -static void dhcp_option_trailer(struct dhcp *dhcp); - -/** - * Back-off the DHCP client (because of a received NAK response). - * - * Back-off the DHCP client because of a received NAK. Receiving a - * NAK means the client asked for something non-sensible, for - * example when it tries to renew a lease obtained on another network. - * - * We clear any existing set IP address and restart DHCP negotiation - * afresh (as per RFC2131 3.2.3). - * - * @param netif the netif under DHCP control - */ -static void -dhcp_handle_nak(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", - (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); - /* Set the interface down since the address must no longer be used, as per RFC2131 */ - netif_set_down(netif); - /* remove IP address from interface */ - netif_set_ipaddr(netif, IP_ADDR_ANY); - netif_set_gw(netif, IP_ADDR_ANY); - netif_set_netmask(netif, IP_ADDR_ANY); - /* Change to a defined state */ - dhcp_set_state(dhcp, DHCP_BACKING_OFF); - /* We can immediately restart discovery */ - dhcp_discover(netif); -} - -#if DHCP_DOES_ARP_CHECK -/** - * Checks if the offered IP address is already in use. - * - * It does so by sending an ARP request for the offered address and - * entering CHECKING state. If no ARP reply is received within a small - * interval, the address is assumed to be free for use by us. - * - * @param netif the netif under DHCP control - */ -static void -dhcp_check(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0], - (s16_t)netif->name[1])); - dhcp_set_state(dhcp, DHCP_CHECKING); - /* create an ARP query for the offered IP address, expecting that no host - responds, as the IP address should not be in use. */ - result = etharp_query(netif, &dhcp->offered_ip_addr, NULL); - if (result != ERR_OK) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("dhcp_check: could not perform ARP query\n")); - } - dhcp->tries++; - msecs = 500; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_check(): set request timeout %"U16_F" msecs\n", msecs)); -} -#endif /* DHCP_DOES_ARP_CHECK */ - -/** - * Remember the configuration offered by a DHCP server. - * - * @param netif the netif under DHCP control - */ -static void -dhcp_handle_offer(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n", - (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); - /* obtain the server address */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) { - ip4_addr_set_u32(&dhcp->server_ip_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", - ip4_addr_get_u32(&dhcp->server_ip_addr))); - /* remember offered address */ - ip_addr_copy(dhcp->offered_ip_addr, dhcp->msg_in->yiaddr); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n", - ip4_addr_get_u32(&dhcp->offered_ip_addr))); - - dhcp_select(netif); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, - ("dhcp_handle_offer(netif=%p) did not get server ID!\n", (void*)netif)); - } -} - -/** - * Select a DHCP server offer out of all offers. - * - * Simply select the first offer received. - * - * @param netif the netif under DHCP control - * @return lwIP specific error (see error.h) - */ -static err_t -dhcp_select(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result; - u16_t msecs; - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); - dhcp_set_state(dhcp, DHCP_REQUESTING); - - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); - if (result == ERR_OK) { - dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); - dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); - - /* MUST request the offered IP address */ - dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); - - dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->server_ip_addr))); - - dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/); - dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK); - dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER); - dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST); - dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER); - -#if LWIP_NETIF_HOSTNAME - dhcp_option_hostname(dhcp, netif); -#endif /* LWIP_NETIF_HOSTNAME */ - - dhcp_option_trailer(dhcp); - /* shrink the pbuf to the actual content length */ - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - /* send broadcast to any DHCP server */ - udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(dhcp); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_select: REQUESTING\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("dhcp_select: could not allocate DHCP request\n")); - } - dhcp->tries++; - msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * 1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_select(): set request timeout %"U16_F" msecs\n", msecs)); - return result; -} - -/** - * The DHCP timer that checks for lease renewal/rebind timeouts. - */ -void -dhcp_coarse_tmr() -{ - struct netif *netif = netif_list; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_coarse_tmr()\n")); - /* iterate through all network interfaces */ - while (netif != NULL) { - /* only act on DHCP configured interfaces */ - if (netif->dhcp != NULL) { - /* timer is active (non zero), and triggers (zeroes) now? */ - if (netif->dhcp->t2_timeout-- == 1) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n")); - /* this clients' rebind timeout triggered */ - dhcp_t2_timeout(netif); - /* timer is active (non zero), and triggers (zeroes) now */ - } else if (netif->dhcp->t1_timeout-- == 1) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n")); - /* this clients' renewal timeout triggered */ - dhcp_t1_timeout(netif); - } - } - /* proceed to next netif */ - netif = netif->next; - } -} - -/** - * DHCP transaction timeout handling - * - * A DHCP server is expected to respond within a short period of time. - * This timer checks whether an outstanding DHCP request is timed out. - */ -void -dhcp_fine_tmr() -{ - struct netif *netif = netif_list; - /* loop through netif's */ - while (netif != NULL) { - /* only act on DHCP configured interfaces */ - if (netif->dhcp != NULL) { - /* timer is active (non zero), and is about to trigger now */ - if (netif->dhcp->request_timeout > 1) { - netif->dhcp->request_timeout--; - } - else if (netif->dhcp->request_timeout == 1) { - netif->dhcp->request_timeout--; - /* { netif->dhcp->request_timeout == 0 } */ - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_fine_tmr(): request timeout\n")); - /* this client's request timeout triggered */ - dhcp_timeout(netif); - } - } - /* proceed to next network interface */ - netif = netif->next; - } -} - -/** - * A DHCP negotiation transaction, or ARP request, has timed out. - * - * The timer that was started with the DHCP or ARP request has - * timed out, indicating no response was received in time. - * - * @param netif the netif under DHCP control - */ -static void -dhcp_timeout(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_timeout()\n")); - /* back-off period has passed, or server selection timed out */ - if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_timeout(): restarting discovery\n")); - dhcp_discover(netif); - /* receiving the requested lease timed out */ - } else if (dhcp->state == DHCP_REQUESTING) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n")); - if (dhcp->tries <= 5) { - dhcp_select(netif); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n")); - dhcp_release(netif); - dhcp_discover(netif); - } -#if DHCP_DOES_ARP_CHECK - /* received no ARP reply for the offered address (which is good) */ - } else if (dhcp->state == DHCP_CHECKING) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n")); - if (dhcp->tries <= 1) { - dhcp_check(netif); - /* no ARP replies on the offered address, - looks like the IP address is indeed free */ - } else { - /* bind the interface to the offered address */ - dhcp_bind(netif); - } -#endif /* DHCP_DOES_ARP_CHECK */ - } - /* did not get response to renew request? */ - else if (dhcp->state == DHCP_RENEWING) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n")); - /* just retry renewal */ - /* note that the rebind timer will eventually time-out if renew does not work */ - dhcp_renew(netif); - /* did not get response to rebind request? */ - } else if (dhcp->state == DHCP_REBINDING) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n")); - if (dhcp->tries <= 8) { - dhcp_rebind(netif); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n")); - dhcp_release(netif); - dhcp_discover(netif); - } - } else if (dhcp->state == DHCP_REBOOTING) { - if (dhcp->tries < REBOOT_TRIES) { - dhcp_reboot(netif); - } else { - dhcp_discover(netif); - } - } -} - -/** - * The renewal period has timed out. - * - * @param netif the netif under DHCP control - */ -static void -dhcp_t1_timeout(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_t1_timeout()\n")); - if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || - (dhcp->state == DHCP_RENEWING)) { - /* just retry to renew - note that the rebind timer (t2) will - * eventually time-out if renew tries fail. */ - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("dhcp_t1_timeout(): must renew\n")); - /* This slightly different to RFC2131: DHCPREQUEST will be sent from state - DHCP_RENEWING, not DHCP_BOUND */ - dhcp_renew(netif); - } -} - -/** - * The rebind period has timed out. - * - * @param netif the netif under DHCP control - */ -static void -dhcp_t2_timeout(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t2_timeout()\n")); - if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || - (dhcp->state == DHCP_RENEWING)) { - /* just retry to rebind */ - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("dhcp_t2_timeout(): must rebind\n")); - /* This slightly different to RFC2131: DHCPREQUEST will be sent from state - DHCP_REBINDING, not DHCP_BOUND */ - dhcp_rebind(netif); - } -} - -/** - * Handle a DHCP ACK packet - * - * @param netif the netif under DHCP control - */ -static void -dhcp_handle_ack(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; -#if LWIP_DNS - u8_t n; -#endif /* LWIP_DNS */ - - /* clear options we might not get from the ACK */ - ip_addr_set_zero(&dhcp->offered_sn_mask); - ip_addr_set_zero(&dhcp->offered_gw_addr); -#if LWIP_DHCP_BOOTP_FILE - ip_addr_set_zero(&dhcp->offered_si_addr); -#endif /* LWIP_DHCP_BOOTP_FILE */ - - /* lease time given? */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_LEASE_TIME)) { - /* remember offered lease time */ - dhcp->offered_t0_lease = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_LEASE_TIME); - } - /* renewal period given? */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_T1)) { - /* remember given renewal period */ - dhcp->offered_t1_renew = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_T1); - } else { - /* calculate safe periods for renewal */ - dhcp->offered_t1_renew = dhcp->offered_t0_lease / 2; - } - - /* renewal period given? */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_T2)) { - /* remember given rebind period */ - dhcp->offered_t2_rebind = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_T2); - } else { - /* calculate safe periods for rebinding */ - dhcp->offered_t2_rebind = dhcp->offered_t0_lease; - } - - /* (y)our internet address */ - ip_addr_copy(dhcp->offered_ip_addr, dhcp->msg_in->yiaddr); - -#if LWIP_DHCP_BOOTP_FILE - /* copy boot server address, - boot file name copied in dhcp_parse_reply if not overloaded */ - ip_addr_copy(dhcp->offered_si_addr, dhcp->msg_in->siaddr); -#endif /* LWIP_DHCP_BOOTP_FILE */ - - /* subnet mask given? */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SUBNET_MASK)) { - /* remember given subnet mask */ - ip4_addr_set_u32(&dhcp->offered_sn_mask, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SUBNET_MASK))); - dhcp->subnet_mask_given = 1; - } else { - dhcp->subnet_mask_given = 0; - } - - /* gateway router */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_ROUTER)) { - ip4_addr_set_u32(&dhcp->offered_gw_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_ROUTER))); - } - -#if LWIP_DNS - /* DNS servers */ - n = 0; - while(dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n) && (n < DNS_MAX_SERVERS)) { - ip_addr_t dns_addr; - ip4_addr_set_u32(&dns_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n))); - dns_setserver(n, &dns_addr); - n++; - } -#endif /* LWIP_DNS */ -} - -/** Set a statically allocated struct dhcp to work with. - * Using this prevents dhcp_start to allocate it using mem_malloc. - * - * @param netif the netif for which to set the struct dhcp - * @param dhcp (uninitialised) dhcp struct allocated by the application - */ -void -dhcp_set_struct(struct netif *netif, struct dhcp *dhcp) -{ - LWIP_ASSERT("netif != NULL", netif != NULL); - LWIP_ASSERT("dhcp != NULL", dhcp != NULL); - LWIP_ASSERT("netif already has a struct dhcp set", netif->dhcp == NULL); - - /* clear data structure */ - memset(dhcp, 0, sizeof(struct dhcp)); - /* dhcp_set_state(&dhcp, DHCP_OFF); */ - netif->dhcp = dhcp; -} - -/** Removes a struct dhcp from a netif. - * - * ATTENTION: Only use this when not using dhcp_set_struct() to allocate the - * struct dhcp since the memory is passed back to the heap. - * - * @param netif the netif from which to remove the struct dhcp - */ -void dhcp_cleanup(struct netif *netif) -{ - LWIP_ASSERT("netif != NULL", netif != NULL); - - if (netif->dhcp != NULL) { - mem_free(netif->dhcp); - netif->dhcp = NULL; - } -} - -/** - * Start DHCP negotiation for a network interface. - * - * If no DHCP client instance was attached to this interface, - * a new client is created first. If a DHCP client instance - * was already present, it restarts negotiation. - * - * @param netif The lwIP network interface - * @return lwIP error code - * - ERR_OK - No error - * - ERR_MEM - Out of memory - */ -err_t -dhcp_start(struct netif *netif) -{ - struct dhcp *dhcp; - err_t result = ERR_OK; - - LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;); - dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); - /* Remove the flag that says this netif is handled by DHCP, - it is set when we succeeded starting. */ - netif->flags &= ~NETIF_FLAG_DHCP; - - /* check hwtype of the netif */ - if ((netif->flags & NETIF_FLAG_ETHARP) == 0) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): No ETHARP netif\n")); - return ERR_ARG; - } - - /* check MTU of the netif */ - if (netif->mtu < DHCP_MAX_MSG_LEN_MIN_REQUIRED) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): Cannot use this netif with DHCP: MTU is too small\n")); - return ERR_MEM; - } - - /* no DHCP client attached yet? */ - if (dhcp == NULL) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting new DHCP client\n")); - dhcp = (struct dhcp *)mem_malloc(sizeof(struct dhcp)); - if (dhcp == NULL) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n")); - return ERR_MEM; - } - /* store this dhcp client in the netif */ - netif->dhcp = dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): allocated dhcp")); - /* already has DHCP client attached */ - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(): restarting DHCP configuration\n")); - if (dhcp->pcb != NULL) { - udp_remove(dhcp->pcb); - } - LWIP_ASSERT("pbuf p_out wasn't freed", dhcp->p_out == NULL); - LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL ); - } - - /* clear data structure */ - memset(dhcp, 0, sizeof(struct dhcp)); - /* dhcp_set_state(&dhcp, DHCP_OFF); */ - /* allocate UDP PCB */ - dhcp->pcb = udp_new(); - if (dhcp->pcb == NULL) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not obtain pcb\n")); - return ERR_MEM; - } - ip_set_option(dhcp->pcb, SOF_BROADCAST); - /* set up local and remote port for the pcb */ - udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); - udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); - /* set up the recv callback and argument */ - udp_recv(dhcp->pcb, dhcp_recv, netif); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n")); - /* (re)start the DHCP negotiation */ - result = dhcp_discover(netif); - if (result != ERR_OK) { - /* free resources allocated above */ - dhcp_stop(netif); - return ERR_MEM; - } - /* Set the flag that says this netif is handled by DHCP. */ - netif->flags |= NETIF_FLAG_DHCP; - return result; -} - -/** - * Inform a DHCP server of our manual configuration. - * - * This informs DHCP servers of our fixed IP address configuration - * by sending an INFORM message. It does not involve DHCP address - * configuration, it is just here to be nice to the network. - * - * @param netif The lwIP network interface - */ -void -dhcp_inform(struct netif *netif) -{ - struct dhcp dhcp; - err_t result = ERR_OK; - struct udp_pcb *pcb; - - LWIP_ERROR("netif != NULL", (netif != NULL), return;); - - memset(&dhcp, 0, sizeof(struct dhcp)); - dhcp_set_state(&dhcp, DHCP_INFORM); - - if ((netif->dhcp != NULL) && (netif->dhcp->pcb != NULL)) { - /* re-use existing pcb */ - pcb = netif->dhcp->pcb; - } else { - pcb = udp_new(); - if (pcb == NULL) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_inform(): could not obtain pcb")); - return; - } - dhcp.pcb = pcb; - ip_set_option(dhcp.pcb, SOF_BROADCAST); - udp_bind(dhcp.pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_inform(): created new udp pcb\n")); - } - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, &dhcp, DHCP_INFORM); - if (result == ERR_OK) { - dhcp_option(&dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); - dhcp_option_short(&dhcp, DHCP_MAX_MSG_LEN(netif)); - - dhcp_option_trailer(&dhcp); - - pbuf_realloc(dhcp.p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp.options_out_len); - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_inform: INFORMING\n")); - udp_sendto_if(pcb, dhcp.p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(&dhcp); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_inform: could not allocate DHCP request\n")); - } - - if (dhcp.pcb != NULL) { - /* otherwise, the existing pcb was used */ - udp_remove(dhcp.pcb); - } -} - -/** Handle a possible change in the network configuration. - * - * This enters the REBOOTING state to verify that the currently bound - * address is still valid. - */ -void -dhcp_network_changed(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - if (!dhcp) - return; - switch (dhcp->state) { - case DHCP_REBINDING: - case DHCP_RENEWING: - case DHCP_BOUND: - case DHCP_REBOOTING: - netif_set_down(netif); - dhcp->tries = 0; - dhcp_reboot(netif); - break; - case DHCP_OFF: - /* stay off */ - break; - default: - dhcp->tries = 0; -#if LWIP_DHCP_AUTOIP_COOP - if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { - autoip_stop(netif); - dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; - } -#endif /* LWIP_DHCP_AUTOIP_COOP */ - dhcp_discover(netif); - break; - } -} - -#if DHCP_DOES_ARP_CHECK -/** - * Match an ARP reply with the offered IP address. - * - * @param netif the network interface on which the reply was received - * @param addr The IP address we received a reply from - */ -void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr) -{ - LWIP_ERROR("netif != NULL", (netif != NULL), return;); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_arp_reply()\n")); - /* is a DHCP client doing an ARP check? */ - if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08"X32_F"\n", - ip4_addr_get_u32(addr))); - /* did a host respond with the address we - were offered by the DHCP server? */ - if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) { - /* we will not accept the offered address */ - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, - ("dhcp_arp_reply(): arp reply matched with offered address, declining\n")); - dhcp_decline(netif); - } - } -} - -/** - * Decline an offered lease. - * - * Tell the DHCP server we do not accept the offered address. - * One reason to decline the lease is when we find out the address - * is already in use by another host (through ARP). - * - * @param netif the netif under DHCP control - */ -static err_t -dhcp_decline(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result = ERR_OK; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline()\n")); - dhcp_set_state(dhcp, DHCP_BACKING_OFF); - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_DECLINE); - if (result == ERR_OK) { - dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); - - dhcp_option_trailer(dhcp); - /* resize pbuf to reflect true size of options */ - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - /* per section 4.4.4, broadcast DECLINE messages */ - udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(dhcp); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_decline: BACKING OFF\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, - ("dhcp_decline: could not allocate DHCP request\n")); - } - dhcp->tries++; - msecs = 10*1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs)); - return result; -} -#endif /* DHCP_DOES_ARP_CHECK */ - - -/** - * Start the DHCP process, discover a DHCP server. - * - * @param netif the netif under DHCP control - */ -static err_t -dhcp_discover(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result = ERR_OK; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover()\n")); - ip_addr_set_any(&dhcp->offered_ip_addr); - dhcp_set_state(dhcp, DHCP_SELECTING); - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_DISCOVER); - if (result == ERR_OK) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: making request\n")); - - dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); - dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); - - dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/); - dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK); - dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER); - dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST); - dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER); - - dhcp_option_trailer(dhcp); - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: realloc()ing\n")); - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)\n")); - udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: deleting()ing\n")); - dhcp_delete_msg(dhcp); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover: SELECTING\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_discover: could not allocate DHCP request\n")); - } - dhcp->tries++; -#if LWIP_DHCP_AUTOIP_COOP - if(dhcp->tries >= LWIP_DHCP_AUTOIP_COOP_TRIES && dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_OFF) { - dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_ON; - autoip_start(netif); - } -#endif /* LWIP_DHCP_AUTOIP_COOP */ - msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * 1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs)); - return result; -} - - -/** - * Bind the interface to the offered IP address. - * - * @param netif network interface to bind to the offered address - */ -static void -dhcp_bind(struct netif *netif) -{ - u32_t timeout; - struct dhcp *dhcp; - ip_addr_t sn_mask, gw_addr; - LWIP_ERROR("dhcp_bind: netif != NULL", (netif != NULL), return;); - dhcp = netif->dhcp; - LWIP_ERROR("dhcp_bind: dhcp != NULL", (dhcp != NULL), return;); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); - - /* temporary DHCP lease? */ - if (dhcp->offered_t1_renew != 0xffffffffUL) { - /* set renewal period timer */ - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew)); - timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; - if(timeout > 0xffff) { - timeout = 0xffff; - } - dhcp->t1_timeout = (u16_t)timeout; - if (dhcp->t1_timeout == 0) { - dhcp->t1_timeout = 1; - } - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000)); - } - /* set renewal period timer */ - if (dhcp->offered_t2_rebind != 0xffffffffUL) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind)); - timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; - if(timeout > 0xffff) { - timeout = 0xffff; - } - dhcp->t2_timeout = (u16_t)timeout; - if (dhcp->t2_timeout == 0) { - dhcp->t2_timeout = 1; - } - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000)); - } - - /* If we have sub 1 minute lease, t2 and t1 will kick in at the same time. */ - if ((dhcp->t1_timeout >= dhcp->t2_timeout) && (dhcp->t2_timeout > 0)) { - dhcp->t1_timeout = 0; - } - - if (dhcp->subnet_mask_given) { - /* copy offered network mask */ - ip_addr_copy(sn_mask, dhcp->offered_sn_mask); - } else { - /* subnet mask not given, choose a safe subnet mask given the network class */ - u8_t first_octet = ip4_addr1(&dhcp->offered_ip_addr); - if (first_octet <= 127) { - ip4_addr_set_u32(&sn_mask, PP_HTONL(0xff000000UL)); - } else if (first_octet >= 192) { - ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffffff00UL)); - } else { - ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffff0000UL)); - } - } - - ip_addr_copy(gw_addr, dhcp->offered_gw_addr); - /* gateway address not given? */ - if (ip_addr_isany(&gw_addr)) { - /* copy network address */ - ip_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask); - /* use first host address on network as gateway */ - ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001UL)); - } - -#if LWIP_DHCP_AUTOIP_COOP - if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { - autoip_stop(netif); - dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; - } -#endif /* LWIP_DHCP_AUTOIP_COOP */ - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", - ip4_addr_get_u32(&dhcp->offered_ip_addr))); - netif_set_ipaddr(netif, &dhcp->offered_ip_addr); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", - ip4_addr_get_u32(&sn_mask))); - netif_set_netmask(netif, &sn_mask); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): GW: 0x%08"X32_F"\n", - ip4_addr_get_u32(&gw_addr))); - netif_set_gw(netif, &gw_addr); - /* bring the interface up */ - netif_set_up(netif); - /* netif is now bound to DHCP leased address */ - dhcp_set_state(dhcp, DHCP_BOUND); -} - -/** - * Renew an existing DHCP lease at the involved DHCP server. - * - * @param netif network interface which must renew its lease - */ -err_t -dhcp_renew(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_renew()\n")); - dhcp_set_state(dhcp, DHCP_RENEWING); - - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); - if (result == ERR_OK) { - dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); - dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); - -#if 0 - dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); -#endif - -#if 0 - dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); - dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); -#endif - -#if LWIP_NETIF_HOSTNAME - dhcp_option_hostname(dhcp, netif); -#endif /* LWIP_NETIF_HOSTNAME */ - - /* append DHCP message trailer */ - dhcp_option_trailer(dhcp); - - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - udp_sendto_if(dhcp->pcb, dhcp->p_out, &dhcp->server_ip_addr, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(dhcp); - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew: RENEWING\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_renew: could not allocate DHCP request\n")); - } - dhcp->tries++; - /* back-off on retries, but to a maximum of 20 seconds */ - msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew(): set request timeout %"U16_F" msecs\n", msecs)); - return result; -} - -/** - * Rebind with a DHCP server for an existing DHCP lease. - * - * @param netif network interface which must rebind with a DHCP server - */ -static err_t -dhcp_rebind(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind()\n")); - dhcp_set_state(dhcp, DHCP_REBINDING); - - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); - if (result == ERR_OK) { - dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); - dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif)); - -#if LWIP_NETIF_HOSTNAME - dhcp_option_hostname(dhcp, netif); -#endif /* LWIP_NETIF_HOSTNAME */ - -#if 0 - dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); - - dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); - dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); -#endif - - dhcp_option_trailer(dhcp); - - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - /* broadcast to server */ - udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(dhcp); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind: REBINDING\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_rebind: could not allocate DHCP request\n")); - } - dhcp->tries++; - msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind(): set request timeout %"U16_F" msecs\n", msecs)); - return result; -} - -/** - * Enter REBOOTING state to verify an existing lease - * - * @param netif network interface which must reboot - */ -static err_t -dhcp_reboot(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot()\n")); - dhcp_set_state(dhcp, DHCP_REBOOTING); - - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_REQUEST); - if (result == ERR_OK) { - dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); - dhcp_option_short(dhcp, 576); - - dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); - - dhcp_option_trailer(dhcp); - - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - /* broadcast to server */ - udp_sendto_if(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(dhcp); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot: REBOOTING\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_reboot: could not allocate DHCP request\n")); - } - dhcp->tries++; - msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot(): set request timeout %"U16_F" msecs\n", msecs)); - return result; -} - - -/** - * Release a DHCP lease. - * - * @param netif network interface which must release its lease - */ -err_t -dhcp_release(struct netif *netif) -{ - struct dhcp *dhcp = netif->dhcp; - err_t result; - u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_release()\n")); - - /* idle DHCP client */ - dhcp_set_state(dhcp, DHCP_OFF); - /* clean old DHCP offer */ - ip_addr_set_zero(&dhcp->server_ip_addr); - ip_addr_set_zero(&dhcp->offered_ip_addr); - ip_addr_set_zero(&dhcp->offered_sn_mask); - ip_addr_set_zero(&dhcp->offered_gw_addr); -#if LWIP_DHCP_BOOTP_FILE - ip_addr_set_zero(&dhcp->offered_si_addr); -#endif /* LWIP_DHCP_BOOTP_FILE */ - dhcp->offered_t0_lease = dhcp->offered_t1_renew = dhcp->offered_t2_rebind = 0; - - /* create and initialize the DHCP message header */ - result = dhcp_create_msg(netif, dhcp, DHCP_RELEASE); - if (result == ERR_OK) { - dhcp_option_trailer(dhcp); - - pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); - - udp_sendto_if(dhcp->pcb, dhcp->p_out, &dhcp->server_ip_addr, DHCP_SERVER_PORT, netif); - dhcp_delete_msg(dhcp); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_release: could not allocate DHCP request\n")); - } - dhcp->tries++; - msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; - dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs)); - /* bring the interface down */ - netif_set_down(netif); - /* remove IP address from interface */ - netif_set_ipaddr(netif, IP_ADDR_ANY); - netif_set_gw(netif, IP_ADDR_ANY); - netif_set_netmask(netif, IP_ADDR_ANY); - - return result; -} - -/** - * Remove the DHCP client from the interface. - * - * @param netif The network interface to stop DHCP on - */ -void -dhcp_stop(struct netif *netif) -{ - struct dhcp *dhcp; - LWIP_ERROR("dhcp_stop: netif != NULL", (netif != NULL), return;); - dhcp = netif->dhcp; - /* Remove the flag that says this netif is handled by DHCP. */ - netif->flags &= ~NETIF_FLAG_DHCP; - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_stop()\n")); - /* netif is DHCP configured? */ - if (dhcp != NULL) { -#if LWIP_DHCP_AUTOIP_COOP - if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { - autoip_stop(netif); - dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; - } -#endif /* LWIP_DHCP_AUTOIP_COOP */ - - if (dhcp->pcb != NULL) { - udp_remove(dhcp->pcb); - dhcp->pcb = NULL; - } - LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL); - dhcp_set_state(dhcp, DHCP_OFF); - } -} - -/* - * Set the DHCP state of a DHCP client. - * - * If the state changed, reset the number of tries. - */ -static void -dhcp_set_state(struct dhcp *dhcp, u8_t new_state) -{ - if (new_state != dhcp->state) { - dhcp->state = new_state; - dhcp->tries = 0; - dhcp->request_timeout = 0; - } -} - -/* - * Concatenate an option type and length field to the outgoing - * DHCP message. - * - */ -static void -dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len) -{ - LWIP_ASSERT("dhcp_option: dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2U + option_len <= DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = option_type; - dhcp->msg_out->options[dhcp->options_out_len++] = option_len; -} -/* - * Concatenate a single byte to the outgoing DHCP message. - * - */ -static void -dhcp_option_byte(struct dhcp *dhcp, u8_t value) -{ - LWIP_ASSERT("dhcp_option_byte: dhcp->options_out_len < DHCP_OPTIONS_LEN", dhcp->options_out_len < DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = value; -} - -static void -dhcp_option_short(struct dhcp *dhcp, u16_t value) -{ - LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2U <= DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0xff00U) >> 8); - dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t) (value & 0x00ffU); -} - -static void -dhcp_option_long(struct dhcp *dhcp, u32_t value) -{ - LWIP_ASSERT("dhcp_option_long: dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 4U <= DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0xff000000UL) >> 24); - dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x00ff0000UL) >> 16); - dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x0000ff00UL) >> 8); - dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x000000ffUL)); -} - -#if LWIP_NETIF_HOSTNAME -static void -dhcp_option_hostname(struct dhcp *dhcp, struct netif *netif) -{ - if (netif->hostname != NULL) { - size_t namelen = strlen(netif->hostname); - if (namelen > 0) { - u8_t len; - const char *p = netif->hostname; - /* Shrink len to available bytes (need 2 bytes for OPTION_HOSTNAME - and 1 byte for trailer) */ - size_t available = DHCP_OPTIONS_LEN - dhcp->options_out_len - 3; - LWIP_ASSERT("DHCP: hostname is too long!", namelen <= available); - len = LWIP_MIN(namelen, available); - dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, len); - while (len--) { - dhcp_option_byte(dhcp, *p++); - } - } - } -} -#endif /* LWIP_NETIF_HOSTNAME */ - -/** - * Extract the DHCP message and the DHCP options. - * - * Extract the DHCP message and the DHCP options, each into a contiguous - * piece of memory. As a DHCP message is variable sized by its options, - * and also allows overriding some fields for options, the easy approach - * is to first unfold the options into a conitguous piece of memory, and - * use that further on. - * - */ -static err_t -dhcp_parse_reply(struct dhcp *dhcp, struct pbuf *p) -{ - u8_t *options; - u16_t offset; - u16_t offset_max; - u16_t options_idx; - u16_t options_idx_max; - struct pbuf *q; - int parse_file_as_options = 0; - int parse_sname_as_options = 0; - - /* clear received options */ - dhcp_clear_all_options(dhcp); - /* check that beginning of dhcp_msg (up to and including chaddr) is in first pbuf */ - if (p->len < DHCP_SNAME_OFS) { - return ERR_BUF; - } - dhcp->msg_in = (struct dhcp_msg *)p->payload; -#if LWIP_DHCP_BOOTP_FILE - /* clear boot file name */ - dhcp->boot_file_name[0] = 0; -#endif /* LWIP_DHCP_BOOTP_FILE */ - - /* parse options */ - - /* start with options field */ - options_idx = DHCP_OPTIONS_OFS; - /* parse options to the end of the received packet */ - options_idx_max = p->tot_len; -again: - q = p; - while((q != NULL) && (options_idx >= q->len)) { - options_idx -= q->len; - options_idx_max -= q->len; - q = q->next; - } - if (q == NULL) { - return ERR_BUF; - } - offset = options_idx; - offset_max = options_idx_max; - options = (u8_t*)q->payload; - /* at least 1 byte to read and no end marker, then at least 3 bytes to read? */ - while((q != NULL) && (options[offset] != DHCP_OPTION_END) && (offset < offset_max)) { - u8_t op = options[offset]; - u8_t len; - u8_t decode_len = 0; - int decode_idx = -1; - u16_t val_offset = offset + 2; - /* len byte might be in the next pbuf */ - if (offset + 1 < q->len) { - len = options[offset + 1]; - } else { - len = (q->next != NULL ? ((u8_t*)q->next->payload)[0] : 0); - } - /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */ - decode_len = len; - switch(op) { - /* case(DHCP_OPTION_END): handled above */ - case(DHCP_OPTION_PAD): - /* special option: no len encoded */ - decode_len = len = 0; - /* will be increased below */ - offset--; - break; - case(DHCP_OPTION_SUBNET_MASK): - LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_SUBNET_MASK; - break; - case(DHCP_OPTION_ROUTER): - decode_len = 4; /* only copy the first given router */ - LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_ROUTER; - break; - case(DHCP_OPTION_DNS_SERVER): - /* special case: there might be more than one server */ - LWIP_ERROR("len % 4 == 0", len % 4 == 0, return ERR_VAL;); - /* limit number of DNS servers */ - decode_len = LWIP_MIN(len, 4 * DNS_MAX_SERVERS); - LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_DNS_SERVER; - break; - case(DHCP_OPTION_LEASE_TIME): - LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_LEASE_TIME; - break; - case(DHCP_OPTION_OVERLOAD): - LWIP_ERROR("len == 1", len == 1, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_OVERLOAD; - break; - case(DHCP_OPTION_MESSAGE_TYPE): - LWIP_ERROR("len == 1", len == 1, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_MSG_TYPE; - break; - case(DHCP_OPTION_SERVER_ID): - LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_SERVER_ID; - break; - case(DHCP_OPTION_T1): - LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_T1; - break; - case(DHCP_OPTION_T2): - LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); - decode_idx = DHCP_OPTION_IDX_T2; - break; - default: - decode_len = 0; - LWIP_DEBUGF(DHCP_DEBUG, ("skipping option %"U16_F" in options\n", op)); - break; - } - offset += len + 2; - if (decode_len > 0) { - u32_t value = 0; - u16_t copy_len; -decode_next: - LWIP_ASSERT("check decode_idx", decode_idx >= 0 && decode_idx < DHCP_OPTION_IDX_MAX); - if (!dhcp_option_given(dhcp, decode_idx)) { - copy_len = LWIP_MIN(decode_len, 4); - pbuf_copy_partial(q, &value, copy_len, val_offset); - if (decode_len > 4) { - /* decode more than one u32_t */ - LWIP_ERROR("decode_len % 4 == 0", decode_len % 4 == 0, return ERR_VAL;); - dhcp_got_option(dhcp, decode_idx); - dhcp_set_option_value(dhcp, decode_idx, htonl(value)); - decode_len -= 4; - val_offset += 4; - decode_idx++; - goto decode_next; - } else if (decode_len == 4) { - value = ntohl(value); - } else { - LWIP_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;); - value = ((u8_t*)&value)[0]; - } - dhcp_got_option(dhcp, decode_idx); - dhcp_set_option_value(dhcp, decode_idx, value); - } - } - if (offset >= q->len) { - offset -= q->len; - offset_max -= q->len; - if ((offset < offset_max) && offset_max) { - q = q->next; - LWIP_ASSERT("next pbuf was null", q); - options = (u8_t*)q->payload; - } else { - // We've run out of bytes, probably no end marker. Don't proceed. - break; - } - } - } - /* is this an overloaded message? */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_OVERLOAD)) { - u32_t overload = dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_OVERLOAD); - dhcp_clear_option(dhcp, DHCP_OPTION_IDX_OVERLOAD); - if (overload == DHCP_OVERLOAD_FILE) { - parse_file_as_options = 1; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("overloaded file field\n")); - } else if (overload == DHCP_OVERLOAD_SNAME) { - parse_sname_as_options = 1; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("overloaded sname field\n")); - } else if (overload == DHCP_OVERLOAD_SNAME_FILE) { - parse_sname_as_options = 1; - parse_file_as_options = 1; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("overloaded sname and file field\n")); - } else { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("invalid overload option: %d\n", (int)overload)); - } -#if LWIP_DHCP_BOOTP_FILE - if (!parse_file_as_options) { - /* only do this for ACK messages */ - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE) && - (dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE) == DHCP_ACK)) - /* copy bootp file name, don't care for sname (server hostname) */ - pbuf_copy_partial(p, dhcp->boot_file_name, DHCP_FILE_LEN-1, DHCP_FILE_OFS); - /* make sure the string is really NULL-terminated */ - dhcp->boot_file_name[DHCP_FILE_LEN-1] = 0; - } -#endif /* LWIP_DHCP_BOOTP_FILE */ - } - if (parse_file_as_options) { - /* if both are overloaded, parse file first and then sname (RFC 2131 ch. 4.1) */ - parse_file_as_options = 0; - options_idx = DHCP_FILE_OFS; - options_idx_max = DHCP_FILE_OFS + DHCP_FILE_LEN; - goto again; - } else if (parse_sname_as_options) { - parse_sname_as_options = 0; - options_idx = DHCP_SNAME_OFS; - options_idx_max = DHCP_SNAME_OFS + DHCP_SNAME_LEN; - goto again; - } - return ERR_OK; -} - -/** - * If an incoming DHCP message is in response to us, then trigger the state machine - */ -static void -dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) -{ - struct netif *netif = (struct netif *)arg; - struct dhcp *dhcp = netif->dhcp; - struct dhcp_msg *reply_msg = (struct dhcp_msg *)p->payload; - u8_t msg_type; - u8_t i; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p, - ip4_addr1_16(addr), ip4_addr2_16(addr), ip4_addr3_16(addr), ip4_addr4_16(addr), port)); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len)); - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len)); - /* prevent warnings about unused arguments */ - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(addr); - LWIP_UNUSED_ARG(port); - - LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL); - - if (p->len < DHCP_MIN_REPLY_LEN) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("DHCP reply message or pbuf too short\n")); - goto free_pbuf_and_return; - } - - if (reply_msg->op != DHCP_BOOTREPLY) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("not a DHCP reply message, but type %"U16_F"\n", (u16_t)reply_msg->op)); - goto free_pbuf_and_return; - } - /* iterate through hardware address and match against DHCP message */ - for (i = 0; i < netif->hwaddr_len; i++) { - if (netif->hwaddr[i] != reply_msg->chaddr[i]) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, - ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n", - (u16_t)i, (u16_t)netif->hwaddr[i], (u16_t)i, (u16_t)reply_msg->chaddr[i])); - goto free_pbuf_and_return; - } - } - /* match transaction ID against what we expected */ - if (ntohl(reply_msg->xid) != dhcp->xid) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, - ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",ntohl(reply_msg->xid),dhcp->xid)); - goto free_pbuf_and_return; - } - /* option fields could be unfold? */ - if (dhcp_parse_reply(dhcp, p) != ERR_OK) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, - ("problem unfolding DHCP message - too short on memory?\n")); - goto free_pbuf_and_return; - } - - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n")); - /* obtain pointer to DHCP message type */ - if (!dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE)) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("DHCP_OPTION_MESSAGE_TYPE option not found\n")); - goto free_pbuf_and_return; - } - - /* read DHCP message type */ - msg_type = (u8_t)dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE); - /* message type is DHCP ACK? */ - if (msg_type == DHCP_ACK) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_ACK received\n")); - /* in requesting state? */ - if (dhcp->state == DHCP_REQUESTING) { - dhcp_handle_ack(netif); -#if DHCP_DOES_ARP_CHECK - /* check if the acknowledged lease address is already in use */ - dhcp_check(netif); -#else - /* bind interface to the acknowledged lease address */ - dhcp_bind(netif); -#endif - } - /* already bound to the given lease address? */ - else if ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING)) { - dhcp_bind(netif); - } - } - /* received a DHCP_NAK in appropriate state? */ - else if ((msg_type == DHCP_NAK) && - ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) || - (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_NAK received\n")); - dhcp_handle_nak(netif); - } - /* received a DHCP_OFFER in DHCP_SELECTING state? */ - else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_OFFER received in DHCP_SELECTING state\n")); - dhcp->request_timeout = 0; - /* remember offered lease */ - dhcp_handle_offer(netif); - } -free_pbuf_and_return: - dhcp->msg_in = NULL; - pbuf_free(p); -} - -/** - * Create a DHCP request, fill in common headers - * - * @param netif the netif under DHCP control - * @param dhcp dhcp control struct - * @param message_type message type of the request - */ -static err_t -dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type) -{ - u16_t i; -#ifndef DHCP_GLOBAL_XID - /** default global transaction identifier starting value (easy to match - * with a packet analyser). We simply increment for each new request. - * Predefine DHCP_GLOBAL_XID to a better value or a function call to generate one - * at runtime, any supporting function prototypes can be defined in DHCP_GLOBAL_XID_HEADER */ -#if DHCP_CREATE_RAND_XID && defined(LWIP_RAND) - static u32_t xid; -#else /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ - static u32_t xid = 0xABCD0000; -#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ -#else - if (!xid_initialised) { - xid = DHCP_GLOBAL_XID; - xid_initialised = !xid_initialised; - } -#endif - LWIP_ERROR("dhcp_create_msg: netif != NULL", (netif != NULL), return ERR_ARG;); - LWIP_ERROR("dhcp_create_msg: dhcp != NULL", (dhcp != NULL), return ERR_VAL;); - LWIP_ASSERT("dhcp_create_msg: dhcp->p_out == NULL", dhcp->p_out == NULL); - LWIP_ASSERT("dhcp_create_msg: dhcp->msg_out == NULL", dhcp->msg_out == NULL); - dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM); - if (dhcp->p_out == NULL) { - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, - ("dhcp_create_msg(): could not allocate pbuf\n")); - return ERR_MEM; - } - LWIP_ASSERT("dhcp_create_msg: check that first pbuf can hold struct dhcp_msg", - (dhcp->p_out->len >= sizeof(struct dhcp_msg))); - - /* reuse transaction identifier in retransmissions */ - if (dhcp->tries == 0) { -#if DHCP_CREATE_RAND_XID && defined(LWIP_RAND) - xid = LWIP_RAND(); -#else /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ - xid++; -#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */ - } - dhcp->xid = xid; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, - ("transaction id xid(%"X32_F")\n", xid)); - - dhcp->msg_out = (struct dhcp_msg *)dhcp->p_out->payload; - - dhcp->msg_out->op = DHCP_BOOTREQUEST; - /* TODO: make link layer independent */ - dhcp->msg_out->htype = DHCP_HTYPE_ETH; - dhcp->msg_out->hlen = netif->hwaddr_len; - dhcp->msg_out->hops = 0; - dhcp->msg_out->xid = htonl(dhcp->xid); - dhcp->msg_out->secs = 0; - /* we don't need the broadcast flag since we can receive unicast traffic - before being fully configured! */ - dhcp->msg_out->flags = 0; - ip_addr_set_zero(&dhcp->msg_out->ciaddr); - /* set ciaddr to netif->ip_addr based on message_type and state */ - if ((message_type == DHCP_INFORM) || (message_type == DHCP_DECLINE) || - ((message_type == DHCP_REQUEST) && /* DHCP_BOUND not used for sending! */ - ((dhcp->state==DHCP_RENEWING) || dhcp->state==DHCP_REBINDING))) { - ip_addr_copy(dhcp->msg_out->ciaddr, netif->ip_addr); - } - ip_addr_set_zero(&dhcp->msg_out->yiaddr); - ip_addr_set_zero(&dhcp->msg_out->siaddr); - ip_addr_set_zero(&dhcp->msg_out->giaddr); - for (i = 0; i < DHCP_CHADDR_LEN; i++) { - /* copy netif hardware address, pad with zeroes */ - dhcp->msg_out->chaddr[i] = (i < netif->hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/; - } - for (i = 0; i < DHCP_SNAME_LEN; i++) { - dhcp->msg_out->sname[i] = 0; - } - for (i = 0; i < DHCP_FILE_LEN; i++) { - dhcp->msg_out->file[i] = 0; - } - dhcp->msg_out->cookie = PP_HTONL(DHCP_MAGIC_COOKIE); - dhcp->options_out_len = 0; - /* fill options field with an incrementing array (for debugging purposes) */ - for (i = 0; i < DHCP_OPTIONS_LEN; i++) { - dhcp->msg_out->options[i] = (u8_t)i; /* for debugging only, no matter if truncated */ - } - /* Add option MESSAGE_TYPE */ - dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); - dhcp_option_byte(dhcp, message_type); - return ERR_OK; -} - -/** - * Free previously allocated memory used to send a DHCP request. - * - * @param dhcp the dhcp struct to free the request from - */ -static void -dhcp_delete_msg(struct dhcp *dhcp) -{ - LWIP_ERROR("dhcp_delete_msg: dhcp != NULL", (dhcp != NULL), return;); - LWIP_ASSERT("dhcp_delete_msg: dhcp->p_out != NULL", dhcp->p_out != NULL); - LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL); - if (dhcp->p_out != NULL) { - pbuf_free(dhcp->p_out); - } - dhcp->p_out = NULL; - dhcp->msg_out = NULL; -} - -/** - * Add a DHCP message trailer - * - * Adds the END option to the DHCP message, and if - * necessary, up to three padding bytes. - * - * @param dhcp DHCP state structure - */ -static void -dhcp_option_trailer(struct dhcp *dhcp) -{ - LWIP_ERROR("dhcp_option_trailer: dhcp != NULL", (dhcp != NULL), return;); - LWIP_ASSERT("dhcp_option_trailer: dhcp->msg_out != NULL\n", dhcp->msg_out != NULL); - LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END; - /* packet is too small, or not 4 byte aligned? */ - while (((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) && - (dhcp->options_out_len < DHCP_OPTIONS_LEN)) { - /* add a fill/padding byte */ - dhcp->msg_out->options[dhcp->options_out_len++] = 0; - } -} - -#endif /* LWIP_DHCP */ diff --git a/user/mpy/lib/lwip/src/core/dns.c b/user/mpy/lib/lwip/src/core/dns.c deleted file mode 100644 index d633612..0000000 --- a/user/mpy/lib/lwip/src/core/dns.c +++ /dev/null @@ -1,970 +0,0 @@ -/** - * @file - * DNS - host name to IP address resolver. - * - */ - -/** - - * This file implements a DNS host name to IP address resolver. - - * Port to lwIP from uIP - * by Jim Pettinato April 2007 - - * uIP version Copyright (c) 2002-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * DNS.C - * - * The lwIP DNS resolver functions are used to lookup a host name and - * map it to a numerical IP address. It maintains a list of resolved - * hostnames that can be queried with the dns_lookup() function. - * New hostnames can be resolved using the dns_query() function. - * - * The lwIP version of the resolver also adds a non-blocking version of - * gethostbyname() that will work with a raw API application. This function - * checks for an IP address string first and converts it if it is valid. - * gethostbyname() then does a dns_lookup() to see if the name is - * already in the table. If so, the IP is returned. If not, a query is - * issued and the function returns with a ERR_INPROGRESS status. The app - * using the dns client must then go into a waiting state. - * - * Once a hostname has been resolved (or found to be non-existent), - * the resolver code calls a specified callback function (which - * must be implemented by the module that uses the resolver). - */ - -/*----------------------------------------------------------------------------- - * RFC 1035 - Domain names - implementation and specification - * RFC 2181 - Clarifications to the DNS Specification - *----------------------------------------------------------------------------*/ - -/** @todo: define good default values (rfc compliance) */ -/** @todo: improve answer parsing, more checkings... */ -/** @todo: check RFC1035 - 7.3. Processing responses */ - -/*----------------------------------------------------------------------------- - * Includes - *----------------------------------------------------------------------------*/ - -#include "lwip/opt.h" - -#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/udp.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/dns.h" - -#include - -/** DNS server IP address */ -#ifndef DNS_SERVER_ADDRESS -#define DNS_SERVER_ADDRESS(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("208.67.222.222"))) /* resolver1.opendns.com */ -#endif - -/** DNS server port address */ -#ifndef DNS_SERVER_PORT -#define DNS_SERVER_PORT 53 -#endif - -/** DNS maximum number of retries when asking for a name, before "timeout". */ -#ifndef DNS_MAX_RETRIES -#define DNS_MAX_RETRIES 4 -#endif - -/** DNS resource record max. TTL (one week as default) */ -#ifndef DNS_MAX_TTL -#define DNS_MAX_TTL 604800 -#endif - -/* DNS protocol flags */ -#define DNS_FLAG1_RESPONSE 0x80 -#define DNS_FLAG1_OPCODE_STATUS 0x10 -#define DNS_FLAG1_OPCODE_INVERSE 0x08 -#define DNS_FLAG1_OPCODE_STANDARD 0x00 -#define DNS_FLAG1_AUTHORATIVE 0x04 -#define DNS_FLAG1_TRUNC 0x02 -#define DNS_FLAG1_RD 0x01 -#define DNS_FLAG2_RA 0x80 -#define DNS_FLAG2_ERR_MASK 0x0f -#define DNS_FLAG2_ERR_NONE 0x00 -#define DNS_FLAG2_ERR_NAME 0x03 - -/* DNS protocol states */ -#define DNS_STATE_UNUSED 0 -#define DNS_STATE_NEW 1 -#define DNS_STATE_ASKING 2 -#define DNS_STATE_DONE 3 - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** DNS message header */ -struct dns_hdr { - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FIELD(u8_t flags1); - PACK_STRUCT_FIELD(u8_t flags2); - PACK_STRUCT_FIELD(u16_t numquestions); - PACK_STRUCT_FIELD(u16_t numanswers); - PACK_STRUCT_FIELD(u16_t numauthrr); - PACK_STRUCT_FIELD(u16_t numextrarr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif -#define SIZEOF_DNS_HDR 12 - -/** DNS query message structure. - No packing needed: only used locally on the stack. */ -struct dns_query { - /* DNS query record starts with either a domain name or a pointer - to a name already present somewhere in the packet. */ - u16_t type; - u16_t cls; -}; -#define SIZEOF_DNS_QUERY 4 - -/** DNS answer message structure. - No packing needed: only used locally on the stack. */ -struct dns_answer { - /* DNS answer record starts with either a domain name or a pointer - to a name already present somewhere in the packet. */ - u16_t type; - u16_t cls; - u32_t ttl; - u16_t len; -}; -#define SIZEOF_DNS_ANSWER 10 - -/** DNS table entry */ -struct dns_table_entry { - u8_t state; - u8_t numdns; - u8_t tmr; - u8_t retries; - u8_t seqno; - u8_t err; - u32_t ttl; - char name[DNS_MAX_NAME_LENGTH]; - ip_addr_t ipaddr; - /* pointer to callback on DNS query done */ - dns_found_callback found; - void *arg; -}; - -#if DNS_LOCAL_HOSTLIST - -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC -/** Local host-list. For hostnames in this list, no - * external name resolution is performed */ -static struct local_hostlist_entry *local_hostlist_dynamic; -#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -/** Defining this allows the local_hostlist_static to be placed in a different - * linker section (e.g. FLASH) */ -#ifndef DNS_LOCAL_HOSTLIST_STORAGE_PRE -#define DNS_LOCAL_HOSTLIST_STORAGE_PRE static -#endif /* DNS_LOCAL_HOSTLIST_STORAGE_PRE */ -/** Defining this allows the local_hostlist_static to be placed in a different - * linker section (e.g. FLASH) */ -#ifndef DNS_LOCAL_HOSTLIST_STORAGE_POST -#define DNS_LOCAL_HOSTLIST_STORAGE_POST -#endif /* DNS_LOCAL_HOSTLIST_STORAGE_POST */ -DNS_LOCAL_HOSTLIST_STORAGE_PRE struct local_hostlist_entry local_hostlist_static[] - DNS_LOCAL_HOSTLIST_STORAGE_POST = DNS_LOCAL_HOSTLIST_INIT; - -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -static void dns_init_local(); -#endif /* DNS_LOCAL_HOSTLIST */ - - -/* forward declarations */ -static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); -static void dns_check_entries(void); - -/*----------------------------------------------------------------------------- - * Globales - *----------------------------------------------------------------------------*/ - -/* DNS variables */ -static struct udp_pcb *dns_pcb; -static u8_t dns_seqno; -static struct dns_table_entry dns_table[DNS_TABLE_SIZE]; -static ip_addr_t dns_servers[DNS_MAX_SERVERS]; -/** Contiguous buffer for processing responses */ -static u8_t dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)]; -static u8_t* dns_payload; - -/** - * Initialize the resolver: set up the UDP pcb and configure the default server - * (DNS_SERVER_ADDRESS). - */ -void -dns_init() -{ - ip_addr_t dnsserver; - - dns_payload = (u8_t *)LWIP_MEM_ALIGN(dns_payload_buffer); - - /* initialize default DNS server address */ - DNS_SERVER_ADDRESS(&dnsserver); - - LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n")); - - /* if dns client not yet initialized... */ - if (dns_pcb == NULL) { - dns_pcb = udp_new(); - - if (dns_pcb != NULL) { - /* initialize DNS table not needed (initialized to zero since it is a - * global variable) */ - LWIP_ASSERT("For implicit initialization to work, DNS_STATE_UNUSED needs to be 0", - DNS_STATE_UNUSED == 0); - - /* initialize DNS client */ - udp_bind(dns_pcb, IP_ADDR_ANY, 0); - udp_recv(dns_pcb, dns_recv, NULL); - - /* initialize default DNS primary server */ - dns_setserver(0, &dnsserver); - } - } -#if DNS_LOCAL_HOSTLIST - dns_init_local(); -#endif -} - -/** - * Initialize one of the DNS servers. - * - * @param numdns the index of the DNS server to set must be < DNS_MAX_SERVERS - * @param dnsserver IP address of the DNS server to set - */ -void -dns_setserver(u8_t numdns, ip_addr_t *dnsserver) -{ - if ((numdns < DNS_MAX_SERVERS) && (dns_pcb != NULL) && - (dnsserver != NULL) && !ip_addr_isany(dnsserver)) { - dns_servers[numdns] = (*dnsserver); - } -} - -/** - * Obtain one of the currently configured DNS server. - * - * @param numdns the index of the DNS server - * @return IP address of the indexed DNS server or "ip_addr_any" if the DNS - * server has not been configured. - */ -ip_addr_t -dns_getserver(u8_t numdns) -{ - if (numdns < DNS_MAX_SERVERS) { - return dns_servers[numdns]; - } else { - return *IP_ADDR_ANY; - } -} - -/** - * The DNS resolver client timer - handle retries and timeouts and should - * be called every DNS_TMR_INTERVAL milliseconds (every second by default). - */ -void -dns_tmr(void) -{ - if (dns_pcb != NULL) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_tmr: dns_check_entries\n")); - dns_check_entries(); - } -} - -#if DNS_LOCAL_HOSTLIST -static void -dns_init_local() -{ -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) - int i; - struct local_hostlist_entry *entry; - /* Dynamic: copy entries from DNS_LOCAL_HOSTLIST_INIT to list */ - struct local_hostlist_entry local_hostlist_init[] = DNS_LOCAL_HOSTLIST_INIT; - size_t namelen; - for (i = 0; i < sizeof(local_hostlist_init) / sizeof(struct local_hostlist_entry); i++) { - struct local_hostlist_entry *init_entry = &local_hostlist_init[i]; - LWIP_ASSERT("invalid host name (NULL)", init_entry->name != NULL); - namelen = strlen(init_entry->name); - LWIP_ASSERT("namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN", namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN); - entry = (struct local_hostlist_entry *)memp_malloc(MEMP_LOCALHOSTLIST); - LWIP_ASSERT("mem-error in dns_init_local", entry != NULL); - if (entry != NULL) { - entry->name = (char*)entry + sizeof(struct local_hostlist_entry); - MEMCPY((char*)entry->name, init_entry->name, namelen); - ((char*)entry->name)[namelen] = 0; - entry->addr = init_entry->addr; - entry->next = local_hostlist_dynamic; - local_hostlist_dynamic = entry; - } - } -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) */ -} - -/** - * Scans the local host-list for a hostname. - * - * @param hostname Hostname to look for in the local host-list - * @return The first IP address for the hostname in the local host-list or - * IPADDR_NONE if not found. - */ -static u32_t -dns_lookup_local(const char *hostname) -{ -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC - struct local_hostlist_entry *entry = local_hostlist_dynamic; - while(entry != NULL) { - if(strcmp(entry->name, hostname) == 0) { - return ip4_addr_get_u32(&entry->addr); - } - entry = entry->next; - } -#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - int i; - for (i = 0; i < sizeof(local_hostlist_static) / sizeof(struct local_hostlist_entry); i++) { - if(strcmp(local_hostlist_static[i].name, hostname) == 0) { - return ip4_addr_get_u32(&local_hostlist_static[i].addr); - } - } -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - return IPADDR_NONE; -} - -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC -/** Remove all entries from the local host-list for a specific hostname - * and/or IP addess - * - * @param hostname hostname for which entries shall be removed from the local - * host-list - * @param addr address for which entries shall be removed from the local host-list - * @return the number of removed entries - */ -int -dns_local_removehost(const char *hostname, const ip_addr_t *addr) -{ - int removed = 0; - struct local_hostlist_entry *entry = local_hostlist_dynamic; - struct local_hostlist_entry *last_entry = NULL; - while (entry != NULL) { - if (((hostname == NULL) || !strcmp(entry->name, hostname)) && - ((addr == NULL) || ip_addr_cmp(&entry->addr, addr))) { - struct local_hostlist_entry *free_entry; - if (last_entry != NULL) { - last_entry->next = entry->next; - } else { - local_hostlist_dynamic = entry->next; - } - free_entry = entry; - entry = entry->next; - memp_free(MEMP_LOCALHOSTLIST, free_entry); - removed++; - } else { - last_entry = entry; - entry = entry->next; - } - } - return removed; -} - -/** - * Add a hostname/IP address pair to the local host-list. - * Duplicates are not checked. - * - * @param hostname hostname of the new entry - * @param addr IP address of the new entry - * @return ERR_OK if succeeded or ERR_MEM on memory error - */ -err_t -dns_local_addhost(const char *hostname, const ip_addr_t *addr) -{ - struct local_hostlist_entry *entry; - size_t namelen; - LWIP_ASSERT("invalid host name (NULL)", hostname != NULL); - namelen = strlen(hostname); - LWIP_ASSERT("namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN", namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN); - entry = (struct local_hostlist_entry *)memp_malloc(MEMP_LOCALHOSTLIST); - if (entry == NULL) { - return ERR_MEM; - } - entry->name = (char*)entry + sizeof(struct local_hostlist_entry); - MEMCPY((char*)entry->name, hostname, namelen); - ((char*)entry->name)[namelen] = 0; - ip_addr_copy(entry->addr, *addr); - entry->next = local_hostlist_dynamic; - local_hostlist_dynamic = entry; - return ERR_OK; -} -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC*/ -#endif /* DNS_LOCAL_HOSTLIST */ - -/** - * Look up a hostname in the array of known hostnames. - * - * @note This function only looks in the internal array of known - * hostnames, it does not send out a query for the hostname if none - * was found. The function dns_enqueue() can be used to send a query - * for a hostname. - * - * @param name the hostname to look up - * @return the hostname's IP address, as u32_t (instead of ip_addr_t to - * better check for failure: != IPADDR_NONE) or IPADDR_NONE if the hostname - * was not found in the cached dns_table. - */ -static u32_t -dns_lookup(const char *name) -{ - u8_t i; -#if DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) - u32_t addr; -#endif /* DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) */ -#if DNS_LOCAL_HOSTLIST - if ((addr = dns_lookup_local(name)) != IPADDR_NONE) { - return addr; - } -#endif /* DNS_LOCAL_HOSTLIST */ -#ifdef DNS_LOOKUP_LOCAL_EXTERN - if((addr = DNS_LOOKUP_LOCAL_EXTERN(name)) != IPADDR_NONE) { - return addr; - } -#endif /* DNS_LOOKUP_LOCAL_EXTERN */ - - /* Walk through name list, return entry if found. If not, return NULL. */ - for (i = 0; i < DNS_TABLE_SIZE; ++i) { - if ((dns_table[i].state == DNS_STATE_DONE) && - (strcmp(name, dns_table[i].name) == 0)) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_lookup: \"%s\": found = ", name)); - ip_addr_debug_print(DNS_DEBUG, &(dns_table[i].ipaddr)); - LWIP_DEBUGF(DNS_DEBUG, ("\n")); - return ip4_addr_get_u32(&dns_table[i].ipaddr); - } - } - - return IPADDR_NONE; -} - -#if DNS_DOES_NAME_CHECK -/** - * Compare the "dotted" name "query" with the encoded name "response" - * to make sure an answer from the DNS server matches the current dns_table - * entry (otherwise, answers might arrive late for hostname not on the list - * any more). - * - * @param query hostname (not encoded) from the dns_table - * @param response encoded hostname in the DNS response - * @return 0: names equal; 1: names differ - */ -static u8_t -dns_compare_name(unsigned char *query, unsigned char *response) -{ - unsigned char n; - - do { - n = *response++; - /** @see RFC 1035 - 4.1.4. Message compression */ - if ((n & 0xc0) == 0xc0) { - /* Compressed name */ - break; - } else { - /* Not compressed name */ - while (n > 0) { - if ((*query) != (*response)) { - return 1; - } - ++response; - ++query; - --n; - }; - ++query; - } - } while (*response != 0); - - return 0; -} -#endif /* DNS_DOES_NAME_CHECK */ - -/** - * Walk through a compact encoded DNS name and return the end of the name. - * - * @param query encoded DNS name in the DNS server response - * @return end of the name - */ -static unsigned char * -dns_parse_name(unsigned char *query) -{ - unsigned char n; - - do { - n = *query++; - /** @see RFC 1035 - 4.1.4. Message compression */ - if ((n & 0xc0) == 0xc0) { - /* Compressed name */ - break; - } else { - /* Not compressed name */ - while (n > 0) { - ++query; - --n; - }; - } - } while (*query != 0); - - return query + 1; -} - -/** - * Send a DNS query packet. - * - * @param numdns index of the DNS server in the dns_servers table - * @param name hostname to query - * @param id index of the hostname in dns_table, used as transaction ID in the - * DNS query packet - * @return ERR_OK if packet is sent; an err_t indicating the problem otherwise - */ -static err_t -dns_send(u8_t numdns, const char* name, u8_t id) -{ - err_t err; - struct dns_hdr *hdr; - struct dns_query qry; - struct pbuf *p; - char *query, *nptr; - const char *pHostname; - u8_t n; - - LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n", - (u16_t)(numdns), name)); - LWIP_ASSERT("dns server out of array", numdns < DNS_MAX_SERVERS); - LWIP_ASSERT("dns server has no IP address set", !ip_addr_isany(&dns_servers[numdns])); - - /* if here, we have either a new query or a retry on a previous query to process */ - p = pbuf_alloc(PBUF_TRANSPORT, SIZEOF_DNS_HDR + DNS_MAX_NAME_LENGTH + - SIZEOF_DNS_QUERY, PBUF_RAM); - if (p != NULL) { - LWIP_ASSERT("pbuf must be in one piece", p->next == NULL); - /* fill dns header */ - hdr = (struct dns_hdr*)p->payload; - memset(hdr, 0, SIZEOF_DNS_HDR); - hdr->id = htons(id); - hdr->flags1 = DNS_FLAG1_RD; - hdr->numquestions = PP_HTONS(1); - query = (char*)hdr + SIZEOF_DNS_HDR; - pHostname = name; - --pHostname; - - /* convert hostname into suitable query format. */ - do { - ++pHostname; - nptr = query; - ++query; - for(n = 0; *pHostname != '.' && *pHostname != 0; ++pHostname) { - *query = *pHostname; - ++query; - ++n; - } - *nptr = n; - } while(*pHostname != 0); - *query++='\0'; - - /* fill dns query */ - qry.type = PP_HTONS(DNS_RRTYPE_A); - qry.cls = PP_HTONS(DNS_RRCLASS_IN); - SMEMCPY(query, &qry, SIZEOF_DNS_QUERY); - - /* resize pbuf to the exact dns query */ - pbuf_realloc(p, (u16_t)((query + SIZEOF_DNS_QUERY) - ((char*)(p->payload)))); - - /* connect to the server for faster receiving */ - udp_connect(dns_pcb, &dns_servers[numdns], DNS_SERVER_PORT); - /* send dns packet */ - err = udp_sendto(dns_pcb, p, &dns_servers[numdns], DNS_SERVER_PORT); - - /* free pbuf */ - pbuf_free(p); - } else { - err = ERR_MEM; - } - - return err; -} - -/** - * dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query. - * Check an entry in the dns_table: - * - send out query for new entries - * - retry old pending entries on timeout (also with different servers) - * - remove completed entries from the table if their TTL has expired - * - * @param i index of the dns_table entry to check - */ -static void -dns_check_entry(u8_t i) -{ - err_t err; - struct dns_table_entry *pEntry = &dns_table[i]; - - LWIP_ASSERT("array index out of bounds", i < DNS_TABLE_SIZE); - - switch(pEntry->state) { - - case DNS_STATE_NEW: { - /* initialize new entry */ - pEntry->state = DNS_STATE_ASKING; - pEntry->numdns = 0; - pEntry->tmr = 1; - pEntry->retries = 0; - - /* send DNS packet for this entry */ - err = dns_send(pEntry->numdns, pEntry->name, i); - if (err != ERR_OK) { - LWIP_DEBUGF(DNS_DEBUG | LWIP_DBG_LEVEL_WARNING, - ("dns_send returned error: %s\n", lwip_strerr(err))); - } - break; - } - - case DNS_STATE_ASKING: { - if (--pEntry->tmr == 0) { - if (++pEntry->retries == DNS_MAX_RETRIES) { - if ((pEntry->numdns+1numdns+1])) { - /* change of server */ - pEntry->numdns++; - pEntry->tmr = 1; - pEntry->retries = 0; - break; - } else { - LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n", pEntry->name)); - /* call specified callback function if provided */ - if (pEntry->found) - (*pEntry->found)(pEntry->name, NULL, pEntry->arg); - /* flush this entry */ - pEntry->state = DNS_STATE_UNUSED; - pEntry->found = NULL; - break; - } - } - - /* wait longer for the next retry */ - pEntry->tmr = pEntry->retries; - - /* send DNS packet for this entry */ - err = dns_send(pEntry->numdns, pEntry->name, i); - if (err != ERR_OK) { - LWIP_DEBUGF(DNS_DEBUG | LWIP_DBG_LEVEL_WARNING, - ("dns_send returned error: %s\n", lwip_strerr(err))); - } - } - break; - } - - case DNS_STATE_DONE: { - /* if the time to live is nul */ - if (--pEntry->ttl == 0) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name)); - /* flush this entry */ - pEntry->state = DNS_STATE_UNUSED; - pEntry->found = NULL; - } - break; - } - case DNS_STATE_UNUSED: - /* nothing to do */ - break; - default: - LWIP_ASSERT("unknown dns_table entry state:", 0); - break; - } -} - -/** - * Call dns_check_entry for each entry in dns_table - check all entries. - */ -static void -dns_check_entries(void) -{ - u8_t i; - - for (i = 0; i < DNS_TABLE_SIZE; ++i) { - dns_check_entry(i); - } -} - -/** - * Receive input function for DNS response packets arriving for the dns UDP pcb. - * - * @params see udp.h - */ -static void -dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) -{ - u16_t i; - char *pHostname; - struct dns_hdr *hdr; - struct dns_answer ans; - struct dns_table_entry *pEntry; - u16_t nquestions, nanswers; - - LWIP_UNUSED_ARG(arg); - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(addr); - LWIP_UNUSED_ARG(port); - - /* is the dns message too big ? */ - if (p->tot_len > DNS_MSG_SIZE) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too big\n")); - /* free pbuf and return */ - goto memerr; - } - - /* is the dns message big enough ? */ - if (p->tot_len < (SIZEOF_DNS_HDR + SIZEOF_DNS_QUERY + SIZEOF_DNS_ANSWER)) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too small\n")); - /* free pbuf and return */ - goto memerr; - } - - /* copy dns payload inside static buffer for processing */ - if (pbuf_copy_partial(p, dns_payload, p->tot_len, 0) == p->tot_len) { - /* The ID in the DNS header should be our entry into the name table. */ - hdr = (struct dns_hdr*)dns_payload; - i = htons(hdr->id); - if (i < DNS_TABLE_SIZE) { - pEntry = &dns_table[i]; - if(pEntry->state == DNS_STATE_ASKING) { - /* This entry is now completed. */ - pEntry->state = DNS_STATE_DONE; - pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK; - - /* We only care about the question(s) and the answers. The authrr - and the extrarr are simply discarded. */ - nquestions = htons(hdr->numquestions); - nanswers = htons(hdr->numanswers); - - /* Check for error. If so, call callback to inform. */ - if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (pEntry->err != 0) || (nquestions != 1)) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", pEntry->name)); - /* call callback to indicate error, clean up memory and return */ - goto responseerr; - } - -#if DNS_DOES_NAME_CHECK - /* Check if the name in the "question" part match with the name in the entry. */ - if (dns_compare_name((unsigned char *)(pEntry->name), (unsigned char *)dns_payload + SIZEOF_DNS_HDR) != 0) { - LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", pEntry->name)); - /* call callback to indicate error, clean up memory and return */ - goto responseerr; - } -#endif /* DNS_DOES_NAME_CHECK */ - - /* Skip the name in the "question" part */ - pHostname = (char *) dns_parse_name((unsigned char *)dns_payload + SIZEOF_DNS_HDR) + SIZEOF_DNS_QUERY; - - while (nanswers > 0) { - /* skip answer resource record's host name */ - pHostname = (char *) dns_parse_name((unsigned char *)pHostname); - - /* Check for IP address type and Internet class. Others are discarded. */ - SMEMCPY(&ans, pHostname, SIZEOF_DNS_ANSWER); - if((ans.type == PP_HTONS(DNS_RRTYPE_A)) && (ans.cls == PP_HTONS(DNS_RRCLASS_IN)) && - (ans.len == PP_HTONS(sizeof(ip_addr_t))) ) { - /* read the answer resource record's TTL, and maximize it if needed */ - pEntry->ttl = ntohl(ans.ttl); - if (pEntry->ttl > DNS_MAX_TTL) { - pEntry->ttl = DNS_MAX_TTL; - } - /* read the IP address after answer resource record's header */ - SMEMCPY(&(pEntry->ipaddr), (pHostname+SIZEOF_DNS_ANSWER), sizeof(ip_addr_t)); - LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", pEntry->name)); - ip_addr_debug_print(DNS_DEBUG, (&(pEntry->ipaddr))); - LWIP_DEBUGF(DNS_DEBUG, ("\n")); - /* call specified callback function if provided */ - if (pEntry->found) { - (*pEntry->found)(pEntry->name, &pEntry->ipaddr, pEntry->arg); - } - /* deallocate memory and return */ - goto memerr; - } else { - pHostname = pHostname + SIZEOF_DNS_ANSWER + htons(ans.len); - } - --nanswers; - } - LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", pEntry->name)); - /* call callback to indicate error, clean up memory and return */ - goto responseerr; - } - } - } - - /* deallocate memory and return */ - goto memerr; - -responseerr: - /* ERROR: call specified callback function with NULL as name to indicate an error */ - if (pEntry->found) { - (*pEntry->found)(pEntry->name, NULL, pEntry->arg); - } - /* flush this entry */ - pEntry->state = DNS_STATE_UNUSED; - pEntry->found = NULL; - -memerr: - /* free pbuf */ - pbuf_free(p); - return; -} - -/** - * Queues a new hostname to resolve and sends out a DNS query for that hostname - * - * @param name the hostname that is to be queried - * @param found a callback founction to be called on success, failure or timeout - * @param callback_arg argument to pass to the callback function - * @return @return a err_t return code. - */ -static err_t -dns_enqueue(const char *name, dns_found_callback found, void *callback_arg) -{ - u8_t i; - u8_t lseq, lseqi; - struct dns_table_entry *pEntry = NULL; - size_t namelen; - - /* search an unused entry, or the oldest one */ - lseq = lseqi = 0; - for (i = 0; i < DNS_TABLE_SIZE; ++i) { - pEntry = &dns_table[i]; - /* is it an unused entry ? */ - if (pEntry->state == DNS_STATE_UNUSED) - break; - - /* check if this is the oldest completed entry */ - if (pEntry->state == DNS_STATE_DONE) { - if ((dns_seqno - pEntry->seqno) > lseq) { - lseq = dns_seqno - pEntry->seqno; - lseqi = i; - } - } - } - - /* if we don't have found an unused entry, use the oldest completed one */ - if (i == DNS_TABLE_SIZE) { - if ((lseqi >= DNS_TABLE_SIZE) || (dns_table[lseqi].state != DNS_STATE_DONE)) { - /* no entry can't be used now, table is full */ - LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": DNS entries table is full\n", name)); - return ERR_MEM; - } else { - /* use the oldest completed one */ - i = lseqi; - pEntry = &dns_table[i]; - } - } - - /* use this entry */ - LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": use DNS entry %"U16_F"\n", name, (u16_t)(i))); - - /* fill the entry */ - pEntry->state = DNS_STATE_NEW; - pEntry->seqno = dns_seqno++; - pEntry->found = found; - pEntry->arg = callback_arg; - namelen = LWIP_MIN(strlen(name), DNS_MAX_NAME_LENGTH-1); - MEMCPY(pEntry->name, name, namelen); - pEntry->name[namelen] = 0; - - /* force to send query without waiting timer */ - dns_check_entry(i); - - /* dns query is enqueued */ - return ERR_INPROGRESS; -} - -/** - * Resolve a hostname (string) into an IP address. - * NON-BLOCKING callback version for use with raw API!!! - * - * Returns immediately with one of err_t return codes: - * - ERR_OK if hostname is a valid IP address string or the host - * name is already in the local names table. - * - ERR_INPROGRESS enqueue a request to be sent to the DNS server - * for resolution if no errors are present. - * - ERR_ARG: dns client not initialized or invalid hostname - * - * @param hostname the hostname that is to be queried - * @param addr pointer to a ip_addr_t where to store the address if it is already - * cached in the dns_table (only valid if ERR_OK is returned!) - * @param found a callback function to be called on success, failure or timeout (only if - * ERR_INPROGRESS is returned!) - * @param callback_arg argument to pass to the callback function - * @return a err_t return code. - */ -err_t -dns_gethostbyname(const char *hostname, ip_addr_t *addr, dns_found_callback found, - void *callback_arg) -{ - u32_t ipaddr; - /* not initialized or no valid server yet, or invalid addr pointer - * or invalid hostname or invalid hostname length */ - if ((dns_pcb == NULL) || (addr == NULL) || - (!hostname) || (!hostname[0]) || - (strlen(hostname) >= DNS_MAX_NAME_LENGTH)) { - return ERR_ARG; - } - -#if LWIP_HAVE_LOOPIF - if (strcmp(hostname, "localhost")==0) { - ip_addr_set_loopback(addr); - return ERR_OK; - } -#endif /* LWIP_HAVE_LOOPIF */ - - /* host name already in octet notation? set ip addr and return ERR_OK */ - ipaddr = ipaddr_addr(hostname); - if (ipaddr == IPADDR_NONE) { - /* already have this address cached? */ - ipaddr = dns_lookup(hostname); - } - if (ipaddr != IPADDR_NONE) { - ip4_addr_set_u32(addr, ipaddr); - return ERR_OK; - } - - /* queue query with specified callback */ - return dns_enqueue(hostname, found, callback_arg); -} - -#endif /* LWIP_DNS */ diff --git a/user/mpy/lib/lwip/src/core/init.c b/user/mpy/lib/lwip/src/core/init.c deleted file mode 100644 index a7b15a7..0000000 --- a/user/mpy/lib/lwip/src/core/init.c +++ /dev/null @@ -1,332 +0,0 @@ -/** - * @file - * Modules initialization - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/init.h" -#include "lwip/stats.h" -#include "lwip/sys.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/sockets.h" -#include "lwip/ip.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcp_impl.h" -#include "lwip/snmp_msg.h" -#include "lwip/autoip.h" -#include "lwip/igmp.h" -#include "lwip/dns.h" -#include "lwip/timers.h" -#include "netif/etharp.h" -#include "lwip/api.h" - -/* Compile-time sanity checks for configuration errors. - * These can be done independently of LWIP_DEBUG, without penalty. - */ -#ifndef BYTE_ORDER - #error "BYTE_ORDER is not defined, you have to define it in your cc.h" -#endif -#if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV) - #error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_UDPLITE) - #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_SNMP) - #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_DHCP) - #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_IGMP) - #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_SNMP) - #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_DNS) - #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */ -#if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0)) - #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h" -#endif -#if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0)) - #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h" -#endif -#if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0)) - #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h" -#endif -#if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0)) - #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h" -#endif -#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1)) - #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h" -#endif -#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0)) - #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" -#endif -/* There must be sufficient timeouts, taking into account requirements of the subsystems. */ -#if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT)) - #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" -#endif -#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) - #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!" -#endif -#endif /* !MEMP_MEM_MALLOC */ -#if (LWIP_TCP && (TCP_WND > 0xffff)) - #error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h" -#endif -#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff)) - #error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h" -#endif -#if (LWIP_TCP && (TCP_SND_QUEUELEN < 2)) - #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work" -#endif -#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) - #error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h" -#endif -#if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)) - #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" -#endif -#if (LWIP_NETIF_API && (NO_SYS==1)) - #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h" -#endif -#if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1)) - #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h" -#endif -#if (!LWIP_NETCONN && LWIP_SOCKET) - #error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h" -#endif -#if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP) - #error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h" -#endif -#if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK) - #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h" -#endif -#if (!LWIP_ARP && LWIP_AUTOIP) - #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h" -#endif -#if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0)) - #error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h" -#endif -#if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0)) - #error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h" -#endif -#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API))) - #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h" -#endif -#if (MEM_LIBC_MALLOC && MEM_USE_POOLS) - #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h" -#endif -#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) - #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" -#endif -#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) - #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf" -#endif -#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT))) - #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST" -#endif -#if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT - #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on" -#endif -#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) - #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" -#endif -#if LWIP_IGMP && !defined(LWIP_RAND) - #error "When using IGMP, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value" -#endif -#if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING - #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too" -#endif -#if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE - #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets" -#endif -#if IP_FRAG && IP_FRAG_USES_STATIC_BUF && LWIP_NETIF_TX_SINGLE_PBUF - #error "LWIP_NETIF_TX_SINGLE_PBUF does not work with IP_FRAG_USES_STATIC_BUF==1 as that creates pbuf queues" -#endif -#if LWIP_NETCONN && LWIP_TCP -#if NETCONN_COPY != TCP_WRITE_FLAG_COPY - #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY" -#endif -#if NETCONN_MORE != TCP_WRITE_FLAG_MORE - #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" -#endif -#endif /* LWIP_NETCONN && LWIP_TCP */ -#if LWIP_SOCKET -/* Check that the SO_* socket options and SOF_* lwIP-internal flags match */ -#if SO_ACCEPTCONN != SOF_ACCEPTCONN - #error "SO_ACCEPTCONN != SOF_ACCEPTCONN" -#endif -#if SO_REUSEADDR != SOF_REUSEADDR - #error "WARNING: SO_REUSEADDR != SOF_REUSEADDR" -#endif -#if SO_KEEPALIVE != SOF_KEEPALIVE - #error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE" -#endif -#if SO_BROADCAST != SOF_BROADCAST - #error "WARNING: SO_BROADCAST != SOF_BROADCAST" -#endif -#if SO_LINGER != SOF_LINGER - #error "WARNING: SO_LINGER != SOF_LINGER" -#endif -#endif /* LWIP_SOCKET */ - - -/* Compile-time checks for deprecated options. - */ -#ifdef MEMP_NUM_TCPIP_MSG - #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef MEMP_NUM_API_MSG - #error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef TCP_REXMIT_DEBUG - #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef RAW_STATS - #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef ETHARP_QUEUE_FIRST - #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef ETHARP_ALWAYS_INSERT - #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h." -#endif - -#ifndef LWIP_DISABLE_TCP_SANITY_CHECKS -#define LWIP_DISABLE_TCP_SANITY_CHECKS 0 -#endif -#ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS -#define LWIP_DISABLE_MEMP_SANITY_CHECKS 0 -#endif - -/* MEMP sanity checks */ -#if !LWIP_DISABLE_MEMP_SANITY_CHECKS -#if LWIP_NETCONN -#if MEMP_MEM_MALLOC -#if !MEMP_NUM_NETCONN && LWIP_SOCKET -#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!" -#endif -#else /* MEMP_MEM_MALLOC */ -#if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB) -#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN should be less than the sum of MEMP_NUM_{TCP,RAW,UDP}_PCB+MEMP_NUM_TCP_PCB_LISTEN. If you know what you are doing, define LWIP_DISABLE_MEMP_SANITY_CHECKS to 1 to disable this error." -#endif -#endif /* MEMP_MEM_MALLOC */ -#endif /* LWIP_NETCONN */ -#endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */ - -/* TCP sanity checks */ -#if !LWIP_DISABLE_TCP_SANITY_CHECKS -#if LWIP_TCP -#if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN) - #error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SND_BUF < (2 * TCP_MSS) - #error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS)) - #error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SNDLOWAT >= TCP_SND_BUF - #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN - #error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if !MEMP_MEM_MALLOC && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)))) - #error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_WND < TCP_MSS - #error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#endif /* LWIP_TCP */ -#endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */ - -/** - * Perform Sanity check of user-configurable values, and initialize all modules. - */ -void -lwip_init(void) -{ - /* Modules initialization */ - stats_init(); -#if !NO_SYS - sys_init(); -#endif /* !NO_SYS */ - mem_init(); - memp_init(); - pbuf_init(); - netif_init(); -#if LWIP_SOCKET - lwip_socket_init(); -#endif /* LWIP_SOCKET */ - ip_init(); -#if LWIP_ARP - etharp_init(); -#endif /* LWIP_ARP */ -#if LWIP_RAW - raw_init(); -#endif /* LWIP_RAW */ -#if LWIP_UDP - udp_init(); -#endif /* LWIP_UDP */ -#if LWIP_TCP - tcp_init(); -#endif /* LWIP_TCP */ -#if LWIP_SNMP - snmp_init(); -#endif /* LWIP_SNMP */ -#if LWIP_AUTOIP - autoip_init(); -#endif /* LWIP_AUTOIP */ -#if LWIP_IGMP - igmp_init(); -#endif /* LWIP_IGMP */ -#if LWIP_DNS - dns_init(); -#endif /* LWIP_DNS */ - -#if LWIP_TIMERS - sys_timeouts_init(); -#endif /* LWIP_TIMERS */ -} diff --git a/user/mpy/lib/lwip/src/core/ipv4/autoip.c b/user/mpy/lib/lwip/src/core/ipv4/autoip.c deleted file mode 100644 index b122da2..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/autoip.c +++ /dev/null @@ -1,528 +0,0 @@ -/** - * @file - * AutoIP Automatic LinkLocal IP Configuration - * - */ - -/* - * - * Copyright (c) 2007 Dominik Spies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Dominik Spies - * - * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform - * with RFC 3927. - * - * - * Please coordinate changes and requests with Dominik Spies - * - */ - -/******************************************************************************* - * USAGE: - * - * define LWIP_AUTOIP 1 in your lwipopts.h - * - * If you don't use tcpip.c (so, don't call, you don't call tcpip_init): - * - First, call autoip_init(). - * - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces, - * that should be defined in autoip.h. - * I recommend a value of 100. The value must divide 1000 with a remainder almost 0. - * Possible values are 1000, 500, 333, 250, 200, 166, 142, 125, 111, 100 .... - * - * Without DHCP: - * - Call autoip_start() after netif_add(). - * - * With DHCP: - * - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h. - * - Configure your DHCP Client. - * - */ - -#include "lwip/opt.h" - -#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/mem.h" -#include "lwip/udp.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/autoip.h" -#include "netif/etharp.h" - -#include -#include - -/* 169.254.0.0 */ -#define AUTOIP_NET 0xA9FE0000 -/* 169.254.1.0 */ -#define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) -/* 169.254.254.255 */ -#define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) - - -/** Pseudo random macro based on netif informations. - * You could use "rand()" from the C Library if you define LWIP_AUTOIP_RAND in lwipopts.h */ -#ifndef LWIP_AUTOIP_RAND -#define LWIP_AUTOIP_RAND(netif) ( (((u32_t)((netif->hwaddr[5]) & 0xff) << 24) | \ - ((u32_t)((netif->hwaddr[3]) & 0xff) << 16) | \ - ((u32_t)((netif->hwaddr[2]) & 0xff) << 8) | \ - ((u32_t)((netif->hwaddr[4]) & 0xff))) + \ - (netif->autoip?netif->autoip->tried_llipaddr:0)) -#endif /* LWIP_AUTOIP_RAND */ - -/** - * Macro that generates the initial IP address to be tried by AUTOIP. - * If you want to override this, define it to something else in lwipopts.h. - */ -#ifndef LWIP_AUTOIP_CREATE_SEED_ADDR -#define LWIP_AUTOIP_CREATE_SEED_ADDR(netif) \ - htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \ - ((u32_t)((u8_t)(netif->hwaddr[5]))) << 8))) -#endif /* LWIP_AUTOIP_CREATE_SEED_ADDR */ - -/* static functions */ -static void autoip_handle_arp_conflict(struct netif *netif); - -/* creates a pseudo random LL IP-Address for a network interface */ -static void autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr); - -/* sends an ARP probe */ -static err_t autoip_arp_probe(struct netif *netif); - -/* sends an ARP announce */ -static err_t autoip_arp_announce(struct netif *netif); - -/* configure interface for use with current LL IP-Address */ -static err_t autoip_bind(struct netif *netif); - -/* start sending probes for llipaddr */ -static void autoip_start_probing(struct netif *netif); - - -/** Set a statically allocated struct autoip to work with. - * Using this prevents autoip_start to allocate it using mem_malloc. - * - * @param netif the netif for which to set the struct autoip - * @param dhcp (uninitialised) dhcp struct allocated by the application - */ -void -autoip_set_struct(struct netif *netif, struct autoip *autoip) -{ - LWIP_ASSERT("netif != NULL", netif != NULL); - LWIP_ASSERT("autoip != NULL", autoip != NULL); - LWIP_ASSERT("netif already has a struct autoip set", netif->autoip == NULL); - - /* clear data structure */ - memset(autoip, 0, sizeof(struct autoip)); - /* autoip->state = AUTOIP_STATE_OFF; */ - netif->autoip = autoip; -} - -/** Restart AutoIP client and check the next address (conflict detected) - * - * @param netif The netif under AutoIP control - */ -static void -autoip_restart(struct netif *netif) -{ - netif->autoip->tried_llipaddr++; - autoip_start(netif); -} - -/** - * Handle a IP address conflict after an ARP conflict detection - */ -static void -autoip_handle_arp_conflict(struct netif *netif) -{ - /* Somehow detect if we are defending or retreating */ - unsigned char defend = 1; /* tbd */ - - if (defend) { - if (netif->autoip->lastconflict > 0) { - /* retreat, there was a conflicting ARP in the last - * DEFEND_INTERVAL seconds - */ - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_handle_arp_conflict(): we are defending, but in DEFEND_INTERVAL, retreating\n")); - - /* TODO: close all TCP sessions */ - autoip_restart(netif); - } else { - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_handle_arp_conflict(): we are defend, send ARP Announce\n")); - autoip_arp_announce(netif); - netif->autoip->lastconflict = DEFEND_INTERVAL * AUTOIP_TICKS_PER_SECOND; - } - } else { - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_handle_arp_conflict(): we do not defend, retreating\n")); - /* TODO: close all TCP sessions */ - autoip_restart(netif); - } -} - -/** - * Create an IP-Address out of range 169.254.1.0 to 169.254.254.255 - * - * @param netif network interface on which create the IP-Address - * @param ipaddr ip address to initialize - */ -static void -autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr) -{ - /* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255 - * compliant to RFC 3927 Section 2.1 - * We have 254 * 256 possibilities */ - - u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif)); - addr += netif->autoip->tried_llipaddr; - addr = AUTOIP_NET | (addr & 0xffff); - /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */ - - if (addr < AUTOIP_RANGE_START) { - addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1; - } - if (addr > AUTOIP_RANGE_END) { - addr -= AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1; - } - LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) && - (addr <= AUTOIP_RANGE_END)); - ip4_addr_set_u32(ipaddr, htonl(addr)); - - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - (u16_t)(netif->autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), - ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr))); -} - -/** - * Sends an ARP probe from a network interface - * - * @param netif network interface used to send the probe - */ -static err_t -autoip_arp_probe(struct netif *netif) -{ - return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast, - (struct eth_addr *)netif->hwaddr, IP_ADDR_ANY, ðzero, - &netif->autoip->llipaddr, ARP_REQUEST); -} - -/** - * Sends an ARP announce from a network interface - * - * @param netif network interface used to send the announce - */ -static err_t -autoip_arp_announce(struct netif *netif) -{ - return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast, - (struct eth_addr *)netif->hwaddr, &netif->autoip->llipaddr, ðzero, - &netif->autoip->llipaddr, ARP_REQUEST); -} - -/** - * Configure interface for use with current LL IP-Address - * - * @param netif network interface to configure with current LL IP-Address - */ -static err_t -autoip_bind(struct netif *netif) -{ - struct autoip *autoip = netif->autoip; - ip_addr_t sn_mask, gw_addr; - - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, - ("autoip_bind(netif=%p) %c%c%"U16_F" %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num, - ip4_addr1_16(&autoip->llipaddr), ip4_addr2_16(&autoip->llipaddr), - ip4_addr3_16(&autoip->llipaddr), ip4_addr4_16(&autoip->llipaddr))); - - IP4_ADDR(&sn_mask, 255, 255, 0, 0); - IP4_ADDR(&gw_addr, 0, 0, 0, 0); - - netif_set_ipaddr(netif, &autoip->llipaddr); - netif_set_netmask(netif, &sn_mask); - netif_set_gw(netif, &gw_addr); - - /* bring the interface up */ - netif_set_up(netif); - - return ERR_OK; -} - -/** - * Start AutoIP client - * - * @param netif network interface on which start the AutoIP client - */ -err_t -autoip_start(struct netif *netif) -{ - struct autoip *autoip = netif->autoip; - err_t result = ERR_OK; - - if (netif_is_up(netif)) { - netif_set_down(netif); - } - - /* Set IP-Address, Netmask and Gateway to 0 to make sure that - * ARP Packets are formed correctly - */ - ip_addr_set_zero(&netif->ip_addr); - ip_addr_set_zero(&netif->netmask); - ip_addr_set_zero(&netif->gw); - - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], - netif->name[1], (u16_t)netif->num)); - if (autoip == NULL) { - /* no AutoIP client attached yet? */ - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, - ("autoip_start(): starting new AUTOIP client\n")); - autoip = (struct autoip *)mem_malloc(sizeof(struct autoip)); - if (autoip == NULL) { - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, - ("autoip_start(): could not allocate autoip\n")); - return ERR_MEM; - } - memset(autoip, 0, sizeof(struct autoip)); - /* store this AutoIP client in the netif */ - netif->autoip = autoip; - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip")); - } else { - autoip->state = AUTOIP_STATE_OFF; - autoip->ttw = 0; - autoip->sent_num = 0; - ip_addr_set_zero(&autoip->llipaddr); - autoip->lastconflict = 0; - } - - autoip_create_addr(netif, &(autoip->llipaddr)); - autoip_start_probing(netif); - - return result; -} - -static void -autoip_start_probing(struct netif *netif) -{ - struct autoip *autoip = netif->autoip; - - autoip->state = AUTOIP_STATE_PROBING; - autoip->sent_num = 0; - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_start_probing(): changing state to PROBING: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr), - ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr))); - - /* time to wait to first probe, this is randomly - * choosen out of 0 to PROBE_WAIT seconds. - * compliant to RFC 3927 Section 2.2.1 - */ - autoip->ttw = (u16_t)(LWIP_AUTOIP_RAND(netif) % (PROBE_WAIT * AUTOIP_TICKS_PER_SECOND)); - - /* - * if we tried more then MAX_CONFLICTS we must limit our rate for - * accquiring and probing address - * compliant to RFC 3927 Section 2.2.1 - */ - if (autoip->tried_llipaddr > MAX_CONFLICTS) { - autoip->ttw = RATE_LIMIT_INTERVAL * AUTOIP_TICKS_PER_SECOND; - } -} - -/** - * Handle a possible change in the network configuration. - * - * If there is an AutoIP address configured, take the interface down - * and begin probing with the same address. - */ -void -autoip_network_changed(struct netif *netif) -{ - if (netif->autoip && netif->autoip->state != AUTOIP_STATE_OFF) { - netif_set_down(netif); - autoip_start_probing(netif); - } -} - -/** - * Stop AutoIP client - * - * @param netif network interface on which stop the AutoIP client - */ -err_t -autoip_stop(struct netif *netif) -{ - netif->autoip->state = AUTOIP_STATE_OFF; - netif_set_down(netif); - return ERR_OK; -} - -/** - * Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds - */ -void -autoip_tmr() -{ - struct netif *netif = netif_list; - /* loop through netif's */ - while (netif != NULL) { - /* only act on AutoIP configured interfaces */ - if (netif->autoip != NULL) { - if (netif->autoip->lastconflict > 0) { - netif->autoip->lastconflict--; - } - - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, - ("autoip_tmr() AutoIP-State: %"U16_F", ttw=%"U16_F"\n", - (u16_t)(netif->autoip->state), netif->autoip->ttw)); - - switch(netif->autoip->state) { - case AUTOIP_STATE_PROBING: - if (netif->autoip->ttw > 0) { - netif->autoip->ttw--; - } else { - if (netif->autoip->sent_num >= PROBE_NUM) { - netif->autoip->state = AUTOIP_STATE_ANNOUNCING; - netif->autoip->sent_num = 0; - netif->autoip->ttw = ANNOUNCE_WAIT * AUTOIP_TICKS_PER_SECOND; - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_tmr(): changing state to ANNOUNCING: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr), - ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr))); - } else { - autoip_arp_probe(netif); - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, - ("autoip_tmr() PROBING Sent Probe\n")); - netif->autoip->sent_num++; - /* calculate time to wait to next probe */ - netif->autoip->ttw = (u16_t)((LWIP_AUTOIP_RAND(netif) % - ((PROBE_MAX - PROBE_MIN) * AUTOIP_TICKS_PER_SECOND) ) + - PROBE_MIN * AUTOIP_TICKS_PER_SECOND); - } - } - break; - - case AUTOIP_STATE_ANNOUNCING: - if (netif->autoip->ttw > 0) { - netif->autoip->ttw--; - } else { - if (netif->autoip->sent_num == 0) { - /* We are here the first time, so we waited ANNOUNCE_WAIT seconds - * Now we can bind to an IP address and use it. - * - * autoip_bind calls netif_set_up. This triggers a gratuitous ARP - * which counts as an announcement. - */ - autoip_bind(netif); - } else { - autoip_arp_announce(netif); - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, - ("autoip_tmr() ANNOUNCING Sent Announce\n")); - } - netif->autoip->ttw = ANNOUNCE_INTERVAL * AUTOIP_TICKS_PER_SECOND; - netif->autoip->sent_num++; - - if (netif->autoip->sent_num >= ANNOUNCE_NUM) { - netif->autoip->state = AUTOIP_STATE_BOUND; - netif->autoip->sent_num = 0; - netif->autoip->ttw = 0; - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("autoip_tmr(): changing state to BOUND: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr), - ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr))); - } - } - break; - } - } - /* proceed to next network interface */ - netif = netif->next; - } -} - -/** - * Handles every incoming ARP Packet, called by etharp_arp_input. - * - * @param netif network interface to use for autoip processing - * @param hdr Incoming ARP packet - */ -void -autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr) -{ - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_arp_reply()\n")); - if ((netif->autoip != NULL) && (netif->autoip->state != AUTOIP_STATE_OFF)) { - /* when ip.src == llipaddr && hw.src != netif->hwaddr - * - * when probing ip.dst == llipaddr && hw.src != netif->hwaddr - * we have a conflict and must solve it - */ - ip_addr_t sipaddr, dipaddr; - struct eth_addr netifaddr; - ETHADDR16_COPY(netifaddr.addr, netif->hwaddr); - - /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without - * structure packing (not using structure copy which breaks strict-aliasing rules). - */ - IPADDR2_COPY(&sipaddr, &hdr->sipaddr); - IPADDR2_COPY(&dipaddr, &hdr->dipaddr); - - if ((netif->autoip->state == AUTOIP_STATE_PROBING) || - ((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) && - (netif->autoip->sent_num == 0))) { - /* RFC 3927 Section 2.2.1: - * from beginning to after ANNOUNCE_WAIT - * seconds we have a conflict if - * ip.src == llipaddr OR - * ip.dst == llipaddr && hw.src != own hwaddr - */ - if ((ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr)) || - (ip_addr_cmp(&dipaddr, &netif->autoip->llipaddr) && - !eth_addr_cmp(&netifaddr, &hdr->shwaddr))) { - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, - ("autoip_arp_reply(): Probe Conflict detected\n")); - autoip_restart(netif); - } - } else { - /* RFC 3927 Section 2.5: - * in any state we have a conflict if - * ip.src == llipaddr && hw.src != own hwaddr - */ - if (ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr) && - !eth_addr_cmp(&netifaddr, &hdr->shwaddr)) { - LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, - ("autoip_arp_reply(): Conflicting ARP-Packet detected\n")); - autoip_handle_arp_conflict(netif); - } - } - } -} - -#endif /* LWIP_AUTOIP */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/icmp.c b/user/mpy/lib/lwip/src/core/ipv4/icmp.c deleted file mode 100644 index 47ba857..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/icmp.c +++ /dev/null @@ -1,339 +0,0 @@ -/** - * @file - * ICMP - Internet Control Message Protocol - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -/* Some ICMP messages should be passed to the transport protocols. This - is not implemented. */ - -#include "lwip/opt.h" - -#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/icmp.h" -#include "lwip/inet_chksum.h" -#include "lwip/ip.h" -#include "lwip/def.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" - -#include - -/** Small optimization: set to 0 if incoming PBUF_POOL pbuf always can be - * used to modify and send a response packet (and to 1 if this is not the case, - * e.g. when link header is stripped of when receiving) */ -#ifndef LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN -#define LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN 1 -#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ - -/* The amount of data from the original packet to return in a dest-unreachable */ -#define ICMP_DEST_UNREACH_DATASIZE 8 - -static void icmp_send_response(struct pbuf *p, u8_t type, u8_t code); - -/** - * Processes ICMP input packets, called from ip_input(). - * - * Currently only processes icmp echo requests and sends - * out the echo response. - * - * @param p the icmp echo request packet, p->payload pointing to the ip header - * @param inp the netif on which this packet was received - */ -void -icmp_input(struct pbuf *p, struct netif *inp) -{ - u8_t type; -#ifdef LWIP_DEBUG - u8_t code; -#endif /* LWIP_DEBUG */ - struct icmp_echo_hdr *iecho; - struct ip_hdr *iphdr; - s16_t hlen; - - ICMP_STATS_INC(icmp.recv); - snmp_inc_icmpinmsgs(); - - - iphdr = (struct ip_hdr *)p->payload; - hlen = IPH_HL(iphdr) * 4; - if (pbuf_header(p, -hlen) || (p->tot_len < sizeof(u16_t)*2)) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len)); - goto lenerr; - } - - type = *((u8_t *)p->payload); -#ifdef LWIP_DEBUG - code = *(((u8_t *)p->payload)+1); -#endif /* LWIP_DEBUG */ - switch (type) { - case ICMP_ER: - /* This is OK, echo reply might have been parsed by a raw PCB - (as obviously, an echo request has been sent, too). */ - break; - case ICMP_ECHO: -#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING - { - int accepted = 1; -#if !LWIP_MULTICAST_PING - /* multicast destination address? */ - if (ip_addr_ismulticast(¤t_iphdr_dest)) { - accepted = 0; - } -#endif /* LWIP_MULTICAST_PING */ -#if !LWIP_BROADCAST_PING - /* broadcast destination address? */ - if (ip_addr_isbroadcast(¤t_iphdr_dest, inp)) { - accepted = 0; - } -#endif /* LWIP_BROADCAST_PING */ - /* broadcast or multicast destination address not acceptd? */ - if (!accepted) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n")); - ICMP_STATS_INC(icmp.err); - pbuf_free(p); - return; - } - } -#endif /* !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */ - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); - if (p->tot_len < sizeof(struct icmp_echo_hdr)) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); - goto lenerr; - } - if (inet_chksum_pbuf(p) != 0) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); - pbuf_free(p); - ICMP_STATS_INC(icmp.chkerr); - snmp_inc_icmpinerrors(); - return; - } -#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN - if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) { - /* p is not big enough to contain link headers - * allocate a new one and copy p into it - */ - struct pbuf *r; - /* switch p->payload to ip header */ - if (pbuf_header(p, hlen)) { - LWIP_ASSERT("icmp_input: moving p->payload to ip header failed\n", 0); - goto memerr; - } - /* allocate new packet buffer with space for link headers */ - r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); - if (r == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: allocating new pbuf failed\n")); - goto memerr; - } - LWIP_ASSERT("check that first pbuf can hold struct the ICMP header", - (r->len >= hlen + sizeof(struct icmp_echo_hdr))); - /* copy the whole packet including ip header */ - if (pbuf_copy(r, p) != ERR_OK) { - LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0); - goto memerr; - } - iphdr = (struct ip_hdr *)r->payload; - /* switch r->payload back to icmp header */ - if (pbuf_header(r, -hlen)) { - LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0); - goto memerr; - } - /* free the original p */ - pbuf_free(p); - /* we now have an identical copy of p that has room for link headers */ - p = r; - } else { - /* restore p->payload to point to icmp header */ - if (pbuf_header(p, -(s16_t)(PBUF_IP_HLEN + PBUF_LINK_HLEN))) { - LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0); - goto memerr; - } - } -#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ - /* At this point, all checks are OK. */ - /* We generate an answer by switching the dest and src ip addresses, - * setting the icmp type to ECHO_RESPONSE and updating the checksum. */ - iecho = (struct icmp_echo_hdr *)p->payload; - ip_addr_copy(iphdr->src, *ip_current_dest_addr()); - ip_addr_copy(iphdr->dest, *ip_current_src_addr()); - ICMPH_TYPE_SET(iecho, ICMP_ER); -#if CHECKSUM_GEN_ICMP - /* adjust the checksum */ - if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) { - iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1; - } else { - iecho->chksum += PP_HTONS(ICMP_ECHO << 8); - } -#else /* CHECKSUM_GEN_ICMP */ - iecho->chksum = 0; -#endif /* CHECKSUM_GEN_ICMP */ - - /* Set the correct TTL and recalculate the header checksum. */ - IPH_TTL_SET(iphdr, ICMP_TTL); - IPH_CHKSUM_SET(iphdr, 0); -#if CHECKSUM_GEN_IP - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); -#endif /* CHECKSUM_GEN_IP */ - - ICMP_STATS_INC(icmp.xmit); - /* increase number of messages attempted to send */ - snmp_inc_icmpoutmsgs(); - /* increase number of echo replies attempted to send */ - snmp_inc_icmpoutechoreps(); - - if(pbuf_header(p, hlen)) { - LWIP_ASSERT("Can't move over header in packet", 0); - } else { - err_t ret; - /* send an ICMP packet, src addr is the dest addr of the curren packet */ - ret = ip_output_if(p, ip_current_dest_addr(), IP_HDRINCL, - ICMP_TTL, 0, IP_PROTO_ICMP, inp); - if (ret != ERR_OK) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret)); - } - } - break; - default: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", - (s16_t)type, (s16_t)code)); - ICMP_STATS_INC(icmp.proterr); - ICMP_STATS_INC(icmp.drop); - } - pbuf_free(p); - return; -lenerr: - pbuf_free(p); - ICMP_STATS_INC(icmp.lenerr); - snmp_inc_icmpinerrors(); - return; -#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN -memerr: - pbuf_free(p); - ICMP_STATS_INC(icmp.err); - snmp_inc_icmpinerrors(); - return; -#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ -} - -/** - * Send an icmp 'destination unreachable' packet, called from ip_input() if - * the transport layer protocol is unknown and from udp_input() if the local - * port is not bound. - * - * @param p the input packet for which the 'unreachable' should be sent, - * p->payload pointing to the IP header - * @param t type of the 'unreachable' packet - */ -void -icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) -{ - icmp_send_response(p, ICMP_DUR, t); -} - -#if IP_FORWARD || IP_REASSEMBLY -/** - * Send a 'time exceeded' packet, called from ip_forward() if TTL is 0. - * - * @param p the input packet for which the 'time exceeded' should be sent, - * p->payload pointing to the IP header - * @param t type of the 'time exceeded' packet - */ -void -icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) -{ - icmp_send_response(p, ICMP_TE, t); -} - -#endif /* IP_FORWARD || IP_REASSEMBLY */ - -/** - * Send an icmp packet in response to an incoming packet. - * - * @param p the input packet for which the 'unreachable' should be sent, - * p->payload pointing to the IP header - * @param type Type of the ICMP header - * @param code Code of the ICMP header - */ -static void -icmp_send_response(struct pbuf *p, u8_t type, u8_t code) -{ - struct pbuf *q; - struct ip_hdr *iphdr; - /* we can use the echo header here */ - struct icmp_echo_hdr *icmphdr; - ip_addr_t iphdr_src; - - /* ICMP header + IP header + 8 bytes of data */ - q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE, - PBUF_RAM); - if (q == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n")); - return; - } - LWIP_ASSERT("check that first pbuf can hold icmp message", - (q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE))); - - iphdr = (struct ip_hdr *)p->payload; - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); - ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); - LWIP_DEBUGF(ICMP_DEBUG, (" to ")); - ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); - LWIP_DEBUGF(ICMP_DEBUG, ("\n")); - - icmphdr = (struct icmp_echo_hdr *)q->payload; - icmphdr->type = type; - icmphdr->code = code; - icmphdr->id = 0; - icmphdr->seqno = 0; - - /* copy fields from original packet */ - SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, - IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); - - /* calculate checksum */ - icmphdr->chksum = 0; - icmphdr->chksum = inet_chksum(icmphdr, q->len); - ICMP_STATS_INC(icmp.xmit); - /* increase number of messages attempted to send */ - snmp_inc_icmpoutmsgs(); - /* increase number of destination unreachable messages attempted to send */ - snmp_inc_icmpouttimeexcds(); - ip_addr_copy(iphdr_src, iphdr->src); - ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP); - pbuf_free(q); -} - -#endif /* LWIP_ICMP */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/igmp.c b/user/mpy/lib/lwip/src/core/ipv4/igmp.c deleted file mode 100644 index 45bb5d9..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/igmp.c +++ /dev/null @@ -1,805 +0,0 @@ -/** - * @file - * IGMP - Internet Group Management Protocol - * - */ - -/* - * Copyright (c) 2002 CITEL Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is a contribution to the lwIP TCP/IP stack. - * The Swedish Institute of Computer Science and Adam Dunkels - * are specifically granted permission to redistribute this - * source code. -*/ - -/*------------------------------------------------------------- -Note 1) -Although the rfc requires V1 AND V2 capability -we will only support v2 since now V1 is very old (August 1989) -V1 can be added if required - -a debug print and statistic have been implemented to -show this up. -------------------------------------------------------------- -------------------------------------------------------------- -Note 2) -A query for a specific group address (as opposed to ALLHOSTS) -has now been implemented as I am unsure if it is required - -a debug print and statistic have been implemented to -show this up. -------------------------------------------------------------- -------------------------------------------------------------- -Note 3) -The router alert rfc 2113 is implemented in outgoing packets -but not checked rigorously incoming -------------------------------------------------------------- -Steve Reynolds -------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------- - * RFC 988 - Host extensions for IP multicasting - V0 - * RFC 1054 - Host extensions for IP multicasting - - * RFC 1112 - Host extensions for IP multicasting - V1 - * RFC 2236 - Internet Group Management Protocol, Version 2 - V2 <- this code is based on this RFC (it's the "de facto" standard) - * RFC 3376 - Internet Group Management Protocol, Version 3 - V3 - * RFC 4604 - Using Internet Group Management Protocol Version 3... - V3+ - * RFC 2113 - IP Router Alert Option - - *----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------- - * Includes - *----------------------------------------------------------------------------*/ - -#include "lwip/opt.h" - -#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/igmp.h" -#include "lwip/debug.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/ip.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/udp.h" -#include "lwip/tcp.h" -#include "lwip/stats.h" - -#include "string.h" - -/* - * IGMP constants - */ -#define IGMP_TTL 1 -#define IGMP_MINLEN 8 -#define ROUTER_ALERT 0x9404U -#define ROUTER_ALERTLEN 4 - -/* - * IGMP message types, including version number. - */ -#define IGMP_MEMB_QUERY 0x11 /* Membership query */ -#define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */ -#define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */ -#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ - -/* Group membership states */ -#define IGMP_GROUP_NON_MEMBER 0 -#define IGMP_GROUP_DELAYING_MEMBER 1 -#define IGMP_GROUP_IDLE_MEMBER 2 - -/** - * IGMP packet format. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct igmp_msg { - PACK_STRUCT_FIELD(u8_t igmp_msgtype); - PACK_STRUCT_FIELD(u8_t igmp_maxresp); - PACK_STRUCT_FIELD(u16_t igmp_checksum); - PACK_STRUCT_FIELD(ip_addr_p_t igmp_group_address); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - - -static struct igmp_group *igmp_lookup_group(struct netif *ifp, ip_addr_t *addr); -static err_t igmp_remove_group(struct igmp_group *group); -static void igmp_timeout( struct igmp_group *group); -static void igmp_start_timer(struct igmp_group *group, u8_t max_time); -static void igmp_delaying_member(struct igmp_group *group, u8_t maxresp); -static err_t igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif); -static void igmp_send(struct igmp_group *group, u8_t type); - - -static struct igmp_group* igmp_group_list; -static ip_addr_t allsystems; -static ip_addr_t allrouters; - - -/** - * Initialize the IGMP module - */ -void -igmp_init(void) -{ - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_init: initializing\n")); - - IP4_ADDR(&allsystems, 224, 0, 0, 1); - IP4_ADDR(&allrouters, 224, 0, 0, 2); -} - -#ifdef LWIP_DEBUG -/** - * Dump global IGMP groups list - */ -void -igmp_dump_group_list() -{ - struct igmp_group *group = igmp_group_list; - - while (group != NULL) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_dump_group_list: [%"U32_F"] ", (u32_t)(group->group_state))); - ip_addr_debug_print(IGMP_DEBUG, &group->group_address); - LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif)); - group = group->next; - } - LWIP_DEBUGF(IGMP_DEBUG, ("\n")); -} -#else -#define igmp_dump_group_list() -#endif /* LWIP_DEBUG */ - -/** - * Start IGMP processing on interface - * - * @param netif network interface on which start IGMP processing - */ -err_t -igmp_start(struct netif *netif) -{ - struct igmp_group* group; - - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %p\n", netif)); - - group = igmp_lookup_group(netif, &allsystems); - - if (group != NULL) { - group->group_state = IGMP_GROUP_IDLE_MEMBER; - group->use++; - - /* Allow the igmp messages at the MAC level */ - if (netif->igmp_mac_filter != NULL) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD ")); - ip_addr_debug_print(IGMP_DEBUG, &allsystems); - LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); - netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER); - } - - return ERR_OK; - } - - return ERR_MEM; -} - -/** - * Stop IGMP processing on interface - * - * @param netif network interface on which stop IGMP processing - */ -err_t -igmp_stop(struct netif *netif) -{ - struct igmp_group *group = igmp_group_list; - struct igmp_group *prev = NULL; - struct igmp_group *next; - - /* look for groups joined on this interface further down the list */ - while (group != NULL) { - next = group->next; - /* is it a group joined on this interface? */ - if (group->netif == netif) { - /* is it the first group of the list? */ - if (group == igmp_group_list) { - igmp_group_list = next; - } - /* is there a "previous" group defined? */ - if (prev != NULL) { - prev->next = next; - } - /* disable the group at the MAC level */ - if (netif->igmp_mac_filter != NULL) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL ")); - ip_addr_debug_print(IGMP_DEBUG, &group->group_address); - LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); - netif->igmp_mac_filter(netif, &(group->group_address), IGMP_DEL_MAC_FILTER); - } - /* free group */ - memp_free(MEMP_IGMP_GROUP, group); - } else { - /* change the "previous" */ - prev = group; - } - /* move to "next" */ - group = next; - } - return ERR_OK; -} - -/** - * Report IGMP memberships for this interface - * - * @param netif network interface on which report IGMP memberships - */ -void -igmp_report_groups(struct netif *netif) -{ - struct igmp_group *group = igmp_group_list; - - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", netif)); - - while (group != NULL) { - if (group->netif == netif) { - igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR); - } - group = group->next; - } -} - -/** - * Search for a group in the global igmp_group_list - * - * @param ifp the network interface for which to look - * @param addr the group ip address to search for - * @return a struct igmp_group* if the group has been found, - * NULL if the group wasn't found. - */ -struct igmp_group * -igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr) -{ - struct igmp_group *group = igmp_group_list; - - while (group != NULL) { - if ((group->netif == ifp) && (ip_addr_cmp(&(group->group_address), addr))) { - return group; - } - group = group->next; - } - - /* to be clearer, we return NULL here instead of - * 'group' (which is also NULL at this point). - */ - return NULL; -} - -/** - * Search for a specific igmp group and create a new one if not found- - * - * @param ifp the network interface for which to look - * @param addr the group ip address to search - * @return a struct igmp_group*, - * NULL on memory error. - */ -struct igmp_group * -igmp_lookup_group(struct netif *ifp, ip_addr_t *addr) -{ - struct igmp_group *group = igmp_group_list; - - /* Search if the group already exists */ - group = igmp_lookfor_group(ifp, addr); - if (group != NULL) { - /* Group already exists. */ - return group; - } - - /* Group doesn't exist yet, create a new one */ - group = (struct igmp_group *)memp_malloc(MEMP_IGMP_GROUP); - if (group != NULL) { - group->netif = ifp; - ip_addr_set(&(group->group_address), addr); - group->timer = 0; /* Not running */ - group->group_state = IGMP_GROUP_NON_MEMBER; - group->last_reporter_flag = 0; - group->use = 0; - group->next = igmp_group_list; - - igmp_group_list = group; - } - - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: %sallocated a new group with address ", (group?"":"impossible to "))); - ip_addr_debug_print(IGMP_DEBUG, addr); - LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", ifp)); - - return group; -} - -/** - * Remove a group in the global igmp_group_list - * - * @param group the group to remove from the global igmp_group_list - * @return ERR_OK if group was removed from the list, an err_t otherwise - */ -static err_t -igmp_remove_group(struct igmp_group *group) -{ - err_t err = ERR_OK; - - /* Is it the first group? */ - if (igmp_group_list == group) { - igmp_group_list = group->next; - } else { - /* look for group further down the list */ - struct igmp_group *tmpGroup; - for (tmpGroup = igmp_group_list; tmpGroup != NULL; tmpGroup = tmpGroup->next) { - if (tmpGroup->next == group) { - tmpGroup->next = group->next; - break; - } - } - /* Group not found in the global igmp_group_list */ - if (tmpGroup == NULL) - err = ERR_ARG; - } - /* free group */ - memp_free(MEMP_IGMP_GROUP, group); - - return err; -} - -/** - * Called from ip_input() if a new IGMP packet is received. - * - * @param p received igmp packet, p->payload pointing to the ip header - * @param inp network interface on which the packet was received - * @param dest destination ip address of the igmp packet - */ -void -igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) -{ - struct ip_hdr * iphdr; - struct igmp_msg* igmp; - struct igmp_group* group; - struct igmp_group* groupref; - - IGMP_STATS_INC(igmp.recv); - - /* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */ - iphdr = (struct ip_hdr *)p->payload; - if (pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4)) || (p->len < IGMP_MINLEN)) { - pbuf_free(p); - IGMP_STATS_INC(igmp.lenerr); - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: length error\n")); - return; - } - - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: message from ")); - ip_addr_debug_print(IGMP_DEBUG, &(iphdr->src)); - LWIP_DEBUGF(IGMP_DEBUG, (" to address ")); - ip_addr_debug_print(IGMP_DEBUG, &(iphdr->dest)); - LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", inp)); - - /* Now calculate and check the checksum */ - igmp = (struct igmp_msg *)p->payload; - if (inet_chksum(igmp, p->len)) { - pbuf_free(p); - IGMP_STATS_INC(igmp.chkerr); - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: checksum error\n")); - return; - } - - /* Packet is ok so find an existing group */ - group = igmp_lookfor_group(inp, dest); /* use the destination IP address of incoming packet */ - - /* If group can be found or create... */ - if (!group) { - pbuf_free(p); - IGMP_STATS_INC(igmp.drop); - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP frame not for us\n")); - return; - } - - /* NOW ACT ON THE INCOMING MESSAGE TYPE... */ - switch (igmp->igmp_msgtype) { - case IGMP_MEMB_QUERY: { - /* IGMP_MEMB_QUERY to the "all systems" address ? */ - if ((ip_addr_cmp(dest, &allsystems)) && ip_addr_isany(&igmp->igmp_group_address)) { - /* THIS IS THE GENERAL QUERY */ - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: General IGMP_MEMB_QUERY on \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); - - if (igmp->igmp_maxresp == 0) { - IGMP_STATS_INC(igmp.rx_v1); - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: got an all hosts query with time== 0 - this is V1 and not implemented - treat as v2\n")); - igmp->igmp_maxresp = IGMP_V1_DELAYING_MEMBER_TMR; - } else { - IGMP_STATS_INC(igmp.rx_general); - } - - groupref = igmp_group_list; - while (groupref) { - /* Do not send messages on the all systems group address! */ - if ((groupref->netif == inp) && (!(ip_addr_cmp(&(groupref->group_address), &allsystems)))) { - igmp_delaying_member(groupref, igmp->igmp_maxresp); - } - groupref = groupref->next; - } - } else { - /* IGMP_MEMB_QUERY to a specific group ? */ - if (!ip_addr_isany(&igmp->igmp_group_address)) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group ")); - ip_addr_debug_print(IGMP_DEBUG, &igmp->igmp_group_address); - if (ip_addr_cmp(dest, &allsystems)) { - ip_addr_t groupaddr; - LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); - /* we first need to re-look for the group since we used dest last time */ - ip_addr_copy(groupaddr, igmp->igmp_group_address); - group = igmp_lookfor_group(inp, &groupaddr); - } else { - LWIP_DEBUGF(IGMP_DEBUG, (" with the group address as destination [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); - } - - if (group != NULL) { - IGMP_STATS_INC(igmp.rx_group); - igmp_delaying_member(group, igmp->igmp_maxresp); - } else { - IGMP_STATS_INC(igmp.drop); - } - } else { - IGMP_STATS_INC(igmp.proterr); - } - } - break; - } - case IGMP_V2_MEMB_REPORT: { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_V2_MEMB_REPORT\n")); - IGMP_STATS_INC(igmp.rx_report); - if (group->group_state == IGMP_GROUP_DELAYING_MEMBER) { - /* This is on a specific group we have already looked up */ - group->timer = 0; /* stopped */ - group->group_state = IGMP_GROUP_IDLE_MEMBER; - group->last_reporter_flag = 0; - } - break; - } - default: { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: unexpected msg %d in state %d on group %p on if %p\n", - igmp->igmp_msgtype, group->group_state, &group, group->netif)); - IGMP_STATS_INC(igmp.proterr); - break; - } - } - - pbuf_free(p); - return; -} - -/** - * Join a group on one network interface. - * - * @param ifaddr ip address of the network interface which should join a new group - * @param groupaddr the ip address of the group which to join - * @return ERR_OK if group was joined on the netif(s), an err_t otherwise - */ -err_t -igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) -{ - err_t err = ERR_VAL; /* no matching interface */ - struct igmp_group *group; - struct netif *netif; - - /* make sure it is multicast address */ - LWIP_ERROR("igmp_joingroup: attempt to join non-multicast address", ip_addr_ismulticast(groupaddr), return ERR_VAL;); - LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); - - /* loop through netif's */ - netif = netif_list; - while (netif != NULL) { - /* Should we join this interface ? */ - if ((netif->flags & NETIF_FLAG_IGMP) && ((ip_addr_isany(ifaddr) || ip_addr_cmp(&(netif->ip_addr), ifaddr)))) { - /* find group or create a new one if not found */ - group = igmp_lookup_group(netif, groupaddr); - - if (group != NULL) { - /* This should create a new group, check the state to make sure */ - if (group->group_state != IGMP_GROUP_NON_MEMBER) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: join to group not in state IGMP_GROUP_NON_MEMBER\n")); - } else { - /* OK - it was new group */ - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: join to new group: ")); - ip_addr_debug_print(IGMP_DEBUG, groupaddr); - LWIP_DEBUGF(IGMP_DEBUG, ("\n")); - - /* If first use of the group, allow the group at the MAC level */ - if ((group->use==0) && (netif->igmp_mac_filter != NULL)) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: igmp_mac_filter(ADD ")); - ip_addr_debug_print(IGMP_DEBUG, groupaddr); - LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); - netif->igmp_mac_filter(netif, groupaddr, IGMP_ADD_MAC_FILTER); - } - - IGMP_STATS_INC(igmp.tx_join); - igmp_send(group, IGMP_V2_MEMB_REPORT); - - igmp_start_timer(group, IGMP_JOIN_DELAYING_MEMBER_TMR); - - /* Need to work out where this timer comes from */ - group->group_state = IGMP_GROUP_DELAYING_MEMBER; - } - /* Increment group use */ - group->use++; - /* Join on this interface */ - err = ERR_OK; - } else { - /* Return an error even if some network interfaces are joined */ - /** @todo undo any other netif already joined */ - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: Not enought memory to join to group\n")); - return ERR_MEM; - } - } - /* proceed to next network interface */ - netif = netif->next; - } - - return err; -} - -/** - * Leave a group on one network interface. - * - * @param ifaddr ip address of the network interface which should leave a group - * @param groupaddr the ip address of the group which to leave - * @return ERR_OK if group was left on the netif(s), an err_t otherwise - */ -err_t -igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) -{ - err_t err = ERR_VAL; /* no matching interface */ - struct igmp_group *group; - struct netif *netif; - - /* make sure it is multicast address */ - LWIP_ERROR("igmp_leavegroup: attempt to leave non-multicast address", ip_addr_ismulticast(groupaddr), return ERR_VAL;); - LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;); - - /* loop through netif's */ - netif = netif_list; - while (netif != NULL) { - /* Should we leave this interface ? */ - if ((netif->flags & NETIF_FLAG_IGMP) && ((ip_addr_isany(ifaddr) || ip_addr_cmp(&(netif->ip_addr), ifaddr)))) { - /* find group */ - group = igmp_lookfor_group(netif, groupaddr); - - if (group != NULL) { - /* Only send a leave if the flag is set according to the state diagram */ - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: Leaving group: ")); - ip_addr_debug_print(IGMP_DEBUG, groupaddr); - LWIP_DEBUGF(IGMP_DEBUG, ("\n")); - - /* If there is no other use of the group */ - if (group->use <= 1) { - /* If we are the last reporter for this group */ - if (group->last_reporter_flag) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: sending leaving group\n")); - IGMP_STATS_INC(igmp.tx_leave); - igmp_send(group, IGMP_LEAVE_GROUP); - } - - /* Disable the group at the MAC level */ - if (netif->igmp_mac_filter != NULL) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL ")); - ip_addr_debug_print(IGMP_DEBUG, groupaddr); - LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); - netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER); - } - - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: remove group: ")); - ip_addr_debug_print(IGMP_DEBUG, groupaddr); - LWIP_DEBUGF(IGMP_DEBUG, ("\n")); - - /* Free the group */ - igmp_remove_group(group); - } else { - /* Decrement group use */ - group->use--; - } - /* Leave on this interface */ - err = ERR_OK; - } else { - /* It's not a fatal error on "leavegroup" */ - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: not member of group\n")); - } - } - /* proceed to next network interface */ - netif = netif->next; - } - - return err; -} - -/** - * The igmp timer function (both for NO_SYS=1 and =0) - * Should be called every IGMP_TMR_INTERVAL milliseconds (100 ms is default). - */ -void -igmp_tmr(void) -{ - struct igmp_group *group = igmp_group_list; - - while (group != NULL) { - if (group->timer > 0) { - group->timer--; - if (group->timer == 0) { - igmp_timeout(group); - } - } - group = group->next; - } -} - -/** - * Called if a timeout for one group is reached. - * Sends a report for this group. - * - * @param group an igmp_group for which a timeout is reached - */ -static void -igmp_timeout(struct igmp_group *group) -{ - /* If the state is IGMP_GROUP_DELAYING_MEMBER then we send a report for this group */ - if (group->group_state == IGMP_GROUP_DELAYING_MEMBER) { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address ")); - ip_addr_debug_print(IGMP_DEBUG, &(group->group_address)); - LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif)); - - IGMP_STATS_INC(igmp.tx_report); - igmp_send(group, IGMP_V2_MEMB_REPORT); - } -} - -/** - * Start a timer for an igmp group - * - * @param group the igmp_group for which to start a timer - * @param max_time the time in multiples of IGMP_TMR_INTERVAL (decrease with - * every call to igmp_tmr()) - */ -static void -igmp_start_timer(struct igmp_group *group, u8_t max_time) -{ - /* ensure the input value is > 0 */ - if (max_time == 0) { - max_time = 1; - } - /* ensure the random value is > 0 */ - group->timer = (LWIP_RAND() % (max_time - 1)) + 1; -} - -/** - * Delaying membership report for a group if necessary - * - * @param group the igmp_group for which "delaying" membership report - * @param maxresp query delay - */ -static void -igmp_delaying_member(struct igmp_group *group, u8_t maxresp) -{ - if ((group->group_state == IGMP_GROUP_IDLE_MEMBER) || - ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) && - ((group->timer == 0) || (maxresp < group->timer)))) { - igmp_start_timer(group, maxresp); - group->group_state = IGMP_GROUP_DELAYING_MEMBER; - } -} - - -/** - * Sends an IP packet on a network interface. This function constructs the IP header - * and calculates the IP header checksum. If the source IP address is NULL, - * the IP address of the outgoing network interface is filled in as source address. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * @param netif the netif on which to send this packet - * @return ERR_OK if the packet was sent OK - * ERR_BUF if p doesn't have enough space for IP/LINK headers - * returns errors returned by netif->output - */ -static err_t -igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif) -{ - /* This is the "router alert" option */ - u16_t ra[2]; - ra[0] = PP_HTONS(ROUTER_ALERT); - ra[1] = 0x0000; /* Router shall examine packet */ - IGMP_STATS_INC(igmp.xmit); - return ip_output_if_opt(p, src, dest, IGMP_TTL, 0, IP_PROTO_IGMP, netif, ra, ROUTER_ALERTLEN); -} - -/** - * Send an igmp packet to a specific group. - * - * @param group the group to which to send the packet - * @param type the type of igmp packet to send - */ -static void -igmp_send(struct igmp_group *group, u8_t type) -{ - struct pbuf* p = NULL; - struct igmp_msg* igmp = NULL; - ip_addr_t src = *IP_ADDR_ANY; - ip_addr_t* dest = NULL; - - /* IP header + "router alert" option + IGMP header */ - p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM); - - if (p) { - igmp = (struct igmp_msg *)p->payload; - LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg", - (p->len >= sizeof(struct igmp_msg))); - ip_addr_copy(src, group->netif->ip_addr); - - if (type == IGMP_V2_MEMB_REPORT) { - dest = &(group->group_address); - ip_addr_copy(igmp->igmp_group_address, group->group_address); - group->last_reporter_flag = 1; /* Remember we were the last to report */ - } else { - if (type == IGMP_LEAVE_GROUP) { - dest = &allrouters; - ip_addr_copy(igmp->igmp_group_address, group->group_address); - } - } - - if ((type == IGMP_V2_MEMB_REPORT) || (type == IGMP_LEAVE_GROUP)) { - igmp->igmp_msgtype = type; - igmp->igmp_maxresp = 0; - igmp->igmp_checksum = 0; - igmp->igmp_checksum = inet_chksum(igmp, IGMP_MINLEN); - - igmp_ip_output_if(p, &src, dest, group->netif); - } - - pbuf_free(p); - } else { - LWIP_DEBUGF(IGMP_DEBUG, ("igmp_send: not enough memory for igmp_send\n")); - IGMP_STATS_INC(igmp.memerr); - } -} - -#endif /* LWIP_IGMP */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/inet.c b/user/mpy/lib/lwip/src/core/ipv4/inet.c deleted file mode 100644 index e283a57..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/inet.c +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file - * Functions common to all TCP/IPv4 modules, such as the byte order functions. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/inet.h" - diff --git a/user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c b/user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c deleted file mode 100644 index 960252f..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/inet_chksum.c +++ /dev/null @@ -1,450 +0,0 @@ -/** - * @file - * Incluse internet checksum functions. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/inet_chksum.h" -#include "lwip/def.h" - -#include -#include - -/* These are some reference implementations of the checksum algorithm, with the - * aim of being simple, correct and fully portable. Checksumming is the - * first thing you would want to optimize for your platform. If you create - * your own version, link it in and in your cc.h put: - * - * #define LWIP_CHKSUM - * - * Or you can select from the implementations below by defining - * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. - */ - -#ifndef LWIP_CHKSUM -# define LWIP_CHKSUM lwip_standard_chksum -# ifndef LWIP_CHKSUM_ALGORITHM -# define LWIP_CHKSUM_ALGORITHM 2 -# endif -#endif -/* If none set: */ -#ifndef LWIP_CHKSUM_ALGORITHM -# define LWIP_CHKSUM_ALGORITHM 0 -#endif - -#if (LWIP_CHKSUM_ALGORITHM == 1) /* Version #1 */ -/** - * lwip checksum - * - * @param dataptr points to start of data to be summed at any boundary - * @param len length of data to be summed - * @return host order (!) lwip checksum (non-inverted Internet sum) - * - * @note accumulator size limits summable length to 64k - * @note host endianess is irrelevant (p3 RFC1071) - */ -static u16_t -lwip_standard_chksum(void *dataptr, u16_t len) -{ - u32_t acc; - u16_t src; - u8_t *octetptr; - - acc = 0; - /* dataptr may be at odd or even addresses */ - octetptr = (u8_t*)dataptr; - while (len > 1) { - /* declare first octet as most significant - thus assume network order, ignoring host order */ - src = (*octetptr) << 8; - octetptr++; - /* declare second octet as least significant */ - src |= (*octetptr); - octetptr++; - acc += src; - len -= 2; - } - if (len > 0) { - /* accumulate remaining octet */ - src = (*octetptr) << 8; - acc += src; - } - /* add deferred carry bits */ - acc = (acc >> 16) + (acc & 0x0000ffffUL); - if ((acc & 0xffff0000UL) != 0) { - acc = (acc >> 16) + (acc & 0x0000ffffUL); - } - /* This maybe a little confusing: reorder sum using htons() - instead of ntohs() since it has a little less call overhead. - The caller must invert bits for Internet sum ! */ - return htons((u16_t)acc); -} -#endif - -#if (LWIP_CHKSUM_ALGORITHM == 2) /* Alternative version #2 */ -/* - * Curt McDowell - * Broadcom Corp. - * csm@broadcom.com - * - * IP checksum two bytes at a time with support for - * unaligned buffer. - * Works for len up to and including 0x20000. - * by Curt McDowell, Broadcom Corp. 12/08/2005 - * - * @param dataptr points to start of data to be summed at any boundary - * @param len length of data to be summed - * @return host order (!) lwip checksum (non-inverted Internet sum) - */ - -static u16_t -lwip_standard_chksum(void *dataptr, int len) -{ - u8_t *pb = (u8_t *)dataptr; - u16_t *ps, t = 0; - u32_t sum = 0; - int odd = ((mem_ptr_t)pb & 1); - - /* Get aligned to u16_t */ - if (odd && len > 0) { - ((u8_t *)&t)[1] = *pb++; - len--; - } - - /* Add the bulk of the data */ - ps = (u16_t *)(void *)pb; - while (len > 1) { - sum += *ps++; - len -= 2; - } - - /* Consume left-over byte, if any */ - if (len > 0) { - ((u8_t *)&t)[0] = *(u8_t *)ps; - } - - /* Add end bytes */ - sum += t; - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - sum = FOLD_U32T(sum); - sum = FOLD_U32T(sum); - - /* Swap if alignment was odd */ - if (odd) { - sum = SWAP_BYTES_IN_WORD(sum); - } - - return (u16_t)sum; -} -#endif - -#if (LWIP_CHKSUM_ALGORITHM == 3) /* Alternative version #3 */ -/** - * An optimized checksum routine. Basically, it uses loop-unrolling on - * the checksum loop, treating the head and tail bytes specially, whereas - * the inner loop acts on 8 bytes at a time. - * - * @arg start of buffer to be checksummed. May be an odd byte address. - * @len number of bytes in the buffer to be checksummed. - * @return host order (!) lwip checksum (non-inverted Internet sum) - * - * by Curt McDowell, Broadcom Corp. December 8th, 2005 - */ - -static u16_t -lwip_standard_chksum(void *dataptr, int len) -{ - u8_t *pb = (u8_t *)dataptr; - u16_t *ps, t = 0; - u32_t *pl; - u32_t sum = 0, tmp; - /* starts at odd byte address? */ - int odd = ((mem_ptr_t)pb & 1); - - if (odd && len > 0) { - ((u8_t *)&t)[1] = *pb++; - len--; - } - - ps = (u16_t *)pb; - - if (((mem_ptr_t)ps & 3) && len > 1) { - sum += *ps++; - len -= 2; - } - - pl = (u32_t *)ps; - - while (len > 7) { - tmp = sum + *pl++; /* ping */ - if (tmp < sum) { - tmp++; /* add back carry */ - } - - sum = tmp + *pl++; /* pong */ - if (sum < tmp) { - sum++; /* add back carry */ - } - - len -= 8; - } - - /* make room in upper bits */ - sum = FOLD_U32T(sum); - - ps = (u16_t *)pl; - - /* 16-bit aligned word remaining? */ - while (len > 1) { - sum += *ps++; - len -= 2; - } - - /* dangling tail byte remaining? */ - if (len > 0) { /* include odd byte */ - ((u8_t *)&t)[0] = *(u8_t *)ps; - } - - sum += t; /* add end bytes */ - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - sum = FOLD_U32T(sum); - sum = FOLD_U32T(sum); - - if (odd) { - sum = SWAP_BYTES_IN_WORD(sum); - } - - return (u16_t)sum; -} -#endif - -/* inet_chksum_pseudo: - * - * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. - * IP addresses are expected to be in network byte order. - * - * @param p chain of pbufs over that a checksum should be calculated (ip data part) - * @param src source ip address (used for checksum of pseudo header) - * @param dst destination ip address (used for checksum of pseudo header) - * @param proto ip protocol (used for checksum of pseudo header) - * @param proto_len length of the ip data part (used for checksum of pseudo header) - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -inet_chksum_pseudo(struct pbuf *p, - ip_addr_t *src, ip_addr_t *dest, - u8_t proto, u16_t proto_len) -{ - u32_t acc; - u32_t addr; - struct pbuf *q; - u8_t swapped; - - acc = 0; - swapped = 0; - /* iterate through all pbuf in chain */ - for(q = p; q != NULL; q = q->next) { - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", - (void *)q, (void *)q->next)); - acc += LWIP_CHKSUM(q->payload, q->len); - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ - /* just executing this next line is probably faster that the if statement needed - to check whether we really need to execute it, and does no harm */ - acc = FOLD_U32T(acc); - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = SWAP_BYTES_IN_WORD(acc); - } - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ - } - - if (swapped) { - acc = SWAP_BYTES_IN_WORD(acc); - } - addr = ip4_addr_get_u32(src); - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - addr = ip4_addr_get_u32(dest); - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - acc += (u32_t)htons((u16_t)proto); - acc += (u32_t)htons(proto_len); - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); - return (u16_t)~(acc & 0xffffUL); -} - -/* inet_chksum_pseudo: - * - * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. - * IP addresses are expected to be in network byte order. - * - * @param p chain of pbufs over that a checksum should be calculated (ip data part) - * @param src source ip address (used for checksum of pseudo header) - * @param dst destination ip address (used for checksum of pseudo header) - * @param proto ip protocol (used for checksum of pseudo header) - * @param proto_len length of the ip data part (used for checksum of pseudo header) - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -inet_chksum_pseudo_partial(struct pbuf *p, - ip_addr_t *src, ip_addr_t *dest, - u8_t proto, u16_t proto_len, u16_t chksum_len) -{ - u32_t acc; - u32_t addr; - struct pbuf *q; - u8_t swapped; - u16_t chklen; - - acc = 0; - swapped = 0; - /* iterate through all pbuf in chain */ - for(q = p; (q != NULL) && (chksum_len > 0); q = q->next) { - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", - (void *)q, (void *)q->next)); - chklen = q->len; - if (chklen > chksum_len) { - chklen = chksum_len; - } - acc += LWIP_CHKSUM(q->payload, chklen); - chksum_len -= chklen; - LWIP_ASSERT("delete me", chksum_len < 0x7fff); - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ - /* fold the upper bit down */ - acc = FOLD_U32T(acc); - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = SWAP_BYTES_IN_WORD(acc); - } - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ - } - - if (swapped) { - acc = SWAP_BYTES_IN_WORD(acc); - } - addr = ip4_addr_get_u32(src); - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - addr = ip4_addr_get_u32(dest); - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - acc += (u32_t)htons((u16_t)proto); - acc += (u32_t)htons(proto_len); - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); - return (u16_t)~(acc & 0xffffUL); -} - -/* inet_chksum: - * - * Calculates the Internet checksum over a portion of memory. Used primarily for IP - * and ICMP. - * - * @param dataptr start of the buffer to calculate the checksum (no alignment needed) - * @param len length of the buffer to calculate the checksum - * @return checksum (as u16_t) to be saved directly in the protocol header - */ - -u16_t -inet_chksum(void *dataptr, u16_t len) -{ - return ~LWIP_CHKSUM(dataptr, len); -} - -/** - * Calculate a checksum over a chain of pbufs (without pseudo-header, much like - * inet_chksum only pbufs are used). - * - * @param p pbuf chain over that the checksum should be calculated - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -inet_chksum_pbuf(struct pbuf *p) -{ - u32_t acc; - struct pbuf *q; - u8_t swapped; - - acc = 0; - swapped = 0; - for(q = p; q != NULL; q = q->next) { - acc += LWIP_CHKSUM(q->payload, q->len); - acc = FOLD_U32T(acc); - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = SWAP_BYTES_IN_WORD(acc); - } - } - - if (swapped) { - acc = SWAP_BYTES_IN_WORD(acc); - } - return (u16_t)~(acc & 0xffffUL); -} - -/* These are some implementations for LWIP_CHKSUM_COPY, which copies data - * like MEMCPY but generates a checksum at the same time. Since this is a - * performance-sensitive function, you might want to create your own version - * in assembly targeted at your hardware by defining it in lwipopts.h: - * #define LWIP_CHKSUM_COPY(dst, src, len) your_chksum_copy(dst, src, len) - */ - -#if (LWIP_CHKSUM_COPY_ALGORITHM == 1) /* Version #1 */ -/** Safe but slow: first call MEMCPY, then call LWIP_CHKSUM. - * For architectures with big caches, data might still be in cache when - * generating the checksum after copying. - */ -u16_t -lwip_chksum_copy(void *dst, const void *src, u16_t len) -{ - MEMCPY(dst, src, len); - return LWIP_CHKSUM(dst, len); -} -#endif /* (LWIP_CHKSUM_COPY_ALGORITHM == 1) */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/ip.c b/user/mpy/lib/lwip/src/core/ipv4/ip.c deleted file mode 100644 index 95d2db4..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/ip.c +++ /dev/null @@ -1,924 +0,0 @@ -/** - * @file - * This is the IPv4 layer implementation for incoming and outgoing IP traffic. - * - * @see ip_frag.c - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/ip_frag.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/igmp.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcp_impl.h" -#include "lwip/snmp.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" -#include "lwip/stats.h" -#include "arch/perf.h" - -#include - -/** Set this to 0 in the rare case of wanting to call an extra function to - * generate the IP checksum (in contrast to calculating it on-the-fly). */ -#ifndef LWIP_INLINE_IP_CHKSUM -#define LWIP_INLINE_IP_CHKSUM 1 -#endif -#if LWIP_INLINE_IP_CHKSUM && CHECKSUM_GEN_IP -#define CHECKSUM_GEN_IP_INLINE 1 -#else -#define CHECKSUM_GEN_IP_INLINE 0 -#endif - -#if LWIP_DHCP || defined(LWIP_IP_ACCEPT_UDP_PORT) -#define IP_ACCEPT_LINK_LAYER_ADDRESSING 1 - -/** Some defines for DHCP to let link-layer-addressed packets through while the - * netif is down. - * To use this in your own application/protocol, define LWIP_IP_ACCEPT_UDP_PORT - * to return 1 if the port is accepted and 0 if the port is not accepted. - */ -#if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) -/* accept DHCP client port and custom port */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (((port) == PP_NTOHS(DHCP_CLIENT_PORT)) \ - || (LWIP_IP_ACCEPT_UDP_PORT(port))) -#elif defined(LWIP_IP_ACCEPT_UDP_PORT) /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ -/* accept custom port only */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (LWIP_IP_ACCEPT_UDP_PORT(port)) -#else /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ -/* accept DHCP client port only */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) ((port) == PP_NTOHS(DHCP_CLIENT_PORT)) -#endif /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ - -#else /* LWIP_DHCP */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSING 0 -#endif /* LWIP_DHCP */ - -/** - * The interface that provided the packet for the current callback - * invocation. - */ -struct netif *current_netif; - -/** - * Header of the input packet currently being processed. - */ -const struct ip_hdr *current_header; -/** Source IP address of current_header */ -ip_addr_t current_iphdr_src; -/** Destination IP address of current_header */ -ip_addr_t current_iphdr_dest; - -/** The IP header ID of the next outgoing IP packet */ -static u16_t ip_id; - -/** - * Finds the appropriate network interface for a given IP address. It - * searches the list of network interfaces linearly. A match is found - * if the masked IP address of the network interface equals the masked - * IP address given to the function. - * - * @param dest the destination IP address for which to find the route - * @return the netif on which to send to reach dest - */ -struct netif * -ip_route(ip_addr_t *dest) -{ - struct netif *netif; - -#ifdef LWIP_HOOK_IP4_ROUTE - netif = LWIP_HOOK_IP4_ROUTE(dest); - if (netif != NULL) { - return netif; - } -#endif - - /* iterate through netifs */ - for (netif = netif_list; netif != NULL; netif = netif->next) { - /* network mask matches? */ - if (netif_is_up(netif)) { - if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { - /* return netif on which to forward IP packet */ - return netif; - } - } - } - if ((netif_default == NULL) || (!netif_is_up(netif_default))) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); - IP_STATS_INC(ip.rterr); - snmp_inc_ipoutnoroutes(); - return NULL; - } - /* no matching netif found, use default netif */ - return netif_default; -} - -#if IP_FORWARD -/** - * Determine whether an IP address is in a reserved set of addresses - * that may not be forwarded, or whether datagrams to that destination - * may be forwarded. - * @param p the packet to forward - * @param dest the destination IP address - * @return 1: can forward 0: discard - */ -static int -ip_canforward(struct pbuf *p) -{ - u32_t addr = ip4_addr_get_u32(ip_current_dest_addr()); - - if (p->flags & PBUF_FLAG_LLBCAST) { - /* don't route link-layer broadcasts */ - return 0; - } - if ((p->flags & PBUF_FLAG_LLMCAST) && !IP_MULTICAST(addr)) { - /* don't route link-layer multicasts unless the destination address is an IP - multicast address */ - return 0; - } - if (IP_EXPERIMENTAL(addr)) { - return 0; - } - if (IP_CLASSA(addr)) { - u32_t net = addr & IP_CLASSA_NET; - if ((net == 0) || (net == (IP_LOOPBACKNET << IP_CLASSA_NSHIFT))) { - /* don't route loopback packets */ - return 0; - } - } - return 1; -} - -/** - * Forwards an IP packet. It finds an appropriate route for the - * packet, decrements the TTL value of the packet, adjusts the - * checksum and outputs the packet on the appropriate interface. - * - * @param p the packet to forward (p->payload points to IP header) - * @param iphdr the IP header of the input packet - * @param inp the netif on which this packet was received - */ -static void -ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) -{ - struct netif *netif; - - PERF_START; - - if (!ip_canforward(p)) { - goto return_noroute; - } - - /* RFC3927 2.7: do not forward link-local addresses */ - if (ip_addr_islinklocal(¤t_iphdr_dest)) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not forwarding LLA %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(¤t_iphdr_dest), ip4_addr2_16(¤t_iphdr_dest), - ip4_addr3_16(¤t_iphdr_dest), ip4_addr4_16(¤t_iphdr_dest))); - goto return_noroute; - } - - /* Find network interface where to forward this IP packet to. */ - netif = ip_route(¤t_iphdr_dest); - if (netif == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for %"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n", - ip4_addr1_16(¤t_iphdr_dest), ip4_addr2_16(¤t_iphdr_dest), - ip4_addr3_16(¤t_iphdr_dest), ip4_addr4_16(¤t_iphdr_dest))); - /* @todo: send ICMP_DUR_NET? */ - goto return_noroute; - } -#if !IP_FORWARD_ALLOW_TX_ON_RX_NETIF - /* Do not forward packets onto the same network interface on which - * they arrived. */ - if (netif == inp) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n")); - goto return_noroute; - } -#endif /* IP_FORWARD_ALLOW_TX_ON_RX_NETIF */ - - /* decrement TTL */ - IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1); - /* send ICMP if TTL == 0 */ - if (IPH_TTL(iphdr) == 0) { - snmp_inc_ipinhdrerrors(); -#if LWIP_ICMP - /* Don't send ICMP messages in response to ICMP messages */ - if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) { - icmp_time_exceeded(p, ICMP_TE_TTL); - } -#endif /* LWIP_ICMP */ - return; - } - - /* Incrementally update the IP checksum. */ - if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffffU - 0x100)) { - IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100) + 1); - } else { - IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100)); - } - - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(¤t_iphdr_dest), ip4_addr2_16(¤t_iphdr_dest), - ip4_addr3_16(¤t_iphdr_dest), ip4_addr4_16(¤t_iphdr_dest))); - - IP_STATS_INC(ip.fw); - IP_STATS_INC(ip.xmit); - snmp_inc_ipforwdatagrams(); - - PERF_STOP("ip_forward"); - /* don't fragment if interface has mtu set to 0 [loopif] */ - if (netif->mtu && (p->tot_len > netif->mtu)) { - if ((IPH_OFFSET(iphdr) & PP_NTOHS(IP_DF)) == 0) { -#if IP_FRAG - ip_frag(p, netif, ip_current_dest_addr()); -#else /* IP_FRAG */ - /* @todo: send ICMP Destination Unreacheable code 13 "Communication administratively prohibited"? */ -#endif /* IP_FRAG */ - } else { - /* send ICMP Destination Unreacheable code 4: "Fragmentation Needed and DF Set" */ - icmp_dest_unreach(p, ICMP_DUR_FRAG); - } - return; - } - /* transmit pbuf on chosen interface */ - netif->output(netif, p, ¤t_iphdr_dest); - return; -return_noroute: - snmp_inc_ipoutnoroutes(); -} -#endif /* IP_FORWARD */ - -/** - * This function is called by the network interface device driver when - * an IP packet is received. The function does the basic checks of the - * IP header such as packet size being at least larger than the header - * size etc. If the packet was not destined for us, the packet is - * forwarded (using ip_forward). The IP checksum is always checked. - * - * Finally, the packet is sent to the upper layer protocol input function. - * - * @param p the received IP packet (p->payload points to IP header) - * @param inp the netif on which this packet was received - * @return ERR_OK if the packet was processed (could return ERR_* if it wasn't - * processed, but currently always returns ERR_OK) - */ -err_t -ip_input(struct pbuf *p, struct netif *inp) -{ - struct ip_hdr *iphdr; - struct netif *netif; - u16_t iphdr_hlen; - u16_t iphdr_len; -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - int check_ip_src=1; -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - - IP_STATS_INC(ip.recv); - snmp_inc_ipinreceives(); - - /* identify the IP header */ - iphdr = (struct ip_hdr *)p->payload; - if (IPH_V(iphdr) != 4) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr))); - ip_debug_print(p); - pbuf_free(p); - IP_STATS_INC(ip.err); - IP_STATS_INC(ip.drop); - snmp_inc_ipinhdrerrors(); - return ERR_OK; - } - -#ifdef LWIP_HOOK_IP4_INPUT - if (LWIP_HOOK_IP4_INPUT(p, inp)) { - /* the packet has been eaten */ - return ERR_OK; - } -#endif - - /* obtain IP header length in number of 32-bit words */ - iphdr_hlen = IPH_HL(iphdr); - /* calculate IP header length in bytes */ - iphdr_hlen *= 4; - /* obtain ip length in bytes */ - iphdr_len = ntohs(IPH_LEN(iphdr)); - - /* header length exceeds first pbuf length, or ip length exceeds total pbuf length? */ - if ((iphdr_hlen > p->len) || (iphdr_len > p->tot_len)) { - if (iphdr_hlen > p->len) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IP header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n", - iphdr_hlen, p->len)); - } - if (iphdr_len > p->tot_len) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IP (len %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n", - iphdr_len, p->tot_len)); - } - /* free (drop) packet pbufs */ - pbuf_free(p); - IP_STATS_INC(ip.lenerr); - IP_STATS_INC(ip.drop); - snmp_inc_ipindiscards(); - return ERR_OK; - } - - /* verify checksum */ -#if CHECKSUM_CHECK_IP - if (inet_chksum(iphdr, iphdr_hlen) != 0) { - - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdr_hlen))); - ip_debug_print(p); - pbuf_free(p); - IP_STATS_INC(ip.chkerr); - IP_STATS_INC(ip.drop); - snmp_inc_ipinhdrerrors(); - return ERR_OK; - } -#endif - - /* Trim pbuf. This should have been done at the netif layer, - * but we'll do it anyway just to be sure that its done. */ - pbuf_realloc(p, iphdr_len); - - /* copy IP addresses to aligned ip_addr_t */ - ip_addr_copy(current_iphdr_dest, iphdr->dest); - ip_addr_copy(current_iphdr_src, iphdr->src); - - /* match packet against an interface, i.e. is this packet for us? */ -#if LWIP_IGMP - if (ip_addr_ismulticast(¤t_iphdr_dest)) { - if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ¤t_iphdr_dest))) { - netif = inp; - } else { - netif = NULL; - } - } else -#endif /* LWIP_IGMP */ - { - /* start trying with inp. if that's not acceptable, start walking the - list of configured netifs. - 'first' is used as a boolean to mark whether we started walking the list */ - int first = 1; - netif = inp; - do { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n", - ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(&netif->ip_addr), - ip4_addr_get_u32(&iphdr->dest) & ip4_addr_get_u32(&netif->netmask), - ip4_addr_get_u32(&netif->ip_addr) & ip4_addr_get_u32(&netif->netmask), - ip4_addr_get_u32(&iphdr->dest) & ~ip4_addr_get_u32(&netif->netmask))); - - /* interface is up and configured? */ - if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr)))) { - /* unicast to this interface address? */ - if (ip_addr_cmp(¤t_iphdr_dest, &(netif->ip_addr)) || - /* or broadcast on this interface network address? */ - ip_addr_isbroadcast(¤t_iphdr_dest, netif)) { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n", - netif->name[0], netif->name[1])); - /* break out of for loop */ - break; - } -#if LWIP_AUTOIP - /* connections to link-local addresses must persist after changing - the netif's address (RFC3927 ch. 1.9) */ - if ((netif->autoip != NULL) && - ip_addr_cmp(¤t_iphdr_dest, &(netif->autoip->llipaddr))) { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: LLA packet accepted on interface %c%c\n", - netif->name[0], netif->name[1])); - /* break out of for loop */ - break; - } -#endif /* LWIP_AUTOIP */ - } - if (first) { - first = 0; - netif = netif_list; - } else { - netif = netif->next; - } - if (netif == inp) { - netif = netif->next; - } - } while(netif != NULL); - } - -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - /* Pass DHCP messages regardless of destination address. DHCP traffic is addressed - * using link layer addressing (such as Ethernet MAC) so we must not filter on IP. - * According to RFC 1542 section 3.1.1, referred by RFC 2131). - * - * If you want to accept private broadcast communication while a netif is down, - * define LWIP_IP_ACCEPT_UDP_PORT(dst_port), e.g.: - * - * #define LWIP_IP_ACCEPT_UDP_PORT(dst_port) ((dst_port) == PP_NTOHS(12345)) - */ - if (netif == NULL) { - /* remote port is DHCP server? */ - if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { - struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)iphdr + iphdr_hlen); - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: UDP packet to DHCP client port %"U16_F"\n", - ntohs(udphdr->dest))); - if (IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(udphdr->dest)) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: DHCP packet accepted.\n")); - netif = inp; - check_ip_src = 0; - } - } - } -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - - /* broadcast or multicast packet source address? Compliant with RFC 1122: 3.2.1.3 */ -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - /* DHCP servers need 0.0.0.0 to be allowed as source address (RFC 1.1.2.2: 3.2.1.3/a) */ - if (check_ip_src && !ip_addr_isany(¤t_iphdr_src)) -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - { if ((ip_addr_isbroadcast(¤t_iphdr_src, inp)) || - (ip_addr_ismulticast(¤t_iphdr_src))) { - /* packet source is not valid */ - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("ip_input: packet source is not valid.\n")); - /* free (drop) packet pbufs */ - pbuf_free(p); - IP_STATS_INC(ip.drop); - snmp_inc_ipinaddrerrors(); - snmp_inc_ipindiscards(); - return ERR_OK; - } - } - - /* packet not for us? */ - if (netif == NULL) { - /* packet not for us, route or discard */ - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: packet not for us.\n")); -#if IP_FORWARD - /* non-broadcast packet? */ - if (!ip_addr_isbroadcast(¤t_iphdr_dest, inp)) { - /* try to forward IP packet on (other) interfaces */ - ip_forward(p, iphdr, inp); - } else -#endif /* IP_FORWARD */ - { - snmp_inc_ipinaddrerrors(); - snmp_inc_ipindiscards(); - } - pbuf_free(p); - return ERR_OK; - } - /* packet consists of multiple fragments? */ - if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) { -#if IP_REASSEMBLY /* packet fragment reassembly code present? */ - LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip_reass()\n", - ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8)); - /* reassemble the packet*/ - p = ip_reass(p); - /* packet not fully reassembled yet? */ - if (p == NULL) { - return ERR_OK; - } - iphdr = (struct ip_hdr *)p->payload; -#else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */ - pbuf_free(p); - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n", - ntohs(IPH_OFFSET(iphdr)))); - IP_STATS_INC(ip.opterr); - IP_STATS_INC(ip.drop); - /* unsupported protocol feature */ - snmp_inc_ipinunknownprotos(); - return ERR_OK; -#endif /* IP_REASSEMBLY */ - } - -#if IP_OPTIONS_ALLOWED == 0 /* no support for IP options in the IP header? */ - -#if LWIP_IGMP - /* there is an extra "router alert" option in IGMP messages which we allow for but do not police */ - if((iphdr_hlen > IP_HLEN) && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) { -#else - if (iphdr_hlen > IP_HLEN) { -#endif /* LWIP_IGMP */ - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since there were IP options (while IP_OPTIONS_ALLOWED == 0).\n")); - pbuf_free(p); - IP_STATS_INC(ip.opterr); - IP_STATS_INC(ip.drop); - /* unsupported protocol feature */ - snmp_inc_ipinunknownprotos(); - return ERR_OK; - } -#endif /* IP_OPTIONS_ALLOWED == 0 */ - - /* send to upper layers */ - LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n")); - ip_debug_print(p); - LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len)); - - current_netif = inp; - current_header = iphdr; - -#if LWIP_RAW - /* raw input did not eat the packet? */ - if (raw_input(p, inp) == 0) -#endif /* LWIP_RAW */ - { - switch (IPH_PROTO(iphdr)) { -#if LWIP_UDP - case IP_PROTO_UDP: -#if LWIP_UDPLITE - case IP_PROTO_UDPLITE: -#endif /* LWIP_UDPLITE */ - snmp_inc_ipindelivers(); - udp_input(p, inp); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case IP_PROTO_TCP: - snmp_inc_ipindelivers(); - tcp_input(p, inp); - break; -#endif /* LWIP_TCP */ -#if LWIP_ICMP - case IP_PROTO_ICMP: - snmp_inc_ipindelivers(); - icmp_input(p, inp); - break; -#endif /* LWIP_ICMP */ -#if LWIP_IGMP - case IP_PROTO_IGMP: - igmp_input(p, inp, ¤t_iphdr_dest); - break; -#endif /* LWIP_IGMP */ - default: -#if LWIP_ICMP - /* send ICMP destination protocol unreachable unless is was a broadcast */ - if (!ip_addr_isbroadcast(¤t_iphdr_dest, inp) && - !ip_addr_ismulticast(¤t_iphdr_dest)) { - p->payload = iphdr; - icmp_dest_unreach(p, ICMP_DUR_PROTO); - } -#endif /* LWIP_ICMP */ - pbuf_free(p); - - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr))); - - IP_STATS_INC(ip.proterr); - IP_STATS_INC(ip.drop); - snmp_inc_ipinunknownprotos(); - } - } - - current_netif = NULL; - current_header = NULL; - ip_addr_set_any(¤t_iphdr_src); - ip_addr_set_any(¤t_iphdr_dest); - - return ERR_OK; -} - -/** - * Sends an IP packet on a network interface. This function constructs - * the IP header and calculates the IP header checksum. If the source - * IP address is NULL, the IP address of the outgoing network - * interface is filled in as source address. - * If the destination IP address is IP_HDRINCL, p is assumed to already - * include an IP header and p->payload points to it instead of the data. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param tos the TOS value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * @param netif the netif on which to send this packet - * @return ERR_OK if the packet was sent OK - * ERR_BUF if p doesn't have enough space for IP/LINK headers - * returns errors returned by netif->output - * - * @note ip_id: RFC791 "some host may be able to simply use - * unique identifiers independent of destination" - */ -err_t -ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, - u8_t proto, struct netif *netif) -{ -#if IP_OPTIONS_SEND - return ip_output_if_opt(p, src, dest, ttl, tos, proto, netif, NULL, 0); -} - -/** - * Same as ip_output_if() but with the possibility to include IP options: - * - * @ param ip_options pointer to the IP options, copied into the IP header - * @ param optlen length of ip_options - */ -err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, - u16_t optlen) -{ -#endif /* IP_OPTIONS_SEND */ - struct ip_hdr *iphdr; - ip_addr_t dest_addr; -#if CHECKSUM_GEN_IP_INLINE - u32_t chk_sum = 0; -#endif /* CHECKSUM_GEN_IP_INLINE */ - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - snmp_inc_ipoutrequests(); - - /* Should the IP header be generated or is it already included in p? */ - if (dest != IP_HDRINCL) { - u16_t ip_hlen = IP_HLEN; -#if IP_OPTIONS_SEND - u16_t optlen_aligned = 0; - if (optlen != 0) { -#if CHECKSUM_GEN_IP_INLINE - int i; -#endif /* CHECKSUM_GEN_IP_INLINE */ - /* round up to a multiple of 4 */ - optlen_aligned = ((optlen + 3) & ~3); - ip_hlen += optlen_aligned; - /* First write in the IP options */ - if (pbuf_header(p, optlen_aligned)) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output_if_opt: not enough room for IP options in pbuf\n")); - IP_STATS_INC(ip.err); - snmp_inc_ipoutdiscards(); - return ERR_BUF; - } - MEMCPY(p->payload, ip_options, optlen); - if (optlen < optlen_aligned) { - /* zero the remaining bytes */ - memset(((char*)p->payload) + optlen, 0, optlen_aligned - optlen); - } -#if CHECKSUM_GEN_IP_INLINE - for (i = 0; i < optlen_aligned/2; i++) { - chk_sum += ((u16_t*)p->payload)[i]; - } -#endif /* CHECKSUM_GEN_IP_INLINE */ - } -#endif /* IP_OPTIONS_SEND */ - /* generate IP header */ - if (pbuf_header(p, IP_HLEN)) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output: not enough room for IP header in pbuf\n")); - - IP_STATS_INC(ip.err); - snmp_inc_ipoutdiscards(); - return ERR_BUF; - } - - iphdr = (struct ip_hdr *)p->payload; - LWIP_ASSERT("check that first pbuf can hold struct ip_hdr", - (p->len >= sizeof(struct ip_hdr))); - - IPH_TTL_SET(iphdr, ttl); - IPH_PROTO_SET(iphdr, proto); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += LWIP_MAKE_U16(proto, ttl); -#endif /* CHECKSUM_GEN_IP_INLINE */ - - /* dest cannot be NULL here */ - ip_addr_copy(iphdr->dest, *dest); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += ip4_addr_get_u32(&iphdr->dest) & 0xFFFF; - chk_sum += ip4_addr_get_u32(&iphdr->dest) >> 16; -#endif /* CHECKSUM_GEN_IP_INLINE */ - - IPH_VHL_SET(iphdr, 4, ip_hlen / 4); - IPH_TOS_SET(iphdr, tos); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += LWIP_MAKE_U16(tos, iphdr->_v_hl); -#endif /* CHECKSUM_GEN_IP_INLINE */ - IPH_LEN_SET(iphdr, htons(p->tot_len)); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += iphdr->_len; -#endif /* CHECKSUM_GEN_IP_INLINE */ - IPH_OFFSET_SET(iphdr, 0); - IPH_ID_SET(iphdr, htons(ip_id)); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += iphdr->_id; -#endif /* CHECKSUM_GEN_IP_INLINE */ - ++ip_id; - - if (ip_addr_isany(src)) { - ip_addr_copy(iphdr->src, netif->ip_addr); - } else { - /* src cannot be NULL here */ - ip_addr_copy(iphdr->src, *src); - } - -#if CHECKSUM_GEN_IP_INLINE - chk_sum += ip4_addr_get_u32(&iphdr->src) & 0xFFFF; - chk_sum += ip4_addr_get_u32(&iphdr->src) >> 16; - chk_sum = (chk_sum >> 16) + (chk_sum & 0xFFFF); - chk_sum = (chk_sum >> 16) + chk_sum; - chk_sum = ~chk_sum; - iphdr->_chksum = chk_sum; /* network order */ -#else /* CHECKSUM_GEN_IP_INLINE */ - IPH_CHKSUM_SET(iphdr, 0); -#if CHECKSUM_GEN_IP - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen)); -#endif -#endif /* CHECKSUM_GEN_IP_INLINE */ - } else { - /* IP header already included in p */ - iphdr = (struct ip_hdr *)p->payload; - ip_addr_copy(dest_addr, iphdr->dest); - dest = &dest_addr; - } - - IP_STATS_INC(ip.xmit); - - LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num)); - ip_debug_print(p); - -#if ENABLE_LOOPBACK - if (ip_addr_cmp(dest, &netif->ip_addr)) { - /* Packet to self, enqueue it for loopback */ - LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()")); - return netif_loop_output(netif, p, dest); - } -#if LWIP_IGMP - if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) { - netif_loop_output(netif, p, dest); - } -#endif /* LWIP_IGMP */ -#endif /* ENABLE_LOOPBACK */ -#if IP_FRAG - /* don't fragment if interface has mtu set to 0 [loopif] */ - if (netif->mtu && (p->tot_len > netif->mtu)) { - return ip_frag(p, netif, dest); - } -#endif /* IP_FRAG */ - - LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); - return netif->output(netif, p, dest); -} - -/** - * Simple interface to ip_output_if. It finds the outgoing network - * interface and calls upon ip_output_if to do the actual work. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param tos the TOS value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * - * @return ERR_RTE if no route is found - * see ip_output_if() for more return values - */ -err_t -ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto) -{ - struct netif *netif; - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); - IP_STATS_INC(ip.rterr); - return ERR_RTE; - } - - return ip_output_if(p, src, dest, ttl, tos, proto, netif); -} - -#if LWIP_NETIF_HWADDRHINT -/** Like ip_output, but takes and addr_hint pointer that is passed on to netif->addr_hint - * before calling ip_output_if. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param tos the TOS value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * @param addr_hint address hint pointer set to netif->addr_hint before - * calling ip_output_if() - * - * @return ERR_RTE if no route is found - * see ip_output_if() for more return values - */ -err_t -ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint) -{ - struct netif *netif; - err_t err; - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); - IP_STATS_INC(ip.rterr); - return ERR_RTE; - } - - NETIF_SET_HWADDRHINT(netif, addr_hint); - err = ip_output_if(p, src, dest, ttl, tos, proto, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - - return err; -} -#endif /* LWIP_NETIF_HWADDRHINT*/ - -#if IP_DEBUG -/* Print an IP header by using LWIP_DEBUGF - * @param p an IP packet, p->payload pointing to the IP header - */ -void -ip_debug_print(struct pbuf *p) -{ - struct ip_hdr *iphdr = (struct ip_hdr *)p->payload; - - LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" | 0x%02"X16_F" | %5"U16_F" | (v, hl, tos, len)\n", - IPH_V(iphdr), - IPH_HL(iphdr), - IPH_TOS(iphdr), - ntohs(IPH_LEN(iphdr)))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" |%"U16_F"%"U16_F"%"U16_F"| %4"U16_F" | (id, flags, offset)\n", - ntohs(IPH_ID(iphdr)), - ntohs(IPH_OFFSET(iphdr)) >> 15 & 1, - ntohs(IPH_OFFSET(iphdr)) >> 14 & 1, - ntohs(IPH_OFFSET(iphdr)) >> 13 & 1, - ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%04"X16_F" | (ttl, proto, chksum)\n", - IPH_TTL(iphdr), - IPH_PROTO(iphdr), - ntohs(IPH_CHKSUM(iphdr)))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (src)\n", - ip4_addr1_16(&iphdr->src), - ip4_addr2_16(&iphdr->src), - ip4_addr3_16(&iphdr->src), - ip4_addr4_16(&iphdr->src))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (dest)\n", - ip4_addr1_16(&iphdr->dest), - ip4_addr2_16(&iphdr->dest), - ip4_addr3_16(&iphdr->dest), - ip4_addr4_16(&iphdr->dest))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); -} -#endif /* IP_DEBUG */ diff --git a/user/mpy/lib/lwip/src/core/ipv4/ip_addr.c b/user/mpy/lib/lwip/src/core/ipv4/ip_addr.c deleted file mode 100644 index 8f633ff..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/ip_addr.c +++ /dev/null @@ -1,312 +0,0 @@ -/** - * @file - * This is the IPv4 address tools implementation. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" - -/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ -const ip_addr_t ip_addr_any = { IPADDR_ANY }; -const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST }; - -/** - * Determine if an address is a broadcast address on a network interface - * - * @param addr address to be checked - * @param netif the network interface against which the address is checked - * @return returns non-zero if the address is a broadcast address - */ -u8_t -ip4_addr_isbroadcast(u32_t addr, const struct netif *netif) -{ - ip_addr_t ipaddr; - ip4_addr_set_u32(&ipaddr, addr); - - /* all ones (broadcast) or all zeroes (old skool broadcast) */ - if ((~addr == IPADDR_ANY) || - (addr == IPADDR_ANY)) { - return 1; - /* no broadcast support on this network interface? */ - } else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) { - /* the given address cannot be a broadcast address - * nor can we check against any broadcast addresses */ - return 0; - /* address matches network interface address exactly? => no broadcast */ - } else if (addr == ip4_addr_get_u32(&netif->ip_addr)) { - return 0; - /* on the same (sub) network... */ - } else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask)) - /* ...and host identifier bits are all ones? =>... */ - && ((addr & ~ip4_addr_get_u32(&netif->netmask)) == - (IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) { - /* => network broadcast address */ - return 1; - } else { - return 0; - } -} - -/** Checks if a netmask is valid (starting with ones, then only zeros) - * - * @param netmask the IPv4 netmask to check (in network byte order!) - * @return 1 if the netmask is valid, 0 if it is not - */ -u8_t -ip4_addr_netmask_valid(u32_t netmask) -{ - u32_t mask; - u32_t nm_hostorder = lwip_htonl(netmask); - - /* first, check for the first zero */ - for (mask = 1UL << 31 ; mask != 0; mask >>= 1) { - if ((nm_hostorder & mask) == 0) { - break; - } - } - /* then check that there is no one */ - for (; mask != 0; mask >>= 1) { - if ((nm_hostorder & mask) != 0) { - /* there is a one after the first zero -> invalid */ - return 0; - } - } - /* no one after the first zero -> valid */ - return 1; -} - -/* Here for now until needed in other places in lwIP */ -#ifndef isprint -#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) -#define isprint(c) in_range(c, 0x20, 0x7f) -#define isdigit(c) in_range(c, '0', '9') -#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) -#define islower(c) in_range(c, 'a', 'z') -#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') -#endif - -/** - * Ascii internet address interpretation routine. - * The value returned is in network order. - * - * @param cp IP address in ascii represenation (e.g. "127.0.0.1") - * @return ip address in network order - */ -u32_t -ipaddr_addr(const char *cp) -{ - ip_addr_t val; - - if (ipaddr_aton(cp, &val)) { - return ip4_addr_get_u32(&val); - } - return (IPADDR_NONE); -} - -/** - * Check whether "cp" is a valid ascii representation - * of an Internet address and convert to a binary address. - * Returns 1 if the address is valid, 0 if not. - * This replaces inet_addr, the return value from which - * cannot distinguish between failure and a local broadcast address. - * - * @param cp IP address in ascii represenation (e.g. "127.0.0.1") - * @param addr pointer to which to save the ip address in network order - * @return 1 if cp could be converted to addr, 0 on failure - */ -int -ipaddr_aton(const char *cp, ip_addr_t *addr) -{ - u32_t val; - u8_t base; - char c; - u32_t parts[4]; - u32_t *pp = parts; - - c = *cp; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, 1-9=decimal. - */ - if (!isdigit(c)) - return (0); - val = 0; - base = 10; - if (c == '0') { - c = *++cp; - if (c == 'x' || c == 'X') { - base = 16; - c = *++cp; - } else - base = 8; - } - for (;;) { - if (isdigit(c)) { - val = (val * base) + (int)(c - '0'); - c = *++cp; - } else if (base == 16 && isxdigit(c)) { - val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A')); - c = *++cp; - } else - break; - } - if (c == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16 bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 3) { - return (0); - } - *pp++ = val; - c = *++cp; - } else - break; - } - /* - * Check for trailing characters. - */ - if (c != '\0' && !isspace(c)) { - return (0); - } - /* - * Concoct the address according to - * the number of parts specified. - */ - switch (pp - parts + 1) { - - case 0: - return (0); /* initial nondigit */ - - case 1: /* a -- 32 bits */ - break; - - case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffffUL) { - return (0); - } - val |= parts[0] << 24; - break; - - case 3: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffff) { - return (0); - } - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xff) { - return (0); - } - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - default: - LWIP_ASSERT("unhandled", 0); - break; - } - if (addr) { - ip4_addr_set_u32(addr, htonl(val)); - } - return (1); -} - -/** - * Convert numeric IP address into decimal dotted ASCII representation. - * returns ptr to static buffer; not reentrant! - * - * @param addr ip address in network order to convert - * @return pointer to a global static (!) buffer that holds the ASCII - * represenation of addr - */ -char * -ipaddr_ntoa(const ip_addr_t *addr) -{ - static char str[16]; - return ipaddr_ntoa_r(addr, str, 16); -} - -/** - * Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used. - * - * @param addr ip address in network order to convert - * @param buf target buffer where the string is stored - * @param buflen length of buf - * @return either pointer to buf which now holds the ASCII - * representation of addr or NULL if buf was too small - */ -char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen) -{ - u32_t s_addr; - char inv[3]; - char *rp; - u8_t *ap; - u8_t rem; - u8_t n; - u8_t i; - int len = 0; - - s_addr = ip4_addr_get_u32(addr); - - rp = buf; - ap = (u8_t *)&s_addr; - for(n = 0; n < 4; n++) { - i = 0; - do { - rem = *ap % (u8_t)10; - *ap /= (u8_t)10; - inv[i++] = '0' + rem; - } while(*ap); - while(i--) { - if (len++ >= buflen) { - return NULL; - } - *rp++ = inv[i]; - } - if (len++ >= buflen) { - return NULL; - } - *rp++ = '.'; - ap++; - } - *--rp = 0; - return buf; -} diff --git a/user/mpy/lib/lwip/src/core/ipv4/ip_frag.c b/user/mpy/lib/lwip/src/core/ipv4/ip_frag.c deleted file mode 100644 index 8d18434..0000000 --- a/user/mpy/lib/lwip/src/core/ipv4/ip_frag.c +++ /dev/null @@ -1,863 +0,0 @@ -/** - * @file - * This is the IPv4 packet segmentation and reassembly implementation. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Jani Monoses - * Simon Goldschmidt - * original reassembly code by Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip_frag.h" -#include "lwip/def.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/snmp.h" -#include "lwip/stats.h" -#include "lwip/icmp.h" - -#include - -#if IP_REASSEMBLY -/** - * The IP reassembly code currently has the following limitations: - * - IP header options are not supported - * - fragments must not overlap (e.g. due to different routes), - * currently, overlapping or duplicate fragments are thrown away - * if IP_REASS_CHECK_OVERLAP=1 (the default)! - * - * @todo: work with IP header options - */ - -/** Setting this to 0, you can turn off checking the fragments for overlapping - * regions. The code gets a little smaller. Only use this if you know that - * overlapping won't occur on your network! */ -#ifndef IP_REASS_CHECK_OVERLAP -#define IP_REASS_CHECK_OVERLAP 1 -#endif /* IP_REASS_CHECK_OVERLAP */ - -/** Set to 0 to prevent freeing the oldest datagram when the reassembly buffer is - * full (IP_REASS_MAX_PBUFS pbufs are enqueued). The code gets a little smaller. - * Datagrams will be freed by timeout only. Especially useful when MEMP_NUM_REASSDATA - * is set to 1, so one datagram can be reassembled at a time, only. */ -#ifndef IP_REASS_FREE_OLDEST -#define IP_REASS_FREE_OLDEST 1 -#endif /* IP_REASS_FREE_OLDEST */ - -#define IP_REASS_FLAG_LASTFRAG 0x01 - -/** This is a helper struct which holds the starting - * offset and the ending offset of this fragment to - * easily chain the fragments. - * It has the same packing requirements as the IP header, since it replaces - * the IP header in memory in incoming fragments (after copying it) to keep - * track of the various fragments. (-> If the IP header doesn't need packing, - * this struct doesn't need packing, too.) - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_reass_helper { - PACK_STRUCT_FIELD(struct pbuf *next_pbuf); - PACK_STRUCT_FIELD(u16_t start); - PACK_STRUCT_FIELD(u16_t end); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IP_ADDRESSES_AND_ID_MATCH(iphdrA, iphdrB) \ - (ip_addr_cmp(&(iphdrA)->src, &(iphdrB)->src) && \ - ip_addr_cmp(&(iphdrA)->dest, &(iphdrB)->dest) && \ - IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0 - -/* global variables */ -static struct ip_reassdata *reassdatagrams; -static u16_t ip_reass_pbufcount; - -/* function prototypes */ -static void ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev); -static int ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev); - -/** - * Reassembly timer base function - * for both NO_SYS == 0 and 1 (!). - * - * Should be called every 1000 msec (defined by IP_TMR_INTERVAL). - */ -void -ip_reass_tmr(void) -{ - struct ip_reassdata *r, *prev = NULL; - - r = reassdatagrams; - while (r != NULL) { - /* Decrement the timer. Once it reaches 0, - * clean up the incomplete fragment assembly */ - if (r->timer > 0) { - r->timer--; - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n",(u16_t)r->timer)); - prev = r; - r = r->next; - } else { - /* reassembly timed out */ - struct ip_reassdata *tmp; - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer timed out\n")); - tmp = r; - /* get the next pointer before freeing */ - r = r->next; - /* free the helper struct and all enqueued pbufs */ - ip_reass_free_complete_datagram(tmp, prev); - } - } -} - -/** - * Free a datagram (struct ip_reassdata) and all its pbufs. - * Updates the total count of enqueued pbufs (ip_reass_pbufcount), - * SNMP counters and sends an ICMP time exceeded packet. - * - * @param ipr datagram to free - * @param prev the previous datagram in the linked list - * @return the number of pbufs freed - */ -static int -ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) -{ - u16_t pbufs_freed = 0; - u8_t clen; - struct pbuf *p; - struct ip_reass_helper *iprh; - - LWIP_ASSERT("prev != ipr", prev != ipr); - if (prev != NULL) { - LWIP_ASSERT("prev->next == ipr", prev->next == ipr); - } - - snmp_inc_ipreasmfails(); -#if LWIP_ICMP - iprh = (struct ip_reass_helper *)ipr->p->payload; - if (iprh->start == 0) { - /* The first fragment was received, send ICMP time exceeded. */ - /* First, de-queue the first pbuf from r->p. */ - p = ipr->p; - ipr->p = iprh->next_pbuf; - /* Then, copy the original header into it. */ - SMEMCPY(p->payload, &ipr->iphdr, IP_HLEN); - icmp_time_exceeded(p, ICMP_TE_FRAG); - clen = pbuf_clen(p); - LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); - pbufs_freed += clen; - pbuf_free(p); - } -#endif /* LWIP_ICMP */ - - /* First, free all received pbufs. The individual pbufs need to be released - separately as they have not yet been chained */ - p = ipr->p; - while (p != NULL) { - struct pbuf *pcur; - iprh = (struct ip_reass_helper *)p->payload; - pcur = p; - /* get the next pointer before freeing */ - p = iprh->next_pbuf; - clen = pbuf_clen(pcur); - LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); - pbufs_freed += clen; - pbuf_free(pcur); - } - /* Then, unchain the struct ip_reassdata from the list and free it. */ - ip_reass_dequeue_datagram(ipr, prev); - LWIP_ASSERT("ip_reass_pbufcount >= clen", ip_reass_pbufcount >= pbufs_freed); - ip_reass_pbufcount -= pbufs_freed; - - return pbufs_freed; -} - -#if IP_REASS_FREE_OLDEST -/** - * Free the oldest datagram to make room for enqueueing new fragments. - * The datagram 'fraghdr' belongs to is not freed! - * - * @param fraghdr IP header of the current fragment - * @param pbufs_needed number of pbufs needed to enqueue - * (used for freeing other datagrams if not enough space) - * @return the number of pbufs freed - */ -static int -ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed) -{ - /* @todo Can't we simply remove the last datagram in the - * linked list behind reassdatagrams? - */ - struct ip_reassdata *r, *oldest, *prev; - int pbufs_freed = 0, pbufs_freed_current; - int other_datagrams; - - /* Free datagrams until being allowed to enqueue 'pbufs_needed' pbufs, - * but don't free the datagram that 'fraghdr' belongs to! */ - do { - oldest = NULL; - prev = NULL; - other_datagrams = 0; - r = reassdatagrams; - while (r != NULL) { - if (!IP_ADDRESSES_AND_ID_MATCH(&r->iphdr, fraghdr)) { - /* Not the same datagram as fraghdr */ - other_datagrams++; - if (oldest == NULL) { - oldest = r; - } else if (r->timer <= oldest->timer) { - /* older than the previous oldest */ - oldest = r; - } - } - if (r->next != NULL) { - prev = r; - } - r = r->next; - } - if (oldest != NULL) { - pbufs_freed_current = ip_reass_free_complete_datagram(oldest, prev); - pbufs_freed += pbufs_freed_current; - } - } while ((pbufs_freed < pbufs_needed) && (other_datagrams > 1)); - return pbufs_freed; -} -#endif /* IP_REASS_FREE_OLDEST */ - -/** - * Enqueues a new fragment into the fragment queue - * @param fraghdr points to the new fragments IP hdr - * @param clen number of pbufs needed to enqueue (used for freeing other datagrams if not enough space) - * @return A pointer to the queue location into which the fragment was enqueued - */ -static struct ip_reassdata* -ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen) -{ - struct ip_reassdata* ipr; - /* No matching previous fragment found, allocate a new reassdata struct */ - ipr = (struct ip_reassdata *)memp_malloc(MEMP_REASSDATA); - if (ipr == NULL) { -#if IP_REASS_FREE_OLDEST - if (ip_reass_remove_oldest_datagram(fraghdr, clen) >= clen) { - ipr = (struct ip_reassdata *)memp_malloc(MEMP_REASSDATA); - } - if (ipr == NULL) -#endif /* IP_REASS_FREE_OLDEST */ - { - IPFRAG_STATS_INC(ip_frag.memerr); - LWIP_DEBUGF(IP_REASS_DEBUG,("Failed to alloc reassdata struct\n")); - return NULL; - } - } - memset(ipr, 0, sizeof(struct ip_reassdata)); - ipr->timer = IP_REASS_MAXAGE; - - /* enqueue the new structure to the front of the list */ - ipr->next = reassdatagrams; - reassdatagrams = ipr; - /* copy the ip header for later tests and input */ - /* @todo: no ip options supported? */ - SMEMCPY(&(ipr->iphdr), fraghdr, IP_HLEN); - return ipr; -} - -/** - * Dequeues a datagram from the datagram queue. Doesn't deallocate the pbufs. - * @param ipr points to the queue entry to dequeue - */ -static void -ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) -{ - - /* dequeue the reass struct */ - if (reassdatagrams == ipr) { - /* it was the first in the list */ - reassdatagrams = ipr->next; - } else { - /* it wasn't the first, so it must have a valid 'prev' */ - LWIP_ASSERT("sanity check linked list", prev != NULL); - prev->next = ipr->next; - } - - /* now we can free the ip_reass struct */ - memp_free(MEMP_REASSDATA, ipr); -} - -/** - * Chain a new pbuf into the pbuf list that composes the datagram. The pbuf list - * will grow over time as new pbufs are rx. - * Also checks that the datagram passes basic continuity checks (if the last - * fragment was received at least once). - * @param root_p points to the 'root' pbuf for the current datagram being assembled. - * @param new_p points to the pbuf for the current fragment - * @return 0 if invalid, >0 otherwise - */ -static int -ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct pbuf *new_p) -{ - struct ip_reass_helper *iprh, *iprh_tmp, *iprh_prev=NULL; - struct pbuf *q; - u16_t offset,len; - struct ip_hdr *fraghdr; - int valid = 1; - - /* Extract length and fragment offset from current fragment */ - fraghdr = (struct ip_hdr*)new_p->payload; - len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; - offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; - - /* overwrite the fragment's ip header from the pbuf with our helper struct, - * and setup the embedded helper structure. */ - /* make sure the struct ip_reass_helper fits into the IP header */ - LWIP_ASSERT("sizeof(struct ip_reass_helper) <= IP_HLEN", - sizeof(struct ip_reass_helper) <= IP_HLEN); - iprh = (struct ip_reass_helper*)new_p->payload; - iprh->next_pbuf = NULL; - iprh->start = offset; - iprh->end = offset + len; - - /* Iterate through until we either get to the end of the list (append), - * or we find on with a larger offset (insert). */ - for (q = ipr->p; q != NULL;) { - iprh_tmp = (struct ip_reass_helper*)q->payload; - if (iprh->start < iprh_tmp->start) { - /* the new pbuf should be inserted before this */ - iprh->next_pbuf = q; - if (iprh_prev != NULL) { - /* not the fragment with the lowest offset */ -#if IP_REASS_CHECK_OVERLAP - if ((iprh->start < iprh_prev->end) || (iprh->end > iprh_tmp->start)) { - /* fragment overlaps with previous or following, throw away */ - goto freepbuf; - } -#endif /* IP_REASS_CHECK_OVERLAP */ - iprh_prev->next_pbuf = new_p; - } else { - /* fragment with the lowest offset */ - ipr->p = new_p; - } - break; - } else if(iprh->start == iprh_tmp->start) { - /* received the same datagram twice: no need to keep the datagram */ - goto freepbuf; -#if IP_REASS_CHECK_OVERLAP - } else if(iprh->start < iprh_tmp->end) { - /* overlap: no need to keep the new datagram */ - goto freepbuf; -#endif /* IP_REASS_CHECK_OVERLAP */ - } else { - /* Check if the fragments received so far have no wholes. */ - if (iprh_prev != NULL) { - if (iprh_prev->end != iprh_tmp->start) { - /* There is a fragment missing between the current - * and the previous fragment */ - valid = 0; - } - } - } - q = iprh_tmp->next_pbuf; - iprh_prev = iprh_tmp; - } - - /* If q is NULL, then we made it to the end of the list. Determine what to do now */ - if (q == NULL) { - if (iprh_prev != NULL) { - /* this is (for now), the fragment with the highest offset: - * chain it to the last fragment */ -#if IP_REASS_CHECK_OVERLAP - LWIP_ASSERT("check fragments don't overlap", iprh_prev->end <= iprh->start); -#endif /* IP_REASS_CHECK_OVERLAP */ - iprh_prev->next_pbuf = new_p; - if (iprh_prev->end != iprh->start) { - valid = 0; - } - } else { -#if IP_REASS_CHECK_OVERLAP - LWIP_ASSERT("no previous fragment, this must be the first fragment!", - ipr->p == NULL); -#endif /* IP_REASS_CHECK_OVERLAP */ - /* this is the first fragment we ever received for this ip datagram */ - ipr->p = new_p; - } - } - - /* At this point, the validation part begins: */ - /* If we already received the last fragment */ - if ((ipr->flags & IP_REASS_FLAG_LASTFRAG) != 0) { - /* and had no wholes so far */ - if (valid) { - /* then check if the rest of the fragments is here */ - /* Check if the queue starts with the first datagram */ - if (((struct ip_reass_helper*)ipr->p->payload)->start != 0) { - valid = 0; - } else { - /* and check that there are no wholes after this datagram */ - iprh_prev = iprh; - q = iprh->next_pbuf; - while (q != NULL) { - iprh = (struct ip_reass_helper*)q->payload; - if (iprh_prev->end != iprh->start) { - valid = 0; - break; - } - iprh_prev = iprh; - q = iprh->next_pbuf; - } - /* if still valid, all fragments are received - * (because to the MF==0 already arrived */ - if (valid) { - LWIP_ASSERT("sanity check", ipr->p != NULL); - LWIP_ASSERT("sanity check", - ((struct ip_reass_helper*)ipr->p->payload) != iprh); - LWIP_ASSERT("validate_datagram:next_pbuf!=NULL", - iprh->next_pbuf == NULL); - LWIP_ASSERT("validate_datagram:datagram end!=datagram len", - iprh->end == ipr->datagram_len); - } - } - } - /* If valid is 0 here, there are some fragments missing in the middle - * (since MF == 0 has already arrived). Such datagrams simply time out if - * no more fragments are received... */ - return valid; - } - /* If we come here, not all fragments were received, yet! */ - return 0; /* not yet valid! */ -#if IP_REASS_CHECK_OVERLAP -freepbuf: - ip_reass_pbufcount -= pbuf_clen(new_p); - pbuf_free(new_p); - return 0; -#endif /* IP_REASS_CHECK_OVERLAP */ -} - -/** - * Reassembles incoming IP fragments into an IP datagram. - * - * @param p points to a pbuf chain of the fragment - * @return NULL if reassembly is incomplete, ? otherwise - */ -struct pbuf * -ip_reass(struct pbuf *p) -{ - struct pbuf *r; - struct ip_hdr *fraghdr; - struct ip_reassdata *ipr; - struct ip_reass_helper *iprh; - u16_t offset, len; - u8_t clen; - struct ip_reassdata *ipr_prev = NULL; - - IPFRAG_STATS_INC(ip_frag.recv); - snmp_inc_ipreasmreqds(); - - fraghdr = (struct ip_hdr*)p->payload; - - if ((IPH_HL(fraghdr) * 4) != IP_HLEN) { - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: IP options currently not supported!\n")); - IPFRAG_STATS_INC(ip_frag.err); - goto nullreturn; - } - - offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; - len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; - - /* Check if we are allowed to enqueue more datagrams. */ - clen = pbuf_clen(p); - if ((ip_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS) { -#if IP_REASS_FREE_OLDEST - if (!ip_reass_remove_oldest_datagram(fraghdr, clen) || - ((ip_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS)) -#endif /* IP_REASS_FREE_OLDEST */ - { - /* No datagram could be freed and still too many pbufs enqueued */ - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: Overflow condition: pbufct=%d, clen=%d, MAX=%d\n", - ip_reass_pbufcount, clen, IP_REASS_MAX_PBUFS)); - IPFRAG_STATS_INC(ip_frag.memerr); - /* @todo: send ICMP time exceeded here? */ - /* drop this pbuf */ - goto nullreturn; - } - } - - /* Look for the datagram the fragment belongs to in the current datagram queue, - * remembering the previous in the queue for later dequeueing. */ - for (ipr = reassdatagrams; ipr != NULL; ipr = ipr->next) { - /* Check if the incoming fragment matches the one currently present - in the reassembly buffer. If so, we proceed with copying the - fragment into the buffer. */ - if (IP_ADDRESSES_AND_ID_MATCH(&ipr->iphdr, fraghdr)) { - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching previous fragment ID=%"X16_F"\n", - ntohs(IPH_ID(fraghdr)))); - IPFRAG_STATS_INC(ip_frag.cachehit); - break; - } - ipr_prev = ipr; - } - - if (ipr == NULL) { - /* Enqueue a new datagram into the datagram queue */ - ipr = ip_reass_enqueue_new_datagram(fraghdr, clen); - /* Bail if unable to enqueue */ - if(ipr == NULL) { - goto nullreturn; - } - } else { - if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && - ((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { - /* ipr->iphdr is not the header from the first fragment, but fraghdr is - * -> copy fraghdr into ipr->iphdr since we want to have the header - * of the first fragment (for ICMP time exceeded and later, for copying - * all options, if supported)*/ - SMEMCPY(&ipr->iphdr, fraghdr, IP_HLEN); - } - } - /* Track the current number of pbufs current 'in-flight', in order to limit - the number of fragments that may be enqueued at any one time */ - ip_reass_pbufcount += clen; - - /* At this point, we have either created a new entry or pointing - * to an existing one */ - - /* check for 'no more fragments', and update queue entry*/ - if ((IPH_OFFSET(fraghdr) & PP_NTOHS(IP_MF)) == 0) { - ipr->flags |= IP_REASS_FLAG_LASTFRAG; - ipr->datagram_len = offset + len; - LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: last fragment seen, total len %"S16_F"\n", - ipr->datagram_len)); - } - /* find the right place to insert this pbuf */ - /* @todo: trim pbufs if fragments are overlapping */ - if (ip_reass_chain_frag_into_datagram_and_validate(ipr, p)) { - /* the totally last fragment (flag more fragments = 0) was received at least - * once AND all fragments are received */ - ipr->datagram_len += IP_HLEN; - - /* save the second pbuf before copying the header over the pointer */ - r = ((struct ip_reass_helper*)ipr->p->payload)->next_pbuf; - - /* copy the original ip header back to the first pbuf */ - fraghdr = (struct ip_hdr*)(ipr->p->payload); - SMEMCPY(fraghdr, &ipr->iphdr, IP_HLEN); - IPH_LEN_SET(fraghdr, htons(ipr->datagram_len)); - IPH_OFFSET_SET(fraghdr, 0); - IPH_CHKSUM_SET(fraghdr, 0); - /* @todo: do we need to set calculate the correct checksum? */ - IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN)); - - p = ipr->p; - - /* chain together the pbufs contained within the reass_data list. */ - while(r != NULL) { - iprh = (struct ip_reass_helper*)r->payload; - - /* hide the ip header for every succeding fragment */ - pbuf_header(r, -IP_HLEN); - pbuf_cat(p, r); - r = iprh->next_pbuf; - } - /* release the sources allocate for the fragment queue entry */ - ip_reass_dequeue_datagram(ipr, ipr_prev); - - /* and adjust the number of pbufs currently queued for reassembly. */ - ip_reass_pbufcount -= pbuf_clen(p); - - /* Return the pbuf chain */ - return p; - } - /* the datagram is not (yet?) reassembled completely */ - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass_pbufcount: %d out\n", ip_reass_pbufcount)); - return NULL; - -nullreturn: - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: nullreturn\n")); - IPFRAG_STATS_INC(ip_frag.drop); - pbuf_free(p); - return NULL; -} -#endif /* IP_REASSEMBLY */ - -#if IP_FRAG -#if IP_FRAG_USES_STATIC_BUF -static u8_t buf[LWIP_MEM_ALIGN_SIZE(IP_FRAG_MAX_MTU + MEM_ALIGNMENT - 1)]; -#else /* IP_FRAG_USES_STATIC_BUF */ - -#if !LWIP_NETIF_TX_SINGLE_PBUF -/** Allocate a new struct pbuf_custom_ref */ -static struct pbuf_custom_ref* -ip_frag_alloc_pbuf_custom_ref(void) -{ - return (struct pbuf_custom_ref*)memp_malloc(MEMP_FRAG_PBUF); -} - -/** Free a struct pbuf_custom_ref */ -static void -ip_frag_free_pbuf_custom_ref(struct pbuf_custom_ref* p) -{ - LWIP_ASSERT("p != NULL", p != NULL); - memp_free(MEMP_FRAG_PBUF, p); -} - -/** Free-callback function to free a 'struct pbuf_custom_ref', called by - * pbuf_free. */ -static void -ipfrag_free_pbuf_custom(struct pbuf *p) -{ - struct pbuf_custom_ref *pcr = (struct pbuf_custom_ref*)p; - LWIP_ASSERT("pcr != NULL", pcr != NULL); - LWIP_ASSERT("pcr == p", (void*)pcr == (void*)p); - if (pcr->original != NULL) { - pbuf_free(pcr->original); - } - ip_frag_free_pbuf_custom_ref(pcr); -} -#endif /* !LWIP_NETIF_TX_SINGLE_PBUF */ -#endif /* IP_FRAG_USES_STATIC_BUF */ - -/** - * Fragment an IP datagram if too large for the netif. - * - * Chop the datagram in MTU sized chunks and send them in order - * by using a fixed size static memory buffer (PBUF_REF) or - * point PBUF_REFs into p (depending on IP_FRAG_USES_STATIC_BUF). - * - * @param p ip packet to send - * @param netif the netif on which to send - * @param dest destination ip address to which to send - * - * @return ERR_OK if sent successfully, err_t otherwise - */ -err_t -ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) -{ - struct pbuf *rambuf; -#if IP_FRAG_USES_STATIC_BUF - struct pbuf *header; -#else -#if !LWIP_NETIF_TX_SINGLE_PBUF - struct pbuf *newpbuf; -#endif - struct ip_hdr *original_iphdr; -#endif - struct ip_hdr *iphdr; - u16_t nfb; - u16_t left, cop; - u16_t mtu = netif->mtu; - u16_t ofo, omf; - u16_t last; - u16_t poff = IP_HLEN; - u16_t tmp; -#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF - u16_t newpbuflen = 0; - u16_t left_to_copy; -#endif - - /* Get a RAM based MTU sized pbuf */ -#if IP_FRAG_USES_STATIC_BUF - /* When using a static buffer, we use a PBUF_REF, which we will - * use to reference the packet (without link header). - * Layer and length is irrelevant. - */ - rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF); - if (rambuf == NULL) { - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc(PBUF_LINK, 0, PBUF_REF) failed\n")); - return ERR_MEM; - } - rambuf->tot_len = rambuf->len = mtu; - rambuf->payload = LWIP_MEM_ALIGN((void *)buf); - - /* Copy the IP header in it */ - iphdr = (struct ip_hdr *)rambuf->payload; - SMEMCPY(iphdr, p->payload, IP_HLEN); -#else /* IP_FRAG_USES_STATIC_BUF */ - original_iphdr = (struct ip_hdr *)p->payload; - iphdr = original_iphdr; -#endif /* IP_FRAG_USES_STATIC_BUF */ - - /* Save original offset */ - tmp = ntohs(IPH_OFFSET(iphdr)); - ofo = tmp & IP_OFFMASK; - omf = tmp & IP_MF; - - left = p->tot_len - IP_HLEN; - - nfb = (mtu - IP_HLEN) / 8; - - while (left) { - last = (left <= mtu - IP_HLEN); - - /* Set new offset and MF flag */ - tmp = omf | (IP_OFFMASK & (ofo)); - if (!last) { - tmp = tmp | IP_MF; - } - - /* Fill this fragment */ - cop = last ? left : nfb * 8; - -#if IP_FRAG_USES_STATIC_BUF - poff += pbuf_copy_partial(p, (u8_t*)iphdr + IP_HLEN, cop, poff); -#else /* IP_FRAG_USES_STATIC_BUF */ -#if LWIP_NETIF_TX_SINGLE_PBUF - rambuf = pbuf_alloc(PBUF_IP, cop, PBUF_RAM); - if (rambuf == NULL) { - return ERR_MEM; - } - LWIP_ASSERT("this needs a pbuf in one piece!", - (rambuf->len == rambuf->tot_len) && (rambuf->next == NULL)); - poff += pbuf_copy_partial(p, rambuf->payload, cop, poff); - /* make room for the IP header */ - if(pbuf_header(rambuf, IP_HLEN)) { - pbuf_free(rambuf); - return ERR_MEM; - } - /* fill in the IP header */ - SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); - iphdr = rambuf->payload; -#else /* LWIP_NETIF_TX_SINGLE_PBUF */ - /* When not using a static buffer, create a chain of pbufs. - * The first will be a PBUF_RAM holding the link and IP header. - * The rest will be PBUF_REFs mirroring the pbuf chain to be fragged, - * but limited to the size of an mtu. - */ - rambuf = pbuf_alloc(PBUF_LINK, IP_HLEN, PBUF_RAM); - if (rambuf == NULL) { - return ERR_MEM; - } - LWIP_ASSERT("this needs a pbuf in one piece!", - (p->len >= (IP_HLEN))); - SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); - iphdr = (struct ip_hdr *)rambuf->payload; - - /* Can just adjust p directly for needed offset. */ - p->payload = (u8_t *)p->payload + poff; - p->len -= poff; - - left_to_copy = cop; - while (left_to_copy) { - struct pbuf_custom_ref *pcr; - newpbuflen = (left_to_copy < p->len) ? left_to_copy : p->len; - /* Is this pbuf already empty? */ - if (!newpbuflen) { - p = p->next; - continue; - } - pcr = ip_frag_alloc_pbuf_custom_ref(); - if (pcr == NULL) { - pbuf_free(rambuf); - return ERR_MEM; - } - /* Mirror this pbuf, although we might not need all of it. */ - newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc, p->payload, newpbuflen); - if (newpbuf == NULL) { - ip_frag_free_pbuf_custom_ref(pcr); - pbuf_free(rambuf); - return ERR_MEM; - } - pbuf_ref(p); - pcr->original = p; - pcr->pc.custom_free_function = ipfrag_free_pbuf_custom; - - /* Add it to end of rambuf's chain, but using pbuf_cat, not pbuf_chain - * so that it is removed when pbuf_dechain is later called on rambuf. - */ - pbuf_cat(rambuf, newpbuf); - left_to_copy -= newpbuflen; - if (left_to_copy) { - p = p->next; - } - } - poff = newpbuflen; -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ -#endif /* IP_FRAG_USES_STATIC_BUF */ - - /* Correct header */ - IPH_OFFSET_SET(iphdr, htons(tmp)); - IPH_LEN_SET(iphdr, htons(cop + IP_HLEN)); - IPH_CHKSUM_SET(iphdr, 0); - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); - -#if IP_FRAG_USES_STATIC_BUF - if (last) { - pbuf_realloc(rambuf, left + IP_HLEN); - } - - /* This part is ugly: we alloc a RAM based pbuf for - * the link level header for each chunk and then - * free it.A PBUF_ROM style pbuf for which pbuf_header - * worked would make things simpler. - */ - header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); - if (header != NULL) { - pbuf_chain(header, rambuf); - netif->output(netif, header, dest); - IPFRAG_STATS_INC(ip_frag.xmit); - snmp_inc_ipfragcreates(); - pbuf_free(header); - } else { - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc() for header failed\n")); - pbuf_free(rambuf); - return ERR_MEM; - } -#else /* IP_FRAG_USES_STATIC_BUF */ - /* No need for separate header pbuf - we allowed room for it in rambuf - * when allocated. - */ - netif->output(netif, rambuf, dest); - IPFRAG_STATS_INC(ip_frag.xmit); - - /* Unfortunately we can't reuse rambuf - the hardware may still be - * using the buffer. Instead we free it (and the ensuing chain) and - * recreate it next time round the loop. If we're lucky the hardware - * will have already sent the packet, the free will really free, and - * there will be zero memory penalty. - */ - - pbuf_free(rambuf); -#endif /* IP_FRAG_USES_STATIC_BUF */ - left -= cop; - ofo += nfb; - } -#if IP_FRAG_USES_STATIC_BUF - pbuf_free(rambuf); -#endif /* IP_FRAG_USES_STATIC_BUF */ - snmp_inc_ipfragoks(); - return ERR_OK; -} -#endif /* IP_FRAG */ diff --git a/user/mpy/lib/lwip/src/core/ipv6/README b/user/mpy/lib/lwip/src/core/ipv6/README deleted file mode 100644 index 3620004..0000000 --- a/user/mpy/lib/lwip/src/core/ipv6/README +++ /dev/null @@ -1 +0,0 @@ -IPv6 support in lwIP is very experimental. diff --git a/user/mpy/lib/lwip/src/core/ipv6/icmp6.c b/user/mpy/lib/lwip/src/core/ipv6/icmp6.c deleted file mode 100644 index 4fcc895..0000000 --- a/user/mpy/lib/lwip/src/core/ipv6/icmp6.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -/* Some ICMP messages should be passed to the transport protocols. This - is not implemented. */ - -#include "lwip/opt.h" - -#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/icmp.h" -#include "lwip/inet.h" -#include "lwip/ip.h" -#include "lwip/def.h" -#include "lwip/stats.h" - -void -icmp_input(struct pbuf *p, struct netif *inp) -{ - u8_t type; - struct icmp_echo_hdr *iecho; - struct ip_hdr *iphdr; - struct ip_addr tmpaddr; - - ICMP_STATS_INC(icmp.recv); - - /* TODO: check length before accessing payload! */ - - type = ((u8_t *)p->payload)[0]; - - switch (type) { - case ICMP6_ECHO: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); - - if (p->tot_len < sizeof(struct icmp_echo_hdr)) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); - - pbuf_free(p); - ICMP_STATS_INC(icmp.lenerr); - return; - } - iecho = p->payload; - iphdr = (struct ip_hdr *)((u8_t *)p->payload - IP_HLEN); - if (inet_chksum_pbuf(p) != 0) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); - ICMP_STATS_INC(icmp.chkerr); - /* return;*/ - } - LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %"S16_F" p->tot_len %"S16_F"\n", p->len, p->tot_len)); - ip_addr_set(&tmpaddr, &(iphdr->src)); - ip_addr_set(&(iphdr->src), &(iphdr->dest)); - ip_addr_set(&(iphdr->dest), &tmpaddr); - iecho->type = ICMP6_ER; - /* adjust the checksum */ - if (iecho->chksum >= htons(0xffff - (ICMP6_ECHO << 8))) { - iecho->chksum += htons(ICMP6_ECHO << 8) + 1; - } else { - iecho->chksum += htons(ICMP6_ECHO << 8); - } - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); - ICMP_STATS_INC(icmp.xmit); - - /* LWIP_DEBUGF("icmp: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/ - ip_output_if (p, &(iphdr->src), IP_HDRINCL, - iphdr->hoplim, IP_PROTO_ICMP, inp); - break; - default: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" not supported.\n", (s16_t)type)); - ICMP_STATS_INC(icmp.proterr); - ICMP_STATS_INC(icmp.drop); - } - - pbuf_free(p); -} - -void -icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) -{ - struct pbuf *q; - struct ip_hdr *iphdr; - struct icmp_dur_hdr *idur; - - /* @todo: can this be PBUF_LINK instead of PBUF_IP? */ - q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); - /* ICMP header + IP header + 8 bytes of data */ - if (q == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_dest_unreach: failed to allocate pbuf for ICMP packet.\n")); - pbuf_free(p); - return; - } - LWIP_ASSERT("check that first pbuf can hold icmp message", - (q->len >= (8 + IP_HLEN + 8))); - - iphdr = p->payload; - - idur = q->payload; - idur->type = (u8_t)ICMP6_DUR; - idur->icode = (u8_t)t; - - SMEMCPY((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8); - - /* calculate checksum */ - idur->chksum = 0; - idur->chksum = inet_chksum(idur, q->len); - ICMP_STATS_INC(icmp.xmit); - - ip_output(q, NULL, - (struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP); - pbuf_free(q); -} - -void -icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) -{ - struct pbuf *q; - struct ip_hdr *iphdr; - struct icmp_te_hdr *tehdr; - - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded\n")); - - /* @todo: can this be PBUF_LINK instead of PBUF_IP? */ - q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); - /* ICMP header + IP header + 8 bytes of data */ - if (q == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_dest_unreach: failed to allocate pbuf for ICMP packet.\n")); - pbuf_free(p); - return; - } - LWIP_ASSERT("check that first pbuf can hold icmp message", - (q->len >= (8 + IP_HLEN + 8))); - - iphdr = p->payload; - - tehdr = q->payload; - tehdr->type = (u8_t)ICMP6_TE; - tehdr->icode = (u8_t)t; - - /* copy fields from original packet */ - SMEMCPY((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8); - - /* calculate checksum */ - tehdr->chksum = 0; - tehdr->chksum = inet_chksum(tehdr, q->len); - ICMP_STATS_INC(icmp.xmit); - ip_output(q, NULL, - (struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP); - pbuf_free(q); -} - -#endif /* LWIP_ICMP */ diff --git a/user/mpy/lib/lwip/src/core/ipv6/inet6.c b/user/mpy/lib/lwip/src/core/ipv6/inet6.c deleted file mode 100644 index c3de85c..0000000 --- a/user/mpy/lib/lwip/src/core/ipv6/inet6.c +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @file - * Functions common to all TCP/IPv6 modules, such as the Internet checksum and the - * byte order functions. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/inet.h" - -/* chksum: - * - * Sums up all 16 bit words in a memory portion. Also includes any odd byte. - * This function is used by the other checksum functions. - * - * For now, this is not optimized. Must be optimized for the particular processor - * arcitecture on which it is to run. Preferebly coded in assembler. - */ - -static u32_t -chksum(void *dataptr, u16_t len) -{ - u16_t *sdataptr = dataptr; - u32_t acc; - - - for(acc = 0; len > 1; len -= 2) { - acc += *sdataptr++; - } - - /* add up any odd byte */ - if (len == 1) { - acc += htons((u16_t)(*(u8_t *)dataptr) << 8); - } - - return acc; - -} - -/* inet_chksum_pseudo: - * - * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. - */ - -u16_t -inet_chksum_pseudo(struct pbuf *p, - struct ip_addr *src, struct ip_addr *dest, - u8_t proto, u32_t proto_len) -{ - u32_t acc; - struct pbuf *q; - u8_t swapped, i; - - acc = 0; - swapped = 0; - for(q = p; q != NULL; q = q->next) { - acc += chksum(q->payload, q->len); - while (acc >> 16) { - acc = (acc & 0xffff) + (acc >> 16); - } - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); - } - } - - if (swapped) { - acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); - } - - for(i = 0; i < 8; i++) { - acc += ((u16_t *)src->addr)[i] & 0xffff; - acc += ((u16_t *)dest->addr)[i] & 0xffff; - while (acc >> 16) { - acc = (acc & 0xffff) + (acc >> 16); - } - } - acc += (u16_t)htons((u16_t)proto); - acc += ((u16_t *)&proto_len)[0] & 0xffff; - acc += ((u16_t *)&proto_len)[1] & 0xffff; - - while (acc >> 16) { - acc = (acc & 0xffff) + (acc >> 16); - } - return ~(acc & 0xffff); -} - -/* inet_chksum: - * - * Calculates the Internet checksum over a portion of memory. Used primarely for IP - * and ICMP. - */ - -u16_t -inet_chksum(void *dataptr, u16_t len) -{ - u32_t acc, sum; - - acc = chksum(dataptr, len); - sum = (acc & 0xffff) + (acc >> 16); - sum += (sum >> 16); - return ~(sum & 0xffff); -} - -u16_t -inet_chksum_pbuf(struct pbuf *p) -{ - u32_t acc; - struct pbuf *q; - u8_t swapped; - - acc = 0; - swapped = 0; - for(q = p; q != NULL; q = q->next) { - acc += chksum(q->payload, q->len); - while (acc >> 16) { - acc = (acc & 0xffff) + (acc >> 16); - } - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8); - } - } - - if (swapped) { - acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); - } - return ~(acc & 0xffff); -} diff --git a/user/mpy/lib/lwip/src/core/ipv6/ip6.c b/user/mpy/lib/lwip/src/core/ipv6/ip6.c deleted file mode 100644 index ad59b72..0000000 --- a/user/mpy/lib/lwip/src/core/ipv6/ip6.c +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - - -/* ip.c - * - * This is the code for the IP layer for IPv6. - * - */ - - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/ip.h" -#include "lwip/inet.h" -#include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/udp.h" -#include "lwip/tcp_impl.h" - -#include "lwip/stats.h" - -#include "arch/perf.h" - -/* ip_init: - * - * Initializes the IP layer. - */ - -void -ip_init(void) -{ -} - -/* ip_route: - * - * Finds the appropriate network interface for a given IP address. It searches the - * list of network interfaces linearly. A match is found if the masked IP address of - * the network interface equals the masked IP address given to the function. - */ - -struct netif * -ip_route(struct ip_addr *dest) -{ - struct netif *netif; - - for(netif = netif_list; netif != NULL; netif = netif->next) { - if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { - return netif; - } - } - - return netif_default; -} - -/* ip_forward: - * - * Forwards an IP packet. It finds an appropriate route for the packet, decrements - * the TTL value of the packet, adjusts the checksum and outputs the packet on the - * appropriate interface. - */ - -static void -ip_forward(struct pbuf *p, struct ip_hdr *iphdr) -{ - struct netif *netif; - - PERF_START; - - if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) { - - LWIP_DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for ")); -#if IP_DEBUG - ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); -#endif /* IP_DEBUG */ - LWIP_DEBUGF(IP_DEBUG, ("\n")); - pbuf_free(p); - return; - } - /* Decrement TTL and send ICMP if ttl == 0. */ - if (--iphdr->hoplim == 0) { -#if LWIP_ICMP - /* Don't send ICMP messages in response to ICMP messages */ - if (iphdr->nexthdr != IP_PROTO_ICMP) { - icmp_time_exceeded(p, ICMP_TE_TTL); - } -#endif /* LWIP_ICMP */ - pbuf_free(p); - return; - } - - /* Incremental update of the IP checksum. */ - /* if (iphdr->chksum >= htons(0xffff - 0x100)) { - iphdr->chksum += htons(0x100) + 1; - } else { - iphdr->chksum += htons(0x100); - }*/ - - - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to ")); -#if IP_DEBUG - ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); -#endif /* IP_DEBUG */ - LWIP_DEBUGF(IP_DEBUG, ("\n")); - - IP_STATS_INC(ip.fw); - IP_STATS_INC(ip.xmit); - - PERF_STOP("ip_forward"); - - netif->output(netif, p, (struct ip_addr *)&(iphdr->dest)); -} - -/* ip_input: - * - * This function is called by the network interface device driver when an IP packet is - * received. The function does the basic checks of the IP header such as packet size - * being at least larger than the header size etc. If the packet was not destined for - * us, the packet is forwarded (using ip_forward). The IP checksum is always checked. - * - * Finally, the packet is sent to the upper layer protocol input function. - */ - -void -ip_input(struct pbuf *p, struct netif *inp) { - struct ip_hdr *iphdr; - struct netif *netif; - - - PERF_START; - -#if IP_DEBUG - ip_debug_print(p); -#endif /* IP_DEBUG */ - - - IP_STATS_INC(ip.recv); - - /* identify the IP header */ - iphdr = p->payload; - - - if (iphdr->v != 6) { - LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); -#if IP_DEBUG - ip_debug_print(p); -#endif /* IP_DEBUG */ - pbuf_free(p); - IP_STATS_INC(ip.err); - IP_STATS_INC(ip.drop); - return; - } - - /* is this packet for us? */ - for(netif = netif_list; netif != NULL; netif = netif->next) { -#if IP_DEBUG - LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest ")); - ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); - LWIP_DEBUGF(IP_DEBUG, ("netif->ip_addr ")); - ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest))); - LWIP_DEBUGF(IP_DEBUG, ("\n")); -#endif /* IP_DEBUG */ - if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) { - break; - } - } - - - if (netif == NULL) { - /* packet not for us, route or discard */ -#if IP_FORWARD - ip_forward(p, iphdr); -#endif - pbuf_free(p); - return; - } - - pbuf_realloc(p, IP_HLEN + ntohs(iphdr->len)); - - /* send to upper layers */ -#if IP_DEBUG - /* LWIP_DEBUGF("ip_input: \n"); - ip_debug_print(p); - LWIP_DEBUGF("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/ -#endif /* IP_DEBUG */ - - if(pbuf_header(p, -IP_HLEN)) { - LWIP_ASSERT("Can't move over header in packet", 0); - return; - } - - switch (iphdr->nexthdr) { - case IP_PROTO_UDP: - udp_input(p, inp); - break; - case IP_PROTO_TCP: - tcp_input(p, inp); - break; -#if LWIP_ICMP - case IP_PROTO_ICMP: - icmp_input(p, inp); - break; -#endif /* LWIP_ICMP */ - default: -#if LWIP_ICMP - /* send ICMP destination protocol unreachable */ - icmp_dest_unreach(p, ICMP_DUR_PROTO); -#endif /* LWIP_ICMP */ - pbuf_free(p); - LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n", - iphdr->nexthdr)); - - IP_STATS_INC(ip.proterr); - IP_STATS_INC(ip.drop); - } - PERF_STOP("ip_input"); -} - - -/* ip_output_if: - * - * Sends an IP packet on a network interface. This function constructs the IP header - * and calculates the IP header checksum. If the source IP address is NULL, - * the IP address of the outgoing network interface is filled in as source address. - */ - -err_t -ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - u8_t ttl, - u8_t proto, struct netif *netif) -{ - struct ip_hdr *iphdr; - - PERF_START; - - LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len)); - if (pbuf_header(p, IP_HLEN)) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); - IP_STATS_INC(ip.err); - - return ERR_BUF; - } - LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len)); - - iphdr = p->payload; - - - if (dest != IP_HDRINCL) { - LWIP_DEBUGF(IP_DEBUG, ("!IP_HDRLINCL\n")); - iphdr->hoplim = ttl; - iphdr->nexthdr = proto; - iphdr->len = htons(p->tot_len - IP_HLEN); - ip_addr_set(&(iphdr->dest), dest); - - iphdr->v = 6; - - if (ip_addr_isany(src)) { - ip_addr_set(&(iphdr->src), &(netif->ip_addr)); - } else { - ip_addr_set(&(iphdr->src), src); - } - - } else { - dest = &(iphdr->dest); - } - - IP_STATS_INC(ip.xmit); - - LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %"U16_F")\n", netif->name[0], netif->name[1], p->tot_len)); -#if IP_DEBUG - ip_debug_print(p); -#endif /* IP_DEBUG */ - - PERF_STOP("ip_output_if"); - return netif->output(netif, p, dest); -} - -/* ip_output: - * - * Simple interface to ip_output_if. It finds the outgoing network interface and - * calls upon ip_output_if to do the actual work. - */ - -err_t -ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - u8_t ttl, u8_t proto) -{ - struct netif *netif; - if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr)); - IP_STATS_INC(ip.rterr); - return ERR_RTE; - } - - return ip_output_if (p, src, dest, ttl, proto, netif); -} - -#if LWIP_NETIF_HWADDRHINT -err_t -ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint) -{ - struct netif *netif; - err_t err; - - if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr)); - IP_STATS_INC(ip.rterr); - return ERR_RTE; - } - - LWIP_NETIF_HWADDRHINT(netif, addr_hint); - err = ip_output_if(p, src, dest, ttl, tos, proto, netif); - LWIP_NETIF_HWADDRHINT(netif, NULL); - - return err; -} -#endif /* LWIP_NETIF_HWADDRHINT*/ - -#if IP_DEBUG -void -ip_debug_print(struct pbuf *p) -{ - struct ip_hdr *iphdr = p->payload; - - LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" | %"X16_F"%"X16_F" | %"X16_F"%"X16_F" | (v, traffic class, flow label)\n", - iphdr->v, - iphdr->tclass1, iphdr->tclass2, - iphdr->flow1, iphdr->flow2)); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" | %2"U16_F" | %2"U16_F" | (len, nexthdr, hoplim)\n", - ntohs(iphdr->len), - iphdr->nexthdr, - iphdr->hoplim)); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", - (ntohl(iphdr->src.addr[0]) >> 16) & 0xffff, - ntohl(iphdr->src.addr[0]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", - (ntohl(iphdr->src.addr[1]) >> 16) & 0xffff, - ntohl(iphdr->src.addr[1]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", - (ntohl(iphdr->src.addr[2]) >> 16) & 0xffff, - ntohl(iphdr->src.addr[2]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", - (ntohl(iphdr->src.addr[3]) >> 16) & 0xffff, - ntohl(iphdr->src.addr[3]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", - (ntohl(iphdr->dest.addr[0]) >> 16) & 0xffff, - ntohl(iphdr->dest.addr[0]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", - (ntohl(iphdr->dest.addr[1]) >> 16) & 0xffff, - ntohl(iphdr->dest.addr[1]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", - (ntohl(iphdr->dest.addr[2]) >> 16) & 0xffff, - ntohl(iphdr->dest.addr[2]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", - (ntohl(iphdr->dest.addr[3]) >> 16) & 0xffff, - ntohl(iphdr->dest.addr[3]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); -} -#endif /* IP_DEBUG */ diff --git a/user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c b/user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c deleted file mode 100644 index 2da6cea..0000000 --- a/user/mpy/lib/lwip/src/core/ipv6/ip6_addr.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" -#include "lwip/inet.h" - -u8_t -ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, - struct ip_addr *mask) -{ - return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) && - (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) && - (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) && - (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3])); - -} - -u8_t -ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2) -{ - return(addr1->addr[0] == addr2->addr[0] && - addr1->addr[1] == addr2->addr[1] && - addr1->addr[2] == addr2->addr[2] && - addr1->addr[3] == addr2->addr[3]); -} - -void -ip_addr_set(struct ip_addr *dest, struct ip_addr *src) -{ - SMEMCPY(dest, src, sizeof(struct ip_addr)); - /* dest->addr[0] = src->addr[0]; - dest->addr[1] = src->addr[1]; - dest->addr[2] = src->addr[2]; - dest->addr[3] = src->addr[3];*/ -} - -u8_t -ip_addr_isany(struct ip_addr *addr) -{ - if (addr == NULL) return 1; - return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0); -} diff --git a/user/mpy/lib/lwip/src/core/mem.c b/user/mpy/lib/lwip/src/core/mem.c deleted file mode 100644 index 1659a2c..0000000 --- a/user/mpy/lib/lwip/src/core/mem.c +++ /dev/null @@ -1,659 +0,0 @@ -/** - * @file - * Dynamic memory manager - * - * This is a lightweight replacement for the standard C library malloc(). - * - * If you want to use the standard C library malloc() instead, define - * MEM_LIBC_MALLOC to 1 in your lwipopts.h - * - * To let mem_malloc() use pools (prevents fragmentation and is much faster than - * a heap but might waste some memory), define MEM_USE_POOLS to 1, define - * MEM_USE_CUSTOM_POOLS to 1 and create a file "lwippools.h" that includes a list - * of pools like this (more pools can be added between _START and _END): - * - * Define three pools with sizes 256, 512, and 1512 bytes - * LWIP_MALLOC_MEMPOOL_START - * LWIP_MALLOC_MEMPOOL(20, 256) - * LWIP_MALLOC_MEMPOOL(10, 512) - * LWIP_MALLOC_MEMPOOL(5, 1512) - * LWIP_MALLOC_MEMPOOL_END - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ - -#include "lwip/opt.h" - -#if !MEM_LIBC_MALLOC /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/sys.h" -#include "lwip/stats.h" -#include "lwip/err.h" - -#include - -#if MEM_USE_POOLS -/* lwIP head implemented with different sized pools */ - -/** - * Allocate memory: determine the smallest pool that is big enough - * to contain an element of 'size' and get an element from that pool. - * - * @param size the size in bytes of the memory needed - * @return a pointer to the allocated memory or NULL if the pool is empty - */ -void * -mem_malloc(mem_size_t size) -{ - void *ret; - struct memp_malloc_helper *element; - memp_t poolnr; - mem_size_t required_size = size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); - - for (poolnr = MEMP_POOL_FIRST; poolnr <= MEMP_POOL_LAST; poolnr = (memp_t)(poolnr + 1)) { -#if MEM_USE_POOLS_TRY_BIGGER_POOL -again: -#endif /* MEM_USE_POOLS_TRY_BIGGER_POOL */ - /* is this pool big enough to hold an element of the required size - plus a struct memp_malloc_helper that saves the pool this element came from? */ - if (required_size <= memp_sizes[poolnr]) { - break; - } - } - if (poolnr > MEMP_POOL_LAST) { - LWIP_ASSERT("mem_malloc(): no pool is that big!", 0); - return NULL; - } - element = (struct memp_malloc_helper*)memp_malloc(poolnr); - if (element == NULL) { - /* No need to DEBUGF or ASSERT: This error is already - taken care of in memp.c */ -#if MEM_USE_POOLS_TRY_BIGGER_POOL - /** Try a bigger pool if this one is empty! */ - if (poolnr < MEMP_POOL_LAST) { - poolnr++; - goto again; - } -#endif /* MEM_USE_POOLS_TRY_BIGGER_POOL */ - return NULL; - } - - /* save the pool number this element came from */ - element->poolnr = poolnr; - /* and return a pointer to the memory directly after the struct memp_malloc_helper */ - ret = (u8_t*)element + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); - - return ret; -} - -/** - * Free memory previously allocated by mem_malloc. Loads the pool number - * and calls memp_free with that pool number to put the element back into - * its pool - * - * @param rmem the memory element to free - */ -void -mem_free(void *rmem) -{ - struct memp_malloc_helper *hmem; - - LWIP_ASSERT("rmem != NULL", (rmem != NULL)); - LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem))); - - /* get the original struct memp_malloc_helper */ - hmem = (struct memp_malloc_helper*)(void*)((u8_t*)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))); - - LWIP_ASSERT("hmem != NULL", (hmem != NULL)); - LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem))); - LWIP_ASSERT("hmem->poolnr < MEMP_MAX", (hmem->poolnr < MEMP_MAX)); - - /* and put it in the pool we saved earlier */ - memp_free(hmem->poolnr, hmem); -} - -#else /* MEM_USE_POOLS */ -/* lwIP replacement for your libc malloc() */ - -/** - * The heap is made up as a list of structs of this type. - * This does not have to be aligned since for getting its size, - * we only use the macro SIZEOF_STRUCT_MEM, which automatically alignes. - */ -struct mem { - /** index (-> ram[next]) of the next struct */ - mem_size_t next; - /** index (-> ram[prev]) of the previous struct */ - mem_size_t prev; - /** 1: this area is used; 0: this area is unused */ - u8_t used; -}; - -/** All allocated blocks will be MIN_SIZE bytes big, at least! - * MIN_SIZE can be overridden to suit your needs. Smaller values save space, - * larger values could prevent too small blocks to fragment the RAM too much. */ -#ifndef MIN_SIZE -#define MIN_SIZE 12 -#endif /* MIN_SIZE */ -/* some alignment macros: we define them here for better source code layout */ -#define MIN_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MIN_SIZE) -#define SIZEOF_STRUCT_MEM LWIP_MEM_ALIGN_SIZE(sizeof(struct mem)) -#define MEM_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEM_SIZE) - -/** If you want to relocate the heap to external memory, simply define - * LWIP_RAM_HEAP_POINTER as a void-pointer to that location. - * If so, make sure the memory at that location is big enough (see below on - * how that space is calculated). */ -#ifndef LWIP_RAM_HEAP_POINTER -/** the heap. we need one struct mem at the end and some room for alignment */ -u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT]; -#define LWIP_RAM_HEAP_POINTER ram_heap -#endif /* LWIP_RAM_HEAP_POINTER */ - -/** pointer to the heap (ram_heap): for alignment, ram is now a pointer instead of an array */ -static u8_t *ram; -/** the last entry, always unused! */ -static struct mem *ram_end; -/** pointer to the lowest free block, this is used for faster search */ -static struct mem *lfree; - -/** concurrent access protection */ -#if !NO_SYS -static sys_mutex_t mem_mutex; -#endif - -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - -static volatile u8_t mem_free_count; - -/* Allow mem_free from other (e.g. interrupt) context */ -#define LWIP_MEM_FREE_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_free) -#define LWIP_MEM_FREE_PROTECT() SYS_ARCH_PROTECT(lev_free) -#define LWIP_MEM_FREE_UNPROTECT() SYS_ARCH_UNPROTECT(lev_free) -#define LWIP_MEM_ALLOC_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_alloc) -#define LWIP_MEM_ALLOC_PROTECT() SYS_ARCH_PROTECT(lev_alloc) -#define LWIP_MEM_ALLOC_UNPROTECT() SYS_ARCH_UNPROTECT(lev_alloc) - -#else /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - -/* Protect the heap only by using a semaphore */ -#define LWIP_MEM_FREE_DECL_PROTECT() -#define LWIP_MEM_FREE_PROTECT() sys_mutex_lock(&mem_mutex) -#define LWIP_MEM_FREE_UNPROTECT() sys_mutex_unlock(&mem_mutex) -/* mem_malloc is protected using semaphore AND LWIP_MEM_ALLOC_PROTECT */ -#define LWIP_MEM_ALLOC_DECL_PROTECT() -#define LWIP_MEM_ALLOC_PROTECT() -#define LWIP_MEM_ALLOC_UNPROTECT() - -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - - -/** - * "Plug holes" by combining adjacent empty struct mems. - * After this function is through, there should not exist - * one empty struct mem pointing to another empty struct mem. - * - * @param mem this points to a struct mem which just has been freed - * @internal this function is only called by mem_free() and mem_trim() - * - * This assumes access to the heap is protected by the calling function - * already. - */ -static void -plug_holes(struct mem *mem) -{ - struct mem *nmem; - struct mem *pmem; - - LWIP_ASSERT("plug_holes: mem >= ram", (u8_t *)mem >= ram); - LWIP_ASSERT("plug_holes: mem < ram_end", (u8_t *)mem < (u8_t *)ram_end); - LWIP_ASSERT("plug_holes: mem->used == 0", mem->used == 0); - - /* plug hole forward */ - LWIP_ASSERT("plug_holes: mem->next <= MEM_SIZE_ALIGNED", mem->next <= MEM_SIZE_ALIGNED); - - nmem = (struct mem *)(void *)&ram[mem->next]; - if (mem != nmem && nmem->used == 0 && (u8_t *)nmem != (u8_t *)ram_end) { - /* if mem->next is unused and not end of ram, combine mem and mem->next */ - if (lfree == nmem) { - lfree = mem; - } - mem->next = nmem->next; - ((struct mem *)(void *)&ram[nmem->next])->prev = (mem_size_t)((u8_t *)mem - ram); - } - - /* plug hole backward */ - pmem = (struct mem *)(void *)&ram[mem->prev]; - if (pmem != mem && pmem->used == 0) { - /* if mem->prev is unused, combine mem and mem->prev */ - if (lfree == mem) { - lfree = pmem; - } - pmem->next = mem->next; - ((struct mem *)(void *)&ram[mem->next])->prev = (mem_size_t)((u8_t *)pmem - ram); - } -} - -/** - * Zero the heap and initialize start, end and lowest-free - */ -void -mem_init(void) -{ - struct mem *mem; - - LWIP_ASSERT("Sanity check alignment", - (SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0); - - /* align the heap */ - ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER); - /* initialize the start of the heap */ - mem = (struct mem *)(void *)ram; - mem->next = MEM_SIZE_ALIGNED; - mem->prev = 0; - mem->used = 0; - /* initialize the end of the heap */ - ram_end = (struct mem *)(void *)&ram[MEM_SIZE_ALIGNED]; - ram_end->used = 1; - ram_end->next = MEM_SIZE_ALIGNED; - ram_end->prev = MEM_SIZE_ALIGNED; - - /* initialize the lowest-free pointer to the start of the heap */ - lfree = (struct mem *)(void *)ram; - - MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED); - - if(sys_mutex_new(&mem_mutex) != ERR_OK) { - LWIP_ASSERT("failed to create mem_mutex", 0); - } -} - -/** - * Put a struct mem back on the heap - * - * @param rmem is the data portion of a struct mem as returned by a previous - * call to mem_malloc() - */ -void -mem_free(void *rmem) -{ - struct mem *mem; - LWIP_MEM_FREE_DECL_PROTECT(); - - if (rmem == NULL) { - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("mem_free(p == NULL) was called.\n")); - return; - } - LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0); - - LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram && - (u8_t *)rmem < (u8_t *)ram_end); - - if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { - SYS_ARCH_DECL_PROTECT(lev); - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("mem_free: illegal memory\n")); - /* protect mem stats from concurrent access */ - SYS_ARCH_PROTECT(lev); - MEM_STATS_INC(illegal); - SYS_ARCH_UNPROTECT(lev); - return; - } - /* protect the heap from concurrent access */ - LWIP_MEM_FREE_PROTECT(); - /* Get the corresponding struct mem ... */ - mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); - /* ... which has to be in a used state ... */ - LWIP_ASSERT("mem_free: mem->used", mem->used); - /* ... and is now unused. */ - mem->used = 0; - - if (mem < lfree) { - /* the newly freed struct is now the lowest */ - lfree = mem; - } - - MEM_STATS_DEC_USED(used, mem->next - (mem_size_t)(((u8_t *)mem - ram))); - - /* finally, see if prev or next are free also */ - plug_holes(mem); -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 1; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_MEM_FREE_UNPROTECT(); -} - -/** - * Shrink memory returned by mem_malloc(). - * - * @param rmem pointer to memory allocated by mem_malloc the is to be shrinked - * @param newsize required size after shrinking (needs to be smaller than or - * equal to the previous size) - * @return for compatibility reasons: is always == rmem, at the moment - * or NULL if newsize is > old size, in which case rmem is NOT touched - * or freed! - */ -void * -mem_trim(void *rmem, mem_size_t newsize) -{ - mem_size_t size; - mem_size_t ptr, ptr2; - struct mem *mem, *mem2; - /* use the FREE_PROTECT here: it protects with sem OR SYS_ARCH_PROTECT */ - LWIP_MEM_FREE_DECL_PROTECT(); - - /* Expand the size of the allocated memory region so that we can - adjust for alignment. */ - newsize = LWIP_MEM_ALIGN_SIZE(newsize); - - if(newsize < MIN_SIZE_ALIGNED) { - /* every data block must be at least MIN_SIZE_ALIGNED long */ - newsize = MIN_SIZE_ALIGNED; - } - - if (newsize > MEM_SIZE_ALIGNED) { - return NULL; - } - - LWIP_ASSERT("mem_trim: legal memory", (u8_t *)rmem >= (u8_t *)ram && - (u8_t *)rmem < (u8_t *)ram_end); - - if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { - SYS_ARCH_DECL_PROTECT(lev); - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("mem_trim: illegal memory\n")); - /* protect mem stats from concurrent access */ - SYS_ARCH_PROTECT(lev); - MEM_STATS_INC(illegal); - SYS_ARCH_UNPROTECT(lev); - return rmem; - } - /* Get the corresponding struct mem ... */ - mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); - /* ... and its offset pointer */ - ptr = (mem_size_t)((u8_t *)mem - ram); - - size = mem->next - ptr - SIZEOF_STRUCT_MEM; - LWIP_ASSERT("mem_trim can only shrink memory", newsize <= size); - if (newsize > size) { - /* not supported */ - return NULL; - } - if (newsize == size) { - /* No change in size, simply return */ - return rmem; - } - - /* protect the heap from concurrent access */ - LWIP_MEM_FREE_PROTECT(); - - mem2 = (struct mem *)(void *)&ram[mem->next]; - if(mem2->used == 0) { - /* The next struct is unused, we can simply move it at little */ - mem_size_t next; - /* remember the old next pointer */ - next = mem2->next; - /* create new struct mem which is moved directly after the shrinked mem */ - ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; - if (lfree == mem2) { - lfree = (struct mem *)(void *)&ram[ptr2]; - } - mem2 = (struct mem *)(void *)&ram[ptr2]; - mem2->used = 0; - /* restore the next pointer */ - mem2->next = next; - /* link it back to mem */ - mem2->prev = ptr; - /* link mem to it */ - mem->next = ptr2; - /* last thing to restore linked list: as we have moved mem2, - * let 'mem2->next->prev' point to mem2 again. but only if mem2->next is not - * the end of the heap */ - if (mem2->next != MEM_SIZE_ALIGNED) { - ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; - } - MEM_STATS_DEC_USED(used, (size - newsize)); - /* no need to plug holes, we've already done that */ - } else if (newsize + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED <= size) { - /* Next struct is used but there's room for another struct mem with - * at least MIN_SIZE_ALIGNED of data. - * Old size ('size') must be big enough to contain at least 'newsize' plus a struct mem - * ('SIZEOF_STRUCT_MEM') with some data ('MIN_SIZE_ALIGNED'). - * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty - * region that couldn't hold data, but when mem->next gets freed, - * the 2 regions would be combined, resulting in more free memory */ - ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; - mem2 = (struct mem *)(void *)&ram[ptr2]; - if (mem2 < lfree) { - lfree = mem2; - } - mem2->used = 0; - mem2->next = mem->next; - mem2->prev = ptr; - mem->next = ptr2; - if (mem2->next != MEM_SIZE_ALIGNED) { - ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; - } - MEM_STATS_DEC_USED(used, (size - newsize)); - /* the original mem->next is used, so no need to plug holes! */ - } - /* else { - next struct mem is used but size between mem and mem2 is not big enough - to create another struct mem - -> don't do anyhting. - -> the remaining space stays unused since it is too small - } */ -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 1; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_MEM_FREE_UNPROTECT(); - return rmem; -} - -/** - * Adam's mem_malloc() plus solution for bug #17922 - * Allocate a block of memory with a minimum of 'size' bytes. - * - * @param size is the minimum size of the requested block in bytes. - * @return pointer to allocated memory or NULL if no free memory was found. - * - * Note that the returned value will always be aligned (as defined by MEM_ALIGNMENT). - */ -void * -mem_malloc(mem_size_t size) -{ - mem_size_t ptr, ptr2; - struct mem *mem, *mem2; -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - u8_t local_mem_free_count = 0; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_MEM_ALLOC_DECL_PROTECT(); - - if (size == 0) { - return NULL; - } - - /* Expand the size of the allocated memory region so that we can - adjust for alignment. */ - size = LWIP_MEM_ALIGN_SIZE(size); - - if(size < MIN_SIZE_ALIGNED) { - /* every data block must be at least MIN_SIZE_ALIGNED long */ - size = MIN_SIZE_ALIGNED; - } - - if (size > MEM_SIZE_ALIGNED) { - return NULL; - } - - /* protect the heap from concurrent access */ - sys_mutex_lock(&mem_mutex); - LWIP_MEM_ALLOC_PROTECT(); -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - /* run as long as a mem_free disturbed mem_malloc or mem_trim */ - do { - local_mem_free_count = 0; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - - /* Scan through the heap searching for a free block that is big enough, - * beginning with the lowest free block. - */ - for (ptr = (mem_size_t)((u8_t *)lfree - ram); ptr < MEM_SIZE_ALIGNED - size; - ptr = ((struct mem *)(void *)&ram[ptr])->next) { - mem = (struct mem *)(void *)&ram[ptr]; -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 0; - LWIP_MEM_ALLOC_UNPROTECT(); - /* allow mem_free or mem_trim to run */ - LWIP_MEM_ALLOC_PROTECT(); - if (mem_free_count != 0) { - /* If mem_free or mem_trim have run, we have to restart since they - could have altered our current struct mem. */ - local_mem_free_count = 1; - break; - } -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - - if ((!mem->used) && - (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) { - /* mem is not used and at least perfect fit is possible: - * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ - - if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) { - /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing - * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem') - * -> split large block, create empty remainder, - * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if - * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size, - * struct mem would fit in but no data between mem2 and mem2->next - * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty - * region that couldn't hold data, but when mem->next gets freed, - * the 2 regions would be combined, resulting in more free memory - */ - ptr2 = ptr + SIZEOF_STRUCT_MEM + size; - /* create mem2 struct */ - mem2 = (struct mem *)(void *)&ram[ptr2]; - mem2->used = 0; - mem2->next = mem->next; - mem2->prev = ptr; - /* and insert it between mem and mem->next */ - mem->next = ptr2; - mem->used = 1; - - if (mem2->next != MEM_SIZE_ALIGNED) { - ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; - } - MEM_STATS_INC_USED(used, (size + SIZEOF_STRUCT_MEM)); - } else { - /* (a mem2 struct does no fit into the user data space of mem and mem->next will always - * be used at this point: if not we have 2 unused structs in a row, plug_holes should have - * take care of this). - * -> near fit or excact fit: do not split, no mem2 creation - * also can't move mem->next directly behind mem, since mem->next - * will always be used at this point! - */ - mem->used = 1; - MEM_STATS_INC_USED(used, mem->next - (mem_size_t)((u8_t *)mem - ram)); - } -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT -mem_malloc_adjust_lfree: -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - if (mem == lfree) { - struct mem *cur = lfree; - /* Find next free block after mem and update lowest free pointer */ - while (cur->used && cur != ram_end) { -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 0; - LWIP_MEM_ALLOC_UNPROTECT(); - /* prevent high interrupt latency... */ - LWIP_MEM_ALLOC_PROTECT(); - if (mem_free_count != 0) { - /* If mem_free or mem_trim have run, we have to restart since they - could have altered our current struct mem or lfree. */ - goto mem_malloc_adjust_lfree; - } -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - cur = (struct mem *)(void *)&ram[cur->next]; - } - lfree = cur; - LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); - } - LWIP_MEM_ALLOC_UNPROTECT(); - sys_mutex_unlock(&mem_mutex); - LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", - (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); - LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", - ((mem_ptr_t)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); - LWIP_ASSERT("mem_malloc: sanity check alignment", - (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); - - return (u8_t *)mem + SIZEOF_STRUCT_MEM; - } - } -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - /* if we got interrupted by a mem_free, try again */ - } while(local_mem_free_count != 0); -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size)); - MEM_STATS_INC(err); - LWIP_MEM_ALLOC_UNPROTECT(); - sys_mutex_unlock(&mem_mutex); - return NULL; -} - -#endif /* MEM_USE_POOLS */ -/** - * Contiguously allocates enough space for count objects that are size bytes - * of memory each and returns a pointer to the allocated memory. - * - * The allocated memory is filled with bytes of value zero. - * - * @param count number of objects to allocate - * @param size size of the objects to allocate - * @return pointer to allocated memory / NULL pointer if there is an error - */ -void *mem_calloc(mem_size_t count, mem_size_t size) -{ - void *p; - - /* allocate 'count' objects of size 'size' */ - p = mem_malloc(count * size); - if (p) { - /* zero the memory */ - memset(p, 0, count * size); - } - return p; -} - -#endif /* !MEM_LIBC_MALLOC */ diff --git a/user/mpy/lib/lwip/src/core/memp.c b/user/mpy/lib/lwip/src/core/memp.c deleted file mode 100644 index 9f680e2..0000000 --- a/user/mpy/lib/lwip/src/core/memp.c +++ /dev/null @@ -1,470 +0,0 @@ -/** - * @file - * Dynamic pool memory manager - * - * lwIP has dedicated pools for many structures (netconn, protocol control blocks, - * packet buffers, ...). All these pools are managed here. - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/udp.h" -#include "lwip/raw.h" -#include "lwip/tcp_impl.h" -#include "lwip/igmp.h" -#include "lwip/api.h" -#include "lwip/api_msg.h" -#include "lwip/tcpip.h" -#include "lwip/sys.h" -#include "lwip/timers.h" -#include "lwip/stats.h" -#include "netif/etharp.h" -#include "lwip/ip_frag.h" -#include "lwip/snmp_structs.h" -#include "lwip/snmp_msg.h" -#include "lwip/dns.h" -#include "netif/ppp_oe.h" - -#include - -#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */ - -struct memp { - struct memp *next; -#if MEMP_OVERFLOW_CHECK - const char *file; - int line; -#endif /* MEMP_OVERFLOW_CHECK */ -}; - -#if MEMP_OVERFLOW_CHECK -/* if MEMP_OVERFLOW_CHECK is turned on, we reserve some bytes at the beginning - * and at the end of each element, initialize them as 0xcd and check - * them later. */ -/* If MEMP_OVERFLOW_CHECK is >= 2, on every call to memp_malloc or memp_free, - * every single element in each pool is checked! - * This is VERY SLOW but also very helpful. */ -/* MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in - * lwipopts.h to change the amount reserved for checking. */ -#ifndef MEMP_SANITY_REGION_BEFORE -#define MEMP_SANITY_REGION_BEFORE 16 -#endif /* MEMP_SANITY_REGION_BEFORE*/ -#if MEMP_SANITY_REGION_BEFORE > 0 -#define MEMP_SANITY_REGION_BEFORE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_BEFORE) -#else -#define MEMP_SANITY_REGION_BEFORE_ALIGNED 0 -#endif /* MEMP_SANITY_REGION_BEFORE*/ -#ifndef MEMP_SANITY_REGION_AFTER -#define MEMP_SANITY_REGION_AFTER 16 -#endif /* MEMP_SANITY_REGION_AFTER*/ -#if MEMP_SANITY_REGION_AFTER > 0 -#define MEMP_SANITY_REGION_AFTER_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_AFTER) -#else -#define MEMP_SANITY_REGION_AFTER_ALIGNED 0 -#endif /* MEMP_SANITY_REGION_AFTER*/ - -/* MEMP_SIZE: save space for struct memp and for sanity check */ -#define MEMP_SIZE (LWIP_MEM_ALIGN_SIZE(sizeof(struct memp)) + MEMP_SANITY_REGION_BEFORE_ALIGNED) -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x) + MEMP_SANITY_REGION_AFTER_ALIGNED) - -#else /* MEMP_OVERFLOW_CHECK */ - -/* No sanity checks - * We don't need to preserve the struct memp while not allocated, so we - * can save a little space and set MEMP_SIZE to 0. - */ -#define MEMP_SIZE 0 -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) - -#endif /* MEMP_OVERFLOW_CHECK */ - -/** This array holds the first free element of each pool. - * Elements form a linked list. */ -static struct memp *memp_tab[MEMP_MAX]; - -#else /* MEMP_MEM_MALLOC */ - -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) - -#endif /* MEMP_MEM_MALLOC */ - -/** This array holds the element sizes of each pool. */ -#if !MEM_USE_POOLS && !MEMP_MEM_MALLOC -static -#endif -const u16_t memp_sizes[MEMP_MAX] = { -#define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEM_ALIGN_SIZE(size), -#include "lwip/memp_std.h" -}; - -#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */ - -/** This array holds the number of elements in each pool. */ -static const u16_t memp_num[MEMP_MAX] = { -#define LWIP_MEMPOOL(name,num,size,desc) (num), -#include "lwip/memp_std.h" -}; - -/** This array holds a textual description of each pool. */ -#ifdef LWIP_DEBUG -static const char *memp_desc[MEMP_MAX] = { -#define LWIP_MEMPOOL(name,num,size,desc) (desc), -#include "lwip/memp_std.h" -}; -#endif /* LWIP_DEBUG */ - -#if MEMP_SEPARATE_POOLS - -/** This creates each memory pool. These are named memp_memory_XXX_base (where - * XXX is the name of the pool defined in memp_std.h). - * To relocate a pool, declare it as extern in cc.h. Example for GCC: - * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; - */ -#define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ - [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; -#include "lwip/memp_std.h" - -/** This array holds the base of each memory pool. */ -static u8_t *const memp_bases[] = { -#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, -#include "lwip/memp_std.h" -}; - -#else /* MEMP_SEPARATE_POOLS */ - -/** This is the actual memory used by the pools (all pools in one big block). */ -static u8_t memp_memory[MEM_ALIGNMENT - 1 -#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) -#include "lwip/memp_std.h" -]; - -#endif /* MEMP_SEPARATE_POOLS */ - -#if MEMP_SANITY_CHECK -/** - * Check that memp-lists don't form a circle, using "Floyd's cycle-finding algorithm". - */ -static int -memp_sanity(void) -{ - s16_t i; - struct memp *t, *h; - - for (i = 0; i < MEMP_MAX; i++) { - t = memp_tab[i]; - if(t != NULL) { - for (h = t->next; (t != NULL) && (h != NULL); t = t->next, - h = (((h->next != NULL) && (h->next->next != NULL)) ? h->next->next : NULL)) { - if (t == h) { - return 0; - } - } - } - } - return 1; -} -#endif /* MEMP_SANITY_CHECK*/ -#if MEMP_OVERFLOW_CHECK -#if defined(LWIP_DEBUG) && MEMP_STATS -static const char * memp_overflow_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) "/"desc, -#include "lwip/memp_std.h" - }; -#endif - -/** - * Check if a memp element was victim of an overflow - * (e.g. the restricted area after it has been altered) - * - * @param p the memp element to check - * @param memp_type the pool p comes from - */ -static void -memp_overflow_check_element_overflow(struct memp *p, u16_t memp_type) -{ - u16_t k; - u8_t *m; -#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE + memp_sizes[memp_type]; - for (k = 0; k < MEMP_SANITY_REGION_AFTER_ALIGNED; k++) { - if (m[k] != 0xcd) { - char errstr[128] = "detected memp overflow in pool "; - char digit[] = "0"; - if(memp_type >= 10) { - digit[0] = '0' + (memp_type/10); - strcat(errstr, digit); - } - digit[0] = '0' + (memp_type%10); - strcat(errstr, digit); -#if defined(LWIP_DEBUG) && MEMP_STATS - strcat(errstr, memp_overflow_names[memp_type]); -#endif - LWIP_ASSERT(errstr, 0); - } - } -#endif -} - -/** - * Check if a memp element was victim of an underflow - * (e.g. the restricted area before it has been altered) - * - * @param p the memp element to check - * @param memp_type the pool p comes from - */ -static void -memp_overflow_check_element_underflow(struct memp *p, u16_t memp_type) -{ - u16_t k; - u8_t *m; -#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; - for (k = 0; k < MEMP_SANITY_REGION_BEFORE_ALIGNED; k++) { - if (m[k] != 0xcd) { - char errstr[128] = "detected memp underflow in pool "; - char digit[] = "0"; - if(memp_type >= 10) { - digit[0] = '0' + (memp_type/10); - strcat(errstr, digit); - } - digit[0] = '0' + (memp_type%10); - strcat(errstr, digit); -#if defined(LWIP_DEBUG) && MEMP_STATS - strcat(errstr, memp_overflow_names[memp_type]); -#endif - LWIP_ASSERT(errstr, 0); - } - } -#endif -} - -/** - * Do an overflow check for all elements in every pool. - * - * @see memp_overflow_check_element for a description of the check - */ -static void -memp_overflow_check_all(void) -{ - u16_t i, j; - struct memp *p; - - p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); - for (i = 0; i < MEMP_MAX; ++i) { - p = p; - for (j = 0; j < memp_num[i]; ++j) { - memp_overflow_check_element_overflow(p, i); - p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); - } - } - p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); - for (i = 0; i < MEMP_MAX; ++i) { - p = p; - for (j = 0; j < memp_num[i]; ++j) { - memp_overflow_check_element_underflow(p, i); - p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); - } - } -} - -/** - * Initialize the restricted areas of all memp elements in every pool. - */ -static void -memp_overflow_init(void) -{ - u16_t i, j; - struct memp *p; - u8_t *m; - - p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); - for (i = 0; i < MEMP_MAX; ++i) { - p = p; - for (j = 0; j < memp_num[i]; ++j) { -#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; - memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED); -#endif -#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE + memp_sizes[i]; - memset(m, 0xcd, MEMP_SANITY_REGION_AFTER_ALIGNED); -#endif - p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); - } - } -} -#endif /* MEMP_OVERFLOW_CHECK */ - -/** - * Initialize this module. - * - * Carves out memp_memory into linked lists for each pool-type. - */ -void -memp_init(void) -{ - struct memp *memp; - u16_t i, j; - - for (i = 0; i < MEMP_MAX; ++i) { - MEMP_STATS_AVAIL(used, i, 0); - MEMP_STATS_AVAIL(max, i, 0); - MEMP_STATS_AVAIL(err, i, 0); - MEMP_STATS_AVAIL(avail, i, memp_num[i]); - } - -#if !MEMP_SEPARATE_POOLS - memp = (struct memp *)LWIP_MEM_ALIGN(memp_memory); -#endif /* !MEMP_SEPARATE_POOLS */ - /* for every pool: */ - for (i = 0; i < MEMP_MAX; ++i) { - memp_tab[i] = NULL; -#if MEMP_SEPARATE_POOLS - memp = (struct memp*)memp_bases[i]; -#endif /* MEMP_SEPARATE_POOLS */ - /* create a linked list of memp elements */ - for (j = 0; j < memp_num[i]; ++j) { - memp->next = memp_tab[i]; - memp_tab[i] = memp; - memp = (struct memp *)(void *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i] -#if MEMP_OVERFLOW_CHECK - + MEMP_SANITY_REGION_AFTER_ALIGNED -#endif - ); - } - } -#if MEMP_OVERFLOW_CHECK - memp_overflow_init(); - /* check everything a first time to see if it worked */ - memp_overflow_check_all(); -#endif /* MEMP_OVERFLOW_CHECK */ -} - -/** - * Get an element from a specific pool. - * - * @param type the pool to get an element from - * - * the debug version has two more parameters: - * @param file file name calling this function - * @param line number of line where this function is called - * - * @return a pointer to the allocated memory or a NULL pointer on error - */ -void * -#if !MEMP_OVERFLOW_CHECK -memp_malloc(memp_t type) -#else -memp_malloc_fn(memp_t type, const char* file, const int line) -#endif -{ - struct memp *memp; - SYS_ARCH_DECL_PROTECT(old_level); - - LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); - - SYS_ARCH_PROTECT(old_level); -#if MEMP_OVERFLOW_CHECK >= 2 - memp_overflow_check_all(); -#endif /* MEMP_OVERFLOW_CHECK >= 2 */ - - memp = memp_tab[type]; - - if (memp != NULL) { - memp_tab[type] = memp->next; -#if MEMP_OVERFLOW_CHECK - memp->next = NULL; - memp->file = file; - memp->line = line; -#endif /* MEMP_OVERFLOW_CHECK */ - MEMP_STATS_INC_USED(used, type); - LWIP_ASSERT("memp_malloc: memp properly aligned", - ((mem_ptr_t)memp % MEM_ALIGNMENT) == 0); - memp = (struct memp*)(void *)((u8_t*)memp + MEMP_SIZE); - } else { - LWIP_DEBUGF(MEMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("memp_malloc: out of memory in pool %s\n", memp_desc[type])); - MEMP_STATS_INC(err, type); - } - - SYS_ARCH_UNPROTECT(old_level); - - return memp; -} - -/** - * Put an element back into its pool. - * - * @param type the pool where to put mem - * @param mem the memp element to free - */ -void -memp_free(memp_t type, void *mem) -{ - struct memp *memp; - SYS_ARCH_DECL_PROTECT(old_level); - - if (mem == NULL) { - return; - } - LWIP_ASSERT("memp_free: mem properly aligned", - ((mem_ptr_t)mem % MEM_ALIGNMENT) == 0); - - memp = (struct memp *)(void *)((u8_t*)mem - MEMP_SIZE); - - SYS_ARCH_PROTECT(old_level); -#if MEMP_OVERFLOW_CHECK -#if MEMP_OVERFLOW_CHECK >= 2 - memp_overflow_check_all(); -#else - memp_overflow_check_element_overflow(memp, type); - memp_overflow_check_element_underflow(memp, type); -#endif /* MEMP_OVERFLOW_CHECK >= 2 */ -#endif /* MEMP_OVERFLOW_CHECK */ - - MEMP_STATS_DEC(used, type); - - memp->next = memp_tab[type]; - memp_tab[type] = memp; - -#if MEMP_SANITY_CHECK - LWIP_ASSERT("memp sanity", memp_sanity()); -#endif /* MEMP_SANITY_CHECK */ - - SYS_ARCH_UNPROTECT(old_level); -} - -#endif /* MEMP_MEM_MALLOC */ diff --git a/user/mpy/lib/lwip/src/core/netif.c b/user/mpy/lib/lwip/src/core/netif.c deleted file mode 100644 index 4a02e77..0000000 --- a/user/mpy/lib/lwip/src/core/netif.c +++ /dev/null @@ -1,774 +0,0 @@ -/** - * @file - * lwIP network interface abstraction - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/tcp_impl.h" -#include "lwip/snmp.h" -#include "lwip/igmp.h" -#include "netif/etharp.h" -#include "lwip/stats.h" -#if ENABLE_LOOPBACK -#include "lwip/sys.h" -#if LWIP_NETIF_LOOPBACK_MULTITHREADING -#include "lwip/tcpip.h" -#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ - -#if LWIP_AUTOIP -#include "lwip/autoip.h" -#endif /* LWIP_AUTOIP */ -#if LWIP_DHCP -#include "lwip/dhcp.h" -#endif /* LWIP_DHCP */ - -#if LWIP_NETIF_STATUS_CALLBACK -#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) -#else -#define NETIF_STATUS_CALLBACK(n) -#endif /* LWIP_NETIF_STATUS_CALLBACK */ - -#if LWIP_NETIF_LINK_CALLBACK -#define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0) -#else -#define NETIF_LINK_CALLBACK(n) -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -struct netif *netif_list; -struct netif *netif_default; - -static u8_t netif_num; - -#if LWIP_HAVE_LOOPIF -static struct netif loop_netif; - -/** - * Initialize a lwip network interface structure for a loopback interface - * - * @param netif the lwip network interface structure for this loopif - * @return ERR_OK if the loopif is initialized - * ERR_MEM if private data couldn't be allocated - */ -static err_t -netif_loopif_init(struct netif *netif) -{ - /* initialize the snmp variables and counters inside the struct netif - * ifSpeed: no assumption can be made! - */ - NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0); - - netif->name[0] = 'l'; - netif->name[1] = 'o'; - netif->output = netif_loop_output; - return ERR_OK; -} -#endif /* LWIP_HAVE_LOOPIF */ - -void -netif_init(void) -{ -#if LWIP_HAVE_LOOPIF - ip_addr_t loop_ipaddr, loop_netmask, loop_gw; - IP4_ADDR(&loop_gw, 127,0,0,1); - IP4_ADDR(&loop_ipaddr, 127,0,0,1); - IP4_ADDR(&loop_netmask, 255,0,0,0); - -#if NO_SYS - netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, ip_input); -#else /* NO_SYS */ - netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input); -#endif /* NO_SYS */ - netif_set_up(&loop_netif); - -#endif /* LWIP_HAVE_LOOPIF */ -} - -/** - * Add a network interface to the list of lwIP netifs. - * - * @param netif a pre-allocated netif structure - * @param ipaddr IP address for the new netif - * @param netmask network mask for the new netif - * @param gw default gateway IP address for the new netif - * @param state opaque data passed to the new netif - * @param init callback function that initializes the interface - * @param input callback function that is called to pass - * ingress packets up in the protocol layer stack. - * - * @return netif, or NULL if failed. - */ -struct netif * -netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input) -{ - - LWIP_ASSERT("No init function given", init != NULL); - - /* reset new interface configuration state */ - ip_addr_set_zero(&netif->ip_addr); - ip_addr_set_zero(&netif->netmask); - ip_addr_set_zero(&netif->gw); - netif->flags = 0; -#if LWIP_DHCP - /* netif not under DHCP control by default */ - netif->dhcp = NULL; -#endif /* LWIP_DHCP */ -#if LWIP_AUTOIP - /* netif not under AutoIP control by default */ - netif->autoip = NULL; -#endif /* LWIP_AUTOIP */ -#if LWIP_NETIF_STATUS_CALLBACK - netif->status_callback = NULL; -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_LINK_CALLBACK - netif->link_callback = NULL; -#endif /* LWIP_NETIF_LINK_CALLBACK */ -#if LWIP_IGMP - netif->igmp_mac_filter = NULL; -#endif /* LWIP_IGMP */ -#if ENABLE_LOOPBACK - netif->loop_first = NULL; - netif->loop_last = NULL; -#endif /* ENABLE_LOOPBACK */ - - /* remember netif specific state information data */ - netif->state = state; - netif->num = netif_num++; - netif->input = input; - NETIF_SET_HWADDRHINT(netif, NULL); -#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS - netif->loop_cnt_current = 0; -#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */ - - netif_set_addr(netif, ipaddr, netmask, gw); - - /* call user specified initialization function for netif */ - if (init(netif) != ERR_OK) { - return NULL; - } - - /* add this netif to the list */ - netif->next = netif_list; - netif_list = netif; - snmp_inc_iflist(); - -#if LWIP_IGMP - /* start IGMP processing */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_start(netif); - } -#endif /* LWIP_IGMP */ - - LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ", - netif->name[0], netif->name[1])); - ip_addr_debug_print(NETIF_DEBUG, ipaddr); - LWIP_DEBUGF(NETIF_DEBUG, (" netmask ")); - ip_addr_debug_print(NETIF_DEBUG, netmask); - LWIP_DEBUGF(NETIF_DEBUG, (" gw ")); - ip_addr_debug_print(NETIF_DEBUG, gw); - LWIP_DEBUGF(NETIF_DEBUG, ("\n")); - return netif; -} - -/** - * Change IP address configuration for a network interface (including netmask - * and default gateway). - * - * @param netif the network interface to change - * @param ipaddr the new IP address - * @param netmask the new netmask - * @param gw the new default gateway - */ -void -netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw) -{ - netif_set_ipaddr(netif, ipaddr); - netif_set_netmask(netif, netmask); - netif_set_gw(netif, gw); -} - -/** - * Remove a network interface from the list of lwIP netifs. - * - * @param netif the network interface to remove - */ -void -netif_remove(struct netif *netif) -{ - if (netif == NULL) { - return; - } - -#if LWIP_IGMP - /* stop IGMP processing */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_stop(netif); - } -#endif /* LWIP_IGMP */ - if (netif_is_up(netif)) { - /* set netif down before removing (call callback function) */ - netif_set_down(netif); - } - - snmp_delete_ipaddridx_tree(netif); - - /* is it the first netif? */ - if (netif_list == netif) { - netif_list = netif->next; - } else { - /* look for netif further down the list */ - struct netif * tmpNetif; - for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { - if (tmpNetif->next == netif) { - tmpNetif->next = netif->next; - break; - } - } - if (tmpNetif == NULL) - return; /* we didn't find any netif today */ - } - snmp_dec_iflist(); - /* this netif is default? */ - if (netif_default == netif) { - /* reset default netif */ - netif_set_default(NULL); - } -#if LWIP_NETIF_REMOVE_CALLBACK - if (netif->remove_callback) { - netif->remove_callback(netif); - } -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); -} - -/** - * Find a network interface by searching for its name - * - * @param name the name of the netif (like netif->name) plus concatenated number - * in ascii representation (e.g. 'en0') - */ -struct netif * -netif_find(char *name) -{ - struct netif *netif; - u8_t num; - - if (name == NULL) { - return NULL; - } - - num = name[2] - '0'; - - for(netif = netif_list; netif != NULL; netif = netif->next) { - if (num == netif->num && - name[0] == netif->name[0] && - name[1] == netif->name[1]) { - LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); - return netif; - } - } - LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); - return NULL; -} - -/** - * Change the IP address of a network interface - * - * @param netif the network interface to change - * @param ipaddr the new IP address - * - * @note call netif_set_addr() if you also want to change netmask and - * default gateway - */ -void -netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr) -{ - /* TODO: Handling of obsolete pcbs */ - /* See: http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */ -#if LWIP_TCP - struct tcp_pcb *pcb; - struct tcp_pcb_listen *lpcb; - - /* address is actually being changed? */ - if (ipaddr && (ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) { - /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */ - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n")); - pcb = tcp_active_pcbs; - while (pcb != NULL) { - /* PCB bound to current local interface address? */ - if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr)) -#if LWIP_AUTOIP - /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */ - && !ip_addr_islinklocal(&(pcb->local_ip)) -#endif /* LWIP_AUTOIP */ - ) { - /* this connection must be aborted */ - struct tcp_pcb *next = pcb->next; - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb)); - tcp_abort(pcb); - pcb = next; - } else { - pcb = pcb->next; - } - } - for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - /* PCB bound to current local interface address? */ - if ((!(ip_addr_isany(&(lpcb->local_ip)))) && - (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr)))) { - /* The PCB is listening to the old ipaddr and - * is set to listen to the new one instead */ - ip_addr_set(&(lpcb->local_ip), ipaddr); - } - } - } -#endif - snmp_delete_ipaddridx_tree(netif); - snmp_delete_iprteidx_tree(0,netif); - /* set new IP address to netif */ - ip_addr_set(&(netif->ip_addr), ipaddr); - snmp_insert_ipaddridx_tree(netif); - snmp_insert_iprteidx_tree(0,netif); - - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - netif->name[0], netif->name[1], - ip4_addr1_16(&netif->ip_addr), - ip4_addr2_16(&netif->ip_addr), - ip4_addr3_16(&netif->ip_addr), - ip4_addr4_16(&netif->ip_addr))); -} - -/** - * Change the default gateway for a network interface - * - * @param netif the network interface to change - * @param gw the new default gateway - * - * @note call netif_set_addr() if you also want to change ip address and netmask - */ -void -netif_set_gw(struct netif *netif, ip_addr_t *gw) -{ - ip_addr_set(&(netif->gw), gw); - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - netif->name[0], netif->name[1], - ip4_addr1_16(&netif->gw), - ip4_addr2_16(&netif->gw), - ip4_addr3_16(&netif->gw), - ip4_addr4_16(&netif->gw))); -} - -/** - * Change the netmask of a network interface - * - * @param netif the network interface to change - * @param netmask the new netmask - * - * @note call netif_set_addr() if you also want to change ip address and - * default gateway - */ -void -netif_set_netmask(struct netif *netif, ip_addr_t *netmask) -{ - snmp_delete_iprteidx_tree(0, netif); - /* set new netmask to netif */ - ip_addr_set(&(netif->netmask), netmask); - snmp_insert_iprteidx_tree(0, netif); - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - netif->name[0], netif->name[1], - ip4_addr1_16(&netif->netmask), - ip4_addr2_16(&netif->netmask), - ip4_addr3_16(&netif->netmask), - ip4_addr4_16(&netif->netmask))); -} - -/** - * Set a network interface as the default network interface - * (used to output all packets for which no specific route is found) - * - * @param netif the default network interface - */ -void -netif_set_default(struct netif *netif) -{ - if (netif == NULL) { - /* remove default route */ - snmp_delete_iprteidx_tree(1, netif); - } else { - /* install default route */ - snmp_insert_iprteidx_tree(1, netif); - } - netif_default = netif; - LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n", - netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); -} - -/** - * Bring an interface up, available for processing - * traffic. - * - * @note: Enabling DHCP on a down interface will make it come - * up once configured. - * - * @see dhcp_start() - */ -void netif_set_up(struct netif *netif) -{ - if (!(netif->flags & NETIF_FLAG_UP)) { - netif->flags |= NETIF_FLAG_UP; - -#if LWIP_SNMP - snmp_get_sysuptime(&netif->ts); -#endif /* LWIP_SNMP */ - - NETIF_STATUS_CALLBACK(netif); - - if (netif->flags & NETIF_FLAG_LINK_UP) { -#if LWIP_ARP - /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ - if (netif->flags & (NETIF_FLAG_ETHARP)) { - etharp_gratuitous(netif); - } -#endif /* LWIP_ARP */ - -#if LWIP_IGMP - /* resend IGMP memberships */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_report_groups( netif); - } -#endif /* LWIP_IGMP */ - } - } -} - -/** - * Bring an interface down, disabling any traffic processing. - * - * @note: Enabling DHCP on a down interface will make it come - * up once configured. - * - * @see dhcp_start() - */ -void netif_set_down(struct netif *netif) -{ - if (netif->flags & NETIF_FLAG_UP) { - netif->flags &= ~NETIF_FLAG_UP; -#if LWIP_SNMP - snmp_get_sysuptime(&netif->ts); -#endif - -#if LWIP_ARP - if (netif->flags & NETIF_FLAG_ETHARP) { - etharp_cleanup_netif(netif); - } -#endif /* LWIP_ARP */ - NETIF_STATUS_CALLBACK(netif); - } -} - -#if LWIP_NETIF_STATUS_CALLBACK -/** - * Set callback to be called when interface is brought up/down - */ -void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback) -{ - if (netif) { - netif->status_callback = status_callback; - } -} -#endif /* LWIP_NETIF_STATUS_CALLBACK */ - -#if LWIP_NETIF_REMOVE_CALLBACK -/** - * Set callback to be called when the interface has been removed - */ -void -netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback) -{ - if (netif) { - netif->remove_callback = remove_callback; - } -} -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - -/** - * Called by a driver when its link goes up - */ -void netif_set_link_up(struct netif *netif ) -{ - if (!(netif->flags & NETIF_FLAG_LINK_UP)) { - netif->flags |= NETIF_FLAG_LINK_UP; - -#if LWIP_DHCP - if (netif->dhcp) { - dhcp_network_changed(netif); - } -#endif /* LWIP_DHCP */ - -#if LWIP_AUTOIP - if (netif->autoip) { - autoip_network_changed(netif); - } -#endif /* LWIP_AUTOIP */ - - if (netif->flags & NETIF_FLAG_UP) { -#if LWIP_ARP - /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ - if (netif->flags & NETIF_FLAG_ETHARP) { - etharp_gratuitous(netif); - } -#endif /* LWIP_ARP */ - -#if LWIP_IGMP - /* resend IGMP memberships */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_report_groups( netif); - } -#endif /* LWIP_IGMP */ - } - NETIF_LINK_CALLBACK(netif); - } -} - -/** - * Called by a driver when its link goes down - */ -void netif_set_link_down(struct netif *netif ) -{ - if (netif->flags & NETIF_FLAG_LINK_UP) { - netif->flags &= ~NETIF_FLAG_LINK_UP; - NETIF_LINK_CALLBACK(netif); - } -} - -#if LWIP_NETIF_LINK_CALLBACK -/** - * Set callback to be called when link is brought up/down - */ -void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback) -{ - if (netif) { - netif->link_callback = link_callback; - } -} -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#if ENABLE_LOOPBACK -/** - * Send an IP packet to be received on the same netif (loopif-like). - * The pbuf is simply copied and handed back to netif->input. - * In multithreaded mode, this is done directly since netif->input must put - * the packet on a queue. - * In callback mode, the packet is put on an internal queue and is fed to - * netif->input by netif_poll(). - * - * @param netif the lwip network interface structure - * @param p the (IP) packet to 'send' - * @param ipaddr the ip address to send the packet to (not used) - * @return ERR_OK if the packet has been sent - * ERR_MEM if the pbuf used to copy the packet couldn't be allocated - */ -err_t -netif_loop_output(struct netif *netif, struct pbuf *p, - ip_addr_t *ipaddr) -{ - struct pbuf *r; - err_t err; - struct pbuf *last; -#if LWIP_LOOPBACK_MAX_PBUFS - u8_t clen = 0; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ - /* If we have a loopif, SNMP counters are adjusted for it, - * if not they are adjusted for 'netif'. */ -#if LWIP_SNMP -#if LWIP_HAVE_LOOPIF - struct netif *stats_if = &loop_netif; -#else /* LWIP_HAVE_LOOPIF */ - struct netif *stats_if = netif; -#endif /* LWIP_HAVE_LOOPIF */ -#endif /* LWIP_SNMP */ - SYS_ARCH_DECL_PROTECT(lev); - LWIP_UNUSED_ARG(ipaddr); - - /* Allocate a new pbuf */ - r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); - if (r == NULL) { - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(stats_if); - return ERR_MEM; - } -#if LWIP_LOOPBACK_MAX_PBUFS - clen = pbuf_clen(r); - /* check for overflow or too many pbuf on queue */ - if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) || - ((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) { - pbuf_free(r); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(stats_if); - return ERR_MEM; - } - netif->loop_cnt_current += clen; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ - - /* Copy the whole pbuf queue p into the single pbuf r */ - if ((err = pbuf_copy(r, p)) != ERR_OK) { - pbuf_free(r); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(stats_if); - return err; - } - - /* Put the packet on a linked list which gets emptied through calling - netif_poll(). */ - - /* let last point to the last pbuf in chain r */ - for (last = r; last->next != NULL; last = last->next); - - SYS_ARCH_PROTECT(lev); - if(netif->loop_first != NULL) { - LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL); - netif->loop_last->next = r; - netif->loop_last = last; - } else { - netif->loop_first = r; - netif->loop_last = last; - } - SYS_ARCH_UNPROTECT(lev); - - LINK_STATS_INC(link.xmit); - snmp_add_ifoutoctets(stats_if, p->tot_len); - snmp_inc_ifoutucastpkts(stats_if); - -#if LWIP_NETIF_LOOPBACK_MULTITHREADING - /* For multithreading environment, schedule a call to netif_poll */ - tcpip_callback((tcpip_callback_fn)netif_poll, netif); -#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ - - return ERR_OK; -} - -/** - * Call netif_poll() in the main loop of your application. This is to prevent - * reentering non-reentrant functions like tcp_input(). Packets passed to - * netif_loop_output() are put on a list that is passed to netif->input() by - * netif_poll(). - */ -void -netif_poll(struct netif *netif) -{ - struct pbuf *in; - /* If we have a loopif, SNMP counters are adjusted for it, - * if not they are adjusted for 'netif'. */ -#if LWIP_SNMP -#if LWIP_HAVE_LOOPIF - struct netif *stats_if = &loop_netif; -#else /* LWIP_HAVE_LOOPIF */ - struct netif *stats_if = netif; -#endif /* LWIP_HAVE_LOOPIF */ -#endif /* LWIP_SNMP */ - SYS_ARCH_DECL_PROTECT(lev); - - do { - /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */ - SYS_ARCH_PROTECT(lev); - in = netif->loop_first; - if (in != NULL) { - struct pbuf *in_end = in; -#if LWIP_LOOPBACK_MAX_PBUFS - u8_t clen = pbuf_clen(in); - /* adjust the number of pbufs on queue */ - LWIP_ASSERT("netif->loop_cnt_current underflow", - ((netif->loop_cnt_current - clen) < netif->loop_cnt_current)); - netif->loop_cnt_current -= clen; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ - while (in_end->len != in_end->tot_len) { - LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL); - in_end = in_end->next; - } - /* 'in_end' now points to the last pbuf from 'in' */ - if (in_end == netif->loop_last) { - /* this was the last pbuf in the list */ - netif->loop_first = netif->loop_last = NULL; - } else { - /* pop the pbuf off the list */ - netif->loop_first = in_end->next; - LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL); - } - /* De-queue the pbuf from its successors on the 'loop_' list. */ - in_end->next = NULL; - } - SYS_ARCH_UNPROTECT(lev); - - if (in != NULL) { - LINK_STATS_INC(link.recv); - snmp_add_ifinoctets(stats_if, in->tot_len); - snmp_inc_ifinucastpkts(stats_if); - /* loopback packets are always IP packets! */ - if (ip_input(in, netif) != ERR_OK) { - pbuf_free(in); - } - /* Don't reference the packet any more! */ - in = NULL; - } - /* go on while there is a packet on the list */ - } while (netif->loop_first != NULL); -} - -#if !LWIP_NETIF_LOOPBACK_MULTITHREADING -/** - * Calls netif_poll() for every netif on the netif_list. - */ -void -netif_poll_all(void) -{ - struct netif *netif = netif_list; - /* loop through netifs */ - while (netif != NULL) { - netif_poll(netif); - /* proceed to next network interface */ - netif = netif->next; - } -} -#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ diff --git a/user/mpy/lib/lwip/src/core/pbuf.c b/user/mpy/lib/lwip/src/core/pbuf.c deleted file mode 100644 index 1e5e53b..0000000 --- a/user/mpy/lib/lwip/src/core/pbuf.c +++ /dev/null @@ -1,1179 +0,0 @@ -/** - * @file - * Packet buffer management - * - * Packets are built from the pbuf data structure. It supports dynamic - * memory allocation for packet contents or can reference externally - * managed packet contents both in RAM and ROM. Quick allocation for - * incoming packets is provided through pools with fixed sized pbufs. - * - * A packet may span over multiple pbufs, chained as a singly linked - * list. This is called a "pbuf chain". - * - * Multiple packets may be queued, also using this singly linked list. - * This is called a "packet queue". - * - * So, a packet queue consists of one or more pbuf chains, each of - * which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE - * NOT SUPPORTED!!! Use helper structs to queue multiple packets. - * - * The differences between a pbuf chain and a packet queue are very - * precise but subtle. - * - * The last pbuf of a packet has a ->tot_len field that equals the - * ->len field. It can be found by traversing the list. If the last - * pbuf of a packet has a ->next field other than NULL, more packets - * are on the queue. - * - * Therefore, looping through a pbuf of a single packet, has an - * loop end condition (tot_len == p->len), NOT (next == NULL). - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/stats.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/sys.h" -#include "arch/perf.h" -#if LWIP_TCP && TCP_QUEUE_OOSEQ -#include "lwip/tcp_impl.h" -#endif -#if LWIP_CHECKSUM_ON_COPY -#include "lwip/inet_chksum.h" -#endif - -#include - -#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) -/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically - aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */ -#define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) - -#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ -#define PBUF_POOL_IS_EMPTY() -#else /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ */ - -#if !NO_SYS -#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL -#include "lwip/tcpip.h" -#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \ - if(tcpip_callback_with_block(pbuf_free_ooseq_callback, NULL, 0) != ERR_OK) { \ - SYS_ARCH_PROTECT(old_level); \ - pbuf_free_ooseq_pending = 0; \ - SYS_ARCH_UNPROTECT(old_level); \ - } } while(0) -#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ -#endif /* !NO_SYS */ - -volatile u8_t pbuf_free_ooseq_pending; -#define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty() - -/** - * Attempt to reclaim some memory from queued out-of-sequence TCP segments - * if we run out of pool pbufs. It's better to give priority to new packets - * if we're running out. - * - * This must be done in the correct thread context therefore this function - * can only be used with NO_SYS=0 and through tcpip_callback. - */ -#if !NO_SYS -static -#endif /* !NO_SYS */ -void -pbuf_free_ooseq(void) -{ - struct tcp_pcb* pcb; - SYS_ARCH_DECL_PROTECT(old_level); - - SYS_ARCH_PROTECT(old_level); - pbuf_free_ooseq_pending = 0; - SYS_ARCH_UNPROTECT(old_level); - - for (pcb = tcp_active_pcbs; NULL != pcb; pcb = pcb->next) { - if (NULL != pcb->ooseq) { - /** Free the ooseq pbufs of one PCB only */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free_ooseq: freeing out-of-sequence pbufs\n")); - tcp_segs_free(pcb->ooseq); - pcb->ooseq = NULL; - return; - } - } -} - -#if !NO_SYS -/** - * Just a callback function for tcpip_timeout() that calls pbuf_free_ooseq(). - */ -static void -pbuf_free_ooseq_callback(void *arg) -{ - LWIP_UNUSED_ARG(arg); - pbuf_free_ooseq(); -} -#endif /* !NO_SYS */ - -/** Queue a call to pbuf_free_ooseq if not already queued. */ -static void -pbuf_pool_is_empty(void) -{ -#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL - SYS_ARCH_DECL_PROTECT(old_level); - SYS_ARCH_PROTECT(old_level); - pbuf_free_ooseq_pending = 1; - SYS_ARCH_UNPROTECT(old_level); -#else /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ - u8_t queued; - SYS_ARCH_DECL_PROTECT(old_level); - SYS_ARCH_PROTECT(old_level); - queued = pbuf_free_ooseq_pending; - pbuf_free_ooseq_pending = 1; - SYS_ARCH_UNPROTECT(old_level); - - if(!queued) { - /* queue a call to pbuf_free_ooseq if not already queued */ - PBUF_POOL_FREE_OOSEQ_QUEUE_CALL(); - } -#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ -} -#endif /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ */ - -/** - * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). - * - * The actual memory allocated for the pbuf is determined by the - * layer at which the pbuf is allocated and the requested size - * (from the size parameter). - * - * @param layer flag to define header size - * @param length size of the pbuf's payload - * @param type this parameter decides how and where the pbuf - * should be allocated as follows: - * - * - PBUF_RAM: buffer memory for pbuf is allocated as one large - * chunk. This includes protocol headers as well. - * - PBUF_ROM: no buffer memory is allocated for the pbuf, even for - * protocol headers. Additional headers must be prepended - * by allocating another pbuf and chain in to the front of - * the ROM pbuf. It is assumed that the memory used is really - * similar to ROM in that it is immutable and will not be - * changed. Memory which is dynamic should generally not - * be attached to PBUF_ROM pbufs. Use PBUF_REF instead. - * - PBUF_REF: no buffer memory is allocated for the pbuf, even for - * protocol headers. It is assumed that the pbuf is only - * being used in a single thread. If the pbuf gets queued, - * then pbuf_take should be called to copy the buffer. - * - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from - * the pbuf pool that is allocated during pbuf_init(). - * - * @return the allocated pbuf. If multiple pbufs where allocated, this - * is the first pbuf of a pbuf chain. - */ -struct pbuf * -pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) -{ - struct pbuf *p, *q, *r; - u16_t offset; - s32_t rem_len; /* remaining length */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F")\n", length)); - - /* determine header offset */ - switch (layer) { - case PBUF_TRANSPORT: - /* add room for transport (often TCP) layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; - break; - case PBUF_IP: - /* add room for IP layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; - break; - case PBUF_LINK: - /* add room for link layer header */ - offset = PBUF_LINK_HLEN; - break; - case PBUF_RAW: - offset = 0; - break; - default: - LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0); - return NULL; - } - - switch (type) { - case PBUF_POOL: - /* allocate head of pbuf chain into p */ - p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); - if (p == NULL) { - PBUF_POOL_IS_EMPTY(); - return NULL; - } - p->type = type; - p->next = NULL; - - /* make the payload pointer point 'offset' bytes into pbuf data memory */ - p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + (SIZEOF_STRUCT_PBUF + offset))); - LWIP_ASSERT("pbuf_alloc: pbuf p->payload properly aligned", - ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); - /* the total length of the pbuf chain is the requested size */ - p->tot_len = length; - /* set the length of the first pbuf in the chain */ - p->len = LWIP_MIN(length, PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)); - LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", - ((u8_t*)p->payload + p->len <= - (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); - LWIP_ASSERT("PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT", - (PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)) > 0 ); - /* set reference count (needed here in case we fail) */ - p->ref = 1; - - /* now allocate the tail of the pbuf chain */ - - /* remember first pbuf for linkage in next iteration */ - r = p; - /* remaining length to be allocated */ - rem_len = length - p->len; - /* any remaining pbufs to be allocated? */ - while (rem_len > 0) { - q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); - if (q == NULL) { - PBUF_POOL_IS_EMPTY(); - /* free chain so far allocated */ - pbuf_free(p); - /* bail out unsuccesfully */ - return NULL; - } - q->type = type; - q->flags = 0; - q->next = NULL; - /* make previous pbuf point to this pbuf */ - r->next = q; - /* set total length of this pbuf and next in chain */ - LWIP_ASSERT("rem_len < max_u16_t", rem_len < 0xffff); - q->tot_len = (u16_t)rem_len; - /* this pbuf length is pool size, unless smaller sized tail */ - q->len = LWIP_MIN((u16_t)rem_len, PBUF_POOL_BUFSIZE_ALIGNED); - q->payload = (void *)((u8_t *)q + SIZEOF_STRUCT_PBUF); - LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", - ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0); - LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", - ((u8_t*)p->payload + p->len <= - (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); - q->ref = 1; - /* calculate remaining length to be allocated */ - rem_len -= q->len; - /* remember this pbuf for linkage in next iteration */ - r = q; - } - /* end of chain */ - /*r->next = NULL;*/ - - break; - case PBUF_RAM: - /* If pbuf is to be allocated in RAM, allocate memory for it. */ - p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length)); - if (p == NULL) { - return NULL; - } - /* Set up internal structure of the pbuf. */ - p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)); - p->len = p->tot_len = length; - p->next = NULL; - p->type = type; - - LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", - ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); - break; - /* pbuf references existing (non-volatile static constant) ROM payload? */ - case PBUF_ROM: - /* pbuf references existing (externally allocated) RAM payload? */ - case PBUF_REF: - /* only allocate memory for the pbuf structure */ - p = (struct pbuf *)memp_malloc(MEMP_PBUF); - if (p == NULL) { - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", - (type == PBUF_ROM) ? "ROM" : "REF")); - return NULL; - } - /* caller must set this field properly, afterwards */ - p->payload = NULL; - p->len = p->tot_len = length; - p->next = NULL; - p->type = type; - break; - default: - LWIP_ASSERT("pbuf_alloc: erroneous type", 0); - return NULL; - } - /* set reference count */ - p->ref = 1; - /* set flags */ - p->flags = 0; - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); - return p; -} - -#if LWIP_SUPPORT_CUSTOM_PBUF -/** Initialize a custom pbuf (already allocated). - * - * @param layer flag to define header size - * @param length size of the pbuf's payload - * @param type type of the pbuf (only used to treat the pbuf accordingly, as - * this function allocates no memory) - * @param p pointer to the custom pbuf to initialize (already allocated) - * @param payload_mem pointer to the buffer that is used for payload and headers, - * must be at least big enough to hold 'length' plus the header size, - * may be NULL if set later. - * ATTENTION: The caller is responsible for correct alignment of this buffer!! - * @param payload_mem_len the size of the 'payload_mem' buffer, must be at least - * big enough to hold 'length' plus the header size - */ -struct pbuf* -pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, - void *payload_mem, u16_t payload_mem_len) -{ - u16_t offset; - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloced_custom(length=%"U16_F")\n", length)); - - /* determine header offset */ - switch (l) { - case PBUF_TRANSPORT: - /* add room for transport (often TCP) layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; - break; - case PBUF_IP: - /* add room for IP layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; - break; - case PBUF_LINK: - /* add room for link layer header */ - offset = PBUF_LINK_HLEN; - break; - case PBUF_RAW: - offset = 0; - break; - default: - LWIP_ASSERT("pbuf_alloced_custom: bad pbuf layer", 0); - return NULL; - } - - if (LWIP_MEM_ALIGN_SIZE(offset) + length > payload_mem_len) { - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_WARNING, ("pbuf_alloced_custom(length=%"U16_F") buffer too short\n", length)); - return NULL; - } - - p->pbuf.next = NULL; - if (payload_mem != NULL) { - p->pbuf.payload = (u8_t *)payload_mem + LWIP_MEM_ALIGN_SIZE(offset); - } else { - p->pbuf.payload = NULL; - } - p->pbuf.flags = PBUF_FLAG_IS_CUSTOM; - p->pbuf.len = p->pbuf.tot_len = length; - p->pbuf.type = type; - p->pbuf.ref = 1; - return &p->pbuf; -} -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - -/** - * Shrink a pbuf chain to a desired length. - * - * @param p pbuf to shrink. - * @param new_len desired new length of pbuf chain - * - * Depending on the desired length, the first few pbufs in a chain might - * be skipped and left unchanged. The new last pbuf in the chain will be - * resized, and any remaining pbufs will be freed. - * - * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted. - * @note May not be called on a packet queue. - * - * @note Despite its name, pbuf_realloc cannot grow the size of a pbuf (chain). - */ -void -pbuf_realloc(struct pbuf *p, u16_t new_len) -{ - struct pbuf *q; - u16_t rem_len; /* remaining length */ - s32_t grow; - - LWIP_ASSERT("pbuf_realloc: p != NULL", p != NULL); - LWIP_ASSERT("pbuf_realloc: sane p->type", p->type == PBUF_POOL || - p->type == PBUF_ROM || - p->type == PBUF_RAM || - p->type == PBUF_REF); - - /* desired length larger than current length? */ - if (new_len >= p->tot_len) { - /* enlarging not yet supported */ - return; - } - - /* the pbuf chain grows by (new_len - p->tot_len) bytes - * (which may be negative in case of shrinking) */ - grow = new_len - p->tot_len; - - /* first, step over any pbufs that should remain in the chain */ - rem_len = new_len; - q = p; - /* should this pbuf be kept? */ - while (rem_len > q->len) { - /* decrease remaining length by pbuf length */ - rem_len -= q->len; - /* decrease total length indicator */ - LWIP_ASSERT("grow < max_u16_t", grow < 0xffff); - q->tot_len += (u16_t)grow; - /* proceed to next pbuf in chain */ - q = q->next; - LWIP_ASSERT("pbuf_realloc: q != NULL", q != NULL); - } - /* we have now reached the new last pbuf (in q) */ - /* rem_len == desired length for pbuf q */ - - /* shrink allocated memory for PBUF_RAM */ - /* (other types merely adjust their length fields */ - if ((q->type == PBUF_RAM) && (rem_len != q->len)) { - /* reallocate and adjust the length of the pbuf that will be split */ - q = (struct pbuf *)mem_trim(q, (u16_t)((u8_t *)q->payload - (u8_t *)q) + rem_len); - LWIP_ASSERT("mem_trim returned q == NULL", q != NULL); - } - /* adjust length fields for new last pbuf */ - q->len = rem_len; - q->tot_len = q->len; - - /* any remaining pbufs in chain? */ - if (q->next != NULL) { - /* free remaining pbufs in chain */ - pbuf_free(q->next); - } - /* q is last packet in chain */ - q->next = NULL; - -} - -/** - * Adjusts the payload pointer to hide or reveal headers in the payload. - * - * Adjusts the ->payload pointer so that space for a header - * (dis)appears in the pbuf payload. - * - * The ->payload, ->tot_len and ->len fields are adjusted. - * - * @param p pbuf to change the header size. - * @param header_size_increment Number of bytes to increment header size which - * increases the size of the pbuf. New space is on the front. - * (Using a negative value decreases the header size.) - * If hdr_size_inc is 0, this function does nothing and returns succesful. - * - * PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so - * the call will fail. A check is made that the increase in header size does - * not move the payload pointer in front of the start of the buffer. - * @return non-zero on failure, zero on success. - * - */ -u8_t -pbuf_header(struct pbuf *p, s16_t header_size_increment) -{ - u16_t type; - void *payload; - u16_t increment_magnitude; - - LWIP_ASSERT("p != NULL", p != NULL); - if ((header_size_increment == 0) || (p == NULL)) { - return 0; - } - - if (header_size_increment < 0){ - increment_magnitude = -header_size_increment; - /* Check that we aren't going to move off the end of the pbuf */ - LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;); - } else { - increment_magnitude = header_size_increment; -#if 0 - /* Can't assert these as some callers speculatively call - pbuf_header() to see if it's OK. Will return 1 below instead. */ - /* Check that we've got the correct type of pbuf to work with */ - LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL", - p->type == PBUF_RAM || p->type == PBUF_POOL); - /* Check that we aren't going to move off the beginning of the pbuf */ - LWIP_ASSERT("p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF", - (u8_t *)p->payload - increment_magnitude >= (u8_t *)p + SIZEOF_STRUCT_PBUF); -#endif - } - - type = p->type; - /* remember current payload pointer */ - payload = p->payload; - - /* pbuf types containing payloads? */ - if (type == PBUF_RAM || type == PBUF_POOL) { - /* set new payload pointer */ - p->payload = (u8_t *)p->payload - header_size_increment; - /* boundary check fails? */ - if ((u8_t *)p->payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) { - LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("pbuf_header: failed as %p < %p (not enough space for new header size)\n", - (void *)p->payload, (void *)(p + 1))); - /* restore old payload pointer */ - p->payload = payload; - /* bail out unsuccesfully */ - return 1; - } - /* pbuf types refering to external payloads? */ - } else if (type == PBUF_REF || type == PBUF_ROM) { - /* hide a header in the payload? */ - if ((header_size_increment < 0) && (increment_magnitude <= p->len)) { - /* increase payload pointer */ - p->payload = (u8_t *)p->payload - header_size_increment; - } else { - /* cannot expand payload to front (yet!) - * bail out unsuccesfully */ - return 1; - } - } else { - /* Unknown type */ - LWIP_ASSERT("bad pbuf type", 0); - return 1; - } - /* modify pbuf length fields */ - p->len += header_size_increment; - p->tot_len += header_size_increment; - - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"S16_F")\n", - (void *)payload, (void *)p->payload, header_size_increment)); - - return 0; -} - -/** - * Dereference a pbuf chain or queue and deallocate any no-longer-used - * pbufs at the head of this chain or queue. - * - * Decrements the pbuf reference count. If it reaches zero, the pbuf is - * deallocated. - * - * For a pbuf chain, this is repeated for each pbuf in the chain, - * up to the first pbuf which has a non-zero reference count after - * decrementing. So, when all reference counts are one, the whole - * chain is free'd. - * - * @param p The pbuf (chain) to be dereferenced. - * - * @return the number of pbufs that were de-allocated - * from the head of the chain. - * - * @note MUST NOT be called on a packet queue (Not verified to work yet). - * @note the reference counter of a pbuf equals the number of pointers - * that refer to the pbuf (or into the pbuf). - * - * @internal examples: - * - * Assuming existing chains a->b->c with the following reference - * counts, calling pbuf_free(a) results in: - * - * 1->2->3 becomes ...1->3 - * 3->3->3 becomes 2->3->3 - * 1->1->2 becomes ......1 - * 2->1->1 becomes 1->1->1 - * 1->1->1 becomes ....... - * - */ -u8_t -pbuf_free(struct pbuf *p) -{ - u16_t type; - struct pbuf *q; - u8_t count; - - if (p == NULL) { - LWIP_ASSERT("p != NULL", p != NULL); - /* if assertions are disabled, proceed with debug output */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("pbuf_free(p == NULL) was called.\n")); - return 0; - } - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); - - PERF_START; - - LWIP_ASSERT("pbuf_free: sane type", - p->type == PBUF_RAM || p->type == PBUF_ROM || - p->type == PBUF_REF || p->type == PBUF_POOL); - - count = 0; - /* de-allocate all consecutive pbufs from the head of the chain that - * obtain a zero reference count after decrementing*/ - while (p != NULL) { - u16_t ref; - SYS_ARCH_DECL_PROTECT(old_level); - /* Since decrementing ref cannot be guaranteed to be a single machine operation - * we must protect it. We put the new ref into a local variable to prevent - * further protection. */ - SYS_ARCH_PROTECT(old_level); - /* all pbufs in a chain are referenced at least once */ - LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); - /* decrease reference count (number of pointers to pbuf) */ - ref = --(p->ref); - SYS_ARCH_UNPROTECT(old_level); - /* this pbuf is no longer referenced to? */ - if (ref == 0) { - /* remember next pbuf in chain for next iteration */ - q = p->next; - LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: deallocating %p\n", (void *)p)); - type = p->type; -#if LWIP_SUPPORT_CUSTOM_PBUF - /* is this a custom pbuf? */ - if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { - struct pbuf_custom *pc = (struct pbuf_custom*)p; - LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL); - pc->custom_free_function(p); - } else -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - { - /* is this a pbuf from the pool? */ - if (type == PBUF_POOL) { - memp_free(MEMP_PBUF_POOL, p); - /* is this a ROM or RAM referencing pbuf? */ - } else if (type == PBUF_ROM || type == PBUF_REF) { - memp_free(MEMP_PBUF, p); - /* type == PBUF_RAM */ - } else { - mem_free(p); - } - } - count++; - /* proceed to next pbuf */ - p = q; - /* p->ref > 0, this pbuf is still referenced to */ - /* (and so the remaining pbufs in chain as well) */ - } else { - LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref)); - /* stop walking through the chain */ - p = NULL; - } - } - PERF_STOP("pbuf_free"); - /* return number of de-allocated pbufs */ - return count; -} - -/** - * Count number of pbufs in a chain - * - * @param p first pbuf of chain - * @return the number of pbufs in a chain - */ - -u8_t -pbuf_clen(struct pbuf *p) -{ - u8_t len; - - len = 0; - while (p != NULL) { - ++len; - p = p->next; - } - return len; -} - -/** - * Increment the reference count of the pbuf. - * - * @param p pbuf to increase reference counter of - * - */ -void -pbuf_ref(struct pbuf *p) -{ - SYS_ARCH_DECL_PROTECT(old_level); - /* pbuf given? */ - if (p != NULL) { - SYS_ARCH_PROTECT(old_level); - ++(p->ref); - SYS_ARCH_UNPROTECT(old_level); - } -} - -/** - * Concatenate two pbufs (each may be a pbuf chain) and take over - * the caller's reference of the tail pbuf. - * - * @note The caller MAY NOT reference the tail pbuf afterwards. - * Use pbuf_chain() for that purpose. - * - * @see pbuf_chain() - */ - -void -pbuf_cat(struct pbuf *h, struct pbuf *t) -{ - struct pbuf *p; - - LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)", - ((h != NULL) && (t != NULL)), return;); - - /* proceed to last pbuf of chain */ - for (p = h; p->next != NULL; p = p->next) { - /* add total length of second chain to all totals of first chain */ - p->tot_len += t->tot_len; - } - /* { p is last pbuf of first h chain, p->next == NULL } */ - LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); - LWIP_ASSERT("p->next == NULL", p->next == NULL); - /* add total length of second chain to last pbuf total of first chain */ - p->tot_len += t->tot_len; - /* chain last pbuf of head (p) with first of tail (t) */ - p->next = t; - /* p->next now references t, but the caller will drop its reference to t, - * so netto there is no change to the reference count of t. - */ -} - -/** - * Chain two pbufs (or pbuf chains) together. - * - * The caller MUST call pbuf_free(t) once it has stopped - * using it. Use pbuf_cat() instead if you no longer use t. - * - * @param h head pbuf (chain) - * @param t tail pbuf (chain) - * @note The pbufs MUST belong to the same packet. - * @note MAY NOT be called on a packet queue. - * - * The ->tot_len fields of all pbufs of the head chain are adjusted. - * The ->next field of the last pbuf of the head chain is adjusted. - * The ->ref field of the first pbuf of the tail chain is adjusted. - * - */ -void -pbuf_chain(struct pbuf *h, struct pbuf *t) -{ - pbuf_cat(h, t); - /* t is now referenced by h */ - pbuf_ref(t); - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t)); -} - -/** - * Dechains the first pbuf from its succeeding pbufs in the chain. - * - * Makes p->tot_len field equal to p->len. - * @param p pbuf to dechain - * @return remainder of the pbuf chain, or NULL if it was de-allocated. - * @note May not be called on a packet queue. - */ -struct pbuf * -pbuf_dechain(struct pbuf *p) -{ - struct pbuf *q; - u8_t tail_gone = 1; - /* tail */ - q = p->next; - /* pbuf has successor in chain? */ - if (q != NULL) { - /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ - LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); - /* enforce invariant if assertion is disabled */ - q->tot_len = p->tot_len - p->len; - /* decouple pbuf from remainder */ - p->next = NULL; - /* total length of pbuf p is its own length only */ - p->tot_len = p->len; - /* q is no longer referenced by p, free it */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_dechain: unreferencing %p\n", (void *)q)); - tail_gone = pbuf_free(q); - if (tail_gone > 0) { - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, - ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q)); - } - /* return remaining tail or NULL if deallocated */ - } - /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ - LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); - return ((tail_gone > 0) ? NULL : q); -} - -/** - * - * Create PBUF_RAM copies of pbufs. - * - * Used to queue packets on behalf of the lwIP stack, such as - * ARP based queueing. - * - * @note You MUST explicitly use p = pbuf_take(p); - * - * @note Only one packet is copied, no packet queue! - * - * @param p_to pbuf destination of the copy - * @param p_from pbuf source of the copy - * - * @return ERR_OK if pbuf was copied - * ERR_ARG if one of the pbufs is NULL or p_to is not big - * enough to hold p_from - */ -err_t -pbuf_copy(struct pbuf *p_to, struct pbuf *p_from) -{ - u16_t offset_to=0, offset_from=0, len; - - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n", - (void*)p_to, (void*)p_from)); - - /* is the target big enough to hold the source? */ - LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) && - (p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;); - - /* iterate through pbuf chain */ - do - { - /* copy one part of the original chain */ - if ((p_to->len - offset_to) >= (p_from->len - offset_from)) { - /* complete current p_from fits into current p_to */ - len = p_from->len - offset_from; - } else { - /* current p_from does not fit into current p_to */ - len = p_to->len - offset_to; - } - MEMCPY((u8_t*)p_to->payload + offset_to, (u8_t*)p_from->payload + offset_from, len); - offset_to += len; - offset_from += len; - LWIP_ASSERT("offset_to <= p_to->len", offset_to <= p_to->len); - LWIP_ASSERT("offset_from <= p_from->len", offset_from <= p_from->len); - if (offset_from >= p_from->len) { - /* on to next p_from (if any) */ - offset_from = 0; - p_from = p_from->next; - } - if (offset_to == p_to->len) { - /* on to next p_to (if any) */ - offset_to = 0; - p_to = p_to->next; - LWIP_ERROR("p_to != NULL", (p_to != NULL) || (p_from == NULL) , return ERR_ARG;); - } - - if((p_from != NULL) && (p_from->len == p_from->tot_len)) { - /* don't copy more than one packet! */ - LWIP_ERROR("pbuf_copy() does not allow packet queues!\n", - (p_from->next == NULL), return ERR_VAL;); - } - if((p_to != NULL) && (p_to->len == p_to->tot_len)) { - /* don't copy more than one packet! */ - LWIP_ERROR("pbuf_copy() does not allow packet queues!\n", - (p_to->next == NULL), return ERR_VAL;); - } - } while (p_from); - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy: end of chain reached.\n")); - return ERR_OK; -} - -/** - * Copy (part of) the contents of a packet buffer - * to an application supplied buffer. - * - * @param buf the pbuf from which to copy data - * @param dataptr the application supplied buffer - * @param len length of data to copy (dataptr must be big enough). No more - * than buf->tot_len will be copied, irrespective of len - * @param offset offset into the packet buffer from where to begin copying len bytes - * @return the number of bytes copied, or 0 on failure - */ -u16_t -pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset) -{ - struct pbuf *p; - u16_t left; - u16_t buf_copy_len; - u16_t copied_total = 0; - - LWIP_ERROR("pbuf_copy_partial: invalid buf", (buf != NULL), return 0;); - LWIP_ERROR("pbuf_copy_partial: invalid dataptr", (dataptr != NULL), return 0;); - - left = 0; - - if((buf == NULL) || (dataptr == NULL)) { - return 0; - } - - /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */ - for(p = buf; len != 0 && p != NULL; p = p->next) { - if ((offset != 0) && (offset >= p->len)) { - /* don't copy from this buffer -> on to the next */ - offset -= p->len; - } else { - /* copy from this buffer. maybe only partially. */ - buf_copy_len = p->len - offset; - if (buf_copy_len > len) - buf_copy_len = len; - /* copy the necessary parts of the buffer */ - MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len); - copied_total += buf_copy_len; - left += buf_copy_len; - len -= buf_copy_len; - offset = 0; - } - } - return copied_total; -} - -/** - * Copy application supplied data into a pbuf. - * This function can only be used to copy the equivalent of buf->tot_len data. - * - * @param buf pbuf to fill with data - * @param dataptr application supplied data buffer - * @param len length of the application supplied data buffer - * - * @return ERR_OK if successful, ERR_MEM if the pbuf is not big enough - */ -err_t -pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len) -{ - struct pbuf *p; - u16_t buf_copy_len; - u16_t total_copy_len = len; - u16_t copied_total = 0; - - LWIP_ERROR("pbuf_take: invalid buf", (buf != NULL), return 0;); - LWIP_ERROR("pbuf_take: invalid dataptr", (dataptr != NULL), return 0;); - - if ((buf == NULL) || (dataptr == NULL) || (buf->tot_len < len)) { - return ERR_ARG; - } - - /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */ - for(p = buf; total_copy_len != 0; p = p->next) { - LWIP_ASSERT("pbuf_take: invalid pbuf", p != NULL); - buf_copy_len = total_copy_len; - if (buf_copy_len > p->len) { - /* this pbuf cannot hold all remaining data */ - buf_copy_len = p->len; - } - /* copy the necessary parts of the buffer */ - MEMCPY(p->payload, &((char*)dataptr)[copied_total], buf_copy_len); - total_copy_len -= buf_copy_len; - copied_total += buf_copy_len; - } - LWIP_ASSERT("did not copy all data", total_copy_len == 0 && copied_total == len); - return ERR_OK; -} - -/** - * Creates a single pbuf out of a queue of pbufs. - * - * @remark: Either the source pbuf 'p' is freed by this function or the original - * pbuf 'p' is returned, therefore the caller has to check the result! - * - * @param p the source pbuf - * @param layer pbuf_layer of the new pbuf - * - * @return a new, single pbuf (p->next is NULL) - * or the old pbuf if allocation fails - */ -struct pbuf* -pbuf_coalesce(struct pbuf *p, pbuf_layer layer) -{ - struct pbuf *q; - err_t err; - if (p->next == NULL) { - return p; - } - q = pbuf_alloc(layer, p->tot_len, PBUF_RAM); - if (q == NULL) { - /* @todo: what do we do now? */ - return p; - } - err = pbuf_copy(q, p); - LWIP_ASSERT("pbuf_copy failed", err == ERR_OK); - pbuf_free(p); - return q; -} - -#if LWIP_CHECKSUM_ON_COPY -/** - * Copies data into a single pbuf (*not* into a pbuf queue!) and updates - * the checksum while copying - * - * @param p the pbuf to copy data into - * @param start_offset offset of p->payload where to copy the data to - * @param dataptr data to copy into the pbuf - * @param len length of data to copy into the pbuf - * @param chksum pointer to the checksum which is updated - * @return ERR_OK if successful, another error if the data does not fit - * within the (first) pbuf (no pbuf queues!) - */ -err_t -pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, - u16_t len, u16_t *chksum) -{ - u32_t acc; - u16_t copy_chksum; - char *dst_ptr; - LWIP_ASSERT("p != NULL", p != NULL); - LWIP_ASSERT("dataptr != NULL", dataptr != NULL); - LWIP_ASSERT("chksum != NULL", chksum != NULL); - LWIP_ASSERT("len != 0", len != 0); - - if ((start_offset >= p->len) || (start_offset + len > p->len)) { - return ERR_ARG; - } - - dst_ptr = ((char*)p->payload) + start_offset; - copy_chksum = LWIP_CHKSUM_COPY(dst_ptr, dataptr, len); - if ((start_offset & 1) != 0) { - copy_chksum = SWAP_BYTES_IN_WORD(copy_chksum); - } - acc = *chksum; - acc += copy_chksum; - *chksum = FOLD_U32T(acc); - return ERR_OK; -} -#endif /* LWIP_CHECKSUM_ON_COPY */ - - /** Get one byte from the specified position in a pbuf - * WARNING: returns zero for offset >= p->tot_len - * - * @param p pbuf to parse - * @param offset offset into p of the byte to return - * @return byte at an offset into p OR ZERO IF 'offset' >= p->tot_len - */ -u8_t -pbuf_get_at(struct pbuf* p, u16_t offset) -{ - u16_t copy_from = offset; - struct pbuf* q = p; - - /* get the correct pbuf */ - while ((q != NULL) && (q->len <= copy_from)) { - copy_from -= q->len; - q = q->next; - } - /* return requested data if pbuf is OK */ - if ((q != NULL) && (q->len > copy_from)) { - return ((u8_t*)q->payload)[copy_from]; - } - return 0; -} - -/** Compare pbuf contents at specified offset with memory s2, both of length n - * - * @param p pbuf to compare - * @param offset offset into p at wich to start comparing - * @param s2 buffer to compare - * @param n length of buffer to compare - * @return zero if equal, nonzero otherwise - * (0xffff if p is too short, diffoffset+1 otherwise) - */ -u16_t -pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n) -{ - u16_t start = offset; - struct pbuf* q = p; - - /* get the correct pbuf */ - while ((q != NULL) && (q->len <= start)) { - start -= q->len; - q = q->next; - } - /* return requested data if pbuf is OK */ - if ((q != NULL) && (q->len > start)) { - u16_t i; - for(i = 0; i < n; i++) { - u8_t a = pbuf_get_at(q, start + i); - u8_t b = ((u8_t*)s2)[i]; - if (a != b) { - return i+1; - } - } - return 0; - } - return 0xffff; -} - -/** Find occurrence of mem (with length mem_len) in pbuf p, starting at offset - * start_offset. - * - * @param p pbuf to search, maximum length is 0xFFFE since 0xFFFF is used as - * return value 'not found' - * @param mem search for the contents of this buffer - * @param mem_len length of 'mem' - * @param start_offset offset into p at which to start searching - * @return 0xFFFF if substr was not found in p or the index where it was found - */ -u16_t -pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset) -{ - u16_t i; - u16_t max = p->tot_len - mem_len; - if (p->tot_len >= mem_len + start_offset) { - for(i = start_offset; i <= max; ) { - u16_t plus = pbuf_memcmp(p, i, mem, mem_len); - if (plus == 0) { - return i; - } else { - i += plus; - } - } - } - return 0xFFFF; -} - -/** Find occurrence of substr with length substr_len in pbuf p, start at offset - * start_offset - * WARNING: in contrast to strstr(), this one does not stop at the first \0 in - * the pbuf/source string! - * - * @param p pbuf to search, maximum length is 0xFFFE since 0xFFFF is used as - * return value 'not found' - * @param substr string to search for in p, maximum length is 0xFFFE - * @return 0xFFFF if substr was not found in p or the index where it was found - */ -u16_t -pbuf_strstr(struct pbuf* p, const char* substr) -{ - size_t substr_len; - if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { - return 0xFFFF; - } - substr_len = strlen(substr); - if (substr_len >= 0xFFFF) { - return 0xFFFF; - } - return pbuf_memfind(p, substr, (u16_t)substr_len, 0); -} diff --git a/user/mpy/lib/lwip/src/core/raw.c b/user/mpy/lib/lwip/src/core/raw.c deleted file mode 100644 index 7160c0f..0000000 --- a/user/mpy/lib/lwip/src/core/raw.c +++ /dev/null @@ -1,350 +0,0 @@ -/** - * @file - * Implementation of raw protocol PCBs for low-level handling of - * different types of protocols besides (or overriding) those - * already available in lwIP. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/memp.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/raw.h" -#include "lwip/stats.h" -#include "arch/perf.h" - -#include - -/** The list of RAW PCBs */ -static struct raw_pcb *raw_pcbs; - -/** - * Determine if in incoming IP packet is covered by a RAW PCB - * and if so, pass it to a user-provided receive callback function. - * - * Given an incoming IP datagram (as a chain of pbufs) this function - * finds a corresponding RAW PCB and calls the corresponding receive - * callback function. - * - * @param p pbuf to be demultiplexed to a RAW PCB. - * @param inp network interface on which the datagram was received. - * @return - 1 if the packet has been eaten by a RAW PCB receive - * callback function. The caller MAY NOT not reference the - * packet any longer, and MAY NOT call pbuf_free(). - * @return - 0 if packet is not eaten (pbuf is still referenced by the - * caller). - * - */ -u8_t -raw_input(struct pbuf *p, struct netif *inp) -{ - struct raw_pcb *pcb, *prev; - struct ip_hdr *iphdr; - s16_t proto; - u8_t eaten = 0; - - LWIP_UNUSED_ARG(inp); - - iphdr = (struct ip_hdr *)p->payload; - proto = IPH_PROTO(iphdr); - - prev = NULL; - pcb = raw_pcbs; - /* loop through all raw pcbs until the packet is eaten by one */ - /* this allows multiple pcbs to match against the packet by design */ - while ((eaten == 0) && (pcb != NULL)) { - if ((pcb->protocol == proto) && - (ip_addr_isany(&pcb->local_ip) || - ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest))) { -#if IP_SOF_BROADCAST_RECV - /* broadcast filter? */ - if (ip_get_option(pcb, SOF_BROADCAST) || !ip_addr_isbroadcast(¤t_iphdr_dest, inp)) -#endif /* IP_SOF_BROADCAST_RECV */ - { - /* receive callback function available? */ - if (pcb->recv != NULL) { - /* the receive callback function did not eat the packet? */ - if (pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr()) != 0) { - /* receive function ate the packet */ - p = NULL; - eaten = 1; - if (prev != NULL) { - /* move the pcb to the front of raw_pcbs so that is - found faster next time */ - prev->next = pcb->next; - pcb->next = raw_pcbs; - raw_pcbs = pcb; - } - } - } - /* no receive callback function was set for this raw PCB */ - } - /* drop the packet */ - } - prev = pcb; - pcb = pcb->next; - } - return eaten; -} - -/** - * Bind a RAW PCB. - * - * @param pcb RAW PCB to be bound with a local address ipaddr. - * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to - * bind to all local interfaces. - * - * @return lwIP error code. - * - ERR_OK. Successful. No error occured. - * - ERR_USE. The specified IP address is already bound to by - * another RAW PCB. - * - * @see raw_disconnect() - */ -err_t -raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr) -{ - ip_addr_set(&pcb->local_ip, ipaddr); - return ERR_OK; -} - -/** - * Connect an RAW PCB. This function is required by upper layers - * of lwip. Using the raw api you could use raw_sendto() instead - * - * This will associate the RAW PCB with the remote address. - * - * @param pcb RAW PCB to be connected with remote address ipaddr and port. - * @param ipaddr remote IP address to connect with. - * - * @return lwIP error code - * - * @see raw_disconnect() and raw_sendto() - */ -err_t -raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr) -{ - ip_addr_set(&pcb->remote_ip, ipaddr); - return ERR_OK; -} - - -/** - * Set the callback function for received packets that match the - * raw PCB's protocol and binding. - * - * The callback function MUST either - * - eat the packet by calling pbuf_free() and returning non-zero. The - * packet will not be passed to other raw PCBs or other protocol layers. - * - not free the packet, and return zero. The packet will be matched - * against further PCBs and/or forwarded to another protocol layers. - * - * @return non-zero if the packet was free()d, zero if the packet remains - * available for others. - */ -void -raw_recv(struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg) -{ - /* remember recv() callback and user data */ - pcb->recv = recv; - pcb->recv_arg = recv_arg; -} - -/** - * Send the raw IP packet to the given address. Note that actually you cannot - * modify the IP headers (this is inconsistent with the receive callback where - * you actually get the IP headers), you can only specify the IP payload here. - * It requires some more changes in lwIP. (there will be a raw_send() function - * then.) - * - * @param pcb the raw pcb which to send - * @param p the IP payload to send - * @param ipaddr the destination address of the IP packet - * - */ -err_t -raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr) -{ - err_t err; - struct netif *netif; - ip_addr_t *src_ip; - struct pbuf *q; /* q will be sent down the stack */ - - LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n")); - - /* not enough space to add an IP header to first pbuf in given p chain? */ - if (pbuf_header(p, IP_HLEN)) { - /* allocate header in new pbuf */ - q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM); - /* new header pbuf could not be allocated? */ - if (q == NULL) { - LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("raw_sendto: could not allocate header\n")); - return ERR_MEM; - } - if (p->tot_len != 0) { - /* chain header q in front of given pbuf p */ - pbuf_chain(q, p); - } - /* { first pbuf q points to header pbuf } */ - LWIP_DEBUGF(RAW_DEBUG, ("raw_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); - } else { - /* first pbuf q equals given pbuf */ - q = p; - if(pbuf_header(q, -IP_HLEN)) { - LWIP_ASSERT("Can't restore header we just removed!", 0); - return ERR_MEM; - } - } - - if ((netif = ip_route(ipaddr)) == NULL) { - LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr))); - /* free any temporary header pbuf allocated by pbuf_header() */ - if (q != p) { - pbuf_free(q); - } - return ERR_RTE; - } - -#if IP_SOF_BROADCAST - /* broadcast filter? */ - if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(ipaddr, netif)) { - LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); - /* free any temporary header pbuf allocated by pbuf_header() */ - if (q != p) { - pbuf_free(q); - } - return ERR_VAL; - } -#endif /* IP_SOF_BROADCAST */ - - if (ip_addr_isany(&pcb->local_ip)) { - /* use outgoing network interface IP address as source address */ - src_ip = &(netif->ip_addr); - } else { - /* use RAW PCB local IP address as source address */ - src_ip = &(pcb->local_ip); - } - - NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint); - err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - - /* did we chain a header earlier? */ - if (q != p) { - /* free the header */ - pbuf_free(q); - } - return err; -} - -/** - * Send the raw IP packet to the address given by raw_connect() - * - * @param pcb the raw pcb which to send - * @param p the IP payload to send - * - */ -err_t -raw_send(struct raw_pcb *pcb, struct pbuf *p) -{ - return raw_sendto(pcb, p, &pcb->remote_ip); -} - -/** - * Remove an RAW PCB. - * - * @param pcb RAW PCB to be removed. The PCB is removed from the list of - * RAW PCB's and the data structure is freed from memory. - * - * @see raw_new() - */ -void -raw_remove(struct raw_pcb *pcb) -{ - struct raw_pcb *pcb2; - /* pcb to be removed is first in list? */ - if (raw_pcbs == pcb) { - /* make list start at 2nd pcb */ - raw_pcbs = raw_pcbs->next; - /* pcb not 1st in list */ - } else { - for(pcb2 = raw_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { - /* find pcb in raw_pcbs list */ - if (pcb2->next != NULL && pcb2->next == pcb) { - /* remove pcb from list */ - pcb2->next = pcb->next; - } - } - } - memp_free(MEMP_RAW_PCB, pcb); -} - -/** - * Create a RAW PCB. - * - * @return The RAW PCB which was created. NULL if the PCB data structure - * could not be allocated. - * - * @param proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP) - * - * @see raw_remove() - */ -struct raw_pcb * -raw_new(u8_t proto) -{ - struct raw_pcb *pcb; - - LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_new\n")); - - pcb = (struct raw_pcb *)memp_malloc(MEMP_RAW_PCB); - /* could allocate RAW PCB? */ - if (pcb != NULL) { - /* initialize PCB to all zeroes */ - memset(pcb, 0, sizeof(struct raw_pcb)); - pcb->protocol = proto; - pcb->ttl = RAW_TTL; - pcb->next = raw_pcbs; - raw_pcbs = pcb; - } - return pcb; -} - -#endif /* LWIP_RAW */ diff --git a/user/mpy/lib/lwip/src/core/snmp/asn1_dec.c b/user/mpy/lib/lwip/src/core/snmp/asn1_dec.c deleted file mode 100644 index 1d56582..0000000 --- a/user/mpy/lib/lwip/src/core/snmp/asn1_dec.c +++ /dev/null @@ -1,657 +0,0 @@ -/** - * @file - * Abstract Syntax Notation One (ISO 8824, 8825) decoding - * - * @todo not optimised (yet), favor correctness over speed, favor speed over size - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp_asn1.h" - -/** - * Retrieves type field from incoming pbuf chain. - * - * @param p points to a pbuf holding an ASN1 coded type field - * @param ofs points to the offset within the pbuf chain of the ASN1 coded type field - * @param type return ASN1 type - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode - */ -err_t -snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - *type = *msg_ptr; - return ERR_OK; - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Decodes length field from incoming pbuf chain into host length. - * - * @param p points to a pbuf holding an ASN1 coded length - * @param ofs points to the offset within the pbuf chain of the ASN1 coded length - * @param octets_used returns number of octets used by the length code - * @param length return host order length, upto 64k - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode - */ -err_t -snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - if (*msg_ptr < 0x80) - { - /* primitive definite length format */ - *octets_used = 1; - *length = *msg_ptr; - return ERR_OK; - } - else if (*msg_ptr == 0x80) - { - /* constructed indefinite length format, termination with two zero octets */ - u8_t zeros; - u8_t i; - - *length = 0; - zeros = 0; - while (zeros != 2) - { - i = 2; - while (i > 0) - { - i--; - (*length) += 1; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - if (*msg_ptr == 0) - { - zeros++; - if (zeros == 2) - { - /* stop while (i > 0) */ - i = 0; - } - } - else - { - zeros = 0; - } - } - } - *octets_used = 1; - return ERR_OK; - } - else if (*msg_ptr == 0x81) - { - /* constructed definite length format, one octet */ - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - *length = *msg_ptr; - *octets_used = 2; - return ERR_OK; - } - else if (*msg_ptr == 0x82) - { - u8_t i; - - /* constructed definite length format, two octets */ - i = 2; - while (i > 0) - { - i--; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - if (i == 0) - { - /* least significant length octet */ - *length |= *msg_ptr; - } - else - { - /* most significant length octet */ - *length = (*msg_ptr) << 8; - } - } - *octets_used = 3; - return ERR_OK; - } - else - { - /* constructed definite length format 3..127 octets, this is too big (>64k) */ - /** @todo: do we need to accept inefficient codings with many leading zero's? */ - *octets_used = 1 + ((*msg_ptr) & 0x7f); - return ERR_ARG; - } - } - p = p->next; - } - - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Decodes positive integer (counter, gauge, timeticks) into u32_t. - * - * @param p points to a pbuf holding an ASN1 coded integer - * @param ofs points to the offset within the pbuf chain of the ASN1 coded integer - * @param len length of the coded integer field - * @param value return host order integer - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode - * - * @note ASN coded integers are _always_ signed. E.g. +0xFFFF is coded - * as 0x00,0xFF,0xFF. Note the leading sign octet. A positive value - * of 0xFFFFFFFF is preceded with 0x00 and the length is 5 octets!! - */ -err_t -snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - if ((len > 0) && (len < 6)) - { - /* start from zero */ - *value = 0; - if (*msg_ptr & 0x80) - { - /* negative, expecting zero sign bit! */ - return ERR_ARG; - } - else - { - /* positive */ - if ((len > 1) && (*msg_ptr == 0)) - { - /* skip leading "sign byte" octet 0x00 */ - len--; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - } - /* OR octets with value */ - while (len > 1) - { - len--; - *value |= *msg_ptr; - *value <<= 8; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - *value |= *msg_ptr; - return ERR_OK; - } - else - { - return ERR_ARG; - } - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Decodes integer into s32_t. - * - * @param p points to a pbuf holding an ASN1 coded integer - * @param ofs points to the offset within the pbuf chain of the ASN1 coded integer - * @param len length of the coded integer field - * @param value return host order integer - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode - * - * @note ASN coded integers are _always_ signed! - */ -err_t -snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value) -{ - u16_t plen, base; - u8_t *msg_ptr; -#if BYTE_ORDER == LITTLE_ENDIAN - u8_t *lsb_ptr = (u8_t*)value; -#endif -#if BYTE_ORDER == BIG_ENDIAN - u8_t *lsb_ptr = (u8_t*)value + sizeof(s32_t) - 1; -#endif - u8_t sign; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - if ((len > 0) && (len < 5)) - { - if (*msg_ptr & 0x80) - { - /* negative, start from -1 */ - *value = -1; - sign = 1; - } - else - { - /* positive, start from 0 */ - *value = 0; - sign = 0; - } - /* OR/AND octets with value */ - while (len > 1) - { - len--; - if (sign) - { - *lsb_ptr &= *msg_ptr; - *value <<= 8; - *lsb_ptr |= 255; - } - else - { - *lsb_ptr |= *msg_ptr; - *value <<= 8; - } - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - if (sign) - { - *lsb_ptr &= *msg_ptr; - } - else - { - *lsb_ptr |= *msg_ptr; - } - return ERR_OK; - } - else - { - return ERR_ARG; - } - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Decodes object identifier from incoming message into array of s32_t. - * - * @param p points to a pbuf holding an ASN1 coded object identifier - * @param ofs points to the offset within the pbuf chain of the ASN1 coded object identifier - * @param len length of the coded object identifier - * @param oid return object identifier struct - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode - */ -err_t -snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid) -{ - u16_t plen, base; - u8_t *msg_ptr; - s32_t *oid_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - oid->len = 0; - oid_ptr = &oid->id[0]; - if (len > 0) - { - /* first compressed octet */ - if (*msg_ptr == 0x2B) - { - /* (most) common case 1.3 (iso.org) */ - *oid_ptr = 1; - oid_ptr++; - *oid_ptr = 3; - oid_ptr++; - } - else if (*msg_ptr < 40) - { - *oid_ptr = 0; - oid_ptr++; - *oid_ptr = *msg_ptr; - oid_ptr++; - } - else if (*msg_ptr < 80) - { - *oid_ptr = 1; - oid_ptr++; - *oid_ptr = (*msg_ptr) - 40; - oid_ptr++; - } - else - { - *oid_ptr = 2; - oid_ptr++; - *oid_ptr = (*msg_ptr) - 80; - oid_ptr++; - } - oid->len = 2; - } - else - { - /* accepting zero length identifiers e.g. for - getnext operation. uncommon but valid */ - return ERR_OK; - } - len--; - if (len > 0) - { - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - while ((len > 0) && (oid->len < LWIP_SNMP_OBJ_ID_LEN)) - { - /* sub-identifier uses multiple octets */ - if (*msg_ptr & 0x80) - { - s32_t sub_id = 0; - - while ((*msg_ptr & 0x80) && (len > 1)) - { - len--; - sub_id = (sub_id << 7) + (*msg_ptr & ~0x80); - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - if (!(*msg_ptr & 0x80) && (len > 0)) - { - /* last octet sub-identifier */ - len--; - sub_id = (sub_id << 7) + *msg_ptr; - *oid_ptr = sub_id; - } - } - else - { - /* !(*msg_ptr & 0x80) sub-identifier uses single octet */ - len--; - *oid_ptr = *msg_ptr; - } - if (len > 0) - { - /* remaining oid bytes available ... */ - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - oid_ptr++; - oid->len++; - } - if (len == 0) - { - /* len == 0, end of oid */ - return ERR_OK; - } - else - { - /* len > 0, oid->len == LWIP_SNMP_OBJ_ID_LEN or malformed encoding */ - return ERR_ARG; - } - - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Decodes (copies) raw data (ip-addresses, octet strings, opaque encoding) - * from incoming message into array. - * - * @param p points to a pbuf holding an ASN1 coded raw data - * @param ofs points to the offset within the pbuf chain of the ASN1 coded raw data - * @param len length of the coded raw data (zero is valid, e.g. empty string!) - * @param raw_len length of the raw return value - * @param raw return raw bytes - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) decode - */ -err_t -snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw) -{ - u16_t plen, base; - u8_t *msg_ptr; - - if (len > 0) - { - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - if (raw_len >= len) - { - while (len > 1) - { - /* copy len - 1 octets */ - len--; - *raw = *msg_ptr; - raw++; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - /* copy last octet */ - *raw = *msg_ptr; - return ERR_OK; - } - else - { - /* raw_len < len, not enough dst space */ - return ERR_ARG; - } - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; - } - else - { - /* len == 0, empty string */ - return ERR_OK; - } -} - -#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/asn1_enc.c b/user/mpy/lib/lwip/src/core/snmp/asn1_enc.c deleted file mode 100644 index 64dfc5f..0000000 --- a/user/mpy/lib/lwip/src/core/snmp/asn1_enc.c +++ /dev/null @@ -1,611 +0,0 @@ -/** - * @file - * Abstract Syntax Notation One (ISO 8824, 8825) encoding - * - * @todo not optimised (yet), favor correctness over speed, favor speed over size - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp_asn1.h" - -/** - * Returns octet count for length. - * - * @param length - * @param octets_needed points to the return value - */ -void -snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed) -{ - if (length < 0x80U) - { - *octets_needed = 1; - } - else if (length < 0x100U) - { - *octets_needed = 2; - } - else - { - *octets_needed = 3; - } -} - -/** - * Returns octet count for an u32_t. - * - * @param value - * @param octets_needed points to the return value - * - * @note ASN coded integers are _always_ signed. E.g. +0xFFFF is coded - * as 0x00,0xFF,0xFF. Note the leading sign octet. A positive value - * of 0xFFFFFFFF is preceded with 0x00 and the length is 5 octets!! - */ -void -snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed) -{ - if (value < 0x80UL) - { - *octets_needed = 1; - } - else if (value < 0x8000UL) - { - *octets_needed = 2; - } - else if (value < 0x800000UL) - { - *octets_needed = 3; - } - else if (value < 0x80000000UL) - { - *octets_needed = 4; - } - else - { - *octets_needed = 5; - } -} - -/** - * Returns octet count for an s32_t. - * - * @param value - * @param octets_needed points to the return value - * - * @note ASN coded integers are _always_ signed. - */ -void -snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed) -{ - if (value < 0) - { - value = ~value; - } - if (value < 0x80L) - { - *octets_needed = 1; - } - else if (value < 0x8000L) - { - *octets_needed = 2; - } - else if (value < 0x800000L) - { - *octets_needed = 3; - } - else - { - *octets_needed = 4; - } -} - -/** - * Returns octet count for an object identifier. - * - * @param ident_len object identifier array length - * @param ident points to object identifier array - * @param octets_needed points to the return value - */ -void -snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed) -{ - s32_t sub_id; - u8_t cnt; - - cnt = 0; - if (ident_len > 1) - { - /* compressed prefix in one octet */ - cnt++; - ident_len -= 2; - ident += 2; - } - while(ident_len > 0) - { - ident_len--; - sub_id = *ident; - - sub_id >>= 7; - cnt++; - while(sub_id > 0) - { - sub_id >>= 7; - cnt++; - } - ident++; - } - *octets_needed = cnt; -} - -/** - * Encodes ASN type field into a pbuf chained ASN1 msg. - * - * @param p points to output pbuf to encode value into - * @param ofs points to the offset within the pbuf chain - * @param type input ASN1 type - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode - */ -err_t -snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - *msg_ptr = type; - return ERR_OK; - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Encodes host order length field into a pbuf chained ASN1 msg. - * - * @param p points to output pbuf to encode length into - * @param ofs points to the offset within the pbuf chain - * @param length is the host order length to be encoded - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode - */ -err_t -snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - if (length < 0x80) - { - *msg_ptr = (u8_t)length; - return ERR_OK; - } - else if (length < 0x100) - { - *msg_ptr = 0x81; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - *msg_ptr = (u8_t)length; - return ERR_OK; - } - else - { - u8_t i; - - /* length >= 0x100 && length <= 0xFFFF */ - *msg_ptr = 0x82; - i = 2; - while (i > 0) - { - i--; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - if (i == 0) - { - /* least significant length octet */ - *msg_ptr = (u8_t)length; - } - else - { - /* most significant length octet */ - *msg_ptr = (u8_t)(length >> 8); - } - } - return ERR_OK; - } - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Encodes u32_t (counter, gauge, timeticks) into a pbuf chained ASN1 msg. - * - * @param p points to output pbuf to encode value into - * @param ofs points to the offset within the pbuf chain - * @param octets_needed encoding length (from snmp_asn1_enc_u32t_cnt()) - * @param value is the host order u32_t value to be encoded - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode - * - * @see snmp_asn1_enc_u32t_cnt() - */ -err_t -snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - if (octets_needed == 5) - { - /* not enough bits in 'value' add leading 0x00 */ - octets_needed--; - *msg_ptr = 0x00; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - while (octets_needed > 1) - { - octets_needed--; - *msg_ptr = (u8_t)(value >> (octets_needed << 3)); - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - /* (only) one least significant octet */ - *msg_ptr = (u8_t)value; - return ERR_OK; - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Encodes s32_t integer into a pbuf chained ASN1 msg. - * - * @param p points to output pbuf to encode value into - * @param ofs points to the offset within the pbuf chain - * @param octets_needed encoding length (from snmp_asn1_enc_s32t_cnt()) - * @param value is the host order s32_t value to be encoded - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode - * - * @see snmp_asn1_enc_s32t_cnt() - */ -err_t -snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - while (octets_needed > 1) - { - octets_needed--; - *msg_ptr = (u8_t)(value >> (octets_needed << 3)); - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - /* (only) one least significant octet */ - *msg_ptr = (u8_t)value; - return ERR_OK; - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Encodes object identifier into a pbuf chained ASN1 msg. - * - * @param p points to output pbuf to encode oid into - * @param ofs points to the offset within the pbuf chain - * @param ident_len object identifier array length - * @param ident points to object identifier array - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode - */ -err_t -snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - if (ident_len > 1) - { - if ((ident[0] == 1) && (ident[1] == 3)) - { - /* compressed (most common) prefix .iso.org */ - *msg_ptr = 0x2b; - } - else - { - /* calculate prefix */ - *msg_ptr = (u8_t)((ident[0] * 40) + ident[1]); - } - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - ident_len -= 2; - ident += 2; - } - else - { -/* @bug: allow empty varbinds for symmetry (we must decode them for getnext), allow partial compression?? */ - /* ident_len <= 1, at least we need zeroDotZero (0.0) (ident_len == 2) */ - return ERR_ARG; - } - while (ident_len > 0) - { - s32_t sub_id; - u8_t shift, tail; - - ident_len--; - sub_id = *ident; - tail = 0; - shift = 28; - while(shift > 0) - { - u8_t code; - - code = (u8_t)(sub_id >> shift); - if ((code != 0) || (tail != 0)) - { - tail = 1; - *msg_ptr = code | 0x80; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - shift -= 7; - } - *msg_ptr = (u8_t)sub_id & 0x7F; - if (ident_len > 0) - { - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - /* proceed to next sub-identifier */ - ident++; - } - return ERR_OK; - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -/** - * Encodes raw data (octet string, opaque) into a pbuf chained ASN1 msg. - * - * @param p points to output pbuf to encode raw data into - * @param ofs points to the offset within the pbuf chain - * @param raw_len raw data length - * @param raw points raw data - * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode - */ -err_t -snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw) -{ - u16_t plen, base; - u8_t *msg_ptr; - - plen = 0; - while (p != NULL) - { - base = plen; - plen += p->len; - if (ofs < plen) - { - msg_ptr = (u8_t*)p->payload; - msg_ptr += ofs - base; - - while (raw_len > 1) - { - /* copy raw_len - 1 octets */ - raw_len--; - *msg_ptr = *raw; - raw++; - ofs += 1; - if (ofs >= plen) - { - /* next octet in next pbuf */ - p = p->next; - if (p == NULL) { return ERR_ARG; } - msg_ptr = (u8_t*)p->payload; - plen += p->len; - } - else - { - /* next octet in same pbuf */ - msg_ptr++; - } - } - if (raw_len > 0) - { - /* copy last or single octet */ - *msg_ptr = *raw; - } - return ERR_OK; - } - p = p->next; - } - /* p == NULL, ofs >= plen */ - return ERR_ARG; -} - -#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/mib2.c b/user/mpy/lib/lwip/src/core/snmp/mib2.c deleted file mode 100644 index 4775ba9..0000000 --- a/user/mpy/lib/lwip/src/core/snmp/mib2.c +++ /dev/null @@ -1,4146 +0,0 @@ -/** - * @file - * Management Information Base II (RFC1213) objects and functions. - * - * @note the object identifiers for this MIB-2 and private MIB tree - * must be kept in sorted ascending order. This to ensure correct getnext operation. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp.h" -#include "lwip/netif.h" -#include "lwip/ip.h" -#include "lwip/ip_frag.h" -#include "lwip/mem.h" -#include "lwip/tcp_impl.h" -#include "lwip/udp.h" -#include "lwip/snmp_asn1.h" -#include "lwip/snmp_structs.h" -#include "lwip/sys.h" -#include "netif/etharp.h" - -/** - * IANA assigned enterprise ID for lwIP is 26381 - * @see http://www.iana.org/assignments/enterprise-numbers - * - * @note this enterprise ID is assigned to the lwIP project, - * all object identifiers living under this ID are assigned - * by the lwIP maintainers (contact Christiaan Simons)! - * @note don't change this define, use snmp_set_sysobjid() - * - * If you need to create your own private MIB you'll need - * to apply for your own enterprise ID with IANA: - * http://www.iana.org/numbers.html - */ -#define SNMP_ENTERPRISE_ID 26381 -#define SNMP_SYSOBJID_LEN 7 -#define SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, SNMP_ENTERPRISE_ID} - -#ifndef SNMP_SYSSERVICES -#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) -#endif - -#ifndef SNMP_GET_SYSUPTIME -#define SNMP_GET_SYSUPTIME(sysuptime) (sysuptime = (sys_now() / 10)) -#endif - -static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void system_get_value(struct obj_def *od, u16_t len, void *value); -static u8_t system_set_test(struct obj_def *od, u16_t len, void *value); -static void system_set_value(struct obj_def *od, u16_t len, void *value); -static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void interfaces_get_value(struct obj_def *od, u16_t len, void *value); -static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void ifentry_get_value(struct obj_def *od, u16_t len, void *value); -#if !SNMP_SAFE_REQUESTS -static u8_t ifentry_set_test (struct obj_def *od, u16_t len, void *value); -static void ifentry_set_value (struct obj_def *od, u16_t len, void *value); -#endif /* SNMP_SAFE_REQUESTS */ -static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void atentry_get_value(struct obj_def *od, u16_t len, void *value); -static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void ip_get_value(struct obj_def *od, u16_t len, void *value); -static u8_t ip_set_test(struct obj_def *od, u16_t len, void *value); -static void ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value); -static void ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value); -static void ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value); -static void icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void icmp_get_value(struct obj_def *od, u16_t len, void *value); -#if LWIP_TCP -static void tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void tcp_get_value(struct obj_def *od, u16_t len, void *value); -#ifdef THIS_SEEMS_UNUSED -static void tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value); -#endif -#endif -static void udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void udp_get_value(struct obj_def *od, u16_t len, void *value); -static void udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void udpentry_get_value(struct obj_def *od, u16_t len, void *value); -static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -static void snmp_get_value(struct obj_def *od, u16_t len, void *value); -static u8_t snmp_set_test(struct obj_def *od, u16_t len, void *value); -static void snmp_set_value(struct obj_def *od, u16_t len, void *value); - - -/* snmp .1.3.6.1.2.1.11 */ -const mib_scalar_node snmp_scalar = { - &snmp_get_object_def, - &snmp_get_value, - &snmp_set_test, - &snmp_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t snmp_ids[28] = { - 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30 -}; -struct mib_node* const snmp_nodes[28] = { - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar, - (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar -}; -const struct mib_array_node snmp = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 28, - snmp_ids, - snmp_nodes -}; - -/* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */ -/* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */ -/* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */ - -/* udp .1.3.6.1.2.1.7 */ -/** index root node for udpTable */ -struct mib_list_rootnode udp_root = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t udpentry_ids[2] = { 1, 2 }; -struct mib_node* const udpentry_nodes[2] = { - (struct mib_node*)&udp_root, (struct mib_node*)&udp_root, -}; -const struct mib_array_node udpentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 2, - udpentry_ids, - udpentry_nodes -}; - -s32_t udptable_id = 1; -struct mib_node* udptable_node = (struct mib_node*)&udpentry; -struct mib_ram_array_node udptable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, - 0, - &udptable_id, - &udptable_node -}; - -const mib_scalar_node udp_scalar = { - &udp_get_object_def, - &udp_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 }; -struct mib_node* const udp_nodes[5] = { - (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar, - (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar, - (struct mib_node*)&udptable -}; -const struct mib_array_node udp = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 5, - udp_ids, - udp_nodes -}; - -/* tcp .1.3.6.1.2.1.6 */ -#if LWIP_TCP -/* only if the TCP protocol is available may implement this group */ -/** index root node for tcpConnTable */ -struct mib_list_rootnode tcpconntree_root = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 }; -struct mib_node* const tcpconnentry_nodes[5] = { - (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root, - (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root, - (struct mib_node*)&tcpconntree_root -}; -const struct mib_array_node tcpconnentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 5, - tcpconnentry_ids, - tcpconnentry_nodes -}; - -s32_t tcpconntable_id = 1; -struct mib_node* tcpconntable_node = (struct mib_node*)&tcpconnentry; -struct mib_ram_array_node tcpconntable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, -/** @todo update maxlength when inserting / deleting from table - 0 when table is empty, 1 when more than one entry */ - 0, - &tcpconntable_id, - &tcpconntable_node -}; - -const mib_scalar_node tcp_scalar = { - &tcp_get_object_def, - &tcp_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; -struct mib_node* const tcp_nodes[15] = { - (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcpconntable, (struct mib_node*)&tcp_scalar, - (struct mib_node*)&tcp_scalar -}; -const struct mib_array_node tcp = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 15, - tcp_ids, - tcp_nodes -}; -#endif - -/* icmp .1.3.6.1.2.1.5 */ -const mib_scalar_node icmp_scalar = { - &icmp_get_object_def, - &icmp_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }; -struct mib_node* const icmp_nodes[26] = { - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar, - (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar -}; -const struct mib_array_node icmp = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 26, - icmp_ids, - icmp_nodes -}; - -/** index root node for ipNetToMediaTable */ -struct mib_list_rootnode ipntomtree_root = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 }; -struct mib_node* const ipntomentry_nodes[4] = { - (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root, - (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root -}; -const struct mib_array_node ipntomentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 4, - ipntomentry_ids, - ipntomentry_nodes -}; - -s32_t ipntomtable_id = 1; -struct mib_node* ipntomtable_node = (struct mib_node*)&ipntomentry; -struct mib_ram_array_node ipntomtable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, - 0, - &ipntomtable_id, - &ipntomtable_node -}; - -/** index root node for ipRouteTable */ -struct mib_list_rootnode iprtetree_root = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; -struct mib_node* const iprteentry_nodes[13] = { - (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, - (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, - (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, - (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, - (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, - (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root, - (struct mib_node*)&iprtetree_root -}; -const struct mib_array_node iprteentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 13, - iprteentry_ids, - iprteentry_nodes -}; - -s32_t iprtetable_id = 1; -struct mib_node* iprtetable_node = (struct mib_node*)&iprteentry; -struct mib_ram_array_node iprtetable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, - 0, - &iprtetable_id, - &iprtetable_node -}; - -/** index root node for ipAddrTable */ -struct mib_list_rootnode ipaddrtree_root = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 }; -struct mib_node* const ipaddrentry_nodes[5] = { - (struct mib_node*)&ipaddrtree_root, - (struct mib_node*)&ipaddrtree_root, - (struct mib_node*)&ipaddrtree_root, - (struct mib_node*)&ipaddrtree_root, - (struct mib_node*)&ipaddrtree_root -}; -const struct mib_array_node ipaddrentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 5, - ipaddrentry_ids, - ipaddrentry_nodes -}; - -s32_t ipaddrtable_id = 1; -struct mib_node* ipaddrtable_node = (struct mib_node*)&ipaddrentry; -struct mib_ram_array_node ipaddrtable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, - 0, - &ipaddrtable_id, - &ipaddrtable_node -}; - -/* ip .1.3.6.1.2.1.4 */ -const mib_scalar_node ip_scalar = { - &ip_get_object_def, - &ip_get_value, - &ip_set_test, - &noleafs_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; -struct mib_node* const ip_nodes[23] = { - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar, - (struct mib_node*)&ip_scalar, (struct mib_node*)&ipaddrtable, - (struct mib_node*)&iprtetable, (struct mib_node*)&ipntomtable, - (struct mib_node*)&ip_scalar -}; -const struct mib_array_node mib2_ip = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 23, - ip_ids, - ip_nodes -}; - -/** index root node for atTable */ -struct mib_list_rootnode arptree_root = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t atentry_ids[3] = { 1, 2, 3 }; -struct mib_node* const atentry_nodes[3] = { - (struct mib_node*)&arptree_root, - (struct mib_node*)&arptree_root, - (struct mib_node*)&arptree_root -}; -const struct mib_array_node atentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 3, - atentry_ids, - atentry_nodes -}; - -const s32_t attable_id = 1; -struct mib_node* const attable_node = (struct mib_node*)&atentry; -const struct mib_array_node attable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 1, - &attable_id, - &attable_node -}; - -/* at .1.3.6.1.2.1.3 */ -s32_t at_id = 1; -struct mib_node* mib2_at_node = (struct mib_node*)&attable; -struct mib_ram_array_node at = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, - 0, - &at_id, - &mib2_at_node -}; - -/** index root node for ifTable */ -struct mib_list_rootnode iflist_root = { - &ifentry_get_object_def, - &ifentry_get_value, -#if SNMP_SAFE_REQUESTS - &noleafs_set_test, - &noleafs_set_value, -#else /* SNMP_SAFE_REQUESTS */ - &ifentry_set_test, - &ifentry_set_value, -#endif /* SNMP_SAFE_REQUESTS */ - MIB_NODE_LR, - 0, - NULL, - NULL, - 0 -}; -const s32_t ifentry_ids[22] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 }; -struct mib_node* const ifentry_nodes[22] = { - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root, - (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root -}; -const struct mib_array_node ifentry = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 22, - ifentry_ids, - ifentry_nodes -}; - -s32_t iftable_id = 1; -struct mib_node* iftable_node = (struct mib_node*)&ifentry; -struct mib_ram_array_node iftable = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_RA, - 0, - &iftable_id, - &iftable_node -}; - -/* interfaces .1.3.6.1.2.1.2 */ -const mib_scalar_node interfaces_scalar = { - &interfaces_get_object_def, - &interfaces_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t interfaces_ids[2] = { 1, 2 }; -struct mib_node* const interfaces_nodes[2] = { - (struct mib_node*)&interfaces_scalar, (struct mib_node*)&iftable -}; -const struct mib_array_node interfaces = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 2, - interfaces_ids, - interfaces_nodes -}; - - -/* 0 1 2 3 4 5 6 */ -/* system .1.3.6.1.2.1.1 */ -const mib_scalar_node sys_tem_scalar = { - &system_get_object_def, - &system_get_value, - &system_set_test, - &system_set_value, - MIB_NODE_SC, - 0 -}; -const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 }; -struct mib_node* const sys_tem_nodes[7] = { - (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar, - (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar, - (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar, - (struct mib_node*)&sys_tem_scalar -}; -/* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */ -const struct mib_array_node sys_tem = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 7, - sys_tem_ids, - sys_tem_nodes -}; - -/* mib-2 .1.3.6.1.2.1 */ -#if LWIP_TCP -#define MIB2_GROUPS 8 -#else -#define MIB2_GROUPS 7 -#endif -const s32_t mib2_ids[MIB2_GROUPS] = -{ - 1, - 2, - 3, - 4, - 5, -#if LWIP_TCP - 6, -#endif - 7, - 11 -}; -struct mib_node* const mib2_nodes[MIB2_GROUPS] = { - (struct mib_node*)&sys_tem, - (struct mib_node*)&interfaces, - (struct mib_node*)&at, - (struct mib_node*)&mib2_ip, - (struct mib_node*)&icmp, -#if LWIP_TCP - (struct mib_node*)&tcp, -#endif - (struct mib_node*)&udp, - (struct mib_node*)&snmp -}; - -const struct mib_array_node mib2 = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - MIB2_GROUPS, - mib2_ids, - mib2_nodes -}; - -/* mgmt .1.3.6.1.2 */ -const s32_t mgmt_ids[1] = { 1 }; -struct mib_node* const mgmt_nodes[1] = { (struct mib_node*)&mib2 }; -const struct mib_array_node mgmt = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 1, - mgmt_ids, - mgmt_nodes -}; - -/* internet .1.3.6.1 */ -#if SNMP_PRIVATE_MIB -/* When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. */ -s32_t internet_ids[2] = { 2, 4 }; -struct mib_node* const internet_nodes[2] = { (struct mib_node*)&mgmt, (struct mib_node*)&mib_private }; -const struct mib_array_node internet = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 2, - internet_ids, - internet_nodes -}; -#else -const s32_t internet_ids[1] = { 2 }; -struct mib_node* const internet_nodes[1] = { (struct mib_node*)&mgmt }; -const struct mib_array_node internet = { - &noleafs_get_object_def, - &noleafs_get_value, - &noleafs_set_test, - &noleafs_set_value, - MIB_NODE_AR, - 1, - internet_ids, - internet_nodes -}; -#endif - -/** mib-2.system.sysObjectID */ -static struct snmp_obj_id sysobjid = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID}; -/** enterprise ID for generic TRAPs, .iso.org.dod.internet.mgmt.mib-2.snmp */ -static struct snmp_obj_id snmpgrp_id = {7,{1,3,6,1,2,1,11}}; -/** mib-2.system.sysServices */ -static const s32_t sysservices = SNMP_SYSSERVICES; - -/** mib-2.system.sysDescr */ -static const u8_t sysdescr_len_default = 4; -static const u8_t sysdescr_default[] = "lwIP"; -static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default; -static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0]; -/** mib-2.system.sysContact */ -static const u8_t syscontact_len_default = 0; -static const u8_t syscontact_default[] = ""; -static u8_t* syscontact_len_ptr = (u8_t*)&syscontact_len_default; -static u8_t* syscontact_ptr = (u8_t*)&syscontact_default[0]; -/** mib-2.system.sysName */ -static const u8_t sysname_len_default = 8; -static const u8_t sysname_default[] = "FQDN-unk"; -static u8_t* sysname_len_ptr = (u8_t*)&sysname_len_default; -static u8_t* sysname_ptr = (u8_t*)&sysname_default[0]; -/** mib-2.system.sysLocation */ -static const u8_t syslocation_len_default = 0; -static const u8_t syslocation_default[] = ""; -static u8_t* syslocation_len_ptr = (u8_t*)&syslocation_len_default; -static u8_t* syslocation_ptr = (u8_t*)&syslocation_default[0]; -/** mib-2.snmp.snmpEnableAuthenTraps */ -static const u8_t snmpenableauthentraps_default = 2; /* disabled */ -static u8_t* snmpenableauthentraps_ptr = (u8_t*)&snmpenableauthentraps_default; - -/** mib-2.interfaces.ifTable.ifEntry.ifSpecific (zeroDotZero) */ -static const struct snmp_obj_id ifspecific = {2, {0, 0}}; -/** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */ -static const struct snmp_obj_id iprouteinfo = {2, {0, 0}}; - - - -/* mib-2.system counter(s) */ -static u32_t sysuptime = 0; - -/* mib-2.ip counter(s) */ -static u32_t ipinreceives = 0, - ipinhdrerrors = 0, - ipinaddrerrors = 0, - ipforwdatagrams = 0, - ipinunknownprotos = 0, - ipindiscards = 0, - ipindelivers = 0, - ipoutrequests = 0, - ipoutdiscards = 0, - ipoutnoroutes = 0, - ipreasmreqds = 0, - ipreasmoks = 0, - ipreasmfails = 0, - ipfragoks = 0, - ipfragfails = 0, - ipfragcreates = 0, - iproutingdiscards = 0; -/* mib-2.icmp counter(s) */ -static u32_t icmpinmsgs = 0, - icmpinerrors = 0, - icmpindestunreachs = 0, - icmpintimeexcds = 0, - icmpinparmprobs = 0, - icmpinsrcquenchs = 0, - icmpinredirects = 0, - icmpinechos = 0, - icmpinechoreps = 0, - icmpintimestamps = 0, - icmpintimestampreps = 0, - icmpinaddrmasks = 0, - icmpinaddrmaskreps = 0, - icmpoutmsgs = 0, - icmpouterrors = 0, - icmpoutdestunreachs = 0, - icmpouttimeexcds = 0, - icmpoutparmprobs = 0, - icmpoutsrcquenchs = 0, - icmpoutredirects = 0, - icmpoutechos = 0, - icmpoutechoreps = 0, - icmpouttimestamps = 0, - icmpouttimestampreps = 0, - icmpoutaddrmasks = 0, - icmpoutaddrmaskreps = 0; -/* mib-2.tcp counter(s) */ -static u32_t tcpactiveopens = 0, - tcppassiveopens = 0, - tcpattemptfails = 0, - tcpestabresets = 0, - tcpinsegs = 0, - tcpoutsegs = 0, - tcpretranssegs = 0, - tcpinerrs = 0, - tcpoutrsts = 0; -/* mib-2.udp counter(s) */ -static u32_t udpindatagrams = 0, - udpnoports = 0, - udpinerrors = 0, - udpoutdatagrams = 0; -/* mib-2.snmp counter(s) */ -static u32_t snmpinpkts = 0, - snmpoutpkts = 0, - snmpinbadversions = 0, - snmpinbadcommunitynames = 0, - snmpinbadcommunityuses = 0, - snmpinasnparseerrs = 0, - snmpintoobigs = 0, - snmpinnosuchnames = 0, - snmpinbadvalues = 0, - snmpinreadonlys = 0, - snmpingenerrs = 0, - snmpintotalreqvars = 0, - snmpintotalsetvars = 0, - snmpingetrequests = 0, - snmpingetnexts = 0, - snmpinsetrequests = 0, - snmpingetresponses = 0, - snmpintraps = 0, - snmpouttoobigs = 0, - snmpoutnosuchnames = 0, - snmpoutbadvalues = 0, - snmpoutgenerrs = 0, - snmpoutgetrequests = 0, - snmpoutgetnexts = 0, - snmpoutsetrequests = 0, - snmpoutgetresponses = 0, - snmpouttraps = 0; - - - -/* prototypes of the following functions are in lwip/src/include/lwip/snmp.h */ -/** - * Copy octet string. - * - * @param dst points to destination - * @param src points to source - * @param n number of octets to copy. - */ -static void ocstrncpy(u8_t *dst, u8_t *src, u16_t n) -{ - u16_t i = n; - while (i > 0) { - i--; - *dst++ = *src++; - } -} - -/** - * Copy object identifier (s32_t) array. - * - * @param dst points to destination - * @param src points to source - * @param n number of sub identifiers to copy. - */ -void objectidncpy(s32_t *dst, s32_t *src, u8_t n) -{ - u8_t i = n; - while(i > 0) { - i--; - *dst++ = *src++; - } -} - -/** - * Initializes sysDescr pointers. - * - * @param str if non-NULL then copy str pointer - * @param len points to string length, excluding zero terminator - */ -void snmp_set_sysdesr(u8_t *str, u8_t *len) -{ - if (str != NULL) - { - sysdescr_ptr = str; - sysdescr_len_ptr = len; - } -} - -void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid) -{ - *oid = &sysobjid; -} - -/** - * Initializes sysObjectID value. - * - * @param oid points to stuct snmp_obj_id to copy - */ -void snmp_set_sysobjid(struct snmp_obj_id *oid) -{ - sysobjid = *oid; -} - -/** - * Must be called at regular 10 msec interval from a timer interrupt - * or signal handler depending on your runtime environment. - */ -void snmp_inc_sysuptime(void) -{ - sysuptime++; -} - -void snmp_add_sysuptime(u32_t value) -{ - sysuptime+=value; -} - -void snmp_get_sysuptime(u32_t *value) -{ - SNMP_GET_SYSUPTIME(sysuptime); - *value = sysuptime; -} - -/** - * Initializes sysContact pointers, - * e.g. ptrs to non-volatile memory external to lwIP. - * - * @param ocstr if non-NULL then copy str pointer - * @param ocstrlen points to string length, excluding zero terminator - */ -void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen) -{ - if (ocstr != NULL) - { - syscontact_ptr = ocstr; - syscontact_len_ptr = ocstrlen; - } -} - -/** - * Initializes sysName pointers, - * e.g. ptrs to non-volatile memory external to lwIP. - * - * @param ocstr if non-NULL then copy str pointer - * @param ocstrlen points to string length, excluding zero terminator - */ -void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen) -{ - if (ocstr != NULL) - { - sysname_ptr = ocstr; - sysname_len_ptr = ocstrlen; - } -} - -/** - * Initializes sysLocation pointers, - * e.g. ptrs to non-volatile memory external to lwIP. - * - * @param ocstr if non-NULL then copy str pointer - * @param ocstrlen points to string length, excluding zero terminator - */ -void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen) -{ - if (ocstr != NULL) - { - syslocation_ptr = ocstr; - syslocation_len_ptr = ocstrlen; - } -} - - -void snmp_add_ifinoctets(struct netif *ni, u32_t value) -{ - ni->ifinoctets += value; -} - -void snmp_inc_ifinucastpkts(struct netif *ni) -{ - (ni->ifinucastpkts)++; -} - -void snmp_inc_ifinnucastpkts(struct netif *ni) -{ - (ni->ifinnucastpkts)++; -} - -void snmp_inc_ifindiscards(struct netif *ni) -{ - (ni->ifindiscards)++; -} - -void snmp_add_ifoutoctets(struct netif *ni, u32_t value) -{ - ni->ifoutoctets += value; -} - -void snmp_inc_ifoutucastpkts(struct netif *ni) -{ - (ni->ifoutucastpkts)++; -} - -void snmp_inc_ifoutnucastpkts(struct netif *ni) -{ - (ni->ifoutnucastpkts)++; -} - -void snmp_inc_ifoutdiscards(struct netif *ni) -{ - (ni->ifoutdiscards)++; -} - -void snmp_inc_iflist(void) -{ - struct mib_list_node *if_node = NULL; - - snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node); - /* enable getnext traversal on filled table */ - iftable.maxlength = 1; -} - -void snmp_dec_iflist(void) -{ - snmp_mib_node_delete(&iflist_root, iflist_root.tail); - /* disable getnext traversal on empty table */ - if(iflist_root.count == 0) iftable.maxlength = 0; -} - -/** - * Inserts ARP table indexes (.xIfIndex.xNetAddress) - * into arp table index trees (both atTable and ipNetToMediaTable). - */ -void snmp_insert_arpidx_tree(struct netif *ni, ip_addr_t *ip) -{ - struct mib_list_rootnode *at_rn; - struct mib_list_node *at_node; - s32_t arpidx[5]; - u8_t level, tree; - - LWIP_ASSERT("ni != NULL", ni != NULL); - snmp_netiftoifindex(ni, &arpidx[0]); - snmp_iptooid(ip, &arpidx[1]); - - for (tree = 0; tree < 2; tree++) - { - if (tree == 0) - { - at_rn = &arptree_root; - } - else - { - at_rn = &ipntomtree_root; - } - for (level = 0; level < 5; level++) - { - at_node = NULL; - snmp_mib_node_insert(at_rn, arpidx[level], &at_node); - if ((level != 4) && (at_node != NULL)) - { - if (at_node->nptr == NULL) - { - at_rn = snmp_mib_lrn_alloc(); - at_node->nptr = (struct mib_node*)at_rn; - if (at_rn != NULL) - { - if (level == 3) - { - if (tree == 0) - { - at_rn->get_object_def = atentry_get_object_def; - at_rn->get_value = atentry_get_value; - } - else - { - at_rn->get_object_def = ip_ntomentry_get_object_def; - at_rn->get_value = ip_ntomentry_get_value; - } - at_rn->set_test = noleafs_set_test; - at_rn->set_value = noleafs_set_value; - } - } - else - { - /* at_rn == NULL, malloc failure */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_arpidx_tree() insert failed, mem full")); - break; - } - } - else - { - at_rn = (struct mib_list_rootnode*)at_node->nptr; - } - } - } - } - /* enable getnext traversal on filled tables */ - at.maxlength = 1; - ipntomtable.maxlength = 1; -} - -/** - * Removes ARP table indexes (.xIfIndex.xNetAddress) - * from arp table index trees. - */ -void snmp_delete_arpidx_tree(struct netif *ni, ip_addr_t *ip) -{ - struct mib_list_rootnode *at_rn, *next, *del_rn[5]; - struct mib_list_node *at_n, *del_n[5]; - s32_t arpidx[5]; - u8_t fc, tree, level, del_cnt; - - snmp_netiftoifindex(ni, &arpidx[0]); - snmp_iptooid(ip, &arpidx[1]); - - for (tree = 0; tree < 2; tree++) - { - /* mark nodes for deletion */ - if (tree == 0) - { - at_rn = &arptree_root; - } - else - { - at_rn = &ipntomtree_root; - } - level = 0; - del_cnt = 0; - while ((level < 5) && (at_rn != NULL)) - { - fc = snmp_mib_node_find(at_rn, arpidx[level], &at_n); - if (fc == 0) - { - /* arpidx[level] does not exist */ - del_cnt = 0; - at_rn = NULL; - } - else if (fc == 1) - { - del_rn[del_cnt] = at_rn; - del_n[del_cnt] = at_n; - del_cnt++; - at_rn = (struct mib_list_rootnode*)(at_n->nptr); - } - else if (fc == 2) - { - /* reset delete (2 or more childs) */ - del_cnt = 0; - at_rn = (struct mib_list_rootnode*)(at_n->nptr); - } - level++; - } - /* delete marked index nodes */ - while (del_cnt > 0) - { - del_cnt--; - - at_rn = del_rn[del_cnt]; - at_n = del_n[del_cnt]; - - next = snmp_mib_node_delete(at_rn, at_n); - if (next != NULL) - { - LWIP_ASSERT("next_count == 0",next->count == 0); - snmp_mib_lrn_free(next); - } - } - } - /* disable getnext traversal on empty tables */ - if(arptree_root.count == 0) at.maxlength = 0; - if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0; -} - -void snmp_inc_ipinreceives(void) -{ - ipinreceives++; -} - -void snmp_inc_ipinhdrerrors(void) -{ - ipinhdrerrors++; -} - -void snmp_inc_ipinaddrerrors(void) -{ - ipinaddrerrors++; -} - -void snmp_inc_ipforwdatagrams(void) -{ - ipforwdatagrams++; -} - -void snmp_inc_ipinunknownprotos(void) -{ - ipinunknownprotos++; -} - -void snmp_inc_ipindiscards(void) -{ - ipindiscards++; -} - -void snmp_inc_ipindelivers(void) -{ - ipindelivers++; -} - -void snmp_inc_ipoutrequests(void) -{ - ipoutrequests++; -} - -void snmp_inc_ipoutdiscards(void) -{ - ipoutdiscards++; -} - -void snmp_inc_ipoutnoroutes(void) -{ - ipoutnoroutes++; -} - -void snmp_inc_ipreasmreqds(void) -{ - ipreasmreqds++; -} - -void snmp_inc_ipreasmoks(void) -{ - ipreasmoks++; -} - -void snmp_inc_ipreasmfails(void) -{ - ipreasmfails++; -} - -void snmp_inc_ipfragoks(void) -{ - ipfragoks++; -} - -void snmp_inc_ipfragfails(void) -{ - ipfragfails++; -} - -void snmp_inc_ipfragcreates(void) -{ - ipfragcreates++; -} - -void snmp_inc_iproutingdiscards(void) -{ - iproutingdiscards++; -} - -/** - * Inserts ipAddrTable indexes (.ipAdEntAddr) - * into index tree. - */ -void snmp_insert_ipaddridx_tree(struct netif *ni) -{ - struct mib_list_rootnode *ipa_rn; - struct mib_list_node *ipa_node; - s32_t ipaddridx[4]; - u8_t level; - - LWIP_ASSERT("ni != NULL", ni != NULL); - snmp_iptooid(&ni->ip_addr, &ipaddridx[0]); - - level = 0; - ipa_rn = &ipaddrtree_root; - while (level < 4) - { - ipa_node = NULL; - snmp_mib_node_insert(ipa_rn, ipaddridx[level], &ipa_node); - if ((level != 3) && (ipa_node != NULL)) - { - if (ipa_node->nptr == NULL) - { - ipa_rn = snmp_mib_lrn_alloc(); - ipa_node->nptr = (struct mib_node*)ipa_rn; - if (ipa_rn != NULL) - { - if (level == 2) - { - ipa_rn->get_object_def = ip_addrentry_get_object_def; - ipa_rn->get_value = ip_addrentry_get_value; - ipa_rn->set_test = noleafs_set_test; - ipa_rn->set_value = noleafs_set_value; - } - } - else - { - /* ipa_rn == NULL, malloc failure */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_ipaddridx_tree() insert failed, mem full")); - break; - } - } - else - { - ipa_rn = (struct mib_list_rootnode*)ipa_node->nptr; - } - } - level++; - } - /* enable getnext traversal on filled table */ - ipaddrtable.maxlength = 1; -} - -/** - * Removes ipAddrTable indexes (.ipAdEntAddr) - * from index tree. - */ -void snmp_delete_ipaddridx_tree(struct netif *ni) -{ - struct mib_list_rootnode *ipa_rn, *next, *del_rn[4]; - struct mib_list_node *ipa_n, *del_n[4]; - s32_t ipaddridx[4]; - u8_t fc, level, del_cnt; - - LWIP_ASSERT("ni != NULL", ni != NULL); - snmp_iptooid(&ni->ip_addr, &ipaddridx[0]); - - /* mark nodes for deletion */ - level = 0; - del_cnt = 0; - ipa_rn = &ipaddrtree_root; - while ((level < 4) && (ipa_rn != NULL)) - { - fc = snmp_mib_node_find(ipa_rn, ipaddridx[level], &ipa_n); - if (fc == 0) - { - /* ipaddridx[level] does not exist */ - del_cnt = 0; - ipa_rn = NULL; - } - else if (fc == 1) - { - del_rn[del_cnt] = ipa_rn; - del_n[del_cnt] = ipa_n; - del_cnt++; - ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr); - } - else if (fc == 2) - { - /* reset delete (2 or more childs) */ - del_cnt = 0; - ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr); - } - level++; - } - /* delete marked index nodes */ - while (del_cnt > 0) - { - del_cnt--; - - ipa_rn = del_rn[del_cnt]; - ipa_n = del_n[del_cnt]; - - next = snmp_mib_node_delete(ipa_rn, ipa_n); - if (next != NULL) - { - LWIP_ASSERT("next_count == 0",next->count == 0); - snmp_mib_lrn_free(next); - } - } - /* disable getnext traversal on empty table */ - if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0; -} - -/** - * Inserts ipRouteTable indexes (.ipRouteDest) - * into index tree. - * - * @param dflt non-zero for the default rte, zero for network rte - * @param ni points to network interface for this rte - * - * @todo record sysuptime for _this_ route when it is installed - * (needed for ipRouteAge) in the netif. - */ -void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni) -{ - u8_t insert = 0; - ip_addr_t dst; - - if (dflt != 0) - { - /* the default route 0.0.0.0 */ - ip_addr_set_any(&dst); - insert = 1; - } - else - { - /* route to the network address */ - ip_addr_get_network(&dst, &ni->ip_addr, &ni->netmask); - /* exclude 0.0.0.0 network (reserved for default rte) */ - if (!ip_addr_isany(&dst)) { - insert = 1; - } - } - if (insert) - { - struct mib_list_rootnode *iprte_rn; - struct mib_list_node *iprte_node; - s32_t iprteidx[4]; - u8_t level; - - snmp_iptooid(&dst, &iprteidx[0]); - level = 0; - iprte_rn = &iprtetree_root; - while (level < 4) - { - iprte_node = NULL; - snmp_mib_node_insert(iprte_rn, iprteidx[level], &iprte_node); - if ((level != 3) && (iprte_node != NULL)) - { - if (iprte_node->nptr == NULL) - { - iprte_rn = snmp_mib_lrn_alloc(); - iprte_node->nptr = (struct mib_node*)iprte_rn; - if (iprte_rn != NULL) - { - if (level == 2) - { - iprte_rn->get_object_def = ip_rteentry_get_object_def; - iprte_rn->get_value = ip_rteentry_get_value; - iprte_rn->set_test = noleafs_set_test; - iprte_rn->set_value = noleafs_set_value; - } - } - else - { - /* iprte_rn == NULL, malloc failure */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_iprteidx_tree() insert failed, mem full")); - break; - } - } - else - { - iprte_rn = (struct mib_list_rootnode*)iprte_node->nptr; - } - } - level++; - } - } - /* enable getnext traversal on filled table */ - iprtetable.maxlength = 1; -} - -/** - * Removes ipRouteTable indexes (.ipRouteDest) - * from index tree. - * - * @param dflt non-zero for the default rte, zero for network rte - * @param ni points to network interface for this rte or NULL - * for default route to be removed. - */ -void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni) -{ - u8_t del = 0; - ip_addr_t dst; - - if (dflt != 0) - { - /* the default route 0.0.0.0 */ - ip_addr_set_any(&dst); - del = 1; - } - else - { - /* route to the network address */ - ip_addr_get_network(&dst, &ni->ip_addr, &ni->netmask); - /* exclude 0.0.0.0 network (reserved for default rte) */ - if (!ip_addr_isany(&dst)) { - del = 1; - } - } - if (del) - { - struct mib_list_rootnode *iprte_rn, *next, *del_rn[4]; - struct mib_list_node *iprte_n, *del_n[4]; - s32_t iprteidx[4]; - u8_t fc, level, del_cnt; - - snmp_iptooid(&dst, &iprteidx[0]); - /* mark nodes for deletion */ - level = 0; - del_cnt = 0; - iprte_rn = &iprtetree_root; - while ((level < 4) && (iprte_rn != NULL)) - { - fc = snmp_mib_node_find(iprte_rn, iprteidx[level], &iprte_n); - if (fc == 0) - { - /* iprteidx[level] does not exist */ - del_cnt = 0; - iprte_rn = NULL; - } - else if (fc == 1) - { - del_rn[del_cnt] = iprte_rn; - del_n[del_cnt] = iprte_n; - del_cnt++; - iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr); - } - else if (fc == 2) - { - /* reset delete (2 or more childs) */ - del_cnt = 0; - iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr); - } - level++; - } - /* delete marked index nodes */ - while (del_cnt > 0) - { - del_cnt--; - - iprte_rn = del_rn[del_cnt]; - iprte_n = del_n[del_cnt]; - - next = snmp_mib_node_delete(iprte_rn, iprte_n); - if (next != NULL) - { - LWIP_ASSERT("next_count == 0",next->count == 0); - snmp_mib_lrn_free(next); - } - } - } - /* disable getnext traversal on empty table */ - if (iprtetree_root.count == 0) iprtetable.maxlength = 0; -} - - -void snmp_inc_icmpinmsgs(void) -{ - icmpinmsgs++; -} - -void snmp_inc_icmpinerrors(void) -{ - icmpinerrors++; -} - -void snmp_inc_icmpindestunreachs(void) -{ - icmpindestunreachs++; -} - -void snmp_inc_icmpintimeexcds(void) -{ - icmpintimeexcds++; -} - -void snmp_inc_icmpinparmprobs(void) -{ - icmpinparmprobs++; -} - -void snmp_inc_icmpinsrcquenchs(void) -{ - icmpinsrcquenchs++; -} - -void snmp_inc_icmpinredirects(void) -{ - icmpinredirects++; -} - -void snmp_inc_icmpinechos(void) -{ - icmpinechos++; -} - -void snmp_inc_icmpinechoreps(void) -{ - icmpinechoreps++; -} - -void snmp_inc_icmpintimestamps(void) -{ - icmpintimestamps++; -} - -void snmp_inc_icmpintimestampreps(void) -{ - icmpintimestampreps++; -} - -void snmp_inc_icmpinaddrmasks(void) -{ - icmpinaddrmasks++; -} - -void snmp_inc_icmpinaddrmaskreps(void) -{ - icmpinaddrmaskreps++; -} - -void snmp_inc_icmpoutmsgs(void) -{ - icmpoutmsgs++; -} - -void snmp_inc_icmpouterrors(void) -{ - icmpouterrors++; -} - -void snmp_inc_icmpoutdestunreachs(void) -{ - icmpoutdestunreachs++; -} - -void snmp_inc_icmpouttimeexcds(void) -{ - icmpouttimeexcds++; -} - -void snmp_inc_icmpoutparmprobs(void) -{ - icmpoutparmprobs++; -} - -void snmp_inc_icmpoutsrcquenchs(void) -{ - icmpoutsrcquenchs++; -} - -void snmp_inc_icmpoutredirects(void) -{ - icmpoutredirects++; -} - -void snmp_inc_icmpoutechos(void) -{ - icmpoutechos++; -} - -void snmp_inc_icmpoutechoreps(void) -{ - icmpoutechoreps++; -} - -void snmp_inc_icmpouttimestamps(void) -{ - icmpouttimestamps++; -} - -void snmp_inc_icmpouttimestampreps(void) -{ - icmpouttimestampreps++; -} - -void snmp_inc_icmpoutaddrmasks(void) -{ - icmpoutaddrmasks++; -} - -void snmp_inc_icmpoutaddrmaskreps(void) -{ - icmpoutaddrmaskreps++; -} - -void snmp_inc_tcpactiveopens(void) -{ - tcpactiveopens++; -} - -void snmp_inc_tcppassiveopens(void) -{ - tcppassiveopens++; -} - -void snmp_inc_tcpattemptfails(void) -{ - tcpattemptfails++; -} - -void snmp_inc_tcpestabresets(void) -{ - tcpestabresets++; -} - -void snmp_inc_tcpinsegs(void) -{ - tcpinsegs++; -} - -void snmp_inc_tcpoutsegs(void) -{ - tcpoutsegs++; -} - -void snmp_inc_tcpretranssegs(void) -{ - tcpretranssegs++; -} - -void snmp_inc_tcpinerrs(void) -{ - tcpinerrs++; -} - -void snmp_inc_tcpoutrsts(void) -{ - tcpoutrsts++; -} - -void snmp_inc_udpindatagrams(void) -{ - udpindatagrams++; -} - -void snmp_inc_udpnoports(void) -{ - udpnoports++; -} - -void snmp_inc_udpinerrors(void) -{ - udpinerrors++; -} - -void snmp_inc_udpoutdatagrams(void) -{ - udpoutdatagrams++; -} - -/** - * Inserts udpTable indexes (.udpLocalAddress.udpLocalPort) - * into index tree. - */ -void snmp_insert_udpidx_tree(struct udp_pcb *pcb) -{ - struct mib_list_rootnode *udp_rn; - struct mib_list_node *udp_node; - s32_t udpidx[5]; - u8_t level; - - LWIP_ASSERT("pcb != NULL", pcb != NULL); - snmp_iptooid(&pcb->local_ip, &udpidx[0]); - udpidx[4] = pcb->local_port; - - udp_rn = &udp_root; - for (level = 0; level < 5; level++) - { - udp_node = NULL; - snmp_mib_node_insert(udp_rn, udpidx[level], &udp_node); - if ((level != 4) && (udp_node != NULL)) - { - if (udp_node->nptr == NULL) - { - udp_rn = snmp_mib_lrn_alloc(); - udp_node->nptr = (struct mib_node*)udp_rn; - if (udp_rn != NULL) - { - if (level == 3) - { - udp_rn->get_object_def = udpentry_get_object_def; - udp_rn->get_value = udpentry_get_value; - udp_rn->set_test = noleafs_set_test; - udp_rn->set_value = noleafs_set_value; - } - } - else - { - /* udp_rn == NULL, malloc failure */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_udpidx_tree() insert failed, mem full")); - break; - } - } - else - { - udp_rn = (struct mib_list_rootnode*)udp_node->nptr; - } - } - } - udptable.maxlength = 1; -} - -/** - * Removes udpTable indexes (.udpLocalAddress.udpLocalPort) - * from index tree. - */ -void snmp_delete_udpidx_tree(struct udp_pcb *pcb) -{ - struct udp_pcb *npcb; - struct mib_list_rootnode *udp_rn, *next, *del_rn[5]; - struct mib_list_node *udp_n, *del_n[5]; - s32_t udpidx[5]; - u8_t bindings, fc, level, del_cnt; - - LWIP_ASSERT("pcb != NULL", pcb != NULL); - snmp_iptooid(&pcb->local_ip, &udpidx[0]); - udpidx[4] = pcb->local_port; - - /* count PCBs for a given binding - (e.g. when reusing ports or for temp output PCBs) */ - bindings = 0; - npcb = udp_pcbs; - while ((npcb != NULL)) - { - if (ip_addr_cmp(&npcb->local_ip, &pcb->local_ip) && - (npcb->local_port == udpidx[4])) - { - bindings++; - } - npcb = npcb->next; - } - if (bindings == 1) - { - /* selectively remove */ - /* mark nodes for deletion */ - level = 0; - del_cnt = 0; - udp_rn = &udp_root; - while ((level < 5) && (udp_rn != NULL)) - { - fc = snmp_mib_node_find(udp_rn, udpidx[level], &udp_n); - if (fc == 0) - { - /* udpidx[level] does not exist */ - del_cnt = 0; - udp_rn = NULL; - } - else if (fc == 1) - { - del_rn[del_cnt] = udp_rn; - del_n[del_cnt] = udp_n; - del_cnt++; - udp_rn = (struct mib_list_rootnode*)(udp_n->nptr); - } - else if (fc == 2) - { - /* reset delete (2 or more childs) */ - del_cnt = 0; - udp_rn = (struct mib_list_rootnode*)(udp_n->nptr); - } - level++; - } - /* delete marked index nodes */ - while (del_cnt > 0) - { - del_cnt--; - - udp_rn = del_rn[del_cnt]; - udp_n = del_n[del_cnt]; - - next = snmp_mib_node_delete(udp_rn, udp_n); - if (next != NULL) - { - LWIP_ASSERT("next_count == 0",next->count == 0); - snmp_mib_lrn_free(next); - } - } - } - /* disable getnext traversal on empty table */ - if (udp_root.count == 0) udptable.maxlength = 0; -} - - -void snmp_inc_snmpinpkts(void) -{ - snmpinpkts++; -} - -void snmp_inc_snmpoutpkts(void) -{ - snmpoutpkts++; -} - -void snmp_inc_snmpinbadversions(void) -{ - snmpinbadversions++; -} - -void snmp_inc_snmpinbadcommunitynames(void) -{ - snmpinbadcommunitynames++; -} - -void snmp_inc_snmpinbadcommunityuses(void) -{ - snmpinbadcommunityuses++; -} - -void snmp_inc_snmpinasnparseerrs(void) -{ - snmpinasnparseerrs++; -} - -void snmp_inc_snmpintoobigs(void) -{ - snmpintoobigs++; -} - -void snmp_inc_snmpinnosuchnames(void) -{ - snmpinnosuchnames++; -} - -void snmp_inc_snmpinbadvalues(void) -{ - snmpinbadvalues++; -} - -void snmp_inc_snmpinreadonlys(void) -{ - snmpinreadonlys++; -} - -void snmp_inc_snmpingenerrs(void) -{ - snmpingenerrs++; -} - -void snmp_add_snmpintotalreqvars(u8_t value) -{ - snmpintotalreqvars += value; -} - -void snmp_add_snmpintotalsetvars(u8_t value) -{ - snmpintotalsetvars += value; -} - -void snmp_inc_snmpingetrequests(void) -{ - snmpingetrequests++; -} - -void snmp_inc_snmpingetnexts(void) -{ - snmpingetnexts++; -} - -void snmp_inc_snmpinsetrequests(void) -{ - snmpinsetrequests++; -} - -void snmp_inc_snmpingetresponses(void) -{ - snmpingetresponses++; -} - -void snmp_inc_snmpintraps(void) -{ - snmpintraps++; -} - -void snmp_inc_snmpouttoobigs(void) -{ - snmpouttoobigs++; -} - -void snmp_inc_snmpoutnosuchnames(void) -{ - snmpoutnosuchnames++; -} - -void snmp_inc_snmpoutbadvalues(void) -{ - snmpoutbadvalues++; -} - -void snmp_inc_snmpoutgenerrs(void) -{ - snmpoutgenerrs++; -} - -void snmp_inc_snmpoutgetrequests(void) -{ - snmpoutgetrequests++; -} - -void snmp_inc_snmpoutgetnexts(void) -{ - snmpoutgetnexts++; -} - -void snmp_inc_snmpoutsetrequests(void) -{ - snmpoutsetrequests++; -} - -void snmp_inc_snmpoutgetresponses(void) -{ - snmpoutgetresponses++; -} - -void snmp_inc_snmpouttraps(void) -{ - snmpouttraps++; -} - -void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid) -{ - *oid = &snmpgrp_id; -} - -void snmp_set_snmpenableauthentraps(u8_t *value) -{ - if (value != NULL) - { - snmpenableauthentraps_ptr = value; - } -} - -void snmp_get_snmpenableauthentraps(u8_t *value) -{ - *value = *snmpenableauthentraps_ptr; -} - -void -noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - LWIP_UNUSED_ARG(ident_len); - LWIP_UNUSED_ARG(ident); - od->instance = MIB_OBJECT_NONE; -} - -void -noleafs_get_value(struct obj_def *od, u16_t len, void *value) -{ - LWIP_UNUSED_ARG(od); - LWIP_UNUSED_ARG(len); - LWIP_UNUSED_ARG(value); -} - -u8_t -noleafs_set_test(struct obj_def *od, u16_t len, void *value) -{ - LWIP_UNUSED_ARG(od); - LWIP_UNUSED_ARG(len); - LWIP_UNUSED_ARG(value); - /* can't set */ - return 0; -} - -void -noleafs_set_value(struct obj_def *od, u16_t len, void *value) -{ - LWIP_UNUSED_ARG(od); - LWIP_UNUSED_ARG(len); - LWIP_UNUSED_ARG(value); -} - - -/** - * Returns systems object definitions. - * - * @param ident_len the address length (2) - * @param ident points to objectname.0 (object id trailer) - * @param od points to object definition. - */ -static void -system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - u8_t id; - - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if (ident_len == 2) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def system.%"U16_F".0\n",(u16_t)id)); - switch (id) - { - case 1: /* sysDescr */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = *sysdescr_len_ptr; - break; - case 2: /* sysObjectID */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID); - od->v_len = sysobjid.len * sizeof(s32_t); - break; - case 3: /* sysUpTime */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS); - od->v_len = sizeof(u32_t); - break; - case 4: /* sysContact */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = *syscontact_len_ptr; - break; - case 5: /* sysName */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = *sysname_len_ptr; - break; - case 6: /* sysLocation */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = *syslocation_len_ptr; - break; - case 7: /* sysServices */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - }; - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -/** - * Returns system object value. - * - * @param ident_len the address length (2) - * @param ident points to objectname.0 (object id trailer) - * @param len return value space (in bytes) - * @param value points to (varbind) space to copy value into. - */ -static void -system_get_value(struct obj_def *od, u16_t len, void *value) -{ - u8_t id; - - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* sysDescr */ - ocstrncpy((u8_t*)value, sysdescr_ptr, len); - break; - case 2: /* sysObjectID */ - objectidncpy((s32_t*)value, (s32_t*)sysobjid.id, (u8_t)(len / sizeof(s32_t))); - break; - case 3: /* sysUpTime */ - { - snmp_get_sysuptime((u32_t*)value); - } - break; - case 4: /* sysContact */ - ocstrncpy((u8_t*)value, syscontact_ptr, len); - break; - case 5: /* sysName */ - ocstrncpy((u8_t*)value, sysname_ptr, len); - break; - case 6: /* sysLocation */ - ocstrncpy((u8_t*)value, syslocation_ptr, len); - break; - case 7: /* sysServices */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = sysservices; - } - break; - }; -} - -static u8_t -system_set_test(struct obj_def *od, u16_t len, void *value) -{ - u8_t id, set_ok; - - LWIP_UNUSED_ARG(value); - set_ok = 0; - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 4: /* sysContact */ - if ((syscontact_ptr != syscontact_default) && - (len <= 255)) - { - set_ok = 1; - } - break; - case 5: /* sysName */ - if ((sysname_ptr != sysname_default) && - (len <= 255)) - { - set_ok = 1; - } - break; - case 6: /* sysLocation */ - if ((syslocation_ptr != syslocation_default) && - (len <= 255)) - { - set_ok = 1; - } - break; - }; - return set_ok; -} - -static void -system_set_value(struct obj_def *od, u16_t len, void *value) -{ - u8_t id; - - LWIP_ASSERT("invalid len", len <= 0xff); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 4: /* sysContact */ - ocstrncpy(syscontact_ptr, (u8_t*)value, len); - *syscontact_len_ptr = (u8_t)len; - break; - case 5: /* sysName */ - ocstrncpy(sysname_ptr, (u8_t*)value, len); - *sysname_len_ptr = (u8_t)len; - break; - case 6: /* sysLocation */ - ocstrncpy(syslocation_ptr, (u8_t*)value, len); - *syslocation_len_ptr = (u8_t)len; - break; - }; -} - -/** - * Returns interfaces.ifnumber object definition. - * - * @param ident_len the address length (2) - * @param ident points to objectname.index - * @param od points to object definition. - */ -static void -interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if (ident_len == 2) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("interfaces_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -/** - * Returns interfaces.ifnumber object value. - * - * @param ident_len the address length (2) - * @param ident points to objectname.0 (object id trailer) - * @param len return value space (in bytes) - * @param value points to (varbind) space to copy value into. - */ -static void -interfaces_get_value(struct obj_def *od, u16_t len, void *value) -{ - LWIP_UNUSED_ARG(len); - if (od->id_inst_ptr[0] == 1) - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = iflist_root.count; - } -} - -/** - * Returns ifentry object definitions. - * - * @param ident_len the address length (2) - * @param ident points to objectname.index - * @param od points to object definition. - */ -static void -ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - u8_t id; - - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if (ident_len == 2) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ifentry.%"U16_F"\n",(u16_t)id)); - switch (id) - { - case 1: /* ifIndex */ - case 3: /* ifType */ - case 4: /* ifMtu */ - case 8: /* ifOperStatus */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 2: /* ifDescr */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - /** @todo this should be some sort of sizeof(struct netif.name) */ - od->v_len = 2; - break; - case 5: /* ifSpeed */ - case 21: /* ifOutQLen */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE); - od->v_len = sizeof(u32_t); - break; - case 6: /* ifPhysAddress */ - { - struct netif *netif; - - snmp_ifindextonetif(ident[1], &netif); - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = netif->hwaddr_len; - } - break; - case 7: /* ifAdminStatus */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 9: /* ifLastChange */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS); - od->v_len = sizeof(u32_t); - break; - case 10: /* ifInOctets */ - case 11: /* ifInUcastPkts */ - case 12: /* ifInNUcastPkts */ - case 13: /* ifInDiscarts */ - case 14: /* ifInErrors */ - case 15: /* ifInUnkownProtos */ - case 16: /* ifOutOctets */ - case 17: /* ifOutUcastPkts */ - case 18: /* ifOutNUcastPkts */ - case 19: /* ifOutDiscarts */ - case 20: /* ifOutErrors */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); - od->v_len = sizeof(u32_t); - break; - case 22: /* ifSpecific */ - /** @note returning zeroDotZero (0.0) no media specific MIB support */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID); - od->v_len = ifspecific.len * sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - }; - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -/** - * Returns ifentry object value. - * - * @param ident_len the address length (2) - * @param ident points to objectname.0 (object id trailer) - * @param len return value space (in bytes) - * @param value points to (varbind) space to copy value into. - */ -static void -ifentry_get_value(struct obj_def *od, u16_t len, void *value) -{ - struct netif *netif; - u8_t id; - - snmp_ifindextonetif(od->id_inst_ptr[1], &netif); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* ifIndex */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = od->id_inst_ptr[1]; - } - break; - case 2: /* ifDescr */ - ocstrncpy((u8_t*)value, (u8_t*)netif->name, len); - break; - case 3: /* ifType */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = netif->link_type; - } - break; - case 4: /* ifMtu */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = netif->mtu; - } - break; - case 5: /* ifSpeed */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->link_speed; - } - break; - case 6: /* ifPhysAddress */ - ocstrncpy((u8_t*)value, netif->hwaddr, len); - break; - case 7: /* ifAdminStatus */ - { - s32_t *sint_ptr = (s32_t*)value; - if (netif_is_up(netif)) - { - if (netif_is_link_up(netif)) - { - *sint_ptr = 1; /* up */ - } - else - { - *sint_ptr = 7; /* lowerLayerDown */ - } - } - else - { - *sint_ptr = 2; /* down */ - } - } - break; - case 8: /* ifOperStatus */ - { - s32_t *sint_ptr = (s32_t*)value; - if (netif_is_up(netif)) - { - *sint_ptr = 1; - } - else - { - *sint_ptr = 2; - } - } - break; - case 9: /* ifLastChange */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ts; - } - break; - case 10: /* ifInOctets */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifinoctets; - } - break; - case 11: /* ifInUcastPkts */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifinucastpkts; - } - break; - case 12: /* ifInNUcastPkts */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifinnucastpkts; - } - break; - case 13: /* ifInDiscarts */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifindiscards; - } - break; - case 14: /* ifInErrors */ - case 15: /* ifInUnkownProtos */ - /** @todo add these counters! */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = 0; - } - break; - case 16: /* ifOutOctets */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifoutoctets; - } - break; - case 17: /* ifOutUcastPkts */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifoutucastpkts; - } - break; - case 18: /* ifOutNUcastPkts */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifoutnucastpkts; - } - break; - case 19: /* ifOutDiscarts */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = netif->ifoutdiscards; - } - break; - case 20: /* ifOutErrors */ - /** @todo add this counter! */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = 0; - } - break; - case 21: /* ifOutQLen */ - /** @todo figure out if this must be 0 (no queue) or 1? */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = 0; - } - break; - case 22: /* ifSpecific */ - objectidncpy((s32_t*)value, (s32_t*)ifspecific.id, (u8_t)(len / sizeof(s32_t))); - break; - }; -} - -#if !SNMP_SAFE_REQUESTS -static u8_t -ifentry_set_test(struct obj_def *od, u16_t len, void *value) -{ - struct netif *netif; - u8_t id, set_ok; - LWIP_UNUSED_ARG(len); - - set_ok = 0; - snmp_ifindextonetif(od->id_inst_ptr[1], &netif); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 7: /* ifAdminStatus */ - { - s32_t *sint_ptr = (s32_t*)value; - if (*sint_ptr == 1 || *sint_ptr == 2) - set_ok = 1; - } - break; - } - return set_ok; -} - -static void -ifentry_set_value(struct obj_def *od, u16_t len, void *value) -{ - struct netif *netif; - u8_t id; - LWIP_UNUSED_ARG(len); - - snmp_ifindextonetif(od->id_inst_ptr[1], &netif); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 7: /* ifAdminStatus */ - { - s32_t *sint_ptr = (s32_t*)value; - if (*sint_ptr == 1) - { - netif_set_up(netif); - } - else if (*sint_ptr == 2) - { - netif_set_down(netif); - } - } - break; - } -} -#endif /* SNMP_SAFE_REQUESTS */ - -/** - * Returns atentry object definitions. - * - * @param ident_len the address length (6) - * @param ident points to objectname.atifindex.atnetaddress - * @param od points to object definition. - */ -static void -atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (5) */ - ident_len += 5; - ident -= 5; - - if (ident_len == 6) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - switch (ident[0]) - { - case 1: /* atIfIndex */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 2: /* atPhysAddress */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = 6; /** @todo try to use netif::hwaddr_len */ - break; - case 3: /* atNetAddress */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); - od->v_len = 4; - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - } - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -atentry_get_value(struct obj_def *od, u16_t len, void *value) -{ -#if LWIP_ARP - u8_t id; - struct eth_addr* ethaddr_ret; - ip_addr_t* ipaddr_ret; -#endif /* LWIP_ARP */ - ip_addr_t ip; - struct netif *netif; - - LWIP_UNUSED_ARG(len); - LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */ - - snmp_ifindextonetif(od->id_inst_ptr[1], &netif); - snmp_oidtoip(&od->id_inst_ptr[2], &ip); - -#if LWIP_ARP /** @todo implement a netif_find_addr */ - if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1) - { - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* atIfIndex */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = od->id_inst_ptr[1]; - } - break; - case 2: /* atPhysAddress */ - { - struct eth_addr *dst = (struct eth_addr*)value; - - *dst = *ethaddr_ret; - } - break; - case 3: /* atNetAddress */ - { - ip_addr_t *dst = (ip_addr_t*)value; - - *dst = *ipaddr_ret; - } - break; - } - } -#endif /* LWIP_ARP */ -} - -static void -ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - u8_t id; - - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if (ident_len == 2) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ip.%"U16_F".0\n",(u16_t)id)); - switch (id) - { - case 1: /* ipForwarding */ - case 2: /* ipDefaultTTL */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 3: /* ipInReceives */ - case 4: /* ipInHdrErrors */ - case 5: /* ipInAddrErrors */ - case 6: /* ipForwDatagrams */ - case 7: /* ipInUnknownProtos */ - case 8: /* ipInDiscards */ - case 9: /* ipInDelivers */ - case 10: /* ipOutRequests */ - case 11: /* ipOutDiscards */ - case 12: /* ipOutNoRoutes */ - case 14: /* ipReasmReqds */ - case 15: /* ipReasmOKs */ - case 16: /* ipReasmFails */ - case 17: /* ipFragOKs */ - case 18: /* ipFragFails */ - case 19: /* ipFragCreates */ - case 23: /* ipRoutingDiscards */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); - od->v_len = sizeof(u32_t); - break; - case 13: /* ipReasmTimeout */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - }; - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -ip_get_value(struct obj_def *od, u16_t len, void *value) -{ - u8_t id; - - LWIP_UNUSED_ARG(len); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* ipForwarding */ - { - s32_t *sint_ptr = (s32_t*)value; -#if IP_FORWARD - /* forwarding */ - *sint_ptr = 1; -#else - /* not-forwarding */ - *sint_ptr = 2; -#endif - } - break; - case 2: /* ipDefaultTTL */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = IP_DEFAULT_TTL; - } - break; - case 3: /* ipInReceives */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipinreceives; - } - break; - case 4: /* ipInHdrErrors */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipinhdrerrors; - } - break; - case 5: /* ipInAddrErrors */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipinaddrerrors; - } - break; - case 6: /* ipForwDatagrams */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipforwdatagrams; - } - break; - case 7: /* ipInUnknownProtos */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipinunknownprotos; - } - break; - case 8: /* ipInDiscards */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipindiscards; - } - break; - case 9: /* ipInDelivers */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipindelivers; - } - break; - case 10: /* ipOutRequests */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipoutrequests; - } - break; - case 11: /* ipOutDiscards */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipoutdiscards; - } - break; - case 12: /* ipOutNoRoutes */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipoutnoroutes; - } - break; - case 13: /* ipReasmTimeout */ - { - s32_t *sint_ptr = (s32_t*)value; -#if IP_REASSEMBLY - *sint_ptr = IP_REASS_MAXAGE; -#else - *sint_ptr = 0; -#endif - } - break; - case 14: /* ipReasmReqds */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipreasmreqds; - } - break; - case 15: /* ipReasmOKs */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipreasmoks; - } - break; - case 16: /* ipReasmFails */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipreasmfails; - } - break; - case 17: /* ipFragOKs */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipfragoks; - } - break; - case 18: /* ipFragFails */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipfragfails; - } - break; - case 19: /* ipFragCreates */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = ipfragcreates; - } - break; - case 23: /* ipRoutingDiscards */ - /** @todo can lwIP discard routes at all?? hardwire this to 0?? */ - { - u32_t *uint_ptr = (u32_t*)value; - *uint_ptr = iproutingdiscards; - } - break; - }; -} - -/** - * Test ip object value before setting. - * - * @param od is the object definition - * @param len return value space (in bytes) - * @param value points to (varbind) space to copy value from. - * - * @note we allow set if the value matches the hardwired value, - * otherwise return badvalue. - */ -static u8_t -ip_set_test(struct obj_def *od, u16_t len, void *value) -{ - u8_t id, set_ok; - s32_t *sint_ptr = (s32_t*)value; - - LWIP_UNUSED_ARG(len); - set_ok = 0; - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* ipForwarding */ -#if IP_FORWARD - /* forwarding */ - if (*sint_ptr == 1) -#else - /* not-forwarding */ - if (*sint_ptr == 2) -#endif - { - set_ok = 1; - } - break; - case 2: /* ipDefaultTTL */ - if (*sint_ptr == IP_DEFAULT_TTL) - { - set_ok = 1; - } - break; - }; - return set_ok; -} - -static void -ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (4) */ - ident_len += 4; - ident -= 4; - - if (ident_len == 5) - { - u8_t id; - - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - switch (id) - { - case 1: /* ipAdEntAddr */ - case 3: /* ipAdEntNetMask */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); - od->v_len = 4; - break; - case 2: /* ipAdEntIfIndex */ - case 4: /* ipAdEntBcastAddr */ - case 5: /* ipAdEntReasmMaxSize */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - } - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value) -{ - u8_t id; - u16_t ifidx; - ip_addr_t ip; - struct netif *netif = netif_list; - - LWIP_UNUSED_ARG(len); - snmp_oidtoip(&od->id_inst_ptr[1], &ip); - ifidx = 0; - while ((netif != NULL) && !ip_addr_cmp(&ip, &netif->ip_addr)) - { - netif = netif->next; - ifidx++; - } - - if (netif != NULL) - { - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* ipAdEntAddr */ - { - ip_addr_t *dst = (ip_addr_t*)value; - *dst = netif->ip_addr; - } - break; - case 2: /* ipAdEntIfIndex */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = ifidx + 1; - } - break; - case 3: /* ipAdEntNetMask */ - { - ip_addr_t *dst = (ip_addr_t*)value; - *dst = netif->netmask; - } - break; - case 4: /* ipAdEntBcastAddr */ - { - s32_t *sint_ptr = (s32_t*)value; - - /* lwIP oddity, there's no broadcast - address in the netif we can rely on */ - *sint_ptr = IPADDR_BROADCAST & 1; - } - break; - case 5: /* ipAdEntReasmMaxSize */ - { - s32_t *sint_ptr = (s32_t*)value; -#if IP_REASSEMBLY - /* @todo The theoretical maximum is IP_REASS_MAX_PBUFS * size of the pbufs, - * but only if receiving one fragmented packet at a time. - * The current solution is to calculate for 2 simultaneous packets... - */ - *sint_ptr = (IP_HLEN + ((IP_REASS_MAX_PBUFS/2) * - (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN - IP_HLEN))); -#else - /** @todo returning MTU would be a bad thing and - returning a wild guess like '576' isn't good either */ - *sint_ptr = 0; -#endif - } - break; - } - } -} - -/** - * @note - * lwIP IP routing is currently using the network addresses in netif_list. - * if no suitable network IP is found in netif_list, the default_netif is used. - */ -static void -ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - u8_t id; - - /* return to object name, adding index depth (4) */ - ident_len += 4; - ident -= 4; - - if (ident_len == 5) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - switch (id) - { - case 1: /* ipRouteDest */ - case 7: /* ipRouteNextHop */ - case 11: /* ipRouteMask */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); - od->v_len = 4; - break; - case 2: /* ipRouteIfIndex */ - case 3: /* ipRouteMetric1 */ - case 4: /* ipRouteMetric2 */ - case 5: /* ipRouteMetric3 */ - case 6: /* ipRouteMetric4 */ - case 8: /* ipRouteType */ - case 10: /* ipRouteAge */ - case 12: /* ipRouteMetric5 */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 9: /* ipRouteProto */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 13: /* ipRouteInfo */ - /** @note returning zeroDotZero (0.0) no routing protocol specific MIB */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID); - od->v_len = iprouteinfo.len * sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - } - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value) -{ - struct netif *netif; - ip_addr_t dest; - s32_t *ident; - u8_t id; - - ident = od->id_inst_ptr; - snmp_oidtoip(&ident[1], &dest); - - if (ip_addr_isany(&dest)) - { - /* ip_route() uses default netif for default route */ - netif = netif_default; - } - else - { - /* not using ip_route(), need exact match! */ - netif = netif_list; - while ((netif != NULL) && - !ip_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) ) - { - netif = netif->next; - } - } - if (netif != NULL) - { - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - switch (id) - { - case 1: /* ipRouteDest */ - { - ip_addr_t *dst = (ip_addr_t*)value; - - if (ip_addr_isany(&dest)) - { - /* default rte has 0.0.0.0 dest */ - ip_addr_set_zero(dst); - } - else - { - /* netifs have netaddress dest */ - ip_addr_get_network(dst, &netif->ip_addr, &netif->netmask); - } - } - break; - case 2: /* ipRouteIfIndex */ - { - s32_t *sint_ptr = (s32_t*)value; - - snmp_netiftoifindex(netif, sint_ptr); - } - break; - case 3: /* ipRouteMetric1 */ - { - s32_t *sint_ptr = (s32_t*)value; - - if (ip_addr_isany(&dest)) - { - /* default rte has metric 1 */ - *sint_ptr = 1; - } - else - { - /* other rtes have metric 0 */ - *sint_ptr = 0; - } - } - break; - case 4: /* ipRouteMetric2 */ - case 5: /* ipRouteMetric3 */ - case 6: /* ipRouteMetric4 */ - case 12: /* ipRouteMetric5 */ - { - s32_t *sint_ptr = (s32_t*)value; - /* not used */ - *sint_ptr = -1; - } - break; - case 7: /* ipRouteNextHop */ - { - ip_addr_t *dst = (ip_addr_t*)value; - - if (ip_addr_isany(&dest)) - { - /* default rte: gateway */ - *dst = netif->gw; - } - else - { - /* other rtes: netif ip_addr */ - *dst = netif->ip_addr; - } - } - break; - case 8: /* ipRouteType */ - { - s32_t *sint_ptr = (s32_t*)value; - - if (ip_addr_isany(&dest)) - { - /* default rte is indirect */ - *sint_ptr = 4; - } - else - { - /* other rtes are direct */ - *sint_ptr = 3; - } - } - break; - case 9: /* ipRouteProto */ - { - s32_t *sint_ptr = (s32_t*)value; - /* locally defined routes */ - *sint_ptr = 2; - } - break; - case 10: /* ipRouteAge */ - { - s32_t *sint_ptr = (s32_t*)value; - /** @todo (sysuptime - timestamp last change) / 100 - @see snmp_insert_iprteidx_tree() */ - *sint_ptr = 0; - } - break; - case 11: /* ipRouteMask */ - { - ip_addr_t *dst = (ip_addr_t*)value; - - if (ip_addr_isany(&dest)) - { - /* default rte use 0.0.0.0 mask */ - ip_addr_set_zero(dst); - } - else - { - /* other rtes use netmask */ - *dst = netif->netmask; - } - } - break; - case 13: /* ipRouteInfo */ - objectidncpy((s32_t*)value, (s32_t*)iprouteinfo.id, (u8_t)(len / sizeof(s32_t))); - break; - } - } -} - -static void -ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (5) */ - ident_len += 5; - ident -= 5; - - if (ident_len == 6) - { - u8_t id; - - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - switch (id) - { - case 1: /* ipNetToMediaIfIndex */ - case 4: /* ipNetToMediaType */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 2: /* ipNetToMediaPhysAddress */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); - od->v_len = 6; /** @todo try to use netif::hwaddr_len */ - break; - case 3: /* ipNetToMediaNetAddress */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); - od->v_len = 4; - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - } - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value) -{ -#if LWIP_ARP - u8_t id; - struct eth_addr* ethaddr_ret; - ip_addr_t* ipaddr_ret; -#endif /* LWIP_ARP */ - ip_addr_t ip; - struct netif *netif; - - LWIP_UNUSED_ARG(len); - LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */ - - snmp_ifindextonetif(od->id_inst_ptr[1], &netif); - snmp_oidtoip(&od->id_inst_ptr[2], &ip); - -#if LWIP_ARP /** @todo implement a netif_find_addr */ - if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1) - { - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* ipNetToMediaIfIndex */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = od->id_inst_ptr[1]; - } - break; - case 2: /* ipNetToMediaPhysAddress */ - { - struct eth_addr *dst = (struct eth_addr*)value; - - *dst = *ethaddr_ret; - } - break; - case 3: /* ipNetToMediaNetAddress */ - { - ip_addr_t *dst = (ip_addr_t*)value; - - *dst = *ipaddr_ret; - } - break; - case 4: /* ipNetToMediaType */ - { - s32_t *sint_ptr = (s32_t*)value; - /* dynamic (?) */ - *sint_ptr = 3; - } - break; - } - } -#endif /* LWIP_ARP */ -} - -static void -icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if ((ident_len == 2) && - (ident[0] > 0) && (ident[0] < 27)) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); - od->v_len = sizeof(u32_t); - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -icmp_get_value(struct obj_def *od, u16_t len, void *value) -{ - u32_t *uint_ptr = (u32_t*)value; - u8_t id; - - LWIP_UNUSED_ARG(len); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* icmpInMsgs */ - *uint_ptr = icmpinmsgs; - break; - case 2: /* icmpInErrors */ - *uint_ptr = icmpinerrors; - break; - case 3: /* icmpInDestUnreachs */ - *uint_ptr = icmpindestunreachs; - break; - case 4: /* icmpInTimeExcds */ - *uint_ptr = icmpintimeexcds; - break; - case 5: /* icmpInParmProbs */ - *uint_ptr = icmpinparmprobs; - break; - case 6: /* icmpInSrcQuenchs */ - *uint_ptr = icmpinsrcquenchs; - break; - case 7: /* icmpInRedirects */ - *uint_ptr = icmpinredirects; - break; - case 8: /* icmpInEchos */ - *uint_ptr = icmpinechos; - break; - case 9: /* icmpInEchoReps */ - *uint_ptr = icmpinechoreps; - break; - case 10: /* icmpInTimestamps */ - *uint_ptr = icmpintimestamps; - break; - case 11: /* icmpInTimestampReps */ - *uint_ptr = icmpintimestampreps; - break; - case 12: /* icmpInAddrMasks */ - *uint_ptr = icmpinaddrmasks; - break; - case 13: /* icmpInAddrMaskReps */ - *uint_ptr = icmpinaddrmaskreps; - break; - case 14: /* icmpOutMsgs */ - *uint_ptr = icmpoutmsgs; - break; - case 15: /* icmpOutErrors */ - *uint_ptr = icmpouterrors; - break; - case 16: /* icmpOutDestUnreachs */ - *uint_ptr = icmpoutdestunreachs; - break; - case 17: /* icmpOutTimeExcds */ - *uint_ptr = icmpouttimeexcds; - break; - case 18: /* icmpOutParmProbs */ - *uint_ptr = icmpoutparmprobs; - break; - case 19: /* icmpOutSrcQuenchs */ - *uint_ptr = icmpoutsrcquenchs; - break; - case 20: /* icmpOutRedirects */ - *uint_ptr = icmpoutredirects; - break; - case 21: /* icmpOutEchos */ - *uint_ptr = icmpoutechos; - break; - case 22: /* icmpOutEchoReps */ - *uint_ptr = icmpoutechoreps; - break; - case 23: /* icmpOutTimestamps */ - *uint_ptr = icmpouttimestamps; - break; - case 24: /* icmpOutTimestampReps */ - *uint_ptr = icmpouttimestampreps; - break; - case 25: /* icmpOutAddrMasks */ - *uint_ptr = icmpoutaddrmasks; - break; - case 26: /* icmpOutAddrMaskReps */ - *uint_ptr = icmpoutaddrmaskreps; - break; - } -} - -#if LWIP_TCP -/** @todo tcp grp */ -static void -tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - u8_t id; - - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if (ident_len == 2) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id)); - - switch (id) - { - case 1: /* tcpRtoAlgorithm */ - case 2: /* tcpRtoMin */ - case 3: /* tcpRtoMax */ - case 4: /* tcpMaxConn */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 5: /* tcpActiveOpens */ - case 6: /* tcpPassiveOpens */ - case 7: /* tcpAttemptFails */ - case 8: /* tcpEstabResets */ - case 10: /* tcpInSegs */ - case 11: /* tcpOutSegs */ - case 12: /* tcpRetransSegs */ - case 14: /* tcpInErrs */ - case 15: /* tcpOutRsts */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); - od->v_len = sizeof(u32_t); - break; - case 9: /* tcpCurrEstab */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE); - od->v_len = sizeof(u32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - }; - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -tcp_get_value(struct obj_def *od, u16_t len, void *value) -{ - u32_t *uint_ptr = (u32_t*)value; - s32_t *sint_ptr = (s32_t*)value; - u8_t id; - - LWIP_UNUSED_ARG(len); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* tcpRtoAlgorithm, vanj(4) */ - *sint_ptr = 4; - break; - case 2: /* tcpRtoMin */ - /* @todo not the actual value, a guess, - needs to be calculated */ - *sint_ptr = 1000; - break; - case 3: /* tcpRtoMax */ - /* @todo not the actual value, a guess, - needs to be calculated */ - *sint_ptr = 60000; - break; - case 4: /* tcpMaxConn */ - *sint_ptr = MEMP_NUM_TCP_PCB; - break; - case 5: /* tcpActiveOpens */ - *uint_ptr = tcpactiveopens; - break; - case 6: /* tcpPassiveOpens */ - *uint_ptr = tcppassiveopens; - break; - case 7: /* tcpAttemptFails */ - *uint_ptr = tcpattemptfails; - break; - case 8: /* tcpEstabResets */ - *uint_ptr = tcpestabresets; - break; - case 9: /* tcpCurrEstab */ - { - u16_t tcpcurrestab = 0; - struct tcp_pcb *pcb = tcp_active_pcbs; - while (pcb != NULL) - { - if ((pcb->state == ESTABLISHED) || - (pcb->state == CLOSE_WAIT)) - { - tcpcurrestab++; - } - pcb = pcb->next; - } - *uint_ptr = tcpcurrestab; - } - break; - case 10: /* tcpInSegs */ - *uint_ptr = tcpinsegs; - break; - case 11: /* tcpOutSegs */ - *uint_ptr = tcpoutsegs; - break; - case 12: /* tcpRetransSegs */ - *uint_ptr = tcpretranssegs; - break; - case 14: /* tcpInErrs */ - *uint_ptr = tcpinerrs; - break; - case 15: /* tcpOutRsts */ - *uint_ptr = tcpoutrsts; - break; - } -} -#ifdef THIS_SEEMS_UNUSED -static void -tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (10) */ - ident_len += 10; - ident -= 10; - - if (ident_len == 11) - { - u8_t id; - - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - id = ident[0]; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id)); - - switch (id) - { - case 1: /* tcpConnState */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - case 2: /* tcpConnLocalAddress */ - case 4: /* tcpConnRemAddress */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); - od->v_len = 4; - break; - case 3: /* tcpConnLocalPort */ - case 5: /* tcpConnRemPort */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - }; - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value) -{ - ip_addr_t lip, rip; - u16_t lport, rport; - s32_t *ident; - - ident = od->id_inst_ptr; - snmp_oidtoip(&ident[1], &lip); - lport = ident[5]; - snmp_oidtoip(&ident[6], &rip); - rport = ident[10]; - - /** @todo find matching PCB */ -} -#endif /* if 0 */ -#endif - -static void -udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if ((ident_len == 2) && - (ident[0] > 0) && (ident[0] < 6)) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); - od->v_len = sizeof(u32_t); - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -udp_get_value(struct obj_def *od, u16_t len, void *value) -{ - u32_t *uint_ptr = (u32_t*)value; - u8_t id; - - LWIP_UNUSED_ARG(len); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* udpInDatagrams */ - *uint_ptr = udpindatagrams; - break; - case 2: /* udpNoPorts */ - *uint_ptr = udpnoports; - break; - case 3: /* udpInErrors */ - *uint_ptr = udpinerrors; - break; - case 4: /* udpOutDatagrams */ - *uint_ptr = udpoutdatagrams; - break; - } -} - -static void -udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (5) */ - ident_len += 5; - ident -= 5; - - if (ident_len == 6) - { - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - switch (ident[0]) - { - case 1: /* udpLocalAddress */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); - od->v_len = 4; - break; - case 2: /* udpLocalPort */ - od->instance = MIB_OBJECT_TAB; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - } - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -udpentry_get_value(struct obj_def *od, u16_t len, void *value) -{ - u8_t id; - struct udp_pcb *pcb; - ip_addr_t ip; - u16_t port; - - LWIP_UNUSED_ARG(len); - snmp_oidtoip(&od->id_inst_ptr[1], &ip); - LWIP_ASSERT("invalid port", (od->id_inst_ptr[5] >= 0) && (od->id_inst_ptr[5] <= 0xffff)); - port = (u16_t)od->id_inst_ptr[5]; - - pcb = udp_pcbs; - while ((pcb != NULL) && - !(ip_addr_cmp(&pcb->local_ip, &ip) && - (pcb->local_port == port))) - { - pcb = pcb->next; - } - - if (pcb != NULL) - { - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* udpLocalAddress */ - { - ip_addr_t *dst = (ip_addr_t*)value; - *dst = pcb->local_ip; - } - break; - case 2: /* udpLocalPort */ - { - s32_t *sint_ptr = (s32_t*)value; - *sint_ptr = pcb->local_port; - } - break; - } - } -} - -static void -snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) -{ - /* return to object name, adding index depth (1) */ - ident_len += 1; - ident -= 1; - if (ident_len == 2) - { - u8_t id; - - od->id_inst_len = ident_len; - od->id_inst_ptr = ident; - - LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); - id = (u8_t)ident[0]; - switch (id) - { - case 1: /* snmpInPkts */ - case 2: /* snmpOutPkts */ - case 3: /* snmpInBadVersions */ - case 4: /* snmpInBadCommunityNames */ - case 5: /* snmpInBadCommunityUses */ - case 6: /* snmpInASNParseErrs */ - case 8: /* snmpInTooBigs */ - case 9: /* snmpInNoSuchNames */ - case 10: /* snmpInBadValues */ - case 11: /* snmpInReadOnlys */ - case 12: /* snmpInGenErrs */ - case 13: /* snmpInTotalReqVars */ - case 14: /* snmpInTotalSetVars */ - case 15: /* snmpInGetRequests */ - case 16: /* snmpInGetNexts */ - case 17: /* snmpInSetRequests */ - case 18: /* snmpInGetResponses */ - case 19: /* snmpInTraps */ - case 20: /* snmpOutTooBigs */ - case 21: /* snmpOutNoSuchNames */ - case 22: /* snmpOutBadValues */ - case 24: /* snmpOutGenErrs */ - case 25: /* snmpOutGetRequests */ - case 26: /* snmpOutGetNexts */ - case 27: /* snmpOutSetRequests */ - case 28: /* snmpOutGetResponses */ - case 29: /* snmpOutTraps */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_ONLY; - od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER); - od->v_len = sizeof(u32_t); - break; - case 30: /* snmpEnableAuthenTraps */ - od->instance = MIB_OBJECT_SCALAR; - od->access = MIB_OBJECT_READ_WRITE; - od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); - od->v_len = sizeof(s32_t); - break; - default: - LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no such object\n")); - od->instance = MIB_OBJECT_NONE; - break; - }; - } - else - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no scalar\n")); - od->instance = MIB_OBJECT_NONE; - } -} - -static void -snmp_get_value(struct obj_def *od, u16_t len, void *value) -{ - u32_t *uint_ptr = (u32_t*)value; - u8_t id; - - LWIP_UNUSED_ARG(len); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - switch (id) - { - case 1: /* snmpInPkts */ - *uint_ptr = snmpinpkts; - break; - case 2: /* snmpOutPkts */ - *uint_ptr = snmpoutpkts; - break; - case 3: /* snmpInBadVersions */ - *uint_ptr = snmpinbadversions; - break; - case 4: /* snmpInBadCommunityNames */ - *uint_ptr = snmpinbadcommunitynames; - break; - case 5: /* snmpInBadCommunityUses */ - *uint_ptr = snmpinbadcommunityuses; - break; - case 6: /* snmpInASNParseErrs */ - *uint_ptr = snmpinasnparseerrs; - break; - case 8: /* snmpInTooBigs */ - *uint_ptr = snmpintoobigs; - break; - case 9: /* snmpInNoSuchNames */ - *uint_ptr = snmpinnosuchnames; - break; - case 10: /* snmpInBadValues */ - *uint_ptr = snmpinbadvalues; - break; - case 11: /* snmpInReadOnlys */ - *uint_ptr = snmpinreadonlys; - break; - case 12: /* snmpInGenErrs */ - *uint_ptr = snmpingenerrs; - break; - case 13: /* snmpInTotalReqVars */ - *uint_ptr = snmpintotalreqvars; - break; - case 14: /* snmpInTotalSetVars */ - *uint_ptr = snmpintotalsetvars; - break; - case 15: /* snmpInGetRequests */ - *uint_ptr = snmpingetrequests; - break; - case 16: /* snmpInGetNexts */ - *uint_ptr = snmpingetnexts; - break; - case 17: /* snmpInSetRequests */ - *uint_ptr = snmpinsetrequests; - break; - case 18: /* snmpInGetResponses */ - *uint_ptr = snmpingetresponses; - break; - case 19: /* snmpInTraps */ - *uint_ptr = snmpintraps; - break; - case 20: /* snmpOutTooBigs */ - *uint_ptr = snmpouttoobigs; - break; - case 21: /* snmpOutNoSuchNames */ - *uint_ptr = snmpoutnosuchnames; - break; - case 22: /* snmpOutBadValues */ - *uint_ptr = snmpoutbadvalues; - break; - case 24: /* snmpOutGenErrs */ - *uint_ptr = snmpoutgenerrs; - break; - case 25: /* snmpOutGetRequests */ - *uint_ptr = snmpoutgetrequests; - break; - case 26: /* snmpOutGetNexts */ - *uint_ptr = snmpoutgetnexts; - break; - case 27: /* snmpOutSetRequests */ - *uint_ptr = snmpoutsetrequests; - break; - case 28: /* snmpOutGetResponses */ - *uint_ptr = snmpoutgetresponses; - break; - case 29: /* snmpOutTraps */ - *uint_ptr = snmpouttraps; - break; - case 30: /* snmpEnableAuthenTraps */ - *uint_ptr = *snmpenableauthentraps_ptr; - break; - }; -} - -/** - * Test snmp object value before setting. - * - * @param od is the object definition - * @param len return value space (in bytes) - * @param value points to (varbind) space to copy value from. - */ -static u8_t -snmp_set_test(struct obj_def *od, u16_t len, void *value) -{ - u8_t id, set_ok; - - LWIP_UNUSED_ARG(len); - set_ok = 0; - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - if (id == 30) - { - /* snmpEnableAuthenTraps */ - s32_t *sint_ptr = (s32_t*)value; - - if (snmpenableauthentraps_ptr != &snmpenableauthentraps_default) - { - /* we should have writable non-volatile mem here */ - if ((*sint_ptr == 1) || (*sint_ptr == 2)) - { - set_ok = 1; - } - } - else - { - /* const or hardwired value */ - if (*sint_ptr == snmpenableauthentraps_default) - { - set_ok = 1; - } - } - } - return set_ok; -} - -static void -snmp_set_value(struct obj_def *od, u16_t len, void *value) -{ - u8_t id; - - LWIP_UNUSED_ARG(len); - LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); - id = (u8_t)od->id_inst_ptr[0]; - if (id == 30) - { - /* snmpEnableAuthenTraps */ - /* @todo @fixme: which kind of pointer is 'value'? s32_t or u8_t??? */ - u8_t *ptr = (u8_t*)value; - *snmpenableauthentraps_ptr = *ptr; - } -} - -#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/mib_structs.c b/user/mpy/lib/lwip/src/core/snmp/mib_structs.c deleted file mode 100644 index 2f185cb..0000000 --- a/user/mpy/lib/lwip/src/core/snmp/mib_structs.c +++ /dev/null @@ -1,1174 +0,0 @@ -/** - * @file - * MIB tree access/construction functions. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp_structs.h" -#include "lwip/memp.h" -#include "lwip/netif.h" - -/** .iso.org.dod.internet address prefix, @see snmp_iso_*() */ -const s32_t prefix[4] = {1, 3, 6, 1}; - -#define NODE_STACK_SIZE (LWIP_SNMP_OBJ_ID_LEN) -/** node stack entry (old news?) */ -struct nse -{ - /** right child */ - struct mib_node* r_ptr; - /** right child identifier */ - s32_t r_id; - /** right child next level */ - u8_t r_nl; -}; -static u8_t node_stack_cnt; -static struct nse node_stack[NODE_STACK_SIZE]; - -/** - * Pushes nse struct onto stack. - */ -static void -push_node(struct nse* node) -{ - LWIP_ASSERT("node_stack_cnt < NODE_STACK_SIZE",node_stack_cnt < NODE_STACK_SIZE); - LWIP_DEBUGF(SNMP_MIB_DEBUG,("push_node() node=%p id=%"S32_F"\n",(void*)(node->r_ptr),node->r_id)); - if (node_stack_cnt < NODE_STACK_SIZE) - { - node_stack[node_stack_cnt] = *node; - node_stack_cnt++; - } -} - -/** - * Pops nse struct from stack. - */ -static void -pop_node(struct nse* node) -{ - if (node_stack_cnt > 0) - { - node_stack_cnt--; - *node = node_stack[node_stack_cnt]; - } - LWIP_DEBUGF(SNMP_MIB_DEBUG,("pop_node() node=%p id=%"S32_F"\n",(void *)(node->r_ptr),node->r_id)); -} - -/** - * Conversion from ifIndex to lwIP netif - * @param ifindex is a s32_t object sub-identifier - * @param netif points to returned netif struct pointer - */ -void -snmp_ifindextonetif(s32_t ifindex, struct netif **netif) -{ - struct netif *nif = netif_list; - s32_t i, ifidx; - - ifidx = ifindex - 1; - i = 0; - while ((nif != NULL) && (i < ifidx)) - { - nif = nif->next; - i++; - } - *netif = nif; -} - -/** - * Conversion from lwIP netif to ifIndex - * @param netif points to a netif struct - * @param ifidx points to s32_t object sub-identifier - */ -void -snmp_netiftoifindex(struct netif *netif, s32_t *ifidx) -{ - struct netif *nif = netif_list; - u16_t i; - - i = 0; - while ((nif != NULL) && (nif != netif)) - { - nif = nif->next; - i++; - } - *ifidx = i+1; -} - -/** - * Conversion from oid to lwIP ip_addr - * @param ident points to s32_t ident[4] input - * @param ip points to output struct - */ -void -snmp_oidtoip(s32_t *ident, ip_addr_t *ip) -{ - IP4_ADDR(ip, ident[0], ident[1], ident[2], ident[3]); -} - -/** - * Conversion from lwIP ip_addr to oid - * @param ip points to input struct - * @param ident points to s32_t ident[4] output - */ -void -snmp_iptooid(ip_addr_t *ip, s32_t *ident) -{ - ident[0] = ip4_addr1(ip); - ident[1] = ip4_addr2(ip); - ident[2] = ip4_addr3(ip); - ident[3] = ip4_addr4(ip); -} - -struct mib_list_node * -snmp_mib_ln_alloc(s32_t id) -{ - struct mib_list_node *ln; - - ln = (struct mib_list_node *)memp_malloc(MEMP_SNMP_NODE); - if (ln != NULL) - { - ln->prev = NULL; - ln->next = NULL; - ln->objid = id; - ln->nptr = NULL; - } - return ln; -} - -void -snmp_mib_ln_free(struct mib_list_node *ln) -{ - memp_free(MEMP_SNMP_NODE, ln); -} - -struct mib_list_rootnode * -snmp_mib_lrn_alloc(void) -{ - struct mib_list_rootnode *lrn; - - lrn = (struct mib_list_rootnode*)memp_malloc(MEMP_SNMP_ROOTNODE); - if (lrn != NULL) - { - lrn->get_object_def = noleafs_get_object_def; - lrn->get_value = noleafs_get_value; - lrn->set_test = noleafs_set_test; - lrn->set_value = noleafs_set_value; - lrn->node_type = MIB_NODE_LR; - lrn->maxlength = 0; - lrn->head = NULL; - lrn->tail = NULL; - lrn->count = 0; - } - return lrn; -} - -void -snmp_mib_lrn_free(struct mib_list_rootnode *lrn) -{ - memp_free(MEMP_SNMP_ROOTNODE, lrn); -} - -/** - * Inserts node in idx list in a sorted - * (ascending order) fashion and - * allocates the node if needed. - * - * @param rn points to the root node - * @param objid is the object sub identifier - * @param insn points to a pointer to the inserted node - * used for constructing the tree. - * @return -1 if failed, 1 if inserted, 2 if present. - */ -s8_t -snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn) -{ - struct mib_list_node *nn; - s8_t insert; - - LWIP_ASSERT("rn != NULL",rn != NULL); - - /* -1 = malloc failure, 0 = not inserted, 1 = inserted, 2 = was present */ - insert = 0; - if (rn->head == NULL) - { - /* empty list, add first node */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc empty list objid==%"S32_F"\n",objid)); - nn = snmp_mib_ln_alloc(objid); - if (nn != NULL) - { - rn->head = nn; - rn->tail = nn; - *insn = nn; - insert = 1; - } - else - { - insert = -1; - } - } - else - { - struct mib_list_node *n; - /* at least one node is present */ - n = rn->head; - while ((n != NULL) && (insert == 0)) - { - if (n->objid == objid) - { - /* node is already there */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("node already there objid==%"S32_F"\n",objid)); - *insn = n; - insert = 2; - } - else if (n->objid < objid) - { - if (n->next == NULL) - { - /* alloc and insert at the tail */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc ins tail objid==%"S32_F"\n",objid)); - nn = snmp_mib_ln_alloc(objid); - if (nn != NULL) - { - nn->next = NULL; - nn->prev = n; - n->next = nn; - rn->tail = nn; - *insn = nn; - insert = 1; - } - else - { - /* insertion failure */ - insert = -1; - } - } - else - { - /* there's more to explore: traverse list */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("traverse list\n")); - n = n->next; - } - } - else - { - /* n->objid > objid */ - /* alloc and insert between n->prev and n */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc ins n->prev, objid==%"S32_F", n\n",objid)); - nn = snmp_mib_ln_alloc(objid); - if (nn != NULL) - { - if (n->prev == NULL) - { - /* insert at the head */ - nn->next = n; - nn->prev = NULL; - rn->head = nn; - n->prev = nn; - } - else - { - /* insert in the middle */ - nn->next = n; - nn->prev = n->prev; - n->prev->next = nn; - n->prev = nn; - } - *insn = nn; - insert = 1; - } - else - { - /* insertion failure */ - insert = -1; - } - } - } - } - if (insert == 1) - { - rn->count += 1; - } - LWIP_ASSERT("insert != 0",insert != 0); - return insert; -} - -/** - * Finds node in idx list and returns deletion mark. - * - * @param rn points to the root node - * @param objid is the object sub identifier - * @param fn returns pointer to found node - * @return 0 if not found, 1 if deletable, - * 2 can't delete (2 or more children), 3 not a list_node - */ -s8_t -snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn) -{ - s8_t fc; - struct mib_list_node *n; - - LWIP_ASSERT("rn != NULL",rn != NULL); - n = rn->head; - while ((n != NULL) && (n->objid != objid)) - { - n = n->next; - } - if (n == NULL) - { - fc = 0; - } - else if (n->nptr == NULL) - { - /* leaf, can delete node */ - fc = 1; - } - else - { - struct mib_list_rootnode *r; - - if (n->nptr->node_type == MIB_NODE_LR) - { - r = (struct mib_list_rootnode *)n->nptr; - if (r->count > 1) - { - /* can't delete node */ - fc = 2; - } - else - { - /* count <= 1, can delete node */ - fc = 1; - } - } - else - { - /* other node type */ - fc = 3; - } - } - *fn = n; - return fc; -} - -/** - * Removes node from idx list - * if it has a single child left. - * - * @param rn points to the root node - * @param n points to the node to delete - * @return the nptr to be freed by caller - */ -struct mib_list_rootnode * -snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n) -{ - struct mib_list_rootnode *next; - - LWIP_ASSERT("rn != NULL",rn != NULL); - LWIP_ASSERT("n != NULL",n != NULL); - - /* caller must remove this sub-tree */ - next = (struct mib_list_rootnode*)(n->nptr); - rn->count -= 1; - - if (n == rn->head) - { - rn->head = n->next; - if (n->next != NULL) - { - /* not last node, new list begin */ - n->next->prev = NULL; - } - } - else if (n == rn->tail) - { - rn->tail = n->prev; - if (n->prev != NULL) - { - /* not last node, new list end */ - n->prev->next = NULL; - } - } - else - { - /* node must be in the middle */ - n->prev->next = n->next; - n->next->prev = n->prev; - } - LWIP_DEBUGF(SNMP_MIB_DEBUG,("free list objid==%"S32_F"\n",n->objid)); - snmp_mib_ln_free(n); - if (rn->count == 0) - { - rn->head = NULL; - rn->tail = NULL; - } - return next; -} - - - -/** - * Searches tree for the supplied (scalar?) object identifier. - * - * @param node points to the root of the tree ('.internet') - * @param ident_len the length of the supplied object identifier - * @param ident points to the array of sub identifiers - * @param np points to the found object instance (return) - * @return pointer to the requested parent (!) node if success, NULL otherwise - */ -struct mib_node * -snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np) -{ - u8_t node_type, ext_level; - - ext_level = 0; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("node==%p *ident==%"S32_F"\n",(void*)node,*ident)); - while (node != NULL) - { - node_type = node->node_type; - if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA)) - { - struct mib_array_node *an; - u16_t i; - - if (ident_len > 0) - { - /* array node (internal ROM or RAM, fixed length) */ - an = (struct mib_array_node *)node; - i = 0; - while ((i < an->maxlength) && (an->objid[i] != *ident)) - { - i++; - } - if (i < an->maxlength) - { - /* found it, if available proceed to child, otherwise inspect leaf */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->objid[i],*ident)); - if (an->nptr[i] == NULL) - { - /* a scalar leaf OR table, - inspect remaining instance number / table index */ - np->ident_len = ident_len; - np->ident = ident; - return (struct mib_node*)an; - } - else - { - /* follow next child pointer */ - ident++; - ident_len--; - node = an->nptr[i]; - } - } - else - { - /* search failed, identifier mismatch (nosuchname) */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("an search failed *ident==%"S32_F"\n",*ident)); - return NULL; - } - } - else - { - /* search failed, short object identifier (nosuchname) */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("an search failed, short object identifier\n")); - return NULL; - } - } - else if(node_type == MIB_NODE_LR) - { - struct mib_list_rootnode *lrn; - struct mib_list_node *ln; - - if (ident_len > 0) - { - /* list root node (internal 'RAM', variable length) */ - lrn = (struct mib_list_rootnode *)node; - ln = lrn->head; - /* iterate over list, head to tail */ - while ((ln != NULL) && (ln->objid != *ident)) - { - ln = ln->next; - } - if (ln != NULL) - { - /* found it, proceed to child */; - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln->objid==%"S32_F" *ident==%"S32_F"\n",ln->objid,*ident)); - if (ln->nptr == NULL) - { - np->ident_len = ident_len; - np->ident = ident; - return (struct mib_node*)lrn; - } - else - { - /* follow next child pointer */ - ident_len--; - ident++; - node = ln->nptr; - } - } - else - { - /* search failed */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln search failed *ident==%"S32_F"\n",*ident)); - return NULL; - } - } - else - { - /* search failed, short object identifier (nosuchname) */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln search failed, short object identifier\n")); - return NULL; - } - } - else if(node_type == MIB_NODE_EX) - { - struct mib_external_node *en; - u16_t i, len; - - if (ident_len > 0) - { - /* external node (addressing and access via functions) */ - en = (struct mib_external_node *)node; - - i = 0; - len = en->level_length(en->addr_inf,ext_level); - while ((i < len) && (en->ident_cmp(en->addr_inf,ext_level,i,*ident) != 0)) - { - i++; - } - if (i < len) - { - s32_t debug_id; - - en->get_objid(en->addr_inf,ext_level,i,&debug_id); - LWIP_DEBUGF(SNMP_MIB_DEBUG,("en->objid==%"S32_F" *ident==%"S32_F"\n",debug_id,*ident)); - if ((ext_level + 1) == en->tree_levels) - { - np->ident_len = ident_len; - np->ident = ident; - return (struct mib_node*)en; - } - else - { - /* found it, proceed to child */ - ident_len--; - ident++; - ext_level++; - } - } - else - { - /* search failed */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("en search failed *ident==%"S32_F"\n",*ident)); - return NULL; - } - } - else - { - /* search failed, short object identifier (nosuchname) */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("en search failed, short object identifier\n")); - return NULL; - } - } - else if (node_type == MIB_NODE_SC) - { - mib_scalar_node *sn; - - sn = (mib_scalar_node *)node; - if ((ident_len == 1) && (*ident == 0)) - { - np->ident_len = ident_len; - np->ident = ident; - return (struct mib_node*)sn; - } - else - { - /* search failed, short object identifier (nosuchname) */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed, invalid object identifier length\n")); - return NULL; - } - } - else - { - /* unknown node_type */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed node_type %"U16_F" unkown\n",(u16_t)node_type)); - return NULL; - } - } - /* done, found nothing */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed node==%p\n",(void*)node)); - return NULL; -} - -/** - * Test table for presence of at least one table entry. - */ -static u8_t -empty_table(struct mib_node *node) -{ - u8_t node_type; - u8_t empty = 0; - - if (node != NULL) - { - node_type = node->node_type; - if (node_type == MIB_NODE_LR) - { - struct mib_list_rootnode *lrn; - lrn = (struct mib_list_rootnode *)node; - if ((lrn->count == 0) || (lrn->head == NULL)) - { - empty = 1; - } - } - else if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA)) - { - struct mib_array_node *an; - an = (struct mib_array_node *)node; - if ((an->maxlength == 0) || (an->nptr == NULL)) - { - empty = 1; - } - } - else if (node_type == MIB_NODE_EX) - { - struct mib_external_node *en; - en = (struct mib_external_node *)node; - if (en->tree_levels == 0) - { - empty = 1; - } - } - } - return empty; -} - -/** - * Tree expansion. - */ -struct mib_node * -snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret) -{ - u8_t node_type, ext_level, climb_tree; - - ext_level = 0; - /* reset node stack */ - node_stack_cnt = 0; - while (node != NULL) - { - climb_tree = 0; - node_type = node->node_type; - if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA)) - { - struct mib_array_node *an; - u16_t i; - - /* array node (internal ROM or RAM, fixed length) */ - an = (struct mib_array_node *)node; - if (ident_len > 0) - { - i = 0; - while ((i < an->maxlength) && (an->objid[i] < *ident)) - { - i++; - } - if (i < an->maxlength) - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->objid[i],*ident)); - /* add identifier to oidret */ - oidret->id[oidret->len] = an->objid[i]; - (oidret->len)++; - - if (an->nptr[i] == NULL) - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n")); - /* leaf node (e.g. in a fixed size table) */ - if (an->objid[i] > *ident) - { - return (struct mib_node*)an; - } - else if ((i + 1) < an->maxlength) - { - /* an->objid[i] == *ident */ - (oidret->len)--; - oidret->id[oidret->len] = an->objid[i + 1]; - (oidret->len)++; - return (struct mib_node*)an; - } - else - { - /* (i + 1) == an->maxlength */ - (oidret->len)--; - climb_tree = 1; - } - } - else - { - u8_t j; - struct nse cur_node; - - LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n")); - /* non-leaf, store right child ptr and id */ - LWIP_ASSERT("i < 0xff", i < 0xff); - j = (u8_t)i + 1; - while ((j < an->maxlength) && (empty_table(an->nptr[j]))) - { - j++; - } - if (j < an->maxlength) - { - cur_node.r_ptr = an->nptr[j]; - cur_node.r_id = an->objid[j]; - cur_node.r_nl = 0; - } - else - { - cur_node.r_ptr = NULL; - } - push_node(&cur_node); - if (an->objid[i] == *ident) - { - ident_len--; - ident++; - } - else - { - /* an->objid[i] < *ident */ - ident_len = 0; - } - /* follow next child pointer */ - node = an->nptr[i]; - } - } - else - { - /* i == an->maxlength */ - climb_tree = 1; - } - } - else - { - u8_t j; - /* ident_len == 0, complete with leftmost '.thing' */ - j = 0; - while ((j < an->maxlength) && empty_table(an->nptr[j])) - { - j++; - } - if (j < an->maxlength) - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("left an->objid[j]==%"S32_F"\n",an->objid[j])); - oidret->id[oidret->len] = an->objid[j]; - (oidret->len)++; - if (an->nptr[j] == NULL) - { - /* leaf node */ - return (struct mib_node*)an; - } - else - { - /* no leaf, continue */ - node = an->nptr[j]; - } - } - else - { - /* j == an->maxlength */ - climb_tree = 1; - } - } - } - else if(node_type == MIB_NODE_LR) - { - struct mib_list_rootnode *lrn; - struct mib_list_node *ln; - - /* list root node (internal 'RAM', variable length) */ - lrn = (struct mib_list_rootnode *)node; - if (ident_len > 0) - { - ln = lrn->head; - /* iterate over list, head to tail */ - while ((ln != NULL) && (ln->objid < *ident)) - { - ln = ln->next; - } - if (ln != NULL) - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("ln->objid==%"S32_F" *ident==%"S32_F"\n",ln->objid,*ident)); - oidret->id[oidret->len] = ln->objid; - (oidret->len)++; - if (ln->nptr == NULL) - { - /* leaf node */ - if (ln->objid > *ident) - { - return (struct mib_node*)lrn; - } - else if (ln->next != NULL) - { - /* ln->objid == *ident */ - (oidret->len)--; - oidret->id[oidret->len] = ln->next->objid; - (oidret->len)++; - return (struct mib_node*)lrn; - } - else - { - /* ln->next == NULL */ - (oidret->len)--; - climb_tree = 1; - } - } - else - { - struct mib_list_node *jn; - struct nse cur_node; - - /* non-leaf, store right child ptr and id */ - jn = ln->next; - while ((jn != NULL) && empty_table(jn->nptr)) - { - jn = jn->next; - } - if (jn != NULL) - { - cur_node.r_ptr = jn->nptr; - cur_node.r_id = jn->objid; - cur_node.r_nl = 0; - } - else - { - cur_node.r_ptr = NULL; - } - push_node(&cur_node); - if (ln->objid == *ident) - { - ident_len--; - ident++; - } - else - { - /* ln->objid < *ident */ - ident_len = 0; - } - /* follow next child pointer */ - node = ln->nptr; - } - - } - else - { - /* ln == NULL */ - climb_tree = 1; - } - } - else - { - struct mib_list_node *jn; - /* ident_len == 0, complete with leftmost '.thing' */ - jn = lrn->head; - while ((jn != NULL) && empty_table(jn->nptr)) - { - jn = jn->next; - } - if (jn != NULL) - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("left jn->objid==%"S32_F"\n",jn->objid)); - oidret->id[oidret->len] = jn->objid; - (oidret->len)++; - if (jn->nptr == NULL) - { - /* leaf node */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("jn->nptr == NULL\n")); - return (struct mib_node*)lrn; - } - else - { - /* no leaf, continue */ - node = jn->nptr; - } - } - else - { - /* jn == NULL */ - climb_tree = 1; - } - } - } - else if(node_type == MIB_NODE_EX) - { - struct mib_external_node *en; - s32_t ex_id; - - /* external node (addressing and access via functions) */ - en = (struct mib_external_node *)node; - if (ident_len > 0) - { - u16_t i, len; - - i = 0; - len = en->level_length(en->addr_inf,ext_level); - while ((i < len) && (en->ident_cmp(en->addr_inf,ext_level,i,*ident) < 0)) - { - i++; - } - if (i < len) - { - /* add identifier to oidret */ - en->get_objid(en->addr_inf,ext_level,i,&ex_id); - LWIP_DEBUGF(SNMP_MIB_DEBUG,("en->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,ex_id,*ident)); - oidret->id[oidret->len] = ex_id; - (oidret->len)++; - - if ((ext_level + 1) == en->tree_levels) - { - LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n")); - /* leaf node */ - if (ex_id > *ident) - { - return (struct mib_node*)en; - } - else if ((i + 1) < len) - { - /* ex_id == *ident */ - en->get_objid(en->addr_inf,ext_level,i + 1,&ex_id); - (oidret->len)--; - oidret->id[oidret->len] = ex_id; - (oidret->len)++; - return (struct mib_node*)en; - } - else - { - /* (i + 1) == len */ - (oidret->len)--; - climb_tree = 1; - } - } - else - { - u8_t j; - struct nse cur_node; - - LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n")); - /* non-leaf, store right child ptr and id */ - LWIP_ASSERT("i < 0xff", i < 0xff); - j = (u8_t)i + 1; - if (j < len) - { - /* right node is the current external node */ - cur_node.r_ptr = node; - en->get_objid(en->addr_inf,ext_level,j,&cur_node.r_id); - cur_node.r_nl = ext_level + 1; - } - else - { - cur_node.r_ptr = NULL; - } - push_node(&cur_node); - if (en->ident_cmp(en->addr_inf,ext_level,i,*ident) == 0) - { - ident_len--; - ident++; - } - else - { - /* external id < *ident */ - ident_len = 0; - } - /* proceed to child */ - ext_level++; - } - } - else - { - /* i == len (en->level_len()) */ - climb_tree = 1; - } - } - else - { - /* ident_len == 0, complete with leftmost '.thing' */ - en->get_objid(en->addr_inf,ext_level,0,&ex_id); - LWIP_DEBUGF(SNMP_MIB_DEBUG,("left en->objid==%"S32_F"\n",ex_id)); - oidret->id[oidret->len] = ex_id; - (oidret->len)++; - if ((ext_level + 1) == en->tree_levels) - { - /* leaf node */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("(ext_level + 1) == en->tree_levels\n")); - return (struct mib_node*)en; - } - else - { - /* no leaf, proceed to child */ - ext_level++; - } - } - } - else if(node_type == MIB_NODE_SC) - { - mib_scalar_node *sn; - - /* scalar node */ - sn = (mib_scalar_node *)node; - if (ident_len > 0) - { - /* at .0 */ - climb_tree = 1; - } - else - { - /* ident_len == 0, complete object identifier */ - oidret->id[oidret->len] = 0; - (oidret->len)++; - /* leaf node */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("completed scalar leaf\n")); - return (struct mib_node*)sn; - } - } - else - { - /* unknown/unhandled node_type */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand failed node_type %"U16_F" unkown\n",(u16_t)node_type)); - return NULL; - } - - if (climb_tree) - { - struct nse child; - - /* find right child ptr */ - child.r_ptr = NULL; - child.r_id = 0; - child.r_nl = 0; - while ((node_stack_cnt > 0) && (child.r_ptr == NULL)) - { - pop_node(&child); - /* trim returned oid */ - (oidret->len)--; - } - if (child.r_ptr != NULL) - { - /* incoming ident is useless beyond this point */ - ident_len = 0; - oidret->id[oidret->len] = child.r_id; - oidret->len++; - node = child.r_ptr; - ext_level = child.r_nl; - } - else - { - /* tree ends here ... */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand failed, tree ends here\n")); - return NULL; - } - } - } - /* done, found nothing */ - LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand failed node==%p\n",(void*)node)); - return NULL; -} - -/** - * Test object identifier for the iso.org.dod.internet prefix. - * - * @param ident_len the length of the supplied object identifier - * @param ident points to the array of sub identifiers - * @return 1 if it matches, 0 otherwise - */ -u8_t -snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident) -{ - if ((ident_len > 3) && - (ident[0] == 1) && (ident[1] == 3) && - (ident[2] == 6) && (ident[3] == 1)) - { - return 1; - } - else - { - return 0; - } -} - -/** - * Expands object identifier to the iso.org.dod.internet - * prefix for use in getnext operation. - * - * @param ident_len the length of the supplied object identifier - * @param ident points to the array of sub identifiers - * @param oidret points to returned expanded object identifier - * @return 1 if it matches, 0 otherwise - * - * @note ident_len 0 is allowed, expanding to the first known object id!! - */ -u8_t -snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret) -{ - const s32_t *prefix_ptr; - s32_t *ret_ptr; - u8_t i; - - i = 0; - prefix_ptr = &prefix[0]; - ret_ptr = &oidret->id[0]; - ident_len = ((ident_len < 4)?ident_len:4); - while ((i < ident_len) && ((*ident) <= (*prefix_ptr))) - { - *ret_ptr++ = *prefix_ptr++; - ident++; - i++; - } - if (i == ident_len) - { - /* match, complete missing bits */ - while (i < 4) - { - *ret_ptr++ = *prefix_ptr++; - i++; - } - oidret->len = i; - return 1; - } - else - { - /* i != ident_len */ - return 0; - } -} - -#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/msg_in.c b/user/mpy/lib/lwip/src/core/snmp/msg_in.c deleted file mode 100644 index be940c6..0000000 --- a/user/mpy/lib/lwip/src/core/snmp/msg_in.c +++ /dev/null @@ -1,1453 +0,0 @@ -/** - * @file - * SNMP input message processing (RFC1157). - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp.h" -#include "lwip/snmp_asn1.h" -#include "lwip/snmp_msg.h" -#include "lwip/snmp_structs.h" -#include "lwip/ip_addr.h" -#include "lwip/memp.h" -#include "lwip/udp.h" -#include "lwip/stats.h" - -#include - -/* public (non-static) constants */ -/** SNMP v1 == 0 */ -const s32_t snmp_version = 0; -/** default SNMP community string */ -const char snmp_publiccommunity[7] = "public"; - -/* statically allocated buffers for SNMP_CONCURRENT_REQUESTS */ -struct snmp_msg_pstat msg_input_list[SNMP_CONCURRENT_REQUESTS]; -/* UDP Protocol Control Block */ -struct udp_pcb *snmp1_pcb; - -static void snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); -static err_t snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat); -static err_t snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat); - - -/** - * Starts SNMP Agent. - * Allocates UDP pcb and binds it to IP_ADDR_ANY port 161. - */ -void -snmp_init(void) -{ - struct snmp_msg_pstat *msg_ps; - u8_t i; - - snmp1_pcb = udp_new(); - if (snmp1_pcb != NULL) - { - udp_recv(snmp1_pcb, snmp_recv, (void *)SNMP_IN_PORT); - udp_bind(snmp1_pcb, IP_ADDR_ANY, SNMP_IN_PORT); - } - msg_ps = &msg_input_list[0]; - for (i=0; istate = SNMP_MSG_EMPTY; - msg_ps->error_index = 0; - msg_ps->error_status = SNMP_ES_NOERROR; - msg_ps++; - } - trap_msg.pcb = snmp1_pcb; - -#ifdef SNMP_PRIVATE_MIB_INIT - /* If defined, this must be a function-like define to initialize the - * private MIB after the stack has been initialized. - * The private MIB can also be initialized in tcpip_callback (or after - * the stack is initialized), this define is only for convenience. */ - SNMP_PRIVATE_MIB_INIT(); -#endif /* SNMP_PRIVATE_MIB_INIT */ - - /* The coldstart trap will only be output - if our outgoing interface is up & configured */ - snmp_coldstart_trap(); -} - -static void -snmp_error_response(struct snmp_msg_pstat *msg_ps, u8_t error) -{ - /* move names back from outvb to invb */ - int v; - struct snmp_varbind *vbi = msg_ps->invb.head; - struct snmp_varbind *vbo = msg_ps->outvb.head; - for (v=0; vvb_idx; v++) { - vbi->ident_len = vbo->ident_len; - vbo->ident_len = 0; - vbi->ident = vbo->ident; - vbo->ident = NULL; - vbi = vbi->next; - vbo = vbo->next; - } - /* free outvb */ - snmp_varbind_list_free(&msg_ps->outvb); - /* we send invb back */ - msg_ps->outvb = msg_ps->invb; - msg_ps->invb.head = NULL; - msg_ps->invb.tail = NULL; - msg_ps->invb.count = 0; - msg_ps->error_status = error; - /* error index must be 0 for error too big */ - msg_ps->error_index = (error != SNMP_ES_TOOBIG) ? (1 + msg_ps->vb_idx) : 0; - snmp_send_response(msg_ps); - snmp_varbind_list_free(&msg_ps->outvb); - msg_ps->state = SNMP_MSG_EMPTY; -} - -static void -snmp_ok_response(struct snmp_msg_pstat *msg_ps) -{ - err_t err_ret; - - err_ret = snmp_send_response(msg_ps); - if (err_ret == ERR_MEM) - { - /* serious memory problem, can't return tooBig */ - } - else - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event = %"S32_F"\n",msg_ps->error_status)); - } - /* free varbinds (if available) */ - snmp_varbind_list_free(&msg_ps->invb); - snmp_varbind_list_free(&msg_ps->outvb); - msg_ps->state = SNMP_MSG_EMPTY; -} - -/** - * Service an internal or external event for SNMP GET. - * - * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) - * @param msg_ps points to the assosicated message process state - */ -static void -snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps) -{ - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_get_event: msg_ps->state==%"U16_F"\n",(u16_t)msg_ps->state)); - - if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF) - { - struct mib_external_node *en; - struct snmp_name_ptr np; - - /* get_object_def() answer*/ - en = msg_ps->ext_mib_node; - np = msg_ps->ext_name_ptr; - - /* translate answer into a known lifeform */ - en->get_object_def_a(request_id, np.ident_len, np.ident, &msg_ps->ext_object_def); - if ((msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) && - (msg_ps->ext_object_def.access & MIB_ACCESS_READ)) - { - msg_ps->state = SNMP_MSG_EXTERNAL_GET_VALUE; - en->get_value_q(request_id, &msg_ps->ext_object_def); - } - else - { - en->get_object_def_pc(request_id, np.ident_len, np.ident); - /* search failed, object id points to unknown object (nosuchname) */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - else if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_VALUE) - { - struct mib_external_node *en; - struct snmp_varbind *vb; - - /* get_value() answer */ - en = msg_ps->ext_mib_node; - - /* allocate output varbind */ - vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND); - if (vb != NULL) - { - vb->next = NULL; - vb->prev = NULL; - - /* move name from invb to outvb */ - vb->ident = msg_ps->vb_ptr->ident; - vb->ident_len = msg_ps->vb_ptr->ident_len; - /* ensure this memory is refereced once only */ - msg_ps->vb_ptr->ident = NULL; - msg_ps->vb_ptr->ident_len = 0; - - vb->value_type = msg_ps->ext_object_def.asn_type; - LWIP_ASSERT("invalid length", msg_ps->ext_object_def.v_len <= 0xff); - vb->value_len = (u8_t)msg_ps->ext_object_def.v_len; - if (vb->value_len > 0) - { - LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE); - vb->value = memp_malloc(MEMP_SNMP_VALUE); - if (vb->value != NULL) - { - en->get_value_a(request_id, &msg_ps->ext_object_def, vb->value_len, vb->value); - snmp_varbind_tail_add(&msg_ps->outvb, vb); - /* search again (if vb_idx < msg_ps->invb.count) */ - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - else - { - en->get_value_pc(request_id, &msg_ps->ext_object_def); - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: no variable space\n")); - msg_ps->vb_ptr->ident = vb->ident; - msg_ps->vb_ptr->ident_len = vb->ident_len; - memp_free(MEMP_SNMP_VARBIND, vb); - snmp_error_response(msg_ps,SNMP_ES_TOOBIG); - } - } - else - { - /* vb->value_len == 0, empty value (e.g. empty string) */ - en->get_value_a(request_id, &msg_ps->ext_object_def, 0, NULL); - vb->value = NULL; - snmp_varbind_tail_add(&msg_ps->outvb, vb); - /* search again (if vb_idx < msg_ps->invb.count) */ - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - } - else - { - en->get_value_pc(request_id, &msg_ps->ext_object_def); - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: no outvb space\n")); - snmp_error_response(msg_ps,SNMP_ES_TOOBIG); - } - } - - while ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && - (msg_ps->vb_idx < msg_ps->invb.count)) - { - struct mib_node *mn; - struct snmp_name_ptr np; - - if (msg_ps->vb_idx == 0) - { - msg_ps->vb_ptr = msg_ps->invb.head; - } - else - { - msg_ps->vb_ptr = msg_ps->vb_ptr->next; - } - /** test object identifier for .iso.org.dod.internet prefix */ - if (snmp_iso_prefix_tst(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident)) - { - mn = snmp_search_tree((struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4, - msg_ps->vb_ptr->ident + 4, &np); - if (mn != NULL) - { - if (mn->node_type == MIB_NODE_EX) - { - /* external object */ - struct mib_external_node *en = (struct mib_external_node*)mn; - - msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF; - /* save en && args in msg_ps!! */ - msg_ps->ext_mib_node = en; - msg_ps->ext_name_ptr = np; - - en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident); - } - else - { - /* internal object */ - struct obj_def object_def; - - msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF; - mn->get_object_def(np.ident_len, np.ident, &object_def); - if ((object_def.instance != MIB_OBJECT_NONE) && - (object_def.access & MIB_ACCESS_READ)) - { - mn = mn; - } - else - { - /* search failed, object id points to unknown object (nosuchname) */ - mn = NULL; - } - if (mn != NULL) - { - struct snmp_varbind *vb; - - msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE; - /* allocate output varbind */ - vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND); - if (vb != NULL) - { - vb->next = NULL; - vb->prev = NULL; - - /* move name from invb to outvb */ - vb->ident = msg_ps->vb_ptr->ident; - vb->ident_len = msg_ps->vb_ptr->ident_len; - /* ensure this memory is refereced once only */ - msg_ps->vb_ptr->ident = NULL; - msg_ps->vb_ptr->ident_len = 0; - - vb->value_type = object_def.asn_type; - LWIP_ASSERT("invalid length", object_def.v_len <= 0xff); - vb->value_len = (u8_t)object_def.v_len; - if (vb->value_len > 0) - { - LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", - vb->value_len <= SNMP_MAX_VALUE_SIZE); - vb->value = memp_malloc(MEMP_SNMP_VALUE); - if (vb->value != NULL) - { - mn->get_value(&object_def, vb->value_len, vb->value); - snmp_varbind_tail_add(&msg_ps->outvb, vb); - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - else - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: couldn't allocate variable space\n")); - msg_ps->vb_ptr->ident = vb->ident; - msg_ps->vb_ptr->ident_len = vb->ident_len; - vb->ident = NULL; - vb->ident_len = 0; - memp_free(MEMP_SNMP_VARBIND, vb); - snmp_error_response(msg_ps,SNMP_ES_TOOBIG); - } - } - else - { - /* vb->value_len == 0, empty value (e.g. empty string) */ - vb->value = NULL; - snmp_varbind_tail_add(&msg_ps->outvb, vb); - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - } - else - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: couldn't allocate outvb space\n")); - snmp_error_response(msg_ps,SNMP_ES_TOOBIG); - } - } - } - } - } - else - { - mn = NULL; - } - if (mn == NULL) - { - /* mn == NULL, noSuchName */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - if ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && - (msg_ps->vb_idx == msg_ps->invb.count)) - { - snmp_ok_response(msg_ps); - } -} - -/** - * Service an internal or external event for SNMP GETNEXT. - * - * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) - * @param msg_ps points to the assosicated message process state - */ -static void -snmp_msg_getnext_event(u8_t request_id, struct snmp_msg_pstat *msg_ps) -{ - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_getnext_event: msg_ps->state==%"U16_F"\n",(u16_t)msg_ps->state)); - - if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF) - { - struct mib_external_node *en; - - /* get_object_def() answer*/ - en = msg_ps->ext_mib_node; - - /* translate answer into a known lifeform */ - en->get_object_def_a(request_id, 1, &msg_ps->ext_oid.id[msg_ps->ext_oid.len - 1], &msg_ps->ext_object_def); - if (msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) - { - msg_ps->state = SNMP_MSG_EXTERNAL_GET_VALUE; - en->get_value_q(request_id, &msg_ps->ext_object_def); - } - else - { - en->get_object_def_pc(request_id, 1, &msg_ps->ext_oid.id[msg_ps->ext_oid.len - 1]); - /* search failed, object id points to unknown object (nosuchname) */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - else if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_VALUE) - { - struct mib_external_node *en; - struct snmp_varbind *vb; - - /* get_value() answer */ - en = msg_ps->ext_mib_node; - - LWIP_ASSERT("invalid length", msg_ps->ext_object_def.v_len <= 0xff); - vb = snmp_varbind_alloc(&msg_ps->ext_oid, - msg_ps->ext_object_def.asn_type, - (u8_t)msg_ps->ext_object_def.v_len); - if (vb != NULL) - { - en->get_value_a(request_id, &msg_ps->ext_object_def, vb->value_len, vb->value); - snmp_varbind_tail_add(&msg_ps->outvb, vb); - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - else - { - en->get_value_pc(request_id, &msg_ps->ext_object_def); - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_getnext_event: couldn't allocate outvb space\n")); - snmp_error_response(msg_ps,SNMP_ES_TOOBIG); - } - } - - while ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && - (msg_ps->vb_idx < msg_ps->invb.count)) - { - struct mib_node *mn; - struct snmp_obj_id oid; - - if (msg_ps->vb_idx == 0) - { - msg_ps->vb_ptr = msg_ps->invb.head; - } - else - { - msg_ps->vb_ptr = msg_ps->vb_ptr->next; - } - if (snmp_iso_prefix_expand(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident, &oid)) - { - if (msg_ps->vb_ptr->ident_len > 3) - { - /* can offset ident_len and ident */ - mn = snmp_expand_tree((struct mib_node*)&internet, - msg_ps->vb_ptr->ident_len - 4, - msg_ps->vb_ptr->ident + 4, &oid); - } - else - { - /* can't offset ident_len -4, ident + 4 */ - mn = snmp_expand_tree((struct mib_node*)&internet, 0, NULL, &oid); - } - } - else - { - mn = NULL; - } - if (mn != NULL) - { - if (mn->node_type == MIB_NODE_EX) - { - /* external object */ - struct mib_external_node *en = (struct mib_external_node*)mn; - - msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF; - /* save en && args in msg_ps!! */ - msg_ps->ext_mib_node = en; - msg_ps->ext_oid = oid; - - en->get_object_def_q(en->addr_inf, request_id, 1, &oid.id[oid.len - 1]); - } - else - { - /* internal object */ - struct obj_def object_def; - struct snmp_varbind *vb; - - msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF; - mn->get_object_def(1, &oid.id[oid.len - 1], &object_def); - - LWIP_ASSERT("invalid length", object_def.v_len <= 0xff); - vb = snmp_varbind_alloc(&oid, object_def.asn_type, (u8_t)object_def.v_len); - if (vb != NULL) - { - msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE; - mn->get_value(&object_def, object_def.v_len, vb->value); - snmp_varbind_tail_add(&msg_ps->outvb, vb); - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - else - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv couldn't allocate outvb space\n")); - snmp_error_response(msg_ps,SNMP_ES_TOOBIG); - } - } - } - if (mn == NULL) - { - /* mn == NULL, noSuchName */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - if ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && - (msg_ps->vb_idx == msg_ps->invb.count)) - { - snmp_ok_response(msg_ps); - } -} - -/** - * Service an internal or external event for SNMP SET. - * - * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) - * @param msg_ps points to the assosicated message process state - */ -static void -snmp_msg_set_event(u8_t request_id, struct snmp_msg_pstat *msg_ps) -{ - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_set_event: msg_ps->state==%"U16_F"\n",(u16_t)msg_ps->state)); - - if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF) - { - struct mib_external_node *en; - struct snmp_name_ptr np; - - /* get_object_def() answer*/ - en = msg_ps->ext_mib_node; - np = msg_ps->ext_name_ptr; - - /* translate answer into a known lifeform */ - en->get_object_def_a(request_id, np.ident_len, np.ident, &msg_ps->ext_object_def); - if (msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) - { - msg_ps->state = SNMP_MSG_EXTERNAL_SET_TEST; - en->set_test_q(request_id, &msg_ps->ext_object_def); - } - else - { - en->get_object_def_pc(request_id, np.ident_len, np.ident); - /* search failed, object id points to unknown object (nosuchname) */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - else if (msg_ps->state == SNMP_MSG_EXTERNAL_SET_TEST) - { - struct mib_external_node *en; - - /* set_test() answer*/ - en = msg_ps->ext_mib_node; - - if (msg_ps->ext_object_def.access & MIB_ACCESS_WRITE) - { - if ((msg_ps->ext_object_def.asn_type == msg_ps->vb_ptr->value_type) && - (en->set_test_a(request_id,&msg_ps->ext_object_def, - msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value) != 0)) - { - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - else - { - en->set_test_pc(request_id,&msg_ps->ext_object_def); - /* bad value */ - snmp_error_response(msg_ps,SNMP_ES_BADVALUE); - } - } - else - { - en->set_test_pc(request_id,&msg_ps->ext_object_def); - /* object not available for set */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - else if (msg_ps->state == SNMP_MSG_EXTERNAL_GET_OBJDEF_S) - { - struct mib_external_node *en; - struct snmp_name_ptr np; - - /* get_object_def() answer*/ - en = msg_ps->ext_mib_node; - np = msg_ps->ext_name_ptr; - - /* translate answer into a known lifeform */ - en->get_object_def_a(request_id, np.ident_len, np.ident, &msg_ps->ext_object_def); - if (msg_ps->ext_object_def.instance != MIB_OBJECT_NONE) - { - msg_ps->state = SNMP_MSG_EXTERNAL_SET_VALUE; - en->set_value_q(request_id, &msg_ps->ext_object_def, - msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value); - } - else - { - en->get_object_def_pc(request_id, np.ident_len, np.ident); - /* set_value failed, object has disappeared for some odd reason?? */ - snmp_error_response(msg_ps,SNMP_ES_GENERROR); - } - } - else if (msg_ps->state == SNMP_MSG_EXTERNAL_SET_VALUE) - { - struct mib_external_node *en; - - /** set_value_a() */ - en = msg_ps->ext_mib_node; - en->set_value_a(request_id, &msg_ps->ext_object_def, - msg_ps->vb_ptr->value_len, msg_ps->vb_ptr->value); - - /** @todo use set_value_pc() if toobig */ - msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE; - msg_ps->vb_idx += 1; - } - - /* test all values before setting */ - while ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && - (msg_ps->vb_idx < msg_ps->invb.count)) - { - struct mib_node *mn; - struct snmp_name_ptr np; - - if (msg_ps->vb_idx == 0) - { - msg_ps->vb_ptr = msg_ps->invb.head; - } - else - { - msg_ps->vb_ptr = msg_ps->vb_ptr->next; - } - /** test object identifier for .iso.org.dod.internet prefix */ - if (snmp_iso_prefix_tst(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident)) - { - mn = snmp_search_tree((struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4, - msg_ps->vb_ptr->ident + 4, &np); - if (mn != NULL) - { - if (mn->node_type == MIB_NODE_EX) - { - /* external object */ - struct mib_external_node *en = (struct mib_external_node*)mn; - - msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF; - /* save en && args in msg_ps!! */ - msg_ps->ext_mib_node = en; - msg_ps->ext_name_ptr = np; - - en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident); - } - else - { - /* internal object */ - struct obj_def object_def; - - msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF; - mn->get_object_def(np.ident_len, np.ident, &object_def); - if (object_def.instance != MIB_OBJECT_NONE) - { - mn = mn; - } - else - { - /* search failed, object id points to unknown object (nosuchname) */ - mn = NULL; - } - if (mn != NULL) - { - msg_ps->state = SNMP_MSG_INTERNAL_SET_TEST; - - if (object_def.access & MIB_ACCESS_WRITE) - { - if ((object_def.asn_type == msg_ps->vb_ptr->value_type) && - (mn->set_test(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value) != 0)) - { - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - msg_ps->vb_idx += 1; - } - else - { - /* bad value */ - snmp_error_response(msg_ps,SNMP_ES_BADVALUE); - } - } - else - { - /* object not available for set */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - } - } - } - else - { - mn = NULL; - } - if (mn == NULL) - { - /* mn == NULL, noSuchName */ - snmp_error_response(msg_ps,SNMP_ES_NOSUCHNAME); - } - } - - if ((msg_ps->state == SNMP_MSG_SEARCH_OBJ) && - (msg_ps->vb_idx == msg_ps->invb.count)) - { - msg_ps->vb_idx = 0; - msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE; - } - - /* set all values "atomically" (be as "atomic" as possible) */ - while ((msg_ps->state == SNMP_MSG_INTERNAL_SET_VALUE) && - (msg_ps->vb_idx < msg_ps->invb.count)) - { - struct mib_node *mn; - struct snmp_name_ptr np; - - if (msg_ps->vb_idx == 0) - { - msg_ps->vb_ptr = msg_ps->invb.head; - } - else - { - msg_ps->vb_ptr = msg_ps->vb_ptr->next; - } - /* skip iso prefix test, was done previously while settesting() */ - mn = snmp_search_tree((struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4, - msg_ps->vb_ptr->ident + 4, &np); - /* check if object is still available - (e.g. external hot-plug thingy present?) */ - if (mn != NULL) - { - if (mn->node_type == MIB_NODE_EX) - { - /* external object */ - struct mib_external_node *en = (struct mib_external_node*)mn; - - msg_ps->state = SNMP_MSG_EXTERNAL_GET_OBJDEF_S; - /* save en && args in msg_ps!! */ - msg_ps->ext_mib_node = en; - msg_ps->ext_name_ptr = np; - - en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident); - } - else - { - /* internal object */ - struct obj_def object_def; - - msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF_S; - mn->get_object_def(np.ident_len, np.ident, &object_def); - msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE; - mn->set_value(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value); - msg_ps->vb_idx += 1; - } - } - } - if ((msg_ps->state == SNMP_MSG_INTERNAL_SET_VALUE) && - (msg_ps->vb_idx == msg_ps->invb.count)) - { - /* simply echo the input if we can set it - @todo do we need to return the actual value? - e.g. if value is silently modified or behaves sticky? */ - msg_ps->outvb = msg_ps->invb; - msg_ps->invb.head = NULL; - msg_ps->invb.tail = NULL; - msg_ps->invb.count = 0; - snmp_ok_response(msg_ps); - } -} - - -/** - * Handle one internal or external event. - * Called for one async event. (recv external/private answer) - * - * @param request_id identifies requests from 0 to (SNMP_CONCURRENT_REQUESTS-1) - */ -void -snmp_msg_event(u8_t request_id) -{ - struct snmp_msg_pstat *msg_ps; - - if (request_id < SNMP_CONCURRENT_REQUESTS) - { - msg_ps = &msg_input_list[request_id]; - if (msg_ps->rt == SNMP_ASN1_PDU_GET_NEXT_REQ) - { - snmp_msg_getnext_event(request_id, msg_ps); - } - else if (msg_ps->rt == SNMP_ASN1_PDU_GET_REQ) - { - snmp_msg_get_event(request_id, msg_ps); - } - else if(msg_ps->rt == SNMP_ASN1_PDU_SET_REQ) - { - snmp_msg_set_event(request_id, msg_ps); - } - } -} - - -/* lwIP UDP receive callback function */ -static void -snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) -{ - struct snmp_msg_pstat *msg_ps; - u8_t req_idx; - err_t err_ret; - u16_t payload_len = p->tot_len; - u16_t payload_ofs = 0; - u16_t varbind_ofs = 0; - - /* suppress unused argument warning */ - LWIP_UNUSED_ARG(arg); - - /* traverse input message process list, look for SNMP_MSG_EMPTY */ - msg_ps = &msg_input_list[0]; - req_idx = 0; - while ((req_idx < SNMP_CONCURRENT_REQUESTS) && (msg_ps->state != SNMP_MSG_EMPTY)) - { - req_idx++; - msg_ps++; - } - if (req_idx == SNMP_CONCURRENT_REQUESTS) - { - /* exceeding number of concurrent requests */ - pbuf_free(p); - return; - } - - /* accepting request */ - snmp_inc_snmpinpkts(); - /* record used 'protocol control block' */ - msg_ps->pcb = pcb; - /* source address (network order) */ - msg_ps->sip = *addr; - /* source port (host order (lwIP oddity)) */ - msg_ps->sp = port; - - /* check total length, version, community, pdu type */ - err_ret = snmp_pdu_header_check(p, payload_ofs, payload_len, &varbind_ofs, msg_ps); - /* Only accept requests and requests without error (be robust) */ - /* Reject response and trap headers or error requests as input! */ - if ((err_ret != ERR_OK) || - ((msg_ps->rt != SNMP_ASN1_PDU_GET_REQ) && - (msg_ps->rt != SNMP_ASN1_PDU_GET_NEXT_REQ) && - (msg_ps->rt != SNMP_ASN1_PDU_SET_REQ)) || - ((msg_ps->error_status != SNMP_ES_NOERROR) || - (msg_ps->error_index != 0)) ) - { - /* header check failed drop request silently, do not return error! */ - pbuf_free(p); - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_header_check() failed\n")); - return; - } - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv ok, community %s\n", msg_ps->community)); - - /* Builds a list of variable bindings. Copy the varbinds from the pbuf - chain to glue them when these are divided over two or more pbuf's. */ - err_ret = snmp_pdu_dec_varbindlist(p, varbind_ofs, &varbind_ofs, msg_ps); - /* we've decoded the incoming message, release input msg now */ - pbuf_free(p); - if ((err_ret != ERR_OK) || (msg_ps->invb.count == 0)) - { - /* varbind-list decode failed, or varbind list empty. - drop request silently, do not return error! - (errors are only returned for a specific varbind failure) */ - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_dec_varbindlist() failed\n")); - return; - } - - msg_ps->error_status = SNMP_ES_NOERROR; - msg_ps->error_index = 0; - /* find object for each variable binding */ - msg_ps->state = SNMP_MSG_SEARCH_OBJ; - /* first variable binding from list to inspect */ - msg_ps->vb_idx = 0; - - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_recv varbind cnt=%"U16_F"\n",(u16_t)msg_ps->invb.count)); - - /* handle input event and as much objects as possible in one go */ - snmp_msg_event(req_idx); -} - -/** - * Checks and decodes incoming SNMP message header, logs header errors. - * - * @param p points to pbuf chain of SNMP message (UDP payload) - * @param ofs points to first octet of SNMP message - * @param pdu_len the length of the UDP payload - * @param ofs_ret returns the ofset of the variable bindings - * @param m_stat points to the current message request state return - * @return - * - ERR_OK SNMP header is sane and accepted - * - ERR_ARG SNMP header is either malformed or rejected - */ -static err_t -snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat) -{ - err_t derr; - u16_t len, ofs_base; - u8_t len_octets; - u8_t type; - s32_t version; - - ofs_base = ofs; - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || - (pdu_len != (1 + len_octets + len)) || - (type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ))) - { - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - ofs += (1 + len_octets); - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) - { - /* can't decode or no integer (version) */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &version); - if (derr != ERR_OK) - { - /* can't decode */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - if (version != 0) - { - /* not version 1 */ - snmp_inc_snmpinbadversions(); - return ERR_ARG; - } - ofs += (1 + len_octets + len); - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR))) - { - /* can't decode or no octet string (community) */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, SNMP_COMMUNITY_STR_LEN, m_stat->community); - if (derr != ERR_OK) - { - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - /* add zero terminator */ - len = ((len < (SNMP_COMMUNITY_STR_LEN))?(len):(SNMP_COMMUNITY_STR_LEN)); - m_stat->community[len] = 0; - m_stat->com_strlen = (u8_t)len; - if (strncmp(snmp_publiccommunity, (const char*)m_stat->community, SNMP_COMMUNITY_STR_LEN) != 0) - { - /** @todo: move this if we need to check more names */ - snmp_inc_snmpinbadcommunitynames(); - snmp_authfail_trap(); - return ERR_ARG; - } - ofs += (1 + len_octets + len); - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if (derr != ERR_OK) - { - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - switch(type) - { - case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_REQ): - /* GetRequest PDU */ - snmp_inc_snmpingetrequests(); - derr = ERR_OK; - break; - case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_NEXT_REQ): - /* GetNextRequest PDU */ - snmp_inc_snmpingetnexts(); - derr = ERR_OK; - break; - case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_RESP): - /* GetResponse PDU */ - snmp_inc_snmpingetresponses(); - derr = ERR_ARG; - break; - case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_SET_REQ): - /* SetRequest PDU */ - snmp_inc_snmpinsetrequests(); - derr = ERR_OK; - break; - case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_TRAP): - /* Trap PDU */ - snmp_inc_snmpintraps(); - derr = ERR_ARG; - break; - default: - snmp_inc_snmpinasnparseerrs(); - derr = ERR_ARG; - break; - } - if (derr != ERR_OK) - { - /* unsupported input PDU for this agent (no parse error) */ - return ERR_ARG; - } - m_stat->rt = type & 0x1F; - ofs += (1 + len_octets); - if (len != (pdu_len - (ofs - ofs_base))) - { - /* decoded PDU length does not equal actual payload length */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) - { - /* can't decode or no integer (request ID) */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->rid); - if (derr != ERR_OK) - { - /* can't decode */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - ofs += (1 + len_octets + len); - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) - { - /* can't decode or no integer (error-status) */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - /* must be noError (0) for incoming requests. - log errors for mib-2 completeness and for debug purposes */ - derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->error_status); - if (derr != ERR_OK) - { - /* can't decode */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - switch (m_stat->error_status) - { - case SNMP_ES_TOOBIG: - snmp_inc_snmpintoobigs(); - break; - case SNMP_ES_NOSUCHNAME: - snmp_inc_snmpinnosuchnames(); - break; - case SNMP_ES_BADVALUE: - snmp_inc_snmpinbadvalues(); - break; - case SNMP_ES_READONLY: - snmp_inc_snmpinreadonlys(); - break; - case SNMP_ES_GENERROR: - snmp_inc_snmpingenerrs(); - break; - } - ofs += (1 + len_octets + len); - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG))) - { - /* can't decode or no integer (error-index) */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - /* must be 0 for incoming requests. - decode anyway to catch bad integers (and dirty tricks) */ - derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->error_index); - if (derr != ERR_OK) - { - /* can't decode */ - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - ofs += (1 + len_octets + len); - *ofs_ret = ofs; - return ERR_OK; -} - -static err_t -snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat) -{ - err_t derr; - u16_t len, vb_len; - u8_t len_octets; - u8_t type; - - /* variable binding list */ - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &vb_len); - if ((derr != ERR_OK) || - (type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ))) - { - snmp_inc_snmpinasnparseerrs(); - return ERR_ARG; - } - ofs += (1 + len_octets); - - /* start with empty list */ - m_stat->invb.count = 0; - m_stat->invb.head = NULL; - m_stat->invb.tail = NULL; - - while (vb_len > 0) - { - struct snmp_obj_id oid, oid_value; - struct snmp_varbind *vb; - - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || - (type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)) || - (len == 0) || (len > vb_len)) - { - snmp_inc_snmpinasnparseerrs(); - /* free varbinds (if available) */ - snmp_varbind_list_free(&m_stat->invb); - return ERR_ARG; - } - ofs += (1 + len_octets); - vb_len -= (1 + len_octets); - - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID))) - { - /* can't decode object name length */ - snmp_inc_snmpinasnparseerrs(); - /* free varbinds (if available) */ - snmp_varbind_list_free(&m_stat->invb); - return ERR_ARG; - } - derr = snmp_asn1_dec_oid(p, ofs + 1 + len_octets, len, &oid); - if (derr != ERR_OK) - { - /* can't decode object name */ - snmp_inc_snmpinasnparseerrs(); - /* free varbinds (if available) */ - snmp_varbind_list_free(&m_stat->invb); - return ERR_ARG; - } - ofs += (1 + len_octets + len); - vb_len -= (1 + len_octets + len); - - snmp_asn1_dec_type(p, ofs, &type); - derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len); - if (derr != ERR_OK) - { - /* can't decode object value length */ - snmp_inc_snmpinasnparseerrs(); - /* free varbinds (if available) */ - snmp_varbind_list_free(&m_stat->invb); - return ERR_ARG; - } - - switch (type) - { - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG): - vb = snmp_varbind_alloc(&oid, type, sizeof(s32_t)); - if (vb != NULL) - { - s32_t *vptr = (s32_t*)vb->value; - - derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, vptr); - snmp_varbind_tail_add(&m_stat->invb, vb); - } - else - { - derr = ERR_ARG; - } - break; - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS): - vb = snmp_varbind_alloc(&oid, type, sizeof(u32_t)); - if (vb != NULL) - { - u32_t *vptr = (u32_t*)vb->value; - - derr = snmp_asn1_dec_u32t(p, ofs + 1 + len_octets, len, vptr); - snmp_varbind_tail_add(&m_stat->invb, vb); - } - else - { - derr = ERR_ARG; - } - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE): - LWIP_ASSERT("invalid length", len <= 0xff); - vb = snmp_varbind_alloc(&oid, type, (u8_t)len); - if (vb != NULL) - { - derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, vb->value_len, (u8_t*)vb->value); - snmp_varbind_tail_add(&m_stat->invb, vb); - } - else - { - derr = ERR_ARG; - } - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL): - vb = snmp_varbind_alloc(&oid, type, 0); - if (vb != NULL) - { - snmp_varbind_tail_add(&m_stat->invb, vb); - derr = ERR_OK; - } - else - { - derr = ERR_ARG; - } - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID): - derr = snmp_asn1_dec_oid(p, ofs + 1 + len_octets, len, &oid_value); - if (derr == ERR_OK) - { - vb = snmp_varbind_alloc(&oid, type, oid_value.len * sizeof(s32_t)); - if (vb != NULL) - { - u8_t i = oid_value.len; - s32_t *vptr = (s32_t*)vb->value; - - while(i > 0) - { - i--; - vptr[i] = oid_value.id[i]; - } - snmp_varbind_tail_add(&m_stat->invb, vb); - derr = ERR_OK; - } - else - { - derr = ERR_ARG; - } - } - break; - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR): - if (len == 4) - { - /* must be exactly 4 octets! */ - vb = snmp_varbind_alloc(&oid, type, 4); - if (vb != NULL) - { - derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, vb->value_len, (u8_t*)vb->value); - snmp_varbind_tail_add(&m_stat->invb, vb); - } - else - { - derr = ERR_ARG; - } - } - else - { - derr = ERR_ARG; - } - break; - default: - derr = ERR_ARG; - break; - } - if (derr != ERR_OK) - { - snmp_inc_snmpinasnparseerrs(); - /* free varbinds (if available) */ - snmp_varbind_list_free(&m_stat->invb); - return ERR_ARG; - } - ofs += (1 + len_octets + len); - vb_len -= (1 + len_octets + len); - } - - if (m_stat->rt == SNMP_ASN1_PDU_SET_REQ) - { - snmp_add_snmpintotalsetvars(m_stat->invb.count); - } - else - { - snmp_add_snmpintotalreqvars(m_stat->invb.count); - } - - *ofs_ret = ofs; - return ERR_OK; -} - -struct snmp_varbind* -snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len) -{ - struct snmp_varbind *vb; - - vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND); - if (vb != NULL) - { - u8_t i; - - vb->next = NULL; - vb->prev = NULL; - i = oid->len; - vb->ident_len = i; - if (i > 0) - { - LWIP_ASSERT("SNMP_MAX_TREE_DEPTH is configured too low", i <= SNMP_MAX_TREE_DEPTH); - /* allocate array of s32_t for our object identifier */ - vb->ident = (s32_t*)memp_malloc(MEMP_SNMP_VALUE); - if (vb->ident == NULL) - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate ident value space\n")); - memp_free(MEMP_SNMP_VARBIND, vb); - return NULL; - } - while(i > 0) - { - i--; - vb->ident[i] = oid->id[i]; - } - } - else - { - /* i == 0, pass zero length object identifier */ - vb->ident = NULL; - } - vb->value_type = type; - vb->value_len = len; - if (len > 0) - { - LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE); - /* allocate raw bytes for our object value */ - vb->value = memp_malloc(MEMP_SNMP_VALUE); - if (vb->value == NULL) - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate value space\n")); - if (vb->ident != NULL) - { - memp_free(MEMP_SNMP_VALUE, vb->ident); - } - memp_free(MEMP_SNMP_VARBIND, vb); - return NULL; - } - } - else - { - /* ASN1_NUL type, or zero length ASN1_OC_STR */ - vb->value = NULL; - } - } - else - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate varbind space\n")); - } - return vb; -} - -void -snmp_varbind_free(struct snmp_varbind *vb) -{ - if (vb->value != NULL ) - { - memp_free(MEMP_SNMP_VALUE, vb->value); - } - if (vb->ident != NULL ) - { - memp_free(MEMP_SNMP_VALUE, vb->ident); - } - memp_free(MEMP_SNMP_VARBIND, vb); -} - -void -snmp_varbind_list_free(struct snmp_varbind_root *root) -{ - struct snmp_varbind *vb, *prev; - - vb = root->tail; - while ( vb != NULL ) - { - prev = vb->prev; - snmp_varbind_free(vb); - vb = prev; - } - root->count = 0; - root->head = NULL; - root->tail = NULL; -} - -void -snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb) -{ - if (root->count == 0) - { - /* add first varbind to list */ - root->head = vb; - root->tail = vb; - } - else - { - /* add nth varbind to list tail */ - root->tail->next = vb; - vb->prev = root->tail; - root->tail = vb; - } - root->count += 1; -} - -struct snmp_varbind* -snmp_varbind_tail_remove(struct snmp_varbind_root *root) -{ - struct snmp_varbind* vb; - - if (root->count > 0) - { - /* remove tail varbind */ - vb = root->tail; - root->tail = vb->prev; - vb->prev->next = NULL; - root->count -= 1; - } - else - { - /* nothing to remove */ - vb = NULL; - } - return vb; -} - -#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/snmp/msg_out.c b/user/mpy/lib/lwip/src/core/snmp/msg_out.c deleted file mode 100644 index 485f076..0000000 --- a/user/mpy/lib/lwip/src/core/snmp/msg_out.c +++ /dev/null @@ -1,674 +0,0 @@ -/** - * @file - * SNMP output message processing (RFC1157). - * - * Output responses and traps are build in two passes: - * - * Pass 0: iterate over the output message backwards to determine encoding lengths - * Pass 1: the actual forward encoding of internal form into ASN1 - * - * The single-pass encoding method described by Comer & Stevens - * requires extra buffer space and copying for reversal of the packet. - * The buffer requirement can be prohibitively large for big payloads - * (>= 484) therefore we use the two encoding passes. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/udp.h" -#include "lwip/netif.h" -#include "lwip/snmp.h" -#include "lwip/snmp_asn1.h" -#include "lwip/snmp_msg.h" - -struct snmp_trap_dst -{ - /* destination IP address in network order */ - ip_addr_t dip; - /* set to 0 when disabled, >0 when enabled */ - u8_t enable; -}; -struct snmp_trap_dst trap_dst[SNMP_TRAP_DESTINATIONS]; - -/** TRAP message structure */ -struct snmp_msg_trap trap_msg; - -static u16_t snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len); -static u16_t snmp_trap_header_sum(struct snmp_msg_trap *m_trap, u16_t vb_len); -static u16_t snmp_varbind_list_sum(struct snmp_varbind_root *root); - -static u16_t snmp_resp_header_enc(struct snmp_msg_pstat *m_stat, struct pbuf *p); -static u16_t snmp_trap_header_enc(struct snmp_msg_trap *m_trap, struct pbuf *p); -static u16_t snmp_varbind_list_enc(struct snmp_varbind_root *root, struct pbuf *p, u16_t ofs); - -/** - * Sets enable switch for this trap destination. - * @param dst_idx index in 0 .. SNMP_TRAP_DESTINATIONS-1 - * @param enable switch if 0 destination is disabled >0 enabled. - */ -void -snmp_trap_dst_enable(u8_t dst_idx, u8_t enable) -{ - if (dst_idx < SNMP_TRAP_DESTINATIONS) - { - trap_dst[dst_idx].enable = enable; - } -} - -/** - * Sets IPv4 address for this trap destination. - * @param dst_idx index in 0 .. SNMP_TRAP_DESTINATIONS-1 - * @param dst IPv4 address in host order. - */ -void -snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst) -{ - if (dst_idx < SNMP_TRAP_DESTINATIONS) - { - ip_addr_set(&trap_dst[dst_idx].dip, dst); - } -} - -/** - * Sends a 'getresponse' message to the request originator. - * - * @param m_stat points to the current message request state source - * @return ERR_OK when success, ERR_MEM if we're out of memory - * - * @note the caller is responsible for filling in outvb in the m_stat - * and provide error-status and index (except for tooBig errors) ... - */ -err_t -snmp_send_response(struct snmp_msg_pstat *m_stat) -{ - struct snmp_varbind_root emptyvb = {NULL, NULL, 0, 0, 0}; - struct pbuf *p; - u16_t tot_len; - err_t err; - - /* pass 0, calculate length fields */ - tot_len = snmp_varbind_list_sum(&m_stat->outvb); - tot_len = snmp_resp_header_sum(m_stat, tot_len); - - /* try allocating pbuf(s) for complete response */ - p = pbuf_alloc(PBUF_TRANSPORT, tot_len, PBUF_POOL); - if (p == NULL) - { - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_snd_response() tooBig\n")); - - /* can't construct reply, return error-status tooBig */ - m_stat->error_status = SNMP_ES_TOOBIG; - m_stat->error_index = 0; - /* pass 0, recalculate lengths, for empty varbind-list */ - tot_len = snmp_varbind_list_sum(&emptyvb); - tot_len = snmp_resp_header_sum(m_stat, tot_len); - /* retry allocation once for header and empty varbind-list */ - p = pbuf_alloc(PBUF_TRANSPORT, tot_len, PBUF_POOL); - } - if (p != NULL) - { - /* first pbuf alloc try or retry alloc success */ - u16_t ofs; - - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_snd_response() p != NULL\n")); - - /* pass 1, size error, encode packet ino the pbuf(s) */ - ofs = snmp_resp_header_enc(m_stat, p); - snmp_varbind_list_enc(&m_stat->outvb, p, ofs); - - switch (m_stat->error_status) - { - case SNMP_ES_TOOBIG: - snmp_inc_snmpouttoobigs(); - break; - case SNMP_ES_NOSUCHNAME: - snmp_inc_snmpoutnosuchnames(); - break; - case SNMP_ES_BADVALUE: - snmp_inc_snmpoutbadvalues(); - break; - case SNMP_ES_GENERROR: - snmp_inc_snmpoutgenerrs(); - break; - } - snmp_inc_snmpoutgetresponses(); - snmp_inc_snmpoutpkts(); - - /** @todo do we need separate rx and tx pcbs for threaded case? */ - /** connect to the originating source */ - udp_connect(m_stat->pcb, &m_stat->sip, m_stat->sp); - err = udp_send(m_stat->pcb, p); - if (err == ERR_MEM) - { - /** @todo release some memory, retry and return tooBig? tooMuchHassle? */ - err = ERR_MEM; - } - else - { - err = ERR_OK; - } - /** disassociate remote address and port with this pcb */ - udp_disconnect(m_stat->pcb); - - pbuf_free(p); - LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_snd_response() done\n")); - return err; - } - else - { - /* first pbuf alloc try or retry alloc failed - very low on memory, couldn't return tooBig */ - return ERR_MEM; - } -} - - -/** - * Sends an generic or enterprise specific trap message. - * - * @param generic_trap is the trap code - * @param eoid points to enterprise object identifier - * @param specific_trap used for enterprise traps when generic_trap == 6 - * @return ERR_OK when success, ERR_MEM if we're out of memory - * - * @note the caller is responsible for filling in outvb in the trap_msg - * @note the use of the enterpise identifier field - * is per RFC1215. - * Use .iso.org.dod.internet.mgmt.mib-2.snmp for generic traps - * and .iso.org.dod.internet.private.enterprises.yourenterprise - * (sysObjectID) for specific traps. - */ -err_t -snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap) -{ - struct snmp_trap_dst *td; - struct netif *dst_if; - ip_addr_t dst_ip; - struct pbuf *p; - u16_t i,tot_len; - - for (i=0, td = &trap_dst[0]; ienable != 0) && !ip_addr_isany(&td->dip)) - { - /* network order trap destination */ - ip_addr_copy(trap_msg.dip, td->dip); - /* lookup current source address for this dst */ - dst_if = ip_route(&td->dip); - ip_addr_copy(dst_ip, dst_if->ip_addr); - /* @todo: what about IPv6? */ - trap_msg.sip_raw[0] = ip4_addr1(&dst_ip); - trap_msg.sip_raw[1] = ip4_addr2(&dst_ip); - trap_msg.sip_raw[2] = ip4_addr3(&dst_ip); - trap_msg.sip_raw[3] = ip4_addr4(&dst_ip); - trap_msg.gen_trap = generic_trap; - trap_msg.spc_trap = specific_trap; - if (generic_trap == SNMP_GENTRAP_ENTERPRISESPC) - { - /* enterprise-Specific trap */ - trap_msg.enterprise = eoid; - } - else - { - /* generic (MIB-II) trap */ - snmp_get_snmpgrpid_ptr(&trap_msg.enterprise); - } - snmp_get_sysuptime(&trap_msg.ts); - - /* pass 0, calculate length fields */ - tot_len = snmp_varbind_list_sum(&trap_msg.outvb); - tot_len = snmp_trap_header_sum(&trap_msg, tot_len); - - /* allocate pbuf(s) */ - p = pbuf_alloc(PBUF_TRANSPORT, tot_len, PBUF_POOL); - if (p != NULL) - { - u16_t ofs; - - /* pass 1, encode packet ino the pbuf(s) */ - ofs = snmp_trap_header_enc(&trap_msg, p); - snmp_varbind_list_enc(&trap_msg.outvb, p, ofs); - - snmp_inc_snmpouttraps(); - snmp_inc_snmpoutpkts(); - - /** send to the TRAP destination */ - udp_sendto(trap_msg.pcb, p, &trap_msg.dip, SNMP_TRAP_PORT); - - pbuf_free(p); - } - else - { - return ERR_MEM; - } - } - } - return ERR_OK; -} - -void -snmp_coldstart_trap(void) -{ - trap_msg.outvb.head = NULL; - trap_msg.outvb.tail = NULL; - trap_msg.outvb.count = 0; - snmp_send_trap(SNMP_GENTRAP_COLDSTART, NULL, 0); -} - -void -snmp_authfail_trap(void) -{ - u8_t enable; - snmp_get_snmpenableauthentraps(&enable); - if (enable == 1) - { - trap_msg.outvb.head = NULL; - trap_msg.outvb.tail = NULL; - trap_msg.outvb.count = 0; - snmp_send_trap(SNMP_GENTRAP_AUTHFAIL, NULL, 0); - } -} - -/** - * Sums response header field lengths from tail to head and - * returns resp_header_lengths for second encoding pass. - * - * @param vb_len varbind-list length - * @param rhl points to returned header lengths - * @return the required lenght for encoding the response header - */ -static u16_t -snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len) -{ - u16_t tot_len; - struct snmp_resp_header_lengths *rhl; - - rhl = &m_stat->rhl; - tot_len = vb_len; - snmp_asn1_enc_s32t_cnt(m_stat->error_index, &rhl->erridxlen); - snmp_asn1_enc_length_cnt(rhl->erridxlen, &rhl->erridxlenlen); - tot_len += 1 + rhl->erridxlenlen + rhl->erridxlen; - - snmp_asn1_enc_s32t_cnt(m_stat->error_status, &rhl->errstatlen); - snmp_asn1_enc_length_cnt(rhl->errstatlen, &rhl->errstatlenlen); - tot_len += 1 + rhl->errstatlenlen + rhl->errstatlen; - - snmp_asn1_enc_s32t_cnt(m_stat->rid, &rhl->ridlen); - snmp_asn1_enc_length_cnt(rhl->ridlen, &rhl->ridlenlen); - tot_len += 1 + rhl->ridlenlen + rhl->ridlen; - - rhl->pdulen = tot_len; - snmp_asn1_enc_length_cnt(rhl->pdulen, &rhl->pdulenlen); - tot_len += 1 + rhl->pdulenlen; - - rhl->comlen = m_stat->com_strlen; - snmp_asn1_enc_length_cnt(rhl->comlen, &rhl->comlenlen); - tot_len += 1 + rhl->comlenlen + rhl->comlen; - - snmp_asn1_enc_s32t_cnt(snmp_version, &rhl->verlen); - snmp_asn1_enc_length_cnt(rhl->verlen, &rhl->verlenlen); - tot_len += 1 + rhl->verlen + rhl->verlenlen; - - rhl->seqlen = tot_len; - snmp_asn1_enc_length_cnt(rhl->seqlen, &rhl->seqlenlen); - tot_len += 1 + rhl->seqlenlen; - - return tot_len; -} - -/** - * Sums trap header field lengths from tail to head and - * returns trap_header_lengths for second encoding pass. - * - * @param vb_len varbind-list length - * @param thl points to returned header lengths - * @return the required lenght for encoding the trap header - */ -static u16_t -snmp_trap_header_sum(struct snmp_msg_trap *m_trap, u16_t vb_len) -{ - u16_t tot_len; - struct snmp_trap_header_lengths *thl; - - thl = &m_trap->thl; - tot_len = vb_len; - - snmp_asn1_enc_u32t_cnt(m_trap->ts, &thl->tslen); - snmp_asn1_enc_length_cnt(thl->tslen, &thl->tslenlen); - tot_len += 1 + thl->tslen + thl->tslenlen; - - snmp_asn1_enc_s32t_cnt(m_trap->spc_trap, &thl->strplen); - snmp_asn1_enc_length_cnt(thl->strplen, &thl->strplenlen); - tot_len += 1 + thl->strplen + thl->strplenlen; - - snmp_asn1_enc_s32t_cnt(m_trap->gen_trap, &thl->gtrplen); - snmp_asn1_enc_length_cnt(thl->gtrplen, &thl->gtrplenlen); - tot_len += 1 + thl->gtrplen + thl->gtrplenlen; - - thl->aaddrlen = 4; - snmp_asn1_enc_length_cnt(thl->aaddrlen, &thl->aaddrlenlen); - tot_len += 1 + thl->aaddrlen + thl->aaddrlenlen; - - snmp_asn1_enc_oid_cnt(m_trap->enterprise->len, &m_trap->enterprise->id[0], &thl->eidlen); - snmp_asn1_enc_length_cnt(thl->eidlen, &thl->eidlenlen); - tot_len += 1 + thl->eidlen + thl->eidlenlen; - - thl->pdulen = tot_len; - snmp_asn1_enc_length_cnt(thl->pdulen, &thl->pdulenlen); - tot_len += 1 + thl->pdulenlen; - - thl->comlen = sizeof(snmp_publiccommunity) - 1; - snmp_asn1_enc_length_cnt(thl->comlen, &thl->comlenlen); - tot_len += 1 + thl->comlenlen + thl->comlen; - - snmp_asn1_enc_s32t_cnt(snmp_version, &thl->verlen); - snmp_asn1_enc_length_cnt(thl->verlen, &thl->verlenlen); - tot_len += 1 + thl->verlen + thl->verlenlen; - - thl->seqlen = tot_len; - snmp_asn1_enc_length_cnt(thl->seqlen, &thl->seqlenlen); - tot_len += 1 + thl->seqlenlen; - - return tot_len; -} - -/** - * Sums varbind lengths from tail to head and - * annotates lengths in varbind for second encoding pass. - * - * @param root points to the root of the variable binding list - * @return the required lenght for encoding the variable bindings - */ -static u16_t -snmp_varbind_list_sum(struct snmp_varbind_root *root) -{ - struct snmp_varbind *vb; - u32_t *uint_ptr; - s32_t *sint_ptr; - u16_t tot_len; - - tot_len = 0; - vb = root->tail; - while ( vb != NULL ) - { - /* encoded value lenght depends on type */ - switch (vb->value_type) - { - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG): - sint_ptr = (s32_t*)vb->value; - snmp_asn1_enc_s32t_cnt(*sint_ptr, &vb->vlen); - break; - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS): - uint_ptr = (u32_t*)vb->value; - snmp_asn1_enc_u32t_cnt(*uint_ptr, &vb->vlen); - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR): - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE): - vb->vlen = vb->value_len; - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID): - sint_ptr = (s32_t*)vb->value; - snmp_asn1_enc_oid_cnt(vb->value_len / sizeof(s32_t), sint_ptr, &vb->vlen); - break; - default: - /* unsupported type */ - vb->vlen = 0; - break; - }; - /* encoding length of value length field */ - snmp_asn1_enc_length_cnt(vb->vlen, &vb->vlenlen); - snmp_asn1_enc_oid_cnt(vb->ident_len, vb->ident, &vb->olen); - snmp_asn1_enc_length_cnt(vb->olen, &vb->olenlen); - - vb->seqlen = 1 + vb->vlenlen + vb->vlen; - vb->seqlen += 1 + vb->olenlen + vb->olen; - snmp_asn1_enc_length_cnt(vb->seqlen, &vb->seqlenlen); - - /* varbind seq */ - tot_len += 1 + vb->seqlenlen + vb->seqlen; - - vb = vb->prev; - } - - /* varbind-list seq */ - root->seqlen = tot_len; - snmp_asn1_enc_length_cnt(root->seqlen, &root->seqlenlen); - tot_len += 1 + root->seqlenlen; - - return tot_len; -} - -/** - * Encodes response header from head to tail. - */ -static u16_t -snmp_resp_header_enc(struct snmp_msg_pstat *m_stat, struct pbuf *p) -{ - u16_t ofs; - - ofs = 0; - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.seqlen); - ofs += m_stat->rhl.seqlenlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.verlen); - ofs += m_stat->rhl.verlenlen; - snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.verlen, snmp_version); - ofs += m_stat->rhl.verlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.comlen); - ofs += m_stat->rhl.comlenlen; - snmp_asn1_enc_raw(p, ofs, m_stat->rhl.comlen, m_stat->community); - ofs += m_stat->rhl.comlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_RESP)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.pdulen); - ofs += m_stat->rhl.pdulenlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.ridlen); - ofs += m_stat->rhl.ridlenlen; - snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.ridlen, m_stat->rid); - ofs += m_stat->rhl.ridlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.errstatlen); - ofs += m_stat->rhl.errstatlenlen; - snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.errstatlen, m_stat->error_status); - ofs += m_stat->rhl.errstatlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_stat->rhl.erridxlen); - ofs += m_stat->rhl.erridxlenlen; - snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.erridxlen, m_stat->error_index); - ofs += m_stat->rhl.erridxlen; - - return ofs; -} - -/** - * Encodes trap header from head to tail. - */ -static u16_t -snmp_trap_header_enc(struct snmp_msg_trap *m_trap, struct pbuf *p) -{ - u16_t ofs; - - ofs = 0; - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.seqlen); - ofs += m_trap->thl.seqlenlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.verlen); - ofs += m_trap->thl.verlenlen; - snmp_asn1_enc_s32t(p, ofs, m_trap->thl.verlen, snmp_version); - ofs += m_trap->thl.verlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.comlen); - ofs += m_trap->thl.comlenlen; - snmp_asn1_enc_raw(p, ofs, m_trap->thl.comlen, (u8_t *)&snmp_publiccommunity[0]); - ofs += m_trap->thl.comlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_TRAP)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.pdulen); - ofs += m_trap->thl.pdulenlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.eidlen); - ofs += m_trap->thl.eidlenlen; - snmp_asn1_enc_oid(p, ofs, m_trap->enterprise->len, &m_trap->enterprise->id[0]); - ofs += m_trap->thl.eidlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.aaddrlen); - ofs += m_trap->thl.aaddrlenlen; - snmp_asn1_enc_raw(p, ofs, m_trap->thl.aaddrlen, &m_trap->sip_raw[0]); - ofs += m_trap->thl.aaddrlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.gtrplen); - ofs += m_trap->thl.gtrplenlen; - snmp_asn1_enc_u32t(p, ofs, m_trap->thl.gtrplen, m_trap->gen_trap); - ofs += m_trap->thl.gtrplen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.strplen); - ofs += m_trap->thl.strplenlen; - snmp_asn1_enc_u32t(p, ofs, m_trap->thl.strplen, m_trap->spc_trap); - ofs += m_trap->thl.strplen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, m_trap->thl.tslen); - ofs += m_trap->thl.tslenlen; - snmp_asn1_enc_u32t(p, ofs, m_trap->thl.tslen, m_trap->ts); - ofs += m_trap->thl.tslen; - - return ofs; -} - -/** - * Encodes varbind list from head to tail. - */ -static u16_t -snmp_varbind_list_enc(struct snmp_varbind_root *root, struct pbuf *p, u16_t ofs) -{ - struct snmp_varbind *vb; - s32_t *sint_ptr; - u32_t *uint_ptr; - u8_t *raw_ptr; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, root->seqlen); - ofs += root->seqlenlen; - - vb = root->head; - while ( vb != NULL ) - { - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, vb->seqlen); - ofs += vb->seqlenlen; - - snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID)); - ofs += 1; - snmp_asn1_enc_length(p, ofs, vb->olen); - ofs += vb->olenlen; - snmp_asn1_enc_oid(p, ofs, vb->ident_len, &vb->ident[0]); - ofs += vb->olen; - - snmp_asn1_enc_type(p, ofs, vb->value_type); - ofs += 1; - snmp_asn1_enc_length(p, ofs, vb->vlen); - ofs += vb->vlenlen; - - switch (vb->value_type) - { - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG): - sint_ptr = (s32_t*)vb->value; - snmp_asn1_enc_s32t(p, ofs, vb->vlen, *sint_ptr); - break; - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS): - uint_ptr = (u32_t*)vb->value; - snmp_asn1_enc_u32t(p, ofs, vb->vlen, *uint_ptr); - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR): - case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE): - raw_ptr = (u8_t*)vb->value; - snmp_asn1_enc_raw(p, ofs, vb->vlen, raw_ptr); - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL): - break; - case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID): - sint_ptr = (s32_t*)vb->value; - snmp_asn1_enc_oid(p, ofs, vb->value_len / sizeof(s32_t), sint_ptr); - break; - default: - /* unsupported type */ - break; - }; - ofs += vb->vlen; - vb = vb->next; - } - return ofs; -} - -#endif /* LWIP_SNMP */ diff --git a/user/mpy/lib/lwip/src/core/stats.c b/user/mpy/lib/lwip/src/core/stats.c deleted file mode 100644 index 8ea8249..0000000 --- a/user/mpy/lib/lwip/src/core/stats.c +++ /dev/null @@ -1,176 +0,0 @@ -/** - * @file - * Statistics module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_STATS /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/stats.h" -#include "lwip/mem.h" - -#include - -struct stats_ lwip_stats; - -void stats_init(void) -{ -#ifdef LWIP_DEBUG -#if MEMP_STATS - const char * memp_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) desc, -#include "lwip/memp_std.h" - }; - int i; - for (i = 0; i < MEMP_MAX; i++) { - lwip_stats.memp[i].name = memp_names[i]; - } -#endif /* MEMP_STATS */ -#if MEM_STATS - lwip_stats.mem.name = "MEM"; -#endif /* MEM_STATS */ -#endif /* LWIP_DEBUG */ -} - -#if LWIP_STATS_DISPLAY -void -stats_display_proto(struct stats_proto *proto, const char *name) -{ - LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); - LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); - LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); - LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); - LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); - LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); - LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); - LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); - LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); - LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); -} - -#if IGMP_STATS -void -stats_display_igmp(struct stats_igmp *igmp) -{ - LWIP_PLATFORM_DIAG(("\nIGMP\n\t")); - LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); - LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); - LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); - LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); - LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); - LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group)); - LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general)); - LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); - LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); - LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); - LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); -} -#endif /* IGMP_STATS */ - -#if MEM_STATS || MEMP_STATS -void -stats_display_mem(struct stats_mem *mem, const char *name) -{ - LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); - LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); - LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); - LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); - LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); -} - -#if MEMP_STATS -void -stats_display_memp(struct stats_mem *mem, int index) -{ - char * memp_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) desc, -#include "lwip/memp_std.h" - }; - if(index < MEMP_MAX) { - stats_display_mem(mem, memp_names[index]); - } -} -#endif /* MEMP_STATS */ -#endif /* MEM_STATS || MEMP_STATS */ - -#if SYS_STATS -void -stats_display_sys(struct stats_sys *sys) -{ - LWIP_PLATFORM_DIAG(("\nSYS\n\t")); - LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); - LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); - LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); - LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); - LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); - LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); - LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); - LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); - LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); -} -#endif /* SYS_STATS */ - -void -stats_display(void) -{ - s16_t i; - - LINK_STATS_DISPLAY(); - ETHARP_STATS_DISPLAY(); - IPFRAG_STATS_DISPLAY(); - IP_STATS_DISPLAY(); - IGMP_STATS_DISPLAY(); - ICMP_STATS_DISPLAY(); - UDP_STATS_DISPLAY(); - TCP_STATS_DISPLAY(); - MEM_STATS_DISPLAY(); - for (i = 0; i < MEMP_MAX; i++) { - MEMP_STATS_DISPLAY(i); - } - SYS_STATS_DISPLAY(); -} -#endif /* LWIP_STATS_DISPLAY */ - -#endif /* LWIP_STATS */ - diff --git a/user/mpy/lib/lwip/src/core/sys.c b/user/mpy/lib/lwip/src/core/sys.c deleted file mode 100644 index f177737..0000000 --- a/user/mpy/lib/lwip/src/core/sys.c +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file - * lwIP Operating System abstraction - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/sys.h" - -/* Most of the functions defined in sys.h must be implemented in the - * architecture-dependent file sys_arch.c */ - -#if !NO_SYS - -#ifndef sys_msleep -/** - * Sleep for some ms. Timeouts are NOT processed while sleeping. - * - * @param ms number of milliseconds to sleep - */ -void -sys_msleep(u32_t ms) -{ - if (ms > 0) { - sys_sem_t delaysem; - err_t err = sys_sem_new(&delaysem, 0); - if (err == ERR_OK) { - sys_arch_sem_wait(&delaysem, ms); - sys_sem_free(&delaysem); - } - } -} -#endif /* sys_msleep */ - -#endif /* !NO_SYS */ diff --git a/user/mpy/lib/lwip/src/core/tcp.c b/user/mpy/lib/lwip/src/core/tcp.c deleted file mode 100644 index b710d2e..0000000 --- a/user/mpy/lib/lwip/src/core/tcp.c +++ /dev/null @@ -1,1742 +0,0 @@ -/** - * @file - * Transmission Control Protocol for IP - * - * This file contains common functions for the TCP implementation, such as functinos - * for manipulating the data structures and the TCP timer functions. TCP functions - * related to input and output is found in tcp_in.c and tcp_out.c respectively. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/snmp.h" -#include "lwip/tcp.h" -#include "lwip/tcp_impl.h" -#include "lwip/debug.h" -#include "lwip/stats.h" - -#include - -#ifndef TCP_LOCAL_PORT_RANGE_START -/* From http://www.iana.org/assignments/port-numbers: - "The Dynamic and/or Private Ports are those from 49152 through 65535" */ -#define TCP_LOCAL_PORT_RANGE_START 0xc000 -#define TCP_LOCAL_PORT_RANGE_END 0xffff -#define TCP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START) -#endif - -#if LWIP_TCP_KEEPALIVE -#define TCP_KEEP_DUR(pcb) ((pcb)->keep_cnt * (pcb)->keep_intvl) -#define TCP_KEEP_INTVL(pcb) ((pcb)->keep_intvl) -#else /* LWIP_TCP_KEEPALIVE */ -#define TCP_KEEP_DUR(pcb) TCP_MAXIDLE -#define TCP_KEEP_INTVL(pcb) TCP_KEEPINTVL_DEFAULT -#endif /* LWIP_TCP_KEEPALIVE */ - -const char * const tcp_state_str[] = { - "CLOSED", - "LISTEN", - "SYN_SENT", - "SYN_RCVD", - "ESTABLISHED", - "FIN_WAIT_1", - "FIN_WAIT_2", - "CLOSE_WAIT", - "CLOSING", - "LAST_ACK", - "TIME_WAIT" -}; - -/* last local TCP port */ -static u16_t tcp_port = TCP_LOCAL_PORT_RANGE_START; - -/* Incremented every coarse grained timer shot (typically every 500 ms). */ -u32_t tcp_ticks; -const u8_t tcp_backoff[13] = - { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7}; - /* Times per slowtmr hits */ -const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; - -/* The TCP PCB lists. */ - -/** List of all TCP PCBs bound but not yet (connected || listening) */ -struct tcp_pcb *tcp_bound_pcbs; -/** List of all TCP PCBs in LISTEN state */ -union tcp_listen_pcbs_t tcp_listen_pcbs; -/** List of all TCP PCBs that are in a state in which - * they accept or send data. */ -struct tcp_pcb *tcp_active_pcbs; -/** List of all TCP PCBs in TIME-WAIT state */ -struct tcp_pcb *tcp_tw_pcbs; - -#define NUM_TCP_PCB_LISTS 4 -#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 -/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */ -struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs, - &tcp_active_pcbs, &tcp_tw_pcbs}; - -/** Only used for temporary storage. */ -struct tcp_pcb *tcp_tmp_pcb; - -u8_t tcp_active_pcbs_changed; - -/** Timer counter to handle calling slow-timer from tcp_tmr() */ -static u8_t tcp_timer; -static u8_t tcp_timer_ctr; -static u16_t tcp_new_port(void); - -/** - * Initialize this module. - */ -void -tcp_init(void) -{ -#if LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) - tcp_port = TCP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()); -#endif /* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) */ -} - -/** - * Called periodically to dispatch TCP timers. - */ -void -tcp_tmr(void) -{ - /* Call tcp_fasttmr() every 250 ms */ - tcp_fasttmr(); - - if (++tcp_timer & 1) { - /* Call tcp_tmr() every 500 ms, i.e., every other timer - tcp_tmr() is called. */ - tcp_slowtmr(); - } -} - -/** - * Closes the TX side of a connection held by the PCB. - * For tcp_close(), a RST is sent if the application didn't receive all data - * (tcp_recved() not called for all data passed to recv callback). - * - * Listening pcbs are freed and may not be referenced any more. - * Connection pcbs are freed if not yet connected and may not be referenced - * any more. If a connection is established (at least SYN received or in - * a closing state), the connection is closed, and put in a closing state. - * The pcb is then automatically freed in tcp_slowtmr(). It is therefore - * unsafe to reference it. - * - * @param pcb the tcp_pcb to close - * @return ERR_OK if connection has been closed - * another err_t if closing failed and pcb is not freed - */ -static err_t -tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data) -{ - err_t err; - - if (rst_on_unacked_data && ((pcb->state == ESTABLISHED) || (pcb->state == CLOSE_WAIT))) { - if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) { - /* Not all data received by application, send RST to tell the remote - side about this. */ - LWIP_ASSERT("pcb->flags & TF_RXCLOSED", pcb->flags & TF_RXCLOSED); - - /* don't call tcp_abort here: we must not deallocate the pcb since - that might not be expected when calling tcp_close */ - tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, - pcb->local_port, pcb->remote_port); - - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - if (pcb->state == ESTABLISHED) { - /* move to TIME_WAIT since we close actively */ - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } else { - /* CLOSE_WAIT: deallocate the pcb since we already sent a RST for it */ - memp_free(MEMP_TCP_PCB, pcb); - } - return ERR_OK; - } - } - - switch (pcb->state) { - case CLOSED: - /* Closing a pcb in the CLOSED state might seem erroneous, - * however, it is in this state once allocated and as yet unused - * and the user needs some way to free it should the need arise. - * Calling tcp_close() with a pcb that has already been closed, (i.e. twice) - * or for a pcb that has been used and then entered the CLOSED state - * is erroneous, but this should never happen as the pcb has in those cases - * been freed, and so any remaining handles are bogus. */ - err = ERR_OK; - if (pcb->local_port != 0) { - TCP_RMV(&tcp_bound_pcbs, pcb); - } - memp_free(MEMP_TCP_PCB, pcb); - pcb = NULL; - break; - case LISTEN: - err = ERR_OK; - tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb); - memp_free(MEMP_TCP_PCB_LISTEN, pcb); - pcb = NULL; - break; - case SYN_SENT: - err = ERR_OK; - TCP_PCB_REMOVE_ACTIVE(pcb); - memp_free(MEMP_TCP_PCB, pcb); - pcb = NULL; - snmp_inc_tcpattemptfails(); - break; - case SYN_RCVD: - err = tcp_send_fin(pcb); - if (err == ERR_OK) { - snmp_inc_tcpattemptfails(); - pcb->state = FIN_WAIT_1; - } - break; - case ESTABLISHED: - err = tcp_send_fin(pcb); - if (err == ERR_OK) { - snmp_inc_tcpestabresets(); - pcb->state = FIN_WAIT_1; - } - break; - case CLOSE_WAIT: - err = tcp_send_fin(pcb); - if (err == ERR_OK) { - snmp_inc_tcpestabresets(); - pcb->state = LAST_ACK; - } - break; - default: - /* Has already been closed, do nothing. */ - err = ERR_OK; - pcb = NULL; - break; - } - - if (pcb != NULL && err == ERR_OK) { - /* To ensure all data has been sent when tcp_close returns, we have - to make sure tcp_output doesn't fail. - Since we don't really have to ensure all data has been sent when tcp_close - returns (unsent data is sent from tcp timer functions, also), we don't care - for the return value of tcp_output for now. */ - /* @todo: When implementing SO_LINGER, this must be changed somehow: - If SOF_LINGER is set, the data should be sent and acked before close returns. - This can only be valid for sequential APIs, not for the raw API. */ - tcp_output(pcb); - } - return err; -} - -/** - * Closes the connection held by the PCB. - * - * Listening pcbs are freed and may not be referenced any more. - * Connection pcbs are freed if not yet connected and may not be referenced - * any more. If a connection is established (at least SYN received or in - * a closing state), the connection is closed, and put in a closing state. - * The pcb is then automatically freed in tcp_slowtmr(). It is therefore - * unsafe to reference it (unless an error is returned). - * - * @param pcb the tcp_pcb to close - * @return ERR_OK if connection has been closed - * another err_t if closing failed and pcb is not freed - */ -err_t -tcp_close(struct tcp_pcb *pcb) -{ -#if TCP_DEBUG - LWIP_DEBUGF(TCP_DEBUG, ("tcp_close: closing in ")); - tcp_debug_print_state(pcb->state); -#endif /* TCP_DEBUG */ - - if (pcb->state != LISTEN) { - /* Set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; - } - /* ... and close */ - return tcp_close_shutdown(pcb, 1); -} - -/** - * Causes all or part of a full-duplex connection of this PCB to be shut down. - * This doesn't deallocate the PCB unless shutting down both sides! - * Shutting down both sides is the same as calling tcp_close, so if it succeds, - * the PCB should not be referenced any more. - * - * @param pcb PCB to shutdown - * @param shut_rx shut down receive side if this is != 0 - * @param shut_tx shut down send side if this is != 0 - * @return ERR_OK if shutdown succeeded (or the PCB has already been shut down) - * another err_t on error. - */ -err_t -tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx) -{ - if (pcb->state == LISTEN) { - return ERR_CONN; - } - if (shut_rx) { - /* shut down the receive side: set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; - if (shut_tx) { - /* shutting down the tx AND rx side is the same as closing for the raw API */ - return tcp_close_shutdown(pcb, 1); - } - /* ... and free buffered data */ - if (pcb->refused_data != NULL) { - pbuf_free(pcb->refused_data); - pcb->refused_data = NULL; - } - } - if (shut_tx) { - /* This can't happen twice since if it succeeds, the pcb's state is changed. - Only close in these states as the others directly deallocate the PCB */ - switch (pcb->state) { - case SYN_RCVD: - case ESTABLISHED: - case CLOSE_WAIT: - return tcp_close_shutdown(pcb, shut_rx); - default: - /* Not (yet?) connected, cannot shutdown the TX side as that would bring us - into CLOSED state, where the PCB is deallocated. */ - return ERR_CONN; - } - } - return ERR_OK; -} - -/** - * Abandons a connection and optionally sends a RST to the remote - * host. Deletes the local protocol control block. This is done when - * a connection is killed because of shortage of memory. - * - * @param pcb the tcp_pcb to abort - * @param reset boolean to indicate whether a reset should be sent - */ -void -tcp_abandon(struct tcp_pcb *pcb, int reset) -{ - u32_t seqno, ackno; -#if LWIP_CALLBACK_API - tcp_err_fn errf; -#endif /* LWIP_CALLBACK_API */ - void *errf_arg; - - /* pcb->state LISTEN not allowed here */ - LWIP_ASSERT("don't call tcp_abort/tcp_abandon for listen-pcbs", - pcb->state != LISTEN); - /* Figure out on which TCP PCB list we are, and remove us. If we - are in an active state, call the receive function associated with - the PCB with a NULL argument, and send an RST to the remote end. */ - if (pcb->state == TIME_WAIT) { - tcp_pcb_remove(&tcp_tw_pcbs, pcb); - memp_free(MEMP_TCP_PCB, pcb); - } else { - seqno = pcb->snd_nxt; - ackno = pcb->rcv_nxt; -#if LWIP_CALLBACK_API - errf = pcb->errf; -#endif /* LWIP_CALLBACK_API */ - errf_arg = pcb->callback_arg; - TCP_PCB_REMOVE_ACTIVE(pcb); - if (pcb->unacked != NULL) { - tcp_segs_free(pcb->unacked); - } - if (pcb->unsent != NULL) { - tcp_segs_free(pcb->unsent); - } -#if TCP_QUEUE_OOSEQ - if (pcb->ooseq != NULL) { - tcp_segs_free(pcb->ooseq); - } -#endif /* TCP_QUEUE_OOSEQ */ - if (reset) { - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n")); - tcp_rst(seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port); - } - memp_free(MEMP_TCP_PCB, pcb); - TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT); - } -} - -/** - * Aborts the connection by sending a RST (reset) segment to the remote - * host. The pcb is deallocated. This function never fails. - * - * ATTENTION: When calling this from one of the TCP callbacks, make - * sure you always return ERR_ABRT (and never return ERR_ABRT otherwise - * or you will risk accessing deallocated memory or memory leaks! - * - * @param pcb the tcp pcb to abort - */ -void -tcp_abort(struct tcp_pcb *pcb) -{ - tcp_abandon(pcb, 1); -} - -/** - * Binds the connection to a local portnumber and IP address. If the - * IP address is not given (i.e., ipaddr == NULL), the IP address of - * the outgoing network interface is used instead. - * - * @param pcb the tcp_pcb to bind (no check is done whether this pcb is - * already bound!) - * @param ipaddr the local ip address to bind to (use IP_ADDR_ANY to bind - * to any local address - * @param port the local port to bind to - * @return ERR_USE if the port is already in use - * ERR_VAL if bind failed because the PCB is not in a valid state - * ERR_OK if bound - */ -err_t -tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) -{ - int i; - int max_pcb_list = NUM_TCP_PCB_LISTS; - struct tcp_pcb *cpcb; - - LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL); - -#if SO_REUSE - /* Unless the REUSEADDR flag is set, - we have to check the pcbs in TIME-WAIT state, also. - We do not dump TIME_WAIT pcb's; they can still be matched by incoming - packets using both local and remote IP addresses and ports to distinguish. - */ - if (ip_get_option(pcb, SOF_REUSEADDR)) { - max_pcb_list = NUM_TCP_PCB_LISTS_NO_TIME_WAIT; - } -#endif /* SO_REUSE */ - - if (port == 0) { - port = tcp_new_port(); - if (port == 0) { - return ERR_BUF; - } - } - - /* Check if the address already is in use (on all lists) */ - for (i = 0; i < max_pcb_list; i++) { - for(cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { - if (cpcb->local_port == port) { -#if SO_REUSE - /* Omit checking for the same port if both pcbs have REUSEADDR set. - For SO_REUSEADDR, the duplicate-check for a 5-tuple is done in - tcp_connect. */ - if (!ip_get_option(pcb, SOF_REUSEADDR) || - !ip_get_option(cpcb, SOF_REUSEADDR)) -#endif /* SO_REUSE */ - { - if (ip_addr_isany(&(cpcb->local_ip)) || - ip_addr_isany(ipaddr) || - ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { - return ERR_USE; - } - } - } - } - } - - if (!ip_addr_isany(ipaddr)) { - pcb->local_ip = *ipaddr; - } - pcb->local_port = port; - TCP_REG(&tcp_bound_pcbs, pcb); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %"U16_F"\n", port)); - return ERR_OK; -} -#if LWIP_CALLBACK_API -/** - * Default accept callback if no accept callback is specified by the user. - */ -static err_t -tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) -{ - LWIP_UNUSED_ARG(arg); - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(err); - - return ERR_ABRT; -} -#endif /* LWIP_CALLBACK_API */ - -/** - * Set the state of the connection to be LISTEN, which means that it - * is able to accept incoming connections. The protocol control block - * is reallocated in order to consume less memory. Setting the - * connection to LISTEN is an irreversible process. - * - * @param pcb the original tcp_pcb - * @param backlog the incoming connections queue limit - * @return tcp_pcb used for listening, consumes less memory. - * - * @note The original tcp_pcb is freed. This function therefore has to be - * called like this: - * tpcb = tcp_listen(tpcb); - */ -struct tcp_pcb * -tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) -{ - struct tcp_pcb_listen *lpcb; - - LWIP_UNUSED_ARG(backlog); - LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL); - - /* already listening? */ - if (pcb->state == LISTEN) { - return pcb; - } -#if SO_REUSE - if (ip_get_option(pcb, SOF_REUSEADDR)) { - /* Since SOF_REUSEADDR allows reusing a local address before the pcb's usage - is declared (listen-/connection-pcb), we have to make sure now that - this port is only used once for every local IP. */ - for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - if (lpcb->local_port == pcb->local_port) { - if (ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) { - /* this address/port is already used */ - return NULL; - } - } - } - } -#endif /* SO_REUSE */ - lpcb = (struct tcp_pcb_listen *)memp_malloc(MEMP_TCP_PCB_LISTEN); - if (lpcb == NULL) { - return NULL; - } - lpcb->callback_arg = pcb->callback_arg; - lpcb->local_port = pcb->local_port; - lpcb->state = LISTEN; - lpcb->prio = pcb->prio; - lpcb->so_options = pcb->so_options; - ip_set_option(lpcb, SOF_ACCEPTCONN); - lpcb->ttl = pcb->ttl; - lpcb->tos = pcb->tos; - ip_addr_copy(lpcb->local_ip, pcb->local_ip); - if (pcb->local_port != 0) { - TCP_RMV(&tcp_bound_pcbs, pcb); - } - memp_free(MEMP_TCP_PCB, pcb); -#if LWIP_CALLBACK_API - lpcb->accept = tcp_accept_null; -#endif /* LWIP_CALLBACK_API */ -#if TCP_LISTEN_BACKLOG - lpcb->accepts_pending = 0; - lpcb->backlog = (backlog ? backlog : 1); -#endif /* TCP_LISTEN_BACKLOG */ - TCP_REG(&tcp_listen_pcbs.pcbs, (struct tcp_pcb *)lpcb); - return (struct tcp_pcb *)lpcb; -} - -/** - * Update the state that tracks the available window space to advertise. - * - * Returns how much extra window would be advertised if we sent an - * update now. - */ -u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb) -{ - u32_t new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd; - - if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) { - /* we can advertise more window */ - pcb->rcv_ann_wnd = pcb->rcv_wnd; - return new_right_edge - pcb->rcv_ann_right_edge; - } else { - if (TCP_SEQ_GT(pcb->rcv_nxt, pcb->rcv_ann_right_edge)) { - /* Can happen due to other end sending out of advertised window, - * but within actual available (but not yet advertised) window */ - pcb->rcv_ann_wnd = 0; - } else { - /* keep the right edge of window constant */ - u32_t new_rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt; - LWIP_ASSERT("new_rcv_ann_wnd <= 0xffff", new_rcv_ann_wnd <= 0xffff); - pcb->rcv_ann_wnd = (u16_t)new_rcv_ann_wnd; - } - return 0; - } -} - -/** - * This function should be called by the application when it has - * processed the data. The purpose is to advertise a larger window - * when the data has been processed. - * - * @param pcb the tcp_pcb for which data is read - * @param len the amount of bytes that have been read by the application - */ -void -tcp_recved(struct tcp_pcb *pcb, u16_t len) -{ - int wnd_inflation; - - /* pcb->state LISTEN not allowed here */ - LWIP_ASSERT("don't call tcp_recved for listen-pcbs", - pcb->state != LISTEN); - LWIP_ASSERT("tcp_recved: len would wrap rcv_wnd\n", - len <= 0xffff - pcb->rcv_wnd ); - - pcb->rcv_wnd += len; - if (pcb->rcv_wnd > TCP_WND) { - pcb->rcv_wnd = TCP_WND; - } - - wnd_inflation = tcp_update_rcv_ann_wnd(pcb); - - /* If the change in the right edge of window is significant (default - * watermark is TCP_WND/4), then send an explicit update now. - * Otherwise wait for a packet to be sent in the normal course of - * events (or more window to be available later) */ - if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD) { - tcp_ack_now(pcb); - tcp_output(pcb); - } - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %"U16_F" bytes, wnd %"U16_F" (%"U16_F").\n", - len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd)); -} - -/** - * Allocate a new local TCP port. - * - * @return a new (free) local TCP port number - */ -static u16_t -tcp_new_port(void) -{ - u8_t i; - u16_t n = 0; - struct tcp_pcb *pcb; - -again: - if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) { - tcp_port = TCP_LOCAL_PORT_RANGE_START; - } - /* Check all PCB lists. */ - for (i = 0; i < NUM_TCP_PCB_LISTS; i++) { - for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) { - if (pcb->local_port == tcp_port) { - if (++n > (TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START)) { - return 0; - } - goto again; - } - } - } - return tcp_port; -} - -/** - * Connects to another host. The function given as the "connected" - * argument will be called when the connection has been established. - * - * @param pcb the tcp_pcb used to establish the connection - * @param ipaddr the remote ip address to connect to - * @param port the remote tcp port to connect to - * @param connected callback function to call when connected (or on error) - * @return ERR_VAL if invalid arguments are given - * ERR_OK if connect request has been sent - * other err_t values if connect request couldn't be sent - */ -err_t -tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, - tcp_connected_fn connected) -{ - err_t ret; - u32_t iss; - u16_t old_local_port; - - LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port)); - if (ipaddr != NULL) { - pcb->remote_ip = *ipaddr; - } else { - return ERR_VAL; - } - pcb->remote_port = port; - - /* check if we have a route to the remote host */ - if (ip_addr_isany(&(pcb->local_ip))) { - /* no local IP address set, yet. */ - struct netif *netif = ip_route(&(pcb->remote_ip)); - if (netif == NULL) { - /* Don't even try to send a SYN packet if we have no route - since that will fail. */ - return ERR_RTE; - } - /* Use the netif's IP address as local address. */ - ip_addr_copy(pcb->local_ip, netif->ip_addr); - } - - old_local_port = pcb->local_port; - if (pcb->local_port == 0) { - pcb->local_port = tcp_new_port(); - if (pcb->local_port == 0) { - return ERR_BUF; - } - } -#if SO_REUSE - if (ip_get_option(pcb, SOF_REUSEADDR)) { - /* Since SOF_REUSEADDR allows reusing a local address, we have to make sure - now that the 5-tuple is unique. */ - struct tcp_pcb *cpcb; - int i; - /* Don't check listen- and bound-PCBs, check active- and TIME-WAIT PCBs. */ - for (i = 2; i < NUM_TCP_PCB_LISTS; i++) { - for(cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { - if ((cpcb->local_port == pcb->local_port) && - (cpcb->remote_port == port) && - ip_addr_cmp(&cpcb->local_ip, &pcb->local_ip) && - ip_addr_cmp(&cpcb->remote_ip, ipaddr)) { - /* linux returns EISCONN here, but ERR_USE should be OK for us */ - return ERR_USE; - } - } - } - } -#endif /* SO_REUSE */ - iss = tcp_next_iss(); - pcb->rcv_nxt = 0; - pcb->snd_nxt = iss; - pcb->lastack = iss - 1; - pcb->snd_lbb = iss - 1; - pcb->rcv_wnd = TCP_WND; - pcb->rcv_ann_wnd = TCP_WND; - pcb->rcv_ann_right_edge = pcb->rcv_nxt; - pcb->snd_wnd = TCP_WND; - /* As initial send MSS, we use TCP_MSS but limit it to 536. - The send MSS is updated when an MSS option is received. */ - pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; -#if TCP_CALCULATE_EFF_SEND_MSS - pcb->mss = tcp_eff_send_mss(pcb->mss, ipaddr); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - pcb->cwnd = 1; - pcb->ssthresh = pcb->mss * 10; -#if LWIP_CALLBACK_API - pcb->connected = connected; -#else /* LWIP_CALLBACK_API */ - LWIP_UNUSED_ARG(connected); -#endif /* LWIP_CALLBACK_API */ - - /* Send a SYN together with the MSS option. */ - ret = tcp_enqueue_flags(pcb, TCP_SYN); - if (ret == ERR_OK) { - /* SYN segment was enqueued, changed the pcbs state now */ - pcb->state = SYN_SENT; - if (old_local_port != 0) { - TCP_RMV(&tcp_bound_pcbs, pcb); - } - TCP_REG_ACTIVE(pcb); - snmp_inc_tcpactiveopens(); - - tcp_output(pcb); - } - return ret; -} - -/** - * Called every 500 ms and implements the retransmission timer and the timer that - * removes PCBs that have been in TIME-WAIT for enough time. It also increments - * various timers such as the inactivity timer in each PCB. - * - * Automatically called from tcp_tmr(). - */ -void -tcp_slowtmr(void) -{ - struct tcp_pcb *pcb, *prev; - u16_t eff_wnd; - u8_t pcb_remove; /* flag if a PCB should be removed */ - u8_t pcb_reset; /* flag if a RST should be sent when removing */ - err_t err; - - err = ERR_OK; - - ++tcp_ticks; - ++tcp_timer_ctr; - -tcp_slowtmr_start: - /* Steps through all of the active PCBs. */ - prev = NULL; - pcb = tcp_active_pcbs; - if (pcb == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n")); - } - while (pcb != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n")); - LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED); - LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN); - LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT); - if (pcb->last_timer == tcp_timer_ctr) { - /* skip this pcb, we have already processed it */ - pcb = pcb->next; - continue; - } - pcb->last_timer = tcp_timer_ctr; - - pcb_remove = 0; - pcb_reset = 0; - - if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); - } - else if (pcb->nrtx == TCP_MAXRTX) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); - } else { - if (pcb->persist_backoff > 0) { - /* If snd_wnd is zero, use persist timer to send 1 byte probes - * instead of using the standard retransmission mechanism. */ - pcb->persist_cnt++; - if (pcb->persist_cnt >= tcp_persist_backoff[pcb->persist_backoff-1]) { - pcb->persist_cnt = 0; - if (pcb->persist_backoff < sizeof(tcp_persist_backoff)) { - pcb->persist_backoff++; - } - tcp_zero_window_probe(pcb); - } - } else { - /* Increase the retransmission timer if it is running */ - if(pcb->rtime >= 0) { - ++pcb->rtime; - } - - if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) { - /* Time for a retransmission. */ - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %"S16_F - " pcb->rto %"S16_F"\n", - pcb->rtime, pcb->rto)); - - /* Double retransmission time-out unless we are trying to - * connect to somebody (i.e., we are in SYN_SENT). */ - if (pcb->state != SYN_SENT) { - pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx]; - } - - /* Reset the retransmission timer. */ - pcb->rtime = 0; - - /* Reduce congestion window and ssthresh. */ - eff_wnd = LWIP_MIN(pcb->cwnd, pcb->snd_wnd); - pcb->ssthresh = eff_wnd >> 1; - if (pcb->ssthresh < (pcb->mss << 1)) { - pcb->ssthresh = (pcb->mss << 1); - } - pcb->cwnd = pcb->mss; - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F - " ssthresh %"U16_F"\n", - pcb->cwnd, pcb->ssthresh)); - - /* The following needs to be called AFTER cwnd is set to one - mss - STJ */ - tcp_rexmit_rto(pcb); - } - } - } - /* Check if this PCB has stayed too long in FIN-WAIT-2 */ - if (pcb->state == FIN_WAIT_2) { - /* If this PCB is in FIN_WAIT_2 because of SHUT_WR don't let it time out. */ - if (pcb->flags & TF_RXCLOSED) { - /* PCB was fully closed (either through close() or SHUT_RDWR): - normal FIN-WAIT timeout handling. */ - if ((u32_t)(tcp_ticks - pcb->tmr) > - TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); - } - } - } - - /* Check if KEEPALIVE should be sent */ - if(ip_get_option(pcb, SOF_KEEPALIVE) && - ((pcb->state == ESTABLISHED) || - (pcb->state == CLOSE_WAIT))) { - if((u32_t)(tcp_ticks - pcb->tmr) > - (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) - { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n", - ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), - ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); - - ++pcb_remove; - ++pcb_reset; - } - else if((u32_t)(tcp_ticks - pcb->tmr) > - (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb)) - / TCP_SLOW_INTERVAL) - { - tcp_keepalive(pcb); - pcb->keep_cnt_sent++; - } - } - - /* If this PCB has queued out of sequence data, but has been - inactive for too long, will drop the data (it will eventually - be retransmitted). */ -#if TCP_QUEUE_OOSEQ - if (pcb->ooseq != NULL && - (u32_t)tcp_ticks - pcb->tmr >= pcb->rto * TCP_OOSEQ_TIMEOUT) { - tcp_segs_free(pcb->ooseq); - pcb->ooseq = NULL; - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); - } -#endif /* TCP_QUEUE_OOSEQ */ - - /* Check if this PCB has stayed too long in SYN-RCVD */ - if (pcb->state == SYN_RCVD) { - if ((u32_t)(tcp_ticks - pcb->tmr) > - TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); - } - } - - /* Check if this PCB has stayed too long in LAST-ACK */ - if (pcb->state == LAST_ACK) { - if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in LAST-ACK\n")); - } - } - - /* If the PCB should be removed, do it. */ - if (pcb_remove) { - struct tcp_pcb *pcb2; - tcp_err_fn err_fn; - void *err_arg; - tcp_pcb_purge(pcb); - /* Remove PCB from tcp_active_pcbs list. */ - if (prev != NULL) { - LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs); - prev->next = pcb->next; - } else { - /* This PCB was the first. */ - LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb); - tcp_active_pcbs = pcb->next; - } - - if (pcb_reset) { - tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, - pcb->local_port, pcb->remote_port); - } - - err_fn = pcb->errf; - err_arg = pcb->callback_arg; - pcb2 = pcb; - pcb = pcb->next; - memp_free(MEMP_TCP_PCB, pcb2); - - tcp_active_pcbs_changed = 0; - TCP_EVENT_ERR(err_fn, err_arg, ERR_ABRT); - if (tcp_active_pcbs_changed) { - goto tcp_slowtmr_start; - } - } else { - /* get the 'next' element now and work with 'prev' below (in case of abort) */ - prev = pcb; - pcb = pcb->next; - - /* We check if we should poll the connection. */ - ++prev->polltmr; - if (prev->polltmr >= prev->pollinterval) { - prev->polltmr = 0; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n")); - tcp_active_pcbs_changed = 0; - TCP_EVENT_POLL(prev, err); - if (tcp_active_pcbs_changed) { - goto tcp_slowtmr_start; - } - /* if err == ERR_ABRT, 'prev' is already deallocated */ - if (err == ERR_OK) { - tcp_output(prev); - } - } - } - } - - - /* Steps through all of the TIME-WAIT PCBs. */ - prev = NULL; - pcb = tcp_tw_pcbs; - while (pcb != NULL) { - LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); - pcb_remove = 0; - - /* Check if this PCB has stayed long enough in TIME-WAIT */ - if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { - ++pcb_remove; - } - - - - /* If the PCB should be removed, do it. */ - if (pcb_remove) { - struct tcp_pcb *pcb2; - tcp_pcb_purge(pcb); - /* Remove PCB from tcp_tw_pcbs list. */ - if (prev != NULL) { - LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs); - prev->next = pcb->next; - } else { - /* This PCB was the first. */ - LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", tcp_tw_pcbs == pcb); - tcp_tw_pcbs = pcb->next; - } - pcb2 = pcb; - pcb = pcb->next; - memp_free(MEMP_TCP_PCB, pcb2); - } else { - prev = pcb; - pcb = pcb->next; - } - } -} - -/** - * Is called every TCP_FAST_INTERVAL (250 ms) and process data previously - * "refused" by upper layer (application) and sends delayed ACKs. - * - * Automatically called from tcp_tmr(). - */ -void -tcp_fasttmr(void) -{ - struct tcp_pcb *pcb; - - ++tcp_timer_ctr; - -tcp_fasttmr_start: - pcb = tcp_active_pcbs; - - while(pcb != NULL) { - if (pcb->last_timer != tcp_timer_ctr) { - struct tcp_pcb *next; - pcb->last_timer = tcp_timer_ctr; - /* send delayed ACKs */ - if (pcb->flags & TF_ACK_DELAY) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); - tcp_ack_now(pcb); - tcp_output(pcb); - pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); - } - - next = pcb->next; - - /* If there is data which was previously "refused" by upper layer */ - if (pcb->refused_data != NULL) { - tcp_active_pcbs_changed = 0; - tcp_process_refused_data(pcb); - if (tcp_active_pcbs_changed) { - /* application callback has changed the pcb list: restart the loop */ - goto tcp_fasttmr_start; - } - } - pcb = next; - } - } -} - -/** Pass pcb->refused_data to the recv callback */ -err_t -tcp_process_refused_data(struct tcp_pcb *pcb) -{ - err_t err; - u8_t refused_flags = pcb->refused_data->flags; - /* set pcb->refused_data to NULL in case the callback frees it and then - closes the pcb */ - struct pbuf *refused_data = pcb->refused_data; - pcb->refused_data = NULL; - /* Notify again application with data previously received. */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: notify kept packet\n")); - TCP_EVENT_RECV(pcb, refused_data, ERR_OK, err); - if (err == ERR_OK) { - /* did refused_data include a FIN? */ - if (refused_flags & PBUF_FLAG_TCP_FIN) { - /* correct rcv_wnd as the application won't call tcp_recved() - for the FIN's seqno */ - if (pcb->rcv_wnd != TCP_WND) { - pcb->rcv_wnd++; - } - TCP_EVENT_CLOSED(pcb, err); - if (err == ERR_ABRT) { - return ERR_ABRT; - } - } - } else if (err == ERR_ABRT) { - /* if err == ERR_ABRT, 'pcb' is already deallocated */ - /* Drop incoming packets because pcb is "full" (only if the incoming - segment contains data). */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: drop incoming packets, because pcb is \"full\"\n")); - return ERR_ABRT; - } else { - /* data is still refused, pbuf is still valid (go on for ACK-only packets) */ - pcb->refused_data = refused_data; - } - return ERR_OK; -} - -/** - * Deallocates a list of TCP segments (tcp_seg structures). - * - * @param seg tcp_seg list of TCP segments to free - */ -void -tcp_segs_free(struct tcp_seg *seg) -{ - while (seg != NULL) { - struct tcp_seg *next = seg->next; - tcp_seg_free(seg); - seg = next; - } -} - -/** - * Frees a TCP segment (tcp_seg structure). - * - * @param seg single tcp_seg to free - */ -void -tcp_seg_free(struct tcp_seg *seg) -{ - if (seg != NULL) { - if (seg->p != NULL) { - pbuf_free(seg->p); -#if TCP_DEBUG - seg->p = NULL; -#endif /* TCP_DEBUG */ - } - memp_free(MEMP_TCP_SEG, seg); - } -} - -/** - * Sets the priority of a connection. - * - * @param pcb the tcp_pcb to manipulate - * @param prio new priority - */ -void -tcp_setprio(struct tcp_pcb *pcb, u8_t prio) -{ - pcb->prio = prio; -} - -#if TCP_QUEUE_OOSEQ -/** - * Returns a copy of the given TCP segment. - * The pbuf and data are not copied, only the pointers - * - * @param seg the old tcp_seg - * @return a copy of seg - */ -struct tcp_seg * -tcp_seg_copy(struct tcp_seg *seg) -{ - struct tcp_seg *cseg; - - cseg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG); - if (cseg == NULL) { - return NULL; - } - SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); - pbuf_ref(cseg->p); - return cseg; -} -#endif /* TCP_QUEUE_OOSEQ */ - -#if LWIP_CALLBACK_API -/** - * Default receive callback that is called if the user didn't register - * a recv callback for the pcb. - */ -err_t -tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) -{ - LWIP_UNUSED_ARG(arg); - if (p != NULL) { - tcp_recved(pcb, p->tot_len); - pbuf_free(p); - } else if (err == ERR_OK) { - return tcp_close(pcb); - } - return ERR_OK; -} -#endif /* LWIP_CALLBACK_API */ - -/** - * Kills the oldest active connection that has the same or lower priority than - * 'prio'. - * - * @param prio minimum priority - */ -static void -tcp_kill_prio(u8_t prio) -{ - struct tcp_pcb *pcb, *inactive; - u32_t inactivity; - u8_t mprio; - - - mprio = TCP_PRIO_MAX; - - /* We kill the oldest active connection that has lower priority than prio. */ - inactivity = 0; - inactive = NULL; - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - if (pcb->prio <= prio && - pcb->prio <= mprio && - (u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { - inactivity = tcp_ticks - pcb->tmr; - inactive = pcb; - mprio = pcb->prio; - } - } - if (inactive != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%"S32_F")\n", - (void *)inactive, inactivity)); - tcp_abort(inactive); - } -} - -/** - * Kills the oldest connection that is in TIME_WAIT state. - * Called from tcp_alloc() if no more connections are available. - */ -static void -tcp_kill_timewait(void) -{ - struct tcp_pcb *pcb, *inactive; - u32_t inactivity; - - inactivity = 0; - inactive = NULL; - /* Go through the list of TIME_WAIT pcbs and get the oldest pcb. */ - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - if ((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { - inactivity = tcp_ticks - pcb->tmr; - inactive = pcb; - } - } - if (inactive != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%"S32_F")\n", - (void *)inactive, inactivity)); - tcp_abort(inactive); - } -} - -/** - * Allocate a new tcp_pcb structure. - * - * @param prio priority for the new pcb - * @return a new tcp_pcb that initially is in state CLOSED - */ -struct tcp_pcb * -tcp_alloc(u8_t prio) -{ - struct tcp_pcb *pcb; - u32_t iss; - - pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); - if (pcb == NULL) { - /* Try killing oldest connection in TIME-WAIT. */ - LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n")); - tcp_kill_timewait(); - /* Try to allocate a tcp_pcb again. */ - pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); - if (pcb == NULL) { - /* Try killing active connections with lower priority than the new one. */ - LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing connection with prio lower than %d\n", prio)); - tcp_kill_prio(prio); - /* Try to allocate a tcp_pcb again. */ - pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); - if (pcb != NULL) { - /* adjust err stats: memp_malloc failed twice before */ - MEMP_STATS_DEC(err, MEMP_TCP_PCB); - } - } - if (pcb != NULL) { - /* adjust err stats: timewait PCB was freed above */ - MEMP_STATS_DEC(err, MEMP_TCP_PCB); - } - } - if (pcb != NULL) { - memset(pcb, 0, sizeof(struct tcp_pcb)); - pcb->prio = prio; - pcb->snd_buf = TCP_SND_BUF; - pcb->snd_queuelen = 0; - pcb->rcv_wnd = TCP_WND; - pcb->rcv_ann_wnd = TCP_WND; - pcb->tos = 0; - pcb->ttl = TCP_TTL; - /* As initial send MSS, we use TCP_MSS but limit it to 536. - The send MSS is updated when an MSS option is received. */ - pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; - pcb->rto = 3000 / TCP_SLOW_INTERVAL; - pcb->sa = 0; - pcb->sv = 3000 / TCP_SLOW_INTERVAL; - pcb->rtime = -1; - pcb->cwnd = 1; - iss = tcp_next_iss(); - pcb->snd_wl2 = iss; - pcb->snd_nxt = iss; - pcb->lastack = iss; - pcb->snd_lbb = iss; - pcb->tmr = tcp_ticks; - pcb->last_timer = tcp_timer_ctr; - - pcb->polltmr = 0; - -#if LWIP_CALLBACK_API - pcb->recv = tcp_recv_null; -#endif /* LWIP_CALLBACK_API */ - - /* Init KEEPALIVE timer */ - pcb->keep_idle = TCP_KEEPIDLE_DEFAULT; - -#if LWIP_TCP_KEEPALIVE - pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT; - pcb->keep_cnt = TCP_KEEPCNT_DEFAULT; -#endif /* LWIP_TCP_KEEPALIVE */ - - pcb->keep_cnt_sent = 0; - } - return pcb; -} - -/** - * Creates a new TCP protocol control block but doesn't place it on - * any of the TCP PCB lists. - * The pcb is not put on any list until binding using tcp_bind(). - * - * @internal: Maybe there should be a idle TCP PCB list where these - * PCBs are put on. Port reservation using tcp_bind() is implemented but - * allocated pcbs that are not bound can't be killed automatically if wanting - * to allocate a pcb with higher prio (@see tcp_kill_prio()) - * - * @return a new tcp_pcb that initially is in state CLOSED - */ -struct tcp_pcb * -tcp_new(void) -{ - return tcp_alloc(TCP_PRIO_NORMAL); -} - -/** - * Used to specify the argument that should be passed callback - * functions. - * - * @param pcb tcp_pcb to set the callback argument - * @param arg void pointer argument to pass to callback functions - */ -void -tcp_arg(struct tcp_pcb *pcb, void *arg) -{ - /* This function is allowed to be called for both listen pcbs and - connection pcbs. */ - pcb->callback_arg = arg; -} -#if LWIP_CALLBACK_API - -/** - * Used to specify the function that should be called when a TCP - * connection receives data. - * - * @param pcb tcp_pcb to set the recv callback - * @param recv callback function to call for this pcb when data is received - */ -void -tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) -{ - LWIP_ASSERT("invalid socket state for recv callback", pcb->state != LISTEN); - pcb->recv = recv; -} - -/** - * Used to specify the function that should be called when TCP data - * has been successfully delivered to the remote host. - * - * @param pcb tcp_pcb to set the sent callback - * @param sent callback function to call for this pcb when data is successfully sent - */ -void -tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) -{ - LWIP_ASSERT("invalid socket state for sent callback", pcb->state != LISTEN); - pcb->sent = sent; -} - -/** - * Used to specify the function that should be called when a fatal error - * has occured on the connection. - * - * @param pcb tcp_pcb to set the err callback - * @param err callback function to call for this pcb when a fatal error - * has occured on the connection - */ -void -tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) -{ - LWIP_ASSERT("invalid socket state for err callback", pcb->state != LISTEN); - pcb->errf = err; -} - -/** - * Used for specifying the function that should be called when a - * LISTENing connection has been connected to another host. - * - * @param pcb tcp_pcb to set the accept callback - * @param accept callback function to call for this pcb when LISTENing - * connection has been connected to another host - */ -void -tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) -{ - /* This function is allowed to be called for both listen pcbs and - connection pcbs. */ - pcb->accept = accept; -} -#endif /* LWIP_CALLBACK_API */ - - -/** - * Used to specify the function that should be called periodically - * from TCP. The interval is specified in terms of the TCP coarse - * timer interval, which is called twice a second. - * - */ -void -tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval) -{ - LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN); -#if LWIP_CALLBACK_API - pcb->poll = poll; -#else /* LWIP_CALLBACK_API */ - LWIP_UNUSED_ARG(poll); -#endif /* LWIP_CALLBACK_API */ - pcb->pollinterval = interval; -} - -/** - * Purges a TCP PCB. Removes any buffered data and frees the buffer memory - * (pcb->ooseq, pcb->unsent and pcb->unacked are freed). - * - * @param pcb tcp_pcb to purge. The pcb itself is not deallocated! - */ -void -tcp_pcb_purge(struct tcp_pcb *pcb) -{ - if (pcb->state != CLOSED && - pcb->state != TIME_WAIT && - pcb->state != LISTEN) { - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n")); - -#if TCP_LISTEN_BACKLOG - if (pcb->state == SYN_RCVD) { - /* Need to find the corresponding listen_pcb and decrease its accepts_pending */ - struct tcp_pcb_listen *lpcb; - LWIP_ASSERT("tcp_pcb_purge: pcb->state == SYN_RCVD but tcp_listen_pcbs is NULL", - tcp_listen_pcbs.listen_pcbs != NULL); - for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - if ((lpcb->local_port == pcb->local_port) && - (ip_addr_isany(&lpcb->local_ip) || - ip_addr_cmp(&pcb->local_ip, &lpcb->local_ip))) { - /* port and address of the listen pcb match the timed-out pcb */ - LWIP_ASSERT("tcp_pcb_purge: listen pcb does not have accepts pending", - lpcb->accepts_pending > 0); - lpcb->accepts_pending--; - break; - } - } - } -#endif /* TCP_LISTEN_BACKLOG */ - - - if (pcb->refused_data != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->refused_data\n")); - pbuf_free(pcb->refused_data); - pcb->refused_data = NULL; - } - if (pcb->unsent != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n")); - } - if (pcb->unacked != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n")); - } -#if TCP_QUEUE_OOSEQ - if (pcb->ooseq != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n")); - } - tcp_segs_free(pcb->ooseq); - pcb->ooseq = NULL; -#endif /* TCP_QUEUE_OOSEQ */ - - /* Stop the retransmission timer as it will expect data on unacked - queue if it fires */ - pcb->rtime = -1; - - tcp_segs_free(pcb->unsent); - tcp_segs_free(pcb->unacked); - pcb->unacked = pcb->unsent = NULL; -#if TCP_OVERSIZE - pcb->unsent_oversize = 0; -#endif /* TCP_OVERSIZE */ - } -} - -/** - * Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first. - * - * @param pcblist PCB list to purge. - * @param pcb tcp_pcb to purge. The pcb itself is NOT deallocated! - */ -void -tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) -{ - TCP_RMV(pcblist, pcb); - - tcp_pcb_purge(pcb); - - /* if there is an outstanding delayed ACKs, send it */ - if (pcb->state != TIME_WAIT && - pcb->state != LISTEN && - pcb->flags & TF_ACK_DELAY) { - pcb->flags |= TF_ACK_NOW; - tcp_output(pcb); - } - - if (pcb->state != LISTEN) { - LWIP_ASSERT("unsent segments leaking", pcb->unsent == NULL); - LWIP_ASSERT("unacked segments leaking", pcb->unacked == NULL); -#if TCP_QUEUE_OOSEQ - LWIP_ASSERT("ooseq segments leaking", pcb->ooseq == NULL); -#endif /* TCP_QUEUE_OOSEQ */ - } - - pcb->state = CLOSED; - - LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane()); -} - -/** - * Calculates a new initial sequence number for new connections. - * - * @return u32_t pseudo random sequence number - */ -u32_t -tcp_next_iss(void) -{ - static u32_t iss = 6510; - - iss += tcp_ticks; /* XXX */ - return iss; -} - -#if TCP_CALCULATE_EFF_SEND_MSS -/** - * Calcluates the effective send mss that can be used for a specific IP address - * by using ip_route to determin the netif used to send to the address and - * calculating the minimum of TCP_MSS and that netif's mtu (if set). - */ -u16_t -tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr) -{ - u16_t mss_s; - struct netif *outif; - - outif = ip_route(addr); - if ((outif != NULL) && (outif->mtu != 0)) { - mss_s = outif->mtu - IP_HLEN - TCP_HLEN; - /* RFC 1122, chap 4.2.2.6: - * Eff.snd.MSS = min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize - * We correct for TCP options in tcp_write(), and don't support IP options. - */ - sendmss = LWIP_MIN(sendmss, mss_s); - } - return sendmss; -} -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - -const char* -tcp_debug_state_str(enum tcp_state s) -{ - return tcp_state_str[s]; -} - -#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG -/** - * Print a tcp header for debugging purposes. - * - * @param tcphdr pointer to a struct tcp_hdr - */ -void -tcp_debug_print(struct tcp_hdr *tcphdr) -{ - LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n")); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", - ntohs(tcphdr->src), ntohs(tcphdr->dest))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (seq no)\n", - ntohl(tcphdr->seqno))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (ack no)\n", - ntohl(tcphdr->ackno))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %2"U16_F" | |%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"| %5"U16_F" | (hdrlen, flags (", - TCPH_HDRLEN(tcphdr), - TCPH_FLAGS(tcphdr) >> 5 & 1, - TCPH_FLAGS(tcphdr) >> 4 & 1, - TCPH_FLAGS(tcphdr) >> 3 & 1, - TCPH_FLAGS(tcphdr) >> 2 & 1, - TCPH_FLAGS(tcphdr) >> 1 & 1, - TCPH_FLAGS(tcphdr) & 1, - ntohs(tcphdr->wnd))); - tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); - LWIP_DEBUGF(TCP_DEBUG, ("), win)\n")); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04"X16_F" | %5"U16_F" | (chksum, urgp)\n", - ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); -} - -/** - * Print a tcp state for debugging purposes. - * - * @param s enum tcp_state to print - */ -void -tcp_debug_print_state(enum tcp_state s) -{ - LWIP_DEBUGF(TCP_DEBUG, ("State: %s\n", tcp_state_str[s])); -} - -/** - * Print tcp flags for debugging purposes. - * - * @param flags tcp flags, all active flags are printed - */ -void -tcp_debug_print_flags(u8_t flags) -{ - if (flags & TCP_FIN) { - LWIP_DEBUGF(TCP_DEBUG, ("FIN ")); - } - if (flags & TCP_SYN) { - LWIP_DEBUGF(TCP_DEBUG, ("SYN ")); - } - if (flags & TCP_RST) { - LWIP_DEBUGF(TCP_DEBUG, ("RST ")); - } - if (flags & TCP_PSH) { - LWIP_DEBUGF(TCP_DEBUG, ("PSH ")); - } - if (flags & TCP_ACK) { - LWIP_DEBUGF(TCP_DEBUG, ("ACK ")); - } - if (flags & TCP_URG) { - LWIP_DEBUGF(TCP_DEBUG, ("URG ")); - } - if (flags & TCP_ECE) { - LWIP_DEBUGF(TCP_DEBUG, ("ECE ")); - } - if (flags & TCP_CWR) { - LWIP_DEBUGF(TCP_DEBUG, ("CWR ")); - } - LWIP_DEBUGF(TCP_DEBUG, ("\n")); -} - -/** - * Print all tcp_pcbs in every list for debugging purposes. - */ -void -tcp_debug_print_pcbs(void) -{ - struct tcp_pcb *pcb; - LWIP_DEBUGF(TCP_DEBUG, ("Active PCB states:\n")); - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", - pcb->local_port, pcb->remote_port, - pcb->snd_nxt, pcb->rcv_nxt)); - tcp_debug_print_state(pcb->state); - } - LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); - for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", - pcb->local_port, pcb->remote_port, - pcb->snd_nxt, pcb->rcv_nxt)); - tcp_debug_print_state(pcb->state); - } - LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", - pcb->local_port, pcb->remote_port, - pcb->snd_nxt, pcb->rcv_nxt)); - tcp_debug_print_state(pcb->state); - } -} - -/** - * Check state consistency of the tcp_pcb lists. - */ -s16_t -tcp_pcbs_sane(void) -{ - struct tcp_pcb *pcb; - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != CLOSED", pcb->state != CLOSED); - LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != LISTEN", pcb->state != LISTEN); - LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); - } - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_pcbs_sane: tw pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); - } - return 1; -} -#endif /* TCP_DEBUG */ - -#endif /* LWIP_TCP */ diff --git a/user/mpy/lib/lwip/src/core/tcp_in.c b/user/mpy/lib/lwip/src/core/tcp_in.c deleted file mode 100644 index 4ec971a..0000000 --- a/user/mpy/lib/lwip/src/core/tcp_in.c +++ /dev/null @@ -1,1619 +0,0 @@ -/** - * @file - * Transmission Control Protocol, incoming traffic - * - * The input processing functions of the TCP layer. - * - * These functions are generally called in the order (ip_input() ->) - * tcp_input() -> * tcp_process() -> tcp_receive() (-> application). - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/tcp_impl.h" -#include "lwip/def.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/inet_chksum.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "arch/perf.h" - -/* These variables are global to all functions involved in the input - processing of TCP segments. They are set by the tcp_input() - function. */ -static struct tcp_seg inseg; -static struct tcp_hdr *tcphdr; -static struct ip_hdr *iphdr; -static u32_t seqno, ackno; -static u8_t flags; -static u16_t tcplen; - -static u8_t recv_flags; -static struct pbuf *recv_data; - -struct tcp_pcb *tcp_input_pcb; - -/* Forward declarations. */ -static err_t tcp_process(struct tcp_pcb *pcb); -static void tcp_receive(struct tcp_pcb *pcb); -static void tcp_parseopt(struct tcp_pcb *pcb); - -static err_t tcp_listen_input(struct tcp_pcb_listen *pcb); -static err_t tcp_timewait_input(struct tcp_pcb *pcb); - -/** - * The initial input processing of TCP. It verifies the TCP header, demultiplexes - * the segment between the PCBs and passes it on to tcp_process(), which implements - * the TCP finite state machine. This function is called by the IP layer (in - * ip_input()). - * - * @param p received TCP segment to process (p->payload pointing to the IP header) - * @param inp network interface on which this segment was received - */ -void -tcp_input(struct pbuf *p, struct netif *inp) -{ - struct tcp_pcb *pcb, *prev; - struct tcp_pcb_listen *lpcb; -#if SO_REUSE - struct tcp_pcb *lpcb_prev = NULL; - struct tcp_pcb_listen *lpcb_any = NULL; -#endif /* SO_REUSE */ - u8_t hdrlen; - err_t err; - - PERF_START; - - TCP_STATS_INC(tcp.recv); - snmp_inc_tcpinsegs(); - - iphdr = (struct ip_hdr *)p->payload; - tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4); - -#if TCP_INPUT_DEBUG - tcp_debug_print(tcphdr); -#endif - - /* remove header from payload */ - if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { - /* drop short packets */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%"U16_F" bytes) discarded\n", p->tot_len)); - TCP_STATS_INC(tcp.lenerr); - goto dropped; - } - - /* Don't even process incoming broadcasts/multicasts. */ - if (ip_addr_isbroadcast(¤t_iphdr_dest, inp) || - ip_addr_ismulticast(¤t_iphdr_dest)) { - TCP_STATS_INC(tcp.proterr); - goto dropped; - } - -#if CHECKSUM_CHECK_TCP - /* Verify TCP checksum. */ - if (inet_chksum_pseudo(p, ip_current_src_addr(), ip_current_dest_addr(), - IP_PROTO_TCP, p->tot_len) != 0) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04"X16_F"\n", - inet_chksum_pseudo(p, ip_current_src_addr(), ip_current_dest_addr(), - IP_PROTO_TCP, p->tot_len))); -#if TCP_DEBUG - tcp_debug_print(tcphdr); -#endif /* TCP_DEBUG */ - TCP_STATS_INC(tcp.chkerr); - goto dropped; - } -#endif - - /* Move the payload pointer in the pbuf so that it points to the - TCP data instead of the TCP header. */ - hdrlen = TCPH_HDRLEN(tcphdr); - if(pbuf_header(p, -(hdrlen * 4))){ - /* drop short packets */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet\n")); - TCP_STATS_INC(tcp.lenerr); - goto dropped; - } - - /* Convert fields in TCP header to host byte order. */ - tcphdr->src = ntohs(tcphdr->src); - tcphdr->dest = ntohs(tcphdr->dest); - seqno = tcphdr->seqno = ntohl(tcphdr->seqno); - ackno = tcphdr->ackno = ntohl(tcphdr->ackno); - tcphdr->wnd = ntohs(tcphdr->wnd); - - flags = TCPH_FLAGS(tcphdr); - tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0); - - /* Demultiplex an incoming segment. First, we check if it is destined - for an active connection. */ - prev = NULL; - - - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); - LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); - LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN); - if (pcb->remote_port == tcphdr->src && - pcb->local_port == tcphdr->dest && - ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) && - ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest)) { - - /* Move this PCB to the front of the list so that subsequent - lookups will be faster (we exploit locality in TCP segment - arrivals). */ - LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb); - if (prev != NULL) { - prev->next = pcb->next; - pcb->next = tcp_active_pcbs; - tcp_active_pcbs = pcb; - } - LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb); - break; - } - prev = pcb; - } - - if (pcb == NULL) { - /* If it did not go to an active connection, we check the connections - in the TIME-WAIT state. */ - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); - if (pcb->remote_port == tcphdr->src && - pcb->local_port == tcphdr->dest && - ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) && - ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest)) { - /* We don't really care enough to move this PCB to the front - of the list since we are not very likely to receive that - many segments for connections in TIME-WAIT. */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n")); - tcp_timewait_input(pcb); - pbuf_free(p); - return; - } - } - - /* Finally, if we still did not get a match, we check all PCBs that - are LISTENing for incoming connections. */ - prev = NULL; - for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - if (lpcb->local_port == tcphdr->dest) { -#if SO_REUSE - if (ip_addr_cmp(&(lpcb->local_ip), ¤t_iphdr_dest)) { - /* found an exact match */ - break; - } else if(ip_addr_isany(&(lpcb->local_ip))) { - /* found an ANY-match */ - lpcb_any = lpcb; - lpcb_prev = prev; - } -#else /* SO_REUSE */ - if (ip_addr_cmp(&(lpcb->local_ip), ¤t_iphdr_dest) || - ip_addr_isany(&(lpcb->local_ip))) { - /* found a match */ - break; - } -#endif /* SO_REUSE */ - } - prev = (struct tcp_pcb *)lpcb; - } -#if SO_REUSE - /* first try specific local IP */ - if (lpcb == NULL) { - /* only pass to ANY if no specific local IP has been found */ - lpcb = lpcb_any; - prev = lpcb_prev; - } -#endif /* SO_REUSE */ - if (lpcb != NULL) { - /* Move this PCB to the front of the list so that subsequent - lookups will be faster (we exploit locality in TCP segment - arrivals). */ - if (prev != NULL) { - ((struct tcp_pcb_listen *)prev)->next = lpcb->next; - /* our successor is the remainder of the listening list */ - lpcb->next = tcp_listen_pcbs.listen_pcbs; - /* put this listening pcb at the head of the listening list */ - tcp_listen_pcbs.listen_pcbs = lpcb; - } - - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); - tcp_listen_input(lpcb); - pbuf_free(p); - return; - } - } - -#if TCP_INPUT_DEBUG - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ")); - tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n")); -#endif /* TCP_INPUT_DEBUG */ - - - if (pcb != NULL) { - /* The incoming segment belongs to a connection. */ -#if TCP_INPUT_DEBUG -#if TCP_DEBUG - tcp_debug_print_state(pcb->state); -#endif /* TCP_DEBUG */ -#endif /* TCP_INPUT_DEBUG */ - - /* Set up a tcp_seg structure. */ - inseg.next = NULL; - inseg.len = p->tot_len; - inseg.p = p; - inseg.tcphdr = tcphdr; - - recv_data = NULL; - recv_flags = 0; - - if (flags & TCP_PSH) { - p->flags |= PBUF_FLAG_PUSH; - } - - /* If there is data which was previously "refused" by upper layer */ - if (pcb->refused_data != NULL) { - if ((tcp_process_refused_data(pcb) == ERR_ABRT) || - ((pcb->refused_data != NULL) && (tcplen > 0))) { - /* pcb has been aborted or refused data is still refused and the new - segment contains data */ - TCP_STATS_INC(tcp.drop); - snmp_inc_tcpinerrs(); - goto aborted; - } - } - tcp_input_pcb = pcb; - err = tcp_process(pcb); - /* A return value of ERR_ABRT means that tcp_abort() was called - and that the pcb has been freed. If so, we don't do anything. */ - if (err != ERR_ABRT) { - if (recv_flags & TF_RESET) { - /* TF_RESET means that the connection was reset by the other - end. We then call the error callback to inform the - application that the connection is dead before we - deallocate the PCB. */ - TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST); - tcp_pcb_remove(&tcp_active_pcbs, pcb); - memp_free(MEMP_TCP_PCB, pcb); - } else if (recv_flags & TF_CLOSED) { - /* The connection has been closed and we will deallocate the - PCB. */ - if (!(pcb->flags & TF_RXCLOSED)) { - /* Connection closed although the application has only shut down the - tx side: call the PCB's err callback and indicate the closure to - ensure the application doesn't continue using the PCB. */ - TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_CLSD); - } - tcp_pcb_remove(&tcp_active_pcbs, pcb); - memp_free(MEMP_TCP_PCB, pcb); - } else { - err = ERR_OK; - /* If the application has registered a "sent" function to be - called when new send buffer space is available, we call it - now. */ - if (pcb->acked > 0) { - TCP_EVENT_SENT(pcb, pcb->acked, err); - if (err == ERR_ABRT) { - goto aborted; - } - } - - if (recv_data != NULL) { - LWIP_ASSERT("pcb->refused_data == NULL", pcb->refused_data == NULL); - if (pcb->flags & TF_RXCLOSED) { - /* received data although already closed -> abort (send RST) to - notify the remote host that not all data has been processed */ - pbuf_free(recv_data); - tcp_abort(pcb); - goto aborted; - } - - /* Notify application that data has been received. */ - TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err); - if (err == ERR_ABRT) { - goto aborted; - } - - /* If the upper layer can't receive this data, store it */ - if (err != ERR_OK) { - pcb->refused_data = recv_data; - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: keep incoming packet, because pcb is \"full\"\n")); - } - } - - /* If a FIN segment was received, we call the callback - function with a NULL buffer to indicate EOF. */ - if (recv_flags & TF_GOT_FIN) { - if (pcb->refused_data != NULL) { - /* Delay this if we have refused data. */ - pcb->refused_data->flags |= PBUF_FLAG_TCP_FIN; - } else { - /* correct rcv_wnd as the application won't call tcp_recved() - for the FIN's seqno */ - if (pcb->rcv_wnd != TCP_WND) { - pcb->rcv_wnd++; - } - TCP_EVENT_CLOSED(pcb, err); - if (err == ERR_ABRT) { - goto aborted; - } - } - } - - tcp_input_pcb = NULL; - /* Try to send something out. */ - tcp_output(pcb); -#if TCP_INPUT_DEBUG -#if TCP_DEBUG - tcp_debug_print_state(pcb->state); -#endif /* TCP_DEBUG */ -#endif /* TCP_INPUT_DEBUG */ - } - } - /* Jump target if pcb has been aborted in a callback (by calling tcp_abort()). - Below this line, 'pcb' may not be dereferenced! */ -aborted: - tcp_input_pcb = NULL; - recv_data = NULL; - - /* give up our reference to inseg.p */ - if (inseg.p != NULL) - { - pbuf_free(inseg.p); - inseg.p = NULL; - } - } else { - - /* If no matching PCB was found, send a TCP RST (reset) to the - sender. */ - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); - if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) { - TCP_STATS_INC(tcp.proterr); - TCP_STATS_INC(tcp.drop); - tcp_rst(ackno, seqno + tcplen, - ip_current_dest_addr(), ip_current_src_addr(), - tcphdr->dest, tcphdr->src); - } - pbuf_free(p); - } - - LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); - PERF_STOP("tcp_input"); - return; -dropped: - TCP_STATS_INC(tcp.drop); - snmp_inc_tcpinerrs(); - pbuf_free(p); -} - -/** - * Called by tcp_input() when a segment arrives for a listening - * connection (from tcp_input()). - * - * @param pcb the tcp_pcb_listen for which a segment arrived - * @return ERR_OK if the segment was processed - * another err_t on error - * - * @note the return value is not (yet?) used in tcp_input() - * @note the segment which arrived is saved in global variables, therefore only the pcb - * involved is passed as a parameter to this function - */ -static err_t -tcp_listen_input(struct tcp_pcb_listen *pcb) -{ - struct tcp_pcb *npcb; - err_t rc; - - if (flags & TCP_RST) { - /* An incoming RST should be ignored. Return. */ - return ERR_OK; - } - - /* In the LISTEN state, we check for incoming SYN segments, - creates a new PCB, and responds with a SYN|ACK. */ - if (flags & TCP_ACK) { - /* For incoming segments with the ACK flag set, respond with a - RST. */ - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n")); - tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), - ip_current_src_addr(), tcphdr->dest, tcphdr->src); - } else if (flags & TCP_SYN) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest)); -#if TCP_LISTEN_BACKLOG - if (pcb->accepts_pending >= pcb->backlog) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: listen backlog exceeded for port %"U16_F"\n", tcphdr->dest)); - return ERR_ABRT; - } -#endif /* TCP_LISTEN_BACKLOG */ - npcb = tcp_alloc(pcb->prio); - /* If a new PCB could not be created (probably due to lack of memory), - we don't do anything, but rely on the sender will retransmit the - SYN at a time when we have more memory available. */ - if (npcb == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } -#if TCP_LISTEN_BACKLOG - pcb->accepts_pending++; -#endif /* TCP_LISTEN_BACKLOG */ - /* Set up the new PCB. */ - ip_addr_copy(npcb->local_ip, current_iphdr_dest); - npcb->local_port = pcb->local_port; - ip_addr_copy(npcb->remote_ip, current_iphdr_src); - npcb->remote_port = tcphdr->src; - npcb->state = SYN_RCVD; - npcb->rcv_nxt = seqno + 1; - npcb->rcv_ann_right_edge = npcb->rcv_nxt; - npcb->snd_wnd = tcphdr->wnd; - npcb->snd_wnd_max = tcphdr->wnd; - npcb->ssthresh = npcb->snd_wnd; - npcb->snd_wl1 = seqno - 1;/* initialise to seqno-1 to force window update */ - npcb->callback_arg = pcb->callback_arg; -#if LWIP_CALLBACK_API - npcb->accept = pcb->accept; -#endif /* LWIP_CALLBACK_API */ - /* inherit socket options */ - npcb->so_options = pcb->so_options & SOF_INHERITED; - /* Register the new PCB so that we can begin receiving segments - for it. */ - TCP_REG_ACTIVE(npcb); - - /* Parse any options in the SYN. */ - tcp_parseopt(npcb); -#if TCP_CALCULATE_EFF_SEND_MSS - npcb->mss = tcp_eff_send_mss(npcb->mss, &(npcb->remote_ip)); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - - snmp_inc_tcppassiveopens(); - - /* Send a SYN|ACK together with the MSS option. */ - rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK); - if (rc != ERR_OK) { - tcp_abandon(npcb, 0); - return rc; - } - return tcp_output(npcb); - } - return ERR_OK; -} - -/** - * Called by tcp_input() when a segment arrives for a connection in - * TIME_WAIT. - * - * @param pcb the tcp_pcb for which a segment arrived - * - * @note the segment which arrived is saved in global variables, therefore only the pcb - * involved is passed as a parameter to this function - */ -static err_t -tcp_timewait_input(struct tcp_pcb *pcb) -{ - /* RFC 1337: in TIME_WAIT, ignore RST and ACK FINs + any 'acceptable' segments */ - /* RFC 793 3.9 Event Processing - Segment Arrives: - * - first check sequence number - we skip that one in TIME_WAIT (always - * acceptable since we only send ACKs) - * - second check the RST bit (... return) */ - if (flags & TCP_RST) { - return ERR_OK; - } - /* - fourth, check the SYN bit, */ - if (flags & TCP_SYN) { - /* If an incoming segment is not acceptable, an acknowledgment - should be sent in reply */ - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) { - /* If the SYN is in the window it is an error, send a reset */ - tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), - tcphdr->dest, tcphdr->src); - return ERR_OK; - } - } else if (flags & TCP_FIN) { - /* - eighth, check the FIN bit: Remain in the TIME-WAIT state. - Restart the 2 MSL time-wait timeout.*/ - pcb->tmr = tcp_ticks; - } - - if ((tcplen > 0)) { - /* Acknowledge data, FIN or out-of-window SYN */ - pcb->flags |= TF_ACK_NOW; - return tcp_output(pcb); - } - return ERR_OK; -} - -/** - * Implements the TCP state machine. Called by tcp_input. In some - * states tcp_receive() is called to receive data. The tcp_seg - * argument will be freed by the caller (tcp_input()) unless the - * recv_data pointer in the pcb is set. - * - * @param pcb the tcp_pcb for which a segment arrived - * - * @note the segment which arrived is saved in global variables, therefore only the pcb - * involved is passed as a parameter to this function - */ -static err_t -tcp_process(struct tcp_pcb *pcb) -{ - struct tcp_seg *rseg; - u8_t acceptable = 0; - err_t err; - - err = ERR_OK; - - /* Process incoming RST segments. */ - if (flags & TCP_RST) { - /* First, determine if the reset is acceptable. */ - if (pcb->state == SYN_SENT) { - if (ackno == pcb->snd_nxt) { - acceptable = 1; - } - } else { - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, - pcb->rcv_nxt+pcb->rcv_wnd)) { - acceptable = 1; - } - } - - if (acceptable) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n")); - LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED); - recv_flags |= TF_RESET; - pcb->flags &= ~TF_ACK_DELAY; - return ERR_RST; - } else { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", - seqno, pcb->rcv_nxt)); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", - seqno, pcb->rcv_nxt)); - return ERR_OK; - } - } - - if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) { - /* Cope with new connection attempt after remote end crashed */ - tcp_ack_now(pcb); - return ERR_OK; - } - - if ((pcb->flags & TF_RXCLOSED) == 0) { - /* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */ - pcb->tmr = tcp_ticks; - } - pcb->keep_cnt_sent = 0; - - tcp_parseopt(pcb); - - /* Do different things depending on the TCP state. */ - switch (pcb->state) { - case SYN_SENT: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %"U32_F" pcb->snd_nxt %"U32_F" unacked %"U32_F"\n", ackno, - pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); - /* received SYN ACK with expected sequence number? */ - if ((flags & TCP_ACK) && (flags & TCP_SYN) - && ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) { - pcb->snd_buf++; - pcb->rcv_nxt = seqno + 1; - pcb->rcv_ann_right_edge = pcb->rcv_nxt; - pcb->lastack = ackno; - pcb->snd_wnd = tcphdr->wnd; - pcb->snd_wnd_max = tcphdr->wnd; - pcb->snd_wl1 = seqno - 1; /* initialise to seqno - 1 to force window update */ - pcb->state = ESTABLISHED; - -#if TCP_CALCULATE_EFF_SEND_MSS - pcb->mss = tcp_eff_send_mss(pcb->mss, &(pcb->remote_ip)); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - - /* Set ssthresh again after changing pcb->mss (already set in tcp_connect - * but for the default value of pcb->mss) */ - pcb->ssthresh = pcb->mss * 10; - - pcb->cwnd = ((pcb->cwnd == 1) ? (pcb->mss * 2) : pcb->mss); - LWIP_ASSERT("pcb->snd_queuelen > 0", (pcb->snd_queuelen > 0)); - --pcb->snd_queuelen; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %"U16_F"\n", (u16_t)pcb->snd_queuelen)); - rseg = pcb->unacked; - pcb->unacked = rseg->next; - tcp_seg_free(rseg); - - /* If there's nothing left to acknowledge, stop the retransmit - timer, otherwise reset it to start again */ - if(pcb->unacked == NULL) - pcb->rtime = -1; - else { - pcb->rtime = 0; - pcb->nrtx = 0; - } - - /* Call the user specified function to call when sucessfully - * connected. */ - TCP_EVENT_CONNECTED(pcb, ERR_OK, err); - if (err == ERR_ABRT) { - return ERR_ABRT; - } - tcp_ack_now(pcb); - } - /* received ACK? possibly a half-open connection */ - else if (flags & TCP_ACK) { - /* send a RST to bring the other side in a non-synchronized state. */ - tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), - tcphdr->dest, tcphdr->src); - } - break; - case SYN_RCVD: - if (flags & TCP_ACK) { - /* expected ACK number? */ - if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) { - u16_t old_cwnd; - pcb->state = ESTABLISHED; - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); -#if LWIP_CALLBACK_API - LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL); -#endif - /* Call the accept function. */ - TCP_EVENT_ACCEPT(pcb, ERR_OK, err); - if (err != ERR_OK) { - /* If the accept function returns with an error, we abort - * the connection. */ - /* Already aborted? */ - if (err != ERR_ABRT) { - tcp_abort(pcb); - } - return ERR_ABRT; - } - old_cwnd = pcb->cwnd; - /* If there was any data contained within this ACK, - * we'd better pass it on to the application as well. */ - tcp_receive(pcb); - - /* Prevent ACK for SYN to generate a sent event */ - if (pcb->acked != 0) { - pcb->acked--; - } - - pcb->cwnd = ((old_cwnd == 1) ? (pcb->mss * 2) : pcb->mss); - - if (recv_flags & TF_GOT_FIN) { - tcp_ack_now(pcb); - pcb->state = CLOSE_WAIT; - } - } else { - /* incorrect ACK number, send RST */ - tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(), ip_current_src_addr(), - tcphdr->dest, tcphdr->src); - } - } else if ((flags & TCP_SYN) && (seqno == pcb->rcv_nxt - 1)) { - /* Looks like another copy of the SYN - retransmit our SYN-ACK */ - tcp_rexmit(pcb); - } - break; - case CLOSE_WAIT: - /* FALLTHROUGH */ - case ESTABLISHED: - tcp_receive(pcb); - if (recv_flags & TF_GOT_FIN) { /* passive close */ - tcp_ack_now(pcb); - pcb->state = CLOSE_WAIT; - } - break; - case FIN_WAIT_1: - tcp_receive(pcb); - if (recv_flags & TF_GOT_FIN) { - if ((flags & TCP_ACK) && (ackno == pcb->snd_nxt)) { - LWIP_DEBUGF(TCP_DEBUG, - ("TCP connection closed: FIN_WAIT_1 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - tcp_ack_now(pcb); - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } else { - tcp_ack_now(pcb); - pcb->state = CLOSING; - } - } else if ((flags & TCP_ACK) && (ackno == pcb->snd_nxt)) { - pcb->state = FIN_WAIT_2; - } - break; - case FIN_WAIT_2: - tcp_receive(pcb); - if (recv_flags & TF_GOT_FIN) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: FIN_WAIT_2 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - tcp_ack_now(pcb); - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } - break; - case CLOSING: - tcp_receive(pcb); - if (flags & TCP_ACK && ackno == pcb->snd_nxt) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: CLOSING %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } - break; - case LAST_ACK: - tcp_receive(pcb); - if (flags & TCP_ACK && ackno == pcb->snd_nxt) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: LAST_ACK %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - /* bugfix #21699: don't set pcb->state to CLOSED here or we risk leaking segments */ - recv_flags |= TF_CLOSED; - } - break; - default: - break; - } - return ERR_OK; -} - -#if TCP_QUEUE_OOSEQ -/** - * Insert segment into the list (segments covered with new one will be deleted) - * - * Called from tcp_receive() - */ -static void -tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next) -{ - struct tcp_seg *old_seg; - - if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { - /* received segment overlaps all following segments */ - tcp_segs_free(next); - next = NULL; - } - else { - /* delete some following segments - oos queue may have segments with FIN flag */ - while (next && - TCP_SEQ_GEQ((seqno + cseg->len), - (next->tcphdr->seqno + next->len))) { - /* cseg with FIN already processed */ - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) { - TCPH_SET_FLAG(cseg->tcphdr, TCP_FIN); - } - old_seg = next; - next = next->next; - tcp_seg_free(old_seg); - } - if (next && - TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) { - /* We need to trim the incoming segment. */ - cseg->len = (u16_t)(next->tcphdr->seqno - seqno); - pbuf_realloc(cseg->p, cseg->len); - } - } - cseg->next = next; -} -#endif /* TCP_QUEUE_OOSEQ */ - -/** - * Called by tcp_process. Checks if the given segment is an ACK for outstanding - * data, and if so frees the memory of the buffered data. Next, is places the - * segment on any of the receive queues (pcb->recved or pcb->ooseq). If the segment - * is buffered, the pbuf is referenced by pbuf_ref so that it will not be freed until - * it has been removed from the buffer. - * - * If the incoming segment constitutes an ACK for a segment that was used for RTT - * estimation, the RTT is estimated here as well. - * - * Called from tcp_process(). - */ -static void -tcp_receive(struct tcp_pcb *pcb) -{ - struct tcp_seg *next; -#if TCP_QUEUE_OOSEQ - struct tcp_seg *prev, *cseg; -#endif /* TCP_QUEUE_OOSEQ */ - struct pbuf *p; - s32_t off; - s16_t m; - u32_t right_wnd_edge; - u16_t new_tot_len; - int found_dupack = 0; -#if TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS - u32_t ooseq_blen; - u16_t ooseq_qlen; -#endif /* TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS */ - - LWIP_ASSERT("tcp_receive: wrong state", pcb->state >= ESTABLISHED); - - if (flags & TCP_ACK) { - right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2; - - /* Update window. */ - if (TCP_SEQ_LT(pcb->snd_wl1, seqno) || - (pcb->snd_wl1 == seqno && TCP_SEQ_LT(pcb->snd_wl2, ackno)) || - (pcb->snd_wl2 == ackno && tcphdr->wnd > pcb->snd_wnd)) { - pcb->snd_wnd = tcphdr->wnd; - /* keep track of the biggest window announced by the remote host to calculate - the maximum segment size */ - if (pcb->snd_wnd_max < tcphdr->wnd) { - pcb->snd_wnd_max = tcphdr->wnd; - } - pcb->snd_wl1 = seqno; - pcb->snd_wl2 = ackno; - if (pcb->snd_wnd == 0) { - if (pcb->persist_backoff == 0) { - /* start persist timer */ - pcb->persist_cnt = 0; - pcb->persist_backoff = 1; - } - } else if (pcb->persist_backoff > 0) { - /* stop persist timer */ - pcb->persist_backoff = 0; - } - LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %"U16_F"\n", pcb->snd_wnd)); -#if TCP_WND_DEBUG - } else { - if (pcb->snd_wnd != tcphdr->wnd) { - LWIP_DEBUGF(TCP_WND_DEBUG, - ("tcp_receive: no window update lastack %"U32_F" ackno %" - U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n", - pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); - } -#endif /* TCP_WND_DEBUG */ - } - - /* (From Stevens TCP/IP Illustrated Vol II, p970.) Its only a - * duplicate ack if: - * 1) It doesn't ACK new data - * 2) length of received packet is zero (i.e. no payload) - * 3) the advertised window hasn't changed - * 4) There is outstanding unacknowledged data (retransmission timer running) - * 5) The ACK is == biggest ACK sequence number so far seen (snd_una) - * - * If it passes all five, should process as a dupack: - * a) dupacks < 3: do nothing - * b) dupacks == 3: fast retransmit - * c) dupacks > 3: increase cwnd - * - * If it only passes 1-3, should reset dupack counter (and add to - * stats, which we don't do in lwIP) - * - * If it only passes 1, should reset dupack counter - * - */ - - /* Clause 1 */ - if (TCP_SEQ_LEQ(ackno, pcb->lastack)) { - pcb->acked = 0; - /* Clause 2 */ - if (tcplen == 0) { - /* Clause 3 */ - if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge){ - /* Clause 4 */ - if (pcb->rtime >= 0) { - /* Clause 5 */ - if (pcb->lastack == ackno) { - found_dupack = 1; - if ((u8_t)(pcb->dupacks + 1) > pcb->dupacks) { - ++pcb->dupacks; - } - if (pcb->dupacks > 3) { - /* Inflate the congestion window, but not if it means that - the value overflows. */ - if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { - pcb->cwnd += pcb->mss; - } - } else if (pcb->dupacks == 3) { - /* Do fast retransmit */ - tcp_rexmit_fast(pcb); - } - } - } - } - } - /* If Clause (1) or more is true, but not a duplicate ack, reset - * count of consecutive duplicate acks */ - if (!found_dupack) { - pcb->dupacks = 0; - } - } else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){ - /* We come here when the ACK acknowledges new data. */ - - /* Reset the "IN Fast Retransmit" flag, since we are no longer - in fast retransmit. Also reset the congestion window to the - slow start threshold. */ - if (pcb->flags & TF_INFR) { - pcb->flags &= ~TF_INFR; - pcb->cwnd = pcb->ssthresh; - } - - /* Reset the number of retransmissions. */ - pcb->nrtx = 0; - - /* Reset the retransmission time-out. */ - pcb->rto = (pcb->sa >> 3) + pcb->sv; - - /* Update the send buffer space. Diff between the two can never exceed 64K? */ - pcb->acked = (u16_t)(ackno - pcb->lastack); - - pcb->snd_buf += pcb->acked; - - /* Reset the fast retransmit variables. */ - pcb->dupacks = 0; - pcb->lastack = ackno; - - /* Update the congestion control variables (cwnd and - ssthresh). */ - if (pcb->state >= ESTABLISHED) { - if (pcb->cwnd < pcb->ssthresh) { - if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { - pcb->cwnd += pcb->mss; - } - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %"U16_F"\n", pcb->cwnd)); - } else { - u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd); - if (new_cwnd > pcb->cwnd) { - pcb->cwnd = new_cwnd; - } - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %"U16_F"\n", pcb->cwnd)); - } - } - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n", - ackno, - pcb->unacked != NULL? - ntohl(pcb->unacked->tcphdr->seqno): 0, - pcb->unacked != NULL? - ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); - - /* Remove segment from the unacknowledged list if the incoming - ACK acknowlegdes them. */ - while (pcb->unacked != NULL && - TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + - TCP_TCPLEN(pcb->unacked), ackno)) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unacked\n", - ntohl(pcb->unacked->tcphdr->seqno), - ntohl(pcb->unacked->tcphdr->seqno) + - TCP_TCPLEN(pcb->unacked))); - - next = pcb->unacked; - pcb->unacked = pcb->unacked->next; - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); - LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); - /* Prevent ACK for FIN to generate a sent event */ - if ((pcb->acked != 0) && ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) != 0)) { - pcb->acked--; - } - - pcb->snd_queuelen -= pbuf_clen(next->p); - tcp_seg_free(next); - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unacked)\n", (u16_t)pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || - pcb->unsent != NULL); - } - } - - /* If there's nothing left to acknowledge, stop the retransmit - timer, otherwise reset it to start again */ - if(pcb->unacked == NULL) - pcb->rtime = -1; - else - pcb->rtime = 0; - - pcb->polltmr = 0; - } else { - /* Fix bug bug #21582: out of sequence ACK, didn't really ack anything */ - pcb->acked = 0; - } - - /* We go through the ->unsent list to see if any of the segments - on the list are acknowledged by the ACK. This may seem - strange since an "unsent" segment shouldn't be acked. The - rationale is that lwIP puts all outstanding segments on the - ->unsent list after a retransmission, so these segments may - in fact have been sent once. */ - while (pcb->unsent != NULL && - TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + - TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", - ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + - TCP_TCPLEN(pcb->unsent))); - - next = pcb->unsent; - pcb->unsent = pcb->unsent->next; -#if TCP_OVERSIZE - if (pcb->unsent == NULL) { - pcb->unsent_oversize = 0; - } -#endif /* TCP_OVERSIZE */ - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); - LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); - /* Prevent ACK for FIN to generate a sent event */ - if ((pcb->acked != 0) && ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) != 0)) { - pcb->acked--; - } - pcb->snd_queuelen -= pbuf_clen(next->p); - tcp_seg_free(next); - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unsent)\n", (u16_t)pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_receive: valid queue length", - pcb->unacked != NULL || pcb->unsent != NULL); - } - } - /* End of ACK for new data processing. */ - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %"U32_F" rtseq %"U32_F" ackno %"U32_F"\n", - pcb->rttest, pcb->rtseq, ackno)); - - /* RTT estimation calculations. This is done by checking if the - incoming segment acknowledges the segment we use to take a - round-trip time measurement. */ - if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) { - /* diff between this shouldn't exceed 32K since this are tcp timer ticks - and a round-trip shouldn't be that long... */ - m = (s16_t)(tcp_ticks - pcb->rttest); - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %"U16_F" ticks (%"U16_F" msec).\n", - m, m * TCP_SLOW_INTERVAL)); - - /* This is taken directly from VJs original code in his paper */ - m = m - (pcb->sa >> 3); - pcb->sa += m; - if (m < 0) { - m = -m; - } - m = m - (pcb->sv >> 2); - pcb->sv += m; - pcb->rto = (pcb->sa >> 3) + pcb->sv; - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %"U16_F" (%"U16_F" milliseconds)\n", - pcb->rto, pcb->rto * TCP_SLOW_INTERVAL)); - - pcb->rttest = 0; - } - } - - /* If the incoming segment contains data, we must process it - further unless the pcb already received a FIN. - (RFC 793, chapeter 3.9, "SEGMENT ARRIVES" in states CLOSE-WAIT, CLOSING, - LAST-ACK and TIME-WAIT: "Ignore the segment text.") */ - if ((tcplen > 0) && (pcb->state < CLOSE_WAIT)) { - /* This code basically does three things: - - +) If the incoming segment contains data that is the next - in-sequence data, this data is passed to the application. This - might involve trimming the first edge of the data. The rcv_nxt - variable and the advertised window are adjusted. - - +) If the incoming segment has data that is above the next - sequence number expected (->rcv_nxt), the segment is placed on - the ->ooseq queue. This is done by finding the appropriate - place in the ->ooseq queue (which is ordered by sequence - number) and trim the segment in both ends if needed. An - immediate ACK is sent to indicate that we received an - out-of-sequence segment. - - +) Finally, we check if the first segment on the ->ooseq queue - now is in sequence (i.e., if rcv_nxt >= ooseq->seqno). If - rcv_nxt > ooseq->seqno, we must trim the first edge of the - segment on ->ooseq before we adjust rcv_nxt. The data in the - segments that are now on sequence are chained onto the - incoming segment so that we only need to call the application - once. - */ - - /* First, we check if we must trim the first edge. We have to do - this if the sequence number of the incoming segment is less - than rcv_nxt, and the sequence number plus the length of the - segment is larger than rcv_nxt. */ - /* if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ - if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {*/ - if (TCP_SEQ_BETWEEN(pcb->rcv_nxt, seqno + 1, seqno + tcplen - 1)){ - /* Trimming the first edge is done by pushing the payload - pointer in the pbuf downwards. This is somewhat tricky since - we do not want to discard the full contents of the pbuf up to - the new starting point of the data since we have to keep the - TCP header which is present in the first pbuf in the chain. - - What is done is really quite a nasty hack: the first pbuf in - the pbuf chain is pointed to by inseg.p. Since we need to be - able to deallocate the whole pbuf, we cannot change this - inseg.p pointer to point to any of the later pbufs in the - chain. Instead, we point the ->payload pointer in the first - pbuf to data in one of the later pbufs. We also set the - inseg.data pointer to point to the right place. This way, the - ->p pointer will still point to the first pbuf, but the - ->p->payload pointer will point to data in another pbuf. - - After we are done with adjusting the pbuf pointers we must - adjust the ->data pointer in the seg and the segment - length.*/ - - off = pcb->rcv_nxt - seqno; - p = inseg.p; - LWIP_ASSERT("inseg.p != NULL", inseg.p); - LWIP_ASSERT("insane offset!", (off < 0x7fff)); - if (inseg.p->len < off) { - LWIP_ASSERT("pbuf too short!", (((s32_t)inseg.p->tot_len) >= off)); - new_tot_len = (u16_t)(inseg.p->tot_len - off); - while (p->len < off) { - off -= p->len; - /* KJM following line changed (with addition of new_tot_len var) - to fix bug #9076 - inseg.p->tot_len -= p->len; */ - p->tot_len = new_tot_len; - p->len = 0; - p = p->next; - } - if(pbuf_header(p, (s16_t)-off)) { - /* Do we need to cope with this failing? Assert for now */ - LWIP_ASSERT("pbuf_header failed", 0); - } - } else { - if(pbuf_header(inseg.p, (s16_t)-off)) { - /* Do we need to cope with this failing? Assert for now */ - LWIP_ASSERT("pbuf_header failed", 0); - } - } - inseg.len -= (u16_t)(pcb->rcv_nxt - seqno); - inseg.tcphdr->seqno = seqno = pcb->rcv_nxt; - } - else { - if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ - /* the whole segment is < rcv_nxt */ - /* must be a duplicate of a packet that has already been correctly handled */ - - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %"U32_F"\n", seqno)); - tcp_ack_now(pcb); - } - } - - /* The sequence number must be within the window (above rcv_nxt - and below rcv_nxt + rcv_wnd) in order to be further - processed. */ - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, - pcb->rcv_nxt + pcb->rcv_wnd - 1)){ - if (pcb->rcv_nxt == seqno) { - /* The incoming segment is the next in sequence. We check if - we have to trim the end of the segment and update rcv_nxt - and pass the data to the application. */ - tcplen = TCP_TCPLEN(&inseg); - - if (tcplen > pcb->rcv_wnd) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, - ("tcp_receive: other end overran receive window" - "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", - seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); - if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - /* Must remove the FIN from the header as we're trimming - * that byte of sequence-space from the packet */ - TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN); - } - /* Adjust length of segment to fit in the window. */ - inseg.len = pcb->rcv_wnd; - if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { - inseg.len -= 1; - } - pbuf_realloc(inseg.p, inseg.len); - tcplen = TCP_TCPLEN(&inseg); - LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n", - (seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd)); - } -#if TCP_QUEUE_OOSEQ - /* Received in-sequence data, adjust ooseq data if: - - FIN has been received or - - inseq overlaps with ooseq */ - if (pcb->ooseq != NULL) { - if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, - ("tcp_receive: received in-order FIN, binning ooseq queue\n")); - /* Received in-order FIN means anything that was received - * out of order must now have been received in-order, so - * bin the ooseq queue */ - while (pcb->ooseq != NULL) { - struct tcp_seg *old_ooseq = pcb->ooseq; - pcb->ooseq = pcb->ooseq->next; - tcp_seg_free(old_ooseq); - } - } else { - next = pcb->ooseq; - /* Remove all segments on ooseq that are covered by inseg already. - * FIN is copied from ooseq to inseg if present. */ - while (next && - TCP_SEQ_GEQ(seqno + tcplen, - next->tcphdr->seqno + next->len)) { - /* inseg cannot have FIN here (already processed above) */ - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN && - (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) == 0) { - TCPH_SET_FLAG(inseg.tcphdr, TCP_FIN); - tcplen = TCP_TCPLEN(&inseg); - } - prev = next; - next = next->next; - tcp_seg_free(prev); - } - /* Now trim right side of inseg if it overlaps with the first - * segment on ooseq */ - if (next && - TCP_SEQ_GT(seqno + tcplen, - next->tcphdr->seqno)) { - /* inseg cannot have FIN here (already processed above) */ - inseg.len = (u16_t)(next->tcphdr->seqno - seqno); - if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { - inseg.len -= 1; - } - pbuf_realloc(inseg.p, inseg.len); - tcplen = TCP_TCPLEN(&inseg); - LWIP_ASSERT("tcp_receive: segment not trimmed correctly to ooseq queue\n", - (seqno + tcplen) == next->tcphdr->seqno); - } - pcb->ooseq = next; - } - } -#endif /* TCP_QUEUE_OOSEQ */ - - pcb->rcv_nxt = seqno + tcplen; - - /* Update the receiver's (our) window. */ - LWIP_ASSERT("tcp_receive: tcplen > rcv_wnd\n", pcb->rcv_wnd >= tcplen); - pcb->rcv_wnd -= tcplen; - - tcp_update_rcv_ann_wnd(pcb); - - /* If there is data in the segment, we make preparations to - pass this up to the application. The ->recv_data variable - is used for holding the pbuf that goes to the - application. The code for reassembling out-of-sequence data - chains its data on this pbuf as well. - - If the segment was a FIN, we set the TF_GOT_FIN flag that will - be used to indicate to the application that the remote side has - closed its end of the connection. */ - if (inseg.p->tot_len > 0) { - recv_data = inseg.p; - /* Since this pbuf now is the responsibility of the - application, we delete our reference to it so that we won't - (mistakingly) deallocate it. */ - inseg.p = NULL; - } - if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.\n")); - recv_flags |= TF_GOT_FIN; - } - -#if TCP_QUEUE_OOSEQ - /* We now check if we have segments on the ->ooseq queue that - are now in sequence. */ - while (pcb->ooseq != NULL && - pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) { - - cseg = pcb->ooseq; - seqno = pcb->ooseq->tcphdr->seqno; - - pcb->rcv_nxt += TCP_TCPLEN(cseg); - LWIP_ASSERT("tcp_receive: ooseq tcplen > rcv_wnd\n", - pcb->rcv_wnd >= TCP_TCPLEN(cseg)); - pcb->rcv_wnd -= TCP_TCPLEN(cseg); - - tcp_update_rcv_ann_wnd(pcb); - - if (cseg->p->tot_len > 0) { - /* Chain this pbuf onto the pbuf that we will pass to - the application. */ - if (recv_data) { - pbuf_cat(recv_data, cseg->p); - } else { - recv_data = cseg->p; - } - cseg->p = NULL; - } - if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.\n")); - recv_flags |= TF_GOT_FIN; - if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */ - pcb->state = CLOSE_WAIT; - } - } - - pcb->ooseq = cseg->next; - tcp_seg_free(cseg); - } -#endif /* TCP_QUEUE_OOSEQ */ - - - /* Acknowledge the segment(s). */ - tcp_ack(pcb); - - } else { - /* We get here if the incoming segment is out-of-sequence. */ - tcp_send_empty_ack(pcb); -#if TCP_QUEUE_OOSEQ - /* We queue the segment on the ->ooseq queue. */ - if (pcb->ooseq == NULL) { - pcb->ooseq = tcp_seg_copy(&inseg); - } else { - /* If the queue is not empty, we walk through the queue and - try to find a place where the sequence number of the - incoming segment is between the sequence numbers of the - previous and the next segment on the ->ooseq queue. That is - the place where we put the incoming segment. If needed, we - trim the second edges of the previous and the incoming - segment so that it will fit into the sequence. - - If the incoming segment has the same sequence number as a - segment on the ->ooseq queue, we discard the segment that - contains less data. */ - - prev = NULL; - for(next = pcb->ooseq; next != NULL; next = next->next) { - if (seqno == next->tcphdr->seqno) { - /* The sequence number of the incoming segment is the - same as the sequence number of the segment on - ->ooseq. We check the lengths to see which one to - discard. */ - if (inseg.len > next->len) { - /* The incoming segment is larger than the old - segment. We replace some segments with the new - one. */ - cseg = tcp_seg_copy(&inseg); - if (cseg != NULL) { - if (prev != NULL) { - prev->next = cseg; - } else { - pcb->ooseq = cseg; - } - tcp_oos_insert_segment(cseg, next); - } - break; - } else { - /* Either the lenghts are the same or the incoming - segment was smaller than the old one; in either - case, we ditch the incoming segment. */ - break; - } - } else { - if (prev == NULL) { - if (TCP_SEQ_LT(seqno, next->tcphdr->seqno)) { - /* The sequence number of the incoming segment is lower - than the sequence number of the first segment on the - queue. We put the incoming segment first on the - queue. */ - cseg = tcp_seg_copy(&inseg); - if (cseg != NULL) { - pcb->ooseq = cseg; - tcp_oos_insert_segment(cseg, next); - } - break; - } - } else { - /*if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) && - TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {*/ - if (TCP_SEQ_BETWEEN(seqno, prev->tcphdr->seqno+1, next->tcphdr->seqno-1)) { - /* The sequence number of the incoming segment is in - between the sequence numbers of the previous and - the next segment on ->ooseq. We trim trim the previous - segment, delete next segments that included in received segment - and trim received, if needed. */ - cseg = tcp_seg_copy(&inseg); - if (cseg != NULL) { - if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) { - /* We need to trim the prev segment. */ - prev->len = (u16_t)(seqno - prev->tcphdr->seqno); - pbuf_realloc(prev->p, prev->len); - } - prev->next = cseg; - tcp_oos_insert_segment(cseg, next); - } - break; - } - } - /* If the "next" segment is the last segment on the - ooseq queue, we add the incoming segment to the end - of the list. */ - if (next->next == NULL && - TCP_SEQ_GT(seqno, next->tcphdr->seqno)) { - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) { - /* segment "next" already contains all data */ - break; - } - next->next = tcp_seg_copy(&inseg); - if (next->next != NULL) { - if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) { - /* We need to trim the last segment. */ - next->len = (u16_t)(seqno - next->tcphdr->seqno); - pbuf_realloc(next->p, next->len); - } - /* check if the remote side overruns our receive window */ - if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, - ("tcp_receive: other end overran receive window" - "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", - seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); - if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) { - /* Must remove the FIN from the header as we're trimming - * that byte of sequence-space from the packet */ - TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN); - } - /* Adjust length of segment to fit in the window. */ - next->next->len = pcb->rcv_nxt + pcb->rcv_wnd - seqno; - pbuf_realloc(next->next->p, next->next->len); - tcplen = TCP_TCPLEN(next->next); - LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n", - (seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd)); - } - } - break; - } - } - prev = next; - } - } -#if TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS - /* Check that the data on ooseq doesn't exceed one of the limits - and throw away everything above that limit. */ - ooseq_blen = 0; - ooseq_qlen = 0; - prev = NULL; - for(next = pcb->ooseq; next != NULL; prev = next, next = next->next) { - struct pbuf *p = next->p; - ooseq_blen += p->tot_len; - ooseq_qlen += pbuf_clen(p); - if ((ooseq_blen > TCP_OOSEQ_MAX_BYTES) || - (ooseq_qlen > TCP_OOSEQ_MAX_PBUFS)) { - /* too much ooseq data, dump this and everything after it */ - tcp_segs_free(next); - if (prev == NULL) { - /* first ooseq segment is too much, dump the whole queue */ - pcb->ooseq = NULL; - } else { - /* just dump 'next' and everything after it */ - prev->next = NULL; - } - break; - } - } -#endif /* TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS */ -#endif /* TCP_QUEUE_OOSEQ */ - } - } else { - /* The incoming segment is not withing the window. */ - tcp_send_empty_ack(pcb); - } - } else { - /* Segments with length 0 is taken care of here. Segments that - fall out of the window are ACKed. */ - /*if (TCP_SEQ_GT(pcb->rcv_nxt, seqno) || - TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {*/ - if(!TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd-1)){ - tcp_ack_now(pcb); - } - } -} - -/** - * Parses the options contained in the incoming segment. - * - * Called from tcp_listen_input() and tcp_process(). - * Currently, only the MSS option is supported! - * - * @param pcb the tcp_pcb for which a segment arrived - */ -static void -tcp_parseopt(struct tcp_pcb *pcb) -{ - u16_t c, max_c; - u16_t mss; - u8_t *opts, opt; -#if LWIP_TCP_TIMESTAMPS - u32_t tsval; -#endif - - opts = (u8_t *)tcphdr + TCP_HLEN; - - /* Parse the TCP MSS option, if present. */ - if(TCPH_HDRLEN(tcphdr) > 0x5) { - max_c = (TCPH_HDRLEN(tcphdr) - 5) << 2; - for (c = 0; c < max_c; ) { - opt = opts[c]; - switch (opt) { - case 0x00: - /* End of options. */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: EOL\n")); - return; - case 0x01: - /* NOP option. */ - ++c; - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: NOP\n")); - break; - case 0x02: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: MSS\n")); - if (opts[c + 1] != 0x04 || c + 0x04 > max_c) { - /* Bad length */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); - return; - } - /* An MSS option with the right option length. */ - mss = (opts[c + 2] << 8) | opts[c + 3]; - /* Limit the mss to the configured TCP_MSS and prevent division by zero */ - pcb->mss = ((mss > TCP_MSS) || (mss == 0)) ? TCP_MSS : mss; - /* Advance to next option */ - c += 0x04; - break; -#if LWIP_TCP_TIMESTAMPS - case 0x08: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: TS\n")); - if (opts[c + 1] != 0x0A || c + 0x0A > max_c) { - /* Bad length */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); - return; - } - /* TCP timestamp option with valid length */ - tsval = (opts[c+2]) | (opts[c+3] << 8) | - (opts[c+4] << 16) | (opts[c+5] << 24); - if (flags & TCP_SYN) { - pcb->ts_recent = ntohl(tsval); - pcb->flags |= TF_TIMESTAMP; - } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno+tcplen)) { - pcb->ts_recent = ntohl(tsval); - } - /* Advance to next option */ - c += 0x0A; - break; -#endif - default: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: other\n")); - if (opts[c + 1] == 0) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); - /* If the length field is zero, the options are malformed - and we don't process them further. */ - return; - } - /* All other options have a length field, so that we easily - can skip past them. */ - c += opts[c + 1]; - } - } - } -} - -#endif /* LWIP_TCP */ diff --git a/user/mpy/lib/lwip/src/core/tcp_out.c b/user/mpy/lib/lwip/src/core/tcp_out.c deleted file mode 100644 index ee19fe0..0000000 --- a/user/mpy/lib/lwip/src/core/tcp_out.c +++ /dev/null @@ -1,1485 +0,0 @@ -/** - * @file - * Transmission Control Protocol, outgoing traffic - * - * The output functions of TCP. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/tcp_impl.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/inet_chksum.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#if LWIP_TCP_TIMESTAMPS -#include "lwip/sys.h" -#endif - -#include - -/* Define some copy-macros for checksum-on-copy so that the code looks - nicer by preventing too many ifdef's. */ -#if TCP_CHECKSUM_ON_COPY -#define TCP_DATA_COPY(dst, src, len, seg) do { \ - tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst, src, len), \ - len, &seg->chksum, &seg->chksum_swapped); \ - seg->flags |= TF_SEG_DATA_CHECKSUMMED; } while(0) -#define TCP_DATA_COPY2(dst, src, len, chksum, chksum_swapped) \ - tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst, src, len), len, chksum, chksum_swapped); -#else /* TCP_CHECKSUM_ON_COPY*/ -#define TCP_DATA_COPY(dst, src, len, seg) MEMCPY(dst, src, len) -#define TCP_DATA_COPY2(dst, src, len, chksum, chksum_swapped) MEMCPY(dst, src, len) -#endif /* TCP_CHECKSUM_ON_COPY*/ - -/** Define this to 1 for an extra check that the output checksum is valid - * (usefule when the checksum is generated by the application, not the stack) */ -#ifndef TCP_CHECKSUM_ON_COPY_SANITY_CHECK -#define TCP_CHECKSUM_ON_COPY_SANITY_CHECK 0 -#endif - -/* Forward declarations.*/ -static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb); - -/** Allocate a pbuf and create a tcphdr at p->payload, used for output - * functions other than the default tcp_output -> tcp_output_segment - * (e.g. tcp_send_empty_ack, etc.) - * - * @param pcb tcp pcb for which to send a packet (used to initialize tcp_hdr) - * @param optlen length of header-options - * @param datalen length of tcp data to reserve in pbuf - * @param seqno_be seqno in network byte order (big-endian) - * @return pbuf with p->payload being the tcp_hdr - */ -static struct pbuf * -tcp_output_alloc_header(struct tcp_pcb *pcb, u16_t optlen, u16_t datalen, - u32_t seqno_be /* already in network byte order */) -{ - struct tcp_hdr *tcphdr; - struct pbuf *p = pbuf_alloc(PBUF_IP, TCP_HLEN + optlen + datalen, PBUF_RAM); - if (p != NULL) { - LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", - (p->len >= TCP_HLEN + optlen)); - tcphdr = (struct tcp_hdr *)p->payload; - tcphdr->src = htons(pcb->local_port); - tcphdr->dest = htons(pcb->remote_port); - tcphdr->seqno = seqno_be; - tcphdr->ackno = htonl(pcb->rcv_nxt); - TCPH_HDRLEN_FLAGS_SET(tcphdr, (5 + optlen / 4), TCP_ACK); - tcphdr->wnd = htons(pcb->rcv_ann_wnd); - tcphdr->chksum = 0; - tcphdr->urgp = 0; - - /* If we're sending a packet, update the announced right window edge */ - pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; - } - return p; -} - -/** - * Called by tcp_close() to send a segment including FIN flag but not data. - * - * @param pcb the tcp_pcb over which to send a segment - * @return ERR_OK if sent, another err_t otherwise - */ -err_t -tcp_send_fin(struct tcp_pcb *pcb) -{ - /* first, try to add the fin to the last unsent segment */ - if (pcb->unsent != NULL) { - struct tcp_seg *last_unsent; - for (last_unsent = pcb->unsent; last_unsent->next != NULL; - last_unsent = last_unsent->next); - - if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { - /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ - TCPH_SET_FLAG(last_unsent->tcphdr, TCP_FIN); - pcb->flags |= TF_FIN; - return ERR_OK; - } - } - /* no data, no length, flags, copy=1, no optdata */ - return tcp_enqueue_flags(pcb, TCP_FIN); -} - -/** - * Create a TCP segment with prefilled header. - * - * Called by tcp_write and tcp_enqueue_flags. - * - * @param pcb Protocol control block for the TCP connection. - * @param p pbuf that is used to hold the TCP header. - * @param flags TCP flags for header. - * @param seqno TCP sequence number of this packet - * @param optflags options to include in TCP header - * @return a new tcp_seg pointing to p, or NULL. - * The TCP header is filled in except ackno and wnd. - * p is freed on failure. - */ -static struct tcp_seg * -tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, u8_t optflags) -{ - struct tcp_seg *seg; - u8_t optlen = LWIP_TCP_OPT_LENGTH(optflags); - - if ((seg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_create_segment: no memory.\n")); - pbuf_free(p); - return NULL; - } - seg->flags = optflags; - seg->next = NULL; - seg->p = p; - seg->len = p->tot_len - optlen; -#if TCP_OVERSIZE_DBGCHECK - seg->oversize_left = 0; -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - seg->chksum = 0; - seg->chksum_swapped = 0; - /* check optflags */ - LWIP_ASSERT("invalid optflags passed: TF_SEG_DATA_CHECKSUMMED", - (optflags & TF_SEG_DATA_CHECKSUMMED) == 0); -#endif /* TCP_CHECKSUM_ON_COPY */ - - /* build TCP header */ - if (pbuf_header(p, TCP_HLEN)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_create_segment: no room for TCP header in pbuf.\n")); - TCP_STATS_INC(tcp.err); - tcp_seg_free(seg); - return NULL; - } - seg->tcphdr = (struct tcp_hdr *)seg->p->payload; - seg->tcphdr->src = htons(pcb->local_port); - seg->tcphdr->dest = htons(pcb->remote_port); - seg->tcphdr->seqno = htonl(seqno); - /* ackno is set in tcp_output */ - TCPH_HDRLEN_FLAGS_SET(seg->tcphdr, (5 + optlen / 4), flags); - /* wnd and chksum are set in tcp_output */ - seg->tcphdr->urgp = 0; - return seg; -} - -/** - * Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. - * - * This function is like pbuf_alloc(layer, length, PBUF_RAM) except - * there may be extra bytes available at the end. - * - * @param layer flag to define header size. - * @param length size of the pbuf's payload. - * @param max_length maximum usable size of payload+oversize. - * @param oversize pointer to a u16_t that will receive the number of usable tail bytes. - * @param pcb The TCP connection that willo enqueue the pbuf. - * @param apiflags API flags given to tcp_write. - * @param first_seg true when this pbuf will be used in the first enqueued segment. - * @param - */ -#if TCP_OVERSIZE -static struct pbuf * -tcp_pbuf_prealloc(pbuf_layer layer, u16_t length, u16_t max_length, - u16_t *oversize, struct tcp_pcb *pcb, u8_t apiflags, - u8_t first_seg) -{ - struct pbuf *p; - u16_t alloc = length; - -#if LWIP_NETIF_TX_SINGLE_PBUF - LWIP_UNUSED_ARG(max_length); - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(apiflags); - LWIP_UNUSED_ARG(first_seg); - /* always create MSS-sized pbufs */ - alloc = max_length; -#else /* LWIP_NETIF_TX_SINGLE_PBUF */ - if (length < max_length) { - /* Should we allocate an oversized pbuf, or just the minimum - * length required? If tcp_write is going to be called again - * before this segment is transmitted, we want the oversized - * buffer. If the segment will be transmitted immediately, we can - * save memory by allocating only length. We use a simple - * heuristic based on the following information: - * - * Did the user set TCP_WRITE_FLAG_MORE? - * - * Will the Nagle algorithm defer transmission of this segment? - */ - if ((apiflags & TCP_WRITE_FLAG_MORE) || - (!(pcb->flags & TF_NODELAY) && - (!first_seg || - pcb->unsent != NULL || - pcb->unacked != NULL))) { - alloc = LWIP_MIN(max_length, LWIP_MEM_ALIGN_SIZE(length + TCP_OVERSIZE)); - } - } -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - p = pbuf_alloc(layer, alloc, PBUF_RAM); - if (p == NULL) { - return NULL; - } - LWIP_ASSERT("need unchained pbuf", p->next == NULL); - *oversize = p->len - length; - /* trim p->len to the currently used size */ - p->len = p->tot_len = length; - return p; -} -#else /* TCP_OVERSIZE */ -#define tcp_pbuf_prealloc(layer, length, mx, os, pcb, api, fst) pbuf_alloc((layer), (length), PBUF_RAM) -#endif /* TCP_OVERSIZE */ - -#if TCP_CHECKSUM_ON_COPY -/** Add a checksum of newly added data to the segment */ -static void -tcp_seg_add_chksum(u16_t chksum, u16_t len, u16_t *seg_chksum, - u8_t *seg_chksum_swapped) -{ - u32_t helper; - /* add chksum to old chksum and fold to u16_t */ - helper = chksum + *seg_chksum; - chksum = FOLD_U32T(helper); - if ((len & 1) != 0) { - *seg_chksum_swapped = 1 - *seg_chksum_swapped; - chksum = SWAP_BYTES_IN_WORD(chksum); - } - *seg_chksum = chksum; -} -#endif /* TCP_CHECKSUM_ON_COPY */ - -/** Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen). - * - * @param pcb the tcp pcb to check for - * @param len length of data to send (checked agains snd_buf) - * @return ERR_OK if tcp_write is allowed to proceed, another err_t otherwise - */ -static err_t -tcp_write_checks(struct tcp_pcb *pcb, u16_t len) -{ - /* connection is in invalid state for data transmission? */ - if ((pcb->state != ESTABLISHED) && - (pcb->state != CLOSE_WAIT) && - (pcb->state != SYN_SENT) && - (pcb->state != SYN_RCVD)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_STATE | LWIP_DBG_LEVEL_SEVERE, ("tcp_write() called in invalid state\n")); - return ERR_CONN; - } else if (len == 0) { - return ERR_OK; - } - - /* fail on too much data */ - if (len > pcb->snd_buf) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_write: too much data (len=%"U16_F" > snd_buf=%"U16_F")\n", - len, pcb->snd_buf)); - pcb->flags |= TF_NAGLEMEMERR; - return ERR_MEM; - } - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); - - /* If total number of pbufs on the unsent/unacked queues exceeds the - * configured maximum, return an error */ - /* check for configured max queuelen and possible overflow */ - if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_write: too long queue %"U16_F" (max %"U16_F")\n", - pcb->snd_queuelen, TCP_SND_QUEUELEN)); - TCP_STATS_INC(tcp.memerr); - pcb->flags |= TF_NAGLEMEMERR; - return ERR_MEM; - } - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_write: pbufs on queue => at least one queue non-empty", - pcb->unacked != NULL || pcb->unsent != NULL); - } else { - LWIP_ASSERT("tcp_write: no pbufs on queue => both queues empty", - pcb->unacked == NULL && pcb->unsent == NULL); - } - return ERR_OK; -} - -/** - * Write data for sending (but does not send it immediately). - * - * It waits in the expectation of more data being sent soon (as - * it can send them more efficiently by combining them together). - * To prompt the system to send data now, call tcp_output() after - * calling tcp_write(). - * - * @param pcb Protocol control block for the TCP connection to enqueue data for. - * @param arg Pointer to the data to be enqueued for sending. - * @param len Data length in bytes - * @param apiflags combination of following flags : - * - TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack - * - TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will be set on last segment sent, - * @return ERR_OK if enqueued, another err_t on error - */ -err_t -tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) -{ - struct pbuf *concat_p = NULL; - struct tcp_seg *last_unsent = NULL, *seg = NULL, *prev_seg = NULL, *queue = NULL; - u16_t pos = 0; /* position in 'arg' data */ - u16_t queuelen; - u8_t optlen = 0; - u8_t optflags = 0; -#if TCP_OVERSIZE - u16_t oversize = 0; - u16_t oversize_used = 0; -#endif /* TCP_OVERSIZE */ -#if TCP_CHECKSUM_ON_COPY - u16_t concat_chksum = 0; - u8_t concat_chksum_swapped = 0; - u16_t concat_chksummed = 0; -#endif /* TCP_CHECKSUM_ON_COPY */ - err_t err; - /* don't allocate segments bigger than half the maximum window we ever received */ - u16_t mss_local = LWIP_MIN(pcb->mss, pcb->snd_wnd_max/2); - -#if LWIP_NETIF_TX_SINGLE_PBUF - /* Always copy to try to create single pbufs for TX */ - apiflags |= TCP_WRITE_FLAG_COPY; -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n", - (void *)pcb, arg, len, (u16_t)apiflags)); - LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)", - arg != NULL, return ERR_ARG;); - - err = tcp_write_checks(pcb, len); - if (err != ERR_OK) { - return err; - } - queuelen = pcb->snd_queuelen; - -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - optflags = TF_SEG_OPTS_TS; - optlen = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS); - } -#endif /* LWIP_TCP_TIMESTAMPS */ - - - /* - * TCP segmentation is done in three phases with increasing complexity: - * - * 1. Copy data directly into an oversized pbuf. - * 2. Chain a new pbuf to the end of pcb->unsent. - * 3. Create new segments. - * - * We may run out of memory at any point. In that case we must - * return ERR_MEM and not change anything in pcb. Therefore, all - * changes are recorded in local variables and committed at the end - * of the function. Some pcb fields are maintained in local copies: - * - * queuelen = pcb->snd_queuelen - * oversize = pcb->unsent_oversize - * - * These variables are set consistently by the phases: - * - * seg points to the last segment tampered with. - * - * pos records progress as data is segmented. - */ - - /* Find the tail of the unsent queue. */ - if (pcb->unsent != NULL) { - u16_t space; - u16_t unsent_optlen; - - /* @todo: this could be sped up by keeping last_unsent in the pcb */ - for (last_unsent = pcb->unsent; last_unsent->next != NULL; - last_unsent = last_unsent->next); - - /* Usable space at the end of the last unsent segment */ - unsent_optlen = LWIP_TCP_OPT_LENGTH(last_unsent->flags); - space = mss_local - (last_unsent->len + unsent_optlen); - - /* - * Phase 1: Copy data directly into an oversized pbuf. - * - * The number of bytes copied is recorded in the oversize_used - * variable. The actual copying is done at the bottom of the - * function. - */ -#if TCP_OVERSIZE -#if TCP_OVERSIZE_DBGCHECK - /* check that pcb->unsent_oversize matches last_unsent->unsent_oversize */ - LWIP_ASSERT("unsent_oversize mismatch (pcb vs. last_unsent)", - pcb->unsent_oversize == last_unsent->oversize_left); -#endif /* TCP_OVERSIZE_DBGCHECK */ - oversize = pcb->unsent_oversize; - if (oversize > 0) { - LWIP_ASSERT("inconsistent oversize vs. space", oversize_used <= space); - seg = last_unsent; - oversize_used = oversize < len ? oversize : len; - pos += oversize_used; - oversize -= oversize_used; - space -= oversize_used; - } - /* now we are either finished or oversize is zero */ - LWIP_ASSERT("inconsistend oversize vs. len", (oversize == 0) || (pos == len)); -#endif /* TCP_OVERSIZE */ - - /* - * Phase 2: Chain a new pbuf to the end of pcb->unsent. - * - * We don't extend segments containing SYN/FIN flags or options - * (len==0). The new pbuf is kept in concat_p and pbuf_cat'ed at - * the end. - */ - if ((pos < len) && (space > 0) && (last_unsent->len > 0)) { - u16_t seglen = space < len - pos ? space : len - pos; - seg = last_unsent; - - /* Create a pbuf with a copy or reference to seglen bytes. We - * can use PBUF_RAW here since the data appears in the middle of - * a segment. A header will never be prepended. */ - if (apiflags & TCP_WRITE_FLAG_COPY) { - /* Data is copied */ - if ((concat_p = tcp_pbuf_prealloc(PBUF_RAW, seglen, space, &oversize, pcb, apiflags, 1)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, - ("tcp_write : could not allocate memory for pbuf copy size %"U16_F"\n", - seglen)); - goto memerr; - } -#if TCP_OVERSIZE_DBGCHECK - last_unsent->oversize_left += oversize; -#endif /* TCP_OVERSIZE_DBGCHECK */ - TCP_DATA_COPY2(concat_p->payload, (u8_t*)arg + pos, seglen, &concat_chksum, &concat_chksum_swapped); -#if TCP_CHECKSUM_ON_COPY - concat_chksummed += seglen; -#endif /* TCP_CHECKSUM_ON_COPY */ - } else { - /* Data is not copied */ - if ((concat_p = pbuf_alloc(PBUF_RAW, seglen, PBUF_ROM)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, - ("tcp_write: could not allocate memory for zero-copy pbuf\n")); - goto memerr; - } -#if TCP_CHECKSUM_ON_COPY - /* calculate the checksum of nocopy-data */ - tcp_seg_add_chksum(~inet_chksum((u8_t*)arg + pos, seglen), seglen, - &concat_chksum, &concat_chksum_swapped); - concat_chksummed += seglen; -#endif /* TCP_CHECKSUM_ON_COPY */ - /* reference the non-volatile payload data */ - concat_p->payload = (u8_t*)arg + pos; - } - - pos += seglen; - queuelen += pbuf_clen(concat_p); - } - } else { -#if TCP_OVERSIZE - LWIP_ASSERT("unsent_oversize mismatch (pcb->unsent is NULL)", - pcb->unsent_oversize == 0); -#endif /* TCP_OVERSIZE */ - } - - /* - * Phase 3: Create new segments. - * - * The new segments are chained together in the local 'queue' - * variable, ready to be appended to pcb->unsent. - */ - while (pos < len) { - struct pbuf *p; - u16_t left = len - pos; - u16_t max_len = mss_local - optlen; - u16_t seglen = left > max_len ? max_len : left; -#if TCP_CHECKSUM_ON_COPY - u16_t chksum = 0; - u8_t chksum_swapped = 0; -#endif /* TCP_CHECKSUM_ON_COPY */ - - if (apiflags & TCP_WRITE_FLAG_COPY) { - /* If copy is set, memory should be allocated and data copied - * into pbuf */ - if ((p = tcp_pbuf_prealloc(PBUF_TRANSPORT, seglen + optlen, mss_local, &oversize, pcb, apiflags, queue == NULL)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write : could not allocate memory for pbuf copy size %"U16_F"\n", seglen)); - goto memerr; - } - LWIP_ASSERT("tcp_write: check that first pbuf can hold the complete seglen", - (p->len >= seglen)); - TCP_DATA_COPY2((char *)p->payload + optlen, (u8_t*)arg + pos, seglen, &chksum, &chksum_swapped); - } else { - /* Copy is not set: First allocate a pbuf for holding the data. - * Since the referenced data is available at least until it is - * sent out on the link (as it has to be ACKed by the remote - * party) we can safely use PBUF_ROM instead of PBUF_REF here. - */ - struct pbuf *p2; -#if TCP_OVERSIZE - LWIP_ASSERT("oversize == 0", oversize == 0); -#endif /* TCP_OVERSIZE */ - if ((p2 = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: could not allocate memory for zero-copy pbuf\n")); - goto memerr; - } -#if TCP_CHECKSUM_ON_COPY - /* calculate the checksum of nocopy-data */ - chksum = ~inet_chksum((u8_t*)arg + pos, seglen); -#endif /* TCP_CHECKSUM_ON_COPY */ - /* reference the non-volatile payload data */ - p2->payload = (u8_t*)arg + pos; - - /* Second, allocate a pbuf for the headers. */ - if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { - /* If allocation fails, we have to deallocate the data pbuf as - * well. */ - pbuf_free(p2); - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: could not allocate memory for header pbuf\n")); - goto memerr; - } - /* Concatenate the headers and data pbufs together. */ - pbuf_cat(p/*header*/, p2/*data*/); - } - - queuelen += pbuf_clen(p); - - /* Now that there are more segments queued, we check again if the - * length of the queue exceeds the configured maximum or - * overflows. */ - if ((queuelen > TCP_SND_QUEUELEN) || (queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: queue too long %"U16_F" (%"U16_F")\n", queuelen, TCP_SND_QUEUELEN)); - pbuf_free(p); - goto memerr; - } - - if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) { - goto memerr; - } -#if TCP_OVERSIZE_DBGCHECK - seg->oversize_left = oversize; -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - seg->chksum = chksum; - seg->chksum_swapped = chksum_swapped; - seg->flags |= TF_SEG_DATA_CHECKSUMMED; -#endif /* TCP_CHECKSUM_ON_COPY */ - - /* first segment of to-be-queued data? */ - if (queue == NULL) { - queue = seg; - } else { - /* Attach the segment to the end of the queued segments */ - LWIP_ASSERT("prev_seg != NULL", prev_seg != NULL); - prev_seg->next = seg; - } - /* remember last segment of to-be-queued data for next iteration */ - prev_seg = seg; - - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_write: queueing %"U32_F":%"U32_F"\n", - ntohl(seg->tcphdr->seqno), - ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); - - pos += seglen; - } - - /* - * All three segmentation phases were successful. We can commit the - * transaction. - */ - - /* - * Phase 1: If data has been added to the preallocated tail of - * last_unsent, we update the length fields of the pbuf chain. - */ -#if TCP_OVERSIZE - if (oversize_used > 0) { - struct pbuf *p; - /* Bump tot_len of whole chain, len of tail */ - for (p = last_unsent->p; p; p = p->next) { - p->tot_len += oversize_used; - if (p->next == NULL) { - TCP_DATA_COPY((char *)p->payload + p->len, arg, oversize_used, last_unsent); - p->len += oversize_used; - } - } - last_unsent->len += oversize_used; -#if TCP_OVERSIZE_DBGCHECK - LWIP_ASSERT("last_unsent->oversize_left >= oversize_used", - last_unsent->oversize_left >= oversize_used); - last_unsent->oversize_left -= oversize_used; -#endif /* TCP_OVERSIZE_DBGCHECK */ - } - pcb->unsent_oversize = oversize; -#endif /* TCP_OVERSIZE */ - - /* - * Phase 2: concat_p can be concatenated onto last_unsent->p - */ - if (concat_p != NULL) { - LWIP_ASSERT("tcp_write: cannot concatenate when pcb->unsent is empty", - (last_unsent != NULL)); - pbuf_cat(last_unsent->p, concat_p); - last_unsent->len += concat_p->tot_len; -#if TCP_CHECKSUM_ON_COPY - if (concat_chksummed) { - tcp_seg_add_chksum(concat_chksum, concat_chksummed, &last_unsent->chksum, - &last_unsent->chksum_swapped); - last_unsent->flags |= TF_SEG_DATA_CHECKSUMMED; - } -#endif /* TCP_CHECKSUM_ON_COPY */ - } - - /* - * Phase 3: Append queue to pcb->unsent. Queue may be NULL, but that - * is harmless - */ - if (last_unsent == NULL) { - pcb->unsent = queue; - } else { - last_unsent->next = queue; - } - - /* - * Finally update the pcb state. - */ - pcb->snd_lbb += len; - pcb->snd_buf -= len; - pcb->snd_queuelen = queuelen; - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: %"S16_F" (after enqueued)\n", - pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_write: valid queue length", - pcb->unacked != NULL || pcb->unsent != NULL); - } - - /* Set the PSH flag in the last segment that we enqueued. */ - if (seg != NULL && seg->tcphdr != NULL && ((apiflags & TCP_WRITE_FLAG_MORE)==0)) { - TCPH_SET_FLAG(seg->tcphdr, TCP_PSH); - } - - return ERR_OK; -memerr: - pcb->flags |= TF_NAGLEMEMERR; - TCP_STATS_INC(tcp.memerr); - - if (concat_p != NULL) { - pbuf_free(concat_p); - } - if (queue != NULL) { - tcp_segs_free(queue); - } - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_write: valid queue length", pcb->unacked != NULL || - pcb->unsent != NULL); - } - LWIP_DEBUGF(TCP_QLEN_DEBUG | LWIP_DBG_STATE, ("tcp_write: %"S16_F" (with mem err)\n", pcb->snd_queuelen)); - return ERR_MEM; -} - -/** - * Enqueue TCP options for transmission. - * - * Called by tcp_connect(), tcp_listen_input(), and tcp_send_ctrl(). - * - * @param pcb Protocol control block for the TCP connection. - * @param flags TCP header flags to set in the outgoing segment. - * @param optdata pointer to TCP options, or NULL. - * @param optlen length of TCP options in bytes. - */ -err_t -tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) -{ - struct pbuf *p; - struct tcp_seg *seg; - u8_t optflags = 0; - u8_t optlen = 0; - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue_flags: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); - - LWIP_ASSERT("tcp_enqueue_flags: need either TCP_SYN or TCP_FIN in flags (programmer violates API)", - (flags & (TCP_SYN | TCP_FIN)) != 0); - - /* check for configured max queuelen and possible overflow */ - if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue_flags: too long queue %"U16_F" (max %"U16_F")\n", - pcb->snd_queuelen, TCP_SND_QUEUELEN)); - TCP_STATS_INC(tcp.memerr); - pcb->flags |= TF_NAGLEMEMERR; - return ERR_MEM; - } - - if (flags & TCP_SYN) { - optflags = TF_SEG_OPTS_MSS; - } -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - optflags |= TF_SEG_OPTS_TS; - } -#endif /* LWIP_TCP_TIMESTAMPS */ - optlen = LWIP_TCP_OPT_LENGTH(optflags); - - /* tcp_enqueue_flags is always called with either SYN or FIN in flags. - * We need one available snd_buf byte to do that. - * This means we can't send FIN while snd_buf==0. A better fix would be to - * not include SYN and FIN sequence numbers in the snd_buf count. */ - if (pcb->snd_buf == 0) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue_flags: no send buffer available\n")); - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } - - /* Allocate pbuf with room for TCP header + options */ - if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { - pcb->flags |= TF_NAGLEMEMERR; - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } - LWIP_ASSERT("tcp_enqueue_flags: check that first pbuf can hold optlen", - (p->len >= optlen)); - - /* Allocate memory for tcp_seg, and fill in fields. */ - if ((seg = tcp_create_segment(pcb, p, flags, pcb->snd_lbb, optflags)) == NULL) { - pcb->flags |= TF_NAGLEMEMERR; - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } - LWIP_ASSERT("seg->tcphdr not aligned", ((mem_ptr_t)seg->tcphdr % MEM_ALIGNMENT) == 0); - LWIP_ASSERT("tcp_enqueue_flags: invalid segment length", seg->len == 0); - - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, - ("tcp_enqueue_flags: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n", - ntohl(seg->tcphdr->seqno), - ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), - (u16_t)flags)); - - /* Now append seg to pcb->unsent queue */ - if (pcb->unsent == NULL) { - pcb->unsent = seg; - } else { - struct tcp_seg *useg; - for (useg = pcb->unsent; useg->next != NULL; useg = useg->next); - useg->next = seg; - } -#if TCP_OVERSIZE - /* The new unsent tail has no space */ - pcb->unsent_oversize = 0; -#endif /* TCP_OVERSIZE */ - - /* SYN and FIN bump the sequence number */ - if ((flags & TCP_SYN) || (flags & TCP_FIN)) { - pcb->snd_lbb++; - /* optlen does not influence snd_buf */ - pcb->snd_buf--; - } - if (flags & TCP_FIN) { - pcb->flags |= TF_FIN; - } - - /* update number of segments on the queues */ - pcb->snd_queuelen += pbuf_clen(seg->p); - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue_flags: %"S16_F" (after enqueued)\n", pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_enqueue_flags: invalid queue length", - pcb->unacked != NULL || pcb->unsent != NULL); - } - - return ERR_OK; -} - -#if LWIP_TCP_TIMESTAMPS -/* Build a timestamp option (12 bytes long) at the specified options pointer) - * - * @param pcb tcp_pcb - * @param opts option pointer where to store the timestamp option - */ -static void -tcp_build_timestamp_option(struct tcp_pcb *pcb, u32_t *opts) -{ - /* Pad with two NOP options to make everything nicely aligned */ - opts[0] = PP_HTONL(0x0101080A); - opts[1] = htonl(sys_now()); - opts[2] = htonl(pcb->ts_recent); -} -#endif - -/** Send an ACK without data. - * - * @param pcb Protocol control block for the TCP connection to send the ACK - */ -err_t -tcp_send_empty_ack(struct tcp_pcb *pcb) -{ - struct pbuf *p; - struct tcp_hdr *tcphdr; - u8_t optlen = 0; - -#if LWIP_TCP_TIMESTAMPS - if (pcb->flags & TF_TIMESTAMP) { - optlen = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS); - } -#endif - - p = tcp_output_alloc_header(pcb, optlen, 0, htonl(pcb->snd_nxt)); - if (p == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); - return ERR_BUF; - } - tcphdr = (struct tcp_hdr *)p->payload; - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, - ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt)); - /* remove ACK flags from the PCB, as we send an empty ACK now */ - pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); - - /* NB. MSS option is only sent on SYNs, so ignore it here */ -#if LWIP_TCP_TIMESTAMPS - pcb->ts_lastacksent = pcb->rcv_nxt; - - if (pcb->flags & TF_TIMESTAMP) { - tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1)); - } -#endif - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip), - IP_PROTO_TCP, p->tot_len); -#endif -#if LWIP_NETIF_HWADDRHINT - ip_output_hinted(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, - IP_PROTO_TCP, &(pcb->addr_hint)); -#else /* LWIP_NETIF_HWADDRHINT*/ - ip_output(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, - IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ - pbuf_free(p); - - return ERR_OK; -} - -/** - * Find out what we can send and send it - * - * @param pcb Protocol control block for the TCP connection to send data - * @return ERR_OK if data has been sent or nothing to send - * another err_t on error - */ -err_t -tcp_output(struct tcp_pcb *pcb) -{ - struct tcp_seg *seg, *useg; - u32_t wnd, snd_nxt; -#if TCP_CWND_DEBUG - s16_t i = 0; -#endif /* TCP_CWND_DEBUG */ - - /* pcb->state LISTEN not allowed here */ - LWIP_ASSERT("don't call tcp_output for listen-pcbs", - pcb->state != LISTEN); - - /* First, check if we are invoked by the TCP input processing - code. If so, we do not output anything. Instead, we rely on the - input processing code to call us when input processing is done - with. */ - if (tcp_input_pcb == pcb) { - return ERR_OK; - } - - wnd = LWIP_MIN(pcb->snd_wnd, pcb->cwnd); - - seg = pcb->unsent; - - /* If the TF_ACK_NOW flag is set and no data will be sent (either - * because the ->unsent queue is empty or because the window does - * not allow it), construct an empty ACK segment and send it. - * - * If data is to be sent, we will just piggyback the ACK (see below). - */ - if (pcb->flags & TF_ACK_NOW && - (seg == NULL || - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) { - return tcp_send_empty_ack(pcb); - } - - /* useg should point to last segment on unacked queue */ - useg = pcb->unacked; - if (useg != NULL) { - for (; useg->next != NULL; useg = useg->next); - } - -#if TCP_OUTPUT_DEBUG - if (seg == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", - (void*)pcb->unsent)); - } -#endif /* TCP_OUTPUT_DEBUG */ -#if TCP_CWND_DEBUG - if (seg == NULL) { - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F - ", cwnd %"U16_F", wnd %"U32_F - ", seg == NULL, ack %"U32_F"\n", - pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); - } else { - LWIP_DEBUGF(TCP_CWND_DEBUG, - ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F - ", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", - pcb->snd_wnd, pcb->cwnd, wnd, - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, - ntohl(seg->tcphdr->seqno), pcb->lastack)); - } -#endif /* TCP_CWND_DEBUG */ - /* data available and window allows it to be sent? */ - while (seg != NULL && - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { - LWIP_ASSERT("RST not expected here!", - (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0); - /* Stop sending if the nagle algorithm would prevent it - * Don't stop: - * - if tcp_write had a memory error before (prevent delayed ACK timeout) or - * - if FIN was already enqueued for this PCB (SYN is always alone in a segment - - * either seg->next != NULL or pcb->unacked == NULL; - * RST is no sent using tcp_write/tcp_output. - */ - if((tcp_do_output_nagle(pcb) == 0) && - ((pcb->flags & (TF_NAGLEMEMERR | TF_FIN)) == 0)){ - break; - } -#if TCP_CWND_DEBUG - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F", i %"S16_F"\n", - pcb->snd_wnd, pcb->cwnd, wnd, - ntohl(seg->tcphdr->seqno) + seg->len - - pcb->lastack, - ntohl(seg->tcphdr->seqno), pcb->lastack, i)); - ++i; -#endif /* TCP_CWND_DEBUG */ - - pcb->unsent = seg->next; - - if (pcb->state != SYN_SENT) { - TCPH_SET_FLAG(seg->tcphdr, TCP_ACK); - pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); - } - - tcp_output_segment(seg, pcb); - snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); - if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) { - pcb->snd_nxt = snd_nxt; - } - /* put segment on unacknowledged list if length > 0 */ - if (TCP_TCPLEN(seg) > 0) { - seg->next = NULL; - /* unacked list is empty? */ - if (pcb->unacked == NULL) { - pcb->unacked = seg; - useg = seg; - /* unacked list is not empty? */ - } else { - /* In the case of fast retransmit, the packet should not go to the tail - * of the unacked queue, but rather somewhere before it. We need to check for - * this case. -STJ Jul 27, 2004 */ - if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) { - /* add segment to before tail of unacked list, keeping the list sorted */ - struct tcp_seg **cur_seg = &(pcb->unacked); - while (*cur_seg && - TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { - cur_seg = &((*cur_seg)->next ); - } - seg->next = (*cur_seg); - (*cur_seg) = seg; - } else { - /* add segment to tail of unacked list */ - useg->next = seg; - useg = useg->next; - } - } - /* do not queue empty segments on the unacked list */ - } else { - tcp_seg_free(seg); - } - seg = pcb->unsent; - } -#if TCP_OVERSIZE - if (pcb->unsent == NULL) { - /* last unsent has been removed, reset unsent_oversize */ - pcb->unsent_oversize = 0; - } -#endif /* TCP_OVERSIZE */ - - pcb->flags &= ~TF_NAGLEMEMERR; - return ERR_OK; -} - -/** - * Called by tcp_output() to actually send a TCP segment over IP. - * - * @param seg the tcp_seg to send - * @param pcb the tcp_pcb for the TCP connection used to send the segment - */ -static void -tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) -{ - u16_t len; - struct netif *netif; - u32_t *opts; - - /** @bug Exclude retransmitted segments from this count. */ - snmp_inc_tcpoutsegs(); - - /* The TCP header has already been constructed, but the ackno and - wnd fields remain. */ - seg->tcphdr->ackno = htonl(pcb->rcv_nxt); - - /* advertise our receive window size in this TCP segment */ - seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd); - - pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; - - /* Add any requested options. NB MSS option is only set on SYN - packets, so ignore it here */ - opts = (u32_t *)(void *)(seg->tcphdr + 1); - if (seg->flags & TF_SEG_OPTS_MSS) { - u16_t mss; -#if TCP_CALCULATE_EFF_SEND_MSS - mss = tcp_eff_send_mss(TCP_MSS, &pcb->remote_ip); -#else /* TCP_CALCULATE_EFF_SEND_MSS */ - mss = TCP_MSS; -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - *opts = TCP_BUILD_MSS_OPTION(mss); - opts += 1; - } -#if LWIP_TCP_TIMESTAMPS - pcb->ts_lastacksent = pcb->rcv_nxt; - - if (seg->flags & TF_SEG_OPTS_TS) { - tcp_build_timestamp_option(pcb, opts); - opts += 3; - } -#endif - - /* Set retransmission timer running if it is not currently enabled - This must be set before checking the route. */ - if (pcb->rtime == -1) { - pcb->rtime = 0; - } - - /* If we don't have a local IP address, we get one by - calling ip_route(). */ - if (ip_addr_isany(&(pcb->local_ip))) { - netif = ip_route(&(pcb->remote_ip)); - if (netif == NULL) { - return; - } - ip_addr_copy(pcb->local_ip, netif->ip_addr); - } - - if (pcb->rttest == 0) { - pcb->rttest = tcp_ticks; - pcb->rtseq = ntohl(seg->tcphdr->seqno); - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %"U32_F"\n", pcb->rtseq)); - } - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %"U32_F":%"U32_F"\n", - htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + - seg->len)); - - len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload); - - seg->p->len -= len; - seg->p->tot_len -= len; - - seg->p->payload = seg->tcphdr; - - seg->tcphdr->chksum = 0; -#if CHECKSUM_GEN_TCP -#if TCP_CHECKSUM_ON_COPY - { - u32_t acc; -#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK - u16_t chksum_slow = inet_chksum_pseudo(seg->p, &(pcb->local_ip), - &(pcb->remote_ip), - IP_PROTO_TCP, seg->p->tot_len); -#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ - if ((seg->flags & TF_SEG_DATA_CHECKSUMMED) == 0) { - LWIP_ASSERT("data included but not checksummed", - seg->p->tot_len == (TCPH_HDRLEN(seg->tcphdr) * 4)); - } - - /* rebuild TCP header checksum (TCP header changes for retransmissions!) */ - acc = inet_chksum_pseudo_partial(seg->p, &(pcb->local_ip), - &(pcb->remote_ip), - IP_PROTO_TCP, seg->p->tot_len, TCPH_HDRLEN(seg->tcphdr) * 4); - /* add payload checksum */ - if (seg->chksum_swapped) { - seg->chksum = SWAP_BYTES_IN_WORD(seg->chksum); - seg->chksum_swapped = 0; - } - acc += (u16_t)~(seg->chksum); - seg->tcphdr->chksum = FOLD_U32T(acc); -#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK - if (chksum_slow != seg->tcphdr->chksum) { - LWIP_DEBUGF(TCP_DEBUG | LWIP_DBG_LEVEL_WARNING, - ("tcp_output_segment: calculated checksum is %"X16_F" instead of %"X16_F"\n", - seg->tcphdr->chksum, chksum_slow)); - seg->tcphdr->chksum = chksum_slow; - } -#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ - } -#else /* TCP_CHECKSUM_ON_COPY */ - seg->tcphdr->chksum = inet_chksum_pseudo(seg->p, &(pcb->local_ip), - &(pcb->remote_ip), - IP_PROTO_TCP, seg->p->tot_len); -#endif /* TCP_CHECKSUM_ON_COPY */ -#endif /* CHECKSUM_GEN_TCP */ - TCP_STATS_INC(tcp.xmit); - -#if LWIP_NETIF_HWADDRHINT - ip_output_hinted(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, - IP_PROTO_TCP, &(pcb->addr_hint)); -#else /* LWIP_NETIF_HWADDRHINT*/ - ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, - IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ -} - -/** - * Send a TCP RESET packet (empty segment with RST flag set) either to - * abort a connection or to show that there is no matching local connection - * for a received segment. - * - * Called by tcp_abort() (to abort a local connection), tcp_input() (if no - * matching local pcb was found), tcp_listen_input() (if incoming segment - * has ACK flag set) and tcp_process() (received segment in the wrong state) - * - * Since a RST segment is in most cases not sent for an active connection, - * tcp_rst() has a number of arguments that are taken from a tcp_pcb for - * most other segment output functions. - * - * @param seqno the sequence number to use for the outgoing segment - * @param ackno the acknowledge number to use for the outgoing segment - * @param local_ip the local IP address to send the segment from - * @param remote_ip the remote IP address to send the segment to - * @param local_port the local TCP port to send the segment from - * @param remote_port the remote TCP port to send the segment to - */ -void -tcp_rst(u32_t seqno, u32_t ackno, - ip_addr_t *local_ip, ip_addr_t *remote_ip, - u16_t local_port, u16_t remote_port) -{ - struct pbuf *p; - struct tcp_hdr *tcphdr; - p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); - if (p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n")); - return; - } - LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", - (p->len >= sizeof(struct tcp_hdr))); - - tcphdr = (struct tcp_hdr *)p->payload; - tcphdr->src = htons(local_port); - tcphdr->dest = htons(remote_port); - tcphdr->seqno = htonl(seqno); - tcphdr->ackno = htonl(ackno); - TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN/4, TCP_RST | TCP_ACK); - tcphdr->wnd = PP_HTONS(TCP_WND); - tcphdr->chksum = 0; - tcphdr->urgp = 0; - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip, - IP_PROTO_TCP, p->tot_len); -#endif - TCP_STATS_INC(tcp.xmit); - snmp_inc_tcpoutrsts(); - /* Send output with hardcoded TTL since we have no access to the pcb */ - ip_output(p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP); - pbuf_free(p); - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %"U32_F" ackno %"U32_F".\n", seqno, ackno)); -} - -/** - * Requeue all unacked segments for retransmission - * - * Called by tcp_slowtmr() for slow retransmission. - * - * @param pcb the tcp_pcb for which to re-enqueue all unacked segments - */ -void -tcp_rexmit_rto(struct tcp_pcb *pcb) -{ - struct tcp_seg *seg; - - if (pcb->unacked == NULL) { - return; - } - - /* Move all unacked segments to the head of the unsent queue */ - for (seg = pcb->unacked; seg->next != NULL; seg = seg->next); - /* concatenate unsent queue after unacked queue */ - seg->next = pcb->unsent; - /* unsent queue is the concatenated queue (of unacked, unsent) */ - pcb->unsent = pcb->unacked; - /* unacked queue is now empty */ - pcb->unacked = NULL; - /* last unsent hasn't changed, no need to reset unsent_oversize */ - - /* increment number of retransmissions */ - ++pcb->nrtx; - - /* Don't take any RTT measurements after retransmitting. */ - pcb->rttest = 0; - - /* Do the actual retransmission */ - tcp_output(pcb); -} - -/** - * Requeue the first unacked segment for retransmission - * - * Called by tcp_receive() for fast retramsmit. - * - * @param pcb the tcp_pcb for which to retransmit the first unacked segment - */ -void -tcp_rexmit(struct tcp_pcb *pcb) -{ - struct tcp_seg *seg; - struct tcp_seg **cur_seg; - - if (pcb->unacked == NULL) { - return; - } - - /* Move the first unacked segment to the unsent queue */ - /* Keep the unsent queue sorted. */ - seg = pcb->unacked; - pcb->unacked = seg->next; - - cur_seg = &(pcb->unsent); - while (*cur_seg && - TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { - cur_seg = &((*cur_seg)->next ); - } - seg->next = *cur_seg; - *cur_seg = seg; -#if TCP_OVERSIZE - if (seg->next == NULL) { - /* the retransmitted segment is last in unsent, so reset unsent_oversize */ - pcb->unsent_oversize = 0; - } -#endif /* TCP_OVERSIZE */ - - ++pcb->nrtx; - - /* Don't take any rtt measurements after retransmitting. */ - pcb->rttest = 0; - - /* Do the actual retransmission. */ - snmp_inc_tcpretranssegs(); - /* No need to call tcp_output: we are always called from tcp_input() - and thus tcp_output directly returns. */ -} - - -/** - * Handle retransmission after three dupacks received - * - * @param pcb the tcp_pcb for which to retransmit the first unacked segment - */ -void -tcp_rexmit_fast(struct tcp_pcb *pcb) -{ - if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) { - /* This is fast retransmit. Retransmit the first unacked segment. */ - LWIP_DEBUGF(TCP_FR_DEBUG, - ("tcp_receive: dupacks %"U16_F" (%"U32_F - "), fast retransmit %"U32_F"\n", - (u16_t)pcb->dupacks, pcb->lastack, - ntohl(pcb->unacked->tcphdr->seqno))); - tcp_rexmit(pcb); - - /* Set ssthresh to half of the minimum of the current - * cwnd and the advertised window */ - if (pcb->cwnd > pcb->snd_wnd) { - pcb->ssthresh = pcb->snd_wnd / 2; - } else { - pcb->ssthresh = pcb->cwnd / 2; - } - - /* The minimum value for ssthresh should be 2 MSS */ - if (pcb->ssthresh < 2*pcb->mss) { - LWIP_DEBUGF(TCP_FR_DEBUG, - ("tcp_receive: The minimum value for ssthresh %"U16_F - " should be min 2 mss %"U16_F"...\n", - pcb->ssthresh, 2*pcb->mss)); - pcb->ssthresh = 2*pcb->mss; - } - - pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; - pcb->flags |= TF_INFR; - } -} - - -/** - * Send keepalive packets to keep a connection active although - * no data is sent over it. - * - * Called by tcp_slowtmr() - * - * @param pcb the tcp_pcb for which to send a keepalive packet - */ -void -tcp_keepalive(struct tcp_pcb *pcb) -{ - struct pbuf *p; - struct tcp_hdr *tcphdr; - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), - ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", - tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); - - p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1)); - if(p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, - ("tcp_keepalive: could not allocate memory for pbuf\n")); - return; - } - tcphdr = (struct tcp_hdr *)p->payload; - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, - IP_PROTO_TCP, p->tot_len); -#endif - TCP_STATS_INC(tcp.xmit); - - /* Send output to IP */ -#if LWIP_NETIF_HWADDRHINT - ip_output_hinted(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP, - &(pcb->addr_hint)); -#else /* LWIP_NETIF_HWADDRHINT*/ - ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ - - pbuf_free(p); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: seqno %"U32_F" ackno %"U32_F".\n", - pcb->snd_nxt - 1, pcb->rcv_nxt)); -} - - -/** - * Send persist timer zero-window probes to keep a connection active - * when a window update is lost. - * - * Called by tcp_slowtmr() - * - * @param pcb the tcp_pcb for which to send a zero-window probe packet - */ -void -tcp_zero_window_probe(struct tcp_pcb *pcb) -{ - struct pbuf *p; - struct tcp_hdr *tcphdr; - struct tcp_seg *seg; - u16_t len; - u8_t is_fin; - - LWIP_DEBUGF(TCP_DEBUG, - ("tcp_zero_window_probe: sending ZERO WINDOW probe to %" - U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), - ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); - - LWIP_DEBUGF(TCP_DEBUG, - ("tcp_zero_window_probe: tcp_ticks %"U32_F - " pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", - tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); - - seg = pcb->unacked; - - if(seg == NULL) { - seg = pcb->unsent; - } - if(seg == NULL) { - return; - } - - is_fin = ((TCPH_FLAGS(seg->tcphdr) & TCP_FIN) != 0) && (seg->len == 0); - /* we want to send one seqno: either FIN or data (no options) */ - len = is_fin ? 0 : 1; - - p = tcp_output_alloc_header(pcb, 0, len, seg->tcphdr->seqno); - if(p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: no memory for pbuf\n")); - return; - } - tcphdr = (struct tcp_hdr *)p->payload; - - if (is_fin) { - /* FIN segment, no data */ - TCPH_FLAGS_SET(tcphdr, TCP_ACK | TCP_FIN); - } else { - /* Data segment, copy in one byte from the head of the unacked queue */ - char *d = ((char *)p->payload + TCP_HLEN); - /* Depending on whether the segment has already been sent (unacked) or not - (unsent), seg->p->payload points to the IP header or TCP header. - Ensure we copy the first TCP data byte: */ - pbuf_copy_partial(seg->p, d, 1, seg->p->tot_len - seg->len); - } - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, - IP_PROTO_TCP, p->tot_len); -#endif - TCP_STATS_INC(tcp.xmit); - - /* Send output to IP */ -#if LWIP_NETIF_HWADDRHINT - ip_output_hinted(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP, - &(pcb->addr_hint)); -#else /* LWIP_NETIF_HWADDRHINT*/ - ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ - - pbuf_free(p); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: seqno %"U32_F - " ackno %"U32_F".\n", - pcb->snd_nxt - 1, pcb->rcv_nxt)); -} -#endif /* LWIP_TCP */ diff --git a/user/mpy/lib/lwip/src/core/timers.c b/user/mpy/lib/lwip/src/core/timers.c deleted file mode 100644 index e308466..0000000 --- a/user/mpy/lib/lwip/src/core/timers.c +++ /dev/null @@ -1,487 +0,0 @@ -/** - * @file - * Stack-internal timers implementation. - * This file includes timer callbacks for stack-internal timers as well as - * functions to set up or stop timers and check for expired timers. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ - -#include "lwip/opt.h" - -#include "lwip/timers.h" -#include "lwip/tcp_impl.h" - -#if LWIP_TIMERS - -#include "lwip/def.h" -#include "lwip/memp.h" -#include "lwip/tcpip.h" - -#include "lwip/ip_frag.h" -#include "netif/etharp.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" -#include "lwip/igmp.h" -#include "lwip/dns.h" -#include "lwip/sys.h" -#include "lwip/pbuf.h" - - -/** The one and only timeout list */ -static struct sys_timeo *next_timeout; -#if NO_SYS -static u32_t timeouts_last_time; -#endif /* NO_SYS */ - -#if LWIP_TCP -/** global variable that shows if the tcp timer is currently scheduled or not */ -static int tcpip_tcp_timer_active; - -/** - * Timer callback function that calls tcp_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -tcpip_tcp_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - - /* call TCP timer handler */ - tcp_tmr(); - /* timer still needed? */ - if (tcp_active_pcbs || tcp_tw_pcbs) { - /* restart timer */ - sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); - } else { - /* disable timer */ - tcpip_tcp_timer_active = 0; - } -} - -/** - * Called from TCP_REG when registering a new PCB: - * the reason is to have the TCP timer only running when - * there are active (or time-wait) PCBs. - */ -void -tcp_timer_needed(void) -{ - /* timer is off but needed again? */ - if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) { - /* enable and start timer */ - tcpip_tcp_timer_active = 1; - sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); - } -} -#endif /* LWIP_TCP */ - -#if IP_REASSEMBLY -/** - * Timer callback function that calls ip_reass_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -ip_reass_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: ip_reass_tmr()\n")); - ip_reass_tmr(); - sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); -} -#endif /* IP_REASSEMBLY */ - -#if LWIP_ARP -/** - * Timer callback function that calls etharp_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -arp_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: etharp_tmr()\n")); - etharp_tmr(); - sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); -} -#endif /* LWIP_ARP */ - -#if LWIP_DHCP -/** - * Timer callback function that calls dhcp_coarse_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -dhcp_timer_coarse(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_coarse_tmr()\n")); - dhcp_coarse_tmr(); - sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); -} - -/** - * Timer callback function that calls dhcp_fine_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -dhcp_timer_fine(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_fine_tmr()\n")); - dhcp_fine_tmr(); - sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); -} -#endif /* LWIP_DHCP */ - -#if LWIP_AUTOIP -/** - * Timer callback function that calls autoip_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -autoip_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: autoip_tmr()\n")); - autoip_tmr(); - sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); -} -#endif /* LWIP_AUTOIP */ - -#if LWIP_IGMP -/** - * Timer callback function that calls igmp_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -igmp_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: igmp_tmr()\n")); - igmp_tmr(); - sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); -} -#endif /* LWIP_IGMP */ - -#if LWIP_DNS -/** - * Timer callback function that calls dns_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -dns_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dns_tmr()\n")); - dns_tmr(); - sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); -} -#endif /* LWIP_DNS */ - -/** Initialize this module */ -void sys_timeouts_init(void) -{ -#if IP_REASSEMBLY - sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); -#endif /* IP_REASSEMBLY */ -#if LWIP_ARP - sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); -#endif /* LWIP_ARP */ -#if LWIP_DHCP - sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); - sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); -#endif /* LWIP_DHCP */ -#if LWIP_AUTOIP - sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); -#endif /* LWIP_AUTOIP */ -#if LWIP_IGMP - sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); -#endif /* LWIP_IGMP */ -#if LWIP_DNS - sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); -#endif /* LWIP_DNS */ - -#if NO_SYS - /* Initialise timestamp for sys_check_timeouts */ - timeouts_last_time = sys_now(); -#endif -} - -/** - * Create a one-shot timer (aka timeout). Timeouts are processed in the - * following cases: - * - while waiting for a message using sys_timeouts_mbox_fetch() - * - by calling sys_check_timeouts() (NO_SYS==1 only) - * - * @param msecs time in milliseconds after that the timer should expire - * @param handler callback function to call when msecs have elapsed - * @param arg argument to pass to the callback function - */ -#if LWIP_DEBUG_TIMERNAMES -void -sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name) -#else /* LWIP_DEBUG_TIMERNAMES */ -void -sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) -#endif /* LWIP_DEBUG_TIMERNAMES */ -{ - struct sys_timeo *timeout, *t; - - timeout = (struct sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); - if (timeout == NULL) { - LWIP_ASSERT("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty", timeout != NULL); - return; - } - timeout->next = NULL; - timeout->h = handler; - timeout->arg = arg; - timeout->time = msecs; -#if LWIP_DEBUG_TIMERNAMES - timeout->handler_name = handler_name; - LWIP_DEBUGF(TIMERS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" handler=%s arg=%p\n", - (void *)timeout, msecs, handler_name, (void *)arg)); -#endif /* LWIP_DEBUG_TIMERNAMES */ - - if (next_timeout == NULL) { - next_timeout = timeout; - return; - } - - if (next_timeout->time > msecs) { - next_timeout->time -= msecs; - timeout->next = next_timeout; - next_timeout = timeout; - } else { - for(t = next_timeout; t != NULL; t = t->next) { - timeout->time -= t->time; - if (t->next == NULL || t->next->time > timeout->time) { - if (t->next != NULL) { - t->next->time -= timeout->time; - } - timeout->next = t->next; - t->next = timeout; - break; - } - } - } -} - -/** - * Go through timeout list (for this task only) and remove the first matching - * entry, even though the timeout has not triggered yet. - * - * @note This function only works as expected if there is only one timeout - * calling 'handler' in the list of timeouts. - * - * @param handler callback function that would be called by the timeout - * @param arg callback argument that would be passed to handler -*/ -void -sys_untimeout(sys_timeout_handler handler, void *arg) -{ - struct sys_timeo *prev_t, *t; - - if (next_timeout == NULL) { - return; - } - - for (t = next_timeout, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { - if ((t->h == handler) && (t->arg == arg)) { - /* We have a match */ - /* Unlink from previous in list */ - if (prev_t == NULL) { - next_timeout = t->next; - } else { - prev_t->next = t->next; - } - /* If not the last one, add time of this one back to next */ - if (t->next != NULL) { - t->next->time += t->time; - } - memp_free(MEMP_SYS_TIMEOUT, t); - return; - } - } - return; -} - -#if NO_SYS - -/** Handle timeouts for NO_SYS==1 (i.e. without using - * tcpip_thread/sys_timeouts_mbox_fetch(). Uses sys_now() to call timeout - * handler functions when timeouts expire. - * - * Must be called periodically from your main loop. - */ -void -sys_check_timeouts(void) -{ - if (next_timeout) { - struct sys_timeo *tmptimeout; - u32_t diff; - sys_timeout_handler handler; - void *arg; - u8_t had_one; - u32_t now; - - now = sys_now(); - /* this cares for wraparounds */ - diff = now - timeouts_last_time; - do - { -#if PBUF_POOL_FREE_OOSEQ - PBUF_CHECK_FREE_OOSEQ(); -#endif /* PBUF_POOL_FREE_OOSEQ */ - had_one = 0; - tmptimeout = next_timeout; - if (tmptimeout && (tmptimeout->time <= diff)) { - /* timeout has expired */ - had_one = 1; - timeouts_last_time = now; - diff -= tmptimeout->time; - next_timeout = tmptimeout->next; - handler = tmptimeout->h; - arg = tmptimeout->arg; -#if LWIP_DEBUG_TIMERNAMES - if (handler != NULL) { - LWIP_DEBUGF(TIMERS_DEBUG, ("sct calling h=%s arg=%p\n", - tmptimeout->handler_name, arg)); - } -#endif /* LWIP_DEBUG_TIMERNAMES */ - memp_free(MEMP_SYS_TIMEOUT, tmptimeout); - if (handler != NULL) { - handler(arg); - } - } - /* repeat until all expired timers have been called */ - }while(had_one); - } -} - -/** Set back the timestamp of the last call to sys_check_timeouts() - * This is necessary if sys_check_timeouts() hasn't been called for a long - * time (e.g. while saving energy) to prevent all timer functions of that - * period being called. - */ -void -sys_restart_timeouts(void) -{ - timeouts_last_time = sys_now(); -} - -#else /* NO_SYS */ - -/** - * Wait (forever) for a message to arrive in an mbox. - * While waiting, timeouts are processed. - * - * @param mbox the mbox to fetch the message from - * @param msg the place to store the message - */ -void -sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) -{ - u32_t time_needed; - struct sys_timeo *tmptimeout; - sys_timeout_handler handler; - void *arg; - - again: - if (!next_timeout) { - time_needed = sys_arch_mbox_fetch(mbox, msg, 0); - } else { - if (next_timeout->time > 0) { - time_needed = sys_arch_mbox_fetch(mbox, msg, next_timeout->time); - } else { - time_needed = SYS_ARCH_TIMEOUT; - } - - if (time_needed == SYS_ARCH_TIMEOUT) { - /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message - could be fetched. We should now call the timeout handler and - deallocate the memory allocated for the timeout. */ - tmptimeout = next_timeout; - next_timeout = tmptimeout->next; - handler = tmptimeout->h; - arg = tmptimeout->arg; -#if LWIP_DEBUG_TIMERNAMES - if (handler != NULL) { - LWIP_DEBUGF(TIMERS_DEBUG, ("stmf calling h=%s arg=%p\n", - tmptimeout->handler_name, arg)); - } -#endif /* LWIP_DEBUG_TIMERNAMES */ - memp_free(MEMP_SYS_TIMEOUT, tmptimeout); - if (handler != NULL) { - /* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the - timeout handler function. */ - LOCK_TCPIP_CORE(); - handler(arg); - UNLOCK_TCPIP_CORE(); - } - LWIP_TCPIP_THREAD_ALIVE(); - - /* We try again to fetch a message from the mbox. */ - goto again; - } else { - /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout - occured. The time variable is set to the number of - milliseconds we waited for the message. */ - if (time_needed < next_timeout->time) { - next_timeout->time -= time_needed; - } else { - next_timeout->time = 0; - } - } - } -} - -#endif /* NO_SYS */ - -#else /* LWIP_TIMERS */ -/* Satisfy the TCP code which calls this function */ -void -tcp_timer_needed(void) -{ -} -#endif /* LWIP_TIMERS */ diff --git a/user/mpy/lib/lwip/src/core/udp.c b/user/mpy/lib/lwip/src/core/udp.c deleted file mode 100644 index 32c7d38..0000000 --- a/user/mpy/lib/lwip/src/core/udp.c +++ /dev/null @@ -1,1013 +0,0 @@ -/** - * @file - * User Datagram Protocol module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - -/* udp.c - * - * The code for the User Datagram Protocol UDP & UDPLite (RFC 3828). - * - */ - -/* @todo Check the use of '(struct udp_pcb).chksum_len_rx'! - */ - -#include "lwip/opt.h" - -#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/udp.h" -#include "lwip/def.h" -#include "lwip/memp.h" -#include "lwip/inet_chksum.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "arch/perf.h" -#include "lwip/dhcp.h" - -#include - -#ifndef UDP_LOCAL_PORT_RANGE_START -/* From http://www.iana.org/assignments/port-numbers: - "The Dynamic and/or Private Ports are those from 49152 through 65535" */ -#define UDP_LOCAL_PORT_RANGE_START 0xc000 -#define UDP_LOCAL_PORT_RANGE_END 0xffff -#define UDP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~UDP_LOCAL_PORT_RANGE_START) + UDP_LOCAL_PORT_RANGE_START) -#endif - -/* last local UDP port */ -static u16_t udp_port = UDP_LOCAL_PORT_RANGE_START; - -/* The list of UDP PCBs */ -/* exported in udp.h (was static) */ -struct udp_pcb *udp_pcbs; - -/** - * Initialize this module. - */ -void -udp_init(void) -{ -#if LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) - udp_port = UDP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()); -#endif /* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) */ -} - -/** - * Allocate a new local UDP port. - * - * @return a new (free) local UDP port number - */ -static u16_t -udp_new_port(void) -{ - u16_t n = 0; - struct udp_pcb *pcb; - -again: - if (udp_port++ == UDP_LOCAL_PORT_RANGE_END) { - udp_port = UDP_LOCAL_PORT_RANGE_START; - } - /* Check all PCBs. */ - for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { - if (pcb->local_port == udp_port) { - if (++n > (UDP_LOCAL_PORT_RANGE_END - UDP_LOCAL_PORT_RANGE_START)) { - return 0; - } - goto again; - } - } - return udp_port; -#if 0 - struct udp_pcb *ipcb = udp_pcbs; - while ((ipcb != NULL) && (udp_port != UDP_LOCAL_PORT_RANGE_END)) { - if (ipcb->local_port == udp_port) { - /* port is already used by another udp_pcb */ - udp_port++; - /* restart scanning all udp pcbs */ - ipcb = udp_pcbs; - } else { - /* go on with next udp pcb */ - ipcb = ipcb->next; - } - } - if (ipcb != NULL) { - return 0; - } - return udp_port; -#endif -} - -/** - * Process an incoming UDP datagram. - * - * Given an incoming UDP datagram (as a chain of pbufs) this function - * finds a corresponding UDP PCB and hands over the pbuf to the pcbs - * recv function. If no pcb is found or the datagram is incorrect, the - * pbuf is freed. - * - * @param p pbuf to be demultiplexed to a UDP PCB. - * @param inp network interface on which the datagram was received. - * - */ -void -udp_input(struct pbuf *p, struct netif *inp) -{ - struct udp_hdr *udphdr; - struct udp_pcb *pcb, *prev; - struct udp_pcb *uncon_pcb; - struct ip_hdr *iphdr; - u16_t src, dest; - u8_t local_match; - u8_t broadcast; - - PERF_START; - - UDP_STATS_INC(udp.recv); - - iphdr = (struct ip_hdr *)p->payload; - - /* Check minimum length (IP header + UDP header) - * and move payload pointer to UDP header */ - if (p->tot_len < (IPH_HL(iphdr) * 4 + UDP_HLEN) || pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4))) { - /* drop short packets */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len)); - UDP_STATS_INC(udp.lenerr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } - - udphdr = (struct udp_hdr *)p->payload; - - /* is broadcast packet ? */ - broadcast = ip_addr_isbroadcast(¤t_iphdr_dest, inp); - - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); - - /* convert src and dest ports to host byte order */ - src = ntohs(udphdr->src); - dest = ntohs(udphdr->dest); - - udp_debug_print(udphdr); - - /* print the UDP source and destination */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") <-- " - "(%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", - ip4_addr1_16(&iphdr->dest), ip4_addr2_16(&iphdr->dest), - ip4_addr3_16(&iphdr->dest), ip4_addr4_16(&iphdr->dest), ntohs(udphdr->dest), - ip4_addr1_16(&iphdr->src), ip4_addr2_16(&iphdr->src), - ip4_addr3_16(&iphdr->src), ip4_addr4_16(&iphdr->src), ntohs(udphdr->src))); - -#if LWIP_DHCP - pcb = NULL; - /* when LWIP_DHCP is active, packets to DHCP_CLIENT_PORT may only be processed by - the dhcp module, no other UDP pcb may use the local UDP port DHCP_CLIENT_PORT */ - if (dest == DHCP_CLIENT_PORT) { - /* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */ - if (src == DHCP_SERVER_PORT) { - if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) { - /* accept the packe if - (- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY! - - inp->dhcp->pcb->remote == ANY or iphdr->src */ - if ((ip_addr_isany(&inp->dhcp->pcb->remote_ip) || - ip_addr_cmp(&(inp->dhcp->pcb->remote_ip), ¤t_iphdr_src))) { - pcb = inp->dhcp->pcb; - } - } - } - } else -#endif /* LWIP_DHCP */ - { - prev = NULL; - local_match = 0; - uncon_pcb = NULL; - /* Iterate through the UDP pcb list for a matching pcb. - * 'Perfect match' pcbs (connected to the remote port & ip address) are - * preferred. If no perfect match is found, the first unconnected pcb that - * matches the local port and ip address gets the datagram. */ - for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { - local_match = 0; - /* print the PCB local and remote address */ - LWIP_DEBUGF(UDP_DEBUG, - ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- " - "(%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", - ip4_addr1_16(&pcb->local_ip), ip4_addr2_16(&pcb->local_ip), - ip4_addr3_16(&pcb->local_ip), ip4_addr4_16(&pcb->local_ip), pcb->local_port, - ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), - ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip), pcb->remote_port)); - - /* compare PCB local addr+port to UDP destination addr+port */ - if (pcb->local_port == dest) { - if ( - (!broadcast && ip_addr_isany(&pcb->local_ip)) || - ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest) || -#if LWIP_IGMP - ip_addr_ismulticast(¤t_iphdr_dest) || -#endif /* LWIP_IGMP */ -#if IP_SOF_BROADCAST_RECV - (broadcast && ip_get_option(pcb, SOF_BROADCAST) && - (ip_addr_isany(&pcb->local_ip) || - ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))) { -#else /* IP_SOF_BROADCAST_RECV */ - (broadcast && - (ip_addr_isany(&pcb->local_ip) || - ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))) { -#endif /* IP_SOF_BROADCAST_RECV */ - local_match = 1; - if ((uncon_pcb == NULL) && - ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { - /* the first unconnected matching PCB */ - uncon_pcb = pcb; - } - } - } - /* compare PCB remote addr+port to UDP source addr+port */ - if ((local_match != 0) && - (pcb->remote_port == src) && - (ip_addr_isany(&pcb->remote_ip) || - ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src))) { - /* the first fully matching PCB */ - if (prev != NULL) { - /* move the pcb to the front of udp_pcbs so that is - found faster next time */ - prev->next = pcb->next; - pcb->next = udp_pcbs; - udp_pcbs = pcb; - } else { - UDP_STATS_INC(udp.cachehit); - } - break; - } - prev = pcb; - } - /* no fully matching pcb found? then look for an unconnected pcb */ - if (pcb == NULL) { - pcb = uncon_pcb; - } - } - - /* Check checksum if this is a match or if it was directed at us. */ - if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, ¤t_iphdr_dest)) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n")); -#if LWIP_UDPLITE - if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) { - /* Do the UDP Lite checksum */ -#if CHECKSUM_CHECK_UDP - u16_t chklen = ntohs(udphdr->len); - if (chklen < sizeof(struct udp_hdr)) { - if (chklen == 0) { - /* For UDP-Lite, checksum length of 0 means checksum - over the complete packet (See RFC 3828 chap. 3.1) */ - chklen = p->tot_len; - } else { - /* At least the UDP-Lite header must be covered by the - checksum! (Again, see RFC 3828 chap. 3.1) */ - UDP_STATS_INC(udp.chkerr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } - } - if (inet_chksum_pseudo_partial(p, ¤t_iphdr_src, ¤t_iphdr_dest, - IP_PROTO_UDPLITE, p->tot_len, chklen) != 0) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("udp_input: UDP Lite datagram discarded due to failing checksum\n")); - UDP_STATS_INC(udp.chkerr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } -#endif /* CHECKSUM_CHECK_UDP */ - } else -#endif /* LWIP_UDPLITE */ - { -#if CHECKSUM_CHECK_UDP - if (udphdr->chksum != 0) { - if (inet_chksum_pseudo(p, ip_current_src_addr(), ip_current_dest_addr(), - IP_PROTO_UDP, p->tot_len) != 0) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("udp_input: UDP datagram discarded due to failing checksum\n")); - UDP_STATS_INC(udp.chkerr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } - } -#endif /* CHECKSUM_CHECK_UDP */ - } - if(pbuf_header(p, -UDP_HLEN)) { - /* Can we cope with this failing? Just assert for now */ - LWIP_ASSERT("pbuf_header failed\n", 0); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } - if (pcb != NULL) { - snmp_inc_udpindatagrams(); -#if SO_REUSE && SO_REUSE_RXTOALL - if ((broadcast || ip_addr_ismulticast(¤t_iphdr_dest)) && - ip_get_option(pcb, SOF_REUSEADDR)) { - /* pass broadcast- or multicast packets to all multicast pcbs - if SOF_REUSEADDR is set on the first match */ - struct udp_pcb *mpcb; - u8_t p_header_changed = 0; - for (mpcb = udp_pcbs; mpcb != NULL; mpcb = mpcb->next) { - if (mpcb != pcb) { - /* compare PCB local addr+port to UDP destination addr+port */ - if ((mpcb->local_port == dest) && - ((!broadcast && ip_addr_isany(&mpcb->local_ip)) || - ip_addr_cmp(&(mpcb->local_ip), ¤t_iphdr_dest) || -#if LWIP_IGMP - ip_addr_ismulticast(¤t_iphdr_dest) || -#endif /* LWIP_IGMP */ -#if IP_SOF_BROADCAST_RECV - (broadcast && ip_get_option(mpcb, SOF_BROADCAST)))) { -#else /* IP_SOF_BROADCAST_RECV */ - (broadcast))) { -#endif /* IP_SOF_BROADCAST_RECV */ - /* pass a copy of the packet to all local matches */ - if (mpcb->recv != NULL) { - struct pbuf *q; - /* for that, move payload to IP header again */ - if (p_header_changed == 0) { - pbuf_header(p, (s16_t)((IPH_HL(iphdr) * 4) + UDP_HLEN)); - p_header_changed = 1; - } - q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); - if (q != NULL) { - err_t err = pbuf_copy(q, p); - if (err == ERR_OK) { - /* move payload to UDP data */ - pbuf_header(q, -(s16_t)((IPH_HL(iphdr) * 4) + UDP_HLEN)); - mpcb->recv(mpcb->recv_arg, mpcb, q, ip_current_src_addr(), src); - } - } - } - } - } - } - if (p_header_changed) { - /* and move payload to UDP data again */ - pbuf_header(p, -(s16_t)((IPH_HL(iphdr) * 4) + UDP_HLEN)); - } - } -#endif /* SO_REUSE && SO_REUSE_RXTOALL */ - /* callback */ - if (pcb->recv != NULL) { - /* now the recv function is responsible for freeing p */ - pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr(), src); - } else { - /* no recv function registered? then we have to free the pbuf! */ - pbuf_free(p); - goto end; - } - } else { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: not for us.\n")); - -#if LWIP_ICMP - /* No match was found, send ICMP destination port unreachable unless - destination address was broadcast/multicast. */ - if (!broadcast && - !ip_addr_ismulticast(¤t_iphdr_dest)) { - /* move payload pointer back to ip header */ - pbuf_header(p, (IPH_HL(iphdr) * 4) + UDP_HLEN); - LWIP_ASSERT("p->payload == iphdr", (p->payload == iphdr)); - icmp_dest_unreach(p, ICMP_DUR_PORT); - } -#endif /* LWIP_ICMP */ - UDP_STATS_INC(udp.proterr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpnoports(); - pbuf_free(p); - } - } else { - pbuf_free(p); - } -end: - PERF_STOP("udp_input"); -} - -/** - * Send data using UDP. - * - * @param pcb UDP PCB used to send the data. - * @param p chain of pbuf's to be sent. - * - * The datagram will be sent to the current remote_ip & remote_port - * stored in pcb. If the pcb is not bound to a port, it will - * automatically be bound to a random port. - * - * @return lwIP error code. - * - ERR_OK. Successful. No error occured. - * - ERR_MEM. Out of memory. - * - ERR_RTE. Could not find route to destination address. - * - More errors could be returned by lower protocol layers. - * - * @see udp_disconnect() udp_sendto() - */ -err_t -udp_send(struct udp_pcb *pcb, struct pbuf *p) -{ - /* send to the packet using remote ip and port stored in the pcb */ - return udp_sendto(pcb, p, &pcb->remote_ip, pcb->remote_port); -} - -#if LWIP_CHECKSUM_ON_COPY -/** Same as udp_send() but with checksum - */ -err_t -udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, - u8_t have_chksum, u16_t chksum) -{ - /* send to the packet using remote ip and port stored in the pcb */ - return udp_sendto_chksum(pcb, p, &pcb->remote_ip, pcb->remote_port, - have_chksum, chksum); -} -#endif /* LWIP_CHECKSUM_ON_COPY */ - -/** - * Send data to a specified address using UDP. - * - * @param pcb UDP PCB used to send the data. - * @param p chain of pbuf's to be sent. - * @param dst_ip Destination IP address. - * @param dst_port Destination UDP port. - * - * dst_ip & dst_port are expected to be in the same byte order as in the pcb. - * - * If the PCB already has a remote address association, it will - * be restored after the data is sent. - * - * @return lwIP error code (@see udp_send for possible error codes) - * - * @see udp_disconnect() udp_send() - */ -err_t -udp_sendto(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port) -{ -#if LWIP_CHECKSUM_ON_COPY - return udp_sendto_chksum(pcb, p, dst_ip, dst_port, 0, 0); -} - -/** Same as udp_sendto(), but with checksum */ -err_t -udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, - u16_t dst_port, u8_t have_chksum, u16_t chksum) -{ -#endif /* LWIP_CHECKSUM_ON_COPY */ - struct netif *netif; - - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n")); - - /* find the outgoing network interface for this packet */ -#if LWIP_IGMP - netif = ip_route((ip_addr_ismulticast(dst_ip))?(&(pcb->multicast_ip)):(dst_ip)); -#else - netif = ip_route(dst_ip); -#endif /* LWIP_IGMP */ - - /* no outgoing network interface could be found? */ - if (netif == NULL) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dst_ip), ip4_addr2_16(dst_ip), ip4_addr3_16(dst_ip), ip4_addr4_16(dst_ip))); - UDP_STATS_INC(udp.rterr); - return ERR_RTE; - } -#if LWIP_CHECKSUM_ON_COPY - return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum); -#else /* LWIP_CHECKSUM_ON_COPY */ - return udp_sendto_if(pcb, p, dst_ip, dst_port, netif); -#endif /* LWIP_CHECKSUM_ON_COPY */ -} - -/** - * Send data to a specified address using UDP. - * The netif used for sending can be specified. - * - * This function exists mainly for DHCP, to be able to send UDP packets - * on a netif that is still down. - * - * @param pcb UDP PCB used to send the data. - * @param p chain of pbuf's to be sent. - * @param dst_ip Destination IP address. - * @param dst_port Destination UDP port. - * @param netif the netif used for sending. - * - * dst_ip & dst_port are expected to be in the same byte order as in the pcb. - * - * @return lwIP error code (@see udp_send for possible error codes) - * - * @see udp_disconnect() udp_send() - */ -err_t -udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif) -{ -#if LWIP_CHECKSUM_ON_COPY - return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0); -} - -/** Same as udp_sendto_if(), but with checksum */ -err_t -udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, - u16_t dst_port, struct netif *netif, u8_t have_chksum, - u16_t chksum) -{ -#endif /* LWIP_CHECKSUM_ON_COPY */ - struct udp_hdr *udphdr; - ip_addr_t *src_ip; - err_t err; - struct pbuf *q; /* q will be sent down the stack */ - -#if IP_SOF_BROADCAST - /* broadcast filter? */ - if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(dst_ip, netif)) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("udp_sendto_if: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); - return ERR_VAL; - } -#endif /* IP_SOF_BROADCAST */ - - /* if the PCB is not yet bound to a port, bind it here */ - if (pcb->local_port == 0) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send: not yet bound to a port, binding now\n")); - err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); - if (err != ERR_OK) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: forced port bind failed\n")); - return err; - } - } - - /* not enough space to add an UDP header to first pbuf in given p chain? */ - if (pbuf_header(p, UDP_HLEN)) { - /* allocate header in a separate new pbuf */ - q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM); - /* new header pbuf could not be allocated? */ - if (q == NULL) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: could not allocate header\n")); - return ERR_MEM; - } - if (p->tot_len != 0) { - /* chain header q in front of given pbuf p (only if p contains data) */ - pbuf_chain(q, p); - } - /* first pbuf q points to header pbuf */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); - } else { - /* adding space for header within p succeeded */ - /* first pbuf q equals given pbuf */ - q = p; - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p)); - } - LWIP_ASSERT("check that first pbuf can hold struct udp_hdr", - (q->len >= sizeof(struct udp_hdr))); - /* q now represents the packet to be sent */ - udphdr = (struct udp_hdr *)q->payload; - udphdr->src = htons(pcb->local_port); - udphdr->dest = htons(dst_port); - /* in UDP, 0 checksum means 'no checksum' */ - udphdr->chksum = 0x0000; - - /* Multicast Loop? */ -#if LWIP_IGMP - if (ip_addr_ismulticast(dst_ip) && ((pcb->flags & UDP_FLAGS_MULTICAST_LOOP) != 0)) { - q->flags |= PBUF_FLAG_MCASTLOOP; - } -#endif /* LWIP_IGMP */ - - - /* PCB local address is IP_ANY_ADDR? */ - if (ip_addr_isany(&pcb->local_ip)) { - /* use outgoing network interface IP address as source address */ - src_ip = &(netif->ip_addr); - } else { - /* check if UDP PCB local IP address is correct - * this could be an old address if netif->ip_addr has changed */ - if (!ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) { - /* local_ip doesn't match, drop the packet */ - if (q != p) { - /* free the header pbuf */ - pbuf_free(q); - q = NULL; - /* p is still referenced by the caller, and will live on */ - } - return ERR_VAL; - } - /* use UDP PCB local IP address as source address */ - src_ip = &(pcb->local_ip); - } - - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len)); - -#if LWIP_UDPLITE - /* UDP Lite protocol? */ - if (pcb->flags & UDP_FLAGS_UDPLITE) { - u16_t chklen, chklen_hdr; - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len)); - /* set UDP message length in UDP header */ - chklen_hdr = chklen = pcb->chksum_len_tx; - if ((chklen < sizeof(struct udp_hdr)) || (chklen > q->tot_len)) { - if (chklen != 0) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE pcb->chksum_len is illegal: %"U16_F"\n", chklen)); - } - /* For UDP-Lite, checksum length of 0 means checksum - over the complete packet. (See RFC 3828 chap. 3.1) - At least the UDP-Lite header must be covered by the - checksum, therefore, if chksum_len has an illegal - value, we generate the checksum over the complete - packet to be safe. */ - chklen_hdr = 0; - chklen = q->tot_len; - } - udphdr->len = htons(chklen_hdr); - /* calculate checksum */ -#if CHECKSUM_GEN_UDP - udphdr->chksum = inet_chksum_pseudo_partial(q, src_ip, dst_ip, - IP_PROTO_UDPLITE, q->tot_len, -#if !LWIP_CHECKSUM_ON_COPY - chklen); -#else /* !LWIP_CHECKSUM_ON_COPY */ - (have_chksum ? UDP_HLEN : chklen)); - if (have_chksum) { - u32_t acc; - acc = udphdr->chksum + (u16_t)~(chksum); - udphdr->chksum = FOLD_U32T(acc); - } -#endif /* !LWIP_CHECKSUM_ON_COPY */ - - /* chksum zero must become 0xffff, as zero means 'no checksum' */ - if (udphdr->chksum == 0x0000) { - udphdr->chksum = 0xffff; - } -#endif /* CHECKSUM_GEN_UDP */ - /* output to IP */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n")); - NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint); - err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - } else -#endif /* LWIP_UDPLITE */ - { /* UDP */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); - udphdr->len = htons(q->tot_len); - /* calculate checksum */ -#if CHECKSUM_GEN_UDP - if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { - u16_t udpchksum; -#if LWIP_CHECKSUM_ON_COPY - if (have_chksum) { - u32_t acc; - udpchksum = inet_chksum_pseudo_partial(q, src_ip, dst_ip, IP_PROTO_UDP, - q->tot_len, UDP_HLEN); - acc = udpchksum + (u16_t)~(chksum); - udpchksum = FOLD_U32T(acc); - } else -#endif /* LWIP_CHECKSUM_ON_COPY */ - { - udpchksum = inet_chksum_pseudo(q, src_ip, dst_ip, IP_PROTO_UDP, q->tot_len); - } - - /* chksum zero must become 0xffff, as zero means 'no checksum' */ - if (udpchksum == 0x0000) { - udpchksum = 0xffff; - } - udphdr->chksum = udpchksum; - } -#endif /* CHECKSUM_GEN_UDP */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); - /* output to IP */ - NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint); - err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - } - /* TODO: must this be increased even if error occured? */ - snmp_inc_udpoutdatagrams(); - - /* did we chain a separate header pbuf earlier? */ - if (q != p) { - /* free the header pbuf */ - pbuf_free(q); - q = NULL; - /* p is still referenced by the caller, and will live on */ - } - - UDP_STATS_INC(udp.xmit); - return err; -} - -/** - * Bind an UDP PCB. - * - * @param pcb UDP PCB to be bound with a local address ipaddr and port. - * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to - * bind to all local interfaces. - * @param port local UDP port to bind with. Use 0 to automatically bind - * to a random port between UDP_LOCAL_PORT_RANGE_START and - * UDP_LOCAL_PORT_RANGE_END. - * - * ipaddr & port are expected to be in the same byte order as in the pcb. - * - * @return lwIP error code. - * - ERR_OK. Successful. No error occured. - * - ERR_USE. The specified ipaddr and port are already bound to by - * another UDP PCB. - * - * @see udp_disconnect() - */ -err_t -udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) -{ - struct udp_pcb *ipcb; - u8_t rebind; - - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_bind(ipaddr = ")); - ip_addr_debug_print(UDP_DEBUG, ipaddr); - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, (", port = %"U16_F")\n", port)); - - rebind = 0; - /* Check for double bind and rebind of the same pcb */ - for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { - /* is this UDP PCB already on active list? */ - if (pcb == ipcb) { - /* pcb may occur at most once in active list */ - LWIP_ASSERT("rebind == 0", rebind == 0); - /* pcb already in list, just rebind */ - rebind = 1; - } - - /* By default, we don't allow to bind to a port that any other udp - PCB is alread bound to, unless *all* PCBs with that port have tha - REUSEADDR flag set. */ -#if SO_REUSE - else if (!ip_get_option(pcb, SOF_REUSEADDR) && - !ip_get_option(ipcb, SOF_REUSEADDR)) { -#else /* SO_REUSE */ - /* port matches that of PCB in list and REUSEADDR not set -> reject */ - else { -#endif /* SO_REUSE */ - if ((ipcb->local_port == port) && - /* IP address matches, or one is IP_ADDR_ANY? */ - (ip_addr_isany(&(ipcb->local_ip)) || - ip_addr_isany(ipaddr) || - ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { - /* other PCB already binds to this local IP and port */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp_bind: local port %"U16_F" already bound by another pcb\n", port)); - return ERR_USE; - } - } - } - - ip_addr_set(&pcb->local_ip, ipaddr); - - /* no port specified? */ - if (port == 0) { - port = udp_new_port(); - if (port == 0) { - /* no more ports available in local range */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n")); - return ERR_USE; - } - } - pcb->local_port = port; - snmp_insert_udpidx_tree(pcb); - /* pcb not active yet? */ - if (rebind == 0) { - /* place the PCB on the active list if not already there */ - pcb->next = udp_pcbs; - udp_pcbs = pcb; - } - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n", - ip4_addr1_16(&pcb->local_ip), ip4_addr2_16(&pcb->local_ip), - ip4_addr3_16(&pcb->local_ip), ip4_addr4_16(&pcb->local_ip), - pcb->local_port)); - return ERR_OK; -} -/** - * Connect an UDP PCB. - * - * This will associate the UDP PCB with the remote address. - * - * @param pcb UDP PCB to be connected with remote address ipaddr and port. - * @param ipaddr remote IP address to connect with. - * @param port remote UDP port to connect with. - * - * @return lwIP error code - * - * ipaddr & port are expected to be in the same byte order as in the pcb. - * - * The udp pcb is bound to a random local port if not already bound. - * - * @see udp_disconnect() - */ -err_t -udp_connect(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) -{ - struct udp_pcb *ipcb; - - if (pcb->local_port == 0) { - err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); - if (err != ERR_OK) { - return err; - } - } - - ip_addr_set(&pcb->remote_ip, ipaddr); - pcb->remote_port = port; - pcb->flags |= UDP_FLAGS_CONNECTED; -/** TODO: this functionality belongs in upper layers */ -#ifdef LWIP_UDP_TODO - /* Nail down local IP for netconn_addr()/getsockname() */ - if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) { - struct netif *netif; - - if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr)); - UDP_STATS_INC(udp.rterr); - return ERR_RTE; - } - /** TODO: this will bind the udp pcb locally, to the interface which - is used to route output packets to the remote address. However, we - might want to accept incoming packets on any interface! */ - pcb->local_ip = netif->ip_addr; - } else if (ip_addr_isany(&pcb->remote_ip)) { - pcb->local_ip.addr = 0; - } -#endif - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - ("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n", - ip4_addr1_16(&pcb->local_ip), ip4_addr2_16(&pcb->local_ip), - ip4_addr3_16(&pcb->local_ip), ip4_addr4_16(&pcb->local_ip), - pcb->local_port)); - - /* Insert UDP PCB into the list of active UDP PCBs. */ - for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { - if (pcb == ipcb) { - /* already on the list, just return */ - return ERR_OK; - } - } - /* PCB not yet on the list, add PCB now */ - pcb->next = udp_pcbs; - udp_pcbs = pcb; - return ERR_OK; -} - -/** - * Disconnect a UDP PCB - * - * @param pcb the udp pcb to disconnect. - */ -void -udp_disconnect(struct udp_pcb *pcb) -{ - /* reset remote address association */ - ip_addr_set_any(&pcb->remote_ip); - pcb->remote_port = 0; - /* mark PCB as unconnected */ - pcb->flags &= ~UDP_FLAGS_CONNECTED; -} - -/** - * Set a receive callback for a UDP PCB - * - * This callback will be called when receiving a datagram for the pcb. - * - * @param pcb the pcb for wich to set the recv callback - * @param recv function pointer of the callback function - * @param recv_arg additional argument to pass to the callback function - */ -void -udp_recv(struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg) -{ - /* remember recv() callback and user data */ - pcb->recv = recv; - pcb->recv_arg = recv_arg; -} - -/** - * Remove an UDP PCB. - * - * @param pcb UDP PCB to be removed. The PCB is removed from the list of - * UDP PCB's and the data structure is freed from memory. - * - * @see udp_new() - */ -void -udp_remove(struct udp_pcb *pcb) -{ - struct udp_pcb *pcb2; - - snmp_delete_udpidx_tree(pcb); - /* pcb to be removed is first in list? */ - if (udp_pcbs == pcb) { - /* make list start at 2nd pcb */ - udp_pcbs = udp_pcbs->next; - /* pcb not 1st in list */ - } else { - for (pcb2 = udp_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { - /* find pcb in udp_pcbs list */ - if (pcb2->next != NULL && pcb2->next == pcb) { - /* remove pcb from list */ - pcb2->next = pcb->next; - } - } - } - memp_free(MEMP_UDP_PCB, pcb); -} - -/** - * Create a UDP PCB. - * - * @return The UDP PCB which was created. NULL if the PCB data structure - * could not be allocated. - * - * @see udp_remove() - */ -struct udp_pcb * -udp_new(void) -{ - struct udp_pcb *pcb; - pcb = (struct udp_pcb *)memp_malloc(MEMP_UDP_PCB); - /* could allocate UDP PCB? */ - if (pcb != NULL) { - /* UDP Lite: by initializing to all zeroes, chksum_len is set to 0 - * which means checksum is generated over the whole datagram per default - * (recommended as default by RFC 3828). */ - /* initialize PCB to all zeroes */ - memset(pcb, 0, sizeof(struct udp_pcb)); - pcb->ttl = UDP_TTL; - } - return pcb; -} - -#if UDP_DEBUG -/** - * Print UDP header information for debug purposes. - * - * @param udphdr pointer to the udp header in memory. - */ -void -udp_debug_print(struct udp_hdr *udphdr) -{ - LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); - LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", - ntohs(udphdr->src), ntohs(udphdr->dest))); - LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n", - ntohs(udphdr->len), ntohs(udphdr->chksum))); - LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); -} -#endif /* UDP_DEBUG */ - -#endif /* LWIP_UDP */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h deleted file mode 100644 index e62b72e..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/autoip.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file - * - * AutoIP Automatic LinkLocal IP Configuration - */ - -/* - * - * Copyright (c) 2007 Dominik Spies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Dominik Spies - * - * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform - * with RFC 3927. - * - * - * Please coordinate changes and requests with Dominik Spies - * - */ - -#ifndef __LWIP_AUTOIP_H__ -#define __LWIP_AUTOIP_H__ - -#include "lwip/opt.h" - -#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/netif.h" -#include "lwip/udp.h" -#include "netif/etharp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* AutoIP Timing */ -#define AUTOIP_TMR_INTERVAL 100 -#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) - -/* RFC 3927 Constants */ -#define PROBE_WAIT 1 /* second (initial random delay) */ -#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ -#define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ -#define PROBE_NUM 3 /* (number of probe packets) */ -#define ANNOUNCE_NUM 2 /* (number of announcement packets) */ -#define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ -#define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ -#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ -#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ -#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ - -/* AutoIP client states */ -#define AUTOIP_STATE_OFF 0 -#define AUTOIP_STATE_PROBING 1 -#define AUTOIP_STATE_ANNOUNCING 2 -#define AUTOIP_STATE_BOUND 3 - -struct autoip -{ - ip_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */ - u8_t state; /* current AutoIP state machine state */ - u8_t sent_num; /* sent number of probes or announces, dependent on state */ - u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ - u8_t lastconflict; /* ticks until a conflict can be solved by defending */ - u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */ -}; - - -#define autoip_init() /* Compatibility define, no init needed. */ - -/** Set a struct autoip allocated by the application to work with */ -void autoip_set_struct(struct netif *netif, struct autoip *autoip); - -/** Start AutoIP client */ -err_t autoip_start(struct netif *netif); - -/** Stop AutoIP client */ -err_t autoip_stop(struct netif *netif); - -/** Handles every incoming ARP Packet, called by etharp_arp_input */ -void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); - -/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */ -void autoip_tmr(void); - -/** Handle a possible change in the network configuration */ -void autoip_network_changed(struct netif *netif); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_AUTOIP */ - -#endif /* __LWIP_AUTOIP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h deleted file mode 100644 index d47a7d8..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/icmp.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ICMP_H__ -#define __LWIP_ICMP_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ICMP_ER 0 /* echo reply */ -#define ICMP_DUR 3 /* destination unreachable */ -#define ICMP_SQ 4 /* source quench */ -#define ICMP_RD 5 /* redirect */ -#define ICMP_ECHO 8 /* echo */ -#define ICMP_TE 11 /* time exceeded */ -#define ICMP_PP 12 /* parameter problem */ -#define ICMP_TS 13 /* timestamp */ -#define ICMP_TSR 14 /* timestamp reply */ -#define ICMP_IRQ 15 /* information request */ -#define ICMP_IR 16 /* information reply */ - -enum icmp_dur_type { - ICMP_DUR_NET = 0, /* net unreachable */ - ICMP_DUR_HOST = 1, /* host unreachable */ - ICMP_DUR_PROTO = 2, /* protocol unreachable */ - ICMP_DUR_PORT = 3, /* port unreachable */ - ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ - ICMP_DUR_SR = 5 /* source route failed */ -}; - -enum icmp_te_type { - ICMP_TE_TTL = 0, /* time to live exceeded in transit */ - ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ -}; - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -/** This is the standard ICMP header only that the u32_t data - * is splitted to two u16_t like ICMP echo needs it. - * This header is also used for other ICMP types that do not - * use the data part. - */ -PACK_STRUCT_BEGIN -struct icmp_echo_hdr { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FIELD(u16_t seqno); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define ICMPH_TYPE(hdr) ((hdr)->type) -#define ICMPH_CODE(hdr) ((hdr)->code) - -/** Combines type and code to an u16_t */ -#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) -#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) - - -#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -void icmp_input(struct pbuf *p, struct netif *inp); -void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); -void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); - -#endif /* LWIP_ICMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_ICMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h deleted file mode 100644 index 8aabac2..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/igmp.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2002 CITEL Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is a contribution to the lwIP TCP/IP stack. - * The Swedish Institute of Computer Science and Adam Dunkels - * are specifically granted permission to redistribute this - * source code. -*/ - -#ifndef __LWIP_IGMP_H__ -#define __LWIP_IGMP_H__ - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/pbuf.h" - -#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* IGMP timer */ -#define IGMP_TMR_INTERVAL 100 /* Milliseconds */ -#define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) -#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) - -/* MAC Filter Actions, these are passed to a netif's - * igmp_mac_filter callback function. */ -#define IGMP_DEL_MAC_FILTER 0 -#define IGMP_ADD_MAC_FILTER 1 - - -/** - * igmp group structure - there is - * a list of groups for each interface - * these should really be linked from the interface, but - * if we keep them separate we will not affect the lwip original code - * too much - * - * There will be a group for the all systems group address but this - * will not run the state machine as it is used to kick off reports - * from all the other groups - */ -struct igmp_group { - /** next link */ - struct igmp_group *next; - /** interface on which the group is active */ - struct netif *netif; - /** multicast address */ - ip_addr_t group_address; - /** signifies we were the last person to report */ - u8_t last_reporter_flag; - /** current state of the group */ - u8_t group_state; - /** timer for reporting, negative is OFF */ - u16_t timer; - /** counter of simultaneous uses */ - u8_t use; -}; - -/* Prototypes */ -void igmp_init(void); -err_t igmp_start(struct netif *netif); -err_t igmp_stop(struct netif *netif); -void igmp_report_groups(struct netif *netif); -struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); -void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); -err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); -err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); -void igmp_tmr(void); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IGMP */ - -#endif /* __LWIP_IGMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h deleted file mode 100644 index 7bff49b..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/inet.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INET_H__ -#define __LWIP_INET_H__ - -#include "lwip/opt.h" -#include "lwip/def.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** For compatibility with BSD code */ -struct in_addr { - u32_t s_addr; -}; - -/** 255.255.255.255 */ -#define INADDR_NONE IPADDR_NONE -/** 127.0.0.1 */ -#define INADDR_LOOPBACK IPADDR_LOOPBACK -/** 0.0.0.0 */ -#define INADDR_ANY IPADDR_ANY -/** 255.255.255.255 */ -#define INADDR_BROADCAST IPADDR_BROADCAST - -/* Definitions of the bits in an Internet address integer. - - On subnets, host and network parts are found according to - the subnet mask, not these masks. */ -#define IN_CLASSA(a) IP_CLASSA(a) -#define IN_CLASSA_NET IP_CLASSA_NET -#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT -#define IN_CLASSA_HOST IP_CLASSA_HOST -#define IN_CLASSA_MAX IP_CLASSA_MAX - -#define IN_CLASSB(b) IP_CLASSB(b) -#define IN_CLASSB_NET IP_CLASSB_NET -#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT -#define IN_CLASSB_HOST IP_CLASSB_HOST -#define IN_CLASSB_MAX IP_CLASSB_MAX - -#define IN_CLASSC(c) IP_CLASSC(c) -#define IN_CLASSC_NET IP_CLASSC_NET -#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT -#define IN_CLASSC_HOST IP_CLASSC_HOST -#define IN_CLASSC_MAX IP_CLASSC_MAX - -#define IN_CLASSD(d) IP_CLASSD(d) -#define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ -#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ -#define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ -#define IN_CLASSD_MAX IP_CLASSD_MAX - -#define IN_MULTICAST(a) IP_MULTICAST(a) - -#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) -#define IN_BADCLASS(a) IP_BADCLASS(a) - -#define IN_LOOPBACKNET IP_LOOPBACKNET - -#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) -#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) -/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */ -#define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr)) - -/* directly map this to the lwip internal functions */ -#define inet_addr(cp) ipaddr_addr(cp) -#define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr) -#define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr)) -#define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen) - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INET_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h deleted file mode 100644 index 79a2d90..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/inet_chksum.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INET_CHKSUM_H__ -#define __LWIP_INET_CHKSUM_H__ - -#include "lwip/opt.h" - -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" - -/** Swap the bytes in an u16_t: much like htons() for little-endian */ -#ifndef SWAP_BYTES_IN_WORD -#if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) -/* little endian and PLATFORM_BYTESWAP defined */ -#define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) -#else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ -/* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ -#define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) -#endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ -#endif /* SWAP_BYTES_IN_WORD */ - -/** Split an u32_t in two u16_ts and add them up */ -#ifndef FOLD_U32T -#define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) -#endif - -#if LWIP_CHECKSUM_ON_COPY -/** Function-like macro: same as MEMCPY but returns the checksum of copied data - as u16_t */ -#ifndef LWIP_CHKSUM_COPY -#define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) -#ifndef LWIP_CHKSUM_COPY_ALGORITHM -#define LWIP_CHKSUM_COPY_ALGORITHM 1 -#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ -#endif /* LWIP_CHKSUM_COPY */ -#else /* LWIP_CHECKSUM_ON_COPY */ -#define LWIP_CHKSUM_COPY_ALGORITHM 0 -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#ifdef __cplusplus -extern "C" { -#endif - -u16_t inet_chksum(void *dataptr, u16_t len); -u16_t inet_chksum_pbuf(struct pbuf *p); -u16_t inet_chksum_pseudo(struct pbuf *p, - ip_addr_t *src, ip_addr_t *dest, - u8_t proto, u16_t proto_len); -u16_t inet_chksum_pseudo_partial(struct pbuf *p, - ip_addr_t *src, ip_addr_t *dest, - u8_t proto, u16_t proto_len, u16_t chksum_len); -#if LWIP_CHKSUM_COPY_ALGORITHM -u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); -#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INET_H__ */ - diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h deleted file mode 100644 index 00c83a0..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP_H__ -#define __LWIP_IP_H__ - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/err.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Currently, the function ip_output_if_opt() is only used with IGMP */ -#define IP_OPTIONS_SEND LWIP_IGMP - -#define IP_HLEN 20 - -#define IP_PROTO_ICMP 1 -#define IP_PROTO_IGMP 2 -#define IP_PROTO_UDP 17 -#define IP_PROTO_UDPLITE 136 -#define IP_PROTO_TCP 6 - -/* This is passed as the destination address to ip_output_if (not - to ip_output), meaning that an IP header already is constructed - in the pbuf. This is used when TCP retransmits. */ -#ifdef IP_HDRINCL -#undef IP_HDRINCL -#endif /* IP_HDRINCL */ -#define IP_HDRINCL NULL - -#if LWIP_NETIF_HWADDRHINT -#define IP_PCB_ADDRHINT ;u8_t addr_hint -#else -#define IP_PCB_ADDRHINT -#endif /* LWIP_NETIF_HWADDRHINT */ - -/* This is the common part of all PCB types. It needs to be at the - beginning of a PCB type definition. It is located here so that - changes to this common part are made in one location instead of - having to change all PCB structs. */ -#define IP_PCB \ - /* ip addresses in network byte order */ \ - ip_addr_t local_ip; \ - ip_addr_t remote_ip; \ - /* Socket options */ \ - u8_t so_options; \ - /* Type Of Service */ \ - u8_t tos; \ - /* Time To Live */ \ - u8_t ttl \ - /* link layer address resolution hint */ \ - IP_PCB_ADDRHINT - -struct ip_pcb { -/* Common members of all PCB types */ - IP_PCB; -}; - -/* - * Option flags per-socket. These are the same like SO_XXX. - */ -/*#define SOF_DEBUG 0x01U Unimplemented: turn on debugging info recording */ -#define SOF_ACCEPTCONN 0x02U /* socket has had listen() */ -#define SOF_REUSEADDR 0x04U /* allow local address reuse */ -#define SOF_KEEPALIVE 0x08U /* keep connections alive */ -/*#define SOF_DONTROUTE 0x10U Unimplemented: just use interface addresses */ -#define SOF_BROADCAST 0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ -/*#define SOF_USELOOPBACK 0x40U Unimplemented: bypass hardware when possible */ -#define SOF_LINGER 0x80U /* linger on close if data present */ -/*#define SOF_OOBINLINE 0x0100U Unimplemented: leave received OOB data in line */ -/*#define SOF_REUSEPORT 0x0200U Unimplemented: allow local address & port reuse */ - -/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */ -#define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/) - - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_hdr { - /* version / header length */ - PACK_STRUCT_FIELD(u8_t _v_hl); - /* type of service */ - PACK_STRUCT_FIELD(u8_t _tos); - /* total length */ - PACK_STRUCT_FIELD(u16_t _len); - /* identification */ - PACK_STRUCT_FIELD(u16_t _id); - /* fragment offset field */ - PACK_STRUCT_FIELD(u16_t _offset); -#define IP_RF 0x8000U /* reserved fragment flag */ -#define IP_DF 0x4000U /* dont fragment flag */ -#define IP_MF 0x2000U /* more fragments flag */ -#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */ - /* time to live */ - PACK_STRUCT_FIELD(u8_t _ttl); - /* protocol*/ - PACK_STRUCT_FIELD(u8_t _proto); - /* checksum */ - PACK_STRUCT_FIELD(u16_t _chksum); - /* source and destination IP addresses */ - PACK_STRUCT_FIELD(ip_addr_p_t src); - PACK_STRUCT_FIELD(ip_addr_p_t dest); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IPH_V(hdr) ((hdr)->_v_hl >> 4) -#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f) -#define IPH_TOS(hdr) ((hdr)->_tos) -#define IPH_LEN(hdr) ((hdr)->_len) -#define IPH_ID(hdr) ((hdr)->_id) -#define IPH_OFFSET(hdr) ((hdr)->_offset) -#define IPH_TTL(hdr) ((hdr)->_ttl) -#define IPH_PROTO(hdr) ((hdr)->_proto) -#define IPH_CHKSUM(hdr) ((hdr)->_chksum) - -#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (((v) << 4) | (hl)) -#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos) -#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len) -#define IPH_ID_SET(hdr, id) (hdr)->_id = (id) -#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off) -#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl) -#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) -#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) - -/** The interface that provided the packet for the current callback invocation. */ -extern struct netif *current_netif; -/** Header of the input packet currently being processed. */ -extern const struct ip_hdr *current_header; -/** Source IP address of current_header */ -extern ip_addr_t current_iphdr_src; -/** Destination IP address of current_header */ -extern ip_addr_t current_iphdr_dest; - -#define ip_init() /* Compatibility define, not init needed. */ -struct netif *ip_route(ip_addr_t *dest); -err_t ip_input(struct pbuf *p, struct netif *inp); -err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto); -err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, - struct netif *netif); -#if LWIP_NETIF_HWADDRHINT -err_t ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint); -#endif /* LWIP_NETIF_HWADDRHINT */ -#if IP_OPTIONS_SEND -err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, - u16_t optlen); -#endif /* IP_OPTIONS_SEND */ -/** Get the interface that received the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip_current_netif() (current_netif) -/** Get the IP header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip_current_header() (current_header) -/** Source IP address of current_header */ -#define ip_current_src_addr() (¤t_iphdr_src) -/** Destination IP address of current_header */ -#define ip_current_dest_addr() (¤t_iphdr_dest) - -/** Gets an IP pcb option (SOF_* flags) */ -#define ip_get_option(pcb, opt) ((pcb)->so_options & (opt)) -/** Sets an IP pcb option (SOF_* flags) */ -#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) -/** Resets an IP pcb option (SOF_* flags) */ -#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt)) - -#if IP_DEBUG -void ip_debug_print(struct pbuf *p); -#else -#define ip_debug_print(p) -#endif /* IP_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_H__ */ - - diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h deleted file mode 100644 index 77f84e0..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_addr.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP_ADDR_H__ -#define __LWIP_IP_ADDR_H__ - -#include "lwip/opt.h" -#include "lwip/def.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* This is the aligned version of ip_addr_t, - used as local variable, on the stack, etc. */ -struct ip_addr { - u32_t addr; -}; - -/* This is the packed version of ip_addr_t, - used in network headers that are itself packed */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_addr_packed { - PACK_STRUCT_FIELD(u32_t addr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** ip_addr_t uses a struct for convenience only, so that the same defines can - * operate both on ip_addr_t as well as on ip_addr_p_t. */ -typedef struct ip_addr ip_addr_t; -typedef struct ip_addr_packed ip_addr_p_t; - -/* - * struct ipaddr2 is used in the definition of the ARP packet format in - * order to support compilers that don't have structure packing. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_addr2 { - PACK_STRUCT_FIELD(u16_t addrw[2]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Forward declaration to not include netif.h */ -struct netif; - -extern const ip_addr_t ip_addr_any; -extern const ip_addr_t ip_addr_broadcast; - -/** IP_ADDR_ can be used as a fixed IP address - * for the wildcard and the broadcast address - */ -#define IP_ADDR_ANY ((ip_addr_t *)&ip_addr_any) -#define IP_ADDR_BROADCAST ((ip_addr_t *)&ip_addr_broadcast) - -/** 255.255.255.255 */ -#define IPADDR_NONE ((u32_t)0xffffffffUL) -/** 127.0.0.1 */ -#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) -/** 0.0.0.0 */ -#define IPADDR_ANY ((u32_t)0x00000000UL) -/** 255.255.255.255 */ -#define IPADDR_BROADCAST ((u32_t)0xffffffffUL) - -/* Definitions of the bits in an Internet address integer. - - On subnets, host and network parts are found according to - the subnet mask, not these masks. */ -#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) -#define IP_CLASSA_NET 0xff000000 -#define IP_CLASSA_NSHIFT 24 -#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) -#define IP_CLASSA_MAX 128 - -#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) -#define IP_CLASSB_NET 0xffff0000 -#define IP_CLASSB_NSHIFT 16 -#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET) -#define IP_CLASSB_MAX 65536 - -#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) -#define IP_CLASSC_NET 0xffffff00 -#define IP_CLASSC_NSHIFT 8 -#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET) - -#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) -#define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */ -#define IP_CLASSD_NSHIFT 28 /* net and host fields, but */ -#define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */ -#define IP_MULTICAST(a) IP_CLASSD(a) - -#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) -#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) - -#define IP_LOOPBACKNET 127 /* official! */ - - -#if BYTE_ORDER == BIG_ENDIAN -/** Set an IP address given by the four byte-parts */ -#define IP4_ADDR(ipaddr, a,b,c,d) \ - (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \ - ((u32_t)((b) & 0xff) << 16) | \ - ((u32_t)((c) & 0xff) << 8) | \ - (u32_t)((d) & 0xff) -#else -/** Set an IP address given by the four byte-parts. - Little-endian version that prevents the use of htonl. */ -#define IP4_ADDR(ipaddr, a,b,c,d) \ - (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \ - ((u32_t)((c) & 0xff) << 16) | \ - ((u32_t)((b) & 0xff) << 8) | \ - (u32_t)((a) & 0xff) -#endif - -/** MEMCPY-like copying of IP addresses where addresses are known to be - * 16-bit-aligned if the port is correctly configured (so a port could define - * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ -#ifndef IPADDR2_COPY -#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t)) -#endif - -/** Copy IP address - faster than ip_addr_set: no NULL check */ -#define ip_addr_copy(dest, src) ((dest).addr = (src).addr) -/** Safely copy one IP address to another (src may be NULL) */ -#define ip_addr_set(dest, src) ((dest)->addr = \ - ((src) == NULL ? 0 : \ - (src)->addr)) -/** Set complete address to zero */ -#define ip_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) -/** Set address to IPADDR_ANY (no need for htonl()) */ -#define ip_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) -/** Set address to loopback address */ -#define ip_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) -/** Safely copy one IP address to another and change byte order - * from host- to network-order. */ -#define ip_addr_set_hton(dest, src) ((dest)->addr = \ - ((src) == NULL ? 0:\ - htonl((src)->addr))) -/** IPv4 only: set the IP address given as an u32_t */ -#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) -/** IPv4 only: get the IP address as an u32_t */ -#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) - -/** Get the network address by combining host address with netmask */ -#define ip_addr_get_network(target, host, netmask) ((target)->addr = ((host)->addr) & ((netmask)->addr)) - -/** - * Determine if two address are on the same network. - * - * @arg addr1 IP address 1 - * @arg addr2 IP address 2 - * @arg mask network identifier mask - * @return !0 if the network identifiers of both address match - */ -#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ - (mask)->addr) == \ - ((addr2)->addr & \ - (mask)->addr)) -#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) - -#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY) - -#define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif)) -u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif); - -#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr) -u8_t ip4_addr_netmask_valid(u32_t netmask); - -#define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL)) - -#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) - -#define ip_addr_debug_print(debug, ipaddr) \ - LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ - ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \ - ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \ - ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \ - ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0)) - -/* Get one byte from the 4-byte address */ -#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0]) -#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1]) -#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2]) -#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3]) -/* These are cast to u16_t, with the intent that they are often arguments - * to printf using the U16_F format from cc.h. */ -#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) -#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) -#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) -#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) - -/** For backwards compatibility */ -#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) - -u32_t ipaddr_addr(const char *cp); -int ipaddr_aton(const char *cp, ip_addr_t *addr); -/** returns ptr to static buffer; not reentrant! */ -char *ipaddr_ntoa(const ip_addr_t *addr); -char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_ADDR_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h b/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h deleted file mode 100644 index 77b5eb1..0000000 --- a/user/mpy/lib/lwip/src/include/ipv4/lwip/ip_frag.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Jani Monoses - * - */ - -#ifndef __LWIP_IP_FRAG_H__ -#define __LWIP_IP_FRAG_H__ - -#include "lwip/opt.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/ip_addr.h" -#include "lwip/ip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if IP_REASSEMBLY -/* The IP reassembly timer interval in milliseconds. */ -#define IP_TMR_INTERVAL 1000 - -/* IP reassembly helper struct. - * This is exported because memp needs to know the size. - */ -struct ip_reassdata { - struct ip_reassdata *next; - struct pbuf *p; - struct ip_hdr iphdr; - u16_t datagram_len; - u8_t flags; - u8_t timer; -}; - -void ip_reass_init(void); -void ip_reass_tmr(void); -struct pbuf * ip_reass(struct pbuf *p); -#endif /* IP_REASSEMBLY */ - -#if IP_FRAG -#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF -/** A custom pbuf that holds a reference to another pbuf, which is freed - * when this custom pbuf is freed. This is used to create a custom PBUF_REF - * that points into the original pbuf. */ -struct pbuf_custom_ref { - /** 'base class' */ - struct pbuf_custom pc; - /** pointer to the original pbuf that is referenced */ - struct pbuf *original; -}; -#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ - -err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest); -#endif /* IP_FRAG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_FRAG_H__ */ diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h deleted file mode 100644 index 87e9ffd..0000000 --- a/user/mpy/lib/lwip/src/include/ipv6/lwip/icmp.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ICMP_H__ -#define __LWIP_ICMP_H__ - -#include "lwip/opt.h" - -#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ICMP6_DUR 1 -#define ICMP6_TE 3 -#define ICMP6_ECHO 128 /* echo */ -#define ICMP6_ER 129 /* echo reply */ - - -enum icmp_dur_type { - ICMP_DUR_NET = 0, /* net unreachable */ - ICMP_DUR_HOST = 1, /* host unreachable */ - ICMP_DUR_PROTO = 2, /* protocol unreachable */ - ICMP_DUR_PORT = 3, /* port unreachable */ - ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ - ICMP_DUR_SR = 5 /* source route failed */ -}; - -enum icmp_te_type { - ICMP_TE_TTL = 0, /* time to live exceeded in transit */ - ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ -}; - -void icmp_input(struct pbuf *p, struct netif *inp); - -void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); -void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); - -struct icmp_echo_hdr { - u8_t type; - u8_t icode; - u16_t chksum; - u16_t id; - u16_t seqno; -}; - -struct icmp_dur_hdr { - u8_t type; - u8_t icode; - u16_t chksum; - u32_t unused; -}; - -struct icmp_te_hdr { - u8_t type; - u8_t icode; - u16_t chksum; - u32_t unused; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_ICMP */ - -#endif /* __LWIP_ICMP_H__ */ - diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h deleted file mode 100644 index de1a0b6..0000000 --- a/user/mpy/lib/lwip/src/include/ipv6/lwip/inet.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INET_H__ -#define __LWIP_INET_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -u16_t inet_chksum(void *data, u16_t len); -u16_t inet_chksum_pbuf(struct pbuf *p); -u16_t inet_chksum_pseudo(struct pbuf *p, - struct ip_addr *src, struct ip_addr *dest, - u8_t proto, u32_t proto_len); - -u32_t inet_addr(const char *cp); -s8_t inet_aton(const char *cp, struct in_addr *addr); - -#ifndef _MACHINE_ENDIAN_H_ -#ifndef _NETINET_IN_H -#ifndef _LINUX_BYTEORDER_GENERIC_H -u16_t htons(u16_t n); -u16_t ntohs(u16_t n); -u32_t htonl(u32_t n); -u32_t ntohl(u32_t n); -#endif /* _LINUX_BYTEORDER_GENERIC_H */ -#endif /* _NETINET_IN_H */ -#endif /* _MACHINE_ENDIAN_H_ */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INET_H__ */ - diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h deleted file mode 100644 index a01cfc6..0000000 --- a/user/mpy/lib/lwip/src/include/ipv6/lwip/ip.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP_H__ -#define __LWIP_IP_H__ - -#include "lwip/opt.h" -#include "lwip/def.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" - -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define IP_HLEN 40 - -#define IP_PROTO_ICMP 58 -#define IP_PROTO_UDP 17 -#define IP_PROTO_UDPLITE 136 -#define IP_PROTO_TCP 6 - -/* This is passed as the destination address to ip_output_if (not - to ip_output), meaning that an IP header already is constructed - in the pbuf. This is used when TCP retransmits. */ -#ifdef IP_HDRINCL -#undef IP_HDRINCL -#endif /* IP_HDRINCL */ -#define IP_HDRINCL NULL - -#if LWIP_NETIF_HWADDRHINT -#define IP_PCB_ADDRHINT ;u8_t addr_hint -#else -#define IP_PCB_ADDRHINT -#endif /* LWIP_NETIF_HWADDRHINT */ - -/* This is the common part of all PCB types. It needs to be at the - beginning of a PCB type definition. It is located here so that - changes to this common part are made in one location instead of - having to change all PCB structs. */ -#define IP_PCB struct ip_addr local_ip; \ - struct ip_addr remote_ip; \ - /* Socket options */ \ - u16_t so_options; \ - /* Type Of Service */ \ - u8_t tos; \ - /* Time To Live */ \ - u8_t ttl; \ - /* link layer address resolution hint */ \ - IP_PCB_ADDRHINT - - -/* The IPv6 header. */ -struct ip_hdr { -#if BYTE_ORDER == LITTLE_ENDIAN - u8_t tclass1:4, v:4; - u8_t flow1:4, tclass2:4; -#else - u8_t v:4, tclass1:4; - u8_t tclass2:8, flow1:4; -#endif - u16_t flow2; - u16_t len; /* payload length */ - u8_t nexthdr; /* next header */ - u8_t hoplim; /* hop limit (TTL) */ - struct ip_addr src, dest; /* source and destination IP addresses */ -}; - -#define IPH_PROTO(hdr) (iphdr->nexthdr) - -void ip_init(void); - -#include "lwip/netif.h" - -struct netif *ip_route(struct ip_addr *dest); - -void ip_input(struct pbuf *p, struct netif *inp); - -/* source and destination addresses in network byte order, please */ -err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - u8_t ttl, u8_t proto); - -err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - u8_t ttl, u8_t proto, - struct netif *netif); - -#define ip_current_netif() NULL -#define ip_current_header() NULL - -#if IP_DEBUG -void ip_debug_print(struct pbuf *p); -#endif /* IP_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_H__ */ - - diff --git a/user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h b/user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h deleted file mode 100644 index b2d8ae5..0000000 --- a/user/mpy/lib/lwip/src/include/ipv6/lwip/ip_addr.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP_ADDR_H__ -#define __LWIP_IP_ADDR_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define IP_ADDR_ANY 0 - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN - struct ip_addr { - PACK_STRUCT_FIELD(u32_t addr[4]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* - * struct ipaddr2 is used in the definition of the ARP packet format in - * order to support compilers that don't have structure packing. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_addr2 { - PACK_STRUCT_FIELD(u16_t addrw[2]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)((a & 0xffff) << 16) | (b & 0xffff)); \ - (ipaddr)->addr[1] = htonl(((c & 0xffff) << 16) | (d & 0xffff)); \ - (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \ - (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0) - -u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, - struct ip_addr *mask); -u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); -void ip_addr_set(struct ip_addr *dest, struct ip_addr *src); -u8_t ip_addr_isany(struct ip_addr *addr); - -#define ip_addr_debug_print(debug, ipaddr) \ - LWIP_DEBUGF(debug, ("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F"\n", \ - (ntohl(ipaddr->addr[0]) >> 16) & 0xffff, \ - ntohl(ipaddr->addr[0]) & 0xffff, \ - (ntohl(ipaddr->addr[1]) >> 16) & 0xffff, \ - ntohl(ipaddr->addr[1]) & 0xffff, \ - (ntohl(ipaddr->addr[2]) >> 16) & 0xffff, \ - ntohl(ipaddr->addr[2]) & 0xffff, \ - (ntohl(ipaddr->addr[3]) >> 16) & 0xffff, \ - ntohl(ipaddr->addr[3]) & 0xffff)); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_ADDR_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/api.h b/user/mpy/lib/lwip/src/include/lwip/api.h deleted file mode 100644 index 7a9fa93..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/api.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_API_H__ -#define __LWIP_API_H__ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include /* for size_t */ - -#include "lwip/netbuf.h" -#include "lwip/sys.h" -#include "lwip/ip_addr.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Throughout this file, IP addresses and port numbers are expected to be in - * the same byte order as in the corresponding pcb. - */ - -/* Flags for netconn_write (u8_t) */ -#define NETCONN_NOFLAG 0x00 -#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */ -#define NETCONN_COPY 0x01 -#define NETCONN_MORE 0x02 -#define NETCONN_DONTBLOCK 0x04 - -/* Flags for struct netconn.flags (u8_t) */ -/** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores whether to wake up the original application task - if data couldn't be sent in the first try. */ -#define NETCONN_FLAG_WRITE_DELAYED 0x01 -/** Should this netconn avoid blocking? */ -#define NETCONN_FLAG_NON_BLOCKING 0x02 -/** Was the last connect action a non-blocking one? */ -#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 -/** If this is set, a TCP netconn must call netconn_recved() to update - the TCP receive window (done automatically if not set). */ -#define NETCONN_FLAG_NO_AUTO_RECVED 0x08 -/** If a nonblocking write has been rejected before, poll_tcp needs to - check if the netconn is writable again */ -#define NETCONN_FLAG_CHECK_WRITESPACE 0x10 - - -/* Helpers to process several netconn_types by the same code */ -#define NETCONNTYPE_GROUP(t) (t&0xF0) -#define NETCONNTYPE_DATAGRAM(t) (t&0xE0) - -/** Protocol family and type of the netconn */ -enum netconn_type { - NETCONN_INVALID = 0, - /* NETCONN_TCP Group */ - NETCONN_TCP = 0x10, - /* NETCONN_UDP Group */ - NETCONN_UDP = 0x20, - NETCONN_UDPLITE = 0x21, - NETCONN_UDPNOCHKSUM= 0x22, - /* NETCONN_RAW Group */ - NETCONN_RAW = 0x40 -}; - -/** Current state of the netconn. Non-TCP netconns are always - * in state NETCONN_NONE! */ -enum netconn_state { - NETCONN_NONE, - NETCONN_WRITE, - NETCONN_LISTEN, - NETCONN_CONNECT, - NETCONN_CLOSE -}; - -/** Use to inform the callback function about changes */ -enum netconn_evt { - NETCONN_EVT_RCVPLUS, - NETCONN_EVT_RCVMINUS, - NETCONN_EVT_SENDPLUS, - NETCONN_EVT_SENDMINUS, - NETCONN_EVT_ERROR -}; - -#if LWIP_IGMP -/** Used for netconn_join_leave_group() */ -enum netconn_igmp { - NETCONN_JOIN, - NETCONN_LEAVE -}; -#endif /* LWIP_IGMP */ - -/* forward-declare some structs to avoid to include their headers */ -struct ip_pcb; -struct tcp_pcb; -struct udp_pcb; -struct raw_pcb; -struct netconn; -struct api_msg_msg; - -/** A callback prototype to inform about events for a netconn */ -typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len); - -/** A netconn descriptor */ -struct netconn { - /** type of the netconn (TCP, UDP or RAW) */ - enum netconn_type type; - /** current state of the netconn */ - enum netconn_state state; - /** the lwIP internal protocol control block */ - union { - struct ip_pcb *ip; - struct tcp_pcb *tcp; - struct udp_pcb *udp; - struct raw_pcb *raw; - } pcb; - /** the last error this netconn had */ - err_t last_err; - /** sem that is used to synchroneously execute functions in the core context */ - sys_sem_t op_completed; - /** mbox where received packets are stored until they are fetched - by the netconn application thread (can grow quite big) */ - sys_mbox_t recvmbox; -#if LWIP_TCP - /** mbox where new connections are stored until processed - by the application thread */ - sys_mbox_t acceptmbox; -#endif /* LWIP_TCP */ - /** only used for socket layer */ -#if LWIP_SOCKET - int socket; -#endif /* LWIP_SOCKET */ -#if LWIP_SO_SNDTIMEO - /** timeout to wait for sending data (which means enqueueing data for sending - in internal buffers) */ - s32_t send_timeout; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVTIMEO - /** timeout to wait for new data to be received - (or connections to arrive for listening netconns) */ - int recv_timeout; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - /** maximum amount of bytes queued in recvmbox - not used for TCP: adjust TCP_WND instead! */ - int recv_bufsize; - /** number of bytes currently in recvmbox to be received, - tested against recv_bufsize to limit bytes on recvmbox - for UDP and RAW, used for FIONREAD */ - s16_t recv_avail; -#endif /* LWIP_SO_RCVBUF */ - /** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */ - u8_t flags; -#if LWIP_TCP - /** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores how much is already sent. */ - size_t write_offset; - /** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores the message. - Also used during connect and close. */ - struct api_msg_msg *current_msg; -#endif /* LWIP_TCP */ - /** A callback function that is informed about events for this netconn */ - netconn_callback callback; -}; - -/** Register an Network connection event */ -#define API_EVENT(c,e,l) if (c->callback) { \ - (*c->callback)(c, e, l); \ - } - -/** Set conn->last_err to err but don't overwrite fatal errors */ -#define NETCONN_SET_SAFE_ERR(conn, err) do { \ - SYS_ARCH_DECL_PROTECT(lev); \ - SYS_ARCH_PROTECT(lev); \ - if (!ERR_IS_FATAL((conn)->last_err)) { \ - (conn)->last_err = err; \ - } \ - SYS_ARCH_UNPROTECT(lev); \ -} while(0); - -/* Network connection functions: */ -#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) -#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) -struct -netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, - netconn_callback callback); -err_t netconn_delete(struct netconn *conn); -/** Get the type of a netconn (as enum netconn_type). */ -#define netconn_type(conn) (conn->type) - -err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, - u16_t *port, u8_t local); -#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) -#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) - -err_t netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port); -err_t netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port); -err_t netconn_disconnect (struct netconn *conn); -err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); -#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) -err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); -err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); -err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); -void netconn_recved(struct netconn *conn, u32_t length); -err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, - ip_addr_t *addr, u16_t port); -err_t netconn_send(struct netconn *conn, struct netbuf *buf); -err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, - u8_t apiflags, size_t *bytes_written); -#define netconn_write(conn, dataptr, size, apiflags) \ - netconn_write_partly(conn, dataptr, size, apiflags, NULL) -err_t netconn_close(struct netconn *conn); -err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); - -#if LWIP_IGMP -err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr, - ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); -#endif /* LWIP_IGMP */ -#if LWIP_DNS -err_t netconn_gethostbyname(const char *name, ip_addr_t *addr); -#endif /* LWIP_DNS */ - -#define netconn_err(conn) ((conn)->last_err) -#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) - -/** Set the blocking status of netconn calls (@todo: write/send is missing) */ -#define netconn_set_nonblocking(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) -/** Get the blocking status of netconn calls (@todo: write/send is missing) */ -#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) - -/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */ -#define netconn_set_noautorecved(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0) -/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */ -#define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0) - -#if LWIP_SO_SNDTIMEO -/** Set the send timeout in milliseconds */ -#define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) -/** Get the send timeout in milliseconds */ -#define netconn_get_sendtimeout(conn) ((conn)->send_timeout) -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO -/** Set the receive timeout in milliseconds */ -#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) -/** Get the receive timeout in milliseconds */ -#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF -/** Set the receive buffer in bytes */ -#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) -/** Get the receive buffer in bytes */ -#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) -#endif /* LWIP_SO_RCVBUF*/ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN */ - -#endif /* __LWIP_API_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/api_msg.h b/user/mpy/lib/lwip/src/include/lwip/api_msg.h deleted file mode 100644 index f9e1c7d..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/api_msg.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_API_MSG_H__ -#define __LWIP_API_MSG_H__ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include /* for size_t */ - -#include "lwip/ip_addr.h" -#include "lwip/err.h" -#include "lwip/sys.h" -#include "lwip/igmp.h" -#include "lwip/api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* For the netconn API, these values are use as a bitmask! */ -#define NETCONN_SHUT_RD 1 -#define NETCONN_SHUT_WR 2 -#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) - -/* IP addresses and port numbers are expected to be in - * the same byte order as in the corresponding pcb. - */ -/** This struct includes everything that is necessary to execute a function - for a netconn in another thread context (mainly used to process netconns - in the tcpip_thread context to be thread safe). */ -struct api_msg_msg { - /** The netconn which to process - always needed: it includes the semaphore - which is used to block the application thread until the function finished. */ - struct netconn *conn; - /** The return value of the function executed in tcpip_thread. */ - err_t err; - /** Depending on the executed function, one of these union members is used */ - union { - /** used for do_send */ - struct netbuf *b; - /** used for do_newconn */ - struct { - u8_t proto; - } n; - /** used for do_bind and do_connect */ - struct { - ip_addr_t *ipaddr; - u16_t port; - } bc; - /** used for do_getaddr */ - struct { - ip_addr_t *ipaddr; - u16_t *port; - u8_t local; - } ad; - /** used for do_write */ - struct { - const void *dataptr; - size_t len; - u8_t apiflags; -#if LWIP_SO_SNDTIMEO - u32_t time_started; -#endif /* LWIP_SO_SNDTIMEO */ - } w; - /** used for do_recv */ - struct { - u32_t len; - } r; - /** used for do_close (/shutdown) */ - struct { - u8_t shut; - } sd; -#if LWIP_IGMP - /** used for do_join_leave_group */ - struct { - ip_addr_t *multiaddr; - ip_addr_t *netif_addr; - enum netconn_igmp join_or_leave; - } jl; -#endif /* LWIP_IGMP */ -#if TCP_LISTEN_BACKLOG - struct { - u8_t backlog; - } lb; -#endif /* TCP_LISTEN_BACKLOG */ - } msg; -}; - -/** This struct contains a function to execute in another thread context and - a struct api_msg_msg that serves as an argument for this function. - This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ -struct api_msg { - /** function to execute in tcpip_thread context */ - void (* function)(struct api_msg_msg *msg); - /** arguments for this function */ - struct api_msg_msg msg; -}; - -#if LWIP_DNS -/** As do_gethostbyname requires more arguments but doesn't require a netconn, - it has its own struct (to avoid struct api_msg getting bigger than necessary). - do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg - (see netconn_gethostbyname). */ -struct dns_api_msg { - /** Hostname to query or dotted IP address string */ - const char *name; - /** Rhe resolved address is stored here */ - ip_addr_t *addr; - /** This semaphore is posted when the name is resolved, the application thread - should wait on it. */ - sys_sem_t *sem; - /** Errors are given back here */ - err_t *err; -}; -#endif /* LWIP_DNS */ - -void do_newconn ( struct api_msg_msg *msg); -void do_delconn ( struct api_msg_msg *msg); -void do_bind ( struct api_msg_msg *msg); -void do_connect ( struct api_msg_msg *msg); -void do_disconnect ( struct api_msg_msg *msg); -void do_listen ( struct api_msg_msg *msg); -void do_send ( struct api_msg_msg *msg); -void do_recv ( struct api_msg_msg *msg); -void do_write ( struct api_msg_msg *msg); -void do_getaddr ( struct api_msg_msg *msg); -void do_close ( struct api_msg_msg *msg); -void do_shutdown ( struct api_msg_msg *msg); -#if LWIP_IGMP -void do_join_leave_group( struct api_msg_msg *msg); -#endif /* LWIP_IGMP */ - -#if LWIP_DNS -void do_gethostbyname(void *arg); -#endif /* LWIP_DNS */ - -struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); -void netconn_free(struct netconn *conn); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN */ - -#endif /* __LWIP_API_MSG_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/arch.h b/user/mpy/lib/lwip/src/include/lwip/arch.h deleted file mode 100644 index 4d6df77..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/arch.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ARCH_H__ -#define __LWIP_ARCH_H__ - -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif - -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif - -#include "arch/cc.h" - -/** Temporary: define format string for size_t if not defined in cc.h */ -#ifndef SZT_F -#define SZT_F U32_F -#endif /* SZT_F */ -/** Temporary upgrade helper: define format string for u8_t as hex if not - defined in cc.h */ -#ifndef X8_F -#define X8_F "02x" -#endif /* X8_F */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef PACK_STRUCT_BEGIN -#define PACK_STRUCT_BEGIN -#endif /* PACK_STRUCT_BEGIN */ - -#ifndef PACK_STRUCT_END -#define PACK_STRUCT_END -#endif /* PACK_STRUCT_END */ - -#ifndef PACK_STRUCT_FIELD -#define PACK_STRUCT_FIELD(x) x -#endif /* PACK_STRUCT_FIELD */ - - -#ifndef LWIP_UNUSED_ARG -#define LWIP_UNUSED_ARG(x) (void)x -#endif /* LWIP_UNUSED_ARG */ - - -#ifdef LWIP_PROVIDE_ERRNO - -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No child processes */ -#define EAGAIN 11 /* Try again */ -#define ENOMEM 12 /* Out of memory */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device or resource busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math argument out of domain of func */ -#define ERANGE 34 /* Math result not representable */ -#define EDEADLK 35 /* Resource deadlock would occur */ -#define ENAMETOOLONG 36 /* File name too long */ -#define ENOLCK 37 /* No record locks available */ -#define ENOSYS 38 /* Function not implemented */ -#define ENOTEMPTY 39 /* Directory not empty */ -#define ELOOP 40 /* Too many symbolic links encountered */ -#define EWOULDBLOCK EAGAIN /* Operation would block */ -#define ENOMSG 42 /* No message of desired type */ -#define EIDRM 43 /* Identifier removed */ -#define ECHRNG 44 /* Channel number out of range */ -#define EL2NSYNC 45 /* Level 2 not synchronized */ -#define EL3HLT 46 /* Level 3 halted */ -#define EL3RST 47 /* Level 3 reset */ -#define ELNRNG 48 /* Link number out of range */ -#define EUNATCH 49 /* Protocol driver not attached */ -#define ENOCSI 50 /* No CSI structure available */ -#define EL2HLT 51 /* Level 2 halted */ -#define EBADE 52 /* Invalid exchange */ -#define EBADR 53 /* Invalid request descriptor */ -#define EXFULL 54 /* Exchange full */ -#define ENOANO 55 /* No anode */ -#define EBADRQC 56 /* Invalid request code */ -#define EBADSLT 57 /* Invalid slot */ - -#define EDEADLOCK EDEADLK - -#define EBFONT 59 /* Bad font file format */ -#define ENOSTR 60 /* Device not a stream */ -#define ENODATA 61 /* No data available */ -#define ETIME 62 /* Timer expired */ -#define ENOSR 63 /* Out of streams resources */ -#define ENONET 64 /* Machine is not on the network */ -#define ENOPKG 65 /* Package not installed */ -#define EREMOTE 66 /* Object is remote */ -#define ENOLINK 67 /* Link has been severed */ -#define EADV 68 /* Advertise error */ -#define ESRMNT 69 /* Srmount error */ -#define ECOMM 70 /* Communication error on send */ -#define EPROTO 71 /* Protocol error */ -#define EMULTIHOP 72 /* Multihop attempted */ -#define EDOTDOT 73 /* RFS specific error */ -#define EBADMSG 74 /* Not a data message */ -#define EOVERFLOW 75 /* Value too large for defined data type */ -#define ENOTUNIQ 76 /* Name not unique on network */ -#define EBADFD 77 /* File descriptor in bad state */ -#define EREMCHG 78 /* Remote address changed */ -#define ELIBACC 79 /* Can not access a needed shared library */ -#define ELIBBAD 80 /* Accessing a corrupted shared library */ -#define ELIBSCN 81 /* .lib section in a.out corrupted */ -#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ -#define ELIBEXEC 83 /* Cannot exec a shared library directly */ -#define EILSEQ 84 /* Illegal byte sequence */ -#define ERESTART 85 /* Interrupted system call should be restarted */ -#define ESTRPIPE 86 /* Streams pipe error */ -#define EUSERS 87 /* Too many users */ -#define ENOTSOCK 88 /* Socket operation on non-socket */ -#define EDESTADDRREQ 89 /* Destination address required */ -#define EMSGSIZE 90 /* Message too long */ -#define EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 92 /* Protocol not available */ -#define EPROTONOSUPPORT 93 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define EADDRINUSE 98 /* Address already in use */ -#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define ENETDOWN 100 /* Network is down */ -#define ENETUNREACH 101 /* Network is unreachable */ -#define ENETRESET 102 /* Network dropped connection because of reset */ -#define ECONNABORTED 103 /* Software caused connection abort */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EISCONN 106 /* Transport endpoint is already connected */ -#define ENOTCONN 107 /* Transport endpoint is not connected */ -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define ETIMEDOUT 110 /* Connection timed out */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EHOSTDOWN 112 /* Host is down */ -#define EHOSTUNREACH 113 /* No route to host */ -#define EALREADY 114 /* Operation already in progress */ -#define EINPROGRESS 115 /* Operation now in progress */ -#define ESTALE 116 /* Stale NFS file handle */ -#define EUCLEAN 117 /* Structure needs cleaning */ -#define ENOTNAM 118 /* Not a XENIX named type file */ -#define ENAVAIL 119 /* No XENIX semaphores available */ -#define EISNAM 120 /* Is a named type file */ -#define EREMOTEIO 121 /* Remote I/O error */ -#define EDQUOT 122 /* Quota exceeded */ - -#define ENOMEDIUM 123 /* No medium found */ -#define EMEDIUMTYPE 124 /* Wrong medium type */ - -#ifndef errno -extern int errno; -#endif - -#endif /* LWIP_PROVIDE_ERRNO */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_ARCH_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/debug.h b/user/mpy/lib/lwip/src/include/lwip/debug.h deleted file mode 100644 index 0fe0413..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/debug.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_DEBUG_H__ -#define __LWIP_DEBUG_H__ - -#include "lwip/arch.h" -#include "lwip/opt.h" - -/** lower two bits indicate debug level - * - 0 all - * - 1 warning - * - 2 serious - * - 3 severe - */ -#define LWIP_DBG_LEVEL_ALL 0x00 -#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ -#define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ -#define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ -#define LWIP_DBG_LEVEL_SEVERE 0x03 -#define LWIP_DBG_MASK_LEVEL 0x03 - -/** flag for LWIP_DEBUGF to enable that debug message */ -#define LWIP_DBG_ON 0x80U -/** flag for LWIP_DEBUGF to disable that debug message */ -#define LWIP_DBG_OFF 0x00U - -/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ -#define LWIP_DBG_TRACE 0x40U -/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ -#define LWIP_DBG_STATE 0x20U -/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ -#define LWIP_DBG_FRESH 0x10U -/** flag for LWIP_DEBUGF to halt after printing this debug message */ -#define LWIP_DBG_HALT 0x08U - -#ifndef LWIP_NOASSERT -#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ - LWIP_PLATFORM_ASSERT(message); } while(0) -#else /* LWIP_NOASSERT */ -#define LWIP_ASSERT(message, assertion) -#endif /* LWIP_NOASSERT */ - -/** if "expression" isn't true, then print "message" and execute "handler" expression */ -#ifndef LWIP_ERROR -#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ - LWIP_PLATFORM_ASSERT(message); handler;}} while(0) -#endif /* LWIP_ERROR */ - -#ifdef LWIP_DEBUG -/** print debug message only if debug message type is enabled... - * AND is of correct type AND is at least LWIP_DBG_LEVEL - */ -#define LWIP_DEBUGF(debug, message) do { \ - if ( \ - ((debug) & LWIP_DBG_ON) && \ - ((debug) & LWIP_DBG_TYPES_ON) && \ - ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ - LWIP_PLATFORM_DIAG(message); \ - if ((debug) & LWIP_DBG_HALT) { \ - while(1); \ - } \ - } \ - } while(0) - -#else /* LWIP_DEBUG */ -#define LWIP_DEBUGF(debug, message) -#endif /* LWIP_DEBUG */ - -#endif /* __LWIP_DEBUG_H__ */ - diff --git a/user/mpy/lib/lwip/src/include/lwip/def.h b/user/mpy/lib/lwip/src/include/lwip/def.h deleted file mode 100644 index 73a1b56..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/def.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_DEF_H__ -#define __LWIP_DEF_H__ - -/* arch.h might define NULL already */ -#include "lwip/arch.h" -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) -#define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) - -#ifndef NULL -#define NULL ((void *)0) -#endif - -/* Endianess-optimized shifting of two u8_t to create one u16_t */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define LWIP_MAKE_U16(a, b) ((a << 8) | b) -#else -#define LWIP_MAKE_U16(a, b) ((b << 8) | a) -#endif - -#ifndef LWIP_PLATFORM_BYTESWAP -#define LWIP_PLATFORM_BYTESWAP 0 -#endif - -#ifndef LWIP_PREFIX_BYTEORDER_FUNCS -/* workaround for naming collisions on some platforms */ - -#ifdef htons -#undef htons -#endif /* htons */ -#ifdef htonl -#undef htonl -#endif /* htonl */ -#ifdef ntohs -#undef ntohs -#endif /* ntohs */ -#ifdef ntohl -#undef ntohl -#endif /* ntohl */ - -#define htons(x) lwip_htons(x) -#define ntohs(x) lwip_ntohs(x) -#define htonl(x) lwip_htonl(x) -#define ntohl(x) lwip_ntohl(x) -#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ - -#if BYTE_ORDER == BIG_ENDIAN -#define lwip_htons(x) (x) -#define lwip_ntohs(x) (x) -#define lwip_htonl(x) (x) -#define lwip_ntohl(x) (x) -#define PP_HTONS(x) (x) -#define PP_NTOHS(x) (x) -#define PP_HTONL(x) (x) -#define PP_NTOHL(x) (x) -#else /* BYTE_ORDER != BIG_ENDIAN */ -#if LWIP_PLATFORM_BYTESWAP -#define lwip_htons(x) LWIP_PLATFORM_HTONS(x) -#define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) -#define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) -#define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) -#else /* LWIP_PLATFORM_BYTESWAP */ -u16_t lwip_htons(u16_t x); -u16_t lwip_ntohs(u16_t x); -u32_t lwip_htonl(u32_t x); -u32_t lwip_ntohl(u32_t x); -#endif /* LWIP_PLATFORM_BYTESWAP */ - -/* These macros should be calculated by the preprocessor and are used - with compile-time constants only (so that there is no little-endian - overhead at runtime). */ -#define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) -#define PP_NTOHS(x) PP_HTONS(x) -#define PP_HTONL(x) ((((x) & 0xff) << 24) | \ - (((x) & 0xff00) << 8) | \ - (((x) & 0xff0000UL) >> 8) | \ - (((x) & 0xff000000UL) >> 24)) -#define PP_NTOHL(x) PP_HTONL(x) - -#endif /* BYTE_ORDER == BIG_ENDIAN */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_DEF_H__ */ - diff --git a/user/mpy/lib/lwip/src/include/lwip/dhcp.h b/user/mpy/lib/lwip/src/include/lwip/dhcp.h deleted file mode 100644 index 32d9338..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/dhcp.h +++ /dev/null @@ -1,242 +0,0 @@ -/** @file - */ - -#ifndef __LWIP_DHCP_H__ -#define __LWIP_DHCP_H__ - -#include "lwip/opt.h" - -#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/netif.h" -#include "lwip/udp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** period (in seconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_SECS 60 -/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) -/** period (in milliseconds) of the application calling dhcp_fine_tmr() */ -#define DHCP_FINE_TIMER_MSECS 500 - -#define DHCP_CHADDR_LEN 16U -#define DHCP_SNAME_LEN 64U -#define DHCP_FILE_LEN 128U - -struct dhcp -{ - /** transaction identifier of last sent request */ - u32_t xid; - /** our connection to the DHCP server */ - struct udp_pcb *pcb; - /** incoming msg */ - struct dhcp_msg *msg_in; - /** current DHCP state machine state */ - u8_t state; - /** retries of current request */ - u8_t tries; -#if LWIP_DHCP_AUTOIP_COOP - u8_t autoip_coop_state; -#endif - u8_t subnet_mask_given; - - struct pbuf *p_out; /* pbuf of outcoming msg */ - struct dhcp_msg *msg_out; /* outgoing msg */ - u16_t options_out_len; /* outgoing msg options length */ - u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ - u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ - u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ - ip_addr_t server_ip_addr; /* dhcp server address that offered this lease */ - ip_addr_t offered_ip_addr; - ip_addr_t offered_sn_mask; - ip_addr_t offered_gw_addr; - - u32_t offered_t0_lease; /* lease period (in seconds) */ - u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ - u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */ - /* @todo: LWIP_DHCP_BOOTP_FILE configuration option? - integrate with possible TFTP-client for booting? */ -#if LWIP_DHCP_BOOTP_FILE - ip_addr_t offered_si_addr; - char boot_file_name[DHCP_FILE_LEN]; -#endif /* LWIP_DHCP_BOOTPFILE */ -}; - -/* MUST be compiled with "pack structs" or equivalent! */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** minimum set of fields of any DHCP message */ -struct dhcp_msg -{ - PACK_STRUCT_FIELD(u8_t op); - PACK_STRUCT_FIELD(u8_t htype); - PACK_STRUCT_FIELD(u8_t hlen); - PACK_STRUCT_FIELD(u8_t hops); - PACK_STRUCT_FIELD(u32_t xid); - PACK_STRUCT_FIELD(u16_t secs); - PACK_STRUCT_FIELD(u16_t flags); - PACK_STRUCT_FIELD(ip_addr_p_t ciaddr); - PACK_STRUCT_FIELD(ip_addr_p_t yiaddr); - PACK_STRUCT_FIELD(ip_addr_p_t siaddr); - PACK_STRUCT_FIELD(ip_addr_p_t giaddr); - PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]); - PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]); - PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]); - PACK_STRUCT_FIELD(u32_t cookie); -#define DHCP_MIN_OPTIONS_LEN 68U -/** make sure user does not configure this too small */ -#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) -# undef DHCP_OPTIONS_LEN -#endif -/** allow this to be configured in lwipopts.h, but not too small */ -#if (!defined(DHCP_OPTIONS_LEN)) -/** set this to be sufficient for your options in outgoing DHCP msgs */ -# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN -#endif - PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); -/** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */ -#define dhcp_remove_struct(netif) do { (netif)->dhcp = NULL; } while(0) -void dhcp_cleanup(struct netif *netif); -/** start DHCP configuration */ -err_t dhcp_start(struct netif *netif); -/** enforce early lease renewal (not needed normally)*/ -err_t dhcp_renew(struct netif *netif); -/** release the DHCP lease, usually called before dhcp_stop()*/ -err_t dhcp_release(struct netif *netif); -/** stop DHCP configuration */ -void dhcp_stop(struct netif *netif); -/** inform server of our manual IP address */ -void dhcp_inform(struct netif *netif); -/** Handle a possible change in the network configuration */ -void dhcp_network_changed(struct netif *netif); - -/** if enabled, check whether the offered IP address is not in use, using ARP */ -#if DHCP_DOES_ARP_CHECK -void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr); -#endif - -/** to be called every minute */ -void dhcp_coarse_tmr(void); -/** to be called every half second */ -void dhcp_fine_tmr(void); - -/** DHCP message item offsets and length */ -#define DHCP_OP_OFS 0 -#define DHCP_HTYPE_OFS 1 -#define DHCP_HLEN_OFS 2 -#define DHCP_HOPS_OFS 3 -#define DHCP_XID_OFS 4 -#define DHCP_SECS_OFS 8 -#define DHCP_FLAGS_OFS 10 -#define DHCP_CIADDR_OFS 12 -#define DHCP_YIADDR_OFS 16 -#define DHCP_SIADDR_OFS 20 -#define DHCP_GIADDR_OFS 24 -#define DHCP_CHADDR_OFS 28 -#define DHCP_SNAME_OFS 44 -#define DHCP_FILE_OFS 108 -#define DHCP_MSG_LEN 236 - -#define DHCP_COOKIE_OFS DHCP_MSG_LEN -#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4) - -#define DHCP_CLIENT_PORT 68 -#define DHCP_SERVER_PORT 67 - -/** DHCP client states */ -#define DHCP_OFF 0 -#define DHCP_REQUESTING 1 -#define DHCP_INIT 2 -#define DHCP_REBOOTING 3 -#define DHCP_REBINDING 4 -#define DHCP_RENEWING 5 -#define DHCP_SELECTING 6 -#define DHCP_INFORMING 7 -#define DHCP_CHECKING 8 -#define DHCP_PERMANENT 9 -#define DHCP_BOUND 10 -/** not yet implemented #define DHCP_RELEASING 11 */ -#define DHCP_BACKING_OFF 12 - -/** AUTOIP cooperatation flags */ -#define DHCP_AUTOIP_COOP_STATE_OFF 0 -#define DHCP_AUTOIP_COOP_STATE_ON 1 - -#define DHCP_BOOTREQUEST 1 -#define DHCP_BOOTREPLY 2 - -/** DHCP message types */ -#define DHCP_DISCOVER 1 -#define DHCP_OFFER 2 -#define DHCP_REQUEST 3 -#define DHCP_DECLINE 4 -#define DHCP_ACK 5 -#define DHCP_NAK 6 -#define DHCP_RELEASE 7 -#define DHCP_INFORM 8 - -/** DHCP hardware type, currently only ethernet is supported */ -#define DHCP_HTYPE_ETH 1 - -#define DHCP_MAGIC_COOKIE 0x63825363UL - -/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */ - -/** BootP options */ -#define DHCP_OPTION_PAD 0 -#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ -#define DHCP_OPTION_ROUTER 3 -#define DHCP_OPTION_DNS_SERVER 6 -#define DHCP_OPTION_HOSTNAME 12 -#define DHCP_OPTION_IP_TTL 23 -#define DHCP_OPTION_MTU 26 -#define DHCP_OPTION_BROADCAST 28 -#define DHCP_OPTION_TCP_TTL 37 -#define DHCP_OPTION_END 255 - -/** DHCP options */ -#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ -#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ -#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ - -#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ -#define DHCP_OPTION_MESSAGE_TYPE_LEN 1 - -#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ -#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ - -#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ -#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 - -#define DHCP_OPTION_T1 58 /* T1 renewal time */ -#define DHCP_OPTION_T2 59 /* T2 rebinding time */ -#define DHCP_OPTION_US 60 -#define DHCP_OPTION_CLIENT_ID 61 -#define DHCP_OPTION_TFTP_SERVERNAME 66 -#define DHCP_OPTION_BOOTFILE 67 - -/** possible combinations of overloading the file and sname fields with options */ -#define DHCP_OVERLOAD_NONE 0 -#define DHCP_OVERLOAD_FILE 1 -#define DHCP_OVERLOAD_SNAME 2 -#define DHCP_OVERLOAD_SNAME_FILE 3 - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DHCP */ - -#endif /*__LWIP_DHCP_H__*/ diff --git a/user/mpy/lib/lwip/src/include/lwip/dns.h b/user/mpy/lib/lwip/src/include/lwip/dns.h deleted file mode 100644 index 6c7d9b0..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/dns.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * lwip DNS resolver header file. - - * Author: Jim Pettinato - * April 2007 - - * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LWIP_DNS_H__ -#define __LWIP_DNS_H__ - -#include "lwip/opt.h" - -#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** DNS timer period */ -#define DNS_TMR_INTERVAL 1000 - -/** DNS field TYPE used for "Resource Records" */ -#define DNS_RRTYPE_A 1 /* a host address */ -#define DNS_RRTYPE_NS 2 /* an authoritative name server */ -#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ -#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ -#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ -#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ -#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ -#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ -#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ -#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ -#define DNS_RRTYPE_WKS 11 /* a well known service description */ -#define DNS_RRTYPE_PTR 12 /* a domain name pointer */ -#define DNS_RRTYPE_HINFO 13 /* host information */ -#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ -#define DNS_RRTYPE_MX 15 /* mail exchange */ -#define DNS_RRTYPE_TXT 16 /* text strings */ - -/** DNS field CLASS used for "Resource Records" */ -#define DNS_RRCLASS_IN 1 /* the Internet */ -#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ -#define DNS_RRCLASS_CH 3 /* the CHAOS class */ -#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ -#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ - -/* The size used for the next line is rather a hack, but it prevents including socket.h in all files - that include memp.h, and that would possibly break portability (since socket.h defines some types - and constants possibly already define by the OS). - Calculation rule: - sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */ -#define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1) - -#if DNS_LOCAL_HOSTLIST -/** struct used for local host-list */ -struct local_hostlist_entry { - /** static hostname */ - const char *name; - /** static host address in network byteorder */ - ip_addr_t addr; - struct local_hostlist_entry *next; -}; -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC -#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN -#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH -#endif -#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ -#endif /* DNS_LOCAL_HOSTLIST */ - -/** Callback which is invoked when a hostname is found. - * A function of this type must be implemented by the application using the DNS resolver. - * @param name pointer to the name that was looked up. - * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, - * or NULL if the name could not be found (or on any other error). - * @param callback_arg a user-specified callback argument passed to dns_gethostbyname -*/ -typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); - -void dns_init(void); -void dns_tmr(void); -void dns_setserver(u8_t numdns, ip_addr_t *dnsserver); -ip_addr_t dns_getserver(u8_t numdns); -err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, - dns_found_callback found, void *callback_arg); - -#if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC -int dns_local_removehost(const char *hostname, const ip_addr_t *addr); -err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); -#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DNS */ - -#endif /* __LWIP_DNS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/err.h b/user/mpy/lib/lwip/src/include/lwip/err.h deleted file mode 100644 index ac90772..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/err.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ERR_H__ -#define __LWIP_ERR_H__ - -#include "lwip/opt.h" -#include "lwip/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Define LWIP_ERR_T in cc.h if you want to use - * a different type for your platform (must be signed). */ -#ifdef LWIP_ERR_T -typedef LWIP_ERR_T err_t; -#else /* LWIP_ERR_T */ -typedef s8_t err_t; -#endif /* LWIP_ERR_T*/ - -/* Definitions for error constants. */ - -#define ERR_OK 0 /* No error, everything OK. */ -#define ERR_MEM -1 /* Out of memory error. */ -#define ERR_BUF -2 /* Buffer error. */ -#define ERR_TIMEOUT -3 /* Timeout. */ -#define ERR_RTE -4 /* Routing problem. */ -#define ERR_INPROGRESS -5 /* Operation in progress */ -#define ERR_VAL -6 /* Illegal value. */ -#define ERR_WOULDBLOCK -7 /* Operation would block. */ -#define ERR_USE -8 /* Address in use. */ -#define ERR_ISCONN -9 /* Already connected. */ - -#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) - -#define ERR_ABRT -10 /* Connection aborted. */ -#define ERR_RST -11 /* Connection reset. */ -#define ERR_CLSD -12 /* Connection closed. */ -#define ERR_CONN -13 /* Not connected. */ - -#define ERR_ARG -14 /* Illegal argument. */ - -#define ERR_IF -15 /* Low-level netif error */ - - -#ifdef LWIP_DEBUG -extern const char *lwip_strerr(err_t err); -#else -#define lwip_strerr(x) "" -#endif /* LWIP_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_ERR_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/init.h b/user/mpy/lib/lwip/src/include/lwip/init.h deleted file mode 100644 index 4e2e285..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/init.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INIT_H__ -#define __LWIP_INIT_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** X.x.x: Major version of the stack */ -#define LWIP_VERSION_MAJOR 1U -/** x.X.x: Minor version of the stack */ -#define LWIP_VERSION_MINOR 4U -/** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 1U -/** For release candidates, this is set to 1..254 - * For official releases, this is set to 255 (LWIP_RC_RELEASE) - * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ -#define LWIP_VERSION_RC 0U - -/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ -#define LWIP_RC_RELEASE 255U -/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ -#define LWIP_RC_DEVELOPMENT 0U - -#define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) -#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) -#define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) - -/** Provides the version of the stack */ -#define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ - LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) - -/* Modules initialization */ -void lwip_init(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INIT_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/mem.h b/user/mpy/lib/lwip/src/include/lwip/mem.h deleted file mode 100644 index 5bb906b..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/mem.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_MEM_H__ -#define __LWIP_MEM_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if MEM_LIBC_MALLOC - -#include /* for size_t */ - -typedef size_t mem_size_t; -#define MEM_SIZE_F SZT_F - -/* aliases for C library malloc() */ -#define mem_init() -/* in case C library malloc() needs extra protection, - * allow these defines to be overridden. - */ -#ifndef mem_free -#define mem_free free -#endif -#ifndef mem_malloc -#define mem_malloc malloc -#endif -#ifndef mem_calloc -#define mem_calloc calloc -#endif -/* Since there is no C library allocation function to shrink memory without - moving it, define this to nothing. */ -#ifndef mem_trim -#define mem_trim(mem, size) (mem) -#endif -#else /* MEM_LIBC_MALLOC */ - -/* MEM_SIZE would have to be aligned, but using 64000 here instead of - * 65535 leaves some room for alignment... - */ -#if MEM_SIZE > 64000L -typedef u32_t mem_size_t; -#define MEM_SIZE_F U32_F -#else -typedef u16_t mem_size_t; -#define MEM_SIZE_F U16_F -#endif /* MEM_SIZE > 64000 */ - -#if MEM_USE_POOLS -/** mem_init is not used when using pools instead of a heap */ -#define mem_init() -/** mem_trim is not used when using pools instead of a heap: - we can't free part of a pool element and don't want to copy the rest */ -#define mem_trim(mem, size) (mem) -#else /* MEM_USE_POOLS */ -/* lwIP alternative malloc */ -void mem_init(void); -void *mem_trim(void *mem, mem_size_t size); -#endif /* MEM_USE_POOLS */ -void *mem_malloc(mem_size_t size); -void *mem_calloc(mem_size_t count, mem_size_t size); -void mem_free(void *mem); -#endif /* MEM_LIBC_MALLOC */ - -/** Calculate memory size for an aligned buffer - returns the next highest - * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and - * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4). - */ -#ifndef LWIP_MEM_ALIGN_SIZE -#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) -#endif - -/** Calculate safe memory size for an aligned buffer when using an unaligned - * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the - * start (e.g. if buffer is u8_t[] and actual data will be u32_t*) - */ -#ifndef LWIP_MEM_ALIGN_BUFFER -#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1)) -#endif - -/** Align a memory pointer to the alignment defined by MEM_ALIGNMENT - * so that ADDR % MEM_ALIGNMENT == 0 - */ -#ifndef LWIP_MEM_ALIGN -#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_MEM_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/memp.h b/user/mpy/lib/lwip/src/include/lwip/memp.h deleted file mode 100644 index f0d0739..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/memp.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __LWIP_MEMP_H__ -#define __LWIP_MEMP_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ -typedef enum { -#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, -#include "lwip/memp_std.h" - MEMP_MAX -} memp_t; - -#if MEM_USE_POOLS -/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ -typedef enum { - /* Get the first (via: - MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ - MEMP_POOL_HELPER_FIRST = ((u8_t) -#define LWIP_MEMPOOL(name,num,size,desc) -#define LWIP_MALLOC_MEMPOOL_START 1 -#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 -#define LWIP_MALLOC_MEMPOOL_END -#include "lwip/memp_std.h" - ) , - /* Get the last (via: - MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ - MEMP_POOL_HELPER_LAST = ((u8_t) -#define LWIP_MEMPOOL(name,num,size,desc) -#define LWIP_MALLOC_MEMPOOL_START -#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * -#define LWIP_MALLOC_MEMPOOL_END 1 -#include "lwip/memp_std.h" - ) -} memp_pool_helper_t; - -/* The actual start and stop values are here (cast them over) - We use this helper type and these defines so we can avoid using const memp_t values */ -#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) -#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) -#endif /* MEM_USE_POOLS */ - -#if MEMP_MEM_MALLOC || MEM_USE_POOLS -extern const u16_t memp_sizes[MEMP_MAX]; -#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ - -#if MEMP_MEM_MALLOC - -#include "mem.h" - -#define memp_init() -#define memp_malloc(type) mem_malloc(memp_sizes[type]) -#define memp_free(type, mem) mem_free(mem) - -#else /* MEMP_MEM_MALLOC */ - -#if MEM_USE_POOLS -/** This structure is used to save the pool one element came from. */ -struct memp_malloc_helper -{ - memp_t poolnr; -}; -#endif /* MEM_USE_POOLS */ - -void memp_init(void); - -#if MEMP_OVERFLOW_CHECK -void *memp_malloc_fn(memp_t type, const char* file, const int line); -#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) -#else -void *memp_malloc(memp_t type); -#endif -void memp_free(memp_t type, void *mem); - -#endif /* MEMP_MEM_MALLOC */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_MEMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/memp_std.h b/user/mpy/lib/lwip/src/include/lwip/memp_std.h deleted file mode 100644 index 461ed1a..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/memp_std.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * SETUP: Make sure we define everything we will need. - * - * We have create three types of pools: - * 1) MEMPOOL - standard pools - * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c - * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct - * - * If the include'r doesn't require any special treatment of each of the types - * above, then will declare #2 & #3 to be just standard mempools. - */ -#ifndef LWIP_MALLOC_MEMPOOL -/* This treats "malloc pools" just like any other pool. - The pools are a little bigger to provide 'size' as the amount of user data. */ -#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size) -#define LWIP_MALLOC_MEMPOOL_START -#define LWIP_MALLOC_MEMPOOL_END -#endif /* LWIP_MALLOC_MEMPOOL */ - -#ifndef LWIP_PBUF_MEMPOOL -/* This treats "pbuf pools" just like any other pool. - * Allocates buffers for a pbuf struct AND a payload size */ -#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc) -#endif /* LWIP_PBUF_MEMPOOL */ - - -/* - * A list of internal pools used by LWIP. - * - * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description) - * creates a pool name MEMP_pool_name. description is used in stats.c - */ -#if LWIP_RAW -LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB") -#endif /* LWIP_RAW */ - -#if LWIP_UDP -LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB") -#endif /* LWIP_UDP */ - -#if LWIP_TCP -LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") -LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN") -LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG") -#endif /* LWIP_TCP */ - -#if IP_REASSEMBLY -LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA") -#endif /* IP_REASSEMBLY */ -#if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF -LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF") -#endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ - -#if LWIP_NETCONN -LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF") -LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN") -#endif /* LWIP_NETCONN */ - -#if NO_SYS==0 -LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API") -#if !LWIP_TCPIP_CORE_LOCKING_INPUT -LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT") -#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ -#endif /* NO_SYS==0 */ - -#if LWIP_ARP && ARP_QUEUEING -LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE") -#endif /* LWIP_ARP && ARP_QUEUEING */ - -#if LWIP_IGMP -LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP") -#endif /* LWIP_IGMP */ - -#if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */ -LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT") -#endif /* LWIP_TIMERS */ - -#if LWIP_SNMP -LWIP_MEMPOOL(SNMP_ROOTNODE, MEMP_NUM_SNMP_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE") -LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_node), "SNMP_NODE") -LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND") -LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE") -#endif /* LWIP_SNMP */ -#if LWIP_DNS && LWIP_SOCKET -LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB") -#endif /* LWIP_DNS && LWIP_SOCKET */ -#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC -LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST") -#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ -#if PPP_SUPPORT && PPPOE_SUPPORT -LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF") -#endif /* PPP_SUPPORT && PPPOE_SUPPORT */ - -/* - * A list of pools of pbuf's used by LWIP. - * - * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description) - * creates a pool name MEMP_pool_name. description is used in stats.c - * This allocates enough space for the pbuf struct and a payload. - * (Example: pbuf_payload_size=0 allocates only size for the struct) - */ -LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM") -LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL") - - -/* - * Allow for user-defined pools; this must be explicitly set in lwipopts.h - * since the default is to NOT look for lwippools.h - */ -#if MEMP_USE_CUSTOM_POOLS -#include "lwippools.h" -#endif /* MEMP_USE_CUSTOM_POOLS */ - -/* - * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later - * (#undef is ignored for something that is not defined) - */ -#undef LWIP_MEMPOOL -#undef LWIP_MALLOC_MEMPOOL -#undef LWIP_MALLOC_MEMPOOL_START -#undef LWIP_MALLOC_MEMPOOL_END -#undef LWIP_PBUF_MEMPOOL diff --git a/user/mpy/lib/lwip/src/include/lwip/netbuf.h b/user/mpy/lib/lwip/src/include/lwip/netbuf.h deleted file mode 100644 index 7d247d7..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/netbuf.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_NETBUF_H__ -#define __LWIP_NETBUF_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** This netbuf has dest-addr/port set */ -#define NETBUF_FLAG_DESTADDR 0x01 -/** This netbuf includes a checksum */ -#define NETBUF_FLAG_CHKSUM 0x02 - -struct netbuf { - struct pbuf *p, *ptr; - ip_addr_t addr; - u16_t port; -#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY -#if LWIP_CHECKSUM_ON_COPY - u8_t flags; -#endif /* LWIP_CHECKSUM_ON_COPY */ - u16_t toport_chksum; -#if LWIP_NETBUF_RECVINFO - ip_addr_t toaddr; -#endif /* LWIP_NETBUF_RECVINFO */ -#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ -}; - -/* Network buffer functions: */ -struct netbuf * netbuf_new (void); -void netbuf_delete (struct netbuf *buf); -void * netbuf_alloc (struct netbuf *buf, u16_t size); -void netbuf_free (struct netbuf *buf); -err_t netbuf_ref (struct netbuf *buf, - const void *dataptr, u16_t size); -void netbuf_chain (struct netbuf *head, - struct netbuf *tail); - -err_t netbuf_data (struct netbuf *buf, - void **dataptr, u16_t *len); -s8_t netbuf_next (struct netbuf *buf); -void netbuf_first (struct netbuf *buf); - - -#define netbuf_copy_partial(buf, dataptr, len, offset) \ - pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) -#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) -#define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) -#define netbuf_len(buf) ((buf)->p->tot_len) -#define netbuf_fromaddr(buf) (&((buf)->addr)) -#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr) -#define netbuf_fromport(buf) ((buf)->port) -#if LWIP_NETBUF_RECVINFO -#define netbuf_destaddr(buf) (&((buf)->toaddr)) -#define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr) -#define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) -#endif /* LWIP_NETBUF_RECVINFO */ -#if LWIP_CHECKSUM_ON_COPY -#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ - (buf)->toport_chksum = chksum; } while(0) -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_NETBUF_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/netdb.h b/user/mpy/lib/lwip/src/include/lwip/netdb.h deleted file mode 100644 index 7587e2f..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/netdb.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ -#ifndef __LWIP_NETDB_H__ -#define __LWIP_NETDB_H__ - -#include "lwip/opt.h" - -#if LWIP_DNS && LWIP_SOCKET - -#include /* for size_t */ - -#include "lwip/inet.h" -#include "lwip/sockets.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* some rarely used options */ -#ifndef LWIP_DNS_API_DECLARE_H_ERRNO -#define LWIP_DNS_API_DECLARE_H_ERRNO 1 -#endif - -#ifndef LWIP_DNS_API_DEFINE_ERRORS -#define LWIP_DNS_API_DEFINE_ERRORS 1 -#endif - -#ifndef LWIP_DNS_API_DECLARE_STRUCTS -#define LWIP_DNS_API_DECLARE_STRUCTS 1 -#endif - -#if LWIP_DNS_API_DEFINE_ERRORS -/** Errors used by the DNS API functions, h_errno can be one of them */ -#define EAI_NONAME 200 -#define EAI_SERVICE 201 -#define EAI_FAIL 202 -#define EAI_MEMORY 203 - -#define HOST_NOT_FOUND 210 -#define NO_DATA 211 -#define NO_RECOVERY 212 -#define TRY_AGAIN 213 -#endif /* LWIP_DNS_API_DEFINE_ERRORS */ - -#if LWIP_DNS_API_DECLARE_STRUCTS -struct hostent { - char *h_name; /* Official name of the host. */ - char **h_aliases; /* A pointer to an array of pointers to alternative host names, - terminated by a null pointer. */ - int h_addrtype; /* Address type. */ - int h_length; /* The length, in bytes, of the address. */ - char **h_addr_list; /* A pointer to an array of pointers to network addresses (in - network byte order) for the host, terminated by a null pointer. */ -#define h_addr h_addr_list[0] /* for backward compatibility */ -}; - -struct addrinfo { - int ai_flags; /* Input flags. */ - int ai_family; /* Address family of socket. */ - int ai_socktype; /* Socket type. */ - int ai_protocol; /* Protocol of socket. */ - socklen_t ai_addrlen; /* Length of socket address. */ - struct sockaddr *ai_addr; /* Socket address of socket. */ - char *ai_canonname; /* Canonical name of service location. */ - struct addrinfo *ai_next; /* Pointer to next in list. */ -}; -#endif /* LWIP_DNS_API_DECLARE_STRUCTS */ - -#if LWIP_DNS_API_DECLARE_H_ERRNO -/* application accessable error code set by the DNS API functions */ -extern int h_errno; -#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/ - -struct hostent *lwip_gethostbyname(const char *name); -int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, - size_t buflen, struct hostent **result, int *h_errnop); -void lwip_freeaddrinfo(struct addrinfo *ai); -int lwip_getaddrinfo(const char *nodename, - const char *servname, - const struct addrinfo *hints, - struct addrinfo **res); - -#if LWIP_COMPAT_SOCKETS -#define gethostbyname(name) lwip_gethostbyname(name) -#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \ - lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop) -#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo) -#define getaddrinfo(nodname, servname, hints, res) \ - lwip_getaddrinfo(nodname, servname, hints, res) -#endif /* LWIP_COMPAT_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DNS && LWIP_SOCKET */ - -#endif /* __LWIP_NETDB_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/netif.h b/user/mpy/lib/lwip/src/include/lwip/netif.h deleted file mode 100644 index f7e4937..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/netif.h +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_NETIF_H__ -#define __LWIP_NETIF_H__ - -#include "lwip/opt.h" - -#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) - -#include "lwip/err.h" - -#include "lwip/ip_addr.h" - -#include "lwip/def.h" -#include "lwip/pbuf.h" -#if LWIP_DHCP -struct dhcp; -#endif -#if LWIP_AUTOIP -struct autoip; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Throughout this file, IP addresses are expected to be in - * the same byte order as in IP_PCB. */ - -/** must be the maximum of all used hardware address lengths - across all types of interfaces in use */ -#define NETIF_MAX_HWADDR_LEN 6U - -/** Whether the network interface is 'up'. This is - * a software flag used to control whether this network - * interface is enabled and processes traffic. - * It is set by the startup code (for static IP configuration) or - * by dhcp/autoip when an address has been assigned. - */ -#define NETIF_FLAG_UP 0x01U -/** If set, the netif has broadcast capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_BROADCAST 0x02U -/** If set, the netif is one end of a point-to-point connection. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_POINTTOPOINT 0x04U -/** If set, the interface is configured using DHCP. - * Set by the DHCP code when starting or stopping DHCP. */ -#define NETIF_FLAG_DHCP 0x08U -/** If set, the interface has an active link - * (set by the network interface driver). - * Either set by the netif driver in its init function (if the link - * is up at that time) or at a later point once the link comes up - * (if link detection is supported by the hardware). */ -#define NETIF_FLAG_LINK_UP 0x10U -/** If set, the netif is an ethernet device using ARP. - * Set by the netif driver in its init function. - * Used to check input packet types and use of DHCP. */ -#define NETIF_FLAG_ETHARP 0x20U -/** If set, the netif is an ethernet device. It might not use - * ARP or TCP/IP if it is used for PPPoE only. - */ -#define NETIF_FLAG_ETHERNET 0x40U -/** If set, the netif has IGMP capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_IGMP 0x80U - -/** Function prototype for netif init functions. Set up flags and output/linkoutput - * callback functions in this function. - * - * @param netif The netif to initialize - */ -typedef err_t (*netif_init_fn)(struct netif *netif); -/** Function prototype for netif->input functions. This function is saved as 'input' - * callback function in the netif struct. Call it when a packet has been received. - * - * @param p The received packet, copied into a pbuf - * @param inp The netif which received the packet - */ -typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); -/** Function prototype for netif->output functions. Called by lwIP when a packet - * shall be sent. For ethernet netif, set this to 'etharp_output' and set - * 'linkoutput'. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (p->payload points to IP header) - * @param ipaddr The IP address to which the packet shall be sent - */ -typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, - ip_addr_t *ipaddr); -/** Function prototype for netif->linkoutput functions. Only used for ethernet - * netifs. This function is called by ARP when a packet shall be sent. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (raw ethernet packet) - */ -typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); -/** Function prototype for netif status- or link-callback functions. */ -typedef void (*netif_status_callback_fn)(struct netif *netif); -/** Function prototype for netif igmp_mac_filter functions */ -typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, - ip_addr_t *group, u8_t action); - -/** Generic data structure used for all lwIP network interfaces. - * The following fields should be filled in by the initialization - * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ -struct netif { - /** pointer to next in linked list */ - struct netif *next; - - /** IP address configuration in network byte order */ - ip_addr_t ip_addr; - ip_addr_t netmask; - ip_addr_t gw; - - /** This function is called by the network device driver - * to pass a packet up the TCP/IP stack. */ - netif_input_fn input; - /** This function is called by the IP module when it wants - * to send a packet on the interface. This function typically - * first resolves the hardware address, then sends the packet. */ - netif_output_fn output; - /** This function is called by the ARP module when it wants - * to send a packet on the interface. This function outputs - * the pbuf as-is on the link medium. */ - netif_linkoutput_fn linkoutput; -#if LWIP_NETIF_STATUS_CALLBACK - /** This function is called when the netif state is set to up or down - */ - netif_status_callback_fn status_callback; -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_LINK_CALLBACK - /** This function is called when the netif link is set to up or down - */ - netif_status_callback_fn link_callback; -#endif /* LWIP_NETIF_LINK_CALLBACK */ -#if LWIP_NETIF_REMOVE_CALLBACK - /** This function is called when the netif has been removed */ - netif_status_callback_fn remove_callback; -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - /** This field can be set by the device driver and could point - * to state information for the device. */ - void *state; -#if LWIP_DHCP - /** the DHCP client state information for this netif */ - struct dhcp *dhcp; -#endif /* LWIP_DHCP */ -#if LWIP_AUTOIP - /** the AutoIP client state information for this netif */ - struct autoip *autoip; -#endif -#if LWIP_NETIF_HOSTNAME - /* the hostname for this netif, NULL is a valid value */ - char* hostname; -#endif /* LWIP_NETIF_HOSTNAME */ - /** maximum transfer unit (in bytes) */ - u16_t mtu; - /** number of bytes used in hwaddr */ - u8_t hwaddr_len; - /** link level hardware address of this interface */ - u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; - /** flags (see NETIF_FLAG_ above) */ - u8_t flags; - /** descriptive abbreviation */ - char name[2]; - /** number of this interface */ - u8_t num; -#if LWIP_SNMP - /** link type (from "snmp_ifType" enum from snmp.h) */ - u8_t link_type; - /** (estimate) link speed */ - u32_t link_speed; - /** timestamp at last change made (up/down) */ - u32_t ts; - /** counters */ - u32_t ifinoctets; - u32_t ifinucastpkts; - u32_t ifinnucastpkts; - u32_t ifindiscards; - u32_t ifoutoctets; - u32_t ifoutucastpkts; - u32_t ifoutnucastpkts; - u32_t ifoutdiscards; -#endif /* LWIP_SNMP */ -#if LWIP_IGMP - /** This function could be called to add or delete a entry in the multicast - filter table of the ethernet MAC.*/ - netif_igmp_mac_filter_fn igmp_mac_filter; -#endif /* LWIP_IGMP */ -#if LWIP_NETIF_HWADDRHINT - u8_t *addr_hint; -#endif /* LWIP_NETIF_HWADDRHINT */ -#if ENABLE_LOOPBACK - /* List of packets to be queued for ourselves. */ - struct pbuf *loop_first; - struct pbuf *loop_last; -#if LWIP_LOOPBACK_MAX_PBUFS - u16_t loop_cnt_current; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ -#endif /* ENABLE_LOOPBACK */ -}; - -#if LWIP_SNMP -#define NETIF_INIT_SNMP(netif, type, speed) \ - /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ - (netif)->link_type = (type); \ - /* your link speed here (units: bits per second) */ \ - (netif)->link_speed = (speed); \ - (netif)->ts = 0; \ - (netif)->ifinoctets = 0; \ - (netif)->ifinucastpkts = 0; \ - (netif)->ifinnucastpkts = 0; \ - (netif)->ifindiscards = 0; \ - (netif)->ifoutoctets = 0; \ - (netif)->ifoutucastpkts = 0; \ - (netif)->ifoutnucastpkts = 0; \ - (netif)->ifoutdiscards = 0 -#else /* LWIP_SNMP */ -#define NETIF_INIT_SNMP(netif, type, speed) -#endif /* LWIP_SNMP */ - - -/** The list of network interfaces. */ -extern struct netif *netif_list; -/** The default network interface. */ -extern struct netif *netif_default; - -void netif_init(void); - -struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input); - -void -netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw); -void netif_remove(struct netif * netif); - -/* Returns a network interface given its name. The name is of the form - "et0", where the first two letters are the "name" field in the - netif structure, and the digit is in the num field in the same - structure. */ -struct netif *netif_find(char *name); - -void netif_set_default(struct netif *netif); - -void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr); -void netif_set_netmask(struct netif *netif, ip_addr_t *netmask); -void netif_set_gw(struct netif *netif, ip_addr_t *gw); - -void netif_set_up(struct netif *netif); -void netif_set_down(struct netif *netif); -/** Ask if an interface is up */ -#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) - -#if LWIP_NETIF_STATUS_CALLBACK -void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_REMOVE_CALLBACK -void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - -void netif_set_link_up(struct netif *netif); -void netif_set_link_down(struct netif *netif); -/** Ask if a link is up */ -#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) - -#if LWIP_NETIF_LINK_CALLBACK -void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#if LWIP_NETIF_HOSTNAME -#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) -#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) -#endif /* LWIP_NETIF_HOSTNAME */ - -#if LWIP_IGMP -#define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) -#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) -#endif /* LWIP_IGMP */ - -#if ENABLE_LOOPBACK -err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); -void netif_poll(struct netif *netif); -#if !LWIP_NETIF_LOOPBACK_MULTITHREADING -void netif_poll_all(void); -#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ - -#if LWIP_NETIF_HWADDRHINT -#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) -#else /* LWIP_NETIF_HWADDRHINT */ -#define NETIF_SET_HWADDRHINT(netif, hint) -#endif /* LWIP_NETIF_HWADDRHINT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_NETIF_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/netifapi.h b/user/mpy/lib/lwip/src/include/lwip/netifapi.h deleted file mode 100644 index 33318ef..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/netifapi.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#ifndef __LWIP_NETIFAPI_H__ -#define __LWIP_NETIFAPI_H__ - -#include "lwip/opt.h" - -#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/sys.h" -#include "lwip/netif.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*netifapi_void_fn)(struct netif *netif); -typedef err_t (*netifapi_errt_fn)(struct netif *netif); - -struct netifapi_msg_msg { -#if !LWIP_TCPIP_CORE_LOCKING - sys_sem_t sem; -#endif /* !LWIP_TCPIP_CORE_LOCKING */ - err_t err; - struct netif *netif; - union { - struct { - ip_addr_t *ipaddr; - ip_addr_t *netmask; - ip_addr_t *gw; - void *state; - netif_init_fn init; - netif_input_fn input; - } add; - struct { - netifapi_void_fn voidfunc; - netifapi_errt_fn errtfunc; - } common; - } msg; -}; - -struct netifapi_msg { - void (* function)(struct netifapi_msg_msg *msg); - struct netifapi_msg_msg msg; -}; - - -/* API for application */ -err_t netifapi_netif_add ( struct netif *netif, - ip_addr_t *ipaddr, - ip_addr_t *netmask, - ip_addr_t *gw, - void *state, - netif_init_fn init, - netif_input_fn input); - -err_t netifapi_netif_set_addr ( struct netif *netif, - ip_addr_t *ipaddr, - ip_addr_t *netmask, - ip_addr_t *gw ); - -err_t netifapi_netif_common ( struct netif *netif, - netifapi_void_fn voidfunc, - netifapi_errt_fn errtfunc); - -#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) -#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) -#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) -#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) -#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) -#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) -#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) -#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETIF_API */ - -#endif /* __LWIP_NETIFAPI_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/opt.h b/user/mpy/lib/lwip/src/include/lwip/opt.h deleted file mode 100644 index b8ebec8..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/opt.h +++ /dev/null @@ -1,2133 +0,0 @@ -/** - * @file - * - * lwIP Options Configuration - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_OPT_H__ -#define __LWIP_OPT_H__ - -/* - * Include user defined options first. Anything not defined in these files - * will be set to standard values. Override anything you dont like! - */ -#include "lwipopts.h" -#include "lwip/debug.h" - -/* - ----------------------------------------------- - ---------- Platform specific locking ---------- - ----------------------------------------------- -*/ - -/** - * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain - * critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -#ifndef SYS_LIGHTWEIGHT_PROT -#define SYS_LIGHTWEIGHT_PROT 0 -#endif - -/** - * NO_SYS==1: Provides VERY minimal functionality. Otherwise, - * use lwIP facilities. - */ -#ifndef NO_SYS -#define NO_SYS 0 -#endif - -/** - * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 - * Mainly for compatibility to old versions. - */ -#ifndef NO_SYS_NO_TIMERS -#define NO_SYS_NO_TIMERS 0 -#endif - -/** - * MEMCPY: override this if you have a faster implementation at hand than the - * one included in your C library - */ -#ifndef MEMCPY -#define MEMCPY(dst,src,len) memcpy(dst,src,len) -#endif - -/** - * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a - * call to memcpy() if the length is known at compile time and is small. - */ -#ifndef SMEMCPY -#define SMEMCPY(dst,src,len) memcpy(dst,src,len) -#endif - -/* - ------------------------------------ - ---------- Memory options ---------- - ------------------------------------ -*/ -/** - * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library - * instead of the lwip internal allocator. Can save code size if you - * already use it. - */ -#ifndef MEM_LIBC_MALLOC -#define MEM_LIBC_MALLOC 0 -#endif - -/** -* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. -* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution -* speed and usage from interrupts! -*/ -#ifndef MEMP_MEM_MALLOC -#define MEMP_MEM_MALLOC 0 -#endif - -/** - * MEM_ALIGNMENT: should be set to the alignment of the CPU - * 4 byte alignment -> #define MEM_ALIGNMENT 4 - * 2 byte alignment -> #define MEM_ALIGNMENT 2 - */ -#ifndef MEM_ALIGNMENT -#define MEM_ALIGNMENT 1 -#endif - -/** - * MEM_SIZE: the size of the heap memory. If the application will send - * a lot of data that needs to be copied, this should be set high. - */ -#ifndef MEM_SIZE -#define MEM_SIZE 1600 -#endif - -/** - * MEMP_SEPARATE_POOLS: if defined to 1, each pool is placed in its own array. - * This can be used to individually change the location of each pool. - * Default is one big array for all pools - */ -#ifndef MEMP_SEPARATE_POOLS -#define MEMP_SEPARATE_POOLS 0 -#endif - -/** - * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable - * amount of bytes before and after each memp element in every pool and fills - * it with a prominent default value. - * MEMP_OVERFLOW_CHECK == 0 no checking - * MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed - * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time - * memp_malloc() or memp_free() is called (useful but slow!) - */ -#ifndef MEMP_OVERFLOW_CHECK -#define MEMP_OVERFLOW_CHECK 0 -#endif - -/** - * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make - * sure that there are no cycles in the linked lists. - */ -#ifndef MEMP_SANITY_CHECK -#define MEMP_SANITY_CHECK 0 -#endif - -/** - * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set - * of memory pools of various sizes. When mem_malloc is called, an element of - * the smallest pool that can provide the length needed is returned. - * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled. - */ -#ifndef MEM_USE_POOLS -#define MEM_USE_POOLS 0 -#endif - -/** - * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next - * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more - * reliable. */ -#ifndef MEM_USE_POOLS_TRY_BIGGER_POOL -#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 -#endif - -/** - * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h - * that defines additional pools beyond the "standard" ones required - * by lwIP. If you set this to 1, you must have lwippools.h in your - * inlude path somewhere. - */ -#ifndef MEMP_USE_CUSTOM_POOLS -#define MEMP_USE_CUSTOM_POOLS 0 -#endif - -/** - * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from - * interrupt context (or another context that doesn't allow waiting for a - * semaphore). - * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, - * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs - * with each loop so that mem_free can run. - * - * ATTENTION: As you can see from the above description, this leads to dis-/ - * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc - * can need longer. - * - * If you don't want that, at least for NO_SYS=0, you can still use the following - * functions to enqueue a deallocation call which then runs in the tcpip_thread - * context: - * - pbuf_free_callback(p); - * - mem_free_callback(m); - */ -#ifndef LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT -#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 -#endif - -/* - ------------------------------------------------ - ---------- Internal Memory Pool Sizes ---------- - ------------------------------------------------ -*/ -/** - * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). - * If the application sends a lot of data out of ROM (or other static memory), - * this should be set high. - */ -#ifndef MEMP_NUM_PBUF -#define MEMP_NUM_PBUF 16 -#endif - -/** - * MEMP_NUM_RAW_PCB: Number of raw connection PCBs - * (requires the LWIP_RAW option) - */ -#ifndef MEMP_NUM_RAW_PCB -#define MEMP_NUM_RAW_PCB 4 -#endif - -/** - * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - * per active UDP "connection". - * (requires the LWIP_UDP option) - */ -#ifndef MEMP_NUM_UDP_PCB -#define MEMP_NUM_UDP_PCB 4 -#endif - -/** - * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. - * (requires the LWIP_TCP option) - */ -#ifndef MEMP_NUM_TCP_PCB -#define MEMP_NUM_TCP_PCB 5 -#endif - -/** - * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. - * (requires the LWIP_TCP option) - */ -#ifndef MEMP_NUM_TCP_PCB_LISTEN -#define MEMP_NUM_TCP_PCB_LISTEN 8 -#endif - -/** - * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. - * (requires the LWIP_TCP option) - */ -#ifndef MEMP_NUM_TCP_SEG -#define MEMP_NUM_TCP_SEG 16 -#endif - -/** - * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for - * reassembly (whole packets, not fragments!) - */ -#ifndef MEMP_NUM_REASSDATA -#define MEMP_NUM_REASSDATA 5 -#endif - -/** - * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent - * (fragments, not whole packets!). - * This is only used with IP_FRAG_USES_STATIC_BUF==0 and - * LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 with DMA-enabled MACs - * where the packet is not yet sent when netif->output returns. - */ -#ifndef MEMP_NUM_FRAG_PBUF -#define MEMP_NUM_FRAG_PBUF 15 -#endif - -/** - * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing - * packets (pbufs) that are waiting for an ARP request (to resolve - * their destination address) to finish. - * (requires the ARP_QUEUEING option) - */ -#ifndef MEMP_NUM_ARP_QUEUE -#define MEMP_NUM_ARP_QUEUE 30 -#endif - -/** - * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces - * can be members et the same time (one per netif - allsystems group -, plus one - * per netif membership). - * (requires the LWIP_IGMP option) - */ -#ifndef MEMP_NUM_IGMP_GROUP -#define MEMP_NUM_IGMP_GROUP 8 -#endif - -/** - * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. - * (requires NO_SYS==0) - * The default number of timeouts is calculated here for all enabled modules. - * The formula expects settings to be either '0' or '1'. - */ -#ifndef MEMP_NUM_SYS_TIMEOUT -#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT) -#endif - -/** - * MEMP_NUM_NETBUF: the number of struct netbufs. - * (only needed if you use the sequential API, like api_lib.c) - */ -#ifndef MEMP_NUM_NETBUF -#define MEMP_NUM_NETBUF 2 -#endif - -/** - * MEMP_NUM_NETCONN: the number of struct netconns. - * (only needed if you use the sequential API, like api_lib.c) - */ -#ifndef MEMP_NUM_NETCONN -#define MEMP_NUM_NETCONN 4 -#endif - -/** - * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used - * for callback/timeout API communication. - * (only needed if you use tcpip.c) - */ -#ifndef MEMP_NUM_TCPIP_MSG_API -#define MEMP_NUM_TCPIP_MSG_API 8 -#endif - -/** - * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used - * for incoming packets. - * (only needed if you use tcpip.c) - */ -#ifndef MEMP_NUM_TCPIP_MSG_INPKT -#define MEMP_NUM_TCPIP_MSG_INPKT 8 -#endif - -/** - * MEMP_NUM_SNMP_NODE: the number of leafs in the SNMP tree. - */ -#ifndef MEMP_NUM_SNMP_NODE -#define MEMP_NUM_SNMP_NODE 50 -#endif - -/** - * MEMP_NUM_SNMP_ROOTNODE: the number of branches in the SNMP tree. - * Every branch has one leaf (MEMP_NUM_SNMP_NODE) at least! - */ -#ifndef MEMP_NUM_SNMP_ROOTNODE -#define MEMP_NUM_SNMP_ROOTNODE 30 -#endif - -/** - * MEMP_NUM_SNMP_VARBIND: the number of concurrent requests (does not have to - * be changed normally) - 2 of these are used per request (1 for input, - * 1 for output) - */ -#ifndef MEMP_NUM_SNMP_VARBIND -#define MEMP_NUM_SNMP_VARBIND 2 -#endif - -/** - * MEMP_NUM_SNMP_VALUE: the number of OID or values concurrently used - * (does not have to be changed normally) - 3 of these are used per request - * (1 for the value read and 2 for OIDs - input and output) - */ -#ifndef MEMP_NUM_SNMP_VALUE -#define MEMP_NUM_SNMP_VALUE 3 -#endif - -/** - * MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls - * (before freeing the corresponding memory using lwip_freeaddrinfo()). - */ -#ifndef MEMP_NUM_NETDB -#define MEMP_NUM_NETDB 1 -#endif - -/** - * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list - * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1. - */ -#ifndef MEMP_NUM_LOCALHOSTLIST -#define MEMP_NUM_LOCALHOSTLIST 1 -#endif - -/** - * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE - * interfaces (only used with PPPOE_SUPPORT==1) - */ -#ifndef MEMP_NUM_PPPOE_INTERFACES -#define MEMP_NUM_PPPOE_INTERFACES 1 -#endif - -/** - * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. - */ -#ifndef PBUF_POOL_SIZE -#define PBUF_POOL_SIZE 16 -#endif - -/* - --------------------------------- - ---------- ARP options ---------- - --------------------------------- -*/ -/** - * LWIP_ARP==1: Enable ARP functionality. - */ -#ifndef LWIP_ARP -#define LWIP_ARP 1 -#endif - -/** - * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached. - */ -#ifndef ARP_TABLE_SIZE -#define ARP_TABLE_SIZE 10 -#endif - -/** - * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address - * resolution. By default, only the most recent packet is queued per IP address. - * This is sufficient for most protocols and mainly reduces TCP connection - * startup time. Set this to 1 if you know your application sends more than one - * packet in a row to an IP address that is not in the ARP cache. - */ -#ifndef ARP_QUEUEING -#define ARP_QUEUEING 0 -#endif - -/** - * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be - * updated with the source MAC and IP addresses supplied in the packet. - * You may want to disable this if you do not trust LAN peers to have the - * correct addresses, or as a limited approach to attempt to handle - * spoofing. If disabled, lwIP will need to make a new ARP request if - * the peer is not already in the ARP table, adding a little latency. - * The peer *is* in the ARP table if it requested our address before. - * Also notice that this slows down input processing of every IP packet! - */ -#ifndef ETHARP_TRUST_IP_MAC -#define ETHARP_TRUST_IP_MAC 0 -#endif - -/** - * ETHARP_SUPPORT_VLAN==1: support receiving ethernet packets with VLAN header. - * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check. - * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted. - * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted. - * Alternatively, define a function/define ETHARP_VLAN_CHECK_FN(eth_hdr, vlan) - * that returns 1 to accept a packet or 0 to drop a packet. - */ -#ifndef ETHARP_SUPPORT_VLAN -#define ETHARP_SUPPORT_VLAN 0 -#endif - -/** LWIP_ETHERNET==1: enable ethernet support for PPPoE even though ARP - * might be disabled - */ -#ifndef LWIP_ETHERNET -#define LWIP_ETHERNET (LWIP_ARP || PPPOE_SUPPORT) -#endif - -/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure - * alignment of payload after that header. Since the header is 14 bytes long, - * without this padding e.g. addresses in the IP header will not be aligned - * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms. - */ -#ifndef ETH_PAD_SIZE -#define ETH_PAD_SIZE 0 -#endif - -/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table - * entries (using etharp_add_static_entry/etharp_remove_static_entry). - */ -#ifndef ETHARP_SUPPORT_STATIC_ENTRIES -#define ETHARP_SUPPORT_STATIC_ENTRIES 0 -#endif - - -/* - -------------------------------- - ---------- IP options ---------- - -------------------------------- -*/ -/** - * IP_FORWARD==1: Enables the ability to forward IP packets across network - * interfaces. If you are going to run lwIP on a device with only one network - * interface, define this to 0. - */ -#ifndef IP_FORWARD -#define IP_FORWARD 0 -#endif - -/** - * IP_OPTIONS_ALLOWED: Defines the behavior for IP options. - * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. - * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). - */ -#ifndef IP_OPTIONS_ALLOWED -#define IP_OPTIONS_ALLOWED 1 -#endif - -/** - * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that - * this option does not affect outgoing packet sizes, which can be controlled - * via IP_FRAG. - */ -#ifndef IP_REASSEMBLY -#define IP_REASSEMBLY 1 -#endif - -/** - * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note - * that this option does not affect incoming packet sizes, which can be - * controlled via IP_REASSEMBLY. - */ -#ifndef IP_FRAG -#define IP_FRAG 1 -#endif - -/** - * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) - * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived - * in this time, the whole packet is discarded. - */ -#ifndef IP_REASS_MAXAGE -#define IP_REASS_MAXAGE 3 -#endif - -/** - * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. - * Since the received pbufs are enqueued, be sure to configure - * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive - * packets even if the maximum amount of fragments is enqueued for reassembly! - */ -#ifndef IP_REASS_MAX_PBUFS -#define IP_REASS_MAX_PBUFS 10 -#endif - -/** - * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP - * fragmentation. Otherwise pbufs are allocated and reference the original - * packet data to be fragmented (or with LWIP_NETIF_TX_SINGLE_PBUF==1, - * new PBUF_RAM pbufs are used for fragments). - * ATTENTION: IP_FRAG_USES_STATIC_BUF==1 may not be used for DMA-enabled MACs! - */ -#ifndef IP_FRAG_USES_STATIC_BUF -#define IP_FRAG_USES_STATIC_BUF 0 -#endif - -/** - * IP_FRAG_MAX_MTU: Assumed max MTU on any interface for IP frag buffer - * (requires IP_FRAG_USES_STATIC_BUF==1) - */ -#if IP_FRAG_USES_STATIC_BUF && !defined(IP_FRAG_MAX_MTU) -#define IP_FRAG_MAX_MTU 1500 -#endif - -/** - * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers. - */ -#ifndef IP_DEFAULT_TTL -#define IP_DEFAULT_TTL 255 -#endif - -/** - * IP_SOF_BROADCAST=1: Use the SOF_BROADCAST field to enable broadcast - * filter per pcb on udp and raw send operations. To enable broadcast filter - * on recv operations, you also have to set IP_SOF_BROADCAST_RECV=1. - */ -#ifndef IP_SOF_BROADCAST -#define IP_SOF_BROADCAST 0 -#endif - -/** - * IP_SOF_BROADCAST_RECV (requires IP_SOF_BROADCAST=1) enable the broadcast - * filter on recv operations. - */ -#ifndef IP_SOF_BROADCAST_RECV -#define IP_SOF_BROADCAST_RECV 0 -#endif - -/** - * IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1: allow ip_forward() to send packets back - * out on the netif where it was received. This should only be used for - * wireless networks. - * ATTENTION: When this is 1, make sure your netif driver correctly marks incoming - * link-layer-broadcast/multicast packets as such using the corresponding pbuf flags! - */ -#ifndef IP_FORWARD_ALLOW_TX_ON_RX_NETIF -#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0 -#endif - -/** - * LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first - * local TCP/UDP pcb (default==0). This can prevent creating predictable port - * numbers after booting a device. - */ -#ifndef LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS -#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0 -#endif - -/* - ---------------------------------- - ---------- ICMP options ---------- - ---------------------------------- -*/ -/** - * LWIP_ICMP==1: Enable ICMP module inside the IP stack. - * Be careful, disable that make your product non-compliant to RFC1122 - */ -#ifndef LWIP_ICMP -#define LWIP_ICMP 1 -#endif - -/** - * ICMP_TTL: Default value for Time-To-Live used by ICMP packets. - */ -#ifndef ICMP_TTL -#define ICMP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) - */ -#ifndef LWIP_BROADCAST_PING -#define LWIP_BROADCAST_PING 0 -#endif - -/** - * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only) - */ -#ifndef LWIP_MULTICAST_PING -#define LWIP_MULTICAST_PING 0 -#endif - -/* - --------------------------------- - ---------- RAW options ---------- - --------------------------------- -*/ -/** - * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. - */ -#ifndef LWIP_RAW -#define LWIP_RAW 1 -#endif - -/** - * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. - */ -#ifndef RAW_TTL -#define RAW_TTL (IP_DEFAULT_TTL) -#endif - -/* - ---------------------------------- - ---------- DHCP options ---------- - ---------------------------------- -*/ -/** - * LWIP_DHCP==1: Enable DHCP module. - */ -#ifndef LWIP_DHCP -#define LWIP_DHCP 0 -#endif - -/** - * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address. - */ -#ifndef DHCP_DOES_ARP_CHECK -#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP)) -#endif - -/* - ------------------------------------ - ---------- AUTOIP options ---------- - ------------------------------------ -*/ -/** - * LWIP_AUTOIP==1: Enable AUTOIP module. - */ -#ifndef LWIP_AUTOIP -#define LWIP_AUTOIP 0 -#endif - -/** - * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on - * the same interface at the same time. - */ -#ifndef LWIP_DHCP_AUTOIP_COOP -#define LWIP_DHCP_AUTOIP_COOP 0 -#endif - -/** - * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes - * that should be sent before falling back on AUTOIP. This can be set - * as low as 1 to get an AutoIP address very quickly, but you should - * be prepared to handle a changing IP address when DHCP overrides - * AutoIP. - */ -#ifndef LWIP_DHCP_AUTOIP_COOP_TRIES -#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 -#endif - -/* - ---------------------------------- - ---------- SNMP options ---------- - ---------------------------------- -*/ -/** - * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP - * transport. - */ -#ifndef LWIP_SNMP -#define LWIP_SNMP 0 -#endif - -/** - * SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will - * allow. At least one request buffer is required. - * Does not have to be changed unless external MIBs answer request asynchronously - */ -#ifndef SNMP_CONCURRENT_REQUESTS -#define SNMP_CONCURRENT_REQUESTS 1 -#endif - -/** - * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap - * destination is required - */ -#ifndef SNMP_TRAP_DESTINATIONS -#define SNMP_TRAP_DESTINATIONS 1 -#endif - -/** - * SNMP_PRIVATE_MIB: - * When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. - */ -#ifndef SNMP_PRIVATE_MIB -#define SNMP_PRIVATE_MIB 0 -#endif - -/** - * Only allow SNMP write actions that are 'safe' (e.g. disabeling netifs is not - * a safe action and disabled when SNMP_SAFE_REQUESTS = 1). - * Unsafe requests are disabled by default! - */ -#ifndef SNMP_SAFE_REQUESTS -#define SNMP_SAFE_REQUESTS 1 -#endif - -/** - * The maximum length of strings used. This affects the size of - * MEMP_SNMP_VALUE elements. - */ -#ifndef SNMP_MAX_OCTET_STRING_LEN -#define SNMP_MAX_OCTET_STRING_LEN 127 -#endif - -/** - * The maximum depth of the SNMP tree. - * With private MIBs enabled, this depends on your MIB! - * This affects the size of MEMP_SNMP_VALUE elements. - */ -#ifndef SNMP_MAX_TREE_DEPTH -#define SNMP_MAX_TREE_DEPTH 15 -#endif - -/** - * The size of the MEMP_SNMP_VALUE elements, normally calculated from - * SNMP_MAX_OCTET_STRING_LEN and SNMP_MAX_TREE_DEPTH. - */ -#ifndef SNMP_MAX_VALUE_SIZE -#define SNMP_MAX_VALUE_SIZE LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN)+1, sizeof(s32_t)*(SNMP_MAX_TREE_DEPTH)) -#endif - -/* - ---------------------------------- - ---------- IGMP options ---------- - ---------------------------------- -*/ -/** - * LWIP_IGMP==1: Turn on IGMP module. - */ -#ifndef LWIP_IGMP -#define LWIP_IGMP 0 -#endif - -/* - ---------------------------------- - ---------- DNS options ----------- - ---------------------------------- -*/ -/** - * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS - * transport. - */ -#ifndef LWIP_DNS -#define LWIP_DNS 0 -#endif - -/** DNS maximum number of entries to maintain locally. */ -#ifndef DNS_TABLE_SIZE -#define DNS_TABLE_SIZE 4 -#endif - -/** DNS maximum host name length supported in the name table. */ -#ifndef DNS_MAX_NAME_LENGTH -#define DNS_MAX_NAME_LENGTH 256 -#endif - -/** The maximum of DNS servers */ -#ifndef DNS_MAX_SERVERS -#define DNS_MAX_SERVERS 2 -#endif - -/** DNS do a name checking between the query and the response. */ -#ifndef DNS_DOES_NAME_CHECK -#define DNS_DOES_NAME_CHECK 1 -#endif - -/** DNS message max. size. Default value is RFC compliant. */ -#ifndef DNS_MSG_SIZE -#define DNS_MSG_SIZE 512 -#endif - -/** DNS_LOCAL_HOSTLIST: Implements a local host-to-address list. If enabled, - * you have to define - * #define DNS_LOCAL_HOSTLIST_INIT {{"host1", 0x123}, {"host2", 0x234}} - * (an array of structs name/address, where address is an u32_t in network - * byte order). - * - * Instead, you can also use an external function: - * #define DNS_LOOKUP_LOCAL_EXTERN(x) extern u32_t my_lookup_function(const char *name) - * that returns the IP address or INADDR_NONE if not found. - */ -#ifndef DNS_LOCAL_HOSTLIST -#define DNS_LOCAL_HOSTLIST 0 -#endif /* DNS_LOCAL_HOSTLIST */ - -/** If this is turned on, the local host-list can be dynamically changed - * at runtime. */ -#ifndef DNS_LOCAL_HOSTLIST_IS_DYNAMIC -#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0 -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -/* - --------------------------------- - ---------- UDP options ---------- - --------------------------------- -*/ -/** - * LWIP_UDP==1: Turn on UDP. - */ -#ifndef LWIP_UDP -#define LWIP_UDP 1 -#endif - -/** - * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP) - */ -#ifndef LWIP_UDPLITE -#define LWIP_UDPLITE 0 -#endif - -/** - * UDP_TTL: Default Time-To-Live value. - */ -#ifndef UDP_TTL -#define UDP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf. - */ -#ifndef LWIP_NETBUF_RECVINFO -#define LWIP_NETBUF_RECVINFO 0 -#endif - -/* - --------------------------------- - ---------- TCP options ---------- - --------------------------------- -*/ -/** - * LWIP_TCP==1: Turn on TCP. - */ -#ifndef LWIP_TCP -#define LWIP_TCP 1 -#endif - -/** - * TCP_TTL: Default Time-To-Live value. - */ -#ifndef TCP_TTL -#define TCP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * TCP_WND: The size of a TCP window. This must be at least - * (2 * TCP_MSS) for things to work well - */ -#ifndef TCP_WND -#define TCP_WND (4 * TCP_MSS) -#endif - -/** - * TCP_MAXRTX: Maximum number of retransmissions of data segments. - */ -#ifndef TCP_MAXRTX -#define TCP_MAXRTX 12 -#endif - -/** - * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments. - */ -#ifndef TCP_SYNMAXRTX -#define TCP_SYNMAXRTX 6 -#endif - -/** - * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order. - * Define to 0 if your device is low on memory. - */ -#ifndef TCP_QUEUE_OOSEQ -#define TCP_QUEUE_OOSEQ (LWIP_TCP) -#endif - -/** - * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, - * you might want to increase this.) - * For the receive side, this MSS is advertised to the remote side - * when opening a connection. For the transmit size, this MSS sets - * an upper limit on the MSS advertised by the remote host. - */ -#ifndef TCP_MSS -#define TCP_MSS 536 -#endif - -/** - * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really - * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which - * reflects the available reassembly buffer size at the remote host) and the - * largest size permitted by the IP layer" (RFC 1122) - * Setting this to 1 enables code that checks TCP_MSS against the MTU of the - * netif used for a connection and limits the MSS if it would be too big otherwise. - */ -#ifndef TCP_CALCULATE_EFF_SEND_MSS -#define TCP_CALCULATE_EFF_SEND_MSS 1 -#endif - - -/** - * TCP_SND_BUF: TCP sender buffer space (bytes). - * To achieve good performance, this should be at least 2 * TCP_MSS. - */ -#ifndef TCP_SND_BUF -#define TCP_SND_BUF (2 * TCP_MSS) -#endif - -/** - * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least - * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. - */ -#ifndef TCP_SND_QUEUELEN -#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) -#endif - -/** - * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than - * TCP_SND_BUF. It is the amount of space which must be available in the - * TCP snd_buf for select to return writable (combined with TCP_SNDQUEUELOWAT). - */ -#ifndef TCP_SNDLOWAT -#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -#endif - -/** - * TCP_SNDQUEUELOWAT: TCP writable bufs (pbuf count). This must be less - * than TCP_SND_QUEUELEN. If the number of pbufs queued on a pcb drops below - * this number, select returns writable (combined with TCP_SNDLOWAT). - */ -#ifndef TCP_SNDQUEUELOWAT -#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5) -#endif - -/** - * TCP_OOSEQ_MAX_BYTES: The maximum number of bytes queued on ooseq per pcb. - * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==0. - */ -#ifndef TCP_OOSEQ_MAX_BYTES -#define TCP_OOSEQ_MAX_BYTES 0 -#endif - -/** - * TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs queued on ooseq per pcb. - * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==0. - */ -#ifndef TCP_OOSEQ_MAX_PBUFS -#define TCP_OOSEQ_MAX_PBUFS 0 -#endif - -/** - * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb. - */ -#ifndef TCP_LISTEN_BACKLOG -#define TCP_LISTEN_BACKLOG 0 -#endif - -/** - * The maximum allowed backlog for TCP listen netconns. - * This backlog is used unless another is explicitly specified. - * 0xff is the maximum (u8_t). - */ -#ifndef TCP_DEFAULT_LISTEN_BACKLOG -#define TCP_DEFAULT_LISTEN_BACKLOG 0xff -#endif - -/** - * TCP_OVERSIZE: The maximum number of bytes that tcp_write may - * allocate ahead of time in an attempt to create shorter pbuf chains - * for transmission. The meaningful range is 0 to TCP_MSS. Some - * suggested values are: - * - * 0: Disable oversized allocation. Each tcp_write() allocates a new - pbuf (old behaviour). - * 1: Allocate size-aligned pbufs with minimal excess. Use this if your - * scatter-gather DMA requires aligned fragments. - * 128: Limit the pbuf/memory overhead to 20%. - * TCP_MSS: Try to create unfragmented TCP packets. - * TCP_MSS/4: Try to create 4 fragments or less per TCP packet. - */ -#ifndef TCP_OVERSIZE -#define TCP_OVERSIZE TCP_MSS -#endif - -/** - * LWIP_TCP_TIMESTAMPS==1: support the TCP timestamp option. - */ -#ifndef LWIP_TCP_TIMESTAMPS -#define LWIP_TCP_TIMESTAMPS 0 -#endif - -/** - * TCP_WND_UPDATE_THRESHOLD: difference in window to trigger an - * explicit window update - */ -#ifndef TCP_WND_UPDATE_THRESHOLD -#define TCP_WND_UPDATE_THRESHOLD (TCP_WND / 4) -#endif - -/** - * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1. - * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all - * events (accept, sent, etc) that happen in the system. - * LWIP_CALLBACK_API==1: The PCB callback function is called directly - * for the event. This is the default. - */ -#if !defined(LWIP_EVENT_API) && !defined(LWIP_CALLBACK_API) -#define LWIP_EVENT_API 0 -#define LWIP_CALLBACK_API 1 -#endif - - -/* - ---------------------------------- - ---------- Pbuf options ---------- - ---------------------------------- -*/ -/** - * PBUF_LINK_HLEN: the number of bytes that should be allocated for a - * link level header. The default is 14, the standard value for - * Ethernet. - */ -#ifndef PBUF_LINK_HLEN -#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) -#endif - -/** - * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is - * designed to accomodate single full size TCP frame in one pbuf, including - * TCP_MSS, IP header, and link header. - */ -#ifndef PBUF_POOL_BUFSIZE -#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN) -#endif - -/* - ------------------------------------------------ - ---------- Network Interfaces options ---------- - ------------------------------------------------ -*/ -/** - * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname - * field. - */ -#ifndef LWIP_NETIF_HOSTNAME -#define LWIP_NETIF_HOSTNAME 0 -#endif - -/** - * LWIP_NETIF_API==1: Support netif api (in netifapi.c) - */ -#ifndef LWIP_NETIF_API -#define LWIP_NETIF_API 0 -#endif - -/** - * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface - * changes its up/down status (i.e., due to DHCP IP acquistion) - */ -#ifndef LWIP_NETIF_STATUS_CALLBACK -#define LWIP_NETIF_STATUS_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface - * whenever the link changes (i.e., link down) - */ -#ifndef LWIP_NETIF_LINK_CALLBACK -#define LWIP_NETIF_LINK_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_REMOVE_CALLBACK==1: Support a callback function that is called - * when a netif has been removed - */ -#ifndef LWIP_NETIF_REMOVE_CALLBACK -#define LWIP_NETIF_REMOVE_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table - * indices) in struct netif. TCP and UDP can make use of this to prevent - * scanning the ARP table for every sent packet. While this is faster for big - * ARP tables or many concurrent connections, it might be counterproductive - * if you have a tiny ARP table or if there never are concurrent connections. - */ -#ifndef LWIP_NETIF_HWADDRHINT -#define LWIP_NETIF_HWADDRHINT 0 -#endif - -/** - * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP - * address equal to the netif IP address, looping them back up the stack. - */ -#ifndef LWIP_NETIF_LOOPBACK -#define LWIP_NETIF_LOOPBACK 0 -#endif - -/** - * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback - * sending for each netif (0 = disabled) - */ -#ifndef LWIP_LOOPBACK_MAX_PBUFS -#define LWIP_LOOPBACK_MAX_PBUFS 0 -#endif - -/** - * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in - * the system, as netifs must change how they behave depending on this setting - * for the LWIP_NETIF_LOOPBACK option to work. - * Setting this is needed to avoid reentering non-reentrant functions like - * tcp_input(). - * LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a - * multithreaded environment like tcpip.c. In this case, netif->input() - * is called directly. - * LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. - * The packets are put on a list and netif_poll() must be called in - * the main application loop. - */ -#ifndef LWIP_NETIF_LOOPBACK_MULTITHREADING -#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) -#endif - -/** - * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data - * to be sent into one single pbuf. This is for compatibility with DMA-enabled - * MACs that do not support scatter-gather. - * Beware that this might involve CPU-memcpy before transmitting that would not - * be needed without this flag! Use this only if you need to! - * - * @todo: TCP and IP-frag do not work with this, yet: - */ -#ifndef LWIP_NETIF_TX_SINGLE_PBUF -#define LWIP_NETIF_TX_SINGLE_PBUF 0 -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - -/* - ------------------------------------ - ---------- LOOPIF options ---------- - ------------------------------------ -*/ -/** - * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c - */ -#ifndef LWIP_HAVE_LOOPIF -#define LWIP_HAVE_LOOPIF 0 -#endif - -/* - ------------------------------------ - ---------- SLIPIF options ---------- - ------------------------------------ -*/ -/** - * LWIP_HAVE_SLIPIF==1: Support slip interface and slipif.c - */ -#ifndef LWIP_HAVE_SLIPIF -#define LWIP_HAVE_SLIPIF 0 -#endif - -/* - ------------------------------------ - ---------- Thread options ---------- - ------------------------------------ -*/ -/** - * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread. - */ -#ifndef TCPIP_THREAD_NAME -#define TCPIP_THREAD_NAME "tcpip_thread" -#endif - -/** - * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef TCPIP_THREAD_STACKSIZE -#define TCPIP_THREAD_STACKSIZE 0 -#endif - -/** - * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef TCPIP_THREAD_PRIO -#define TCPIP_THREAD_PRIO 1 -#endif - -/** - * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when tcpip_init is called. - */ -#ifndef TCPIP_MBOX_SIZE -#define TCPIP_MBOX_SIZE 0 -#endif - -/** - * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread. - */ -#ifndef SLIPIF_THREAD_NAME -#define SLIPIF_THREAD_NAME "slipif_loop" -#endif - -/** - * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef SLIPIF_THREAD_STACKSIZE -#define SLIPIF_THREAD_STACKSIZE 0 -#endif - -/** - * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef SLIPIF_THREAD_PRIO -#define SLIPIF_THREAD_PRIO 1 -#endif - -/** - * PPP_THREAD_NAME: The name assigned to the pppInputThread. - */ -#ifndef PPP_THREAD_NAME -#define PPP_THREAD_NAME "pppInputThread" -#endif - -/** - * PPP_THREAD_STACKSIZE: The stack size used by the pppInputThread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef PPP_THREAD_STACKSIZE -#define PPP_THREAD_STACKSIZE 0 -#endif - -/** - * PPP_THREAD_PRIO: The priority assigned to the pppInputThread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef PPP_THREAD_PRIO -#define PPP_THREAD_PRIO 1 -#endif - -/** - * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread. - */ -#ifndef DEFAULT_THREAD_NAME -#define DEFAULT_THREAD_NAME "lwIP" -#endif - -/** - * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef DEFAULT_THREAD_STACKSIZE -#define DEFAULT_THREAD_STACKSIZE 0 -#endif - -/** - * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef DEFAULT_THREAD_PRIO -#define DEFAULT_THREAD_PRIO 1 -#endif - -/** - * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#ifndef DEFAULT_RAW_RECVMBOX_SIZE -#define DEFAULT_RAW_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#ifndef DEFAULT_UDP_RECVMBOX_SIZE -#define DEFAULT_UDP_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#ifndef DEFAULT_TCP_RECVMBOX_SIZE -#define DEFAULT_TCP_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections. - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when the acceptmbox is created. - */ -#ifndef DEFAULT_ACCEPTMBOX_SIZE -#define DEFAULT_ACCEPTMBOX_SIZE 0 -#endif - -/* - ---------------------------------------------- - ---------- Sequential layer options ---------- - ---------------------------------------------- -*/ -/** - * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) - * Don't use it if you're not an active lwIP project member - */ -#ifndef LWIP_TCPIP_CORE_LOCKING -#define LWIP_TCPIP_CORE_LOCKING 0 -#endif - -/** - * LWIP_TCPIP_CORE_LOCKING_INPUT: (EXPERIMENTAL!) - * Don't use it if you're not an active lwIP project member - */ -#ifndef LWIP_TCPIP_CORE_LOCKING_INPUT -#define LWIP_TCPIP_CORE_LOCKING_INPUT 0 -#endif - -/** - * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) - */ -#ifndef LWIP_NETCONN -#define LWIP_NETCONN 1 -#endif - -/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout tod create - * timers running in tcpip_thread from another thread. - */ -#ifndef LWIP_TCPIP_TIMEOUT -#define LWIP_TCPIP_TIMEOUT 1 -#endif - -/* - ------------------------------------ - ---------- Socket options ---------- - ------------------------------------ -*/ -/** - * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) - */ -#ifndef LWIP_SOCKET -#define LWIP_SOCKET 1 -#endif - -/** - * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. - * (only used if you use sockets.c) - */ -#ifndef LWIP_COMPAT_SOCKETS -#define LWIP_COMPAT_SOCKETS 1 -#endif - -/** - * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names. - * Disable this option if you use a POSIX operating system that uses the same - * names (read, write & close). (only used if you use sockets.c) - */ -#ifndef LWIP_POSIX_SOCKETS_IO_NAMES -#define LWIP_POSIX_SOCKETS_IO_NAMES 1 -#endif - -/** - * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT - * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set - * in seconds. (does not require sockets.c, and will affect tcp.c) - */ -#ifndef LWIP_TCP_KEEPALIVE -#define LWIP_TCP_KEEPALIVE 0 -#endif - -/** - * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and - * SO_SNDTIMEO processing. - */ -#ifndef LWIP_SO_SNDTIMEO -#define LWIP_SO_SNDTIMEO 0 -#endif - -/** - * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and - * SO_RCVTIMEO processing. - */ -#ifndef LWIP_SO_RCVTIMEO -#define LWIP_SO_RCVTIMEO 0 -#endif - -/** - * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing. - */ -#ifndef LWIP_SO_RCVBUF -#define LWIP_SO_RCVBUF 0 -#endif - -/** - * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize. - */ -#ifndef RECV_BUFSIZE_DEFAULT -#define RECV_BUFSIZE_DEFAULT INT_MAX -#endif - -/** - * SO_REUSE==1: Enable SO_REUSEADDR option. - */ -#ifndef SO_REUSE -#define SO_REUSE 0 -#endif - -/** - * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets - * to all local matches if SO_REUSEADDR is turned on. - * WARNING: Adds a memcpy for every packet if passing to more than one pcb! - */ -#ifndef SO_REUSE_RXTOALL -#define SO_REUSE_RXTOALL 0 -#endif - -/* - ---------------------------------------- - ---------- Statistics options ---------- - ---------------------------------------- -*/ -/** - * LWIP_STATS==1: Enable statistics collection in lwip_stats. - */ -#ifndef LWIP_STATS -#define LWIP_STATS 1 -#endif - -#if LWIP_STATS - -/** - * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions. - */ -#ifndef LWIP_STATS_DISPLAY -#define LWIP_STATS_DISPLAY 0 -#endif - -/** - * LINK_STATS==1: Enable link stats. - */ -#ifndef LINK_STATS -#define LINK_STATS 1 -#endif - -/** - * ETHARP_STATS==1: Enable etharp stats. - */ -#ifndef ETHARP_STATS -#define ETHARP_STATS (LWIP_ARP) -#endif - -/** - * IP_STATS==1: Enable IP stats. - */ -#ifndef IP_STATS -#define IP_STATS 1 -#endif - -/** - * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is - * on if using either frag or reass. - */ -#ifndef IPFRAG_STATS -#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG) -#endif - -/** - * ICMP_STATS==1: Enable ICMP stats. - */ -#ifndef ICMP_STATS -#define ICMP_STATS 1 -#endif - -/** - * IGMP_STATS==1: Enable IGMP stats. - */ -#ifndef IGMP_STATS -#define IGMP_STATS (LWIP_IGMP) -#endif - -/** - * UDP_STATS==1: Enable UDP stats. Default is on if - * UDP enabled, otherwise off. - */ -#ifndef UDP_STATS -#define UDP_STATS (LWIP_UDP) -#endif - -/** - * TCP_STATS==1: Enable TCP stats. Default is on if TCP - * enabled, otherwise off. - */ -#ifndef TCP_STATS -#define TCP_STATS (LWIP_TCP) -#endif - -/** - * MEM_STATS==1: Enable mem.c stats. - */ -#ifndef MEM_STATS -#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0)) -#endif - -/** - * MEMP_STATS==1: Enable memp.c pool stats. - */ -#ifndef MEMP_STATS -#define MEMP_STATS (MEMP_MEM_MALLOC == 0) -#endif - -/** - * SYS_STATS==1: Enable system stats (sem and mbox counts, etc). - */ -#ifndef SYS_STATS -#define SYS_STATS (NO_SYS == 0) -#endif - -#else - -#define LINK_STATS 0 -#define IP_STATS 0 -#define IPFRAG_STATS 0 -#define ICMP_STATS 0 -#define IGMP_STATS 0 -#define UDP_STATS 0 -#define TCP_STATS 0 -#define MEM_STATS 0 -#define MEMP_STATS 0 -#define SYS_STATS 0 -#define LWIP_STATS_DISPLAY 0 - -#endif /* LWIP_STATS */ - -/* - --------------------------------- - ---------- PPP options ---------- - --------------------------------- -*/ -/** - * PPP_SUPPORT==1: Enable PPP. - */ -#ifndef PPP_SUPPORT -#define PPP_SUPPORT 0 -#endif - -/** - * PPPOE_SUPPORT==1: Enable PPP Over Ethernet - */ -#ifndef PPPOE_SUPPORT -#define PPPOE_SUPPORT 0 -#endif - -/** - * PPPOS_SUPPORT==1: Enable PPP Over Serial - */ -#ifndef PPPOS_SUPPORT -#define PPPOS_SUPPORT PPP_SUPPORT -#endif - -#if PPP_SUPPORT - -/** - * NUM_PPP: Max PPP sessions. - */ -#ifndef NUM_PPP -#define NUM_PPP 1 -#endif - -/** - * PAP_SUPPORT==1: Support PAP. - */ -#ifndef PAP_SUPPORT -#define PAP_SUPPORT 0 -#endif - -/** - * CHAP_SUPPORT==1: Support CHAP. - */ -#ifndef CHAP_SUPPORT -#define CHAP_SUPPORT 0 -#endif - -/** - * MSCHAP_SUPPORT==1: Support MSCHAP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef MSCHAP_SUPPORT -#define MSCHAP_SUPPORT 0 -#endif - -/** - * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef CBCP_SUPPORT -#define CBCP_SUPPORT 0 -#endif - -/** - * CCP_SUPPORT==1: Support CCP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef CCP_SUPPORT -#define CCP_SUPPORT 0 -#endif - -/** - * VJ_SUPPORT==1: Support VJ header compression. - */ -#ifndef VJ_SUPPORT -#define VJ_SUPPORT 0 -#endif - -/** - * MD5_SUPPORT==1: Support MD5 (see also CHAP). - */ -#ifndef MD5_SUPPORT -#define MD5_SUPPORT 0 -#endif - -/* - * Timeouts - */ -#ifndef FSM_DEFTIMEOUT -#define FSM_DEFTIMEOUT 6 /* Timeout time in seconds */ -#endif - -#ifndef FSM_DEFMAXTERMREQS -#define FSM_DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ -#endif - -#ifndef FSM_DEFMAXCONFREQS -#define FSM_DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ -#endif - -#ifndef FSM_DEFMAXNAKLOOPS -#define FSM_DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */ -#endif - -#ifndef UPAP_DEFTIMEOUT -#define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */ -#endif - -#ifndef UPAP_DEFREQTIME -#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ -#endif - -#ifndef CHAP_DEFTIMEOUT -#define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */ -#endif - -#ifndef CHAP_DEFTRANSMITS -#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ -#endif - -/* Interval in seconds between keepalive echo requests, 0 to disable. */ -#ifndef LCP_ECHOINTERVAL -#define LCP_ECHOINTERVAL 0 -#endif - -/* Number of unanswered echo requests before failure. */ -#ifndef LCP_MAXECHOFAILS -#define LCP_MAXECHOFAILS 3 -#endif - -/* Max Xmit idle time (in jiffies) before resend flag char. */ -#ifndef PPP_MAXIDLEFLAG -#define PPP_MAXIDLEFLAG 100 -#endif - -/* - * Packet sizes - * - * Note - lcp shouldn't be allowed to negotiate stuff outside these - * limits. See lcp.h in the pppd directory. - * (XXX - these constants should simply be shared by lcp.c instead - * of living in lcp.h) - */ -#define PPP_MTU 1500 /* Default MTU (size of Info field) */ -#ifndef PPP_MAXMTU -/* #define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) */ -#define PPP_MAXMTU 1500 /* Largest MTU we allow */ -#endif -#define PPP_MINMTU 64 -#define PPP_MRU 1500 /* default MRU = max length of info field */ -#define PPP_MAXMRU 1500 /* Largest MRU we allow */ -#ifndef PPP_DEFMRU -#define PPP_DEFMRU 296 /* Try for this */ -#endif -#define PPP_MINMRU 128 /* No MRUs below this */ - -#ifndef MAXNAMELEN -#define MAXNAMELEN 256 /* max length of hostname or name for auth */ -#endif -#ifndef MAXSECRETLEN -#define MAXSECRETLEN 256 /* max length of password or secret */ -#endif - -#endif /* PPP_SUPPORT */ - -/* - -------------------------------------- - ---------- Checksum options ---------- - -------------------------------------- -*/ -/** - * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets. - */ -#ifndef CHECKSUM_GEN_IP -#define CHECKSUM_GEN_IP 1 -#endif - -/** - * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets. - */ -#ifndef CHECKSUM_GEN_UDP -#define CHECKSUM_GEN_UDP 1 -#endif - -/** - * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets. - */ -#ifndef CHECKSUM_GEN_TCP -#define CHECKSUM_GEN_TCP 1 -#endif - -/** - * CHECKSUM_GEN_ICMP==1: Generate checksums in software for outgoing ICMP packets. - */ -#ifndef CHECKSUM_GEN_ICMP -#define CHECKSUM_GEN_ICMP 1 -#endif - -/** - * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. - */ -#ifndef CHECKSUM_CHECK_IP -#define CHECKSUM_CHECK_IP 1 -#endif - -/** - * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets. - */ -#ifndef CHECKSUM_CHECK_UDP -#define CHECKSUM_CHECK_UDP 1 -#endif - -/** - * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets. - */ -#ifndef CHECKSUM_CHECK_TCP -#define CHECKSUM_CHECK_TCP 1 -#endif - -/** - * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from - * application buffers to pbufs. - */ -#ifndef LWIP_CHECKSUM_ON_COPY -#define LWIP_CHECKSUM_ON_COPY 0 -#endif - -/* - --------------------------------------- - ---------- Hook options --------------- - --------------------------------------- -*/ - -/* Hooks are undefined by default, define them to a function if you need them. */ - -/** - * LWIP_HOOK_IP4_INPUT(pbuf, input_netif): - * - called from ip_input() (IPv4) - * - pbuf: received struct pbuf passed to ip_input() - * - input_netif: struct netif on which the packet has been received - * Return values: - * - 0: Hook has not consumed the packet, packet is processed as normal - * - != 0: Hook has consumed the packet. - * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook - * (i.e. free it when done). - */ - -/** - * LWIP_HOOK_IP4_ROUTE(dest): - * - called from ip_route() (IPv4) - * - dest: destination IPv4 address - * Returns the destination netif or NULL if no destination netif is found. In - * that case, ip_route() continues as normal. - */ - -/* - --------------------------------------- - ---------- Debugging options ---------- - --------------------------------------- -*/ -/** - * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is - * compared against this value. If it is smaller, then debugging - * messages are written. - */ -#ifndef LWIP_DBG_MIN_LEVEL -#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL -#endif - -/** - * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable - * debug messages of certain types. - */ -#ifndef LWIP_DBG_TYPES_ON -#define LWIP_DBG_TYPES_ON LWIP_DBG_ON -#endif - -/** - * ETHARP_DEBUG: Enable debugging in etharp.c. - */ -#ifndef ETHARP_DEBUG -#define ETHARP_DEBUG LWIP_DBG_OFF -#endif - -/** - * NETIF_DEBUG: Enable debugging in netif.c. - */ -#ifndef NETIF_DEBUG -#define NETIF_DEBUG LWIP_DBG_OFF -#endif - -/** - * PBUF_DEBUG: Enable debugging in pbuf.c. - */ -#ifndef PBUF_DEBUG -#define PBUF_DEBUG LWIP_DBG_OFF -#endif - -/** - * API_LIB_DEBUG: Enable debugging in api_lib.c. - */ -#ifndef API_LIB_DEBUG -#define API_LIB_DEBUG LWIP_DBG_OFF -#endif - -/** - * API_MSG_DEBUG: Enable debugging in api_msg.c. - */ -#ifndef API_MSG_DEBUG -#define API_MSG_DEBUG LWIP_DBG_OFF -#endif - -/** - * SOCKETS_DEBUG: Enable debugging in sockets.c. - */ -#ifndef SOCKETS_DEBUG -#define SOCKETS_DEBUG LWIP_DBG_OFF -#endif - -/** - * ICMP_DEBUG: Enable debugging in icmp.c. - */ -#ifndef ICMP_DEBUG -#define ICMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * IGMP_DEBUG: Enable debugging in igmp.c. - */ -#ifndef IGMP_DEBUG -#define IGMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * INET_DEBUG: Enable debugging in inet.c. - */ -#ifndef INET_DEBUG -#define INET_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP_DEBUG: Enable debugging for IP. - */ -#ifndef IP_DEBUG -#define IP_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass. - */ -#ifndef IP_REASS_DEBUG -#define IP_REASS_DEBUG LWIP_DBG_OFF -#endif - -/** - * RAW_DEBUG: Enable debugging in raw.c. - */ -#ifndef RAW_DEBUG -#define RAW_DEBUG LWIP_DBG_OFF -#endif - -/** - * MEM_DEBUG: Enable debugging in mem.c. - */ -#ifndef MEM_DEBUG -#define MEM_DEBUG LWIP_DBG_OFF -#endif - -/** - * MEMP_DEBUG: Enable debugging in memp.c. - */ -#ifndef MEMP_DEBUG -#define MEMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SYS_DEBUG: Enable debugging in sys.c. - */ -#ifndef SYS_DEBUG -#define SYS_DEBUG LWIP_DBG_OFF -#endif - -/** - * TIMERS_DEBUG: Enable debugging in timers.c. - */ -#ifndef TIMERS_DEBUG -#define TIMERS_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_DEBUG: Enable debugging for TCP. - */ -#ifndef TCP_DEBUG -#define TCP_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug. - */ -#ifndef TCP_INPUT_DEBUG -#define TCP_INPUT_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit. - */ -#ifndef TCP_FR_DEBUG -#define TCP_FR_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_RTO_DEBUG: Enable debugging in TCP for retransmit - * timeout. - */ -#ifndef TCP_RTO_DEBUG -#define TCP_RTO_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_CWND_DEBUG: Enable debugging for TCP congestion window. - */ -#ifndef TCP_CWND_DEBUG -#define TCP_CWND_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating. - */ -#ifndef TCP_WND_DEBUG -#define TCP_WND_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions. - */ -#ifndef TCP_OUTPUT_DEBUG -#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_RST_DEBUG: Enable debugging for TCP with the RST message. - */ -#ifndef TCP_RST_DEBUG -#define TCP_RST_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths. - */ -#ifndef TCP_QLEN_DEBUG -#define TCP_QLEN_DEBUG LWIP_DBG_OFF -#endif - -/** - * UDP_DEBUG: Enable debugging in UDP. - */ -#ifndef UDP_DEBUG -#define UDP_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCPIP_DEBUG: Enable debugging in tcpip.c. - */ -#ifndef TCPIP_DEBUG -#define TCPIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * PPP_DEBUG: Enable debugging for PPP. - */ -#ifndef PPP_DEBUG -#define PPP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SLIP_DEBUG: Enable debugging in slipif.c. - */ -#ifndef SLIP_DEBUG -#define SLIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * DHCP_DEBUG: Enable debugging in dhcp.c. - */ -#ifndef DHCP_DEBUG -#define DHCP_DEBUG LWIP_DBG_OFF -#endif - -/** - * AUTOIP_DEBUG: Enable debugging in autoip.c. - */ -#ifndef AUTOIP_DEBUG -#define AUTOIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SNMP_MSG_DEBUG: Enable debugging for SNMP messages. - */ -#ifndef SNMP_MSG_DEBUG -#define SNMP_MSG_DEBUG LWIP_DBG_OFF -#endif - -/** - * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs. - */ -#ifndef SNMP_MIB_DEBUG -#define SNMP_MIB_DEBUG LWIP_DBG_OFF -#endif - -/** - * DNS_DEBUG: Enable debugging for DNS. - */ -#ifndef DNS_DEBUG -#define DNS_DEBUG LWIP_DBG_OFF -#endif - -#endif /* __LWIP_OPT_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/pbuf.h b/user/mpy/lib/lwip/src/include/lwip/pbuf.h deleted file mode 100644 index 99d5443..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/pbuf.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __LWIP_PBUF_H__ -#define __LWIP_PBUF_H__ - -#include "lwip/opt.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Currently, the pbuf_custom code is only needed for one specific configuration - * of IP_FRAG */ -#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) - -#define PBUF_TRANSPORT_HLEN 20 -#define PBUF_IP_HLEN 20 - -typedef enum { - PBUF_TRANSPORT, - PBUF_IP, - PBUF_LINK, - PBUF_RAW -} pbuf_layer; - -typedef enum { - PBUF_RAM, /* pbuf data is stored in RAM */ - PBUF_ROM, /* pbuf data is stored in ROM */ - PBUF_REF, /* pbuf comes from the pbuf pool */ - PBUF_POOL /* pbuf payload refers to RAM */ -} pbuf_type; - - -/** indicates this packet's data should be immediately passed to the application */ -#define PBUF_FLAG_PUSH 0x01U -/** indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a - a pbuf differently */ -#define PBUF_FLAG_IS_CUSTOM 0x02U -/** indicates this pbuf is UDP multicast to be looped back */ -#define PBUF_FLAG_MCASTLOOP 0x04U -/** indicates this pbuf was received as link-level broadcast */ -#define PBUF_FLAG_LLBCAST 0x08U -/** indicates this pbuf was received as link-level multicast */ -#define PBUF_FLAG_LLMCAST 0x10U -/** indicates this pbuf includes a TCP FIN flag */ -#define PBUF_FLAG_TCP_FIN 0x20U - -struct pbuf { - /** next pbuf in singly linked pbuf chain */ - struct pbuf *next; - - /** pointer to the actual data in the buffer */ - void *payload; - - /** - * total length of this buffer and all next buffers in chain - * belonging to the same packet. - * - * For non-queue packet chains this is the invariant: - * p->tot_len == p->len + (p->next? p->next->tot_len: 0) - */ - u16_t tot_len; - - /** length of this buffer */ - u16_t len; - - /** pbuf_type as u8_t instead of enum to save space */ - u8_t /*pbuf_type*/ type; - - /** misc flags */ - u8_t flags; - - /** - * the reference count always equals the number of pointers - * that refer to this pbuf. This can be pointers from an application, - * the stack itself, or pbuf->next pointers from a chain. - */ - u16_t ref; -}; - -#if LWIP_SUPPORT_CUSTOM_PBUF -/** Prototype for a function to free a custom pbuf */ -typedef void (*pbuf_free_custom_fn)(struct pbuf *p); - -/** A custom pbuf: like a pbuf, but following a function pointer to free it. */ -struct pbuf_custom { - /** The actual pbuf */ - struct pbuf pbuf; - /** This function is called when pbuf_free deallocates this pbuf(_custom) */ - pbuf_free_custom_fn custom_free_function; -}; -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - -#if LWIP_TCP && TCP_QUEUE_OOSEQ -/** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */ -#ifndef PBUF_POOL_FREE_OOSEQ -#define PBUF_POOL_FREE_OOSEQ 1 -#endif /* PBUF_POOL_FREE_OOSEQ */ -#if NO_SYS && PBUF_POOL_FREE_OOSEQ -extern volatile u8_t pbuf_free_ooseq_pending; -void pbuf_free_ooseq(); -/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() - at regular intervals from main level to check if ooseq pbufs need to be - freed! */ -#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \ - /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \ - ooseq queued pbufs now */ \ - pbuf_free_ooseq(); }}while(0) -#endif /* NO_SYS && PBUF_POOL_FREE_OOSEQ*/ -#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ */ - -/* Initializes the pbuf module. This call is empty for now, but may not be in future. */ -#define pbuf_init() - -struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); -#if LWIP_SUPPORT_CUSTOM_PBUF -struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, - struct pbuf_custom *p, void *payload_mem, - u16_t payload_mem_len); -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ -void pbuf_realloc(struct pbuf *p, u16_t size); -u8_t pbuf_header(struct pbuf *p, s16_t header_size); -void pbuf_ref(struct pbuf *p); -u8_t pbuf_free(struct pbuf *p); -u8_t pbuf_clen(struct pbuf *p); -void pbuf_cat(struct pbuf *head, struct pbuf *tail); -void pbuf_chain(struct pbuf *head, struct pbuf *tail); -struct pbuf *pbuf_dechain(struct pbuf *p); -err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from); -u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset); -err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); -struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); -#if LWIP_CHECKSUM_ON_COPY -err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, - u16_t len, u16_t *chksum); -#endif /* LWIP_CHECKSUM_ON_COPY */ - -u8_t pbuf_get_at(struct pbuf* p, u16_t offset); -u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n); -u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset); -u16_t pbuf_strstr(struct pbuf* p, const char* substr); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_PBUF_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/raw.h b/user/mpy/lib/lwip/src/include/lwip/raw.h deleted file mode 100644 index 17d0a1c..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/raw.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_RAW_H__ -#define __LWIP_RAW_H__ - -#include "lwip/opt.h" - -#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/def.h" -#include "lwip/ip.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct raw_pcb; - -/** Function prototype for raw pcb receive callback functions. - * @param arg user supplied argument (raw_pcb.recv_arg) - * @param pcb the raw_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IP address from which the packet was received - * @return 1 if the packet was 'eaten' (aka. deleted), - * 0 if the packet lives on - * If returning 1, the callback is responsible for freeing the pbuf - * if it's not used any more. - */ -typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, - ip_addr_t *addr); - -struct raw_pcb { - /* Common members of all PCB types */ - IP_PCB; - - struct raw_pcb *next; - - u8_t protocol; - - /** receive callback function */ - raw_recv_fn recv; - /* user-supplied argument for the recv callback */ - void *recv_arg; -}; - -/* The following functions is the application layer interface to the - RAW code. */ -struct raw_pcb * raw_new (u8_t proto); -void raw_remove (struct raw_pcb *pcb); -err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr); -err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr); - -void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); -err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr); -err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); - -/* The following functions are the lower layer interface to RAW. */ -u8_t raw_input (struct pbuf *p, struct netif *inp); -#define raw_init() /* Compatibility define, not init needed. */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_RAW */ - -#endif /* __LWIP_RAW_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/sio.h b/user/mpy/lib/lwip/src/include/lwip/sio.h deleted file mode 100644 index 28ae2f2..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/sio.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - */ - -/* - * This is the interface to the platform specific serial IO module - * It needs to be implemented by those platforms which need SLIP or PPP - */ - -#ifndef __SIO_H__ -#define __SIO_H__ - -#include "lwip/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* If you want to define sio_fd_t elsewhere or differently, - define this in your cc.h file. */ -#ifndef __sio_fd_t_defined -typedef void * sio_fd_t; -#endif - -/* The following functions can be defined to something else in your cc.h file - or be implemented in your custom sio.c file. */ - -#ifndef sio_open -/** - * Opens a serial device for communication. - * - * @param devnum device number - * @return handle to serial device if successful, NULL otherwise - */ -sio_fd_t sio_open(u8_t devnum); -#endif - -#ifndef sio_send -/** - * Sends a single character to the serial device. - * - * @param c character to send - * @param fd serial device handle - * - * @note This function will block until the character can be sent. - */ -void sio_send(u8_t c, sio_fd_t fd); -#endif - -#ifndef sio_recv -/** - * Receives a single character from the serial device. - * - * @param fd serial device handle - * - * @note This function will block until a character is received. - */ -u8_t sio_recv(sio_fd_t fd); -#endif - -#ifndef sio_read -/** - * Reads from the serial device. - * - * @param fd serial device handle - * @param data pointer to data buffer for receiving - * @param len maximum length (in bytes) of data to receive - * @return number of bytes actually received - may be 0 if aborted by sio_read_abort - * - * @note This function will block until data can be received. The blocking - * can be cancelled by calling sio_read_abort(). - */ -u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_tryread -/** - * Tries to read from the serial device. Same as sio_read but returns - * immediately if no data is available and never blocks. - * - * @param fd serial device handle - * @param data pointer to data buffer for receiving - * @param len maximum length (in bytes) of data to receive - * @return number of bytes actually received - */ -u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_write -/** - * Writes to the serial device. - * - * @param fd serial device handle - * @param data pointer to data to send - * @param len length (in bytes) of data to send - * @return number of bytes actually sent - * - * @note This function will block until all data can be sent. - */ -u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_read_abort -/** - * Aborts a blocking sio_read() call. - * - * @param fd serial device handle - */ -void sio_read_abort(sio_fd_t fd); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __SIO_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp.h b/user/mpy/lib/lwip/src/include/lwip/snmp.h deleted file mode 100644 index 2ed043d..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/snmp.h +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (c) 2001, 2002 Leon Woestenberg - * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Leon Woestenberg - * - */ -#ifndef __LWIP_SNMP_H__ -#define __LWIP_SNMP_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#include "lwip/ip_addr.h" - -struct udp_pcb; -struct netif; - -/** - * @see RFC1213, "MIB-II, 6. Definitions" - */ -enum snmp_ifType { - snmp_ifType_other=1, /* none of the following */ - snmp_ifType_regular1822, - snmp_ifType_hdh1822, - snmp_ifType_ddn_x25, - snmp_ifType_rfc877_x25, - snmp_ifType_ethernet_csmacd, - snmp_ifType_iso88023_csmacd, - snmp_ifType_iso88024_tokenBus, - snmp_ifType_iso88025_tokenRing, - snmp_ifType_iso88026_man, - snmp_ifType_starLan, - snmp_ifType_proteon_10Mbit, - snmp_ifType_proteon_80Mbit, - snmp_ifType_hyperchannel, - snmp_ifType_fddi, - snmp_ifType_lapb, - snmp_ifType_sdlc, - snmp_ifType_ds1, /* T-1 */ - snmp_ifType_e1, /* european equiv. of T-1 */ - snmp_ifType_basicISDN, - snmp_ifType_primaryISDN, /* proprietary serial */ - snmp_ifType_propPointToPointSerial, - snmp_ifType_ppp, - snmp_ifType_softwareLoopback, - snmp_ifType_eon, /* CLNP over IP [11] */ - snmp_ifType_ethernet_3Mbit, - snmp_ifType_nsip, /* XNS over IP */ - snmp_ifType_slip, /* generic SLIP */ - snmp_ifType_ultra, /* ULTRA technologies */ - snmp_ifType_ds3, /* T-3 */ - snmp_ifType_sip, /* SMDS */ - snmp_ifType_frame_relay -}; - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -/** SNMP "sysuptime" Interval */ -#define SNMP_SYSUPTIME_INTERVAL 10 - -/** fixed maximum length for object identifier type */ -#define LWIP_SNMP_OBJ_ID_LEN 32 - -/** internal object identifier representation */ -struct snmp_obj_id -{ - u8_t len; - s32_t id[LWIP_SNMP_OBJ_ID_LEN]; -}; - -/* system */ -void snmp_set_sysdesr(u8_t* str, u8_t* len); -void snmp_set_sysobjid(struct snmp_obj_id *oid); -void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid); -void snmp_inc_sysuptime(void); -void snmp_add_sysuptime(u32_t value); -void snmp_get_sysuptime(u32_t *value); -void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen); -void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen); -void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen); - -/* network interface */ -void snmp_add_ifinoctets(struct netif *ni, u32_t value); -void snmp_inc_ifinucastpkts(struct netif *ni); -void snmp_inc_ifinnucastpkts(struct netif *ni); -void snmp_inc_ifindiscards(struct netif *ni); -void snmp_add_ifoutoctets(struct netif *ni, u32_t value); -void snmp_inc_ifoutucastpkts(struct netif *ni); -void snmp_inc_ifoutnucastpkts(struct netif *ni); -void snmp_inc_ifoutdiscards(struct netif *ni); -void snmp_inc_iflist(void); -void snmp_dec_iflist(void); - -/* ARP (for atTable and ipNetToMediaTable) */ -void snmp_insert_arpidx_tree(struct netif *ni, ip_addr_t *ip); -void snmp_delete_arpidx_tree(struct netif *ni, ip_addr_t *ip); - -/* IP */ -void snmp_inc_ipinreceives(void); -void snmp_inc_ipinhdrerrors(void); -void snmp_inc_ipinaddrerrors(void); -void snmp_inc_ipforwdatagrams(void); -void snmp_inc_ipinunknownprotos(void); -void snmp_inc_ipindiscards(void); -void snmp_inc_ipindelivers(void); -void snmp_inc_ipoutrequests(void); -void snmp_inc_ipoutdiscards(void); -void snmp_inc_ipoutnoroutes(void); -void snmp_inc_ipreasmreqds(void); -void snmp_inc_ipreasmoks(void); -void snmp_inc_ipreasmfails(void); -void snmp_inc_ipfragoks(void); -void snmp_inc_ipfragfails(void); -void snmp_inc_ipfragcreates(void); -void snmp_inc_iproutingdiscards(void); -void snmp_insert_ipaddridx_tree(struct netif *ni); -void snmp_delete_ipaddridx_tree(struct netif *ni); -void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni); -void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni); - -/* ICMP */ -void snmp_inc_icmpinmsgs(void); -void snmp_inc_icmpinerrors(void); -void snmp_inc_icmpindestunreachs(void); -void snmp_inc_icmpintimeexcds(void); -void snmp_inc_icmpinparmprobs(void); -void snmp_inc_icmpinsrcquenchs(void); -void snmp_inc_icmpinredirects(void); -void snmp_inc_icmpinechos(void); -void snmp_inc_icmpinechoreps(void); -void snmp_inc_icmpintimestamps(void); -void snmp_inc_icmpintimestampreps(void); -void snmp_inc_icmpinaddrmasks(void); -void snmp_inc_icmpinaddrmaskreps(void); -void snmp_inc_icmpoutmsgs(void); -void snmp_inc_icmpouterrors(void); -void snmp_inc_icmpoutdestunreachs(void); -void snmp_inc_icmpouttimeexcds(void); -void snmp_inc_icmpoutparmprobs(void); -void snmp_inc_icmpoutsrcquenchs(void); -void snmp_inc_icmpoutredirects(void); -void snmp_inc_icmpoutechos(void); -void snmp_inc_icmpoutechoreps(void); -void snmp_inc_icmpouttimestamps(void); -void snmp_inc_icmpouttimestampreps(void); -void snmp_inc_icmpoutaddrmasks(void); -void snmp_inc_icmpoutaddrmaskreps(void); - -/* TCP */ -void snmp_inc_tcpactiveopens(void); -void snmp_inc_tcppassiveopens(void); -void snmp_inc_tcpattemptfails(void); -void snmp_inc_tcpestabresets(void); -void snmp_inc_tcpinsegs(void); -void snmp_inc_tcpoutsegs(void); -void snmp_inc_tcpretranssegs(void); -void snmp_inc_tcpinerrs(void); -void snmp_inc_tcpoutrsts(void); - -/* UDP */ -void snmp_inc_udpindatagrams(void); -void snmp_inc_udpnoports(void); -void snmp_inc_udpinerrors(void); -void snmp_inc_udpoutdatagrams(void); -void snmp_insert_udpidx_tree(struct udp_pcb *pcb); -void snmp_delete_udpidx_tree(struct udp_pcb *pcb); - -/* SNMP */ -void snmp_inc_snmpinpkts(void); -void snmp_inc_snmpoutpkts(void); -void snmp_inc_snmpinbadversions(void); -void snmp_inc_snmpinbadcommunitynames(void); -void snmp_inc_snmpinbadcommunityuses(void); -void snmp_inc_snmpinasnparseerrs(void); -void snmp_inc_snmpintoobigs(void); -void snmp_inc_snmpinnosuchnames(void); -void snmp_inc_snmpinbadvalues(void); -void snmp_inc_snmpinreadonlys(void); -void snmp_inc_snmpingenerrs(void); -void snmp_add_snmpintotalreqvars(u8_t value); -void snmp_add_snmpintotalsetvars(u8_t value); -void snmp_inc_snmpingetrequests(void); -void snmp_inc_snmpingetnexts(void); -void snmp_inc_snmpinsetrequests(void); -void snmp_inc_snmpingetresponses(void); -void snmp_inc_snmpintraps(void); -void snmp_inc_snmpouttoobigs(void); -void snmp_inc_snmpoutnosuchnames(void); -void snmp_inc_snmpoutbadvalues(void); -void snmp_inc_snmpoutgenerrs(void); -void snmp_inc_snmpoutgetrequests(void); -void snmp_inc_snmpoutgetnexts(void); -void snmp_inc_snmpoutsetrequests(void); -void snmp_inc_snmpoutgetresponses(void); -void snmp_inc_snmpouttraps(void); -void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid); -void snmp_set_snmpenableauthentraps(u8_t *value); -void snmp_get_snmpenableauthentraps(u8_t *value); - -/* LWIP_SNMP support not available */ -/* define everything to be empty */ -#else - -/* system */ -#define snmp_set_sysdesr(str, len) -#define snmp_set_sysobjid(oid); -#define snmp_get_sysobjid_ptr(oid) -#define snmp_inc_sysuptime() -#define snmp_add_sysuptime(value) -#define snmp_get_sysuptime(value) -#define snmp_set_syscontact(ocstr, ocstrlen); -#define snmp_set_sysname(ocstr, ocstrlen); -#define snmp_set_syslocation(ocstr, ocstrlen); - -/* network interface */ -#define snmp_add_ifinoctets(ni,value) -#define snmp_inc_ifinucastpkts(ni) -#define snmp_inc_ifinnucastpkts(ni) -#define snmp_inc_ifindiscards(ni) -#define snmp_add_ifoutoctets(ni,value) -#define snmp_inc_ifoutucastpkts(ni) -#define snmp_inc_ifoutnucastpkts(ni) -#define snmp_inc_ifoutdiscards(ni) -#define snmp_inc_iflist() -#define snmp_dec_iflist() - -/* ARP */ -#define snmp_insert_arpidx_tree(ni,ip) -#define snmp_delete_arpidx_tree(ni,ip) - -/* IP */ -#define snmp_inc_ipinreceives() -#define snmp_inc_ipinhdrerrors() -#define snmp_inc_ipinaddrerrors() -#define snmp_inc_ipforwdatagrams() -#define snmp_inc_ipinunknownprotos() -#define snmp_inc_ipindiscards() -#define snmp_inc_ipindelivers() -#define snmp_inc_ipoutrequests() -#define snmp_inc_ipoutdiscards() -#define snmp_inc_ipoutnoroutes() -#define snmp_inc_ipreasmreqds() -#define snmp_inc_ipreasmoks() -#define snmp_inc_ipreasmfails() -#define snmp_inc_ipfragoks() -#define snmp_inc_ipfragfails() -#define snmp_inc_ipfragcreates() -#define snmp_inc_iproutingdiscards() -#define snmp_insert_ipaddridx_tree(ni) -#define snmp_delete_ipaddridx_tree(ni) -#define snmp_insert_iprteidx_tree(dflt, ni) -#define snmp_delete_iprteidx_tree(dflt, ni) - -/* ICMP */ -#define snmp_inc_icmpinmsgs() -#define snmp_inc_icmpinerrors() -#define snmp_inc_icmpindestunreachs() -#define snmp_inc_icmpintimeexcds() -#define snmp_inc_icmpinparmprobs() -#define snmp_inc_icmpinsrcquenchs() -#define snmp_inc_icmpinredirects() -#define snmp_inc_icmpinechos() -#define snmp_inc_icmpinechoreps() -#define snmp_inc_icmpintimestamps() -#define snmp_inc_icmpintimestampreps() -#define snmp_inc_icmpinaddrmasks() -#define snmp_inc_icmpinaddrmaskreps() -#define snmp_inc_icmpoutmsgs() -#define snmp_inc_icmpouterrors() -#define snmp_inc_icmpoutdestunreachs() -#define snmp_inc_icmpouttimeexcds() -#define snmp_inc_icmpoutparmprobs() -#define snmp_inc_icmpoutsrcquenchs() -#define snmp_inc_icmpoutredirects() -#define snmp_inc_icmpoutechos() -#define snmp_inc_icmpoutechoreps() -#define snmp_inc_icmpouttimestamps() -#define snmp_inc_icmpouttimestampreps() -#define snmp_inc_icmpoutaddrmasks() -#define snmp_inc_icmpoutaddrmaskreps() -/* TCP */ -#define snmp_inc_tcpactiveopens() -#define snmp_inc_tcppassiveopens() -#define snmp_inc_tcpattemptfails() -#define snmp_inc_tcpestabresets() -#define snmp_inc_tcpinsegs() -#define snmp_inc_tcpoutsegs() -#define snmp_inc_tcpretranssegs() -#define snmp_inc_tcpinerrs() -#define snmp_inc_tcpoutrsts() - -/* UDP */ -#define snmp_inc_udpindatagrams() -#define snmp_inc_udpnoports() -#define snmp_inc_udpinerrors() -#define snmp_inc_udpoutdatagrams() -#define snmp_insert_udpidx_tree(pcb) -#define snmp_delete_udpidx_tree(pcb) - -/* SNMP */ -#define snmp_inc_snmpinpkts() -#define snmp_inc_snmpoutpkts() -#define snmp_inc_snmpinbadversions() -#define snmp_inc_snmpinbadcommunitynames() -#define snmp_inc_snmpinbadcommunityuses() -#define snmp_inc_snmpinasnparseerrs() -#define snmp_inc_snmpintoobigs() -#define snmp_inc_snmpinnosuchnames() -#define snmp_inc_snmpinbadvalues() -#define snmp_inc_snmpinreadonlys() -#define snmp_inc_snmpingenerrs() -#define snmp_add_snmpintotalreqvars(value) -#define snmp_add_snmpintotalsetvars(value) -#define snmp_inc_snmpingetrequests() -#define snmp_inc_snmpingetnexts() -#define snmp_inc_snmpinsetrequests() -#define snmp_inc_snmpingetresponses() -#define snmp_inc_snmpintraps() -#define snmp_inc_snmpouttoobigs() -#define snmp_inc_snmpoutnosuchnames() -#define snmp_inc_snmpoutbadvalues() -#define snmp_inc_snmpoutgenerrs() -#define snmp_inc_snmpoutgetrequests() -#define snmp_inc_snmpoutgetnexts() -#define snmp_inc_snmpoutsetrequests() -#define snmp_inc_snmpoutgetresponses() -#define snmp_inc_snmpouttraps() -#define snmp_get_snmpgrpid_ptr(oid) -#define snmp_set_snmpenableauthentraps(value) -#define snmp_get_snmpenableauthentraps(value) - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_SNMP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h b/user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h deleted file mode 100644 index 605fa3f..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/snmp_asn1.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file - * Abstract Syntax Notation One (ISO 8824, 8825) codec. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#ifndef __LWIP_SNMP_ASN1_H__ -#define __LWIP_SNMP_ASN1_H__ - -#include "lwip/opt.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" -#include "lwip/snmp.h" - -#if LWIP_SNMP - -#ifdef __cplusplus -extern "C" { -#endif - -#define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ -#define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ -#define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ - -#define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ -#define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ - -/* universal tags */ -#define SNMP_ASN1_INTEG 2 -#define SNMP_ASN1_OC_STR 4 -#define SNMP_ASN1_NUL 5 -#define SNMP_ASN1_OBJ_ID 6 -#define SNMP_ASN1_SEQ 16 - -/* application specific (SNMP) tags */ -#define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ -#define SNMP_ASN1_COUNTER 1 /* u32_t */ -#define SNMP_ASN1_GAUGE 2 /* u32_t */ -#define SNMP_ASN1_TIMETICKS 3 /* u32_t */ -#define SNMP_ASN1_OPAQUE 4 /* octet string */ - -/* context specific (SNMP) tags */ -#define SNMP_ASN1_PDU_GET_REQ 0 -#define SNMP_ASN1_PDU_GET_NEXT_REQ 1 -#define SNMP_ASN1_PDU_GET_RESP 2 -#define SNMP_ASN1_PDU_SET_REQ 3 -#define SNMP_ASN1_PDU_TRAP 4 - -err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); -err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); -err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); -err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); -err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); -err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); - -void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); -void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); -void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); -void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); -err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); -err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); -err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); -err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); -err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); -err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* __LWIP_SNMP_ASN1_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp_msg.h b/user/mpy/lib/lwip/src/include/lwip/snmp_msg.h deleted file mode 100644 index 1183e3a..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/snmp_msg.h +++ /dev/null @@ -1,315 +0,0 @@ -/** - * @file - * SNMP Agent message handling structures. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#ifndef __LWIP_SNMP_MSG_H__ -#define __LWIP_SNMP_MSG_H__ - -#include "lwip/opt.h" -#include "lwip/snmp.h" -#include "lwip/snmp_structs.h" -#include "lwip/ip_addr.h" -#include "lwip/err.h" - -#if LWIP_SNMP - -#if SNMP_PRIVATE_MIB -/* When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. */ -#include "private_mib.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* The listen port of the SNMP agent. Clients have to make their requests to - this port. Most standard clients won't work if you change this! */ -#ifndef SNMP_IN_PORT -#define SNMP_IN_PORT 161 -#endif -/* The remote port the SNMP agent sends traps to. Most standard trap sinks won't - work if you change this! */ -#ifndef SNMP_TRAP_PORT -#define SNMP_TRAP_PORT 162 -#endif - -#define SNMP_ES_NOERROR 0 -#define SNMP_ES_TOOBIG 1 -#define SNMP_ES_NOSUCHNAME 2 -#define SNMP_ES_BADVALUE 3 -#define SNMP_ES_READONLY 4 -#define SNMP_ES_GENERROR 5 - -#define SNMP_GENTRAP_COLDSTART 0 -#define SNMP_GENTRAP_WARMSTART 1 -#define SNMP_GENTRAP_AUTHFAIL 4 -#define SNMP_GENTRAP_ENTERPRISESPC 6 - -struct snmp_varbind -{ - /* next pointer, NULL for last in list */ - struct snmp_varbind *next; - /* previous pointer, NULL for first in list */ - struct snmp_varbind *prev; - - /* object identifier length (in s32_t) */ - u8_t ident_len; - /* object identifier array */ - s32_t *ident; - - /* object value ASN1 type */ - u8_t value_type; - /* object value length (in u8_t) */ - u8_t value_len; - /* object value */ - void *value; - - /* encoding varbind seq length length */ - u8_t seqlenlen; - /* encoding object identifier length length */ - u8_t olenlen; - /* encoding object value length length */ - u8_t vlenlen; - /* encoding varbind seq length */ - u16_t seqlen; - /* encoding object identifier length */ - u16_t olen; - /* encoding object value length */ - u16_t vlen; -}; - -struct snmp_varbind_root -{ - struct snmp_varbind *head; - struct snmp_varbind *tail; - /* number of variable bindings in list */ - u8_t count; - /* encoding varbind-list seq length length */ - u8_t seqlenlen; - /* encoding varbind-list seq length */ - u16_t seqlen; -}; - -/** output response message header length fields */ -struct snmp_resp_header_lengths -{ - /* encoding error-index length length */ - u8_t erridxlenlen; - /* encoding error-status length length */ - u8_t errstatlenlen; - /* encoding request id length length */ - u8_t ridlenlen; - /* encoding pdu length length */ - u8_t pdulenlen; - /* encoding community length length */ - u8_t comlenlen; - /* encoding version length length */ - u8_t verlenlen; - /* encoding sequence length length */ - u8_t seqlenlen; - - /* encoding error-index length */ - u16_t erridxlen; - /* encoding error-status length */ - u16_t errstatlen; - /* encoding request id length */ - u16_t ridlen; - /* encoding pdu length */ - u16_t pdulen; - /* encoding community length */ - u16_t comlen; - /* encoding version length */ - u16_t verlen; - /* encoding sequence length */ - u16_t seqlen; -}; - -/** output response message header length fields */ -struct snmp_trap_header_lengths -{ - /* encoding timestamp length length */ - u8_t tslenlen; - /* encoding specific-trap length length */ - u8_t strplenlen; - /* encoding generic-trap length length */ - u8_t gtrplenlen; - /* encoding agent-addr length length */ - u8_t aaddrlenlen; - /* encoding enterprise-id length length */ - u8_t eidlenlen; - /* encoding pdu length length */ - u8_t pdulenlen; - /* encoding community length length */ - u8_t comlenlen; - /* encoding version length length */ - u8_t verlenlen; - /* encoding sequence length length */ - u8_t seqlenlen; - - /* encoding timestamp length */ - u16_t tslen; - /* encoding specific-trap length */ - u16_t strplen; - /* encoding generic-trap length */ - u16_t gtrplen; - /* encoding agent-addr length */ - u16_t aaddrlen; - /* encoding enterprise-id length */ - u16_t eidlen; - /* encoding pdu length */ - u16_t pdulen; - /* encoding community length */ - u16_t comlen; - /* encoding version length */ - u16_t verlen; - /* encoding sequence length */ - u16_t seqlen; -}; - -/* Accepting new SNMP messages. */ -#define SNMP_MSG_EMPTY 0 -/* Search for matching object for variable binding. */ -#define SNMP_MSG_SEARCH_OBJ 1 -/* Perform SNMP operation on in-memory object. - Pass-through states, for symmetry only. */ -#define SNMP_MSG_INTERNAL_GET_OBJDEF 2 -#define SNMP_MSG_INTERNAL_GET_VALUE 3 -#define SNMP_MSG_INTERNAL_SET_TEST 4 -#define SNMP_MSG_INTERNAL_GET_OBJDEF_S 5 -#define SNMP_MSG_INTERNAL_SET_VALUE 6 -/* Perform SNMP operation on object located externally. - In theory this could be used for building a proxy agent. - Practical use is for an enterprise spc. app. gateway. */ -#define SNMP_MSG_EXTERNAL_GET_OBJDEF 7 -#define SNMP_MSG_EXTERNAL_GET_VALUE 8 -#define SNMP_MSG_EXTERNAL_SET_TEST 9 -#define SNMP_MSG_EXTERNAL_GET_OBJDEF_S 10 -#define SNMP_MSG_EXTERNAL_SET_VALUE 11 - -#define SNMP_COMMUNITY_STR_LEN 64 -struct snmp_msg_pstat -{ - /* lwIP local port (161) binding */ - struct udp_pcb *pcb; - /* source IP address */ - ip_addr_t sip; - /* source UDP port */ - u16_t sp; - /* request type */ - u8_t rt; - /* request ID */ - s32_t rid; - /* error status */ - s32_t error_status; - /* error index */ - s32_t error_index; - /* community name (zero terminated) */ - u8_t community[SNMP_COMMUNITY_STR_LEN + 1]; - /* community string length (exclusive zero term) */ - u8_t com_strlen; - /* one out of MSG_EMPTY, MSG_DEMUX, MSG_INTERNAL, MSG_EXTERNAL_x */ - u8_t state; - /* saved arguments for MSG_EXTERNAL_x */ - struct mib_external_node *ext_mib_node; - struct snmp_name_ptr ext_name_ptr; - struct obj_def ext_object_def; - struct snmp_obj_id ext_oid; - /* index into input variable binding list */ - u8_t vb_idx; - /* ptr into input variable binding list */ - struct snmp_varbind *vb_ptr; - /* list of variable bindings from input */ - struct snmp_varbind_root invb; - /* list of variable bindings to output */ - struct snmp_varbind_root outvb; - /* output response lengths used in ASN encoding */ - struct snmp_resp_header_lengths rhl; -}; - -struct snmp_msg_trap -{ - /* lwIP local port (161) binding */ - struct udp_pcb *pcb; - /* destination IP address in network order */ - ip_addr_t dip; - - /* source enterprise ID (sysObjectID) */ - struct snmp_obj_id *enterprise; - /* source IP address, raw network order format */ - u8_t sip_raw[4]; - /* generic trap code */ - u32_t gen_trap; - /* specific trap code */ - u32_t spc_trap; - /* timestamp */ - u32_t ts; - /* list of variable bindings to output */ - struct snmp_varbind_root outvb; - /* output trap lengths used in ASN encoding */ - struct snmp_trap_header_lengths thl; -}; - -/** Agent Version constant, 0 = v1 oddity */ -extern const s32_t snmp_version; -/** Agent default "public" community string */ -extern const char snmp_publiccommunity[7]; - -extern struct snmp_msg_trap trap_msg; - -/** Agent setup, start listening to port 161. */ -void snmp_init(void); -void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); -void snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst); - -/** Varbind-list functions. */ -struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len); -void snmp_varbind_free(struct snmp_varbind *vb); -void snmp_varbind_list_free(struct snmp_varbind_root *root); -void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb); -struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root); - -/** Handle an internal (recv) or external (private response) event. */ -void snmp_msg_event(u8_t request_id); -err_t snmp_send_response(struct snmp_msg_pstat *m_stat); -err_t snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap); -void snmp_coldstart_trap(void); -void snmp_authfail_trap(void); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* __LWIP_SNMP_MSG_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/snmp_structs.h b/user/mpy/lib/lwip/src/include/lwip/snmp_structs.h deleted file mode 100644 index 0d3b46a..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/snmp_structs.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @file - * Generic MIB tree structures. - * - * @todo namespace prefixes - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#ifndef __LWIP_SNMP_STRUCTS_H__ -#define __LWIP_SNMP_STRUCTS_H__ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp.h" - -#if SNMP_PRIVATE_MIB -/* When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. */ -#include "private_mib.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* MIB object instance */ -#define MIB_OBJECT_NONE 0 -#define MIB_OBJECT_SCALAR 1 -#define MIB_OBJECT_TAB 2 - -/* MIB access types */ -#define MIB_ACCESS_READ 1 -#define MIB_ACCESS_WRITE 2 - -/* MIB object access */ -#define MIB_OBJECT_READ_ONLY MIB_ACCESS_READ -#define MIB_OBJECT_READ_WRITE (MIB_ACCESS_READ | MIB_ACCESS_WRITE) -#define MIB_OBJECT_WRITE_ONLY MIB_ACCESS_WRITE -#define MIB_OBJECT_NOT_ACCESSIBLE 0 - -/** object definition returned by (get_object_def)() */ -struct obj_def -{ - /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */ - u8_t instance; - /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */ - u8_t access; - /* ASN type for this object */ - u8_t asn_type; - /* value length (host length) */ - u16_t v_len; - /* length of instance part of supplied object identifier */ - u8_t id_inst_len; - /* instance part of supplied object identifier */ - s32_t *id_inst_ptr; -}; - -struct snmp_name_ptr -{ - u8_t ident_len; - s32_t *ident; -}; - -/** MIB const scalar (.0) node */ -#define MIB_NODE_SC 0x01 -/** MIB const array node */ -#define MIB_NODE_AR 0x02 -/** MIB array node (mem_malloced from RAM) */ -#define MIB_NODE_RA 0x03 -/** MIB list root node (mem_malloced from RAM) */ -#define MIB_NODE_LR 0x04 -/** MIB node for external objects */ -#define MIB_NODE_EX 0x05 - -/** node "base class" layout, the mandatory fields for a node */ -struct mib_node -{ - /** returns struct obj_def for the given object identifier */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - /** returns object value for the given object identifier, - @note the caller must allocate at least len bytes for the value */ - void (*get_value)(struct obj_def *od, u16_t len, void *value); - /** tests length and/or range BEFORE setting */ - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - /** sets object value, only to be called when set_test() */ - void (*set_value)(struct obj_def *od, u16_t len, void *value); - /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */ - u8_t node_type; - /* array or max list length */ - u16_t maxlength; -}; - -/** derived node for scalars .0 index */ -typedef struct mib_node mib_scalar_node; - -/** derived node, points to a fixed size const array - of sub-identifiers plus a 'child' pointer */ -struct mib_array_node -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* additional struct members */ - const s32_t *objid; - struct mib_node* const *nptr; -}; - -/** derived node, points to a fixed size mem_malloced array - of sub-identifiers plus a 'child' pointer */ -struct mib_ram_array_node -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* aditional struct members */ - s32_t *objid; - struct mib_node **nptr; -}; - -struct mib_list_node -{ - struct mib_list_node *prev; - struct mib_list_node *next; - s32_t objid; - struct mib_node *nptr; -}; - -/** derived node, points to a doubly linked list - of sub-identifiers plus a 'child' pointer */ -struct mib_list_rootnode -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* additional struct members */ - struct mib_list_node *head; - struct mib_list_node *tail; - /* counts list nodes in list */ - u16_t count; -}; - -/** derived node, has access functions for mib object in external memory or device - using 'tree_level' and 'idx', with a range 0 .. (level_length() - 1) */ -struct mib_external_node -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* additional struct members */ - /** points to an external (in memory) record of some sort of addressing - information, passed to and interpreted by the funtions below */ - void* addr_inf; - /** tree levels under this node */ - u8_t tree_levels; - /** number of objects at this level */ - u16_t (*level_length)(void* addr_inf, u8_t level); - /** compares object sub identifier with external id - return zero when equal, nonzero when unequal */ - s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id); - void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id); - - /** async Questions */ - void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident); - void (*get_value_q)(u8_t rid, struct obj_def *od); - void (*set_test_q)(u8_t rid, struct obj_def *od); - void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value); - /** async Answers */ - void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - /** async Panic Close (agent returns error reply, - e.g. used for external transaction cleanup) */ - void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident); - void (*get_value_pc)(u8_t rid, struct obj_def *od); - void (*set_test_pc)(u8_t rid, struct obj_def *od); - void (*set_value_pc)(u8_t rid, struct obj_def *od); -}; - -/** export MIB tree from mib2.c */ -extern const struct mib_array_node internet; - -/** dummy function pointers for non-leaf MIB nodes from mib2.c */ -void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -void noleafs_get_value(struct obj_def *od, u16_t len, void *value); -u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value); -void noleafs_set_value(struct obj_def *od, u16_t len, void *value); - -void snmp_oidtoip(s32_t *ident, ip_addr_t *ip); -void snmp_iptooid(ip_addr_t *ip, s32_t *ident); -void snmp_ifindextonetif(s32_t ifindex, struct netif **netif); -void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx); - -struct mib_list_node* snmp_mib_ln_alloc(s32_t id); -void snmp_mib_ln_free(struct mib_list_node *ln); -struct mib_list_rootnode* snmp_mib_lrn_alloc(void); -void snmp_mib_lrn_free(struct mib_list_rootnode *lrn); - -s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn); -s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn); -struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n); - -struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np); -struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); -u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident); -u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* __LWIP_SNMP_STRUCTS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/sockets.h b/user/mpy/lib/lwip/src/include/lwip/sockets.h deleted file mode 100644 index 3ea32f1..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/sockets.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - -#ifndef __LWIP_SOCKETS_H__ -#define __LWIP_SOCKETS_H__ - -#include "lwip/opt.h" - -#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -#include /* for size_t */ - -#include "lwip/ip_addr.h" -#include "lwip/inet.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* members are in network byte order */ -struct sockaddr_in { - u8_t sin_len; - u8_t sin_family; - u16_t sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; - -struct sockaddr { - u8_t sa_len; - u8_t sa_family; - char sa_data[14]; -}; - -/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED - to prevent this code from redefining it. */ -#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) -typedef u32_t socklen_t; -#endif - -/* Socket protocol types (TCP/UDP/RAW) */ -#define SOCK_STREAM 1 -#define SOCK_DGRAM 2 -#define SOCK_RAW 3 - -/* - * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c) - */ -#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_REUSEADDR 0x0004 /* Allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ -#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ -#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */ -#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */ - -#define SO_DONTLINGER ((int)(~SO_LINGER)) - -/* - * Additional options, not kept in so_options. - */ -#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* Unimplemented: send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ -#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */ -#define SO_NO_CHECK 0x100a /* don't create UDP checksum */ - - -/* - * Structure used for manipulating linger option. - */ -struct linger { - int l_onoff; /* option on/off */ - int l_linger; /* linger time */ -}; - -/* - * Level number for (get/set)sockopt() to apply to socket itself. - */ -#define SOL_SOCKET 0xfff /* options for socket level */ - - -#define AF_UNSPEC 0 -#define AF_INET 2 -#define PF_INET AF_INET -#define PF_UNSPEC AF_UNSPEC - -#define IPPROTO_IP 0 -#define IPPROTO_TCP 6 -#define IPPROTO_UDP 17 -#define IPPROTO_UDPLITE 136 - -/* Flags we can use with send and recv. */ -#define MSG_PEEK 0x01 /* Peeks at an incoming message */ -#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */ -#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */ -#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */ -#define MSG_MORE 0x10 /* Sender will send more */ - - -/* - * Options for level IPPROTO_IP - */ -#define IP_TOS 1 -#define IP_TTL 2 - -#if LWIP_TCP -/* - * Options for level IPPROTO_TCP - */ -#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ -#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */ -#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */ -#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */ -#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */ -#endif /* LWIP_TCP */ - -#if LWIP_UDP && LWIP_UDPLITE -/* - * Options for level IPPROTO_UDPLITE - */ -#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ -#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ -#endif /* LWIP_UDP && LWIP_UDPLITE*/ - - -#if LWIP_IGMP -/* - * Options and types for UDP multicast traffic handling - */ -#define IP_ADD_MEMBERSHIP 3 -#define IP_DROP_MEMBERSHIP 4 -#define IP_MULTICAST_TTL 5 -#define IP_MULTICAST_IF 6 -#define IP_MULTICAST_LOOP 7 - -typedef struct ip_mreq { - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_interface; /* local IP address of interface */ -} ip_mreq; -#endif /* LWIP_IGMP */ - -/* - * The Type of Service provides an indication of the abstract - * parameters of the quality of service desired. These parameters are - * to be used to guide the selection of the actual service parameters - * when transmitting a datagram through a particular network. Several - * networks offer service precedence, which somehow treats high - * precedence traffic as more important than other traffic (generally - * by accepting only traffic above a certain precedence at time of high - * load). The major choice is a three way tradeoff between low-delay, - * high-reliability, and high-throughput. - * The use of the Delay, Throughput, and Reliability indications may - * increase the cost (in some sense) of the service. In many networks - * better performance for one of these parameters is coupled with worse - * performance on another. Except for very unusual cases at most two - * of these three indications should be set. - */ -#define IPTOS_TOS_MASK 0x1E -#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#define IPTOS_LOWCOST 0x02 -#define IPTOS_MINCOST IPTOS_LOWCOST - -/* - * The Network Control precedence designation is intended to be used - * within a network only. The actual use and control of that - * designation is up to each network. The Internetwork Control - * designation is intended for use by gateway control originators only. - * If the actual use of these precedence designations is of concern to - * a particular network, it is the responsibility of that network to - * control the access to, and use of, those precedence designations. - */ -#define IPTOS_PREC_MASK 0xe0 -#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) -#define IPTOS_PREC_NETCONTROL 0xe0 -#define IPTOS_PREC_INTERNETCONTROL 0xc0 -#define IPTOS_PREC_CRITIC_ECP 0xa0 -#define IPTOS_PREC_FLASHOVERRIDE 0x80 -#define IPTOS_PREC_FLASH 0x60 -#define IPTOS_PREC_IMMEDIATE 0x40 -#define IPTOS_PREC_PRIORITY 0x20 -#define IPTOS_PREC_ROUTINE 0x00 - - -/* - * Commands for ioctlsocket(), taken from the BSD file fcntl.h. - * lwip_ioctl only supports FIONREAD and FIONBIO, for now - * - * Ioctl's have the command encoded in the lower word, - * and the size of any in or out parameters in the upper - * word. The high 2 bits of the upper word are used - * to encode the in/out status of the parameter; for now - * we restrict parameters to at most 128 bytes. - */ -#if !defined(FIONREAD) || !defined(FIONBIO) -#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000UL /* no parameters */ -#define IOC_OUT 0x40000000UL /* copy out parameters */ -#define IOC_IN 0x80000000UL /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) - /* 0x20000000 distinguishes new & - old ioctl's */ -#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) - -#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) - -#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) -#endif /* !defined(FIONREAD) || !defined(FIONBIO) */ - -#ifndef FIONREAD -#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */ -#endif -#ifndef FIONBIO -#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */ -#endif - -/* Socket I/O Controls: unimplemented */ -#ifndef SIOCSHIWAT -#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */ -#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */ -#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */ -#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */ -#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */ -#endif - -/* commands for fnctl */ -#ifndef F_GETFL -#define F_GETFL 3 -#endif -#ifndef F_SETFL -#define F_SETFL 4 -#endif - -/* File status flags and file access modes for fnctl, - these are bits in an int. */ -#ifndef O_NONBLOCK -#define O_NONBLOCK 1 /* nonblocking I/O */ -#endif -#ifndef O_NDELAY -#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */ -#endif - -#ifndef SHUT_RD - #define SHUT_RD 0 - #define SHUT_WR 1 - #define SHUT_RDWR 2 -#endif - -/* FD_SET used for lwip_select */ -#ifndef FD_SET - #undef FD_SETSIZE - /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */ - #define FD_SETSIZE MEMP_NUM_NETCONN - #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7))) - #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7))) - #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7))) - #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p))) - - typedef struct fd_set { - unsigned char fd_bits [(FD_SETSIZE+7)/8]; - } fd_set; - -#endif /* FD_SET */ - -/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided - * by your system, set this to 0 and include in cc.h */ -#ifndef LWIP_TIMEVAL_PRIVATE -#define LWIP_TIMEVAL_PRIVATE 1 -#endif - -#if LWIP_TIMEVAL_PRIVATE -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; -#endif /* LWIP_TIMEVAL_PRIVATE */ - -void lwip_socket_init(void); - -int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen); -int lwip_shutdown(int s, int how); -int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); -int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); -int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); -int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); -int lwip_close(int s); -int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); -int lwip_listen(int s, int backlog); -int lwip_recv(int s, void *mem, size_t len, int flags); -int lwip_read(int s, void *mem, size_t len); -int lwip_recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen); -int lwip_send(int s, const void *dataptr, size_t size, int flags); -int lwip_sendto(int s, const void *dataptr, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen); -int lwip_socket(int domain, int type, int protocol); -int lwip_write(int s, const void *dataptr, size_t size); -int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, - struct timeval *timeout); -int lwip_ioctl(int s, long cmd, void *argp); -int lwip_fcntl(int s, int cmd, int val); - -#if LWIP_COMPAT_SOCKETS -#define accept(a,b,c) lwip_accept(a,b,c) -#define bind(a,b,c) lwip_bind(a,b,c) -#define shutdown(a,b) lwip_shutdown(a,b) -#define closesocket(s) lwip_close(s) -#define connect(a,b,c) lwip_connect(a,b,c) -#define getsockname(a,b,c) lwip_getsockname(a,b,c) -#define getpeername(a,b,c) lwip_getpeername(a,b,c) -#define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e) -#define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e) -#define listen(a,b) lwip_listen(a,b) -#define recv(a,b,c,d) lwip_recv(a,b,c,d) -#define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f) -#define send(a,b,c,d) lwip_send(a,b,c,d) -#define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f) -#define socket(a,b,c) lwip_socket(a,b,c) -#define select(a,b,c,d,e) lwip_select(a,b,c,d,e) -#define ioctlsocket(a,b,c) lwip_ioctl(a,b,c) - -#if LWIP_POSIX_SOCKETS_IO_NAMES -#define read(a,b,c) lwip_read(a,b,c) -#define write(a,b,c) lwip_write(a,b,c) -#define close(s) lwip_close(s) -#define fcntl(a,b,c) lwip_fcntl(a,b,c) -#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */ - -#endif /* LWIP_COMPAT_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SOCKET */ - -#endif /* __LWIP_SOCKETS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/stats.h b/user/mpy/lib/lwip/src/include/lwip/stats.h deleted file mode 100644 index 1f5152a..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/stats.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_STATS_H__ -#define __LWIP_STATS_H__ - -#include "lwip/opt.h" - -#include "lwip/mem.h" -#include "lwip/memp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_STATS - -#ifndef LWIP_STATS_LARGE -#define LWIP_STATS_LARGE 0 -#endif - -#if LWIP_STATS_LARGE -#define STAT_COUNTER u32_t -#define STAT_COUNTER_F U32_F -#else -#define STAT_COUNTER u16_t -#define STAT_COUNTER_F U16_F -#endif - -struct stats_proto { - STAT_COUNTER xmit; /* Transmitted packets. */ - STAT_COUNTER recv; /* Received packets. */ - STAT_COUNTER fw; /* Forwarded packets. */ - STAT_COUNTER drop; /* Dropped packets. */ - STAT_COUNTER chkerr; /* Checksum error. */ - STAT_COUNTER lenerr; /* Invalid length error. */ - STAT_COUNTER memerr; /* Out of memory error. */ - STAT_COUNTER rterr; /* Routing error. */ - STAT_COUNTER proterr; /* Protocol error. */ - STAT_COUNTER opterr; /* Error in options. */ - STAT_COUNTER err; /* Misc error. */ - STAT_COUNTER cachehit; -}; - -struct stats_igmp { - STAT_COUNTER xmit; /* Transmitted packets. */ - STAT_COUNTER recv; /* Received packets. */ - STAT_COUNTER drop; /* Dropped packets. */ - STAT_COUNTER chkerr; /* Checksum error. */ - STAT_COUNTER lenerr; /* Invalid length error. */ - STAT_COUNTER memerr; /* Out of memory error. */ - STAT_COUNTER proterr; /* Protocol error. */ - STAT_COUNTER rx_v1; /* Received v1 frames. */ - STAT_COUNTER rx_group; /* Received group-specific queries. */ - STAT_COUNTER rx_general; /* Received general queries. */ - STAT_COUNTER rx_report; /* Received reports. */ - STAT_COUNTER tx_join; /* Sent joins. */ - STAT_COUNTER tx_leave; /* Sent leaves. */ - STAT_COUNTER tx_report; /* Sent reports. */ -}; - -struct stats_mem { -#ifdef LWIP_DEBUG - const char *name; -#endif /* LWIP_DEBUG */ - mem_size_t avail; - mem_size_t used; - mem_size_t max; - STAT_COUNTER err; - STAT_COUNTER illegal; -}; - -struct stats_syselem { - STAT_COUNTER used; - STAT_COUNTER max; - STAT_COUNTER err; -}; - -struct stats_sys { - struct stats_syselem sem; - struct stats_syselem mutex; - struct stats_syselem mbox; -}; - -struct stats_ { -#if LINK_STATS - struct stats_proto link; -#endif -#if ETHARP_STATS - struct stats_proto etharp; -#endif -#if IPFRAG_STATS - struct stats_proto ip_frag; -#endif -#if IP_STATS - struct stats_proto ip; -#endif -#if ICMP_STATS - struct stats_proto icmp; -#endif -#if IGMP_STATS - struct stats_igmp igmp; -#endif -#if UDP_STATS - struct stats_proto udp; -#endif -#if TCP_STATS - struct stats_proto tcp; -#endif -#if MEM_STATS - struct stats_mem mem; -#endif -#if MEMP_STATS - struct stats_mem memp[MEMP_MAX]; -#endif -#if SYS_STATS - struct stats_sys sys; -#endif -}; - -extern struct stats_ lwip_stats; - -void stats_init(void); - -#define STATS_INC(x) ++lwip_stats.x -#define STATS_DEC(x) --lwip_stats.x -#define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \ - if (lwip_stats.x.max < lwip_stats.x.used) { \ - lwip_stats.x.max = lwip_stats.x.used; \ - } \ - } while(0) -#else /* LWIP_STATS */ -#define stats_init() -#define STATS_INC(x) -#define STATS_DEC(x) -#define STATS_INC_USED(x) -#endif /* LWIP_STATS */ - -#if TCP_STATS -#define TCP_STATS_INC(x) STATS_INC(x) -#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP") -#else -#define TCP_STATS_INC(x) -#define TCP_STATS_DISPLAY() -#endif - -#if UDP_STATS -#define UDP_STATS_INC(x) STATS_INC(x) -#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP") -#else -#define UDP_STATS_INC(x) -#define UDP_STATS_DISPLAY() -#endif - -#if ICMP_STATS -#define ICMP_STATS_INC(x) STATS_INC(x) -#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP") -#else -#define ICMP_STATS_INC(x) -#define ICMP_STATS_DISPLAY() -#endif - -#if IGMP_STATS -#define IGMP_STATS_INC(x) STATS_INC(x) -#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp) -#else -#define IGMP_STATS_INC(x) -#define IGMP_STATS_DISPLAY() -#endif - -#if IP_STATS -#define IP_STATS_INC(x) STATS_INC(x) -#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP") -#else -#define IP_STATS_INC(x) -#define IP_STATS_DISPLAY() -#endif - -#if IPFRAG_STATS -#define IPFRAG_STATS_INC(x) STATS_INC(x) -#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG") -#else -#define IPFRAG_STATS_INC(x) -#define IPFRAG_STATS_DISPLAY() -#endif - -#if ETHARP_STATS -#define ETHARP_STATS_INC(x) STATS_INC(x) -#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP") -#else -#define ETHARP_STATS_INC(x) -#define ETHARP_STATS_DISPLAY() -#endif - -#if LINK_STATS -#define LINK_STATS_INC(x) STATS_INC(x) -#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK") -#else -#define LINK_STATS_INC(x) -#define LINK_STATS_DISPLAY() -#endif - -#if MEM_STATS -#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y -#define MEM_STATS_INC(x) STATS_INC(mem.x) -#define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y) -#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y -#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP") -#else -#define MEM_STATS_AVAIL(x, y) -#define MEM_STATS_INC(x) -#define MEM_STATS_INC_USED(x, y) -#define MEM_STATS_DEC_USED(x, y) -#define MEM_STATS_DISPLAY() -#endif - -#if MEMP_STATS -#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y -#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x) -#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x) -#define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1) -#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i) -#else -#define MEMP_STATS_AVAIL(x, i, y) -#define MEMP_STATS_INC(x, i) -#define MEMP_STATS_DEC(x, i) -#define MEMP_STATS_INC_USED(x, i) -#define MEMP_STATS_DISPLAY(i) -#endif - -#if SYS_STATS -#define SYS_STATS_INC(x) STATS_INC(sys.x) -#define SYS_STATS_DEC(x) STATS_DEC(sys.x) -#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1) -#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys) -#else -#define SYS_STATS_INC(x) -#define SYS_STATS_DEC(x) -#define SYS_STATS_INC_USED(x) -#define SYS_STATS_DISPLAY() -#endif - -/* Display of statistics */ -#if LWIP_STATS_DISPLAY -void stats_display(void); -void stats_display_proto(struct stats_proto *proto, const char *name); -void stats_display_igmp(struct stats_igmp *igmp); -void stats_display_mem(struct stats_mem *mem, const char *name); -void stats_display_memp(struct stats_mem *mem, int index); -void stats_display_sys(struct stats_sys *sys); -#else /* LWIP_STATS_DISPLAY */ -#define stats_display() -#define stats_display_proto(proto, name) -#define stats_display_igmp(igmp) -#define stats_display_mem(mem, name) -#define stats_display_memp(mem, index) -#define stats_display_sys(sys) -#endif /* LWIP_STATS_DISPLAY */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_STATS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/sys.h b/user/mpy/lib/lwip/src/include/lwip/sys.h deleted file mode 100644 index dc93513..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/sys.h +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_SYS_H__ -#define __LWIP_SYS_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if NO_SYS - -/* For a totally minimal and standalone system, we provide null - definitions of the sys_ functions. */ -typedef u8_t sys_sem_t; -typedef u8_t sys_mutex_t; -typedef u8_t sys_mbox_t; - -#define sys_sem_new(s, c) ERR_OK -#define sys_sem_signal(s) -#define sys_sem_wait(s) -#define sys_arch_sem_wait(s,t) -#define sys_sem_free(s) -#define sys_sem_valid(s) 0 -#define sys_sem_set_invalid(s) -#define sys_mutex_new(mu) ERR_OK -#define sys_mutex_lock(mu) -#define sys_mutex_unlock(mu) -#define sys_mutex_free(mu) -#define sys_mutex_valid(mu) 0 -#define sys_mutex_set_invalid(mu) -#define sys_mbox_new(m, s) ERR_OK -#define sys_mbox_fetch(m,d) -#define sys_mbox_tryfetch(m,d) -#define sys_mbox_post(m,d) -#define sys_mbox_trypost(m,d) -#define sys_mbox_free(m) -#define sys_mbox_valid(m) -#define sys_mbox_set_invalid(m) - -#define sys_thread_new(n,t,a,s,p) - -#define sys_msleep(t) - -#else /* NO_SYS */ - -/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ -#define SYS_ARCH_TIMEOUT 0xffffffffUL - -/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. - * For now we use the same magic value, but we allow this to change in future. - */ -#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT - -#include "lwip/err.h" -#include "arch/sys_arch.h" - -/** Function prototype for thread functions */ -typedef void (*lwip_thread_fn)(void *arg); - -/* Function prototypes for functions to be implemented by platform ports - (in sys_arch.c) */ - -/* Mutex functions: */ - -/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores - should be used instead */ -#if LWIP_COMPAT_MUTEX -/* for old ports that don't have mutexes: define them to binary semaphores */ -#define sys_mutex_t sys_sem_t -#define sys_mutex_new(mutex) sys_sem_new(mutex, 1) -#define sys_mutex_lock(mutex) sys_sem_wait(mutex) -#define sys_mutex_unlock(mutex) sys_sem_signal(mutex) -#define sys_mutex_free(mutex) sys_sem_free(mutex) -#define sys_mutex_valid(mutex) sys_sem_valid(mutex) -#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) - -#else /* LWIP_COMPAT_MUTEX */ - -/** Create a new mutex - * @param mutex pointer to the mutex to create - * @return a new mutex */ -err_t sys_mutex_new(sys_mutex_t *mutex); -/** Lock a mutex - * @param mutex the mutex to lock */ -void sys_mutex_lock(sys_mutex_t *mutex); -/** Unlock a mutex - * @param mutex the mutex to unlock */ -void sys_mutex_unlock(sys_mutex_t *mutex); -/** Delete a semaphore - * @param mutex the mutex to delete */ -void sys_mutex_free(sys_mutex_t *mutex); -#ifndef sys_mutex_valid -/** Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_mutex_valid(sys_mutex_t *mutex); -#endif -#ifndef sys_mutex_set_invalid -/** Set a mutex invalid so that sys_mutex_valid returns 0 */ -void sys_mutex_set_invalid(sys_mutex_t *mutex); -#endif -#endif /* LWIP_COMPAT_MUTEX */ - -/* Semaphore functions: */ - -/** Create a new semaphore - * @param sem pointer to the semaphore to create - * @param count initial count of the semaphore - * @return ERR_OK if successful, another err_t otherwise */ -err_t sys_sem_new(sys_sem_t *sem, u8_t count); -/** Signals a semaphore - * @param sem the semaphore to signal */ -void sys_sem_signal(sys_sem_t *sem); -/** Wait for a semaphore for the specified timeout - * @param sem the semaphore to wait for - * @param timeout timeout in milliseconds to wait (0 = wait forever) - * @return time (in milliseconds) waited for the semaphore - * or SYS_ARCH_TIMEOUT on timeout */ -u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout); -/** Delete a semaphore - * @param sem semaphore to delete */ -void sys_sem_free(sys_sem_t *sem); -/** Wait for a semaphore - forever/no timeout */ -#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0) -#ifndef sys_sem_valid -/** Check if a sempahore is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_sem_valid(sys_sem_t *sem); -#endif -#ifndef sys_sem_set_invalid -/** Set a semaphore invalid so that sys_sem_valid returns 0 */ -void sys_sem_set_invalid(sys_sem_t *sem); -#endif - -/* Time functions. */ -#ifndef sys_msleep -void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */ -#endif - -/* Mailbox functions. */ - -/** Create a new mbox of specified size - * @param mbox pointer to the mbox to create - * @param size (miminum) number of messages in this mbox - * @return ERR_OK if successful, another err_t otherwise */ -err_t sys_mbox_new(sys_mbox_t *mbox, int size); -/** Post a message to an mbox - may not fail - * -> blocks if full, only used from tasks not from ISR - * @param mbox mbox to posts the message - * @param msg message to post (ATTENTION: can be NULL) */ -void sys_mbox_post(sys_mbox_t *mbox, void *msg); -/** Try to post a message to an mbox - may fail if full or ISR - * @param mbox mbox to posts the message - * @param msg message to post (ATTENTION: can be NULL) */ -err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg); -/** Wait for a new message to arrive in the mbox - * @param mbox mbox to get a message from - * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message - * @return time (in milliseconds) waited for a message, may be 0 if not waited - or SYS_ARCH_TIMEOUT on timeout - * The returned time has to be accurate to prevent timer jitter! */ -u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout); -/* Allow port to override with a macro, e.g. special timout for sys_arch_mbox_fetch() */ -#ifndef sys_arch_mbox_tryfetch -/** Wait for a new message to arrive in the mbox - * @param mbox mbox to get a message from - * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message - * @return 0 (milliseconds) if a message has been received - * or SYS_MBOX_EMPTY if the mailbox is empty */ -u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg); -#endif -/** For now, we map straight to sys_arch implementation. */ -#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) -/** Delete an mbox - * @param mbox mbox to delete */ -void sys_mbox_free(sys_mbox_t *mbox); -#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0) -#ifndef sys_mbox_valid -/** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_mbox_valid(sys_mbox_t *mbox); -#endif -#ifndef sys_mbox_set_invalid -/** Set an mbox invalid so that sys_mbox_valid returns 0 */ -void sys_mbox_set_invalid(sys_mbox_t *mbox); -#endif - -/** The only thread function: - * Creates a new thread - * @param name human-readable name for the thread (used for debugging purposes) - * @param thread thread-function - * @param arg parameter passed to 'thread' - * @param stacksize stack size in bytes for the new thread (may be ignored by ports) - * @param prio priority of the new thread (may be ignored by ports) */ -sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio); - -#endif /* NO_SYS */ - -/* sys_init() must be called before anthing else. */ -void sys_init(void); - -#ifndef sys_jiffies -/** Ticks/jiffies since power up. */ -u32_t sys_jiffies(void); -#endif - -/** Returns the current time in milliseconds, - * may be the same as sys_jiffies or at least based on it. */ -u32_t sys_now(void); - -/* Critical Region Protection */ -/* These functions must be implemented in the sys_arch.c file. - In some implementations they can provide a more light-weight protection - mechanism than using semaphores. Otherwise semaphores can be used for - implementation */ -#ifndef SYS_ARCH_PROTECT -/** SYS_LIGHTWEIGHT_PROT - * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection - * for certain critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -#if SYS_LIGHTWEIGHT_PROT - -/** SYS_ARCH_DECL_PROTECT - * declare a protection variable. This macro will default to defining a variable of - * type sys_prot_t. If a particular port needs a different implementation, then - * this macro may be defined in sys_arch.h. - */ -#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev -/** SYS_ARCH_PROTECT - * Perform a "fast" protect. This could be implemented by - * disabling interrupts for an embedded system or by using a semaphore or - * mutex. The implementation should allow calling SYS_ARCH_PROTECT when - * already protected. The old protection level is returned in the variable - * "lev". This macro will default to calling the sys_arch_protect() function - * which should be implemented in sys_arch.c. If a particular port needs a - * different implementation, then this macro may be defined in sys_arch.h - */ -#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() -/** SYS_ARCH_UNPROTECT - * Perform a "fast" set of the protection level to "lev". This could be - * implemented by setting the interrupt level to "lev" within the MACRO or by - * using a semaphore or mutex. This macro will default to calling the - * sys_arch_unprotect() function which should be implemented in - * sys_arch.c. If a particular port needs a different implementation, then - * this macro may be defined in sys_arch.h - */ -#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) -sys_prot_t sys_arch_protect(void); -void sys_arch_unprotect(sys_prot_t pval); - -#else - -#define SYS_ARCH_DECL_PROTECT(lev) -#define SYS_ARCH_PROTECT(lev) -#define SYS_ARCH_UNPROTECT(lev) - -#endif /* SYS_LIGHTWEIGHT_PROT */ - -#endif /* SYS_ARCH_PROTECT */ - -/* - * Macros to set/get and increase/decrease variables in a thread-safe way. - * Use these for accessing variable that are used from more than one thread. - */ - -#ifndef SYS_ARCH_INC -#define SYS_ARCH_INC(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var += val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_INC */ - -#ifndef SYS_ARCH_DEC -#define SYS_ARCH_DEC(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var -= val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_DEC */ - -#ifndef SYS_ARCH_GET -#define SYS_ARCH_GET(var, ret) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - ret = var; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_GET */ - -#ifndef SYS_ARCH_SET -#define SYS_ARCH_SET(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var = val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_SET */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_SYS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/tcp.h b/user/mpy/lib/lwip/src/include/lwip/tcp.h deleted file mode 100644 index c6e61ad..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/tcp.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_TCP_H__ -#define __LWIP_TCP_H__ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/mem.h" -#include "lwip/pbuf.h" -#include "lwip/ip.h" -#include "lwip/icmp.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct tcp_pcb; - -/** Function prototype for tcp accept callback functions. Called when a new - * connection can be accepted on a listening pcb. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param newpcb The new connection pcb - * @param err An error code if there has been an error accepting. - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err); - -/** Function prototype for tcp receive callback functions. Called when data has - * been received. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb which received data - * @param p The received data (or NULL when the connection has been closed!) - * @param err An error code if there has been an error receiving - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb, - struct pbuf *p, err_t err); - -/** Function prototype for tcp sent callback functions. Called when sent data has - * been acknowledged by the remote side. Use it to free corresponding resources. - * This also means that the pcb has now space available to send new data. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb for which data has been acknowledged - * @param len The amount of bytes acknowledged - * @return ERR_OK: try to send some data by calling tcp_output - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb, - u16_t len); - -/** Function prototype for tcp poll callback functions. Called periodically as - * specified by @see tcp_poll. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb tcp pcb - * @return ERR_OK: try to send some data by calling tcp_output - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb); - -/** Function prototype for tcp error callback functions. Called when the pcb - * receives a RST or is unexpectedly closed for any other reason. - * - * @note The corresponding pcb is already freed when this callback is called! - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param err Error code to indicate why the pcb has been closed - * ERR_ABRT: aborted through tcp_abort or by a TCP timer - * ERR_RST: the connection was reset by the remote host - */ -typedef void (*tcp_err_fn)(void *arg, err_t err); - -/** Function prototype for tcp connected callback functions. Called when a pcb - * is connected to the remote side after initiating a connection attempt by - * calling tcp_connect(). - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb which is connected - * @param err An unused error code, always ERR_OK currently ;-) TODO! - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - * - * @note When a connection attempt fails, the error callback is currently called! - */ -typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err); - -enum tcp_state { - CLOSED = 0, - LISTEN = 1, - SYN_SENT = 2, - SYN_RCVD = 3, - ESTABLISHED = 4, - FIN_WAIT_1 = 5, - FIN_WAIT_2 = 6, - CLOSE_WAIT = 7, - CLOSING = 8, - LAST_ACK = 9, - TIME_WAIT = 10 -}; - -#if LWIP_CALLBACK_API - /* Function to call when a listener has been connected. - * @param arg user-supplied argument (tcp_pcb.callback_arg) - * @param pcb a new tcp_pcb that now is connected - * @param err an error argument (TODO: that is current always ERR_OK?) - * @return ERR_OK: accept the new connection, - * any other err_t abortsthe new connection - */ -#define DEF_ACCEPT_CALLBACK tcp_accept_fn accept; -#else /* LWIP_CALLBACK_API */ -#define DEF_ACCEPT_CALLBACK -#endif /* LWIP_CALLBACK_API */ - -/** - * members common to struct tcp_pcb and struct tcp_listen_pcb - */ -#define TCP_PCB_COMMON(type) \ - type *next; /* for the linked list */ \ - void *callback_arg; \ - /* the accept callback for listen- and normal pcbs, if LWIP_CALLBACK_API */ \ - DEF_ACCEPT_CALLBACK \ - enum tcp_state state; /* TCP state */ \ - u8_t prio; \ - /* ports are in host byte order */ \ - u16_t local_port - - -/* the TCP protocol control block */ -struct tcp_pcb { -/** common PCB members */ - IP_PCB; -/** protocol specific PCB members */ - TCP_PCB_COMMON(struct tcp_pcb); - - /* ports are in host byte order */ - u16_t remote_port; - - u8_t flags; -#define TF_ACK_DELAY ((u8_t)0x01U) /* Delayed ACK. */ -#define TF_ACK_NOW ((u8_t)0x02U) /* Immediate ACK. */ -#define TF_INFR ((u8_t)0x04U) /* In fast recovery. */ -#define TF_TIMESTAMP ((u8_t)0x08U) /* Timestamp option enabled */ -#define TF_RXCLOSED ((u8_t)0x10U) /* rx closed by tcp_shutdown */ -#define TF_FIN ((u8_t)0x20U) /* Connection was closed locally (FIN segment enqueued). */ -#define TF_NODELAY ((u8_t)0x40U) /* Disable Nagle algorithm */ -#define TF_NAGLEMEMERR ((u8_t)0x80U) /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ - - /* the rest of the fields are in host byte order - as we have to do some math with them */ - - /* Timers */ - u8_t polltmr, pollinterval; - u8_t last_timer; - u32_t tmr; - - /* receiver variables */ - u32_t rcv_nxt; /* next seqno expected */ - u16_t rcv_wnd; /* receiver window available */ - u16_t rcv_ann_wnd; /* receiver window to announce */ - u32_t rcv_ann_right_edge; /* announced right edge of window */ - - /* Retransmission timer. */ - s16_t rtime; - - u16_t mss; /* maximum segment size */ - - /* RTT (round trip time) estimation variables */ - u32_t rttest; /* RTT estimate in 500ms ticks */ - u32_t rtseq; /* sequence number being timed */ - s16_t sa, sv; /* @todo document this */ - - s16_t rto; /* retransmission time-out */ - u8_t nrtx; /* number of retransmissions */ - - /* fast retransmit/recovery */ - u8_t dupacks; - u32_t lastack; /* Highest acknowledged seqno. */ - - /* congestion avoidance/control variables */ - u16_t cwnd; - u16_t ssthresh; - - /* sender variables */ - u32_t snd_nxt; /* next new seqno to be sent */ - u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last - window update. */ - u32_t snd_lbb; /* Sequence number of next byte to be buffered. */ - u16_t snd_wnd; /* sender window */ - u16_t snd_wnd_max; /* the maximum sender window announced by the remote host */ - - u16_t acked; - - u16_t snd_buf; /* Available buffer space for sending (in bytes). */ -#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) - u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */ - -#if TCP_OVERSIZE - /* Extra bytes available at the end of the last pbuf in unsent. */ - u16_t unsent_oversize; -#endif /* TCP_OVERSIZE */ - - /* These are ordered by sequence number: */ - struct tcp_seg *unsent; /* Unsent (queued) segments. */ - struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ -#if TCP_QUEUE_OOSEQ - struct tcp_seg *ooseq; /* Received out of sequence segments. */ -#endif /* TCP_QUEUE_OOSEQ */ - - struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */ - -#if LWIP_CALLBACK_API - /* Function to be called when more send buffer space is available. */ - tcp_sent_fn sent; - /* Function to be called when (in-sequence) data has arrived. */ - tcp_recv_fn recv; - /* Function to be called when a connection has been set up. */ - tcp_connected_fn connected; - /* Function which is called periodically. */ - tcp_poll_fn poll; - /* Function to be called whenever a fatal error occurs. */ - tcp_err_fn errf; -#endif /* LWIP_CALLBACK_API */ - -#if LWIP_TCP_TIMESTAMPS - u32_t ts_lastacksent; - u32_t ts_recent; -#endif /* LWIP_TCP_TIMESTAMPS */ - - /* idle time before KEEPALIVE is sent */ - u32_t keep_idle; -#if LWIP_TCP_KEEPALIVE - u32_t keep_intvl; - u32_t keep_cnt; -#endif /* LWIP_TCP_KEEPALIVE */ - - /* Persist timer counter */ - u8_t persist_cnt; - /* Persist timer back-off */ - u8_t persist_backoff; - - /* KEEPALIVE counter */ - u8_t keep_cnt_sent; -}; - -struct tcp_pcb_listen { -/* Common members of all PCB types */ - IP_PCB; -/* Protocol specific PCB members */ - TCP_PCB_COMMON(struct tcp_pcb_listen); - -#if TCP_LISTEN_BACKLOG - u8_t backlog; - u8_t accepts_pending; -#endif /* TCP_LISTEN_BACKLOG */ -}; - -#if LWIP_EVENT_API - -enum lwip_event { - LWIP_EVENT_ACCEPT, - LWIP_EVENT_SENT, - LWIP_EVENT_RECV, - LWIP_EVENT_CONNECTED, - LWIP_EVENT_POLL, - LWIP_EVENT_ERR -}; - -err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, - enum lwip_event, - struct pbuf *p, - u16_t size, - err_t err); - -#endif /* LWIP_EVENT_API */ - -/* Application program's interface: */ -struct tcp_pcb * tcp_new (void); - -void tcp_arg (struct tcp_pcb *pcb, void *arg); -void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); -void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv); -void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent); -void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval); -void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); - -#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss) -#define tcp_sndbuf(pcb) ((pcb)->snd_buf) -#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) -#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) -#define tcp_nagle_enable(pcb) ((pcb)->flags &= ~TF_NODELAY) -#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) - -#if TCP_LISTEN_BACKLOG -#define tcp_accepted(pcb) do { \ - LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", pcb->state == LISTEN); \ - (((struct tcp_pcb_listen *)(pcb))->accepts_pending--); } while(0) -#else /* TCP_LISTEN_BACKLOG */ -#define tcp_accepted(pcb) LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", \ - (pcb)->state == LISTEN) -#endif /* TCP_LISTEN_BACKLOG */ - -void tcp_recved (struct tcp_pcb *pcb, u16_t len); -err_t tcp_bind (struct tcp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port); -err_t tcp_connect (struct tcp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port, tcp_connected_fn connected); - -struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); -#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) - -void tcp_abort (struct tcp_pcb *pcb); -err_t tcp_close (struct tcp_pcb *pcb); -err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx); - -/* Flags for "apiflags" parameter in tcp_write */ -#define TCP_WRITE_FLAG_COPY 0x01 -#define TCP_WRITE_FLAG_MORE 0x02 - -err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, - u8_t apiflags); - -void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); - -#define TCP_PRIO_MIN 1 -#define TCP_PRIO_NORMAL 64 -#define TCP_PRIO_MAX 127 - -err_t tcp_output (struct tcp_pcb *pcb); - - -const char* tcp_debug_state_str(enum tcp_state s); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TCP */ - -#endif /* __LWIP_TCP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/tcp_impl.h b/user/mpy/lib/lwip/src/include/lwip/tcp_impl.h deleted file mode 100644 index 173de44..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/tcp_impl.h +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_TCP_IMPL_H__ -#define __LWIP_TCP_IMPL_H__ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/tcp.h" -#include "lwip/mem.h" -#include "lwip/pbuf.h" -#include "lwip/ip.h" -#include "lwip/icmp.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Functions for interfacing with TCP: */ - -/* Lower layer interface to TCP: */ -void tcp_init (void); /* Initialize this module. */ -void tcp_tmr (void); /* Must be called every - TCP_TMR_INTERVAL - ms. (Typically 250 ms). */ -/* It is also possible to call these two functions at the right - intervals (instead of calling tcp_tmr()). */ -void tcp_slowtmr (void); -void tcp_fasttmr (void); - - -/* Only used by IP to pass a TCP segment to TCP: */ -void tcp_input (struct pbuf *p, struct netif *inp); -/* Used within the TCP code only: */ -struct tcp_pcb * tcp_alloc (u8_t prio); -void tcp_abandon (struct tcp_pcb *pcb, int reset); -err_t tcp_send_empty_ack(struct tcp_pcb *pcb); -void tcp_rexmit (struct tcp_pcb *pcb); -void tcp_rexmit_rto (struct tcp_pcb *pcb); -void tcp_rexmit_fast (struct tcp_pcb *pcb); -u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); -err_t tcp_process_refused_data(struct tcp_pcb *pcb); - -/** - * This is the Nagle algorithm: try to combine user data to send as few TCP - * segments as possible. Only send if - * - no previously transmitted data on the connection remains unacknowledged or - * - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or - * - the only unsent segment is at least pcb->mss bytes long (or there is more - * than one unsent segment - with lwIP, this can happen although unsent->len < mss) - * - or if we are in fast-retransmit (TF_INFR) - */ -#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ - ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \ - (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ - ((tpcb)->unsent->len >= (tpcb)->mss))) || \ - ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \ - ) ? 1 : 0) -#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) - - -#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) -#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) -#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) -#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) -/* is b<=a<=c? */ -#if 0 /* see bug #10548 */ -#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) -#endif -#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) -#define TCP_FIN 0x01U -#define TCP_SYN 0x02U -#define TCP_RST 0x04U -#define TCP_PSH 0x08U -#define TCP_ACK 0x10U -#define TCP_URG 0x20U -#define TCP_ECE 0x40U -#define TCP_CWR 0x80U - -#define TCP_FLAGS 0x3fU - -/* Length of the TCP header, excluding options. */ -#define TCP_HLEN 20 - -#ifndef TCP_TMR_INTERVAL -#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ -#endif /* TCP_TMR_INTERVAL */ - -#ifndef TCP_FAST_INTERVAL -#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ -#endif /* TCP_FAST_INTERVAL */ - -#ifndef TCP_SLOW_INTERVAL -#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ -#endif /* TCP_SLOW_INTERVAL */ - -#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ -#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ - -#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ - -#ifndef TCP_MSL -#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */ -#endif - -/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ -#ifndef TCP_KEEPIDLE_DEFAULT -#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ -#endif - -#ifndef TCP_KEEPINTVL_DEFAULT -#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ -#endif - -#ifndef TCP_KEEPCNT_DEFAULT -#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ -#endif - -#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */ - -/* Fields are (of course) in network byte order. - * Some fields are converted to host byte order in tcp_input(). - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct tcp_hdr { - PACK_STRUCT_FIELD(u16_t src); - PACK_STRUCT_FIELD(u16_t dest); - PACK_STRUCT_FIELD(u32_t seqno); - PACK_STRUCT_FIELD(u32_t ackno); - PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); - PACK_STRUCT_FIELD(u16_t wnd); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t urgp); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12) -#define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS) - -#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr)) -#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags)) -#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags)) - -#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags)) -#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) ) - -#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0)) - -/** Flags used on input processing, not on pcb->flags -*/ -#define TF_RESET (u8_t)0x08U /* Connection was reset. */ -#define TF_CLOSED (u8_t)0x10U /* Connection was sucessfully closed. */ -#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ - - -#if LWIP_EVENT_API - -#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_ACCEPT, NULL, 0, err) -#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_SENT, NULL, space, ERR_OK) -#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_RECV, (p), 0, (err)) -#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_RECV, NULL, 0, ERR_OK) -#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_CONNECTED, NULL, 0, (err)) -#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_POLL, NULL, 0, ERR_OK) -#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \ - LWIP_EVENT_ERR, NULL, 0, (err)) - -#else /* LWIP_EVENT_API */ - -#define TCP_EVENT_ACCEPT(pcb,err,ret) \ - do { \ - if((pcb)->accept != NULL) \ - (ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \ - else (ret) = ERR_ARG; \ - } while (0) - -#define TCP_EVENT_SENT(pcb,space,ret) \ - do { \ - if((pcb)->sent != NULL) \ - (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_RECV(pcb,p,err,ret) \ - do { \ - if((pcb)->recv != NULL) { \ - (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\ - } else { \ - (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \ - } \ - } while (0) - -#define TCP_EVENT_CLOSED(pcb,ret) \ - do { \ - if(((pcb)->recv != NULL)) { \ - (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\ - } else { \ - (ret) = ERR_OK; \ - } \ - } while (0) - -#define TCP_EVENT_CONNECTED(pcb,err,ret) \ - do { \ - if((pcb)->connected != NULL) \ - (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_POLL(pcb,ret) \ - do { \ - if((pcb)->poll != NULL) \ - (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_ERR(errf,arg,err) \ - do { \ - if((errf) != NULL) \ - (errf)((arg),(err)); \ - } while (0) - -#endif /* LWIP_EVENT_API */ - -/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */ -#if TCP_OVERSIZE && defined(LWIP_DEBUG) -#define TCP_OVERSIZE_DBGCHECK 1 -#else -#define TCP_OVERSIZE_DBGCHECK 0 -#endif - -/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ -#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) - -/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */ -struct tcp_seg { - struct tcp_seg *next; /* used when putting segements on a queue */ - struct pbuf *p; /* buffer containing data + TCP header */ - u16_t len; /* the TCP length of this segment */ -#if TCP_OVERSIZE_DBGCHECK - u16_t oversize_left; /* Extra bytes available at the end of the last - pbuf in unsent (used for asserting vs. - tcp_pcb.unsent_oversized only) */ -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - u16_t chksum; - u8_t chksum_swapped; -#endif /* TCP_CHECKSUM_ON_COPY */ - u8_t flags; -#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */ -#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */ -#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is - checksummed into 'chksum' */ - struct tcp_hdr *tcphdr; /* the TCP header */ -}; - -#define LWIP_TCP_OPT_LENGTH(flags) \ - (flags & TF_SEG_OPTS_MSS ? 4 : 0) + \ - (flags & TF_SEG_OPTS_TS ? 12 : 0) - -/** This returns a TCP header option for MSS in an u32_t */ -#define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF)) - -/* Global variables: */ -extern struct tcp_pcb *tcp_input_pcb; -extern u32_t tcp_ticks; -extern u8_t tcp_active_pcbs_changed; - -/* The TCP PCB lists. */ -union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ - struct tcp_pcb_listen *listen_pcbs; - struct tcp_pcb *pcbs; -}; -extern struct tcp_pcb *tcp_bound_pcbs; -extern union tcp_listen_pcbs_t tcp_listen_pcbs; -extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a - state in which they accept or send - data. */ -extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ - -extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */ - -/* Axioms about the above lists: - 1) Every TCP PCB that is not CLOSED is in one of the lists. - 2) A PCB is only in one of the lists. - 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. - 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. -*/ -/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB - with a PCB list or removes a PCB from a list, respectively. */ -#ifndef TCP_DEBUG_PCB_LISTS -#define TCP_DEBUG_PCB_LISTS 0 -#endif -#if TCP_DEBUG_PCB_LISTS -#define TCP_REG(pcbs, npcb) do {\ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \ - for(tcp_tmp_pcb = *(pcbs); \ - tcp_tmp_pcb != NULL; \ - tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \ - } \ - LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \ - (npcb)->next = *(pcbs); \ - LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \ - *(pcbs) = (npcb); \ - LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ - tcp_timer_needed(); \ - } while(0) -#define TCP_RMV(pcbs, npcb) do { \ - LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \ - if(*(pcbs) == (npcb)) { \ - *(pcbs) = (*pcbs)->next; \ - } else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - if(tcp_tmp_pcb->next == (npcb)) { \ - tcp_tmp_pcb->next = (npcb)->next; \ - break; \ - } \ - } \ - (npcb)->next = NULL; \ - LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \ - } while(0) - -#else /* LWIP_DEBUG */ - -#define TCP_REG(pcbs, npcb) \ - do { \ - (npcb)->next = *pcbs; \ - *(pcbs) = (npcb); \ - tcp_timer_needed(); \ - } while (0) - -#define TCP_RMV(pcbs, npcb) \ - do { \ - if(*(pcbs) == (npcb)) { \ - (*(pcbs)) = (*pcbs)->next; \ - } \ - else { \ - for(tcp_tmp_pcb = *pcbs; \ - tcp_tmp_pcb != NULL; \ - tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - if(tcp_tmp_pcb->next == (npcb)) { \ - tcp_tmp_pcb->next = (npcb)->next; \ - break; \ - } \ - } \ - } \ - (npcb)->next = NULL; \ - } while(0) - -#endif /* LWIP_DEBUG */ - -#define TCP_REG_ACTIVE(npcb) \ - do { \ - TCP_REG(&tcp_active_pcbs, npcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - -#define TCP_RMV_ACTIVE(npcb) \ - do { \ - TCP_RMV(&tcp_active_pcbs, npcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - -#define TCP_PCB_REMOVE_ACTIVE(pcb) \ - do { \ - tcp_pcb_remove(&tcp_active_pcbs, pcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - - -/* Internal functions: */ -struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); -void tcp_pcb_purge(struct tcp_pcb *pcb); -void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); - -void tcp_segs_free(struct tcp_seg *seg); -void tcp_seg_free(struct tcp_seg *seg); -struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); - -#define tcp_ack(pcb) \ - do { \ - if((pcb)->flags & TF_ACK_DELAY) { \ - (pcb)->flags &= ~TF_ACK_DELAY; \ - (pcb)->flags |= TF_ACK_NOW; \ - } \ - else { \ - (pcb)->flags |= TF_ACK_DELAY; \ - } \ - } while (0) - -#define tcp_ack_now(pcb) \ - do { \ - (pcb)->flags |= TF_ACK_NOW; \ - } while (0) - -err_t tcp_send_fin(struct tcp_pcb *pcb); -err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags); - -void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); - -void tcp_rst(u32_t seqno, u32_t ackno, - ip_addr_t *local_ip, ip_addr_t *remote_ip, - u16_t local_port, u16_t remote_port); - -u32_t tcp_next_iss(void); - -void tcp_keepalive(struct tcp_pcb *pcb); -void tcp_zero_window_probe(struct tcp_pcb *pcb); - -#if TCP_CALCULATE_EFF_SEND_MSS -u16_t tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - -#if LWIP_CALLBACK_API -err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); -#endif /* LWIP_CALLBACK_API */ - -#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG -void tcp_debug_print(struct tcp_hdr *tcphdr); -void tcp_debug_print_flags(u8_t flags); -void tcp_debug_print_state(enum tcp_state s); -void tcp_debug_print_pcbs(void); -s16_t tcp_pcbs_sane(void); -#else -# define tcp_debug_print(tcphdr) -# define tcp_debug_print_flags(flags) -# define tcp_debug_print_state(s) -# define tcp_debug_print_pcbs() -# define tcp_pcbs_sane() 1 -#endif /* TCP_DEBUG */ - -/** External function (implemented in timers.c), called when TCP detects - * that a timer is needed (i.e. active- or time-wait-pcb found). */ -void tcp_timer_needed(void); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TCP */ - -#endif /* __LWIP_TCP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/tcpip.h b/user/mpy/lib/lwip/src/include/lwip/tcpip.h deleted file mode 100644 index 637476e..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/tcpip.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_TCPIP_H__ -#define __LWIP_TCPIP_H__ - -#include "lwip/opt.h" - -#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/api_msg.h" -#include "lwip/netifapi.h" -#include "lwip/pbuf.h" -#include "lwip/api.h" -#include "lwip/sys.h" -#include "lwip/timers.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Define this to something that triggers a watchdog. This is called from - * tcpip_thread after processing a message. */ -#ifndef LWIP_TCPIP_THREAD_ALIVE -#define LWIP_TCPIP_THREAD_ALIVE() -#endif - -#if LWIP_TCPIP_CORE_LOCKING -/** The global semaphore to lock the stack. */ -extern sys_mutex_t lock_tcpip_core; -#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core) -#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core) -#define TCPIP_APIMSG(m) tcpip_apimsg_lock(m) -#define TCPIP_APIMSG_ACK(m) -#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m) -#define TCPIP_NETIFAPI_ACK(m) -#else /* LWIP_TCPIP_CORE_LOCKING */ -#define LOCK_TCPIP_CORE() -#define UNLOCK_TCPIP_CORE() -#define TCPIP_APIMSG(m) tcpip_apimsg(m) -#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed) -#define TCPIP_NETIFAPI(m) tcpip_netifapi(m) -#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem) -#endif /* LWIP_TCPIP_CORE_LOCKING */ - -/** Function prototype for the init_done function passed to tcpip_init */ -typedef void (*tcpip_init_done_fn)(void *arg); -/** Function prototype for functions passed to tcpip_callback() */ -typedef void (*tcpip_callback_fn)(void *ctx); - -/* Forward declarations */ -struct tcpip_callback_msg; - -void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); - -#if LWIP_NETCONN -err_t tcpip_apimsg(struct api_msg *apimsg); -#if LWIP_TCPIP_CORE_LOCKING -err_t tcpip_apimsg_lock(struct api_msg *apimsg); -#endif /* LWIP_TCPIP_CORE_LOCKING */ -#endif /* LWIP_NETCONN */ - -err_t tcpip_input(struct pbuf *p, struct netif *inp); - -#if LWIP_NETIF_API -err_t tcpip_netifapi(struct netifapi_msg *netifapimsg); -#if LWIP_TCPIP_CORE_LOCKING -err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg); -#endif /* LWIP_TCPIP_CORE_LOCKING */ -#endif /* LWIP_NETIF_API */ - -err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); -#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) - -struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx); -void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg); -err_t tcpip_trycallback(struct tcpip_callback_msg* msg); - -/* free pbufs or heap memory from another context without blocking */ -err_t pbuf_free_callback(struct pbuf *p); -err_t mem_free_callback(void *m); - -#if LWIP_TCPIP_TIMEOUT -err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); -err_t tcpip_untimeout(sys_timeout_handler h, void *arg); -#endif /* LWIP_TCPIP_TIMEOUT */ - -enum tcpip_msg_type { -#if LWIP_NETCONN - TCPIP_MSG_API, -#endif /* LWIP_NETCONN */ - TCPIP_MSG_INPKT, -#if LWIP_NETIF_API - TCPIP_MSG_NETIFAPI, -#endif /* LWIP_NETIF_API */ -#if LWIP_TCPIP_TIMEOUT - TCPIP_MSG_TIMEOUT, - TCPIP_MSG_UNTIMEOUT, -#endif /* LWIP_TCPIP_TIMEOUT */ - TCPIP_MSG_CALLBACK, - TCPIP_MSG_CALLBACK_STATIC -}; - -struct tcpip_msg { - enum tcpip_msg_type type; - sys_sem_t *sem; - union { -#if LWIP_NETCONN - struct api_msg *apimsg; -#endif /* LWIP_NETCONN */ -#if LWIP_NETIF_API - struct netifapi_msg *netifapimsg; -#endif /* LWIP_NETIF_API */ - struct { - struct pbuf *p; - struct netif *netif; - } inp; - struct { - tcpip_callback_fn function; - void *ctx; - } cb; -#if LWIP_TCPIP_TIMEOUT - struct { - u32_t msecs; - sys_timeout_handler h; - void *arg; - } tmo; -#endif /* LWIP_TCPIP_TIMEOUT */ - } msg; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !NO_SYS */ - -#endif /* __LWIP_TCPIP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/timers.h b/user/mpy/lib/lwip/src/include/lwip/timers.h deleted file mode 100644 index 04e78e0..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/timers.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ -#ifndef __LWIP_TIMERS_H__ -#define __LWIP_TIMERS_H__ - -#include "lwip/opt.h" - -/* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ -#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) - -#if LWIP_TIMERS - -#include "lwip/err.h" -#if !NO_SYS -#include "lwip/sys.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef LWIP_DEBUG_TIMERNAMES -#ifdef LWIP_DEBUG -#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG -#else /* LWIP_DEBUG */ -#define LWIP_DEBUG_TIMERNAMES 0 -#endif /* LWIP_DEBUG*/ -#endif - -/** Function prototype for a timeout callback function. Register such a function - * using sys_timeout(). - * - * @param arg Additional argument to pass to the function - set up by sys_timeout() - */ -typedef void (* sys_timeout_handler)(void *arg); - -struct sys_timeo { - struct sys_timeo *next; - u32_t time; - sys_timeout_handler h; - void *arg; -#if LWIP_DEBUG_TIMERNAMES - const char* handler_name; -#endif /* LWIP_DEBUG_TIMERNAMES */ -}; - -void sys_timeouts_init(void); - -#if LWIP_DEBUG_TIMERNAMES -void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); -#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) -#else /* LWIP_DEBUG_TIMERNAMES */ -void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); -#endif /* LWIP_DEBUG_TIMERNAMES */ - -void sys_untimeout(sys_timeout_handler handler, void *arg); -#if NO_SYS -void sys_check_timeouts(void); -void sys_restart_timeouts(void); -#else /* NO_SYS */ -void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); -#endif /* NO_SYS */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TIMERS */ -#endif /* __LWIP_TIMERS_H__ */ diff --git a/user/mpy/lib/lwip/src/include/lwip/udp.h b/user/mpy/lib/lwip/src/include/lwip/udp.h deleted file mode 100644 index f1e6d3f..0000000 --- a/user/mpy/lib/lwip/src/include/lwip/udp.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_UDP_H__ -#define __LWIP_UDP_H__ - -#include "lwip/opt.h" - -#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/ip_addr.h" -#include "lwip/ip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define UDP_HLEN 8 - -/* Fields are (of course) in network byte order. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct udp_hdr { - PACK_STRUCT_FIELD(u16_t src); - PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ - PACK_STRUCT_FIELD(u16_t len); - PACK_STRUCT_FIELD(u16_t chksum); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define UDP_FLAGS_NOCHKSUM 0x01U -#define UDP_FLAGS_UDPLITE 0x02U -#define UDP_FLAGS_CONNECTED 0x04U -#define UDP_FLAGS_MULTICAST_LOOP 0x08U - -struct udp_pcb; - -/** Function prototype for udp pcb receive callback functions - * addr and port are in same byte order as in the pcb - * The callback is responsible for freeing the pbuf - * if it's not used any more. - * - * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf - * makes 'addr' invalid, too. - * - * @param arg user supplied argument (udp_pcb.recv_arg) - * @param pcb the udp_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IP address from which the packet was received - * @param port the remote port from which the packet was received - */ -typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *addr, u16_t port); - - -struct udp_pcb { -/* Common members of all PCB types */ - IP_PCB; - -/* Protocol specific PCB members */ - - struct udp_pcb *next; - - u8_t flags; - /** ports are in host byte order */ - u16_t local_port, remote_port; - -#if LWIP_IGMP - /** outgoing network interface for multicast packets */ - ip_addr_t multicast_ip; -#endif /* LWIP_IGMP */ - -#if LWIP_UDPLITE - /** used for UDP_LITE only */ - u16_t chksum_len_rx, chksum_len_tx; -#endif /* LWIP_UDPLITE */ - - /** receive callback function */ - udp_recv_fn recv; - /** user-supplied argument for the recv callback */ - void *recv_arg; -}; -/* udp_pcbs export for exernal reference (e.g. SNMP agent) */ -extern struct udp_pcb *udp_pcbs; - -/* The following functions is the application layer interface to the - UDP code. */ -struct udp_pcb * udp_new (void); -void udp_remove (struct udp_pcb *pcb); -err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port); -err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port); -void udp_disconnect (struct udp_pcb *pcb); -void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, - void *recv_arg); -err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif); -err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port); -err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); - -#if LWIP_CHECKSUM_ON_COPY -err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif, u8_t have_chksum, - u16_t chksum); -err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, - u8_t have_chksum, u16_t chksum); -err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, - u8_t have_chksum, u16_t chksum); -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#define udp_flags(pcb) ((pcb)->flags) -#define udp_setflags(pcb, f) ((pcb)->flags = (f)) - -/* The following functions are the lower layer interface to UDP. */ -void udp_input (struct pbuf *p, struct netif *inp); - -void udp_init (void); - -#if UDP_DEBUG -void udp_debug_print(struct udp_hdr *udphdr); -#else -#define udp_debug_print(udphdr) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_UDP */ - -#endif /* __LWIP_UDP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/netif/etharp.h b/user/mpy/lib/lwip/src/include/netif/etharp.h deleted file mode 100644 index 859608d..0000000 --- a/user/mpy/lib/lwip/src/include/netif/etharp.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * Copyright (c) 2003-2004 Leon Woestenberg - * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __NETIF_ETHARP_H__ -#define __NETIF_ETHARP_H__ - -#include "lwip/opt.h" - -#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/ip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ETHARP_HWADDR_LEN -#define ETHARP_HWADDR_LEN 6 -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct eth_addr { - PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** Ethernet header */ -struct eth_hdr { -#if ETH_PAD_SIZE - PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); -#endif - PACK_STRUCT_FIELD(struct eth_addr dest); - PACK_STRUCT_FIELD(struct eth_addr src); - PACK_STRUCT_FIELD(u16_t type); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE) - -#if ETHARP_SUPPORT_VLAN - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** VLAN header inserted between ethernet header and payload - * if 'type' in ethernet header is ETHTYPE_VLAN. - * See IEEE802.Q */ -struct eth_vlan_hdr { - PACK_STRUCT_FIELD(u16_t prio_vid); - PACK_STRUCT_FIELD(u16_t tpid); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_VLAN_HDR 4 -#define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF) - -#endif /* ETHARP_SUPPORT_VLAN */ - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** the ARP message, see RFC 826 ("Packet format") */ -struct etharp_hdr { - PACK_STRUCT_FIELD(u16_t hwtype); - PACK_STRUCT_FIELD(u16_t proto); - PACK_STRUCT_FIELD(u8_t hwlen); - PACK_STRUCT_FIELD(u8_t protolen); - PACK_STRUCT_FIELD(u16_t opcode); - PACK_STRUCT_FIELD(struct eth_addr shwaddr); - PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); - PACK_STRUCT_FIELD(struct eth_addr dhwaddr); - PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_ETHARP_HDR 28 -#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR) - -/** 5 seconds period */ -#define ARP_TMR_INTERVAL 5000 - -#define ETHTYPE_ARP 0x0806U -#define ETHTYPE_IP 0x0800U -#define ETHTYPE_VLAN 0x8100U -#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */ -#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */ - -/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables - * or known to be 32-bit aligned within the protocol header. */ -#ifndef ETHADDR32_COPY -#define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) -#endif - -/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local - * variables and known to be 16-bit aligned within the protocol header. */ -#ifndef ETHADDR16_COPY -#define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) -#endif - -#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ - -/** ARP message types (opcodes) */ -#define ARP_REQUEST 1 -#define ARP_REPLY 2 - -/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) - * to a filter function that returns the correct netif when using multiple - * netifs on one hardware interface where the netif's low-level receive - * routine cannot decide for the correct netif (e.g. when mapping multiple - * IP addresses to one hardware interface). - */ -#ifndef LWIP_ARP_FILTER_NETIF -#define LWIP_ARP_FILTER_NETIF 0 -#endif - -#if ARP_QUEUEING -/** struct for queueing outgoing packets for unknown address - * defined here to be accessed by memp.h - */ -struct etharp_q_entry { - struct etharp_q_entry *next; - struct pbuf *p; -}; -#endif /* ARP_QUEUEING */ - -#define etharp_init() /* Compatibility define, not init needed. */ -void etharp_tmr(void); -s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, - struct eth_addr **eth_ret, ip_addr_t **ip_ret); -err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr); -err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q); -err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr); -/** For Ethernet network interfaces, we might want to send "gratuitous ARP"; - * this is an ARP packet sent by a node in order to spontaneously cause other - * nodes to update an entry in their ARP cache. - * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ -#define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) -void etharp_cleanup_netif(struct netif *netif); - -#if ETHARP_SUPPORT_STATIC_ENTRIES -err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr); -err_t etharp_remove_static_entry(ip_addr_t *ipaddr); -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - -#if LWIP_AUTOIP -err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, - const struct eth_addr *ethdst_addr, - const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr, - const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr, - const u16_t opcode); -#endif /* LWIP_AUTOIP */ - -#endif /* LWIP_ARP */ - -err_t ethernet_input(struct pbuf *p, struct netif *netif); - -#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0) - -extern const struct eth_addr ethbroadcast, ethzero; - -#endif /* LWIP_ARP || LWIP_ETHERNET */ - -#ifdef __cplusplus -} -#endif - -#endif /* __NETIF_ARP_H__ */ diff --git a/user/mpy/lib/lwip/src/include/netif/ppp_oe.h b/user/mpy/lib/lwip/src/include/netif/ppp_oe.h deleted file mode 100644 index e1cdfa5..0000000 --- a/user/mpy/lib/lwip/src/include/netif/ppp_oe.h +++ /dev/null @@ -1,190 +0,0 @@ -/***************************************************************************** -* ppp_oe.h - PPP Over Ethernet implementation for lwIP. -* -* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 06-01-01 Marc Boucher -* Ported to lwIP. -*****************************************************************************/ - - - -/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef PPP_OE_H -#define PPP_OE_H - -#include "lwip/opt.h" - -#if PPPOE_SUPPORT > 0 - -#include "netif/etharp.h" - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pppoehdr { - PACK_STRUCT_FIELD(u8_t vertype); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t session); - PACK_STRUCT_FIELD(u16_t plen); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pppoetag { - PACK_STRUCT_FIELD(u16_t tag); - PACK_STRUCT_FIELD(u16_t len); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - - -#define PPPOE_STATE_INITIAL 0 -#define PPPOE_STATE_PADI_SENT 1 -#define PPPOE_STATE_PADR_SENT 2 -#define PPPOE_STATE_SESSION 3 -#define PPPOE_STATE_CLOSING 4 -/* passive */ -#define PPPOE_STATE_PADO_SENT 1 - -#define PPPOE_HEADERLEN sizeof(struct pppoehdr) -#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ - -#define PPPOE_TAG_EOL 0x0000 /* end of list */ -#define PPPOE_TAG_SNAME 0x0101 /* service name */ -#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ -#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ -#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ -#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ -#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ -#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ -#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ -#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ - -#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ -#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ -#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ -#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ -#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ - -#ifndef ETHERMTU -#define ETHERMTU 1500 -#endif - -/* two byte PPP protocol discriminator, then IP data */ -#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2) - -#ifndef PPPOE_MAX_AC_COOKIE_LEN -#define PPPOE_MAX_AC_COOKIE_LEN 64 -#endif - -struct pppoe_softc { - struct pppoe_softc *next; - struct netif *sc_ethif; /* ethernet interface we are using */ - int sc_pd; /* ppp unit number */ - void (*sc_linkStatusCB)(int pd, int up); - - int sc_state; /* discovery phase or session connected */ - struct eth_addr sc_dest; /* hardware address of concentrator */ - u16_t sc_session; /* PPPoE session id */ - -#ifdef PPPOE_TODO - char *sc_service_name; /* if != NULL: requested name of service */ - char *sc_concentrator_name; /* if != NULL: requested concentrator id */ -#endif /* PPPOE_TODO */ - u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */ - size_t sc_ac_cookie_len; /* length of cookie data */ -#ifdef PPPOE_SERVER - u8_t *sc_hunique; /* content of host unique we must echo back */ - size_t sc_hunique_len; /* length of host unique */ -#endif - int sc_padi_retried; /* number of PADI retries already done */ - int sc_padr_retried; /* number of PADR retries already done */ -}; - - -#define pppoe_init() /* compatibility define, no initialization needed */ - -err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr); -err_t pppoe_destroy(struct netif *ifp); - -int pppoe_connect(struct pppoe_softc *sc); -void pppoe_disconnect(struct pppoe_softc *sc); - -void pppoe_disc_input(struct netif *netif, struct pbuf *p); -void pppoe_data_input(struct netif *netif, struct pbuf *p); - -err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb); - -/** used in ppp.c */ -#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN) - -#endif /* PPPOE_SUPPORT */ - -#endif /* PPP_OE_H */ diff --git a/user/mpy/lib/lwip/src/include/netif/slipif.h b/user/mpy/lib/lwip/src/include/netif/slipif.h deleted file mode 100644 index 7b6ce5e..0000000 --- a/user/mpy/lib/lwip/src/include/netif/slipif.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __NETIF_SLIPIF_H__ -#define __NETIF_SLIPIF_H__ - -#include "lwip/opt.h" -#include "lwip/netif.h" - -/** Set this to 1 to start a thread that blocks reading on the serial line - * (using sio_read()). - */ -#ifndef SLIP_USE_RX_THREAD -#define SLIP_USE_RX_THREAD !NO_SYS -#endif - -/** Set this to 1 to enable functions to pass in RX bytes from ISR context. - * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled - * packets on a queue, which is fed into lwIP from slipif_poll(). - * If disabled, slipif_poll() polls the serila line (using sio_tryread()). - */ -#ifndef SLIP_RX_FROM_ISR -#define SLIP_RX_FROM_ISR 0 -#endif - -/** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets - * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. - * If disabled, packets will be dropped if more than one packet is received. - */ -#ifndef SLIP_RX_QUEUE -#define SLIP_RX_QUEUE SLIP_RX_FROM_ISR -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -err_t slipif_init(struct netif * netif); -void slipif_poll(struct netif *netif); -#if SLIP_RX_FROM_ISR -void slipif_process_rxqueue(struct netif *netif); -void slipif_received_byte(struct netif *netif, u8_t data); -void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); -#endif /* SLIP_RX_FROM_ISR */ - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/user/mpy/lib/lwip/src/include/posix/netdb.h b/user/mpy/lib/lwip/src/include/posix/netdb.h deleted file mode 100644 index 7134032..0000000 --- a/user/mpy/lib/lwip/src/include/posix/netdb.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file - * This file is a posix wrapper for lwip/netdb.h. - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "lwip/netdb.h" diff --git a/user/mpy/lib/lwip/src/include/posix/sys/socket.h b/user/mpy/lib/lwip/src/include/posix/sys/socket.h deleted file mode 100644 index f7c7066..0000000 --- a/user/mpy/lib/lwip/src/include/posix/sys/socket.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file - * This file is a posix wrapper for lwip/sockets.h. - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "lwip/sockets.h" diff --git a/user/mpy/lib/lwip/src/netif/FILES b/user/mpy/lib/lwip/src/netif/FILES deleted file mode 100644 index 099dbf3..0000000 --- a/user/mpy/lib/lwip/src/netif/FILES +++ /dev/null @@ -1,29 +0,0 @@ -This directory contains generic network interface device drivers that -do not contain any hardware or architecture specific code. The files -are: - -etharp.c - Implements the ARP (Address Resolution Protocol) over - Ethernet. The code in this file should be used together with - Ethernet device drivers. Note that this module has been - largely made Ethernet independent so you should be able to - adapt this for other link layers (such as Firewire). - -ethernetif.c - An example of how an Ethernet device driver could look. This - file can be used as a "skeleton" for developing new Ethernet - network device drivers. It uses the etharp.c ARP code. - -loopif.c - A "loopback" network interface driver. It requires configuration - through the define LWIP_LOOPIF_MULTITHREADING (see opt.h). - -slipif.c - A generic implementation of the SLIP (Serial Line IP) - protocol. It requires a sio (serial I/O) module to work. - -ppp/ Point-to-Point Protocol stack - The PPP stack has been ported from ucip (http://ucip.sourceforge.net). - It matches quite well to pppd 2.3.1 (http://ppp.samba.org), although - compared to that, it has some modifications for embedded systems and - the source code has been reordered a bit. \ No newline at end of file diff --git a/user/mpy/lib/lwip/src/netif/etharp.c b/user/mpy/lib/lwip/src/netif/etharp.c deleted file mode 100644 index 5e382d1..0000000 --- a/user/mpy/lib/lwip/src/netif/etharp.c +++ /dev/null @@ -1,1399 +0,0 @@ -/** - * @file - * Address Resolution Protocol module for IP over Ethernet - * - * Functionally, ARP is divided into two parts. The first maps an IP address - * to a physical address when sending a packet, and the second part answers - * requests from other machines for our physical address. - * - * This implementation complies with RFC 826 (Ethernet ARP). It supports - * Gratuitious ARP from RFC3220 (IP Mobility Support for IPv4) section 4.6 - * if an interface calls etharp_gratuitous(our_netif) upon address change. - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * Copyright (c) 2003-2004 Leon Woestenberg - * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "lwip/opt.h" - -#if LWIP_ARP || LWIP_ETHERNET - -#include "lwip/ip_addr.h" -#include "lwip/def.h" -#include "lwip/ip.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" -#include "netif/etharp.h" - -#if PPPOE_SUPPORT -#include "netif/ppp_oe.h" -#endif /* PPPOE_SUPPORT */ - -#include - -const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; -const struct eth_addr ethzero = {{0,0,0,0,0,0}}; - -/** The 24-bit IANA multicast OUI is 01-00-5e: */ -#define LL_MULTICAST_ADDR_0 0x01 -#define LL_MULTICAST_ADDR_1 0x00 -#define LL_MULTICAST_ADDR_2 0x5e - -#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ - -/** the time an ARP entry stays valid after its last update, - * for ARP_TMR_INTERVAL = 5000, this is - * (240 * 5) seconds = 20 minutes. - */ -#define ARP_MAXAGE 240 -/** Re-request a used ARP entry 1 minute before it would expire to prevent - * breaking a steadily used connection because the ARP entry timed out. */ -#define ARP_AGE_REREQUEST_USED (ARP_MAXAGE - 12) - -/** the time an ARP entry stays pending after first request, - * for ARP_TMR_INTERVAL = 5000, this is - * (2 * 5) seconds = 10 seconds. - * - * @internal Keep this number at least 2, otherwise it might - * run out instantly if the timeout occurs directly after a request. - */ -#define ARP_MAXPENDING 2 - -#define HWTYPE_ETHERNET 1 - -enum etharp_state { - ETHARP_STATE_EMPTY = 0, - ETHARP_STATE_PENDING, - ETHARP_STATE_STABLE, - ETHARP_STATE_STABLE_REREQUESTING -#if ETHARP_SUPPORT_STATIC_ENTRIES - ,ETHARP_STATE_STATIC -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ -}; - -struct etharp_entry { -#if ARP_QUEUEING - /** Pointer to queue of pending outgoing packets on this ARP entry. */ - struct etharp_q_entry *q; -#else /* ARP_QUEUEING */ - /** Pointer to a single pending outgoing packet on this ARP entry. */ - struct pbuf *q; -#endif /* ARP_QUEUEING */ - ip_addr_t ipaddr; - struct netif *netif; - struct eth_addr ethaddr; - u8_t state; - u8_t ctime; -}; - -static struct etharp_entry arp_table[ARP_TABLE_SIZE]; - -#if !LWIP_NETIF_HWADDRHINT -static u8_t etharp_cached_entry; -#endif /* !LWIP_NETIF_HWADDRHINT */ - -/** Try hard to create a new entry - we want the IP address to appear in - the cache (even if this means removing an active entry or so). */ -#define ETHARP_FLAG_TRY_HARD 1 -#define ETHARP_FLAG_FIND_ONLY 2 -#if ETHARP_SUPPORT_STATIC_ENTRIES -#define ETHARP_FLAG_STATIC_ENTRY 4 -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - -#if LWIP_NETIF_HWADDRHINT -#define ETHARP_SET_HINT(netif, hint) if (((netif) != NULL) && ((netif)->addr_hint != NULL)) \ - *((netif)->addr_hint) = (hint); -#else /* LWIP_NETIF_HWADDRHINT */ -#define ETHARP_SET_HINT(netif, hint) (etharp_cached_entry = (hint)) -#endif /* LWIP_NETIF_HWADDRHINT */ - - -/* Some checks, instead of etharp_init(): */ -#if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f)) - #error "ARP_TABLE_SIZE must fit in an s8_t, you have to reduce it in your lwipopts.h" -#endif - - -#if ARP_QUEUEING -/** - * Free a complete queue of etharp entries - * - * @param q a qeueue of etharp_q_entry's to free - */ -static void -free_etharp_q(struct etharp_q_entry *q) -{ - struct etharp_q_entry *r; - LWIP_ASSERT("q != NULL", q != NULL); - LWIP_ASSERT("q->p != NULL", q->p != NULL); - while (q) { - r = q; - q = q->next; - LWIP_ASSERT("r->p != NULL", (r->p != NULL)); - pbuf_free(r->p); - memp_free(MEMP_ARP_QUEUE, r); - } -} -#else /* ARP_QUEUEING */ - -/** Compatibility define: free the queued pbuf */ -#define free_etharp_q(q) pbuf_free(q) - -#endif /* ARP_QUEUEING */ - -/** Clean up ARP table entries */ -static void -etharp_free_entry(int i) -{ - /* remove from SNMP ARP index tree */ - snmp_delete_arpidx_tree(arp_table[i].netif, &arp_table[i].ipaddr); - /* and empty packet queue */ - if (arp_table[i].q != NULL) { - /* remove all queued packets */ - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_free_entry: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].q))); - free_etharp_q(arp_table[i].q); - arp_table[i].q = NULL; - } - /* recycle entry for re-use */ - arp_table[i].state = ETHARP_STATE_EMPTY; -#ifdef LWIP_DEBUG - /* for debugging, clean out the complete entry */ - arp_table[i].ctime = 0; - arp_table[i].netif = NULL; - ip_addr_set_zero(&arp_table[i].ipaddr); - arp_table[i].ethaddr = ethzero; -#endif /* LWIP_DEBUG */ -} - -/** - * Clears expired entries in the ARP table. - * - * This function should be called every ETHARP_TMR_INTERVAL milliseconds (5 seconds), - * in order to expire entries in the ARP table. - */ -void -etharp_tmr(void) -{ - u8_t i; - - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n")); - /* remove expired entries from the ARP table */ - for (i = 0; i < ARP_TABLE_SIZE; ++i) { - u8_t state = arp_table[i].state; - if (state != ETHARP_STATE_EMPTY -#if ETHARP_SUPPORT_STATIC_ENTRIES - && (state != ETHARP_STATE_STATIC) -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - ) { - arp_table[i].ctime++; - if ((arp_table[i].ctime >= ARP_MAXAGE) || - ((arp_table[i].state == ETHARP_STATE_PENDING) && - (arp_table[i].ctime >= ARP_MAXPENDING))) { - /* pending or stable entry has become old! */ - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired %s entry %"U16_F".\n", - arp_table[i].state >= ETHARP_STATE_STABLE ? "stable" : "pending", (u16_t)i)); - /* clean up entries that have just been expired */ - etharp_free_entry(i); - } - else if (arp_table[i].state == ETHARP_STATE_STABLE_REREQUESTING) { - /* Reset state to stable, so that the next transmitted packet will - re-send an ARP request. */ - arp_table[i].state = ETHARP_STATE_STABLE; - } -#if ARP_QUEUEING - /* still pending entry? (not expired) */ - if (arp_table[i].state == ETHARP_STATE_PENDING) { - /* resend an ARP query here? */ - } -#endif /* ARP_QUEUEING */ - } - } -} - -/** - * Search the ARP table for a matching or new entry. - * - * If an IP address is given, return a pending or stable ARP entry that matches - * the address. If no match is found, create a new entry with this address set, - * but in state ETHARP_EMPTY. The caller must check and possibly change the - * state of the returned entry. - * - * If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY. - * - * In all cases, attempt to create new entries from an empty entry. If no - * empty entries are available and ETHARP_FLAG_TRY_HARD flag is set, recycle - * old entries. Heuristic choose the least important entry for recycling. - * - * @param ipaddr IP address to find in ARP cache, or to add if not found. - * @param flags @see definition of ETHARP_FLAG_* - * @param netif netif related to this address (used for NETIF_HWADDRHINT) - * - * @return The ARP entry index that matched or is created, ERR_MEM if no - * entry is found or could be recycled. - */ -static s8_t -etharp_find_entry(ip_addr_t *ipaddr, u8_t flags) -{ - s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE; - s8_t empty = ARP_TABLE_SIZE; - u8_t i = 0, age_pending = 0, age_stable = 0; - /* oldest entry with packets on queue */ - s8_t old_queue = ARP_TABLE_SIZE; - /* its age */ - u8_t age_queue = 0; - - /** - * a) do a search through the cache, remember candidates - * b) select candidate entry - * c) create new entry - */ - - /* a) in a single search sweep, do all of this - * 1) remember the first empty entry (if any) - * 2) remember the oldest stable entry (if any) - * 3) remember the oldest pending entry without queued packets (if any) - * 4) remember the oldest pending entry with queued packets (if any) - * 5) search for a matching IP entry, either pending or stable - * until 5 matches, or all entries are searched for. - */ - - for (i = 0; i < ARP_TABLE_SIZE; ++i) { - u8_t state = arp_table[i].state; - /* no empty entry found yet and now we do find one? */ - if ((empty == ARP_TABLE_SIZE) && (state == ETHARP_STATE_EMPTY)) { - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_find_entry: found empty entry %"U16_F"\n", (u16_t)i)); - /* remember first empty entry */ - empty = i; - } else if (state != ETHARP_STATE_EMPTY) { - LWIP_ASSERT("state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE", - state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE); - /* if given, does IP address match IP address in ARP entry? */ - if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: found matching entry %"U16_F"\n", (u16_t)i)); - /* found exact IP address match, simply bail out */ - return i; - } - /* pending entry? */ - if (state == ETHARP_STATE_PENDING) { - /* pending with queued packets? */ - if (arp_table[i].q != NULL) { - if (arp_table[i].ctime >= age_queue) { - old_queue = i; - age_queue = arp_table[i].ctime; - } - } else - /* pending without queued packets? */ - { - if (arp_table[i].ctime >= age_pending) { - old_pending = i; - age_pending = arp_table[i].ctime; - } - } - /* stable entry? */ - } else if (state >= ETHARP_STATE_STABLE) { -#if ETHARP_SUPPORT_STATIC_ENTRIES - /* don't record old_stable for static entries since they never expire */ - if (state < ETHARP_STATE_STATIC) -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - { - /* remember entry with oldest stable entry in oldest, its age in maxtime */ - if (arp_table[i].ctime >= age_stable) { - old_stable = i; - age_stable = arp_table[i].ctime; - } - } - } - } - } - /* { we have no match } => try to create a new entry */ - - /* don't create new entry, only search? */ - if (((flags & ETHARP_FLAG_FIND_ONLY) != 0) || - /* or no empty entry found and not allowed to recycle? */ - ((empty == ARP_TABLE_SIZE) && ((flags & ETHARP_FLAG_TRY_HARD) == 0))) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: no empty entry found and not allowed to recycle\n")); - return (s8_t)ERR_MEM; - } - - /* b) choose the least destructive entry to recycle: - * 1) empty entry - * 2) oldest stable entry - * 3) oldest pending entry without queued packets - * 4) oldest pending entry with queued packets - * - * { ETHARP_FLAG_TRY_HARD is set at this point } - */ - - /* 1) empty entry available? */ - if (empty < ARP_TABLE_SIZE) { - i = empty; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting empty entry %"U16_F"\n", (u16_t)i)); - } else { - /* 2) found recyclable stable entry? */ - if (old_stable < ARP_TABLE_SIZE) { - /* recycle oldest stable*/ - i = old_stable; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i)); - /* no queued packets should exist on stable entries */ - LWIP_ASSERT("arp_table[i].q == NULL", arp_table[i].q == NULL); - /* 3) found recyclable pending entry without queued packets? */ - } else if (old_pending < ARP_TABLE_SIZE) { - /* recycle oldest pending */ - i = old_pending; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i)); - /* 4) found recyclable pending entry with queued packets? */ - } else if (old_queue < ARP_TABLE_SIZE) { - /* recycle oldest pending (queued packets are free in etharp_free_entry) */ - i = old_queue; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q))); - /* no empty or recyclable entries found */ - } else { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: no empty or recyclable entries found\n")); - return (s8_t)ERR_MEM; - } - - /* { empty or recyclable entry found } */ - LWIP_ASSERT("i < ARP_TABLE_SIZE", i < ARP_TABLE_SIZE); - etharp_free_entry(i); - } - - LWIP_ASSERT("i < ARP_TABLE_SIZE", i < ARP_TABLE_SIZE); - LWIP_ASSERT("arp_table[i].state == ETHARP_STATE_EMPTY", - arp_table[i].state == ETHARP_STATE_EMPTY); - - /* IP address given? */ - if (ipaddr != NULL) { - /* set IP address */ - ip_addr_copy(arp_table[i].ipaddr, *ipaddr); - } - arp_table[i].ctime = 0; - return (err_t)i; -} - -/** - * Send an IP packet on the network using netif->linkoutput - * The ethernet header is filled in before sending. - * - * @params netif the lwIP network interface on which to send the packet - * @params p the packet to send, p->payload pointing to the (uninitialized) ethernet header - * @params src the source MAC address to be copied into the ethernet header - * @params dst the destination MAC address to be copied into the ethernet header - * @return ERR_OK if the packet was sent, any other err_t on failure - */ -static err_t -etharp_send_ip(struct netif *netif, struct pbuf *p, struct eth_addr *src, struct eth_addr *dst) -{ - struct eth_hdr *ethhdr = (struct eth_hdr *)p->payload; - - LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!", - (netif->hwaddr_len == ETHARP_HWADDR_LEN)); - ETHADDR32_COPY(ðhdr->dest, dst); - ETHADDR16_COPY(ðhdr->src, src); - ethhdr->type = PP_HTONS(ETHTYPE_IP); - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_send_ip: sending packet %p\n", (void *)p)); - /* send the packet */ - return netif->linkoutput(netif, p); -} - -/** - * Update (or insert) a IP/MAC address pair in the ARP cache. - * - * If a pending entry is resolved, any queued packets will be sent - * at this point. - * - * @param netif netif related to this entry (used for NETIF_ADDRHINT) - * @param ipaddr IP address of the inserted ARP entry. - * @param ethaddr Ethernet address of the inserted ARP entry. - * @param flags @see definition of ETHARP_FLAG_* - * - * @return - * - ERR_OK Succesfully updated ARP cache. - * - ERR_MEM If we could not add a new ARP entry when ETHARP_FLAG_TRY_HARD was set. - * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. - * - * @see pbuf_free() - */ -static err_t -etharp_update_arp_entry(struct netif *netif, ip_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags) -{ - s8_t i; - LWIP_ASSERT("netif->hwaddr_len == ETHARP_HWADDR_LEN", netif->hwaddr_len == ETHARP_HWADDR_LEN); - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n", - ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr), - ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], - ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); - /* non-unicast address? */ - if (ip_addr_isany(ipaddr) || - ip_addr_isbroadcast(ipaddr, netif) || - ip_addr_ismulticast(ipaddr)) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: will not add non-unicast IP address to ARP cache\n")); - return ERR_ARG; - } - /* find or create ARP entry */ - i = etharp_find_entry(ipaddr, flags); - /* bail out if no entry could be found */ - if (i < 0) { - return (err_t)i; - } - -#if ETHARP_SUPPORT_STATIC_ENTRIES - if (flags & ETHARP_FLAG_STATIC_ENTRY) { - /* record static type */ - arp_table[i].state = ETHARP_STATE_STATIC; - } else -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - { - /* mark it stable */ - arp_table[i].state = ETHARP_STATE_STABLE; - } - - /* record network interface */ - arp_table[i].netif = netif; - /* insert in SNMP ARP index tree */ - snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr); - - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i)); - /* update address */ - ETHADDR32_COPY(&arp_table[i].ethaddr, ethaddr); - /* reset time stamp */ - arp_table[i].ctime = 0; - /* this is where we will send out queued packets! */ -#if ARP_QUEUEING - while (arp_table[i].q != NULL) { - struct pbuf *p; - /* remember remainder of queue */ - struct etharp_q_entry *q = arp_table[i].q; - /* pop first item off the queue */ - arp_table[i].q = q->next; - /* get the packet pointer */ - p = q->p; - /* now queue entry can be freed */ - memp_free(MEMP_ARP_QUEUE, q); -#else /* ARP_QUEUEING */ - if (arp_table[i].q != NULL) { - struct pbuf *p = arp_table[i].q; - arp_table[i].q = NULL; -#endif /* ARP_QUEUEING */ - /* send the queued IP packet */ - etharp_send_ip(netif, p, (struct eth_addr*)(netif->hwaddr), ethaddr); - /* free the queued IP packet */ - pbuf_free(p); - } - return ERR_OK; -} - -#if ETHARP_SUPPORT_STATIC_ENTRIES -/** Add a new static entry to the ARP table. If an entry exists for the - * specified IP address, this entry is overwritten. - * If packets are queued for the specified IP address, they are sent out. - * - * @param ipaddr IP address for the new static entry - * @param ethaddr ethernet address for the new static entry - * @return @see return values of etharp_add_static_entry - */ -err_t -etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr) -{ - struct netif *netif; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_add_static_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n", - ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr), - ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], - ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); - - netif = ip_route(ipaddr); - if (netif == NULL) { - return ERR_RTE; - } - - return etharp_update_arp_entry(netif, ipaddr, ethaddr, ETHARP_FLAG_TRY_HARD | ETHARP_FLAG_STATIC_ENTRY); -} - -/** Remove a static entry from the ARP table previously added with a call to - * etharp_add_static_entry. - * - * @param ipaddr IP address of the static entry to remove - * @return ERR_OK: entry removed - * ERR_MEM: entry wasn't found - * ERR_ARG: entry wasn't a static entry but a dynamic one - */ -err_t -etharp_remove_static_entry(ip_addr_t *ipaddr) -{ - s8_t i; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_remove_static_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr))); - - /* find or create ARP entry */ - i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY); - /* bail out if no entry could be found */ - if (i < 0) { - return (err_t)i; - } - - if (arp_table[i].state != ETHARP_STATE_STATIC) { - /* entry wasn't a static entry, cannot remove it */ - return ERR_ARG; - } - /* entry found, free it */ - etharp_free_entry(i); - return ERR_OK; -} -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - -/** - * Remove all ARP table entries of the specified netif. - * - * @param netif points to a network interface - */ -void etharp_cleanup_netif(struct netif *netif) -{ - u8_t i; - - for (i = 0; i < ARP_TABLE_SIZE; ++i) { - u8_t state = arp_table[i].state; - if ((state != ETHARP_STATE_EMPTY) && (arp_table[i].netif == netif)) { - etharp_free_entry(i); - } - } -} - -/** - * Finds (stable) ethernet/IP address pair from ARP table - * using interface and IP address index. - * @note the addresses in the ARP table are in network order! - * - * @param netif points to interface index - * @param ipaddr points to the (network order) IP address index - * @param eth_ret points to return pointer - * @param ip_ret points to return pointer - * @return table index if found, -1 otherwise - */ -s8_t -etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, - struct eth_addr **eth_ret, ip_addr_t **ip_ret) -{ - s8_t i; - - LWIP_ASSERT("eth_ret != NULL && ip_ret != NULL", - eth_ret != NULL && ip_ret != NULL); - - LWIP_UNUSED_ARG(netif); - - i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY); - if((i >= 0) && (arp_table[i].state >= ETHARP_STATE_STABLE)) { - *eth_ret = &arp_table[i].ethaddr; - *ip_ret = &arp_table[i].ipaddr; - return i; - } - return -1; -} - -#if ETHARP_TRUST_IP_MAC -/** - * Updates the ARP table using the given IP packet. - * - * Uses the incoming IP packet's source address to update the - * ARP cache for the local network. The function does not alter - * or free the packet. This function must be called before the - * packet p is passed to the IP layer. - * - * @param netif The lwIP network interface on which the IP packet pbuf arrived. - * @param p The IP packet that arrived on netif. - * - * @return NULL - * - * @see pbuf_free() - */ -static void -etharp_ip_input(struct netif *netif, struct pbuf *p) -{ - struct eth_hdr *ethhdr; - struct ip_hdr *iphdr; - ip_addr_t iphdr_src; - LWIP_ERROR("netif != NULL", (netif != NULL), return;); - - /* Only insert an entry if the source IP address of the - incoming IP packet comes from a host on the local network. */ - ethhdr = (struct eth_hdr *)p->payload; - iphdr = (struct ip_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR); -#if ETHARP_SUPPORT_VLAN - if (ethhdr->type == PP_HTONS(ETHTYPE_VLAN)) { - iphdr = (struct ip_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR); - } -#endif /* ETHARP_SUPPORT_VLAN */ - - ip_addr_copy(iphdr_src, iphdr->src); - - /* source is not on the local network? */ - if (!ip_addr_netcmp(&iphdr_src, &(netif->ip_addr), &(netif->netmask))) { - /* do nothing */ - return; - } - - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n")); - /* update the source IP address in the cache, if present */ - /* @todo We could use ETHARP_FLAG_TRY_HARD if we think we are going to talk - * back soon (for example, if the destination IP address is ours. */ - etharp_update_arp_entry(netif, &iphdr_src, &(ethhdr->src), ETHARP_FLAG_FIND_ONLY); -} -#endif /* ETHARP_TRUST_IP_MAC */ - -/** - * Responds to ARP requests to us. Upon ARP replies to us, add entry to cache - * send out queued IP packets. Updates cache with snooped address pairs. - * - * Should be called for incoming ARP packets. The pbuf in the argument - * is freed by this function. - * - * @param netif The lwIP network interface on which the ARP packet pbuf arrived. - * @param ethaddr Ethernet address of netif. - * @param p The ARP packet that arrived on netif. Is freed by this function. - * - * @return NULL - * - * @see pbuf_free() - */ -static void -etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) -{ - struct etharp_hdr *hdr; - struct eth_hdr *ethhdr; - /* these are aligned properly, whereas the ARP header fields might not be */ - ip_addr_t sipaddr, dipaddr; - u8_t for_us; -#if LWIP_AUTOIP - const u8_t * ethdst_hwaddr; -#endif /* LWIP_AUTOIP */ - - LWIP_ERROR("netif != NULL", (netif != NULL), return;); - - /* drop short ARP packets: we have to check for p->len instead of p->tot_len here - since a struct etharp_hdr is pointed to p->payload, so it musn't be chained! */ - if (p->len < SIZEOF_ETHARP_PACKET) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, - ("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, - (s16_t)SIZEOF_ETHARP_PACKET)); - ETHARP_STATS_INC(etharp.lenerr); - ETHARP_STATS_INC(etharp.drop); - pbuf_free(p); - return; - } - - ethhdr = (struct eth_hdr *)p->payload; - hdr = (struct etharp_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR); -#if ETHARP_SUPPORT_VLAN - if (ethhdr->type == PP_HTONS(ETHTYPE_VLAN)) { - hdr = (struct etharp_hdr *)(((u8_t*)ethhdr) + SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR); - } -#endif /* ETHARP_SUPPORT_VLAN */ - - /* RFC 826 "Packet Reception": */ - if ((hdr->hwtype != PP_HTONS(HWTYPE_ETHERNET)) || - (hdr->hwlen != ETHARP_HWADDR_LEN) || - (hdr->protolen != sizeof(ip_addr_t)) || - (hdr->proto != PP_HTONS(ETHTYPE_IP))) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, - ("etharp_arp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n", - hdr->hwtype, hdr->hwlen, hdr->proto, hdr->protolen)); - ETHARP_STATS_INC(etharp.proterr); - ETHARP_STATS_INC(etharp.drop); - pbuf_free(p); - return; - } - ETHARP_STATS_INC(etharp.recv); - -#if LWIP_AUTOIP - /* We have to check if a host already has configured our random - * created link local address and continously check if there is - * a host with this IP-address so we can detect collisions */ - autoip_arp_reply(netif, hdr); -#endif /* LWIP_AUTOIP */ - - /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without - * structure packing (not using structure copy which breaks strict-aliasing rules). */ - IPADDR2_COPY(&sipaddr, &hdr->sipaddr); - IPADDR2_COPY(&dipaddr, &hdr->dipaddr); - - /* this interface is not configured? */ - if (ip_addr_isany(&netif->ip_addr)) { - for_us = 0; - } else { - /* ARP packet directed to us? */ - for_us = (u8_t)ip_addr_cmp(&dipaddr, &(netif->ip_addr)); - } - - /* ARP message directed to us? - -> add IP address in ARP cache; assume requester wants to talk to us, - can result in directly sending the queued packets for this host. - ARP message not directed to us? - -> update the source IP address in the cache, if present */ - etharp_update_arp_entry(netif, &sipaddr, &(hdr->shwaddr), - for_us ? ETHARP_FLAG_TRY_HARD : ETHARP_FLAG_FIND_ONLY); - - /* now act on the message itself */ - switch (hdr->opcode) { - /* ARP request? */ - case PP_HTONS(ARP_REQUEST): - /* ARP request. If it asked for our address, we send out a - * reply. In any case, we time-stamp any existing ARP entry, - * and possiby send out an IP packet that was queued on it. */ - - LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP request\n")); - /* ARP request for our address? */ - if (for_us) { - - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n")); - /* Re-use pbuf to send ARP reply. - Since we are re-using an existing pbuf, we can't call etharp_raw since - that would allocate a new pbuf. */ - hdr->opcode = htons(ARP_REPLY); - - IPADDR2_COPY(&hdr->dipaddr, &hdr->sipaddr); - IPADDR2_COPY(&hdr->sipaddr, &netif->ip_addr); - - LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!", - (netif->hwaddr_len == ETHARP_HWADDR_LEN)); -#if LWIP_AUTOIP - /* If we are using Link-Local, all ARP packets that contain a Link-Local - * 'sender IP address' MUST be sent using link-layer broadcast instead of - * link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */ - ethdst_hwaddr = ip_addr_islinklocal(&netif->ip_addr) ? (u8_t*)(ethbroadcast.addr) : hdr->shwaddr.addr; -#endif /* LWIP_AUTOIP */ - - ETHADDR16_COPY(&hdr->dhwaddr, &hdr->shwaddr); -#if LWIP_AUTOIP - ETHADDR16_COPY(ðhdr->dest, ethdst_hwaddr); -#else /* LWIP_AUTOIP */ - ETHADDR16_COPY(ðhdr->dest, &hdr->shwaddr); -#endif /* LWIP_AUTOIP */ - ETHADDR16_COPY(&hdr->shwaddr, ethaddr); - ETHADDR16_COPY(ðhdr->src, ethaddr); - - /* hwtype, hwaddr_len, proto, protolen and the type in the ethernet header - are already correct, we tested that before */ - - /* return ARP reply */ - netif->linkoutput(netif, p); - /* we are not configured? */ - } else if (ip_addr_isany(&netif->ip_addr)) { - /* { for_us == 0 and netif->ip_addr.addr == 0 } */ - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n")); - /* request was not directed to us */ - } else { - /* { for_us == 0 and netif->ip_addr.addr != 0 } */ - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n")); - } - break; - case PP_HTONS(ARP_REPLY): - /* ARP reply. We already updated the ARP cache earlier. */ - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n")); -#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) - /* DHCP wants to know about ARP replies from any host with an - * IP address also offered to us by the DHCP server. We do not - * want to take a duplicate IP address on a single network. - * @todo How should we handle redundant (fail-over) interfaces? */ - dhcp_arp_reply(netif, &sipaddr); -#endif /* (LWIP_DHCP && DHCP_DOES_ARP_CHECK) */ - break; - default: - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode))); - ETHARP_STATS_INC(etharp.err); - break; - } - /* free ARP packet */ - pbuf_free(p); -} - -/** Just a small helper function that sends a pbuf to an ethernet address - * in the arp_table specified by the index 'arp_idx'. - */ -static err_t -etharp_output_to_arp_index(struct netif *netif, struct pbuf *q, u8_t arp_idx) -{ - LWIP_ASSERT("arp_table[arp_idx].state >= ETHARP_STATE_STABLE", - arp_table[arp_idx].state >= ETHARP_STATE_STABLE); - /* if arp table entry is about to expire: re-request it, - but only if its state is ETHARP_STATE_STABLE to prevent flooding the - network with ARP requests if this address is used frequently. */ - if ((arp_table[arp_idx].state == ETHARP_STATE_STABLE) && - (arp_table[arp_idx].ctime >= ARP_AGE_REREQUEST_USED)) { - if (etharp_request(netif, &arp_table[arp_idx].ipaddr) == ERR_OK) { - arp_table[arp_idx].state = ETHARP_STATE_STABLE_REREQUESTING; - } - } - - return etharp_send_ip(netif, q, (struct eth_addr*)(netif->hwaddr), - &arp_table[arp_idx].ethaddr); -} - -/** - * Resolve and fill-in Ethernet address header for outgoing IP packet. - * - * For IP multicast and broadcast, corresponding Ethernet addresses - * are selected and the packet is transmitted on the link. - * - * For unicast addresses, the packet is submitted to etharp_query(). In - * case the IP address is outside the local network, the IP address of - * the gateway is used. - * - * @param netif The lwIP network interface which the IP packet will be sent on. - * @param q The pbuf(s) containing the IP packet to be sent. - * @param ipaddr The IP address of the packet destination. - * - * @return - * - ERR_RTE No route to destination (no gateway to external networks), - * or the return type of either etharp_query() or etharp_send_ip(). - */ -err_t -etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) -{ - struct eth_addr *dest; - struct eth_addr mcastaddr; - ip_addr_t *dst_addr = ipaddr; - - LWIP_ASSERT("netif != NULL", netif != NULL); - LWIP_ASSERT("q != NULL", q != NULL); - LWIP_ASSERT("ipaddr != NULL", ipaddr != NULL); - - /* make room for Ethernet header - should not fail */ - if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) { - /* bail out */ - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, - ("etharp_output: could not allocate room for header.\n")); - LINK_STATS_INC(link.lenerr); - return ERR_BUF; - } - - /* Determine on destination hardware address. Broadcasts and multicasts - * are special, other IP addresses are looked up in the ARP table. */ - - /* broadcast destination IP address? */ - if (ip_addr_isbroadcast(ipaddr, netif)) { - /* broadcast on Ethernet also */ - dest = (struct eth_addr *)ðbroadcast; - /* multicast destination IP address? */ - } else if (ip_addr_ismulticast(ipaddr)) { - /* Hash IP multicast address to MAC address.*/ - mcastaddr.addr[0] = LL_MULTICAST_ADDR_0; - mcastaddr.addr[1] = LL_MULTICAST_ADDR_1; - mcastaddr.addr[2] = LL_MULTICAST_ADDR_2; - mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f; - mcastaddr.addr[4] = ip4_addr3(ipaddr); - mcastaddr.addr[5] = ip4_addr4(ipaddr); - /* destination Ethernet address is multicast */ - dest = &mcastaddr; - /* unicast destination IP address? */ - } else { - s8_t i; - /* outside local network? if so, this can neither be a global broadcast nor - a subnet broadcast. */ - if (!ip_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask)) && - !ip_addr_islinklocal(ipaddr)) { -#if LWIP_AUTOIP - struct ip_hdr *iphdr = (struct ip_hdr*)((u8_t*)q->payload + - sizeof(struct eth_hdr)); - /* According to RFC 3297, chapter 2.6.2 (Forwarding Rules), a packet with - a link-local source address must always be "directly to its destination - on the same physical link. The host MUST NOT send the packet to any - router for forwarding". */ - if (!ip_addr_islinklocal(&iphdr->src)) -#endif /* LWIP_AUTOIP */ - { - /* interface has default gateway? */ - if (!ip_addr_isany(&netif->gw)) { - /* send to hardware address of default gateway IP address */ - dst_addr = &(netif->gw); - /* no default gateway available */ - } else { - /* no route to destination error (default gateway missing) */ - return ERR_RTE; - } - } - } -#if LWIP_NETIF_HWADDRHINT - if (netif->addr_hint != NULL) { - /* per-pcb cached entry was given */ - u8_t etharp_cached_entry = *(netif->addr_hint); - if (etharp_cached_entry < ARP_TABLE_SIZE) { -#endif /* LWIP_NETIF_HWADDRHINT */ - if ((arp_table[etharp_cached_entry].state >= ETHARP_STATE_STABLE) && - (ip_addr_cmp(dst_addr, &arp_table[etharp_cached_entry].ipaddr))) { - /* the per-pcb-cached entry is stable and the right one! */ - ETHARP_STATS_INC(etharp.cachehit); - return etharp_output_to_arp_index(netif, q, etharp_cached_entry); - } -#if LWIP_NETIF_HWADDRHINT - } - } -#endif /* LWIP_NETIF_HWADDRHINT */ - - /* find stable entry: do this here since this is a critical path for - throughput and etharp_find_entry() is kind of slow */ - for (i = 0; i < ARP_TABLE_SIZE; i++) { - if ((arp_table[i].state >= ETHARP_STATE_STABLE) && - (ip_addr_cmp(dst_addr, &arp_table[i].ipaddr))) { - /* found an existing, stable entry */ - ETHARP_SET_HINT(netif, i); - return etharp_output_to_arp_index(netif, q, i); - } - } - /* no stable entry found, use the (slower) query function: - queue on destination Ethernet address belonging to ipaddr */ - return etharp_query(netif, dst_addr, q); - } - - /* continuation for multicast/broadcast destinations */ - /* obtain source Ethernet address of the given interface */ - /* send packet directly on the link */ - return etharp_send_ip(netif, q, (struct eth_addr*)(netif->hwaddr), dest); -} - -/** - * Send an ARP request for the given IP address and/or queue a packet. - * - * If the IP address was not yet in the cache, a pending ARP cache entry - * is added and an ARP request is sent for the given address. The packet - * is queued on this entry. - * - * If the IP address was already pending in the cache, a new ARP request - * is sent for the given address. The packet is queued on this entry. - * - * If the IP address was already stable in the cache, and a packet is - * given, it is directly sent and no ARP request is sent out. - * - * If the IP address was already stable in the cache, and no packet is - * given, an ARP request is sent out. - * - * @param netif The lwIP network interface on which ipaddr - * must be queried for. - * @param ipaddr The IP address to be resolved. - * @param q If non-NULL, a pbuf that must be delivered to the IP address. - * q is not freed by this function. - * - * @note q must only be ONE packet, not a packet queue! - * - * @return - * - ERR_BUF Could not make room for Ethernet header. - * - ERR_MEM Hardware address unknown, and no more ARP entries available - * to query for address or queue the packet. - * - ERR_MEM Could not queue packet due to memory shortage. - * - ERR_RTE No route to destination (no gateway to external networks). - * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. - * - */ -err_t -etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q) -{ - struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr; - err_t result = ERR_MEM; - s8_t i; /* ARP entry index */ - - /* non-unicast address? */ - if (ip_addr_isbroadcast(ipaddr, netif) || - ip_addr_ismulticast(ipaddr) || - ip_addr_isany(ipaddr)) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: will not add non-unicast IP address to ARP cache\n")); - return ERR_ARG; - } - - /* find entry in ARP cache, ask to create entry if queueing packet */ - i = etharp_find_entry(ipaddr, ETHARP_FLAG_TRY_HARD); - - /* could not find or create entry? */ - if (i < 0) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not create ARP entry\n")); - if (q) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: packet dropped\n")); - ETHARP_STATS_INC(etharp.memerr); - } - return (err_t)i; - } - - /* mark a fresh entry as pending (we just sent a request) */ - if (arp_table[i].state == ETHARP_STATE_EMPTY) { - arp_table[i].state = ETHARP_STATE_PENDING; - } - - /* { i is either a STABLE or (new or existing) PENDING entry } */ - LWIP_ASSERT("arp_table[i].state == PENDING or STABLE", - ((arp_table[i].state == ETHARP_STATE_PENDING) || - (arp_table[i].state >= ETHARP_STATE_STABLE))); - - /* do we have a pending entry? or an implicit query request? */ - if ((arp_table[i].state == ETHARP_STATE_PENDING) || (q == NULL)) { - /* try to resolve it; send out ARP request */ - result = etharp_request(netif, ipaddr); - if (result != ERR_OK) { - /* ARP request couldn't be sent */ - /* We don't re-send arp request in etharp_tmr, but we still queue packets, - since this failure could be temporary, and the next packet calling - etharp_query again could lead to sending the queued packets. */ - } - if (q == NULL) { - return result; - } - } - - /* packet given? */ - LWIP_ASSERT("q != NULL", q != NULL); - /* stable entry? */ - if (arp_table[i].state >= ETHARP_STATE_STABLE) { - /* we have a valid IP->Ethernet address mapping */ - ETHARP_SET_HINT(netif, i); - /* send the packet */ - result = etharp_send_ip(netif, q, srcaddr, &(arp_table[i].ethaddr)); - /* pending entry? (either just created or already pending */ - } else if (arp_table[i].state == ETHARP_STATE_PENDING) { - /* entry is still pending, queue the given packet 'q' */ - struct pbuf *p; - int copy_needed = 0; - /* IF q includes a PBUF_REF, PBUF_POOL or PBUF_RAM, we have no choice but - * to copy the whole queue into a new PBUF_RAM (see bug #11400) - * PBUF_ROMs can be left as they are, since ROM must not get changed. */ - p = q; - while (p) { - LWIP_ASSERT("no packet queues allowed!", (p->len != p->tot_len) || (p->next == 0)); - if(p->type != PBUF_ROM) { - copy_needed = 1; - break; - } - p = p->next; - } - if(copy_needed) { - /* copy the whole packet into new pbufs */ - p = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); - if(p != NULL) { - if (pbuf_copy(p, q) != ERR_OK) { - pbuf_free(p); - p = NULL; - } - } - } else { - /* referencing the old pbuf is enough */ - p = q; - pbuf_ref(p); - } - /* packet could be taken over? */ - if (p != NULL) { - /* queue packet ... */ -#if ARP_QUEUEING - struct etharp_q_entry *new_entry; - /* allocate a new arp queue entry */ - new_entry = (struct etharp_q_entry *)memp_malloc(MEMP_ARP_QUEUE); - if (new_entry != NULL) { - new_entry->next = 0; - new_entry->p = p; - if(arp_table[i].q != NULL) { - /* queue was already existent, append the new entry to the end */ - struct etharp_q_entry *r; - r = arp_table[i].q; - while (r->next != NULL) { - r = r->next; - } - r->next = new_entry; - } else { - /* queue did not exist, first item in queue */ - arp_table[i].q = new_entry; - } - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); - result = ERR_OK; - } else { - /* the pool MEMP_ARP_QUEUE is empty */ - pbuf_free(p); - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q)); - result = ERR_MEM; - } -#else /* ARP_QUEUEING */ - /* always queue one packet per ARP request only, freeing a previously queued packet */ - if (arp_table[i].q != NULL) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: dropped previously queued packet %p for ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); - pbuf_free(arp_table[i].q); - } - arp_table[i].q = p; - result = ERR_OK; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); -#endif /* ARP_QUEUEING */ - } else { - ETHARP_STATS_INC(etharp.memerr); - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q)); - result = ERR_MEM; - } - } - return result; -} - -/** - * Send a raw ARP packet (opcode and all addresses can be modified) - * - * @param netif the lwip network interface on which to send the ARP packet - * @param ethsrc_addr the source MAC address for the ethernet header - * @param ethdst_addr the destination MAC address for the ethernet header - * @param hwsrc_addr the source MAC address for the ARP protocol header - * @param ipsrc_addr the source IP address for the ARP protocol header - * @param hwdst_addr the destination MAC address for the ARP protocol header - * @param ipdst_addr the destination IP address for the ARP protocol header - * @param opcode the type of the ARP packet - * @return ERR_OK if the ARP packet has been sent - * ERR_MEM if the ARP packet couldn't be allocated - * any other err_t on failure - */ -#if !LWIP_AUTOIP -static -#endif /* LWIP_AUTOIP */ -err_t -etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, - const struct eth_addr *ethdst_addr, - const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr, - const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr, - const u16_t opcode) -{ - struct pbuf *p; - err_t result = ERR_OK; - struct eth_hdr *ethhdr; - struct etharp_hdr *hdr; -#if LWIP_AUTOIP - const u8_t * ethdst_hwaddr; -#endif /* LWIP_AUTOIP */ - - LWIP_ASSERT("netif != NULL", netif != NULL); - - /* allocate a pbuf for the outgoing ARP request packet */ - p = pbuf_alloc(PBUF_RAW, SIZEOF_ETHARP_PACKET, PBUF_RAM); - /* could allocate a pbuf for an ARP request? */ - if (p == NULL) { - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, - ("etharp_raw: could not allocate pbuf for ARP request.\n")); - ETHARP_STATS_INC(etharp.memerr); - return ERR_MEM; - } - LWIP_ASSERT("check that first pbuf can hold struct etharp_hdr", - (p->len >= SIZEOF_ETHARP_PACKET)); - - ethhdr = (struct eth_hdr *)p->payload; - hdr = (struct etharp_hdr *)((u8_t*)ethhdr + SIZEOF_ETH_HDR); - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_raw: sending raw ARP packet.\n")); - hdr->opcode = htons(opcode); - - LWIP_ASSERT("netif->hwaddr_len must be the same as ETHARP_HWADDR_LEN for etharp!", - (netif->hwaddr_len == ETHARP_HWADDR_LEN)); -#if LWIP_AUTOIP - /* If we are using Link-Local, all ARP packets that contain a Link-Local - * 'sender IP address' MUST be sent using link-layer broadcast instead of - * link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */ - ethdst_hwaddr = ip_addr_islinklocal(ipsrc_addr) ? (u8_t*)(ethbroadcast.addr) : ethdst_addr->addr; -#endif /* LWIP_AUTOIP */ - /* Write the ARP MAC-Addresses */ - ETHADDR16_COPY(&hdr->shwaddr, hwsrc_addr); - ETHADDR16_COPY(&hdr->dhwaddr, hwdst_addr); - /* Write the Ethernet MAC-Addresses */ -#if LWIP_AUTOIP - ETHADDR16_COPY(ðhdr->dest, ethdst_hwaddr); -#else /* LWIP_AUTOIP */ - ETHADDR16_COPY(ðhdr->dest, ethdst_addr); -#endif /* LWIP_AUTOIP */ - ETHADDR16_COPY(ðhdr->src, ethsrc_addr); - /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without - * structure packing. */ - IPADDR2_COPY(&hdr->sipaddr, ipsrc_addr); - IPADDR2_COPY(&hdr->dipaddr, ipdst_addr); - - hdr->hwtype = PP_HTONS(HWTYPE_ETHERNET); - hdr->proto = PP_HTONS(ETHTYPE_IP); - /* set hwlen and protolen */ - hdr->hwlen = ETHARP_HWADDR_LEN; - hdr->protolen = sizeof(ip_addr_t); - - ethhdr->type = PP_HTONS(ETHTYPE_ARP); - /* send ARP query */ - result = netif->linkoutput(netif, p); - ETHARP_STATS_INC(etharp.xmit); - /* free ARP query packet */ - pbuf_free(p); - p = NULL; - /* could not allocate pbuf for ARP request */ - - return result; -} - -/** - * Send an ARP request packet asking for ipaddr. - * - * @param netif the lwip network interface on which to send the request - * @param ipaddr the IP address for which to ask - * @return ERR_OK if the request has been sent - * ERR_MEM if the ARP packet couldn't be allocated - * any other err_t on failure - */ -err_t -etharp_request(struct netif *netif, ip_addr_t *ipaddr) -{ - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_request: sending ARP request.\n")); - return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast, - (struct eth_addr *)netif->hwaddr, &netif->ip_addr, ðzero, - ipaddr, ARP_REQUEST); -} -#endif /* LWIP_ARP */ - -/** - * Process received ethernet frames. Using this function instead of directly - * calling ip_input and passing ARP frames through etharp in ethernetif_input, - * the ARP cache is protected from concurrent access. - * - * @param p the recevied packet, p->payload pointing to the ethernet header - * @param netif the network interface on which the packet was received - */ -err_t -ethernet_input(struct pbuf *p, struct netif *netif) -{ - struct eth_hdr* ethhdr; - u16_t type; -#if LWIP_ARP || ETHARP_SUPPORT_VLAN - s16_t ip_hdr_offset = SIZEOF_ETH_HDR; -#endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */ - - if (p->len <= SIZEOF_ETH_HDR) { - /* a packet with only an ethernet header (or less) is not valid for us */ - ETHARP_STATS_INC(etharp.proterr); - ETHARP_STATS_INC(etharp.drop); - goto free_and_return; - } - - /* points to packet payload, which starts with an Ethernet header */ - ethhdr = (struct eth_hdr *)p->payload; - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, - ("ethernet_input: dest:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", src:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", type:%"X16_F"\n", - (unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2], - (unsigned)ethhdr->dest.addr[3], (unsigned)ethhdr->dest.addr[4], (unsigned)ethhdr->dest.addr[5], - (unsigned)ethhdr->src.addr[0], (unsigned)ethhdr->src.addr[1], (unsigned)ethhdr->src.addr[2], - (unsigned)ethhdr->src.addr[3], (unsigned)ethhdr->src.addr[4], (unsigned)ethhdr->src.addr[5], - (unsigned)htons(ethhdr->type))); - - type = ethhdr->type; -#if ETHARP_SUPPORT_VLAN - if (type == PP_HTONS(ETHTYPE_VLAN)) { - struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr*)(((char*)ethhdr) + SIZEOF_ETH_HDR); - if (p->len <= SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) { - /* a packet with only an ethernet/vlan header (or less) is not valid for us */ - ETHARP_STATS_INC(etharp.proterr); - ETHARP_STATS_INC(etharp.drop); - goto free_and_return; - } -#if defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) /* if not, allow all VLANs */ -#ifdef ETHARP_VLAN_CHECK_FN - if (!ETHARP_VLAN_CHECK_FN(ethhdr, vlan)) { -#elif defined(ETHARP_VLAN_CHECK) - if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) { -#endif - /* silently ignore this packet: not for our VLAN */ - pbuf_free(p); - return ERR_OK; - } -#endif /* defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) */ - type = vlan->tpid; - ip_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR; - } -#endif /* ETHARP_SUPPORT_VLAN */ - -#if LWIP_ARP_FILTER_NETIF - netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, htons(type)); -#endif /* LWIP_ARP_FILTER_NETIF*/ - - if (ethhdr->dest.addr[0] & 1) { - /* this might be a multicast or broadcast packet */ - if (ethhdr->dest.addr[0] == LL_MULTICAST_ADDR_0) { - if ((ethhdr->dest.addr[1] == LL_MULTICAST_ADDR_1) && - (ethhdr->dest.addr[2] == LL_MULTICAST_ADDR_2)) { - /* mark the pbuf as link-layer multicast */ - p->flags |= PBUF_FLAG_LLMCAST; - } - } else if (eth_addr_cmp(ðhdr->dest, ðbroadcast)) { - /* mark the pbuf as link-layer broadcast */ - p->flags |= PBUF_FLAG_LLBCAST; - } - } - - switch (type) { -#if LWIP_ARP - /* IP packet? */ - case PP_HTONS(ETHTYPE_IP): - if (!(netif->flags & NETIF_FLAG_ETHARP)) { - goto free_and_return; - } -#if ETHARP_TRUST_IP_MAC - /* update ARP table */ - etharp_ip_input(netif, p); -#endif /* ETHARP_TRUST_IP_MAC */ - /* skip Ethernet header */ - if(pbuf_header(p, -ip_hdr_offset)) { - LWIP_ASSERT("Can't move over header in packet", 0); - goto free_and_return; - } else { - /* pass to IP layer */ - ip_input(p, netif); - } - break; - - case PP_HTONS(ETHTYPE_ARP): - if (!(netif->flags & NETIF_FLAG_ETHARP)) { - goto free_and_return; - } - /* pass p to ARP module */ - etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p); - break; -#endif /* LWIP_ARP */ -#if PPPOE_SUPPORT - case PP_HTONS(ETHTYPE_PPPOEDISC): /* PPP Over Ethernet Discovery Stage */ - pppoe_disc_input(netif, p); - break; - - case PP_HTONS(ETHTYPE_PPPOE): /* PPP Over Ethernet Session Stage */ - pppoe_data_input(netif, p); - break; -#endif /* PPPOE_SUPPORT */ - - default: - ETHARP_STATS_INC(etharp.proterr); - ETHARP_STATS_INC(etharp.drop); - goto free_and_return; - } - - /* This means the pbuf is freed or consumed, - so the caller doesn't have to free it again */ - return ERR_OK; - -free_and_return: - pbuf_free(p); - return ERR_OK; -} -#endif /* LWIP_ARP || LWIP_ETHERNET */ diff --git a/user/mpy/lib/lwip/src/netif/ethernetif.c b/user/mpy/lib/lwip/src/netif/ethernetif.c deleted file mode 100644 index 8ec40be..0000000 --- a/user/mpy/lib/lwip/src/netif/ethernetif.c +++ /dev/null @@ -1,317 +0,0 @@ -/** - * @file - * Ethernet Interface Skeleton - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -/* - * This file is a skeleton for developing Ethernet network interface - * drivers for lwIP. Add code to the low_level functions and do a - * search-and-replace for the word "ethernetif" to replace it with - * something that better describes your network interface. - */ - -#include "lwip/opt.h" - -#if 0 /* don't build, this is only a skeleton, see previous comment */ - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/pbuf.h" -#include -#include -#include "netif/etharp.h" -#include "netif/ppp_oe.h" - -/* Define those to better describe your network interface. */ -#define IFNAME0 'e' -#define IFNAME1 'n' - -/** - * Helper struct to hold private data used to operate your ethernet interface. - * Keeping the ethernet address of the MAC in this struct is not necessary - * as it is already kept in the struct netif. - * But this is only an example, anyway... - */ -struct ethernetif { - struct eth_addr *ethaddr; - /* Add whatever per-interface state that is needed here. */ -}; - -/* Forward declarations. */ -static void ethernetif_input(struct netif *netif); - -/** - * In this function, the hardware should be initialized. - * Called from ethernetif_init(). - * - * @param netif the already initialized lwip network interface structure - * for this ethernetif - */ -static void -low_level_init(struct netif *netif) -{ - struct ethernetif *ethernetif = netif->state; - - /* set MAC hardware address length */ - netif->hwaddr_len = ETHARP_HWADDR_LEN; - - /* set MAC hardware address */ - netif->hwaddr[0] = ; - ... - netif->hwaddr[5] = ; - - /* maximum transfer unit */ - netif->mtu = 1500; - - /* device capabilities */ - /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ - netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; - - /* Do whatever else is needed to initialize interface. */ -} - -/** - * This function should do the actual transmission of the packet. The packet is - * contained in the pbuf that is passed to the function. This pbuf - * might be chained. - * - * @param netif the lwip network interface structure for this ethernetif - * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type) - * @return ERR_OK if the packet could be sent - * an err_t value if the packet couldn't be sent - * - * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to - * strange results. You might consider waiting for space in the DMA queue - * to become availale since the stack doesn't retry to send a packet - * dropped because of memory failure (except for the TCP timers). - */ - -static err_t -low_level_output(struct netif *netif, struct pbuf *p) -{ - struct ethernetif *ethernetif = netif->state; - struct pbuf *q; - - initiate transfer(); - -#if ETH_PAD_SIZE - pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ -#endif - - for(q = p; q != NULL; q = q->next) { - /* Send the data from the pbuf to the interface, one pbuf at a - time. The size of the data in each pbuf is kept in the ->len - variable. */ - send data from(q->payload, q->len); - } - - signal that packet should be sent(); - -#if ETH_PAD_SIZE - pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ -#endif - - LINK_STATS_INC(link.xmit); - - return ERR_OK; -} - -/** - * Should allocate a pbuf and transfer the bytes of the incoming - * packet from the interface into the pbuf. - * - * @param netif the lwip network interface structure for this ethernetif - * @return a pbuf filled with the received packet (including MAC header) - * NULL on memory error - */ -static struct pbuf * -low_level_input(struct netif *netif) -{ - struct ethernetif *ethernetif = netif->state; - struct pbuf *p, *q; - u16_t len; - - /* Obtain the size of the packet and put it into the "len" - variable. */ - len = ; - -#if ETH_PAD_SIZE - len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ -#endif - - /* We allocate a pbuf chain of pbufs from the pool. */ - p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); - - if (p != NULL) { - -#if ETH_PAD_SIZE - pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ -#endif - - /* We iterate over the pbuf chain until we have read the entire - * packet into the pbuf. */ - for(q = p; q != NULL; q = q->next) { - /* Read enough bytes to fill this pbuf in the chain. The - * available data in the pbuf is given by the q->len - * variable. - * This does not necessarily have to be a memcpy, you can also preallocate - * pbufs for a DMA-enabled MAC and after receiving truncate it to the - * actually received size. In this case, ensure the tot_len member of the - * pbuf is the sum of the chained pbuf len members. - */ - read data into(q->payload, q->len); - } - acknowledge that packet has been read(); - -#if ETH_PAD_SIZE - pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ -#endif - - LINK_STATS_INC(link.recv); - } else { - drop packet(); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - } - - return p; -} - -/** - * This function should be called when a packet is ready to be read - * from the interface. It uses the function low_level_input() that - * should handle the actual reception of bytes from the network - * interface. Then the type of the received packet is determined and - * the appropriate input function is called. - * - * @param netif the lwip network interface structure for this ethernetif - */ -static void -ethernetif_input(struct netif *netif) -{ - struct ethernetif *ethernetif; - struct eth_hdr *ethhdr; - struct pbuf *p; - - ethernetif = netif->state; - - /* move received packet into a new pbuf */ - p = low_level_input(netif); - /* no packet could be read, silently ignore this */ - if (p == NULL) return; - /* points to packet payload, which starts with an Ethernet header */ - ethhdr = p->payload; - - switch (htons(ethhdr->type)) { - /* IP or ARP packet? */ - case ETHTYPE_IP: - case ETHTYPE_ARP: -#if PPPOE_SUPPORT - /* PPPoE packet? */ - case ETHTYPE_PPPOEDISC: - case ETHTYPE_PPPOE: -#endif /* PPPOE_SUPPORT */ - /* full packet send to tcpip_thread to process */ - if (netif->input(p, netif)!=ERR_OK) - { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - pbuf_free(p); - p = NULL; - } - break; - - default: - pbuf_free(p); - p = NULL; - break; - } -} - -/** - * Should be called at the beginning of the program to set up the - * network interface. It calls the function low_level_init() to do the - * actual setup of the hardware. - * - * This function should be passed as a parameter to netif_add(). - * - * @param netif the lwip network interface structure for this ethernetif - * @return ERR_OK if the loopif is initialized - * ERR_MEM if private data couldn't be allocated - * any other err_t on error - */ -err_t -ethernetif_init(struct netif *netif) -{ - struct ethernetif *ethernetif; - - LWIP_ASSERT("netif != NULL", (netif != NULL)); - - ethernetif = mem_malloc(sizeof(struct ethernetif)); - if (ethernetif == NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n")); - return ERR_MEM; - } - -#if LWIP_NETIF_HOSTNAME - /* Initialize interface hostname */ - netif->hostname = "lwip"; -#endif /* LWIP_NETIF_HOSTNAME */ - - /* - * Initialize the snmp variables and counters inside the struct netif. - * The last argument should be replaced with your link speed, in units - * of bits per second. - */ - NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS); - - netif->state = ethernetif; - netif->name[0] = IFNAME0; - netif->name[1] = IFNAME1; - /* We directly use etharp_output() here to save a function call. - * You can instead declare your own function an call etharp_output() - * from it if you have to do some checks before sending (e.g. if link - * is available...) */ - netif->output = etharp_output; - netif->linkoutput = low_level_output; - - ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); - - /* initialize the hardware */ - low_level_init(netif); - - return ERR_OK; -} - -#endif /* 0 */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/auth.c b/user/mpy/lib/lwip/src/netif/ppp/auth.c deleted file mode 100644 index 0fd87a3..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/auth.c +++ /dev/null @@ -1,1334 +0,0 @@ -/***************************************************************************** -* auth.c - Network Authentication and Phase Control program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* Copyright (c) 1997 by Global Election Systems Inc. All rights reserved. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-08 Guy Lancaster , Global Election Systems Inc. -* Ported from public pppd code. -*****************************************************************************/ -/* - * auth.c - PPP authentication and phase control. - * - * Copyright (c) 1993 The Australian National University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the Australian National University. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "fsm.h" -#include "lcp.h" -#include "pap.h" -#include "chap.h" -#include "auth.h" -#include "ipcp.h" - -#if CBCP_SUPPORT -#include "cbcp.h" -#endif /* CBCP_SUPPORT */ - -#include "lwip/inet.h" - -#include - -#if 0 /* UNUSED */ -/* Bits in scan_authfile return value */ -#define NONWILD_SERVER 1 -#define NONWILD_CLIENT 2 - -#define ISWILD(word) (word[0] == '*' && word[1] == 0) -#endif /* UNUSED */ - -#if PAP_SUPPORT || CHAP_SUPPORT -/* The name by which the peer authenticated itself to us. */ -static char peer_authname[MAXNAMELEN]; -#endif /* PAP_SUPPORT || CHAP_SUPPORT */ - -/* Records which authentication operations haven't completed yet. */ -static int auth_pending[NUM_PPP]; - -/* Set if we have successfully called plogin() */ -static int logged_in; - -/* Set if we have run the /etc/ppp/auth-up script. */ -static int did_authup; /* @todo, we don't need this in lwip*/ - -/* List of addresses which the peer may use. */ -static struct wordlist *addresses[NUM_PPP]; - -#if 0 /* UNUSED */ -/* Wordlist giving addresses which the peer may use - without authenticating itself. */ -static struct wordlist *noauth_addrs; - -/* Extra options to apply, from the secrets file entry for the peer. */ -static struct wordlist *extra_options; -#endif /* UNUSED */ - -/* Number of network protocols which we have opened. */ -static int num_np_open; - -/* Number of network protocols which have come up. */ -static int num_np_up; - -#if PAP_SUPPORT || CHAP_SUPPORT -/* Set if we got the contents of passwd[] from the pap-secrets file. */ -static int passwd_from_file; -#endif /* PAP_SUPPORT || CHAP_SUPPORT */ - -#if 0 /* UNUSED */ -/* Set if we require authentication only because we have a default route. */ -static bool default_auth; - -/* Hook to enable a plugin to control the idle time limit */ -int (*idle_time_hook) __P((struct ppp_idle *)) = NULL; - -/* Hook for a plugin to say whether we can possibly authenticate any peer */ -int (*pap_check_hook) __P((void)) = NULL; - -/* Hook for a plugin to check the PAP user and password */ -int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp, - struct wordlist **paddrs, - struct wordlist **popts)) = NULL; - -/* Hook for a plugin to know about the PAP user logout */ -void (*pap_logout_hook) __P((void)) = NULL; - -/* Hook for a plugin to get the PAP password for authenticating us */ -int (*pap_passwd_hook) __P((char *user, char *passwd)) = NULL; - -/* - * This is used to ensure that we don't start an auth-up/down - * script while one is already running. - */ -enum script_state { - s_down, - s_up -}; - -static enum script_state auth_state = s_down; -static enum script_state auth_script_state = s_down; -static pid_t auth_script_pid = 0; - -/* - * Option variables. - * lwip: some of these are present in the ppp_settings structure - */ -bool uselogin = 0; /* Use /etc/passwd for checking PAP */ -bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ -bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ -bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ -bool usehostname = 0; /* Use hostname for our_name */ -bool auth_required = 0; /* Always require authentication from peer */ -bool allow_any_ip = 0; /* Allow peer to use any IP address */ -bool explicit_remote = 0; /* User specified explicit remote name */ -char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ - -#endif /* UNUSED */ - -/* Bits in auth_pending[] */ -#define PAP_WITHPEER 1 -#define PAP_PEER 2 -#define CHAP_WITHPEER 4 -#define CHAP_PEER 8 - -/* @todo, move this somewhere */ -/* Used for storing a sequence of words. Usually malloced. */ -struct wordlist { - struct wordlist *next; - char word[1]; -}; - - -extern char *crypt (const char *, const char *); - -/* Prototypes for procedures local to this file. */ - -static void network_phase (int); -static void check_idle (void *); -static void connect_time_expired (void *); -#if 0 -static int plogin (char *, char *, char **, int *); -#endif -static void plogout (void); -static int null_login (int); -static int get_pap_passwd (int, char *, char *); -static int have_pap_secret (void); -static int have_chap_secret (char *, char *, u32_t); -static int ip_addr_check (u32_t, struct wordlist *); - -#if 0 /* PAP_SUPPORT || CHAP_SUPPORT */ -static int scan_authfile (FILE *, char *, char *, char *, - struct wordlist **, struct wordlist **, - char *); -static void free_wordlist (struct wordlist *); -static void auth_script (char *); -static void auth_script_done (void *); -static void set_allowed_addrs (int unit, struct wordlist *addrs); -static int some_ip_ok (struct wordlist *); -static int setupapfile (char **); -static int privgroup (char **); -static int set_noauth_addr (char **); -static void check_access (FILE *, char *); -#endif /* 0 */ /* PAP_SUPPORT || CHAP_SUPPORT */ - -#if 0 /* UNUSED */ -/* - * Authentication-related options. - */ -option_t auth_options[] = { - { "require-pap", o_bool, &lcp_wantoptions[0].neg_upap, - "Require PAP authentication from peer", 1, &auth_required }, - { "+pap", o_bool, &lcp_wantoptions[0].neg_upap, - "Require PAP authentication from peer", 1, &auth_required }, - { "refuse-pap", o_bool, &refuse_pap, - "Don't agree to auth to peer with PAP", 1 }, - { "-pap", o_bool, &refuse_pap, - "Don't allow PAP authentication with peer", 1 }, - { "require-chap", o_bool, &lcp_wantoptions[0].neg_chap, - "Require CHAP authentication from peer", 1, &auth_required }, - { "+chap", o_bool, &lcp_wantoptions[0].neg_chap, - "Require CHAP authentication from peer", 1, &auth_required }, - { "refuse-chap", o_bool, &refuse_chap, - "Don't agree to auth to peer with CHAP", 1 }, - { "-chap", o_bool, &refuse_chap, - "Don't allow CHAP authentication with peer", 1 }, - { "name", o_string, our_name, - "Set local name for authentication", - OPT_PRIV|OPT_STATIC, NULL, MAXNAMELEN }, - { "user", o_string, user, - "Set name for auth with peer", OPT_STATIC, NULL, MAXNAMELEN }, - { "usehostname", o_bool, &usehostname, - "Must use hostname for authentication", 1 }, - { "remotename", o_string, remote_name, - "Set remote name for authentication", OPT_STATIC, - &explicit_remote, MAXNAMELEN }, - { "auth", o_bool, &auth_required, - "Require authentication from peer", 1 }, - { "noauth", o_bool, &auth_required, - "Don't require peer to authenticate", OPT_PRIV, &allow_any_ip }, - { "login", o_bool, &uselogin, - "Use system password database for PAP", 1 }, - { "papcrypt", o_bool, &cryptpap, - "PAP passwords are encrypted", 1 }, - { "+ua", o_special, (void *)setupapfile, - "Get PAP user and password from file" }, - { "password", o_string, passwd, - "Password for authenticating us to the peer", OPT_STATIC, - NULL, MAXSECRETLEN }, - { "privgroup", o_special, (void *)privgroup, - "Allow group members to use privileged options", OPT_PRIV }, - { "allow-ip", o_special, (void *)set_noauth_addr, - "Set IP address(es) which can be used without authentication", - OPT_PRIV }, - { NULL } -}; -#endif /* UNUSED */ -#if 0 /* UNUSED */ -/* - * setupapfile - specifies UPAP info for authenticating with peer. - */ -static int -setupapfile(char **argv) -{ - FILE * ufile; - int l; - - lcp_allowoptions[0].neg_upap = 1; - - /* open user info file */ - seteuid(getuid()); - ufile = fopen(*argv, "r"); - seteuid(0); - if (ufile == NULL) { - option_error("unable to open user login data file %s", *argv); - return 0; - } - check_access(ufile, *argv); - - /* get username */ - if (fgets(user, MAXNAMELEN - 1, ufile) == NULL - || fgets(passwd, MAXSECRETLEN - 1, ufile) == NULL){ - option_error("unable to read user login data file %s", *argv); - return 0; - } - fclose(ufile); - - /* get rid of newlines */ - l = strlen(user); - if (l > 0 && user[l-1] == '\n') - user[l-1] = 0; - l = strlen(passwd); - if (l > 0 && passwd[l-1] == '\n') - passwd[l-1] = 0; - - return (1); -} -#endif /* UNUSED */ - -#if 0 /* UNUSED */ -/* - * privgroup - allow members of the group to have privileged access. - */ -static int -privgroup(char **argv) -{ - struct group *g; - int i; - - g = getgrnam(*argv); - if (g == 0) { - option_error("group %s is unknown", *argv); - return 0; - } - for (i = 0; i < ngroups; ++i) { - if (groups[i] == g->gr_gid) { - privileged = 1; - break; - } - } - return 1; -} -#endif - -#if 0 /* UNUSED */ -/* - * set_noauth_addr - set address(es) that can be used without authentication. - * Equivalent to specifying an entry like `"" * "" addr' in pap-secrets. - */ -static int -set_noauth_addr(char **argv) -{ - char *addr = *argv; - int l = strlen(addr); - struct wordlist *wp; - - wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l + 1); - if (wp == NULL) - novm("allow-ip argument"); - wp->word = (char *) (wp + 1); - wp->next = noauth_addrs; - BCOPY(addr, wp->word, l); - noauth_addrs = wp; - return 1; -} -#endif /* UNUSED */ - -/* - * An Open on LCP has requested a change from Dead to Establish phase. - * Do what's necessary to bring the physical layer up. - */ -void -link_required(int unit) -{ - LWIP_UNUSED_ARG(unit); - - AUTHDEBUG(LOG_INFO, ("link_required: %d\n", unit)); -} - -/* - * LCP has terminated the link; go to the Dead phase and take the - * physical layer down. - */ -void -link_terminated(int unit) -{ - AUTHDEBUG(LOG_INFO, ("link_terminated: %d\n", unit)); - if (lcp_phase[unit] == PHASE_DEAD) { - return; - } - if (logged_in) { - plogout(); - } - lcp_phase[unit] = PHASE_DEAD; - AUTHDEBUG(LOG_NOTICE, ("Connection terminated.\n")); - pppLinkTerminated(unit); -} - -/* - * LCP has gone down; it will either die or try to re-establish. - */ -void -link_down(int unit) -{ - int i; - struct protent *protp; - - AUTHDEBUG(LOG_INFO, ("link_down: %d\n", unit)); - - if (did_authup) { - /* XXX Do link down processing. */ - did_authup = 0; - } - for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { - if (!protp->enabled_flag) { - continue; - } - if (protp->protocol != PPP_LCP && protp->lowerdown != NULL) { - (*protp->lowerdown)(unit); - } - if (protp->protocol < 0xC000 && protp->close != NULL) { - (*protp->close)(unit, "LCP down"); - } - } - num_np_open = 0; /* number of network protocols we have opened */ - num_np_up = 0; /* Number of network protocols which have come up */ - - if (lcp_phase[unit] != PHASE_DEAD) { - lcp_phase[unit] = PHASE_TERMINATE; - } - pppLinkDown(unit); -} - -/* - * The link is established. - * Proceed to the Dead, Authenticate or Network phase as appropriate. - */ -void -link_established(int unit) -{ - int auth; - int i; - struct protent *protp; - lcp_options *wo = &lcp_wantoptions[unit]; - lcp_options *go = &lcp_gotoptions[unit]; -#if PAP_SUPPORT || CHAP_SUPPORT - lcp_options *ho = &lcp_hisoptions[unit]; -#endif /* PAP_SUPPORT || CHAP_SUPPORT */ - - AUTHDEBUG(LOG_INFO, ("link_established: unit %d; Lowering up all protocols...\n", unit)); - /* - * Tell higher-level protocols that LCP is up. - */ - for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { - if (protp->protocol != PPP_LCP && protp->enabled_flag && protp->lowerup != NULL) { - (*protp->lowerup)(unit); - } - } - if (ppp_settings.auth_required && !(go->neg_chap || go->neg_upap)) { - /* - * We wanted the peer to authenticate itself, and it refused: - * treat it as though it authenticated with PAP using a username - * of "" and a password of "". If that's not OK, boot it out. - */ - if (!wo->neg_upap || !null_login(unit)) { - AUTHDEBUG(LOG_WARNING, ("peer refused to authenticate\n")); - lcp_close(unit, "peer refused to authenticate"); - return; - } - } - - lcp_phase[unit] = PHASE_AUTHENTICATE; - auth = 0; -#if CHAP_SUPPORT - if (go->neg_chap) { - ChapAuthPeer(unit, ppp_settings.our_name, go->chap_mdtype); - auth |= CHAP_PEER; - } -#endif /* CHAP_SUPPORT */ -#if PAP_SUPPORT && CHAP_SUPPORT - else -#endif /* PAP_SUPPORT && CHAP_SUPPORT */ -#if PAP_SUPPORT - if (go->neg_upap) { - upap_authpeer(unit); - auth |= PAP_PEER; - } -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT - if (ho->neg_chap) { - ChapAuthWithPeer(unit, ppp_settings.user, ho->chap_mdtype); - auth |= CHAP_WITHPEER; - } -#endif /* CHAP_SUPPORT */ -#if PAP_SUPPORT && CHAP_SUPPORT - else -#endif /* PAP_SUPPORT && CHAP_SUPPORT */ -#if PAP_SUPPORT - if (ho->neg_upap) { - if (ppp_settings.passwd[0] == 0) { - passwd_from_file = 1; - if (!get_pap_passwd(unit, ppp_settings.user, ppp_settings.passwd)) { - AUTHDEBUG(LOG_ERR, ("No secret found for PAP login\n")); - } - } - upap_authwithpeer(unit, ppp_settings.user, ppp_settings.passwd); - auth |= PAP_WITHPEER; - } -#endif /* PAP_SUPPORT */ - auth_pending[unit] = auth; - - if (!auth) { - network_phase(unit); - } -} - -/* - * Proceed to the network phase. - */ -static void -network_phase(int unit) -{ - int i; - struct protent *protp; - lcp_options *go = &lcp_gotoptions[unit]; - - /* - * If the peer had to authenticate, run the auth-up script now. - */ - if ((go->neg_chap || go->neg_upap) && !did_authup) { - /* XXX Do setup for peer authentication. */ - did_authup = 1; - } - -#if CBCP_SUPPORT - /* - * If we negotiated callback, do it now. - */ - if (go->neg_cbcp) { - lcp_phase[unit] = PHASE_CALLBACK; - (*cbcp_protent.open)(unit); - return; - } -#endif /* CBCP_SUPPORT */ - - lcp_phase[unit] = PHASE_NETWORK; - for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { - if (protp->protocol < 0xC000 && protp->enabled_flag && protp->open != NULL) { - (*protp->open)(unit); - if (protp->protocol != PPP_CCP) { - ++num_np_open; - } - } - } - - if (num_np_open == 0) { - /* nothing to do */ - lcp_close(0, "No network protocols running"); - } -} -/* @todo: add void start_networks(void) here (pppd 2.3.11) */ - -/* - * The peer has failed to authenticate himself using `protocol'. - */ -void -auth_peer_fail(int unit, u16_t protocol) -{ - LWIP_UNUSED_ARG(protocol); - - AUTHDEBUG(LOG_INFO, ("auth_peer_fail: %d proto=%X\n", unit, protocol)); - /* - * Authentication failure: take the link down - */ - lcp_close(unit, "Authentication failed"); -} - - -#if PAP_SUPPORT || CHAP_SUPPORT -/* - * The peer has been successfully authenticated using `protocol'. - */ -void -auth_peer_success(int unit, u16_t protocol, char *name, int namelen) -{ - int pbit; - - AUTHDEBUG(LOG_INFO, ("auth_peer_success: %d proto=%X\n", unit, protocol)); - switch (protocol) { - case PPP_CHAP: - pbit = CHAP_PEER; - break; - case PPP_PAP: - pbit = PAP_PEER; - break; - default: - AUTHDEBUG(LOG_WARNING, ("auth_peer_success: unknown protocol %x\n", protocol)); - return; - } - - /* - * Save the authenticated name of the peer for later. - */ - if (namelen > (int)sizeof(peer_authname) - 1) { - namelen = sizeof(peer_authname) - 1; - } - BCOPY(name, peer_authname, namelen); - peer_authname[namelen] = 0; - - /* - * If there is no more authentication still to be done, - * proceed to the network (or callback) phase. - */ - if ((auth_pending[unit] &= ~pbit) == 0) { - network_phase(unit); - } -} - -/* - * We have failed to authenticate ourselves to the peer using `protocol'. - */ -void -auth_withpeer_fail(int unit, u16_t protocol) -{ - int errCode = PPPERR_AUTHFAIL; - - LWIP_UNUSED_ARG(protocol); - - AUTHDEBUG(LOG_INFO, ("auth_withpeer_fail: %d proto=%X\n", unit, protocol)); - if (passwd_from_file) { - BZERO(ppp_settings.passwd, MAXSECRETLEN); - } - - /* - * We've failed to authenticate ourselves to our peer. - * He'll probably take the link down, and there's not much - * we can do except wait for that. - */ - pppIOCtl(unit, PPPCTLS_ERRCODE, &errCode); - lcp_close(unit, "Failed to authenticate ourselves to peer"); -} - -/* - * We have successfully authenticated ourselves with the peer using `protocol'. - */ -void -auth_withpeer_success(int unit, u16_t protocol) -{ - int pbit; - - AUTHDEBUG(LOG_INFO, ("auth_withpeer_success: %d proto=%X\n", unit, protocol)); - switch (protocol) { - case PPP_CHAP: - pbit = CHAP_WITHPEER; - break; - case PPP_PAP: - if (passwd_from_file) { - BZERO(ppp_settings.passwd, MAXSECRETLEN); - } - pbit = PAP_WITHPEER; - break; - default: - AUTHDEBUG(LOG_WARNING, ("auth_peer_success: unknown protocol %x\n", protocol)); - pbit = 0; - } - - /* - * If there is no more authentication still being done, - * proceed to the network (or callback) phase. - */ - if ((auth_pending[unit] &= ~pbit) == 0) { - network_phase(unit); - } -} -#endif /* PAP_SUPPORT || CHAP_SUPPORT */ - - -/* - * np_up - a network protocol has come up. - */ -void -np_up(int unit, u16_t proto) -{ - LWIP_UNUSED_ARG(unit); - LWIP_UNUSED_ARG(proto); - - AUTHDEBUG(LOG_INFO, ("np_up: %d proto=%X\n", unit, proto)); - if (num_np_up == 0) { - AUTHDEBUG(LOG_INFO, ("np_up: maxconnect=%d idle_time_limit=%d\n",ppp_settings.maxconnect,ppp_settings.idle_time_limit)); - /* - * At this point we consider that the link has come up successfully. - */ - if (ppp_settings.idle_time_limit > 0) { - TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit); - } - - /* - * Set a timeout to close the connection once the maximum - * connect time has expired. - */ - if (ppp_settings.maxconnect > 0) { - TIMEOUT(connect_time_expired, 0, ppp_settings.maxconnect); - } - } - ++num_np_up; -} - -/* - * np_down - a network protocol has gone down. - */ -void -np_down(int unit, u16_t proto) -{ - LWIP_UNUSED_ARG(unit); - LWIP_UNUSED_ARG(proto); - - AUTHDEBUG(LOG_INFO, ("np_down: %d proto=%X\n", unit, proto)); - if (--num_np_up == 0 && ppp_settings.idle_time_limit > 0) { - UNTIMEOUT(check_idle, NULL); - } -} - -/* - * np_finished - a network protocol has finished using the link. - */ -void -np_finished(int unit, u16_t proto) -{ - LWIP_UNUSED_ARG(unit); - LWIP_UNUSED_ARG(proto); - - AUTHDEBUG(LOG_INFO, ("np_finished: %d proto=%X\n", unit, proto)); - if (--num_np_open <= 0) { - /* no further use for the link: shut up shop. */ - lcp_close(0, "No network protocols running"); - } -} - -/* - * check_idle - check whether the link has been idle for long - * enough that we can shut it down. - */ -static void -check_idle(void *arg) -{ - struct ppp_idle idle; - u_short itime; - - LWIP_UNUSED_ARG(arg); - if (!get_idle_time(0, &idle)) { - return; - } - itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); - if (itime >= ppp_settings.idle_time_limit) { - /* link is idle: shut it down. */ - AUTHDEBUG(LOG_INFO, ("Terminating connection due to lack of activity.\n")); - lcp_close(0, "Link inactive"); - } else { - TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit - itime); - } -} - -/* - * connect_time_expired - log a message and close the connection. - */ -static void -connect_time_expired(void *arg) -{ - LWIP_UNUSED_ARG(arg); - - AUTHDEBUG(LOG_INFO, ("Connect time expired\n")); - lcp_close(0, "Connect time expired"); /* Close connection */ -} - -#if 0 /* UNUSED */ -/* - * auth_check_options - called to check authentication options. - */ -void -auth_check_options(void) -{ - lcp_options *wo = &lcp_wantoptions[0]; - int can_auth; - ipcp_options *ipwo = &ipcp_wantoptions[0]; - u32_t remote; - - /* Default our_name to hostname, and user to our_name */ - if (ppp_settings.our_name[0] == 0 || ppp_settings.usehostname) { - strcpy(ppp_settings.our_name, ppp_settings.hostname); - } - - if (ppp_settings.user[0] == 0) { - strcpy(ppp_settings.user, ppp_settings.our_name); - } - - /* If authentication is required, ask peer for CHAP or PAP. */ - if (ppp_settings.auth_required && !wo->neg_chap && !wo->neg_upap) { - wo->neg_chap = 1; - wo->neg_upap = 1; - } - - /* - * Check whether we have appropriate secrets to use - * to authenticate the peer. - */ - can_auth = wo->neg_upap && have_pap_secret(); - if (!can_auth && wo->neg_chap) { - remote = ipwo->accept_remote? 0: ipwo->hisaddr; - can_auth = have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote); - } - - if (ppp_settings.auth_required && !can_auth) { - ppp_panic("No auth secret"); - } -} -#endif /* UNUSED */ - -/* - * auth_reset - called when LCP is starting negotiations to recheck - * authentication options, i.e. whether we have appropriate secrets - * to use for authenticating ourselves and/or the peer. - */ -void -auth_reset(int unit) -{ - lcp_options *go = &lcp_gotoptions[unit]; - lcp_options *ao = &lcp_allowoptions[0]; - ipcp_options *ipwo = &ipcp_wantoptions[0]; - u32_t remote; - - AUTHDEBUG(LOG_INFO, ("auth_reset: %d\n", unit)); - ao->neg_upap = !ppp_settings.refuse_pap && (ppp_settings.passwd[0] != 0 || get_pap_passwd(unit, NULL, NULL)); - ao->neg_chap = !ppp_settings.refuse_chap && ppp_settings.passwd[0] != 0 /*have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0)*/; - - if (go->neg_upap && !have_pap_secret()) { - go->neg_upap = 0; - } - if (go->neg_chap) { - remote = ipwo->accept_remote? 0: ipwo->hisaddr; - if (!have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote)) { - go->neg_chap = 0; - } - } -} - -#if PAP_SUPPORT -/* - * check_passwd - Check the user name and passwd against the PAP secrets - * file. If requested, also check against the system password database, - * and login the user if OK. - * - * returns: - * UPAP_AUTHNAK: Authentication failed. - * UPAP_AUTHACK: Authentication succeeded. - * In either case, msg points to an appropriate message. - */ -u_char -check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, char **msg, int *msglen) -{ -#if 1 /* XXX Assume all entries OK. */ - LWIP_UNUSED_ARG(unit); - LWIP_UNUSED_ARG(auser); - LWIP_UNUSED_ARG(userlen); - LWIP_UNUSED_ARG(apasswd); - LWIP_UNUSED_ARG(passwdlen); - LWIP_UNUSED_ARG(msglen); - *msg = (char *) 0; - return UPAP_AUTHACK; /* XXX Assume all entries OK. */ -#else - u_char ret = 0; - struct wordlist *addrs = NULL; - char passwd[256], user[256]; - char secret[MAXWORDLEN]; - static u_short attempts = 0; - - /* - * Make copies of apasswd and auser, then null-terminate them. - */ - BCOPY(apasswd, passwd, passwdlen); - passwd[passwdlen] = '\0'; - BCOPY(auser, user, userlen); - user[userlen] = '\0'; - *msg = (char *) 0; - - /* XXX Validate user name and password. */ - ret = UPAP_AUTHACK; /* XXX Assume all entries OK. */ - - if (ret == UPAP_AUTHNAK) { - if (*msg == (char *) 0) { - *msg = "Login incorrect"; - } - *msglen = strlen(*msg); - /* - * Frustrate passwd stealer programs. - * Allow 10 tries, but start backing off after 3 (stolen from login). - * On 10'th, drop the connection. - */ - if (attempts++ >= 10) { - AUTHDEBUG(LOG_WARNING, ("%d LOGIN FAILURES BY %s\n", attempts, user)); - /*ppp_panic("Excess Bad Logins");*/ - } - if (attempts > 3) { - /* @todo: this was sleep(), i.e. seconds, not milliseconds - * I don't think we really need this in lwIP - we would block tcpip_thread! - */ - /*sys_msleep((attempts - 3) * 5);*/ - } - if (addrs != NULL) { - free_wordlist(addrs); - } - } else { - attempts = 0; /* Reset count */ - if (*msg == (char *) 0) { - *msg = "Login ok"; - } - *msglen = strlen(*msg); - set_allowed_addrs(unit, addrs); - } - - BZERO(passwd, sizeof(passwd)); - BZERO(secret, sizeof(secret)); - - return ret; -#endif -} -#endif /* PAP_SUPPORT */ - -#if 0 /* UNUSED */ -/* - * This function is needed for PAM. - */ - -#ifdef USE_PAM - -/* lwip does not support PAM*/ - -#endif /* USE_PAM */ - -#endif /* UNUSED */ - - -#if 0 /* UNUSED */ -/* - * plogin - Check the user name and password against the system - * password database, and login the user if OK. - * - * returns: - * UPAP_AUTHNAK: Login failed. - * UPAP_AUTHACK: Login succeeded. - * In either case, msg points to an appropriate message. - */ -static int -plogin(char *user, char *passwd, char **msg, int *msglen) -{ - - LWIP_UNUSED_ARG(user); - LWIP_UNUSED_ARG(passwd); - LWIP_UNUSED_ARG(msg); - LWIP_UNUSED_ARG(msglen); - - - /* The new lines are here align the file when - * compared against the pppd 2.3.11 code */ - - - - - - - - - - - - - - - - - /* XXX Fail until we decide that we want to support logins. */ - return (UPAP_AUTHNAK); -} -#endif - - - -/* - * plogout - Logout the user. - */ -static void -plogout(void) -{ - logged_in = 0; -} - -/* - * null_login - Check if a username of "" and a password of "" are - * acceptable, and iff so, set the list of acceptable IP addresses - * and return 1. - */ -static int -null_login(int unit) -{ - LWIP_UNUSED_ARG(unit); - /* XXX Fail until we decide that we want to support logins. */ - return 0; -} - - -/* - * get_pap_passwd - get a password for authenticating ourselves with - * our peer using PAP. Returns 1 on success, 0 if no suitable password - * could be found. - */ -static int -get_pap_passwd(int unit, char *user, char *passwd) -{ - LWIP_UNUSED_ARG(unit); -/* normally we would reject PAP if no password is provided, - but this causes problems with some providers (like CHT in Taiwan) - who incorrectly request PAP and expect a bogus/empty password, so - always provide a default user/passwd of "none"/"none" - - @todo: This should be configured by the user, instead of being hardcoded here! -*/ - if(user) { - strcpy(user, "none"); - } - if(passwd) { - strcpy(passwd, "none"); - } - return 1; -} - -/* - * have_pap_secret - check whether we have a PAP file with any - * secrets that we could possibly use for authenticating the peer. - */ -static int -have_pap_secret(void) -{ - /* XXX Fail until we set up our passwords. */ - return 0; -} - -/* - * have_chap_secret - check whether we have a CHAP file with a - * secret that we could possibly use for authenticating `client' - * on `server'. Either can be the null string, meaning we don't - * know the identity yet. - */ -static int -have_chap_secret(char *client, char *server, u32_t remote) -{ - LWIP_UNUSED_ARG(client); - LWIP_UNUSED_ARG(server); - LWIP_UNUSED_ARG(remote); - - /* XXX Fail until we set up our passwords. */ - return 0; -} -#if CHAP_SUPPORT - -/* - * get_secret - open the CHAP secret file and return the secret - * for authenticating the given client on the given server. - * (We could be either client or server). - */ -int -get_secret(int unit, char *client, char *server, char *secret, int *secret_len, int save_addrs) -{ -#if 1 - int len; - struct wordlist *addrs; - - LWIP_UNUSED_ARG(unit); - LWIP_UNUSED_ARG(server); - LWIP_UNUSED_ARG(save_addrs); - - addrs = NULL; - - if(!client || !client[0] || strcmp(client, ppp_settings.user)) { - return 0; - } - - len = (int)strlen(ppp_settings.passwd); - if (len > MAXSECRETLEN) { - AUTHDEBUG(LOG_ERR, ("Secret for %s on %s is too long\n", client, server)); - len = MAXSECRETLEN; - } - - BCOPY(ppp_settings.passwd, secret, len); - *secret_len = len; - - return 1; -#else - int ret = 0, len; - struct wordlist *addrs; - char secbuf[MAXWORDLEN]; - - addrs = NULL; - secbuf[0] = 0; - - /* XXX Find secret. */ - if (ret < 0) { - return 0; - } - - if (save_addrs) { - set_allowed_addrs(unit, addrs); - } - - len = strlen(secbuf); - if (len > MAXSECRETLEN) { - AUTHDEBUG(LOG_ERR, ("Secret for %s on %s is too long\n", client, server)); - len = MAXSECRETLEN; - } - - BCOPY(secbuf, secret, len); - BZERO(secbuf, sizeof(secbuf)); - *secret_len = len; - - return 1; -#endif -} -#endif /* CHAP_SUPPORT */ - - -#if 0 /* PAP_SUPPORT || CHAP_SUPPORT */ -/* - * set_allowed_addrs() - set the list of allowed addresses. - */ -static void -set_allowed_addrs(int unit, struct wordlist *addrs) -{ - if (addresses[unit] != NULL) { - free_wordlist(addresses[unit]); - } - addresses[unit] = addrs; - -#if 0 - /* - * If there's only one authorized address we might as well - * ask our peer for that one right away - */ - if (addrs != NULL && addrs->next == NULL) { - char *p = addrs->word; - struct ipcp_options *wo = &ipcp_wantoptions[unit]; - u32_t a; - struct hostent *hp; - - if (wo->hisaddr == 0 && *p != '!' && *p != '-' && strchr(p, '/') == NULL) { - hp = gethostbyname(p); - if (hp != NULL && hp->h_addrtype == AF_INET) { - a = *(u32_t *)hp->h_addr; - } else { - a = inet_addr(p); - } - if (a != (u32_t) -1) { - wo->hisaddr = a; - } - } - } -#endif -} -#endif /* 0 */ /* PAP_SUPPORT || CHAP_SUPPORT */ - -/* - * auth_ip_addr - check whether the peer is authorized to use - * a given IP address. Returns 1 if authorized, 0 otherwise. - */ -int -auth_ip_addr(int unit, u32_t addr) -{ - return ip_addr_check(addr, addresses[unit]); -} - -static int /* @todo: integrate this funtion into auth_ip_addr()*/ -ip_addr_check(u32_t addr, struct wordlist *addrs) -{ - /* don't allow loopback or multicast address */ - if (bad_ip_adrs(addr)) { - return 0; - } - - if (addrs == NULL) { - return !ppp_settings.auth_required; /* no addresses authorized */ - } - - /* XXX All other addresses allowed. */ - return 1; -} - -/* - * bad_ip_adrs - return 1 if the IP address is one we don't want - * to use, such as an address in the loopback net or a multicast address. - * addr is in network byte order. - */ -int -bad_ip_adrs(u32_t addr) -{ - addr = ntohl(addr); - return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET - || IN_MULTICAST(addr) || IN_BADCLASS(addr); -} - -#if 0 /* UNUSED */ /* PAP_SUPPORT || CHAP_SUPPORT */ -/* - * some_ip_ok - check a wordlist to see if it authorizes any - * IP address(es). - */ -static int -some_ip_ok(struct wordlist *addrs) -{ - for (; addrs != 0; addrs = addrs->next) { - if (addrs->word[0] == '-') - break; - if (addrs->word[0] != '!') - return 1; /* some IP address is allowed */ - } - return 0; -} - -/* - * check_access - complain if a secret file has too-liberal permissions. - */ -static void -check_access(FILE *f, char *filename) -{ - struct stat sbuf; - - if (fstat(fileno(f), &sbuf) < 0) { - warn("cannot stat secret file %s: %m", filename); - } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) { - warn("Warning - secret file %s has world and/or group access", - filename); - } -} - - -/* - * scan_authfile - Scan an authorization file for a secret suitable - * for authenticating `client' on `server'. The return value is -1 - * if no secret is found, otherwise >= 0. The return value has - * NONWILD_CLIENT set if the secret didn't have "*" for the client, and - * NONWILD_SERVER set if the secret didn't have "*" for the server. - * Any following words on the line up to a "--" (i.e. address authorization - * info) are placed in a wordlist and returned in *addrs. Any - * following words (extra options) are placed in a wordlist and - * returned in *opts. - * We assume secret is NULL or points to MAXWORDLEN bytes of space. - */ -static int -scan_authfile(FILE *f, char *client, char *server, char *secret, struct wordlist **addrs, struct wordlist **opts, char *filename) -{ - /* We do not (currently) need this in lwip */ - return 0; /* dummy */ -} -/* - * free_wordlist - release memory allocated for a wordlist. - */ -static void -free_wordlist(struct wordlist *wp) -{ - struct wordlist *next; - - while (wp != NULL) { - next = wp->next; - free(wp); - wp = next; - } -} - -/* - * auth_script_done - called when the auth-up or auth-down script - * has finished. - */ -static void -auth_script_done(void *arg) -{ - auth_script_pid = 0; - switch (auth_script_state) { - case s_up: - if (auth_state == s_down) { - auth_script_state = s_down; - auth_script(_PATH_AUTHDOWN); - } - break; - case s_down: - if (auth_state == s_up) { - auth_script_state = s_up; - auth_script(_PATH_AUTHUP); - } - break; - } -} - -/* - * auth_script - execute a script with arguments - * interface-name peer-name real-user tty speed - */ -static void -auth_script(char *script) -{ - char strspeed[32]; - struct passwd *pw; - char struid[32]; - char *user_name; - char *argv[8]; - - if ((pw = getpwuid(getuid())) != NULL && pw->pw_name != NULL) - user_name = pw->pw_name; - else { - slprintf(struid, sizeof(struid), "%d", getuid()); - user_name = struid; - } - slprintf(strspeed, sizeof(strspeed), "%d", baud_rate); - - argv[0] = script; - argv[1] = ifname; - argv[2] = peer_authname; - argv[3] = user_name; - argv[4] = devnam; - argv[5] = strspeed; - argv[6] = NULL; - - auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL); -} -#endif /* 0 */ /* PAP_SUPPORT || CHAP_SUPPORT */ -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/auth.h b/user/mpy/lib/lwip/src/netif/ppp/auth.h deleted file mode 100644 index a8069ec..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/auth.h +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** -* auth.h - PPP Authentication and phase control header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1998 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-04 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD pppd.h. -*****************************************************************************/ -/* - * pppd.h - PPP daemon global declarations. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -#ifndef AUTH_H -#define AUTH_H - -/*********************** -*** PUBLIC FUNCTIONS *** -***********************/ - -/* we are starting to use the link */ -void link_required (int); - -/* we are finished with the link */ -void link_terminated (int); - -/* the LCP layer has left the Opened state */ -void link_down (int); - -/* the link is up; authenticate now */ -void link_established (int); - -/* a network protocol has come up */ -void np_up (int, u16_t); - -/* a network protocol has gone down */ -void np_down (int, u16_t); - -/* a network protocol no longer needs link */ -void np_finished (int, u16_t); - -/* peer failed to authenticate itself */ -void auth_peer_fail (int, u16_t); - -/* peer successfully authenticated itself */ -void auth_peer_success (int, u16_t, char *, int); - -/* we failed to authenticate ourselves */ -void auth_withpeer_fail (int, u16_t); - -/* we successfully authenticated ourselves */ -void auth_withpeer_success (int, u16_t); - -/* check authentication options supplied */ -void auth_check_options (void); - -/* check what secrets we have */ -void auth_reset (int); - -/* Check peer-supplied username/password */ -u_char check_passwd (int, char *, int, char *, int, char **, int *); - -/* get "secret" for chap */ -int get_secret (int, char *, char *, char *, int *, int); - -/* check if IP address is authorized */ -int auth_ip_addr (int, u32_t); - -/* check if IP address is unreasonable */ -int bad_ip_adrs (u32_t); - -#endif /* AUTH_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chap.c b/user/mpy/lib/lwip/src/netif/ppp/chap.c deleted file mode 100644 index f10e27d..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/chap.c +++ /dev/null @@ -1,908 +0,0 @@ -/*** WARNING - THIS HAS NEVER BEEN FINISHED ***/ -/***************************************************************************** -* chap.c - Network Challenge Handshake Authentication Protocol program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-04 Guy Lancaster , Global Election Systems Inc. -* Original based on BSD chap.c. -*****************************************************************************/ -/* - * chap.c - Challenge Handshake Authentication Protocol. - * - * Copyright (c) 1993 The Australian National University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the Australian National University. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Copyright (c) 1991 Gregory M. Christy. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Gregory M. Christy. The name of the author may not be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#if CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "magic.h" -#include "randm.h" -#include "auth.h" -#include "md5.h" -#include "chap.h" -#include "chpms.h" - -#include - -#if 0 /* UNUSED */ -/* - * Command-line options. - */ -static option_t chap_option_list[] = { - { "chap-restart", o_int, &chap[0].timeouttime, - "Set timeout for CHAP" }, - { "chap-max-challenge", o_int, &chap[0].max_transmits, - "Set max #xmits for challenge" }, - { "chap-interval", o_int, &chap[0].chal_interval, - "Set interval for rechallenge" }, -#ifdef MSLANMAN - { "ms-lanman", o_bool, &ms_lanman, - "Use LanMan passwd when using MS-CHAP", 1 }, -#endif - { NULL } -}; -#endif /* UNUSED */ - -/* - * Protocol entry points. - */ -static void ChapInit (int); -static void ChapLowerUp (int); -static void ChapLowerDown (int); -static void ChapInput (int, u_char *, int); -static void ChapProtocolReject (int); -#if PPP_ADDITIONAL_CALLBACKS -static int ChapPrintPkt (u_char *, int, void (*) (void *, char *, ...), void *); -#endif - -struct protent chap_protent = { - PPP_CHAP, - ChapInit, - ChapInput, - ChapProtocolReject, - ChapLowerUp, - ChapLowerDown, - NULL, - NULL, -#if PPP_ADDITIONAL_CALLBACKS - ChapPrintPkt, - NULL, -#endif /* PPP_ADDITIONAL_CALLBACKS */ - 1, - "CHAP", -#if PPP_ADDITIONAL_CALLBACKS - NULL, - NULL, - NULL -#endif /* PPP_ADDITIONAL_CALLBACKS */ -}; - -chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */ - -static void ChapChallengeTimeout (void *); -static void ChapResponseTimeout (void *); -static void ChapReceiveChallenge (chap_state *, u_char *, u_char, int); -static void ChapRechallenge (void *); -static void ChapReceiveResponse (chap_state *, u_char *, int, int); -static void ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len); -static void ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len); -static void ChapSendStatus (chap_state *, int); -static void ChapSendChallenge (chap_state *); -static void ChapSendResponse (chap_state *); -static void ChapGenChallenge (chap_state *); - -/* - * ChapInit - Initialize a CHAP unit. - */ -static void -ChapInit(int unit) -{ - chap_state *cstate = &chap[unit]; - - BZERO(cstate, sizeof(*cstate)); - cstate->unit = unit; - cstate->clientstate = CHAPCS_INITIAL; - cstate->serverstate = CHAPSS_INITIAL; - cstate->timeouttime = CHAP_DEFTIMEOUT; - cstate->max_transmits = CHAP_DEFTRANSMITS; - /* random number generator is initialized in magic_init */ -} - - -/* - * ChapAuthWithPeer - Authenticate us with our peer (start client). - * - */ -void -ChapAuthWithPeer(int unit, char *our_name, u_char digest) -{ - chap_state *cstate = &chap[unit]; - - cstate->resp_name = our_name; - cstate->resp_type = digest; - - if (cstate->clientstate == CHAPCS_INITIAL || - cstate->clientstate == CHAPCS_PENDING) { - /* lower layer isn't up - wait until later */ - cstate->clientstate = CHAPCS_PENDING; - return; - } - - /* - * We get here as a result of LCP coming up. - * So even if CHAP was open before, we will - * have to re-authenticate ourselves. - */ - cstate->clientstate = CHAPCS_LISTEN; -} - - -/* - * ChapAuthPeer - Authenticate our peer (start server). - */ -void -ChapAuthPeer(int unit, char *our_name, u_char digest) -{ - chap_state *cstate = &chap[unit]; - - cstate->chal_name = our_name; - cstate->chal_type = digest; - - if (cstate->serverstate == CHAPSS_INITIAL || - cstate->serverstate == CHAPSS_PENDING) { - /* lower layer isn't up - wait until later */ - cstate->serverstate = CHAPSS_PENDING; - return; - } - - ChapGenChallenge(cstate); - ChapSendChallenge(cstate); /* crank it up dude! */ - cstate->serverstate = CHAPSS_INITIAL_CHAL; -} - - -/* - * ChapChallengeTimeout - Timeout expired on sending challenge. - */ -static void -ChapChallengeTimeout(void *arg) -{ - chap_state *cstate = (chap_state *) arg; - - /* if we aren't sending challenges, don't worry. then again we */ - /* probably shouldn't be here either */ - if (cstate->serverstate != CHAPSS_INITIAL_CHAL && - cstate->serverstate != CHAPSS_RECHALLENGE) { - return; - } - - if (cstate->chal_transmits >= cstate->max_transmits) { - /* give up on peer */ - CHAPDEBUG(LOG_ERR, ("Peer failed to respond to CHAP challenge\n")); - cstate->serverstate = CHAPSS_BADAUTH; - auth_peer_fail(cstate->unit, PPP_CHAP); - return; - } - - ChapSendChallenge(cstate); /* Re-send challenge */ -} - - -/* - * ChapResponseTimeout - Timeout expired on sending response. - */ -static void -ChapResponseTimeout(void *arg) -{ - chap_state *cstate = (chap_state *) arg; - - /* if we aren't sending a response, don't worry. */ - if (cstate->clientstate != CHAPCS_RESPONSE) { - return; - } - - ChapSendResponse(cstate); /* re-send response */ -} - - -/* - * ChapRechallenge - Time to challenge the peer again. - */ -static void -ChapRechallenge(void *arg) -{ - chap_state *cstate = (chap_state *) arg; - - /* if we aren't sending a response, don't worry. */ - if (cstate->serverstate != CHAPSS_OPEN) { - return; - } - - ChapGenChallenge(cstate); - ChapSendChallenge(cstate); - cstate->serverstate = CHAPSS_RECHALLENGE; -} - - -/* - * ChapLowerUp - The lower layer is up. - * - * Start up if we have pending requests. - */ -static void -ChapLowerUp(int unit) -{ - chap_state *cstate = &chap[unit]; - - if (cstate->clientstate == CHAPCS_INITIAL) { - cstate->clientstate = CHAPCS_CLOSED; - } else if (cstate->clientstate == CHAPCS_PENDING) { - cstate->clientstate = CHAPCS_LISTEN; - } - - if (cstate->serverstate == CHAPSS_INITIAL) { - cstate->serverstate = CHAPSS_CLOSED; - } else if (cstate->serverstate == CHAPSS_PENDING) { - ChapGenChallenge(cstate); - ChapSendChallenge(cstate); - cstate->serverstate = CHAPSS_INITIAL_CHAL; - } -} - - -/* - * ChapLowerDown - The lower layer is down. - * - * Cancel all timeouts. - */ -static void -ChapLowerDown(int unit) -{ - chap_state *cstate = &chap[unit]; - - /* Timeout(s) pending? Cancel if so. */ - if (cstate->serverstate == CHAPSS_INITIAL_CHAL || - cstate->serverstate == CHAPSS_RECHALLENGE) { - UNTIMEOUT(ChapChallengeTimeout, cstate); - } else if (cstate->serverstate == CHAPSS_OPEN - && cstate->chal_interval != 0) { - UNTIMEOUT(ChapRechallenge, cstate); - } - if (cstate->clientstate == CHAPCS_RESPONSE) { - UNTIMEOUT(ChapResponseTimeout, cstate); - } - cstate->clientstate = CHAPCS_INITIAL; - cstate->serverstate = CHAPSS_INITIAL; -} - - -/* - * ChapProtocolReject - Peer doesn't grok CHAP. - */ -static void -ChapProtocolReject(int unit) -{ - chap_state *cstate = &chap[unit]; - - if (cstate->serverstate != CHAPSS_INITIAL && - cstate->serverstate != CHAPSS_CLOSED) { - auth_peer_fail(unit, PPP_CHAP); - } - if (cstate->clientstate != CHAPCS_INITIAL && - cstate->clientstate != CHAPCS_CLOSED) { - auth_withpeer_fail(unit, PPP_CHAP); /* lwip: just sets the PPP error code on this unit to PPPERR_AUTHFAIL */ - } - ChapLowerDown(unit); /* shutdown chap */ -} - - -/* - * ChapInput - Input CHAP packet. - */ -static void -ChapInput(int unit, u_char *inpacket, int packet_len) -{ - chap_state *cstate = &chap[unit]; - u_char *inp; - u_char code, id; - int len; - - /* - * Parse header (code, id and length). - * If packet too short, drop it. - */ - inp = inpacket; - if (packet_len < CHAP_HEADERLEN) { - CHAPDEBUG(LOG_INFO, ("ChapInput: rcvd short header.\n")); - return; - } - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < CHAP_HEADERLEN) { - CHAPDEBUG(LOG_INFO, ("ChapInput: rcvd illegal length.\n")); - return; - } - if (len > packet_len) { - CHAPDEBUG(LOG_INFO, ("ChapInput: rcvd short packet.\n")); - return; - } - len -= CHAP_HEADERLEN; - - /* - * Action depends on code (as in fact it usually does :-). - */ - switch (code) { - case CHAP_CHALLENGE: - ChapReceiveChallenge(cstate, inp, id, len); - break; - - case CHAP_RESPONSE: - ChapReceiveResponse(cstate, inp, id, len); - break; - - case CHAP_FAILURE: - ChapReceiveFailure(cstate, inp, id, len); - break; - - case CHAP_SUCCESS: - ChapReceiveSuccess(cstate, inp, id, len); - break; - - default: /* Need code reject? */ - CHAPDEBUG(LOG_WARNING, ("Unknown CHAP code (%d) received.\n", code)); - break; - } -} - - -/* - * ChapReceiveChallenge - Receive Challenge and send Response. - */ -static void -ChapReceiveChallenge(chap_state *cstate, u_char *inp, u_char id, int len) -{ - int rchallenge_len; - u_char *rchallenge; - int secret_len; - char secret[MAXSECRETLEN]; - char rhostname[256]; - MD5_CTX mdContext; - u_char hash[MD5_SIGNATURE_SIZE]; - - CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: Rcvd id %d.\n", id)); - if (cstate->clientstate == CHAPCS_CLOSED || - cstate->clientstate == CHAPCS_PENDING) { - CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: in state %d\n", - cstate->clientstate)); - return; - } - - if (len < 2) { - CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: rcvd short packet.\n")); - return; - } - - GETCHAR(rchallenge_len, inp); - len -= sizeof (u_char) + rchallenge_len; /* now name field length */ - if (len < 0) { - CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: rcvd short packet.\n")); - return; - } - rchallenge = inp; - INCPTR(rchallenge_len, inp); - - if (len >= (int)sizeof(rhostname)) { - len = sizeof(rhostname) - 1; - } - BCOPY(inp, rhostname, len); - rhostname[len] = '\000'; - - CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: received name field '%s'\n", - rhostname)); - - /* Microsoft doesn't send their name back in the PPP packet */ - if (ppp_settings.remote_name[0] != 0 && (ppp_settings.explicit_remote || rhostname[0] == 0)) { - strncpy(rhostname, ppp_settings.remote_name, sizeof(rhostname)); - rhostname[sizeof(rhostname) - 1] = 0; - CHAPDEBUG(LOG_INFO, ("ChapReceiveChallenge: using '%s' as remote name\n", - rhostname)); - } - - /* get secret for authenticating ourselves with the specified host */ - if (!get_secret(cstate->unit, cstate->resp_name, rhostname, - secret, &secret_len, 0)) { - secret_len = 0; /* assume null secret if can't find one */ - CHAPDEBUG(LOG_WARNING, ("No CHAP secret found for authenticating us to %s\n", - rhostname)); - } - - /* cancel response send timeout if necessary */ - if (cstate->clientstate == CHAPCS_RESPONSE) { - UNTIMEOUT(ChapResponseTimeout, cstate); - } - - cstate->resp_id = id; - cstate->resp_transmits = 0; - - /* generate MD based on negotiated type */ - switch (cstate->resp_type) { - - case CHAP_DIGEST_MD5: - MD5Init(&mdContext); - MD5Update(&mdContext, &cstate->resp_id, 1); - MD5Update(&mdContext, (u_char*)secret, secret_len); - MD5Update(&mdContext, rchallenge, rchallenge_len); - MD5Final(hash, &mdContext); - BCOPY(hash, cstate->response, MD5_SIGNATURE_SIZE); - cstate->resp_length = MD5_SIGNATURE_SIZE; - break; - -#if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len); - break; -#endif - - default: - CHAPDEBUG(LOG_INFO, ("unknown digest type %d\n", cstate->resp_type)); - return; - } - - BZERO(secret, sizeof(secret)); - ChapSendResponse(cstate); -} - - -/* - * ChapReceiveResponse - Receive and process response. - */ -static void -ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) -{ - u_char *remmd, remmd_len; - int secret_len, old_state; - int code; - char rhostname[256]; - MD5_CTX mdContext; - char secret[MAXSECRETLEN]; - u_char hash[MD5_SIGNATURE_SIZE]; - - CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: Rcvd id %d.\n", id)); - - if (cstate->serverstate == CHAPSS_CLOSED || - cstate->serverstate == CHAPSS_PENDING) { - CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: in state %d\n", - cstate->serverstate)); - return; - } - - if (id != cstate->chal_id) { - return; /* doesn't match ID of last challenge */ - } - - /* - * If we have received a duplicate or bogus Response, - * we have to send the same answer (Success/Failure) - * as we did for the first Response we saw. - */ - if (cstate->serverstate == CHAPSS_OPEN) { - ChapSendStatus(cstate, CHAP_SUCCESS); - return; - } - if (cstate->serverstate == CHAPSS_BADAUTH) { - ChapSendStatus(cstate, CHAP_FAILURE); - return; - } - - if (len < 2) { - CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: rcvd short packet.\n")); - return; - } - GETCHAR(remmd_len, inp); /* get length of MD */ - remmd = inp; /* get pointer to MD */ - INCPTR(remmd_len, inp); - - len -= sizeof (u_char) + remmd_len; - if (len < 0) { - CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: rcvd short packet.\n")); - return; - } - - UNTIMEOUT(ChapChallengeTimeout, cstate); - - if (len >= (int)sizeof(rhostname)) { - len = sizeof(rhostname) - 1; - } - BCOPY(inp, rhostname, len); - rhostname[len] = '\000'; - - CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: received name field: %s\n", - rhostname)); - - /* - * Get secret for authenticating them with us, - * do the hash ourselves, and compare the result. - */ - code = CHAP_FAILURE; - if (!get_secret(cstate->unit, rhostname, cstate->chal_name, - secret, &secret_len, 1)) { - CHAPDEBUG(LOG_WARNING, ("No CHAP secret found for authenticating %s\n", - rhostname)); - } else { - /* generate MD based on negotiated type */ - switch (cstate->chal_type) { - - case CHAP_DIGEST_MD5: /* only MD5 is defined for now */ - if (remmd_len != MD5_SIGNATURE_SIZE) { - break; /* it's not even the right length */ - } - MD5Init(&mdContext); - MD5Update(&mdContext, &cstate->chal_id, 1); - MD5Update(&mdContext, (u_char*)secret, secret_len); - MD5Update(&mdContext, cstate->challenge, cstate->chal_len); - MD5Final(hash, &mdContext); - - /* compare local and remote MDs and send the appropriate status */ - if (memcmp (hash, remmd, MD5_SIGNATURE_SIZE) == 0) { - code = CHAP_SUCCESS; /* they are the same! */ - } - break; - - default: - CHAPDEBUG(LOG_INFO, ("unknown digest type %d\n", cstate->chal_type)); - } - } - - BZERO(secret, sizeof(secret)); - ChapSendStatus(cstate, code); - - if (code == CHAP_SUCCESS) { - old_state = cstate->serverstate; - cstate->serverstate = CHAPSS_OPEN; - if (old_state == CHAPSS_INITIAL_CHAL) { - auth_peer_success(cstate->unit, PPP_CHAP, rhostname, len); - } - if (cstate->chal_interval != 0) { - TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval); - } - } else { - CHAPDEBUG(LOG_ERR, ("CHAP peer authentication failed\n")); - cstate->serverstate = CHAPSS_BADAUTH; - auth_peer_fail(cstate->unit, PPP_CHAP); - } -} - -/* - * ChapReceiveSuccess - Receive Success - */ -static void -ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len) -{ - LWIP_UNUSED_ARG(id); - LWIP_UNUSED_ARG(inp); - - CHAPDEBUG(LOG_INFO, ("ChapReceiveSuccess: Rcvd id %d.\n", id)); - - if (cstate->clientstate == CHAPCS_OPEN) { - /* presumably an answer to a duplicate response */ - return; - } - - if (cstate->clientstate != CHAPCS_RESPONSE) { - /* don't know what this is */ - CHAPDEBUG(LOG_INFO, ("ChapReceiveSuccess: in state %d\n", - cstate->clientstate)); - return; - } - - UNTIMEOUT(ChapResponseTimeout, cstate); - - /* - * Print message. - */ - if (len > 0) { - PRINTMSG(inp, len); - } - - cstate->clientstate = CHAPCS_OPEN; - - auth_withpeer_success(cstate->unit, PPP_CHAP); -} - - -/* - * ChapReceiveFailure - Receive failure. - */ -static void -ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len) -{ - LWIP_UNUSED_ARG(id); - LWIP_UNUSED_ARG(inp); - - CHAPDEBUG(LOG_INFO, ("ChapReceiveFailure: Rcvd id %d.\n", id)); - - if (cstate->clientstate != CHAPCS_RESPONSE) { - /* don't know what this is */ - CHAPDEBUG(LOG_INFO, ("ChapReceiveFailure: in state %d\n", - cstate->clientstate)); - return; - } - - UNTIMEOUT(ChapResponseTimeout, cstate); - - /* - * Print message. - */ - if (len > 0) { - PRINTMSG(inp, len); - } - - CHAPDEBUG(LOG_ERR, ("CHAP authentication failed\n")); - auth_withpeer_fail(cstate->unit, PPP_CHAP); /* lwip: just sets the PPP error code on this unit to PPPERR_AUTHFAIL */ -} - - -/* - * ChapSendChallenge - Send an Authenticate challenge. - */ -static void -ChapSendChallenge(chap_state *cstate) -{ - u_char *outp; - int chal_len, name_len; - int outlen; - - chal_len = cstate->chal_len; - name_len = (int)strlen(cstate->chal_name); - outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len; - outp = outpacket_buf[cstate->unit]; - - MAKEHEADER(outp, PPP_CHAP); /* paste in a CHAP header */ - - PUTCHAR(CHAP_CHALLENGE, outp); - PUTCHAR(cstate->chal_id, outp); - PUTSHORT(outlen, outp); - - PUTCHAR(chal_len, outp); /* put length of challenge */ - BCOPY(cstate->challenge, outp, chal_len); - INCPTR(chal_len, outp); - - BCOPY(cstate->chal_name, outp, name_len); /* append hostname */ - - pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); - - CHAPDEBUG(LOG_INFO, ("ChapSendChallenge: Sent id %d.\n", cstate->chal_id)); - - TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime); - ++cstate->chal_transmits; -} - - -/* - * ChapSendStatus - Send a status response (ack or nak). - */ -static void -ChapSendStatus(chap_state *cstate, int code) -{ - u_char *outp; - int outlen, msglen; - char msg[256]; /* @todo: this can be a char*, no strcpy needed */ - - if (code == CHAP_SUCCESS) { - strcpy(msg, "Welcome!"); - } else { - strcpy(msg, "I don't like you. Go 'way."); - } - msglen = (int)strlen(msg); - - outlen = CHAP_HEADERLEN + msglen; - outp = outpacket_buf[cstate->unit]; - - MAKEHEADER(outp, PPP_CHAP); /* paste in a header */ - - PUTCHAR(code, outp); - PUTCHAR(cstate->chal_id, outp); - PUTSHORT(outlen, outp); - BCOPY(msg, outp, msglen); - pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); - - CHAPDEBUG(LOG_INFO, ("ChapSendStatus: Sent code %d, id %d.\n", code, - cstate->chal_id)); -} - -/* - * ChapGenChallenge is used to generate a pseudo-random challenge string of - * a pseudo-random length between min_len and max_len. The challenge - * string and its length are stored in *cstate, and various other fields of - * *cstate are initialized. - */ - -static void -ChapGenChallenge(chap_state *cstate) -{ - int chal_len; - u_char *ptr = cstate->challenge; - int i; - - /* pick a random challenge length between MIN_CHALLENGE_LENGTH and - MAX_CHALLENGE_LENGTH */ - chal_len = (unsigned) - ((((magic() >> 16) * - (MAX_CHALLENGE_LENGTH - MIN_CHALLENGE_LENGTH)) >> 16) - + MIN_CHALLENGE_LENGTH); - LWIP_ASSERT("chal_len <= 0xff", chal_len <= 0xffff); - cstate->chal_len = (u_char)chal_len; - cstate->chal_id = ++cstate->id; - cstate->chal_transmits = 0; - - /* generate a random string */ - for (i = 0; i < chal_len; i++ ) { - *ptr++ = (char) (magic() & 0xff); - } -} - -/* - * ChapSendResponse - send a response packet with values as specified - * in *cstate. - */ -/* ARGSUSED */ -static void -ChapSendResponse(chap_state *cstate) -{ - u_char *outp; - int outlen, md_len, name_len; - - md_len = cstate->resp_length; - name_len = (int)strlen(cstate->resp_name); - outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len; - outp = outpacket_buf[cstate->unit]; - - MAKEHEADER(outp, PPP_CHAP); - - PUTCHAR(CHAP_RESPONSE, outp); /* we are a response */ - PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */ - PUTSHORT(outlen, outp); /* packet length */ - - PUTCHAR(md_len, outp); /* length of MD */ - BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */ - INCPTR(md_len, outp); - - BCOPY(cstate->resp_name, outp, name_len); /* append our name */ - - /* send the packet */ - pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); - - cstate->clientstate = CHAPCS_RESPONSE; - TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime); - ++cstate->resp_transmits; -} - -#if PPP_ADDITIONAL_CALLBACKS -static char *ChapCodenames[] = { - "Challenge", "Response", "Success", "Failure" -}; -/* - * ChapPrintPkt - print the contents of a CHAP packet. - */ -static int -ChapPrintPkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) -{ - int code, id, len; - int clen, nlen; - u_char x; - - if (plen < CHAP_HEADERLEN) { - return 0; - } - GETCHAR(code, p); - GETCHAR(id, p); - GETSHORT(len, p); - if (len < CHAP_HEADERLEN || len > plen) { - return 0; - } - - if (code >= 1 && code <= sizeof(ChapCodenames) / sizeof(char *)) { - printer(arg, " %s", ChapCodenames[code-1]); - } else { - printer(arg, " code=0x%x", code); - } - printer(arg, " id=0x%x", id); - len -= CHAP_HEADERLEN; - switch (code) { - case CHAP_CHALLENGE: - case CHAP_RESPONSE: - if (len < 1) { - break; - } - clen = p[0]; - if (len < clen + 1) { - break; - } - ++p; - nlen = len - clen - 1; - printer(arg, " <"); - for (; clen > 0; --clen) { - GETCHAR(x, p); - printer(arg, "%.2x", x); - } - printer(arg, ">, name = %.*Z", nlen, p); - break; - case CHAP_FAILURE: - case CHAP_SUCCESS: - printer(arg, " %.*Z", len, p); - break; - default: - for (clen = len; clen > 0; --clen) { - GETCHAR(x, p); - printer(arg, " %.2x", x); - } - } - - return len + CHAP_HEADERLEN; -} -#endif /* PPP_ADDITIONAL_CALLBACKS */ - -#endif /* CHAP_SUPPORT */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chap.h b/user/mpy/lib/lwip/src/netif/ppp/chap.h deleted file mode 100644 index fedcab8..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/chap.h +++ /dev/null @@ -1,150 +0,0 @@ -/***************************************************************************** -* chap.h - Network Challenge Handshake Authentication Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1998 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-03 Guy Lancaster , Global Election Systems Inc. -* Original built from BSD network code. -******************************************************************************/ -/* - * chap.h - Challenge Handshake Authentication Protocol definitions. - * - * Copyright (c) 1993 The Australian National University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the Australian National University. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Copyright (c) 1991 Gregory M. Christy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the author. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: chap.h,v 1.6 2010/01/24 13:19:34 goldsimon Exp $ - */ - -#ifndef CHAP_H -#define CHAP_H - -/* Code + ID + length */ -#define CHAP_HEADERLEN 4 - -/* - * CHAP codes. - */ - -#define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */ -#define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */ -#define CHAP_MICROSOFT 0x80 /* use Microsoft-compatible alg. */ -#define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */ - -#define CHAP_CHALLENGE 1 -#define CHAP_RESPONSE 2 -#define CHAP_SUCCESS 3 -#define CHAP_FAILURE 4 - -/* - * Challenge lengths (for challenges we send) and other limits. - */ -#define MIN_CHALLENGE_LENGTH 32 -#define MAX_CHALLENGE_LENGTH 64 -#define MAX_RESPONSE_LENGTH 64 /* sufficient for MD5 or MS-CHAP */ - -/* - * Each interface is described by a chap structure. - */ - -typedef struct chap_state { - int unit; /* Interface unit number */ - int clientstate; /* Client state */ - int serverstate; /* Server state */ - u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */ - u_char chal_len; /* challenge length */ - u_char chal_id; /* ID of last challenge */ - u_char chal_type; /* hash algorithm for challenges */ - u_char id; /* Current id */ - char *chal_name; /* Our name to use with challenge */ - int chal_interval; /* Time until we challenge peer again */ - int timeouttime; /* Timeout time in seconds */ - int max_transmits; /* Maximum # of challenge transmissions */ - int chal_transmits; /* Number of transmissions of challenge */ - int resp_transmits; /* Number of transmissions of response */ - u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */ - u_char resp_length; /* length of response */ - u_char resp_id; /* ID for response messages */ - u_char resp_type; /* hash algorithm for responses */ - char *resp_name; /* Our name to send with response */ -} chap_state; - - -/* - * Client (peer) states. - */ -#define CHAPCS_INITIAL 0 /* Lower layer down, not opened */ -#define CHAPCS_CLOSED 1 /* Lower layer up, not opened */ -#define CHAPCS_PENDING 2 /* Auth us to peer when lower up */ -#define CHAPCS_LISTEN 3 /* Listening for a challenge */ -#define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */ -#define CHAPCS_OPEN 5 /* We've received Success */ - -/* - * Server (authenticator) states. - */ -#define CHAPSS_INITIAL 0 /* Lower layer down, not opened */ -#define CHAPSS_CLOSED 1 /* Lower layer up, not opened */ -#define CHAPSS_PENDING 2 /* Auth peer when lower up */ -#define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */ -#define CHAPSS_OPEN 4 /* We've sent a Success msg */ -#define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */ -#define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */ - -extern chap_state chap[]; - -void ChapAuthWithPeer (int, char *, u_char); -void ChapAuthPeer (int, char *, u_char); - -extern struct protent chap_protent; - -#endif /* CHAP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chpms.c b/user/mpy/lib/lwip/src/netif/ppp/chpms.c deleted file mode 100644 index 81a887b..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/chpms.c +++ /dev/null @@ -1,396 +0,0 @@ -/*** WARNING - THIS CODE HAS NOT BEEN FINISHED! ***/ -/*** The original PPPD code is written in a way to require either the UNIX DES - encryption functions encrypt(3) and setkey(3) or the DES library libdes. - Since both is not included in lwIP, MSCHAP currently does not work! */ -/***************************************************************************** -* chpms.c - Network MicroSoft Challenge Handshake Authentication Protocol program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* Copyright (c) 1997 by Global Election Systems Inc. All rights reserved. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-08 Guy Lancaster , Global Election Systems Inc. -* Original based on BSD chap_ms.c. -*****************************************************************************/ -/* - * chap_ms.c - Microsoft MS-CHAP compatible implementation. - * - * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. - * http://www.strataware.com/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Eric Rosenquist. The name of the author may not be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* - * Modifications by Lauri Pesonen / lpesonen@clinet.fi, april 1997 - * - * Implemented LANManager type password response to MS-CHAP challenges. - * Now pppd provides both NT style and LANMan style blocks, and the - * prefered is set by option "ms-lanman". Default is to use NT. - * The hash text (StdText) was taken from Win95 RASAPI32.DLL. - * - * You should also use DOMAIN\\USERNAME as described in README.MSCHAP80 - */ - -#define USE_CRYPT - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#if MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "md4.h" -#ifndef USE_CRYPT -#include "des.h" -#endif -#include "chap.h" -#include "chpms.h" - -#include - - -/*************************/ -/*** LOCAL DEFINITIONS ***/ -/*************************/ - - -/************************/ -/*** LOCAL DATA TYPES ***/ -/************************/ -typedef struct { - u_char LANManResp[24]; - u_char NTResp[24]; - u_char UseNT; /* If 1, ignore the LANMan response field */ -} MS_ChapResponse; -/* We use MS_CHAP_RESPONSE_LEN, rather than sizeof(MS_ChapResponse), - in case this struct gets padded. */ - - - -/***********************************/ -/*** LOCAL FUNCTION DECLARATIONS ***/ -/***********************************/ - -/* XXX Don't know what to do with these. */ -extern void setkey(const char *); -extern void encrypt(char *, int); - -static void DesEncrypt (u_char *, u_char *, u_char *); -static void MakeKey (u_char *, u_char *); - -#ifdef USE_CRYPT -static void Expand (u_char *, u_char *); -static void Collapse (u_char *, u_char *); -#endif - -static void ChallengeResponse( - u_char *challenge, /* IN 8 octets */ - u_char *pwHash, /* IN 16 octets */ - u_char *response /* OUT 24 octets */ -); -static void ChapMS_NT( - char *rchallenge, - int rchallenge_len, - char *secret, - int secret_len, - MS_ChapResponse *response -); -static u_char Get7Bits( - u_char *input, - int startBit -); - -static void -ChallengeResponse( u_char *challenge, /* IN 8 octets */ - u_char *pwHash, /* IN 16 octets */ - u_char *response /* OUT 24 octets */) -{ - u_char ZPasswordHash[21]; - - BZERO(ZPasswordHash, sizeof(ZPasswordHash)); - BCOPY(pwHash, ZPasswordHash, 16); - -#if 0 - log_packet(ZPasswordHash, sizeof(ZPasswordHash), "ChallengeResponse - ZPasswordHash", LOG_DEBUG); -#endif - - DesEncrypt(challenge, ZPasswordHash + 0, response + 0); - DesEncrypt(challenge, ZPasswordHash + 7, response + 8); - DesEncrypt(challenge, ZPasswordHash + 14, response + 16); - -#if 0 - log_packet(response, 24, "ChallengeResponse - response", LOG_DEBUG); -#endif -} - - -#ifdef USE_CRYPT -static void -DesEncrypt( u_char *clear, /* IN 8 octets */ - u_char *key, /* IN 7 octets */ - u_char *cipher /* OUT 8 octets */) -{ - u_char des_key[8]; - u_char crypt_key[66]; - u_char des_input[66]; - - MakeKey(key, des_key); - - Expand(des_key, crypt_key); - setkey((char*)crypt_key); - -#if 0 - CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X\n", - clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); -#endif - - Expand(clear, des_input); - encrypt((char*)des_input, 0); - Collapse(des_input, cipher); - -#if 0 - CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X\n", - cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); -#endif -} - -#else /* USE_CRYPT */ - -static void -DesEncrypt( u_char *clear, /* IN 8 octets */ - u_char *key, /* IN 7 octets */ - u_char *cipher /* OUT 8 octets */) -{ - des_cblock des_key; - des_key_schedule key_schedule; - - MakeKey(key, des_key); - - des_set_key(&des_key, key_schedule); - -#if 0 - CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X\n", - clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); -#endif - - des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, key_schedule, 1); - -#if 0 - CHAPDEBUG(LOG_INFO, ("DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X\n", - cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); -#endif -} - -#endif /* USE_CRYPT */ - - -static u_char -Get7Bits( u_char *input, int startBit) -{ - register unsigned int word; - - word = (unsigned)input[startBit / 8] << 8; - word |= (unsigned)input[startBit / 8 + 1]; - - word >>= 15 - (startBit % 8 + 7); - - return word & 0xFE; -} - -#ifdef USE_CRYPT - -/* in == 8-byte string (expanded version of the 56-bit key) - * out == 64-byte string where each byte is either 1 or 0 - * Note that the low-order "bit" is always ignored by by setkey() - */ -static void -Expand(u_char *in, u_char *out) -{ - int j, c; - int i; - - for(i = 0; i < 64; in++){ - c = *in; - for(j = 7; j >= 0; j--) { - *out++ = (c >> j) & 01; - } - i += 8; - } -} - -/* The inverse of Expand - */ -static void -Collapse(u_char *in, u_char *out) -{ - int j; - int i; - unsigned int c; - - for (i = 0; i < 64; i += 8, out++) { - c = 0; - for (j = 7; j >= 0; j--, in++) { - c |= *in << j; - } - *out = c & 0xff; - } -} -#endif - -static void -MakeKey( u_char *key, /* IN 56 bit DES key missing parity bits */ - u_char *des_key /* OUT 64 bit DES key with parity bits added */) -{ - des_key[0] = Get7Bits(key, 0); - des_key[1] = Get7Bits(key, 7); - des_key[2] = Get7Bits(key, 14); - des_key[3] = Get7Bits(key, 21); - des_key[4] = Get7Bits(key, 28); - des_key[5] = Get7Bits(key, 35); - des_key[6] = Get7Bits(key, 42); - des_key[7] = Get7Bits(key, 49); - -#ifndef USE_CRYPT - des_set_odd_parity((des_cblock *)des_key); -#endif - -#if 0 - CHAPDEBUG(LOG_INFO, ("MakeKey: 56-bit input : %02X%02X%02X%02X%02X%02X%02X\n", - key[0], key[1], key[2], key[3], key[4], key[5], key[6])); - CHAPDEBUG(LOG_INFO, ("MakeKey: 64-bit output: %02X%02X%02X%02X%02X%02X%02X%02X\n", - des_key[0], des_key[1], des_key[2], des_key[3], des_key[4], des_key[5], des_key[6], des_key[7])); -#endif -} - -static void -ChapMS_NT( char *rchallenge, - int rchallenge_len, - char *secret, - int secret_len, - MS_ChapResponse *response) -{ - int i; - MDstruct md4Context; - u_char unicodePassword[MAX_NT_PASSWORD * 2]; - static int low_byte_first = -1; - - LWIP_UNUSED_ARG(rchallenge_len); - - /* Initialize the Unicode version of the secret (== password). */ - /* This implicitly supports 8-bit ISO8859/1 characters. */ - BZERO(unicodePassword, sizeof(unicodePassword)); - for (i = 0; i < secret_len; i++) { - unicodePassword[i * 2] = (u_char)secret[i]; - } - MDbegin(&md4Context); - MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */ - - if (low_byte_first == -1) { - low_byte_first = (PP_HTONS((unsigned short int)1) != 1); - } - if (low_byte_first == 0) { - /* @todo: arg type - u_long* or u_int* ? */ - MDreverse((unsigned int*)&md4Context); /* sfb 961105 */ - } - - MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */ - - ChallengeResponse((u_char*)rchallenge, (u_char*)md4Context.buffer, response->NTResp); -} - -#ifdef MSLANMAN -static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ - -static void -ChapMS_LANMan( char *rchallenge, - int rchallenge_len, - char *secret, - int secret_len, - MS_ChapResponse *response) -{ - int i; - u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ - u_char PasswordHash[16]; - - /* LANMan password is case insensitive */ - BZERO(UcasePassword, sizeof(UcasePassword)); - for (i = 0; i < secret_len; i++) { - UcasePassword[i] = (u_char)toupper(secret[i]); - } - DesEncrypt( StdText, UcasePassword + 0, PasswordHash + 0 ); - DesEncrypt( StdText, UcasePassword + 7, PasswordHash + 8 ); - ChallengeResponse(rchallenge, PasswordHash, response->LANManResp); -} -#endif - -void -ChapMS( chap_state *cstate, char *rchallenge, int rchallenge_len, char *secret, int secret_len) -{ - MS_ChapResponse response; -#ifdef MSLANMAN - extern int ms_lanman; -#endif - -#if 0 - CHAPDEBUG(LOG_INFO, ("ChapMS: secret is '%.*s'\n", secret_len, secret)); -#endif - BZERO(&response, sizeof(response)); - - /* Calculate both always */ - ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, &response); - -#ifdef MSLANMAN - ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, &response); - - /* prefered method is set by option */ - response.UseNT = !ms_lanman; -#else - response.UseNT = 1; -#endif - - BCOPY(&response, cstate->response, MS_CHAP_RESPONSE_LEN); - cstate->resp_length = MS_CHAP_RESPONSE_LEN; -} - -#endif /* MSCHAP_SUPPORT */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/chpms.h b/user/mpy/lib/lwip/src/netif/ppp/chpms.h deleted file mode 100644 index df070fb..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/chpms.h +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************** -* chpms.h - Network Microsoft Challenge Handshake Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1998 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 98-01-30 Guy Lancaster , Global Election Systems Inc. -* Original built from BSD network code. -******************************************************************************/ -/* - * chap.h - Challenge Handshake Authentication Protocol definitions. - * - * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. - * http://www.strataware.com/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Eric Rosenquist. The name of the author may not be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $ - */ - -#ifndef CHPMS_H -#define CHPMS_H - -#define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ - -void ChapMS (chap_state *, char *, int, char *, int); - -#endif /* CHPMS_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/fsm.c b/user/mpy/lib/lwip/src/netif/ppp/fsm.c deleted file mode 100644 index e8a254e..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/fsm.c +++ /dev/null @@ -1,890 +0,0 @@ -/***************************************************************************** -* fsm.c - Network Control Protocol Finite State Machine program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-01 Guy Lancaster , Global Election Systems Inc. -* Original based on BSD fsm.c. -*****************************************************************************/ -/* - * fsm.c - {Link, IP} Control Protocol Finite State Machine. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* - * TODO: - * Randomize fsm id on link/init. - * Deal with variable outgoing MTU. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "fsm.h" - -#include - -#if PPP_DEBUG -static const char *ppperr_strerr[] = { - "LS_INITIAL", /* LS_INITIAL 0 */ - "LS_STARTING", /* LS_STARTING 1 */ - "LS_CLOSED", /* LS_CLOSED 2 */ - "LS_STOPPED", /* LS_STOPPED 3 */ - "LS_CLOSING", /* LS_CLOSING 4 */ - "LS_STOPPING", /* LS_STOPPING 5 */ - "LS_REQSENT", /* LS_REQSENT 6 */ - "LS_ACKRCVD", /* LS_ACKRCVD 7 */ - "LS_ACKSENT", /* LS_ACKSENT 8 */ - "LS_OPENED" /* LS_OPENED 9 */ -}; -#endif /* PPP_DEBUG */ - -static void fsm_timeout (void *); -static void fsm_rconfreq (fsm *, u_char, u_char *, int); -static void fsm_rconfack (fsm *, int, u_char *, int); -static void fsm_rconfnakrej (fsm *, int, int, u_char *, int); -static void fsm_rtermreq (fsm *, int, u_char *, int); -static void fsm_rtermack (fsm *); -static void fsm_rcoderej (fsm *, u_char *, int); -static void fsm_sconfreq (fsm *, int); - -#define PROTO_NAME(f) ((f)->callbacks->proto_name) - -int peer_mru[NUM_PPP]; - - -/* - * fsm_init - Initialize fsm. - * - * Initialize fsm state. - */ -void -fsm_init(fsm *f) -{ - f->state = LS_INITIAL; - f->flags = 0; - f->id = 0; /* XXX Start with random id? */ - f->timeouttime = FSM_DEFTIMEOUT; - f->maxconfreqtransmits = FSM_DEFMAXCONFREQS; - f->maxtermtransmits = FSM_DEFMAXTERMREQS; - f->maxnakloops = FSM_DEFMAXNAKLOOPS; - f->term_reason_len = 0; -} - - -/* - * fsm_lowerup - The lower layer is up. - */ -void -fsm_lowerup(fsm *f) -{ - int oldState = f->state; - - LWIP_UNUSED_ARG(oldState); - - switch( f->state ) { - case LS_INITIAL: - f->state = LS_CLOSED; - break; - - case LS_STARTING: - if( f->flags & OPT_SILENT ) { - f->state = LS_STOPPED; - } else { - /* Send an initial configure-request */ - fsm_sconfreq(f, 0); - f->state = LS_REQSENT; - } - break; - - default: - FSMDEBUG(LOG_INFO, ("%s: Up event in state %d (%s)!\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - } - - FSMDEBUG(LOG_INFO, ("%s: lowerup state %d (%s) -> %d (%s)\n", - PROTO_NAME(f), oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); -} - - -/* - * fsm_lowerdown - The lower layer is down. - * - * Cancel all timeouts and inform upper layers. - */ -void -fsm_lowerdown(fsm *f) -{ - int oldState = f->state; - - LWIP_UNUSED_ARG(oldState); - - switch( f->state ) { - case LS_CLOSED: - f->state = LS_INITIAL; - break; - - case LS_STOPPED: - f->state = LS_STARTING; - if( f->callbacks->starting ) { - (*f->callbacks->starting)(f); - } - break; - - case LS_CLOSING: - f->state = LS_INITIAL; - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - break; - - case LS_STOPPING: - case LS_REQSENT: - case LS_ACKRCVD: - case LS_ACKSENT: - f->state = LS_STARTING; - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - break; - - case LS_OPENED: - if( f->callbacks->down ) { - (*f->callbacks->down)(f); - } - f->state = LS_STARTING; - break; - - default: - FSMDEBUG(LOG_INFO, ("%s: Down event in state %d (%s)!\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - } - - FSMDEBUG(LOG_INFO, ("%s: lowerdown state %d (%s) -> %d (%s)\n", - PROTO_NAME(f), oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); -} - - -/* - * fsm_open - Link is allowed to come up. - */ -void -fsm_open(fsm *f) -{ - int oldState = f->state; - - LWIP_UNUSED_ARG(oldState); - - switch( f->state ) { - case LS_INITIAL: - f->state = LS_STARTING; - if( f->callbacks->starting ) { - (*f->callbacks->starting)(f); - } - break; - - case LS_CLOSED: - if( f->flags & OPT_SILENT ) { - f->state = LS_STOPPED; - } else { - /* Send an initial configure-request */ - fsm_sconfreq(f, 0); - f->state = LS_REQSENT; - } - break; - - case LS_CLOSING: - f->state = LS_STOPPING; - /* fall through */ - case LS_STOPPED: - case LS_OPENED: - if( f->flags & OPT_RESTART ) { - fsm_lowerdown(f); - fsm_lowerup(f); - } - break; - } - - FSMDEBUG(LOG_INFO, ("%s: open state %d (%s) -> %d (%s)\n", - PROTO_NAME(f), oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); -} - -#if 0 /* backport pppd 2.4.4b1; */ -/* - * terminate_layer - Start process of shutting down the FSM - * - * Cancel any timeout running, notify upper layers we're done, and - * send a terminate-request message as configured. - */ -static void -terminate_layer(fsm *f, int nextstate) -{ - /* @todo */ -} -#endif - -/* - * fsm_close - Start closing connection. - * - * Cancel timeouts and either initiate close or possibly go directly to - * the LS_CLOSED state. - */ -void -fsm_close(fsm *f, char *reason) -{ - int oldState = f->state; - - LWIP_UNUSED_ARG(oldState); - - f->term_reason = reason; - f->term_reason_len = (reason == NULL ? 0 : (int)strlen(reason)); - switch( f->state ) { - case LS_STARTING: - f->state = LS_INITIAL; - break; - case LS_STOPPED: - f->state = LS_CLOSED; - break; - case LS_STOPPING: - f->state = LS_CLOSING; - break; - - case LS_REQSENT: - case LS_ACKRCVD: - case LS_ACKSENT: - case LS_OPENED: - if( f->state != LS_OPENED ) { - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - } else if( f->callbacks->down ) { - (*f->callbacks->down)(f); /* Inform upper layers we're down */ - } - /* Init restart counter, send Terminate-Request */ - f->retransmits = f->maxtermtransmits; - fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, f, f->timeouttime); - --f->retransmits; - - f->state = LS_CLOSING; - break; - } - - FSMDEBUG(LOG_INFO, ("%s: close reason=%s state %d (%s) -> %d (%s)\n", - PROTO_NAME(f), reason, oldState, ppperr_strerr[oldState], f->state, ppperr_strerr[f->state])); -} - - -/* - * fsm_timeout - Timeout expired. - */ -static void -fsm_timeout(void *arg) -{ - fsm *f = (fsm *) arg; - - switch (f->state) { - case LS_CLOSING: - case LS_STOPPING: - if( f->retransmits <= 0 ) { - FSMDEBUG(LOG_WARNING, ("%s: timeout sending Terminate-Request state=%d (%s)\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - /* - * We've waited for an ack long enough. Peer probably heard us. - */ - f->state = (f->state == LS_CLOSING)? LS_CLOSED: LS_STOPPED; - if( f->callbacks->finished ) { - (*f->callbacks->finished)(f); - } - } else { - FSMDEBUG(LOG_WARNING, ("%s: timeout resending Terminate-Requests state=%d (%s)\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - /* Send Terminate-Request */ - fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, f, f->timeouttime); - --f->retransmits; - } - break; - - case LS_REQSENT: - case LS_ACKRCVD: - case LS_ACKSENT: - if (f->retransmits <= 0) { - FSMDEBUG(LOG_WARNING, ("%s: timeout sending Config-Requests state=%d (%s)\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - f->state = LS_STOPPED; - if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished ) { - (*f->callbacks->finished)(f); - } - } else { - FSMDEBUG(LOG_WARNING, ("%s: timeout resending Config-Request state=%d (%s)\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - /* Retransmit the configure-request */ - if (f->callbacks->retransmit) { - (*f->callbacks->retransmit)(f); - } - fsm_sconfreq(f, 1); /* Re-send Configure-Request */ - if( f->state == LS_ACKRCVD ) { - f->state = LS_REQSENT; - } - } - break; - - default: - FSMDEBUG(LOG_INFO, ("%s: UNHANDLED timeout event in state %d (%s)!\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - } -} - - -/* - * fsm_input - Input packet. - */ -void -fsm_input(fsm *f, u_char *inpacket, int l) -{ - u_char *inp = inpacket; - u_char code, id; - int len; - - /* - * Parse header (code, id and length). - * If packet too short, drop it. - */ - if (l < HEADERLEN) { - FSMDEBUG(LOG_WARNING, ("fsm_input(%x): Rcvd short header.\n", - f->protocol)); - return; - } - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < HEADERLEN) { - FSMDEBUG(LOG_INFO, ("fsm_input(%x): Rcvd illegal length.\n", - f->protocol)); - return; - } - if (len > l) { - FSMDEBUG(LOG_INFO, ("fsm_input(%x): Rcvd short packet.\n", - f->protocol)); - return; - } - len -= HEADERLEN; /* subtract header length */ - - if( f->state == LS_INITIAL || f->state == LS_STARTING ) { - FSMDEBUG(LOG_INFO, ("fsm_input(%x): Rcvd packet in state %d (%s).\n", - f->protocol, f->state, ppperr_strerr[f->state])); - return; - } - FSMDEBUG(LOG_INFO, ("fsm_input(%s):%d,%d,%d\n", PROTO_NAME(f), code, id, l)); - /* - * Action depends on code. - */ - switch (code) { - case CONFREQ: - fsm_rconfreq(f, id, inp, len); - break; - - case CONFACK: - fsm_rconfack(f, id, inp, len); - break; - - case CONFNAK: - case CONFREJ: - fsm_rconfnakrej(f, code, id, inp, len); - break; - - case TERMREQ: - fsm_rtermreq(f, id, inp, len); - break; - - case TERMACK: - fsm_rtermack(f); - break; - - case CODEREJ: - fsm_rcoderej(f, inp, len); - break; - - default: - FSMDEBUG(LOG_INFO, ("fsm_input(%s): default: \n", PROTO_NAME(f))); - if( !f->callbacks->extcode || - !(*f->callbacks->extcode)(f, code, id, inp, len) ) { - fsm_sdata(f, CODEREJ, ++f->id, inpacket, len + HEADERLEN); - } - break; - } -} - - -/* - * fsm_rconfreq - Receive Configure-Request. - */ -static void -fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) -{ - int code, reject_if_disagree; - - FSMDEBUG(LOG_INFO, ("fsm_rconfreq(%s): Rcvd id %d state=%d (%s)\n", - PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); - switch( f->state ) { - case LS_CLOSED: - /* Go away, we're closed */ - fsm_sdata(f, TERMACK, id, NULL, 0); - return; - case LS_CLOSING: - case LS_STOPPING: - return; - - case LS_OPENED: - /* Go down and restart negotiation */ - if( f->callbacks->down ) { - (*f->callbacks->down)(f); /* Inform upper layers */ - } - fsm_sconfreq(f, 0); /* Send initial Configure-Request */ - break; - - case LS_STOPPED: - /* Negotiation started by our peer */ - fsm_sconfreq(f, 0); /* Send initial Configure-Request */ - f->state = LS_REQSENT; - break; - } - - /* - * Pass the requested configuration options - * to protocol-specific code for checking. - */ - if (f->callbacks->reqci) { /* Check CI */ - reject_if_disagree = (f->nakloops >= f->maxnakloops); - code = (*f->callbacks->reqci)(f, inp, &len, reject_if_disagree); - } else if (len) { - code = CONFREJ; /* Reject all CI */ - } else { - code = CONFACK; - } - - /* send the Ack, Nak or Rej to the peer */ - fsm_sdata(f, (u_char)code, id, inp, len); - - if (code == CONFACK) { - if (f->state == LS_ACKRCVD) { - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - f->state = LS_OPENED; - if (f->callbacks->up) { - (*f->callbacks->up)(f); /* Inform upper layers */ - } - } else { - f->state = LS_ACKSENT; - } - f->nakloops = 0; - } else { - /* we sent CONFACK or CONFREJ */ - if (f->state != LS_ACKRCVD) { - f->state = LS_REQSENT; - } - if( code == CONFNAK ) { - ++f->nakloops; - } - } -} - - -/* - * fsm_rconfack - Receive Configure-Ack. - */ -static void -fsm_rconfack(fsm *f, int id, u_char *inp, int len) -{ - FSMDEBUG(LOG_INFO, ("fsm_rconfack(%s): Rcvd id %d state=%d (%s)\n", - PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); - - if (id != f->reqid || f->seen_ack) { /* Expected id? */ - return; /* Nope, toss... */ - } - if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len): (len == 0)) ) { - /* Ack is bad - ignore it */ - FSMDEBUG(LOG_INFO, ("%s: received bad Ack (length %d)\n", - PROTO_NAME(f), len)); - return; - } - f->seen_ack = 1; - - switch (f->state) { - case LS_CLOSED: - case LS_STOPPED: - fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); - break; - - case LS_REQSENT: - f->state = LS_ACKRCVD; - f->retransmits = f->maxconfreqtransmits; - break; - - case LS_ACKRCVD: - /* Huh? an extra valid Ack? oh well... */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - fsm_sconfreq(f, 0); - f->state = LS_REQSENT; - break; - - case LS_ACKSENT: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - f->state = LS_OPENED; - f->retransmits = f->maxconfreqtransmits; - if (f->callbacks->up) { - (*f->callbacks->up)(f); /* Inform upper layers */ - } - break; - - case LS_OPENED: - /* Go down and restart negotiation */ - if (f->callbacks->down) { - (*f->callbacks->down)(f); /* Inform upper layers */ - } - fsm_sconfreq(f, 0); /* Send initial Configure-Request */ - f->state = LS_REQSENT; - break; - } -} - - -/* - * fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. - */ -static void -fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) -{ - int (*proc) (fsm *, u_char *, int); - int ret; - - FSMDEBUG(LOG_INFO, ("fsm_rconfnakrej(%s): Rcvd id %d state=%d (%s)\n", - PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); - - if (id != f->reqid || f->seen_ack) { /* Expected id? */ - return; /* Nope, toss... */ - } - proc = (code == CONFNAK)? f->callbacks->nakci: f->callbacks->rejci; - if (!proc || !((ret = proc(f, inp, len)))) { - /* Nak/reject is bad - ignore it */ - FSMDEBUG(LOG_INFO, ("%s: received bad %s (length %d)\n", - PROTO_NAME(f), (code==CONFNAK? "Nak": "reject"), len)); - return; - } - f->seen_ack = 1; - - switch (f->state) { - case LS_CLOSED: - case LS_STOPPED: - fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); - break; - - case LS_REQSENT: - case LS_ACKSENT: - /* They didn't agree to what we wanted - try another request */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - if (ret < 0) { - f->state = LS_STOPPED; /* kludge for stopping CCP */ - } else { - fsm_sconfreq(f, 0); /* Send Configure-Request */ - } - break; - - case LS_ACKRCVD: - /* Got a Nak/reject when we had already had an Ack?? oh well... */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - fsm_sconfreq(f, 0); - f->state = LS_REQSENT; - break; - - case LS_OPENED: - /* Go down and restart negotiation */ - if (f->callbacks->down) { - (*f->callbacks->down)(f); /* Inform upper layers */ - } - fsm_sconfreq(f, 0); /* Send initial Configure-Request */ - f->state = LS_REQSENT; - break; - } -} - - -/* - * fsm_rtermreq - Receive Terminate-Req. - */ -static void -fsm_rtermreq(fsm *f, int id, u_char *p, int len) -{ - LWIP_UNUSED_ARG(p); - - FSMDEBUG(LOG_INFO, ("fsm_rtermreq(%s): Rcvd id %d state=%d (%s)\n", - PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); - - switch (f->state) { - case LS_ACKRCVD: - case LS_ACKSENT: - f->state = LS_REQSENT; /* Start over but keep trying */ - break; - - case LS_OPENED: - if (len > 0) { - FSMDEBUG(LOG_INFO, ("%s terminated by peer (%p)\n", PROTO_NAME(f), p)); - } else { - FSMDEBUG(LOG_INFO, ("%s terminated by peer\n", PROTO_NAME(f))); - } - if (f->callbacks->down) { - (*f->callbacks->down)(f); /* Inform upper layers */ - } - f->retransmits = 0; - f->state = LS_STOPPING; - TIMEOUT(fsm_timeout, f, f->timeouttime); - break; - } - - fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); -} - - -/* - * fsm_rtermack - Receive Terminate-Ack. - */ -static void -fsm_rtermack(fsm *f) -{ - FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): state=%d (%s)\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - - switch (f->state) { - case LS_CLOSING: - UNTIMEOUT(fsm_timeout, f); - f->state = LS_CLOSED; - if( f->callbacks->finished ) { - (*f->callbacks->finished)(f); - } - break; - - case LS_STOPPING: - UNTIMEOUT(fsm_timeout, f); - f->state = LS_STOPPED; - if( f->callbacks->finished ) { - (*f->callbacks->finished)(f); - } - break; - - case LS_ACKRCVD: - f->state = LS_REQSENT; - break; - - case LS_OPENED: - if (f->callbacks->down) { - (*f->callbacks->down)(f); /* Inform upper layers */ - } - fsm_sconfreq(f, 0); - break; - default: - FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): UNHANDLED state=%d (%s)!!!\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - } -} - - -/* - * fsm_rcoderej - Receive an Code-Reject. - */ -static void -fsm_rcoderej(fsm *f, u_char *inp, int len) -{ - u_char code, id; - - FSMDEBUG(LOG_INFO, ("fsm_rcoderej(%s): state=%d (%s)\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - - if (len < HEADERLEN) { - FSMDEBUG(LOG_INFO, ("fsm_rcoderej: Rcvd short Code-Reject packet!\n")); - return; - } - GETCHAR(code, inp); - GETCHAR(id, inp); - FSMDEBUG(LOG_WARNING, ("%s: Rcvd Code-Reject for code %d, id %d\n", - PROTO_NAME(f), code, id)); - - if( f->state == LS_ACKRCVD ) { - f->state = LS_REQSENT; - } -} - - -/* - * fsm_protreject - Peer doesn't speak this protocol. - * - * Treat this as a catastrophic error (RXJ-). - */ -void -fsm_protreject(fsm *f) -{ - switch( f->state ) { - case LS_CLOSING: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - /* fall through */ - case LS_CLOSED: - f->state = LS_CLOSED; - if( f->callbacks->finished ) { - (*f->callbacks->finished)(f); - } - break; - - case LS_STOPPING: - case LS_REQSENT: - case LS_ACKRCVD: - case LS_ACKSENT: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - /* fall through */ - case LS_STOPPED: - f->state = LS_STOPPED; - if( f->callbacks->finished ) { - (*f->callbacks->finished)(f); - } - break; - - case LS_OPENED: - if( f->callbacks->down ) { - (*f->callbacks->down)(f); - } - /* Init restart counter, send Terminate-Request */ - f->retransmits = f->maxtermtransmits; - fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, f, f->timeouttime); - --f->retransmits; - - f->state = LS_STOPPING; - break; - - default: - FSMDEBUG(LOG_INFO, ("%s: Protocol-reject event in state %d (%s)!\n", - PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - } -} - - -/* - * fsm_sconfreq - Send a Configure-Request. - */ -static void -fsm_sconfreq(fsm *f, int retransmit) -{ - u_char *outp; - int cilen; - - if( f->state != LS_REQSENT && f->state != LS_ACKRCVD && f->state != LS_ACKSENT ) { - /* Not currently negotiating - reset options */ - if( f->callbacks->resetci ) { - (*f->callbacks->resetci)(f); - } - f->nakloops = 0; - } - - if( !retransmit ) { - /* New request - reset retransmission counter, use new ID */ - f->retransmits = f->maxconfreqtransmits; - f->reqid = ++f->id; - } - - f->seen_ack = 0; - - /* - * Make up the request packet - */ - outp = outpacket_buf[f->unit] + PPP_HDRLEN + HEADERLEN; - if( f->callbacks->cilen && f->callbacks->addci ) { - cilen = (*f->callbacks->cilen)(f); - if( cilen > peer_mru[f->unit] - (int)HEADERLEN ) { - cilen = peer_mru[f->unit] - HEADERLEN; - } - if (f->callbacks->addci) { - (*f->callbacks->addci)(f, outp, &cilen); - } - } else { - cilen = 0; - } - - /* send the request to our peer */ - fsm_sdata(f, CONFREQ, f->reqid, outp, cilen); - - /* start the retransmit timer */ - --f->retransmits; - TIMEOUT(fsm_timeout, f, f->timeouttime); - - FSMDEBUG(LOG_INFO, ("%s: sending Configure-Request, id %d\n", - PROTO_NAME(f), f->reqid)); -} - - -/* - * fsm_sdata - Send some data. - * - * Used for all packets sent to our peer by this module. - */ -void -fsm_sdata( fsm *f, u_char code, u_char id, u_char *data, int datalen) -{ - u_char *outp; - int outlen; - - /* Adjust length to be smaller than MTU */ - outp = outpacket_buf[f->unit]; - if (datalen > peer_mru[f->unit] - (int)HEADERLEN) { - datalen = peer_mru[f->unit] - HEADERLEN; - } - if (datalen && data != outp + PPP_HDRLEN + HEADERLEN) { - BCOPY(data, outp + PPP_HDRLEN + HEADERLEN, datalen); - } - outlen = datalen + HEADERLEN; - MAKEHEADER(outp, f->protocol); - PUTCHAR(code, outp); - PUTCHAR(id, outp); - PUTSHORT(outlen, outp); - pppWrite(f->unit, outpacket_buf[f->unit], outlen + PPP_HDRLEN); - FSMDEBUG(LOG_INFO, ("fsm_sdata(%s): Sent code %d,%d,%d.\n", - PROTO_NAME(f), code, id, outlen)); -} - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/fsm.h b/user/mpy/lib/lwip/src/netif/ppp/fsm.h deleted file mode 100644 index 8d41b5f..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/fsm.h +++ /dev/null @@ -1,157 +0,0 @@ -/***************************************************************************** -* fsm.h - Network Control Protocol Finite State Machine header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original based on BSD code. -*****************************************************************************/ -/* - * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: fsm.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $ - */ - -#ifndef FSM_H -#define FSM_H - -/* - * LCP Packet header = Code, id, length. - */ -#define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) - - -/* - * CP (LCP, IPCP, etc.) codes. - */ -#define CONFREQ 1 /* Configuration Request */ -#define CONFACK 2 /* Configuration Ack */ -#define CONFNAK 3 /* Configuration Nak */ -#define CONFREJ 4 /* Configuration Reject */ -#define TERMREQ 5 /* Termination Request */ -#define TERMACK 6 /* Termination Ack */ -#define CODEREJ 7 /* Code Reject */ - - -/* - * Each FSM is described by an fsm structure and fsm callbacks. - */ -typedef struct fsm { - int unit; /* Interface unit number */ - u_short protocol; /* Data Link Layer Protocol field value */ - int state; /* State */ - int flags; /* Contains option bits */ - u_char id; /* Current id */ - u_char reqid; /* Current request id */ - u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */ - int timeouttime; /* Timeout time in milliseconds */ - int maxconfreqtransmits; /* Maximum Configure-Request transmissions */ - int retransmits; /* Number of retransmissions left */ - int maxtermtransmits; /* Maximum Terminate-Request transmissions */ - int nakloops; /* Number of nak loops since last ack */ - int maxnakloops; /* Maximum number of nak loops tolerated */ - struct fsm_callbacks* callbacks; /* Callback routines */ - char* term_reason; /* Reason for closing protocol */ - int term_reason_len; /* Length of term_reason */ -} fsm; - - -typedef struct fsm_callbacks { - void (*resetci)(fsm*); /* Reset our Configuration Information */ - int (*cilen)(fsm*); /* Length of our Configuration Information */ - void (*addci)(fsm*, u_char*, int*); /* Add our Configuration Information */ - int (*ackci)(fsm*, u_char*, int); /* ACK our Configuration Information */ - int (*nakci)(fsm*, u_char*, int); /* NAK our Configuration Information */ - int (*rejci)(fsm*, u_char*, int); /* Reject our Configuration Information */ - int (*reqci)(fsm*, u_char*, int*, int); /* Request peer's Configuration Information */ - void (*up)(fsm*); /* Called when fsm reaches LS_OPENED state */ - void (*down)(fsm*); /* Called when fsm leaves LS_OPENED state */ - void (*starting)(fsm*); /* Called when we want the lower layer */ - void (*finished)(fsm*); /* Called when we don't want the lower layer */ - void (*protreject)(int); /* Called when Protocol-Reject received */ - void (*retransmit)(fsm*); /* Retransmission is necessary */ - int (*extcode)(fsm*, int, u_char, u_char*, int); /* Called when unknown code received */ - char *proto_name; /* String name for protocol (for messages) */ -} fsm_callbacks; - - -/* - * Link states. - */ -#define LS_INITIAL 0 /* Down, hasn't been opened */ -#define LS_STARTING 1 /* Down, been opened */ -#define LS_CLOSED 2 /* Up, hasn't been opened */ -#define LS_STOPPED 3 /* Open, waiting for down event */ -#define LS_CLOSING 4 /* Terminating the connection, not open */ -#define LS_STOPPING 5 /* Terminating, but open */ -#define LS_REQSENT 6 /* We've sent a Config Request */ -#define LS_ACKRCVD 7 /* We've received a Config Ack */ -#define LS_ACKSENT 8 /* We've sent a Config Ack */ -#define LS_OPENED 9 /* Connection available */ - -/* - * Flags - indicate options controlling FSM operation - */ -#define OPT_PASSIVE 1 /* Don't die if we don't get a response */ -#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */ -#define OPT_SILENT 4 /* Wait for peer to speak first */ - - -/* - * Prototypes - */ -void fsm_init (fsm*); -void fsm_lowerup (fsm*); -void fsm_lowerdown (fsm*); -void fsm_open (fsm*); -void fsm_close (fsm*, char*); -void fsm_input (fsm*, u_char*, int); -void fsm_protreject (fsm*); -void fsm_sdata (fsm*, u_char, u_char, u_char*, int); - - -/* - * Variables - */ -extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */ - -#endif /* FSM_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ipcp.c b/user/mpy/lib/lwip/src/netif/ppp/ipcp.c deleted file mode 100644 index f0ab2e0..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/ipcp.c +++ /dev/null @@ -1,1411 +0,0 @@ -/** In contrast to pppd 2.3.1, DNS support has been added, proxy-ARP and - dial-on-demand has been stripped. */ -/***************************************************************************** -* ipcp.c - Network PPP IP Control Protocol program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-08 Guy Lancaster , Global Election Systems Inc. -* Original. -*****************************************************************************/ -/* - * ipcp.c - PPP IP Control Protocol. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "auth.h" -#include "fsm.h" -#include "vj.h" -#include "ipcp.h" - -#include "lwip/inet.h" - -#include - -/* #define OLD_CI_ADDRS 1 */ /* Support deprecated address negotiation. */ - -/* global vars */ -ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */ -ipcp_options ipcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ -ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ -ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ - -/* local vars */ -static int default_route_set[NUM_PPP]; /* Have set up a default route */ -static int cis_received[NUM_PPP]; /* # Conf-Reqs received */ - - -/* - * Callbacks for fsm code. (CI = Configuration Information) - */ -static void ipcp_resetci (fsm *); /* Reset our CI */ -static int ipcp_cilen (fsm *); /* Return length of our CI */ -static void ipcp_addci (fsm *, u_char *, int *); /* Add our CI */ -static int ipcp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */ -static int ipcp_nakci (fsm *, u_char *, int); /* Peer nak'd our CI */ -static int ipcp_rejci (fsm *, u_char *, int); /* Peer rej'd our CI */ -static int ipcp_reqci (fsm *, u_char *, int *, int); /* Rcv CI */ -static void ipcp_up (fsm *); /* We're UP */ -static void ipcp_down (fsm *); /* We're DOWN */ -#if PPP_ADDITIONAL_CALLBACKS -static void ipcp_script (fsm *, char *); /* Run an up/down script */ -#endif -static void ipcp_finished (fsm *); /* Don't need lower layer */ - - -fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */ - - -static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */ - ipcp_resetci, /* Reset our Configuration Information */ - ipcp_cilen, /* Length of our Configuration Information */ - ipcp_addci, /* Add our Configuration Information */ - ipcp_ackci, /* ACK our Configuration Information */ - ipcp_nakci, /* NAK our Configuration Information */ - ipcp_rejci, /* Reject our Configuration Information */ - ipcp_reqci, /* Request peer's Configuration Information */ - ipcp_up, /* Called when fsm reaches LS_OPENED state */ - ipcp_down, /* Called when fsm leaves LS_OPENED state */ - NULL, /* Called when we want the lower layer up */ - ipcp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - NULL, /* Called to handle protocol-specific codes */ - "IPCP" /* String name of protocol */ -}; - -/* - * Protocol entry points from main code. - */ -static void ipcp_init (int); -static void ipcp_open (int); -static void ipcp_close (int, char *); -static void ipcp_lowerup (int); -static void ipcp_lowerdown (int); -static void ipcp_input (int, u_char *, int); -static void ipcp_protrej (int); - - -struct protent ipcp_protent = { - PPP_IPCP, - ipcp_init, - ipcp_input, - ipcp_protrej, - ipcp_lowerup, - ipcp_lowerdown, - ipcp_open, - ipcp_close, -#if PPP_ADDITIONAL_CALLBACKS - ipcp_printpkt, - NULL, -#endif /* PPP_ADDITIONAL_CALLBACKS */ - 1, - "IPCP", -#if PPP_ADDITIONAL_CALLBACKS - ip_check_options, - NULL, - ip_active_pkt -#endif /* PPP_ADDITIONAL_CALLBACKS */ -}; - -static void ipcp_clear_addrs (int); - -/* - * Lengths of configuration options. - */ -#define CILEN_VOID 2 -#define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ -#define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ -#define CILEN_ADDR 6 /* new-style single address option */ -#define CILEN_ADDRS 10 /* old-style dual address option */ - - -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") - - -/* - * ipcp_init - Initialize IPCP. - */ -static void -ipcp_init(int unit) -{ - fsm *f = &ipcp_fsm[unit]; - ipcp_options *wo = &ipcp_wantoptions[unit]; - ipcp_options *ao = &ipcp_allowoptions[unit]; - - f->unit = unit; - f->protocol = PPP_IPCP; - f->callbacks = &ipcp_callbacks; - fsm_init(&ipcp_fsm[unit]); - - memset(wo, 0, sizeof(*wo)); - memset(ao, 0, sizeof(*ao)); - - wo->neg_addr = 1; - wo->ouraddr = 0; -#if VJ_SUPPORT - wo->neg_vj = 1; -#else /* VJ_SUPPORT */ - wo->neg_vj = 0; -#endif /* VJ_SUPPORT */ - wo->vj_protocol = IPCP_VJ_COMP; - wo->maxslotindex = MAX_SLOTS - 1; - wo->cflag = 0; - wo->default_route = 1; - - ao->neg_addr = 1; -#if VJ_SUPPORT - ao->neg_vj = 1; -#else /* VJ_SUPPORT */ - ao->neg_vj = 0; -#endif /* VJ_SUPPORT */ - ao->maxslotindex = MAX_SLOTS - 1; - ao->cflag = 1; - ao->default_route = 1; -} - - -/* - * ipcp_open - IPCP is allowed to come up. - */ -static void -ipcp_open(int unit) -{ - fsm_open(&ipcp_fsm[unit]); -} - - -/* - * ipcp_close - Take IPCP down. - */ -static void -ipcp_close(int unit, char *reason) -{ - fsm_close(&ipcp_fsm[unit], reason); -} - - -/* - * ipcp_lowerup - The lower layer is up. - */ -static void -ipcp_lowerup(int unit) -{ - fsm_lowerup(&ipcp_fsm[unit]); -} - - -/* - * ipcp_lowerdown - The lower layer is down. - */ -static void -ipcp_lowerdown(int unit) -{ - fsm_lowerdown(&ipcp_fsm[unit]); -} - - -/* - * ipcp_input - Input IPCP packet. - */ -static void -ipcp_input(int unit, u_char *p, int len) -{ - fsm_input(&ipcp_fsm[unit], p, len); -} - - -/* - * ipcp_protrej - A Protocol-Reject was received for IPCP. - * - * Pretend the lower layer went down, so we shut up. - */ -static void -ipcp_protrej(int unit) -{ - fsm_lowerdown(&ipcp_fsm[unit]); -} - - -/* - * ipcp_resetci - Reset our CI. - */ -static void -ipcp_resetci(fsm *f) -{ - ipcp_options *wo = &ipcp_wantoptions[f->unit]; - - wo->req_addr = wo->neg_addr && ipcp_allowoptions[f->unit].neg_addr; - if (wo->ouraddr == 0) { - wo->accept_local = 1; - } - if (wo->hisaddr == 0) { - wo->accept_remote = 1; - } - /* Request DNS addresses from the peer */ - wo->req_dns1 = ppp_settings.usepeerdns; - wo->req_dns2 = ppp_settings.usepeerdns; - ipcp_gotoptions[f->unit] = *wo; - cis_received[f->unit] = 0; -} - - -/* - * ipcp_cilen - Return length of our CI. - */ -static int -ipcp_cilen(fsm *f) -{ - ipcp_options *go = &ipcp_gotoptions[f->unit]; - ipcp_options *wo = &ipcp_wantoptions[f->unit]; - ipcp_options *ho = &ipcp_hisoptions[f->unit]; - -#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) -#define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0) -#define LENCIDNS(neg) (neg ? (CILEN_ADDR) : 0) - - /* - * First see if we want to change our options to the old - * forms because we have received old forms from the peer. - */ - if (wo->neg_addr && !go->neg_addr && !go->old_addrs) { - /* use the old style of address negotiation */ - go->neg_addr = 1; - go->old_addrs = 1; - } - if (wo->neg_vj && !go->neg_vj && !go->old_vj) { - /* try an older style of VJ negotiation */ - if (cis_received[f->unit] == 0) { - /* keep trying the new style until we see some CI from the peer */ - go->neg_vj = 1; - } else { - /* use the old style only if the peer did */ - if (ho->neg_vj && ho->old_vj) { - go->neg_vj = 1; - go->old_vj = 1; - go->vj_protocol = ho->vj_protocol; - } - } - } - - return (LENCIADDR(go->neg_addr, go->old_addrs) + - LENCIVJ(go->neg_vj, go->old_vj) + - LENCIDNS(go->req_dns1) + - LENCIDNS(go->req_dns2)); -} - - -/* - * ipcp_addci - Add our desired CIs to a packet. - */ -static void -ipcp_addci(fsm *f, u_char *ucp, int *lenp) -{ - ipcp_options *go = &ipcp_gotoptions[f->unit]; - int len = *lenp; - -#define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \ - if (neg) { \ - int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ - if (len >= vjlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(vjlen, ucp); \ - PUTSHORT(val, ucp); \ - if (!old) { \ - PUTCHAR(maxslotindex, ucp); \ - PUTCHAR(cflag, ucp); \ - } \ - len -= vjlen; \ - } else { \ - neg = 0; \ - } \ - } - -#define ADDCIADDR(opt, neg, old, val1, val2) \ - if (neg) { \ - int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ - if (len >= addrlen) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(addrlen, ucp); \ - l = ntohl(val1); \ - PUTLONG(l, ucp); \ - if (old) { \ - l = ntohl(val2); \ - PUTLONG(l, ucp); \ - } \ - len -= addrlen; \ - } else { \ - neg = 0; \ - } \ - } - -#define ADDCIDNS(opt, neg, addr) \ - if (neg) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = ntohl(addr); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else { \ - neg = 0; \ - } \ - } - - ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, - go->old_addrs, go->ouraddr, go->hisaddr); - - ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); - - ADDCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]); - - ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]); - - *lenp -= len; -} - - -/* - * ipcp_ackci - Ack our CIs. - * - * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. - */ -static int -ipcp_ackci(fsm *f, u_char *p, int len) -{ - ipcp_options *go = &ipcp_gotoptions[f->unit]; - u_short cilen, citype, cishort; - u32_t cilong; - u_char cimaxslotindex, cicflag; - - /* - * CIs must be in exactly the same order that we sent... - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ - -#define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \ - if (neg) { \ - int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ - if ((len -= vjlen) < 0) { \ - goto bad; \ - } \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != vjlen || \ - citype != opt) { \ - goto bad; \ - } \ - GETSHORT(cishort, p); \ - if (cishort != val) { \ - goto bad; \ - } \ - if (!old) { \ - GETCHAR(cimaxslotindex, p); \ - if (cimaxslotindex != maxslotindex) { \ - goto bad; \ - } \ - GETCHAR(cicflag, p); \ - if (cicflag != cflag) { \ - goto bad; \ - } \ - } \ - } - -#define ACKCIADDR(opt, neg, old, val1, val2) \ - if (neg) { \ - int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ - u32_t l; \ - if ((len -= addrlen) < 0) { \ - goto bad; \ - } \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != addrlen || \ - citype != opt) { \ - goto bad; \ - } \ - GETLONG(l, p); \ - cilong = htonl(l); \ - if (val1 != cilong) { \ - goto bad; \ - } \ - if (old) { \ - GETLONG(l, p); \ - cilong = htonl(l); \ - if (val2 != cilong) { \ - goto bad; \ - } \ - } \ - } - -#define ACKCIDNS(opt, neg, addr) \ - if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) { \ - goto bad; \ - } \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || \ - citype != opt) { \ - goto bad; \ - } \ - GETLONG(l, p); \ - cilong = htonl(l); \ - if (addr != cilong) { \ - goto bad; \ - } \ - } - - ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, - go->old_addrs, go->ouraddr, go->hisaddr); - - ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); - - ACKCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]); - - ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]); - - /* - * If there are any remaining CIs, then this packet is bad. - */ - if (len != 0) { - goto bad; - } - return (1); - -bad: - IPCPDEBUG(LOG_INFO, ("ipcp_ackci: received bad Ack!\n")); - return (0); -} - -/* - * ipcp_nakci - Peer has sent a NAK for some of our CIs. - * This should not modify any state if the Nak is bad - * or if IPCP is in the LS_OPENED state. - * - * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. - */ -static int -ipcp_nakci(fsm *f, u_char *p, int len) -{ - ipcp_options *go = &ipcp_gotoptions[f->unit]; - u_char cimaxslotindex, cicflag; - u_char citype, cilen, *next; - u_short cishort; - u32_t ciaddr1, ciaddr2, l, cidnsaddr; - ipcp_options no; /* options we've seen Naks for */ - ipcp_options try; /* options to request next time */ - - BZERO(&no, sizeof(no)); - try = *go; - - /* - * Any Nak'd CIs must be in exactly the same order that we sent. - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ -#define NAKCIADDR(opt, neg, old, code) \ - if (go->neg && \ - len >= (cilen = (old? CILEN_ADDRS: CILEN_ADDR)) && \ - p[1] == cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - ciaddr1 = htonl(l); \ - if (old) { \ - GETLONG(l, p); \ - ciaddr2 = htonl(l); \ - no.old_addrs = 1; \ - } else { \ - ciaddr2 = 0; \ - } \ - no.neg = 1; \ - code \ - } - -#define NAKCIVJ(opt, neg, code) \ - if (go->neg && \ - ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ - code \ - } - -#define NAKCIDNS(opt, neg, code) \ - if (go->neg && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cidnsaddr = htonl(l); \ - no.neg = 1; \ - code \ - } - - /* - * Accept the peer's idea of {our,his} address, if different - * from our idea, only if the accept_{local,remote} flag is set. - */ - NAKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, go->old_addrs, - if (go->accept_local && ciaddr1) { /* Do we know our address? */ - try.ouraddr = ciaddr1; - IPCPDEBUG(LOG_INFO, ("local IP address %s\n", - inet_ntoa(ciaddr1))); - } - if (go->accept_remote && ciaddr2) { /* Does he know his? */ - try.hisaddr = ciaddr2; - IPCPDEBUG(LOG_INFO, ("remote IP address %s\n", - inet_ntoa(ciaddr2))); - } - ); - - /* - * Accept the peer's value of maxslotindex provided that it - * is less than what we asked for. Turn off slot-ID compression - * if the peer wants. Send old-style compress-type option if - * the peer wants. - */ - NAKCIVJ(CI_COMPRESSTYPE, neg_vj, - if (cilen == CILEN_VJ) { - GETCHAR(cimaxslotindex, p); - GETCHAR(cicflag, p); - if (cishort == IPCP_VJ_COMP) { - try.old_vj = 0; - if (cimaxslotindex < go->maxslotindex) { - try.maxslotindex = cimaxslotindex; - } - if (!cicflag) { - try.cflag = 0; - } - } else { - try.neg_vj = 0; - } - } else { - if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { - try.old_vj = 1; - try.vj_protocol = cishort; - } else { - try.neg_vj = 0; - } - } - ); - - NAKCIDNS(CI_MS_DNS1, req_dns1, - try.dnsaddr[0] = cidnsaddr; - IPCPDEBUG(LOG_INFO, ("primary DNS address %s\n", inet_ntoa(cidnsaddr))); - ); - - NAKCIDNS(CI_MS_DNS2, req_dns2, - try.dnsaddr[1] = cidnsaddr; - IPCPDEBUG(LOG_INFO, ("secondary DNS address %s\n", inet_ntoa(cidnsaddr))); - ); - - /* - * There may be remaining CIs, if the peer is requesting negotiation - * on an option that we didn't include in our request packet. - * If they want to negotiate about IP addresses, we comply. - * If they want us to ask for compression, we refuse. - */ - while (len > CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if( (len -= cilen) < 0 ) { - goto bad; - } - next = p + cilen - 2; - - switch (citype) { - case CI_COMPRESSTYPE: - if (go->neg_vj || no.neg_vj || - (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { - goto bad; - } - no.neg_vj = 1; - break; - case CI_ADDRS: - if ((go->neg_addr && go->old_addrs) || no.old_addrs - || cilen != CILEN_ADDRS) { - goto bad; - } - try.neg_addr = 1; - try.old_addrs = 1; - GETLONG(l, p); - ciaddr1 = htonl(l); - if (ciaddr1 && go->accept_local) { - try.ouraddr = ciaddr1; - } - GETLONG(l, p); - ciaddr2 = htonl(l); - if (ciaddr2 && go->accept_remote) { - try.hisaddr = ciaddr2; - } - no.old_addrs = 1; - break; - case CI_ADDR: - if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) { - goto bad; - } - try.old_addrs = 0; - GETLONG(l, p); - ciaddr1 = htonl(l); - if (ciaddr1 && go->accept_local) { - try.ouraddr = ciaddr1; - } - if (try.ouraddr != 0) { - try.neg_addr = 1; - } - no.neg_addr = 1; - break; - } - p = next; - } - - /* If there is still anything left, this packet is bad. */ - if (len != 0) { - goto bad; - } - - /* - * OK, the Nak is good. Now we can update state. - */ - if (f->state != LS_OPENED) { - *go = try; - } - - return 1; - -bad: - IPCPDEBUG(LOG_INFO, ("ipcp_nakci: received bad Nak!\n")); - return 0; -} - - -/* - * ipcp_rejci - Reject some of our CIs. - */ -static int -ipcp_rejci(fsm *f, u_char *p, int len) -{ - ipcp_options *go = &ipcp_gotoptions[f->unit]; - u_char cimaxslotindex, ciflag, cilen; - u_short cishort; - u32_t cilong; - ipcp_options try; /* options to request next time */ - - try = *go; - /* - * Any Rejected CIs must be in exactly the same order that we sent. - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ -#define REJCIADDR(opt, neg, old, val1, val2) \ - if (go->neg && \ - len >= (cilen = old? CILEN_ADDRS: CILEN_ADDR) && \ - p[1] == cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val1) { \ - goto bad; \ - } \ - if (old) { \ - GETLONG(l, p); \ - cilong = htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val2) { \ - goto bad; \ - } \ - } \ - try.neg = 0; \ - } - -#define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ - if (go->neg && \ - p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ - len >= p[1] && \ - p[0] == opt) { \ - len -= p[1]; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) { \ - goto bad; \ - } \ - if (!old) { \ - GETCHAR(cimaxslotindex, p); \ - if (cimaxslotindex != maxslot) { \ - goto bad; \ - } \ - GETCHAR(ciflag, p); \ - if (ciflag != cflag) { \ - goto bad; \ - } \ - } \ - try.neg = 0; \ - } - -#define REJCIDNS(opt, neg, dnsaddr) \ - if (go->neg && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = htonl(l); \ - /* Check rejected value. */ \ - if (cilong != dnsaddr) { \ - goto bad; \ - } \ - try.neg = 0; \ - } - - REJCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, - go->old_addrs, go->ouraddr, go->hisaddr); - - REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); - - REJCIDNS(CI_MS_DNS1, req_dns1, go->dnsaddr[0]); - - REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]); - - /* - * If there are any remaining CIs, then this packet is bad. - */ - if (len != 0) { - goto bad; - } - /* - * Now we can update state. - */ - if (f->state != LS_OPENED) { - *go = try; - } - return 1; - -bad: - IPCPDEBUG(LOG_INFO, ("ipcp_rejci: received bad Reject!\n")); - return 0; -} - - -/* - * ipcp_reqci - Check the peer's requested CIs and send appropriate response. - * - * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified - * appropriately. If reject_if_disagree is non-zero, doesn't return - * CONFNAK; returns CONFREJ if it can't return CONFACK. - */ -static int -ipcp_reqci(fsm *f, u_char *inp/* Requested CIs */,int *len/* Length of requested CIs */,int reject_if_disagree) -{ - ipcp_options *wo = &ipcp_wantoptions[f->unit]; - ipcp_options *ho = &ipcp_hisoptions[f->unit]; - ipcp_options *ao = &ipcp_allowoptions[f->unit]; -#ifdef OLD_CI_ADDRS - ipcp_options *go = &ipcp_gotoptions[f->unit]; -#endif - u_char *cip, *next; /* Pointer to current and next CIs */ - u_short cilen, citype; /* Parsed len, type */ - u_short cishort; /* Parsed short value */ - u32_t tl, ciaddr1; /* Parsed address values */ -#ifdef OLD_CI_ADDRS - u32_t ciaddr2; /* Parsed address values */ -#endif - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *ucp = inp; /* Pointer to current output char */ - int l = *len; /* Length left */ - u_char maxslotindex, cflag; - int d; - - cis_received[f->unit] = 1; - - /* - * Reset all his options. - */ - BZERO(ho, sizeof(*ho)); - - /* - * Process all his options. - */ - next = inp; - while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: bad CI length!\n")); - orc = CONFREJ; /* Reject bad CI */ - cilen = (u_short)l;/* Reject till end of packet */ - l = 0; /* Don't loop again */ - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ -#ifdef OLD_CI_ADDRS /* Need to save space... */ - case CI_ADDRS: - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: received ADDRS\n")); - if (!ao->neg_addr || - cilen != CILEN_ADDRS) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no address, or if we both have his address but - * disagree about it, then NAK it with our idea. - * In particular, if we don't know his address, but he does, - * then accept it. - */ - GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = htonl(tl); - IPCPDEBUG(LOG_INFO, ("his addr %s\n", inet_ntoa(ciaddr1))); - if (ciaddr1 != wo->hisaddr - && (ciaddr1 == 0 || !wo->accept_remote)) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = ntohl(wo->hisaddr); - PUTLONG(tl, p); - } - } else if (ciaddr1 == 0 && wo->hisaddr == 0) { - /* - * If neither we nor he knows his address, reject the option. - */ - orc = CONFREJ; - wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ - break; - } - - /* - * If he doesn't know our address, or if we both have our address - * but disagree about it, then NAK it with our idea. - */ - GETLONG(tl, p); /* Parse desination address (ours) */ - ciaddr2 = htonl(tl); - IPCPDEBUG(LOG_INFO, ("our addr %s\n", inet_ntoa(ciaddr2))); - if (ciaddr2 != wo->ouraddr) { - if (ciaddr2 == 0 || !wo->accept_local) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = ntohl(wo->ouraddr); - PUTLONG(tl, p); - } - } else { - go->ouraddr = ciaddr2; /* accept peer's idea */ - } - } - - ho->neg_addr = 1; - ho->old_addrs = 1; - ho->hisaddr = ciaddr1; - ho->ouraddr = ciaddr2; - break; -#endif - - case CI_ADDR: - if (!ao->neg_addr) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Reject ADDR not allowed\n")); - orc = CONFREJ; /* Reject CI */ - break; - } else if (cilen != CILEN_ADDR) { /* Check CI length */ - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Reject ADDR bad len\n")); - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no address, or if we both have his address but - * disagree about it, then NAK it with our idea. - * In particular, if we don't know his address, but he does, - * then accept it. - */ - GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = htonl(tl); - if (ciaddr1 != wo->hisaddr - && (ciaddr1 == 0 || !wo->accept_remote)) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = ntohl(wo->hisaddr); - PUTLONG(tl, p); - } - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Nak ADDR %s\n", inet_ntoa(ciaddr1))); - } else if (ciaddr1 == 0 && wo->hisaddr == 0) { - /* - * Don't ACK an address of 0.0.0.0 - reject it instead. - */ - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Reject ADDR %s\n", inet_ntoa(ciaddr1))); - orc = CONFREJ; - wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ - break; - } - - ho->neg_addr = 1; - ho->hisaddr = ciaddr1; - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: ADDR %s\n", inet_ntoa(ciaddr1))); - break; - - case CI_MS_DNS1: - case CI_MS_DNS2: - /* Microsoft primary or secondary DNS request */ - d = citype == CI_MS_DNS2; - - /* If we do not have a DNS address then we cannot send it */ - if (ao->dnsaddr[d] == 0 || - cilen != CILEN_ADDR) { /* Check CI length */ - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting DNS%d Request\n", d+1)); - orc = CONFREJ; /* Reject CI */ - break; - } - GETLONG(tl, p); - if (htonl(tl) != ao->dnsaddr[d]) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking DNS%d Request %s\n", - d+1, inet_ntoa(tl))); - DECPTR(sizeof(u32_t), p); - tl = ntohl(ao->dnsaddr[d]); - PUTLONG(tl, p); - orc = CONFNAK; - } - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: received DNS%d Request\n", d+1)); - break; - - case CI_MS_WINS1: - case CI_MS_WINS2: - /* Microsoft primary or secondary WINS request */ - d = citype == CI_MS_WINS2; - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: received WINS%d Request\n", d+1)); - - /* If we do not have a DNS address then we cannot send it */ - if (ao->winsaddr[d] == 0 || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETLONG(tl, p); - if (htonl(tl) != ao->winsaddr[d]) { - DECPTR(sizeof(u32_t), p); - tl = ntohl(ao->winsaddr[d]); - PUTLONG(tl, p); - orc = CONFNAK; - } - break; - - case CI_COMPRESSTYPE: - if (!ao->neg_vj) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting COMPRESSTYPE not allowed\n")); - orc = CONFREJ; - break; - } else if (cilen != CILEN_VJ && cilen != CILEN_COMPRESS) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting COMPRESSTYPE len=%d\n", cilen)); - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - - if (!(cishort == IPCP_VJ_COMP || - (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting COMPRESSTYPE %d\n", cishort)); - orc = CONFREJ; - break; - } - - ho->neg_vj = 1; - ho->vj_protocol = cishort; - if (cilen == CILEN_VJ) { - GETCHAR(maxslotindex, p); - if (maxslotindex > ao->maxslotindex) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking VJ max slot %d\n", maxslotindex)); - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(1, p); - PUTCHAR(ao->maxslotindex, p); - } - } - GETCHAR(cflag, p); - if (cflag && !ao->cflag) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking VJ cflag %d\n", cflag)); - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(1, p); - PUTCHAR(wo->cflag, p); - } - } - ho->maxslotindex = maxslotindex; - ho->cflag = cflag; - } else { - ho->old_vj = 1; - ho->maxslotindex = MAX_SLOTS - 1; - ho->cflag = 1; - } - IPCPDEBUG(LOG_INFO, ( - "ipcp_reqci: received COMPRESSTYPE p=%d old=%d maxslot=%d cflag=%d\n", - ho->vj_protocol, ho->old_vj, ho->maxslotindex, ho->cflag)); - break; - - default: - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting unknown CI type %d\n", citype)); - orc = CONFREJ; - break; - } - -endswitch: - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) { /* but prior CI wasnt? */ - continue; /* Don't send this one */ - } - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree) { /* Getting fed up with sending NAKs? */ - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Rejecting too many naks\n")); - orc = CONFREJ; /* Get tough if so */ - } else { - if (rc == CONFREJ) { /* Rejecting prior CI? */ - continue; /* Don't send this one */ - } - if (rc == CONFACK) { /* Ack'd all prior CIs? */ - rc = CONFNAK; /* Not anymore... */ - ucp = inp; /* Backup */ - } - } - } - - if (orc == CONFREJ && /* Reject this CI */ - rc != CONFREJ) { /* but no prior ones? */ - rc = CONFREJ; - ucp = inp; /* Backup */ - } - - /* Need to move CI? */ - if (ucp != cip) { - BCOPY(cip, ucp, cilen); /* Move it */ - } - - /* Update output pointer */ - INCPTR(cilen, ucp); - } - - /* - * If we aren't rejecting this packet, and we want to negotiate - * their address, and they didn't send their address, then we - * send a NAK with a CI_ADDR option appended. We assume the - * input buffer is long enough that we can append the extra - * option safely. - */ - if (rc != CONFREJ && !ho->neg_addr && - wo->req_addr && !reject_if_disagree) { - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Requesting peer address\n")); - if (rc == CONFACK) { - rc = CONFNAK; - ucp = inp; /* reset pointer */ - wo->req_addr = 0; /* don't ask again */ - } - PUTCHAR(CI_ADDR, ucp); - PUTCHAR(CILEN_ADDR, ucp); - tl = ntohl(wo->hisaddr); - PUTLONG(tl, ucp); - } - - *len = (int)(ucp - inp); /* Compute output length */ - IPCPDEBUG(LOG_INFO, ("ipcp_reqci: returning Configure-%s\n", CODENAME(rc))); - return (rc); /* Return final code */ -} - - -#if 0 -/* - * ip_check_options - check that any IP-related options are OK, - * and assign appropriate defaults. - */ -static void -ip_check_options(u_long localAddr) -{ - ipcp_options *wo = &ipcp_wantoptions[0]; - - /* - * Load our default IP address but allow the remote host to give us - * a new address. - */ - if (wo->ouraddr == 0 && !ppp_settings.disable_defaultip) { - wo->accept_local = 1; /* don't insist on this default value */ - wo->ouraddr = htonl(localAddr); - } -} -#endif - - -/* - * ipcp_up - IPCP has come UP. - * - * Configure the IP network interface appropriately and bring it up. - */ -static void -ipcp_up(fsm *f) -{ - u32_t mask; - ipcp_options *ho = &ipcp_hisoptions[f->unit]; - ipcp_options *go = &ipcp_gotoptions[f->unit]; - ipcp_options *wo = &ipcp_wantoptions[f->unit]; - - np_up(f->unit, PPP_IP); - IPCPDEBUG(LOG_INFO, ("ipcp: up\n")); - - /* - * We must have a non-zero IP address for both ends of the link. - */ - if (!ho->neg_addr) { - ho->hisaddr = wo->hisaddr; - } - - if (ho->hisaddr == 0) { - IPCPDEBUG(LOG_ERR, ("Could not determine remote IP address\n")); - ipcp_close(f->unit, "Could not determine remote IP address"); - return; - } - if (go->ouraddr == 0) { - IPCPDEBUG(LOG_ERR, ("Could not determine local IP address\n")); - ipcp_close(f->unit, "Could not determine local IP address"); - return; - } - - if (ppp_settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { - /*pppGotDNSAddrs(go->dnsaddr[0], go->dnsaddr[1]);*/ - } - - /* - * Check that the peer is allowed to use the IP address it wants. - */ - if (!auth_ip_addr(f->unit, ho->hisaddr)) { - IPCPDEBUG(LOG_ERR, ("Peer is not authorized to use remote address %s\n", - inet_ntoa(ho->hisaddr))); - ipcp_close(f->unit, "Unauthorized remote IP address"); - return; - } - - /* set tcp compression */ - sifvjcomp(f->unit, ho->neg_vj, ho->cflag, ho->maxslotindex); - - /* - * Set IP addresses and (if specified) netmask. - */ - mask = GetMask(go->ouraddr); - - if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask, go->dnsaddr[0], go->dnsaddr[1])) { - IPCPDEBUG(LOG_WARNING, ("sifaddr failed\n")); - ipcp_close(f->unit, "Interface configuration failed"); - return; - } - - /* bring the interface up for IP */ - if (!sifup(f->unit)) { - IPCPDEBUG(LOG_WARNING, ("sifup failed\n")); - ipcp_close(f->unit, "Interface configuration failed"); - return; - } - - sifnpmode(f->unit, PPP_IP, NPMODE_PASS); - - /* assign a default route through the interface if required */ - if (ipcp_wantoptions[f->unit].default_route) { - if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr)) { - default_route_set[f->unit] = 1; - } - } - - IPCPDEBUG(LOG_NOTICE, ("local IP address %s\n", inet_ntoa(go->ouraddr))); - IPCPDEBUG(LOG_NOTICE, ("remote IP address %s\n", inet_ntoa(ho->hisaddr))); - if (go->dnsaddr[0]) { - IPCPDEBUG(LOG_NOTICE, ("primary DNS address %s\n", inet_ntoa(go->dnsaddr[0]))); - } - if (go->dnsaddr[1]) { - IPCPDEBUG(LOG_NOTICE, ("secondary DNS address %s\n", inet_ntoa(go->dnsaddr[1]))); - } -} - - -/* - * ipcp_down - IPCP has gone DOWN. - * - * Take the IP network interface down, clear its addresses - * and delete routes through it. - */ -static void -ipcp_down(fsm *f) -{ - IPCPDEBUG(LOG_INFO, ("ipcp: down\n")); - np_down(f->unit, PPP_IP); - sifvjcomp(f->unit, 0, 0, 0); - - sifdown(f->unit); - ipcp_clear_addrs(f->unit); -} - - -/* - * ipcp_clear_addrs() - clear the interface addresses, routes, etc. - */ -static void -ipcp_clear_addrs(int unit) -{ - u32_t ouraddr, hisaddr; - - ouraddr = ipcp_gotoptions[unit].ouraddr; - hisaddr = ipcp_hisoptions[unit].hisaddr; - if (default_route_set[unit]) { - cifdefaultroute(unit, ouraddr, hisaddr); - default_route_set[unit] = 0; - } - cifaddr(unit, ouraddr, hisaddr); -} - - -/* - * ipcp_finished - possibly shut down the lower layers. - */ -static void -ipcp_finished(fsm *f) -{ - np_finished(f->unit, PPP_IP); -} - -#if PPP_ADDITIONAL_CALLBACKS -static int -ipcp_printpkt(u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) -{ - LWIP_UNUSED_ARG(p); - LWIP_UNUSED_ARG(plen); - LWIP_UNUSED_ARG(printer); - LWIP_UNUSED_ARG(arg); - return 0; -} - -/* - * ip_active_pkt - see if this IP packet is worth bringing the link up for. - * We don't bring the link up for IP fragments or for TCP FIN packets - * with no data. - */ -#define IP_HDRLEN 20 /* bytes */ -#define IP_OFFMASK 0x1fff -#define IPPROTO_TCP 6 -#define TCP_HDRLEN 20 -#define TH_FIN 0x01 - -/* - * We use these macros because the IP header may be at an odd address, - * and some compilers might use word loads to get th_off or ip_hl. - */ - -#define net_short(x) (((x)[0] << 8) + (x)[1]) -#define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) -#define get_ipoff(x) net_short((unsigned char *)(x) + 6) -#define get_ipproto(x) (((unsigned char *)(x))[9]) -#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) -#define get_tcpflags(x) (((unsigned char *)(x))[13]) - -static int -ip_active_pkt(u_char *pkt, int len) -{ - u_char *tcp; - int hlen; - - len -= PPP_HDRLEN; - pkt += PPP_HDRLEN; - if (len < IP_HDRLEN) { - return 0; - } - if ((get_ipoff(pkt) & IP_OFFMASK) != 0) { - return 0; - } - if (get_ipproto(pkt) != IPPROTO_TCP) { - return 1; - } - hlen = get_iphl(pkt) * 4; - if (len < hlen + TCP_HDRLEN) { - return 0; - } - tcp = pkt + hlen; - if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4) { - return 0; - } - return 1; -} -#endif /* PPP_ADDITIONAL_CALLBACKS */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ipcp.h b/user/mpy/lib/lwip/src/netif/ppp/ipcp.h deleted file mode 100644 index de03f46..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/ipcp.h +++ /dev/null @@ -1,106 +0,0 @@ -/***************************************************************************** -* ipcp.h - PPP IP NCP: Internet Protocol Network Control Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-04 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ -/* - * ipcp.h - IP Control Protocol definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: ipcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $ - */ - -#ifndef IPCP_H -#define IPCP_H - -/* - * Options. - */ -#define CI_ADDRS 1 /* IP Addresses */ -#define CI_COMPRESSTYPE 2 /* Compression Type */ -#define CI_ADDR 3 - -#define CI_MS_DNS1 129 /* Primary DNS value */ -#define CI_MS_WINS1 128 /* Primary WINS value */ -#define CI_MS_DNS2 131 /* Secondary DNS value */ -#define CI_MS_WINS2 130 /* Secondary WINS value */ - -#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */ -#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */ -#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */ - /* maxslot and slot number compression) */ - -#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option */ -#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */ - /* compression option */ - -typedef struct ipcp_options { - u_int neg_addr : 1; /* Negotiate IP Address? */ - u_int old_addrs : 1; /* Use old (IP-Addresses) option? */ - u_int req_addr : 1; /* Ask peer to send IP address? */ - u_int default_route : 1; /* Assign default route through interface? */ - u_int proxy_arp : 1; /* Make proxy ARP entry for peer? */ - u_int neg_vj : 1; /* Van Jacobson Compression? */ - u_int old_vj : 1; /* use old (short) form of VJ option? */ - u_int accept_local : 1; /* accept peer's value for ouraddr */ - u_int accept_remote : 1; /* accept peer's value for hisaddr */ - u_int req_dns1 : 1; /* Ask peer to send primary DNS address? */ - u_int req_dns2 : 1; /* Ask peer to send secondary DNS address? */ - u_short vj_protocol; /* protocol value to use in VJ option */ - u_char maxslotindex; /* VJ slots - 1. */ - u_char cflag; /* VJ slot compression flag. */ - u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ - u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ - u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ -} ipcp_options; - -extern fsm ipcp_fsm[]; -extern ipcp_options ipcp_wantoptions[]; -extern ipcp_options ipcp_gotoptions[]; -extern ipcp_options ipcp_allowoptions[]; -extern ipcp_options ipcp_hisoptions[]; - -extern struct protent ipcp_protent; - -#endif /* IPCP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/lcp.c b/user/mpy/lib/lwip/src/netif/ppp/lcp.c deleted file mode 100644 index 54f758a..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/lcp.c +++ /dev/null @@ -1,2066 +0,0 @@ -/***************************************************************************** -* lcp.c - Network Link Control Protocol program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-01 Guy Lancaster , Global Election Systems Inc. -* Original. -*****************************************************************************/ - -/* - * lcp.c - PPP Link Control Protocol. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "fsm.h" -#include "chap.h" -#include "magic.h" -#include "auth.h" -#include "lcp.h" - -#include - -#if PPPOE_SUPPORT -#include "netif/ppp_oe.h" -#else -#define PPPOE_MAXMTU PPP_MAXMRU -#endif - -#if 0 /* UNUSED */ -/* - * LCP-related command-line options. - */ -int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ -int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ -bool lax_recv = 0; /* accept control chars in asyncmap */ - -static int setescape (char **); - -static option_t lcp_option_list[] = { - /* LCP options */ - /* list stripped for simplicity */ - {NULL} -}; -#endif /* UNUSED */ - -/* options */ -LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */ -static u_int lcp_echo_interval = LCP_ECHOINTERVAL; /* Interval between LCP echo-requests */ -static u_int lcp_echo_fails = LCP_MAXECHOFAILS; /* Tolerance to unanswered echo-requests */ - -/* global vars */ -static fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/ -lcp_options lcp_wantoptions[NUM_PPP]; /* Options that we want to request */ -lcp_options lcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ -lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ -lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ -ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */ - -static u32_t lcp_echos_pending = 0; /* Number of outstanding echo msgs */ -static u32_t lcp_echo_number = 0; /* ID number of next echo frame */ -static u32_t lcp_echo_timer_running = 0; /* TRUE if a timer is running */ - -/* @todo: do we really need such a large buffer? The typical 1500 bytes seem too much. */ -static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ - -/* - * Callbacks for fsm code. (CI = Configuration Information) - */ -static void lcp_resetci (fsm*); /* Reset our CI */ -static int lcp_cilen (fsm*); /* Return length of our CI */ -static void lcp_addci (fsm*, u_char*, int*); /* Add our CI to pkt */ -static int lcp_ackci (fsm*, u_char*, int); /* Peer ack'd our CI */ -static int lcp_nakci (fsm*, u_char*, int); /* Peer nak'd our CI */ -static int lcp_rejci (fsm*, u_char*, int); /* Peer rej'd our CI */ -static int lcp_reqci (fsm*, u_char*, int*, int); /* Rcv peer CI */ -static void lcp_up (fsm*); /* We're UP */ -static void lcp_down (fsm*); /* We're DOWN */ -static void lcp_starting (fsm*); /* We need lower layer up */ -static void lcp_finished (fsm*); /* We need lower layer down */ -static int lcp_extcode (fsm*, int, u_char, u_char*, int); -static void lcp_rprotrej (fsm*, u_char*, int); - -/* - * routines to send LCP echos to peer - */ - -static void lcp_echo_lowerup (int); -static void lcp_echo_lowerdown (int); -static void LcpEchoTimeout (void*); -static void lcp_received_echo_reply (fsm*, int, u_char*, int); -static void LcpSendEchoRequest (fsm*); -static void LcpLinkFailure (fsm*); -static void LcpEchoCheck (fsm*); - -static fsm_callbacks lcp_callbacks = { /* LCP callback routines */ - lcp_resetci, /* Reset our Configuration Information */ - lcp_cilen, /* Length of our Configuration Information */ - lcp_addci, /* Add our Configuration Information */ - lcp_ackci, /* ACK our Configuration Information */ - lcp_nakci, /* NAK our Configuration Information */ - lcp_rejci, /* Reject our Configuration Information */ - lcp_reqci, /* Request peer's Configuration Information */ - lcp_up, /* Called when fsm reaches LS_OPENED state */ - lcp_down, /* Called when fsm leaves LS_OPENED state */ - lcp_starting, /* Called when we want the lower layer up */ - lcp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - lcp_extcode, /* Called to handle LCP-specific codes */ - "LCP" /* String name of protocol */ -}; - -/* - * Protocol entry points. - * Some of these are called directly. - */ - -static void lcp_input (int, u_char *, int); -static void lcp_protrej (int); - -struct protent lcp_protent = { - PPP_LCP, - lcp_init, - lcp_input, - lcp_protrej, - lcp_lowerup, - lcp_lowerdown, - lcp_open, - lcp_close, -#if PPP_ADDITIONAL_CALLBACKS - lcp_printpkt, - NULL, -#endif /* PPP_ADDITIONAL_CALLBACKS */ - 1, - "LCP", -#if PPP_ADDITIONAL_CALLBACKS - NULL, - NULL, - NULL -#endif /* PPP_ADDITIONAL_CALLBACKS */ -}; - -int lcp_loopbackfail = DEFLOOPBACKFAIL; - -/* - * Length of each type of configuration option (in octets) - */ -#define CILEN_VOID 2 -#define CILEN_CHAR 3 -#define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */ -#define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */ -#define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */ -#define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */ -#define CILEN_CBCP 3 - -#define CODENAME(x) ((x) == CONFACK ? "ACK" : (x) == CONFNAK ? "NAK" : "REJ") - -#if 0 /* UNUSED */ -/* - * setescape - add chars to the set we escape on transmission. - */ -static int -setescape(argv) - char **argv; -{ - int n, ret; - char *p, *endp; - - p = *argv; - ret = 1; - while (*p) { - n = strtol(p, &endp, 16); - if (p == endp) { - option_error("escape parameter contains invalid hex number '%s'", p); - return 0; - } - p = endp; - if (n < 0 || n == 0x5E || n > 0xFF) { - option_error("can't escape character 0x%x", n); - ret = 0; - } else - xmit_accm[0][n >> 5] |= 1 << (n & 0x1F); - while (*p == ',' || *p == ' ') - ++p; - } - return ret; -} -#endif /* UNUSED */ - -/* - * lcp_init - Initialize LCP. - */ -void -lcp_init(int unit) -{ - fsm *f = &lcp_fsm[unit]; - lcp_options *wo = &lcp_wantoptions[unit]; - lcp_options *ao = &lcp_allowoptions[unit]; - - f->unit = unit; - f->protocol = PPP_LCP; - f->callbacks = &lcp_callbacks; - - fsm_init(f); - - wo->passive = 0; - wo->silent = 0; - wo->restart = 0; /* Set to 1 in kernels or multi-line implementations */ - wo->neg_mru = 1; - wo->mru = PPP_DEFMRU; - wo->neg_asyncmap = 1; - wo->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */ - wo->neg_chap = 0; /* Set to 1 on server */ - wo->neg_upap = 0; /* Set to 1 on server */ - wo->chap_mdtype = CHAP_DIGEST_MD5; - wo->neg_magicnumber = 1; - wo->neg_pcompression = 1; - wo->neg_accompression = 1; - wo->neg_lqr = 0; /* no LQR implementation yet */ - wo->neg_cbcp = 0; - - ao->neg_mru = 1; - ao->mru = PPP_MAXMRU; - ao->neg_asyncmap = 1; - ao->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */ - ao->neg_chap = (CHAP_SUPPORT != 0); - ao->chap_mdtype = CHAP_DIGEST_MD5; - ao->neg_upap = (PAP_SUPPORT != 0); - ao->neg_magicnumber = 1; - ao->neg_pcompression = 1; - ao->neg_accompression = 1; - ao->neg_lqr = 0; /* no LQR implementation yet */ - ao->neg_cbcp = (CBCP_SUPPORT != 0); - - /* - * Set transmit escape for the flag and escape characters plus anything - * set for the allowable options. - */ - memset(xmit_accm[unit], 0, sizeof(xmit_accm[0])); - xmit_accm[unit][15] = 0x60; - xmit_accm[unit][0] = (u_char)((ao->asyncmap & 0xFF)); - xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF); - xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF); - xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF); - LCPDEBUG(LOG_INFO, ("lcp_init: xmit_accm=%X %X %X %X\n", - xmit_accm[unit][0], - xmit_accm[unit][1], - xmit_accm[unit][2], - xmit_accm[unit][3])); - - lcp_phase[unit] = PHASE_INITIALIZE; -} - - -/* - * lcp_open - LCP is allowed to come up. - */ -void -lcp_open(int unit) -{ - fsm *f = &lcp_fsm[unit]; - lcp_options *wo = &lcp_wantoptions[unit]; - - f->flags = 0; - if (wo->passive) { - f->flags |= OPT_PASSIVE; - } - if (wo->silent) { - f->flags |= OPT_SILENT; - } - fsm_open(f); - - lcp_phase[unit] = PHASE_ESTABLISH; -} - - -/* - * lcp_close - Take LCP down. - */ -void -lcp_close(int unit, char *reason) -{ - fsm *f = &lcp_fsm[unit]; - - if (lcp_phase[unit] != PHASE_DEAD) { - lcp_phase[unit] = PHASE_TERMINATE; - } - if (f->state == LS_STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) { - /* - * This action is not strictly according to the FSM in RFC1548, - * but it does mean that the program terminates if you do an - * lcp_close() in passive/silent mode when a connection hasn't - * been established. - */ - f->state = LS_CLOSED; - lcp_finished(f); - } else { - fsm_close(f, reason); - } -} - - -/* - * lcp_lowerup - The lower layer is up. - */ -void -lcp_lowerup(int unit) -{ - lcp_options *wo = &lcp_wantoptions[unit]; - - /* - * Don't use A/C or protocol compression on transmission, - * but accept A/C and protocol compressed packets - * if we are going to ask for A/C and protocol compression. - */ - ppp_set_xaccm(unit, &xmit_accm[unit]); - ppp_send_config(unit, PPP_MRU, 0xffffffffl, 0, 0); - ppp_recv_config(unit, PPP_MRU, 0x00000000l, - wo->neg_pcompression, wo->neg_accompression); - peer_mru[unit] = PPP_MRU; - lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0] - | ((u_long)xmit_accm[unit][1] << 8) - | ((u_long)xmit_accm[unit][2] << 16) - | ((u_long)xmit_accm[unit][3] << 24); - LCPDEBUG(LOG_INFO, ("lcp_lowerup: asyncmap=%X %X %X %X\n", - xmit_accm[unit][3], - xmit_accm[unit][2], - xmit_accm[unit][1], - xmit_accm[unit][0])); - - fsm_lowerup(&lcp_fsm[unit]); -} - - -/* - * lcp_lowerdown - The lower layer is down. - */ -void -lcp_lowerdown(int unit) -{ - fsm_lowerdown(&lcp_fsm[unit]); -} - - -/* - * lcp_input - Input LCP packet. - */ -static void -lcp_input(int unit, u_char *p, int len) -{ - fsm *f = &lcp_fsm[unit]; - - fsm_input(f, p, len); -} - - -/* - * lcp_extcode - Handle a LCP-specific code. - */ -static int -lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len) -{ - u_char *magp; - - switch( code ){ - case PROTREJ: - lcp_rprotrej(f, inp, len); - break; - - case ECHOREQ: - if (f->state != LS_OPENED) { - break; - } - LCPDEBUG(LOG_INFO, ("lcp: Echo-Request, Rcvd id %d\n", id)); - magp = inp; - PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp); - fsm_sdata(f, ECHOREP, id, inp, len); - break; - - case ECHOREP: - lcp_received_echo_reply(f, id, inp, len); - break; - - case DISCREQ: - break; - - default: - return 0; - } - return 1; -} - - -/* - * lcp_rprotrej - Receive an Protocol-Reject. - * - * Figure out which protocol is rejected and inform it. - */ -static void -lcp_rprotrej(fsm *f, u_char *inp, int len) -{ - int i; - struct protent *protp; - u_short prot; - - if (len < (int)sizeof (u_short)) { - LCPDEBUG(LOG_INFO, ("lcp_rprotrej: Rcvd short Protocol-Reject packet!\n")); - return; - } - - GETSHORT(prot, inp); - - LCPDEBUG(LOG_INFO, ("lcp_rprotrej: Rcvd Protocol-Reject packet for %x!\n", prot)); - - /* - * Protocol-Reject packets received in any state other than the LCP - * LS_OPENED state SHOULD be silently discarded. - */ - if( f->state != LS_OPENED ) { - LCPDEBUG(LOG_INFO, ("Protocol-Reject discarded: LCP in state %d\n", f->state)); - return; - } - - /* - * Upcall the proper Protocol-Reject routine. - */ - for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { - if (protp->protocol == prot && protp->enabled_flag) { - (*protp->protrej)(f->unit); - return; - } - } - - LCPDEBUG(LOG_WARNING, ("Protocol-Reject for unsupported protocol 0x%x\n", prot)); -} - - -/* - * lcp_protrej - A Protocol-Reject was received. - */ -static void -lcp_protrej(int unit) -{ - LWIP_UNUSED_ARG(unit); - /* - * Can't reject LCP! - */ - LCPDEBUG(LOG_WARNING, ("lcp_protrej: Received Protocol-Reject for LCP!\n")); - fsm_protreject(&lcp_fsm[unit]); -} - - -/* - * lcp_sprotrej - Send a Protocol-Reject for some protocol. - */ -void -lcp_sprotrej(int unit, u_char *p, int len) -{ - /* - * Send back the protocol and the information field of the - * rejected packet. We only get here if LCP is in the LS_OPENED state. - */ - - fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id, p, len); -} - - -/* - * lcp_resetci - Reset our CI. - */ -static void -lcp_resetci(fsm *f) -{ - lcp_wantoptions[f->unit].magicnumber = magic(); - lcp_wantoptions[f->unit].numloops = 0; - lcp_gotoptions[f->unit] = lcp_wantoptions[f->unit]; - peer_mru[f->unit] = PPP_MRU; - auth_reset(f->unit); -} - - -/* - * lcp_cilen - Return length of our CI. - */ -static int -lcp_cilen(fsm *f) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - -#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) -#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) -#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) -#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) -#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) -#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) - /* - * NB: we only ask for one of CHAP and UPAP, even if we will - * accept either. - */ - return (LENCISHORT(go->neg_mru && go->mru != PPP_DEFMRU) + - LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) + - LENCICHAP(go->neg_chap) + - LENCISHORT(!go->neg_chap && go->neg_upap) + - LENCILQR(go->neg_lqr) + - LENCICBCP(go->neg_cbcp) + - LENCILONG(go->neg_magicnumber) + - LENCIVOID(go->neg_pcompression) + - LENCIVOID(go->neg_accompression)); -} - - -/* - * lcp_addci - Add our desired CIs to a packet. - */ -static void -lcp_addci(fsm *f, u_char *ucp, int *lenp) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - u_char *start_ucp = ucp; - -#define ADDCIVOID(opt, neg) \ - if (neg) { \ - LCPDEBUG(LOG_INFO, ("lcp_addci: opt=%d\n", opt)); \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_VOID, ucp); \ - } -#define ADDCISHORT(opt, neg, val) \ - if (neg) { \ - LCPDEBUG(LOG_INFO, ("lcp_addci: INT opt=%d %X\n", opt, val)); \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_SHORT, ucp); \ - PUTSHORT(val, ucp); \ - } -#define ADDCICHAP(opt, neg, val, digest) \ - if (neg) { \ - LCPDEBUG(LOG_INFO, ("lcp_addci: CHAP opt=%d %X\n", opt, val)); \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_CHAP, ucp); \ - PUTSHORT(val, ucp); \ - PUTCHAR(digest, ucp); \ - } -#define ADDCILONG(opt, neg, val) \ - if (neg) { \ - LCPDEBUG(LOG_INFO, ("lcp_addci: L opt=%d %lX\n", opt, val)); \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_LONG, ucp); \ - PUTLONG(val, ucp); \ - } -#define ADDCILQR(opt, neg, val) \ - if (neg) { \ - LCPDEBUG(LOG_INFO, ("lcp_addci: LQR opt=%d %lX\n", opt, val)); \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_LQR, ucp); \ - PUTSHORT(PPP_LQR, ucp); \ - PUTLONG(val, ucp); \ - } -#define ADDCICHAR(opt, neg, val) \ - if (neg) { \ - LCPDEBUG(LOG_INFO, ("lcp_addci: CHAR opt=%d %X '%z'\n", opt, val, val)); \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_CHAR, ucp); \ - PUTCHAR(val, ucp); \ - } - - ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); - ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap); - ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype); - ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP); - ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period); - ADDCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT); - ADDCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber); - ADDCIVOID(CI_PCOMPRESSION, go->neg_pcompression); - ADDCIVOID(CI_ACCOMPRESSION, go->neg_accompression); - - if (ucp - start_ucp != *lenp) { - /* this should never happen, because peer_mtu should be 1500 */ - LCPDEBUG(LOG_ERR, ("Bug in lcp_addci: wrong length\n")); - } -} - - -/* - * lcp_ackci - Ack our CIs. - * This should not modify any state if the Ack is bad. - * - * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. - */ -static int -lcp_ackci(fsm *f, u_char *p, int len) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - u_char cilen, citype, cichar; - u_short cishort; - u32_t cilong; - - /* - * CIs must be in exactly the same order that we sent. - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ -#define ACKCIVOID(opt, neg) \ - if (neg) { \ - if ((len -= CILEN_VOID) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_VOID || citype != opt) \ - goto bad; \ - } -#define ACKCISHORT(opt, neg, val) \ - if (neg) { \ - if ((len -= CILEN_SHORT) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_SHORT || citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ - } -#define ACKCICHAR(opt, neg, val) \ - if (neg) { \ - if ((len -= CILEN_CHAR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAR || citype != opt) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != val) \ - goto bad; \ - } -#define ACKCICHAP(opt, neg, val, digest) \ - if (neg) { \ - if ((len -= CILEN_CHAP) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAP || citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != digest) \ - goto bad; \ - } -#define ACKCILONG(opt, neg, val) \ - if (neg) { \ - if ((len -= CILEN_LONG) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_LONG || citype != opt) \ - goto bad; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - goto bad; \ - } -#define ACKCILQR(opt, neg, val) \ - if (neg) { \ - if ((len -= CILEN_LQR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_LQR || citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != PPP_LQR) \ - goto bad; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - goto bad; \ - } - - ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); - ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap); - ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype); - ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP); - ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period); - ACKCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT); - ACKCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber); - ACKCIVOID(CI_PCOMPRESSION, go->neg_pcompression); - ACKCIVOID(CI_ACCOMPRESSION, go->neg_accompression); - - /* - * If there are any remaining CIs, then this packet is bad. - */ - if (len != 0) { - goto bad; - } - LCPDEBUG(LOG_INFO, ("lcp_acki: Ack\n")); - return (1); -bad: - LCPDEBUG(LOG_WARNING, ("lcp_acki: received bad Ack!\n")); - return (0); -} - - -/* - * lcp_nakci - Peer has sent a NAK for some of our CIs. - * This should not modify any state if the Nak is bad - * or if LCP is in the LS_OPENED state. - * - * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. - */ -static int -lcp_nakci(fsm *f, u_char *p, int len) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - lcp_options *wo = &lcp_wantoptions[f->unit]; - u_char citype, cichar, *next; - u_short cishort; - u32_t cilong; - lcp_options no; /* options we've seen Naks for */ - lcp_options try; /* options to request next time */ - int looped_back = 0; - int cilen; - - BZERO(&no, sizeof(no)); - try = *go; - - /* - * Any Nak'd CIs must be in exactly the same order that we sent. - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ -#define NAKCIVOID(opt, neg, code) \ - if (go->neg && \ - len >= CILEN_VOID && \ - p[1] == CILEN_VOID && \ - p[0] == opt) { \ - len -= CILEN_VOID; \ - INCPTR(CILEN_VOID, p); \ - no.neg = 1; \ - code \ - } -#define NAKCICHAP(opt, neg, code) \ - if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - no.neg = 1; \ - code \ - } -#define NAKCICHAR(opt, neg, code) \ - if (go->neg && \ - len >= CILEN_CHAR && \ - p[1] == CILEN_CHAR && \ - p[0] == opt) { \ - len -= CILEN_CHAR; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - no.neg = 1; \ - code \ - } -#define NAKCISHORT(opt, neg, code) \ - if (go->neg && \ - len >= CILEN_SHORT && \ - p[1] == CILEN_SHORT && \ - p[0] == opt) { \ - len -= CILEN_SHORT; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ - code \ - } -#define NAKCILONG(opt, neg, code) \ - if (go->neg && \ - len >= CILEN_LONG && \ - p[1] == CILEN_LONG && \ - p[0] == opt) { \ - len -= CILEN_LONG; \ - INCPTR(2, p); \ - GETLONG(cilong, p); \ - no.neg = 1; \ - code \ - } -#define NAKCILQR(opt, neg, code) \ - if (go->neg && \ - len >= CILEN_LQR && \ - p[1] == CILEN_LQR && \ - p[0] == opt) { \ - len -= CILEN_LQR; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETLONG(cilong, p); \ - no.neg = 1; \ - code \ - } - - /* - * We don't care if they want to send us smaller packets than - * we want. Therefore, accept any MRU less than what we asked for, - * but then ignore the new value when setting the MRU in the kernel. - * If they send us a bigger MRU than what we asked, accept it, up to - * the limit of the default MRU we'd get if we didn't negotiate. - */ - if (go->neg_mru && go->mru != PPP_DEFMRU) { - NAKCISHORT(CI_MRU, neg_mru, - if (cishort <= wo->mru || cishort < PPP_DEFMRU) { - try.mru = cishort; - } - ); - } - - /* - * Add any characters they want to our (receive-side) asyncmap. - */ - if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) { - NAKCILONG(CI_ASYNCMAP, neg_asyncmap, - try.asyncmap = go->asyncmap | cilong; - ); - } - - /* - * If they've nak'd our authentication-protocol, check whether - * they are proposing a different protocol, or a different - * hash algorithm for CHAP. - */ - if ((go->neg_chap || go->neg_upap) - && len >= CILEN_SHORT - && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { - cilen = p[1]; - len -= cilen; - no.neg_chap = go->neg_chap; - no.neg_upap = go->neg_upap; - INCPTR(2, p); - GETSHORT(cishort, p); - if (cishort == PPP_PAP && cilen == CILEN_SHORT) { - /* - * If we were asking for CHAP, they obviously don't want to do it. - * If we weren't asking for CHAP, then we were asking for PAP, - * in which case this Nak is bad. - */ - if (!go->neg_chap) { - goto bad; - } - try.neg_chap = 0; - - } else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { - GETCHAR(cichar, p); - if (go->neg_chap) { - /* - * We were asking for CHAP/MD5; they must want a different - * algorithm. If they can't do MD5, we'll have to stop - * asking for CHAP. - */ - if (cichar != go->chap_mdtype) { - try.neg_chap = 0; - } - } else { - /* - * Stop asking for PAP if we were asking for it. - */ - try.neg_upap = 0; - } - - } else { - /* - * We don't recognize what they're suggesting. - * Stop asking for what we were asking for. - */ - if (go->neg_chap) { - try.neg_chap = 0; - } else { - try.neg_upap = 0; - } - p += cilen - CILEN_SHORT; - } - } - - /* - * If they can't cope with our link quality protocol, we'll have - * to stop asking for LQR. We haven't got any other protocol. - * If they Nak the reporting period, take their value XXX ? - */ - NAKCILQR(CI_QUALITY, neg_lqr, - if (cishort != PPP_LQR) { - try.neg_lqr = 0; - } else { - try.lqr_period = cilong; - } - ); - - /* - * Only implementing CBCP...not the rest of the callback options - */ - NAKCICHAR(CI_CALLBACK, neg_cbcp, - try.neg_cbcp = 0; - ); - - /* - * Check for a looped-back line. - */ - NAKCILONG(CI_MAGICNUMBER, neg_magicnumber, - try.magicnumber = magic(); - looped_back = 1; - ); - - /* - * Peer shouldn't send Nak for protocol compression or - * address/control compression requests; they should send - * a Reject instead. If they send a Nak, treat it as a Reject. - */ - NAKCIVOID(CI_PCOMPRESSION, neg_pcompression, - try.neg_pcompression = 0; - ); - NAKCIVOID(CI_ACCOMPRESSION, neg_accompression, - try.neg_accompression = 0; - ); - - /* - * There may be remaining CIs, if the peer is requesting negotiation - * on an option that we didn't include in our request packet. - * If we see an option that we requested, or one we've already seen - * in this packet, then this packet is bad. - * If we wanted to respond by starting to negotiate on the requested - * option(s), we could, but we don't, because except for the - * authentication type and quality protocol, if we are not negotiating - * an option, it is because we were told not to. - * For the authentication type, the Nak from the peer means - * `let me authenticate myself with you' which is a bit pointless. - * For the quality protocol, the Nak means `ask me to send you quality - * reports', but if we didn't ask for them, we don't want them. - * An option we don't recognize represents the peer asking to - * negotiate some option we don't support, so ignore it. - */ - while (len > CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if (cilen < CILEN_VOID || (len -= cilen) < 0) { - goto bad; - } - next = p + cilen - 2; - - switch (citype) { - case CI_MRU: - if ((go->neg_mru && go->mru != PPP_DEFMRU) - || no.neg_mru || cilen != CILEN_SHORT) { - goto bad; - } - GETSHORT(cishort, p); - if (cishort < PPP_DEFMRU) { - try.mru = cishort; - } - break; - case CI_ASYNCMAP: - if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) - || no.neg_asyncmap || cilen != CILEN_LONG) { - goto bad; - } - break; - case CI_AUTHTYPE: - if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap) { - goto bad; - } - break; - case CI_MAGICNUMBER: - if (go->neg_magicnumber || no.neg_magicnumber || - cilen != CILEN_LONG) { - goto bad; - } - break; - case CI_PCOMPRESSION: - if (go->neg_pcompression || no.neg_pcompression - || cilen != CILEN_VOID) { - goto bad; - } - break; - case CI_ACCOMPRESSION: - if (go->neg_accompression || no.neg_accompression - || cilen != CILEN_VOID) { - goto bad; - } - break; - case CI_QUALITY: - if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) { - goto bad; - } - break; - } - p = next; - } - - /* If there is still anything left, this packet is bad. */ - if (len != 0) { - goto bad; - } - - /* - * OK, the Nak is good. Now we can update state. - */ - if (f->state != LS_OPENED) { - if (looped_back) { - if (++try.numloops >= lcp_loopbackfail) { - LCPDEBUG(LOG_NOTICE, ("Serial line is looped back.\n")); - lcp_close(f->unit, "Loopback detected"); - } - } else { - try.numloops = 0; - } - *go = try; - } - - return 1; - -bad: - LCPDEBUG(LOG_WARNING, ("lcp_nakci: received bad Nak!\n")); - return 0; -} - - -/* - * lcp_rejci - Peer has Rejected some of our CIs. - * This should not modify any state if the Reject is bad - * or if LCP is in the LS_OPENED state. - * - * Returns: - * 0 - Reject was bad. - * 1 - Reject was good. - */ -static int -lcp_rejci(fsm *f, u_char *p, int len) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - u_char cichar; - u_short cishort; - u32_t cilong; - lcp_options try; /* options to request next time */ - - try = *go; - - /* - * Any Rejected CIs must be in exactly the same order that we sent. - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ -#define REJCIVOID(opt, neg) \ - if (go->neg && \ - len >= CILEN_VOID && \ - p[1] == CILEN_VOID && \ - p[0] == opt) { \ - len -= CILEN_VOID; \ - INCPTR(CILEN_VOID, p); \ - try.neg = 0; \ - LCPDEBUG(LOG_INFO, ("lcp_rejci: void opt %d rejected\n", opt)); \ - } -#define REJCISHORT(opt, neg, val) \ - if (go->neg && \ - len >= CILEN_SHORT && \ - p[1] == CILEN_SHORT && \ - p[0] == opt) { \ - len -= CILEN_SHORT; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) { \ - goto bad; \ - } \ - try.neg = 0; \ - LCPDEBUG(LOG_INFO, ("lcp_rejci: short opt %d rejected\n", opt)); \ - } -#define REJCICHAP(opt, neg, val, digest) \ - if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if (cishort != val || cichar != digest) { \ - goto bad; \ - } \ - try.neg = 0; \ - try.neg_upap = 0; \ - LCPDEBUG(LOG_INFO, ("lcp_rejci: chap opt %d rejected\n", opt)); \ - } -#define REJCILONG(opt, neg, val) \ - if (go->neg && \ - len >= CILEN_LONG && \ - p[1] == CILEN_LONG && \ - p[0] == opt) { \ - len -= CILEN_LONG; \ - INCPTR(2, p); \ - GETLONG(cilong, p); \ - /* Check rejected value. */ \ - if (cilong != val) { \ - goto bad; \ - } \ - try.neg = 0; \ - LCPDEBUG(LOG_INFO, ("lcp_rejci: long opt %d rejected\n", opt)); \ - } -#define REJCILQR(opt, neg, val) \ - if (go->neg && \ - len >= CILEN_LQR && \ - p[1] == CILEN_LQR && \ - p[0] == opt) { \ - len -= CILEN_LQR; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETLONG(cilong, p); \ - /* Check rejected value. */ \ - if (cishort != PPP_LQR || cilong != val) { \ - goto bad; \ - } \ - try.neg = 0; \ - LCPDEBUG(LOG_INFO, ("lcp_rejci: LQR opt %d rejected\n", opt)); \ - } -#define REJCICBCP(opt, neg, val) \ - if (go->neg && \ - len >= CILEN_CBCP && \ - p[1] == CILEN_CBCP && \ - p[0] == opt) { \ - len -= CILEN_CBCP; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if (cichar != val) { \ - goto bad; \ - } \ - try.neg = 0; \ - LCPDEBUG(LOG_INFO, ("lcp_rejci: Callback opt %d rejected\n", opt)); \ - } - - REJCISHORT(CI_MRU, neg_mru, go->mru); - REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap); - REJCICHAP(CI_AUTHTYPE, neg_chap, PPP_CHAP, go->chap_mdtype); - if (!go->neg_chap) { - REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); - } - REJCILQR(CI_QUALITY, neg_lqr, go->lqr_period); - REJCICBCP(CI_CALLBACK, neg_cbcp, CBCP_OPT); - REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber); - REJCIVOID(CI_PCOMPRESSION, neg_pcompression); - REJCIVOID(CI_ACCOMPRESSION, neg_accompression); - - /* - * If there are any remaining CIs, then this packet is bad. - */ - if (len != 0) { - goto bad; - } - /* - * Now we can update state. - */ - if (f->state != LS_OPENED) { - *go = try; - } - return 1; - -bad: - LCPDEBUG(LOG_WARNING, ("lcp_rejci: received bad Reject!\n")); - return 0; -} - - -/* - * lcp_reqci - Check the peer's requested CIs and send appropriate response. - * - * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified - * appropriately. If reject_if_disagree is non-zero, doesn't return - * CONFNAK; returns CONFREJ if it can't return CONFACK. - */ -static int -lcp_reqci(fsm *f, - u_char *inp, /* Requested CIs */ - int *lenp, /* Length of requested CIs */ - int reject_if_disagree) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - lcp_options *ho = &lcp_hisoptions[f->unit]; - lcp_options *ao = &lcp_allowoptions[f->unit]; - u_char *cip, *next; /* Pointer to current and next CIs */ - int cilen, citype; /* Parsed len, type */ - u_char cichar; /* Parsed char value */ - u_short cishort; /* Parsed short value */ - u32_t cilong; /* Parse long value */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *rejp; /* Pointer to next char in reject frame */ - u_char *nakp; /* Pointer to next char in Nak frame */ - int l = *lenp; /* Length left */ -#if TRACELCP > 0 - char traceBuf[80]; - size_t traceNdx = 0; -#endif - - /* - * Reset all his options. - */ - BZERO(ho, sizeof(*ho)); - - /* - * Process all his options. - */ - next = inp; - nakp = nak_buffer; - rejp = inp; - while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - LCPDEBUG(LOG_WARNING, ("lcp_reqci: bad CI length!\n")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - citype = 0; - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_MRU: - if (!ao->neg_mru) { /* Allow option? */ - LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject MRU - not allowed\n")); - orc = CONFREJ; /* Reject CI */ - break; - } else if (cilen != CILEN_SHORT) { /* Check CI length */ - LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject MRU - bad length\n")); - orc = CONFREJ; /* Reject CI */ - break; - } - GETSHORT(cishort, p); /* Parse MRU */ - - /* - * He must be able to receive at least our minimum. - * No need to check a maximum. If he sends a large number, - * we'll just ignore it. - */ - if (cishort < PPP_MINMRU) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak - MRU too small\n")); - orc = CONFNAK; /* Nak CI */ - PUTCHAR(CI_MRU, nakp); - PUTCHAR(CILEN_SHORT, nakp); - PUTSHORT(PPP_MINMRU, nakp); /* Give him a hint */ - break; - } - ho->neg_mru = 1; /* Remember he sent MRU */ - ho->mru = cishort; /* And remember value */ -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " MRU %d", cishort); - traceNdx = strlen(traceBuf); -#endif - break; - - case CI_ASYNCMAP: - if (!ao->neg_asyncmap) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject ASYNCMAP not allowed\n")); - orc = CONFREJ; - break; - } else if (cilen != CILEN_LONG) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject ASYNCMAP bad length\n")); - orc = CONFREJ; - break; - } - GETLONG(cilong, p); - - /* - * Asyncmap must have set at least the bits - * which are set in lcp_allowoptions[unit].asyncmap. - */ - if ((ao->asyncmap & ~cilong) != 0) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak ASYNCMAP %lX missing %lX\n", - cilong, ao->asyncmap)); - orc = CONFNAK; - PUTCHAR(CI_ASYNCMAP, nakp); - PUTCHAR(CILEN_LONG, nakp); - PUTLONG(ao->asyncmap | cilong, nakp); - break; - } - ho->neg_asyncmap = 1; - ho->asyncmap = cilong; -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ASYNCMAP=%lX", cilong); - traceNdx = strlen(traceBuf); -#endif - break; - - case CI_AUTHTYPE: - if (cilen < CILEN_SHORT) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject AUTHTYPE missing arg\n")); - orc = CONFREJ; - break; - } else if (!(ao->neg_upap || ao->neg_chap)) { - /* - * Reject the option if we're not willing to authenticate. - */ - LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject AUTHTYPE not allowed\n")); - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - - /* - * Authtype must be UPAP or CHAP. - * - * Note: if both ao->neg_upap and ao->neg_chap are set, - * and the peer sends a Configure-Request with two - * authenticate-protocol requests, one for CHAP and one - * for UPAP, then we will reject the second request. - * Whether we end up doing CHAP or UPAP depends then on - * the ordering of the CIs in the peer's Configure-Request. - */ - - if (cishort == PPP_PAP) { - if (ho->neg_chap) { /* we've already accepted CHAP */ - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP already accepted\n")); - orc = CONFREJ; - break; - } else if (cilen != CILEN_SHORT) { - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP bad len\n")); - orc = CONFREJ; - break; - } - if (!ao->neg_upap) { /* we don't want to do PAP */ - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE PAP not allowed\n")); - orc = CONFNAK; /* NAK it and suggest CHAP */ - PUTCHAR(CI_AUTHTYPE, nakp); - PUTCHAR(CILEN_CHAP, nakp); - PUTSHORT(PPP_CHAP, nakp); - PUTCHAR(ao->chap_mdtype, nakp); - break; - } - ho->neg_upap = 1; -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PAP (%X)", cishort); - traceNdx = strlen(traceBuf); -#endif - break; - } - if (cishort == PPP_CHAP) { - if (ho->neg_upap) { /* we've already accepted PAP */ - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE CHAP accepted PAP\n")); - orc = CONFREJ; - break; - } else if (cilen != CILEN_CHAP) { - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE CHAP bad len\n")); - orc = CONFREJ; - break; - } - if (!ao->neg_chap) { /* we don't want to do CHAP */ - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE CHAP not allowed\n")); - orc = CONFNAK; /* NAK it and suggest PAP */ - PUTCHAR(CI_AUTHTYPE, nakp); - PUTCHAR(CILEN_SHORT, nakp); - PUTSHORT(PPP_PAP, nakp); - break; - } - GETCHAR(cichar, p); /* get digest type*/ - if (cichar != CHAP_DIGEST_MD5 -#if MSCHAP_SUPPORT - && cichar != CHAP_MICROSOFT -#endif - ) { - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE CHAP digest=%d\n", (int)cichar)); - orc = CONFNAK; - PUTCHAR(CI_AUTHTYPE, nakp); - PUTCHAR(CILEN_CHAP, nakp); - PUTSHORT(PPP_CHAP, nakp); - PUTCHAR(ao->chap_mdtype, nakp); - break; - } -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CHAP %X,%d", cishort, (int)cichar); - traceNdx = strlen(traceBuf); -#endif - ho->chap_mdtype = cichar; /* save md type */ - ho->neg_chap = 1; - break; - } - - /* - * We don't recognize the protocol they're asking for. - * Nak it with something we're willing to do. - * (At this point we know ao->neg_upap || ao->neg_chap.) - */ - orc = CONFNAK; - PUTCHAR(CI_AUTHTYPE, nakp); - if (ao->neg_chap) { - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE %d req CHAP\n", cishort)); - PUTCHAR(CILEN_CHAP, nakp); - PUTSHORT(PPP_CHAP, nakp); - PUTCHAR(ao->chap_mdtype, nakp); - } else { - LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE %d req PAP\n", cishort)); - PUTCHAR(CILEN_SHORT, nakp); - PUTSHORT(PPP_PAP, nakp); - } - break; - - case CI_QUALITY: - GETSHORT(cishort, p); - GETLONG(cilong, p); -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " QUALITY (%x %x)", cishort, (unsigned int) cilong); - traceNdx = strlen(traceBuf); -#endif - - if (!ao->neg_lqr || - cilen != CILEN_LQR) { - orc = CONFREJ; - break; - } - - /* - * Check the protocol and the reporting period. - * XXX When should we Nak this, and what with? - */ - if (cishort != PPP_LQR) { - orc = CONFNAK; - PUTCHAR(CI_QUALITY, nakp); - PUTCHAR(CILEN_LQR, nakp); - PUTSHORT(PPP_LQR, nakp); - PUTLONG(ao->lqr_period, nakp); - break; - } - break; - - case CI_MAGICNUMBER: - if (!(ao->neg_magicnumber || go->neg_magicnumber) || - cilen != CILEN_LONG) { - orc = CONFREJ; - break; - } - GETLONG(cilong, p); -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " MAGICNUMBER (%lX)", cilong); - traceNdx = strlen(traceBuf); -#endif - - /* - * He must have a different magic number. - */ - if (go->neg_magicnumber && - cilong == go->magicnumber) { - cilong = magic(); /* Don't put magic() inside macro! */ - orc = CONFNAK; - PUTCHAR(CI_MAGICNUMBER, nakp); - PUTCHAR(CILEN_LONG, nakp); - PUTLONG(cilong, nakp); - break; - } - ho->neg_magicnumber = 1; - ho->magicnumber = cilong; - break; - - - case CI_PCOMPRESSION: -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PCOMPRESSION"); - traceNdx = strlen(traceBuf); -#endif - if (!ao->neg_pcompression || - cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_pcompression = 1; - break; - - case CI_ACCOMPRESSION: -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ACCOMPRESSION"); - traceNdx = strlen(traceBuf); -#endif - if (!ao->neg_accompression || - cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_accompression = 1; - break; - - case CI_MRRU: -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_MRRU"); - traceNdx = strlen(traceBuf); -#endif - orc = CONFREJ; - break; - - case CI_SSNHF: -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_SSNHF"); - traceNdx = strlen(traceBuf); -#endif - orc = CONFREJ; - break; - - case CI_EPDISC: -#if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_EPDISC"); - traceNdx = strlen(traceBuf); -#endif - orc = CONFREJ; - break; - - default: -#if TRACELCP - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " unknown %d", citype); - traceNdx = strlen(traceBuf); -#endif - orc = CONFREJ; - break; - } - - endswitch: -#if TRACELCP - if (traceNdx >= 80 - 32) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: rcvd%s\n", traceBuf)); - traceNdx = 0; - } -#endif - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) { /* but prior CI wasnt? */ - continue; /* Don't send this one */ - } - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree /* Getting fed up with sending NAKs? */ - && citype != CI_MAGICNUMBER) { - orc = CONFREJ; /* Get tough if so */ - } else { - if (rc == CONFREJ) { /* Rejecting prior CI? */ - continue; /* Don't send this one */ - } - rc = CONFNAK; - } - } - if (orc == CONFREJ) { /* Reject this CI */ - rc = CONFREJ; - if (cip != rejp) { /* Need to move rejected CI? */ - BCOPY(cip, rejp, cilen); /* Move it */ - } - INCPTR(cilen, rejp); /* Update output pointer */ - } - } - - /* - * If we wanted to send additional NAKs (for unsent CIs), the - * code would go here. The extra NAKs would go at *nakp. - * At present there are no cases where we want to ask the - * peer to negotiate an option. - */ - - switch (rc) { - case CONFACK: - *lenp = (int)(next - inp); - break; - case CONFNAK: - /* - * Copy the Nak'd options from the nak_buffer to the caller's buffer. - */ - *lenp = (int)(nakp - nak_buffer); - BCOPY(nak_buffer, inp, *lenp); - break; - case CONFREJ: - *lenp = (int)(rejp - inp); - break; - } - -#if TRACELCP > 0 - if (traceNdx > 0) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: %s\n", traceBuf)); - } -#endif - LCPDEBUG(LOG_INFO, ("lcp_reqci: returning CONF%s.\n", CODENAME(rc))); - return (rc); /* Return final code */ -} - - -/* - * lcp_up - LCP has come UP. - */ -static void -lcp_up(fsm *f) -{ - lcp_options *wo = &lcp_wantoptions[f->unit]; - lcp_options *ho = &lcp_hisoptions[f->unit]; - lcp_options *go = &lcp_gotoptions[f->unit]; - lcp_options *ao = &lcp_allowoptions[f->unit]; - - if (!go->neg_magicnumber) { - go->magicnumber = 0; - } - if (!ho->neg_magicnumber) { - ho->magicnumber = 0; - } - - /* - * Set our MTU to the smaller of the MTU we wanted and - * the MRU our peer wanted. If we negotiated an MRU, - * set our MRU to the larger of value we wanted and - * the value we got in the negotiation. - */ - ppp_send_config(f->unit, LWIP_MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)), - (ho->neg_asyncmap? ho->asyncmap: 0xffffffffl), - ho->neg_pcompression, ho->neg_accompression); - /* - * If the asyncmap hasn't been negotiated, we really should - * set the receive asyncmap to ffffffff, but we set it to 0 - * for backwards contemptibility. - */ - ppp_recv_config(f->unit, (go->neg_mru? LWIP_MAX(wo->mru, go->mru): PPP_MRU), - (go->neg_asyncmap? go->asyncmap: 0x00000000), - go->neg_pcompression, go->neg_accompression); - - if (ho->neg_mru) { - peer_mru[f->unit] = ho->mru; - } - - lcp_echo_lowerup(f->unit); /* Enable echo messages */ - - link_established(f->unit); /* The link is up; authenticate now */ -} - - -/* - * lcp_down - LCP has gone DOWN. - * - * Alert other protocols. - */ -static void -lcp_down(fsm *f) -{ - lcp_options *go = &lcp_gotoptions[f->unit]; - - lcp_echo_lowerdown(f->unit); - - link_down(f->unit); - - ppp_send_config(f->unit, PPP_MRU, 0xffffffffl, 0, 0); - ppp_recv_config(f->unit, PPP_MRU, - (go->neg_asyncmap? go->asyncmap: 0x00000000), - go->neg_pcompression, go->neg_accompression); - peer_mru[f->unit] = PPP_MRU; -} - - -/* - * lcp_starting - LCP needs the lower layer up. - */ -static void -lcp_starting(fsm *f) -{ - link_required(f->unit); /* lwip: currently does nothing */ -} - - -/* - * lcp_finished - LCP has finished with the lower layer. - */ -static void -lcp_finished(fsm *f) -{ - link_terminated(f->unit); /* we are finished with the link */ -} - - -#if PPP_ADDITIONAL_CALLBACKS -/* - * print_string - print a readable representation of a string using - * printer. - */ -static void -print_string( char *p, int len, void (*printer) (void *, char *, ...), void *arg) -{ - int c; - - printer(arg, "\""); - for (; len > 0; --len) { - c = *p++; - if (' ' <= c && c <= '~') { - if (c == '\\' || c == '"') { - printer(arg, "\\"); - } - printer(arg, "%c", c); - } else { - switch (c) { - case '\n': - printer(arg, "\\n"); - break; - case '\r': - printer(arg, "\\r"); - break; - case '\t': - printer(arg, "\\t"); - break; - default: - printer(arg, "\\%.3o", c); - } - } - } - printer(arg, "\""); -} - - -/* - * lcp_printpkt - print the contents of an LCP packet. - */ -static char *lcp_codenames[] = { - "ConfReq", "ConfAck", "ConfNak", "ConfRej", - "TermReq", "TermAck", "CodeRej", "ProtRej", - "EchoReq", "EchoRep", "DiscReq" -}; - -static int -lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) -{ - int code, id, len, olen; - u_char *pstart, *optend; - u_short cishort; - u32_t cilong; - - if (plen < HEADERLEN) { - return 0; - } - pstart = p; - GETCHAR(code, p); - GETCHAR(id, p); - GETSHORT(len, p); - if (len < HEADERLEN || len > plen) { - return 0; - } - - if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *)) { - printer(arg, " %s", lcp_codenames[code-1]); - } else { - printer(arg, " code=0x%x", code); - } - printer(arg, " id=0x%x", id); - len -= HEADERLEN; - switch (code) { - case CONFREQ: - case CONFACK: - case CONFNAK: - case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { - case CI_MRU: - if (olen == CILEN_SHORT) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "mru %d", cishort); - } - break; - case CI_ASYNCMAP: - if (olen == CILEN_LONG) { - p += 2; - GETLONG(cilong, p); - printer(arg, "asyncmap 0x%lx", cilong); - } - break; - case CI_AUTHTYPE: - if (olen >= CILEN_SHORT) { - p += 2; - printer(arg, "auth "); - GETSHORT(cishort, p); - switch (cishort) { - case PPP_PAP: - printer(arg, "pap"); - break; - case PPP_CHAP: - printer(arg, "chap"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; - case CI_QUALITY: - if (olen >= CILEN_SHORT) { - p += 2; - printer(arg, "quality "); - GETSHORT(cishort, p); - switch (cishort) { - case PPP_LQR: - printer(arg, "lqr"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; - case CI_CALLBACK: - if (olen >= CILEN_CHAR) { - p += 2; - printer(arg, "callback "); - GETSHORT(cishort, p); - switch (cishort) { - case CBCP_OPT: - printer(arg, "CBCP"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; - case CI_MAGICNUMBER: - if (olen == CILEN_LONG) { - p += 2; - GETLONG(cilong, p); - printer(arg, "magic 0x%x", cilong); - } - break; - case CI_PCOMPRESSION: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "pcomp"); - } - break; - case CI_ACCOMPRESSION: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "accomp"); - } - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; - - case TERMACK: - case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - print_string((char*)p, len, printer, arg); - p += len; - len = 0; - } - break; - - case ECHOREQ: - case ECHOREP: - case DISCREQ: - if (len >= 4) { - GETLONG(cilong, p); - printer(arg, " magic=0x%x", cilong); - p += 4; - len -= 4; - } - break; - } - - /* print the rest of the bytes in the packet */ - for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - - return (int)(p - pstart); -} -#endif /* PPP_ADDITIONAL_CALLBACKS */ - -/* - * Time to shut down the link because there is nothing out there. - */ -static void -LcpLinkFailure (fsm *f) -{ - if (f->state == LS_OPENED) { - LCPDEBUG(LOG_INFO, ("No response to %d echo-requests\n", lcp_echos_pending)); - LCPDEBUG(LOG_NOTICE, ("Serial link appears to be disconnected.\n")); - lcp_close(f->unit, "Peer not responding"); - } -} - -/* - * Timer expired for the LCP echo requests from this process. - */ -static void -LcpEchoCheck (fsm *f) -{ - LcpSendEchoRequest (f); - - /* - * Start the timer for the next interval. - */ - LWIP_ASSERT("lcp_echo_timer_running == 0", lcp_echo_timer_running == 0); - - TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval); - lcp_echo_timer_running = 1; -} - -/* - * LcpEchoTimeout - Timer expired on the LCP echo - */ -static void -LcpEchoTimeout (void *arg) -{ - if (lcp_echo_timer_running != 0) { - lcp_echo_timer_running = 0; - LcpEchoCheck ((fsm *) arg); - } -} - -/* - * LcpEchoReply - LCP has received a reply to the echo - */ -static void -lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len) -{ - u32_t magic; - - LWIP_UNUSED_ARG(id); - - /* Check the magic number - don't count replies from ourselves. */ - if (len < 4) { - LCPDEBUG(LOG_WARNING, ("lcp: received short Echo-Reply, length %d\n", len)); - return; - } - GETLONG(magic, inp); - if (lcp_gotoptions[f->unit].neg_magicnumber && magic == lcp_gotoptions[f->unit].magicnumber) { - LCPDEBUG(LOG_WARNING, ("appear to have received our own echo-reply!\n")); - return; - } - - /* Reset the number of outstanding echo frames */ - lcp_echos_pending = 0; -} - -/* - * LcpSendEchoRequest - Send an echo request frame to the peer - */ -static void -LcpSendEchoRequest (fsm *f) -{ - u32_t lcp_magic; - u_char pkt[4], *pktp; - - /* - * Detect the failure of the peer at this point. - */ - if (lcp_echo_fails != 0) { - if (lcp_echos_pending >= lcp_echo_fails) { - LcpLinkFailure(f); - lcp_echos_pending = 0; - } - } - - /* - * Make and send the echo request frame. - */ - if (f->state == LS_OPENED) { - lcp_magic = lcp_gotoptions[f->unit].magicnumber; - pktp = pkt; - PUTLONG(lcp_magic, pktp); - fsm_sdata(f, ECHOREQ, (u_char)(lcp_echo_number++ & 0xFF), pkt, (int)(pktp - pkt)); - ++lcp_echos_pending; - } -} - -/* - * lcp_echo_lowerup - Start the timer for the LCP frame - */ - -static void -lcp_echo_lowerup (int unit) -{ - fsm *f = &lcp_fsm[unit]; - - /* Clear the parameters for generating echo frames */ - lcp_echos_pending = 0; - lcp_echo_number = 0; - lcp_echo_timer_running = 0; - - /* If a timeout interval is specified then start the timer */ - if (lcp_echo_interval != 0) { - LcpEchoCheck (f); - } -} - -/* - * lcp_echo_lowerdown - Stop the timer for the LCP frame - */ - -static void -lcp_echo_lowerdown (int unit) -{ - fsm *f = &lcp_fsm[unit]; - - if (lcp_echo_timer_running != 0) { - UNTIMEOUT (LcpEchoTimeout, f); - lcp_echo_timer_running = 0; - } -} - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/lcp.h b/user/mpy/lib/lwip/src/netif/ppp/lcp.h deleted file mode 100644 index b9201ee..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/lcp.h +++ /dev/null @@ -1,151 +0,0 @@ -/***************************************************************************** -* lcp.h - Network Link Control Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ -/* - * lcp.h - Link Control Protocol definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: lcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $ - */ - -#ifndef LCP_H -#define LCP_H -/* - * Options. - */ -#define CI_MRU 1 /* Maximum Receive Unit */ -#define CI_ASYNCMAP 2 /* Async Control Character Map */ -#define CI_AUTHTYPE 3 /* Authentication Type */ -#define CI_QUALITY 4 /* Quality Protocol */ -#define CI_MAGICNUMBER 5 /* Magic Number */ -#define CI_PCOMPRESSION 7 /* Protocol Field Compression */ -#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */ -#define CI_CALLBACK 13 /* callback */ -#define CI_MRRU 17 /* max reconstructed receive unit; multilink */ -#define CI_SSNHF 18 /* short sequence numbers for multilink */ -#define CI_EPDISC 19 /* endpoint discriminator */ - -/* - * LCP-specific packet types (code numbers). - */ -#define PROTREJ 8 /* Protocol Reject */ -#define ECHOREQ 9 /* Echo Request */ -#define ECHOREP 10 /* Echo Reply */ -#define DISCREQ 11 /* Discard Request */ -#define CBCP_OPT 6 /* Use callback control protocol */ - -/* - * The state of options is described by an lcp_options structure. - */ -typedef struct lcp_options { - u_int passive : 1; /* Don't die if we don't get a response */ - u_int silent : 1; /* Wait for the other end to start first */ - u_int restart : 1; /* Restart vs. exit after close */ - u_int neg_mru : 1; /* Negotiate the MRU? */ - u_int neg_asyncmap : 1; /* Negotiate the async map? */ - u_int neg_upap : 1; /* Ask for UPAP authentication? */ - u_int neg_chap : 1; /* Ask for CHAP authentication? */ - u_int neg_magicnumber : 1; /* Ask for magic number? */ - u_int neg_pcompression : 1; /* HDLC Protocol Field Compression? */ - u_int neg_accompression : 1; /* HDLC Address/Control Field Compression? */ - u_int neg_lqr : 1; /* Negotiate use of Link Quality Reports */ - u_int neg_cbcp : 1; /* Negotiate use of CBCP */ -#ifdef PPP_MULTILINK - u_int neg_mrru : 1; /* Negotiate multilink MRRU */ - u_int neg_ssnhf : 1; /* Negotiate short sequence numbers */ - u_int neg_endpoint : 1; /* Negotiate endpoint discriminator */ -#endif - u_short mru; /* Value of MRU */ -#ifdef PPP_MULTILINK - u_short mrru; /* Value of MRRU, and multilink enable */ -#endif - u_char chap_mdtype; /* which MD type (hashing algorithm) */ - u32_t asyncmap; /* Value of async map */ - u32_t magicnumber; - int numloops; /* Number of loops during magic number neg. */ - u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ -#ifdef PPP_MULTILINK - struct epdisc endpoint; /* endpoint discriminator */ -#endif -} lcp_options; - -/* - * Values for phase from BSD pppd.h based on RFC 1661. - */ -typedef enum { - PHASE_DEAD = 0, - PHASE_INITIALIZE, - PHASE_ESTABLISH, - PHASE_AUTHENTICATE, - PHASE_CALLBACK, - PHASE_NETWORK, - PHASE_TERMINATE -} LinkPhase; - - - -extern LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */ -extern lcp_options lcp_wantoptions[]; -extern lcp_options lcp_gotoptions[]; -extern lcp_options lcp_allowoptions[]; -extern lcp_options lcp_hisoptions[]; -extern ext_accm xmit_accm[]; - - -void lcp_init (int); -void lcp_open (int); -void lcp_close (int, char *); -void lcp_lowerup (int); -void lcp_lowerdown(int); -void lcp_sprotrej (int, u_char *, int); /* send protocol reject */ - -extern struct protent lcp_protent; - -/* Default number of times we receive our magic number from the peer - before deciding the link is looped-back. */ -#define DEFLOOPBACKFAIL 10 - -#endif /* LCP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/magic.c b/user/mpy/lib/lwip/src/netif/ppp/magic.c deleted file mode 100644 index 3732a42..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/magic.c +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** -* magic.c - Network Random Number Generator program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-04 Guy Lancaster , Global Election Systems Inc. -* Original based on BSD magic.c. -*****************************************************************************/ -/* - * magic.c - PPP Magic Number routines. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT - -#include "ppp_impl.h" -#include "randm.h" -#include "magic.h" - - -/* - * magicInit - Initialize the magic number generator. - * - * Since we use another random number generator that has its own - * initialization, we do nothing here. - */ -void magicInit() -{ - return; -} - -/* - * magic - Returns the next magic number. - */ -u32_t magic() -{ - return avRandom(); -} - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/magic.h b/user/mpy/lib/lwip/src/netif/ppp/magic.h deleted file mode 100644 index eba70d2..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/magic.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** -* magic.h - Network Random Number Generator header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-04 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ -/* - * magic.h - PPP Magic Number definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: magic.h,v 1.3 2010/01/18 20:49:43 goldsimon Exp $ - */ - -#ifndef MAGIC_H -#define MAGIC_H - -/* Initialize the magic number generator */ -void magicInit(void); - -/* Returns the next magic number */ -u32_t magic(void); - -#endif /* MAGIC_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/md5.c b/user/mpy/lib/lwip/src/netif/ppp/md5.c deleted file mode 100644 index dc3cc75..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/md5.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - *********************************************************************** - ** md5.c -- the source code for MD5 routines ** - ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** - ** Created: 2/17/90 RLR ** - ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. ** - *********************************************************************** - */ - -/* - *********************************************************************** - ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** - ** ** - ** License to copy and use this software is granted provided that ** - ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** - ** Digest Algorithm" in all material mentioning or referencing this ** - ** software or this function. ** - ** ** - ** License is also granted to make and use derivative works ** - ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** - ** material mentioning or referencing the derived work. ** - ** ** - ** RSA Data Security, Inc. makes no representations concerning ** - ** either the merchantability of this software or the suitability ** - ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** - ** ** - ** These notices must be retained in any copies of any part of this ** - ** documentation and/or software. ** - *********************************************************************** - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#if CHAP_SUPPORT || MD5_SUPPORT - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "md5.h" - -#include - -/* - *********************************************************************** - ** Message-digest routines: ** - ** To form the message digest for a message M ** - ** (1) Initialize a context buffer mdContext using MD5Init ** - ** (2) Call MD5Update on mdContext and M ** - ** (3) Call MD5Final on mdContext ** - ** The message digest is now in mdContext->digest[0...15] ** - *********************************************************************** - */ - -/* forward declaration */ -static void Transform (u32_t *buf, u32_t *in); - -static unsigned char PADDING[64] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* F, G, H and I are basic MD5 functions */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ -/* Rotation is separate from addition to prevent recomputation */ -#define FF(a, b, c, d, x, s, ac) \ - {(a) += F ((b), (c), (d)) + (x) + (u32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) \ - {(a) += G ((b), (c), (d)) + (x) + (u32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) \ - {(a) += H ((b), (c), (d)) + (x) + (u32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) \ - {(a) += I ((b), (c), (d)) + (x) + (u32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -#ifdef __STDC__ -#define UL(x) x##UL -#else -#ifdef WIN32 -#define UL(x) x##UL -#else -#define UL(x) x -#endif -#endif - -/* The routine MD5Init initializes the message-digest context - mdContext. All fields are set to zero. - */ -void -MD5Init (MD5_CTX *mdContext) -{ - mdContext->i[0] = mdContext->i[1] = (u32_t)0; - - /* Load magic initialization constants. */ - mdContext->buf[0] = (u32_t)0x67452301UL; - mdContext->buf[1] = (u32_t)0xefcdab89UL; - mdContext->buf[2] = (u32_t)0x98badcfeUL; - mdContext->buf[3] = (u32_t)0x10325476UL; -} - -/* The routine MD5Update updates the message-digest context to - account for the presence of each of the characters inBuf[0..inLen-1] - in the message whose digest is being computed. - */ -void -MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) -{ - u32_t in[16]; - int mdi; - unsigned int i, ii; - -#if 0 - PPPDEBUG(LOG_INFO, ("MD5Update: %u:%.*H\n", inLen, LWIP_MIN(inLen, 20) * 2, inBuf)); - PPPDEBUG(LOG_INFO, ("MD5Update: %u:%s\n", inLen, inBuf)); -#endif - - /* compute number of bytes mod 64 */ - mdi = (int)((mdContext->i[0] >> 3) & 0x3F); - - /* update number of bits */ - if ((mdContext->i[0] + ((u32_t)inLen << 3)) < mdContext->i[0]) { - mdContext->i[1]++; - } - mdContext->i[0] += ((u32_t)inLen << 3); - mdContext->i[1] += ((u32_t)inLen >> 29); - - while (inLen--) { - /* add new character to buffer, increment mdi */ - mdContext->in[mdi++] = *inBuf++; - - /* transform if necessary */ - if (mdi == 0x40) { - for (i = 0, ii = 0; i < 16; i++, ii += 4) { - in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | - (((u32_t)mdContext->in[ii+2]) << 16) | - (((u32_t)mdContext->in[ii+1]) << 8) | - ((u32_t)mdContext->in[ii]); - } - Transform (mdContext->buf, in); - mdi = 0; - } - } -} - -/* The routine MD5Final terminates the message-digest computation and - ends with the desired message digest in mdContext->digest[0...15]. - */ -void -MD5Final (unsigned char hash[], MD5_CTX *mdContext) -{ - u32_t in[16]; - int mdi; - unsigned int i, ii; - unsigned int padLen; - - /* save number of bits */ - in[14] = mdContext->i[0]; - in[15] = mdContext->i[1]; - - /* compute number of bytes mod 64 */ - mdi = (int)((mdContext->i[0] >> 3) & 0x3F); - - /* pad out to 56 mod 64 */ - padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); - MD5Update (mdContext, PADDING, padLen); - - /* append length in bits and transform */ - for (i = 0, ii = 0; i < 14; i++, ii += 4) { - in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | - (((u32_t)mdContext->in[ii+2]) << 16) | - (((u32_t)mdContext->in[ii+1]) << 8) | - ((u32_t)mdContext->in[ii]); - } - Transform (mdContext->buf, in); - - /* store buffer in digest */ - for (i = 0, ii = 0; i < 4; i++, ii += 4) { - mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); - mdContext->digest[ii+1] = - (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); - mdContext->digest[ii+2] = - (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); - mdContext->digest[ii+3] = - (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); - } - SMEMCPY(hash, mdContext->digest, 16); -} - -/* Basic MD5 step. Transforms buf based on in. - */ -static void -Transform (u32_t *buf, u32_t *in) -{ - u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3]; - - /* Round 1 */ -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 - FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */ - FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */ - FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */ - FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */ - FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */ - FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */ - FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */ - FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */ - FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */ - FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */ - FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */ - FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */ - FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */ - FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */ - FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */ - FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */ - - /* Round 2 */ -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 - GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */ - GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */ - GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */ - GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */ - GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */ - GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */ - GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */ - GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */ - GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */ - GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */ - GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */ - GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */ - GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */ - GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */ - GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */ - GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */ - - /* Round 3 */ -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 - HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */ - HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */ - HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */ - HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */ - HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */ - HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */ - HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */ - HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */ - HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */ - HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */ - HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */ - HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */ - HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */ - HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */ - HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */ - HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */ - - /* Round 4 */ -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */ - II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */ - II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */ - II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */ - II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */ - II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */ - II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */ - II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */ - II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */ - II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */ - II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */ - II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */ - II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */ - II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */ - II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */ - II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */ - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -#endif /* CHAP_SUPPORT || MD5_SUPPORT */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/md5.h b/user/mpy/lib/lwip/src/netif/ppp/md5.h deleted file mode 100644 index e129533..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/md5.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - *********************************************************************** - ** md5.h -- header file for implementation of MD5 ** - ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** - ** Created: 2/17/90 RLR ** - ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** - ** Revised (for MD5): RLR 4/27/91 ** - ** -- G modified to have y&~z instead of y&z ** - ** -- FF, GG, HH modified to add in last register done ** - ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** - ** -- distinct additive constant for each step ** - ** -- round 4 added, working mod 7 ** - *********************************************************************** - */ - -/* - *********************************************************************** - ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** - ** ** - ** License to copy and use this software is granted provided that ** - ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** - ** Digest Algorithm" in all material mentioning or referencing this ** - ** software or this function. ** - ** ** - ** License is also granted to make and use derivative works ** - ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** - ** material mentioning or referencing the derived work. ** - ** ** - ** RSA Data Security, Inc. makes no representations concerning ** - ** either the merchantability of this software or the suitability ** - ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** - ** ** - ** These notices must be retained in any copies of any part of this ** - ** documentation and/or software. ** - *********************************************************************** - */ - -#ifndef MD5_H -#define MD5_H - -/* Data structure for MD5 (Message-Digest) computation */ -typedef struct { - u32_t i[2]; /* number of _bits_ handled mod 2^64 */ - u32_t buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after MD5Final call */ -} MD5_CTX; - -void MD5Init ( MD5_CTX *mdContext); -void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); -void MD5Final ( unsigned char hash[], MD5_CTX *mdContext); - -#endif /* MD5_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/pap.c b/user/mpy/lib/lwip/src/netif/ppp/pap.c deleted file mode 100644 index 5fb9f88..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/pap.c +++ /dev/null @@ -1,628 +0,0 @@ -/***************************************************************************** -* pap.c - Network Password Authentication Protocol program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-12 Guy Lancaster , Global Election Systems Inc. -* Original. -*****************************************************************************/ -/* - * upap.c - User/Password Authentication Protocol. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "auth.h" -#include "pap.h" - -#include - -#if 0 /* UNUSED */ -static bool hide_password = 1; - -/* - * Command-line options. - */ -static option_t pap_option_list[] = { - { "hide-password", o_bool, &hide_password, - "Don't output passwords to log", 1 }, - { "show-password", o_bool, &hide_password, - "Show password string in debug log messages", 0 }, - { "pap-restart", o_int, &upap[0].us_timeouttime, - "Set retransmit timeout for PAP" }, - { "pap-max-authreq", o_int, &upap[0].us_maxtransmits, - "Set max number of transmissions for auth-reqs" }, - { "pap-timeout", o_int, &upap[0].us_reqtimeout, - "Set time limit for peer PAP authentication" }, - { NULL } -}; -#endif - -/* - * Protocol entry points. - */ -static void upap_init (int); -static void upap_lowerup (int); -static void upap_lowerdown (int); -static void upap_input (int, u_char *, int); -static void upap_protrej (int); -#if PPP_ADDITIONAL_CALLBACKS -static int upap_printpkt (u_char *, int, void (*)(void *, char *, ...), void *); -#endif /* PPP_ADDITIONAL_CALLBACKS */ - -struct protent pap_protent = { - PPP_PAP, - upap_init, - upap_input, - upap_protrej, - upap_lowerup, - upap_lowerdown, - NULL, - NULL, -#if PPP_ADDITIONAL_CALLBACKS - upap_printpkt, - NULL, -#endif /* PPP_ADDITIONAL_CALLBACKS */ - 1, - "PAP", -#if PPP_ADDITIONAL_CALLBACKS - NULL, - NULL, - NULL -#endif /* PPP_ADDITIONAL_CALLBACKS */ -}; - -upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */ - -static void upap_timeout (void *); -static void upap_reqtimeout(void *); -static void upap_rauthreq (upap_state *, u_char *, u_char, int); -static void upap_rauthack (upap_state *, u_char *, int, int); -static void upap_rauthnak (upap_state *, u_char *, int, int); -static void upap_sauthreq (upap_state *); -static void upap_sresp (upap_state *, u_char, u_char, char *, int); - - -/* - * upap_init - Initialize a UPAP unit. - */ -static void -upap_init(int unit) -{ - upap_state *u = &upap[unit]; - - UPAPDEBUG(LOG_INFO, ("upap_init: %d\n", unit)); - u->us_unit = unit; - u->us_user = NULL; - u->us_userlen = 0; - u->us_passwd = NULL; - u->us_passwdlen = 0; - u->us_clientstate = UPAPCS_INITIAL; - u->us_serverstate = UPAPSS_INITIAL; - u->us_id = 0; - u->us_timeouttime = UPAP_DEFTIMEOUT; - u->us_maxtransmits = 10; - u->us_reqtimeout = UPAP_DEFREQTIME; -} - -/* - * upap_authwithpeer - Authenticate us with our peer (start client). - * - * Set new state and send authenticate's. - */ -void -upap_authwithpeer(int unit, char *user, char *password) -{ - upap_state *u = &upap[unit]; - - UPAPDEBUG(LOG_INFO, ("upap_authwithpeer: %d user=%s password=%s s=%d\n", - unit, user, password, u->us_clientstate)); - - /* Save the username and password we're given */ - u->us_user = user; - u->us_userlen = (int)strlen(user); - u->us_passwd = password; - u->us_passwdlen = (int)strlen(password); - - u->us_transmits = 0; - - /* Lower layer up yet? */ - if (u->us_clientstate == UPAPCS_INITIAL || - u->us_clientstate == UPAPCS_PENDING) { - u->us_clientstate = UPAPCS_PENDING; - return; - } - - upap_sauthreq(u); /* Start protocol */ -} - - -/* - * upap_authpeer - Authenticate our peer (start server). - * - * Set new state. - */ -void -upap_authpeer(int unit) -{ - upap_state *u = &upap[unit]; - - /* Lower layer up yet? */ - if (u->us_serverstate == UPAPSS_INITIAL || - u->us_serverstate == UPAPSS_PENDING) { - u->us_serverstate = UPAPSS_PENDING; - return; - } - - u->us_serverstate = UPAPSS_LISTEN; - if (u->us_reqtimeout > 0) { - TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); - } -} - -/* - * upap_timeout - Retransmission timer for sending auth-reqs expired. - */ -static void -upap_timeout(void *arg) -{ - upap_state *u = (upap_state *) arg; - - UPAPDEBUG(LOG_INFO, ("upap_timeout: %d timeout %d expired s=%d\n", - u->us_unit, u->us_timeouttime, u->us_clientstate)); - - if (u->us_clientstate != UPAPCS_AUTHREQ) { - UPAPDEBUG(LOG_INFO, ("upap_timeout: not in AUTHREQ state!\n")); - return; - } - - if (u->us_transmits >= u->us_maxtransmits) { - /* give up in disgust */ - UPAPDEBUG(LOG_ERR, ("No response to PAP authenticate-requests\n")); - u->us_clientstate = UPAPCS_BADAUTH; - auth_withpeer_fail(u->us_unit, PPP_PAP); - return; - } - - upap_sauthreq(u); /* Send Authenticate-Request and set upap timeout*/ -} - - -/* - * upap_reqtimeout - Give up waiting for the peer to send an auth-req. - */ -static void -upap_reqtimeout(void *arg) -{ - upap_state *u = (upap_state *) arg; - - if (u->us_serverstate != UPAPSS_LISTEN) { - return; /* huh?? */ - } - - auth_peer_fail(u->us_unit, PPP_PAP); - u->us_serverstate = UPAPSS_BADAUTH; -} - - -/* - * upap_lowerup - The lower layer is up. - * - * Start authenticating if pending. - */ -static void -upap_lowerup(int unit) -{ - upap_state *u = &upap[unit]; - - UPAPDEBUG(LOG_INFO, ("upap_lowerup: init %d clientstate s=%d\n", unit, u->us_clientstate)); - - if (u->us_clientstate == UPAPCS_INITIAL) { - u->us_clientstate = UPAPCS_CLOSED; - } else if (u->us_clientstate == UPAPCS_PENDING) { - upap_sauthreq(u); /* send an auth-request */ - /* now client state is UPAPCS__AUTHREQ */ - } - - if (u->us_serverstate == UPAPSS_INITIAL) { - u->us_serverstate = UPAPSS_CLOSED; - } else if (u->us_serverstate == UPAPSS_PENDING) { - u->us_serverstate = UPAPSS_LISTEN; - if (u->us_reqtimeout > 0) { - TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); - } - } -} - - -/* - * upap_lowerdown - The lower layer is down. - * - * Cancel all timeouts. - */ -static void -upap_lowerdown(int unit) -{ - upap_state *u = &upap[unit]; - - UPAPDEBUG(LOG_INFO, ("upap_lowerdown: %d s=%d\n", unit, u->us_clientstate)); - - if (u->us_clientstate == UPAPCS_AUTHREQ) { /* Timeout pending? */ - UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ - } - if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0) { - UNTIMEOUT(upap_reqtimeout, u); - } - - u->us_clientstate = UPAPCS_INITIAL; - u->us_serverstate = UPAPSS_INITIAL; -} - - -/* - * upap_protrej - Peer doesn't speak this protocol. - * - * This shouldn't happen. In any case, pretend lower layer went down. - */ -static void -upap_protrej(int unit) -{ - upap_state *u = &upap[unit]; - - if (u->us_clientstate == UPAPCS_AUTHREQ) { - UPAPDEBUG(LOG_ERR, ("PAP authentication failed due to protocol-reject\n")); - auth_withpeer_fail(unit, PPP_PAP); - } - if (u->us_serverstate == UPAPSS_LISTEN) { - UPAPDEBUG(LOG_ERR, ("PAP authentication of peer failed (protocol-reject)\n")); - auth_peer_fail(unit, PPP_PAP); - } - upap_lowerdown(unit); -} - - -/* - * upap_input - Input UPAP packet. - */ -static void -upap_input(int unit, u_char *inpacket, int l) -{ - upap_state *u = &upap[unit]; - u_char *inp; - u_char code, id; - int len; - - /* - * Parse header (code, id and length). - * If packet too short, drop it. - */ - inp = inpacket; - if (l < (int)UPAP_HEADERLEN) { - UPAPDEBUG(LOG_INFO, ("pap_input: rcvd short header.\n")); - return; - } - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < (int)UPAP_HEADERLEN) { - UPAPDEBUG(LOG_INFO, ("pap_input: rcvd illegal length.\n")); - return; - } - if (len > l) { - UPAPDEBUG(LOG_INFO, ("pap_input: rcvd short packet.\n")); - return; - } - len -= UPAP_HEADERLEN; - - /* - * Action depends on code. - */ - switch (code) { - case UPAP_AUTHREQ: - upap_rauthreq(u, inp, id, len); - break; - - case UPAP_AUTHACK: - upap_rauthack(u, inp, id, len); - break; - - case UPAP_AUTHNAK: - upap_rauthnak(u, inp, id, len); - break; - - default: /* XXX Need code reject */ - UPAPDEBUG(LOG_INFO, ("pap_input: UNHANDLED default: code: %d, id: %d, len: %d.\n", code, id, len)); - break; - } -} - - -/* - * upap_rauth - Receive Authenticate. - */ -static void -upap_rauthreq(upap_state *u, u_char *inp, u_char id, int len) -{ - u_char ruserlen, rpasswdlen; - char *ruser, *rpasswd; - u_char retcode; - char *msg; - int msglen; - - UPAPDEBUG(LOG_INFO, ("pap_rauth: Rcvd id %d.\n", id)); - - if (u->us_serverstate < UPAPSS_LISTEN) { - return; - } - - /* - * If we receive a duplicate authenticate-request, we are - * supposed to return the same status as for the first request. - */ - if (u->us_serverstate == UPAPSS_OPEN) { - upap_sresp(u, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ - return; - } - if (u->us_serverstate == UPAPSS_BADAUTH) { - upap_sresp(u, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ - return; - } - - /* - * Parse user/passwd. - */ - if (len < (int)sizeof (u_char)) { - UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); - return; - } - GETCHAR(ruserlen, inp); - len -= sizeof (u_char) + ruserlen + sizeof (u_char); - if (len < 0) { - UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); - return; - } - ruser = (char *) inp; - INCPTR(ruserlen, inp); - GETCHAR(rpasswdlen, inp); - if (len < rpasswdlen) { - UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); - return; - } - rpasswd = (char *) inp; - - /* - * Check the username and password given. - */ - retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen); - /* lwip: currently retcode is always UPAP_AUTHACK */ - BZERO(rpasswd, rpasswdlen); - - upap_sresp(u, retcode, id, msg, msglen); - - if (retcode == UPAP_AUTHACK) { - u->us_serverstate = UPAPSS_OPEN; - auth_peer_success(u->us_unit, PPP_PAP, ruser, ruserlen); - } else { - u->us_serverstate = UPAPSS_BADAUTH; - auth_peer_fail(u->us_unit, PPP_PAP); - } - - if (u->us_reqtimeout > 0) { - UNTIMEOUT(upap_reqtimeout, u); - } -} - - -/* - * upap_rauthack - Receive Authenticate-Ack. - */ -static void -upap_rauthack(upap_state *u, u_char *inp, int id, int len) -{ - u_char msglen; - char *msg; - - LWIP_UNUSED_ARG(id); - - UPAPDEBUG(LOG_INFO, ("pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate)); - - if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ - UPAPDEBUG(LOG_INFO, ("pap_rauthack: us_clientstate != UPAPCS_AUTHREQ\n")); - return; - } - - /* - * Parse message. - */ - if (len < (int)sizeof (u_char)) { - UPAPDEBUG(LOG_INFO, ("pap_rauthack: ignoring missing msg-length.\n")); - } else { - GETCHAR(msglen, inp); - if (msglen > 0) { - len -= sizeof (u_char); - if (len < msglen) { - UPAPDEBUG(LOG_INFO, ("pap_rauthack: rcvd short packet.\n")); - return; - } - msg = (char *) inp; - PRINTMSG(msg, msglen); - } - } - UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ - u->us_clientstate = UPAPCS_OPEN; - - auth_withpeer_success(u->us_unit, PPP_PAP); -} - - -/* - * upap_rauthnak - Receive Authenticate-Nak. - */ -static void -upap_rauthnak(upap_state *u, u_char *inp, int id, int len) -{ - u_char msglen; - char *msg; - - LWIP_UNUSED_ARG(id); - - UPAPDEBUG(LOG_INFO, ("pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate)); - - if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ - return; - } - - /* - * Parse message. - */ - if (len < sizeof (u_char)) { - UPAPDEBUG(LOG_INFO, ("pap_rauthnak: ignoring missing msg-length.\n")); - } else { - GETCHAR(msglen, inp); - if(msglen > 0) { - len -= sizeof (u_char); - if (len < msglen) { - UPAPDEBUG(LOG_INFO, ("pap_rauthnak: rcvd short packet.\n")); - return; - } - msg = (char *) inp; - PRINTMSG(msg, msglen); - } - } - - u->us_clientstate = UPAPCS_BADAUTH; - - UPAPDEBUG(LOG_ERR, ("PAP authentication failed\n")); - auth_withpeer_fail(u->us_unit, PPP_PAP); -} - - -/* - * upap_sauthreq - Send an Authenticate-Request. - */ -static void -upap_sauthreq(upap_state *u) -{ - u_char *outp; - int outlen; - - outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) - + u->us_userlen + u->us_passwdlen; - outp = outpacket_buf[u->us_unit]; - - MAKEHEADER(outp, PPP_PAP); - - PUTCHAR(UPAP_AUTHREQ, outp); - PUTCHAR(++u->us_id, outp); - PUTSHORT(outlen, outp); - PUTCHAR(u->us_userlen, outp); - BCOPY(u->us_user, outp, u->us_userlen); - INCPTR(u->us_userlen, outp); - PUTCHAR(u->us_passwdlen, outp); - BCOPY(u->us_passwd, outp, u->us_passwdlen); - - pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); - - UPAPDEBUG(LOG_INFO, ("pap_sauth: Sent id %d\n", u->us_id)); - - TIMEOUT(upap_timeout, u, u->us_timeouttime); - ++u->us_transmits; - u->us_clientstate = UPAPCS_AUTHREQ; -} - - -/* - * upap_sresp - Send a response (ack or nak). - */ -static void -upap_sresp(upap_state *u, u_char code, u_char id, char *msg, int msglen) -{ - u_char *outp; - int outlen; - - outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen; - outp = outpacket_buf[u->us_unit]; - MAKEHEADER(outp, PPP_PAP); - - PUTCHAR(code, outp); - PUTCHAR(id, outp); - PUTSHORT(outlen, outp); - PUTCHAR(msglen, outp); - BCOPY(msg, outp, msglen); - pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); - - UPAPDEBUG(LOG_INFO, ("pap_sresp: Sent code %d, id %d s=%d\n", code, id, u->us_clientstate)); -} - -#if PPP_ADDITIONAL_CALLBACKS -static char *upap_codenames[] = { - "AuthReq", "AuthAck", "AuthNak" -}; - -/* - * upap_printpkt - print the contents of a PAP packet. - */ -static int upap_printpkt( - u_char *p, - int plen, - void (*printer) (void *, char *, ...), - void *arg -) -{ - LWIP_UNUSED_ARG(p); - LWIP_UNUSED_ARG(plen); - LWIP_UNUSED_ARG(printer); - LWIP_UNUSED_ARG(arg); - return 0; -} -#endif /* PPP_ADDITIONAL_CALLBACKS */ - -#endif /* PAP_SUPPORT */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/pap.h b/user/mpy/lib/lwip/src/netif/ppp/pap.h deleted file mode 100644 index c99a204..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/pap.h +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************** -* pap.h - PPP Password Authentication Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-12-04 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ -/* - * upap.h - User/Password Authentication Protocol definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef PAP_H -#define PAP_H - -#if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -/* - * Packet header = Code, id, length. - */ -#define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) - - -/* - * UPAP codes. - */ -#define UPAP_AUTHREQ 1 /* Authenticate-Request */ -#define UPAP_AUTHACK 2 /* Authenticate-Ack */ -#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ - -/* - * Each interface is described by upap structure. - */ -typedef struct upap_state { - int us_unit; /* Interface unit number */ - const char *us_user; /* User */ - int us_userlen; /* User length */ - const char *us_passwd; /* Password */ - int us_passwdlen; /* Password length */ - int us_clientstate; /* Client state */ - int us_serverstate; /* Server state */ - u_char us_id; /* Current id */ - int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */ - int us_transmits; /* Number of auth-reqs sent */ - int us_maxtransmits; /* Maximum number of auth-reqs to send */ - int us_reqtimeout; /* Time to wait for auth-req from peer */ -} upap_state; - -/* - * Client states. - */ -#define UPAPCS_INITIAL 0 /* Connection down */ -#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ -#define UPAPCS_OPEN 4 /* We've received an Ack */ -#define UPAPCS_BADAUTH 5 /* We've received a Nak */ - -/* - * Server states. - */ -#define UPAPSS_INITIAL 0 /* Connection down */ -#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ -#define UPAPSS_OPEN 4 /* We've sent an Ack */ -#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ - - -extern upap_state upap[]; - -void upap_authwithpeer (int, char *, char *); -void upap_authpeer (int); - -extern struct protent pap_protent; - -#endif /* PAP_SUPPORT */ - -#endif /* PAP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp.c b/user/mpy/lib/lwip/src/netif/ppp/ppp.c deleted file mode 100644 index 8e8fae9..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/ppp.c +++ /dev/null @@ -1,2045 +0,0 @@ -/***************************************************************************** -* ppp.c - Network Point to Point Protocol program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original. -*****************************************************************************/ - -/* - * ppp_defs.h - PPP definitions. - * - * if_pppvar.h - private structures and declarations for PPP. - * - * Copyright (c) 1994 The Australian National University. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation is hereby granted, provided that the above copyright - * notice appears in all copies. This software is provided without any - * warranty, express or implied. The Australian National University - * makes no representations about the suitability of this software for - * any purpose. - * - * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, - * OR MODIFICATIONS. - */ - -/* - * if_ppp.h - Point-to-Point Protocol definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "lwip/ip.h" /* for ip_input() */ - -#include "pppdebug.h" - -#include "randm.h" -#include "fsm.h" -#if PAP_SUPPORT -#include "pap.h" -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT -#include "chap.h" -#endif /* CHAP_SUPPORT */ -#include "ipcp.h" -#include "lcp.h" -#include "magic.h" -#include "auth.h" -#if VJ_SUPPORT -#include "vj.h" -#endif /* VJ_SUPPORT */ -#if PPPOE_SUPPORT -#include "netif/ppp_oe.h" -#endif /* PPPOE_SUPPORT */ - -#include "lwip/tcpip.h" -#include "lwip/api.h" -#include "lwip/snmp.h" - -#include - -/*************************/ -/*** LOCAL DEFINITIONS ***/ -/*************************/ - -/** PPP_INPROC_MULTITHREADED==1 call pppInput using tcpip_callback(). - * Set this to 0 if pppInProc is called inside tcpip_thread or with NO_SYS==1. - * Default is 1 for NO_SYS==0 (multithreaded) and 0 for NO_SYS==1 (single-threaded). - */ -#ifndef PPP_INPROC_MULTITHREADED -#define PPP_INPROC_MULTITHREADED (NO_SYS==0) -#endif - -/** PPP_INPROC_OWNTHREAD==1: start a dedicated RX thread per PPP session. - * Default is 0: call pppos_input() for received raw characters, charcater - * reception is up to the port */ -#ifndef PPP_INPROC_OWNTHREAD -#define PPP_INPROC_OWNTHREAD PPP_INPROC_MULTITHREADED -#endif - -#if PPP_INPROC_OWNTHREAD && !PPP_INPROC_MULTITHREADED - #error "PPP_INPROC_OWNTHREAD needs PPP_INPROC_MULTITHREADED==1" -#endif - -/* - * The basic PPP frame. - */ -#define PPP_ADDRESS(p) (((u_char *)(p))[0]) -#define PPP_CONTROL(p) (((u_char *)(p))[1]) -#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3]) - -/* PPP packet parser states. Current state indicates operation yet to be - * completed. */ -typedef enum { - PDIDLE = 0, /* Idle state - waiting. */ - PDSTART, /* Process start flag. */ - PDADDRESS, /* Process address field. */ - PDCONTROL, /* Process control field. */ - PDPROTOCOL1, /* Process protocol field 1. */ - PDPROTOCOL2, /* Process protocol field 2. */ - PDDATA /* Process data byte. */ -} PPPDevStates; - -#define ESCAPE_P(accm, c) ((accm)[(c) >> 3] & pppACCMMask[c & 0x07]) - -/************************/ -/*** LOCAL DATA TYPES ***/ -/************************/ - -/** RX buffer size: this may be configured smaller! */ -#ifndef PPPOS_RX_BUFSIZE -#define PPPOS_RX_BUFSIZE (PPP_MRU + PPP_HDRLEN) -#endif - -typedef struct PPPControlRx_s { - /** unit number / ppp descriptor */ - int pd; - /** the rx file descriptor */ - sio_fd_t fd; - /** receive buffer - encoded data is stored here */ -#if PPP_INPROC_OWNTHREAD - u_char rxbuf[PPPOS_RX_BUFSIZE]; -#endif /* PPP_INPROC_OWNTHREAD */ - - /* The input packet. */ - struct pbuf *inHead, *inTail; - -#if PPPOS_SUPPORT - u16_t inProtocol; /* The input protocol code. */ - u16_t inFCS; /* Input Frame Check Sequence value. */ -#endif /* PPPOS_SUPPORT */ - PPPDevStates inState; /* The input process state. */ - char inEscaped; /* Escape next character. */ - ext_accm inACCM; /* Async-Ctl-Char-Map for input. */ -} PPPControlRx; - -/* - * PPP interface control block. - */ -typedef struct PPPControl_s { - PPPControlRx rx; - char openFlag; /* True when in use. */ -#if PPPOE_SUPPORT - struct netif *ethif; - struct pppoe_softc *pppoe_sc; -#endif /* PPPOE_SUPPORT */ - int if_up; /* True when the interface is up. */ - int errCode; /* Code indicating why interface is down. */ -#if PPPOS_SUPPORT - sio_fd_t fd; /* File device ID of port. */ -#endif /* PPPOS_SUPPORT */ - u16_t mtu; /* Peer's mru */ - int pcomp; /* Does peer accept protocol compression? */ - int accomp; /* Does peer accept addr/ctl compression? */ - u_long lastXMit; /* Time of last transmission. */ - ext_accm outACCM; /* Async-Ctl-Char-Map for output. */ -#if PPPOS_SUPPORT && VJ_SUPPORT - int vjEnabled; /* Flag indicating VJ compression enabled. */ - struct vjcompress vjComp; /* Van Jacobson compression header. */ -#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ - - struct netif netif; - - struct ppp_addrs addrs; - - void (*linkStatusCB)(void *ctx, int errCode, void *arg); - void *linkStatusCtx; - -} PPPControl; - - -/* - * Ioctl definitions. - */ - -struct npioctl { - int protocol; /* PPP procotol, e.g. PPP_IP */ - enum NPmode mode; -}; - - - -/***********************************/ -/*** LOCAL FUNCTION DECLARATIONS ***/ -/***********************************/ -#if PPPOS_SUPPORT -#if PPP_INPROC_OWNTHREAD -static void pppInputThread(void *arg); -#endif /* PPP_INPROC_OWNTHREAD */ -static void pppDrop(PPPControlRx *pcrx); -static void pppInProc(PPPControlRx *pcrx, u_char *s, int l); -static void pppFreeCurrentInputPacket(PPPControlRx *pcrx); -#endif /* PPPOS_SUPPORT */ - - -/******************************/ -/*** PUBLIC DATA STRUCTURES ***/ -/******************************/ -u_long subnetMask; - -static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */ - -/* - * PPP Data Link Layer "protocol" table. - * One entry per supported protocol. - * The last entry must be NULL. - */ -struct protent *ppp_protocols[] = { - &lcp_protent, -#if PAP_SUPPORT - &pap_protent, -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT - &chap_protent, -#endif /* CHAP_SUPPORT */ -#if CBCP_SUPPORT - &cbcp_protent, -#endif /* CBCP_SUPPORT */ - &ipcp_protent, -#if CCP_SUPPORT - &ccp_protent, -#endif /* CCP_SUPPORT */ - NULL -}; - - -/* - * Buffers for outgoing packets. This must be accessed only from the appropriate - * PPP task so that it doesn't need to be protected to avoid collisions. - */ -u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; - - -/*****************************/ -/*** LOCAL DATA STRUCTURES ***/ -/*****************************/ - -#if PPPOS_SUPPORT -/* - * FCS lookup table as calculated by genfcstab. - * @todo: smaller, slower implementation for lower memory footprint? - */ -static const u_short fcstab[256] = { - 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, - 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, - 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, - 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, - 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, - 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, - 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, - 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, - 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, - 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, - 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, - 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, - 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, - 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, - 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, - 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, - 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, - 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, - 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, - 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, - 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, - 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, - 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, - 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, - 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, - 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, - 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, - 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, - 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, - 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, - 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, - 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 -}; - -/* PPP's Asynchronous-Control-Character-Map. The mask array is used - * to select the specific bit for a character. */ -static u_char pppACCMMask[] = { - 0x01, - 0x02, - 0x04, - 0x08, - 0x10, - 0x20, - 0x40, - 0x80 -}; - -#if PPP_INPROC_OWNTHREAD -/** Wake up the task blocked in reading from serial line (if any) */ -static void -pppRecvWakeup(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppRecvWakeup: unit %d\n", pd)); - if (pppControl[pd].openFlag != 0) { - sio_read_abort(pppControl[pd].fd); - } -} -#endif /* PPP_INPROC_OWNTHREAD */ -#endif /* PPPOS_SUPPORT */ - -void -pppLinkTerminated(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: unit %d\n", pd)); - -#if PPPOE_SUPPORT - if (pppControl[pd].ethif) { - pppoe_disconnect(pppControl[pd].pppoe_sc); - } else -#endif /* PPPOE_SUPPORT */ - { -#if PPPOS_SUPPORT - PPPControl* pc; -#if PPP_INPROC_OWNTHREAD - pppRecvWakeup(pd); -#endif /* PPP_INPROC_OWNTHREAD */ - pc = &pppControl[pd]; - - PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); - if (pc->linkStatusCB) { - pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, NULL); - } - - pc->openFlag = 0;/**/ -#endif /* PPPOS_SUPPORT */ - } - PPPDEBUG(LOG_DEBUG, ("pppLinkTerminated: finished.\n")); -} - -void -pppLinkDown(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppLinkDown: unit %d\n", pd)); - -#if PPPOE_SUPPORT - if (pppControl[pd].ethif) { - pppoe_disconnect(pppControl[pd].pppoe_sc); - } else -#endif /* PPPOE_SUPPORT */ - { -#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD - pppRecvWakeup(pd); -#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD*/ - } -} - -/** Initiate LCP open request */ -static void -pppStart(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppStart: unit %d\n", pd)); - lcp_lowerup(pd); - lcp_open(pd); /* Start protocol */ - PPPDEBUG(LOG_DEBUG, ("pppStart: finished\n")); -} - -/** LCP close request */ -static void -pppStop(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppStop: unit %d\n", pd)); - lcp_close(pd, "User request"); -} - -/** Called when carrier/link is lost */ -static void -pppHup(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppHupCB: unit %d\n", pd)); - lcp_lowerdown(pd); - link_terminated(pd); -} - -/***********************************/ -/*** PUBLIC FUNCTION DEFINITIONS ***/ -/***********************************/ -/* Initialize the PPP subsystem. */ - -struct ppp_settings ppp_settings; - -void -pppInit(void) -{ - struct protent *protp; - int i, j; - - memset(&ppp_settings, 0, sizeof(ppp_settings)); - ppp_settings.usepeerdns = 1; - pppSetAuth(PPPAUTHTYPE_NONE, NULL, NULL); - - magicInit(); - - subnetMask = PP_HTONL(0xffffff00UL); - - for (i = 0; i < NUM_PPP; i++) { - /* Initialize each protocol to the standard option set. */ - for (j = 0; (protp = ppp_protocols[j]) != NULL; ++j) { - (*protp->init)(i); - } - } -} - -void -pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) -{ - switch(authType) { - case PPPAUTHTYPE_NONE: - default: -#ifdef LWIP_PPP_STRICT_PAP_REJECT - ppp_settings.refuse_pap = 1; -#else /* LWIP_PPP_STRICT_PAP_REJECT */ - /* some providers request pap and accept an empty login/pw */ - ppp_settings.refuse_pap = 0; -#endif /* LWIP_PPP_STRICT_PAP_REJECT */ - ppp_settings.refuse_chap = 1; - break; - - case PPPAUTHTYPE_ANY: - /* Warning: Using PPPAUTHTYPE_ANY might have security consequences. - * RFC 1994 says: - * - * In practice, within or associated with each PPP server, there is a - * database which associates "user" names with authentication - * information ("secrets"). It is not anticipated that a particular - * named user would be authenticated by multiple methods. This would - * make the user vulnerable to attacks which negotiate the least secure - * method from among a set (such as PAP rather than CHAP). If the same - * secret was used, PAP would reveal the secret to be used later with - * CHAP. - * - * Instead, for each user name there should be an indication of exactly - * one method used to authenticate that user name. If a user needs to - * make use of different authentication methods under different - * circumstances, then distinct user names SHOULD be employed, each of - * which identifies exactly one authentication method. - * - */ - ppp_settings.refuse_pap = 0; - ppp_settings.refuse_chap = 0; - break; - - case PPPAUTHTYPE_PAP: - ppp_settings.refuse_pap = 0; - ppp_settings.refuse_chap = 1; - break; - - case PPPAUTHTYPE_CHAP: - ppp_settings.refuse_pap = 1; - ppp_settings.refuse_chap = 0; - break; - } - - if(user) { - strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1); - ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0'; - } else { - ppp_settings.user[0] = '\0'; - } - - if(passwd) { - strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1); - ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0'; - } else { - ppp_settings.passwd[0] = '\0'; - } -} - -#if PPPOS_SUPPORT -/** Open a new PPP connection using the given I/O device. - * This initializes the PPP control block but does not - * attempt to negotiate the LCP session. If this port - * connects to a modem, the modem connection must be - * established before calling this. - * Return a new PPP connection descriptor on success or - * an error code (negative) on failure. - * - * pppOpen() is directly defined to this function. - */ -int -pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx) -{ - PPPControl *pc; - int pd; - - if (linkStatusCB == NULL) { - /* PPP is single-threaded: without a callback, - * there is no way to know when the link is up. */ - return PPPERR_PARAM; - } - - /* Find a free PPP session descriptor. */ - for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++); - - if (pd >= NUM_PPP) { - pd = PPPERR_OPEN; - } else { - pc = &pppControl[pd]; - /* input pbuf left over from last session? */ - pppFreeCurrentInputPacket(&pc->rx); - /* @todo: is this correct or do I overwrite something? */ - memset(pc, 0, sizeof(PPPControl)); - pc->rx.pd = pd; - pc->rx.fd = fd; - - pc->openFlag = 1; - pc->fd = fd; - -#if VJ_SUPPORT - vj_compress_init(&pc->vjComp); -#endif /* VJ_SUPPORT */ - - /* - * Default the in and out accm so that escape and flag characters - * are always escaped. - */ - pc->rx.inACCM[15] = 0x60; /* no need to protect since RX is not running */ - pc->outACCM[15] = 0x60; - - pc->linkStatusCB = linkStatusCB; - pc->linkStatusCtx = linkStatusCtx; - - /* - * Start the connection and handle incoming events (packet or timeout). - */ - PPPDEBUG(LOG_INFO, ("pppOverSerialOpen: unit %d: Connecting\n", pd)); - pppStart(pd); -#if PPP_INPROC_OWNTHREAD - sys_thread_new(PPP_THREAD_NAME, pppInputThread, (void*)&pc->rx, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); -#endif /* PPP_INPROC_OWNTHREAD */ - } - - return pd; -} -#endif /* PPPOS_SUPPORT */ - -#if PPPOE_SUPPORT -static void pppOverEthernetLinkStatusCB(int pd, int up); - -void -pppOverEthernetClose(int pd) -{ - PPPControl* pc = &pppControl[pd]; - - /* *TJL* There's no lcp_deinit */ - lcp_close(pd, NULL); - - pppoe_destroy(&pc->netif); -} - -int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, - pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx) -{ - PPPControl *pc; - int pd; - - LWIP_UNUSED_ARG(service_name); - LWIP_UNUSED_ARG(concentrator_name); - - if (linkStatusCB == NULL) { - /* PPP is single-threaded: without a callback, - * there is no way to know when the link is up. */ - return PPPERR_PARAM; - } - - /* Find a free PPP session descriptor. Critical region? */ - for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++); - if (pd >= NUM_PPP) { - pd = PPPERR_OPEN; - } else { - pc = &pppControl[pd]; - memset(pc, 0, sizeof(PPPControl)); - pc->openFlag = 1; - pc->ethif = ethif; - - pc->linkStatusCB = linkStatusCB; - pc->linkStatusCtx = linkStatusCtx; - - lcp_wantoptions[pd].mru = PPPOE_MAXMTU; - lcp_wantoptions[pd].neg_asyncmap = 0; - lcp_wantoptions[pd].neg_pcompression = 0; - lcp_wantoptions[pd].neg_accompression = 0; - - lcp_allowoptions[pd].mru = PPPOE_MAXMTU; - lcp_allowoptions[pd].neg_asyncmap = 0; - lcp_allowoptions[pd].neg_pcompression = 0; - lcp_allowoptions[pd].neg_accompression = 0; - - if(pppoe_create(ethif, pd, pppOverEthernetLinkStatusCB, &pc->pppoe_sc) != ERR_OK) { - pc->openFlag = 0; - return PPPERR_OPEN; - } - - pppoe_connect(pc->pppoe_sc); - } - - return pd; -} -#endif /* PPPOE_SUPPORT */ - - -/* Close a PPP connection and release the descriptor. - * Any outstanding packets in the queues are dropped. - * Return 0 on success, an error code on failure. */ -int -pppClose(int pd) -{ - PPPControl *pc = &pppControl[pd]; - int st = 0; - - PPPDEBUG(LOG_DEBUG, ("pppClose() called\n")); - - /* Disconnect */ -#if PPPOE_SUPPORT - if(pc->ethif) { - PPPDEBUG(LOG_DEBUG, ("pppClose: unit %d kill_link -> pppStop\n", pd)); - pc->errCode = PPPERR_USER; - /* This will leave us at PHASE_DEAD. */ - pppStop(pd); - } else -#endif /* PPPOE_SUPPORT */ - { -#if PPPOS_SUPPORT - PPPDEBUG(LOG_DEBUG, ("pppClose: unit %d kill_link -> pppStop\n", pd)); - pc->errCode = PPPERR_USER; - /* This will leave us at PHASE_DEAD. */ - pppStop(pd); -#if PPP_INPROC_OWNTHREAD - pppRecvWakeup(pd); -#endif /* PPP_INPROC_OWNTHREAD */ -#endif /* PPPOS_SUPPORT */ - } - - return st; -} - -/* This function is called when carrier is lost on the PPP channel. */ -void -pppSigHUP(int pd) -{ - PPPDEBUG(LOG_DEBUG, ("pppSigHUP: unit %d sig_hup -> pppHupCB\n", pd)); - pppHup(pd); -} - -#if PPPOS_SUPPORT -static void -nPut(PPPControl *pc, struct pbuf *nb) -{ - struct pbuf *b; - int c; - - for(b = nb; b != NULL; b = b->next) { - if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) { - PPPDEBUG(LOG_WARNING, - ("PPP nPut: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (size_t)pc->fd, b->len, c, c)); - LINK_STATS_INC(link.err); - pc->lastXMit = 0; /* prepend PPP_FLAG to next packet */ - snmp_inc_ifoutdiscards(&pc->netif); - pbuf_free(nb); - return; - } - } - - snmp_add_ifoutoctets(&pc->netif, nb->tot_len); - snmp_inc_ifoutucastpkts(&pc->netif); - pbuf_free(nb); - LINK_STATS_INC(link.xmit); -} - -/* - * pppAppend - append given character to end of given pbuf. If outACCM - * is not NULL and the character needs to be escaped, do so. - * If pbuf is full, append another. - * Return the current pbuf. - */ -static struct pbuf * -pppAppend(u_char c, struct pbuf *nb, ext_accm *outACCM) -{ - struct pbuf *tb = nb; - - /* Make sure there is room for the character and an escape code. - * Sure we don't quite fill the buffer if the character doesn't - * get escaped but is one character worth complicating this? */ - /* Note: We assume no packet header. */ - if (nb && (PBUF_POOL_BUFSIZE - nb->len) < 2) { - tb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); - if (tb) { - nb->next = tb; - } else { - LINK_STATS_INC(link.memerr); - } - nb = tb; - } - - if (nb) { - if (outACCM && ESCAPE_P(*outACCM, c)) { - *((u_char*)nb->payload + nb->len++) = PPP_ESCAPE; - *((u_char*)nb->payload + nb->len++) = c ^ PPP_TRANS; - } else { - *((u_char*)nb->payload + nb->len++) = c; - } - } - - return tb; -} -#endif /* PPPOS_SUPPORT */ - -#if PPPOE_SUPPORT -static err_t -pppifOutputOverEthernet(int pd, struct pbuf *p) -{ - PPPControl *pc = &pppControl[pd]; - struct pbuf *pb; - u_short protocol = PPP_IP; - int i=0; - u16_t tot_len; - - /* @todo: try to use pbuf_header() here! */ - pb = pbuf_alloc(PBUF_LINK, PPPOE_HDRLEN + sizeof(protocol), PBUF_RAM); - if(!pb) { - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.proterr); - snmp_inc_ifoutdiscards(&pc->netif); - return ERR_MEM; - } - - pbuf_header(pb, -(s16_t)PPPOE_HDRLEN); - - pc->lastXMit = sys_jiffies(); - - if (!pc->pcomp || protocol > 0xFF) { - *((u_char*)pb->payload + i++) = (protocol >> 8) & 0xFF; - } - *((u_char*)pb->payload + i) = protocol & 0xFF; - - pbuf_chain(pb, p); - tot_len = pb->tot_len; - - if(pppoe_xmit(pc->pppoe_sc, pb) != ERR_OK) { - LINK_STATS_INC(link.err); - snmp_inc_ifoutdiscards(&pc->netif); - return PPPERR_DEVICE; - } - - snmp_add_ifoutoctets(&pc->netif, tot_len); - snmp_inc_ifoutucastpkts(&pc->netif); - LINK_STATS_INC(link.xmit); - return ERR_OK; -} -#endif /* PPPOE_SUPPORT */ - -/* Send a packet on the given connection. */ -static err_t -pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) -{ - int pd = (int)(size_t)netif->state; - PPPControl *pc = &pppControl[pd]; -#if PPPOS_SUPPORT - u_short protocol = PPP_IP; - u_int fcsOut = PPP_INITFCS; - struct pbuf *headMB = NULL, *tailMB = NULL, *p; - u_char c; -#endif /* PPPOS_SUPPORT */ - - LWIP_UNUSED_ARG(ipaddr); - - /* Validate parameters. */ - /* We let any protocol value go through - it can't hurt us - * and the peer will just drop it if it's not accepting it. */ - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag || !pb) { - PPPDEBUG(LOG_WARNING, ("pppifOutput[%d]: bad parms prot=%d pb=%p\n", - pd, PPP_IP, pb)); - LINK_STATS_INC(link.opterr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(netif); - return ERR_ARG; - } - - /* Check that the link is up. */ - if (lcp_phase[pd] == PHASE_DEAD) { - PPPDEBUG(LOG_ERR, ("pppifOutput[%d]: link not up\n", pd)); - LINK_STATS_INC(link.rterr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(netif); - return ERR_RTE; - } - -#if PPPOE_SUPPORT - if(pc->ethif) { - return pppifOutputOverEthernet(pd, pb); - } -#endif /* PPPOE_SUPPORT */ - -#if PPPOS_SUPPORT - /* Grab an output buffer. */ - headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); - if (headMB == NULL) { - PPPDEBUG(LOG_WARNING, ("pppifOutput[%d]: first alloc fail\n", pd)); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(netif); - return ERR_MEM; - } - -#if VJ_SUPPORT - /* - * Attempt Van Jacobson header compression if VJ is configured and - * this is an IP packet. - */ - if (protocol == PPP_IP && pc->vjEnabled) { - switch (vj_compress_tcp(&pc->vjComp, pb)) { - case TYPE_IP: - /* No change... - protocol = PPP_IP_PROTOCOL; */ - break; - case TYPE_COMPRESSED_TCP: - protocol = PPP_VJC_COMP; - break; - case TYPE_UNCOMPRESSED_TCP: - protocol = PPP_VJC_UNCOMP; - break; - default: - PPPDEBUG(LOG_WARNING, ("pppifOutput[%d]: bad IP packet\n", pd)); - LINK_STATS_INC(link.proterr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(netif); - pbuf_free(headMB); - return ERR_VAL; - } - } -#endif /* VJ_SUPPORT */ - - tailMB = headMB; - - /* Build the PPP header. */ - if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) { - tailMB = pppAppend(PPP_FLAG, tailMB, NULL); - } - - pc->lastXMit = sys_jiffies(); - if (!pc->accomp) { - fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS); - tailMB = pppAppend(PPP_ALLSTATIONS, tailMB, &pc->outACCM); - fcsOut = PPP_FCS(fcsOut, PPP_UI); - tailMB = pppAppend(PPP_UI, tailMB, &pc->outACCM); - } - if (!pc->pcomp || protocol > 0xFF) { - c = (protocol >> 8) & 0xFF; - fcsOut = PPP_FCS(fcsOut, c); - tailMB = pppAppend(c, tailMB, &pc->outACCM); - } - c = protocol & 0xFF; - fcsOut = PPP_FCS(fcsOut, c); - tailMB = pppAppend(c, tailMB, &pc->outACCM); - - /* Load packet. */ - for(p = pb; p; p = p->next) { - int n; - u_char *sPtr; - - sPtr = (u_char*)p->payload; - n = p->len; - while (n-- > 0) { - c = *sPtr++; - - /* Update FCS before checking for special characters. */ - fcsOut = PPP_FCS(fcsOut, c); - - /* Copy to output buffer escaping special characters. */ - tailMB = pppAppend(c, tailMB, &pc->outACCM); - } - } - - /* Add FCS and trailing flag. */ - c = ~fcsOut & 0xFF; - tailMB = pppAppend(c, tailMB, &pc->outACCM); - c = (~fcsOut >> 8) & 0xFF; - tailMB = pppAppend(c, tailMB, &pc->outACCM); - tailMB = pppAppend(PPP_FLAG, tailMB, NULL); - - /* If we failed to complete the packet, throw it away. */ - if (!tailMB) { - PPPDEBUG(LOG_WARNING, - ("pppifOutput[%d]: Alloc err - dropping proto=%d\n", - pd, protocol)); - pbuf_free(headMB); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(netif); - return ERR_MEM; - } - - /* Send it. */ - PPPDEBUG(LOG_INFO, ("pppifOutput[%d]: proto=0x%"X16_F"\n", pd, protocol)); - - nPut(pc, headMB); -#endif /* PPPOS_SUPPORT */ - - return ERR_OK; -} - -/* Get and set parameters for the given connection. - * Return 0 on success, an error code on failure. */ -int -pppIOCtl(int pd, int cmd, void *arg) -{ - PPPControl *pc = &pppControl[pd]; - int st = 0; - - if (pd < 0 || pd >= NUM_PPP) { - st = PPPERR_PARAM; - } else { - switch(cmd) { - case PPPCTLG_UPSTATUS: /* Get the PPP up status. */ - if (arg) { - *(int *)arg = (int)(pc->if_up); - } else { - st = PPPERR_PARAM; - } - break; - case PPPCTLS_ERRCODE: /* Set the PPP error code. */ - if (arg) { - pc->errCode = *(int *)arg; - } else { - st = PPPERR_PARAM; - } - break; - case PPPCTLG_ERRCODE: /* Get the PPP error code. */ - if (arg) { - *(int *)arg = (int)(pc->errCode); - } else { - st = PPPERR_PARAM; - } - break; -#if PPPOS_SUPPORT - case PPPCTLG_FD: /* Get the fd associated with the ppp */ - if (arg) { - *(sio_fd_t *)arg = pc->fd; - } else { - st = PPPERR_PARAM; - } - break; -#endif /* PPPOS_SUPPORT */ - default: - st = PPPERR_PARAM; - break; - } - } - - return st; -} - -/* - * Return the Maximum Transmission Unit for the given PPP connection. - */ -u_short -pppMTU(int pd) -{ - PPPControl *pc = &pppControl[pd]; - u_short st; - - /* Validate parameters. */ - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - } else { - st = pc->mtu; - } - - return st; -} - -#if PPPOE_SUPPORT -int -pppWriteOverEthernet(int pd, const u_char *s, int n) -{ - PPPControl *pc = &pppControl[pd]; - struct pbuf *pb; - - /* skip address & flags */ - s += 2; - n -= 2; - - LWIP_ASSERT("PPPOE_HDRLEN + n <= 0xffff", PPPOE_HDRLEN + n <= 0xffff); - pb = pbuf_alloc(PBUF_LINK, (u16_t)(PPPOE_HDRLEN + n), PBUF_RAM); - if(!pb) { - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.proterr); - snmp_inc_ifoutdiscards(&pc->netif); - return PPPERR_ALLOC; - } - - pbuf_header(pb, -(s16_t)PPPOE_HDRLEN); - - pc->lastXMit = sys_jiffies(); - - MEMCPY(pb->payload, s, n); - - if(pppoe_xmit(pc->pppoe_sc, pb) != ERR_OK) { - LINK_STATS_INC(link.err); - snmp_inc_ifoutdiscards(&pc->netif); - return PPPERR_DEVICE; - } - - snmp_add_ifoutoctets(&pc->netif, (u16_t)n); - snmp_inc_ifoutucastpkts(&pc->netif); - LINK_STATS_INC(link.xmit); - return PPPERR_NONE; -} -#endif /* PPPOE_SUPPORT */ - -/* - * Write n characters to a ppp link. - * RETURN: >= 0 Number of characters written - * -1 Failed to write to device - */ -int -pppWrite(int pd, const u_char *s, int n) -{ - PPPControl *pc = &pppControl[pd]; -#if PPPOS_SUPPORT - u_char c; - u_int fcsOut; - struct pbuf *headMB, *tailMB; -#endif /* PPPOS_SUPPORT */ - -#if PPPOE_SUPPORT - if(pc->ethif) { - return pppWriteOverEthernet(pd, s, n); - } -#endif /* PPPOE_SUPPORT */ - -#if PPPOS_SUPPORT - headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); - if (headMB == NULL) { - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.proterr); - snmp_inc_ifoutdiscards(&pc->netif); - return PPPERR_ALLOC; - } - - tailMB = headMB; - - /* If the link has been idle, we'll send a fresh flag character to - * flush any noise. */ - if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) { - tailMB = pppAppend(PPP_FLAG, tailMB, NULL); - } - pc->lastXMit = sys_jiffies(); - - fcsOut = PPP_INITFCS; - /* Load output buffer. */ - while (n-- > 0) { - c = *s++; - - /* Update FCS before checking for special characters. */ - fcsOut = PPP_FCS(fcsOut, c); - - /* Copy to output buffer escaping special characters. */ - tailMB = pppAppend(c, tailMB, &pc->outACCM); - } - - /* Add FCS and trailing flag. */ - c = ~fcsOut & 0xFF; - tailMB = pppAppend(c, tailMB, &pc->outACCM); - c = (~fcsOut >> 8) & 0xFF; - tailMB = pppAppend(c, tailMB, &pc->outACCM); - tailMB = pppAppend(PPP_FLAG, tailMB, NULL); - - /* If we failed to complete the packet, throw it away. - * Otherwise send it. */ - if (!tailMB) { - PPPDEBUG(LOG_WARNING, - ("pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->len)); - /*"pppWrite[%d]: Alloc err - dropping %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ - pbuf_free(headMB); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.proterr); - snmp_inc_ifoutdiscards(&pc->netif); - return PPPERR_ALLOC; - } - - PPPDEBUG(LOG_INFO, ("pppWrite[%d]: len=%d\n", pd, headMB->len)); - /* "pppWrite[%d]: %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ - nPut(pc, headMB); -#endif /* PPPOS_SUPPORT */ - - return PPPERR_NONE; -} - -/* - * ppp_send_config - configure the transmit characteristics of - * the ppp interface. - */ -void -ppp_send_config( int unit, u16_t mtu, u32_t asyncmap, int pcomp, int accomp) -{ - PPPControl *pc = &pppControl[unit]; - int i; - - pc->mtu = mtu; - pc->pcomp = pcomp; - pc->accomp = accomp; - - /* Load the ACCM bits for the 32 control codes. */ - for (i = 0; i < 32/8; i++) { - pc->outACCM[i] = (u_char)((asyncmap >> (8 * i)) & 0xFF); - } - PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]: outACCM=%X %X %X %X\n", - unit, - pc->outACCM[0], pc->outACCM[1], pc->outACCM[2], pc->outACCM[3])); -} - - -/* - * ppp_set_xaccm - set the extended transmit ACCM for the interface. - */ -void -ppp_set_xaccm(int unit, ext_accm *accm) -{ - SMEMCPY(pppControl[unit].outACCM, accm, sizeof(ext_accm)); - PPPDEBUG(LOG_INFO, ("ppp_set_xaccm[%d]: outACCM=%X %X %X %X\n", - unit, - pppControl[unit].outACCM[0], - pppControl[unit].outACCM[1], - pppControl[unit].outACCM[2], - pppControl[unit].outACCM[3])); -} - - -/* - * ppp_recv_config - configure the receive-side characteristics of - * the ppp interface. - */ -void -ppp_recv_config( int unit, int mru, u32_t asyncmap, int pcomp, int accomp) -{ - PPPControl *pc = &pppControl[unit]; - int i; - SYS_ARCH_DECL_PROTECT(lev); - - LWIP_UNUSED_ARG(accomp); - LWIP_UNUSED_ARG(pcomp); - LWIP_UNUSED_ARG(mru); - - /* Load the ACCM bits for the 32 control codes. */ - SYS_ARCH_PROTECT(lev); - for (i = 0; i < 32 / 8; i++) { - /* @todo: does this work? ext_accm has been modified from pppd! */ - pc->rx.inACCM[i] = (u_char)(asyncmap >> (i * 8)); - } - SYS_ARCH_UNPROTECT(lev); - PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]: inACCM=%X %X %X %X\n", - unit, - pc->rx.inACCM[0], pc->rx.inACCM[1], pc->rx.inACCM[2], pc->rx.inACCM[3])); -} - -#if 0 -/* - * ccp_test - ask kernel whether a given compression method - * is acceptable for use. Returns 1 if the method and parameters - * are OK, 0 if the method is known but the parameters are not OK - * (e.g. code size should be reduced), or -1 if the method is unknown. - */ -int -ccp_test( int unit, int opt_len, int for_transmit, u_char *opt_ptr) -{ - return 0; /* XXX Currently no compression. */ -} - -/* - * ccp_flags_set - inform kernel about the current state of CCP. - */ -void -ccp_flags_set(int unit, int isopen, int isup) -{ - /* XXX */ -} - -/* - * ccp_fatal_error - returns 1 if decompression was disabled as a - * result of an error detected after decompression of a packet, - * 0 otherwise. This is necessary because of patent nonsense. - */ -int -ccp_fatal_error(int unit) -{ - /* XXX */ - return 0; -} -#endif - -/* - * get_idle_time - return how long the link has been idle. - */ -int -get_idle_time(int u, struct ppp_idle *ip) -{ - /* XXX */ - LWIP_UNUSED_ARG(u); - LWIP_UNUSED_ARG(ip); - - return 0; -} - - -/* - * Return user specified netmask, modified by any mask we might determine - * for address `addr' (in network byte order). - * Here we scan through the system's list of interfaces, looking for - * any non-point-to-point interfaces which might appear to be on the same - * network as `addr'. If we find any, we OR in their netmask to the - * user-specified netmask. - */ -u32_t -GetMask(u32_t addr) -{ - u32_t mask, nmask; - - addr = htonl(addr); - if (IP_CLASSA(addr)) { /* determine network mask for address class */ - nmask = IP_CLASSA_NET; - } else if (IP_CLASSB(addr)) { - nmask = IP_CLASSB_NET; - } else { - nmask = IP_CLASSC_NET; - } - - /* class D nets are disallowed by bad_ip_adrs */ - mask = subnetMask | htonl(nmask); - - /* XXX - * Scan through the system's network interfaces. - * Get each netmask and OR them into our mask. - */ - - return mask; -} - -/* - * sifvjcomp - config tcp header compression - */ -int -sifvjcomp(int pd, int vjcomp, u8_t cidcomp, u8_t maxcid) -{ -#if PPPOS_SUPPORT && VJ_SUPPORT - PPPControl *pc = &pppControl[pd]; - - pc->vjEnabled = vjcomp; - pc->vjComp.compressSlot = cidcomp; - pc->vjComp.maxSlotIndex = maxcid; - PPPDEBUG(LOG_INFO, ("sifvjcomp: VJ compress enable=%d slot=%d max slot=%d\n", - vjcomp, cidcomp, maxcid)); -#else /* PPPOS_SUPPORT && VJ_SUPPORT */ - LWIP_UNUSED_ARG(pd); - LWIP_UNUSED_ARG(vjcomp); - LWIP_UNUSED_ARG(cidcomp); - LWIP_UNUSED_ARG(maxcid); -#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ - - return 0; -} - -/* - * pppifNetifInit - netif init callback - */ -static err_t -pppifNetifInit(struct netif *netif) -{ - netif->name[0] = 'p'; - netif->name[1] = 'p'; - netif->output = pppifOutput; - netif->mtu = pppMTU((int)(size_t)netif->state); - netif->flags = NETIF_FLAG_POINTTOPOINT | NETIF_FLAG_LINK_UP; -#if LWIP_NETIF_HOSTNAME - /* @todo: Initialize interface hostname */ - /* netif_set_hostname(netif, "lwip"); */ -#endif /* LWIP_NETIF_HOSTNAME */ - return ERR_OK; -} - - -/* - * sifup - Config the interface up and enable IP packets to pass. - */ -int -sifup(int pd) -{ - PPPControl *pc = &pppControl[pd]; - int st = 1; - - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); - } else { - netif_remove(&pc->netif); - if (netif_add(&pc->netif, &pc->addrs.our_ipaddr, &pc->addrs.netmask, - &pc->addrs.his_ipaddr, (void *)(size_t)pd, pppifNetifInit, ip_input)) { - netif_set_up(&pc->netif); - pc->if_up = 1; - pc->errCode = PPPERR_NONE; - - PPPDEBUG(LOG_DEBUG, ("sifup: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); - if (pc->linkStatusCB) { - pc->linkStatusCB(pc->linkStatusCtx, pc->errCode, &pc->addrs); - } - } else { - st = 0; - PPPDEBUG(LOG_ERR, ("sifup[%d]: netif_add failed\n", pd)); - } - } - - return st; -} - -/* - * sifnpmode - Set the mode for handling packets for a given NP. - */ -int -sifnpmode(int u, int proto, enum NPmode mode) -{ - LWIP_UNUSED_ARG(u); - LWIP_UNUSED_ARG(proto); - LWIP_UNUSED_ARG(mode); - return 0; -} - -/* - * sifdown - Config the interface down and disable IP. - */ -int -sifdown(int pd) -{ - PPPControl *pc = &pppControl[pd]; - int st = 1; - - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - PPPDEBUG(LOG_WARNING, ("sifdown[%d]: bad parms\n", pd)); - } else { - pc->if_up = 0; - /* make sure the netif status callback is called */ - netif_set_down(&pc->netif); - netif_remove(&pc->netif); - PPPDEBUG(LOG_DEBUG, ("sifdown: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); - if (pc->linkStatusCB) { - pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, NULL); - } - } - return st; -} - -/** - * sifaddr - Config the interface IP addresses and netmask. - * @param pd Interface unit ??? - * @param o Our IP address ??? - * @param h His IP address ??? - * @param m IP subnet mask ??? - * @param ns1 Primary DNS - * @param ns2 Secondary DNS - */ -int -sifaddr( int pd, u32_t o, u32_t h, u32_t m, u32_t ns1, u32_t ns2) -{ - PPPControl *pc = &pppControl[pd]; - int st = 1; - - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); - } else { - SMEMCPY(&pc->addrs.our_ipaddr, &o, sizeof(o)); - SMEMCPY(&pc->addrs.his_ipaddr, &h, sizeof(h)); - SMEMCPY(&pc->addrs.netmask, &m, sizeof(m)); - SMEMCPY(&pc->addrs.dns1, &ns1, sizeof(ns1)); - SMEMCPY(&pc->addrs.dns2, &ns2, sizeof(ns2)); - } - return st; -} - -/** - * cifaddr - Clear the interface IP addresses, and delete routes - * through the interface if possible. - * @param pd Interface unit ??? - * @param o Our IP address ??? - * @param h IP broadcast address ??? - */ -int -cifaddr( int pd, u32_t o, u32_t h) -{ - PPPControl *pc = &pppControl[pd]; - int st = 1; - - LWIP_UNUSED_ARG(o); - LWIP_UNUSED_ARG(h); - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); - } else { - IP4_ADDR(&pc->addrs.our_ipaddr, 0,0,0,0); - IP4_ADDR(&pc->addrs.his_ipaddr, 0,0,0,0); - IP4_ADDR(&pc->addrs.netmask, 255,255,255,0); - IP4_ADDR(&pc->addrs.dns1, 0,0,0,0); - IP4_ADDR(&pc->addrs.dns2, 0,0,0,0); - } - return st; -} - -/* - * sifdefaultroute - assign a default route through the address given. - */ -int -sifdefaultroute(int pd, u32_t l, u32_t g) -{ - PPPControl *pc = &pppControl[pd]; - int st = 1; - - LWIP_UNUSED_ARG(l); - LWIP_UNUSED_ARG(g); - - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); - } else { - netif_set_default(&pc->netif); - } - - /* TODO: check how PPP handled the netMask, previously not set by ipSetDefault */ - - return st; -} - -/* - * cifdefaultroute - delete a default route through the address given. - */ -int -cifdefaultroute(int pd, u32_t l, u32_t g) -{ - PPPControl *pc = &pppControl[pd]; - int st = 1; - - LWIP_UNUSED_ARG(l); - LWIP_UNUSED_ARG(g); - - if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { - st = 0; - PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); - } else { - netif_set_default(NULL); - } - - return st; -} - -/**********************************/ -/*** LOCAL FUNCTION DEFINITIONS ***/ -/**********************************/ - -#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD -/* The main PPP process function. This implements the state machine according - * to section 4 of RFC 1661: The Point-To-Point Protocol. */ -static void -pppInputThread(void *arg) -{ - int count; - PPPControlRx *pcrx = arg; - - while (lcp_phase[pcrx->pd] != PHASE_DEAD) { - count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE); - if(count > 0) { - pppInProc(pcrx, pcrx->rxbuf, count); - } else { - /* nothing received, give other tasks a chance to run */ - sys_msleep(1); - } - } -} -#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */ - -#if PPPOE_SUPPORT - -void -pppOverEthernetInitFailed(int pd) -{ - PPPControl* pc; - - pppHup(pd); - pppStop(pd); - - pc = &pppControl[pd]; - pppoe_destroy(&pc->netif); - pc->openFlag = 0; - - if(pc->linkStatusCB) { - pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, NULL); - } -} - -static void -pppOverEthernetLinkStatusCB(int pd, int up) -{ - if(up) { - PPPDEBUG(LOG_INFO, ("pppOverEthernetLinkStatusCB: unit %d: Connecting\n", pd)); - pppStart(pd); - } else { - pppOverEthernetInitFailed(pd); - } -} -#endif /* PPPOE_SUPPORT */ - -struct pbuf * -pppSingleBuf(struct pbuf *p) -{ - struct pbuf *q, *b; - u_char *pl; - - if(p->tot_len == p->len) { - return p; - } - - q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); - if(!q) { - PPPDEBUG(LOG_ERR, - ("pppSingleBuf: unable to alloc new buf (%d)\n", p->tot_len)); - return p; /* live dangerously */ - } - - for(b = p, pl = q->payload; b != NULL; b = b->next) { - MEMCPY(pl, b->payload, b->len); - pl += b->len; - } - - pbuf_free(p); - - return q; -} - -struct pppInputHeader { - int unit; - u16_t proto; -}; - -/* - * Pass the processed input packet to the appropriate handler. - * This function and all handlers run in the context of the tcpip_thread - */ -static void -pppInput(void *arg) -{ - struct pbuf *nb = (struct pbuf *)arg; - u16_t protocol; - int pd; - - pd = ((struct pppInputHeader *)nb->payload)->unit; - protocol = ((struct pppInputHeader *)nb->payload)->proto; - - if(pbuf_header(nb, -(int)sizeof(struct pppInputHeader))) { - LWIP_ASSERT("pbuf_header failed\n", 0); - goto drop; - } - - LINK_STATS_INC(link.recv); - snmp_inc_ifinucastpkts(&pppControl[pd].netif); - snmp_add_ifinoctets(&pppControl[pd].netif, nb->tot_len); - - /* - * Toss all non-LCP packets unless LCP is OPEN. - * Until we get past the authentication phase, toss all packets - * except LCP, LQR and authentication packets. - */ - if((lcp_phase[pd] <= PHASE_AUTHENTICATE) && (protocol != PPP_LCP)) { - if(!((protocol == PPP_LQR) || (protocol == PPP_PAP) || (protocol == PPP_CHAP)) || - (lcp_phase[pd] != PHASE_AUTHENTICATE)) { - PPPDEBUG(LOG_INFO, ("pppInput: discarding proto 0x%"X16_F" in phase %d\n", protocol, lcp_phase[pd])); - goto drop; - } - } - - switch(protocol) { - case PPP_VJC_COMP: /* VJ compressed TCP */ -#if PPPOS_SUPPORT && VJ_SUPPORT - PPPDEBUG(LOG_INFO, ("pppInput[%d]: vj_comp in pbuf len=%d\n", pd, nb->len)); - /* - * Clip off the VJ header and prepend the rebuilt TCP/IP header and - * pass the result to IP. - */ - if ((vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) && (pppControl[pd].netif.input)) { - pppControl[pd].netif.input(nb, &pppControl[pd].netif); - return; - } - /* Something's wrong so drop it. */ - PPPDEBUG(LOG_WARNING, ("pppInput[%d]: Dropping VJ compressed\n", pd)); -#else /* PPPOS_SUPPORT && VJ_SUPPORT */ - /* No handler for this protocol so drop the packet. */ - PPPDEBUG(LOG_INFO, ("pppInput[%d]: drop VJ Comp in %d:%s\n", pd, nb->len, nb->payload)); -#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ - break; - - case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */ -#if PPPOS_SUPPORT && VJ_SUPPORT - PPPDEBUG(LOG_INFO, ("pppInput[%d]: vj_un in pbuf len=%d\n", pd, nb->len)); - /* - * Process the TCP/IP header for VJ header compression and then pass - * the packet to IP. - */ - if ((vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) && pppControl[pd].netif.input) { - pppControl[pd].netif.input(nb, &pppControl[pd].netif); - return; - } - /* Something's wrong so drop it. */ - PPPDEBUG(LOG_WARNING, ("pppInput[%d]: Dropping VJ uncompressed\n", pd)); -#else /* PPPOS_SUPPORT && VJ_SUPPORT */ - /* No handler for this protocol so drop the packet. */ - PPPDEBUG(LOG_INFO, - ("pppInput[%d]: drop VJ UnComp in %d:.*H\n", - pd, nb->len, LWIP_MIN(nb->len * 2, 40), nb->payload)); -#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ - break; - - case PPP_IP: /* Internet Protocol */ - PPPDEBUG(LOG_INFO, ("pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len)); - if (pppControl[pd].netif.input) { - pppControl[pd].netif.input(nb, &pppControl[pd].netif); - return; - } - break; - - default: { - struct protent *protp; - int i; - - /* - * Upcall the proper protocol input routine. - */ - for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { - if (protp->protocol == protocol && protp->enabled_flag) { - PPPDEBUG(LOG_INFO, ("pppInput[%d]: %s len=%d\n", pd, protp->name, nb->len)); - nb = pppSingleBuf(nb); - (*protp->input)(pd, nb->payload, nb->len); - PPPDEBUG(LOG_DETAIL, ("pppInput[%d]: packet processed\n", pd)); - goto out; - } - } - - /* No handler for this protocol so reject the packet. */ - PPPDEBUG(LOG_INFO, ("pppInput[%d]: rejecting unsupported proto 0x%"X16_F" len=%d\n", pd, protocol, nb->len)); - if (pbuf_header(nb, sizeof(protocol))) { - LWIP_ASSERT("pbuf_header failed\n", 0); - goto drop; - } -#if BYTE_ORDER == LITTLE_ENDIAN - protocol = htons(protocol); -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ - SMEMCPY(nb->payload, &protocol, sizeof(protocol)); - lcp_sprotrej(pd, nb->payload, nb->len); - } - break; - } - -drop: - LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&pppControl[pd].netif); - -out: - pbuf_free(nb); - return; -} - -#if PPPOS_SUPPORT -/* - * Drop the input packet. - */ -static void -pppFreeCurrentInputPacket(PPPControlRx *pcrx) -{ - if (pcrx->inHead != NULL) { - if (pcrx->inTail && (pcrx->inTail != pcrx->inHead)) { - pbuf_free(pcrx->inTail); - } - pbuf_free(pcrx->inHead); - pcrx->inHead = NULL; - } - pcrx->inTail = NULL; -} - -/* - * Drop the input packet and increase error counters. - */ -static void -pppDrop(PPPControlRx *pcrx) -{ - if (pcrx->inHead != NULL) { -#if 0 - PPPDEBUG(LOG_INFO, ("pppDrop: %d:%.*H\n", pcrx->inHead->len, min(60, pcrx->inHead->len * 2), pcrx->inHead->payload)); -#endif - PPPDEBUG(LOG_INFO, ("pppDrop: pbuf len=%d, addr %p\n", pcrx->inHead->len, (void*)pcrx->inHead)); - } - pppFreeCurrentInputPacket(pcrx); -#if VJ_SUPPORT - vj_uncompress_err(&pppControl[pcrx->pd].vjComp); -#endif /* VJ_SUPPORT */ - - LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&pppControl[pcrx->pd].netif); -} - -#if !PPP_INPROC_OWNTHREAD -/** Pass received raw characters to PPPoS to be decoded. This function is - * thread-safe and can be called from a dedicated RX-thread or from a main-loop. - * - * @param pd PPP descriptor index, returned by pppOpen() - * @param data received data - * @param len length of received data - */ -void -pppos_input(int pd, u_char* data, int len) -{ - pppInProc(&pppControl[pd].rx, data, len); -} -#endif - -/** - * Process a received octet string. - */ -static void -pppInProc(PPPControlRx *pcrx, u_char *s, int l) -{ - struct pbuf *nextNBuf; - u_char curChar; - u_char escaped; - SYS_ARCH_DECL_PROTECT(lev); - - PPPDEBUG(LOG_DEBUG, ("pppInProc[%d]: got %d bytes\n", pcrx->pd, l)); - while (l-- > 0) { - curChar = *s++; - - SYS_ARCH_PROTECT(lev); - escaped = ESCAPE_P(pcrx->inACCM, curChar); - SYS_ARCH_UNPROTECT(lev); - /* Handle special characters. */ - if (escaped) { - /* Check for escape sequences. */ - /* XXX Note that this does not handle an escaped 0x5d character which - * would appear as an escape character. Since this is an ASCII ']' - * and there is no reason that I know of to escape it, I won't complicate - * the code to handle this case. GLL */ - if (curChar == PPP_ESCAPE) { - pcrx->inEscaped = 1; - /* Check for the flag character. */ - } else if (curChar == PPP_FLAG) { - /* If this is just an extra flag character, ignore it. */ - if (pcrx->inState <= PDADDRESS) { - /* ignore it */; - /* If we haven't received the packet header, drop what has come in. */ - } else if (pcrx->inState < PDDATA) { - PPPDEBUG(LOG_WARNING, - ("pppInProc[%d]: Dropping incomplete packet %d\n", - pcrx->pd, pcrx->inState)); - LINK_STATS_INC(link.lenerr); - pppDrop(pcrx); - /* If the fcs is invalid, drop the packet. */ - } else if (pcrx->inFCS != PPP_GOODFCS) { - PPPDEBUG(LOG_INFO, - ("pppInProc[%d]: Dropping bad fcs 0x%"X16_F" proto=0x%"X16_F"\n", - pcrx->pd, pcrx->inFCS, pcrx->inProtocol)); - /* Note: If you get lots of these, check for UART frame errors or try different baud rate */ - LINK_STATS_INC(link.chkerr); - pppDrop(pcrx); - /* Otherwise it's a good packet so pass it on. */ - } else { - struct pbuf *inp; - /* Trim off the checksum. */ - if(pcrx->inTail->len >= 2) { - pcrx->inTail->len -= 2; - - pcrx->inTail->tot_len = pcrx->inTail->len; - if (pcrx->inTail != pcrx->inHead) { - pbuf_cat(pcrx->inHead, pcrx->inTail); - } - } else { - pcrx->inTail->tot_len = pcrx->inTail->len; - if (pcrx->inTail != pcrx->inHead) { - pbuf_cat(pcrx->inHead, pcrx->inTail); - } - - pbuf_realloc(pcrx->inHead, pcrx->inHead->tot_len - 2); - } - - /* Dispatch the packet thereby consuming it. */ - inp = pcrx->inHead; - /* Packet consumed, release our references. */ - pcrx->inHead = NULL; - pcrx->inTail = NULL; -#if PPP_INPROC_MULTITHREADED - if(tcpip_callback_with_block(pppInput, inp, 0) != ERR_OK) { - PPPDEBUG(LOG_ERR, ("pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pcrx->pd)); - pbuf_free(inp); - LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&pppControl[pcrx->pd].netif); - } -#else /* PPP_INPROC_MULTITHREADED */ - pppInput(inp); -#endif /* PPP_INPROC_MULTITHREADED */ - } - - /* Prepare for a new packet. */ - pcrx->inFCS = PPP_INITFCS; - pcrx->inState = PDADDRESS; - pcrx->inEscaped = 0; - /* Other characters are usually control characters that may have - * been inserted by the physical layer so here we just drop them. */ - } else { - PPPDEBUG(LOG_WARNING, - ("pppInProc[%d]: Dropping ACCM char <%d>\n", pcrx->pd, curChar)); - } - /* Process other characters. */ - } else { - /* Unencode escaped characters. */ - if (pcrx->inEscaped) { - pcrx->inEscaped = 0; - curChar ^= PPP_TRANS; - } - - /* Process character relative to current state. */ - switch(pcrx->inState) { - case PDIDLE: /* Idle state - waiting. */ - /* Drop the character if it's not 0xff - * we would have processed a flag character above. */ - if (curChar != PPP_ALLSTATIONS) { - break; - } - - /* Fall through */ - case PDSTART: /* Process start flag. */ - /* Prepare for a new packet. */ - pcrx->inFCS = PPP_INITFCS; - - /* Fall through */ - case PDADDRESS: /* Process address field. */ - if (curChar == PPP_ALLSTATIONS) { - pcrx->inState = PDCONTROL; - break; - } - /* Else assume compressed address and control fields so - * fall through to get the protocol... */ - case PDCONTROL: /* Process control field. */ - /* If we don't get a valid control code, restart. */ - if (curChar == PPP_UI) { - pcrx->inState = PDPROTOCOL1; - break; - } -#if 0 - else { - PPPDEBUG(LOG_WARNING, - ("pppInProc[%d]: Invalid control <%d>\n", pcrx->pd, curChar)); - pcrx->inState = PDSTART; - } -#endif - case PDPROTOCOL1: /* Process protocol field 1. */ - /* If the lower bit is set, this is the end of the protocol - * field. */ - if (curChar & 1) { - pcrx->inProtocol = curChar; - pcrx->inState = PDDATA; - } else { - pcrx->inProtocol = (u_int)curChar << 8; - pcrx->inState = PDPROTOCOL2; - } - break; - case PDPROTOCOL2: /* Process protocol field 2. */ - pcrx->inProtocol |= curChar; - pcrx->inState = PDDATA; - break; - case PDDATA: /* Process data byte. */ - /* Make space to receive processed data. */ - if (pcrx->inTail == NULL || pcrx->inTail->len == PBUF_POOL_BUFSIZE) { - if (pcrx->inTail != NULL) { - pcrx->inTail->tot_len = pcrx->inTail->len; - if (pcrx->inTail != pcrx->inHead) { - pbuf_cat(pcrx->inHead, pcrx->inTail); - /* give up the inTail reference now */ - pcrx->inTail = NULL; - } - } - /* If we haven't started a packet, we need a packet header. */ - nextNBuf = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); - if (nextNBuf == NULL) { - /* No free buffers. Drop the input packet and let the - * higher layers deal with it. Continue processing - * the received pbuf chain in case a new packet starts. */ - PPPDEBUG(LOG_ERR, ("pppInProc[%d]: NO FREE MBUFS!\n", pcrx->pd)); - LINK_STATS_INC(link.memerr); - pppDrop(pcrx); - pcrx->inState = PDSTART; /* Wait for flag sequence. */ - break; - } - if (pcrx->inHead == NULL) { - struct pppInputHeader *pih = nextNBuf->payload; - - pih->unit = pcrx->pd; - pih->proto = pcrx->inProtocol; - - nextNBuf->len += sizeof(*pih); - - pcrx->inHead = nextNBuf; - } - pcrx->inTail = nextNBuf; - } - /* Load character into buffer. */ - ((u_char*)pcrx->inTail->payload)[pcrx->inTail->len++] = curChar; - break; - } - - /* update the frame check sequence number. */ - pcrx->inFCS = PPP_FCS(pcrx->inFCS, curChar); - } - } /* while (l-- > 0), all bytes processed */ - - avRandomize(); -} -#endif /* PPPOS_SUPPORT */ - -#if PPPOE_SUPPORT -void -pppInProcOverEthernet(int pd, struct pbuf *pb) -{ - struct pppInputHeader *pih; - u16_t inProtocol; - - if(pb->len < sizeof(inProtocol)) { - PPPDEBUG(LOG_ERR, ("pppInProcOverEthernet: too small for protocol field\n")); - goto drop; - } - - inProtocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1]; - - /* make room for pppInputHeader - should not fail */ - if (pbuf_header(pb, sizeof(*pih) - sizeof(inProtocol)) != 0) { - PPPDEBUG(LOG_ERR, ("pppInProcOverEthernet: could not allocate room for header\n")); - goto drop; - } - - pih = pb->payload; - - pih->unit = pd; - pih->proto = inProtocol; - - /* Dispatch the packet thereby consuming it. */ - pppInput(pb); - return; - -drop: - LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&pppControl[pd].netif); - pbuf_free(pb); - return; -} -#endif /* PPPOE_SUPPORT */ - -#if LWIP_NETIF_STATUS_CALLBACK -/** Set the status callback of a PPP's netif - * - * @param pd The PPP descriptor returned by pppOpen() - * @param status_callback pointer to the status callback function - * - * @see netif_set_status_callback - */ -void -ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) -{ - netif_set_status_callback(&pppControl[pd].netif, status_callback); -} -#endif /* LWIP_NETIF_STATUS_CALLBACK */ - -#if LWIP_NETIF_LINK_CALLBACK -/** Set the link callback of a PPP's netif - * - * @param pd The PPP descriptor returned by pppOpen() - * @param link_callback pointer to the link callback function - * - * @see netif_set_link_callback - */ -void -ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback) -{ - netif_set_link_callback(&pppControl[pd].netif, link_callback); -} -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp.h b/user/mpy/lib/lwip/src/netif/ppp/ppp.h deleted file mode 100644 index 08d6e62..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/ppp.h +++ /dev/null @@ -1,201 +0,0 @@ -/***************************************************************************** -* ppp.h - Network Point to Point Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ - -#ifndef PPP_H -#define PPP_H - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/sio.h" -#include "lwip/stats.h" -#include "lwip/mem.h" -#include "lwip/netif.h" -#include "lwip/sys.h" -#include "lwip/timers.h" - - -#ifndef __u_char_defined - -/* Type definitions for BSD code. */ -typedef unsigned long u_long; -typedef unsigned int u_int; -typedef unsigned short u_short; -typedef unsigned char u_char; - -#endif - - -/************************* -*** PUBLIC DEFINITIONS *** -*************************/ - -/* Error codes. */ -#define PPPERR_NONE 0 /* No error. */ -#define PPPERR_PARAM -1 /* Invalid parameter. */ -#define PPPERR_OPEN -2 /* Unable to open PPP session. */ -#define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */ -#define PPPERR_ALLOC -4 /* Unable to allocate resources. */ -#define PPPERR_USER -5 /* User interrupt. */ -#define PPPERR_CONNECT -6 /* Connection lost. */ -#define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */ -#define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */ - -/* - * PPP IOCTL commands. - */ -/* - * Get the up status - 0 for down, non-zero for up. The argument must - * point to an int. - */ -#define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */ -#define PPPCTLS_ERRCODE 101 /* Set the error code */ -#define PPPCTLG_ERRCODE 102 /* Get the error code */ -#define PPPCTLG_FD 103 /* Get the fd associated with the ppp */ - -/************************ -*** PUBLIC DATA TYPES *** -************************/ - -struct ppp_addrs { - ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2; -}; - - -/*********************** -*** PUBLIC FUNCTIONS *** -***********************/ - -/* Initialize the PPP subsystem. */ -void pppInit(void); - -/* Warning: Using PPPAUTHTYPE_ANY might have security consequences. - * RFC 1994 says: - * - * In practice, within or associated with each PPP server, there is a - * database which associates "user" names with authentication - * information ("secrets"). It is not anticipated that a particular - * named user would be authenticated by multiple methods. This would - * make the user vulnerable to attacks which negotiate the least secure - * method from among a set (such as PAP rather than CHAP). If the same - * secret was used, PAP would reveal the secret to be used later with - * CHAP. - * - * Instead, for each user name there should be an indication of exactly - * one method used to authenticate that user name. If a user needs to - * make use of different authentication methods under different - * circumstances, then distinct user names SHOULD be employed, each of - * which identifies exactly one authentication method. - * - */ -enum pppAuthType { - PPPAUTHTYPE_NONE, - PPPAUTHTYPE_ANY, - PPPAUTHTYPE_PAP, - PPPAUTHTYPE_CHAP -}; - -void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd); - -/* Link status callback function prototype */ -typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg); - -#if PPPOS_SUPPORT -/* - * Open a new PPP connection using the given serial I/O device. - * This initializes the PPP control block but does not - * attempt to negotiate the LCP session. - * Return a new PPP connection descriptor on success or - * an error code (negative) on failure. - */ -int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx); -#endif /* PPPOS_SUPPORT */ - -#if PPPOE_SUPPORT -/* - * Open a new PPP Over Ethernet (PPPOE) connection. - */ -int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, - pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx); -#endif /* PPPOE_SUPPORT */ - -/* for source code compatibility */ -#define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls) - -/* - * Close a PPP connection and release the descriptor. - * Any outstanding packets in the queues are dropped. - * Return 0 on success, an error code on failure. - */ -int pppClose(int pd); - -/* - * Indicate to the PPP process that the line has disconnected. - */ -void pppSigHUP(int pd); - -/* - * Get and set parameters for the given connection. - * Return 0 on success, an error code on failure. - */ -int pppIOCtl(int pd, int cmd, void *arg); - -/* - * Return the Maximum Transmission Unit for the given PPP connection. - */ -u_short pppMTU(int pd); - -#if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD -/* - * PPP over Serial: this is the input function to be called for received data. - * If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking - * sio_read() is used, so this is deactivated. - */ -void pppos_input(int pd, u_char* data, int len); -#endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */ - - -#if LWIP_NETIF_STATUS_CALLBACK -/* Set an lwIP-style status-callback for the selected PPP device */ -void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback); -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_LINK_CALLBACK -/* Set an lwIP-style link-callback for the selected PPP device */ -void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback); -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#endif /* PPP_SUPPORT */ - -#endif /* PPP_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h b/user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h deleted file mode 100644 index 89aea60..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/ppp_impl.h +++ /dev/null @@ -1,363 +0,0 @@ -/***************************************************************************** -* ppp.h - Network Point to Point Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ - -#ifndef PPP_IMPL_H -#define PPP_IMPL_H - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp.h" -#include "lwip/def.h" -#include "lwip/sio.h" -#include "lwip/stats.h" -#include "lwip/mem.h" -#include "lwip/netif.h" -#include "lwip/sys.h" -#include "lwip/timers.h" - -/** Some defines for code we skip compared to the original pppd. - * These are just here to minimise the use of the ugly "#if 0". */ -#define PPP_ADDITIONAL_CALLBACKS 0 - -/** Some error checks to test for unsupported code */ -#if CBCP_SUPPORT -#error "CBCP is not supported in lwIP PPP" -#endif -#if CCP_SUPPORT -#error "CCP is not supported in lwIP PPP" -#endif - -/* - * pppd.h - PPP daemon global declarations. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ -/* - * ppp_defs.h - PPP definitions. - * - * Copyright (c) 1994 The Australian National University. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation is hereby granted, provided that the above copyright - * notice appears in all copies. This software is provided without any - * warranty, express or implied. The Australian National University - * makes no representations about the suitability of this software for - * any purpose. - * - * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, - * OR MODIFICATIONS. - */ - -#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0) -#define UNTIMEOUT(f, a) sys_untimeout((f), (a)) - - -/* - * Constants and structures defined by the internet system, - * Per RFC 790, September 1981, and numerous additions. - */ - -/* - * The basic PPP frame. - */ -#define PPP_HDRLEN 4 /* octets for standard ppp header */ -#define PPP_FCSLEN 2 /* octets for FCS */ - - -/* - * Significant octet values. - */ -#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ -#define PPP_UI 0x03 /* Unnumbered Information */ -#define PPP_FLAG 0x7e /* Flag Sequence */ -#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ -#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ - -/* - * Protocol field values. - */ -#define PPP_IP 0x21 /* Internet Protocol */ -#define PPP_AT 0x29 /* AppleTalk Protocol */ -#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ -#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ -#define PPP_COMP 0xfd /* compressed packet */ -#define PPP_IPCP 0x8021 /* IP Control Protocol */ -#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ -#define PPP_CCP 0x80fd /* Compression Control Protocol */ -#define PPP_LCP 0xc021 /* Link Control Protocol */ -#define PPP_PAP 0xc023 /* Password Authentication Protocol */ -#define PPP_LQR 0xc025 /* Link Quality Report protocol */ -#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ -#define PPP_CBCP 0xc029 /* Callback Control Protocol */ - -/* - * Values for FCS calculations. - */ -#define PPP_INITFCS 0xffff /* Initial FCS value */ -#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ -#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) - -/* - * Extended asyncmap - allows any character to be escaped. - */ -typedef u_char ext_accm[32]; - -/* - * What to do with network protocol (NP) packets. - */ -enum NPmode { - NPMODE_PASS, /* pass the packet through */ - NPMODE_DROP, /* silently drop the packet */ - NPMODE_ERROR, /* return an error */ - NPMODE_QUEUE /* save it up for later. */ -}; - -/* - * Inline versions of get/put char/short/long. - * Pointer is advanced; we assume that both arguments - * are lvalues and will already be in registers. - * cp MUST be u_char *. - */ -#define GETCHAR(c, cp) { \ - (c) = *(cp)++; \ -} -#define PUTCHAR(c, cp) { \ - *(cp)++ = (u_char) (c); \ -} - - -#define GETSHORT(s, cp) { \ - (s) = *(cp); (cp)++; (s) <<= 8; \ - (s) |= *(cp); (cp)++; \ -} -#define PUTSHORT(s, cp) { \ - *(cp)++ = (u_char) ((s) >> 8); \ - *(cp)++ = (u_char) (s & 0xff); \ -} - -#define GETLONG(l, cp) { \ - (l) = *(cp); (cp)++; (l) <<= 8; \ - (l) |= *(cp); (cp)++; (l) <<= 8; \ - (l) |= *(cp); (cp)++; (l) <<= 8; \ - (l) |= *(cp); (cp)++; \ -} -#define PUTLONG(l, cp) { \ - *(cp)++ = (u_char) ((l) >> 24); \ - *(cp)++ = (u_char) ((l) >> 16); \ - *(cp)++ = (u_char) ((l) >> 8); \ - *(cp)++ = (u_char) (l); \ -} - - -#define INCPTR(n, cp) ((cp) += (n)) -#define DECPTR(n, cp) ((cp) -= (n)) - -#define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l)) -#define BCOPY(s, d, l) MEMCPY((d), (s), (l)) -#define BZERO(s, n) memset(s, 0, n) - -#if PPP_DEBUG -#define PRINTMSG(m, l) { m[l] = '\0'; LWIP_DEBUGF(LOG_INFO, ("Remote message: %s\n", m)); } -#else /* PPP_DEBUG */ -#define PRINTMSG(m, l) -#endif /* PPP_DEBUG */ - -/* - * MAKEHEADER - Add PPP Header fields to a packet. - */ -#define MAKEHEADER(p, t) { \ - PUTCHAR(PPP_ALLSTATIONS, p); \ - PUTCHAR(PPP_UI, p); \ - PUTSHORT(t, p); } - -/************************ -*** PUBLIC DATA TYPES *** -************************/ - -/* - * The following struct gives the addresses of procedures to call - * for a particular protocol. - */ -struct protent { - u_short protocol; /* PPP protocol number */ - /* Initialization procedure */ - void (*init) (int unit); - /* Process a received packet */ - void (*input) (int unit, u_char *pkt, int len); - /* Process a received protocol-reject */ - void (*protrej) (int unit); - /* Lower layer has come up */ - void (*lowerup) (int unit); - /* Lower layer has gone down */ - void (*lowerdown) (int unit); - /* Open the protocol */ - void (*open) (int unit); - /* Close the protocol */ - void (*close) (int unit, char *reason); -#if PPP_ADDITIONAL_CALLBACKS - /* Print a packet in readable form */ - int (*printpkt) (u_char *pkt, int len, - void (*printer) (void *, char *, ...), - void *arg); - /* Process a received data packet */ - void (*datainput) (int unit, u_char *pkt, int len); -#endif /* PPP_ADDITIONAL_CALLBACKS */ - int enabled_flag; /* 0 if protocol is disabled */ - char *name; /* Text name of protocol */ -#if PPP_ADDITIONAL_CALLBACKS - /* Check requested options, assign defaults */ - void (*check_options) (u_long); - /* Configure interface for demand-dial */ - int (*demand_conf) (int unit); - /* Say whether to bring up link for this pkt */ - int (*active_pkt) (u_char *pkt, int len); -#endif /* PPP_ADDITIONAL_CALLBACKS */ -}; - -/* - * The following structure records the time in seconds since - * the last NP packet was sent or received. - */ -struct ppp_idle { - u_short xmit_idle; /* seconds since last NP packet sent */ - u_short recv_idle; /* seconds since last NP packet received */ -}; - -struct ppp_settings { - - u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ - u_int auth_required : 1; /* Peer is required to authenticate */ - u_int explicit_remote : 1; /* remote_name specified with remotename opt */ - u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */ - u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */ - u_int usehostname : 1; /* Use hostname for our_name */ - u_int usepeerdns : 1; /* Ask peer for DNS adds */ - - u_short idle_time_limit; /* Shut down link if idle for this long */ - int maxconnect; /* Maximum connect time (seconds) */ - - char user [MAXNAMELEN + 1]; /* Username for PAP */ - char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ - char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */ - char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ -}; - -/***************************** -*** PUBLIC DATA STRUCTURES *** -*****************************/ - -/* Buffers for outgoing packets. */ -extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; - -extern struct ppp_settings ppp_settings; - -extern struct protent *ppp_protocols[]; /* Table of pointers to supported protocols */ - - -/*********************** -*** PUBLIC FUNCTIONS *** -***********************/ - -/* - * Write n characters to a ppp link. - * RETURN: >= 0 Number of characters written, -1 Failed to write to device. - */ -int pppWrite(int pd, const u_char *s, int n); - -void pppInProcOverEthernet(int pd, struct pbuf *pb); - -struct pbuf *pppSingleBuf(struct pbuf *p); - -void pppLinkTerminated(int pd); - -void pppLinkDown(int pd); - -/* Configure i/f transmit parameters */ -void ppp_send_config (int, u16_t, u32_t, int, int); -/* Set extended transmit ACCM */ -void ppp_set_xaccm (int, ext_accm *); -/* Configure i/f receive parameters */ -void ppp_recv_config (int, int, u32_t, int, int); -/* Find out how long link has been idle */ -int get_idle_time (int, struct ppp_idle *); - -/* Configure VJ TCP header compression */ -int sifvjcomp (int, int, u8_t, u8_t); -/* Configure i/f down (for IP) */ -int sifup (int); -/* Set mode for handling packets for proto */ -int sifnpmode (int u, int proto, enum NPmode mode); -/* Configure i/f down (for IP) */ -int sifdown (int); -/* Configure IP addresses for i/f */ -int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t); -/* Reset i/f IP addresses */ -int cifaddr (int, u32_t, u32_t); -/* Create default route through i/f */ -int sifdefaultroute (int, u32_t, u32_t); -/* Delete default route through i/f */ -int cifdefaultroute (int, u32_t, u32_t); - -/* Get appropriate netmask for address */ -u32_t GetMask (u32_t); - -#endif /* PPP_SUPPORT */ - -#endif /* PPP_IMPL_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c b/user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c deleted file mode 100644 index fdf52ae..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/ppp_oe.c +++ /dev/null @@ -1,1132 +0,0 @@ -/***************************************************************************** -* ppp_oe.c - PPP Over Ethernet implementation for lwIP. -* -* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 06-01-01 Marc Boucher -* Ported to lwIP. -*****************************************************************************/ - - - -/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "lwip/opt.h" - -#if PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "netif/ppp_oe.h" - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "lwip/timers.h" -#include "lwip/memp.h" - -#include -#include - - -/* Add a 16 bit unsigned value to a buffer pointed to by PTR */ -#define PPPOE_ADD_16(PTR, VAL) \ - *(PTR)++ = (u8_t)((VAL) / 256); \ - *(PTR)++ = (u8_t)((VAL) % 256) - -/* Add a complete PPPoE header to the buffer pointed to by PTR */ -#define PPPOE_ADD_HEADER(PTR, CODE, SESS, LEN) \ - *(PTR)++ = PPPOE_VERTYPE; \ - *(PTR)++ = (CODE); \ - PPPOE_ADD_16(PTR, SESS); \ - PPPOE_ADD_16(PTR, LEN) - -#define PPPOE_DISC_TIMEOUT (5*1000) /* base for quick timeout calculation */ -#define PPPOE_SLOW_RETRY (60*1000) /* persistent retry interval */ -#define PPPOE_DISC_MAXPADI 4 /* retry PADI four times (quickly) */ -#define PPPOE_DISC_MAXPADR 2 /* retry PADR twice */ - -#ifdef PPPOE_SERVER -#error "PPPOE_SERVER is not yet supported under lwIP!" -/* from if_spppsubr.c */ -#define IFF_PASSIVE IFF_LINK0 /* wait passively for connection */ -#endif - -#ifndef PPPOE_ERRORSTRING_LEN -#define PPPOE_ERRORSTRING_LEN 64 -#endif -static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN]; - - -/* input routines */ -static void pppoe_dispatch_disc_pkt(struct netif *, struct pbuf *); - -/* management routines */ -static int pppoe_do_disconnect(struct pppoe_softc *); -static void pppoe_abort_connect(struct pppoe_softc *); -static void pppoe_clear_softc(struct pppoe_softc *, const char *); - -/* internal timeout handling */ -static void pppoe_timeout(void *); - -/* sending actual protocol controll packets */ -static err_t pppoe_send_padi(struct pppoe_softc *); -static err_t pppoe_send_padr(struct pppoe_softc *); -#ifdef PPPOE_SERVER -static err_t pppoe_send_pado(struct pppoe_softc *); -static err_t pppoe_send_pads(struct pppoe_softc *); -#endif -static err_t pppoe_send_padt(struct netif *, u_int, const u8_t *); - -/* internal helper functions */ -static struct pppoe_softc * pppoe_find_softc_by_session(u_int, struct netif *); -static struct pppoe_softc * pppoe_find_softc_by_hunique(u8_t *, size_t, struct netif *); - -/** linked list of created pppoe interfaces */ -static struct pppoe_softc *pppoe_softc_list; - -err_t -pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr) -{ - struct pppoe_softc *sc; - - sc = (struct pppoe_softc *)memp_malloc(MEMP_PPPOE_IF); - if (sc == NULL) { - *scptr = NULL; - return ERR_MEM; - } - memset(sc, 0, sizeof(struct pppoe_softc)); - - /* changed to real address later */ - MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); - - sc->sc_pd = pd; - sc->sc_linkStatusCB = linkStatusCB; - sc->sc_ethif = ethif; - - /* put the new interface at the head of the list */ - sc->next = pppoe_softc_list; - pppoe_softc_list = sc; - - *scptr = sc; - - return ERR_OK; -} - -err_t -pppoe_destroy(struct netif *ifp) -{ - struct pppoe_softc *sc, *prev = NULL; - - for (sc = pppoe_softc_list; sc != NULL; prev = sc, sc = sc->next) { - if (sc->sc_ethif == ifp) { - break; - } - } - - if(!(sc && (sc->sc_ethif == ifp))) { - return ERR_IF; - } - - sys_untimeout(pppoe_timeout, sc); - if (prev == NULL) { - /* remove sc from the head of the list */ - pppoe_softc_list = sc->next; - } else { - /* remove sc from the list */ - prev->next = sc->next; - } - -#ifdef PPPOE_TODO - if (sc->sc_concentrator_name) { - mem_free(sc->sc_concentrator_name); - } - if (sc->sc_service_name) { - mem_free(sc->sc_service_name); - } -#endif /* PPPOE_TODO */ - memp_free(MEMP_PPPOE_IF, sc); - - return ERR_OK; -} - -/* - * Find the interface handling the specified session. - * Note: O(number of sessions open), this is a client-side only, mean - * and lean implementation, so number of open sessions typically should - * be 1. - */ -static struct pppoe_softc * -pppoe_find_softc_by_session(u_int session, struct netif *rcvif) -{ - struct pppoe_softc *sc; - - if (session == 0) { - return NULL; - } - - for (sc = pppoe_softc_list; sc != NULL; sc = sc->next) { - if (sc->sc_state == PPPOE_STATE_SESSION - && sc->sc_session == session) { - if (sc->sc_ethif == rcvif) { - return sc; - } else { - return NULL; - } - } - } - return NULL; -} - -/* Check host unique token passed and return appropriate softc pointer, - * or NULL if token is bogus. */ -static struct pppoe_softc * -pppoe_find_softc_by_hunique(u8_t *token, size_t len, struct netif *rcvif) -{ - struct pppoe_softc *sc, *t; - - if (pppoe_softc_list == NULL) { - return NULL; - } - - if (len != sizeof sc) { - return NULL; - } - MEMCPY(&t, token, len); - - for (sc = pppoe_softc_list; sc != NULL; sc = sc->next) { - if (sc == t) { - break; - } - } - - if (sc == NULL) { - PPPDEBUG(LOG_DEBUG, ("pppoe: alien host unique tag, no session found\n")); - return NULL; - } - - /* should be safe to access *sc now */ - if (sc->sc_state < PPPOE_STATE_PADI_SENT || sc->sc_state >= PPPOE_STATE_SESSION) { - printf("%c%c%"U16_F": host unique tag found, but it belongs to a connection in state %d\n", - sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_state); - return NULL; - } - if (sc->sc_ethif != rcvif) { - printf("%c%c%"U16_F": wrong interface, not accepting host unique\n", - sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); - return NULL; - } - return sc; -} - -static void -pppoe_linkstatus_up(struct pppoe_softc *sc) -{ - sc->sc_linkStatusCB(sc->sc_pd, 1); -} - -/* analyze and handle a single received packet while not in session state */ -static void -pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb) -{ - u16_t tag, len; - u16_t session, plen; - struct pppoe_softc *sc; - const char *err_msg; - char devname[6]; - u8_t *ac_cookie; - u16_t ac_cookie_len; -#ifdef PPPOE_SERVER - u8_t *hunique; - size_t hunique_len; -#endif - struct pppoehdr *ph; - struct pppoetag pt; - int off, err, errortag; - struct eth_hdr *ethhdr; - - pb = pppSingleBuf(pb); - - strcpy(devname, "pppoe"); /* as long as we don't know which instance */ - err_msg = NULL; - errortag = 0; - if (pb->len < sizeof(*ethhdr)) { - goto done; - } - ethhdr = (struct eth_hdr *)pb->payload; - off = sizeof(*ethhdr); - - ac_cookie = NULL; - ac_cookie_len = 0; -#ifdef PPPOE_SERVER - hunique = NULL; - hunique_len = 0; -#endif - session = 0; - if (pb->len - off < PPPOE_HEADERLEN) { - printf("pppoe: packet too short: %d\n", pb->len); - goto done; - } - - ph = (struct pppoehdr *) (ethhdr + 1); - if (ph->vertype != PPPOE_VERTYPE) { - printf("pppoe: unknown version/type packet: 0x%x\n", ph->vertype); - goto done; - } - session = ntohs(ph->session); - plen = ntohs(ph->plen); - off += sizeof(*ph); - - if (plen + off > pb->len) { - printf("pppoe: packet content does not fit: data available = %d, packet size = %u\n", - pb->len - off, plen); - goto done; - } - if(pb->tot_len == pb->len) { - pb->tot_len = pb->len = (u16_t)off + plen; /* ignore trailing garbage */ - } - tag = 0; - len = 0; - sc = NULL; - while (off + sizeof(pt) <= pb->len) { - MEMCPY(&pt, (u8_t*)pb->payload + off, sizeof(pt)); - tag = ntohs(pt.tag); - len = ntohs(pt.len); - if (off + sizeof(pt) + len > pb->len) { - printf("pppoe: tag 0x%x len 0x%x is too long\n", tag, len); - goto done; - } - switch (tag) { - case PPPOE_TAG_EOL: - goto breakbreak; - case PPPOE_TAG_SNAME: - break; /* ignored */ - case PPPOE_TAG_ACNAME: - break; /* ignored */ - case PPPOE_TAG_HUNIQUE: - if (sc != NULL) { - break; - } -#ifdef PPPOE_SERVER - hunique = (u8_t*)pb->payload + off + sizeof(pt); - hunique_len = len; -#endif - sc = pppoe_find_softc_by_hunique((u8_t*)pb->payload + off + sizeof(pt), len, netif); - if (sc != NULL) { - snprintf(devname, sizeof(devname), "%c%c%"U16_F, sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); - } - break; - case PPPOE_TAG_ACCOOKIE: - if (ac_cookie == NULL) { - ac_cookie = (u8_t*)pb->payload + off + sizeof(pt); - ac_cookie_len = len; - } - break; - case PPPOE_TAG_SNAME_ERR: - err_msg = "SERVICE NAME ERROR"; - errortag = 1; - break; - case PPPOE_TAG_ACSYS_ERR: - err_msg = "AC SYSTEM ERROR"; - errortag = 1; - break; - case PPPOE_TAG_GENERIC_ERR: - err_msg = "GENERIC ERROR"; - errortag = 1; - break; - } - if (err_msg) { - if (errortag && len) { - u16_t error_len = LWIP_MIN(len, sizeof(pppoe_error_tmp)-1); - strncpy(pppoe_error_tmp, (char*)pb->payload + off + sizeof(pt), error_len); - pppoe_error_tmp[error_len-1] = '\0'; - printf("%s: %s: %s\n", devname, err_msg, pppoe_error_tmp); - } else { - printf("%s: %s\n", devname, err_msg); - } - if (errortag) { - goto done; - } - } - off += sizeof(pt) + len; - } - -breakbreak:; - switch (ph->code) { - case PPPOE_CODE_PADI: -#ifdef PPPOE_SERVER - /* - * got service name, concentrator name, and/or host unique. - * ignore if we have no interfaces with IFF_PASSIVE|IFF_UP. - */ - if (LIST_EMPTY(&pppoe_softc_list)) { - goto done; - } - LIST_FOREACH(sc, &pppoe_softc_list, sc_list) { - if (!(sc->sc_sppp.pp_if.if_flags & IFF_UP)) { - continue; - } - if (!(sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) { - continue; - } - if (sc->sc_state == PPPOE_STATE_INITIAL) { - break; - } - } - if (sc == NULL) { - /* printf("pppoe: free passive interface is not found\n"); */ - goto done; - } - if (hunique) { - if (sc->sc_hunique) { - mem_free(sc->sc_hunique); - } - sc->sc_hunique = mem_malloc(hunique_len); - if (sc->sc_hunique == NULL) { - goto done; - } - sc->sc_hunique_len = hunique_len; - MEMCPY(sc->sc_hunique, hunique, hunique_len); - } - MEMCPY(&sc->sc_dest, eh->ether_shost, sizeof sc->sc_dest); - sc->sc_state = PPPOE_STATE_PADO_SENT; - pppoe_send_pado(sc); - break; -#endif /* PPPOE_SERVER */ - case PPPOE_CODE_PADR: -#ifdef PPPOE_SERVER - /* - * get sc from ac_cookie if IFF_PASSIVE - */ - if (ac_cookie == NULL) { - /* be quiet if there is not a single pppoe instance */ - printf("pppoe: received PADR but not includes ac_cookie\n"); - goto done; - } - sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len, netif); - if (sc == NULL) { - /* be quiet if there is not a single pppoe instance */ - if (!LIST_EMPTY(&pppoe_softc_list)) { - printf("pppoe: received PADR but could not find request for it\n"); - } - goto done; - } - if (sc->sc_state != PPPOE_STATE_PADO_SENT) { - printf("%c%c%"U16_F": received unexpected PADR\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); - goto done; - } - if (hunique) { - if (sc->sc_hunique) { - mem_free(sc->sc_hunique); - } - sc->sc_hunique = mem_malloc(hunique_len); - if (sc->sc_hunique == NULL) { - goto done; - } - sc->sc_hunique_len = hunique_len; - MEMCPY(sc->sc_hunique, hunique, hunique_len); - } - pppoe_send_pads(sc); - sc->sc_state = PPPOE_STATE_SESSION; - pppoe_linkstatus_up(sc); /* notify upper layers */ - break; -#else - /* ignore, we are no access concentrator */ - goto done; -#endif /* PPPOE_SERVER */ - case PPPOE_CODE_PADO: - if (sc == NULL) { - /* be quiet if there is not a single pppoe instance */ - if (pppoe_softc_list != NULL) { - printf("pppoe: received PADO but could not find request for it\n"); - } - goto done; - } - if (sc->sc_state != PPPOE_STATE_PADI_SENT) { - printf("%c%c%"U16_F": received unexpected PADO\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); - goto done; - } - if (ac_cookie) { - sc->sc_ac_cookie_len = ac_cookie_len; - MEMCPY(sc->sc_ac_cookie, ac_cookie, ac_cookie_len); - } - MEMCPY(&sc->sc_dest, ethhdr->src.addr, sizeof(sc->sc_dest.addr)); - sys_untimeout(pppoe_timeout, sc); - sc->sc_padr_retried = 0; - sc->sc_state = PPPOE_STATE_PADR_SENT; - if ((err = pppoe_send_padr(sc)) != 0) { - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADR, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); - } - sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc); - break; - case PPPOE_CODE_PADS: - if (sc == NULL) { - goto done; - } - sc->sc_session = session; - sys_untimeout(pppoe_timeout, sc); - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": session 0x%x connected\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, session)); - sc->sc_state = PPPOE_STATE_SESSION; - pppoe_linkstatus_up(sc); /* notify upper layers */ - break; - case PPPOE_CODE_PADT: - if (sc == NULL) { - goto done; - } - pppoe_clear_softc(sc, "received PADT"); - break; - default: - if(sc) { - printf("%c%c%"U16_F": unknown code (0x%"X16_F") session = 0x%"X16_F"\n", - sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, - (u16_t)ph->code, session); - } else { - printf("pppoe: unknown code (0x%"X16_F") session = 0x%"X16_F"\n", (u16_t)ph->code, session); - } - break; - } - -done: - pbuf_free(pb); - return; -} - -void -pppoe_disc_input(struct netif *netif, struct pbuf *p) -{ - /* avoid error messages if there is not a single pppoe instance */ - if (pppoe_softc_list != NULL) { - pppoe_dispatch_disc_pkt(netif, p); - } else { - pbuf_free(p); - } -} - -void -pppoe_data_input(struct netif *netif, struct pbuf *pb) -{ - u16_t session, plen; - struct pppoe_softc *sc; - struct pppoehdr *ph; -#ifdef PPPOE_TERM_UNKNOWN_SESSIONS - u8_t shost[ETHER_ADDR_LEN]; -#endif - -#ifdef PPPOE_TERM_UNKNOWN_SESSIONS - MEMCPY(shost, ((struct eth_hdr *)pb->payload)->src.addr, sizeof(shost)); -#endif - if (pbuf_header(pb, -(int)sizeof(struct eth_hdr)) != 0) { - /* bail out */ - PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header failed\n")); - LINK_STATS_INC(link.lenerr); - goto drop; - } - - pb = pppSingleBuf (pb); - - if (pb->len <= PPPOE_HEADERLEN) { - printf("pppoe (data): dropping too short packet: %d bytes\n", pb->len); - goto drop; - } - - if (pb->len < sizeof(*ph)) { - printf("pppoe_data_input: could not get PPPoE header\n"); - goto drop; - } - ph = (struct pppoehdr *)pb->payload; - - if (ph->vertype != PPPOE_VERTYPE) { - printf("pppoe (data): unknown version/type packet: 0x%x\n", ph->vertype); - goto drop; - } - if (ph->code != 0) { - goto drop; - } - - session = ntohs(ph->session); - sc = pppoe_find_softc_by_session(session, netif); - if (sc == NULL) { -#ifdef PPPOE_TERM_UNKNOWN_SESSIONS - printf("pppoe: input for unknown session 0x%x, sending PADT\n", session); - pppoe_send_padt(netif, session, shost); -#endif - goto drop; - } - - plen = ntohs(ph->plen); - - if (pbuf_header(pb, -(int)(PPPOE_HEADERLEN)) != 0) { - /* bail out */ - PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n")); - LINK_STATS_INC(link.lenerr); - goto drop; - } - - PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: %c%c%"U16_F": pkthdr.len=%d, pppoe.len=%d\n", - sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, - pb->len, plen)); - - if (pb->len < plen) { - goto drop; - } - - pppInProcOverEthernet(sc->sc_pd, pb); - - return; - -drop: - pbuf_free(pb); -} - -static err_t -pppoe_output(struct pppoe_softc *sc, struct pbuf *pb) -{ - struct eth_hdr *ethhdr; - u16_t etype; - err_t res; - - if (!sc->sc_ethif) { - pbuf_free(pb); - return ERR_IF; - } - - ethhdr = (struct eth_hdr *)pb->payload; - etype = sc->sc_state == PPPOE_STATE_SESSION ? ETHTYPE_PPPOE : ETHTYPE_PPPOEDISC; - ethhdr->type = htons(etype); - MEMCPY(ethhdr->dest.addr, sc->sc_dest.addr, sizeof(ethhdr->dest.addr)); - MEMCPY(ethhdr->src.addr, ((struct eth_addr *)sc->sc_ethif->hwaddr)->addr, sizeof(ethhdr->src.addr)); - - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F" (%x) state=%d, session=0x%x output -> %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F", len=%d\n", - sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, etype, - sc->sc_state, sc->sc_session, - sc->sc_dest.addr[0], sc->sc_dest.addr[1], sc->sc_dest.addr[2], sc->sc_dest.addr[3], sc->sc_dest.addr[4], sc->sc_dest.addr[5], - pb->tot_len)); - - res = sc->sc_ethif->linkoutput(sc->sc_ethif, pb); - - pbuf_free(pb); - - return res; -} - -static err_t -pppoe_send_padi(struct pppoe_softc *sc) -{ - struct pbuf *pb; - u8_t *p; - int len; -#ifdef PPPOE_TODO - int l1 = 0, l2 = 0; /* XXX: gcc */ -#endif /* PPPOE_TODO */ - - if (sc->sc_state >PPPOE_STATE_PADI_SENT) { - PPPDEBUG(LOG_ERR, ("ERROR: pppoe_send_padi in state %d", sc->sc_state)); - } - - /* calculate length of frame (excluding ethernet header + pppoe header) */ - len = 2 + 2 + 2 + 2 + sizeof sc; /* service name tag is required, host unique is send too */ -#ifdef PPPOE_TODO - if (sc->sc_service_name != NULL) { - l1 = (int)strlen(sc->sc_service_name); - len += l1; - } - if (sc->sc_concentrator_name != NULL) { - l2 = (int)strlen(sc->sc_concentrator_name); - len += 2 + 2 + l2; - } -#endif /* PPPOE_TODO */ - LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff", - sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff); - - /* allocate a buffer */ - pb = pbuf_alloc(PBUF_LINK, (u16_t)(sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len), PBUF_RAM); - if (!pb) { - return ERR_MEM; - } - LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); - - p = (u8_t*)pb->payload + sizeof (struct eth_hdr); - /* fill in pkt */ - PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, (u16_t)len); - PPPOE_ADD_16(p, PPPOE_TAG_SNAME); -#ifdef PPPOE_TODO - if (sc->sc_service_name != NULL) { - PPPOE_ADD_16(p, l1); - MEMCPY(p, sc->sc_service_name, l1); - p += l1; - } else -#endif /* PPPOE_TODO */ - { - PPPOE_ADD_16(p, 0); - } -#ifdef PPPOE_TODO - if (sc->sc_concentrator_name != NULL) { - PPPOE_ADD_16(p, PPPOE_TAG_ACNAME); - PPPOE_ADD_16(p, l2); - MEMCPY(p, sc->sc_concentrator_name, l2); - p += l2; - } -#endif /* PPPOE_TODO */ - PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); - PPPOE_ADD_16(p, sizeof(sc)); - MEMCPY(p, &sc, sizeof sc); - - /* send pkt */ - return pppoe_output(sc, pb); -} - -static void -pppoe_timeout(void *arg) -{ - int retry_wait, err; - struct pppoe_softc *sc = (struct pppoe_softc*)arg; - - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": timeout\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num)); - - switch (sc->sc_state) { - case PPPOE_STATE_PADI_SENT: - /* - * We have two basic ways of retrying: - * - Quick retry mode: try a few times in short sequence - * - Slow retry mode: we already had a connection successfully - * established and will try infinitely (without user - * intervention) - * We only enter slow retry mode if IFF_LINK1 (aka autodial) - * is not set. - */ - - /* initialize for quick retry mode */ - retry_wait = PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried); - - sc->sc_padi_retried++; - if (sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) { -#if 0 - if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) { - /* slow retry mode */ - retry_wait = PPPOE_SLOW_RETRY; - } else -#endif - { - pppoe_abort_connect(sc); - return; - } - } - if ((err = pppoe_send_padi(sc)) != 0) { - sc->sc_padi_retried--; - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to transmit PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); - } - sys_timeout(retry_wait, pppoe_timeout, sc); - break; - - case PPPOE_STATE_PADR_SENT: - sc->sc_padr_retried++; - if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) { - MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); - sc->sc_state = PPPOE_STATE_PADI_SENT; - sc->sc_padr_retried = 0; - if ((err = pppoe_send_padi(sc)) != 0) { - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); - } - sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried), pppoe_timeout, sc); - return; - } - if ((err = pppoe_send_padr(sc)) != 0) { - sc->sc_padr_retried--; - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADR, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); - } - sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc); - break; - case PPPOE_STATE_CLOSING: - pppoe_do_disconnect(sc); - break; - default: - return; /* all done, work in peace */ - } -} - -/* Start a connection (i.e. initiate discovery phase) */ -int -pppoe_connect(struct pppoe_softc *sc) -{ - int err; - - if (sc->sc_state != PPPOE_STATE_INITIAL) { - return EBUSY; - } - -#ifdef PPPOE_SERVER - /* wait PADI if IFF_PASSIVE */ - if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) { - return 0; - } -#endif - /* save state, in case we fail to send PADI */ - sc->sc_state = PPPOE_STATE_PADI_SENT; - sc->sc_padr_retried = 0; - err = pppoe_send_padi(sc); - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to send PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err)); - sys_timeout(PPPOE_DISC_TIMEOUT, pppoe_timeout, sc); - return err; -} - -/* disconnect */ -void -pppoe_disconnect(struct pppoe_softc *sc) -{ - if (sc->sc_state < PPPOE_STATE_SESSION) { - return; - } - /* - * Do not call pppoe_disconnect here, the upper layer state - * machine gets confused by this. We must return from this - * function and defer disconnecting to the timeout handler. - */ - sc->sc_state = PPPOE_STATE_CLOSING; - sys_timeout(20, pppoe_timeout, sc); -} - -static int -pppoe_do_disconnect(struct pppoe_softc *sc) -{ - int err; - - if (sc->sc_state < PPPOE_STATE_SESSION) { - err = EBUSY; - } else { - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num)); - err = pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest); - } - - /* cleanup softc */ - sc->sc_state = PPPOE_STATE_INITIAL; - MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); - sc->sc_ac_cookie_len = 0; -#ifdef PPPOE_SERVER - if (sc->sc_hunique) { - mem_free(sc->sc_hunique); - sc->sc_hunique = NULL; - } - sc->sc_hunique_len = 0; -#endif - sc->sc_session = 0; - - sc->sc_linkStatusCB(sc->sc_pd, 0); /* notify upper layers */ - - return err; -} - -/* Connection attempt aborted */ -static void -pppoe_abort_connect(struct pppoe_softc *sc) -{ - printf("%c%c%"U16_F": could not establish connection\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); - sc->sc_state = PPPOE_STATE_CLOSING; - - sc->sc_linkStatusCB(sc->sc_pd, 0); /* notify upper layers */ - - /* clear connection state */ - MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); - sc->sc_state = PPPOE_STATE_INITIAL; -} - -/* Send a PADR packet */ -static err_t -pppoe_send_padr(struct pppoe_softc *sc) -{ - struct pbuf *pb; - u8_t *p; - size_t len; -#ifdef PPPOE_TODO - size_t l1 = 0; /* XXX: gcc */ -#endif /* PPPOE_TODO */ - - if (sc->sc_state != PPPOE_STATE_PADR_SENT) { - return ERR_CONN; - } - - len = 2 + 2 + 2 + 2 + sizeof(sc); /* service name, host unique */ -#ifdef PPPOE_TODO - if (sc->sc_service_name != NULL) { /* service name tag maybe empty */ - l1 = strlen(sc->sc_service_name); - len += l1; - } -#endif /* PPPOE_TODO */ - if (sc->sc_ac_cookie_len > 0) { - len += 2 + 2 + sc->sc_ac_cookie_len; /* AC cookie */ - } - LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff", - sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff); - pb = pbuf_alloc(PBUF_LINK, (u16_t)(sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len), PBUF_RAM); - if (!pb) { - return ERR_MEM; - } - LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); - p = (u8_t*)pb->payload + sizeof (struct eth_hdr); - PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len); - PPPOE_ADD_16(p, PPPOE_TAG_SNAME); -#ifdef PPPOE_TODO - if (sc->sc_service_name != NULL) { - PPPOE_ADD_16(p, l1); - MEMCPY(p, sc->sc_service_name, l1); - p += l1; - } else -#endif /* PPPOE_TODO */ - { - PPPOE_ADD_16(p, 0); - } - if (sc->sc_ac_cookie_len > 0) { - PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE); - PPPOE_ADD_16(p, sc->sc_ac_cookie_len); - MEMCPY(p, sc->sc_ac_cookie, sc->sc_ac_cookie_len); - p += sc->sc_ac_cookie_len; - } - PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); - PPPOE_ADD_16(p, sizeof(sc)); - MEMCPY(p, &sc, sizeof sc); - - return pppoe_output(sc, pb); -} - -/* send a PADT packet */ -static err_t -pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest) -{ - struct pbuf *pb; - struct eth_hdr *ethhdr; - err_t res; - u8_t *p; - - pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN, PBUF_RAM); - if (!pb) { - return ERR_MEM; - } - LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); - - ethhdr = (struct eth_hdr *)pb->payload; - ethhdr->type = PP_HTONS(ETHTYPE_PPPOEDISC); - MEMCPY(ethhdr->dest.addr, dest, sizeof(ethhdr->dest.addr)); - MEMCPY(ethhdr->src.addr, ((struct eth_addr *)outgoing_if->hwaddr)->addr, sizeof(ethhdr->src.addr)); - - p = (u8_t*)(ethhdr + 1); - PPPOE_ADD_HEADER(p, PPPOE_CODE_PADT, session, 0); - - res = outgoing_if->linkoutput(outgoing_if, pb); - - pbuf_free(pb); - - return res; -} - -#ifdef PPPOE_SERVER -static err_t -pppoe_send_pado(struct pppoe_softc *sc) -{ - struct pbuf *pb; - u8_t *p; - size_t len; - - if (sc->sc_state != PPPOE_STATE_PADO_SENT) { - return ERR_CONN; - } - - /* calc length */ - len = 0; - /* include ac_cookie */ - len += 2 + 2 + sizeof(sc); - /* include hunique */ - len += 2 + 2 + sc->sc_hunique_len; - pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM); - if (!pb) { - return ERR_MEM; - } - LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); - p = (u8_t*)pb->payload + sizeof (struct eth_hdr); - PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, len); - PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE); - PPPOE_ADD_16(p, sizeof(sc)); - MEMCPY(p, &sc, sizeof(sc)); - p += sizeof(sc); - PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); - PPPOE_ADD_16(p, sc->sc_hunique_len); - MEMCPY(p, sc->sc_hunique, sc->sc_hunique_len); - return pppoe_output(sc, pb); -} - -static err_t -pppoe_send_pads(struct pppoe_softc *sc) -{ - struct pbuf *pb; - u8_t *p; - size_t len, l1 = 0; /* XXX: gcc */ - - if (sc->sc_state != PPPOE_STATE_PADO_SENT) { - return ERR_CONN; - } - - sc->sc_session = mono_time.tv_sec % 0xff + 1; - /* calc length */ - len = 0; - /* include hunique */ - len += 2 + 2 + 2 + 2 + sc->sc_hunique_len; /* service name, host unique*/ - if (sc->sc_service_name != NULL) { /* service name tag maybe empty */ - l1 = strlen(sc->sc_service_name); - len += l1; - } - pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM); - if (!pb) { - return ERR_MEM; - } - LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); - p = (u8_t*)pb->payload + sizeof (struct eth_hdr); - PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, len); - PPPOE_ADD_16(p, PPPOE_TAG_SNAME); - if (sc->sc_service_name != NULL) { - PPPOE_ADD_16(p, l1); - MEMCPY(p, sc->sc_service_name, l1); - p += l1; - } else { - PPPOE_ADD_16(p, 0); - } - PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE); - PPPOE_ADD_16(p, sc->sc_hunique_len); - MEMCPY(p, sc->sc_hunique, sc->sc_hunique_len); - return pppoe_output(sc, pb); -} -#endif - -err_t -pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb) -{ - u8_t *p; - size_t len; - - /* are we ready to process data yet? */ - if (sc->sc_state < PPPOE_STATE_SESSION) { - /*sppp_flush(&sc->sc_sppp.pp_if);*/ - pbuf_free(pb); - return ERR_CONN; - } - - len = pb->tot_len; - - /* make room for Ethernet header - should not fail */ - if (pbuf_header(pb, sizeof(struct eth_hdr) + PPPOE_HEADERLEN) != 0) { - /* bail out */ - PPPDEBUG(LOG_ERR, ("pppoe: %c%c%"U16_F": pppoe_xmit: could not allocate room for header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num)); - LINK_STATS_INC(link.lenerr); - pbuf_free(pb); - return ERR_BUF; - } - - p = (u8_t*)pb->payload + sizeof(struct eth_hdr); - PPPOE_ADD_HEADER(p, 0, sc->sc_session, len); - - return pppoe_output(sc, pb); -} - -#if 0 /*def PFIL_HOOKS*/ -static int -pppoe_ifattach_hook(void *arg, struct pbuf **mp, struct netif *ifp, int dir) -{ - struct pppoe_softc *sc; - int s; - - if (mp != (struct pbuf **)PFIL_IFNET_DETACH) { - return 0; - } - - LIST_FOREACH(sc, &pppoe_softc_list, sc_list) { - if (sc->sc_ethif != ifp) { - continue; - } - if (sc->sc_sppp.pp_if.if_flags & IFF_UP) { - sc->sc_sppp.pp_if.if_flags &= ~(IFF_UP|IFF_RUNNING); - printf("%c%c%"U16_F": ethernet interface detached, going down\n", - sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num); - } - sc->sc_ethif = NULL; - pppoe_clear_softc(sc, "ethernet interface detached"); - } - - return 0; -} -#endif - -static void -pppoe_clear_softc(struct pppoe_softc *sc, const char *message) -{ - LWIP_UNUSED_ARG(message); - - /* stop timer */ - sys_untimeout(pppoe_timeout, sc); - PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": session 0x%x terminated, %s\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_session, message)); - - /* fix our state */ - sc->sc_state = PPPOE_STATE_INITIAL; - - /* notify upper layers */ - sc->sc_linkStatusCB(sc->sc_pd, 0); - - /* clean up softc */ - MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); - sc->sc_ac_cookie_len = 0; - sc->sc_session = 0; -} - -#endif /* PPPOE_SUPPORT */ - diff --git a/user/mpy/lib/lwip/src/netif/ppp/pppdebug.h b/user/mpy/lib/lwip/src/netif/ppp/pppdebug.h deleted file mode 100644 index 8134997..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/pppdebug.h +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************************** -* pppdebug.h - System debugging utilities. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1998 Global Election Systems Inc. -* portions Copyright (c) 2001 by Cognizant Pty Ltd. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY (please don't use tabs!) -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 98-07-29 Guy Lancaster , Global Election Systems Inc. -* Original. -* -***************************************************************************** -*/ -#ifndef PPPDEBUG_H -#define PPPDEBUG_H - -/* Trace levels. */ -#define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) -#define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) -#define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) -#define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) -#define LOG_INFO (PPP_DEBUG) -#define LOG_DETAIL (PPP_DEBUG) -#define LOG_DEBUG (PPP_DEBUG) - - -#define TRACELCP PPP_DEBUG - -#if PPP_DEBUG - -#define AUTHDEBUG(a, b) LWIP_DEBUGF(a, b) -#define IPCPDEBUG(a, b) LWIP_DEBUGF(a, b) -#define UPAPDEBUG(a, b) LWIP_DEBUGF(a, b) -#define LCPDEBUG(a, b) LWIP_DEBUGF(a, b) -#define FSMDEBUG(a, b) LWIP_DEBUGF(a, b) -#define CHAPDEBUG(a, b) LWIP_DEBUGF(a, b) -#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) - -#else /* PPP_DEBUG */ - -#define AUTHDEBUG(a, b) -#define IPCPDEBUG(a, b) -#define UPAPDEBUG(a, b) -#define LCPDEBUG(a, b) -#define FSMDEBUG(a, b) -#define CHAPDEBUG(a, b) -#define PPPDEBUG(a, b) - -#endif /* PPP_DEBUG */ - -#endif /* PPPDEBUG_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/randm.c b/user/mpy/lib/lwip/src/netif/ppp/randm.c deleted file mode 100644 index b736091..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/randm.c +++ /dev/null @@ -1,249 +0,0 @@ -/***************************************************************************** -* randm.c - Random number generator program file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* Copyright (c) 1998 by Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 98-06-03 Guy Lancaster , Global Election Systems Inc. -* Extracted from avos. -*****************************************************************************/ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "md5.h" -#include "randm.h" - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include - -#if MD5_SUPPORT /* this module depends on MD5 */ -#define RANDPOOLSZ 16 /* Bytes stored in the pool of randomness. */ - -/*****************************/ -/*** LOCAL DATA STRUCTURES ***/ -/*****************************/ -static char randPool[RANDPOOLSZ]; /* Pool of randomness. */ -static long randCount = 0; /* Pseudo-random incrementer */ - - -/***********************************/ -/*** PUBLIC FUNCTION DEFINITIONS ***/ -/***********************************/ -/* - * Initialize the random number generator. - * - * Since this is to be called on power up, we don't have much - * system randomess to work with. Here all we use is the - * real-time clock. We'll accumulate more randomness as soon - * as things start happening. - */ -void -avRandomInit() -{ - avChurnRand(NULL, 0); -} - -/* - * Churn the randomness pool on a random event. Call this early and often - * on random and semi-random system events to build randomness in time for - * usage. For randomly timed events, pass a null pointer and a zero length - * and this will use the system timer and other sources to add randomness. - * If new random data is available, pass a pointer to that and it will be - * included. - * - * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 - */ -void -avChurnRand(char *randData, u32_t randLen) -{ - MD5_CTX md5; - - /* LWIP_DEBUGF(LOG_INFO, ("churnRand: %u@%P\n", randLen, randData)); */ - MD5Init(&md5); - MD5Update(&md5, (u_char *)randPool, sizeof(randPool)); - if (randData) { - MD5Update(&md5, (u_char *)randData, randLen); - } else { - struct { - /* INCLUDE fields for any system sources of randomness */ - char foobar; - } sysData; - - /* Load sysData fields here. */ - MD5Update(&md5, (u_char *)&sysData, sizeof(sysData)); - } - MD5Final((u_char *)randPool, &md5); -/* LWIP_DEBUGF(LOG_INFO, ("churnRand: -> 0\n")); */ -} - -/* - * Use the random pool to generate random data. This degrades to pseudo - * random when used faster than randomness is supplied using churnRand(). - * Note: It's important that there be sufficient randomness in randPool - * before this is called for otherwise the range of the result may be - * narrow enough to make a search feasible. - * - * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 - * - * XXX Why does he not just call churnRand() for each block? Probably - * so that you don't ever publish the seed which could possibly help - * predict future values. - * XXX Why don't we preserve md5 between blocks and just update it with - * randCount each time? Probably there is a weakness but I wish that - * it was documented. - */ -void -avGenRand(char *buf, u32_t bufLen) -{ - MD5_CTX md5; - u_char tmp[16]; - u32_t n; - - while (bufLen > 0) { - n = LWIP_MIN(bufLen, RANDPOOLSZ); - MD5Init(&md5); - MD5Update(&md5, (u_char *)randPool, sizeof(randPool)); - MD5Update(&md5, (u_char *)&randCount, sizeof(randCount)); - MD5Final(tmp, &md5); - randCount++; - MEMCPY(buf, tmp, n); - buf += n; - bufLen -= n; - } -} - -/* - * Return a new random number. - */ -u32_t -avRandom() -{ - u32_t newRand; - - avGenRand((char *)&newRand, sizeof(newRand)); - - return newRand; -} - -#else /* MD5_SUPPORT */ - -/*****************************/ -/*** LOCAL DATA STRUCTURES ***/ -/*****************************/ -static int avRandomized = 0; /* Set when truely randomized. */ -static u32_t avRandomSeed = 0; /* Seed used for random number generation. */ - - -/***********************************/ -/*** PUBLIC FUNCTION DEFINITIONS ***/ -/***********************************/ -/* - * Initialize the random number generator. - * - * Here we attempt to compute a random number seed but even if - * it isn't random, we'll randomize it later. - * - * The current method uses the fields from the real time clock, - * the idle process counter, the millisecond counter, and the - * hardware timer tick counter. When this is invoked - * in startup(), then the idle counter and timer values may - * repeat after each boot and the real time clock may not be - * operational. Thus we call it again on the first random - * event. - */ -void -avRandomInit() -{ -#if 0 - /* Get a pointer into the last 4 bytes of clockBuf. */ - u32_t *lptr1 = (u32_t *)((char *)&clockBuf[3]); - - /* - * Initialize our seed using the real-time clock, the idle - * counter, the millisecond timer, and the hardware timer - * tick counter. The real-time clock and the hardware - * tick counter are the best sources of randomness but - * since the tick counter is only 16 bit (and truncated - * at that), the idle counter and millisecond timer - * (which may be small values) are added to help - * randomize the lower 16 bits of the seed. - */ - readClk(); - avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr - + ppp_mtime() + ((u32_t)TM1 << 16) + TM1; -#else - avRandomSeed += sys_jiffies(); /* XXX */ -#endif - - /* Initialize the Borland random number generator. */ - srand((unsigned)avRandomSeed); -} - -/* - * Randomize our random seed value. Here we use the fact that - * this function is called at *truely random* times by the polling - * and network functions. Here we only get 16 bits of new random - * value but we use the previous value to randomize the other 16 - * bits. - */ -void -avRandomize(void) -{ - static u32_t last_jiffies; - - if (!avRandomized) { - avRandomized = !0; - avRandomInit(); - /* The initialization function also updates the seed. */ - } else { - /* avRandomSeed += (avRandomSeed << 16) + TM1; */ - avRandomSeed += (sys_jiffies() - last_jiffies); /* XXX */ - } - last_jiffies = sys_jiffies(); -} - -/* - * Return a new random number. - * Here we use the Borland rand() function to supply a pseudo random - * number which we make truely random by combining it with our own - * seed which is randomized by truely random events. - * Thus the numbers will be truely random unless there have been no - * operator or network events in which case it will be pseudo random - * seeded by the real time clock. - */ -u32_t -avRandom() -{ - return ((((u32_t)rand() << 16) + rand()) + avRandomSeed); -} - -#endif /* MD5_SUPPORT */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/randm.h b/user/mpy/lib/lwip/src/netif/ppp/randm.h deleted file mode 100644 index a0984b0..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/randm.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** -* randm.h - Random number generator header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* Copyright (c) 1998 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 98-05-29 Guy Lancaster , Global Election Systems Inc. -* Extracted from avos. -*****************************************************************************/ - -#ifndef RANDM_H -#define RANDM_H - -/*********************** -*** PUBLIC FUNCTIONS *** -***********************/ -/* - * Initialize the random number generator. - */ -void avRandomInit(void); - -/* - * Churn the randomness pool on a random event. Call this early and often - * on random and semi-random system events to build randomness in time for - * usage. For randomly timed events, pass a null pointer and a zero length - * and this will use the system timer and other sources to add randomness. - * If new random data is available, pass a pointer to that and it will be - * included. - */ -void avChurnRand(char *randData, u32_t randLen); - -/* - * Randomize our random seed value. To be called for truely random events - * such as user operations and network traffic. - */ -#if MD5_SUPPORT -#define avRandomize() avChurnRand(NULL, 0) -#else /* MD5_SUPPORT */ -void avRandomize(void); -#endif /* MD5_SUPPORT */ - -/* - * Use the random pool to generate random data. This degrades to pseudo - * random when used faster than randomness is supplied using churnRand(). - * Thus it's important to make sure that the results of this are not - * published directly because one could predict the next result to at - * least some degree. Also, it's important to get a good seed before - * the first use. - */ -void avGenRand(char *buf, u32_t bufLen); - -/* - * Return a new random number. - */ -u32_t avRandom(void); - - -#endif /* RANDM_H */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/vj.c b/user/mpy/lib/lwip/src/netif/ppp/vj.c deleted file mode 100644 index 40fdad1..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/vj.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * Routines to compress and uncompess tcp packets (for transmission - * over low speed serial lines. - * - * Copyright (c) 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: - * Initial distribution. - * - * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au, - * so that the entire packet being decompressed doesn't have - * to be in contiguous memory (just the compressed header). - * - * Modified March 1998 by Guy Lancaster, glanca@gesn.com, - * for a 16 bit processor. - */ - -#include "lwip/opt.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#include "ppp_impl.h" -#include "pppdebug.h" - -#include "vj.h" - -#include - -#if VJ_SUPPORT - -#if LINK_STATS -#define INCR(counter) ++comp->stats.counter -#else -#define INCR(counter) -#endif - -void -vj_compress_init(struct vjcompress *comp) -{ - register u_char i; - register struct cstate *tstate = comp->tstate; - -#if MAX_SLOTS == 0 - memset((char *)comp, 0, sizeof(*comp)); -#endif - comp->maxSlotIndex = MAX_SLOTS - 1; - comp->compressSlot = 0; /* Disable slot ID compression by default. */ - for (i = MAX_SLOTS - 1; i > 0; --i) { - tstate[i].cs_id = i; - tstate[i].cs_next = &tstate[i - 1]; - } - tstate[0].cs_next = &tstate[MAX_SLOTS - 1]; - tstate[0].cs_id = 0; - comp->last_cs = &tstate[0]; - comp->last_recv = 255; - comp->last_xmit = 255; - comp->flags = VJF_TOSS; -} - - -/* ENCODE encodes a number that is known to be non-zero. ENCODEZ - * checks for zero (since zero has to be encoded in the long, 3 byte - * form). - */ -#define ENCODE(n) { \ - if ((u_short)(n) >= 256) { \ - *cp++ = 0; \ - cp[1] = (u_char)(n); \ - cp[0] = (u_char)((n) >> 8); \ - cp += 2; \ - } else { \ - *cp++ = (u_char)(n); \ - } \ -} -#define ENCODEZ(n) { \ - if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \ - *cp++ = 0; \ - cp[1] = (u_char)(n); \ - cp[0] = (u_char)((n) >> 8); \ - cp += 2; \ - } else { \ - *cp++ = (u_char)(n); \ - } \ -} - -#define DECODEL(f) { \ - if (*cp == 0) {\ - u32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \ - (f) = htonl(tmp); \ - cp += 3; \ - } else { \ - u32_t tmp = ntohl(f) + (u32_t)*cp++; \ - (f) = htonl(tmp); \ - } \ -} - -#define DECODES(f) { \ - if (*cp == 0) {\ - u_short tmp = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \ - (f) = htons(tmp); \ - cp += 3; \ - } else { \ - u_short tmp = ntohs(f) + (u_short)*cp++; \ - (f) = htons(tmp); \ - } \ -} - -#define DECODEU(f) { \ - if (*cp == 0) {\ - (f) = htons(((u_short)cp[1] << 8) | cp[2]); \ - cp += 3; \ - } else { \ - (f) = htons((u_short)*cp++); \ - } \ -} - -/* - * vj_compress_tcp - Attempt to do Van Jacobson header compression on a - * packet. This assumes that nb and comp are not null and that the first - * buffer of the chain contains a valid IP header. - * Return the VJ type code indicating whether or not the packet was - * compressed. - */ -u_int -vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) -{ - register struct ip_hdr *ip = (struct ip_hdr *)pb->payload; - register struct cstate *cs = comp->last_cs->cs_next; - register u_short hlen = IPH_HL(ip); - register struct tcp_hdr *oth; - register struct tcp_hdr *th; - register u_short deltaS, deltaA; - register u_long deltaL; - register u_int changes = 0; - u_char new_seq[16]; - register u_char *cp = new_seq; - - /* - * Check that the packet is IP proto TCP. - */ - if (IPH_PROTO(ip) != IP_PROTO_TCP) { - return (TYPE_IP); - } - - /* - * Bail if this is an IP fragment or if the TCP packet isn't - * `compressible' (i.e., ACK isn't set or some other control bit is - * set). - */ - if ((IPH_OFFSET(ip) & PP_HTONS(0x3fff)) || pb->tot_len < 40) { - return (TYPE_IP); - } - th = (struct tcp_hdr *)&((long *)ip)[hlen]; - if ((TCPH_FLAGS(th) & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK) { - return (TYPE_IP); - } - /* - * Packet is compressible -- we're going to send either a - * COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need - * to locate (or create) the connection state. Special case the - * most recently used connection since it's most likely to be used - * again & we don't have to do any reordering if it's used. - */ - INCR(vjs_packets); - if (!ip_addr_cmp(&ip->src, &cs->cs_ip.src) - || !ip_addr_cmp(&ip->dest, &cs->cs_ip.dest) - || *(long *)th != ((long *)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { - /* - * Wasn't the first -- search for it. - * - * States are kept in a circularly linked list with - * last_cs pointing to the end of the list. The - * list is kept in lru order by moving a state to the - * head of the list whenever it is referenced. Since - * the list is short and, empirically, the connection - * we want is almost always near the front, we locate - * states via linear search. If we don't find a state - * for the datagram, the oldest state is (re-)used. - */ - register struct cstate *lcs; - register struct cstate *lastcs = comp->last_cs; - - do { - lcs = cs; cs = cs->cs_next; - INCR(vjs_searches); - if (ip_addr_cmp(&ip->src, &cs->cs_ip.src) - && ip_addr_cmp(&ip->dest, &cs->cs_ip.dest) - && *(long *)th == ((long *)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { - goto found; - } - } while (cs != lastcs); - - /* - * Didn't find it -- re-use oldest cstate. Send an - * uncompressed packet that tells the other side what - * connection number we're using for this conversation. - * Note that since the state list is circular, the oldest - * state points to the newest and we only need to set - * last_cs to update the lru linkage. - */ - INCR(vjs_misses); - comp->last_cs = lcs; - hlen += TCPH_HDRLEN(th); - hlen <<= 2; - /* Check that the IP/TCP headers are contained in the first buffer. */ - if (hlen > pb->len) { - return (TYPE_IP); - } - goto uncompressed; - - found: - /* - * Found it -- move to the front on the connection list. - */ - if (cs == lastcs) { - comp->last_cs = lcs; - } else { - lcs->cs_next = cs->cs_next; - cs->cs_next = lastcs->cs_next; - lastcs->cs_next = cs; - } - } - - oth = (struct tcp_hdr *)&((long *)&cs->cs_ip)[hlen]; - deltaS = hlen; - hlen += TCPH_HDRLEN(th); - hlen <<= 2; - /* Check that the IP/TCP headers are contained in the first buffer. */ - if (hlen > pb->len) { - PPPDEBUG(LOG_INFO, ("vj_compress_tcp: header len %d spans buffers\n", hlen)); - return (TYPE_IP); - } - - /* - * Make sure that only what we expect to change changed. The first - * line of the `if' checks the IP protocol version, header length & - * type of service. The 2nd line checks the "Don't fragment" bit. - * The 3rd line checks the time-to-live and protocol (the protocol - * check is unnecessary but costless). The 4th line checks the TCP - * header length. The 5th line checks IP options, if any. The 6th - * line checks TCP options, if any. If any of these things are - * different between the previous & current datagram, we send the - * current datagram `uncompressed'. - */ - if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] - || ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] - || ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] - || TCPH_HDRLEN(th) != TCPH_HDRLEN(oth) - || (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) - || (TCPH_HDRLEN(th) > 5 && BCMP(th + 1, oth + 1, (TCPH_HDRLEN(th) - 5) << 2))) { - goto uncompressed; - } - - /* - * Figure out which of the changing fields changed. The - * receiver expects changes in the order: urgent, window, - * ack, seq (the order minimizes the number of temporaries - * needed in this section of code). - */ - if (TCPH_FLAGS(th) & TCP_URG) { - deltaS = ntohs(th->urgp); - ENCODEZ(deltaS); - changes |= NEW_U; - } else if (th->urgp != oth->urgp) { - /* argh! URG not set but urp changed -- a sensible - * implementation should never do this but RFC793 - * doesn't prohibit the change so we have to deal - * with it. */ - goto uncompressed; - } - - if ((deltaS = (u_short)(ntohs(th->wnd) - ntohs(oth->wnd))) != 0) { - ENCODE(deltaS); - changes |= NEW_W; - } - - if ((deltaL = ntohl(th->ackno) - ntohl(oth->ackno)) != 0) { - if (deltaL > 0xffff) { - goto uncompressed; - } - deltaA = (u_short)deltaL; - ENCODE(deltaA); - changes |= NEW_A; - } - - if ((deltaL = ntohl(th->seqno) - ntohl(oth->seqno)) != 0) { - if (deltaL > 0xffff) { - goto uncompressed; - } - deltaS = (u_short)deltaL; - ENCODE(deltaS); - changes |= NEW_S; - } - - switch(changes) { - case 0: - /* - * Nothing changed. If this packet contains data and the - * last one didn't, this is probably a data packet following - * an ack (normal on an interactive connection) and we send - * it compressed. Otherwise it's probably a retransmit, - * retransmitted ack or window probe. Send it uncompressed - * in case the other side missed the compressed version. - */ - if (IPH_LEN(ip) != IPH_LEN(&cs->cs_ip) && - ntohs(IPH_LEN(&cs->cs_ip)) == hlen) { - break; - } - - /* (fall through) */ - - case SPECIAL_I: - case SPECIAL_D: - /* - * actual changes match one of our special case encodings -- - * send packet uncompressed. - */ - goto uncompressed; - - case NEW_S|NEW_A: - if (deltaS == deltaA && deltaS == ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { - /* special case for echoed terminal traffic */ - changes = SPECIAL_I; - cp = new_seq; - } - break; - - case NEW_S: - if (deltaS == ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { - /* special case for data xfer */ - changes = SPECIAL_D; - cp = new_seq; - } - break; - } - - deltaS = (u_short)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip))); - if (deltaS != 1) { - ENCODEZ(deltaS); - changes |= NEW_I; - } - if (TCPH_FLAGS(th) & TCP_PSH) { - changes |= TCP_PUSH_BIT; - } - /* - * Grab the cksum before we overwrite it below. Then update our - * state with this packet's header. - */ - deltaA = ntohs(th->chksum); - BCOPY(ip, &cs->cs_ip, hlen); - - /* - * We want to use the original packet as our compressed packet. - * (cp - new_seq) is the number of bytes we need for compressed - * sequence numbers. In addition we need one byte for the change - * mask, one for the connection id and two for the tcp checksum. - * So, (cp - new_seq) + 4 bytes of header are needed. hlen is how - * many bytes of the original packet to toss so subtract the two to - * get the new packet size. - */ - deltaS = (u_short)(cp - new_seq); - if (!comp->compressSlot || comp->last_xmit != cs->cs_id) { - comp->last_xmit = cs->cs_id; - hlen -= deltaS + 4; - if(pbuf_header(pb, -hlen)){ - /* Can we cope with this failing? Just assert for now */ - LWIP_ASSERT("pbuf_header failed\n", 0); - } - cp = (u_char *)pb->payload; - *cp++ = (u_char)(changes | NEW_C); - *cp++ = cs->cs_id; - } else { - hlen -= deltaS + 3; - if(pbuf_header(pb, -hlen)) { - /* Can we cope with this failing? Just assert for now */ - LWIP_ASSERT("pbuf_header failed\n", 0); - } - cp = (u_char *)pb->payload; - *cp++ = (u_char)changes; - } - *cp++ = (u_char)(deltaA >> 8); - *cp++ = (u_char)deltaA; - BCOPY(new_seq, cp, deltaS); - INCR(vjs_compressed); - return (TYPE_COMPRESSED_TCP); - - /* - * Update connection state cs & send uncompressed packet (that is, - * a regular ip/tcp packet but with the 'conversation id' we hope - * to use on future compressed packets in the protocol field). - */ -uncompressed: - BCOPY(ip, &cs->cs_ip, hlen); - IPH_PROTO_SET(ip, cs->cs_id); - comp->last_xmit = cs->cs_id; - return (TYPE_UNCOMPRESSED_TCP); -} - -/* - * Called when we may have missed a packet. - */ -void -vj_uncompress_err(struct vjcompress *comp) -{ - comp->flags |= VJF_TOSS; - INCR(vjs_errorin); -} - -/* - * "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP. - * Return 0 on success, -1 on failure. - */ -int -vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) -{ - register u_int hlen; - register struct cstate *cs; - register struct ip_hdr *ip; - - ip = (struct ip_hdr *)nb->payload; - hlen = IPH_HL(ip) << 2; - if (IPH_PROTO(ip) >= MAX_SLOTS - || hlen + sizeof(struct tcp_hdr) > nb->len - || (hlen += TCPH_HDRLEN(((struct tcp_hdr *)&((char *)ip)[hlen])) << 2) - > nb->len - || hlen > MAX_HDR) { - PPPDEBUG(LOG_INFO, ("vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n", - IPH_PROTO(ip), hlen, nb->len)); - comp->flags |= VJF_TOSS; - INCR(vjs_errorin); - return -1; - } - cs = &comp->rstate[comp->last_recv = IPH_PROTO(ip)]; - comp->flags &=~ VJF_TOSS; - IPH_PROTO_SET(ip, IP_PROTO_TCP); - BCOPY(ip, &cs->cs_ip, hlen); - cs->cs_hlen = (u_short)hlen; - INCR(vjs_uncompressedin); - return 0; -} - -/* - * Uncompress a packet of type TYPE_COMPRESSED_TCP. - * The packet is composed of a buffer chain and the first buffer - * must contain an accurate chain length. - * The first buffer must include the entire compressed TCP/IP header. - * This procedure replaces the compressed header with the uncompressed - * header and returns the length of the VJ header. - */ -int -vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) -{ - u_char *cp; - struct tcp_hdr *th; - struct cstate *cs; - u_short *bp; - struct pbuf *n0 = *nb; - u32_t tmp; - u_int vjlen, hlen, changes; - - INCR(vjs_compressedin); - cp = (u_char *)n0->payload; - changes = *cp++; - if (changes & NEW_C) { - /* - * Make sure the state index is in range, then grab the state. - * If we have a good state index, clear the 'discard' flag. - */ - if (*cp >= MAX_SLOTS) { - PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: bad cid=%d\n", *cp)); - goto bad; - } - - comp->flags &=~ VJF_TOSS; - comp->last_recv = *cp++; - } else { - /* - * this packet has an implicit state index. If we've - * had a line error since the last time we got an - * explicit state index, we have to toss the packet. - */ - if (comp->flags & VJF_TOSS) { - PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: tossing\n")); - INCR(vjs_tossed); - return (-1); - } - } - cs = &comp->rstate[comp->last_recv]; - hlen = IPH_HL(&cs->cs_ip) << 2; - th = (struct tcp_hdr *)&((u_char *)&cs->cs_ip)[hlen]; - th->chksum = htons((*cp << 8) | cp[1]); - cp += 2; - if (changes & TCP_PUSH_BIT) { - TCPH_SET_FLAG(th, TCP_PSH); - } else { - TCPH_UNSET_FLAG(th, TCP_PSH); - } - - switch (changes & SPECIALS_MASK) { - case SPECIAL_I: - { - register u32_t i = ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; - /* some compilers can't nest inline assembler.. */ - tmp = ntohl(th->ackno) + i; - th->ackno = htonl(tmp); - tmp = ntohl(th->seqno) + i; - th->seqno = htonl(tmp); - } - break; - - case SPECIAL_D: - /* some compilers can't nest inline assembler.. */ - tmp = ntohl(th->seqno) + ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; - th->seqno = htonl(tmp); - break; - - default: - if (changes & NEW_U) { - TCPH_SET_FLAG(th, TCP_URG); - DECODEU(th->urgp); - } else { - TCPH_UNSET_FLAG(th, TCP_URG); - } - if (changes & NEW_W) { - DECODES(th->wnd); - } - if (changes & NEW_A) { - DECODEL(th->ackno); - } - if (changes & NEW_S) { - DECODEL(th->seqno); - } - break; - } - if (changes & NEW_I) { - DECODES(cs->cs_ip._id); - } else { - IPH_ID_SET(&cs->cs_ip, ntohs(IPH_ID(&cs->cs_ip)) + 1); - IPH_ID_SET(&cs->cs_ip, htons(IPH_ID(&cs->cs_ip))); - } - - /* - * At this point, cp points to the first byte of data in the - * packet. Fill in the IP total length and update the IP - * header checksum. - */ - vjlen = (u_short)(cp - (u_char*)n0->payload); - if (n0->len < vjlen) { - /* - * We must have dropped some characters (crc should detect - * this but the old slip framing won't) - */ - PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: head buffer %d too short %d\n", - n0->len, vjlen)); - goto bad; - } - -#if BYTE_ORDER == LITTLE_ENDIAN - tmp = n0->tot_len - vjlen + cs->cs_hlen; - IPH_LEN_SET(&cs->cs_ip, htons((u_short)tmp)); -#else - IPH_LEN_SET(&cs->cs_ip, htons(n0->tot_len - vjlen + cs->cs_hlen)); -#endif - - /* recompute the ip header checksum */ - bp = (u_short *) &cs->cs_ip; - IPH_CHKSUM_SET(&cs->cs_ip, 0); - for (tmp = 0; hlen > 0; hlen -= 2) { - tmp += *bp++; - } - tmp = (tmp & 0xffff) + (tmp >> 16); - tmp = (tmp & 0xffff) + (tmp >> 16); - IPH_CHKSUM_SET(&cs->cs_ip, (u_short)(~tmp)); - - /* Remove the compressed header and prepend the uncompressed header. */ - if(pbuf_header(n0, -((s16_t)(vjlen)))) { - /* Can we cope with this failing? Just assert for now */ - LWIP_ASSERT("pbuf_header failed\n", 0); - goto bad; - } - - if(LWIP_MEM_ALIGN(n0->payload) != n0->payload) { - struct pbuf *np, *q; - u8_t *bufptr; - - np = pbuf_alloc(PBUF_RAW, n0->len + cs->cs_hlen, PBUF_POOL); - if(!np) { - PPPDEBUG(LOG_WARNING, ("vj_uncompress_tcp: realign failed\n")); - goto bad; - } - - if(pbuf_header(np, -cs->cs_hlen)) { - /* Can we cope with this failing? Just assert for now */ - LWIP_ASSERT("pbuf_header failed\n", 0); - goto bad; - } - - bufptr = n0->payload; - for(q = np; q != NULL; q = q->next) { - MEMCPY(q->payload, bufptr, q->len); - bufptr += q->len; - } - - if(n0->next) { - pbuf_chain(np, n0->next); - pbuf_dechain(n0); - } - pbuf_free(n0); - n0 = np; - } - - if(pbuf_header(n0, cs->cs_hlen)) { - struct pbuf *np; - - LWIP_ASSERT("vj_uncompress_tcp: cs->cs_hlen <= PBUF_POOL_BUFSIZE", cs->cs_hlen <= PBUF_POOL_BUFSIZE); - np = pbuf_alloc(PBUF_RAW, cs->cs_hlen, PBUF_POOL); - if(!np) { - PPPDEBUG(LOG_WARNING, ("vj_uncompress_tcp: prepend failed\n")); - goto bad; - } - pbuf_cat(np, n0); - n0 = np; - } - LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen); - MEMCPY(n0->payload, &cs->cs_ip, cs->cs_hlen); - - *nb = n0; - - return vjlen; - -bad: - comp->flags |= VJF_TOSS; - INCR(vjs_errorin); - return (-1); -} - -#endif /* VJ_SUPPORT */ - -#endif /* PPP_SUPPORT */ diff --git a/user/mpy/lib/lwip/src/netif/ppp/vj.h b/user/mpy/lib/lwip/src/netif/ppp/vj.h deleted file mode 100644 index fad1213..0000000 --- a/user/mpy/lib/lwip/src/netif/ppp/vj.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Definitions for tcp compression routines. - * - * $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $ - * - * Copyright (c) 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: - * - Initial distribution. - */ - -#ifndef VJ_H -#define VJ_H - -#include "lwip/ip.h" -#include "lwip/tcp_impl.h" - -#define MAX_SLOTS 16 /* must be > 2 and < 256 */ -#define MAX_HDR 128 - -/* - * Compressed packet format: - * - * The first octet contains the packet type (top 3 bits), TCP - * 'push' bit, and flags that indicate which of the 4 TCP sequence - * numbers have changed (bottom 5 bits). The next octet is a - * conversation number that associates a saved IP/TCP header with - * the compressed packet. The next two octets are the TCP checksum - * from the original datagram. The next 0 to 15 octets are - * sequence number changes, one change per bit set in the header - * (there may be no changes and there are two special cases where - * the receiver implicitly knows what changed -- see below). - * - * There are 5 numbers which can change (they are always inserted - * in the following order): TCP urgent pointer, window, - * acknowlegement, sequence number and IP ID. (The urgent pointer - * is different from the others in that its value is sent, not the - * change in value.) Since typical use of SLIP links is biased - * toward small packets (see comments on MTU/MSS below), changes - * use a variable length coding with one octet for numbers in the - * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the - * range 256 - 65535 or 0. (If the change in sequence number or - * ack is more than 65535, an uncompressed packet is sent.) - */ - -/* - * Packet types (must not conflict with IP protocol version) - * - * The top nibble of the first octet is the packet type. There are - * three possible types: IP (not proto TCP or tcp with one of the - * control flags set); uncompressed TCP (a normal IP/TCP packet but - * with the 8-bit protocol field replaced by an 8-bit connection id -- - * this type of packet syncs the sender & receiver); and compressed - * TCP (described above). - * - * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and - * is logically part of the 4-bit "changes" field that follows. Top - * three bits are actual packet type. For backward compatibility - * and in the interest of conserving bits, numbers are chosen so the - * IP protocol version number (4) which normally appears in this nibble - * means "IP packet". - */ - -/* packet types */ -#define TYPE_IP 0x40 -#define TYPE_UNCOMPRESSED_TCP 0x70 -#define TYPE_COMPRESSED_TCP 0x80 -#define TYPE_ERROR 0x00 - -/* Bits in first octet of compressed packet */ -#define NEW_C 0x40 /* flag bits for what changed in a packet */ -#define NEW_I 0x20 -#define NEW_S 0x08 -#define NEW_A 0x04 -#define NEW_W 0x02 -#define NEW_U 0x01 - -/* reserved, special-case values of above */ -#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ -#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ -#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) - -#define TCP_PUSH_BIT 0x10 - - -/* - * "state" data for each active tcp conversation on the wire. This is - * basically a copy of the entire IP/TCP header from the last packet - * we saw from the conversation together with a small identifier - * the transmit & receive ends of the line use to locate saved header. - */ -struct cstate { - struct cstate *cs_next; /* next most recently used state (xmit only) */ - u_short cs_hlen; /* size of hdr (receive only) */ - u_char cs_id; /* connection # associated with this state */ - u_char cs_filler; - union { - char csu_hdr[MAX_HDR]; - struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */ - } vjcs_u; -}; -#define cs_ip vjcs_u.csu_ip -#define cs_hdr vjcs_u.csu_hdr - - -struct vjstat { - unsigned long vjs_packets; /* outbound packets */ - unsigned long vjs_compressed; /* outbound compressed packets */ - unsigned long vjs_searches; /* searches for connection state */ - unsigned long vjs_misses; /* times couldn't find conn. state */ - unsigned long vjs_uncompressedin; /* inbound uncompressed packets */ - unsigned long vjs_compressedin; /* inbound compressed packets */ - unsigned long vjs_errorin; /* inbound unknown type packets */ - unsigned long vjs_tossed; /* inbound packets tossed because of error */ -}; - -/* - * all the state data for one serial line (we need one of these per line). - */ -struct vjcompress { - struct cstate *last_cs; /* most recently used tstate */ - u_char last_recv; /* last rcvd conn. id */ - u_char last_xmit; /* last sent conn. id */ - u_short flags; - u_char maxSlotIndex; - u_char compressSlot; /* Flag indicating OK to compress slot ID. */ -#if LINK_STATS - struct vjstat stats; -#endif - struct cstate tstate[MAX_SLOTS]; /* xmit connection states */ - struct cstate rstate[MAX_SLOTS]; /* receive connection states */ -}; - -/* flag values */ -#define VJF_TOSS 1U /* tossing rcvd frames because of input err */ - -extern void vj_compress_init (struct vjcompress *comp); -extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb); -extern void vj_uncompress_err (struct vjcompress *comp); -extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp); -extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp); - -#endif /* VJ_H */ diff --git a/user/mpy/lib/lwip/src/netif/slipif.c b/user/mpy/lib/lwip/src/netif/slipif.c deleted file mode 100644 index 2777630..0000000 --- a/user/mpy/lib/lwip/src/netif/slipif.c +++ /dev/null @@ -1,510 +0,0 @@ -/** - * @file - * SLIP Interface - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is built upon the file: src/arch/rtxc/netif/sioslip.c - * - * Author: Magnus Ivarsson - * Simon Goldschmidt - * - * Usage: This netif can be used in three ways: - * 1) For NO_SYS==0, an RX thread can be used which blocks on sio_read() - * until data is received. - * 2) In your main loop, call slipif_poll() to check for new RX bytes, - * completed packets are fed into netif->input(). - * 3) Call slipif_received_byte[s]() from your serial RX ISR and - * slipif_process_rxqueue() from your main loop. ISR level decodes - * packets and puts completed packets on a queue which is fed into - * the stack from the main loop (needs SYS_LIGHTWEIGHT_PROT for - * pbuf_alloc to work on ISR level!). - * - */ - -/* - * This is an arch independent SLIP netif. The specific serial hooks must be - * provided by another file. They are sio_open, sio_read/sio_tryread and sio_send - */ - -#include "netif/slipif.h" -#include "lwip/opt.h" - -#if LWIP_HAVE_SLIPIF - -#include "lwip/def.h" -#include "lwip/pbuf.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "lwip/sio.h" -#include "lwip/sys.h" - -#define SLIP_END 0xC0 /* 0300: start and end of every packet */ -#define SLIP_ESC 0xDB /* 0333: escape start (one byte escaped data follows) */ -#define SLIP_ESC_END 0xDC /* 0334: following escape: original byte is 0xC0 (END) */ -#define SLIP_ESC_ESC 0xDD /* 0335: following escape: original byte is 0xDB (ESC) */ - -/** Maximum packet size that is received by this netif */ -#ifndef SLIP_MAX_SIZE -#define SLIP_MAX_SIZE 1500 -#endif - -/** Define this to the interface speed for SNMP - * (sio_fd is the sio_fd_t returned by sio_open). - * The default value of zero means 'unknown'. - */ -#ifndef SLIP_SIO_SPEED -#define SLIP_SIO_SPEED(sio_fd) 0 -#endif - -enum slipif_recv_state { - SLIP_RECV_NORMAL, - SLIP_RECV_ESCAPE, -}; - -struct slipif_priv { - sio_fd_t sd; - /* q is the whole pbuf chain for a packet, p is the current pbuf in the chain */ - struct pbuf *p, *q; - u8_t state; - u16_t i, recved; -#if SLIP_RX_FROM_ISR - struct pbuf *rxpackets; -#endif -}; - -/** - * Send a pbuf doing the necessary SLIP encapsulation - * - * Uses the serial layer's sio_send() - * - * @param netif the lwip network interface structure for this slipif - * @param p the pbuf chaing packet to send - * @param ipaddr the ip address to send the packet to (not used for slipif) - * @return always returns ERR_OK since the serial layer does not provide return values - */ -err_t -slipif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) -{ - struct slipif_priv *priv; - struct pbuf *q; - u16_t i; - u8_t c; - - LWIP_ASSERT("netif != NULL", (netif != NULL)); - LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); - LWIP_ASSERT("p != NULL", (p != NULL)); - - LWIP_UNUSED_ARG(ipaddr); - - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_output(%"U16_F"): sending %"U16_F" bytes\n", (u16_t)netif->num, p->tot_len)); - priv = netif->state; - - /* Send pbuf out on the serial I/O device. */ - /* Start with packet delimiter. */ - sio_send(SLIP_END, priv->sd); - - for (q = p; q != NULL; q = q->next) { - for (i = 0; i < q->len; i++) { - c = ((u8_t *)q->payload)[i]; - switch (c) { - case SLIP_END: - /* need to escape this byte (0xC0 -> 0xDB, 0xDC) */ - sio_send(SLIP_ESC, priv->sd); - sio_send(SLIP_ESC_END, priv->sd); - break; - case SLIP_ESC: - /* need to escape this byte (0xDB -> 0xDB, 0xDD) */ - sio_send(SLIP_ESC, priv->sd); - sio_send(SLIP_ESC_ESC, priv->sd); - break; - default: - /* normal byte - no need for escaping */ - sio_send(c, priv->sd); - break; - } - } - } - /* End with packet delimiter. */ - sio_send(SLIP_END, priv->sd); - return ERR_OK; -} - -/** - * Handle the incoming SLIP stream character by character - * - * @param netif the lwip network interface structure for this slipif - * @param c received character (multiple calls to this function will - * return a complete packet, NULL is returned before - used for polling) - * @return The IP packet when SLIP_END is received - */ -static struct pbuf* -slipif_rxbyte(struct netif *netif, u8_t c) -{ - struct slipif_priv *priv; - struct pbuf *t; - - LWIP_ASSERT("netif != NULL", (netif != NULL)); - LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); - - priv = netif->state; - - switch (priv->state) { - case SLIP_RECV_NORMAL: - switch (c) { - case SLIP_END: - if (priv->recved > 0) { - /* Received whole packet. */ - /* Trim the pbuf to the size of the received packet. */ - pbuf_realloc(priv->q, priv->recved); - - LINK_STATS_INC(link.recv); - - LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet (%"U16_F" bytes)\n", priv->recved)); - t = priv->q; - priv->p = priv->q = NULL; - priv->i = priv->recved = 0; - return t; - } - return NULL; - case SLIP_ESC: - priv->state = SLIP_RECV_ESCAPE; - return NULL; - } /* end switch (c) */ - break; - case SLIP_RECV_ESCAPE: - /* un-escape END or ESC bytes, leave other bytes - (although that would be a protocol error) */ - switch (c) { - case SLIP_ESC_END: - c = SLIP_END; - break; - case SLIP_ESC_ESC: - c = SLIP_ESC; - break; - } - priv->state = SLIP_RECV_NORMAL; - break; - } /* end switch (priv->state) */ - - /* byte received, packet not yet completely received */ - if (priv->p == NULL) { - /* allocate a new pbuf */ - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n")); - priv->p = pbuf_alloc(PBUF_LINK, (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN), PBUF_POOL); - - if (priv->p == NULL) { - LINK_STATS_INC(link.drop); - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n")); - /* don't process any further since we got no pbuf to receive to */ - return NULL; - } - - if (priv->q != NULL) { - /* 'chain' the pbuf to the existing chain */ - pbuf_cat(priv->q, priv->p); - } else { - /* p is the first pbuf in the chain */ - priv->q = priv->p; - } - } - - /* this automatically drops bytes if > SLIP_MAX_SIZE */ - if ((priv->p != NULL) && (priv->recved <= SLIP_MAX_SIZE)) { - ((u8_t *)priv->p->payload)[priv->i] = c; - priv->recved++; - priv->i++; - if (priv->i >= priv->p->len) { - /* on to the next pbuf */ - priv->i = 0; - if (priv->p->next != NULL && priv->p->next->len > 0) { - /* p is a chain, on to the next in the chain */ - priv->p = priv->p->next; - } else { - /* p is a single pbuf, set it to NULL so next time a new - * pbuf is allocated */ - priv->p = NULL; - } - } - } - return NULL; -} - -/** Like slipif_rxbyte, but passes completed packets to netif->input - * - * @param netif The lwip network interface structure for this slipif - * @param data received character - */ -static void -slipif_rxbyte_input(struct netif *netif, u8_t c) -{ - struct pbuf *p; - p = slipif_rxbyte(netif, c); - if (p != NULL) { - if (netif->input(p, netif) != ERR_OK) { - pbuf_free(p); - } - } -} - -#if SLIP_USE_RX_THREAD -/** - * The SLIP input thread. - * - * Feed the IP layer with incoming packets - * - * @param nf the lwip network interface structure for this slipif - */ -static void -slipif_loop_thread(void *nf) -{ - u8_t c; - struct netif *netif = (struct netif *)nf; - struct slipif_priv *priv = (struct slipif_priv *)netif->state; - - while (1) { - if (sio_read(priv->sd, &c, 1) > 0) { - slipif_rxbyte_input(netif, c); - } - } -} -#endif /* SLIP_USE_RX_THREAD */ - -/** - * SLIP netif initialization - * - * Call the arch specific sio_open and remember - * the opened device in the state field of the netif. - * - * @param netif the lwip network interface structure for this slipif - * @return ERR_OK if serial line could be opened, - * ERR_MEM if no memory could be allocated, - * ERR_IF is serial line couldn't be opened - * - * @note netif->num must contain the number of the serial port to open - * (0 by default). If netif->state is != NULL, it is interpreted as an - * u8_t pointer pointing to the serial port number instead of netif->num. - * - */ -err_t -slipif_init(struct netif *netif) -{ - struct slipif_priv *priv; - u8_t sio_num; - - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num)); - - /* Allocate private data */ - priv = (struct slipif_priv *)mem_malloc(sizeof(struct slipif_priv)); - if (!priv) { - return ERR_MEM; - } - - netif->name[0] = 's'; - netif->name[1] = 'l'; - netif->output = slipif_output; - netif->mtu = SLIP_MAX_SIZE; - netif->flags |= NETIF_FLAG_POINTTOPOINT; - - /* netif->state or netif->num contain the port number */ - if (netif->state != NULL) { - sio_num = *(u8_t*)netif->state; - } else { - sio_num = netif->num; - } - /* Try to open the serial port. */ - priv->sd = sio_open(sio_num); - if (!priv->sd) { - /* Opening the serial port failed. */ - mem_free(priv); - return ERR_IF; - } - - /* Initialize private data */ - priv->p = NULL; - priv->q = NULL; - priv->state = SLIP_RECV_NORMAL; - priv->i = 0; - priv->recved = 0; -#if SLIP_RX_FROM_ISR - priv->rxpackets = NULL; -#endif - - netif->state = priv; - - /* initialize the snmp variables and counters inside the struct netif */ - NETIF_INIT_SNMP(netif, snmp_ifType_slip, SLIP_SIO_SPEED(priv->sd)); - -#if SLIP_USE_RX_THREAD - /* Create a thread to poll the serial line. */ - sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop_thread, netif, - SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO); -#endif /* SLIP_USE_RX_THREAD */ - return ERR_OK; -} - -/** - * Polls the serial device and feeds the IP layer with incoming packets. - * - * @param netif The lwip network interface structure for this slipif - */ -void -slipif_poll(struct netif *netif) -{ - u8_t c; - struct slipif_priv *priv; - - LWIP_ASSERT("netif != NULL", (netif != NULL)); - LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); - - priv = (struct slipif_priv *)netif->state; - - while (sio_tryread(priv->sd, &c, 1) > 0) { - slipif_rxbyte_input(netif, c); - } -} - -#if SLIP_RX_FROM_ISR -/** - * Feeds the IP layer with incoming packets that were receive - * - * @param netif The lwip network interface structure for this slipif - */ -void -slipif_process_rxqueue(struct netif *netif) -{ - struct slipif_priv *priv; - SYS_ARCH_DECL_PROTECT(old_level); - - LWIP_ASSERT("netif != NULL", (netif != NULL)); - LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); - - priv = (struct slipif_priv *)netif->state; - - SYS_ARCH_PROTECT(old_level); - while (priv->rxpackets != NULL) { - struct pbuf *p = priv->rxpackets; -#if SLIP_RX_QUEUE - /* dequeue packet */ - struct pbuf *q = p; - while ((q->len != q->tot_len) && (q->next != NULL)) { - q = q->next; - } - priv->rxpackets = q->next; - q->next = NULL; -#else /* SLIP_RX_QUEUE */ - priv->rxpackets = NULL; -#endif /* SLIP_RX_QUEUE */ - SYS_ARCH_UNPROTECT(old_level); - if (netif->input(p, netif) != ERR_OK) { - pbuf_free(p); - } - SYS_ARCH_PROTECT(old_level); - } -} - -/** Like slipif_rxbyte, but queues completed packets. - * - * @param netif The lwip network interface structure for this slipif - * @param data Received serial byte - */ -static void -slipif_rxbyte_enqueue(struct netif *netif, u8_t data) -{ - struct pbuf *p; - struct slipif_priv *priv = (struct slipif_priv *)netif->state; - SYS_ARCH_DECL_PROTECT(old_level); - - p = slipif_rxbyte(netif, data); - if (p != NULL) { - SYS_ARCH_PROTECT(old_level); - if (priv->rxpackets != NULL) { -#if SLIP_RX_QUEUE - /* queue multiple pbufs */ - struct pbuf *q = p; - while(q->next != NULL) { - q = q->next; - } - q->next = p; - } else { -#else /* SLIP_RX_QUEUE */ - pbuf_free(priv->rxpackets); - } - { -#endif /* SLIP_RX_QUEUE */ - priv->rxpackets = p; - } - SYS_ARCH_UNPROTECT(old_level); - } -} - -/** - * Process a received byte, completed packets are put on a queue that is - * fed into IP through slipif_process_rxqueue(). - * - * This function can be called from ISR if SYS_LIGHTWEIGHT_PROT is enabled. - * - * @param netif The lwip network interface structure for this slipif - * @param data received character - */ -void -slipif_received_byte(struct netif *netif, u8_t data) -{ - LWIP_ASSERT("netif != NULL", (netif != NULL)); - LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); - slipif_rxbyte_enqueue(netif, data); -} - -/** - * Process multiple received byte, completed packets are put on a queue that is - * fed into IP through slipif_process_rxqueue(). - * - * This function can be called from ISR if SYS_LIGHTWEIGHT_PROT is enabled. - * - * @param netif The lwip network interface structure for this slipif - * @param data received character - * @param len Number of received characters - */ -void -slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len) -{ - u8_t i; - u8_t *rxdata = data; - LWIP_ASSERT("netif != NULL", (netif != NULL)); - LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); - - for (i = 0; i < len; i++, rxdata++) { - slipif_rxbyte_enqueue(netif, *rxdata); - } -} -#endif /* SLIP_RX_FROM_ISR */ - -#endif /* LWIP_HAVE_SLIPIF */ diff --git a/user/mpy/lib/lwip/test/unit/core/test_mem.c b/user/mpy/lib/lwip/test/unit/core/test_mem.c deleted file mode 100644 index d3a5d54..0000000 --- a/user/mpy/lib/lwip/test/unit/core/test_mem.c +++ /dev/null @@ -1,73 +0,0 @@ -#include "test_mem.h" - -#include "lwip/mem.h" -#include "lwip/stats.h" - -#if !LWIP_STATS || !MEM_STATS -#error "This tests needs MEM-statistics enabled" -#endif -#if LWIP_DNS -#error "This test needs DNS turned off (as it mallocs on init)" -#endif - -/* Setups/teardown functions */ - -static void -mem_setup(void) -{ -} - -static void -mem_teardown(void) -{ -} - - -/* Test functions */ - -/** Call mem_malloc, mem_free and mem_trim and check stats */ -START_TEST(test_mem_one) -{ -#define SIZE1 16 -#define SIZE1_2 12 -#define SIZE2 16 - void *p1, *p2; - mem_size_t s1, s2; - LWIP_UNUSED_ARG(_i); - -#if LWIP_DNS - fail("This test needs DNS turned off (as it mallocs on init)"); -#endif - - fail_unless(lwip_stats.mem.used == 0); - - p1 = mem_malloc(SIZE1); - fail_unless(p1 != NULL); - fail_unless(lwip_stats.mem.used >= SIZE1); - s1 = lwip_stats.mem.used; - - p2 = mem_malloc(SIZE2); - fail_unless(p2 != NULL); - fail_unless(lwip_stats.mem.used >= SIZE2 + s1); - s2 = lwip_stats.mem.used; - - mem_trim(p1, SIZE1_2); - - mem_free(p2); - fail_unless(lwip_stats.mem.used <= s2 - SIZE2); - - mem_free(p1); - fail_unless(lwip_stats.mem.used == 0); -} -END_TEST - - -/** Create the suite including all tests for this module */ -Suite * -mem_suite(void) -{ - TFun tests[] = { - test_mem_one - }; - return create_suite("MEM", tests, sizeof(tests)/sizeof(TFun), mem_setup, mem_teardown); -} diff --git a/user/mpy/lib/lwip/test/unit/core/test_mem.h b/user/mpy/lib/lwip/test/unit/core/test_mem.h deleted file mode 100644 index 13803ed..0000000 --- a/user/mpy/lib/lwip/test/unit/core/test_mem.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __TEST_MEM_H__ -#define __TEST_MEM_H__ - -#include "../lwip_check.h" - -Suite *mem_suite(void); - -#endif diff --git a/user/mpy/lib/lwip/test/unit/etharp/test_etharp.c b/user/mpy/lib/lwip/test/unit/etharp/test_etharp.c deleted file mode 100644 index cbbc950..0000000 --- a/user/mpy/lib/lwip/test/unit/etharp/test_etharp.c +++ /dev/null @@ -1,262 +0,0 @@ -#include "test_etharp.h" - -#include "lwip/udp.h" -#include "netif/etharp.h" -#include "lwip/stats.h" - -#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS || !ETHARP_STATS -#error "This tests needs UDP-, MEMP- and ETHARP-statistics enabled" -#endif -#if !ETHARP_SUPPORT_STATIC_ENTRIES -#error "This test needs ETHARP_SUPPORT_STATIC_ENTRIES enabled" -#endif - -static struct netif test_netif; -static ip_addr_t test_ipaddr, test_netmask, test_gw; -struct eth_addr test_ethaddr = {1,1,1,1,1,1}; -struct eth_addr test_ethaddr2 = {1,1,1,1,1,2}; -struct eth_addr test_ethaddr3 = {1,1,1,1,1,3}; -struct eth_addr test_ethaddr4 = {1,1,1,1,1,4}; -static int linkoutput_ctr; - -/* Helper functions */ -static void -etharp_remove_all(void) -{ - int i; - /* call etharp_tmr often enough to have all entries cleaned */ - for(i = 0; i < 0xff; i++) { - etharp_tmr(); - } -} - -static err_t -default_netif_linkoutput(struct netif *netif, struct pbuf *p) -{ - fail_unless(netif == &test_netif); - fail_unless(p != NULL); - linkoutput_ctr++; - return ERR_OK; -} - -static err_t -default_netif_init(struct netif *netif) -{ - fail_unless(netif != NULL); - netif->linkoutput = default_netif_linkoutput; - netif->output = etharp_output; - netif->mtu = 1500; - netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; - netif->hwaddr_len = ETHARP_HWADDR_LEN; - return ERR_OK; -} - -static void -default_netif_add(void) -{ - IP4_ADDR(&test_gw, 192,168,0,1); - IP4_ADDR(&test_ipaddr, 192,168,0,1); - IP4_ADDR(&test_netmask, 255,255,0,0); - - fail_unless(netif_default == NULL); - netif_set_default(netif_add(&test_netif, &test_ipaddr, &test_netmask, - &test_gw, NULL, default_netif_init, NULL)); - netif_set_up(&test_netif); -} - -static void -default_netif_remove(void) -{ - fail_unless(netif_default == &test_netif); - netif_remove(&test_netif); -} - -static void -create_arp_response(ip_addr_t *adr) -{ - int k; - struct eth_hdr *ethhdr; - struct etharp_hdr *etharphdr; - struct pbuf *p = pbuf_alloc(PBUF_RAW, sizeof(struct eth_hdr) + sizeof(struct etharp_hdr), PBUF_RAM); - if(p == NULL) { - FAIL_RET(); - } - ethhdr = (struct eth_hdr*)p->payload; - etharphdr = (struct etharp_hdr*)(ethhdr + 1); - - ethhdr->dest = test_ethaddr; - ethhdr->src = test_ethaddr2; - ethhdr->type = htons(ETHTYPE_ARP); - - etharphdr->hwtype = htons(/*HWTYPE_ETHERNET*/ 1); - etharphdr->proto = htons(ETHTYPE_IP); - etharphdr->hwlen = ETHARP_HWADDR_LEN; - etharphdr->protolen = sizeof(ip_addr_t); - etharphdr->opcode = htons(ARP_REPLY); - - SMEMCPY(ðarphdr->sipaddr, adr, sizeof(ip_addr_t)); - SMEMCPY(ðarphdr->dipaddr, &test_ipaddr, sizeof(ip_addr_t)); - - k = 6; - while(k > 0) { - k--; - /* Write the ARP MAC-Addresses */ - etharphdr->shwaddr.addr[k] = test_ethaddr2.addr[k]; - etharphdr->dhwaddr.addr[k] = test_ethaddr.addr[k]; - /* Write the Ethernet MAC-Addresses */ - ethhdr->dest.addr[k] = test_ethaddr.addr[k]; - ethhdr->src.addr[k] = test_ethaddr2.addr[k]; - } - - ethernet_input(p, &test_netif); -} - -/* Setups/teardown functions */ - -static void -etharp_setup(void) -{ - etharp_remove_all(); - default_netif_add(); -} - -static void -etharp_teardown(void) -{ - etharp_remove_all(); - default_netif_remove(); -} - - -/* Test functions */ - -START_TEST(test_etharp_table) -{ -#if ETHARP_SUPPORT_STATIC_ENTRIES - err_t err; -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - s8_t idx; - ip_addr_t *unused_ipaddr; - struct eth_addr *unused_ethaddr; - struct udp_pcb* pcb; - LWIP_UNUSED_ARG(_i); - - if (netif_default != &test_netif) { - fail("This test needs a default netif"); - } - - linkoutput_ctr = 0; - - pcb = udp_new(); - fail_unless(pcb != NULL); - if (pcb != NULL) { - ip_addr_t adrs[ARP_TABLE_SIZE + 2]; - int i; - for(i = 0; i < ARP_TABLE_SIZE + 2; i++) { - IP4_ADDR(&adrs[i], 192,168,0,i+2); - } - /* fill ARP-table with dynamic entries */ - for(i = 0; i < ARP_TABLE_SIZE; i++) { - struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, 10, PBUF_RAM); - fail_unless(p != NULL); - if (p != NULL) { - err_t err = udp_sendto(pcb, p, &adrs[i], 123); - fail_unless(err == ERR_OK); - /* etharp request sent? */ - fail_unless(linkoutput_ctr == (2*i) + 1); - pbuf_free(p); - - /* create an ARP response */ - create_arp_response(&adrs[i]); - /* queued UDP packet sent? */ - fail_unless(linkoutput_ctr == (2*i) + 2); - - idx = etharp_find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == i); - etharp_tmr(); - } - } - linkoutput_ctr = 0; -#if ETHARP_SUPPORT_STATIC_ENTRIES - /* create one static entry */ - err = etharp_add_static_entry(&adrs[ARP_TABLE_SIZE], &test_ethaddr3); - fail_unless(err == ERR_OK); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == 0); - fail_unless(linkoutput_ctr == 0); -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - - linkoutput_ctr = 0; - /* fill ARP-table with dynamic entries */ - for(i = 0; i < ARP_TABLE_SIZE; i++) { - struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, 10, PBUF_RAM); - fail_unless(p != NULL); - if (p != NULL) { - err_t err = udp_sendto(pcb, p, &adrs[i], 123); - fail_unless(err == ERR_OK); - /* etharp request sent? */ - fail_unless(linkoutput_ctr == (2*i) + 1); - pbuf_free(p); - - /* create an ARP response */ - create_arp_response(&adrs[i]); - /* queued UDP packet sent? */ - fail_unless(linkoutput_ctr == (2*i) + 2); - - idx = etharp_find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr); - if (i < ARP_TABLE_SIZE - 1) { - fail_unless(idx == i+1); - } else { - /* the last entry must not overwrite the static entry! */ - fail_unless(idx == 1); - } - etharp_tmr(); - } - } -#if ETHARP_SUPPORT_STATIC_ENTRIES - /* create a second static entry */ - err = etharp_add_static_entry(&adrs[ARP_TABLE_SIZE+1], &test_ethaddr4); - fail_unless(err == ERR_OK); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == 0); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == 2); - /* and remove it again */ - err = etharp_remove_static_entry(&adrs[ARP_TABLE_SIZE+1]); - fail_unless(err == ERR_OK); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == 0); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == -1); -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - - /* check that static entries don't time out */ - etharp_remove_all(); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == 0); - -#if ETHARP_SUPPORT_STATIC_ENTRIES - /* remove the first static entry */ - err = etharp_remove_static_entry(&adrs[ARP_TABLE_SIZE]); - fail_unless(err == ERR_OK); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == -1); - idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr); - fail_unless(idx == -1); -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - - udp_remove(pcb); - } -} -END_TEST - - -/** Create the suite including all tests for this module */ -Suite * -etharp_suite(void) -{ - TFun tests[] = { - test_etharp_table - }; - return create_suite("ETHARP", tests, sizeof(tests)/sizeof(TFun), etharp_setup, etharp_teardown); -} diff --git a/user/mpy/lib/lwip/test/unit/etharp/test_etharp.h b/user/mpy/lib/lwip/test/unit/etharp/test_etharp.h deleted file mode 100644 index 96e00c3..0000000 --- a/user/mpy/lib/lwip/test/unit/etharp/test_etharp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __TEST_ETHARP_H__ -#define __TEST_ETHARP_H__ - -#include "../lwip_check.h" - -Suite* etharp_suite(void); - -#endif diff --git a/user/mpy/lib/lwip/test/unit/lwip_check.h b/user/mpy/lib/lwip/test/unit/lwip_check.h deleted file mode 100644 index e27f55a..0000000 --- a/user/mpy/lib/lwip/test/unit/lwip_check.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __LWIP_CHECK_H__ -#define __LWIP_CHECK_H__ - -/* Common header file for lwIP unit tests using the check framework */ - -#include -#include -#include - -#define FAIL_RET() do { fail(); return; } while(0) -#define EXPECT(x) fail_unless(x) -#define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0) -#define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) -#define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) - -/** typedef for a function returning a test suite */ -typedef Suite* (suite_getter_fn)(void); - -/** Create a test suite */ -static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown) -{ - size_t i; - Suite *s = suite_create(name); - - for(i = 0; i < num_tests; i++) { - /* Core test case */ - TCase *tc_core = tcase_create("Core"); - if ((setup != NULL) || (teardown != NULL)) { - tcase_add_checked_fixture(tc_core, setup, teardown); - } - tcase_add_test(tc_core, tests[i]); - suite_add_tcase(s, tc_core); - } - return s; -} - -#endif /* __LWIP_CHECK_H__ */ diff --git a/user/mpy/lib/lwip/test/unit/lwip_unittests.c b/user/mpy/lib/lwip/test/unit/lwip_unittests.c deleted file mode 100644 index 4f537e6..0000000 --- a/user/mpy/lib/lwip/test/unit/lwip_unittests.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "lwip_check.h" - -#include "udp/test_udp.h" -#include "tcp/test_tcp.h" -#include "tcp/test_tcp_oos.h" -#include "core/test_mem.h" -#include "etharp/test_etharp.h" - -#include "lwip/init.h" - - -int main() -{ - int number_failed; - SRunner *sr; - size_t i; - suite_getter_fn* suites[] = { - udp_suite, - tcp_suite, - tcp_oos_suite, - mem_suite, - etharp_suite - }; - size_t num = sizeof(suites)/sizeof(void*); - LWIP_ASSERT("No suites defined", num > 0); - - lwip_init(); - - sr = srunner_create((suites[0])()); - for(i = 1; i < num; i++) { - srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); - } - -#ifdef LWIP_UNITTESTS_NOFORK - srunner_set_fork_status(sr, CK_NOFORK); -#endif -#ifdef LWIP_UNITTESTS_FORK - srunner_set_fork_status(sr, CK_FORK); -#endif - - srunner_run_all(sr, CK_NORMAL); - number_failed = srunner_ntests_failed(sr); - srunner_free(sr); - return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/user/mpy/lib/lwip/test/unit/lwipopts.h b/user/mpy/lib/lwip/test/unit/lwipopts.h deleted file mode 100644 index 88e76d7..0000000 --- a/user/mpy/lib/lwip/test/unit/lwipopts.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ -#ifndef __LWIPOPTS_H__ -#define __LWIPOPTS_H__ - -/* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */ -#define NO_SYS 1 -#define LWIP_NETCONN 0 -#define LWIP_SOCKET 0 - -/* Minimal changes to opt.h required for tcp unit tests: */ -#define MEM_SIZE 16000 -#define TCP_SND_QUEUELEN 40 -#define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN -#define TCP_SND_BUF (12 * TCP_MSS) -#define TCP_WND (10 * TCP_MSS) - -/* Minimal changes to opt.h required for etharp unit tests: */ -#define ETHARP_SUPPORT_STATIC_ENTRIES 1 - -#endif /* __LWIPOPTS_H__ */ diff --git a/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c b/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c deleted file mode 100644 index dd550f1..0000000 --- a/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.c +++ /dev/null @@ -1,294 +0,0 @@ -#include "tcp_helper.h" - -#include "lwip/tcp_impl.h" -#include "lwip/stats.h" -#include "lwip/pbuf.h" -#include "lwip/inet_chksum.h" - -#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS -#error "This tests needs TCP- and MEMP-statistics enabled" -#endif - -/** Remove all pcbs on the given list. */ -static void -tcp_remove(struct tcp_pcb* pcb_list) -{ - struct tcp_pcb *pcb = pcb_list; - struct tcp_pcb *pcb2; - - while(pcb != NULL) { - pcb2 = pcb; - pcb = pcb->next; - tcp_abort(pcb2); - } -} - -/** Remove all pcbs on listen-, active- and time-wait-list (bound- isn't exported). */ -void -tcp_remove_all(void) -{ - tcp_remove(tcp_listen_pcbs.pcbs); - tcp_remove(tcp_active_pcbs); - tcp_remove(tcp_tw_pcbs); - fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0); - fail_unless(lwip_stats.memp[MEMP_TCP_PCB_LISTEN].used == 0); - fail_unless(lwip_stats.memp[MEMP_TCP_SEG].used == 0); - fail_unless(lwip_stats.memp[MEMP_PBUF_POOL].used == 0); -} - -/** Create a TCP segment usable for passing to tcp_input */ -static struct pbuf* -tcp_create_segment_wnd(ip_addr_t* src_ip, ip_addr_t* dst_ip, - u16_t src_port, u16_t dst_port, void* data, size_t data_len, - u32_t seqno, u32_t ackno, u8_t headerflags, u16_t wnd) -{ - struct pbuf *p, *q; - struct ip_hdr* iphdr; - struct tcp_hdr* tcphdr; - u16_t pbuf_len = (u16_t)(sizeof(struct ip_hdr) + sizeof(struct tcp_hdr) + data_len); - - p = pbuf_alloc(PBUF_RAW, pbuf_len, PBUF_POOL); - EXPECT_RETNULL(p != NULL); - /* first pbuf must be big enough to hold the headers */ - EXPECT_RETNULL(p->len >= (sizeof(struct ip_hdr) + sizeof(struct tcp_hdr))); - if (data_len > 0) { - /* first pbuf must be big enough to hold at least 1 data byte, too */ - EXPECT_RETNULL(p->len > (sizeof(struct ip_hdr) + sizeof(struct tcp_hdr))); - } - - for(q = p; q != NULL; q = q->next) { - memset(q->payload, 0, q->len); - } - - iphdr = p->payload; - /* fill IP header */ - iphdr->dest.addr = dst_ip->addr; - iphdr->src.addr = src_ip->addr; - IPH_VHL_SET(iphdr, 4, IP_HLEN / 4); - IPH_TOS_SET(iphdr, 0); - IPH_LEN_SET(iphdr, htons(p->tot_len)); - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); - - /* let p point to TCP header */ - pbuf_header(p, -(s16_t)sizeof(struct ip_hdr)); - - tcphdr = p->payload; - tcphdr->src = htons(src_port); - tcphdr->dest = htons(dst_port); - tcphdr->seqno = htonl(seqno); - tcphdr->ackno = htonl(ackno); - TCPH_HDRLEN_SET(tcphdr, sizeof(struct tcp_hdr)/4); - TCPH_FLAGS_SET(tcphdr, headerflags); - tcphdr->wnd = htons(wnd); - - if (data_len > 0) { - /* let p point to TCP data */ - pbuf_header(p, -(s16_t)sizeof(struct tcp_hdr)); - /* copy data */ - pbuf_take(p, data, data_len); - /* let p point to TCP header again */ - pbuf_header(p, sizeof(struct tcp_hdr)); - } - - /* calculate checksum */ - - tcphdr->chksum = inet_chksum_pseudo(p, src_ip, dst_ip, - IP_PROTO_TCP, p->tot_len); - - pbuf_header(p, sizeof(struct ip_hdr)); - - return p; -} - -/** Create a TCP segment usable for passing to tcp_input */ -struct pbuf* -tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, - u16_t src_port, u16_t dst_port, void* data, size_t data_len, - u32_t seqno, u32_t ackno, u8_t headerflags) -{ - return tcp_create_segment_wnd(src_ip, dst_ip, src_port, dst_port, data, - data_len, seqno, ackno, headerflags, TCP_WND); -} - -/** Create a TCP segment usable for passing to tcp_input - * - IP-addresses, ports, seqno and ackno are taken from pcb - * - seqno and ackno can be altered with an offset - */ -struct pbuf* -tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, u32_t seqno_offset, - u32_t ackno_offset, u8_t headerflags) -{ - return tcp_create_segment(&pcb->remote_ip, &pcb->local_ip, pcb->remote_port, pcb->local_port, - data, data_len, pcb->rcv_nxt + seqno_offset, pcb->lastack + ackno_offset, headerflags); -} - -/** Create a TCP segment usable for passing to tcp_input - * - IP-addresses, ports, seqno and ackno are taken from pcb - * - seqno and ackno can be altered with an offset - * - TCP window can be adjusted - */ -struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, - u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd) -{ - return tcp_create_segment_wnd(&pcb->remote_ip, &pcb->local_ip, pcb->remote_port, pcb->local_port, - data, data_len, pcb->rcv_nxt + seqno_offset, pcb->lastack + ackno_offset, headerflags, wnd); -} - -/** Safely bring a tcp_pcb into the requested state */ -void -tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, - ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port) -{ - /* @todo: are these all states? */ - /* @todo: remove from previous list */ - pcb->state = state; - if (state == ESTABLISHED) { - TCP_REG(&tcp_active_pcbs, pcb); - pcb->local_ip.addr = local_ip->addr; - pcb->local_port = local_port; - pcb->remote_ip.addr = remote_ip->addr; - pcb->remote_port = remote_port; - } else if(state == LISTEN) { - TCP_REG(&tcp_listen_pcbs.pcbs, pcb); - pcb->local_ip.addr = local_ip->addr; - pcb->local_port = local_port; - } else if(state == TIME_WAIT) { - TCP_REG(&tcp_tw_pcbs, pcb); - pcb->local_ip.addr = local_ip->addr; - pcb->local_port = local_port; - pcb->remote_ip.addr = remote_ip->addr; - pcb->remote_port = remote_port; - } else { - fail(); - } -} - -void -test_tcp_counters_err(void* arg, err_t err) -{ - struct test_tcp_counters* counters = arg; - EXPECT_RET(arg != NULL); - counters->err_calls++; - counters->last_err = err; -} - -static void -test_tcp_counters_check_rxdata(struct test_tcp_counters* counters, struct pbuf* p) -{ - struct pbuf* q; - u32_t i, received; - if(counters->expected_data == NULL) { - /* no data to compare */ - return; - } - EXPECT_RET(counters->recved_bytes + p->tot_len <= counters->expected_data_len); - received = counters->recved_bytes; - for(q = p; q != NULL; q = q->next) { - char *data = q->payload; - for(i = 0; i < q->len; i++) { - EXPECT_RET(data[i] == counters->expected_data[received]); - received++; - } - } - EXPECT(received == counters->recved_bytes + p->tot_len); -} - -err_t -test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err) -{ - struct test_tcp_counters* counters = arg; - EXPECT_RETX(arg != NULL, ERR_OK); - EXPECT_RETX(pcb != NULL, ERR_OK); - EXPECT_RETX(err == ERR_OK, ERR_OK); - - if (p != NULL) { - if (counters->close_calls == 0) { - counters->recv_calls++; - test_tcp_counters_check_rxdata(counters, p); - counters->recved_bytes += p->tot_len; - } else { - counters->recv_calls_after_close++; - counters->recved_bytes_after_close += p->tot_len; - } - pbuf_free(p); - } else { - counters->close_calls++; - } - EXPECT(counters->recv_calls_after_close == 0 && counters->recved_bytes_after_close == 0); - return ERR_OK; -} - -/** Allocate a pcb and set up the test_tcp_counters_* callbacks */ -struct tcp_pcb* -test_tcp_new_counters_pcb(struct test_tcp_counters* counters) -{ - struct tcp_pcb* pcb = tcp_new(); - if (pcb != NULL) { - /* set up args and callbacks */ - tcp_arg(pcb, counters); - tcp_recv(pcb, test_tcp_counters_recv); - tcp_err(pcb, test_tcp_counters_err); - pcb->snd_wnd = TCP_WND; - pcb->snd_wnd_max = TCP_WND; - } - return pcb; -} - -/** Calls tcp_input() after adjusting current_iphdr_dest */ -void test_tcp_input(struct pbuf *p, struct netif *inp) -{ - struct ip_hdr *iphdr = (struct ip_hdr*)p->payload; - ip_addr_copy(current_iphdr_dest, iphdr->dest); - ip_addr_copy(current_iphdr_src, iphdr->src); - current_netif = inp; - current_header = iphdr; - - tcp_input(p, inp); - - current_iphdr_dest.addr = 0; - current_iphdr_src.addr = 0; - current_netif = NULL; - current_header = NULL; -} - -static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p, - ip_addr_t *ipaddr) -{ - struct test_tcp_txcounters *txcounters = (struct test_tcp_txcounters*)netif->state; - LWIP_UNUSED_ARG(ipaddr); - txcounters->num_tx_calls++; - txcounters->num_tx_bytes += p->tot_len; - if (txcounters->copy_tx_packets) { - struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); - err_t err; - EXPECT(p_copy != NULL); - err = pbuf_copy(p_copy, p); - EXPECT(err == ERR_OK); - if (txcounters->tx_packets == NULL) { - txcounters->tx_packets = p_copy; - } else { - pbuf_cat(txcounters->tx_packets, p_copy); - } - } - return ERR_OK; -} - -void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, - ip_addr_t *ip_addr, ip_addr_t *netmask) -{ - struct netif *n; - memset(netif, 0, sizeof(struct netif)); - memset(txcounters, 0, sizeof(struct test_tcp_txcounters)); - netif->output = test_tcp_netif_output; - netif->state = txcounters; - netif->flags |= NETIF_FLAG_UP; - ip_addr_copy(netif->netmask, *netmask); - ip_addr_copy(netif->ip_addr, *ip_addr); - for (n = netif_list; n != NULL; n = n->next) { - if (n == netif) { - return; - } - } - netif->next = NULL; - netif_list = netif; -} diff --git a/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h b/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h deleted file mode 100644 index 4a72c93..0000000 --- a/user/mpy/lib/lwip/test/unit/tcp/tcp_helper.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __TCP_HELPER_H__ -#define __TCP_HELPER_H__ - -#include "../lwip_check.h" -#include "lwip/arch.h" -#include "lwip/tcp.h" -#include "lwip/netif.h" - -/* counters used for test_tcp_counters_* callback functions */ -struct test_tcp_counters { - u32_t recv_calls; - u32_t recved_bytes; - u32_t recv_calls_after_close; - u32_t recved_bytes_after_close; - u32_t close_calls; - u32_t err_calls; - err_t last_err; - char* expected_data; - u32_t expected_data_len; -}; - -struct test_tcp_txcounters { - u32_t num_tx_calls; - u32_t num_tx_bytes; - u8_t copy_tx_packets; - struct pbuf *tx_packets; -}; - -/* Helper functions */ -void tcp_remove_all(void); - -struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, - u16_t src_port, u16_t dst_port, void* data, size_t data_len, - u32_t seqno, u32_t ackno, u8_t headerflags); -struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, - u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags); -struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, - u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd); -void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, - ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port); -void test_tcp_counters_err(void* arg, err_t err); -err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); - -struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters); - -void test_tcp_input(struct pbuf *p, struct netif *inp); - -void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, - ip_addr_t *ip_addr, ip_addr_t *netmask); - - -#endif diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp.c b/user/mpy/lib/lwip/test/unit/tcp/test_tcp.c deleted file mode 100644 index 6fd5be5..0000000 --- a/user/mpy/lib/lwip/test/unit/tcp/test_tcp.c +++ /dev/null @@ -1,667 +0,0 @@ -#include "test_tcp.h" - -#include "lwip/tcp_impl.h" -#include "lwip/stats.h" -#include "tcp_helper.h" - -#ifdef _MSC_VER -#pragma warning(disable: 4307) /* we explicitly wrap around TCP seqnos */ -#endif - -#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS -#error "This tests needs TCP- and MEMP-statistics enabled" -#endif -#if TCP_SND_BUF <= TCP_WND -#error "This tests needs TCP_SND_BUF to be > TCP_WND" -#endif - -static u8_t test_tcp_timer; - -/* our own version of tcp_tmr so we can reset fast/slow timer state */ -static void -test_tcp_tmr(void) -{ - tcp_fasttmr(); - if (++test_tcp_timer & 1) { - tcp_slowtmr(); - } -} - -/* Setups/teardown functions */ - -static void -tcp_setup(void) -{ - /* reset iss to default (6510) */ - tcp_ticks = 0; - tcp_ticks = 0 - (tcp_next_iss() - 6510); - tcp_next_iss(); - tcp_ticks = 0; - - test_tcp_timer = 0; - tcp_remove_all(); -} - -static void -tcp_teardown(void) -{ - netif_list = NULL; - tcp_remove_all(); -} - - -/* Test functions */ - -/** Call tcp_new() and tcp_abort() and test memp stats */ -START_TEST(test_tcp_new_abort) -{ - struct tcp_pcb* pcb; - LWIP_UNUSED_ARG(_i); - - fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0); - - pcb = tcp_new(); - fail_unless(pcb != NULL); - if (pcb != NULL) { - fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0); - } -} -END_TEST - -/** Create an ESTABLISHED pcb and check if receive callback is called */ -START_TEST(test_tcp_recv_inseq) -{ - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf* p; - char data[] = {1, 2, 3, 4}; - ip_addr_t remote_ip, local_ip; - u16_t data_len; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - LWIP_UNUSED_ARG(_i); - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - data_len = sizeof(data); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = data_len; - counters.expected_data = data; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - - /* create a segment */ - p = tcp_create_rx_segment(pcb, counters.expected_data, data_len, 0, 0, 0); - EXPECT(p != NULL); - if (p != NULL) { - /* pass the segment to tcp_input */ - test_tcp_input(p, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 1); - EXPECT(counters.recved_bytes == data_len); - EXPECT(counters.err_calls == 0); - } - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} -END_TEST - -/** Provoke fast retransmission by duplicate ACKs and then recover by ACKing all sent data. - * At the end, send more data. */ -START_TEST(test_tcp_fast_retx_recover) -{ - struct netif netif; - struct test_tcp_txcounters txcounters; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf* p; - char data1[] = { 1, 2, 3, 4}; - char data2[] = { 5, 6, 7, 8}; - char data3[] = { 9, 10, 11, 12}; - char data4[] = {13, 14, 15, 16}; - char data5[] = {17, 18, 19, 20}; - char data6[] = {21, 22, 23, 24}; - ip_addr_t remote_ip, local_ip, netmask; - u16_t remote_port = 0x100, local_port = 0x101; - err_t err; - LWIP_UNUSED_ARG(_i); - - /* initialize local vars */ - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - IP4_ADDR(&netmask, 255, 255, 255, 0); - test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); - memset(&counters, 0, sizeof(counters)); - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->mss = TCP_MSS; - /* disable initial congestion window (we don't send a SYN here...) */ - pcb->cwnd = pcb->snd_wnd; - - /* send data1 */ - err = tcp_write(pcb, data1, sizeof(data1), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - EXPECT_RET(txcounters.num_tx_calls == 1); - EXPECT_RET(txcounters.num_tx_bytes == sizeof(data1) + sizeof(struct tcp_hdr) + sizeof(struct ip_hdr)); - memset(&txcounters, 0, sizeof(txcounters)); - /* "recv" ACK for data1 */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 4, TCP_ACK); - EXPECT_RET(p != NULL); - test_tcp_input(p, &netif); - EXPECT_RET(txcounters.num_tx_calls == 0); - EXPECT_RET(pcb->unacked == NULL); - /* send data2 */ - err = tcp_write(pcb, data2, sizeof(data2), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - EXPECT_RET(txcounters.num_tx_calls == 1); - EXPECT_RET(txcounters.num_tx_bytes == sizeof(data2) + sizeof(struct tcp_hdr) + sizeof(struct ip_hdr)); - memset(&txcounters, 0, sizeof(txcounters)); - /* duplicate ACK for data1 (data2 is lost) */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - EXPECT_RET(p != NULL); - test_tcp_input(p, &netif); - EXPECT_RET(txcounters.num_tx_calls == 0); - EXPECT_RET(pcb->dupacks == 1); - /* send data3 */ - err = tcp_write(pcb, data3, sizeof(data3), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - /* nagle enabled, no tx calls */ - EXPECT_RET(txcounters.num_tx_calls == 0); - EXPECT_RET(txcounters.num_tx_bytes == 0); - memset(&txcounters, 0, sizeof(txcounters)); - /* 2nd duplicate ACK for data1 (data2 and data3 are lost) */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - EXPECT_RET(p != NULL); - test_tcp_input(p, &netif); - EXPECT_RET(txcounters.num_tx_calls == 0); - EXPECT_RET(pcb->dupacks == 2); - /* queue data4, don't send it (unsent-oversize is != 0) */ - err = tcp_write(pcb, data4, sizeof(data4), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - /* 3nd duplicate ACK for data1 (data2 and data3 are lost) -> fast retransmission */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - EXPECT_RET(p != NULL); - test_tcp_input(p, &netif); - /*EXPECT_RET(txcounters.num_tx_calls == 1);*/ - EXPECT_RET(pcb->dupacks == 3); - memset(&txcounters, 0, sizeof(txcounters)); - /* TODO: check expected data?*/ - - /* send data5, not output yet */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - /*err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK);*/ - EXPECT_RET(txcounters.num_tx_calls == 0); - EXPECT_RET(txcounters.num_tx_bytes == 0); - memset(&txcounters, 0, sizeof(txcounters)); - { - int i = 0; - do - { - err = tcp_write(pcb, data6, TCP_MSS, TCP_WRITE_FLAG_COPY); - i++; - }while(err == ERR_OK); - EXPECT_RET(err != ERR_OK); - } - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - /*EXPECT_RET(txcounters.num_tx_calls == 0); - EXPECT_RET(txcounters.num_tx_bytes == 0);*/ - memset(&txcounters, 0, sizeof(txcounters)); - - /* send even more data */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - /* ...and even more data */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - /* ...and even more data */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - /* ...and even more data */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - - /* send ACKs for data2 and data3 */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 12, TCP_ACK); - EXPECT_RET(p != NULL); - test_tcp_input(p, &netif); - /*EXPECT_RET(txcounters.num_tx_calls == 0);*/ - - /* ...and even more data */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - /* ...and even more data */ - err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - -#if 0 - /* create expected segment */ - p1 = tcp_create_rx_segment(pcb, counters.expected_data, data_len, 0, 0, 0); - EXPECT_RET(p != NULL); - if (p != NULL) { - /* pass the segment to tcp_input */ - test_tcp_input(p, &netif); - /* check if counters are as expected */ - EXPECT_RET(counters.close_calls == 0); - EXPECT_RET(counters.recv_calls == 1); - EXPECT_RET(counters.recved_bytes == data_len); - EXPECT_RET(counters.err_calls == 0); - } -#endif - /* make sure the pcb is freed */ - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} -END_TEST - -static u8_t tx_data[TCP_WND*2]; - -static void -check_seqnos(struct tcp_seg *segs, int num_expected, u32_t *seqnos_expected) -{ - struct tcp_seg *s = segs; - int i; - for (i = 0; i < num_expected; i++, s = s->next) { - EXPECT_RET(s != NULL); - EXPECT(s->tcphdr->seqno == htonl(seqnos_expected[i])); - } - EXPECT(s == NULL); -} - -/** Send data with sequence numbers that wrap around the u32_t range. - * Then, provoke fast retransmission by duplicate ACKs and check that all - * segment lists are still properly sorted. */ -START_TEST(test_tcp_fast_rexmit_wraparound) -{ - struct netif netif; - struct test_tcp_txcounters txcounters; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf* p; - ip_addr_t remote_ip, local_ip, netmask; - u16_t remote_port = 0x100, local_port = 0x101; - err_t err; -#define SEQNO1 (0xFFFFFF00 - TCP_MSS) -#define ISS 6510 - u16_t i, sent_total = 0; - u32_t seqnos[] = { - SEQNO1, - SEQNO1 + (1 * TCP_MSS), - SEQNO1 + (2 * TCP_MSS), - SEQNO1 + (3 * TCP_MSS), - SEQNO1 + (4 * TCP_MSS), - SEQNO1 + (5 * TCP_MSS)}; - LWIP_UNUSED_ARG(_i); - - for (i = 0; i < sizeof(tx_data); i++) { - tx_data[i] = (u8_t)i; - } - - /* initialize local vars */ - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - IP4_ADDR(&netmask, 255, 255, 255, 0); - test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); - memset(&counters, 0, sizeof(counters)); - - /* create and initialize the pcb */ - tcp_ticks = SEQNO1 - ISS; - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - EXPECT(pcb->lastack == SEQNO1); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->mss = TCP_MSS; - /* disable initial congestion window (we don't send a SYN here...) */ - pcb->cwnd = 2*TCP_MSS; - - /* send 6 mss-sized segments */ - for (i = 0; i < 6; i++) { - err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - sent_total += TCP_MSS; - } - check_seqnos(pcb->unsent, 6, seqnos); - EXPECT(pcb->unacked == NULL); - err = tcp_output(pcb); - EXPECT(txcounters.num_tx_calls == 2); - EXPECT(txcounters.num_tx_bytes == 2 * (TCP_MSS + 40U)); - memset(&txcounters, 0, sizeof(txcounters)); - - check_seqnos(pcb->unacked, 2, seqnos); - check_seqnos(pcb->unsent, 4, &seqnos[2]); - - /* ACK the first segment */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, TCP_MSS, TCP_ACK); - test_tcp_input(p, &netif); - /* ensure this didn't trigger a retransmission */ - EXPECT(txcounters.num_tx_calls == 1); - EXPECT(txcounters.num_tx_bytes == TCP_MSS + 40U); - memset(&txcounters, 0, sizeof(txcounters)); - check_seqnos(pcb->unacked, 2, &seqnos[1]); - check_seqnos(pcb->unsent, 3, &seqnos[3]); - - /* 3 dupacks */ - EXPECT(pcb->dupacks == 0); - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - test_tcp_input(p, &netif); - EXPECT(txcounters.num_tx_calls == 0); - EXPECT(pcb->dupacks == 1); - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - test_tcp_input(p, &netif); - EXPECT(txcounters.num_tx_calls == 0); - EXPECT(pcb->dupacks == 2); - /* 3rd dupack -> fast rexmit */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - test_tcp_input(p, &netif); - EXPECT(pcb->dupacks == 3); - EXPECT(txcounters.num_tx_calls == 4); - memset(&txcounters, 0, sizeof(txcounters)); - EXPECT(pcb->unsent == NULL); - check_seqnos(pcb->unacked, 5, &seqnos[1]); - - /* make sure the pcb is freed */ - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} -END_TEST - -/** Send data with sequence numbers that wrap around the u32_t range. - * Then, provoke RTO retransmission and check that all - * segment lists are still properly sorted. */ -START_TEST(test_tcp_rto_rexmit_wraparound) -{ - struct netif netif; - struct test_tcp_txcounters txcounters; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - ip_addr_t remote_ip, local_ip, netmask; - u16_t remote_port = 0x100, local_port = 0x101; - err_t err; -#define SEQNO1 (0xFFFFFF00 - TCP_MSS) -#define ISS 6510 - u16_t i, sent_total = 0; - u32_t seqnos[] = { - SEQNO1, - SEQNO1 + (1 * TCP_MSS), - SEQNO1 + (2 * TCP_MSS), - SEQNO1 + (3 * TCP_MSS), - SEQNO1 + (4 * TCP_MSS), - SEQNO1 + (5 * TCP_MSS)}; - LWIP_UNUSED_ARG(_i); - - for (i = 0; i < sizeof(tx_data); i++) { - tx_data[i] = (u8_t)i; - } - - /* initialize local vars */ - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - IP4_ADDR(&netmask, 255, 255, 255, 0); - test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); - memset(&counters, 0, sizeof(counters)); - - /* create and initialize the pcb */ - tcp_ticks = 0; - tcp_ticks = 0 - tcp_next_iss(); - tcp_ticks = SEQNO1 - tcp_next_iss(); - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - EXPECT(pcb->lastack == SEQNO1); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->mss = TCP_MSS; - /* disable initial congestion window (we don't send a SYN here...) */ - pcb->cwnd = 2*TCP_MSS; - - /* send 6 mss-sized segments */ - for (i = 0; i < 6; i++) { - err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - sent_total += TCP_MSS; - } - check_seqnos(pcb->unsent, 6, seqnos); - EXPECT(pcb->unacked == NULL); - err = tcp_output(pcb); - EXPECT(txcounters.num_tx_calls == 2); - EXPECT(txcounters.num_tx_bytes == 2 * (TCP_MSS + 40U)); - memset(&txcounters, 0, sizeof(txcounters)); - - check_seqnos(pcb->unacked, 2, seqnos); - check_seqnos(pcb->unsent, 4, &seqnos[2]); - - /* call the tcp timer some times */ - for (i = 0; i < 10; i++) { - test_tcp_tmr(); - EXPECT(txcounters.num_tx_calls == 0); - } - /* 11th call to tcp_tmr: RTO rexmit fires */ - test_tcp_tmr(); - EXPECT(txcounters.num_tx_calls == 1); - check_seqnos(pcb->unacked, 1, seqnos); - check_seqnos(pcb->unsent, 5, &seqnos[1]); - - /* fake greater cwnd */ - pcb->cwnd = pcb->snd_wnd; - /* send more data */ - err = tcp_output(pcb); - EXPECT(err == ERR_OK); - /* check queues are sorted */ - EXPECT(pcb->unsent == NULL); - check_seqnos(pcb->unacked, 6, seqnos); - - /* make sure the pcb is freed */ - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} -END_TEST - -/** Provoke fast retransmission by duplicate ACKs and then recover by ACKing all sent data. - * At the end, send more data. */ -static void test_tcp_tx_full_window_lost(u8_t zero_window_probe_from_unsent) -{ - struct netif netif; - struct test_tcp_txcounters txcounters; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *p; - ip_addr_t remote_ip, local_ip, netmask; - u16_t remote_port = 0x100, local_port = 0x101; - err_t err; - u16_t sent_total, i; - u8_t expected = 0xFE; - - for (i = 0; i < sizeof(tx_data); i++) { - u8_t d = (u8_t)i; - if (d == 0xFE) { - d = 0xF0; - } - tx_data[i] = d; - } - if (zero_window_probe_from_unsent) { - tx_data[TCP_WND] = expected; - } else { - tx_data[0] = expected; - } - - /* initialize local vars */ - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - IP4_ADDR(&netmask, 255, 255, 255, 0); - test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask); - memset(&counters, 0, sizeof(counters)); - memset(&txcounters, 0, sizeof(txcounters)); - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->mss = TCP_MSS; - /* disable initial congestion window (we don't send a SYN here...) */ - pcb->cwnd = pcb->snd_wnd; - - /* send a full window (minus 1 packets) of TCP data in MSS-sized chunks */ - sent_total = 0; - if ((TCP_WND - TCP_MSS) % TCP_MSS != 0) { - u16_t initial_data_len = (TCP_WND - TCP_MSS) % TCP_MSS; - err = tcp_write(pcb, &tx_data[sent_total], initial_data_len, TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - EXPECT(txcounters.num_tx_calls == 1); - EXPECT(txcounters.num_tx_bytes == initial_data_len + 40U); - memset(&txcounters, 0, sizeof(txcounters)); - sent_total += initial_data_len; - } - for (; sent_total < (TCP_WND - TCP_MSS); sent_total += TCP_MSS) { - err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - EXPECT(txcounters.num_tx_calls == 1); - EXPECT(txcounters.num_tx_bytes == TCP_MSS + 40U); - memset(&txcounters, 0, sizeof(txcounters)); - } - EXPECT(sent_total == (TCP_WND - TCP_MSS)); - - /* now ACK the packet before the first */ - p = tcp_create_rx_segment(pcb, NULL, 0, 0, 0, TCP_ACK); - test_tcp_input(p, &netif); - /* ensure this didn't trigger a retransmission */ - EXPECT(txcounters.num_tx_calls == 0); - EXPECT(txcounters.num_tx_bytes == 0); - - EXPECT(pcb->persist_backoff == 0); - /* send the last packet, now a complete window has been sent */ - err = tcp_write(pcb, &tx_data[sent_total], TCP_MSS, TCP_WRITE_FLAG_COPY); - sent_total += TCP_MSS; - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - EXPECT(txcounters.num_tx_calls == 1); - EXPECT(txcounters.num_tx_bytes == TCP_MSS + 40U); - memset(&txcounters, 0, sizeof(txcounters)); - EXPECT(pcb->persist_backoff == 0); - - if (zero_window_probe_from_unsent) { - /* ACK all data but close the TX window */ - p = tcp_create_rx_segment_wnd(pcb, NULL, 0, 0, TCP_WND, TCP_ACK, 0); - test_tcp_input(p, &netif); - /* ensure this didn't trigger any transmission */ - EXPECT(txcounters.num_tx_calls == 0); - EXPECT(txcounters.num_tx_bytes == 0); - EXPECT(pcb->persist_backoff == 1); - } - - /* send one byte more (out of window) -> persist timer starts */ - err = tcp_write(pcb, &tx_data[sent_total], 1, TCP_WRITE_FLAG_COPY); - EXPECT_RET(err == ERR_OK); - err = tcp_output(pcb); - EXPECT_RET(err == ERR_OK); - EXPECT(txcounters.num_tx_calls == 0); - EXPECT(txcounters.num_tx_bytes == 0); - memset(&txcounters, 0, sizeof(txcounters)); - if (!zero_window_probe_from_unsent) { - /* no persist timer unless a zero window announcement has been received */ - EXPECT(pcb->persist_backoff == 0); - } else { - EXPECT(pcb->persist_backoff == 1); - - /* call tcp_timer some more times to let persist timer count up */ - for (i = 0; i < 4; i++) { - test_tcp_tmr(); - EXPECT(txcounters.num_tx_calls == 0); - EXPECT(txcounters.num_tx_bytes == 0); - } - - /* this should trigger the zero-window-probe */ - txcounters.copy_tx_packets = 1; - test_tcp_tmr(); - txcounters.copy_tx_packets = 0; - EXPECT(txcounters.num_tx_calls == 1); - EXPECT(txcounters.num_tx_bytes == 1 + 40U); - EXPECT(txcounters.tx_packets != NULL); - if (txcounters.tx_packets != NULL) { - u8_t sent; - u16_t ret; - ret = pbuf_copy_partial(txcounters.tx_packets, &sent, 1, 40U); - EXPECT(ret == 1); - EXPECT(sent == expected); - } - if (txcounters.tx_packets != NULL) { - pbuf_free(txcounters.tx_packets); - txcounters.tx_packets = NULL; - } - } - - /* make sure the pcb is freed */ - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} - -START_TEST(test_tcp_tx_full_window_lost_from_unsent) -{ - LWIP_UNUSED_ARG(_i); - test_tcp_tx_full_window_lost(1); -} -END_TEST - -START_TEST(test_tcp_tx_full_window_lost_from_unacked) -{ - LWIP_UNUSED_ARG(_i); - test_tcp_tx_full_window_lost(0); -} -END_TEST - -/** Create the suite including all tests for this module */ -Suite * -tcp_suite(void) -{ - TFun tests[] = { - test_tcp_new_abort, - test_tcp_recv_inseq, - test_tcp_fast_retx_recover, - test_tcp_fast_rexmit_wraparound, - test_tcp_rto_rexmit_wraparound, - test_tcp_tx_full_window_lost_from_unacked, - test_tcp_tx_full_window_lost_from_unsent - }; - return create_suite("TCP", tests, sizeof(tests)/sizeof(TFun), tcp_setup, tcp_teardown); -} diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp.h b/user/mpy/lib/lwip/test/unit/tcp/test_tcp.h deleted file mode 100644 index f1c4a46..0000000 --- a/user/mpy/lib/lwip/test/unit/tcp/test_tcp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __TEST_TCP_H__ -#define __TEST_TCP_H__ - -#include "../lwip_check.h" - -Suite *tcp_suite(void); - -#endif diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c b/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c deleted file mode 100644 index 764de1c..0000000 --- a/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.c +++ /dev/null @@ -1,944 +0,0 @@ -#include "test_tcp_oos.h" - -#include "lwip/tcp_impl.h" -#include "lwip/stats.h" -#include "tcp_helper.h" - -#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS -#error "This tests needs TCP- and MEMP-statistics enabled" -#endif -#if !TCP_QUEUE_OOSEQ -#error "This tests needs TCP_QUEUE_OOSEQ enabled" -#endif - -/** CHECK_SEGMENTS_ON_OOSEQ: - * 1: check count, seqno and len of segments on pcb->ooseq (strict) - * 0: only check that bytes are received in correct order (less strict) */ -#define CHECK_SEGMENTS_ON_OOSEQ 1 - -#if CHECK_SEGMENTS_ON_OOSEQ -#define EXPECT_OOSEQ(x) EXPECT(x) -#else -#define EXPECT_OOSEQ(x) -#endif - -/* helper functions */ - -/** Get the numbers of segments on the ooseq list */ -static int tcp_oos_count(struct tcp_pcb* pcb) -{ - int num = 0; - struct tcp_seg* seg = pcb->ooseq; - while(seg != NULL) { - num++; - seg = seg->next; - } - return num; -} - -/** Get the numbers of pbufs on the ooseq list */ -static int tcp_oos_pbuf_count(struct tcp_pcb* pcb) -{ - int num = 0; - struct tcp_seg* seg = pcb->ooseq; - while(seg != NULL) { - num += pbuf_clen(seg->p); - seg = seg->next; - } - return num; -} - -/** Get the seqno of a segment (by index) on the ooseq list - * - * @param pcb the pcb to check for ooseq segments - * @param seg_index index of the segment on the ooseq list - * @return seqno of the segment - */ -static u32_t -tcp_oos_seg_seqno(struct tcp_pcb* pcb, int seg_index) -{ - int num = 0; - struct tcp_seg* seg = pcb->ooseq; - - /* then check the actual segment */ - while(seg != NULL) { - if(num == seg_index) { - return seg->tcphdr->seqno; - } - num++; - seg = seg->next; - } - fail(); - return 0; -} - -/** Get the tcplen (datalen + SYN/FIN) of a segment (by index) on the ooseq list - * - * @param pcb the pcb to check for ooseq segments - * @param seg_index index of the segment on the ooseq list - * @return tcplen of the segment - */ -static int -tcp_oos_seg_tcplen(struct tcp_pcb* pcb, int seg_index) -{ - int num = 0; - struct tcp_seg* seg = pcb->ooseq; - - /* then check the actual segment */ - while(seg != NULL) { - if(num == seg_index) { - return TCP_TCPLEN(seg); - } - num++; - seg = seg->next; - } - fail(); - return -1; -} - -/** Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list - * - * @param pcb the pcb to check for ooseq segments - * @return tcplen of all segment - */ -static int -tcp_oos_tcplen(struct tcp_pcb* pcb) -{ - int len = 0; - struct tcp_seg* seg = pcb->ooseq; - - /* then check the actual segment */ - while(seg != NULL) { - len += TCP_TCPLEN(seg); - seg = seg->next; - } - return len; -} - -/* Setup/teardown functions */ - -static void -tcp_oos_setup(void) -{ - tcp_remove_all(); -} - -static void -tcp_oos_teardown(void) -{ - tcp_remove_all(); -} - - - -/* Test functions */ - -/** create multiple segments and pass them to tcp_input in a wrong - * order to see if ooseq-caching works correctly - * FIN is received in out-of-sequence segments only */ -START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ) -{ - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq; - char data[] = { - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16}; - ip_addr_t remote_ip, local_ip; - u16_t data_len; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - LWIP_UNUSED_ARG(_i); - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - data_len = sizeof(data); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = data_len; - counters.expected_data = data; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - - /* create segments */ - /* pinseq is sent as last segment! */ - pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK); - /* p1: 8 bytes before FIN */ - /* seqno: 8..16 */ - p_8_9 = tcp_create_rx_segment(pcb, &data[8], 8, 8, 0, TCP_ACK|TCP_FIN); - /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */ - /* seqno: 4..11 */ - p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK); - /* p3: same as p2 but 2 bytes longer */ - /* seqno: 4..13 */ - p_4_10 = tcp_create_rx_segment(pcb, &data[4], 10, 4, 0, TCP_ACK); - /* p4: 14 bytes before FIN, includes data from p1 and p2, plus partly from pinseq */ - /* seqno: 2..15 */ - p_2_14 = tcp_create_rx_segment(pcb, &data[2], 14, 2, 0, TCP_ACK); - /* FIN, seqno 16 */ - p_fin = tcp_create_rx_segment(pcb, NULL, 0,16, 0, TCP_ACK|TCP_FIN); - EXPECT(pinseq != NULL); - EXPECT(p_8_9 != NULL); - EXPECT(p_4_8 != NULL); - EXPECT(p_4_10 != NULL); - EXPECT(p_2_14 != NULL); - EXPECT(p_fin != NULL); - if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) { - /* pass the segment to tcp_input */ - test_tcp_input(p_8_9, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 8); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */ - - /* pass the segment to tcp_input */ - test_tcp_input(p_4_8, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */ - - /* pass the segment to tcp_input */ - test_tcp_input(p_4_10, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* ooseq queue: unchanged */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */ - - /* pass the segment to tcp_input */ - test_tcp_input(p_2_14, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */ - - /* pass the segment to tcp_input */ - test_tcp_input(p_fin, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* ooseq queue: unchanged */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */ - - /* pass the segment to tcp_input */ - test_tcp_input(pinseq, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 1); - EXPECT(counters.recv_calls == 1); - EXPECT(counters.recved_bytes == data_len); - EXPECT(counters.err_calls == 0); - EXPECT(pcb->ooseq == NULL); - } - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} -END_TEST - - -/** create multiple segments and pass them to tcp_input in a wrong - * order to see if ooseq-caching works correctly - * FIN is received IN-SEQUENCE at the end */ -START_TEST(test_tcp_recv_ooseq_FIN_INSEQ) -{ - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN; - char data[] = { - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16}; - ip_addr_t remote_ip, local_ip; - u16_t data_len; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - LWIP_UNUSED_ARG(_i); - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - data_len = sizeof(data); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = data_len; - counters.expected_data = data; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - - /* create segments */ - /* p1: 7 bytes - 2 before FIN */ - /* seqno: 1..2 */ - p_1_2 = tcp_create_rx_segment(pcb, &data[1], 2, 1, 0, TCP_ACK); - /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */ - /* seqno: 4..11 */ - p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK); - /* p3: same as p2 but 2 bytes longer and one byte more at the front */ - /* seqno: 3..13 */ - p_3_11 = tcp_create_rx_segment(pcb, &data[3], 11, 3, 0, TCP_ACK); - /* p4: 13 bytes - 2 before FIN - should be ignored as contained in p1 and p3 */ - /* seqno: 2..13 */ - p_2_12 = tcp_create_rx_segment(pcb, &data[2], 12, 2, 0, TCP_ACK); - /* pinseq is the first segment that is held back to create ooseq! */ - /* seqno: 0..3 */ - pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK); - /* p5: last byte before FIN */ - /* seqno: 15 */ - p_15_1 = tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK); - /* p6: same as p5, should be ignored */ - p_15_1a= tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK); - /* pinseqFIN: last 2 bytes plus FIN */ - /* only segment containing seqno 14 and FIN */ - pinseqFIN = tcp_create_rx_segment(pcb, &data[14], 2, 14, 0, TCP_ACK|TCP_FIN); - EXPECT(pinseq != NULL); - EXPECT(p_1_2 != NULL); - EXPECT(p_4_8 != NULL); - EXPECT(p_3_11 != NULL); - EXPECT(p_2_12 != NULL); - EXPECT(p_15_1 != NULL); - EXPECT(p_15_1a != NULL); - EXPECT(pinseqFIN != NULL); - if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL) - && (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) { - /* pass the segment to tcp_input */ - test_tcp_input(p_1_2, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); - - /* pass the segment to tcp_input */ - test_tcp_input(p_4_8, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 4); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8); - - /* pass the segment to tcp_input */ - test_tcp_input(p_3_11, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); - /* p_3_11 has removed p_4_8 from ooseq */ - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 3); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11); - - /* pass the segment to tcp_input */ - test_tcp_input(p_2_12, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 2); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12); - - /* pass the segment to tcp_input */ - test_tcp_input(pinseq, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 1); - EXPECT(counters.recved_bytes == 14); - EXPECT(counters.err_calls == 0); - EXPECT(pcb->ooseq == NULL); - - /* pass the segment to tcp_input */ - test_tcp_input(p_15_1, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 1); - EXPECT(counters.recved_bytes == 14); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); - - /* pass the segment to tcp_input */ - test_tcp_input(p_15_1a, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 1); - EXPECT(counters.recved_bytes == 14); - EXPECT(counters.err_calls == 0); - /* check ooseq queue: unchanged */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); - EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15); - EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); - - /* pass the segment to tcp_input */ - test_tcp_input(pinseqFIN, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 1); - EXPECT(counters.recv_calls == 2); - EXPECT(counters.recved_bytes == data_len); - EXPECT(counters.err_calls == 0); - EXPECT(pcb->ooseq == NULL); - } - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} -END_TEST - -static char data_full_wnd[TCP_WND]; - -/** create multiple segments and pass them to tcp_input with the first segment missing - * to simulate overruning the rxwin with ooseq queueing enabled */ -START_TEST(test_tcp_recv_ooseq_overrun_rxwin) -{ -#if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS - int i, k; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *pinseq, *p_ovr; - ip_addr_t remote_ip, local_ip; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - int datalen = 0; - int datalen2; - - for(i = 0; i < sizeof(data_full_wnd); i++) { - data_full_wnd[i] = (char)i; - } - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = TCP_WND; - counters.expected_data = data_full_wnd; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->rcv_nxt = 0x8000; - - /* create segments */ - /* pinseq is sent as last segment! */ - pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); - - for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) { - int count, expected_datalen; - struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], - TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); - EXPECT_RET(p != NULL); - /* pass the segment to tcp_input */ - test_tcp_input(p, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - count = tcp_oos_count(pcb); - EXPECT_OOSEQ(count == k+1); - datalen = tcp_oos_tcplen(pcb); - if (i + TCP_MSS < TCP_WND) { - expected_datalen = (k+1)*TCP_MSS; - } else { - expected_datalen = TCP_WND - TCP_MSS; - } - if (datalen != expected_datalen) { - EXPECT_OOSEQ(datalen == expected_datalen); - } - } - - /* pass in one more segment, cleary overrunning the rxwin */ - p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); - EXPECT_RET(p_ovr != NULL); - /* pass the segment to tcp_input */ - test_tcp_input(p_ovr, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == k); - datalen2 = tcp_oos_tcplen(pcb); - EXPECT_OOSEQ(datalen == datalen2); - - /* now pass inseq */ - test_tcp_input(pinseq, &netif); - EXPECT(pcb->ooseq == NULL); - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -#endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */ - LWIP_UNUSED_ARG(_i); -} -END_TEST - -START_TEST(test_tcp_recv_ooseq_max_bytes) -{ -#if TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) - int i, k; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *p_ovr; - ip_addr_t remote_ip, local_ip; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - int datalen = 0; - int datalen2; - - for(i = 0; i < sizeof(data_full_wnd); i++) { - data_full_wnd[i] = (char)i; - } - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = TCP_WND; - counters.expected_data = data_full_wnd; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->rcv_nxt = 0x8000; - - /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */ - - /* create segments and 'recv' them */ - for(k = 1, i = 1; k < TCP_OOSEQ_MAX_BYTES; k += TCP_MSS, i++) { - int count; - struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[k], - TCP_MSS, k, 0, TCP_ACK); - EXPECT_RET(p != NULL); - EXPECT_RET(p->next == NULL); - /* pass the segment to tcp_input */ - test_tcp_input(p, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - count = tcp_oos_pbuf_count(pcb); - EXPECT_OOSEQ(count == i); - datalen = tcp_oos_tcplen(pcb); - EXPECT_OOSEQ(datalen == (i * TCP_MSS)); - } - - /* pass in one more segment, overrunning the limit */ - p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[k+1], 1, k+1, 0, TCP_ACK); - EXPECT_RET(p_ovr != NULL); - /* pass the segment to tcp_input */ - test_tcp_input(p_ovr, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue (ensure the new segment was not accepted) */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1)); - datalen2 = tcp_oos_tcplen(pcb); - EXPECT_OOSEQ(datalen2 == ((i-1) * TCP_MSS)); - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -#endif /* TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */ - LWIP_UNUSED_ARG(_i); -} -END_TEST - -START_TEST(test_tcp_recv_ooseq_max_pbufs) -{ -#if TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_PBUFS < ((TCP_WND / TCP_MSS) + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) - int i; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *p_ovr; - ip_addr_t remote_ip, local_ip; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - int datalen = 0; - int datalen2; - - for(i = 0; i < sizeof(data_full_wnd); i++) { - data_full_wnd[i] = (char)i; - } - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = TCP_WND; - counters.expected_data = data_full_wnd; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->rcv_nxt = 0x8000; - - /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */ - - /* create segments and 'recv' them */ - for(i = 1; i <= TCP_OOSEQ_MAX_PBUFS; i++) { - int count; - struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[i], - 1, i, 0, TCP_ACK); - EXPECT_RET(p != NULL); - EXPECT_RET(p->next == NULL); - /* pass the segment to tcp_input */ - test_tcp_input(p, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue */ - count = tcp_oos_pbuf_count(pcb); - EXPECT_OOSEQ(count == i); - datalen = tcp_oos_tcplen(pcb); - EXPECT_OOSEQ(datalen == i); - } - - /* pass in one more segment, overrunning the limit */ - p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[i+1], 1, i+1, 0, TCP_ACK); - EXPECT_RET(p_ovr != NULL); - /* pass the segment to tcp_input */ - test_tcp_input(p_ovr, &netif); - /* check if counters are as expected */ - EXPECT(counters.close_calls == 0); - EXPECT(counters.recv_calls == 0); - EXPECT(counters.recved_bytes == 0); - EXPECT(counters.err_calls == 0); - /* check ooseq queue (ensure the new segment was not accepted) */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1)); - datalen2 = tcp_oos_tcplen(pcb); - EXPECT_OOSEQ(datalen2 == (i-1)); - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -#endif /* TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */ - LWIP_UNUSED_ARG(_i); -} -END_TEST - -static void -check_rx_counters(struct tcp_pcb *pcb, struct test_tcp_counters *counters, u32_t exp_close_calls, u32_t exp_rx_calls, - u32_t exp_rx_bytes, u32_t exp_err_calls, int exp_oos_count, int exp_oos_len) -{ - int oos_len; - EXPECT(counters->close_calls == exp_close_calls); - EXPECT(counters->recv_calls == exp_rx_calls); - EXPECT(counters->recved_bytes == exp_rx_bytes); - EXPECT(counters->err_calls == exp_err_calls); - /* check that pbuf is queued in ooseq */ - EXPECT_OOSEQ(tcp_oos_count(pcb) == exp_oos_count); - oos_len = tcp_oos_tcplen(pcb); - EXPECT_OOSEQ(exp_oos_len == oos_len); -} - -/* this test uses 4 packets: - * - data (len=TCP_MSS) - * - FIN - * - data after FIN (len=1) (invalid) - * - 2nd FIN (invalid) - * - * the parameter 'delay_packet' is a bitmask that choses which on these packets is ooseq - */ -static void test_tcp_recv_ooseq_double_FINs(int delay_packet) -{ - int i, k; - struct test_tcp_counters counters; - struct tcp_pcb* pcb; - struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq; - ip_addr_t remote_ip, local_ip; - u16_t remote_port = 0x100, local_port = 0x101; - struct netif netif; - u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0; - int first_dropped = 0xff; - int last_dropped = 0; - - for(i = 0; i < sizeof(data_full_wnd); i++) { - data_full_wnd[i] = (char)i; - } - - /* initialize local vars */ - memset(&netif, 0, sizeof(netif)); - IP4_ADDR(&local_ip, 192, 168, 1, 1); - IP4_ADDR(&remote_ip, 192, 168, 1, 2); - /* initialize counter struct */ - memset(&counters, 0, sizeof(counters)); - counters.expected_data_len = TCP_WND; - counters.expected_data = data_full_wnd; - - /* create and initialize the pcb */ - pcb = test_tcp_new_counters_pcb(&counters); - EXPECT_RET(pcb != NULL); - tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port); - pcb->rcv_nxt = 0x8000; - - /* create segments */ - p = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); - p_normal_fin = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS, 0, TCP_ACK|TCP_FIN); - k = 1; - p_data_after_fin = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS+1], k, TCP_MSS+1, 0, TCP_ACK); - p_2nd_fin_ooseq = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS+1+k, 0, TCP_ACK|TCP_FIN); - - if(delay_packet & 1) { - /* drop normal data */ - first_dropped = 1; - last_dropped = 1; - } else { - /* send normal data */ - test_tcp_input(p, &netif); - exp_rx_calls++; - exp_rx_bytes += TCP_MSS; - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 2) { - /* drop FIN */ - if(first_dropped > 2) { - first_dropped = 2; - } - last_dropped = 2; - } else { - /* send FIN */ - test_tcp_input(p_normal_fin, &netif); - if (first_dropped < 2) { - /* already dropped packets, this one is ooseq */ - exp_oos_pbufs++; - exp_oos_tcplen++; - } else { - /* inseq */ - exp_close_calls++; - } - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 4) { - /* drop data-after-FIN */ - if(first_dropped > 3) { - first_dropped = 3; - } - last_dropped = 3; - } else { - /* send data-after-FIN */ - test_tcp_input(p_data_after_fin, &netif); - if (first_dropped < 3) { - /* already dropped packets, this one is ooseq */ - if (delay_packet & 2) { - /* correct FIN was ooseq */ - exp_oos_pbufs++; - exp_oos_tcplen += k; - } - } else { - /* inseq: no change */ - } - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 8) { - /* drop 2nd-FIN */ - if(first_dropped > 4) { - first_dropped = 4; - } - last_dropped = 4; - } else { - /* send 2nd-FIN */ - test_tcp_input(p_2nd_fin_ooseq, &netif); - if (first_dropped < 3) { - /* already dropped packets, this one is ooseq */ - if (delay_packet & 2) { - /* correct FIN was ooseq */ - exp_oos_pbufs++; - exp_oos_tcplen++; - } - } else { - /* inseq: no change */ - } - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 1) { - /* dropped normal data before */ - test_tcp_input(p, &netif); - exp_rx_calls++; - exp_rx_bytes += TCP_MSS; - if((delay_packet & 2) == 0) { - /* normal FIN was NOT delayed */ - exp_close_calls++; - exp_oos_pbufs = exp_oos_tcplen = 0; - } - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 2) { - /* dropped normal FIN before */ - test_tcp_input(p_normal_fin, &netif); - exp_close_calls++; - exp_oos_pbufs = exp_oos_tcplen = 0; - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 4) { - /* dropped data-after-FIN before */ - test_tcp_input(p_data_after_fin, &netif); - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - if(delay_packet & 8) { - /* dropped 2nd-FIN before */ - test_tcp_input(p_2nd_fin_ooseq, &netif); - } - /* check if counters are as expected */ - check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); - - /* check that ooseq data has been dumped */ - EXPECT(pcb->ooseq == NULL); - - /* make sure the pcb is freed */ - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1); - tcp_abort(pcb); - EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0); -} - -/** create multiple segments and pass them to tcp_input with the first segment missing - * to simulate overruning the rxwin with ooseq queueing enabled */ -#define FIN_TEST(name, num) \ - START_TEST(name) \ - { \ - LWIP_UNUSED_ARG(_i); \ - test_tcp_recv_ooseq_double_FINs(num); \ - } \ - END_TEST -FIN_TEST(test_tcp_recv_ooseq_double_FIN_0, 0) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_1, 1) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_2, 2) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_3, 3) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_4, 4) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_5, 5) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_6, 6) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_7, 7) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_8, 8) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_9, 9) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_10, 10) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_11, 11) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_12, 12) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_13, 13) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_14, 14) -FIN_TEST(test_tcp_recv_ooseq_double_FIN_15, 15) - - -/** Create the suite including all tests for this module */ -Suite * -tcp_oos_suite(void) -{ - TFun tests[] = { - test_tcp_recv_ooseq_FIN_OOSEQ, - test_tcp_recv_ooseq_FIN_INSEQ, - test_tcp_recv_ooseq_overrun_rxwin, - test_tcp_recv_ooseq_max_bytes, - test_tcp_recv_ooseq_max_pbufs, - test_tcp_recv_ooseq_double_FIN_0, - test_tcp_recv_ooseq_double_FIN_1, - test_tcp_recv_ooseq_double_FIN_2, - test_tcp_recv_ooseq_double_FIN_3, - test_tcp_recv_ooseq_double_FIN_4, - test_tcp_recv_ooseq_double_FIN_5, - test_tcp_recv_ooseq_double_FIN_6, - test_tcp_recv_ooseq_double_FIN_7, - test_tcp_recv_ooseq_double_FIN_8, - test_tcp_recv_ooseq_double_FIN_9, - test_tcp_recv_ooseq_double_FIN_10, - test_tcp_recv_ooseq_double_FIN_11, - test_tcp_recv_ooseq_double_FIN_12, - test_tcp_recv_ooseq_double_FIN_13, - test_tcp_recv_ooseq_double_FIN_14, - test_tcp_recv_ooseq_double_FIN_15 - }; - return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(TFun), tcp_oos_setup, tcp_oos_teardown); -} diff --git a/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h b/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h deleted file mode 100644 index 5e411f0..0000000 --- a/user/mpy/lib/lwip/test/unit/tcp/test_tcp_oos.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __TEST_TCP_OOS_H__ -#define __TEST_TCP_OOS_H__ - -#include "../lwip_check.h" - -Suite *tcp_oos_suite(void); - -#endif diff --git a/user/mpy/lib/lwip/test/unit/udp/test_udp.c b/user/mpy/lib/lwip/test/unit/udp/test_udp.c deleted file mode 100644 index a2f02af..0000000 --- a/user/mpy/lib/lwip/test/unit/udp/test_udp.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "test_udp.h" - -#include "lwip/udp.h" -#include "lwip/stats.h" - -#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS -#error "This tests needs UDP- and MEMP-statistics enabled" -#endif - -/* Helper functions */ -static void -udp_remove_all(void) -{ - struct udp_pcb *pcb = udp_pcbs; - struct udp_pcb *pcb2; - - while(pcb != NULL) { - pcb2 = pcb; - pcb = pcb->next; - udp_remove(pcb2); - } - fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); -} - -/* Setups/teardown functions */ - -static void -udp_setup(void) -{ - udp_remove_all(); -} - -static void -udp_teardown(void) -{ - udp_remove_all(); -} - - -/* Test functions */ - -START_TEST(test_udp_new_remove) -{ - struct udp_pcb* pcb; - LWIP_UNUSED_ARG(_i); - - fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); - - pcb = udp_new(); - fail_unless(pcb != NULL); - if (pcb != NULL) { - fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 1); - udp_remove(pcb); - fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); - } -} -END_TEST - - -/** Create the suite including all tests for this module */ -Suite * -udp_suite(void) -{ - TFun tests[] = { - test_udp_new_remove, - }; - return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown); -} diff --git a/user/mpy/lib/lwip/test/unit/udp/test_udp.h b/user/mpy/lib/lwip/test/unit/udp/test_udp.h deleted file mode 100644 index 9335368..0000000 --- a/user/mpy/lib/lwip/test/unit/udp/test_udp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __TEST_UDP_H__ -#define __TEST_UDP_H__ - -#include "../lwip_check.h" - -Suite* udp_suite(void); - -#endif diff --git a/user/mpy/lib/memzip/README.md b/user/mpy/lib/memzip/README.md deleted file mode 100644 index 287d0fc..0000000 --- a/user/mpy/lib/memzip/README.md +++ /dev/null @@ -1,28 +0,0 @@ -MEMZIP - a simple readonly file system - -memzip takes a zip file which is comprised of uncompressed files and -and presents it as a filesystem, allowing Python files to be imported. - -The script make-memzip.py takes a directory name and will create a zip file -containing uncompressed files found in the directory. It will then generate -a C file which contains the data from the zip file. - -A typical addition to a makefile would look like: -``` -SRC_C += \ - lib/memzip/import.c \ - lib/memzip/lexermemzip.c \ - lib/memzip/memzip.c \ - -OBJ += $(BUILD)/memzip-files.o - -MAKE_MEMZIP = ../lib/memzip/make-memzip.py - -$(BUILD)/memzip-files.o: $(BUILD)/memzip-files.c - $(call compile_c) - -$(BUILD)/memzip-files.c: $(shell find ${MEMZIP_DIR} -type f) - @$(ECHO) "Creating $@" - $(Q)$(PYTHON) $(MAKE_MEMZIP) --zip-file $(BUILD)/memzip-files.zip --c-file $@ $(MEMZIP_DIR) -``` - diff --git a/user/mpy/lib/memzip/import.c b/user/mpy/lib/memzip/import.c deleted file mode 100644 index 2d5225b..0000000 --- a/user/mpy/lib/memzip/import.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#include "py/lexer.h" -#include "memzip.h" - -mp_import_stat_t mp_import_stat(const char *path) { - MEMZIP_FILE_INFO info; - - if (memzip_stat(path, &info) != MZ_OK) { - return MP_IMPORT_STAT_NO_EXIST; - } - - if (info.is_dir) { - return MP_IMPORT_STAT_DIR; - } - return MP_IMPORT_STAT_FILE; -} diff --git a/user/mpy/lib/memzip/lexermemzip.c b/user/mpy/lib/memzip/lexermemzip.c deleted file mode 100644 index 6b26961..0000000 --- a/user/mpy/lib/memzip/lexermemzip.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#include "py/lexer.h" -#include "py/runtime.h" -#include "py/mperrno.h" -#include "memzip.h" - -mp_lexer_t *mp_lexer_new_from_file(const char *filename) -{ - void *data; - size_t len; - - if (memzip_locate(filename, &data, &len) != MZ_OK) { - mp_raise_OSError(MP_ENOENT); - } - - return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (mp_uint_t)len, 0); -} - diff --git a/user/mpy/lib/memzip/make-memzip.py b/user/mpy/lib/memzip/make-memzip.py deleted file mode 100755 index 9730f5e..0000000 --- a/user/mpy/lib/memzip/make-memzip.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -# Takes a directory of files and zips them up (as uncompressed files). -# This then gets converted into a C data structure which can be read -# like a filesystem at runtime. -# -# This is somewhat like frozen modules in python, but allows arbitrary files -# to be used. - -from __future__ import print_function - -import argparse -import os -import subprocess -import sys -import types - -def create_zip(zip_filename, zip_dir): - abs_zip_filename = os.path.abspath(zip_filename) - save_cwd = os.getcwd() - os.chdir(zip_dir) - if os.path.exists(abs_zip_filename): - os.remove(abs_zip_filename) - subprocess.check_call(['zip', '-0', '-r', '-D', abs_zip_filename, '.']) - os.chdir(save_cwd) - -def create_c_from_file(c_filename, zip_filename): - with open(zip_filename, 'rb') as zip_file: - with open(c_filename, 'wb') as c_file: - print('#include ', file=c_file) - print('', file=c_file) - print('const uint8_t memzip_data[] = {', file=c_file) - while True: - buf = zip_file.read(16) - if not buf: - break - print(' ', end='', file=c_file) - for byte in buf: - if type(byte) is types.StringType: - print(' 0x{:02x},'.format(ord(byte)), end='', file=c_file) - else: - print(' 0x{:02x},'.format(byte), end='', file=c_file) - print('', file=c_file) - print('};', file=c_file) - -def main(): - parser = argparse.ArgumentParser( - prog='make-memzip.py', - usage='%(prog)s [options] [command]', - description='Generates a C source memzip file.' - ) - parser.add_argument( - '-z', '--zip-file', - dest='zip_filename', - help='Specifies the name of the created zip file.', - default='memzip_files.zip' - ) - parser.add_argument( - '-c', '--c-file', - dest='c_filename', - help='Specifies the name of the created C source file.', - default='memzip_files.c' - ) - parser.add_argument( - dest='source_dir', - default='memzip_files' - ) - args = parser.parse_args(sys.argv[1:]) - - print('args.zip_filename =', args.zip_filename) - print('args.c_filename =', args.c_filename) - print('args.source_dir =', args.source_dir) - - create_zip(args.zip_filename, args.source_dir) - create_c_from_file(args.c_filename, args.zip_filename) - -if __name__ == "__main__": - main() - diff --git a/user/mpy/lib/memzip/memzip.c b/user/mpy/lib/memzip/memzip.c deleted file mode 100644 index 3fbea8e..0000000 --- a/user/mpy/lib/memzip/memzip.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include -#include "py/mpconfig.h" -#include "py/misc.h" -#include "memzip.h" - -extern uint8_t memzip_data[]; - -const MEMZIP_FILE_HDR *memzip_find_file_header(const char *filename) { - - const MEMZIP_FILE_HDR *file_hdr = (const MEMZIP_FILE_HDR *)memzip_data; - uint8_t *mem_data; - - /* Zip file filenames don't have a leading /, so we strip it off */ - - if (*filename == '/') { - filename++; - } - while (file_hdr->signature == MEMZIP_FILE_HEADER_SIGNATURE) { - const char *file_hdr_filename = (const char *)&file_hdr[1]; - mem_data = (uint8_t *)file_hdr_filename; - mem_data += file_hdr->filename_len; - mem_data += file_hdr->extra_len; - if (!strncmp(file_hdr_filename, filename, file_hdr->filename_len)) { - /* We found a match */ - return file_hdr; - } - mem_data += file_hdr->uncompressed_size; - file_hdr = (const MEMZIP_FILE_HDR *)mem_data; - } - return NULL; -} - -bool memzip_is_dir(const char *filename) { - const MEMZIP_FILE_HDR *file_hdr = (const MEMZIP_FILE_HDR *)memzip_data; - uint8_t *mem_data; - - if (strcmp(filename, "/") == 0) { - // The root directory is a directory. - return true; - } - - // Zip filenames don't have a leading /, so we strip it off - if (*filename == '/') { - filename++; - } - size_t filename_len = strlen(filename); - - while (file_hdr->signature == MEMZIP_FILE_HEADER_SIGNATURE) { - const char *file_hdr_filename = (const char *)&file_hdr[1]; - if (filename_len < file_hdr->filename_len && - strncmp(file_hdr_filename, filename, filename_len) == 0 && - file_hdr_filename[filename_len] == '/') { - return true; - } - - mem_data = (uint8_t *)file_hdr_filename; - mem_data += file_hdr->filename_len; - mem_data += file_hdr->extra_len; - mem_data += file_hdr->uncompressed_size; - file_hdr = (const MEMZIP_FILE_HDR *)mem_data; - } - return NULL; - -} - -MEMZIP_RESULT memzip_locate(const char *filename, void **data, size_t *len) -{ - const MEMZIP_FILE_HDR *file_hdr = memzip_find_file_header(filename); - if (file_hdr == NULL) { - return MZ_NO_FILE; - } - if (file_hdr->compression_method != 0) { - return MZ_FILE_COMPRESSED; - } - - uint8_t *mem_data; - mem_data = (uint8_t *)&file_hdr[1]; - mem_data += file_hdr->filename_len; - mem_data += file_hdr->extra_len; - - *data = mem_data; - *len = file_hdr->uncompressed_size; - return MZ_OK; -} - -MEMZIP_RESULT memzip_stat(const char *path, MEMZIP_FILE_INFO *info) { - const MEMZIP_FILE_HDR *file_hdr = memzip_find_file_header(path); - if (file_hdr == NULL) { - if (memzip_is_dir(path)) { - info->file_size = 0; - info->last_mod_date = 0; - info->last_mod_time = 0; - info->is_dir = 1; - return MZ_OK; - } - return MZ_NO_FILE; - } - info->file_size = file_hdr->uncompressed_size; - info->last_mod_date = file_hdr->last_mod_date; - info->last_mod_time = file_hdr->last_mod_time; - info->is_dir = 0; - - return MZ_OK; -} diff --git a/user/mpy/lib/memzip/memzip.h b/user/mpy/lib/memzip/memzip.h deleted file mode 100644 index 667e2df..0000000 --- a/user/mpy/lib/memzip/memzip.h +++ /dev/null @@ -1,83 +0,0 @@ -#pragma pack(push, 1) - -#define MEMZIP_FILE_HEADER_SIGNATURE 0x04034b50 -typedef struct -{ - uint32_t signature; - uint16_t version; - uint16_t flags; - uint16_t compression_method; - uint16_t last_mod_time; - uint16_t last_mod_date; - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; - uint16_t filename_len; - uint16_t extra_len; - - /* char filename[filename_len] */ - /* uint8_t extra[extra_len] */ - -} MEMZIP_FILE_HDR; - -#define MEMZIP_CENTRAL_DIRECTORY_SIGNATURE 0x02014b50 -typedef struct -{ - uint32_t signature; - uint16_t version_made_by; - uint16_t version_read_with; - uint16_t flags; - uint16_t compression_method; - uint16_t last_mod_time; - uint16_t last_mod_date; - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; - uint16_t filename_len; - uint16_t extra_len; - uint16_t disk_num; - uint16_t internal_file_attributes; - uint32_t external_file_attributes; - uint32_t file_header_offset; - - /* char filename[filename_len] */ - /* uint8_t extra[extra_len] */ - -} MEMZIP_CENTRAL_DIRECTORY_HDR; - -#define MEMZIP_END_OF_CENTRAL_DIRECTORY_SIGNATURE 0x06054b50 -typedef struct -{ - uint32_t signature; - uint16_t disk_num; - uint16_t central_directory_disk; - uint16_t num_central_directories_this_disk; - uint16_t total_central_directories; - uint32_t central_directory_size; - uint32_t central_directory_offset; - uint16_t comment_len; - - /* char comment[comment_len] */ - -} MEMZIP_END_OF_CENTRAL_DIRECTORY; - -#pragma pack(pop) - -typedef enum { - MZ_OK = 0, /* (0) Succeeded */ - MZ_NO_FILE, /* (1) Could not find the file. */ - MZ_FILE_COMPRESSED, /* (2) File is compressed (expecting uncompressed) */ - -} MEMZIP_RESULT; - -typedef struct { - uint32_t file_size; - uint16_t last_mod_date; - uint16_t last_mod_time; - uint8_t is_dir; - -} MEMZIP_FILE_INFO; - -MEMZIP_RESULT memzip_locate(const char *filename, void **data, size_t *len); - -MEMZIP_RESULT memzip_stat(const char *path, MEMZIP_FILE_INFO *info); diff --git a/user/mpy/lib/mp-readline/readline.c b/user/mpy/lib/mp-readline/readline.c deleted file mode 100644 index 9d254d8..0000000 --- a/user/mpy/lib/mp-readline/readline.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpstate.h" -#include "py/repl.h" -#include "py/mphal.h" -#include "lib/mp-readline/readline.h" - -#if 0 // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -#define READLINE_HIST_SIZE (MP_ARRAY_SIZE(MP_STATE_PORT(readline_hist))) - -enum { ESEQ_NONE, ESEQ_ESC, ESEQ_ESC_BRACKET, ESEQ_ESC_BRACKET_DIGIT, ESEQ_ESC_O }; - -void readline_init0(void) { - memset(MP_STATE_PORT(readline_hist), 0, READLINE_HIST_SIZE * sizeof(const char*)); -} - -STATIC char *str_dup_maybe(const char *str) { - uint32_t len = strlen(str); - char *s2 = m_new_maybe(char, len + 1); - if (s2 == NULL) { - return NULL; - } - memcpy(s2, str, len + 1); - return s2; -} - -// By default assume terminal which implements VT100 commands... -#ifndef MICROPY_HAL_HAS_VT100 -#define MICROPY_HAL_HAS_VT100 (1) -#endif - -// ...and provide the implementation using them -#if MICROPY_HAL_HAS_VT100 -STATIC void mp_hal_move_cursor_back(uint pos) { - if (pos <= 4) { - // fast path for most common case of 1 step back - mp_hal_stdout_tx_strn("\b\b\b\b", pos); - } else { - char vt100_command[6]; - // snprintf needs space for the terminating null character - int n = snprintf(&vt100_command[0], sizeof(vt100_command), "\x1b[%u", pos); - if (n > 0) { - vt100_command[n] = 'D'; // replace null char - mp_hal_stdout_tx_strn(vt100_command, n + 1); - } - } -} - -STATIC void mp_hal_erase_line_from_cursor(uint n_chars_to_erase) { - (void)n_chars_to_erase; - mp_hal_stdout_tx_strn("\x1b[K", 3); -} -#endif - -typedef struct _readline_t { - vstr_t *line; - size_t orig_line_len; - int escape_seq; - int hist_cur; - size_t cursor_pos; - char escape_seq_buf[1]; - const char *prompt; -} readline_t; - -STATIC readline_t rl; - -int readline_process_char(int c) { - size_t last_line_len = rl.line->len; - int redraw_step_back = 0; - bool redraw_from_cursor = false; - int redraw_step_forward = 0; - if (rl.escape_seq == ESEQ_NONE) { - if (CHAR_CTRL_A <= c && c <= CHAR_CTRL_E && vstr_len(rl.line) == rl.orig_line_len) { - // control character with empty line - return c; - } else if (c == CHAR_CTRL_A) { - // CTRL-A with non-empty line is go-to-start-of-line - goto home_key; - #if MICROPY_REPL_EMACS_KEYS - } else if (c == CHAR_CTRL_B) { - // CTRL-B with non-empty line is go-back-one-char - goto left_arrow_key; - #endif - } else if (c == CHAR_CTRL_C) { - // CTRL-C with non-empty line is cancel - return c; - #if MICROPY_REPL_EMACS_KEYS - } else if (c == CHAR_CTRL_D) { - // CTRL-D with non-empty line is delete-at-cursor - goto delete_key; - #endif - } else if (c == CHAR_CTRL_E) { - // CTRL-E is go-to-end-of-line - goto end_key; - #if MICROPY_REPL_EMACS_KEYS - } else if (c == CHAR_CTRL_F) { - // CTRL-F with non-empty line is go-forward-one-char - goto right_arrow_key; - } else if (c == CHAR_CTRL_K) { - // CTRL-K is kill from cursor to end-of-line, inclusive - vstr_cut_tail_bytes(rl.line, last_line_len - rl.cursor_pos); - // set redraw parameters - redraw_from_cursor = true; - } else if (c == CHAR_CTRL_N) { - // CTRL-N is go to next line in history - goto down_arrow_key; - } else if (c == CHAR_CTRL_P) { - // CTRL-P is go to previous line in history - goto up_arrow_key; - } else if (c == CHAR_CTRL_U) { - // CTRL-U is kill from beginning-of-line up to cursor - vstr_cut_out_bytes(rl.line, rl.orig_line_len, rl.cursor_pos - rl.orig_line_len); - // set redraw parameters - redraw_step_back = rl.cursor_pos - rl.orig_line_len; - redraw_from_cursor = true; - #endif - } else if (c == '\r') { - // newline - mp_hal_stdout_tx_str("\r\n"); - readline_push_history(vstr_null_terminated_str(rl.line) + rl.orig_line_len); - return 0; - } else if (c == 27) { - // escape sequence - rl.escape_seq = ESEQ_ESC; - } else if (c == 8 || c == 127) { - // backspace/delete - if (rl.cursor_pos > rl.orig_line_len) { - // work out how many chars to backspace - #if MICROPY_REPL_AUTO_INDENT - int nspace = 0; - for (size_t i = rl.orig_line_len; i < rl.cursor_pos; i++) { - if (rl.line->buf[i] != ' ') { - nspace = 0; - break; - } - nspace += 1; - } - if (nspace < 4) { - nspace = 1; - } else { - nspace = 4; - } - #else - int nspace = 1; - #endif - - // do the backspace - vstr_cut_out_bytes(rl.line, rl.cursor_pos - nspace, nspace); - // set redraw parameters - redraw_step_back = nspace; - redraw_from_cursor = true; - } - #if MICROPY_HELPER_REPL - } else if (c == 9) { - // tab magic - const char *compl_str; - size_t compl_len = mp_repl_autocomplete(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len, &mp_plat_print, &compl_str); - if (compl_len == 0) { - // no match - } else if (compl_len == (size_t)(-1)) { - // many matches - mp_hal_stdout_tx_str(rl.prompt); - mp_hal_stdout_tx_strn(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len); - redraw_from_cursor = true; - } else { - // one match - for (size_t i = 0; i < compl_len; ++i) { - vstr_ins_byte(rl.line, rl.cursor_pos + i, *compl_str++); - } - // set redraw parameters - redraw_from_cursor = true; - redraw_step_forward = compl_len; - } - #endif - } else if (32 <= c && c <= 126) { - // printable character - vstr_ins_char(rl.line, rl.cursor_pos, c); - // set redraw parameters - redraw_from_cursor = true; - redraw_step_forward = 1; - } - } else if (rl.escape_seq == ESEQ_ESC) { - switch (c) { - case '[': - rl.escape_seq = ESEQ_ESC_BRACKET; - break; - case 'O': - rl.escape_seq = ESEQ_ESC_O; - break; - default: - DEBUG_printf("(ESC %d)", c); - rl.escape_seq = ESEQ_NONE; - } - } else if (rl.escape_seq == ESEQ_ESC_BRACKET) { - if ('0' <= c && c <= '9') { - rl.escape_seq = ESEQ_ESC_BRACKET_DIGIT; - rl.escape_seq_buf[0] = c; - } else { - rl.escape_seq = ESEQ_NONE; - if (c == 'A') { -#if MICROPY_REPL_EMACS_KEYS -up_arrow_key: -#endif - // up arrow - if (rl.hist_cur + 1 < (int)READLINE_HIST_SIZE && MP_STATE_PORT(readline_hist)[rl.hist_cur + 1] != NULL) { - // increase hist num - rl.hist_cur += 1; - // set line to history - rl.line->len = rl.orig_line_len; - vstr_add_str(rl.line, MP_STATE_PORT(readline_hist)[rl.hist_cur]); - // set redraw parameters - redraw_step_back = rl.cursor_pos - rl.orig_line_len; - redraw_from_cursor = true; - redraw_step_forward = rl.line->len - rl.orig_line_len; - } - } else if (c == 'B') { -#if MICROPY_REPL_EMACS_KEYS -down_arrow_key: -#endif - // down arrow - if (rl.hist_cur >= 0) { - // decrease hist num - rl.hist_cur -= 1; - // set line to history - vstr_cut_tail_bytes(rl.line, rl.line->len - rl.orig_line_len); - if (rl.hist_cur >= 0) { - vstr_add_str(rl.line, MP_STATE_PORT(readline_hist)[rl.hist_cur]); - } - // set redraw parameters - redraw_step_back = rl.cursor_pos - rl.orig_line_len; - redraw_from_cursor = true; - redraw_step_forward = rl.line->len - rl.orig_line_len; - } - } else if (c == 'C') { -#if MICROPY_REPL_EMACS_KEYS -right_arrow_key: -#endif - // right arrow - if (rl.cursor_pos < rl.line->len) { - redraw_step_forward = 1; - } - } else if (c == 'D') { -#if MICROPY_REPL_EMACS_KEYS -left_arrow_key: -#endif - // left arrow - if (rl.cursor_pos > rl.orig_line_len) { - redraw_step_back = 1; - } - } else if (c == 'H') { - // home - goto home_key; - } else if (c == 'F') { - // end - goto end_key; - } else { - DEBUG_printf("(ESC [ %d)", c); - } - } - } else if (rl.escape_seq == ESEQ_ESC_BRACKET_DIGIT) { - if (c == '~') { - if (rl.escape_seq_buf[0] == '1' || rl.escape_seq_buf[0] == '7') { -home_key: - redraw_step_back = rl.cursor_pos - rl.orig_line_len; - } else if (rl.escape_seq_buf[0] == '4' || rl.escape_seq_buf[0] == '8') { -end_key: - redraw_step_forward = rl.line->len - rl.cursor_pos; - } else if (rl.escape_seq_buf[0] == '3') { - // delete -#if MICROPY_REPL_EMACS_KEYS -delete_key: -#endif - if (rl.cursor_pos < rl.line->len) { - vstr_cut_out_bytes(rl.line, rl.cursor_pos, 1); - redraw_from_cursor = true; - } - } else { - DEBUG_printf("(ESC [ %c %d)", rl.escape_seq_buf[0], c); - } - } else { - DEBUG_printf("(ESC [ %c %d)", rl.escape_seq_buf[0], c); - } - rl.escape_seq = ESEQ_NONE; - } else if (rl.escape_seq == ESEQ_ESC_O) { - switch (c) { - case 'H': - goto home_key; - case 'F': - goto end_key; - default: - DEBUG_printf("(ESC O %d)", c); - rl.escape_seq = ESEQ_NONE; - } - } else { - rl.escape_seq = ESEQ_NONE; - } - - // redraw command prompt, efficiently - if (redraw_step_back > 0) { - mp_hal_move_cursor_back(redraw_step_back); - rl.cursor_pos -= redraw_step_back; - } - if (redraw_from_cursor) { - if (rl.line->len < last_line_len) { - // erase old chars - mp_hal_erase_line_from_cursor(last_line_len - rl.cursor_pos); - } - // draw new chars - mp_hal_stdout_tx_strn(rl.line->buf + rl.cursor_pos, rl.line->len - rl.cursor_pos); - // move cursor forward if needed (already moved forward by length of line, so move it back) - mp_hal_move_cursor_back(rl.line->len - (rl.cursor_pos + redraw_step_forward)); - rl.cursor_pos += redraw_step_forward; - } else if (redraw_step_forward > 0) { - // draw over old chars to move cursor forwards - mp_hal_stdout_tx_strn(rl.line->buf + rl.cursor_pos, redraw_step_forward); - rl.cursor_pos += redraw_step_forward; - } - - return -1; -} - -#if MICROPY_REPL_AUTO_INDENT -STATIC void readline_auto_indent(void) { - vstr_t *line = rl.line; - if (line->len > 1 && line->buf[line->len - 1] == '\n') { - int i; - for (i = line->len - 1; i > 0; i--) { - if (line->buf[i - 1] == '\n') { - break; - } - } - size_t j; - for (j = i; j < line->len; j++) { - if (line->buf[j] != ' ') { - break; - } - } - // i=start of line; j=first non-space - if (i > 0 && j + 1 == line->len) { - // previous line is not first line and is all spaces - for (size_t k = i - 1; k > 0; --k) { - if (line->buf[k - 1] == '\n') { - // don't auto-indent if last 2 lines are all spaces - return; - } else if (line->buf[k - 1] != ' ') { - // 2nd previous line is not all spaces - break; - } - } - } - int n = (j - i) / 4; - if (line->buf[line->len - 2] == ':') { - n += 1; - } - while (n-- > 0) { - vstr_add_strn(line, " ", 4); - mp_hal_stdout_tx_strn(" ", 4); - rl.cursor_pos += 4; - } - } -} -#endif - -void readline_note_newline(const char *prompt) { - rl.orig_line_len = rl.line->len; - rl.cursor_pos = rl.orig_line_len; - rl.prompt = prompt; - mp_hal_stdout_tx_str(prompt); - #if MICROPY_REPL_AUTO_INDENT - readline_auto_indent(); - #endif -} - -void readline_init(vstr_t *line, const char *prompt) { - rl.line = line; - rl.orig_line_len = line->len; - rl.escape_seq = ESEQ_NONE; - rl.escape_seq_buf[0] = 0; - rl.hist_cur = -1; - rl.cursor_pos = rl.orig_line_len; - rl.prompt = prompt; - mp_hal_stdout_tx_str(prompt); - #if MICROPY_REPL_AUTO_INDENT - readline_auto_indent(); - #endif -} - -int readline(vstr_t *line, const char *prompt) { - readline_init(line, prompt); - for (;;) { - int c = mp_hal_stdin_rx_chr(); - int r = readline_process_char(c); - if (r >= 0) { - return r; - } - } -} - -void readline_push_history(const char *line) { - if (line[0] != '\0' - && (MP_STATE_PORT(readline_hist)[0] == NULL - || strcmp(MP_STATE_PORT(readline_hist)[0], line) != 0)) { - // a line which is not empty and different from the last one - // so update the history - char *most_recent_hist = str_dup_maybe(line); - if (most_recent_hist != NULL) { - for (int i = READLINE_HIST_SIZE - 1; i > 0; i--) { - MP_STATE_PORT(readline_hist)[i] = MP_STATE_PORT(readline_hist)[i - 1]; - } - MP_STATE_PORT(readline_hist)[0] = most_recent_hist; - } - } -} diff --git a/user/mpy/lib/mp-readline/readline.h b/user/mpy/lib/mp-readline/readline.h deleted file mode 100644 index 00aa962..0000000 --- a/user/mpy/lib/mp-readline/readline.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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_LIB_MP_READLINE_READLINE_H -#define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H - -#define CHAR_CTRL_A (1) -#define CHAR_CTRL_B (2) -#define CHAR_CTRL_C (3) -#define CHAR_CTRL_D (4) -#define CHAR_CTRL_E (5) -#define CHAR_CTRL_F (6) -#define CHAR_CTRL_K (11) -#define CHAR_CTRL_N (14) -#define CHAR_CTRL_P (16) -#define CHAR_CTRL_U (21) - -void readline_init0(void); -int readline(vstr_t *line, const char *prompt); -void readline_push_history(const char *line); - -void readline_init(vstr_t *line, const char *prompt); -void readline_note_newline(const char *prompt); -int readline_process_char(int c); - -#endif // MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H diff --git a/user/mpy/lib/netutils/netutils.c b/user/mpy/lib/netutils/netutils.c deleted file mode 100644 index 15e7039..0000000 --- a/user/mpy/lib/netutils/netutils.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * 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. - */ - -#include -#include -#include - -#include "py/obj.h" -#include "py/nlr.h" -#include "py/runtime.h" -#include "lib/netutils/netutils.h" - -// Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. -mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian) { - char ip_str[16]; - mp_uint_t ip_len; - if (endian == NETUTILS_LITTLE) { - ip_len = snprintf(ip_str, 16, "%u.%u.%u.%u", ip[3], ip[2], ip[1], ip[0]); - } else { - ip_len = snprintf(ip_str, 16, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); - } - return mp_obj_new_str(ip_str, ip_len, false); -} - -// Takes an array with a raw IP address, and a port, and returns a net-address -// tuple such as ('192.168.0.1', 8080). -mp_obj_t netutils_format_inet_addr(uint8_t *ip, mp_uint_t port, netutils_endian_t endian) { - mp_obj_t tuple[2] = { - tuple[0] = netutils_format_ipv4_addr(ip, endian), - tuple[1] = mp_obj_new_int(port), - }; - return mp_obj_new_tuple(2, tuple); -} - -void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian) { - size_t addr_len; - const char *addr_str = mp_obj_str_get_data(addr_in, &addr_len); - if (addr_len == 0) { - // special case of no address given - memset(out_ip, 0, NETUTILS_IPV4ADDR_BUFSIZE); - return; - } - const char *s = addr_str; - const char *s_top = addr_str + addr_len; - for (mp_uint_t i = 3 ; ; i--) { - mp_uint_t val = 0; - for (; s < s_top && *s != '.'; s++) { - val = val * 10 + *s - '0'; - } - if (endian == NETUTILS_LITTLE) { - out_ip[i] = val; - } else { - out_ip[NETUTILS_IPV4ADDR_BUFSIZE - 1 - i] = val; - } - if (i == 0 && s == s_top) { - return; - } else if (i > 0 && s < s_top && *s == '.') { - s++; - } else { - mp_raise_ValueError("invalid arguments"); - } - } -} - -// Takes an address of the form ('192.168.0.1', 8080), returns the port and -// puts IP in out_ip (which must take at least IPADDR_BUF_SIZE bytes). -mp_uint_t netutils_parse_inet_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian) { - mp_obj_t *addr_items; - mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); - netutils_parse_ipv4_addr(addr_items[0], out_ip, endian); - return mp_obj_get_int(addr_items[1]); -} diff --git a/user/mpy/lib/netutils/netutils.h b/user/mpy/lib/netutils/netutils.h deleted file mode 100644 index 4befc90..0000000 --- a/user/mpy/lib/netutils/netutils.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * 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_LIB_NETUTILS_NETUTILS_H -#define MICROPY_INCLUDED_LIB_NETUTILS_NETUTILS_H - -#define NETUTILS_IPV4ADDR_BUFSIZE 4 - -typedef enum _netutils_endian_t { - NETUTILS_LITTLE, - NETUTILS_BIG, -} netutils_endian_t; - -// Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. -mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian); - -// Takes an array with a raw IP address, and a port, and returns a net-address -// tuple such as ('192.168.0.1', 8080). -mp_obj_t netutils_format_inet_addr(uint8_t *ip, mp_uint_t port, netutils_endian_t endian); - -void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian); - -// Takes an address of the form ('192.168.0.1', 8080), returns the port and -// puts IP in out_ip (which must take at least IPADDR_BUF_SIZE bytes). -mp_uint_t netutils_parse_inet_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian_t endian); - -#endif // MICROPY_INCLUDED_LIB_NETUTILS_NETUTILS_H diff --git a/user/mpy/lib/oofatfs/diskio.h b/user/mpy/lib/oofatfs/diskio.h deleted file mode 100644 index 8deb68e..0000000 --- a/user/mpy/lib/oofatfs/diskio.h +++ /dev/null @@ -1,83 +0,0 @@ -/* This file is part of ooFatFs, a customised version of FatFs - * See https://github.com/micropython/oofatfs for details - */ - -/*-----------------------------------------------------------------------/ -/ Low level disk interface modlue include file (C)ChaN, 2014 / -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DRESULT disk_read (void *drv, BYTE* buff, DWORD sector, UINT count); -DRESULT disk_write (void *drv, const BYTE* buff, DWORD sector, UINT count); -DRESULT disk_ioctl (void *drv, BYTE cmd, void* buff); - - -/* Disk Status Bits (DSTATUS) */ - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ -#define IOCTL_INIT 5 -#define IOCTL_STATUS 6 - -/* Generic command (Not used by FatFs) */ -#define CTRL_POWER 5 /* Get/Set power status */ -#define CTRL_LOCK 6 /* Lock/Unlock media removal */ -#define CTRL_EJECT 7 /* Eject media */ -#define CTRL_FORMAT 8 /* Create physical format on the media */ - -/* MMC/SDC specific ioctl command */ -#define MMC_GET_TYPE 10 /* Get card type */ -#define MMC_GET_CSD 11 /* Get CSD */ -#define MMC_GET_CID 12 /* Get CID */ -#define MMC_GET_OCR 13 /* Get OCR */ -#define MMC_GET_SDSTAT 14 /* Get SD status */ -#define ISDIO_READ 55 /* Read data form SD iSDIO register */ -#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ -#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ - -/* ATA/CF specific ioctl command */ -#define ATA_GET_REV 20 /* Get F/W revision */ -#define ATA_GET_MODEL 21 /* Get model name */ -#define ATA_GET_SN 22 /* Get serial number */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/user/mpy/lib/oofatfs/ff.c b/user/mpy/lib/oofatfs/ff.c deleted file mode 100644 index b098475..0000000 --- a/user/mpy/lib/oofatfs/ff.c +++ /dev/null @@ -1,5594 +0,0 @@ -/* This file is part of ooFatFs, a customised version of FatFs - * See https://github.com/micropython/oofatfs for details - */ - -/*----------------------------------------------------------------------------/ -/ FatFs - Generic FAT file system module R0.12b / -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2016, ChaN, all right reserved. -/ -/ FatFs module is an open source software. Redistribution and use of FatFs in -/ source and binary forms, with or without modification, are permitted provided -/ that the following condition is met: - -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of device I/O functions */ - -// DIR has been renamed FF_DIR in the public API so it doesn't clash with POSIX -#define DIR FF_DIR - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 68020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File lock controls */ -#if _FS_LOCK != 0 -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - DWORD ofs; /* Object ID 3, directory offset */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS upper conversion tables */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 771 /* KBL */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Latin 1 */ -#define _DF1S 0 -#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ - 0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \ - 0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0xAC, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ - 0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \ - 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0x49,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 860 /* Portuguese */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ - 0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 861 /* Icelandic */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 863 /* Canadian-French */ -#define _DF1S 0 -#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ - 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ - 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 864 /* Arabic */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 865 /* Nordic */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 869 /* Greek 2 */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ - 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ - 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ - 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN != 0 -#error Cannot enable LFN without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S != 0 /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* File attribute bits (internal use) */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* File access control and file status flags (internal use) */ -#define FA_SEEKEND 0x20 /* Seek to end of the file on file open */ -#define FA_MODIFIED 0x40 /* File has been modified */ -#define FA_DIRTY 0x80 /* FIL.buf[] needs to be written-back */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ -#define NS_NOLFN 0x40 /* Do not find LFN */ -#define NS_NONAME 0x80 /* Not followed */ - - -/* Limits and boundaries (differ from specs but correct for real DOS/Windows) */ -#define MAX_FAT12 0xFF5 /* Maximum number of FAT12 clusters */ -#define MAX_FAT16 0xFFF5 /* Maximum number of FAT16 clusters */ -#define MAX_FAT32 0xFFFFFF5 /* Maximum number of FAT32 clusters */ -#define MAX_EXFAT 0x7FFFFFFD /* Maximum number of exFAT clusters (limited by implementation) */ -#define MAX_DIR 0x200000 /* Maximum size of FAT directory */ -#define MAX_DIR_EX 0x10000000 /* Maximum size of exFAT directory */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure members because the structure is not binary compatible between -/ different platforms */ - -#define BS_JmpBoot 0 /* x86 jump instruction (3-byte) */ -#define BS_OEMName 3 /* OEM name (8-byte) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (WORD) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (BYTE) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (WORD) */ -#define BPB_NumFATs 16 /* Number of FATs (BYTE) */ -#define BPB_RootEntCnt 17 /* Size of root directory area for FAT12/16 [entry] (WORD) */ -#define BPB_TotSec16 19 /* Volume size (16-bit) [sector] (WORD) */ -#define BPB_Media 21 /* Media descriptor byte (BYTE) */ -#define BPB_FATSz16 22 /* FAT size (16-bit) [sector] (WORD) */ -#define BPB_SecPerTrk 24 /* Track size for int13h [sector] (WORD) */ -#define BPB_NumHeads 26 /* Number of heads for int13h (WORD) */ -#define BPB_HiddSec 28 /* Volume offset from top of the drive (DWORD) */ -#define BPB_TotSec32 32 /* Volume size (32-bit) [sector] (DWORD) */ -#define BS_DrvNum 36 /* Physical drive number for int13h (BYTE) */ -#define BS_NTres 37 /* Error flag (BYTE) */ -#define BS_BootSig 38 /* Extended boot signature (BYTE) */ -#define BS_VolID 39 /* Volume serial number (DWORD) */ -#define BS_VolLab 43 /* Volume label string (8-byte) */ -#define BS_FilSysType 54 /* File system type string (8-byte) */ -#define BS_BootCode 62 /* Boot code (448-byte) */ -#define BS_55AA 510 /* Signature word (WORD) */ - -#define BPB_FATSz32 36 /* FAT32: FAT size [sector] (DWORD) */ -#define BPB_ExtFlags32 40 /* FAT32: Extended flags (WORD) */ -#define BPB_FSVer32 42 /* FAT32: File system version (WORD) */ -#define BPB_RootClus32 44 /* FAT32: Root directory cluster (DWORD) */ -#define BPB_FSInfo32 48 /* FAT32: Offset of FSINFO sector (WORD) */ -#define BPB_BkBootSec32 50 /* FAT32: Offset of backup boot sector (WORD) */ -#define BS_DrvNum32 64 /* FAT32: Physical drive number for int13h (BYTE) */ -#define BS_NTres32 65 /* FAT32: Error flag (BYTE) */ -#define BS_BootSig32 66 /* FAT32: Extended boot signature (BYTE) */ -#define BS_VolID32 67 /* FAT32: Volume serial number (DWORD) */ -#define BS_VolLab32 71 /* FAT32: Volume label string (8-byte) */ -#define BS_FilSysType32 82 /* FAT32: File system type string (8-byte) */ -#define BS_BootCode32 90 /* FAT32: Boot code (420-byte) */ - -#define BPB_ZeroedEx 11 /* exFAT: MBZ field (53-byte) */ -#define BPB_VolOfsEx 64 /* exFAT: Volume offset from top of the drive [sector] (QWORD) */ -#define BPB_TotSecEx 72 /* exFAT: Volume size [sector] (QWORD) */ -#define BPB_FatOfsEx 80 /* exFAT: FAT offset from top of the volume [sector] (DWORD) */ -#define BPB_FatSzEx 84 /* exFAT: FAT size [sector] (DWORD) */ -#define BPB_DataOfsEx 88 /* exFAT: Data offset from top of the volume [sector] (DWORD) */ -#define BPB_NumClusEx 92 /* exFAT: Number of clusters (DWORD) */ -#define BPB_RootClusEx 96 /* exFAT: Root directory cluster (DWORD) */ -#define BPB_VolIDEx 100 /* exFAT: Volume serial number (DWORD) */ -#define BPB_FSVerEx 104 /* exFAT: File system version (WORD) */ -#define BPB_VolFlagEx 106 /* exFAT: Volume flags (BYTE) */ -#define BPB_ActFatEx 107 /* exFAT: Active FAT flags (BYTE) */ -#define BPB_BytsPerSecEx 108 /* exFAT: Log2 of sector size in byte (BYTE) */ -#define BPB_SecPerClusEx 109 /* exFAT: Log2 of cluster size in sector (BYTE) */ -#define BPB_NumFATsEx 110 /* exFAT: Number of FATs (BYTE) */ -#define BPB_DrvNumEx 111 /* exFAT: Physical drive number for int13h (BYTE) */ -#define BPB_PercInUseEx 112 /* exFAT: Percent in use (BYTE) */ -#define BPB_RsvdEx 113 /* exFAT: Reserved (7-byte) */ -#define BS_BootCodeEx 120 /* exFAT: Boot code (390-byte) */ - -#define FSI_LeadSig 0 /* FAT32 FSI: Leading signature (DWORD) */ -#define FSI_StrucSig 484 /* FAT32 FSI: Structure signature (DWORD) */ -#define FSI_Free_Count 488 /* FAT32 FSI: Number of free clusters (DWORD) */ -#define FSI_Nxt_Free 492 /* FAT32 FSI: Last allocated cluster (DWORD) */ - -#define MBR_Table 446 /* MBR: Offset of partition table in the MBR */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define PTE_Boot 0 /* MBR PTE: Boot indicator */ -#define PTE_StHead 1 /* MBR PTE: Start head */ -#define PTE_StSec 2 /* MBR PTE: Start sector */ -#define PTE_StCyl 3 /* MBR PTE: Start cylinder */ -#define PTE_System 4 /* MBR PTE: System ID */ -#define PTE_EdHead 5 /* MBR PTE: End head */ -#define PTE_EdSec 6 /* MBR PTE: End sector */ -#define PTE_EdCyl 7 /* MBR PTE: End cylinder */ -#define PTE_StLba 8 /* MBR PTE: Start in LBA */ -#define PTE_SizLba 12 /* MBR PTE: Size in LBA */ - -#define DIR_Name 0 /* Short file name (11-byte) */ -#define DIR_Attr 11 /* Attribute (BYTE) */ -#define DIR_NTres 12 /* Lower case flag (BYTE) */ -#define DIR_CrtTime10 13 /* Created time sub-second (BYTE) */ -#define DIR_CrtTime 14 /* Created time (DWORD) */ -#define DIR_LstAccDate 18 /* Last accessed date (WORD) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (WORD) */ -#define DIR_ModTime 22 /* Modified time (DWORD) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (WORD) */ -#define DIR_FileSize 28 /* File size (DWORD) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (BYTE) */ -#define LDIR_Attr 11 /* LFN attribute (BYTE) */ -#define LDIR_Type 12 /* LFN type (BYTE) */ -#define LDIR_Chksum 13 /* Checksum of the SFN entry (BYTE) */ -#define LDIR_FstClusLO 26 /* Must be zero (WORD) */ -#define XDIR_Type 0 /* Type of exFAT directory entry (BYTE) */ -#define XDIR_NumLabel 1 /* Number of volume label characters (BYTE) */ -#define XDIR_Label 2 /* Volume label (11-WORD) */ -#define XDIR_CaseSum 4 /* Sum of case conversion table (DWORD) */ -#define XDIR_NumSec 1 /* Number of secondary entries (BYTE) */ -#define XDIR_SetSum 2 /* Sum of the set of directory entries (WORD) */ -#define XDIR_Attr 4 /* File attribute (WORD) */ -#define XDIR_CrtTime 8 /* Created time (DWORD) */ -#define XDIR_ModTime 12 /* Modified time (DWORD) */ -#define XDIR_AccTime 16 /* Last accessed time (DWORD) */ -#define XDIR_CrtTime10 20 /* Created time subsecond (BYTE) */ -#define XDIR_ModTime10 21 /* Modified time subsecond (BYTE) */ -#define XDIR_CrtTZ 22 /* Created timezone (BYTE) */ -#define XDIR_ModTZ 23 /* Modified timezone (BYTE) */ -#define XDIR_AccTZ 24 /* Last accessed timezone (BYTE) */ -#define XDIR_GenFlags 33 /* Gneral secondary flags (WORD) */ -#define XDIR_NumName 35 /* Number of file name characters (BYTE) */ -#define XDIR_NameHash 36 /* Hash of file name (WORD) */ -#define XDIR_ValidFileSize 40 /* Valid file size (QWORD) */ -#define XDIR_FstClus 52 /* First cluster of the file data (DWORD) */ -#define XDIR_FileSize 56 /* File/Directory size (QWORD) */ - -#define SZDIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark set to DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - - -/*-------------------------------------------------------------------------- - - Module Private Work Area - ----------------------------------------------------------------------------*/ - -/* Remark: Variables here without initial value shall be guaranteed zero/null -/ at start-up. If not, either the linker or start-up routine being used is -/ not compliance with C standard. */ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static WORD Fsid; /* File system mount ID */ - -#if _FS_LOCK != 0 -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non-LFN configuration */ -#define DEF_NAMBUF -#define INIT_NAMBUF(fs) -#define FREE_NAMBUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif - -#if _USE_LFN == 1 /* LFN enabled with static working buffer */ -#if _FS_EXFAT -static BYTE DirBuf[SZDIRE*19]; /* Directory entry block scratchpad buffer (19 entries in size) */ -#endif -static WCHAR LfnBuf[_MAX_LFN+1]; /* LFN enabled with static working buffer */ -#define DEF_NAMBUF -#define INIT_NAMBUF(fs) -#define FREE_NAMBUF() - -#elif _USE_LFN == 2 /* LFN enabled with dynamic working buffer on the stack */ -#if _FS_EXFAT -#define DEF_NAMBUF WCHAR lbuf[_MAX_LFN+1]; BYTE dbuf[SZDIRE*19]; -#define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; (fs)->dirbuf = dbuf; } -#define FREE_NAMBUF() -#else -#define DEF_NAMBUF WCHAR lbuf[_MAX_LFN+1]; -#define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; } -#define FREE_NAMBUF() -#endif - -#elif _USE_LFN == 3 /* LFN enabled with dynamic working buffer on the heap */ -#if _FS_EXFAT -#define DEF_NAMBUF WCHAR *lfn; -#define INIT_NAMBUF(fs) { lfn = ff_memalloc((_MAX_LFN+1)*2 + SZDIRE*19); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; (fs)->dirbuf = (BYTE*)(lfn+_MAX_LFN+1); } -#define FREE_NAMBUF() ff_memfree(lfn) -#else -#define DEF_NAMBUF WCHAR *lfn; -#define INIT_NAMBUF(fs) { lfn = ff_memalloc((_MAX_LFN+1)*2); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; } -#define FREE_NAMBUF() ff_memfree(lfn) -#endif - -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for SBCS extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Load/Store multi-byte word in the FAT structure */ -/*-----------------------------------------------------------------------*/ - -static -WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ -{ - WORD rv; - - rv = ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} - -static -DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ -{ - DWORD rv; - - rv = ptr[3]; - rv = rv << 8 | ptr[2]; - rv = rv << 8 | ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} - -#if _FS_EXFAT -static -QWORD ld_qword (const BYTE* ptr) /* Load an 8-byte little-endian word */ -{ - QWORD rv; - - rv = ptr[7]; - rv = rv << 8 | ptr[6]; - rv = rv << 8 | ptr[5]; - rv = rv << 8 | ptr[4]; - rv = rv << 8 | ptr[3]; - rv = rv << 8 | ptr[2]; - rv = rv << 8 | ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} -#endif - -#if !_FS_READONLY -static -void st_word (BYTE* ptr, WORD val) /* Store a 2-byte word in little-endian */ -{ - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; -} - -static -void st_dword (BYTE* ptr, DWORD val) /* Store a 4-byte word in little-endian */ -{ - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; -} - -#if _FS_EXFAT -static -void st_qword (BYTE* ptr, QWORD val) /* Store an 8-byte word in little-endian */ -{ - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; val >>= 8; - *ptr++ = (BYTE)val; -} -#endif -#endif /* !_FS_READONLY */ - - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -// These were originally provided by the FatFs library but we use externally -// provided versions from C stdlib to (hopefully) reduce code size and use -// more efficient versions. -#define mem_cpy memcpy -#define mem_set memset -#define mem_cmp memcmp - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { /* NZ:contained, ZR:not contained */ - while (*str && *str != chr) str++; - return *str; -} - - - - -#if _FS_REENTRANT -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && res != FR_NOT_ENABLED && res != FR_INVALID_DRIVE && res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} - -#endif - - - -#if _FS_LOCK != 0 -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->obj.fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->obj.sclust && - Files[i].ofs == dp->dptr) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) { /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - } - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->obj.fs && - Files[i].clu == dp->obj.sclust && - Files[i].ofs == dp->dptr) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->obj.fs; - Files[i].clu = dp->obj.sclust; - Files[i].ofs = dp->dptr; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n > 0) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (n == 0) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} - -#endif /* _FS_LOCK != 0 */ - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( /* Returns FR_OK or FR_DISK_ERROR */ - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( /* Returns FR_OK or FR_DISK_ERROR */ - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT sync_fs ( /* FR_OK:succeeded, !=0:error */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSInfo sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSInfo structure */ - mem_set(fs->win, 0, SS(fs)); - st_word(fs->win + BS_55AA, 0xAA55); - st_dword(fs->win + FSI_LeadSig, 0x41615252); - st_dword(fs->win + FSI_StrucSig, 0x61417272); - st_dword(fs->win + FSI_Free_Count, fs->free_clst); - st_dword(fs->win + FSI_Nxt_Free, fs->last_clst); - /* Write it into the FSInfo sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) res = FR_DISK_ERR; - } - - return res; -} - -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ - -static -DWORD clust2sect ( /* !=0:Sector number, 0:Failed (invalid cluster#) */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -static -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x7FFFFFFF:Cluster status */ - _FDID* obj, /* Corresponding object */ - DWORD clst /* Cluster number to get the value */ -) -{ - UINT wc, bc; - DWORD val; - FATFS *fs = obj->fs; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check if in valid range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = (clst & 1) ? (wc >> 4) : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - val = ld_word(fs->win + clst * 2 % SS(fs)); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - val = ld_dword(fs->win + clst * 4 % SS(fs)) & 0x0FFFFFFF; - break; -#if _FS_EXFAT - case FS_EXFAT : - if (obj->objsize) { - DWORD cofs = clst - obj->sclust; /* Offset from start cluster */ - DWORD clen = (DWORD)((obj->objsize - 1) / SS(fs)) / fs->csize; /* Number of clusters - 1 */ - - if (obj->stat == 2) { /* Is there no valid chain on the FAT? */ - if (cofs <= clen) { - val = (cofs == clen) ? 0x7FFFFFFF : clst + 1; /* Generate the value */ - break; - } - } - if (obj->stat == 3 && cofs < obj->n_cont) { /* Is it in the contiguous part? */ - val = clst + 1; /* Generate the value */ - break; - } - if (obj->stat != 2) { /* Get value from FAT if FAT chain is valid */ - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - val = ld_dword(fs->win + clst * 4 % SS(fs)) & 0x7FFFFFFF; - break; - } - } - /* go next */ -#endif - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT put_fat ( /* FR_OK(0):succeeded, !=0:error */ - FATFS* fs, /* Corresponding file system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res = FR_INT_ERR; - - - if (clst >= 2 && clst < fs->n_fatent) { /* Check if in valid range */ - switch (fs->fs_type) { - case FS_FAT12 : /* Bitfield items */ - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = fs->win + bc++ % SS(fs); - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = fs->win + bc % SS(fs); - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : /* WORD aligned items */ - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - st_word(fs->win + clst * 2 % SS(fs), (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : /* DWORD aligned items */ -#if _FS_EXFAT - case FS_EXFAT : -#endif - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { - val = (val & 0x0FFFFFFF) | (ld_dword(fs->win + clst * 4 % SS(fs)) & 0xF0000000); - } - st_dword(fs->win + clst * 4 % SS(fs), val); - fs->wflag = 1; - break; - } - } - return res; -} - -#endif /* !_FS_READONLY */ - - - - -#if _FS_EXFAT && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* exFAT: Accessing FAT and Allocation Bitmap */ -/*-----------------------------------------------------------------------*/ - -/*---------------------------------------------*/ -/* exFAT: Find a contiguous free cluster block */ -/*---------------------------------------------*/ - -static -DWORD find_bitmap ( /* 0:No free cluster, 2..:Free cluster found, 0xFFFFFFFF:Disk error */ - FATFS* fs, /* File system object */ - DWORD clst, /* Cluster number to scan from */ - DWORD ncl /* Number of contiguous clusters to find (1..) */ -) -{ - BYTE bm, bv; - UINT i; - DWORD val, scl, ctr; - - - clst -= 2; /* The first bit in the bitmap corresponds to cluster #2 */ - if (clst >= fs->n_fatent - 2) clst = 0; - scl = val = clst; ctr = 0; - for (;;) { - if (move_window(fs, fs->database + val / 8 / SS(fs)) != FR_OK) return 0xFFFFFFFF; /* (assuming bitmap is located top of the cluster heap) */ - i = val / 8 % SS(fs); bm = 1 << (val % 8); - do { - do { - bv = fs->win[i] & bm; bm <<= 1; /* Get bit value */ - if (++val >= fs->n_fatent - 2) { /* Next cluster (with wrap-around) */ - val = 0; bm = 0; i = 4096; - } - if (!bv) { /* Is it a free cluster? */ - if (++ctr == ncl) return scl + 2; /* Check run length */ - } else { - scl = val; ctr = 0; /* Encountered a live cluster, restart to scan */ - } - if (val == clst) return 0; /* All cluster scanned? */ - } while (bm); - bm = 1; - } while (++i < SS(fs)); - } -} - - -/*------------------------------------*/ -/* exFAT: Set/Clear a block of bitmap */ -/*------------------------------------*/ - -static -FRESULT change_bitmap ( - FATFS* fs, /* File system object */ - DWORD clst, /* Cluster number to change from */ - DWORD ncl, /* Number of clusters to be changed */ - int bv /* bit value to be set (0 or 1) */ -) -{ - BYTE bm; - UINT i; - DWORD sect; - - - clst -= 2; /* The first bit corresponds to cluster #2 */ - sect = fs->database + clst / 8 / SS(fs); /* Sector address (assuming bitmap is located top of the cluster heap) */ - i = clst / 8 % SS(fs); /* Byte offset in the sector */ - bm = 1 << (clst % 8); /* Bit mask in the byte */ - for (;;) { - if (move_window(fs, sect++) != FR_OK) return FR_DISK_ERR; - do { - do { - if (bv == (int)((fs->win[i] & bm) != 0)) return FR_INT_ERR; /* Is the bit expected value? */ - fs->win[i] ^= bm; /* Flip the bit */ - fs->wflag = 1; - if (--ncl == 0) return FR_OK; /* All bits processed? */ - } while (bm <<= 1); /* Next bit */ - bm = 1; - } while (++i < SS(fs)); /* Next byte */ - i = 0; - } -} - - -/*---------------------------------------------*/ -/* Complement contiguous part of the FAT chain */ -/*---------------------------------------------*/ - -static -FRESULT fill_fat_chain ( - _FDID* obj /* Pointer to the corresponding object */ -) -{ - FRESULT res; - DWORD cl, n; - - if (obj->stat == 3) { /* Has the object been changed 'fragmented'? */ - for (cl = obj->sclust, n = obj->n_cont; n; cl++, n--) { /* Create cluster chain on the FAT */ - res = put_fat(obj->fs, cl, cl + 1); - if (res != FR_OK) return res; - } - obj->stat = 0; /* Change status 'FAT chain is valid' */ - } - return FR_OK; -} - -#endif /* _FS_EXFAT && !_FS_READONLY */ - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -static -FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */ - _FDID* obj, /* Corresponding object */ - DWORD clst, /* Cluster to remove a chain from */ - DWORD pclst /* Previous cluster of clst (0:an entire chain) */ -) -{ - FRESULT res = FR_OK; - DWORD nxt; - FATFS *fs = obj->fs; -#if _FS_EXFAT || _USE_TRIM - DWORD scl = clst, ecl = clst; -#endif -#if _USE_TRIM - DWORD rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) return FR_INT_ERR; /* Check if in valid range */ - - /* Mark the previous cluster 'EOC' on the FAT if it exists */ - if (pclst && (!_FS_EXFAT || fs->fs_type != FS_EXFAT || obj->stat != 2)) { - res = put_fat(fs, pclst, 0xFFFFFFFF); - if (res != FR_OK) return res; - } - - /* Remove the chain */ - do { - nxt = get_fat(obj, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) return FR_INT_ERR; /* Internal error? */ - if (nxt == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error? */ - if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { - res = put_fat(fs, clst, 0); /* Mark the cluster 'free' on the FAT */ - if (res != FR_OK) return res; - } - if (fs->free_clst < fs->n_fatent - 2) { /* Update FSINFO */ - fs->free_clst++; - fs->fsi_flag |= 1; - } -#if _FS_EXFAT || _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous cluster block */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - res = change_bitmap(fs, scl, ecl - scl + 1, 0); /* Mark the cluster block 'free' on the bitmap */ - if (res != FR_OK) return res; - } -#endif -#if _USE_TRIM - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Inform device the block can be erased */ -#endif - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } while (clst < fs->n_fatent); /* Repeat while not the last link */ - -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - if (pclst == 0) { /* Does object have no chain? */ - obj->stat = 0; /* Change the object status 'initial' */ - } else { - if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Did the chain got contiguous? */ - obj->stat = 2; /* Change the object status 'contiguous' */ - } - } - } -#endif - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch a chain or Create a new chain */ -/*-----------------------------------------------------------------------*/ -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - _FDID* obj, /* Corresponding object */ - DWORD clst /* Cluster# to stretch, 0:Create a new chain */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - FATFS *fs = obj->fs; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clst; /* Get suggested cluster to start from */ - if (scl == 0 || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch current chain */ - cs = get_fat(obj, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - ncl = find_bitmap(fs, scl, 1); /* Find a free cluster */ - if (ncl == 0 || ncl == 0xFFFFFFFF) return ncl; /* No free cluster or hard error? */ - res = change_bitmap(fs, ncl, 1, 1); /* Mark the cluster 'in use' */ - if (res == FR_INT_ERR) return 1; - if (res == FR_DISK_ERR) return 0xFFFFFFFF; - if (clst == 0) { /* Is it a new chain? */ - obj->stat = 2; /* Set status 'contiguous chain' */ - } else { /* This is a stretched chain */ - if (obj->stat == 2 && ncl != scl + 1) { /* Is the chain got fragmented? */ - obj->n_cont = scl - obj->sclust; /* Set size of the contiguous part */ - obj->stat = 3; /* Change status 'just fragmented' */ - } - } - } else -#endif - { /* On the FAT12/16/32 volume */ - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap-around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(obj, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 1 || cs == 0xFFFFFFFF) return cs; /* An error occurred */ - if (ncl == scl) return 0; /* No free cluster */ - } - } - - if (_FS_EXFAT && fs->fs_type == FS_EXFAT && obj->stat == 2) { /* Is it a contiguous chain? */ - res = FR_OK; /* FAT does not need to be written */ - } else { - res = put_fat(fs, ncl, 0xFFFFFFFF); /* Mark the new cluster 'EOC' */ - if (res == FR_OK && clst) { - res = put_fat(fs, clst, ncl); /* Link it from the previous one if needed */ - } - } - - if (res == FR_OK) { /* Update FSINFO if function succeeded. */ - fs->last_clst = ncl; - if (fs->free_clst < fs->n_fatent - 2) fs->free_clst--; - fs->fsi_flag |= 1; - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; /* Failed. Create error status */ - } - - return ncl; /* Return new cluster number or error status */ -} - -#endif /* !_FS_READONLY */ - - - - -#if _USE_FASTSEEK -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - FSIZE_t ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - FATFS *fs = fp->obj.fs; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = (DWORD)(ofs / SS(fs) / fs->csize); /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (ncl == 0) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} - -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( /* FR_OK(0):succeeded, !=0:error */ - DIR* dp, /* Pointer to directory object */ - DWORD ofs /* Offset of directory table */ -) -{ - DWORD csz, clst; - FATFS *fs = dp->obj.fs; - - - if (ofs >= (DWORD)((_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR) || ofs % SZDIRE) { /* Check range of offset and alignment */ - return FR_INT_ERR; - } - dp->dptr = ofs; /* Set current offset */ - clst = dp->obj.sclust; /* Table start cluster (0:root) */ - if (clst == 0 && fs->fs_type >= FS_FAT32) { /* Replace cluster# 0 with root cluster# */ - clst = fs->dirbase; - if (_FS_EXFAT) dp->obj.stat = 0; /* exFAT: Root dir has an FAT chain */ - } - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (ofs / SZDIRE >= fs->n_rootdir) return FR_INT_ERR; /* Is index out of range? */ - dp->sect = fs->dirbase; - - } else { /* Dynamic table (sub-directory or root-directory in FAT32+) */ - csz = (DWORD)fs->csize * SS(fs); /* Bytes per cluster */ - while (ofs >= csz) { /* Follow cluster chain */ - clst = get_fat(&dp->obj, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= fs->n_fatent) return FR_INT_ERR; /* Reached to end of table or internal error */ - ofs -= csz; - } - dp->sect = clust2sect(fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!dp->sect) return FR_INT_ERR; - dp->sect += ofs / SS(fs); /* Sector# of the directory entry */ - dp->dir = fs->win + (ofs % SS(fs)); /* Pointer to the entry in the win[] */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD ofs, clst; - FATFS *fs = dp->obj.fs; -#if !_FS_READONLY - UINT n; -#endif - - ofs = dp->dptr + SZDIRE; /* Next entry */ - if (!dp->sect || ofs >= (DWORD)((_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) return FR_NO_FILE; /* Report EOT when offset has reached max value */ - - if (ofs % SS(fs) == 0) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (ofs / SZDIRE >= fs->n_rootdir) { /* Report EOT if it reached end of static table */ - dp->sect = 0; return FR_NO_FILE; - } - } - else { /* Dynamic table */ - if ((ofs / SS(fs) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; /* Internal error */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst >= fs->n_fatent) { /* Reached end of dynamic table */ -#if !_FS_READONLY - if (!stretch) { /* If no stretch, report EOT */ - dp->sect = 0; return FR_NO_FILE; - } - clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; /* Internal error */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - /* Clean-up the stretched table */ - if (_FS_EXFAT) dp->obj.stat |= 4; /* The directory needs to be updated */ - if (sync_window(fs) != FR_OK) return FR_DISK_ERR; /* Flush disk access window */ - mem_set(fs->win, 0, SS(fs)); /* Clear window buffer */ - for (n = 0, fs->winsect = clust2sect(fs, clst); n < fs->csize; n++, fs->winsect++) { /* Fill the new cluster with 0 */ - fs->wflag = 1; - if (sync_window(fs) != FR_OK) return FR_DISK_ERR; - } - fs->winsect -= n; /* Restore window offset */ -#else - if (!stretch) dp->sect = 0; /* If no stretch, report EOT (this is to suppress warning) */ - dp->sect = 0; return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(fs, clst); - } - } - } - dp->dptr = ofs; /* Current entry */ - dp->dir = fs->win + ofs % SS(fs); /* Pointer to the entry in the win[] */ - - return FR_OK; -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve a block of directory entries */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_alloc ( /* FR_OK(0):succeeded, !=0:error */ - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate */ -) -{ - FRESULT res; - UINT n; - FATFS *fs = dp->obj.fs; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(fs, dp->sect); - if (res != FR_OK) break; -#if _FS_EXFAT - if ((fs->fs_type == FS_EXFAT) ? (int)((dp->dir[XDIR_Type] & 0x80) == 0) : (int)(dp->dir[DIR_Name] == DDEM || dp->dir[DIR_Name] == 0)) { -#else - if (dp->dir[DIR_Name] == DDEM || dp->dir[DIR_Name] == 0) { -#endif - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); - } while (res == FR_OK); /* Next entry with table stretch enabled */ - } - - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT: Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( /* Returns the top cluster value of the SFN entry */ - FATFS* fs, /* Pointer to the fs object */ - const BYTE* dir /* Pointer to the key entry */ -) -{ - DWORD cl; - - cl = ld_word(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) { - cl |= (DWORD)ld_word(dir + DIR_FstClusHI) << 16; - } - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir, /* Pointer to the key entry */ - DWORD cl /* Value to be set */ -) -{ - st_word(dir + DIR_FstClusLO, (WORD)cl); - if (fs->fs_type == FS_FAT32) { - st_word(dir + DIR_FstClusHI, (WORD)(cl >> 16)); - } -} -#endif - - - -#if _USE_LFN != 0 -/*------------------------------------------------------------------------*/ -/* FAT-LFN: LFN handling */ -/*------------------------------------------------------------------------*/ -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -/*--------------------------------------------------------*/ -/* FAT-LFN: Compare a part of file name with an LFN entry */ -/*--------------------------------------------------------*/ -static -int cmp_lfn ( /* 1:matched, 0:not matched */ - const WCHAR* lfnbuf, /* Pointer to the LFN working buffer to be compared */ - BYTE* dir /* Pointer to the directory entry containing the part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - if (ld_word(dir + LDIR_FstClusLO) != 0) return 0; /* Check LDIR_FstClusLO */ - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - for (wc = 1, s = 0; s < 13; s++) { /* Process all characters in the entry */ - uc = ld_word(dir + LfnOfs[s]); /* Pick an LFN character */ - if (wc) { - if (i >= _MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++])) { /* Compare it */ - return 0; /* Not matched */ - } - wc = uc; - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) return 0; /* Last segment matched but different length */ - - return 1; /* The part of LFN matched */ -} - - -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 || _USE_LABEL || _FS_EXFAT -/*-----------------------------------------------------*/ -/* FAT-LFN: Pick a part of file name from an LFN entry */ -/*-----------------------------------------------------*/ -static -int pick_lfn ( /* 1:succeeded, 0:buffer overflow or invalid LFN entry */ - WCHAR* lfnbuf, /* Pointer to the LFN working buffer */ - BYTE* dir /* Pointer to the LFN entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - if (ld_word(dir + LDIR_FstClusLO) != 0) return 0; /* Check LDIR_FstClusLO */ - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - for (wc = 1, s = 0; s < 13; s++) { /* Process all characters in the entry */ - uc = ld_word(dir + LfnOfs[s]); /* Pick an LFN character */ - if (wc) { - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; /* The part of LFN is valid */ -} -#endif - - -#if !_FS_READONLY -/*-----------------------------------------*/ -/* FAT-LFN: Create an entry of LFN entries */ -/*-----------------------------------------*/ -static -void put_lfn ( - const WCHAR* lfn, /* Pointer to the LFN */ - BYTE* dir, /* Pointer to the LFN entry to be created */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* Checksum of the corresponding SFN */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set checksum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - st_word(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN working buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfn[i++]; /* Get an effective character */ - st_word(dir + LfnOfs[s], wc); /* Put it */ - if (wc == 0) wc = 0xFFFF; /* Padding characters for left locations */ - } while (++s < 13); - if (wc == 0xFFFF || !lfn[i]) ord |= LLEF; /* Last LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LFN != 0 */ - - - -#if _USE_LFN != 0 && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* FAT-LFN: Create a Numbered SFN */ -/*-----------------------------------------------------------------------*/ - -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* In case of many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (BYTE)((seq % 16) + '0'); - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif /* _USE_LFN != 0 && !_FS_READONLY */ - - - -#if _USE_LFN != 0 -/*-----------------------------------------------------------------------*/ -/* FAT-LFN: Calculate checksum of an SFN entry */ -/*-----------------------------------------------------------------------*/ - -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} - -#endif /* _USE_LFN != 0 */ - - - -#if _FS_EXFAT -/*-----------------------------------------------------------------------*/ -/* exFAT: Checksum */ -/*-----------------------------------------------------------------------*/ - -static -WORD xdir_sum ( /* Get checksum of the directoly block */ - const BYTE* dir /* Directory entry block to be calculated */ -) -{ - UINT i, szblk; - WORD sum; - - - szblk = (dir[XDIR_NumSec] + 1) * SZDIRE; - for (i = sum = 0; i < szblk; i++) { - if (i == XDIR_SetSum) { /* Skip sum field */ - i++; - } else { - sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + dir[i]; - } - } - return sum; -} - - - -static -WORD xname_sum ( /* Get check sum (to be used as hash) of the name */ - const WCHAR* name /* File name to be calculated */ -) -{ - WCHAR chr; - WORD sum = 0; - - - while ((chr = *name++) != 0) { - chr = ff_wtoupper(chr); /* File name needs to be ignored case */ - sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr & 0xFF); - sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr >> 8); - } - return sum; -} - - -#if !_FS_READONLY && _USE_MKFS -static -DWORD xsum32 ( - BYTE dat, /* Data to be sumed */ - DWORD sum /* Previous value */ -) -{ - sum = ((sum & 1) ? 0x80000000 : 0) + (sum >> 1) + dat; - return sum; -} -#endif - - -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -/*------------------------------------------------------*/ -/* exFAT: Get object information from a directory block */ -/*------------------------------------------------------*/ - -static -void get_xdir_info ( - BYTE* dirb, /* Pointer to the direcotry entry block 85+C0+C1s */ - FILINFO* fno /* Buffer to store the extracted file information */ -) -{ - UINT di, si; - WCHAR w; -#if !_LFN_UNICODE - UINT nc; -#endif - - /* Get file name */ -#if _LFN_UNICODE - if (dirb[XDIR_NumName] <= _MAX_LFN) { - for (si = SZDIRE * 2, di = 0; di < dirb[XDIR_NumName]; si += 2, di++) { - if ((si % SZDIRE) == 0) si += 2; /* Skip entry type field */ - w = ld_word(dirb + si); /* Get a character */ - fno->fname[di] = w; /* Store it */ - } - } else { - di = 0; /* Buffer overflow and inaccessible object */ - } -#else - for (si = SZDIRE * 2, di = nc = 0; nc < dirb[XDIR_NumName]; si += 2, nc++) { - if ((si % SZDIRE) == 0) si += 2; /* Skip entry type field */ - w = ld_word(dirb + si); /* Get a character */ - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (w == 0) { di = 0; break; } /* Could not be converted and inaccessible object */ - if (_DF1S && w >= 0x100) { /* Put 1st byte if it is a DBC (always false at SBCS cfg) */ - fno->fname[di++] = (char)(w >> 8); - } - if (di >= _MAX_LFN) { di = 0; break; } /* Buffer overflow and inaccessible object */ - fno->fname[di++] = (char)w; - } -#endif - if (di == 0) fno->fname[di++] = '?'; /* Inaccessible object? */ - fno->fname[di] = 0; /* Terminate file name */ - - fno->altname[0] = 0; /* No SFN */ - fno->fattrib = dirb[XDIR_Attr]; /* Attribute */ - fno->fsize = (fno->fattrib & AM_DIR) ? 0 : ld_qword(dirb + XDIR_FileSize); /* Size */ - fno->ftime = ld_word(dirb + XDIR_ModTime + 0); /* Time */ - fno->fdate = ld_word(dirb + XDIR_ModTime + 2); /* Date */ -} - -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - -/*-----------------------------------*/ -/* exFAT: Get a directry entry block */ -/*-----------------------------------*/ - -static -FRESULT load_xdir ( /* FR_INT_ERR: invalid entry block */ - DIR* dp /* Pointer to the reading direcotry object pointing the 85 entry */ -) -{ - FRESULT res; - UINT i, nent; - BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory direcotry entry block 85+C0+C1s */ - - - /* Load 85 entry */ - res = move_window(dp->obj.fs, dp->sect); - if (res != FR_OK) return res; - if (dp->dir[XDIR_Type] != 0x85) return FR_INT_ERR; - mem_cpy(dirb, dp->dir, SZDIRE); - nent = dirb[XDIR_NumSec] + 1; - - /* Load C0 entry */ - res = dir_next(dp, 0); - if (res != FR_OK) return res; - res = move_window(dp->obj.fs, dp->sect); - if (res != FR_OK) return res; - if (dp->dir[XDIR_Type] != 0xC0) return FR_INT_ERR; - mem_cpy(dirb + SZDIRE, dp->dir, SZDIRE); - - /* Load C1 entries */ - if (nent < 3 || nent > 19) return FR_NO_FILE; - i = SZDIRE * 2; nent *= SZDIRE; - do { - res = dir_next(dp, 0); - if (res != FR_OK) return res; - res = move_window(dp->obj.fs, dp->sect); - if (res != FR_OK) return res; - if (dp->dir[XDIR_Type] != 0xC1) return FR_INT_ERR; - mem_cpy(dirb + i, dp->dir, SZDIRE); - i += SZDIRE; - } while (i < nent); - - /* Sanity check */ - if (xdir_sum(dirb) != ld_word(dirb + XDIR_SetSum)) return FR_INT_ERR; - - return FR_OK; -} - - -#if !_FS_READONLY || _FS_RPATH != 0 -/*------------------------------------------------*/ -/* exFAT: Load the object's directory entry block */ -/*------------------------------------------------*/ -static -FRESULT load_obj_dir ( - DIR* dp, /* Blank directory object to be used to access containing direcotry */ - const _FDID* obj /* Object with containing directory information */ -) -{ - FRESULT res; - - - /* Open object containing directory */ - dp->obj.fs = obj->fs; - dp->obj.sclust = obj->c_scl; - dp->obj.stat = (BYTE)obj->c_size; - dp->obj.objsize = obj->c_size & 0xFFFFFF00; - dp->blk_ofs = obj->c_ofs; - - res = dir_sdi(dp, dp->blk_ofs); /* Goto the block location */ - if (res == FR_OK) { - res = load_xdir(dp); /* Load the object's entry block */ - } - return res; -} -#endif - - -#if !_FS_READONLY -/*-----------------------------------------------*/ -/* exFAT: Store the directory block to the media */ -/*-----------------------------------------------*/ -static -FRESULT store_xdir ( - DIR* dp /* Pointer to the direcotry object */ -) -{ - FRESULT res; - UINT nent; - BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the direcotry entry block 85+C0+C1s */ - - /* Create set sum */ - st_word(dirb + XDIR_SetSum, xdir_sum(dirb)); - nent = dirb[XDIR_NumSec] + 1; - - /* Store the set of directory to the volume */ - res = dir_sdi(dp, dp->blk_ofs); - while (res == FR_OK) { - res = move_window(dp->obj.fs, dp->sect); - if (res != FR_OK) break; - mem_cpy(dp->dir, dirb, SZDIRE); - dp->obj.fs->wflag = 1; - if (--nent == 0) break; - dirb += SZDIRE; - res = dir_next(dp, 0); - } - return (res == FR_OK || res == FR_DISK_ERR) ? res : FR_INT_ERR; -} - - - -/*-------------------------------------------*/ -/* exFAT: Create a new directory enrty block */ -/*-------------------------------------------*/ - -static -void create_xdir ( - BYTE* dirb, /* Pointer to the direcotry entry block buffer */ - const WCHAR* lfn /* Pointer to the nul terminated file name */ -) -{ - UINT i; - BYTE nb, nc; - WCHAR chr; - - - mem_set(dirb, 0, 2 * SZDIRE); /* Initialize 85+C0 entry */ - dirb[XDIR_Type] = 0x85; - dirb[XDIR_Type + SZDIRE] = 0xC0; - st_word(dirb + XDIR_NameHash, xname_sum(lfn)); /* Set name hash */ - - i = SZDIRE * 2; /* C1 offset */ - nc = 0; nb = 1; chr = 1; - do { - dirb[i++] = 0xC1; dirb[i++] = 0; /* Entry type C1 */ - do { /* Fill name field */ - if (chr && (chr = lfn[nc]) != 0) nc++; /* Get a character if exist */ - st_word(dirb + i, chr); i += 2; /* Store it */ - } while (i % SZDIRE); - nb++; - } while (lfn[nc]); /* Fill next entry if any char follows */ - - dirb[XDIR_NumName] = nc; /* Set name length */ - dirb[XDIR_NumSec] = nb; /* Set number of C0+C1s */ -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_EXFAT */ - - - -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 || _USE_LABEL || _FS_EXFAT -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res = FR_NO_FILE; - FATFS *fs = dp->obj.fs; - BYTE a, c; -#if _USE_LFN != 0 - BYTE ord = 0xFF, sum = 0xFF; -#endif - - while (dp->sect) { - res = move_window(fs, dp->sect); - if (res != FR_OK) break; - c = dp->dir[DIR_Name]; /* Test for the entry type */ - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of the directory */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - if (_USE_LABEL && vol) { - if (c == 0x83) break; /* Volume label entry? */ - } else { - if (c == 0x85) { /* Start of the file entry block? */ - dp->blk_ofs = dp->dptr; /* Get location of the block */ - res = load_xdir(dp); /* Load the entry block */ - if (res == FR_OK) { - dp->obj.attr = fs->dirbuf[XDIR_Attr] & AM_MASK; /* Get attribute */ - } - break; - } - } - } else -#endif - { /* On the FAT12/16/32 volume */ - dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */ -#if _USE_LFN != 0 /* LFN configuration */ - if (c == DDEM || c == '.' || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of an LFN sequence? */ - sum = dp->dir[LDIR_Chksum]; - c &= (BYTE)~LLEF; ord = c; - dp->blk_ofs = dp->dptr; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dp->dir[LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dp->dir)) { /* Is there a valid LFN? */ - dp->blk_ofs = 0xFFFFFFFF; /* It has no LFN. */ - } - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && c != '.' && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) { /* Is it a valid entry? */ - break; - } -#endif - } - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; /* Terminate the read operation on error or EOT */ - return res; -} - -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */ - DIR* dp /* Pointer to the directory object with the file name */ -) -{ - FRESULT res; - FATFS *fs = dp->obj.fs; - BYTE c; -#if _USE_LFN != 0 - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - BYTE nc; - UINT di, ni; - WORD hash = xname_sum(fs->lfnbuf); /* Hash value of the name to find */ - - while ((res = dir_read(dp, 0)) == FR_OK) { /* Read an item */ - if (ld_word(fs->dirbuf + XDIR_NameHash) != hash) continue; /* Skip the comparison if hash value mismatched */ - for (nc = fs->dirbuf[XDIR_NumName], di = SZDIRE * 2, ni = 0; nc; nc--, di += 2, ni++) { /* Compare the name */ - if ((di % SZDIRE) == 0) di += 2; - if (ff_wtoupper(ld_word(fs->dirbuf + di)) != ff_wtoupper(fs->lfnbuf[ni])) break; - } - if (nc == 0 && !fs->lfnbuf[ni]) break; /* Name matched? */ - } - return res; - } -#endif - /* On the FAT12/16/32 volume */ -#if _USE_LFN != 0 - ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(fs, dp->sect); - if (res != FR_OK) break; - c = dp->dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN != 0 /* LFN configuration */ - dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (!(dp->fn[NSFLAG] & NS_NOLFN)) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dp->dir[LDIR_Chksum]; - c &= (BYTE)~LLEF; ord = c; /* LFN start order */ - dp->blk_ofs = dp->dptr; /* Start offset of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dp->dir[LDIR_Chksum] && cmp_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dp->dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dp->dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - dp->obj.attr = dp->dir[DIR_Attr] & AM_MASK; - if (!(dp->dir[DIR_Attr] & AM_VOL) && !mem_cmp(dp->dir, dp->fn, 11)) break; /* Is it a valid entry? */ -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; - FATFS *fs = dp->obj.fs; -#if _USE_LFN != 0 /* LFN configuration */ - UINT n, nlen, nent; - BYTE sn[12], sum; - - - if (dp->fn[NSFLAG] & (NS_DOT | NS_NONAME)) return FR_INVALID_NAME; /* Check name validity */ - for (nlen = 0; fs->lfnbuf[nlen]; nlen++) ; /* Get lfn length */ - -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - DIR dj; - - nent = (nlen + 14) / 15 + 2; /* Number of entries to allocate (85+C0+C1s) */ - res = dir_alloc(dp, nent); /* Allocate entries */ - if (res != FR_OK) return res; - dp->blk_ofs = dp->dptr - SZDIRE * (nent - 1); /* Set block position */ - - if (dp->obj.sclust != 0 && (dp->obj.stat & 4)) { /* Has the sub-directory been stretched? */ - dp->obj.stat &= 3; - dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase object size by cluster size */ - res = fill_fat_chain(&dp->obj); /* Complement FAT chain if needed */ - if (res != FR_OK) return res; - res = load_obj_dir(&dj, &dp->obj); - if (res != FR_OK) return res; /* Load the object status */ - st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize); /* Update the allocation status */ - st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize); - fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1; - res = store_xdir(&dj); /* Store the object status */ - if (res != FR_OK) return res; - } - - create_xdir(fs->dirbuf, fs->lfnbuf); /* Create on-memory directory block to be written later */ - return FR_OK; - } -#endif - /* On the FAT12/16/32 volume */ - mem_cpy(sn, dp->fn, 12); - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - dp->fn[NSFLAG] = NS_NOLFN; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(dp->fn, sn, fs->lfnbuf, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - dp->fn[NSFLAG] = sn[NSFLAG]; - } - - /* Create an SFN with/without LFNs. */ - nent = (sn[NSFLAG] & NS_LFN) ? (nlen + 12) / 13 + 1 : 1; /* Number of entries to allocate */ - res = dir_alloc(dp, nent); /* Allocate entries */ - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->dptr - nent * SZDIRE); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Checksum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(fs, dp->sect); - if (res != FR_OK) break; - put_lfn(fs->lfnbuf, dp->dir, (BYTE)nent, sum); - fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } - -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ - -#endif - - /* Set SFN entry */ - if (res == FR_OK) { - res = move_window(fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZDIRE); /* Clean the entry */ - mem_cpy(dp->dir + DIR_Name, dp->fn, 11); /* Put SFN */ -#if _USE_LFN != 0 - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - fs->wflag = 1; - } - } - - return res; -} - -#endif /* !_FS_READONLY */ - - - -#if !_FS_READONLY && _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; - FATFS *fs = dp->obj.fs; -#if _USE_LFN != 0 /* LFN configuration */ - DWORD last = dp->dptr; - - res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs); /* Goto top of the entry block if LFN is exist */ - if (res == FR_OK) { - do { - res = move_window(fs, dp->sect); - if (res != FR_OK) break; - /* Mark an entry 'deleted' */ - if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - dp->dir[XDIR_Type] &= 0x7F; - } else { /* On the FAT12/16/32 volume */ - dp->dir[DIR_Name] = DDEM; - } - fs->wflag = 1; - if (dp->dptr >= last) break; /* If reached last entry then all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } -#else /* Non LFN configuration */ - - res = move_window(fs, dp->sect); - if (res == FR_OK) { - dp->dir[DIR_Name] = DDEM; - fs->wflag = 1; - } -#endif - - return res; -} - -#endif /* !_FS_READONLY && _FS_MINIMIZE == 0 */ - - - -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ - -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i, j; - TCHAR c; - DWORD tm; -#if _USE_LFN != 0 - WCHAR w, lfv; - FATFS *fs = dp->obj.fs; -#endif - - - fno->fname[0] = 0; /* Invaidate file info */ - if (!dp->sect) return; /* Exit if read pointer has reached end of directory */ - -#if _USE_LFN != 0 /* LFN configuration */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - get_xdir_info(fs->dirbuf, fno); - return; - } else -#endif - { /* On the FAT12/16/32 volume */ - if (dp->blk_ofs != 0xFFFFFFFF) { /* Get LFN if available */ - i = j = 0; - while ((w = fs->lfnbuf[j++]) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (w == 0) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) { /* Put 1st byte if it is a DBC (always false at SBCS cfg) */ - fno->fname[i++] = (char)(w >> 8); - } -#endif - if (i >= _MAX_LFN) { i = 0; break; } /* No LFN if buffer overflow */ - fno->fname[i++] = (TCHAR)w; - } - fno->fname[i] = 0; /* Terminate the LFN */ - } - } - - i = j = 0; - lfv = fno->fname[i]; /* LFN is exist if non-zero */ - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dp->dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) { /* Insert a . if extension is exist */ - if (!lfv) fno->fname[j] = '.'; - fno->altname[j++] = '.'; - } -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dp->dir[i])) { - c = c << 8 | dp->dir[i++]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif - fno->altname[j] = c; - if (!lfv) { - if (IsUpper(c) && (dp->dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) { - c += 0x20; /* To lower */ - } - fno->fname[j] = c; - } - j++; - } - if (!lfv) { - fno->fname[j] = 0; - if (!dp->dir[DIR_NTres]) j = 0; /* Altname is no longer needed if neither LFN nor case info is exist. */ - } - fno->altname[j] = 0; /* Terminate the SFN */ - -#else /* Non-LFN configuration */ - i = j = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dp->dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) fno->fname[j++] = '.'; /* Insert a . if extension is exist */ - fno->fname[j++] = c; - } - fno->fname[j] = 0; -#endif - - fno->fattrib = dp->dir[DIR_Attr]; /* Attribute */ - fno->fsize = ld_dword(dp->dir + DIR_FileSize); /* Size */ - tm = ld_dword(dp->dir + DIR_ModTime); /* Timestamp */ - fno->ftime = (WORD)tm; fno->fdate = (WORD)(tm >> 16); -} - -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - -#if _USE_FIND && _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ - -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ -#if !_LFN_UNICODE - WCHAR chr; - - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#else - if (IsDBCS1(chr) && IsDBCS2(**ptr)) { /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; - } -#endif - return chr; -#else - return ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif -} - - -static -int pattern_matching ( /* 0:not matched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (pc == 0) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} - -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - -/*-----------------------------------------------------------------------*/ -/* Pick a top segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */ - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN != 0 /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - p = *path; lfn = dp->obj.fs->lfnbuf; si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ') break; /* Break if end of the path name */ - if (w == '/' || w == '\\') { /* Break if a separator is found */ - while (p[si] == '/' || p[si] == '\\') si++; /* Skip duplicated separator if exist */ - break; - } - if (di >= _MAX_LFN) return FR_INVALID_NAME; /* Reject too long name */ -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) return FR_INVALID_NAME; /* Reject illegal characters for LFN */ - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of the path */ -#if _FS_RPATH != 0 - if ((di == 1 && lfn[di - 1] == '.') || - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { /* Is this segment a dot name? */ - lfn[di] = 0; - for (i = 0; i < 11; i++) /* Create dot name for SFN entry */ - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Snip off trailing spaces and dots if exist */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - lfn[di] = 0; /* LFN is created */ - if (di == 0) return FR_INVALID_NAME; /* Reject nul name */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - i = b = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* Is this DBC? (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) cf |= NS_LFN; /* Create LFN entry when there are composite capitals */ - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* _USE_LFN != 0 : Non-LFN configuration */ - BYTE c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - p = *path; sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = 0; ni = 8; -#if _FS_RPATH != 0 - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = p + si; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of the path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ') break; /* Break if end of the path name */ - if (c == '/' || c == '\\') { /* Break if a separator is found */ - while (p[si] == '/' || p[si] == '\\') si++; /* Skip duplicated separator if exist */ - break; - } - if (c == '.' || i >= ni) { /* End of body or over size? */ - if (ni == 11 || c != '.') return FR_INVALID_NAME; /* Over size or invalid dot */ - i = 8; ni = 11; /* Goto extension */ - continue; - } - if (c >= 0x80) { /* Extended character? */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII only cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false at SBCS cfg.) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) return FR_INVALID_NAME; /* Reject invalid DBC */ - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) return FR_INVALID_NAME; /* Reject illegal chrs for SFN */ - if (IsLower(c)) c -= 0x20; /* To upper */ - sfn[i++] = c; - } - } - *path = p + si; /* Return pointer to the next segment */ - if (i == 0) return FR_INVALID_NAME; /* Reject nul string */ - - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* If the first character collides with DDEM, replace it with RDDEM */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of the path */ - - return FR_OK; -#endif /* _USE_LFN != 0 */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE ns; - _FDID *obj = &dp->obj; - FATFS *fs = obj->fs; - - -#if _FS_RPATH != 0 - if (*path != '/' && *path != '\\') { /* Without heading separator */ - obj->sclust = fs->cdir; /* Start from the current directory */ - } else -#endif - { /* With heading separator */ - while (*path == '/' || *path == '\\') path++; /* Strip heading separator */ - obj->sclust = 0; /* Start from the root directory */ - } -#if _FS_EXFAT && _FS_RPATH != 0 - if (fs->fs_type == FS_EXFAT && obj->sclust) { /* Retrieve the sub-directory status if needed */ - DIR dj; - - obj->c_scl = fs->cdc_scl; - obj->c_size = fs->cdc_size; - obj->c_ofs = fs->cdc_ofs; - res = load_obj_dir(&dj, obj); - if (res != FR_OK) return res; - obj->objsize = ld_dword(fs->dirbuf + XDIR_FileSize); - obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; - } -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - dp->fn[NSFLAG] = NS_NONAME; - res = dir_sdi(dp, 0); - - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the segment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - dp->fn[NSFLAG] = NS_NONAME; - res = FR_OK; - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - /* Get into the sub-directory */ - if (!(obj->attr & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - obj->c_scl = obj->sclust; /* Save containing directory information for next dir */ - obj->c_size = ((DWORD)obj->objsize & 0xFFFFFF00) | obj->stat; - obj->c_ofs = dp->blk_ofs; - obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Open next directory */ - obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; - obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); - } else -#endif - { - obj->sclust = ld_clust(fs, fs->win + dp->dptr % SS(fs)); /* Open next directory */ - } - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT, 1:exFAT, 2:Valid BS but not FAT, 3:Not a BS, 4:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT-VBR or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) return 4; /* Load boot record */ - - if (ld_word(fs->win + BS_55AA) != 0xAA55) return 3; /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - - if (fs->win[BS_JmpBoot] == 0xE9 || (fs->win[BS_JmpBoot] == 0xEB && fs->win[BS_JmpBoot + 2] == 0x90)) { - if ((ld_dword(fs->win + BS_FilSysType) & 0xFFFFFF) == 0x544146) return 0; /* Check "FAT" string */ - if (ld_dword(fs->win + BS_FilSysType32) == 0x33544146) return 0; /* Check "FAT3" string */ - } -#if _FS_EXFAT - if (!mem_cmp(fs->win + BS_JmpBoot, "\xEB\x76\x90" "EXFAT ", 11)) return 1; -#endif - return 2; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS* fs, /* Pointer to the file system object */ - BYTE mode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - UINT i; - - - ENTER_FF(fs); /* Lock the volume */ - - mode &= (BYTE)~FA_READ; /* Desired access mode, write access or not */ - if (fs->fs_type) { /* If the volume has been mounted */ - disk_ioctl(fs->drv, IOCTL_STATUS, &stat); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && mode && (stat & STA_PROTECT)) { /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - } - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - disk_ioctl(fs->drv, IOCTL_INIT, &stat); /* Initialize the physical drive */ - if (stat & STA_NOINIT) { /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - } - if (!_FS_READONLY && mode && (stat & STA_PROTECT)) { /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; - } -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK) return FR_DISK_ERR; - if (SS(fs) > _MAX_SS || SS(fs) < _MIN_SS || (SS(fs) & (SS(fs) - 1))) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT-VBR as SFD */ - if (fmt == 2 || (fmt < 2 && LD2PT(fs) != 0)) { /* Not an FAT-VBR or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + (MBR_Table + i * SZ_PTE); - br[i] = pt[PTE_System] ? ld_dword(pt + PTE_StLba) : 0; - } - i = LD2PT(fs); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */ - } while (!LD2PT(fs) && fmt >= 2 && ++i < 4); - } - if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - -#if _FS_EXFAT - if (fmt == 1) { - QWORD maxlba; - - for (i = BPB_ZeroedEx; i < BPB_ZeroedEx + 53 && fs->win[i] == 0; i++) ; /* Check zero filler */ - if (i < BPB_ZeroedEx + 53) return FR_NO_FILESYSTEM; - - if (ld_word(fs->win + BPB_FSVerEx) != 0x100) return FR_NO_FILESYSTEM; /* Check exFAT revision (Must be 1.0) */ - - if (1 << fs->win[BPB_BytsPerSecEx] != SS(fs)) /* (BPB_BytsPerSecEx must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - maxlba = ld_qword(fs->win + BPB_TotSecEx) + bsect; /* Last LBA + 1 of the volume */ - if (maxlba >= 0x100000000) return FR_NO_FILESYSTEM; /* (It cannot be handled in 32-bit LBA) */ - - fs->fsize = ld_dword(fs->win + BPB_FatSzEx); /* Number of sectors per FAT */ - - fs->n_fats = fs->win[BPB_NumFATsEx]; /* Number of FATs */ - if (fs->n_fats != 1) return FR_NO_FILESYSTEM; /* (Supports only 1 FAT) */ - - fs->csize = 1 << fs->win[BPB_SecPerClusEx]; /* Cluster size */ - if (fs->csize == 0) return FR_NO_FILESYSTEM; /* (Must be 1..32768) */ - - nclst = ld_dword(fs->win + BPB_NumClusEx); /* Number of clusters */ - if (nclst > MAX_EXFAT) return FR_NO_FILESYSTEM; /* (Too many clusters) */ - fs->n_fatent = nclst + 2; - - /* Boundaries and Limits */ - fs->volbase = bsect; - fs->database = bsect + ld_dword(fs->win + BPB_DataOfsEx); - fs->fatbase = bsect + ld_dword(fs->win + BPB_FatOfsEx); - if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */ - fs->dirbase = ld_dword(fs->win + BPB_RootClusEx); - - /* Check if bitmap location is in assumption (at the first cluster) */ - if (move_window(fs, clust2sect(fs, fs->dirbase)) != FR_OK) return FR_DISK_ERR; - for (i = 0; i < SS(fs); i += SZDIRE) { - if (fs->win[i] == 0x81 && ld_dword(fs->win + i + 20) == 2) break; /* 81 entry with cluster #2? */ - } - if (i == SS(fs)) return FR_NO_FILESYSTEM; -#if !_FS_READONLY - fs->last_clst = fs->free_clst = 0xFFFFFFFF; /* Initialize cluster allocation information */ -#endif - fmt = FS_EXFAT; /* FAT sub-type */ - } else -#endif /* _FS_EXFAT */ - { - if (ld_word(fs->win + BPB_BytsPerSec) != SS(fs)) return FR_NO_FILESYSTEM; /* (BPB_BytsPerSec must be equal to the physical sector size) */ - - fasize = ld_word(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (fasize == 0) fasize = ld_dword(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FATs */ - if (fs->n_fats != 1 && fs->n_fats != 2) return FR_NO_FILESYSTEM; /* (Must be 1 or 2) */ - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Cluster size */ - if (fs->csize == 0 || (fs->csize & (fs->csize - 1))) return FR_NO_FILESYSTEM; /* (Must be power of 2) */ - - fs->n_rootdir = ld_word(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZDIRE)) return FR_NO_FILESYSTEM; /* (Must be sector aligned) */ - - tsect = ld_word(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (tsect == 0) tsect = ld_dword(fs->win + BPB_TotSec32); - - nrsv = ld_word(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (nrsv == 0) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZDIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (nclst == 0) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT32; - if (nclst <= MAX_FAT16) fmt = FS_FAT16; - if (nclst <= MAX_FAT12) fmt = FS_FAT12; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (ld_word(fs->win + BPB_FSVer32) != 0) return FR_NO_FILESYSTEM; /* (Must be FAT32 revision 0.0) */ - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = ld_dword(fs->win + BPB_RootClus32); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (fs->n_rootdir == 0) return FR_NO_FILESYSTEM;/* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) return FR_NO_FILESYSTEM; /* (BPB_FATSz must not be less than the size needed) */ - -#if !_FS_READONLY - /* Get FSINFO if available */ - fs->last_clst = fs->free_clst = 0xFFFFFFFF; /* Initialize cluster allocation information */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo32 == 1 */ - && ld_word(fs->win + BPB_FSInfo32) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (ld_word(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && ld_dword(fs->win + FSI_LeadSig) == 0x41615252 - && ld_dword(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clst = ld_dword(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clst = ld_dword(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif /* (_FS_NOFSINFO & 3) != 3 */ -#endif /* !_FS_READONLY */ - } - - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _USE_LFN == 1 - fs->lfnbuf = LfnBuf; /* Static LFN working buffer */ -#if _FS_EXFAT - fs->dirbuf = DirBuf; /* Static directory block working buuffer */ -#endif -#endif -#if _FS_RPATH != 0 - fs->cdir = 0; /* Initialize current directory */ -#endif -#if _FS_LOCK != 0 /* Clear file lock semaphores */ - clear_lock(fs); -#endif - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */ - _FDID* obj, /* Pointer to the _OBJ, the 1st member in the FIL/DIR object, to check validity */ - FATFS** fs /* Pointer to pointer to the owner file system object to return */ -) -{ - FRESULT res; - DSTATUS stat; - - - if (!obj || !obj->fs || !obj->fs->fs_type || obj->fs->id != obj->id || disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) != RES_OK || (stat & STA_NOINIT)) { - *fs = 0; /* The object is invalid */ - res = FR_INVALID_OBJECT; - } else { - *fs = obj->fs; /* Owner file sytem object */ - ENTER_FF(obj->fs); /* Lock file system */ - res = FR_OK; - } - return res; -} - - - - -/*--------------------------------------------------------------------------- - - Public Functions (FatFs API) - -----------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs /* Pointer to the file system object to mount */ -) -{ - FRESULT res; - - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj(fs, &fs->sobj)) return FR_INT_ERR; -#endif - - res = find_volume(fs, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - -FRESULT f_umount ( - FATFS* fs /* Pointer to the file system object to unmount */ -) -{ -#if _FS_LOCK - clear_lock(fs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(fs->sobj)) return FR_INT_ERR; -#endif - fs->fs_type = 0; /* Clear old fs object */ - - return FR_OK; -} - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FATFS *fs, - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; -#if !_FS_READONLY - DWORD dw, cl, bcs, clst, sc; - FSIZE_t ofs; -#endif - DEF_NAMBUF - - - if (!fp) return FR_INVALID_OBJECT; - - /* Get logical drive */ - mode &= _FS_READONLY ? FA_READ : FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_CREATE_NEW | FA_OPEN_ALWAYS | FA_OPEN_APPEND | FA_SEEKEND; - res = find_volume(fs, mode); - if (res == FR_OK) { - dj.obj.fs = fs; - INIT_NAMBUF(fs); - res = follow_path(&dj, path); /* Follow the file path */ -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (dj.fn[NSFLAG] & NS_NONAME) { /* Origin directory itself? */ - res = FR_INVALID_NAME; - } -#if _FS_LOCK != 0 - else { - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - } -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK != 0 - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - } - else { /* Any object is already existing */ - if (dj.obj.attr & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) res = FR_EXIST; /* Cannot create as new file */ - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - /* Get current allocation info */ - fp->obj.fs = fs; - fp->obj.sclust = ld_dword(fs->dirbuf + XDIR_FstClus); - fp->obj.objsize = ld_qword(fs->dirbuf + XDIR_FileSize); - fp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2; - /* Initialize directory entry block */ - st_dword(fs->dirbuf + XDIR_CrtTime, dw); /* Set created time */ - fs->dirbuf[XDIR_CrtTime10] = 0; - st_dword(fs->dirbuf + XDIR_ModTime, dw); /* Set modified time */ - fs->dirbuf[XDIR_ModTime10] = 0; - fs->dirbuf[XDIR_Attr] = AM_ARC; /* Reset attribute */ - st_dword(fs->dirbuf + XDIR_FstClus, 0); /* Reset file allocation info */ - st_qword(fs->dirbuf + XDIR_FileSize, 0); - st_qword(fs->dirbuf + XDIR_ValidFileSize, 0); - fs->dirbuf[XDIR_GenFlags] = 1; - res = store_xdir(&dj); - if (res == FR_OK && fp->obj.sclust) { /* Remove the cluster chain if exist */ - res = remove_chain(&fp->obj, fp->obj.sclust, 0); - fs->last_clst = fp->obj.sclust - 1; /* Reuse the cluster hole */ - } - } else -#endif - { - /* Clean directory info */ - st_dword(dj.dir + DIR_CrtTime, dw); /* Set created time */ - st_dword(dj.dir + DIR_ModTime, dw); /* Set modified time */ - dj.dir[DIR_Attr] = AM_ARC; /* Reset attribute */ - cl = ld_clust(fs, dj.dir); /* Get cluster chain */ - st_clust(fs, dj.dir, 0); /* Reset file allocation info */ - st_dword(dj.dir + DIR_FileSize, 0); - fs->wflag = 1; - - if (cl) { /* Remove the cluster chain if exist */ - dw = fs->winsect; - res = remove_chain(&dj.obj, cl, 0); - if (res == FR_OK) { - res = move_window(fs, dw); - fs->last_clst = cl - 1; /* Reuse the cluster hole */ - } - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Following succeeded */ - if (dj.obj.attr & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dj.obj.attr & AM_RDO)) { /* R/O violation */ - res = FR_DENIED; - } - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA_MODIFIED; - fp->dir_sect = fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dj.dir; -#if _FS_LOCK != 0 - fp->obj.lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->obj.lockid) res = FR_INT_ERR; -#endif - } -#else /* R/O configuration */ - if (res == FR_OK) { - if (dj.fn[NSFLAG] & NS_NONAME) { /* Origin directory itself? */ - res = FR_INVALID_NAME; - } else { - if (dj.obj.attr & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } - } - } -#endif - - if (res == FR_OK) { -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - fp->obj.sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Get allocation info */ - fp->obj.objsize = ld_qword(fs->dirbuf + XDIR_FileSize); - fp->obj.stat = fs->dirbuf[XDIR_GenFlags] & 2; - fp->obj.c_scl = dj.obj.sclust; - fp->obj.c_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat; - fp->obj.c_ofs = dj.blk_ofs; - } else -#endif - { - fp->obj.sclust = ld_clust(fs, dj.dir); /* Get allocation info */ - fp->obj.objsize = ld_dword(dj.dir + DIR_FileSize); - } -#if _USE_FASTSEEK - fp->cltbl = 0; /* Disable fast seek mode */ -#endif - fp->obj.fs = fs; /* Validate the file object */ - fp->obj.id = fs->id; - fp->flag = mode; /* Set file access mode */ - fp->err = 0; /* Clear error flag */ - fp->sect = 0; /* Invalidate current data sector */ - fp->fptr = 0; /* Set file pointer top of the file */ -#if !_FS_READONLY -#if !_FS_TINY - mem_set(fp->buf, 0, _MAX_SS); /* Clear sector buffer */ -#endif - if ((mode & FA_SEEKEND) && fp->obj.objsize > 0) { /* Seek to end of file if FA_OPEN_APPEND is specified */ - fp->fptr = fp->obj.objsize; /* Offset to seek */ - bcs = (DWORD)fs->csize * SS(fs); /* Cluster size in byte */ - clst = fp->obj.sclust; /* Follow the cluster chain */ - for (ofs = fp->obj.objsize; res == FR_OK && ofs > bcs; ofs -= bcs) { - clst = get_fat(&fp->obj, clst); - if (clst <= 1) res = FR_INT_ERR; - if (clst == 0xFFFFFFFF) res = FR_DISK_ERR; - } - fp->clust = clst; - if (res == FR_OK && ofs % SS(fs)) { /* Fill sector buffer if not on the sector boundary */ - if ((sc = clust2sect(fs, clst)) == 0) { - res = FR_INT_ERR; - } else { - fp->sect = sc + (DWORD)(ofs / SS(fs)); -#if !_FS_TINY - if (disk_read(fs->drv, fp->buf, fp->sect, 1) != RES_OK) res = FR_DISK_ERR; -#endif - } - } - } -#endif - } - - FREE_NAMBUF(); - } - - if (res != FR_OK) fp->obj.fs = 0; /* Invalidate file object on error */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - FATFS *fs; - DWORD clst, sect; - FSIZE_t remain; - UINT rcnt, cc, csect; - BYTE *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */ - if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ - remain = fp->obj.objsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if (fp->fptr % SS(fs) == 0) { /* On the sector boundary? */ - csect = (UINT)(fp->fptr / SS(fs) & (fs->csize - 1)); /* Sector offset in the cluster */ - if (csect == 0) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->obj.sclust; /* Follow cluster chain from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) { - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - } else -#endif - { - clst = get_fat(&fp->obj, fp->clust); /* Follow cluster chain on the FAT */ - } - } - if (clst < 2) ABORT(fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fs->csize) { /* Clip at cluster boundary */ - cc = fs->csize - csect; - } - if (disk_read(fs->drv, rbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fs->wflag && fs->winsect - sect < cc) { - mem_cpy(rbuff + ((fs->winsect - sect) * SS(fs)), fs->win, SS(fs)); - } -#else - if ((fp->flag & FA_DIRTY) && fp->sect - sect < cc) { - mem_cpy(rbuff + ((fp->sect - sect) * SS(fs)), fp->buf, SS(fs)); - } -#endif -#endif - rcnt = SS(fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->sect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif - if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */ - } -#endif - fp->sect = sect; - } - rcnt = SS(fs) - (UINT)fp->fptr % SS(fs); /* Number of bytes left in the sector */ - if (rcnt > btr) rcnt = btr; /* Clip it by btr if needed */ -#if _FS_TINY - if (move_window(fs, fp->sect) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Move sector window */ - mem_cpy(rbuff, fs->win + fp->fptr % SS(fs), rcnt); /* Extract partial sector */ -#else - mem_cpy(rbuff, fp->buf + fp->fptr % SS(fs), rcnt); /* Extract partial sector */ -#endif - } - - LEAVE_FF(fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void* buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - FATFS *fs; - DWORD clst, sect; - UINT wcnt, cc, csect; - const BYTE *wbuff = (const BYTE*)buff; - - - *bw = 0; /* Clear write byte counter */ - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */ - if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ - - /* Check fptr wrap-around (file size cannot reach 4GiB on FATxx) */ - if ((!_FS_EXFAT || fs->fs_type != FS_EXFAT) && (DWORD)(fp->fptr + btw) < (DWORD)fp->fptr) { - btw = (UINT)(0xFFFFFFFF - (DWORD)fp->fptr); - } - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, fp->obj.objsize = (fp->fptr > fp->obj.objsize) ? fp->fptr : fp->obj.objsize, *bw += wcnt, btw -= wcnt) { - if (fp->fptr % SS(fs) == 0) { /* On the sector boundary? */ - csect = (UINT)(fp->fptr / SS(fs)) & (fs->csize - 1); /* Sector offset in the cluster */ - if (csect == 0) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->obj.sclust; /* Follow from the origin */ - if (clst == 0) { /* If no cluster is allocated, */ - clst = create_chain(&fp->obj, 0); /* create a new cluster chain */ - } - } else { /* On the middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) { - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - } else -#endif - { - clst = create_chain(&fp->obj, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->obj.sclust == 0) fp->obj.sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fs->winsect == fp->sect && sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Write-back sector cache */ -#else - if (fp->flag & FA_DIRTY) { /* Write-back sector cache */ - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif - sect = clust2sect(fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fs->csize) { /* Clip at cluster boundary */ - cc = fs->csize - csect; - } - if (disk_write(fs->drv, wbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fs->win, wbuff + ((fs->winsect - sect) * SS(fs)), SS(fs)); - fs->wflag = 0; - } -#else - if (fp->sect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->sect - sect) * SS(fs)), SS(fs)); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif -#endif - wcnt = SS(fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->obj.objsize) { /* Avoid silly cache filling on the growing edge */ - if (sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR); - fs->winsect = sect; - } -#else - if (fp->sect != sect && /* Fill sector cache with file data */ - fp->fptr < fp->obj.objsize && - disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) { - ABORT(fs, FR_DISK_ERR); - } -#endif - fp->sect = sect; - } - wcnt = SS(fs) - (UINT)fp->fptr % SS(fs); /* Number of bytes left in the sector */ - if (wcnt > btw) wcnt = btw; /* Clip it by btw if needed */ -#if _FS_TINY - if (move_window(fs, fp->sect) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Move sector window */ - mem_cpy(fs->win + fp->fptr % SS(fs), wbuff, wcnt); /* Fit data to the sector */ - fs->wflag = 1; -#else - mem_cpy(fp->buf + fp->fptr % SS(fs), wbuff, wcnt); /* Fit data to the sector */ - fp->flag |= FA_DIRTY; -#endif - } - - fp->flag |= FA_MODIFIED; /* Set file change flag */ - - LEAVE_FF(fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD tm; - BYTE *dir; -#if _FS_EXFAT - DEF_NAMBUF -#endif - - - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res == FR_OK) { - if (fp->flag & FA_MODIFIED) { /* Is there any change to the file? */ -#if !_FS_TINY - if (fp->flag & FA_DIRTY) { /* Write-back cached data if needed */ - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) LEAVE_FF(fs, FR_DISK_ERR); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif - /* Update the directory entry */ - tm = GET_FATTIME(); /* Modified time */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - res = fill_fat_chain(&fp->obj); /* Create FAT chain if needed */ - if (res == FR_OK) { - DIR dj; - - INIT_NAMBUF(fs); - res = load_obj_dir(&dj, &fp->obj); /* Load directory entry block */ - if (res == FR_OK) { - fs->dirbuf[XDIR_Attr] |= AM_ARC; /* Set archive bit */ - fs->dirbuf[XDIR_GenFlags] = fp->obj.stat | 1; /* Update file allocation info */ - st_dword(fs->dirbuf + XDIR_FstClus, fp->obj.sclust); - st_qword(fs->dirbuf + XDIR_FileSize, fp->obj.objsize); - st_qword(fs->dirbuf + XDIR_ValidFileSize, fp->obj.objsize); - st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Update modified time */ - fs->dirbuf[XDIR_ModTime10] = 0; - st_dword(fs->dirbuf + XDIR_AccTime, 0); - res = store_xdir(&dj); /* Restore it to the directory */ - if (res == FR_OK) { - res = sync_fs(fs); - fp->flag &= (BYTE)~FA_MODIFIED; - } - } - FREE_NAMBUF(); - } - } else -#endif - { - res = move_window(fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - st_clust(fp->obj.fs, dir, fp->obj.sclust); /* Update file allocation info */ - st_dword(dir + DIR_FileSize, (DWORD)fp->obj.objsize); /* Update file size */ - st_dword(dir + DIR_ModTime, tm); /* Update modified time */ - st_word(dir + DIR_LstAccDate, 0); - fs->wflag = 1; - res = sync_fs(fs); /* Restore it to the directory */ - fp->flag &= (BYTE)~FA_MODIFIED; - } - } - } - } - - LEAVE_FF(fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL* fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - FATFS *fs; - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(&fp->obj, &fs); /* Lock volume */ - if (res == FR_OK) { -#if _FS_LOCK != 0 - res = dec_lock(fp->obj.lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - { - fp->obj.fs = 0; /* Invalidate file object */ - } -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -#if _FS_RPATH >= 1 -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chdir ( - FATFS *fs, - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEF_NAMBUF - - /* Get logical drive */ - res = find_volume(fs, 0); - if (res == FR_OK) { - dj.obj.fs = fs; - INIT_NAMBUF(fs); - res = follow_path(&dj, path); /* Follow the path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.fn[NSFLAG] & NS_NONAME) { - fs->cdir = dj.obj.sclust; /* It is the start directory itself */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - fs->cdc_scl = dj.obj.c_scl; - fs->cdc_size = dj.obj.c_size; - fs->cdc_ofs = dj.obj.c_ofs; - } -#endif - } else { - if (dj.obj.attr & AM_DIR) { /* It is a sub-directory */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - fs->cdir = ld_dword(fs->dirbuf + XDIR_FstClus); /* Sub-directory cluster */ - fs->cdc_scl = dj.obj.sclust; /* Save containing directory information */ - fs->cdc_size = ((DWORD)dj.obj.objsize & 0xFFFFFF00) | dj.obj.stat; - fs->cdc_ofs = dj.blk_ofs; - } else -#endif - { - fs->cdir = ld_clust(fs, dj.dir); /* Sub-directory cluster */ - } - } else { - res = FR_NO_PATH; /* Reached but a file */ - } - } - } - FREE_NAMBUF(); - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - FATFS *fs, - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEF_NAMBUF - - - *buff = 0; - /* Get logical drive */ - res = find_volume(fs, 0); /* Get current volume */ - if (res == FR_OK) { - dj.obj.fs = fs; - INIT_NAMBUF(fs); - i = len; /* Bottom of buffer (directory stack base) */ - if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { /* (Cannot do getcwd on exFAT and returns root path) */ - dj.obj.sclust = fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.obj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1 * SZDIRE); /* Get parent directory */ - if (res != FR_OK) break; - res = move_window(fs, dj.sect); - if (res != FR_OK) break; - dj.obj.sclust = ld_clust(fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - for (n = 0; fno.fname[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = fno.fname[--n]; - buff[--i] = '/'; - } - } - tp = buff; - if (res == FR_OK) { - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_NAMBUF(); - } - - LEAVE_FF(fs, res); -} - -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - FSIZE_t ofs /* File pointer from top of file */ -) -{ - FRESULT res; - FATFS *fs; - DWORD clst, bcs, nsect; - FSIZE_t ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */ -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->obj.sclust; /* Origin of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(&fp->obj, cl); - if (cl <= 1) ABORT(fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) { - *tbl = 0; /* Terminate table */ - } else { - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - } - } else { /* Fast seek */ - if (ofs > fp->obj.objsize) ofs = fp->obj.objsize; /* Clip offset at the file size */ - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fs, fp->clust); - if (!dsc) ABORT(fs, FR_INT_ERR); - dsc += (DWORD)((ofs - 1) / SS(fs)) & (fs->csize - 1); - if (fp->fptr % SS(fs) && dsc != fp->sect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif - if (disk_read(fs->drv, fp->buf, dsc, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Load current sector */ -#endif - fp->sect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { -#if _FS_EXFAT - if (fs->fs_type != FS_EXFAT && ofs >= 0x100000000) ofs = 0xFFFFFFFF; /* Clip at 4GiB-1 if at FATxx */ -#endif - if (ofs > fp->obj.objsize && (_FS_READONLY || !(fp->flag & FA_WRITE))) { /* In read-only mode, clip offset with the file size */ - ofs = fp->obj.objsize; - } - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fs->csize * SS(fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(FSIZE_t)(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->obj.sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(&fp->obj, 0); - if (clst == 1) ABORT(fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); - fp->obj.sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ - ofs -= bcs; fp->fptr += bcs; -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - if (_FS_EXFAT && fp->fptr > fp->obj.objsize) { /* No FAT chain object needs correct objsize to generate FAT value */ - fp->obj.objsize = fp->fptr; - fp->flag |= FA_MODIFIED; - } - clst = create_chain(&fp->obj, clst); /* Follow chain with forceed stretch */ - if (clst == 0) { /* Clip file size in case of disk full */ - ofs = 0; break; - } - } else -#endif - { - clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */ - } - if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR); - fp->clust = clst; - } - fp->fptr += ofs; - if (ofs % SS(fs)) { - nsect = clust2sect(fs, clst); /* Current sector */ - if (!nsect) ABORT(fs, FR_INT_ERR); - nsect += (DWORD)(ofs / SS(fs)); - } - } - } - if (!_FS_READONLY && fp->fptr > fp->obj.objsize) { /* Set file change flag if the file size is extended */ - fp->obj.objsize = fp->fptr; - fp->flag |= FA_MODIFIED; - } - if (fp->fptr % SS(fs) && nsect != fp->sect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif - if (disk_read(fs->drv, fp->buf, nsect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */ -#endif - fp->sect = nsect; - } - } - - LEAVE_FF(fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - FATFS *fs, - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - _FDID *obj; - DEF_NAMBUF - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive */ - obj = &dp->obj; - res = find_volume(fs, 0); - if (res == FR_OK) { - obj->fs = fs; - INIT_NAMBUF(fs); - res = follow_path(dp, path); /* Follow the path to the directory */ - if (res == FR_OK) { /* Follow completed */ - if (!(dp->fn[NSFLAG] & NS_NONAME)) { /* It is not the origin directory itself */ - if (obj->attr & AM_DIR) { /* This object is a sub-directory */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - obj->c_scl = obj->sclust; /* Save containing directory inforamation */ - obj->c_size = ((DWORD)obj->objsize & 0xFFFFFF00) | obj->stat; - obj->c_ofs = dp->blk_ofs; - obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Get object location and status */ - obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); - obj->stat = fs->dirbuf[XDIR_GenFlags] & 2; - } else -#endif - { - obj->sclust = ld_clust(fs, dp->dir); /* Get object location */ - } - } else { /* This object is a file */ - res = FR_NO_PATH; - } - } - if (res == FR_OK) { - obj->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK != 0 - if (res == FR_OK) { - if (obj->sclust) { - obj->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!obj->lockid) res = FR_TOO_MANY_OPEN_FILES; - } else { - obj->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - FREE_NAMBUF(); - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) obj->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - FATFS *fs; - - - res = validate(&dp->obj, &fs); /* Check validity of the file object */ - if (res == FR_OK) { -#if _FS_LOCK != 0 - if (dp->obj.lockid) { /* Decrement sub-directory open counter */ - res = dec_lock(dp->obj.lockid); - } - if (res == FR_OK) -#endif - { - dp->obj.fs = 0; /* Invalidate directory object */ - } -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - FATFS *fs; - DEF_NAMBUF - - - res = validate(&dp->obj, &fs); /* Check validity of the directory object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_NAMBUF(fs); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) res = FR_OK; /* Ignore end of directory */ - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) res = FR_OK; /* Ignore end of directory now */ - } - FREE_NAMBUF(); - } - } - LEAVE_FF(fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find Next File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for the file name */ -#if _USE_LFN != 0 && _USE_FIND == 2 - if (pattern_matching(dp->pat, fno->altname, 0, 0)) break; /* Test for alternative name if exist */ -#endif - } - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Find First File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) { - res = f_findnext(dp, fno); /* Find the first item */ - } - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - FATFS *fs, - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEF_NAMBUF - - - /* Get logical drive */ - res = find_volume(fs, 0); - dj.obj.fs = fs; - if (res == FR_OK) { - INIT_NAMBUF(dj.obj.fs); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.fn[NSFLAG] & NS_NONAME) { /* It is origin directory */ - res = FR_INVALID_NAME; - } else { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } - } - FREE_NAMBUF(); - } - - LEAVE_FF(dj.obj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - FATFS *fs, - DWORD* nclst /* Pointer to a variable to return number of free clusters */ -) -{ - FRESULT res; - DWORD nfree, clst, sect, stat; - UINT i; - BYTE *p; - _FDID obj; - - - /* Get logical drive */ - res = find_volume(fs, 0); - if (res == FR_OK) { - /* If free_clst is valid, return it without full cluster scan */ - if (fs->free_clst <= fs->n_fatent - 2) { - *nclst = fs->free_clst; - } else { - /* Get number of free clusters */ - nfree = 0; - if (fs->fs_type == FS_FAT12) { /* FAT12: Sector unalighed FAT entries */ - clst = 2; obj.fs = fs; - do { - stat = get_fat(&obj, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) nfree++; - } while (++clst < fs->n_fatent); - } else { -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* exFAT: Scan bitmap table */ - BYTE bm; - UINT b; - - clst = fs->n_fatent - 2; - sect = fs->database; - i = 0; - do { - if (i == 0 && (res = move_window(fs, sect++)) != FR_OK) break; - for (b = 8, bm = fs->win[i]; b && clst; b--, clst--) { - if (!(bm & 1)) nfree++; - bm >>= 1; - } - i = (i + 1) % SS(fs); - } while (clst); - } else -#endif - { /* FAT16/32: Sector alighed FAT entries */ - clst = fs->n_fatent; sect = fs->fatbase; - i = 0; p = 0; - do { - if (i == 0) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fs->fs_type == FS_FAT16) { - if (ld_word(p) == 0) nfree++; - p += 2; i -= 2; - } else { - if ((ld_dword(p) & 0x0FFFFFFF) == 0) nfree++; - p += 4; i -= 4; - } - } while (--clst); - } - } - *nclst = nfree; /* Return the free clusters */ - fs->free_clst = nfree; /* Now free_clst is valid */ - fs->fsi_flag |= 1; /* FSInfo is to be updated */ - } - } - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD ncl; - - - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); - if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ - - if (fp->obj.objsize > fp->fptr) { - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(&fp->obj, fp->obj.sclust, 0); - fp->obj.sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(&fp->obj, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fs->n_fatent) { - res = remove_chain(&fp->obj, ncl, fp->clust); - } - } - fp->obj.objsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA_MODIFIED; -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA_DIRTY)) { - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fp->flag &= (BYTE)~FA_DIRTY; - } - } -#endif - if (res != FR_OK) ABORT(fs, res); - } - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - FATFS *fs, - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - DWORD dclst = 0; -#if _FS_EXFAT - _FDID obj; -#endif - DEF_NAMBUF - - - /* Get logical drive */ - res = find_volume(fs, FA_WRITE); - dj.obj.fs = fs; - if (res == FR_OK) { - INIT_NAMBUF(fs); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) { - res = FR_INVALID_NAME; /* Cannot remove dot entry */ - } -#if _FS_LOCK != 0 - if (res == FR_OK) res = chk_lock(&dj, 2); /* Check if it is an open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - if (dj.fn[NSFLAG] & NS_NONAME) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dj.obj.attr & AM_RDO) { - res = FR_DENIED; /* Cannot remove R/O object */ - } - } - if (res == FR_OK) { -#if _FS_EXFAT - obj.fs = fs; - if (fs->fs_type == FS_EXFAT) { - obj.sclust = dclst = ld_dword(fs->dirbuf + XDIR_FstClus); - obj.objsize = ld_qword(fs->dirbuf + XDIR_FileSize); - obj.stat = fs->dirbuf[XDIR_GenFlags] & 2; - } else -#endif - { - dclst = ld_clust(fs, dj.dir); - } - if (dj.obj.attr & AM_DIR) { /* Is it a sub-directory ? */ -#if _FS_RPATH != 0 - if (dclst == fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - sdj.obj.fs = fs; /* Open the sub-directory */ - sdj.obj.sclust = dclst; -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - sdj.obj.objsize = obj.objsize; - sdj.obj.stat = obj.stat; - } -#endif - res = dir_sdi(&sdj, 0); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) { /* Remove the cluster chain if exist */ -#if _FS_EXFAT - res = remove_chain(&obj, dclst, 0); -#else - res = remove_chain(&dj.obj, dclst, 0); -#endif - } - if (res == FR_OK) res = sync_fs(fs); - } - } - FREE_NAMBUF(); - } - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - FATFS *fs, - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - UINT n; - DWORD dsc, dcl, pcl, tm; - DEF_NAMBUF - - - /* Get logical drive */ - res = find_volume(fs, FA_WRITE); - dj.obj.fs = fs; - if (res == FR_OK) { - INIT_NAMBUF(fs); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) { - res = FR_INVALID_NAME; - } - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(&dj.obj, 0); /* Allocate a cluster for the new directory table */ - dj.obj.objsize = (DWORD)fs->csize * SS(fs); - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) res = sync_window(fs); /* Flush FAT */ - tm = GET_FATTIME(); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(fs, dcl); - dir = fs->win; - mem_set(dir, 0, SS(fs)); - if (!_FS_EXFAT || fs->fs_type != FS_EXFAT) { - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - st_dword(dir + DIR_ModTime, tm); - st_clust(fs, dir, dcl); - mem_cpy(dir + SZDIRE, dir, SZDIRE); /* Create ".." entry */ - dir[SZDIRE + 1] = '.'; pcl = dj.obj.sclust; - if (fs->fs_type == FS_FAT32 && pcl == fs->dirbase) pcl = 0; - st_clust(fs, dir + SZDIRE, pcl); - } - for (n = fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - fs->winsect = dsc++; - fs->wflag = 1; - res = sync_window(fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res == FR_OK) { -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* Initialize directory entry block */ - st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Created time */ - st_dword(fs->dirbuf + XDIR_FstClus, dcl); /* Table start cluster */ - st_dword(fs->dirbuf + XDIR_FileSize, (DWORD)dj.obj.objsize); /* File size needs to be valid */ - st_dword(fs->dirbuf + XDIR_ValidFileSize, (DWORD)dj.obj.objsize); - fs->dirbuf[XDIR_GenFlags] = 3; /* Initialize the object flag (contiguous) */ - fs->dirbuf[XDIR_Attr] = AM_DIR; /* Attribute */ - res = store_xdir(&dj); - } else -#endif - { - dir = dj.dir; - st_dword(dir + DIR_ModTime, tm); /* Created time */ - st_clust(fs, dir, dcl); /* Table start cluster */ - dir[DIR_Attr] = AM_DIR; /* Attribute */ - fs->wflag = 1; - } - if (res == FR_OK) res = sync_fs(fs); - } else { - remove_chain(&dj.obj, dcl, 0); /* Could not register, remove cluster chain */ - } - } - FREE_NAMBUF(); - } - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename a File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - FATFS *fs, - const TCHAR* path_old, /* Pointer to the object name to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[_FS_EXFAT ? SZDIRE * 2 : 24], *dir; - DWORD dw; - DEF_NAMBUF - - - res = find_volume(fs, FA_WRITE); - if (res == FR_OK) { - djo.obj.fs = fs; - INIT_NAMBUF(fs); - res = follow_path(&djo, path_old); /* Check old object */ - if (res == FR_OK && (djo.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME; /* Check validity of name */ -#if _FS_LOCK != 0 - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Object to be renamed is found */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* At exFAT */ - BYTE nf, nn; - WORD nh; - - mem_cpy(buf, fs->dirbuf, SZDIRE * 2); /* Save 85+C0 entry of old object */ - mem_cpy(&djn, &djo, sizeof djo); - res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */ - if (res == FR_OK) { /* Is new name already in use by any other object? */ - res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST; - } - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { - nf = fs->dirbuf[XDIR_NumSec]; nn = fs->dirbuf[XDIR_NumName]; - nh = ld_word(fs->dirbuf + XDIR_NameHash); - mem_cpy(fs->dirbuf, buf, SZDIRE * 2); - fs->dirbuf[XDIR_NumSec] = nf; fs->dirbuf[XDIR_NumName] = nn; - st_word(fs->dirbuf + XDIR_NameHash, nh); -/* Start of critical section where any interruption can cause a cross-link */ - res = store_xdir(&djn); - } - } - } else -#endif - { /* At FAT12/FAT16/FAT32 */ - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about the object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */ - if (res == FR_OK) { /* Is new name already in use by any other object? */ - res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST; - } - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.obj.sclust != djn.obj.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(fs, ld_clust(fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { -/* Start of critical section where any interruption can cause a cross-link */ - res = move_window(fs, dw); - dir = fs->win + SZDIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(fs, dir, djn.obj.sclust); - fs->wflag = 1; - } - } - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) { - res = sync_fs(fs); - } - } -/* End of critical section */ - } - FREE_NAMBUF(); - } - - LEAVE_FF(fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - -#if _USE_CHMOD && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - FATFS *fs, - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - DEF_NAMBUF - - - res = find_volume(fs, FA_WRITE); /* Get logical drive */ - dj.obj.fs = fs; - if (res == FR_OK) { - INIT_NAMBUF(fs); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK && (dj.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME; /* Check object validity */ - if (res == FR_OK) { - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - fs->dirbuf[XDIR_Attr] = (attr & mask) | (fs->dirbuf[XDIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - res = store_xdir(&dj); - } else -#endif - { - dj.dir[DIR_Attr] = (attr & mask) | (dj.dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - fs->wflag = 1; - } - if (res == FR_OK) res = sync_fs(fs); - } - FREE_NAMBUF(); - } - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - FATFS *fs, - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - DEF_NAMBUF - - - res = find_volume(fs, FA_WRITE); /* Get logical drive */ - dj.obj.fs = fs; - if (res == FR_OK) { - INIT_NAMBUF(fs); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK && (dj.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME; /* Check object validity */ - if (res == FR_OK) { -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - st_dword(fs->dirbuf + XDIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime); - res = store_xdir(&dj); - } else -#endif - { - st_dword(dj.dir + DIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime); - fs->wflag = 1; - } - if (res == FR_OK) res = sync_fs(fs); - } - FREE_NAMBUF(); - } - - LEAVE_FF(fs, res); -} - -#endif /* _USE_CHMOD && !_FS_READONLY */ - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get Volume Label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - FATFS *fs, - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT si, di; -#if _LFN_UNICODE || _FS_EXFAT - WCHAR w; -#endif - - /* Get logical drive */ - res = find_volume(fs, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Find a volume label entry */ - if (res == FR_OK) { -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - for (si = di = 0; si < dj.dir[XDIR_NumLabel]; si++) { /* Extract volume label from 83 entry */ - w = ld_word(dj.dir + XDIR_Label + si * 2); -#if _LFN_UNICODE - label[di++] = w; -#else - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (w == 0) w = '?'; /* Replace wrong character */ - if (_DF1S && w >= 0x100) label[di++] = (char)(w >> 8); - label[di++] = (char)w; -#endif - } - label[di] = 0; - } else -#endif - { - si = di = 0; /* Extract volume label from AM_VOL entry with code comversion */ - do { -#if _LFN_UNICODE - w = (si < 11) ? dj.dir[si++] : ' '; - if (IsDBCS1(w) && si < 11 && IsDBCS2(dj.dir[si])) { - w = w << 8 | dj.dir[si++]; - } - label[di++] = ff_convert(w, 1); /* OEM -> Unicode */ -#else - label[di++] = dj.dir[si++]; -#endif - } while (di < 11); - do { /* Truncate trailing spaces */ - label[di] = 0; - if (di == 0) break; - } while (label[--di] == ' '); - } - } - } - if (res == FR_NO_FILE) { /* No label entry and return nul string */ - label[0] = 0; - res = FR_OK; - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(fs, fs->volbase); - if (res == FR_OK) { - switch (fs->fs_type) { - case FS_EXFAT: di = BPB_VolIDEx; break; - case FS_FAT32: di = BS_VolID32; break; - default: di = BS_VolID; - } - *vsn = ld_dword(fs->win + di); - } - } - - LEAVE_FF(fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set Volume Label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - FATFS *fs, - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE dirvn[22]; - UINT i, j, slen; - WCHAR w; - static const char badchr[] = "\"*+,.:;<=>\?[]|\x7F"; - - - /* Get logical drive */ - res = find_volume(fs, FA_WRITE); - if (res != FR_OK) LEAVE_FF(fs, res); - dj.obj.fs = fs; - - /* Get length of given volume label */ - for (slen = 0; (UINT)label[slen] >= ' '; slen++) { } /* Get name length */ - -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */ - for (i = j = 0; i < slen; ) { /* Create volume label in directory form */ - w = label[i++]; -#if !_LFN_UNICODE - if (IsDBCS1(w)) { - w = (i < slen && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; - } - w = ff_convert(w, 1); -#endif - if (w == 0 || chk_chr(badchr, w) || j == 22) { /* Check validity check validity of the volume label */ - LEAVE_FF(fs, FR_INVALID_NAME); - } - st_word(dirvn + j, w); j += 2; - } - slen = j; - } else -#endif - { /* On the FAT12/16/32 volume */ - for ( ; slen && label[slen - 1] == ' '; slen--) ; /* Remove trailing spaces */ - if (slen) { /* Is there a volume label to be set? */ - dirvn[0] = 0; i = j = 0; /* Create volume label in directory form */ - do { -#if _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) { - w = (j < 10 && i < slen && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; - } -#if _USE_LFN != 0 - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (w == 0 || chk_chr(badchr, w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) { /* Reject invalid characters for volume label */ - LEAVE_FF(fs, FR_INVALID_NAME); - } - if (w >= 0x100) dirvn[j++] = (BYTE)(w >> 8); - dirvn[j++] = (BYTE)w; - } while (i < slen); - while (j < 11) dirvn[j++] = ' '; /* Fill remaining name field */ - if (dirvn[0] == DDEM) LEAVE_FF(fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - } - - /* Set volume label */ - dj.obj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get volume label entry */ - if (res == FR_OK) { - if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { - dj.dir[XDIR_NumLabel] = (BYTE)(slen / 2); /* Change the volume label */ - mem_cpy(dj.dir + XDIR_Label, dirvn, slen); - } else { - if (slen) { - mem_cpy(dj.dir, dirvn, 11); /* Change the volume label */ - } else { - dj.dir[DIR_Name] = DDEM; /* Remove the volume label */ - } - } - fs->wflag = 1; - res = sync_fs(fs); - } else { /* No volume label entry is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (slen) { /* Create a volume label entry */ - res = dir_alloc(&dj, 1); /* Allocate an entry */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZDIRE); /* Clear the entry */ - if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { - dj.dir[XDIR_Type] = 0x83; /* Create 83 entry */ - dj.dir[XDIR_NumLabel] = (BYTE)(slen / 2); - mem_cpy(dj.dir + XDIR_Label, dirvn, slen); - } else { - dj.dir[DIR_Attr] = AM_VOL; /* Create volume label entry */ - mem_cpy(dj.dir, dirvn, 11); - } - fs->wflag = 1; - res = sync_fs(fs); - } - } - } - } - } - - LEAVE_FF(fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -#if _USE_EXPAND && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Allocate a Contiguous Blocks to the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_expand ( - FIL* fp, /* Pointer to the file object */ - FSIZE_t fsz, /* File size to be expanded to */ - BYTE opt /* Operation mode 0:Find and prepare or 1:Find and allocate */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, stcl, scl, ncl, tcl, lclst; - - - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); - if (fsz == 0 || fp->obj.objsize != 0 || !(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); -#if _FS_EXFAT - if (fs->fs_type != FS_EXFAT && fsz >= 0x100000000) LEAVE_FF(fs, FR_DENIED); /* Check if in size limit */ -#endif - n = (DWORD)fs->csize * SS(fs); /* Cluster size */ - tcl = (DWORD)(fsz / n) + ((fsz & (n - 1)) ? 1 : 0); /* Number of clusters required */ - stcl = fs->last_clst; lclst = 0; - if (stcl < 2 || stcl >= fs->n_fatent) stcl = 2; - -#if _FS_EXFAT - if (fs->fs_type == FS_EXFAT) { - scl = find_bitmap(fs, stcl, tcl); /* Find a contiguous cluster block */ - if (scl == 0) res = FR_DENIED; /* No contiguous cluster block was found */ - if (scl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) { - if (opt) { - res = change_bitmap(fs, scl, tcl, 1); /* Mark the cluster block 'in use' */ - lclst = scl + tcl - 1; - } else { - lclst = scl - 1; - } - } - } else -#endif - { - scl = clst = stcl; ncl = 0; - for (;;) { /* Find a contiguous cluster block */ - n = get_fat(&fp->obj, clst); - if (++clst >= fs->n_fatent) clst = 2; - if (n == 1) { res = FR_INT_ERR; break; } - if (n == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (n == 0) { /* Is it a free cluster? */ - if (++ncl == tcl) break; /* Break if a contiguous cluster block is found */ - } else { - scl = clst; ncl = 0; /* Not a free cluster */ - } - if (clst == stcl) { res = FR_DENIED; break; } /* No contiguous cluster? */ - } - if (res == FR_OK) { - if (opt) { - for (clst = scl, n = tcl; n; clst++, n--) { /* Create a cluster chain on the FAT */ - res = put_fat(fs, clst, (n == 1) ? 0xFFFFFFFF : clst + 1); - if (res != FR_OK) break; - lclst = clst; - } - } else { - lclst = scl - 1; - } - } - } - - if (res == FR_OK) { - fs->last_clst = lclst; /* Set suggested start cluster to start next */ - if (opt) { - fp->obj.sclust = scl; /* Update object allocation information */ - fp->obj.objsize = fsz; - if (_FS_EXFAT) fp->obj.stat = 2; /* Set status 'contiguous chain' */ - fp->flag |= FA_MODIFIED; - if (fs->free_clst < fs->n_fatent - 2) { /* Update FSINFO */ - fs->free_clst -= tcl; - fs->fsi_flag |= 1; - } - } - } - - LEAVE_FF(fs, res); -} - -#endif /* _USE_EXPAND && !_FS_READONLY */ - - - -#if _USE_FORWARD -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - FATFS *fs; - DWORD clst, sect; - FSIZE_t remain; - UINT rcnt, csect; - BYTE *dbuf; - - - *bf = 0; /* Clear transfer byte counter */ - res = validate(&fp->obj, &fs); /* Check validity of the file object */ - if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); - if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */ - - remain = fp->obj.objsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream goes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (UINT)(fp->fptr / SS(fs) & (fs->csize - 1)); /* Sector offset in the cluster */ - if (fp->fptr % SS(fs) == 0) { /* On the sector boundary? */ - if (csect == 0) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->obj.sclust : get_fat(&fp->obj, fp->clust); - if (clst <= 1) ABORT(fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fs, FR_INT_ERR); - sect += csect; -#if _FS_TINY - if (move_window(fs, sect) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Move sector window to the file data */ - dbuf = fs->win; -#else - if (fp->sect != sect) { /* Fill sector cache with file data */ -#if !_FS_READONLY - if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); - fp->flag &= (BYTE)~FA_DIRTY; - } -#endif - if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); - } - dbuf = fp->buf; -#endif - fp->sect = sect; - rcnt = SS(fs) - (UINT)fp->fptr % SS(fs); /* Number of bytes left in the sector */ - if (rcnt > btf) rcnt = btf; /* Clip it by btr if needed */ - rcnt = (*func)(dbuf + ((UINT)fp->fptr % SS(fs)), rcnt); /* Forward the file data */ - if (!rcnt) ABORT(fs, FR_INT_ERR); - } - - LEAVE_FF(fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create FAT file system on the logical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkfs ( - FATFS *fs, - BYTE opt, /* Format option */ - DWORD au, /* Size of allocation unit [byte] */ - void* work, /* Pointer to working buffer */ - UINT len /* Size of working buffer */ -) -{ - const UINT n_fats = 1; /* Number of FATs for FAT12/16/32 volume (1 or 2) */ - const UINT n_rootdir = 512; /* Number of root directory entries for FAT12/16 volume */ - static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT12/16 volume (4Ks unit) */ - static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */ - BYTE fmt, sys, *buf, *pte, part; void *pdrv; - WORD ss; - DWORD szb_buf, sz_buf, sz_blk, n_clst, pau, sect, nsect, n; - DWORD b_vol, b_fat, b_data; /* Base LBA for volume, fat, data */ - DWORD sz_vol, sz_rsv, sz_fat, sz_dir; /* Size for volume, fat, dir, data */ - UINT i; - DSTATUS stat; -#if _USE_TRIM || _FS_EXFAT - DWORD tbl[3]; -#endif - - - /* Check mounted drive and clear work area */ - fs->fs_type = 0; /* Clear mounted volume */ - pdrv = fs->drv; /* Physical drive */ - part = LD2PT(fs); /* Partition (0:create as new, 1-4:get from partition table) */ - - /* Check physical drive status */ - disk_ioctl(pdrv, IOCTL_INIT, &stat); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_blk) != RES_OK || !sz_blk || sz_blk > 32768 || (sz_blk & (sz_blk - 1))) sz_blk = 1; /* Erase block to align data area */ -#if _MAX_SS != _MIN_SS /* Get sector size of the medium */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) return FR_DISK_ERR; - if (ss > _MAX_SS || ss < _MIN_SS || (ss & (ss - 1))) return FR_DISK_ERR; -#else - ss = _MAX_SS; -#endif - if ((au != 0 && au < ss) || au > 0x1000000 || (au & (au - 1))) return FR_INVALID_PARAMETER; /* Check if au is valid */ - au /= ss; /* Cluster size in unit of sector */ - - /* Get working buffer */ - buf = (BYTE*)work; /* Working buffer */ - sz_buf = len / ss; /* Size of working buffer (sector) */ - szb_buf = sz_buf * ss; /* Size of working buffer (byte) */ - if (!szb_buf) return FR_MKFS_ABORTED; - - /* Determine where the volume to be located (b_vol, sz_vol) */ - if (_MULTI_PARTITION && part != 0) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */ - if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if MBR is valid */ - pte = buf + (MBR_Table + (part - 1) * SZ_PTE); - if (!pte[PTE_System]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = ld_dword(pte + PTE_StLba); /* Get volume start sector */ - sz_vol = ld_dword(pte + PTE_SizLba); /* Get volume size */ - } else { - /* Create a single-partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_vol) != RES_OK) return FR_DISK_ERR; - b_vol = (opt & FM_SFD) ? 0 : 63; /* Volume start sector */ - if (sz_vol < b_vol) return FR_MKFS_ABORTED; - sz_vol -= b_vol; /* Volume size */ - } - if (sz_vol < 50) return FR_MKFS_ABORTED; /* Check if volume size is >=50s */ - - /* Pre-determine the FAT type */ - do { - if (_FS_EXFAT && (opt & FM_EXFAT)) { /* exFAT possible? */ - if ((opt & FM_ANY) == FM_EXFAT || sz_vol >= 0x4000000 || au > 128) { /* exFAT only, vol >= 64Ms or au > 128s ? */ - fmt = FS_EXFAT; break; - } - } - if (au > 128) return FR_INVALID_PARAMETER; /* Too large au for FAT/FAT32 */ - if (opt & FM_FAT32) { /* FAT32 possible? */ - if ((opt & FM_ANY) == FM_FAT32 || !(opt & FM_FAT)) { /* FAT32 only or no-FAT? */ - fmt = FS_FAT32; break; - } - } - if (!(opt & FM_FAT)) return FR_INVALID_PARAMETER; /* no-FAT? */ - fmt = FS_FAT16; - } while (0); - -#if _FS_EXFAT - if (fmt == FS_EXFAT) { /* Create an exFAT volume */ - DWORD szb_bit, szb_case, sum, nb, cl; - WCHAR ch, si; - UINT j, st; - BYTE b; - - if (sz_vol < 0x1000) return FR_MKFS_ABORTED; /* Too small volume? */ -#if _USE_TRIM - tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1; /* Inform the device the volume area can be erased */ - disk_ioctl(pdrv, CTRL_TRIM, tbl); -#endif - /* Determine FAT location, data location and number of clusters */ - if (!au) { /* au auto-selection */ - au = 8; - if (sz_vol >= 0x80000) au = 64; /* >= 512Ks */ - if (sz_vol >= 0x4000000) au = 256; /* >= 64Ms */ - } - b_fat = b_vol + 32; /* FAT start at offset 32 */ - sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss; /* Number of FAT sectors */ - b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1); /* Align data area to the erase block boundary */ - if (b_data >= sz_vol / 2) return FR_MKFS_ABORTED; /* Too small volume? */ - n_clst = (sz_vol - (b_data - b_vol)) / au; /* Number of clusters */ - if (n_clst <16) return FR_MKFS_ABORTED; /* Too few clusters? */ - if (n_clst > MAX_EXFAT) return FR_MKFS_ABORTED; /* Too many clusters? */ - - szb_bit = (n_clst + 7) / 8; /* Size of allocation bitmap */ - tbl[0] = (szb_bit + au * ss - 1) / (au * ss); /* Number of allocation bitmap clusters */ - - /* Create a compressed up-case table */ - sect = b_data + au * tbl[0]; /* Table start sector */ - sum = 0; /* Table checksum to be stored in the 82 entry */ - st = si = i = j = szb_case = 0; - do { - switch (st) { - case 0: - ch = ff_wtoupper(si); /* Get an up-case char */ - if (ch != si) { - si++; break; /* Store the up-case char if exist */ - } - for (j = 1; (WCHAR)(si + j) && (WCHAR)(si + j) == ff_wtoupper((WCHAR)(si + j)); j++) ; /* Get run length of no-case block */ - if (j >= 128) { - ch = 0xFFFF; st = 2; break; /* Compress the no-case block if run is >= 128 */ - } - st = 1; /* Do not compress short run */ - /* continue */ - case 1: - ch = si++; /* Fill the short run */ - if (--j == 0) st = 0; - break; - default: - ch = (WCHAR)j; si += j; /* Number of chars to skip */ - st = 0; - } - sum = xsum32(buf[i + 0] = (BYTE)ch, sum); /* Put it into the write buffer */ - sum = xsum32(buf[i + 1] = (BYTE)(ch >> 8), sum); - i += 2; szb_case += 2; - if (!si || i == szb_buf) { /* Write buffered data when buffer full or end of process */ - n = (i + ss - 1) / ss; - if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; - sect += n; i = 0; - } - } while (si); - tbl[1] = (szb_case + au * ss - 1) / (au * ss); /* Number of up-case table clusters */ - tbl[2] = 1; /* Number of root dir clusters */ - - /* Initialize the allocation bitmap */ - sect = b_data; nsect = (szb_bit + ss - 1) / ss; /* Start of bitmap and number of sectors */ - nb = tbl[0] + tbl[1] + tbl[2]; /* Number of clusters in-use by system */ - do { - mem_set(buf, 0, szb_buf); - for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ; - for (b = 1; nb && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ; - n = (nsect > sz_buf) ? sz_buf : nsect; /* Write the buffered data */ - if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; - sect += n; nsect -= n; - } while (nsect); - - /* Initialize the FAT */ - sect = b_fat; nsect = sz_fat; /* Start of FAT and number of FAT sectors */ - j = nb = cl = 0; - do { - mem_set(buf, 0, szb_buf); i = 0; /* Clear work area and reset write index */ - if (cl == 0) { /* Set entry 0 and 1 */ - st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++; - st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++; - } - do { /* Create chains of bitmap, up-case and root dir */ - while (nb && i < szb_buf) { /* Create a chain */ - st_dword(buf + i, (nb > 1) ? cl + 1 : 0xFFFFFFFF); - i += 4; cl++; nb--; - } - if (!nb && j < 3) nb = tbl[j++]; /* Next chain */ - } while (nb && i < szb_buf); - n = (nsect > sz_buf) ? sz_buf : nsect; /* Write the buffered data */ - if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; - sect += n; nsect -= n; - } while (nsect); - - /* Initialize the root directory */ - mem_set(buf, 0, szb_buf); - buf[SZDIRE * 0 + 0] = 0x83; /* 83 entry (volume label) */ - buf[SZDIRE * 1 + 0] = 0x81; /* 81 entry (allocation bitmap) */ - st_dword(buf + SZDIRE * 1 + 20, 2); - st_dword(buf + SZDIRE * 1 + 24, szb_bit); - buf[SZDIRE * 2 + 0] = 0x82; /* 82 entry (up-case table) */ - st_dword(buf + SZDIRE * 2 + 4, sum); - st_dword(buf + SZDIRE * 2 + 20, 2 + tbl[0]); - st_dword(buf + SZDIRE * 2 + 24, szb_case); - sect = b_data + au * (tbl[0] + tbl[1]); nsect = au; /* Start of the root directory and number of sectors */ - do { /* Fill root directory sectors */ - n = (nsect > sz_buf) ? sz_buf : nsect; - if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR; - mem_set(buf, 0, ss); - sect += n; nsect -= n; - } while (nsect); - - /* Create two set of the exFAT VBR blocks */ - sect = b_vol; - for (n = 0; n < 2; n++) { - /* Main record (+0) */ - mem_set(buf, 0, ss); - mem_cpy(buf + BS_JmpBoot, "\xEB\x76\x90" "EXFAT ", 11); /* Boot jump code (x86), OEM name */ - st_dword(buf + BPB_VolOfsEx, b_vol); /* Volume offset in the physical drive [sector] */ - st_dword(buf + BPB_TotSecEx, sz_vol); /* Volume size [sector] */ - st_dword(buf + BPB_FatOfsEx, b_fat - b_vol); /* FAT offset [sector] */ - st_dword(buf + BPB_FatSzEx, sz_fat); /* FAT size [sector] */ - st_dword(buf + BPB_DataOfsEx, b_data - b_vol); /* Data offset [sector] */ - st_dword(buf + BPB_NumClusEx, n_clst); /* Number of clusters */ - st_dword(buf + BPB_RootClusEx, 2 + tbl[0] + tbl[1]); /* Root dir cluster # */ - st_dword(buf + BPB_VolIDEx, GET_FATTIME()); /* VSN */ - st_word(buf + BPB_FSVerEx, 0x100); /* File system version (1.00) */ - for (buf[BPB_BytsPerSecEx] = 0, i = ss; i >>= 1; buf[BPB_BytsPerSecEx]++) ; /* Log2 of sector size [byte] */ - for (buf[BPB_SecPerClusEx] = 0, i = au; i >>= 1; buf[BPB_SecPerClusEx]++) ; /* Log2 of cluster size [sector] */ - buf[BPB_NumFATsEx] = 1; /* Number of FATs */ - buf[BPB_DrvNumEx] = 0x80; /* Drive number (for int13) */ - st_word(buf + BS_BootCodeEx, 0xFEEB); /* Boot code (x86) */ - st_word(buf + BS_55AA, 0xAA55); /* Signature (placed here regardless of sector size) */ - for (i = sum = 0; i < ss; i++) { /* VBR checksum */ - if (i != BPB_VolFlagEx && i != BPB_VolFlagEx + 1 && i != BPB_PercInUseEx) sum = xsum32(buf[i], sum); - } - if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; - /* Extended bootstrap record (+1..+8) */ - mem_set(buf, 0, ss); - st_word(buf + ss - 2, 0xAA55); /* Signature (placed at end of sector) */ - for (j = 1; j < 9; j++) { - for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ; /* VBR checksum */ - if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; - } - /* OEM/Reserved record (+9..+10) */ - mem_set(buf, 0, ss); - for ( ; j < 11; j++) { - for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ; /* VBR checksum */ - if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; - } - /* Sum record (+11) */ - for (i = 0; i < ss; i += 4) st_dword(buf + i, sum); /* Fill with checksum value */ - if (disk_write(pdrv, buf, sect++, 1) != RES_OK) return FR_DISK_ERR; - } - - } else -#endif /* _FS_EXFAT */ - { /* Create an FAT12/16/32 volume */ - do { - pau = au; - /* Pre-determine number of clusters and FAT sub-type */ - if (fmt == FS_FAT32) { /* FAT32 volume */ - if (!pau) { /* au auto-selection */ - n = sz_vol / 0x20000; /* Volume size in unit of 128KS */ - for (i = 0, pau = 1; cst32[i] && cst32[i] <= n; i++, pau <<= 1) ; /* Get from table */ - } - n_clst = sz_vol / pau; /* Number of clusters */ - sz_fat = (n_clst * 4 + 8 + ss - 1) / ss; /* FAT size [sector] */ - sz_rsv = 32; /* Number of reserved sectors */ - sz_dir = 0; /* No static directory */ - if (n_clst <= MAX_FAT16 || n_clst > MAX_FAT32) return FR_MKFS_ABORTED; - } else { /* FAT12/16 volume */ - if (!pau) { /* au auto-selection */ - n = sz_vol / 0x1000; /* Volume size in unit of 4KS */ - for (i = 0, pau = 1; cst[i] && cst[i] <= n; i++, pau <<= 1) ; /* Get from table */ - } - n_clst = sz_vol / pau; - if (n_clst > MAX_FAT12) { - n = n_clst * 2 + 4; /* FAT size [byte] */ - } else { - fmt = FS_FAT12; - n = (n_clst * 3 + 1) / 2 + 3; /* FAT size [byte] */ - } - sz_fat = (n + ss - 1) / ss; /* FAT size [sector] */ - sz_rsv = 1; /* Number of reserved sectors */ - sz_dir = (DWORD)n_rootdir * SZDIRE / ss; /* Rootdir size [sector] */ - } - b_fat = b_vol + sz_rsv; /* FAT base */ - b_data = b_fat + sz_fat * n_fats + sz_dir; /* Data base */ - - /* Align data base to erase block boundary (for flash memory media) */ - n = ((b_data + sz_blk - 1) & ~(sz_blk - 1)) - b_data; /* Next nearest erase block from current data base */ - if (fmt == FS_FAT32) { /* FAT32: Move FAT base */ - sz_rsv += n; b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - sz_fat += n / n_fats; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - if (sz_vol < b_data + pau * 16 - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir) / pau; - if (fmt == FS_FAT32) { - if (n_clst <= MAX_FAT16) { /* Too few clusters for FAT32 */ - if (!au && (au = pau / 2) != 0) continue; /* Adjust cluster size and retry */ - return FR_MKFS_ABORTED; - } - } - if (fmt == FS_FAT16) { - if (n_clst > MAX_FAT16) { /* Too many clusters for FAT16 */ - if (!au && (pau * 2) <= 64) { - au = pau * 2; continue; /* Adjust cluster size and retry */ - } - if ((opt & FM_FAT32)) { - fmt = FS_FAT32; continue; /* Switch type to FAT32 and retry */ - } - if (!au && (au = pau * 2) <= 128) continue; /* Adjust cluster size and retry */ - return FR_MKFS_ABORTED; - } - if (n_clst <= MAX_FAT12) { /* Too few clusters for FAT16 */ - if (!au && (au = pau * 2) <= 128) continue; /* Adjust cluster size and retry */ - return FR_MKFS_ABORTED; - } - } - if (fmt == FS_FAT12 && n_clst > MAX_FAT12) return FR_MKFS_ABORTED; /* Too many clusters for FAT12 */ - - /* Ok, it is the valid cluster configuration */ - break; - } while (1); - -#if _USE_TRIM - tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1; /* Inform the device the volume area can be erased */ - disk_ioctl(pdrv, CTRL_TRIM, tbl); -#endif - /* Create FAT VBR */ - mem_set(buf, 0, ss); - mem_cpy(buf + BS_JmpBoot, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code (x86), OEM name */ - st_word(buf + BPB_BytsPerSec, ss); /* Sector size [byte] */ - buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */ - st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */ - buf[BPB_NumFATs] = (BYTE)n_fats; /* Number of FATs */ - st_word(buf + BPB_RootEntCnt, (WORD)((fmt == FS_FAT32) ? 0 : n_rootdir)); /* Number of root directory entries */ - if (sz_vol < 0x10000) { - st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */ - } else { - st_dword(buf + BPB_TotSec32, sz_vol); /* Volume size in 32-bit LBA */ - } - buf[BPB_Media] = 0xF8; /* Media descriptor byte */ - st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */ - st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */ - st_dword(buf + BPB_HiddSec, b_vol); /* Volume offset in the physical drive [sector] */ - if (fmt == FS_FAT32) { - st_dword(buf + BS_VolID32, GET_FATTIME()); /* VSN */ - st_dword(buf + BPB_FATSz32, sz_fat); /* FAT size [sector] */ - st_dword(buf + BPB_RootClus32, 2); /* Root directory cluster # (2) */ - st_word(buf + BPB_FSInfo32, 1); /* Offset of FSINFO sector (VBR + 1) */ - st_word(buf + BPB_BkBootSec32, 6); /* Offset of backup VBR (VBR + 6) */ - buf[BS_DrvNum32] = 0x80; /* Drive number (for int13) */ - buf[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(buf + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - st_dword(buf + BS_VolID, GET_FATTIME()); /* VSN */ - st_word(buf + BPB_FATSz16, (WORD)sz_fat); /* FAT size [sector] */ - buf[BS_DrvNum] = 0x80; /* Drive number (for int13) */ - buf[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(buf + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - st_word(buf + BS_55AA, 0xAA55); /* Signature (offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, buf, b_vol, 1) != RES_OK) return FR_DISK_ERR; /* Write it to the VBR sector */ - - /* Create FSINFO record if needed */ - if (fmt == FS_FAT32) { - disk_write(pdrv, buf, b_vol + 6, 1); /* Write backup VBR (VBR + 6) */ - mem_set(buf, 0, ss); - st_dword(buf + FSI_LeadSig, 0x41615252); - st_dword(buf + FSI_StrucSig, 0x61417272); - st_dword(buf + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - st_dword(buf + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - st_word(buf + BS_55AA, 0xAA55); - disk_write(pdrv, buf, b_vol + 7, 1); /* Write backup FSINFO (VBR + 7) */ - disk_write(pdrv, buf, b_vol + 1, 1); /* Write original FSINFO (VBR + 1) */ - } - - /* Initialize FAT area */ - mem_set(buf, 0, (UINT)szb_buf); - sect = b_fat; /* FAT start sector */ - for (i = 0; i < n_fats; i++) { /* Initialize FATs each */ - if (fmt == FS_FAT32) { - st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */ - st_dword(buf + 4, 0xFFFFFFFF); /* Entry 1 */ - st_dword(buf + 8, 0x0FFFFFFF); /* Entry 2 (root directory) */ - } else { - st_dword(buf + 0, (fmt == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */ - } - nsect = sz_fat; /* Number of FAT sectors */ - do { /* Fill FAT sectors */ - n = (nsect > sz_buf) ? sz_buf : nsect; - if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR; - mem_set(buf, 0, ss); - sect += n; nsect -= n; - } while (nsect); - } - - /* Initialize root directory (fill with zero) */ - nsect = (fmt == FS_FAT32) ? pau : sz_dir; /* Number of root directory sectors */ - do { - n = (nsect > sz_buf) ? sz_buf : nsect; - if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR; - sect += n; nsect -= n; - } while (nsect); - } - - /* Determine system ID in the partition table */ - if (_FS_EXFAT && fmt == FS_EXFAT) { - sys = 0x07; /* HPFS/NTFS/exFAT */ - } else { - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (sz_vol >= 0x10000) { - sys = 0x06; /* FAT12/16 (>=64KS) */ - } else { - sys = (fmt == FS_FAT16) ? 0x04 : 0x01; /* FAT16 (<64KS) : FAT12 (<64KS) */ - } - } - } - - if (_MULTI_PARTITION && part != 0) { - /* Update system ID in the partition table */ - if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Read the MBR */ - buf[MBR_Table + (part - 1) * SZ_PTE + PTE_System] = sys; /* Set system type */ - if (disk_write(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Write it back to the MBR */ - } else { - if (!(opt & FM_SFD)) { - /* Create partition table in FDISK format */ - mem_set(buf, 0, ss); - st_word(buf + BS_55AA, 0xAA55); /* MBR signature */ - pte = buf + MBR_Table; /* Create partition table for single partition in the drive */ - pte[PTE_Boot] = 0; /* Boot indicator */ - pte[PTE_StHead] = 1; /* Start head */ - pte[PTE_StSec] = 1; /* Start sector */ - pte[PTE_StCyl] = 0; /* Start cylinder */ - pte[PTE_System] = sys; /* System type */ - n = (b_vol + sz_vol) / (63 * 255); /* (End CHS is incorrect) */ - pte[PTE_EdHead] = 254; /* End head */ - pte[PTE_EdSec] = (BYTE)(n >> 2 | 63); /* End sector */ - pte[PTE_EdCyl] = (BYTE)n; /* End cylinder */ - st_dword(pte + PTE_StLba, b_vol); /* Start offset in LBA */ - st_dword(pte + PTE_SizLba, sz_vol); /* Size in sectors */ - if (disk_write(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Write it to the MBR */ - } - } - - if (disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) return FR_DISK_ERR; - - return FR_OK; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - void *pdrv, /* Physical drive number */ - const DWORD* szt, /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - disk_ioctl(pdrv, IOCTL_INIT, &stat); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine the CHS without any care of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - st_dword(p + 8, s_part); /* Start sector in LBA */ - st_dword(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - st_word(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ diff --git a/user/mpy/lib/oofatfs/ff.h b/user/mpy/lib/oofatfs/ff.h deleted file mode 100644 index 068de11..0000000 --- a/user/mpy/lib/oofatfs/ff.h +++ /dev/null @@ -1,380 +0,0 @@ -/* This file is part of ooFatFs, a customised version of FatFs - * See https://github.com/micropython/oofatfs for details - */ - -/*----------------------------------------------------------------------------/ -/ FatFs - Generic FAT file system module R0.12b / -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2016, ChaN, all right reserved. -/ -/ FatFs module is an open source software. Redistribution and use of FatFs in -/ source and binary forms, with or without modification, are permitted provided -/ that the following condition is met: - -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 68020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* This type MUST be 8-bit */ -typedef uint8_t BYTE; - -/* These types MUST be 16-bit */ -typedef int16_t SHORT; -typedef uint16_t WORD; -typedef uint16_t WCHAR; - -/* These types MUST be 16-bit or 32-bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32-bit */ -typedef int32_t LONG; -typedef uint32_t DWORD; - -/* This type MUST be 64-bit (Remove this for C89 compatibility) */ -typedef uint64_t QWORD; - -#include FFCONF_H /* FatFs configuration options */ - -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -#define LD2PT(fs) (fs->part) /* Get partition index */ -#else /* Single partition configuration */ -#define LD2PT(fs) 0 /* Find first valid partition or in SFD */ -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode (UTF-16) string */ -#if _USE_LFN == 0 -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif -#endif - - - -/* Type of file size variables */ - -#if _FS_EXFAT -#if _USE_LFN == 0 -#error LFN must be enabled when enable exFAT -#endif -typedef QWORD FSIZE_t; -#else -typedef DWORD FSIZE_t; -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - void *drv; // block device underlying this filesystem -#if _MULTI_PARTITION /* Multiple partition configuration */ - BYTE part; // Partition: 0:Auto detect, 1-4:Forced partition -#endif - BYTE fs_type; /* File system type (0:N/A) */ - BYTE n_fats; /* Number of FATs (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ - WORD csize; /* Cluster size [sectors] */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */ -#endif -#if _USE_LFN != 0 - WCHAR* lfnbuf; /* LFN working buffer */ -#endif -#if _FS_EXFAT - BYTE* dirbuf; /* Directory entry block scratchpad buffer */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clst; /* Last allocated cluster */ - DWORD free_clst; /* Number of free clusters */ -#endif -#if _FS_RPATH != 0 - DWORD cdir; /* Current directory start cluster (0:root) */ -#if _FS_EXFAT - DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */ - DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */ - DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */ -#endif -#endif - DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */ - DWORD fsize; /* Size of an FAT [sectors] */ - DWORD volbase; /* Volume base sector */ - DWORD fatbase; /* FAT base sector */ - DWORD dirbase; /* Root directory base sector/cluster */ - DWORD database; /* Data base sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* Object ID and allocation information (_FDID) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object */ - WORD id; /* Owner file system mount ID */ - BYTE attr; /* Object attribute */ - BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous (no data on FAT), =3:got flagmented, b2:sub-directory stretched) */ - DWORD sclust; /* Object start cluster (0:no cluster or root directory) */ - FSIZE_t objsize; /* Object size (valid when sclust != 0) */ -#if _FS_EXFAT - DWORD n_cont; /* Size of coutiguous part, clusters - 1 (valid when stat == 3) */ - DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */ - DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */ - DWORD c_ofs; /* Offset in the containing directory (valid when sclust != 0) */ -#endif -#if _FS_LOCK != 0 - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -} _FDID; - - - -/* File object structure (FIL) */ - -typedef struct { - _FDID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */ - BYTE flag; /* File status flags */ - BYTE err; /* Abort flag (error code) */ - FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD clust; /* Current cluster of fpter (invalid when fprt is 0) */ - DWORD sect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (FF_DIR) */ - -typedef struct { - _FDID obj; /* Object identifier */ - DWORD dptr; /* Current read/write offset */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the directory item in the win[] */ - BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */ -#if _USE_LFN != 0 - DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} FF_DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - FSIZE_t fsize; /* File size */ - WORD fdate; /* Modified date */ - WORD ftime; /* Modified time */ - BYTE fattrib; /* File attribute */ -#if _USE_LFN != 0 - TCHAR altname[13]; /* Altenative file name */ - TCHAR fname[_MAX_LFN + 1]; /* Primary file name */ -#else - TCHAR fname[13]; /* File name */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FATFS *fs, FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */ -FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ -FRESULT f_truncate (FIL* fp); /* Truncate the file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */ -FRESULT f_opendir (FATFS *fs, FF_DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (FF_DIR* dp); /* Close an open directory */ -FRESULT f_readdir (FF_DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (FF_DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (FF_DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (FATFS *fs, const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (FATFS *fs, const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (FATFS *fs, const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (FATFS *fs, const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (FATFS *fs, const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */ -FRESULT f_utime (FATFS *fs, const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */ -FRESULT f_chdir (FATFS *fs, const TCHAR* path); /* Change current directory */ -FRESULT f_getcwd (FATFS *fs, TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (FATFS *fs, DWORD* nclst); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (FATFS *fs, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (FATFS *fs, const TCHAR* label); /* Set volume label */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt); /* Allocate a contiguous block to the file */ -FRESULT f_mount (FATFS* fs); /* Mount/Unmount a logical drive */ -FRESULT f_umount (FATFS* fs); /* Unmount a logical drive */ -FRESULT f_mkfs (FATFS *fs, BYTE opt, DWORD au, void* work, UINT len); /* Create a FAT volume */ -FRESULT f_fdisk (void *pdrv, const DWORD* szt, void* work); /* Divide a physical drive into some partitions */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->obj.objsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN != 0 /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (FATFS *fatfs, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access mode and open method flags (3rd argument of f_open) */ -#define FA_READ 0x01 -#define FA_WRITE 0x02 -#define FA_OPEN_EXISTING 0x00 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA_OPEN_APPEND 0x30 - -/* Fast seek controls (2nd argument of f_lseek) */ -#define CREATE_LINKMAP ((FSIZE_t)0 - 1) - -/* Format options (2nd argument of f_mkfs) */ -#define FM_FAT 0x01 -#define FM_FAT32 0x02 -#define FM_EXFAT 0x04 -#define FM_ANY 0x07 -#define FM_SFD 0x08 - -/* Filesystem type (FATFS.fs_type) */ -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 -#define FS_EXFAT 4 - -/* File attribute bits for directory entry (FILINFO.fattrib) */ -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/user/mpy/lib/oofatfs/ffconf.h b/user/mpy/lib/oofatfs/ffconf.h deleted file mode 100644 index 315101f..0000000 --- a/user/mpy/lib/oofatfs/ffconf.h +++ /dev/null @@ -1,349 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * Original file from: - * FatFs - FAT file system module configuration file R0.12a (C)ChaN, 2016 - * - * The MIT License (MIT) - * - * Copyright (c) 2013-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. - */ - -#include "py/mpconfig.h" - -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file -/---------------------------------------------------------------------------*/ - -#define _FFCONF 68020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Function Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_READONLY 0 -/* This option switches read-only configuration. (0:Read/Write or 1:Read-only) -/ Read-only configuration removes writing API functions, f_write(), f_sync(), -/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree() -/ and optional writing functions as well. */ - - -#define _FS_MINIMIZE 0 -/* This option defines minimization level to remove some basic API functions. -/ -/ 0: All basic functions are enabled. -/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename() -/ are removed. -/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. -/ 3: f_lseek() function is removed in addition to 2. */ - - -#define _USE_STRFUNC 0 -/* This option switches string functions, f_gets(), f_putc(), f_puts() and -/ f_printf(). -/ -/ 0: Disable string functions. -/ 1: Enable without LF-CRLF conversion. -/ 2: Enable with LF-CRLF conversion. */ - - -#define _USE_FIND 0 -/* This option switches filtered directory read functions, f_findfirst() and -/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ - - -#define _USE_MKFS 1 -/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ - - -#define _USE_FASTSEEK 0 -/* This option switches fast seek function. (0:Disable or 1:Enable) */ - - -#define _USE_EXPAND 0 -/* This option switches f_expand function. (0:Disable or 1:Enable) */ - - -#define _USE_CHMOD 1 -/* This option switches attribute manipulation functions, f_chmod() and f_utime(). -/ (0:Disable or 1:Enable) Also _FS_READONLY needs to be 0 to enable this option. */ - - -#ifdef MICROPY_FATFS_USE_LABEL -#define _USE_LABEL (MICROPY_FATFS_USE_LABEL) -#else -#define _USE_LABEL 0 -#endif -/* This option switches volume label functions, f_getlabel() and f_setlabel(). -/ (0:Disable or 1:Enable) */ - - -#define _USE_FORWARD 0 -/* This option switches f_forward() function. (0:Disable or 1:Enable) */ - - -/*---------------------------------------------------------------------------/ -/ Locale and Namespace Configurations -/---------------------------------------------------------------------------*/ - -#ifdef MICROPY_FATFS_LFN_CODE_PAGE -#define _CODE_PAGE (MICROPY_FATFS_LFN_CODE_PAGE) -#else -#define _CODE_PAGE 1 -#endif -/* This option specifies the OEM code page to be used on the target system. -/ Incorrect setting of the code page can cause a file open failure. -/ -/ 1 - ASCII (No extended character. Non-LFN cfg. only) -/ 437 - U.S. -/ 720 - Arabic -/ 737 - Greek -/ 771 - KBL -/ 775 - Baltic -/ 850 - Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 860 - Portuguese -/ 861 - Icelandic -/ 862 - Hebrew -/ 863 - Canadian French -/ 864 - Arabic -/ 865 - Nordic -/ 866 - Russian -/ 869 - Greek 2 -/ 932 - Japanese (DBCS) -/ 936 - Simplified Chinese (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese (DBCS) -*/ - - -#ifdef MICROPY_FATFS_ENABLE_LFN -#define _USE_LFN (MICROPY_FATFS_ENABLE_LFN) -#else -#define _USE_LFN 0 -#endif -#ifdef MICROPY_FATFS_MAX_LFN -#define _MAX_LFN (MICROPY_FATFS_MAX_LFN) -#else -#define _MAX_LFN 255 -#endif -/* The _USE_LFN switches the support of long file name (LFN). -/ -/ 0: Disable support of LFN. _MAX_LFN has no effect. -/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. -/ 2: Enable LFN with dynamic working buffer on the STACK. -/ 3: Enable LFN with dynamic working buffer on the HEAP. -/ -/ To enable the LFN, Unicode handling functions (option/unicode.c) must be added -/ to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and -/ additional 608 bytes at exFAT enabled. _MAX_LFN can be in range from 12 to 255. -/ It should be set 255 to support full featured LFN operations. -/ When use stack for the working buffer, take care on stack overflow. When use heap -/ memory for the working buffer, memory management functions, ff_memalloc() and -/ ff_memfree(), must be added to the project. */ - - -#define _LFN_UNICODE 0 -/* This option switches character encoding on the API. (0:ANSI/OEM or 1:UTF-16) -/ To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1. -/ This option also affects behavior of string I/O functions. */ - - -#define _STRF_ENCODE 3 -/* When _LFN_UNICODE == 1, this option selects the character encoding ON THE FILE to -/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf(). -/ -/ 0: ANSI/OEM -/ 1: UTF-16LE -/ 2: UTF-16BE -/ 3: UTF-8 -/ -/ This option has no effect when _LFN_UNICODE == 0. */ - - -#ifdef MICROPY_FATFS_RPATH -#define _FS_RPATH (MICROPY_FATFS_RPATH) -#else -#define _FS_RPATH 0 -#endif -/* This option configures support of relative path. -/ -/ 0: Disable relative path and remove related functions. -/ 1: Enable relative path. f_chdir() and f_chdrive() are available. -/ 2: f_getcwd() function is available in addition to 1. -*/ - - -/*---------------------------------------------------------------------------/ -/ Drive/Volume Configurations -/---------------------------------------------------------------------------*/ - -#define _VOLUMES 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" -/* _STR_VOLUME_ID switches string support of volume ID. -/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive -/ number in the path name. _VOLUME_STRS defines the drive ID strings for each -/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for -/ the drive ID strings are: A-Z and 0-9. */ - - -#ifdef MICROPY_FATFS_MULTI_PARTITION -#define _MULTI_PARTITION (MICROPY_FATFS_MULTI_PARTITION) -#else -#define _MULTI_PARTITION 0 -#endif -/* This option switches support of multi-partition on a physical drive. -/ By default (0), each logical drive number is bound to the same physical drive -/ number and only an FAT volume found on the physical drive will be mounted. -/ When multi-partition is enabled (1), each logical drive number can be bound to -/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() -/ funciton will be available. */ - - -#define _MIN_SS 512 -#ifdef MICROPY_FATFS_MAX_SS -#define _MAX_SS (MICROPY_FATFS_MAX_SS) -#else -#define _MAX_SS 512 -#endif -/* These options configure the range of sector size to be supported. (512, 1024, -/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and -/ harddisk. But a larger value may be required for on-board flash memory and some -/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured -/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the -/ disk_ioctl() function. */ - - -#define _USE_TRIM 0 -/* This option switches support of ATA-TRIM. (0:Disable or 1:Enable) -/ To enable Trim function, also CTRL_TRIM command should be implemented to the -/ disk_ioctl() function. */ - - -#define _FS_NOFSINFO 0 -/* If you need to know correct free space on the FAT32 volume, set bit 0 of this -/ option, and f_getfree() function at first time after volume mount will force -/ a full FAT scan. Bit 1 controls the use of last allocated cluster number. -/ -/ bit0=0: Use free cluster count in the FSINFO if available. -/ bit0=1: Do not trust free cluster count in the FSINFO. -/ bit1=0: Use last allocated cluster number in the FSINFO if available. -/ bit1=1: Do not trust last allocated cluster number in the FSINFO. -*/ - - - -/*---------------------------------------------------------------------------/ -/ System Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) -/ At the tiny configuration, size of file object (FIL) is reduced _MAX_SS bytes. -/ Instead of private sector buffer eliminated from the file object, common sector -/ buffer in the file system object (FATFS) is used for the file data transfer. */ - - -#ifdef MICROPY_FATFS_EXFAT -#define _FS_EXFAT (MICROPY_FATFS_EXFAT) -#else -#define _FS_EXFAT 0 -#endif -/* This option switches support of exFAT file system. (0:Disable or 1:Enable) -/ When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1) -/ Note that enabling exFAT discards C89 compatibility. */ - - -#ifdef MICROPY_FATFS_NORTC -#define _FS_NORTC (MICROPY_FATFS_NORTC) -#else -#define _FS_NORTC 0 -#endif -#define _NORTC_MON 1 -#define _NORTC_MDAY 1 -#define _NORTC_YEAR 2016 -/* The option _FS_NORTC switches timestamp functiton. If the system does not have -/ any RTC function or valid timestamp is not needed, set _FS_NORTC = 1 to disable -/ the timestamp function. All objects modified by FatFs will have a fixed timestamp -/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time. -/ To enable timestamp function (_FS_NORTC = 0), get_fattime() function need to be -/ added to the project to get current time form real-time clock. _NORTC_MON, -/ _NORTC_MDAY and _NORTC_YEAR have no effect. -/ These options have no effect at read-only configuration (_FS_READONLY = 1). */ - - -#define _FS_LOCK 0 -/* The option _FS_LOCK switches file lock function to control duplicated file open -/ and illegal operation to open objects. This option must be 0 when _FS_READONLY -/ is 1. -/ -/ 0: Disable file lock function. To avoid volume corruption, application program -/ should avoid illegal open, remove and rename to the open objects. -/ >0: Enable file lock function. The value defines how many files/sub-directories -/ can be opened simultaneously under file lock control. Note that the file -/ lock control is independent of re-entrancy. */ - - -#ifdef MICROPY_FATFS_REENTRANT -#define _FS_REENTRANT (MICROPY_FATFS_REENTRANT) -#else -#define _FS_REENTRANT 0 -#endif - -// milliseconds -#ifdef MICROPY_FATFS_TIMEOUT -#define _FS_TIMEOUT (MICROPY_FATFS_TIMEOUT) -#else -#define _FS_TIMEOUT 1000 -#endif - -#ifdef MICROPY_FATFS_SYNC_T -#define _SYNC_t MICROPY_FATFS_SYNC_T -#else -#define _SYNC_t HANDLE -#endif -/* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs -/ module itself. Note that regardless of this option, file access to different -/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs() -/ and f_fdisk() function, are always not re-entrant. Only file/directory access -/ to the same volume is under control of this function. -/ -/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect. -/ 1: Enable re-entrancy. Also user provided synchronization handlers, -/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() -/ function, must be added to the project. Samples are available in -/ option/syscall.c. -/ -/ The _FS_TIMEOUT defines timeout period in unit of time tick. -/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, -/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be -/ included somewhere in the scope of ff.h. */ - -/* #include // O/S definitions */ - - -/*--- End of configuration options ---*/ diff --git a/user/mpy/lib/oofatfs/option/ccsbcs.c b/user/mpy/lib/oofatfs/option/ccsbcs.c deleted file mode 100644 index fdded96..0000000 --- a/user/mpy/lib/oofatfs/option/ccsbcs.c +++ /dev/null @@ -1,388 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 437 U.S. -/ 720 Arabic -/ 737 Greek -/ 771 KBL -/ 775 Baltic -/ 850 Latin 1 -/ 852 Latin 2 -/ 855 Cyrillic -/ 857 Turkish -/ 860 Portuguese -/ 861 Icelandic -/ 862 Hebrew -/ 863 Canadian French -/ 864 Arabic -/ 865 Nordic -/ 866 Russian -/ 869 Greek 2 -*/ - -#include "../ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted (BMP only) */ -) -{ - /* Compressed upper conversion table */ - static const WCHAR cvt1[] = { /* U+0000 - U+0FFF */ - /* Basic Latin */ - 0x0061,0x031A, - /* Latin-1 Supplement */ - 0x00E0,0x0317, 0x00F8,0x0307, 0x00FF,0x0001,0x0178, - /* Latin Extended-A */ - 0x0100,0x0130, 0x0132,0x0106, 0x0139,0x0110, 0x014A,0x012E, 0x0179,0x0106, - /* Latin Extended-B */ - 0x0180,0x004D,0x0243,0x0181,0x0182,0x0182,0x0184,0x0184,0x0186,0x0187,0x0187,0x0189,0x018A,0x018B,0x018B,0x018D,0x018E,0x018F,0x0190,0x0191,0x0191,0x0193,0x0194,0x01F6,0x0196,0x0197,0x0198,0x0198,0x023D,0x019B,0x019C,0x019D,0x0220,0x019F,0x01A0,0x01A0,0x01A2,0x01A2,0x01A4,0x01A4,0x01A6,0x01A7,0x01A7,0x01A9,0x01AA,0x01AB,0x01AC,0x01AC,0x01AE,0x01AF,0x01AF,0x01B1,0x01B2,0x01B3,0x01B3,0x01B5,0x01B5,0x01B7,0x01B8,0x01B8,0x01BA,0x01BB,0x01BC,0x01BC,0x01BE,0x01F7,0x01C0,0x01C1,0x01C2,0x01C3,0x01C4,0x01C5,0x01C4,0x01C7,0x01C8,0x01C7,0x01CA,0x01CB,0x01CA, - 0x01CD,0x0110, 0x01DD,0x0001,0x018E, 0x01DE,0x0112, 0x01F3,0x0003,0x01F1,0x01F4,0x01F4, 0x01F8,0x0128, - 0x0222,0x0112, 0x023A,0x0009,0x2C65,0x023B,0x023B,0x023D,0x2C66,0x023F,0x0240,0x0241,0x0241, 0x0246,0x010A, - /* IPA Extensions */ - 0x0253,0x0040,0x0181,0x0186,0x0255,0x0189,0x018A,0x0258,0x018F,0x025A,0x0190,0x025C,0x025D,0x025E,0x025F,0x0193,0x0261,0x0262,0x0194,0x0264,0x0265,0x0266,0x0267,0x0197,0x0196,0x026A,0x2C62,0x026C,0x026D,0x026E,0x019C,0x0270,0x0271,0x019D,0x0273,0x0274,0x019F,0x0276,0x0277,0x0278,0x0279,0x027A,0x027B,0x027C,0x2C64,0x027E,0x027F,0x01A6,0x0281,0x0282,0x01A9,0x0284,0x0285,0x0286,0x0287,0x01AE,0x0244,0x01B1,0x01B2,0x0245,0x028D,0x028E,0x028F,0x0290,0x0291,0x01B7, - /* Greek, Coptic */ - 0x037B,0x0003,0x03FD,0x03FE,0x03FF, 0x03AC,0x0004,0x0386,0x0388,0x0389,0x038A, 0x03B1,0x0311, - 0x03C2,0x0002,0x03A3,0x03A3, 0x03C4,0x0308, 0x03CC,0x0003,0x038C,0x038E,0x038F, 0x03D8,0x0118, - 0x03F2,0x000A,0x03F9,0x03F3,0x03F4,0x03F5,0x03F6,0x03F7,0x03F7,0x03F9,0x03FA,0x03FA, - /* Cyrillic */ - 0x0430,0x0320, 0x0450,0x0710, 0x0460,0x0122, 0x048A,0x0136, 0x04C1,0x010E, 0x04CF,0x0001,0x04C0, 0x04D0,0x0144, - /* Armenian */ - 0x0561,0x0426, - - 0x0000 - }; - static const WCHAR cvt2[] = { /* U+1000 - U+FFFF */ - /* Phonetic Extensions */ - 0x1D7D,0x0001,0x2C63, - /* Latin Extended Additional */ - 0x1E00,0x0196, 0x1EA0,0x015A, - /* Greek Extended */ - 0x1F00,0x0608, 0x1F10,0x0606, 0x1F20,0x0608, 0x1F30,0x0608, 0x1F40,0x0606, - 0x1F51,0x0007,0x1F59,0x1F52,0x1F5B,0x1F54,0x1F5D,0x1F56,0x1F5F, 0x1F60,0x0608, - 0x1F70,0x000E,0x1FBA,0x1FBB,0x1FC8,0x1FC9,0x1FCA,0x1FCB,0x1FDA,0x1FDB,0x1FF8,0x1FF9,0x1FEA,0x1FEB,0x1FFA,0x1FFB, - 0x1F80,0x0608, 0x1F90,0x0608, 0x1FA0,0x0608, 0x1FB0,0x0004,0x1FB8,0x1FB9,0x1FB2,0x1FBC, - 0x1FCC,0x0001,0x1FC3, 0x1FD0,0x0602, 0x1FE0,0x0602, 0x1FE5,0x0001,0x1FEC, 0x1FF2,0x0001,0x1FFC, - /* Letterlike Symbols */ - 0x214E,0x0001,0x2132, - /* Number forms */ - 0x2170,0x0210, 0x2184,0x0001,0x2183, - /* Enclosed Alphanumerics */ - 0x24D0,0x051A, 0x2C30,0x042F, - /* Latin Extended-C */ - 0x2C60,0x0102, 0x2C67,0x0106, 0x2C75,0x0102, - /* Coptic */ - 0x2C80,0x0164, - /* Georgian Supplement */ - 0x2D00,0x0826, - /* Full-width */ - 0xFF41,0x031A, - - 0x0000 - }; - const WCHAR *p; - WCHAR bc, nc, cmd; - - - p = chr < 0x1000 ? cvt1 : cvt2; - for (;;) { - bc = *p++; /* Get block base */ - if (!bc || chr < bc) break; - nc = *p++; cmd = nc >> 8; nc &= 0xFF; /* Get processing command and block size */ - if (chr < bc + nc) { /* In the block? */ - switch (cmd) { - case 0: chr = p[chr - bc]; break; /* Table conversion */ - case 1: chr -= (chr - bc) & 1; break; /* Case pairs */ - case 2: chr -= 16; break; /* Shift -16 */ - case 3: chr -= 32; break; /* Shift -32 */ - case 4: chr -= 48; break; /* Shift -48 */ - case 5: chr -= 26; break; /* Shift -26 */ - case 6: chr += 8; break; /* Shift +8 */ - case 7: chr -= 80; break; /* Shift -80 */ - case 8: chr -= 0x1C60; break; /* Shift -0x1C60 */ - } - break; - } - if (!cmd) p += nc; - } - - return chr; -} - diff --git a/user/mpy/lib/oofatfs/option/unicode.c b/user/mpy/lib/oofatfs/option/unicode.c deleted file mode 100644 index e48d09c..0000000 --- a/user/mpy/lib/oofatfs/option/unicode.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "../ff.h" - -#if _USE_LFN != 0 - -#if _CODE_PAGE == 932 /* Japanese Shift_JIS */ -#include "cc932.c" -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#include "cc936.c" -#elif _CODE_PAGE == 949 /* Korean */ -#include "cc949.c" -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#include "cc950.c" -#else /* Single Byte Character-Set */ -#include "ccsbcs.c" -#endif - -#endif diff --git a/user/mpy/lib/timeutils/timeutils.c b/user/mpy/lib/timeutils/timeutils.c deleted file mode 100644 index eb3dc80..0000000 --- a/user/mpy/lib/timeutils/timeutils.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * 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. - */ - -#include "py/obj.h" - -#include "lib/timeutils/timeutils.h" - -// LEAPOCH corresponds to 2000-03-01, which is a mod-400 year, immediately -// after Feb 29. We calculate seconds as a signed integer relative to that. -// -// Our timebase is relative to 2000-01-01. - -#define LEAPOCH ((31 + 29) * 86400) - -#define DAYS_PER_400Y (365*400 + 97) -#define DAYS_PER_100Y (365*100 + 24) -#define DAYS_PER_4Y (365*4 + 1) - -STATIC const uint16_t days_since_jan1[]= { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; - -bool timeutils_is_leap_year(mp_uint_t year) { - return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; -} - -// month is one based -mp_uint_t timeutils_days_in_month(mp_uint_t year, mp_uint_t month) { - mp_uint_t mdays = days_since_jan1[month] - days_since_jan1[month - 1]; - if (month == 2 && timeutils_is_leap_year(year)) { - mdays++; - } - return mdays; -} - -// compute the day of the year, between 1 and 366 -// month should be between 1 and 12, date should start at 1 -mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t date) { - mp_uint_t yday = days_since_jan1[month - 1] + date; - if (month >= 3 && timeutils_is_leap_year(year)) { - yday += 1; - } - return yday; -} - -void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, timeutils_struct_time_t *tm) { - // The following algorithm was adapted from musl's __secs_to_tm and adapted - // for differences in MicroPython's timebase. - - mp_int_t seconds = t - LEAPOCH; - - mp_int_t days = seconds / 86400; - seconds %= 86400; - if (seconds < 0) { - seconds += 86400; - days -= 1; - } - tm->tm_hour = seconds / 3600; - tm->tm_min = seconds / 60 % 60; - tm->tm_sec = seconds % 60; - - mp_int_t wday = (days + 2) % 7; // Mar 1, 2000 was a Wednesday (2) - if (wday < 0) { - wday += 7; - } - tm->tm_wday = wday; - - mp_int_t qc_cycles = days / DAYS_PER_400Y; - days %= DAYS_PER_400Y; - if (days < 0) { - days += DAYS_PER_400Y; - qc_cycles--; - } - mp_int_t c_cycles = days / DAYS_PER_100Y; - if (c_cycles == 4) { - c_cycles--; - } - days -= (c_cycles * DAYS_PER_100Y); - - mp_int_t q_cycles = days / DAYS_PER_4Y; - if (q_cycles == 25) { - q_cycles--; - } - days -= q_cycles * DAYS_PER_4Y; - - mp_int_t years = days / 365; - if (years == 4) { - years--; - } - days -= (years * 365); - - /* We will compute tm_yday at the very end - mp_int_t leap = !years && (q_cycles || !c_cycles); - - tm->tm_yday = days + 31 + 28 + leap; - if (tm->tm_yday >= 365 + leap) { - tm->tm_yday -= 365 + leap; - } - - tm->tm_yday++; // Make one based - */ - - tm->tm_year = 2000 + years + 4 * q_cycles + 100 * c_cycles + 400 * qc_cycles; - - // Note: days_in_month[0] corresponds to March - STATIC const int8_t days_in_month[] = {31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29}; - - mp_int_t month; - for (month = 0; days_in_month[month] <= days; month++) { - days -= days_in_month[month]; - } - - tm->tm_mon = month + 2; - if (tm->tm_mon >= 12) { - tm->tm_mon -= 12; - tm->tm_year++; - } - tm->tm_mday = days + 1; // Make one based - tm->tm_mon++; // Make one based - - tm->tm_yday = timeutils_year_day(tm->tm_year, tm->tm_mon, tm->tm_mday); -} - -// returns the number of seconds, as an integer, since 2000-01-01 -mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month, - mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second) { - return - second - + minute * 60 - + hour * 3600 - + (timeutils_year_day(year, month, date) - 1 - + ((year - 2000 + 3) / 4) // add a day each 4 years starting with 2001 - - ((year - 2000 + 99) / 100) // subtract a day each 100 years starting with 2001 - + ((year - 2000 + 399) / 400) // add a day each 400 years starting with 2001 - ) * 86400 - + (year - 2000) * 31536000; -} - -mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, - mp_int_t hours, mp_int_t minutes, mp_int_t seconds) { - - // Normalize the tuple. This allows things like: - // - // tm_tomorrow = list(time.localtime()) - // tm_tomorrow[2] += 1 # Adds 1 to mday - // tomorrow = time.mktime(tm_tomorrow) - // - // And not have to worry about all the weird overflows. - // - // You can subtract dates/times this way as well. - - minutes += seconds / 60; - if ((seconds = seconds % 60) < 0) { - seconds += 60; - minutes--; - } - - hours += minutes / 60; - if ((minutes = minutes % 60) < 0) { - minutes += 60; - hours--; - } - - mday += hours / 24; - if ((hours = hours % 24) < 0) { - hours += 24; - mday--; - } - - month--; // make month zero based - year += month / 12; - if ((month = month % 12) < 0) { - month += 12; - year--; - } - month++; // back to one based - - while (mday < 1) { - if (--month == 0) { - month = 12; - year--; - } - mday += timeutils_days_in_month(year, month); - } - while ((mp_uint_t)mday > timeutils_days_in_month(year, month)) { - mday -= timeutils_days_in_month(year, month); - if (++month == 13) { - month = 1; - year++; - } - } - return timeutils_seconds_since_2000(year, month, mday, hours, minutes, seconds); -} diff --git a/user/mpy/lib/timeutils/timeutils.h b/user/mpy/lib/timeutils/timeutils.h deleted file mode 100644 index 9b1abeb..0000000 --- a/user/mpy/lib/timeutils/timeutils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * 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_LIB_TIMEUTILS_TIMEUTILS_H -#define MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H - -typedef struct _timeutils_struct_time_t { - uint16_t tm_year; // i.e. 2014 - uint8_t tm_mon; // 1..12 - uint8_t tm_mday; // 1..31 - uint8_t tm_hour; // 0..23 - uint8_t tm_min; // 0..59 - uint8_t tm_sec; // 0..59 - uint8_t tm_wday; // 0..6 0 = Monday - uint16_t tm_yday; // 1..366 -} timeutils_struct_time_t; - -bool timeutils_is_leap_year(mp_uint_t year); -mp_uint_t timeutils_days_in_month(mp_uint_t year, mp_uint_t month); -mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t date); - -void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, - timeutils_struct_time_t *tm); - -mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month, - mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second); - -mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, - mp_int_t hours, mp_int_t minutes, mp_int_t seconds); - -#endif // MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H diff --git a/user/mpy/lib/utils/interrupt_char.c b/user/mpy/lib/utils/interrupt_char.c deleted file mode 100644 index fca0f95..0000000 --- a/user/mpy/lib/utils/interrupt_char.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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. - */ - -#include "py/obj.h" -#include "py/mpstate.h" - -#if MICROPY_KBD_EXCEPTION - -int mp_interrupt_char; - -void mp_hal_set_interrupt_char(int c) { - if (c != -1) { - mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); - } - mp_interrupt_char = c; -} - -void mp_keyboard_interrupt(void) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)); - #if MICROPY_ENABLE_SCHEDULER - if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { - MP_STATE_VM(sched_state) = MP_SCHED_PENDING; - } - #endif -} - -#endif diff --git a/user/mpy/lib/utils/interrupt_char.h b/user/mpy/lib/utils/interrupt_char.h deleted file mode 100644 index ca50d4d..0000000 --- a/user/mpy/lib/utils/interrupt_char.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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_LIB_UTILS_INTERRUPT_CHAR_H -#define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H - -extern int mp_interrupt_char; -void mp_hal_set_interrupt_char(int c); -void mp_keyboard_interrupt(void); - -#endif // MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H diff --git a/user/mpy/lib/utils/printf.c b/user/mpy/lib/utils/printf.c deleted file mode 100644 index 51dfa5b..0000000 --- a/user/mpy/lib/utils/printf.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" - -#if MICROPY_USE_INTERNAL_PRINTF - -#include -#include -#include - -#include "py/obj.h" -#include "py/mphal.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include "py/formatfloat.h" -#endif - -#undef putchar // Some stdlibs have a #define for putchar -int printf(const char *fmt, ...); -int vprintf(const char *fmt, va_list ap); -int putchar(int c); -int puts(const char *s); -int vsnprintf(char *str, size_t size, const char *fmt, va_list ap); -int snprintf(char *str, size_t size, const char *fmt, ...); - -int printf(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - int ret = mp_vprintf(&mp_plat_print, fmt, ap); - va_end(ap); - return ret; -} - -int vprintf(const char *fmt, va_list ap) { - return mp_vprintf(&mp_plat_print, fmt, ap); -} - -#if MICROPY_DEBUG_PRINTERS -int DEBUG_printf(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - #ifndef MICROPY_DEBUG_PRINTER_DEST - #define MICROPY_DEBUG_PRINTER_DEST mp_plat_print - #endif - extern const mp_print_t MICROPY_DEBUG_PRINTER_DEST; - int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap); - va_end(ap); - return ret; -} -#endif - -// need this because gcc optimises printf("%c", c) -> putchar(c), and printf("a") -> putchar('a') -int putchar(int c) { - char chr = c; - mp_hal_stdout_tx_strn_cooked(&chr, 1); - return chr; -} - -// need this because gcc optimises printf("string\n") -> puts("string") -int puts(const char *s) { - mp_hal_stdout_tx_strn_cooked(s, strlen(s)); - char chr = '\n'; - mp_hal_stdout_tx_strn_cooked(&chr, 1); - return 1; -} - -typedef struct _strn_print_env_t { - char *cur; - size_t remain; -} strn_print_env_t; - -STATIC void strn_print_strn(void *data, const char *str, size_t len) { - strn_print_env_t *strn_print_env = data; - if (len > strn_print_env->remain) { - len = strn_print_env->remain; - } - memcpy(strn_print_env->cur, str, len); - strn_print_env->cur += len; - strn_print_env->remain -= len; -} - -#if defined(__GNUC__) && !defined(__clang__) -// uClibc requires this alias to be defined, or there may be link errors -// when linkings against it statically. -int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias ("vsnprintf"))); -#endif - -int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { - strn_print_env_t strn_print_env = {str, size}; - mp_print_t print = {&strn_print_env, strn_print_strn}; - int len = mp_vprintf(&print, fmt, ap); - // add terminating null byte - if (size > 0) { - if (strn_print_env.remain == 0) { - strn_print_env.cur[-1] = 0; - } else { - strn_print_env.cur[0] = 0; - } - } - return len; -} - -int snprintf(char *str, size_t size, const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - int ret = vsnprintf(str, size, fmt, ap); - va_end(ap); - return ret; -} - -#endif //MICROPY_USE_INTERNAL_PRINTF diff --git a/user/mpy/lib/utils/pyexec.c b/user/mpy/lib/utils/pyexec.c deleted file mode 100644 index d3500b4..0000000 --- a/user/mpy/lib/utils/pyexec.c +++ /dev/null @@ -1,531 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/nlr.h" -#include "py/compile.h" -#include "py/runtime.h" -#include "py/repl.h" -#include "py/gc.h" -#include "py/frozenmod.h" -#include "py/mphal.h" -#if defined(USE_DEVICE_MODE) -#include "irq.h" -#include "usb.h" -#endif -#include "lib/mp-readline/readline.h" -#include "lib/utils/pyexec.h" -#include "genhdr/mpversion.h" - -pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; -int pyexec_system_exit = 0; -STATIC bool repl_display_debugging_info = 0; - -#define EXEC_FLAG_PRINT_EOF (1) -#define EXEC_FLAG_ALLOW_DEBUGGING (2) -#define EXEC_FLAG_IS_REPL (4) -#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) -#define EXEC_FLAG_SOURCE_IS_VSTR (16) -#define EXEC_FLAG_SOURCE_IS_FILENAME (32) - -// parses, compiles and executes the code in the lexer -// frees the lexer before returning -// EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output -// EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code -// EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile) -STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, int exec_flags) { - int ret = 0; - uint32_t start = 0; - - // by default a SystemExit exception returns 0 - pyexec_system_exit = 0; - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t module_fun; - #if MICROPY_MODULE_FROZEN_MPY - if (exec_flags & EXEC_FLAG_SOURCE_IS_RAW_CODE) { - // source is a raw_code object, create the function - module_fun = mp_make_function_from_raw_code(source, MP_OBJ_NULL, MP_OBJ_NULL); - } else - #endif - { - #if MICROPY_ENABLE_COMPILER - mp_lexer_t *lex; - if (exec_flags & EXEC_FLAG_SOURCE_IS_VSTR) { - const vstr_t *vstr = source; - lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr->buf, vstr->len, 0); - } else if (exec_flags & EXEC_FLAG_SOURCE_IS_FILENAME) { - lex = mp_lexer_new_from_file(source); - } else { - lex = (mp_lexer_t*)source; - } - // source is a lexer, parse and compile the script - qstr source_name = lex->source_name; - mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); - module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL); - #else - mp_raise_msg(&mp_type_RuntimeError, "script compilation not supported"); - #endif - } - - // execute code - mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us - start = mp_hal_ticks_ms(); - mp_call_function_0(module_fun); - mp_hal_set_interrupt_char(-1); // disable interrupt - nlr_pop(); - ret = 1; - if (exec_flags & EXEC_FLAG_PRINT_EOF) { - mp_hal_stdout_tx_strn("\x04", 1); - } - } else { - // uncaught exception - // FIXME it could be that an interrupt happens just before we disable it here - mp_hal_set_interrupt_char(-1); // disable interrupt - // print EOF after normal output - if (exec_flags & EXEC_FLAG_PRINT_EOF) { - mp_hal_stdout_tx_strn("\x04", 1); - } - // check for SystemExit - if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) { - // at the moment, the value of SystemExit is unused - ret = pyexec_system_exit; - } else { - mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); - ret = 0; - } - } - - // display debugging info if wanted - if ((exec_flags & EXEC_FLAG_ALLOW_DEBUGGING) && repl_display_debugging_info) { - mp_uint_t ticks = mp_hal_ticks_ms() - start; // TODO implement a function that does this properly - printf("took " UINT_FMT " ms\n", ticks); - // qstr info - { - size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; - qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); - printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n " - "n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", - (unsigned)n_pool, (unsigned)n_qstr, (unsigned)n_str_data_bytes, (unsigned)n_total_bytes); - } - - #if MICROPY_ENABLE_GC - // run collection and print GC info - gc_collect(); - gc_dump_info(); - #endif - } - - if (exec_flags & EXEC_FLAG_PRINT_EOF) { - mp_hal_stdout_tx_strn("\x04", 1); - } - - return ret; -} - -#if MICROPY_ENABLE_COMPILER -#if MICROPY_REPL_EVENT_DRIVEN - -typedef struct _repl_t { - // This structure originally also held current REPL line, - // but it was moved to MP_STATE_VM(repl_line) as containing - // root pointer. Still keep structure in case more state - // will be added later. - //vstr_t line; - bool cont_line; -} repl_t; - -repl_t repl; - -STATIC int pyexec_raw_repl_process_char(int c); -STATIC int pyexec_friendly_repl_process_char(int c); - -void pyexec_event_repl_init(void) { - MP_STATE_VM(repl_line) = vstr_new(32); - repl.cont_line = false; - // no prompt before printing friendly REPL banner or entering raw REPL - readline_init(MP_STATE_VM(repl_line), ""); - if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { - pyexec_raw_repl_process_char(CHAR_CTRL_A); - } else { - pyexec_friendly_repl_process_char(CHAR_CTRL_B); - } -} - -STATIC int pyexec_raw_repl_process_char(int c) { - if (c == CHAR_CTRL_A) { - // reset raw REPL - mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n"); - goto reset; - } else if (c == CHAR_CTRL_B) { - // change to friendly REPL - pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; - vstr_reset(MP_STATE_VM(repl_line)); - repl.cont_line = false; - pyexec_friendly_repl_process_char(CHAR_CTRL_B); - return 0; - } else if (c == CHAR_CTRL_C) { - // clear line - vstr_reset(MP_STATE_VM(repl_line)); - return 0; - } else if (c == CHAR_CTRL_D) { - // input finished - } else { - // let through any other raw 8-bit value - vstr_add_byte(MP_STATE_VM(repl_line), c); - return 0; - } - - // indicate reception of command - mp_hal_stdout_tx_str("OK"); - - if (MP_STATE_VM(repl_line)->len == 0) { - // exit for a soft reset - mp_hal_stdout_tx_str("\r\n"); - vstr_clear(MP_STATE_VM(repl_line)); - return PYEXEC_FORCED_EXIT; - } - - int ret = parse_compile_execute(MP_STATE_VM(repl_line), MP_PARSE_FILE_INPUT, EXEC_FLAG_PRINT_EOF | EXEC_FLAG_SOURCE_IS_VSTR); - if (ret & PYEXEC_FORCED_EXIT) { - return ret; - } - -reset: - vstr_reset(MP_STATE_VM(repl_line)); - mp_hal_stdout_tx_str(">"); - - return 0; -} - -STATIC int pyexec_friendly_repl_process_char(int c) { - int ret = readline_process_char(c); - - if (!repl.cont_line) { - - if (ret == CHAR_CTRL_A) { - // change to raw REPL - pyexec_mode_kind = PYEXEC_MODE_RAW_REPL; - mp_hal_stdout_tx_str("\r\n"); - pyexec_raw_repl_process_char(CHAR_CTRL_A); - return 0; - } else if (ret == CHAR_CTRL_B) { - // reset friendly REPL - mp_hal_stdout_tx_str("\r\n"); - mp_hal_stdout_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n"); - #if MICROPY_PY_BUILTINS_HELP - mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n"); - #endif - goto input_restart; - } else if (ret == CHAR_CTRL_C) { - // break - mp_hal_stdout_tx_str("\r\n"); - goto input_restart; - } else if (ret == CHAR_CTRL_D) { - // exit for a soft reset - mp_hal_stdout_tx_str("\r\n"); - vstr_clear(MP_STATE_VM(repl_line)); - return PYEXEC_FORCED_EXIT; - } - - if (ret < 0) { - return 0; - } - - if (!mp_repl_continue_with_input(vstr_null_terminated_str(MP_STATE_VM(repl_line)))) { - goto exec; - } - - vstr_add_byte(MP_STATE_VM(repl_line), '\n'); - repl.cont_line = true; - readline_note_newline("... "); - return 0; - - } else { - - if (ret == CHAR_CTRL_C) { - // cancel everything - mp_hal_stdout_tx_str("\r\n"); - repl.cont_line = false; - goto input_restart; - } else if (ret == CHAR_CTRL_D) { - // stop entering compound statement - goto exec; - } - - if (ret < 0) { - return 0; - } - - if (mp_repl_continue_with_input(vstr_null_terminated_str(MP_STATE_VM(repl_line)))) { - vstr_add_byte(MP_STATE_VM(repl_line), '\n'); - readline_note_newline("... "); - return 0; - } - -exec: ; - int ret = parse_compile_execute(MP_STATE_VM(repl_line), MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL | EXEC_FLAG_SOURCE_IS_VSTR); - if (ret & PYEXEC_FORCED_EXIT) { - return ret; - } - -input_restart: - vstr_reset(MP_STATE_VM(repl_line)); - repl.cont_line = false; - readline_init(MP_STATE_VM(repl_line), ">>> "); - return 0; - } -} - -uint8_t pyexec_repl_active; -int pyexec_event_repl_process_char(int c) { - pyexec_repl_active = 1; - int res; - if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { - res = pyexec_raw_repl_process_char(c); - } else { - res = pyexec_friendly_repl_process_char(c); - } - pyexec_repl_active = 0; - return res; -} - -#else // MICROPY_REPL_EVENT_DRIVEN - -int pyexec_raw_repl(void) { - vstr_t line; - vstr_init(&line, 32); - -raw_repl_reset: - mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n"); - - for (;;) { - vstr_reset(&line); - mp_hal_stdout_tx_str(">"); - for (;;) { - int c = mp_hal_stdin_rx_chr(); - if (c == CHAR_CTRL_A) { - // reset raw REPL - goto raw_repl_reset; - } else if (c == CHAR_CTRL_B) { - // change to friendly REPL - mp_hal_stdout_tx_str("\r\n"); - vstr_clear(&line); - pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; - return 0; - } else if (c == CHAR_CTRL_C) { - // clear line - vstr_reset(&line); - } else if (c == CHAR_CTRL_D) { - // input finished - break; - } else { - // let through any other raw 8-bit value - vstr_add_byte(&line, c); - } - } - - // indicate reception of command - mp_hal_stdout_tx_str("OK"); - - if (line.len == 0) { - // exit for a soft reset - mp_hal_stdout_tx_str("\r\n"); - vstr_clear(&line); - return PYEXEC_FORCED_EXIT; - } - - int ret = parse_compile_execute(&line, MP_PARSE_FILE_INPUT, EXEC_FLAG_PRINT_EOF | EXEC_FLAG_SOURCE_IS_VSTR); - if (ret & PYEXEC_FORCED_EXIT) { - return ret; - } - } -} - -int pyexec_friendly_repl(void) { - vstr_t line; - vstr_init(&line, 32); - -#if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD - // in host mode, we enable the LCD for the repl - mp_obj_t lcd_o = mp_call_function_0(mp_load_name(qstr_from_str("LCD"))); - mp_call_function_1(mp_load_attr(lcd_o, qstr_from_str("light")), mp_const_true); -#endif - -friendly_repl_reset: - mp_hal_stdout_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n"); - #if MICROPY_PY_BUILTINS_HELP - mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n"); - #endif - - // to test ctrl-C - /* - { - uint32_t x[4] = {0x424242, 0xdeaddead, 0x242424, 0xdeadbeef}; - for (;;) { - nlr_buf_t nlr; - printf("pyexec_repl: %p\n", x); - mp_hal_set_interrupt_char(CHAR_CTRL_C); - if (nlr_push(&nlr) == 0) { - for (;;) { - } - } else { - printf("break\n"); - } - } - } - */ - - for (;;) { - input_restart: - - #if defined(USE_DEVICE_MODE) - if (usb_vcp_is_enabled()) { - // If the user gets to here and interrupts are disabled then - // they'll never see the prompt, traceback etc. The USB REPL needs - // interrupts to be enabled or no transfers occur. So we try to - // do the user a favor and reenable interrupts. - if (query_irq() == IRQ_STATE_DISABLED) { - enable_irq(IRQ_STATE_ENABLED); - mp_hal_stdout_tx_str("PYB: enabling IRQs\r\n"); - } - } - #endif - - vstr_reset(&line); - int ret = readline(&line, ">>> "); - mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT; - - if (ret == CHAR_CTRL_A) { - // change to raw REPL - mp_hal_stdout_tx_str("\r\n"); - vstr_clear(&line); - pyexec_mode_kind = PYEXEC_MODE_RAW_REPL; - return 0; - } else if (ret == CHAR_CTRL_B) { - // reset friendly REPL - mp_hal_stdout_tx_str("\r\n"); - goto friendly_repl_reset; - } else if (ret == CHAR_CTRL_C) { - // break - mp_hal_stdout_tx_str("\r\n"); - continue; - } else if (ret == CHAR_CTRL_D) { - // exit for a soft reset - mp_hal_stdout_tx_str("\r\n"); - vstr_clear(&line); - return PYEXEC_FORCED_EXIT; - } else if (ret == CHAR_CTRL_E) { - // paste mode - mp_hal_stdout_tx_str("\r\npaste mode; Ctrl-C to cancel, Ctrl-D to finish\r\n=== "); - vstr_reset(&line); - for (;;) { - char c = mp_hal_stdin_rx_chr(); - if (c == CHAR_CTRL_C) { - // cancel everything - mp_hal_stdout_tx_str("\r\n"); - goto input_restart; - } else if (c == CHAR_CTRL_D) { - // end of input - mp_hal_stdout_tx_str("\r\n"); - break; - } else { - // add char to buffer and echo - vstr_add_byte(&line, c); - if (c == '\r') { - mp_hal_stdout_tx_str("\r\n=== "); - } else { - mp_hal_stdout_tx_strn(&c, 1); - } - } - } - parse_input_kind = MP_PARSE_FILE_INPUT; - } else if (vstr_len(&line) == 0) { - continue; - } else { - // got a line with non-zero length, see if it needs continuing - while (mp_repl_continue_with_input(vstr_null_terminated_str(&line))) { - vstr_add_byte(&line, '\n'); - ret = readline(&line, "... "); - if (ret == CHAR_CTRL_C) { - // cancel everything - mp_hal_stdout_tx_str("\r\n"); - goto input_restart; - } else if (ret == CHAR_CTRL_D) { - // stop entering compound statement - break; - } - } - } - - ret = parse_compile_execute(&line, parse_input_kind, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL | EXEC_FLAG_SOURCE_IS_VSTR); - if (ret & PYEXEC_FORCED_EXIT) { - return ret; - } - } -} - -#endif // MICROPY_REPL_EVENT_DRIVEN -#endif // MICROPY_ENABLE_COMPILER - -int pyexec_file(const char *filename) { - return parse_compile_execute(filename, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_FILENAME); -} - -#if MICROPY_MODULE_FROZEN -int pyexec_frozen_module(const char *name) { - void *frozen_data; - int frozen_type = mp_find_frozen_module(name, strlen(name), &frozen_data); - - switch (frozen_type) { - #if MICROPY_MODULE_FROZEN_STR - case MP_FROZEN_STR: - return parse_compile_execute(frozen_data, MP_PARSE_FILE_INPUT, 0); - #endif - - #if MICROPY_MODULE_FROZEN_MPY - case MP_FROZEN_MPY: - return parse_compile_execute(frozen_data, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_RAW_CODE); - #endif - - default: - printf("could not find module '%s'\n", name); - return false; - } -} -#endif - -mp_obj_t pyb_set_repl_info(mp_obj_t o_value) { - repl_display_debugging_info = mp_obj_get_int(o_value); - return mp_const_none; -} - -MP_DEFINE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj, pyb_set_repl_info); diff --git a/user/mpy/lib/utils/pyexec.h b/user/mpy/lib/utils/pyexec.h deleted file mode 100644 index bc98ba9..0000000 --- a/user/mpy/lib/utils/pyexec.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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_LIB_UTILS_PYEXEC_H -#define MICROPY_INCLUDED_LIB_UTILS_PYEXEC_H - -typedef enum { - PYEXEC_MODE_RAW_REPL, - PYEXEC_MODE_FRIENDLY_REPL, -} pyexec_mode_kind_t; - -extern pyexec_mode_kind_t pyexec_mode_kind; - -// Set this to the value (eg PYEXEC_FORCED_EXIT) that will be propagated through -// the pyexec functions if a SystemExit exception is raised by the running code. -// It will reset to 0 at the start of each execution (eg each REPL entry). -extern int pyexec_system_exit; - -#define PYEXEC_FORCED_EXIT (0x100) -#define PYEXEC_SWITCH_MODE (0x200) - -int pyexec_raw_repl(void); -int pyexec_friendly_repl(void); -int pyexec_file(const char *filename); -int pyexec_frozen_module(const char *name); -void pyexec_event_repl_init(void); -int pyexec_event_repl_process_char(int c); -extern uint8_t pyexec_repl_active; - -MP_DECLARE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj); - -#endif // MICROPY_INCLUDED_LIB_UTILS_PYEXEC_H diff --git a/user/mpy/lib/utils/stdout_helpers.c b/user/mpy/lib/utils/stdout_helpers.c deleted file mode 100644 index 3de1197..0000000 --- a/user/mpy/lib/utils/stdout_helpers.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include "py/mpconfig.h" -#include "py/mphal.h" - -/* - * Extra stdout functions - * These can be either optimized for a particular port, or reference - * implementation below can be used. - */ - -// Send "cooked" string of given length, where every occurrence of -// LF character is replaced with CR LF. -void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { - while (len--) { - if (*str == '\n') { - mp_hal_stdout_tx_strn("\r", 1); - } - mp_hal_stdout_tx_strn(str++, 1); - } -} - -// Send zero-terminated string -void mp_hal_stdout_tx_str(const char *str) { - mp_hal_stdout_tx_strn(str, strlen(str)); -} diff --git a/user/mpy/lib/utils/sys_stdio_mphal.c b/user/mpy/lib/utils/sys_stdio_mphal.c deleted file mode 100644 index fc8a74e..0000000 --- a/user/mpy/lib/utils/sys_stdio_mphal.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-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. - */ - -#include -#include - -#include "py/obj.h" -#include "py/stream.h" -#include "py/mperrno.h" -#include "py/mphal.h" - -// TODO make stdin, stdout and stderr writable objects so they can -// be changed by Python code. This requires some changes, as these -// objects are in a read-only module (py/modsys.c). - -/******************************************************************************/ -// MicroPython bindings - -#define STDIO_FD_IN (0) -#define STDIO_FD_OUT (1) -#define STDIO_FD_ERR (2) - -typedef struct _sys_stdio_obj_t { - mp_obj_base_t base; - int fd; -} sys_stdio_obj_t; - -#if MICROPY_PY_SYS_STDIO_BUFFER -STATIC const sys_stdio_obj_t stdio_buffer_obj; -#endif - -void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - sys_stdio_obj_t *self = self_in; - mp_printf(print, "", self->fd); -} - -STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - sys_stdio_obj_t *self = self_in; - if (self->fd == STDIO_FD_IN) { - for (uint i = 0; i < size; i++) { - int c = mp_hal_stdin_rx_chr(); - if (c == '\r') { - c = '\n'; - } - ((byte*)buf)[i] = c; - } - return size; - } else { - *errcode = MP_EPERM; - return MP_STREAM_ERROR; - } -} - -STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - sys_stdio_obj_t *self = self_in; - if (self->fd == STDIO_FD_OUT || self->fd == STDIO_FD_ERR) { - mp_hal_stdout_tx_strn_cooked(buf, size); - return size; - } else { - *errcode = MP_EPERM; - return MP_STREAM_ERROR; - } -} - -STATIC mp_obj_t stdio_obj___exit__(size_t n_args, const mp_obj_t *args) { - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_obj___exit__); - -// TODO gc hook to close the file if not already closed - -STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = { -#if MICROPY_PY_SYS_STDIO_BUFFER - { MP_ROM_QSTR(MP_QSTR_buffer), MP_ROM_PTR(&stdio_buffer_obj) }, -#endif - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj)}, - { MP_ROM_QSTR(MP_QSTR_readlines), MP_ROM_PTR(&mp_stream_unbuffered_readlines_obj)}, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_identity_obj) }, - { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_identity_obj) }, - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&stdio_obj___exit___obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(stdio_locals_dict, stdio_locals_dict_table); - -STATIC const mp_stream_p_t stdio_obj_stream_p = { - .read = stdio_read, - .write = stdio_write, - .is_text = true, -}; - -STATIC const mp_obj_type_t stdio_obj_type = { - { &mp_type_type }, - .name = MP_QSTR_FileIO, - // TODO .make_new? - .print = stdio_obj_print, - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &stdio_obj_stream_p, - .locals_dict = (mp_obj_dict_t*)&stdio_locals_dict, -}; - -const sys_stdio_obj_t mp_sys_stdin_obj = {{&stdio_obj_type}, .fd = STDIO_FD_IN}; -const sys_stdio_obj_t mp_sys_stdout_obj = {{&stdio_obj_type}, .fd = STDIO_FD_OUT}; -const sys_stdio_obj_t mp_sys_stderr_obj = {{&stdio_obj_type}, .fd = STDIO_FD_ERR}; - -#if MICROPY_PY_SYS_STDIO_BUFFER -STATIC mp_uint_t stdio_buffer_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { - for (uint i = 0; i < size; i++) { - ((byte*)buf)[i] = mp_hal_stdin_rx_chr(); - } - return size; -} - -STATIC mp_uint_t stdio_buffer_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - mp_hal_stdout_tx_strn(buf, size); - return size; -} - -STATIC const mp_stream_p_t stdio_buffer_obj_stream_p = { - .read = stdio_buffer_read, - .write = stdio_buffer_write, - .is_text = false, -}; - -STATIC const mp_obj_type_t stdio_buffer_obj_type = { - { &mp_type_type }, - .name = MP_QSTR_FileIO, - .print = stdio_obj_print, - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &stdio_buffer_obj_stream_p, - .locals_dict = (mp_obj_t)&stdio_locals_dict, -}; - -STATIC const sys_stdio_obj_t stdio_buffer_obj = {{&stdio_buffer_obj_type}, .fd = 0}; // fd unused -#endif diff --git a/user/mpy/micropython b/user/mpy/micropython new file mode 160000 index 0000000..d5191ed --- /dev/null +++ b/user/mpy/micropython @@ -0,0 +1 @@ +Subproject commit d5191edf7ff81f5f07243cb2a318508c1e9cc5df diff --git a/user/mpy/py/__pycache__/makeqstrdata.cpython-35.pyc b/user/mpy/py/__pycache__/makeqstrdata.cpython-35.pyc deleted file mode 100644 index a62a8c80af08d42f153c47c553710e2acbd176fd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4914 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 -#include - -#include "py/nlr.h" -#include "py/runtime.h" - -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) { - // TODO maybe take the function name as an argument so we can print nicer error messages - - if (n_kw && !takes_kw) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - mp_raise_TypeError("function does not take keyword arguments"); - } - } - - if (n_args_min == n_args_max) { - if (n_args != n_args_min) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function takes %d positional arguments but %d were given", - n_args_min, n_args)); - } - } - } else { - if (n_args < n_args_min) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function missing %d required positional arguments", - n_args_min - n_args)); - } - } else if (n_args > n_args_max) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function expected at most %d arguments, got %d", - n_args_max, n_args)); - } - } - } -} - -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) { - size_t pos_found = 0, kws_found = 0; - for (size_t i = 0; i < n_allowed; i++) { - mp_obj_t given_arg; - if (i < n_pos) { - if (allowed[i].flags & MP_ARG_KW_ONLY) { - goto extra_positional; - } - pos_found++; - given_arg = pos[i]; - } else { - mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qst), MP_MAP_LOOKUP); - if (kw == NULL) { - if (allowed[i].flags & MP_ARG_REQUIRED) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%q' argument required", allowed[i].qst)); - } - } - out_vals[i] = allowed[i].defval; - continue; - } else { - kws_found++; - given_arg = kw->value; - } - } - if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_BOOL) { - out_vals[i].u_bool = mp_obj_is_true(given_arg); - } else if ((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_INT) { - out_vals[i].u_int = mp_obj_get_int(given_arg); - } else { - assert((allowed[i].flags & MP_ARG_KIND_MASK) == MP_ARG_OBJ); - out_vals[i].u_obj = given_arg; - } - } - if (pos_found < n_pos) { - extra_positional: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - // TODO better error message - mp_raise_TypeError("extra positional arguments given"); - } - } - if (kws_found < kws->used) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - // TODO better error message - mp_raise_TypeError("extra keyword arguments given"); - } - } -} - -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) { - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, args + n_pos); - mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals); -} - -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE || _MSC_VER -NORETURN void mp_arg_error_terse_mismatch(void) { - mp_raise_TypeError("argument num/types mismatch"); -} -#endif - -#if MICROPY_CPYTHON_COMPAT -NORETURN void mp_arg_error_unimpl_kw(void) { - mp_raise_NotImplementedError("keyword argument(s) not yet implemented - use normal args instead"); -} -#endif diff --git a/user/mpy/py/asmarm.c b/user/mpy/py/asmarm.c deleted file mode 100644 index 552fdfb..0000000 --- a/user/mpy/py/asmarm.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Fabian Vogt - * 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. - */ - -#include -#include -#include - -#include "py/mpconfig.h" - -// wrapper around everything in this file -#if MICROPY_EMIT_ARM - -#include "py/asmarm.h" - -#define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000) - -void asm_arm_end_pass(asm_arm_t *as) { - if (as->base.pass == MP_ASM_PASS_EMIT) { -#ifdef __arm__ - // flush I- and D-cache - asm volatile( - "0:" - "mrc p15, 0, r15, c7, c10, 3\n" - "bne 0b\n" - "mov r0, #0\n" - "mcr p15, 0, r0, c7, c7, 0\n" - : : : "r0", "cc"); -#endif - } -} - -// Insert word into instruction flow -STATIC void emit(asm_arm_t *as, uint op) { - uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4); - if (c != NULL) { - *(uint32_t*)c = op; - } -} - -// Insert word into instruction flow, add "ALWAYS" condition code -STATIC void emit_al(asm_arm_t *as, uint op) { - emit(as, op | ASM_ARM_CC_AL); -} - -// Basic instructions without condition code -STATIC uint asm_arm_op_push(uint reglist) { - // stmfd sp!, {reglist} - return 0x92d0000 | (reglist & 0xFFFF); -} - -STATIC uint asm_arm_op_pop(uint reglist) { - // ldmfd sp!, {reglist} - return 0x8bd0000 | (reglist & 0xFFFF); -} - -STATIC uint asm_arm_op_mov_reg(uint rd, uint rn) { - // mov rd, rn - return 0x1a00000 | (rd << 12) | rn; -} - -STATIC uint asm_arm_op_mov_imm(uint rd, uint imm) { - // mov rd, #imm - return 0x3a00000 | (rd << 12) | imm; -} - -STATIC uint asm_arm_op_mvn_imm(uint rd, uint imm) { - // mvn rd, #imm - return 0x3e00000 | (rd << 12) | imm; -} - -STATIC uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) { - // add rd, rn, #imm - return 0x2800000 | (rn << 16) | (rd << 12) | (imm & 0xFF); -} - -STATIC uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) { - // add rd, rn, rm - return 0x0800000 | (rn << 16) | (rd << 12) | rm; -} - -STATIC uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) { - // sub rd, rn, #imm - return 0x2400000 | (rn << 16) | (rd << 12) | (imm & 0xFF); -} - -STATIC uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) { - // sub rd, rn, rm - return 0x0400000 | (rn << 16) | (rd << 12) | rm; -} - -STATIC uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) { - // mul rd, rm, rs - assert(rd != rm); - return 0x0000090 | (rd << 16) | (rs << 8) | rm; -} - -STATIC uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) { - // and rd, rn, rm - return 0x0000000 | (rn << 16) | (rd << 12) | rm; -} - -STATIC uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) { - // eor rd, rn, rm - return 0x0200000 | (rn << 16) | (rd << 12) | rm; -} - -STATIC uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) { - // orr rd, rn, rm - return 0x1800000 | (rn << 16) | (rd << 12) | rm; -} - -void asm_arm_bkpt(asm_arm_t *as) { - // bkpt #0 - emit_al(as, 0x1200070); -} - -// locals: -// - stored on the stack in ascending order -// - numbered 0 through num_locals-1 -// - SP points to first local -// -// | SP -// v -// l0 l1 l2 ... l(n-1) -// ^ ^ -// | low address | high address in RAM - -void asm_arm_entry(asm_arm_t *as, int num_locals) { - - if (num_locals < 0) { - num_locals = 0; - } - - as->stack_adjust = 0; - as->push_reglist = 1 << ASM_ARM_REG_R1 - | 1 << ASM_ARM_REG_R2 - | 1 << ASM_ARM_REG_R3 - | 1 << ASM_ARM_REG_R4 - | 1 << ASM_ARM_REG_R5 - | 1 << ASM_ARM_REG_R6 - | 1 << ASM_ARM_REG_R7 - | 1 << ASM_ARM_REG_R8; - - // Only adjust the stack if there are more locals than usable registers - if (num_locals > 3) { - as->stack_adjust = num_locals * 4; - // Align stack to 8 bytes - if (num_locals & 1) { - as->stack_adjust += 4; - } - } - - emit_al(as, asm_arm_op_push(as->push_reglist | 1 << ASM_ARM_REG_LR)); - if (as->stack_adjust > 0) { - emit_al(as, asm_arm_op_sub_imm(ASM_ARM_REG_SP, ASM_ARM_REG_SP, as->stack_adjust)); - } -} - -void asm_arm_exit(asm_arm_t *as) { - if (as->stack_adjust > 0) { - emit_al(as, asm_arm_op_add_imm(ASM_ARM_REG_SP, ASM_ARM_REG_SP, as->stack_adjust)); - } - - emit_al(as, asm_arm_op_pop(as->push_reglist | (1 << ASM_ARM_REG_PC))); -} - -void asm_arm_push(asm_arm_t *as, uint reglist) { - emit_al(as, asm_arm_op_push(reglist)); -} - -void asm_arm_pop(asm_arm_t *as, uint reglist) { - emit_al(as, asm_arm_op_pop(reglist)); -} - -void asm_arm_mov_reg_reg(asm_arm_t *as, uint reg_dest, uint reg_src) { - emit_al(as, asm_arm_op_mov_reg(reg_dest, reg_src)); -} - -void asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm) { - // TODO: There are more variants of immediate values - if ((imm & 0xFF) == imm) { - emit_al(as, asm_arm_op_mov_imm(rd, imm)); - } else if (imm < 0 && imm >= -256) { - // mvn is "move not", not "move negative" - emit_al(as, asm_arm_op_mvn_imm(rd, ~imm)); - } else { - //Insert immediate into code and jump over it - emit_al(as, 0x59f0000 | (rd << 12)); // ldr rd, [pc] - emit_al(as, 0xa000000); // b pc - emit(as, imm); - } -} - -void asm_arm_mov_local_reg(asm_arm_t *as, int local_num, uint rd) { - // str rd, [sp, #local_num*4] - emit_al(as, 0x58d0000 | (rd << 12) | (local_num << 2)); -} - -void asm_arm_mov_reg_local(asm_arm_t *as, uint rd, int local_num) { - // ldr rd, [sp, #local_num*4] - emit_al(as, 0x59d0000 | (rd << 12) | (local_num << 2)); -} - -void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm) { - // cmp rd, #imm - emit_al(as, 0x3500000 | (rd << 16) | (imm & 0xFF)); -} - -void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn) { - // cmp rd, rn - emit_al(as, 0x1500000 | (rd << 16) | rn); -} - -void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond) { - emit(as, asm_arm_op_mov_imm(rd, 1) | cond); // movCOND rd, #1 - emit(as, asm_arm_op_mov_imm(rd, 0) | (cond ^ (1 << 28))); // mov!COND rd, #0 -} - -void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { - // add rd, rn, rm - emit_al(as, asm_arm_op_add_reg(rd, rn, rm)); -} - -void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { - // sub rd, rn, rm - emit_al(as, asm_arm_op_sub_reg(rd, rn, rm)); -} - -void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rs, uint rm) { - // rs and rm are swapped because of restriction rd!=rm - // mul rd, rm, rs - emit_al(as, asm_arm_op_mul_reg(rd, rm, rs)); -} - -void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { - // and rd, rn, rm - emit_al(as, asm_arm_op_and_reg(rd, rn, rm)); -} - -void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { - // eor rd, rn, rm - emit_al(as, asm_arm_op_eor_reg(rd, rn, rm)); -} - -void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) { - // orr rd, rn, rm - emit_al(as, asm_arm_op_orr_reg(rd, rn, rm)); -} - -void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num) { - // add rd, sp, #local_num*4 - emit_al(as, asm_arm_op_add_imm(rd, ASM_ARM_REG_SP, local_num << 2)); -} - -void asm_arm_lsl_reg_reg(asm_arm_t *as, uint rd, uint rs) { - // mov rd, rd, lsl rs - emit_al(as, 0x1a00010 | (rd << 12) | (rs << 8) | rd); -} - -void asm_arm_asr_reg_reg(asm_arm_t *as, uint rd, uint rs) { - // mov rd, rd, asr rs - emit_al(as, 0x1a00050 | (rd << 12) | (rs << 8) | rd); -} - -void asm_arm_ldr_reg_reg(asm_arm_t *as, uint rd, uint rn, uint byte_offset) { - // ldr rd, [rn, #off] - emit_al(as, 0x5900000 | (rn << 16) | (rd << 12) | byte_offset); -} - -void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn) { - // ldrh rd, [rn] - emit_al(as, 0x1d000b0 | (rn << 16) | (rd << 12)); -} - -void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn) { - // ldrb rd, [rn] - emit_al(as, 0x5d00000 | (rn << 16) | (rd << 12)); -} - -void asm_arm_str_reg_reg(asm_arm_t *as, uint rd, uint rm, uint byte_offset) { - // str rd, [rm, #off] - emit_al(as, 0x5800000 | (rm << 16) | (rd << 12) | byte_offset); -} - -void asm_arm_strh_reg_reg(asm_arm_t *as, uint rd, uint rm) { - // strh rd, [rm] - emit_al(as, 0x1c000b0 | (rm << 16) | (rd << 12)); -} - -void asm_arm_strb_reg_reg(asm_arm_t *as, uint rd, uint rm) { - // strb rd, [rm] - emit_al(as, 0x5c00000 | (rm << 16) | (rd << 12)); -} - -void asm_arm_str_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) { - // str rd, [rm, rn, lsl #2] - emit_al(as, 0x7800100 | (rm << 16) | (rd << 12) | rn); -} - -void asm_arm_strh_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) { - // strh doesn't support scaled register index - emit_al(as, 0x1a00080 | (ASM_ARM_REG_R8 << 12) | rn); // mov r8, rn, lsl #1 - emit_al(as, 0x18000b0 | (rm << 16) | (rd << 12) | ASM_ARM_REG_R8); // strh rd, [rm, r8] -} - -void asm_arm_strb_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) { - // strb rd, [rm, rn] - emit_al(as, 0x7c00000 | (rm << 16) | (rd << 12) | rn); -} - -void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label) { - assert(label < as->base.max_num_labels); - mp_uint_t dest = as->base.label_offsets[label]; - mp_int_t rel = dest - as->base.code_offset; - rel -= 8; // account for instruction prefetch, PC is 8 bytes ahead of this instruction - rel >>= 2; // in ARM mode the branch target is 32-bit aligned, so the 2 LSB are omitted - - if (SIGNED_FIT24(rel)) { - emit(as, cond | 0xa000000 | (rel & 0xffffff)); - } else { - printf("asm_arm_bcc: branch does not fit in 24 bits\n"); - } -} - -void asm_arm_b_label(asm_arm_t *as, uint label) { - asm_arm_bcc_label(as, ASM_ARM_CC_AL, label); -} - -void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp) { - // If the table offset fits into the ldr instruction - if (fun_id < (0x1000 / 4)) { - emit_al(as, asm_arm_op_mov_reg(ASM_ARM_REG_LR, ASM_ARM_REG_PC)); // mov lr, pc - emit_al(as, 0x597f000 | (fun_id << 2)); // ldr pc, [r7, #fun_id*4] - return; - } - - emit_al(as, 0x59f0004 | (reg_temp << 12)); // ldr rd, [pc, #4] - // Set lr after fun_ptr - emit_al(as, asm_arm_op_add_imm(ASM_ARM_REG_LR, ASM_ARM_REG_PC, 4)); // add lr, pc, #4 - emit_al(as, asm_arm_op_mov_reg(ASM_ARM_REG_PC, reg_temp)); // mov pc, reg_temp - emit(as, (uint) fun_ptr); -} - -#endif // MICROPY_EMIT_ARM diff --git a/user/mpy/py/asmarm.h b/user/mpy/py/asmarm.h deleted file mode 100644 index a302b15..0000000 --- a/user/mpy/py/asmarm.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Fabian Vogt - * 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_ASMARM_H -#define MICROPY_INCLUDED_PY_ASMARM_H - -#include "py/misc.h" -#include "py/asmbase.h" - -#define ASM_ARM_REG_R0 (0) -#define ASM_ARM_REG_R1 (1) -#define ASM_ARM_REG_R2 (2) -#define ASM_ARM_REG_R3 (3) -#define ASM_ARM_REG_R4 (4) -#define ASM_ARM_REG_R5 (5) -#define ASM_ARM_REG_R6 (6) -#define ASM_ARM_REG_R7 (7) -#define ASM_ARM_REG_R8 (8) -#define ASM_ARM_REG_R9 (9) -#define ASM_ARM_REG_R10 (10) -#define ASM_ARM_REG_R11 (11) -#define ASM_ARM_REG_R12 (12) -#define ASM_ARM_REG_R13 (13) -#define ASM_ARM_REG_R14 (14) -#define ASM_ARM_REG_R15 (15) -#define ASM_ARM_REG_SP (ASM_ARM_REG_R13) -#define ASM_ARM_REG_LR (ASM_ARM_REG_R14) -#define ASM_ARM_REG_PC (ASM_ARM_REG_R15) - -#define ASM_ARM_CC_EQ (0x0 << 28) -#define ASM_ARM_CC_NE (0x1 << 28) -#define ASM_ARM_CC_CS (0x2 << 28) -#define ASM_ARM_CC_CC (0x3 << 28) -#define ASM_ARM_CC_MI (0x4 << 28) -#define ASM_ARM_CC_PL (0x5 << 28) -#define ASM_ARM_CC_VS (0x6 << 28) -#define ASM_ARM_CC_VC (0x7 << 28) -#define ASM_ARM_CC_HI (0x8 << 28) -#define ASM_ARM_CC_LS (0x9 << 28) -#define ASM_ARM_CC_GE (0xa << 28) -#define ASM_ARM_CC_LT (0xb << 28) -#define ASM_ARM_CC_GT (0xc << 28) -#define ASM_ARM_CC_LE (0xd << 28) -#define ASM_ARM_CC_AL (0xe << 28) - -typedef struct _asm_arm_t { - mp_asm_base_t base; - uint push_reglist; - uint stack_adjust; -} asm_arm_t; - -void asm_arm_end_pass(asm_arm_t *as); - -void asm_arm_entry(asm_arm_t *as, int num_locals); -void asm_arm_exit(asm_arm_t *as); - -void asm_arm_bkpt(asm_arm_t *as); - -// mov -void asm_arm_mov_reg_reg(asm_arm_t *as, uint reg_dest, uint reg_src); -void asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm); -void asm_arm_mov_local_reg(asm_arm_t *as, int local_num, uint rd); -void asm_arm_mov_reg_local(asm_arm_t *as, uint rd, int local_num); -void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond); - -// compare -void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm); -void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn); - -// arithmetic -void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); -void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); -void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); -void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); -void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); -void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm); -void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num); -void asm_arm_lsl_reg_reg(asm_arm_t *as, uint rd, uint rs); -void asm_arm_asr_reg_reg(asm_arm_t *as, uint rd, uint rs); - -// memory -void asm_arm_ldr_reg_reg(asm_arm_t *as, uint rd, uint rn, uint byte_offset); -void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn); -void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn); -void asm_arm_str_reg_reg(asm_arm_t *as, uint rd, uint rm, uint byte_offset); -void asm_arm_strh_reg_reg(asm_arm_t *as, uint rd, uint rm); -void asm_arm_strb_reg_reg(asm_arm_t *as, uint rd, uint rm); -// store to array -void asm_arm_str_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn); -void asm_arm_strh_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn); -void asm_arm_strb_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn); - -// stack -void asm_arm_push(asm_arm_t *as, uint reglist); -void asm_arm_pop(asm_arm_t *as, uint reglist); - -// control flow -void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label); -void asm_arm_b_label(asm_arm_t *as, uint label); -void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp); - -#if GENERIC_ASM_API - -// The following macros provide a (mostly) arch-independent API to -// generate native code, and are used by the native emitter. - -#define ASM_WORD_SIZE (4) - -#define REG_RET ASM_ARM_REG_R0 -#define REG_ARG_1 ASM_ARM_REG_R0 -#define REG_ARG_2 ASM_ARM_REG_R1 -#define REG_ARG_3 ASM_ARM_REG_R2 -#define REG_ARG_4 ASM_ARM_REG_R3 - -#define REG_TEMP0 ASM_ARM_REG_R0 -#define REG_TEMP1 ASM_ARM_REG_R1 -#define REG_TEMP2 ASM_ARM_REG_R2 - -#define REG_LOCAL_1 ASM_ARM_REG_R4 -#define REG_LOCAL_2 ASM_ARM_REG_R5 -#define REG_LOCAL_3 ASM_ARM_REG_R6 -#define REG_LOCAL_NUM (3) - -#define ASM_T asm_arm_t -#define ASM_END_PASS asm_arm_end_pass -#define ASM_ENTRY asm_arm_entry -#define ASM_EXIT asm_arm_exit - -#define ASM_JUMP asm_arm_b_label -#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ - do { \ - asm_arm_cmp_reg_i8(as, reg, 0); \ - asm_arm_bcc_label(as, ASM_ARM_CC_EQ, label); \ - } while (0) -#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ - do { \ - asm_arm_cmp_reg_i8(as, reg, 0); \ - asm_arm_bcc_label(as, ASM_ARM_CC_NE, label); \ - } while (0) -#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ - do { \ - asm_arm_cmp_reg_reg(as, reg1, reg2); \ - asm_arm_bcc_label(as, ASM_ARM_CC_EQ, label); \ - } while (0) -#define ASM_CALL_IND(as, ptr, idx) asm_arm_bl_ind(as, ptr, idx, ASM_ARM_REG_R3) - -#define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_arm_mov_local_reg(as, (local_num), (reg)) -#define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_arm_mov_reg_i32(as, (reg), (imm)) -#define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_arm_mov_reg_i32(as, (reg), (imm)) -#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ - do { \ - asm_arm_mov_reg_i32(as, (reg_temp), (imm)); \ - asm_arm_mov_local_reg(as, (local_num), (reg_temp)); \ - } while (false) -#define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_arm_mov_reg_local(as, (reg), (local_num)) -#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_arm_mov_reg_reg((as), (reg_dest), (reg_src)) -#define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_arm_mov_reg_local_addr(as, (reg), (local_num)) - -#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_arm_lsl_reg_reg((as), (reg_dest), (reg_shift)) -#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_arm_asr_reg_reg((as), (reg_dest), (reg_shift)) -#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_arm_orr_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_arm_eor_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_arm_and_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_arm_add_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_arm_sub_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_arm_mul_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_src)) - -#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_arm_ldr_reg_reg((as), (reg_dest), (reg_base), 0) -#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_arm_ldr_reg_reg((as), (reg_dest), (reg_base), 4 * (word_offset)) -#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_arm_ldrb_reg_reg((as), (reg_dest), (reg_base)) -#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_arm_ldrh_reg_reg((as), (reg_dest), (reg_base)) -#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_arm_ldr_reg_reg((as), (reg_dest), (reg_base), 0) - -#define ASM_STORE_REG_REG(as, reg_value, reg_base) asm_arm_str_reg_reg((as), (reg_value), (reg_base), 0) -#define ASM_STORE_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_arm_str_reg_reg((as), (reg_dest), (reg_base), 4 * (word_offset)) -#define ASM_STORE8_REG_REG(as, reg_value, reg_base) asm_arm_strb_reg_reg((as), (reg_value), (reg_base)) -#define ASM_STORE16_REG_REG(as, reg_value, reg_base) asm_arm_strh_reg_reg((as), (reg_value), (reg_base)) -#define ASM_STORE32_REG_REG(as, reg_value, reg_base) asm_arm_str_reg_reg((as), (reg_value), (reg_base), 0) - -#endif // GENERIC_ASM_API - -#endif // MICROPY_INCLUDED_PY_ASMARM_H diff --git a/user/mpy/py/asmbase.c b/user/mpy/py/asmbase.c deleted file mode 100644 index c941e91..0000000 --- a/user/mpy/py/asmbase.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include - -#include "py/obj.h" -#include "py/misc.h" -#include "py/asmbase.h" - -#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM - -void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels) { - as->max_num_labels = max_num_labels; - as->label_offsets = m_new(size_t, max_num_labels); -} - -void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code) { - if (free_code) { - MP_PLAT_FREE_EXEC(as->code_base, as->code_size); - } - m_del(size_t, as->label_offsets, as->max_num_labels); -} - -void mp_asm_base_start_pass(mp_asm_base_t *as, int pass) { - if (pass == MP_ASM_PASS_COMPUTE) { - // reset all labels - memset(as->label_offsets, -1, as->max_num_labels * sizeof(size_t)); - } else if (pass == MP_ASM_PASS_EMIT) { - // allocating executable RAM is platform specific - MP_PLAT_ALLOC_EXEC(as->code_offset, (void**)&as->code_base, &as->code_size); - assert(as->code_base != NULL); - } - as->pass = pass; - as->code_offset = 0; -} - -// all functions must go through this one to emit bytes -// if as->pass < MP_ASM_PASS_EMIT, then this function just counts the number -// of bytes needed and returns NULL, and callers should not store any data -uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write) { - uint8_t *c = NULL; - if (as->pass == MP_ASM_PASS_EMIT) { - assert(as->code_offset + num_bytes_to_write <= as->code_size); - c = as->code_base + as->code_offset; - } - as->code_offset += num_bytes_to_write; - return c; -} - -void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label) { - assert(label < as->max_num_labels); - if (as->pass < MP_ASM_PASS_EMIT) { - // assign label offset - assert(as->label_offsets[label] == (size_t)-1); - as->label_offsets[label] = as->code_offset; - } else { - // ensure label offset has not changed from PASS_COMPUTE to PASS_EMIT - assert(as->label_offsets[label] == as->code_offset); - } -} - -// align must be a multiple of 2 -void mp_asm_base_align(mp_asm_base_t* as, unsigned int align) { - as->code_offset = (as->code_offset + align - 1) & (~(align - 1)); -} - -// this function assumes a little endian machine -void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val) { - uint8_t *c = mp_asm_base_get_cur_to_write_bytes(as, bytesize); - if (c != NULL) { - for (unsigned int i = 0; i < bytesize; i++) { - *c++ = val; - val >>= 8; - } - } -} - -#endif // MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM diff --git a/user/mpy/py/asmbase.h b/user/mpy/py/asmbase.h deleted file mode 100644 index d2b4038..0000000 --- a/user/mpy/py/asmbase.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_ASMBASE_H -#define MICROPY_INCLUDED_PY_ASMBASE_H - -#include -#include - -#define MP_ASM_PASS_COMPUTE (1) -#define MP_ASM_PASS_EMIT (2) - -typedef struct _mp_asm_base_t { - int pass; - size_t code_offset; - size_t code_size; - uint8_t *code_base; - - size_t max_num_labels; - size_t *label_offsets; -} mp_asm_base_t; - -void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels); -void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code); -void mp_asm_base_start_pass(mp_asm_base_t *as, int pass); -uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write); -void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label); -void mp_asm_base_align(mp_asm_base_t* as, unsigned int align); -void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val); - -static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) { - return as->code_offset; -} - -static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) { - return as->code_size; -} - -static inline void *mp_asm_base_get_code(mp_asm_base_t *as) { - #if defined(MP_PLAT_COMMIT_EXEC) - return MP_PLAT_COMMIT_EXEC(as->code_base, as->code_size); - #else - return as->code_base; - #endif -} - -#endif // MICROPY_INCLUDED_PY_ASMBASE_H diff --git a/user/mpy/py/asmthumb.c b/user/mpy/py/asmthumb.c deleted file mode 100644 index 4360a6a..0000000 --- a/user/mpy/py/asmthumb.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpconfig.h" - -// wrapper around everything in this file -#if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB - -#include "py/asmthumb.h" - -#define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0) -#define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0) -#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) -#define SIGNED_FIT9(x) (((x) & 0xffffff00) == 0) || (((x) & 0xffffff00) == 0xffffff00) -#define SIGNED_FIT12(x) (((x) & 0xfffff800) == 0) || (((x) & 0xfffff800) == 0xfffff800) -#define SIGNED_FIT23(x) (((x) & 0xffc00000) == 0) || (((x) & 0xffc00000) == 0xffc00000) - -static inline byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int n) { - return mp_asm_base_get_cur_to_write_bytes(&as->base, n); -} - -void asm_thumb_end_pass(asm_thumb_t *as) { - (void)as; - // could check labels are resolved... - - #if defined(MCU_SERIES_F7) - if (as->base.pass == MP_ASM_PASS_EMIT) { - // flush D-cache, so the code emitted is stored in memory - SCB_CleanDCache_by_Addr((uint32_t*)as->base.code_base, as->base.code_size); - // invalidate I-cache - SCB_InvalidateICache(); - } - #endif -} - -/* -STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) { - byte *c = asm_thumb_get_cur_to_write_bytes(as, 1); - c[0] = b1; -} -*/ - -/* -#define IMM32_L0(x) ((x) & 0xff) -#define IMM32_L1(x) (((x) >> 8) & 0xff) -#define IMM32_L2(x) (((x) >> 16) & 0xff) -#define IMM32_L3(x) (((x) >> 24) & 0xff) - -STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) { - byte *c = asm_thumb_get_cur_to_write_bytes(as, 4); - c[0] = IMM32_L0(w32); - c[1] = IMM32_L1(w32); - c[2] = IMM32_L2(w32); - c[3] = IMM32_L3(w32); -} -*/ - -// rlolist is a bit map indicating desired lo-registers -#define OP_PUSH_RLIST(rlolist) (0xb400 | (rlolist)) -#define OP_PUSH_RLIST_LR(rlolist) (0xb400 | 0x0100 | (rlolist)) -#define OP_POP_RLIST(rlolist) (0xbc00 | (rlolist)) -#define OP_POP_RLIST_PC(rlolist) (0xbc00 | 0x0100 | (rlolist)) - -#define OP_ADD_SP(num_words) (0xb000 | (num_words)) -#define OP_SUB_SP(num_words) (0xb080 | (num_words)) - -// locals: -// - stored on the stack in ascending order -// - numbered 0 through num_locals-1 -// - SP points to first local -// -// | SP -// v -// l0 l1 l2 ... l(n-1) -// ^ ^ -// | low address | high address in RAM - -void asm_thumb_entry(asm_thumb_t *as, int num_locals) { - // work out what to push and how many extra spaces to reserve on stack - // so that we have enough for all locals and it's aligned an 8-byte boundary - // we push extra regs (r1, r2, r3) to help do the stack adjustment - // we probably should just always subtract from sp, since this would be more efficient - // for push rlist, lowest numbered register at the lowest address - uint reglist; - uint stack_adjust; - if (num_locals < 0) { - num_locals = 0; - } - // don't pop r0 because it's used for return value - switch (num_locals) { - case 0: - reglist = 0xf2; - stack_adjust = 0; - break; - - case 1: - reglist = 0xf2; - stack_adjust = 0; - break; - - case 2: - reglist = 0xfe; - stack_adjust = 0; - break; - - case 3: - reglist = 0xfe; - stack_adjust = 0; - break; - - default: - reglist = 0xfe; - stack_adjust = ((num_locals - 3) + 1) & (~1); - break; - } - asm_thumb_op16(as, OP_PUSH_RLIST_LR(reglist)); - if (stack_adjust > 0) { - asm_thumb_op16(as, OP_SUB_SP(stack_adjust)); - } - as->push_reglist = reglist; - as->stack_adjust = stack_adjust; -} - -void asm_thumb_exit(asm_thumb_t *as) { - if (as->stack_adjust > 0) { - asm_thumb_op16(as, OP_ADD_SP(as->stack_adjust)); - } - asm_thumb_op16(as, OP_POP_RLIST_PC(as->push_reglist)); -} - -STATIC mp_uint_t get_label_dest(asm_thumb_t *as, uint label) { - assert(label < as->base.max_num_labels); - return as->base.label_offsets[label]; -} - -void asm_thumb_op16(asm_thumb_t *as, uint op) { - byte *c = asm_thumb_get_cur_to_write_bytes(as, 2); - if (c != NULL) { - // little endian - c[0] = op; - c[1] = op >> 8; - } -} - -void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2) { - byte *c = asm_thumb_get_cur_to_write_bytes(as, 4); - if (c != NULL) { - // little endian, op1 then op2 - c[0] = op1; - c[1] = op1 >> 8; - c[2] = op2; - c[3] = op2 >> 8; - } -} - -#define OP_FORMAT_4(op, rlo_dest, rlo_src) ((op) | ((rlo_src) << 3) | (rlo_dest)) - -void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src) { - assert(rlo_dest < ASM_THUMB_REG_R8); - assert(rlo_src < ASM_THUMB_REG_R8); - asm_thumb_op16(as, OP_FORMAT_4(op, rlo_dest, rlo_src)); -} - -void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src) { - uint op_lo; - if (reg_src < 8) { - op_lo = reg_src << 3; - } else { - op_lo = 0x40 | ((reg_src - 8) << 3); - } - if (reg_dest < 8) { - op_lo |= reg_dest; - } else { - op_lo |= 0x80 | (reg_dest - 8); - } - // mov reg_dest, reg_src - asm_thumb_op16(as, 0x4600 | op_lo); -} - -// if loading lo half with movw, the i16 value will be zero extended into the r32 register! -void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) { - assert(reg_dest < ASM_THUMB_REG_R15); - // mov[wt] reg_dest, #i16_src - asm_thumb_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), ((i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff)); -} - -#define OP_B_N(byte_offset) (0xe000 | (((byte_offset) >> 1) & 0x07ff)) - -bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction - asm_thumb_op16(as, OP_B_N(rel)); - return as->base.pass != MP_ASM_PASS_EMIT || SIGNED_FIT12(rel); -} - -#define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff)) - -// all these bit arithmetics need coverage testing! -#define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f)) -#define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff)) - -bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction - if (!wide) { - asm_thumb_op16(as, OP_BCC_N(cond, rel)); - return as->base.pass != MP_ASM_PASS_EMIT || SIGNED_FIT9(rel); - } else { - asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel)); - return true; - } -} - -#define OP_BL_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff)) -#define OP_BL_LO(byte_offset) (0xf800 | (((byte_offset) >> 1) & 0x07ff)) - -bool asm_thumb_bl_label(asm_thumb_t *as, uint label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction - asm_thumb_op32(as, OP_BL_HI(rel), OP_BL_LO(rel)); - return as->base.pass != MP_ASM_PASS_EMIT || SIGNED_FIT23(rel); -} - -void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32) { - // movw, movt does it in 8 bytes - // ldr [pc, #], dw does it in 6 bytes, but we might not reach to end of code for dw - - asm_thumb_mov_reg_i16(as, ASM_THUMB_OP_MOVW, reg_dest, i32); - asm_thumb_mov_reg_i16(as, ASM_THUMB_OP_MOVT, reg_dest, i32 >> 16); -} - -void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32) { - if (reg_dest < 8 && UNSIGNED_FIT8(i32)) { - asm_thumb_mov_rlo_i8(as, reg_dest, i32); - } else if (UNSIGNED_FIT16(i32)) { - asm_thumb_mov_reg_i16(as, ASM_THUMB_OP_MOVW, reg_dest, i32); - } else { - asm_thumb_mov_reg_i32(as, reg_dest, i32); - } -} - -// i32 is stored as a full word in the code, and aligned to machine-word boundary -// TODO this is very inefficient, improve it! -void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32) { - // align on machine-word + 2 - if ((as->base.code_offset & 3) == 0) { - asm_thumb_op16(as, ASM_THUMB_OP_NOP); - } - // jump over the i32 value (instruction prefetch adds 2 to PC) - asm_thumb_op16(as, OP_B_N(2)); - // store i32 on machine-word aligned boundary - mp_asm_base_data(&as->base, 4, i32); - // do the actual load of the i32 value - asm_thumb_mov_reg_i32_optimised(as, reg_dest, i32); -} - -#define OP_STR_TO_SP_OFFSET(rlo_dest, word_offset) (0x9000 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) -#define OP_LDR_FROM_SP_OFFSET(rlo_dest, word_offset) (0x9800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) - -void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num, uint rlo_src) { - assert(rlo_src < ASM_THUMB_REG_R8); - int word_offset = local_num; - assert(as->base.pass < MP_ASM_PASS_EMIT || word_offset >= 0); - asm_thumb_op16(as, OP_STR_TO_SP_OFFSET(rlo_src, word_offset)); -} - -void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num) { - assert(rlo_dest < ASM_THUMB_REG_R8); - int word_offset = local_num; - assert(as->base.pass < MP_ASM_PASS_EMIT || word_offset >= 0); - asm_thumb_op16(as, OP_LDR_FROM_SP_OFFSET(rlo_dest, word_offset)); -} - -#define OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset) (0xa800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) - -void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num) { - assert(rlo_dest < ASM_THUMB_REG_R8); - int word_offset = local_num; - assert(as->base.pass < MP_ASM_PASS_EMIT || word_offset >= 0); - asm_thumb_op16(as, OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset)); -} - -// this could be wrong, because it should have a range of +/- 16MiB... -#define OP_BW_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff)) -#define OP_BW_LO(byte_offset) (0xb800 | (((byte_offset) >> 1) & 0x07ff)) - -void asm_thumb_b_label(asm_thumb_t *as, uint label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction - if (dest != (mp_uint_t)-1 && rel <= -4) { - // is a backwards jump, so we know the size of the jump on the first pass - // calculate rel assuming 12 bit relative jump - if (SIGNED_FIT12(rel)) { - asm_thumb_op16(as, OP_B_N(rel)); - } else { - goto large_jump; - } - } else { - // is a forwards jump, so need to assume it's large - large_jump: - asm_thumb_op32(as, OP_BW_HI(rel), OP_BW_LO(rel)); - } -} - -void asm_thumb_bcc_label(asm_thumb_t *as, int cond, uint label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction - if (dest != (mp_uint_t)-1 && rel <= -4) { - // is a backwards jump, so we know the size of the jump on the first pass - // calculate rel assuming 9 bit relative jump - if (SIGNED_FIT9(rel)) { - asm_thumb_op16(as, OP_BCC_N(cond, rel)); - } else { - goto large_jump; - } - } else { - // is a forwards jump, so need to assume it's large - large_jump: - asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel)); - } -} - -#define OP_BLX(reg) (0x4780 | ((reg) << 3)) -#define OP_SVC(arg) (0xdf00 | (arg)) - -void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp) { - /* TODO make this use less bytes - uint rlo_base = ASM_THUMB_REG_R3; - uint rlo_dest = ASM_THUMB_REG_R7; - uint word_offset = 4; - asm_thumb_op16(as, 0x0000); - asm_thumb_op16(as, 0x6800 | (word_offset << 6) | (rlo_base << 3) | rlo_dest); // ldr rlo_dest, [rlo_base, #offset] - asm_thumb_op16(as, 0x4780 | (ASM_THUMB_REG_R9 << 3)); // blx reg - */ - - if (fun_id < 32) { - // load ptr to function from table, indexed by fun_id (must be in range 0-31); 4 bytes - asm_thumb_op16(as, ASM_THUMB_FORMAT_9_10_ENCODE(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, reg_temp, ASM_THUMB_REG_R7, fun_id)); - asm_thumb_op16(as, OP_BLX(reg_temp)); - } else { - // load ptr to function into register using immediate; 6 bytes - asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr); - asm_thumb_op16(as, OP_BLX(reg_temp)); - } -} - -#endif // MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB diff --git a/user/mpy/py/asmthumb.h b/user/mpy/py/asmthumb.h deleted file mode 100644 index 7070e03..0000000 --- a/user/mpy/py/asmthumb.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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_ASMTHUMB_H -#define MICROPY_INCLUDED_PY_ASMTHUMB_H - -#include "py/misc.h" -#include "py/asmbase.h" - -#define ASM_THUMB_REG_R0 (0) -#define ASM_THUMB_REG_R1 (1) -#define ASM_THUMB_REG_R2 (2) -#define ASM_THUMB_REG_R3 (3) -#define ASM_THUMB_REG_R4 (4) -#define ASM_THUMB_REG_R5 (5) -#define ASM_THUMB_REG_R6 (6) -#define ASM_THUMB_REG_R7 (7) -#define ASM_THUMB_REG_R8 (8) -#define ASM_THUMB_REG_R9 (9) -#define ASM_THUMB_REG_R10 (10) -#define ASM_THUMB_REG_R11 (11) -#define ASM_THUMB_REG_R12 (12) -#define ASM_THUMB_REG_R13 (13) -#define ASM_THUMB_REG_R14 (14) -#define ASM_THUMB_REG_R15 (15) -#define ASM_THUMB_REG_LR (REG_R14) - -#define ASM_THUMB_CC_EQ (0x0) -#define ASM_THUMB_CC_NE (0x1) -#define ASM_THUMB_CC_CS (0x2) -#define ASM_THUMB_CC_CC (0x3) -#define ASM_THUMB_CC_MI (0x4) -#define ASM_THUMB_CC_PL (0x5) -#define ASM_THUMB_CC_VS (0x6) -#define ASM_THUMB_CC_VC (0x7) -#define ASM_THUMB_CC_HI (0x8) -#define ASM_THUMB_CC_LS (0x9) -#define ASM_THUMB_CC_GE (0xa) -#define ASM_THUMB_CC_LT (0xb) -#define ASM_THUMB_CC_GT (0xc) -#define ASM_THUMB_CC_LE (0xd) - -typedef struct _asm_thumb_t { - mp_asm_base_t base; - uint32_t push_reglist; - uint32_t stack_adjust; -} asm_thumb_t; - -void asm_thumb_end_pass(asm_thumb_t *as); - -void asm_thumb_entry(asm_thumb_t *as, int num_locals); -void asm_thumb_exit(asm_thumb_t *as); - -// argument order follows ARM, in general dest is first -// note there is a difference between movw and mov.w, and many others! - -#define ASM_THUMB_OP_IT (0xbf00) -#define ASM_THUMB_OP_ITE_EQ (0xbf0c) -#define ASM_THUMB_OP_ITE_CS (0xbf2c) -#define ASM_THUMB_OP_ITE_MI (0xbf4c) -#define ASM_THUMB_OP_ITE_VS (0xbf6c) -#define ASM_THUMB_OP_ITE_HI (0xbf8c) -#define ASM_THUMB_OP_ITE_GE (0xbfac) -#define ASM_THUMB_OP_ITE_GT (0xbfcc) - -#define ASM_THUMB_OP_NOP (0xbf00) -#define ASM_THUMB_OP_WFI (0xbf30) -#define ASM_THUMB_OP_CPSID_I (0xb672) // cpsid i, disable irq -#define ASM_THUMB_OP_CPSIE_I (0xb662) // cpsie i, enable irq - -void asm_thumb_op16(asm_thumb_t *as, uint op); -void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2); - -static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask) - { asm_thumb_op16(as, ASM_THUMB_OP_IT | (cc << 4) | mask); } - -// FORMAT 1: move shifted register - -#define ASM_THUMB_FORMAT_1_LSL (0x0000) -#define ASM_THUMB_FORMAT_1_LSR (0x0800) -#define ASM_THUMB_FORMAT_1_ASR (0x1000) - -#define ASM_THUMB_FORMAT_1_ENCODE(op, rlo_dest, rlo_src, offset) \ - ((op) | ((offset) << 6) | ((rlo_src) << 3) | (rlo_dest)) - -static inline void asm_thumb_format_1(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, uint offset) { - assert(rlo_dest < ASM_THUMB_REG_R8); - assert(rlo_src < ASM_THUMB_REG_R8); - asm_thumb_op16(as, ASM_THUMB_FORMAT_1_ENCODE(op, rlo_dest, rlo_src, offset)); -} - -// FORMAT 2: add/subtract - -#define ASM_THUMB_FORMAT_2_ADD (0x1800) -#define ASM_THUMB_FORMAT_2_SUB (0x1a00) -#define ASM_THUMB_FORMAT_2_REG_OPERAND (0x0000) -#define ASM_THUMB_FORMAT_2_IMM_OPERAND (0x0400) - -#define ASM_THUMB_FORMAT_2_ENCODE(op, rlo_dest, rlo_src, src_b) \ - ((op) | ((src_b) << 6) | ((rlo_src) << 3) | (rlo_dest)) - -static inline void asm_thumb_format_2(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src, int src_b) { - assert(rlo_dest < ASM_THUMB_REG_R8); - assert(rlo_src < ASM_THUMB_REG_R8); - asm_thumb_op16(as, ASM_THUMB_FORMAT_2_ENCODE(op, rlo_dest, rlo_src, src_b)); -} - -static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) - { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b); } -static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) - { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src); } -static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) - { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b); } -static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) - { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src); } - -// FORMAT 3: move/compare/add/subtract immediate -// These instructions all do zero extension of the i8 value - -#define ASM_THUMB_FORMAT_3_MOV (0x2000) -#define ASM_THUMB_FORMAT_3_CMP (0x2800) -#define ASM_THUMB_FORMAT_3_ADD (0x3000) -#define ASM_THUMB_FORMAT_3_SUB (0x3800) - -#define ASM_THUMB_FORMAT_3_ENCODE(op, rlo, i8) ((op) | ((rlo) << 8) | (i8)) - -static inline void asm_thumb_format_3(asm_thumb_t *as, uint op, uint rlo, int i8) { - assert(rlo < ASM_THUMB_REG_R8); - asm_thumb_op16(as, ASM_THUMB_FORMAT_3_ENCODE(op, rlo, i8)); -} - -static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_MOV, rlo, i8); } -static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_CMP, rlo, i8); } -static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_ADD, rlo, i8); } -static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_SUB, rlo, i8); } - -// FORMAT 4: ALU operations - -#define ASM_THUMB_FORMAT_4_AND (0x4000) -#define ASM_THUMB_FORMAT_4_EOR (0x4040) -#define ASM_THUMB_FORMAT_4_LSL (0x4080) -#define ASM_THUMB_FORMAT_4_LSR (0x40c0) -#define ASM_THUMB_FORMAT_4_ASR (0x4100) -#define ASM_THUMB_FORMAT_4_ADC (0x4140) -#define ASM_THUMB_FORMAT_4_SBC (0x4180) -#define ASM_THUMB_FORMAT_4_ROR (0x41c0) -#define ASM_THUMB_FORMAT_4_TST (0x4200) -#define ASM_THUMB_FORMAT_4_NEG (0x4240) -#define ASM_THUMB_FORMAT_4_CMP (0x4280) -#define ASM_THUMB_FORMAT_4_CMN (0x42c0) -#define ASM_THUMB_FORMAT_4_ORR (0x4300) -#define ASM_THUMB_FORMAT_4_MUL (0x4340) -#define ASM_THUMB_FORMAT_4_BIC (0x4380) -#define ASM_THUMB_FORMAT_4_MVN (0x43c0) - -void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src); - -static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src) { asm_thumb_format_4(as, ASM_THUMB_FORMAT_4_CMP, rlo_dest, rlo_src); } - -// FORMAT 9: load/store with immediate offset -// For word transfers the offset must be aligned, and >>2 - -// FORMAT 10: load/store halfword -// The offset must be aligned, and >>1 -// The load is zero extended into the register - -#define ASM_THUMB_FORMAT_9_STR (0x6000) -#define ASM_THUMB_FORMAT_9_LDR (0x6800) -#define ASM_THUMB_FORMAT_9_WORD_TRANSFER (0x0000) -#define ASM_THUMB_FORMAT_9_BYTE_TRANSFER (0x1000) - -#define ASM_THUMB_FORMAT_10_STRH (0x8000) -#define ASM_THUMB_FORMAT_10_LDRH (0x8800) - -#define ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset) \ - ((op) | (((offset) << 6) & 0x07c0) | ((rlo_base) << 3) | (rlo_dest)) - -static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_base, uint offset) - { asm_thumb_op16(as, ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset)); } - -static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint word_offset) - { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_src, rlo_base, word_offset); } -static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER, rlo_src, rlo_base, byte_offset); } -static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_STRH, rlo_src, rlo_base, byte_offset); } -static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint word_offset) - { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_dest, rlo_base, word_offset); } -static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER , rlo_dest, rlo_base, byte_offset); } -static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) - { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_LDRH, rlo_dest, rlo_base, byte_offset); } - -// TODO convert these to above format style - -#define ASM_THUMB_OP_MOVW (0xf240) -#define ASM_THUMB_OP_MOVT (0xf2c0) - -void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src); -void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src); - -// these return true if the destination is in range, false otherwise -bool asm_thumb_b_n_label(asm_thumb_t *as, uint label); -bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide); -bool asm_thumb_bl_label(asm_thumb_t *as, uint label); - -void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32_src); // convenience -void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32_src); // convenience -void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32); // convenience -void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num_dest, uint rlo_src); // convenience -void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num); // convenience -void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num); // convenience - -void asm_thumb_b_label(asm_thumb_t *as, uint label); // convenience: picks narrow or wide branch -void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); // convenience: picks narrow or wide branch -void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); // convenience - -#if GENERIC_ASM_API - -// The following macros provide a (mostly) arch-independent API to -// generate native code, and are used by the native emitter. - -#define ASM_WORD_SIZE (4) - -#define REG_RET ASM_THUMB_REG_R0 -#define REG_ARG_1 ASM_THUMB_REG_R0 -#define REG_ARG_2 ASM_THUMB_REG_R1 -#define REG_ARG_3 ASM_THUMB_REG_R2 -#define REG_ARG_4 ASM_THUMB_REG_R3 -// rest of args go on stack - -#define REG_TEMP0 ASM_THUMB_REG_R0 -#define REG_TEMP1 ASM_THUMB_REG_R1 -#define REG_TEMP2 ASM_THUMB_REG_R2 - -#define REG_LOCAL_1 ASM_THUMB_REG_R4 -#define REG_LOCAL_2 ASM_THUMB_REG_R5 -#define REG_LOCAL_3 ASM_THUMB_REG_R6 -#define REG_LOCAL_NUM (3) - -#define ASM_T asm_thumb_t -#define ASM_END_PASS asm_thumb_end_pass -#define ASM_ENTRY asm_thumb_entry -#define ASM_EXIT asm_thumb_exit - -#define ASM_JUMP asm_thumb_b_label -#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ - do { \ - asm_thumb_cmp_rlo_i8(as, reg, 0); \ - asm_thumb_bcc_label(as, ASM_THUMB_CC_EQ, label); \ - } while (0) -#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ - do { \ - asm_thumb_cmp_rlo_i8(as, reg, 0); \ - asm_thumb_bcc_label(as, ASM_THUMB_CC_NE, label); \ - } while (0) -#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ - do { \ - asm_thumb_cmp_rlo_rlo(as, reg1, reg2); \ - asm_thumb_bcc_label(as, ASM_THUMB_CC_EQ, label); \ - } while (0) -#define ASM_CALL_IND(as, ptr, idx) asm_thumb_bl_ind(as, ptr, idx, ASM_THUMB_REG_R3) - -#define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_thumb_mov_local_reg(as, (local_num), (reg)) -#define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_thumb_mov_reg_i32_optimised(as, (reg), (imm)) -#define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_thumb_mov_reg_i32_aligned(as, (reg), (imm)) -#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ - do { \ - asm_thumb_mov_reg_i32_optimised(as, (reg_temp), (imm)); \ - asm_thumb_mov_local_reg(as, (local_num), (reg_temp)); \ - } while (false) -#define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_thumb_mov_reg_local(as, (reg), (local_num)) -#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_thumb_mov_reg_reg((as), (reg_dest), (reg_src)) -#define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_thumb_mov_reg_local_addr(as, (reg), (local_num)) - -#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSL, (reg_dest), (reg_shift)) -#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ASR, (reg_dest), (reg_shift)) -#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ORR, (reg_dest), (reg_src)) -#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_EOR, (reg_dest), (reg_src)) -#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_AND, (reg_dest), (reg_src)) -#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_thumb_add_rlo_rlo_rlo((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_thumb_sub_rlo_rlo_rlo((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_MUL, (reg_dest), (reg_src)) - -#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_thumb_ldr_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) -#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_thumb_ldr_rlo_rlo_i5((as), (reg_dest), (reg_base), (word_offset)) -#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_thumb_ldrb_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) -#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_thumb_ldrh_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) -#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_thumb_ldr_rlo_rlo_i5((as), (reg_dest), (reg_base), 0) - -#define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_thumb_str_rlo_rlo_i5((as), (reg_src), (reg_base), 0) -#define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_thumb_str_rlo_rlo_i5((as), (reg_src), (reg_base), (word_offset)) -#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_thumb_strb_rlo_rlo_i5((as), (reg_src), (reg_base), 0) -#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_thumb_strh_rlo_rlo_i5((as), (reg_src), (reg_base), 0) -#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_thumb_str_rlo_rlo_i5((as), (reg_src), (reg_base), 0) - -#endif // GENERIC_ASM_API - -#endif // MICROPY_INCLUDED_PY_ASMTHUMB_H diff --git a/user/mpy/py/asmx64.c b/user/mpy/py/asmx64.c deleted file mode 100644 index aa2a8ec..0000000 --- a/user/mpy/py/asmx64.c +++ /dev/null @@ -1,632 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/mpconfig.h" - -// wrapper around everything in this file -#if MICROPY_EMIT_X64 - -#include "py/asmx64.h" - -/* all offsets are measured in multiples of 8 bytes */ -#define WORD_SIZE (8) - -#define OPCODE_NOP (0x90) -#define OPCODE_PUSH_R64 (0x50) /* +rq */ -#define OPCODE_PUSH_I64 (0x68) -#define OPCODE_PUSH_M64 (0xff) /* /6 */ -#define OPCODE_POP_R64 (0x58) /* +rq */ -#define OPCODE_RET (0xc3) -#define OPCODE_MOV_I8_TO_R8 (0xb0) /* +rb */ -#define OPCODE_MOV_I64_TO_R64 (0xb8) /* +rq */ -#define OPCODE_MOV_I32_TO_RM32 (0xc7) -#define OPCODE_MOV_R8_TO_RM8 (0x88) /* /r */ -#define OPCODE_MOV_R64_TO_RM64 (0x89) /* /r */ -#define OPCODE_MOV_RM64_TO_R64 (0x8b) /* /r */ -#define OPCODE_MOVZX_RM8_TO_R64 (0xb6) /* 0x0f 0xb6/r */ -#define OPCODE_MOVZX_RM16_TO_R64 (0xb7) /* 0x0f 0xb7/r */ -#define OPCODE_LEA_MEM_TO_R64 (0x8d) /* /r */ -#define OPCODE_AND_R64_TO_RM64 (0x21) /* /r */ -#define OPCODE_OR_R64_TO_RM64 (0x09) /* /r */ -#define OPCODE_XOR_R64_TO_RM64 (0x31) /* /r */ -#define OPCODE_ADD_R64_TO_RM64 (0x01) /* /r */ -#define OPCODE_ADD_I32_TO_RM32 (0x81) /* /0 */ -#define OPCODE_ADD_I8_TO_RM32 (0x83) /* /0 */ -#define OPCODE_SUB_R64_FROM_RM64 (0x29) -#define OPCODE_SUB_I32_FROM_RM64 (0x81) /* /5 */ -#define OPCODE_SUB_I8_FROM_RM64 (0x83) /* /5 */ -//#define OPCODE_SHL_RM32_BY_I8 (0xc1) /* /4 */ -//#define OPCODE_SHR_RM32_BY_I8 (0xc1) /* /5 */ -//#define OPCODE_SAR_RM32_BY_I8 (0xc1) /* /7 */ -#define OPCODE_SHL_RM64_CL (0xd3) /* /4 */ -#define OPCODE_SAR_RM64_CL (0xd3) /* /7 */ -//#define OPCODE_CMP_I32_WITH_RM32 (0x81) /* /7 */ -//#define OPCODE_CMP_I8_WITH_RM32 (0x83) /* /7 */ -#define OPCODE_CMP_R64_WITH_RM64 (0x39) /* /r */ -//#define OPCODE_CMP_RM32_WITH_R32 (0x3b) -#define OPCODE_TEST_R8_WITH_RM8 (0x84) /* /r */ -#define OPCODE_JMP_REL8 (0xeb) -#define OPCODE_JMP_REL32 (0xe9) -#define OPCODE_JCC_REL8 (0x70) /* | jcc type */ -#define OPCODE_JCC_REL32_A (0x0f) -#define OPCODE_JCC_REL32_B (0x80) /* | jcc type */ -#define OPCODE_SETCC_RM8_A (0x0f) -#define OPCODE_SETCC_RM8_B (0x90) /* | jcc type, /0 */ -#define OPCODE_CALL_REL32 (0xe8) -#define OPCODE_CALL_RM32 (0xff) /* /2 */ -#define OPCODE_LEAVE (0xc9) - -#define MODRM_R64(x) (((x) & 0x7) << 3) -#define MODRM_RM_DISP0 (0x00) -#define MODRM_RM_DISP8 (0x40) -#define MODRM_RM_DISP32 (0x80) -#define MODRM_RM_REG (0xc0) -#define MODRM_RM_R64(x) ((x) & 0x7) - -#define OP_SIZE_PREFIX (0x66) - -#define REX_PREFIX (0x40) -#define REX_W (0x08) // width -#define REX_R (0x04) // register -#define REX_X (0x02) // index -#define REX_B (0x01) // base -#define REX_W_FROM_R64(r64) ((r64) >> 0 & 0x08) -#define REX_R_FROM_R64(r64) ((r64) >> 1 & 0x04) -#define REX_X_FROM_R64(r64) ((r64) >> 2 & 0x02) -#define REX_B_FROM_R64(r64) ((r64) >> 3 & 0x01) - -#define IMM32_L0(x) ((x) & 0xff) -#define IMM32_L1(x) (((x) >> 8) & 0xff) -#define IMM32_L2(x) (((x) >> 16) & 0xff) -#define IMM32_L3(x) (((x) >> 24) & 0xff) -#define IMM64_L4(x) (((x) >> 32) & 0xff) -#define IMM64_L5(x) (((x) >> 40) & 0xff) -#define IMM64_L6(x) (((x) >> 48) & 0xff) -#define IMM64_L7(x) (((x) >> 56) & 0xff) - -#define UNSIGNED_FIT8(x) (((x) & 0xffffffffffffff00) == 0) -#define UNSIGNED_FIT32(x) (((x) & 0xffffffff00000000) == 0) -#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) - -static inline byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int n) { - return mp_asm_base_get_cur_to_write_bytes(&as->base, n); -} - -STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) { - byte* c = asm_x64_get_cur_to_write_bytes(as, 1); - if (c != NULL) { - c[0] = b1; - } -} - -STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) { - byte* c = asm_x64_get_cur_to_write_bytes(as, 2); - if (c != NULL) { - c[0] = b1; - c[1] = b2; - } -} - -STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) { - byte* c = asm_x64_get_cur_to_write_bytes(as, 3); - if (c != NULL) { - c[0] = b1; - c[1] = b2; - c[2] = b3; - } -} - -STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) { - byte* c = asm_x64_get_cur_to_write_bytes(as, 4); - if (c != NULL) { - c[0] = IMM32_L0(w32); - c[1] = IMM32_L1(w32); - c[2] = IMM32_L2(w32); - c[3] = IMM32_L3(w32); - } -} - -STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) { - byte* c = asm_x64_get_cur_to_write_bytes(as, 8); - if (c != NULL) { - c[0] = IMM32_L0(w64); - c[1] = IMM32_L1(w64); - c[2] = IMM32_L2(w64); - c[3] = IMM32_L3(w64); - c[4] = IMM64_L4(w64); - c[5] = IMM64_L5(w64); - c[6] = IMM64_L6(w64); - c[7] = IMM64_L7(w64); - } -} - -/* unused -STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) { - byte* c; - assert(offset + 4 <= as->code_size); - c = as->code_base + offset; - c[0] = IMM32_L0(w32); - c[1] = IMM32_L1(w32); - c[2] = IMM32_L2(w32); - c[3] = IMM32_L3(w32); -} -*/ - -STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) { - assert(disp_r64 != ASM_X64_REG_RSP); - - if (disp_r64 == ASM_X64_REG_R12) { - // special case for r12; not fully implemented - assert(SIGNED_FIT8(disp_offset)); - asm_x64_write_byte_3(as, MODRM_R64(r64) | MODRM_RM_DISP8 | MODRM_RM_R64(disp_r64), 0x24, IMM32_L0(disp_offset)); - return; - } - - if (disp_offset == 0 && disp_r64 != ASM_X64_REG_RBP) { - asm_x64_write_byte_1(as, MODRM_R64(r64) | MODRM_RM_DISP0 | MODRM_RM_R64(disp_r64)); - } else if (SIGNED_FIT8(disp_offset)) { - asm_x64_write_byte_2(as, MODRM_R64(r64) | MODRM_RM_DISP8 | MODRM_RM_R64(disp_r64), IMM32_L0(disp_offset)); - } else { - asm_x64_write_byte_1(as, MODRM_R64(r64) | MODRM_RM_DISP32 | MODRM_RM_R64(disp_r64)); - asm_x64_write_word32(as, disp_offset); - } -} - -STATIC void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) { - asm_x64_write_byte_3(as, REX_PREFIX | REX_W | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), op, MODRM_R64(src_r64) | MODRM_RM_REG | MODRM_RM_R64(dest_r64)); -} - -void asm_x64_nop(asm_x64_t *as) { - asm_x64_write_byte_1(as, OPCODE_NOP); -} - -void asm_x64_push_r64(asm_x64_t *as, int src_r64) { - if (src_r64 < 8) { - asm_x64_write_byte_1(as, OPCODE_PUSH_R64 | src_r64); - } else { - asm_x64_write_byte_2(as, REX_PREFIX | REX_B, OPCODE_PUSH_R64 | (src_r64 & 7)); - } -} - -/* -void asm_x64_push_i32(asm_x64_t *as, int src_i32) { - asm_x64_write_byte_1(as, OPCODE_PUSH_I64); - asm_x64_write_word32(as, src_i32); // will be sign extended to 64 bits -} -*/ - -/* -void asm_x64_push_disp(asm_x64_t *as, int src_r64, int src_offset) { - assert(src_r64 < 8); - asm_x64_write_byte_1(as, OPCODE_PUSH_M64); - asm_x64_write_r64_disp(as, 6, src_r64, src_offset); -} -*/ - -void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) { - if (dest_r64 < 8) { - asm_x64_write_byte_1(as, OPCODE_POP_R64 | dest_r64); - } else { - asm_x64_write_byte_2(as, REX_PREFIX | REX_B, OPCODE_POP_R64 | (dest_r64 & 7)); - } -} - -STATIC void asm_x64_ret(asm_x64_t *as) { - asm_x64_write_byte_1(as, OPCODE_RET); -} - -void asm_x64_mov_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_MOV_R64_TO_RM64); -} - -void asm_x64_mov_r8_to_mem8(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { - if (src_r64 < 8 && dest_r64 < 8) { - asm_x64_write_byte_1(as, OPCODE_MOV_R8_TO_RM8); - } else { - asm_x64_write_byte_2(as, REX_PREFIX | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R8_TO_RM8); - } - asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); -} - -void asm_x64_mov_r16_to_mem16(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { - if (src_r64 < 8 && dest_r64 < 8) { - asm_x64_write_byte_2(as, OP_SIZE_PREFIX, OPCODE_MOV_R64_TO_RM64); - } else { - asm_x64_write_byte_3(as, OP_SIZE_PREFIX, REX_PREFIX | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R64_TO_RM64); - } - asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); -} - -void asm_x64_mov_r32_to_mem32(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { - if (src_r64 < 8 && dest_r64 < 8) { - asm_x64_write_byte_1(as, OPCODE_MOV_R64_TO_RM64); - } else { - asm_x64_write_byte_2(as, REX_PREFIX | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R64_TO_RM64); - } - asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); -} - -void asm_x64_mov_r64_to_mem64(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp) { - // use REX prefix for 64 bit operation - asm_x64_write_byte_2(as, REX_PREFIX | REX_W | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), OPCODE_MOV_R64_TO_RM64); - asm_x64_write_r64_disp(as, src_r64, dest_r64, dest_disp); -} - -void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { - assert(src_r64 < 8); - if (dest_r64 < 8) { - asm_x64_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM8_TO_R64); - } else { - asm_x64_write_byte_3(as, REX_PREFIX | REX_R, 0x0f, OPCODE_MOVZX_RM8_TO_R64); - } - asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); -} - -void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { - assert(src_r64 < 8); - if (dest_r64 < 8) { - asm_x64_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM16_TO_R64); - } else { - asm_x64_write_byte_3(as, REX_PREFIX | REX_R, 0x0f, OPCODE_MOVZX_RM16_TO_R64); - } - asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); -} - -void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { - assert(src_r64 < 8); - if (dest_r64 < 8) { - asm_x64_write_byte_1(as, OPCODE_MOV_RM64_TO_R64); - } else { - asm_x64_write_byte_2(as, REX_PREFIX | REX_R, OPCODE_MOV_RM64_TO_R64); - } - asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); -} - -void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { - // use REX prefix for 64 bit operation - asm_x64_write_byte_2(as, REX_PREFIX | REX_W | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), OPCODE_MOV_RM64_TO_R64); - asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); -} - -STATIC void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) { - // use REX prefix for 64 bit operation - assert(src_r64 < 8); - assert(dest_r64 < 8); - asm_x64_write_byte_2(as, REX_PREFIX | REX_W, OPCODE_LEA_MEM_TO_R64); - asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp); -} - -/* -void asm_x64_mov_i8_to_r8(asm_x64_t *as, int src_i8, int dest_r64) { - assert(dest_r64 < 8); - asm_x64_write_byte_2(as, OPCODE_MOV_I8_TO_R8 | dest_r64, src_i8); -} -*/ - -STATIC void asm_x64_mov_i32_to_r64(asm_x64_t *as, int src_i32, int dest_r64) { - // cpu defaults to i32 to r64, with zero extension - if (dest_r64 < 8) { - asm_x64_write_byte_1(as, OPCODE_MOV_I64_TO_R64 | dest_r64); - } else { - asm_x64_write_byte_2(as, REX_PREFIX | REX_B, OPCODE_MOV_I64_TO_R64 | (dest_r64 & 7)); - } - asm_x64_write_word32(as, src_i32); -} - -void asm_x64_mov_i64_to_r64(asm_x64_t *as, int64_t src_i64, int dest_r64) { - // cpu defaults to i32 to r64 - // to mov i64 to r64 need to use REX prefix - asm_x64_write_byte_2(as, - REX_PREFIX | REX_W | (dest_r64 < 8 ? 0 : REX_B), - OPCODE_MOV_I64_TO_R64 | (dest_r64 & 7)); - asm_x64_write_word64(as, src_i64); -} - -void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r64) { - // TODO use movzx, movsx if possible - if (UNSIGNED_FIT32(src_i64)) { - // 5 bytes - asm_x64_mov_i32_to_r64(as, src_i64 & 0xffffffff, dest_r64); - } else { - // 10 bytes - asm_x64_mov_i64_to_r64(as, src_i64, dest_r64); - } -} - -// src_i64 is stored as a full word in the code, and aligned to machine-word boundary -void asm_x64_mov_i64_to_r64_aligned(asm_x64_t *as, int64_t src_i64, int dest_r64) { - // mov instruction uses 2 bytes for the instruction, before the i64 - while (((as->base.code_offset + 2) & (WORD_SIZE - 1)) != 0) { - asm_x64_nop(as); - } - asm_x64_mov_i64_to_r64(as, src_i64, dest_r64); -} - -void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_AND_R64_TO_RM64); -} - -void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_OR_R64_TO_RM64); -} - -void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_XOR_R64_TO_RM64); -} - -void asm_x64_shl_r64_cl(asm_x64_t* as, int dest_r64) { - asm_x64_generic_r64_r64(as, dest_r64, 4, OPCODE_SHL_RM64_CL); -} - -void asm_x64_sar_r64_cl(asm_x64_t* as, int dest_r64) { - asm_x64_generic_r64_r64(as, dest_r64, 7, OPCODE_SAR_RM64_CL); -} - -void asm_x64_add_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_ADD_R64_TO_RM64); -} - -void asm_x64_sub_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_SUB_R64_FROM_RM64); -} - -void asm_x64_mul_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) { - // imul reg64, reg/mem64 -- 0x0f 0xaf /r - asm_x64_write_byte_1(as, REX_PREFIX | REX_W | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64)); - asm_x64_write_byte_3(as, 0x0f, 0xaf, MODRM_R64(dest_r64) | MODRM_RM_REG | MODRM_RM_R64(src_r64)); -} - -/* -void asm_x64_sub_i32_from_r32(asm_x64_t *as, int src_i32, int dest_r32) { - if (SIGNED_FIT8(src_i32)) { - // defaults to 32 bit operation - asm_x64_write_byte_2(as, OPCODE_SUB_I8_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r32)); - asm_x64_write_byte_1(as, src_i32 & 0xff); - } else { - // defaults to 32 bit operation - asm_x64_write_byte_2(as, OPCODE_SUB_I32_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r32)); - asm_x64_write_word32(as, src_i32); - } -} -*/ - -STATIC void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) { - assert(dest_r64 < 8); - if (SIGNED_FIT8(src_i32)) { - // use REX prefix for 64 bit operation - asm_x64_write_byte_3(as, REX_PREFIX | REX_W, OPCODE_SUB_I8_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r64)); - asm_x64_write_byte_1(as, src_i32 & 0xff); - } else { - // use REX prefix for 64 bit operation - asm_x64_write_byte_3(as, REX_PREFIX | REX_W, OPCODE_SUB_I32_FROM_RM64, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(dest_r64)); - asm_x64_write_word32(as, src_i32); - } -} - -/* -void asm_x64_shl_r32_by_imm(asm_x64_t *as, int r32, int imm) { - asm_x64_write_byte_2(as, OPCODE_SHL_RM32_BY_I8, MODRM_R64(4) | MODRM_RM_REG | MODRM_RM_R64(r32)); - asm_x64_write_byte_1(as, imm); -} - -void asm_x64_shr_r32_by_imm(asm_x64_t *as, int r32, int imm) { - asm_x64_write_byte_2(as, OPCODE_SHR_RM32_BY_I8, MODRM_R64(5) | MODRM_RM_REG | MODRM_RM_R64(r32)); - asm_x64_write_byte_1(as, imm); -} - -void asm_x64_sar_r32_by_imm(asm_x64_t *as, int r32, int imm) { - asm_x64_write_byte_2(as, OPCODE_SAR_RM32_BY_I8, MODRM_R64(7) | MODRM_RM_REG | MODRM_RM_R64(r32)); - asm_x64_write_byte_1(as, imm); -} -*/ - -void asm_x64_cmp_r64_with_r64(asm_x64_t *as, int src_r64_a, int src_r64_b) { - asm_x64_generic_r64_r64(as, src_r64_b, src_r64_a, OPCODE_CMP_R64_WITH_RM64); -} - -/* -void asm_x64_cmp_i32_with_r32(asm_x64_t *as, int src_i32, int src_r32) { - if (SIGNED_FIT8(src_i32)) { - asm_x64_write_byte_2(as, OPCODE_CMP_I8_WITH_RM32, MODRM_R64(7) | MODRM_RM_REG | MODRM_RM_R64(src_r32)); - asm_x64_write_byte_1(as, src_i32 & 0xff); - } else { - asm_x64_write_byte_2(as, OPCODE_CMP_I32_WITH_RM32, MODRM_R64(7) | MODRM_RM_REG | MODRM_RM_R64(src_r32)); - asm_x64_write_word32(as, src_i32); - } -} -*/ - -void asm_x64_test_r8_with_r8(asm_x64_t *as, int src_r64_a, int src_r64_b) { - // TODO implement for other registers - assert(src_r64_a == ASM_X64_REG_RAX); - assert(src_r64_b == ASM_X64_REG_RAX); - asm_x64_write_byte_2(as, OPCODE_TEST_R8_WITH_RM8, MODRM_R64(src_r64_a) | MODRM_RM_REG | MODRM_RM_R64(src_r64_b)); -} - -void asm_x64_setcc_r8(asm_x64_t *as, int jcc_type, int dest_r8) { - assert(dest_r8 < 8); - asm_x64_write_byte_3(as, OPCODE_SETCC_RM8_A, OPCODE_SETCC_RM8_B | jcc_type, MODRM_R64(0) | MODRM_RM_REG | MODRM_RM_R64(dest_r8)); -} - -STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) { - assert(label < as->base.max_num_labels); - return as->base.label_offsets[label]; -} - -void asm_x64_jmp_label(asm_x64_t *as, mp_uint_t label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - if (dest != (mp_uint_t)-1 && rel < 0) { - // is a backwards jump, so we know the size of the jump on the first pass - // calculate rel assuming 8 bit relative jump - rel -= 2; - if (SIGNED_FIT8(rel)) { - asm_x64_write_byte_2(as, OPCODE_JMP_REL8, rel & 0xff); - } else { - rel += 2; - goto large_jump; - } - } else { - // is a forwards jump, so need to assume it's large - large_jump: - rel -= 5; - asm_x64_write_byte_1(as, OPCODE_JMP_REL32); - asm_x64_write_word32(as, rel); - } -} - -void asm_x64_jcc_label(asm_x64_t *as, int jcc_type, mp_uint_t label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - if (dest != (mp_uint_t)-1 && rel < 0) { - // is a backwards jump, so we know the size of the jump on the first pass - // calculate rel assuming 8 bit relative jump - rel -= 2; - if (SIGNED_FIT8(rel)) { - asm_x64_write_byte_2(as, OPCODE_JCC_REL8 | jcc_type, rel & 0xff); - } else { - rel += 2; - goto large_jump; - } - } else { - // is a forwards jump, so need to assume it's large - large_jump: - rel -= 6; - asm_x64_write_byte_2(as, OPCODE_JCC_REL32_A, OPCODE_JCC_REL32_B | jcc_type); - asm_x64_write_word32(as, rel); - } -} - -void asm_x64_entry(asm_x64_t *as, int num_locals) { - asm_x64_push_r64(as, ASM_X64_REG_RBP); - asm_x64_mov_r64_r64(as, ASM_X64_REG_RBP, ASM_X64_REG_RSP); - if (num_locals < 0) { - num_locals = 0; - } - num_locals |= 1; // make it odd so stack is aligned on 16 byte boundary - asm_x64_sub_r64_i32(as, ASM_X64_REG_RSP, num_locals * WORD_SIZE); - asm_x64_push_r64(as, ASM_X64_REG_RBX); - asm_x64_push_r64(as, ASM_X64_REG_R12); - asm_x64_push_r64(as, ASM_X64_REG_R13); - as->num_locals = num_locals; -} - -void asm_x64_exit(asm_x64_t *as) { - asm_x64_pop_r64(as, ASM_X64_REG_R13); - asm_x64_pop_r64(as, ASM_X64_REG_R12); - asm_x64_pop_r64(as, ASM_X64_REG_RBX); - asm_x64_write_byte_1(as, OPCODE_LEAVE); - asm_x64_ret(as); -} - -// locals: -// - stored on the stack in ascending order -// - numbered 0 through as->num_locals-1 -// - RBP points above the last local -// -// | RBP -// v -// l0 l1 l2 ... l(n-1) -// ^ ^ -// | low address | high address in RAM -// -STATIC int asm_x64_local_offset_from_ebp(asm_x64_t *as, int local_num) { - return (-as->num_locals + local_num) * WORD_SIZE; -} - -void asm_x64_mov_local_to_r64(asm_x64_t *as, int src_local_num, int dest_r64) { - asm_x64_mov_mem64_to_r64(as, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, src_local_num), dest_r64); -} - -void asm_x64_mov_r64_to_local(asm_x64_t *as, int src_r64, int dest_local_num) { - asm_x64_mov_r64_to_mem64(as, src_r64, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, dest_local_num)); -} - -void asm_x64_mov_local_addr_to_r64(asm_x64_t *as, int local_num, int dest_r64) { - int offset = asm_x64_local_offset_from_ebp(as, local_num); - if (offset == 0) { - asm_x64_mov_r64_r64(as, dest_r64, ASM_X64_REG_RBP); - } else { - asm_x64_lea_disp_to_r64(as, ASM_X64_REG_RBP, offset, dest_r64); - } -} - -/* -void asm_x64_push_local(asm_x64_t *as, int local_num) { - asm_x64_push_disp(as, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, local_num)); -} - -void asm_x64_push_local_addr(asm_x64_t *as, int local_num, int temp_r64) { - asm_x64_mov_r64_r64(as, temp_r64, ASM_X64_REG_RBP); - asm_x64_add_i32_to_r32(as, asm_x64_local_offset_from_ebp(as, local_num), temp_r64); - asm_x64_push_r64(as, temp_r64); -} -*/ - -/* - can't use these because code might be relocated when resized - -void asm_x64_call(asm_x64_t *as, void* func) { - asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP); - asm_x64_write_byte_1(as, OPCODE_CALL_REL32); - asm_x64_write_word32(as, func - (void*)(as->code_cur + 4)); - asm_x64_mov_r64_r64(as, ASM_X64_REG_RSP, ASM_X64_REG_RBP); -} - -void asm_x64_call_i1(asm_x64_t *as, void* func, int i1) { - asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP); - asm_x64_sub_i32_from_r32(as, 12, ASM_X64_REG_RSP); - asm_x64_push_i32(as, i1); - asm_x64_write_byte_1(as, OPCODE_CALL_REL32); - asm_x64_write_word32(as, func - (void*)(as->code_cur + 4)); - asm_x64_add_i32_to_r32(as, 16, ASM_X64_REG_RSP); - asm_x64_mov_r64_r64(as, ASM_X64_REG_RSP, ASM_X64_REG_RBP); -} -*/ - -void asm_x64_call_ind(asm_x64_t *as, void *ptr, int temp_r64) { - assert(temp_r64 < 8); -#ifdef __LP64__ - asm_x64_mov_i64_to_r64_optimised(as, (int64_t)ptr, temp_r64); -#else - // If we get here, sizeof(int) == sizeof(void*). - asm_x64_mov_i64_to_r64_optimised(as, (int64_t)(unsigned int)ptr, temp_r64); -#endif - asm_x64_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R64(2) | MODRM_RM_REG | MODRM_RM_R64(temp_r64)); - // this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all - // doesn't work anymore because calls are 64 bits away - /* - asm_x64_write_byte_1(as, OPCODE_CALL_REL32); - asm_x64_write_word32(as, ptr - (void*)(as->code_base + as->code_offset + 4)); - */ -} - -#endif // MICROPY_EMIT_X64 diff --git a/user/mpy/py/asmx64.h b/user/mpy/py/asmx64.h deleted file mode 100644 index 425bdf2..0000000 --- a/user/mpy/py/asmx64.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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_ASMX64_H -#define MICROPY_INCLUDED_PY_ASMX64_H - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/asmbase.h" - -// AMD64 calling convention is: -// - args pass in: RDI, RSI, RDX, RCX, R08, R09 -// - return value in RAX -// - stack must be aligned on a 16-byte boundary before all calls -// - RAX, RCX, RDX, RSI, RDI, R08, R09, R10, R11 are caller-save -// - RBX, RBP, R12, R13, R14, R15 are callee-save - -// In the functions below, argument order follows x86 docs and generally -// the destination is the first argument. -// NOTE: this is a change from the old convention used in this file and -// some functions still use the old (reverse) convention. - -#define ASM_X64_REG_RAX (0) -#define ASM_X64_REG_RCX (1) -#define ASM_X64_REG_RDX (2) -#define ASM_X64_REG_RBX (3) -#define ASM_X64_REG_RSP (4) -#define ASM_X64_REG_RBP (5) -#define ASM_X64_REG_RSI (6) -#define ASM_X64_REG_RDI (7) -#define ASM_X64_REG_R08 (8) -#define ASM_X64_REG_R09 (9) -#define ASM_X64_REG_R10 (10) -#define ASM_X64_REG_R11 (11) -#define ASM_X64_REG_R12 (12) -#define ASM_X64_REG_R13 (13) -#define ASM_X64_REG_R14 (14) -#define ASM_X64_REG_R15 (15) - -// condition codes, used for jcc and setcc (despite their j-name!) -#define ASM_X64_CC_JB (0x2) // below, unsigned -#define ASM_X64_CC_JZ (0x4) -#define ASM_X64_CC_JE (0x4) -#define ASM_X64_CC_JNZ (0x5) -#define ASM_X64_CC_JNE (0x5) -#define ASM_X64_CC_JL (0xc) // less, signed -#define ASM_X64_CC_JGE (0xd) // greater or equal, signed -#define ASM_X64_CC_JLE (0xe) // less or equal, signed -#define ASM_X64_CC_JG (0xf) // greater, signed - -typedef struct _asm_x64_t { - mp_asm_base_t base; - int num_locals; -} asm_x64_t; - -static inline void asm_x64_end_pass(asm_x64_t *as) { - (void)as; -} - -void asm_x64_nop(asm_x64_t* as); -void asm_x64_push_r64(asm_x64_t* as, int src_r64); -void asm_x64_pop_r64(asm_x64_t* as, int dest_r64); -void asm_x64_mov_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); -void asm_x64_mov_i64_to_r64(asm_x64_t* as, int64_t src_i64, int dest_r64); -void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r64); -void asm_x64_mov_i64_to_r64_aligned(asm_x64_t *as, int64_t src_i64, int dest_r64); -void asm_x64_mov_r8_to_mem8(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); -void asm_x64_mov_r16_to_mem16(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); -void asm_x64_mov_r32_to_mem32(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); -void asm_x64_mov_r64_to_mem64(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp); -void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); -void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); -void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); -void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64); -void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64); -void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64); -void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64); -void asm_x64_shl_r64_cl(asm_x64_t* as, int dest_r64); -void asm_x64_sar_r64_cl(asm_x64_t* as, int dest_r64); -void asm_x64_add_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); -void asm_x64_sub_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); -void asm_x64_mul_r64_r64(asm_x64_t* as, int dest_r64, int src_r64); -void asm_x64_cmp_r64_with_r64(asm_x64_t* as, int src_r64_a, int src_r64_b); -void asm_x64_test_r8_with_r8(asm_x64_t* as, int src_r64_a, int src_r64_b); -void asm_x64_setcc_r8(asm_x64_t* as, int jcc_type, int dest_r8); -void asm_x64_jmp_label(asm_x64_t* as, mp_uint_t label); -void asm_x64_jcc_label(asm_x64_t* as, int jcc_type, mp_uint_t label); -void asm_x64_entry(asm_x64_t* as, int num_locals); -void asm_x64_exit(asm_x64_t* as); -void asm_x64_mov_local_to_r64(asm_x64_t* as, int src_local_num, int dest_r64); -void asm_x64_mov_r64_to_local(asm_x64_t* as, int src_r64, int dest_local_num); -void asm_x64_mov_local_addr_to_r64(asm_x64_t* as, int local_num, int dest_r64); -void asm_x64_call_ind(asm_x64_t* as, void* ptr, int temp_r32); - -#if GENERIC_ASM_API - -// The following macros provide a (mostly) arch-independent API to -// generate native code, and are used by the native emitter. - -#define ASM_WORD_SIZE (8) - -#define REG_RET ASM_X64_REG_RAX -#define REG_ARG_1 ASM_X64_REG_RDI -#define REG_ARG_2 ASM_X64_REG_RSI -#define REG_ARG_3 ASM_X64_REG_RDX -#define REG_ARG_4 ASM_X64_REG_RCX -#define REG_ARG_5 ASM_X64_REG_R08 - -// caller-save -#define REG_TEMP0 ASM_X64_REG_RAX -#define REG_TEMP1 ASM_X64_REG_RDI -#define REG_TEMP2 ASM_X64_REG_RSI - -// callee-save -#define REG_LOCAL_1 ASM_X64_REG_RBX -#define REG_LOCAL_2 ASM_X64_REG_R12 -#define REG_LOCAL_3 ASM_X64_REG_R13 -#define REG_LOCAL_NUM (3) - -#define ASM_T asm_x64_t -#define ASM_END_PASS asm_x64_end_pass -#define ASM_ENTRY asm_x64_entry -#define ASM_EXIT asm_x64_exit - -#define ASM_JUMP asm_x64_jmp_label -#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ - do { \ - asm_x64_test_r8_with_r8(as, reg, reg); \ - asm_x64_jcc_label(as, ASM_X64_CC_JZ, label); \ - } while (0) -#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ - do { \ - asm_x64_test_r8_with_r8(as, reg, reg); \ - asm_x64_jcc_label(as, ASM_X64_CC_JNZ, label); \ - } while (0) -#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ - do { \ - asm_x64_cmp_r64_with_r64(as, reg1, reg2); \ - asm_x64_jcc_label(as, ASM_X64_CC_JE, label); \ - } while (0) -#define ASM_CALL_IND(as, ptr, idx) asm_x64_call_ind(as, ptr, ASM_X64_REG_RAX) - -#define ASM_MOV_REG_TO_LOCAL asm_x64_mov_r64_to_local -#define ASM_MOV_IMM_TO_REG asm_x64_mov_i64_to_r64_optimised -#define ASM_MOV_ALIGNED_IMM_TO_REG asm_x64_mov_i64_to_r64_aligned -#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ - do { \ - asm_x64_mov_i64_to_r64_optimised(as, (imm), (reg_temp)); \ - asm_x64_mov_r64_to_local(as, (reg_temp), (local_num)); \ - } while (false) -#define ASM_MOV_LOCAL_TO_REG asm_x64_mov_local_to_r64 -#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_x64_mov_r64_r64((as), (reg_dest), (reg_src)) -#define ASM_MOV_LOCAL_ADDR_TO_REG asm_x64_mov_local_addr_to_r64 - -#define ASM_LSL_REG(as, reg) asm_x64_shl_r64_cl((as), (reg)) -#define ASM_ASR_REG(as, reg) asm_x64_sar_r64_cl((as), (reg)) -#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_x64_or_r64_r64((as), (reg_dest), (reg_src)) -#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_x64_xor_r64_r64((as), (reg_dest), (reg_src)) -#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_x64_and_r64_r64((as), (reg_dest), (reg_src)) -#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_x64_add_r64_r64((as), (reg_dest), (reg_src)) -#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_x64_sub_r64_r64((as), (reg_dest), (reg_src)) -#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_x64_mul_r64_r64((as), (reg_dest), (reg_src)) - -#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem64_to_r64((as), (reg_base), 0, (reg_dest)) -#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_x64_mov_mem64_to_r64((as), (reg_base), 8 * (word_offset), (reg_dest)) -#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem8_to_r64zx((as), (reg_base), 0, (reg_dest)) -#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem16_to_r64zx((as), (reg_base), 0, (reg_dest)) -#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_x64_mov_mem32_to_r64zx((as), (reg_base), 0, (reg_dest)) - -#define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_x64_mov_r64_to_mem64((as), (reg_src), (reg_base), 0) -#define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_x64_mov_r64_to_mem64((as), (reg_src), (reg_base), 8 * (word_offset)) -#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_x64_mov_r8_to_mem8((as), (reg_src), (reg_base), 0) -#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_x64_mov_r16_to_mem16((as), (reg_src), (reg_base), 0) -#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_x64_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) - -#endif // GENERIC_ASM_API - -#endif // MICROPY_INCLUDED_PY_ASMX64_H diff --git a/user/mpy/py/asmx86.c b/user/mpy/py/asmx86.c deleted file mode 100644 index 6a78fbd..0000000 --- a/user/mpy/py/asmx86.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/mpconfig.h" - -// wrapper around everything in this file -#if MICROPY_EMIT_X86 - -#include "py/asmx86.h" - -/* all offsets are measured in multiples of 4 bytes */ -#define WORD_SIZE (4) - -#define OPCODE_NOP (0x90) -#define OPCODE_PUSH_R32 (0x50) -//#define OPCODE_PUSH_I32 (0x68) -//#define OPCODE_PUSH_M32 (0xff) /* /6 */ -#define OPCODE_POP_R32 (0x58) -#define OPCODE_RET (0xc3) -//#define OPCODE_MOV_I8_TO_R8 (0xb0) /* +rb */ -#define OPCODE_MOV_I32_TO_R32 (0xb8) -//#define OPCODE_MOV_I32_TO_RM32 (0xc7) -#define OPCODE_MOV_R8_TO_RM8 (0x88) /* /r */ -#define OPCODE_MOV_R32_TO_RM32 (0x89) /* /r */ -#define OPCODE_MOV_RM32_TO_R32 (0x8b) /* /r */ -#define OPCODE_MOVZX_RM8_TO_R32 (0xb6) /* 0x0f 0xb6/r */ -#define OPCODE_MOVZX_RM16_TO_R32 (0xb7) /* 0x0f 0xb7/r */ -#define OPCODE_LEA_MEM_TO_R32 (0x8d) /* /r */ -#define OPCODE_AND_R32_TO_RM32 (0x21) /* /r */ -#define OPCODE_OR_R32_TO_RM32 (0x09) /* /r */ -#define OPCODE_XOR_R32_TO_RM32 (0x31) /* /r */ -#define OPCODE_ADD_R32_TO_RM32 (0x01) -#define OPCODE_ADD_I32_TO_RM32 (0x81) /* /0 */ -#define OPCODE_ADD_I8_TO_RM32 (0x83) /* /0 */ -#define OPCODE_SUB_R32_FROM_RM32 (0x29) -#define OPCODE_SUB_I32_FROM_RM32 (0x81) /* /5 */ -#define OPCODE_SUB_I8_FROM_RM32 (0x83) /* /5 */ -//#define OPCODE_SHL_RM32_BY_I8 (0xc1) /* /4 */ -//#define OPCODE_SHR_RM32_BY_I8 (0xc1) /* /5 */ -//#define OPCODE_SAR_RM32_BY_I8 (0xc1) /* /7 */ -#define OPCODE_SHL_RM32_CL (0xd3) /* /4 */ -#define OPCODE_SAR_RM32_CL (0xd3) /* /7 */ -//#define OPCODE_CMP_I32_WITH_RM32 (0x81) /* /7 */ -//#define OPCODE_CMP_I8_WITH_RM32 (0x83) /* /7 */ -#define OPCODE_CMP_R32_WITH_RM32 (0x39) -//#define OPCODE_CMP_RM32_WITH_R32 (0x3b) -#define OPCODE_TEST_R8_WITH_RM8 (0x84) /* /r */ -#define OPCODE_JMP_REL8 (0xeb) -#define OPCODE_JMP_REL32 (0xe9) -#define OPCODE_JCC_REL8 (0x70) /* | jcc type */ -#define OPCODE_JCC_REL32_A (0x0f) -#define OPCODE_JCC_REL32_B (0x80) /* | jcc type */ -#define OPCODE_SETCC_RM8_A (0x0f) -#define OPCODE_SETCC_RM8_B (0x90) /* | jcc type, /0 */ -#define OPCODE_CALL_REL32 (0xe8) -#define OPCODE_CALL_RM32 (0xff) /* /2 */ -#define OPCODE_LEAVE (0xc9) - -#define MODRM_R32(x) ((x) << 3) -#define MODRM_RM_DISP0 (0x00) -#define MODRM_RM_DISP8 (0x40) -#define MODRM_RM_DISP32 (0x80) -#define MODRM_RM_REG (0xc0) -#define MODRM_RM_R32(x) (x) - -#define OP_SIZE_PREFIX (0x66) - -#define IMM32_L0(x) ((x) & 0xff) -#define IMM32_L1(x) (((x) >> 8) & 0xff) -#define IMM32_L2(x) (((x) >> 16) & 0xff) -#define IMM32_L3(x) (((x) >> 24) & 0xff) - -#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) - -STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) { - byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1); - if (c != NULL) { - c[0] = b1; - } -} - -STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) { - byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2); - if (c != NULL) { - c[0] = b1; - c[1] = b2; - } -} - -STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) { - byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3); - if (c != NULL) { - c[0] = b1; - c[1] = b2; - c[2] = b3; - } -} - -STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) { - byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4); - if (c != NULL) { - c[0] = IMM32_L0(w32); - c[1] = IMM32_L1(w32); - c[2] = IMM32_L2(w32); - c[3] = IMM32_L3(w32); - } -} - -STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) { - assert(disp_r32 != ASM_X86_REG_ESP); - - if (disp_offset == 0 && disp_r32 != ASM_X86_REG_EBP) { - asm_x86_write_byte_1(as, MODRM_R32(r32) | MODRM_RM_DISP0 | MODRM_RM_R32(disp_r32)); - } else if (SIGNED_FIT8(disp_offset)) { - asm_x86_write_byte_2(as, MODRM_R32(r32) | MODRM_RM_DISP8 | MODRM_RM_R32(disp_r32), IMM32_L0(disp_offset)); - } else { - asm_x86_write_byte_1(as, MODRM_R32(r32) | MODRM_RM_DISP32 | MODRM_RM_R32(disp_r32)); - asm_x86_write_word32(as, disp_offset); - } -} - -STATIC void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) { - asm_x86_write_byte_2(as, op, MODRM_R32(src_r32) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); -} - -STATIC void asm_x86_nop(asm_x86_t *as) { - asm_x86_write_byte_1(as, OPCODE_NOP); -} - -STATIC void asm_x86_push_r32(asm_x86_t *as, int src_r32) { - asm_x86_write_byte_1(as, OPCODE_PUSH_R32 | src_r32); -} - -#if 0 -void asm_x86_push_i32(asm_x86_t *as, int src_i32) { - asm_x86_write_byte_1(as, OPCODE_PUSH_I32); - asm_x86_write_word32(as, src_i32); -} - -void asm_x86_push_disp(asm_x86_t *as, int src_r32, int src_offset) { - asm_x86_write_byte_1(as, OPCODE_PUSH_M32); - asm_x86_write_r32_disp(as, 6, src_r32, src_offset); -} -#endif - -STATIC void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) { - asm_x86_write_byte_1(as, OPCODE_POP_R32 | dest_r32); -} - -STATIC void asm_x86_ret(asm_x86_t *as) { - asm_x86_write_byte_1(as, OPCODE_RET); -} - -void asm_x86_mov_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_MOV_R32_TO_RM32); -} - -void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp) { - asm_x86_write_byte_1(as, OPCODE_MOV_R8_TO_RM8); - asm_x86_write_r32_disp(as, src_r32, dest_r32, dest_disp); -} - -void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp) { - asm_x86_write_byte_2(as, OP_SIZE_PREFIX, OPCODE_MOV_R32_TO_RM32); - asm_x86_write_r32_disp(as, src_r32, dest_r32, dest_disp); -} - -void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp) { - asm_x86_write_byte_1(as, OPCODE_MOV_R32_TO_RM32); - asm_x86_write_r32_disp(as, src_r32, dest_r32, dest_disp); -} - -void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { - asm_x86_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM8_TO_R32); - asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); -} - -void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { - asm_x86_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM16_TO_R32); - asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); -} - -void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { - asm_x86_write_byte_1(as, OPCODE_MOV_RM32_TO_R32); - asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); -} - -STATIC void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) { - asm_x86_write_byte_1(as, OPCODE_LEA_MEM_TO_R32); - asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp); -} - -#if 0 -void asm_x86_mov_i8_to_r8(asm_x86_t *as, int src_i8, int dest_r32) { - asm_x86_write_byte_2(as, OPCODE_MOV_I8_TO_R8 | dest_r32, src_i8); -} -#endif - -void asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32) { - asm_x86_write_byte_1(as, OPCODE_MOV_I32_TO_R32 | dest_r32); - asm_x86_write_word32(as, src_i32); -} - -// src_i32 is stored as a full word in the code, and aligned to machine-word boundary -void asm_x86_mov_i32_to_r32_aligned(asm_x86_t *as, int32_t src_i32, int dest_r32) { - // mov instruction uses 1 byte for the instruction, before the i32 - while (((as->base.code_offset + 1) & (WORD_SIZE - 1)) != 0) { - asm_x86_nop(as); - } - asm_x86_mov_i32_to_r32(as, src_i32, dest_r32); -} - -void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_AND_R32_TO_RM32); -} - -void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_OR_R32_TO_RM32); -} - -void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_XOR_R32_TO_RM32); -} - -void asm_x86_shl_r32_cl(asm_x86_t* as, int dest_r32) { - asm_x86_generic_r32_r32(as, dest_r32, 4, OPCODE_SHL_RM32_CL); -} - -void asm_x86_sar_r32_cl(asm_x86_t* as, int dest_r32) { - asm_x86_generic_r32_r32(as, dest_r32, 7, OPCODE_SAR_RM32_CL); -} - -void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_ADD_R32_TO_RM32); -} - -STATIC void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) { - if (SIGNED_FIT8(src_i32)) { - asm_x86_write_byte_2(as, OPCODE_ADD_I8_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); - asm_x86_write_byte_1(as, src_i32 & 0xff); - } else { - asm_x86_write_byte_2(as, OPCODE_ADD_I32_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); - asm_x86_write_word32(as, src_i32); - } -} - -void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_SUB_R32_FROM_RM32); -} - -STATIC void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) { - if (SIGNED_FIT8(src_i32)) { - // defaults to 32 bit operation - asm_x86_write_byte_2(as, OPCODE_SUB_I8_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); - asm_x86_write_byte_1(as, src_i32 & 0xff); - } else { - // defaults to 32 bit operation - asm_x86_write_byte_2(as, OPCODE_SUB_I32_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32)); - asm_x86_write_word32(as, src_i32); - } -} - -void asm_x86_mul_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) { - // imul reg32, reg/mem32 -- 0x0f 0xaf /r - asm_x86_write_byte_3(as, 0x0f, 0xaf, MODRM_R32(dest_r32) | MODRM_RM_REG | MODRM_RM_R32(src_r32)); -} - -#if 0 -/* shifts not tested */ -void asm_x86_shl_r32_by_imm(asm_x86_t *as, int r32, int imm) { - asm_x86_write_byte_2(as, OPCODE_SHL_RM32_BY_I8, MODRM_R32(4) | MODRM_RM_REG | MODRM_RM_R32(r32)); - asm_x86_write_byte_1(as, imm); -} - -void asm_x86_shr_r32_by_imm(asm_x86_t *as, int r32, int imm) { - asm_x86_write_byte_2(as, OPCODE_SHR_RM32_BY_I8, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(r32)); - asm_x86_write_byte_1(as, imm); -} - -void asm_x86_sar_r32_by_imm(asm_x86_t *as, int r32, int imm) { - asm_x86_write_byte_2(as, OPCODE_SAR_RM32_BY_I8, MODRM_R32(7) | MODRM_RM_REG | MODRM_RM_R32(r32)); - asm_x86_write_byte_1(as, imm); -} -#endif - -void asm_x86_cmp_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32_b) { - asm_x86_write_byte_2(as, OPCODE_CMP_R32_WITH_RM32, MODRM_R32(src_r32_a) | MODRM_RM_REG | MODRM_RM_R32(src_r32_b)); -} - -#if 0 -void asm_x86_cmp_i32_with_r32(asm_x86_t *as, int src_i32, int src_r32) { - if (SIGNED_FIT8(src_i32)) { - asm_x86_write_byte_2(as, OPCODE_CMP_I8_WITH_RM32, MODRM_R32(7) | MODRM_RM_REG | MODRM_RM_R32(src_r32)); - asm_x86_write_byte_1(as, src_i32 & 0xff); - } else { - asm_x86_write_byte_2(as, OPCODE_CMP_I32_WITH_RM32, MODRM_R32(7) | MODRM_RM_REG | MODRM_RM_R32(src_r32)); - asm_x86_write_word32(as, src_i32); - } -} -#endif - -void asm_x86_test_r8_with_r8(asm_x86_t *as, int src_r32_a, int src_r32_b) { - // TODO implement for other registers - assert(src_r32_a == ASM_X86_REG_EAX); - assert(src_r32_b == ASM_X86_REG_EAX); - asm_x86_write_byte_2(as, OPCODE_TEST_R8_WITH_RM8, MODRM_R32(src_r32_a) | MODRM_RM_REG | MODRM_RM_R32(src_r32_b)); -} - -void asm_x86_setcc_r8(asm_x86_t *as, mp_uint_t jcc_type, int dest_r8) { - asm_x86_write_byte_3(as, OPCODE_SETCC_RM8_A, OPCODE_SETCC_RM8_B | jcc_type, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r8)); -} - -STATIC mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) { - assert(label < as->base.max_num_labels); - return as->base.label_offsets[label]; -} - -void asm_x86_jmp_label(asm_x86_t *as, mp_uint_t label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - if (dest != (mp_uint_t)-1 && rel < 0) { - // is a backwards jump, so we know the size of the jump on the first pass - // calculate rel assuming 8 bit relative jump - rel -= 2; - if (SIGNED_FIT8(rel)) { - asm_x86_write_byte_2(as, OPCODE_JMP_REL8, rel & 0xff); - } else { - rel += 2; - goto large_jump; - } - } else { - // is a forwards jump, so need to assume it's large - large_jump: - rel -= 5; - asm_x86_write_byte_1(as, OPCODE_JMP_REL32); - asm_x86_write_word32(as, rel); - } -} - -void asm_x86_jcc_label(asm_x86_t *as, mp_uint_t jcc_type, mp_uint_t label) { - mp_uint_t dest = get_label_dest(as, label); - mp_int_t rel = dest - as->base.code_offset; - if (dest != (mp_uint_t)-1 && rel < 0) { - // is a backwards jump, so we know the size of the jump on the first pass - // calculate rel assuming 8 bit relative jump - rel -= 2; - if (SIGNED_FIT8(rel)) { - asm_x86_write_byte_2(as, OPCODE_JCC_REL8 | jcc_type, rel & 0xff); - } else { - rel += 2; - goto large_jump; - } - } else { - // is a forwards jump, so need to assume it's large - large_jump: - rel -= 6; - asm_x86_write_byte_2(as, OPCODE_JCC_REL32_A, OPCODE_JCC_REL32_B | jcc_type); - asm_x86_write_word32(as, rel); - } -} - -void asm_x86_entry(asm_x86_t *as, mp_uint_t num_locals) { - asm_x86_push_r32(as, ASM_X86_REG_EBP); - asm_x86_mov_r32_r32(as, ASM_X86_REG_EBP, ASM_X86_REG_ESP); - if (num_locals > 0) { - asm_x86_sub_r32_i32(as, ASM_X86_REG_ESP, num_locals * WORD_SIZE); - } - asm_x86_push_r32(as, ASM_X86_REG_EBX); - asm_x86_push_r32(as, ASM_X86_REG_ESI); - asm_x86_push_r32(as, ASM_X86_REG_EDI); - // TODO align stack on 16-byte boundary - as->num_locals = num_locals; -} - -void asm_x86_exit(asm_x86_t *as) { - asm_x86_pop_r32(as, ASM_X86_REG_EDI); - asm_x86_pop_r32(as, ASM_X86_REG_ESI); - asm_x86_pop_r32(as, ASM_X86_REG_EBX); - asm_x86_write_byte_1(as, OPCODE_LEAVE); - asm_x86_ret(as); -} - -#if 0 -void asm_x86_push_arg(asm_x86_t *as, int src_arg_num) { - asm_x86_push_disp(as, ASM_X86_REG_EBP, 2 * WORD_SIZE + src_arg_num * WORD_SIZE); -} -#endif - -void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32) { - asm_x86_mov_mem32_to_r32(as, ASM_X86_REG_EBP, 2 * WORD_SIZE + src_arg_num * WORD_SIZE, dest_r32); -} - -#if 0 -void asm_x86_mov_r32_to_arg(asm_x86_t *as, int src_r32, int dest_arg_num) { - asm_x86_mov_r32_to_mem32(as, src_r32, ASM_X86_REG_EBP, 2 * WORD_SIZE + dest_arg_num * WORD_SIZE); -} -#endif - -// locals: -// - stored on the stack in ascending order -// - numbered 0 through as->num_locals-1 -// - EBP points above the last local -// -// | EBP -// v -// l0 l1 l2 ... l(n-1) -// ^ ^ -// | low address | high address in RAM -// -STATIC int asm_x86_local_offset_from_ebp(asm_x86_t *as, int local_num) { - return (-as->num_locals + local_num) * WORD_SIZE; -} - -void asm_x86_mov_local_to_r32(asm_x86_t *as, int src_local_num, int dest_r32) { - asm_x86_mov_mem32_to_r32(as, ASM_X86_REG_EBP, asm_x86_local_offset_from_ebp(as, src_local_num), dest_r32); -} - -void asm_x86_mov_r32_to_local(asm_x86_t *as, int src_r32, int dest_local_num) { - asm_x86_mov_r32_to_mem32(as, src_r32, ASM_X86_REG_EBP, asm_x86_local_offset_from_ebp(as, dest_local_num)); -} - -void asm_x86_mov_local_addr_to_r32(asm_x86_t *as, int local_num, int dest_r32) { - int offset = asm_x86_local_offset_from_ebp(as, local_num); - if (offset == 0) { - asm_x86_mov_r32_r32(as, dest_r32, ASM_X86_REG_EBP); - } else { - asm_x86_lea_disp_to_r32(as, ASM_X86_REG_EBP, offset, dest_r32); - } -} - -#if 0 -void asm_x86_push_local(asm_x86_t *as, int local_num) { - asm_x86_push_disp(as, ASM_X86_REG_EBP, asm_x86_local_offset_from_ebp(as, local_num)); -} - -void asm_x86_push_local_addr(asm_x86_t *as, int local_num, int temp_r32) -{ - asm_x86_mov_r32_r32(as, temp_r32, ASM_X86_REG_EBP); - asm_x86_add_i32_to_r32(as, asm_x86_local_offset_from_ebp(as, local_num), temp_r32); - asm_x86_push_r32(as, temp_r32); -} -#endif - -void asm_x86_call_ind(asm_x86_t *as, void *ptr, mp_uint_t n_args, int temp_r32) { - // TODO align stack on 16-byte boundary before the call - assert(n_args <= 5); - if (n_args > 4) { - asm_x86_push_r32(as, ASM_X86_REG_ARG_5); - } - if (n_args > 3) { - asm_x86_push_r32(as, ASM_X86_REG_ARG_4); - } - if (n_args > 2) { - asm_x86_push_r32(as, ASM_X86_REG_ARG_3); - } - if (n_args > 1) { - asm_x86_push_r32(as, ASM_X86_REG_ARG_2); - } - if (n_args > 0) { - asm_x86_push_r32(as, ASM_X86_REG_ARG_1); - } -#ifdef __LP64__ - // We wouldn't run x86 code on an x64 machine. This is here to enable - // testing of the x86 emitter only. - asm_x86_mov_i32_to_r32(as, (int32_t)(int64_t)ptr, temp_r32); -#else - // If we get here, sizeof(int) == sizeof(void*). - asm_x86_mov_i32_to_r32(as, (int32_t)ptr, temp_r32); -#endif - asm_x86_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R32(2) | MODRM_RM_REG | MODRM_RM_R32(temp_r32)); - // this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all - /* - asm_x86_write_byte_1(as, OPCODE_CALL_REL32); - asm_x86_write_word32(as, ptr - (void*)(as->code_base + as->base.code_offset + 4)); - */ - - // the caller must clean up the stack - if (n_args > 0) { - asm_x86_add_i32_to_r32(as, WORD_SIZE * n_args, ASM_X86_REG_ESP); - } -} - -#endif // MICROPY_EMIT_X86 diff --git a/user/mpy/py/asmx86.h b/user/mpy/py/asmx86.h deleted file mode 100644 index 0a00e2e..0000000 --- a/user/mpy/py/asmx86.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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_ASMX86_H -#define MICROPY_INCLUDED_PY_ASMX86_H - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/asmbase.h" - -// x86 cdecl calling convention is: -// - args passed on the stack in reverse order -// - return value in EAX -// - caller cleans up the stack after a call -// - stack must be aligned to 16-byte boundary before all calls -// - EAX, ECX, EDX are caller-save -// - EBX, ESI, EDI, EBP, ESP, EIP are callee-save - -// In the functions below, argument order follows x86 docs and generally -// the destination is the first argument. -// NOTE: this is a change from the old convention used in this file and -// some functions still use the old (reverse) convention. - -#define ASM_X86_REG_EAX (0) -#define ASM_X86_REG_ECX (1) -#define ASM_X86_REG_EDX (2) -#define ASM_X86_REG_EBX (3) -#define ASM_X86_REG_ESP (4) -#define ASM_X86_REG_EBP (5) -#define ASM_X86_REG_ESI (6) -#define ASM_X86_REG_EDI (7) - -// x86 passes values on the stack, but the emitter is register based, so we need -// to define registers that can temporarily hold the function arguments. They -// need to be defined here so that asm_x86_call_ind can push them onto the stack -// before the call. -#define ASM_X86_REG_ARG_1 ASM_X86_REG_EAX -#define ASM_X86_REG_ARG_2 ASM_X86_REG_ECX -#define ASM_X86_REG_ARG_3 ASM_X86_REG_EDX -#define ASM_X86_REG_ARG_4 ASM_X86_REG_EBX -#define ASM_X86_REG_ARG_5 ASM_X86_REG_ESI - -// condition codes, used for jcc and setcc (despite their j-name!) -#define ASM_X86_CC_JB (0x2) // below, unsigned -#define ASM_X86_CC_JZ (0x4) -#define ASM_X86_CC_JE (0x4) -#define ASM_X86_CC_JNZ (0x5) -#define ASM_X86_CC_JNE (0x5) -#define ASM_X86_CC_JL (0xc) // less, signed -#define ASM_X86_CC_JGE (0xd) // greater or equal, signed -#define ASM_X86_CC_JLE (0xe) // less or equal, signed -#define ASM_X86_CC_JG (0xf) // greater, signed - -typedef struct _asm_x86_t { - mp_asm_base_t base; - int num_locals; -} asm_x86_t; - -static inline void asm_x86_end_pass(asm_x86_t *as) { - (void)as; -} - -void asm_x86_mov_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); -void asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32); -void asm_x86_mov_i32_to_r32_aligned(asm_x86_t *as, int32_t src_i32, int dest_r32); -void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp); -void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp); -void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp); -void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32); -void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32); -void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32); -void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32); -void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32); -void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32); -void asm_x86_shl_r32_cl(asm_x86_t* as, int dest_r32); -void asm_x86_sar_r32_cl(asm_x86_t* as, int dest_r32); -void asm_x86_add_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); -void asm_x86_sub_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); -void asm_x86_mul_r32_r32(asm_x86_t* as, int dest_r32, int src_r32); -void asm_x86_cmp_r32_with_r32(asm_x86_t* as, int src_r32_a, int src_r32_b); -void asm_x86_test_r8_with_r8(asm_x86_t* as, int src_r32_a, int src_r32_b); -void asm_x86_setcc_r8(asm_x86_t* as, mp_uint_t jcc_type, int dest_r8); -void asm_x86_jmp_label(asm_x86_t* as, mp_uint_t label); -void asm_x86_jcc_label(asm_x86_t* as, mp_uint_t jcc_type, mp_uint_t label); -void asm_x86_entry(asm_x86_t* as, mp_uint_t num_locals); -void asm_x86_exit(asm_x86_t* as); -void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32); -void asm_x86_mov_local_to_r32(asm_x86_t* as, int src_local_num, int dest_r32); -void asm_x86_mov_r32_to_local(asm_x86_t* as, int src_r32, int dest_local_num); -void asm_x86_mov_local_addr_to_r32(asm_x86_t* as, int local_num, int dest_r32); -void asm_x86_call_ind(asm_x86_t* as, void* ptr, mp_uint_t n_args, int temp_r32); - -#if GENERIC_ASM_API - -// The following macros provide a (mostly) arch-independent API to -// generate native code, and are used by the native emitter. - -#define ASM_WORD_SIZE (4) - -#define REG_RET ASM_X86_REG_EAX -#define REG_ARG_1 ASM_X86_REG_ARG_1 -#define REG_ARG_2 ASM_X86_REG_ARG_2 -#define REG_ARG_3 ASM_X86_REG_ARG_3 -#define REG_ARG_4 ASM_X86_REG_ARG_4 -#define REG_ARG_5 ASM_X86_REG_ARG_5 - -// caller-save, so can be used as temporaries -#define REG_TEMP0 ASM_X86_REG_EAX -#define REG_TEMP1 ASM_X86_REG_ECX -#define REG_TEMP2 ASM_X86_REG_EDX - -// callee-save, so can be used as locals -#define REG_LOCAL_1 ASM_X86_REG_EBX -#define REG_LOCAL_2 ASM_X86_REG_ESI -#define REG_LOCAL_3 ASM_X86_REG_EDI -#define REG_LOCAL_NUM (3) - -#define ASM_T asm_x86_t -#define ASM_END_PASS asm_x86_end_pass -#define ASM_ENTRY asm_x86_entry -#define ASM_EXIT asm_x86_exit - -#define ASM_JUMP asm_x86_jmp_label -#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ - do { \ - asm_x86_test_r8_with_r8(as, reg, reg); \ - asm_x86_jcc_label(as, ASM_X86_CC_JZ, label); \ - } while (0) -#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ - do { \ - asm_x86_test_r8_with_r8(as, reg, reg); \ - asm_x86_jcc_label(as, ASM_X86_CC_JNZ, label); \ - } while (0) -#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ - do { \ - asm_x86_cmp_r32_with_r32(as, reg1, reg2); \ - asm_x86_jcc_label(as, ASM_X86_CC_JE, label); \ - } while (0) -#define ASM_CALL_IND(as, ptr, idx) asm_x86_call_ind(as, ptr, mp_f_n_args[idx], ASM_X86_REG_EAX) - -#define ASM_MOV_REG_TO_LOCAL asm_x86_mov_r32_to_local -#define ASM_MOV_IMM_TO_REG asm_x86_mov_i32_to_r32 -#define ASM_MOV_ALIGNED_IMM_TO_REG asm_x86_mov_i32_to_r32_aligned -#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ - do { \ - asm_x86_mov_i32_to_r32(as, (imm), (reg_temp)); \ - asm_x86_mov_r32_to_local(as, (reg_temp), (local_num)); \ - } while (false) -#define ASM_MOV_LOCAL_TO_REG asm_x86_mov_local_to_r32 -#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_x86_mov_r32_r32((as), (reg_dest), (reg_src)) -#define ASM_MOV_LOCAL_ADDR_TO_REG asm_x86_mov_local_addr_to_r32 - -#define ASM_LSL_REG(as, reg) asm_x86_shl_r32_cl((as), (reg)) -#define ASM_ASR_REG(as, reg) asm_x86_sar_r32_cl((as), (reg)) -#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_x86_or_r32_r32((as), (reg_dest), (reg_src)) -#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_x86_xor_r32_r32((as), (reg_dest), (reg_src)) -#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_x86_and_r32_r32((as), (reg_dest), (reg_src)) -#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_x86_add_r32_r32((as), (reg_dest), (reg_src)) -#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_x86_sub_r32_r32((as), (reg_dest), (reg_src)) -#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_x86_mul_r32_r32((as), (reg_dest), (reg_src)) - -#define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem32_to_r32((as), (reg_base), 0, (reg_dest)) -#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_x86_mov_mem32_to_r32((as), (reg_base), 4 * (word_offset), (reg_dest)) -#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem8_to_r32zx((as), (reg_base), 0, (reg_dest)) -#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem16_to_r32zx((as), (reg_base), 0, (reg_dest)) -#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem32_to_r32((as), (reg_base), 0, (reg_dest)) - -#define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) -#define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 4 * (word_offset)) -#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_x86_mov_r8_to_mem8((as), (reg_src), (reg_base), 0) -#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_x86_mov_r16_to_mem16((as), (reg_src), (reg_base), 0) -#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) - -#endif // GENERIC_ASM_API - -#endif // MICROPY_INCLUDED_PY_ASMX86_H diff --git a/user/mpy/py/asmxtensa.c b/user/mpy/py/asmxtensa.c deleted file mode 100644 index 00448df..0000000 --- a/user/mpy/py/asmxtensa.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include - -#include "py/mpconfig.h" - -// wrapper around everything in this file -#if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA - -#include "py/asmxtensa.h" - -#define WORD_SIZE (4) -#define SIGNED_FIT8(x) ((((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)) -#define SIGNED_FIT12(x) ((((x) & 0xfffff800) == 0) || (((x) & 0xfffff800) == 0xfffff800)) - -void asm_xtensa_end_pass(asm_xtensa_t *as) { - as->num_const = as->cur_const; - as->cur_const = 0; - - #if 0 - // make a hex dump of the machine code - if (as->base.pass == MP_ASM_PASS_EMIT) { - uint8_t *d = as->base.code_base; - printf("XTENSA ASM:"); - for (int i = 0; i < ((as->base.code_size + 15) & ~15); ++i) { - if (i % 16 == 0) { - printf("\n%08x:", (uint32_t)&d[i]); - } - if (i % 2 == 0) { - printf(" "); - } - printf("%02x", d[i]); - } - printf("\n"); - } - #endif -} - -void asm_xtensa_entry(asm_xtensa_t *as, int num_locals) { - // jump over the constants - asm_xtensa_op_j(as, as->num_const * WORD_SIZE + 4 - 4); - mp_asm_base_get_cur_to_write_bytes(&as->base, 1); // padding/alignment byte - as->const_table = (uint32_t*)mp_asm_base_get_cur_to_write_bytes(&as->base, as->num_const * 4); - - // adjust the stack-pointer to store a0, a12, a13, a14 and locals, 16-byte aligned - as->stack_adjust = (((4 + num_locals) * WORD_SIZE) + 15) & ~15; - asm_xtensa_op_addi(as, ASM_XTENSA_REG_A1, ASM_XTENSA_REG_A1, -as->stack_adjust); - - // save return value (a0) and callee-save registers (a12, a13, a14) - asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A0, ASM_XTENSA_REG_A1, 0); - asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A12, ASM_XTENSA_REG_A1, 1); - asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A13, ASM_XTENSA_REG_A1, 2); - asm_xtensa_op_s32i_n(as, ASM_XTENSA_REG_A14, ASM_XTENSA_REG_A1, 3); -} - -void asm_xtensa_exit(asm_xtensa_t *as) { - // restore registers - asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A14, ASM_XTENSA_REG_A1, 3); - asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A13, ASM_XTENSA_REG_A1, 2); - asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A12, ASM_XTENSA_REG_A1, 1); - asm_xtensa_op_l32i_n(as, ASM_XTENSA_REG_A0, ASM_XTENSA_REG_A1, 0); - - // restore stack-pointer and return - asm_xtensa_op_addi(as, ASM_XTENSA_REG_A1, ASM_XTENSA_REG_A1, as->stack_adjust); - asm_xtensa_op_ret_n(as); -} - -STATIC uint32_t get_label_dest(asm_xtensa_t *as, uint label) { - assert(label < as->base.max_num_labels); - return as->base.label_offsets[label]; -} - -void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op) { - uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2); - if (c != NULL) { - c[0] = op; - c[1] = op >> 8; - } -} - -void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op) { - uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3); - if (c != NULL) { - c[0] = op; - c[1] = op >> 8; - c[2] = op >> 16; - } -} - -void asm_xtensa_j_label(asm_xtensa_t *as, uint label) { - uint32_t dest = get_label_dest(as, label); - int32_t rel = dest - as->base.code_offset - 4; - // we assume rel, as a signed int, fits in 18-bits - asm_xtensa_op_j(as, rel); -} - -void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label) { - uint32_t dest = get_label_dest(as, label); - int32_t rel = dest - as->base.code_offset - 4; - if (as->base.pass == MP_ASM_PASS_EMIT && !SIGNED_FIT12(rel)) { - printf("ERROR: xtensa bccz out of range\n"); - } - asm_xtensa_op_bccz(as, cond, reg, rel); -} - -void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label) { - uint32_t dest = get_label_dest(as, label); - int32_t rel = dest - as->base.code_offset - 4; - if (as->base.pass == MP_ASM_PASS_EMIT && !SIGNED_FIT8(rel)) { - printf("ERROR: xtensa bcc out of range\n"); - } - asm_xtensa_op_bcc(as, cond, reg1, reg2, rel); -} - -// convenience function; reg_dest must be different from reg_src[12] -void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2) { - asm_xtensa_op_movi_n(as, reg_dest, 1); - asm_xtensa_op_bcc(as, cond, reg_src1, reg_src2, 1); - asm_xtensa_op_movi_n(as, reg_dest, 0); -} - -void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) { - if (SIGNED_FIT12(i32)) { - asm_xtensa_op_movi(as, reg_dest, i32); - } else { - // load the constant - asm_xtensa_op_l32r(as, reg_dest, as->base.code_offset, 4 + as->cur_const * WORD_SIZE); - // store the constant in the table - if (as->const_table != NULL) { - as->const_table[as->cur_const] = i32; - } - ++as->cur_const; - } -} - -void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src) { - asm_xtensa_op_s32i(as, reg_src, ASM_XTENSA_REG_A1, 4 + local_num); -} - -void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num) { - asm_xtensa_op_l32i(as, reg_dest, ASM_XTENSA_REG_A1, 4 + local_num); -} - -void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num) { - asm_xtensa_op_mov_n(as, reg_dest, ASM_XTENSA_REG_A1); - asm_xtensa_op_addi(as, reg_dest, reg_dest, (4 + local_num) * WORD_SIZE); -} - -#endif // MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA diff --git a/user/mpy/py/asmxtensa.h b/user/mpy/py/asmxtensa.h deleted file mode 100644 index 7db6c0d..0000000 --- a/user/mpy/py/asmxtensa.h +++ /dev/null @@ -1,324 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_ASMXTENSA_H -#define MICROPY_INCLUDED_PY_ASMXTENSA_H - -#include "py/asmbase.h" - -// calling conventions: -// up to 6 args in a2-a7 -// return value in a2 -// PC stored in a0 -// stack pointer is a1, stack full descending, is aligned to 16 bytes -// callee save: a1, a12, a13, a14, a15 -// caller save: a3 - -#define ASM_XTENSA_REG_A0 (0) -#define ASM_XTENSA_REG_A1 (1) -#define ASM_XTENSA_REG_A2 (2) -#define ASM_XTENSA_REG_A3 (3) -#define ASM_XTENSA_REG_A4 (4) -#define ASM_XTENSA_REG_A5 (5) -#define ASM_XTENSA_REG_A6 (6) -#define ASM_XTENSA_REG_A7 (7) -#define ASM_XTENSA_REG_A8 (8) -#define ASM_XTENSA_REG_A9 (9) -#define ASM_XTENSA_REG_A10 (10) -#define ASM_XTENSA_REG_A11 (11) -#define ASM_XTENSA_REG_A12 (12) -#define ASM_XTENSA_REG_A13 (13) -#define ASM_XTENSA_REG_A14 (14) -#define ASM_XTENSA_REG_A15 (15) - -// for bccz -#define ASM_XTENSA_CCZ_EQ (0) -#define ASM_XTENSA_CCZ_NE (1) - -// for bcc and setcc -#define ASM_XTENSA_CC_NONE (0) -#define ASM_XTENSA_CC_EQ (1) -#define ASM_XTENSA_CC_LT (2) -#define ASM_XTENSA_CC_LTU (3) -#define ASM_XTENSA_CC_ALL (4) -#define ASM_XTENSA_CC_BC (5) -#define ASM_XTENSA_CC_ANY (8) -#define ASM_XTENSA_CC_NE (9) -#define ASM_XTENSA_CC_GE (10) -#define ASM_XTENSA_CC_GEU (11) -#define ASM_XTENSA_CC_NALL (12) -#define ASM_XTENSA_CC_BS (13) - -// macros for encoding instructions (little endian versions) -#define ASM_XTENSA_ENCODE_RRR(op0, op1, op2, r, s, t) \ - ((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_RRI4(op0, op1, r, s, t, imm4) \ - (((imm4) << 20) | ((op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_RRI8(op0, r, s, t, imm8) \ - ((((uint32_t)imm8) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_RI16(op0, t, imm16) \ - (((imm16) << 8) | ((t) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_RSR(op0, op1, op2, rs, t) \ - (((op2) << 20) | ((op1) << 16) | ((rs) << 8) | ((t) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_CALL(op0, n, offset) \ - (((offset) << 6) | ((n) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_CALLX(op0, op1, op2, r, s, m, n) \ - ((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_BRI8(op0, r, s, m, n, imm8) \ - (((imm8) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_BRI12(op0, s, m, n, imm12) \ - (((imm12) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_RRRN(op0, r, s, t) \ - (((r) << 12) | ((s) << 8) | ((t) << 4) | (op0)) -#define ASM_XTENSA_ENCODE_RI7(op0, s, imm7) \ - ((((imm7) & 0xf) << 12) | ((s) << 8) | ((imm7) & 0x70) | (op0)) - -typedef struct _asm_xtensa_t { - mp_asm_base_t base; - uint32_t cur_const; - uint32_t num_const; - uint32_t *const_table; - uint32_t stack_adjust; -} asm_xtensa_t; - -void asm_xtensa_end_pass(asm_xtensa_t *as); - -void asm_xtensa_entry(asm_xtensa_t *as, int num_locals); -void asm_xtensa_exit(asm_xtensa_t *as); - -void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op); -void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op); - -// raw instructions - -static inline void asm_xtensa_op_add(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 8, reg_dest, reg_src_a, reg_src_b)); -} - -static inline void asm_xtensa_op_addi(asm_xtensa_t *as, uint reg_dest, uint reg_src, int imm8) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 12, reg_dest, reg_src, imm8 & 0xff)); -} - -static inline void asm_xtensa_op_and(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 1, reg_dest, reg_src_a, reg_src_b)); -} - -static inline void asm_xtensa_op_bcc(asm_xtensa_t *as, uint cond, uint reg_src1, uint reg_src2, int32_t rel8) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(7, cond, reg_src1, reg_src2, rel8 & 0xff)); -} - -static inline void asm_xtensa_op_bccz(asm_xtensa_t *as, uint cond, uint reg_src, int32_t rel12) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_BRI12(6, reg_src, cond, 1, rel12 & 0xfff)); -} - -static inline void asm_xtensa_op_callx0(asm_xtensa_t *as, uint reg) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_CALLX(0, 0, 0, 0, reg, 3, 0)); -} - -static inline void asm_xtensa_op_j(asm_xtensa_t *as, int32_t rel18) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_CALL(6, 0, rel18 & 0x3ffff)); -} - -static inline void asm_xtensa_op_jx(asm_xtensa_t *as, uint reg) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_CALLX(0, 0, 0, 0, reg, 2, 2)); -} - -static inline void asm_xtensa_op_l8ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint byte_offset) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 0, reg_base, reg_dest, byte_offset & 0xff)); -} - -static inline void asm_xtensa_op_l16ui(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint half_word_offset) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 1, reg_base, reg_dest, half_word_offset & 0xff)); -} - -static inline void asm_xtensa_op_l32i(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 2, reg_base, reg_dest, word_offset & 0xff)); -} - -static inline void asm_xtensa_op_l32i_n(asm_xtensa_t *as, uint reg_dest, uint reg_base, uint word_offset) { - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(8, word_offset & 0xf, reg_base, reg_dest)); -} - -static inline void asm_xtensa_op_l32r(asm_xtensa_t *as, uint reg_dest, uint32_t op_off, uint32_t dest_off) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RI16(1, reg_dest, ((dest_off - ((op_off + 3) & ~3)) >> 2) & 0xffff)); -} - -static inline void asm_xtensa_op_mov_n(asm_xtensa_t *as, uint reg_dest, uint reg_src) { - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(13, 0, reg_src, reg_dest)); -} - -static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t imm12) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 10, (imm12 >> 8) & 0xf, reg_dest, imm12 & 0xff)); -} - -static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) { - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm4)); -} - -static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 2, 8, reg_dest, reg_src_a, reg_src_b)); -} - -static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 2, reg_dest, reg_src_a, reg_src_b)); -} - -static inline void asm_xtensa_op_ret_n(asm_xtensa_t *as) { - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(13, 15, 0, 0)); -} - -static inline void asm_xtensa_op_s8i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint byte_offset) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 4, reg_base, reg_src, byte_offset & 0xff)); -} - -static inline void asm_xtensa_op_s16i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint half_word_offset) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 5, reg_base, reg_src, half_word_offset & 0xff)); -} - -static inline void asm_xtensa_op_s32i(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 6, reg_base, reg_src, word_offset & 0xff)); -} - -static inline void asm_xtensa_op_s32i_n(asm_xtensa_t *as, uint reg_src, uint reg_base, uint word_offset) { - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RRRN(9, word_offset & 0xf, reg_base, reg_src)); -} - -static inline void asm_xtensa_op_sll(asm_xtensa_t *as, uint reg_dest, uint reg_src) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 1, 10, reg_dest, reg_src, 0)); -} - -static inline void asm_xtensa_op_sra(asm_xtensa_t *as, uint reg_dest, uint reg_src) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 1, 11, reg_dest, 0, reg_src)); -} - -static inline void asm_xtensa_op_ssl(asm_xtensa_t *as, uint reg_src) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 4, 1, reg_src, 0)); -} - -static inline void asm_xtensa_op_ssr(asm_xtensa_t *as, uint reg_src) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 4, 0, reg_src, 0)); -} - -static inline void asm_xtensa_op_sub(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 12, reg_dest, reg_src_a, reg_src_b)); -} - -static inline void asm_xtensa_op_xor(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { - asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 3, reg_dest, reg_src_a, reg_src_b)); -} - -// convenience functions -void asm_xtensa_j_label(asm_xtensa_t *as, uint label); -void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, uint label); -void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1, uint reg2, uint label); -void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_dest, uint reg_src1, uint reg_src2); -void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32); -void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src); -void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num); -void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num); - -#if GENERIC_ASM_API - -// The following macros provide a (mostly) arch-independent API to -// generate native code, and are used by the native emitter. - -#define ASM_WORD_SIZE (4) - -#define REG_RET ASM_XTENSA_REG_A2 -#define REG_ARG_1 ASM_XTENSA_REG_A2 -#define REG_ARG_2 ASM_XTENSA_REG_A3 -#define REG_ARG_3 ASM_XTENSA_REG_A4 -#define REG_ARG_4 ASM_XTENSA_REG_A5 -#define REG_ARG_5 ASM_XTENSA_REG_A6 - -#define REG_TEMP0 ASM_XTENSA_REG_A2 -#define REG_TEMP1 ASM_XTENSA_REG_A3 -#define REG_TEMP2 ASM_XTENSA_REG_A4 - -#define REG_LOCAL_1 ASM_XTENSA_REG_A12 -#define REG_LOCAL_2 ASM_XTENSA_REG_A13 -#define REG_LOCAL_3 ASM_XTENSA_REG_A14 -#define REG_LOCAL_NUM (3) - -#define ASM_T asm_xtensa_t -#define ASM_END_PASS asm_xtensa_end_pass -#define ASM_ENTRY asm_xtensa_entry -#define ASM_EXIT asm_xtensa_exit - -#define ASM_JUMP asm_xtensa_j_label -#define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ - asm_xtensa_bccz_reg_label(as, ASM_XTENSA_CCZ_EQ, reg, label) -#define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ - asm_xtensa_bccz_reg_label(as, ASM_XTENSA_CCZ_NE, reg, label) -#define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ - asm_xtensa_bcc_reg_reg_label(as, ASM_XTENSA_CC_EQ, reg1, reg2, label) -#define ASM_CALL_IND(as, ptr, idx) \ - do { \ - asm_xtensa_mov_reg_i32(as, ASM_XTENSA_REG_A0, (uint32_t)ptr); \ - asm_xtensa_op_callx0(as, ASM_XTENSA_REG_A0); \ - } while (0) - -#define ASM_MOV_REG_TO_LOCAL(as, reg, local_num) asm_xtensa_mov_local_reg(as, (local_num), (reg)) -#define ASM_MOV_IMM_TO_REG(as, imm, reg) asm_xtensa_mov_reg_i32(as, (reg), (imm)) -#define ASM_MOV_ALIGNED_IMM_TO_REG(as, imm, reg) asm_xtensa_mov_reg_i32(as, (reg), (imm)) -#define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ - do { \ - asm_xtensa_mov_reg_i32(as, (reg_temp), (imm)); \ - asm_xtensa_mov_local_reg(as, (local_num), (reg_temp)); \ - } while (0) -#define ASM_MOV_LOCAL_TO_REG(as, local_num, reg) asm_xtensa_mov_reg_local(as, (reg), (local_num)) -#define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_mov_n((as), (reg_dest), (reg_src)) -#define ASM_MOV_LOCAL_ADDR_TO_REG(as, local_num, reg) asm_xtensa_mov_reg_local_addr(as, (reg), (local_num)) - -#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) \ - do { \ - asm_xtensa_op_ssl((as), (reg_shift)); \ - asm_xtensa_op_sll((as), (reg_dest), (reg_dest)); \ - } while (0) -#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) \ - do { \ - asm_xtensa_op_ssr((as), (reg_shift)); \ - asm_xtensa_op_sra((as), (reg_dest), (reg_dest)); \ - } while (0) -#define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_or((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_xor((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_and((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_add((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_sub((as), (reg_dest), (reg_dest), (reg_src)) -#define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_xtensa_op_mull((as), (reg_dest), (reg_dest), (reg_src)) - -#define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_xtensa_op_l32i_n((as), (reg_dest), (reg_base), (word_offset)) -#define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l8ui((as), (reg_dest), (reg_base), 0) -#define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l16ui((as), (reg_dest), (reg_base), 0) -#define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_xtensa_op_l32i_n((as), (reg_dest), (reg_base), 0) - -#define ASM_STORE_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_xtensa_op_s32i_n((as), (reg_dest), (reg_base), (word_offset)) -#define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s8i((as), (reg_src), (reg_base), 0) -#define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s16i((as), (reg_src), (reg_base), 0) -#define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_xtensa_op_s32i_n((as), (reg_src), (reg_base), 0) - -#endif // GENERIC_ASM_API - -#endif // MICROPY_INCLUDED_PY_ASMXTENSA_H diff --git a/user/mpy/py/bc.c b/user/mpy/py/bc.c deleted file mode 100644 index 917eba5..0000000 --- a/user/mpy/py/bc.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/objfun.h" -#include "py/runtime0.h" -#include "py/bc0.h" -#include "py/bc.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#else // don't print debugging info -#define DEBUG_PRINT (0) -#define DEBUG_printf(...) (void)0 -#endif - -mp_uint_t mp_decode_uint(const byte **ptr) { - mp_uint_t unum = 0; - byte val; - const byte *p = *ptr; - do { - val = *p++; - unum = (unum << 7) | (val & 0x7f); - } while ((val & 0x80) != 0); - *ptr = p; - return unum; -} - -// This function is used to help reduce stack usage at the caller, for the case when -// the caller doesn't need to increase the ptr argument. If ptr is a local variable -// and the caller uses mp_decode_uint(&ptr) instead of this function, then the compiler -// must allocate a slot on the stack for ptr, and this slot cannot be reused for -// anything else in the function because the pointer may have been stored in a global -// and reused later in the function. -mp_uint_t mp_decode_uint_value(const byte *ptr) { - return mp_decode_uint(&ptr); -} - -// This function is used to help reduce stack usage at the caller, for the case when -// the caller doesn't need the actual value and just wants to skip over it. -const byte *mp_decode_uint_skip(const byte *ptr) { - while ((*ptr++) & 0x80) { - } - return ptr; -} - -STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) { -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE - // generic message, used also for other argument issues - (void)f; - (void)expected; - (void)given; - mp_arg_error_terse_mismatch(); -#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL - (void)f; - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function takes %d positional arguments but %d were given", expected, given)); -#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "%q() takes %d positional arguments but %d were given", - mp_obj_fun_get_name(MP_OBJ_FROM_PTR(f)), expected, given)); -#endif -} - -#if DEBUG_PRINT -STATIC void dump_args(const mp_obj_t *a, size_t sz) { - DEBUG_printf("%p: ", a); - for (size_t i = 0; i < sz; i++) { - DEBUG_printf("%p ", a[i]); - } - DEBUG_printf("\n"); -} -#else -#define dump_args(...) (void)0 -#endif - -// On entry code_state should be allocated somewhere (stack/heap) and -// contain the following valid entries: -// - code_state->fun_bc should contain a pointer to the function object -// - code_state->ip should contain the offset in bytes from the pointer -// code_state->fun_bc->bytecode to the entry n_state (0 for bytecode, non-zero for native) -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) { - // This function is pretty complicated. It's main aim is to be efficient in speed and RAM - // usage for the common case of positional only args. - - // get the function object that we want to set up (could be bytecode or native code) - mp_obj_fun_bc_t *self = code_state->fun_bc; - - // ip comes in as an offset into bytecode, so turn it into a true pointer - code_state->ip = self->bytecode + (size_t)code_state->ip; - - #if MICROPY_STACKLESS - code_state->prev = NULL; - #endif - - // get params - size_t n_state = mp_decode_uint(&code_state->ip); - code_state->ip = mp_decode_uint_skip(code_state->ip); // skip n_exc_stack - size_t scope_flags = *code_state->ip++; - size_t n_pos_args = *code_state->ip++; - size_t n_kwonly_args = *code_state->ip++; - size_t n_def_pos_args = *code_state->ip++; - - code_state->sp = &code_state->state[0] - 1; - code_state->exc_sp = (mp_exc_stack_t*)(code_state->state + n_state) - 1; - - // zero out the local stack to begin with - memset(code_state->state, 0, n_state * sizeof(*code_state->state)); - - const mp_obj_t *kwargs = args + n_args; - - // var_pos_kw_args points to the stack where the var-args tuple, and var-kw dict, should go (if they are needed) - mp_obj_t *var_pos_kw_args = &code_state->state[n_state - 1 - n_pos_args - n_kwonly_args]; - - // check positional arguments - - if (n_args > n_pos_args) { - // given more than enough arguments - if ((scope_flags & MP_SCOPE_FLAG_VARARGS) == 0) { - fun_pos_args_mismatch(self, n_pos_args, n_args); - } - // put extra arguments in varargs tuple - *var_pos_kw_args-- = mp_obj_new_tuple(n_args - n_pos_args, args + n_pos_args); - n_args = n_pos_args; - } else { - if ((scope_flags & MP_SCOPE_FLAG_VARARGS) != 0) { - DEBUG_printf("passing empty tuple as *args\n"); - *var_pos_kw_args-- = mp_const_empty_tuple; - } - // Apply processing and check below only if we don't have kwargs, - // otherwise, kw handling code below has own extensive checks. - if (n_kw == 0 && (scope_flags & MP_SCOPE_FLAG_DEFKWARGS) == 0) { - if (n_args >= (size_t)(n_pos_args - n_def_pos_args)) { - // given enough arguments, but may need to use some default arguments - for (size_t i = n_args; i < n_pos_args; i++) { - code_state->state[n_state - 1 - i] = self->extra_args[i - (n_pos_args - n_def_pos_args)]; - } - } else { - fun_pos_args_mismatch(self, n_pos_args - n_def_pos_args, n_args); - } - } - } - - // copy positional args into state - for (size_t i = 0; i < n_args; i++) { - code_state->state[n_state - 1 - i] = args[i]; - } - - // check keyword arguments - - if (n_kw != 0 || (scope_flags & MP_SCOPE_FLAG_DEFKWARGS) != 0) { - DEBUG_printf("Initial args: "); - dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); - - mp_obj_t dict = MP_OBJ_NULL; - if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) { - dict = mp_obj_new_dict(n_kw); // TODO: better go conservative with 0? - *var_pos_kw_args = dict; - } - - // get pointer to arg_names array - const mp_obj_t *arg_names = (const mp_obj_t*)self->const_table; - - for (size_t i = 0; i < n_kw; i++) { - // the keys in kwargs are expected to be qstr objects - mp_obj_t wanted_arg_name = kwargs[2 * i]; - for (size_t j = 0; j < n_pos_args + n_kwonly_args; j++) { - if (wanted_arg_name == arg_names[j]) { - if (code_state->state[n_state - 1 - j] != MP_OBJ_NULL) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function got multiple values for argument '%q'", MP_OBJ_QSTR_VALUE(wanted_arg_name))); - } - code_state->state[n_state - 1 - j] = kwargs[2 * i + 1]; - goto continue2; - } - } - // Didn't find name match with positional args - if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) == 0) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("unexpected keyword argument"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "unexpected keyword argument '%q'", MP_OBJ_QSTR_VALUE(wanted_arg_name))); - } - } - mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]); -continue2:; - } - - DEBUG_printf("Args with kws flattened: "); - dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); - - // fill in defaults for positional args - mp_obj_t *d = &code_state->state[n_state - n_pos_args]; - mp_obj_t *s = &self->extra_args[n_def_pos_args - 1]; - for (size_t i = n_def_pos_args; i > 0; i--, d++, s--) { - if (*d == MP_OBJ_NULL) { - *d = *s; - } - } - - DEBUG_printf("Args after filling default positional: "); - dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); - - // Check that all mandatory positional args are specified - while (d < &code_state->state[n_state]) { - if (*d++ == MP_OBJ_NULL) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function missing required positional argument #%d", &code_state->state[n_state] - d)); - } - } - - // Check that all mandatory keyword args are specified - // Fill in default kw args if we have them - for (size_t i = 0; i < n_kwonly_args; i++) { - if (code_state->state[n_state - 1 - n_pos_args - i] == MP_OBJ_NULL) { - mp_map_elem_t *elem = NULL; - if ((scope_flags & MP_SCOPE_FLAG_DEFKWARGS) != 0) { - elem = mp_map_lookup(&((mp_obj_dict_t*)MP_OBJ_TO_PTR(self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP); - } - if (elem != NULL) { - code_state->state[n_state - 1 - n_pos_args - i] = elem->value; - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function missing required keyword argument '%q'", MP_OBJ_QSTR_VALUE(arg_names[n_pos_args + i]))); - } - } - } - - } else { - // no keyword arguments given - if (n_kwonly_args != 0) { - mp_raise_TypeError("function missing keyword-only argument"); - } - if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) { - *var_pos_kw_args = mp_obj_new_dict(0); - } - } - - // get the ip and skip argument names - const byte *ip = code_state->ip; - - // jump over code info (source file and line-number mapping) - ip += mp_decode_uint_value(ip); - - // bytecode prelude: initialise closed over variables - size_t local_num; - while ((local_num = *ip++) != 255) { - code_state->state[n_state - 1 - local_num] = - mp_obj_new_cell(code_state->state[n_state - 1 - local_num]); - } - - // now that we skipped over the prelude, set the ip for the VM - code_state->ip = ip; - - DEBUG_printf("Calling: n_pos_args=%d, n_kwonly_args=%d\n", n_pos_args, n_kwonly_args); - dump_args(code_state->state + n_state - n_pos_args - n_kwonly_args, n_pos_args + n_kwonly_args); - dump_args(code_state->state, n_state); -} - -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE - -// The following table encodes the number of bytes that a specific opcode -// takes up. There are 3 special opcodes that always have an extra byte: -// MP_BC_MAKE_CLOSURE -// MP_BC_MAKE_CLOSURE_DEFARGS -// MP_BC_RAISE_VARARGS -// There are 4 special opcodes that have an extra byte only when -// MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE is enabled: -// MP_BC_LOAD_NAME -// MP_BC_LOAD_GLOBAL -// MP_BC_LOAD_ATTR -// MP_BC_STORE_ATTR -#define OC4(a, b, c, d) (a | (b << 2) | (c << 4) | (d << 6)) -#define U (0) // undefined opcode -#define B (MP_OPCODE_BYTE) // single byte -#define Q (MP_OPCODE_QSTR) // single byte plus 2-byte qstr -#define V (MP_OPCODE_VAR_UINT) // single byte plus variable encoded unsigned int -#define O (MP_OPCODE_OFFSET) // single byte plus 2-byte bytecode offset -STATIC const byte opcode_format_table[64] = { - OC4(U, U, U, U), // 0x00-0x03 - OC4(U, U, U, U), // 0x04-0x07 - OC4(U, U, U, U), // 0x08-0x0b - OC4(U, U, U, U), // 0x0c-0x0f - OC4(B, B, B, U), // 0x10-0x13 - OC4(V, U, Q, V), // 0x14-0x17 - OC4(B, V, V, Q), // 0x18-0x1b - OC4(Q, Q, Q, Q), // 0x1c-0x1f - OC4(B, B, V, V), // 0x20-0x23 - OC4(Q, Q, Q, B), // 0x24-0x27 - OC4(V, V, Q, Q), // 0x28-0x2b - OC4(U, U, U, U), // 0x2c-0x2f - OC4(B, B, B, B), // 0x30-0x33 - OC4(B, O, O, O), // 0x34-0x37 - OC4(O, O, U, U), // 0x38-0x3b - OC4(U, O, B, O), // 0x3c-0x3f - OC4(O, B, B, O), // 0x40-0x43 - OC4(B, B, O, U), // 0x44-0x47 - OC4(U, U, U, U), // 0x48-0x4b - OC4(U, U, U, U), // 0x4c-0x4f - OC4(V, V, U, V), // 0x50-0x53 - OC4(B, U, V, V), // 0x54-0x57 - OC4(V, V, V, B), // 0x58-0x5b - OC4(B, B, B, U), // 0x5c-0x5f - OC4(V, V, V, V), // 0x60-0x63 - OC4(V, V, V, V), // 0x64-0x67 - OC4(Q, Q, B, U), // 0x68-0x6b - OC4(U, U, U, U), // 0x6c-0x6f - - OC4(B, B, B, B), // 0x70-0x73 - OC4(B, B, B, B), // 0x74-0x77 - OC4(B, B, B, B), // 0x78-0x7b - OC4(B, B, B, B), // 0x7c-0x7f - OC4(B, B, B, B), // 0x80-0x83 - OC4(B, B, B, B), // 0x84-0x87 - OC4(B, B, B, B), // 0x88-0x8b - OC4(B, B, B, B), // 0x8c-0x8f - OC4(B, B, B, B), // 0x90-0x93 - OC4(B, B, B, B), // 0x94-0x97 - OC4(B, B, B, B), // 0x98-0x9b - OC4(B, B, B, B), // 0x9c-0x9f - OC4(B, B, B, B), // 0xa0-0xa3 - OC4(B, B, B, B), // 0xa4-0xa7 - OC4(B, B, B, B), // 0xa8-0xab - OC4(B, B, B, B), // 0xac-0xaf - - OC4(B, B, B, B), // 0xb0-0xb3 - OC4(B, B, B, B), // 0xb4-0xb7 - OC4(B, B, B, B), // 0xb8-0xbb - OC4(B, B, B, B), // 0xbc-0xbf - - OC4(B, B, B, B), // 0xc0-0xc3 - OC4(B, B, B, B), // 0xc4-0xc7 - OC4(B, B, B, B), // 0xc8-0xcb - OC4(B, B, B, B), // 0xcc-0xcf - - OC4(B, B, B, B), // 0xd0-0xd3 - OC4(B, B, B, B), // 0xd4-0xd7 - OC4(B, B, B, B), // 0xd8-0xdb - OC4(B, B, B, B), // 0xdc-0xdf - - OC4(B, B, B, B), // 0xe0-0xe3 - OC4(B, B, B, B), // 0xe4-0xe7 - OC4(B, B, B, B), // 0xe8-0xeb - OC4(B, B, B, B), // 0xec-0xef - - OC4(B, B, B, B), // 0xf0-0xf3 - OC4(B, B, B, B), // 0xf4-0xf7 - OC4(B, B, B, U), // 0xf8-0xfb - OC4(U, U, U, U), // 0xfc-0xff -}; -#undef OC4 -#undef U -#undef B -#undef Q -#undef V -#undef O - -uint mp_opcode_format(const byte *ip, size_t *opcode_size) { - uint f = (opcode_format_table[*ip >> 2] >> (2 * (*ip & 3))) & 3; - const byte *ip_start = ip; - if (f == MP_OPCODE_QSTR) { - ip += 3; - } else { - int extra_byte = ( - *ip == MP_BC_RAISE_VARARGS - || *ip == MP_BC_MAKE_CLOSURE - || *ip == MP_BC_MAKE_CLOSURE_DEFARGS - #if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - || *ip == MP_BC_LOAD_NAME - || *ip == MP_BC_LOAD_GLOBAL - || *ip == MP_BC_LOAD_ATTR - || *ip == MP_BC_STORE_ATTR - #endif - ); - ip += 1; - if (f == MP_OPCODE_VAR_UINT) { - while ((*ip++ & 0x80) != 0) { - } - } else if (f == MP_OPCODE_OFFSET) { - ip += 2; - } - ip += extra_byte; - } - *opcode_size = ip - ip_start; - return f; -} - -#endif // MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE diff --git a/user/mpy/py/bc.h b/user/mpy/py/bc.h deleted file mode 100644 index 69e213e..0000000 --- a/user/mpy/py/bc.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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_BC_H -#define MICROPY_INCLUDED_PY_BC_H - -#include "py/runtime.h" -#include "py/obj.h" -#include "py/objfun.h" - -// bytecode layout: -// -// n_state : var uint -// n_exc_stack : var uint -// scope_flags : byte -// n_pos_args : byte number of arguments this function takes -// n_kwonly_args : byte number of keyword-only arguments this function takes -// n_def_pos_args : byte number of default positional arguments -// -// code_info_size : var uint | code_info_size counts bytes in this chunk -// simple_name : var qstr | -// source_file : var qstr | -// | -// | only needed if bytecode contains pointers -// -// local_num0 : byte | -// ... : byte | -// local_numN : byte | N = num_cells -// 255 : byte | end of list sentinel -// | -// -// -// constant table layout: -// -// argname0 : obj (qstr) -// ... : obj (qstr) -// argnameN : obj (qstr) N = num_pos_args + num_kwonly_args -// const0 : obj -// constN : obj - -// Exception stack entry -typedef struct _mp_exc_stack_t { - const byte *handler; - // bit 0 is saved currently_in_except_block value - // bit 1 is whether the opcode was SETUP_WITH or SETUP_FINALLY - mp_obj_t *val_sp; - // Saved exception, valid if currently_in_except_block bit is 1 - mp_obj_base_t *prev_exc; -} mp_exc_stack_t; - -typedef struct _mp_code_state_t { - // The fun_bc entry points to the underlying function object that is being executed. - // It is needed to access the start of bytecode and the const_table. - // It is also needed to prevent the GC from reclaiming the bytecode during execution, - // because the ip pointer below will always point to the interior of the bytecode. - mp_obj_fun_bc_t *fun_bc; - const byte *ip; - mp_obj_t *sp; - // bit 0 is saved currently_in_except_block value - mp_exc_stack_t *exc_sp; - mp_obj_dict_t *old_globals; - #if MICROPY_STACKLESS - struct _mp_code_state_t *prev; - #endif - // Variable-length - mp_obj_t state[0]; - // Variable-length, never accessed by name, only as (void*)(state + n_state) - //mp_exc_stack_t exc_state[0]; -} mp_code_state_t; - -mp_uint_t mp_decode_uint(const byte **ptr); -mp_uint_t mp_decode_uint_value(const byte *ptr); -const byte *mp_decode_uint_skip(const byte *ptr); - -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc); -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table); -void mp_bytecode_print2(const byte *code, size_t len, const mp_uint_t *const_table); -const byte *mp_bytecode_print_str(const byte *ip); -#define mp_bytecode_print_inst(code, const_table) mp_bytecode_print2(code, 1, const_table) - -// Helper macros to access pointer with least significant bits holding flags -#define MP_TAGPTR_PTR(x) ((void*)((uintptr_t)(x) & ~((uintptr_t)3))) -#define MP_TAGPTR_TAG0(x) ((uintptr_t)(x) & 1) -#define MP_TAGPTR_TAG1(x) ((uintptr_t)(x) & 2) -#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((uintptr_t)(ptr) | (tag))) - -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE - -#define MP_OPCODE_BYTE (0) -#define MP_OPCODE_QSTR (1) -#define MP_OPCODE_VAR_UINT (2) -#define MP_OPCODE_OFFSET (3) - -uint mp_opcode_format(const byte *ip, size_t *opcode_size); - -#endif - -#endif // MICROPY_INCLUDED_PY_BC_H diff --git a/user/mpy/py/bc0.h b/user/mpy/py/bc0.h deleted file mode 100644 index f671c5b..0000000 --- a/user/mpy/py/bc0.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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_BC0_H -#define MICROPY_INCLUDED_PY_BC0_H - -// MicroPython byte-codes. -// The comment at the end of the line (if it exists) tells the arguments to the byte-code. - -#define MP_BC_LOAD_CONST_FALSE (0x10) -#define MP_BC_LOAD_CONST_NONE (0x11) -#define MP_BC_LOAD_CONST_TRUE (0x12) -#define MP_BC_LOAD_CONST_SMALL_INT (0x14) // signed var-int -#define MP_BC_LOAD_CONST_STRING (0x16) // qstr -#define MP_BC_LOAD_CONST_OBJ (0x17) // ptr -#define MP_BC_LOAD_NULL (0x18) - -#define MP_BC_LOAD_FAST_N (0x19) // uint -#define MP_BC_LOAD_DEREF (0x1a) // uint -#define MP_BC_LOAD_NAME (0x1b) // qstr -#define MP_BC_LOAD_GLOBAL (0x1c) // qstr -#define MP_BC_LOAD_ATTR (0x1d) // qstr -#define MP_BC_LOAD_METHOD (0x1e) // qstr -#define MP_BC_LOAD_SUPER_METHOD (0x1f) // qstr -#define MP_BC_LOAD_BUILD_CLASS (0x20) -#define MP_BC_LOAD_SUBSCR (0x21) - -#define MP_BC_STORE_FAST_N (0x22) // uint -#define MP_BC_STORE_DEREF (0x23) // uint -#define MP_BC_STORE_NAME (0x24) // qstr -#define MP_BC_STORE_GLOBAL (0x25) // qstr -#define MP_BC_STORE_ATTR (0x26) // qstr -#define MP_BC_STORE_SUBSCR (0x27) - -#define MP_BC_DELETE_FAST (0x28) // uint -#define MP_BC_DELETE_DEREF (0x29) // uint -#define MP_BC_DELETE_NAME (0x2a) // qstr -#define MP_BC_DELETE_GLOBAL (0x2b) // qstr - -#define MP_BC_DUP_TOP (0x30) -#define MP_BC_DUP_TOP_TWO (0x31) -#define MP_BC_POP_TOP (0x32) -#define MP_BC_ROT_TWO (0x33) -#define MP_BC_ROT_THREE (0x34) - -#define MP_BC_JUMP (0x35) // rel byte code offset, 16-bit signed, in excess -#define MP_BC_POP_JUMP_IF_TRUE (0x36) // rel byte code offset, 16-bit signed, in excess -#define MP_BC_POP_JUMP_IF_FALSE (0x37) // rel byte code offset, 16-bit signed, in excess -#define MP_BC_JUMP_IF_TRUE_OR_POP (0x38) // rel byte code offset, 16-bit signed, in excess -#define MP_BC_JUMP_IF_FALSE_OR_POP (0x39) // rel byte code offset, 16-bit signed, in excess -#define MP_BC_SETUP_WITH (0x3d) // rel byte code offset, 16-bit unsigned -#define MP_BC_WITH_CLEANUP (0x3e) -#define MP_BC_SETUP_EXCEPT (0x3f) // rel byte code offset, 16-bit unsigned -#define MP_BC_SETUP_FINALLY (0x40) // rel byte code offset, 16-bit unsigned -#define MP_BC_END_FINALLY (0x41) -#define MP_BC_GET_ITER (0x42) -#define MP_BC_FOR_ITER (0x43) // rel byte code offset, 16-bit unsigned -#define MP_BC_POP_BLOCK (0x44) -#define MP_BC_POP_EXCEPT (0x45) -#define MP_BC_UNWIND_JUMP (0x46) // rel byte code offset, 16-bit signed, in excess; then a byte -#define MP_BC_GET_ITER_STACK (0x47) - -#define MP_BC_BUILD_TUPLE (0x50) // uint -#define MP_BC_BUILD_LIST (0x51) // uint -#define MP_BC_BUILD_MAP (0x53) // uint -#define MP_BC_STORE_MAP (0x54) -#define MP_BC_BUILD_SET (0x56) // uint -#define MP_BC_BUILD_SLICE (0x58) // uint -#define MP_BC_STORE_COMP (0x57) // uint -#define MP_BC_UNPACK_SEQUENCE (0x59) // uint -#define MP_BC_UNPACK_EX (0x5a) // uint - -#define MP_BC_RETURN_VALUE (0x5b) -#define MP_BC_RAISE_VARARGS (0x5c) // byte -#define MP_BC_YIELD_VALUE (0x5d) -#define MP_BC_YIELD_FROM (0x5e) - -#define MP_BC_MAKE_FUNCTION (0x60) // uint -#define MP_BC_MAKE_FUNCTION_DEFARGS (0x61) // uint -#define MP_BC_MAKE_CLOSURE (0x62) // uint -#define MP_BC_MAKE_CLOSURE_DEFARGS (0x63) // uint -#define MP_BC_CALL_FUNCTION (0x64) // uint -#define MP_BC_CALL_FUNCTION_VAR_KW (0x65) // uint -#define MP_BC_CALL_METHOD (0x66) // uint -#define MP_BC_CALL_METHOD_VAR_KW (0x67) // uint - -#define MP_BC_IMPORT_NAME (0x68) // qstr -#define MP_BC_IMPORT_FROM (0x69) // qstr -#define MP_BC_IMPORT_STAR (0x6a) - -#define MP_BC_LOAD_CONST_SMALL_INT_MULTI (0x70) // + N(64) -#define MP_BC_LOAD_FAST_MULTI (0xb0) // + N(16) -#define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16) -#define MP_BC_UNARY_OP_MULTI (0xd0) // + op(7) -#define MP_BC_BINARY_OP_MULTI (0xd7) // + op(36) - -#endif // MICROPY_INCLUDED_PY_BC0_H diff --git a/user/mpy/py/binary.c b/user/mpy/py/binary.c deleted file mode 100644 index 870a094..0000000 --- a/user/mpy/py/binary.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include -#include - -#include "py/binary.h" -#include "py/smallint.h" -#include "py/objint.h" -#include "py/runtime.h" - -// Helpers to work with binary-encoded data - -#ifndef alignof -#define alignof(type) offsetof(struct { char c; type t; }, t) -#endif - -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) { - size_t size = 0; - int align = 1; - switch (struct_type) { - case '<': case '>': - switch (val_type) { - case 'b': case 'B': - size = 1; break; - case 'h': case 'H': - size = 2; break; - case 'i': case 'I': - size = 4; break; - case 'l': case 'L': - size = 4; break; - case 'q': case 'Q': - size = 8; break; - case 'P': case 'O': case 'S': - size = sizeof(void*); break; - case 'f': - size = sizeof(float); break; - case 'd': - size = sizeof(double); break; - } - break; - case '@': { - // TODO: - // The simplest heuristic for alignment is to align by value - // size, but that doesn't work for "bigger than int" types, - // for example, long long may very well have long alignment - // So, we introduce separate alignment handling, but having - // formal support for that is different from actually supporting - // particular (or any) ABI. - switch (val_type) { - case BYTEARRAY_TYPECODE: - case 'b': case 'B': - align = size = 1; break; - case 'h': case 'H': - align = alignof(short); - size = sizeof(short); break; - case 'i': case 'I': - align = alignof(int); - size = sizeof(int); break; - case 'l': case 'L': - align = alignof(long); - size = sizeof(long); break; - case 'q': case 'Q': - align = alignof(long long); - size = sizeof(long long); break; - case 'P': case 'O': case 'S': - align = alignof(void*); - size = sizeof(void*); break; - case 'f': - align = alignof(float); - size = sizeof(float); break; - case 'd': - align = alignof(double); - size = sizeof(double); break; - } - } - } - - if (size == 0) { - mp_raise_ValueError("bad typecode"); - } - - if (palign != NULL) { - *palign = align; - } - return size; -} - -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { - mp_int_t val = 0; - switch (typecode) { - case 'b': - val = ((signed char*)p)[index]; - break; - case BYTEARRAY_TYPECODE: - case 'B': - val = ((unsigned char*)p)[index]; - break; - case 'h': - val = ((short*)p)[index]; - break; - case 'H': - val = ((unsigned short*)p)[index]; - break; - case 'i': - return mp_obj_new_int(((int*)p)[index]); - case 'I': - return mp_obj_new_int_from_uint(((unsigned int*)p)[index]); - case 'l': - return mp_obj_new_int(((long*)p)[index]); - case 'L': - return mp_obj_new_int_from_uint(((unsigned long*)p)[index]); - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - case 'q': - return mp_obj_new_int_from_ll(((long long*)p)[index]); - case 'Q': - return mp_obj_new_int_from_ull(((unsigned long long*)p)[index]); - #endif -#if MICROPY_PY_BUILTINS_FLOAT - case 'f': - return mp_obj_new_float(((float*)p)[index]); - case 'd': - return mp_obj_new_float(((double*)p)[index]); -#endif - // Extension to CPython: array of objects - case 'O': - return ((mp_obj_t*)p)[index]; - // Extension to CPython: array of pointers - case 'P': - return mp_obj_new_int((mp_int_t)(uintptr_t)((void**)p)[index]); - } - return MP_OBJ_NEW_SMALL_INT(val); -} - -// The long long type is guaranteed to hold at least 64 bits, and size is at -// most 8 (for q and Q), so we will always be able to parse the given data -// and fit it into a long long. -long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src) { - int delta; - if (!big_endian) { - delta = -1; - src += size - 1; - } else { - delta = 1; - } - - long long val = 0; - if (is_signed && *src & 0x80) { - val = -1; - } - for (uint i = 0; i < size; i++) { - val <<= 8; - val |= *src; - src += delta; - } - - return val; -} - -#define is_signed(typecode) (typecode > 'Z') -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) { - byte *p = *ptr; - mp_uint_t align; - - size_t size = mp_binary_get_size(struct_type, val_type, &align); - if (struct_type == '@') { - // Make pointer aligned - p = (byte*)MP_ALIGN(p, (size_t)align); - #if MP_ENDIANNESS_LITTLE - struct_type = '<'; - #else - struct_type = '>'; - #endif - } - *ptr = p + size; - - long long val = mp_binary_get_int(size, is_signed(val_type), (struct_type == '>'), p); - - if (val_type == 'O') { - return (mp_obj_t)(mp_uint_t)val; - } else if (val_type == 'S') { - const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val; - return mp_obj_new_str(s_val, strlen(s_val), false); -#if MICROPY_PY_BUILTINS_FLOAT - } else if (val_type == 'f') { - union { uint32_t i; float f; } fpu = {val}; - return mp_obj_new_float(fpu.f); - } else if (val_type == 'd') { - union { uint64_t i; double f; } fpu = {val}; - return mp_obj_new_float(fpu.f); -#endif - } else if (is_signed(val_type)) { - if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) { - return mp_obj_new_int((mp_int_t)val); - } else { - return mp_obj_new_int_from_ll(val); - } - } else { - if ((unsigned long long)val <= (unsigned long long)MP_SMALL_INT_MAX) { - return mp_obj_new_int_from_uint((mp_uint_t)val); - } else { - return mp_obj_new_int_from_ull(val); - } - } -} - -void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val) { - if (MP_ENDIANNESS_LITTLE && !big_endian) { - memcpy(dest, &val, val_sz); - } else if (MP_ENDIANNESS_BIG && big_endian) { - // only copy the least-significant val_sz bytes - memcpy(dest, (byte*)&val + sizeof(mp_uint_t) - val_sz, val_sz); - } else { - const byte *src; - if (MP_ENDIANNESS_LITTLE) { - src = (const byte*)&val + val_sz; - } else { - src = (const byte*)&val + sizeof(mp_uint_t); - } - while (val_sz--) { - *dest++ = *--src; - } - } -} - -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr) { - byte *p = *ptr; - mp_uint_t align; - - size_t size = mp_binary_get_size(struct_type, val_type, &align); - if (struct_type == '@') { - // Make pointer aligned - p = (byte*)MP_ALIGN(p, (size_t)align); - if (MP_ENDIANNESS_LITTLE) { - struct_type = '<'; - } else { - struct_type = '>'; - } - } - *ptr = p + size; - - mp_uint_t val; - switch (val_type) { - case 'O': - val = (mp_uint_t)val_in; - break; -#if MICROPY_PY_BUILTINS_FLOAT - case 'f': { - union { uint32_t i; float f; } fp_sp; - fp_sp.f = mp_obj_get_float(val_in); - val = fp_sp.i; - break; - } - case 'd': { - union { uint64_t i64; uint32_t i32[2]; double f; } fp_dp; - fp_dp.f = mp_obj_get_float(val_in); - if (BYTES_PER_WORD == 8) { - val = fp_dp.i64; - } else { - int be = struct_type == '>'; - mp_binary_set_int(sizeof(uint32_t), be, p, fp_dp.i32[MP_ENDIANNESS_BIG ^ be]); - p += sizeof(uint32_t); - val = fp_dp.i32[MP_ENDIANNESS_LITTLE ^ be]; - } - break; - } -#endif - default: - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) { - mp_obj_int_to_bytes_impl(val_in, struct_type == '>', size, p); - return; - } else - #endif - { - val = mp_obj_get_int(val_in); - // zero/sign extend if needed - if (BYTES_PER_WORD < 8 && size > sizeof(val)) { - int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00; - memset(p, c, size); - if (struct_type == '>') { - p += size - sizeof(val); - } - } - } - } - - mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val); -} - -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) { - switch (typecode) { -#if MICROPY_PY_BUILTINS_FLOAT - case 'f': - ((float*)p)[index] = mp_obj_get_float(val_in); - break; - case 'd': - ((double*)p)[index] = mp_obj_get_float(val_in); - break; -#endif - // Extension to CPython: array of objects - case 'O': - ((mp_obj_t*)p)[index] = val_in; - break; - default: - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) { - size_t size = mp_binary_get_size('@', typecode, NULL); - mp_obj_int_to_bytes_impl(val_in, MP_ENDIANNESS_BIG, - size, (uint8_t*)p + index * size); - return; - } - #endif - mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in)); - } -} - -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val) { - switch (typecode) { - case 'b': - ((signed char*)p)[index] = val; - break; - case BYTEARRAY_TYPECODE: - case 'B': - ((unsigned char*)p)[index] = val; - break; - case 'h': - ((short*)p)[index] = val; - break; - case 'H': - ((unsigned short*)p)[index] = val; - break; - case 'i': - ((int*)p)[index] = val; - break; - case 'I': - ((unsigned int*)p)[index] = val; - break; - case 'l': - ((long*)p)[index] = val; - break; - case 'L': - ((unsigned long*)p)[index] = val; - break; - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - case 'q': - ((long long*)p)[index] = val; - break; - case 'Q': - ((unsigned long long*)p)[index] = val; - break; - #endif -#if MICROPY_PY_BUILTINS_FLOAT - case 'f': - ((float*)p)[index] = val; - break; - case 'd': - ((double*)p)[index] = val; - break; -#endif - // Extension to CPython: array of pointers - case 'P': - ((void**)p)[index] = (void*)(uintptr_t)val; - break; - } -} diff --git a/user/mpy/py/binary.h b/user/mpy/py/binary.h deleted file mode 100644 index 7b5c60f..0000000 --- a/user/mpy/py/binary.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_BINARY_H -#define MICROPY_INCLUDED_PY_BINARY_H - -#include "py/obj.h" - -// Use special typecode to differentiate repr() of bytearray vs array.array('B') -// (underlyingly they're same). -#define BYTEARRAY_TYPECODE 0 - -size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign); -mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index); -void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in); -void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, mp_int_t val); -mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); -void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); -long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src); -void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val); - -#endif // MICROPY_INCLUDED_PY_BINARY_H diff --git a/user/mpy/py/builtin.h b/user/mpy/py/builtin.h deleted file mode 100644 index a637b6e..0000000 --- a/user/mpy/py/builtin.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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_BUILTIN_H -#define MICROPY_INCLUDED_PY_BUILTIN_H - -#include "py/obj.h" - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args); - -MP_DECLARE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_abs_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_all_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_any_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_bin_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_callable_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_chr_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_execfile_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj); -MP_DECLARE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_builtin_globals_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_hash_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_hex_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_id_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_isinstance_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_iter_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_len_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_builtin_locals_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_max_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_min_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_next_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_oct_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_ord_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_print_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_builtin_repr_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj); -// Defined by a port, but declared here for simplicity -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj); - -MP_DECLARE_CONST_FUN_OBJ_2(mp_namedtuple_obj); - -MP_DECLARE_CONST_FUN_OBJ_2(mp_op_contains_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_op_getitem_obj); -MP_DECLARE_CONST_FUN_OBJ_3(mp_op_setitem_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_op_delitem_obj); - -extern const mp_obj_module_t mp_module___main__; -extern const mp_obj_module_t mp_module_builtins; -extern const mp_obj_module_t mp_module_array; -extern const mp_obj_module_t mp_module_collections; -extern const mp_obj_module_t mp_module_io; -extern const mp_obj_module_t mp_module_math; -extern const mp_obj_module_t mp_module_cmath; -extern const mp_obj_module_t mp_module_micropython; -extern const mp_obj_module_t mp_module_ustruct; -extern const mp_obj_module_t mp_module_sys; -extern const mp_obj_module_t mp_module_gc; -extern const mp_obj_module_t mp_module_thread; - -extern const mp_obj_dict_t mp_module_builtins_globals; - -// extmod modules -extern const mp_obj_module_t mp_module_uerrno; -extern const mp_obj_module_t mp_module_uctypes; -extern const mp_obj_module_t mp_module_uzlib; -extern const mp_obj_module_t mp_module_ujson; -extern const mp_obj_module_t mp_module_ure; -extern const mp_obj_module_t mp_module_uheapq; -extern const mp_obj_module_t mp_module_uhashlib; -extern const mp_obj_module_t mp_module_ubinascii; -extern const mp_obj_module_t mp_module_urandom; -extern const mp_obj_module_t mp_module_uselect; -extern const mp_obj_module_t mp_module_ussl; -extern const mp_obj_module_t mp_module_utimeq; -extern const mp_obj_module_t mp_module_machine; -extern const mp_obj_module_t mp_module_lwip; -extern const mp_obj_module_t mp_module_websocket; -extern const mp_obj_module_t mp_module_webrepl; -extern const mp_obj_module_t mp_module_framebuf; -extern const mp_obj_module_t mp_module_btree; - -extern const char *MICROPY_PY_BUILTINS_HELP_TEXT; - -#endif // MICROPY_INCLUDED_PY_BUILTIN_H diff --git a/user/mpy/py/builtinevex.c b/user/mpy/py/builtinevex.c deleted file mode 100644 index ba8048f..0000000 --- a/user/mpy/py/builtinevex.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/nlr.h" -#include "py/objfun.h" -#include "py/compile.h" -#include "py/runtime.h" -#include "py/builtin.h" - -#if MICROPY_PY_BUILTINS_COMPILE - -typedef struct _mp_obj_code_t { - mp_obj_base_t base; - mp_obj_t module_fun; -} mp_obj_code_t; - -STATIC const mp_obj_type_t mp_type_code = { - { &mp_type_type }, - .name = MP_QSTR_code, -}; - -STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { - // save context and set new context - mp_obj_dict_t *old_globals = mp_globals_get(); - mp_obj_dict_t *old_locals = mp_locals_get(); - mp_globals_set(globals); - mp_locals_set(locals); - - // a bit of a hack: fun_bc will re-set globals, so need to make sure it's - // the correct one - if (MP_OBJ_IS_TYPE(self->module_fun, &mp_type_fun_bc)) { - mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(self->module_fun); - fun_bc->globals = globals; - } - - // execute code - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t ret = mp_call_function_0(self->module_fun); - nlr_pop(); - mp_globals_set(old_globals); - mp_locals_set(old_locals); - return ret; - } else { - // exception; restore context and re-raise same exception - mp_globals_set(old_globals); - mp_locals_set(old_locals); - nlr_jump(nlr.ret_val); - } -} - -STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) { - (void)n_args; - - // get the source - size_t str_len; - const char *str = mp_obj_str_get_data(args[0], &str_len); - - // get the filename - qstr filename = mp_obj_str_get_qstr(args[1]); - - // create the lexer - mp_lexer_t *lex = mp_lexer_new_from_str_len(filename, str, str_len, 0); - - // get the compile mode - qstr mode = mp_obj_str_get_qstr(args[2]); - mp_parse_input_kind_t parse_input_kind; - switch (mode) { - case MP_QSTR_single: parse_input_kind = MP_PARSE_SINGLE_INPUT; break; - case MP_QSTR_exec: parse_input_kind = MP_PARSE_FILE_INPUT; break; - case MP_QSTR_eval: parse_input_kind = MP_PARSE_EVAL_INPUT; break; - default: - mp_raise_ValueError("bad compile mode"); - } - - mp_obj_code_t *code = m_new_obj(mp_obj_code_t); - code->base.type = &mp_type_code; - code->module_fun = mp_parse_compile_execute(lex, parse_input_kind, NULL, NULL); - return MP_OBJ_FROM_PTR(code); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_compile); - -#endif // MICROPY_PY_BUILTINS_COMPILE - -#if MICROPY_PY_BUILTINS_EVAL_EXEC - -STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) { - // work out the context - mp_obj_dict_t *globals = mp_globals_get(); - mp_obj_dict_t *locals = mp_locals_get(); - for (size_t i = 1; i < 3 && i < n_args; ++i) { - if (args[i] != mp_const_none) { - if (!MP_OBJ_IS_TYPE(args[i], &mp_type_dict)) { - mp_raise_TypeError(NULL); - } - locals = MP_OBJ_TO_PTR(args[i]); - if (i == 1) { - globals = locals; - } - } - } - - #if MICROPY_PY_BUILTINS_COMPILE - if (MP_OBJ_IS_TYPE(args[0], &mp_type_code)) { - return code_execute(MP_OBJ_TO_PTR(args[0]), globals, locals); - } - #endif - - size_t str_len; - const char *str = mp_obj_str_get_data(args[0], &str_len); - - // create the lexer - // MP_PARSE_SINGLE_INPUT is used to indicate a file input - mp_lexer_t *lex; - if (MICROPY_PY_BUILTINS_EXECFILE && parse_input_kind == MP_PARSE_SINGLE_INPUT) { - lex = mp_lexer_new_from_file(str); - parse_input_kind = MP_PARSE_FILE_INPUT; - } else { - lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0); - } - - return mp_parse_compile_execute(lex, parse_input_kind, globals, locals); -} - -STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) { - return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj, 1, 3, mp_builtin_eval); - -STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) { - return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec); - -#endif // MICROPY_PY_BUILTINS_EVAL_EXEC - -#if MICROPY_PY_BUILTINS_EXECFILE -STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) { - // MP_PARSE_SINGLE_INPUT is used to indicate a file input - return eval_exec_helper(n_args, args, MP_PARSE_SINGLE_INPUT); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_execfile_obj, 1, 3, mp_builtin_execfile); -#endif diff --git a/user/mpy/py/builtinhelp.c b/user/mpy/py/builtinhelp.c deleted file mode 100644 index dbcd6e0..0000000 --- a/user/mpy/py/builtinhelp.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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. - */ - -#include -#include - -#include "py/builtin.h" -#include "py/objmodule.h" - -#if MICROPY_PY_BUILTINS_HELP - -const char *mp_help_default_text = -"Welcome to MicroPython!\n" -"\n" -"For online docs please visit http://docs.micropython.org/\n" -"\n" -"Control commands:\n" -" CTRL-A -- on a blank line, enter raw REPL mode\n" -" CTRL-B -- on a blank line, enter normal REPL mode\n" -" CTRL-C -- interrupt a running program\n" -" CTRL-D -- on a blank line, exit or do a soft reset\n" -" CTRL-E -- on a blank line, enter paste mode\n" -"\n" -"For further help on a specific object, type help(obj)\n" -; - -STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) { - mp_print_str(MP_PYTHON_PRINTER, " "); - mp_obj_print(name_o, PRINT_STR); - mp_print_str(MP_PYTHON_PRINTER, " -- "); - mp_obj_print(value, PRINT_STR); - mp_print_str(MP_PYTHON_PRINTER, "\n"); -} - -#if MICROPY_PY_BUILTINS_HELP_MODULES -STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) { - for (size_t i = 0; i < map->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - mp_obj_list_append(list, map->table[i].key); - } - } -} - -#if MICROPY_MODULE_FROZEN -STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) { - while (*name) { - size_t l = strlen(name); - // name should end in '.py' and we strip it off - mp_obj_list_append(list, mp_obj_new_str(name, l - 3, false)); - name += l + 1; - } -} -#endif - -STATIC void mp_help_print_modules(void) { - mp_obj_t list = mp_obj_new_list(0, NULL); - - mp_help_add_from_map(list, &mp_builtin_module_map); - - #if MICROPY_MODULE_WEAK_LINKS - mp_help_add_from_map(list, &mp_builtin_module_weak_links_map); - #endif - - #if MICROPY_MODULE_FROZEN_STR - extern const char mp_frozen_str_names[]; - mp_help_add_from_names(list, mp_frozen_str_names); - #endif - - #if MICROPY_MODULE_FROZEN_MPY - extern const char mp_frozen_mpy_names[]; - mp_help_add_from_names(list, mp_frozen_mpy_names); - #endif - - // sort the list so it's printed in alphabetical order - mp_obj_list_sort(1, &list, (mp_map_t*)&mp_const_empty_map); - - // print the list of modules in a column-first order - #define NUM_COLUMNS (4) - #define COLUMN_WIDTH (18) - mp_uint_t len; - mp_obj_t *items; - mp_obj_list_get(list, &len, &items); - unsigned int num_rows = (len + NUM_COLUMNS - 1) / NUM_COLUMNS; - for (unsigned int i = 0; i < num_rows; ++i) { - unsigned int j = i; - for (;;) { - int l = mp_print_str(MP_PYTHON_PRINTER, mp_obj_str_get_str(items[j])); - j += num_rows; - if (j >= len) { - break; - } - int gap = COLUMN_WIDTH - l; - while (gap < 1) { - gap += COLUMN_WIDTH; - } - while (gap--) { - mp_print_str(MP_PYTHON_PRINTER, " "); - } - } - mp_print_str(MP_PYTHON_PRINTER, "\n"); - } - - // let the user know there may be other modules available from the filesystem - mp_print_str(MP_PYTHON_PRINTER, "Plus any modules on the filesystem\n"); -} -#endif - -STATIC void mp_help_print_obj(const mp_obj_t obj) { - #if MICROPY_PY_BUILTINS_HELP_MODULES - if (obj == MP_OBJ_NEW_QSTR(MP_QSTR_modules)) { - mp_help_print_modules(); - return; - } - #endif - - // try to print something sensible about the given object - mp_print_str(MP_PYTHON_PRINTER, "object "); - mp_obj_print(obj, PRINT_STR); - mp_printf(MP_PYTHON_PRINTER, " is of type %s\n", mp_obj_get_type_str(obj)); - - mp_map_t *map = NULL; - if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) { - map = mp_obj_dict_get_map(mp_obj_module_get_globals(obj)); - } else { - mp_obj_type_t *type; - if (MP_OBJ_IS_TYPE(obj, &mp_type_type)) { - type = obj; - } else { - type = mp_obj_get_type(obj); - } - if (type->locals_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(type->locals_dict, &mp_type_dict)) { - map = mp_obj_dict_get_map(type->locals_dict); - } - } - if (map != NULL) { - for (uint i = 0; i < map->alloc; i++) { - if (map->table[i].key != MP_OBJ_NULL) { - mp_help_print_info_about_object(map->table[i].key, map->table[i].value); - } - } - } -} - -STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) { - if (n_args == 0) { - // print a general help message - mp_print_str(MP_PYTHON_PRINTER, MICROPY_PY_BUILTINS_HELP_TEXT); - } else { - // try to print something sensible about the given object - mp_help_print_obj(args[0]); - } - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj, 0, 1, mp_builtin_help); - -#endif // MICROPY_PY_BUILTINS_HELP diff --git a/user/mpy/py/builtinimport.c b/user/mpy/py/builtinimport.c deleted file mode 100644 index f5bfb0d..0000000 --- a/user/mpy/py/builtinimport.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/compile.h" -#include "py/objmodule.h" -#include "py/persistentcode.h" -#include "py/runtime.h" -#include "py/builtin.h" -#include "py/frozenmod.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_PRINT (0) -#define DEBUG_printf(...) (void)0 -#endif - -#define PATH_SEP_CHAR '/' - -bool mp_obj_is_package(mp_obj_t module) { - mp_obj_t dest[2]; - mp_load_method_maybe(module, MP_QSTR___path__, dest); - return dest[0] != MP_OBJ_NULL; -} - -// Stat either frozen or normal module by a given path -// (whatever is available, if at all). -STATIC mp_import_stat_t mp_import_stat_any(const char *path) { - #if MICROPY_MODULE_FROZEN - mp_import_stat_t st = mp_frozen_stat(path); - if (st != MP_IMPORT_STAT_NO_EXIST) { - return st; - } - #endif - return mp_import_stat(path); -} - -STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); - if (stat == MP_IMPORT_STAT_FILE) { - return stat; - } - - #if MICROPY_PERSISTENT_CODE_LOAD - vstr_ins_byte(path, path->len - 2, 'm'); - stat = mp_import_stat_any(vstr_null_terminated_str(path)); - if (stat == MP_IMPORT_STAT_FILE) { - return stat; - } - #endif - - return MP_IMPORT_STAT_NO_EXIST; -} - -STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); - DEBUG_printf("stat %s: %d\n", vstr_str(path), stat); - if (stat == MP_IMPORT_STAT_DIR) { - return stat; - } - - // not a directory, add .py and try as a file - vstr_add_str(path, ".py"); - return stat_file_py_or_mpy(path); -} - -STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { -#if MICROPY_PY_SYS - // extract the list of paths - size_t path_num; - mp_obj_t *path_items; - mp_obj_list_get(mp_sys_path, &path_num, &path_items); - - if (path_num == 0) { -#endif - // mp_sys_path is empty, so just use the given file name - vstr_add_strn(dest, file_str, file_len); - return stat_dir_or_file(dest); -#if MICROPY_PY_SYS - } else { - // go through each path looking for a directory or file - for (size_t i = 0; i < path_num; i++) { - vstr_reset(dest); - size_t p_len; - const char *p = mp_obj_str_get_data(path_items[i], &p_len); - if (p_len > 0) { - vstr_add_strn(dest, p, p_len); - vstr_add_char(dest, PATH_SEP_CHAR); - } - vstr_add_strn(dest, file_str, file_len); - mp_import_stat_t stat = stat_dir_or_file(dest); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - } - - // could not find a directory or file - return MP_IMPORT_STAT_NO_EXIST; - } -#endif -} - -#if MICROPY_ENABLE_COMPILER -STATIC void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) { - #if MICROPY_PY___FILE__ - qstr source_name = lex->source_name; - mp_store_attr(module_obj, MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name)); - #endif - - // parse, compile and execute the module in its context - mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); - mp_parse_compile_execute(lex, MP_PARSE_FILE_INPUT, mod_globals, mod_globals); -} -#endif - -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_MODULE_FROZEN_MPY -STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code) { - #if MICROPY_PY___FILE__ - // TODO - //qstr source_name = lex->source_name; - //mp_store_attr(module_obj, MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name)); - #endif - - // execute the module in its context - mp_obj_dict_t *mod_globals = mp_obj_module_get_globals(module_obj); - - // save context - mp_obj_dict_t *volatile old_globals = mp_globals_get(); - mp_obj_dict_t *volatile old_locals = mp_locals_get(); - - // set new context - mp_globals_set(mod_globals); - mp_locals_set(mod_globals); - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t module_fun = mp_make_function_from_raw_code(raw_code, MP_OBJ_NULL, MP_OBJ_NULL); - mp_call_function_0(module_fun); - - // finish nlr block, restore context - nlr_pop(); - mp_globals_set(old_globals); - mp_locals_set(old_locals); - } else { - // exception; restore context and re-raise same exception - mp_globals_set(old_globals); - mp_locals_set(old_locals); - nlr_jump(nlr.ret_val); - } -} -#endif - -STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { - #if MICROPY_MODULE_FROZEN || MICROPY_PERSISTENT_CODE_LOAD || MICROPY_ENABLE_COMPILER - char *file_str = vstr_null_terminated_str(file); - #endif - - // If we support frozen modules (either as str or mpy) then try to find the - // requested filename in the list of frozen module filenames. - #if MICROPY_MODULE_FROZEN - void *modref; - int frozen_type = mp_find_frozen_module(file_str, file->len, &modref); - #endif - - // If we support frozen str modules and the compiler is enabled, and we - // found the filename in the list of frozen files, then load and execute it. - #if MICROPY_MODULE_FROZEN_STR - if (frozen_type == MP_FROZEN_STR) { - do_load_from_lexer(module_obj, modref); - return; - } - #endif - - // If we support frozen mpy modules and we found a corresponding file (and - // its data) in the list of frozen files, execute it. - #if MICROPY_MODULE_FROZEN_MPY - if (frozen_type == MP_FROZEN_MPY) { - do_execute_raw_code(module_obj, modref); - return; - } - #endif - - // If we support loading .mpy files then check if the file extension is of - // the correct format and, if so, load and execute the file. - #if MICROPY_PERSISTENT_CODE_LOAD - if (file_str[file->len - 3] == 'm') { - mp_raw_code_t *raw_code = mp_raw_code_load_file(file_str); - do_execute_raw_code(module_obj, raw_code); - return; - } - #endif - - // If we can compile scripts then load the file and compile and execute it. - #if MICROPY_ENABLE_COMPILER - { - mp_lexer_t *lex = mp_lexer_new_from_file(file_str); - do_load_from_lexer(module_obj, lex); - return; - } - #else - - // If we get here then the file was not frozen and we can't compile scripts. - mp_raise_msg(&mp_type_ImportError, "script compilation not supported"); - #endif -} - -STATIC void chop_component(const char *start, const char **end) { - const char *p = *end; - while (p > start) { - if (*--p == '.') { - *end = p; - return; - } - } - *end = p; -} - -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { -#if DEBUG_PRINT - DEBUG_printf("__import__:\n"); - for (size_t i = 0; i < n_args; i++) { - DEBUG_printf(" "); - mp_obj_print(args[i], PRINT_REPR); - DEBUG_printf("\n"); - } -#endif - - mp_obj_t module_name = args[0]; - mp_obj_t fromtuple = mp_const_none; - mp_int_t level = 0; - if (n_args >= 4) { - fromtuple = args[3]; - if (n_args >= 5) { - level = MP_OBJ_SMALL_INT_VALUE(args[4]); - if (level < 0) { - mp_raise_ValueError(NULL); - } - } - } - - size_t mod_len; - const char *mod_str = mp_obj_str_get_data(module_name, &mod_len); - - if (level != 0) { - // What we want to do here is to take name of current module, - // chop trailing components, and concatenate with passed-in - // module name, thus resolving relative import name into absolute. - // This even appears to be correct per - // http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name - // "Relative imports use a module's __name__ attribute to determine that - // module's position in the package hierarchy." - level--; - mp_obj_t this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___name__)); - assert(this_name_q != MP_OBJ_NULL); - #if MICROPY_CPYTHON_COMPAT - if (MP_OBJ_QSTR_VALUE(this_name_q) == MP_QSTR___main__) { - // This is a module run by -m command-line switch, get its real name from backup attribute - this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - } - #endif - mp_map_t *globals_map = &mp_globals_get()->map; - mp_map_elem_t *elem = mp_map_lookup(globals_map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP); - bool is_pkg = (elem != NULL); - -#if DEBUG_PRINT - DEBUG_printf("Current module/package: "); - mp_obj_print(this_name_q, PRINT_REPR); - DEBUG_printf(", is_package: %d", is_pkg); - DEBUG_printf("\n"); -#endif - - size_t this_name_l; - const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l); - - const char *p = this_name + this_name_l; - if (!is_pkg) { - // We have module, but relative imports are anchored at package, so - // go there. - chop_component(this_name, &p); - } - - while (level--) { - chop_component(this_name, &p); - } - - // We must have some component left over to import from - if (p == this_name) { - mp_raise_ValueError("cannot perform relative import"); - } - - uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); - char *new_mod = alloca(new_mod_l); - memcpy(new_mod, this_name, p - this_name); - if (mod_len != 0) { - new_mod[p - this_name] = '.'; - memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len); - } - - qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); - DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); - module_name = MP_OBJ_NEW_QSTR(new_mod_q); - mod_str = new_mod; - mod_len = new_mod_l; - } - - // check if module already exists - qstr module_name_qstr = mp_obj_str_get_qstr(module_name); - mp_obj_t module_obj = mp_module_get(module_name_qstr); - if (module_obj != MP_OBJ_NULL) { - DEBUG_printf("Module already loaded\n"); - // If it's not a package, return module right away - char *p = strchr(mod_str, '.'); - if (p == NULL) { - return module_obj; - } - // If fromlist is not empty, return leaf module - if (fromtuple != mp_const_none) { - return module_obj; - } - // Otherwise, we need to return top-level package - qstr pkg_name = qstr_from_strn(mod_str, p - mod_str); - return mp_module_get(pkg_name); - } - DEBUG_printf("Module not yet loaded\n"); - - uint last = 0; - VSTR_FIXED(path, MICROPY_ALLOC_PATH_MAX) - module_obj = MP_OBJ_NULL; - mp_obj_t top_module_obj = MP_OBJ_NULL; - mp_obj_t outer_module_obj = MP_OBJ_NULL; - uint i; - for (i = 1; i <= mod_len; i++) { - if (i == mod_len || mod_str[i] == '.') { - // create a qstr for the module name up to this depth - qstr mod_name = qstr_from_strn(mod_str, i); - DEBUG_printf("Processing module: %s\n", qstr_str(mod_name)); - DEBUG_printf("Previous path: =%.*s=\n", vstr_len(&path), vstr_str(&path)); - - // find the file corresponding to the module name - mp_import_stat_t stat; - if (vstr_len(&path) == 0) { - // first module in the dotted-name; search for a directory or file - stat = find_file(mod_str, i, &path); - } else { - // latter module in the dotted-name; append to path - vstr_add_char(&path, PATH_SEP_CHAR); - vstr_add_strn(&path, mod_str + last, i - last); - stat = stat_dir_or_file(&path); - } - DEBUG_printf("Current path: %.*s\n", vstr_len(&path), vstr_str(&path)); - - if (stat == MP_IMPORT_STAT_NO_EXIST) { - #if MICROPY_MODULE_WEAK_LINKS - // check if there is a weak link to this module - if (i == mod_len) { - mp_map_elem_t *el = mp_map_lookup((mp_map_t*)&mp_builtin_module_weak_links_map, MP_OBJ_NEW_QSTR(mod_name), MP_MAP_LOOKUP); - if (el == NULL) { - goto no_exist; - } - // found weak linked module - module_obj = el->value; - } else { - no_exist: - #else - { - #endif - // couldn't find the file, so fail - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_msg(&mp_type_ImportError, "module not found"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, - "no module named '%q'", mod_name)); - } - } - } else { - // found the file, so get the module - module_obj = mp_module_get(mod_name); - } - - if (module_obj == MP_OBJ_NULL) { - // module not already loaded, so load it! - - module_obj = mp_obj_new_module(mod_name); - - // if args[3] (fromtuple) has magic value False, set up - // this module for command-line "-m" option (set module's - // name to __main__ instead of real name). Do this only - // for *modules* however - packages never have their names - // replaced, instead they're -m'ed using a special __main__ - // submodule in them. (This all apparently is done to not - // touch package name itself, which is important for future - // imports). - if (i == mod_len && fromtuple == mp_const_false && stat != MP_IMPORT_STAT_DIR) { - mp_obj_module_t *o = MP_OBJ_TO_PTR(module_obj); - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - #if MICROPY_CPYTHON_COMPAT - // Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules). - mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj); - // Store real name in "__main__" attribute. Chosen semi-randonly, to reuse existing qstr's. - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(mod_name)); - #endif - } - - if (stat == MP_IMPORT_STAT_DIR) { - DEBUG_printf("%.*s is dir\n", vstr_len(&path), vstr_str(&path)); - // https://docs.python.org/3/reference/import.html - // "Specifically, any module that contains a __path__ attribute is considered a package." - mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(&path), vstr_len(&path), false)); - size_t orig_path_len = path.len; - vstr_add_char(&path, PATH_SEP_CHAR); - vstr_add_str(&path, "__init__.py"); - if (stat_file_py_or_mpy(&path) != MP_IMPORT_STAT_FILE) { - //mp_warning("%s is imported as namespace package", vstr_str(&path)); - } else { - do_load(module_obj, &path); - } - path.len = orig_path_len; - } else { // MP_IMPORT_STAT_FILE - do_load(module_obj, &path); - // This should be the last component in the import path. If there are - // remaining components then it's an ImportError because the current path - // (the module that was just loaded) is not a package. This will be caught - // on the next iteration because the file will not exist. - } - } - if (outer_module_obj != MP_OBJ_NULL) { - qstr s = qstr_from_strn(mod_str + last, i - last); - mp_store_attr(outer_module_obj, s, module_obj); - } - outer_module_obj = module_obj; - if (top_module_obj == MP_OBJ_NULL) { - top_module_obj = module_obj; - } - last = i + 1; - } - } - - // If fromlist is not empty, return leaf module - if (fromtuple != mp_const_none) { - return module_obj; - } - // Otherwise, we need to return top-level package - return top_module_obj; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj, 1, 5, mp_builtin___import__); diff --git a/user/mpy/py/compile.c b/user/mpy/py/compile.c deleted file mode 100644 index 00052e1..0000000 --- a/user/mpy/py/compile.c +++ /dev/null @@ -1,3522 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2015 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. - */ - -#include -#include -#include -#include -#include - -#include "py/scope.h" -#include "py/emit.h" -#include "py/compile.h" -#include "py/runtime.h" -#include "py/asmbase.h" - -#if MICROPY_ENABLE_COMPILER - -// TODO need to mangle __attr names - -#define INVALID_LABEL (0xffff) - -typedef enum { -// define rules with a compile function -#define DEF_RULE(rule, comp, kind, ...) PN_##rule, -#define DEF_RULE_NC(rule, kind, ...) -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC - PN_const_object, // special node for a constant, generic Python object -// define rules without a compile function -#define DEF_RULE(rule, comp, kind, ...) -#define DEF_RULE_NC(rule, kind, ...) PN_##rule, -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC -} pn_kind_t; - -#define NEED_METHOD_TABLE MICROPY_EMIT_NATIVE - -#if NEED_METHOD_TABLE - -// we need a method table to do the lookup for the emitter functions -#define EMIT(fun) (comp->emit_method_table->fun(comp->emit)) -#define EMIT_ARG(fun, ...) (comp->emit_method_table->fun(comp->emit, __VA_ARGS__)) -#define EMIT_LOAD_FAST(qst, local_num) (comp->emit_method_table->load_id.fast(comp->emit, qst, local_num)) -#define EMIT_LOAD_GLOBAL(qst) (comp->emit_method_table->load_id.global(comp->emit, qst)) - -#else - -// if we only have the bytecode emitter enabled then we can do a direct call to the functions -#define EMIT(fun) (mp_emit_bc_##fun(comp->emit)) -#define EMIT_ARG(fun, ...) (mp_emit_bc_##fun(comp->emit, __VA_ARGS__)) -#define EMIT_LOAD_FAST(qst, local_num) (mp_emit_bc_load_fast(comp->emit, qst, local_num)) -#define EMIT_LOAD_GLOBAL(qst) (mp_emit_bc_load_global(comp->emit, qst)) - -#endif - -#if MICROPY_EMIT_NATIVE -// define a macro to access external native emitter -#if MICROPY_EMIT_X64 -#define NATIVE_EMITTER(f) emit_native_x64_##f -#elif MICROPY_EMIT_X86 -#define NATIVE_EMITTER(f) emit_native_x86_##f -#elif MICROPY_EMIT_THUMB -#define NATIVE_EMITTER(f) emit_native_thumb_##f -#elif MICROPY_EMIT_ARM -#define NATIVE_EMITTER(f) emit_native_arm_##f -#elif MICROPY_EMIT_XTENSA -#define NATIVE_EMITTER(f) emit_native_xtensa_##f -#else -#error "unknown native emitter" -#endif -#endif - -#if MICROPY_EMIT_INLINE_ASM -// define macros for inline assembler -#if MICROPY_EMIT_INLINE_THUMB -#define ASM_DECORATOR_QSTR MP_QSTR_asm_thumb -#define ASM_EMITTER(f) emit_inline_thumb_##f -#elif MICROPY_EMIT_INLINE_XTENSA -#define ASM_DECORATOR_QSTR MP_QSTR_asm_xtensa -#define ASM_EMITTER(f) emit_inline_xtensa_##f -#else -#error "unknown asm emitter" -#endif -#endif - -#define EMIT_INLINE_ASM(fun) (comp->emit_inline_asm_method_table->fun(comp->emit_inline_asm)) -#define EMIT_INLINE_ASM_ARG(fun, ...) (comp->emit_inline_asm_method_table->fun(comp->emit_inline_asm, __VA_ARGS__)) - -// elements in this struct are ordered to make it compact -typedef struct _compiler_t { - qstr source_file; - - uint8_t is_repl; - uint8_t pass; // holds enum type pass_kind_t - uint8_t have_star; - - // try to keep compiler clean from nlr - mp_obj_t compile_error; // set to an exception object if there's an error - size_t compile_error_line; // set to best guess of line of error - - uint next_label; - - uint16_t num_dict_params; - uint16_t num_default_params; - - uint16_t break_label; // highest bit set indicates we are breaking out of a for loop - uint16_t continue_label; - uint16_t cur_except_level; // increased for SETUP_EXCEPT, SETUP_FINALLY; decreased for POP_BLOCK, POP_EXCEPT - uint16_t break_continue_except_level; - - scope_t *scope_head; - scope_t *scope_cur; - - emit_t *emit; // current emitter - #if NEED_METHOD_TABLE - const emit_method_table_t *emit_method_table; // current emit method table - #endif - - #if MICROPY_EMIT_INLINE_ASM - emit_inline_asm_t *emit_inline_asm; // current emitter for inline asm - const emit_inline_asm_method_table_t *emit_inline_asm_method_table; // current emit method table for inline asm - #endif -} compiler_t; - -STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) { - // if the line of the error is unknown then try to update it from the pn - if (comp->compile_error_line == 0 && MP_PARSE_NODE_IS_STRUCT(pn)) { - comp->compile_error_line = ((mp_parse_node_struct_t*)pn)->source_line; - } -} - -STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const char *msg) { - // only register the error if there has been no other error - if (comp->compile_error == MP_OBJ_NULL) { - comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); - compile_error_set_line(comp, pn); - } -} - -STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra); -STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind); -STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn); - -STATIC uint comp_next_label(compiler_t *comp) { - return comp->next_label++; -} - -STATIC void compile_increase_except_level(compiler_t *comp) { - comp->cur_except_level += 1; - if (comp->cur_except_level > comp->scope_cur->exc_stack_size) { - comp->scope_cur->exc_stack_size = comp->cur_except_level; - } -} - -STATIC void compile_decrease_except_level(compiler_t *comp) { - assert(comp->cur_except_level > 0); - comp->cur_except_level -= 1; -} - -STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) { - scope_t *scope = scope_new(kind, pn, comp->source_file, emit_options); - scope->parent = comp->scope_cur; - scope->next = NULL; - if (comp->scope_head == NULL) { - comp->scope_head = scope; - } else { - scope_t *s = comp->scope_head; - while (s->next != NULL) { - s = s->next; - } - s->next = scope; - } - return scope; -} - -typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn); - -STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) { - if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, pn_list_kind)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - for (int i = 0; i < num_nodes; i++) { - f(comp, pns->nodes[i]); - } - } else if (!MP_PARSE_NODE_IS_NULL(pn)) { - f(comp, pn); - } -} - -STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) { - int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - for (int i = 0; i < num_nodes; i++) { - compile_node(comp, pns->nodes[i]); - if (comp->compile_error != MP_OBJ_NULL) { - // add line info for the error in case it didn't have a line number - compile_error_set_line(comp, pns->nodes[i]); - return; - } - } -} - -STATIC void compile_load_id(compiler_t *comp, qstr qst) { - if (comp->pass == MP_PASS_SCOPE) { - mp_emit_common_get_id_for_load(comp->scope_cur, qst); - } else { - #if NEED_METHOD_TABLE - mp_emit_common_id_op(comp->emit, &comp->emit_method_table->load_id, comp->scope_cur, qst); - #else - mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_load_id_ops, comp->scope_cur, qst); - #endif - } -} - -STATIC void compile_store_id(compiler_t *comp, qstr qst) { - if (comp->pass == MP_PASS_SCOPE) { - mp_emit_common_get_id_for_modification(comp->scope_cur, qst); - } else { - #if NEED_METHOD_TABLE - mp_emit_common_id_op(comp->emit, &comp->emit_method_table->store_id, comp->scope_cur, qst); - #else - mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_store_id_ops, comp->scope_cur, qst); - #endif - } -} - -STATIC void compile_delete_id(compiler_t *comp, qstr qst) { - if (comp->pass == MP_PASS_SCOPE) { - mp_emit_common_get_id_for_modification(comp->scope_cur, qst); - } else { - #if NEED_METHOD_TABLE - mp_emit_common_id_op(comp->emit, &comp->emit_method_table->delete_id, comp->scope_cur, qst); - #else - mp_emit_common_id_op(comp->emit, &mp_emit_bc_method_table_delete_id_ops, comp->scope_cur, qst); - #endif - } -} - -STATIC void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) { - int total = 0; - if (!MP_PARSE_NODE_IS_NULL(pn)) { - compile_node(comp, pn); - total += 1; - } - if (pns_list != NULL) { - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_list); - for (int i = 0; i < n; i++) { - compile_node(comp, pns_list->nodes[i]); - } - total += n; - } - EMIT_ARG(build_tuple, total); -} - -STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) { - // a simple tuple expression - c_tuple(comp, MP_PARSE_NODE_NULL, pns); -} - -STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) { - if (mp_parse_node_is_const_false(pn)) { - if (jump_if == false) { - EMIT_ARG(jump, label); - } - return; - } else if (mp_parse_node_is_const_true(pn)) { - if (jump_if == true) { - EMIT_ARG(jump, label); - } - return; - } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test) { - if (jump_if == false) { - and_or_logic1:; - uint label2 = comp_next_label(comp); - for (int i = 0; i < n - 1; i++) { - c_if_cond(comp, pns->nodes[i], !jump_if, label2); - } - c_if_cond(comp, pns->nodes[n - 1], jump_if, label); - EMIT_ARG(label_assign, label2); - } else { - and_or_logic2: - for (int i = 0; i < n; i++) { - c_if_cond(comp, pns->nodes[i], jump_if, label); - } - } - return; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_and_test) { - if (jump_if == false) { - goto and_or_logic2; - } else { - goto and_or_logic1; - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_not_test_2) { - c_if_cond(comp, pns->nodes[0], !jump_if, label); - return; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_atom_paren) { - // cond is something in parenthesis - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // empty tuple, acts as false for the condition - if (jump_if == false) { - EMIT_ARG(jump, label); - } - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); - // non-empty tuple, acts as true for the condition - if (jump_if == true) { - EMIT_ARG(jump, label); - } - } - return; - } - } - - // nothing special, fall back to default compiling for node and jump - compile_node(comp, pn); - EMIT_ARG(pop_jump_if, jump_if, label); -} - -typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t; -STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind); - -STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) { - if (assign_kind != ASSIGN_AUG_STORE) { - compile_node(comp, pns->nodes[0]); - } - - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_atom_expr_trailers) { - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); - if (assign_kind != ASSIGN_AUG_STORE) { - for (int i = 0; i < n - 1; i++) { - compile_node(comp, pns1->nodes[i]); - } - } - assert(MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])); - pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; - } - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_bracket) { - if (assign_kind == ASSIGN_AUG_STORE) { - EMIT(rot_three); - EMIT(store_subscr); - } else { - compile_node(comp, pns1->nodes[0]); - if (assign_kind == ASSIGN_AUG_LOAD) { - EMIT(dup_top_two); - EMIT(load_subscr); - } else { - EMIT(store_subscr); - } - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_period) { - assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); - if (assign_kind == ASSIGN_AUG_LOAD) { - EMIT(dup_top); - EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])); - } else { - if (assign_kind == ASSIGN_AUG_STORE) { - EMIT(rot_two); - } - EMIT_ARG(store_attr, MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])); - } - } else { - goto cannot_assign; - } - } else { - goto cannot_assign; - } - - return; - -cannot_assign: - compile_syntax_error(comp, (mp_parse_node_t)pns, "can't assign to expression"); -} - -// we need to allow for a caller passing in 1 initial node (node_head) followed by an array of nodes (nodes_tail) -STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num_tail, mp_parse_node_t *nodes_tail) { - uint num_head = (node_head == MP_PARSE_NODE_NULL) ? 0 : 1; - - // look for star expression - uint have_star_index = -1; - if (num_head != 0 && MP_PARSE_NODE_IS_STRUCT_KIND(node_head, PN_star_expr)) { - EMIT_ARG(unpack_ex, 0, num_tail); - have_star_index = 0; - } - for (uint i = 0; i < num_tail; i++) { - if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes_tail[i], PN_star_expr)) { - if (have_star_index == (uint)-1) { - EMIT_ARG(unpack_ex, num_head + i, num_tail - i - 1); - have_star_index = num_head + i; - } else { - compile_syntax_error(comp, nodes_tail[i], "multiple *x in assignment"); - return; - } - } - } - if (have_star_index == (uint)-1) { - EMIT_ARG(unpack_sequence, num_head + num_tail); - } - if (num_head != 0) { - if (0 == have_star_index) { - c_assign(comp, ((mp_parse_node_struct_t*)node_head)->nodes[0], ASSIGN_STORE); - } else { - c_assign(comp, node_head, ASSIGN_STORE); - } - } - for (uint i = 0; i < num_tail; i++) { - if (num_head + i == have_star_index) { - c_assign(comp, ((mp_parse_node_struct_t*)nodes_tail[i])->nodes[0], ASSIGN_STORE); - } else { - c_assign(comp, nodes_tail[i], ASSIGN_STORE); - } - } -} - -// assigns top of stack to pn -STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) { - assert(!MP_PARSE_NODE_IS_NULL(pn)); - if (MP_PARSE_NODE_IS_LEAF(pn)) { - if (MP_PARSE_NODE_IS_ID(pn)) { - qstr arg = MP_PARSE_NODE_LEAF_ARG(pn); - switch (assign_kind) { - case ASSIGN_STORE: - case ASSIGN_AUG_STORE: - compile_store_id(comp, arg); - break; - case ASSIGN_AUG_LOAD: - default: - compile_load_id(comp, arg); - break; - } - } else { - goto cannot_assign; - } - } else { - // pn must be a struct - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - switch (MP_PARSE_NODE_STRUCT_KIND(pns)) { - case PN_atom_expr_normal: - // lhs is an index or attribute - c_assign_atom_expr(comp, pns, assign_kind); - break; - - case PN_testlist_star_expr: - case PN_exprlist: - // lhs is a tuple - if (assign_kind != ASSIGN_STORE) { - goto cannot_assign; - } - c_assign_tuple(comp, MP_PARSE_NODE_NULL, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); - break; - - case PN_atom_paren: - // lhs is something in parenthesis - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // empty tuple - goto cannot_assign; - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); - if (assign_kind != ASSIGN_STORE) { - goto cannot_assign; - } - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - goto testlist_comp; - } - break; - - case PN_atom_bracket: - // lhs is something in brackets - if (assign_kind != ASSIGN_STORE) { - goto cannot_assign; - } - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // empty list, assignment allowed - c_assign_tuple(comp, MP_PARSE_NODE_NULL, 0, NULL); - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - goto testlist_comp; - } else { - // brackets around 1 item - c_assign_tuple(comp, pns->nodes[0], 0, NULL); - } - break; - - default: - goto cannot_assign; - } - return; - - testlist_comp: - // lhs is a sequence - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { - // sequence of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); - c_assign_tuple(comp, pns->nodes[0], 0, NULL); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { - // sequence of many items - uint n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns2); - c_assign_tuple(comp, pns->nodes[0], n, pns2->nodes); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { - goto cannot_assign; - } else { - // sequence with 2 items - goto sequence_with_2_items; - } - } else { - // sequence with 2 items - sequence_with_2_items: - c_assign_tuple(comp, MP_PARSE_NODE_NULL, 2, pns->nodes); - } - return; - } - return; - - cannot_assign: - compile_syntax_error(comp, pn, "can't assign to expression"); -} - -// stuff for lambda and comprehensions and generators: -// if n_pos_defaults > 0 then there is a tuple on the stack with the positional defaults -// if n_kw_defaults > 0 then there is a dictionary on the stack with the keyword defaults -// if both exist, the tuple is above the dictionary (ie the first pop gets the tuple) -STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) { - assert(n_pos_defaults >= 0); - assert(n_kw_defaults >= 0); - - // set flags - if (n_kw_defaults > 0) { - this_scope->scope_flags |= MP_SCOPE_FLAG_DEFKWARGS; - } - this_scope->num_def_pos_args = n_pos_defaults; - - // make closed over variables, if any - // ensure they are closed over in the order defined in the outer scope (mainly to agree with CPython) - int nfree = 0; - if (comp->scope_cur->kind != SCOPE_MODULE) { - for (int i = 0; i < comp->scope_cur->id_info_len; i++) { - id_info_t *id = &comp->scope_cur->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { - for (int j = 0; j < this_scope->id_info_len; j++) { - id_info_t *id2 = &this_scope->id_info[j]; - if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { - // in MicroPython we load closures using LOAD_FAST - EMIT_LOAD_FAST(id->qst, id->local_num); - nfree += 1; - } - } - } - } - } - - // make the function/closure - if (nfree == 0) { - EMIT_ARG(make_function, this_scope, n_pos_defaults, n_kw_defaults); - } else { - EMIT_ARG(make_closure, this_scope, nfree, n_pos_defaults, n_kw_defaults); - } -} - -STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) { - // For efficiency of the code below we extract the parse-node kind here - int pn_kind; - if (MP_PARSE_NODE_IS_ID(pn)) { - pn_kind = -1; - } else { - assert(MP_PARSE_NODE_IS_STRUCT(pn)); - pn_kind = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn); - } - - if (pn_kind == PN_typedargslist_star || pn_kind == PN_varargslist_star) { - comp->have_star = true; - /* don't need to distinguish bare from named star - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // bare star - } else { - // named star - } - */ - - } else if (pn_kind == PN_typedargslist_dbl_star || pn_kind == PN_varargslist_dbl_star) { - // named double star - // TODO do we need to do anything with this? - - } else { - mp_parse_node_t pn_id; - mp_parse_node_t pn_colon; - mp_parse_node_t pn_equal; - if (pn_kind == -1) { - // this parameter is just an id - - pn_id = pn; - pn_colon = MP_PARSE_NODE_NULL; - pn_equal = MP_PARSE_NODE_NULL; - - } else if (pn_kind == PN_typedargslist_name) { - // this parameter has a colon and/or equal specifier - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - pn_id = pns->nodes[0]; - pn_colon = pns->nodes[1]; - pn_equal = pns->nodes[2]; - - } else { - assert(pn_kind == PN_varargslist_name); // should be - // this parameter has an equal specifier - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - pn_id = pns->nodes[0]; - pn_equal = pns->nodes[1]; - } - - if (MP_PARSE_NODE_IS_NULL(pn_equal)) { - // this parameter does not have a default value - - // check for non-default parameters given after default parameters (allowed by parser, but not syntactically valid) - if (!comp->have_star && comp->num_default_params != 0) { - compile_syntax_error(comp, pn, "non-default argument follows default argument"); - return; - } - - } else { - // this parameter has a default value - // in CPython, None (and True, False?) as default parameters are loaded with LOAD_NAME; don't understandy why - - if (comp->have_star) { - comp->num_dict_params += 1; - // in MicroPython we put the default dict parameters into a dictionary using the bytecode - if (comp->num_dict_params == 1) { - // in MicroPython we put the default positional parameters into a tuple using the bytecode - // we need to do this here before we start building the map for the default keywords - if (comp->num_default_params > 0) { - EMIT_ARG(build_tuple, comp->num_default_params); - } else { - EMIT(load_null); // sentinel indicating empty default positional args - } - // first default dict param, so make the map - EMIT_ARG(build_map, 0); - } - - // compile value then key, then store it to the dict - compile_node(comp, pn_equal); - EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id)); - EMIT(store_map); - } else { - comp->num_default_params += 1; - compile_node(comp, pn_equal); - } - } - - // TODO pn_colon not implemented - (void)pn_colon; - } -} - -STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) { - // When we call compile_funcdef_lambdef_param below it can compile an arbitrary - // expression for default arguments, which may contain a lambda. The lambda will - // call here in a nested way, so we must save and restore the relevant state. - bool orig_have_star = comp->have_star; - uint16_t orig_num_dict_params = comp->num_dict_params; - uint16_t orig_num_default_params = comp->num_default_params; - - // compile default parameters - comp->have_star = false; - comp->num_dict_params = 0; - comp->num_default_params = 0; - apply_to_single_or_list(comp, pn_params, pn_list_kind, compile_funcdef_lambdef_param); - - if (comp->compile_error != MP_OBJ_NULL) { - return; - } - - // in MicroPython we put the default positional parameters into a tuple using the bytecode - // the default keywords args may have already made the tuple; if not, do it now - if (comp->num_default_params > 0 && comp->num_dict_params == 0) { - EMIT_ARG(build_tuple, comp->num_default_params); - EMIT(load_null); // sentinel indicating empty default keyword args - } - - // make the function - close_over_variables_etc(comp, scope, comp->num_default_params, comp->num_dict_params); - - // restore state - comp->have_star = orig_have_star; - comp->num_dict_params = orig_num_dict_params; - comp->num_default_params = orig_num_default_params; -} - -// leaves function object on stack -// returns function name -STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { - if (comp->pass == MP_PASS_SCOPE) { - // create a new scope for this function - scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options); - // store the function scope so the compiling function can use it at each pass - pns->nodes[4] = (mp_parse_node_t)s; - } - - // get the scope for this function - scope_t *fscope = (scope_t*)pns->nodes[4]; - - // compile the function definition - compile_funcdef_lambdef(comp, fscope, pns->nodes[1], PN_typedargslist); - - // return its name (the 'f' in "def f(...):") - return fscope->simple_name; -} - -// leaves class object on stack -// returns class name -STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) { - if (comp->pass == MP_PASS_SCOPE) { - // create a new scope for this class - scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options); - // store the class scope so the compiling function can use it at each pass - pns->nodes[3] = (mp_parse_node_t)s; - } - - EMIT(load_build_class); - - // scope for this class - scope_t *cscope = (scope_t*)pns->nodes[3]; - - // compile the class - close_over_variables_etc(comp, cscope, 0, 0); - - // get its name - EMIT_ARG(load_const_str, cscope->simple_name); - - // nodes[1] has parent classes, if any - // empty parenthesis (eg class C():) gets here as an empty PN_classdef_2 and needs special handling - mp_parse_node_t parents = pns->nodes[1]; - if (MP_PARSE_NODE_IS_STRUCT_KIND(parents, PN_classdef_2)) { - parents = MP_PARSE_NODE_NULL; - } - compile_trailer_paren_helper(comp, parents, false, 2); - - // return its name (the 'C' in class C(...):") - return cscope->simple_name; -} - -// returns true if it was a built-in decorator (even if the built-in had an error) -STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_node_t *name_nodes, uint *emit_options) { - if (MP_PARSE_NODE_LEAF_ARG(name_nodes[0]) != MP_QSTR_micropython) { - return false; - } - - if (name_len != 2) { - compile_syntax_error(comp, name_nodes[0], "invalid micropython decorator"); - return true; - } - - qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]); - if (attr == MP_QSTR_bytecode) { - *emit_options = MP_EMIT_OPT_BYTECODE; -#if MICROPY_EMIT_NATIVE - } else if (attr == MP_QSTR_native) { - *emit_options = MP_EMIT_OPT_NATIVE_PYTHON; - } else if (attr == MP_QSTR_viper) { - *emit_options = MP_EMIT_OPT_VIPER; -#endif - #if MICROPY_EMIT_INLINE_ASM - } else if (attr == ASM_DECORATOR_QSTR) { - *emit_options = MP_EMIT_OPT_ASM; - #endif - } else { - compile_syntax_error(comp, name_nodes[1], "invalid micropython decorator"); - } - - return true; -} - -STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) { - // get the list of decorators - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes); - - // inherit emit options for this function/class definition - uint emit_options = comp->scope_cur->emit_options; - - // compile each decorator - int num_built_in_decorators = 0; - for (int i = 0; i < n; i++) { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(nodes[i], PN_decorator)); // should be - mp_parse_node_struct_t *pns_decorator = (mp_parse_node_struct_t*)nodes[i]; - - // nodes[0] contains the decorator function, which is a dotted name - mp_parse_node_t *name_nodes; - int name_len = mp_parse_node_extract_list(&pns_decorator->nodes[0], PN_dotted_name, &name_nodes); - - // check for built-in decorators - if (compile_built_in_decorator(comp, name_len, name_nodes, &emit_options)) { - // this was a built-in - num_built_in_decorators += 1; - - } else { - // not a built-in, compile normally - - // compile the decorator function - compile_node(comp, name_nodes[0]); - for (int j = 1; j < name_len; j++) { - assert(MP_PARSE_NODE_IS_ID(name_nodes[j])); // should be - EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(name_nodes[j])); - } - - // nodes[1] contains arguments to the decorator function, if any - if (!MP_PARSE_NODE_IS_NULL(pns_decorator->nodes[1])) { - // call the decorator function with the arguments in nodes[1] - compile_node(comp, pns_decorator->nodes[1]); - } - } - } - - // compile the body (funcdef, async funcdef or classdef) and get its name - mp_parse_node_struct_t *pns_body = (mp_parse_node_struct_t*)pns->nodes[1]; - qstr body_name = 0; - if (MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_funcdef) { - body_name = compile_funcdef_helper(comp, pns_body, emit_options); - #if MICROPY_PY_ASYNC_AWAIT - } else if (MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_async_funcdef) { - assert(MP_PARSE_NODE_IS_STRUCT(pns_body->nodes[0])); - mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns_body->nodes[0]; - body_name = compile_funcdef_helper(comp, pns0, emit_options); - scope_t *fscope = (scope_t*)pns0->nodes[4]; - fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; - #endif - } else { - assert(MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_classdef); // should be - body_name = compile_classdef_helper(comp, pns_body, emit_options); - } - - // call each decorator - for (int i = 0; i < n - num_built_in_decorators; i++) { - EMIT_ARG(call_function, 1, 0, 0); - } - - // store func/class object into name - compile_store_id(comp, body_name); -} - -STATIC void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) { - qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options); - // store function object into function name - compile_store_id(comp, fname); -} - -STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) { - if (MP_PARSE_NODE_IS_ID(pn)) { - compile_delete_id(comp, MP_PARSE_NODE_LEAF_ARG(pn)); - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_expr_normal)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - - compile_node(comp, pns->nodes[0]); // base of the atom_expr_normal node - - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_atom_expr_trailers) { - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); - for (int i = 0; i < n - 1; i++) { - compile_node(comp, pns1->nodes[i]); - } - assert(MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1])); - pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1]; - } - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_bracket) { - compile_node(comp, pns1->nodes[0]); - EMIT(delete_subscr); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_period) { - assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); - EMIT_ARG(delete_attr, MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])); - } else { - goto cannot_delete; - } - } else { - goto cannot_delete; - } - - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_paren)) { - pn = ((mp_parse_node_struct_t*)pn)->nodes[0]; - if (MP_PARSE_NODE_IS_NULL(pn)) { - goto cannot_delete; - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - // TODO perhaps factorise testlist_comp code with other uses of PN_testlist_comp - - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3b) { - // sequence of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns1->nodes[0])); - c_del_stmt(comp, pns->nodes[0]); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3c) { - // sequence of many items - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); - c_del_stmt(comp, pns->nodes[0]); - for (int i = 0; i < n; i++) { - c_del_stmt(comp, pns1->nodes[i]); - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for) { - goto cannot_delete; - } else { - // sequence with 2 items - goto sequence_with_2_items; - } - } else { - // sequence with 2 items - sequence_with_2_items: - c_del_stmt(comp, pns->nodes[0]); - c_del_stmt(comp, pns->nodes[1]); - } - } - } else { - // some arbitrary statement that we can't delete (eg del 1) - goto cannot_delete; - } - - return; - -cannot_delete: - compile_syntax_error(comp, (mp_parse_node_t)pn, "can't delete expression"); -} - -STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt); -} - -STATIC void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->break_label == INVALID_LABEL) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' outside loop"); - } - assert(comp->cur_except_level >= comp->break_continue_except_level); - EMIT_ARG(break_loop, comp->break_label, comp->cur_except_level - comp->break_continue_except_level); -} - -STATIC void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->continue_label == INVALID_LABEL) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' outside loop"); - } - assert(comp->cur_except_level >= comp->break_continue_except_level); - EMIT_ARG(continue_loop, comp->continue_label, comp->cur_except_level - comp->break_continue_except_level); -} - -STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->scope_cur->kind != SCOPE_FUNCTION) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' outside function"); - return; - } - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // no argument to 'return', so return None - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - } else if (MICROPY_COMP_RETURN_IF_EXPR - && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_test_if_expr)) { - // special case when returning an if-expression; to match CPython optimisation - mp_parse_node_struct_t *pns_test_if_expr = (mp_parse_node_struct_t*)pns->nodes[0]; - mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns_test_if_expr->nodes[1]; - - uint l_fail = comp_next_label(comp); - c_if_cond(comp, pns_test_if_else->nodes[0], false, l_fail); // condition - compile_node(comp, pns_test_if_expr->nodes[0]); // success value - EMIT(return_value); - EMIT_ARG(label_assign, l_fail); - compile_node(comp, pns_test_if_else->nodes[1]); // failure value - } else { - compile_node(comp, pns->nodes[0]); - } - EMIT(return_value); -} - -STATIC void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[0]); - EMIT(pop_top); -} - -STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // raise - EMIT_ARG(raise_varargs, 0); - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_raise_stmt_arg)) { - // raise x from y - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - compile_node(comp, pns->nodes[0]); - compile_node(comp, pns->nodes[1]); - EMIT_ARG(raise_varargs, 2); - } else { - // raise x - compile_node(comp, pns->nodes[0]); - EMIT_ARG(raise_varargs, 1); - } -} - -// q_base holds the base of the name -// eg a -> q_base=a -// a.b.c -> q_base=a -STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) { - bool is_as = false; - if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_as_name)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - // a name of the form x as y; unwrap it - *q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[1]); - pn = pns->nodes[0]; - is_as = true; - } - if (MP_PARSE_NODE_IS_NULL(pn)) { - // empty name (eg, from . import x) - *q_base = MP_QSTR_; - EMIT_ARG(import_name, MP_QSTR_); // import the empty string - } else if (MP_PARSE_NODE_IS_ID(pn)) { - // just a simple name - qstr q_full = MP_PARSE_NODE_LEAF_ARG(pn); - if (!is_as) { - *q_base = q_full; - } - EMIT_ARG(import_name, q_full); - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_name)); // should be - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - { - // a name of the form a.b.c - if (!is_as) { - *q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - } - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - int len = n - 1; - for (int i = 0; i < n; i++) { - len += qstr_len(MP_PARSE_NODE_LEAF_ARG(pns->nodes[i])); - } - byte *q_ptr; - byte *str_dest = qstr_build_start(len, &q_ptr); - for (int i = 0; i < n; i++) { - if (i > 0) { - *str_dest++ = '.'; - } - size_t str_src_len; - const byte *str_src = qstr_data(MP_PARSE_NODE_LEAF_ARG(pns->nodes[i]), &str_src_len); - memcpy(str_dest, str_src, str_src_len); - str_dest += str_src_len; - } - qstr q_full = qstr_build_end(q_ptr); - EMIT_ARG(import_name, q_full); - if (is_as) { - for (int i = 1; i < n; i++) { - EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[i])); - } - } - } - } -} - -STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) { - EMIT_ARG(load_const_small_int, 0); // level 0 import - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // not importing from anything - qstr q_base; - do_import_name(comp, pn, &q_base); - compile_store_id(comp, q_base); -} - -STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) { - apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name); -} - -STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) { - mp_parse_node_t pn_import_source = pns->nodes[0]; - - // extract the preceding .'s (if any) for a relative import, to compute the import level - uint import_level = 0; - do { - mp_parse_node_t pn_rel; - if (MP_PARSE_NODE_IS_TOKEN(pn_import_source) || MP_PARSE_NODE_IS_STRUCT_KIND(pn_import_source, PN_one_or_more_period_or_ellipsis)) { - // This covers relative imports with dots only like "from .. import" - pn_rel = pn_import_source; - pn_import_source = MP_PARSE_NODE_NULL; - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn_import_source, PN_import_from_2b)) { - // This covers relative imports starting with dot(s) like "from .foo import" - mp_parse_node_struct_t *pns_2b = (mp_parse_node_struct_t*)pn_import_source; - pn_rel = pns_2b->nodes[0]; - pn_import_source = pns_2b->nodes[1]; - assert(!MP_PARSE_NODE_IS_NULL(pn_import_source)); // should not be - } else { - // Not a relative import - break; - } - - // get the list of . and/or ...'s - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pn_rel, PN_one_or_more_period_or_ellipsis, &nodes); - - // count the total number of .'s - for (int i = 0; i < n; i++) { - if (MP_PARSE_NODE_IS_TOKEN_KIND(nodes[i], MP_TOKEN_DEL_PERIOD)) { - import_level++; - } else { - // should be an MP_TOKEN_ELLIPSIS - import_level += 3; - } - } - } while (0); - - if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_STAR)) { - EMIT_ARG(load_const_small_int, import_level); - - // build the "fromlist" tuple - EMIT_ARG(load_const_str, MP_QSTR__star_); - EMIT_ARG(build_tuple, 1); - - // do the import - qstr dummy_q; - do_import_name(comp, pn_import_source, &dummy_q); - EMIT(import_star); - - } else { - EMIT_ARG(load_const_small_int, import_level); - - // build the "fromlist" tuple - mp_parse_node_t *pn_nodes; - int n = mp_parse_node_extract_list(&pns->nodes[1], PN_import_as_names, &pn_nodes); - for (int i = 0; i < n; i++) { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)); - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; - qstr id2 = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[0]); // should be id - EMIT_ARG(load_const_str, id2); - } - EMIT_ARG(build_tuple, n); - - // do the import - qstr dummy_q; - do_import_name(comp, pn_import_source, &dummy_q); - for (int i = 0; i < n; i++) { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name)); - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i]; - qstr id2 = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[0]); // should be id - EMIT_ARG(import_from, id2); - if (MP_PARSE_NODE_IS_NULL(pns3->nodes[1])) { - compile_store_id(comp, id2); - } else { - compile_store_id(comp, MP_PARSE_NODE_LEAF_ARG(pns3->nodes[1])); - } - } - EMIT(pop_top); - } -} - -STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, qstr qst) { - bool added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); - if (!added && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) { - compile_syntax_error(comp, pn, "identifier redefined as global"); - return; - } - id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; - - // if the id exists in the global scope, set its kind to EXPLICIT_GLOBAL - id_info = scope_find_global(comp->scope_cur, qst); - if (id_info != NULL) { - id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; - } -} - -STATIC void compile_global_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->pass == MP_PASS_SCOPE) { - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); - for (int i = 0; i < n; i++) { - compile_declare_global(comp, (mp_parse_node_t)pns, MP_PARSE_NODE_LEAF_ARG(nodes[i])); - } - } -} - -STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, qstr qst) { - bool added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qst, &added); - if (added) { - scope_find_local_and_close_over(comp->scope_cur, id_info, qst); - if (id_info->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - compile_syntax_error(comp, pn, "no binding for nonlocal found"); - } - } else if (id_info->kind != ID_INFO_KIND_FREE) { - compile_syntax_error(comp, pn, "identifier redefined as nonlocal"); - } -} - -STATIC void compile_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->pass == MP_PASS_SCOPE) { - if (comp->scope_cur->kind == SCOPE_MODULE) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "can't declare nonlocal in outer code"); - return; - } - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_name_list, &nodes); - for (int i = 0; i < n; i++) { - compile_declare_nonlocal(comp, (mp_parse_node_t)pns, MP_PARSE_NODE_LEAF_ARG(nodes[i])); - } - } -} - -STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - // with optimisations enabled we don't compile assertions - if (MP_STATE_VM(mp_optimise_value) != 0) { - return; - } - - uint l_end = comp_next_label(comp); - c_if_cond(comp, pns->nodes[0], true, l_end); - EMIT_LOAD_GLOBAL(MP_QSTR_AssertionError); // we load_global instead of load_id, to be consistent with CPython - if (!MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { - // assertion message - compile_node(comp, pns->nodes[1]); - EMIT_ARG(call_function, 1, 0, 0); - } - EMIT_ARG(raise_varargs, 1); - EMIT_ARG(label_assign, l_end); -} - -STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - uint l_end = comp_next_label(comp); - - // optimisation: don't emit anything when "if False" - if (!mp_parse_node_is_const_false(pns->nodes[0])) { - uint l_fail = comp_next_label(comp); - c_if_cond(comp, pns->nodes[0], false, l_fail); // if condition - - compile_node(comp, pns->nodes[1]); // if block - - // optimisation: skip everything else when "if True" - if (mp_parse_node_is_const_true(pns->nodes[0])) { - goto done; - } - - if ( - // optimisation: don't jump over non-existent elif/else blocks - !(MP_PARSE_NODE_IS_NULL(pns->nodes[2]) && MP_PARSE_NODE_IS_NULL(pns->nodes[3])) - // optimisation: don't jump if last instruction was return - && !EMIT(last_emit_was_return_value) - ) { - // jump over elif/else blocks - EMIT_ARG(jump, l_end); - } - - EMIT_ARG(label_assign, l_fail); - } - - // compile elif blocks (if any) - mp_parse_node_t *pn_elif; - int n_elif = mp_parse_node_extract_list(&pns->nodes[2], PN_if_stmt_elif_list, &pn_elif); - for (int i = 0; i < n_elif; i++) { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_elif[i], PN_if_stmt_elif)); // should be - mp_parse_node_struct_t *pns_elif = (mp_parse_node_struct_t*)pn_elif[i]; - - // optimisation: don't emit anything when "if False" - if (!mp_parse_node_is_const_false(pns_elif->nodes[0])) { - uint l_fail = comp_next_label(comp); - c_if_cond(comp, pns_elif->nodes[0], false, l_fail); // elif condition - - compile_node(comp, pns_elif->nodes[1]); // elif block - - // optimisation: skip everything else when "elif True" - if (mp_parse_node_is_const_true(pns_elif->nodes[0])) { - goto done; - } - - // optimisation: don't jump if last instruction was return - if (!EMIT(last_emit_was_return_value)) { - EMIT_ARG(jump, l_end); - } - EMIT_ARG(label_assign, l_fail); - } - } - - // compile else block - compile_node(comp, pns->nodes[3]); // can be null - -done: - EMIT_ARG(label_assign, l_end); -} - -#define START_BREAK_CONTINUE_BLOCK \ - uint16_t old_break_label = comp->break_label; \ - uint16_t old_continue_label = comp->continue_label; \ - uint16_t old_break_continue_except_level = comp->break_continue_except_level; \ - uint break_label = comp_next_label(comp); \ - uint continue_label = comp_next_label(comp); \ - comp->break_label = break_label; \ - comp->continue_label = continue_label; \ - comp->break_continue_except_level = comp->cur_except_level; - -#define END_BREAK_CONTINUE_BLOCK \ - comp->break_label = old_break_label; \ - comp->continue_label = old_continue_label; \ - comp->break_continue_except_level = old_break_continue_except_level; - -STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - START_BREAK_CONTINUE_BLOCK - - if (!mp_parse_node_is_const_false(pns->nodes[0])) { // optimisation: don't emit anything for "while False" - uint top_label = comp_next_label(comp); - if (!mp_parse_node_is_const_true(pns->nodes[0])) { // optimisation: don't jump to cond for "while True" - EMIT_ARG(jump, continue_label); - } - EMIT_ARG(label_assign, top_label); - compile_node(comp, pns->nodes[1]); // body - EMIT_ARG(label_assign, continue_label); - c_if_cond(comp, pns->nodes[0], true, top_label); // condition - } - - // break/continue apply to outer loop (if any) in the else block - END_BREAK_CONTINUE_BLOCK - - compile_node(comp, pns->nodes[2]); // else - - EMIT_ARG(label_assign, break_label); -} - -// This function compiles an optimised for-loop of the form: -// for in range(, , ): -// -// else: -// -// must be an identifier and must be a small-int. -// -// Semantics of for-loop require: -// - final failing value should not be stored in the loop variable -// - if the loop never runs, the loop variable should never be assigned -// - assignments to , or in the body do not alter the loop -// ( is a constant for us, so no need to worry about it changing) -// -// If is a small-int, then the stack during the for-loop contains just -// the current value of . Otherwise, the stack contains then the -// current value of . -STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) { - START_BREAK_CONTINUE_BLOCK - - uint top_label = comp_next_label(comp); - uint entry_label = comp_next_label(comp); - - // put the end value on the stack if it's not a small-int constant - bool end_on_stack = !MP_PARSE_NODE_IS_SMALL_INT(pn_end); - if (end_on_stack) { - compile_node(comp, pn_end); - } - - // compile: start - compile_node(comp, pn_start); - - EMIT_ARG(jump, entry_label); - EMIT_ARG(label_assign, top_label); - - // duplicate next value and store it to var - EMIT(dup_top); - c_assign(comp, pn_var, ASSIGN_STORE); - - // compile body - compile_node(comp, pn_body); - - EMIT_ARG(label_assign, continue_label); - - // compile: var + step - compile_node(comp, pn_step); - EMIT_ARG(binary_op, MP_BINARY_OP_INPLACE_ADD); - - EMIT_ARG(label_assign, entry_label); - - // compile: if var end: goto top - if (end_on_stack) { - EMIT(dup_top_two); - EMIT(rot_two); - } else { - EMIT(dup_top); - compile_node(comp, pn_end); - } - assert(MP_PARSE_NODE_IS_SMALL_INT(pn_step)); - if (MP_PARSE_NODE_LEAF_SMALL_INT(pn_step) >= 0) { - EMIT_ARG(binary_op, MP_BINARY_OP_LESS); - } else { - EMIT_ARG(binary_op, MP_BINARY_OP_MORE); - } - EMIT_ARG(pop_jump_if, true, top_label); - - // break/continue apply to outer loop (if any) in the else block - END_BREAK_CONTINUE_BLOCK - - // Compile the else block. We must pop the iterator variables before - // executing the else code because it may contain break/continue statements. - uint end_label = 0; - if (!MP_PARSE_NODE_IS_NULL(pn_else)) { - // discard final value of "var", and possible "end" value - EMIT(pop_top); - if (end_on_stack) { - EMIT(pop_top); - } - compile_node(comp, pn_else); - end_label = comp_next_label(comp); - EMIT_ARG(jump, end_label); - EMIT_ARG(adjust_stack_size, 1 + end_on_stack); - } - - EMIT_ARG(label_assign, break_label); - - // discard final value of var that failed the loop condition - EMIT(pop_top); - - // discard value if it's on the stack - if (end_on_stack) { - EMIT(pop_top); - } - - if (!MP_PARSE_NODE_IS_NULL(pn_else)) { - EMIT_ARG(label_assign, end_label); - } -} - -STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - // this bit optimises: for in range(...), turning it into an explicitly incremented variable - // this is actually slower, but uses no heap memory - // for viper it will be much, much faster - if (/*comp->scope_cur->emit_options == MP_EMIT_OPT_VIPER &&*/ MP_PARSE_NODE_IS_ID(pns->nodes[0]) && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_atom_expr_normal)) { - mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_IS_ID(pns_it->nodes[0]) - && MP_PARSE_NODE_LEAF_ARG(pns_it->nodes[0]) == MP_QSTR_range - && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pns_it->nodes[1]) == PN_trailer_paren) { - mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0]; - mp_parse_node_t *args; - int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args); - mp_parse_node_t pn_range_start; - mp_parse_node_t pn_range_end; - mp_parse_node_t pn_range_step; - bool optimize = false; - if (1 <= n_args && n_args <= 3) { - optimize = true; - if (n_args == 1) { - pn_range_start = mp_parse_node_new_small_int(0); - pn_range_end = args[0]; - pn_range_step = mp_parse_node_new_small_int(1); - } else if (n_args == 2) { - pn_range_start = args[0]; - pn_range_end = args[1]; - pn_range_step = mp_parse_node_new_small_int(1); - } else { - pn_range_start = args[0]; - pn_range_end = args[1]; - pn_range_step = args[2]; - // the step must be a non-zero constant integer to do the optimisation - if (!MP_PARSE_NODE_IS_SMALL_INT(pn_range_step) - || MP_PARSE_NODE_LEAF_SMALL_INT(pn_range_step) == 0) { - optimize = false; - } - } - // arguments must be able to be compiled as standard expressions - if (optimize && MP_PARSE_NODE_IS_STRUCT(pn_range_start)) { - int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_range_start); - if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { - optimize = false; - } - } - if (optimize && MP_PARSE_NODE_IS_STRUCT(pn_range_end)) { - int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_range_end); - if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) { - optimize = false; - } - } - } - if (optimize) { - compile_for_stmt_optimised_range(comp, pns->nodes[0], pn_range_start, pn_range_end, pn_range_step, pns->nodes[2], pns->nodes[3]); - return; - } - } - } - - START_BREAK_CONTINUE_BLOCK - comp->break_label |= MP_EMIT_BREAK_FROM_FOR; - - uint pop_label = comp_next_label(comp); - - compile_node(comp, pns->nodes[1]); // iterator - EMIT_ARG(get_iter, true); - EMIT_ARG(label_assign, continue_label); - EMIT_ARG(for_iter, pop_label); - c_assign(comp, pns->nodes[0], ASSIGN_STORE); // variable - compile_node(comp, pns->nodes[2]); // body - if (!EMIT(last_emit_was_return_value)) { - EMIT_ARG(jump, continue_label); - } - EMIT_ARG(label_assign, pop_label); - EMIT(for_iter_end); - - // break/continue apply to outer loop (if any) in the else block - END_BREAK_CONTINUE_BLOCK - - compile_node(comp, pns->nodes[3]); // else (may be empty) - - EMIT_ARG(label_assign, break_label); -} - -STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) { - // setup code - uint l1 = comp_next_label(comp); - uint success_label = comp_next_label(comp); - - EMIT_ARG(setup_except, l1); - compile_increase_except_level(comp); - - compile_node(comp, pn_body); // body - EMIT(pop_block); - EMIT_ARG(jump, success_label); // jump over exception handler - - EMIT_ARG(label_assign, l1); // start of exception handler - EMIT(start_except_handler); - - // at this point the top of the stack contains the exception instance that was raised - - uint l2 = comp_next_label(comp); - - for (int i = 0; i < n_except; i++) { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_excepts[i], PN_try_stmt_except)); // should be - mp_parse_node_struct_t *pns_except = (mp_parse_node_struct_t*)pn_excepts[i]; - - qstr qstr_exception_local = 0; - uint end_finally_label = comp_next_label(comp); - - if (MP_PARSE_NODE_IS_NULL(pns_except->nodes[0])) { - // this is a catch all exception handler - if (i + 1 != n_except) { - compile_syntax_error(comp, pn_excepts[i], "default 'except' must be last"); - compile_decrease_except_level(comp); - return; - } - } else { - // this exception handler requires a match to a certain type of exception - mp_parse_node_t pns_exception_expr = pns_except->nodes[0]; - if (MP_PARSE_NODE_IS_STRUCT(pns_exception_expr)) { - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns_exception_expr; - if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_try_stmt_as_name) { - // handler binds the exception to a local - pns_exception_expr = pns3->nodes[0]; - qstr_exception_local = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[1]); - } - } - EMIT(dup_top); - compile_node(comp, pns_exception_expr); - EMIT_ARG(binary_op, MP_BINARY_OP_EXCEPTION_MATCH); - EMIT_ARG(pop_jump_if, false, end_finally_label); - } - - // either discard or store the exception instance - if (qstr_exception_local == 0) { - EMIT(pop_top); - } else { - compile_store_id(comp, qstr_exception_local); - } - - uint l3 = 0; - if (qstr_exception_local != 0) { - l3 = comp_next_label(comp); - EMIT_ARG(setup_finally, l3); - compile_increase_except_level(comp); - } - compile_node(comp, pns_except->nodes[1]); - if (qstr_exception_local != 0) { - EMIT(pop_block); - } - EMIT(pop_except); - if (qstr_exception_local != 0) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT_ARG(label_assign, l3); - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - compile_store_id(comp, qstr_exception_local); - compile_delete_id(comp, qstr_exception_local); - - compile_decrease_except_level(comp); - EMIT(end_finally); - } - EMIT_ARG(jump, l2); - EMIT_ARG(label_assign, end_finally_label); - EMIT_ARG(adjust_stack_size, 1); // stack adjust for the exception instance - } - - compile_decrease_except_level(comp); - EMIT(end_finally); - EMIT(end_except_handler); - - EMIT_ARG(label_assign, success_label); - compile_node(comp, pn_else); // else block, can be null - EMIT_ARG(label_assign, l2); -} - -STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) { - uint l_finally_block = comp_next_label(comp); - - EMIT_ARG(setup_finally, l_finally_block); - compile_increase_except_level(comp); - - if (n_except == 0) { - assert(MP_PARSE_NODE_IS_NULL(pn_else)); - EMIT_ARG(adjust_stack_size, 3); // stack adjust for possible UNWIND_JUMP state - compile_node(comp, pn_body); - EMIT_ARG(adjust_stack_size, -3); - } else { - compile_try_except(comp, pn_body, n_except, pn_except, pn_else); - } - EMIT(pop_block); - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT_ARG(label_assign, l_finally_block); - compile_node(comp, pn_finally); - - compile_decrease_except_level(comp); - EMIT(end_finally); -} - -STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should be - { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_try_stmt_finally) { - // just try-finally - compile_try_finally(comp, pns->nodes[0], 0, NULL, MP_PARSE_NODE_NULL, pns2->nodes[0]); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_try_stmt_except_and_more) { - // try-except and possibly else and/or finally - mp_parse_node_t *pn_excepts; - int n_except = mp_parse_node_extract_list(&pns2->nodes[0], PN_try_stmt_except_list, &pn_excepts); - if (MP_PARSE_NODE_IS_NULL(pns2->nodes[2])) { - // no finally - compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1]); - } else { - // have finally - compile_try_finally(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1], ((mp_parse_node_struct_t*)pns2->nodes[2])->nodes[0]); - } - } else { - // just try-except - mp_parse_node_t *pn_excepts; - int n_except = mp_parse_node_extract_list(&pns->nodes[1], PN_try_stmt_except_list, &pn_excepts); - compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, MP_PARSE_NODE_NULL); - } - } -} - -STATIC void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, mp_parse_node_t body) { - if (n == 0) { - // no more pre-bits, compile the body of the with - compile_node(comp, body); - } else { - uint l_end = comp_next_label(comp); - if (MICROPY_EMIT_NATIVE && comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) { - // we need to allocate an extra label for the native emitter - // it will use l_end+1 as an auxiliary label - comp_next_label(comp); - } - if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes[0], PN_with_item)) { - // this pre-bit is of the form "a as b" - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0]; - compile_node(comp, pns->nodes[0]); - EMIT_ARG(setup_with, l_end); - c_assign(comp, pns->nodes[1], ASSIGN_STORE); - } else { - // this pre-bit is just an expression - compile_node(comp, nodes[0]); - EMIT_ARG(setup_with, l_end); - EMIT(pop_top); - } - compile_increase_except_level(comp); - // compile additional pre-bits and the body - compile_with_stmt_helper(comp, n - 1, nodes + 1, body); - // finish this with block - EMIT_ARG(with_cleanup, l_end); - compile_decrease_except_level(comp); - EMIT(end_finally); - } -} - -STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit) - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes); - assert(n > 0); - - // compile in a nested fashion - compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]); -} - -STATIC void compile_yield_from(compiler_t *comp) { - EMIT_ARG(get_iter, false); - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT(yield_from); -} - -#if MICROPY_PY_ASYNC_AWAIT -STATIC void compile_await_object_method(compiler_t *comp, qstr method) { - EMIT_ARG(load_method, method, false); - EMIT_ARG(call_method, 0, 0, 0); - compile_yield_from(comp); -} - -STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - // comp->break_label |= MP_EMIT_BREAK_FROM_FOR; - - qstr context = MP_PARSE_NODE_LEAF_ARG(pns->nodes[1]); - uint while_else_label = comp_next_label(comp); - uint try_exception_label = comp_next_label(comp); - uint try_else_label = comp_next_label(comp); - uint try_finally_label = comp_next_label(comp); - - compile_node(comp, pns->nodes[1]); // iterator - compile_await_object_method(comp, MP_QSTR___aiter__); - compile_store_id(comp, context); - - START_BREAK_CONTINUE_BLOCK - - EMIT_ARG(label_assign, continue_label); - - EMIT_ARG(setup_except, try_exception_label); - compile_increase_except_level(comp); - - compile_load_id(comp, context); - compile_await_object_method(comp, MP_QSTR___anext__); - c_assign(comp, pns->nodes[0], ASSIGN_STORE); // variable - EMIT(pop_block); - EMIT_ARG(jump, try_else_label); - - EMIT_ARG(label_assign, try_exception_label); - EMIT(start_except_handler); - EMIT(dup_top); - EMIT_LOAD_GLOBAL(MP_QSTR_StopAsyncIteration); - EMIT_ARG(binary_op, MP_BINARY_OP_EXCEPTION_MATCH); - EMIT_ARG(pop_jump_if, false, try_finally_label); - EMIT(pop_top); // pop exception instance - EMIT(pop_except); - EMIT_ARG(jump, while_else_label); - - EMIT_ARG(label_assign, try_finally_label); - EMIT_ARG(adjust_stack_size, 1); // if we jump here, the exc is on the stack - compile_decrease_except_level(comp); - EMIT(end_finally); - EMIT(end_except_handler); - - EMIT_ARG(label_assign, try_else_label); - compile_node(comp, pns->nodes[2]); // body - - EMIT_ARG(jump, continue_label); - // break/continue apply to outer loop (if any) in the else block - END_BREAK_CONTINUE_BLOCK - - EMIT_ARG(label_assign, while_else_label); - compile_node(comp, pns->nodes[3]); // else - - EMIT_ARG(label_assign, break_label); -} - -STATIC void compile_async_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, mp_parse_node_t body) { - if (n == 0) { - // no more pre-bits, compile the body of the with - compile_node(comp, body); - } else { - uint try_exception_label = comp_next_label(comp); - uint no_reraise_label = comp_next_label(comp); - uint try_else_label = comp_next_label(comp); - uint end_label = comp_next_label(comp); - qstr context; - - if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes[0], PN_with_item)) { - // this pre-bit is of the form "a as b" - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0]; - compile_node(comp, pns->nodes[0]); - context = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - compile_store_id(comp, context); - compile_load_id(comp, context); - compile_await_object_method(comp, MP_QSTR___aenter__); - c_assign(comp, pns->nodes[1], ASSIGN_STORE); - } else { - // this pre-bit is just an expression - compile_node(comp, nodes[0]); - context = MP_PARSE_NODE_LEAF_ARG(nodes[0]); - compile_store_id(comp, context); - compile_load_id(comp, context); - compile_await_object_method(comp, MP_QSTR___aenter__); - EMIT(pop_top); - } - - compile_load_id(comp, context); - EMIT_ARG(load_method, MP_QSTR___aexit__, false); - - EMIT_ARG(setup_except, try_exception_label); - compile_increase_except_level(comp); - // compile additional pre-bits and the body - compile_async_with_stmt_helper(comp, n - 1, nodes + 1, body); - // finish this with block - EMIT(pop_block); - EMIT_ARG(jump, try_else_label); // jump over exception handler - - EMIT_ARG(label_assign, try_exception_label); // start of exception handler - EMIT(start_except_handler); - - // at this point the stack contains: ..., __aexit__, self, exc - EMIT(dup_top); - #if MICROPY_CPYTHON_COMPAT - EMIT_ARG(load_attr, MP_QSTR___class__); // get type(exc) - #else - compile_load_id(comp, MP_QSTR_type); - EMIT(rot_two); - EMIT_ARG(call_function, 1, 0, 0); // get type(exc) - #endif - EMIT(rot_two); - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // dummy traceback value - // at this point the stack contains: ..., __aexit__, self, type(exc), exc, None - EMIT_ARG(call_method, 3, 0, 0); - - compile_yield_from(comp); - EMIT_ARG(pop_jump_if, true, no_reraise_label); - EMIT_ARG(raise_varargs, 0); - - EMIT_ARG(label_assign, no_reraise_label); - EMIT(pop_except); - EMIT_ARG(jump, end_label); - - EMIT_ARG(adjust_stack_size, 3); // adjust for __aexit__, self, exc - compile_decrease_except_level(comp); - EMIT(end_finally); - EMIT(end_except_handler); - - EMIT_ARG(label_assign, try_else_label); // start of try-else handler - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT(dup_top); - EMIT(dup_top); - EMIT_ARG(call_method, 3, 0, 0); - compile_yield_from(comp); - EMIT(pop_top); - - EMIT_ARG(label_assign, end_label); - - } -} - -STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit) - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes); - assert(n > 0); - - // compile in a nested fashion - compile_async_with_stmt_helper(comp, n, nodes, pns->nodes[1]); -} - -STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[0])); - mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_funcdef) { - // async def - compile_funcdef(comp, pns0); - scope_t *fscope = (scope_t*)pns0->nodes[4]; - fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_for_stmt) { - // async for - compile_async_for_stmt(comp, pns0); - } else { - // async with - assert(MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_with_stmt); - compile_async_with_stmt(comp, pns0); - } -} -#endif - -STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { - if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) { - // for REPL, evaluate then print the expression - compile_load_id(comp, MP_QSTR___repl_print__); - compile_node(comp, pns->nodes[0]); - EMIT_ARG(call_function, 1, 0, 0); - EMIT(pop_top); - - } else { - // for non-REPL, evaluate then discard the expression - if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0]) && !MP_PARSE_NODE_IS_ID(pns->nodes[0])) - || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_const_object)) { - // do nothing with a lonely constant - } else { - compile_node(comp, pns->nodes[0]); // just an expression - EMIT(pop_top); // discard last result since this is a statement and leaves nothing on the stack - } - } - } else if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - int kind = MP_PARSE_NODE_STRUCT_KIND(pns1); - if (kind == PN_expr_stmt_augassign) { - c_assign(comp, pns->nodes[0], ASSIGN_AUG_LOAD); // lhs load for aug assign - compile_node(comp, pns1->nodes[1]); // rhs - assert(MP_PARSE_NODE_IS_TOKEN(pns1->nodes[0])); - mp_binary_op_t op; - switch (MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0])) { - case MP_TOKEN_DEL_PIPE_EQUAL: op = MP_BINARY_OP_INPLACE_OR; break; - case MP_TOKEN_DEL_CARET_EQUAL: op = MP_BINARY_OP_INPLACE_XOR; break; - case MP_TOKEN_DEL_AMPERSAND_EQUAL: op = MP_BINARY_OP_INPLACE_AND; break; - case MP_TOKEN_DEL_DBL_LESS_EQUAL: op = MP_BINARY_OP_INPLACE_LSHIFT; break; - case MP_TOKEN_DEL_DBL_MORE_EQUAL: op = MP_BINARY_OP_INPLACE_RSHIFT; break; - case MP_TOKEN_DEL_PLUS_EQUAL: op = MP_BINARY_OP_INPLACE_ADD; break; - case MP_TOKEN_DEL_MINUS_EQUAL: op = MP_BINARY_OP_INPLACE_SUBTRACT; break; - case MP_TOKEN_DEL_STAR_EQUAL: op = MP_BINARY_OP_INPLACE_MULTIPLY; break; - case MP_TOKEN_DEL_DBL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_FLOOR_DIVIDE; break; - case MP_TOKEN_DEL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_TRUE_DIVIDE; break; - case MP_TOKEN_DEL_PERCENT_EQUAL: op = MP_BINARY_OP_INPLACE_MODULO; break; - case MP_TOKEN_DEL_DBL_STAR_EQUAL: default: op = MP_BINARY_OP_INPLACE_POWER; break; - } - EMIT_ARG(binary_op, op); - c_assign(comp, pns->nodes[0], ASSIGN_AUG_STORE); // lhs store for aug assign - } else if (kind == PN_expr_stmt_assign_list) { - int rhs = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1) - 1; - compile_node(comp, pns1->nodes[rhs]); // rhs - // following CPython, we store left-most first - if (rhs > 0) { - EMIT(dup_top); - } - c_assign(comp, pns->nodes[0], ASSIGN_STORE); // lhs store - for (int i = 0; i < rhs; i++) { - if (i + 1 < rhs) { - EMIT(dup_top); - } - c_assign(comp, pns1->nodes[i], ASSIGN_STORE); // middle store - } - } else { - plain_assign: - if (MICROPY_COMP_DOUBLE_TUPLE_ASSIGN - && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_testlist_star_expr) - && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_star_expr) - && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[1]) == 2 - && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 2) { - // optimisation for a, b = c, d - mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; - mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr) - || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr)) { - // can't optimise when it's a star expression on the lhs - goto no_optimisation; - } - compile_node(comp, pns10->nodes[0]); // rhs - compile_node(comp, pns10->nodes[1]); // rhs - EMIT(rot_two); - c_assign(comp, pns0->nodes[0], ASSIGN_STORE); // lhs store - c_assign(comp, pns0->nodes[1], ASSIGN_STORE); // lhs store - } else if (MICROPY_COMP_TRIPLE_TUPLE_ASSIGN - && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_testlist_star_expr) - && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_star_expr) - && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[1]) == 3 - && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 3) { - // optimisation for a, b, c = d, e, f - mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns->nodes[1]; - mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr) - || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr) - || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[2], PN_star_expr)) { - // can't optimise when it's a star expression on the lhs - goto no_optimisation; - } - compile_node(comp, pns10->nodes[0]); // rhs - compile_node(comp, pns10->nodes[1]); // rhs - compile_node(comp, pns10->nodes[2]); // rhs - EMIT(rot_three); - EMIT(rot_two); - c_assign(comp, pns0->nodes[0], ASSIGN_STORE); // lhs store - c_assign(comp, pns0->nodes[1], ASSIGN_STORE); // lhs store - c_assign(comp, pns0->nodes[2], ASSIGN_STORE); // lhs store - } else { - no_optimisation: - compile_node(comp, pns->nodes[1]); // rhs - c_assign(comp, pns->nodes[0], ASSIGN_STORE); // lhs store - } - } - } else { - goto plain_assign; - } -} - -STATIC void c_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns, mp_binary_op_t binary_op) { - int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - compile_node(comp, pns->nodes[0]); - for (int i = 1; i < num_nodes; i += 1) { - compile_node(comp, pns->nodes[i]); - EMIT_ARG(binary_op, binary_op); - } -} - -STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else)); - mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns->nodes[1]; - - uint l_fail = comp_next_label(comp); - uint l_end = comp_next_label(comp); - c_if_cond(comp, pns_test_if_else->nodes[0], false, l_fail); // condition - compile_node(comp, pns->nodes[0]); // success value - EMIT_ARG(jump, l_end); - EMIT_ARG(label_assign, l_fail); - EMIT_ARG(adjust_stack_size, -1); // adjust stack size - compile_node(comp, pns_test_if_else->nodes[1]); // failure value - EMIT_ARG(label_assign, l_end); -} - -STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->pass == MP_PASS_SCOPE) { - // create a new scope for this lambda - scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options); - // store the lambda scope so the compiling function (this one) can use it at each pass - pns->nodes[2] = (mp_parse_node_t)s; - } - - // get the scope for this lambda - scope_t *this_scope = (scope_t*)pns->nodes[2]; - - // compile the lambda definition - compile_funcdef_lambdef(comp, this_scope, pns->nodes[0], PN_varargslist); -} - -STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns, bool cond) { - uint l_end = comp_next_label(comp); - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - for (int i = 0; i < n; i += 1) { - compile_node(comp, pns->nodes[i]); - if (i + 1 < n) { - EMIT_ARG(jump_if_or_pop, cond, l_end); - } - } - EMIT_ARG(label_assign, l_end); -} - -STATIC void compile_or_test(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_or_and_test(comp, pns, true); -} - -STATIC void compile_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_or_and_test(comp, pns, false); -} - -STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[0]); - EMIT_ARG(unary_op, MP_UNARY_OP_NOT); -} - -STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) { - int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - compile_node(comp, pns->nodes[0]); - bool multi = (num_nodes > 3); - uint l_fail = 0; - if (multi) { - l_fail = comp_next_label(comp); - } - for (int i = 1; i + 1 < num_nodes; i += 2) { - compile_node(comp, pns->nodes[i + 1]); - if (i + 2 < num_nodes) { - EMIT(dup_top); - EMIT(rot_three); - } - if (MP_PARSE_NODE_IS_TOKEN(pns->nodes[i])) { - mp_binary_op_t op; - switch (MP_PARSE_NODE_LEAF_ARG(pns->nodes[i])) { - case MP_TOKEN_OP_LESS: op = MP_BINARY_OP_LESS; break; - case MP_TOKEN_OP_MORE: op = MP_BINARY_OP_MORE; break; - case MP_TOKEN_OP_DBL_EQUAL: op = MP_BINARY_OP_EQUAL; break; - case MP_TOKEN_OP_LESS_EQUAL: op = MP_BINARY_OP_LESS_EQUAL; break; - case MP_TOKEN_OP_MORE_EQUAL: op = MP_BINARY_OP_MORE_EQUAL; break; - case MP_TOKEN_OP_NOT_EQUAL: op = MP_BINARY_OP_NOT_EQUAL; break; - case MP_TOKEN_KW_IN: default: op = MP_BINARY_OP_IN; break; - } - EMIT_ARG(binary_op, op); - } else { - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[i])); // should be - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[i]; - int kind = MP_PARSE_NODE_STRUCT_KIND(pns2); - if (kind == PN_comp_op_not_in) { - EMIT_ARG(binary_op, MP_BINARY_OP_NOT_IN); - } else { - assert(kind == PN_comp_op_is); // should be - if (MP_PARSE_NODE_IS_NULL(pns2->nodes[0])) { - EMIT_ARG(binary_op, MP_BINARY_OP_IS); - } else { - EMIT_ARG(binary_op, MP_BINARY_OP_IS_NOT); - } - } - } - if (i + 2 < num_nodes) { - EMIT_ARG(jump_if_or_pop, false, l_fail); - } - } - if (multi) { - uint l_end = comp_next_label(comp); - EMIT_ARG(jump, l_end); - EMIT_ARG(label_assign, l_fail); - EMIT_ARG(adjust_stack_size, 1); - EMIT(rot_two); - EMIT(pop_top); - EMIT_ARG(label_assign, l_end); - } -} - -STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "*x must be assignment target"); -} - -STATIC void compile_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - c_binary_op(comp, pns, MP_BINARY_OP_OR); -} - -STATIC void compile_xor_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - c_binary_op(comp, pns, MP_BINARY_OP_XOR); -} - -STATIC void compile_and_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - c_binary_op(comp, pns, MP_BINARY_OP_AND); -} - -STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) { - int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - compile_node(comp, pns->nodes[0]); - for (int i = 1; i + 1 < num_nodes; i += 2) { - compile_node(comp, pns->nodes[i + 1]); - mp_binary_op_t op; - mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[i]); - switch (tok) { - case MP_TOKEN_OP_PLUS: op = MP_BINARY_OP_ADD; break; - case MP_TOKEN_OP_MINUS: op = MP_BINARY_OP_SUBTRACT; break; - case MP_TOKEN_OP_STAR: op = MP_BINARY_OP_MULTIPLY; break; - case MP_TOKEN_OP_DBL_SLASH: op = MP_BINARY_OP_FLOOR_DIVIDE; break; - case MP_TOKEN_OP_SLASH: op = MP_BINARY_OP_TRUE_DIVIDE; break; - case MP_TOKEN_OP_PERCENT: op = MP_BINARY_OP_MODULO; break; - case MP_TOKEN_OP_DBL_LESS: op = MP_BINARY_OP_LSHIFT; break; - default: - assert(tok == MP_TOKEN_OP_DBL_MORE); - op = MP_BINARY_OP_RSHIFT; - break; - } - EMIT_ARG(binary_op, op); - } -} - -STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[1]); - mp_unary_op_t op; - mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - switch (tok) { - case MP_TOKEN_OP_PLUS: op = MP_UNARY_OP_POSITIVE; break; - case MP_TOKEN_OP_MINUS: op = MP_UNARY_OP_NEGATIVE; break; - default: - assert(tok == MP_TOKEN_OP_TILDE); - op = MP_UNARY_OP_INVERT; - break; - } - EMIT_ARG(unary_op, op); -} - -STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) { - // compile the subject of the expression - compile_node(comp, pns->nodes[0]); - - // compile_atom_expr_await may call us with a NULL node - if (MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { - return; - } - - // get the array of trailers (known to be an array of PARSE_NODE_STRUCT) - size_t num_trail = 1; - mp_parse_node_struct_t **pns_trail = (mp_parse_node_struct_t**)&pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_atom_expr_trailers) { - num_trail = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_trail[0]); - pns_trail = (mp_parse_node_struct_t**)&pns_trail[0]->nodes[0]; - } - - // the current index into the array of trailers - size_t i = 0; - - // handle special super() call - if (comp->scope_cur->kind == SCOPE_FUNCTION - && MP_PARSE_NODE_IS_ID(pns->nodes[0]) - && MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]) == MP_QSTR_super - && MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_trailer_paren - && MP_PARSE_NODE_IS_NULL(pns_trail[0]->nodes[0])) { - // at this point we have matched "super()" within a function - - // load the class for super to search for a parent - compile_load_id(comp, MP_QSTR___class__); - - // look for first argument to function (assumes it's "self") - bool found = false; - id_info_t *id = &comp->scope_cur->id_info[0]; - for (size_t n = comp->scope_cur->id_info_len; n > 0; --n, ++id) { - if (id->flags & ID_FLAG_IS_PARAM) { - // first argument found; load it - compile_load_id(comp, id->qst); - found = true; - break; - } - } - if (!found) { - compile_syntax_error(comp, (mp_parse_node_t)pns_trail[0], - "super() can't find self"); // really a TypeError - return; - } - - if (num_trail >= 3 - && MP_PARSE_NODE_STRUCT_KIND(pns_trail[1]) == PN_trailer_period - && MP_PARSE_NODE_STRUCT_KIND(pns_trail[2]) == PN_trailer_paren) { - // optimisation for method calls super().f(...), to eliminate heap allocation - mp_parse_node_struct_t *pns_period = pns_trail[1]; - mp_parse_node_struct_t *pns_paren = pns_trail[2]; - EMIT_ARG(load_method, MP_PARSE_NODE_LEAF_ARG(pns_period->nodes[0]), true); - compile_trailer_paren_helper(comp, pns_paren->nodes[0], true, 0); - i = 3; - } else { - // a super() call - EMIT_ARG(call_function, 2, 0, 0); - i = 1; - } - } - - // compile the remaining trailers - for (; i < num_trail; i++) { - if (i + 1 < num_trail - && MP_PARSE_NODE_STRUCT_KIND(pns_trail[i]) == PN_trailer_period - && MP_PARSE_NODE_STRUCT_KIND(pns_trail[i + 1]) == PN_trailer_paren) { - // optimisation for method calls a.f(...), following PyPy - mp_parse_node_struct_t *pns_period = pns_trail[i]; - mp_parse_node_struct_t *pns_paren = pns_trail[i + 1]; - EMIT_ARG(load_method, MP_PARSE_NODE_LEAF_ARG(pns_period->nodes[0]), false); - compile_trailer_paren_helper(comp, pns_paren->nodes[0], true, 0); - i += 1; - } else { - // node is one of: trailer_paren, trailer_bracket, trailer_period - compile_node(comp, (mp_parse_node_t)pns_trail[i]); - } - } -} - -STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_generic_all_nodes(comp, pns); // 2 nodes, arguments of power - EMIT_ARG(binary_op, MP_BINARY_OP_POWER); -} - -STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) { - // function to call is on top of stack - - // get the list of arguments - mp_parse_node_t *args; - int n_args = mp_parse_node_extract_list(&pn_arglist, PN_arglist, &args); - - // compile the arguments - // Rather than calling compile_node on the list, we go through the list of args - // explicitly here so that we can count the number of arguments and give sensible - // error messages. - int n_positional = n_positional_extra; - uint n_keyword = 0; - uint star_flags = 0; - mp_parse_node_struct_t *star_args_node = NULL, *dblstar_args_node = NULL; - for (int i = 0; i < n_args; i++) { - if (MP_PARSE_NODE_IS_STRUCT(args[i])) { - mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t*)args[i]; - if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_star) { - if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) { - compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple *x"); - return; - } - star_flags |= MP_EMIT_STAR_FLAG_SINGLE; - star_args_node = pns_arg; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_dbl_star) { - if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) { - compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple **x"); - return; - } - star_flags |= MP_EMIT_STAR_FLAG_DOUBLE; - dblstar_args_node = pns_arg; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_argument) { - if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns_arg->nodes[1], PN_comp_for)) { - if (!MP_PARSE_NODE_IS_ID(pns_arg->nodes[0])) { - compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id"); - return; - } - EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0])); - compile_node(comp, pns_arg->nodes[1]); - n_keyword += 1; - } else { - compile_comprehension(comp, pns_arg, SCOPE_GEN_EXPR); - n_positional++; - } - } else { - goto normal_argument; - } - } else { - normal_argument: - if (star_flags) { - compile_syntax_error(comp, args[i], "non-keyword arg after */**"); - return; - } - if (n_keyword > 0) { - compile_syntax_error(comp, args[i], "non-keyword arg after keyword arg"); - return; - } - compile_node(comp, args[i]); - n_positional++; - } - } - - // compile the star/double-star arguments if we had them - // if we had one but not the other then we load "null" as a place holder - if (star_flags != 0) { - if (star_args_node == NULL) { - EMIT(load_null); - } else { - compile_node(comp, star_args_node->nodes[0]); - } - if (dblstar_args_node == NULL) { - EMIT(load_null); - } else { - compile_node(comp, dblstar_args_node->nodes[0]); - } - } - - // emit the function/method call - if (is_method_call) { - EMIT_ARG(call_method, n_positional, n_keyword, star_flags); - } else { - EMIT_ARG(call_function, n_positional, n_keyword, star_flags); - } -} - -// pns needs to have 2 nodes, first is lhs of comprehension, second is PN_comp_for node -STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) { - assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2); - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)); - mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; - - if (comp->pass == MP_PASS_SCOPE) { - // create a new scope for this comprehension - scope_t *s = scope_new_and_link(comp, kind, (mp_parse_node_t)pns, comp->scope_cur->emit_options); - // store the comprehension scope so the compiling function (this one) can use it at each pass - pns_comp_for->nodes[3] = (mp_parse_node_t)s; - } - - // get the scope for this comprehension - scope_t *this_scope = (scope_t*)pns_comp_for->nodes[3]; - - // compile the comprehension - close_over_variables_etc(comp, this_scope, 0, 0); - - compile_node(comp, pns_comp_for->nodes[1]); // source of the iterator - if (kind == SCOPE_GEN_EXPR) { - EMIT_ARG(get_iter, false); - } - EMIT_ARG(call_function, 1, 0, 0); -} - -STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // an empty tuple - c_tuple(comp, MP_PARSE_NODE_NULL, NULL); - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - assert(!MP_PARSE_NODE_IS_NULL(pns->nodes[1])); - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { - // tuple of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); - c_tuple(comp, pns->nodes[0], NULL); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { - // tuple of many items - c_tuple(comp, pns->nodes[0], pns2); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { - // generator expression - compile_comprehension(comp, pns, SCOPE_GEN_EXPR); - } else { - // tuple with 2 items - goto tuple_with_2_items; - } - } else { - // tuple with 2 items - tuple_with_2_items: - c_tuple(comp, MP_PARSE_NODE_NULL, pns); - } - } -} - -STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // empty list - EMIT_ARG(build_list, 0); - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[0]; - if (MP_PARSE_NODE_IS_STRUCT(pns2->nodes[1])) { - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns2->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3b) { - // list of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns3->nodes[0])); - compile_node(comp, pns2->nodes[0]); - EMIT_ARG(build_list, 1); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3c) { - // list of many items - compile_node(comp, pns2->nodes[0]); - compile_generic_all_nodes(comp, pns3); - EMIT_ARG(build_list, 1 + MP_PARSE_NODE_STRUCT_NUM_NODES(pns3)); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_comp_for) { - // list comprehension - compile_comprehension(comp, pns2, SCOPE_LIST_COMP); - } else { - // list with 2 items - goto list_with_2_items; - } - } else { - // list with 2 items - list_with_2_items: - compile_node(comp, pns2->nodes[0]); - compile_node(comp, pns2->nodes[1]); - EMIT_ARG(build_list, 2); - } - } else { - // list with 1 item - compile_node(comp, pns->nodes[0]); - EMIT_ARG(build_list, 1); - } -} - -STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) { - mp_parse_node_t pn = pns->nodes[0]; - if (MP_PARSE_NODE_IS_NULL(pn)) { - // empty dict - EMIT_ARG(build_map, 0); - } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { - pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker_item) { - // dict with one element - EMIT_ARG(build_map, 1); - compile_node(comp, pn); - EMIT(store_map); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker) { - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should succeed - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_dictorsetmaker_list) { - // dict/set with multiple elements - - // get tail elements (2nd, 3rd, ...) - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns1->nodes[0], PN_dictorsetmaker_list2, &nodes); - - // first element sets whether it's a dict or set - bool is_dict; - if (!MICROPY_PY_BUILTINS_SET || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_dictorsetmaker_item)) { - // a dictionary - EMIT_ARG(build_map, 1 + n); - compile_node(comp, pns->nodes[0]); - EMIT(store_map); - is_dict = true; - } else { - // a set - compile_node(comp, pns->nodes[0]); // 1st value of set - is_dict = false; - } - - // process rest of elements - for (int i = 0; i < n; i++) { - mp_parse_node_t pn_i = nodes[i]; - bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND(pn_i, PN_dictorsetmaker_item); - compile_node(comp, pn_i); - if (is_dict) { - if (!is_key_value) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); - } else { - compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict"); - } - return; - } - EMIT(store_map); - } else { - if (is_key_value) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax"); - } else { - compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set"); - } - return; - } - } - } - - #if MICROPY_PY_BUILTINS_SET - // if it's a set, build it - if (!is_dict) { - EMIT_ARG(build_set, 1 + n); - } - #endif - } else { - assert(MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for); // should be - // dict/set comprehension - if (!MICROPY_PY_BUILTINS_SET || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_dictorsetmaker_item)) { - // a dictionary comprehension - compile_comprehension(comp, pns, SCOPE_DICT_COMP); - } else { - // a set comprehension - compile_comprehension(comp, pns, SCOPE_SET_COMP); - } - } - } else { - // set with one element - goto set_with_one_element; - } - } else { - // set with one element - set_with_one_element: - #if MICROPY_PY_BUILTINS_SET - compile_node(comp, pn); - EMIT_ARG(build_set, 1); - #else - assert(0); - #endif - } -} - -STATIC void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_trailer_paren_helper(comp, pns->nodes[0], false, 0); -} - -STATIC void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) { - // object who's index we want is on top of stack - compile_node(comp, pns->nodes[0]); // the index - EMIT(load_subscr); -} - -STATIC void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) { - // object who's attribute we want is on top of stack - EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // attribute to get -} - -#if MICROPY_PY_BUILTINS_SLICE -STATIC void compile_subscript_3_helper(compiler_t *comp, mp_parse_node_struct_t *pns) { - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3); // should always be - mp_parse_node_t pn = pns->nodes[0]; - if (MP_PARSE_NODE_IS_NULL(pn)) { - // [?:] - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT_ARG(build_slice, 2); - } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { - pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3c) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - pn = pns->nodes[0]; - if (MP_PARSE_NODE_IS_NULL(pn)) { - // [?::] - EMIT_ARG(build_slice, 2); - } else { - // [?::x] - compile_node(comp, pn); - EMIT_ARG(build_slice, 3); - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3d) { - compile_node(comp, pns->nodes[0]); - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be - pns = (mp_parse_node_struct_t*)pns->nodes[1]; - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_sliceop); // should always be - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // [?:x:] - EMIT_ARG(build_slice, 2); - } else { - // [?:x:x] - compile_node(comp, pns->nodes[0]); - EMIT_ARG(build_slice, 3); - } - } else { - // [?:x] - compile_node(comp, pn); - EMIT_ARG(build_slice, 2); - } - } else { - // [?:x] - compile_node(comp, pn); - EMIT_ARG(build_slice, 2); - } -} - -STATIC void compile_subscript_2(compiler_t *comp, mp_parse_node_struct_t *pns) { - compile_node(comp, pns->nodes[0]); // start of slice - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be - compile_subscript_3_helper(comp, (mp_parse_node_struct_t*)pns->nodes[1]); -} - -STATIC void compile_subscript_3(compiler_t *comp, mp_parse_node_struct_t *pns) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - compile_subscript_3_helper(comp, pns); -} -#endif // MICROPY_PY_BUILTINS_SLICE - -STATIC void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) { - // if this is called then we are compiling a dict key:value pair - compile_node(comp, pns->nodes[1]); // value - compile_node(comp, pns->nodes[0]); // key -} - -STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) { - qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options); - // store class object into class name - compile_store_id(comp, cname); -} - -STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'yield' outside function"); - return; - } - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT(yield_value); - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_yield_arg_from)) { - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - compile_node(comp, pns->nodes[0]); - compile_yield_from(comp); - } else { - compile_node(comp, pns->nodes[0]); - EMIT(yield_value); - } -} - -#if MICROPY_PY_ASYNC_AWAIT -STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) { - if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) { - compile_syntax_error(comp, (mp_parse_node_t)pns, "'await' outside function"); - return; - } - compile_atom_expr_normal(comp, pns); - compile_yield_from(comp); -} -#endif - -STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) { - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - // nodes are 32-bit pointers, but need to extract 64-bit object - return (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32); - #else - return (mp_obj_t)pns->nodes[0]; - #endif -} - -STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) { - EMIT_ARG(load_const_obj, get_const_object(pns)); -} - -typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*); -STATIC const compile_function_t compile_function[] = { -// only define rules with a compile function -#define c(f) compile_##f -#define DEF_RULE(rule, comp, kind, ...) comp, -#define DEF_RULE_NC(rule, kind, ...) -#include "py/grammar.h" -#undef c -#undef DEF_RULE -#undef DEF_RULE_NC - compile_const_object, -}; - -STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) { - if (MP_PARSE_NODE_IS_NULL(pn)) { - // pass - } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) { - mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn); - #if MICROPY_DYNAMIC_COMPILER - mp_uint_t sign_mask = -(1 << (mp_dynamic_compiler.small_int_bits - 1)); - if ((arg & sign_mask) == 0 || (arg & sign_mask) == sign_mask) { - // integer fits in target runtime's small-int - EMIT_ARG(load_const_small_int, arg); - } else { - // integer doesn't fit, so create a multi-precision int object - // (but only create the actual object on the last pass) - if (comp->pass != MP_PASS_EMIT) { - EMIT_ARG(load_const_obj, mp_const_none); - } else { - EMIT_ARG(load_const_obj, mp_obj_new_int_from_ll(arg)); - } - } - #else - EMIT_ARG(load_const_small_int, arg); - #endif - } else if (MP_PARSE_NODE_IS_LEAF(pn)) { - uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn); - switch (MP_PARSE_NODE_LEAF_KIND(pn)) { - case MP_PARSE_NODE_ID: compile_load_id(comp, arg); break; - case MP_PARSE_NODE_STRING: EMIT_ARG(load_const_str, arg); break; - case MP_PARSE_NODE_BYTES: - // only create and load the actual bytes object on the last pass - if (comp->pass != MP_PASS_EMIT) { - EMIT_ARG(load_const_obj, mp_const_none); - } else { - size_t len; - const byte *data = qstr_data(arg, &len); - EMIT_ARG(load_const_obj, mp_obj_new_bytes(data, len)); - } - break; - case MP_PARSE_NODE_TOKEN: default: - if (arg == MP_TOKEN_NEWLINE) { - // this can occur when file_input lets through a NEWLINE (eg if file starts with a newline) - // or when single_input lets through a NEWLINE (user enters a blank line) - // do nothing - } else { - EMIT_ARG(load_const_tok, arg); - } - break; - } - } else { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - EMIT_ARG(set_source_line, pns->source_line); - assert(MP_PARSE_NODE_STRUCT_KIND(pns) <= PN_const_object); - compile_function_t f = compile_function[MP_PARSE_NODE_STRUCT_KIND(pns)]; - f(comp, pns); - } -} - -STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) { - // check that **kw is last - if ((comp->scope_cur->scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) { - compile_syntax_error(comp, pn, "invalid syntax"); - return; - } - - qstr param_name = MP_QSTR_NULL; - uint param_flag = ID_FLAG_IS_PARAM; - if (MP_PARSE_NODE_IS_ID(pn)) { - param_name = MP_PARSE_NODE_LEAF_ARG(pn); - if (comp->have_star) { - // comes after a star, so counts as a keyword-only parameter - comp->scope_cur->num_kwonly_args += 1; - } else { - // comes before a star, so counts as a positional parameter - comp->scope_cur->num_pos_args += 1; - } - } else { - assert(MP_PARSE_NODE_IS_STRUCT(pn)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_STRUCT_KIND(pns) == pn_name) { - param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - if (comp->have_star) { - // comes after a star, so counts as a keyword-only parameter - comp->scope_cur->num_kwonly_args += 1; - } else { - // comes before a star, so counts as a positional parameter - comp->scope_cur->num_pos_args += 1; - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == pn_star) { - if (comp->have_star) { - // more than one star - compile_syntax_error(comp, pn, "invalid syntax"); - return; - } - comp->have_star = true; - param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_STAR_PARAM; - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // bare star - // TODO see http://www.python.org/dev/peps/pep-3102/ - //assert(comp->scope_cur->num_dict_params == 0); - } else if (MP_PARSE_NODE_IS_ID(pns->nodes[0])) { - // named star - comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARARGS; - param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)); // should be - // named star with possible annotation - comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARARGS; - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - } - } else { - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == pn_dbl_star); // should be - param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - param_flag = ID_FLAG_IS_PARAM | ID_FLAG_IS_DBL_STAR_PARAM; - comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARKEYWORDS; - } - } - - if (param_name != MP_QSTR_NULL) { - bool added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, param_name, &added); - if (!added) { - compile_syntax_error(comp, pn, "name reused for argument"); - return; - } - id_info->kind = ID_INFO_KIND_LOCAL; - id_info->flags = param_flag; - } -} - -STATIC void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) { - compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star); -} - -STATIC void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) { - compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star); -} - -#if MICROPY_EMIT_NATIVE -STATIC void compile_scope_func_annotations(compiler_t *comp, mp_parse_node_t pn) { - if (!MP_PARSE_NODE_IS_STRUCT(pn)) { - // no annotation - return; - } - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_typedargslist_name) { - // named parameter with possible annotation - // fallthrough - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_typedargslist_star) { - if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)) { - // named star with possible annotation - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - // fallthrough - } else { - // no annotation - return; - } - } else { - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_typedargslist_dbl_star); - // double star with possible annotation - // fallthrough - } - - mp_parse_node_t pn_annotation = pns->nodes[1]; - - if (!MP_PARSE_NODE_IS_NULL(pn_annotation)) { - qstr param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); - id_info_t *id_info = scope_find(comp->scope_cur, param_name); - assert(id_info != NULL); - - if (MP_PARSE_NODE_IS_ID(pn_annotation)) { - qstr arg_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); - EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_ARG, id_info->local_num, arg_type); - } else { - compile_syntax_error(comp, pn_annotation, "parameter annotation must be an identifier"); - } - } -} -#endif // MICROPY_EMIT_NATIVE - -STATIC void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) { - uint l_top = comp_next_label(comp); - uint l_end = comp_next_label(comp); - EMIT_ARG(label_assign, l_top); - EMIT_ARG(for_iter, l_end); - c_assign(comp, pns_comp_for->nodes[0], ASSIGN_STORE); - mp_parse_node_t pn_iter = pns_comp_for->nodes[2]; - - tail_recursion: - if (MP_PARSE_NODE_IS_NULL(pn_iter)) { - // no more nested if/for; compile inner expression - compile_node(comp, pn_inner_expr); - if (comp->scope_cur->kind == SCOPE_GEN_EXPR) { - EMIT(yield_value); - EMIT(pop_top); - } else { - EMIT_ARG(store_comp, comp->scope_cur->kind, 4 * for_depth + 5); - } - } else if (MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_if) { - // if condition - mp_parse_node_struct_t *pns_comp_if = (mp_parse_node_struct_t*)pn_iter; - c_if_cond(comp, pns_comp_if->nodes[0], false, l_top); - pn_iter = pns_comp_if->nodes[1]; - goto tail_recursion; - } else { - assert(MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_for); // should be - // for loop - mp_parse_node_struct_t *pns_comp_for2 = (mp_parse_node_struct_t*)pn_iter; - compile_node(comp, pns_comp_for2->nodes[1]); - EMIT_ARG(get_iter, true); - compile_scope_comp_iter(comp, pns_comp_for2, pn_inner_expr, for_depth + 1); - } - - EMIT_ARG(jump, l_top); - EMIT_ARG(label_assign, l_end); - EMIT(for_iter_end); -} - -STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) { -#if MICROPY_ENABLE_DOC_STRING - // see http://www.python.org/dev/peps/pep-0257/ - - // look for the first statement - if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) { - // a statement; fall through - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_file_input_2)) { - // file input; find the first non-newline node - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - for (int i = 0; i < num_nodes; i++) { - pn = pns->nodes[i]; - if (!(MP_PARSE_NODE_IS_LEAF(pn) && MP_PARSE_NODE_LEAF_KIND(pn) == MP_PARSE_NODE_TOKEN && MP_PARSE_NODE_LEAF_ARG(pn) == MP_TOKEN_NEWLINE)) { - // not a newline, so this is the first statement; finish search - break; - } - } - // if we didn't find a non-newline then it's okay to fall through; pn will be a newline and so doc-string test below will fail gracefully - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_suite_block_stmts)) { - // a list of statements; get the first one - pn = ((mp_parse_node_struct_t*)pn)->nodes[0]; - } else { - return; - } - - // check the first statement for a doc string - if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0]) - && MP_PARSE_NODE_LEAF_KIND(pns->nodes[0]) == MP_PARSE_NODE_STRING) - || (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_const_object) - && MP_OBJ_IS_STR(get_const_object((mp_parse_node_struct_t*)pns->nodes[0])))) { - // compile the doc string - compile_node(comp, pns->nodes[0]); - // store the doc string - compile_store_id(comp, MP_QSTR___doc__); - } - } -#else - (void)comp; - (void)pn; -#endif -} - -STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { - comp->pass = pass; - comp->scope_cur = scope; - comp->next_label = 0; - EMIT_ARG(start_pass, pass, scope); - - if (comp->pass == MP_PASS_SCOPE) { - // reset maximum stack sizes in scope - // they will be computed in this first pass - scope->stack_size = 0; - scope->exc_stack_size = 0; - } - - // compile - if (MP_PARSE_NODE_IS_STRUCT_KIND(scope->pn, PN_eval_input)) { - assert(scope->kind == SCOPE_MODULE); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - compile_node(comp, pns->nodes[0]); // compile the expression - EMIT(return_value); - } else if (scope->kind == SCOPE_MODULE) { - if (!comp->is_repl) { - check_for_doc_string(comp, scope->pn); - } - compile_node(comp, scope->pn); - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT(return_value); - } else if (scope->kind == SCOPE_FUNCTION) { - assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef); - - // work out number of parameters, keywords and default parameters, and add them to the id_info array - // must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc) - if (comp->pass == MP_PASS_SCOPE) { - comp->have_star = false; - apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param); - } - #if MICROPY_EMIT_NATIVE - else if (scope->emit_options == MP_EMIT_OPT_VIPER) { - // compile annotations; only needed on latter compiler passes - // only needed for viper emitter - - // argument annotations - apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_annotations); - - // pns->nodes[2] is return/whole function annotation - mp_parse_node_t pn_annotation = pns->nodes[2]; - if (!MP_PARSE_NODE_IS_NULL(pn_annotation)) { - // nodes[2] can be null or a test-expr - if (MP_PARSE_NODE_IS_ID(pn_annotation)) { - qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); - EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_RETURN, 0, ret_type); - } else { - compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier"); - } - } - } - #endif // MICROPY_EMIT_NATIVE - - compile_node(comp, pns->nodes[3]); // 3 is function body - // emit return if it wasn't the last opcode - if (!EMIT(last_emit_was_return_value)) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - EMIT(return_value); - } - } else if (scope->kind == SCOPE_LAMBDA) { - assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3); - - // work out number of parameters, keywords and default parameters, and add them to the id_info array - // must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc) - if (comp->pass == MP_PASS_SCOPE) { - comp->have_star = false; - apply_to_single_or_list(comp, pns->nodes[0], PN_varargslist, compile_scope_lambda_param); - } - - compile_node(comp, pns->nodes[1]); // 1 is lambda body - - // if the lambda is a generator, then we return None, not the result of the expression of the lambda - if (scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) { - EMIT(pop_top); - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - } - EMIT(return_value); - } else if (scope->kind == SCOPE_LIST_COMP || scope->kind == SCOPE_DICT_COMP || scope->kind == SCOPE_SET_COMP || scope->kind == SCOPE_GEN_EXPR) { - // a bit of a hack at the moment - - assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2); - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)); - mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1]; - - // We need a unique name for the comprehension argument (the iterator). - // CPython uses .0, but we should be able to use anything that won't - // clash with a user defined variable. Best to use an existing qstr, - // so we use the blank qstr. - qstr qstr_arg = MP_QSTR_; - if (comp->pass == MP_PASS_SCOPE) { - bool added; - id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qstr_arg, &added); - assert(added); - id_info->kind = ID_INFO_KIND_LOCAL; - scope->num_pos_args = 1; - } - - if (scope->kind == SCOPE_LIST_COMP) { - EMIT_ARG(build_list, 0); - } else if (scope->kind == SCOPE_DICT_COMP) { - EMIT_ARG(build_map, 0); - #if MICROPY_PY_BUILTINS_SET - } else if (scope->kind == SCOPE_SET_COMP) { - EMIT_ARG(build_set, 0); - #endif - } - - // There are 4 slots on the stack for the iterator, and the first one is - // NULL to indicate that the second one points to the iterator object. - if (scope->kind == SCOPE_GEN_EXPR) { - // TODO static assert that MP_OBJ_ITER_BUF_NSLOTS == 4 - EMIT(load_null); - compile_load_id(comp, qstr_arg); - EMIT(load_null); - EMIT(load_null); - } else { - compile_load_id(comp, qstr_arg); - EMIT_ARG(get_iter, true); - } - - compile_scope_comp_iter(comp, pns_comp_for, pns->nodes[0], 0); - - if (scope->kind == SCOPE_GEN_EXPR) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - } - EMIT(return_value); - } else { - assert(scope->kind == SCOPE_CLASS); - assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_classdef); - - if (comp->pass == MP_PASS_SCOPE) { - bool added; - id_info_t *id_info = scope_find_or_add_id(scope, MP_QSTR___class__, &added); - assert(added); - id_info->kind = ID_INFO_KIND_LOCAL; - } - - compile_load_id(comp, MP_QSTR___name__); - compile_store_id(comp, MP_QSTR___module__); - EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // 0 is class name - compile_store_id(comp, MP_QSTR___qualname__); - - check_for_doc_string(comp, pns->nodes[2]); - compile_node(comp, pns->nodes[2]); // 2 is class body - - id_info_t *id = scope_find(scope, MP_QSTR___class__); - assert(id != NULL); - if (id->kind == ID_INFO_KIND_LOCAL) { - EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); - } else { - EMIT_LOAD_FAST(MP_QSTR___class__, id->local_num); - } - EMIT(return_value); - } - - EMIT(end_pass); - - // make sure we match all the exception levels - assert(comp->cur_except_level == 0); -} - -#if MICROPY_EMIT_INLINE_ASM -// requires 3 passes: SCOPE, CODE_SIZE, EMIT -STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) { - comp->pass = pass; - comp->scope_cur = scope; - comp->next_label = 0; - - if (scope->kind != SCOPE_FUNCTION) { - compile_syntax_error(comp, MP_PARSE_NODE_NULL, "inline assembler must be a function"); - return; - } - - if (comp->pass > MP_PASS_SCOPE) { - EMIT_INLINE_ASM_ARG(start_pass, comp->pass, &comp->compile_error); - } - - // get the function definition parse node - assert(MP_PARSE_NODE_IS_STRUCT(scope->pn)); - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn; - assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef); - - //qstr f_id = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); // function name - - // parameters are in pns->nodes[1] - if (comp->pass == MP_PASS_CODE_SIZE) { - mp_parse_node_t *pn_params; - int n_params = mp_parse_node_extract_list(&pns->nodes[1], PN_typedargslist, &pn_params); - scope->num_pos_args = EMIT_INLINE_ASM_ARG(count_params, n_params, pn_params); - if (comp->compile_error != MP_OBJ_NULL) { - goto inline_asm_error; - } - } - - // pns->nodes[2] is function return annotation - mp_uint_t type_sig = MP_NATIVE_TYPE_INT; - mp_parse_node_t pn_annotation = pns->nodes[2]; - if (!MP_PARSE_NODE_IS_NULL(pn_annotation)) { - // nodes[2] can be null or a test-expr - if (MP_PARSE_NODE_IS_ID(pn_annotation)) { - qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); - switch (ret_type) { - case MP_QSTR_object: type_sig = MP_NATIVE_TYPE_OBJ; break; - case MP_QSTR_bool: type_sig = MP_NATIVE_TYPE_BOOL; break; - case MP_QSTR_int: type_sig = MP_NATIVE_TYPE_INT; break; - case MP_QSTR_uint: type_sig = MP_NATIVE_TYPE_UINT; break; - default: compile_syntax_error(comp, pn_annotation, "unknown type"); return; - } - } else { - compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier"); - } - } - - mp_parse_node_t pn_body = pns->nodes[3]; // body - mp_parse_node_t *nodes; - int num = mp_parse_node_extract_list(&pn_body, PN_suite_block_stmts, &nodes); - - for (int i = 0; i < num; i++) { - assert(MP_PARSE_NODE_IS_STRUCT(nodes[i])); - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)nodes[i]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_pass_stmt) { - // no instructions - continue; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) != PN_expr_stmt) { - // not an instruction; error - not_an_instruction: - compile_syntax_error(comp, nodes[i], "expecting an assembler instruction"); - return; - } - - // check structure of parse node - assert(MP_PARSE_NODE_IS_STRUCT(pns2->nodes[0])); - if (!MP_PARSE_NODE_IS_NULL(pns2->nodes[1])) { - goto not_an_instruction; - } - pns2 = (mp_parse_node_struct_t*)pns2->nodes[0]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) != PN_atom_expr_normal) { - goto not_an_instruction; - } - if (!MP_PARSE_NODE_IS_ID(pns2->nodes[0])) { - goto not_an_instruction; - } - if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns2->nodes[1], PN_trailer_paren)) { - goto not_an_instruction; - } - - // parse node looks like an instruction - // get instruction name and args - qstr op = MP_PARSE_NODE_LEAF_ARG(pns2->nodes[0]); - pns2 = (mp_parse_node_struct_t*)pns2->nodes[1]; // PN_trailer_paren - mp_parse_node_t *pn_arg; - int n_args = mp_parse_node_extract_list(&pns2->nodes[0], PN_arglist, &pn_arg); - - // emit instructions - if (op == MP_QSTR_label) { - if (!(n_args == 1 && MP_PARSE_NODE_IS_ID(pn_arg[0]))) { - compile_syntax_error(comp, nodes[i], "'label' requires 1 argument"); - return; - } - uint lab = comp_next_label(comp); - if (pass > MP_PASS_SCOPE) { - if (!EMIT_INLINE_ASM_ARG(label, lab, MP_PARSE_NODE_LEAF_ARG(pn_arg[0]))) { - compile_syntax_error(comp, nodes[i], "label redefined"); - return; - } - } - } else if (op == MP_QSTR_align) { - if (!(n_args == 1 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) { - compile_syntax_error(comp, nodes[i], "'align' requires 1 argument"); - return; - } - if (pass > MP_PASS_SCOPE) { - mp_asm_base_align((mp_asm_base_t*)comp->emit_inline_asm, - MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0])); - } - } else if (op == MP_QSTR_data) { - if (!(n_args >= 2 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) { - compile_syntax_error(comp, nodes[i], "'data' requires at least 2 arguments"); - return; - } - if (pass > MP_PASS_SCOPE) { - mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]); - for (uint j = 1; j < n_args; j++) { - if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) { - compile_syntax_error(comp, nodes[i], "'data' requires integer arguments"); - return; - } - mp_asm_base_data((mp_asm_base_t*)comp->emit_inline_asm, - bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j])); - } - } - } else { - if (pass > MP_PASS_SCOPE) { - EMIT_INLINE_ASM_ARG(op, op, n_args, pn_arg); - } - } - - if (comp->compile_error != MP_OBJ_NULL) { - pns = pns2; // this is the parse node that had the error - goto inline_asm_error; - } - } - - if (comp->pass > MP_PASS_SCOPE) { - EMIT_INLINE_ASM_ARG(end_pass, type_sig); - - if (comp->pass == MP_PASS_EMIT) { - void *f = mp_asm_base_get_code((mp_asm_base_t*)comp->emit_inline_asm); - mp_emit_glue_assign_native(comp->scope_cur->raw_code, MP_CODE_NATIVE_ASM, - f, mp_asm_base_get_code_size((mp_asm_base_t*)comp->emit_inline_asm), - NULL, comp->scope_cur->num_pos_args, 0, type_sig); - } - } - - if (comp->compile_error != MP_OBJ_NULL) { - // inline assembler had an error; set line for its exception - inline_asm_error: - comp->compile_error_line = pns->source_line; - } -} -#endif - -STATIC void scope_compute_things(scope_t *scope) { - // in MicroPython we put the *x parameter after all other parameters (except **y) - if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) { - id_info_t *id_param = NULL; - for (int i = scope->id_info_len - 1; i >= 0; i--) { - id_info_t *id = &scope->id_info[i]; - if (id->flags & ID_FLAG_IS_STAR_PARAM) { - if (id_param != NULL) { - // swap star param with last param - id_info_t temp = *id_param; *id_param = *id; *id = temp; - } - break; - } else if (id_param == NULL && id->flags == ID_FLAG_IS_PARAM) { - id_param = id; - } - } - } - - // in functions, turn implicit globals into explicit globals - // compute the index of each local - scope->num_locals = 0; - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (scope->kind == SCOPE_CLASS && id->qst == MP_QSTR___class__) { - // __class__ is not counted as a local; if it's used then it becomes a ID_INFO_KIND_CELL - continue; - } - if (SCOPE_IS_FUNC_LIKE(scope->kind) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT; - } - // params always count for 1 local, even if they are a cell - if (id->kind == ID_INFO_KIND_LOCAL || (id->flags & ID_FLAG_IS_PARAM)) { - id->local_num = scope->num_locals++; - } - } - - // compute the index of cell vars - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - // in MicroPython the cells come right after the fast locals - // parameters are not counted here, since they remain at the start - // of the locals, even if they are cell vars - if (id->kind == ID_INFO_KIND_CELL && !(id->flags & ID_FLAG_IS_PARAM)) { - id->local_num = scope->num_locals; - scope->num_locals += 1; - } - } - - // compute the index of free vars - // make sure they are in the order of the parent scope - if (scope->parent != NULL) { - int num_free = 0; - for (int i = 0; i < scope->parent->id_info_len; i++) { - id_info_t *id = &scope->parent->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE) { - for (int j = 0; j < scope->id_info_len; j++) { - id_info_t *id2 = &scope->id_info[j]; - if (id2->kind == ID_INFO_KIND_FREE && id->qst == id2->qst) { - assert(!(id2->flags & ID_FLAG_IS_PARAM)); // free vars should not be params - // in MicroPython the frees come first, before the params - id2->local_num = num_free; - num_free += 1; - } - } - } - } - // in MicroPython shift all other locals after the free locals - if (num_free > 0) { - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (id->kind != ID_INFO_KIND_FREE || (id->flags & ID_FLAG_IS_PARAM)) { - id->local_num += num_free; - } - } - scope->num_pos_args += num_free; // free vars are counted as params for passing them into the function - scope->num_locals += num_free; - } - } -} - -#if !MICROPY_PERSISTENT_CODE_SAVE -STATIC -#endif -mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl) { - // put compiler state on the stack, it's relatively small - compiler_t comp_state = {0}; - compiler_t *comp = &comp_state; - - comp->source_file = source_file; - comp->is_repl = is_repl; - comp->break_label = INVALID_LABEL; - comp->continue_label = INVALID_LABEL; - - // create the module scope - scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, parse_tree->root, emit_opt); - - // create standard emitter; it's used at least for MP_PASS_SCOPE - emit_t *emit_bc = emit_bc_new(); - - // compile pass 1 - comp->emit = emit_bc; - #if MICROPY_EMIT_NATIVE - comp->emit_method_table = &emit_bc_method_table; - #endif - uint max_num_labels = 0; - for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) { - if (false) { - #if MICROPY_EMIT_INLINE_ASM - } else if (s->emit_options == MP_EMIT_OPT_ASM) { - compile_scope_inline_asm(comp, s, MP_PASS_SCOPE); - #endif - } else { - compile_scope(comp, s, MP_PASS_SCOPE); - } - - // update maximim number of labels needed - if (comp->next_label > max_num_labels) { - max_num_labels = comp->next_label; - } - } - - // compute some things related to scope and identifiers - for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) { - scope_compute_things(s); - } - - // set max number of labels now that it's calculated - emit_bc_set_max_num_labels(emit_bc, max_num_labels); - - // compile pass 2 and 3 -#if MICROPY_EMIT_NATIVE - emit_t *emit_native = NULL; -#endif - for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) { - if (false) { - // dummy - - #if MICROPY_EMIT_INLINE_ASM - } else if (s->emit_options == MP_EMIT_OPT_ASM) { - // inline assembly - if (comp->emit_inline_asm == NULL) { - comp->emit_inline_asm = ASM_EMITTER(new)(max_num_labels); - } - comp->emit = NULL; - comp->emit_inline_asm_method_table = &ASM_EMITTER(method_table); - compile_scope_inline_asm(comp, s, MP_PASS_CODE_SIZE); - #if MICROPY_EMIT_INLINE_XTENSA - // Xtensa requires an extra pass to compute size of l32r const table - // TODO this can be improved by calculating it during SCOPE pass - // but that requires some other structural changes to the asm emitters - compile_scope_inline_asm(comp, s, MP_PASS_CODE_SIZE); - #endif - if (comp->compile_error == MP_OBJ_NULL) { - compile_scope_inline_asm(comp, s, MP_PASS_EMIT); - } - #endif - - } else { - - // choose the emit type - - switch (s->emit_options) { - -#if MICROPY_EMIT_NATIVE - case MP_EMIT_OPT_NATIVE_PYTHON: - case MP_EMIT_OPT_VIPER: - if (emit_native == NULL) { - emit_native = NATIVE_EMITTER(new)(&comp->compile_error, max_num_labels); - } - comp->emit_method_table = &NATIVE_EMITTER(method_table); - comp->emit = emit_native; - EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_ENABLE, s->emit_options == MP_EMIT_OPT_VIPER, 0); - break; -#endif // MICROPY_EMIT_NATIVE - - default: - comp->emit = emit_bc; - #if MICROPY_EMIT_NATIVE - comp->emit_method_table = &emit_bc_method_table; - #endif - break; - } - - // need a pass to compute stack size - compile_scope(comp, s, MP_PASS_STACK_SIZE); - - // second last pass: compute code size - if (comp->compile_error == MP_OBJ_NULL) { - compile_scope(comp, s, MP_PASS_CODE_SIZE); - } - - // final pass: emit code - if (comp->compile_error == MP_OBJ_NULL) { - compile_scope(comp, s, MP_PASS_EMIT); - } - } - } - - if (comp->compile_error != MP_OBJ_NULL) { - // if there is no line number for the error then use the line - // number for the start of this scope - compile_error_set_line(comp, comp->scope_cur->pn); - // add a traceback to the exception using relevant source info - mp_obj_exception_add_traceback(comp->compile_error, comp->source_file, - comp->compile_error_line, comp->scope_cur->simple_name); - } - - // free the emitters - - emit_bc_free(emit_bc); -#if MICROPY_EMIT_NATIVE - if (emit_native != NULL) { - NATIVE_EMITTER(free)(emit_native); - } -#endif - #if MICROPY_EMIT_INLINE_ASM - if (comp->emit_inline_asm != NULL) { - ASM_EMITTER(free)(comp->emit_inline_asm); - } - #endif - - // free the parse tree - mp_parse_tree_clear(parse_tree); - - // free the scopes - mp_raw_code_t *outer_raw_code = module_scope->raw_code; - for (scope_t *s = module_scope; s;) { - scope_t *next = s->next; - scope_free(s); - s = next; - } - - if (comp->compile_error != MP_OBJ_NULL) { - nlr_raise(comp->compile_error); - } else { - return outer_raw_code; - } -} - -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl) { - mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl); - // return function that executes the outer module - return mp_make_function_from_raw_code(rc, MP_OBJ_NULL, MP_OBJ_NULL); -} - -#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/compile.h b/user/mpy/py/compile.h deleted file mode 100644 index 3297e83..0000000 --- a/user/mpy/py/compile.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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_COMPILE_H -#define MICROPY_INCLUDED_PY_COMPILE_H - -#include "py/lexer.h" -#include "py/parse.h" -#include "py/emitglue.h" - -// These must fit in 8 bits; see scope.h -enum { - MP_EMIT_OPT_NONE, - MP_EMIT_OPT_BYTECODE, - MP_EMIT_OPT_NATIVE_PYTHON, - MP_EMIT_OPT_VIPER, - MP_EMIT_OPT_ASM, -}; - -// the compiler will raise an exception if an error occurred -// the compiler will clear the parse tree before it returns -mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl); - -#if MICROPY_PERSISTENT_CODE_SAVE -// this has the same semantics as mp_compile -mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl); -#endif - -// this is implemented in runtime.c -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); - -#endif // MICROPY_INCLUDED_PY_COMPILE_H diff --git a/user/mpy/py/emit.h b/user/mpy/py/emit.h deleted file mode 100644 index 2b2c904..0000000 --- a/user/mpy/py/emit.h +++ /dev/null @@ -1,286 +0,0 @@ -/* - * 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_EMIT_H -#define MICROPY_INCLUDED_PY_EMIT_H - -#include "py/lexer.h" -#include "py/scope.h" -#include "py/runtime0.h" - -/* Notes on passes: - * We don't know exactly the opcodes in pass 1 because they depend on the - * closing over of variables (LOAD_CLOSURE, BUILD_TUPLE, MAKE_CLOSURE), which - * depends on determining the scope of variables in each function, and this - * is not known until the end of pass 1. - * As a consequence, we don't know the maximum stack size until the end of pass 2. - * This is problematic for some emitters (x64) since they need to know the maximum - * stack size to compile the entry to the function, and this affects code size. - */ - -typedef enum { - MP_PASS_SCOPE = 1, // work out id's and their kind, and number of labels - MP_PASS_STACK_SIZE = 2, // work out maximum stack size - MP_PASS_CODE_SIZE = 3, // work out code size and label offsets - MP_PASS_EMIT = 4, // emit code -} pass_kind_t; - -#define MP_EMIT_STAR_FLAG_SINGLE (0x01) -#define MP_EMIT_STAR_FLAG_DOUBLE (0x02) - -#define MP_EMIT_BREAK_FROM_FOR (0x8000) - -#define MP_EMIT_NATIVE_TYPE_ENABLE (0) -#define MP_EMIT_NATIVE_TYPE_RETURN (1) -#define MP_EMIT_NATIVE_TYPE_ARG (2) - -typedef struct _emit_t emit_t; - -typedef struct _mp_emit_method_table_id_ops_t { - void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); - void (*name)(emit_t *emit, qstr qst); - void (*global)(emit_t *emit, qstr qst); -} mp_emit_method_table_id_ops_t; - -typedef struct _emit_method_table_t { - void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); - void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); - void (*end_pass)(emit_t *emit); - bool (*last_emit_was_return_value)(emit_t *emit); - void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); - void (*set_source_line)(emit_t *emit, mp_uint_t line); - - mp_emit_method_table_id_ops_t load_id; - mp_emit_method_table_id_ops_t store_id; - mp_emit_method_table_id_ops_t delete_id; - - void (*label_assign)(emit_t *emit, mp_uint_t l); - void (*import_name)(emit_t *emit, qstr qst); - void (*import_from)(emit_t *emit, qstr qst); - void (*import_star)(emit_t *emit); - void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); - void (*load_const_small_int)(emit_t *emit, mp_int_t arg); - void (*load_const_str)(emit_t *emit, qstr qst); - void (*load_const_obj)(emit_t *emit, mp_obj_t obj); - void (*load_null)(emit_t *emit); - void (*load_attr)(emit_t *emit, qstr qst); - void (*load_method)(emit_t *emit, qstr qst, bool is_super); - void (*load_build_class)(emit_t *emit); - void (*load_subscr)(emit_t *emit); - void (*store_attr)(emit_t *emit, qstr qst); - void (*store_subscr)(emit_t *emit); - void (*delete_attr)(emit_t *emit, qstr qst); - void (*delete_subscr)(emit_t *emit); - void (*dup_top)(emit_t *emit); - void (*dup_top_two)(emit_t *emit); - void (*pop_top)(emit_t *emit); - void (*rot_two)(emit_t *emit); - void (*rot_three)(emit_t *emit); - void (*jump)(emit_t *emit, mp_uint_t label); - void (*pop_jump_if)(emit_t *emit, bool cond, mp_uint_t label); - void (*jump_if_or_pop)(emit_t *emit, bool cond, mp_uint_t label); - void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); - void (*setup_with)(emit_t *emit, mp_uint_t label); - void (*with_cleanup)(emit_t *emit, mp_uint_t label); - void (*setup_except)(emit_t *emit, mp_uint_t label); - void (*setup_finally)(emit_t *emit, mp_uint_t label); - void (*end_finally)(emit_t *emit); - void (*get_iter)(emit_t *emit, bool use_stack); - void (*for_iter)(emit_t *emit, mp_uint_t label); - void (*for_iter_end)(emit_t *emit); - void (*pop_block)(emit_t *emit); - void (*pop_except)(emit_t *emit); - void (*unary_op)(emit_t *emit, mp_unary_op_t op); - void (*binary_op)(emit_t *emit, mp_binary_op_t op); - void (*build_tuple)(emit_t *emit, mp_uint_t n_args); - void (*build_list)(emit_t *emit, mp_uint_t n_args); - void (*build_map)(emit_t *emit, mp_uint_t n_args); - void (*store_map)(emit_t *emit); - #if MICROPY_PY_BUILTINS_SET - void (*build_set)(emit_t *emit, mp_uint_t n_args); - #endif - #if MICROPY_PY_BUILTINS_SLICE - void (*build_slice)(emit_t *emit, mp_uint_t n_args); - #endif - void (*store_comp)(emit_t *emit, scope_kind_t kind, mp_uint_t set_stack_index); - void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); - void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); - void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); - void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); - void (*return_value)(emit_t *emit); - void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); - void (*yield_value)(emit_t *emit); - void (*yield_from)(emit_t *emit); - - // these methods are used to control entry to/exit from an exception handler - // they may or may not emit code - void (*start_except_handler)(emit_t *emit); - void (*end_except_handler)(emit_t *emit); -} emit_method_table_t; - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); - -extern const emit_method_table_t emit_bc_method_table; -extern const emit_method_table_t emit_native_x64_method_table; -extern const emit_method_table_t emit_native_x86_method_table; -extern const emit_method_table_t emit_native_thumb_method_table; -extern const emit_method_table_t emit_native_arm_method_table; -extern const emit_method_table_t emit_native_xtensa_method_table; - -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; -extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; - -emit_t *emit_bc_new(void); -emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); -emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); - -void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); - -void emit_bc_free(emit_t *emit); -void emit_native_x64_free(emit_t *emit); -void emit_native_x86_free(emit_t *emit); -void emit_native_thumb_free(emit_t *emit); -void emit_native_arm_free(emit_t *emit); -void emit_native_xtensa_free(emit_t *emit); - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); -void mp_emit_bc_end_pass(emit_t *emit); -bool mp_emit_bc_last_emit_was_return_value(emit_t *emit); -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_load_name(emit_t *emit, qstr qst); -void mp_emit_bc_load_global(emit_t *emit, qstr qst); -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_store_name(emit_t *emit, qstr qst); -void mp_emit_bc_store_global(emit_t *emit, qstr qst); -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); -void mp_emit_bc_delete_name(emit_t *emit, qstr qst); -void mp_emit_bc_delete_global(emit_t *emit, qstr qst); - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); -void mp_emit_bc_import_name(emit_t *emit, qstr qst); -void mp_emit_bc_import_from(emit_t *emit, qstr qst); -void mp_emit_bc_import_star(emit_t *emit); -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); -void mp_emit_bc_load_null(emit_t *emit); -void mp_emit_bc_load_attr(emit_t *emit, qstr qst); -void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super); -void mp_emit_bc_load_build_class(emit_t *emit); -void mp_emit_bc_load_subscr(emit_t *emit); -void mp_emit_bc_store_attr(emit_t *emit, qstr qst); -void mp_emit_bc_store_subscr(emit_t *emit); -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); -void mp_emit_bc_delete_subscr(emit_t *emit); -void mp_emit_bc_dup_top(emit_t *emit); -void mp_emit_bc_dup_top_two(emit_t *emit); -void mp_emit_bc_pop_top(emit_t *emit); -void mp_emit_bc_rot_two(emit_t *emit); -void mp_emit_bc_rot_three(emit_t *emit); -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); -void mp_emit_bc_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label); -void mp_emit_bc_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label); -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); -#define mp_emit_bc_break_loop mp_emit_bc_unwind_jump -#define mp_emit_bc_continue_loop mp_emit_bc_unwind_jump -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); -void mp_emit_bc_end_finally(emit_t *emit); -void mp_emit_bc_get_iter(emit_t *emit, bool use_stack); -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); -void mp_emit_bc_for_iter_end(emit_t *emit); -void mp_emit_bc_pop_block(emit_t *emit); -void mp_emit_bc_pop_except(emit_t *emit); -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_store_map(emit_t *emit); -#if MICROPY_PY_BUILTINS_SET -void mp_emit_bc_build_set(emit_t *emit, mp_uint_t n_args); -#endif -#if MICROPY_PY_BUILTINS_SLICE -void mp_emit_bc_build_slice(emit_t *emit, mp_uint_t n_args); -#endif -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t list_stack_index); -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); -void mp_emit_bc_return_value(emit_t *emit); -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); -void mp_emit_bc_yield_value(emit_t *emit); -void mp_emit_bc_yield_from(emit_t *emit); -void mp_emit_bc_start_except_handler(emit_t *emit); -void mp_emit_bc_end_except_handler(emit_t *emit); - -typedef struct _emit_inline_asm_t emit_inline_asm_t; - -typedef struct _emit_inline_asm_method_table_t { - void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot); - void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); - mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); - bool (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); - void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); -} emit_inline_asm_method_table_t; - -extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; -extern const emit_inline_asm_method_table_t emit_inline_xtensa_method_table; - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels); - -void emit_inline_thumb_free(emit_inline_asm_t *emit); -void emit_inline_xtensa_free(emit_inline_asm_t *emit); - -#if MICROPY_WARNINGS -void mp_emitter_warning(pass_kind_t pass, const char *msg); -#else -#define mp_emitter_warning(pass, msg) -#endif - -#endif // MICROPY_INCLUDED_PY_EMIT_H diff --git a/user/mpy/py/emitbc.c b/user/mpy/py/emitbc.c deleted file mode 100644 index 6770209..0000000 --- a/user/mpy/py/emitbc.c +++ /dev/null @@ -1,1076 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include -#include - -#include "py/mpstate.h" -#include "py/emit.h" -#include "py/bc0.h" - -#if MICROPY_ENABLE_COMPILER - -#define BYTES_FOR_INT ((BYTES_PER_WORD * 8 + 6) / 7) -#define DUMMY_DATA_SIZE (BYTES_FOR_INT) - -struct _emit_t { - // Accessed as mp_obj_t, so must be aligned as such, and we rely on the - // memory allocator returning a suitably aligned pointer. - // Should work for cases when mp_obj_t is 64-bit on a 32-bit machine. - byte dummy_data[DUMMY_DATA_SIZE]; - - pass_kind_t pass : 8; - mp_uint_t last_emit_was_return_value : 8; - - int stack_size; - - scope_t *scope; - - mp_uint_t last_source_line_offset; - mp_uint_t last_source_line; - - mp_uint_t max_num_labels; - mp_uint_t *label_offsets; - - size_t code_info_offset; - size_t code_info_size; - size_t bytecode_offset; - size_t bytecode_size; - byte *code_base; // stores both byte code and code info - - #if MICROPY_PERSISTENT_CODE - uint16_t ct_cur_obj; - uint16_t ct_num_obj; - uint16_t ct_cur_raw_code; - #endif - mp_uint_t *const_table; -}; - -emit_t *emit_bc_new(void) { - emit_t *emit = m_new0(emit_t, 1); - return emit; -} - -void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels) { - emit->max_num_labels = max_num_labels; - emit->label_offsets = m_new(mp_uint_t, emit->max_num_labels); -} - -void emit_bc_free(emit_t *emit) { - m_del(mp_uint_t, emit->label_offsets, emit->max_num_labels); - m_del_obj(emit_t, emit); -} - -typedef byte *(*emit_allocator_t)(emit_t *emit, int nbytes); - -STATIC void emit_write_uint(emit_t *emit, emit_allocator_t allocator, mp_uint_t val) { - // We store each 7 bits in a separate byte, and that's how many bytes needed - byte buf[BYTES_FOR_INT]; - byte *p = buf + sizeof(buf); - // We encode in little-ending order, but store in big-endian, to help decoding - do { - *--p = val & 0x7f; - val >>= 7; - } while (val != 0); - byte *c = allocator(emit, buf + sizeof(buf) - p); - while (p != buf + sizeof(buf) - 1) { - *c++ = *p++ | 0x80; - } - *c = *p; -} - -// all functions must go through this one to emit code info -STATIC byte *emit_get_cur_to_write_code_info(emit_t *emit, int num_bytes_to_write) { - //printf("emit %d\n", num_bytes_to_write); - if (emit->pass < MP_PASS_EMIT) { - emit->code_info_offset += num_bytes_to_write; - return emit->dummy_data; - } else { - assert(emit->code_info_offset + num_bytes_to_write <= emit->code_info_size); - byte *c = emit->code_base + emit->code_info_offset; - emit->code_info_offset += num_bytes_to_write; - return c; - } -} - -STATIC void emit_write_code_info_byte(emit_t* emit, byte val) { - *emit_get_cur_to_write_code_info(emit, 1) = val; -} - -STATIC void emit_write_code_info_uint(emit_t* emit, mp_uint_t val) { - emit_write_uint(emit, emit_get_cur_to_write_code_info, val); -} - -STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) { - #if MICROPY_PERSISTENT_CODE - assert((qst >> 16) == 0); - byte *c = emit_get_cur_to_write_code_info(emit, 2); - c[0] = qst; - c[1] = qst >> 8; - #else - emit_write_uint(emit, emit_get_cur_to_write_code_info, qst); - #endif -} - -#if MICROPY_ENABLE_SOURCE_LINE -STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) { - assert(bytes_to_skip > 0 || lines_to_skip > 0); - //printf(" %d %d\n", bytes_to_skip, lines_to_skip); - while (bytes_to_skip > 0 || lines_to_skip > 0) { - mp_uint_t b, l; - if (lines_to_skip <= 6 || bytes_to_skip > 0xf) { - // use 0b0LLBBBBB encoding - b = MIN(bytes_to_skip, 0x1f); - if (b < bytes_to_skip) { - // we can't skip any lines until we skip all the bytes - l = 0; - } else { - l = MIN(lines_to_skip, 0x3); - } - *emit_get_cur_to_write_code_info(emit, 1) = b | (l << 5); - } else { - // use 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) - b = MIN(bytes_to_skip, 0xf); - l = MIN(lines_to_skip, 0x7ff); - byte *ci = emit_get_cur_to_write_code_info(emit, 2); - ci[0] = 0x80 | b | ((l >> 4) & 0x70); - ci[1] = l; - } - bytes_to_skip -= b; - lines_to_skip -= l; - } -} -#endif - -// all functions must go through this one to emit byte code -STATIC byte *emit_get_cur_to_write_bytecode(emit_t *emit, int num_bytes_to_write) { - //printf("emit %d\n", num_bytes_to_write); - if (emit->pass < MP_PASS_EMIT) { - emit->bytecode_offset += num_bytes_to_write; - return emit->dummy_data; - } else { - assert(emit->bytecode_offset + num_bytes_to_write <= emit->bytecode_size); - byte *c = emit->code_base + emit->code_info_size + emit->bytecode_offset; - emit->bytecode_offset += num_bytes_to_write; - return c; - } -} - -STATIC void emit_write_bytecode_byte(emit_t *emit, byte b1) { - byte *c = emit_get_cur_to_write_bytecode(emit, 1); - c[0] = b1; -} - -STATIC void emit_write_bytecode_byte_byte(emit_t* emit, byte b1, byte b2) { - byte *c = emit_get_cur_to_write_bytecode(emit, 2); - c[0] = b1; - c[1] = b2; -} - -// Similar to emit_write_bytecode_uint(), just some extra handling to encode sign -STATIC void emit_write_bytecode_byte_int(emit_t *emit, byte b1, mp_int_t num) { - emit_write_bytecode_byte(emit, b1); - - // We store each 7 bits in a separate byte, and that's how many bytes needed - byte buf[BYTES_FOR_INT]; - byte *p = buf + sizeof(buf); - // We encode in little-ending order, but store in big-endian, to help decoding - do { - *--p = num & 0x7f; - num >>= 7; - } while (num != 0 && num != -1); - // Make sure that highest bit we stored (mask 0x40) matches sign - // of the number. If not, store extra byte just to encode sign - if (num == -1 && (*p & 0x40) == 0) { - *--p = 0x7f; - } else if (num == 0 && (*p & 0x40) != 0) { - *--p = 0; - } - - byte *c = emit_get_cur_to_write_bytecode(emit, buf + sizeof(buf) - p); - while (p != buf + sizeof(buf) - 1) { - *c++ = *p++ | 0x80; - } - *c = *p; -} - -STATIC void emit_write_bytecode_byte_uint(emit_t *emit, byte b, mp_uint_t val) { - emit_write_bytecode_byte(emit, b); - emit_write_uint(emit, emit_get_cur_to_write_bytecode, val); -} - -#if MICROPY_PERSISTENT_CODE -STATIC void emit_write_bytecode_byte_const(emit_t *emit, byte b, mp_uint_t n, mp_uint_t c) { - if (emit->pass == MP_PASS_EMIT) { - emit->const_table[n] = c; - } - emit_write_bytecode_byte_uint(emit, b, n); -} -#endif - -STATIC void emit_write_bytecode_byte_qstr(emit_t* emit, byte b, qstr qst) { - #if MICROPY_PERSISTENT_CODE - assert((qst >> 16) == 0); - byte *c = emit_get_cur_to_write_bytecode(emit, 3); - c[0] = b; - c[1] = qst; - c[2] = qst >> 8; - #else - emit_write_bytecode_byte_uint(emit, b, qst); - #endif -} - -STATIC void emit_write_bytecode_byte_obj(emit_t *emit, byte b, mp_obj_t obj) { - #if MICROPY_PERSISTENT_CODE - emit_write_bytecode_byte_const(emit, b, - emit->scope->num_pos_args + emit->scope->num_kwonly_args - + emit->ct_cur_obj++, (mp_uint_t)obj); - #else - // aligns the pointer so it is friendly to GC - emit_write_bytecode_byte(emit, b); - emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(mp_obj_t)); - mp_obj_t *c = (mp_obj_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_obj_t)); - // Verify thar c is already uint-aligned - assert(c == MP_ALIGN(c, sizeof(mp_obj_t))); - *c = obj; - #endif -} - -STATIC void emit_write_bytecode_byte_raw_code(emit_t *emit, byte b, mp_raw_code_t *rc) { - #if MICROPY_PERSISTENT_CODE - emit_write_bytecode_byte_const(emit, b, - emit->scope->num_pos_args + emit->scope->num_kwonly_args - + emit->ct_num_obj + emit->ct_cur_raw_code++, (mp_uint_t)(uintptr_t)rc); - #else - // aligns the pointer so it is friendly to GC - emit_write_bytecode_byte(emit, b); - emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(void*)); - void **c = (void**)emit_get_cur_to_write_bytecode(emit, sizeof(void*)); - // Verify thar c is already uint-aligned - assert(c == MP_ALIGN(c, sizeof(void*))); - *c = rc; - #endif -} - -// unsigned labels are relative to ip following this instruction, stored as 16 bits -STATIC void emit_write_bytecode_byte_unsigned_label(emit_t *emit, byte b1, mp_uint_t label) { - mp_uint_t bytecode_offset; - if (emit->pass < MP_PASS_EMIT) { - bytecode_offset = 0; - } else { - bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3; - } - byte *c = emit_get_cur_to_write_bytecode(emit, 3); - c[0] = b1; - c[1] = bytecode_offset; - c[2] = bytecode_offset >> 8; -} - -// signed labels are relative to ip following this instruction, stored as 16 bits, in excess -STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint_t label) { - int bytecode_offset; - if (emit->pass < MP_PASS_EMIT) { - bytecode_offset = 0; - } else { - bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3 + 0x8000; - } - byte *c = emit_get_cur_to_write_bytecode(emit, 3); - c[0] = b1; - c[1] = bytecode_offset; - c[2] = bytecode_offset >> 8; -} - -void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { - emit->pass = pass; - emit->stack_size = 0; - emit->last_emit_was_return_value = false; - emit->scope = scope; - emit->last_source_line_offset = 0; - emit->last_source_line = 1; - if (pass < MP_PASS_EMIT) { - memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(mp_uint_t)); - } - emit->bytecode_offset = 0; - emit->code_info_offset = 0; - - // Write local state size and exception stack size. - { - mp_uint_t n_state = scope->num_locals + scope->stack_size; - if (n_state == 0) { - // Need at least 1 entry in the state, in the case an exception is - // propagated through this function, the exception is returned in - // the highest slot in the state (fastn[0], see vm.c). - n_state = 1; - } - emit_write_code_info_uint(emit, n_state); - emit_write_code_info_uint(emit, scope->exc_stack_size); - } - - // Write scope flags and number of arguments. - // TODO check that num args all fit in a byte - emit_write_code_info_byte(emit, emit->scope->scope_flags); - emit_write_code_info_byte(emit, emit->scope->num_pos_args); - emit_write_code_info_byte(emit, emit->scope->num_kwonly_args); - emit_write_code_info_byte(emit, emit->scope->num_def_pos_args); - - // Write size of the rest of the code info. We don't know how big this - // variable uint will be on the MP_PASS_CODE_SIZE pass so we reserve 2 bytes - // for it and hope that is enough! TODO assert this or something. - if (pass == MP_PASS_EMIT) { - emit_write_code_info_uint(emit, emit->code_info_size - emit->code_info_offset); - } else { - emit_get_cur_to_write_code_info(emit, 2); - } - - // Write the name and source file of this function. - emit_write_code_info_qstr(emit, scope->simple_name); - emit_write_code_info_qstr(emit, scope->source_file); - - // bytecode prelude: initialise closed over variables - for (int i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL) { - assert(id->local_num < 255); - emit_write_bytecode_byte(emit, id->local_num); // write the local which should be converted to a cell - } - } - emit_write_bytecode_byte(emit, 255); // end of list sentinel - - #if MICROPY_PERSISTENT_CODE - emit->ct_cur_obj = 0; - emit->ct_cur_raw_code = 0; - #endif - - if (pass == MP_PASS_EMIT) { - // Write argument names (needed to resolve positional args passed as - // keywords). We store them as full word-sized objects for efficient access - // in mp_setup_code_state this is the start of the prelude and is guaranteed - // to be aligned on a word boundary. - - // For a given argument position (indexed by i) we need to find the - // corresponding id_info which is a parameter, as it has the correct - // qstr name to use as the argument name. Note that it's not a simple - // 1-1 mapping (ie i!=j in general) because of possible closed-over - // variables. In the case that the argument i has no corresponding - // parameter we use "*" as its name (since no argument can ever be named - // "*"). We could use a blank qstr but "*" is better for debugging. - // Note: there is some wasted RAM here for the case of storing a qstr - // for each closed-over variable, and maybe there is a better way to do - // it, but that would require changes to mp_setup_code_state. - for (int i = 0; i < scope->num_pos_args + scope->num_kwonly_args; i++) { - qstr qst = MP_QSTR__star_; - for (int j = 0; j < scope->id_info_len; ++j) { - id_info_t *id = &scope->id_info[j]; - if ((id->flags & ID_FLAG_IS_PARAM) && id->local_num == i) { - qst = id->qst; - break; - } - } - emit->const_table[i] = (mp_uint_t)MP_OBJ_NEW_QSTR(qst); - } - } -} - -void mp_emit_bc_end_pass(emit_t *emit) { - if (emit->pass == MP_PASS_SCOPE) { - return; - } - - // check stack is back to zero size - assert(emit->stack_size == 0); - - emit_write_code_info_byte(emit, 0); // end of line number info - - #if MICROPY_PERSISTENT_CODE - assert(emit->pass <= MP_PASS_STACK_SIZE || (emit->ct_num_obj == emit->ct_cur_obj)); - emit->ct_num_obj = emit->ct_cur_obj; - #endif - - if (emit->pass == MP_PASS_CODE_SIZE) { - #if !MICROPY_PERSISTENT_CODE - // so bytecode is aligned - emit->code_info_offset = (size_t)MP_ALIGN(emit->code_info_offset, sizeof(mp_uint_t)); - #endif - - // calculate size of total code-info + bytecode, in bytes - emit->code_info_size = emit->code_info_offset; - emit->bytecode_size = emit->bytecode_offset; - emit->code_base = m_new0(byte, emit->code_info_size + emit->bytecode_size); - - #if MICROPY_PERSISTENT_CODE - emit->const_table = m_new0(mp_uint_t, - emit->scope->num_pos_args + emit->scope->num_kwonly_args - + emit->ct_cur_obj + emit->ct_cur_raw_code); - #else - emit->const_table = m_new0(mp_uint_t, - emit->scope->num_pos_args + emit->scope->num_kwonly_args); - #endif - - } else if (emit->pass == MP_PASS_EMIT) { - mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base, - emit->code_info_size + emit->bytecode_size, - emit->const_table, - #if MICROPY_PERSISTENT_CODE_SAVE - emit->ct_cur_obj, emit->ct_cur_raw_code, - #endif - emit->scope->scope_flags); - } -} - -bool mp_emit_bc_last_emit_was_return_value(emit_t *emit) { - return emit->last_emit_was_return_value; -} - -void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta) { - if (emit->pass == MP_PASS_SCOPE) { - return; - } - assert((mp_int_t)emit->stack_size + delta >= 0); - emit->stack_size += delta; - if (emit->stack_size > emit->scope->stack_size) { - emit->scope->stack_size = emit->stack_size; - } - emit->last_emit_was_return_value = false; -} - -static inline void emit_bc_pre(emit_t *emit, mp_int_t stack_size_delta) { - mp_emit_bc_adjust_stack_size(emit, stack_size_delta); -} - -void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) { - //printf("source: line %d -> %d offset %d -> %d\n", emit->last_source_line, source_line, emit->last_source_line_offset, emit->bytecode_offset); -#if MICROPY_ENABLE_SOURCE_LINE - if (MP_STATE_VM(mp_optimise_value) >= 3) { - // If we compile with -O3, don't store line numbers. - return; - } - if (source_line > emit->last_source_line) { - mp_uint_t bytes_to_skip = emit->bytecode_offset - emit->last_source_line_offset; - mp_uint_t lines_to_skip = source_line - emit->last_source_line; - emit_write_code_info_bytes_lines(emit, bytes_to_skip, lines_to_skip); - emit->last_source_line_offset = emit->bytecode_offset; - emit->last_source_line = source_line; - } -#else - (void)emit; - (void)source_line; -#endif -} - -void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) { - emit_bc_pre(emit, 0); - if (emit->pass == MP_PASS_SCOPE) { - return; - } - assert(l < emit->max_num_labels); - if (emit->pass < MP_PASS_EMIT) { - // assign label offset - assert(emit->label_offsets[l] == (mp_uint_t)-1); - emit->label_offsets[l] = emit->bytecode_offset; - } else { - // ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT - //printf("l%d: (at %d vs %d)\n", l, emit->bytecode_offset, emit->label_offsets[l]); - assert(emit->label_offsets[l] == emit->bytecode_offset); - } -} - -void mp_emit_bc_import_name(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_qstr(emit, MP_BC_IMPORT_NAME, qst); -} - -void mp_emit_bc_import_from(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, MP_BC_IMPORT_FROM, qst); -} - -void mp_emit_bc_import_star(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, MP_BC_IMPORT_STAR); -} - -void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { - emit_bc_pre(emit, 1); - switch (tok) { - case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_FALSE); break; - case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_NONE); break; - case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_TRUE); break; - default: - assert(tok == MP_TOKEN_ELLIPSIS); - emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj)); - break; - } -} - -void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) { - emit_bc_pre(emit, 1); - if (-16 <= arg && arg <= 47) { - emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_SMALL_INT_MULTI + 16 + arg); - } else { - emit_write_bytecode_byte_int(emit, MP_BC_LOAD_CONST_SMALL_INT, arg); - } -} - -void mp_emit_bc_load_const_str(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_CONST_STRING, qst); -} - -void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, obj); -} - -void mp_emit_bc_load_null(emit_t *emit) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte(emit, MP_BC_LOAD_NULL); -}; - -void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, 1); - if (local_num <= 15) { - emit_write_bytecode_byte(emit, MP_BC_LOAD_FAST_MULTI + local_num); - } else { - emit_write_bytecode_byte_uint(emit, MP_BC_LOAD_FAST_N, local_num); - } -} - -void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_uint(emit, MP_BC_LOAD_DEREF, local_num); -} - -void mp_emit_bc_load_name(emit_t *emit, qstr qst) { - (void)qst; - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_NAME, qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_load_global(emit_t *emit, qstr qst) { - (void)qst; - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_GLOBAL, qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_load_attr(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_ATTR, qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super) { - emit_bc_pre(emit, 1 - 2 * is_super); - emit_write_bytecode_byte_qstr(emit, is_super ? MP_BC_LOAD_SUPER_METHOD : MP_BC_LOAD_METHOD, qst); -} - -void mp_emit_bc_load_build_class(emit_t *emit) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte(emit, MP_BC_LOAD_BUILD_CLASS); -} - -void mp_emit_bc_load_subscr(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, MP_BC_LOAD_SUBSCR); -} - -void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, -1); - if (local_num <= 15) { - emit_write_bytecode_byte(emit, MP_BC_STORE_FAST_MULTI + local_num); - } else { - emit_write_bytecode_byte_uint(emit, MP_BC_STORE_FAST_N, local_num); - } -} - -void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_uint(emit, MP_BC_STORE_DEREF, local_num); -} - -void mp_emit_bc_store_name(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_qstr(emit, MP_BC_STORE_NAME, qst); -} - -void mp_emit_bc_store_global(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_qstr(emit, MP_BC_STORE_GLOBAL, qst); -} - -void mp_emit_bc_store_attr(emit_t *emit, qstr qst) { - emit_bc_pre(emit, -2); - emit_write_bytecode_byte_qstr(emit, MP_BC_STORE_ATTR, qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_byte(emit, 0); - } -} - -void mp_emit_bc_store_subscr(emit_t *emit) { - emit_bc_pre(emit, -3); - emit_write_bytecode_byte(emit, MP_BC_STORE_SUBSCR); -} - -void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_FAST, local_num); -} - -void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - (void)qst; - emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_DEREF, local_num); -} - -void mp_emit_bc_delete_name(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_qstr(emit, MP_BC_DELETE_NAME, qst); -} - -void mp_emit_bc_delete_global(emit_t *emit, qstr qst) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_qstr(emit, MP_BC_DELETE_GLOBAL, qst); -} - -void mp_emit_bc_delete_attr(emit_t *emit, qstr qst) { - mp_emit_bc_load_null(emit); - mp_emit_bc_rot_two(emit); - mp_emit_bc_store_attr(emit, qst); -} - -void mp_emit_bc_delete_subscr(emit_t *emit) { - mp_emit_bc_load_null(emit); - mp_emit_bc_rot_three(emit); - mp_emit_bc_store_subscr(emit); -} - -void mp_emit_bc_dup_top(emit_t *emit) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte(emit, MP_BC_DUP_TOP); -} - -void mp_emit_bc_dup_top_two(emit_t *emit) { - emit_bc_pre(emit, 2); - emit_write_bytecode_byte(emit, MP_BC_DUP_TOP_TWO); -} - -void mp_emit_bc_pop_top(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, MP_BC_POP_TOP); -} - -void mp_emit_bc_rot_two(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, MP_BC_ROT_TWO); -} - -void mp_emit_bc_rot_three(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, MP_BC_ROT_THREE); -} - -void mp_emit_bc_jump(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP, label); -} - -void mp_emit_bc_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) { - emit_bc_pre(emit, -1); - if (cond) { - emit_write_bytecode_byte_signed_label(emit, MP_BC_POP_JUMP_IF_TRUE, label); - } else { - emit_write_bytecode_byte_signed_label(emit, MP_BC_POP_JUMP_IF_FALSE, label); - } -} - -void mp_emit_bc_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) { - emit_bc_pre(emit, -1); - if (cond) { - emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP_IF_TRUE_OR_POP, label); - } else { - emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP_IF_FALSE_OR_POP, label); - } -} - -void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { - if (except_depth == 0) { - emit_bc_pre(emit, 0); - if (label & MP_EMIT_BREAK_FROM_FOR) { - // need to pop the iterator if we are breaking out of a for loop - emit_write_bytecode_byte(emit, MP_BC_POP_TOP); - // also pop the iter_buf - for (size_t i = 0; i < MP_OBJ_ITER_BUF_NSLOTS - 1; ++i) { - emit_write_bytecode_byte(emit, MP_BC_POP_TOP); - } - } - emit_write_bytecode_byte_signed_label(emit, MP_BC_JUMP, label & ~MP_EMIT_BREAK_FROM_FOR); - } else { - emit_write_bytecode_byte_signed_label(emit, MP_BC_UNWIND_JUMP, label & ~MP_EMIT_BREAK_FROM_FOR); - emit_write_bytecode_byte(emit, ((label & MP_EMIT_BREAK_FROM_FOR) ? 0x80 : 0) | except_depth); - } -} - -void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label) { - // The SETUP_WITH opcode pops ctx_mgr from the top of the stack - // and then pushes 3 entries: __exit__, ctx_mgr, as_value. - emit_bc_pre(emit, 2); - emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_WITH, label); -} - -void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label) { - mp_emit_bc_pop_block(emit); - mp_emit_bc_load_const_tok(emit, MP_TOKEN_KW_NONE); - mp_emit_bc_label_assign(emit, label); - emit_bc_pre(emit, 2); // ensure we have enough stack space to call the __exit__ method - emit_write_bytecode_byte(emit, MP_BC_WITH_CLEANUP); - emit_bc_pre(emit, -4); // cancel the 2 above, plus the 2 from mp_emit_bc_setup_with -} - -void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_EXCEPT, label); -} - -void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_FINALLY, label); -} - -void mp_emit_bc_end_finally(emit_t *emit) { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, MP_BC_END_FINALLY); -} - -void mp_emit_bc_get_iter(emit_t *emit, bool use_stack) { - emit_bc_pre(emit, use_stack ? MP_OBJ_ITER_BUF_NSLOTS - 1 : 0); - emit_write_bytecode_byte(emit, use_stack ? MP_BC_GET_ITER_STACK : MP_BC_GET_ITER); -} - -void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_unsigned_label(emit, MP_BC_FOR_ITER, label); -} - -void mp_emit_bc_for_iter_end(emit_t *emit) { - emit_bc_pre(emit, -MP_OBJ_ITER_BUF_NSLOTS); -} - -void mp_emit_bc_pop_block(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, MP_BC_POP_BLOCK); -} - -void mp_emit_bc_pop_except(emit_t *emit) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, MP_BC_POP_EXCEPT); -} - -void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, MP_BC_UNARY_OP_MULTI + op); -} - -void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op) { - bool invert = false; - if (op == MP_BINARY_OP_NOT_IN) { - invert = true; - op = MP_BINARY_OP_IN; - } else if (op == MP_BINARY_OP_IS_NOT) { - invert = true; - op = MP_BINARY_OP_IS; - } - emit_bc_pre(emit, -1); - emit_write_bytecode_byte(emit, MP_BC_BINARY_OP_MULTI + op); - if (invert) { - emit_bc_pre(emit, 0); - emit_write_bytecode_byte(emit, MP_BC_UNARY_OP_MULTI + MP_UNARY_OP_NOT); - } -} - -void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1 - n_args); - emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_TUPLE, n_args); -} - -void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1 - n_args); - emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_LIST, n_args); -} - -void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_MAP, n_args); -} - -void mp_emit_bc_store_map(emit_t *emit) { - emit_bc_pre(emit, -2); - emit_write_bytecode_byte(emit, MP_BC_STORE_MAP); -} - -#if MICROPY_PY_BUILTINS_SET -void mp_emit_bc_build_set(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1 - n_args); - emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_SET, n_args); -} -#endif - -#if MICROPY_PY_BUILTINS_SLICE -void mp_emit_bc_build_slice(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, 1 - n_args); - emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_SLICE, n_args); -} -#endif - -void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_stack_index) { - int t; - int n; - if (kind == SCOPE_LIST_COMP) { - n = 0; - t = 0; - } else if (!MICROPY_PY_BUILTINS_SET || kind == SCOPE_DICT_COMP) { - n = 1; - t = 1; - } else if (MICROPY_PY_BUILTINS_SET) { - n = 0; - t = 2; - } - emit_bc_pre(emit, -1 - n); - // the lower 2 bits of the opcode argument indicate the collection type - emit_write_bytecode_byte_uint(emit, MP_BC_STORE_COMP, ((collection_stack_index + n) << 2) | t); -} - -void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args) { - emit_bc_pre(emit, -1 + n_args); - emit_write_bytecode_byte_uint(emit, MP_BC_UNPACK_SEQUENCE, n_args); -} - -void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) { - emit_bc_pre(emit, -1 + n_left + n_right + 1); - emit_write_bytecode_byte_uint(emit, MP_BC_UNPACK_EX, n_left | (n_right << 8)); -} - -void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { - if (n_pos_defaults == 0 && n_kw_defaults == 0) { - emit_bc_pre(emit, 1); - emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_FUNCTION, scope->raw_code); - } else { - emit_bc_pre(emit, -1); - emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_FUNCTION_DEFARGS, scope->raw_code); - } -} - -void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { - if (n_pos_defaults == 0 && n_kw_defaults == 0) { - emit_bc_pre(emit, -n_closed_over + 1); - emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_CLOSURE, scope->raw_code); - emit_write_bytecode_byte(emit, n_closed_over); - } else { - assert(n_closed_over <= 255); - emit_bc_pre(emit, -2 - (mp_int_t)n_closed_over + 1); - emit_write_bytecode_byte_raw_code(emit, MP_BC_MAKE_CLOSURE_DEFARGS, scope->raw_code); - emit_write_bytecode_byte(emit, n_closed_over); - } -} - -STATIC void emit_bc_call_function_method_helper(emit_t *emit, mp_int_t stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - if (star_flags) { - emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword - 2); - emit_write_bytecode_byte_uint(emit, bytecode_base + 1, (n_keyword << 8) | n_positional); // TODO make it 2 separate uints? - } else { - emit_bc_pre(emit, stack_adj - (mp_int_t)n_positional - 2 * (mp_int_t)n_keyword); - emit_write_bytecode_byte_uint(emit, bytecode_base, (n_keyword << 8) | n_positional); // TODO make it 2 separate uints? - } -} - -void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - emit_bc_call_function_method_helper(emit, 0, MP_BC_CALL_FUNCTION, n_positional, n_keyword, star_flags); -} - -void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - emit_bc_call_function_method_helper(emit, -1, MP_BC_CALL_METHOD, n_positional, n_keyword, star_flags); -} - -void mp_emit_bc_return_value(emit_t *emit) { - emit_bc_pre(emit, -1); - emit->last_emit_was_return_value = true; - emit_write_bytecode_byte(emit, MP_BC_RETURN_VALUE); -} - -void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args) { - assert(n_args <= 2); - emit_bc_pre(emit, -n_args); - emit_write_bytecode_byte_byte(emit, MP_BC_RAISE_VARARGS, n_args); -} - -void mp_emit_bc_yield_value(emit_t *emit) { - emit_bc_pre(emit, 0); - emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; - emit_write_bytecode_byte(emit, MP_BC_YIELD_VALUE); -} - -void mp_emit_bc_yield_from(emit_t *emit) { - emit_bc_pre(emit, -1); - emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; - emit_write_bytecode_byte(emit, MP_BC_YIELD_FROM); -} - -void mp_emit_bc_start_except_handler(emit_t *emit) { - mp_emit_bc_adjust_stack_size(emit, 4); // stack adjust for the exception instance, +3 for possible UNWIND_JUMP state -} - -void mp_emit_bc_end_except_handler(emit_t *emit) { - mp_emit_bc_adjust_stack_size(emit, -3); // stack adjust -} - -#if MICROPY_EMIT_NATIVE -const emit_method_table_t emit_bc_method_table = { - NULL, // set_native_type is never called when emitting bytecode - mp_emit_bc_start_pass, - mp_emit_bc_end_pass, - mp_emit_bc_last_emit_was_return_value, - mp_emit_bc_adjust_stack_size, - mp_emit_bc_set_source_line, - - { - mp_emit_bc_load_fast, - mp_emit_bc_load_deref, - mp_emit_bc_load_name, - mp_emit_bc_load_global, - }, - { - mp_emit_bc_store_fast, - mp_emit_bc_store_deref, - mp_emit_bc_store_name, - mp_emit_bc_store_global, - }, - { - mp_emit_bc_delete_fast, - mp_emit_bc_delete_deref, - mp_emit_bc_delete_name, - mp_emit_bc_delete_global, - }, - - mp_emit_bc_label_assign, - mp_emit_bc_import_name, - mp_emit_bc_import_from, - mp_emit_bc_import_star, - mp_emit_bc_load_const_tok, - mp_emit_bc_load_const_small_int, - mp_emit_bc_load_const_str, - mp_emit_bc_load_const_obj, - mp_emit_bc_load_null, - mp_emit_bc_load_attr, - mp_emit_bc_load_method, - mp_emit_bc_load_build_class, - mp_emit_bc_load_subscr, - mp_emit_bc_store_attr, - mp_emit_bc_store_subscr, - mp_emit_bc_delete_attr, - mp_emit_bc_delete_subscr, - mp_emit_bc_dup_top, - mp_emit_bc_dup_top_two, - mp_emit_bc_pop_top, - mp_emit_bc_rot_two, - mp_emit_bc_rot_three, - mp_emit_bc_jump, - mp_emit_bc_pop_jump_if, - mp_emit_bc_jump_if_or_pop, - mp_emit_bc_unwind_jump, - mp_emit_bc_unwind_jump, - mp_emit_bc_setup_with, - mp_emit_bc_with_cleanup, - mp_emit_bc_setup_except, - mp_emit_bc_setup_finally, - mp_emit_bc_end_finally, - mp_emit_bc_get_iter, - mp_emit_bc_for_iter, - mp_emit_bc_for_iter_end, - mp_emit_bc_pop_block, - mp_emit_bc_pop_except, - mp_emit_bc_unary_op, - mp_emit_bc_binary_op, - mp_emit_bc_build_tuple, - mp_emit_bc_build_list, - mp_emit_bc_build_map, - mp_emit_bc_store_map, - #if MICROPY_PY_BUILTINS_SET - mp_emit_bc_build_set, - #endif - #if MICROPY_PY_BUILTINS_SLICE - mp_emit_bc_build_slice, - #endif - mp_emit_bc_store_comp, - mp_emit_bc_unpack_sequence, - mp_emit_bc_unpack_ex, - mp_emit_bc_make_function, - mp_emit_bc_make_closure, - mp_emit_bc_call_function, - mp_emit_bc_call_method, - mp_emit_bc_return_value, - mp_emit_bc_raise_varargs, - mp_emit_bc_yield_value, - mp_emit_bc_yield_from, - - mp_emit_bc_start_except_handler, - mp_emit_bc_end_except_handler, -}; -#else -const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops = { - mp_emit_bc_load_fast, - mp_emit_bc_load_deref, - mp_emit_bc_load_name, - mp_emit_bc_load_global, -}; - -const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops = { - mp_emit_bc_store_fast, - mp_emit_bc_store_deref, - mp_emit_bc_store_name, - mp_emit_bc_store_global, -}; - -const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops = { - mp_emit_bc_delete_fast, - mp_emit_bc_delete_deref, - mp_emit_bc_delete_name, - mp_emit_bc_delete_global, -}; -#endif - -#endif //MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/emitcommon.c b/user/mpy/py/emitcommon.c deleted file mode 100644 index 07b1dbb..0000000 --- a/user/mpy/py/emitcommon.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/emit.h" - -#if MICROPY_ENABLE_COMPILER - -void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst) { - // name adding/lookup - bool added; - id_info_t *id = scope_find_or_add_id(scope, qst, &added); - if (added) { - scope_find_local_and_close_over(scope, id, qst); - } -} - -void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst) { - // name adding/lookup - bool added; - id_info_t *id = scope_find_or_add_id(scope, qst, &added); - if (added) { - if (SCOPE_IS_FUNC_LIKE(scope->kind)) { - id->kind = ID_INFO_KIND_LOCAL; - } else { - id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; - } - } else if (SCOPE_IS_FUNC_LIKE(scope->kind) && id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - // rebind as a local variable - id->kind = ID_INFO_KIND_LOCAL; - } -} - -void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst) { - // assumes pass is greater than 1, ie that all identifiers are defined in the scope - - id_info_t *id = scope_find(scope, qst); - assert(id != NULL); - - // call the emit backend with the correct code - if (id->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) { - emit_method_table->name(emit, qst); - } else if (id->kind == ID_INFO_KIND_GLOBAL_EXPLICIT) { - emit_method_table->global(emit, qst); - } else if (id->kind == ID_INFO_KIND_LOCAL) { - emit_method_table->fast(emit, qst, id->local_num); - } else { - assert(id->kind == ID_INFO_KIND_CELL || id->kind == ID_INFO_KIND_FREE); - emit_method_table->deref(emit, qst, id->local_num); - } -} - -#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/emitglue.c b/user/mpy/py/emitglue.c deleted file mode 100644 index d2add98..0000000 --- a/user/mpy/py/emitglue.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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. - */ - -// This code glues the code emitters to the runtime. - -#include -#include -#include -#include - -#include "py/emitglue.h" -#include "py/runtime0.h" -#include "py/bc.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define WRITE_CODE (1) -#define DEBUG_printf DEBUG_printf -#define DEBUG_OP_printf(...) DEBUG_printf(__VA_ARGS__) -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#define DEBUG_OP_printf(...) (void)0 -#endif - -#if MICROPY_DEBUG_PRINTERS -mp_uint_t mp_verbose_flag = 0; -#endif - -mp_raw_code_t *mp_emit_glue_new_raw_code(void) { - mp_raw_code_t *rc = m_new0(mp_raw_code_t, 1); - rc->kind = MP_CODE_RESERVED; - return rc; -} - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - #if MICROPY_PERSISTENT_CODE_SAVE - uint16_t n_obj, uint16_t n_raw_code, - #endif - mp_uint_t scope_flags) { - - rc->kind = MP_CODE_BYTECODE; - rc->scope_flags = scope_flags; - rc->data.u_byte.bytecode = code; - rc->data.u_byte.const_table = const_table; - #if MICROPY_PERSISTENT_CODE_SAVE - rc->data.u_byte.bc_len = len; - rc->data.u_byte.n_obj = n_obj; - rc->data.u_byte.n_raw_code = n_raw_code; - #endif - -#ifdef DEBUG_PRINT - DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags); -#endif -#if MICROPY_DEBUG_PRINTERS - if (mp_verbose_flag >= 2) { - mp_bytecode_print(rc, code, len, const_table); - } -#endif -} - -#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig) { - assert(kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER || kind == MP_CODE_NATIVE_ASM); - rc->kind = kind; - rc->scope_flags = scope_flags; - rc->n_pos_args = n_pos_args; - rc->data.u_native.fun_data = fun_data; - rc->data.u_native.const_table = const_table; - rc->data.u_native.type_sig = type_sig; - -#ifdef DEBUG_PRINT - DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, n_pos_args, (uint)scope_flags); - for (mp_uint_t i = 0; i < fun_len; i++) { - if (i > 0 && i % 16 == 0) { - DEBUG_printf("\n"); - } - DEBUG_printf(" %02x", ((byte*)fun_data)[i]); - } - DEBUG_printf("\n"); - -#ifdef WRITE_CODE - FILE *fp_write_code = fopen("out-code", "wb"); - fwrite(fun_data, fun_len, 1, fp_write_code); - fclose(fp_write_code); -#endif -#else - (void)fun_len; -#endif -} -#endif - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args) { - DEBUG_OP_printf("make_function_from_raw_code %p\n", rc); - assert(rc != NULL); - - // def_args must be MP_OBJ_NULL or a tuple - assert(def_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_args, &mp_type_tuple)); - - // def_kw_args must be MP_OBJ_NULL or a dict - assert(def_kw_args == MP_OBJ_NULL || MP_OBJ_IS_TYPE(def_kw_args, &mp_type_dict)); - - // make the function, depending on the raw code kind - mp_obj_t fun; - switch (rc->kind) { - #if MICROPY_EMIT_NATIVE - case MP_CODE_NATIVE_PY: - fun = mp_obj_new_fun_native(def_args, def_kw_args, rc->data.u_native.fun_data, rc->data.u_native.const_table); - break; - case MP_CODE_NATIVE_VIPER: - fun = mp_obj_new_fun_viper(rc->n_pos_args, rc->data.u_native.fun_data, rc->data.u_native.type_sig); - break; - #endif - #if MICROPY_EMIT_INLINE_ASM - case MP_CODE_NATIVE_ASM: - fun = mp_obj_new_fun_asm(rc->n_pos_args, rc->data.u_native.fun_data, rc->data.u_native.type_sig); - break; - #endif - default: - // rc->kind should always be set and BYTECODE is the only remaining case - assert(rc->kind == MP_CODE_BYTECODE); - fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table); - break; - } - - // check for generator functions and if so wrap in generator object - if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) { - fun = mp_obj_new_gen_wrap(fun); - } - - return fun; -} - -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args) { - DEBUG_OP_printf("make_closure_from_raw_code %p " UINT_FMT " %p\n", rc, n_closed_over, args); - // make function object - mp_obj_t ffun; - if (n_closed_over & 0x100) { - // default positional and keyword args given - ffun = mp_make_function_from_raw_code(rc, args[0], args[1]); - } else { - // default positional and keyword args not given - ffun = mp_make_function_from_raw_code(rc, MP_OBJ_NULL, MP_OBJ_NULL); - } - // wrap function in closure object - return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2)); -} diff --git a/user/mpy/py/emitglue.h b/user/mpy/py/emitglue.h deleted file mode 100644 index 4393033..0000000 --- a/user/mpy/py/emitglue.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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_EMITGLUE_H -#define MICROPY_INCLUDED_PY_EMITGLUE_H - -#include "py/obj.h" - -// These variables and functions glue the code emitters to the runtime. - -typedef enum { - MP_CODE_UNUSED, - MP_CODE_RESERVED, - MP_CODE_BYTECODE, - MP_CODE_NATIVE_PY, - MP_CODE_NATIVE_VIPER, - MP_CODE_NATIVE_ASM, -} mp_raw_code_kind_t; - -typedef struct _mp_raw_code_t { - mp_raw_code_kind_t kind : 3; - mp_uint_t scope_flags : 7; - mp_uint_t n_pos_args : 11; - union { - struct { - const byte *bytecode; - const mp_uint_t *const_table; - #if MICROPY_PERSISTENT_CODE_SAVE - mp_uint_t bc_len; - uint16_t n_obj; - uint16_t n_raw_code; - #endif - } u_byte; - struct { - void *fun_data; - const mp_uint_t *const_table; - mp_uint_t type_sig; // for viper, compressed as 2-bit types; ret is MSB, then arg0, arg1, etc - } u_native; - } data; -} mp_raw_code_t; - -mp_raw_code_t *mp_emit_glue_new_raw_code(void); - -void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, - const mp_uint_t *const_table, - #if MICROPY_PERSISTENT_CODE_SAVE - uint16_t n_obj, uint16_t n_raw_code, - #endif - mp_uint_t scope_flags); -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig); - -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); - -#endif // MICROPY_INCLUDED_PY_EMITGLUE_H diff --git a/user/mpy/py/emitinlinethumb.c b/user/mpy/py/emitinlinethumb.c deleted file mode 100644 index 577f656..0000000 --- a/user/mpy/py/emitinlinethumb.c +++ /dev/null @@ -1,822 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include -#include - -#include "py/emit.h" -#include "py/asmthumb.h" - -#if MICROPY_EMIT_INLINE_THUMB - -typedef enum { -// define rules with a compile function -#define DEF_RULE(rule, comp, kind, ...) PN_##rule, -#define DEF_RULE_NC(rule, kind, ...) -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC - PN_const_object, // special node for a constant, generic Python object -// define rules without a compile function -#define DEF_RULE(rule, comp, kind, ...) -#define DEF_RULE_NC(rule, kind, ...) PN_##rule, -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC -} pn_kind_t; - -struct _emit_inline_asm_t { - asm_thumb_t as; - uint16_t pass; - mp_obj_t *error_slot; - mp_uint_t max_num_labels; - qstr *label_lookup; -}; - -STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const char *msg) { - *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); -} - -STATIC void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) { - *emit->error_slot = exc; -} - -emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels) { - emit_inline_asm_t *emit = m_new_obj(emit_inline_asm_t); - memset(&emit->as, 0, sizeof(emit->as)); - mp_asm_base_init(&emit->as.base, max_num_labels); - emit->max_num_labels = max_num_labels; - emit->label_lookup = m_new(qstr, max_num_labels); - return emit; -} - -void emit_inline_thumb_free(emit_inline_asm_t *emit) { - m_del(qstr, emit->label_lookup, emit->max_num_labels); - mp_asm_base_deinit(&emit->as.base, false); - m_del_obj(emit_inline_asm_t, emit); -} - -STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) { - emit->pass = pass; - emit->error_slot = error_slot; - if (emit->pass == MP_PASS_CODE_SIZE) { - memset(emit->label_lookup, 0, emit->max_num_labels * sizeof(qstr)); - } - mp_asm_base_start_pass(&emit->as.base, pass == MP_PASS_EMIT ? MP_ASM_PASS_EMIT : MP_ASM_PASS_COMPUTE); - asm_thumb_entry(&emit->as, 0); -} - -STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) { - asm_thumb_exit(&emit->as); - asm_thumb_end_pass(&emit->as); -} - -STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) { - if (n_params > 4) { - emit_inline_thumb_error_msg(emit, "can only have up to 4 parameters to Thumb assembly"); - return 0; - } - for (mp_uint_t i = 0; i < n_params; i++) { - if (!MP_PARSE_NODE_IS_ID(pn_params[i])) { - emit_inline_thumb_error_msg(emit, "parameters must be registers in sequence r0 to r3"); - return 0; - } - const char *p = qstr_str(MP_PARSE_NODE_LEAF_ARG(pn_params[i])); - if (!(strlen(p) == 2 && p[0] == 'r' && p[1] == '0' + i)) { - emit_inline_thumb_error_msg(emit, "parameters must be registers in sequence r0 to r3"); - return 0; - } - } - return n_params; -} - -STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) { - assert(label_num < emit->max_num_labels); - if (emit->pass == MP_PASS_CODE_SIZE) { - // check for duplicate label on first pass - for (uint i = 0; i < emit->max_num_labels; i++) { - if (emit->label_lookup[i] == label_id) { - return false; - } - } - } - emit->label_lookup[label_num] = label_id; - mp_asm_base_label_assign(&emit->as.base, label_num); - return true; -} - -typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t; -STATIC const reg_name_t reg_name_table[] = { - {0, "r0\0"}, - {1, "r1\0"}, - {2, "r2\0"}, - {3, "r3\0"}, - {4, "r4\0"}, - {5, "r5\0"}, - {6, "r6\0"}, - {7, "r7\0"}, - {8, "r8\0"}, - {9, "r9\0"}, - {10, "r10"}, - {11, "r11"}, - {12, "r12"}, - {13, "r13"}, - {14, "r14"}, - {15, "r15"}, - {10, "sl\0"}, - {11, "fp\0"}, - {13, "sp\0"}, - {14, "lr\0"}, - {15, "pc\0"}, -}; - -#define MAX_SPECIAL_REGISTER_NAME_LENGTH 7 -typedef struct _special_reg_name_t { byte reg; char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1]; } special_reg_name_t; -STATIC const special_reg_name_t special_reg_name_table[] = { - {5, "IPSR"}, - {17, "BASEPRI"}, -}; - -// return empty string in case of error, so we can attempt to parse the string -// without a special check if it was in fact a string -STATIC const char *get_arg_str(mp_parse_node_t pn) { - if (MP_PARSE_NODE_IS_ID(pn)) { - qstr qst = MP_PARSE_NODE_LEAF_ARG(pn); - return qstr_str(qst); - } else { - return ""; - } -} - -STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) { - const char *reg_str = get_arg_str(pn); - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) { - const reg_name_t *r = ®_name_table[i]; - if (reg_str[0] == r->name[0] - && reg_str[1] == r->name[1] - && reg_str[2] == r->name[2] - && (reg_str[2] == '\0' || reg_str[3] == '\0')) { - if (r->reg > max_reg) { - emit_inline_thumb_error_exc(emit, - mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, - "'%s' expects at most r%d", op, max_reg)); - return 0; - } else { - return r->reg; - } - } - } - emit_inline_thumb_error_exc(emit, - mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, - "'%s' expects a register", op)); - return 0; -} - -STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { - const char *reg_str = get_arg_str(pn); - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(special_reg_name_table); i++) { - const special_reg_name_t *r = &special_reg_name_table[i]; - if (strcmp(r->name, reg_str) == 0) { - return r->reg; - } - } - emit_inline_thumb_error_exc(emit, - mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, - "'%s' expects a special register", op)); - return 0; -} - -#if MICROPY_EMIT_INLINE_THUMB_FLOAT -STATIC mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { - const char *reg_str = get_arg_str(pn); - if (reg_str[0] == 's' && reg_str[1] != '\0') { - mp_uint_t regno = 0; - for (++reg_str; *reg_str; ++reg_str) { - mp_uint_t v = *reg_str; - if (!('0' <= v && v <= '9')) { - goto malformed; - } - regno = 10 * regno + v - '0'; - } - if (regno > 31) { - emit_inline_thumb_error_exc(emit, - mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, - "'%s' expects at most r%d", op, 31)); - return 0; - } else { - return regno; - } - } -malformed: - emit_inline_thumb_error_exc(emit, - mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, - "'%s' expects an FPU register", op)); - return 0; -} -#endif - -STATIC mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { - // a register list looks like {r0, r1, r2} and is parsed as a Python set - - if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_brace)) { - goto bad_arg; - } - - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 1); // should always be - pn = pns->nodes[0]; - - mp_uint_t reglist = 0; - - if (MP_PARSE_NODE_IS_ID(pn)) { - // set with one element - reglist |= 1 << get_arg_reg(emit, op, pn, 15); - } else if (MP_PARSE_NODE_IS_STRUCT(pn)) { - pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker) { - assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should succeed - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_dictorsetmaker_list) { - // set with multiple elements - - // get first element of set (we rely on get_arg_reg to catch syntax errors) - reglist |= 1 << get_arg_reg(emit, op, pns->nodes[0], 15); - - // get tail elements (2nd, 3rd, ...) - mp_parse_node_t *nodes; - int n = mp_parse_node_extract_list(&pns1->nodes[0], PN_dictorsetmaker_list2, &nodes); - - // process rest of elements - for (int i = 0; i < n; i++) { - reglist |= 1 << get_arg_reg(emit, op, nodes[i], 15); - } - } else { - goto bad_arg; - } - } else { - goto bad_arg; - } - } else { - goto bad_arg; - } - - return reglist; - -bad_arg: - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects {r0, r1, ...}", op)); - return 0; -} - -STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) { - mp_obj_t o; - if (!mp_parse_node_get_int_maybe(pn, &o)) { - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects an integer", op)); - return 0; - } - uint32_t i = mp_obj_get_int_truncated(o); - if ((i & (~fit_mask)) != 0) { - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer 0x%x does not fit in mask 0x%x", op, i, fit_mask)); - return 0; - } - return i; -} - -STATIC bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_parse_node_t *pn_base, mp_parse_node_t *pn_offset) { - if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_bracket)) { - goto bad_arg; - } - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { - goto bad_arg; - } - pns = (mp_parse_node_struct_t*)pns->nodes[0]; - if (MP_PARSE_NODE_STRUCT_NUM_NODES(pns) != 2) { - goto bad_arg; - } - - *pn_base = pns->nodes[0]; - *pn_offset = pns->nodes[1]; - return true; - -bad_arg: - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects an address of the form [a, b]", op)); - return false; -} - -STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { - if (!MP_PARSE_NODE_IS_ID(pn)) { - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects a label", op)); - return 0; - } - qstr label_qstr = MP_PARSE_NODE_LEAF_ARG(pn); - for (uint i = 0; i < emit->max_num_labels; i++) { - if (emit->label_lookup[i] == label_qstr) { - return i; - } - } - // only need to have the labels on the last pass - if (emit->pass == MP_PASS_EMIT) { - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "label '%q' not defined", label_qstr)); - } - return 0; -} - -typedef struct _cc_name_t { byte cc; byte name[2]; } cc_name_t; -STATIC const cc_name_t cc_name_table[] = { - { ASM_THUMB_CC_EQ, "eq" }, - { ASM_THUMB_CC_NE, "ne" }, - { ASM_THUMB_CC_CS, "cs" }, - { ASM_THUMB_CC_CC, "cc" }, - { ASM_THUMB_CC_MI, "mi" }, - { ASM_THUMB_CC_PL, "pl" }, - { ASM_THUMB_CC_VS, "vs" }, - { ASM_THUMB_CC_VC, "vc" }, - { ASM_THUMB_CC_HI, "hi" }, - { ASM_THUMB_CC_LS, "ls" }, - { ASM_THUMB_CC_GE, "ge" }, - { ASM_THUMB_CC_LT, "lt" }, - { ASM_THUMB_CC_GT, "gt" }, - { ASM_THUMB_CC_LE, "le" }, -}; - -typedef struct _format_4_op_t { byte op; char name[3]; } format_4_op_t; -#define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops -STATIC const format_4_op_t format_4_op_table[] = { - { X(ASM_THUMB_FORMAT_4_EOR), "eor" }, - { X(ASM_THUMB_FORMAT_4_LSL), "lsl" }, - { X(ASM_THUMB_FORMAT_4_LSR), "lsr" }, - { X(ASM_THUMB_FORMAT_4_ASR), "asr" }, - { X(ASM_THUMB_FORMAT_4_ADC), "adc" }, - { X(ASM_THUMB_FORMAT_4_SBC), "sbc" }, - { X(ASM_THUMB_FORMAT_4_ROR), "ror" }, - { X(ASM_THUMB_FORMAT_4_TST), "tst" }, - { X(ASM_THUMB_FORMAT_4_NEG), "neg" }, - { X(ASM_THUMB_FORMAT_4_CMP), "cmp" }, - { X(ASM_THUMB_FORMAT_4_CMN), "cmn" }, - { X(ASM_THUMB_FORMAT_4_ORR), "orr" }, - { X(ASM_THUMB_FORMAT_4_MUL), "mul" }, - { X(ASM_THUMB_FORMAT_4_BIC), "bic" }, - { X(ASM_THUMB_FORMAT_4_MVN), "mvn" }, -}; -#undef X - -// name is actually a qstr, which should fit in 16 bits -typedef struct _format_9_10_op_t { uint16_t op; uint16_t name; } format_9_10_op_t; -#define X(x) (x) -STATIC const format_9_10_op_t format_9_10_op_table[] = { - { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_ldr }, - { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_ldrb }, - { X(ASM_THUMB_FORMAT_10_LDRH), MP_QSTR_ldrh }, - { X(ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_str }, - { X(ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_strb }, - { X(ASM_THUMB_FORMAT_10_STRH), MP_QSTR_strh }, -}; -#undef X - -#if MICROPY_EMIT_INLINE_THUMB_FLOAT -// actual opcodes are: 0xee00 | op.hi_nibble, 0x0a00 | op.lo_nibble -typedef struct _format_vfp_op_t { byte op; char name[3]; } format_vfp_op_t; -STATIC const format_vfp_op_t format_vfp_op_table[] = { - { 0x30, "add" }, - { 0x34, "sub" }, - { 0x20, "mul" }, - { 0x80, "div" }, -}; -#endif - -// shorthand alias for whether we allow ARMv7-M instructions -#define ARMV7M MICROPY_EMIT_INLINE_THUMB_ARMV7M - -STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) { - // TODO perhaps make two tables: - // one_args = - // "b", LAB, asm_thumb_b_n, - // "bgt", LAB, asm_thumb_bgt_n, - // two_args = - // "movs", RLO, I8, asm_thumb_movs_reg_i8 - // "movw", REG, REG, asm_thumb_movw_reg_i16 - // three_args = - // "subs", RLO, RLO, I3, asm_thumb_subs_reg_reg_i3 - - size_t op_len; - const char *op_str = (const char*)qstr_data(op, &op_len); - - #if MICROPY_EMIT_INLINE_THUMB_FLOAT - if (op_str[0] == 'v') { - // floating point operations - if (n_args == 2) { - mp_uint_t op_code = 0x0ac0, op_code_hi; - if (op == MP_QSTR_vcmp) { - op_code_hi = 0xeeb4; - op_vfp_twoargs:; - mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]); - mp_uint_t vm = get_arg_vfpreg(emit, op_str, pn_args[1]); - asm_thumb_op32(&emit->as, - op_code_hi | ((vd & 1) << 6), - op_code | ((vd & 0x1e) << 11) | ((vm & 1) << 5) | (vm & 0x1e) >> 1); - } else if (op == MP_QSTR_vsqrt) { - op_code_hi = 0xeeb1; - goto op_vfp_twoargs; - } else if (op == MP_QSTR_vneg) { - op_code_hi = 0xeeb1; - op_code = 0x0a40; - goto op_vfp_twoargs; - } else if (op == MP_QSTR_vcvt_f32_s32) { - op_code_hi = 0xeeb8; // int to float - goto op_vfp_twoargs; - } else if (op == MP_QSTR_vcvt_s32_f32) { - op_code_hi = 0xeebd; // float to int - goto op_vfp_twoargs; - } else if (op == MP_QSTR_vmrs) { - mp_uint_t reg_dest; - const char *reg_str0 = get_arg_str(pn_args[0]); - if (strcmp(reg_str0, "APSR_nzcv") == 0) { - reg_dest = 15; - } else { - reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); - } - const char *reg_str1 = get_arg_str(pn_args[1]); - if (strcmp(reg_str1, "FPSCR") == 0) { - // FP status to ARM reg - asm_thumb_op32(&emit->as, 0xeef1, 0x0a10 | (reg_dest << 12)); - } else { - goto unknown_op; - } - } else if (op == MP_QSTR_vmov) { - op_code_hi = 0xee00; - mp_uint_t r_arm, vm; - const char *reg_str = get_arg_str(pn_args[0]); - if (reg_str[0] == 'r') { - r_arm = get_arg_reg(emit, op_str, pn_args[0], 15); - vm = get_arg_vfpreg(emit, op_str, pn_args[1]); - op_code_hi |= 0x10; - } else { - vm = get_arg_vfpreg(emit, op_str, pn_args[0]); - r_arm = get_arg_reg(emit, op_str, pn_args[1], 15); - } - asm_thumb_op32(&emit->as, - op_code_hi | ((vm & 0x1e) >> 1), - 0x0a10 | (r_arm << 12) | ((vm & 1) << 7)); - } else if (op == MP_QSTR_vldr) { - op_code_hi = 0xed90; - op_vldr_vstr:; - mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]); - mp_parse_node_t pn_base, pn_offset; - if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) { - mp_uint_t rlo_base = get_arg_reg(emit, op_str, pn_base, 7); - mp_uint_t i8; - i8 = get_arg_i(emit, op_str, pn_offset, 0x3fc) >> 2; - asm_thumb_op32(&emit->as, - op_code_hi | rlo_base | ((vd & 1) << 6), - 0x0a00 | ((vd & 0x1e) << 11) | i8); - } - } else if (op == MP_QSTR_vstr) { - op_code_hi = 0xed80; - goto op_vldr_vstr; - } else { - goto unknown_op; - } - } else if (n_args == 3) { - // search table for arith ops - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(format_vfp_op_table); i++) { - if (strncmp(op_str + 1, format_vfp_op_table[i].name, 3) == 0 && op_str[4] == '\0') { - mp_uint_t op_code_hi = 0xee00 | (format_vfp_op_table[i].op & 0xf0); - mp_uint_t op_code = 0x0a00 | ((format_vfp_op_table[i].op & 0x0f) << 4); - mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]); - mp_uint_t vn = get_arg_vfpreg(emit, op_str, pn_args[1]); - mp_uint_t vm = get_arg_vfpreg(emit, op_str, pn_args[2]); - asm_thumb_op32(&emit->as, - op_code_hi | ((vd & 1) << 6) | (vn >> 1), - op_code | (vm >> 1) | ((vm & 1) << 5) | ((vd & 0x1e) << 11) | ((vn & 1) << 7)); - return; - } - } - goto unknown_op; - } else { - goto unknown_op; - } - } else - #endif - if (n_args == 0) { - if (op == MP_QSTR_nop) { - asm_thumb_op16(&emit->as, ASM_THUMB_OP_NOP); - } else if (op == MP_QSTR_wfi) { - asm_thumb_op16(&emit->as, ASM_THUMB_OP_WFI); - } else { - goto unknown_op; - } - - } else if (n_args == 1) { - if (op == MP_QSTR_b) { - int label_num = get_arg_label(emit, op_str, pn_args[0]); - if (!asm_thumb_b_n_label(&emit->as, label_num)) { - goto branch_not_in_range; - } - } else if (op == MP_QSTR_bl) { - int label_num = get_arg_label(emit, op_str, pn_args[0]); - if (!asm_thumb_bl_label(&emit->as, label_num)) { - goto branch_not_in_range; - } - } else if (op == MP_QSTR_bx) { - mp_uint_t r = get_arg_reg(emit, op_str, pn_args[0], 15); - asm_thumb_op16(&emit->as, 0x4700 | (r << 3)); - } else if (op_str[0] == 'b' && (op_len == 3 - || (op_len == 5 && op_str[3] == '_' - && (op_str[4] == 'n' || (ARMV7M && op_str[4] == 'w'))))) { - mp_uint_t cc = -1; - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) { - if (op_str[1] == cc_name_table[i].name[0] && op_str[2] == cc_name_table[i].name[1]) { - cc = cc_name_table[i].cc; - } - } - if (cc == (mp_uint_t)-1) { - goto unknown_op; - } - int label_num = get_arg_label(emit, op_str, pn_args[0]); - if (!asm_thumb_bcc_nw_label(&emit->as, cc, label_num, op_len == 5 && op_str[4] == 'w')) { - goto branch_not_in_range; - } - } else if (ARMV7M && op_str[0] == 'i' && op_str[1] == 't') { - const char *arg_str = get_arg_str(pn_args[0]); - mp_uint_t cc = -1; - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) { - if (arg_str[0] == cc_name_table[i].name[0] - && arg_str[1] == cc_name_table[i].name[1] - && arg_str[2] == '\0') { - cc = cc_name_table[i].cc; - break; - } - } - if (cc == (mp_uint_t)-1) { - goto unknown_op; - } - const char *os = op_str + 2; - while (*os != '\0') { - os++; - } - if (os > op_str + 5) { - goto unknown_op; - } - mp_uint_t it_mask = 8; - while (--os >= op_str + 2) { - it_mask >>= 1; - if (*os == 't') { - it_mask |= (cc & 1) << 3; - } else if (*os == 'e') { - it_mask |= ((~cc) & 1) << 3; - } else { - goto unknown_op; - } - } - asm_thumb_it_cc(&emit->as, cc, it_mask); - } else if (op == MP_QSTR_cpsid) { - // TODO check pn_args[0] == i - asm_thumb_op16(&emit->as, ASM_THUMB_OP_CPSID_I); - } else if (op == MP_QSTR_cpsie) { - // TODO check pn_args[0] == i - asm_thumb_op16(&emit->as, ASM_THUMB_OP_CPSIE_I); - } else if (op == MP_QSTR_push) { - mp_uint_t reglist = get_arg_reglist(emit, op_str, pn_args[0]); - if ((reglist & 0xff00) == 0) { - asm_thumb_op16(&emit->as, 0xb400 | reglist); - } else { - if (!ARMV7M) { - goto unknown_op; - } - asm_thumb_op32(&emit->as, 0xe92d, reglist); - } - } else if (op == MP_QSTR_pop) { - mp_uint_t reglist = get_arg_reglist(emit, op_str, pn_args[0]); - if ((reglist & 0xff00) == 0) { - asm_thumb_op16(&emit->as, 0xbc00 | reglist); - } else { - if (!ARMV7M) { - goto unknown_op; - } - asm_thumb_op32(&emit->as, 0xe8bd, reglist); - } - } else { - goto unknown_op; - } - - } else if (n_args == 2) { - if (MP_PARSE_NODE_IS_ID(pn_args[1])) { - // second arg is a register (or should be) - mp_uint_t op_code, op_code_hi; - if (op == MP_QSTR_mov) { - mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); - mp_uint_t reg_src = get_arg_reg(emit, op_str, pn_args[1], 15); - asm_thumb_mov_reg_reg(&emit->as, reg_dest, reg_src); - } else if (ARMV7M && op == MP_QSTR_clz) { - op_code_hi = 0xfab0; - op_code = 0xf080; - mp_uint_t rd, rm; - op_clz_rbit: - rd = get_arg_reg(emit, op_str, pn_args[0], 15); - rm = get_arg_reg(emit, op_str, pn_args[1], 15); - asm_thumb_op32(&emit->as, op_code_hi | rm, op_code | (rd << 8) | rm); - } else if (ARMV7M && op == MP_QSTR_rbit) { - op_code_hi = 0xfa90; - op_code = 0xf0a0; - goto op_clz_rbit; - } else if (ARMV7M && op == MP_QSTR_mrs){ - mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 12); - mp_uint_t reg_src = get_arg_special_reg(emit, op_str, pn_args[1]); - asm_thumb_op32(&emit->as, 0xf3ef, 0x8000 | (reg_dest << 8) | reg_src); - } else { - if (op == MP_QSTR_and_) { - op_code = ASM_THUMB_FORMAT_4_AND; - mp_uint_t reg_dest, reg_src; - op_format_4: - reg_dest = get_arg_reg(emit, op_str, pn_args[0], 7); - reg_src = get_arg_reg(emit, op_str, pn_args[1], 7); - asm_thumb_format_4(&emit->as, op_code, reg_dest, reg_src); - return; - } - // search table for ALU ops - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(format_4_op_table); i++) { - if (strncmp(op_str, format_4_op_table[i].name, 3) == 0 && op_str[3] == '\0') { - op_code = 0x4000 | (format_4_op_table[i].op << 4); - goto op_format_4; - } - } - goto unknown_op; - } - } else { - // second arg is not a register - mp_uint_t op_code; - if (op == MP_QSTR_mov) { - op_code = ASM_THUMB_FORMAT_3_MOV; - mp_uint_t rlo_dest, i8_src; - op_format_3: - rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); - i8_src = get_arg_i(emit, op_str, pn_args[1], 0xff); - asm_thumb_format_3(&emit->as, op_code, rlo_dest, i8_src); - } else if (op == MP_QSTR_cmp) { - op_code = ASM_THUMB_FORMAT_3_CMP; - goto op_format_3; - } else if (op == MP_QSTR_add) { - op_code = ASM_THUMB_FORMAT_3_ADD; - goto op_format_3; - } else if (op == MP_QSTR_sub) { - op_code = ASM_THUMB_FORMAT_3_SUB; - goto op_format_3; - } else if (ARMV7M && op == MP_QSTR_movw) { - op_code = ASM_THUMB_OP_MOVW; - mp_uint_t reg_dest; - op_movw_movt: - reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); - int i_src = get_arg_i(emit, op_str, pn_args[1], 0xffff); - asm_thumb_mov_reg_i16(&emit->as, op_code, reg_dest, i_src); - } else if (ARMV7M && op == MP_QSTR_movt) { - op_code = ASM_THUMB_OP_MOVT; - goto op_movw_movt; - } else if (ARMV7M && op == MP_QSTR_movwt) { - // this is a convenience instruction - mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15); - uint32_t i_src = get_arg_i(emit, op_str, pn_args[1], 0xffffffff); - asm_thumb_mov_reg_i16(&emit->as, ASM_THUMB_OP_MOVW, reg_dest, i_src & 0xffff); - asm_thumb_mov_reg_i16(&emit->as, ASM_THUMB_OP_MOVT, reg_dest, (i_src >> 16) & 0xffff); - } else if (ARMV7M && op == MP_QSTR_ldrex) { - mp_uint_t r_dest = get_arg_reg(emit, op_str, pn_args[0], 15); - mp_parse_node_t pn_base, pn_offset; - if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) { - mp_uint_t r_base = get_arg_reg(emit, op_str, pn_base, 15); - mp_uint_t i8 = get_arg_i(emit, op_str, pn_offset, 0xff) >> 2; - asm_thumb_op32(&emit->as, 0xe850 | r_base, 0x0f00 | (r_dest << 12) | i8); - } - } else { - // search table for ldr/str instructions - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(format_9_10_op_table); i++) { - if (op == format_9_10_op_table[i].name) { - op_code = format_9_10_op_table[i].op; - mp_parse_node_t pn_base, pn_offset; - mp_uint_t rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); - if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) { - mp_uint_t rlo_base = get_arg_reg(emit, op_str, pn_base, 7); - mp_uint_t i5; - if (op_code & ASM_THUMB_FORMAT_9_BYTE_TRANSFER) { - i5 = get_arg_i(emit, op_str, pn_offset, 0x1f); - } else if (op_code & ASM_THUMB_FORMAT_10_STRH) { // also catches LDRH - i5 = get_arg_i(emit, op_str, pn_offset, 0x3e) >> 1; - } else { - i5 = get_arg_i(emit, op_str, pn_offset, 0x7c) >> 2; - } - asm_thumb_format_9_10(&emit->as, op_code, rlo_dest, rlo_base, i5); - return; - } - break; - } - } - goto unknown_op; - } - } - - } else if (n_args == 3) { - mp_uint_t op_code; - if (op == MP_QSTR_lsl) { - op_code = ASM_THUMB_FORMAT_1_LSL; - mp_uint_t rlo_dest, rlo_src, i5; - op_format_1: - rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); - rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7); - i5 = get_arg_i(emit, op_str, pn_args[2], 0x1f); - asm_thumb_format_1(&emit->as, op_code, rlo_dest, rlo_src, i5); - } else if (op == MP_QSTR_lsr) { - op_code = ASM_THUMB_FORMAT_1_LSR; - goto op_format_1; - } else if (op == MP_QSTR_asr) { - op_code = ASM_THUMB_FORMAT_1_ASR; - goto op_format_1; - } else if (op == MP_QSTR_add) { - op_code = ASM_THUMB_FORMAT_2_ADD; - mp_uint_t rlo_dest, rlo_src; - op_format_2: - rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7); - rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7); - int src_b; - if (MP_PARSE_NODE_IS_ID(pn_args[2])) { - op_code |= ASM_THUMB_FORMAT_2_REG_OPERAND; - src_b = get_arg_reg(emit, op_str, pn_args[2], 7); - } else { - op_code |= ASM_THUMB_FORMAT_2_IMM_OPERAND; - src_b = get_arg_i(emit, op_str, pn_args[2], 0x7); - } - asm_thumb_format_2(&emit->as, op_code, rlo_dest, rlo_src, src_b); - } else if (ARMV7M && op == MP_QSTR_sdiv) { - op_code = 0xfb90; // sdiv high part - mp_uint_t rd, rn, rm; - op_sdiv_udiv: - rd = get_arg_reg(emit, op_str, pn_args[0], 15); - rn = get_arg_reg(emit, op_str, pn_args[1], 15); - rm = get_arg_reg(emit, op_str, pn_args[2], 15); - asm_thumb_op32(&emit->as, op_code | rn, 0xf0f0 | (rd << 8) | rm); - } else if (ARMV7M && op == MP_QSTR_udiv) { - op_code = 0xfbb0; // udiv high part - goto op_sdiv_udiv; - } else if (op == MP_QSTR_sub) { - op_code = ASM_THUMB_FORMAT_2_SUB; - goto op_format_2; - } else if (ARMV7M && op == MP_QSTR_strex) { - mp_uint_t r_dest = get_arg_reg(emit, op_str, pn_args[0], 15); - mp_uint_t r_src = get_arg_reg(emit, op_str, pn_args[1], 15); - mp_parse_node_t pn_base, pn_offset; - if (get_arg_addr(emit, op_str, pn_args[2], &pn_base, &pn_offset)) { - mp_uint_t r_base = get_arg_reg(emit, op_str, pn_base, 15); - mp_uint_t i8 = get_arg_i(emit, op_str, pn_offset, 0xff) >> 2; - asm_thumb_op32(&emit->as, 0xe840 | r_base, (r_src << 12) | (r_dest << 8) | i8); - } - } else { - goto unknown_op; - } - - } else { - goto unknown_op; - } - - return; - -unknown_op: - emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "unsupported Thumb instruction '%s' with %d arguments", op_str, n_args)); - return; - -branch_not_in_range: - emit_inline_thumb_error_msg(emit, "branch not in range"); - return; -} - -const emit_inline_asm_method_table_t emit_inline_thumb_method_table = { - emit_inline_thumb_start_pass, - emit_inline_thumb_end_pass, - emit_inline_thumb_count_params, - emit_inline_thumb_label, - emit_inline_thumb_op, -}; - -#endif // MICROPY_EMIT_INLINE_THUMB diff --git a/user/mpy/py/emitinlinextensa.c b/user/mpy/py/emitinlinextensa.c deleted file mode 100644 index 3d3217f..0000000 --- a/user/mpy/py/emitinlinextensa.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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. - */ - -#include -#include -#include -#include -#include - -#include "py/emit.h" -#include "py/asmxtensa.h" - -#if MICROPY_EMIT_INLINE_XTENSA - -struct _emit_inline_asm_t { - asm_xtensa_t as; - uint16_t pass; - mp_obj_t *error_slot; - mp_uint_t max_num_labels; - qstr *label_lookup; -}; - -STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const char *msg) { - *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); -} - -STATIC void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) { - *emit->error_slot = exc; -} - -emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels) { - emit_inline_asm_t *emit = m_new_obj(emit_inline_asm_t); - memset(&emit->as, 0, sizeof(emit->as)); - mp_asm_base_init(&emit->as.base, max_num_labels); - emit->max_num_labels = max_num_labels; - emit->label_lookup = m_new(qstr, max_num_labels); - return emit; -} - -void emit_inline_xtensa_free(emit_inline_asm_t *emit) { - m_del(qstr, emit->label_lookup, emit->max_num_labels); - mp_asm_base_deinit(&emit->as.base, false); - m_del_obj(emit_inline_asm_t, emit); -} - -STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) { - emit->pass = pass; - emit->error_slot = error_slot; - if (emit->pass == MP_PASS_CODE_SIZE) { - memset(emit->label_lookup, 0, emit->max_num_labels * sizeof(qstr)); - } - mp_asm_base_start_pass(&emit->as.base, pass == MP_PASS_EMIT ? MP_ASM_PASS_EMIT : MP_ASM_PASS_COMPUTE); - asm_xtensa_entry(&emit->as, 0); -} - -STATIC void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) { - asm_xtensa_exit(&emit->as); - asm_xtensa_end_pass(&emit->as); -} - -STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) { - if (n_params > 4) { - emit_inline_xtensa_error_msg(emit, "can only have up to 4 parameters to Xtensa assembly"); - return 0; - } - for (mp_uint_t i = 0; i < n_params; i++) { - if (!MP_PARSE_NODE_IS_ID(pn_params[i])) { - emit_inline_xtensa_error_msg(emit, "parameters must be registers in sequence a2 to a5"); - return 0; - } - const char *p = qstr_str(MP_PARSE_NODE_LEAF_ARG(pn_params[i])); - if (!(strlen(p) == 2 && p[0] == 'a' && p[1] == '2' + i)) { - emit_inline_xtensa_error_msg(emit, "parameters must be registers in sequence a2 to a5"); - return 0; - } - } - return n_params; -} - -STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) { - assert(label_num < emit->max_num_labels); - if (emit->pass == MP_PASS_CODE_SIZE) { - // check for duplicate label on first pass - for (uint i = 0; i < emit->max_num_labels; i++) { - if (emit->label_lookup[i] == label_id) { - return false; - } - } - } - emit->label_lookup[label_num] = label_id; - mp_asm_base_label_assign(&emit->as.base, label_num); - return true; -} - -typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t; -STATIC const reg_name_t reg_name_table[] = { - {0, "a0\0"}, - {1, "a1\0"}, - {2, "a2\0"}, - {3, "a3\0"}, - {4, "a4\0"}, - {5, "a5\0"}, - {6, "a6\0"}, - {7, "a7\0"}, - {8, "a8\0"}, - {9, "a9\0"}, - {10, "a10"}, - {11, "a11"}, - {12, "a12"}, - {13, "a13"}, - {14, "a14"}, - {15, "a15"}, -}; - -// return empty string in case of error, so we can attempt to parse the string -// without a special check if it was in fact a string -STATIC const char *get_arg_str(mp_parse_node_t pn) { - if (MP_PARSE_NODE_IS_ID(pn)) { - qstr qst = MP_PARSE_NODE_LEAF_ARG(pn); - return qstr_str(qst); - } else { - return ""; - } -} - -STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { - const char *reg_str = get_arg_str(pn); - for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) { - const reg_name_t *r = ®_name_table[i]; - if (reg_str[0] == r->name[0] - && reg_str[1] == r->name[1] - && reg_str[2] == r->name[2] - && (reg_str[2] == '\0' || reg_str[3] == '\0')) { - return r->reg; - } - } - emit_inline_xtensa_error_exc(emit, - mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, - "'%s' expects a register", op)); - return 0; -} - -STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) { - mp_obj_t o; - if (!mp_parse_node_get_int_maybe(pn, &o)) { - emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects an integer", op)); - return 0; - } - uint32_t i = mp_obj_get_int_truncated(o); - if (min != max && ((int)i < min || (int)i > max)) { - emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer %d is not within range %d..%d", op, i, min, max)); - return 0; - } - return i; -} - -STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) { - if (!MP_PARSE_NODE_IS_ID(pn)) { - emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' expects a label", op)); - return 0; - } - qstr label_qstr = MP_PARSE_NODE_LEAF_ARG(pn); - for (uint i = 0; i < emit->max_num_labels; i++) { - if (emit->label_lookup[i] == label_qstr) { - return i; - } - } - // only need to have the labels on the last pass - if (emit->pass == MP_PASS_EMIT) { - emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "label '%q' not defined", label_qstr)); - } - return 0; -} - -#define RRR (0) -#define RRI8 (1) -#define RRI8_B (2) - -typedef struct _opcode_table_3arg_t { - uint16_t name; // actually a qstr, which should fit in 16 bits - uint8_t type; - uint8_t a0 : 4; - uint8_t a1 : 4; -} opcode_table_3arg_t; - -STATIC const opcode_table_3arg_t opcode_table_3arg[] = { - // arithmetic opcodes: reg, reg, reg - {MP_QSTR_and_, RRR, 0, 1}, - {MP_QSTR_or_, RRR, 0, 2}, - {MP_QSTR_xor, RRR, 0, 3}, - {MP_QSTR_add, RRR, 0, 8}, - {MP_QSTR_sub, RRR, 0, 12}, - {MP_QSTR_mull, RRR, 2, 8}, - - // load/store/addi opcodes: reg, reg, imm - // upper nibble of type encodes the range of the immediate arg - {MP_QSTR_l8ui, RRI8 | 0x10, 2, 0}, - {MP_QSTR_l16ui, RRI8 | 0x30, 2, 1}, - {MP_QSTR_l32i, RRI8 | 0x50, 2, 2}, - {MP_QSTR_s8i, RRI8 | 0x10, 2, 4}, - {MP_QSTR_s16i, RRI8 | 0x30, 2, 5}, - {MP_QSTR_s32i, RRI8 | 0x50, 2, 6}, - {MP_QSTR_l16si, RRI8 | 0x30, 2, 9}, - {MP_QSTR_addi, RRI8 | 0x00, 2, 12}, - - // branch opcodes: reg, reg, label - {MP_QSTR_ball, RRI8_B, ASM_XTENSA_CC_ALL, 0}, - {MP_QSTR_bany, RRI8_B, ASM_XTENSA_CC_ANY, 0}, - {MP_QSTR_bbc, RRI8_B, ASM_XTENSA_CC_BC, 0}, - {MP_QSTR_bbs, RRI8_B, ASM_XTENSA_CC_BS, 0}, - {MP_QSTR_beq, RRI8_B, ASM_XTENSA_CC_EQ, 0}, - {MP_QSTR_bge, RRI8_B, ASM_XTENSA_CC_GE, 0}, - {MP_QSTR_bgeu, RRI8_B, ASM_XTENSA_CC_GEU, 0}, - {MP_QSTR_blt, RRI8_B, ASM_XTENSA_CC_LT, 0}, - {MP_QSTR_bnall, RRI8_B, ASM_XTENSA_CC_NALL, 0}, - {MP_QSTR_bne, RRI8_B, ASM_XTENSA_CC_NE, 0}, - {MP_QSTR_bnone, RRI8_B, ASM_XTENSA_CC_NONE, 0}, -}; - -STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) { - size_t op_len; - const char *op_str = (const char*)qstr_data(op, &op_len); - - if (n_args == 0) { - if (op == MP_QSTR_ret_n) { - asm_xtensa_op_ret_n(&emit->as); - } else { - goto unknown_op; - } - - } else if (n_args == 1) { - if (op == MP_QSTR_callx0) { - uint r0 = get_arg_reg(emit, op_str, pn_args[0]); - asm_xtensa_op_callx0(&emit->as, r0); - } else if (op == MP_QSTR_j) { - int label = get_arg_label(emit, op_str, pn_args[0]); - asm_xtensa_j_label(&emit->as, label); - } else if (op == MP_QSTR_jx) { - uint r0 = get_arg_reg(emit, op_str, pn_args[0]); - asm_xtensa_op_jx(&emit->as, r0); - } else { - goto unknown_op; - } - - } else if (n_args == 2) { - uint r0 = get_arg_reg(emit, op_str, pn_args[0]); - if (op == MP_QSTR_beqz) { - int label = get_arg_label(emit, op_str, pn_args[1]); - asm_xtensa_bccz_reg_label(&emit->as, ASM_XTENSA_CCZ_EQ, r0, label); - } else if (op == MP_QSTR_bnez) { - int label = get_arg_label(emit, op_str, pn_args[1]); - asm_xtensa_bccz_reg_label(&emit->as, ASM_XTENSA_CCZ_NE, r0, label); - } else if (op == MP_QSTR_mov || op == MP_QSTR_mov_n) { - // we emit mov.n for both "mov" and "mov_n" opcodes - uint r1 = get_arg_reg(emit, op_str, pn_args[1]); - asm_xtensa_op_mov_n(&emit->as, r0, r1); - } else if (op == MP_QSTR_movi) { - // for convenience we emit l32r if the integer doesn't fit in movi - uint32_t imm = get_arg_i(emit, op_str, pn_args[1], 0, 0); - asm_xtensa_mov_reg_i32(&emit->as, r0, imm); - } else { - goto unknown_op; - } - - } else if (n_args == 3) { - // search table for 3 arg instructions - for (uint i = 0; i < MP_ARRAY_SIZE(opcode_table_3arg); i++) { - const opcode_table_3arg_t *o = &opcode_table_3arg[i]; - if (op == o->name) { - uint r0 = get_arg_reg(emit, op_str, pn_args[0]); - uint r1 = get_arg_reg(emit, op_str, pn_args[1]); - if (o->type == RRR) { - uint r2 = get_arg_reg(emit, op_str, pn_args[2]); - asm_xtensa_op24(&emit->as, ASM_XTENSA_ENCODE_RRR(0, o->a0, o->a1, r0, r1, r2)); - } else if (o->type == RRI8_B) { - int label = get_arg_label(emit, op_str, pn_args[2]); - asm_xtensa_bcc_reg_reg_label(&emit->as, o->a0, r0, r1, label); - } else { - int shift, min, max; - if ((o->type & 0xf0) == 0) { - shift = 0; - min = -128; - max = 127; - } else { - shift = (o->type & 0xf0) >> 5; - min = 0; - max = 0xff << shift; - } - uint32_t imm = get_arg_i(emit, op_str, pn_args[2], min, max); - asm_xtensa_op24(&emit->as, ASM_XTENSA_ENCODE_RRI8(o->a0, o->a1, r1, r0, (imm >> shift) & 0xff)); - } - return; - } - } - goto unknown_op; - - } else { - goto unknown_op; - } - - return; - -unknown_op: - emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "unsupported Xtensa instruction '%s' with %d arguments", op_str, n_args)); - return; - - /* -branch_not_in_range: - emit_inline_xtensa_error_msg(emit, "branch not in range"); - return; - */ -} - -const emit_inline_asm_method_table_t emit_inline_xtensa_method_table = { - emit_inline_xtensa_start_pass, - emit_inline_xtensa_end_pass, - emit_inline_xtensa_count_params, - emit_inline_xtensa_label, - emit_inline_xtensa_op, -}; - -#endif // MICROPY_EMIT_INLINE_XTENSA diff --git a/user/mpy/py/emitnative.c b/user/mpy/py/emitnative.c deleted file mode 100644 index 4608cd1..0000000 --- a/user/mpy/py/emitnative.c +++ /dev/null @@ -1,2350 +0,0 @@ -/* - * 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. - */ - -// Essentially normal Python has 1 type: Python objects -// Viper has more than 1 type, and is just a more complicated (a superset of) Python. -// If you declare everything in Viper as a Python object (ie omit type decls) then -// it should in principle be exactly the same as Python native. -// Having types means having more opcodes, like binary_op_nat_nat, binary_op_nat_obj etc. -// In practice we won't have a VM but rather do this in asm which is actually very minimal. - -// Because it breaks strict Python equivalence it should be a completely separate -// decorator. It breaks equivalence because overflow on integers wraps around. -// It shouldn't break equivalence if you don't use the new types, but since the -// type decls might be used in normal Python for other reasons, it's probably safest, -// cleanest and clearest to make it a separate decorator. - -// Actually, it does break equivalence because integers default to native integers, -// not Python objects. - -// for x in l[0:8]: can be compiled into a native loop if l has pointer type - -#include -#include -#include - -#include "py/nlr.h" -#include "py/emit.h" -#include "py/bc.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -// wrapper around everything in this file -#if (MICROPY_EMIT_X64 && N_X64) \ - || (MICROPY_EMIT_X86 && N_X86) \ - || (MICROPY_EMIT_THUMB && N_THUMB) \ - || (MICROPY_EMIT_ARM && N_ARM) \ - || (MICROPY_EMIT_XTENSA && N_XTENSA) \ - -// this is defined so that the assembler exports generic assembler API macros -#define GENERIC_ASM_API (1) - -#if N_X64 - -// x64 specific stuff -#include "py/asmx64.h" -#define EXPORT_FUN(name) emit_native_x64_##name - -#elif N_X86 - -// x86 specific stuff - -STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = { - [MP_F_CONVERT_OBJ_TO_NATIVE] = 2, - [MP_F_CONVERT_NATIVE_TO_OBJ] = 2, - [MP_F_LOAD_NAME] = 1, - [MP_F_LOAD_GLOBAL] = 1, - [MP_F_LOAD_BUILD_CLASS] = 0, - [MP_F_LOAD_ATTR] = 2, - [MP_F_LOAD_METHOD] = 3, - [MP_F_LOAD_SUPER_METHOD] = 2, - [MP_F_STORE_NAME] = 2, - [MP_F_STORE_GLOBAL] = 2, - [MP_F_STORE_ATTR] = 3, - [MP_F_OBJ_SUBSCR] = 3, - [MP_F_OBJ_IS_TRUE] = 1, - [MP_F_UNARY_OP] = 2, - [MP_F_BINARY_OP] = 3, - [MP_F_BUILD_TUPLE] = 2, - [MP_F_BUILD_LIST] = 2, - [MP_F_LIST_APPEND] = 2, - [MP_F_BUILD_MAP] = 1, - [MP_F_STORE_MAP] = 3, -#if MICROPY_PY_BUILTINS_SET - [MP_F_BUILD_SET] = 2, - [MP_F_STORE_SET] = 2, -#endif - [MP_F_MAKE_FUNCTION_FROM_RAW_CODE] = 3, - [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3, - [MP_F_CALL_METHOD_N_KW] = 3, - [MP_F_CALL_METHOD_N_KW_VAR] = 3, - [MP_F_NATIVE_GETITER] = 2, - [MP_F_NATIVE_ITERNEXT] = 1, - [MP_F_NLR_PUSH] = 1, - [MP_F_NLR_POP] = 0, - [MP_F_NATIVE_RAISE] = 1, - [MP_F_IMPORT_NAME] = 3, - [MP_F_IMPORT_FROM] = 2, - [MP_F_IMPORT_ALL] = 1, -#if MICROPY_PY_BUILTINS_SLICE - [MP_F_NEW_SLICE] = 3, -#endif - [MP_F_UNPACK_SEQUENCE] = 3, - [MP_F_UNPACK_EX] = 3, - [MP_F_DELETE_NAME] = 1, - [MP_F_DELETE_GLOBAL] = 1, - [MP_F_NEW_CELL] = 1, - [MP_F_MAKE_CLOSURE_FROM_RAW_CODE] = 3, - [MP_F_SETUP_CODE_STATE] = 5, -}; - -#include "py/asmx86.h" -#define EXPORT_FUN(name) emit_native_x86_##name - -#elif N_THUMB - -// thumb specific stuff -#include "py/asmthumb.h" -#define EXPORT_FUN(name) emit_native_thumb_##name - -#elif N_ARM - -// ARM specific stuff -#include "py/asmarm.h" -#define EXPORT_FUN(name) emit_native_arm_##name - -#elif N_XTENSA - -// Xtensa specific stuff -#include "py/asmxtensa.h" -#define EXPORT_FUN(name) emit_native_xtensa_##name - -#else - -#error unknown native emitter - -#endif - -#define EMIT_NATIVE_VIPER_TYPE_ERROR(emit, ...) do { \ - *emit->error_slot = mp_obj_new_exception_msg_varg(&mp_type_ViperTypeError, __VA_ARGS__); \ - } while (0) - -typedef enum { - STACK_VALUE, - STACK_REG, - STACK_IMM, -} stack_info_kind_t; - -// these enums must be distinct and the bottom 4 bits -// must correspond to the correct MP_NATIVE_TYPE_xxx value -typedef enum { - VTYPE_PYOBJ = 0x00 | MP_NATIVE_TYPE_OBJ, - VTYPE_BOOL = 0x00 | MP_NATIVE_TYPE_BOOL, - VTYPE_INT = 0x00 | MP_NATIVE_TYPE_INT, - VTYPE_UINT = 0x00 | MP_NATIVE_TYPE_UINT, - VTYPE_PTR = 0x00 | MP_NATIVE_TYPE_PTR, - VTYPE_PTR8 = 0x00 | MP_NATIVE_TYPE_PTR8, - VTYPE_PTR16 = 0x00 | MP_NATIVE_TYPE_PTR16, - VTYPE_PTR32 = 0x00 | MP_NATIVE_TYPE_PTR32, - - VTYPE_PTR_NONE = 0x50 | MP_NATIVE_TYPE_PTR, - - VTYPE_UNBOUND = 0x60 | MP_NATIVE_TYPE_OBJ, - VTYPE_BUILTIN_CAST = 0x70 | MP_NATIVE_TYPE_OBJ, -} vtype_kind_t; - -STATIC qstr vtype_to_qstr(vtype_kind_t vtype) { - switch (vtype) { - case VTYPE_PYOBJ: return MP_QSTR_object; - case VTYPE_BOOL: return MP_QSTR_bool; - case VTYPE_INT: return MP_QSTR_int; - case VTYPE_UINT: return MP_QSTR_uint; - case VTYPE_PTR: return MP_QSTR_ptr; - case VTYPE_PTR8: return MP_QSTR_ptr8; - case VTYPE_PTR16: return MP_QSTR_ptr16; - case VTYPE_PTR32: return MP_QSTR_ptr32; - case VTYPE_PTR_NONE: default: return MP_QSTR_None; - } -} - -typedef struct _stack_info_t { - vtype_kind_t vtype; - stack_info_kind_t kind; - union { - int u_reg; - mp_int_t u_imm; - } data; -} stack_info_t; - -struct _emit_t { - mp_obj_t *error_slot; - int pass; - - bool do_viper_types; - - vtype_kind_t return_vtype; - - mp_uint_t local_vtype_alloc; - vtype_kind_t *local_vtype; - - mp_uint_t stack_info_alloc; - stack_info_t *stack_info; - vtype_kind_t saved_stack_vtype; - - int prelude_offset; - int const_table_offset; - int n_state; - int stack_start; - int stack_size; - - bool last_emit_was_return_value; - - scope_t *scope; - - ASM_T *as; -}; - -emit_t *EXPORT_FUN(new)(mp_obj_t *error_slot, mp_uint_t max_num_labels) { - emit_t *emit = m_new0(emit_t, 1); - emit->error_slot = error_slot; - emit->as = m_new0(ASM_T, 1); - mp_asm_base_init(&emit->as->base, max_num_labels); - return emit; -} - -void EXPORT_FUN(free)(emit_t *emit) { - mp_asm_base_deinit(&emit->as->base, false); - m_del_obj(ASM_T, emit->as); - m_del(vtype_kind_t, emit->local_vtype, emit->local_vtype_alloc); - m_del(stack_info_t, emit->stack_info, emit->stack_info_alloc); - m_del_obj(emit_t, emit); -} - -STATIC void emit_native_set_native_type(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2) { - switch (op) { - case MP_EMIT_NATIVE_TYPE_ENABLE: - emit->do_viper_types = arg1; - break; - - default: { - vtype_kind_t type; - switch (arg2) { - case MP_QSTR_object: type = VTYPE_PYOBJ; break; - case MP_QSTR_bool: type = VTYPE_BOOL; break; - case MP_QSTR_int: type = VTYPE_INT; break; - case MP_QSTR_uint: type = VTYPE_UINT; break; - case MP_QSTR_ptr: type = VTYPE_PTR; break; - case MP_QSTR_ptr8: type = VTYPE_PTR8; break; - case MP_QSTR_ptr16: type = VTYPE_PTR16; break; - case MP_QSTR_ptr32: type = VTYPE_PTR32; break; - default: EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "unknown type '%q'", arg2); return; - } - if (op == MP_EMIT_NATIVE_TYPE_RETURN) { - emit->return_vtype = type; - } else { - assert(arg1 < emit->local_vtype_alloc); - emit->local_vtype[arg1] = type; - } - break; - } - } -} - -STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest); -STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg); -STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); -STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); - -#define STATE_START (sizeof(mp_code_state_t) / sizeof(mp_uint_t)) - -STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { - DEBUG_printf("start_pass(pass=%u, scope=%p)\n", pass, scope); - - emit->pass = pass; - emit->stack_start = 0; - emit->stack_size = 0; - emit->last_emit_was_return_value = false; - emit->scope = scope; - - // allocate memory for keeping track of the types of locals - if (emit->local_vtype_alloc < scope->num_locals) { - emit->local_vtype = m_renew(vtype_kind_t, emit->local_vtype, emit->local_vtype_alloc, scope->num_locals); - emit->local_vtype_alloc = scope->num_locals; - } - - // allocate memory for keeping track of the objects on the stack - // XXX don't know stack size on entry, and it should be maximum over all scopes - // XXX this is such a big hack and really needs to be fixed - if (emit->stack_info == NULL) { - emit->stack_info_alloc = scope->stack_size + 200; - emit->stack_info = m_new(stack_info_t, emit->stack_info_alloc); - } - - // set default type for return - emit->return_vtype = VTYPE_PYOBJ; - - // set default type for arguments - mp_uint_t num_args = emit->scope->num_pos_args + emit->scope->num_kwonly_args; - if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) { - num_args += 1; - } - if (scope->scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) { - num_args += 1; - } - for (mp_uint_t i = 0; i < num_args; i++) { - emit->local_vtype[i] = VTYPE_PYOBJ; - } - - // local variables begin unbound, and have unknown type - for (mp_uint_t i = num_args; i < emit->local_vtype_alloc; i++) { - emit->local_vtype[i] = VTYPE_UNBOUND; - } - - // values on stack begin unbound - for (mp_uint_t i = 0; i < emit->stack_info_alloc; i++) { - emit->stack_info[i].kind = STACK_VALUE; - emit->stack_info[i].vtype = VTYPE_UNBOUND; - } - - mp_asm_base_start_pass(&emit->as->base, pass == MP_PASS_EMIT ? MP_ASM_PASS_EMIT : MP_ASM_PASS_COMPUTE); - - // generate code for entry to function - - if (emit->do_viper_types) { - - // right now we have a restriction of maximum of 4 arguments - if (scope->num_pos_args >= 5) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "Viper functions don't currently support more than 4 arguments"); - return; - } - - // entry to function - int num_locals = 0; - if (pass > MP_PASS_SCOPE) { - num_locals = scope->num_locals - REG_LOCAL_NUM; - if (num_locals < 0) { - num_locals = 0; - } - emit->stack_start = num_locals; - num_locals += scope->stack_size; - } - ASM_ENTRY(emit->as, num_locals); - - // TODO don't load r7 if we don't need it - #if N_THUMB - asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); - #elif N_ARM - asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); - #endif - - #if N_X86 - for (int i = 0; i < scope->num_pos_args; i++) { - if (i == 0) { - asm_x86_mov_arg_to_r32(emit->as, i, REG_LOCAL_1); - } else if (i == 1) { - asm_x86_mov_arg_to_r32(emit->as, i, REG_LOCAL_2); - } else if (i == 2) { - asm_x86_mov_arg_to_r32(emit->as, i, REG_LOCAL_3); - } else { - asm_x86_mov_arg_to_r32(emit->as, i, REG_TEMP0); - asm_x86_mov_r32_to_local(emit->as, REG_TEMP0, i - REG_LOCAL_NUM); - } - } - #else - for (int i = 0; i < scope->num_pos_args; i++) { - if (i == 0) { - ASM_MOV_REG_REG(emit->as, REG_LOCAL_1, REG_ARG_1); - } else if (i == 1) { - ASM_MOV_REG_REG(emit->as, REG_LOCAL_2, REG_ARG_2); - } else if (i == 2) { - ASM_MOV_REG_REG(emit->as, REG_LOCAL_3, REG_ARG_3); - } else { - assert(i == 3); // should be true; max 4 args is checked above - ASM_MOV_REG_TO_LOCAL(emit->as, REG_ARG_4, i - REG_LOCAL_NUM); - } - } - #endif - - } else { - // work out size of state (locals plus stack) - emit->n_state = scope->num_locals + scope->stack_size; - - // allocate space on C-stack for code_state structure, which includes state - ASM_ENTRY(emit->as, STATE_START + emit->n_state); - - // TODO don't load r7 if we don't need it - #if N_THUMB - asm_thumb_mov_reg_i32(emit->as, ASM_THUMB_REG_R7, (mp_uint_t)mp_fun_table); - #elif N_ARM - asm_arm_mov_reg_i32(emit->as, ASM_ARM_REG_R7, (mp_uint_t)mp_fun_table); - #endif - - // prepare incoming arguments for call to mp_setup_code_state - - #if N_X86 - asm_x86_mov_arg_to_r32(emit->as, 0, REG_ARG_1); - asm_x86_mov_arg_to_r32(emit->as, 1, REG_ARG_2); - asm_x86_mov_arg_to_r32(emit->as, 2, REG_ARG_3); - asm_x86_mov_arg_to_r32(emit->as, 3, REG_ARG_4); - #endif - - // set code_state.fun_bc - ASM_MOV_REG_TO_LOCAL(emit->as, REG_ARG_1, offsetof(mp_code_state_t, fun_bc) / sizeof(uintptr_t)); - - // set code_state.ip (offset from start of this function to prelude info) - // XXX this encoding may change size - ASM_MOV_IMM_TO_LOCAL_USING(emit->as, emit->prelude_offset, offsetof(mp_code_state_t, ip) / sizeof(uintptr_t), REG_ARG_1); - - // put address of code_state into first arg - ASM_MOV_LOCAL_ADDR_TO_REG(emit->as, 0, REG_ARG_1); - - // call mp_setup_code_state to prepare code_state structure - #if N_THUMB - asm_thumb_bl_ind(emit->as, mp_fun_table[MP_F_SETUP_CODE_STATE], MP_F_SETUP_CODE_STATE, ASM_THUMB_REG_R4); - #elif N_ARM - asm_arm_bl_ind(emit->as, mp_fun_table[MP_F_SETUP_CODE_STATE], MP_F_SETUP_CODE_STATE, ASM_ARM_REG_R4); - #else - ASM_CALL_IND(emit->as, mp_fun_table[MP_F_SETUP_CODE_STATE], MP_F_SETUP_CODE_STATE); - #endif - - // cache some locals in registers - if (scope->num_locals > 0) { - ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - 0, REG_LOCAL_1); - if (scope->num_locals > 1) { - ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - 1, REG_LOCAL_2); - if (scope->num_locals > 2) { - ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - 2, REG_LOCAL_3); - } - } - } - - // set the type of closed over variables - for (mp_uint_t i = 0; i < scope->id_info_len; i++) { - id_info_t *id = &scope->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL) { - emit->local_vtype[id->local_num] = VTYPE_PYOBJ; - } - } - } - -} - -STATIC void emit_native_end_pass(emit_t *emit) { - if (!emit->last_emit_was_return_value) { - ASM_EXIT(emit->as); - } - - if (!emit->do_viper_types) { - emit->prelude_offset = mp_asm_base_get_code_pos(&emit->as->base); - mp_asm_base_data(&emit->as->base, 1, 0x80 | ((emit->n_state >> 7) & 0x7f)); - mp_asm_base_data(&emit->as->base, 1, emit->n_state & 0x7f); - mp_asm_base_data(&emit->as->base, 1, 0); // n_exc_stack - mp_asm_base_data(&emit->as->base, 1, emit->scope->scope_flags); - mp_asm_base_data(&emit->as->base, 1, emit->scope->num_pos_args); - mp_asm_base_data(&emit->as->base, 1, emit->scope->num_kwonly_args); - mp_asm_base_data(&emit->as->base, 1, emit->scope->num_def_pos_args); - - // write code info - #if MICROPY_PERSISTENT_CODE - mp_asm_base_data(&emit->as->base, 1, 5); - mp_asm_base_data(&emit->as->base, 1, emit->scope->simple_name); - mp_asm_base_data(&emit->as->base, 1, emit->scope->simple_name >> 8); - mp_asm_base_data(&emit->as->base, 1, emit->scope->source_file); - mp_asm_base_data(&emit->as->base, 1, emit->scope->source_file >> 8); - #else - mp_asm_base_data(&emit->as->base, 1, 1); - #endif - - // bytecode prelude: initialise closed over variables - for (int i = 0; i < emit->scope->id_info_len; i++) { - id_info_t *id = &emit->scope->id_info[i]; - if (id->kind == ID_INFO_KIND_CELL) { - assert(id->local_num < 255); - mp_asm_base_data(&emit->as->base, 1, id->local_num); // write the local which should be converted to a cell - } - } - mp_asm_base_data(&emit->as->base, 1, 255); // end of list sentinel - - mp_asm_base_align(&emit->as->base, ASM_WORD_SIZE); - emit->const_table_offset = mp_asm_base_get_code_pos(&emit->as->base); - - // write argument names as qstr objects - // see comment in corresponding part of emitbc.c about the logic here - for (int i = 0; i < emit->scope->num_pos_args + emit->scope->num_kwonly_args; i++) { - qstr qst = MP_QSTR__star_; - for (int j = 0; j < emit->scope->id_info_len; ++j) { - id_info_t *id = &emit->scope->id_info[j]; - if ((id->flags & ID_FLAG_IS_PARAM) && id->local_num == i) { - qst = id->qst; - break; - } - } - mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (mp_uint_t)MP_OBJ_NEW_QSTR(qst)); - } - - } - - ASM_END_PASS(emit->as); - - // check stack is back to zero size - assert(emit->stack_size == 0); - - if (emit->pass == MP_PASS_EMIT) { - void *f = mp_asm_base_get_code(&emit->as->base); - mp_uint_t f_len = mp_asm_base_get_code_size(&emit->as->base); - - // compute type signature - // note that the lower 4 bits of a vtype are tho correct MP_NATIVE_TYPE_xxx - mp_uint_t type_sig = emit->return_vtype & 0xf; - for (mp_uint_t i = 0; i < emit->scope->num_pos_args; i++) { - type_sig |= (emit->local_vtype[i] & 0xf) << (i * 4 + 4); - } - - mp_emit_glue_assign_native(emit->scope->raw_code, - emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY, - f, f_len, (mp_uint_t*)((byte*)f + emit->const_table_offset), - emit->scope->num_pos_args, emit->scope->scope_flags, type_sig); - } -} - -STATIC bool emit_native_last_emit_was_return_value(emit_t *emit) { - return emit->last_emit_was_return_value; -} - -STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) { - assert((mp_int_t)emit->stack_size + stack_size_delta >= 0); - emit->stack_size += stack_size_delta; - if (emit->pass > MP_PASS_SCOPE && emit->stack_size > emit->scope->stack_size) { - emit->scope->stack_size = emit->stack_size; - } -#ifdef DEBUG_PRINT - DEBUG_printf(" adjust_stack; stack_size=%d+%d; stack now:", emit->stack_size - stack_size_delta, stack_size_delta); - for (int i = 0; i < emit->stack_size; i++) { - stack_info_t *si = &emit->stack_info[i]; - DEBUG_printf(" (v=%d k=%d %d)", si->vtype, si->kind, si->data.u_reg); - } - DEBUG_printf("\n"); -#endif -} - -STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) { - DEBUG_printf("adjust_stack_size(" INT_FMT ")\n", delta); - // If we are adjusting the stack in a positive direction (pushing) then we - // need to fill in values for the stack kind and vtype of the newly-pushed - // entries. These should be set to "value" (ie not reg or imm) because we - // should only need to adjust the stack due to a jump to this part in the - // code (and hence we have settled the stack before the jump). - for (mp_int_t i = 0; i < delta; i++) { - stack_info_t *si = &emit->stack_info[emit->stack_size + i]; - si->kind = STACK_VALUE; - // TODO we don't know the vtype to use here. At the moment this is a - // hack to get the case of multi comparison working. - if (delta == 1) { - si->vtype = emit->saved_stack_vtype; - } else { - si->vtype = VTYPE_PYOBJ; - } - } - adjust_stack(emit, delta); -} - -STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) { - (void)emit; - (void)source_line; -} - -// this must be called at start of emit functions -STATIC void emit_native_pre(emit_t *emit) { - emit->last_emit_was_return_value = false; -} - -// depth==0 is top, depth==1 is before top, etc -STATIC stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) { - return &emit->stack_info[emit->stack_size - 1 - depth]; -} - -// depth==0 is top, depth==1 is before top, etc -STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) { - return peek_stack(emit, depth)->vtype; -} - -// pos=1 is TOS, pos=2 is next, etc -// use pos=0 for no skipping -STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) { - skip_stack_pos = emit->stack_size - skip_stack_pos; - for (int i = 0; i < emit->stack_size; i++) { - if (i != skip_stack_pos) { - stack_info_t *si = &emit->stack_info[i]; - if (si->kind == STACK_REG && si->data.u_reg == reg_needed) { - si->kind = STACK_VALUE; - ASM_MOV_REG_TO_LOCAL(emit->as, si->data.u_reg, emit->stack_start + i); - } - } - } -} - -STATIC void need_reg_all(emit_t *emit) { - for (int i = 0; i < emit->stack_size; i++) { - stack_info_t *si = &emit->stack_info[i]; - if (si->kind == STACK_REG) { - si->kind = STACK_VALUE; - ASM_MOV_REG_TO_LOCAL(emit->as, si->data.u_reg, emit->stack_start + i); - } - } -} - -STATIC void need_stack_settled(emit_t *emit) { - DEBUG_printf(" need_stack_settled; stack_size=%d\n", emit->stack_size); - for (int i = 0; i < emit->stack_size; i++) { - stack_info_t *si = &emit->stack_info[i]; - if (si->kind == STACK_REG) { - DEBUG_printf(" reg(%u) to local(%u)\n", si->data.u_reg, emit->stack_start + i); - si->kind = STACK_VALUE; - ASM_MOV_REG_TO_LOCAL(emit->as, si->data.u_reg, emit->stack_start + i); - } - } - for (int i = 0; i < emit->stack_size; i++) { - stack_info_t *si = &emit->stack_info[i]; - if (si->kind == STACK_IMM) { - DEBUG_printf(" imm(" INT_FMT ") to local(%u)\n", si->data.u_imm, emit->stack_start + i); - si->kind = STACK_VALUE; - ASM_MOV_IMM_TO_LOCAL_USING(emit->as, si->data.u_imm, emit->stack_start + i, REG_TEMP0); - } - } -} - -// pos=1 is TOS, pos=2 is next, etc -STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int reg_dest) { - need_reg_single(emit, reg_dest, pos); - stack_info_t *si = &emit->stack_info[emit->stack_size - pos]; - *vtype = si->vtype; - switch (si->kind) { - case STACK_VALUE: - ASM_MOV_LOCAL_TO_REG(emit->as, emit->stack_start + emit->stack_size - pos, reg_dest); - break; - - case STACK_REG: - if (si->data.u_reg != reg_dest) { - ASM_MOV_REG_REG(emit->as, reg_dest, si->data.u_reg); - } - break; - - case STACK_IMM: - ASM_MOV_IMM_TO_REG(emit->as, si->data.u_imm, reg_dest); - break; - } -} - -// does an efficient X=pop(); discard(); push(X) -// needs a (non-temp) register in case the poped element was stored in the stack -STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) { - stack_info_t *si = &emit->stack_info[emit->stack_size - 2]; - si[0] = si[1]; - if (si->kind == STACK_VALUE) { - // if folded element was on the stack we need to put it in a register - ASM_MOV_LOCAL_TO_REG(emit->as, emit->stack_start + emit->stack_size - 1, reg_dest); - si->kind = STACK_REG; - si->data.u_reg = reg_dest; - } - adjust_stack(emit, -1); -} - -// If stacked value is in a register and the register is not r1 or r2, then -// *reg_dest is set to that register. Otherwise the value is put in *reg_dest. -STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *reg_dest, int not_r1, int not_r2) { - emit->last_emit_was_return_value = false; - stack_info_t *si = peek_stack(emit, 0); - if (si->kind == STACK_REG && si->data.u_reg != not_r1 && si->data.u_reg != not_r2) { - *vtype = si->vtype; - *reg_dest = si->data.u_reg; - need_reg_single(emit, *reg_dest, 1); - } else { - emit_access_stack(emit, 1, vtype, *reg_dest); - } - adjust_stack(emit, -1); -} - -STATIC void emit_pre_pop_discard(emit_t *emit) { - emit->last_emit_was_return_value = false; - adjust_stack(emit, -1); -} - -STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest) { - emit->last_emit_was_return_value = false; - emit_access_stack(emit, 1, vtype, reg_dest); - adjust_stack(emit, -1); -} - -STATIC void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb) { - emit_pre_pop_reg(emit, vtypea, rega); - emit_pre_pop_reg(emit, vtypeb, regb); -} - -STATIC void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb, vtype_kind_t *vtypec, int regc) { - emit_pre_pop_reg(emit, vtypea, rega); - emit_pre_pop_reg(emit, vtypeb, regb); - emit_pre_pop_reg(emit, vtypec, regc); -} - -STATIC void emit_post(emit_t *emit) { - (void)emit; -} - -STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) { - stack_info_t *si = &emit->stack_info[emit->stack_size - 1]; - si->vtype = new_vtype; -} - -STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) { - stack_info_t *si = &emit->stack_info[emit->stack_size]; - si->vtype = vtype; - si->kind = STACK_REG; - si->data.u_reg = reg; - adjust_stack(emit, 1); -} - -STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) { - stack_info_t *si = &emit->stack_info[emit->stack_size]; - si->vtype = vtype; - si->kind = STACK_IMM; - si->data.u_imm = imm; - adjust_stack(emit, 1); -} - -STATIC void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb) { - emit_post_push_reg(emit, vtypea, rega); - emit_post_push_reg(emit, vtypeb, regb); -} - -STATIC void emit_post_push_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc) { - emit_post_push_reg(emit, vtypea, rega); - emit_post_push_reg(emit, vtypeb, regb); - emit_post_push_reg(emit, vtypec, regc); -} - -STATIC void emit_post_push_reg_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc, vtype_kind_t vtyped, int regd) { - emit_post_push_reg(emit, vtypea, rega); - emit_post_push_reg(emit, vtypeb, regb); - emit_post_push_reg(emit, vtypec, regc); - emit_post_push_reg(emit, vtyped, regd); -} - -STATIC void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) { - need_reg_all(emit); - ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); -} - -STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) { - need_reg_all(emit); - ASM_MOV_IMM_TO_REG(emit->as, arg_val, arg_reg); - ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); -} - -// the first arg is stored in the code aligned on a mp_uint_t boundary -STATIC void emit_call_with_imm_arg_aligned(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) { - need_reg_all(emit); - ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, arg_val, arg_reg); - ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); -} - -STATIC void emit_call_with_2_imm_args(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val1, int arg_reg1, mp_int_t arg_val2, int arg_reg2) { - need_reg_all(emit); - ASM_MOV_IMM_TO_REG(emit->as, arg_val1, arg_reg1); - ASM_MOV_IMM_TO_REG(emit->as, arg_val2, arg_reg2); - ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); -} - -// the first arg is stored in the code aligned on a mp_uint_t boundary -STATIC void emit_call_with_3_imm_args_and_first_aligned(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val1, int arg_reg1, mp_int_t arg_val2, int arg_reg2, mp_int_t arg_val3, int arg_reg3) { - need_reg_all(emit); - ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, arg_val1, arg_reg1); - ASM_MOV_IMM_TO_REG(emit->as, arg_val2, arg_reg2); - ASM_MOV_IMM_TO_REG(emit->as, arg_val3, arg_reg3); - ASM_CALL_IND(emit->as, mp_fun_table[fun_kind], fun_kind); -} - -// vtype of all n_pop objects is VTYPE_PYOBJ -// Will convert any items that are not VTYPE_PYOBJ to this type and put them back on the stack. -// If any conversions of non-immediate values are needed, then it uses REG_ARG_1, REG_ARG_2 and REG_RET. -// Otherwise, it does not use any temporary registers (but may use reg_dest before loading it with stack pointer). -STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_pop) { - need_reg_all(emit); - - // First, store any immediate values to their respective place on the stack. - for (mp_uint_t i = 0; i < n_pop; i++) { - stack_info_t *si = &emit->stack_info[emit->stack_size - 1 - i]; - // must push any imm's to stack - // must convert them to VTYPE_PYOBJ for viper code - if (si->kind == STACK_IMM) { - si->kind = STACK_VALUE; - switch (si->vtype) { - case VTYPE_PYOBJ: - ASM_MOV_IMM_TO_LOCAL_USING(emit->as, si->data.u_imm, emit->stack_start + emit->stack_size - 1 - i, reg_dest); - break; - case VTYPE_BOOL: - if (si->data.u_imm == 0) { - ASM_MOV_IMM_TO_LOCAL_USING(emit->as, (mp_uint_t)mp_const_false, emit->stack_start + emit->stack_size - 1 - i, reg_dest); - } else { - ASM_MOV_IMM_TO_LOCAL_USING(emit->as, (mp_uint_t)mp_const_true, emit->stack_start + emit->stack_size - 1 - i, reg_dest); - } - si->vtype = VTYPE_PYOBJ; - break; - case VTYPE_INT: - case VTYPE_UINT: - ASM_MOV_IMM_TO_LOCAL_USING(emit->as, (uintptr_t)MP_OBJ_NEW_SMALL_INT(si->data.u_imm), emit->stack_start + emit->stack_size - 1 - i, reg_dest); - si->vtype = VTYPE_PYOBJ; - break; - default: - // not handled - mp_raise_NotImplementedError("conversion to object"); - } - } - - // verify that this value is on the stack - assert(si->kind == STACK_VALUE); - } - - // Second, convert any non-VTYPE_PYOBJ to that type. - for (mp_uint_t i = 0; i < n_pop; i++) { - stack_info_t *si = &emit->stack_info[emit->stack_size - 1 - i]; - if (si->vtype != VTYPE_PYOBJ) { - mp_uint_t local_num = emit->stack_start + emit->stack_size - 1 - i; - ASM_MOV_LOCAL_TO_REG(emit->as, local_num, REG_ARG_1); - emit_call_with_imm_arg(emit, MP_F_CONVERT_NATIVE_TO_OBJ, si->vtype, REG_ARG_2); // arg2 = type - ASM_MOV_REG_TO_LOCAL(emit->as, REG_RET, local_num); - si->vtype = VTYPE_PYOBJ; - DEBUG_printf(" convert_native_to_obj(local_num=" UINT_FMT ")\n", local_num); - } - } - - // Adujust the stack for a pop of n_pop items, and load the stack pointer into reg_dest. - adjust_stack(emit, -n_pop); - ASM_MOV_LOCAL_ADDR_TO_REG(emit->as, emit->stack_start + emit->stack_size, reg_dest); -} - -// vtype of all n_push objects is VTYPE_PYOBJ -STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_push) { - need_reg_all(emit); - for (mp_uint_t i = 0; i < n_push; i++) { - emit->stack_info[emit->stack_size + i].kind = STACK_VALUE; - emit->stack_info[emit->stack_size + i].vtype = VTYPE_PYOBJ; - } - ASM_MOV_LOCAL_ADDR_TO_REG(emit->as, emit->stack_start + emit->stack_size, reg_dest); - adjust_stack(emit, n_push); -} - -STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) { - DEBUG_printf("label_assign(" UINT_FMT ")\n", l); - emit_native_pre(emit); - // need to commit stack because we can jump here from elsewhere - need_stack_settled(emit); - mp_asm_base_label_assign(&emit->as->base, l); - emit_post(emit); -} - -STATIC void emit_native_import_name(emit_t *emit, qstr qst) { - DEBUG_printf("import_name %s\n", qstr_str(qst)); - - // get arguments from stack: arg2 = fromlist, arg3 = level - // if using viper types these arguments must be converted to proper objects - if (emit->do_viper_types) { - // fromlist should be None or a tuple - stack_info_t *top = peek_stack(emit, 0); - if (top->vtype == VTYPE_PTR_NONE) { - emit_pre_pop_discard(emit); - ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)mp_const_none, REG_ARG_2); - } else { - vtype_kind_t vtype_fromlist; - emit_pre_pop_reg(emit, &vtype_fromlist, REG_ARG_2); - assert(vtype_fromlist == VTYPE_PYOBJ); - } - - // level argument should be an immediate integer - top = peek_stack(emit, 0); - assert(top->vtype == VTYPE_INT && top->kind == STACK_IMM); - ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)MP_OBJ_NEW_SMALL_INT(top->data.u_imm), REG_ARG_3); - emit_pre_pop_discard(emit); - - } else { - vtype_kind_t vtype_fromlist; - vtype_kind_t vtype_level; - emit_pre_pop_reg_reg(emit, &vtype_fromlist, REG_ARG_2, &vtype_level, REG_ARG_3); - assert(vtype_fromlist == VTYPE_PYOBJ); - assert(vtype_level == VTYPE_PYOBJ); - } - - emit_call_with_imm_arg(emit, MP_F_IMPORT_NAME, qst, REG_ARG_1); // arg1 = import name - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_import_from(emit_t *emit, qstr qst) { - DEBUG_printf("import_from %s\n", qstr_str(qst)); - emit_native_pre(emit); - vtype_kind_t vtype_module; - emit_access_stack(emit, 1, &vtype_module, REG_ARG_1); // arg1 = module - assert(vtype_module == VTYPE_PYOBJ); - emit_call_with_imm_arg(emit, MP_F_IMPORT_FROM, qst, REG_ARG_2); // arg2 = import name - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_import_star(emit_t *emit) { - DEBUG_printf("import_star\n"); - vtype_kind_t vtype_module; - emit_pre_pop_reg(emit, &vtype_module, REG_ARG_1); // arg1 = module - assert(vtype_module == VTYPE_PYOBJ); - emit_call(emit, MP_F_IMPORT_ALL); - emit_post(emit); -} - -STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) { - DEBUG_printf("load_const_tok(tok=%u)\n", tok); - emit_native_pre(emit); - vtype_kind_t vtype; - mp_uint_t val; - if (emit->do_viper_types) { - switch (tok) { - case MP_TOKEN_KW_NONE: vtype = VTYPE_PTR_NONE; val = 0; break; - case MP_TOKEN_KW_FALSE: vtype = VTYPE_BOOL; val = 0; break; - case MP_TOKEN_KW_TRUE: vtype = VTYPE_BOOL; val = 1; break; - default: - assert(tok == MP_TOKEN_ELLIPSIS); - vtype = VTYPE_PYOBJ; val = (mp_uint_t)&mp_const_ellipsis_obj; break; - } - } else { - vtype = VTYPE_PYOBJ; - switch (tok) { - case MP_TOKEN_KW_NONE: val = (mp_uint_t)mp_const_none; break; - case MP_TOKEN_KW_FALSE: val = (mp_uint_t)mp_const_false; break; - case MP_TOKEN_KW_TRUE: val = (mp_uint_t)mp_const_true; break; - default: - assert(tok == MP_TOKEN_ELLIPSIS); - val = (mp_uint_t)&mp_const_ellipsis_obj; break; - } - } - emit_post_push_imm(emit, vtype, val); -} - -STATIC void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) { - DEBUG_printf("load_const_small_int(int=" INT_FMT ")\n", arg); - emit_native_pre(emit); - if (emit->do_viper_types) { - emit_post_push_imm(emit, VTYPE_INT, arg); - } else { - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)MP_OBJ_NEW_SMALL_INT(arg)); - } -} - -STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) { - emit_native_pre(emit); - // TODO: Eventually we want to be able to work with raw pointers in viper to - // do native array access. For now we just load them as any other object. - /* - if (emit->do_viper_types) { - // load a pointer to the asciiz string? - emit_post_push_imm(emit, VTYPE_PTR, (mp_uint_t)qstr_str(qst)); - } else - */ - { - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)MP_OBJ_NEW_QSTR(qst)); - } -} - -STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) { - emit_native_pre(emit); - need_reg_single(emit, REG_RET, 0); - ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, (mp_uint_t)obj, REG_RET); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_load_null(emit_t *emit) { - emit_native_pre(emit); - emit_post_push_imm(emit, VTYPE_PYOBJ, 0); -} - -STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - DEBUG_printf("load_fast(%s, " UINT_FMT ")\n", qstr_str(qst), local_num); - vtype_kind_t vtype = emit->local_vtype[local_num]; - if (vtype == VTYPE_UNBOUND) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "local '%q' used before type known", qst); - } - emit_native_pre(emit); - if (local_num == 0) { - emit_post_push_reg(emit, vtype, REG_LOCAL_1); - } else if (local_num == 1) { - emit_post_push_reg(emit, vtype, REG_LOCAL_2); - } else if (local_num == 2) { - emit_post_push_reg(emit, vtype, REG_LOCAL_3); - } else { - need_reg_single(emit, REG_TEMP0, 0); - if (emit->do_viper_types) { - ASM_MOV_LOCAL_TO_REG(emit->as, local_num - REG_LOCAL_NUM, REG_TEMP0); - } else { - ASM_MOV_LOCAL_TO_REG(emit->as, STATE_START + emit->n_state - 1 - local_num, REG_TEMP0); - } - emit_post_push_reg(emit, vtype, REG_TEMP0); - } -} - -STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - DEBUG_printf("load_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num); - need_reg_single(emit, REG_RET, 0); - emit_native_load_fast(emit, qst, local_num); - vtype_kind_t vtype; - int reg_base = REG_RET; - emit_pre_pop_reg_flexible(emit, &vtype, ®_base, -1, -1); - ASM_LOAD_REG_REG_OFFSET(emit->as, REG_RET, reg_base, 1); - // closed over vars are always Python objects - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_load_name(emit_t *emit, qstr qst) { - DEBUG_printf("load_name(%s)\n", qstr_str(qst)); - emit_native_pre(emit); - emit_call_with_imm_arg(emit, MP_F_LOAD_NAME, qst, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_load_global(emit_t *emit, qstr qst) { - DEBUG_printf("load_global(%s)\n", qstr_str(qst)); - emit_native_pre(emit); - // check for builtin casting operators - if (emit->do_viper_types && qst == MP_QSTR_int) { - emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_INT); - } else if (emit->do_viper_types && qst == MP_QSTR_uint) { - emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_UINT); - } else if (emit->do_viper_types && qst == MP_QSTR_ptr) { - emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR); - } else if (emit->do_viper_types && qst == MP_QSTR_ptr8) { - emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR8); - } else if (emit->do_viper_types && qst == MP_QSTR_ptr16) { - emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR16); - } else if (emit->do_viper_types && qst == MP_QSTR_ptr32) { - emit_post_push_imm(emit, VTYPE_BUILTIN_CAST, VTYPE_PTR32); - } else { - emit_call_with_imm_arg(emit, MP_F_LOAD_GLOBAL, qst, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } -} - -STATIC void emit_native_load_attr(emit_t *emit, qstr qst) { - // depends on type of subject: - // - integer, function, pointer to integers: error - // - pointer to structure: get member, quite easy - // - Python object: call mp_load_attr, and needs to be typed to convert result - vtype_kind_t vtype_base; - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base - assert(vtype_base == VTYPE_PYOBJ); - emit_call_with_imm_arg(emit, MP_F_LOAD_ATTR, qst, REG_ARG_2); // arg2 = attribute name - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) { - if (is_super) { - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, 3); // arg2 = dest ptr - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_2, 2); // arg2 = dest ptr - emit_call_with_imm_arg(emit, MP_F_LOAD_SUPER_METHOD, qst, REG_ARG_1); // arg1 = method name - } else { - vtype_kind_t vtype_base; - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base - assert(vtype_base == VTYPE_PYOBJ); - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, 2); // arg3 = dest ptr - emit_call_with_imm_arg(emit, MP_F_LOAD_METHOD, qst, REG_ARG_2); // arg2 = method name - } -} - -STATIC void emit_native_load_build_class(emit_t *emit) { - emit_native_pre(emit); - emit_call(emit, MP_F_LOAD_BUILD_CLASS); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_load_subscr(emit_t *emit) { - DEBUG_printf("load_subscr\n"); - // need to compile: base[index] - - // pop: index, base - // optimise case where index is an immediate - vtype_kind_t vtype_base = peek_vtype(emit, 1); - - if (vtype_base == VTYPE_PYOBJ) { - // standard Python subscr - // TODO factor this implicit cast code with other uses of it - vtype_kind_t vtype_index = peek_vtype(emit, 0); - if (vtype_index == VTYPE_PYOBJ) { - emit_pre_pop_reg(emit, &vtype_index, REG_ARG_2); - } else { - emit_pre_pop_reg(emit, &vtype_index, REG_ARG_1); - emit_call_with_imm_arg(emit, MP_F_CONVERT_NATIVE_TO_OBJ, vtype_index, REG_ARG_2); // arg2 = type - ASM_MOV_REG_REG(emit->as, REG_ARG_2, REG_RET); - } - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); - emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_SENTINEL, REG_ARG_3); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } else { - // viper load - // TODO The different machine architectures have very different - // capabilities and requirements for loads, so probably best to - // write a completely separate load-optimiser for each one. - stack_info_t *top = peek_stack(emit, 0); - if (top->vtype == VTYPE_INT && top->kind == STACK_IMM) { - // index is an immediate - mp_int_t index_value = top->data.u_imm; - emit_pre_pop_discard(emit); // discard index - int reg_base = REG_ARG_1; - int reg_index = REG_ARG_2; - emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_index); - switch (vtype_base) { - case VTYPE_PTR8: { - // pointer to 8-bit memory - // TODO optimise to use thumb ldrb r1, [r2, r3] - if (index_value != 0) { - // index is non-zero - #if N_THUMB - if (index_value > 0 && index_value < 32) { - asm_thumb_ldrb_rlo_rlo_i5(emit->as, REG_RET, reg_base, index_value); - break; - } - #endif - ASM_MOV_IMM_TO_REG(emit->as, index_value, reg_index); - ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add index to base - reg_base = reg_index; - } - ASM_LOAD8_REG_REG(emit->as, REG_RET, reg_base); // load from (base+index) - break; - } - case VTYPE_PTR16: { - // pointer to 16-bit memory - if (index_value != 0) { - // index is a non-zero immediate - #if N_THUMB - if (index_value > 0 && index_value < 32) { - asm_thumb_ldrh_rlo_rlo_i5(emit->as, REG_RET, reg_base, index_value); - break; - } - #endif - ASM_MOV_IMM_TO_REG(emit->as, index_value << 1, reg_index); - ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 2*index to base - reg_base = reg_index; - } - ASM_LOAD16_REG_REG(emit->as, REG_RET, reg_base); // load from (base+2*index) - break; - } - case VTYPE_PTR32: { - // pointer to 32-bit memory - if (index_value != 0) { - // index is a non-zero immediate - #if N_THUMB - if (index_value > 0 && index_value < 32) { - asm_thumb_ldr_rlo_rlo_i5(emit->as, REG_RET, reg_base, index_value); - break; - } - #endif - ASM_MOV_IMM_TO_REG(emit->as, index_value << 2, reg_index); - ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 4*index to base - reg_base = reg_index; - } - ASM_LOAD32_REG_REG(emit->as, REG_RET, reg_base); // load from (base+4*index) - break; - } - default: - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't load from '%q'", vtype_to_qstr(vtype_base)); - } - } else { - // index is not an immediate - vtype_kind_t vtype_index; - int reg_index = REG_ARG_2; - emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, REG_ARG_1); - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); - if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't load with '%q' index", vtype_to_qstr(vtype_index)); - } - switch (vtype_base) { - case VTYPE_PTR8: { - // pointer to 8-bit memory - // TODO optimise to use thumb ldrb r1, [r2, r3] - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_LOAD8_REG_REG(emit->as, REG_RET, REG_ARG_1); // store value to (base+index) - break; - } - case VTYPE_PTR16: { - // pointer to 16-bit memory - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_LOAD16_REG_REG(emit->as, REG_RET, REG_ARG_1); // load from (base+2*index) - break; - } - case VTYPE_PTR32: { - // pointer to word-size memory - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_LOAD32_REG_REG(emit->as, REG_RET, REG_ARG_1); // load from (base+4*index) - break; - } - default: - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't load from '%q'", vtype_to_qstr(vtype_base)); - } - } - emit_post_push_reg(emit, VTYPE_INT, REG_RET); - } -} - -STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - vtype_kind_t vtype; - if (local_num == 0) { - emit_pre_pop_reg(emit, &vtype, REG_LOCAL_1); - } else if (local_num == 1) { - emit_pre_pop_reg(emit, &vtype, REG_LOCAL_2); - } else if (local_num == 2) { - emit_pre_pop_reg(emit, &vtype, REG_LOCAL_3); - } else { - emit_pre_pop_reg(emit, &vtype, REG_TEMP0); - if (emit->do_viper_types) { - ASM_MOV_REG_TO_LOCAL(emit->as, REG_TEMP0, local_num - REG_LOCAL_NUM); - } else { - ASM_MOV_REG_TO_LOCAL(emit->as, REG_TEMP0, STATE_START + emit->n_state - 1 - local_num); - } - } - emit_post(emit); - - // check types - if (emit->local_vtype[local_num] == VTYPE_UNBOUND) { - // first time this local is assigned, so give it a type of the object stored in it - emit->local_vtype[local_num] = vtype; - } else if (emit->local_vtype[local_num] != vtype) { - // type of local is not the same as object stored in it - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "local '%q' has type '%q' but source is '%q'", - qst, vtype_to_qstr(emit->local_vtype[local_num]), vtype_to_qstr(vtype)); - } -} - -STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - DEBUG_printf("store_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num); - need_reg_single(emit, REG_TEMP0, 0); - need_reg_single(emit, REG_TEMP1, 0); - emit_native_load_fast(emit, qst, local_num); - vtype_kind_t vtype; - int reg_base = REG_TEMP0; - emit_pre_pop_reg_flexible(emit, &vtype, ®_base, -1, -1); - int reg_src = REG_TEMP1; - emit_pre_pop_reg_flexible(emit, &vtype, ®_src, reg_base, reg_base); - ASM_STORE_REG_REG_OFFSET(emit->as, reg_src, reg_base, 1); - emit_post(emit); -} - -STATIC void emit_native_store_name(emit_t *emit, qstr qst) { - // mp_store_name, but needs conversion of object (maybe have mp_viper_store_name(obj, type)) - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_ARG_2); - assert(vtype == VTYPE_PYOBJ); - emit_call_with_imm_arg(emit, MP_F_STORE_NAME, qst, REG_ARG_1); // arg1 = name - emit_post(emit); -} - -STATIC void emit_native_store_global(emit_t *emit, qstr qst) { - vtype_kind_t vtype = peek_vtype(emit, 0); - if (vtype == VTYPE_PYOBJ) { - emit_pre_pop_reg(emit, &vtype, REG_ARG_2); - } else { - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); - emit_call_with_imm_arg(emit, MP_F_CONVERT_NATIVE_TO_OBJ, vtype, REG_ARG_2); // arg2 = type - ASM_MOV_REG_REG(emit->as, REG_ARG_2, REG_RET); - } - emit_call_with_imm_arg(emit, MP_F_STORE_GLOBAL, qst, REG_ARG_1); // arg1 = name - emit_post(emit); -} - -STATIC void emit_native_store_attr(emit_t *emit, qstr qst) { - vtype_kind_t vtype_base, vtype_val; - emit_pre_pop_reg_reg(emit, &vtype_base, REG_ARG_1, &vtype_val, REG_ARG_3); // arg1 = base, arg3 = value - assert(vtype_base == VTYPE_PYOBJ); - assert(vtype_val == VTYPE_PYOBJ); - emit_call_with_imm_arg(emit, MP_F_STORE_ATTR, qst, REG_ARG_2); // arg2 = attribute name - emit_post(emit); -} - -STATIC void emit_native_store_subscr(emit_t *emit) { - DEBUG_printf("store_subscr\n"); - // need to compile: base[index] = value - - // pop: index, base, value - // optimise case where index is an immediate - vtype_kind_t vtype_base = peek_vtype(emit, 1); - - if (vtype_base == VTYPE_PYOBJ) { - // standard Python subscr - vtype_kind_t vtype_index = peek_vtype(emit, 0); - vtype_kind_t vtype_value = peek_vtype(emit, 2); - if (vtype_index != VTYPE_PYOBJ || vtype_value != VTYPE_PYOBJ) { - // need to implicitly convert non-objects to objects - // TODO do this properly - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, 3); - adjust_stack(emit, 3); - } - emit_pre_pop_reg_reg_reg(emit, &vtype_index, REG_ARG_2, &vtype_base, REG_ARG_1, &vtype_value, REG_ARG_3); - emit_call(emit, MP_F_OBJ_SUBSCR); - } else { - // viper store - // TODO The different machine architectures have very different - // capabilities and requirements for stores, so probably best to - // write a completely separate store-optimiser for each one. - stack_info_t *top = peek_stack(emit, 0); - if (top->vtype == VTYPE_INT && top->kind == STACK_IMM) { - // index is an immediate - mp_int_t index_value = top->data.u_imm; - emit_pre_pop_discard(emit); // discard index - vtype_kind_t vtype_value; - int reg_base = REG_ARG_1; - int reg_index = REG_ARG_2; - int reg_value = REG_ARG_3; - emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_value); - #if N_X86 - // special case: x86 needs byte stores to be from lower 4 regs (REG_ARG_3 is EDX) - emit_pre_pop_reg(emit, &vtype_value, reg_value); - #else - emit_pre_pop_reg_flexible(emit, &vtype_value, ®_value, reg_base, reg_index); - #endif - if (vtype_value != VTYPE_BOOL && vtype_value != VTYPE_INT && vtype_value != VTYPE_UINT) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't store '%q'", vtype_to_qstr(vtype_value)); - } - switch (vtype_base) { - case VTYPE_PTR8: { - // pointer to 8-bit memory - // TODO optimise to use thumb strb r1, [r2, r3] - if (index_value != 0) { - // index is non-zero - #if N_THUMB - if (index_value > 0 && index_value < 32) { - asm_thumb_strb_rlo_rlo_i5(emit->as, reg_value, reg_base, index_value); - break; - } - #endif - ASM_MOV_IMM_TO_REG(emit->as, index_value, reg_index); - #if N_ARM - asm_arm_strb_reg_reg_reg(emit->as, reg_value, reg_base, reg_index); - return; - #endif - ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add index to base - reg_base = reg_index; - } - ASM_STORE8_REG_REG(emit->as, reg_value, reg_base); // store value to (base+index) - break; - } - case VTYPE_PTR16: { - // pointer to 16-bit memory - if (index_value != 0) { - // index is a non-zero immediate - #if N_THUMB - if (index_value > 0 && index_value < 32) { - asm_thumb_strh_rlo_rlo_i5(emit->as, reg_value, reg_base, index_value); - break; - } - #endif - ASM_MOV_IMM_TO_REG(emit->as, index_value << 1, reg_index); - #if N_ARM - asm_arm_strh_reg_reg_reg(emit->as, reg_value, reg_base, reg_index); - return; - #endif - ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 2*index to base - reg_base = reg_index; - } - ASM_STORE16_REG_REG(emit->as, reg_value, reg_base); // store value to (base+2*index) - break; - } - case VTYPE_PTR32: { - // pointer to 32-bit memory - if (index_value != 0) { - // index is a non-zero immediate - #if N_THUMB - if (index_value > 0 && index_value < 32) { - asm_thumb_str_rlo_rlo_i5(emit->as, reg_value, reg_base, index_value); - break; - } - #endif - ASM_MOV_IMM_TO_REG(emit->as, index_value << 2, reg_index); - #if N_ARM - asm_arm_str_reg_reg_reg(emit->as, reg_value, reg_base, reg_index); - return; - #endif - ASM_ADD_REG_REG(emit->as, reg_index, reg_base); // add 4*index to base - reg_base = reg_index; - } - ASM_STORE32_REG_REG(emit->as, reg_value, reg_base); // store value to (base+4*index) - break; - } - default: - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't store to '%q'", vtype_to_qstr(vtype_base)); - } - } else { - // index is not an immediate - vtype_kind_t vtype_index, vtype_value; - int reg_index = REG_ARG_2; - int reg_value = REG_ARG_3; - emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, reg_value); - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); - if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't store with '%q' index", vtype_to_qstr(vtype_index)); - } - #if N_X86 - // special case: x86 needs byte stores to be from lower 4 regs (REG_ARG_3 is EDX) - emit_pre_pop_reg(emit, &vtype_value, reg_value); - #else - emit_pre_pop_reg_flexible(emit, &vtype_value, ®_value, REG_ARG_1, reg_index); - #endif - if (vtype_value != VTYPE_BOOL && vtype_value != VTYPE_INT && vtype_value != VTYPE_UINT) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't store '%q'", vtype_to_qstr(vtype_value)); - } - switch (vtype_base) { - case VTYPE_PTR8: { - // pointer to 8-bit memory - // TODO optimise to use thumb strb r1, [r2, r3] - #if N_ARM - asm_arm_strb_reg_reg_reg(emit->as, reg_value, REG_ARG_1, reg_index); - break; - #endif - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_STORE8_REG_REG(emit->as, reg_value, REG_ARG_1); // store value to (base+index) - break; - } - case VTYPE_PTR16: { - // pointer to 16-bit memory - #if N_ARM - asm_arm_strh_reg_reg_reg(emit->as, reg_value, REG_ARG_1, reg_index); - break; - #endif - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_STORE16_REG_REG(emit->as, reg_value, REG_ARG_1); // store value to (base+2*index) - break; - } - case VTYPE_PTR32: { - // pointer to 32-bit memory - #if N_ARM - asm_arm_str_reg_reg_reg(emit->as, reg_value, REG_ARG_1, reg_index); - break; - #endif - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_ADD_REG_REG(emit->as, REG_ARG_1, reg_index); // add index to base - ASM_STORE32_REG_REG(emit->as, reg_value, REG_ARG_1); // store value to (base+4*index) - break; - } - default: - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't store to '%q'", vtype_to_qstr(vtype_base)); - } - } - - } -} - -STATIC void emit_native_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - // TODO: This is not compliant implementation. We could use MP_OBJ_SENTINEL - // to mark deleted vars but then every var would need to be checked on - // each access. Very inefficient, so just set value to None to enable GC. - emit_native_load_const_tok(emit, MP_TOKEN_KW_NONE); - emit_native_store_fast(emit, qst, local_num); -} - -STATIC void emit_native_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { - // TODO implement me! - (void)emit; - (void)qst; - (void)local_num; -} - -STATIC void emit_native_delete_name(emit_t *emit, qstr qst) { - emit_native_pre(emit); - emit_call_with_imm_arg(emit, MP_F_DELETE_NAME, qst, REG_ARG_1); - emit_post(emit); -} - -STATIC void emit_native_delete_global(emit_t *emit, qstr qst) { - emit_native_pre(emit); - emit_call_with_imm_arg(emit, MP_F_DELETE_GLOBAL, qst, REG_ARG_1); - emit_post(emit); -} - -STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) { - vtype_kind_t vtype_base; - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base - assert(vtype_base == VTYPE_PYOBJ); - emit_call_with_2_imm_args(emit, MP_F_STORE_ATTR, qst, REG_ARG_2, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); // arg2 = attribute name, arg3 = value (null for delete) - emit_post(emit); -} - -STATIC void emit_native_delete_subscr(emit_t *emit) { - vtype_kind_t vtype_index, vtype_base; - emit_pre_pop_reg_reg(emit, &vtype_index, REG_ARG_2, &vtype_base, REG_ARG_1); // index, base - assert(vtype_index == VTYPE_PYOBJ); - assert(vtype_base == VTYPE_PYOBJ); - emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); -} - -STATIC void emit_native_dup_top(emit_t *emit) { - DEBUG_printf("dup_top\n"); - vtype_kind_t vtype; - int reg = REG_TEMP0; - emit_pre_pop_reg_flexible(emit, &vtype, ®, -1, -1); - emit_post_push_reg_reg(emit, vtype, reg, vtype, reg); -} - -STATIC void emit_native_dup_top_two(emit_t *emit) { - vtype_kind_t vtype0, vtype1; - emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1); - emit_post_push_reg_reg_reg_reg(emit, vtype1, REG_TEMP1, vtype0, REG_TEMP0, vtype1, REG_TEMP1, vtype0, REG_TEMP0); -} - -STATIC void emit_native_pop_top(emit_t *emit) { - DEBUG_printf("pop_top\n"); - emit_pre_pop_discard(emit); - emit_post(emit); -} - -STATIC void emit_native_rot_two(emit_t *emit) { - DEBUG_printf("rot_two\n"); - vtype_kind_t vtype0, vtype1; - emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1); - emit_post_push_reg_reg(emit, vtype0, REG_TEMP0, vtype1, REG_TEMP1); -} - -STATIC void emit_native_rot_three(emit_t *emit) { - DEBUG_printf("rot_three\n"); - vtype_kind_t vtype0, vtype1, vtype2; - emit_pre_pop_reg_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1, &vtype2, REG_TEMP2); - emit_post_push_reg_reg_reg(emit, vtype0, REG_TEMP0, vtype2, REG_TEMP2, vtype1, REG_TEMP1); -} - -STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) { - DEBUG_printf("jump(label=" UINT_FMT ")\n", label); - emit_native_pre(emit); - // need to commit stack because we are jumping elsewhere - need_stack_settled(emit); - ASM_JUMP(emit->as, label); - emit_post(emit); -} - -STATIC void emit_native_jump_helper(emit_t *emit, bool pop) { - vtype_kind_t vtype = peek_vtype(emit, 0); - if (vtype == VTYPE_PYOBJ) { - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); - if (!pop) { - adjust_stack(emit, 1); - } - emit_call(emit, MP_F_OBJ_IS_TRUE); - } else { - emit_pre_pop_reg(emit, &vtype, REG_RET); - if (!pop) { - adjust_stack(emit, 1); - } - if (!(vtype == VTYPE_BOOL || vtype == VTYPE_INT || vtype == VTYPE_UINT)) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't implicitly convert '%q' to 'bool'", vtype_to_qstr(vtype)); - } - } - // For non-pop need to save the vtype so that emit_native_adjust_stack_size - // can use it. This is a bit of a hack. - if (!pop) { - emit->saved_stack_vtype = vtype; - } - // need to commit stack because we may jump elsewhere - need_stack_settled(emit); -} - -STATIC void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) { - DEBUG_printf("pop_jump_if(cond=%u, label=" UINT_FMT ")\n", cond, label); - emit_native_jump_helper(emit, true); - if (cond) { - ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); - } else { - ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label); - } - emit_post(emit); -} - -STATIC void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) { - DEBUG_printf("jump_if_or_pop(cond=%u, label=" UINT_FMT ")\n", cond, label); - emit_native_jump_helper(emit, false); - if (cond) { - ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); - } else { - ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label); - } - adjust_stack(emit, -1); - emit_post(emit); -} - -STATIC void emit_native_break_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { - (void)except_depth; - emit_native_jump(emit, label & ~MP_EMIT_BREAK_FROM_FOR); // TODO properly -} - -STATIC void emit_native_continue_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) { - (void)except_depth; - emit_native_jump(emit, label); // TODO properly -} - -STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) { - // the context manager is on the top of the stack - // stack: (..., ctx_mgr) - - // get __exit__ method - vtype_kind_t vtype; - emit_access_stack(emit, 1, &vtype, REG_ARG_1); // arg1 = ctx_mgr - assert(vtype == VTYPE_PYOBJ); - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, 2); // arg3 = dest ptr - emit_call_with_imm_arg(emit, MP_F_LOAD_METHOD, MP_QSTR___exit__, REG_ARG_2); - // stack: (..., ctx_mgr, __exit__, self) - - emit_pre_pop_reg(emit, &vtype, REG_ARG_3); // self - emit_pre_pop_reg(emit, &vtype, REG_ARG_2); // __exit__ - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); // ctx_mgr - emit_post_push_reg(emit, vtype, REG_ARG_2); // __exit__ - emit_post_push_reg(emit, vtype, REG_ARG_3); // self - // stack: (..., __exit__, self) - // REG_ARG_1=ctx_mgr - - // get __enter__ method - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, 2); // arg3 = dest ptr - emit_call_with_imm_arg(emit, MP_F_LOAD_METHOD, MP_QSTR___enter__, REG_ARG_2); // arg2 = method name - // stack: (..., __exit__, self, __enter__, self) - - // call __enter__ method - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 2); // pointer to items, including meth and self - emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, 0, REG_ARG_1, 0, REG_ARG_2); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // push return value of __enter__ - // stack: (..., __exit__, self, as_value) - - // need to commit stack because we may jump elsewhere - need_stack_settled(emit); - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_1, sizeof(nlr_buf_t) / sizeof(mp_uint_t)); // arg1 = pointer to nlr buf - emit_call(emit, MP_F_NLR_PUSH); - ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); - - emit_access_stack(emit, sizeof(nlr_buf_t) / sizeof(mp_uint_t) + 1, &vtype, REG_RET); // access return value of __enter__ - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // push return value of __enter__ - // stack: (..., __exit__, self, as_value, nlr_buf, as_value) -} - -STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) { - // note: label+1 is available as an auxiliary label - - // stack: (..., __exit__, self, as_value, nlr_buf) - emit_native_pre(emit); - emit_call(emit, MP_F_NLR_POP); - adjust_stack(emit, -(mp_int_t)(sizeof(nlr_buf_t) / sizeof(mp_uint_t)) - 1); - // stack: (..., __exit__, self) - - // call __exit__ - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 5); - emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, 3, REG_ARG_1, 0, REG_ARG_2); - - // jump to after with cleanup nlr_catch block - adjust_stack(emit, 1); // dummy nlr_buf.prev - emit_native_load_const_tok(emit, MP_TOKEN_KW_NONE); // nlr_buf.ret_val = no exception - emit_native_jump(emit, label + 1); - - // nlr_catch - emit_native_label_assign(emit, label); - - // adjust stack counter for: __exit__, self, as_value - adjust_stack(emit, 3); - // stack: (..., __exit__, self, as_value, nlr_buf.prev, nlr_buf.ret_val) - - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); // get the thrown value (exc) - adjust_stack(emit, -2); // discard nlr_buf.prev and as_value - // stack: (..., __exit__, self) - // REG_ARG_1=exc - - emit_pre_pop_reg(emit, &vtype, REG_ARG_2); // self - emit_pre_pop_reg(emit, &vtype, REG_ARG_3); // __exit__ - adjust_stack(emit, 1); // dummy nlr_buf.prev - emit_post_push_reg(emit, vtype, REG_ARG_1); // push exc to save it for later - emit_post_push_reg(emit, vtype, REG_ARG_3); // __exit__ - emit_post_push_reg(emit, vtype, REG_ARG_2); // self - // stack: (..., exc, __exit__, self) - // REG_ARG_1=exc - - ASM_LOAD_REG_REG_OFFSET(emit->as, REG_ARG_2, REG_ARG_1, 0); // get type(exc) - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_ARG_2); // push type(exc) - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_ARG_1); // push exc value - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); // traceback info - // stack: (..., exc, __exit__, self, type(exc), exc, traceback) - - // call __exit__ method - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 5); - emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, 3, REG_ARG_1, 0, REG_ARG_2); - // stack: (..., exc) - - // if REG_RET is true then we need to replace top-of-stack with None (swallow exception) - if (REG_ARG_1 != REG_RET) { - ASM_MOV_REG_REG(emit->as, REG_ARG_1, REG_RET); - } - emit_call(emit, MP_F_OBJ_IS_TRUE); - ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label + 1); - - // replace exc with None - emit_pre_pop_discard(emit); - emit_post_push_imm(emit, VTYPE_PYOBJ, (mp_uint_t)mp_const_none); - - // end of with cleanup nlr_catch block - emit_native_label_assign(emit, label + 1); -} - -STATIC void emit_native_setup_except(emit_t *emit, mp_uint_t label) { - emit_native_pre(emit); - // need to commit stack because we may jump elsewhere - need_stack_settled(emit); - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_1, sizeof(nlr_buf_t) / sizeof(mp_uint_t)); // arg1 = pointer to nlr buf - emit_call(emit, MP_F_NLR_PUSH); - ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label); - emit_post(emit); -} - -STATIC void emit_native_setup_finally(emit_t *emit, mp_uint_t label) { - emit_native_setup_except(emit, label); -} - -STATIC void emit_native_end_finally(emit_t *emit) { - // logic: - // exc = pop_stack - // if exc == None: pass - // else: raise exc - // the check if exc is None is done in the MP_F_NATIVE_RAISE stub - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); // get nlr_buf.ret_val - emit_pre_pop_discard(emit); // discard nlr_buf.prev - emit_call(emit, MP_F_NATIVE_RAISE); - emit_post(emit); -} - -STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) { - // perhaps the difficult one, as we want to rewrite for loops using native code - // in cases where we iterate over a Python object, can we use normal runtime calls? - - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); - assert(vtype == VTYPE_PYOBJ); - if (use_stack) { - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_2, MP_OBJ_ITER_BUF_NSLOTS); - emit_call(emit, MP_F_NATIVE_GETITER); - } else { - // mp_getiter will allocate the iter_buf on the heap - ASM_MOV_IMM_TO_REG(emit->as, 0, REG_ARG_2); - emit_call(emit, MP_F_NATIVE_GETITER); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } -} - -STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) { - emit_native_pre(emit); - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, MP_OBJ_ITER_BUF_NSLOTS); - adjust_stack(emit, MP_OBJ_ITER_BUF_NSLOTS); - emit_call(emit, MP_F_NATIVE_ITERNEXT); - ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)MP_OBJ_STOP_ITERATION, REG_TEMP1); - ASM_JUMP_IF_REG_EQ(emit->as, REG_RET, REG_TEMP1, label); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_for_iter_end(emit_t *emit) { - // adjust stack counter (we get here from for_iter ending, which popped the value for us) - emit_native_pre(emit); - adjust_stack(emit, -MP_OBJ_ITER_BUF_NSLOTS); - emit_post(emit); -} - -STATIC void emit_native_pop_block(emit_t *emit) { - emit_native_pre(emit); - emit_call(emit, MP_F_NLR_POP); - adjust_stack(emit, -(mp_int_t)(sizeof(nlr_buf_t) / sizeof(mp_uint_t)) + 1); - emit_post(emit); -} - -STATIC void emit_native_pop_except(emit_t *emit) { - (void)emit; -} - -STATIC void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) { - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_ARG_2); - if (vtype == VTYPE_PYOBJ) { - emit_call_with_imm_arg(emit, MP_F_UNARY_OP, op, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } else { - adjust_stack(emit, 1); - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "unary op %q not implemented", mp_unary_op_method_name[op]); - } -} - -STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) { - DEBUG_printf("binary_op(" UINT_FMT ")\n", op); - vtype_kind_t vtype_lhs = peek_vtype(emit, 1); - vtype_kind_t vtype_rhs = peek_vtype(emit, 0); - if (vtype_lhs == VTYPE_INT && vtype_rhs == VTYPE_INT) { - #if N_X64 || N_X86 - // special cases for x86 and shifting - if (op == MP_BINARY_OP_LSHIFT - || op == MP_BINARY_OP_INPLACE_LSHIFT - || op == MP_BINARY_OP_RSHIFT - || op == MP_BINARY_OP_INPLACE_RSHIFT) { - #if N_X64 - emit_pre_pop_reg_reg(emit, &vtype_rhs, ASM_X64_REG_RCX, &vtype_lhs, REG_RET); - #else - emit_pre_pop_reg_reg(emit, &vtype_rhs, ASM_X86_REG_ECX, &vtype_lhs, REG_RET); - #endif - if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) { - ASM_LSL_REG(emit->as, REG_RET); - } else { - ASM_ASR_REG(emit->as, REG_RET); - } - emit_post_push_reg(emit, VTYPE_INT, REG_RET); - return; - } - #endif - int reg_rhs = REG_ARG_3; - emit_pre_pop_reg_flexible(emit, &vtype_rhs, ®_rhs, REG_RET, REG_ARG_2); - emit_pre_pop_reg(emit, &vtype_lhs, REG_ARG_2); - if (0) { - // dummy - #if !(N_X64 || N_X86) - } else if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) { - ASM_LSL_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (op == MP_BINARY_OP_RSHIFT || op == MP_BINARY_OP_INPLACE_RSHIFT) { - ASM_ASR_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - #endif - } else if (op == MP_BINARY_OP_OR || op == MP_BINARY_OP_INPLACE_OR) { - ASM_OR_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (op == MP_BINARY_OP_XOR || op == MP_BINARY_OP_INPLACE_XOR) { - ASM_XOR_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (op == MP_BINARY_OP_AND || op == MP_BINARY_OP_INPLACE_AND) { - ASM_AND_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (op == MP_BINARY_OP_ADD || op == MP_BINARY_OP_INPLACE_ADD) { - ASM_ADD_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (op == MP_BINARY_OP_SUBTRACT || op == MP_BINARY_OP_INPLACE_SUBTRACT) { - ASM_SUB_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (op == MP_BINARY_OP_MULTIPLY || op == MP_BINARY_OP_INPLACE_MULTIPLY) { - ASM_MUL_REG_REG(emit->as, REG_ARG_2, reg_rhs); - emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2); - } else if (MP_BINARY_OP_LESS <= op && op <= MP_BINARY_OP_NOT_EQUAL) { - // comparison ops are (in enum order): - // 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 - need_reg_single(emit, REG_RET, 0); - #if N_X64 - asm_x64_xor_r64_r64(emit->as, REG_RET, REG_RET); - asm_x64_cmp_r64_with_r64(emit->as, reg_rhs, REG_ARG_2); - static byte ops[6] = { - ASM_X64_CC_JL, - ASM_X64_CC_JG, - ASM_X64_CC_JE, - ASM_X64_CC_JLE, - ASM_X64_CC_JGE, - ASM_X64_CC_JNE, - }; - asm_x64_setcc_r8(emit->as, ops[op - MP_BINARY_OP_LESS], REG_RET); - #elif N_X86 - asm_x86_xor_r32_r32(emit->as, REG_RET, REG_RET); - asm_x86_cmp_r32_with_r32(emit->as, reg_rhs, REG_ARG_2); - static byte ops[6] = { - ASM_X86_CC_JL, - ASM_X86_CC_JG, - ASM_X86_CC_JE, - ASM_X86_CC_JLE, - ASM_X86_CC_JGE, - ASM_X86_CC_JNE, - }; - asm_x86_setcc_r8(emit->as, ops[op - MP_BINARY_OP_LESS], REG_RET); - #elif N_THUMB - asm_thumb_cmp_rlo_rlo(emit->as, REG_ARG_2, reg_rhs); - static uint16_t ops[6] = { - ASM_THUMB_OP_ITE_GE, - ASM_THUMB_OP_ITE_GT, - ASM_THUMB_OP_ITE_EQ, - ASM_THUMB_OP_ITE_GT, - ASM_THUMB_OP_ITE_GE, - ASM_THUMB_OP_ITE_EQ, - }; - static byte ret[6] = { 0, 1, 1, 0, 1, 0, }; - asm_thumb_op16(emit->as, ops[op - MP_BINARY_OP_LESS]); - asm_thumb_mov_rlo_i8(emit->as, REG_RET, ret[op - MP_BINARY_OP_LESS]); - asm_thumb_mov_rlo_i8(emit->as, REG_RET, ret[op - MP_BINARY_OP_LESS] ^ 1); - #elif N_ARM - asm_arm_cmp_reg_reg(emit->as, REG_ARG_2, reg_rhs); - static uint ccs[6] = { - ASM_ARM_CC_LT, - ASM_ARM_CC_GT, - ASM_ARM_CC_EQ, - ASM_ARM_CC_LE, - ASM_ARM_CC_GE, - ASM_ARM_CC_NE, - }; - asm_arm_setcc_reg(emit->as, REG_RET, ccs[op - MP_BINARY_OP_LESS]); - #elif N_XTENSA - static uint8_t ccs[6] = { - ASM_XTENSA_CC_LT, - 0x80 | ASM_XTENSA_CC_LT, // for GT we'll swap args - ASM_XTENSA_CC_EQ, - 0x80 | ASM_XTENSA_CC_GE, // for LE we'll swap args - ASM_XTENSA_CC_GE, - ASM_XTENSA_CC_NE, - }; - uint8_t cc = ccs[op - MP_BINARY_OP_LESS]; - if ((cc & 0x80) == 0) { - asm_xtensa_setcc_reg_reg_reg(emit->as, cc, REG_RET, REG_ARG_2, reg_rhs); - } else { - asm_xtensa_setcc_reg_reg_reg(emit->as, cc & ~0x80, REG_RET, reg_rhs, REG_ARG_2); - } - #else - #error not implemented - #endif - emit_post_push_reg(emit, VTYPE_BOOL, REG_RET); - } else { - // TODO other ops not yet implemented - adjust_stack(emit, 1); - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "binary op %q not implemented", mp_binary_op_method_name[op]); - } - } else if (vtype_lhs == VTYPE_PYOBJ && vtype_rhs == VTYPE_PYOBJ) { - emit_pre_pop_reg_reg(emit, &vtype_rhs, REG_ARG_3, &vtype_lhs, REG_ARG_2); - bool invert = false; - if (op == MP_BINARY_OP_NOT_IN) { - invert = true; - op = MP_BINARY_OP_IN; - } else if (op == MP_BINARY_OP_IS_NOT) { - invert = true; - op = MP_BINARY_OP_IS; - } - emit_call_with_imm_arg(emit, MP_F_BINARY_OP, op, REG_ARG_1); - if (invert) { - ASM_MOV_REG_REG(emit->as, REG_ARG_2, REG_RET); - emit_call_with_imm_arg(emit, MP_F_UNARY_OP, MP_UNARY_OP_NOT, REG_ARG_1); - } - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } else { - adjust_stack(emit, -1); - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "can't do binary op between '%q' and '%q'", - vtype_to_qstr(vtype_lhs), vtype_to_qstr(vtype_rhs)); - } -} - -STATIC void emit_native_build_tuple(emit_t *emit, mp_uint_t n_args) { - // for viper: call runtime, with types of args - // if wrapped in byte_array, or something, allocates memory and fills it - emit_native_pre(emit); - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items - emit_call_with_imm_arg(emit, MP_F_BUILD_TUPLE, n_args, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new tuple -} - -STATIC void emit_native_build_list(emit_t *emit, mp_uint_t n_args) { - emit_native_pre(emit); - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items - emit_call_with_imm_arg(emit, MP_F_BUILD_LIST, n_args, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new list -} - -STATIC void emit_native_build_map(emit_t *emit, mp_uint_t n_args) { - emit_native_pre(emit); - emit_call_with_imm_arg(emit, MP_F_BUILD_MAP, n_args, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new map -} - -STATIC void emit_native_store_map(emit_t *emit) { - vtype_kind_t vtype_key, vtype_value, vtype_map; - emit_pre_pop_reg_reg_reg(emit, &vtype_key, REG_ARG_2, &vtype_value, REG_ARG_3, &vtype_map, REG_ARG_1); // key, value, map - assert(vtype_key == VTYPE_PYOBJ); - assert(vtype_value == VTYPE_PYOBJ); - assert(vtype_map == VTYPE_PYOBJ); - emit_call(emit, MP_F_STORE_MAP); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // map -} - -#if MICROPY_PY_BUILTINS_SET -STATIC void emit_native_build_set(emit_t *emit, mp_uint_t n_args) { - emit_native_pre(emit); - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items - emit_call_with_imm_arg(emit, MP_F_BUILD_SET, n_args, REG_ARG_1); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new set -} -#endif - -#if MICROPY_PY_BUILTINS_SLICE -STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) { - DEBUG_printf("build_slice %d\n", n_args); - if (n_args == 2) { - vtype_kind_t vtype_start, vtype_stop; - emit_pre_pop_reg_reg(emit, &vtype_stop, REG_ARG_2, &vtype_start, REG_ARG_1); // arg1 = start, arg2 = stop - assert(vtype_start == VTYPE_PYOBJ); - assert(vtype_stop == VTYPE_PYOBJ); - emit_call_with_imm_arg(emit, MP_F_NEW_SLICE, (mp_uint_t)mp_const_none, REG_ARG_3); // arg3 = step - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } else { - assert(n_args == 3); - vtype_kind_t vtype_start, vtype_stop, vtype_step; - emit_pre_pop_reg_reg_reg(emit, &vtype_step, REG_ARG_3, &vtype_stop, REG_ARG_2, &vtype_start, REG_ARG_1); // arg1 = start, arg2 = stop, arg3 = step - assert(vtype_start == VTYPE_PYOBJ); - assert(vtype_stop == VTYPE_PYOBJ); - assert(vtype_step == VTYPE_PYOBJ); - emit_call(emit, MP_F_NEW_SLICE); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } -} -#endif - -STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_index) { - mp_fun_kind_t f; - if (kind == SCOPE_LIST_COMP) { - vtype_kind_t vtype_item; - emit_pre_pop_reg(emit, &vtype_item, REG_ARG_2); - assert(vtype_item == VTYPE_PYOBJ); - f = MP_F_LIST_APPEND; - #if MICROPY_PY_BUILTINS_SET - } else if (kind == SCOPE_SET_COMP) { - vtype_kind_t vtype_item; - emit_pre_pop_reg(emit, &vtype_item, REG_ARG_2); - assert(vtype_item == VTYPE_PYOBJ); - f = MP_F_STORE_SET; - #endif - } else { - // SCOPE_DICT_COMP - vtype_kind_t vtype_key, vtype_value; - emit_pre_pop_reg_reg(emit, &vtype_key, REG_ARG_2, &vtype_value, REG_ARG_3); - assert(vtype_key == VTYPE_PYOBJ); - assert(vtype_value == VTYPE_PYOBJ); - f = MP_F_STORE_MAP; - } - vtype_kind_t vtype_collection; - emit_access_stack(emit, collection_index, &vtype_collection, REG_ARG_1); - assert(vtype_collection == VTYPE_PYOBJ); - emit_call(emit, f); - emit_post(emit); -} - -STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) { - DEBUG_printf("unpack_sequence %d\n", n_args); - vtype_kind_t vtype_base; - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq - assert(vtype_base == VTYPE_PYOBJ); - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, n_args); // arg3 = dest ptr - emit_call_with_imm_arg(emit, MP_F_UNPACK_SEQUENCE, n_args, REG_ARG_2); // arg2 = n_args -} - -STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) { - DEBUG_printf("unpack_ex %d %d\n", n_left, n_right); - vtype_kind_t vtype_base; - emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq - assert(vtype_base == VTYPE_PYOBJ); - emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_3, n_left + n_right + 1); // arg3 = dest ptr - emit_call_with_imm_arg(emit, MP_F_UNPACK_EX, n_left | (n_right << 8), REG_ARG_2); // arg2 = n_left + n_right -} - -STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { - // call runtime, with type info for args, or don't support dict/default params, or only support Python objects for them - emit_native_pre(emit); - if (n_pos_defaults == 0 && n_kw_defaults == 0) { - emit_call_with_3_imm_args_and_first_aligned(emit, MP_F_MAKE_FUNCTION_FROM_RAW_CODE, (mp_uint_t)scope->raw_code, REG_ARG_1, (mp_uint_t)MP_OBJ_NULL, REG_ARG_2, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); - } else { - vtype_kind_t vtype_def_tuple, vtype_def_dict; - emit_pre_pop_reg_reg(emit, &vtype_def_dict, REG_ARG_3, &vtype_def_tuple, REG_ARG_2); - assert(vtype_def_tuple == VTYPE_PYOBJ); - assert(vtype_def_dict == VTYPE_PYOBJ); - emit_call_with_imm_arg_aligned(emit, MP_F_MAKE_FUNCTION_FROM_RAW_CODE, (mp_uint_t)scope->raw_code, REG_ARG_1); - } - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) { - emit_native_pre(emit); - if (n_pos_defaults == 0 && n_kw_defaults == 0) { - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_closed_over); - ASM_MOV_IMM_TO_REG(emit->as, n_closed_over, REG_ARG_2); - } else { - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_closed_over + 2); - ASM_MOV_IMM_TO_REG(emit->as, 0x100 | n_closed_over, REG_ARG_2); - } - ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, (mp_uint_t)scope->raw_code, REG_ARG_1); - ASM_CALL_IND(emit->as, mp_fun_table[MP_F_MAKE_CLOSURE_FROM_RAW_CODE], MP_F_MAKE_CLOSURE_FROM_RAW_CODE); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); -} - -STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - DEBUG_printf("call_function(n_pos=" UINT_FMT ", n_kw=" UINT_FMT ", star_flags=" UINT_FMT ")\n", n_positional, n_keyword, star_flags); - - // TODO: in viper mode, call special runtime routine with type info for args, - // and wanted type info for return, to remove need for boxing/unboxing - - emit_native_pre(emit); - vtype_kind_t vtype_fun = peek_vtype(emit, n_positional + 2 * n_keyword); - if (vtype_fun == VTYPE_BUILTIN_CAST) { - // casting operator - assert(n_positional == 1 && n_keyword == 0); - assert(!star_flags); - DEBUG_printf(" cast to %d\n", vtype_fun); - vtype_kind_t vtype_cast = peek_stack(emit, 1)->data.u_imm; - switch (peek_vtype(emit, 0)) { - case VTYPE_PYOBJ: { - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_ARG_1); - emit_pre_pop_discard(emit); - emit_call_with_imm_arg(emit, MP_F_CONVERT_OBJ_TO_NATIVE, vtype_cast, REG_ARG_2); // arg2 = type - emit_post_push_reg(emit, vtype_cast, REG_RET); - break; - } - case VTYPE_BOOL: - case VTYPE_INT: - case VTYPE_UINT: - case VTYPE_PTR: - case VTYPE_PTR8: - case VTYPE_PTR16: - case VTYPE_PTR32: - case VTYPE_PTR_NONE: - emit_fold_stack_top(emit, REG_ARG_1); - emit_post_top_set_vtype(emit, vtype_cast); - break; - default: - // this can happen when casting a cast: int(int) - mp_raise_NotImplementedError("casting"); - } - } else { - assert(vtype_fun == VTYPE_PYOBJ); - if (star_flags) { - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 3); // pointer to args - emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 0, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } else { - if (n_positional != 0 || n_keyword != 0) { - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword); // pointer to args - } - emit_pre_pop_reg(emit, &vtype_fun, REG_ARG_1); // the function - emit_call_with_imm_arg(emit, MP_F_NATIVE_CALL_FUNCTION_N_KW, n_positional | (n_keyword << 8), REG_ARG_2); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } - } -} - -STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) { - if (star_flags) { - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 4); // pointer to args - emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 1, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } else { - emit_native_pre(emit); - emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, 2 + n_positional + 2 * n_keyword); // pointer to items, including meth and self - emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW, n_positional, REG_ARG_1, n_keyword, REG_ARG_2); - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } -} - -STATIC void emit_native_return_value(emit_t *emit) { - DEBUG_printf("return_value\n"); - if (emit->do_viper_types) { - if (peek_vtype(emit, 0) == VTYPE_PTR_NONE) { - emit_pre_pop_discard(emit); - if (emit->return_vtype == VTYPE_PYOBJ) { - ASM_MOV_IMM_TO_REG(emit->as, (mp_uint_t)mp_const_none, REG_RET); - } else { - ASM_MOV_IMM_TO_REG(emit->as, 0, REG_RET); - } - } else { - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_RET); - if (vtype != emit->return_vtype) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, - "return expected '%q' but got '%q'", - vtype_to_qstr(emit->return_vtype), vtype_to_qstr(vtype)); - } - } - } else { - vtype_kind_t vtype; - emit_pre_pop_reg(emit, &vtype, REG_RET); - assert(vtype == VTYPE_PYOBJ); - } - emit->last_emit_was_return_value = true; - ASM_EXIT(emit->as); -} - -STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) { - assert(n_args == 1); - vtype_kind_t vtype_exc; - emit_pre_pop_reg(emit, &vtype_exc, REG_ARG_1); // arg1 = object to raise - if (vtype_exc != VTYPE_PYOBJ) { - EMIT_NATIVE_VIPER_TYPE_ERROR(emit, "must raise an object"); - } - // TODO probably make this 1 call to the runtime (which could even call convert, native_raise(obj, type)) - emit_call(emit, MP_F_NATIVE_RAISE); -} - -STATIC void emit_native_yield_value(emit_t *emit) { - // not supported (for now) - (void)emit; - mp_raise_NotImplementedError("native yield"); -} -STATIC void emit_native_yield_from(emit_t *emit) { - // not supported (for now) - (void)emit; - mp_raise_NotImplementedError("native yield from"); -} - -STATIC void emit_native_start_except_handler(emit_t *emit) { - // This instruction follows an nlr_pop, so the stack counter is back to zero, when really - // it should be up by a whole nlr_buf_t. We then want to pop the nlr_buf_t here, but save - // the first 2 elements, so we can get the thrown value. - adjust_stack(emit, 1); - vtype_kind_t vtype_nlr; - emit_pre_pop_reg(emit, &vtype_nlr, REG_ARG_1); // get the thrown value - emit_pre_pop_discard(emit); // discard the linked-list pointer in the nlr_buf - emit_post_push_reg_reg_reg(emit, VTYPE_PYOBJ, REG_ARG_1, VTYPE_PYOBJ, REG_ARG_1, VTYPE_PYOBJ, REG_ARG_1); // push the 3 exception items -} - -STATIC void emit_native_end_except_handler(emit_t *emit) { - adjust_stack(emit, -1); -} - -const emit_method_table_t EXPORT_FUN(method_table) = { - emit_native_set_native_type, - emit_native_start_pass, - emit_native_end_pass, - emit_native_last_emit_was_return_value, - emit_native_adjust_stack_size, - emit_native_set_source_line, - - { - emit_native_load_fast, - emit_native_load_deref, - emit_native_load_name, - emit_native_load_global, - }, - { - emit_native_store_fast, - emit_native_store_deref, - emit_native_store_name, - emit_native_store_global, - }, - { - emit_native_delete_fast, - emit_native_delete_deref, - emit_native_delete_name, - emit_native_delete_global, - }, - - emit_native_label_assign, - emit_native_import_name, - emit_native_import_from, - emit_native_import_star, - emit_native_load_const_tok, - emit_native_load_const_small_int, - emit_native_load_const_str, - emit_native_load_const_obj, - emit_native_load_null, - emit_native_load_attr, - emit_native_load_method, - emit_native_load_build_class, - emit_native_load_subscr, - emit_native_store_attr, - emit_native_store_subscr, - emit_native_delete_attr, - emit_native_delete_subscr, - emit_native_dup_top, - emit_native_dup_top_two, - emit_native_pop_top, - emit_native_rot_two, - emit_native_rot_three, - emit_native_jump, - emit_native_pop_jump_if, - emit_native_jump_if_or_pop, - emit_native_break_loop, - emit_native_continue_loop, - emit_native_setup_with, - emit_native_with_cleanup, - emit_native_setup_except, - emit_native_setup_finally, - emit_native_end_finally, - emit_native_get_iter, - emit_native_for_iter, - emit_native_for_iter_end, - emit_native_pop_block, - emit_native_pop_except, - emit_native_unary_op, - emit_native_binary_op, - emit_native_build_tuple, - emit_native_build_list, - emit_native_build_map, - emit_native_store_map, - #if MICROPY_PY_BUILTINS_SET - emit_native_build_set, - #endif - #if MICROPY_PY_BUILTINS_SLICE - emit_native_build_slice, - #endif - emit_native_store_comp, - emit_native_unpack_sequence, - emit_native_unpack_ex, - emit_native_make_function, - emit_native_make_closure, - emit_native_call_function, - emit_native_call_method, - emit_native_return_value, - emit_native_raise_varargs, - emit_native_yield_value, - emit_native_yield_from, - - emit_native_start_except_handler, - emit_native_end_except_handler, -}; - -#endif diff --git a/user/mpy/py/formatfloat.c b/user/mpy/py/formatfloat.c deleted file mode 100644 index 4130e8b..0000000 --- a/user/mpy/py/formatfloat.c +++ /dev/null @@ -1,428 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_FLOAT_IMPL != MICROPY_FLOAT_IMPL_NONE - -#include -#include -#include -#include "py/formatfloat.h" - -/*********************************************************************** - - Routine for converting a arbitrary floating - point number into a string. - - The code in this funcion was inspired from Fred Bayer's pdouble.c. - Since pdouble.c was released as Public Domain, I'm releasing this - code as public domain as well. - - The original code can be found in https://github.com/dhylands/format-float - - Dave Hylands - -***********************************************************************/ - -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -// 1 sign bit, 8 exponent bits, and 23 mantissa bits. -// exponent values 0 and 255 are reserved, exponent can be 1 to 254. -// exponent is stored with a bias of 127. -// The min and max floats are on the order of 1x10^37 and 1x10^-37 - -#define FPTYPE float -#define FPCONST(x) x##F -#define FPROUND_TO_ONE 0.9999995F -#define FPDECEXP 32 -#define FPMIN_BUF_SIZE 6 // +9e+99 - -#define FLT_SIGN_MASK 0x80000000 -#define FLT_EXP_MASK 0x7F800000 -#define FLT_MAN_MASK 0x007FFFFF - -union floatbits { - float f; - uint32_t u; -}; -static inline int fp_signbit(float x) { union floatbits fb = {x}; return fb.u & FLT_SIGN_MASK; } -static inline int fp_isspecial(float x) { union floatbits fb = {x}; return (fb.u & FLT_EXP_MASK) == FLT_EXP_MASK; } -static inline int fp_isinf(float x) { union floatbits fb = {x}; return (fb.u & FLT_MAN_MASK) == 0; } -static inline int fp_iszero(float x) { union floatbits fb = {x}; return fb.u == 0; } -static inline int fp_isless1(float x) { union floatbits fb = {x}; return fb.u < 0x3f800000; } -// Assumes both fp_isspecial() and fp_isinf() were applied before -#define fp_isnan(x) 1 - -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE - -#define FPTYPE double -#define FPCONST(x) x -#define FPROUND_TO_ONE 0.999999999995 -#define FPDECEXP 256 -#define FPMIN_BUF_SIZE 7 // +9e+199 -#include -#define fp_signbit(x) signbit(x) -#define fp_isspecial(x) 1 -#define fp_isnan(x) isnan(x) -#define fp_isinf(x) isinf(x) -#define fp_iszero(x) (x == 0) -#define fp_isless1(x) (x < 1.0) - -#endif - -static const FPTYPE g_pos_pow[] = { - #if FPDECEXP > 32 - 1e256, 1e128, 1e64, - #endif - 1e32, 1e16, 1e8, 1e4, 1e2, 1e1 -}; -static const FPTYPE g_neg_pow[] = { - #if FPDECEXP > 32 - 1e-256, 1e-128, 1e-64, - #endif - 1e-32, 1e-16, 1e-8, 1e-4, 1e-2, 1e-1 -}; - -int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, char sign) { - - char *s = buf; - - if (buf_size <= FPMIN_BUF_SIZE) { - // FPMIN_BUF_SIZE is the minimum size needed to store any FP number. - // If the buffer does not have enough room for this (plus null terminator) - // then don't try to format the float. - - if (buf_size >= 2) { - *s++ = '?'; - } - if (buf_size >= 1) { - *s++ = '\0'; - } - return buf_size >= 2; - } - if (fp_signbit(f)) { - *s++ = '-'; - f = -f; - } else { - if (sign) { - *s++ = sign; - } - } - - // buf_remaining contains bytes available for digits and exponent. - // It is buf_size minus room for the sign and null byte. - int buf_remaining = buf_size - 1 - (s - buf); - - if (fp_isspecial(f)) { - char uc = fmt & 0x20; - if (fp_isinf(f)) { - *s++ = 'I' ^ uc; - *s++ = 'N' ^ uc; - *s++ = 'F' ^ uc; - goto ret; - } else if (fp_isnan(f)) { - *s++ = 'N' ^ uc; - *s++ = 'A' ^ uc; - *s++ = 'N' ^ uc; - ret: - *s = '\0'; - return s - buf; - } - } - - if (prec < 0) { - prec = 6; - } - char e_char = 'E' | (fmt & 0x20); // e_char will match case of fmt - fmt |= 0x20; // Force fmt to be lowercase - char org_fmt = fmt; - if (fmt == 'g' && prec == 0) { - prec = 1; - } - int e, e1; - int dec = 0; - char e_sign = '\0'; - int num_digits = 0; - const FPTYPE *pos_pow = g_pos_pow; - const FPTYPE *neg_pow = g_neg_pow; - - if (fp_iszero(f)) { - e = 0; - if (fmt == 'f') { - // Truncate precision to prevent buffer overflow - if (prec + 2 > buf_remaining) { - prec = buf_remaining - 2; - } - num_digits = prec + 1; - } else { - // Truncate precision to prevent buffer overflow - if (prec + 6 > buf_remaining) { - prec = buf_remaining - 6; - } - if (fmt == 'e') { - e_sign = '+'; - } - } - } else if (fp_isless1(f)) { - // We need to figure out what an integer digit will be used - // in case 'f' is used (or we revert other format to it below). - // As we just tested number to be <1, this is obviously 0, - // but we can round it up to 1 below. - char first_dig = '0'; - if (f >= FPROUND_TO_ONE) { - first_dig = '1'; - } - - // Build negative exponent - for (e = 0, e1 = FPDECEXP; e1; e1 >>= 1, pos_pow++, neg_pow++) { - if (*neg_pow > f) { - e += e1; - f *= *pos_pow; - } - } - char e_sign_char = '-'; - if (fp_isless1(f) && f >= FPROUND_TO_ONE) { - f = FPCONST(1.0); - if (e == 0) { - e_sign_char = '+'; - } - } else if (fp_isless1(f)) { - e++; - f *= FPCONST(10.0); - } - - // If the user specified 'g' format, and e is <= 4, then we'll switch - // to the fixed format ('f') - - if (fmt == 'f' || (fmt == 'g' && e <= 4)) { - fmt = 'f'; - dec = -1; - *s++ = first_dig; - - if (org_fmt == 'g') { - prec += (e - 1); - } - - // truncate precision to prevent buffer overflow - if (prec + 2 > buf_remaining) { - prec = buf_remaining - 2; - } - - num_digits = prec; - if (num_digits) { - *s++ = '.'; - while (--e && num_digits) { - *s++ = '0'; - num_digits--; - } - } - } else { - // For e & g formats, we'll be printing the exponent, so set the - // sign. - e_sign = e_sign_char; - dec = 0; - - if (prec > (buf_remaining - FPMIN_BUF_SIZE)) { - prec = buf_remaining - FPMIN_BUF_SIZE; - if (fmt == 'g') { - prec++; - } - } - } - } else { - // Build positive exponent - for (e = 0, e1 = FPDECEXP; e1; e1 >>= 1, pos_pow++, neg_pow++) { - if (*pos_pow <= f) { - e += e1; - f *= *neg_pow; - } - } - - // It can be that f was right on the edge of an entry in pos_pow needs to be reduced - if (f >= FPCONST(10.0)) { - e += 1; - f *= FPCONST(0.1); - } - - // If the user specified fixed format (fmt == 'f') and e makes the - // number too big to fit into the available buffer, then we'll - // switch to the 'e' format. - - if (fmt == 'f') { - if (e >= buf_remaining) { - fmt = 'e'; - } else if ((e + prec + 2) > buf_remaining) { - prec = buf_remaining - e - 2; - if (prec < 0) { - // This means no decimal point, so we can add one back - // for the decimal. - prec++; - } - } - } - if (fmt == 'e' && prec > (buf_remaining - FPMIN_BUF_SIZE)) { - prec = buf_remaining - FPMIN_BUF_SIZE; - } - if (fmt == 'g'){ - // Truncate precision to prevent buffer overflow - if (prec + (FPMIN_BUF_SIZE - 1) > buf_remaining) { - prec = buf_remaining - (FPMIN_BUF_SIZE - 1); - } - } - // If the user specified 'g' format, and e is < prec, then we'll switch - // to the fixed format. - - if (fmt == 'g' && e < prec) { - fmt = 'f'; - prec -= (e + 1); - } - if (fmt == 'f') { - dec = e; - num_digits = prec + e + 1; - } else { - e_sign = '+'; - } - } - if (prec < 0) { - // This can happen when the prec is trimmed to prevent buffer overflow - prec = 0; - } - - // We now have num.f as a floating point number between >= 1 and < 10 - // (or equal to zero), and e contains the absolute value of the power of - // 10 exponent. and (dec + 1) == the number of dgits before the decimal. - - // For e, prec is # digits after the decimal - // For f, prec is # digits after the decimal - // For g, prec is the max number of significant digits - // - // For e & g there will be a single digit before the decimal - // for f there will be e digits before the decimal - - if (fmt == 'e') { - num_digits = prec + 1; - } else if (fmt == 'g') { - if (prec == 0) { - prec = 1; - } - num_digits = prec; - } - - // Print the digits of the mantissa - for (int i = 0; i < num_digits; ++i, --dec) { - int32_t d = (int32_t)f; - *s++ = '0' + d; - if (dec == 0 && prec > 0) { - *s++ = '.'; - } - f -= (FPTYPE)d; - f *= FPCONST(10.0); - } - - // Round - // If we print non-exponential format (i.e. 'f'), but a digit we're going - // to round by (e) is too far away, then there's nothing to round. - if ((org_fmt != 'f' || e <= 1) && f >= FPCONST(5.0)) { - char *rs = s; - rs--; - while (1) { - if (*rs == '.') { - rs--; - continue; - } - if (*rs < '0' || *rs > '9') { - // + or - - rs++; // So we sit on the digit to the right of the sign - break; - } - if (*rs < '9') { - (*rs)++; - break; - } - *rs = '0'; - if (rs == buf) { - break; - } - rs--; - } - if (*rs == '0') { - // We need to insert a 1 - if (rs[1] == '.' && fmt != 'f') { - // We're going to round 9.99 to 10.00 - // Move the decimal point - rs[0] = '.'; - rs[1] = '0'; - if (e_sign == '-') { - e--; - if (e == 0) { - e_sign = '+'; - } - } else { - e++; - } - } else { - // Need at extra digit at the end to make room for the leading '1' - s++; - } - char *ss = s; - while (ss > rs) { - *ss = ss[-1]; - ss--; - } - *rs = '1'; - } - } - - // verify that we did not overrun the input buffer so far - assert((size_t)(s + 1 - buf) <= buf_size); - - if (org_fmt == 'g' && prec > 0) { - // Remove trailing zeros and a trailing decimal point - while (s[-1] == '0') { - s--; - } - if (s[-1] == '.') { - s--; - } - } - // Append the exponent - if (e_sign) { - *s++ = e_char; - *s++ = e_sign; - if (FPMIN_BUF_SIZE == 7 && e >= 100) { - *s++ = '0' + (e / 100); - } - *s++ = '0' + ((e / 10) % 10); - *s++ = '0' + (e % 10); - } - *s = '\0'; - - // verify that we did not overrun the input buffer - assert((size_t)(s + 1 - buf) <= buf_size); - - return s - buf; -} - -#endif // MICROPY_FLOAT_IMPL != MICROPY_FLOAT_IMPL_NONE diff --git a/user/mpy/py/formatfloat.h b/user/mpy/py/formatfloat.h deleted file mode 100644 index 9a1643b..0000000 --- a/user/mpy/py/formatfloat.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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_FORMATFLOAT_H -#define MICROPY_INCLUDED_PY_FORMATFLOAT_H - -#include "py/mpconfig.h" - -#if MICROPY_PY_BUILTINS_FLOAT -int mp_format_float(mp_float_t f, char *buf, size_t bufSize, char fmt, int prec, char sign); -#endif - -#endif // MICROPY_INCLUDED_PY_FORMATFLOAT_H diff --git a/user/mpy/py/frozenmod.c b/user/mpy/py/frozenmod.c deleted file mode 100644 index 06d4f84..0000000 --- a/user/mpy/py/frozenmod.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Paul Sokolovsky - * Copyright (c) 2016 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. - */ - -#include -#include - -#include "py/lexer.h" -#include "py/frozenmod.h" - -#if MICROPY_MODULE_FROZEN_STR - -#ifndef MICROPY_MODULE_FROZEN_LEXER -#define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str_len -#else -mp_lexer_t *MICROPY_MODULE_FROZEN_LEXER(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len); -#endif - -extern const char mp_frozen_str_names[]; -extern const uint32_t mp_frozen_str_sizes[]; -extern const char mp_frozen_str_content[]; - -// On input, *len contains size of name, on output - size of content -const char *mp_find_frozen_str(const char *str, size_t *len) { - const char *name = mp_frozen_str_names; - - size_t offset = 0; - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == *len && !memcmp(str, name, l)) { - *len = mp_frozen_str_sizes[i]; - return mp_frozen_str_content + offset; - } - name += l + 1; - offset += mp_frozen_str_sizes[i] + 1; - } - return NULL; -} - -STATIC mp_lexer_t *mp_lexer_frozen_str(const char *str, size_t len) { - size_t name_len = len; - const char *content = mp_find_frozen_str(str, &len); - - if (content == NULL) { - return NULL; - } - - qstr source = qstr_from_strn(str, name_len); - mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, content, len, 0); - return lex; -} - -#endif - -#if MICROPY_MODULE_FROZEN_MPY - -#include "py/emitglue.h" - -extern const char mp_frozen_mpy_names[]; -extern const mp_raw_code_t *const mp_frozen_mpy_content[]; - -STATIC const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t len) { - const char *name = mp_frozen_mpy_names; - for (size_t i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == len && !memcmp(str, name, l)) { - return mp_frozen_mpy_content[i]; - } - name += l + 1; - } - return NULL; -} - -#endif - -#if MICROPY_MODULE_FROZEN - -STATIC mp_import_stat_t mp_frozen_stat_helper(const char *name, const char *str) { - size_t len = strlen(str); - - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l >= len && !memcmp(str, name, len)) { - if (name[len] == 0) { - return MP_IMPORT_STAT_FILE; - } else if (name[len] == '/') { - return MP_IMPORT_STAT_DIR; - } - } - name += l + 1; - } - return MP_IMPORT_STAT_NO_EXIST; -} - -mp_import_stat_t mp_frozen_stat(const char *str) { - mp_import_stat_t stat; - - #if MICROPY_MODULE_FROZEN_STR - stat = mp_frozen_stat_helper(mp_frozen_str_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - #endif - - #if MICROPY_MODULE_FROZEN_MPY - stat = mp_frozen_stat_helper(mp_frozen_mpy_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - #endif - - return MP_IMPORT_STAT_NO_EXIST; -} - -int mp_find_frozen_module(const char *str, size_t len, void **data) { - #if MICROPY_MODULE_FROZEN_STR - mp_lexer_t *lex = mp_lexer_frozen_str(str, len); - if (lex != NULL) { - *data = lex; - return MP_FROZEN_STR; - } - #endif - #if MICROPY_MODULE_FROZEN_MPY - const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len); - if (rc != NULL) { - *data = (void*)rc; - return MP_FROZEN_MPY; - } - #endif - return MP_FROZEN_NONE; -} - -#endif diff --git a/user/mpy/py/frozenmod.h b/user/mpy/py/frozenmod.h deleted file mode 100644 index 8cddef6..0000000 --- a/user/mpy/py/frozenmod.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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_FROZENMOD_H -#define MICROPY_INCLUDED_PY_FROZENMOD_H - -#include "py/lexer.h" - -enum { - MP_FROZEN_NONE, - MP_FROZEN_STR, - MP_FROZEN_MPY, -}; - -int mp_find_frozen_module(const char *str, size_t len, void **data); -const char *mp_find_frozen_str(const char *str, size_t *len); -mp_import_stat_t mp_frozen_stat(const char *str); - -#endif // MICROPY_INCLUDED_PY_FROZENMOD_H diff --git a/user/mpy/py/gc.c b/user/mpy/py/gc.c deleted file mode 100644 index 3a505e9..0000000 --- a/user/mpy/py/gc.c +++ /dev/null @@ -1,918 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpstate.h" -#include "py/gc.h" -#include "py/obj.h" -#include "py/runtime.h" - -#if MICROPY_ENABLE_GC - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_PRINT (0) -#define DEBUG_printf(...) (void)0 -#endif - -// make this 1 to dump the heap each time it changes -#define EXTENSIVE_HEAP_PROFILING (0) - -#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_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 MICROPY_ENABLE_FINALISER -// 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 - -#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL -#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 -#define GC_ENTER() -#define GC_EXIT() -#endif - -// 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 MICROPY_ENABLE_FINALISER - MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len * BITS_PER_BYTE / (BITS_PER_BYTE + BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK); -#else - MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len / (1 + BITS_PER_BYTE / 2 * BYTES_PER_BLOCK); -#endif - - MP_STATE_MEM(gc_alloc_table_start) = (byte*)start; - -#if MICROPY_ENABLE_FINALISER - 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 - - 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 MICROPY_ENABLE_FINALISER - assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len); -#endif - - // clear ATBs - memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len)); - -#if MICROPY_ENABLE_FINALISER - // clear FTBs - memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len); -#endif - - // set last free ATB index to start of heap - MP_STATE_MEM(gc_last_free_atb_index) = 0; - - // unlock the GC - MP_STATE_MEM(gc_lock_depth) = 0; - - // allow auto collection - MP_STATE_MEM(gc_auto_collect_enabled) = 1; - - #if MICROPY_GC_ALLOC_THRESHOLD - // 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 - - #if MICROPY_PY_THREAD - mp_thread_mutex_init(&MP_STATE_MEM(gc_mutex)); - #endif - - 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 MICROPY_ENABLE_FINALISER - 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 - 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) { - GC_ENTER(); - MP_STATE_MEM(gc_lock_depth)++; - GC_EXIT(); -} - -void gc_unlock(void) { - GC_ENTER(); - MP_STATE_MEM(gc_lock_depth)--; - GC_EXIT(); -} - -bool gc_is_locked(void) { - return MP_STATE_MEM(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 */ \ - ) - -// ptr should be of type void* -#define VERIFY_MARK_AND_PUSH(ptr) \ - do { \ - if (VERIFY_PTR(ptr)) { \ - size_t _block = BLOCK_FROM_PTR(ptr); \ - if (ATB_GET_KIND(_block) == AT_HEAD) { \ - /* an unmarked head, mark it, and push it on gc stack */ \ - DEBUG_printf("gc_mark(%p)\n", ptr); \ - ATB_HEAD_TO_MARK(_block); \ - if (MP_STATE_MEM(gc_sp) < &MP_STATE_MEM(gc_stack)[MICROPY_ALLOC_GC_STACK_SIZE]) { \ - *MP_STATE_MEM(gc_sp)++ = _block; \ - } else { \ - MP_STATE_MEM(gc_stack_overflow) = 1; \ - } \ - } \ - } \ - } while (0) - -STATIC void gc_drain_stack(void) { - while (MP_STATE_MEM(gc_sp) > MP_STATE_MEM(gc_stack)) { - // pop the next block off the stack - size_t block = *--MP_STATE_MEM(gc_sp); - - // 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; - VERIFY_MARK_AND_PUSH(ptr); - } - } -} - -STATIC void gc_deal_with_stack_overflow(void) { - while (MP_STATE_MEM(gc_stack_overflow)) { - MP_STATE_MEM(gc_stack_overflow) = 0; - MP_STATE_MEM(gc_sp) = MP_STATE_MEM(gc_stack); - - // 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) { - *MP_STATE_MEM(gc_sp)++ = block; - gc_drain_stack(); - } - } - } -} - -STATIC void gc_sweep(void) { - #if MICROPY_PY_GC_COLLECT_RETVAL - MP_STATE_MEM(gc_collected) = 0; - #endif - // 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 MICROPY_ENABLE_FINALISER - 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 MICROPY_ENABLE_SCHEDULER - mp_sched_lock(); - #endif - mp_call_function_1_protected(dest[0], dest[1]); - #if MICROPY_ENABLE_SCHEDULER - mp_sched_unlock(); - #endif - } - } - // clear finaliser flag - FTB_CLEAR(block); - } -#endif - free_tail = 1; - DEBUG_printf("gc_sweep(%x)\n", PTR_FROM_BLOCK(block)); - #if MICROPY_PY_GC_COLLECT_RETVAL - MP_STATE_MEM(gc_collected)++; - #endif - // fall through to free the head - - case AT_TAIL: - if (free_tail) { - ATB_ANY_TO_FREE(block); - } - break; - - case AT_MARK: - ATB_MARK_TO_HEAD(block); - free_tail = 0; - break; - } - } -} - -void gc_collect_start(void) { - GC_ENTER(); - MP_STATE_MEM(gc_lock_depth)++; - #if MICROPY_GC_ALLOC_THRESHOLD - MP_STATE_MEM(gc_alloc_amount) = 0; - #endif - MP_STATE_MEM(gc_stack_overflow) = 0; - MP_STATE_MEM(gc_sp) = MP_STATE_MEM(gc_stack); - // 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; - gc_collect_root(ptrs, offsetof(mp_state_ctx_t, vm.qstr_last_chunk) / sizeof(void*)); -} - -void gc_collect_root(void **ptrs, size_t len) { - for (size_t i = 0; i < len; i++) { - void *ptr = ptrs[i]; - VERIFY_MARK_AND_PUSH(ptr); - gc_drain_stack(); - } -} - -void gc_collect_end(void) { - gc_deal_with_stack_overflow(); - gc_sweep(); - MP_STATE_MEM(gc_last_free_atb_index) = 0; - MP_STATE_MEM(gc_lock_depth)--; - GC_EXIT(); -} - -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, bool 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; - } - - GC_ENTER(); - - // check if GC is locked - if (MP_STATE_MEM(gc_lock_depth) > 0) { - GC_EXIT(); - return NULL; - } - - size_t i; - size_t end_block; - size_t start_block; - size_t n_free = 0; - int collected = !MP_STATE_MEM(gc_auto_collect_enabled); - - #if MICROPY_GC_ALLOC_THRESHOLD - if (!collected && MP_STATE_MEM(gc_alloc_amount) >= MP_STATE_MEM(gc_alloc_threshold)) { - GC_EXIT(); - gc_collect(); - GC_ENTER(); - } - #endif - - for (;;) { - - // look for a run of n_blocks available blocks - 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]; - 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; } - } - - 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 MICROPY_GC_ALLOC_THRESHOLD - MP_STATE_MEM(gc_alloc_amount) += n_blocks; - #endif - - GC_EXIT(); - - #if MICROPY_GC_CONSERVATIVE_CLEAR - // be conservative and zero out all the newly allocated blocks - memset((byte*)ret_ptr, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK); - #else - // 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 - - #if MICROPY_ENABLE_FINALISER - 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 - (void)has_finaliser; - #endif - - #if EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); - #endif - - 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) { - GC_ENTER(); - if (MP_STATE_MEM(gc_lock_depth) > 0) { - // TODO how to deal with this error? - GC_EXIT(); - return; - } - - 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 MICROPY_ENABLE_FINALISER - FTB_CLEAR(block); - #endif - - // 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 EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); - #endif - } -} - -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 -// 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 MICROPY_ENABLE_FINALISER - has_finaliser = FTB_GET(BLOCK_FROM_PTR((mp_uint_t)ptr)); -#else - has_finaliser = false; -#endif - } - 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 - -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; - } - - void *ptr = ptr_in; - - // sanity check the ptr - if (!VERIFY_PTR(ptr)) { - return NULL; - } - - // get first block - size_t block = BLOCK_FROM_PTR(ptr); - - GC_ENTER(); - - // sanity check the ptr is pointing to the head of a block - if (ATB_GET_KIND(block) != AT_HEAD) { - GC_EXIT(); - return NULL; - } - - if (MP_STATE_MEM(gc_lock_depth) > 0) { - GC_EXIT(); - return NULL; - } - - // 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 EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); - #endif - - 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 MICROPY_GC_CONSERVATIVE_CLEAR - // 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 - // 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 - - #if EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); - #endif - - return ptr_in; - } - - #if MICROPY_ENABLE_FINALISER - bool ftb_state = FTB_GET(block); - #else - bool ftb_state = false; - #endif - - 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 - -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 !EXTENSIVE_HEAP_PROFILING - // 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 - 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 MICROPY_PY_BUILTINS_BYTEARRAY - else if (*ptr == &mp_type_bytearray) { c = 'A'; } - #endif - #if MICROPY_PY_ARRAY - else if (*ptr == &mp_type_array) { c = 'A'; } - #endif - #if MICROPY_PY_BUILTINS_FLOAT - else if (*ptr == &mp_type_float) { c = 'F'; } - #endif - else if (*ptr == &mp_type_fun_bc) { c = 'B'; } - else if (*ptr == &mp_type_module) { c = 'M'; } - else { - c = 'h'; - #if 0 - // 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 - } - 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 DEBUG_PRINT -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 - -#endif // MICROPY_ENABLE_GC diff --git a/user/mpy/py/gc.h b/user/mpy/py/gc.h deleted file mode 100644 index 739349c..0000000 --- a/user/mpy/py/gc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 - -#include - -#include "py/mpconfig.h" -#include "py/misc.h" - -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); - -void *gc_alloc(size_t n_bytes, bool has_finaliser); -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 diff --git a/user/mpy/py/grammar.h b/user/mpy/py/grammar.h deleted file mode 100644 index 6abb1de..0000000 --- a/user/mpy/py/grammar.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2015 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. - */ - -// rules for writing rules: -// - zero_or_more is implemented using opt_rule around a one_or_more rule -// - don't put opt_rule in arguments of or rule; instead, wrap the call to this or rule in opt_rule - -// # Start symbols for the grammar: -// # single_input is a single interactive statement; -// # file_input is a module or sequence of commands read from an input file; -// # eval_input is the input for the eval() functions. -// # NB: compound_stmt in single_input is followed by extra NEWLINE! --> not in MicroPython -// single_input: NEWLINE | simple_stmt | compound_stmt -// file_input: (NEWLINE | stmt)* ENDMARKER -// eval_input: testlist NEWLINE* ENDMARKER - -DEF_RULE_NC(single_input, or(3), tok(NEWLINE), rule(simple_stmt), rule(compound_stmt)) -DEF_RULE(file_input, c(generic_all_nodes), and_ident(1), opt_rule(file_input_2)) -DEF_RULE(file_input_2, c(generic_all_nodes), one_or_more, rule(file_input_3)) -DEF_RULE_NC(file_input_3, or(2), tok(NEWLINE), rule(stmt)) -DEF_RULE_NC(eval_input, and_ident(2), rule(testlist), opt_rule(eval_input_2)) -DEF_RULE_NC(eval_input_2, and(1), tok(NEWLINE)) - -// decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE -// decorators: decorator+ -// decorated: decorators (classdef | funcdef | async_funcdef) -// funcdef: 'def' NAME parameters ['->' test] ':' suite -// async_funcdef: 'async' funcdef -// parameters: '(' [typedargslist] ')' -// typedargslist: tfpdef ['=' test] (',' tfpdef ['=' test])* [',' ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]] | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef -// tfpdef: NAME [':' test] -// varargslist: vfpdef ['=' test] (',' vfpdef ['=' test])* [',' ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]] | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef -// vfpdef: NAME - -DEF_RULE_NC(decorator, and(4), tok(DEL_AT), rule(dotted_name), opt_rule(trailer_paren), tok(NEWLINE)) -DEF_RULE_NC(decorators, one_or_more, rule(decorator)) -DEF_RULE(decorated, c(decorated), and_ident(2), rule(decorators), rule(decorated_body)) -#if MICROPY_PY_ASYNC_AWAIT -DEF_RULE_NC(decorated_body, or(3), rule(classdef), rule(funcdef), rule(async_funcdef)) -DEF_RULE_NC(async_funcdef, and(2), tok(KW_ASYNC), rule(funcdef)) -#else -DEF_RULE_NC(decorated_body, or(2), rule(classdef), rule(funcdef)) -#endif -DEF_RULE(funcdef, c(funcdef), and_blank(8), tok(KW_DEF), tok(NAME), tok(DEL_PAREN_OPEN), opt_rule(typedargslist), tok(DEL_PAREN_CLOSE), opt_rule(funcdefrettype), tok(DEL_COLON), rule(suite)) -DEF_RULE_NC(funcdefrettype, and_ident(2), tok(DEL_MINUS_MORE), rule(test)) -// note: typedargslist lets through more than is allowed, compiler does further checks -DEF_RULE_NC(typedargslist, list_with_end, rule(typedargslist_item), tok(DEL_COMMA)) -DEF_RULE_NC(typedargslist_item, or(3), rule(typedargslist_name), rule(typedargslist_star), rule(typedargslist_dbl_star)) -DEF_RULE_NC(typedargslist_name, and_ident(3), tok(NAME), opt_rule(typedargslist_colon), opt_rule(typedargslist_equal)) -DEF_RULE_NC(typedargslist_star, and(2), tok(OP_STAR), opt_rule(tfpdef)) -DEF_RULE_NC(typedargslist_dbl_star, and(3), tok(OP_DBL_STAR), tok(NAME), opt_rule(typedargslist_colon)) -DEF_RULE_NC(typedargslist_colon, and_ident(2), tok(DEL_COLON), rule(test)) -DEF_RULE_NC(typedargslist_equal, and_ident(2), tok(DEL_EQUAL), rule(test)) -DEF_RULE_NC(tfpdef, and(2), tok(NAME), opt_rule(typedargslist_colon)) -// note: varargslist lets through more than is allowed, compiler does further checks -DEF_RULE_NC(varargslist, list_with_end, rule(varargslist_item), tok(DEL_COMMA)) -DEF_RULE_NC(varargslist_item, or(3), rule(varargslist_name), rule(varargslist_star), rule(varargslist_dbl_star)) -DEF_RULE_NC(varargslist_name, and_ident(2), tok(NAME), opt_rule(varargslist_equal)) -DEF_RULE_NC(varargslist_star, and(2), tok(OP_STAR), opt_rule(vfpdef)) -DEF_RULE_NC(varargslist_dbl_star, and(2), tok(OP_DBL_STAR), tok(NAME)) -DEF_RULE_NC(varargslist_equal, and_ident(2), tok(DEL_EQUAL), rule(test)) -DEF_RULE_NC(vfpdef, and_ident(1), tok(NAME)) - -// stmt: compound_stmt | simple_stmt - -DEF_RULE_NC(stmt, or(2), rule(compound_stmt), rule(simple_stmt)) - -// simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE - -DEF_RULE_NC(simple_stmt, and_ident(2), rule(simple_stmt_2), tok(NEWLINE)) -DEF_RULE(simple_stmt_2, c(generic_all_nodes), list_with_end, rule(small_stmt), tok(DEL_SEMICOLON)) - -// small_stmt: expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt -// expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist_star_expr))*) -// testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [','] -// augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=' -// # For normal assignments, additional restrictions enforced by the interpreter - -DEF_RULE_NC(small_stmt, or(8), rule(del_stmt), rule(pass_stmt), rule(flow_stmt), rule(import_stmt), rule(global_stmt), rule(nonlocal_stmt), rule(assert_stmt), rule(expr_stmt)) -DEF_RULE(expr_stmt, c(expr_stmt), and(2), rule(testlist_star_expr), opt_rule(expr_stmt_2)) -DEF_RULE_NC(expr_stmt_2, or(2), rule(expr_stmt_augassign), rule(expr_stmt_assign_list)) -DEF_RULE_NC(expr_stmt_augassign, and_ident(2), rule(augassign), rule(expr_stmt_6)) -DEF_RULE_NC(expr_stmt_assign_list, one_or_more, rule(expr_stmt_assign)) -DEF_RULE_NC(expr_stmt_assign, and_ident(2), tok(DEL_EQUAL), rule(expr_stmt_6)) -DEF_RULE_NC(expr_stmt_6, or(2), rule(yield_expr), rule(testlist_star_expr)) -DEF_RULE(testlist_star_expr, c(generic_tuple), list_with_end, rule(testlist_star_expr_2), tok(DEL_COMMA)) -DEF_RULE_NC(testlist_star_expr_2, or(2), rule(star_expr), rule(test)) -DEF_RULE_NC(augassign, or(12), tok(DEL_PLUS_EQUAL), tok(DEL_MINUS_EQUAL), tok(DEL_STAR_EQUAL), tok(DEL_SLASH_EQUAL), tok(DEL_PERCENT_EQUAL), tok(DEL_AMPERSAND_EQUAL), tok(DEL_PIPE_EQUAL), tok(DEL_CARET_EQUAL), tok(DEL_DBL_LESS_EQUAL), tok(DEL_DBL_MORE_EQUAL), tok(DEL_DBL_STAR_EQUAL), tok(DEL_DBL_SLASH_EQUAL)) - -// del_stmt: 'del' exprlist -// pass_stmt: 'pass' -// flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt -// break_stmt: 'break' -// continue_stmt: 'continue' -// return_stmt: 'return' [testlist] -// yield_stmt: yield_expr -// raise_stmt: 'raise' [test ['from' test]] - -DEF_RULE(del_stmt, c(del_stmt), and(2), tok(KW_DEL), rule(exprlist)) -DEF_RULE(pass_stmt, c(generic_all_nodes), and(1), tok(KW_PASS)) -DEF_RULE_NC(flow_stmt, or(5), rule(break_stmt), rule(continue_stmt), rule(return_stmt), rule(raise_stmt), rule(yield_stmt)) -DEF_RULE(break_stmt, c(break_stmt), and(1), tok(KW_BREAK)) -DEF_RULE(continue_stmt, c(continue_stmt), and(1), tok(KW_CONTINUE)) -DEF_RULE(return_stmt, c(return_stmt), and(2), tok(KW_RETURN), opt_rule(testlist)) -DEF_RULE(yield_stmt, c(yield_stmt), and(1), rule(yield_expr)) -DEF_RULE(raise_stmt, c(raise_stmt), and(2), tok(KW_RAISE), opt_rule(raise_stmt_arg)) -DEF_RULE_NC(raise_stmt_arg, and_ident(2), rule(test), opt_rule(raise_stmt_from)) -DEF_RULE_NC(raise_stmt_from, and_ident(2), tok(KW_FROM), rule(test)) - -// import_stmt: import_name | import_from -// import_name: 'import' dotted_as_names -// import_from: 'from' (('.' | '...')* dotted_name | ('.' | '...')+) 'import' ('*' | '(' import_as_names ')' | import_as_names) -// import_as_name: NAME ['as' NAME] -// dotted_as_name: dotted_name ['as' NAME] -// import_as_names: import_as_name (',' import_as_name)* [','] -// dotted_as_names: dotted_as_name (',' dotted_as_name)* -// dotted_name: NAME ('.' NAME)* -// global_stmt: 'global' NAME (',' NAME)* -// nonlocal_stmt: 'nonlocal' NAME (',' NAME)* -// assert_stmt: 'assert' test [',' test] - -DEF_RULE_NC(import_stmt, or(2), rule(import_name), rule(import_from)) -DEF_RULE(import_name, c(import_name), and(2), tok(KW_IMPORT), rule(dotted_as_names)) -DEF_RULE(import_from, c(import_from), and(4), tok(KW_FROM), rule(import_from_2), tok(KW_IMPORT), rule(import_from_3)) -DEF_RULE_NC(import_from_2, or(2), rule(dotted_name), rule(import_from_2b)) -DEF_RULE_NC(import_from_2b, and_ident(2), rule(one_or_more_period_or_ellipsis), opt_rule(dotted_name)) -DEF_RULE_NC(import_from_3, or(3), tok(OP_STAR), rule(import_as_names_paren), rule(import_as_names)) -DEF_RULE_NC(import_as_names_paren, and_ident(3), tok(DEL_PAREN_OPEN), rule(import_as_names), tok(DEL_PAREN_CLOSE)) -DEF_RULE_NC(one_or_more_period_or_ellipsis, one_or_more, rule(period_or_ellipsis)) -DEF_RULE_NC(period_or_ellipsis, or(2), tok(DEL_PERIOD), tok(ELLIPSIS)) -DEF_RULE_NC(import_as_name, and(2), tok(NAME), opt_rule(as_name)) -DEF_RULE_NC(dotted_as_name, and_ident(2), rule(dotted_name), opt_rule(as_name)) -DEF_RULE_NC(as_name, and_ident(2), tok(KW_AS), tok(NAME)) -DEF_RULE_NC(import_as_names, list_with_end, rule(import_as_name), tok(DEL_COMMA)) -DEF_RULE_NC(dotted_as_names, list, rule(dotted_as_name), tok(DEL_COMMA)) -DEF_RULE_NC(dotted_name, list, tok(NAME), tok(DEL_PERIOD)) -DEF_RULE(global_stmt, c(global_stmt), and(2), tok(KW_GLOBAL), rule(name_list)) -DEF_RULE(nonlocal_stmt, c(nonlocal_stmt), and(2), tok(KW_NONLOCAL), rule(name_list)) -DEF_RULE_NC(name_list, list, tok(NAME), tok(DEL_COMMA)) -DEF_RULE(assert_stmt, c(assert_stmt), and(3), tok(KW_ASSERT), rule(test), opt_rule(assert_stmt_extra)) -DEF_RULE_NC(assert_stmt_extra, and_ident(2), tok(DEL_COMMA), rule(test)) - -// compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt -// if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -// while_stmt: 'while' test ':' suite ['else' ':' suite] -// for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] -// try_stmt: 'try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite) -// # NB compile.c makes sure that the default except clause is last -// except_clause: 'except' [test ['as' NAME]] -// with_stmt: 'with' with_item (',' with_item)* ':' suite -// with_item: test ['as' expr] -// suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT -// async_stmt: 'async' (funcdef | with_stmt | for_stmt) - -#if MICROPY_PY_ASYNC_AWAIT -DEF_RULE_NC(compound_stmt, or(9), rule(if_stmt), rule(while_stmt), rule(for_stmt), rule(try_stmt), rule(with_stmt), rule(funcdef), rule(classdef), rule(decorated), rule(async_stmt)) -DEF_RULE(async_stmt, c(async_stmt), and(2), tok(KW_ASYNC), rule(async_stmt_2)) -DEF_RULE_NC(async_stmt_2, or(3), rule(funcdef), rule(with_stmt), rule(for_stmt)) -#else -DEF_RULE_NC(compound_stmt, or(8), rule(if_stmt), rule(while_stmt), rule(for_stmt), rule(try_stmt), rule(with_stmt), rule(funcdef), rule(classdef), rule(decorated)) -#endif -DEF_RULE(if_stmt, c(if_stmt), and(6), tok(KW_IF), rule(test), tok(DEL_COLON), rule(suite), opt_rule(if_stmt_elif_list), opt_rule(else_stmt)) -DEF_RULE_NC(if_stmt_elif_list, one_or_more, rule(if_stmt_elif)) -DEF_RULE_NC(if_stmt_elif, and(4), tok(KW_ELIF), rule(test), tok(DEL_COLON), rule(suite)) -DEF_RULE(while_stmt, c(while_stmt), and(5), tok(KW_WHILE), rule(test), tok(DEL_COLON), rule(suite), opt_rule(else_stmt)) -DEF_RULE(for_stmt, c(for_stmt), and(7), tok(KW_FOR), rule(exprlist), tok(KW_IN), rule(testlist), tok(DEL_COLON), rule(suite), opt_rule(else_stmt)) -DEF_RULE(try_stmt, c(try_stmt), and(4), tok(KW_TRY), tok(DEL_COLON), rule(suite), rule(try_stmt_2)) -DEF_RULE_NC(try_stmt_2, or(2), rule(try_stmt_except_and_more), rule(try_stmt_finally)) -DEF_RULE_NC(try_stmt_except_and_more, and_ident(3), rule(try_stmt_except_list), opt_rule(else_stmt), opt_rule(try_stmt_finally)) -DEF_RULE_NC(try_stmt_except, and(4), tok(KW_EXCEPT), opt_rule(try_stmt_as_name), tok(DEL_COLON), rule(suite)) -DEF_RULE_NC(try_stmt_as_name, and_ident(2), rule(test), opt_rule(as_name)) -DEF_RULE_NC(try_stmt_except_list, one_or_more, rule(try_stmt_except)) -DEF_RULE_NC(try_stmt_finally, and(3), tok(KW_FINALLY), tok(DEL_COLON), rule(suite)) -DEF_RULE_NC(else_stmt, and_ident(3), tok(KW_ELSE), tok(DEL_COLON), rule(suite)) -DEF_RULE(with_stmt, c(with_stmt), and(4), tok(KW_WITH), rule(with_stmt_list), tok(DEL_COLON), rule(suite)) -DEF_RULE_NC(with_stmt_list, list, rule(with_item), tok(DEL_COMMA)) -DEF_RULE_NC(with_item, and_ident(2), rule(test), opt_rule(with_item_as)) -DEF_RULE_NC(with_item_as, and_ident(2), tok(KW_AS), rule(expr)) -DEF_RULE_NC(suite, or(2), rule(suite_block), rule(simple_stmt)) -DEF_RULE_NC(suite_block, and_ident(4), tok(NEWLINE), tok(INDENT), rule(suite_block_stmts), tok(DEDENT)) -DEF_RULE(suite_block_stmts, c(generic_all_nodes), one_or_more, rule(stmt)) - -// test: or_test ['if' or_test 'else' test] | lambdef -// test_nocond: or_test | lambdef_nocond -// lambdef: 'lambda' [varargslist] ':' test -// lambdef_nocond: 'lambda' [varargslist] ':' test_nocond - -DEF_RULE_NC(test, or(2), rule(lambdef), rule(test_if_expr)) -DEF_RULE(test_if_expr, c(test_if_expr), and_ident(2), rule(or_test), opt_rule(test_if_else)) -DEF_RULE_NC(test_if_else, and(4), tok(KW_IF), rule(or_test), tok(KW_ELSE), rule(test)) -DEF_RULE_NC(test_nocond, or(2), rule(lambdef_nocond), rule(or_test)) -DEF_RULE(lambdef, c(lambdef), and_blank(4), tok(KW_LAMBDA), opt_rule(varargslist), tok(DEL_COLON), rule(test)) -DEF_RULE(lambdef_nocond, c(lambdef), and_blank(4), tok(KW_LAMBDA), opt_rule(varargslist), tok(DEL_COLON), rule(test_nocond)) - -// or_test: and_test ('or' and_test)* -// and_test: not_test ('and' not_test)* -// not_test: 'not' not_test | comparison -// comparison: expr (comp_op expr)* -// comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not' -// star_expr: '*' expr -// expr: xor_expr ('|' xor_expr)* -// xor_expr: and_expr ('^' and_expr)* -// and_expr: shift_expr ('&' shift_expr)* -// shift_expr: arith_expr (('<<'|'>>') arith_expr)* -// arith_expr: term (('+'|'-') term)* -// term: factor (('*'|'/'|'%'|'//') factor)* -// factor: ('+'|'-'|'~') factor | power -// power: atom_expr ['**' factor] -// atom_expr: 'await' atom trailer* | atom trailer* - -DEF_RULE(or_test, c(or_test), list, rule(and_test), tok(KW_OR)) -DEF_RULE(and_test, c(and_test), list, rule(not_test), tok(KW_AND)) -DEF_RULE_NC(not_test, or(2), rule(not_test_2), rule(comparison)) -DEF_RULE(not_test_2, c(not_test_2), and(2), tok(KW_NOT), rule(not_test)) -DEF_RULE(comparison, c(comparison), list, rule(expr), rule(comp_op)) -DEF_RULE_NC(comp_op, or(9), tok(OP_LESS), tok(OP_MORE), tok(OP_DBL_EQUAL), tok(OP_LESS_EQUAL), tok(OP_MORE_EQUAL), tok(OP_NOT_EQUAL), tok(KW_IN), rule(comp_op_not_in), rule(comp_op_is)) -DEF_RULE_NC(comp_op_not_in, and(2), tok(KW_NOT), tok(KW_IN)) -DEF_RULE_NC(comp_op_is, and(2), tok(KW_IS), opt_rule(comp_op_is_not)) -DEF_RULE_NC(comp_op_is_not, and(1), tok(KW_NOT)) -DEF_RULE(star_expr, c(star_expr), and(2), tok(OP_STAR), rule(expr)) -DEF_RULE(expr, c(expr), list, rule(xor_expr), tok(OP_PIPE)) -DEF_RULE(xor_expr, c(xor_expr), list, rule(and_expr), tok(OP_CARET)) -DEF_RULE(and_expr, c(and_expr), list, rule(shift_expr), tok(OP_AMPERSAND)) -DEF_RULE(shift_expr, c(term), list, rule(arith_expr), rule(shift_op)) -DEF_RULE_NC(shift_op, or(2), tok(OP_DBL_LESS), tok(OP_DBL_MORE)) -DEF_RULE(arith_expr, c(term), list, rule(term), rule(arith_op)) -DEF_RULE_NC(arith_op, or(2), tok(OP_PLUS), tok(OP_MINUS)) -DEF_RULE(term, c(term), list, rule(factor), rule(term_op)) -DEF_RULE_NC(term_op, or(4), tok(OP_STAR), tok(OP_SLASH), tok(OP_PERCENT), tok(OP_DBL_SLASH)) -DEF_RULE_NC(factor, or(2), rule(factor_2), rule(power)) -DEF_RULE(factor_2, c(factor_2), and_ident(2), rule(factor_op), rule(factor)) -DEF_RULE_NC(factor_op, or(3), tok(OP_PLUS), tok(OP_MINUS), tok(OP_TILDE)) -DEF_RULE(power, c(power), and_ident(2), rule(atom_expr), opt_rule(power_dbl_star)) -#if MICROPY_PY_ASYNC_AWAIT -DEF_RULE_NC(atom_expr, or(2), rule(atom_expr_await), rule(atom_expr_normal)) -DEF_RULE(atom_expr_await, c(atom_expr_await), and(3), tok(KW_AWAIT), rule(atom), opt_rule(atom_expr_trailers)) -#else -DEF_RULE_NC(atom_expr, or(1), rule(atom_expr_normal)) -#endif -DEF_RULE(atom_expr_normal, c(atom_expr_normal), and_ident(2), rule(atom), opt_rule(atom_expr_trailers)) -DEF_RULE_NC(atom_expr_trailers, one_or_more, rule(trailer)) -DEF_RULE_NC(power_dbl_star, and_ident(2), tok(OP_DBL_STAR), rule(factor)) - -// atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False' -// testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) -// trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME - -DEF_RULE_NC(atom, or(12), tok(NAME), tok(INTEGER), tok(FLOAT_OR_IMAG), tok(STRING), tok(BYTES), tok(ELLIPSIS), tok(KW_NONE), tok(KW_TRUE), tok(KW_FALSE), rule(atom_paren), rule(atom_bracket), rule(atom_brace)) -DEF_RULE(atom_paren, c(atom_paren), and(3), tok(DEL_PAREN_OPEN), opt_rule(atom_2b), tok(DEL_PAREN_CLOSE)) -DEF_RULE_NC(atom_2b, or(2), rule(yield_expr), rule(testlist_comp)) -DEF_RULE(atom_bracket, c(atom_bracket), and(3), tok(DEL_BRACKET_OPEN), opt_rule(testlist_comp), tok(DEL_BRACKET_CLOSE)) -DEF_RULE(atom_brace, c(atom_brace), and(3), tok(DEL_BRACE_OPEN), opt_rule(dictorsetmaker), tok(DEL_BRACE_CLOSE)) -DEF_RULE_NC(testlist_comp, and_ident(2), rule(testlist_comp_2), opt_rule(testlist_comp_3)) -DEF_RULE_NC(testlist_comp_2, or(2), rule(star_expr), rule(test)) -DEF_RULE_NC(testlist_comp_3, or(2), rule(comp_for), rule(testlist_comp_3b)) -DEF_RULE_NC(testlist_comp_3b, and_ident(2), tok(DEL_COMMA), opt_rule(testlist_comp_3c)) -DEF_RULE_NC(testlist_comp_3c, list_with_end, rule(testlist_comp_2), tok(DEL_COMMA)) -DEF_RULE_NC(trailer, or(3), rule(trailer_paren), rule(trailer_bracket), rule(trailer_period)) -DEF_RULE(trailer_paren, c(trailer_paren), and(3), tok(DEL_PAREN_OPEN), opt_rule(arglist), tok(DEL_PAREN_CLOSE)) -DEF_RULE(trailer_bracket, c(trailer_bracket), and(3), tok(DEL_BRACKET_OPEN), rule(subscriptlist), tok(DEL_BRACKET_CLOSE)) -DEF_RULE(trailer_period, c(trailer_period), and(2), tok(DEL_PERIOD), tok(NAME)) - -// subscriptlist: subscript (',' subscript)* [','] -// subscript: test | [test] ':' [test] [sliceop] -// sliceop: ':' [test] - -#if MICROPY_PY_BUILTINS_SLICE -DEF_RULE(subscriptlist, c(generic_tuple), list_with_end, rule(subscript), tok(DEL_COMMA)) -DEF_RULE_NC(subscript, or(2), rule(subscript_3), rule(subscript_2)) -DEF_RULE(subscript_2, c(subscript_2), and_ident(2), rule(test), opt_rule(subscript_3)) -DEF_RULE(subscript_3, c(subscript_3), and(2), tok(DEL_COLON), opt_rule(subscript_3b)) -DEF_RULE_NC(subscript_3b, or(2), rule(subscript_3c), rule(subscript_3d)) -DEF_RULE_NC(subscript_3c, and(2), tok(DEL_COLON), opt_rule(test)) -DEF_RULE_NC(subscript_3d, and_ident(2), rule(test), opt_rule(sliceop)) -DEF_RULE_NC(sliceop, and(2), tok(DEL_COLON), opt_rule(test)) -#else -DEF_RULE(subscriptlist, c(generic_tuple), list_with_end, rule(test), tok(DEL_COMMA)) -#endif - -// exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] -// testlist: test (',' test)* [','] -// dictorsetmaker: (test ':' test (comp_for | (',' test ':' test)* [','])) | (test (comp_for | (',' test)* [','])) - -DEF_RULE_NC(exprlist, list_with_end, rule(exprlist_2), tok(DEL_COMMA)) -DEF_RULE_NC(exprlist_2, or(2), rule(star_expr), rule(expr)) -DEF_RULE(testlist, c(generic_tuple), list_with_end, rule(test), tok(DEL_COMMA)) -// TODO dictorsetmaker lets through more than is allowed -DEF_RULE_NC(dictorsetmaker, and_ident(2), rule(dictorsetmaker_item), opt_rule(dictorsetmaker_tail)) -#if MICROPY_PY_BUILTINS_SET -DEF_RULE(dictorsetmaker_item, c(dictorsetmaker_item), and_ident(2), rule(test), opt_rule(dictorsetmaker_colon)) -DEF_RULE_NC(dictorsetmaker_colon, and_ident(2), tok(DEL_COLON), rule(test)) -#else -DEF_RULE(dictorsetmaker_item, c(dictorsetmaker_item), and(3), rule(test), tok(DEL_COLON), rule(test)) -#endif -DEF_RULE_NC(dictorsetmaker_tail, or(2), rule(comp_for), rule(dictorsetmaker_list)) -DEF_RULE_NC(dictorsetmaker_list, and(2), tok(DEL_COMMA), opt_rule(dictorsetmaker_list2)) -DEF_RULE_NC(dictorsetmaker_list2, list_with_end, rule(dictorsetmaker_item), tok(DEL_COMMA)) - -// classdef: 'class' NAME ['(' [arglist] ')'] ':' suite - -DEF_RULE(classdef, c(classdef), and_blank(5), tok(KW_CLASS), tok(NAME), opt_rule(classdef_2), tok(DEL_COLON), rule(suite)) -DEF_RULE_NC(classdef_2, and_ident(3), tok(DEL_PAREN_OPEN), opt_rule(arglist), tok(DEL_PAREN_CLOSE)) - -// arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test) - -// TODO arglist lets through more than is allowed, compiler needs to do further verification -DEF_RULE_NC(arglist, list_with_end, rule(arglist_2), tok(DEL_COMMA)) -DEF_RULE_NC(arglist_2, or(3), rule(arglist_star), rule(arglist_dbl_star), rule(argument)) -DEF_RULE_NC(arglist_star, and(2), tok(OP_STAR), rule(test)) -DEF_RULE_NC(arglist_dbl_star, and(2), tok(OP_DBL_STAR), rule(test)) - -// # The reason that keywords are test nodes instead of NAME is that using NAME -// # results in an ambiguity. ast.c makes sure it's a NAME. -// argument: test [comp_for] | test '=' test # Really [keyword '='] test -// comp_iter: comp_for | comp_if -// comp_for: 'for' exprlist 'in' or_test [comp_iter] -// comp_if: 'if' test_nocond [comp_iter] - -DEF_RULE_NC(argument, and_ident(2), rule(test), opt_rule(argument_2)) -DEF_RULE_NC(argument_2, or(2), rule(comp_for), rule(argument_3)) -DEF_RULE_NC(argument_3, and_ident(2), tok(DEL_EQUAL), rule(test)) -DEF_RULE_NC(comp_iter, or(2), rule(comp_for), rule(comp_if)) -DEF_RULE_NC(comp_for, and_blank(5), tok(KW_FOR), rule(exprlist), tok(KW_IN), rule(or_test), opt_rule(comp_iter)) -DEF_RULE_NC(comp_if, and(3), tok(KW_IF), rule(test_nocond), opt_rule(comp_iter)) - -// # not used in grammar, but may appear in "node" passed from Parser to Compiler -// encoding_decl: NAME - -// yield_expr: 'yield' [yield_arg] -// yield_arg: 'from' test | testlist - -DEF_RULE(yield_expr, c(yield_expr), and(2), tok(KW_YIELD), opt_rule(yield_arg)) -DEF_RULE_NC(yield_arg, or(2), rule(yield_arg_from), rule(testlist)) -DEF_RULE_NC(yield_arg_from, and(2), tok(KW_FROM), rule(test)) diff --git a/user/mpy/py/lexer.c b/user/mpy/py/lexer.c deleted file mode 100644 index 074d6f3..0000000 --- a/user/mpy/py/lexer.c +++ /dev/null @@ -1,763 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpstate.h" -#include "py/reader.h" -#include "py/lexer.h" -#include "py/runtime.h" - -#if MICROPY_ENABLE_COMPILER - -#define TAB_SIZE (8) - -// TODO seems that CPython allows NULL byte in the input stream -// don't know if that's intentional or not, but we don't allow it - -#define MP_LEXER_EOF ((unichar)MP_READER_EOF) -#define CUR_CHAR(lex) ((lex)->chr0) - -STATIC bool is_end(mp_lexer_t *lex) { - return lex->chr0 == MP_LEXER_EOF; -} - -STATIC bool is_physical_newline(mp_lexer_t *lex) { - return lex->chr0 == '\n'; -} - -STATIC bool is_char(mp_lexer_t *lex, byte c) { - return lex->chr0 == c; -} - -STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr0 == c1 || lex->chr0 == c2; -} - -STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) { - return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3; -} - -STATIC bool is_char_following(mp_lexer_t *lex, byte c) { - return lex->chr1 == c; -} - -STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr1 == c1 || lex->chr1 == c2; -} - -STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr2 == c1 || lex->chr2 == c2; -} - -STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) { - return lex->chr0 == c1 && lex->chr1 == c2; -} - -STATIC bool is_whitespace(mp_lexer_t *lex) { - return unichar_isspace(lex->chr0); -} - -STATIC bool is_letter(mp_lexer_t *lex) { - return unichar_isalpha(lex->chr0); -} - -STATIC bool is_digit(mp_lexer_t *lex) { - return unichar_isdigit(lex->chr0); -} - -STATIC bool is_following_digit(mp_lexer_t *lex) { - return unichar_isdigit(lex->chr1); -} - -STATIC bool is_following_base_char(mp_lexer_t *lex) { - const unichar chr1 = lex->chr1 | 0x20; - return chr1 == 'b' || chr1 == 'o' || chr1 == 'x'; -} - -STATIC bool is_following_odigit(mp_lexer_t *lex) { - return lex->chr1 >= '0' && lex->chr1 <= '7'; -} - -STATIC bool is_string_or_bytes(mp_lexer_t *lex) { - return is_char_or(lex, '\'', '\"') - || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"')) - || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r')) - && is_char_following_following_or(lex, '\'', '\"')); -} - -// to easily parse utf-8 identifiers we allow any raw byte with high bit set -STATIC bool is_head_of_identifier(mp_lexer_t *lex) { - return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80; -} - -STATIC bool is_tail_of_identifier(mp_lexer_t *lex) { - return is_head_of_identifier(lex) || is_digit(lex); -} - -STATIC void next_char(mp_lexer_t *lex) { - if (lex->chr0 == '\n') { - // a new line - ++lex->line; - lex->column = 1; - } else if (lex->chr0 == '\t') { - // a tab - lex->column = (((lex->column - 1 + TAB_SIZE) / TAB_SIZE) * TAB_SIZE) + 1; - } else { - // a character worth one column - ++lex->column; - } - - lex->chr0 = lex->chr1; - lex->chr1 = lex->chr2; - lex->chr2 = lex->reader.readbyte(lex->reader.data); - - if (lex->chr1 == '\r') { - // CR is a new line, converted to LF - lex->chr1 = '\n'; - if (lex->chr2 == '\n') { - // CR LF is a single new line, throw out the extra LF - lex->chr2 = lex->reader.readbyte(lex->reader.data); - } - } - - // check if we need to insert a newline at end of file - if (lex->chr2 == MP_LEXER_EOF && lex->chr1 != MP_LEXER_EOF && lex->chr1 != '\n') { - lex->chr2 = '\n'; - } -} - -STATIC void indent_push(mp_lexer_t *lex, size_t indent) { - if (lex->num_indent_level >= lex->alloc_indent_level) { - lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC); - lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC; - } - lex->indent_level[lex->num_indent_level++] = indent; -} - -STATIC size_t indent_top(mp_lexer_t *lex) { - return lex->indent_level[lex->num_indent_level - 1]; -} - -STATIC void indent_pop(mp_lexer_t *lex) { - lex->num_indent_level -= 1; -} - -// some tricky operator encoding: -// = begin with , if this opchar matches then begin here -// e = end with , if this opchar matches then end -// c = continue with , if this opchar matches then continue matching -// this means if the start of two ops are the same then they are equal til the last char - -STATIC const char *const tok_enc = - "()[]{},:;@~" // singles - "e=c>e=" // > >= >> >>= - "*e=c*e=" // * *= ** **= - "+e=" // + += - "-e=e>" // - -= -> - "&e=" // & &= - "|e=" // | |= - "/e=c/e=" // / /= // //= - "%e=" // % %= - "^e=" // ^ ^= - "=e=" // = == - "!."; // start of special cases: != . ... - -// TODO static assert that number of tokens is less than 256 so we can safely make this table with byte sized entries -STATIC const uint8_t tok_enc_kind[] = { - MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, MP_TOKEN_DEL_COLON, MP_TOKEN_DEL_SEMICOLON, MP_TOKEN_DEL_AT, MP_TOKEN_OP_TILDE, - - MP_TOKEN_OP_LESS, MP_TOKEN_OP_LESS_EQUAL, MP_TOKEN_OP_DBL_LESS, MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_OP_MORE, MP_TOKEN_OP_MORE_EQUAL, MP_TOKEN_OP_DBL_MORE, MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_OP_STAR, MP_TOKEN_DEL_STAR_EQUAL, MP_TOKEN_OP_DBL_STAR, MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_OP_PLUS, MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_OP_MINUS, MP_TOKEN_DEL_MINUS_EQUAL, MP_TOKEN_DEL_MINUS_MORE, - MP_TOKEN_OP_AMPERSAND, MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_OP_PIPE, MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_OP_SLASH, MP_TOKEN_DEL_SLASH_EQUAL, MP_TOKEN_OP_DBL_SLASH, MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_OP_PERCENT, MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_OP_CARET, MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_EQUAL, MP_TOKEN_OP_DBL_EQUAL, -}; - -// must have the same order as enum in lexer.h -// must be sorted according to strcmp -STATIC const char *const tok_kw[] = { - "False", - "None", - "True", - "__debug__", - "and", - "as", - "assert", - #if MICROPY_PY_ASYNC_AWAIT - "async", - "await", - #endif - "break", - "class", - "continue", - "def", - "del", - "elif", - "else", - "except", - "finally", - "for", - "from", - "global", - "if", - "import", - "in", - "is", - "lambda", - "nonlocal", - "not", - "or", - "pass", - "raise", - "return", - "try", - "while", - "with", - "yield", -}; - -// This is called with CUR_CHAR() before first hex digit, and should return with -// it pointing to last hex digit -// num_digits must be greater than zero -STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) { - mp_uint_t num = 0; - while (num_digits-- != 0) { - next_char(lex); - unichar c = CUR_CHAR(lex); - if (!unichar_isxdigit(c)) { - return false; - } - num = (num << 4) + unichar_xdigit_value(c); - } - *result = num; - return true; -} - -STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) { - // get first quoting character - char quote_char = '\''; - if (is_char(lex, '\"')) { - quote_char = '\"'; - } - next_char(lex); - - // work out if it's a single or triple quoted literal - size_t num_quotes; - if (is_char_and(lex, quote_char, quote_char)) { - // triple quotes - next_char(lex); - next_char(lex); - num_quotes = 3; - } else { - // single quotes - num_quotes = 1; - } - - size_t n_closing = 0; - while (!is_end(lex) && (num_quotes > 1 || !is_char(lex, '\n')) && n_closing < num_quotes) { - if (is_char(lex, quote_char)) { - n_closing += 1; - vstr_add_char(&lex->vstr, CUR_CHAR(lex)); - } else { - n_closing = 0; - if (is_char(lex, '\\')) { - next_char(lex); - unichar c = CUR_CHAR(lex); - if (is_raw) { - // raw strings allow escaping of quotes, but the backslash is also emitted - vstr_add_char(&lex->vstr, '\\'); - } else { - switch (c) { - // note: "c" can never be MP_LEXER_EOF because next_char - // always inserts a newline at the end of the input stream - case '\n': c = MP_LEXER_EOF; break; // backslash escape the newline, just ignore it - case '\\': break; - case '\'': break; - case '"': break; - case 'a': c = 0x07; break; - case 'b': c = 0x08; break; - case 't': c = 0x09; break; - case 'n': c = 0x0a; break; - case 'v': c = 0x0b; break; - case 'f': c = 0x0c; break; - case 'r': c = 0x0d; break; - case 'u': - case 'U': - if (lex->tok_kind == MP_TOKEN_BYTES) { - // b'\u1234' == b'\\u1234' - vstr_add_char(&lex->vstr, '\\'); - break; - } - // Otherwise fall through. - case 'x': - { - mp_uint_t num = 0; - if (!get_hex(lex, (c == 'x' ? 2 : c == 'u' ? 4 : 8), &num)) { - // not enough hex chars for escape sequence - lex->tok_kind = MP_TOKEN_INVALID; - } - c = num; - break; - } - case 'N': - // Supporting '\N{LATIN SMALL LETTER A}' == 'a' would require keeping the - // entire Unicode name table in the core. As of Unicode 6.3.0, that's nearly - // 3MB of text; even gzip-compressed and with minimal structure, it'll take - // roughly half a meg of storage. This form of Unicode escape may be added - // later on, but it's definitely not a priority right now. -- CJA 20140607 - mp_raise_NotImplementedError("unicode name escapes"); - break; - default: - if (c >= '0' && c <= '7') { - // Octal sequence, 1-3 chars - size_t digits = 3; - mp_uint_t num = c - '0'; - while (is_following_odigit(lex) && --digits != 0) { - next_char(lex); - num = num * 8 + (CUR_CHAR(lex) - '0'); - } - c = num; - } else { - // unrecognised escape character; CPython lets this through verbatim as '\' and then the character - vstr_add_char(&lex->vstr, '\\'); - } - break; - } - } - if (c != MP_LEXER_EOF) { - if (MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) { - if (c < 0x110000 && lex->tok_kind == MP_TOKEN_STRING) { - vstr_add_char(&lex->vstr, c); - } else if (c < 0x100 && lex->tok_kind == MP_TOKEN_BYTES) { - vstr_add_byte(&lex->vstr, c); - } else { - // unicode character out of range - // this raises a generic SyntaxError; could provide more info - lex->tok_kind = MP_TOKEN_INVALID; - } - } else { - // without unicode everything is just added as an 8-bit byte - if (c < 0x100) { - vstr_add_byte(&lex->vstr, c); - } else { - // 8-bit character out of range - // this raises a generic SyntaxError; could provide more info - lex->tok_kind = MP_TOKEN_INVALID; - } - } - } - } else { - // Add the "character" as a byte so that we remain 8-bit clean. - // This way, strings are parsed correctly whether or not they contain utf-8 chars. - vstr_add_byte(&lex->vstr, CUR_CHAR(lex)); - } - } - next_char(lex); - } - - // check we got the required end quotes - if (n_closing < num_quotes) { - lex->tok_kind = MP_TOKEN_LONELY_STRING_OPEN; - } - - // cut off the end quotes from the token text - vstr_cut_tail_bytes(&lex->vstr, n_closing); -} - -STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) { - bool had_physical_newline = false; - while (!is_end(lex)) { - if (is_physical_newline(lex)) { - if (stop_at_newline && lex->nested_bracket_level == 0) { - break; - } - had_physical_newline = true; - next_char(lex); - } else if (is_whitespace(lex)) { - next_char(lex); - } else if (is_char(lex, '#')) { - next_char(lex); - while (!is_end(lex) && !is_physical_newline(lex)) { - next_char(lex); - } - // had_physical_newline will be set on next loop - } else if (is_char_and(lex, '\\', '\n')) { - // line-continuation, so don't set had_physical_newline - next_char(lex); - next_char(lex); - } else { - break; - } - } - return had_physical_newline; -} - -void mp_lexer_to_next(mp_lexer_t *lex) { - // start new token text - vstr_reset(&lex->vstr); - - // skip white space and comments - bool had_physical_newline = skip_whitespace(lex, false); - - // set token source information - lex->tok_line = lex->line; - lex->tok_column = lex->column; - - if (lex->emit_dent < 0) { - lex->tok_kind = MP_TOKEN_DEDENT; - lex->emit_dent += 1; - - } else if (lex->emit_dent > 0) { - lex->tok_kind = MP_TOKEN_INDENT; - lex->emit_dent -= 1; - - } else if (had_physical_newline && lex->nested_bracket_level == 0) { - lex->tok_kind = MP_TOKEN_NEWLINE; - - size_t num_spaces = lex->column - 1; - if (num_spaces == indent_top(lex)) { - } else if (num_spaces > indent_top(lex)) { - indent_push(lex, num_spaces); - lex->emit_dent += 1; - } else { - while (num_spaces < indent_top(lex)) { - indent_pop(lex); - lex->emit_dent -= 1; - } - if (num_spaces != indent_top(lex)) { - lex->tok_kind = MP_TOKEN_DEDENT_MISMATCH; - } - } - - } else if (is_end(lex)) { - lex->tok_kind = MP_TOKEN_END; - - } else if (is_string_or_bytes(lex)) { - // a string or bytes literal - - // Python requires adjacent string/bytes literals to be automatically - // concatenated. We do it here in the tokeniser to make efficient use of RAM, - // because then the lexer's vstr can be used to accumulate the string literal, - // in contrast to creating a parse tree of strings and then joining them later - // in the compiler. It's also more compact in code size to do it here. - - // MP_TOKEN_END is used to indicate that this is the first string token - lex->tok_kind = MP_TOKEN_END; - - // Loop to accumulate string/bytes literals - do { - // parse type codes - bool is_raw = false; - mp_token_kind_t kind = MP_TOKEN_STRING; - int n_char = 0; - if (is_char(lex, 'u')) { - n_char = 1; - } else if (is_char(lex, 'b')) { - kind = MP_TOKEN_BYTES; - n_char = 1; - if (is_char_following(lex, 'r')) { - is_raw = true; - n_char = 2; - } - } else if (is_char(lex, 'r')) { - is_raw = true; - n_char = 1; - if (is_char_following(lex, 'b')) { - kind = MP_TOKEN_BYTES; - n_char = 2; - } - } - - // Set or check token kind - if (lex->tok_kind == MP_TOKEN_END) { - lex->tok_kind = kind; - } else if (lex->tok_kind != kind) { - // Can't concatenate string with bytes - break; - } - - // Skip any type code characters - if (n_char != 0) { - next_char(lex); - if (n_char == 2) { - next_char(lex); - } - } - - // Parse the literal - parse_string_literal(lex, is_raw); - - // Skip whitespace so we can check if there's another string following - skip_whitespace(lex, true); - - } while (is_string_or_bytes(lex)); - - } else if (is_head_of_identifier(lex)) { - lex->tok_kind = MP_TOKEN_NAME; - - // get first char (add as byte to remain 8-bit clean and support utf-8) - vstr_add_byte(&lex->vstr, CUR_CHAR(lex)); - next_char(lex); - - // get tail chars - while (!is_end(lex) && is_tail_of_identifier(lex)) { - vstr_add_byte(&lex->vstr, CUR_CHAR(lex)); - next_char(lex); - } - - // Check if the name is a keyword. - // We also check for __debug__ here and convert it to its value. This is - // so the parser gives a syntax error on, eg, x.__debug__. Otherwise, we - // need to check for this special token in many places in the compiler. - const char *s = vstr_null_terminated_str(&lex->vstr); - for (size_t i = 0; i < MP_ARRAY_SIZE(tok_kw); i++) { - int cmp = strcmp(s, tok_kw[i]); - if (cmp == 0) { - lex->tok_kind = MP_TOKEN_KW_FALSE + i; - if (lex->tok_kind == MP_TOKEN_KW___DEBUG__) { - lex->tok_kind = (MP_STATE_VM(mp_optimise_value) == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE); - } - break; - } else if (cmp < 0) { - // Table is sorted and comparison was less-than, so stop searching - break; - } - } - - } else if (is_digit(lex) || (is_char(lex, '.') && is_following_digit(lex))) { - bool forced_integer = false; - if (is_char(lex, '.')) { - lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; - } else { - lex->tok_kind = MP_TOKEN_INTEGER; - if (is_char(lex, '0') && is_following_base_char(lex)) { - forced_integer = true; - } - } - - // get first char - vstr_add_char(&lex->vstr, CUR_CHAR(lex)); - next_char(lex); - - // get tail chars - while (!is_end(lex)) { - if (!forced_integer && is_char_or(lex, 'e', 'E')) { - lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; - vstr_add_char(&lex->vstr, 'e'); - next_char(lex); - if (is_char(lex, '+') || is_char(lex, '-')) { - vstr_add_char(&lex->vstr, CUR_CHAR(lex)); - next_char(lex); - } - } else if (is_letter(lex) || is_digit(lex) || is_char(lex, '.')) { - if (is_char_or3(lex, '.', 'j', 'J')) { - lex->tok_kind = MP_TOKEN_FLOAT_OR_IMAG; - } - vstr_add_char(&lex->vstr, CUR_CHAR(lex)); - next_char(lex); - } else { - break; - } - } - - } else { - // search for encoded delimiter or operator - - const char *t = tok_enc; - size_t tok_enc_index = 0; - for (; *t != 0 && !is_char(lex, *t); t += 1) { - if (*t == 'e' || *t == 'c') { - t += 1; - } - tok_enc_index += 1; - } - - next_char(lex); - - if (*t == 0) { - // didn't match any delimiter or operator characters - lex->tok_kind = MP_TOKEN_INVALID; - - } else if (*t == '!') { - // "!=" is a special case because "!" is not a valid operator - if (is_char(lex, '=')) { - next_char(lex); - lex->tok_kind = MP_TOKEN_OP_NOT_EQUAL; - } else { - lex->tok_kind = MP_TOKEN_INVALID; - } - - } else if (*t == '.') { - // "." and "..." are special cases because ".." is not a valid operator - if (is_char_and(lex, '.', '.')) { - next_char(lex); - next_char(lex); - lex->tok_kind = MP_TOKEN_ELLIPSIS; - } else { - lex->tok_kind = MP_TOKEN_DEL_PERIOD; - } - - } else { - // matched a delimiter or operator character - - // get the maximum characters for a valid token - t += 1; - size_t t_index = tok_enc_index; - while (*t == 'c' || *t == 'e') { - t_index += 1; - if (is_char(lex, t[1])) { - next_char(lex); - tok_enc_index = t_index; - if (*t == 'e') { - break; - } - } else if (*t == 'c') { - break; - } - t += 2; - } - - // set token kind - lex->tok_kind = tok_enc_kind[tok_enc_index]; - - // compute bracket level for implicit line joining - if (lex->tok_kind == MP_TOKEN_DEL_PAREN_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACKET_OPEN || lex->tok_kind == MP_TOKEN_DEL_BRACE_OPEN) { - lex->nested_bracket_level += 1; - } else if (lex->tok_kind == MP_TOKEN_DEL_PAREN_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACKET_CLOSE || lex->tok_kind == MP_TOKEN_DEL_BRACE_CLOSE) { - lex->nested_bracket_level -= 1; - } - } - } -} - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) { - mp_lexer_t *lex = m_new_obj(mp_lexer_t); - - lex->source_name = src_name; - lex->reader = reader; - lex->line = 1; - lex->column = (size_t)-2; // account for 3 dummy bytes - lex->emit_dent = 0; - lex->nested_bracket_level = 0; - lex->alloc_indent_level = MICROPY_ALLOC_LEXER_INDENT_INIT; - lex->num_indent_level = 1; - lex->indent_level = m_new(uint16_t, lex->alloc_indent_level); - vstr_init(&lex->vstr, 32); - - // store sentinel for first indentation level - lex->indent_level[0] = 0; - - // load lexer with start of file, advancing lex->column to 1 - // start with dummy bytes and use next_char() for proper EOL/EOF handling - lex->chr0 = lex->chr1 = lex->chr2 = 0; - next_char(lex); - next_char(lex); - next_char(lex); - - // preload first token - mp_lexer_to_next(lex); - - // Check that the first token is in the first column. If it's not then we - // convert the token kind to INDENT so that the parser gives a syntax error. - if (lex->tok_column != 1) { - lex->tok_kind = MP_TOKEN_INDENT; - } - - return lex; -} - -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len) { - mp_reader_t reader; - mp_reader_new_mem(&reader, (const byte*)str, len, free_len); - return mp_lexer_new(src_name, reader); -} - -#if MICROPY_READER_POSIX || MICROPY_READER_VFS - -mp_lexer_t *mp_lexer_new_from_file(const char *filename) { - mp_reader_t reader; - mp_reader_new_file(&reader, filename); - return mp_lexer_new(qstr_from_str(filename), reader); -} - -#if MICROPY_HELPER_LEXER_UNIX - -mp_lexer_t *mp_lexer_new_from_fd(qstr filename, int fd, bool close_fd) { - mp_reader_t reader; - mp_reader_new_file_from_fd(&reader, fd, close_fd); - return mp_lexer_new(filename, reader); -} - -#endif - -#endif - -void mp_lexer_free(mp_lexer_t *lex) { - if (lex) { - lex->reader.close(lex->reader.data); - vstr_clear(&lex->vstr); - m_del(uint16_t, lex->indent_level, lex->alloc_indent_level); - m_del_obj(mp_lexer_t, lex); - } -} - -#if 0 -// This function is used to print the current token and should only be -// needed to debug the lexer, so it's not available via a config option. -void mp_lexer_show_token(const mp_lexer_t *lex) { - printf("(" UINT_FMT ":" UINT_FMT ") kind:%u str:%p len:%zu", lex->tok_line, lex->tok_column, lex->tok_kind, lex->vstr.buf, lex->vstr.len); - if (lex->vstr.len > 0) { - const byte *i = (const byte *)lex->vstr.buf; - const byte *j = (const byte *)i + lex->vstr.len; - printf(" "); - while (i < j) { - unichar c = utf8_get_char(i); - i = utf8_next_char(i); - if (unichar_isprint(c)) { - printf("%c", (int)c); - } else { - printf("?"); - } - } - } - printf("\n"); -} -#endif - -#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/lexer.h b/user/mpy/py/lexer.h deleted file mode 100644 index a297091..0000000 --- a/user/mpy/py/lexer.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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_LEXER_H -#define MICROPY_INCLUDED_PY_LEXER_H - -#include - -#include "py/mpconfig.h" -#include "py/qstr.h" -#include "py/reader.h" - -/* lexer.h -- simple tokeniser for MicroPython - * - * Uses (byte) length instead of null termination. - * Tokens are the same - UTF-8 with (byte) length. - */ - -typedef enum _mp_token_kind_t { - MP_TOKEN_END, - - MP_TOKEN_INVALID, - MP_TOKEN_DEDENT_MISMATCH, - MP_TOKEN_LONELY_STRING_OPEN, - - MP_TOKEN_NEWLINE, - MP_TOKEN_INDENT, - MP_TOKEN_DEDENT, - - MP_TOKEN_NAME, - MP_TOKEN_INTEGER, - MP_TOKEN_FLOAT_OR_IMAG, - MP_TOKEN_STRING, - MP_TOKEN_BYTES, - - MP_TOKEN_ELLIPSIS, - - MP_TOKEN_KW_FALSE, - MP_TOKEN_KW_NONE, - MP_TOKEN_KW_TRUE, - MP_TOKEN_KW___DEBUG__, - MP_TOKEN_KW_AND, - MP_TOKEN_KW_AS, - MP_TOKEN_KW_ASSERT, - #if MICROPY_PY_ASYNC_AWAIT - MP_TOKEN_KW_ASYNC, - MP_TOKEN_KW_AWAIT, - #endif - MP_TOKEN_KW_BREAK, - MP_TOKEN_KW_CLASS, - MP_TOKEN_KW_CONTINUE, - MP_TOKEN_KW_DEF, - MP_TOKEN_KW_DEL, - MP_TOKEN_KW_ELIF, - MP_TOKEN_KW_ELSE, - MP_TOKEN_KW_EXCEPT, - MP_TOKEN_KW_FINALLY, - MP_TOKEN_KW_FOR, - MP_TOKEN_KW_FROM, - MP_TOKEN_KW_GLOBAL, - MP_TOKEN_KW_IF, - MP_TOKEN_KW_IMPORT, - MP_TOKEN_KW_IN, - MP_TOKEN_KW_IS, - MP_TOKEN_KW_LAMBDA, - MP_TOKEN_KW_NONLOCAL, - MP_TOKEN_KW_NOT, - MP_TOKEN_KW_OR, - MP_TOKEN_KW_PASS, - MP_TOKEN_KW_RAISE, - MP_TOKEN_KW_RETURN, - MP_TOKEN_KW_TRY, - MP_TOKEN_KW_WHILE, - MP_TOKEN_KW_WITH, - MP_TOKEN_KW_YIELD, - - MP_TOKEN_OP_PLUS, - MP_TOKEN_OP_MINUS, - MP_TOKEN_OP_STAR, - MP_TOKEN_OP_DBL_STAR, - MP_TOKEN_OP_SLASH, - MP_TOKEN_OP_DBL_SLASH, - MP_TOKEN_OP_PERCENT, - MP_TOKEN_OP_LESS, - MP_TOKEN_OP_DBL_LESS, - MP_TOKEN_OP_MORE, - MP_TOKEN_OP_DBL_MORE, - MP_TOKEN_OP_AMPERSAND, - MP_TOKEN_OP_PIPE, - MP_TOKEN_OP_CARET, - MP_TOKEN_OP_TILDE, - MP_TOKEN_OP_LESS_EQUAL, - MP_TOKEN_OP_MORE_EQUAL, - MP_TOKEN_OP_DBL_EQUAL, - MP_TOKEN_OP_NOT_EQUAL, - - MP_TOKEN_DEL_PAREN_OPEN, - MP_TOKEN_DEL_PAREN_CLOSE, - MP_TOKEN_DEL_BRACKET_OPEN, - MP_TOKEN_DEL_BRACKET_CLOSE, - MP_TOKEN_DEL_BRACE_OPEN, - MP_TOKEN_DEL_BRACE_CLOSE, - MP_TOKEN_DEL_COMMA, - MP_TOKEN_DEL_COLON, - MP_TOKEN_DEL_PERIOD, - MP_TOKEN_DEL_SEMICOLON, - MP_TOKEN_DEL_AT, - MP_TOKEN_DEL_EQUAL, - MP_TOKEN_DEL_PLUS_EQUAL, - MP_TOKEN_DEL_MINUS_EQUAL, - MP_TOKEN_DEL_STAR_EQUAL, - MP_TOKEN_DEL_SLASH_EQUAL, - MP_TOKEN_DEL_DBL_SLASH_EQUAL, - MP_TOKEN_DEL_PERCENT_EQUAL, - MP_TOKEN_DEL_AMPERSAND_EQUAL, - MP_TOKEN_DEL_PIPE_EQUAL, - MP_TOKEN_DEL_CARET_EQUAL, - MP_TOKEN_DEL_DBL_MORE_EQUAL, - MP_TOKEN_DEL_DBL_LESS_EQUAL, - MP_TOKEN_DEL_DBL_STAR_EQUAL, - MP_TOKEN_DEL_MINUS_MORE, -} mp_token_kind_t; - -// this data structure is exposed for efficiency -// public members are: source_name, tok_line, tok_column, tok_kind, vstr -typedef struct _mp_lexer_t { - qstr source_name; // name of source - mp_reader_t reader; // stream source - - unichar chr0, chr1, chr2; // current cached characters from source - - size_t line; // current source line - size_t column; // current source column - - mp_int_t emit_dent; // non-zero when there are INDENT/DEDENT tokens to emit - mp_int_t nested_bracket_level; // >0 when there are nested brackets over multiple lines - - size_t alloc_indent_level; - size_t num_indent_level; - uint16_t *indent_level; - - size_t tok_line; // token source line - size_t tok_column; // token source column - mp_token_kind_t tok_kind; // token kind - vstr_t vstr; // token data -} mp_lexer_t; - -mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader); -mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len); - -void mp_lexer_free(mp_lexer_t *lex); -void mp_lexer_to_next(mp_lexer_t *lex); - -/******************************************************************/ -// platform specific import function; must be implemented for a specific port -// TODO tidy up, rename, or put elsewhere - -//mp_lexer_t *mp_import_open_file(qstr mod_name); - -typedef enum { - MP_IMPORT_STAT_NO_EXIST, - MP_IMPORT_STAT_DIR, - MP_IMPORT_STAT_FILE, -} mp_import_stat_t; - -mp_import_stat_t mp_import_stat(const char *path); -mp_lexer_t *mp_lexer_new_from_file(const char *filename); - -#if MICROPY_HELPER_LEXER_UNIX -mp_lexer_t *mp_lexer_new_from_fd(qstr filename, int fd, bool close_fd); -#endif - -#endif // MICROPY_INCLUDED_PY_LEXER_H diff --git a/user/mpy/py/makeqstrdata.py b/user/mpy/py/makeqstrdata.py deleted file mode 100644 index 7249769..0000000 --- a/user/mpy/py/makeqstrdata.py +++ /dev/null @@ -1,158 +0,0 @@ -""" -Process raw qstr file and output qstr data with length, hash and data bytes. - -This script works with Python 2.6, 2.7, 3.3 and 3.4. -""" - -from __future__ import print_function - -import re -import sys - -# Python 2/3 compatibility: -# - iterating through bytes is different -# - codepoint2name lives in a different module -import platform -if platform.python_version_tuple()[0] == '2': - bytes_cons = lambda val, enc=None: bytearray(val) - from htmlentitydefs import codepoint2name -elif platform.python_version_tuple()[0] == '3': - bytes_cons = bytes - from html.entities import codepoint2name -# end compatibility code - -codepoint2name[ord('-')] = 'hyphen'; - -# add some custom names to map characters that aren't in HTML -codepoint2name[ord(' ')] = 'space' -codepoint2name[ord('\'')] = 'squot' -codepoint2name[ord(',')] = 'comma' -codepoint2name[ord('.')] = 'dot' -codepoint2name[ord(':')] = 'colon' -codepoint2name[ord(';')] = 'semicolon' -codepoint2name[ord('/')] = 'slash' -codepoint2name[ord('%')] = 'percent' -codepoint2name[ord('#')] = 'hash' -codepoint2name[ord('(')] = 'paren_open' -codepoint2name[ord(')')] = 'paren_close' -codepoint2name[ord('[')] = 'bracket_open' -codepoint2name[ord(']')] = 'bracket_close' -codepoint2name[ord('{')] = 'brace_open' -codepoint2name[ord('}')] = 'brace_close' -codepoint2name[ord('*')] = 'star' -codepoint2name[ord('!')] = 'bang' -codepoint2name[ord('\\')] = 'backslash' -codepoint2name[ord('+')] = 'plus' -codepoint2name[ord('$')] = 'dollar' -codepoint2name[ord('=')] = 'equals' -codepoint2name[ord('?')] = 'question' -codepoint2name[ord('@')] = 'at_sign' -codepoint2name[ord('^')] = 'caret' -codepoint2name[ord('|')] = 'pipe' -codepoint2name[ord('~')] = 'tilde' - -# this must match the equivalent function in qstr.c -def compute_hash(qstr, bytes_hash): - hash = 5381 - for b in qstr: - hash = (hash * 33) ^ b - # Make sure that valid hash is never zero, zero means "hash not computed" - return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1 - -def qstr_escape(qst): - def esc_char(m): - c = ord(m.group(0)) - try: - name = codepoint2name[c] - except KeyError: - name = '0x%02x' % c - return "_" + name + '_' - return re.sub(r'[^A-Za-z0-9_]', esc_char, qst) - -def parse_input_headers(infiles): - # read the qstrs in from the input files - qcfgs = {} - qstrs = {} - for infile in infiles: - with open(infile, 'rt') as f: - for line in f: - line = line.strip() - - # is this a config line? - match = re.match(r'^QCFG\((.+), (.+)\)', line) - if match: - value = match.group(2) - if value[0] == '(' and value[-1] == ')': - # strip parenthesis from config value - value = value[1:-1] - qcfgs[match.group(1)] = value - continue - - # is this a QSTR line? - match = re.match(r'^Q\((.*)\)$', line) - if not match: - continue - - # get the qstr value - qstr = match.group(1) - - # special case to specify control characters - if qstr == '\\n': - qstr = '\n' - - # work out the corresponding qstr name - ident = qstr_escape(qstr) - - # don't add duplicates - if ident in qstrs: - continue - - # add the qstr to the list, with order number to retain original order in file - qstrs[ident] = (len(qstrs), ident, qstr) - - if not qcfgs: - sys.stderr.write("ERROR: Empty preprocessor output - check for errors above\n") - sys.exit(1) - - return qcfgs, qstrs - -def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr): - qbytes = bytes_cons(qstr, 'utf8') - qlen = len(qbytes) - qhash = compute_hash(qbytes, cfg_bytes_hash) - if all(32 <= ord(c) <= 126 and c != '\\' and c != '"' for c in qstr): - # qstr is all printable ASCII so render it as-is (for easier debugging) - qdata = qstr - else: - # qstr contains non-printable codes so render entire thing as hex pairs - qdata = ''.join(('\\x%02x' % b) for b in qbytes) - if qlen >= (1 << (8 * cfg_bytes_len)): - print('qstr is too long:', qstr) - assert False - qlen_str = ('\\x%02x' * cfg_bytes_len) % tuple(((qlen >> (8 * i)) & 0xff) for i in range(cfg_bytes_len)) - qhash_str = ('\\x%02x' * cfg_bytes_hash) % tuple(((qhash >> (8 * i)) & 0xff) for i in range(cfg_bytes_hash)) - return '(const byte*)"%s%s" "%s"' % (qhash_str, qlen_str, qdata) - -def print_qstr_data(qcfgs, qstrs): - # get config variables - cfg_bytes_len = int(qcfgs['BYTES_IN_LEN']) - cfg_bytes_hash = int(qcfgs['BYTES_IN_HASH']) - - # print out the starter of the generated C header file - print('// This file was automatically generated by makeqstrdata.py') - print('') - - # add NULL qstr with no hash or data - print('QDEF(MP_QSTR_NULL, (const byte*)"%s%s" "")' % ('\\x00' * cfg_bytes_hash, '\\x00' * cfg_bytes_len)) - - # go through each qstr and print it out - for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]): - qbytes = make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr) - print('QDEF(MP_QSTR_%s, %s)' % (ident, qbytes)) - -def do_work(infiles): - qcfgs, qstrs = parse_input_headers(infiles) - print_qstr_data(qcfgs, qstrs) - -if __name__ == "__main__": - do_work(sys.argv[1:]) diff --git a/user/mpy/py/makeqstrdefs.py b/user/mpy/py/makeqstrdefs.py deleted file mode 100644 index 525dec1..0000000 --- a/user/mpy/py/makeqstrdefs.py +++ /dev/null @@ -1,111 +0,0 @@ -""" -This script processes the output from the C preprocessor and extracts all -qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'. - -This script works with Python 2.6, 2.7, 3.3 and 3.4. -""" - -from __future__ import print_function - -import re -import sys -import os - -# Blacklist of qstrings that are specially handled in further -# processing and should be ignored -QSTRING_BLACK_LIST = set(['NULL', 'number_of']) - - -def write_out(fname, output): - if output: - for m, r in [("/", "__"), ("\\", "__"), (":", "@"), ("..", "@@")]: - fname = fname.replace(m, r) - with open(args.output_dir + "/" + fname + ".qstr", "w") as f: - f.write("\n".join(output) + "\n") - -def process_file(f): - output = [] - last_fname = None - for line in f: - # match gcc-like output (# n "file") and msvc-like output (#line n "file") - if line and (line[0:2] == "# " or line[0:5] == "#line"): - m = re.match(r"#[line]*\s\d+\s\"([^\"]+)\"", line) - assert m is not None - fname = m.group(1) - if not fname.endswith(".c"): - continue - if fname != last_fname: - write_out(last_fname, output) - output = [] - last_fname = fname - continue - for match in re.findall(r'MP_QSTR_[_a-zA-Z0-9]+', line): - name = match.replace('MP_QSTR_', '') - if name not in QSTRING_BLACK_LIST: - output.append('Q(' + name + ')') - - write_out(last_fname, output) - return "" - - -def cat_together(): - import glob - import hashlib - hasher = hashlib.md5() - all_lines = [] - outf = open(args.output_dir + "/out", "wb") - for fname in glob.glob(args.output_dir + "/*.qstr"): - with open(fname, "rb") as f: - lines = f.readlines() - all_lines += lines - all_lines.sort() - all_lines = b"\n".join(all_lines) - outf.write(all_lines) - outf.close() - hasher.update(all_lines) - new_hash = hasher.hexdigest() - #print(new_hash) - old_hash = None - try: - with open(args.output_file + ".hash") as f: - old_hash = f.read() - except IOError: - pass - if old_hash != new_hash: - print("QSTR updated") - try: - # rename below might fail if file exists - os.remove(args.output_file) - except: - pass - os.rename(args.output_dir + "/out", args.output_file) - with open(args.output_file + ".hash", "w") as f: - f.write(new_hash) - else: - print("QSTR not updated") - - -if __name__ == "__main__": - if len(sys.argv) != 5: - print('usage: %s command input_filename output_dir output_file' % sys.argv[0]) - sys.exit(2) - - class Args: - pass - args = Args() - args.command = sys.argv[1] - args.input_filename = sys.argv[2] - args.output_dir = sys.argv[3] - args.output_file = sys.argv[4] - - try: - os.makedirs(args.output_dir) - except OSError: - pass - - if args.command == "split": - with open(args.input_filename) as infile: - process_file(infile) - - if args.command == "cat": - cat_together() diff --git a/user/mpy/py/makeversionhdr.py b/user/mpy/py/makeversionhdr.py deleted file mode 100644 index 749160b..0000000 --- a/user/mpy/py/makeversionhdr.py +++ /dev/null @@ -1,107 +0,0 @@ -""" -Generate header file with macros defining MicroPython version info. - -This script works with Python 2.6, 2.7, 3.3 and 3.4. -""" - -from __future__ import print_function - -import sys -import os -import datetime -import subprocess - -def get_version_info_from_git(): - # Python 2.6 doesn't have check_output, so check for that - try: - subprocess.check_output - subprocess.check_call - except AttributeError: - return None - - # Note: git describe doesn't work if no tag is available - try: - git_tag = subprocess.check_output(["git", "describe", "--dirty", "--always"], stderr=subprocess.STDOUT, universal_newlines=True).strip() - except subprocess.CalledProcessError as er: - if er.returncode == 128: - # git exit code of 128 means no repository found - return None - git_tag = "" - except OSError: - return None - try: - git_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], stderr=subprocess.STDOUT, universal_newlines=True).strip() - except subprocess.CalledProcessError: - git_hash = "unknown" - except OSError: - return None - - try: - # Check if there are any modified files. - subprocess.check_call(["git", "diff", "--no-ext-diff", "--quiet", "--exit-code"], stderr=subprocess.STDOUT) - # Check if there are any staged files. - subprocess.check_call(["git", "diff-index", "--cached", "--quiet", "HEAD", "--"], stderr=subprocess.STDOUT) - except subprocess.CalledProcessError: - git_hash += "-dirty" - except OSError: - return None - - # Try to extract MicroPython version from git tag - if git_tag.startswith("v"): - ver = git_tag[1:].split("-")[0].split(".") - if len(ver) == 2: - ver.append("0") - else: - ver = ["0", "0", "1"] - - return git_tag, git_hash, ver - -def get_version_info_from_docs_conf(): - with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "docs", "conf.py")) as f: - for line in f: - if line.startswith("version = release = '"): - ver = line.strip().split(" = ")[2].strip("'") - git_tag = "v" + ver - ver = ver.split(".") - if len(ver) == 2: - ver.append("0") - return git_tag, "", ver - return None - -def make_version_header(filename): - # Get version info using git, with fallback to docs/conf.py - info = get_version_info_from_git() - if info is None: - info = get_version_info_from_docs_conf() - - git_tag, git_hash, ver = info - - # Generate the file with the git and version info - file_data = """\ -// This file was generated by py/makeversionhdr.py -#define MICROPY_GIT_TAG "%s" -#define MICROPY_GIT_HASH "%s" -#define MICROPY_BUILD_DATE "%s" -#define MICROPY_VERSION_MAJOR (%s) -#define MICROPY_VERSION_MINOR (%s) -#define MICROPY_VERSION_MICRO (%s) -#define MICROPY_VERSION_STRING "%s.%s.%s" -""" % (git_tag, git_hash, datetime.date.today().strftime("%Y-%m-%d"), - ver[0], ver[1], ver[2], ver[0], ver[1], ver[2]) - - # Check if the file contents changed from last time - write_file = True - if os.path.isfile(filename): - with open(filename, 'r') as f: - existing_data = f.read() - if existing_data == file_data: - write_file = False - - # Only write the file if we need to - if write_file: - print("Generating %s" % filename) - with open(filename, 'w') as f: - f.write(file_data) - -if __name__ == "__main__": - make_version_header(sys.argv[1]) diff --git a/user/mpy/py/malloc.c b/user/mpy/py/malloc.c deleted file mode 100644 index af4ccf2..0000000 --- a/user/mpy/py/malloc.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/mpstate.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -#if MICROPY_MEM_STATS -#define UPDATE_PEAK() { if (MP_STATE_MEM(current_bytes_allocated) > MP_STATE_MEM(peak_bytes_allocated)) MP_STATE_MEM(peak_bytes_allocated) = MP_STATE_MEM(current_bytes_allocated); } -#endif - -#if MICROPY_ENABLE_GC -#include "py/gc.h" - -// We redirect standard alloc functions to GC heap - just for the rest of -// this module. In the rest of MicroPython source, system malloc can be -// freely accessed - for interfacing with system and 3rd-party libs for -// example. On the other hand, some (e.g. bare-metal) ports may use GC -// heap as system heap, so, to avoid warnings, we do undef's first. -#undef malloc -#undef free -#undef realloc -#define malloc(b) gc_alloc((b), false) -#define malloc_with_finaliser(b) gc_alloc((b), true) -#define free gc_free -#define realloc(ptr, n) gc_realloc(ptr, n, true) -#define realloc_ext(ptr, n, mv) gc_realloc(ptr, n, mv) -#else -STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) { - if (allow_move) { - return realloc(ptr, n_bytes); - } else { - // We are asked to resize, but without moving the memory region pointed to - // by ptr. Unless the underlying memory manager has special provision for - // this behaviour there is nothing we can do except fail to resize. - return NULL; - } -} -#endif // MICROPY_ENABLE_GC - -void *m_malloc(size_t num_bytes) { - void *ptr = malloc(num_bytes); - if (ptr == NULL && num_bytes != 0) { - return m_malloc_fail(num_bytes); - } -#if MICROPY_MEM_STATS - MP_STATE_MEM(total_bytes_allocated) += num_bytes; - MP_STATE_MEM(current_bytes_allocated) += num_bytes; - UPDATE_PEAK(); -#endif - DEBUG_printf("malloc %d : %p\n", num_bytes, ptr); - return ptr; -} - -void *m_malloc_maybe(size_t num_bytes) { - void *ptr = malloc(num_bytes); -#if MICROPY_MEM_STATS - MP_STATE_MEM(total_bytes_allocated) += num_bytes; - MP_STATE_MEM(current_bytes_allocated) += num_bytes; - UPDATE_PEAK(); -#endif - DEBUG_printf("malloc %d : %p\n", num_bytes, ptr); - return ptr; -} - -#if MICROPY_ENABLE_FINALISER -void *m_malloc_with_finaliser(size_t num_bytes) { - void *ptr = malloc_with_finaliser(num_bytes); - if (ptr == NULL && num_bytes != 0) { - return m_malloc_fail(num_bytes); - } -#if MICROPY_MEM_STATS - MP_STATE_MEM(total_bytes_allocated) += num_bytes; - MP_STATE_MEM(current_bytes_allocated) += num_bytes; - UPDATE_PEAK(); -#endif - DEBUG_printf("malloc %d : %p\n", num_bytes, ptr); - return ptr; -} -#endif - -void *m_malloc0(size_t num_bytes) { - void *ptr = m_malloc(num_bytes); - if (ptr == NULL && num_bytes != 0) { - return m_malloc_fail(num_bytes); - } - // If this config is set then the GC clears all memory, so we don't need to. - #if !MICROPY_GC_CONSERVATIVE_CLEAR - memset(ptr, 0, num_bytes); - #endif - return ptr; -} - -#if MICROPY_MALLOC_USES_ALLOCATED_SIZE -void *m_realloc(void *ptr, size_t old_num_bytes, size_t new_num_bytes) { -#else -void *m_realloc(void *ptr, size_t new_num_bytes) { -#endif - void *new_ptr = realloc(ptr, new_num_bytes); - if (new_ptr == NULL && new_num_bytes != 0) { - return m_malloc_fail(new_num_bytes); - } -#if MICROPY_MEM_STATS - // At first thought, "Total bytes allocated" should only grow, - // after all, it's *total*. But consider for example 2K block - // shrunk to 1K and then grown to 2K again. It's still 2K - // allocated total. If we process only positive increments, - // we'll count 3K. - size_t diff = new_num_bytes - old_num_bytes; - MP_STATE_MEM(total_bytes_allocated) += diff; - MP_STATE_MEM(current_bytes_allocated) += diff; - UPDATE_PEAK(); -#endif - DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr); - return new_ptr; -} - -#if MICROPY_MALLOC_USES_ALLOCATED_SIZE -void *m_realloc_maybe(void *ptr, size_t old_num_bytes, size_t new_num_bytes, bool allow_move) { -#else -void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move) { -#endif - void *new_ptr = realloc_ext(ptr, new_num_bytes, allow_move); -#if MICROPY_MEM_STATS - // At first thought, "Total bytes allocated" should only grow, - // after all, it's *total*. But consider for example 2K block - // shrunk to 1K and then grown to 2K again. It's still 2K - // allocated total. If we process only positive increments, - // we'll count 3K. - // Also, don't count failed reallocs. - if (!(new_ptr == NULL && new_num_bytes != 0)) { - size_t diff = new_num_bytes - old_num_bytes; - MP_STATE_MEM(total_bytes_allocated) += diff; - MP_STATE_MEM(current_bytes_allocated) += diff; - UPDATE_PEAK(); - } -#endif - DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr); - return new_ptr; -} - -#if MICROPY_MALLOC_USES_ALLOCATED_SIZE -void m_free(void *ptr, size_t num_bytes) { -#else -void m_free(void *ptr) { -#endif - free(ptr); -#if MICROPY_MEM_STATS - MP_STATE_MEM(current_bytes_allocated) -= num_bytes; -#endif - DEBUG_printf("free %p, %d\n", ptr, num_bytes); -} - -#if MICROPY_MEM_STATS -size_t m_get_total_bytes_allocated(void) { - return MP_STATE_MEM(total_bytes_allocated); -} - -size_t m_get_current_bytes_allocated(void) { - return MP_STATE_MEM(current_bytes_allocated); -} - -size_t m_get_peak_bytes_allocated(void) { - return MP_STATE_MEM(peak_bytes_allocated); -} -#endif diff --git a/user/mpy/py/map.c b/user/mpy/py/map.c deleted file mode 100644 index 7f3c900..0000000 --- a/user/mpy/py/map.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -// Fixed empty map. Useful when need to call kw-receiving functions -// without any keywords from C, etc. -const mp_map_t mp_const_empty_map = { - .all_keys_are_qstrs = 0, - .is_fixed = 1, - .is_ordered = 1, - .used = 0, - .alloc = 0, - .table = NULL, -}; - -// This table of sizes is used to control the growth of hash tables. -// The first set of sizes are chosen so the allocation fits exactly in a -// 4-word GC block, and it's not so important for these small values to be -// prime. The latter sizes are prime and increase at an increasing rate. -STATIC const uint16_t hash_allocation_sizes[] = { - 0, 2, 4, 6, 8, 10, 12, // +2 - 17, 23, 29, 37, 47, 59, 73, // *1.25 - 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, // *1.33 - 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, // *1.5 -}; - -STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x) { - for (size_t i = 0; i < MP_ARRAY_SIZE(hash_allocation_sizes); i++) { - if (hash_allocation_sizes[i] >= x) { - return hash_allocation_sizes[i]; - } - } - // ran out of primes in the table! - // return something sensible, at least make it odd - return (x + x / 2) | 1; -} - -/******************************************************************************/ -/* map */ - -void mp_map_init(mp_map_t *map, size_t n) { - if (n == 0) { - map->alloc = 0; - map->table = NULL; - } else { - map->alloc = n; - map->table = m_new0(mp_map_elem_t, map->alloc); - } - map->used = 0; - map->all_keys_are_qstrs = 1; - map->is_fixed = 0; - map->is_ordered = 0; -} - -void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table) { - map->alloc = n; - map->used = n; - map->all_keys_are_qstrs = 1; - map->is_fixed = 1; - map->is_ordered = 1; - map->table = (mp_map_elem_t*)table; -} - -mp_map_t *mp_map_new(size_t n) { - mp_map_t *map = m_new(mp_map_t, 1); - mp_map_init(map, n); - return map; -} - -// Differentiate from mp_map_clear() - semantics is different -void mp_map_deinit(mp_map_t *map) { - if (!map->is_fixed) { - m_del(mp_map_elem_t, map->table, map->alloc); - } - map->used = map->alloc = 0; -} - -void mp_map_free(mp_map_t *map) { - mp_map_deinit(map); - m_del_obj(mp_map_t, map); -} - -void mp_map_clear(mp_map_t *map) { - if (!map->is_fixed) { - m_del(mp_map_elem_t, map->table, map->alloc); - } - map->alloc = 0; - map->used = 0; - map->all_keys_are_qstrs = 1; - map->is_fixed = 0; - map->table = NULL; -} - -STATIC void mp_map_rehash(mp_map_t *map) { - size_t old_alloc = map->alloc; - size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1); - mp_map_elem_t *old_table = map->table; - mp_map_elem_t *new_table = m_new0(mp_map_elem_t, new_alloc); - // If we reach this point, table resizing succeeded, now we can edit the old map. - map->alloc = new_alloc; - map->used = 0; - map->all_keys_are_qstrs = 1; - map->table = new_table; - for (size_t i = 0; i < old_alloc; i++) { - if (old_table[i].key != MP_OBJ_NULL && old_table[i].key != MP_OBJ_SENTINEL) { - mp_map_lookup(map, old_table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = old_table[i].value; - } - } - m_del(mp_map_elem_t, old_table, old_alloc); -} - -// MP_MAP_LOOKUP behaviour: -// - returns NULL if not found, else the slot it was found in with key,value non-null -// MP_MAP_LOOKUP_ADD_IF_NOT_FOUND behaviour: -// - returns slot, with key non-null and value=MP_OBJ_NULL if it was added -// MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour: -// - returns NULL if not found, else the slot if was found in with key null and value non-null -mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { - - if (map->is_fixed && lookup_kind != MP_MAP_LOOKUP) { - // can't add/remove from a fixed array - return NULL; - } - - // Work out if we can compare just pointers - bool compare_only_ptrs = map->all_keys_are_qstrs; - if (compare_only_ptrs) { - if (MP_OBJ_IS_QSTR(index)) { - // Index is a qstr, so can just do ptr comparison. - } else if (MP_OBJ_IS_TYPE(index, &mp_type_str)) { - // Index is a non-interned string. - // We can either intern the string, or force a full equality comparison. - // We chose the latter, since interning costs time and potentially RAM, - // and it won't necessarily benefit subsequent calls because these calls - // most likely won't pass the newly-interned string. - compare_only_ptrs = false; - } else if (lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - // If we are not adding, then we can return straight away a failed - // lookup because we know that the index will never be found. - return NULL; - } - } - - // if the map is an ordered array then we must do a brute force linear search - if (map->is_ordered) { - for (mp_map_elem_t *elem = &map->table[0], *top = &map->table[map->used]; elem < top; elem++) { - if (elem->key == index || (!compare_only_ptrs && mp_obj_equal(elem->key, index))) { - if (MP_UNLIKELY(lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND)) { - // remove the found element by moving the rest of the array down - mp_obj_t value = elem->value; - --map->used; - memmove(elem, elem + 1, (top - elem - 1) * sizeof(*elem)); - // put the found element after the end so the caller can access it if needed - elem = &map->table[map->used]; - elem->key = MP_OBJ_NULL; - elem->value = value; - } - return elem; - } - } - if (MP_LIKELY(lookup_kind != MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)) { - return NULL; - } - if (map->used == map->alloc) { - // TODO: Alloc policy - map->alloc += 4; - map->table = m_renew(mp_map_elem_t, map->table, map->used, map->alloc); - mp_seq_clear(map->table, map->used, map->alloc, sizeof(*map->table)); - } - mp_map_elem_t *elem = map->table + map->used++; - elem->key = index; - if (!MP_OBJ_IS_QSTR(index)) { - map->all_keys_are_qstrs = 0; - } - return elem; - } - - // map is a hash table (not an ordered array), so do a hash lookup - - if (map->alloc == 0) { - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - mp_map_rehash(map); - } else { - return NULL; - } - } - - // get hash of index, with fast path for common case of qstr - mp_uint_t hash; - if (MP_OBJ_IS_QSTR(index)) { - hash = qstr_hash(MP_OBJ_QSTR_VALUE(index)); - } else { - hash = MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, index)); - } - - size_t pos = hash % map->alloc; - size_t start_pos = pos; - mp_map_elem_t *avail_slot = NULL; - for (;;) { - mp_map_elem_t *slot = &map->table[pos]; - if (slot->key == MP_OBJ_NULL) { - // found NULL slot, so index is not in table - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - map->used += 1; - if (avail_slot == NULL) { - avail_slot = slot; - } - avail_slot->key = index; - avail_slot->value = MP_OBJ_NULL; - if (!MP_OBJ_IS_QSTR(index)) { - map->all_keys_are_qstrs = 0; - } - return avail_slot; - } else { - return NULL; - } - } else if (slot->key == MP_OBJ_SENTINEL) { - // found deleted slot, remember for later - if (avail_slot == NULL) { - avail_slot = slot; - } - } else if (slot->key == index || (!compare_only_ptrs && mp_obj_equal(slot->key, index))) { - // found index - // Note: CPython does not replace the index; try x={True:'true'};x[1]='one';x - if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - // delete element in this slot - map->used--; - if (map->table[(pos + 1) % map->alloc].key == MP_OBJ_NULL) { - // optimisation if next slot is empty - slot->key = MP_OBJ_NULL; - } else { - slot->key = MP_OBJ_SENTINEL; - } - // keep slot->value so that caller can access it if needed - } - return slot; - } - - // not yet found, keep searching in this table - pos = (pos + 1) % map->alloc; - - if (pos == start_pos) { - // search got back to starting position, so index is not in table - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - if (avail_slot != NULL) { - // there was an available slot, so use that - map->used++; - avail_slot->key = index; - avail_slot->value = MP_OBJ_NULL; - if (!MP_OBJ_IS_QSTR(index)) { - map->all_keys_are_qstrs = 0; - } - return avail_slot; - } else { - // not enough room in table, rehash it - mp_map_rehash(map); - // restart the search for the new element - start_pos = pos = hash % map->alloc; - } - } else { - return NULL; - } - } - } -} - -/******************************************************************************/ -/* set */ - -#if MICROPY_PY_BUILTINS_SET - -void mp_set_init(mp_set_t *set, size_t n) { - set->alloc = n; - set->used = 0; - set->table = m_new0(mp_obj_t, set->alloc); -} - -STATIC void mp_set_rehash(mp_set_t *set) { - size_t old_alloc = set->alloc; - mp_obj_t *old_table = set->table; - set->alloc = get_hash_alloc_greater_or_equal_to(set->alloc + 1); - set->used = 0; - set->table = m_new0(mp_obj_t, set->alloc); - for (size_t i = 0; i < old_alloc; i++) { - if (old_table[i] != MP_OBJ_NULL && old_table[i] != MP_OBJ_SENTINEL) { - mp_set_lookup(set, old_table[i], MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - } - } - m_del(mp_obj_t, old_table, old_alloc); -} - -mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { - // Note: lookup_kind can be MP_MAP_LOOKUP_ADD_IF_NOT_FOUND_OR_REMOVE_IF_FOUND which - // is handled by using bitwise operations. - - if (set->alloc == 0) { - if (lookup_kind & MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - mp_set_rehash(set); - } else { - return MP_OBJ_NULL; - } - } - mp_uint_t hash = MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, index)); - size_t pos = hash % set->alloc; - size_t start_pos = pos; - mp_obj_t *avail_slot = NULL; - for (;;) { - mp_obj_t elem = set->table[pos]; - if (elem == MP_OBJ_NULL) { - // found NULL slot, so index is not in table - if (lookup_kind & MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - if (avail_slot == NULL) { - avail_slot = &set->table[pos]; - } - set->used++; - *avail_slot = index; - return index; - } else { - return MP_OBJ_NULL; - } - } else if (elem == MP_OBJ_SENTINEL) { - // found deleted slot, remember for later - if (avail_slot == NULL) { - avail_slot = &set->table[pos]; - } - } else if (mp_obj_equal(elem, index)) { - // found index - if (lookup_kind & MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - // delete element - set->used--; - if (set->table[(pos + 1) % set->alloc] == MP_OBJ_NULL) { - // optimisation if next slot is empty - set->table[pos] = MP_OBJ_NULL; - } else { - set->table[pos] = MP_OBJ_SENTINEL; - } - } - return elem; - } - - // not yet found, keep searching in this table - pos = (pos + 1) % set->alloc; - - if (pos == start_pos) { - // search got back to starting position, so index is not in table - if (lookup_kind & MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - if (avail_slot != NULL) { - // there was an available slot, so use that - set->used++; - *avail_slot = index; - return index; - } else { - // not enough room in table, rehash it - mp_set_rehash(set); - // restart the search for the new element - start_pos = pos = hash % set->alloc; - } - } else { - return MP_OBJ_NULL; - } - } - } -} - -mp_obj_t mp_set_remove_first(mp_set_t *set) { - for (size_t pos = 0; pos < set->alloc; pos++) { - if (MP_SET_SLOT_IS_FILLED(set, pos)) { - mp_obj_t elem = set->table[pos]; - // delete element - set->used--; - if (set->table[(pos + 1) % set->alloc] == MP_OBJ_NULL) { - // optimisation if next slot is empty - set->table[pos] = MP_OBJ_NULL; - } else { - set->table[pos] = MP_OBJ_SENTINEL; - } - return elem; - } - } - return MP_OBJ_NULL; -} - -void mp_set_clear(mp_set_t *set) { - m_del(mp_obj_t, set->table, set->alloc); - set->alloc = 0; - set->used = 0; - set->table = NULL; -} - -#endif // MICROPY_PY_BUILTINS_SET - -#if defined(DEBUG_PRINT) && DEBUG_PRINT -void mp_map_dump(mp_map_t *map) { - for (size_t i = 0; i < map->alloc; i++) { - if (map->table[i].key != NULL) { - mp_obj_print(map->table[i].key, PRINT_REPR); - } else { - printf("(nil)"); - } - printf(": %p\n", map->table[i].value); - } - printf("---\n"); -} -#endif diff --git a/user/mpy/py/misc.h b/user/mpy/py/misc.h deleted file mode 100644 index 71425b8..0000000 --- a/user/mpy/py/misc.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 *******************************************************/ - -#include -#include -#include - -typedef unsigned char byte; -typedef unsigned int uint; - -/** generic ops *************************************************/ - -#ifndef MIN -#define MIN(x, y) ((x) < (y) ? (x) : (y)) -#endif -#ifndef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) -#endif - -// Classical double-indirection stringification of preprocessor macro's value -#define _MP_STRINGIFY(x) #x -#define MP_STRINGIFY(x) _MP_STRINGIFY(x) - -/** 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 MICROPY_ENABLE_FINALISER -#define m_new_obj_with_finaliser(type) ((type*)(m_malloc_with_finaliser(sizeof(type)))) -#else -#define m_new_obj_with_finaliser(type) m_new_obj(type) -#endif -#if MICROPY_MALLOC_USES_ALLOCATED_SIZE -#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 -#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 -#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 MICROPY_MALLOC_USES_ALLOCATED_SIZE -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 -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 -NORETURN void *m_malloc_fail(size_t num_bytes); - -#if MICROPY_MEM_STATS -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 - -/** 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 MICROPY_PY_BUILTINS_STR_UNICODE -// with unicode enabled we need a type which can fit chars up to 0x10ffff -typedef uint32_t unichar; -#else -// 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 - -unichar utf8_get_char(const byte *s); -const byte *utf8_next_char(const byte *s); - -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_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); -mp_uint_t unichar_charlen(const char *str, mp_uint_t len); -#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 - -// Debugging helpers -int DEBUG_printf(const char *fmt, ...); - -extern mp_uint_t mp_verbose_flag; - -// This is useful for unicode handling. Some CPU archs has -// special instructions for efficient implementation of this -// function (e.g. CLZ on ARM). -// NOTE: this function is unused at the moment -#ifndef count_lead_ones -static inline mp_uint_t count_lead_ones(byte val) { - mp_uint_t c = 0; - for (byte mask = 0x80; val & mask; mask >>= 1) { - c++; - } - return c; -} -#endif - -/** float internals *************/ - -#if MICROPY_PY_BUILTINS_FLOAT -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -#define MP_FLOAT_EXP_BITS (11) -#define MP_FLOAT_FRAC_BITS (52) -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -#define MP_FLOAT_EXP_BITS (8) -#define MP_FLOAT_FRAC_BITS (23) -#endif -#define MP_FLOAT_EXP_BIAS ((1 << (MP_FLOAT_EXP_BITS - 1)) - 1) -#endif // MICROPY_PY_BUILTINS_FLOAT - -#endif // MICROPY_INCLUDED_PY_MISC_H diff --git a/user/mpy/py/mkenv.mk b/user/mpy/py/mkenv.mk deleted file mode 100644 index b167b25..0000000 --- a/user/mpy/py/mkenv.mk +++ /dev/null @@ -1,70 +0,0 @@ -ifneq ($(lastword a b),b) -$(error These Makefiles require make 3.81 or newer) -endif - -# Set TOP to be the path to get from the current directory (where make was -# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns -# the name of this makefile relative to where make was invoked. -# -# We assume that this file is in the py directory so we use $(dir ) twice -# to get to the top of the tree. - -THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) -TOP := $(patsubst %/py/mkenv.mk,%,$(THIS_MAKEFILE)) - -# Turn on increased build verbosity by defining BUILD_VERBOSE in your main -# Makefile or in your environment. You can also use V=1 on the make command -# line. - -ifeq ("$(origin V)", "command line") -BUILD_VERBOSE=$(V) -endif -ifndef BUILD_VERBOSE -BUILD_VERBOSE = 0 -endif -ifeq ($(BUILD_VERBOSE),0) -Q = @ -else -Q = -endif -# Since this is a new feature, advertise it -ifeq ($(BUILD_VERBOSE),0) -$(info Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.) -endif - -# default settings; can be overridden in main Makefile - -PY_SRC ?= $(TOP)/py -BUILD ?= build - -RM = rm -ECHO = @echo -CP = cp -MKDIR = mkdir -SED = sed -PYTHON = python - -AS = $(CROSS_COMPILE)as -CC = $(CROSS_COMPILE)gcc -CXX = $(CROSS_COMPILE)g++ -LD = $(CROSS_COMPILE)ld -OBJCOPY = $(CROSS_COMPILE)objcopy -SIZE = $(CROSS_COMPILE)size -STRIP = $(CROSS_COMPILE)strip -AR = $(CROSS_COMPILE)ar -ifeq ($(MICROPY_FORCE_32BIT),1) -CC += -m32 -CXX += -m32 -LD += -m32 -endif - -MAKE_FROZEN = $(TOP)/tools/make-frozen.py -MPY_CROSS = $(TOP)/mpy-cross/mpy-cross -MPY_TOOL = $(TOP)/tools/mpy-tool.py - -all: -.PHONY: all - -.DELETE_ON_ERROR: - -MKENV_INCLUDED = 1 diff --git a/user/mpy/py/mkrules.mk b/user/mpy/py/mkrules.mk deleted file mode 100644 index bb8a77a..0000000 --- a/user/mpy/py/mkrules.mk +++ /dev/null @@ -1,175 +0,0 @@ -ifneq ($(MKENV_INCLUDED),1) -# We assume that mkenv is in the same directory as this file. -THIS_MAKEFILE = $(lastword $(MAKEFILE_LIST)) -include $(dir $(THIS_MAKEFILE))mkenv.mk -endif - -# This file expects that OBJ contains a list of all of the object files. -# The directory portion of each object file is used to locate the source -# and should not contain any ..'s but rather be relative to the top of the -# tree. -# -# So for example, py/map.c would have an object file name py/map.o -# The object files will go into the build directory and mantain the same -# directory structure as the source tree. So the final dependency will look -# like this: -# -# build/py/map.o: py/map.c -# -# We set vpath to point to the top of the tree so that the source files -# can be located. By following this scheme, it allows a single build rule -# to be used to compile all .c files. - -vpath %.S . $(TOP) -$(BUILD)/%.o: %.S - $(ECHO) "CC $<" - $(Q)$(CC) $(CFLAGS) -c -o $@ $< - -vpath %.s . $(TOP) -$(BUILD)/%.o: %.s - $(ECHO) "AS $<" - $(Q)$(AS) -o $@ $< - -define compile_c -$(ECHO) "CC $<" -$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $< -@# The following fixes the dependency file. -@# See http://make.paulandlesley.org/autodep.html for details. -@# Regex adjusted from the above to play better with Windows paths, etc. -@$(CP) $(@:.o=.d) $(@:.o=.P); \ - $(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ - $(RM) -f $(@:.o=.d) -endef - -vpath %.c . $(TOP) -$(BUILD)/%.o: %.c - $(call compile_c) - -# List all native flags since the current build system doesn't have -# the MicroPython configuration available. However, these flags are -# needed to extract all qstrings -QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB -DN_ARM -DN_XTENSA -QSTR_GEN_EXTRA_CFLAGS += -I$(BUILD)/tmp - -vpath %.c . $(TOP) - -$(BUILD)/%.pp: %.c - $(ECHO) "PreProcess $<" - $(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $< - -# The following rule uses | to create an order only prerequisite. Order only -# prerequisites only get built if they don't exist. They don't cause timestamp -# checking to be performed. -# -# We don't know which source files actually need the generated.h (since -# it is #included from str.h). The compiler generated dependencies will cause -# the right .o's to get recompiled if the generated.h file changes. Adding -# an order-only dependency to all of the .o's will cause the generated .h -# to get built before we try to compile any of them. -$(OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h - -$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) | $(HEADER_BUILD)/mpversion.h - $(ECHO) "GEN $@" - $(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(if $?,$?,$^) >$(HEADER_BUILD)/qstr.i.last; - -$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last - $(ECHO) "GEN $@" - $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) - $(Q)touch $@ - -$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split - $(ECHO) "GEN $@" - $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) - -# $(sort $(var)) removes duplicates -# -# The net effect of this, is it causes the objects to depend on the -# object directories (but only for existence), and the object directories -# will be created if they don't exist. -OBJ_DIRS = $(sort $(dir $(OBJ))) -$(OBJ): | $(OBJ_DIRS) -$(OBJ_DIRS): - $(MKDIR) -p $@ - -$(HEADER_BUILD): - $(MKDIR) -p $@ - -ifneq ($(FROZEN_DIR),) -$(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DEPS) - $(ECHO) "Generating $@" - $(Q)$(MAKE_FROZEN) $(FROZEN_DIR) > $@ -endif - -ifneq ($(FROZEN_MPY_DIR),) -# to build the MicroPython cross compiler -$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/windows/fmode.c - $(Q)$(MAKE) -C $(TOP)/mpy-cross - -# make a list of all the .py files that need compiling and freezing -FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)/==') -FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/frozen_mpy/,$(FROZEN_MPY_PY_FILES:.py=.mpy)) - -# to build .mpy files from .py files -$(BUILD)/frozen_mpy/%.mpy: $(FROZEN_MPY_DIR)/%.py $(TOP)/mpy-cross/mpy-cross - @$(ECHO) "MPY $<" - $(Q)$(MKDIR) -p $(dir $@) - $(Q)$(MPY_CROSS) -o $@ -s $(<:$(FROZEN_MPY_DIR)/%=%) $(MPY_CROSS_FLAGS) $< - -# to build frozen_mpy.c from all .mpy files -$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h - @$(ECHO) "Creating $@" - $(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@ -endif - -ifneq ($(PROG),) -# Build a standalone executable (unix does this) - -all: $(PROG) - -$(PROG): $(OBJ) - $(ECHO) "LINK $@" -# Do not pass COPT here - it's *C* compiler optimizations. For example, -# we may want to compile using Thumb, but link with non-Thumb libc. - $(Q)$(CC) -o $@ $^ $(LIB) $(LDFLAGS) -ifndef DEBUG - $(Q)$(STRIP) $(STRIPFLAGS_EXTRA) $(PROG) -endif - $(Q)$(SIZE) $$(find $(BUILD)/build -name "frozen*.o") $(PROG) - -clean: clean-prog -clean-prog: - $(RM) -f $(PROG) - $(RM) -f $(PROG).map - -.PHONY: clean-prog -endif - -LIBMICROPYTHON = libmicropython.a - -# We can execute extra commands after library creation using -# LIBMICROPYTHON_EXTRA_CMD. This may be needed e.g. to integrate -# with 3rd-party projects which don't have proper dependency -# tracking. Then LIBMICROPYTHON_EXTRA_CMD can e.g. touch some -# other file to cause needed effect, e.g. relinking with new lib. -lib $(LIBMICROPYTHON): $(OBJ) - $(AR) rcs $(LIBMICROPYTHON) $^ - $(LIBMICROPYTHON_EXTRA_CMD) - -clean-py: - $(RM) -rf $(BUILD) $(CLEAN_EXTRA) -.PHONY: clean - -print-cfg: - $(ECHO) "PY_SRC = $(PY_SRC)" - $(ECHO) "BUILD = $(BUILD)" - $(ECHO) "OBJ = $(OBJ)" -.PHONY: print-cfg - -print-def: - @$(ECHO) "The following defines are built into the $(CC) compiler" - touch __empty__.c - @$(CC) -E -Wp,-dM __empty__.c - @$(RM) -f __empty__.c - --include $(OBJ:.o=.P) diff --git a/user/mpy/py/modarray.c b/user/mpy/py/modarray.c deleted file mode 100644 index c0cdca9..0000000 --- a/user/mpy/py/modarray.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -#include "py/builtin.h" - -#if MICROPY_PY_ARRAY - -STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_array) }, - { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_type_array) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table); - -const mp_obj_module_t mp_module_array = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_array_globals, -}; - -#endif diff --git a/user/mpy/py/modbuiltins.c b/user/mpy/py/modbuiltins.c deleted file mode 100644 index 1c76b80..0000000 --- a/user/mpy/py/modbuiltins.c +++ /dev/null @@ -1,774 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/smallint.h" -#include "py/objint.h" -#include "py/objstr.h" -#include "py/objtype.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/builtin.h" -#include "py/stream.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include -#endif - -#if MICROPY_PY_IO -extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need pointer -#endif - -// args[0] is function from class body -// args[1] is class name -// args[2:] are base objects -STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) { - assert(2 <= n_args); - - // set the new classes __locals__ object - mp_obj_dict_t *old_locals = mp_locals_get(); - mp_obj_t class_locals = mp_obj_new_dict(0); - mp_locals_set(MP_OBJ_TO_PTR(class_locals)); - - // call the class code - mp_obj_t cell = mp_call_function_0(args[0]); - - // restore old __locals__ object - mp_locals_set(old_locals); - - // get the class type (meta object) from the base objects - mp_obj_t meta; - if (n_args == 2) { - // no explicit bases, so use 'type' - meta = MP_OBJ_FROM_PTR(&mp_type_type); - } else { - // use type of first base object - meta = MP_OBJ_FROM_PTR(mp_obj_get_type(args[2])); - } - - // TODO do proper metaclass resolution for multiple base objects - - // create the new class using a call to the meta object - mp_obj_t meta_args[3]; - meta_args[0] = args[1]; // class name - meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); // tuple of bases - meta_args[2] = class_locals; // dict of members - mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args); - - // store into cell if neede - if (cell != mp_const_none) { - mp_obj_cell_set(cell, new_class); - } - - return new_class; -} -MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__); - -STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) { - #if MICROPY_PY_BUILTINS_FLOAT - if (mp_obj_is_float(o_in)) { - mp_float_t value = mp_obj_float_get(o_in); - // TODO check for NaN etc - if (value < 0) { - return mp_obj_new_float(-value); - } else { - return o_in; - } - #if MICROPY_PY_BUILTINS_COMPLEX - } else if (MP_OBJ_IS_TYPE(o_in, &mp_type_complex)) { - mp_float_t real, imag; - mp_obj_complex_get(o_in, &real, &imag); - return mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(real*real + imag*imag)); - #endif - } - #endif - - // this will raise a TypeError if the argument is not integral - return mp_obj_int_abs(o_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs); - -STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(o_in, &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - if (!mp_obj_is_true(item)) { - return mp_const_false; - } - } - return mp_const_true; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all); - -STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(o_in, &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - if (mp_obj_is_true(item)) { - return mp_const_true; - } - } - return mp_const_false; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any); - -STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) { - mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in }; - return mp_obj_str_format(MP_ARRAY_SIZE(args), args, NULL); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin); - -STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) { - if (mp_obj_is_callable(o_in)) { - return mp_const_true; - } else { - return mp_const_false; - } -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable); - -STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { - #if MICROPY_PY_BUILTINS_STR_UNICODE - mp_uint_t c = mp_obj_get_int(o_in); - char str[4]; - int len = 0; - if (c < 0x80) { - *str = c; len = 1; - } else if (c < 0x800) { - str[0] = (c >> 6) | 0xC0; - str[1] = (c & 0x3F) | 0x80; - len = 2; - } else if (c < 0x10000) { - str[0] = (c >> 12) | 0xE0; - str[1] = ((c >> 6) & 0x3F) | 0x80; - str[2] = (c & 0x3F) | 0x80; - len = 3; - } else if (c < 0x110000) { - str[0] = (c >> 18) | 0xF0; - str[1] = ((c >> 12) & 0x3F) | 0x80; - str[2] = ((c >> 6) & 0x3F) | 0x80; - str[3] = (c & 0x3F) | 0x80; - len = 4; - } else { - mp_raise_ValueError("chr() arg not in range(0x110000)"); - } - return mp_obj_new_str(str, len, true); - #else - mp_int_t ord = mp_obj_get_int(o_in); - if (0 <= ord && ord <= 0xff) { - char str[1] = {ord}; - return mp_obj_new_str(str, 1, true); - } else { - mp_raise_ValueError("chr() arg not in range(256)"); - } - #endif -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr); - -STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { - // TODO make this function more general and less of a hack - - mp_obj_dict_t *dict = NULL; - mp_map_t *members = NULL; - if (n_args == 0) { - // make a list of names in the local name space - dict = mp_locals_get(); - } else { // n_args == 1 - // make a list of names in the given object - if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) { - dict = mp_obj_module_get_globals(args[0]); - } else { - mp_obj_type_t *type; - if (MP_OBJ_IS_TYPE(args[0], &mp_type_type)) { - type = MP_OBJ_TO_PTR(args[0]); - } else { - type = mp_obj_get_type(args[0]); - } - if (type->locals_dict != NULL && type->locals_dict->base.type == &mp_type_dict) { - dict = type->locals_dict; - } - } - if (mp_obj_is_instance_type(mp_obj_get_type(args[0]))) { - mp_obj_instance_t *inst = MP_OBJ_TO_PTR(args[0]); - members = &inst->members; - } - } - - mp_obj_t dir = mp_obj_new_list(0, NULL); - if (dict != NULL) { - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - mp_obj_list_append(dir, dict->map.table[i].key); - } - } - } - if (members != NULL) { - for (size_t i = 0; i < members->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(members, i)) { - mp_obj_list_append(dir, members->table[i].key); - } - } - } - return dir; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir); - -STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) { - return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod); - -STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) { - // result is guaranteed to be a (small) int - return mp_unary_op(MP_UNARY_OP_HASH, o_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash); - -STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) { - return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex); - -#if MICROPY_PY_BUILTINS_INPUT - -#include "py/mphal.h" -#include "lib/mp-readline/readline.h" - -// A port can define mp_hal_readline if they want to use a custom function here -#ifndef mp_hal_readline -#define mp_hal_readline readline -#endif - -STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) { - if (n_args == 1) { - mp_obj_print(args[0], PRINT_STR); - } - vstr_t line; - vstr_init(&line, 16); - int ret = mp_hal_readline(&line, ""); - if (ret == CHAR_CTRL_C) { - nlr_raise(mp_obj_new_exception(&mp_type_KeyboardInterrupt)); - } - if (line.len == 0 && ret == CHAR_CTRL_D) { - nlr_raise(mp_obj_new_exception(&mp_type_EOFError)); - } - return mp_obj_new_str_from_vstr(&mp_type_str, &line); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input); - -#endif - -STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) { - return mp_getiter(o_in, NULL); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter); - -#if MICROPY_PY_BUILTINS_MIN_MAX - -STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) { - mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP); - mp_map_elem_t *default_elem; - mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value; - if (n_args == 1) { - // given an iterable - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(args[0], &iter_buf); - mp_obj_t best_key = MP_OBJ_NULL; - mp_obj_t best_obj = MP_OBJ_NULL; - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - mp_obj_t key = key_fn == MP_OBJ_NULL ? item : mp_call_function_1(key_fn, item); - if (best_obj == MP_OBJ_NULL || (mp_binary_op(op, key, best_key) == mp_const_true)) { - best_key = key; - best_obj = item; - } - } - if (best_obj == MP_OBJ_NULL) { - default_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_default), MP_MAP_LOOKUP); - if (default_elem != NULL) { - best_obj = default_elem->value; - } else { - mp_raise_ValueError("arg is an empty sequence"); - } - } - return best_obj; - } else { - // given many args - mp_obj_t best_key = MP_OBJ_NULL; - mp_obj_t best_obj = MP_OBJ_NULL; - for (size_t i = 0; i < n_args; i++) { - mp_obj_t key = key_fn == MP_OBJ_NULL ? args[i] : mp_call_function_1(key_fn, args[i]); - if (best_obj == MP_OBJ_NULL || (mp_binary_op(op, key, best_key) == mp_const_true)) { - best_key = key; - best_obj = args[i]; - } - } - return best_obj; - } -} - -STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE); -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max); - -STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS); -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min); - -#endif - -STATIC mp_obj_t mp_builtin_next(mp_obj_t o) { - mp_obj_t ret = mp_iternext_allow_raise(o); - if (ret == MP_OBJ_STOP_ITERATION) { - nlr_raise(mp_obj_new_exception(&mp_type_StopIteration)); - } else { - return ret; - } -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next); - -STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) { - return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct); - -STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) { - size_t len; - const char *str = mp_obj_str_get_data(o_in, &len); - #if MICROPY_PY_BUILTINS_STR_UNICODE - if (MP_OBJ_IS_STR(o_in)) { - len = unichar_charlen(str, len); - if (len == 1) { - if (!UTF8_IS_NONASCII(*str)) { - goto return_first_byte; - } - mp_int_t ord = *str++ & 0x7F; - for (mp_int_t mask = 0x40; ord & mask; mask >>= 1) { - ord &= ~mask; - } - while (UTF8_IS_CONT(*str)) { - ord = (ord << 6) | (*str++ & 0x3F); - } - return mp_obj_new_int(ord); - } - } else { - // a bytes object - if (len == 1) { - return_first_byte: - return MP_OBJ_NEW_SMALL_INT(((const byte*)str)[0]); - } - } - #else - if (len == 1) { - // don't sign extend when converting to ord - return mp_obj_new_int(((const byte*)str)[0]); - } - #endif - - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("ord expects a character"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "ord() expected a character, but string of length %d found", (int)len)); - } -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord); - -STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) { - switch (n_args) { - case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]); - default: -#if !MICROPY_PY_BUILTINS_POW3 - mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported"); -#elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ - return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); -#else - return mp_obj_int_pow3(args[0], args[1], args[2]); -#endif - } -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow); - -STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP); - mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP); - const char *sep_data = " "; - size_t sep_len = 1; - const char *end_data = "\n"; - size_t end_len = 1; - if (sep_elem != NULL && sep_elem->value != mp_const_none) { - sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len); - } - if (end_elem != NULL && end_elem->value != mp_const_none) { - end_data = mp_obj_str_get_data(end_elem->value, &end_len); - } - #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES - void *stream_obj = &mp_sys_stdout_obj; - mp_map_elem_t *file_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_file), MP_MAP_LOOKUP); - if (file_elem != NULL && file_elem->value != mp_const_none) { - stream_obj = MP_OBJ_TO_PTR(file_elem->value); // XXX may not be a concrete object - } - - mp_print_t print = {stream_obj, mp_stream_write_adaptor}; - #endif - for (size_t i = 0; i < n_args; i++) { - if (i > 0) { - #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES - mp_stream_write_adaptor(stream_obj, sep_data, sep_len); - #else - mp_print_strn(&mp_plat_print, sep_data, sep_len, 0, 0, 0); - #endif - } - #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES - mp_obj_print_helper(&print, args[i], PRINT_STR); - #else - mp_obj_print_helper(&mp_plat_print, args[i], PRINT_STR); - #endif - } - #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES - mp_stream_write_adaptor(stream_obj, end_data, end_len); - #else - mp_print_strn(&mp_plat_print, end_data, end_len, 0, 0, 0); - #endif - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print); - -STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { - if (o != mp_const_none) { - mp_obj_print_helper(MP_PYTHON_PRINTER, o, PRINT_REPR); - mp_print_str(MP_PYTHON_PRINTER, "\n"); - #if MICROPY_CAN_OVERRIDE_BUILTINS - // Set "_" special variable - mp_obj_t dest[2] = {MP_OBJ_SENTINEL, o}; - mp_type_module.attr(MP_OBJ_FROM_PTR(&mp_module_builtins), MP_QSTR__, dest); - #endif - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__); - -STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - mp_obj_print_helper(&print, o_in, PRINT_REPR); - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr); - -STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) { - mp_obj_t o_in = args[0]; - if (MP_OBJ_IS_INT(o_in)) { - return o_in; - } -#if MICROPY_PY_BUILTINS_FLOAT - mp_int_t num_dig = 0; - if (n_args > 1) { - num_dig = mp_obj_get_int(args[1]); - mp_float_t val = mp_obj_get_float(o_in); - mp_float_t mult = MICROPY_FLOAT_C_FUN(pow)(10, num_dig); - // TODO may lead to overflow - mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val * mult) / mult; - return mp_obj_new_float(rounded); - } - mp_float_t val = mp_obj_get_float(o_in); - mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val); - return mp_obj_new_int_from_float(rounded); -#else - mp_int_t r = mp_obj_get_int(o_in); - return mp_obj_new_int(r); -#endif -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round); - -STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) { - mp_obj_t value; - switch (n_args) { - case 1: value = MP_OBJ_NEW_SMALL_INT(0); break; - default: value = args[1]; break; - } - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(args[0], &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - value = mp_binary_op(MP_BINARY_OP_ADD, value, item); - } - return value; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum); - -STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - if (n_args > 1) { - mp_raise_TypeError("must use keyword argument for key function"); - } - mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); - mp_obj_list_sort(1, &self, kwargs); - - return self; -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted); - -// See mp_load_attr() if making any changes -static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t defval) { - mp_obj_t dest[2]; - // use load_method, raising or not raising exception - ((defval == MP_OBJ_NULL) ? mp_load_method : mp_load_method_maybe)(base, attr, dest); - if (dest[0] == MP_OBJ_NULL) { - return defval; - } else if (dest[1] == MP_OBJ_NULL) { - // load_method returned just a normal attribute - return dest[0]; - } else { - // load_method returned a method, so build a bound method object - return mp_obj_new_bound_meth(dest[0], dest[1]); - } -} - -STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) { - mp_obj_t defval = MP_OBJ_NULL; - if (n_args > 2) { - defval = args[2]; - } - return mp_load_attr_default(args[0], mp_obj_str_get_qstr(args[1]), defval); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr); - -STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) { - mp_store_attr(base, mp_obj_str_get_qstr(attr), value); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr); - -#if MICROPY_CPYTHON_COMPAT -STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) { - return mp_builtin_setattr(base, attr, MP_OBJ_NULL); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr); -#endif - -STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { - qstr attr = mp_obj_str_get_qstr(attr_in); - - mp_obj_t dest[2]; - // TODO: https://docs.python.org/3/library/functions.html?highlight=hasattr#hasattr - // explicitly says "This is implemented by calling getattr(object, name) and seeing - // whether it raises an AttributeError or not.", so we should explicitly wrap this - // in nlr_push and handle exception. - mp_load_method_maybe(object_in, attr, dest); - - return mp_obj_new_bool(dest[0] != MP_OBJ_NULL); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr); - -STATIC mp_obj_t mp_builtin_globals(void) { - return MP_OBJ_FROM_PTR(mp_globals_get()); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals); - -STATIC mp_obj_t mp_builtin_locals(void) { - return MP_OBJ_FROM_PTR(mp_locals_get()); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals); - -// These are defined in terms of MicroPython API functions right away -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id); -MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len); - -STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) }, - - // built-in core functions - { MP_ROM_QSTR(MP_QSTR___build_class__), MP_ROM_PTR(&mp_builtin___build_class___obj) }, - { MP_ROM_QSTR(MP_QSTR___import__), MP_ROM_PTR(&mp_builtin___import___obj) }, - { MP_ROM_QSTR(MP_QSTR___repl_print__), MP_ROM_PTR(&mp_builtin___repl_print___obj) }, - - // built-in types - { MP_ROM_QSTR(MP_QSTR_bool), MP_ROM_PTR(&mp_type_bool) }, - { MP_ROM_QSTR(MP_QSTR_bytes), MP_ROM_PTR(&mp_type_bytes) }, - #if MICROPY_PY_BUILTINS_BYTEARRAY - { MP_ROM_QSTR(MP_QSTR_bytearray), MP_ROM_PTR(&mp_type_bytearray) }, - #endif - #if MICROPY_PY_BUILTINS_COMPLEX - { MP_ROM_QSTR(MP_QSTR_complex), MP_ROM_PTR(&mp_type_complex) }, - #endif - { MP_ROM_QSTR(MP_QSTR_dict), MP_ROM_PTR(&mp_type_dict) }, - #if MICROPY_PY_BUILTINS_ENUMERATE - { MP_ROM_QSTR(MP_QSTR_enumerate), MP_ROM_PTR(&mp_type_enumerate) }, - #endif - #if MICROPY_PY_BUILTINS_FILTER - { MP_ROM_QSTR(MP_QSTR_filter), MP_ROM_PTR(&mp_type_filter) }, - #endif - #if MICROPY_PY_BUILTINS_FLOAT - { MP_ROM_QSTR(MP_QSTR_float), MP_ROM_PTR(&mp_type_float) }, - #endif - #if MICROPY_PY_BUILTINS_SET && MICROPY_PY_BUILTINS_FROZENSET - { MP_ROM_QSTR(MP_QSTR_frozenset), MP_ROM_PTR(&mp_type_frozenset) }, - #endif - { MP_ROM_QSTR(MP_QSTR_int), MP_ROM_PTR(&mp_type_int) }, - { MP_ROM_QSTR(MP_QSTR_list), MP_ROM_PTR(&mp_type_list) }, - { MP_ROM_QSTR(MP_QSTR_map), MP_ROM_PTR(&mp_type_map) }, - #if MICROPY_PY_BUILTINS_MEMORYVIEW - { MP_ROM_QSTR(MP_QSTR_memoryview), MP_ROM_PTR(&mp_type_memoryview) }, - #endif - { MP_ROM_QSTR(MP_QSTR_object), MP_ROM_PTR(&mp_type_object) }, - #if MICROPY_PY_BUILTINS_PROPERTY - { MP_ROM_QSTR(MP_QSTR_property), MP_ROM_PTR(&mp_type_property) }, - #endif - { MP_ROM_QSTR(MP_QSTR_range), MP_ROM_PTR(&mp_type_range) }, - #if MICROPY_PY_BUILTINS_REVERSED - { MP_ROM_QSTR(MP_QSTR_reversed), MP_ROM_PTR(&mp_type_reversed) }, - #endif - #if MICROPY_PY_BUILTINS_SET - { MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&mp_type_set) }, - #endif - #if MICROPY_PY_BUILTINS_SLICE - { MP_ROM_QSTR(MP_QSTR_slice), MP_ROM_PTR(&mp_type_slice) }, - #endif - { MP_ROM_QSTR(MP_QSTR_str), MP_ROM_PTR(&mp_type_str) }, - { MP_ROM_QSTR(MP_QSTR_super), MP_ROM_PTR(&mp_type_super) }, - { MP_ROM_QSTR(MP_QSTR_tuple), MP_ROM_PTR(&mp_type_tuple) }, - { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&mp_type_type) }, - { MP_ROM_QSTR(MP_QSTR_zip), MP_ROM_PTR(&mp_type_zip) }, - - { MP_ROM_QSTR(MP_QSTR_classmethod), MP_ROM_PTR(&mp_type_classmethod) }, - { MP_ROM_QSTR(MP_QSTR_staticmethod), MP_ROM_PTR(&mp_type_staticmethod) }, - - // built-in objects - { MP_ROM_QSTR(MP_QSTR_Ellipsis), MP_ROM_PTR(&mp_const_ellipsis_obj) }, - #if MICROPY_PY_BUILTINS_NOTIMPLEMENTED - { MP_ROM_QSTR(MP_QSTR_NotImplemented), MP_ROM_PTR(&mp_const_notimplemented_obj) }, - #endif - - // built-in user functions - { MP_ROM_QSTR(MP_QSTR_abs), MP_ROM_PTR(&mp_builtin_abs_obj) }, - { MP_ROM_QSTR(MP_QSTR_all), MP_ROM_PTR(&mp_builtin_all_obj) }, - { MP_ROM_QSTR(MP_QSTR_any), MP_ROM_PTR(&mp_builtin_any_obj) }, - { MP_ROM_QSTR(MP_QSTR_bin), MP_ROM_PTR(&mp_builtin_bin_obj) }, - { MP_ROM_QSTR(MP_QSTR_callable), MP_ROM_PTR(&mp_builtin_callable_obj) }, - #if MICROPY_PY_BUILTINS_COMPILE - { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mp_builtin_compile_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_chr), MP_ROM_PTR(&mp_builtin_chr_obj) }, - #if MICROPY_CPYTHON_COMPAT - { MP_ROM_QSTR(MP_QSTR_delattr), MP_ROM_PTR(&mp_builtin_delattr_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_dir), MP_ROM_PTR(&mp_builtin_dir_obj) }, - { MP_ROM_QSTR(MP_QSTR_divmod), MP_ROM_PTR(&mp_builtin_divmod_obj) }, - #if MICROPY_PY_BUILTINS_EVAL_EXEC - { MP_ROM_QSTR(MP_QSTR_eval), MP_ROM_PTR(&mp_builtin_eval_obj) }, - { MP_ROM_QSTR(MP_QSTR_exec), MP_ROM_PTR(&mp_builtin_exec_obj) }, - #endif - #if MICROPY_PY_BUILTINS_EXECFILE - { MP_ROM_QSTR(MP_QSTR_execfile), MP_ROM_PTR(&mp_builtin_execfile_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_getattr), MP_ROM_PTR(&mp_builtin_getattr_obj) }, - { MP_ROM_QSTR(MP_QSTR_setattr), MP_ROM_PTR(&mp_builtin_setattr_obj) }, - { MP_ROM_QSTR(MP_QSTR_globals), MP_ROM_PTR(&mp_builtin_globals_obj) }, - { MP_ROM_QSTR(MP_QSTR_hasattr), MP_ROM_PTR(&mp_builtin_hasattr_obj) }, - { MP_ROM_QSTR(MP_QSTR_hash), MP_ROM_PTR(&mp_builtin_hash_obj) }, - #if MICROPY_PY_BUILTINS_HELP - { MP_ROM_QSTR(MP_QSTR_help), MP_ROM_PTR(&mp_builtin_help_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&mp_builtin_hex_obj) }, - { MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&mp_builtin_id_obj) }, - #if MICROPY_PY_BUILTINS_INPUT - { MP_ROM_QSTR(MP_QSTR_input), MP_ROM_PTR(&mp_builtin_input_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_isinstance), MP_ROM_PTR(&mp_builtin_isinstance_obj) }, - { MP_ROM_QSTR(MP_QSTR_issubclass), MP_ROM_PTR(&mp_builtin_issubclass_obj) }, - { MP_ROM_QSTR(MP_QSTR_iter), MP_ROM_PTR(&mp_builtin_iter_obj) }, - { MP_ROM_QSTR(MP_QSTR_len), MP_ROM_PTR(&mp_builtin_len_obj) }, - { MP_ROM_QSTR(MP_QSTR_locals), MP_ROM_PTR(&mp_builtin_locals_obj) }, - #if MICROPY_PY_BUILTINS_MIN_MAX - { MP_ROM_QSTR(MP_QSTR_max), MP_ROM_PTR(&mp_builtin_max_obj) }, - { MP_ROM_QSTR(MP_QSTR_min), MP_ROM_PTR(&mp_builtin_min_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_next), MP_ROM_PTR(&mp_builtin_next_obj) }, - { MP_ROM_QSTR(MP_QSTR_oct), MP_ROM_PTR(&mp_builtin_oct_obj) }, - { MP_ROM_QSTR(MP_QSTR_ord), MP_ROM_PTR(&mp_builtin_ord_obj) }, - { MP_ROM_QSTR(MP_QSTR_pow), MP_ROM_PTR(&mp_builtin_pow_obj) }, - { MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&mp_builtin_print_obj) }, - { MP_ROM_QSTR(MP_QSTR_repr), MP_ROM_PTR(&mp_builtin_repr_obj) }, - { MP_ROM_QSTR(MP_QSTR_round), MP_ROM_PTR(&mp_builtin_round_obj) }, - { MP_ROM_QSTR(MP_QSTR_sorted), MP_ROM_PTR(&mp_builtin_sorted_obj) }, - { MP_ROM_QSTR(MP_QSTR_sum), MP_ROM_PTR(&mp_builtin_sum_obj) }, - - // built-in exceptions - { MP_ROM_QSTR(MP_QSTR_BaseException), MP_ROM_PTR(&mp_type_BaseException) }, - { MP_ROM_QSTR(MP_QSTR_ArithmeticError), MP_ROM_PTR(&mp_type_ArithmeticError) }, - { MP_ROM_QSTR(MP_QSTR_AssertionError), MP_ROM_PTR(&mp_type_AssertionError) }, - { MP_ROM_QSTR(MP_QSTR_AttributeError), MP_ROM_PTR(&mp_type_AttributeError) }, - { MP_ROM_QSTR(MP_QSTR_EOFError), MP_ROM_PTR(&mp_type_EOFError) }, - { MP_ROM_QSTR(MP_QSTR_Exception), MP_ROM_PTR(&mp_type_Exception) }, - { MP_ROM_QSTR(MP_QSTR_GeneratorExit), MP_ROM_PTR(&mp_type_GeneratorExit) }, - { MP_ROM_QSTR(MP_QSTR_ImportError), MP_ROM_PTR(&mp_type_ImportError) }, - { MP_ROM_QSTR(MP_QSTR_IndentationError), MP_ROM_PTR(&mp_type_IndentationError) }, - { MP_ROM_QSTR(MP_QSTR_IndexError), MP_ROM_PTR(&mp_type_IndexError) }, - { MP_ROM_QSTR(MP_QSTR_KeyboardInterrupt), MP_ROM_PTR(&mp_type_KeyboardInterrupt) }, - { MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) }, - { MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) }, - { MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) }, - { MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) }, - { MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) }, - { MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) }, - { MP_ROM_QSTR(MP_QSTR_OverflowError), MP_ROM_PTR(&mp_type_OverflowError) }, - { MP_ROM_QSTR(MP_QSTR_RuntimeError), MP_ROM_PTR(&mp_type_RuntimeError) }, - #if MICROPY_PY_ASYNC_AWAIT - { MP_ROM_QSTR(MP_QSTR_StopAsyncIteration), MP_ROM_PTR(&mp_type_StopAsyncIteration) }, - #endif - { MP_ROM_QSTR(MP_QSTR_StopIteration), MP_ROM_PTR(&mp_type_StopIteration) }, - { MP_ROM_QSTR(MP_QSTR_SyntaxError), MP_ROM_PTR(&mp_type_SyntaxError) }, - { MP_ROM_QSTR(MP_QSTR_SystemExit), MP_ROM_PTR(&mp_type_SystemExit) }, - { MP_ROM_QSTR(MP_QSTR_TypeError), MP_ROM_PTR(&mp_type_TypeError) }, - #if MICROPY_PY_BUILTINS_STR_UNICODE - { MP_ROM_QSTR(MP_QSTR_UnicodeError), MP_ROM_PTR(&mp_type_UnicodeError) }, - #endif - { MP_ROM_QSTR(MP_QSTR_ValueError), MP_ROM_PTR(&mp_type_ValueError) }, - #if MICROPY_EMIT_NATIVE - { MP_ROM_QSTR(MP_QSTR_ViperTypeError), MP_ROM_PTR(&mp_type_ViperTypeError) }, - #endif - { MP_ROM_QSTR(MP_QSTR_ZeroDivisionError), MP_ROM_PTR(&mp_type_ZeroDivisionError) }, - // Somehow CPython managed to have OverflowError not inherit from ValueError ;-/ - // TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation - - // Extra builtins as defined by a port - MICROPY_PORT_BUILTINS -}; - -MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_table); - -const mp_obj_module_t mp_module_builtins = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_builtins_globals, -}; diff --git a/user/mpy/py/modcmath.c b/user/mpy/py/modcmath.c deleted file mode 100644 index 627a2cb..0000000 --- a/user/mpy/py/modcmath.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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. - */ - -#include "py/builtin.h" - -#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH - -#include - -/// \module cmath - mathematical functions for complex numbers -/// -/// The `cmath` module provides some basic mathematical funtions for -/// working with complex numbers. - -/// \function phase(z) -/// Returns the phase of the number `z`, in the range (-pi, +pi]. -STATIC mp_obj_t mp_cmath_phase(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - return mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase); - -/// \function polar(z) -/// Returns, as a tuple, the polar form of `z`. -STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - mp_obj_t tuple[2] = { - mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(real*real + imag*imag)), - mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real)), - }; - return mp_obj_new_tuple(2, tuple); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar); - -/// \function rect(r, phi) -/// Returns the complex number with modulus `r` and phase `phi`. -STATIC mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) { - mp_float_t r = mp_obj_get_float(r_obj); - mp_float_t phi = mp_obj_get_float(phi_obj); - return mp_obj_new_complex(r * MICROPY_FLOAT_C_FUN(cos)(phi), r * MICROPY_FLOAT_C_FUN(sin)(phi)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect); - -/// \function exp(z) -/// Return the exponential of `z`. -STATIC mp_obj_t mp_cmath_exp(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - mp_float_t exp_real = MICROPY_FLOAT_C_FUN(exp)(real); - return mp_obj_new_complex(exp_real * MICROPY_FLOAT_C_FUN(cos)(imag), exp_real * MICROPY_FLOAT_C_FUN(sin)(imag)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp); - -/// \function log(z) -/// Return the natural logarithm of `z`. The branch cut is along the negative real axis. -// TODO can take second argument, being the base -STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log)(real*real + imag*imag), MICROPY_FLOAT_C_FUN(atan2)(imag, real)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log); - -#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS -/// \function log10(z) -/// Return the base-10 logarithm of `z`. The branch cut is along the negative real axis. -STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log10)(real*real + imag*imag), 0.4342944819032518 * MICROPY_FLOAT_C_FUN(atan2)(imag, real)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10); -#endif - -/// \function sqrt(z) -/// Return the square-root of `z`. -STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real*real + imag*imag, 0.25); - mp_float_t theta = 0.5 * MICROPY_FLOAT_C_FUN(atan2)(imag, real); - return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt); - -/// \function cos(z) -/// Return the cosine of `z`. -STATIC mp_obj_t mp_cmath_cos(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), -MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos); - -/// \function sin(z) -/// Return the sine of `z`. -STATIC mp_obj_t mp_cmath_sin(mp_obj_t z_obj) { - mp_float_t real, imag; - mp_obj_get_complex(z_obj, &real, &imag); - return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin); - -STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cmath) }, - { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e }, - { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi }, - { MP_ROM_QSTR(MP_QSTR_phase), MP_ROM_PTR(&mp_cmath_phase_obj) }, - { MP_ROM_QSTR(MP_QSTR_polar), MP_ROM_PTR(&mp_cmath_polar_obj) }, - { MP_ROM_QSTR(MP_QSTR_rect), MP_ROM_PTR(&mp_cmath_rect_obj) }, - { MP_ROM_QSTR(MP_QSTR_exp), MP_ROM_PTR(&mp_cmath_exp_obj) }, - { MP_ROM_QSTR(MP_QSTR_log), MP_ROM_PTR(&mp_cmath_log_obj) }, - #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS - { MP_ROM_QSTR(MP_QSTR_log10), MP_ROM_PTR(&mp_cmath_log10_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_sqrt), MP_ROM_PTR(&mp_cmath_sqrt_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_acos), MP_ROM_PTR(&mp_cmath_acos_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_asin), MP_ROM_PTR(&mp_cmath_asin_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_atan), MP_ROM_PTR(&mp_cmath_atan_obj) }, - { MP_ROM_QSTR(MP_QSTR_cos), MP_ROM_PTR(&mp_cmath_cos_obj) }, - { MP_ROM_QSTR(MP_QSTR_sin), MP_ROM_PTR(&mp_cmath_sin_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_tan), MP_ROM_PTR(&mp_cmath_tan_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_acosh), MP_ROM_PTR(&mp_cmath_acosh_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_asinh), MP_ROM_PTR(&mp_cmath_asinh_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_atanh), MP_ROM_PTR(&mp_cmath_atanh_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_cosh), MP_ROM_PTR(&mp_cmath_cosh_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_sinh), MP_ROM_PTR(&mp_cmath_sinh_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_tanh), MP_ROM_PTR(&mp_cmath_tanh_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_isfinite), MP_ROM_PTR(&mp_cmath_isfinite_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_isinf), MP_ROM_PTR(&mp_cmath_isinf_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_cmath_isnan_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table); - -const mp_obj_module_t mp_module_cmath = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_cmath_globals, -}; - -#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH diff --git a/user/mpy/py/modcollections.c b/user/mpy/py/modcollections.c deleted file mode 100644 index 1a15603..0000000 --- a/user/mpy/py/modcollections.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -#include "py/builtin.h" - -#if MICROPY_PY_COLLECTIONS - -STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucollections) }, - { MP_ROM_QSTR(MP_QSTR_namedtuple), MP_ROM_PTR(&mp_namedtuple_obj) }, - #if MICROPY_PY_COLLECTIONS_ORDEREDDICT - { MP_ROM_QSTR(MP_QSTR_OrderedDict), MP_ROM_PTR(&mp_type_ordereddict) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table); - -const mp_obj_module_t mp_module_collections = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_collections_globals, -}; - -#endif // MICROPY_PY_COLLECTIONS diff --git a/user/mpy/py/modgc.c b/user/mpy/py/modgc.c deleted file mode 100644 index d45e007..0000000 --- a/user/mpy/py/modgc.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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. - */ - -#include "py/mpstate.h" -#include "py/obj.h" -#include "py/gc.h" - -#if MICROPY_PY_GC && MICROPY_ENABLE_GC - -/// \module gc - control the garbage collector - -/// \function collect() -/// Run a garbage collection. -STATIC mp_obj_t py_gc_collect(void) { - gc_collect(); -#if MICROPY_PY_GC_COLLECT_RETVAL - return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected)); -#else - return mp_const_none; -#endif -} -MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect); - -/// \function disable() -/// Disable the garbage collector. -STATIC mp_obj_t gc_disable(void) { - MP_STATE_MEM(gc_auto_collect_enabled) = 0; - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable); - -/// \function enable() -/// Enable the garbage collector. -STATIC mp_obj_t gc_enable(void) { - MP_STATE_MEM(gc_auto_collect_enabled) = 1; - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable); - -STATIC mp_obj_t gc_isenabled(void) { - return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled)); -} -MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled); - -/// \function mem_free() -/// Return the number of bytes of available heap RAM. -STATIC mp_obj_t gc_mem_free(void) { - gc_info_t info; - gc_info(&info); - return MP_OBJ_NEW_SMALL_INT(info.free); -} -MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free); - -/// \function mem_alloc() -/// Return the number of bytes of heap RAM that are allocated. -STATIC mp_obj_t gc_mem_alloc(void) { - gc_info_t info; - gc_info(&info); - return MP_OBJ_NEW_SMALL_INT(info.used); -} -MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_alloc_obj, gc_mem_alloc); - -#if MICROPY_GC_ALLOC_THRESHOLD -STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) { - if (n_args == 0) { - if (MP_STATE_MEM(gc_alloc_threshold) == (size_t)-1) { - return MP_OBJ_NEW_SMALL_INT(-1); - } - return mp_obj_new_int(MP_STATE_MEM(gc_alloc_threshold) * MICROPY_BYTES_PER_GC_BLOCK); - } - mp_int_t val = mp_obj_get_int(args[0]); - if (val < 0) { - MP_STATE_MEM(gc_alloc_threshold) = (size_t)-1; - } else { - MP_STATE_MEM(gc_alloc_threshold) = val / MICROPY_BYTES_PER_GC_BLOCK; - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gc_threshold_obj, 0, 1, gc_threshold); -#endif - -STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gc) }, - { MP_ROM_QSTR(MP_QSTR_collect), MP_ROM_PTR(&gc_collect_obj) }, - { MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&gc_disable_obj) }, - { MP_ROM_QSTR(MP_QSTR_enable), MP_ROM_PTR(&gc_enable_obj) }, - { MP_ROM_QSTR(MP_QSTR_isenabled), MP_ROM_PTR(&gc_isenabled_obj) }, - { MP_ROM_QSTR(MP_QSTR_mem_free), MP_ROM_PTR(&gc_mem_free_obj) }, - { MP_ROM_QSTR(MP_QSTR_mem_alloc), MP_ROM_PTR(&gc_mem_alloc_obj) }, - #if MICROPY_GC_ALLOC_THRESHOLD - { MP_ROM_QSTR(MP_QSTR_threshold), MP_ROM_PTR(&gc_threshold_obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table); - -const mp_obj_module_t mp_module_gc = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_gc_globals, -}; - -#endif diff --git a/user/mpy/py/modio.c b/user/mpy/py/modio.c deleted file mode 100644 index 353a002..0000000 --- a/user/mpy/py/modio.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime.h" -#include "py/builtin.h" -#include "py/stream.h" -#include "py/objstringio.h" -#include "py/frozenmod.h" - -#if MICROPY_PY_IO - -extern const mp_obj_type_t mp_type_fileio; -extern const mp_obj_type_t mp_type_textio; - -#if MICROPY_PY_IO_BUFFEREDWRITER -typedef struct _mp_obj_bufwriter_t { - mp_obj_base_t base; - mp_obj_t stream; - size_t alloc; - size_t len; - byte buf[0]; -} mp_obj_bufwriter_t; - -STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, 2, false); - size_t alloc = mp_obj_get_int(args[1]); - mp_obj_bufwriter_t *o = m_new_obj_var(mp_obj_bufwriter_t, byte, alloc); - o->base.type = type; - o->stream = args[0]; - o->alloc = alloc; - o->len = 0; - return o; -} - -STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { - mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in); - - mp_uint_t org_size = size; - - while (size > 0) { - mp_uint_t rem = self->alloc - self->len; - if (size < rem) { - memcpy(self->buf + self->len, buf, size); - self->len += size; - return org_size; - } - - // Buffer flushing policy here is to flush entire buffer all the time. - // This allows e.g. to have a block device as backing storage and write - // entire block to it. memcpy below is not ideal and could be optimized - // in some cases. But the way it is now it at least ensures that buffer - // is word-aligned, to guard against obscure cases when it matters, e.g. - // https://github.com/micropython/micropython/issues/1863 - memcpy(self->buf + self->len, buf, rem); - buf = (byte*)buf + rem; - size -= rem; - mp_uint_t out_sz = mp_stream_write_exactly(self->stream, self->buf, self->alloc, errcode); - if (*errcode != 0) { - return MP_STREAM_ERROR; - } - // TODO: try to recover from a case of non-blocking stream, e.g. move - // remaining chunk to the beginning of buffer. - assert(out_sz == self->alloc); - self->len = 0; - } - - return org_size; -} - -STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) { - mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in); - - if (self->len != 0) { - int err; - mp_uint_t out_sz = mp_stream_write_exactly(self->stream, self->buf, self->len, &err); - // TODO: try to recover from a case of non-blocking stream, e.g. move - // remaining chunk to the beginning of buffer. - assert(out_sz == self->len); - self->len = 0; - if (err != 0) { - mp_raise_OSError(err); - } - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush); - -STATIC const mp_rom_map_elem_t bufwriter_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&bufwriter_flush_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table); - -STATIC const mp_stream_p_t bufwriter_stream_p = { - .write = bufwriter_write, -}; - -STATIC const mp_obj_type_t bufwriter_type = { - { &mp_type_type }, - .name = MP_QSTR_BufferedWriter, - .make_new = bufwriter_make_new, - .protocol = &bufwriter_stream_p, - .locals_dict = (mp_obj_dict_t*)&bufwriter_locals_dict, -}; -#endif // MICROPY_PY_IO_BUFFEREDWRITER - -#if MICROPY_MODULE_FROZEN_STR -STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) { - VSTR_FIXED(path_buf, MICROPY_ALLOC_PATH_MAX); - size_t len; - - // As an extension to pkg_resources.resource_stream(), we support - // package parameter being None, the path_in is interpreted as a - // raw path. - if (package_in != mp_const_none) { - mp_obj_t args[5]; - args[0] = package_in; - args[1] = mp_const_none; // TODO should be globals - args[2] = mp_const_none; // TODO should be locals - args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module - args[4] = MP_OBJ_NEW_SMALL_INT(0); - - // TODO lookup __import__ and call that instead of going straight to builtin implementation - mp_obj_t pkg = mp_builtin___import__(5, args); - - mp_obj_t dest[2]; - mp_load_method_maybe(pkg, MP_QSTR___path__, dest); - if (dest[0] == MP_OBJ_NULL) { - mp_raise_TypeError(NULL); - } - - const char *path = mp_obj_str_get_data(dest[0], &len); - vstr_add_strn(&path_buf, path, len); - vstr_add_byte(&path_buf, '/'); - } - - const char *path = mp_obj_str_get_data(path_in, &len); - vstr_add_strn(&path_buf, path, len); - - len = path_buf.len; - const char *data = mp_find_frozen_str(path_buf.buf, &len); - if (data != NULL) { - mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); - o->base.type = &mp_type_bytesio; - o->vstr = m_new_obj(vstr_t); - vstr_init_fixed_buf(o->vstr, len + 1, (char*)data); - o->vstr->len = len; - o->pos = 0; - return MP_OBJ_FROM_PTR(o); - } - - mp_obj_t path_out = mp_obj_new_str(path_buf.buf, path_buf.len, false); - return mp_builtin_open(1, &path_out, (mp_map_t*)&mp_const_empty_map); -} -MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream); -#endif - -STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uio) }, - // Note: mp_builtin_open_obj should be defined by port, it's not - // part of the core. - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, - #if MICROPY_PY_IO_RESOURCE_STREAM - { MP_ROM_QSTR(MP_QSTR_resource_stream), MP_ROM_PTR(&resource_stream_obj) }, - #endif - #if MICROPY_PY_IO_FILEIO - { MP_ROM_QSTR(MP_QSTR_FileIO), MP_ROM_PTR(&mp_type_fileio) }, - #if MICROPY_CPYTHON_COMPAT - { MP_ROM_QSTR(MP_QSTR_TextIOWrapper), MP_ROM_PTR(&mp_type_textio) }, - #endif - #endif - { MP_ROM_QSTR(MP_QSTR_StringIO), MP_ROM_PTR(&mp_type_stringio) }, - #if MICROPY_PY_IO_BYTESIO - { MP_ROM_QSTR(MP_QSTR_BytesIO), MP_ROM_PTR(&mp_type_bytesio) }, - #endif - #if MICROPY_PY_IO_BUFFEREDWRITER - { MP_ROM_QSTR(MP_QSTR_BufferedWriter), MP_ROM_PTR(&bufwriter_type) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table); - -const mp_obj_module_t mp_module_io = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_io_globals, -}; - -#endif diff --git a/user/mpy/py/modmath.c b/user/mpy/py/modmath.c deleted file mode 100644 index c56056a..0000000 --- a/user/mpy/py/modmath.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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. - */ - -#include "py/builtin.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH - -#include - -// M_PI is not part of the math.h standard and may not be defined -// And by defining our own we can ensure it uses the correct const format. -#define MP_PI MICROPY_FLOAT_CONST(3.14159265358979323846) - -/// \module math - mathematical functions -/// -/// The `math` module provides some basic mathematical funtions for -/// working with floating-point numbers. - -STATIC NORETURN void math_error(void) { - mp_raise_ValueError("math domain error"); -} - -#define MATH_FUN_1(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); - -#define MATH_FUN_2(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_float(y_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name); - -#define MATH_FUN_1_TO_BOOL(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); - -#define MATH_FUN_1_TO_INT(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); - -#define MATH_FUN_1_ERRCOND(py_name, c_name, error_condition) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { \ - mp_float_t x = mp_obj_get_float(x_obj); \ - if (error_condition) { \ - math_error(); \ - } \ - return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(x)); \ - } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); - -#if MP_NEED_LOG2 -// 1.442695040888963407354163704 is 1/_M_LN2 -#define log2(x) (log(x) * 1.442695040888963407354163704) -#endif - -/// \function sqrt(x) -/// Returns the square root of `x`. -MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) -/// \function pow(x, y) -/// Returns `x` to the power of `y`. -MATH_FUN_2(pow, pow) -/// \function exp(x) -MATH_FUN_1(exp, exp) -#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS -/// \function expm1(x) -MATH_FUN_1(expm1, expm1) -/// \function log2(x) -MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0)) -/// \function log10(x) -MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0)) -/// \function cosh(x) -MATH_FUN_1(cosh, cosh) -/// \function sinh(x) -MATH_FUN_1(sinh, sinh) -/// \function tanh(x) -MATH_FUN_1(tanh, tanh) -/// \function acosh(x) -MATH_FUN_1(acosh, acosh) -/// \function asinh(x) -MATH_FUN_1(asinh, asinh) -/// \function atanh(x) -MATH_FUN_1(atanh, atanh) -#endif -/// \function cos(x) -MATH_FUN_1(cos, cos) -/// \function sin(x) -MATH_FUN_1(sin, sin) -/// \function tan(x) -MATH_FUN_1(tan, tan) -/// \function acos(x) -MATH_FUN_1(acos, acos) -/// \function asin(x) -MATH_FUN_1(asin, asin) -/// \function atan(x) -MATH_FUN_1(atan, atan) -/// \function atan2(y, x) -MATH_FUN_2(atan2, atan2) -/// \function ceil(x) -MATH_FUN_1_TO_INT(ceil, ceil) -/// \function copysign(x, y) -MATH_FUN_2(copysign, copysign) -/// \function fabs(x) -MATH_FUN_1(fabs, fabs) -/// \function floor(x) -MATH_FUN_1_TO_INT(floor, floor) //TODO: delegate to x.__floor__() if x is not a float -/// \function fmod(x, y) -MATH_FUN_2(fmod, fmod) -/// \function isfinite(x) -MATH_FUN_1_TO_BOOL(isfinite, isfinite) -/// \function isinf(x) -MATH_FUN_1_TO_BOOL(isinf, isinf) -/// \function isnan(x) -MATH_FUN_1_TO_BOOL(isnan, isnan) -/// \function trunc(x) -MATH_FUN_1_TO_INT(trunc, trunc) -/// \function ldexp(x, exp) -MATH_FUN_2(ldexp, ldexp) -#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS -/// \function erf(x) -/// Return the error function of `x`. -MATH_FUN_1(erf, erf) -/// \function erfc(x) -/// Return the complementary error function of `x`. -MATH_FUN_1(erfc, erfc) -/// \function gamma(x) -/// Return the gamma function of `x`. -MATH_FUN_1(gamma, tgamma) -/// \function lgamma(x) -/// return the natural logarithm of the gamma function of `x`. -MATH_FUN_1(lgamma, lgamma) -#endif -//TODO: factorial, fsum - -// Function that takes a variable number of arguments - -// log(x[, base]) -STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) { - mp_float_t x = mp_obj_get_float(args[0]); - if (x <= (mp_float_t)0.0) { - math_error(); - } - mp_float_t l = MICROPY_FLOAT_C_FUN(log)(x); - if (n_args == 1) { - return mp_obj_new_float(l); - } else { - mp_float_t base = mp_obj_get_float(args[1]); - if (base <= (mp_float_t)0.0) { - math_error(); - } else if (base == (mp_float_t)1.0) { - mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); - } - return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); - } -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log); - -// Functions that return a tuple - -/// \function frexp(x) -/// Converts a floating-point number to fractional and integral components. -STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) { - int int_exponent = 0; - mp_float_t significand = MICROPY_FLOAT_C_FUN(frexp)(mp_obj_get_float(x_obj), &int_exponent); - mp_obj_t tuple[2]; - tuple[0] = mp_obj_new_float(significand); - tuple[1] = mp_obj_new_int(int_exponent); - return mp_obj_new_tuple(2, tuple); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp); - -/// \function modf(x) -STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) { - mp_float_t int_part = 0.0; - mp_float_t fractional_part = MICROPY_FLOAT_C_FUN(modf)(mp_obj_get_float(x_obj), &int_part); - mp_obj_t tuple[2]; - tuple[0] = mp_obj_new_float(fractional_part); - tuple[1] = mp_obj_new_float(int_part); - return mp_obj_new_tuple(2, tuple); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf); - -// Angular conversions - -/// \function radians(x) -STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) { - return mp_obj_new_float(mp_obj_get_float(x_obj) * (MP_PI / MICROPY_FLOAT_CONST(180.0))); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians); - -/// \function degrees(x) -STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) { - return mp_obj_new_float(mp_obj_get_float(x_obj) * (MICROPY_FLOAT_CONST(180.0) / MP_PI)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees); - -STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_math) }, - { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e }, - { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi }, - { MP_ROM_QSTR(MP_QSTR_sqrt), MP_ROM_PTR(&mp_math_sqrt_obj) }, - { MP_ROM_QSTR(MP_QSTR_pow), MP_ROM_PTR(&mp_math_pow_obj) }, - { MP_ROM_QSTR(MP_QSTR_exp), MP_ROM_PTR(&mp_math_exp_obj) }, - #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS - { MP_ROM_QSTR(MP_QSTR_expm1), MP_ROM_PTR(&mp_math_expm1_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_log), MP_ROM_PTR(&mp_math_log_obj) }, - #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS - { MP_ROM_QSTR(MP_QSTR_log2), MP_ROM_PTR(&mp_math_log2_obj) }, - { MP_ROM_QSTR(MP_QSTR_log10), MP_ROM_PTR(&mp_math_log10_obj) }, - { MP_ROM_QSTR(MP_QSTR_cosh), MP_ROM_PTR(&mp_math_cosh_obj) }, - { MP_ROM_QSTR(MP_QSTR_sinh), MP_ROM_PTR(&mp_math_sinh_obj) }, - { MP_ROM_QSTR(MP_QSTR_tanh), MP_ROM_PTR(&mp_math_tanh_obj) }, - { MP_ROM_QSTR(MP_QSTR_acosh), MP_ROM_PTR(&mp_math_acosh_obj) }, - { MP_ROM_QSTR(MP_QSTR_asinh), MP_ROM_PTR(&mp_math_asinh_obj) }, - { MP_ROM_QSTR(MP_QSTR_atanh), MP_ROM_PTR(&mp_math_atanh_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_cos), MP_ROM_PTR(&mp_math_cos_obj) }, - { MP_ROM_QSTR(MP_QSTR_sin), MP_ROM_PTR(&mp_math_sin_obj) }, - { MP_ROM_QSTR(MP_QSTR_tan), MP_ROM_PTR(&mp_math_tan_obj) }, - { MP_ROM_QSTR(MP_QSTR_acos), MP_ROM_PTR(&mp_math_acos_obj) }, - { MP_ROM_QSTR(MP_QSTR_asin), MP_ROM_PTR(&mp_math_asin_obj) }, - { MP_ROM_QSTR(MP_QSTR_atan), MP_ROM_PTR(&mp_math_atan_obj) }, - { MP_ROM_QSTR(MP_QSTR_atan2), MP_ROM_PTR(&mp_math_atan2_obj) }, - { MP_ROM_QSTR(MP_QSTR_ceil), MP_ROM_PTR(&mp_math_ceil_obj) }, - { MP_ROM_QSTR(MP_QSTR_copysign), MP_ROM_PTR(&mp_math_copysign_obj) }, - { MP_ROM_QSTR(MP_QSTR_fabs), MP_ROM_PTR(&mp_math_fabs_obj) }, - { MP_ROM_QSTR(MP_QSTR_floor), MP_ROM_PTR(&mp_math_floor_obj) }, - { MP_ROM_QSTR(MP_QSTR_fmod), MP_ROM_PTR(&mp_math_fmod_obj) }, - { MP_ROM_QSTR(MP_QSTR_frexp), MP_ROM_PTR(&mp_math_frexp_obj) }, - { MP_ROM_QSTR(MP_QSTR_ldexp), MP_ROM_PTR(&mp_math_ldexp_obj) }, - { MP_ROM_QSTR(MP_QSTR_modf), MP_ROM_PTR(&mp_math_modf_obj) }, - { MP_ROM_QSTR(MP_QSTR_isfinite), MP_ROM_PTR(&mp_math_isfinite_obj) }, - { MP_ROM_QSTR(MP_QSTR_isinf), MP_ROM_PTR(&mp_math_isinf_obj) }, - { MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_math_isnan_obj) }, - { MP_ROM_QSTR(MP_QSTR_trunc), MP_ROM_PTR(&mp_math_trunc_obj) }, - { MP_ROM_QSTR(MP_QSTR_radians), MP_ROM_PTR(&mp_math_radians_obj) }, - { MP_ROM_QSTR(MP_QSTR_degrees), MP_ROM_PTR(&mp_math_degrees_obj) }, - #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS - { MP_ROM_QSTR(MP_QSTR_erf), MP_ROM_PTR(&mp_math_erf_obj) }, - { MP_ROM_QSTR(MP_QSTR_erfc), MP_ROM_PTR(&mp_math_erfc_obj) }, - { MP_ROM_QSTR(MP_QSTR_gamma), MP_ROM_PTR(&mp_math_gamma_obj) }, - { MP_ROM_QSTR(MP_QSTR_lgamma), MP_ROM_PTR(&mp_math_lgamma_obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table); - -const mp_obj_module_t mp_module_math = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_math_globals, -}; - -#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/user/mpy/py/modmicropython.c b/user/mpy/py/modmicropython.c deleted file mode 100644 index 6fa3f9a..0000000 --- a/user/mpy/py/modmicropython.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/mpstate.h" -#include "py/builtin.h" -#include "py/stackctrl.h" -#include "py/runtime.h" -#include "py/gc.h" -#include "py/mphal.h" - -// Various builtins specific to MicroPython runtime, -// living in micropython module - -STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) { - if (n_args == 0) { - return MP_OBJ_NEW_SMALL_INT(MP_STATE_VM(mp_optimise_value)); - } else { - MP_STATE_VM(mp_optimise_value) = mp_obj_get_int(args[0]); - return mp_const_none; - } -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level); - -#if MICROPY_PY_MICROPYTHON_MEM_INFO - -#if MICROPY_MEM_STATS -STATIC mp_obj_t mp_micropython_mem_total(void) { - return MP_OBJ_NEW_SMALL_INT(m_get_total_bytes_allocated()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total); - -STATIC mp_obj_t mp_micropython_mem_current(void) { - return MP_OBJ_NEW_SMALL_INT(m_get_current_bytes_allocated()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current); - -STATIC mp_obj_t mp_micropython_mem_peak(void) { - return MP_OBJ_NEW_SMALL_INT(m_get_peak_bytes_allocated()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak); -#endif - -mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) { - (void)args; -#if MICROPY_MEM_STATS - mp_printf(&mp_plat_print, "mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n", - (mp_uint_t)m_get_total_bytes_allocated(), (mp_uint_t)m_get_current_bytes_allocated(), (mp_uint_t)m_get_peak_bytes_allocated()); -#endif -#if MICROPY_STACK_CHECK - mp_printf(&mp_plat_print, "stack: " UINT_FMT " out of " UINT_FMT "\n", - mp_stack_usage(), (mp_uint_t)MP_STATE_THREAD(stack_limit)); -#else - mp_printf(&mp_plat_print, "stack: " UINT_FMT "\n", mp_stack_usage()); -#endif -#if MICROPY_ENABLE_GC - gc_dump_info(); - if (n_args == 1) { - // arg given means dump gc allocation table - gc_dump_alloc_table(); - } -#else - (void)n_args; -#endif - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info); - -STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) { - (void)args; - size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; - qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); - mp_printf(&mp_plat_print, "qstr pool: n_pool=%u, n_qstr=%u, n_str_data_bytes=%u, n_total_bytes=%u\n", - n_pool, n_qstr, n_str_data_bytes, n_total_bytes); - if (n_args == 1) { - // arg given means dump qstr data - qstr_dump_data(); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info); - -#if MICROPY_STACK_CHECK -STATIC mp_obj_t mp_micropython_stack_use(void) { - return MP_OBJ_NEW_SMALL_INT(mp_stack_usage()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use); -#endif - -#endif // MICROPY_PY_MICROPYTHON_MEM_INFO - -#if MICROPY_ENABLE_GC -STATIC mp_obj_t mp_micropython_heap_lock(void) { - gc_lock(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock); - -STATIC mp_obj_t mp_micropython_heap_unlock(void) { - gc_unlock(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock); -#endif - -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0) -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf); -#endif - -#if MICROPY_KBD_EXCEPTION -STATIC mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) { - mp_hal_set_interrupt_char(mp_obj_get_int(int_chr_in)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr); -#endif - -#if MICROPY_ENABLE_SCHEDULER -STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) { - if (!mp_sched_schedule(function, arg)) { - mp_raise_msg(&mp_type_RuntimeError, "schedule stack full"); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule); -#endif - -STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) }, - { MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) }, - { MP_ROM_QSTR(MP_QSTR_opt_level), MP_ROM_PTR(&mp_micropython_opt_level_obj) }, -#if MICROPY_PY_MICROPYTHON_MEM_INFO -#if MICROPY_MEM_STATS - { MP_ROM_QSTR(MP_QSTR_mem_total), MP_ROM_PTR(&mp_micropython_mem_total_obj) }, - { MP_ROM_QSTR(MP_QSTR_mem_current), MP_ROM_PTR(&mp_micropython_mem_current_obj) }, - { MP_ROM_QSTR(MP_QSTR_mem_peak), MP_ROM_PTR(&mp_micropython_mem_peak_obj) }, -#endif - { MP_ROM_QSTR(MP_QSTR_mem_info), MP_ROM_PTR(&mp_micropython_mem_info_obj) }, - { MP_ROM_QSTR(MP_QSTR_qstr_info), MP_ROM_PTR(&mp_micropython_qstr_info_obj) }, - #if MICROPY_STACK_CHECK - { MP_ROM_QSTR(MP_QSTR_stack_use), MP_ROM_PTR(&mp_micropython_stack_use_obj) }, - #endif -#endif -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0) - { MP_ROM_QSTR(MP_QSTR_alloc_emergency_exception_buf), MP_ROM_PTR(&mp_alloc_emergency_exception_buf_obj) }, -#endif - #if MICROPY_ENABLE_GC - { MP_ROM_QSTR(MP_QSTR_heap_lock), MP_ROM_PTR(&mp_micropython_heap_lock_obj) }, - { MP_ROM_QSTR(MP_QSTR_heap_unlock), MP_ROM_PTR(&mp_micropython_heap_unlock_obj) }, - #endif - #if MICROPY_KBD_EXCEPTION - { MP_ROM_QSTR(MP_QSTR_kbd_intr), MP_ROM_PTR(&mp_micropython_kbd_intr_obj) }, - #endif - #if MICROPY_ENABLE_SCHEDULER - { MP_ROM_QSTR(MP_QSTR_schedule), MP_ROM_PTR(&mp_micropython_schedule_obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table); - -const mp_obj_module_t mp_module_micropython = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_micropython_globals, -}; diff --git a/user/mpy/py/modstruct.c b/user/mpy/py/modstruct.c deleted file mode 100644 index 1daa333..0000000 --- a/user/mpy/py/modstruct.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime.h" -#include "py/builtin.h" -#include "py/objtuple.h" -#include "py/binary.h" -#include "py/parsenum.h" - -#if MICROPY_PY_STRUCT - -/* - This module implements most of character typecodes from CPython, with - some extensions: - - O - (Pointer to) an arbitrary Python object. This is useful for callback - data, etc. Note that you must keep reference to passed object in - your Python application, otherwise it may be garbage-collected, - and then when you get back this value from callback it may be - invalid (and lead to crash). - S - Pointer to a string (returned as a Python string). Note the - difference from "Ns", - the latter says "in this place of structure - is character data of up to N bytes length", while "S" means - "in this place of a structure is a pointer to zero-terminated - character data". - */ - -STATIC char get_fmt_type(const char **fmt) { - char t = **fmt; - switch (t) { - case '!': - t = '>'; - break; - case '@': - case '=': - case '<': - case '>': - break; - default: - return '@'; - } - // Skip type char - (*fmt)++; - return t; -} - -STATIC mp_uint_t get_fmt_num(const char **p) { - const char *num = *p; - uint len = 1; - while (unichar_isdigit(*++num)) { - len++; - } - mp_uint_t val = (mp_uint_t)MP_OBJ_SMALL_INT_VALUE(mp_parse_num_integer(*p, len, 10, NULL)); - *p = num; - return val; -} - -STATIC uint calcsize_items(const char *fmt) { - uint cnt = 0; - while (*fmt) { - int num = 1; - if (unichar_isdigit(*fmt)) { - num = get_fmt_num(&fmt); - if (*fmt == 's') { - num = 1; - } - } - cnt += num; - fmt++; - } - return cnt; -} - -STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { - const char *fmt = mp_obj_str_get_str(fmt_in); - char fmt_type = get_fmt_type(&fmt); - mp_uint_t size; - for (size = 0; *fmt; fmt++) { - mp_uint_t cnt = 1; - if (unichar_isdigit(*fmt)) { - cnt = get_fmt_num(&fmt); - } - - if (*fmt == 's') { - size += cnt; - } else { - mp_uint_t align; - size_t sz = mp_binary_get_size(fmt_type, *fmt, &align); - while (cnt--) { - // Apply alignment - size = (size + align - 1) & ~(align - 1); - size += sz; - } - } - } - return MP_OBJ_NEW_SMALL_INT(size); -} -MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize); - -STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) { - // unpack requires that the buffer be exactly the right size. - // unpack_from requires that the buffer be "big enough". - // Since we implement unpack and unpack_from using the same function - // we relax the "exact" requirement, and only implement "big enough". - const char *fmt = mp_obj_str_get_str(args[0]); - char fmt_type = get_fmt_type(&fmt); - uint num_items = calcsize_items(fmt); - mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_items, NULL)); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); - byte *p = bufinfo.buf; - byte *end_p = &p[bufinfo.len]; - mp_int_t offset = 0; - - if (n_args > 2) { - // offset arg provided - offset = mp_obj_get_int(args[2]); - if (offset < 0) { - // negative offsets are relative to the end of the buffer - offset = bufinfo.len + offset; - if (offset < 0) { - mp_raise_ValueError("buffer too small"); - } - } - p += offset; - } - - for (uint i = 0; i < num_items;) { - mp_uint_t sz = 1; - if (unichar_isdigit(*fmt)) { - sz = get_fmt_num(&fmt); - } - if (p + sz > end_p) { - mp_raise_ValueError("buffer too small"); - } - mp_obj_t item; - if (*fmt == 's') { - item = mp_obj_new_bytes(p, sz); - p += sz; - res->items[i++] = item; - } else { - while (sz--) { - item = mp_binary_get_val(fmt_type, *fmt, &p); - res->items[i++] = item; - } - } - fmt++; - } - return MP_OBJ_FROM_PTR(res); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_from); - -STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args) { - const char *fmt = mp_obj_str_get_str(fmt_in); - char fmt_type = get_fmt_type(&fmt); - - size_t i; - for (i = 0; i < n_args;) { - mp_uint_t sz = 1; - if (*fmt == '\0') { - // more arguments given than used by format string; CPython raises struct.error here - break; - } - if (unichar_isdigit(*fmt)) { - sz = get_fmt_num(&fmt); - } - if (p + sz > end_p) { - mp_raise_ValueError("buffer too small"); - } - - if (*fmt == 's') { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[i++], &bufinfo, MP_BUFFER_READ); - mp_uint_t to_copy = sz; - if (bufinfo.len < to_copy) { - to_copy = bufinfo.len; - } - memcpy(p, bufinfo.buf, to_copy); - memset(p + to_copy, 0, sz - to_copy); - p += sz; - } else { - while (sz--) { - mp_binary_set_val(fmt_type, *fmt, args[i++], &p); - } - } - fmt++; - } -} - -STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { - // TODO: "The arguments must match the values required by the format exactly." - mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); - vstr_t vstr; - vstr_init_len(&vstr, size); - byte *p = (byte*)vstr.buf; - memset(p, 0, size); - byte *end_p = &p[size]; - struct_pack_into_internal(args[0], p, end_p, n_args - 1, &args[1]); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack); - -STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); - mp_int_t offset = mp_obj_get_int(args[2]); - if (offset < 0) { - // negative offsets are relative to the end of the buffer - offset = (mp_int_t)bufinfo.len + offset; - if (offset < 0) { - mp_raise_ValueError("buffer too small"); - } - } - byte *p = (byte *)bufinfo.buf; - byte *end_p = &p[bufinfo.len]; - p += offset; - - struct_pack_into_internal(args[0], p, end_p, n_args - 3, &args[3]); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into); - -STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ustruct) }, - { MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) }, - { MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) }, - { MP_ROM_QSTR(MP_QSTR_pack_into), MP_ROM_PTR(&struct_pack_into_obj) }, - { MP_ROM_QSTR(MP_QSTR_unpack), MP_ROM_PTR(&struct_unpack_from_obj) }, - { MP_ROM_QSTR(MP_QSTR_unpack_from), MP_ROM_PTR(&struct_unpack_from_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table); - -const mp_obj_module_t mp_module_ustruct = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_struct_globals, -}; - -#endif diff --git a/user/mpy/py/modsys.c b/user/mpy/py/modsys.c deleted file mode 100644 index b7d55fd..0000000 --- a/user/mpy/py/modsys.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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-2017 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. - */ - -#include "py/mpstate.h" -#include "py/nlr.h" -#include "py/builtin.h" -#include "py/objlist.h" -#include "py/objtuple.h" -#include "py/objstr.h" -#include "py/objint.h" -#include "py/objtype.h" -#include "py/stream.h" -#include "py/smallint.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_SYS - -#include "genhdr/mpversion.h" - -/// \module sys - system specific functions - -// defined per port; type of these is irrelevant, just need pointer -extern struct _mp_dummy_t mp_sys_stdin_obj; -extern struct _mp_dummy_t mp_sys_stdout_obj; -extern struct _mp_dummy_t mp_sys_stderr_obj; - -#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES -const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, mp_stream_write_adaptor}; -#endif - -/// \constant version - Python language version that this implementation conforms to, as a string -STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0"); - -/// \constant version_info - Python language version that this implementation conforms to, as a tuple of ints -#define I(n) MP_OBJ_NEW_SMALL_INT(n) -// TODO: CPython is now at 5-element array, but save 2 els so far... -STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}}; - -// sys.implementation object -// this holds the MicroPython version -STATIC const mp_obj_tuple_t mp_sys_implementation_version_info_obj = { - {&mp_type_tuple}, - 3, - { I(MICROPY_VERSION_MAJOR), I(MICROPY_VERSION_MINOR), I(MICROPY_VERSION_MICRO) } -}; -#if MICROPY_PY_ATTRTUPLE -STATIC const qstr impl_fields[] = { MP_QSTR_name, MP_QSTR_version }; -STATIC MP_DEFINE_ATTRTUPLE( - mp_sys_implementation_obj, - impl_fields, - 2, - MP_ROM_QSTR(MP_QSTR_micropython), - MP_ROM_PTR(&mp_sys_implementation_version_info_obj) -); -#else -STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = { - {&mp_type_tuple}, - 2, - { - MP_ROM_QSTR(MP_QSTR_micropython), - MP_ROM_PTR(&mp_sys_implementation_version_info_obj), - } -}; -#endif - -#undef I - -#ifdef MICROPY_PY_SYS_PLATFORM -/// \constant platform - the platform that MicroPython is running on -STATIC const MP_DEFINE_STR_OBJ(platform_obj, MICROPY_PY_SYS_PLATFORM); -#endif - -/// \function exit([retval]) -/// Raise a `SystemExit` exception. If an argument is given, it is the -/// value given to `SystemExit`. -STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) { - mp_obj_t exc; - if (n_args == 0) { - exc = mp_obj_new_exception(&mp_type_SystemExit); - } else { - exc = mp_obj_new_exception_arg1(&mp_type_SystemExit, args[0]); - } - nlr_raise(exc); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit); - -STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) { - #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES - void *stream_obj = &mp_sys_stdout_obj; - if (n_args > 1) { - stream_obj = MP_OBJ_TO_PTR(args[1]); // XXX may fail - } - - mp_print_t print = {stream_obj, mp_stream_write_adaptor}; - mp_obj_print_exception(&print, args[0]); - #else - (void)n_args; - mp_obj_print_exception(&mp_plat_print, args[0]); - #endif - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_print_exception_obj, 1, 2, mp_sys_print_exception); - -#if MICROPY_PY_SYS_EXC_INFO -STATIC mp_obj_t mp_sys_exc_info(void) { - mp_obj_t cur_exc = MP_OBJ_FROM_PTR(MP_STATE_VM(cur_exception)); - mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL)); - - if (cur_exc == MP_OBJ_NULL) { - t->items[0] = mp_const_none; - t->items[1] = mp_const_none; - t->items[2] = mp_const_none; - return MP_OBJ_FROM_PTR(t); - } - - t->items[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(cur_exc)); - t->items[1] = cur_exc; - t->items[2] = mp_const_none; - return MP_OBJ_FROM_PTR(t); -} -MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info); -#endif - -STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) { - return mp_unary_op(MP_UNARY_OP_SIZEOF, obj); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof); - -STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) }, - - { MP_ROM_QSTR(MP_QSTR_path), MP_ROM_PTR(&MP_STATE_VM(mp_sys_path_obj)) }, - { MP_ROM_QSTR(MP_QSTR_argv), MP_ROM_PTR(&MP_STATE_VM(mp_sys_argv_obj)) }, - { MP_ROM_QSTR(MP_QSTR_version), MP_ROM_PTR(&version_obj) }, - { MP_ROM_QSTR(MP_QSTR_version_info), MP_ROM_PTR(&mp_sys_version_info_obj) }, - { MP_ROM_QSTR(MP_QSTR_implementation), MP_ROM_PTR(&mp_sys_implementation_obj) }, - #ifdef MICROPY_PY_SYS_PLATFORM - { MP_ROM_QSTR(MP_QSTR_platform), MP_ROM_PTR(&platform_obj) }, - #endif - /// \constant byteorder - the byte order of the system ("little" or "big") - #if MP_ENDIANNESS_LITTLE - { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_QSTR(MP_QSTR_little) }, - #else - { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_QSTR(MP_QSTR_big) }, - #endif - - #if MICROPY_PY_SYS_MAXSIZE - #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE - // Maximum mp_int_t value is not representable as small int, so we have - // little choice but to use MP_SMALL_INT_MAX. Apps also should be careful - // to not try to compare sys.maxsize to some literal number (as this - // number might not fit in available int size), but instead count number - // of "one" bits in sys.maxsize. - { MP_ROM_QSTR(MP_QSTR_maxsize), MP_ROM_INT(MP_SMALL_INT_MAX) }, - #else - { MP_ROM_QSTR(MP_QSTR_maxsize), MP_ROM_PTR(&mp_maxsize_obj) }, - #endif - #endif - - #if MICROPY_PY_SYS_EXIT - // documented per-port - { MP_ROM_QSTR(MP_QSTR_exit), MP_ROM_PTR(&mp_sys_exit_obj) }, - #endif - - #if MICROPY_PY_SYS_STDFILES - // documented per-port - { MP_ROM_QSTR(MP_QSTR_stdin), MP_ROM_PTR(&mp_sys_stdin_obj) }, - { MP_ROM_QSTR(MP_QSTR_stdout), MP_ROM_PTR(&mp_sys_stdout_obj) }, - { MP_ROM_QSTR(MP_QSTR_stderr), MP_ROM_PTR(&mp_sys_stderr_obj) }, - #endif - - #if MICROPY_PY_SYS_MODULES - { MP_ROM_QSTR(MP_QSTR_modules), MP_ROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)) }, - #endif - #if MICROPY_PY_SYS_EXC_INFO - { MP_ROM_QSTR(MP_QSTR_exc_info), MP_ROM_PTR(&mp_sys_exc_info_obj) }, - #endif - #if MICROPY_PY_SYS_GETSIZEOF - { MP_ROM_QSTR(MP_QSTR_getsizeof), MP_ROM_PTR(&mp_sys_getsizeof_obj) }, - #endif - - /* - * Extensions to CPython - */ - - { MP_ROM_QSTR(MP_QSTR_print_exception), MP_ROM_PTR(&mp_sys_print_exception_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table); - -const mp_obj_module_t mp_module_sys = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_sys_globals, -}; - -#endif diff --git a/user/mpy/py/modthread.c b/user/mpy/py/modthread.c deleted file mode 100644 index bf74128..0000000 --- a/user/mpy/py/modthread.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime.h" -#include "py/stackctrl.h" - -#if MICROPY_PY_THREAD - -#include "py/mpthread.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_PRINT (0) -#define DEBUG_printf(...) (void)0 -#endif - -/****************************************************************/ -// Lock object - -STATIC const mp_obj_type_t mp_type_thread_lock; - -typedef struct _mp_obj_thread_lock_t { - mp_obj_base_t base; - mp_thread_mutex_t mutex; - volatile bool locked; -} mp_obj_thread_lock_t; - -STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) { - mp_obj_thread_lock_t *self = m_new_obj(mp_obj_thread_lock_t); - self->base.type = &mp_type_thread_lock; - mp_thread_mutex_init(&self->mutex); - self->locked = false; - return self; -} - -STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) { - mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(args[0]); - bool wait = true; - if (n_args > 1) { - wait = mp_obj_get_int(args[1]); - // TODO support timeout arg - } - MP_THREAD_GIL_EXIT(); - int ret = mp_thread_mutex_lock(&self->mutex, wait); - MP_THREAD_GIL_ENTER(); - if (ret == 0) { - return mp_const_false; - } else if (ret == 1) { - self->locked = true; - return mp_const_true; - } else { - mp_raise_OSError(-ret); - } -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire); - -STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) { - mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in); - if (!self->locked) { - mp_raise_msg(&mp_type_RuntimeError, NULL); - } - self->locked = false; - MP_THREAD_GIL_EXIT(); - mp_thread_mutex_unlock(&self->mutex); - MP_THREAD_GIL_ENTER(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release); - -STATIC mp_obj_t thread_lock_locked(mp_obj_t self_in) { - mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->locked); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked); - -STATIC mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) { - (void)n_args; // unused - return thread_lock_release(args[0]); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__); - -STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_acquire), MP_ROM_PTR(&thread_lock_acquire_obj) }, - { MP_ROM_QSTR(MP_QSTR_release), MP_ROM_PTR(&thread_lock_release_obj) }, - { MP_ROM_QSTR(MP_QSTR_locked), MP_ROM_PTR(&thread_lock_locked_obj) }, - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&thread_lock_acquire_obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&thread_lock___exit___obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table); - -STATIC const mp_obj_type_t mp_type_thread_lock = { - { &mp_type_type }, - .name = MP_QSTR_lock, - .locals_dict = (mp_obj_dict_t*)&thread_lock_locals_dict, -}; - -/****************************************************************/ -// _thread module - -STATIC size_t thread_stack_size = 0; - -STATIC mp_obj_t mod_thread_get_ident(void) { - return mp_obj_new_int_from_uint((uintptr_t)mp_thread_get_state()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident); - -STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) { - mp_obj_t ret = mp_obj_new_int_from_uint(thread_stack_size); - if (n_args == 0) { - thread_stack_size = 0; - } else { - thread_stack_size = mp_obj_get_int(args[0]); - } - return ret; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size); - -typedef struct _thread_entry_args_t { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - size_t stack_size; - mp_obj_t fun; - size_t n_args; - size_t n_kw; - mp_obj_t args[]; -} thread_entry_args_t; - -STATIC void *thread_entry(void *args_in) { - // Execution begins here for a new thread. We do not have the GIL. - - thread_entry_args_t *args = (thread_entry_args_t*)args_in; - - mp_state_thread_t ts; - mp_thread_set_state(&ts); - - mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan - mp_stack_set_limit(args->stack_size); - - // set locals and globals from the calling context - mp_locals_set(args->dict_locals); - mp_globals_set(args->dict_globals); - - MP_THREAD_GIL_ENTER(); - - // signal that we are set up and running - mp_thread_start(); - - // TODO set more thread-specific state here: - // mp_pending_exception? (root pointer) - // cur_exception (root pointer) - - DEBUG_printf("[thread] start ts=%p args=%p stack=%p\n", &ts, &args, MP_STATE_THREAD(stack_top)); - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_call_function_n_kw(args->fun, args->n_args, args->n_kw, args->args); - nlr_pop(); - } else { - // uncaught exception - // check for SystemExit - mp_obj_base_t *exc = (mp_obj_base_t*)nlr.ret_val; - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) { - // swallow exception silently - } else { - // print exception out - mp_printf(&mp_plat_print, "Unhandled exception in thread started by "); - mp_obj_print_helper(&mp_plat_print, args->fun, PRINT_REPR); - mp_printf(&mp_plat_print, "\n"); - mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(exc)); - } - } - - DEBUG_printf("[thread] finish ts=%p\n", &ts); - - // signal that we are finished - mp_thread_finish(); - - MP_THREAD_GIL_EXIT(); - - return NULL; -} - -STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) { - // This structure holds the Python function and arguments for thread entry. - // We copy all arguments into this structure to keep ownership of them. - // We must be very careful about root pointers because this pointer may - // disappear from our address space before the thread is created. - thread_entry_args_t *th_args; - - // get positional arguments - size_t pos_args_len; - mp_obj_t *pos_args_items; - mp_obj_get_array(args[1], &pos_args_len, &pos_args_items); - - // check for keyword arguments - if (n_args == 2) { - // just position arguments - th_args = m_new_obj_var(thread_entry_args_t, mp_obj_t, pos_args_len); - th_args->n_kw = 0; - } else { - // positional and keyword arguments - if (mp_obj_get_type(args[2]) != &mp_type_dict) { - mp_raise_TypeError("expecting a dict for keyword args"); - } - mp_map_t *map = &((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[2]))->map; - th_args = m_new_obj_var(thread_entry_args_t, mp_obj_t, pos_args_len + 2 * map->used); - th_args->n_kw = map->used; - // copy across the keyword arguments - for (size_t i = 0, n = pos_args_len; i < map->alloc; ++i) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - th_args->args[n++] = map->table[i].key; - th_args->args[n++] = map->table[i].value; - } - } - } - - // copy agross the positional arguments - th_args->n_args = pos_args_len; - memcpy(th_args->args, pos_args_items, pos_args_len * sizeof(mp_obj_t)); - - // pass our locals and globals into the new thread - th_args->dict_locals = mp_locals_get(); - th_args->dict_globals = mp_globals_get(); - - // set the stack size to use - th_args->stack_size = thread_stack_size; - - // set the function for thread entry - th_args->fun = args[0]; - - // spawn the thread! - mp_thread_create(thread_entry, th_args, &th_args->stack_size); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread); - -STATIC mp_obj_t mod_thread_exit(void) { - nlr_raise(mp_obj_new_exception(&mp_type_SystemExit)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit); - -STATIC mp_obj_t mod_thread_allocate_lock(void) { - return MP_OBJ_FROM_PTR(mp_obj_new_thread_lock()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock); - -STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__thread) }, - { MP_ROM_QSTR(MP_QSTR_LockType), MP_ROM_PTR(&mp_type_thread_lock) }, - { MP_ROM_QSTR(MP_QSTR_get_ident), MP_ROM_PTR(&mod_thread_get_ident_obj) }, - { MP_ROM_QSTR(MP_QSTR_stack_size), MP_ROM_PTR(&mod_thread_stack_size_obj) }, - { MP_ROM_QSTR(MP_QSTR_start_new_thread), MP_ROM_PTR(&mod_thread_start_new_thread_obj) }, - { MP_ROM_QSTR(MP_QSTR_exit), MP_ROM_PTR(&mod_thread_exit_obj) }, - { MP_ROM_QSTR(MP_QSTR_allocate_lock), MP_ROM_PTR(&mod_thread_allocate_lock_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table); - -const mp_obj_module_t mp_module_thread = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_thread_globals, -}; - -#endif // MICROPY_PY_THREAD diff --git a/user/mpy/py/moduerrno.c b/user/mpy/py/moduerrno.c deleted file mode 100644 index de66c94..0000000 --- a/user/mpy/py/moduerrno.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ - -#include -#include - -#include "py/obj.h" -#include "py/mperrno.h" - -#if MICROPY_PY_UERRNO - -// This list can be defined per port in mpconfigport.h to tailor it to a -// specific port's needs. If it's not defined then we provide a default. -#ifndef MICROPY_PY_UERRNO_LIST -#define MICROPY_PY_UERRNO_LIST \ - X(EPERM) \ - X(ENOENT) \ - X(EIO) \ - X(EBADF) \ - X(EAGAIN) \ - X(ENOMEM) \ - X(EACCES) \ - X(EEXIST) \ - X(ENODEV) \ - X(EISDIR) \ - X(EINVAL) \ - X(EOPNOTSUPP) \ - X(EADDRINUSE) \ - X(ECONNABORTED) \ - X(ECONNRESET) \ - X(ENOBUFS) \ - X(ENOTCONN) \ - X(ETIMEDOUT) \ - X(ECONNREFUSED) \ - X(EHOSTUNREACH) \ - X(EALREADY) \ - X(EINPROGRESS) \ - -#endif - -#if MICROPY_PY_UERRNO_ERRORCODE -STATIC const mp_rom_map_elem_t errorcode_table[] = { - #define X(e) { MP_ROM_INT(MP_ ## e), MP_ROM_QSTR(MP_QSTR_## e) }, - MICROPY_PY_UERRNO_LIST - #undef X -}; - -STATIC const mp_obj_dict_t errorcode_dict = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 0, // keys are integers - .is_fixed = 1, - .is_ordered = 1, - .used = MP_ARRAY_SIZE(errorcode_table), - .alloc = MP_ARRAY_SIZE(errorcode_table), - .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)errorcode_table, - }, -}; -#endif - -STATIC const mp_rom_map_elem_t mp_module_uerrno_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uerrno) }, - #if MICROPY_PY_UERRNO_ERRORCODE - { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) }, - #endif - - #define X(e) { MP_ROM_QSTR(MP_QSTR_## e), MP_ROM_INT(MP_ ## e) }, - MICROPY_PY_UERRNO_LIST - #undef X -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_uerrno_globals, mp_module_uerrno_globals_table); - -const mp_obj_module_t mp_module_uerrno = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_uerrno_globals, -}; - -qstr mp_errno_to_str(mp_obj_t errno_val) { - #if MICROPY_PY_UERRNO_ERRORCODE - // We have the errorcode dict so can do a lookup using the hash map - mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&errorcode_dict.map, errno_val, MP_MAP_LOOKUP); - if (elem == NULL) { - return MP_QSTR_NULL; - } else { - return MP_OBJ_QSTR_VALUE(elem->value); - } - #else - // We don't have the errorcode dict so do a simple search in the modules dict - for (size_t i = 0; i < MP_ARRAY_SIZE(mp_module_uerrno_globals_table); ++i) { - if (errno_val == mp_module_uerrno_globals_table[i].value) { - return MP_OBJ_QSTR_VALUE(mp_module_uerrno_globals_table[i].key); - } - } - return MP_QSTR_NULL; - #endif -} - -#endif //MICROPY_PY_UERRNO diff --git a/user/mpy/py/mpconfig.h b/user/mpy/py/mpconfig.h deleted file mode 100644 index dac8a90..0000000 --- a/user/mpy/py/mpconfig.h +++ /dev/null @@ -1,1266 +0,0 @@ -/* - * 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 - -// 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=""' -// 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 -#include MP_CONFIGFILE -#else -#include -#endif - -// 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...xx10 : a qstr, bits 2 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...xx11 : a qstr, bits 2 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 qqqqq110 str with 20-bit qstr 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 and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000. -// This makes strs 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 00000000 00000000 iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int -// - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str -// - 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 - -/*****************************************************************************/ -/* 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 * BYTES_PER_WORD) -#endif - -// 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 - -// 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 - -// Support automatic GC when reaching allocation threshold, -// configurable by gc.threshold(). -#ifndef MICROPY_GC_ALLOC_THRESHOLD -#define MICROPY_GC_ALLOC_THRESHOLD (1) -#endif - -// 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 - -// Initial amount for lexer indentation level -#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT -#define MICROPY_ALLOC_LEXER_INDENT_INIT (10) -#endif - -// Increment for lexer indentation level -#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC -#define MICROPY_ALLOC_LEXEL_INDENT_INC (8) -#endif - -// Initial amount for parse rule stack -#ifndef MICROPY_ALLOC_PARSE_RULE_INIT -#define MICROPY_ALLOC_PARSE_RULE_INIT (64) -#endif - -// Increment for parse rule stack -#ifndef MICROPY_ALLOC_PARSE_RULE_INC -#define MICROPY_ALLOC_PARSE_RULE_INC (16) -#endif - -// Initial amount for parse result stack -#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT -#define MICROPY_ALLOC_PARSE_RESULT_INIT (32) -#endif - -// Increment for parse result stack -#ifndef MICROPY_ALLOC_PARSE_RESULT_INC -#define MICROPY_ALLOC_PARSE_RESULT_INC (16) -#endif - -// 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 - -// 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 - -// Initial amount for ids in a scope -#ifndef MICROPY_ALLOC_SCOPE_ID_INIT -#define MICROPY_ALLOC_SCOPE_ID_INIT (4) -#endif - -// Increment for ids in a scope -#ifndef MICROPY_ALLOC_SCOPE_ID_INC -#define MICROPY_ALLOC_SCOPE_ID_INC (6) -#endif - -// 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 - -// Initial size of module dict -#ifndef MICROPY_MODULE_DICT_SIZE -#define MICROPY_MODULE_DICT_SIZE (1) -#endif - -// 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 - -// 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 - -// Number of bytes used to store qstr hash -#ifndef MICROPY_QSTR_BYTES_IN_HASH -#define MICROPY_QSTR_BYTES_IN_HASH (2) -#endif - -// 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 - -// 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 - -// 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 defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA -#undef alloca -#define alloca(x) m_malloc(x) -#endif - -/*****************************************************************************/ -/* MicroPython emitters */ - -// Whether to support loading of persistent code -#ifndef MICROPY_PERSISTENT_CODE_LOAD -#define MICROPY_PERSISTENT_CODE_LOAD (0) -#endif - -// Whether to support saving of persistent code -#ifndef MICROPY_PERSISTENT_CODE_SAVE -#define MICROPY_PERSISTENT_CODE_SAVE (0) -#endif - -// 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 - -// Whether to emit x64 native code -#ifndef MICROPY_EMIT_X64 -#define MICROPY_EMIT_X64 (0) -#endif - -// Whether to emit x86 native code -#ifndef MICROPY_EMIT_X86 -#define MICROPY_EMIT_X86 (0) -#endif - -// Whether to emit thumb native code -#ifndef MICROPY_EMIT_THUMB -#define MICROPY_EMIT_THUMB (0) -#endif - -// Whether to enable the thumb inline assembler -#ifndef MICROPY_EMIT_INLINE_THUMB -#define MICROPY_EMIT_INLINE_THUMB (0) -#endif - -// 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 - -// Whether to enable float support in the Thumb2 inline assembler -#ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT -#define MICROPY_EMIT_INLINE_THUMB_FLOAT (1) -#endif - -// Whether to emit ARM native code -#ifndef MICROPY_EMIT_ARM -#define MICROPY_EMIT_ARM (0) -#endif - -// Whether to emit Xtensa native code -#ifndef MICROPY_EMIT_XTENSA -#define MICROPY_EMIT_XTENSA (0) -#endif - -// Whether to enable the Xtensa inline assembler -#ifndef MICROPY_EMIT_INLINE_XTENSA -#define MICROPY_EMIT_INLINE_XTENSA (0) -#endif - -// 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) - -// Convenience definition for whether any inline assembler emitter is enabled -#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA) - -/*****************************************************************************/ -/* Compiler configuration */ - -// Whether to include the compiler -#ifndef MICROPY_ENABLE_COMPILER -#define MICROPY_ENABLE_COMPILER (1) -#endif - -// Whether the compiler is dynamically configurable (ie at runtime) -#ifndef MICROPY_DYNAMIC_COMPILER -#define MICROPY_DYNAMIC_COMPILER (0) -#endif - -// Configure dynamic compiler macros -#if MICROPY_DYNAMIC_COMPILER -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode) -#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode) -#else -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE -#endif - -// Whether to enable constant folding; eg 1+2 rewritten as 3 -#ifndef MICROPY_COMP_CONST_FOLDING -#define MICROPY_COMP_CONST_FOLDING (1) -#endif - -// Whether to enable lookup of constants in modules; eg module.CONST -#ifndef MICROPY_COMP_MODULE_CONST -#define MICROPY_COMP_MODULE_CONST (0) -#endif - -// Whether to enable constant optimisation; id = const(value) -#ifndef MICROPY_COMP_CONST -#define MICROPY_COMP_CONST (1) -#endif - -// 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 (1) -#endif - -// Whether to enable optimisation of: a, b, c = d, e, f -// Cost 156 bytes (Thumb2) -#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN -#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0) -#endif - -// 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 - -/*****************************************************************************/ -/* Internal debugging stuff */ - -// Whether to collect memory allocation stats -#ifndef MICROPY_MEM_STATS -#define MICROPY_MEM_STATS (0) -#endif - -// 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 - -// Whether to enable all debugging outputs (it will be extremely verbose) -#ifndef MICROPY_DEBUG_VERBOSE -#define MICROPY_DEBUG_VERBOSE (0) -#endif - -/*****************************************************************************/ -/* 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 -#ifndef MICROPY_OPT_COMPUTED_GOTO -#define MICROPY_OPT_COMPUTED_GOTO (0) -#endif - -// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR, -// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and -// uses a bit of extra code ROM, but greatly improves lookup speed. -#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) -#endif - -// 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 - -/*****************************************************************************/ -/* Python internal features */ - -// Whether to use the POSIX reader for importing files -#ifndef MICROPY_READER_POSIX -#define MICROPY_READER_POSIX (0) -#endif - -// Whether to use the VFS reader for importing files -#ifndef MICROPY_READER_VFS -#define MICROPY_READER_VFS (0) -#endif - -// 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 - -// Hook for the VM during the opcode loop (but only after jump opcodes) -#ifndef MICROPY_VM_HOOK_LOOP -#define MICROPY_VM_HOOK_LOOP -#endif - -// Hook for the VM just before return opcode is finished being interpreted -#ifndef MICROPY_VM_HOOK_RETURN -#define MICROPY_VM_HOOK_RETURN -#endif - -// Whether to include the garbage collector -#ifndef MICROPY_ENABLE_GC -#define MICROPY_ENABLE_GC (0) -#endif - -// Whether to enable finalisers in the garbage collector (ie call __del__) -#ifndef MICROPY_ENABLE_FINALISER -#define MICROPY_ENABLE_FINALISER (0) -#endif - -// 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 - -// Whether to have an emergency exception buffer -#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF -#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0) -#endif -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF -# ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE -# define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation -# endif -#endif - -// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function -#ifndef MICROPY_KBD_EXCEPTION -#define MICROPY_KBD_EXCEPTION (0) -#endif - -// 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 - -// Whether to include REPL helper function -#ifndef MICROPY_HELPER_REPL -#define MICROPY_HELPER_REPL (0) -#endif - -// Whether to include emacs-style readline behavior in REPL -#ifndef MICROPY_REPL_EMACS_KEYS -#define MICROPY_REPL_EMACS_KEYS (0) -#endif - -// Whether to implement auto-indent in REPL -#ifndef MICROPY_REPL_AUTO_INDENT -#define MICROPY_REPL_AUTO_INDENT (0) -#endif - -// Whether port requires event-driven REPL functions -#ifndef MICROPY_REPL_EVENT_DRIVEN -#define MICROPY_REPL_EVENT_DRIVEN (0) -#endif - -// Whether to include lexer helper function for unix -#ifndef MICROPY_HELPER_LEXER_UNIX -#define MICROPY_HELPER_LEXER_UNIX (0) -#endif - -// 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 - -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG -typedef long long mp_longint_impl_t; -#endif - -// 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 - -// Whether to include doc strings (increases RAM usage) -#ifndef MICROPY_ENABLE_DOC_STRING -#define MICROPY_ENABLE_DOC_STRING (0) -#endif - -// 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 -#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) -#endif - -// Whether issue warnings during compiling/execution -#ifndef MICROPY_WARNINGS -#define MICROPY_WARNINGS (0) -#endif - -// 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 - -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -#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; -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -#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 -#define MICROPY_PY_BUILTINS_FLOAT (0) -#endif - -#ifndef MICROPY_PY_BUILTINS_COMPLEX -#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT) -#endif - -// 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 - -// 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 (1) -#endif - -// 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 (1) -#endif - -// Whether POSIX-semantics non-blocking streams are supported -#ifndef MICROPY_STREAMS_NON_BLOCK -#define MICROPY_STREAMS_NON_BLOCK (0) -#endif - -// 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 - -// Whether to call __init__ when importing builtin modules for the first time -#ifndef MICROPY_MODULE_BUILTIN_INIT -#define MICROPY_MODULE_BUILTIN_INIT (0) -#endif - -// Whether module weak links are supported -#ifndef MICROPY_MODULE_WEAK_LINKS -#define MICROPY_MODULE_WEAK_LINKS (0) -#endif - -// Whether frozen modules are supported in the form of strings -#ifndef MICROPY_MODULE_FROZEN_STR -#define MICROPY_MODULE_FROZEN_STR (0) -#endif - -// Whether frozen modules are supported in the form of .mpy files -#ifndef MICROPY_MODULE_FROZEN_MPY -#define MICROPY_MODULE_FROZEN_MPY (0) -#endif - -// 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 - -// Whether you can override builtins in the builtins module -#ifndef MICROPY_CAN_OVERRIDE_BUILTINS -#define MICROPY_CAN_OVERRIDE_BUILTINS (0) -#endif - -// 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 (1) -#endif - -// Whether to use internally defined errno's (otherwise system provided ones) -#ifndef MICROPY_USE_INTERNAL_ERRNO -#define MICROPY_USE_INTERNAL_ERRNO (0) -#endif - -// Whether to use internally defined *printf() functions (otherwise external ones) -#ifndef MICROPY_USE_INTERNAL_PRINTF -#define MICROPY_USE_INTERNAL_PRINTF (1) -#endif - -// Support for internal scheduler -#ifndef MICROPY_ENABLE_SCHEDULER -#define MICROPY_ENABLE_SCHEDULER (0) -#endif - -// Maximum number of entries in the scheduler -#ifndef MICROPY_SCHEDULER_DEPTH -#define MICROPY_SCHEDULER_DEPTH (4) -#endif - -// Support for generic VFS sub-system -#ifndef MICROPY_VFS -#define MICROPY_VFS (0) -#endif - -/*****************************************************************************/ -/* Fine control over Python builtins, classes, modules, etc */ - -// Whether to implement attributes on functions -#ifndef MICROPY_PY_FUNCTION_ATTRS -#define MICROPY_PY_FUNCTION_ATTRS (0) -#endif - -// Whether to support descriptors (__get__ and __set__) -// This costs some code size and makes all load attrs and store attrs slow -#ifndef MICROPY_PY_DESCRIPTORS -#define MICROPY_PY_DESCRIPTORS (0) -#endif - -// Whether to support class __delattr__ and __setattr__ methods -// This costs some code size and makes all del attrs and store attrs slow -#ifndef MICROPY_PY_DELATTR_SETATTR -#define MICROPY_PY_DELATTR_SETATTR (0) -#endif - -// Support for async/await/async for/async with -#ifndef MICROPY_PY_ASYNC_AWAIT -#define MICROPY_PY_ASYNC_AWAIT (1) -#endif - -// 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 - -// Whether str object is proper unicode -#ifndef MICROPY_PY_BUILTINS_STR_UNICODE -#define MICROPY_PY_BUILTINS_STR_UNICODE (0) -#endif - -// Whether str.center() method provided -#ifndef MICROPY_PY_BUILTINS_STR_CENTER -#define MICROPY_PY_BUILTINS_STR_CENTER (0) -#endif - -// Whether str.partition()/str.rpartition() method provided -#ifndef MICROPY_PY_BUILTINS_STR_PARTITION -#define MICROPY_PY_BUILTINS_STR_PARTITION (0) -#endif - -// Whether str.splitlines() method provided -#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES -#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0) -#endif - -// Whether to support bytearray object -#ifndef MICROPY_PY_BUILTINS_BYTEARRAY -#define MICROPY_PY_BUILTINS_BYTEARRAY (1) -#endif - -// Whether to support memoryview object -#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW -#define MICROPY_PY_BUILTINS_MEMORYVIEW (0) -#endif - -// Whether to support set object -#ifndef MICROPY_PY_BUILTINS_SET -#define MICROPY_PY_BUILTINS_SET (1) -#endif - -// Whether to support slice subscript operators and slice object -#ifndef MICROPY_PY_BUILTINS_SLICE -#define MICROPY_PY_BUILTINS_SLICE (1) -#endif - -// 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 - -// Whether to support frozenset object -#ifndef MICROPY_PY_BUILTINS_FROZENSET -#define MICROPY_PY_BUILTINS_FROZENSET (0) -#endif - -// Whether to support property object -#ifndef MICROPY_PY_BUILTINS_PROPERTY -#define MICROPY_PY_BUILTINS_PROPERTY (1) -#endif - -// 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 (1) -#endif - -// Whether to support timeout exceptions (like socket.timeout) -#ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR -#define MICROPY_PY_BUILTINS_TIMEOUTERROR (0) -#endif - -// Whether to support complete set of special methods -// for user classes, otherwise only the most used -#ifndef MICROPY_PY_ALL_SPECIAL_METHODS -#define MICROPY_PY_ALL_SPECIAL_METHODS (0) -#endif - -// Whether to support compile function -#ifndef MICROPY_PY_BUILTINS_COMPILE -#define MICROPY_PY_BUILTINS_COMPILE (0) -#endif - -// Whether to support enumerate function(type) -#ifndef MICROPY_PY_BUILTINS_ENUMERATE -#define MICROPY_PY_BUILTINS_ENUMERATE (1) -#endif - -// 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 - -// Whether to support the Python 2 execfile function -#ifndef MICROPY_PY_BUILTINS_EXECFILE -#define MICROPY_PY_BUILTINS_EXECFILE (0) -#endif - -// Whether to support filter function(type) -#ifndef MICROPY_PY_BUILTINS_FILTER -#define MICROPY_PY_BUILTINS_FILTER (1) -#endif - -// Whether to support reversed function(type) -#ifndef MICROPY_PY_BUILTINS_REVERSED -#define MICROPY_PY_BUILTINS_REVERSED (1) -#endif - -// Whether to define "NotImplemented" special constant -#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) -#endif - -// Whether to provide the built-in input() function. The implementation of this -// uses mp-readline, so can only be enabled if the port uses this readline. -#ifndef MICROPY_PY_BUILTINS_INPUT -#define MICROPY_PY_BUILTINS_INPUT (0) -#endif - -// Whether to support min/max functions -#ifndef MICROPY_PY_BUILTINS_MIN_MAX -#define MICROPY_PY_BUILTINS_MIN_MAX (1) -#endif - -// Support for calls to pow() with 3 integer arguments -#ifndef MICROPY_PY_BUILTINS_POW3 -#define MICROPY_PY_BUILTINS_POW3 (0) -#endif - -// Whether to provide the help function -#ifndef MICROPY_PY_BUILTINS_HELP -#define MICROPY_PY_BUILTINS_HELP (0) -#endif - -// 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 - -// 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 - -// Whether to set __file__ for imported modules -#ifndef MICROPY_PY___FILE__ -#define MICROPY_PY___FILE__ (1) -#endif - -// Whether to provide mem-info related functions in micropython module -#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO -#define MICROPY_PY_MICROPYTHON_MEM_INFO (0) -#endif - -// 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 (1) -#endif - -// 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 - -// Whether to support attrtuple type (MicroPython extension) -// It provides space-efficient tuples with attribute access -#ifndef MICROPY_PY_ATTRTUPLE -#define MICROPY_PY_ATTRTUPLE (1) -#endif - -// Whether to provide "collections" module -#ifndef MICROPY_PY_COLLECTIONS -#define MICROPY_PY_COLLECTIONS (1) -#endif - -// Whether to provide "collections.OrderedDict" type -#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT -#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) -#endif - -// Whether to provide "math" module -#ifndef MICROPY_PY_MATH -#define MICROPY_PY_MATH (1) -#endif - -// 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 - -// Whether to provide "cmath" module -#ifndef MICROPY_PY_CMATH -#define MICROPY_PY_CMATH (0) -#endif - -// Whether to provide "gc" module -#ifndef MICROPY_PY_GC -#define MICROPY_PY_GC (1) -#endif - -// Whether to return number of collected objects from gc.collect() -#ifndef MICROPY_PY_GC_COLLECT_RETVAL -#define MICROPY_PY_GC_COLLECT_RETVAL (0) -#endif - -// Whether to provide "io" module -#ifndef MICROPY_PY_IO -#define MICROPY_PY_IO (1) -#endif - -// Whether to provide "uio.resource_stream()" function with -// the semantics of CPython's pkg_resources.resource_stream() -// (allows to access resources in frozen packages). -#ifndef MICROPY_PY_IO_RESOURCE_STREAM -#define MICROPY_PY_IO_RESOURCE_STREAM (0) -#endif - -// Whether to provide "io.FileIO" class -#ifndef MICROPY_PY_IO_FILEIO -#define MICROPY_PY_IO_FILEIO (0) -#endif - -// Whether to provide "io.BytesIO" class -#ifndef MICROPY_PY_IO_BYTESIO -#define MICROPY_PY_IO_BYTESIO (1) -#endif - -// Whether to provide "io.BufferedWriter" class -#ifndef MICROPY_PY_IO_BUFFEREDWRITER -#define MICROPY_PY_IO_BUFFEREDWRITER (0) -#endif - -// Whether to provide "struct" module -#ifndef MICROPY_PY_STRUCT -#define MICROPY_PY_STRUCT (1) -#endif - -// Whether to provide "sys" module -#ifndef MICROPY_PY_SYS -#define MICROPY_PY_SYS (1) -#endif - -// Whether to provide "sys.maxsize" constant -#ifndef MICROPY_PY_SYS_MAXSIZE -#define MICROPY_PY_SYS_MAXSIZE (0) -#endif - -// Whether to provide "sys.modules" dictionary -#ifndef MICROPY_PY_SYS_MODULES -#define MICROPY_PY_SYS_MODULES (1) -#endif - -// 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 - -// Whether to provide "sys.exit" function -#ifndef MICROPY_PY_SYS_EXIT -#define MICROPY_PY_SYS_EXIT (1) -#endif - -// Whether to provide "sys.getsizeof" function -#ifndef MICROPY_PY_SYS_GETSIZEOF -#define MICROPY_PY_SYS_GETSIZEOF (0) -#endif - -// Whether to provide sys.{stdin,stdout,stderr} objects -#ifndef MICROPY_PY_SYS_STDFILES -#define MICROPY_PY_SYS_STDFILES (0) -#endif - -// 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 - -// Whether to provide "uerrno" module -#ifndef MICROPY_PY_UERRNO -#define MICROPY_PY_UERRNO (0) -#endif - -// Whether to provide the uerrno.errorcode dict -#ifndef MICROPY_PY_UERRNO_ERRORCODE -#define MICROPY_PY_UERRNO_ERRORCODE (1) -#endif - -// Whether to provide "uselect" module (baremetal implementation) -#ifndef MICROPY_PY_USELECT -#define MICROPY_PY_USELECT (0) -#endif - -// 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 - -// 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 - -// Whether to provide "_thread" module -#ifndef MICROPY_PY_THREAD -#define MICROPY_PY_THREAD (0) -#endif - -// 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 - -// 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 - -// Extended modules - -#ifndef MICROPY_PY_UCTYPES -#define MICROPY_PY_UCTYPES (0) -#endif - -#ifndef MICROPY_PY_UZLIB -#define MICROPY_PY_UZLIB (0) -#endif - -#ifndef MICROPY_PY_UJSON -#define MICROPY_PY_UJSON (0) -#endif - -#ifndef MICROPY_PY_URE -#define MICROPY_PY_URE (0) -#endif - -#ifndef MICROPY_PY_UHEAPQ -#define MICROPY_PY_UHEAPQ (0) -#endif - -// Optimized heap queue for relative timestamps -#ifndef MICROPY_PY_UTIMEQ -#define MICROPY_PY_UTIMEQ (0) -#endif - -#ifndef MICROPY_PY_UHASHLIB -#define MICROPY_PY_UHASHLIB (0) -#endif - -#ifndef MICROPY_PY_UBINASCII -#define MICROPY_PY_UBINASCII (0) -#endif - -// Depends on MICROPY_PY_UZLIB -#ifndef MICROPY_PY_UBINASCII_CRC32 -#define MICROPY_PY_UBINASCII_CRC32 (0) -#endif - -#ifndef MICROPY_PY_URANDOM -#define MICROPY_PY_URANDOM (0) -#endif - -// Whether to include: randrange, randint, choice, random, uniform -#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) -#endif - -#ifndef MICROPY_PY_MACHINE -#define MICROPY_PY_MACHINE (0) -#endif - -// Whether to include: time_pulse_us -#ifndef MICROPY_PY_MACHINE_PULSE -#define MICROPY_PY_MACHINE_PULSE (0) -#endif - -#ifndef MICROPY_PY_MACHINE_I2C -#define MICROPY_PY_MACHINE_I2C (0) -#endif - -#ifndef MICROPY_PY_MACHINE_SPI -#define MICROPY_PY_MACHINE_SPI (0) -#endif - -#ifndef MICROPY_PY_USSL -#define MICROPY_PY_USSL (0) -#endif - -#ifndef MICROPY_PY_WEBSOCKET -#define MICROPY_PY_WEBSOCKET (0) -#endif - -#ifndef MICROPY_PY_FRAMEBUF -#define MICROPY_PY_FRAMEBUF (0) -#endif - -#ifndef MICROPY_PY_BTREE -#define MICROPY_PY_BTREE (0) -#endif - -/*****************************************************************************/ -/* Hooks for a port to add builtins */ - -// Additional builtin function definitions - see builtintables.c:builtin_object_table for format. -#ifndef MICROPY_PORT_BUILTINS -#define MICROPY_PORT_BUILTINS -#endif - -// Additional builtin module definitions - see builtintables.c:builtin_module_table for format. -#ifndef MICROPY_PORT_BUILTIN_MODULES -#define MICROPY_PORT_BUILTIN_MODULES -#endif - -// Any module weak links - see builtintables.c:mp_builtin_module_weak_links_table. -#ifndef MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS -#endif - -// Additional constant definitions for the compiler - see compile.c:mp_constants_table. -#ifndef MICROPY_PORT_CONSTANTS -#define MICROPY_PORT_CONSTANTS -#endif - -// Any root pointers for GC scanning - see mpstate.c -#ifndef MICROPY_PORT_ROOT_POINTERS -#define MICROPY_PORT_ROOT_POINTERS -#endif - -/*****************************************************************************/ -/* 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 - -// On embedded platforms, these will typically enable/disable irqs. -#ifndef MICROPY_BEGIN_ATOMIC_SECTION -#define MICROPY_BEGIN_ATOMIC_SECTION() (0) -#endif -#ifndef MICROPY_END_ATOMIC_SECTION -#define MICROPY_END_ATOMIC_SECTION(state) (void)(state) -#endif - -// 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 - -// Number of bytes in a word -#ifndef BYTES_PER_WORD -#define BYTES_PER_WORD (sizeof(mp_uint_t)) -#endif - -#define BITS_PER_BYTE (8) -#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD) -// mp_int_t value with most significant bit set -#define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1)) - -// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are -// defined and that they are the opposite of each other. -#if defined(MP_ENDIANNESS_LITTLE) -#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) -#elif defined(MP_ENDIANNESS_BIG) -#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG) -#else - // Endiannes not defined by port so try to autodetect it. - #if defined(__BYTE_ORDER__) - #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define MP_ENDIANNESS_LITTLE (1) - #else - #define MP_ENDIANNESS_LITTLE (0) - #endif - #elif defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN) - #define MP_ENDIANNESS_LITTLE (1) - #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined (_BIG_ENDIAN) - #define MP_ENDIANNESS_LITTLE (0) - #else - #include - #if defined(__BYTE_ORDER) - #if __BYTE_ORDER == __LITTLE_ENDIAN - #define MP_ENDIANNESS_LITTLE (1) - #else - #define MP_ENDIANNESS_LITTLE (0) - #endif - #else - #error endianness not defined and cannot detect it - #endif - #endif - #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) -#endif - -// 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 - -// 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 - -#ifndef MP_PLAT_FREE_EXEC -#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size) -#endif - -// 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 - -#ifndef MP_SSIZE_MAX -#define MP_SSIZE_MAX SSIZE_MAX -#endif - -// printf format spec to use for mp_int_t and friends -#ifndef INT_FMT -#if defined(__LP64__) -// Archs where mp_int_t == long, long != int -#define UINT_FMT "%lu" -#define INT_FMT "%ld" -#elif defined(_WIN64) -#define UINT_FMT "%llu" -#define INT_FMT "%lld" -#else -// Archs where mp_int_t == int -#define UINT_FMT "%u" -#define INT_FMT "%d" -#endif -#endif //INT_FMT - -// Modifier for function which doesn't return -#ifndef NORETURN -#define NORETURN __attribute__((noreturn)) -#endif - -// Modifier for weak functions -#ifndef MP_WEAK -#define MP_WEAK __attribute__((weak)) -#endif - -// Modifier for functions which should be never inlined -#ifndef MP_NOINLINE -#define MP_NOINLINE __attribute__((noinline)) -#endif - -// Modifier for functions which should be always inlined -#ifndef MP_ALWAYSINLINE -#define MP_ALWAYSINLINE __attribute__((always_inline)) -#endif - -// Condition is likely to be true, to help branch prediction -#ifndef MP_LIKELY -#define MP_LIKELY(x) __builtin_expect((x), 1) -#endif - -// Condition is likely to be false, to help branch prediction -#ifndef MP_UNLIKELY -#define MP_UNLIKELY(x) __builtin_expect((x), 0) -#endif - -#endif // MICROPY_INCLUDED_PY_MPCONFIG_H diff --git a/user/mpy/py/mperrno.h b/user/mpy/py/mperrno.h deleted file mode 100644 index f439f65..0000000 --- a/user/mpy/py/mperrno.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_MPERRNO_H -#define MICROPY_INCLUDED_PY_MPERRNO_H - -#include "py/mpconfig.h" - -#if MICROPY_USE_INTERNAL_ERRNO - -// MP_Exxx errno's are defined directly as numeric values -// (Linux constants are used as a reference) - -#define MP_EPERM (1) // Operation not permitted -#define MP_ENOENT (2) // No such file or directory -#define MP_ESRCH (3) // No such process -#define MP_EINTR (4) // Interrupted system call -#define MP_EIO (5) // I/O error -#define MP_ENXIO (6) // No such device or address -#define MP_E2BIG (7) // Argument list too long -#define MP_ENOEXEC (8) // Exec format error -#define MP_EBADF (9) // Bad file number -#define MP_ECHILD (10) // No child processes -#define MP_EAGAIN (11) // Try again -#define MP_ENOMEM (12) // Out of memory -#define MP_EACCES (13) // Permission denied -#define MP_EFAULT (14) // Bad address -#define MP_ENOTBLK (15) // Block device required -#define MP_EBUSY (16) // Device or resource busy -#define MP_EEXIST (17) // File exists -#define MP_EXDEV (18) // Cross-device link -#define MP_ENODEV (19) // No such device -#define MP_ENOTDIR (20) // Not a directory -#define MP_EISDIR (21) // Is a directory -#define MP_EINVAL (22) // Invalid argument -#define MP_ENFILE (23) // File table overflow -#define MP_EMFILE (24) // Too many open files -#define MP_ENOTTY (25) // Not a typewriter -#define MP_ETXTBSY (26) // Text file busy -#define MP_EFBIG (27) // File too large -#define MP_ENOSPC (28) // No space left on device -#define MP_ESPIPE (29) // Illegal seek -#define MP_EROFS (30) // Read-only file system -#define MP_EMLINK (31) // Too many links -#define MP_EPIPE (32) // Broken pipe -#define MP_EDOM (33) // Math argument out of domain of func -#define MP_ERANGE (34) // Math result not representable -#define MP_EWOULDBLOCK MP_EAGAIN // Operation would block -#define MP_EOPNOTSUPP (95) // Operation not supported on transport endpoint -#define MP_EAFNOSUPPORT (97) // Address family not supported by protocol -#define MP_EADDRINUSE (98) // Address already in use -#define MP_ECONNABORTED (103) // Software caused connection abort -#define MP_ECONNRESET (104) // Connection reset by peer -#define MP_ENOBUFS (105) // No buffer space available -#define MP_EISCONN (106) // Transport endpoint is already connected -#define MP_ENOTCONN (107) // Transport endpoint is not connected -#define MP_ETIMEDOUT (110) // Connection timed out -#define MP_ECONNREFUSED (111) // Connection refused -#define MP_EHOSTUNREACH (113) // No route to host -#define MP_EALREADY (114) // Operation already in progress -#define MP_EINPROGRESS (115) // Operation now in progress - -#else - -// MP_Exxx errno's are defined in terms of system supplied ones - -#include - -#define MP_EPERM EPERM -#define MP_ENOENT ENOENT -#define MP_ESRCH ESRCH -#define MP_EINTR EINTR -#define MP_EIO EIO -#define MP_ENXIO ENXIO -#define MP_E2BIG E2BIG -#define MP_ENOEXEC ENOEXEC -#define MP_EBADF EBADF -#define MP_ECHILD ECHILD -#define MP_EAGAIN EAGAIN -#define MP_ENOMEM ENOMEM -#define MP_EACCES EACCES -#define MP_EFAULT EFAULT -#define MP_ENOTBLK ENOTBLK -#define MP_EBUSY EBUSY -#define MP_EEXIST EEXIST -#define MP_EXDEV EXDEV -#define MP_ENODEV ENODEV -#define MP_ENOTDIR ENOTDIR -#define MP_EISDIR EISDIR -#define MP_EINVAL EINVAL -#define MP_ENFILE ENFILE -#define MP_EMFILE EMFILE -#define MP_ENOTTY ENOTTY -#define MP_ETXTBSY ETXTBSY -#define MP_EFBIG EFBIG -#define MP_ENOSPC ENOSPC -#define MP_ESPIPE ESPIPE -#define MP_EROFS EROFS -#define MP_EMLINK EMLINK -#define MP_EPIPE EPIPE -#define MP_EDOM EDOM -#define MP_ERANGE ERANGE -#define MP_EWOULDBLOCK EAGAIN -#define MP_EOPNOTSUPP EOPNOTSUPP -#define MP_EAFNOSUPPORT EAFNOSUPPORT -#define MP_EADDRINUSE EADDRINUSE -#define MP_ECONNABORTED ECONNABORTED -#define MP_ECONNRESET ECONNRESET -#define MP_ENOBUFS ENOBUFS -#define MP_EISCONN EISCONN -#define MP_ENOTCONN ENOTCONN -#define MP_ETIMEDOUT ETIMEDOUT -#define MP_ECONNREFUSED ECONNREFUSED -#define MP_EHOSTUNREACH EHOSTUNREACH -#define MP_EALREADY EALREADY -#define MP_EINPROGRESS EINPROGRESS - -#endif - -#if MICROPY_PY_UERRNO - -#include "py/obj.h" - -qstr mp_errno_to_str(mp_obj_t errno_val); - -#endif - -#endif // MICROPY_INCLUDED_PY_MPERRNO_H diff --git a/user/mpy/py/mphal.h b/user/mpy/py/mphal.h deleted file mode 100644 index 92de01d..0000000 --- a/user/mpy/py/mphal.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 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_MPHAL_H -#define MICROPY_INCLUDED_PY_MPHAL_H - -#include "py/mpconfig.h" - -#ifdef MICROPY_MPHALPORT_H -#include MICROPY_MPHALPORT_H -#else -#include -#endif - -#ifndef mp_hal_stdin_rx_chr -int mp_hal_stdin_rx_chr(void); -#endif - -#ifndef mp_hal_stdout_tx_str -void mp_hal_stdout_tx_str(const char *str); -#endif - -#ifndef mp_hal_stdout_tx_strn -void mp_hal_stdout_tx_strn(const char *str, size_t len); -#endif - -#ifndef mp_hal_stdout_tx_strn_cooked -void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len); -#endif - -#ifndef mp_hal_delay_ms -void mp_hal_delay_ms(mp_uint_t ms); -#endif - -#ifndef mp_hal_delay_us -void mp_hal_delay_us(mp_uint_t us); -#endif - -#ifndef mp_hal_ticks_ms -mp_uint_t mp_hal_ticks_ms(void); -#endif - -#ifndef mp_hal_ticks_us -mp_uint_t mp_hal_ticks_us(void); -#endif - -#ifndef mp_hal_ticks_cpu -mp_uint_t mp_hal_ticks_cpu(void); -#endif - -// If port HAL didn't define its own pin API, use generic -// "virtual pin" API from the core. -#ifndef mp_hal_pin_obj_t -#define mp_hal_pin_obj_t mp_obj_t -#define mp_hal_get_pin_obj(pin) (pin) -#define mp_hal_pin_read(pin) mp_virtual_pin_read(pin) -#define mp_hal_pin_write(pin, v) mp_virtual_pin_write(pin, v) -#include "extmod/virtpin.h" -#endif - -#endif // MICROPY_INCLUDED_PY_MPHAL_H diff --git a/user/mpy/py/mpprint.c b/user/mpy/py/mpprint.c deleted file mode 100644 index 6c02d7c..0000000 --- a/user/mpy/py/mpprint.c +++ /dev/null @@ -1,555 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2015 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. - */ - -#include -#include -#include -#include -#include - -#include "py/mphal.h" -#include "py/mpprint.h" -#include "py/obj.h" -#include "py/objint.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include "py/formatfloat.h" -#endif - -static const char pad_spaces[] = " "; -static const char pad_zeroes[] = "0000000000000000"; - -STATIC void plat_print_strn(void *env, const char *str, size_t len) { - (void)env; - MP_PLAT_PRINT_STRN(str, len); -} - -const mp_print_t mp_plat_print = {NULL, plat_print_strn}; - -int mp_print_str(const mp_print_t *print, const char *str) { - size_t len = strlen(str); - if (len) { - print->print_strn(print->data, str, len); - } - return len; -} - -int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) { - int left_pad = 0; - int right_pad = 0; - int pad = width - len; - int pad_size; - int total_chars_printed = 0; - const char *pad_chars; - - if (!fill || fill == ' ') { - pad_chars = pad_spaces; - pad_size = sizeof(pad_spaces) - 1; - } else if (fill == '0') { - pad_chars = pad_zeroes; - pad_size = sizeof(pad_zeroes) - 1; - } else { - // Other pad characters are fairly unusual, so we'll take the hit - // and output them 1 at a time. - pad_chars = &fill; - pad_size = 1; - } - - if (flags & PF_FLAG_CENTER_ADJUST) { - left_pad = pad / 2; - right_pad = pad - left_pad; - } else if (flags & PF_FLAG_LEFT_ADJUST) { - right_pad = pad; - } else { - left_pad = pad; - } - - if (left_pad > 0) { - total_chars_printed += left_pad; - while (left_pad > 0) { - int p = left_pad; - if (p > pad_size) { - p = pad_size; - } - print->print_strn(print->data, pad_chars, p); - left_pad -= p; - } - } - if (len) { - print->print_strn(print->data, str, len); - total_chars_printed += len; - } - if (right_pad > 0) { - total_chars_printed += right_pad; - while (right_pad > 0) { - int p = right_pad; - if (p > pad_size) { - p = pad_size; - } - print->print_strn(print->data, pad_chars, p); - right_pad -= p; - } - } - return total_chars_printed; -} - -// 32-bits is 10 digits, add 3 for commas, 1 for sign, 1 for terminating null -// We can use 16 characters for 32-bit and 32 characters for 64-bit -#define INT_BUF_SIZE (sizeof(mp_int_t) * 4) - -// Our mp_vprintf function below does not support the '#' format modifier to -// print the prefix of a non-base-10 number, so we don't need code for this. -#define SUPPORT_INT_BASE_PREFIX (0) - -// This function is used exclusively by mp_vprintf to format ints. -// It needs to be a separate function to mp_print_mp_int, since converting to a mp_int looses the MSB. -STATIC int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) { - char sign = 0; - if (sgn) { - if ((mp_int_t)x < 0) { - sign = '-'; - x = -x; - } else if (flags & PF_FLAG_SHOW_SIGN) { - sign = '+'; - } else if (flags & PF_FLAG_SPACE_SIGN) { - sign = ' '; - } - } - - char buf[INT_BUF_SIZE]; - char *b = buf + INT_BUF_SIZE; - - if (x == 0) { - *(--b) = '0'; - } else { - do { - int c = x % base; - x /= base; - if (c >= 10) { - c += base_char - 10; - } else { - c += '0'; - } - *(--b) = c; - } while (b > buf && x != 0); - } - - #if SUPPORT_INT_BASE_PREFIX - char prefix_char = '\0'; - - if (flags & PF_FLAG_SHOW_PREFIX) { - if (base == 2) { - prefix_char = base_char + 'b' - 'a'; - } else if (base == 8) { - prefix_char = base_char + 'o' - 'a'; - } else if (base == 16) { - prefix_char = base_char + 'x' - 'a'; - } - } - #endif - - int len = 0; - if (flags & PF_FLAG_PAD_AFTER_SIGN) { - if (sign) { - len += mp_print_strn(print, &sign, 1, flags, fill, 1); - width--; - } - #if SUPPORT_INT_BASE_PREFIX - if (prefix_char) { - len += mp_print_strn(print, "0", 1, flags, fill, 1); - len += mp_print_strn(print, &prefix_char, 1, flags, fill, 1); - width -= 2; - } - #endif - } else { - #if SUPPORT_INT_BASE_PREFIX - if (prefix_char && b > &buf[1]) { - *(--b) = prefix_char; - *(--b) = '0'; - } - #endif - if (sign && b > buf) { - *(--b) = sign; - } - } - - len += mp_print_strn(print, b, buf + INT_BUF_SIZE - b, flags, fill, width); - return len; -} - -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) { - // These are the only values for "base" that are required to be supported by this - // function, since Python only allows the user to format integers in these bases. - // If needed this function could be generalised to handle other values. - assert(base == 2 || base == 8 || base == 10 || base == 16); - - if (!MP_OBJ_IS_INT(x)) { - // This will convert booleans to int, or raise an error for - // non-integer types. - x = MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(x)); - } - - if ((flags & (PF_FLAG_LEFT_ADJUST | PF_FLAG_CENTER_ADJUST)) == 0 && fill == '0') { - if (prec > width) { - width = prec; - } - prec = 0; - } - char prefix_buf[4]; - char *prefix = prefix_buf; - - if (mp_obj_int_sign(x) >= 0) { - if (flags & PF_FLAG_SHOW_SIGN) { - *prefix++ = '+'; - } else if (flags & PF_FLAG_SPACE_SIGN) { - *prefix++ = ' '; - } - } - - if (flags & PF_FLAG_SHOW_PREFIX) { - if (base == 2) { - *prefix++ = '0'; - *prefix++ = base_char + 'b' - 'a'; - } else if (base == 8) { - *prefix++ = '0'; - if (flags & PF_FLAG_SHOW_OCTAL_LETTER) { - *prefix++ = base_char + 'o' - 'a'; - } - } else if (base == 16) { - *prefix++ = '0'; - *prefix++ = base_char + 'x' - 'a'; - } - } - *prefix = '\0'; - int prefix_len = prefix - prefix_buf; - prefix = prefix_buf; - - char comma = '\0'; - if (flags & PF_FLAG_SHOW_COMMA) { - comma = ','; - } - - // The size of this buffer is rather arbitrary. If it's not large - // enough, a dynamic one will be allocated. - char stack_buf[sizeof(mp_int_t) * 4]; - char *buf = stack_buf; - size_t buf_size = sizeof(stack_buf); - size_t fmt_size = 0; - char *str; - - if (prec > 1) { - flags |= PF_FLAG_PAD_AFTER_SIGN; - } - char sign = '\0'; - if (flags & PF_FLAG_PAD_AFTER_SIGN) { - // We add the pad in this function, so since the pad goes after - // the sign & prefix, we format without a prefix - str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, - x, base, NULL, base_char, comma); - if (*str == '-') { - sign = *str++; - fmt_size--; - } - } else { - str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, - x, base, prefix, base_char, comma); - } - - int spaces_before = 0; - int spaces_after = 0; - - if (prec > 1) { - // If prec was specified, then prec specifies the width to zero-pad the - // the number to. This zero-padded number then gets left or right - // aligned in width characters. - - int prec_width = fmt_size; // The digits - if (prec_width < prec) { - prec_width = prec; - } - if (flags & PF_FLAG_PAD_AFTER_SIGN) { - if (sign) { - prec_width++; - } - prec_width += prefix_len; - } - if (prec_width < width) { - if (flags & PF_FLAG_LEFT_ADJUST) { - spaces_after = width - prec_width; - } else { - spaces_before = width - prec_width; - } - } - fill = '0'; - flags &= ~PF_FLAG_LEFT_ADJUST; - } - - int len = 0; - if (spaces_before) { - len += mp_print_strn(print, "", 0, 0, ' ', spaces_before); - } - if (flags & PF_FLAG_PAD_AFTER_SIGN) { - // pad after sign implies pad after prefix as well. - if (sign) { - len += mp_print_strn(print, &sign, 1, 0, 0, 1); - width--; - } - if (prefix_len) { - len += mp_print_strn(print, prefix, prefix_len, 0, 0, 1); - width -= prefix_len; - } - } - if (prec > 1) { - width = prec; - } - - len += mp_print_strn(print, str, fmt_size, flags, fill, width); - - if (spaces_after) { - len += mp_print_strn(print, "", 0, 0, ' ', spaces_after); - } - - if (buf != stack_buf) { - m_del(char, buf, buf_size); - } - return len; -} - -#if MICROPY_PY_BUILTINS_FLOAT -int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec) { - char buf[32]; - char sign = '\0'; - int chrs = 0; - - if (flags & PF_FLAG_SHOW_SIGN) { - sign = '+'; - } - else - if (flags & PF_FLAG_SPACE_SIGN) { - sign = ' '; - } - - int len = mp_format_float(f, buf, sizeof(buf), fmt, prec, sign); - - char *s = buf; - - if ((flags & PF_FLAG_ADD_PERCENT) && (size_t)(len + 1) < sizeof(buf)) { - buf[len++] = '%'; - buf[len] = '\0'; - } - - // buf[0] < '0' returns true if the first character is space, + or - - if ((flags & PF_FLAG_PAD_AFTER_SIGN) && buf[0] < '0') { - // We have a sign character - s++; - chrs += mp_print_strn(print, &buf[0], 1, 0, 0, 1); - width--; - len--; - } - - chrs += mp_print_strn(print, s, len, flags, fill, width); - - return chrs; -} -#endif - -int mp_printf(const mp_print_t *print, const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - int ret = mp_vprintf(print, fmt, ap); - va_end(ap); - return ret; -} - -int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) { - int chrs = 0; - for (;;) { - { - const char *f = fmt; - while (*f != '\0' && *f != '%') { - ++f; // XXX UTF8 advance char - } - if (f > fmt) { - print->print_strn(print->data, fmt, f - fmt); - chrs += f - fmt; - fmt = f; - } - } - - if (*fmt == '\0') { - break; - } - - // move past % character - ++fmt; - - // parse flags, if they exist - int flags = 0; - char fill = ' '; - while (*fmt != '\0') { - if (*fmt == '-') flags |= PF_FLAG_LEFT_ADJUST; - else if (*fmt == '+') flags |= PF_FLAG_SHOW_SIGN; - else if (*fmt == ' ') flags |= PF_FLAG_SPACE_SIGN; - else if (*fmt == '!') flags |= PF_FLAG_NO_TRAILZ; - else if (*fmt == '0') { - flags |= PF_FLAG_PAD_AFTER_SIGN; - fill = '0'; - } else break; - ++fmt; - } - - // parse width, if it exists - int width = 0; - for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { - width = width * 10 + *fmt - '0'; - } - - // parse precision, if it exists - int prec = -1; - if (*fmt == '.') { - ++fmt; - if (*fmt == '*') { - ++fmt; - prec = va_arg(args, int); - } else { - prec = 0; - for (; '0' <= *fmt && *fmt <= '9'; ++fmt) { - prec = prec * 10 + *fmt - '0'; - } - } - if (prec < 0) { - prec = 0; - } - } - - // parse long specifiers (current not used) - //bool long_arg = false; - if (*fmt == 'l') { - ++fmt; - //long_arg = true; - } - - if (*fmt == '\0') { - break; - } - - switch (*fmt) { - case 'b': - if (va_arg(args, int)) { - chrs += mp_print_strn(print, "true", 4, flags, fill, width); - } else { - chrs += mp_print_strn(print, "false", 5, flags, fill, width); - } - break; - case 'c': - { - char str = va_arg(args, int); - chrs += mp_print_strn(print, &str, 1, flags, fill, width); - break; - } - case 'q': - { - qstr qst = va_arg(args, qstr); - size_t len; - const char *str = (const char*)qstr_data(qst, &len); - if (prec < 0) { - prec = len; - } - chrs += mp_print_strn(print, str, prec, flags, fill, width); - break; - } - case 's': - { - const char *str = va_arg(args, const char*); - if (str) { - if (prec < 0) { - prec = strlen(str); - } - chrs += mp_print_strn(print, str, prec, flags, fill, width); - } else { - chrs += mp_print_strn(print, "(null)", 6, flags, fill, width); - } - break; - } - case 'u': - chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 10, 'a', flags, fill, width); - break; - case 'd': - chrs += mp_print_int(print, va_arg(args, int), 1, 10, 'a', flags, fill, width); - break; - case 'x': - chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 16, 'a', flags, fill, width); - break; - case 'X': - chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 16, 'A', flags, fill, width); - break; - case 'p': - case 'P': // don't bother to handle upcase for 'P' - chrs += mp_print_int(print, va_arg(args, unsigned int), 0, 16, 'a', flags, fill, width); - break; -#if MICROPY_PY_BUILTINS_FLOAT - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - { -#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE)) - mp_float_t f = va_arg(args, double); - chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec); -#else -#error Unknown MICROPY FLOAT IMPL -#endif - break; - } -#endif - // Because 'l' is eaten above, another 'l' means %ll. We need to support - // this length specifier for OBJ_REPR_D (64-bit NaN boxing). - // TODO Either enable this unconditionally, or provide a specific config var. - #if (MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D) || defined(_WIN64) - case 'l': { - unsigned long long int arg_value = va_arg(args, unsigned long long int); - ++fmt; - if (*fmt == 'u' || *fmt == 'd') { - chrs += mp_print_int(print, arg_value, *fmt == 'd', 10, 'a', flags, fill, width); - break; - } - assert(!"unsupported fmt char"); - } - #endif - default: - // if it's not %% then it's an unsupported format character - assert(*fmt == '%' || !"unsupported fmt char"); - print->print_strn(print->data, fmt, 1); - chrs += 1; - break; - } - ++fmt; - } - return chrs; -} diff --git a/user/mpy/py/mpprint.h b/user/mpy/py/mpprint.h deleted file mode 100644 index 07462bd..0000000 --- a/user/mpy/py/mpprint.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 - -#include "py/mpconfig.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 MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES -# define MP_PYTHON_PRINTER &mp_sys_stdout_print -#else -# define MP_PYTHON_PRINTER &mp_plat_print -#endif - -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; - -// 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 MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES -// 2) Wrapper for printing to sys.stdout. -extern const mp_print_t mp_sys_stdout_print; -#endif - -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 MICROPY_PY_BUILTINS_FLOAT -int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec); -#endif - -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 - -#endif // MICROPY_INCLUDED_PY_MPPRINT_H diff --git a/user/mpy/py/mpstate.c b/user/mpy/py/mpstate.c deleted file mode 100644 index 6ce64ad..0000000 --- a/user/mpy/py/mpstate.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -#include "py/mpstate.h" - -#if MICROPY_DYNAMIC_COMPILER -mp_dynamic_compiler_t mp_dynamic_compiler = {0}; -#endif - -mp_state_ctx_t mp_state_ctx; diff --git a/user/mpy/py/mpstate.h b/user/mpy/py/mpstate.h deleted file mode 100644 index eca14a9..0000000 --- a/user/mpy/py/mpstate.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * 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 - -#include - -#include "py/mpconfig.h" -#include "py/mpthread.h" -#include "py/misc.h" -#include "py/nlr.h" -#include "py/obj.h" -#include "py/objlist.h" -#include "py/objexcept.h" - -// 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 MICROPY_DYNAMIC_COMPILER -typedef struct mp_dynamic_compiler_t { - uint8_t small_int_bits; // must be <= host small_int_bits - bool opt_cache_map_lookup_in_bytecode; - bool py_builtins_str_unicode; -} mp_dynamic_compiler_t; -extern mp_dynamic_compiler_t mp_dynamic_compiler; -#endif - -// 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 MICROPY_MEM_STATS - size_t total_bytes_allocated; - size_t current_bytes_allocated; - size_t peak_bytes_allocated; - #endif - - byte *gc_alloc_table_start; - size_t gc_alloc_table_byte_len; - #if MICROPY_ENABLE_FINALISER - byte *gc_finaliser_table_start; - #endif - byte *gc_pool_start; - byte *gc_pool_end; - - int gc_stack_overflow; - size_t gc_stack[MICROPY_ALLOC_GC_STACK_SIZE]; - size_t *gc_sp; - uint16_t gc_lock_depth; - - // 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 MICROPY_GC_ALLOC_THRESHOLD - size_t gc_alloc_amount; - size_t gc_alloc_threshold; - #endif - - size_t gc_last_free_atb_index; - - #if MICROPY_PY_GC_COLLECT_RETVAL - size_t gc_collected; - #endif - - #if MICROPY_PY_THREAD - // This is a global mutex used to make the GC thread-safe. - mp_thread_mutex_t gc_mutex; - #endif -} 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 { - //////////////////////////////////////////////////////////// - // START ROOT POINTER SECTION - // everything that needs GC scanning must go here - // this must start at the start of this structure - // - - 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 MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - #if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0 - // 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 - // dynamically allocated buf - byte *mp_emergency_exception_buf; - #endif - #endif - - #if MICROPY_KBD_EXCEPTION - // exception object of type KeyboardInterrupt - mp_obj_exception_t mp_kbd_exception; - #endif - - // dictionary with loaded modules (may be exposed as sys.modules) - mp_obj_dict_t mp_loaded_modules_dict; - - // pending exception object (MP_OBJ_NULL if not pending) - volatile mp_obj_t mp_pending_exception; - - #if MICROPY_ENABLE_SCHEDULER - volatile int16_t sched_state; - uint16_t sched_sp; - mp_sched_item_t sched_stack[MICROPY_SCHEDULER_DEPTH]; - #endif - - // current exception being handled, for sys.exc_info() - #if MICROPY_PY_SYS_EXC_INFO - mp_obj_base_t *cur_exception; - #endif - - // 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 MICROPY_CAN_OVERRIDE_BUILTINS - mp_obj_dict_t *mp_module_builtins_override_dict; - #endif - - // include any root pointers defined by a port - MICROPY_PORT_ROOT_POINTERS - - // root pointers for extmod - - #if MICROPY_PY_OS_DUPTERM - mp_obj_t term_obj; - mp_obj_t dupterm_arr_obj; - #endif - - #if MICROPY_PY_LWIP_SLIP - mp_obj_t lwip_slip_stream; - #endif - - #if MICROPY_VFS - struct _mp_vfs_mount_t *vfs_cur; - struct _mp_vfs_mount_t *vfs_mount_table; - #endif - - // - // 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 MICROPY_PY_THREAD - // This is a global mutex used to make qstr interning thread-safe. - mp_thread_mutex_t qstr_mutex; - #endif - - mp_uint_t mp_optimise_value; - - // size of the emergency exception buf, if it's dynamically allocated - #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0 - mp_int_t mp_emergency_exception_buf_size; - #endif - - #if MICROPY_PY_THREAD_GIL - // This is a global mutex used to make the VM/runtime thread-safe. - mp_thread_mutex_t gil_mutex; - #endif -} 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 { - mp_obj_dict_t *dict_locals; - mp_obj_dict_t *dict_globals; - - // Note: nlr asm code has the offset of this hard-coded - nlr_buf_t *nlr_top; // ROOT POINTER - - // Stack top at the start of program - char *stack_top; - - #if MICROPY_STACK_CHECK - size_t stack_limit; - #endif -} 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. -// Note: if this structure changes then revisit all nlr asm code since they -// have the offset of nlr_top hard-coded. -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) - -#if MICROPY_PY_THREAD -extern mp_state_thread_t *mp_thread_get_state(void); -#define MP_STATE_THREAD(x) (mp_thread_get_state()->x) -#else -#define MP_STATE_THREAD(x) (mp_state_ctx.thread.x) -#endif - -#endif // MICROPY_INCLUDED_PY_MPSTATE_H diff --git a/user/mpy/py/mpthread.h b/user/mpy/py/mpthread.h deleted file mode 100644 index 602df83..0000000 --- a/user/mpy/py/mpthread.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 - -#include "py/mpconfig.h" - -#if MICROPY_PY_THREAD - -#ifdef MICROPY_MPTHREADPORT_H -#include MICROPY_MPTHREADPORT_H -#else -#include -#endif - -struct _mp_state_thread_t; - -struct _mp_state_thread_t *mp_thread_get_state(void); -void mp_thread_set_state(void *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 - -#if MICROPY_PY_THREAD && MICROPY_PY_THREAD_GIL -#include "py/mpstate.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 -#define MP_THREAD_GIL_ENTER() -#define MP_THREAD_GIL_EXIT() -#endif - -#endif // MICROPY_INCLUDED_PY_MPTHREAD_H diff --git a/user/mpy/py/mpz.c b/user/mpy/py/mpz.c deleted file mode 100644 index d300a8e..0000000 --- a/user/mpy/py/mpz.c +++ /dev/null @@ -1,1766 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/mpz.h" - -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ - -#define DIG_SIZE (MPZ_DIG_SIZE) -#define DIG_MASK ((MPZ_LONG_1 << DIG_SIZE) - 1) -#define DIG_MSB (MPZ_LONG_1 << (DIG_SIZE - 1)) -#define DIG_BASE (MPZ_LONG_1 << DIG_SIZE) - -/* - mpz is an arbitrary precision integer type with a public API. - - mpn functions act on non-negative integers represented by an array of generalised - digits (eg a word per digit). You also need to specify separately the length of the - array. There is no public API for mpn. Rather, the functions are used by mpz to - implement its features. - - Integer values are stored little endian (first digit is first in memory). - - Definition of normalise: ? -*/ - -STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) { - for (--idig; idig >= oidig && *idig == 0; --idig) { - } - return idig + 1 - oidig; -} - -/* compares i with j - returns sign(i - j) - assumes i, j are normalised -*/ -STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) { - if (ilen < jlen) { return -1; } - if (ilen > jlen) { return 1; } - - for (idig += ilen, jdig += ilen; ilen > 0; --ilen) { - mpz_dbl_dig_signed_t cmp = (mpz_dbl_dig_t)*(--idig) - (mpz_dbl_dig_t)*(--jdig); - if (cmp < 0) { return -1; } - if (cmp > 0) { return 1; } - } - - return 0; -} - -/* computes i = j << n - returns number of digits in i - assumes enough memory in i; assumes normalised j; assumes n > 0 - can have i, j pointing to same memory -*/ -STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) { - mp_uint_t n_whole = (n + DIG_SIZE - 1) / DIG_SIZE; - mp_uint_t n_part = n % DIG_SIZE; - if (n_part == 0) { - n_part = DIG_SIZE; - } - - // start from the high end of the digit arrays - idig += jlen + n_whole - 1; - jdig += jlen - 1; - - // shift the digits - mpz_dbl_dig_t d = 0; - for (size_t i = jlen; i > 0; i--, idig--, jdig--) { - d |= *jdig; - *idig = (d >> (DIG_SIZE - n_part)) & DIG_MASK; - d <<= DIG_SIZE; - } - - // store remaining bits - *idig = (d >> (DIG_SIZE - n_part)) & DIG_MASK; - idig -= n_whole - 1; - memset(idig, 0, (n_whole - 1) * sizeof(mpz_dig_t)); - - // work out length of result - jlen += n_whole; - while (jlen != 0 && idig[jlen - 1] == 0) { - jlen--; - } - - // return length of result - return jlen; -} - -/* computes i = j >> n - returns number of digits in i - assumes enough memory in i; assumes normalised j; assumes n > 0 - can have i, j pointing to same memory -*/ -STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) { - mp_uint_t n_whole = n / DIG_SIZE; - mp_uint_t n_part = n % DIG_SIZE; - - if (n_whole >= jlen) { - return 0; - } - - jdig += n_whole; - jlen -= n_whole; - - for (size_t i = jlen; i > 0; i--, idig++, jdig++) { - mpz_dbl_dig_t d = *jdig; - if (i > 1) { - d |= (mpz_dbl_dig_t)jdig[1] << DIG_SIZE; - } - d >>= n_part; - *idig = d & DIG_MASK; - } - - if (idig[-1] == 0) { - jlen--; - } - - return jlen; -} - -/* computes i = j + k - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { - mpz_dig_t *oidig = idig; - mpz_dbl_dig_t carry = 0; - - jlen -= klen; - - for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { - carry += (mpz_dbl_dig_t)*jdig + (mpz_dbl_dig_t)*kdig; - *idig = carry & DIG_MASK; - carry >>= DIG_SIZE; - } - - for (; jlen > 0; --jlen, ++idig, ++jdig) { - carry += *jdig; - *idig = carry & DIG_MASK; - carry >>= DIG_SIZE; - } - - if (carry != 0) { - *idig++ = carry; - } - - return idig - oidig; -} - -/* computes i = j - k - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes j >= k - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { - mpz_dig_t *oidig = idig; - mpz_dbl_dig_signed_t borrow = 0; - - jlen -= klen; - - for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { - borrow += (mpz_dbl_dig_t)*jdig - (mpz_dbl_dig_t)*kdig; - *idig = borrow & DIG_MASK; - borrow >>= DIG_SIZE; - } - - for (; jlen > 0; --jlen, ++idig, ++jdig) { - borrow += *jdig; - *idig = borrow & DIG_MASK; - borrow >>= DIG_SIZE; - } - - return mpn_remove_trailing_zeros(oidig, idig); -} - -#if MICROPY_OPT_MPZ_BITWISE - -/* computes i = j & k - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen (jlen argument not needed) - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) { - mpz_dig_t *oidig = idig; - - for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { - *idig = *jdig & *kdig; - } - - return mpn_remove_trailing_zeros(oidig, idig); -} - -#endif - -/* i = -((-j) & (-k)) = ~((~j + 1) & (~k + 1)) + 1 - i = (j & (-k)) = (j & (~k + 1)) = ( j & (~k + 1)) - i = ((-j) & k) = ((~j + 1) & k) = ((~j + 1) & k ) - computes general form: - i = (im ^ (((j ^ jm) + jc) & ((k ^ km) + kc))) + ic where Xm = Xc == 0 ? 0 : DIG_MASK - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes length j >= length k - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, - mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { - mpz_dig_t *oidig = idig; - mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK; - mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK; - mpz_dig_t kmask = (0 == carryk) ? 0 : DIG_MASK; - - for (; jlen > 0; ++idig, ++jdig) { - carryj += *jdig ^ jmask; - carryk += (--klen <= --jlen) ? (*kdig++ ^ kmask) : kmask; - carryi += ((carryj & carryk) ^ imask) & DIG_MASK; - *idig = carryi & DIG_MASK; - carryk >>= DIG_SIZE; - carryj >>= DIG_SIZE; - carryi >>= DIG_SIZE; - } - - if (0 != carryi) { - *idig++ = carryi; - } - - return mpn_remove_trailing_zeros(oidig, idig); -} - -#if MICROPY_OPT_MPZ_BITWISE - -/* computes i = j | k - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { - mpz_dig_t *oidig = idig; - - jlen -= klen; - - for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { - *idig = *jdig | *kdig; - } - - for (; jlen > 0; --jlen, ++idig, ++jdig) { - *idig = *jdig; - } - - return idig - oidig; -} - -#endif - -/* i = -((-j) | (-k)) = ~((~j + 1) | (~k + 1)) + 1 - i = -(j | (-k)) = -(j | (~k + 1)) = ~( j | (~k + 1)) + 1 - i = -((-j) | k) = -((~j + 1) | k) = ~((~j + 1) | k ) + 1 - computes general form: - i = ~(((j ^ jm) + jc) | ((k ^ km) + kc)) + 1 where Xm = Xc == 0 ? 0 : DIG_MASK - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes length j >= length k - can have i, j, k pointing to same memory -*/ - -#if MICROPY_OPT_MPZ_BITWISE - -STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, - mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { - mpz_dig_t *oidig = idig; - mpz_dbl_dig_t carryi = 1; - mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK; - mpz_dig_t kmask = (0 == carryk) ? 0 : DIG_MASK; - - for (; jlen > 0; ++idig, ++jdig) { - carryj += *jdig ^ jmask; - carryk += (--klen <= --jlen) ? (*kdig++ ^ kmask) : kmask; - carryi += ((carryj | carryk) ^ DIG_MASK) & DIG_MASK; - *idig = carryi & DIG_MASK; - carryk >>= DIG_SIZE; - carryj >>= DIG_SIZE; - carryi >>= DIG_SIZE; - } - - // At least one of j,k must be negative so the above for-loop runs at least - // once. For carryi to be non-zero here it must be equal to 1 at the end of - // each iteration of the loop. So the accumulation of carryi must overflow - // each time, ie carryi += 0xff..ff. So carryj|carryk must be 0 in the - // DIG_MASK bits on each iteration. But considering all cases of signs of - // j,k one sees that this is not possible. - assert(carryi == 0); - - return mpn_remove_trailing_zeros(oidig, idig); -} - -#else - -STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, - mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { - mpz_dig_t *oidig = idig; - mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK; - mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK; - mpz_dig_t kmask = (0 == carryk) ? 0 : DIG_MASK; - - for (; jlen > 0; ++idig, ++jdig) { - carryj += *jdig ^ jmask; - carryk += (--klen <= --jlen) ? (*kdig++ ^ kmask) : kmask; - carryi += ((carryj | carryk) ^ imask) & DIG_MASK; - *idig = carryi & DIG_MASK; - carryk >>= DIG_SIZE; - carryj >>= DIG_SIZE; - carryi >>= DIG_SIZE; - } - - // See comment in above mpn_or_neg for why carryi must be 0. - assert(carryi == 0); - - return mpn_remove_trailing_zeros(oidig, idig); -} - -#endif - -#if MICROPY_OPT_MPZ_BITWISE - -/* computes i = j ^ k - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) { - mpz_dig_t *oidig = idig; - - jlen -= klen; - - for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) { - *idig = *jdig ^ *kdig; - } - - for (; jlen > 0; --jlen, ++idig, ++jdig) { - *idig = *jdig; - } - - return mpn_remove_trailing_zeros(oidig, idig); -} - -#endif - -/* i = (-j) ^ (-k) = ~(j - 1) ^ ~(k - 1) = (j - 1) ^ (k - 1) - i = -(j ^ (-k)) = -(j ^ ~(k - 1)) = ~(j ^ ~(k - 1)) + 1 = (j ^ (k - 1)) + 1 - i = -((-j) ^ k) = -(~(j - 1) ^ k) = ~(~(j - 1) ^ k) + 1 = ((j - 1) ^ k) + 1 - computes general form: - i = ((j - 1 + jc) ^ (k - 1 + kc)) + ic - returns number of digits in i - assumes enough memory in i; assumes normalised j, k; assumes length j >= length k - can have i, j, k pointing to same memory -*/ -STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, - mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) { - mpz_dig_t *oidig = idig; - - for (; jlen > 0; ++idig, ++jdig) { - carryj += *jdig + DIG_MASK; - carryk += (--klen <= --jlen) ? (*kdig++ + DIG_MASK) : DIG_MASK; - carryi += (carryj ^ carryk) & DIG_MASK; - *idig = carryi & DIG_MASK; - carryk >>= DIG_SIZE; - carryj >>= DIG_SIZE; - carryi >>= DIG_SIZE; - } - - if (0 != carryi) { - *idig++ = carryi; - } - - return mpn_remove_trailing_zeros(oidig, idig); -} - -/* computes i = i * d1 + d2 - returns number of digits in i - assumes enough memory in i; assumes normalised i; assumes dmul != 0 -*/ -STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) { - mpz_dig_t *oidig = idig; - mpz_dbl_dig_t carry = dadd; - - for (; ilen > 0; --ilen, ++idig) { - carry += (mpz_dbl_dig_t)*idig * (mpz_dbl_dig_t)dmul; // will never overflow so long as DIG_SIZE <= 8*sizeof(mpz_dbl_dig_t)/2 - *idig = carry & DIG_MASK; - carry >>= DIG_SIZE; - } - - if (carry != 0) { - *idig++ = carry; - } - - return idig - oidig; -} - -/* computes i = j * k - returns number of digits in i - assumes enough memory in i; assumes i is zeroed; assumes normalised j, k - can have j, k point to same memory -*/ -STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) { - mpz_dig_t *oidig = idig; - size_t ilen = 0; - - for (; klen > 0; --klen, ++idig, ++kdig) { - mpz_dig_t *id = idig; - mpz_dbl_dig_t carry = 0; - - size_t jl = jlen; - for (mpz_dig_t *jd = jdig; jl > 0; --jl, ++jd, ++id) { - carry += (mpz_dbl_dig_t)*id + (mpz_dbl_dig_t)*jd * (mpz_dbl_dig_t)*kdig; // will never overflow so long as DIG_SIZE <= 8*sizeof(mpz_dbl_dig_t)/2 - *id = carry & DIG_MASK; - carry >>= DIG_SIZE; - } - - if (carry != 0) { - *id++ = carry; - } - - ilen = id - oidig; - } - - return ilen; -} - -/* natural_div - quo * den + new_num = old_num (ie num is replaced with rem) - assumes den != 0 - assumes num_dig has enough memory to be extended by 1 digit - assumes quo_dig has enough memory (as many digits as num) - assumes quo_dig is filled with zeros -*/ -STATIC void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len) { - mpz_dig_t *orig_num_dig = num_dig; - mpz_dig_t *orig_quo_dig = quo_dig; - mpz_dig_t norm_shift = 0; - mpz_dbl_dig_t lead_den_digit; - - // handle simple cases - { - int cmp = mpn_cmp(num_dig, *num_len, den_dig, den_len); - if (cmp == 0) { - *num_len = 0; - quo_dig[0] = 1; - *quo_len = 1; - return; - } else if (cmp < 0) { - // numerator remains the same - *quo_len = 0; - return; - } - } - - // We need to normalise the denominator (leading bit of leading digit is 1) - // so that the division routine works. Since the denominator memory is - // read-only we do the normalisation on the fly, each time a digit of the - // denominator is needed. We need to know is how many bits to shift by. - - // count number of leading zeros in leading digit of denominator - { - mpz_dig_t d = den_dig[den_len - 1]; - while ((d & DIG_MSB) == 0) { - d <<= 1; - ++norm_shift; - } - } - - // now need to shift numerator by same amount as denominator - // first, increase length of numerator in case we need more room to shift - num_dig[*num_len] = 0; - ++(*num_len); - for (mpz_dig_t *num = num_dig, carry = 0; num < num_dig + *num_len; ++num) { - mpz_dig_t n = *num; - *num = ((n << norm_shift) | carry) & DIG_MASK; - carry = (mpz_dbl_dig_t)n >> (DIG_SIZE - norm_shift); - } - - // cache the leading digit of the denominator - lead_den_digit = (mpz_dbl_dig_t)den_dig[den_len - 1] << norm_shift; - if (den_len >= 2) { - lead_den_digit |= (mpz_dbl_dig_t)den_dig[den_len - 2] >> (DIG_SIZE - norm_shift); - } - - // point num_dig to last digit in numerator - num_dig += *num_len - 1; - - // calculate number of digits in quotient - *quo_len = *num_len - den_len; - - // point to last digit to store for quotient - quo_dig += *quo_len - 1; - - // keep going while we have enough digits to divide - while (*num_len > den_len) { - mpz_dbl_dig_t quo = ((mpz_dbl_dig_t)*num_dig << DIG_SIZE) | num_dig[-1]; - - // get approximate quotient - quo /= lead_den_digit; - - // Multiply quo by den and subtract from num to get remainder. - // We have different code here to handle different compile-time - // configurations of mpz: - // - // 1. DIG_SIZE is stricly less than half the number of bits - // available in mpz_dbl_dig_t. In this case we can use a - // slightly more optimal (in time and space) routine that - // uses the extra bits in mpz_dbl_dig_signed_t to store a - // sign bit. - // - // 2. DIG_SIZE is exactly half the number of bits available in - // mpz_dbl_dig_t. In this (common) case we need to be careful - // not to overflow the borrow variable. And the shifting of - // borrow needs some special logic (it's a shift right with - // round up). - - if (DIG_SIZE < 8 * sizeof(mpz_dbl_dig_t) / 2) { - const mpz_dig_t *d = den_dig; - mpz_dbl_dig_t d_norm = 0; - mpz_dbl_dig_signed_t borrow = 0; - - for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { - d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); - borrow += (mpz_dbl_dig_t)*n - (mpz_dbl_dig_t)quo * (d_norm & DIG_MASK); // will overflow if DIG_SIZE >= 8*sizeof(mpz_dbl_dig_t)/2 - *n = borrow & DIG_MASK; - borrow >>= DIG_SIZE; - } - borrow += *num_dig; // will overflow if DIG_SIZE >= 8*sizeof(mpz_dbl_dig_t)/2 - *num_dig = borrow & DIG_MASK; - borrow >>= DIG_SIZE; - - // adjust quotient if it is too big - for (; borrow != 0; --quo) { - d = den_dig; - d_norm = 0; - mpz_dbl_dig_t carry = 0; - for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { - d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); - carry += (mpz_dbl_dig_t)*n + (d_norm & DIG_MASK); - *n = carry & DIG_MASK; - carry >>= DIG_SIZE; - } - carry += *num_dig; - *num_dig = carry & DIG_MASK; - carry >>= DIG_SIZE; - - borrow += carry; - } - } else { // DIG_SIZE == 8 * sizeof(mpz_dbl_dig_t) / 2 - const mpz_dig_t *d = den_dig; - mpz_dbl_dig_t d_norm = 0; - mpz_dbl_dig_t borrow = 0; - - for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { - d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); - mpz_dbl_dig_t x = (mpz_dbl_dig_t)quo * (d_norm & DIG_MASK); - if (x >= *n || *n - x <= borrow) { - borrow += (mpz_dbl_dig_t)x - (mpz_dbl_dig_t)*n; - *n = (-borrow) & DIG_MASK; - borrow = (borrow >> DIG_SIZE) + ((borrow & DIG_MASK) == 0 ? 0 : 1); // shift-right with round-up - } else { - *n = ((mpz_dbl_dig_t)*n - (mpz_dbl_dig_t)x - (mpz_dbl_dig_t)borrow) & DIG_MASK; - borrow = 0; - } - } - if (borrow >= *num_dig) { - borrow -= (mpz_dbl_dig_t)*num_dig; - *num_dig = (-borrow) & DIG_MASK; - borrow = (borrow >> DIG_SIZE) + ((borrow & DIG_MASK) == 0 ? 0 : 1); // shift-right with round-up - } else { - *num_dig = (*num_dig - borrow) & DIG_MASK; - borrow = 0; - } - - // adjust quotient if it is too big - for (; borrow != 0; --quo) { - d = den_dig; - d_norm = 0; - mpz_dbl_dig_t carry = 0; - for (mpz_dig_t *n = num_dig - den_len; n < num_dig; ++n, ++d) { - d_norm = ((mpz_dbl_dig_t)*d << norm_shift) | (d_norm >> DIG_SIZE); - carry += (mpz_dbl_dig_t)*n + (d_norm & DIG_MASK); - *n = carry & DIG_MASK; - carry >>= DIG_SIZE; - } - carry += (mpz_dbl_dig_t)*num_dig; - *num_dig = carry & DIG_MASK; - carry >>= DIG_SIZE; - - //assert(borrow >= carry); // enable this to check the logic - borrow -= carry; - } - } - - // store this digit of the quotient - *quo_dig = quo & DIG_MASK; - --quo_dig; - - // move down to next digit of numerator - --num_dig; - --(*num_len); - } - - // unnormalise numerator (remainder now) - for (mpz_dig_t *num = orig_num_dig + *num_len - 1, carry = 0; num >= orig_num_dig; --num) { - mpz_dig_t n = *num; - *num = ((n >> norm_shift) | carry) & DIG_MASK; - carry = (mpz_dbl_dig_t)n << (DIG_SIZE - norm_shift); - } - - // strip trailing zeros - - while (*quo_len > 0 && orig_quo_dig[*quo_len - 1] == 0) { - --(*quo_len); - } - - while (*num_len > 0 && orig_num_dig[*num_len - 1] == 0) { - --(*num_len); - } -} - -#define MIN_ALLOC (2) - -void mpz_init_zero(mpz_t *z) { - z->neg = 0; - z->fixed_dig = 0; - z->alloc = 0; - z->len = 0; - z->dig = NULL; -} - -void mpz_init_from_int(mpz_t *z, mp_int_t val) { - mpz_init_zero(z); - mpz_set_from_int(z, val); -} - -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t alloc, mp_int_t val) { - z->neg = 0; - z->fixed_dig = 1; - z->alloc = alloc; - z->len = 0; - z->dig = dig; - mpz_set_from_int(z, val); -} - -void mpz_deinit(mpz_t *z) { - if (z != NULL && !z->fixed_dig) { - m_del(mpz_dig_t, z->dig, z->alloc); - } -} - -#if 0 -these functions are unused - -mpz_t *mpz_zero(void) { - mpz_t *z = m_new_obj(mpz_t); - mpz_init_zero(z); - return z; -} - -mpz_t *mpz_from_int(mp_int_t val) { - mpz_t *z = mpz_zero(); - mpz_set_from_int(z, val); - return z; -} - -mpz_t *mpz_from_ll(long long val, bool is_signed) { - mpz_t *z = mpz_zero(); - mpz_set_from_ll(z, val, is_signed); - return z; -} - -#if MICROPY_PY_BUILTINS_FLOAT -mpz_t *mpz_from_float(mp_float_t val) { - mpz_t *z = mpz_zero(); - mpz_set_from_float(z, val); - return z; -} -#endif - -mpz_t *mpz_from_str(const char *str, size_t len, bool neg, unsigned int base) { - mpz_t *z = mpz_zero(); - mpz_set_from_str(z, str, len, neg, base); - return z; -} -#endif - -STATIC void mpz_free(mpz_t *z) { - if (z != NULL) { - m_del(mpz_dig_t, z->dig, z->alloc); - m_del_obj(mpz_t, z); - } -} - -STATIC void mpz_need_dig(mpz_t *z, size_t need) { - if (need < MIN_ALLOC) { - need = MIN_ALLOC; - } - - if (z->dig == NULL || z->alloc < need) { - // if z has fixed digit buffer there's not much we can do as the caller will - // be expecting a buffer with at least "need" bytes (but it shouldn't happen) - assert(!z->fixed_dig); - z->dig = m_renew(mpz_dig_t, z->dig, z->alloc, need); - z->alloc = need; - } -} - -STATIC mpz_t *mpz_clone(const mpz_t *src) { - mpz_t *z = m_new_obj(mpz_t); - z->neg = src->neg; - z->fixed_dig = 0; - z->alloc = src->alloc; - z->len = src->len; - if (src->dig == NULL) { - z->dig = NULL; - } else { - z->dig = m_new(mpz_dig_t, z->alloc); - memcpy(z->dig, src->dig, src->alloc * sizeof(mpz_dig_t)); - } - return z; -} - -/* sets dest = src - can have dest, src the same -*/ -void mpz_set(mpz_t *dest, const mpz_t *src) { - mpz_need_dig(dest, src->len); - dest->neg = src->neg; - dest->len = src->len; - memcpy(dest->dig, src->dig, src->len * sizeof(mpz_dig_t)); -} - -void mpz_set_from_int(mpz_t *z, mp_int_t val) { - if (val == 0) { - z->len = 0; - return; - } - - mpz_need_dig(z, MPZ_NUM_DIG_FOR_INT); - - mp_uint_t uval; - if (val < 0) { - z->neg = 1; - uval = -val; - } else { - z->neg = 0; - uval = val; - } - - z->len = 0; - while (uval > 0) { - z->dig[z->len++] = uval & DIG_MASK; - uval >>= DIG_SIZE; - } -} - -void mpz_set_from_ll(mpz_t *z, long long val, bool is_signed) { - mpz_need_dig(z, MPZ_NUM_DIG_FOR_LL); - - unsigned long long uval; - if (is_signed && val < 0) { - z->neg = 1; - uval = -val; - } else { - z->neg = 0; - uval = val; - } - - z->len = 0; - while (uval > 0) { - z->dig[z->len++] = uval & DIG_MASK; - uval >>= DIG_SIZE; - } -} - -#if MICROPY_PY_BUILTINS_FLOAT -void mpz_set_from_float(mpz_t *z, mp_float_t src) { -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -typedef uint64_t mp_float_int_t; -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -typedef uint32_t mp_float_int_t; -#endif - union { - mp_float_t f; - #if MP_ENDIANNESS_LITTLE - struct { mp_float_int_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; - #else - struct { mp_float_int_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; - #endif - } u = {src}; - - z->neg = u.p.sgn; - if (u.p.exp == 0) { - // value == 0 || value < 1 - mpz_set_from_int(z, 0); - } else if (u.p.exp == ((1 << MP_FLOAT_EXP_BITS) - 1)) { - // u.p.frc == 0 indicates inf, else NaN - // should be handled by caller - mpz_set_from_int(z, 0); - } else { - const int adj_exp = (int)u.p.exp - MP_FLOAT_EXP_BIAS; - if (adj_exp < 0) { - // value < 1 , truncates to 0 - mpz_set_from_int(z, 0); - } else if (adj_exp == 0) { - // 1 <= value < 2 , so truncates to 1 - mpz_set_from_int(z, 1); - } else { - // 2 <= value - const int dig_cnt = (adj_exp + 1 + (DIG_SIZE - 1)) / DIG_SIZE; - const unsigned int rem = adj_exp % DIG_SIZE; - int dig_ind, shft; - mp_float_int_t frc = u.p.frc | ((mp_float_int_t)1 << MP_FLOAT_FRAC_BITS); - - if (adj_exp < MP_FLOAT_FRAC_BITS) { - shft = 0; - dig_ind = 0; - frc >>= MP_FLOAT_FRAC_BITS - adj_exp; - } else { - shft = (rem - MP_FLOAT_FRAC_BITS) % DIG_SIZE; - dig_ind = (adj_exp - MP_FLOAT_FRAC_BITS) / DIG_SIZE; - } - mpz_need_dig(z, dig_cnt); - z->len = dig_cnt; - if (dig_ind != 0) { - memset(z->dig, 0, dig_ind * sizeof(mpz_dig_t)); - } - if (shft != 0) { - z->dig[dig_ind++] = (frc << shft) & DIG_MASK; - frc >>= DIG_SIZE - shft; - } -#if DIG_SIZE < (MP_FLOAT_FRAC_BITS + 1) - while (dig_ind != dig_cnt) { - z->dig[dig_ind++] = frc & DIG_MASK; - frc >>= DIG_SIZE; - } -#else - if (dig_ind != dig_cnt) { - z->dig[dig_ind] = frc; - } -#endif - } - } -} -#endif - -// returns number of bytes from str that were processed -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base) { - assert(base <= 36); - - const char *cur = str; - const char *top = str + len; - - mpz_need_dig(z, len * 8 / DIG_SIZE + 1); - - if (neg) { - z->neg = 1; - } else { - z->neg = 0; - } - - z->len = 0; - for (; cur < top; ++cur) { // XXX UTF8 next char - //mp_uint_t v = char_to_numeric(cur#); // XXX UTF8 get char - mp_uint_t v = *cur; - if ('0' <= v && v <= '9') { - v -= '0'; - } else if ('A' <= v && v <= 'Z') { - v -= 'A' - 10; - } else if ('a' <= v && v <= 'z') { - v -= 'a' - 10; - } else { - break; - } - if (v >= base) { - break; - } - z->len = mpn_mul_dig_add_dig(z->dig, z->len, base, v); - } - - return cur - str; -} - -void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf) { - int delta = 1; - if (big_endian) { - buf += len - 1; - delta = -1; - } - - mpz_need_dig(z, (len * 8 + DIG_SIZE - 1) / DIG_SIZE); - - mpz_dig_t d = 0; - int num_bits = 0; - z->neg = 0; - z->len = 0; - while (len) { - while (len && num_bits < DIG_SIZE) { - d |= *buf << num_bits; - num_bits += 8; - buf += delta; - len--; - } - z->dig[z->len++] = d & DIG_MASK; - // Need this #if because it's C undefined behavior to do: uint32_t >> 32 - #if DIG_SIZE != 8 && DIG_SIZE != 16 && DIG_SIZE != 32 - d >>= DIG_SIZE; - #else - d = 0; - #endif - num_bits -= DIG_SIZE; - } - - z->len = mpn_remove_trailing_zeros(z->dig, z->dig + z->len); -} - -#if 0 -these functions are unused - -bool mpz_is_pos(const mpz_t *z) { - return z->len > 0 && z->neg == 0; -} - -bool mpz_is_odd(const mpz_t *z) { - return z->len > 0 && (z->dig[0] & 1) != 0; -} - -bool mpz_is_even(const mpz_t *z) { - return z->len == 0 || (z->dig[0] & 1) == 0; -} -#endif - -int mpz_cmp(const mpz_t *z1, const mpz_t *z2) { - // to catch comparison of -0 with +0 - if (z1->len == 0 && z2->len == 0) { - return 0; - } - int cmp = (int)z2->neg - (int)z1->neg; - if (cmp != 0) { - return cmp; - } - cmp = mpn_cmp(z1->dig, z1->len, z2->dig, z2->len); - if (z1->neg != 0) { - cmp = -cmp; - } - return cmp; -} - -#if 0 -// obsolete -// compares mpz with an integer that fits within DIG_SIZE bits -mp_int_t mpz_cmp_sml_int(const mpz_t *z, mp_int_t sml_int) { - mp_int_t cmp; - if (z->neg == 0) { - if (sml_int < 0) return 1; - if (sml_int == 0) { - if (z->len == 0) return 0; - return 1; - } - if (z->len == 0) return -1; - assert(sml_int < (1 << DIG_SIZE)); - if (z->len != 1) return 1; - cmp = z->dig[0] - sml_int; - } else { - if (sml_int > 0) return -1; - if (sml_int == 0) { - if (z->len == 0) return 0; - return -1; - } - if (z->len == 0) return 1; - assert(sml_int > -(1 << DIG_SIZE)); - if (z->len != 1) return -1; - cmp = -z->dig[0] - sml_int; - } - if (cmp < 0) return -1; - if (cmp > 0) return 1; - return 0; -} -#endif - -#if 0 -these functions are unused - -/* returns abs(z) -*/ -mpz_t *mpz_abs(const mpz_t *z) { - mpz_t *z2 = mpz_clone(z); - z2->neg = 0; - return z2; -} - -/* returns -z -*/ -mpz_t *mpz_neg(const mpz_t *z) { - mpz_t *z2 = mpz_clone(z); - z2->neg = 1 - z2->neg; - return z2; -} - -/* returns lhs + rhs - can have lhs, rhs the same -*/ -mpz_t *mpz_add(const mpz_t *lhs, const mpz_t *rhs) { - mpz_t *z = mpz_zero(); - mpz_add_inpl(z, lhs, rhs); - return z; -} - -/* returns lhs - rhs - can have lhs, rhs the same -*/ -mpz_t *mpz_sub(const mpz_t *lhs, const mpz_t *rhs) { - mpz_t *z = mpz_zero(); - mpz_sub_inpl(z, lhs, rhs); - return z; -} - -/* returns lhs * rhs - can have lhs, rhs the same -*/ -mpz_t *mpz_mul(const mpz_t *lhs, const mpz_t *rhs) { - mpz_t *z = mpz_zero(); - mpz_mul_inpl(z, lhs, rhs); - return z; -} - -/* returns lhs ** rhs - can have lhs, rhs the same -*/ -mpz_t *mpz_pow(const mpz_t *lhs, const mpz_t *rhs) { - mpz_t *z = mpz_zero(); - mpz_pow_inpl(z, lhs, rhs); - return z; -} - -/* computes new integers in quo and rem such that: - quo * rhs + rem = lhs - 0 <= rem < rhs - can have lhs, rhs the same -*/ -void mpz_divmod(const mpz_t *lhs, const mpz_t *rhs, mpz_t **quo, mpz_t **rem) { - *quo = mpz_zero(); - *rem = mpz_zero(); - mpz_divmod_inpl(*quo, *rem, lhs, rhs); -} -#endif - -/* computes dest = abs(z) - can have dest, z the same -*/ -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z) { - if (dest != z) { - mpz_set(dest, z); - } - dest->neg = 0; -} - -/* computes dest = -z - can have dest, z the same -*/ -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z) { - if (dest != z) { - mpz_set(dest, z); - } - dest->neg = 1 - dest->neg; -} - -/* computes dest = ~z (= -z - 1) - can have dest, z the same -*/ -void mpz_not_inpl(mpz_t *dest, const mpz_t *z) { - if (dest != z) { - mpz_set(dest, z); - } - if (dest->len == 0) { - mpz_need_dig(dest, 1); - dest->dig[0] = 1; - dest->len = 1; - dest->neg = 1; - } else if (dest->neg) { - dest->neg = 0; - mpz_dig_t k = 1; - dest->len = mpn_sub(dest->dig, dest->dig, dest->len, &k, 1); - } else { - mpz_need_dig(dest, dest->len + 1); - mpz_dig_t k = 1; - dest->len = mpn_add(dest->dig, dest->dig, dest->len, &k, 1); - dest->neg = 1; - } -} - -/* computes dest = lhs << rhs - can have dest, lhs the same -*/ -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) { - if (lhs->len == 0 || rhs == 0) { - mpz_set(dest, lhs); - } else { - mpz_need_dig(dest, lhs->len + (rhs + DIG_SIZE - 1) / DIG_SIZE); - dest->len = mpn_shl(dest->dig, lhs->dig, lhs->len, rhs); - dest->neg = lhs->neg; - } -} - -/* computes dest = lhs >> rhs - can have dest, lhs the same -*/ -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) { - if (lhs->len == 0 || rhs == 0) { - mpz_set(dest, lhs); - } else { - mpz_need_dig(dest, lhs->len); - dest->len = mpn_shr(dest->dig, lhs->dig, lhs->len, rhs); - dest->neg = lhs->neg; - if (dest->neg) { - // arithmetic shift right, rounding to negative infinity - mp_uint_t n_whole = rhs / DIG_SIZE; - mp_uint_t n_part = rhs % DIG_SIZE; - mpz_dig_t round_up = 0; - for (size_t i = 0; i < lhs->len && i < n_whole; i++) { - if (lhs->dig[i] != 0) { - round_up = 1; - break; - } - } - if (n_whole < lhs->len && (lhs->dig[n_whole] & ((1 << n_part) - 1)) != 0) { - round_up = 1; - } - if (round_up) { - if (dest->len == 0) { - // dest == 0, so need to add 1 by hand (answer will be -1) - dest->dig[0] = 1; - dest->len = 1; - } else { - // dest > 0, so can use mpn_add to add 1 - dest->len = mpn_add(dest->dig, dest->dig, dest->len, &round_up, 1); - } - } - } - } -} - -/* computes dest = lhs + rhs - can have dest, lhs, rhs the same -*/ -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - if (mpn_cmp(lhs->dig, lhs->len, rhs->dig, rhs->len) < 0) { - const mpz_t *temp = lhs; - lhs = rhs; - rhs = temp; - } - - if (lhs->neg == rhs->neg) { - mpz_need_dig(dest, lhs->len + 1); - dest->len = mpn_add(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - } else { - mpz_need_dig(dest, lhs->len); - dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - } - - dest->neg = lhs->neg; -} - -/* computes dest = lhs - rhs - can have dest, lhs, rhs the same -*/ -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - bool neg = false; - - if (mpn_cmp(lhs->dig, lhs->len, rhs->dig, rhs->len) < 0) { - const mpz_t *temp = lhs; - lhs = rhs; - rhs = temp; - neg = true; - } - - if (lhs->neg != rhs->neg) { - mpz_need_dig(dest, lhs->len + 1); - dest->len = mpn_add(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - } else { - mpz_need_dig(dest, lhs->len); - dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - } - - if (neg) { - dest->neg = 1 - lhs->neg; - } else { - dest->neg = lhs->neg; - } -} - -/* computes dest = lhs & rhs - can have dest, lhs, rhs the same -*/ -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - // make sure lhs has the most digits - if (lhs->len < rhs->len) { - const mpz_t *temp = lhs; - lhs = rhs; - rhs = temp; - } - - #if MICROPY_OPT_MPZ_BITWISE - - if ((0 == lhs->neg) && (0 == rhs->neg)) { - mpz_need_dig(dest, lhs->len); - dest->len = mpn_and(dest->dig, lhs->dig, rhs->dig, rhs->len); - dest->neg = 0; - } else { - mpz_need_dig(dest, lhs->len + 1); - dest->len = mpn_and_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, - lhs->neg == rhs->neg, 0 != lhs->neg, 0 != rhs->neg); - dest->neg = lhs->neg & rhs->neg; - } - - #else - - mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg)); - dest->len = mpn_and_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, - (lhs->neg == rhs->neg) ? lhs->neg : 0, lhs->neg, rhs->neg); - dest->neg = lhs->neg & rhs->neg; - - #endif -} - -/* computes dest = lhs | rhs - can have dest, lhs, rhs the same -*/ -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - // make sure lhs has the most digits - if (lhs->len < rhs->len) { - const mpz_t *temp = lhs; - lhs = rhs; - rhs = temp; - } - - #if MICROPY_OPT_MPZ_BITWISE - - if ((0 == lhs->neg) && (0 == rhs->neg)) { - mpz_need_dig(dest, lhs->len); - dest->len = mpn_or(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - dest->neg = 0; - } else { - mpz_need_dig(dest, lhs->len + 1); - dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, - 0 != lhs->neg, 0 != rhs->neg); - dest->neg = 1; - } - - #else - - mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg)); - dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, - (lhs->neg || rhs->neg), lhs->neg, rhs->neg); - dest->neg = lhs->neg | rhs->neg; - - #endif -} - -/* computes dest = lhs ^ rhs - can have dest, lhs, rhs the same -*/ -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - // make sure lhs has the most digits - if (lhs->len < rhs->len) { - const mpz_t *temp = lhs; - lhs = rhs; - rhs = temp; - } - - #if MICROPY_OPT_MPZ_BITWISE - - if (lhs->neg == rhs->neg) { - mpz_need_dig(dest, lhs->len); - if (lhs->neg == 0) { - dest->len = mpn_xor(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - } else { - dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, 0, 0, 0); - } - dest->neg = 0; - } else { - mpz_need_dig(dest, lhs->len + 1); - dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, 1, - 0 == lhs->neg, 0 == rhs->neg); - dest->neg = 1; - } - - #else - - mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg)); - dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, - (lhs->neg != rhs->neg), 0 == lhs->neg, 0 == rhs->neg); - dest->neg = lhs->neg ^ rhs->neg; - - #endif -} - -/* computes dest = lhs * rhs - can have dest, lhs, rhs the same -*/ -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - if (lhs->len == 0 || rhs->len == 0) { - mpz_set_from_int(dest, 0); - return; - } - - mpz_t *temp = NULL; - if (lhs == dest) { - lhs = temp = mpz_clone(lhs); - if (rhs == dest) { - rhs = lhs; - } - } else if (rhs == dest) { - rhs = temp = mpz_clone(rhs); - } - - mpz_need_dig(dest, lhs->len + rhs->len); // min mem l+r-1, max mem l+r - memset(dest->dig, 0, dest->alloc * sizeof(mpz_dig_t)); - dest->len = mpn_mul(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); - - if (lhs->neg == rhs->neg) { - dest->neg = 0; - } else { - dest->neg = 1; - } - - mpz_free(temp); -} - -/* computes dest = lhs ** rhs - can have dest, lhs, rhs the same -*/ -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { - if (lhs->len == 0 || rhs->neg != 0) { - mpz_set_from_int(dest, 0); - return; - } - - if (rhs->len == 0) { - mpz_set_from_int(dest, 1); - return; - } - - mpz_t *x = mpz_clone(lhs); - mpz_t *n = mpz_clone(rhs); - - mpz_set_from_int(dest, 1); - - while (n->len > 0) { - if ((n->dig[0] & 1) != 0) { - mpz_mul_inpl(dest, dest, x); - } - n->len = mpn_shr(n->dig, n->dig, n->len, 1); - if (n->len == 0) { - break; - } - mpz_mul_inpl(x, x, x); - } - - mpz_free(x); - mpz_free(n); -} - -/* computes dest = (lhs ** rhs) % mod - can have dest, lhs, rhs the same; mod can't be the same as dest -*/ -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod) { - if (lhs->len == 0 || rhs->neg != 0) { - mpz_set_from_int(dest, 0); - return; - } - - if (rhs->len == 0) { - mpz_set_from_int(dest, 1); - return; - } - - mpz_t *x = mpz_clone(lhs); - mpz_t *n = mpz_clone(rhs); - mpz_t quo; mpz_init_zero(&quo); - - mpz_set_from_int(dest, 1); - - while (n->len > 0) { - if ((n->dig[0] & 1) != 0) { - mpz_mul_inpl(dest, dest, x); - mpz_divmod_inpl(&quo, dest, dest, mod); - } - n->len = mpn_shr(n->dig, n->dig, n->len, 1); - if (n->len == 0) { - break; - } - mpz_mul_inpl(x, x, x); - mpz_divmod_inpl(&quo, x, x, mod); - } - - mpz_deinit(&quo); - mpz_free(x); - mpz_free(n); -} - -#if 0 -these functions are unused - -/* computes gcd(z1, z2) - based on Knuth's modified gcd algorithm (I think?) - gcd(z1, z2) >= 0 - gcd(0, 0) = 0 - gcd(z, 0) = abs(z) -*/ -mpz_t *mpz_gcd(const mpz_t *z1, const mpz_t *z2) { - if (z1->len == 0) { - mpz_t *a = mpz_clone(z2); - a->neg = 0; - return a; - } else if (z2->len == 0) { - mpz_t *a = mpz_clone(z1); - a->neg = 0; - return a; - } - - mpz_t *a = mpz_clone(z1); - mpz_t *b = mpz_clone(z2); - mpz_t c; mpz_init_zero(&c); - a->neg = 0; - b->neg = 0; - - for (;;) { - if (mpz_cmp(a, b) < 0) { - if (a->len == 0) { - mpz_free(a); - mpz_deinit(&c); - return b; - } - mpz_t *t = a; a = b; b = t; - } - if (!(b->len >= 2 || (b->len == 1 && b->dig[0] > 1))) { // compute b > 0; could be mpz_cmp_small_int(b, 1) > 0 - break; - } - mpz_set(&c, b); - do { - mpz_add_inpl(&c, &c, &c); - } while (mpz_cmp(&c, a) <= 0); - c.len = mpn_shr(c.dig, c.dig, c.len, 1); - mpz_sub_inpl(a, a, &c); - } - - mpz_deinit(&c); - - if (b->len == 1 && b->dig[0] == 1) { // compute b == 1; could be mpz_cmp_small_int(b, 1) == 0 - mpz_free(a); - return b; - } else { - mpz_free(b); - return a; - } -} - -/* computes lcm(z1, z2) - = abs(z1) / gcd(z1, z2) * abs(z2) - lcm(z1, z1) >= 0 - lcm(0, 0) = 0 - lcm(z, 0) = 0 -*/ -mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) { - if (z1->len == 0 || z2->len == 0) { - return mpz_zero(); - } - - mpz_t *gcd = mpz_gcd(z1, z2); - mpz_t *quo = mpz_zero(); - mpz_t *rem = mpz_zero(); - mpz_divmod_inpl(quo, rem, z1, gcd); - mpz_mul_inpl(rem, quo, z2); - mpz_free(gcd); - mpz_free(quo); - rem->neg = 0; - return rem; -} -#endif - -/* computes new integers in quo and rem such that: - quo * rhs + rem = lhs - 0 <= rem < rhs - can have lhs, rhs the same - assumes rhs != 0 (undefined behaviour if it is) -*/ -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs) { - assert(!mpz_is_zero(rhs)); - - mpz_need_dig(dest_quo, lhs->len + 1); // +1 necessary? - memset(dest_quo->dig, 0, (lhs->len + 1) * sizeof(mpz_dig_t)); - dest_quo->len = 0; - mpz_need_dig(dest_rem, lhs->len + 1); // +1 necessary? - mpz_set(dest_rem, lhs); - mpn_div(dest_rem->dig, &dest_rem->len, rhs->dig, rhs->len, dest_quo->dig, &dest_quo->len); - - // check signs and do Python style modulo - if (lhs->neg != rhs->neg) { - dest_quo->neg = 1; - if (!mpz_is_zero(dest_rem)) { - mpz_t mpzone; mpz_init_from_int(&mpzone, -1); - mpz_add_inpl(dest_quo, dest_quo, &mpzone); - mpz_add_inpl(dest_rem, dest_rem, rhs); - } - } -} - -#if 0 -these functions are unused - -/* computes floor(lhs / rhs) - can have lhs, rhs the same -*/ -mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs) { - mpz_t *quo = mpz_zero(); - mpz_t rem; mpz_init_zero(&rem); - mpz_divmod_inpl(quo, &rem, lhs, rhs); - mpz_deinit(&rem); - return quo; -} - -/* computes lhs % rhs ( >= 0) - can have lhs, rhs the same -*/ -mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs) { - mpz_t quo; mpz_init_zero(&quo); - mpz_t *rem = mpz_zero(); - mpz_divmod_inpl(&quo, rem, lhs, rhs); - mpz_deinit(&quo); - return rem; -} -#endif - -// must return actual int value if it fits in mp_int_t -mp_int_t mpz_hash(const mpz_t *z) { - mp_int_t val = 0; - mpz_dig_t *d = z->dig + z->len; - - while (d-- > z->dig) { - val = (val << DIG_SIZE) | *d; - } - - if (z->neg != 0) { - val = -val; - } - - return val; -} - -bool mpz_as_int_checked(const mpz_t *i, mp_int_t *value) { - mp_uint_t val = 0; - mpz_dig_t *d = i->dig + i->len; - - while (d-- > i->dig) { - if (val > (~(WORD_MSBIT_HIGH) >> DIG_SIZE)) { - // will overflow - return false; - } - val = (val << DIG_SIZE) | *d; - } - - if (i->neg != 0) { - val = -val; - } - - *value = val; - return true; -} - -bool mpz_as_uint_checked(const mpz_t *i, mp_uint_t *value) { - if (i->neg != 0) { - // can't represent signed values - return false; - } - - mp_uint_t val = 0; - mpz_dig_t *d = i->dig + i->len; - - while (d-- > i->dig) { - if (val > (~(WORD_MSBIT_HIGH) >> (DIG_SIZE - 1))) { - // will overflow - return false; - } - val = (val << DIG_SIZE) | *d; - } - - *value = val; - return true; -} - -// writes at most len bytes to buf (so buf should be zeroed before calling) -void mpz_as_bytes(const mpz_t *z, bool big_endian, size_t len, byte *buf) { - byte *b = buf; - if (big_endian) { - b += len; - } - mpz_dig_t *zdig = z->dig; - int bits = 0; - mpz_dbl_dig_t d = 0; - mpz_dbl_dig_t carry = 1; - for (size_t zlen = z->len; zlen > 0; --zlen) { - bits += DIG_SIZE; - d = (d << DIG_SIZE) | *zdig++; - for (; bits >= 8; bits -= 8, d >>= 8) { - mpz_dig_t val = d; - if (z->neg) { - val = (~val & 0xff) + carry; - carry = val >> 8; - } - if (big_endian) { - *--b = val; - if (b == buf) { - return; - } - } else { - *b++ = val; - if (b == buf + len) { - return; - } - } - } - } -} - -#if MICROPY_PY_BUILTINS_FLOAT -mp_float_t mpz_as_float(const mpz_t *i) { - mp_float_t val = 0; - mpz_dig_t *d = i->dig + i->len; - - while (d-- > i->dig) { - val = val * DIG_BASE + *d; - } - - if (i->neg != 0) { - val = -val; - } - - return val; -} -#endif - -#if 0 -this function is unused -char *mpz_as_str(const mpz_t *i, unsigned int base) { - char *s = m_new(char, mp_int_format_size(mpz_max_num_bits(i), base, NULL, '\0')); - mpz_as_str_inpl(i, base, NULL, 'a', '\0', s); - return s; -} -#endif - -// assumes enough space as calculated by mp_int_format_size -// returns length of string, not including null byte -size_t mpz_as_str_inpl(const mpz_t *i, unsigned int base, const char *prefix, char base_char, char comma, char *str) { - if (str == NULL) { - return 0; - } - if (base < 2 || base > 32) { - str[0] = 0; - return 0; - } - - size_t ilen = i->len; - - char *s = str; - if (ilen == 0) { - if (prefix) { - while (*prefix) - *s++ = *prefix++; - } - *s++ = '0'; - *s = '\0'; - return s - str; - } - - // make a copy of mpz digits, so we can do the div/mod calculation - mpz_dig_t *dig = m_new(mpz_dig_t, ilen); - memcpy(dig, i->dig, ilen * sizeof(mpz_dig_t)); - - // convert - char *last_comma = str; - bool done; - do { - mpz_dig_t *d = dig + ilen; - mpz_dbl_dig_t a = 0; - - // compute next remainder - while (--d >= dig) { - a = (a << DIG_SIZE) | *d; - *d = a / base; - a %= base; - } - - // convert to character - a += '0'; - if (a > '9') { - a += base_char - '9' - 1; - } - *s++ = a; - - // check if number is zero - done = true; - for (d = dig; d < dig + ilen; ++d) { - if (*d != 0) { - done = false; - break; - } - } - if (comma && (s - last_comma) == 3) { - *s++ = comma; - last_comma = s; - } - } - while (!done); - - // free the copy of the digits array - m_del(mpz_dig_t, dig, ilen); - - if (prefix) { - const char *p = &prefix[strlen(prefix)]; - while (p > prefix) { - *s++ = *--p; - } - } - if (i->neg != 0) { - *s++ = '-'; - } - - // reverse string - for (char *u = str, *v = s - 1; u < v; ++u, --v) { - char temp = *u; - *u = *v; - *v = temp; - } - - *s = '\0'; // null termination - - return s - str; -} - -#endif // MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ diff --git a/user/mpy/py/mpz.h b/user/mpy/py/mpz.h deleted file mode 100644 index e2d0c30..0000000 --- a/user/mpy/py/mpz.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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_MPZ_H -#define MICROPY_INCLUDED_PY_MPZ_H - -#include - -#include "py/mpconfig.h" -#include "py/misc.h" - -// This mpz module implements arbitrary precision integers. -// -// The storage for each digit is defined by mpz_dig_t. The actual number of -// bits in mpz_dig_t that are used is defined by MPZ_DIG_SIZE. The machine must -// also provide a type that is twice as wide as mpz_dig_t, in both signed and -// unsigned versions. -// -// MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most -// sense to have it as large as possible. If MPZ_DIG_SIZE is not already -// defined then it is auto-detected below, depending on the machine. The types -// are then set based on the value of MPZ_DIG_SIZE (although they can be freely -// changed so long as the constraints mentioned above are met). - -#ifndef MPZ_DIG_SIZE - #if defined(__x86_64__) || defined(_WIN64) - // 64-bit machine, using 32-bit storage for digits - #define MPZ_DIG_SIZE (32) - #else - // default: 32-bit machine, using 16-bit storage for digits - #define MPZ_DIG_SIZE (16) - #endif -#endif - -#if MPZ_DIG_SIZE > 16 -typedef uint32_t mpz_dig_t; -typedef uint64_t mpz_dbl_dig_t; -typedef int64_t mpz_dbl_dig_signed_t; -#elif MPZ_DIG_SIZE > 8 -typedef uint16_t mpz_dig_t; -typedef uint32_t mpz_dbl_dig_t; -typedef int32_t mpz_dbl_dig_signed_t; -#elif MPZ_DIG_SIZE > 4 -typedef uint8_t mpz_dig_t; -typedef uint16_t mpz_dbl_dig_t; -typedef int16_t mpz_dbl_dig_signed_t; -#else -typedef uint8_t mpz_dig_t; -typedef uint8_t mpz_dbl_dig_t; -typedef int8_t mpz_dbl_dig_signed_t; -#endif - -#ifdef _WIN64 - #ifdef __MINGW32__ - #define MPZ_LONG_1 1LL - #else - #define MPZ_LONG_1 1i64 - #endif -#else - #define MPZ_LONG_1 1L -#endif - -// these define the maximum storage needed to hold an int or long long -#define MPZ_NUM_DIG_FOR_INT ((sizeof(mp_int_t) * 8 + MPZ_DIG_SIZE - 1) / MPZ_DIG_SIZE) -#define MPZ_NUM_DIG_FOR_LL ((sizeof(long long) * 8 + MPZ_DIG_SIZE - 1) / MPZ_DIG_SIZE) - -typedef struct _mpz_t { - size_t neg : 1; - size_t fixed_dig : 1; - size_t alloc : 8 * sizeof(size_t) - 2; - size_t len; - mpz_dig_t *dig; -} mpz_t; - -// convenience macro to declare an mpz with a digit array from the stack, initialised by an integer -#define MPZ_CONST_INT(z, val) mpz_t z; mpz_dig_t z ## _digits[MPZ_NUM_DIG_FOR_INT]; mpz_init_fixed_from_int(&z, z_digits, MPZ_NUM_DIG_FOR_INT, val); - -void mpz_init_zero(mpz_t *z); -void mpz_init_from_int(mpz_t *z, mp_int_t val); -void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t dig_alloc, mp_int_t val); -void mpz_deinit(mpz_t *z); - -void mpz_set(mpz_t *dest, const mpz_t *src); -void mpz_set_from_int(mpz_t *z, mp_int_t src); -void mpz_set_from_ll(mpz_t *z, long long i, bool is_signed); -#if MICROPY_PY_BUILTINS_FLOAT -void mpz_set_from_float(mpz_t *z, mp_float_t src); -#endif -size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base); -void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf); - -static inline bool mpz_is_zero(const mpz_t *z) { return z->len == 0; } -static inline bool mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; } -int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); - -void mpz_abs_inpl(mpz_t *dest, const mpz_t *z); -void mpz_neg_inpl(mpz_t *dest, const mpz_t *z); -void mpz_not_inpl(mpz_t *dest, const mpz_t *z); -void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs); -void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod); -void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs); -void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs); - -static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * MPZ_DIG_SIZE; } -mp_int_t mpz_hash(const mpz_t *z); -bool mpz_as_int_checked(const mpz_t *z, mp_int_t *value); -bool mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); -void mpz_as_bytes(const mpz_t *z, bool big_endian, size_t len, byte *buf); -#if MICROPY_PY_BUILTINS_FLOAT -mp_float_t mpz_as_float(const mpz_t *z); -#endif -size_t mpz_as_str_inpl(const mpz_t *z, unsigned int base, const char *prefix, char base_char, char comma, char *str); - -#endif // MICROPY_INCLUDED_PY_MPZ_H diff --git a/user/mpy/py/nativeglue.c b/user/mpy/py/nativeglue.c deleted file mode 100644 index e954234..0000000 --- a/user/mpy/py/nativeglue.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/emitglue.h" -#include "py/bc.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -#if MICROPY_EMIT_NATIVE - -// convert a MicroPython object to a valid native value based on type -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type) { - DEBUG_printf("mp_convert_obj_to_native(%p, " UINT_FMT ")\n", obj, type); - switch (type & 0xf) { - case MP_NATIVE_TYPE_OBJ: return (mp_uint_t)obj; - case MP_NATIVE_TYPE_BOOL: - case MP_NATIVE_TYPE_INT: - case MP_NATIVE_TYPE_UINT: return mp_obj_get_int_truncated(obj); - default: { // cast obj to a pointer - mp_buffer_info_t bufinfo; - if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_RW)) { - return (mp_uint_t)bufinfo.buf; - } else { - // assume obj is an integer that represents an address - return mp_obj_get_int_truncated(obj); - } - } - } -} - -#endif - -#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM - -// convert a native value to a MicroPython object based on type -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type) { - DEBUG_printf("mp_convert_native_to_obj(" UINT_FMT ", " UINT_FMT ")\n", val, type); - switch (type & 0xf) { - case MP_NATIVE_TYPE_OBJ: return (mp_obj_t)val; - case MP_NATIVE_TYPE_BOOL: return mp_obj_new_bool(val); - case MP_NATIVE_TYPE_INT: return mp_obj_new_int(val); - case MP_NATIVE_TYPE_UINT: return mp_obj_new_int_from_uint(val); - default: // a pointer - // we return just the value of the pointer as an integer - return mp_obj_new_int_from_uint(val); - } -} - -#endif - -#if MICROPY_EMIT_NATIVE - -// wrapper that accepts n_args and n_kw in one argument -// (native emitter can only pass at most 3 arguments to a function) -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) { - return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args); -} - -// wrapper that makes raise obj and raises it -// END_FINALLY opcode requires that we don't raise if o==None -void mp_native_raise(mp_obj_t o) { - if (o != mp_const_none) { - nlr_raise(mp_make_raise_obj(o)); - } -} - -// wrapper that handles iterator buffer -STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) { - if (iter == NULL) { - return mp_getiter(obj, NULL); - } else { - obj = mp_getiter(obj, iter); - if (obj != MP_OBJ_FROM_PTR(iter)) { - // Iterator didn't use the stack so indicate that with MP_OBJ_NULL. - iter->base.type = MP_OBJ_NULL; - iter->buf[0] = obj; - } - return NULL; - } -} - -// wrapper that handles iterator buffer -STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) { - mp_obj_t obj; - if (iter->base.type == MP_OBJ_NULL) { - obj = iter->buf[0]; - } else { - obj = MP_OBJ_FROM_PTR(iter); - } - return mp_iternext(obj); -} - -// these must correspond to the respective enum in runtime0.h -void *const mp_fun_table[MP_F_NUMBER_OF] = { - mp_convert_obj_to_native, - mp_convert_native_to_obj, - mp_load_name, - mp_load_global, - mp_load_build_class, - mp_load_attr, - mp_load_method, - mp_load_super_method, - mp_store_name, - mp_store_global, - mp_store_attr, - mp_obj_subscr, - mp_obj_is_true, - mp_unary_op, - mp_binary_op, - mp_obj_new_tuple, - mp_obj_new_list, - mp_obj_list_append, - mp_obj_new_dict, - mp_obj_dict_store, -#if MICROPY_PY_BUILTINS_SET - mp_obj_new_set, - mp_obj_set_store, -#endif - mp_make_function_from_raw_code, - mp_native_call_function_n_kw, - mp_call_method_n_kw, - mp_call_method_n_kw_var, - mp_native_getiter, - mp_native_iternext, - nlr_push, - nlr_pop, - mp_native_raise, - mp_import_name, - mp_import_from, - mp_import_all, -#if MICROPY_PY_BUILTINS_SLICE - mp_obj_new_slice, -#endif - mp_unpack_sequence, - mp_unpack_ex, - mp_delete_name, - mp_delete_global, - mp_obj_new_cell, - mp_make_closure_from_raw_code, - mp_setup_code_state, -}; - -/* -void mp_f_vector(mp_fun_kind_t fun_kind) { - (mp_f_table[fun_kind])(); -} -*/ - -#endif // MICROPY_EMIT_NATIVE diff --git a/user/mpy/py/nlr.h b/user/mpy/py/nlr.h deleted file mode 100644 index 63fe392..0000000 --- a/user/mpy/py/nlr.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 - -#include -#include -#include - -#include "py/mpconfig.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 !defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP -#if defined(__i386__) - void *regs[6]; -#elif defined(__x86_64__) - #if defined(__CYGWIN__) - void *regs[12]; - #else - void *regs[8]; - #endif -#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__) - void *regs[10]; -#elif defined(__xtensa__) - void *regs[10]; -#else - #define MICROPY_NLR_SETJMP (1) - //#warning "No native NLR support for this arch, using setjmp implementation" -#endif -#endif - -#if MICROPY_NLR_SETJMP - jmp_buf jmpbuf; -#endif -}; - -#if MICROPY_NLR_SETJMP -#include "py/mpstate.h" - -NORETURN void nlr_setjmp_jump(void *val); -// nlr_push() must be defined as a macro, because "The stack context will be -// invalidated if the function which called setjmp() returns." -#define nlr_push(buf) ((buf)->prev = MP_STATE_THREAD(nlr_top), MP_STATE_THREAD(nlr_top) = (buf), setjmp((buf)->jmpbuf)) -#define nlr_pop() { MP_STATE_THREAD(nlr_top) = MP_STATE_THREAD(nlr_top)->prev; } -#define nlr_jump(val) nlr_setjmp_jump(val) -#else -unsigned int nlr_push(nlr_buf_t *); -void nlr_pop(void); -NORETURN void nlr_jump(void *val); -#endif - -// 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 -#include "mpstate.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 !MICROPY_NLR_SETJMP -#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 -*/ -#endif - -#endif - -#endif // MICROPY_INCLUDED_PY_NLR_H diff --git a/user/mpy/py/nlrsetjmp.c b/user/mpy/py/nlrsetjmp.c deleted file mode 100644 index 1fb4594..0000000 --- a/user/mpy/py/nlrsetjmp.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -#include "py/nlr.h" - -#if MICROPY_NLR_SETJMP - -void nlr_setjmp_jump(void *val) { - 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; - *top_ptr = top->prev; - longjmp(top->jmpbuf, 1); -} - -#endif diff --git a/user/mpy/py/nlrthumb.c b/user/mpy/py/nlrthumb.c deleted file mode 100644 index 08a71ac..0000000 --- a/user/mpy/py/nlrthumb.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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. - */ - -#include "py/mpstate.h" -#include "py/nlr.h" - -#if (!defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP) && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) - -#undef nlr_push - -// We only need the functions here if we are on arm/thumb, and we are not -// using setjmp/longjmp. -// -// For reference, arm/thumb callee save regs are: -// r4-r11, r13=sp - -__attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) { - - __asm volatile ( - "str r4, [r0, #12] \n" // store r4 into nlr_buf - "str r5, [r0, #16] \n" // store r5 into nlr_buf - "str r6, [r0, #20] \n" // store r6 into nlr_buf - "str r7, [r0, #24] \n" // store r7 into nlr_buf - -#if defined(__ARM_ARCH_6M__) - "mov r1, r8 \n" - "str r1, [r0, #28] \n" // store r8 into nlr_buf - "mov r1, r9 \n" - "str r1, [r0, #32] \n" // store r9 into nlr_buf - "mov r1, r10 \n" - "str r1, [r0, #36] \n" // store r10 into nlr_buf - "mov r1, r11 \n" - "str r1, [r0, #40] \n" // store r11 into nlr_buf - "mov r1, r13 \n" - "str r1, [r0, #44] \n" // store r13=sp into nlr_buf - "mov r1, lr \n" - "str r1, [r0, #8] \n" // store lr into nlr_buf -#else - "str r8, [r0, #28] \n" // store r8 into nlr_buf - "str r9, [r0, #32] \n" // store r9 into nlr_buf - "str r10, [r0, #36] \n" // store r10 into nlr_buf - "str r11, [r0, #40] \n" // store r11 into nlr_buf - "str r13, [r0, #44] \n" // store r13=sp into nlr_buf - "str lr, [r0, #8] \n" // store lr into nlr_buf -#endif - - "b nlr_push_tail \n" // do the rest in C - ); - - return 0; // needed to silence compiler warning -} - -__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - nlr->prev = *top; - *top = nlr; - return 0; // normal return -} - -void nlr_pop(void) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - *top = (*top)->prev; -} - -NORETURN __attribute__((naked)) void nlr_jump(void *val) { - 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; - *top_ptr = top->prev; - - __asm volatile ( - "mov r0, %0 \n" // r0 points to nlr_buf - "ldr r4, [r0, #12] \n" // load r4 from nlr_buf - "ldr r5, [r0, #16] \n" // load r5 from nlr_buf - "ldr r6, [r0, #20] \n" // load r6 from nlr_buf - "ldr r7, [r0, #24] \n" // load r7 from nlr_buf - -#if defined(__ARM_ARCH_6M__) - "ldr r1, [r0, #28] \n" // load r8 from nlr_buf - "mov r8, r1 \n" - "ldr r1, [r0, #32] \n" // load r9 from nlr_buf - "mov r9, r1 \n" - "ldr r1, [r0, #36] \n" // load r10 from nlr_buf - "mov r10, r1 \n" - "ldr r1, [r0, #40] \n" // load r11 from nlr_buf - "mov r11, r1 \n" - "ldr r1, [r0, #44] \n" // load r13=sp from nlr_buf - "mov r13, r1 \n" - "ldr r1, [r0, #8] \n" // load lr from nlr_buf - "mov lr, r1 \n" -#else - "ldr r8, [r0, #28] \n" // load r8 from nlr_buf - "ldr r9, [r0, #32] \n" // load r9 from nlr_buf - "ldr r10, [r0, #36] \n" // load r10 from nlr_buf - "ldr r11, [r0, #40] \n" // load r11 from nlr_buf - "ldr r13, [r0, #44] \n" // load r13=sp from nlr_buf - "ldr lr, [r0, #8] \n" // load lr from nlr_buf -#endif - "movs r0, #1 \n" // return 1, non-local return - "bx lr \n" // return - : // output operands - : "r"(top) // input operands - : // clobbered registers - ); - - for (;;); // needed to silence compiler warning -} - -#endif // (!defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP) && (defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) diff --git a/user/mpy/py/nlrx64.c b/user/mpy/py/nlrx64.c deleted file mode 100644 index c23fd8f..0000000 --- a/user/mpy/py/nlrx64.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-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. - */ - -#include "py/mpstate.h" -#include "py/nlr.h" - -#if !MICROPY_NLR_SETJMP && defined(__x86_64__) - -#undef nlr_push - -// x86-64 callee-save registers are: -// rbx, rbp, rsp, r12, r13, r14, r15 - -#define NLR_OS_WINDOWS (defined(_WIN32) || defined(__CYGWIN__)) - -__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr); - -unsigned int nlr_push(nlr_buf_t *nlr) { - (void)nlr; - - #if NLR_OS_WINDOWS - - __asm volatile ( - "movq (%rsp), %rax \n" // load return %rip - "movq %rax, 16(%rcx) \n" // store %rip into nlr_buf - "movq %rbp, 24(%rcx) \n" // store %rbp into nlr_buf - "movq %rsp, 32(%rcx) \n" // store %rsp into nlr_buf - "movq %rbx, 40(%rcx) \n" // store %rbx into nlr_buf - "movq %r12, 48(%rcx) \n" // store %r12 into nlr_buf - "movq %r13, 56(%rcx) \n" // store %r13 into nlr_buf - "movq %r14, 64(%rcx) \n" // store %r14 into nlr_buf - "movq %r15, 72(%rcx) \n" // store %r15 into nlr_buf - "movq %rdi, 80(%rcx) \n" // store %rdr into nlr_buf - "movq %rsi, 88(%rcx) \n" // store %rsi into nlr_buf - "jmp nlr_push_tail \n" // do the rest in C - ); - - #else - - __asm volatile ( - #if defined(__APPLE__) || defined(__MACH__) - "pop %rbp \n" // undo function's prelude - #endif - "movq (%rsp), %rax \n" // load return %rip - "movq %rax, 16(%rdi) \n" // store %rip into nlr_buf - "movq %rbp, 24(%rdi) \n" // store %rbp into nlr_buf - "movq %rsp, 32(%rdi) \n" // store %rsp into nlr_buf - "movq %rbx, 40(%rdi) \n" // store %rbx into nlr_buf - "movq %r12, 48(%rdi) \n" // store %r12 into nlr_buf - "movq %r13, 56(%rdi) \n" // store %r13 into nlr_buf - "movq %r14, 64(%rdi) \n" // store %r14 into nlr_buf - "movq %r15, 72(%rdi) \n" // store %r15 into nlr_buf - #if defined(__APPLE__) || defined(__MACH__) - "jmp _nlr_push_tail \n" // do the rest in C - #else - "jmp nlr_push_tail \n" // do the rest in C - #endif - ); - - #endif - - return 0; // needed to silence compiler warning -} - -__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - nlr->prev = *top; - *top = nlr; - return 0; // normal return -} - -void nlr_pop(void) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - *top = (*top)->prev; -} - -NORETURN void nlr_jump(void *val) { - 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; - *top_ptr = top->prev; - - __asm volatile ( - "movq %0, %%rcx \n" // %rcx points to nlr_buf - #if NLR_OS_WINDOWS - "movq 88(%%rcx), %%rsi \n" // load saved %rsi - "movq 80(%%rcx), %%rdi \n" // load saved %rdr - #endif - "movq 72(%%rcx), %%r15 \n" // load saved %r15 - "movq 64(%%rcx), %%r14 \n" // load saved %r14 - "movq 56(%%rcx), %%r13 \n" // load saved %r13 - "movq 48(%%rcx), %%r12 \n" // load saved %r12 - "movq 40(%%rcx), %%rbx \n" // load saved %rbx - "movq 32(%%rcx), %%rsp \n" // load saved %rsp - "movq 24(%%rcx), %%rbp \n" // load saved %rbp - "movq 16(%%rcx), %%rax \n" // load saved %rip - "movq %%rax, (%%rsp) \n" // store saved %rip to stack - "xorq %%rax, %%rax \n" // clear return register - "inc %%al \n" // increase to make 1, non-local return - "ret \n" // return - : // output operands - : "r"(top) // input operands - : // clobbered registers - ); - - for (;;); // needed to silence compiler warning -} - -#endif // !MICROPY_NLR_SETJMP && defined(__x86_64__) diff --git a/user/mpy/py/nlrx86.c b/user/mpy/py/nlrx86.c deleted file mode 100644 index 58aaa1a..0000000 --- a/user/mpy/py/nlrx86.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-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. - */ - -#include "py/mpconfig.h" -#include "py/mpstate.h" -#include "py/nlr.h" - -#if !MICROPY_NLR_SETJMP && defined(__i386__) - -#undef nlr_push - -// For reference, x86 callee save regs are: -// ebx, esi, edi, ebp, esp, eip - -#define NLR_OS_WINDOWS (defined(_WIN32) || defined(__CYGWIN__)) - -#if NLR_OS_WINDOWS -unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail"); -#else -__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr); -#endif - -unsigned int nlr_push(nlr_buf_t *nlr) { - (void)nlr; - - __asm volatile ( - // Check for Zephyr, which uses a different calling convention - // by default. - // TODE: Better support for various x86 calling conventions - // (unfortunately, __attribute__((naked)) is not supported on x86). - #ifndef __ZEPHYR__ - "pop %ebp \n" // undo function's prelude - #endif - "mov 4(%esp), %edx \n" // load nlr_buf - "mov (%esp), %eax \n" // load return %eip - "mov %eax, 8(%edx) \n" // store %eip into nlr_buf - "mov %ebp, 12(%edx) \n" // store %ebp into nlr_buf - "mov %esp, 16(%edx) \n" // store %esp into nlr_buf - "mov %ebx, 20(%edx) \n" // store %ebx into nlr_buf - "mov %edi, 24(%edx) \n" // store %edi into nlr_buf - "mov %esi, 28(%edx) \n" // store %esi into nlr_buf - "jmp nlr_push_tail \n" // do the rest in C - ); - - return 0; // needed to silence compiler warning -} - -__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - nlr->prev = *top; - *top = nlr; - return 0; // normal return -} - -void nlr_pop(void) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - *top = (*top)->prev; -} - -NORETURN void nlr_jump(void *val) { - 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; - *top_ptr = top->prev; - - __asm volatile ( - "mov %0, %%edx \n" // %edx points to nlr_buf - "mov 28(%%edx), %%esi \n" // load saved %esi - "mov 24(%%edx), %%edi \n" // load saved %edi - "mov 20(%%edx), %%ebx \n" // load saved %ebx - "mov 16(%%edx), %%esp \n" // load saved %esp - "mov 12(%%edx), %%ebp \n" // load saved %ebp - "mov 8(%%edx), %%eax \n" // load saved %eip - "mov %%eax, (%%esp) \n" // store saved %eip to stack - "xor %%eax, %%eax \n" // clear return register - "inc %%al \n" // increase to make 1, non-local return - "ret \n" // return - : // output operands - : "r"(top) // input operands - : // clobbered registers - ); - - for (;;); // needed to silence compiler warning -} - -#endif // !MICROPY_NLR_SETJMP && defined(__i386__) diff --git a/user/mpy/py/nlrxtensa.c b/user/mpy/py/nlrxtensa.c deleted file mode 100644 index ccac359..0000000 --- a/user/mpy/py/nlrxtensa.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014-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. - */ - -#include "py/mpstate.h" -#include "py/nlr.h" - -#if !MICROPY_NLR_SETJMP && defined(__xtensa__) - -#undef nlr_push - -// Xtensa calling conventions: -// a0 = return address -// a1 = stack pointer -// a2 = first arg, return value -// a3-a7 = rest of args - -unsigned int nlr_push(nlr_buf_t *nlr) { - - __asm volatile ( - "s32i.n a0, a2, 8 \n" // save regs... - "s32i.n a1, a2, 12 \n" - "s32i.n a8, a2, 16 \n" - "s32i.n a9, a2, 20 \n" - "s32i.n a10, a2, 24 \n" - "s32i.n a11, a2, 28 \n" - "s32i.n a12, a2, 32 \n" - "s32i.n a13, a2, 36 \n" - "s32i.n a14, a2, 40 \n" - "s32i.n a15, a2, 44 \n" - "j nlr_push_tail \n" // do the rest in C - ); - - return 0; // needed to silence compiler warning -} - -__attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - nlr->prev = *top; - *top = nlr; - return 0; // normal return -} - -void nlr_pop(void) { - nlr_buf_t **top = &MP_STATE_THREAD(nlr_top); - *top = (*top)->prev; -} - -NORETURN void nlr_jump(void *val) { - 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; - *top_ptr = top->prev; - - __asm volatile ( - "mov.n a2, %0 \n" // a2 points to nlr_buf - "l32i.n a0, a2, 8 \n" // restore regs... - "l32i.n a1, a2, 12 \n" - "l32i.n a8, a2, 16 \n" - "l32i.n a9, a2, 20 \n" - "l32i.n a10, a2, 24 \n" - "l32i.n a11, a2, 28 \n" - "l32i.n a12, a2, 32 \n" - "l32i.n a13, a2, 36 \n" - "l32i.n a14, a2, 40 \n" - "l32i.n a15, a2, 44 \n" - "movi.n a2, 1 \n" // return 1, non-local return - "ret.n \n" // return - : // output operands - : "r"(top) // input operands - : // clobbered registers - ); - - for (;;); // needed to silence compiler warning -} - -#endif // !MICROPY_NLR_SETJMP && defined(__xtensa__) diff --git a/user/mpy/py/obj.c b/user/mpy/py/obj.c deleted file mode 100644 index 515a95b..0000000 --- a/user/mpy/py/obj.c +++ /dev/null @@ -1,513 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/objtype.h" -#include "py/objint.h" -#include "py/objstr.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/stackctrl.h" -#include "py/stream.h" // for mp_obj_print - -mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { - if (MP_OBJ_IS_SMALL_INT(o_in)) { - return (mp_obj_type_t*)&mp_type_int; - } else if (MP_OBJ_IS_QSTR(o_in)) { - return (mp_obj_type_t*)&mp_type_str; - #if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_float(o_in)) { - return (mp_obj_type_t*)&mp_type_float; - #endif - } else { - const mp_obj_base_t *o = MP_OBJ_TO_PTR(o_in); - return (mp_obj_type_t*)o->type; - } -} - -const char *mp_obj_get_type_str(mp_const_obj_t o_in) { - return qstr_str(mp_obj_get_type(o_in)->name); -} - -void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - // There can be data structures nested too deep, or just recursive - MP_STACK_CHECK(); -#ifndef NDEBUG - if (o_in == MP_OBJ_NULL) { - mp_print_str(print, "(nil)"); - return; - } -#endif - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->print != NULL) { - type->print((mp_print_t*)print, o_in, kind); - } else { - mp_printf(print, "<%q>", type->name); - } -} - -void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_print_helper(MP_PYTHON_PRINTER, o_in, kind); -} - -// helper function to print an exception with traceback -void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { - if (mp_obj_is_exception_instance(exc)) { - size_t n, *values; - mp_obj_exception_get_traceback(exc, &n, &values); - if (n > 0) { - assert(n % 3 == 0); - mp_print_str(print, "Traceback (most recent call last):\n"); - for (int i = n - 3; i >= 0; i -= 3) { -#if MICROPY_ENABLE_SOURCE_LINE - mp_printf(print, " File \"%q\", line %d", values[i], (int)values[i + 1]); -#else - mp_printf(print, " File \"%q\"", values[i]); -#endif - // the block name can be NULL if it's unknown - qstr block = values[i + 2]; - if (block == MP_QSTR_NULL) { - mp_print_str(print, "\n"); - } else { - mp_printf(print, ", in %q\n", block); - } - } - } - } - mp_obj_print_helper(print, exc, PRINT_EXC); - mp_print_str(print, "\n"); -} - -bool mp_obj_is_true(mp_obj_t arg) { - if (arg == mp_const_false) { - return 0; - } else if (arg == mp_const_true) { - return 1; - } else if (arg == mp_const_none) { - return 0; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - if (MP_OBJ_SMALL_INT_VALUE(arg) == 0) { - return 0; - } else { - return 1; - } - } else { - mp_obj_type_t *type = mp_obj_get_type(arg); - if (type->unary_op != NULL) { - mp_obj_t result = type->unary_op(MP_UNARY_OP_BOOL, arg); - if (result != MP_OBJ_NULL) { - return result == mp_const_true; - } - } - - mp_obj_t len = mp_obj_len_maybe(arg); - if (len != MP_OBJ_NULL) { - // obj has a length, truth determined if len != 0 - return len != MP_OBJ_NEW_SMALL_INT(0); - } else { - // any other obj is true per Python semantics - return 1; - } - } -} - -bool mp_obj_is_callable(mp_obj_t o_in) { - mp_call_fun_t call = mp_obj_get_type(o_in)->call; - if (call != mp_obj_instance_call) { - return call != NULL; - } - return mp_obj_instance_is_callable(o_in); -} - -// This function implements the '==' operator (and so the inverse of '!='). -// -// From the Python language reference: -// (https://docs.python.org/3/reference/expressions.html#not-in) -// "The objects need not have the same type. If both are numbers, they are converted -// to a common type. Otherwise, the == and != operators always consider objects of -// different types to be unequal." -// -// This means that False==0 and True==1 are true expressions. -// -// Furthermore, from the v3.4.2 code for object.c: "Practical amendments: If rich -// comparison returns NotImplemented, == and != are decided by comparing the object -// pointer." -bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) { - if (o1 == o2) { - return true; - } - if (o1 == mp_const_none || o2 == mp_const_none) { - return false; - } - - // fast path for small ints - if (MP_OBJ_IS_SMALL_INT(o1)) { - if (MP_OBJ_IS_SMALL_INT(o2)) { - // both SMALL_INT, and not equal if we get here - return false; - } else { - mp_obj_t temp = o2; o2 = o1; o1 = temp; - // o2 is now the SMALL_INT, o1 is not - // fall through to generic op - } - } - - // fast path for strings - if (MP_OBJ_IS_STR(o1)) { - if (MP_OBJ_IS_STR(o2)) { - // both strings, use special function - return mp_obj_str_equal(o1, o2); - } else { - // a string is never equal to anything else - goto str_cmp_err; - } - } else if (MP_OBJ_IS_STR(o2)) { - // o1 is not a string (else caught above), so the objects are not equal - str_cmp_err: - #if MICROPY_PY_STR_BYTES_CMP_WARN - if (MP_OBJ_IS_TYPE(o1, &mp_type_bytes) || MP_OBJ_IS_TYPE(o2, &mp_type_bytes)) { - mp_warning("Comparison between bytes and str"); - } - #endif - return false; - } - - // generic type, call binary_op(MP_BINARY_OP_EQUAL) - mp_obj_type_t *type = mp_obj_get_type(o1); - if (type->binary_op != NULL) { - mp_obj_t r = type->binary_op(MP_BINARY_OP_EQUAL, o1, o2); - if (r != MP_OBJ_NULL) { - return r == mp_const_true ? true : false; - } - } - - // equality not implemented, and objects are not the same object, so - // they are defined as not equal - return false; -} - -mp_int_t mp_obj_get_int(mp_const_obj_t arg) { - // This function essentially performs implicit type conversion to int - // Note that Python does NOT provide implicit type conversion from - // float to int in the core expression language, try some_list[1.0]. - if (arg == mp_const_false) { - return 0; - } else if (arg == mp_const_true) { - return 1; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - return MP_OBJ_SMALL_INT_VALUE(arg); - } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { - return mp_obj_int_get_checked(arg); - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("can't convert to int"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "can't convert %s to int", mp_obj_get_type_str(arg))); - } - } -} - -mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg) { - if (MP_OBJ_IS_INT(arg)) { - return mp_obj_int_get_truncated(arg); - } else { - return mp_obj_get_int(arg); - } -} - -// returns false if arg is not of integral type -// returns true and sets *value if it is of integral type -// can throw OverflowError if arg is of integral type, but doesn't fit in a mp_int_t -bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value) { - if (arg == mp_const_false) { - *value = 0; - } else if (arg == mp_const_true) { - *value = 1; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - *value = MP_OBJ_SMALL_INT_VALUE(arg); - } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { - *value = mp_obj_int_get_checked(arg); - } else { - return false; - } - return true; -} - -#if MICROPY_PY_BUILTINS_FLOAT -mp_float_t mp_obj_get_float(mp_obj_t arg) { - if (arg == mp_const_false) { - return 0; - } else if (arg == mp_const_true) { - return 1; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - return MP_OBJ_SMALL_INT_VALUE(arg); - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { - return mp_obj_int_as_float_impl(arg); - #endif - } else if (mp_obj_is_float(arg)) { - return mp_obj_float_get(arg); - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("can't convert to float"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "can't convert %s to float", mp_obj_get_type_str(arg))); - } - } -} - -#if MICROPY_PY_BUILTINS_COMPLEX -void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) { - if (arg == mp_const_false) { - *real = 0; - *imag = 0; - } else if (arg == mp_const_true) { - *real = 1; - *imag = 0; - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - *real = MP_OBJ_SMALL_INT_VALUE(arg); - *imag = 0; - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { - *real = mp_obj_int_as_float_impl(arg); - *imag = 0; - #endif - } else if (mp_obj_is_float(arg)) { - *real = mp_obj_float_get(arg); - *imag = 0; - } else if (MP_OBJ_IS_TYPE(arg, &mp_type_complex)) { - mp_obj_complex_get(arg, real, imag); - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("can't convert to complex"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "can't convert %s to complex", mp_obj_get_type_str(arg))); - } - } -} -#endif -#endif - -// note: returned value in *items may point to the interior of a GC block -void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) { - if (MP_OBJ_IS_TYPE(o, &mp_type_tuple)) { - mp_obj_tuple_get(o, len, items); - } else if (MP_OBJ_IS_TYPE(o, &mp_type_list)) { - mp_obj_list_get(o, len, items); - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("expected tuple/list"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "object '%s' is not a tuple or list", mp_obj_get_type_str(o))); - } - } -} - -// note: returned value in *items may point to the interior of a GC block -void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) { - size_t seq_len; - mp_obj_get_array(o, &seq_len, items); - if (seq_len != len) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_ValueError("tuple/list has wrong length"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "requested length %d but object has length %d", (int)len, (int)seq_len)); - } - } -} - -// is_slice determines whether the index is a slice index -size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice) { - mp_int_t i; - if (MP_OBJ_IS_SMALL_INT(index)) { - i = MP_OBJ_SMALL_INT_VALUE(index); - } else if (!mp_obj_get_int_maybe(index, &i)) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("indices must be integers"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "%q indices must be integers, not %s", - type->name, mp_obj_get_type_str(index))); - } - } - - if (i < 0) { - i += len; - } - if (is_slice) { - if (i < 0) { - i = 0; - } else if ((mp_uint_t)i > len) { - i = len; - } - } else { - if (i < 0 || (mp_uint_t)i >= len) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_msg(&mp_type_IndexError, "index out of range"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_IndexError, - "%q index out of range", type->name)); - } - } - } - - // By this point 0 <= i <= len and so fits in a size_t - return (size_t)i; -} - -mp_obj_t mp_obj_id(mp_obj_t o_in) { - mp_int_t id = (mp_int_t)o_in; - if (!MP_OBJ_IS_OBJ(o_in)) { - return mp_obj_new_int(id); - } else if (id >= 0) { - // Many OSes and CPUs have affinity for putting "user" memories - // into low half of address space, and "system" into upper half. - // We're going to take advantage of that and return small int - // (signed) for such "user" addresses. - return MP_OBJ_NEW_SMALL_INT(id); - } else { - // If that didn't work, well, let's return long int, just as - // a (big) positive value, so it will never clash with the range - // of small int returned in previous case. - return mp_obj_new_int_from_uint((mp_uint_t)id); - } -} - -// will raise a TypeError if object has no length -mp_obj_t mp_obj_len(mp_obj_t o_in) { - mp_obj_t len = mp_obj_len_maybe(o_in); - if (len == MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object has no len"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "object of type '%s' has no len()", mp_obj_get_type_str(o_in))); - } - } else { - return len; - } -} - -// may return MP_OBJ_NULL -mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { - if ( -#if !MICROPY_PY_BUILTINS_STR_UNICODE - // It's simple - unicode is slow, non-unicode is fast - MP_OBJ_IS_STR(o_in) || -#endif - MP_OBJ_IS_TYPE(o_in, &mp_type_bytes)) { - GET_STR_LEN(o_in, l); - return MP_OBJ_NEW_SMALL_INT(l); - } else { - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->unary_op != NULL) { - return type->unary_op(MP_UNARY_OP_LEN, o_in); - } else { - return MP_OBJ_NULL; - } - } -} - -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { - mp_obj_type_t *type = mp_obj_get_type(base); - if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(base, index, value); - if (ret != MP_OBJ_NULL) { - return ret; - } - // TODO: call base classes here? - } - if (value == MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object does not support item deletion"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object does not support item deletion", mp_obj_get_type_str(base))); - } - } else if (value == MP_OBJ_SENTINEL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object is not subscriptable"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not subscriptable", mp_obj_get_type_str(base))); - } - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object does not support item assignment"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object does not support item assignment", mp_obj_get_type_str(base))); - } - } -} - -// Return input argument. Useful as .getiter for objects which are -// their own iterators, etc. -mp_obj_t mp_identity(mp_obj_t self) { - return self; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity); - -mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf) { - (void)iter_buf; - return self; -} - -bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - mp_obj_type_t *type = mp_obj_get_type(obj); - if (type->buffer_p.get_buffer == NULL) { - return false; - } - int ret = type->buffer_p.get_buffer(obj, bufinfo, flags); - if (ret != 0) { - return false; - } - return true; -} - -void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - if (!mp_get_buffer(obj, bufinfo, flags)) { - mp_raise_TypeError("object with buffer protocol required"); - } -} - -mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in) { - switch (op) { - case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in); - default: return MP_OBJ_NULL; // op not supported - } -} diff --git a/user/mpy/py/obj.h b/user/mpy/py/obj.h deleted file mode 100644 index 22bfda0..0000000 --- a/user/mpy/py/obj.h +++ /dev/null @@ -1,867 +0,0 @@ -/* - * 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 - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/qstr.h" -#include "py/mpprint.h" - -// 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 MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D -typedef uint64_t mp_obj_t; -typedef uint64_t mp_const_obj_t; -#else -typedef void *mp_obj_t; -typedef const void *mp_const_obj_t; -#endif - -// 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. - -#ifdef NDEBUG -#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)) -#else -#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)) -#endif - -// 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 MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A - -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)) & 3) == 2); } -#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2) -#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)) - -#if MICROPY_PY_BUILTINS_FLOAT -#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 - -static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } - -#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B - -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)) & 3) == 3); } -#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2) -#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 3)) - -#if MICROPY_PY_BUILTINS_FLOAT -#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 - -static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 1) == 0); } - -#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C - -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)) - -#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); -} - -static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return (((mp_uint_t)(o)) & 0xff800007) == 0x00000006; } -#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) | 0x00000006)) - -static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 3) == 0); } - -#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - -static inline bool MP_OBJ_IS_SMALL_INT(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 0xffff000000000000) == 0x0001000000000000); } -#define MP_OBJ_SMALL_INT_VALUE(o) (((intptr_t)(o)) >> 1) -#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)(((uintptr_t)(small_int)) << 1) | 0x0001000000000001) - -static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) - { return ((((mp_int_t)(o)) & 0xffff000000000000) == 0x0002000000000000); } -#define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff) -#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 1) | 0x0002000000000001)) - -#if MICROPY_PY_BUILTINS_FLOAT -#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b125769 + 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 - -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 MP_ENDIANNESS_LITTLE -#define MP_ROM_PTR(p) {.u32 = {.lo = (p), .hi = NULL}} -#else -#define MP_ROM_PTR(p) {.u32 = {.lo = NULL, .hi = (p)}} -#endif - -#endif - -// 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 - -// Cast object pointer to mp_obj_t -#ifndef MP_OBJ_FROM_PTR -#define MP_OBJ_FROM_PTR(p) ((mp_obj_t)p) -#endif - -// Macros to create objects that are stored in ROM. - -#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 - -// The macros below are derived from the ones above and are used to -// check for more specific object types. - -#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 -#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_FUN(o) (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function)) - -// Note: inline functions sometimes use much more code space than the -// equivalent macros, depending on the compiler. -//static inline bool MP_OBJ_IS_TYPE(mp_const_obj_t o, const mp_obj_type_t *t) { return (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)(o))->type == (t))); } // this does not work for checking a string, use below macro for that -//static inline bool MP_OBJ_IS_INT(mp_const_obj_t o) { return (MP_OBJ_IS_SMALL_INT(o) || MP_OBJ_IS_TYPE(o, &mp_type_int)); } // returns true if o is a small int or long int -// Need to forward declare these for the inline function to compile. -extern const mp_obj_type_t mp_type_int; -extern const mp_obj_type_t mp_type_bool; -static inline bool mp_obj_is_integer(mp_const_obj_t o) { return MP_OBJ_IS_INT(o) || MP_OBJ_IS_TYPE(o, &mp_type_bool); } // returns true if o is bool, small int or long int -//static inline bool MP_OBJ_IS_STR(mp_const_obj_t o) { return (MP_OBJ_IS_QSTR(o) || MP_OBJ_IS_TYPE(o, &mp_type_str)); } - - -// 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_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}, false, n_args_min, MP_OBJ_FUN_ARGS_MAX, .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}, false, n_args_min, n_args_max, .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}, true, n_args_min, MP_OBJ_FUN_ARGS_MAX, .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} - -// 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; - -// TODO maybe have a truncated mp_map_t for fixed tables, since alloc=used -// put alloc last in the structure, so the truncated version does not need it -// this would save 1 ROM word for all ROM objects that have a locals_dict -// would also need a trucated dict structure - -typedef struct _mp_map_t { - size_t all_keys_are_qstrs : 1; - size_t is_fixed : 1; // a fixed array that can't be modified; must also be ordered - size_t is_ordered : 1; // an ordered array - 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; - -extern const mp_map_t mp_const_empty_map; - -static inline bool MP_MAP_SLOT_IS_FILLED(const mp_map_t *map, size_t pos) { 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 *); - -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_uint_t op, mp_obj_t); -typedef mp_obj_t (*mp_binary_op_fun_t)(mp_uint_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 { - // if we'd bother to support various versions of structure - // (with different number of fields), we can distinguish - // them with ver = sizeof(struct). Cons: overkill for *micro*? - //int ver; // ? - - void *buf; // can be NULL if len == 0 - size_t len; // in bytes - int typecode; // as per binary.h - - // Rationale: to load arbitrary-sized sprites directly to LCD - // Cons: a bit adhoc usecase - // int stride; -} 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); - -// Stream protocol -typedef struct _mp_stream_p_t { - // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values - // are implementation-dependent, but will be exposed to user, e.g. via exception). - mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); - mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); - mp_uint_t is_text : 1; // default is bytes, set this for text stream -} mp_stream_p_t; - -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; - - // The name of this type. - qstr 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_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_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_TimeoutError; -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 -// The macros are for convenience only -#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)) -#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)) -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; -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_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_MemoryError_obj; -extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj; - -// General API for objects - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -mp_obj_t mp_obj_new_none(void); -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, bool make_qstr_if_not_already); -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 MICROPY_PY_BUILTINS_FLOAT -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 -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!) -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_viper(size_t n_args, void *fun_data, mp_uint_t type_sig); -mp_obj_t mp_obj_new_fun_asm(size_t n_args, 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); - -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_instance_cast_to_native_base(mp_const_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); -bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2); - -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 MICROPY_PY_BUILTINS_FLOAT -mp_float_t mp_obj_get_float(mp_obj_t self_in); -void mp_obj_get_complex(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag); -#endif -//qstr mp_obj_get_qstr(mp_obj_t arg); -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_uint_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); - -// 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); - -// 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); -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes); - -#if MICROPY_PY_BUILTINS_FLOAT -// float -#if MICROPY_FLOAT_HIGH_QUALITY_HASH -mp_int_t mp_float_hash(mp_float_t val); -#else -static inline mp_int_t mp_float_hash(mp_float_t val) { return (mp_int_t)val; } -#endif -mp_obj_t mp_obj_float_binary_op(mp_uint_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_uint_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 -#define mp_obj_is_float(o) (false) -#endif - -// 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 -struct _mp_obj_list_t; -void mp_obj_list_init(struct _mp_obj_list_t *o, size_t n); -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; -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_map_t *mp_obj_dict_get_map(mp_obj_t self_in); - -// set -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item); - -// slice -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); - -// 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; - -#define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below -typedef struct _mp_obj_fun_builtin_var_t { - mp_obj_base_t base; - bool is_kw : 1; - mp_uint_t n_args_min : 15; // inclusive - mp_uint_t n_args_max : 16; // inclusive - 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; -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in); -// 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 - -// slice indexes resolved to particular sequence -typedef struct { - mp_uint_t start; - mp_uint_t stop; - mp_int_t step; -} mp_bound_slice_t; - -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); -#if MICROPY_PY_BUILTINS_SLICE -bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes); -#endif -#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)) -#define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_sz) \ - /*printf("memcpy(%p, %p, %d)\n", dest + beg, slice, slice_len * (item_sz));*/ \ - memcpy(((char*)dest) + (beg) * (item_sz), slice, slice_len * (item_sz)); \ - /*printf("memmove(%p, %p, %d)\n", dest + (beg + slice_len), dest + end, (dest_len - end) * (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) \ - /*printf("memmove(%p, %p, %d)\n", dest + beg + len_adj, dest + beg, (dest_len - beg) * (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)); - -#endif // MICROPY_INCLUDED_PY_OBJ_H diff --git a/user/mpy/py/objarray.c b/user/mpy/py/objarray.c deleted file mode 100644 index a31c536..0000000 --- a/user/mpy/py/objarray.c +++ /dev/null @@ -1,634 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/binary.h" -#include "py/objstr.h" -#include "py/objarray.h" - -#if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW - -// About memoryview object: We want to reuse as much code as possible from -// array, and keep the memoryview object 4 words in size so it fits in 1 GC -// block. Also, memoryview must keep a pointer to the base of the buffer so -// that the buffer is not GC'd if the original parent object is no longer -// around (we are assuming that all memoryview'able objects return a pointer -// which points to the start of a GC chunk). Given the above constraints we -// do the following: -// - typecode high bit is set if the buffer is read-write (else read-only) -// - free is the offset in elements to the first item in the memoryview -// - len is the length in elements -// - items points to the start of the original buffer -// Note that we don't handle the case where the original buffer might change -// size due to a resize of the original parent object. - -// make (& TYPECODE_MASK) a null operation if memorview not enabled -#if MICROPY_PY_BUILTINS_MEMORYVIEW -#define TYPECODE_MASK (0x7f) -#else -#define TYPECODE_MASK (~(size_t)0) -#endif - -STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf); -STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg); -STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in); -STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -/******************************************************************************/ -// array - -#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in); - if (o->typecode == BYTEARRAY_TYPECODE) { - mp_print_str(print, "bytearray(b"); - mp_str_print_quoted(print, o->items, o->len, true); - } else { - mp_printf(print, "array('%c'", o->typecode); - if (o->len > 0) { - mp_print_str(print, ", ["); - for (size_t i = 0; i < o->len; i++) { - if (i > 0) { - mp_print_str(print, ", "); - } - mp_obj_print_helper(print, mp_binary_get_val_array(o->typecode, o->items, i), PRINT_REPR); - } - mp_print_str(print, "]"); - } - } - mp_print_str(print, ")"); -} -#endif - -#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -STATIC mp_obj_array_t *array_new(char typecode, size_t n) { - int typecode_size = mp_binary_get_size('@', typecode, NULL); - mp_obj_array_t *o = m_new_obj(mp_obj_array_t); - #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY - o->base.type = (typecode == BYTEARRAY_TYPECODE) ? &mp_type_bytearray : &mp_type_array; - #elif MICROPY_PY_BUILTINS_BYTEARRAY - o->base.type = &mp_type_bytearray; - #else - o->base.type = &mp_type_array; - #endif - o->typecode = typecode; - o->free = 0; - o->len = n; - o->items = m_new(byte, typecode_size * o->len); - return o; -} -#endif - -#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) { - // bytearrays can be raw-initialised from anything with the buffer protocol - // other arrays can only be raw-initialised from bytes and bytearray objects - mp_buffer_info_t bufinfo; - if (((MICROPY_PY_BUILTINS_BYTEARRAY - && typecode == BYTEARRAY_TYPECODE) - || (MICROPY_PY_ARRAY - && (MP_OBJ_IS_TYPE(initializer, &mp_type_bytes) - || (MICROPY_PY_BUILTINS_BYTEARRAY && MP_OBJ_IS_TYPE(initializer, &mp_type_bytearray))))) - && mp_get_buffer(initializer, &bufinfo, MP_BUFFER_READ)) { - // construct array from raw bytes - // we round-down the len to make it a multiple of sz (CPython raises error) - size_t sz = mp_binary_get_size('@', typecode, NULL); - size_t len = bufinfo.len / sz; - mp_obj_array_t *o = array_new(typecode, len); - memcpy(o->items, bufinfo.buf, len * sz); - return MP_OBJ_FROM_PTR(o); - } - - size_t len; - // Try to create array of exact len if initializer len is known - mp_obj_t len_in = mp_obj_len_maybe(initializer); - if (len_in == MP_OBJ_NULL) { - len = 0; - } else { - len = MP_OBJ_SMALL_INT_VALUE(len_in); - } - - mp_obj_array_t *array = array_new(typecode, len); - - mp_obj_t iterable = mp_getiter(initializer, NULL); - mp_obj_t item; - size_t i = 0; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - if (len == 0) { - array_append(MP_OBJ_FROM_PTR(array), item); - } else { - mp_binary_set_val_array(typecode, array->items, i++, item); - } - } - - return MP_OBJ_FROM_PTR(array); -} -#endif - -#if MICROPY_PY_ARRAY -STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 1, 2, false); - - // get typecode - const char *typecode = mp_obj_str_get_str(args[0]); - - if (n_args == 1) { - // 1 arg: make an empty array - return MP_OBJ_FROM_PTR(array_new(*typecode, 0)); - } else { - // 2 args: construct the array from the given object - return array_construct(*typecode, args[1]); - } -} -#endif - -#if MICROPY_PY_BUILTINS_BYTEARRAY -STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 1, false); - - if (n_args == 0) { - // no args: construct an empty bytearray - return MP_OBJ_FROM_PTR(array_new(BYTEARRAY_TYPECODE, 0)); - } else if (MP_OBJ_IS_INT(args[0])) { - // 1 arg, an integer: construct a blank bytearray of that length - mp_uint_t len = mp_obj_get_int(args[0]); - mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, len); - memset(o->items, 0, len); - return MP_OBJ_FROM_PTR(o); - } else { - // 1 arg: construct the bytearray from that - return array_construct(BYTEARRAY_TYPECODE, args[0]); - } -} -#endif - -#if MICROPY_PY_BUILTINS_MEMORYVIEW - -mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) { - mp_obj_array_t *self = m_new_obj(mp_obj_array_t); - self->base.type = &mp_type_memoryview; - self->typecode = typecode; - self->free = 0; - self->len = nitems; - self->items = items; - return MP_OBJ_FROM_PTR(self); -} - -STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - // TODO possibly allow memoryview constructor to take start/stop so that one - // can do memoryview(b, 4, 8) instead of memoryview(b)[4:8] (uses less RAM) - - mp_arg_check_num(n_args, n_kw, 1, 1, false); - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); - - mp_obj_array_t *self = MP_OBJ_TO_PTR(mp_obj_new_memoryview(bufinfo.typecode, - bufinfo.len / mp_binary_get_size('@', bufinfo.typecode, NULL), - bufinfo.buf)); - - // test if the object can be written to - if (mp_get_buffer(args[0], &bufinfo, MP_BUFFER_RW)) { - self->typecode |= 0x80; // used to indicate writable buffer - } - - return MP_OBJ_FROM_PTR(self); -} -#endif - -STATIC mp_obj_t array_unary_op(mp_uint_t op, mp_obj_t o_in) { - mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(o->len); - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t array_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in); - switch (op) { - case MP_BINARY_OP_ADD: { - // allow to add anything that has the buffer protocol (extension to CPython) - mp_buffer_info_t lhs_bufinfo; - mp_buffer_info_t rhs_bufinfo; - array_get_buffer(lhs_in, &lhs_bufinfo, MP_BUFFER_READ); - mp_get_buffer_raise(rhs_in, &rhs_bufinfo, MP_BUFFER_READ); - - size_t sz = mp_binary_get_size('@', lhs_bufinfo.typecode, NULL); - - // convert byte count to element count (in case rhs is not multiple of sz) - size_t rhs_len = rhs_bufinfo.len / sz; - - // note: lhs->len is element count of lhs, lhs_bufinfo.len is byte count - mp_obj_array_t *res = array_new(lhs_bufinfo.typecode, lhs->len + rhs_len); - mp_seq_cat((byte*)res->items, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_len * sz, byte); - return MP_OBJ_FROM_PTR(res); - } - - case MP_BINARY_OP_INPLACE_ADD: { - #if MICROPY_PY_BUILTINS_MEMORYVIEW - if (lhs->base.type == &mp_type_memoryview) { - return MP_OBJ_NULL; // op not supported - } - #endif - array_extend(lhs_in, rhs_in); - return lhs_in; - } - - case MP_BINARY_OP_IN: { - /* NOTE `a in b` is `b.__contains__(a)` */ - mp_buffer_info_t lhs_bufinfo; - mp_buffer_info_t rhs_bufinfo; - - // Can search string only in bytearray - if (mp_get_buffer(rhs_in, &rhs_bufinfo, MP_BUFFER_READ)) { - if (!MP_OBJ_IS_TYPE(lhs_in, &mp_type_bytearray)) { - return mp_const_false; - } - array_get_buffer(lhs_in, &lhs_bufinfo, MP_BUFFER_READ); - return mp_obj_new_bool( - find_subbytes(lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len, 1) != NULL); - } - - // Otherwise, can only look for a scalar numeric value in an array - if (MP_OBJ_IS_INT(rhs_in) || mp_obj_is_float(rhs_in)) { - mp_raise_NotImplementedError(""); - } - - return mp_const_false; - } - - case MP_BINARY_OP_EQUAL: { - mp_buffer_info_t lhs_bufinfo; - mp_buffer_info_t rhs_bufinfo; - array_get_buffer(lhs_in, &lhs_bufinfo, MP_BUFFER_READ); - if (!mp_get_buffer(rhs_in, &rhs_bufinfo, MP_BUFFER_READ)) { - return mp_const_false; - } - return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len)); - } - - default: - return MP_OBJ_NULL; // op not supported - } -} - -#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) { - // self is not a memoryview, so we don't need to use (& TYPECODE_MASK) - assert((MICROPY_PY_BUILTINS_BYTEARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_bytearray)) - || (MICROPY_PY_ARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_array))); - mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in); - - if (self->free == 0) { - size_t item_sz = mp_binary_get_size('@', self->typecode, NULL); - // TODO: alloc policy - self->free = 8; - self->items = m_renew(byte, self->items, item_sz * self->len, item_sz * (self->len + self->free)); - mp_seq_clear(self->items, self->len + 1, self->len + self->free, item_sz); - } - mp_binary_set_val_array(self->typecode, self->items, self->len, arg); - // only update length/free if set succeeded - self->len++; - self->free--; - return mp_const_none; // return None, as per CPython -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_append_obj, array_append); - -STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { - // self is not a memoryview, so we don't need to use (& TYPECODE_MASK) - assert((MICROPY_PY_BUILTINS_BYTEARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_bytearray)) - || (MICROPY_PY_ARRAY && MP_OBJ_IS_TYPE(self_in, &mp_type_array))); - mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in); - - // allow to extend by anything that has the buffer protocol (extension to CPython) - mp_buffer_info_t arg_bufinfo; - mp_get_buffer_raise(arg_in, &arg_bufinfo, MP_BUFFER_READ); - - size_t sz = mp_binary_get_size('@', self->typecode, NULL); - - // convert byte count to element count - size_t len = arg_bufinfo.len / sz; - - // make sure we have enough room to extend - // TODO: alloc policy; at the moment we go conservative - if (self->free < len) { - self->items = m_renew(byte, self->items, (self->len + self->free) * sz, (self->len + len) * sz); - self->free = 0; - } else { - self->free -= len; - } - - // extend - mp_seq_copy((byte*)self->items + self->len * sz, arg_bufinfo.buf, len * sz, byte); - self->len += len; - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); -#endif - -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { - if (value == MP_OBJ_NULL) { - // delete item - // TODO implement - // TODO: confirmed that both bytearray and array.array support - // slice deletion - return MP_OBJ_NULL; // op not supported - } else { - mp_obj_array_t *o = MP_OBJ_TO_PTR(self_in); - if (0) { -#if MICROPY_PY_BUILTINS_SLICE - } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { - mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(o->len, index_in, &slice)) { - mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); - } - if (value != MP_OBJ_SENTINEL) { - #if MICROPY_PY_ARRAY_SLICE_ASSIGN - // Assign - size_t src_len; - void *src_items; - size_t item_sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL); - if (MP_OBJ_IS_OBJ(value) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(value))->type->subscr == array_subscr) { - // value is array, bytearray or memoryview - mp_obj_array_t *src_slice = MP_OBJ_TO_PTR(value); - if (item_sz != mp_binary_get_size('@', src_slice->typecode & TYPECODE_MASK, NULL)) { - compat_error: - mp_raise_ValueError("lhs and rhs should be compatible"); - } - src_len = src_slice->len; - src_items = src_slice->items; - #if MICROPY_PY_BUILTINS_MEMORYVIEW - if (MP_OBJ_IS_TYPE(value, &mp_type_memoryview)) { - src_items = (uint8_t*)src_items + (src_slice->free * item_sz); - } - #endif - } else if (MP_OBJ_IS_TYPE(value, &mp_type_bytes)) { - if (item_sz != 1) { - goto compat_error; - } - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); - src_len = bufinfo.len; - src_items = bufinfo.buf; - } else { - mp_raise_NotImplementedError("array/bytes required on right side"); - } - - // TODO: check src/dst compat - mp_int_t len_adj = src_len - (slice.stop - slice.start); - uint8_t* dest_items = o->items; - #if MICROPY_PY_BUILTINS_MEMORYVIEW - if (o->base.type == &mp_type_memoryview) { - if ((o->typecode & 0x80) == 0) { - // store to read-only memoryview not allowed - return MP_OBJ_NULL; - } - if (len_adj != 0) { - goto compat_error; - } - dest_items += o->free * item_sz; - } - #endif - if (len_adj > 0) { - if (len_adj > o->free) { - // TODO: alloc policy; at the moment we go conservative - o->items = m_renew(byte, o->items, (o->len + o->free) * item_sz, (o->len + len_adj) * item_sz); - o->free = 0; - dest_items = o->items; - } - mp_seq_replace_slice_grow_inplace(dest_items, o->len, - slice.start, slice.stop, src_items, src_len, len_adj, item_sz); - } else { - mp_seq_replace_slice_no_grow(dest_items, o->len, - slice.start, slice.stop, src_items, src_len, item_sz); - // Clear "freed" elements at the end of list - // TODO: This is actually only needed for typecode=='O' - mp_seq_clear(dest_items, o->len + len_adj, o->len, item_sz); - // TODO: alloc policy after shrinking - } - o->len += len_adj; - return mp_const_none; - #else - return MP_OBJ_NULL; // op not supported - #endif - } - - mp_obj_array_t *res; - size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL); - assert(sz > 0); - if (0) { - // dummy - #if MICROPY_PY_BUILTINS_MEMORYVIEW - } else if (o->base.type == &mp_type_memoryview) { - res = m_new_obj(mp_obj_array_t); - *res = *o; - res->free += slice.start; - res->len = slice.stop - slice.start; - #endif - } else { - res = array_new(o->typecode, slice.stop - slice.start); - memcpy(res->items, (uint8_t*)o->items + slice.start * sz, (slice.stop - slice.start) * sz); - } - return MP_OBJ_FROM_PTR(res); -#endif - } else { - size_t index = mp_get_index(o->base.type, o->len, index_in, false); - #if MICROPY_PY_BUILTINS_MEMORYVIEW - if (o->base.type == &mp_type_memoryview) { - index += o->free; - if (value != MP_OBJ_SENTINEL && (o->typecode & 0x80) == 0) { - // store to read-only memoryview - return MP_OBJ_NULL; - } - } - #endif - if (value == MP_OBJ_SENTINEL) { - // load - return mp_binary_get_val_array(o->typecode & TYPECODE_MASK, o->items, index); - } else { - // store - mp_binary_set_val_array(o->typecode & TYPECODE_MASK, o->items, index, value); - return mp_const_none; - } - } - } -} - -STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in); - size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL); - bufinfo->buf = o->items; - bufinfo->len = o->len * sz; - bufinfo->typecode = o->typecode & TYPECODE_MASK; - #if MICROPY_PY_BUILTINS_MEMORYVIEW - if (o->base.type == &mp_type_memoryview) { - if ((o->typecode & 0x80) == 0 && (flags & MP_BUFFER_WRITE)) { - // read-only memoryview - return 1; - } - bufinfo->buf = (uint8_t*)bufinfo->buf + (size_t)o->free * sz; - } - #else - (void)flags; - #endif - return 0; -} - -#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -STATIC const mp_rom_map_elem_t array_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) }, - { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table); -#endif - -#if MICROPY_PY_ARRAY -const mp_obj_type_t mp_type_array = { - { &mp_type_type }, - .name = MP_QSTR_array, - .print = array_print, - .make_new = array_make_new, - .getiter = array_iterator_new, - .unary_op = array_unary_op, - .binary_op = array_binary_op, - .subscr = array_subscr, - .buffer_p = { .get_buffer = array_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&array_locals_dict, -}; -#endif - -#if MICROPY_PY_BUILTINS_BYTEARRAY -const mp_obj_type_t mp_type_bytearray = { - { &mp_type_type }, - .name = MP_QSTR_bytearray, - .print = array_print, - .make_new = bytearray_make_new, - .getiter = array_iterator_new, - .unary_op = array_unary_op, - .binary_op = array_binary_op, - .subscr = array_subscr, - .buffer_p = { .get_buffer = array_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&array_locals_dict, -}; -#endif - -#if MICROPY_PY_BUILTINS_MEMORYVIEW -const mp_obj_type_t mp_type_memoryview = { - { &mp_type_type }, - .name = MP_QSTR_memoryview, - .make_new = memoryview_make_new, - .getiter = array_iterator_new, - .unary_op = array_unary_op, - .binary_op = array_binary_op, - .subscr = array_subscr, - .buffer_p = { .get_buffer = array_get_buffer }, -}; -#endif - -/* unused -size_t mp_obj_array_len(mp_obj_t self_in) { - return ((mp_obj_array_t *)self_in)->len; -} -*/ - -#if MICROPY_PY_BUILTINS_BYTEARRAY -mp_obj_t mp_obj_new_bytearray(size_t n, void *items) { - mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n); - memcpy(o->items, items, n); - return MP_OBJ_FROM_PTR(o); -} - -// Create bytearray which references specified memory area -mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items) { - mp_obj_array_t *o = m_new_obj(mp_obj_array_t); - o->base.type = &mp_type_bytearray; - o->typecode = BYTEARRAY_TYPECODE; - o->free = 0; - o->len = n; - o->items = items; - return MP_OBJ_FROM_PTR(o); -} -#endif - -/******************************************************************************/ -// array iterator - -typedef struct _mp_obj_array_it_t { - mp_obj_base_t base; - mp_obj_array_t *array; - size_t offset; - size_t cur; -} mp_obj_array_it_t; - -STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) { - mp_obj_array_it_t *self = MP_OBJ_TO_PTR(self_in); - if (self->cur < self->array->len) { - return mp_binary_get_val_array(self->array->typecode & TYPECODE_MASK, self->array->items, self->offset + self->cur++); - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -STATIC const mp_obj_type_t array_it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = array_it_iternext, -}; - -STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_array_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_array_t *array = MP_OBJ_TO_PTR(array_in); - mp_obj_array_it_t *o = (mp_obj_array_it_t*)iter_buf; - o->base.type = &array_it_type; - o->array = array; - o->offset = 0; - o->cur = 0; - #if MICROPY_PY_BUILTINS_MEMORYVIEW - if (array->base.type == &mp_type_memoryview) { - o->offset = array->free; - } - #endif - return MP_OBJ_FROM_PTR(o); -} - -#endif // MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW diff --git a/user/mpy/py/objarray.h b/user/mpy/py/objarray.h deleted file mode 100644 index 0389668..0000000 --- a/user/mpy/py/objarray.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ -#ifndef MICROPY_INCLUDED_PY_OBJARRAY_H -#define MICROPY_INCLUDED_PY_OBJARRAY_H - -#include "py/obj.h" - -typedef struct _mp_obj_array_t { - mp_obj_base_t base; - size_t typecode : 8; - // free is number of unused elements after len used elements - // alloc size = len + free - size_t free : (8 * sizeof(size_t) - 8); - size_t len; // in elements - void *items; -} mp_obj_array_t; - -#endif // MICROPY_INCLUDED_PY_OBJARRAY_H diff --git a/user/mpy/py/objattrtuple.c b/user/mpy/py/objattrtuple.c deleted file mode 100644 index 3cc298d..0000000 --- a/user/mpy/py/objattrtuple.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 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. - */ - -#include "py/objtuple.h" - -#if MICROPY_PY_ATTRTUPLE || MICROPY_PY_COLLECTIONS - -// this helper function is used by collections.namedtuple -#if !MICROPY_PY_COLLECTIONS -STATIC -#endif -void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o) { - mp_print_str(print, "("); - for (size_t i = 0; i < o->len; i++) { - if (i > 0) { - mp_print_str(print, ", "); - } - mp_printf(print, "%q=", fields[i]); - mp_obj_print_helper(print, o->items[i], PRINT_REPR); - } - mp_print_str(print, ")"); -} - -#endif - -#if MICROPY_PY_ATTRTUPLE - -STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); - const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(o->items[o->len]); - mp_obj_attrtuple_print_helper(print, fields, o); -} - -STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] == MP_OBJ_NULL) { - // load attribute - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); - size_t len = self->len; - const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(self->items[len]); - for (size_t i = 0; i < len; i++) { - if (fields[i] == attr) { - dest[0] = self->items[i]; - return; - } - } - } -} - -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) { - mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, n + 1); - o->base.type = &mp_type_attrtuple; - o->len = n; - for (size_t i = 0; i < n; i++) { - o->items[i] = items[i]; - } - o->items[n] = MP_OBJ_FROM_PTR(fields); - return MP_OBJ_FROM_PTR(o); -} - -const mp_obj_type_t mp_type_attrtuple = { - { &mp_type_type }, - .name = MP_QSTR_tuple, // reuse tuple to save on a qstr - .print = mp_obj_attrtuple_print, - .unary_op = mp_obj_tuple_unary_op, - .binary_op = mp_obj_tuple_binary_op, - .attr = mp_obj_attrtuple_attr, - .subscr = mp_obj_tuple_subscr, - .getiter = mp_obj_tuple_getiter, -}; - -#endif // MICROPY_PY_ATTRTUPLE diff --git a/user/mpy/py/objbool.c b/user/mpy/py/objbool.c deleted file mode 100644 index e5bc3c2..0000000 --- a/user/mpy/py/objbool.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/obj.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -typedef struct _mp_obj_bool_t { - mp_obj_base_t base; - bool value; -} mp_obj_bool_t; - -STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_bool_t *self = MP_OBJ_TO_PTR(self_in); - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { - if (self->value) { - mp_print_str(print, "true"); - } else { - mp_print_str(print, "false"); - } - } else { - if (self->value) { - mp_print_str(print, "True"); - } else { - mp_print_str(print, "False"); - } - } -} - -STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 1, false); - - if (n_args == 0) { - return mp_const_false; - } else { - return mp_obj_new_bool(mp_obj_is_true(args[0])); - } -} - -STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { - if (op == MP_UNARY_OP_LEN) { - return MP_OBJ_NULL; - } - mp_obj_bool_t *self = MP_OBJ_TO_PTR(o_in); - return mp_unary_op(op, MP_OBJ_NEW_SMALL_INT(self->value)); -} - -STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_bool_t *self = MP_OBJ_TO_PTR(lhs_in); - return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in); -} - -const mp_obj_type_t mp_type_bool = { - { &mp_type_type }, - .name = MP_QSTR_bool, - .print = bool_print, - .make_new = bool_make_new, - .unary_op = bool_unary_op, - .binary_op = bool_binary_op, -}; - -const mp_obj_bool_t mp_const_false_obj = {{&mp_type_bool}, false}; -const mp_obj_bool_t mp_const_true_obj = {{&mp_type_bool}, true}; diff --git a/user/mpy/py/objboundmeth.c b/user/mpy/py/objboundmeth.c deleted file mode 100644 index 890f8b1..0000000 --- a/user/mpy/py/objboundmeth.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/obj.h" -#include "py/runtime.h" - -typedef struct _mp_obj_bound_meth_t { - mp_obj_base_t base; - mp_obj_t meth; - mp_obj_t self; -} mp_obj_bound_meth_t; - -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED -STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(o_in); - mp_printf(print, "self, PRINT_REPR); - mp_print_str(print, "."); - mp_obj_print_helper(print, o->meth, PRINT_REPR); - mp_print_str(print, ">"); -} -#endif - -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) { - // need to insert self before all other args and then call meth - size_t n_total = n_args + 2 * n_kw; - mp_obj_t *args2 = NULL; - mp_obj_t *free_args2 = NULL; - if (n_total > 4) { - // try to use heap to allocate temporary args array - args2 = m_new_maybe(mp_obj_t, 1 + n_total); - free_args2 = args2; - } - if (args2 == NULL) { - // (fallback to) use stack to allocate temporary args array - args2 = alloca(sizeof(mp_obj_t) * (1 + n_total)); - } - args2[0] = self; - memcpy(args2 + 1, args, n_total * sizeof(mp_obj_t)); - mp_obj_t res = mp_call_function_n_kw(meth, n_args + 1, n_kw, args2); - if (free_args2 != NULL) { - m_del(mp_obj_t, free_args2, 1 + n_total); - } - return res; -} - -STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in); - return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args); -} - -#if MICROPY_PY_FUNCTION_ATTRS -STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != MP_OBJ_NULL) { - // not load attribute - return; - } - if (attr == MP_QSTR___name__) { - mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(self_in); - dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth)); - } -} -#endif - -STATIC const mp_obj_type_t mp_type_bound_meth = { - { &mp_type_type }, - .name = MP_QSTR_bound_method, -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED - .print = bound_meth_print, -#endif - .call = bound_meth_call, -#if MICROPY_PY_FUNCTION_ATTRS - .attr = bound_meth_attr, -#endif -}; - -mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) { - mp_obj_bound_meth_t *o = m_new_obj(mp_obj_bound_meth_t); - o->base.type = &mp_type_bound_meth; - o->meth = meth; - o->self = self; - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objcell.c b/user/mpy/py/objcell.c deleted file mode 100644 index 1119064..0000000 --- a/user/mpy/py/objcell.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ - -#include "py/obj.h" - -typedef struct _mp_obj_cell_t { - mp_obj_base_t base; - mp_obj_t obj; -} mp_obj_cell_t; - -mp_obj_t mp_obj_cell_get(mp_obj_t self_in) { - mp_obj_cell_t *self = MP_OBJ_TO_PTR(self_in); - return self->obj; -} - -void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) { - mp_obj_cell_t *self = MP_OBJ_TO_PTR(self_in); - self->obj = obj; -} - -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED -STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_cell_t *o = MP_OBJ_TO_PTR(o_in); - mp_printf(print, "obj); - if (o->obj == MP_OBJ_NULL) { - mp_print_str(print, "(nil)"); - } else { - mp_obj_print_helper(print, o->obj, PRINT_REPR); - } - mp_print_str(print, ">"); -} -#endif - -STATIC const mp_obj_type_t mp_type_cell = { - { &mp_type_type }, - .name = MP_QSTR_, // cell representation is just value in < > -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED - .print = cell_print, -#endif -}; - -mp_obj_t mp_obj_new_cell(mp_obj_t obj) { - mp_obj_cell_t *o = m_new_obj(mp_obj_cell_t); - o->base.type = &mp_type_cell; - o->obj = obj; - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objclosure.c b/user/mpy/py/objclosure.c deleted file mode 100644 index 4eb9eb8..0000000 --- a/user/mpy/py/objclosure.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/obj.h" -#include "py/runtime.h" - -typedef struct _mp_obj_closure_t { - mp_obj_base_t base; - mp_obj_t fun; - size_t n_closed; - mp_obj_t closed[]; -} mp_obj_closure_t; - -STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in); - - // need to concatenate closed-over-vars and args - - size_t n_total = self->n_closed + n_args + 2 * n_kw; - if (n_total <= 5) { - // use stack to allocate temporary args array - mp_obj_t args2[5]; - memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); - memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - return mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); - } else { - // use heap to allocate temporary args array - mp_obj_t *args2 = m_new(mp_obj_t, n_total); - memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t)); - memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - mp_obj_t res = mp_call_function_n_kw(self->fun, self->n_closed + n_args, n_kw, args2); - m_del(mp_obj_t, args2, n_total); - return res; - } -} - -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED -STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_closure_t *o = MP_OBJ_TO_PTR(o_in); - mp_print_str(print, "fun, PRINT_REPR); - mp_printf(print, " at %p, n_closed=%u ", o, (int)o->n_closed); - for (size_t i = 0; i < o->n_closed; i++) { - if (o->closed[i] == MP_OBJ_NULL) { - mp_print_str(print, "(nil)"); - } else { - mp_obj_print_helper(print, o->closed[i], PRINT_REPR); - } - mp_print_str(print, " "); - } - mp_print_str(print, ">"); -} -#endif - -const mp_obj_type_t closure_type = { - { &mp_type_type }, - .name = MP_QSTR_closure, -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED - .print = closure_print, -#endif - .call = closure_call, -}; - -mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) { - mp_obj_closure_t *o = m_new_obj_var(mp_obj_closure_t, mp_obj_t, n_closed_over); - o->base.type = &closure_type; - o->fun = fun; - o->n_closed = n_closed_over; - memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t)); - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objcomplex.c b/user/mpy/py/objcomplex.c deleted file mode 100644 index f945f35..0000000 --- a/user/mpy/py/objcomplex.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/parsenum.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_COMPLEX - -#include -#include "py/formatfloat.h" - -typedef struct _mp_obj_complex_t { - mp_obj_base_t base; - mp_float_t real; - mp_float_t imag; -} mp_obj_complex_t; - -STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in); -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - char buf[16]; - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C - const int precision = 6; - #else - const int precision = 7; - #endif -#else - char buf[32]; - const int precision = 16; -#endif - if (o->real == 0) { - mp_format_float(o->imag, buf, sizeof(buf), 'g', precision, '\0'); - mp_printf(print, "%sj", buf); - } else { - mp_format_float(o->real, buf, sizeof(buf), 'g', precision, '\0'); - mp_printf(print, "(%s", buf); - if (o->imag >= 0 || isnan(o->imag)) { - mp_print_str(print, "+"); - } - mp_format_float(o->imag, buf, sizeof(buf), 'g', precision, '\0'); - mp_printf(print, "%sj)", buf); - } -} - -STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 2, false); - - switch (n_args) { - case 0: - return mp_obj_new_complex(0, 0); - - case 1: - if (MP_OBJ_IS_STR(args[0])) { - // a string, parse it - size_t l; - const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_decimal(s, l, true, true, NULL); - } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { - // a complex, just return it - return args[0]; - } else { - // something else, try to cast it to a complex - return mp_obj_new_complex(mp_obj_get_float(args[0]), 0); - } - - case 2: - default: { - mp_float_t real, imag; - if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { - mp_obj_complex_get(args[0], &real, &imag); - } else { - real = mp_obj_get_float(args[0]); - imag = 0; - } - if (MP_OBJ_IS_TYPE(args[1], &mp_type_complex)) { - mp_float_t real2, imag2; - mp_obj_complex_get(args[1], &real2, &imag2); - real -= imag2; - imag += real2; - } else { - imag += mp_obj_get_float(args[1]); - } - return mp_obj_new_complex(real, imag); - } - } -} - -STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) { - mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->real != 0 || o->imag != 0); - case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(o->real) ^ mp_float_hash(o->imag)); - case MP_UNARY_OP_POSITIVE: return o_in; - case MP_UNARY_OP_NEGATIVE: return mp_obj_new_complex(-o->real, -o->imag); - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t complex_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_complex_t *lhs = MP_OBJ_TO_PTR(lhs_in); - return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in); -} - -STATIC void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != MP_OBJ_NULL) { - // not load attribute - return; - } - mp_obj_complex_t *self = MP_OBJ_TO_PTR(self_in); - if (attr == MP_QSTR_real) { - dest[0] = mp_obj_new_float(self->real); - } else if (attr == MP_QSTR_imag) { - dest[0] = mp_obj_new_float(self->imag); - } -} - -const mp_obj_type_t mp_type_complex = { - { &mp_type_type }, - .name = MP_QSTR_complex, - .print = complex_print, - .make_new = complex_make_new, - .unary_op = complex_unary_op, - .binary_op = complex_binary_op, - .attr = complex_attr, -}; - -mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag) { - mp_obj_complex_t *o = m_new_obj(mp_obj_complex_t); - o->base.type = &mp_type_complex; - o->real = real; - o->imag = imag; - return MP_OBJ_FROM_PTR(o); -} - -void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_complex)); - mp_obj_complex_t *self = MP_OBJ_TO_PTR(self_in); - *real = self->real; - *imag = self->imag; -} - -mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in) { - mp_float_t rhs_real, rhs_imag; - mp_obj_get_complex(rhs_in, &rhs_real, &rhs_imag); // can be any type, this function will convert to float (if possible) - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: - lhs_real += rhs_real; - lhs_imag += rhs_imag; - break; - case MP_BINARY_OP_SUBTRACT: - case MP_BINARY_OP_INPLACE_SUBTRACT: - lhs_real -= rhs_real; - lhs_imag -= rhs_imag; - break; - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: { - mp_float_t real; - multiply: - real = lhs_real * rhs_real - lhs_imag * rhs_imag; - lhs_imag = lhs_real * rhs_imag + lhs_imag * rhs_real; - lhs_real = real; - break; - } - case MP_BINARY_OP_FLOOR_DIVIDE: - case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: - mp_raise_TypeError("can't do truncated division of a complex number"); - - case MP_BINARY_OP_TRUE_DIVIDE: - case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: - if (rhs_imag == 0) { - if (rhs_real == 0) { - mp_raise_msg(&mp_type_ZeroDivisionError, "complex division by zero"); - } - lhs_real /= rhs_real; - lhs_imag /= rhs_real; - } else if (rhs_real == 0) { - mp_float_t real = lhs_imag / rhs_imag; - lhs_imag = -lhs_real / rhs_imag; - lhs_real = real; - } else { - mp_float_t rhs_len_sq = rhs_real*rhs_real + rhs_imag*rhs_imag; - rhs_real /= rhs_len_sq; - rhs_imag /= -rhs_len_sq; - goto multiply; - } - break; - - case MP_BINARY_OP_POWER: - case MP_BINARY_OP_INPLACE_POWER: { - // z1**z2 = exp(z2*ln(z1)) - // = exp(z2*(ln(|z1|)+i*arg(z1))) - // = exp( (x2*ln1 - y2*arg1) + i*(y2*ln1 + x2*arg1) ) - // = exp(x3 + i*y3) - // = exp(x3)*(cos(y3) + i*sin(y3)) - mp_float_t abs1 = MICROPY_FLOAT_C_FUN(sqrt)(lhs_real*lhs_real + lhs_imag*lhs_imag); - if (abs1 == 0) { - if (rhs_imag == 0 && rhs_real >= 0) { - lhs_real = (rhs_real == 0); - rhs_real = 0; - } else { - mp_raise_msg(&mp_type_ZeroDivisionError, "0.0 to a complex power"); - } - } else { - mp_float_t ln1 = MICROPY_FLOAT_C_FUN(log)(abs1); - mp_float_t arg1 = MICROPY_FLOAT_C_FUN(atan2)(lhs_imag, lhs_real); - mp_float_t x3 = rhs_real * ln1 - rhs_imag * arg1; - mp_float_t y3 = rhs_imag * ln1 + rhs_real * arg1; - mp_float_t exp_x3 = MICROPY_FLOAT_C_FUN(exp)(x3); - lhs_real = exp_x3 * MICROPY_FLOAT_C_FUN(cos)(y3); - lhs_imag = exp_x3 * MICROPY_FLOAT_C_FUN(sin)(y3); - } - break; - } - - case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_real == rhs_real && lhs_imag == rhs_imag); - - default: - return MP_OBJ_NULL; // op not supported - } - return mp_obj_new_complex(lhs_real, lhs_imag); -} - -#endif diff --git a/user/mpy/py/objdict.c b/user/mpy/py/objdict.c deleted file mode 100644 index f6357a9..0000000 --- a/user/mpy/py/objdict.c +++ /dev/null @@ -1,615 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/builtin.h" -#include "py/objtype.h" - -#define MP_OBJ_IS_DICT_TYPE(o) (MP_OBJ_IS_OBJ(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new) - -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); - -// This is a helper function to iterate through a dictionary. The state of -// the iteration is held in *cur and should be initialised with zero for the -// first call. Will return NULL when no more elements are available. -STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) { - size_t max = dict->map.alloc; - mp_map_t *map = &dict->map; - - for (size_t i = *cur; i < max; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - *cur = i + 1; - return &(map->table[i]); - } - } - - return NULL; -} - -STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - bool first = true; - if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { - kind = PRINT_REPR; - } - if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) { - mp_printf(print, "%q(", self->base.type->name); - } - mp_print_str(print, "{"); - size_t cur = 0; - mp_map_elem_t *next = NULL; - while ((next = dict_iter_next(self, &cur)) != NULL) { - if (!first) { - mp_print_str(print, ", "); - } - first = false; - mp_obj_print_helper(print, next->key, kind); - mp_print_str(print, ": "); - mp_obj_print_helper(print, next->value, kind); - } - mp_print_str(print, "}"); - if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) { - mp_print_str(print, ")"); - } -} - -STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_t dict_out = mp_obj_new_dict(0); - mp_obj_dict_t *dict = MP_OBJ_TO_PTR(dict_out); - dict->base.type = type; - #if MICROPY_PY_COLLECTIONS_ORDEREDDICT - if (type == &mp_type_ordereddict) { - dict->map.is_ordered = 1; - } - #endif - if (n_args > 0 || n_kw > 0) { - mp_obj_t args2[2] = {dict_out, args[0]}; // args[0] is always valid, even if it's not a positional arg - mp_map_t kwargs; - mp_map_init_fixed_table(&kwargs, n_kw, args + n_args); - dict_update(n_args + 1, args2, &kwargs); // dict_update will check that n_args + 1 == 1 or 2 - } - return dict_out; -} - -STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->map.used); - #if MICROPY_PY_SYS_GETSIZEOF - case MP_UNARY_OP_SIZEOF: { - size_t sz = sizeof(*self) + sizeof(*self->map.table) * self->map.alloc; - return MP_OBJ_NEW_SMALL_INT(sz); - } - #endif - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in); - switch (op) { - case MP_BINARY_OP_IN: { - mp_map_elem_t *elem = mp_map_lookup(&o->map, rhs_in, MP_MAP_LOOKUP); - return mp_obj_new_bool(elem != NULL); - } - case MP_BINARY_OP_EQUAL: { - #if MICROPY_PY_COLLECTIONS_ORDEREDDICT - if (MP_UNLIKELY(MP_OBJ_IS_TYPE(lhs_in, &mp_type_ordereddict) && MP_OBJ_IS_TYPE(rhs_in, &mp_type_ordereddict))) { - // Iterate through both dictionaries simultaneously and compare keys and values. - mp_obj_dict_t *rhs = MP_OBJ_TO_PTR(rhs_in); - size_t c1 = 0, c2 = 0; - mp_map_elem_t *e1 = dict_iter_next(o, &c1), *e2 = dict_iter_next(rhs, &c2); - for (; e1 != NULL && e2 != NULL; e1 = dict_iter_next(o, &c1), e2 = dict_iter_next(rhs, &c2)) { - if (!mp_obj_equal(e1->key, e2->key) || !mp_obj_equal(e1->value, e2->value)) { - return mp_const_false; - } - } - return e1 == NULL && e2 == NULL ? mp_const_true : mp_const_false; - } else - #endif - if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_dict)) { - mp_obj_dict_t *rhs = MP_OBJ_TO_PTR(rhs_in); - if (o->map.used != rhs->map.used) { - return mp_const_false; - } - - size_t cur = 0; - mp_map_elem_t *next = NULL; - while ((next = dict_iter_next(o, &cur)) != NULL) { - mp_map_elem_t *elem = mp_map_lookup(&rhs->map, next->key, MP_MAP_LOOKUP); - if (elem == NULL || !mp_obj_equal(next->value, elem->value)) { - return mp_const_false; - } - } - return mp_const_true; - } else { - // dict is not equal to instance of any other type - return mp_const_false; - } - } - default: - // op not supported - return MP_OBJ_NULL; - } -} - -// TODO: Make sure this is inlined in dict_subscr() below. -mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); - if (elem == NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, index)); - } else { - return elem->value; - } -} - -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == MP_OBJ_NULL) { - // delete - mp_obj_dict_delete(self_in, index); - return mp_const_none; - } else if (value == MP_OBJ_SENTINEL) { - // load - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); - if (elem == NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, index)); - } else { - return elem->value; - } - } else { - // store - mp_obj_dict_store(self_in, index, value); - return mp_const_none; - } -} - -/******************************************************************************/ -/* dict iterator */ - -typedef struct _mp_obj_dict_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t dict; - size_t cur; -} mp_obj_dict_it_t; - -STATIC mp_obj_t dict_it_iternext(mp_obj_t self_in) { - mp_obj_dict_it_t *self = MP_OBJ_TO_PTR(self_in); - mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur); - - if (next == NULL) { - return MP_OBJ_STOP_ITERATION; - } else { - return next->key; - } -} - -STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_dict_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_dict_it_t *o = (mp_obj_dict_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = dict_it_iternext; - o->dict = self_in; - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} - -/******************************************************************************/ -/* dict methods */ - -STATIC mp_obj_t dict_clear(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - - mp_map_clear(&self->map); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear); - -STATIC mp_obj_t dict_copy(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t other_out = mp_obj_new_dict(self->map.alloc); - mp_obj_dict_t *other = MP_OBJ_TO_PTR(other_out); - other->base.type = self->base.type; - other->map.used = self->map.used; - other->map.all_keys_are_qstrs = self->map.all_keys_are_qstrs; - other->map.is_fixed = 0; - other->map.is_ordered = self->map.is_ordered; - memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t)); - return other_out; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, dict_copy); - -// this is a classmethod -STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) { - mp_obj_t iter = mp_getiter(args[1], NULL); - mp_obj_t value = mp_const_none; - mp_obj_t next = MP_OBJ_NULL; - - if (n_args > 2) { - value = args[2]; - } - - // optimisation to allocate result based on len of argument - mp_obj_t self_out; - mp_obj_t len = mp_obj_len_maybe(args[1]); - if (len == MP_OBJ_NULL) { - /* object's type doesn't have a __len__ slot */ - self_out = mp_obj_new_dict(0); - } else { - self_out = mp_obj_new_dict(MP_OBJ_SMALL_INT_VALUE(len)); - } - - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_out); - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_map_lookup(&self->map, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - } - - return self_out; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys); -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj)); - -STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(args[0])); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]); - mp_map_elem_t *elem = mp_map_lookup(&self->map, args[1], lookup_kind); - mp_obj_t value; - if (elem == NULL || elem->value == MP_OBJ_NULL) { - if (n_args == 2) { - if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, args[1])); - } else { - value = mp_const_none; - } - } else { - value = args[2]; - } - if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { - elem->value = value; - } - } else { - value = elem->value; - if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - elem->value = MP_OBJ_NULL; // so that GC can collect the deleted value - } - } - return value; -} - -STATIC mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) { - return dict_get_helper(n_args, args, MP_MAP_LOOKUP); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get); - -STATIC mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) { - return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop); - -STATIC mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) { - return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault); - -STATIC mp_obj_t dict_popitem(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - size_t cur = 0; - mp_map_elem_t *next = dict_iter_next(self, &cur); - if (next == NULL) { - mp_raise_msg(&mp_type_KeyError, "popitem(): dictionary is empty"); - } - self->map.used--; - mp_obj_t items[] = {next->key, next->value}; - next->key = MP_OBJ_SENTINEL; // must mark key as sentinel to indicate that it was deleted - next->value = MP_OBJ_NULL; - mp_obj_t tuple = mp_obj_new_tuple(2, items); - - return tuple; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem); - -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(args[0])); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]); - - mp_arg_check_num(n_args, kwargs->used, 1, 2, true); - - if (n_args == 2) { - // given a positional argument - - if (MP_OBJ_IS_DICT_TYPE(args[1])) { - // update from other dictionary (make sure other is not self) - if (args[1] != args[0]) { - size_t cur = 0; - mp_map_elem_t *elem = NULL; - while ((elem = dict_iter_next((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[1]), &cur)) != NULL) { - mp_map_lookup(&self->map, elem->key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = elem->value; - } - } - } else { - // update from a generic iterable of pairs - mp_obj_t iter = mp_getiter(args[1], NULL); - mp_obj_t next = MP_OBJ_NULL; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_t inneriter = mp_getiter(next, NULL); - mp_obj_t key = mp_iternext(inneriter); - mp_obj_t value = mp_iternext(inneriter); - mp_obj_t stop = mp_iternext(inneriter); - if (key == MP_OBJ_STOP_ITERATION - || value == MP_OBJ_STOP_ITERATION - || stop != MP_OBJ_STOP_ITERATION) { - mp_raise_ValueError("dict update sequence has wrong length"); - } else { - mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - } - } - } - } - - // update the dict with any keyword args - for (size_t i = 0; i < kwargs->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) { - mp_map_lookup(&self->map, kwargs->table[i].key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = kwargs->table[i].value; - } - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update); - - -/******************************************************************************/ -/* dict views */ - -STATIC const mp_obj_type_t dict_view_type; -STATIC const mp_obj_type_t dict_view_it_type; - -typedef enum _mp_dict_view_kind_t { - MP_DICT_VIEW_ITEMS, - MP_DICT_VIEW_KEYS, - MP_DICT_VIEW_VALUES, -} mp_dict_view_kind_t; - -STATIC const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"}; - -typedef struct _mp_obj_dict_view_it_t { - mp_obj_base_t base; - mp_dict_view_kind_t kind; - mp_obj_t dict; - size_t cur; -} mp_obj_dict_view_it_t; - -typedef struct _mp_obj_dict_view_t { - mp_obj_base_t base; - mp_obj_t dict; - mp_dict_view_kind_t kind; -} mp_obj_dict_view_t; - -STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &dict_view_it_type)); - mp_obj_dict_view_it_t *self = MP_OBJ_TO_PTR(self_in); - mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur); - - if (next == NULL) { - return MP_OBJ_STOP_ITERATION; - } else { - switch (self->kind) { - case MP_DICT_VIEW_ITEMS: - default: { - mp_obj_t items[] = {next->key, next->value}; - return mp_obj_new_tuple(2, items); - } - case MP_DICT_VIEW_KEYS: - return next->key; - case MP_DICT_VIEW_VALUES: - return next->value; - } - } -} - -STATIC const mp_obj_type_t dict_view_it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = dict_view_it_iternext, -}; - -STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_check_self(MP_OBJ_IS_TYPE(view_in, &dict_view_type)); - mp_obj_dict_view_t *view = MP_OBJ_TO_PTR(view_in); - mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t*)iter_buf; - o->base.type = &dict_view_it_type; - o->kind = view->kind; - o->dict = view->dict; - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} - -STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_check_self(MP_OBJ_IS_TYPE(self_in, &dict_view_type)); - mp_obj_dict_view_t *self = MP_OBJ_TO_PTR(self_in); - bool first = true; - mp_print_str(print, mp_dict_view_names[self->kind]); - mp_print_str(print, "(["); - mp_obj_iter_buf_t iter_buf; - mp_obj_t self_iter = dict_view_getiter(self_in, &iter_buf); - mp_obj_t next = MP_OBJ_NULL; - while ((next = dict_view_it_iternext(self_iter)) != MP_OBJ_STOP_ITERATION) { - if (!first) { - mp_print_str(print, ", "); - } - first = false; - mp_obj_print_helper(print, next, PRINT_REPR); - } - mp_print_str(print, "])"); -} - -STATIC mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - // only supported for the 'keys' kind until sets and dicts are refactored - mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in); - if (o->kind != MP_DICT_VIEW_KEYS) { - return MP_OBJ_NULL; // op not supported - } - if (op != MP_BINARY_OP_IN) { - return MP_OBJ_NULL; // op not supported - } - return dict_binary_op(op, o->dict, rhs_in); -} - -STATIC const mp_obj_type_t dict_view_type = { - { &mp_type_type }, - .name = MP_QSTR_dict_view, - .print = dict_view_print, - .binary_op = dict_view_binary_op, - .getiter = dict_view_getiter, -}; - -STATIC mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) { - mp_obj_dict_view_t *o = m_new_obj(mp_obj_dict_view_t); - o->base.type = &dict_view_type; - o->dict = dict; - o->kind = kind; - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); - return mp_obj_new_dict_view(self_in, kind); -} - -STATIC mp_obj_t dict_items(mp_obj_t self_in) { - return dict_view(self_in, MP_DICT_VIEW_ITEMS); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items); - -STATIC mp_obj_t dict_keys(mp_obj_t self_in) { - return dict_view(self_in, MP_DICT_VIEW_KEYS); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys); - -STATIC mp_obj_t dict_values(mp_obj_t self_in) { - return dict_view(self_in, MP_DICT_VIEW_VALUES); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values); - -/******************************************************************************/ -/* dict constructors & public C API */ - -STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&dict_clear_obj) }, - { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&dict_copy_obj) }, - { MP_ROM_QSTR(MP_QSTR_fromkeys), MP_ROM_PTR(&dict_fromkeys_obj) }, - { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&dict_get_obj) }, - { MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&dict_items_obj) }, - { MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&dict_keys_obj) }, - { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&dict_pop_obj) }, - { MP_ROM_QSTR(MP_QSTR_popitem), MP_ROM_PTR(&dict_popitem_obj) }, - { MP_ROM_QSTR(MP_QSTR_setdefault), MP_ROM_PTR(&dict_setdefault_obj) }, - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&dict_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_values), MP_ROM_PTR(&dict_values_obj) }, - { MP_ROM_QSTR(MP_QSTR___getitem__), MP_ROM_PTR(&mp_op_getitem_obj) }, - { MP_ROM_QSTR(MP_QSTR___setitem__), MP_ROM_PTR(&mp_op_setitem_obj) }, - { MP_ROM_QSTR(MP_QSTR___delitem__), MP_ROM_PTR(&mp_op_delitem_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table); - -const mp_obj_type_t mp_type_dict = { - { &mp_type_type }, - .name = MP_QSTR_dict, - .print = dict_print, - .make_new = dict_make_new, - .unary_op = dict_unary_op, - .binary_op = dict_binary_op, - .subscr = dict_subscr, - .getiter = dict_getiter, - .locals_dict = (mp_obj_dict_t*)&dict_locals_dict, -}; - -#if MICROPY_PY_COLLECTIONS_ORDEREDDICT -const mp_obj_type_t mp_type_ordereddict = { - { &mp_type_type }, - .name = MP_QSTR_OrderedDict, - .print = dict_print, - .make_new = dict_make_new, - .unary_op = dict_unary_op, - .binary_op = dict_binary_op, - .subscr = dict_subscr, - .getiter = dict_getiter, - .parent = &mp_type_dict, - .locals_dict = (mp_obj_dict_t*)&dict_locals_dict, -}; -#endif - -void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args) { - dict->base.type = &mp_type_dict; - mp_map_init(&dict->map, n_args); -} - -mp_obj_t mp_obj_new_dict(size_t n_args) { - mp_obj_dict_t *o = m_new_obj(mp_obj_dict_t); - mp_obj_dict_init(o, n_args); - return MP_OBJ_FROM_PTR(o); -} - -size_t mp_obj_dict_len(mp_obj_t self_in) { - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - return self->map.used; -} - -mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - return self_in; -} - -mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key) { - mp_obj_t args[2] = {self_in, key}; - dict_get_helper(2, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND); - return self_in; -} - -mp_map_t *mp_obj_dict_get_map(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in)); - mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); - return &self->map; -} diff --git a/user/mpy/py/objenumerate.c b/user/mpy/py/objenumerate.c deleted file mode 100644 index 1a9d30f..0000000 --- a/user/mpy/py/objenumerate.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_ENUMERATE - -typedef struct _mp_obj_enumerate_t { - mp_obj_base_t base; - mp_obj_t iter; - mp_int_t cur; -} mp_obj_enumerate_t; - -STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in); - -STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { -#if MICROPY_CPYTHON_COMPAT - static const mp_arg_t allowed_args[] = { - { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_start, MP_ARG_INT, {.u_int = 0} }, - }; - - // parse args - struct { - mp_arg_val_t iterable, start; - } arg_vals; - mp_arg_parse_all_kw_array(n_args, n_kw, args, - MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&arg_vals); - - // create enumerate object - mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); - o->base.type = type; - o->iter = mp_getiter(arg_vals.iterable.u_obj, NULL); - o->cur = arg_vals.start.u_int; -#else - (void)n_kw; - mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); - o->base.type = type; - o->iter = mp_getiter(args[0], NULL); - o->cur = n_args > 1 ? mp_obj_get_int(args[1]) : 0; -#endif - - return MP_OBJ_FROM_PTR(o); -} - -const mp_obj_type_t mp_type_enumerate = { - { &mp_type_type }, - .name = MP_QSTR_enumerate, - .make_new = enumerate_make_new, - .iternext = enumerate_iternext, - .getiter = mp_identity_getiter, -}; - -STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_enumerate)); - mp_obj_enumerate_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t next = mp_iternext(self->iter); - if (next == MP_OBJ_STOP_ITERATION) { - return MP_OBJ_STOP_ITERATION; - } else { - mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(self->cur++), next}; - return mp_obj_new_tuple(2, items); - } -} - -#endif // MICROPY_PY_BUILTINS_ENUMERATE diff --git a/user/mpy/py/objexcept.c b/user/mpy/py/objexcept.c deleted file mode 100644 index a9fe040..0000000 --- a/user/mpy/py/objexcept.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/mpstate.h" -#include "py/objlist.h" -#include "py/objstr.h" -#include "py/objtuple.h" -#include "py/objtype.h" -#include "py/runtime.h" -#include "py/gc.h" -#include "py/mperrno.h" - -// Instance of MemoryError exception - needed by mp_malloc_fail -const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; - -// Optionally allocated buffer for storing the first argument of an exception -// allocated when the heap is locked. -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF -# if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0 -#define mp_emergency_exception_buf_size MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE - -void mp_init_emergency_exception_buf(void) { - // Nothing to do since the buffer was declared statically. We put this - // definition here so that the calling code can call this function - // regardless of how its configured (makes the calling code a bit cleaner). -} - -#else -#define mp_emergency_exception_buf_size MP_STATE_VM(mp_emergency_exception_buf_size) - -void mp_init_emergency_exception_buf(void) { - mp_emergency_exception_buf_size = 0; - MP_STATE_VM(mp_emergency_exception_buf) = NULL; -} - -mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in) { - mp_int_t size = mp_obj_get_int(size_in); - void *buf = NULL; - if (size > 0) { - buf = m_new(byte, size); - } - - int old_size = mp_emergency_exception_buf_size; - void *old_buf = MP_STATE_VM(mp_emergency_exception_buf); - - // Update the 2 variables atomically so that an interrupt can't occur - // between the assignments. - mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); - mp_emergency_exception_buf_size = size; - MP_STATE_VM(mp_emergency_exception_buf) = buf; - MICROPY_END_ATOMIC_SECTION(atomic_state); - - if (old_buf != NULL) { - m_del(byte, old_buf, old_size); - } - return mp_const_none; -} -#endif -#endif // MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - -// Instance of GeneratorExit exception - needed by generator.close() -// This would belong to objgenerator.c, but to keep mp_obj_exception_t -// definition module-private so far, have it here. -const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}; - -STATIC void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_exception_t *o = MP_OBJ_TO_PTR(o_in); - mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; - bool is_subclass = kind & PRINT_EXC_SUBCLASS; - if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) { - mp_print_str(print, qstr_str(o->base.type->name)); - } - - if (k == PRINT_EXC) { - mp_print_str(print, ": "); - } - - if (k == PRINT_STR || k == PRINT_EXC) { - if (o->args == NULL || o->args->len == 0) { - mp_print_str(print, ""); - return; - } else if (o->args->len == 1) { - #if MICROPY_PY_UERRNO - // try to provide a nice OSError error message - if (o->base.type == &mp_type_OSError && MP_OBJ_IS_SMALL_INT(o->args->items[0])) { - qstr qst = mp_errno_to_str(o->args->items[0]); - if (qst != MP_QSTR_NULL) { - mp_printf(print, "[Errno %d] %q", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), qst); - return; - } - } - #endif - mp_obj_print_helper(print, o->args->items[0], PRINT_STR); - return; - } - } - mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind); -} - -mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); - mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0); - if (o == NULL) { - // Couldn't allocate heap memory; use local data instead. - o = &MP_STATE_VM(mp_emergency_exception_obj); - // We can't store any args. - o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; - } else { - o->args = MP_OBJ_TO_PTR(mp_obj_new_tuple(n_args, args)); - } - o->base.type = type; - o->traceback_data = NULL; - return MP_OBJ_FROM_PTR(o); -} - -// Get exception "value" - that is, first argument, or None -mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) { - mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in); - if (self->args->len == 0) { - return mp_const_none; - } else { - return self->args->items[0]; - } -} - -STATIC void exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in); - if (dest[0] != MP_OBJ_NULL) { - // store/delete attribute - if (attr == MP_QSTR___traceback__ && dest[1] == mp_const_none) { - // We allow 'exc.__traceback__ = None' assignment as low-level - // optimization of pre-allocating exception instance and raising - // it repeatedly - this avoids memory allocation during raise. - // However, uPy will keep adding traceback entries to such - // exception instance, so before throwing it, traceback should - // be cleared like above. - self->traceback_len = 0; - dest[0] = MP_OBJ_NULL; // indicate success - } - return; - } - if (attr == MP_QSTR_args) { - dest[0] = MP_OBJ_FROM_PTR(self->args); - } else if (self->base.type == &mp_type_StopIteration && attr == MP_QSTR_value) { - dest[0] = mp_obj_exception_get_value(self_in); - } -} - -STATIC mp_obj_t exc___init__(size_t n_args, const mp_obj_t *args) { - mp_obj_exception_t *self = MP_OBJ_TO_PTR(args[0]); - mp_obj_t argst = mp_obj_new_tuple(n_args - 1, args + 1); - self->args = MP_OBJ_TO_PTR(argst); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(exc___init___obj, 1, MP_OBJ_FUN_ARGS_MAX, exc___init__); - -STATIC const mp_rom_map_elem_t exc_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&exc___init___obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(exc_locals_dict, exc_locals_dict_table); - -const mp_obj_type_t mp_type_BaseException = { - { &mp_type_type }, - .name = MP_QSTR_BaseException, - .print = mp_obj_exception_print, - .make_new = mp_obj_exception_make_new, - .attr = exception_attr, - .locals_dict = (mp_obj_dict_t*)&exc_locals_dict, -}; - -#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 = exception_attr, \ - .parent = &mp_type_ ## base_name, \ -}; - -// List of all exceptions, arranged as in the table at: -// http://docs.python.org/3/library/exceptions.html -MP_DEFINE_EXCEPTION(SystemExit, BaseException) -MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException) -MP_DEFINE_EXCEPTION(GeneratorExit, BaseException) -MP_DEFINE_EXCEPTION(Exception, BaseException) - #if MICROPY_PY_ASYNC_AWAIT - MP_DEFINE_EXCEPTION(StopAsyncIteration, Exception) - #endif - MP_DEFINE_EXCEPTION(StopIteration, Exception) - MP_DEFINE_EXCEPTION(ArithmeticError, Exception) - //MP_DEFINE_EXCEPTION(FloatingPointError, ArithmeticError) - MP_DEFINE_EXCEPTION(OverflowError, ArithmeticError) - MP_DEFINE_EXCEPTION(ZeroDivisionError, ArithmeticError) - MP_DEFINE_EXCEPTION(AssertionError, Exception) - MP_DEFINE_EXCEPTION(AttributeError, Exception) - //MP_DEFINE_EXCEPTION(BufferError, Exception) - //MP_DEFINE_EXCEPTION(EnvironmentError, Exception) use OSError instead - MP_DEFINE_EXCEPTION(EOFError, Exception) - MP_DEFINE_EXCEPTION(ImportError, Exception) - //MP_DEFINE_EXCEPTION(IOError, Exception) use OSError instead - MP_DEFINE_EXCEPTION(LookupError, Exception) - MP_DEFINE_EXCEPTION(IndexError, LookupError) - MP_DEFINE_EXCEPTION(KeyError, LookupError) - MP_DEFINE_EXCEPTION(MemoryError, Exception) - MP_DEFINE_EXCEPTION(NameError, Exception) - /* - MP_DEFINE_EXCEPTION(UnboundLocalError, NameError) - */ - MP_DEFINE_EXCEPTION(OSError, Exception) -#if MICROPY_PY_BUILTINS_TIMEOUTERROR - MP_DEFINE_EXCEPTION(TimeoutError, OSError) -#endif - /* - MP_DEFINE_EXCEPTION(BlockingIOError, OSError) - MP_DEFINE_EXCEPTION(ChildProcessError, OSError) - MP_DEFINE_EXCEPTION(ConnectionError, OSError) - MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError) - MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError) - MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError) - MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError) - MP_DEFINE_EXCEPTION(InterruptedError, OSError) - MP_DEFINE_EXCEPTION(IsADirectoryError, OSError) - MP_DEFINE_EXCEPTION(NotADirectoryError, OSError) - MP_DEFINE_EXCEPTION(PermissionError, OSError) - MP_DEFINE_EXCEPTION(ProcessLookupError, OSError) - MP_DEFINE_EXCEPTION(FileExistsError, OSError) - MP_DEFINE_EXCEPTION(FileNotFoundError, OSError) - MP_DEFINE_EXCEPTION(ReferenceError, Exception) - */ - MP_DEFINE_EXCEPTION(RuntimeError, Exception) - MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError) - MP_DEFINE_EXCEPTION(SyntaxError, Exception) - MP_DEFINE_EXCEPTION(IndentationError, SyntaxError) - /* - MP_DEFINE_EXCEPTION(TabError, IndentationError) - */ - //MP_DEFINE_EXCEPTION(SystemError, Exception) - MP_DEFINE_EXCEPTION(TypeError, Exception) -#if MICROPY_EMIT_NATIVE - MP_DEFINE_EXCEPTION(ViperTypeError, TypeError) -#endif - MP_DEFINE_EXCEPTION(ValueError, Exception) -#if MICROPY_PY_BUILTINS_STR_UNICODE - MP_DEFINE_EXCEPTION(UnicodeError, ValueError) - //TODO: Implement more UnicodeError subclasses which take arguments -#endif - /* - MP_DEFINE_EXCEPTION(Warning, Exception) - MP_DEFINE_EXCEPTION(DeprecationWarning, Warning) - MP_DEFINE_EXCEPTION(PendingDeprecationWarning, Warning) - MP_DEFINE_EXCEPTION(RuntimeWarning, Warning) - MP_DEFINE_EXCEPTION(SyntaxWarning, Warning) - MP_DEFINE_EXCEPTION(UserWarning, Warning) - MP_DEFINE_EXCEPTION(FutureWarning, Warning) - MP_DEFINE_EXCEPTION(ImportWarning, Warning) - MP_DEFINE_EXCEPTION(UnicodeWarning, Warning) - MP_DEFINE_EXCEPTION(BytesWarning, Warning) - MP_DEFINE_EXCEPTION(ResourceWarning, Warning) - */ - -mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) { - return mp_obj_new_exception_args(exc_type, 0, NULL); -} - -// "Optimized" version for common(?) case of having 1 exception arg -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { - return mp_obj_new_exception_args(exc_type, 1, &arg); -} - -mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args) { - assert(exc_type->make_new == mp_obj_exception_make_new); - return exc_type->make_new(exc_type, n_args, 0, args); -} - -mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg) { - return mp_obj_new_exception_msg_varg(exc_type, msg); -} - -mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...) { - // check that the given type is an exception type - assert(exc_type->make_new == mp_obj_exception_make_new); - - // make exception object - mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0); - if (o == NULL) { - // Couldn't allocate heap memory; use local data instead. - // Unfortunately, we won't be able to format the string... - o = &MP_STATE_VM(mp_emergency_exception_obj); - o->base.type = exc_type; - o->traceback_data = NULL; - o->args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; - -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - // If the user has provided a buffer, then we try to create a tuple - // of length 1, which has a string object and the string data. - - if (mp_emergency_exception_buf_size > (sizeof(mp_obj_tuple_t) + sizeof(mp_obj_str_t) + sizeof(mp_obj_t))) { - mp_obj_tuple_t *tuple = (mp_obj_tuple_t *)MP_STATE_VM(mp_emergency_exception_buf); - mp_obj_str_t *str = (mp_obj_str_t *)&tuple->items[1]; - - tuple->base.type = &mp_type_tuple; - tuple->len = 1; - tuple->items[0] = MP_OBJ_FROM_PTR(str); - - byte *str_data = (byte *)&str[1]; - size_t max_len = (byte*)MP_STATE_VM(mp_emergency_exception_buf) + mp_emergency_exception_buf_size - - str_data; - - vstr_t vstr; - vstr_init_fixed_buf(&vstr, max_len, (char *)str_data); - - va_list ap; - va_start(ap, fmt); - vstr_vprintf(&vstr, fmt, ap); - va_end(ap); - - str->base.type = &mp_type_str; - str->hash = qstr_compute_hash(str_data, str->len); - str->len = vstr.len; - str->data = str_data; - - o->args = tuple; - - size_t offset = &str_data[str->len] - (byte*)MP_STATE_VM(mp_emergency_exception_buf); - offset += sizeof(void *) - 1; - offset &= ~(sizeof(void *) - 1); - - if ((mp_emergency_exception_buf_size - offset) > (sizeof(o->traceback_data[0]) * 3)) { - // We have room to store some traceback. - o->traceback_data = (size_t*)((byte *)MP_STATE_VM(mp_emergency_exception_buf) + offset); - o->traceback_alloc = ((byte*)MP_STATE_VM(mp_emergency_exception_buf) + mp_emergency_exception_buf_size - (byte *)o->traceback_data) / sizeof(o->traceback_data[0]); - o->traceback_len = 0; - } - } -#endif // MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - } else { - o->base.type = exc_type; - o->traceback_data = NULL; - o->args = MP_OBJ_TO_PTR(mp_obj_new_tuple(1, NULL)); - - assert(fmt != NULL); - { - if (strchr(fmt, '%') == NULL) { - // no formatting substitutions, avoid allocating vstr. - o->args->items[0] = mp_obj_new_str(fmt, strlen(fmt), false); - } else { - // render exception message and store as .args[0] - va_list ap; - vstr_t vstr; - vstr_init(&vstr, 16); - va_start(ap, fmt); - vstr_vprintf(&vstr, fmt, ap); - va_end(ap); - o->args->items[0] = mp_obj_new_str_from_vstr(&mp_type_str, &vstr); - } - } - } - - return MP_OBJ_FROM_PTR(o); -} - -// return true if the given object is an exception type -bool mp_obj_is_exception_type(mp_obj_t self_in) { - if (MP_OBJ_IS_TYPE(self_in, &mp_type_type)) { - // optimisation when self_in is a builtin exception - mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); - if (self->make_new == mp_obj_exception_make_new) { - return true; - } - } - return mp_obj_is_subclass_fast(self_in, MP_OBJ_FROM_PTR(&mp_type_BaseException)); -} - -// return true if the given object is an instance of an exception type -bool mp_obj_is_exception_instance(mp_obj_t self_in) { - return mp_obj_is_exception_type(MP_OBJ_FROM_PTR(mp_obj_get_type(self_in))); -} - -// Return true if exception (type or instance) is a subclass of given -// exception type. Assumes exc_type is a subclass of BaseException, as -// defined by mp_obj_is_exception_type(exc_type). -bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { - // if exc is an instance of an exception, then extract and use its type - if (mp_obj_is_exception_instance(exc)) { - exc = MP_OBJ_FROM_PTR(mp_obj_get_type(exc)); - } - return mp_obj_is_subclass_fast(exc, exc_type); -} - -// traceback handling functions - -#define GET_NATIVE_EXCEPTION(self, self_in) \ - /* make sure self_in is an exception instance */ \ - assert(mp_obj_is_exception_instance(self_in)); \ - mp_obj_exception_t *self; \ - if (mp_obj_is_native_exception_instance(self_in)) { \ - self = MP_OBJ_TO_PTR(self_in); \ - } else { \ - self = MP_OBJ_TO_PTR(((mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in))->subobj[0]); \ - } - -void mp_obj_exception_clear_traceback(mp_obj_t self_in) { - GET_NATIVE_EXCEPTION(self, self_in); - // just set the traceback to the null object - // we don't want to call any memory management functions here - self->traceback_data = NULL; -} - -void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { - GET_NATIVE_EXCEPTION(self, self_in); - - // append this traceback info to traceback data - // if memory allocation fails (eg because gc is locked), just return - - if (self->traceback_data == NULL) { - self->traceback_data = m_new_maybe(size_t, 3); - if (self->traceback_data == NULL) { - return; - } - self->traceback_alloc = 3; - self->traceback_len = 0; - } else if (self->traceback_len + 3 > self->traceback_alloc) { - // be conservative with growing traceback data - size_t *tb_data = m_renew_maybe(size_t, self->traceback_data, self->traceback_alloc, self->traceback_alloc + 3, true); - if (tb_data == NULL) { - return; - } - self->traceback_data = tb_data; - self->traceback_alloc += 3; - } - - size_t *tb_data = &self->traceback_data[self->traceback_len]; - self->traceback_len += 3; - tb_data[0] = file; - tb_data[1] = line; - tb_data[2] = block; -} - -void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values) { - GET_NATIVE_EXCEPTION(self, self_in); - - if (self->traceback_data == NULL) { - *n = 0; - *values = NULL; - } else { - *n = self->traceback_len; - *values = self->traceback_data; - } -} diff --git a/user/mpy/py/objexcept.h b/user/mpy/py/objexcept.h deleted file mode 100644 index f67651a..0000000 --- a/user/mpy/py/objexcept.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 - -#include "py/obj.h" -#include "py/objtuple.h" - -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; - -#endif // MICROPY_INCLUDED_PY_OBJEXCEPT_H diff --git a/user/mpy/py/objfilter.c b/user/mpy/py/objfilter.c deleted file mode 100644 index cb965d8..0000000 --- a/user/mpy/py/objfilter.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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. - */ - -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_FILTER - -typedef struct _mp_obj_filter_t { - mp_obj_base_t base; - mp_obj_t fun; - mp_obj_t iter; -} mp_obj_filter_t; - -STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, 2, false); - mp_obj_filter_t *o = m_new_obj(mp_obj_filter_t); - o->base.type = type; - o->fun = args[0]; - o->iter = mp_getiter(args[1], NULL); - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t filter_iternext(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_filter)); - mp_obj_filter_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t next; - while ((next = mp_iternext(self->iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_t val; - if (self->fun != mp_const_none) { - val = mp_call_function_n_kw(self->fun, 1, 0, &next); - } else { - val = next; - } - if (mp_obj_is_true(val)) { - return next; - } - } - return MP_OBJ_STOP_ITERATION; -} - -const mp_obj_type_t mp_type_filter = { - { &mp_type_type }, - .name = MP_QSTR_filter, - .make_new = filter_make_new, - .getiter = mp_identity_getiter, - .iternext = filter_iternext, -}; - -#endif // MICROPY_PY_BUILTINS_FILTER diff --git a/user/mpy/py/objfloat.c b/user/mpy/py/objfloat.c deleted file mode 100644 index 15edd81..0000000 --- a/user/mpy/py/objfloat.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/nlr.h" -#include "py/parsenum.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_FLOAT - -#include -#include "py/formatfloat.h" - -#if MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_C && MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D - -// M_E and M_PI are not part of the math.h standard and may not be defined -#ifndef M_E -#define M_E (2.7182818284590452354) -#endif -#ifndef M_PI -#define M_PI (3.14159265358979323846) -#endif - -typedef struct _mp_obj_float_t { - mp_obj_base_t base; - mp_float_t value; -} mp_obj_float_t; - -const mp_obj_float_t mp_const_float_e_obj = {{&mp_type_float}, M_E}; -const mp_obj_float_t mp_const_float_pi_obj = {{&mp_type_float}, M_PI}; - -#endif - -#if MICROPY_FLOAT_HIGH_QUALITY_HASH -// must return actual integer value if it fits in mp_int_t -mp_int_t mp_float_hash(mp_float_t src) { -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -typedef uint64_t mp_float_uint_t; -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -typedef uint32_t mp_float_uint_t; -#endif - union { - mp_float_t f; - #if MP_ENDIANNESS_LITTLE - struct { mp_float_uint_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; - #else - struct { mp_float_uint_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; - #endif - mp_float_uint_t i; - } u = {.f = src}; - - mp_int_t val; - const int adj_exp = (int)u.p.exp - MP_FLOAT_EXP_BIAS; - if (adj_exp < 0) { - // value < 1; must be sure to handle 0.0 correctly (ie return 0) - val = u.i; - } else { - // if adj_exp is max then: u.p.frc==0 indicates inf, else NaN - // else: 1 <= value - mp_float_uint_t frc = u.p.frc | ((mp_float_uint_t)1 << MP_FLOAT_FRAC_BITS); - - if (adj_exp <= MP_FLOAT_FRAC_BITS) { - // number may have a fraction; xor the integer part with the fractional part - val = (frc >> (MP_FLOAT_FRAC_BITS - adj_exp)) - ^ (frc & ((1 << (MP_FLOAT_FRAC_BITS - adj_exp)) - 1)); - } else if ((unsigned int)adj_exp < BITS_PER_BYTE * sizeof(mp_int_t) - 1) { - // the number is a (big) whole integer and will fit in val's signed-width - val = (mp_int_t)frc << (adj_exp - MP_FLOAT_FRAC_BITS); - } else { - // integer part will overflow val's width so just use what bits we can - val = frc; - } - } - - if (u.p.sgn) { - val = -val; - } - - return val; -} -#endif - -STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_float_t o_val = mp_obj_float_get(o_in); -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - char buf[16]; - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C - const int precision = 6; - #else - const int precision = 7; - #endif -#else - char buf[32]; - const int precision = 16; -#endif - mp_format_float(o_val, buf, sizeof(buf), 'g', precision, '\0'); - mp_print_str(print, buf); - if (strchr(buf, '.') == NULL && strchr(buf, 'e') == NULL && strchr(buf, 'n') == NULL) { - // Python floats always have decimal point (unless inf or nan) - mp_print_str(print, ".0"); - } -} - -STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 1, false); - - switch (n_args) { - case 0: - return mp_obj_new_float(0); - - case 1: - default: - if (MP_OBJ_IS_STR(args[0])) { - // a string, parse it - size_t l; - const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_decimal(s, l, false, false, NULL); - } else if (mp_obj_is_float(args[0])) { - // a float, just return it - return args[0]; - } else { - // something else, try to cast it to a float - return mp_obj_new_float(mp_obj_get_float(args[0])); - } - } -} - -STATIC mp_obj_t float_unary_op(mp_uint_t op, mp_obj_t o_in) { - mp_float_t val = mp_obj_float_get(o_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(val != 0); - case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(val)); - case MP_UNARY_OP_POSITIVE: return o_in; - case MP_UNARY_OP_NEGATIVE: return mp_obj_new_float(-val); - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t float_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_float_t lhs_val = mp_obj_float_get(lhs_in); -#if MICROPY_PY_BUILTINS_COMPLEX - if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) { - return mp_obj_complex_binary_op(op, lhs_val, 0, rhs_in); - } else -#endif - { - return mp_obj_float_binary_op(op, lhs_val, rhs_in); - } -} - -const mp_obj_type_t mp_type_float = { - { &mp_type_type }, - .name = MP_QSTR_float, - .print = float_print, - .make_new = float_make_new, - .unary_op = float_unary_op, - .binary_op = float_binary_op, -}; - -#if MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_C && MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D - -mp_obj_t mp_obj_new_float(mp_float_t value) { - mp_obj_float_t *o = m_new(mp_obj_float_t, 1); - o->base.type = &mp_type_float; - o->value = value; - return MP_OBJ_FROM_PTR(o); -} - -mp_float_t mp_obj_float_get(mp_obj_t self_in) { - assert(mp_obj_is_float(self_in)); - mp_obj_float_t *self = MP_OBJ_TO_PTR(self_in); - return self->value; -} - -#endif - -STATIC void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) { - // logic here follows that of CPython - // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations - // x == (x//y)*y + (x%y) - // divmod(x, y) == (x//y, x%y) - mp_float_t mod = MICROPY_FLOAT_C_FUN(fmod)(*x, *y); - mp_float_t div = (*x - mod) / *y; - - // Python specs require that mod has same sign as second operand - if (mod == 0.0) { - mod = MICROPY_FLOAT_C_FUN(copysign)(0.0, *y); - } else { - if ((mod < 0.0) != (*y < 0.0)) { - mod += *y; - div -= 1.0; - } - } - - mp_float_t floordiv; - if (div == 0.0) { - // if division is zero, take the correct sign of zero - floordiv = MICROPY_FLOAT_C_FUN(copysign)(0.0, *x / *y); - } else { - // Python specs require that x == (x//y)*y + (x%y) - floordiv = MICROPY_FLOAT_C_FUN(floor)(div); - if (div - floordiv > 0.5) { - floordiv += 1.0; - } - } - - // return results - *x = floordiv; - *y = mod; -} - -mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs_in) { - mp_float_t rhs_val = mp_obj_get_float(rhs_in); // can be any type, this function will convert to float (if possible) - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break; - case MP_BINARY_OP_SUBTRACT: - case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break; - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: lhs_val *= rhs_val; break; - case MP_BINARY_OP_FLOOR_DIVIDE: - case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: - if (rhs_val == 0) { - zero_division_error: - mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); - } - // Python specs require that x == (x//y)*y + (x%y) so we must - // call divmod to compute the correct floor division, which - // returns the floor divide in lhs_val. - mp_obj_float_divmod(&lhs_val, &rhs_val); - break; - case MP_BINARY_OP_TRUE_DIVIDE: - case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: - if (rhs_val == 0) { - goto zero_division_error; - } - lhs_val /= rhs_val; - break; - case MP_BINARY_OP_MODULO: - case MP_BINARY_OP_INPLACE_MODULO: - if (rhs_val == 0) { - goto zero_division_error; - } - lhs_val = MICROPY_FLOAT_C_FUN(fmod)(lhs_val, rhs_val); - // Python specs require that mod has same sign as second operand - if (lhs_val == 0.0) { - lhs_val = MICROPY_FLOAT_C_FUN(copysign)(0.0, rhs_val); - } else { - if ((lhs_val < 0.0) != (rhs_val < 0.0)) { - lhs_val += rhs_val; - } - } - break; - case MP_BINARY_OP_POWER: - case MP_BINARY_OP_INPLACE_POWER: - if (lhs_val == 0 && rhs_val < 0) { - goto zero_division_error; - } - lhs_val = MICROPY_FLOAT_C_FUN(pow)(lhs_val, rhs_val); - break; - case MP_BINARY_OP_DIVMOD: { - if (rhs_val == 0) { - goto zero_division_error; - } - mp_obj_float_divmod(&lhs_val, &rhs_val); - mp_obj_t tuple[2] = { - mp_obj_new_float(lhs_val), - mp_obj_new_float(rhs_val), - }; - return mp_obj_new_tuple(2, tuple); - } - case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val); - case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val); - case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_val == rhs_val); - case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val); - case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val); - - default: - return MP_OBJ_NULL; // op not supported - } - return mp_obj_new_float(lhs_val); -} - -#endif // MICROPY_PY_BUILTINS_FLOAT diff --git a/user/mpy/py/objfun.c b/user/mpy/py/objfun.c deleted file mode 100644 index 5606511..0000000 --- a/user/mpy/py/objfun.c +++ /dev/null @@ -1,573 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objtuple.h" -#include "py/objfun.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/bc.h" -#include "py/stackctrl.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#else // don't print debugging info -#define DEBUG_PRINT (0) -#define DEBUG_printf(...) (void)0 -#endif - -// Note: the "name" entry in mp_obj_type_t for a function type must be -// MP_QSTR_function because it is used to determine if an object is of generic -// function type. - -/******************************************************************************/ -/* builtin functions */ - -STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)args; - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_0)); - mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num(n_args, n_kw, 0, 0, false); - return self->fun._0(); -} - -const mp_obj_type_t mp_type_fun_builtin_0 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_0_call, - .unary_op = mp_generic_unary_op, -}; - -STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_1)); - mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num(n_args, n_kw, 1, 1, false); - return self->fun._1(args[0]); -} - -const mp_obj_type_t mp_type_fun_builtin_1 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_1_call, - .unary_op = mp_generic_unary_op, -}; - -STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_2)); - mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num(n_args, n_kw, 2, 2, false); - return self->fun._2(args[0], args[1]); -} - -const mp_obj_type_t mp_type_fun_builtin_2 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_2_call, - .unary_op = mp_generic_unary_op, -}; - -STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_3)); - mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num(n_args, n_kw, 3, 3, false); - return self->fun._3(args[0], args[1], args[2]); -} - -const mp_obj_type_t mp_type_fun_builtin_3 = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_3_call, - .unary_op = mp_generic_unary_op, -}; - -STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_fun_builtin_var)); - mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in); - - // check number of arguments - mp_arg_check_num(n_args, n_kw, self->n_args_min, self->n_args_max, self->is_kw); - - if (self->is_kw) { - // function allows keywords - - // we create a map directly from the given args array - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); - - return self->fun.kw(n_args, args, &kw_args); - - } else { - // function takes a variable number of arguments, but no keywords - - return self->fun.var(n_args, args); - } -} - -const mp_obj_type_t mp_type_fun_builtin_var = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_builtin_var_call, - .unary_op = mp_generic_unary_op, -}; - -/******************************************************************************/ -/* byte code functions */ - -qstr mp_obj_code_get_name(const byte *code_info) { - code_info = mp_decode_uint_skip(code_info); // skip code_info_size entry - #if MICROPY_PERSISTENT_CODE - return code_info[0] | (code_info[1] << 8); - #else - return mp_decode_uint_value(code_info); - #endif -} - -#if MICROPY_EMIT_NATIVE -STATIC const mp_obj_type_t mp_type_fun_native; -#endif - -qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) { - const mp_obj_fun_bc_t *fun = MP_OBJ_TO_PTR(fun_in); - #if MICROPY_EMIT_NATIVE - if (fun->base.type == &mp_type_fun_native) { - // TODO native functions don't have name stored - return MP_QSTR_; - } - #endif - - const byte *bc = fun->bytecode; - bc = mp_decode_uint_skip(bc); // skip n_state - bc = mp_decode_uint_skip(bc); // skip n_exc_stack - bc++; // skip scope_params - bc++; // skip n_pos_args - bc++; // skip n_kwonly_args - bc++; // skip n_def_pos_args - return mp_obj_code_get_name(bc); -} - -#if MICROPY_CPYTHON_COMPAT -STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in); - mp_printf(print, "", mp_obj_fun_get_name(o_in), o); -} -#endif - -#if DEBUG_PRINT -STATIC void dump_args(const mp_obj_t *a, size_t sz) { - DEBUG_printf("%p: ", a); - for (size_t i = 0; i < sz; i++) { - DEBUG_printf("%p ", a[i]); - } - DEBUG_printf("\n"); -} -#else -#define dump_args(...) (void)0 -#endif - -// With this macro you can tune the maximum number of function state bytes -// that will be allocated on the stack. Any function that needs more -// than this will try to use the heap, with fallback to stack allocation. -#define VM_MAX_STATE_ON_STACK (11 * sizeof(mp_uint_t)) - -// Set this to enable a simple stack overflow check. -#define VM_DETECT_STACK_OVERFLOW (0) - -#if MICROPY_STACKLESS -mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - MP_STACK_CHECK(); - mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in); - - // bytecode prelude: state size and exception stack size - size_t n_state = mp_decode_uint_value(self->bytecode); - size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode)); - - // allocate state for locals and stack - size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t); - mp_code_state_t *code_state; - code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size); - if (!code_state) { - return NULL; - } - - code_state->fun_bc = self; - code_state->ip = 0; - mp_setup_code_state(code_state, n_args, n_kw, args); - - // execute the byte code with the correct globals context - code_state->old_globals = mp_globals_get(); - mp_globals_set(self->globals); - - return code_state; -} -#endif - -STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - MP_STACK_CHECK(); - - DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw); - DEBUG_printf("Input pos args: "); - dump_args(args, n_args); - DEBUG_printf("Input kw args: "); - dump_args(args + n_args, n_kw * 2); - mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in); - DEBUG_printf("Func n_def_args: %d\n", self->n_def_args); - - // bytecode prelude: state size and exception stack size - size_t n_state = mp_decode_uint_value(self->bytecode); - size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode)); - -#if VM_DETECT_STACK_OVERFLOW - n_state += 1; -#endif - - // allocate state for locals and stack - size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t); - mp_code_state_t *code_state = NULL; - if (state_size > VM_MAX_STATE_ON_STACK) { - code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size); - } - if (code_state == NULL) { - code_state = alloca(sizeof(mp_code_state_t) + state_size); - state_size = 0; // indicate that we allocated using alloca - } - - code_state->fun_bc = self; - code_state->ip = 0; - mp_setup_code_state(code_state, n_args, n_kw, args); - - // execute the byte code with the correct globals context - code_state->old_globals = mp_globals_get(); - mp_globals_set(self->globals); - mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode(code_state, MP_OBJ_NULL); - mp_globals_set(code_state->old_globals); - -#if VM_DETECT_STACK_OVERFLOW - if (vm_return_kind == MP_VM_RETURN_NORMAL) { - if (code_state->sp < code_state->state) { - printf("VM stack underflow: " INT_FMT "\n", code_state->sp - code_state->state); - assert(0); - } - } - // We can't check the case when an exception is returned in state[n_state - 1] - // and there are no arguments, because in this case our detection slot may have - // been overwritten by the returned exception (which is allowed). - if (!(vm_return_kind == MP_VM_RETURN_EXCEPTION && self->n_pos_args + self->n_kwonly_args == 0)) { - // Just check to see that we have at least 1 null object left in the state. - bool overflow = true; - for (size_t i = 0; i < n_state - self->n_pos_args - self->n_kwonly_args; i++) { - if (code_state->state[i] == MP_OBJ_NULL) { - overflow = false; - break; - } - } - if (overflow) { - printf("VM stack overflow state=%p n_state+1=" UINT_FMT "\n", code_state->state, n_state); - assert(0); - } - } -#endif - - mp_obj_t result; - if (vm_return_kind == MP_VM_RETURN_NORMAL) { - // return value is in *sp - result = *code_state->sp; - } else { - // must be an exception because normal functions can't yield - assert(vm_return_kind == MP_VM_RETURN_EXCEPTION); - // return value is in fastn[0]==state[n_state - 1] - result = code_state->state[n_state - 1]; - } - - // free the state if it was allocated on the heap - if (state_size != 0) { - m_del_var(mp_code_state_t, byte, state_size, code_state); - } - - if (vm_return_kind == MP_VM_RETURN_NORMAL) { - return result; - } else { // MP_VM_RETURN_EXCEPTION - nlr_raise(result); - } -} - -#if MICROPY_PY_FUNCTION_ATTRS -STATIC void fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != MP_OBJ_NULL) { - // not load attribute - return; - } - if (attr == MP_QSTR___name__) { - dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(self_in)); - } -} -#endif - -const mp_obj_type_t mp_type_fun_bc = { - { &mp_type_type }, - .name = MP_QSTR_function, -#if MICROPY_CPYTHON_COMPAT - .print = fun_bc_print, -#endif - .call = fun_bc_call, - .unary_op = mp_generic_unary_op, -#if MICROPY_PY_FUNCTION_ATTRS - .attr = fun_bc_attr, -#endif -}; - -mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) { - size_t n_def_args = 0; - size_t n_extra_args = 0; - mp_obj_tuple_t *def_args = MP_OBJ_TO_PTR(def_args_in); - if (def_args_in != MP_OBJ_NULL) { - assert(MP_OBJ_IS_TYPE(def_args_in, &mp_type_tuple)); - n_def_args = def_args->len; - n_extra_args = def_args->len; - } - if (def_kw_args != MP_OBJ_NULL) { - n_extra_args += 1; - } - mp_obj_fun_bc_t *o = m_new_obj_var(mp_obj_fun_bc_t, mp_obj_t, n_extra_args); - o->base.type = &mp_type_fun_bc; - o->globals = mp_globals_get(); - o->bytecode = code; - o->const_table = const_table; - if (def_args != NULL) { - memcpy(o->extra_args, def_args->items, n_def_args * sizeof(mp_obj_t)); - } - if (def_kw_args != MP_OBJ_NULL) { - o->extra_args[n_def_args] = def_kw_args; - } - return MP_OBJ_FROM_PTR(o); -} - -/******************************************************************************/ -/* native functions */ - -#if MICROPY_EMIT_NATIVE - -STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - MP_STACK_CHECK(); - mp_obj_fun_bc_t *self = self_in; - mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void*)self->bytecode); - return fun(self_in, n_args, n_kw, args); -} - -STATIC const mp_obj_type_t mp_type_fun_native = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_native_call, - .unary_op = mp_generic_unary_op, -}; - -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_fun_bc_t *o = mp_obj_new_fun_bc(def_args_in, def_kw_args, (const byte*)fun_data, const_table); - o->base.type = &mp_type_fun_native; - return o; -} - -#endif // MICROPY_EMIT_NATIVE - -/******************************************************************************/ -/* viper functions */ - -#if MICROPY_EMIT_NATIVE - -typedef struct _mp_obj_fun_viper_t { - mp_obj_base_t base; - size_t n_args; - void *fun_data; // GC must be able to trace this pointer - mp_uint_t type_sig; -} mp_obj_fun_viper_t; - -typedef mp_uint_t (*viper_fun_0_t)(void); -typedef mp_uint_t (*viper_fun_1_t)(mp_uint_t); -typedef mp_uint_t (*viper_fun_2_t)(mp_uint_t, mp_uint_t); -typedef mp_uint_t (*viper_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t); -typedef mp_uint_t (*viper_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t); - -STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_fun_viper_t *self = self_in; - - mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); - - void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data); - - mp_uint_t ret; - if (n_args == 0) { - ret = ((viper_fun_0_t)fun)(); - } else if (n_args == 1) { - ret = ((viper_fun_1_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4)); - } else if (n_args == 2) { - ret = ((viper_fun_2_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4), mp_convert_obj_to_native(args[1], self->type_sig >> 8)); - } else if (n_args == 3) { - ret = ((viper_fun_3_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4), mp_convert_obj_to_native(args[1], self->type_sig >> 8), mp_convert_obj_to_native(args[2], self->type_sig >> 12)); - } else { - // compiler allows at most 4 arguments - assert(n_args == 4); - ret = ((viper_fun_4_t)fun)( - mp_convert_obj_to_native(args[0], self->type_sig >> 4), - mp_convert_obj_to_native(args[1], self->type_sig >> 8), - mp_convert_obj_to_native(args[2], self->type_sig >> 12), - mp_convert_obj_to_native(args[3], self->type_sig >> 16) - ); - } - - return mp_convert_native_to_obj(ret, self->type_sig); -} - -STATIC const mp_obj_type_t mp_type_fun_viper = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_viper_call, - .unary_op = mp_generic_unary_op, -}; - -mp_obj_t mp_obj_new_fun_viper(size_t n_args, void *fun_data, mp_uint_t type_sig) { - mp_obj_fun_viper_t *o = m_new_obj(mp_obj_fun_viper_t); - o->base.type = &mp_type_fun_viper; - o->n_args = n_args; - o->fun_data = fun_data; - o->type_sig = type_sig; - return o; -} - -#endif // MICROPY_EMIT_NATIVE - -/******************************************************************************/ -/* inline assembler functions */ - -#if MICROPY_EMIT_INLINE_ASM - -typedef struct _mp_obj_fun_asm_t { - mp_obj_base_t base; - size_t n_args; - void *fun_data; // GC must be able to trace this pointer - mp_uint_t type_sig; -} mp_obj_fun_asm_t; - -typedef mp_uint_t (*inline_asm_fun_0_t)(void); -typedef mp_uint_t (*inline_asm_fun_1_t)(mp_uint_t); -typedef mp_uint_t (*inline_asm_fun_2_t)(mp_uint_t, mp_uint_t); -typedef mp_uint_t (*inline_asm_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t); -typedef mp_uint_t (*inline_asm_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t); - -// convert a MicroPython object to a sensible value for inline asm -STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) { - // TODO for byte_array, pass pointer to the array - if (MP_OBJ_IS_SMALL_INT(obj)) { - return MP_OBJ_SMALL_INT_VALUE(obj); - } else if (obj == mp_const_none) { - return 0; - } else if (obj == mp_const_false) { - return 0; - } else if (obj == mp_const_true) { - return 1; - } else if (MP_OBJ_IS_TYPE(obj, &mp_type_int)) { - return mp_obj_int_get_truncated(obj); - } else if (MP_OBJ_IS_STR(obj)) { - // pointer to the string (it's probably constant though!) - size_t l; - return (mp_uint_t)mp_obj_str_get_data(obj, &l); - } else { - mp_obj_type_t *type = mp_obj_get_type(obj); - if (0) { -#if MICROPY_PY_BUILTINS_FLOAT - } else if (type == &mp_type_float) { - // convert float to int (could also pass in float registers) - return (mp_int_t)mp_obj_float_get(obj); -#endif - } else if (type == &mp_type_tuple || type == &mp_type_list) { - // pointer to start of tuple (could pass length, but then could use len(x) for that) - size_t len; - mp_obj_t *items; - mp_obj_get_array(obj, &len, &items); - return (mp_uint_t)items; - } else { - mp_buffer_info_t bufinfo; - if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_WRITE)) { - // supports the buffer protocol, return a pointer to the data - return (mp_uint_t)bufinfo.buf; - } else { - // just pass along a pointer to the object - return (mp_uint_t)obj; - } - } - } -} - -STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_fun_asm_t *self = self_in; - - mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); - - void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data); - - mp_uint_t ret; - if (n_args == 0) { - ret = ((inline_asm_fun_0_t)fun)(); - } else if (n_args == 1) { - ret = ((inline_asm_fun_1_t)fun)(convert_obj_for_inline_asm(args[0])); - } else if (n_args == 2) { - ret = ((inline_asm_fun_2_t)fun)(convert_obj_for_inline_asm(args[0]), convert_obj_for_inline_asm(args[1])); - } else if (n_args == 3) { - ret = ((inline_asm_fun_3_t)fun)(convert_obj_for_inline_asm(args[0]), convert_obj_for_inline_asm(args[1]), convert_obj_for_inline_asm(args[2])); - } else { - // compiler allows at most 4 arguments - assert(n_args == 4); - ret = ((inline_asm_fun_4_t)fun)( - convert_obj_for_inline_asm(args[0]), - convert_obj_for_inline_asm(args[1]), - convert_obj_for_inline_asm(args[2]), - convert_obj_for_inline_asm(args[3]) - ); - } - - return mp_convert_native_to_obj(ret, self->type_sig); -} - -STATIC const mp_obj_type_t mp_type_fun_asm = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = fun_asm_call, - .unary_op = mp_generic_unary_op, -}; - -mp_obj_t mp_obj_new_fun_asm(size_t n_args, void *fun_data, mp_uint_t type_sig) { - mp_obj_fun_asm_t *o = m_new_obj(mp_obj_fun_asm_t); - o->base.type = &mp_type_fun_asm; - o->n_args = n_args; - o->fun_data = fun_data; - o->type_sig = type_sig; - return o; -} - -#endif // MICROPY_EMIT_INLINE_ASM diff --git a/user/mpy/py/objfun.h b/user/mpy/py/objfun.h deleted file mode 100644 index fbb3516..0000000 --- a/user/mpy/py/objfun.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_OBJFUN_H -#define MICROPY_INCLUDED_PY_OBJFUN_H - -#include "py/obj.h" - -typedef struct _mp_obj_fun_bc_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; // the context within which this function was defined - const byte *bytecode; // bytecode for the function - const mp_uint_t *const_table; // constant table - // the following extra_args array is allocated space to take (in order): - // - values of positional default args (if any) - // - a single slot for default kw args dict (if it has them) - // - a single slot for var args tuple (if it takes them) - // - a single slot for kw args dict (if it takes them) - mp_obj_t extra_args[]; -} mp_obj_fun_bc_t; - -#endif // MICROPY_INCLUDED_PY_OBJFUN_H diff --git a/user/mpy/py/objgenerator.c b/user/mpy/py/objgenerator.c deleted file mode 100644 index 2f39f3a..0000000 --- a/user/mpy/py/objgenerator.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "py/bc.h" -#include "py/objgenerator.h" -#include "py/objfun.h" - -/******************************************************************************/ -/* generator wrapper */ - -typedef struct _mp_obj_gen_wrap_t { - mp_obj_base_t base; - mp_obj_t *fun; -} mp_obj_gen_wrap_t; - -typedef struct _mp_obj_gen_instance_t { - mp_obj_base_t base; - mp_obj_dict_t *globals; - mp_code_state_t code_state; -} mp_obj_gen_instance_t; - -STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_gen_wrap_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun; - assert(self_fun->base.type == &mp_type_fun_bc); - - // bytecode prelude: get state size and exception stack size - size_t n_state = mp_decode_uint_value(self_fun->bytecode); - size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode)); - - // allocate the generator object, with room for local stack and exception stack - mp_obj_gen_instance_t *o = m_new_obj_var(mp_obj_gen_instance_t, byte, - n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t)); - o->base.type = &mp_type_gen_instance; - - o->globals = self_fun->globals; - o->code_state.fun_bc = self_fun; - o->code_state.ip = 0; - mp_setup_code_state(&o->code_state, n_args, n_kw, args); - return MP_OBJ_FROM_PTR(o); -} - -const mp_obj_type_t mp_type_gen_wrap = { - { &mp_type_type }, - .name = MP_QSTR_generator, - .call = gen_wrap_call, - .unary_op = mp_generic_unary_op, -}; - -mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) { - mp_obj_gen_wrap_t *o = m_new_obj(mp_obj_gen_wrap_t); - o->base.type = &mp_type_gen_wrap; - o->fun = MP_OBJ_TO_PTR(fun); - return MP_OBJ_FROM_PTR(o); -} - -/******************************************************************************/ -/* generator instance */ - -STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self); -} - -mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_gen_instance)); - mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in); - if (self->code_state.ip == 0) { - // Trying to resume already stopped generator - *ret_val = MP_OBJ_STOP_ITERATION; - return MP_VM_RETURN_NORMAL; - } - if (self->code_state.sp == self->code_state.state - 1) { - if (send_value != mp_const_none) { - mp_raise_TypeError("can't send non-None value to a just-started generator"); - } - } else { - *self->code_state.sp = send_value; - } - mp_obj_dict_t *old_globals = mp_globals_get(); - mp_globals_set(self->globals); - mp_vm_return_kind_t ret_kind = mp_execute_bytecode(&self->code_state, throw_value); - mp_globals_set(old_globals); - - switch (ret_kind) { - case MP_VM_RETURN_NORMAL: - default: - // Explicitly mark generator as completed. If we don't do this, - // subsequent next() may re-execute statements after last yield - // again and again, leading to side effects. - // TODO: check how return with value behaves under such conditions - // in CPython. - self->code_state.ip = 0; - *ret_val = *self->code_state.sp; - break; - - case MP_VM_RETURN_YIELD: - *ret_val = *self->code_state.sp; - if (*ret_val == MP_OBJ_STOP_ITERATION) { - self->code_state.ip = 0; - } - break; - - case MP_VM_RETURN_EXCEPTION: { - size_t n_state = mp_decode_uint_value(self->code_state.fun_bc->bytecode); - self->code_state.ip = 0; - *ret_val = self->code_state.state[n_state - 1]; - break; - } - } - - return ret_kind; -} - -STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value) { - mp_obj_t ret; - switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) { - case MP_VM_RETURN_NORMAL: - default: - // Optimize return w/o value in case generator is used in for loop - if (ret == mp_const_none || ret == MP_OBJ_STOP_ITERATION) { - return MP_OBJ_STOP_ITERATION; - } else { - nlr_raise(mp_obj_new_exception_args(&mp_type_StopIteration, 1, &ret)); - } - - case MP_VM_RETURN_YIELD: - return ret; - - case MP_VM_RETURN_EXCEPTION: - // TODO: Optimization of returning MP_OBJ_STOP_ITERATION is really part - // of mp_iternext() protocol, but this function is called by other methods - // too, which may not handled MP_OBJ_STOP_ITERATION. - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(ret)), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { - mp_obj_t val = mp_obj_exception_get_value(ret); - if (val == mp_const_none) { - return MP_OBJ_STOP_ITERATION; - } - } - nlr_raise(ret); - } -} - -STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) { - return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL); -} - -STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) { - mp_obj_t ret = gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL); - if (ret == MP_OBJ_STOP_ITERATION) { - nlr_raise(mp_obj_new_exception(&mp_type_StopIteration)); - } else { - return ret; - } -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send); - -STATIC mp_obj_t gen_instance_close(mp_obj_t self_in); -STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) { - mp_obj_t exc = (n_args == 2) ? args[1] : args[2]; - - mp_obj_t ret = gen_resume_and_raise(args[0], mp_const_none, exc); - if (ret == MP_OBJ_STOP_ITERATION) { - nlr_raise(mp_obj_new_exception(&mp_type_StopIteration)); - } else { - return ret; - } -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw); - -STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) { - mp_obj_t ret; - switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) { - case MP_VM_RETURN_YIELD: - mp_raise_msg(&mp_type_RuntimeError, "generator ignored GeneratorExit"); - - // Swallow StopIteration & GeneratorExit (== successful close), and re-raise any other - case MP_VM_RETURN_EXCEPTION: - // ret should always be an instance of an exception class - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(ret)), MP_OBJ_FROM_PTR(&mp_type_GeneratorExit)) || - mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(ret)), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { - return mp_const_none; - } - nlr_raise(ret); - - default: - // The only choice left is MP_VM_RETURN_NORMAL which is successful close - return mp_const_none; - } -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close); - -STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&gen_instance_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&gen_instance_send_obj) }, - { MP_ROM_QSTR(MP_QSTR_throw), MP_ROM_PTR(&gen_instance_throw_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table); - -const mp_obj_type_t mp_type_gen_instance = { - { &mp_type_type }, - .name = MP_QSTR_generator, - .print = gen_instance_print, - .unary_op = mp_generic_unary_op, - .getiter = mp_identity_getiter, - .iternext = gen_instance_iternext, - .locals_dict = (mp_obj_dict_t*)&gen_instance_locals_dict, -}; diff --git a/user/mpy/py/objgenerator.h b/user/mpy/py/objgenerator.h deleted file mode 100644 index 80bf9cd..0000000 --- a/user/mpy/py/objgenerator.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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_OBJGENERATOR_H -#define MICROPY_INCLUDED_PY_OBJGENERATOR_H - -#include "py/obj.h" -#include "py/runtime.h" - -mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); - -#endif // MICROPY_INCLUDED_PY_OBJGENERATOR_H diff --git a/user/mpy/py/objgetitemiter.c b/user/mpy/py/objgetitemiter.c deleted file mode 100644 index afd6fb2..0000000 --- a/user/mpy/py/objgetitemiter.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/nlr.h" -#include "py/runtime.h" - -// this is a wrapper object that turns something that has a __getitem__ method into an iterator - -typedef struct _mp_obj_getitem_iter_t { - mp_obj_base_t base; - mp_obj_t args[3]; -} mp_obj_getitem_iter_t; - -STATIC mp_obj_t it_iternext(mp_obj_t self_in) { - mp_obj_getitem_iter_t *self = MP_OBJ_TO_PTR(self_in); - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - // try to get next item - mp_obj_t value = mp_call_method_n_kw(1, 0, self->args); - self->args[2] = MP_OBJ_NEW_SMALL_INT(MP_OBJ_SMALL_INT_VALUE(self->args[2]) + 1); - nlr_pop(); - return value; - } else { - // an exception was raised - mp_obj_type_t *t = (mp_obj_type_t*)((mp_obj_base_t*)nlr.ret_val)->type; - if (t == &mp_type_StopIteration || t == &mp_type_IndexError) { - // return MP_OBJ_STOP_ITERATION instead of raising - return MP_OBJ_STOP_ITERATION; - } else { - // re-raise exception - nlr_jump(nlr.ret_val); - } - } -} - -STATIC const mp_obj_type_t it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = it_iternext, -}; - -// args are those returned from mp_load_method_maybe (ie either an attribute or a method) -mp_obj_t mp_obj_new_getitem_iter(mp_obj_t *args, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_getitem_iter_t *o = (mp_obj_getitem_iter_t*)iter_buf; - o->base.type = &it_type; - o->args[0] = args[0]; - o->args[1] = args[1]; - o->args[2] = MP_OBJ_NEW_SMALL_INT(0); - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objint.c b/user/mpy/py/objint.c deleted file mode 100644 index 29d8896..0000000 --- a/user/mpy/py/objint.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/parsenum.h" -#include "py/smallint.h" -#include "py/objint.h" -#include "py/objstr.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/binary.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include -#endif - -// This dispatcher function is expected to be independent of the implementation of long int -STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 2, false); - - switch (n_args) { - case 0: - return MP_OBJ_NEW_SMALL_INT(0); - - case 1: - if (MP_OBJ_IS_INT(args[0])) { - // already an int (small or long), just return it - return args[0]; - } else if (MP_OBJ_IS_STR_OR_BYTES(args[0])) { - // a string, parse it - size_t l; - const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_integer(s, l, 0, NULL); -#if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_float(args[0])) { - return mp_obj_new_int_from_float(mp_obj_float_get(args[0])); -#endif - } else { - // try to convert to small int (eg from bool) - return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(args[0])); - } - - case 2: - default: { - // should be a string, parse it - // TODO proper error checking of argument types - size_t l; - const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]), NULL); - } - } -} - -#if MICROPY_PY_BUILTINS_FLOAT - -typedef enum { - MP_FP_CLASS_FIT_SMALLINT, - MP_FP_CLASS_FIT_LONGINT, - MP_FP_CLASS_OVERFLOW -} mp_fp_as_int_class_t; - -STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) { - union { - mp_float_t f; -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - uint32_t i; -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE - uint32_t i[2]; -#endif - } u = {val}; - - uint32_t e; -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - e = u.i; -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE - e = u.i[MP_ENDIANNESS_LITTLE]; -#endif -#define MP_FLOAT_SIGN_SHIFT_I32 ((MP_FLOAT_FRAC_BITS + MP_FLOAT_EXP_BITS) % 32) -#define MP_FLOAT_EXP_SHIFT_I32 (MP_FLOAT_FRAC_BITS % 32) - - if (e & (1U << MP_FLOAT_SIGN_SHIFT_I32)) { -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE - e |= u.i[MP_ENDIANNESS_BIG] != 0; -#endif - if ((e & ~(1 << MP_FLOAT_SIGN_SHIFT_I32)) == 0) { - // handle case of -0 (when sign is set but rest of bits are zero) - e = 0; - } else { - e += ((1 << MP_FLOAT_EXP_BITS) - 1) << MP_FLOAT_EXP_SHIFT_I32; - } - } else { - e &= ~((1 << MP_FLOAT_EXP_SHIFT_I32) - 1); - } - // 8 * sizeof(uintptr_t) counts the number of bits for a small int - // TODO provide a way to configure this properly - if (e <= ((8 * sizeof(uintptr_t) + MP_FLOAT_EXP_BIAS - 3) << MP_FLOAT_EXP_SHIFT_I32)) { - return MP_FP_CLASS_FIT_SMALLINT; - } -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG - if (e <= (((sizeof(long long) * BITS_PER_BYTE) + MP_FLOAT_EXP_BIAS - 2) << MP_FLOAT_EXP_SHIFT_I32)) { - return MP_FP_CLASS_FIT_LONGINT; - } -#endif -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ - return MP_FP_CLASS_FIT_LONGINT; -#else - return MP_FP_CLASS_OVERFLOW; -#endif -} -#undef MP_FLOAT_SIGN_SHIFT_I32 -#undef MP_FLOAT_EXP_SHIFT_I32 - -mp_obj_t mp_obj_new_int_from_float(mp_float_t val) { - int cl = fpclassify(val); - if (cl == FP_INFINITE) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OverflowError, "can't convert inf to int")); - } else if (cl == FP_NAN) { - mp_raise_ValueError("can't convert NaN to int"); - } else { - mp_fp_as_int_class_t icl = mp_classify_fp_as_int(val); - if (icl == MP_FP_CLASS_FIT_SMALLINT) { - return MP_OBJ_NEW_SMALL_INT((mp_int_t)val); - #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ - } else { - mp_obj_int_t *o = mp_obj_int_new_mpz(); - mpz_set_from_float(&o->mpz, val); - return MP_OBJ_FROM_PTR(o); - } - #else - #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG - } else if (icl == MP_FP_CLASS_FIT_LONGINT) { - return mp_obj_new_int_from_ll((long long)val); - #endif - } else { - mp_raise_ValueError("float too big"); - } - #endif - } -} - -#endif - -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG -typedef mp_longint_impl_t fmt_int_t; -typedef unsigned long long fmt_uint_t; -#else -typedef mp_int_t fmt_int_t; -typedef mp_uint_t fmt_uint_t; -#endif - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - // The size of this buffer is rather arbitrary. If it's not large - // enough, a dynamic one will be allocated. - char stack_buf[sizeof(fmt_int_t) * 4]; - char *buf = stack_buf; - size_t buf_size = sizeof(stack_buf); - size_t fmt_size; - - char *str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, self_in, 10, NULL, '\0', '\0'); - mp_print_str(print, str); - - if (buf != stack_buf) { - m_del(char, buf, buf_size); - } -} - -STATIC const uint8_t log_base2_floor[] = { - 0, 1, 1, 2, - 2, 2, 2, 3, - 3, 3, 3, 3, - 3, 3, 3, 4, - /* if needed, these are the values for higher bases - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 5 - */ -}; - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma) { - assert(2 <= base && base <= 16); - size_t num_digits = num_bits / log_base2_floor[base - 1] + 1; - size_t num_commas = comma ? num_digits / 3 : 0; - size_t prefix_len = prefix ? strlen(prefix) : 0; - return num_digits + num_commas + prefix_len + 2; // +1 for sign, +1 for null byte -} - -// This routine expects you to pass in a buffer and size (in *buf and *buf_size). -// If, for some reason, this buffer is too small, then it will allocate a -// buffer and return the allocated buffer and size in *buf and *buf_size. It -// is the callers responsibility to free this allocated buffer. -// -// The resulting formatted string will be returned from this function and the -// formatted size will be in *fmt_size. -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma) { - fmt_int_t num; - if (MP_OBJ_IS_SMALL_INT(self_in)) { - // A small int; get the integer value to format. - num = MP_OBJ_SMALL_INT_VALUE(self_in); -#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - } else if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { - // Not a small int. -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG - const mp_obj_int_t *self = self_in; - // Get the value to format; mp_obj_get_int truncates to mp_int_t. - num = self->val; -#else - // Delegate to the implementation for the long int. - return mp_obj_int_formatted_impl(buf, buf_size, fmt_size, self_in, base, prefix, base_char, comma); -#endif -#endif - } else { - // Not an int. - **buf = '\0'; - *fmt_size = 0; - return *buf; - } - - char sign = '\0'; - if (num < 0) { - num = -num; - sign = '-'; - } - - size_t needed_size = mp_int_format_size(sizeof(fmt_int_t) * 8, base, prefix, comma); - if (needed_size > *buf_size) { - *buf = m_new(char, needed_size); - *buf_size = needed_size; - } - char *str = *buf; - - char *b = str + needed_size; - *(--b) = '\0'; - char *last_comma = b; - - if (num == 0) { - *(--b) = '0'; - } else { - do { - // The cast to fmt_uint_t is because num is positive and we want unsigned arithmetic - int c = (fmt_uint_t)num % base; - num = (fmt_uint_t)num / base; - if (c >= 10) { - c += base_char - 10; - } else { - c += '0'; - } - *(--b) = c; - if (comma && num != 0 && b > str && (last_comma - b) == 3) { - *(--b) = comma; - last_comma = b; - } - } - while (b > str && num != 0); - } - if (prefix) { - size_t prefix_len = strlen(prefix); - char *p = b - prefix_len; - if (p > str) { - b = p; - while (*prefix) { - *p++ = *prefix++; - } - } - } - if (sign && b > str) { - *(--b) = sign; - } - *fmt_size = *buf + needed_size - b - 1; - - return b; -} - -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE - -int mp_obj_int_sign(mp_obj_t self_in) { - mp_int_t val = mp_obj_get_int(self_in); - if (val < 0) { - return -1; - } else if (val > 0) { - return 1; - } else { - return 0; - } -} - -// This must handle int and bool types, and must raise a -// TypeError if the argument is not integral -mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { - mp_int_t val = mp_obj_get_int(self_in); - if (val < 0) { - val = -val; - } - return MP_OBJ_NEW_SMALL_INT(val); -} - -// This is called for operations on SMALL_INT that are not handled by mp_unary_op -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { - return MP_OBJ_NULL; // op not supported -} - -// This is called for operations on SMALL_INT that are not handled by mp_binary_op -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); -} - -// This is called only with strings whose value doesn't fit in SMALL_INT -mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { - mp_raise_msg(&mp_type_OverflowError, "long int not supported in this build"); - return mp_const_none; -} - -// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT) -mp_obj_t mp_obj_new_int_from_ll(long long val) { - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return mp_const_none; -} - -// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT) -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return mp_const_none; -} - -mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { - // SMALL_INT accepts only signed numbers, so make sure the input - // value fits completely in the small-int positive range. - if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { - return MP_OBJ_NEW_SMALL_INT(value); - } - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return mp_const_none; -} - -mp_obj_t mp_obj_new_int(mp_int_t value) { - if (MP_SMALL_INT_FITS(value)) { - return MP_OBJ_NEW_SMALL_INT(value); - } - mp_raise_msg(&mp_type_OverflowError, "small int overflow"); - return mp_const_none; -} - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { - return MP_OBJ_SMALL_INT_VALUE(self_in); -} - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { - return MP_OBJ_SMALL_INT_VALUE(self_in); -} - -#endif // MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE - -// This dispatcher function is expected to be independent of the implementation of long int -// It handles the extra cases for integer-like arithmetic -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - if (rhs_in == mp_const_false) { - // false acts as 0 - return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(0)); - } else if (rhs_in == mp_const_true) { - // true acts as 0 - return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(1)); - } else if (op == MP_BINARY_OP_MULTIPLY) { - if (MP_OBJ_IS_STR(rhs_in) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_bytes) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_list)) { - // multiply is commutative for these types, so delegate to them - return mp_binary_op(op, rhs_in, lhs_in); - } - } - return MP_OBJ_NULL; // op not supported -} - -// this is a classmethod -STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) { - // TODO: Support signed param (assumes signed=False at the moment) - (void)n_args; - - // get the buffer info - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); - - const byte* buf = (const byte*)bufinfo.buf; - int delta = 1; - if (args[2] == MP_OBJ_NEW_QSTR(MP_QSTR_little)) { - buf += bufinfo.len - 1; - delta = -1; - } - - mp_uint_t value = 0; - size_t len = bufinfo.len; - for (; len--; buf += delta) { - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - if (value > (MP_SMALL_INT_MAX >> 8)) { - // Result will overflow a small-int so construct a big-int - return mp_obj_int_from_bytes_impl(args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little), bufinfo.len, bufinfo.buf); - } - #endif - value = (value << 8) | *buf; - } - return mp_obj_new_int_from_uint(value); -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes); -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj)); - -STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) { - // TODO: Support signed param (assumes signed=False) - (void)n_args; - - mp_int_t len = mp_obj_get_int(args[1]); - if (len < 0) { - mp_raise_ValueError(NULL); - } - bool big_endian = args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little); - - vstr_t vstr; - vstr_init_len(&vstr, len); - byte *data = (byte*)vstr.buf; - memset(data, 0, len); - - #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - if (!MP_OBJ_IS_SMALL_INT(args[0])) { - mp_obj_int_to_bytes_impl(args[0], big_endian, len, data); - } else - #endif - { - mp_int_t val = MP_OBJ_SMALL_INT_VALUE(args[0]); - size_t l = MIN((size_t)len, sizeof(val)); - mp_binary_set_int(l, big_endian, data + (big_endian ? (len - l) : 0), val); - } - - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes); - -STATIC const mp_rom_map_elem_t int_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) }, - { MP_ROM_QSTR(MP_QSTR_to_bytes), MP_ROM_PTR(&int_to_bytes_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table); - -const mp_obj_type_t mp_type_int = { - { &mp_type_type }, - .name = MP_QSTR_int, - .print = mp_obj_int_print, - .make_new = mp_obj_int_make_new, - .unary_op = mp_obj_int_unary_op, - .binary_op = mp_obj_int_binary_op, - .locals_dict = (mp_obj_dict_t*)&int_locals_dict, -}; diff --git a/user/mpy/py/objint.h b/user/mpy/py/objint.h deleted file mode 100644 index 394c237..0000000 --- a/user/mpy/py/objint.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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_OBJINT_H -#define MICROPY_INCLUDED_PY_OBJINT_H - -#include "py/mpz.h" -#include "py/obj.h" - -typedef struct _mp_obj_int_t { - mp_obj_base_t base; -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG - mp_longint_impl_t val; -#elif MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ - mpz_t mpz; -#endif -} mp_obj_int_t; - -extern const mp_obj_int_t mp_maxsize_obj; - -#if MICROPY_PY_BUILTINS_FLOAT -mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in); -#endif - -size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma); - -mp_obj_int_t *mp_obj_int_new_mpz(void); - -void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); -char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma); -mp_int_t mp_obj_int_hash(mp_obj_t self_in); -mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf); -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf); -int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus); - -#endif // MICROPY_INCLUDED_PY_OBJINT_H diff --git a/user/mpy/py/objint_longlong.c b/user/mpy/py/objint_longlong.c deleted file mode 100644 index 02c005d..0000000 --- a/user/mpy/py/objint_longlong.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/smallint.h" -#include "py/objint.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include -#endif - -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG - -#if MICROPY_PY_SYS_MAXSIZE -// Export value for sys.maxsize -const mp_obj_int_t mp_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX}; -#endif - -mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) { - int delta = 1; - if (!big_endian) { - buf += len - 1; - delta = -1; - } - - mp_longint_impl_t value = 0; - for (; len--; buf += delta) { - value = (value << 8) | *buf; - } - return mp_obj_new_int_from_ll(value); -} - -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); - mp_obj_int_t *self = self_in; - long long val = self->val; - if (big_endian) { - byte *b = buf + len; - while (b > buf) { - *--b = val; - val >>= 8; - } - } else { - for (; len > 0; --len) { - *buf++ = val; - val >>= 8; - } - } -} - -int mp_obj_int_sign(mp_obj_t self_in) { - mp_longint_impl_t val; - if (MP_OBJ_IS_SMALL_INT(self_in)) { - val = MP_OBJ_SMALL_INT_VALUE(self_in); - } else { - mp_obj_int_t *self = self_in; - val = self->val; - } - if (val < 0) { - return -1; - } else if (val > 0) { - return 1; - } else { - return 0; - } -} - -// This must handle int and bool types, and must raise a -// TypeError if the argument is not integral -mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { - if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { - mp_obj_int_t *self = self_in; - self = mp_obj_new_int_from_ll(self->val); - if (self->val < 0) { - // TODO could overflow long long - self->val = -self->val; - } - return self; - } else { - mp_int_t val = mp_obj_get_int(self_in); - if (val == MP_SMALL_INT_MIN) { - return mp_obj_new_int_from_ll(-val); - } else { - if (val < 0) { - val = -val; - } - return MP_OBJ_NEW_SMALL_INT(val); - } - } -} - -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { - mp_obj_int_t *o = o_in; - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->val != 0); - - // truncate value to fit in mp_int_t, which gives the same hash as - // small int if the value fits without truncation - case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_int_t)o->val); - - case MP_UNARY_OP_POSITIVE: return o_in; - case MP_UNARY_OP_NEGATIVE: return mp_obj_new_int_from_ll(-o->val); - case MP_UNARY_OP_INVERT: return mp_obj_new_int_from_ll(~o->val); - default: return MP_OBJ_NULL; // op not supported - } -} - -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - long long lhs_val; - long long rhs_val; - - if (MP_OBJ_IS_SMALL_INT(lhs_in)) { - lhs_val = MP_OBJ_SMALL_INT_VALUE(lhs_in); - } else if (MP_OBJ_IS_TYPE(lhs_in, &mp_type_int)) { - lhs_val = ((mp_obj_int_t*)lhs_in)->val; - } else { - return MP_OBJ_NULL; // op not supported - } - - if (MP_OBJ_IS_SMALL_INT(rhs_in)) { - rhs_val = MP_OBJ_SMALL_INT_VALUE(rhs_in); - } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) { - rhs_val = ((mp_obj_int_t*)rhs_in)->val; - } else { - // delegate to generic function to check for extra cases - return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); - } - - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: - return mp_obj_new_int_from_ll(lhs_val + rhs_val); - case MP_BINARY_OP_SUBTRACT: - case MP_BINARY_OP_INPLACE_SUBTRACT: - return mp_obj_new_int_from_ll(lhs_val - rhs_val); - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: - return mp_obj_new_int_from_ll(lhs_val * rhs_val); - case MP_BINARY_OP_FLOOR_DIVIDE: - case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: - return mp_obj_new_int_from_ll(lhs_val / rhs_val); - case MP_BINARY_OP_MODULO: - case MP_BINARY_OP_INPLACE_MODULO: - return mp_obj_new_int_from_ll(lhs_val % rhs_val); - - case MP_BINARY_OP_AND: - case MP_BINARY_OP_INPLACE_AND: - return mp_obj_new_int_from_ll(lhs_val & rhs_val); - case MP_BINARY_OP_OR: - case MP_BINARY_OP_INPLACE_OR: - return mp_obj_new_int_from_ll(lhs_val | rhs_val); - case MP_BINARY_OP_XOR: - case MP_BINARY_OP_INPLACE_XOR: - return mp_obj_new_int_from_ll(lhs_val ^ rhs_val); - - case MP_BINARY_OP_LSHIFT: - case MP_BINARY_OP_INPLACE_LSHIFT: - return mp_obj_new_int_from_ll(lhs_val << (int)rhs_val); - case MP_BINARY_OP_RSHIFT: - case MP_BINARY_OP_INPLACE_RSHIFT: - return mp_obj_new_int_from_ll(lhs_val >> (int)rhs_val); - - case MP_BINARY_OP_POWER: - case MP_BINARY_OP_INPLACE_POWER: { - if (rhs_val < 0) { - #if MICROPY_PY_BUILTINS_FLOAT - return mp_obj_float_binary_op(op, lhs_val, rhs_in); - #else - mp_raise_ValueError("negative power with no float support"); - #endif - } - long long ans = 1; - while (rhs_val > 0) { - if (rhs_val & 1) { - ans *= lhs_val; - } - if (rhs_val == 1) { - break; - } - rhs_val /= 2; - lhs_val *= lhs_val; - } - return mp_obj_new_int_from_ll(ans); - } - - case MP_BINARY_OP_LESS: - return mp_obj_new_bool(lhs_val < rhs_val); - case MP_BINARY_OP_MORE: - return mp_obj_new_bool(lhs_val > rhs_val); - case MP_BINARY_OP_LESS_EQUAL: - return mp_obj_new_bool(lhs_val <= rhs_val); - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(lhs_val >= rhs_val); - case MP_BINARY_OP_EQUAL: - return mp_obj_new_bool(lhs_val == rhs_val); - - default: - return MP_OBJ_NULL; // op not supported - } -} - -mp_obj_t mp_obj_new_int(mp_int_t value) { - if (MP_SMALL_INT_FITS(value)) { - return MP_OBJ_NEW_SMALL_INT(value); - } - return mp_obj_new_int_from_ll(value); -} - -mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { - // SMALL_INT accepts only signed numbers, so make sure the input - // value fits completely in the small-int positive range. - if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { - return MP_OBJ_NEW_SMALL_INT(value); - } - return mp_obj_new_int_from_ll(value); -} - -mp_obj_t mp_obj_new_int_from_ll(long long val) { - mp_obj_int_t *o = m_new_obj(mp_obj_int_t); - o->base.type = &mp_type_int; - o->val = val; - return o; -} - -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { - // TODO raise an exception if the unsigned long long won't fit - if (val >> (sizeof(unsigned long long) * 8 - 1) != 0) { - mp_raise_msg(&mp_type_OverflowError, "ulonglong too large"); - } - mp_obj_int_t *o = m_new_obj(mp_obj_int_t); - o->base.type = &mp_type_int; - o->val = val; - return o; -} - -mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { - // TODO this does not honor the given length of the string, but it all cases it should anyway be null terminated - // TODO check overflow - mp_obj_int_t *o = m_new_obj(mp_obj_int_t); - o->base.type = &mp_type_int; - char *endptr; - o->val = strtoll(*str, &endptr, base); - *str = endptr; - return o; -} - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { - if (MP_OBJ_IS_SMALL_INT(self_in)) { - return MP_OBJ_SMALL_INT_VALUE(self_in); - } else { - const mp_obj_int_t *self = self_in; - return self->val; - } -} - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { - // TODO: Check overflow - return mp_obj_int_get_truncated(self_in); -} - -#if MICROPY_PY_BUILTINS_FLOAT -mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); - mp_obj_int_t *self = self_in; - return self->val; -} -#endif - -#endif diff --git a/user/mpy/py/objint_mpz.c b/user/mpy/py/objint_mpz.c deleted file mode 100644 index 0791a8a..0000000 --- a/user/mpy/py/objint_mpz.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/parsenumbase.h" -#include "py/smallint.h" -#include "py/objint.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include -#endif - -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ - -#if MICROPY_PY_SYS_MAXSIZE -// Export value for sys.maxsize -#define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1) -STATIC const mpz_dig_t maxsize_dig[] = { - #define NUM_DIG 1 - (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) & DIG_MASK, - #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) > DIG_MASK - #undef NUM_DIG - #define NUM_DIG 2 - (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 1) & DIG_MASK, - #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 1) > DIG_MASK - #undef NUM_DIG - #define NUM_DIG 3 - (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 2) & DIG_MASK, - #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 2) > DIG_MASK - #undef NUM_DIG - #define NUM_DIG 4 - (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 3) & DIG_MASK, - #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 3) > DIG_MASK - #error cannot encode MP_SSIZE_MAX as mpz - #endif - #endif - #endif - #endif -}; -const mp_obj_int_t mp_maxsize_obj = { - {&mp_type_int}, - {.fixed_dig = 1, .len = NUM_DIG, .alloc = NUM_DIG, .dig = (mpz_dig_t*)maxsize_dig} -}; -#undef DIG_MASK -#undef NUM_DIG -#endif - -mp_obj_int_t *mp_obj_int_new_mpz(void) { - mp_obj_int_t *o = m_new_obj(mp_obj_int_t); - o->base.type = &mp_type_int; - mpz_init_zero(&o->mpz); - return o; -} - -// This routine expects you to pass in a buffer and size (in *buf and buf_size). -// If, for some reason, this buffer is too small, then it will allocate a -// buffer and return the allocated buffer and size in *buf and *buf_size. It -// is the callers responsibility to free this allocated buffer. -// -// The resulting formatted string will be returned from this function and the -// formatted size will be in *fmt_size. -// -// This particular routine should only be called for the mpz representation of the int. -char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, - int base, const char *prefix, char base_char, char comma) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); - const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - - size_t needed_size = mp_int_format_size(mpz_max_num_bits(&self->mpz), base, prefix, comma); - if (needed_size > *buf_size) { - *buf = m_new(char, needed_size); - *buf_size = needed_size; - } - char *str = *buf; - - *fmt_size = mpz_as_str_inpl(&self->mpz, base, prefix, base_char, comma, str); - - return str; -} - -mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) { - mp_obj_int_t *o = mp_obj_int_new_mpz(); - mpz_set_from_bytes(&o->mpz, big_endian, len, buf); - return MP_OBJ_FROM_PTR(o); -} - -void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); - mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - memset(buf, 0, len); - mpz_as_bytes(&self->mpz, big_endian, len, buf); -} - -int mp_obj_int_sign(mp_obj_t self_in) { - if (MP_OBJ_IS_SMALL_INT(self_in)) { - mp_int_t val = MP_OBJ_SMALL_INT_VALUE(self_in); - if (val < 0) { - return -1; - } else if (val > 0) { - return 1; - } else { - return 0; - } - } - mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - if (self->mpz.len == 0) { - return 0; - } else if (self->mpz.neg == 0) { - return 1; - } else { - return -1; - } -} - -// This must handle int and bool types, and must raise a -// TypeError if the argument is not integral -mp_obj_t mp_obj_int_abs(mp_obj_t self_in) { - if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { - mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_int_t *self2 = mp_obj_int_new_mpz(); - mpz_abs_inpl(&self2->mpz, &self->mpz); - return MP_OBJ_FROM_PTR(self2); - } else { - mp_int_t val = mp_obj_get_int(self_in); - if (val == MP_SMALL_INT_MIN) { - return mp_obj_new_int_from_ll(-val); - } else { - if (val < 0) { - val = -val; - } - return MP_OBJ_NEW_SMALL_INT(val); - } - } -} - -mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in) { - mp_obj_int_t *o = MP_OBJ_TO_PTR(o_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(!mpz_is_zero(&o->mpz)); - case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mpz_hash(&o->mpz)); - case MP_UNARY_OP_POSITIVE: return o_in; - case MP_UNARY_OP_NEGATIVE: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_neg_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); } - case MP_UNARY_OP_INVERT: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_not_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); } - default: return MP_OBJ_NULL; // op not supported - } -} - -mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - const mpz_t *zlhs; - const mpz_t *zrhs; - mpz_t z_int; - mpz_dig_t z_int_dig[MPZ_NUM_DIG_FOR_INT]; - - // lhs could be a small int (eg small-int + mpz) - if (MP_OBJ_IS_SMALL_INT(lhs_in)) { - mpz_init_fixed_from_int(&z_int, z_int_dig, MPZ_NUM_DIG_FOR_INT, MP_OBJ_SMALL_INT_VALUE(lhs_in)); - zlhs = &z_int; - } else if (MP_OBJ_IS_TYPE(lhs_in, &mp_type_int)) { - zlhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(lhs_in))->mpz; - } else { - // unsupported type - return MP_OBJ_NULL; - } - - // if rhs is small int, then lhs was not (otherwise mp_binary_op handles it) - if (MP_OBJ_IS_SMALL_INT(rhs_in)) { - mpz_init_fixed_from_int(&z_int, z_int_dig, MPZ_NUM_DIG_FOR_INT, MP_OBJ_SMALL_INT_VALUE(rhs_in)); - zrhs = &z_int; - } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) { - zrhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(rhs_in))->mpz; -#if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_float(rhs_in)) { - return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in); -#if MICROPY_PY_BUILTINS_COMPLEX - } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) { - return mp_obj_complex_binary_op(op, mpz_as_float(zlhs), 0, rhs_in); -#endif -#endif - } else { - // delegate to generic function to check for extra cases - return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in); - } - - if (0) { -#if MICROPY_PY_BUILTINS_FLOAT - } else if (op == MP_BINARY_OP_TRUE_DIVIDE || op == MP_BINARY_OP_INPLACE_TRUE_DIVIDE) { - if (mpz_is_zero(zrhs)) { - goto zero_division_error; - } - mp_float_t flhs = mpz_as_float(zlhs); - mp_float_t frhs = mpz_as_float(zrhs); - return mp_obj_new_float(flhs / frhs); -#endif - - } else if (op <= MP_BINARY_OP_INPLACE_POWER) { - mp_obj_int_t *res = mp_obj_int_new_mpz(); - - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: - mpz_add_inpl(&res->mpz, zlhs, zrhs); - break; - case MP_BINARY_OP_SUBTRACT: - case MP_BINARY_OP_INPLACE_SUBTRACT: - mpz_sub_inpl(&res->mpz, zlhs, zrhs); - break; - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: - mpz_mul_inpl(&res->mpz, zlhs, zrhs); - break; - case MP_BINARY_OP_FLOOR_DIVIDE: - case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: { - if (mpz_is_zero(zrhs)) { - zero_division_error: - mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); - } - mpz_t rem; mpz_init_zero(&rem); - mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs); - mpz_deinit(&rem); - break; - } - case MP_BINARY_OP_MODULO: - case MP_BINARY_OP_INPLACE_MODULO: { - if (mpz_is_zero(zrhs)) { - goto zero_division_error; - } - mpz_t quo; mpz_init_zero(&quo); - mpz_divmod_inpl(&quo, &res->mpz, zlhs, zrhs); - mpz_deinit(&quo); - break; - } - - case MP_BINARY_OP_AND: - case MP_BINARY_OP_INPLACE_AND: - mpz_and_inpl(&res->mpz, zlhs, zrhs); - break; - case MP_BINARY_OP_OR: - case MP_BINARY_OP_INPLACE_OR: - mpz_or_inpl(&res->mpz, zlhs, zrhs); - break; - case MP_BINARY_OP_XOR: - case MP_BINARY_OP_INPLACE_XOR: - mpz_xor_inpl(&res->mpz, zlhs, zrhs); - break; - - case MP_BINARY_OP_LSHIFT: - case MP_BINARY_OP_INPLACE_LSHIFT: - case MP_BINARY_OP_RSHIFT: - case MP_BINARY_OP_INPLACE_RSHIFT: { - mp_int_t irhs = mp_obj_int_get_checked(rhs_in); - if (irhs < 0) { - mp_raise_ValueError("negative shift count"); - } - if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) { - mpz_shl_inpl(&res->mpz, zlhs, irhs); - } else { - mpz_shr_inpl(&res->mpz, zlhs, irhs); - } - break; - } - - case MP_BINARY_OP_POWER: - case MP_BINARY_OP_INPLACE_POWER: - if (mpz_is_neg(zrhs)) { - #if MICROPY_PY_BUILTINS_FLOAT - return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in); - #else - mp_raise_ValueError("negative power with no float support"); - #endif - } - mpz_pow_inpl(&res->mpz, zlhs, zrhs); - break; - - default: { - assert(op == MP_BINARY_OP_DIVMOD); - if (mpz_is_zero(zrhs)) { - goto zero_division_error; - } - mp_obj_int_t *quo = mp_obj_int_new_mpz(); - mpz_divmod_inpl(&quo->mpz, &res->mpz, zlhs, zrhs); - mp_obj_t tuple[2] = {MP_OBJ_FROM_PTR(quo), MP_OBJ_FROM_PTR(res)}; - return mp_obj_new_tuple(2, tuple); - } - } - - return MP_OBJ_FROM_PTR(res); - - } else { - int cmp = mpz_cmp(zlhs, zrhs); - switch (op) { - case MP_BINARY_OP_LESS: - return mp_obj_new_bool(cmp < 0); - case MP_BINARY_OP_MORE: - return mp_obj_new_bool(cmp > 0); - case MP_BINARY_OP_LESS_EQUAL: - return mp_obj_new_bool(cmp <= 0); - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(cmp >= 0); - case MP_BINARY_OP_EQUAL: - return mp_obj_new_bool(cmp == 0); - - default: - return MP_OBJ_NULL; // op not supported - } - } -} - -#if MICROPY_PY_BUILTINS_POW3 -STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) { - if (MP_OBJ_IS_SMALL_INT(arg)) { - mpz_init_from_int(temp, MP_OBJ_SMALL_INT_VALUE(arg)); - return temp; - } else { - mp_obj_int_t *arp_p = MP_OBJ_TO_PTR(arg); - return &(arp_p->mpz); - } -} - -mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus) { - if (!MP_OBJ_IS_INT(base) || !MP_OBJ_IS_INT(exponent) || !MP_OBJ_IS_INT(modulus)) { - mp_raise_TypeError("pow() with 3 arguments requires integers"); - } else { - mp_obj_t result = mp_obj_new_int_from_ull(0); // Use the _from_ull version as this forces an mpz int - mp_obj_int_t *res_p = (mp_obj_int_t *) MP_OBJ_TO_PTR(result); - - mpz_t l_temp, r_temp, m_temp; - mpz_t *lhs = mp_mpz_for_int(base, &l_temp); - mpz_t *rhs = mp_mpz_for_int(exponent, &r_temp); - mpz_t *mod = mp_mpz_for_int(modulus, &m_temp); - - mpz_pow3_inpl(&(res_p->mpz), lhs, rhs, mod); - - if (lhs == &l_temp) { mpz_deinit(lhs); } - if (rhs == &r_temp) { mpz_deinit(rhs); } - if (mod == &m_temp) { mpz_deinit(mod); } - return result; - } -} -#endif - -mp_obj_t mp_obj_new_int(mp_int_t value) { - if (MP_SMALL_INT_FITS(value)) { - return MP_OBJ_NEW_SMALL_INT(value); - } - return mp_obj_new_int_from_ll(value); -} - -mp_obj_t mp_obj_new_int_from_ll(long long val) { - mp_obj_int_t *o = mp_obj_int_new_mpz(); - mpz_set_from_ll(&o->mpz, val, true); - return MP_OBJ_FROM_PTR(o); -} - -mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) { - mp_obj_int_t *o = mp_obj_int_new_mpz(); - mpz_set_from_ll(&o->mpz, val, false); - return MP_OBJ_FROM_PTR(o); -} - -mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { - // SMALL_INT accepts only signed numbers, so make sure the input - // value fits completely in the small-int positive range. - if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { - return MP_OBJ_NEW_SMALL_INT(value); - } - return mp_obj_new_int_from_ull(value); -} - -mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { - mp_obj_int_t *o = mp_obj_int_new_mpz(); - size_t n = mpz_set_from_str(&o->mpz, *str, len, neg, base); - *str += n; - return MP_OBJ_FROM_PTR(o); -} - -mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in) { - if (MP_OBJ_IS_SMALL_INT(self_in)) { - return MP_OBJ_SMALL_INT_VALUE(self_in); - } else { - const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - // hash returns actual int value if it fits in mp_int_t - return mpz_hash(&self->mpz); - } -} - -mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { - if (MP_OBJ_IS_SMALL_INT(self_in)) { - return MP_OBJ_SMALL_INT_VALUE(self_in); - } else { - const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t value; - if (mpz_as_int_checked(&self->mpz, &value)) { - return value; - } else { - // overflow - mp_raise_msg(&mp_type_OverflowError, "overflow converting long int to machine word"); - } - } -} - -#if MICROPY_PY_BUILTINS_FLOAT -mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int)); - mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); - return mpz_as_float(&self->mpz); -} -#endif - -#endif diff --git a/user/mpy/py/objlist.c b/user/mpy/py/objlist.c deleted file mode 100644 index 86d4300..0000000 --- a/user/mpy/py/objlist.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objlist.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/stackctrl.h" - -STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf); -STATIC mp_obj_list_t *list_new(size_t n); -STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in); -STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); - -// TODO: Move to mpconfig.h -#define LIST_MIN_ALLOC 4 - -/******************************************************************************/ -/* list */ - -STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in); - if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { - kind = PRINT_REPR; - } - mp_print_str(print, "["); - for (size_t i = 0; i < o->len; i++) { - if (i > 0) { - mp_print_str(print, ", "); - } - mp_obj_print_helper(print, o->items[i], kind); - } - mp_print_str(print, "]"); -} - -STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) { - mp_obj_t iter = mp_getiter(iterable, NULL); - mp_obj_t item; - while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(list, item); - } - return list; -} - -STATIC mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - mp_arg_check_num(n_args, n_kw, 0, 1, false); - - switch (n_args) { - case 0: - // return a new, empty list - return mp_obj_new_list(0, NULL); - - case 1: - default: { - // make list from iterable - // TODO: optimize list/tuple - mp_obj_t list = mp_obj_new_list(0, NULL); - return list_extend_from_iter(list, args[0]); - } - } -} - -// Don't pass MP_BINARY_OP_NOT_EQUAL here -STATIC bool list_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - if (!MP_OBJ_IS_TYPE(another_in, &mp_type_list)) { - return false; - } - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_list_t *another = MP_OBJ_TO_PTR(another_in); - - return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); -} - -STATIC mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); - #if MICROPY_PY_SYS_GETSIZEOF - case MP_UNARY_OP_SIZEOF: { - size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc; - return MP_OBJ_NEW_SMALL_INT(sz); - } - #endif - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t list_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs); - switch (op) { - case MP_BINARY_OP_ADD: { - if (!MP_OBJ_IS_TYPE(rhs, &mp_type_list)) { - return MP_OBJ_NULL; // op not supported - } - mp_obj_list_t *p = MP_OBJ_TO_PTR(rhs); - mp_obj_list_t *s = list_new(o->len + p->len); - mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t); - return MP_OBJ_FROM_PTR(s); - } - case MP_BINARY_OP_INPLACE_ADD: { - list_extend(lhs, rhs); - return lhs; - } - case MP_BINARY_OP_MULTIPLY: { - mp_int_t n; - if (!mp_obj_get_int_maybe(rhs, &n)) { - return MP_OBJ_NULL; // op not supported - } - if (n < 0) { - n = 0; - } - mp_obj_list_t *s = list_new(o->len * n); - mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); - return MP_OBJ_FROM_PTR(s); - } - case MP_BINARY_OP_EQUAL: - case MP_BINARY_OP_LESS: - case MP_BINARY_OP_LESS_EQUAL: - case MP_BINARY_OP_MORE: - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(list_cmp_helper(op, lhs, rhs)); - - default: - return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == MP_OBJ_NULL) { - // delete -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { - mp_raise_NotImplementedError(""); - } - - mp_int_t len_adj = slice.start - slice.stop; - //printf("Len adj: %d\n", len_adj); - assert(len_adj <= 0); - mp_seq_replace_slice_no_grow(self->items, self->len, slice.start, slice.stop, self->items/*NULL*/, 0, sizeof(*self->items)); - // Clear "freed" elements at the end of list - mp_seq_clear(self->items, self->len + len_adj, self->len, sizeof(*self->items)); - self->len += len_adj; - return mp_const_none; - } -#endif - mp_obj_t args[2] = {self_in, index}; - list_pop(2, args); - return mp_const_none; - } else if (value == MP_OBJ_SENTINEL) { - // load - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { - return mp_seq_extract_slice(self->len, self->items, &slice); - } - mp_obj_list_t *res = list_new(slice.stop - slice.start); - mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t); - return MP_OBJ_FROM_PTR(res); - } -#endif - size_t index_val = mp_get_index(self->base.type, self->len, index, false); - return self->items[index_val]; - } else { -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - size_t value_len; mp_obj_t *value_items; - mp_obj_get_array(value, &value_len, &value_items); - mp_bound_slice_t slice_out; - if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice_out)) { - mp_raise_NotImplementedError(""); - } - mp_int_t len_adj = value_len - (slice_out.stop - slice_out.start); - //printf("Len adj: %d\n", len_adj); - if (len_adj > 0) { - if (self->len + len_adj > self->alloc) { - // TODO: Might optimize memory copies here by checking if block can - // be grown inplace or not - self->items = m_renew(mp_obj_t, self->items, self->alloc, self->len + len_adj); - self->alloc = self->len + len_adj; - } - mp_seq_replace_slice_grow_inplace(self->items, self->len, - slice_out.start, slice_out.stop, value_items, value_len, len_adj, sizeof(*self->items)); - } else { - mp_seq_replace_slice_no_grow(self->items, self->len, - slice_out.start, slice_out.stop, value_items, value_len, sizeof(*self->items)); - // Clear "freed" elements at the end of list - mp_seq_clear(self->items, self->len + len_adj, self->len, sizeof(*self->items)); - // TODO: apply allocation policy re: alloc_size - } - self->len += len_adj; - return mp_const_none; - } -#endif - mp_obj_list_store(self_in, index, value); - return mp_const_none; - } -} - -STATIC mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - return mp_obj_new_list_iterator(o_in, 0, iter_buf); -} - -mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - if (self->len >= self->alloc) { - self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc * 2); - self->alloc *= 2; - mp_seq_clear(self->items, self->len + 1, self->alloc, sizeof(*self->items)); - } - self->items[self->len++] = arg; - return mp_const_none; // return None, as per CPython -} - -STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - if (MP_OBJ_IS_TYPE(arg_in, &mp_type_list)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_list_t *arg = MP_OBJ_TO_PTR(arg_in); - - if (self->len + arg->len > self->alloc) { - // TODO: use alloc policy for "4" - self->items = m_renew(mp_obj_t, self->items, self->alloc, self->len + arg->len + 4); - self->alloc = self->len + arg->len + 4; - mp_seq_clear(self->items, self->len + arg->len, self->alloc, sizeof(*self->items)); - } - - memcpy(self->items + self->len, arg->items, sizeof(mp_obj_t) * arg->len); - self->len += arg->len; - } else { - list_extend_from_iter(self_in, arg_in); - } - return mp_const_none; // return None, as per CPython -} - -STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) { - mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]); - if (self->len == 0) { - mp_raise_msg(&mp_type_IndexError, "pop from empty list"); - } - size_t index = mp_get_index(self->base.type, self->len, n_args == 1 ? MP_OBJ_NEW_SMALL_INT(-1) : args[1], false); - mp_obj_t ret = self->items[index]; - self->len -= 1; - memmove(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t)); - // Clear stale pointer from slot which just got freed to prevent GC issues - self->items[self->len] = MP_OBJ_NULL; - if (self->alloc > LIST_MIN_ALLOC && self->alloc > 2 * self->len) { - self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc/2); - self->alloc /= 2; - } - return ret; -} - -STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) { - MP_STACK_CHECK(); - while (head < tail) { - mp_obj_t *h = head - 1; - mp_obj_t *t = tail; - mp_obj_t v = key_fn == MP_OBJ_NULL ? tail[0] : mp_call_function_1(key_fn, tail[0]); // get pivot using key_fn - for (;;) { - do ++h; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, key_fn == MP_OBJ_NULL ? h[0] : mp_call_function_1(key_fn, h[0]), v) == binop_less_result); - do --t; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, v, key_fn == MP_OBJ_NULL ? t[0] : mp_call_function_1(key_fn, t[0])) == binop_less_result); - if (h >= t) break; - mp_obj_t x = h[0]; - h[0] = t[0]; - t[0] = x; - } - mp_obj_t x = h[0]; - h[0] = tail[0]; - tail[0] = x; - // do the smaller recursive call first, to keep stack within O(log(N)) - if (t - head < tail - h - 1) { - mp_quicksort(head, t, key_fn, binop_less_result); - head = h + 1; - } else { - mp_quicksort(h + 1, tail, key_fn, binop_less_result); - tail = t; - } - } -} - -// TODO Python defines sort to be stable but ours is not -mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - static const mp_arg_t allowed_args[] = { - { MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - { MP_QSTR_reverse, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, - }; - - // parse args - struct { - mp_arg_val_t key, reverse; - } args; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, - MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); - - mp_check_self(MP_OBJ_IS_TYPE(pos_args[0], &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(pos_args[0]); - - if (self->len > 1) { - mp_quicksort(self->items, self->items + self->len - 1, - args.key.u_obj == mp_const_none ? MP_OBJ_NULL : args.key.u_obj, - args.reverse.u_bool ? mp_const_false : mp_const_true); - } - - return mp_const_none; -} - -STATIC mp_obj_t list_clear(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - self->len = 0; - self->items = m_renew(mp_obj_t, self->items, self->alloc, LIST_MIN_ALLOC); - self->alloc = LIST_MIN_ALLOC; - mp_seq_clear(self->items, 0, self->alloc, sizeof(*self->items)); - return mp_const_none; -} - -STATIC mp_obj_t list_copy(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_list(self->len, self->items); -} - -STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - return mp_seq_count_obj(self->items, self->len, value); -} - -STATIC mp_obj_t list_index(size_t n_args, const mp_obj_t *args) { - mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]); - return mp_seq_index_obj(self->items, self->len, n_args, args); -} - -STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - // insert has its own strange index logic - mp_int_t index = MP_OBJ_SMALL_INT_VALUE(idx); - if (index < 0) { - index += self->len; - } - if (index < 0) { - index = 0; - } - if ((size_t)index > self->len) { - index = self->len; - } - - mp_obj_list_append(self_in, mp_const_none); - - for (mp_int_t i = self->len-1; i > index; i--) { - self->items[i] = self->items[i-1]; - } - self->items[index] = obj; - - return mp_const_none; -} - -mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_t args[] = {self_in, value}; - args[1] = list_index(2, args); - list_pop(2, args); - - return mp_const_none; -} - -STATIC mp_obj_t list_reverse(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - - mp_int_t len = self->len; - for (mp_int_t i = 0; i < len/2; i++) { - mp_obj_t a = self->items[i]; - self->items[i] = self->items[len-i-1]; - self->items[len-i-1] = a; - } - - return mp_const_none; -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append); -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy); -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count); -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index); -STATIC MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert); -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop); -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse); -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort); - -STATIC const mp_rom_map_elem_t list_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&list_append_obj) }, - { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&list_clear_obj) }, - { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&list_copy_obj) }, - { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&list_count_obj) }, - { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&list_extend_obj) }, - { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&list_index_obj) }, - { MP_ROM_QSTR(MP_QSTR_insert), MP_ROM_PTR(&list_insert_obj) }, - { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&list_pop_obj) }, - { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&list_remove_obj) }, - { MP_ROM_QSTR(MP_QSTR_reverse), MP_ROM_PTR(&list_reverse_obj) }, - { MP_ROM_QSTR(MP_QSTR_sort), MP_ROM_PTR(&list_sort_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table); - -const mp_obj_type_t mp_type_list = { - { &mp_type_type }, - .name = MP_QSTR_list, - .print = list_print, - .make_new = list_make_new, - .unary_op = list_unary_op, - .binary_op = list_binary_op, - .subscr = list_subscr, - .getiter = list_getiter, - .locals_dict = (mp_obj_dict_t*)&list_locals_dict, -}; - -void mp_obj_list_init(mp_obj_list_t *o, size_t n) { - o->base.type = &mp_type_list; - o->alloc = n < LIST_MIN_ALLOC ? LIST_MIN_ALLOC : n; - o->len = n; - o->items = m_new(mp_obj_t, o->alloc); - mp_seq_clear(o->items, n, o->alloc, sizeof(*o->items)); -} - -STATIC mp_obj_list_t *list_new(size_t n) { - mp_obj_list_t *o = m_new_obj(mp_obj_list_t); - mp_obj_list_init(o, n); - return o; -} - -mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items) { - mp_obj_list_t *o = list_new(n); - if (items != NULL) { - for (size_t i = 0; i < n; i++) { - o->items[i] = items[i]; - } - } - return MP_OBJ_FROM_PTR(o); -} - -void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - *len = self->len; - *items = self->items; -} - -void mp_obj_list_set_len(mp_obj_t self_in, size_t len) { - // trust that the caller knows what it's doing - // TODO realloc if len got much smaller than alloc - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - self->len = len; -} - -void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - size_t i = mp_get_index(self->base.type, self->len, index, false); - self->items[i] = value; -} - -/******************************************************************************/ -/* list iterator */ - -typedef struct _mp_obj_list_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t list; - size_t cur; -} mp_obj_list_it_t; - -STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) { - mp_obj_list_it_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_list_t *list = MP_OBJ_TO_PTR(self->list); - if (self->cur < list->len) { - mp_obj_t o_out = list->items[self->cur]; - self->cur += 1; - return o_out; - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_list_it_t *o = (mp_obj_list_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = list_it_iternext; - o->list = list; - o->cur = cur; - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objlist.h b/user/mpy/py/objlist.h deleted file mode 100644 index 28b5495..0000000 --- a/user/mpy/py/objlist.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 - -#include "py/obj.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; - -#endif // MICROPY_INCLUDED_PY_OBJLIST_H diff --git a/user/mpy/py/objmap.c b/user/mpy/py/objmap.c deleted file mode 100644 index 908c615..0000000 --- a/user/mpy/py/objmap.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime.h" - -typedef struct _mp_obj_map_t { - mp_obj_base_t base; - size_t n_iters; - mp_obj_t fun; - mp_obj_t iters[]; -} mp_obj_map_t; - -STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false); - mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1); - o->base.type = type; - o->n_iters = n_args - 1; - o->fun = args[0]; - for (size_t i = 0; i < n_args - 1; i++) { - o->iters[i] = mp_getiter(args[i + 1], NULL); - } - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t map_iternext(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_map)); - mp_obj_map_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters); - - for (size_t i = 0; i < self->n_iters; i++) { - mp_obj_t next = mp_iternext(self->iters[i]); - if (next == MP_OBJ_STOP_ITERATION) { - m_del(mp_obj_t, nextses, self->n_iters); - return MP_OBJ_STOP_ITERATION; - } - nextses[i] = next; - } - return mp_call_function_n_kw(self->fun, self->n_iters, 0, nextses); -} - -const mp_obj_type_t mp_type_map = { - { &mp_type_type }, - .name = MP_QSTR_map, - .make_new = map_make_new, - .getiter = mp_identity_getiter, - .iternext = map_iternext, -}; diff --git a/user/mpy/py/objmodule.c b/user/mpy/py/objmodule.c deleted file mode 100644 index fc8507c..0000000 --- a/user/mpy/py/objmodule.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/mpstate.h" -#include "py/nlr.h" -#include "py/objmodule.h" -#include "py/runtime.h" -#include "py/builtin.h" - -STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); - - const char *module_name = ""; - mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_MAP_LOOKUP); - if (elem != NULL) { - module_name = mp_obj_str_get_str(elem->value); - } - -#if MICROPY_PY___FILE__ - // If we store __file__ to imported modules then try to lookup this - // symbol to give more information about the module. - elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___file__), MP_MAP_LOOKUP); - if (elem != NULL) { - mp_printf(print, "", module_name, mp_obj_str_get_str(elem->value)); - return; - } -#endif - - mp_printf(print, "", module_name); -} - -STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); - if (dest[0] == MP_OBJ_NULL) { - // load attribute - mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); - if (elem != NULL) { - dest[0] = elem->value; - } - } else { - // delete/store attribute - mp_obj_dict_t *dict = self->globals; - if (dict->map.is_fixed) { - #if MICROPY_CAN_OVERRIDE_BUILTINS - if (dict == &mp_module_builtins_globals) { - if (MP_STATE_VM(mp_module_builtins_override_dict) == NULL) { - MP_STATE_VM(mp_module_builtins_override_dict) = MP_OBJ_TO_PTR(mp_obj_new_dict(1)); - } - dict = MP_STATE_VM(mp_module_builtins_override_dict); - } else - #endif - { - // can't delete or store to fixed map - return; - } - } - if (dest[1] == MP_OBJ_NULL) { - // delete attribute - mp_obj_dict_delete(MP_OBJ_FROM_PTR(dict), MP_OBJ_NEW_QSTR(attr)); - } else { - // store attribute - // TODO CPython allows STORE_ATTR to a module, but is this the correct implementation? - mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), MP_OBJ_NEW_QSTR(attr), dest[1]); - } - dest[0] = MP_OBJ_NULL; // indicate success - } -} - -const mp_obj_type_t mp_type_module = { - { &mp_type_type }, - .name = MP_QSTR_module, - .print = module_print, - .attr = module_attr, -}; - -mp_obj_t mp_obj_new_module(qstr module_name) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - // We could error out if module already exists, but let C extensions - // add new members to existing modules. - if (el->value != MP_OBJ_NULL) { - return el->value; - } - - // create new module object - mp_obj_module_t *o = m_new_obj(mp_obj_module_t); - o->base.type = &mp_type_module; - o->globals = MP_OBJ_TO_PTR(mp_obj_new_dict(MICROPY_MODULE_DICT_SIZE)); - - // store __name__ entry in the module - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(module_name)); - - // store the new module into the slot in the global dict holding all modules - el->value = MP_OBJ_FROM_PTR(o); - - // return the new module - return MP_OBJ_FROM_PTR(o); -} - -mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_module)); - mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); - return self->globals; -} - -/******************************************************************************/ -// Global module table and related functions - -STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { - { MP_ROM_QSTR(MP_QSTR___main__), MP_ROM_PTR(&mp_module___main__) }, - { MP_ROM_QSTR(MP_QSTR_builtins), MP_ROM_PTR(&mp_module_builtins) }, - { MP_ROM_QSTR(MP_QSTR_micropython), MP_ROM_PTR(&mp_module_micropython) }, - -#if MICROPY_PY_ARRAY - { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_module_array) }, -#endif -#if MICROPY_PY_IO - { MP_ROM_QSTR(MP_QSTR_uio), MP_ROM_PTR(&mp_module_io) }, -#endif -#if MICROPY_PY_COLLECTIONS - { MP_ROM_QSTR(MP_QSTR_ucollections), MP_ROM_PTR(&mp_module_collections) }, -#endif -#if MICROPY_PY_STRUCT - { MP_ROM_QSTR(MP_QSTR_ustruct), MP_ROM_PTR(&mp_module_ustruct) }, -#endif - -#if MICROPY_PY_BUILTINS_FLOAT -#if MICROPY_PY_MATH - { MP_ROM_QSTR(MP_QSTR_math), MP_ROM_PTR(&mp_module_math) }, -#endif -#if MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH - { MP_ROM_QSTR(MP_QSTR_cmath), MP_ROM_PTR(&mp_module_cmath) }, -#endif -#endif -#if MICROPY_PY_SYS - { MP_ROM_QSTR(MP_QSTR_sys), MP_ROM_PTR(&mp_module_sys) }, -#endif -#if MICROPY_PY_GC && MICROPY_ENABLE_GC - { MP_ROM_QSTR(MP_QSTR_gc), MP_ROM_PTR(&mp_module_gc) }, -#endif -#if MICROPY_PY_THREAD - { MP_ROM_QSTR(MP_QSTR__thread), MP_ROM_PTR(&mp_module_thread) }, -#endif - - // extmod modules - -#if MICROPY_PY_UERRNO - { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) }, -#endif -#if MICROPY_PY_UCTYPES - { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, -#endif -#if MICROPY_PY_UZLIB - { MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) }, -#endif -#if MICROPY_PY_UJSON - { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) }, -#endif -#if MICROPY_PY_URE - { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) }, -#endif -#if MICROPY_PY_UHEAPQ - { MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) }, -#endif -#if MICROPY_PY_UTIMEQ - { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&mp_module_utimeq) }, -#endif -#if MICROPY_PY_UHASHLIB - { MP_ROM_QSTR(MP_QSTR_uhashlib), MP_ROM_PTR(&mp_module_uhashlib) }, -#endif -#if MICROPY_PY_UBINASCII - { MP_ROM_QSTR(MP_QSTR_ubinascii), MP_ROM_PTR(&mp_module_ubinascii) }, -#endif -#if MICROPY_PY_URANDOM - { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_module_urandom) }, -#endif -#if MICROPY_PY_USELECT - { MP_ROM_QSTR(MP_QSTR_uselect), MP_ROM_PTR(&mp_module_uselect) }, -#endif -#if MICROPY_PY_USSL - { MP_ROM_QSTR(MP_QSTR_ussl), MP_ROM_PTR(&mp_module_ussl) }, -#endif -#if MICROPY_PY_LWIP - { MP_ROM_QSTR(MP_QSTR_lwip), MP_ROM_PTR(&mp_module_lwip) }, -#endif -#if MICROPY_PY_WEBSOCKET - { MP_ROM_QSTR(MP_QSTR_websocket), MP_ROM_PTR(&mp_module_websocket) }, -#endif -#if MICROPY_PY_WEBREPL - { MP_ROM_QSTR(MP_QSTR__webrepl), MP_ROM_PTR(&mp_module_webrepl) }, -#endif -#if MICROPY_PY_FRAMEBUF - { MP_ROM_QSTR(MP_QSTR_framebuf), MP_ROM_PTR(&mp_module_framebuf) }, -#endif -#if MICROPY_PY_BTREE - { MP_ROM_QSTR(MP_QSTR_btree), MP_ROM_PTR(&mp_module_btree) }, -#endif - - // extra builtin modules as defined by a port - MICROPY_PORT_BUILTIN_MODULES -}; - -MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); - -#if MICROPY_MODULE_WEAK_LINKS -STATIC const mp_rom_map_elem_t mp_builtin_module_weak_links_table[] = { - MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS -}; - -MP_DEFINE_CONST_MAP(mp_builtin_module_weak_links_map, mp_builtin_module_weak_links_table); -#endif - -// returns MP_OBJ_NULL if not found -mp_obj_t mp_module_get(qstr module_name) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - // lookup module - mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); - - if (el == NULL) { - // module not found, look for builtin module names - el = mp_map_lookup((mp_map_t*)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); - if (el == NULL) { - return MP_OBJ_NULL; - } - - if (MICROPY_MODULE_BUILTIN_INIT) { - // look for __init__ and call it if it exists - mp_obj_t dest[2]; - mp_load_method_maybe(el->value, MP_QSTR___init__, dest); - if (dest[0] != MP_OBJ_NULL) { - mp_call_method_n_kw(0, 0, dest); - // register module so __init__ is not called again - mp_module_register(module_name, el->value); - } - } - } - - // module found, return it - return el->value; -} - -void mp_module_register(qstr qst, mp_obj_t module) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; -} diff --git a/user/mpy/py/objmodule.h b/user/mpy/py/objmodule.h deleted file mode 100644 index b5c07dc..0000000 --- a/user/mpy/py/objmodule.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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_OBJMODULE_H -#define MICROPY_INCLUDED_PY_OBJMODULE_H - -#include "py/obj.h" - -extern const mp_map_t mp_builtin_module_map; -extern const mp_map_t mp_builtin_module_weak_links_map; - -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); - -#endif // MICROPY_INCLUDED_PY_OBJMODULE_H diff --git a/user/mpy/py/objnamedtuple.c b/user/mpy/py/objnamedtuple.c deleted file mode 100644 index fb9d9f0..0000000 --- a/user/mpy/py/objnamedtuple.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/nlr.h" -#include "py/objtuple.h" -#include "py/runtime.h" -#include "py/objstr.h" - -#if MICROPY_PY_COLLECTIONS - -typedef struct _mp_obj_namedtuple_type_t { - mp_obj_type_t base; - size_t n_fields; - qstr fields[]; -} mp_obj_namedtuple_type_t; - -typedef struct _mp_obj_namedtuple_t { - mp_obj_tuple_t tuple; -} mp_obj_namedtuple_t; - -STATIC size_t namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name) { - for (size_t i = 0; i < type->n_fields; i++) { - if (type->fields[i] == name) { - return i; - } - } - return (size_t)-1; -} - -STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_namedtuple_t *o = MP_OBJ_TO_PTR(o_in); - mp_printf(print, "%q", o->tuple.base.type->name); - const qstr *fields = ((mp_obj_namedtuple_type_t*)o->tuple.base.type)->fields; - mp_obj_attrtuple_print_helper(print, fields, &o->tuple); -} - -STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] == MP_OBJ_NULL) { - // load attribute - mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in); - size_t id = namedtuple_find_field((mp_obj_namedtuple_type_t*)self->tuple.base.type, attr); - if (id == (size_t)-1) { - return; - } - dest[0] = self->tuple.items[id]; - } else { - // delete/store attribute - // provide more detailed error message than we'd get by just returning - mp_raise_msg(&mp_type_AttributeError, "can't set attribute"); - } -} - -STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t*)type_in; - size_t num_fields = type->n_fields; - if (n_args + n_kw != num_fields) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function takes %d positional arguments but %d were given", - num_fields, n_args + n_kw)); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "%q() takes %d positional arguments but %d were given", - type->base.name, num_fields, n_args + n_kw)); - } - } - - // Create a tuple and set the type to this namedtuple - mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_fields, NULL)); - tuple->base.type = type_in; - - // Copy the positional args into the first slots of the namedtuple - memcpy(&tuple->items[0], args, sizeof(mp_obj_t) * n_args); - - // Fill in the remaining slots with the keyword args - memset(&tuple->items[n_args], 0, sizeof(mp_obj_t) * n_kw); - for (size_t i = n_args; i < n_args + 2 * n_kw; i += 2) { - qstr kw = mp_obj_str_get_qstr(args[i]); - size_t id = namedtuple_find_field(type, kw); - if (id == (size_t)-1) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "unexpected keyword argument '%q'", kw)); - } - } - if (tuple->items[id] != MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_arg_error_terse_mismatch(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "function got multiple values for argument '%q'", kw)); - } - } - tuple->items[id] = args[i + 1]; - } - - return MP_OBJ_FROM_PTR(tuple); -} - -STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) { - mp_obj_namedtuple_type_t *o = m_new_obj_var(mp_obj_namedtuple_type_t, qstr, n_fields); - memset(&o->base, 0, sizeof(o->base)); - o->base.base.type = &mp_type_type; - o->base.name = name; - o->base.print = namedtuple_print; - o->base.make_new = namedtuple_make_new; - o->base.unary_op = mp_obj_tuple_unary_op; - o->base.binary_op = mp_obj_tuple_binary_op; - o->base.attr = namedtuple_attr; - o->base.subscr = mp_obj_tuple_subscr; - o->base.getiter = mp_obj_tuple_getiter; - o->base.parent = &mp_type_tuple; - o->n_fields = n_fields; - for (size_t i = 0; i < n_fields; i++) { - o->fields[i] = mp_obj_str_get_qstr(fields[i]); - } - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) { - qstr name = mp_obj_str_get_qstr(name_in); - size_t n_fields; - mp_obj_t *fields; - #if MICROPY_CPYTHON_COMPAT - if (MP_OBJ_IS_STR(fields_in)) { - fields_in = mp_obj_str_split(1, &fields_in); - } - #endif - mp_obj_get_array(fields_in, &n_fields, &fields); - return mp_obj_new_namedtuple_type(name, n_fields, fields); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_namedtuple_obj, new_namedtuple_type); - -#endif // MICROPY_PY_COLLECTIONS diff --git a/user/mpy/py/objnone.c b/user/mpy/py/objnone.c deleted file mode 100644 index cd7319b..0000000 --- a/user/mpy/py/objnone.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime0.h" - -typedef struct _mp_obj_none_t { - mp_obj_base_t base; -} mp_obj_none_t; - -STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)self_in; - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { - mp_print_str(print, "null"); - } else { - mp_print_str(print, "None"); - } -} - -const mp_obj_type_t mp_type_NoneType = { - { &mp_type_type }, - .name = MP_QSTR_NoneType, - .print = none_print, - .unary_op = mp_generic_unary_op, -}; - -const mp_obj_none_t mp_const_none_obj = {{&mp_type_NoneType}}; diff --git a/user/mpy/py/objobject.c b/user/mpy/py/objobject.c deleted file mode 100644 index 49d2ec6..0000000 --- a/user/mpy/py/objobject.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/objtype.h" -#include "py/runtime.h" - -typedef struct _mp_obj_object_t { - mp_obj_base_t base; -} mp_obj_object_t; - -STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)args; - mp_arg_check_num(n_args, n_kw, 0, 0, false); - mp_obj_object_t *o = m_new_obj(mp_obj_object_t); - o->base.type = type; - return MP_OBJ_FROM_PTR(o); -} - -#if MICROPY_CPYTHON_COMPAT -STATIC mp_obj_t object___init__(mp_obj_t self) { - (void)self; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__); - -STATIC mp_obj_t object___new__(mp_obj_t cls) { - if (!MP_OBJ_IS_TYPE(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t*)MP_OBJ_TO_PTR(cls))) { - mp_raise_TypeError("__new__ arg must be a user-type"); - } - mp_obj_t o = MP_OBJ_SENTINEL; - mp_obj_t res = mp_obj_instance_make_new(MP_OBJ_TO_PTR(cls), 1, 0, &o); - return res; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__); -STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj)); - -STATIC const mp_rom_map_elem_t object_locals_dict_table[] = { - #if MICROPY_CPYTHON_COMPAT - { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&object___init___obj) }, - #endif - #if MICROPY_CPYTHON_COMPAT - { MP_ROM_QSTR(MP_QSTR___new__), MP_ROM_PTR(&object___new___obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table); -#endif - -const mp_obj_type_t mp_type_object = { - { &mp_type_type }, - .name = MP_QSTR_object, - .make_new = object_make_new, - #if MICROPY_CPYTHON_COMPAT - .locals_dict = (mp_obj_dict_t*)&object_locals_dict, - #endif -}; diff --git a/user/mpy/py/objpolyiter.c b/user/mpy/py/objpolyiter.c deleted file mode 100644 index 61bd1e0..0000000 --- a/user/mpy/py/objpolyiter.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 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. - */ - -#include - -#include "py/nlr.h" -#include "py/runtime.h" - -// This is universal iterator type which calls "iternext" method stored in -// particular object instance. (So, each instance of this time can have its -// own iteration behavior.) Having this type saves to define type objects -// for various internal iterator objects. - -// Any instance should have these 2 fields at the beginning -typedef struct _mp_obj_polymorph_iter_t { - mp_obj_base_t base; - mp_fun_1_t iternext; -} mp_obj_polymorph_iter_t; - -STATIC mp_obj_t polymorph_it_iternext(mp_obj_t self_in) { - mp_obj_polymorph_iter_t *self = MP_OBJ_TO_PTR(self_in); - // Redirect call to object instance's iternext method - return self->iternext(self_in); -} - -const mp_obj_type_t mp_type_polymorph_iter = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = polymorph_it_iternext, -}; diff --git a/user/mpy/py/objproperty.c b/user/mpy/py/objproperty.c deleted file mode 100644 index 0934fad..0000000 --- a/user/mpy/py/objproperty.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_PROPERTY - -typedef struct _mp_obj_property_t { - mp_obj_base_t base; - mp_obj_t proxy[3]; // getter, setter, deleter -} mp_obj_property_t; - -STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - enum { ARG_fget, ARG_fset, ARG_fdel, ARG_doc }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - { MP_QSTR_doc, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} }, - }; - mp_arg_val_t vals[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, vals); - - mp_obj_property_t *o = m_new_obj(mp_obj_property_t); - o->base.type = type; - o->proxy[0] = vals[ARG_fget].u_obj; - o->proxy[1] = vals[ARG_fset].u_obj; - o->proxy[2] = vals[ARG_fdel].u_obj; - // vals[ARG_doc] is silently discarded - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) { - mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t); - *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in); - p2->proxy[0] = getter; - return MP_OBJ_FROM_PTR(p2); -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter); - -STATIC mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) { - mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t); - *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in); - p2->proxy[1] = setter; - return MP_OBJ_FROM_PTR(p2); -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter); - -STATIC mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) { - mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t); - *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in); - p2->proxy[2] = deleter; - return MP_OBJ_FROM_PTR(p2); -} - -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter); - -STATIC const mp_rom_map_elem_t property_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_getter), MP_ROM_PTR(&property_getter_obj) }, - { MP_ROM_QSTR(MP_QSTR_setter), MP_ROM_PTR(&property_setter_obj) }, - { MP_ROM_QSTR(MP_QSTR_deleter), MP_ROM_PTR(&property_deleter_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table); - -const mp_obj_type_t mp_type_property = { - { &mp_type_type }, - .name = MP_QSTR_property, - .make_new = property_make_new, - .locals_dict = (mp_obj_dict_t*)&property_locals_dict, -}; - -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_property)); - mp_obj_property_t *self = MP_OBJ_TO_PTR(self_in); - return self->proxy; -} - -#endif // MICROPY_PY_BUILTINS_PROPERTY diff --git a/user/mpy/py/objrange.c b/user/mpy/py/objrange.c deleted file mode 100644 index 33b07a9..0000000 --- a/user/mpy/py/objrange.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/nlr.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -/******************************************************************************/ -/* range iterator */ - -typedef struct _mp_obj_range_it_t { - mp_obj_base_t base; - // TODO make these values generic objects or something - mp_int_t cur; - mp_int_t stop; - mp_int_t step; -} mp_obj_range_it_t; - -STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) { - mp_obj_range_it_t *o = MP_OBJ_TO_PTR(o_in); - if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) { - mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(o->cur); - o->cur += o->step; - return o_out; - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -STATIC const mp_obj_type_t range_it_type = { - { &mp_type_type }, - .name = MP_QSTR_iterator, - .getiter = mp_identity_getiter, - .iternext = range_it_iternext, -}; - -STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_range_it_t *o = (mp_obj_range_it_t*)iter_buf; - o->base.type = &range_it_type; - o->cur = cur; - o->stop = stop; - o->step = step; - return MP_OBJ_FROM_PTR(o); -} - -/******************************************************************************/ -/* range */ - -typedef struct _mp_obj_range_t { - mp_obj_base_t base; - // TODO make these values generic objects or something - mp_int_t start; - mp_int_t stop; - mp_int_t step; -} mp_obj_range_t; - -STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "range(" INT_FMT ", " INT_FMT "", self->start, self->stop); - if (self->step == 1) { - mp_print_str(print, ")"); - } else { - mp_printf(print, ", " INT_FMT ")", self->step); - } -} - -STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 3, false); - - mp_obj_range_t *o = m_new_obj(mp_obj_range_t); - o->base.type = type; - o->start = 0; - o->step = 1; - - if (n_args == 1) { - o->stop = mp_obj_get_int(args[0]); - } else { - o->start = mp_obj_get_int(args[0]); - o->stop = mp_obj_get_int(args[1]); - if (n_args == 3) { - o->step = mp_obj_get_int(args[2]); - if (o->step == 0) { - mp_raise_ValueError("zero step"); - } - } - } - - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_int_t range_len(mp_obj_range_t *self) { - // When computing length, need to take into account step!=1 and step<0. - mp_int_t len = self->stop - self->start + self->step; - if (self->step > 0) { - len -= 1; - } else { - len += 1; - } - len = len / self->step; - if (len < 0) { - len = 0; - } - return len; -} - -STATIC mp_obj_t range_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t len = range_len(self); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len > 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == MP_OBJ_SENTINEL) { - // load - mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t len = range_len(self); -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_bound_slice_t slice; - mp_seq_get_fast_slice_indexes(len, index, &slice); - mp_obj_range_t *o = m_new_obj(mp_obj_range_t); - o->base.type = &mp_type_range; - o->start = self->start + slice.start * self->step; - o->stop = self->start + slice.stop * self->step; - o->step = slice.step * self->step; - if (slice.step < 0) { - // Negative slice steps have inclusive stop, so adjust for exclusive - o->stop -= self->step; - } - return MP_OBJ_FROM_PTR(o); - } -#endif - size_t index_val = mp_get_index(self->base.type, len, index, false); - return MP_OBJ_NEW_SMALL_INT(self->start + index_val * self->step); - } else { - return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in); - return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf); -} - - -#if MICROPY_PY_BUILTINS_RANGE_ATTRS -STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != MP_OBJ_NULL) { - // not load attribute - return; - } - mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in); - if (attr == MP_QSTR_start) { - dest[0] = mp_obj_new_int(o->start); - } else if (attr == MP_QSTR_stop) { - dest[0] = mp_obj_new_int(o->stop); - } else if (attr == MP_QSTR_step) { - dest[0] = mp_obj_new_int(o->step); - } -} -#endif - -const mp_obj_type_t mp_type_range = { - { &mp_type_type }, - .name = MP_QSTR_range, - .print = range_print, - .make_new = range_make_new, - .unary_op = range_unary_op, - .subscr = range_subscr, - .getiter = range_getiter, -#if MICROPY_PY_BUILTINS_RANGE_ATTRS - .attr = range_attr, -#endif -}; diff --git a/user/mpy/py/objreversed.c b/user/mpy/py/objreversed.c deleted file mode 100644 index a596a2f..0000000 --- a/user/mpy/py/objreversed.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_REVERSED - -typedef struct _mp_obj_reversed_t { - mp_obj_base_t base; - mp_obj_t seq; // sequence object that we are reversing - mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0) -} mp_obj_reversed_t; - -STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 1, false); - - // check if __reversed__ exists, and if so delegate to it - mp_obj_t dest[2]; - mp_load_method_maybe(args[0], MP_QSTR___reversed__, dest); - if (dest[0] != MP_OBJ_NULL) { - return mp_call_method_n_kw(0, 0, dest); - } - - mp_obj_reversed_t *o = m_new_obj(mp_obj_reversed_t); - o->base.type = type; - o->seq = args[0]; - o->cur_index = mp_obj_get_int(mp_obj_len(args[0])); // start at the end of the sequence - - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_reversed)); - mp_obj_reversed_t *self = MP_OBJ_TO_PTR(self_in); - - // "raise" stop iteration if we are at the end (the start) of the sequence - if (self->cur_index == 0) { - return MP_OBJ_STOP_ITERATION; - } - - // pre-decrement and index sequence - self->cur_index -= 1; - return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); -} - -const mp_obj_type_t mp_type_reversed = { - { &mp_type_type }, - .name = MP_QSTR_reversed, - .make_new = reversed_make_new, - .getiter = mp_identity_getiter, - .iternext = reversed_iternext, -}; - -#endif // MICROPY_PY_BUILTINS_REVERSED diff --git a/user/mpy/py/objset.c b/user/mpy/py/objset.c deleted file mode 100644 index 376439b..0000000 --- a/user/mpy/py/objset.c +++ /dev/null @@ -1,609 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/runtime0.h" -#include "py/builtin.h" - -#if MICROPY_PY_BUILTINS_SET - -typedef struct _mp_obj_set_t { - mp_obj_base_t base; - mp_set_t set; -} mp_obj_set_t; - -typedef struct _mp_obj_set_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_set_t *set; - size_t cur; -} mp_obj_set_it_t; - -STATIC mp_obj_t set_it_iternext(mp_obj_t self_in); - -STATIC bool is_set_or_frozenset(mp_obj_t o) { - return MP_OBJ_IS_TYPE(o, &mp_type_set) -#if MICROPY_PY_BUILTINS_FROZENSET - || MP_OBJ_IS_TYPE(o, &mp_type_frozenset) -#endif - ; -} - -// This macro is shorthand for mp_check_self to verify the argument is a -// set or frozenset for methods that operate on both of these types. -#define check_set_or_frozenset(o) mp_check_self(is_set_or_frozenset(o)) - -// This function is used to verify the argument for methods that modify -// the set object, and raises an exception if the arg is a frozenset. -STATIC void check_set(mp_obj_t o) { - #if MICROPY_PY_BUILTINS_FROZENSET - if (MP_OBJ_IS_TYPE(o, &mp_type_frozenset)) { - // Mutable method called on frozenset; emulate CPython behavior, eg: - // AttributeError: 'frozenset' object has no attribute 'add' - mp_raise_msg(&mp_type_AttributeError, "'frozenset' has no such attribute"); - } - #endif - mp_check_self(MP_OBJ_IS_TYPE(o, &mp_type_set)); -} - -STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - #if MICROPY_PY_BUILTINS_FROZENSET - bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset); - #endif - if (self->set.used == 0) { - #if MICROPY_PY_BUILTINS_FROZENSET - if (is_frozen) { - mp_print_str(print, "frozen"); - } - #endif - mp_print_str(print, "set()"); - return; - } - bool first = true; - #if MICROPY_PY_BUILTINS_FROZENSET - if (is_frozen) { - mp_print_str(print, "frozenset("); - } - #endif - mp_print_str(print, "{"); - for (size_t i = 0; i < self->set.alloc; i++) { - if (MP_SET_SLOT_IS_FILLED(&self->set, i)) { - if (!first) { - mp_print_str(print, ", "); - } - first = false; - mp_obj_print_helper(print, self->set.table[i], PRINT_REPR); - } - } - mp_print_str(print, "}"); - #if MICROPY_PY_BUILTINS_FROZENSET - if (is_frozen) { - mp_print_str(print, ")"); - } - #endif -} - -STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); - - switch (n_args) { - case 0: { - // create a new, empty set - mp_obj_set_t *set = MP_OBJ_TO_PTR(mp_obj_new_set(0, NULL)); - // set actual set/frozenset type - set->base.type = type; - return MP_OBJ_FROM_PTR(set); - } - - case 1: - default: { // can only be 0 or 1 arg - // 1 argument, an iterable from which we make a new set - mp_obj_t set = mp_obj_new_set(0, NULL); - mp_obj_t iterable = mp_getiter(args[0], NULL); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - mp_obj_set_store(set, item); - } - // Set actual set/frozenset type - ((mp_obj_set_t*)MP_OBJ_TO_PTR(set))->base.type = type; - return set; - } - } -} - -STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) { - mp_obj_set_it_t *self = MP_OBJ_TO_PTR(self_in); - size_t max = self->set->set.alloc; - mp_set_t *set = &self->set->set; - - for (size_t i = self->cur; i < max; i++) { - if (MP_SET_SLOT_IS_FILLED(set, i)) { - self->cur = i + 1; - return set->table[i]; - } - } - - return MP_OBJ_STOP_ITERATION; -} - -STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_set_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_set_it_t *o = (mp_obj_set_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = set_it_iternext; - o->set = (mp_obj_set_t *)MP_OBJ_TO_PTR(set_in); - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} - - -/******************************************************************************/ -/* set methods */ - -STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) { - check_set(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add); - -STATIC mp_obj_t set_clear(mp_obj_t self_in) { - check_set(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - - mp_set_clear(&self->set); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear); - -STATIC mp_obj_t set_copy_as_mutable(mp_obj_t self_in) { - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - - mp_obj_set_t *other = m_new_obj(mp_obj_set_t); - other->base.type = &mp_type_set; - mp_set_init(&other->set, self->set.alloc); - other->set.used = self->set.used; - memcpy(other->set.table, self->set.table, self->set.alloc * sizeof(mp_obj_t)); - - return MP_OBJ_FROM_PTR(other); -} - -STATIC mp_obj_t set_copy(mp_obj_t self_in) { - check_set_or_frozenset(self_in); - - mp_obj_t other = set_copy_as_mutable(self_in); - ((mp_obj_base_t*)MP_OBJ_TO_PTR(other))->type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(self_in))->type; - - return other; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy); - -STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) { - check_set(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard); - -STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) { - mp_obj_t self; - if (update) { - check_set(args[0]); - self = args[0]; - } else { - check_set_or_frozenset(args[0]); - self = set_copy_as_mutable(args[0]); - } - - - for (size_t i = 1; i < n_args; i++) { - mp_obj_t other = args[i]; - if (self == other) { - set_clear(self); - } else { - mp_obj_t iter = mp_getiter(other, NULL); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - set_discard(self, next); - } - } - } - - ((mp_obj_base_t*)MP_OBJ_TO_PTR(self))->type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]))->type; - return self; -} - -STATIC mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) { - return set_diff_int(n_args, args, false); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff); - -STATIC mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) { - set_diff_int(n_args, args, true); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update); - -STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) { - if (update) { - check_set(self_in); - } else { - check_set_or_frozenset(self_in); - } - - if (self_in == other) { - return update ? mp_const_none : set_copy(self_in); - } - - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_set_t *out = MP_OBJ_TO_PTR(mp_obj_new_set(0, NULL)); - - mp_obj_t iter = mp_getiter(other, NULL); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) { - set_add(MP_OBJ_FROM_PTR(out), next); - } - } - - if (update) { - m_del(mp_obj_t, self->set.table, self->set.alloc); - self->set.alloc = out->set.alloc; - self->set.used = out->set.used; - self->set.table = out->set.table; - } - - return update ? mp_const_none : MP_OBJ_FROM_PTR(out); -} - -STATIC mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) { - return set_intersect_int(self_in, other, false); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect); - -STATIC mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) { - return set_intersect_int(self_in, other, true); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update); - -STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) { - check_set_or_frozenset(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - - mp_obj_iter_buf_t iter_buf; - mp_obj_t iter = mp_getiter(other, &iter_buf); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) { - return mp_const_false; - } - } - return mp_const_true; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint); - -STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) { - mp_obj_set_t *self; - bool cleanup_self = false; - if (is_set_or_frozenset(self_in)) { - self = MP_OBJ_TO_PTR(self_in); - } else { - self = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, 0, &self_in)); - cleanup_self = true; - } - - mp_obj_set_t *other; - bool cleanup_other = false; - if (is_set_or_frozenset(other_in)) { - other = MP_OBJ_TO_PTR(other_in); - } else { - other = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, 0, &other_in)); - cleanup_other = true; - } - bool out = true; - if (proper && self->set.used == other->set.used) { - out = false; - } else { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iter = set_getiter(MP_OBJ_FROM_PTR(self), &iter_buf); - mp_obj_t next; - while ((next = set_it_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - if (!mp_set_lookup(&other->set, next, MP_MAP_LOOKUP)) { - out = false; - break; - } - } - } - // TODO: Should free objects altogether - if (cleanup_self) { - set_clear(MP_OBJ_FROM_PTR(self)); - } - if (cleanup_other) { - set_clear(MP_OBJ_FROM_PTR(other)); - } - return mp_obj_new_bool(out); -} -STATIC mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) { - return set_issubset_internal(self_in, other_in, false); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset); - -STATIC mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) { - return set_issubset_internal(self_in, other_in, true); -} - -STATIC mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) { - return set_issubset_internal(other_in, self_in, false); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset); - -STATIC mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) { - return set_issubset_internal(other_in, self_in, true); -} - -STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) { - check_set_or_frozenset(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - if (!is_set_or_frozenset(other_in)) { - return mp_const_false; - } - mp_obj_set_t *other = MP_OBJ_TO_PTR(other_in); - if (self->set.used != other->set.used) { - return mp_const_false; - } - return set_issubset(self_in, other_in); -} - -STATIC mp_obj_t set_pop(mp_obj_t self_in) { - check_set(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t obj = mp_set_remove_first(&self->set); - if (obj == MP_OBJ_NULL) { - mp_raise_msg(&mp_type_KeyError, "pop from an empty set"); - } - return obj; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop); - -STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) { - check_set(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) { - nlr_raise(mp_obj_new_exception(&mp_type_KeyError)); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove); - -STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) { - check_set(self_in); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t iter = mp_getiter(other_in, NULL); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND_OR_REMOVE_IF_FOUND); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update); - -STATIC mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) { - check_set_or_frozenset(self_in); - mp_obj_t self_out = set_copy_as_mutable(self_in); - set_symmetric_difference_update(self_out, other_in); - ((mp_obj_base_t*)MP_OBJ_TO_PTR(self_out))->type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(self_in))->type; - return self_out; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference); - -STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) { - mp_obj_t iter = mp_getiter(other_in, NULL); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - } -} - -STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) { - check_set(args[0]); - for (size_t i = 1; i < n_args; i++) { - set_update_int(MP_OBJ_TO_PTR(args[0]), args[i]); - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update); - -STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) { - check_set_or_frozenset(self_in); - mp_obj_t self = set_copy(self_in); - set_update_int(MP_OBJ_TO_PTR(self), other_in); - return self; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union); - -STATIC mp_obj_t set_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->set.used != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->set.used); -#if MICROPY_PY_BUILTINS_FROZENSET - case MP_UNARY_OP_HASH: - if (MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset)) { - // start hash with unique value - mp_int_t hash = (mp_int_t)(uintptr_t)&mp_type_frozenset; - size_t max = self->set.alloc; - mp_set_t *set = &self->set; - - for (size_t i = 0; i < max; i++) { - if (MP_SET_SLOT_IS_FILLED(set, i)) { - hash += MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, set->table[i])); - } - } - return MP_OBJ_NEW_SMALL_INT(hash); - } -#endif - default: return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t set_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - mp_obj_t args[] = {lhs, rhs}; - #if MICROPY_PY_BUILTINS_FROZENSET - bool update = MP_OBJ_IS_TYPE(lhs, &mp_type_set); - #else - bool update = true; - #endif - switch (op) { - case MP_BINARY_OP_OR: - return set_union(lhs, rhs); - case MP_BINARY_OP_XOR: - return set_symmetric_difference(lhs, rhs); - case MP_BINARY_OP_AND: - return set_intersect(lhs, rhs); - case MP_BINARY_OP_SUBTRACT: - return set_diff(2, args); - case MP_BINARY_OP_INPLACE_OR: - if (update) { - set_update(2, args); - return lhs; - } else { - return set_union(lhs, rhs); - } - case MP_BINARY_OP_INPLACE_XOR: - if (update) { - set_symmetric_difference_update(lhs, rhs); - return lhs; - } else { - return set_symmetric_difference(lhs, rhs); - } - case MP_BINARY_OP_INPLACE_AND: - rhs = set_intersect_int(lhs, rhs, update); - if (update) { - return lhs; - } else { - return rhs; - } - case MP_BINARY_OP_INPLACE_SUBTRACT: - return set_diff_int(2, args, update); - case MP_BINARY_OP_LESS: - return set_issubset_proper(lhs, rhs); - case MP_BINARY_OP_MORE: - return set_issuperset_proper(lhs, rhs); - case MP_BINARY_OP_EQUAL: - return set_equal(lhs, rhs); - case MP_BINARY_OP_LESS_EQUAL: - return set_issubset(lhs, rhs); - case MP_BINARY_OP_MORE_EQUAL: - return set_issuperset(lhs, rhs); - case MP_BINARY_OP_IN: { - mp_obj_set_t *o = MP_OBJ_TO_PTR(lhs); - mp_obj_t elem = mp_set_lookup(&o->set, rhs, MP_MAP_LOOKUP); - return mp_obj_new_bool(elem != MP_OBJ_NULL); - } - default: - return MP_OBJ_NULL; // op not supported - } -} - -/******************************************************************************/ -/* set constructors & public C API */ - - -STATIC const mp_rom_map_elem_t set_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_add), MP_ROM_PTR(&set_add_obj) }, - { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&set_clear_obj) }, - { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) }, - { MP_ROM_QSTR(MP_QSTR_discard), MP_ROM_PTR(&set_discard_obj) }, - { MP_ROM_QSTR(MP_QSTR_difference), MP_ROM_PTR(&set_diff_obj) }, - { MP_ROM_QSTR(MP_QSTR_difference_update), MP_ROM_PTR(&set_diff_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_intersection), MP_ROM_PTR(&set_intersect_obj) }, - { MP_ROM_QSTR(MP_QSTR_intersection_update), MP_ROM_PTR(&set_intersect_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_isdisjoint), MP_ROM_PTR(&set_isdisjoint_obj) }, - { MP_ROM_QSTR(MP_QSTR_issubset), MP_ROM_PTR(&set_issubset_obj) }, - { MP_ROM_QSTR(MP_QSTR_issuperset), MP_ROM_PTR(&set_issuperset_obj) }, - { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&set_pop_obj) }, - { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&set_remove_obj) }, - { MP_ROM_QSTR(MP_QSTR_symmetric_difference), MP_ROM_PTR(&set_symmetric_difference_obj) }, - { MP_ROM_QSTR(MP_QSTR_symmetric_difference_update), MP_ROM_PTR(&set_symmetric_difference_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_union), MP_ROM_PTR(&set_union_obj) }, - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&set_update_obj) }, - { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table); - -const mp_obj_type_t mp_type_set = { - { &mp_type_type }, - .name = MP_QSTR_set, - .print = set_print, - .make_new = set_make_new, - .unary_op = set_unary_op, - .binary_op = set_binary_op, - .getiter = set_getiter, - .locals_dict = (mp_obj_dict_t*)&set_locals_dict, -}; - -#if MICROPY_PY_BUILTINS_FROZENSET -const mp_obj_type_t mp_type_frozenset = { - { &mp_type_type }, - .name = MP_QSTR_frozenset, - .print = set_print, - .make_new = set_make_new, - .unary_op = set_unary_op, - .binary_op = set_binary_op, - .getiter = set_getiter, - .locals_dict = (mp_obj_dict_t*)&set_locals_dict, -}; -#endif - -mp_obj_t mp_obj_new_set(size_t n_args, mp_obj_t *items) { - mp_obj_set_t *o = m_new_obj(mp_obj_set_t); - o->base.type = &mp_type_set; - mp_set_init(&o->set, n_args); - for (size_t i = 0; i < n_args; i++) { - mp_set_lookup(&o->set, items[i], MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - } - return MP_OBJ_FROM_PTR(o); -} - -void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_set)); - mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); - mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); -} - -#endif // MICROPY_PY_BUILTINS_SET diff --git a/user/mpy/py/objsingleton.c b/user/mpy/py/objsingleton.c deleted file mode 100644 index ea72ae3..0000000 --- a/user/mpy/py/objsingleton.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime0.h" - -/******************************************************************************/ -/* singleton objects defined by Python */ - -typedef struct _mp_obj_singleton_t { - mp_obj_base_t base; - qstr name; -} mp_obj_singleton_t; - -STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_singleton_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "%q", self->name); -} - -const mp_obj_type_t mp_type_singleton = { - { &mp_type_type }, - .name = MP_QSTR_, - .print = singleton_print, -}; - -const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis}; -#if MICROPY_PY_BUILTINS_NOTIMPLEMENTED -const mp_obj_singleton_t mp_const_notimplemented_obj = {{&mp_type_singleton}, MP_QSTR_NotImplemented}; -#endif diff --git a/user/mpy/py/objslice.c b/user/mpy/py/objslice.c deleted file mode 100644 index 358c44d..0000000 --- a/user/mpy/py/objslice.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime0.h" - -/******************************************************************************/ -/* slice object */ - -#if MICROPY_PY_BUILTINS_SLICE - -// TODO: This implements only variant of slice with 2 integer args only. -// CPython supports 3rd arg (step), plus args can be arbitrary Python objects. -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; - -STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_slice_t *o = MP_OBJ_TO_PTR(o_in); - mp_print_str(print, "slice("); - mp_obj_print_helper(print, o->start, PRINT_REPR); - mp_print_str(print, ", "); - mp_obj_print_helper(print, o->stop, PRINT_REPR); - mp_print_str(print, ", "); - mp_obj_print_helper(print, o->step, PRINT_REPR); - mp_print_str(print, ")"); -} - -#if MICROPY_PY_BUILTINS_SLICE_ATTRS -STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != MP_OBJ_NULL) { - // not load attribute - return; - } - mp_obj_slice_t *self = MP_OBJ_TO_PTR(self_in); - if (attr == MP_QSTR_start) { - dest[0] = self->start; - } else if (attr == MP_QSTR_stop) { - dest[0] = self->stop; - } else if (attr == MP_QSTR_step) { - dest[0] = self->step; - } -} -#endif - -const mp_obj_type_t mp_type_slice = { - { &mp_type_type }, - .name = MP_QSTR_slice, - .print = slice_print, -#if MICROPY_PY_BUILTINS_SLICE_ATTRS - .attr = slice_attr, -#endif -}; - -mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) { - mp_obj_slice_t *o = m_new_obj(mp_obj_slice_t); - o->base.type = &mp_type_slice; - o->start = ostart; - o->stop = ostop; - o->step = ostep; - return MP_OBJ_FROM_PTR(o); -} - -void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_slice)); - mp_obj_slice_t *self = MP_OBJ_TO_PTR(self_in); - *start = self->start; - *stop = self->stop; - *step = self->step; -} - -#endif diff --git a/user/mpy/py/objstr.c b/user/mpy/py/objstr.c deleted file mode 100644 index d4c038a..0000000 --- a/user/mpy/py/objstr.c +++ /dev/null @@ -1,2169 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/unicode.h" -#include "py/objstr.h" -#include "py/objlist.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/stackctrl.h" - -STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict); - -STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); -STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in); - -/******************************************************************************/ -/* str */ - -void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes) { - // this escapes characters, but it will be very slow to print (calling print many times) - bool has_single_quote = false; - bool has_double_quote = false; - for (const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) { - if (*s == '\'') { - has_single_quote = true; - } else if (*s == '"') { - has_double_quote = true; - } - } - int quote_char = '\''; - if (has_single_quote && !has_double_quote) { - quote_char = '"'; - } - mp_printf(print, "%c", quote_char); - for (const byte *s = str_data, *top = str_data + str_len; s < top; s++) { - if (*s == quote_char) { - mp_printf(print, "\\%c", quote_char); - } else if (*s == '\\') { - mp_print_str(print, "\\\\"); - } else if (*s >= 0x20 && *s != 0x7f && (!is_bytes || *s < 0x80)) { - // In strings, anything which is not ascii control character - // is printed as is, this includes characters in range 0x80-0xff - // (which can be non-Latin letters, etc.) - mp_printf(print, "%c", *s); - } else if (*s == '\n') { - mp_print_str(print, "\\n"); - } else if (*s == '\r') { - mp_print_str(print, "\\r"); - } else if (*s == '\t') { - mp_print_str(print, "\\t"); - } else { - mp_printf(print, "\\x%02x", *s); - } - } - mp_printf(print, "%c", quote_char); -} - -#if MICROPY_PY_UJSON -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len) { - // for JSON spec, see http://www.ietf.org/rfc/rfc4627.txt - // if we are given a valid utf8-encoded string, we will print it in a JSON-conforming way - mp_print_str(print, "\""); - for (const byte *s = str_data, *top = str_data + str_len; s < top; s++) { - if (*s == '"' || *s == '\\') { - mp_printf(print, "\\%c", *s); - } else if (*s >= 32) { - // this will handle normal and utf-8 encoded chars - mp_printf(print, "%c", *s); - } else if (*s == '\n') { - mp_print_str(print, "\\n"); - } else if (*s == '\r') { - mp_print_str(print, "\\r"); - } else if (*s == '\t') { - mp_print_str(print, "\\t"); - } else { - // this will handle control chars - mp_printf(print, "\\u%04x", *s); - } - } - mp_print_str(print, "\""); -} -#endif - -STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - GET_STR_DATA_LEN(self_in, str_data, str_len); - #if MICROPY_PY_UJSON - if (kind == PRINT_JSON) { - mp_str_print_json(print, str_data, str_len); - return; - } - #endif - #if !MICROPY_PY_BUILTINS_STR_UNICODE - bool is_bytes = MP_OBJ_IS_TYPE(self_in, &mp_type_bytes); - #else - bool is_bytes = true; - #endif - if (kind == PRINT_RAW || (!MICROPY_PY_BUILTINS_STR_UNICODE && kind == PRINT_STR && !is_bytes)) { - mp_printf(print, "%.*s", str_len, str_data); - } else { - if (is_bytes) { - mp_print_str(print, "b"); - } - mp_str_print_quoted(print, str_data, str_len, is_bytes); - } -} - -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { -#if MICROPY_CPYTHON_COMPAT - if (n_kw != 0) { - mp_arg_error_unimpl_kw(); - } -#endif - - mp_arg_check_num(n_args, n_kw, 0, 3, false); - - switch (n_args) { - case 0: - return MP_OBJ_NEW_QSTR(MP_QSTR_); - - case 1: { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - mp_obj_print_helper(&print, args[0], PRINT_STR); - return mp_obj_new_str_from_vstr(type, &vstr); - } - - default: // 2 or 3 args - // TODO: validate 2nd/3rd args - if (MP_OBJ_IS_TYPE(args[0], &mp_type_bytes)) { - GET_STR_DATA_LEN(args[0], str_data, str_len); - GET_STR_HASH(args[0], str_hash); - if (str_hash == 0) { - str_hash = qstr_compute_hash(str_data, str_len); - } - mp_obj_str_t *o = MP_OBJ_TO_PTR(mp_obj_new_str_of_type(type, NULL, str_len)); - o->data = str_data; - o->hash = str_hash; - return MP_OBJ_FROM_PTR(o); - } else { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); - return mp_obj_new_str(bufinfo.buf, bufinfo.len, false); - } - } -} - -STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - #if MICROPY_CPYTHON_COMPAT - if (n_kw != 0) { - mp_arg_error_unimpl_kw(); - } - #else - (void)n_kw; - #endif - - if (n_args == 0) { - return mp_const_empty_bytes; - } - - if (MP_OBJ_IS_STR(args[0])) { - if (n_args < 2 || n_args > 3) { - goto wrong_args; - } - GET_STR_DATA_LEN(args[0], str_data, str_len); - GET_STR_HASH(args[0], str_hash); - if (str_hash == 0) { - str_hash = qstr_compute_hash(str_data, str_len); - } - mp_obj_str_t *o = MP_OBJ_TO_PTR(mp_obj_new_str_of_type(&mp_type_bytes, NULL, str_len)); - o->data = str_data; - o->hash = str_hash; - return MP_OBJ_FROM_PTR(o); - } - - if (n_args > 1) { - goto wrong_args; - } - - if (MP_OBJ_IS_SMALL_INT(args[0])) { - uint len = MP_OBJ_SMALL_INT_VALUE(args[0]); - vstr_t vstr; - vstr_init_len(&vstr, len); - memset(vstr.buf, 0, len); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); - } - - // check if argument has the buffer protocol - mp_buffer_info_t bufinfo; - if (mp_get_buffer(args[0], &bufinfo, MP_BUFFER_READ)) { - return mp_obj_new_str_of_type(&mp_type_bytes, bufinfo.buf, bufinfo.len); - } - - vstr_t vstr; - // Try to create array of exact len if initializer len is known - mp_obj_t len_in = mp_obj_len_maybe(args[0]); - if (len_in == MP_OBJ_NULL) { - vstr_init(&vstr, 16); - } else { - mp_int_t len = MP_OBJ_SMALL_INT_VALUE(len_in); - vstr_init(&vstr, len); - } - - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(args[0], &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - mp_int_t val = mp_obj_get_int(item); - #if MICROPY_FULL_CHECKS - if (val < 0 || val > 255) { - mp_raise_ValueError("bytes value out of range"); - } - #endif - vstr_add_byte(&vstr, val); - } - - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); - -wrong_args: - mp_raise_TypeError("wrong number of arguments"); -} - -// like strstr but with specified length and allows \0 bytes -// TODO replace with something more efficient/standard -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction) { - if (hlen >= nlen) { - size_t str_index, str_index_end; - if (direction > 0) { - str_index = 0; - str_index_end = hlen - nlen; - } else { - str_index = hlen - nlen; - str_index_end = 0; - } - for (;;) { - if (memcmp(&haystack[str_index], needle, nlen) == 0) { - //found - return haystack + str_index; - } - if (str_index == str_index_end) { - //not found - break; - } - str_index += direction; - } - } - return NULL; -} - -// Note: this function is used to check if an object is a str or bytes, which -// works because both those types use it as their binary_op method. Revisit -// MP_OBJ_IS_STR_OR_BYTES if this fact changes. -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - // check for modulo - if (op == MP_BINARY_OP_MODULO) { - mp_obj_t *args = &rhs_in; - size_t n_args = 1; - mp_obj_t dict = MP_OBJ_NULL; - if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_tuple)) { - // TODO: Support tuple subclasses? - mp_obj_tuple_get(rhs_in, &n_args, &args); - } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_dict)) { - dict = rhs_in; - } - return str_modulo_format(lhs_in, n_args, args, dict); - } - - // from now on we need lhs type and data, so extract them - mp_obj_type_t *lhs_type = mp_obj_get_type(lhs_in); - GET_STR_DATA_LEN(lhs_in, lhs_data, lhs_len); - - // check for multiply - if (op == MP_BINARY_OP_MULTIPLY) { - mp_int_t n; - if (!mp_obj_get_int_maybe(rhs_in, &n)) { - return MP_OBJ_NULL; // op not supported - } - if (n <= 0) { - if (lhs_type == &mp_type_str) { - return MP_OBJ_NEW_QSTR(MP_QSTR_); // empty str - } else { - return mp_const_empty_bytes; - } - } - vstr_t vstr; - vstr_init_len(&vstr, lhs_len * n); - mp_seq_multiply(lhs_data, sizeof(*lhs_data), lhs_len, n, vstr.buf); - return mp_obj_new_str_from_vstr(lhs_type, &vstr); - } - - // From now on all operations allow: - // - str with str - // - bytes with bytes - // - bytes with bytearray - // - bytes with array.array - // To do this efficiently we use the buffer protocol to extract the raw - // data for the rhs, but only if the lhs is a bytes object. - // - // NOTE: CPython does not allow comparison between bytes ard array.array - // (even if the array is of type 'b'), even though it allows addition of - // such types. We are not compatible with this (we do allow comparison - // of bytes with anything that has the buffer protocol). It would be - // easy to "fix" this with a bit of extra logic below, but it costs code - // size and execution time so we don't. - - const byte *rhs_data; - size_t rhs_len; - if (lhs_type == mp_obj_get_type(rhs_in)) { - GET_STR_DATA_LEN(rhs_in, rhs_data_, rhs_len_); - rhs_data = rhs_data_; - rhs_len = rhs_len_; - } else if (lhs_type == &mp_type_bytes) { - mp_buffer_info_t bufinfo; - if (!mp_get_buffer(rhs_in, &bufinfo, MP_BUFFER_READ)) { - return MP_OBJ_NULL; // op not supported - } - rhs_data = bufinfo.buf; - rhs_len = bufinfo.len; - } else { - // LHS is str and RHS has an incompatible type - // (except if operation is EQUAL, but that's handled by mp_obj_equal) - bad_implicit_conversion(rhs_in); - } - - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: { - if (lhs_len == 0 && mp_obj_get_type(rhs_in) == lhs_type) { - return rhs_in; - } - if (rhs_len == 0) { - return lhs_in; - } - - vstr_t vstr; - vstr_init_len(&vstr, lhs_len + rhs_len); - memcpy(vstr.buf, lhs_data, lhs_len); - memcpy(vstr.buf + lhs_len, rhs_data, rhs_len); - return mp_obj_new_str_from_vstr(lhs_type, &vstr); - } - - case MP_BINARY_OP_IN: - /* NOTE `a in b` is `b.__contains__(a)` */ - return mp_obj_new_bool(find_subbytes(lhs_data, lhs_len, rhs_data, rhs_len, 1) != NULL); - - //case MP_BINARY_OP_NOT_EQUAL: // This is never passed here - case MP_BINARY_OP_EQUAL: // This will be passed only for bytes, str is dealt with in mp_obj_equal() - case MP_BINARY_OP_LESS: - case MP_BINARY_OP_LESS_EQUAL: - case MP_BINARY_OP_MORE: - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_data, lhs_len, rhs_data, rhs_len)); - } - - return MP_OBJ_NULL; // op not supported -} - -#if !MICROPY_PY_BUILTINS_STR_UNICODE -// objstrunicode defines own version -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, bool is_slice) { - size_t index_val = mp_get_index(type, self_len, index, is_slice); - return self_data + index_val; -} -#endif - -// This is used for both bytes and 8-bit strings. This is not used for unicode strings. -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - GET_STR_DATA_LEN(self_in, self_data, self_len); - if (value == MP_OBJ_SENTINEL) { - // load -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(self_len, index, &slice)) { - mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); - } - return mp_obj_new_str_of_type(type, self_data + slice.start, slice.stop - slice.start); - } -#endif - size_t index_val = mp_get_index(type, self_len, index, false); - // If we have unicode enabled the type will always be bytes, so take the short cut. - if (MICROPY_PY_BUILTINS_STR_UNICODE || type == &mp_type_bytes) { - return MP_OBJ_NEW_SMALL_INT(self_data[index_val]); - } else { - return mp_obj_new_str((char*)&self_data[index_val], 1, true); - } - } else { - return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(self_in)); - const mp_obj_type_t *self_type = mp_obj_get_type(self_in); - - // get separation string - GET_STR_DATA_LEN(self_in, sep_str, sep_len); - - // process args - size_t seq_len; - mp_obj_t *seq_items; - - if (!MP_OBJ_IS_TYPE(arg, &mp_type_list) && !MP_OBJ_IS_TYPE(arg, &mp_type_tuple)) { - // arg is not a list nor a tuple, try to convert it to a list - // TODO: Try to optimize? - arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); - } - mp_obj_get_array(arg, &seq_len, &seq_items); - - // count required length - size_t required_len = 0; - for (size_t i = 0; i < seq_len; i++) { - if (mp_obj_get_type(seq_items[i]) != self_type) { - mp_raise_TypeError( - "join expects a list of str/bytes objects consistent with self object"); - } - if (i > 0) { - required_len += sep_len; - } - GET_STR_LEN(seq_items[i], l); - required_len += l; - } - - // make joined string - vstr_t vstr; - vstr_init_len(&vstr, required_len); - byte *data = (byte*)vstr.buf; - for (size_t i = 0; i < seq_len; i++) { - if (i > 0) { - memcpy(data, sep_str, sep_len); - data += sep_len; - } - GET_STR_DATA_LEN(seq_items[i], s, l); - memcpy(data, s, l); - data += l; - } - - // return joined string - return mp_obj_new_str_from_vstr(self_type, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join); - -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - mp_int_t splits = -1; - mp_obj_t sep = mp_const_none; - if (n_args > 1) { - sep = args[1]; - if (n_args > 2) { - splits = mp_obj_get_int(args[2]); - } - } - - mp_obj_t res = mp_obj_new_list(0, NULL); - GET_STR_DATA_LEN(args[0], s, len); - const byte *top = s + len; - - if (sep == mp_const_none) { - // sep not given, so separate on whitespace - - // Initial whitespace is not counted as split, so we pre-do it - while (s < top && unichar_isspace(*s)) s++; - while (s < top && splits != 0) { - const byte *start = s; - while (s < top && !unichar_isspace(*s)) s++; - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); - if (s >= top) { - break; - } - while (s < top && unichar_isspace(*s)) s++; - if (splits > 0) { - splits--; - } - } - - if (s < top) { - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, s, top - s)); - } - - } else { - // sep given - if (mp_obj_get_type(sep) != self_type) { - bad_implicit_conversion(sep); - } - - size_t sep_len; - const char *sep_str = mp_obj_str_get_data(sep, &sep_len); - - if (sep_len == 0) { - mp_raise_ValueError("empty separator"); - } - - for (;;) { - const byte *start = s; - for (;;) { - if (splits == 0 || s + sep_len > top) { - s = top; - break; - } else if (memcmp(s, sep_str, sep_len) == 0) { - break; - } - s++; - } - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start)); - if (s >= top) { - break; - } - s += sep_len; - if (splits > 0) { - splits--; - } - } - } - - return res; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, mp_obj_str_split); - -#if MICROPY_PY_BUILTINS_STR_SPLITLINES -STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_keepends }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_keepends, MP_ARG_BOOL, {.u_bool = false} }, - }; - - // parse args - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - const mp_obj_type_t *self_type = mp_obj_get_type(pos_args[0]); - mp_obj_t res = mp_obj_new_list(0, NULL); - - GET_STR_DATA_LEN(pos_args[0], s, len); - const byte *top = s + len; - - while (s < top) { - const byte *start = s; - size_t match = 0; - while (s < top) { - if (*s == '\n') { - match = 1; - break; - } else if (*s == '\r') { - if (s[1] == '\n') { - match = 2; - } else { - match = 1; - } - break; - } - s++; - } - size_t sub_len = s - start; - if (args[ARG_keepends].u_bool) { - sub_len += match; - } - mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, sub_len)); - s += match; - } - - return res; -} -MP_DEFINE_CONST_FUN_OBJ_KW(str_splitlines_obj, 1, str_splitlines); -#endif - -STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) { - if (n_args < 3) { - // If we don't have split limit, it doesn't matter from which side - // we split. - return mp_obj_str_split(n_args, args); - } - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - mp_obj_t sep = args[1]; - GET_STR_DATA_LEN(args[0], s, len); - - mp_int_t splits = mp_obj_get_int(args[2]); - if (splits < 0) { - // Negative limit means no limit, so delegate to split(). - return mp_obj_str_split(n_args, args); - } - - mp_int_t org_splits = splits; - // Preallocate list to the max expected # of elements, as we - // will fill it from the end. - mp_obj_list_t *res = MP_OBJ_TO_PTR(mp_obj_new_list(splits + 1, NULL)); - mp_int_t idx = splits; - - if (sep == mp_const_none) { - mp_raise_NotImplementedError("rsplit(None,n)"); - } else { - size_t sep_len; - const char *sep_str = mp_obj_str_get_data(sep, &sep_len); - - if (sep_len == 0) { - mp_raise_ValueError("empty separator"); - } - - const byte *beg = s; - const byte *last = s + len; - for (;;) { - s = last - sep_len; - for (;;) { - if (splits == 0 || s < beg) { - break; - } else if (memcmp(s, sep_str, sep_len) == 0) { - break; - } - s--; - } - if (s < beg || splits == 0) { - res->items[idx] = mp_obj_new_str_of_type(self_type, beg, last - beg); - break; - } - res->items[idx--] = mp_obj_new_str_of_type(self_type, s + sep_len, last - s - sep_len); - last = s; - if (splits > 0) { - splits--; - } - } - if (idx != 0) { - // We split less parts than split limit, now go cleanup surplus - size_t used = org_splits + 1 - idx; - memmove(res->items, &res->items[idx], used * sizeof(mp_obj_t)); - mp_seq_clear(res->items, used, res->alloc, sizeof(*res->items)); - res->len = used; - } - } - - return MP_OBJ_FROM_PTR(res); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit); - -STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); - - // check argument type - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - - GET_STR_DATA_LEN(args[0], haystack, haystack_len); - GET_STR_DATA_LEN(args[1], needle, needle_len); - - const byte *start = haystack; - const byte *end = haystack + haystack_len; - if (n_args >= 3 && args[2] != mp_const_none) { - start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], true); - } - if (n_args >= 4 && args[3] != mp_const_none) { - end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], true); - } - - const byte *p = find_subbytes(start, end - start, needle, needle_len, direction); - if (p == NULL) { - // not found - if (is_index) { - mp_raise_ValueError("substring not found"); - } else { - return MP_OBJ_NEW_SMALL_INT(-1); - } - } else { - // found - #if MICROPY_PY_BUILTINS_STR_UNICODE - if (self_type == &mp_type_str) { - return MP_OBJ_NEW_SMALL_INT(utf8_ptr_to_index(haystack, p)); - } - #endif - return MP_OBJ_NEW_SMALL_INT(p - haystack); - } -} - -STATIC mp_obj_t str_find(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, 1, false); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find); - -STATIC mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, -1, false); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj, 2, 4, str_rfind); - -STATIC mp_obj_t str_index(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, 1, true); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj, 2, 4, str_index); - -STATIC mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) { - return str_finder(n_args, args, -1, true); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj, 2, 4, str_rindex); - -// TODO: (Much) more variety in args -STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - GET_STR_DATA_LEN(args[0], str, str_len); - GET_STR_DATA_LEN(args[1], prefix, prefix_len); - const byte *start = str; - if (n_args > 2) { - start = str_index_to_ptr(self_type, str, str_len, args[2], true); - } - if (prefix_len + (start - str) > str_len) { - return mp_const_false; - } - return mp_obj_new_bool(memcmp(start, prefix, prefix_len) == 0); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj, 2, 3, str_startswith); - -STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) { - GET_STR_DATA_LEN(args[0], str, str_len); - GET_STR_DATA_LEN(args[1], suffix, suffix_len); - if (n_args > 2) { - mp_raise_NotImplementedError("start/end indices"); - } - - if (suffix_len > str_len) { - return mp_const_false; - } - return mp_obj_new_bool(memcmp(str + (str_len - suffix_len), suffix, suffix_len) == 0); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith); - -enum { LSTRIP, RSTRIP, STRIP }; - -STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) { - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - - const byte *chars_to_del; - uint chars_to_del_len; - static const byte whitespace[] = " \t\n\r\v\f"; - - if (n_args == 1) { - chars_to_del = whitespace; - chars_to_del_len = sizeof(whitespace); - } else { - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - GET_STR_DATA_LEN(args[1], s, l); - chars_to_del = s; - chars_to_del_len = l; - } - - GET_STR_DATA_LEN(args[0], orig_str, orig_str_len); - - size_t first_good_char_pos = 0; - bool first_good_char_pos_set = false; - size_t last_good_char_pos = 0; - size_t i = 0; - int delta = 1; - if (type == RSTRIP) { - i = orig_str_len - 1; - delta = -1; - } - for (size_t len = orig_str_len; len > 0; len--) { - if (find_subbytes(chars_to_del, chars_to_del_len, &orig_str[i], 1, 1) == NULL) { - if (!first_good_char_pos_set) { - first_good_char_pos_set = true; - first_good_char_pos = i; - if (type == LSTRIP) { - last_good_char_pos = orig_str_len - 1; - break; - } else if (type == RSTRIP) { - first_good_char_pos = 0; - last_good_char_pos = i; - break; - } - } - last_good_char_pos = i; - } - i += delta; - } - - if (!first_good_char_pos_set) { - // string is all whitespace, return '' - if (self_type == &mp_type_str) { - return MP_OBJ_NEW_QSTR(MP_QSTR_); - } else { - return mp_const_empty_bytes; - } - } - - assert(last_good_char_pos >= first_good_char_pos); - //+1 to accommodate the last character - size_t stripped_len = last_good_char_pos - first_good_char_pos + 1; - if (stripped_len == orig_str_len) { - // If nothing was stripped, don't bother to dup original string - // TODO: watch out for this case when we'll get to bytearray.strip() - assert(first_good_char_pos == 0); - return args[0]; - } - return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len); -} - -STATIC mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) { - return str_uni_strip(STRIP, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip); - -STATIC mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) { - return str_uni_strip(LSTRIP, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj, 1, 2, str_lstrip); - -STATIC mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) { - return str_uni_strip(RSTRIP, n_args, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj, 1, 2, str_rstrip); - -#if MICROPY_PY_BUILTINS_STR_CENTER -STATIC mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) { - GET_STR_DATA_LEN(str_in, str, str_len); - mp_uint_t width = mp_obj_get_int(width_in); - if (str_len >= width) { - return str_in; - } - - vstr_t vstr; - vstr_init_len(&vstr, width); - memset(vstr.buf, ' ', width); - int left = (width - str_len) / 2; - memcpy(vstr.buf + left, str, str_len); - return mp_obj_new_str_from_vstr(mp_obj_get_type(str_in), &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_2(str_center_obj, str_center); -#endif - -// Takes an int arg, but only parses unsigned numbers, and only changes -// *num if at least one digit was parsed. -STATIC const char *str_to_int(const char *str, const char *top, int *num) { - if (str < top && '0' <= *str && *str <= '9') { - *num = 0; - do { - *num = *num * 10 + (*str - '0'); - str++; - } - while (str < top && '0' <= *str && *str <= '9'); - } - return str; -} - -STATIC bool isalignment(char ch) { - return ch && strchr("<>=^", ch) != NULL; -} - -STATIC bool istype(char ch) { - return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL; -} - -STATIC bool arg_looks_integer(mp_obj_t arg) { - return MP_OBJ_IS_TYPE(arg, &mp_type_bool) || MP_OBJ_IS_INT(arg); -} - -STATIC bool arg_looks_numeric(mp_obj_t arg) { - return arg_looks_integer(arg) -#if MICROPY_PY_BUILTINS_FLOAT - || mp_obj_is_float(arg) -#endif - ; -} - -STATIC mp_obj_t arg_as_int(mp_obj_t arg) { -#if MICROPY_PY_BUILTINS_FLOAT - if (mp_obj_is_float(arg)) { - return mp_obj_new_int_from_float(mp_obj_float_get(arg)); - } -#endif - return arg; -} - -#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE -STATIC NORETURN void terse_str_format_value_error(void) { - mp_raise_ValueError("bad format string"); -} -#else -// define to nothing to improve coverage -#define terse_str_format_value_error() -#endif - -STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - - for (; str < top; str++) { - if (*str == '}') { - str++; - if (str < top && *str == '}') { - vstr_add_byte(&vstr, '}'); - continue; - } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("single '}' encountered in format string"); - } - } - if (*str != '{') { - vstr_add_byte(&vstr, *str); - continue; - } - - str++; - if (str < top && *str == '{') { - vstr_add_byte(&vstr, '{'); - continue; - } - - // replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}" - - const char *field_name = NULL; - const char *field_name_top = NULL; - char conversion = '\0'; - const char *format_spec = NULL; - - if (str < top && *str != '}' && *str != '!' && *str != ':') { - field_name = (const char *)str; - while (str < top && *str != '}' && *str != '!' && *str != ':') { - ++str; - } - field_name_top = (const char *)str; - } - - // conversion ::= "r" | "s" - - if (str < top && *str == '!') { - str++; - if (str < top && (*str == 'r' || *str == 's')) { - conversion = *str++; - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { - mp_raise_ValueError("bad conversion specifier"); - } else { - if (str >= top) { - mp_raise_ValueError( - "end of format while looking for conversion specifier"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "unknown conversion specifier %c", *str)); - } - } - } - } - - if (str < top && *str == ':') { - str++; - // {:} is the same as {}, which is the same as {!s} - // This makes a difference when passing in a True or False - // '{}'.format(True) returns 'True' - // '{:d}'.format(True) returns '1' - // So we treat {:} as {} and this later gets treated to be {!s} - if (*str != '}') { - format_spec = str; - for (int nest = 1; str < top;) { - if (*str == '{') { - ++nest; - } else if (*str == '}') { - if (--nest == 0) { - break; - } - } - ++str; - } - } - } - if (str >= top) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("unmatched '{' in format"); - } - } - if (*str != '}') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("expected ':' after format specifier"); - } - } - - mp_obj_t arg = mp_const_none; - - if (field_name) { - int index = 0; - if (MP_LIKELY(unichar_isdigit(*field_name))) { - if (*arg_i > 0) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "can't switch from automatic field numbering to manual field specification"); - } - } - field_name = str_to_int(field_name, field_name_top, &index); - if ((uint)index >= n_args - 1) { - mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); - } - arg = args[index + 1]; - *arg_i = -1; - } else { - const char *lookup; - for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++); - mp_obj_t field_q = mp_obj_new_str(field_name, lookup - field_name, true/*?*/); - field_name = lookup; - mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP); - if (key_elem == NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, field_q)); - } - arg = key_elem->value; - } - if (field_name < field_name_top) { - mp_raise_NotImplementedError("attributes not supported yet"); - } - } else { - if (*arg_i < 0) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "can't switch from manual field specification to automatic field numbering"); - } - } - if ((uint)*arg_i >= n_args - 1) { - mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); - } - arg = args[(*arg_i) + 1]; - (*arg_i)++; - } - if (!format_spec && !conversion) { - conversion = 's'; - } - if (conversion) { - mp_print_kind_t print_kind; - if (conversion == 's') { - print_kind = PRINT_STR; - } else { - assert(conversion == 'r'); - print_kind = PRINT_REPR; - } - vstr_t arg_vstr; - mp_print_t arg_print; - vstr_init_print(&arg_vstr, 16, &arg_print); - mp_obj_print_helper(&arg_print, arg, print_kind); - arg = mp_obj_new_str_from_vstr(&mp_type_str, &arg_vstr); - } - - char fill = '\0'; - char align = '\0'; - int width = -1; - int precision = -1; - char type = '\0'; - int flags = 0; - - if (format_spec) { - // The format specifier (from http://docs.python.org/2/library/string.html#formatspec) - // - // [[fill]align][sign][#][0][width][,][.precision][type] - // fill ::= - // align ::= "<" | ">" | "=" | "^" - // sign ::= "+" | "-" | " " - // width ::= integer - // precision ::= integer - // type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" - - // recursively call the formatter to format any nested specifiers - MP_STACK_CHECK(); - vstr_t format_spec_vstr = mp_obj_str_format_helper(format_spec, str, arg_i, n_args, args, kwargs); - const char *s = vstr_null_terminated_str(&format_spec_vstr); - const char *stop = s + format_spec_vstr.len; - if (isalignment(*s)) { - align = *s++; - } else if (*s && isalignment(s[1])) { - fill = *s++; - align = *s++; - } - if (*s == '+' || *s == '-' || *s == ' ') { - if (*s == '+') { - flags |= PF_FLAG_SHOW_SIGN; - } else if (*s == ' ') { - flags |= PF_FLAG_SPACE_SIGN; - } - s++; - } - if (*s == '#') { - flags |= PF_FLAG_SHOW_PREFIX; - s++; - } - if (*s == '0') { - if (!align) { - align = '='; - } - if (!fill) { - fill = '0'; - } - } - s = str_to_int(s, stop, &width); - if (*s == ',') { - flags |= PF_FLAG_SHOW_COMMA; - s++; - } - if (*s == '.') { - s++; - s = str_to_int(s, stop, &precision); - } - if (istype(*s)) { - type = *s++; - } - if (*s) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("invalid format specifier"); - } - } - vstr_clear(&format_spec_vstr); - } - if (!align) { - if (arg_looks_numeric(arg)) { - align = '>'; - } else { - align = '<'; - } - } - if (!fill) { - fill = ' '; - } - - if (flags & (PF_FLAG_SHOW_SIGN | PF_FLAG_SPACE_SIGN)) { - if (type == 's') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("sign not allowed in string format specifier"); - } - } - if (type == 'c') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "sign not allowed with integer format specifier 'c'"); - } - } - } - - switch (align) { - case '<': flags |= PF_FLAG_LEFT_ADJUST; break; - case '=': flags |= PF_FLAG_PAD_AFTER_SIGN; break; - case '^': flags |= PF_FLAG_CENTER_ADJUST; break; - } - - if (arg_looks_integer(arg)) { - switch (type) { - case 'b': - mp_print_mp_int(&print, arg, 2, 'a', flags, fill, width, 0); - continue; - - case 'c': - { - char ch = mp_obj_get_int(arg); - mp_print_strn(&print, &ch, 1, flags, fill, width); - continue; - } - - case '\0': // No explicit format type implies 'd' - case 'n': // I don't think we support locales in uPy so use 'd' - case 'd': - mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0); - continue; - - case 'o': - if (flags & PF_FLAG_SHOW_PREFIX) { - flags |= PF_FLAG_SHOW_OCTAL_LETTER; - } - - mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, 0); - continue; - - case 'X': - case 'x': - mp_print_mp_int(&print, arg, 16, type - ('X' - 'A'), flags, fill, width, 0); - continue; - - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - case '%': - // The floating point formatters all work with anything that - // looks like an integer - break; - - default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "unknown format code '%c' for object of type '%s'", - type, mp_obj_get_type_str(arg))); - } - } - } - - // NOTE: no else here. We need the e, f, g etc formats for integer - // arguments (from above if) to take this if. - if (arg_looks_numeric(arg)) { - if (!type) { - - // Even though the docs say that an unspecified type is the same - // as 'g', there is one subtle difference, when the exponent - // is one less than the precision. - // - // '{:10.1}'.format(0.0) ==> '0e+00' - // '{:10.1g}'.format(0.0) ==> '0' - // - // TODO: Figure out how to deal with this. - // - // A proper solution would involve adding a special flag - // or something to format_float, and create a format_double - // to deal with doubles. In order to fix this when using - // sprintf, we'd need to use the e format and tweak the - // returned result to strip trailing zeros like the g format - // does. - // - // {:10.3} and {:10.2e} with 1.23e2 both produce 1.23e+02 - // but with 1.e2 you get 1e+02 and 1.00e+02 - // - // Stripping the trailing 0's (like g) does would make the - // e format give us the right format. - // - // CPython sources say: - // Omitted type specifier. Behaves in the same way as repr(x) - // and str(x) if no precision is given, else like 'g', but with - // at least one digit after the decimal point. */ - - type = 'g'; - } - if (type == 'n') { - type = 'g'; - } - - switch (type) { -#if MICROPY_PY_BUILTINS_FLOAT - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - mp_print_float(&print, mp_obj_get_float(arg), type, flags, fill, width, precision); - break; - - case '%': - flags |= PF_FLAG_ADD_PERCENT; - #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - #define F100 100.0F - #else - #define F100 100.0 - #endif - mp_print_float(&print, mp_obj_get_float(arg) * F100, 'f', flags, fill, width, precision); - #undef F100 - break; -#endif - - default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "unknown format code '%c' for object of type 'float'", - type, mp_obj_get_type_str(arg))); - } - } - } else { - // arg doesn't look like a number - - if (align == '=') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError( - "'=' alignment not allowed in string format specifier"); - } - } - - switch (type) { - case '\0': // no explicit format type implies 's' - case 's': { - size_t slen; - const char *s = mp_obj_str_get_data(arg, &slen); - if (precision < 0) { - precision = slen; - } - if (slen > (size_t)precision) { - slen = precision; - } - mp_print_strn(&print, s, slen, flags, fill, width); - break; - } - - default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "unknown format code '%c' for object of type 'str'", - type, mp_obj_get_type_str(arg))); - } - } - } - } - - return vstr; -} - -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); - - GET_STR_DATA_LEN(args[0], str, len); - int arg_i = 0; - vstr_t vstr = mp_obj_str_format_helper((const char*)str, (const char*)str + len, &arg_i, n_args, args, kwargs); - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format); - -STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) { - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(pattern)); - - GET_STR_DATA_LEN(pattern, str, len); - const byte *start_str = str; - bool is_bytes = MP_OBJ_IS_TYPE(pattern, &mp_type_bytes); - size_t arg_i = 0; - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 16, &print); - - for (const byte *top = str + len; str < top; str++) { - mp_obj_t arg = MP_OBJ_NULL; - if (*str != '%') { - vstr_add_byte(&vstr, *str); - continue; - } - if (++str >= top) { - goto incomplete_format; - } - if (*str == '%') { - vstr_add_byte(&vstr, '%'); - continue; - } - - // Dictionary value lookup - if (*str == '(') { - if (dict == MP_OBJ_NULL) { - mp_raise_TypeError("format requires a dict"); - } - arg_i = 1; // we used up the single dict argument - const byte *key = ++str; - while (*str != ')') { - if (str >= top) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("incomplete format key"); - } - } - ++str; - } - mp_obj_t k_obj = mp_obj_new_str((const char*)key, str - key, true); - arg = mp_obj_dict_get(dict, k_obj); - str++; - } - - int flags = 0; - char fill = ' '; - int alt = 0; - while (str < top) { - if (*str == '-') flags |= PF_FLAG_LEFT_ADJUST; - else if (*str == '+') flags |= PF_FLAG_SHOW_SIGN; - else if (*str == ' ') flags |= PF_FLAG_SPACE_SIGN; - else if (*str == '#') alt = PF_FLAG_SHOW_PREFIX; - else if (*str == '0') { - flags |= PF_FLAG_PAD_AFTER_SIGN; - fill = '0'; - } else break; - str++; - } - // parse width, if it exists - int width = 0; - if (str < top) { - if (*str == '*') { - if (arg_i >= n_args) { - goto not_enough_args; - } - width = mp_obj_get_int(args[arg_i++]); - str++; - } else { - str = (const byte*)str_to_int((const char*)str, (const char*)top, &width); - } - } - int prec = -1; - if (str < top && *str == '.') { - if (++str < top) { - if (*str == '*') { - if (arg_i >= n_args) { - goto not_enough_args; - } - prec = mp_obj_get_int(args[arg_i++]); - str++; - } else { - prec = 0; - str = (const byte*)str_to_int((const char*)str, (const char*)top, &prec); - } - } - } - - if (str >= top) { -incomplete_format: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - mp_raise_ValueError("incomplete format"); - } - } - - // Tuple value lookup - if (arg == MP_OBJ_NULL) { - if (arg_i >= n_args) { -not_enough_args: - mp_raise_TypeError("not enough arguments for format string"); - } - arg = args[arg_i++]; - } - switch (*str) { - case 'c': - if (MP_OBJ_IS_STR(arg)) { - size_t slen; - const char *s = mp_obj_str_get_data(arg, &slen); - if (slen != 1) { - mp_raise_TypeError("%%c requires int or char"); - } - mp_print_strn(&print, s, 1, flags, ' ', width); - } else if (arg_looks_integer(arg)) { - char ch = mp_obj_get_int(arg); - mp_print_strn(&print, &ch, 1, flags, ' ', width); - } else { - mp_raise_TypeError("integer required"); - } - break; - - case 'd': - case 'i': - case 'u': - mp_print_mp_int(&print, arg_as_int(arg), 10, 'a', flags, fill, width, prec); - break; - -#if MICROPY_PY_BUILTINS_FLOAT - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - mp_print_float(&print, mp_obj_get_float(arg), *str, flags, fill, width, prec); - break; -#endif - - case 'o': - if (alt) { - flags |= (PF_FLAG_SHOW_PREFIX | PF_FLAG_SHOW_OCTAL_LETTER); - } - mp_print_mp_int(&print, arg, 8, 'a', flags, fill, width, prec); - break; - - case 'r': - case 's': - { - vstr_t arg_vstr; - mp_print_t arg_print; - vstr_init_print(&arg_vstr, 16, &arg_print); - mp_print_kind_t print_kind = (*str == 'r' ? PRINT_REPR : PRINT_STR); - if (print_kind == PRINT_STR && is_bytes && MP_OBJ_IS_TYPE(arg, &mp_type_bytes)) { - // If we have something like b"%s" % b"1", bytes arg should be - // printed undecorated. - print_kind = PRINT_RAW; - } - mp_obj_print_helper(&arg_print, arg, print_kind); - uint vlen = arg_vstr.len; - if (prec < 0) { - prec = vlen; - } - if (vlen > (uint)prec) { - vlen = prec; - } - mp_print_strn(&print, arg_vstr.buf, vlen, flags, ' ', width); - vstr_clear(&arg_vstr); - break; - } - - case 'X': - case 'x': - mp_print_mp_int(&print, arg, 16, *str - ('X' - 'A'), flags | alt, fill, width, prec); - break; - - default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "unsupported format character '%c' (0x%x) at index %d", - *str, *str, str - start_str)); - } - } - } - - if (arg_i != n_args) { - mp_raise_TypeError("not all arguments converted during string formatting"); - } - - return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr); -} - -// The implementation is optimized, returning the original string if there's -// nothing to replace. -STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) { - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); - - mp_int_t max_rep = -1; - if (n_args == 4) { - max_rep = mp_obj_get_int(args[3]); - if (max_rep == 0) { - return args[0]; - } else if (max_rep < 0) { - max_rep = -1; - } - } - - // if max_rep is still -1 by this point we will need to do all possible replacements - - // check argument types - - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - - if (mp_obj_get_type(args[2]) != self_type) { - bad_implicit_conversion(args[2]); - } - - // extract string data - - GET_STR_DATA_LEN(args[0], str, str_len); - GET_STR_DATA_LEN(args[1], old, old_len); - GET_STR_DATA_LEN(args[2], new, new_len); - - // old won't exist in str if it's longer, so nothing to replace - if (old_len > str_len) { - return args[0]; - } - - // data for the replaced string - byte *data = NULL; - vstr_t vstr; - - // do 2 passes over the string: - // first pass computes the required length of the replaced string - // second pass does the replacements - for (;;) { - size_t replaced_str_index = 0; - size_t num_replacements_done = 0; - const byte *old_occurrence; - const byte *offset_ptr = str; - size_t str_len_remain = str_len; - if (old_len == 0) { - // if old_str is empty, copy new_str to start of replaced string - // copy the replacement string - if (data != NULL) { - memcpy(data, new, new_len); - } - replaced_str_index += new_len; - num_replacements_done++; - } - while (num_replacements_done != (size_t)max_rep && str_len_remain > 0 && (old_occurrence = find_subbytes(offset_ptr, str_len_remain, old, old_len, 1)) != NULL) { - if (old_len == 0) { - old_occurrence += 1; - } - // copy from just after end of last occurrence of to-be-replaced string to right before start of next occurrence - if (data != NULL) { - memcpy(data + replaced_str_index, offset_ptr, old_occurrence - offset_ptr); - } - replaced_str_index += old_occurrence - offset_ptr; - // copy the replacement string - if (data != NULL) { - memcpy(data + replaced_str_index, new, new_len); - } - replaced_str_index += new_len; - offset_ptr = old_occurrence + old_len; - str_len_remain = str + str_len - offset_ptr; - num_replacements_done++; - } - - // copy from just after end of last occurrence of to-be-replaced string to end of old string - if (data != NULL) { - memcpy(data + replaced_str_index, offset_ptr, str_len_remain); - } - replaced_str_index += str_len_remain; - - if (data == NULL) { - // first pass - if (num_replacements_done == 0) { - // no substr found, return original string - return args[0]; - } else { - // substr found, allocate new string - vstr_init_len(&vstr, replaced_str_index); - data = (byte*)vstr.buf; - assert(data != NULL); - } - } else { - // second pass, we are done - break; - } - } - - return mp_obj_new_str_from_vstr(self_type, &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace); - -STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) { - const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(args[0])); - - // check argument type - if (mp_obj_get_type(args[1]) != self_type) { - bad_implicit_conversion(args[1]); - } - - GET_STR_DATA_LEN(args[0], haystack, haystack_len); - GET_STR_DATA_LEN(args[1], needle, needle_len); - - const byte *start = haystack; - const byte *end = haystack + haystack_len; - if (n_args >= 3 && args[2] != mp_const_none) { - start = str_index_to_ptr(self_type, haystack, haystack_len, args[2], true); - } - if (n_args >= 4 && args[3] != mp_const_none) { - end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], true); - } - - // if needle_len is zero then we count each gap between characters as an occurrence - if (needle_len == 0) { - return MP_OBJ_NEW_SMALL_INT(unichar_charlen((const char*)start, end - start) + 1); - } - - // count the occurrences - mp_int_t num_occurrences = 0; - for (const byte *haystack_ptr = start; haystack_ptr + needle_len <= end;) { - if (memcmp(haystack_ptr, needle, needle_len) == 0) { - num_occurrences++; - haystack_ptr += needle_len; - } else { - haystack_ptr = utf8_next_char(haystack_ptr); - } - } - - return MP_OBJ_NEW_SMALL_INT(num_occurrences); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count); - -#if MICROPY_PY_BUILTINS_STR_PARTITION -STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) { - mp_check_self(MP_OBJ_IS_STR_OR_BYTES(self_in)); - mp_obj_type_t *self_type = mp_obj_get_type(self_in); - if (self_type != mp_obj_get_type(arg)) { - bad_implicit_conversion(arg); - } - - GET_STR_DATA_LEN(self_in, str, str_len); - GET_STR_DATA_LEN(arg, sep, sep_len); - - if (sep_len == 0) { - mp_raise_ValueError("empty separator"); - } - - mp_obj_t result[3]; - if (self_type == &mp_type_str) { - result[0] = MP_OBJ_NEW_QSTR(MP_QSTR_); - result[1] = MP_OBJ_NEW_QSTR(MP_QSTR_); - result[2] = MP_OBJ_NEW_QSTR(MP_QSTR_); - } else { - result[0] = mp_const_empty_bytes; - result[1] = mp_const_empty_bytes; - result[2] = mp_const_empty_bytes; - } - - if (direction > 0) { - result[0] = self_in; - } else { - result[2] = self_in; - } - - const byte *position_ptr = find_subbytes(str, str_len, sep, sep_len, direction); - if (position_ptr != NULL) { - size_t position = position_ptr - str; - result[0] = mp_obj_new_str_of_type(self_type, str, position); - result[1] = arg; - result[2] = mp_obj_new_str_of_type(self_type, str + position + sep_len, str_len - position - sep_len); - } - - return mp_obj_new_tuple(3, result); -} - -STATIC mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) { - return str_partitioner(self_in, arg, 1); -} -MP_DEFINE_CONST_FUN_OBJ_2(str_partition_obj, str_partition); - -STATIC mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) { - return str_partitioner(self_in, arg, -1); -} -MP_DEFINE_CONST_FUN_OBJ_2(str_rpartition_obj, str_rpartition); -#endif - -// Supposedly not too critical operations, so optimize for code size -STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) { - GET_STR_DATA_LEN(self_in, self_data, self_len); - vstr_t vstr; - vstr_init_len(&vstr, self_len); - byte *data = (byte*)vstr.buf; - for (size_t i = 0; i < self_len; i++) { - *data++ = op(*self_data++); - } - return mp_obj_new_str_from_vstr(mp_obj_get_type(self_in), &vstr); -} - -STATIC mp_obj_t str_lower(mp_obj_t self_in) { - return str_caseconv(unichar_tolower, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_lower_obj, str_lower); - -STATIC mp_obj_t str_upper(mp_obj_t self_in) { - return str_caseconv(unichar_toupper, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_upper_obj, str_upper); - -STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) { - GET_STR_DATA_LEN(self_in, self_data, self_len); - - if (self_len == 0) { - return mp_const_false; // default to False for empty str - } - - if (f != unichar_isupper && f != unichar_islower) { - for (size_t i = 0; i < self_len; i++) { - if (!f(*self_data++)) { - return mp_const_false; - } - } - } else { - bool contains_alpha = false; - - for (size_t i = 0; i < self_len; i++) { // only check alphanumeric characters - if (unichar_isalpha(*self_data++)) { - contains_alpha = true; - if (!f(*(self_data - 1))) { // -1 because we already incremented above - return mp_const_false; - } - } - } - - if (!contains_alpha) { - return mp_const_false; - } - } - - return mp_const_true; -} - -STATIC mp_obj_t str_isspace(mp_obj_t self_in) { - return str_uni_istype(unichar_isspace, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_isspace_obj, str_isspace); - -STATIC mp_obj_t str_isalpha(mp_obj_t self_in) { - return str_uni_istype(unichar_isalpha, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_isalpha_obj, str_isalpha); - -STATIC mp_obj_t str_isdigit(mp_obj_t self_in) { - return str_uni_istype(unichar_isdigit, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_isdigit_obj, str_isdigit); - -STATIC mp_obj_t str_isupper(mp_obj_t self_in) { - return str_uni_istype(unichar_isupper, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_isupper_obj, str_isupper); - -STATIC mp_obj_t str_islower(mp_obj_t self_in) { - return str_uni_istype(unichar_islower, self_in); -} -MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower); - -#if MICROPY_CPYTHON_COMPAT -// These methods are superfluous in the presence of str() and bytes() -// constructors. -// TODO: should accept kwargs too -STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) { - mp_obj_t new_args[2]; - if (n_args == 1) { - new_args[0] = args[0]; - new_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_utf_hyphen_8); - args = new_args; - n_args++; - } - return mp_obj_str_make_new(&mp_type_str, n_args, 0, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode); - -// TODO: should accept kwargs too -STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) { - mp_obj_t new_args[2]; - if (n_args == 1) { - new_args[0] = args[0]; - new_args[1] = MP_OBJ_NEW_QSTR(MP_QSTR_utf_hyphen_8); - args = new_args; - n_args++; - } - return bytes_make_new(NULL, n_args, 0, args); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj, 1, 3, str_encode); -#endif - -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - if (flags == MP_BUFFER_READ) { - GET_STR_DATA_LEN(self_in, str_data, str_len); - bufinfo->buf = (void*)str_data; - bufinfo->len = str_len; - bufinfo->typecode = 'B'; // bytes should be unsigned, so should unicode byte-access - return 0; - } else { - // can't write to a string - bufinfo->buf = NULL; - bufinfo->len = 0; - bufinfo->typecode = -1; - return 1; - } -} - -STATIC const mp_rom_map_elem_t str8_locals_dict_table[] = { -#if MICROPY_CPYTHON_COMPAT - { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&bytes_decode_obj) }, - #if !MICROPY_PY_BUILTINS_STR_UNICODE - // If we have separate unicode type, then here we have methods only - // for bytes type, and it should not have encode() methods. Otherwise, - // we have non-compliant-but-practical bytestring type, which shares - // method table with bytes, so they both have encode() and decode() - // methods (which should do type checking at runtime). - { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&str_encode_obj) }, - #endif -#endif - { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&str_find_obj) }, - { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&str_rfind_obj) }, - { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&str_index_obj) }, - { MP_ROM_QSTR(MP_QSTR_rindex), MP_ROM_PTR(&str_rindex_obj) }, - { MP_ROM_QSTR(MP_QSTR_join), MP_ROM_PTR(&str_join_obj) }, - { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&str_split_obj) }, - #if MICROPY_PY_BUILTINS_STR_SPLITLINES - { MP_ROM_QSTR(MP_QSTR_splitlines), MP_ROM_PTR(&str_splitlines_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_rsplit), MP_ROM_PTR(&str_rsplit_obj) }, - { MP_ROM_QSTR(MP_QSTR_startswith), MP_ROM_PTR(&str_startswith_obj) }, - { MP_ROM_QSTR(MP_QSTR_endswith), MP_ROM_PTR(&str_endswith_obj) }, - { MP_ROM_QSTR(MP_QSTR_strip), MP_ROM_PTR(&str_strip_obj) }, - { MP_ROM_QSTR(MP_QSTR_lstrip), MP_ROM_PTR(&str_lstrip_obj) }, - { MP_ROM_QSTR(MP_QSTR_rstrip), MP_ROM_PTR(&str_rstrip_obj) }, - { MP_ROM_QSTR(MP_QSTR_format), MP_ROM_PTR(&str_format_obj) }, - { MP_ROM_QSTR(MP_QSTR_replace), MP_ROM_PTR(&str_replace_obj) }, - { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&str_count_obj) }, - #if MICROPY_PY_BUILTINS_STR_PARTITION - { MP_ROM_QSTR(MP_QSTR_partition), MP_ROM_PTR(&str_partition_obj) }, - { MP_ROM_QSTR(MP_QSTR_rpartition), MP_ROM_PTR(&str_rpartition_obj) }, - #endif - #if MICROPY_PY_BUILTINS_STR_CENTER - { MP_ROM_QSTR(MP_QSTR_center), MP_ROM_PTR(&str_center_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_lower), MP_ROM_PTR(&str_lower_obj) }, - { MP_ROM_QSTR(MP_QSTR_upper), MP_ROM_PTR(&str_upper_obj) }, - { MP_ROM_QSTR(MP_QSTR_isspace), MP_ROM_PTR(&str_isspace_obj) }, - { MP_ROM_QSTR(MP_QSTR_isalpha), MP_ROM_PTR(&str_isalpha_obj) }, - { MP_ROM_QSTR(MP_QSTR_isdigit), MP_ROM_PTR(&str_isdigit_obj) }, - { MP_ROM_QSTR(MP_QSTR_isupper), MP_ROM_PTR(&str_isupper_obj) }, - { MP_ROM_QSTR(MP_QSTR_islower), MP_ROM_PTR(&str_islower_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(str8_locals_dict, str8_locals_dict_table); - -#if !MICROPY_PY_BUILTINS_STR_UNICODE -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); - -const mp_obj_type_t mp_type_str = { - { &mp_type_type }, - .name = MP_QSTR_str, - .print = str_print, - .make_new = mp_obj_str_make_new, - .binary_op = mp_obj_str_binary_op, - .subscr = bytes_subscr, - .getiter = mp_obj_new_str_iterator, - .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, -}; -#endif - -// Reuses most of methods from str -const mp_obj_type_t mp_type_bytes = { - { &mp_type_type }, - .name = MP_QSTR_bytes, - .print = str_print, - .make_new = bytes_make_new, - .binary_op = mp_obj_str_binary_op, - .subscr = bytes_subscr, - .getiter = mp_obj_new_bytes_iterator, - .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&str8_locals_dict, -}; - -// the zero-length bytes -const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, NULL}; - -// Create a str/bytes object using the given data. New memory is allocated and -// the data is copied across. -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len) { - mp_obj_str_t *o = m_new_obj(mp_obj_str_t); - o->base.type = type; - o->len = len; - if (data) { - o->hash = qstr_compute_hash(data, len); - byte *p = m_new(byte, len + 1); - o->data = p; - memcpy(p, data, len * sizeof(byte)); - p[len] = '\0'; // for now we add null for compatibility with C ASCIIZ strings - } - return MP_OBJ_FROM_PTR(o); -} - -// Create a str/bytes object from the given vstr. The vstr buffer is resized to -// the exact length required and then reused for the str/bytes object. The vstr -// is cleared and can safely be passed to vstr_free if it was heap allocated. -mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) { - // if not a bytes object, look if a qstr with this data already exists - if (type == &mp_type_str) { - qstr q = qstr_find_strn(vstr->buf, vstr->len); - if (q != MP_QSTR_NULL) { - vstr_clear(vstr); - vstr->alloc = 0; - return MP_OBJ_NEW_QSTR(q); - } - } - - // make a new str/bytes object - mp_obj_str_t *o = m_new_obj(mp_obj_str_t); - o->base.type = type; - o->len = vstr->len; - o->hash = qstr_compute_hash((byte*)vstr->buf, vstr->len); - if (vstr->len + 1 == vstr->alloc) { - o->data = (byte*)vstr->buf; - } else { - o->data = (byte*)m_renew(char, vstr->buf, vstr->alloc, vstr->len + 1); - } - ((byte*)o->data)[o->len] = '\0'; // add null byte - vstr->buf = NULL; - vstr->alloc = 0; - return MP_OBJ_FROM_PTR(o); -} - -mp_obj_t mp_obj_new_str(const char* data, size_t len, bool make_qstr_if_not_already) { - if (make_qstr_if_not_already) { - // use existing, or make a new qstr - return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len)); - } else { - qstr q = qstr_find_strn(data, len); - if (q != MP_QSTR_NULL) { - // qstr with this data already exists - return MP_OBJ_NEW_QSTR(q); - } else { - // no existing qstr, don't make one - return mp_obj_new_str_of_type(&mp_type_str, (const byte*)data, len); - } - } -} - -mp_obj_t mp_obj_str_intern(mp_obj_t str) { - GET_STR_DATA_LEN(str, data, len); - return MP_OBJ_NEW_QSTR(qstr_from_strn((const char*)data, len)); -} - -mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) { - return mp_obj_new_str_of_type(&mp_type_bytes, data, len); -} - -bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { - if (MP_OBJ_IS_QSTR(s1) && MP_OBJ_IS_QSTR(s2)) { - return s1 == s2; - } else { - GET_STR_HASH(s1, h1); - GET_STR_HASH(s2, h2); - // If any of hashes is 0, it means it's not valid - if (h1 != 0 && h2 != 0 && h1 != h2) { - return false; - } - GET_STR_DATA_LEN(s1, d1, l1); - GET_STR_DATA_LEN(s2, d2, l2); - if (l1 != l2) { - return false; - } - return memcmp(d1, d2, l1) == 0; - } -} - -STATIC void bad_implicit_conversion(mp_obj_t self_in) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("can't convert to str implicitly"); - } else { - const qstr src_name = mp_obj_get_type(self_in)->name; - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "can't convert '%q' object to %q implicitly", - src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str)); - } -} - -// use this if you will anyway convert the string to a qstr -// will be more efficient for the case where it's already a qstr -qstr mp_obj_str_get_qstr(mp_obj_t self_in) { - if (MP_OBJ_IS_QSTR(self_in)) { - return MP_OBJ_QSTR_VALUE(self_in); - } else if (MP_OBJ_IS_TYPE(self_in, &mp_type_str)) { - mp_obj_str_t *self = MP_OBJ_TO_PTR(self_in); - return qstr_from_strn((char*)self->data, self->len); - } else { - bad_implicit_conversion(self_in); - } -} - -// only use this function if you need the str data to be zero terminated -// at the moment all strings are zero terminated to help with C ASCIIZ compatibility -const char *mp_obj_str_get_str(mp_obj_t self_in) { - if (MP_OBJ_IS_STR_OR_BYTES(self_in)) { - GET_STR_DATA_LEN(self_in, s, l); - (void)l; // len unused - return (const char*)s; - } else { - bad_implicit_conversion(self_in); - } -} - -const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len) { - if (MP_OBJ_IS_STR_OR_BYTES(self_in)) { - GET_STR_DATA_LEN(self_in, s, l); - *len = l; - return (const char*)s; - } else { - bad_implicit_conversion(self_in); - } -} - -#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C -const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len) { - if (MP_OBJ_IS_QSTR(self_in)) { - return qstr_data(MP_OBJ_QSTR_VALUE(self_in), len); - } else { - *len = ((mp_obj_str_t*)self_in)->len; - return ((mp_obj_str_t*)self_in)->data; - } -} -#endif - -/******************************************************************************/ -/* str iterator */ - -typedef struct _mp_obj_str8_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t str; - size_t cur; -} mp_obj_str8_it_t; - -#if !MICROPY_PY_BUILTINS_STR_UNICODE -STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { - mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in); - GET_STR_DATA_LEN(self->str, str, len); - if (self->cur < len) { - mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, true); - self->cur += 1; - return o_out; - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = str_it_iternext; - o->str = str; - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} -#endif - -STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) { - mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in); - GET_STR_DATA_LEN(self->str, str, len); - if (self->cur < len) { - mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(str[self->cur]); - self->cur += 1; - return o_out; - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = bytes_it_iternext; - o->str = str; - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objstr.h b/user/mpy/py/objstr.h deleted file mode 100644 index 3aef8c6..0000000 --- a/user/mpy/py/objstr.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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_OBJSTR_H -#define MICROPY_INCLUDED_PY_OBJSTR_H - -#include "py/obj.h" - -typedef struct _mp_obj_str_t { - mp_obj_base_t base; - mp_uint_t hash; - // len == number of bytes used in data, alloc = len + 1 because (at the moment) we also append a null byte - size_t len; - const byte *data; -} mp_obj_str_t; - -#define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str} - -// use this macro to extract the string hash -// warning: the hash can be 0, meaning invalid, and must then be explicitly computed from the data -#define GET_STR_HASH(str_obj_in, str_hash) \ - mp_uint_t str_hash; if (MP_OBJ_IS_QSTR(str_obj_in)) \ - { str_hash = qstr_hash(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_hash = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->hash; } - -// use this macro to extract the string length -#define GET_STR_LEN(str_obj_in, str_len) \ - size_t str_len; if (MP_OBJ_IS_QSTR(str_obj_in)) \ - { str_len = qstr_len(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; } - -// use this macro to extract the string data and length -#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C -const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len); -#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) \ - size_t str_len; const byte *str_data = mp_obj_str_get_data_no_check(str_obj_in, &str_len); -#else -#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) \ - const byte *str_data; size_t str_len; if (MP_OBJ_IS_QSTR(str_obj_in)) \ - { str_data = qstr_data(MP_OBJ_QSTR_VALUE(str_obj_in), &str_len); } \ - else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; str_data = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->data; } -#endif - -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); -void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); -mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); -mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); -mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len); - -mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); -mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); - -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, bool is_slice); -const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj); -MP_DECLARE_CONST_FUN_OBJ_2(str_join_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(str_splitlines_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(str_format_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj); -MP_DECLARE_CONST_FUN_OBJ_2(str_partition_obj); -MP_DECLARE_CONST_FUN_OBJ_2(str_rpartition_obj); -MP_DECLARE_CONST_FUN_OBJ_2(str_center_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_lower_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_upper_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_isspace_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_isalpha_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_isdigit_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_isupper_obj); -MP_DECLARE_CONST_FUN_OBJ_1(str_islower_obj); - -#endif // MICROPY_INCLUDED_PY_OBJSTR_H diff --git a/user/mpy/py/objstringio.c b/user/mpy/py/objstringio.c deleted file mode 100644 index 046d325..0000000 --- a/user/mpy/py/objstringio.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objstr.h" -#include "py/objstringio.h" -#include "py/runtime.h" -#include "py/stream.h" - -#if MICROPY_PY_IO - -#if MICROPY_CPYTHON_COMPAT -STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) { - if (o->vstr == NULL) { - mp_raise_ValueError("I/O operation on closed file"); - } -} -#else -#define check_stringio_is_open(o) -#endif - -STATIC void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, self->base.type == &mp_type_stringio ? "" : "", self); -} - -STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { - (void)errcode; - mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); - check_stringio_is_open(o); - if (o->vstr->len <= o->pos) { // read to EOF, or seeked to EOF or beyond - return 0; - } - mp_uint_t remaining = o->vstr->len - o->pos; - if (size > remaining) { - size = remaining; - } - memcpy(buf, o->vstr->buf + o->pos, size); - o->pos += size; - return size; -} - -STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) { - const void *buf = o->vstr->buf; - o->vstr->buf = m_new(char, o->vstr->len); - memcpy(o->vstr->buf, buf, o->vstr->len); - o->vstr->fixed_buf = false; - o->ref_obj = MP_OBJ_NULL; -} - -STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { - (void)errcode; - mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); - check_stringio_is_open(o); - - if (o->vstr->fixed_buf) { - stringio_copy_on_write(o); - } - - mp_uint_t new_pos = o->pos + size; - if (new_pos < size) { - // Writing bytes will overflow o->pos beyond limit of mp_uint_t. - *errcode = MP_EFBIG; - return MP_STREAM_ERROR; - } - mp_uint_t org_len = o->vstr->len; - if (new_pos > o->vstr->alloc) { - // Take all what's already allocated... - o->vstr->len = o->vstr->alloc; - // ... and add more - vstr_add_len(o->vstr, new_pos - o->vstr->alloc); - } - // If there was a seek past EOF, clear the hole - if (o->pos > org_len) { - memset(o->vstr->buf + org_len, 0, o->pos - org_len); - } - memcpy(o->vstr->buf + o->pos, buf, size); - o->pos = new_pos; - if (new_pos > o->vstr->len) { - o->vstr->len = new_pos; - } - return size; -} - -STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { - (void)errcode; - mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); - switch (request) { - case MP_STREAM_SEEK: { - struct mp_stream_seek_t *s = (struct mp_stream_seek_t*)arg; - mp_uint_t ref = 0; - switch (s->whence) { - case 1: // SEEK_CUR - ref = o->pos; - break; - case 2: // SEEK_END - ref = o->vstr->len; - break; - } - o->pos = ref + s->offset; - s->offset = o->pos; - return 0; - } - case MP_STREAM_FLUSH: - return 0; - default: - *errcode = MP_EINVAL; - return MP_STREAM_ERROR; - } -} - -#define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_bytes) - -STATIC mp_obj_t stringio_getvalue(mp_obj_t self_in) { - mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); - check_stringio_is_open(self); - // TODO: Try to avoid copying string - return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte*)self->vstr->buf, self->vstr->len); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue); - -STATIC mp_obj_t stringio_close(mp_obj_t self_in) { - mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); -#if MICROPY_CPYTHON_COMPAT - vstr_free(self->vstr); - self->vstr = NULL; -#else - vstr_clear(self->vstr); - self->vstr->alloc = 0; - self->vstr->len = 0; - self->pos = 0; -#endif - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_close_obj, stringio_close); - -STATIC mp_obj_t stringio___exit__(size_t n_args, const mp_obj_t *args) { - (void)n_args; - return stringio_close(args[0]); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stringio___exit___obj, 4, 4, stringio___exit__); - -STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) { - mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); - o->base.type = type; - o->pos = 0; - o->ref_obj = MP_OBJ_NULL; - return o; -} - -STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)n_kw; // TODO check n_kw==0 - - mp_uint_t sz = 16; - bool initdata = false; - mp_buffer_info_t bufinfo; - - mp_obj_stringio_t *o = stringio_new(type_in); - - if (n_args > 0) { - if (MP_OBJ_IS_INT(args[0])) { - sz = mp_obj_get_int(args[0]); - } else { - mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); - - if (MP_OBJ_IS_STR_OR_BYTES(args[0])) { - o->vstr = m_new_obj(vstr_t); - vstr_init_fixed_buf(o->vstr, bufinfo.len, bufinfo.buf); - o->vstr->len = bufinfo.len; - o->ref_obj = args[0]; - return MP_OBJ_FROM_PTR(o); - } - - sz = bufinfo.len; - initdata = true; - } - } - - o->vstr = vstr_new(sz); - - if (initdata) { - stringio_write(MP_OBJ_FROM_PTR(o), bufinfo.buf, bufinfo.len, NULL); - // Cur ptr is always at the beginning of buffer at the construction - o->pos = 0; - } - return MP_OBJ_FROM_PTR(o); -} - -STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) }, - { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) }, - { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&stringio_close_obj) }, - { MP_ROM_QSTR(MP_QSTR_getvalue), MP_ROM_PTR(&stringio_getvalue_obj) }, - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&stringio___exit___obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table); - -STATIC const mp_stream_p_t stringio_stream_p = { - .read = stringio_read, - .write = stringio_write, - .ioctl = stringio_ioctl, - .is_text = true, -}; - -STATIC const mp_stream_p_t bytesio_stream_p = { - .read = stringio_read, - .write = stringio_write, - .ioctl = stringio_ioctl, -}; - -const mp_obj_type_t mp_type_stringio = { - { &mp_type_type }, - .name = MP_QSTR_StringIO, - .print = stringio_print, - .make_new = stringio_make_new, - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &stringio_stream_p, - .locals_dict = (mp_obj_dict_t*)&stringio_locals_dict, -}; - -#if MICROPY_PY_IO_BYTESIO -const mp_obj_type_t mp_type_bytesio = { - { &mp_type_type }, - .name = MP_QSTR_BytesIO, - .print = stringio_print, - .make_new = stringio_make_new, - .getiter = mp_identity_getiter, - .iternext = mp_stream_unbuffered_iter, - .protocol = &bytesio_stream_p, - .locals_dict = (mp_obj_dict_t*)&stringio_locals_dict, -}; -#endif - -#endif diff --git a/user/mpy/py/objstringio.h b/user/mpy/py/objstringio.h deleted file mode 100644 index 56738f4..0000000 --- a/user/mpy/py/objstringio.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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_OBJSTRINGIO_H -#define MICROPY_INCLUDED_PY_OBJSTRINGIO_H - -#include "py/obj.h" - -typedef struct _mp_obj_stringio_t { - mp_obj_base_t base; - vstr_t *vstr; - // StringIO has single pointer used for both reading and writing - mp_uint_t pos; - // Underlying object buffered by this StringIO - mp_obj_t ref_obj; -} mp_obj_stringio_t; - -#endif // MICROPY_INCLUDED_PY_OBJSTRINGIO_H diff --git a/user/mpy/py/objstrunicode.c b/user/mpy/py/objstrunicode.c deleted file mode 100644 index 036f7f3..0000000 --- a/user/mpy/py/objstrunicode.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objstr.h" -#include "py/objlist.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_PY_BUILTINS_STR_UNICODE - -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); - -/******************************************************************************/ -/* str */ - -STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) { - // this escapes characters, but it will be very slow to print (calling print many times) - bool has_single_quote = false; - bool has_double_quote = false; - for (const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) { - if (*s == '\'') { - has_single_quote = true; - } else if (*s == '"') { - has_double_quote = true; - } - } - unichar quote_char = '\''; - if (has_single_quote && !has_double_quote) { - quote_char = '"'; - } - mp_printf(print, "%c", quote_char); - const byte *s = str_data, *top = str_data + str_len; - while (s < top) { - unichar ch; - ch = utf8_get_char(s); - s = utf8_next_char(s); - if (ch == quote_char) { - mp_printf(print, "\\%c", quote_char); - } else if (ch == '\\') { - mp_print_str(print, "\\\\"); - } else if (32 <= ch && ch <= 126) { - mp_printf(print, "%c", ch); - } else if (ch == '\n') { - mp_print_str(print, "\\n"); - } else if (ch == '\r') { - mp_print_str(print, "\\r"); - } else if (ch == '\t') { - mp_print_str(print, "\\t"); - } else if (ch < 0x100) { - mp_printf(print, "\\x%02x", ch); - } else if (ch < 0x10000) { - mp_printf(print, "\\u%04x", ch); - } else { - mp_printf(print, "\\U%08x", ch); - } - } - mp_printf(print, "%c", quote_char); -} - -STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - GET_STR_DATA_LEN(self_in, str_data, str_len); - #if MICROPY_PY_UJSON - if (kind == PRINT_JSON) { - mp_str_print_json(print, str_data, str_len); - return; - } - #endif - if (kind == PRINT_STR) { - mp_printf(print, "%.*s", str_len, str_data); - } else { - uni_print_quoted(print, str_data, str_len); - } -} - -STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) { - GET_STR_DATA_LEN(self_in, str_data, str_len); - switch (op) { - case MP_UNARY_OP_BOOL: - return mp_obj_new_bool(str_len != 0); - case MP_UNARY_OP_LEN: - return MP_OBJ_NEW_SMALL_INT(unichar_charlen((const char *)str_data, str_len)); - default: - return MP_OBJ_NULL; // op not supported - } -} - -// Convert an index into a pointer to its lead byte. Out of bounds indexing will raise IndexError or -// be capped to the first/last character of the string, depending on is_slice. -const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, - mp_obj_t index, bool is_slice) { - // All str functions also handle bytes objects, and they call str_index_to_ptr(), - // so it must handle bytes. - if (type == &mp_type_bytes) { - // Taken from objstr.c:str_index_to_ptr() - size_t index_val = mp_get_index(type, self_len, index, is_slice); - return self_data + index_val; - } - - mp_int_t i; - // Copied from mp_get_index; I don't want bounds checking, just give me - // the integer as-is. (I can't bounds-check without scanning the whole - // string; an out-of-bounds index will be caught in the loops below.) - if (MP_OBJ_IS_SMALL_INT(index)) { - i = MP_OBJ_SMALL_INT_VALUE(index); - } else if (!mp_obj_get_int_maybe(index, &i)) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "string indices must be integers, not %s", mp_obj_get_type_str(index))); - } - const byte *s, *top = self_data + self_len; - if (i < 0) - { - // Negative indexing is performed by counting from the end of the string. - for (s = top - 1; i; --s) { - if (s < self_data) { - if (is_slice) { - return self_data; - } - mp_raise_msg(&mp_type_IndexError, "string index out of range"); - } - if (!UTF8_IS_CONT(*s)) { - ++i; - } - } - ++s; - } else { - // Positive indexing, correspondingly, counts from the start of the string. - // It's assumed that negative indexing will generally be used with small - // absolute values (eg str[-1], not str[-1000000]), which means it'll be - // more efficient this way. - s = self_data; - while (1) { - // First check out-of-bounds - if (s >= top) { - if (is_slice) { - return top; - } - mp_raise_msg(&mp_type_IndexError, "string index out of range"); - } - // Then check completion - if (i-- == 0) { - break; - } - // Then skip UTF-8 char - ++s; - while (UTF8_IS_CONT(*s)) { - ++s; - } - } - } - return s; -} - -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - assert(type == &mp_type_str); - GET_STR_DATA_LEN(self_in, self_data, self_len); - if (value == MP_OBJ_SENTINEL) { - // load -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_t ostart, ostop, ostep; - mp_obj_slice_get(index, &ostart, &ostop, &ostep); - if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) { - mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); - } - - const byte *pstart, *pstop; - if (ostart != mp_const_none) { - pstart = str_index_to_ptr(type, self_data, self_len, ostart, true); - } else { - pstart = self_data; - } - if (ostop != mp_const_none) { - // pstop will point just after the stop character. This depends on - // the \0 at the end of the string. - pstop = str_index_to_ptr(type, self_data, self_len, ostop, true); - } else { - pstop = self_data + self_len; - } - if (pstop < pstart) { - return MP_OBJ_NEW_QSTR(MP_QSTR_); - } - return mp_obj_new_str_of_type(type, (const byte *)pstart, pstop - pstart); - } -#endif - const byte *s = str_index_to_ptr(type, self_data, self_len, index, false); - int len = 1; - if (UTF8_IS_NONASCII(*s)) { - // Count the number of 1 bits (after the first) - for (char mask = 0x40; *s & mask; mask >>= 1) { - ++len; - } - } - return mp_obj_new_str((const char*)s, len, true); // This will create a one-character string - } else { - return MP_OBJ_NULL; // op not supported - } -} - -STATIC const mp_rom_map_elem_t struni_locals_dict_table[] = { -#if MICROPY_CPYTHON_COMPAT - { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&str_encode_obj) }, -#endif - { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&str_find_obj) }, - { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&str_rfind_obj) }, - { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&str_index_obj) }, - { MP_ROM_QSTR(MP_QSTR_rindex), MP_ROM_PTR(&str_rindex_obj) }, - { MP_ROM_QSTR(MP_QSTR_join), MP_ROM_PTR(&str_join_obj) }, - { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&str_split_obj) }, - #if MICROPY_PY_BUILTINS_STR_SPLITLINES - { MP_ROM_QSTR(MP_QSTR_splitlines), MP_ROM_PTR(&str_splitlines_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_rsplit), MP_ROM_PTR(&str_rsplit_obj) }, - { MP_ROM_QSTR(MP_QSTR_startswith), MP_ROM_PTR(&str_startswith_obj) }, - { MP_ROM_QSTR(MP_QSTR_endswith), MP_ROM_PTR(&str_endswith_obj) }, - { MP_ROM_QSTR(MP_QSTR_strip), MP_ROM_PTR(&str_strip_obj) }, - { MP_ROM_QSTR(MP_QSTR_lstrip), MP_ROM_PTR(&str_lstrip_obj) }, - { MP_ROM_QSTR(MP_QSTR_rstrip), MP_ROM_PTR(&str_rstrip_obj) }, - { MP_ROM_QSTR(MP_QSTR_format), MP_ROM_PTR(&str_format_obj) }, - { MP_ROM_QSTR(MP_QSTR_replace), MP_ROM_PTR(&str_replace_obj) }, - { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&str_count_obj) }, - #if MICROPY_PY_BUILTINS_STR_PARTITION - { MP_ROM_QSTR(MP_QSTR_partition), MP_ROM_PTR(&str_partition_obj) }, - { MP_ROM_QSTR(MP_QSTR_rpartition), MP_ROM_PTR(&str_rpartition_obj) }, - #endif - #if MICROPY_PY_BUILTINS_STR_CENTER - { MP_ROM_QSTR(MP_QSTR_center), MP_ROM_PTR(&str_center_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_lower), MP_ROM_PTR(&str_lower_obj) }, - { MP_ROM_QSTR(MP_QSTR_upper), MP_ROM_PTR(&str_upper_obj) }, - { MP_ROM_QSTR(MP_QSTR_isspace), MP_ROM_PTR(&str_isspace_obj) }, - { MP_ROM_QSTR(MP_QSTR_isalpha), MP_ROM_PTR(&str_isalpha_obj) }, - { MP_ROM_QSTR(MP_QSTR_isdigit), MP_ROM_PTR(&str_isdigit_obj) }, - { MP_ROM_QSTR(MP_QSTR_isupper), MP_ROM_PTR(&str_isupper_obj) }, - { MP_ROM_QSTR(MP_QSTR_islower), MP_ROM_PTR(&str_islower_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(struni_locals_dict, struni_locals_dict_table); - -const mp_obj_type_t mp_type_str = { - { &mp_type_type }, - .name = MP_QSTR_str, - .print = uni_print, - .make_new = mp_obj_str_make_new, - .unary_op = uni_unary_op, - .binary_op = mp_obj_str_binary_op, - .subscr = str_subscr, - .getiter = mp_obj_new_str_iterator, - .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, - .locals_dict = (mp_obj_dict_t*)&struni_locals_dict, -}; - -/******************************************************************************/ -/* str iterator */ - -typedef struct _mp_obj_str_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_t str; - size_t cur; -} mp_obj_str_it_t; - -STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { - mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in); - GET_STR_DATA_LEN(self->str, str, len); - if (self->cur < len) { - const byte *cur = str + self->cur; - const byte *end = utf8_next_char(str + self->cur); - mp_obj_t o_out = mp_obj_new_str((const char*)cur, end - cur, true); - self->cur += end - cur; - return o_out; - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_str_it_t *o = (mp_obj_str_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = str_it_iternext; - o->str = str; - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} - -#endif // MICROPY_PY_BUILTINS_STR_UNICODE diff --git a/user/mpy/py/objtuple.c b/user/mpy/py/objtuple.c deleted file mode 100644 index 765edb9..0000000 --- a/user/mpy/py/objtuple.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objtuple.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -/******************************************************************************/ -/* tuple */ - -void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { - mp_print_str(print, "["); - } else { - mp_print_str(print, "("); - kind = PRINT_REPR; - } - for (size_t i = 0; i < o->len; i++) { - if (i > 0) { - mp_print_str(print, ", "); - } - mp_obj_print_helper(print, o->items[i], kind); - } - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { - mp_print_str(print, "]"); - } else { - if (o->len == 1) { - mp_print_str(print, ","); - } - mp_print_str(print, ")"); - } -} - -STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - mp_arg_check_num(n_args, n_kw, 0, 1, false); - - switch (n_args) { - case 0: - // return a empty tuple - return mp_const_empty_tuple; - - case 1: - default: { - // 1 argument, an iterable from which we make a new tuple - if (MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)) { - return args[0]; - } - - // TODO optimise for cases where we know the length of the iterator - - size_t alloc = 4; - size_t len = 0; - mp_obj_t *items = m_new(mp_obj_t, alloc); - - mp_obj_t iterable = mp_getiter(args[0], NULL); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - if (len >= alloc) { - items = m_renew(mp_obj_t, items, alloc, alloc * 2); - alloc *= 2; - } - items[len++] = item; - } - - mp_obj_t tuple = mp_obj_new_tuple(len, items); - m_del(mp_obj_t, items, alloc); - - return tuple; - } - } -} - -// Don't pass MP_BINARY_OP_NOT_EQUAL here -STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) { - // type check is done on getiter method to allow tuple, namedtuple, attrtuple - mp_check_self(mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter); - mp_obj_type_t *another_type = mp_obj_get_type(another_in); - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); - if (another_type->getiter != mp_obj_tuple_getiter) { - // Slow path for user subclasses - another_in = mp_instance_cast_to_native_base(another_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); - if (another_in == MP_OBJ_NULL) { - return false; - } - } - mp_obj_tuple_t *another = MP_OBJ_TO_PTR(another_in); - - return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); -} - -mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); - case MP_UNARY_OP_HASH: { - // start hash with pointer to empty tuple, to make it fairly unique - mp_int_t hash = (mp_int_t)mp_const_empty_tuple; - for (size_t i = 0; i < self->len; i++) { - hash += MP_OBJ_SMALL_INT_VALUE(mp_unary_op(MP_UNARY_OP_HASH, self->items[i])); - } - return MP_OBJ_NEW_SMALL_INT(hash); - } - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); - default: return MP_OBJ_NULL; // op not supported - } -} - -mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - mp_obj_tuple_t *o = MP_OBJ_TO_PTR(lhs); - switch (op) { - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: { - if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(rhs)), MP_OBJ_FROM_PTR(&mp_type_tuple))) { - return MP_OBJ_NULL; // op not supported - } - mp_obj_tuple_t *p = MP_OBJ_TO_PTR(rhs); - mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(o->len + p->len, NULL)); - mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t); - return MP_OBJ_FROM_PTR(s); - } - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: { - mp_int_t n; - if (!mp_obj_get_int_maybe(rhs, &n)) { - return MP_OBJ_NULL; // op not supported - } - if (n <= 0) { - return mp_const_empty_tuple; - } - mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(o->len * n, NULL)); - mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); - return MP_OBJ_FROM_PTR(s); - } - case MP_BINARY_OP_EQUAL: - case MP_BINARY_OP_LESS: - case MP_BINARY_OP_LESS_EQUAL: - case MP_BINARY_OP_MORE: - case MP_BINARY_OP_MORE_EQUAL: - return mp_obj_new_bool(tuple_cmp_helper(op, lhs, rhs)); - - default: - return MP_OBJ_NULL; // op not supported - } -} - -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == MP_OBJ_SENTINEL) { - // load - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); -#if MICROPY_PY_BUILTINS_SLICE - if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { - mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); - } - mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice.stop - slice.start, NULL)); - mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t); - return MP_OBJ_FROM_PTR(res); - } -#endif - size_t index_value = mp_get_index(self->base.type, self->len, index, false); - return self->items[index_value]; - } else { - return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); - return mp_seq_count_obj(self->items, self->len, value); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count); - -STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) { - mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)); - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]); - return mp_seq_index_obj(self->items, self->len, n_args, args); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index); - -STATIC const mp_rom_map_elem_t tuple_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&tuple_count_obj) }, - { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&tuple_index_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table); - -const mp_obj_type_t mp_type_tuple = { - { &mp_type_type }, - .name = MP_QSTR_tuple, - .print = mp_obj_tuple_print, - .make_new = mp_obj_tuple_make_new, - .unary_op = mp_obj_tuple_unary_op, - .binary_op = mp_obj_tuple_binary_op, - .subscr = mp_obj_tuple_subscr, - .getiter = mp_obj_tuple_getiter, - .locals_dict = (mp_obj_dict_t*)&tuple_locals_dict, -}; - -// the zero-length tuple -const mp_obj_tuple_t mp_const_empty_tuple_obj = {{&mp_type_tuple}, 0}; - -mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) { - if (n == 0) { - return mp_const_empty_tuple; - } - mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, n); - o->base.type = &mp_type_tuple; - o->len = n; - if (items) { - for (size_t i = 0; i < n; i++) { - o->items[i] = items[i]; - } - } - return MP_OBJ_FROM_PTR(o); -} - -void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); - *len = self->len; - *items = &self->items[0]; -} - -void mp_obj_tuple_del(mp_obj_t self_in) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); - m_del_var(mp_obj_tuple_t, mp_obj_t, self->len, self); -} - -/******************************************************************************/ -/* tuple iterator */ - -typedef struct _mp_obj_tuple_it_t { - mp_obj_base_t base; - mp_fun_1_t iternext; - mp_obj_tuple_t *tuple; - size_t cur; -} mp_obj_tuple_it_t; - -STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) { - mp_obj_tuple_it_t *self = MP_OBJ_TO_PTR(self_in); - if (self->cur < self->tuple->len) { - mp_obj_t o_out = self->tuple->items[self->cur]; - self->cur += 1; - return o_out; - } else { - return MP_OBJ_STOP_ITERATION; - } -} - -mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - assert(sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t)); - mp_obj_tuple_it_t *o = (mp_obj_tuple_it_t*)iter_buf; - o->base.type = &mp_type_polymorph_iter; - o->iternext = tuple_it_iternext; - o->tuple = MP_OBJ_TO_PTR(o_in); - o->cur = 0; - return MP_OBJ_FROM_PTR(o); -} diff --git a/user/mpy/py/objtuple.h b/user/mpy/py/objtuple.h deleted file mode 100644 index 05c6490..0000000 --- a/user/mpy/py/objtuple.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - -#include "py/obj.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_uint_t op, mp_obj_t self_in); -mp_obj_t mp_obj_tuple_binary_op(mp_uint_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 MICROPY_PY_COLLECTIONS -void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o); -#endif - -mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items); - -#endif // MICROPY_INCLUDED_PY_OBJTUPLE_H diff --git a/user/mpy/py/objtype.c b/user/mpy/py/objtype.c deleted file mode 100644 index e1a24da..0000000 --- a/user/mpy/py/objtype.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* - * 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-2016 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. - */ - -#include -#include -#include -#include - -#include "py/nlr.h" -#include "py/objtype.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_PRINT (0) -#define DEBUG_printf(...) (void)0 -#endif - -STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - -/******************************************************************************/ -// instance object - -STATIC mp_obj_t mp_obj_new_instance(const mp_obj_type_t *class, size_t subobjs) { - mp_obj_instance_t *o = m_new_obj_var(mp_obj_instance_t, mp_obj_t, subobjs); - o->base.type = class; - mp_map_init(&o->members, 0); - mp_seq_clear(o->subobj, 0, subobjs, sizeof(*o->subobj)); - return MP_OBJ_FROM_PTR(o); -} - -STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) { - int count = 0; - for (;;) { - if (type == &mp_type_object) { - // Not a "real" type, end search here. - return count; - } else if (mp_obj_is_native_type(type)) { - // Native types don't have parents (at least not from our perspective) so end. - *last_native_base = type; - return count + 1; - } else if (type->parent == NULL) { - // No parents so end search here. - return count; - } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { - // Multiple parents, search through them all recursively. - const mp_obj_tuple_t *parent_tuple = type->parent; - const mp_obj_t *item = parent_tuple->items; - const mp_obj_t *top = item + parent_tuple->len; - for (; item < top; ++item) { - assert(MP_OBJ_IS_TYPE(*item, &mp_type_type)); - const mp_obj_type_t *bt = (const mp_obj_type_t *)MP_OBJ_TO_PTR(*item); - count += instance_count_native_bases(bt, last_native_base); - } - return count; - } else { - // A single parent, use iteration to continue the search. - type = type->parent; - } - } -} - -// TODO -// This implements depth-first left-to-right MRO, which is not compliant with Python3 MRO -// http://python-history.blogspot.com/2010/06/method-resolution-order.html -// https://www.python.org/download/releases/2.3/mro/ -// -// will keep lookup->dest[0]'s value (should be MP_OBJ_NULL on invocation) if attribute -// is not found -// will set lookup->dest[0] to MP_OBJ_SENTINEL if special method was found in a native -// type base via slot id (as specified by lookup->meth_offset). As there can be only one -// native base, it's known that it applies to instance->subobj[0]. In most cases, we also -// don't need to know which type it was - because instance->subobj[0] is of that type. -// The only exception is when object is not yet constructed, then we need to know base -// native type to construct its instance->subobj[0] from. But this case is handled via -// instance_count_native_bases(), which returns a native base which it saw. -struct class_lookup_data { - mp_obj_instance_t *obj; - qstr attr; - size_t meth_offset; - mp_obj_t *dest; - bool is_type; -}; - -STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) { - assert(lookup->dest[0] == MP_OBJ_NULL); - assert(lookup->dest[1] == MP_OBJ_NULL); - for (;;) { - // Optimize special method lookup for native types - // This avoids extra method_name => slot lookup. On the other hand, - // this should not be applied to class types, as will result in extra - // lookup either. - if (lookup->meth_offset != 0 && mp_obj_is_native_type(type)) { - if (*(void**)((char*)type + lookup->meth_offset) != NULL) { - DEBUG_printf("mp_obj_class_lookup: matched special meth slot for %s\n", qstr_str(lookup->attr)); - lookup->dest[0] = MP_OBJ_SENTINEL; - return; - } - } - - if (type->locals_dict != NULL) { - // search locals_dict (the set of methods/attributes) - assert(type->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now - mp_map_t *locals_map = &type->locals_dict->map; - mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(lookup->attr), MP_MAP_LOOKUP); - if (elem != NULL) { - if (lookup->is_type) { - // If we look up a class method, we need to return original type for which we - // do a lookup, not a (base) type in which we found the class method. - const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj; - mp_convert_member_lookup(MP_OBJ_NULL, org_type, elem->value, lookup->dest); - } else { - mp_obj_instance_t *obj = lookup->obj; - mp_obj_t obj_obj; - if (obj != NULL && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) { - // If we're dealing with native base class, then it applies to native sub-object - obj_obj = obj->subobj[0]; - } else { - obj_obj = MP_OBJ_FROM_PTR(obj); - } - mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest); - } -#if DEBUG_PRINT - printf("mp_obj_class_lookup: Returning: "); - mp_obj_print(lookup->dest[0], PRINT_REPR); printf(" "); - mp_obj_print(lookup->dest[1], PRINT_REPR); printf("\n"); -#endif - return; - } - } - - // Previous code block takes care about attributes defined in .locals_dict, - // but some attributes of native types may be handled using .load_attr method, - // so make sure we try to lookup those too. - if (lookup->obj != NULL && !lookup->is_type && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) { - mp_load_method_maybe(lookup->obj->subobj[0], lookup->attr, lookup->dest); - if (lookup->dest[0] != MP_OBJ_NULL) { - return; - } - } - - // attribute not found, keep searching base classes - - if (type->parent == NULL) { - return; - } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { - const mp_obj_tuple_t *parent_tuple = type->parent; - const mp_obj_t *item = parent_tuple->items; - const mp_obj_t *top = item + parent_tuple->len - 1; - for (; item < top; ++item) { - assert(MP_OBJ_IS_TYPE(*item, &mp_type_type)); - mp_obj_type_t *bt = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item); - if (bt == &mp_type_object) { - // Not a "real" type - continue; - } - mp_obj_class_lookup(lookup, bt); - if (lookup->dest[0] != MP_OBJ_NULL) { - return; - } - } - - // search last base (simple tail recursion elimination) - assert(MP_OBJ_IS_TYPE(*item, &mp_type_type)); - type = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item); - } else { - type = type->parent; - } - if (type == &mp_type_object) { - // Not a "real" type - return; - } - } -} - -STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - qstr meth = (kind == PRINT_STR) ? MP_QSTR___str__ : MP_QSTR___repr__; - mp_obj_t member[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = self, - .attr = meth, - .meth_offset = offsetof(mp_obj_type_t, print), - .dest = member, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == MP_OBJ_NULL && kind == PRINT_STR) { - // If there's no __str__, fall back to __repr__ - lookup.attr = MP_QSTR___repr__; - lookup.meth_offset = 0; - mp_obj_class_lookup(&lookup, self->base.type); - } - - if (member[0] == MP_OBJ_SENTINEL) { - // Handle Exception subclasses specially - if (mp_obj_is_native_exception_instance(self->subobj[0])) { - if (kind != PRINT_STR) { - mp_print_str(print, qstr_str(self->base.type->name)); - } - mp_obj_print_helper(print, self->subobj[0], kind | PRINT_EXC_SUBCLASS); - } else { - mp_obj_print_helper(print, self->subobj[0], kind); - } - return; - } - - if (member[0] != MP_OBJ_NULL) { - mp_obj_t r = mp_call_function_1(member[0], self_in); - mp_obj_print_helper(print, r, PRINT_STR); - return; - } - - // TODO: CPython prints fully-qualified type name - mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self); -} - -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { - assert(mp_obj_is_instance_type(self)); - - const mp_obj_type_t *native_base; - size_t num_native_bases = instance_count_native_bases(self, &native_base); - assert(num_native_bases < 2); - - mp_obj_instance_t *o = MP_OBJ_TO_PTR(mp_obj_new_instance(self, num_native_bases)); - - // This executes only "__new__" part of obejection creation. - // TODO: This won't work will for classes with native bases. - // TODO: This is hack, should be resolved along the lines of - // https://github.com/micropython/micropython/issues/606#issuecomment-43685883 - if (n_args == 1 && *args == MP_OBJ_SENTINEL) { - return MP_OBJ_FROM_PTR(o); - } - - // look for __new__ function - mp_obj_t init_fn[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = NULL, - .attr = MP_QSTR___new__, - .meth_offset = offsetof(mp_obj_type_t, make_new), - .dest = init_fn, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self); - - mp_obj_t new_ret = MP_OBJ_FROM_PTR(o); - if (init_fn[0] == MP_OBJ_SENTINEL) { - // Native type's constructor is what wins - it gets all our arguments, - // and none Python classes are initialized at all. - o->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args); - } else if (init_fn[0] != MP_OBJ_NULL) { - // now call Python class __new__ function with all args - if (n_args == 0 && n_kw == 0) { - mp_obj_t args2[1] = {MP_OBJ_FROM_PTR(self)}; - new_ret = mp_call_function_n_kw(init_fn[0], 1, 0, args2); - } else { - mp_obj_t *args2 = m_new(mp_obj_t, 1 + n_args + 2 * n_kw); - args2[0] = MP_OBJ_FROM_PTR(self); - memcpy(args2 + 1, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - new_ret = mp_call_function_n_kw(init_fn[0], n_args + 1, n_kw, args2); - m_del(mp_obj_t, args2, 1 + n_args + 2 * n_kw); - } - - } - - // https://docs.python.org/3.4/reference/datamodel.html#object.__new__ - // "If __new__() does not return an instance of cls, then the new instance's __init__() method will not be invoked." - if (mp_obj_get_type(new_ret) != self) { - return new_ret; - } - - o = MP_OBJ_TO_PTR(new_ret); - - // now call Python class __init__ function with all args - init_fn[0] = init_fn[1] = MP_OBJ_NULL; - lookup.obj = o; - lookup.attr = MP_QSTR___init__; - lookup.meth_offset = 0; - mp_obj_class_lookup(&lookup, self); - if (init_fn[0] != MP_OBJ_NULL) { - mp_obj_t init_ret; - if (n_args == 0 && n_kw == 0) { - init_ret = mp_call_method_n_kw(0, 0, init_fn); - } else { - mp_obj_t *args2 = m_new(mp_obj_t, 2 + n_args + 2 * n_kw); - args2[0] = init_fn[0]; - args2[1] = init_fn[1]; - memcpy(args2 + 2, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); - init_ret = mp_call_method_n_kw(n_args, n_kw, args2); - m_del(mp_obj_t, args2, 2 + n_args + 2 * n_kw); - } - if (init_ret != mp_const_none) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("__init__() should return None"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "__init__() should return None, not '%s'", mp_obj_get_type_str(init_ret))); - } - } - - } - - return MP_OBJ_FROM_PTR(o); -} - -const qstr mp_unary_op_method_name[] = { - [MP_UNARY_OP_BOOL] = MP_QSTR___bool__, - [MP_UNARY_OP_LEN] = MP_QSTR___len__, - [MP_UNARY_OP_HASH] = MP_QSTR___hash__, - #if MICROPY_PY_ALL_SPECIAL_METHODS - [MP_UNARY_OP_POSITIVE] = MP_QSTR___pos__, - [MP_UNARY_OP_NEGATIVE] = MP_QSTR___neg__, - [MP_UNARY_OP_INVERT] = MP_QSTR___invert__, - #endif - #if MICROPY_PY_SYS_GETSIZEOF - [MP_UNARY_OP_SIZEOF] = MP_QSTR_getsizeof, - #endif - [MP_UNARY_OP_NOT] = MP_QSTR_, // don't need to implement this, used to make sure array has full size -}; - -STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - - #if MICROPY_PY_SYS_GETSIZEOF - if (MP_UNLIKELY(op == MP_UNARY_OP_SIZEOF)) { - // TODO: This doesn't count inherited objects (self->subobj) - const mp_obj_type_t *native_base; - size_t num_native_bases = instance_count_native_bases(mp_obj_get_type(self_in), &native_base); - - size_t sz = sizeof(*self) + sizeof(*self->subobj) * num_native_bases - + sizeof(*self->members.table) * self->members.alloc; - return MP_OBJ_NEW_SMALL_INT(sz); - } - #endif - - qstr op_name = mp_unary_op_method_name[op]; - /* Still try to lookup native slot - if (op_name == 0) { - return MP_OBJ_NULL; - } - */ - mp_obj_t member[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = self, - .attr = op_name, - .meth_offset = offsetof(mp_obj_type_t, unary_op), - .dest = member, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == MP_OBJ_SENTINEL) { - return mp_unary_op(op, self->subobj[0]); - } else if (member[0] != MP_OBJ_NULL) { - mp_obj_t val = mp_call_function_1(member[0], self_in); - // __hash__ must return a small int - if (op == MP_UNARY_OP_HASH) { - val = MP_OBJ_NEW_SMALL_INT(mp_obj_get_int_truncated(val)); - } - return val; - } else { - if (op == MP_UNARY_OP_HASH) { - lookup.attr = MP_QSTR___eq__; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == MP_OBJ_NULL) { - // https://docs.python.org/3/reference/datamodel.html#object.__hash__ - // "User-defined classes have __eq__() and __hash__() methods by default; - // with them, all objects compare unequal (except with themselves) and - // x.__hash__() returns an appropriate value such that x == y implies - // both that x is y and hash(x) == hash(y)." - return MP_OBJ_NEW_SMALL_INT((mp_uint_t)self_in); - } - // "A class that overrides __eq__() and does not define __hash__() will have its __hash__() implicitly set to None. - // When the __hash__() method of a class is None, instances of the class will raise an appropriate TypeError" - } - - return MP_OBJ_NULL; // op not supported - } -} - -const qstr mp_binary_op_method_name[] = { - /* - 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_QSTR___add__, - [MP_BINARY_OP_SUBTRACT] = MP_QSTR___sub__, - #if MICROPY_PY_ALL_SPECIAL_METHODS - [MP_BINARY_OP_MULTIPLY] = MP_QSTR___mul__, - [MP_BINARY_OP_FLOOR_DIVIDE] = MP_QSTR___floordiv__, - [MP_BINARY_OP_TRUE_DIVIDE] = MP_QSTR___truediv__, - #endif - /* - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, - 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,*/ - #if MICROPY_PY_ALL_SPECIAL_METHODS - [MP_BINARY_OP_INPLACE_ADD] = MP_QSTR___iadd__, - [MP_BINARY_OP_INPLACE_SUBTRACT] = MP_QSTR___isub__, - #endif - /*MP_BINARY_OP_INPLACE_MULTIPLY, - MP_BINARY_OP_INPLACE_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER,*/ - [MP_BINARY_OP_LESS] = MP_QSTR___lt__, - [MP_BINARY_OP_MORE] = MP_QSTR___gt__, - [MP_BINARY_OP_EQUAL] = MP_QSTR___eq__, - [MP_BINARY_OP_LESS_EQUAL] = MP_QSTR___le__, - [MP_BINARY_OP_MORE_EQUAL] = MP_QSTR___ge__, - /* - MP_BINARY_OP_NOT_EQUAL, // a != b calls a == b and inverts result - */ - [MP_BINARY_OP_IN] = MP_QSTR___contains__, - /* - MP_BINARY_OP_IS, - */ - [MP_BINARY_OP_EXCEPTION_MATCH] = MP_QSTR_, // not implemented, used to make sure array has full size -}; - -STATIC mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - // Note: For ducktyping, CPython does not look in the instance members or use - // __getattr__ or __getattribute__. It only looks in the class dictionary. - mp_obj_instance_t *lhs = MP_OBJ_TO_PTR(lhs_in); - qstr op_name = mp_binary_op_method_name[op]; - /* Still try to lookup native slot - if (op_name == 0) { - return MP_OBJ_NULL; - } - */ - mp_obj_t dest[3] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = lhs, - .attr = op_name, - .meth_offset = offsetof(mp_obj_type_t, binary_op), - .dest = dest, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, lhs->base.type); - if (dest[0] == MP_OBJ_SENTINEL) { - return mp_binary_op(op, lhs->subobj[0], rhs_in); - } else if (dest[0] != MP_OBJ_NULL) { - dest[2] = rhs_in; - return mp_call_method_n_kw(1, 0, dest); - } else { - return MP_OBJ_NULL; // op not supported - } -} - -STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - // logic: look in instance members then class locals - assert(mp_obj_is_instance_type(mp_obj_get_type(self_in))); - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - - mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); - if (elem != NULL) { - // object member, always treated as a value - // TODO should we check for properties? - dest[0] = elem->value; - return; - } -#if MICROPY_CPYTHON_COMPAT - if (attr == MP_QSTR___dict__) { - // Create a new dict with a copy of the instance's map items. - // This creates, unlike CPython, a 'read-only' __dict__: modifying - // it will not result in modifications to the actual instance members. - mp_map_t *map = &self->members; - mp_obj_t attr_dict = mp_obj_new_dict(map->used); - for (size_t i = 0; i < map->alloc; ++i) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - mp_obj_dict_store(attr_dict, map->table[i].key, map->table[i].value); - } - } - dest[0] = attr_dict; - return; - } -#endif - struct class_lookup_data lookup = { - .obj = self, - .attr = attr, - .meth_offset = 0, - .dest = dest, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - mp_obj_t member = dest[0]; - if (member != MP_OBJ_NULL) { - #if MICROPY_PY_BUILTINS_PROPERTY - if (MP_OBJ_IS_TYPE(member, &mp_type_property)) { - // object member is a property; delegate the load to the property - // Note: This is an optimisation for code size and execution time. - // The proper way to do it is have the functionality just below - // in a __get__ method of the property object, and then it would - // be called by the descriptor code down below. But that way - // requires overhead for the nested mp_call's and overhead for - // the code. - const mp_obj_t *proxy = mp_obj_property_get(member); - if (proxy[0] == mp_const_none) { - mp_raise_msg(&mp_type_AttributeError, "unreadable attribute"); - } else { - dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self_in); - } - return; - } - #endif - - #if MICROPY_PY_DESCRIPTORS - // found a class attribute; if it has a __get__ method then call it with the - // class instance and class as arguments and return the result - // Note that this is functionally correct but very slow: each load_attr - // requires an extra mp_load_method_maybe to check for the __get__. - mp_obj_t attr_get_method[4]; - mp_load_method_maybe(member, MP_QSTR___get__, attr_get_method); - if (attr_get_method[0] != MP_OBJ_NULL) { - attr_get_method[2] = self_in; - attr_get_method[3] = MP_OBJ_FROM_PTR(mp_obj_get_type(self_in)); - dest[0] = mp_call_method_n_kw(2, 0, attr_get_method); - } - #endif - return; - } - - // try __getattr__ - if (attr != MP_QSTR___getattr__) { - #if MICROPY_PY_DELATTR_SETATTR - // If the requested attr is __setattr__/__delattr__ then don't delegate the lookup - // to __getattr__. If we followed CPython's behaviour then __setattr__/__delattr__ - // would have already been found in the "object" base class. - if (attr == MP_QSTR___setattr__ || attr == MP_QSTR___delattr__) { - return; - } - #endif - - mp_obj_t dest2[3]; - mp_load_method_maybe(self_in, MP_QSTR___getattr__, dest2); - if (dest2[0] != MP_OBJ_NULL) { - // __getattr__ exists, call it and return its result - // XXX if this fails to load the requested attr, should we catch the attribute error and return silently? - dest2[2] = MP_OBJ_NEW_QSTR(attr); - dest[0] = mp_call_method_n_kw(1, 0, dest2); - return; - } - } -} - -STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - - #if MICROPY_PY_BUILTINS_PROPERTY || MICROPY_PY_DESCRIPTORS - // With property and/or descriptors enabled we need to do a lookup - // first in the class dict for the attribute to see if the store should - // be delegated. - // Note: this makes all stores slow... how to fix? - mp_obj_t member[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = self, - .attr = attr, - .meth_offset = 0, - .dest = member, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - - if (member[0] != MP_OBJ_NULL) { - #if MICROPY_PY_BUILTINS_PROPERTY - if (MP_OBJ_IS_TYPE(member[0], &mp_type_property)) { - // attribute exists and is a property; delegate the store/delete - // Note: This is an optimisation for code size and execution time. - // The proper way to do it is have the functionality just below in - // a __set__/__delete__ method of the property object, and then it - // would be called by the descriptor code down below. But that way - // requires overhead for the nested mp_call's and overhead for - // the code. - const mp_obj_t *proxy = mp_obj_property_get(member[0]); - mp_obj_t dest[2] = {self_in, value}; - if (value == MP_OBJ_NULL) { - // delete attribute - if (proxy[2] == mp_const_none) { - // TODO better error message? - return false; - } else { - mp_call_function_n_kw(proxy[2], 1, 0, dest); - return true; - } - } else { - // store attribute - if (proxy[1] == mp_const_none) { - // TODO better error message? - return false; - } else { - mp_call_function_n_kw(proxy[1], 2, 0, dest); - return true; - } - } - } - #endif - - #if MICROPY_PY_DESCRIPTORS - // found a class attribute; if it has a __set__/__delete__ method then - // call it with the class instance (and value) as arguments - if (value == MP_OBJ_NULL) { - // delete attribute - mp_obj_t attr_delete_method[3]; - mp_load_method_maybe(member[0], MP_QSTR___delete__, attr_delete_method); - if (attr_delete_method[0] != MP_OBJ_NULL) { - attr_delete_method[2] = self_in; - mp_call_method_n_kw(1, 0, attr_delete_method); - return true; - } - } else { - // store attribute - mp_obj_t attr_set_method[4]; - mp_load_method_maybe(member[0], MP_QSTR___set__, attr_set_method); - if (attr_set_method[0] != MP_OBJ_NULL) { - attr_set_method[2] = self_in; - attr_set_method[3] = value; - mp_call_method_n_kw(2, 0, attr_set_method); - return true; - } - } - #endif - } - #endif - - if (value == MP_OBJ_NULL) { - // delete attribute - #if MICROPY_PY_DELATTR_SETATTR - // try __delattr__ first - mp_obj_t attr_delattr_method[3]; - mp_load_method_maybe(self_in, MP_QSTR___delattr__, attr_delattr_method); - if (attr_delattr_method[0] != MP_OBJ_NULL) { - // __delattr__ exists, so call it - attr_delattr_method[2] = MP_OBJ_NEW_QSTR(attr); - mp_call_method_n_kw(1, 0, attr_delattr_method); - return true; - } - #endif - - mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_REMOVE_IF_FOUND); - return elem != NULL; - } else { - // store attribute - #if MICROPY_PY_DELATTR_SETATTR - // try __setattr__ first - mp_obj_t attr_setattr_method[4]; - mp_load_method_maybe(self_in, MP_QSTR___setattr__, attr_setattr_method); - if (attr_setattr_method[0] != MP_OBJ_NULL) { - // __setattr__ exists, so call it - attr_setattr_method[2] = MP_OBJ_NEW_QSTR(attr); - attr_setattr_method[3] = value; - mp_call_method_n_kw(2, 0, attr_setattr_method); - return true; - } - #endif - - mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; - return true; - } -} - -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] == MP_OBJ_NULL) { - mp_obj_instance_load_attr(self_in, attr, dest); - } else { - if (mp_obj_instance_store_attr(self_in, attr, dest[1])) { - dest[0] = MP_OBJ_NULL; // indicate success - } - } -} - -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t member[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = self, - .meth_offset = offsetof(mp_obj_type_t, subscr), - .dest = member, - .is_type = false, - }; - size_t meth_args; - if (value == MP_OBJ_NULL) { - // delete item - lookup.attr = MP_QSTR___delitem__; - mp_obj_class_lookup(&lookup, self->base.type); - meth_args = 2; - } else if (value == MP_OBJ_SENTINEL) { - // load item - lookup.attr = MP_QSTR___getitem__; - mp_obj_class_lookup(&lookup, self->base.type); - meth_args = 2; - } else { - // store item - lookup.attr = MP_QSTR___setitem__; - mp_obj_class_lookup(&lookup, self->base.type); - meth_args = 3; - } - if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr(self->subobj[0], index, value); - } else if (member[0] != MP_OBJ_NULL) { - mp_obj_t args[3] = {self_in, index, value}; - // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw - mp_obj_t ret = mp_call_function_n_kw(member[0], meth_args, 0, args); - if (value == MP_OBJ_SENTINEL) { - return ret; - } else { - return mp_const_none; - } - } else { - return MP_OBJ_NULL; // op not supported - } -} - -STATIC mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - struct class_lookup_data lookup = { - .obj = self, - .attr = MP_QSTR___call__, - .meth_offset = offsetof(mp_obj_type_t, call), - .dest = member, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - return member[0]; -} - -bool mp_obj_instance_is_callable(mp_obj_t self_in) { - mp_obj_t member[2] = {MP_OBJ_NULL, MP_OBJ_NULL}; - return mp_obj_instance_get_call(self_in, member) != MP_OBJ_NULL; -} - -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_t member[2] = {MP_OBJ_NULL, MP_OBJ_NULL}; - mp_obj_t call = mp_obj_instance_get_call(self_in, member); - if (call == MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object not callable"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not callable", mp_obj_get_type_str(self_in))); - } - } - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - if (call == MP_OBJ_SENTINEL) { - return mp_call_function_n_kw(self->subobj[0], n_args, n_kw, args); - } - - return mp_call_method_self_n_kw(member[0], member[1], n_args, n_kw, args); -} - -STATIC mp_obj_t instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t member[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = self, - .attr = MP_QSTR___iter__, - .meth_offset = offsetof(mp_obj_type_t, getiter), - .dest = member, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == MP_OBJ_NULL) { - return MP_OBJ_NULL; - } else if (member[0] == MP_OBJ_SENTINEL) { - mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); - return type->getiter(self->subobj[0], iter_buf); - } else { - return mp_call_method_n_kw(0, 0, member); - } -} - -STATIC mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t member[2] = {MP_OBJ_NULL}; - struct class_lookup_data lookup = { - .obj = self, - .attr = MP_QSTR_, // don't actually look for a method - .meth_offset = offsetof(mp_obj_type_t, buffer_p.get_buffer), - .dest = member, - .is_type = false, - }; - mp_obj_class_lookup(&lookup, self->base.type); - if (member[0] == MP_OBJ_SENTINEL) { - mp_obj_type_t *type = mp_obj_get_type(self->subobj[0]); - return type->buffer_p.get_buffer(self->subobj[0], bufinfo, flags); - } else { - return 1; // object does not support buffer protocol - } -} - -/******************************************************************************/ -// type object -// - the struct is mp_obj_type_t and is defined in obj.h so const types can be made -// - there is a constant mp_obj_type_t (called mp_type_type) for the 'type' object -// - creating a new class (a new type) creates a new mp_obj_type_t - -STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "", self->name); -} - -STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - - mp_arg_check_num(n_args, n_kw, 1, 3, false); - - switch (n_args) { - case 1: - return MP_OBJ_FROM_PTR(mp_obj_get_type(args[0])); - - case 3: - // args[0] = name - // args[1] = bases tuple - // args[2] = locals dict - return mp_obj_new_type(mp_obj_str_get_qstr(args[0]), args[1], args[2]); - - default: - mp_raise_TypeError("type takes 1 or 3 arguments"); - } -} - -STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - // instantiate an instance of a class - - mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); - - if (self->make_new == NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("cannot create instance"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "cannot create '%q' instances", self->name)); - } - } - - // make new instance - mp_obj_t o = self->make_new(self, n_args, n_kw, args); - - // return new instance - return o; -} - -STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_type)); - mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); - - if (dest[0] == MP_OBJ_NULL) { - // load attribute - #if MICROPY_CPYTHON_COMPAT - if (attr == MP_QSTR___name__) { - dest[0] = MP_OBJ_NEW_QSTR(self->name); - return; - } - #endif - struct class_lookup_data lookup = { - .obj = (mp_obj_instance_t*)self, - .attr = attr, - .meth_offset = 0, - .dest = dest, - .is_type = true, - }; - mp_obj_class_lookup(&lookup, self); - } else { - // delete/store attribute - - // TODO CPython allows STORE_ATTR to a class, but is this the correct implementation? - - if (self->locals_dict != NULL) { - assert(self->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now - mp_map_t *locals_map = &self->locals_dict->map; - if (dest[1] == MP_OBJ_NULL) { - // delete attribute - mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_REMOVE_IF_FOUND); - // note that locals_map may be in ROM, so remove will fail in that case - if (elem != NULL) { - dest[0] = MP_OBJ_NULL; // indicate success - } - } else { - // store attribute - mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - // note that locals_map may be in ROM, so add will fail in that case - if (elem != NULL) { - elem->value = dest[1]; - dest[0] = MP_OBJ_NULL; // indicate success - } - } - } - } -} - -const mp_obj_type_t mp_type_type = { - { &mp_type_type }, - .name = MP_QSTR_type, - .print = type_print, - .make_new = type_make_new, - .call = type_call, - .unary_op = mp_generic_unary_op, - .attr = type_attr, -}; - -mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) { - assert(MP_OBJ_IS_TYPE(bases_tuple, &mp_type_tuple)); // MicroPython restriction, for now - assert(MP_OBJ_IS_TYPE(locals_dict, &mp_type_dict)); // MicroPython restriction, for now - - // TODO might need to make a copy of locals_dict; at least that's how CPython does it - - // Basic validation of base classes - size_t len; - mp_obj_t *items; - mp_obj_tuple_get(bases_tuple, &len, &items); - for (size_t i = 0; i < len; i++) { - assert(MP_OBJ_IS_TYPE(items[i], &mp_type_type)); - mp_obj_type_t *t = MP_OBJ_TO_PTR(items[i]); - // TODO: Verify with CPy, tested on function type - if (t->make_new == NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("type is not an acceptable base type"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "type '%q' is not an acceptable base type", t->name)); - } - } - } - - mp_obj_type_t *o = m_new0(mp_obj_type_t, 1); - o->base.type = &mp_type_type; - o->name = name; - o->print = instance_print; - o->make_new = mp_obj_instance_make_new; - o->call = mp_obj_instance_call; - o->unary_op = instance_unary_op; - o->binary_op = instance_binary_op; - o->attr = mp_obj_instance_attr; - o->subscr = instance_subscr; - o->getiter = instance_getiter; - //o->iternext = ; not implemented - o->buffer_p.get_buffer = instance_get_buffer; - - if (len > 0) { - // Inherit protocol from a base class. This allows to define an - // abstract base class which would translate C-level protocol to - // Python method calls, and any subclass inheriting from it will - // support this feature. - o->protocol = ((mp_obj_type_t*)MP_OBJ_TO_PTR(items[0]))->protocol; - - if (len >= 2) { - o->parent = MP_OBJ_TO_PTR(bases_tuple); - } else { - o->parent = MP_OBJ_TO_PTR(items[0]); - } - } - - o->locals_dict = MP_OBJ_TO_PTR(locals_dict); - - const mp_obj_type_t *native_base; - size_t num_native_bases = instance_count_native_bases(o, &native_base); - if (num_native_bases > 1) { - mp_raise_TypeError("multiple bases have instance lay-out conflict"); - } - - mp_map_t *locals_map = &o->locals_dict->map; - mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(MP_QSTR___new__), MP_MAP_LOOKUP); - if (elem != NULL) { - // __new__ slot exists; check if it is a function - if (MP_OBJ_IS_FUN(elem->value)) { - // __new__ is a function, wrap it in a staticmethod decorator - elem->value = static_class_method_make_new(&mp_type_staticmethod, 1, 0, &elem->value); - } - } - - return MP_OBJ_FROM_PTR(o); -} - -/******************************************************************************/ -// super object - -typedef struct _mp_obj_super_t { - mp_obj_base_t base; - mp_obj_t type; - mp_obj_t obj; -} mp_obj_super_t; - -STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)kind; - mp_obj_super_t *self = MP_OBJ_TO_PTR(self_in); - mp_print_str(print, "type, PRINT_STR); - mp_print_str(print, ", "); - mp_obj_print_helper(print, self->obj, PRINT_STR); - mp_print_str(print, ">"); -} - -STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - (void)type_in; - // 0 arguments are turned into 2 in the compiler - // 1 argument is not yet implemented - mp_arg_check_num(n_args, n_kw, 2, 2, false); - mp_obj_super_t *o = m_new_obj(mp_obj_super_t); - *o = (mp_obj_super_t){{type_in}, args[0], args[1]}; - return MP_OBJ_FROM_PTR(o); -} - -STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - if (dest[0] != MP_OBJ_NULL) { - // not load attribute - return; - } - - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_super)); - mp_obj_super_t *self = MP_OBJ_TO_PTR(self_in); - - assert(MP_OBJ_IS_TYPE(self->type, &mp_type_type)); - - mp_obj_type_t *type = MP_OBJ_TO_PTR(self->type); - - struct class_lookup_data lookup = { - .obj = MP_OBJ_TO_PTR(self->obj), - .attr = attr, - .meth_offset = 0, - .dest = dest, - .is_type = false, - }; - - if (type->parent == NULL) { - // no parents, do nothing - } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) { - const mp_obj_tuple_t *parent_tuple = type->parent; - size_t len = parent_tuple->len; - const mp_obj_t *items = parent_tuple->items; - for (size_t i = 0; i < len; i++) { - assert(MP_OBJ_IS_TYPE(items[i], &mp_type_type)); - mp_obj_class_lookup(&lookup, (mp_obj_type_t*)MP_OBJ_TO_PTR(items[i])); - if (dest[0] != MP_OBJ_NULL) { - return; - } - } - } else { - mp_obj_class_lookup(&lookup, type->parent); - if (dest[0] != MP_OBJ_NULL) { - return; - } - } - - mp_obj_class_lookup(&lookup, &mp_type_object); -} - -const mp_obj_type_t mp_type_super = { - { &mp_type_type }, - .name = MP_QSTR_super, - .print = super_print, - .make_new = super_make_new, - .attr = super_attr, -}; - -void mp_load_super_method(qstr attr, mp_obj_t *dest) { - mp_obj_super_t super = {{&mp_type_super}, dest[1], dest[2]}; - mp_load_method(MP_OBJ_FROM_PTR(&super), attr, dest); -} - -/******************************************************************************/ -// subclassing and built-ins specific to types - -// object and classinfo should be type objects -// (but the function will fail gracefully if they are not) -bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) { - for (;;) { - if (object == classinfo) { - return true; - } - - // not equivalent classes, keep searching base classes - - // object should always be a type object, but just return false if it's not - if (!MP_OBJ_IS_TYPE(object, &mp_type_type)) { - return false; - } - - const mp_obj_type_t *self = MP_OBJ_TO_PTR(object); - - if (self->parent == NULL) { - // type has no parents - return false; - } else if (((mp_obj_base_t*)self->parent)->type == &mp_type_tuple) { - // get the base objects (they should be type objects) - const mp_obj_tuple_t *parent_tuple = self->parent; - const mp_obj_t *item = parent_tuple->items; - const mp_obj_t *top = item + parent_tuple->len - 1; - - // iterate through the base objects - for (; item < top; ++item) { - if (mp_obj_is_subclass_fast(*item, classinfo)) { - return true; - } - } - - // search last base (simple tail recursion elimination) - object = *item; - } else { - // type has 1 parent - object = MP_OBJ_FROM_PTR(self->parent); - } - } -} - -STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) { - size_t len; - mp_obj_t *items; - if (MP_OBJ_IS_TYPE(classinfo, &mp_type_type)) { - len = 1; - items = &classinfo; - } else if (MP_OBJ_IS_TYPE(classinfo, &mp_type_tuple)) { - mp_obj_tuple_get(classinfo, &len, &items); - } else { - mp_raise_TypeError("issubclass() arg 2 must be a class or a tuple of classes"); - } - - for (size_t i = 0; i < len; i++) { - // We explicitly check for 'object' here since no-one explicitly derives from it - if (items[i] == MP_OBJ_FROM_PTR(&mp_type_object) || mp_obj_is_subclass_fast(object, items[i])) { - return mp_const_true; - } - } - return mp_const_false; -} - -STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) { - if (!MP_OBJ_IS_TYPE(object, &mp_type_type)) { - mp_raise_TypeError("issubclass() arg 1 must be a class"); - } - return mp_obj_is_subclass(object, classinfo); -} - -MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj, mp_builtin_issubclass); - -STATIC mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) { - return mp_obj_is_subclass(MP_OBJ_FROM_PTR(mp_obj_get_type(object)), classinfo); -} - -MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_isinstance_obj, mp_builtin_isinstance); - -mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t native_type) { - mp_obj_type_t *self_type = mp_obj_get_type(self_in); - if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(self_type), native_type)) { - return MP_OBJ_NULL; - } - mp_obj_instance_t *self = (mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in); - return self->subobj[0]; -} - -/******************************************************************************/ -// staticmethod and classmethod types (probably should go in a different file) - -STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { - assert(self == &mp_type_staticmethod || self == &mp_type_classmethod); - - mp_arg_check_num(n_args, n_kw, 1, 1, false); - - mp_obj_static_class_method_t *o = m_new_obj(mp_obj_static_class_method_t); - *o = (mp_obj_static_class_method_t){{self}, args[0]}; - return MP_OBJ_FROM_PTR(o); -} - -const mp_obj_type_t mp_type_staticmethod = { - { &mp_type_type }, - .name = MP_QSTR_staticmethod, - .make_new = static_class_method_make_new, -}; - -const mp_obj_type_t mp_type_classmethod = { - { &mp_type_type }, - .name = MP_QSTR_classmethod, - .make_new = static_class_method_make_new, -}; diff --git a/user/mpy/py/objtype.h b/user/mpy/py/objtype.h deleted file mode 100644 index 52419f3..0000000 --- a/user/mpy/py/objtype.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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_OBJTYPE_H -#define MICROPY_INCLUDED_PY_OBJTYPE_H - -#include "py/obj.h" - -// instance object -// creating an instance of a class makes one of these objects -typedef struct _mp_obj_instance_t { - mp_obj_base_t base; - mp_map_t members; - mp_obj_t subobj[]; - // TODO maybe cache __getattr__ and __setattr__ for efficient lookup of them -} mp_obj_instance_t; - -// this needs to be exposed for MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE to work -void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); - -// these need to be exposed so mp_obj_is_callable can work correctly -bool mp_obj_instance_is_callable(mp_obj_t self_in); -mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - -#define mp_obj_is_instance_type(type) ((type)->make_new == mp_obj_instance_make_new) -#define mp_obj_is_native_type(type) ((type)->make_new != mp_obj_instance_make_new) -// this needs to be exposed for the above macros to work correctly -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args); - -#endif // MICROPY_INCLUDED_PY_OBJTYPE_H diff --git a/user/mpy/py/objzip.c b/user/mpy/py/objzip.c deleted file mode 100644 index 0183925..0000000 --- a/user/mpy/py/objzip.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/objtuple.h" -#include "py/runtime.h" - -typedef struct _mp_obj_zip_t { - mp_obj_base_t base; - size_t n_iters; - mp_obj_t iters[]; -} mp_obj_zip_t; - -STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); - - mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args); - o->base.type = type; - o->n_iters = n_args; - for (size_t i = 0; i < n_args; i++) { - o->iters[i] = mp_getiter(args[i], NULL); - } - return MP_OBJ_FROM_PTR(o); -} - -STATIC mp_obj_t zip_iternext(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_zip)); - mp_obj_zip_t *self = MP_OBJ_TO_PTR(self_in); - if (self->n_iters == 0) { - return MP_OBJ_STOP_ITERATION; - } - mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(self->n_iters, NULL)); - - for (size_t i = 0; i < self->n_iters; i++) { - mp_obj_t next = mp_iternext(self->iters[i]); - if (next == MP_OBJ_STOP_ITERATION) { - mp_obj_tuple_del(MP_OBJ_FROM_PTR(tuple)); - return MP_OBJ_STOP_ITERATION; - } - tuple->items[i] = next; - } - return MP_OBJ_FROM_PTR(tuple); -} - -const mp_obj_type_t mp_type_zip = { - { &mp_type_type }, - .name = MP_QSTR_zip, - .make_new = zip_make_new, - .getiter = mp_identity_getiter, - .iternext = zip_iternext, -}; diff --git a/user/mpy/py/opmethods.c b/user/mpy/py/opmethods.c deleted file mode 100644 index 1200ba3..0000000 --- a/user/mpy/py/opmethods.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -#include "py/runtime0.h" -#include "py/builtin.h" - -STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); - -STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in); -} -MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); - -STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_NULL); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); - -STATIC mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_type_t *type = mp_obj_get_type(lhs_in); - return type->binary_op(MP_BINARY_OP_IN, lhs_in, rhs_in); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_op_contains_obj, op_contains); diff --git a/user/mpy/py/parse.c b/user/mpy/py/parse.c deleted file mode 100644 index e399aac..0000000 --- a/user/mpy/py/parse.c +++ /dev/null @@ -1,1084 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2015 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. - */ - -#include -#include -#include -#include // for ssize_t -#include -#include - -#include "py/nlr.h" -#include "py/lexer.h" -#include "py/parse.h" -#include "py/parsenum.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/objint.h" -#include "py/objstr.h" -#include "py/builtin.h" - -#if MICROPY_ENABLE_COMPILER - -#define RULE_ACT_ARG_MASK (0x0f) -#define RULE_ACT_KIND_MASK (0x30) -#define RULE_ACT_ALLOW_IDENT (0x40) -#define RULE_ACT_ADD_BLANK (0x80) -#define RULE_ACT_OR (0x10) -#define RULE_ACT_AND (0x20) -#define RULE_ACT_LIST (0x30) - -#define RULE_ARG_KIND_MASK (0xf000) -#define RULE_ARG_ARG_MASK (0x0fff) -#define RULE_ARG_TOK (0x1000) -#define RULE_ARG_RULE (0x2000) -#define RULE_ARG_OPT_RULE (0x3000) - -// (un)comment to use rule names; for debugging -//#define USE_RULE_NAME (1) - -typedef struct _rule_t { - byte rule_id; - byte act; -#ifdef USE_RULE_NAME - const char *rule_name; -#endif - uint16_t arg[]; -} rule_t; - -enum { -// define rules with a compile function -#define DEF_RULE(rule, comp, kind, ...) RULE_##rule, -#define DEF_RULE_NC(rule, kind, ...) -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC - RULE_const_object, // special node for a constant, generic Python object - -// define rules without a compile function -#define DEF_RULE(rule, comp, kind, ...) -#define DEF_RULE_NC(rule, kind, ...) RULE_##rule, -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC -}; - -#define or(n) (RULE_ACT_OR | n) -#define and(n) (RULE_ACT_AND | n) -#define and_ident(n) (RULE_ACT_AND | n | RULE_ACT_ALLOW_IDENT) -#define and_blank(n) (RULE_ACT_AND | n | RULE_ACT_ADD_BLANK) -#define one_or_more (RULE_ACT_LIST | 2) -#define list (RULE_ACT_LIST | 1) -#define list_with_end (RULE_ACT_LIST | 3) -#define tok(t) (RULE_ARG_TOK | MP_TOKEN_##t) -#define rule(r) (RULE_ARG_RULE | RULE_##r) -#define opt_rule(r) (RULE_ARG_OPT_RULE | RULE_##r) -#ifdef USE_RULE_NAME -#define DEF_RULE(rule, comp, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, #rule, { __VA_ARGS__ } }; -#define DEF_RULE_NC(rule, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, #rule, { __VA_ARGS__ } }; -#else -#define DEF_RULE(rule, comp, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, { __VA_ARGS__ } }; -#define DEF_RULE_NC(rule, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, { __VA_ARGS__ } }; -#endif -#include "py/grammar.h" -#undef or -#undef and -#undef list -#undef list_with_end -#undef tok -#undef rule -#undef opt_rule -#undef one_or_more -#undef DEF_RULE -#undef DEF_RULE_NC - -STATIC const rule_t *const rules[] = { -// define rules with a compile function -#define DEF_RULE(rule, comp, kind, ...) &rule_##rule, -#define DEF_RULE_NC(rule, kind, ...) -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC - NULL, // RULE_const_object - -// define rules without a compile function -#define DEF_RULE(rule, comp, kind, ...) -#define DEF_RULE_NC(rule, kind, ...) &rule_##rule, -#include "py/grammar.h" -#undef DEF_RULE -#undef DEF_RULE_NC -}; - -typedef struct _rule_stack_t { - size_t src_line : 8 * sizeof(size_t) - 8; // maximum bits storing source line number - size_t rule_id : 8; // this must be large enough to fit largest rule number - size_t arg_i; // this dictates the maximum nodes in a "list" of things -} rule_stack_t; - -typedef struct _mp_parse_chunk_t { - size_t alloc; - union { - size_t used; - struct _mp_parse_chunk_t *next; - } union_; - byte data[]; -} mp_parse_chunk_t; - -typedef struct _parser_t { - size_t rule_stack_alloc; - size_t rule_stack_top; - rule_stack_t *rule_stack; - - size_t result_stack_alloc; - size_t result_stack_top; - mp_parse_node_t *result_stack; - - mp_lexer_t *lexer; - - mp_parse_tree_t tree; - mp_parse_chunk_t *cur_chunk; - - #if MICROPY_COMP_CONST - mp_map_t consts; - #endif -} parser_t; - -STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) { - // use a custom memory allocator to store parse nodes sequentially in large chunks - - mp_parse_chunk_t *chunk = parser->cur_chunk; - - if (chunk != NULL && chunk->union_.used + num_bytes > chunk->alloc) { - // not enough room at end of previously allocated chunk so try to grow - mp_parse_chunk_t *new_data = (mp_parse_chunk_t*)m_renew_maybe(byte, chunk, - sizeof(mp_parse_chunk_t) + chunk->alloc, - sizeof(mp_parse_chunk_t) + chunk->alloc + num_bytes, false); - if (new_data == NULL) { - // could not grow existing memory; shrink it to fit previous - (void)m_renew_maybe(byte, chunk, sizeof(mp_parse_chunk_t) + chunk->alloc, - sizeof(mp_parse_chunk_t) + chunk->union_.used, false); - chunk->alloc = chunk->union_.used; - chunk->union_.next = parser->tree.chunk; - parser->tree.chunk = chunk; - chunk = NULL; - } else { - // could grow existing memory - chunk->alloc += num_bytes; - } - } - - if (chunk == NULL) { - // no previous chunk, allocate a new chunk - size_t alloc = MICROPY_ALLOC_PARSE_CHUNK_INIT; - if (alloc < num_bytes) { - alloc = num_bytes; - } - chunk = (mp_parse_chunk_t*)m_new(byte, sizeof(mp_parse_chunk_t) + alloc); - chunk->alloc = alloc; - chunk->union_.used = 0; - parser->cur_chunk = chunk; - } - - byte *ret = chunk->data + chunk->union_.used; - chunk->union_.used += num_bytes; - return ret; -} - -STATIC void push_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t arg_i) { - if (parser->rule_stack_top >= parser->rule_stack_alloc) { - rule_stack_t *rs = m_renew(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC); - parser->rule_stack = rs; - parser->rule_stack_alloc += MICROPY_ALLOC_PARSE_RULE_INC; - } - rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++]; - rs->src_line = src_line; - rs->rule_id = rule->rule_id; - rs->arg_i = arg_i; -} - -STATIC void push_rule_from_arg(parser_t *parser, size_t arg) { - assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE); - size_t rule_id = arg & RULE_ARG_ARG_MASK; - push_rule(parser, parser->lexer->tok_line, rules[rule_id], 0); -} - -STATIC void pop_rule(parser_t *parser, const rule_t **rule, size_t *arg_i, size_t *src_line) { - parser->rule_stack_top -= 1; - *rule = rules[parser->rule_stack[parser->rule_stack_top].rule_id]; - *arg_i = parser->rule_stack[parser->rule_stack_top].arg_i; - *src_line = parser->rule_stack[parser->rule_stack_top].src_line; -} - -bool mp_parse_node_is_const_false(mp_parse_node_t pn) { - return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_FALSE) - || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) == 0); -} - -bool mp_parse_node_is_const_true(mp_parse_node_t pn) { - return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_TRUE) - || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) != 0); -} - -bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) { - if (MP_PARSE_NODE_IS_SMALL_INT(pn)) { - *o = MP_OBJ_NEW_SMALL_INT(MP_PARSE_NODE_LEAF_SMALL_INT(pn)); - return true; - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_const_object)) { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - // nodes are 32-bit pointers, but need to extract 64-bit object - *o = (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32); - #else - *o = (mp_obj_t)pns->nodes[0]; - #endif - return MP_OBJ_IS_INT(*o); - } else { - return false; - } -} - -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes) { - if (MP_PARSE_NODE_IS_NULL(*pn)) { - *nodes = NULL; - return 0; - } else if (MP_PARSE_NODE_IS_LEAF(*pn)) { - *nodes = pn; - return 1; - } else { - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)(*pn); - if (MP_PARSE_NODE_STRUCT_KIND(pns) != pn_kind) { - *nodes = pn; - return 1; - } else { - *nodes = pns->nodes; - return MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - } - } -} - -#if MICROPY_DEBUG_PRINTERS -void mp_parse_node_print(mp_parse_node_t pn, size_t indent) { - if (MP_PARSE_NODE_IS_STRUCT(pn)) { - printf("[% 4d] ", (int)((mp_parse_node_struct_t*)pn)->source_line); - } else { - printf(" "); - } - for (size_t i = 0; i < indent; i++) { - printf(" "); - } - if (MP_PARSE_NODE_IS_NULL(pn)) { - printf("NULL\n"); - } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) { - mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn); - printf("int(" INT_FMT ")\n", arg); - } else if (MP_PARSE_NODE_IS_LEAF(pn)) { - uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn); - switch (MP_PARSE_NODE_LEAF_KIND(pn)) { - case MP_PARSE_NODE_ID: printf("id(%s)\n", qstr_str(arg)); break; - case MP_PARSE_NODE_STRING: printf("str(%s)\n", qstr_str(arg)); break; - case MP_PARSE_NODE_BYTES: printf("bytes(%s)\n", qstr_str(arg)); break; - default: - assert(MP_PARSE_NODE_LEAF_KIND(pn) == MP_PARSE_NODE_TOKEN); - printf("tok(%u)\n", (uint)arg); break; - } - } else { - // node must be a mp_parse_node_struct_t - mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; - if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_const_object) { - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - printf("literal const(%016llx)\n", (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32)); - #else - printf("literal const(%p)\n", (mp_obj_t)pns->nodes[0]); - #endif - } else { - size_t n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); -#ifdef USE_RULE_NAME - printf("%s(%u) (n=%u)\n", rules[MP_PARSE_NODE_STRUCT_KIND(pns)]->rule_name, (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n); -#else - printf("rule(%u) (n=%u)\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n); -#endif - for (size_t i = 0; i < n; i++) { - mp_parse_node_print(pns->nodes[i], indent + 2); - } - } - } -} -#endif // MICROPY_DEBUG_PRINTERS - -/* -STATIC void result_stack_show(parser_t *parser) { - printf("result stack, most recent first\n"); - for (ssize_t i = parser->result_stack_top - 1; i >= 0; i--) { - mp_parse_node_print(parser->result_stack[i], 0); - } -} -*/ - -STATIC mp_parse_node_t pop_result(parser_t *parser) { - assert(parser->result_stack_top > 0); - return parser->result_stack[--parser->result_stack_top]; -} - -STATIC mp_parse_node_t peek_result(parser_t *parser, size_t pos) { - assert(parser->result_stack_top > pos); - return parser->result_stack[parser->result_stack_top - 1 - pos]; -} - -STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) { - if (parser->result_stack_top >= parser->result_stack_alloc) { - mp_parse_node_t *stack = m_renew(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC); - parser->result_stack = stack; - parser->result_stack_alloc += MICROPY_ALLOC_PARSE_RESULT_INC; - } - parser->result_stack[parser->result_stack_top++] = pn; -} - -STATIC mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) { - mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_obj_t)); - pn->source_line = src_line; - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - // nodes are 32-bit pointers, but need to store 64-bit object - pn->kind_num_nodes = RULE_const_object | (2 << 8); - pn->nodes[0] = (uint64_t)obj; - pn->nodes[1] = (uint64_t)obj >> 32; - #else - pn->kind_num_nodes = RULE_const_object | (1 << 8); - pn->nodes[0] = (uintptr_t)obj; - #endif - return (mp_parse_node_t)pn; -} - -STATIC void push_result_token(parser_t *parser, const rule_t *rule) { - mp_parse_node_t pn; - mp_lexer_t *lex = parser->lexer; - if (lex->tok_kind == MP_TOKEN_NAME) { - qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len); - #if MICROPY_COMP_CONST - // if name is a standalone identifier, look it up in the table of dynamic constants - mp_map_elem_t *elem; - if (rule->rule_id == RULE_atom - && (elem = mp_map_lookup(&parser->consts, MP_OBJ_NEW_QSTR(id), MP_MAP_LOOKUP)) != NULL) { - if (MP_OBJ_IS_SMALL_INT(elem->value)) { - pn = mp_parse_node_new_small_int(MP_OBJ_SMALL_INT_VALUE(elem->value)); - } else { - pn = make_node_const_object(parser, lex->tok_line, elem->value); - } - } else { - pn = mp_parse_node_new_leaf(MP_PARSE_NODE_ID, id); - } - #else - (void)rule; - pn = mp_parse_node_new_leaf(MP_PARSE_NODE_ID, id); - #endif - } else if (lex->tok_kind == MP_TOKEN_INTEGER) { - mp_obj_t o = mp_parse_num_integer(lex->vstr.buf, lex->vstr.len, 0, lex); - if (MP_OBJ_IS_SMALL_INT(o)) { - pn = mp_parse_node_new_small_int(MP_OBJ_SMALL_INT_VALUE(o)); - } else { - pn = make_node_const_object(parser, lex->tok_line, o); - } - } else if (lex->tok_kind == MP_TOKEN_FLOAT_OR_IMAG) { - mp_obj_t o = mp_parse_num_decimal(lex->vstr.buf, lex->vstr.len, true, false, lex); - pn = make_node_const_object(parser, lex->tok_line, o); - } else if (lex->tok_kind == MP_TOKEN_STRING || lex->tok_kind == MP_TOKEN_BYTES) { - // Don't automatically intern all strings/bytes. doc strings (which are usually large) - // will be discarded by the compiler, and so we shouldn't intern them. - qstr qst = MP_QSTR_NULL; - if (lex->vstr.len <= MICROPY_ALLOC_PARSE_INTERN_STRING_LEN) { - // intern short strings - qst = qstr_from_strn(lex->vstr.buf, lex->vstr.len); - } else { - // check if this string is already interned - qst = qstr_find_strn(lex->vstr.buf, lex->vstr.len); - } - if (qst != MP_QSTR_NULL) { - // qstr exists, make a leaf node - pn = mp_parse_node_new_leaf(lex->tok_kind == MP_TOKEN_STRING ? MP_PARSE_NODE_STRING : MP_PARSE_NODE_BYTES, qst); - } else { - // not interned, make a node holding a pointer to the string/bytes object - mp_obj_t o = mp_obj_new_str_of_type( - lex->tok_kind == MP_TOKEN_STRING ? &mp_type_str : &mp_type_bytes, - (const byte*)lex->vstr.buf, lex->vstr.len); - pn = make_node_const_object(parser, lex->tok_line, o); - } - } else { - pn = mp_parse_node_new_leaf(MP_PARSE_NODE_TOKEN, lex->tok_kind); - } - push_result_node(parser, pn); -} - -#if MICROPY_COMP_MODULE_CONST -STATIC const mp_rom_map_elem_t mp_constants_table[] = { - #if MICROPY_PY_UERRNO - { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, - #endif - #if MICROPY_PY_UCTYPES - { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, - #endif - // Extra constants as defined by a port - MICROPY_PORT_CONSTANTS -}; -STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table); -#endif - -STATIC void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args); - -#if MICROPY_COMP_CONST_FOLDING -STATIC bool fold_logical_constants(parser_t *parser, const rule_t *rule, size_t *num_args) { - if (rule->rule_id == RULE_or_test - || rule->rule_id == RULE_and_test) { - // folding for binary logical ops: or and - size_t copy_to = *num_args; - for (size_t i = copy_to; i > 0;) { - mp_parse_node_t pn = peek_result(parser, --i); - parser->result_stack[parser->result_stack_top - copy_to] = pn; - if (i == 0) { - // always need to keep the last value - break; - } - if (rule->rule_id == RULE_or_test) { - if (mp_parse_node_is_const_true(pn)) { - // - break; - } else if (!mp_parse_node_is_const_false(pn)) { - copy_to -= 1; - } - } else { - // RULE_and_test - if (mp_parse_node_is_const_false(pn)) { - break; - } else if (!mp_parse_node_is_const_true(pn)) { - copy_to -= 1; - } - } - } - copy_to -= 1; // copy_to now contains number of args to pop - - // pop and discard all the short-circuited expressions - for (size_t i = 0; i < copy_to; ++i) { - pop_result(parser); - } - *num_args -= copy_to; - - // we did a complete folding if there's only 1 arg left - return *num_args == 1; - - } else if (rule->rule_id == RULE_not_test_2) { - // folding for unary logical op: not - mp_parse_node_t pn = peek_result(parser, 0); - if (mp_parse_node_is_const_false(pn)) { - pn = mp_parse_node_new_leaf(MP_PARSE_NODE_TOKEN, MP_TOKEN_KW_TRUE); - } else if (mp_parse_node_is_const_true(pn)) { - pn = mp_parse_node_new_leaf(MP_PARSE_NODE_TOKEN, MP_TOKEN_KW_FALSE); - } else { - return false; - } - pop_result(parser); - push_result_node(parser, pn); - return true; - } - - return false; -} - -STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args) { - // this code does folding of arbitrary integer expressions, eg 1 + 2 * 3 + 4 - // it does not do partial folding, eg 1 + 2 + x -> 3 + x - - mp_obj_t arg0; - if (rule->rule_id == RULE_expr - || rule->rule_id == RULE_xor_expr - || rule->rule_id == RULE_and_expr) { - // folding for binary ops: | ^ & - mp_parse_node_t pn = peek_result(parser, num_args - 1); - if (!mp_parse_node_get_int_maybe(pn, &arg0)) { - return false; - } - mp_binary_op_t op; - if (rule->rule_id == RULE_expr) { - op = MP_BINARY_OP_OR; - } else if (rule->rule_id == RULE_xor_expr) { - op = MP_BINARY_OP_XOR; - } else { - op = MP_BINARY_OP_AND; - } - for (ssize_t i = num_args - 2; i >= 0; --i) { - pn = peek_result(parser, i); - mp_obj_t arg1; - if (!mp_parse_node_get_int_maybe(pn, &arg1)) { - return false; - } - arg0 = mp_binary_op(op, arg0, arg1); - } - } else if (rule->rule_id == RULE_shift_expr - || rule->rule_id == RULE_arith_expr - || rule->rule_id == RULE_term) { - // folding for binary ops: << >> + - * / % // - mp_parse_node_t pn = peek_result(parser, num_args - 1); - if (!mp_parse_node_get_int_maybe(pn, &arg0)) { - return false; - } - for (ssize_t i = num_args - 2; i >= 1; i -= 2) { - pn = peek_result(parser, i - 1); - mp_obj_t arg1; - if (!mp_parse_node_get_int_maybe(pn, &arg1)) { - return false; - } - mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(peek_result(parser, i)); - static const uint8_t token_to_op[] = { - MP_BINARY_OP_ADD, - MP_BINARY_OP_SUBTRACT, - MP_BINARY_OP_MULTIPLY, - 255,//MP_BINARY_OP_POWER, - 255,//MP_BINARY_OP_TRUE_DIVIDE, - MP_BINARY_OP_FLOOR_DIVIDE, - MP_BINARY_OP_MODULO, - 255,//MP_BINARY_OP_LESS - MP_BINARY_OP_LSHIFT, - 255,//MP_BINARY_OP_MORE - MP_BINARY_OP_RSHIFT, - }; - mp_binary_op_t op = token_to_op[tok - MP_TOKEN_OP_PLUS]; - if (op == (mp_binary_op_t)255) { - return false; - } - int rhs_sign = mp_obj_int_sign(arg1); - if (op <= MP_BINARY_OP_RSHIFT) { - // << and >> can't have negative rhs - if (rhs_sign < 0) { - return false; - } - } else if (op >= MP_BINARY_OP_FLOOR_DIVIDE) { - // % and // can't have zero rhs - if (rhs_sign == 0) { - return false; - } - } - arg0 = mp_binary_op(op, arg0, arg1); - } - } else if (rule->rule_id == RULE_factor_2) { - // folding for unary ops: + - ~ - mp_parse_node_t pn = peek_result(parser, 0); - if (!mp_parse_node_get_int_maybe(pn, &arg0)) { - return false; - } - mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(peek_result(parser, 1)); - mp_unary_op_t op; - if (tok == MP_TOKEN_OP_PLUS) { - op = MP_UNARY_OP_POSITIVE; - } else if (tok == MP_TOKEN_OP_MINUS) { - op = MP_UNARY_OP_NEGATIVE; - } else { - assert(tok == MP_TOKEN_OP_TILDE); // should be - op = MP_UNARY_OP_INVERT; - } - arg0 = mp_unary_op(op, arg0); - - #if MICROPY_COMP_CONST - } else if (rule->rule_id == RULE_expr_stmt) { - mp_parse_node_t pn1 = peek_result(parser, 0); - if (!MP_PARSE_NODE_IS_NULL(pn1) - && !(MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_augassign) - || MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_assign_list))) { - // this node is of the form = - mp_parse_node_t pn0 = peek_result(parser, 1); - if (MP_PARSE_NODE_IS_ID(pn0) - && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_atom_expr_normal) - && MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t*)pn1)->nodes[0]) - && MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn1)->nodes[0]) == MP_QSTR_const - && MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t*)pn1)->nodes[1], RULE_trailer_paren) - ) { - // code to assign dynamic constants: id = const(value) - - // get the id - qstr id = MP_PARSE_NODE_LEAF_ARG(pn0); - - // get the value - mp_parse_node_t pn_value = ((mp_parse_node_struct_t*)((mp_parse_node_struct_t*)pn1)->nodes[1])->nodes[0]; - mp_obj_t value; - if (!mp_parse_node_get_int_maybe(pn_value, &value)) { - mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - "constant must be an integer"); - mp_obj_exception_add_traceback(exc, parser->lexer->source_name, - ((mp_parse_node_struct_t*)pn1)->source_line, MP_QSTR_NULL); - nlr_raise(exc); - } - - // store the value in the table of dynamic constants - mp_map_elem_t *elem = mp_map_lookup(&parser->consts, MP_OBJ_NEW_QSTR(id), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); - assert(elem->value == MP_OBJ_NULL); - elem->value = value; - - // If the constant starts with an underscore then treat it as a private - // variable and don't emit any code to store the value to the id. - if (qstr_str(id)[0] == '_') { - pop_result(parser); // pop const(value) - pop_result(parser); // pop id - push_result_rule(parser, 0, rules[RULE_pass_stmt], 0); // replace with "pass" - return true; - } - - // replace const(value) with value - pop_result(parser); - push_result_node(parser, pn_value); - - // finished folding this assignment, but we still want it to be part of the tree - return false; - } - } - return false; - #endif - - #if MICROPY_COMP_MODULE_CONST - } else if (rule->rule_id == RULE_atom_expr_normal) { - mp_parse_node_t pn0 = peek_result(parser, 1); - mp_parse_node_t pn1 = peek_result(parser, 0); - if (!(MP_PARSE_NODE_IS_ID(pn0) - && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period))) { - return false; - } - // id1.id2 - // look it up in constant table, see if it can be replaced with an integer - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pn1; - assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); - qstr q_base = MP_PARSE_NODE_LEAF_ARG(pn0); - qstr q_attr = MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0]); - mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&mp_constants_map, MP_OBJ_NEW_QSTR(q_base), MP_MAP_LOOKUP); - if (elem == NULL) { - return false; - } - mp_obj_t dest[2]; - mp_load_method_maybe(elem->value, q_attr, dest); - if (!(dest[0] != MP_OBJ_NULL && MP_OBJ_IS_INT(dest[0]) && dest[1] == MP_OBJ_NULL)) { - return false; - } - arg0 = dest[0]; - #endif - - } else { - return false; - } - - // success folding this rule - - for (size_t i = num_args; i > 0; i--) { - pop_result(parser); - } - if (MP_OBJ_IS_SMALL_INT(arg0)) { - push_result_node(parser, mp_parse_node_new_small_int(MP_OBJ_SMALL_INT_VALUE(arg0))); - } else { - // TODO reuse memory for parse node struct? - push_result_node(parser, make_node_const_object(parser, 0, arg0)); - } - - return true; -} -#endif - -STATIC void push_result_rule(parser_t *parser, size_t src_line, const rule_t *rule, size_t num_args) { - // optimise away parenthesis around an expression if possible - if (rule->rule_id == RULE_atom_paren) { - // there should be just 1 arg for this rule - mp_parse_node_t pn = peek_result(parser, 0); - if (MP_PARSE_NODE_IS_NULL(pn)) { - // need to keep parenthesis for () - } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_testlist_comp)) { - // need to keep parenthesis for (a, b, ...) - } else { - // parenthesis around a single expression, so it's just the expression - return; - } - } - - #if MICROPY_COMP_CONST_FOLDING - if (fold_logical_constants(parser, rule, &num_args)) { - // we folded this rule so return straight away - return; - } - if (fold_constants(parser, rule, num_args)) { - // we folded this rule so return straight away - return; - } - #endif - - mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * num_args); - pn->source_line = src_line; - pn->kind_num_nodes = (rule->rule_id & 0xff) | (num_args << 8); - for (size_t i = num_args; i > 0; i--) { - pn->nodes[i - 1] = pop_result(parser); - } - push_result_node(parser, (mp_parse_node_t)pn); -} - -mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { - - // initialise parser and allocate memory for its stacks - - parser_t parser; - - parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT; - parser.rule_stack_top = 0; - parser.rule_stack = m_new(rule_stack_t, parser.rule_stack_alloc); - - parser.result_stack_alloc = MICROPY_ALLOC_PARSE_RESULT_INIT; - parser.result_stack_top = 0; - parser.result_stack = m_new(mp_parse_node_t, parser.result_stack_alloc); - - parser.lexer = lex; - - parser.tree.chunk = NULL; - parser.cur_chunk = NULL; - - #if MICROPY_COMP_CONST - mp_map_init(&parser.consts, 0); - #endif - - // work out the top-level rule to use, and push it on the stack - size_t top_level_rule; - switch (input_kind) { - case MP_PARSE_SINGLE_INPUT: top_level_rule = RULE_single_input; break; - case MP_PARSE_EVAL_INPUT: top_level_rule = RULE_eval_input; break; - default: top_level_rule = RULE_file_input; - } - push_rule(&parser, lex->tok_line, rules[top_level_rule], 0); - - // parse! - - size_t n, i; // state for the current rule - size_t rule_src_line; // source line for the first token matched by the current rule - bool backtrack = false; - const rule_t *rule = NULL; - - for (;;) { - next_rule: - if (parser.rule_stack_top == 0) { - break; - } - - pop_rule(&parser, &rule, &i, &rule_src_line); - n = rule->act & RULE_ACT_ARG_MASK; - - /* - // debugging - printf("depth=%d ", parser.rule_stack_top); - for (int j = 0; j < parser.rule_stack_top; ++j) { - printf(" "); - } - printf("%s n=%d i=%d bt=%d\n", rule->rule_name, n, i, backtrack); - */ - - switch (rule->act & RULE_ACT_KIND_MASK) { - case RULE_ACT_OR: - if (i > 0 && !backtrack) { - goto next_rule; - } else { - backtrack = false; - } - for (; i < n; ++i) { - uint16_t kind = rule->arg[i] & RULE_ARG_KIND_MASK; - if (kind == RULE_ARG_TOK) { - if (lex->tok_kind == (rule->arg[i] & RULE_ARG_ARG_MASK)) { - push_result_token(&parser, rule); - mp_lexer_to_next(lex); - goto next_rule; - } - } else { - assert(kind == RULE_ARG_RULE); - if (i + 1 < n) { - push_rule(&parser, rule_src_line, rule, i + 1); // save this or-rule - } - push_rule_from_arg(&parser, rule->arg[i]); // push child of or-rule - goto next_rule; - } - } - backtrack = true; - break; - - case RULE_ACT_AND: { - - // failed, backtrack if we can, else syntax error - if (backtrack) { - assert(i > 0); - if ((rule->arg[i - 1] & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE) { - // an optional rule that failed, so continue with next arg - push_result_node(&parser, MP_PARSE_NODE_NULL); - backtrack = false; - } else { - // a mandatory rule that failed, so propagate backtrack - if (i > 1) { - // already eaten tokens so can't backtrack - goto syntax_error; - } else { - goto next_rule; - } - } - } - - // progress through the rule - for (; i < n; ++i) { - if ((rule->arg[i] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { - // need to match a token - mp_token_kind_t tok_kind = rule->arg[i] & RULE_ARG_ARG_MASK; - if (lex->tok_kind == tok_kind) { - // matched token - if (tok_kind == MP_TOKEN_NAME) { - push_result_token(&parser, rule); - } - mp_lexer_to_next(lex); - } else { - // failed to match token - if (i > 0) { - // already eaten tokens so can't backtrack - goto syntax_error; - } else { - // this rule failed, so backtrack - backtrack = true; - goto next_rule; - } - } - } else { - push_rule(&parser, rule_src_line, rule, i + 1); // save this and-rule - push_rule_from_arg(&parser, rule->arg[i]); // push child of and-rule - goto next_rule; - } - } - - assert(i == n); - - // matched the rule, so now build the corresponding parse_node - - #if !MICROPY_ENABLE_DOC_STRING - // this code discards lonely statements, such as doc strings - if (input_kind != MP_PARSE_SINGLE_INPUT && rule->rule_id == RULE_expr_stmt && peek_result(&parser, 0) == MP_PARSE_NODE_NULL) { - mp_parse_node_t p = peek_result(&parser, 1); - if ((MP_PARSE_NODE_IS_LEAF(p) && !MP_PARSE_NODE_IS_ID(p)) - || MP_PARSE_NODE_IS_STRUCT_KIND(p, RULE_const_object)) { - pop_result(&parser); // MP_PARSE_NODE_NULL - pop_result(&parser); // const expression (leaf or RULE_const_object) - // Pushing the "pass" rule here will overwrite any RULE_const_object - // entry that was on the result stack, allowing the GC to reclaim - // the memory from the const object when needed. - push_result_rule(&parser, rule_src_line, rules[RULE_pass_stmt], 0); - break; - } - } - #endif - - // count number of arguments for the parse node - i = 0; - size_t num_not_nil = 0; - for (size_t x = n; x > 0;) { - --x; - if ((rule->arg[x] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { - mp_token_kind_t tok_kind = rule->arg[x] & RULE_ARG_ARG_MASK; - if (tok_kind == MP_TOKEN_NAME) { - // only tokens which were names are pushed to stack - i += 1; - num_not_nil += 1; - } - } else { - // rules are always pushed - if (peek_result(&parser, i) != MP_PARSE_NODE_NULL) { - num_not_nil += 1; - } - i += 1; - } - } - - if (num_not_nil == 1 && (rule->act & RULE_ACT_ALLOW_IDENT)) { - // this rule has only 1 argument and should not be emitted - mp_parse_node_t pn = MP_PARSE_NODE_NULL; - for (size_t x = 0; x < i; ++x) { - mp_parse_node_t pn2 = pop_result(&parser); - if (pn2 != MP_PARSE_NODE_NULL) { - pn = pn2; - } - } - push_result_node(&parser, pn); - } else { - // this rule must be emitted - - if (rule->act & RULE_ACT_ADD_BLANK) { - // and add an extra blank node at the end (used by the compiler to store data) - push_result_node(&parser, MP_PARSE_NODE_NULL); - i += 1; - } - - push_result_rule(&parser, rule_src_line, rule, i); - } - break; - } - - default: { - assert((rule->act & RULE_ACT_KIND_MASK) == RULE_ACT_LIST); - - // n=2 is: item item* - // n=1 is: item (sep item)* - // n=3 is: item (sep item)* [sep] - bool had_trailing_sep; - if (backtrack) { - list_backtrack: - had_trailing_sep = false; - if (n == 2) { - if (i == 1) { - // fail on item, first time round; propagate backtrack - goto next_rule; - } else { - // fail on item, in later rounds; finish with this rule - backtrack = false; - } - } else { - if (i == 1) { - // fail on item, first time round; propagate backtrack - goto next_rule; - } else if ((i & 1) == 1) { - // fail on item, in later rounds; have eaten tokens so can't backtrack - if (n == 3) { - // list allows trailing separator; finish parsing list - had_trailing_sep = true; - backtrack = false; - } else { - // list doesn't allowing trailing separator; fail - goto syntax_error; - } - } else { - // fail on separator; finish parsing list - backtrack = false; - } - } - } else { - for (;;) { - size_t arg = rule->arg[i & 1 & n]; - if ((arg & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { - if (lex->tok_kind == (arg & RULE_ARG_ARG_MASK)) { - if (i & 1 & n) { - // separators which are tokens are not pushed to result stack - } else { - push_result_token(&parser, rule); - } - mp_lexer_to_next(lex); - // got element of list, so continue parsing list - i += 1; - } else { - // couldn't get element of list - i += 1; - backtrack = true; - goto list_backtrack; - } - } else { - assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE); - push_rule(&parser, rule_src_line, rule, i + 1); // save this list-rule - push_rule_from_arg(&parser, arg); // push child of list-rule - goto next_rule; - } - } - } - assert(i >= 1); - - // compute number of elements in list, result in i - i -= 1; - if ((n & 1) && (rule->arg[1] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { - // don't count separators when they are tokens - i = (i + 1) / 2; - } - - if (i == 1) { - // list matched single item - if (had_trailing_sep) { - // if there was a trailing separator, make a list of a single item - push_result_rule(&parser, rule_src_line, rule, i); - } else { - // just leave single item on stack (ie don't wrap in a list) - } - } else { - push_result_rule(&parser, rule_src_line, rule, i); - } - break; - } - } - } - - #if MICROPY_COMP_CONST - mp_map_deinit(&parser.consts); - #endif - - // truncate final chunk and link into chain of chunks - if (parser.cur_chunk != NULL) { - (void)m_renew_maybe(byte, parser.cur_chunk, - sizeof(mp_parse_chunk_t) + parser.cur_chunk->alloc, - sizeof(mp_parse_chunk_t) + parser.cur_chunk->union_.used, - false); - parser.cur_chunk->alloc = parser.cur_chunk->union_.used; - parser.cur_chunk->union_.next = parser.tree.chunk; - parser.tree.chunk = parser.cur_chunk; - } - - if ( - lex->tok_kind != MP_TOKEN_END // check we are at the end of the token stream - || parser.result_stack_top == 0 // check that we got a node (can fail on empty input) - ) { - syntax_error:; - mp_obj_t exc; - if (lex->tok_kind == MP_TOKEN_INDENT) { - exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - "unexpected indent"); - } else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) { - exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - "unindent does not match any outer indentation level"); - } else { - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - "invalid syntax"); - } - // add traceback to give info about file name and location - // we don't have a 'block' name, so just pass the NULL qstr to indicate this - mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); - nlr_raise(exc); - } - - // get the root parse node that we created - assert(parser.result_stack_top == 1); - parser.tree.root = parser.result_stack[0]; - - // free the memory that we don't need anymore - m_del(rule_stack_t, parser.rule_stack, parser.rule_stack_alloc); - m_del(mp_parse_node_t, parser.result_stack, parser.result_stack_alloc); - - // we also free the lexer on behalf of the caller - mp_lexer_free(lex); - - return parser.tree; -} - -void mp_parse_tree_clear(mp_parse_tree_t *tree) { - mp_parse_chunk_t *chunk = tree->chunk; - while (chunk != NULL) { - mp_parse_chunk_t *next = chunk->union_.next; - m_del(byte, chunk, sizeof(mp_parse_chunk_t) + chunk->alloc); - chunk = next; - } -} - -#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/parse.h b/user/mpy/py/parse.h deleted file mode 100644 index 9a1a2b4..0000000 --- a/user/mpy/py/parse.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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_PARSE_H -#define MICROPY_INCLUDED_PY_PARSE_H - -#include -#include - -#include "py/obj.h" - -struct _mp_lexer_t; - -// a mp_parse_node_t is: -// - 0000...0000: no node -// - xxxx...xxx1: a small integer; bits 1 and above are the signed value, 2's complement -// - xxxx...xx00: pointer to mp_parse_node_struct_t -// - xx...xx0010: an identifier; bits 4 and above are the qstr -// - xx...xx0110: a string; bits 4 and above are the qstr holding the value -// - xx...xx1010: a string of bytes; bits 4 and above are the qstr holding the value -// - xx...xx1110: a token; bits 4 and above are mp_token_kind_t - -#define MP_PARSE_NODE_NULL (0) -#define MP_PARSE_NODE_SMALL_INT (0x1) -#define MP_PARSE_NODE_ID (0x02) -#define MP_PARSE_NODE_STRING (0x06) -#define MP_PARSE_NODE_BYTES (0x0a) -#define MP_PARSE_NODE_TOKEN (0x0e) - -typedef uintptr_t mp_parse_node_t; // must be pointer size - -typedef struct _mp_parse_node_struct_t { - uint32_t source_line; // line number in source file - uint32_t kind_num_nodes; // parse node kind, and number of nodes - mp_parse_node_t nodes[]; // nodes -} mp_parse_node_struct_t; - -// macros for mp_parse_node_t usage -// some of these evaluate their argument more than once - -#define MP_PARSE_NODE_IS_NULL(pn) ((pn) == MP_PARSE_NODE_NULL) -#define MP_PARSE_NODE_IS_LEAF(pn) ((pn) & 3) -#define MP_PARSE_NODE_IS_STRUCT(pn) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0) -#define MP_PARSE_NODE_IS_STRUCT_KIND(pn, k) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0 && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)(pn)) == (k)) - -#define MP_PARSE_NODE_IS_SMALL_INT(pn) (((pn) & 0x1) == MP_PARSE_NODE_SMALL_INT) -#define MP_PARSE_NODE_IS_ID(pn) (((pn) & 0x0f) == MP_PARSE_NODE_ID) -#define MP_PARSE_NODE_IS_TOKEN(pn) (((pn) & 0x0f) == MP_PARSE_NODE_TOKEN) -#define MP_PARSE_NODE_IS_TOKEN_KIND(pn, k) ((pn) == (MP_PARSE_NODE_TOKEN | ((k) << 4))) - -#define MP_PARSE_NODE_LEAF_KIND(pn) ((pn) & 0x0f) -#define MP_PARSE_NODE_LEAF_ARG(pn) (((uintptr_t)(pn)) >> 4) -#define MP_PARSE_NODE_LEAF_SMALL_INT(pn) (((mp_int_t)(intptr_t)(pn)) >> 1) -#define MP_PARSE_NODE_STRUCT_KIND(pns) ((pns)->kind_num_nodes & 0xff) -#define MP_PARSE_NODE_STRUCT_NUM_NODES(pns) ((pns)->kind_num_nodes >> 8) - -static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) { - return (mp_parse_node_t)(MP_PARSE_NODE_SMALL_INT | ((mp_uint_t)val << 1)); -} -static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) { - return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4)); -} -bool mp_parse_node_is_const_false(mp_parse_node_t pn); -bool mp_parse_node_is_const_true(mp_parse_node_t pn); -bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o); -int mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes); -void mp_parse_node_print(mp_parse_node_t pn, size_t indent); - -typedef enum { - MP_PARSE_SINGLE_INPUT, - MP_PARSE_FILE_INPUT, - MP_PARSE_EVAL_INPUT, -} mp_parse_input_kind_t; - -typedef struct _mp_parse_t { - mp_parse_node_t root; - struct _mp_parse_chunk_t *chunk; -} mp_parse_tree_t; - -// the parser will raise an exception if an error occurred -// the parser will free the lexer before it returns -mp_parse_tree_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind); -void mp_parse_tree_clear(mp_parse_tree_t *tree); - -#endif // MICROPY_INCLUDED_PY_PARSE_H diff --git a/user/mpy/py/parsenum.c b/user/mpy/py/parsenum.c deleted file mode 100644 index b62029f..0000000 --- a/user/mpy/py/parsenum.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/runtime.h" -#include "py/parsenumbase.h" -#include "py/parsenum.h" -#include "py/smallint.h" - -#if MICROPY_PY_BUILTINS_FLOAT -#include -#endif - -STATIC NORETURN void raise_exc(mp_obj_t exc, mp_lexer_t *lex) { - // if lex!=NULL then the parser called us and we need to convert the - // exception's type from ValueError to SyntaxError and add traceback info - if (lex != NULL) { - ((mp_obj_base_t*)MP_OBJ_TO_PTR(exc))->type = &mp_type_SyntaxError; - mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL); - } - nlr_raise(exc); -} - -mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, mp_lexer_t *lex) { - const byte *restrict str = (const byte *)str_; - const byte *restrict top = str + len; - bool neg = false; - mp_obj_t ret_val; - - // check radix base - if ((base != 0 && base < 2) || base > 36) { - // this won't be reached if lex!=NULL - mp_raise_ValueError("int() arg 2 must be >= 2 and <= 36"); - } - - // skip leading space - for (; str < top && unichar_isspace(*str); str++) { - } - - // parse optional sign - if (str < top) { - if (*str == '+') { - str++; - } else if (*str == '-') { - str++; - neg = true; - } - } - - // parse optional base prefix - str += mp_parse_num_base((const char*)str, top - str, &base); - - // string should be an integer number - mp_int_t int_val = 0; - const byte *restrict str_val_start = str; - for (; str < top; str++) { - // get next digit as a value - mp_uint_t dig = *str; - if ('0' <= dig && dig <= '9') { - dig -= '0'; - } else { - dig |= 0x20; // make digit lower-case - if ('a' <= dig && dig <= 'z') { - dig -= 'a' - 10; - } else { - // unknown character - break; - } - } - if (dig >= (mp_uint_t)base) { - break; - } - - // add next digi and check for overflow - if (mp_small_int_mul_overflow(int_val, base)) { - goto overflow; - } - int_val = int_val * base + dig; - if (!MP_SMALL_INT_FITS(int_val)) { - goto overflow; - } - } - - // negate value if needed - if (neg) { - int_val = -int_val; - } - - // create the small int - ret_val = MP_OBJ_NEW_SMALL_INT(int_val); - -have_ret_val: - // check we parsed something - if (str == str_val_start) { - goto value_error; - } - - // skip trailing space - for (; str < top && unichar_isspace(*str); str++) { - } - - // check we reached the end of the string - if (str != top) { - goto value_error; - } - - // return the object - return ret_val; - -overflow: - // reparse using long int - { - const char *s2 = (const char*)str_val_start; - ret_val = mp_obj_new_int_from_str_len(&s2, top - str_val_start, neg, base); - str = (const byte*)s2; - goto have_ret_val; - } - -value_error: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_ValueError, - "invalid syntax for integer"); - raise_exc(exc, lex); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { - mp_obj_t exc = mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "invalid syntax for integer with base %d", base); - raise_exc(exc, lex); - } else { - vstr_t vstr; - mp_print_t print; - vstr_init_print(&vstr, 50, &print); - mp_printf(&print, "invalid syntax for integer with base %d: ", base); - mp_str_print_quoted(&print, str_val_start, top - str_val_start, true); - mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_ValueError, - mp_obj_new_str_from_vstr(&mp_type_str, &vstr)); - raise_exc(exc, lex); - } -} - -typedef enum { - PARSE_DEC_IN_INTG, - PARSE_DEC_IN_FRAC, - PARSE_DEC_IN_EXP, -} parse_dec_in_t; - -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool force_complex, mp_lexer_t *lex) { -#if MICROPY_PY_BUILTINS_FLOAT - const char *top = str + len; - mp_float_t dec_val = 0; - bool dec_neg = false; - bool imag = false; - - // skip leading space - for (; str < top && unichar_isspace(*str); str++) { - } - - // parse optional sign - if (str < top) { - if (*str == '+') { - str++; - } else if (*str == '-') { - str++; - dec_neg = true; - } - } - - const char *str_val_start = str; - - // determine what the string is - if (str < top && (str[0] | 0x20) == 'i') { - // string starts with 'i', should be 'inf' or 'infinity' (case insensitive) - if (str + 2 < top && (str[1] | 0x20) == 'n' && (str[2] | 0x20) == 'f') { - // inf - str += 3; - dec_val = INFINITY; - if (str + 4 < top && (str[0] | 0x20) == 'i' && (str[1] | 0x20) == 'n' && (str[2] | 0x20) == 'i' && (str[3] | 0x20) == 't' && (str[4] | 0x20) == 'y') { - // infinity - str += 5; - } - } - } else if (str < top && (str[0] | 0x20) == 'n') { - // string starts with 'n', should be 'nan' (case insensitive) - if (str + 2 < top && (str[1] | 0x20) == 'a' && (str[2] | 0x20) == 'n') { - // NaN - str += 3; - dec_val = MICROPY_FLOAT_C_FUN(nan)(""); - } - } else { - // string should be a decimal number - parse_dec_in_t in = PARSE_DEC_IN_INTG; - bool exp_neg = false; - mp_float_t frac_mult = 0.1; - mp_int_t exp_val = 0; - while (str < top) { - mp_uint_t dig = *str++; - if ('0' <= dig && dig <= '9') { - dig -= '0'; - if (in == PARSE_DEC_IN_EXP) { - exp_val = 10 * exp_val + dig; - } else { - if (in == PARSE_DEC_IN_FRAC) { - dec_val += dig * frac_mult; - frac_mult *= MICROPY_FLOAT_CONST(0.1); - } else { - dec_val = 10 * dec_val + dig; - } - } - } else if (in == PARSE_DEC_IN_INTG && dig == '.') { - in = PARSE_DEC_IN_FRAC; - } else if (in != PARSE_DEC_IN_EXP && ((dig | 0x20) == 'e')) { - in = PARSE_DEC_IN_EXP; - if (str < top) { - if (str[0] == '+') { - str++; - } else if (str[0] == '-') { - str++; - exp_neg = true; - } - } - if (str == top) { - goto value_error; - } - } else if (allow_imag && (dig | 0x20) == 'j') { - imag = true; - break; - } else { - // unknown character - str--; - break; - } - } - - // work out the exponent - if (exp_neg) { - exp_val = -exp_val; - } - - // apply the exponent - dec_val *= MICROPY_FLOAT_C_FUN(pow)(10, exp_val); - } - - // negate value if needed - if (dec_neg) { - dec_val = -dec_val; - } - - // check we parsed something - if (str == str_val_start) { - goto value_error; - } - - // skip trailing space - for (; str < top && unichar_isspace(*str); str++) { - } - - // check we reached the end of the string - if (str != top) { - goto value_error; - } - - // return the object -#if MICROPY_PY_BUILTINS_COMPLEX - if (imag) { - return mp_obj_new_complex(0, dec_val); - } else if (force_complex) { - return mp_obj_new_complex(dec_val, 0); -#else - if (imag || force_complex) { - raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "complex values not supported"), lex); -#endif - } else { - return mp_obj_new_float(dec_val); - } - -value_error: - raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid syntax for number"), lex); - -#else - raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "decimal numbers not supported"), lex); -#endif -} diff --git a/user/mpy/py/parsenum.h b/user/mpy/py/parsenum.h deleted file mode 100644 index a5bed73..0000000 --- a/user/mpy/py/parsenum.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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_PARSENUM_H -#define MICROPY_INCLUDED_PY_PARSENUM_H - -#include "py/mpconfig.h" -#include "py/lexer.h" -#include "py/obj.h" - -// these functions raise a SyntaxError if lex!=NULL, else a ValueError -mp_obj_t mp_parse_num_integer(const char *restrict str, size_t len, int base, mp_lexer_t *lex); -mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool force_complex, mp_lexer_t *lex); - -#endif // MICROPY_INCLUDED_PY_PARSENUM_H diff --git a/user/mpy/py/parsenumbase.c b/user/mpy/py/parsenumbase.c deleted file mode 100644 index ba10591..0000000 --- a/user/mpy/py/parsenumbase.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/parsenumbase.h" - -// find real radix base, and strip preceding '0x', '0o' and '0b' -// puts base in *base, and returns number of bytes to skip the prefix -size_t mp_parse_num_base(const char *str, size_t len, int *base) { - const byte *p = (const byte*)str; - if (len <= 1) { - goto no_prefix; - } - unichar c = *(p++); - if ((*base == 0 || *base == 16) && c == '0') { - c = *(p++); - if ((c | 32) == 'x') { - *base = 16; - } else if (*base == 0 && (c | 32) == 'o') { - *base = 8; - } else if (*base == 0 && (c | 32) == 'b') { - *base = 2; - } else { - if (*base == 0) { - *base = 10; - } - p -= 2; - } - } else if (*base == 8 && c == '0') { - c = *(p++); - if ((c | 32) != 'o') { - p -= 2; - } - } else if (*base == 2 && c == '0') { - c = *(p++); - if ((c | 32) != 'b') { - p -= 2; - } - } else { - p--; - no_prefix: - if (*base == 0) { - *base = 10; - } - } - return p - (const byte*)str; -} diff --git a/user/mpy/py/parsenumbase.h b/user/mpy/py/parsenumbase.h deleted file mode 100644 index 3a525f9..0000000 --- a/user/mpy/py/parsenumbase.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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_PARSENUMBASE_H -#define MICROPY_INCLUDED_PY_PARSENUMBASE_H - -#include "py/mpconfig.h" - -size_t mp_parse_num_base(const char *str, size_t len, int *base); - -#endif // MICROPY_INCLUDED_PY_PARSENUMBASE_H diff --git a/user/mpy/py/persistentcode.c b/user/mpy/py/persistentcode.c deleted file mode 100644 index 2fa8c1d..0000000 --- a/user/mpy/py/persistentcode.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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. - */ - -#include -#include -#include -#include - -#include "py/reader.h" -#include "py/emitglue.h" -#include "py/persistentcode.h" -#include "py/bc.h" - -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE - -#include "py/smallint.h" - -// The current version of .mpy files -#define MPY_VERSION (2) - -// The feature flags byte encodes the compile-time config options that -// affect the generate bytecode. -#define MPY_FEATURE_FLAGS ( \ - ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) << 0) \ - | ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \ - ) -// This is a version of the flags that can be configured at runtime. -#define MPY_FEATURE_FLAGS_DYNAMIC ( \ - ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) << 0) \ - | ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \ - ) - -#if MICROPY_PERSISTENT_CODE_LOAD || (MICROPY_PERSISTENT_CODE_SAVE && !MICROPY_DYNAMIC_COMPILER) -// The bytecode will depend on the number of bits in a small-int, and -// this function computes that (could make it a fixed constant, but it -// would need to be defined in mpconfigport.h). -STATIC int mp_small_int_bits(void) { - mp_int_t i = MP_SMALL_INT_MAX; - int n = 1; - while (i != 0) { - i >>= 1; - ++n; - } - return n; -} -#endif - -typedef struct _bytecode_prelude_t { - uint n_state; - uint n_exc_stack; - uint scope_flags; - uint n_pos_args; - uint n_kwonly_args; - uint n_def_pos_args; - uint code_info_size; -} bytecode_prelude_t; - -// ip will point to start of opcodes -// ip2 will point to simple_name, source_file qstrs -STATIC void extract_prelude(const byte **ip, const byte **ip2, bytecode_prelude_t *prelude) { - prelude->n_state = mp_decode_uint(ip); - prelude->n_exc_stack = mp_decode_uint(ip); - prelude->scope_flags = *(*ip)++; - prelude->n_pos_args = *(*ip)++; - prelude->n_kwonly_args = *(*ip)++; - prelude->n_def_pos_args = *(*ip)++; - *ip2 = *ip; - prelude->code_info_size = mp_decode_uint(ip2); - *ip += prelude->code_info_size; - while (*(*ip)++ != 255) { - } -} - -#endif // MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE - -#if MICROPY_PERSISTENT_CODE_LOAD - -#include "py/parsenum.h" -#include "py/bc0.h" - -STATIC int read_byte(mp_reader_t *reader) { - return reader->readbyte(reader->data); -} - -STATIC void read_bytes(mp_reader_t *reader, byte *buf, size_t len) { - while (len-- > 0) { - *buf++ = reader->readbyte(reader->data); - } -} - -STATIC size_t read_uint(mp_reader_t *reader) { - size_t unum = 0; - for (;;) { - byte b = reader->readbyte(reader->data); - unum = (unum << 7) | (b & 0x7f); - if ((b & 0x80) == 0) { - break; - } - } - return unum; -} - -STATIC qstr load_qstr(mp_reader_t *reader) { - size_t len = read_uint(reader); - char *str = m_new(char, len); - read_bytes(reader, (byte*)str, len); - qstr qst = qstr_from_strn(str, len); - m_del(char, str, len); - return qst; -} - -STATIC mp_obj_t load_obj(mp_reader_t *reader) { - byte obj_type = read_byte(reader); - if (obj_type == 'e') { - return MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj); - } else { - size_t len = read_uint(reader); - vstr_t vstr; - vstr_init_len(&vstr, len); - read_bytes(reader, (byte*)vstr.buf, len); - if (obj_type == 's' || obj_type == 'b') { - return mp_obj_new_str_from_vstr(obj_type == 's' ? &mp_type_str : &mp_type_bytes, &vstr); - } else if (obj_type == 'i') { - return mp_parse_num_integer(vstr.buf, vstr.len, 10, NULL); - } else { - assert(obj_type == 'f' || obj_type == 'c'); - return mp_parse_num_decimal(vstr.buf, vstr.len, obj_type == 'c', false, NULL); - } - } -} - -STATIC void load_bytecode_qstrs(mp_reader_t *reader, byte *ip, byte *ip_top) { - while (ip < ip_top) { - size_t sz; - uint f = mp_opcode_format(ip, &sz); - if (f == MP_OPCODE_QSTR) { - qstr qst = load_qstr(reader); - ip[1] = qst; - ip[2] = qst >> 8; - } - ip += sz; - } -} - -STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader) { - // load bytecode - size_t bc_len = read_uint(reader); - byte *bytecode = m_new(byte, bc_len); - read_bytes(reader, bytecode, bc_len); - - // extract prelude - const byte *ip = bytecode; - const byte *ip2; - bytecode_prelude_t prelude; - extract_prelude(&ip, &ip2, &prelude); - - // load qstrs and link global qstr ids into bytecode - qstr simple_name = load_qstr(reader); - qstr source_file = load_qstr(reader); - ((byte*)ip2)[0] = simple_name; ((byte*)ip2)[1] = simple_name >> 8; - ((byte*)ip2)[2] = source_file; ((byte*)ip2)[3] = source_file >> 8; - load_bytecode_qstrs(reader, (byte*)ip, bytecode + bc_len); - - // load constant table - size_t n_obj = read_uint(reader); - size_t n_raw_code = read_uint(reader); - mp_uint_t *const_table = m_new(mp_uint_t, prelude.n_pos_args + prelude.n_kwonly_args + n_obj + n_raw_code); - mp_uint_t *ct = const_table; - for (size_t i = 0; i < prelude.n_pos_args + prelude.n_kwonly_args; ++i) { - *ct++ = (mp_uint_t)MP_OBJ_NEW_QSTR(load_qstr(reader)); - } - for (size_t i = 0; i < n_obj; ++i) { - *ct++ = (mp_uint_t)load_obj(reader); - } - for (size_t i = 0; i < n_raw_code; ++i) { - *ct++ = (mp_uint_t)(uintptr_t)load_raw_code(reader); - } - - // create raw_code and return it - mp_raw_code_t *rc = mp_emit_glue_new_raw_code(); - mp_emit_glue_assign_bytecode(rc, bytecode, bc_len, const_table, - #if MICROPY_PERSISTENT_CODE_SAVE - n_obj, n_raw_code, - #endif - prelude.scope_flags); - return rc; -} - -mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader) { - byte header[4]; - read_bytes(reader, header, sizeof(header)); - if (header[0] != 'M' - || header[1] != MPY_VERSION - || header[2] != MPY_FEATURE_FLAGS - || header[3] > mp_small_int_bits()) { - mp_raise_ValueError("incompatible .mpy file"); - } - mp_raw_code_t *rc = load_raw_code(reader); - reader->close(reader->data); - return rc; -} - -mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len) { - mp_reader_t reader; - mp_reader_new_mem(&reader, buf, len, 0); - return mp_raw_code_load(&reader); -} - -mp_raw_code_t *mp_raw_code_load_file(const char *filename) { - mp_reader_t reader; - mp_reader_new_file(&reader, filename); - return mp_raw_code_load(&reader); -} - -#endif // MICROPY_PERSISTENT_CODE_LOAD - -#if MICROPY_PERSISTENT_CODE_SAVE - -#include "py/objstr.h" - -STATIC void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) { - print->print_strn(print->data, (const char*)data, len); -} - -#define BYTES_FOR_INT ((BYTES_PER_WORD * 8 + 6) / 7) -STATIC void mp_print_uint(mp_print_t *print, size_t n) { - byte buf[BYTES_FOR_INT]; - byte *p = buf + sizeof(buf); - *--p = n & 0x7f; - n >>= 7; - for (; n != 0; n >>= 7) { - *--p = 0x80 | (n & 0x7f); - } - print->print_strn(print->data, (char*)p, buf + sizeof(buf) - p); -} - -STATIC void save_qstr(mp_print_t *print, qstr qst) { - size_t len; - const byte *str = qstr_data(qst, &len); - mp_print_uint(print, len); - mp_print_bytes(print, str, len); -} - -STATIC void save_obj(mp_print_t *print, mp_obj_t o) { - if (MP_OBJ_IS_STR_OR_BYTES(o)) { - byte obj_type; - if (MP_OBJ_IS_STR(o)) { - obj_type = 's'; - } else { - obj_type = 'b'; - } - mp_uint_t len; - const char *str = mp_obj_str_get_data(o, &len); - mp_print_bytes(print, &obj_type, 1); - mp_print_uint(print, len); - mp_print_bytes(print, (const byte*)str, len); - } else if (MP_OBJ_TO_PTR(o) == &mp_const_ellipsis_obj) { - byte obj_type = 'e'; - mp_print_bytes(print, &obj_type, 1); - } else { - // we save numbers using a simplistic text representation - // TODO could be improved - byte obj_type; - if (MP_OBJ_IS_TYPE(o, &mp_type_int)) { - obj_type = 'i'; - #if MICROPY_PY_BUILTINS_COMPLEX - } else if (MP_OBJ_IS_TYPE(o, &mp_type_complex)) { - obj_type = 'c'; - #endif - } else { - assert(mp_obj_is_float(o)); - obj_type = 'f'; - } - vstr_t vstr; - mp_print_t pr; - vstr_init_print(&vstr, 10, &pr); - mp_obj_print_helper(&pr, o, PRINT_REPR); - mp_print_bytes(print, &obj_type, 1); - mp_print_uint(print, vstr.len); - mp_print_bytes(print, (const byte*)vstr.buf, vstr.len); - vstr_clear(&vstr); - } -} - -STATIC void save_bytecode_qstrs(mp_print_t *print, const byte *ip, const byte *ip_top) { - while (ip < ip_top) { - size_t sz; - uint f = mp_opcode_format(ip, &sz); - if (f == MP_OPCODE_QSTR) { - qstr qst = ip[1] | (ip[2] << 8); - save_qstr(print, qst); - } - ip += sz; - } -} - -STATIC void save_raw_code(mp_print_t *print, mp_raw_code_t *rc) { - if (rc->kind != MP_CODE_BYTECODE) { - mp_raise_ValueError("can only save bytecode"); - } - - // save bytecode - mp_print_uint(print, rc->data.u_byte.bc_len); - mp_print_bytes(print, rc->data.u_byte.bytecode, rc->data.u_byte.bc_len); - - // extract prelude - const byte *ip = rc->data.u_byte.bytecode; - const byte *ip2; - bytecode_prelude_t prelude; - extract_prelude(&ip, &ip2, &prelude); - - // save qstrs - save_qstr(print, ip2[0] | (ip2[1] << 8)); // simple_name - save_qstr(print, ip2[2] | (ip2[3] << 8)); // source_file - save_bytecode_qstrs(print, ip, rc->data.u_byte.bytecode + rc->data.u_byte.bc_len); - - // save constant table - mp_print_uint(print, rc->data.u_byte.n_obj); - mp_print_uint(print, rc->data.u_byte.n_raw_code); - const mp_uint_t *const_table = rc->data.u_byte.const_table; - for (uint i = 0; i < prelude.n_pos_args + prelude.n_kwonly_args; ++i) { - mp_obj_t o = (mp_obj_t)*const_table++; - save_qstr(print, MP_OBJ_QSTR_VALUE(o)); - } - for (uint i = 0; i < rc->data.u_byte.n_obj; ++i) { - save_obj(print, (mp_obj_t)*const_table++); - } - for (uint i = 0; i < rc->data.u_byte.n_raw_code; ++i) { - save_raw_code(print, (mp_raw_code_t*)(uintptr_t)*const_table++); - } -} - -void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) { - // header contains: - // byte 'M' - // byte version - // byte feature flags - // byte number of bits in a small int - byte header[4] = {'M', MPY_VERSION, MPY_FEATURE_FLAGS_DYNAMIC, - #if MICROPY_DYNAMIC_COMPILER - mp_dynamic_compiler.small_int_bits, - #else - mp_small_int_bits(), - #endif - }; - mp_print_bytes(print, header, sizeof(header)); - - save_raw_code(print, rc); -} - -// here we define mp_raw_code_save_file depending on the port -// TODO abstract this away properly - -#if defined(__i386__) || defined(__x86_64__) || (defined(__arm__) && (defined(__unix__))) - -#include -#include -#include - -STATIC void fd_print_strn(void *env, const char *str, size_t len) { - int fd = (intptr_t)env; - ssize_t ret = write(fd, str, len); - (void)ret; -} - -void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename) { - int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); - mp_print_t fd_print = {(void*)(intptr_t)fd, fd_print_strn}; - mp_raw_code_save(rc, &fd_print); - close(fd); -} - -#else -#error mp_raw_code_save_file not implemented for this platform -#endif - -#endif // MICROPY_PERSISTENT_CODE_SAVE diff --git a/user/mpy/py/persistentcode.h b/user/mpy/py/persistentcode.h deleted file mode 100644 index d04e0b6..0000000 --- a/user/mpy/py/persistentcode.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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_PERSISTENTCODE_H -#define MICROPY_INCLUDED_PY_PERSISTENTCODE_H - -#include "py/mpprint.h" -#include "py/reader.h" -#include "py/emitglue.h" - -mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader); -mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len); -mp_raw_code_t *mp_raw_code_load_file(const char *filename); - -void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print); -void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename); - -#endif // MICROPY_INCLUDED_PY_PERSISTENTCODE_H diff --git a/user/mpy/py/py.mk b/user/mpy/py/py.mk deleted file mode 100644 index cd0e94e..0000000 --- a/user/mpy/py/py.mk +++ /dev/null @@ -1,324 +0,0 @@ -# where py object files go (they have a name prefix to prevent filename clashes) -PY_BUILD = $(BUILD)/py - -# where autogenerated header files go -HEADER_BUILD = $(BUILD)/genhdr - -# file containing qstr defs for the core Python bit -PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h - -# If qstr autogeneration is not disabled we specify the output header -# for all collected qstrings. -ifneq ($(QSTR_AUTOGEN_DISABLE),1) -QSTR_DEFS_COLLECTED = $(HEADER_BUILD)/qstrdefs.collected.h -endif - -# some code is performance bottleneck and compiled with other optimization options -CSUPEROPT = -O3 - -# this sets the config file for FatFs -CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\" - -ifeq ($(MICROPY_PY_USSL),1) -CFLAGS_MOD += -DMICROPY_PY_USSL=1 -ifeq ($(MICROPY_SSL_AXTLS),1) -CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/lib/axtls/config -LDFLAGS_MOD += -Lbuild -laxtls -else ifeq ($(MICROPY_SSL_MBEDTLS),1) -# Can be overridden by ports which have "builtin" mbedTLS -MICROPY_SSL_MBEDTLS_INCLUDE ?= $(TOP)/lib/mbedtls/include -CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE) -LDFLAGS_MOD += -L$(TOP)/lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto -endif -endif - -#ifeq ($(MICROPY_PY_LWIP),1) -#CFLAGS_MOD += -DMICROPY_PY_LWIP=1 -I../lib/lwip/src/include -I../lib/lwip/src/include/ipv4 -I../extmod/lwip-include -#endif - -ifeq ($(MICROPY_PY_LWIP),1) -LWIP_DIR = lib/lwip/src -INC += -I$(TOP)/lib/lwip/src/include -I$(TOP)/lib/lwip/src/include/ipv4 -I$(TOP)/extmod/lwip-include -CFLAGS_MOD += -DMICROPY_PY_LWIP=1 -SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c -SRC_MOD += $(addprefix $(LWIP_DIR)/,\ - core/def.c \ - core/dns.c \ - core/init.c \ - core/mem.c \ - core/memp.c \ - core/netif.c \ - core/pbuf.c \ - core/raw.c \ - core/stats.c \ - core/sys.c \ - core/tcp.c \ - core/tcp_in.c \ - core/tcp_out.c \ - core/timers.c \ - core/udp.c \ - core/ipv4/autoip.c \ - core/ipv4/icmp.c \ - core/ipv4/igmp.c \ - core/ipv4/inet.c \ - core/ipv4/inet_chksum.c \ - core/ipv4/ip_addr.c \ - core/ipv4/ip.c \ - core/ipv4/ip_frag.c \ - ) -ifeq ($(MICROPY_PY_LWIP_SLIP),1) -CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1 -SRC_MOD += $(LWIP_DIR)/netif/slipif.c -endif -endif - -ifeq ($(MICROPY_PY_BTREE),1) -BTREE_DIR = lib/berkeley-db-1.xx -BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ -Dvirt_fd_t=mp_obj_t "-DVIRT_FD_T_HEADER=" -INC += -I$(TOP)/$(BTREE_DIR)/PORT/include -SRC_MOD += extmod/modbtree.c -SRC_MOD += $(addprefix $(BTREE_DIR)/,\ -btree/bt_close.c \ -btree/bt_conv.c \ -btree/bt_debug.c \ -btree/bt_delete.c \ -btree/bt_get.c \ -btree/bt_open.c \ -btree/bt_overflow.c \ -btree/bt_page.c \ -btree/bt_put.c \ -btree/bt_search.c \ -btree/bt_seq.c \ -btree/bt_split.c \ -btree/bt_utils.c \ -mpool/mpool.c \ - ) -CFLAGS_MOD += -DMICROPY_PY_BTREE=1 -# we need to suppress certain warnings to get berkeley-db to compile cleanly -# and we have separate BTREE_DEFS so the definitions don't interfere with other source code -$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS) -$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS) -endif - -# py object files -PY_O_BASENAME = \ - mpstate.o \ - nlrx86.o \ - nlrx64.o \ - nlrthumb.o \ - nlrxtensa.o \ - nlrsetjmp.o \ - malloc.o \ - gc.o \ - qstr.o \ - vstr.o \ - mpprint.o \ - unicode.o \ - mpz.o \ - reader.o \ - lexer.o \ - parse.o \ - scope.o \ - compile.o \ - emitcommon.o \ - emitbc.o \ - asmbase.o \ - asmx64.o \ - emitnx64.o \ - asmx86.o \ - emitnx86.o \ - asmthumb.o \ - emitnthumb.o \ - emitinlinethumb.o \ - asmarm.o \ - emitnarm.o \ - asmxtensa.o \ - emitnxtensa.o \ - emitinlinextensa.o \ - formatfloat.o \ - parsenumbase.o \ - parsenum.o \ - emitglue.o \ - persistentcode.o \ - runtime.o \ - runtime_utils.o \ - scheduler.o \ - nativeglue.o \ - stackctrl.o \ - argcheck.o \ - warning.o \ - map.o \ - obj.o \ - objarray.o \ - objattrtuple.o \ - objbool.o \ - objboundmeth.o \ - objcell.o \ - objclosure.o \ - objcomplex.o \ - objdict.o \ - objenumerate.o \ - objexcept.o \ - objfilter.o \ - objfloat.o \ - objfun.o \ - objgenerator.o \ - objgetitemiter.o \ - objint.o \ - objint_longlong.o \ - objint_mpz.o \ - objlist.o \ - objmap.o \ - objmodule.o \ - objobject.o \ - objpolyiter.o \ - objproperty.o \ - objnone.o \ - objnamedtuple.o \ - objrange.o \ - objreversed.o \ - objset.o \ - objsingleton.o \ - objslice.o \ - objstr.o \ - objstrunicode.o \ - objstringio.o \ - objtuple.o \ - objtype.o \ - objzip.o \ - opmethods.o \ - sequence.o \ - stream.o \ - binary.o \ - builtinimport.o \ - builtinevex.o \ - builtinhelp.o \ - modarray.o \ - modbuiltins.o \ - modcollections.o \ - modgc.o \ - modio.o \ - modmath.o \ - modcmath.o \ - modmicropython.o \ - modstruct.o \ - modsys.o \ - moduerrno.o \ - modthread.o \ - vm.o \ - bc.o \ - showbc.o \ - repl.o \ - smallint.o \ - frozenmod.o \ - ../extmod/moductypes.o \ - ../extmod/modujson.o \ - ../extmod/modure.o \ - ../extmod/moduzlib.o \ - ../extmod/moduheapq.o \ - ../extmod/modutimeq.o \ - ../extmod/moduhashlib.o \ - ../extmod/modubinascii.o \ - ../extmod/virtpin.o \ - ../extmod/machine_mem.o \ - ../extmod/machine_pinbase.o \ - ../extmod/machine_signal.o \ - ../extmod/machine_pulse.o \ - ../extmod/machine_i2c.o \ - ../extmod/machine_spi.o \ - ../extmod/modussl_axtls.o \ - ../extmod/modussl_mbedtls.o \ - ../extmod/modurandom.o \ - ../extmod/moduselect.o \ - ../extmod/modwebsocket.o \ - ../extmod/modwebrepl.o \ - ../extmod/modframebuf.o \ - ../extmod/vfs.o \ - ../extmod/vfs_reader.o \ - ../extmod/vfs_fat.o \ - ../extmod/vfs_fat_diskio.o \ - ../extmod/vfs_fat_file.o \ - ../extmod/vfs_fat_misc.o \ - ../extmod/utime_mphal.o \ - ../extmod/uos_dupterm.o \ - ../lib/embed/abort_.o \ - ../lib/utils/printf.o \ - -# prepend the build destination prefix to the py object files -PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME)) - -# object file for frozen files -ifneq ($(FROZEN_DIR),) -PY_O += $(BUILD)/$(BUILD)/frozen.o -endif - -# object file for frozen bytecode (frozen .mpy files) -ifneq ($(FROZEN_MPY_DIR),) -PY_O += $(BUILD)/$(BUILD)/frozen_mpy.o -endif - -# Sources that may contain qstrings -SRC_QSTR_IGNORE = nlr% emitnx86% emitnx64% emitnthumb% emitnarm% emitnxtensa% -SRC_QSTR = $(SRC_MOD) $(addprefix py/,$(filter-out $(SRC_QSTR_IGNORE),$(PY_O_BASENAME:.o=.c)) emitnative.c) - - -$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD) - $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ - -# mpconfigport.mk is optional, but changes to it may drastically change -# overall config, so they need to be caught -MPCONFIGPORT_MK = $(wildcard mpconfigport.mk) - -# qstr data -# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get -# created before we run the script to generate the .h -# Note: we need to protect the qstr names from the preprocessor, so we wrap -# the lines in "" and then unwrap after the preprocessor is finished. -$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) - $(ECHO) "GEN $@" - $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h - $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ - -# Force nlr code to always be compiled with space-saving optimisation so -# that the function preludes are of a minimal and predictable form. -$(PY_BUILD)/nlr%.o: CFLAGS += -Os - -# emitters - -$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64 -$(PY_BUILD)/emitnx64.o: py/emitnative.c - $(call compile_c) - -$(PY_BUILD)/emitnx86.o: CFLAGS += -DN_X86 -$(PY_BUILD)/emitnx86.o: py/emitnative.c - $(call compile_c) - -$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB -$(PY_BUILD)/emitnthumb.o: py/emitnative.c - $(call compile_c) - -$(PY_BUILD)/emitnarm.o: CFLAGS += -DN_ARM -$(PY_BUILD)/emitnarm.o: py/emitnative.c - $(call compile_c) - -$(PY_BUILD)/emitnxtensa.o: CFLAGS += -DN_XTENSA -$(PY_BUILD)/emitnxtensa.o: py/emitnative.c - $(call compile_c) - -# optimising gc for speed; 5ms down to 4ms on pybv2 -$(PY_BUILD)/gc.o: CFLAGS += $(CSUPEROPT) - -# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster) -$(PY_BUILD)/vm.o: CFLAGS += $(CSUPEROPT) -# Optimizing vm.o for modern deeply pipelined CPUs with branch predictors -# may require disabling tail jump optimization. This will make sure that -# each opcode has its own dispatching jump which will improve branch -# branch predictor efficiency. -# http://article.gmane.org/gmane.comp.lang.lua.general/75426 -# http://hg.python.org/cpython/file/b127046831e2/Python/ceval.c#l828 -# http://www.emulators.com/docs/nx25_nostradamus.htm -#-fno-crossjumping - -# Anything that depends on FORCE will be considered out-of-date -FORCE: -.PHONY: FORCE diff --git a/user/mpy/py/qstr.c b/user/mpy/py/qstr.c deleted file mode 100644 index 95c9b68..0000000 --- a/user/mpy/py/qstr.c +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpstate.h" -#include "py/qstr.h" -#include "py/gc.h" - -// NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings) -// ultimately we will replace this with a static hash table of some kind -// also probably need to include the length in the string data, to allow null bytes in the string - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_printf DEBUG_printf -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#endif - -// A qstr is an index into the qstr pool. -// The data for a qstr contains (hash, length, data): -// - hash (configurable number of bytes) -// - length (configurable number of bytes) -// - data ("length" number of bytes) -// - \0 terminated (so they can be printed using printf) - -#if MICROPY_QSTR_BYTES_IN_HASH == 1 - #define Q_HASH_MASK (0xff) - #define Q_GET_HASH(q) ((mp_uint_t)(q)[0]) - #define Q_SET_HASH(q, hash) do { (q)[0] = (hash); } while (0) -#elif MICROPY_QSTR_BYTES_IN_HASH == 2 - #define Q_HASH_MASK (0xffff) - #define Q_GET_HASH(q) ((mp_uint_t)(q)[0] | ((mp_uint_t)(q)[1] << 8)) - #define Q_SET_HASH(q, hash) do { (q)[0] = (hash); (q)[1] = (hash) >> 8; } while (0) -#else - #error unimplemented qstr hash decoding -#endif -#define Q_GET_ALLOC(q) (MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + Q_GET_LENGTH(q) + 1) -#define Q_GET_DATA(q) ((q) + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN) -#if MICROPY_QSTR_BYTES_IN_LEN == 1 - #define Q_GET_LENGTH(q) ((q)[MICROPY_QSTR_BYTES_IN_HASH]) - #define Q_SET_LENGTH(q, len) do { (q)[MICROPY_QSTR_BYTES_IN_HASH] = (len); } while (0) -#elif MICROPY_QSTR_BYTES_IN_LEN == 2 - #define Q_GET_LENGTH(q) ((q)[MICROPY_QSTR_BYTES_IN_HASH] | ((q)[MICROPY_QSTR_BYTES_IN_HASH + 1] << 8)) - #define Q_SET_LENGTH(q, len) do { (q)[MICROPY_QSTR_BYTES_IN_HASH] = (len); (q)[MICROPY_QSTR_BYTES_IN_HASH + 1] = (len) >> 8; } while (0) -#else - #error unimplemented qstr length decoding -#endif - -#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL -#define QSTR_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(qstr_mutex), 1) -#define QSTR_EXIT() mp_thread_mutex_unlock(&MP_STATE_VM(qstr_mutex)) -#else -#define QSTR_ENTER() -#define QSTR_EXIT() -#endif - -// this must match the equivalent function in makeqstrdata.py -mp_uint_t qstr_compute_hash(const byte *data, size_t len) { - // djb2 algorithm; see http://www.cse.yorku.ca/~oz/hash.html - mp_uint_t hash = 5381; - for (const byte *top = data + len; data < top; data++) { - hash = ((hash << 5) + hash) ^ (*data); // hash * 33 ^ data - } - hash &= Q_HASH_MASK; - // Make sure that valid hash is never zero, zero means "hash not computed" - if (hash == 0) { - hash++; - } - return hash; -} - -const qstr_pool_t mp_qstr_const_pool = { - NULL, // no previous pool - 0, // no previous pool - 10, // set so that the first dynamically allocated pool is twice this size; must be <= the len (just below) - MP_QSTRnumber_of, // corresponds to number of strings in array just below - { -#ifndef NO_QSTR -#define QDEF(id, str) str, -#include "genhdr/qstrdefs.generated.h" -#undef QDEF -#endif - }, -}; - -#ifdef MICROPY_QSTR_EXTRA_POOL -extern const qstr_pool_t MICROPY_QSTR_EXTRA_POOL; -#define CONST_POOL MICROPY_QSTR_EXTRA_POOL -#else -#define CONST_POOL mp_qstr_const_pool -#endif - -void qstr_init(void) { - MP_STATE_VM(last_pool) = (qstr_pool_t*)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left - MP_STATE_VM(qstr_last_chunk) = NULL; - - #if MICROPY_PY_THREAD - mp_thread_mutex_init(&MP_STATE_VM(qstr_mutex)); - #endif -} - -STATIC const byte *find_qstr(qstr q) { - // search pool for this qstr - for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) { - if (q >= pool->total_prev_len) { - return pool->qstrs[q - pool->total_prev_len]; - } - } - - // not found - return 0; -} - -// qstr_mutex must be taken while in this function -STATIC qstr qstr_add(const byte *q_ptr) { - DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", Q_GET_HASH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_DATA(q_ptr)); - - // make sure we have room in the pool for a new qstr - if (MP_STATE_VM(last_pool)->len >= MP_STATE_VM(last_pool)->alloc) { - qstr_pool_t *pool = m_new_obj_var_maybe(qstr_pool_t, const char*, MP_STATE_VM(last_pool)->alloc * 2); - if (pool == NULL) { - QSTR_EXIT(); - m_malloc_fail(MP_STATE_VM(last_pool)->alloc * 2); - } - pool->prev = MP_STATE_VM(last_pool); - pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len; - pool->alloc = MP_STATE_VM(last_pool)->alloc * 2; - pool->len = 0; - MP_STATE_VM(last_pool) = pool; - DEBUG_printf("QSTR: allocate new pool of size %d\n", MP_STATE_VM(last_pool)->alloc); - } - - // add the new qstr - MP_STATE_VM(last_pool)->qstrs[MP_STATE_VM(last_pool)->len++] = q_ptr; - - // return id for the newly-added qstr - return MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len - 1; -} - -qstr qstr_find_strn(const char *str, size_t str_len) { - // work out hash of str - mp_uint_t str_hash = qstr_compute_hash((const byte*)str, str_len); - - // search pools for the data - for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) { - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - if (Q_GET_HASH(*q) == str_hash && Q_GET_LENGTH(*q) == str_len && memcmp(Q_GET_DATA(*q), str, str_len) == 0) { - return pool->total_prev_len + (q - pool->qstrs); - } - } - } - - // not found; return null qstr - return 0; -} - -qstr qstr_from_str(const char *str) { - return qstr_from_strn(str, strlen(str)); -} - -qstr qstr_from_strn(const char *str, size_t len) { - assert(len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))); - QSTR_ENTER(); - qstr q = qstr_find_strn(str, len); - if (q == 0) { - // qstr does not exist in interned pool so need to add it - - // compute number of bytes needed to intern this string - size_t n_bytes = MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len + 1; - - if (MP_STATE_VM(qstr_last_chunk) != NULL && MP_STATE_VM(qstr_last_used) + n_bytes > MP_STATE_VM(qstr_last_alloc)) { - // not enough room at end of previously interned string so try to grow - byte *new_p = m_renew_maybe(byte, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_alloc) + n_bytes, false); - if (new_p == NULL) { - // could not grow existing memory; shrink it to fit previous - (void)m_renew_maybe(byte, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_used), false); - MP_STATE_VM(qstr_last_chunk) = NULL; - } else { - // could grow existing memory - MP_STATE_VM(qstr_last_alloc) += n_bytes; - } - } - - if (MP_STATE_VM(qstr_last_chunk) == NULL) { - // no existing memory for the interned string so allocate a new chunk - size_t al = n_bytes; - if (al < MICROPY_ALLOC_QSTR_CHUNK_INIT) { - al = MICROPY_ALLOC_QSTR_CHUNK_INIT; - } - MP_STATE_VM(qstr_last_chunk) = m_new_maybe(byte, al); - if (MP_STATE_VM(qstr_last_chunk) == NULL) { - // failed to allocate a large chunk so try with exact size - MP_STATE_VM(qstr_last_chunk) = m_new_maybe(byte, n_bytes); - if (MP_STATE_VM(qstr_last_chunk) == NULL) { - QSTR_EXIT(); - m_malloc_fail(n_bytes); - } - al = n_bytes; - } - MP_STATE_VM(qstr_last_alloc) = al; - MP_STATE_VM(qstr_last_used) = 0; - } - - // allocate memory from the chunk for this new interned string's data - byte *q_ptr = MP_STATE_VM(qstr_last_chunk) + MP_STATE_VM(qstr_last_used); - MP_STATE_VM(qstr_last_used) += n_bytes; - - // store the interned strings' data - mp_uint_t hash = qstr_compute_hash((const byte*)str, len); - Q_SET_HASH(q_ptr, hash); - Q_SET_LENGTH(q_ptr, len); - memcpy(q_ptr + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN, str, len); - q_ptr[MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len] = '\0'; - q = qstr_add(q_ptr); - } - QSTR_EXIT(); - return q; -} - -byte *qstr_build_start(size_t len, byte **q_ptr) { - assert(len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))); - *q_ptr = m_new(byte, MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len + 1); - Q_SET_LENGTH(*q_ptr, len); - return Q_GET_DATA(*q_ptr); -} - -qstr qstr_build_end(byte *q_ptr) { - QSTR_ENTER(); - qstr q = qstr_find_strn((const char*)Q_GET_DATA(q_ptr), Q_GET_LENGTH(q_ptr)); - if (q == 0) { - size_t len = Q_GET_LENGTH(q_ptr); - mp_uint_t hash = qstr_compute_hash(Q_GET_DATA(q_ptr), len); - Q_SET_HASH(q_ptr, hash); - q_ptr[MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len] = '\0'; - q = qstr_add(q_ptr); - } else { - m_del(byte, q_ptr, Q_GET_ALLOC(q_ptr)); - } - QSTR_EXIT(); - return q; -} - -mp_uint_t qstr_hash(qstr q) { - return Q_GET_HASH(find_qstr(q)); -} - -size_t qstr_len(qstr q) { - const byte *qd = find_qstr(q); - return Q_GET_LENGTH(qd); -} - -const char *qstr_str(qstr q) { - const byte *qd = find_qstr(q); - return (const char*)Q_GET_DATA(qd); -} - -const byte *qstr_data(qstr q, size_t *len) { - const byte *qd = find_qstr(q); - *len = Q_GET_LENGTH(qd); - return Q_GET_DATA(qd); -} - -void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, size_t *n_total_bytes) { - QSTR_ENTER(); - *n_pool = 0; - *n_qstr = 0; - *n_str_data_bytes = 0; - *n_total_bytes = 0; - for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL && pool != &CONST_POOL; pool = pool->prev) { - *n_pool += 1; - *n_qstr += pool->len; - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - *n_str_data_bytes += Q_GET_ALLOC(*q); - } - #if MICROPY_ENABLE_GC - *n_total_bytes += gc_nbytes(pool); // this counts actual bytes used in heap - #else - *n_total_bytes += sizeof(qstr_pool_t) + sizeof(qstr) * pool->alloc; - #endif - } - *n_total_bytes += *n_str_data_bytes; - QSTR_EXIT(); -} - -#if MICROPY_PY_MICROPYTHON_MEM_INFO -void qstr_dump_data(void) { - QSTR_ENTER(); - for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL && pool != &CONST_POOL; pool = pool->prev) { - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - mp_printf(&mp_plat_print, "Q(%s)\n", Q_GET_DATA(*q)); - } - } - QSTR_EXIT(); -} -#endif diff --git a/user/mpy/py/qstr.h b/user/mpy/py/qstr.h deleted file mode 100644 index e2bdcc3..0000000 --- a/user/mpy/py/qstr.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 - -#include "py/mpconfig.h" -#include "py/misc.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_static("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_QSTR_NULL=0, which indicates invalid/no qstr -enum { -#ifndef NO_QSTR -#define QDEF(id, str) id, -#include "genhdr/qstrdefs.generated.h" -#undef QDEF -#endif - 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_FROM_STR_STATIC(s) (qstr_from_strn((s), strlen(s))) - -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_QSTR_NULL if not found - -qstr qstr_from_str(const char *str); -qstr qstr_from_strn(const char *str, size_t len); - -byte *qstr_build_start(size_t len, byte **q_ptr); -qstr qstr_build_end(byte *q_ptr); - -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); - -#endif // MICROPY_INCLUDED_PY_QSTR_H diff --git a/user/mpy/py/qstrdefs.h b/user/mpy/py/qstrdefs.h deleted file mode 100644 index 9375b91..0000000 --- a/user/mpy/py/qstrdefs.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -#include "py/mpconfig.h" - -// All the qstr definitions in this file are available as constants. -// That is, they are in ROM and you can reference them simply as MP_QSTR_xxxx. - -// qstr configuration passed to makeqstrdata.py of the form QCFG(key, value) -QCFG(BYTES_IN_LEN, MICROPY_QSTR_BYTES_IN_LEN) -QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH) - -Q() -Q(*) -Q(_) -Q(/) -Q(%#o) -Q(%#x) -Q({:#b}) -Q(\n) -Q(maximum recursion depth exceeded) -Q() -Q() -Q() -Q() -Q() -Q() -Q() -Q() -Q(utf-8) - -// The following qstrings not referenced from anywhere in the sources -Q(__locals__) -Q(BufferError) -Q(FileExistsError) -Q(FileNotFoundError) -Q(FloatingPointError) -Q(UnboundLocalError) diff --git a/user/mpy/py/reader.c b/user/mpy/py/reader.c deleted file mode 100644 index c4d18d5..0000000 --- a/user/mpy/py/reader.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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. - */ - -#include -#include - -#include "py/runtime.h" -#include "py/mperrno.h" -#include "py/reader.h" - -typedef struct _mp_reader_mem_t { - size_t free_len; // if >0 mem is freed on close by: m_free(beg, free_len) - const byte *beg; - const byte *cur; - const byte *end; -} mp_reader_mem_t; - -STATIC mp_uint_t mp_reader_mem_readbyte(void *data) { - mp_reader_mem_t *reader = (mp_reader_mem_t*)data; - if (reader->cur < reader->end) { - return *reader->cur++; - } else { - return MP_READER_EOF; - } -} - -STATIC void mp_reader_mem_close(void *data) { - mp_reader_mem_t *reader = (mp_reader_mem_t*)data; - if (reader->free_len > 0) { - m_del(char, (char*)reader->beg, reader->free_len); - } - m_del_obj(mp_reader_mem_t, reader); -} - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len) { - mp_reader_mem_t *rm = m_new_obj(mp_reader_mem_t); - rm->free_len = free_len; - rm->beg = buf; - rm->cur = buf; - rm->end = buf + len; - reader->data = rm; - reader->readbyte = mp_reader_mem_readbyte; - reader->close = mp_reader_mem_close; -} - -#if MICROPY_READER_POSIX - -#include -#include -#include - -typedef struct _mp_reader_posix_t { - bool close_fd; - int fd; - size_t len; - size_t pos; - byte buf[20]; -} mp_reader_posix_t; - -STATIC mp_uint_t mp_reader_posix_readbyte(void *data) { - mp_reader_posix_t *reader = (mp_reader_posix_t*)data; - if (reader->pos >= reader->len) { - if (reader->len == 0) { - return MP_READER_EOF; - } else { - int n = read(reader->fd, reader->buf, sizeof(reader->buf)); - if (n <= 0) { - reader->len = 0; - return MP_READER_EOF; - } - reader->len = n; - reader->pos = 0; - } - } - return reader->buf[reader->pos++]; -} - -STATIC void mp_reader_posix_close(void *data) { - mp_reader_posix_t *reader = (mp_reader_posix_t*)data; - if (reader->close_fd) { - close(reader->fd); - } - m_del_obj(mp_reader_posix_t, reader); -} - -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, bool close_fd) { - mp_reader_posix_t *rp = m_new_obj(mp_reader_posix_t); - rp->close_fd = close_fd; - rp->fd = fd; - int n = read(rp->fd, rp->buf, sizeof(rp->buf)); - if (n == -1) { - if (close_fd) { - close(fd); - } - mp_raise_OSError(errno); - } - rp->len = n; - rp->pos = 0; - reader->data = rp; - reader->readbyte = mp_reader_posix_readbyte; - reader->close = mp_reader_posix_close; -} - -void mp_reader_new_file(mp_reader_t *reader, const char *filename) { - int fd = open(filename, O_RDONLY, 0644); - if (fd < 0) { - mp_raise_OSError(errno); - } - mp_reader_new_file_from_fd(reader, fd, true); -} - -#endif diff --git a/user/mpy/py/reader.h b/user/mpy/py/reader.h deleted file mode 100644 index 8511c72..0000000 --- a/user/mpy/py/reader.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 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_READER_H -#define MICROPY_INCLUDED_PY_READER_H - -#include "py/obj.h" - -// the readbyte function must return the next byte in the input stream -// it must return MP_READER_EOF if end of stream -// it can be called again after returning MP_READER_EOF, and in that case must return MP_READER_EOF -#define MP_READER_EOF ((mp_uint_t)(-1)) - -typedef struct _mp_reader_t { - void *data; - mp_uint_t (*readbyte)(void *data); - void (*close)(void *data); -} mp_reader_t; - -void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len); -void mp_reader_new_file(mp_reader_t *reader, const char *filename); -void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, bool close_fd); - -#endif // MICROPY_INCLUDED_PY_READER_H diff --git a/user/mpy/py/repl.c b/user/mpy/py/repl.c deleted file mode 100644 index 7e8922e..0000000 --- a/user/mpy/py/repl.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2015 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. - */ - -#include -#include "py/obj.h" -#include "py/runtime.h" -#include "py/repl.h" - -#if MICROPY_HELPER_REPL - -STATIC bool str_startswith_word(const char *str, const char *head) { - size_t i; - for (i = 0; str[i] && head[i]; i++) { - if (str[i] != head[i]) { - return false; - } - } - return head[i] == '\0' && (str[i] == '\0' || !unichar_isident(str[i])); -} - -bool mp_repl_continue_with_input(const char *input) { - // check for blank input - if (input[0] == '\0') { - return false; - } - - // check if input starts with a certain keyword - bool starts_with_compound_keyword = - input[0] == '@' - || str_startswith_word(input, "if") - || str_startswith_word(input, "while") - || str_startswith_word(input, "for") - || str_startswith_word(input, "try") - || str_startswith_word(input, "with") - || str_startswith_word(input, "def") - || str_startswith_word(input, "class") - #if MICROPY_PY_ASYNC_AWAIT - || str_startswith_word(input, "async") - #endif - ; - - // check for unmatched open bracket, quote or escape quote - #define Q_NONE (0) - #define Q_1_SINGLE (1) - #define Q_1_DOUBLE (2) - #define Q_3_SINGLE (3) - #define Q_3_DOUBLE (4) - int n_paren = 0; - int n_brack = 0; - int n_brace = 0; - int in_quote = Q_NONE; - const char *i; - for (i = input; *i; i++) { - if (*i == '\'') { - if ((in_quote == Q_NONE || in_quote == Q_3_SINGLE) && i[1] == '\'' && i[2] == '\'') { - i += 2; - in_quote = Q_3_SINGLE - in_quote; - } else if (in_quote == Q_NONE || in_quote == Q_1_SINGLE) { - in_quote = Q_1_SINGLE - in_quote; - } - } else if (*i == '"') { - if ((in_quote == Q_NONE || in_quote == Q_3_DOUBLE) && i[1] == '"' && i[2] == '"') { - i += 2; - in_quote = Q_3_DOUBLE - in_quote; - } else if (in_quote == Q_NONE || in_quote == Q_1_DOUBLE) { - in_quote = Q_1_DOUBLE - in_quote; - } - } else if (*i == '\\' && (i[1] == '\'' || i[1] == '"' || i[1] == '\\')) { - if (in_quote != Q_NONE) { - i++; - } - } else if (in_quote == Q_NONE) { - switch (*i) { - case '(': n_paren += 1; break; - case ')': n_paren -= 1; break; - case '[': n_brack += 1; break; - case ']': n_brack -= 1; break; - case '{': n_brace += 1; break; - case '}': n_brace -= 1; break; - default: break; - } - } - } - - // continue if unmatched brackets or quotes - if (n_paren > 0 || n_brack > 0 || n_brace > 0 || in_quote == Q_3_SINGLE || in_quote == Q_3_DOUBLE) { - return true; - } - - // continue if last character was backslash (for line continuation) - if (i[-1] == '\\') { - return true; - } - - // continue if compound keyword and last line was not empty - if (starts_with_compound_keyword && i[-1] != '\n') { - return true; - } - - // otherwise, don't continue - return false; -} - -size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str) { - // scan backwards to find start of "a.b.c" chain - const char *org_str = str; - const char *top = str + len; - for (const char *s = top; --s >= str;) { - if (!(unichar_isalpha(*s) || unichar_isdigit(*s) || *s == '_' || *s == '.')) { - ++s; - str = s; - break; - } - } - - // begin search in locals dict - mp_obj_dict_t *dict = mp_locals_get(); - - for (;;) { - // get next word in string to complete - const char *s_start = str; - while (str < top && *str != '.') { - ++str; - } - size_t s_len = str - s_start; - - if (str < top) { - // a complete word, lookup in current dict - - mp_obj_t obj = MP_OBJ_NULL; - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - size_t d_len; - const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); - if (s_len == d_len && strncmp(s_start, d_str, d_len) == 0) { - obj = dict->map.table[i].value; - break; - } - } - } - - if (obj == MP_OBJ_NULL) { - // lookup failed - return 0; - } - - // found an object of this name; try to get its dict - if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) { - dict = mp_obj_module_get_globals(obj); - } else { - mp_obj_type_t *type; - if (MP_OBJ_IS_TYPE(obj, &mp_type_type)) { - type = MP_OBJ_TO_PTR(obj); - } else { - type = mp_obj_get_type(obj); - } - if (type->locals_dict != NULL && type->locals_dict->base.type == &mp_type_dict) { - dict = type->locals_dict; - } else { - // obj has no dict - return 0; - } - } - - // skip '.' to move to next word - ++str; - - } else { - // end of string, do completion on this partial name - - // look for matches - int n_found = 0; - const char *match_str = NULL; - size_t match_len = 0; - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - size_t d_len; - const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); - if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { - if (match_str == NULL) { - match_str = d_str; - match_len = d_len; - } else { - // search for longest common prefix of match_str and d_str - // (assumes these strings are null-terminated) - for (size_t j = s_len; j <= match_len && j <= d_len; ++j) { - if (match_str[j] != d_str[j]) { - match_len = j; - break; - } - } - } - ++n_found; - } - } - } - - // nothing found - if (n_found == 0) { - // If there're no better alternatives, and if it's first word - // in the line, try to complete "import". - if (s_start == org_str) { - static const char import_str[] = "import "; - if (memcmp(s_start, import_str, s_len) == 0) { - *compl_str = import_str + s_len; - return sizeof(import_str) - 1 - s_len; - } - } - - return 0; - } - - // 1 match found, or multiple matches with a common prefix - if (n_found == 1 || match_len > s_len) { - *compl_str = match_str + s_len; - return match_len - s_len; - } - - // multiple matches found, print them out - - #define WORD_SLOT_LEN (16) - #define MAX_LINE_LEN (4 * WORD_SLOT_LEN) - - int line_len = MAX_LINE_LEN; // force a newline for first word - for (size_t i = 0; i < dict->map.alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { - size_t d_len; - const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len); - if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) { - int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len; - if (gap < 2) { - gap += WORD_SLOT_LEN; - } - if (line_len + gap + d_len <= MAX_LINE_LEN) { - // TODO optimise printing of gap? - for (int j = 0; j < gap; ++j) { - mp_print_str(print, " "); - } - mp_print_str(print, d_str); - line_len += gap + d_len; - } else { - mp_printf(print, "\n%s", d_str); - line_len = d_len; - } - } - } - } - mp_print_str(print, "\n"); - - return (size_t)(-1); // indicate many matches - } - } -} - -#endif // MICROPY_HELPER_REPL diff --git a/user/mpy/py/repl.h b/user/mpy/py/repl.h deleted file mode 100644 index a7a4136..0000000 --- a/user/mpy/py/repl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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_REPL_H -#define MICROPY_INCLUDED_PY_REPL_H - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/mpprint.h" - -#if MICROPY_HELPER_REPL -bool mp_repl_continue_with_input(const char *input); -size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str); -#endif - -#endif // MICROPY_INCLUDED_PY_REPL_H diff --git a/user/mpy/py/ringbuf.h b/user/mpy/py/ringbuf.h deleted file mode 100644 index b416927..0000000 --- a/user/mpy/py/ringbuf.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 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. - */ -#ifndef MICROPY_INCLUDED_PY_RINGBUF_H -#define MICROPY_INCLUDED_PY_RINGBUF_H - -typedef struct _ringbuf_t { - uint8_t *buf; - uint16_t size; - uint16_t iget; - uint16_t iput; -} ringbuf_t; - -// Static initialization: -// byte buf_array[N]; -// ringbuf_t buf = {buf_array, sizeof(buf_array)}; - -// Dynamic initialization. This creates root pointer! -#define ringbuf_alloc(r, sz) \ -{ \ - (r)->buf = m_new(uint8_t, sz); \ - (r)->size = sz; \ - (r)->iget = (r)->iput = 0; \ -} - -static inline int ringbuf_get(ringbuf_t *r) { - if (r->iget == r->iput) { - return -1; - } - uint8_t v = r->buf[r->iget++]; - if (r->iget >= r->size) { - r->iget = 0; - } - return v; -} - -static inline int ringbuf_put(ringbuf_t *r, uint8_t v) { - uint32_t iput_new = r->iput + 1; - if (iput_new >= r->size) { - iput_new = 0; - } - if (iput_new == r->iget) { - return -1; - } - r->buf[r->iput] = v; - r->iput = iput_new; - return 0; -} - -#endif // MICROPY_INCLUDED_PY_RINGBUF_H diff --git a/user/mpy/py/runtime.c b/user/mpy/py/runtime.c deleted file mode 100644 index eb12988..0000000 --- a/user/mpy/py/runtime.c +++ /dev/null @@ -1,1444 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpstate.h" -#include "py/nlr.h" -#include "py/parsenum.h" -#include "py/compile.h" -#include "py/objstr.h" -#include "py/objtuple.h" -#include "py/objlist.h" -#include "py/objmodule.h" -#include "py/objgenerator.h" -#include "py/smallint.h" -#include "py/runtime0.h" -#include "py/runtime.h" -#include "py/builtin.h" -#include "py/stackctrl.h" -#include "py/gc.h" - -#if MICROPY_DEBUG_VERBOSE // print debugging info -#define DEBUG_PRINT (1) -#define DEBUG_printf DEBUG_printf -#define DEBUG_OP_printf(...) DEBUG_printf(__VA_ARGS__) -#else // don't print debugging info -#define DEBUG_printf(...) (void)0 -#define DEBUG_OP_printf(...) (void)0 -#endif - -const mp_obj_module_t mp_module___main__ = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&MP_STATE_VM(dict_main), -}; - -void mp_init(void) { - qstr_init(); - - // no pending exceptions to start with - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; - #if MICROPY_ENABLE_SCHEDULER - MP_STATE_VM(sched_state) = MP_SCHED_IDLE; - MP_STATE_VM(sched_sp) = 0; - #endif - -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - mp_init_emergency_exception_buf(); -#endif - - #if MICROPY_KBD_EXCEPTION - // initialise the exception object for raising KeyboardInterrupt - MP_STATE_VM(mp_kbd_exception).base.type = &mp_type_KeyboardInterrupt; - MP_STATE_VM(mp_kbd_exception).traceback_alloc = 0; - MP_STATE_VM(mp_kbd_exception).traceback_len = 0; - MP_STATE_VM(mp_kbd_exception).traceback_data = NULL; - MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; - #endif - - // call port specific initialization if any -#ifdef MICROPY_PORT_INIT_FUNC - MICROPY_PORT_INIT_FUNC; -#endif - - // optimization disabled by default - MP_STATE_VM(mp_optimise_value) = 0; - - // init global module dict - mp_obj_dict_init(&MP_STATE_VM(mp_loaded_modules_dict), 3); - - // initialise the __main__ module - mp_obj_dict_init(&MP_STATE_VM(dict_main), 1); - mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(dict_main)), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - - // locals = globals for outer module (see Objects/frameobject.c/PyFrame_New()) - mp_locals_set(&MP_STATE_VM(dict_main)); - mp_globals_set(&MP_STATE_VM(dict_main)); - - #if MICROPY_CAN_OVERRIDE_BUILTINS - // start with no extensions to builtins - MP_STATE_VM(mp_module_builtins_override_dict) = NULL; - #endif - - #if MICROPY_FSUSERMOUNT - // zero out the pointers to the user-mounted devices - memset(MP_STATE_VM(fs_user_mount), 0, sizeof(MP_STATE_VM(fs_user_mount))); - #endif - - #if MICROPY_VFS - // initialise the VFS sub-system - MP_STATE_VM(vfs_cur) = NULL; - MP_STATE_VM(vfs_mount_table) = NULL; - #endif - - #if MICROPY_PY_THREAD_GIL - mp_thread_mutex_init(&MP_STATE_VM(gil_mutex)); - #endif - - MP_THREAD_GIL_ENTER(); -} - -void mp_deinit(void) { - //mp_obj_dict_free(&dict_main); - //mp_map_deinit(&MP_STATE_VM(mp_loaded_modules_map)); - - // call port specific deinitialization if any -#ifdef MICROPY_PORT_INIT_FUNC - MICROPY_PORT_DEINIT_FUNC; -#endif -} - -mp_obj_t mp_load_name(qstr qst) { - // logic: search locals, globals, builtins - DEBUG_OP_printf("load name %s\n", qstr_str(qst)); - // If we're at the outer scope (locals == globals), dispatch to load_global right away - if (mp_locals_get() != mp_globals_get()) { - mp_map_elem_t *elem = mp_map_lookup(&mp_locals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); - if (elem != NULL) { - return elem->value; - } - } - return mp_load_global(qst); -} - -mp_obj_t mp_load_global(qstr qst) { - // logic: search globals, builtins - DEBUG_OP_printf("load global %s\n", qstr_str(qst)); - mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); - if (elem == NULL) { - #if MICROPY_CAN_OVERRIDE_BUILTINS - if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) { - // lookup in additional dynamic table of builtins first - elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); - if (elem != NULL) { - return elem->value; - } - } - #endif - elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); - if (elem == NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_msg(&mp_type_NameError, "name not defined"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError, - "name '%q' is not defined", qst)); - } - } - } - return elem->value; -} - -mp_obj_t mp_load_build_class(void) { - DEBUG_OP_printf("load_build_class\n"); - #if MICROPY_CAN_OVERRIDE_BUILTINS - if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) { - // lookup in additional dynamic table of builtins first - mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(MP_QSTR___build_class__), MP_MAP_LOOKUP); - if (elem != NULL) { - return elem->value; - } - } - #endif - return MP_OBJ_FROM_PTR(&mp_builtin___build_class___obj); -} - -void mp_store_name(qstr qst, mp_obj_t obj) { - DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qst), obj); - mp_obj_dict_store(MP_OBJ_FROM_PTR(mp_locals_get()), MP_OBJ_NEW_QSTR(qst), obj); -} - -void mp_delete_name(qstr qst) { - DEBUG_OP_printf("delete name %s\n", qstr_str(qst)); - // TODO convert KeyError to NameError if qst not found - mp_obj_dict_delete(MP_OBJ_FROM_PTR(mp_locals_get()), MP_OBJ_NEW_QSTR(qst)); -} - -void mp_store_global(qstr qst, mp_obj_t obj) { - DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qst), obj); - mp_obj_dict_store(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(qst), obj); -} - -void mp_delete_global(qstr qst) { - DEBUG_OP_printf("delete global %s\n", qstr_str(qst)); - // TODO convert KeyError to NameError if qst not found - mp_obj_dict_delete(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(qst)); -} - -mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) { - DEBUG_OP_printf("unary " UINT_FMT " %p\n", op, arg); - - if (op == MP_UNARY_OP_NOT) { - // "not x" is the negative of whether "x" is true per Python semantics - return mp_obj_new_bool(mp_obj_is_true(arg) == 0); - } else if (MP_OBJ_IS_SMALL_INT(arg)) { - mp_int_t val = MP_OBJ_SMALL_INT_VALUE(arg); - switch (op) { - case MP_UNARY_OP_BOOL: - return mp_obj_new_bool(val != 0); - case MP_UNARY_OP_HASH: - return arg; - case MP_UNARY_OP_POSITIVE: - return arg; - case MP_UNARY_OP_NEGATIVE: - // check for overflow - if (val == MP_SMALL_INT_MIN) { - return mp_obj_new_int(-val); - } else { - return MP_OBJ_NEW_SMALL_INT(-val); - } - default: - assert(op == MP_UNARY_OP_INVERT); - return MP_OBJ_NEW_SMALL_INT(~val); - } - } else if (op == MP_UNARY_OP_HASH && MP_OBJ_IS_STR_OR_BYTES(arg)) { - // fast path for hashing str/bytes - GET_STR_HASH(arg, h); - if (h == 0) { - GET_STR_DATA_LEN(arg, data, len); - h = qstr_compute_hash(data, len); - } - return MP_OBJ_NEW_SMALL_INT(h); - } else { - mp_obj_type_t *type = mp_obj_get_type(arg); - if (type->unary_op != NULL) { - mp_obj_t result = type->unary_op(op, arg); - if (result != MP_OBJ_NULL) { - return result; - } - } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("unsupported type for operator"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "unsupported type for %q: '%s'", - mp_unary_op_method_name[op], mp_obj_get_type_str(arg))); - } - } -} - -mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) { - DEBUG_OP_printf("binary " UINT_FMT " %p %p\n", op, lhs, rhs); - - // TODO correctly distinguish inplace operators for mutable objects - // lookup logic that CPython uses for +=: - // check for implemented += - // then check for implemented + - // then check for implemented seq.inplace_concat - // then check for implemented seq.concat - // then fail - // note that list does not implement + or +=, so that inplace_concat is reached first for += - - // deal with is - if (op == MP_BINARY_OP_IS) { - return mp_obj_new_bool(lhs == rhs); - } - - // deal with == and != for all types - if (op == MP_BINARY_OP_EQUAL || op == MP_BINARY_OP_NOT_EQUAL) { - if (mp_obj_equal(lhs, rhs)) { - if (op == MP_BINARY_OP_EQUAL) { - return mp_const_true; - } else { - return mp_const_false; - } - } else { - if (op == MP_BINARY_OP_EQUAL) { - return mp_const_false; - } else { - return mp_const_true; - } - } - } - - // deal with exception_match for all types - if (op == MP_BINARY_OP_EXCEPTION_MATCH) { - // rhs must be issubclass(rhs, BaseException) - if (mp_obj_is_exception_type(rhs)) { - if (mp_obj_exception_match(lhs, rhs)) { - return mp_const_true; - } else { - return mp_const_false; - } - } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_tuple)) { - mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(rhs); - for (size_t i = 0; i < tuple->len; i++) { - rhs = tuple->items[i]; - if (!mp_obj_is_exception_type(rhs)) { - goto unsupported_op; - } - if (mp_obj_exception_match(lhs, rhs)) { - return mp_const_true; - } - } - return mp_const_false; - } - goto unsupported_op; - } - - if (MP_OBJ_IS_SMALL_INT(lhs)) { - mp_int_t lhs_val = MP_OBJ_SMALL_INT_VALUE(lhs); - if (MP_OBJ_IS_SMALL_INT(rhs)) { - mp_int_t rhs_val = MP_OBJ_SMALL_INT_VALUE(rhs); - // This is a binary operation: lhs_val op rhs_val - // We need to be careful to handle overflow; see CERT INT32-C - // Operations that can overflow: - // + result always fits in mp_int_t, then handled by SMALL_INT check - // - result always fits in mp_int_t, then handled by SMALL_INT check - // * checked explicitly - // / if lhs=MIN and rhs=-1; result always fits in mp_int_t, then handled by SMALL_INT check - // % if lhs=MIN and rhs=-1; result always fits in mp_int_t, then handled by SMALL_INT check - // << checked explicitly - switch (op) { - case MP_BINARY_OP_OR: - case MP_BINARY_OP_INPLACE_OR: lhs_val |= rhs_val; break; - case MP_BINARY_OP_XOR: - case MP_BINARY_OP_INPLACE_XOR: lhs_val ^= rhs_val; break; - case MP_BINARY_OP_AND: - case MP_BINARY_OP_INPLACE_AND: lhs_val &= rhs_val; break; - case MP_BINARY_OP_LSHIFT: - case MP_BINARY_OP_INPLACE_LSHIFT: { - if (rhs_val < 0) { - // negative shift not allowed - mp_raise_ValueError("negative shift count"); - } else if (rhs_val >= (mp_int_t)BITS_PER_WORD || lhs_val > (MP_SMALL_INT_MAX >> rhs_val) || lhs_val < (MP_SMALL_INT_MIN >> rhs_val)) { - // left-shift will overflow, so use higher precision integer - lhs = mp_obj_new_int_from_ll(lhs_val); - goto generic_binary_op; - } else { - // use standard precision - lhs_val <<= rhs_val; - } - break; - } - case MP_BINARY_OP_RSHIFT: - case MP_BINARY_OP_INPLACE_RSHIFT: - if (rhs_val < 0) { - // negative shift not allowed - mp_raise_ValueError("negative shift count"); - } else { - // standard precision is enough for right-shift - if (rhs_val >= (mp_int_t)BITS_PER_WORD) { - // Shifting to big amounts is underfined behavior - // in C and is CPU-dependent; propagate sign bit. - rhs_val = BITS_PER_WORD - 1; - } - lhs_val >>= rhs_val; - } - break; - case MP_BINARY_OP_ADD: - case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break; - case MP_BINARY_OP_SUBTRACT: - case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break; - case MP_BINARY_OP_MULTIPLY: - case MP_BINARY_OP_INPLACE_MULTIPLY: { - - // If long long type exists and is larger than mp_int_t, then - // we can use the following code to perform overflow-checked multiplication. - // Otherwise (eg in x64 case) we must use mp_small_int_mul_overflow. - #if 0 - // compute result using long long precision - long long res = (long long)lhs_val * (long long)rhs_val; - if (res > MP_SMALL_INT_MAX || res < MP_SMALL_INT_MIN) { - // result overflowed SMALL_INT, so return higher precision integer - return mp_obj_new_int_from_ll(res); - } else { - // use standard precision - lhs_val = (mp_int_t)res; - } - #endif - - if (mp_small_int_mul_overflow(lhs_val, rhs_val)) { - // use higher precision - lhs = mp_obj_new_int_from_ll(lhs_val); - goto generic_binary_op; - } else { - // use standard precision - return MP_OBJ_NEW_SMALL_INT(lhs_val * rhs_val); - } - break; - } - case MP_BINARY_OP_FLOOR_DIVIDE: - case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: - if (rhs_val == 0) { - goto zero_division; - } - lhs_val = mp_small_int_floor_divide(lhs_val, rhs_val); - break; - - #if MICROPY_PY_BUILTINS_FLOAT - case MP_BINARY_OP_TRUE_DIVIDE: - case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: - if (rhs_val == 0) { - goto zero_division; - } - return mp_obj_new_float((mp_float_t)lhs_val / (mp_float_t)rhs_val); - #endif - - case MP_BINARY_OP_MODULO: - case MP_BINARY_OP_INPLACE_MODULO: { - if (rhs_val == 0) { - goto zero_division; - } - lhs_val = mp_small_int_modulo(lhs_val, rhs_val); - break; - } - - case MP_BINARY_OP_POWER: - case MP_BINARY_OP_INPLACE_POWER: - if (rhs_val < 0) { - #if MICROPY_PY_BUILTINS_FLOAT - lhs = mp_obj_new_float(lhs_val); - goto generic_binary_op; - #else - mp_raise_ValueError("negative power with no float support"); - #endif - } else { - mp_int_t ans = 1; - while (rhs_val > 0) { - if (rhs_val & 1) { - if (mp_small_int_mul_overflow(ans, lhs_val)) { - goto power_overflow; - } - ans *= lhs_val; - } - if (rhs_val == 1) { - break; - } - rhs_val /= 2; - if (mp_small_int_mul_overflow(lhs_val, lhs_val)) { - goto power_overflow; - } - lhs_val *= lhs_val; - } - lhs_val = ans; - } - break; - - power_overflow: - // use higher precision - lhs = mp_obj_new_int_from_ll(MP_OBJ_SMALL_INT_VALUE(lhs)); - goto generic_binary_op; - - case MP_BINARY_OP_DIVMOD: { - if (rhs_val == 0) { - goto zero_division; - } - // to reduce stack usage we don't pass a temp array of the 2 items - mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL)); - tuple->items[0] = MP_OBJ_NEW_SMALL_INT(mp_small_int_floor_divide(lhs_val, rhs_val)); - tuple->items[1] = MP_OBJ_NEW_SMALL_INT(mp_small_int_modulo(lhs_val, rhs_val)); - return MP_OBJ_FROM_PTR(tuple); - } - - case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val); break; - case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val); break; - case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val); break; - case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val); break; - - default: - goto unsupported_op; - } - // TODO: We just should make mp_obj_new_int() inline and use that - if (MP_SMALL_INT_FITS(lhs_val)) { - return MP_OBJ_NEW_SMALL_INT(lhs_val); - } else { - return mp_obj_new_int(lhs_val); - } -#if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_float(rhs)) { - mp_obj_t res = mp_obj_float_binary_op(op, lhs_val, rhs); - if (res == MP_OBJ_NULL) { - goto unsupported_op; - } else { - return res; - } -#if MICROPY_PY_BUILTINS_COMPLEX - } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_complex)) { - mp_obj_t res = mp_obj_complex_binary_op(op, lhs_val, 0, rhs); - if (res == MP_OBJ_NULL) { - goto unsupported_op; - } else { - return res; - } -#endif -#endif - } - } - - /* deal with `in` - * - * NOTE `a in b` is `b.__contains__(a)`, hence why the generic dispatch - * needs to go below with swapped arguments - */ - if (op == MP_BINARY_OP_IN) { - mp_obj_type_t *type = mp_obj_get_type(rhs); - if (type->binary_op != NULL) { - mp_obj_t res = type->binary_op(op, rhs, lhs); - if (res != MP_OBJ_NULL) { - return res; - } - } - if (type->getiter != NULL) { - /* second attempt, walk the iterator */ - mp_obj_iter_buf_t iter_buf; - mp_obj_t iter = mp_getiter(rhs, &iter_buf); - mp_obj_t next; - while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - if (mp_obj_equal(next, lhs)) { - return mp_const_true; - } - } - return mp_const_false; - } - - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object not iterable"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not iterable", mp_obj_get_type_str(rhs))); - } - } - - // generic binary_op supplied by type - mp_obj_type_t *type; -generic_binary_op: - type = mp_obj_get_type(lhs); - if (type->binary_op != NULL) { - mp_obj_t result = type->binary_op(op, lhs, rhs); - if (result != MP_OBJ_NULL) { - return result; - } - } - - // TODO implement dispatch for reverse binary ops - -unsupported_op: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("unsupported type for operator"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "unsupported types for %q: '%s', '%s'", - mp_binary_op_method_name[op], mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs))); - } - -zero_division: - mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); -} - -mp_obj_t mp_call_function_0(mp_obj_t fun) { - return mp_call_function_n_kw(fun, 0, 0, NULL); -} - -mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg) { - return mp_call_function_n_kw(fun, 1, 0, &arg); -} - -mp_obj_t mp_call_function_2(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { - mp_obj_t args[2]; - args[0] = arg1; - args[1] = arg2; - return mp_call_function_n_kw(fun, 2, 0, args); -} - -// args contains, eg: arg0 arg1 key0 value0 key1 value1 -mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - // TODO improve this: fun object can specify its type and we parse here the arguments, - // passing to the function arrays of fixed and keyword arguments - - DEBUG_OP_printf("calling function %p(n_args=" UINT_FMT ", n_kw=" UINT_FMT ", args=%p)\n", fun_in, n_args, n_kw, args); - - // get the type - mp_obj_type_t *type = mp_obj_get_type(fun_in); - - // do the call - if (type->call != NULL) { - return type->call(fun_in, n_args, n_kw, args); - } - - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object not callable"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not callable", mp_obj_get_type_str(fun_in))); - } -} - -// args contains: fun self/NULL arg(0) ... arg(n_args-2) arg(n_args-1) kw_key(0) kw_val(0) ... kw_key(n_kw-1) kw_val(n_kw-1) -// if n_args==0 and n_kw==0 then there are only fun and self/NULL -mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args) { - DEBUG_OP_printf("call method (fun=%p, self=%p, n_args=" UINT_FMT ", n_kw=" UINT_FMT ", args=%p)\n", args[0], args[1], n_args, n_kw, args); - int adjust = (args[1] == MP_OBJ_NULL) ? 0 : 1; - return mp_call_function_n_kw(args[0], n_args + adjust, n_kw, args + 2 - adjust); -} - -// This function only needs to be exposed externally when in stackless mode. -#if !MICROPY_STACKLESS -STATIC -#endif -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) { - mp_obj_t fun = *args++; - mp_obj_t self = MP_OBJ_NULL; - if (have_self) { - self = *args++; // may be MP_OBJ_NULL - } - uint n_args = n_args_n_kw & 0xff; - uint n_kw = (n_args_n_kw >> 8) & 0xff; - mp_obj_t pos_seq = args[n_args + 2 * n_kw]; // may be MP_OBJ_NULL - mp_obj_t kw_dict = args[n_args + 2 * n_kw + 1]; // may be MP_OBJ_NULL - - DEBUG_OP_printf("call method var (fun=%p, self=%p, n_args=%u, n_kw=%u, args=%p, seq=%p, dict=%p)\n", fun, self, n_args, n_kw, args, pos_seq, kw_dict); - - // We need to create the following array of objects: - // args[0 .. n_args] unpacked(pos_seq) args[n_args .. n_args + 2 * n_kw] unpacked(kw_dict) - // TODO: optimize one day to avoid constructing new arg array? Will be hard. - - // The new args array - mp_obj_t *args2; - uint args2_alloc; - uint args2_len = 0; - - // Try to get a hint for the size of the kw_dict - uint kw_dict_len = 0; - if (kw_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(kw_dict, &mp_type_dict)) { - kw_dict_len = mp_obj_dict_len(kw_dict); - } - - // Extract the pos_seq sequence to the new args array. - // Note that it can be arbitrary iterator. - if (pos_seq == MP_OBJ_NULL) { - // no sequence - - // allocate memory for the new array of args - args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len); - args2 = m_new(mp_obj_t, args2_alloc); - - // copy the self - if (self != MP_OBJ_NULL) { - args2[args2_len++] = self; - } - - // copy the fixed pos args - mp_seq_copy(args2 + args2_len, args, n_args, mp_obj_t); - args2_len += n_args; - - } else if (MP_OBJ_IS_TYPE(pos_seq, &mp_type_tuple) || MP_OBJ_IS_TYPE(pos_seq, &mp_type_list)) { - // optimise the case of a tuple and list - - // get the items - size_t len; - mp_obj_t *items; - mp_obj_get_array(pos_seq, &len, &items); - - // allocate memory for the new array of args - args2_alloc = 1 + n_args + len + 2 * (n_kw + kw_dict_len); - args2 = m_new(mp_obj_t, args2_alloc); - - // copy the self - if (self != MP_OBJ_NULL) { - args2[args2_len++] = self; - } - - // copy the fixed and variable position args - mp_seq_cat(args2 + args2_len, args, n_args, items, len, mp_obj_t); - args2_len += n_args + len; - - } else { - // generic iterator - - // allocate memory for the new array of args - args2_alloc = 1 + n_args + 2 * (n_kw + kw_dict_len) + 3; - args2 = m_new(mp_obj_t, args2_alloc); - - // copy the self - if (self != MP_OBJ_NULL) { - args2[args2_len++] = self; - } - - // copy the fixed position args - mp_seq_copy(args2 + args2_len, args, n_args, mp_obj_t); - args2_len += n_args; - - // extract the variable position args from the iterator - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(pos_seq, &iter_buf); - mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - if (args2_len >= args2_alloc) { - args2 = m_renew(mp_obj_t, args2, args2_alloc, args2_alloc * 2); - args2_alloc *= 2; - } - args2[args2_len++] = item; - } - } - - // The size of the args2 array now is the number of positional args. - uint pos_args_len = args2_len; - - // Copy the fixed kw args. - mp_seq_copy(args2 + args2_len, args + n_args, 2 * n_kw, mp_obj_t); - args2_len += 2 * n_kw; - - // Extract (key,value) pairs from kw_dict dictionary and append to args2. - // Note that it can be arbitrary iterator. - if (kw_dict == MP_OBJ_NULL) { - // pass - } else if (MP_OBJ_IS_TYPE(kw_dict, &mp_type_dict)) { - // dictionary - mp_map_t *map = mp_obj_dict_get_map(kw_dict); - assert(args2_len + 2 * map->used <= args2_alloc); // should have enough, since kw_dict_len is in this case hinted correctly above - for (size_t i = 0; i < map->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - // the key must be a qstr, so intern it if it's a string - mp_obj_t key = map->table[i].key; - if (MP_OBJ_IS_TYPE(key, &mp_type_str)) { - key = mp_obj_str_intern(key); - } - args2[args2_len++] = key; - args2[args2_len++] = map->table[i].value; - } - } - } else { - // generic mapping: - // - call keys() to get an iterable of all keys in the mapping - // - call __getitem__ for each key to get the corresponding value - - // get the keys iterable - mp_obj_t dest[3]; - mp_load_method(kw_dict, MP_QSTR_keys, dest); - mp_obj_t iterable = mp_getiter(mp_call_method_n_kw(0, 0, dest), NULL); - - mp_obj_t key; - while ((key = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - // expand size of args array if needed - if (args2_len + 1 >= args2_alloc) { - uint new_alloc = args2_alloc * 2; - if (new_alloc < 4) { - new_alloc = 4; - } - args2 = m_renew(mp_obj_t, args2, args2_alloc, new_alloc); - args2_alloc = new_alloc; - } - - // the key must be a qstr, so intern it if it's a string - if (MP_OBJ_IS_TYPE(key, &mp_type_str)) { - key = mp_obj_str_intern(key); - } - - // get the value corresponding to the key - mp_load_method(kw_dict, MP_QSTR___getitem__, dest); - dest[2] = key; - mp_obj_t value = mp_call_method_n_kw(1, 0, dest); - - // store the key/value pair in the argument array - args2[args2_len++] = key; - args2[args2_len++] = value; - } - } - - out_args->fun = fun; - out_args->args = args2; - out_args->n_args = pos_args_len; - out_args->n_kw = (args2_len - pos_args_len) / 2; - out_args->n_alloc = args2_alloc; -} - -mp_obj_t mp_call_method_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args) { - mp_call_args_t out_args; - mp_call_prepare_args_n_kw_var(have_self, n_args_n_kw, args, &out_args); - - mp_obj_t res = mp_call_function_n_kw(out_args.fun, out_args.n_args, out_args.n_kw, out_args.args); - m_del(mp_obj_t, out_args.args, out_args.n_alloc); - - return res; -} - -// unpacked items are stored in reverse order into the array pointed to by items -void mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) { - size_t seq_len; - if (MP_OBJ_IS_TYPE(seq_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(seq_in, &mp_type_list)) { - mp_obj_t *seq_items; - mp_obj_get_array(seq_in, &seq_len, &seq_items); - if (seq_len < num) { - goto too_short; - } else if (seq_len > num) { - goto too_long; - } - for (size_t i = 0; i < num; i++) { - items[i] = seq_items[num - 1 - i]; - } - } else { - mp_obj_iter_buf_t iter_buf; - mp_obj_t iterable = mp_getiter(seq_in, &iter_buf); - - for (seq_len = 0; seq_len < num; seq_len++) { - mp_obj_t el = mp_iternext(iterable); - if (el == MP_OBJ_STOP_ITERATION) { - goto too_short; - } - items[num - 1 - seq_len] = el; - } - if (mp_iternext(iterable) != MP_OBJ_STOP_ITERATION) { - goto too_long; - } - } - return; - -too_short: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_ValueError("wrong number of values to unpack"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "need more than %d values to unpack", (int)seq_len)); - } -too_long: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_ValueError("wrong number of values to unpack"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "too many values to unpack (expected %d)", (int)num)); - } -} - -// unpacked items are stored in reverse order into the array pointed to by items -void mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) { - size_t num_left = num_in & 0xff; - size_t num_right = (num_in >> 8) & 0xff; - DEBUG_OP_printf("unpack ex " UINT_FMT " " UINT_FMT "\n", num_left, num_right); - size_t seq_len; - if (MP_OBJ_IS_TYPE(seq_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(seq_in, &mp_type_list)) { - mp_obj_t *seq_items; - mp_obj_get_array(seq_in, &seq_len, &seq_items); - if (seq_len < num_left + num_right) { - goto too_short; - } - for (size_t i = 0; i < num_right; i++) { - items[i] = seq_items[seq_len - 1 - i]; - } - items[num_right] = mp_obj_new_list(seq_len - num_left - num_right, seq_items + num_left); - for (size_t i = 0; i < num_left; i++) { - items[num_right + 1 + i] = seq_items[num_left - 1 - i]; - } - } else { - // Generic iterable; this gets a bit messy: we unpack known left length to the - // items destination array, then the rest to a dynamically created list. Once the - // iterable is exhausted, we take from this list for the right part of the items. - // TODO Improve to waste less memory in the dynamically created list. - mp_obj_t iterable = mp_getiter(seq_in, NULL); - mp_obj_t item; - for (seq_len = 0; seq_len < num_left; seq_len++) { - item = mp_iternext(iterable); - if (item == MP_OBJ_STOP_ITERATION) { - goto too_short; - } - items[num_left + num_right + 1 - 1 - seq_len] = item; - } - mp_obj_list_t *rest = MP_OBJ_TO_PTR(mp_obj_new_list(0, NULL)); - while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(MP_OBJ_FROM_PTR(rest), item); - } - if (rest->len < num_right) { - goto too_short; - } - items[num_right] = MP_OBJ_FROM_PTR(rest); - for (size_t i = 0; i < num_right; i++) { - items[num_right - 1 - i] = rest->items[rest->len - num_right + i]; - } - mp_obj_list_set_len(MP_OBJ_FROM_PTR(rest), rest->len - num_right); - } - return; - -too_short: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_ValueError("wrong number of values to unpack"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "need more than %d values to unpack", (int)seq_len)); - } -} - -mp_obj_t mp_load_attr(mp_obj_t base, qstr attr) { - DEBUG_OP_printf("load attr %p.%s\n", base, qstr_str(attr)); - // use load_method - mp_obj_t dest[2]; - mp_load_method(base, attr, dest); - if (dest[1] == MP_OBJ_NULL) { - // load_method returned just a normal attribute - return dest[0]; - } else { - // load_method returned a method, so build a bound method object - return mp_obj_new_bound_meth(dest[0], dest[1]); - } -} - -#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG - -// The following "checked fun" type is local to the mp_convert_member_lookup -// function, and serves to check that the first argument to a builtin function -// has the correct type. - -typedef struct _mp_obj_checked_fun_t { - mp_obj_base_t base; - const mp_obj_type_t *type; - mp_obj_t fun; -} mp_obj_checked_fun_t; - -STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_obj_checked_fun_t *self = MP_OBJ_TO_PTR(self_in); - if (n_args > 0) { - const mp_obj_type_t *arg0_type = mp_obj_get_type(args[0]); - if (arg0_type != self->type) { - if (MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_DETAILED) { - mp_raise_TypeError("argument has wrong type"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "argument should be a '%q' not a '%q'", self->type->name, arg0_type->name)); - } - } - } - return mp_call_function_n_kw(self->fun, n_args, n_kw, args); -} - -STATIC const mp_obj_type_t mp_type_checked_fun = { - { &mp_type_type }, - .name = MP_QSTR_function, - .call = checked_fun_call, -}; - -STATIC mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) { - mp_obj_checked_fun_t *o = m_new_obj(mp_obj_checked_fun_t); - o->base.type = &mp_type_checked_fun; - o->type = type; - o->fun = fun; - return MP_OBJ_FROM_PTR(o); -} - -#endif // MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG - -// Given a member that was extracted from an instance, convert it correctly -// and put the result in the dest[] array for a possible method call. -// Conversion means dealing with static/class methods, callables, and values. -// see http://docs.python.org/3/howto/descriptor.html -void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest) { - if (MP_OBJ_IS_TYPE(member, &mp_type_staticmethod)) { - // return just the function - dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun; - } else if (MP_OBJ_IS_TYPE(member, &mp_type_classmethod)) { - // return a bound method, with self being the type of this object - // this type should be the type of the original instance, not the base - // type (which is what is passed in the 'type' argument to this function) - if (self != MP_OBJ_NULL) { - type = mp_obj_get_type(self); - } - dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun; - dest[1] = MP_OBJ_FROM_PTR(type); - } else if (MP_OBJ_IS_TYPE(member, &mp_type_type)) { - // Don't try to bind types (even though they're callable) - dest[0] = member; - } else if (MP_OBJ_IS_FUN(member) - || (MP_OBJ_IS_OBJ(member) - && (((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_closure - || ((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_generator))) { - // only functions, closures and generators objects can be bound to self - #if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG - const mp_obj_type_t *m_type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type; - if (self == MP_OBJ_NULL - && (m_type == &mp_type_fun_builtin_0 - || m_type == &mp_type_fun_builtin_1 - || m_type == &mp_type_fun_builtin_2 - || m_type == &mp_type_fun_builtin_3 - || m_type == &mp_type_fun_builtin_var)) { - // we extracted a builtin method without a first argument, so we must - // wrap this function in a type checker - dest[0] = mp_obj_new_checked_fun(type, member); - } else - #endif - { - // return a bound method, with self being this object - dest[0] = member; - dest[1] = self; - } - } else { - // class member is a value, so just return that value - dest[0] = member; - } -} - -// no attribute found, returns: dest[0] == MP_OBJ_NULL, dest[1] == MP_OBJ_NULL -// normal attribute found, returns: dest[0] == , dest[1] == MP_OBJ_NULL -// method attribute found, returns: dest[0] == , dest[1] == -void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { - // clear output to indicate no attribute/method found yet - dest[0] = MP_OBJ_NULL; - dest[1] = MP_OBJ_NULL; - - // get the type - mp_obj_type_t *type = mp_obj_get_type(obj); - - // look for built-in names - if (0) { -#if MICROPY_CPYTHON_COMPAT - } else if (attr == MP_QSTR___class__) { - // a.__class__ is equivalent to type(a) - dest[0] = MP_OBJ_FROM_PTR(type); -#endif - - } else if (attr == MP_QSTR___next__ && type->iternext != NULL) { - dest[0] = MP_OBJ_FROM_PTR(&mp_builtin_next_obj); - dest[1] = obj; - - } else if (type->attr != NULL) { - // this type can do its own load, so call it - type->attr(obj, attr, dest); - - } else if (type->locals_dict != NULL) { - // generic method lookup - // this is a lookup in the object (ie not class or type) - assert(type->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now - mp_map_t *locals_map = &type->locals_dict->map; - mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); - if (elem != NULL) { - mp_convert_member_lookup(obj, type, elem->value, dest); - } - } -} - -void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { - DEBUG_OP_printf("load method %p.%s\n", base, qstr_str(attr)); - - mp_load_method_maybe(base, attr, dest); - - if (dest[0] == MP_OBJ_NULL) { - // no attribute/method called attr - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_msg(&mp_type_AttributeError, "no such attribute"); - } else { - // following CPython, we give a more detailed error message for type objects - if (MP_OBJ_IS_TYPE(base, &mp_type_type)) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, - "type object '%q' has no attribute '%q'", - ((mp_obj_type_t*)MP_OBJ_TO_PTR(base))->name, attr)); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, - "'%s' object has no attribute '%q'", - mp_obj_get_type_str(base), attr)); - } - } - } -} - -void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { - DEBUG_OP_printf("store attr %p.%s <- %p\n", base, qstr_str(attr), value); - mp_obj_type_t *type = mp_obj_get_type(base); - if (type->attr != NULL) { - mp_obj_t dest[2] = {MP_OBJ_SENTINEL, value}; - type->attr(base, attr, dest); - if (dest[0] == MP_OBJ_NULL) { - // success - return; - } - } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_msg(&mp_type_AttributeError, "no such attribute"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, - "'%s' object has no attribute '%q'", - mp_obj_get_type_str(base), attr)); - } -} - -mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { - assert(o_in); - mp_obj_type_t *type = mp_obj_get_type(o_in); - - // Check for native getiter which is the identity. We handle this case explicitly - // so we don't unnecessarily allocate any RAM for the iter_buf, which won't be used. - if (type->getiter == mp_identity_getiter) { - return o_in; - } - - // if caller did not provide a buffer then allocate one on the heap - if (iter_buf == NULL) { - iter_buf = m_new_obj(mp_obj_iter_buf_t); - } - - // check for native getiter (corresponds to __iter__) - if (type->getiter != NULL) { - mp_obj_t iter = type->getiter(o_in, iter_buf); - if (iter != MP_OBJ_NULL) { - return iter; - } - } - - // check for __getitem__ - mp_obj_t dest[2]; - mp_load_method_maybe(o_in, MP_QSTR___getitem__, dest); - if (dest[0] != MP_OBJ_NULL) { - // __getitem__ exists, create and return an iterator - return mp_obj_new_getitem_iter(dest, iter_buf); - } - - // object not iterable - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object not iterable"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not iterable", mp_obj_get_type_str(o_in))); - } -} - -// may return MP_OBJ_STOP_ITERATION as an optimisation instead of raise StopIteration() -// may also raise StopIteration() -mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->iternext != NULL) { - return type->iternext(o_in); - } else { - // check for __next__ method - mp_obj_t dest[2]; - mp_load_method_maybe(o_in, MP_QSTR___next__, dest); - if (dest[0] != MP_OBJ_NULL) { - // __next__ exists, call it and return its result - return mp_call_method_n_kw(0, 0, dest); - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object not an iterator"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not an iterator", mp_obj_get_type_str(o_in))); - } - } - } -} - -// will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration() (or any subclass thereof) -// may raise other exceptions -mp_obj_t mp_iternext(mp_obj_t o_in) { - MP_STACK_CHECK(); // enumerate, filter, map and zip can recursively call mp_iternext - mp_obj_type_t *type = mp_obj_get_type(o_in); - if (type->iternext != NULL) { - return type->iternext(o_in); - } else { - // check for __next__ method - mp_obj_t dest[2]; - mp_load_method_maybe(o_in, MP_QSTR___next__, dest); - if (dest[0] != MP_OBJ_NULL) { - // __next__ exists, call it and return its result - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_obj_t ret = mp_call_method_n_kw(0, 0, dest); - nlr_pop(); - return ret; - } else { - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { - return MP_OBJ_STOP_ITERATION; - } else { - nlr_jump(nlr.ret_val); - } - } - } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("object not an iterator"); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - "'%s' object is not an iterator", mp_obj_get_type_str(o_in))); - } - } - } -} - -// TODO: Unclear what to do with StopIterarion exception here. -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) { - assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL)); - mp_obj_type_t *type = mp_obj_get_type(self_in); - - if (type == &mp_type_gen_instance) { - return mp_obj_gen_resume(self_in, send_value, throw_value, ret_val); - } - - if (type->iternext != NULL && send_value == mp_const_none) { - mp_obj_t ret = type->iternext(self_in); - if (ret != MP_OBJ_STOP_ITERATION) { - *ret_val = ret; - return MP_VM_RETURN_YIELD; - } else { - // Emulate raise StopIteration() - // Special case, handled in vm.c - *ret_val = MP_OBJ_NULL; - return MP_VM_RETURN_NORMAL; - } - } - - mp_obj_t dest[3]; // Reserve slot for send() arg - - // Python instance iterator protocol - if (send_value == mp_const_none) { - mp_load_method_maybe(self_in, MP_QSTR___next__, dest); - if (dest[0] != MP_OBJ_NULL) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - *ret_val = mp_call_method_n_kw(0, 0, dest); - nlr_pop(); - return MP_VM_RETURN_YIELD; - } else { - *ret_val = MP_OBJ_FROM_PTR(nlr.ret_val); - return MP_VM_RETURN_EXCEPTION; - } - } - } - - // Either python instance generator protocol, or native object - // generator protocol. - if (send_value != MP_OBJ_NULL) { - mp_load_method(self_in, MP_QSTR_send, dest); - dest[2] = send_value; - // TODO: This should have exception wrapping like __next__ case - // above. Not done right away to think how to optimize native - // generators better, see: - // https://github.com/micropython/micropython/issues/2628 - *ret_val = mp_call_method_n_kw(1, 0, dest); - return MP_VM_RETURN_YIELD; - } - - assert(throw_value != MP_OBJ_NULL); - { - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(throw_value)), MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) { - mp_load_method_maybe(self_in, MP_QSTR_close, dest); - if (dest[0] != MP_OBJ_NULL) { - // TODO: Exceptions raised in close() are not propagated, - // printed to sys.stderr - *ret_val = mp_call_method_n_kw(0, 0, dest); - // We assume one can't "yield" from close() - return MP_VM_RETURN_NORMAL; - } - } else { - mp_load_method_maybe(self_in, MP_QSTR_throw, dest); - if (dest[0] != MP_OBJ_NULL) { - dest[2] = throw_value; - *ret_val = mp_call_method_n_kw(1, 0, dest); - // If .throw() method returned, we assume it's value to yield - // - any exception would be thrown with nlr_raise(). - return MP_VM_RETURN_YIELD; - } - } - // If there's nowhere to throw exception into, then we assume that object - // is just incapable to handle it, so any exception thrown into it - // will be propagated up. This behavior is approved by test_pep380.py - // test_delegation_of_close_to_non_generator(), - // test_delegating_throw_to_non_generator() - *ret_val = throw_value; - return MP_VM_RETURN_EXCEPTION; - } -} - -mp_obj_t mp_make_raise_obj(mp_obj_t o) { - DEBUG_printf("raise %p\n", o); - if (mp_obj_is_exception_type(o)) { - // o is an exception type (it is derived from BaseException (or is BaseException)) - // create and return a new exception instance by calling o - // TODO could have an option to disable traceback, then builtin exceptions (eg TypeError) - // could have const instances in ROM which we return here instead - return mp_call_function_n_kw(o, 0, 0, NULL); - } else if (mp_obj_is_exception_instance(o)) { - // o is an instance of an exception, so use it as the exception - return o; - } else { - // o cannot be used as an exception, so return a type error (which will be raised by the caller) - return mp_obj_new_exception_msg(&mp_type_TypeError, "exceptions must derive from BaseException"); - } -} - -mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level) { - DEBUG_printf("import name '%s' level=%d\n", qstr_str(name), MP_OBJ_SMALL_INT_VALUE(level)); - - // build args array - mp_obj_t args[5]; - args[0] = MP_OBJ_NEW_QSTR(name); - args[1] = mp_const_none; // TODO should be globals - args[2] = mp_const_none; // TODO should be locals - args[3] = fromlist; - args[4] = level; // must be 0; we don't yet support other values - - // TODO lookup __import__ and call that instead of going straight to builtin implementation - return mp_builtin___import__(5, args); -} - -mp_obj_t mp_import_from(mp_obj_t module, qstr name) { - DEBUG_printf("import from %p %s\n", module, qstr_str(name)); - - mp_obj_t dest[2]; - - mp_load_method_maybe(module, name, dest); - - if (dest[1] != MP_OBJ_NULL) { - // Hopefully we can't import bound method from an object -import_error: - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "cannot import name %q", name)); - } - - if (dest[0] != MP_OBJ_NULL) { - return dest[0]; - } - - // See if it's a package, then can try FS import - if (!mp_obj_is_package(module)) { - goto import_error; - } - - mp_load_method_maybe(module, MP_QSTR___name__, dest); - size_t pkg_name_len; - const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len); - - const uint dot_name_len = pkg_name_len + 1 + qstr_len(name); - char *dot_name = alloca(dot_name_len); - memcpy(dot_name, pkg_name, pkg_name_len); - dot_name[pkg_name_len] = '.'; - memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name)); - qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len); - - mp_obj_t args[5]; - args[0] = MP_OBJ_NEW_QSTR(dot_name_q); - args[1] = mp_const_none; // TODO should be globals - args[2] = mp_const_none; // TODO should be locals - args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module - args[4] = MP_OBJ_NEW_SMALL_INT(0); - - // TODO lookup __import__ and call that instead of going straight to builtin implementation - return mp_builtin___import__(5, args); -} - -void mp_import_all(mp_obj_t module) { - DEBUG_printf("import all %p\n", module); - - // TODO: Support __all__ - mp_map_t *map = mp_obj_dict_get_map(MP_OBJ_FROM_PTR(mp_obj_module_get_globals(module))); - for (size_t i = 0; i < map->alloc; i++) { - if (MP_MAP_SLOT_IS_FILLED(map, i)) { - qstr name = MP_OBJ_QSTR_VALUE(map->table[i].key); - if (*qstr_str(name) != '_') { - mp_store_name(name, map->table[i].value); - } - } - } -} - -#if MICROPY_ENABLE_COMPILER - -// this is implemented in this file so it can optimise access to locals/globals -mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals) { - // save context - mp_obj_dict_t *volatile old_globals = mp_globals_get(); - mp_obj_dict_t *volatile old_locals = mp_locals_get(); - - // set new context - mp_globals_set(globals); - mp_locals_set(locals); - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - qstr source_name = lex->source_name; - mp_parse_tree_t parse_tree = mp_parse(lex, parse_input_kind); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false); - - mp_obj_t ret; - if (MICROPY_PY_BUILTINS_COMPILE && globals == NULL) { - // for compile only, return value is the module function - ret = module_fun; - } else { - // execute module function and get return value - ret = mp_call_function_0(module_fun); - } - - // finish nlr block, restore context and return value - nlr_pop(); - mp_globals_set(old_globals); - mp_locals_set(old_locals); - return ret; - } else { - // exception; restore context and re-raise same exception - mp_globals_set(old_globals); - mp_locals_set(old_locals); - nlr_jump(nlr.ret_val); - } -} - -#endif // MICROPY_ENABLE_COMPILER - -NORETURN void *m_malloc_fail(size_t num_bytes) { - DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes); - #if MICROPY_ENABLE_GC - if (gc_is_locked()) { - mp_raise_msg(&mp_type_MemoryError, "memory allocation failed, heap is locked"); - } - #endif - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError, - "memory allocation failed, allocating %u bytes", (uint)num_bytes)); -} - -NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) { - if (msg == NULL) { - nlr_raise(mp_obj_new_exception(exc_type)); - } else { - nlr_raise(mp_obj_new_exception_msg(exc_type, msg)); - } -} - -NORETURN void mp_raise_ValueError(const char *msg) { - mp_raise_msg(&mp_type_ValueError, msg); -} - -NORETURN void mp_raise_TypeError(const char *msg) { - mp_raise_msg(&mp_type_TypeError, msg); -} - -NORETURN void mp_raise_OSError(int errno_) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_))); -} - -NORETURN void mp_raise_NotImplementedError(const char *msg) { - mp_raise_msg(&mp_type_NotImplementedError, msg); -} diff --git a/user/mpy/py/runtime.h b/user/mpy/py/runtime.h deleted file mode 100644 index 428e257..0000000 --- a/user/mpy/py/runtime.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 - -#include "py/mpstate.h" -#include "py/obj.h" - -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; - -// defined in objtype.c -extern const qstr mp_unary_op_method_name[]; -extern const qstr mp_binary_op_method_name[]; - -void mp_init(void); -void mp_deinit(void); - -void mp_handle_pending(void); -void mp_handle_pending_tail(mp_uint_t atomic_state); - -#if MICROPY_ENABLE_SCHEDULER -void mp_sched_lock(void); -void mp_sched_unlock(void); -static inline unsigned int mp_sched_num_pending(void) { return MP_STATE_VM(sched_sp); } -bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg); -#endif - -// 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(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool 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_uint_t op, mp_obj_t arg); -mp_obj_t mp_binary_op(mp_uint_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 -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void 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 MICROPY_STACKLESS -// 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 - -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_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); - -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); - -NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg); -//NORETURN void nlr_raise_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); -NORETURN void mp_raise_ValueError(const char *msg); -NORETURN void mp_raise_TypeError(const char *msg); -NORETURN void mp_raise_NotImplementedError(const char *msg); -NORETURN void mp_raise_OSError(int errno_); -NORETURN void mp_exc_recursion_depth(void); - -#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG -#undef mp_check_self -#define mp_check_self(pred) -#else -// A port may define to raise TypeError for example -#ifndef mp_check_self -#define mp_check_self(pred) assert(pred) -#endif -#endif - -// helper functions for native/viper code -mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type); -mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); -mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args); -void mp_native_raise(mp_obj_t o); - -#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 MICROPY_WARNINGS -void mp_warning(const char *msg, ...); -#else -#define mp_warning(msg, ...) -#endif - -#endif // MICROPY_INCLUDED_PY_RUNTIME_H diff --git a/user/mpy/py/runtime0.h b/user/mpy/py/runtime0.h deleted file mode 100644 index 703c950..0000000 --- a/user/mpy/py/runtime0.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 - -// These must fit in 8 bits; see scope.h -#define MP_SCOPE_FLAG_VARARGS (0x01) -#define MP_SCOPE_FLAG_VARKEYWORDS (0x02) -#define MP_SCOPE_FLAG_GENERATOR (0x04) -#define MP_SCOPE_FLAG_DEFKWARGS (0x08) - -// 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) - -typedef enum { - MP_UNARY_OP_BOOL, // __bool__ - MP_UNARY_OP_LEN, // __len__ - MP_UNARY_OP_HASH, // __hash__; must return a small int - MP_UNARY_OP_POSITIVE, - MP_UNARY_OP_NEGATIVE, - MP_UNARY_OP_INVERT, - MP_UNARY_OP_NOT, - MP_UNARY_OP_SIZEOF, // for sys.getsizeof() -} mp_unary_op_t; - -typedef enum { - 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_FLOOR_DIVIDE, - MP_BINARY_OP_TRUE_DIVIDE, - - MP_BINARY_OP_MODULO, - MP_BINARY_OP_POWER, - MP_BINARY_OP_DIVMOD, // not emitted by the compiler but supported by the runtime - 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_FLOOR_DIVIDE, - MP_BINARY_OP_INPLACE_TRUE_DIVIDE, - MP_BINARY_OP_INPLACE_MODULO, - MP_BINARY_OP_INPLACE_POWER, - - // these should return a bool - 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, - // these 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; - -typedef enum { - MP_F_CONVERT_OBJ_TO_NATIVE = 0, - MP_F_CONVERT_NATIVE_TO_OBJ, - MP_F_LOAD_NAME, - MP_F_LOAD_GLOBAL, - MP_F_LOAD_BUILD_CLASS, - MP_F_LOAD_ATTR, - MP_F_LOAD_METHOD, - MP_F_LOAD_SUPER_METHOD, - MP_F_STORE_NAME, - MP_F_STORE_GLOBAL, - MP_F_STORE_ATTR, - MP_F_OBJ_SUBSCR, - MP_F_OBJ_IS_TRUE, - MP_F_UNARY_OP, - MP_F_BINARY_OP, - MP_F_BUILD_TUPLE, - MP_F_BUILD_LIST, - MP_F_LIST_APPEND, - MP_F_BUILD_MAP, - MP_F_STORE_MAP, -#if MICROPY_PY_BUILTINS_SET - MP_F_BUILD_SET, - MP_F_STORE_SET, -#endif - MP_F_MAKE_FUNCTION_FROM_RAW_CODE, - MP_F_NATIVE_CALL_FUNCTION_N_KW, - MP_F_CALL_METHOD_N_KW, - MP_F_CALL_METHOD_N_KW_VAR, - MP_F_NATIVE_GETITER, - MP_F_NATIVE_ITERNEXT, - MP_F_NLR_PUSH, - MP_F_NLR_POP, - MP_F_NATIVE_RAISE, - MP_F_IMPORT_NAME, - MP_F_IMPORT_FROM, - MP_F_IMPORT_ALL, -#if MICROPY_PY_BUILTINS_SLICE - MP_F_NEW_SLICE, -#endif - MP_F_UNPACK_SEQUENCE, - MP_F_UNPACK_EX, - MP_F_DELETE_NAME, - MP_F_DELETE_GLOBAL, - MP_F_NEW_CELL, - MP_F_MAKE_CLOSURE_FROM_RAW_CODE, - MP_F_SETUP_CODE_STATE, - MP_F_NUMBER_OF, -} mp_fun_kind_t; - -extern void *const mp_fun_table[MP_F_NUMBER_OF]; - -#endif // MICROPY_INCLUDED_PY_RUNTIME0_H diff --git a/user/mpy/py/runtime_utils.c b/user/mpy/py/runtime_utils.c deleted file mode 100644 index 56a9180..0000000 --- a/user/mpy/py/runtime_utils.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Josef Gajdusek - * Copyright (c) 2015 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. - */ - -#include "py/runtime.h" -#include "py/obj.h" -#include "py/nlr.h" - -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_call_function_1(fun, arg); - nlr_pop(); - } else { - mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); - } -} - -void mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2) { - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_call_function_2(fun, arg1, arg2); - nlr_pop(); - } else { - mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); - } -} diff --git a/user/mpy/py/scheduler.c b/user/mpy/py/scheduler.c deleted file mode 100644 index 30851a4..0000000 --- a/user/mpy/py/scheduler.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/runtime.h" - -#if MICROPY_ENABLE_SCHEDULER - -// A variant of this is inlined in the VM at the pending exception check -void mp_handle_pending(void) { - if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { - mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - if (obj != MP_OBJ_NULL) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; - if (!mp_sched_num_pending()) { - MP_STATE_VM(sched_state) = MP_SCHED_IDLE; - } - MICROPY_END_ATOMIC_SECTION(atomic_state); - nlr_raise(obj); - } - mp_handle_pending_tail(atomic_state); - } -} - -// This function should only be called be mp_sched_handle_pending, -// or by the VM's inlined version of that function. -void mp_handle_pending_tail(mp_uint_t atomic_state) { - MP_STATE_VM(sched_state) = MP_SCHED_LOCKED; - if (MP_STATE_VM(sched_sp) > 0) { - mp_sched_item_t item = MP_STATE_VM(sched_stack)[--MP_STATE_VM(sched_sp)]; - MICROPY_END_ATOMIC_SECTION(atomic_state); - mp_call_function_1_protected(item.func, item.arg); - } else { - MICROPY_END_ATOMIC_SECTION(atomic_state); - } - mp_sched_unlock(); -} - -void mp_sched_lock(void) { - mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); - if (MP_STATE_VM(sched_state) < 0) { - --MP_STATE_VM(sched_state); - } else { - MP_STATE_VM(sched_state) = MP_SCHED_LOCKED; - } - MICROPY_END_ATOMIC_SECTION(atomic_state); -} - -void mp_sched_unlock(void) { - mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); - if (++MP_STATE_VM(sched_state) == 0) { - // vm became unlocked - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL || mp_sched_num_pending()) { - MP_STATE_VM(sched_state) = MP_SCHED_PENDING; - } else { - MP_STATE_VM(sched_state) = MP_SCHED_IDLE; - } - } - MICROPY_END_ATOMIC_SECTION(atomic_state); -} - -bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg) { - mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); - bool ret; - if (MP_STATE_VM(sched_sp) < MICROPY_SCHEDULER_DEPTH) { - if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { - MP_STATE_VM(sched_state) = MP_SCHED_PENDING; - } - MP_STATE_VM(sched_stack)[MP_STATE_VM(sched_sp)].func = function; - MP_STATE_VM(sched_stack)[MP_STATE_VM(sched_sp)].arg = arg; - ++MP_STATE_VM(sched_sp); - ret = true; - } else { - // schedule stack is full - ret = false; - } - MICROPY_END_ATOMIC_SECTION(atomic_state); - return ret; -} - -#else // MICROPY_ENABLE_SCHEDULER - -// A variant of this is inlined in the VM at the pending exception check -void mp_handle_pending(void) { - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; - nlr_raise(obj); - } -} - -#endif // MICROPY_ENABLE_SCHEDULER diff --git a/user/mpy/py/scope.c b/user/mpy/py/scope.c deleted file mode 100644 index 1a6ae7b..0000000 --- a/user/mpy/py/scope.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/scope.h" - -#if MICROPY_ENABLE_COMPILER - -// these low numbered qstrs should fit in 8 bits -STATIC const uint8_t scope_simple_name_table[] = { - [SCOPE_MODULE] = MP_QSTR__lt_module_gt_, - [SCOPE_LAMBDA] = MP_QSTR__lt_lambda_gt_, - [SCOPE_LIST_COMP] = MP_QSTR__lt_listcomp_gt_, - [SCOPE_DICT_COMP] = MP_QSTR__lt_dictcomp_gt_, - [SCOPE_SET_COMP] = MP_QSTR__lt_setcomp_gt_, - [SCOPE_GEN_EXPR] = MP_QSTR__lt_genexpr_gt_, -}; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options) { - scope_t *scope = m_new0(scope_t, 1); - scope->kind = kind; - scope->pn = pn; - scope->source_file = source_file; - if (kind == SCOPE_FUNCTION || kind == SCOPE_CLASS) { - assert(MP_PARSE_NODE_IS_STRUCT(pn)); - scope->simple_name = MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn)->nodes[0]); - } else { - scope->simple_name = scope_simple_name_table[kind]; - } - scope->raw_code = mp_emit_glue_new_raw_code(); - scope->emit_options = emit_options; - scope->id_info_alloc = MICROPY_ALLOC_SCOPE_ID_INIT; - scope->id_info = m_new(id_info_t, scope->id_info_alloc); - - return scope; -} - -void scope_free(scope_t *scope) { - m_del(id_info_t, scope->id_info, scope->id_info_alloc); - m_del(scope_t, scope, 1); -} - -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qst, bool *added) { - id_info_t *id_info = scope_find(scope, qst); - if (id_info != NULL) { - *added = false; - return id_info; - } - - // make sure we have enough memory - if (scope->id_info_len >= scope->id_info_alloc) { - scope->id_info = m_renew(id_info_t, scope->id_info, scope->id_info_alloc, scope->id_info_alloc + MICROPY_ALLOC_SCOPE_ID_INC); - scope->id_info_alloc += MICROPY_ALLOC_SCOPE_ID_INC; - } - - // add new id to end of array of all ids; this seems to match CPython - // important thing is that function arguments are first, but that is - // handled by the compiler because it adds arguments before compiling the body - id_info = &scope->id_info[scope->id_info_len++]; - - id_info->kind = 0; - id_info->flags = 0; - id_info->local_num = 0; - id_info->qst = qst; - *added = true; - return id_info; -} - -id_info_t *scope_find(scope_t *scope, qstr qst) { - for (mp_uint_t i = 0; i < scope->id_info_len; i++) { - if (scope->id_info[i].qst == qst) { - return &scope->id_info[i]; - } - } - return NULL; -} - -id_info_t *scope_find_global(scope_t *scope, qstr qst) { - while (scope->parent != NULL) { - scope = scope->parent; - } - return scope_find(scope, qst); -} - -STATIC void scope_close_over_in_parents(scope_t *scope, qstr qst) { - assert(scope->parent != NULL); // we should have at least 1 parent - for (scope_t *s = scope->parent;; s = s->parent) { - assert(s->parent != NULL); // we should not get to the outer scope - bool added; - id_info_t *id = scope_find_or_add_id(s, qst, &added); - if (added) { - // variable not previously declared in this scope, so declare it as free and keep searching parents - id->kind = ID_INFO_KIND_FREE; - } else { - // variable is declared in this scope, so finish - if (id->kind == ID_INFO_KIND_LOCAL) { - // variable local to this scope, close it over - id->kind = ID_INFO_KIND_CELL; - } else { - // ID_INFO_KIND_FREE: variable already closed over in a parent scope - // ID_INFO_KIND_CELL: variable already closed over in this scope - assert(id->kind == ID_INFO_KIND_FREE || id->kind == ID_INFO_KIND_CELL); - } - return; - } - } -} - -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst) { - if (scope->parent != NULL) { - for (scope_t *s = scope->parent; s->parent != NULL; s = s->parent) { - id_info_t *id2 = scope_find(s, qst); - if (id2 != NULL) { - if (id2->kind == ID_INFO_KIND_LOCAL || id2->kind == ID_INFO_KIND_CELL || id2->kind == ID_INFO_KIND_FREE) { - id->kind = ID_INFO_KIND_FREE; - scope_close_over_in_parents(scope, qst); - return; - } - break; - } - } - } - id->kind = ID_INFO_KIND_GLOBAL_IMPLICIT; -} - -#endif // MICROPY_ENABLE_COMPILER diff --git a/user/mpy/py/scope.h b/user/mpy/py/scope.h deleted file mode 100644 index e3b6a57..0000000 --- a/user/mpy/py/scope.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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_SCOPE_H -#define MICROPY_INCLUDED_PY_SCOPE_H - -#include "py/parse.h" -#include "py/emitglue.h" - -enum { - ID_INFO_KIND_GLOBAL_IMPLICIT, - ID_INFO_KIND_GLOBAL_EXPLICIT, - ID_INFO_KIND_LOCAL, // in a function f, written and only referenced by f - ID_INFO_KIND_CELL, // in a function f, read/written by children of f - ID_INFO_KIND_FREE, // in a function f, belongs to the parent of f -}; - -enum { - ID_FLAG_IS_PARAM = 0x01, - ID_FLAG_IS_STAR_PARAM = 0x02, - ID_FLAG_IS_DBL_STAR_PARAM = 0x04, -}; - -typedef struct _id_info_t { - uint8_t kind; - uint8_t flags; - // when it's an ID_INFO_KIND_LOCAL this is the unique number of the local - // whet it's an ID_INFO_KIND_CELL/FREE this is the unique number of the closed over variable - uint16_t local_num; - qstr qst; -} id_info_t; - -#define SCOPE_IS_FUNC_LIKE(s) ((s) >= SCOPE_LAMBDA) - -// scope is a "block" in Python parlance -typedef enum { - SCOPE_MODULE, - SCOPE_CLASS, - SCOPE_LAMBDA, - SCOPE_LIST_COMP, - SCOPE_DICT_COMP, - SCOPE_SET_COMP, - SCOPE_GEN_EXPR, - SCOPE_FUNCTION, -} scope_kind_t; - -typedef struct _scope_t { - scope_kind_t kind; - struct _scope_t *parent; - struct _scope_t *next; - mp_parse_node_t pn; - uint16_t source_file; // a qstr - uint16_t simple_name; // a qstr - mp_raw_code_t *raw_code; - uint8_t scope_flags; // see runtime0.h - uint8_t emit_options; // see compile.h - uint16_t num_pos_args; - uint16_t num_kwonly_args; - uint16_t num_def_pos_args; - uint16_t num_locals; - uint16_t stack_size; // maximum size of the locals stack - uint16_t exc_stack_size; // maximum size of the exception stack - uint16_t id_info_alloc; - uint16_t id_info_len; - id_info_t *id_info; -} scope_t; - -scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options); -void scope_free(scope_t *scope); -id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added); -id_info_t *scope_find(scope_t *scope, qstr qstr); -id_info_t *scope_find_global(scope_t *scope, qstr qstr); -void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst); - -#endif // MICROPY_INCLUDED_PY_SCOPE_H diff --git a/user/mpy/py/sequence.c b/user/mpy/py/sequence.c deleted file mode 100644 index 0752ee1..0000000 --- a/user/mpy/py/sequence.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime0.h" -#include "py/runtime.h" - -// Helpers for sequence types - -#define SWAP(type, var1, var2) { type t = var2; var2 = var1; var1 = t; } - -// Implements backend of sequence * integer operation. Assumes elements are -// memory-adjacent in sequence. -void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest) { - for (size_t i = 0; i < times; i++) { - size_t copy_sz = item_sz * len; - memcpy(dest, items, copy_sz); - dest = (char*)dest + copy_sz; - } -} - -#if MICROPY_PY_BUILTINS_SLICE - -bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes) { - mp_obj_t ostart, ostop, ostep; - mp_int_t start, stop; - mp_obj_slice_get(slice, &ostart, &ostop, &ostep); - - if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) { - indexes->step = mp_obj_get_int(ostep); - if (indexes->step == 0) { - mp_raise_ValueError("slice step cannot be zero"); - } - } else { - indexes->step = 1; - } - - if (ostart == mp_const_none) { - if (indexes->step > 0) { - start = 0; - } else { - start = len - 1; - } - } else { - start = mp_obj_get_int(ostart); - } - if (ostop == mp_const_none) { - if (indexes->step > 0) { - stop = len; - } else { - stop = 0; - } - } else { - stop = mp_obj_get_int(ostop); - if (stop >= 0 && indexes->step < 0) { - stop += 1; - } - } - - // Unlike subscription, out-of-bounds slice indexes are never error - if (start < 0) { - start = len + start; - if (start < 0) { - if (indexes->step < 0) { - start = -1; - } else { - start = 0; - } - } - } else if (indexes->step > 0 && (mp_uint_t)start > len) { - start = len; - } else if (indexes->step < 0 && (mp_uint_t)start >= len) { - start = len - 1; - } - if (stop < 0) { - stop = len + stop; - if (stop < 0) { - stop = -1; - } - if (indexes->step < 0) { - stop += 1; - } - } else if ((mp_uint_t)stop > len) { - stop = len; - } - - // CPython returns empty sequence in such case, or point for assignment is at start - if (indexes->step > 0 && start > stop) { - stop = start; - } else if (indexes->step < 0 && start < stop) { - stop = start + 1; - } - - indexes->start = start; - indexes->stop = stop; - - return indexes->step == 1; -} - -#endif - -mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) { - (void)len; // TODO can we remove len from the arg list? - - mp_int_t start = indexes->start, stop = indexes->stop; - mp_int_t step = indexes->step; - - mp_obj_t res = mp_obj_new_list(0, NULL); - - if (step < 0) { - while (start >= stop) { - mp_obj_list_append(res, seq[start]); - start += step; - } - } else { - while (start < stop) { - mp_obj_list_append(res, seq[start]); - start += step; - } - } - return res; -} - -// Special-case comparison function for sequences of bytes -// Don't pass MP_BINARY_OP_NOT_EQUAL here -bool mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2) { - if (op == MP_BINARY_OP_EQUAL && len1 != len2) { - return false; - } - - // Let's deal only with > & >= - if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { - SWAP(const byte*, data1, data2); - SWAP(size_t, len1, len2); - if (op == MP_BINARY_OP_LESS) { - op = MP_BINARY_OP_MORE; - } else { - op = MP_BINARY_OP_MORE_EQUAL; - } - } - size_t min_len = len1 < len2 ? len1 : len2; - int res = memcmp(data1, data2, min_len); - if (op == MP_BINARY_OP_EQUAL) { - // If we are checking for equality, here're the answer - return res == 0; - } - if (res < 0) { - return false; - } - if (res > 0) { - return true; - } - - // If we had tie in the last element... - // ... and we have lists of different lengths... - if (len1 != len2) { - if (len1 < len2) { - // ... then longer list length wins (we deal only with >) - return false; - } - } else if (op == MP_BINARY_OP_MORE) { - // Otherwise, if we have strict relation, equality means failure - return false; - } - return true; -} - -// Special-case comparison function for sequences of mp_obj_t -// Don't pass MP_BINARY_OP_NOT_EQUAL here -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) { - if (op == MP_BINARY_OP_EQUAL && len1 != len2) { - return false; - } - - // Let's deal only with > & >= - if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) { - SWAP(const mp_obj_t *, items1, items2); - SWAP(size_t, len1, len2); - if (op == MP_BINARY_OP_LESS) { - op = MP_BINARY_OP_MORE; - } else { - op = MP_BINARY_OP_MORE_EQUAL; - } - } - - size_t len = len1 < len2 ? len1 : len2; - for (size_t i = 0; i < len; i++) { - // If current elements equal, can't decide anything - go on - if (mp_obj_equal(items1[i], items2[i])) { - continue; - } - - // Othewise, if they are not equal, we can have final decision based on them - if (op == MP_BINARY_OP_EQUAL) { - // In particular, if we are checking for equality, here're the answer - return false; - } - - // Otherwise, application of relation op gives the answer - return (mp_binary_op(op, items1[i], items2[i]) == mp_const_true); - } - - // If we had tie in the last element... - // ... and we have lists of different lengths... - if (len1 != len2) { - if (len1 < len2) { - // ... then longer list length wins (we deal only with >) - return false; - } - } else if (op == MP_BINARY_OP_MORE) { - // Otherwise, if we have strict relation, sequence equality means failure - return false; - } - - return true; -} - -// Special-case of index() which searches for mp_obj_t -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_type_t *type = mp_obj_get_type(args[0]); - mp_obj_t value = args[1]; - size_t start = 0; - size_t stop = len; - - if (n_args >= 3) { - start = mp_get_index(type, len, args[2], true); - if (n_args >= 4) { - stop = mp_get_index(type, len, args[3], true); - } - } - - for (size_t i = start; i < stop; i++) { - if (mp_obj_equal(items[i], value)) { - // Common sense says this cannot overflow small int - return MP_OBJ_NEW_SMALL_INT(i); - } - } - - mp_raise_ValueError("object not in sequence"); -} - -mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) { - size_t count = 0; - for (size_t i = 0; i < len; i++) { - if (mp_obj_equal(items[i], value)) { - count++; - } - } - - // Common sense says this cannot overflow small int - return MP_OBJ_NEW_SMALL_INT(count); -} diff --git a/user/mpy/py/showbc.c b/user/mpy/py/showbc.c deleted file mode 100644 index bb2b084..0000000 --- a/user/mpy/py/showbc.c +++ /dev/null @@ -1,568 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/bc0.h" -#include "py/bc.h" - -#if MICROPY_DEBUG_PRINTERS - -// redirect all printfs in this file to the platform print stream -#define printf(...) mp_printf(&mp_plat_print, __VA_ARGS__) - -#define DECODE_UINT { \ - unum = 0; \ - do { \ - unum = (unum << 7) + (*ip & 0x7f); \ - } while ((*ip++ & 0x80) != 0); \ -} -#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0) -#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0) - -#if MICROPY_PERSISTENT_CODE - -#define DECODE_QSTR \ - qst = ip[0] | ip[1] << 8; \ - ip += 2; -#define DECODE_PTR \ - DECODE_UINT; \ - unum = mp_showbc_const_table[unum] -#define DECODE_OBJ \ - DECODE_UINT; \ - unum = mp_showbc_const_table[unum] - -#else - -#define DECODE_QSTR { \ - qst = 0; \ - do { \ - qst = (qst << 7) + (*ip & 0x7f); \ - } while ((*ip++ & 0x80) != 0); \ -} -#define DECODE_PTR do { \ - ip = (byte*)MP_ALIGN(ip, sizeof(void*)); \ - unum = (uintptr_t)*(void**)ip; \ - ip += sizeof(void*); \ -} while (0) -#define DECODE_OBJ do { \ - ip = (byte*)MP_ALIGN(ip, sizeof(mp_obj_t)); \ - unum = (mp_uint_t)*(mp_obj_t*)ip; \ - ip += sizeof(mp_obj_t); \ -} while (0) - -#endif - -const byte *mp_showbc_code_start; -const mp_uint_t *mp_showbc_const_table; - -void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const mp_uint_t *const_table) { - mp_showbc_code_start = ip; - - // get bytecode parameters - mp_uint_t n_state = mp_decode_uint(&ip); - mp_uint_t n_exc_stack = mp_decode_uint(&ip); - /*mp_uint_t scope_flags =*/ ip++; - mp_uint_t n_pos_args = *ip++; - mp_uint_t n_kwonly_args = *ip++; - /*mp_uint_t n_def_pos_args =*/ ip++; - - const byte *code_info = ip; - mp_uint_t code_info_size = mp_decode_uint(&code_info); - ip += code_info_size; - - #if MICROPY_PERSISTENT_CODE - qstr block_name = code_info[0] | (code_info[1] << 8); - qstr source_file = code_info[2] | (code_info[3] << 8); - code_info += 4; - #else - qstr block_name = mp_decode_uint(&code_info); - qstr source_file = mp_decode_uint(&code_info); - #endif - printf("File %s, code block '%s' (descriptor: %p, bytecode @%p " UINT_FMT " bytes)\n", - qstr_str(source_file), qstr_str(block_name), descr, mp_showbc_code_start, len); - - // raw bytecode dump - printf("Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n", code_info_size, len - code_info_size); - for (mp_uint_t i = 0; i < len; i++) { - if (i > 0 && i % 16 == 0) { - printf("\n"); - } - printf(" %02x", mp_showbc_code_start[i]); - } - printf("\n"); - - // bytecode prelude: arg names (as qstr objects) - printf("arg names:"); - for (mp_uint_t i = 0; i < n_pos_args + n_kwonly_args; i++) { - printf(" %s", qstr_str(MP_OBJ_QSTR_VALUE(const_table[i]))); - } - printf("\n"); - - printf("(N_STATE " UINT_FMT ")\n", n_state); - printf("(N_EXC_STACK " UINT_FMT ")\n", n_exc_stack); - - // for printing line number info - const byte *bytecode_start = ip; - - // bytecode prelude: initialise closed over variables - { - uint local_num; - while ((local_num = *ip++) != 255) { - printf("(INIT_CELL %u)\n", local_num); - } - len -= ip - mp_showbc_code_start; - } - - // print out line number info - { - mp_int_t bc = bytecode_start - ip; - mp_uint_t source_line = 1; - printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); - for (const byte* ci = code_info; *ci;) { - if ((ci[0] & 0x80) == 0) { - // 0b0LLBBBBB encoding - bc += ci[0] & 0x1f; - source_line += ci[0] >> 5; - ci += 1; - } else { - // 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) - bc += ci[0] & 0xf; - source_line += ((ci[0] << 4) & 0x700) | ci[1]; - ci += 2; - } - printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); - } - } - mp_bytecode_print2(ip, len - 0, const_table); -} - -const byte *mp_bytecode_print_str(const byte *ip) { - mp_uint_t unum; - qstr qst; - - switch (*ip++) { - case MP_BC_LOAD_CONST_FALSE: - printf("LOAD_CONST_FALSE"); - break; - - case MP_BC_LOAD_CONST_NONE: - printf("LOAD_CONST_NONE"); - break; - - case MP_BC_LOAD_CONST_TRUE: - printf("LOAD_CONST_TRUE"); - break; - - case MP_BC_LOAD_CONST_SMALL_INT: { - mp_int_t num = 0; - if ((ip[0] & 0x40) != 0) { - // Number is negative - num--; - } - do { - num = (num << 7) | (*ip & 0x7f); - } while ((*ip++ & 0x80) != 0); - printf("LOAD_CONST_SMALL_INT " INT_FMT, num); - break; - } - - case MP_BC_LOAD_CONST_STRING: - DECODE_QSTR; - printf("LOAD_CONST_STRING '%s'", qstr_str(qst)); - break; - - case MP_BC_LOAD_CONST_OBJ: - DECODE_OBJ; - printf("LOAD_CONST_OBJ %p=", MP_OBJ_TO_PTR(unum)); - mp_obj_print_helper(&mp_plat_print, (mp_obj_t)unum, PRINT_REPR); - break; - - case MP_BC_LOAD_NULL: - printf("LOAD_NULL"); - break; - - case MP_BC_LOAD_FAST_N: - DECODE_UINT; - printf("LOAD_FAST_N " UINT_FMT, unum); - break; - - case MP_BC_LOAD_DEREF: - DECODE_UINT; - printf("LOAD_DEREF " UINT_FMT, unum); - break; - - case MP_BC_LOAD_NAME: - DECODE_QSTR; - printf("LOAD_NAME %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - printf(" (cache=%u)", *ip++); - } - break; - - case MP_BC_LOAD_GLOBAL: - DECODE_QSTR; - printf("LOAD_GLOBAL %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - printf(" (cache=%u)", *ip++); - } - break; - - case MP_BC_LOAD_ATTR: - DECODE_QSTR; - printf("LOAD_ATTR %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - printf(" (cache=%u)", *ip++); - } - break; - - case MP_BC_LOAD_METHOD: - DECODE_QSTR; - printf("LOAD_METHOD %s", qstr_str(qst)); - break; - - case MP_BC_LOAD_SUPER_METHOD: - DECODE_QSTR; - printf("LOAD_SUPER_METHOD %s", qstr_str(qst)); - break; - - case MP_BC_LOAD_BUILD_CLASS: - printf("LOAD_BUILD_CLASS"); - break; - - case MP_BC_LOAD_SUBSCR: - printf("LOAD_SUBSCR"); - break; - - case MP_BC_STORE_FAST_N: - DECODE_UINT; - printf("STORE_FAST_N " UINT_FMT, unum); - break; - - case MP_BC_STORE_DEREF: - DECODE_UINT; - printf("STORE_DEREF " UINT_FMT, unum); - break; - - case MP_BC_STORE_NAME: - DECODE_QSTR; - printf("STORE_NAME %s", qstr_str(qst)); - break; - - case MP_BC_STORE_GLOBAL: - DECODE_QSTR; - printf("STORE_GLOBAL %s", qstr_str(qst)); - break; - - case MP_BC_STORE_ATTR: - DECODE_QSTR; - printf("STORE_ATTR %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - printf(" (cache=%u)", *ip++); - } - break; - - case MP_BC_STORE_SUBSCR: - printf("STORE_SUBSCR"); - break; - - case MP_BC_DELETE_FAST: - DECODE_UINT; - printf("DELETE_FAST " UINT_FMT, unum); - break; - - case MP_BC_DELETE_DEREF: - DECODE_UINT; - printf("DELETE_DEREF " UINT_FMT, unum); - break; - - case MP_BC_DELETE_NAME: - DECODE_QSTR; - printf("DELETE_NAME %s", qstr_str(qst)); - break; - - case MP_BC_DELETE_GLOBAL: - DECODE_QSTR; - printf("DELETE_GLOBAL %s", qstr_str(qst)); - break; - - case MP_BC_DUP_TOP: - printf("DUP_TOP"); - break; - - case MP_BC_DUP_TOP_TWO: - printf("DUP_TOP_TWO"); - break; - - case MP_BC_POP_TOP: - printf("POP_TOP"); - break; - - case MP_BC_ROT_TWO: - printf("ROT_TWO"); - break; - - case MP_BC_ROT_THREE: - printf("ROT_THREE"); - break; - - case MP_BC_JUMP: - DECODE_SLABEL; - printf("JUMP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_POP_JUMP_IF_TRUE: - DECODE_SLABEL; - printf("POP_JUMP_IF_TRUE " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_POP_JUMP_IF_FALSE: - DECODE_SLABEL; - printf("POP_JUMP_IF_FALSE " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_JUMP_IF_TRUE_OR_POP: - DECODE_SLABEL; - printf("JUMP_IF_TRUE_OR_POP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_JUMP_IF_FALSE_OR_POP: - DECODE_SLABEL; - printf("JUMP_IF_FALSE_OR_POP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_SETUP_WITH: - DECODE_ULABEL; // loop-like labels are always forward - printf("SETUP_WITH " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_WITH_CLEANUP: - printf("WITH_CLEANUP"); - break; - - case MP_BC_UNWIND_JUMP: - DECODE_SLABEL; - printf("UNWIND_JUMP " UINT_FMT " %d", (mp_uint_t)(ip + unum - mp_showbc_code_start), *ip); - ip += 1; - break; - - case MP_BC_SETUP_EXCEPT: - DECODE_ULABEL; // except labels are always forward - printf("SETUP_EXCEPT " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_SETUP_FINALLY: - DECODE_ULABEL; // except labels are always forward - printf("SETUP_FINALLY " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_END_FINALLY: - // if TOS is an exception, reraises the exception (3 values on TOS) - // if TOS is an integer, does something else - // if TOS is None, just pops it and continues - // else error - printf("END_FINALLY"); - break; - - case MP_BC_GET_ITER: - printf("GET_ITER"); - break; - - case MP_BC_GET_ITER_STACK: - printf("GET_ITER_STACK"); - break; - - case MP_BC_FOR_ITER: - DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward - printf("FOR_ITER " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); - break; - - case MP_BC_POP_BLOCK: - // pops block and restores the stack - printf("POP_BLOCK"); - break; - - case MP_BC_POP_EXCEPT: - // pops block, checks it's an exception block, and restores the stack, saving the 3 exception values to local threadstate - printf("POP_EXCEPT"); - break; - - case MP_BC_BUILD_TUPLE: - DECODE_UINT; - printf("BUILD_TUPLE " UINT_FMT, unum); - break; - - case MP_BC_BUILD_LIST: - DECODE_UINT; - printf("BUILD_LIST " UINT_FMT, unum); - break; - - case MP_BC_BUILD_MAP: - DECODE_UINT; - printf("BUILD_MAP " UINT_FMT, unum); - break; - - case MP_BC_STORE_MAP: - printf("STORE_MAP"); - break; - - case MP_BC_BUILD_SET: - DECODE_UINT; - printf("BUILD_SET " UINT_FMT, unum); - break; - -#if MICROPY_PY_BUILTINS_SLICE - case MP_BC_BUILD_SLICE: - DECODE_UINT; - printf("BUILD_SLICE " UINT_FMT, unum); - break; -#endif - - case MP_BC_STORE_COMP: - DECODE_UINT; - printf("STORE_COMP " UINT_FMT, unum); - break; - - case MP_BC_UNPACK_SEQUENCE: - DECODE_UINT; - printf("UNPACK_SEQUENCE " UINT_FMT, unum); - break; - - case MP_BC_UNPACK_EX: - DECODE_UINT; - printf("UNPACK_EX " UINT_FMT, unum); - break; - - case MP_BC_MAKE_FUNCTION: - DECODE_PTR; - printf("MAKE_FUNCTION %p", (void*)(uintptr_t)unum); - break; - - case MP_BC_MAKE_FUNCTION_DEFARGS: - DECODE_PTR; - printf("MAKE_FUNCTION_DEFARGS %p", (void*)(uintptr_t)unum); - break; - - case MP_BC_MAKE_CLOSURE: { - DECODE_PTR; - mp_uint_t n_closed_over = *ip++; - printf("MAKE_CLOSURE %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over); - break; - } - - case MP_BC_MAKE_CLOSURE_DEFARGS: { - DECODE_PTR; - mp_uint_t n_closed_over = *ip++; - printf("MAKE_CLOSURE_DEFARGS %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over); - break; - } - - case MP_BC_CALL_FUNCTION: - DECODE_UINT; - printf("CALL_FUNCTION n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); - break; - - case MP_BC_CALL_FUNCTION_VAR_KW: - DECODE_UINT; - printf("CALL_FUNCTION_VAR_KW n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); - break; - - case MP_BC_CALL_METHOD: - DECODE_UINT; - printf("CALL_METHOD n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); - break; - - case MP_BC_CALL_METHOD_VAR_KW: - DECODE_UINT; - printf("CALL_METHOD_VAR_KW n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); - break; - - case MP_BC_RETURN_VALUE: - printf("RETURN_VALUE"); - break; - - case MP_BC_RAISE_VARARGS: - unum = *ip++; - printf("RAISE_VARARGS " UINT_FMT, unum); - break; - - case MP_BC_YIELD_VALUE: - printf("YIELD_VALUE"); - break; - - case MP_BC_YIELD_FROM: - printf("YIELD_FROM"); - break; - - case MP_BC_IMPORT_NAME: - DECODE_QSTR; - printf("IMPORT_NAME '%s'", qstr_str(qst)); - break; - - case MP_BC_IMPORT_FROM: - DECODE_QSTR; - printf("IMPORT_FROM '%s'", qstr_str(qst)); - break; - - case MP_BC_IMPORT_STAR: - printf("IMPORT_STAR"); - break; - - default: - if (ip[-1] < MP_BC_LOAD_CONST_SMALL_INT_MULTI + 64) { - printf("LOAD_CONST_SMALL_INT " INT_FMT, (mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16); - } else if (ip[-1] < MP_BC_LOAD_FAST_MULTI + 16) { - printf("LOAD_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_LOAD_FAST_MULTI); - } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { - printf("STORE_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_STORE_FAST_MULTI); - } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + 7) { - printf("UNARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_UNARY_OP_MULTI); - } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + 36) { - mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI; - printf("BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op])); - } else { - printf("code %p, byte code 0x%02x not implemented\n", ip, ip[-1]); - assert(0); - return ip; - } - break; - } - - return ip; -} - -void mp_bytecode_print2(const byte *ip, size_t len, const mp_uint_t *const_table) { - mp_showbc_code_start = ip; - mp_showbc_const_table = const_table; - while (ip < len + mp_showbc_code_start) { - printf("%02u ", (uint)(ip - mp_showbc_code_start)); - ip = mp_bytecode_print_str(ip); - printf("\n"); - } -} - -#endif // MICROPY_DEBUG_PRINTERS diff --git a/user/mpy/py/smallint.c b/user/mpy/py/smallint.c deleted file mode 100644 index aa542ca..0000000 --- a/user/mpy/py/smallint.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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. - */ - -#include "py/smallint.h" - -bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y) { - // Check for multiply overflow; see CERT INT32-C - if (x > 0) { // x is positive - if (y > 0) { // x and y are positive - if (x > (MP_SMALL_INT_MAX / y)) { - return true; - } - } else { // x positive, y nonpositive - if (y < (MP_SMALL_INT_MIN / x)) { - return true; - } - } // x positive, y nonpositive - } else { // x is nonpositive - if (y > 0) { // x is nonpositive, y is positive - if (x < (MP_SMALL_INT_MIN / y)) { - return true; - } - } else { // x and y are nonpositive - if (x != 0 && y < (MP_SMALL_INT_MAX / x)) { - return true; - } - } // End if x and y are nonpositive - } // End if x is nonpositive - return false; -} - -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor) { - // Python specs require that mod has same sign as second operand - dividend %= divisor; - if ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0)) { - dividend += divisor; - } - return dividend; -} - -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom) { - if (num >= 0) { - if (denom < 0) { - num += -denom - 1; - } - } else { - if (denom >= 0) { - num += -denom + 1; - } - } - return num / denom; -} diff --git a/user/mpy/py/smallint.h b/user/mpy/py/smallint.h deleted file mode 100644 index 42679a7..0000000 --- a/user/mpy/py/smallint.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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_SMALLINT_H -#define MICROPY_INCLUDED_PY_SMALLINT_H - -#include "py/mpconfig.h" -#include "py/misc.h" - -// Functions for small integer arithmetic - -#ifndef MP_SMALL_INT_MIN - -// In SMALL_INT, next-to-highest bits is used as sign, so both must match for value in range -#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C - -#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 1)) -#define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & WORD_MSBIT_HIGH) == 0) -// Mask to truncate mp_int_t to positive value -#define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1)) - -#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B - -#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 2)) -#define MP_SMALL_INT_FITS(n) ((((n) & MP_SMALL_INT_MIN) == 0) || (((n) & MP_SMALL_INT_MIN) == MP_SMALL_INT_MIN)) -// Mask to truncate mp_int_t to positive value -#define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1) | (WORD_MSBIT_HIGH >> 2)) - -#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - -#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)0xffffffff80000000) >> 1)) -#define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & 0xffffffff80000000) == 0) -// Mask to truncate mp_int_t to positive value -#define MP_SMALL_INT_POSITIVE_MASK ~(0xffffffff80000000 | (0xffffffff80000000 >> 1)) - -#endif - -#endif - -#define MP_SMALL_INT_MAX ((mp_int_t)(~(MP_SMALL_INT_MIN))) - -bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); -mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); -mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); - -#endif // MICROPY_INCLUDED_PY_SMALLINT_H diff --git a/user/mpy/py/stackctrl.c b/user/mpy/py/stackctrl.c deleted file mode 100644 index 0bcd82f..0000000 --- a/user/mpy/py/stackctrl.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ - -#include "py/mpstate.h" -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "py/stackctrl.h" - -void mp_stack_ctrl_init(void) { - volatile int stack_dummy; - MP_STATE_THREAD(stack_top) = (char*)&stack_dummy; -} - -void mp_stack_set_top(void *top) { - MP_STATE_THREAD(stack_top) = top; -} - -mp_uint_t mp_stack_usage(void) { - // Assumes descending stack - volatile int stack_dummy; - return MP_STATE_THREAD(stack_top) - (char*)&stack_dummy; -} - -#if MICROPY_STACK_CHECK - -void mp_stack_set_limit(mp_uint_t limit) { - MP_STATE_THREAD(stack_limit) = limit; -} - -void mp_exc_recursion_depth(void) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_RuntimeError, - MP_OBJ_NEW_QSTR(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded))); -} - -void mp_stack_check(void) { - if (mp_stack_usage() >= MP_STATE_THREAD(stack_limit)) { - mp_exc_recursion_depth(); - } -} - -#endif // MICROPY_STACK_CHECK diff --git a/user/mpy/py/stackctrl.h b/user/mpy/py/stackctrl.h deleted file mode 100644 index ff8da0a..0000000 --- a/user/mpy/py/stackctrl.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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. - */ -#ifndef MICROPY_INCLUDED_PY_STACKCTRL_H -#define MICROPY_INCLUDED_PY_STACKCTRL_H - -#include "py/mpconfig.h" - -void mp_stack_ctrl_init(void); -void mp_stack_set_top(void *top); -mp_uint_t mp_stack_usage(void); - -#if MICROPY_STACK_CHECK - -void mp_stack_set_limit(mp_uint_t limit); -void mp_stack_check(void); -#define MP_STACK_CHECK() mp_stack_check() - -#else - -#define mp_stack_set_limit(limit) -#define MP_STACK_CHECK() - -#endif - -#endif // MICROPY_INCLUDED_PY_STACKCTRL_H diff --git a/user/mpy/py/stream.c b/user/mpy/py/stream.c deleted file mode 100644 index 5d18681..0000000 --- a/user/mpy/py/stream.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/nlr.h" -#include "py/objstr.h" -#include "py/stream.h" -#include "py/runtime.h" - -#if MICROPY_STREAMS_NON_BLOCK -#include -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -#define EWOULDBLOCK 140 -#endif -#endif - -// This file defines generic Python stream read/write methods which -// dispatch to the underlying stream interface of an object. - -// TODO: should be in mpconfig.h -#define DEFAULT_BUFFER_SIZE 256 - -STATIC mp_obj_t stream_readall(mp_obj_t self_in); - -#define STREAM_CONTENT_TYPE(stream) (((stream)->is_text) ? &mp_type_str : &mp_type_bytes) - -// Returns error condition in *errcode, if non-zero, return value is number of bytes written -// before error condition occurred. If *errcode == 0, returns total bytes written (which will -// be equal to input size). -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode, byte flags) { - byte *buf = buf_; - mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - typedef mp_uint_t (*io_func_t)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - io_func_t io_func; - const mp_stream_p_t *stream_p = s->type->protocol; - if (flags & MP_STREAM_RW_WRITE) { - io_func = (io_func_t)stream_p->write; - } else { - io_func = stream_p->read; - } - - *errcode = 0; - mp_uint_t done = 0; - while (size > 0) { - mp_uint_t out_sz = io_func(stream, buf, size, errcode); - // For read, out_sz == 0 means EOF. For write, it's unspecified - // what it means, but we don't make any progress, so returning - // is still the best option. - if (out_sz == 0) { - return done; - } - if (out_sz == MP_STREAM_ERROR) { - // If we read something before getting EAGAIN, don't leak it - if (mp_is_nonblocking_error(*errcode) && done != 0) { - *errcode = 0; - } - return done; - } - if (flags & MP_STREAM_RW_ONCE) { - return out_sz; - } - - buf += out_sz; - size -= out_sz; - done += out_sz; - } - return done; -} - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - const mp_stream_p_t *stream_p = type->protocol; - if (stream_p == NULL - || ((flags & MP_STREAM_OP_READ) && stream_p->read == NULL) - || ((flags & MP_STREAM_OP_WRITE) && stream_p->write == NULL) - || ((flags & MP_STREAM_OP_IOCTL) && stream_p->ioctl == NULL)) { - // CPython: io.UnsupportedOperation, OSError subclass - mp_raise_msg(&mp_type_OSError, "stream operation not supported"); - } - return stream_p; -} - -mp_obj_t mp_stream_close(mp_obj_t stream) { - // TODO: Still consider using ioctl for close - mp_obj_t dest[2]; - mp_load_method(stream, MP_QSTR_close, dest); - return mp_call_method_n_kw(0, 0, dest); -} - -STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_READ); - - // What to do if sz < -1? Python docs don't specify this case. - // CPython does a readall, but here we silently let negatives through, - // and they will cause a MemoryError. - mp_int_t sz; - if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) { - return stream_readall(args[0]); - } - - #if MICROPY_PY_BUILTINS_STR_UNICODE - if (stream_p->is_text) { - // We need to read sz number of unicode characters. Because we don't have any - // buffering, and because the stream API can only read bytes, we must read here - // in units of bytes and must never over read. If we want sz chars, then reading - // sz bytes will never over-read, so we follow this approach, in a loop to keep - // reading until we have exactly enough chars. This will be 1 read for text - // with ASCII-only chars, and about 2 reads for text with a couple of non-ASCII - // chars. For text with lots of non-ASCII chars, it'll be pretty inefficient - // in time and memory. - - vstr_t vstr; - vstr_init(&vstr, sz); - mp_uint_t more_bytes = sz; - mp_uint_t last_buf_offset = 0; - while (more_bytes > 0) { - char *p = vstr_add_len(&vstr, more_bytes); - if (p == NULL) { - mp_raise_msg(&mp_type_MemoryError, "out of memory"); - } - int error; - mp_uint_t out_sz = mp_stream_read_exactly(args[0], p, more_bytes, &error); - if (error != 0) { - vstr_cut_tail_bytes(&vstr, more_bytes); - if (mp_is_nonblocking_error(error)) { - // With non-blocking streams, we read as much as we can. - // If we read nothing, return None, just like read(). - // Otherwise, return data read so far. - // TODO what if we have read only half a non-ASCII char? - if (vstr.len == 0) { - vstr_clear(&vstr); - return mp_const_none; - } - break; - } - mp_raise_OSError(error); - } - - if (out_sz < more_bytes) { - // Finish reading. - // TODO what if we have read only half a non-ASCII char? - vstr_cut_tail_bytes(&vstr, more_bytes - out_sz); - if (out_sz == 0) { - break; - } - } - - // count chars from bytes just read - for (mp_uint_t off = last_buf_offset;;) { - byte b = vstr.buf[off]; - int n; - if (!UTF8_IS_NONASCII(b)) { - // 1-byte ASCII char - n = 1; - } else if ((b & 0xe0) == 0xc0) { - // 2-byte char - n = 2; - } else if ((b & 0xf0) == 0xe0) { - // 3-byte char - n = 3; - } else if ((b & 0xf8) == 0xf0) { - // 4-byte char - n = 4; - } else { - // TODO - n = 5; - } - if (off + n <= vstr.len) { - // got a whole char in n bytes - off += n; - sz -= 1; - last_buf_offset = off; - if (off >= vstr.len) { - more_bytes = sz; - break; - } - } else { - // didn't get a whole char, so work out how many extra bytes are needed for - // this partial char, plus bytes for additional chars that we want - more_bytes = (off + n - vstr.len) + (sz - 1); - break; - } - } - } - - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); - } - #endif - - vstr_t vstr; - vstr_init_len(&vstr, sz); - int error; - mp_uint_t out_sz = mp_stream_rw(args[0], vstr.buf, sz, &error, flags); - if (error != 0) { - vstr_clear(&vstr); - if (mp_is_nonblocking_error(error)) { - // https://docs.python.org/3.4/library/io.html#io.RawIOBase.read - // "If the object is in non-blocking mode and no bytes are available, - // None is returned." - // This is actually very weird, as naive truth check will treat - // this as EOF. - return mp_const_none; - } - mp_raise_OSError(error); - } else { - vstr.len = out_sz; - return mp_obj_new_str_from_vstr(STREAM_CONTENT_TYPE(stream_p), &vstr); - } -} - -STATIC mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) { - return stream_read_generic(n_args, args, MP_STREAM_RW_READ); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj, 1, 2, stream_read); - -STATIC mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) { - return stream_read_generic(n_args, args, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj, 1, 2, stream_read1); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags) { - mp_get_stream_raise(self_in, MP_STREAM_OP_WRITE); - - int error; - mp_uint_t out_sz = mp_stream_rw(self_in, (void*)buf, len, &error, flags); - if (error != 0) { - if (mp_is_nonblocking_error(error)) { - // http://docs.python.org/3/library/io.html#io.RawIOBase.write - // "None is returned if the raw stream is set not to block and - // no single byte could be readily written to it." - return mp_const_none; - } - mp_raise_OSError(error); - } else { - return MP_OBJ_NEW_SMALL_INT(out_sz); - } -} - -// XXX hack -void mp_stream_write_adaptor(void *self, const char *buf, size_t len) { - mp_stream_write(MP_OBJ_FROM_PTR(self), buf, len, MP_STREAM_RW_WRITE); -} - -STATIC mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); - size_t max_len = (size_t)-1; - size_t off = 0; - if (n_args == 3) { - max_len = mp_obj_get_int_truncated(args[2]); - } else if (n_args == 4) { - off = mp_obj_get_int_truncated(args[2]); - max_len = mp_obj_get_int_truncated(args[3]); - if (off > bufinfo.len) { - off = bufinfo.len; - } - } - bufinfo.len -= off; - return mp_stream_write(args[0], (byte*)bufinfo.buf + off, MIN(bufinfo.len, max_len), MP_STREAM_RW_WRITE); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj, 2, 4, stream_write_method); - -STATIC mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); - return mp_stream_write(self_in, bufinfo.buf, bufinfo.len, MP_STREAM_RW_WRITE | MP_STREAM_RW_ONCE); -} -MP_DEFINE_CONST_FUN_OBJ_2(mp_stream_write1_obj, stream_write1_method); - -STATIC mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) { - mp_get_stream_raise(args[0], MP_STREAM_OP_READ); - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); - - // CPython extension: if 2nd arg is provided, that's max len to read, - // instead of full buffer. Similar to - // https://docs.python.org/3/library/socket.html#socket.socket.recv_into - mp_uint_t len = bufinfo.len; - if (n_args > 2) { - len = mp_obj_get_int(args[2]); - if (len > bufinfo.len) { - len = bufinfo.len; - } - } - - int error; - mp_uint_t out_sz = mp_stream_read_exactly(args[0], bufinfo.buf, len, &error); - if (error != 0) { - if (mp_is_nonblocking_error(error)) { - return mp_const_none; - } - mp_raise_OSError(error); - } else { - return MP_OBJ_NEW_SMALL_INT(out_sz); - } -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj, 2, 3, stream_readinto); - -STATIC mp_obj_t stream_readall(mp_obj_t self_in) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(self_in, MP_STREAM_OP_READ); - - mp_uint_t total_size = 0; - vstr_t vstr; - vstr_init(&vstr, DEFAULT_BUFFER_SIZE); - char *p = vstr.buf; - mp_uint_t current_read = DEFAULT_BUFFER_SIZE; - while (true) { - int error; - mp_uint_t out_sz = stream_p->read(self_in, p, current_read, &error); - if (out_sz == MP_STREAM_ERROR) { - if (mp_is_nonblocking_error(error)) { - // With non-blocking streams, we read as much as we can. - // If we read nothing, return None, just like read(). - // Otherwise, return data read so far. - if (total_size == 0) { - return mp_const_none; - } - break; - } - mp_raise_OSError(error); - } - if (out_sz == 0) { - break; - } - total_size += out_sz; - if (out_sz < current_read) { - current_read -= out_sz; - p += out_sz; - } else { - p = vstr_extend(&vstr, DEFAULT_BUFFER_SIZE); - current_read = DEFAULT_BUFFER_SIZE; - } - } - - vstr.len = total_size; - return mp_obj_new_str_from_vstr(STREAM_CONTENT_TYPE(stream_p), &vstr); -} - -// Unbuffered, inefficient implementation of readline() for raw I/O files. -STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_READ); - - mp_int_t max_size = -1; - if (n_args > 1) { - max_size = MP_OBJ_SMALL_INT_VALUE(args[1]); - } - - vstr_t vstr; - if (max_size != -1) { - vstr_init(&vstr, max_size); - } else { - vstr_init(&vstr, 16); - } - - while (max_size == -1 || max_size-- != 0) { - char *p = vstr_add_len(&vstr, 1); - if (p == NULL) { - mp_raise_msg(&mp_type_MemoryError, "out of memory"); - } - - int error; - mp_uint_t out_sz = stream_p->read(args[0], p, 1, &error); - if (out_sz == MP_STREAM_ERROR) { - if (mp_is_nonblocking_error(error)) { - if (vstr.len == 1) { - // We just incremented it, but otherwise we read nothing - // and immediately got EAGAIN. This case is not well - // specified in - // https://docs.python.org/3/library/io.html#io.IOBase.readline - // unlike similar case for read(). But we follow the latter's - // behavior - return None. - vstr_clear(&vstr); - return mp_const_none; - } else { - goto done; - } - } - mp_raise_OSError(error); - } - if (out_sz == 0) { -done: - // Back out previously added byte - // Consider, what's better - read a char and get OutOfMemory (so read - // char is lost), or allocate first as we do. - vstr_cut_tail_bytes(&vstr, 1); - break; - } - if (*p == '\n') { - break; - } - } - - return mp_obj_new_str_from_vstr(STREAM_CONTENT_TYPE(stream_p), &vstr); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj, 1, 2, stream_unbuffered_readline); - -// TODO take an optional extra argument (what does it do exactly?) -STATIC mp_obj_t stream_unbuffered_readlines(mp_obj_t self) { - mp_obj_t lines = mp_obj_new_list(0, NULL); - for (;;) { - mp_obj_t line = stream_unbuffered_readline(1, &self); - if (!mp_obj_is_true(line)) { - break; - } - mp_obj_list_append(lines, line); - } - return lines; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_unbuffered_readlines_obj, stream_unbuffered_readlines); - -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self) { - mp_obj_t l_in = stream_unbuffered_readline(1, &self); - if (mp_obj_is_true(l_in)) { - return l_in; - } - return MP_OBJ_STOP_ITERATION; -} - -STATIC mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_IOCTL); - - struct mp_stream_seek_t seek_s; - // TODO: Could be uint64 - seek_s.offset = mp_obj_get_int(args[1]); - seek_s.whence = 0; - if (n_args == 3) { - seek_s.whence = mp_obj_get_int(args[2]); - } - - int error; - mp_uint_t res = stream_p->ioctl(args[0], MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error); - if (res == MP_STREAM_ERROR) { - mp_raise_OSError(error); - } - - // TODO: Could be uint64 - return mp_obj_new_int_from_uint(seek_s.offset); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj, 2, 3, stream_seek); - -STATIC mp_obj_t stream_tell(mp_obj_t self) { - mp_obj_t offset = MP_OBJ_NEW_SMALL_INT(0); - mp_obj_t whence = MP_OBJ_NEW_SMALL_INT(SEEK_CUR); - const mp_obj_t args[3] = {self, offset, whence}; - return stream_seek(3, args); -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_tell_obj, stream_tell); - -STATIC mp_obj_t stream_flush(mp_obj_t self) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(self, MP_STREAM_OP_IOCTL); - int error; - mp_uint_t res = stream_p->ioctl(self, MP_STREAM_FLUSH, 0, &error); - if (res == MP_STREAM_ERROR) { - mp_raise_OSError(error); - } - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_flush_obj, stream_flush); - -STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) { - const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_IOCTL); - - mp_buffer_info_t bufinfo; - uintptr_t val = 0; - if (n_args > 2) { - if (mp_get_buffer(args[2], &bufinfo, MP_BUFFER_WRITE)) { - val = (uintptr_t)bufinfo.buf; - } else { - val = mp_obj_get_int_truncated(args[2]); - } - } - - int error; - mp_uint_t res = stream_p->ioctl(args[0], mp_obj_get_int(args[1]), val, &error); - if (res == MP_STREAM_ERROR) { - mp_raise_OSError(error); - } - - return mp_obj_new_int(res); -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj, 2, 3, stream_ioctl); - -#if MICROPY_STREAMS_POSIX_API -/* - * POSIX-like functions - * - * These functions have POSIX-compatible signature (except for "void *stream" - * first argument instead of "int fd"). They are useful to port existing - * POSIX-compatible software to work with MicroPython streams. - */ - -// errno-like variable. If any of the functions below returned with error -// status, this variable will contain error no. -int mp_stream_errno; - -ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len) { - mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; - mp_uint_t out_sz = stream_p->write(stream, buf, len, &mp_stream_errno); - if (out_sz == MP_STREAM_ERROR) { - return -1; - } else { - return out_sz; - } -} - -ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len) { - mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; - mp_uint_t out_sz = stream_p->read(stream, buf, len, &mp_stream_errno); - if (out_sz == MP_STREAM_ERROR) { - return -1; - } else { - return out_sz; - } -} - -off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence) { - const mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; - struct mp_stream_seek_t seek_s; - seek_s.offset = offset; - seek_s.whence = whence; - mp_uint_t res = stream_p->ioctl(stream, MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &mp_stream_errno); - if (res == MP_STREAM_ERROR) { - return -1; - } - return seek_s.offset; -} - -int mp_stream_posix_fsync(mp_obj_t stream) { - mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; - mp_uint_t res = stream_p->ioctl(stream, MP_STREAM_FLUSH, 0, &mp_stream_errno); - if (res == MP_STREAM_ERROR) { - return -1; - } - return res; -} - -#endif diff --git a/user/mpy/py/stream.h b/user/mpy/py/stream.h deleted file mode 100644 index 401ae31..0000000 --- a/user/mpy/py/stream.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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_STREAM_H -#define MICROPY_INCLUDED_PY_STREAM_H - -#include "py/obj.h" -#include "py/mperrno.h" - -#define MP_STREAM_ERROR ((mp_uint_t)-1) - -// Stream ioctl request codes -#define MP_STREAM_FLUSH (1) -#define MP_STREAM_SEEK (2) -#define MP_STREAM_POLL (3) -//#define MP_STREAM_CLOSE (4) // Not yet implemented -#define MP_STREAM_TIMEOUT (5) // Get/set timeout (single op) -#define MP_STREAM_GET_OPTS (6) // Get stream options -#define MP_STREAM_SET_OPTS (7) // Set stream options -#define MP_STREAM_GET_DATA_OPTS (8) // Get data/message options -#define MP_STREAM_SET_DATA_OPTS (9) // Set data/message options - -// These poll ioctl values are compatible with Linux -#define MP_STREAM_POLL_RD (0x0001) -#define MP_STREAM_POLL_WR (0x0004) -#define MP_STREAM_POLL_ERR (0x0008) -#define MP_STREAM_POLL_HUP (0x0010) - -// Argument structure for MP_STREAM_SEEK -struct mp_stream_seek_t { - mp_off_t offset; - int whence; -}; - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_stream_unbuffered_readlines_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_stream_write1_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_stream_tell_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_stream_flush_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj); - -// these are for mp_get_stream_raise and can be or'd together -#define MP_STREAM_OP_READ (1) -#define MP_STREAM_OP_WRITE (2) -#define MP_STREAM_OP_IOCTL (4) - -const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); -mp_obj_t mp_stream_close(mp_obj_t stream); - -// Iterator which uses mp_stream_unbuffered_readline_obj -mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); - -mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags); - -// C-level helper functions -#define MP_STREAM_RW_READ 0 -#define MP_STREAM_RW_WRITE 2 -#define MP_STREAM_RW_ONCE 1 -mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags); -#define mp_stream_write_exactly(stream, buf, size, err) mp_stream_rw(stream, (byte*)buf, size, err, MP_STREAM_RW_WRITE) -#define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ) - -void mp_stream_write_adaptor(void *self, const char *buf, size_t len); - -#if MICROPY_STREAMS_POSIX_API -// Functions with POSIX-compatible signatures -ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len); -ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len); -off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence); -int mp_stream_posix_fsync(mp_obj_t stream); -#endif - -#if MICROPY_STREAMS_NON_BLOCK -#define mp_is_nonblocking_error(errno) ((errno) == EAGAIN || (errno) == EWOULDBLOCK) -#else -#define mp_is_nonblocking_error(errno) (0) -#endif - -#endif // MICROPY_INCLUDED_PY_STREAM_H diff --git a/user/mpy/py/unicode.c b/user/mpy/py/unicode.c deleted file mode 100644 index eddb007..0000000 --- a/user/mpy/py/unicode.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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. - */ - -#include - -#include "py/unicode.h" - -// attribute flags -#define FL_PRINT (0x01) -#define FL_SPACE (0x02) -#define FL_DIGIT (0x04) -#define FL_ALPHA (0x08) -#define FL_UPPER (0x10) -#define FL_LOWER (0x20) -#define FL_XDIGIT (0x40) - -// shorthand character attributes -#define AT_PR (FL_PRINT) -#define AT_SP (FL_SPACE | FL_PRINT) -#define AT_DI (FL_DIGIT | FL_PRINT | FL_XDIGIT) -#define AT_AL (FL_ALPHA | FL_PRINT) -#define AT_UP (FL_UPPER | FL_ALPHA | FL_PRINT) -#define AT_LO (FL_LOWER | FL_ALPHA | FL_PRINT) -#define AT_UX (FL_UPPER | FL_ALPHA | FL_PRINT | FL_XDIGIT) -#define AT_LX (FL_LOWER | FL_ALPHA | FL_PRINT | FL_XDIGIT) - -// table of attributes for ascii characters -STATIC const uint8_t attr[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, AT_SP, AT_SP, AT_SP, AT_SP, AT_SP, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - AT_SP, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, - AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, - AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, AT_DI, - AT_DI, AT_DI, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, - AT_PR, AT_UX, AT_UX, AT_UX, AT_UX, AT_UX, AT_UX, AT_UP, - AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, - AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, AT_UP, - AT_UP, AT_UP, AT_UP, AT_PR, AT_PR, AT_PR, AT_PR, AT_PR, - AT_PR, AT_LX, AT_LX, AT_LX, AT_LX, AT_LX, AT_LX, AT_LO, - AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, - AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, AT_LO, - AT_LO, AT_LO, AT_LO, AT_PR, AT_PR, AT_PR, AT_PR, 0 -}; - -// TODO: Rename to str_get_char -unichar utf8_get_char(const byte *s) { -#if MICROPY_PY_BUILTINS_STR_UNICODE - unichar ord = *s++; - if (!UTF8_IS_NONASCII(ord)) return ord; - ord &= 0x7F; - for (unichar mask = 0x40; ord & mask; mask >>= 1) { - ord &= ~mask; - } - while (UTF8_IS_CONT(*s)) { - ord = (ord << 6) | (*s++ & 0x3F); - } - return ord; -#else - return *s; -#endif -} - -// TODO: Rename to str_next_char -const byte *utf8_next_char(const byte *s) { -#if MICROPY_PY_BUILTINS_STR_UNICODE - ++s; - while (UTF8_IS_CONT(*s)) { - ++s; - } - return s; -#else - return s + 1; -#endif -} - -mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr) { - mp_uint_t i = 0; - while (ptr > s) { - if (!UTF8_IS_CONT(*--ptr)) { - i++; - } - } - - return i; -} - -// TODO: Rename to str_charlen -mp_uint_t unichar_charlen(const char *str, mp_uint_t len) { -#if MICROPY_PY_BUILTINS_STR_UNICODE - mp_uint_t charlen = 0; - for (const char *top = str + len; str < top; ++str) { - if (!UTF8_IS_CONT(*str)) { - ++charlen; - } - } - return charlen; -#else - return len; -#endif -} - -// Be aware: These unichar_is* functions are actually ASCII-only! -bool unichar_isspace(unichar c) { - return c < 128 && (attr[c] & FL_SPACE) != 0; -} - -bool unichar_isalpha(unichar c) { - return c < 128 && (attr[c] & FL_ALPHA) != 0; -} - -/* unused -bool unichar_isprint(unichar c) { - return c < 128 && (attr[c] & FL_PRINT) != 0; -} -*/ - -bool unichar_isdigit(unichar c) { - return c < 128 && (attr[c] & FL_DIGIT) != 0; -} - -bool unichar_isxdigit(unichar c) { - return c < 128 && (attr[c] & FL_XDIGIT) != 0; -} - -bool unichar_isident(unichar c) { - return c < 128 && ((attr[c] & (FL_ALPHA | FL_DIGIT)) != 0 || c == '_'); -} - -bool unichar_isupper(unichar c) { - return c < 128 && (attr[c] & FL_UPPER) != 0; -} - -bool unichar_islower(unichar c) { - return c < 128 && (attr[c] & FL_LOWER) != 0; -} - -unichar unichar_tolower(unichar c) { - if (unichar_isupper(c)) { - return c + 0x20; - } - return c; -} - -unichar unichar_toupper(unichar c) { - if (unichar_islower(c)) { - return c - 0x20; - } - return c; -} - -mp_uint_t unichar_xdigit_value(unichar c) { - // c is assumed to be hex digit - mp_uint_t n = c - '0'; - if (n > 9) { - n &= ~('a' - 'A'); - n -= ('A' - ('9' + 1)); - } - return n; -} diff --git a/user/mpy/py/unicode.h b/user/mpy/py/unicode.h deleted file mode 100644 index 19487a6..0000000 --- a/user/mpy/py/unicode.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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_UNICODE_H -#define MICROPY_INCLUDED_PY_UNICODE_H - -#include "py/mpconfig.h" -#include "py/misc.h" - -mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); - -#endif // MICROPY_INCLUDED_PY_UNICODE_H diff --git a/user/mpy/py/vm.c b/user/mpy/py/vm.c deleted file mode 100644 index c7fc83d..0000000 --- a/user/mpy/py/vm.c +++ /dev/null @@ -1,1461 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include - -#include "py/mpstate.h" -#include "py/nlr.h" -#include "py/emitglue.h" -#include "py/objtype.h" -#include "py/runtime.h" -#include "py/bc0.h" -#include "py/bc.h" - -#if 0 -#define TRACE(ip) printf("sp=%d ", (int)(sp - &code_state->state[0] + 1)); mp_bytecode_print2(ip, 1, code_state->fun_bc->const_table); -#else -#define TRACE(ip) -#endif - -// Value stack grows up (this makes it incompatible with native C stack, but -// makes sure that arguments to functions are in natural order arg1..argN -// (Python semantics mandates left-to-right evaluation order, including for -// function arguments). Stack pointer is pre-incremented and points at the -// top element. -// Exception stack also grows up, top element is also pointed at. - -// Exception stack unwind reasons (WHY_* in CPython-speak) -// TODO perhaps compress this to RETURN=0, JUMP>0, with number of unwinds -// left to do encoded in the JUMP number -typedef enum { - UNWIND_RETURN = 1, - UNWIND_JUMP, -} mp_unwind_reason_t; - -#define DECODE_UINT \ - mp_uint_t unum = 0; \ - do { \ - unum = (unum << 7) + (*ip & 0x7f); \ - } while ((*ip++ & 0x80) != 0) -#define DECODE_ULABEL size_t ulab = (ip[0] | (ip[1] << 8)); ip += 2 -#define DECODE_SLABEL size_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2 - -#if MICROPY_PERSISTENT_CODE - -#define DECODE_QSTR \ - qstr qst = ip[0] | ip[1] << 8; \ - ip += 2; -#define DECODE_PTR \ - DECODE_UINT; \ - void *ptr = (void*)(uintptr_t)code_state->fun_bc->const_table[unum] -#define DECODE_OBJ \ - DECODE_UINT; \ - mp_obj_t obj = (mp_obj_t)code_state->fun_bc->const_table[unum] - -#else - -#define DECODE_QSTR qstr qst = 0; \ - do { \ - qst = (qst << 7) + (*ip & 0x7f); \ - } while ((*ip++ & 0x80) != 0) -#define DECODE_PTR \ - ip = (byte*)MP_ALIGN(ip, sizeof(void*)); \ - void *ptr = *(void**)ip; \ - ip += sizeof(void*) -#define DECODE_OBJ \ - ip = (byte*)MP_ALIGN(ip, sizeof(mp_obj_t)); \ - mp_obj_t obj = *(mp_obj_t*)ip; \ - ip += sizeof(mp_obj_t) - -#endif - -#define PUSH(val) *++sp = (val) -#define POP() (*sp--) -#define TOP() (*sp) -#define SET_TOP(val) *sp = (val) - -#if MICROPY_PY_SYS_EXC_INFO -#define CLEAR_SYS_EXC_INFO() MP_STATE_VM(cur_exception) = NULL; -#else -#define CLEAR_SYS_EXC_INFO() -#endif - -#define PUSH_EXC_BLOCK(with_or_finally) do { \ - DECODE_ULABEL; /* except labels are always forward */ \ - ++exc_sp; \ - exc_sp->handler = ip + ulab; \ - exc_sp->val_sp = MP_TAGPTR_MAKE(sp, ((with_or_finally) << 1) | currently_in_except_block); \ - exc_sp->prev_exc = NULL; \ - currently_in_except_block = 0; /* in a try block now */ \ -} while (0) - -#define POP_EXC_BLOCK() \ - currently_in_except_block = MP_TAGPTR_TAG0(exc_sp->val_sp); /* restore previous state */ \ - exc_sp--; /* pop back to previous exception handler */ \ - CLEAR_SYS_EXC_INFO() /* just clear sys.exc_info(), not compliant, but it shouldn't be used in 1st place */ - -// fastn has items in reverse order (fastn[0] is local[0], fastn[-1] is local[1], etc) -// sp points to bottom of stack which grows up -// returns: -// MP_VM_RETURN_NORMAL, sp valid, return value in *sp -// MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp -// MP_VM_RETURN_EXCEPTION, exception in fastn[0] -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { -#define SELECTIVE_EXC_IP (0) -#if SELECTIVE_EXC_IP -#define MARK_EXC_IP_SELECTIVE() { code_state->ip = ip; } /* stores ip 1 byte past last opcode */ -#define MARK_EXC_IP_GLOBAL() -#else -#define MARK_EXC_IP_SELECTIVE() -#define MARK_EXC_IP_GLOBAL() { code_state->ip = ip; } /* stores ip pointing to last opcode */ -#endif -#if MICROPY_OPT_COMPUTED_GOTO - #include "py/vmentrytable.h" - #define DISPATCH() do { \ - TRACE(ip); \ - MARK_EXC_IP_GLOBAL(); \ - goto *entry_table[*ip++]; \ - } while (0) - #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check - #define ENTRY(op) entry_##op - #define ENTRY_DEFAULT entry_default -#else - #define DISPATCH() break - #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check - #define ENTRY(op) case op - #define ENTRY_DEFAULT default -#endif - - // nlr_raise needs to be implemented as a goto, so that the C compiler's flow analyser - // sees that it's possible for us to jump from the dispatch loop to the exception - // handler. Without this, the code may have a different stack layout in the dispatch - // loop and the exception handler, leading to very obscure bugs. - #define RAISE(o) do { nlr_pop(); nlr.ret_val = MP_OBJ_TO_PTR(o); goto exception_handler; } while (0) - -#if MICROPY_STACKLESS -run_code_state: ; -#endif - // Pointers which are constant for particular invocation of mp_execute_bytecode() - mp_obj_t * /*const*/ fastn; - mp_exc_stack_t * /*const*/ exc_stack; - { - size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); - fastn = &code_state->state[n_state - 1]; - exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); - } - - // variables that are visible to the exception handler (declared volatile) - volatile bool currently_in_except_block = MP_TAGPTR_TAG0(code_state->exc_sp); // 0 or 1, to detect nested exceptions - mp_exc_stack_t *volatile exc_sp = MP_TAGPTR_PTR(code_state->exc_sp); // stack grows up, exc_sp points to top of stack - - #if MICROPY_PY_THREAD_GIL && MICROPY_PY_THREAD_GIL_VM_DIVISOR - // This needs to be volatile and outside the VM loop so it persists across handling - // of any exceptions. Otherwise it's possible that the VM never gives up the GIL. - volatile int gil_divisor = MICROPY_PY_THREAD_GIL_VM_DIVISOR; - #endif - - // outer exception handling loop - for (;;) { - nlr_buf_t nlr; -outer_dispatch_loop: - if (nlr_push(&nlr) == 0) { - // local variables that are not visible to the exception handler - const byte *ip = code_state->ip; - mp_obj_t *sp = code_state->sp; - mp_obj_t obj_shared; - MICROPY_VM_HOOK_INIT - - // If we have exception to inject, now that we finish setting up - // execution context, raise it. This works as if RAISE_VARARGS - // bytecode was executed. - // Injecting exc into yield from generator is a special case, - // handled by MP_BC_YIELD_FROM itself - if (inject_exc != MP_OBJ_NULL && *ip != MP_BC_YIELD_FROM) { - mp_obj_t exc = inject_exc; - inject_exc = MP_OBJ_NULL; - exc = mp_make_raise_obj(exc); - RAISE(exc); - } - - // loop to execute byte code - for (;;) { -dispatch_loop: -#if MICROPY_OPT_COMPUTED_GOTO - DISPATCH(); -#else - TRACE(ip); - MARK_EXC_IP_GLOBAL(); - switch (*ip++) { -#endif - - ENTRY(MP_BC_LOAD_CONST_FALSE): - PUSH(mp_const_false); - DISPATCH(); - - ENTRY(MP_BC_LOAD_CONST_NONE): - PUSH(mp_const_none); - DISPATCH(); - - ENTRY(MP_BC_LOAD_CONST_TRUE): - PUSH(mp_const_true); - DISPATCH(); - - ENTRY(MP_BC_LOAD_CONST_SMALL_INT): { - mp_int_t num = 0; - if ((ip[0] & 0x40) != 0) { - // Number is negative - num--; - } - do { - num = (num << 7) | (*ip & 0x7f); - } while ((*ip++ & 0x80) != 0); - PUSH(MP_OBJ_NEW_SMALL_INT(num)); - DISPATCH(); - } - - ENTRY(MP_BC_LOAD_CONST_STRING): { - DECODE_QSTR; - PUSH(MP_OBJ_NEW_QSTR(qst)); - DISPATCH(); - } - - ENTRY(MP_BC_LOAD_CONST_OBJ): { - DECODE_OBJ; - PUSH(obj); - DISPATCH(); - } - - ENTRY(MP_BC_LOAD_NULL): - PUSH(MP_OBJ_NULL); - DISPATCH(); - - ENTRY(MP_BC_LOAD_FAST_N): { - DECODE_UINT; - obj_shared = fastn[-unum]; - load_check: - if (obj_shared == MP_OBJ_NULL) { - local_name_error: { - MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NameError, "local variable referenced before assignment"); - RAISE(obj); - } - } - PUSH(obj_shared); - DISPATCH(); - } - - ENTRY(MP_BC_LOAD_DEREF): { - DECODE_UINT; - obj_shared = mp_obj_cell_get(fastn[-unum]); - goto load_check; - } - - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ENTRY(MP_BC_LOAD_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - PUSH(mp_load_name(qst)); - DISPATCH(); - } - #else - ENTRY(MP_BC_LOAD_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_obj_t key = MP_OBJ_NEW_QSTR(qst); - mp_uint_t x = *ip; - if (x < mp_locals_get()->map.alloc && mp_locals_get()->map.table[x].key == key) { - PUSH(mp_locals_get()->map.table[x].value); - } else { - mp_map_elem_t *elem = mp_map_lookup(&mp_locals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); - if (elem != NULL) { - *(byte*)ip = (elem - &mp_locals_get()->map.table[0]) & 0xff; - PUSH(elem->value); - } else { - PUSH(mp_load_name(MP_OBJ_QSTR_VALUE(key))); - } - } - ip++; - DISPATCH(); - } - #endif - - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ENTRY(MP_BC_LOAD_GLOBAL): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - PUSH(mp_load_global(qst)); - DISPATCH(); - } - #else - ENTRY(MP_BC_LOAD_GLOBAL): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_obj_t key = MP_OBJ_NEW_QSTR(qst); - mp_uint_t x = *ip; - if (x < mp_globals_get()->map.alloc && mp_globals_get()->map.table[x].key == key) { - PUSH(mp_globals_get()->map.table[x].value); - } else { - mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); - if (elem != NULL) { - *(byte*)ip = (elem - &mp_globals_get()->map.table[0]) & 0xff; - PUSH(elem->value); - } else { - PUSH(mp_load_global(MP_OBJ_QSTR_VALUE(key))); - } - } - ip++; - DISPATCH(); - } - #endif - - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ENTRY(MP_BC_LOAD_ATTR): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - SET_TOP(mp_load_attr(TOP(), qst)); - DISPATCH(); - } - #else - ENTRY(MP_BC_LOAD_ATTR): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_obj_t top = TOP(); - if (mp_obj_get_type(top)->attr == mp_obj_instance_attr) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); - mp_uint_t x = *ip; - mp_obj_t key = MP_OBJ_NEW_QSTR(qst); - mp_map_elem_t *elem; - if (x < self->members.alloc && self->members.table[x].key == key) { - elem = &self->members.table[x]; - } else { - elem = mp_map_lookup(&self->members, key, MP_MAP_LOOKUP); - if (elem != NULL) { - *(byte*)ip = elem - &self->members.table[0]; - } else { - goto load_attr_cache_fail; - } - } - SET_TOP(elem->value); - ip++; - DISPATCH(); - } - load_attr_cache_fail: - SET_TOP(mp_load_attr(top, qst)); - ip++; - DISPATCH(); - } - #endif - - ENTRY(MP_BC_LOAD_METHOD): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_load_method(*sp, qst, sp); - sp += 1; - DISPATCH(); - } - - ENTRY(MP_BC_LOAD_SUPER_METHOD): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - sp -= 1; - mp_load_super_method(qst, sp - 1); - DISPATCH(); - } - - ENTRY(MP_BC_LOAD_BUILD_CLASS): - MARK_EXC_IP_SELECTIVE(); - PUSH(mp_load_build_class()); - DISPATCH(); - - ENTRY(MP_BC_LOAD_SUBSCR): { - MARK_EXC_IP_SELECTIVE(); - mp_obj_t index = POP(); - SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); - DISPATCH(); - } - - ENTRY(MP_BC_STORE_FAST_N): { - DECODE_UINT; - fastn[-unum] = POP(); - DISPATCH(); - } - - ENTRY(MP_BC_STORE_DEREF): { - DECODE_UINT; - mp_obj_cell_set(fastn[-unum], POP()); - DISPATCH(); - } - - ENTRY(MP_BC_STORE_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_store_name(qst, POP()); - DISPATCH(); - } - - ENTRY(MP_BC_STORE_GLOBAL): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_store_global(qst, POP()); - DISPATCH(); - } - - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ENTRY(MP_BC_STORE_ATTR): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_store_attr(sp[0], qst, sp[-1]); - sp -= 2; - DISPATCH(); - } - #else - // This caching code works with MICROPY_PY_BUILTINS_PROPERTY and/or - // MICROPY_PY_DESCRIPTORS enabled because if the attr exists in - // self->members then it can't be a property or have descriptors. A - // consequence of this is that we can't use MP_MAP_LOOKUP_ADD_IF_NOT_FOUND - // in the fast-path below, because that store could override a property. - ENTRY(MP_BC_STORE_ATTR): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_obj_t top = TOP(); - if (mp_obj_get_type(top)->attr == mp_obj_instance_attr && sp[-1] != MP_OBJ_NULL) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); - mp_uint_t x = *ip; - mp_obj_t key = MP_OBJ_NEW_QSTR(qst); - mp_map_elem_t *elem; - if (x < self->members.alloc && self->members.table[x].key == key) { - elem = &self->members.table[x]; - } else { - elem = mp_map_lookup(&self->members, key, MP_MAP_LOOKUP); - if (elem != NULL) { - *(byte*)ip = elem - &self->members.table[0]; - } else { - goto store_attr_cache_fail; - } - } - elem->value = sp[-1]; - sp -= 2; - ip++; - DISPATCH(); - } - store_attr_cache_fail: - mp_store_attr(sp[0], qst, sp[-1]); - sp -= 2; - ip++; - DISPATCH(); - } - #endif - - ENTRY(MP_BC_STORE_SUBSCR): - MARK_EXC_IP_SELECTIVE(); - mp_obj_subscr(sp[-1], sp[0], sp[-2]); - sp -= 3; - DISPATCH(); - - ENTRY(MP_BC_DELETE_FAST): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - if (fastn[-unum] == MP_OBJ_NULL) { - goto local_name_error; - } - fastn[-unum] = MP_OBJ_NULL; - DISPATCH(); - } - - ENTRY(MP_BC_DELETE_DEREF): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - if (mp_obj_cell_get(fastn[-unum]) == MP_OBJ_NULL) { - goto local_name_error; - } - mp_obj_cell_set(fastn[-unum], MP_OBJ_NULL); - DISPATCH(); - } - - ENTRY(MP_BC_DELETE_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_delete_name(qst); - DISPATCH(); - } - - ENTRY(MP_BC_DELETE_GLOBAL): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_delete_global(qst); - DISPATCH(); - } - - ENTRY(MP_BC_DUP_TOP): { - mp_obj_t top = TOP(); - PUSH(top); - DISPATCH(); - } - - ENTRY(MP_BC_DUP_TOP_TWO): - sp += 2; - sp[0] = sp[-2]; - sp[-1] = sp[-3]; - DISPATCH(); - - ENTRY(MP_BC_POP_TOP): - sp -= 1; - DISPATCH(); - - ENTRY(MP_BC_ROT_TWO): { - mp_obj_t top = sp[0]; - sp[0] = sp[-1]; - sp[-1] = top; - DISPATCH(); - } - - ENTRY(MP_BC_ROT_THREE): { - mp_obj_t top = sp[0]; - sp[0] = sp[-1]; - sp[-1] = sp[-2]; - sp[-2] = top; - DISPATCH(); - } - - ENTRY(MP_BC_JUMP): { - DECODE_SLABEL; - ip += slab; - DISPATCH_WITH_PEND_EXC_CHECK(); - } - - ENTRY(MP_BC_POP_JUMP_IF_TRUE): { - DECODE_SLABEL; - if (mp_obj_is_true(POP())) { - ip += slab; - } - DISPATCH_WITH_PEND_EXC_CHECK(); - } - - ENTRY(MP_BC_POP_JUMP_IF_FALSE): { - DECODE_SLABEL; - if (!mp_obj_is_true(POP())) { - ip += slab; - } - DISPATCH_WITH_PEND_EXC_CHECK(); - } - - ENTRY(MP_BC_JUMP_IF_TRUE_OR_POP): { - DECODE_SLABEL; - if (mp_obj_is_true(TOP())) { - ip += slab; - } else { - sp--; - } - DISPATCH_WITH_PEND_EXC_CHECK(); - } - - ENTRY(MP_BC_JUMP_IF_FALSE_OR_POP): { - DECODE_SLABEL; - if (mp_obj_is_true(TOP())) { - sp--; - } else { - ip += slab; - } - DISPATCH_WITH_PEND_EXC_CHECK(); - } - - ENTRY(MP_BC_SETUP_WITH): { - MARK_EXC_IP_SELECTIVE(); - // stack: (..., ctx_mgr) - mp_obj_t obj = TOP(); - mp_load_method(obj, MP_QSTR___exit__, sp); - mp_load_method(obj, MP_QSTR___enter__, sp + 2); - mp_obj_t ret = mp_call_method_n_kw(0, 0, sp + 2); - sp += 1; - PUSH_EXC_BLOCK(1); - PUSH(ret); - // stack: (..., __exit__, ctx_mgr, as_value) - DISPATCH(); - } - - ENTRY(MP_BC_WITH_CLEANUP): { - MARK_EXC_IP_SELECTIVE(); - // Arriving here, there's "exception control block" on top of stack, - // and __exit__ method (with self) underneath it. Bytecode calls __exit__, - // and "deletes" it off stack, shifting "exception control block" - // to its place. - // The bytecode emitter ensures that there is enough space on the Python - // value stack to hold the __exit__ method plus an additional 4 entries. - if (TOP() == mp_const_none) { - // stack: (..., __exit__, ctx_mgr, None) - sp[1] = mp_const_none; - sp[2] = mp_const_none; - sp -= 2; - mp_call_method_n_kw(3, 0, sp); - SET_TOP(mp_const_none); - } else if (MP_OBJ_IS_SMALL_INT(TOP())) { - mp_int_t cause_val = MP_OBJ_SMALL_INT_VALUE(TOP()); - if (cause_val == UNWIND_RETURN) { - // stack: (..., __exit__, ctx_mgr, ret_val, UNWIND_RETURN) - mp_obj_t ret_val = sp[-1]; - sp[-1] = mp_const_none; - sp[0] = mp_const_none; - sp[1] = mp_const_none; - mp_call_method_n_kw(3, 0, sp - 3); - sp[-3] = ret_val; - sp[-2] = MP_OBJ_NEW_SMALL_INT(UNWIND_RETURN); - } else { - assert(cause_val == UNWIND_JUMP); - // stack: (..., __exit__, ctx_mgr, dest_ip, num_exc, UNWIND_JUMP) - mp_obj_t dest_ip = sp[-2]; - mp_obj_t num_exc = sp[-1]; - sp[-2] = mp_const_none; - sp[-1] = mp_const_none; - sp[0] = mp_const_none; - mp_call_method_n_kw(3, 0, sp - 4); - sp[-4] = dest_ip; - sp[-3] = num_exc; - sp[-2] = MP_OBJ_NEW_SMALL_INT(UNWIND_JUMP); - } - sp -= 2; // we removed (__exit__, ctx_mgr) - } else { - assert(mp_obj_is_exception_instance(TOP())); - // stack: (..., __exit__, ctx_mgr, exc_instance) - // Need to pass (exc_type, exc_instance, None) as arguments to __exit__. - sp[1] = sp[0]; - sp[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(sp[0])); - sp[2] = mp_const_none; - sp -= 2; - mp_obj_t ret_value = mp_call_method_n_kw(3, 0, sp); - if (mp_obj_is_true(ret_value)) { - // We need to silence/swallow the exception. This is done - // by popping the exception and the __exit__ handler and - // replacing it with None, which signals END_FINALLY to just - // execute the finally handler normally. - SET_TOP(mp_const_none); - assert(exc_sp >= exc_stack); - POP_EXC_BLOCK(); - } else { - // We need to re-raise the exception. We pop __exit__ handler - // by copying the exception instance down to the new top-of-stack. - sp[0] = sp[3]; - } - } - DISPATCH(); - } - - ENTRY(MP_BC_UNWIND_JUMP): { - MARK_EXC_IP_SELECTIVE(); - DECODE_SLABEL; - PUSH((mp_obj_t)(mp_uint_t)(uintptr_t)(ip + slab)); // push destination ip for jump - PUSH((mp_obj_t)(mp_uint_t)(*ip)); // push number of exception handlers to unwind (0x80 bit set if we also need to pop stack) -unwind_jump:; - mp_uint_t unum = (mp_uint_t)POP(); // get number of exception handlers to unwind - while ((unum & 0x7f) > 0) { - unum -= 1; - assert(exc_sp >= exc_stack); - if (MP_TAGPTR_TAG1(exc_sp->val_sp)) { - // Getting here the stack looks like: - // (..., X, dest_ip) - // where X is pointed to by exc_sp->val_sp and in the case - // of a "with" block contains the context manager info. - // We're going to run "finally" code as a coroutine - // (not calling it recursively). Set up a sentinel - // on a stack so it can return back to us when it is - // done (when WITH_CLEANUP or END_FINALLY reached). - PUSH((mp_obj_t)unum); // push number of exception handlers left to unwind - PUSH(MP_OBJ_NEW_SMALL_INT(UNWIND_JUMP)); // push sentinel - ip = exc_sp->handler; // get exception handler byte code address - exc_sp--; // pop exception handler - goto dispatch_loop; // run the exception handler - } - POP_EXC_BLOCK(); - } - ip = (const byte*)MP_OBJ_TO_PTR(POP()); // pop destination ip for jump - if (unum != 0) { - // pop the exhausted iterator - sp -= MP_OBJ_ITER_BUF_NSLOTS; - } - DISPATCH_WITH_PEND_EXC_CHECK(); - } - - // matched against: POP_BLOCK or POP_EXCEPT (anything else?) - ENTRY(MP_BC_SETUP_EXCEPT): - ENTRY(MP_BC_SETUP_FINALLY): { - MARK_EXC_IP_SELECTIVE(); - #if SELECTIVE_EXC_IP - PUSH_EXC_BLOCK((code_state->ip[-1] == MP_BC_SETUP_FINALLY) ? 1 : 0); - #else - PUSH_EXC_BLOCK((code_state->ip[0] == MP_BC_SETUP_FINALLY) ? 1 : 0); - #endif - DISPATCH(); - } - - ENTRY(MP_BC_END_FINALLY): - MARK_EXC_IP_SELECTIVE(); - // if TOS is None, just pops it and continues - // if TOS is an integer, finishes coroutine and returns control to caller - // if TOS is an exception, reraises the exception - if (TOP() == mp_const_none) { - sp--; - } else if (MP_OBJ_IS_SMALL_INT(TOP())) { - // We finished "finally" coroutine and now dispatch back - // to our caller, based on TOS value - mp_unwind_reason_t reason = MP_OBJ_SMALL_INT_VALUE(POP()); - if (reason == UNWIND_RETURN) { - goto unwind_return; - } else { - assert(reason == UNWIND_JUMP); - goto unwind_jump; - } - } else { - assert(mp_obj_is_exception_instance(TOP())); - RAISE(TOP()); - } - DISPATCH(); - - ENTRY(MP_BC_GET_ITER): - MARK_EXC_IP_SELECTIVE(); - SET_TOP(mp_getiter(TOP(), NULL)); - DISPATCH(); - - // An iterator for a for-loop takes MP_OBJ_ITER_BUF_NSLOTS slots on - // the Python value stack. These slots are either used to store the - // iterator object itself, or the first slot is MP_OBJ_NULL and - // the second slot holds a reference to the iterator object. - ENTRY(MP_BC_GET_ITER_STACK): { - MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = TOP(); - mp_obj_iter_buf_t *iter_buf = (mp_obj_iter_buf_t*)sp; - sp += MP_OBJ_ITER_BUF_NSLOTS - 1; - obj = mp_getiter(obj, iter_buf); - if (obj != MP_OBJ_FROM_PTR(iter_buf)) { - // Iterator didn't use the stack so indicate that with MP_OBJ_NULL. - sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] = MP_OBJ_NULL; - sp[-MP_OBJ_ITER_BUF_NSLOTS + 2] = obj; - } - DISPATCH(); - } - - ENTRY(MP_BC_FOR_ITER): { - MARK_EXC_IP_SELECTIVE(); - DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward - code_state->sp = sp; - mp_obj_t obj; - if (sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] == MP_OBJ_NULL) { - obj = sp[-MP_OBJ_ITER_BUF_NSLOTS + 2]; - } else { - obj = MP_OBJ_FROM_PTR(&sp[-MP_OBJ_ITER_BUF_NSLOTS + 1]); - } - mp_obj_t value = mp_iternext_allow_raise(obj); - if (value == MP_OBJ_STOP_ITERATION) { - sp -= MP_OBJ_ITER_BUF_NSLOTS; // pop the exhausted iterator - ip += ulab; // jump to after for-block - } else { - PUSH(value); // push the next iteration value - } - DISPATCH(); - } - - // matched against: SETUP_EXCEPT, SETUP_FINALLY, SETUP_WITH - ENTRY(MP_BC_POP_BLOCK): - // we are exiting an exception handler, so pop the last one of the exception-stack - assert(exc_sp >= exc_stack); - POP_EXC_BLOCK(); - DISPATCH(); - - // matched against: SETUP_EXCEPT - ENTRY(MP_BC_POP_EXCEPT): - assert(exc_sp >= exc_stack); - assert(currently_in_except_block); - POP_EXC_BLOCK(); - DISPATCH(); - - ENTRY(MP_BC_BUILD_TUPLE): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - sp -= unum - 1; - SET_TOP(mp_obj_new_tuple(unum, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_BUILD_LIST): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - sp -= unum - 1; - SET_TOP(mp_obj_new_list(unum, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_BUILD_MAP): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - PUSH(mp_obj_new_dict(unum)); - DISPATCH(); - } - - ENTRY(MP_BC_STORE_MAP): - MARK_EXC_IP_SELECTIVE(); - sp -= 2; - mp_obj_dict_store(sp[0], sp[2], sp[1]); - DISPATCH(); - -#if MICROPY_PY_BUILTINS_SET - ENTRY(MP_BC_BUILD_SET): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - sp -= unum - 1; - SET_TOP(mp_obj_new_set(unum, sp)); - DISPATCH(); - } -#endif - -#if MICROPY_PY_BUILTINS_SLICE - ENTRY(MP_BC_BUILD_SLICE): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - if (unum == 2) { - mp_obj_t stop = POP(); - mp_obj_t start = TOP(); - SET_TOP(mp_obj_new_slice(start, stop, mp_const_none)); - } else { - mp_obj_t step = POP(); - mp_obj_t stop = POP(); - mp_obj_t start = TOP(); - SET_TOP(mp_obj_new_slice(start, stop, step)); - } - DISPATCH(); - } -#endif - - ENTRY(MP_BC_STORE_COMP): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - mp_obj_t obj = sp[-(unum >> 2)]; - if ((unum & 3) == 0) { - mp_obj_list_append(obj, sp[0]); - sp--; - } else if (!MICROPY_PY_BUILTINS_SET || (unum & 3) == 1) { - mp_obj_dict_store(obj, sp[0], sp[-1]); - sp -= 2; - #if MICROPY_PY_BUILTINS_SET - } else { - mp_obj_set_store(obj, sp[0]); - sp--; - #endif - } - DISPATCH(); - } - - ENTRY(MP_BC_UNPACK_SEQUENCE): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - mp_unpack_sequence(sp[0], unum, sp); - sp += unum - 1; - DISPATCH(); - } - - ENTRY(MP_BC_UNPACK_EX): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - mp_unpack_ex(sp[0], unum, sp); - sp += (unum & 0xff) + ((unum >> 8) & 0xff); - DISPATCH(); - } - - ENTRY(MP_BC_MAKE_FUNCTION): { - DECODE_PTR; - PUSH(mp_make_function_from_raw_code(ptr, MP_OBJ_NULL, MP_OBJ_NULL)); - DISPATCH(); - } - - ENTRY(MP_BC_MAKE_FUNCTION_DEFARGS): { - DECODE_PTR; - // Stack layout: def_tuple def_dict <- TOS - mp_obj_t def_dict = POP(); - SET_TOP(mp_make_function_from_raw_code(ptr, TOP(), def_dict)); - DISPATCH(); - } - - ENTRY(MP_BC_MAKE_CLOSURE): { - DECODE_PTR; - size_t n_closed_over = *ip++; - // Stack layout: closed_overs <- TOS - sp -= n_closed_over - 1; - SET_TOP(mp_make_closure_from_raw_code(ptr, n_closed_over, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_MAKE_CLOSURE_DEFARGS): { - DECODE_PTR; - size_t n_closed_over = *ip++; - // Stack layout: def_tuple def_dict closed_overs <- TOS - sp -= 2 + n_closed_over - 1; - SET_TOP(mp_make_closure_from_raw_code(ptr, 0x100 | n_closed_over, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_CALL_FUNCTION): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - // unum & 0xff == n_positional - // (unum >> 8) & 0xff == n_keyword - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe); - #if MICROPY_STACKLESS - if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { - code_state->ip = ip; - code_state->sp = sp; - code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); - mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1); - if (new_state) { - new_state->prev = code_state; - code_state = new_state; - nlr_pop(); - goto run_code_state; - } - #if MICROPY_STACKLESS_STRICT - else { - deep_recursion_error: - mp_exc_recursion_depth(); - } - #endif - } - #endif - SET_TOP(mp_call_function_n_kw(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1)); - DISPATCH(); - } - - ENTRY(MP_BC_CALL_FUNCTION_VAR_KW): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - // unum & 0xff == n_positional - // (unum >> 8) & 0xff == n_keyword - // We have following stack layout here: - // fun arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 2; - #if MICROPY_STACKLESS - if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { - code_state->ip = ip; - code_state->sp = sp; - code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); - - mp_call_args_t out_args; - mp_call_prepare_args_n_kw_var(false, unum, sp, &out_args); - - mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(out_args.fun, - out_args.n_args, out_args.n_kw, out_args.args); - m_del(mp_obj_t, out_args.args, out_args.n_alloc); - if (new_state) { - new_state->prev = code_state; - code_state = new_state; - nlr_pop(); - goto run_code_state; - } - #if MICROPY_STACKLESS_STRICT - else { - goto deep_recursion_error; - } - #endif - } - #endif - SET_TOP(mp_call_method_n_kw_var(false, unum, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_CALL_METHOD): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - // unum & 0xff == n_positional - // (unum >> 8) & 0xff == n_keyword - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 1; - #if MICROPY_STACKLESS - if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { - code_state->ip = ip; - code_state->sp = sp; - code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); - - size_t n_args = unum & 0xff; - size_t n_kw = (unum >> 8) & 0xff; - int adjust = (sp[1] == MP_OBJ_NULL) ? 0 : 1; - - mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(*sp, n_args + adjust, n_kw, sp + 2 - adjust); - if (new_state) { - new_state->prev = code_state; - code_state = new_state; - nlr_pop(); - goto run_code_state; - } - #if MICROPY_STACKLESS_STRICT - else { - goto deep_recursion_error; - } - #endif - } - #endif - SET_TOP(mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_CALL_METHOD_VAR_KW): { - MARK_EXC_IP_SELECTIVE(); - DECODE_UINT; - // unum & 0xff == n_positional - // (unum >> 8) & 0xff == n_keyword - // We have following stack layout here: - // fun self arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS - sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 3; - #if MICROPY_STACKLESS - if (mp_obj_get_type(*sp) == &mp_type_fun_bc) { - code_state->ip = ip; - code_state->sp = sp; - code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); - - mp_call_args_t out_args; - mp_call_prepare_args_n_kw_var(true, unum, sp, &out_args); - - mp_code_state_t *new_state = mp_obj_fun_bc_prepare_codestate(out_args.fun, - out_args.n_args, out_args.n_kw, out_args.args); - m_del(mp_obj_t, out_args.args, out_args.n_alloc); - if (new_state) { - new_state->prev = code_state; - code_state = new_state; - nlr_pop(); - goto run_code_state; - } - #if MICROPY_STACKLESS_STRICT - else { - goto deep_recursion_error; - } - #endif - } - #endif - SET_TOP(mp_call_method_n_kw_var(true, unum, sp)); - DISPATCH(); - } - - ENTRY(MP_BC_RETURN_VALUE): - MARK_EXC_IP_SELECTIVE(); - // These next 3 lines pop a try-finally exception handler, if one - // is there on the exception stack. Without this the finally block - // is executed a second time when the return is executed, because - // the try-finally exception handler is still on the stack. - // TODO Possibly find a better way to handle this case. - if (currently_in_except_block) { - POP_EXC_BLOCK(); - } -unwind_return: - while (exc_sp >= exc_stack) { - if (MP_TAGPTR_TAG1(exc_sp->val_sp)) { - // Getting here the stack looks like: - // (..., X, [iter0, iter1, ...,] ret_val) - // where X is pointed to by exc_sp->val_sp and in the case - // of a "with" block contains the context manager info. - // There may be 0 or more for-iterators between X and the - // return value, and these must be removed before control can - // pass to the finally code. We simply copy the ret_value down - // over these iterators, if they exist. If they don't then the - // following is a null operation. - mp_obj_t *finally_sp = MP_TAGPTR_PTR(exc_sp->val_sp); - finally_sp[1] = sp[0]; - sp = &finally_sp[1]; - // We're going to run "finally" code as a coroutine - // (not calling it recursively). Set up a sentinel - // on a stack so it can return back to us when it is - // done (when WITH_CLEANUP or END_FINALLY reached). - PUSH(MP_OBJ_NEW_SMALL_INT(UNWIND_RETURN)); - ip = exc_sp->handler; - exc_sp--; - goto dispatch_loop; - } - exc_sp--; - } - nlr_pop(); - code_state->sp = sp; - assert(exc_sp == exc_stack - 1); - MICROPY_VM_HOOK_RETURN - #if MICROPY_STACKLESS - if (code_state->prev != NULL) { - mp_obj_t res = *sp; - mp_globals_set(code_state->old_globals); - code_state = code_state->prev; - *code_state->sp = res; - goto run_code_state; - } - #endif - return MP_VM_RETURN_NORMAL; - - ENTRY(MP_BC_RAISE_VARARGS): { - MARK_EXC_IP_SELECTIVE(); - mp_uint_t unum = *ip++; - mp_obj_t obj; - if (unum == 2) { - mp_warning("exception chaining not supported"); - // ignore (pop) "from" argument - sp--; - } - if (unum == 0) { - // search for the inner-most previous exception, to reraise it - obj = MP_OBJ_NULL; - for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; e--) { - if (e->prev_exc != NULL) { - obj = MP_OBJ_FROM_PTR(e->prev_exc); - break; - } - } - if (obj == MP_OBJ_NULL) { - obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, "No active exception to reraise"); - RAISE(obj); - } - } else { - obj = POP(); - } - obj = mp_make_raise_obj(obj); - RAISE(obj); - } - - ENTRY(MP_BC_YIELD_VALUE): -yield: - nlr_pop(); - code_state->ip = ip; - code_state->sp = sp; - code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block); - return MP_VM_RETURN_YIELD; - - ENTRY(MP_BC_YIELD_FROM): { - MARK_EXC_IP_SELECTIVE(); -//#define EXC_MATCH(exc, type) MP_OBJ_IS_TYPE(exc, type) -#define EXC_MATCH(exc, type) mp_obj_exception_match(exc, type) -#define GENERATOR_EXIT_IF_NEEDED(t) if (t != MP_OBJ_NULL && EXC_MATCH(t, MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) { RAISE(t); } - mp_vm_return_kind_t ret_kind; - mp_obj_t send_value = POP(); - mp_obj_t t_exc = MP_OBJ_NULL; - mp_obj_t ret_value; - if (inject_exc != MP_OBJ_NULL) { - t_exc = inject_exc; - inject_exc = MP_OBJ_NULL; - ret_kind = mp_resume(TOP(), MP_OBJ_NULL, t_exc, &ret_value); - } else { - ret_kind = mp_resume(TOP(), send_value, MP_OBJ_NULL, &ret_value); - } - - if (ret_kind == MP_VM_RETURN_YIELD) { - ip--; - PUSH(ret_value); - goto yield; - } else if (ret_kind == MP_VM_RETURN_NORMAL) { - // Pop exhausted gen - sp--; - // TODO: When ret_value can be MP_OBJ_NULL here?? - if (ret_value == MP_OBJ_NULL || ret_value == MP_OBJ_STOP_ITERATION) { - // Optimize StopIteration - // TODO: get StopIteration's value - PUSH(mp_const_none); - } else { - PUSH(ret_value); - } - - // If we injected GeneratorExit downstream, then even - // if it was swallowed, we re-raise GeneratorExit - GENERATOR_EXIT_IF_NEEDED(t_exc); - DISPATCH(); - } else { - assert(ret_kind == MP_VM_RETURN_EXCEPTION); - // Pop exhausted gen - sp--; - if (EXC_MATCH(ret_value, MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { - PUSH(mp_obj_exception_get_value(ret_value)); - // If we injected GeneratorExit downstream, then even - // if it was swallowed, we re-raise GeneratorExit - GENERATOR_EXIT_IF_NEEDED(t_exc); - DISPATCH(); - } else { - RAISE(ret_value); - } - } - } - - ENTRY(MP_BC_IMPORT_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_obj_t obj = POP(); - SET_TOP(mp_import_name(qst, obj, TOP())); - DISPATCH(); - } - - ENTRY(MP_BC_IMPORT_FROM): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_obj_t obj = mp_import_from(TOP(), qst); - PUSH(obj); - DISPATCH(); - } - - ENTRY(MP_BC_IMPORT_STAR): - MARK_EXC_IP_SELECTIVE(); - mp_import_all(POP()); - DISPATCH(); - -#if MICROPY_OPT_COMPUTED_GOTO - ENTRY(MP_BC_LOAD_CONST_SMALL_INT_MULTI): - PUSH(MP_OBJ_NEW_SMALL_INT((mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16)); - DISPATCH(); - - ENTRY(MP_BC_LOAD_FAST_MULTI): - obj_shared = fastn[MP_BC_LOAD_FAST_MULTI - (mp_int_t)ip[-1]]; - goto load_check; - - ENTRY(MP_BC_STORE_FAST_MULTI): - fastn[MP_BC_STORE_FAST_MULTI - (mp_int_t)ip[-1]] = POP(); - DISPATCH(); - - ENTRY(MP_BC_UNARY_OP_MULTI): - MARK_EXC_IP_SELECTIVE(); - SET_TOP(mp_unary_op(ip[-1] - MP_BC_UNARY_OP_MULTI, TOP())); - DISPATCH(); - - ENTRY(MP_BC_BINARY_OP_MULTI): { - MARK_EXC_IP_SELECTIVE(); - mp_obj_t rhs = POP(); - mp_obj_t lhs = TOP(); - SET_TOP(mp_binary_op(ip[-1] - MP_BC_BINARY_OP_MULTI, lhs, rhs)); - DISPATCH(); - } - - ENTRY_DEFAULT: - MARK_EXC_IP_SELECTIVE(); -#else - ENTRY_DEFAULT: - if (ip[-1] < MP_BC_LOAD_CONST_SMALL_INT_MULTI + 64) { - PUSH(MP_OBJ_NEW_SMALL_INT((mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16)); - DISPATCH(); - } else if (ip[-1] < MP_BC_LOAD_FAST_MULTI + 16) { - obj_shared = fastn[MP_BC_LOAD_FAST_MULTI - (mp_int_t)ip[-1]]; - goto load_check; - } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { - fastn[MP_BC_STORE_FAST_MULTI - (mp_int_t)ip[-1]] = POP(); - DISPATCH(); - } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + 7) { - SET_TOP(mp_unary_op(ip[-1] - MP_BC_UNARY_OP_MULTI, TOP())); - DISPATCH(); - } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + 36) { - mp_obj_t rhs = POP(); - mp_obj_t lhs = TOP(); - SET_TOP(mp_binary_op(ip[-1] - MP_BC_BINARY_OP_MULTI, lhs, rhs)); - DISPATCH(); - } else -#endif - { - mp_obj_t obj = mp_obj_new_exception_msg(&mp_type_NotImplementedError, "byte code not implemented"); - nlr_pop(); - fastn[0] = obj; - return MP_VM_RETURN_EXCEPTION; - } - -#if !MICROPY_OPT_COMPUTED_GOTO - } // switch -#endif - -pending_exception_check: - MICROPY_VM_HOOK_LOOP - - #if MICROPY_ENABLE_SCHEDULER - // This is an inlined variant of mp_handle_pending - if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { - MARK_EXC_IP_SELECTIVE(); - mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - if (obj != MP_OBJ_NULL) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; - if (!mp_sched_num_pending()) { - MP_STATE_VM(sched_state) = MP_SCHED_IDLE; - } - MICROPY_END_ATOMIC_SECTION(atomic_state); - RAISE(obj); - } - mp_handle_pending_tail(atomic_state); - } - #else - // This is an inlined variant of mp_handle_pending - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { - MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; - RAISE(obj); - } - #endif - - #if MICROPY_PY_THREAD_GIL - #if MICROPY_PY_THREAD_GIL_VM_DIVISOR - if (--gil_divisor == 0) { - gil_divisor = MICROPY_PY_THREAD_GIL_VM_DIVISOR; - #else - { - #endif - #if MICROPY_ENABLE_SCHEDULER - // can only switch threads if the scheduler is unlocked - if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) - #endif - { - MP_THREAD_GIL_EXIT(); - MP_THREAD_GIL_ENTER(); - } - } - #endif - - } // for loop - - } else { -exception_handler: - // exception occurred - - #if MICROPY_PY_SYS_EXC_INFO - MP_STATE_VM(cur_exception) = nlr.ret_val; - #endif - - #if SELECTIVE_EXC_IP - // with selective ip, we store the ip 1 byte past the opcode, so move ptr back - code_state->ip -= 1; - #endif - - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { - if (code_state->ip) { - // check if it's a StopIteration within a for block - if (*code_state->ip == MP_BC_FOR_ITER) { - const byte *ip = code_state->ip + 1; - DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward - code_state->ip = ip + ulab; // jump to after for-block - code_state->sp -= MP_OBJ_ITER_BUF_NSLOTS; // pop the exhausted iterator - goto outer_dispatch_loop; // continue with dispatch loop - } else if (*code_state->ip == MP_BC_YIELD_FROM) { - // StopIteration inside yield from call means return a value of - // yield from, so inject exception's value as yield from's result - *++code_state->sp = mp_obj_exception_get_value(MP_OBJ_FROM_PTR(nlr.ret_val)); - code_state->ip++; // yield from is over, move to next instruction - goto outer_dispatch_loop; // continue with dispatch loop - } - } - } - -#if MICROPY_STACKLESS -unwind_loop: -#endif - // set file and line number that the exception occurred at - // TODO: don't set traceback for exceptions re-raised by END_FINALLY. - // But consider how to handle nested exceptions. - // TODO need a better way of not adding traceback to constant objects (right now, just GeneratorExit_obj and MemoryError_obj) - if (nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) { - const byte *ip = code_state->fun_bc->bytecode; - ip = mp_decode_uint_skip(ip); // skip n_state - ip = mp_decode_uint_skip(ip); // skip n_exc_stack - ip++; // skip scope_params - ip++; // skip n_pos_args - ip++; // skip n_kwonly_args - ip++; // skip n_def_pos_args - size_t bc = code_state->ip - ip; - size_t code_info_size = mp_decode_uint_value(ip); - ip = mp_decode_uint_skip(ip); // skip code_info_size - bc -= code_info_size; - #if MICROPY_PERSISTENT_CODE - qstr block_name = ip[0] | (ip[1] << 8); - qstr source_file = ip[2] | (ip[3] << 8); - ip += 4; - #else - qstr block_name = mp_decode_uint_value(ip); - ip = mp_decode_uint_skip(ip); - qstr source_file = mp_decode_uint_value(ip); - ip = mp_decode_uint_skip(ip); - #endif - size_t source_line = 1; - size_t c; - while ((c = *ip)) { - size_t b, l; - if ((c & 0x80) == 0) { - // 0b0LLBBBBB encoding - b = c & 0x1f; - l = c >> 5; - ip += 1; - } else { - // 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) - b = c & 0xf; - l = ((c << 4) & 0x700) | ip[1]; - ip += 2; - } - if (bc >= b) { - bc -= b; - source_line += l; - } else { - // found source line corresponding to bytecode offset - break; - } - } - mp_obj_exception_add_traceback(MP_OBJ_FROM_PTR(nlr.ret_val), source_file, source_line, block_name); - } - - while (currently_in_except_block) { - // nested exception - - assert(exc_sp >= exc_stack); - - // TODO make a proper message for nested exception - // at the moment we are just raising the very last exception (the one that caused the nested exception) - - // move up to previous exception handler - POP_EXC_BLOCK(); - } - - if (exc_sp >= exc_stack) { - // set flag to indicate that we are now handling an exception - currently_in_except_block = 1; - - // catch exception and pass to byte code - code_state->ip = exc_sp->handler; - mp_obj_t *sp = MP_TAGPTR_PTR(exc_sp->val_sp); - // save this exception in the stack so it can be used in a reraise, if needed - exc_sp->prev_exc = nlr.ret_val; - // push exception object so it can be handled by bytecode - PUSH(MP_OBJ_FROM_PTR(nlr.ret_val)); - code_state->sp = sp; - - #if MICROPY_STACKLESS - } else if (code_state->prev != NULL) { - mp_globals_set(code_state->old_globals); - code_state = code_state->prev; - size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); - fastn = &code_state->state[n_state - 1]; - exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); - // variables that are visible to the exception handler (declared volatile) - currently_in_except_block = MP_TAGPTR_TAG0(code_state->exc_sp); // 0 or 1, to detect nested exceptions - exc_sp = MP_TAGPTR_PTR(code_state->exc_sp); // stack grows up, exc_sp points to top of stack - goto unwind_loop; - - #endif - } else { - // propagate exception to higher level - // TODO what to do about ip and sp? they don't really make sense at this point - fastn[0] = MP_OBJ_FROM_PTR(nlr.ret_val); // must put exception here because sp is invalid - return MP_VM_RETURN_EXCEPTION; - } - } - } -} diff --git a/user/mpy/py/vmentrytable.h b/user/mpy/py/vmentrytable.h deleted file mode 100644 index 352a6dc..0000000 --- a/user/mpy/py/vmentrytable.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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. - */ - -#if __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winitializer-overrides" -#endif // __clang__ - -static const void *const entry_table[256] = { - [0 ... 255] = &&entry_default, - [MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE, - [MP_BC_LOAD_CONST_NONE] = &&entry_MP_BC_LOAD_CONST_NONE, - [MP_BC_LOAD_CONST_TRUE] = &&entry_MP_BC_LOAD_CONST_TRUE, - [MP_BC_LOAD_CONST_SMALL_INT] = &&entry_MP_BC_LOAD_CONST_SMALL_INT, - [MP_BC_LOAD_CONST_STRING] = &&entry_MP_BC_LOAD_CONST_STRING, - [MP_BC_LOAD_CONST_OBJ] = &&entry_MP_BC_LOAD_CONST_OBJ, - [MP_BC_LOAD_NULL] = &&entry_MP_BC_LOAD_NULL, - [MP_BC_LOAD_FAST_N] = &&entry_MP_BC_LOAD_FAST_N, - [MP_BC_LOAD_DEREF] = &&entry_MP_BC_LOAD_DEREF, - [MP_BC_LOAD_NAME] = &&entry_MP_BC_LOAD_NAME, - [MP_BC_LOAD_GLOBAL] = &&entry_MP_BC_LOAD_GLOBAL, - [MP_BC_LOAD_ATTR] = &&entry_MP_BC_LOAD_ATTR, - [MP_BC_LOAD_METHOD] = &&entry_MP_BC_LOAD_METHOD, - [MP_BC_LOAD_SUPER_METHOD] = &&entry_MP_BC_LOAD_SUPER_METHOD, - [MP_BC_LOAD_BUILD_CLASS] = &&entry_MP_BC_LOAD_BUILD_CLASS, - [MP_BC_LOAD_SUBSCR] = &&entry_MP_BC_LOAD_SUBSCR, - [MP_BC_STORE_FAST_N] = &&entry_MP_BC_STORE_FAST_N, - [MP_BC_STORE_DEREF] = &&entry_MP_BC_STORE_DEREF, - [MP_BC_STORE_NAME] = &&entry_MP_BC_STORE_NAME, - [MP_BC_STORE_GLOBAL] = &&entry_MP_BC_STORE_GLOBAL, - [MP_BC_STORE_ATTR] = &&entry_MP_BC_STORE_ATTR, - [MP_BC_STORE_SUBSCR] = &&entry_MP_BC_STORE_SUBSCR, - [MP_BC_DELETE_FAST] = &&entry_MP_BC_DELETE_FAST, - [MP_BC_DELETE_DEREF] = &&entry_MP_BC_DELETE_DEREF, - [MP_BC_DELETE_NAME] = &&entry_MP_BC_DELETE_NAME, - [MP_BC_DELETE_GLOBAL] = &&entry_MP_BC_DELETE_GLOBAL, - [MP_BC_DUP_TOP] = &&entry_MP_BC_DUP_TOP, - [MP_BC_DUP_TOP_TWO] = &&entry_MP_BC_DUP_TOP_TWO, - [MP_BC_POP_TOP] = &&entry_MP_BC_POP_TOP, - [MP_BC_ROT_TWO] = &&entry_MP_BC_ROT_TWO, - [MP_BC_ROT_THREE] = &&entry_MP_BC_ROT_THREE, - [MP_BC_JUMP] = &&entry_MP_BC_JUMP, - [MP_BC_POP_JUMP_IF_TRUE] = &&entry_MP_BC_POP_JUMP_IF_TRUE, - [MP_BC_POP_JUMP_IF_FALSE] = &&entry_MP_BC_POP_JUMP_IF_FALSE, - [MP_BC_JUMP_IF_TRUE_OR_POP] = &&entry_MP_BC_JUMP_IF_TRUE_OR_POP, - [MP_BC_JUMP_IF_FALSE_OR_POP] = &&entry_MP_BC_JUMP_IF_FALSE_OR_POP, - [MP_BC_SETUP_WITH] = &&entry_MP_BC_SETUP_WITH, - [MP_BC_WITH_CLEANUP] = &&entry_MP_BC_WITH_CLEANUP, - [MP_BC_UNWIND_JUMP] = &&entry_MP_BC_UNWIND_JUMP, - [MP_BC_SETUP_EXCEPT] = &&entry_MP_BC_SETUP_EXCEPT, - [MP_BC_SETUP_FINALLY] = &&entry_MP_BC_SETUP_FINALLY, - [MP_BC_END_FINALLY] = &&entry_MP_BC_END_FINALLY, - [MP_BC_GET_ITER] = &&entry_MP_BC_GET_ITER, - [MP_BC_GET_ITER_STACK] = &&entry_MP_BC_GET_ITER_STACK, - [MP_BC_FOR_ITER] = &&entry_MP_BC_FOR_ITER, - [MP_BC_POP_BLOCK] = &&entry_MP_BC_POP_BLOCK, - [MP_BC_POP_EXCEPT] = &&entry_MP_BC_POP_EXCEPT, - [MP_BC_BUILD_TUPLE] = &&entry_MP_BC_BUILD_TUPLE, - [MP_BC_BUILD_LIST] = &&entry_MP_BC_BUILD_LIST, - [MP_BC_BUILD_MAP] = &&entry_MP_BC_BUILD_MAP, - [MP_BC_STORE_MAP] = &&entry_MP_BC_STORE_MAP, - #if MICROPY_PY_BUILTINS_SET - [MP_BC_BUILD_SET] = &&entry_MP_BC_BUILD_SET, - #endif - #if MICROPY_PY_BUILTINS_SLICE - [MP_BC_BUILD_SLICE] = &&entry_MP_BC_BUILD_SLICE, - #endif - [MP_BC_STORE_COMP] = &&entry_MP_BC_STORE_COMP, - [MP_BC_UNPACK_SEQUENCE] = &&entry_MP_BC_UNPACK_SEQUENCE, - [MP_BC_UNPACK_EX] = &&entry_MP_BC_UNPACK_EX, - [MP_BC_MAKE_FUNCTION] = &&entry_MP_BC_MAKE_FUNCTION, - [MP_BC_MAKE_FUNCTION_DEFARGS] = &&entry_MP_BC_MAKE_FUNCTION_DEFARGS, - [MP_BC_MAKE_CLOSURE] = &&entry_MP_BC_MAKE_CLOSURE, - [MP_BC_MAKE_CLOSURE_DEFARGS] = &&entry_MP_BC_MAKE_CLOSURE_DEFARGS, - [MP_BC_CALL_FUNCTION] = &&entry_MP_BC_CALL_FUNCTION, - [MP_BC_CALL_FUNCTION_VAR_KW] = &&entry_MP_BC_CALL_FUNCTION_VAR_KW, - [MP_BC_CALL_METHOD] = &&entry_MP_BC_CALL_METHOD, - [MP_BC_CALL_METHOD_VAR_KW] = &&entry_MP_BC_CALL_METHOD_VAR_KW, - [MP_BC_RETURN_VALUE] = &&entry_MP_BC_RETURN_VALUE, - [MP_BC_RAISE_VARARGS] = &&entry_MP_BC_RAISE_VARARGS, - [MP_BC_YIELD_VALUE] = &&entry_MP_BC_YIELD_VALUE, - [MP_BC_YIELD_FROM] = &&entry_MP_BC_YIELD_FROM, - [MP_BC_IMPORT_NAME] = &&entry_MP_BC_IMPORT_NAME, - [MP_BC_IMPORT_FROM] = &&entry_MP_BC_IMPORT_FROM, - [MP_BC_IMPORT_STAR] = &&entry_MP_BC_IMPORT_STAR, - [MP_BC_LOAD_CONST_SMALL_INT_MULTI ... MP_BC_LOAD_CONST_SMALL_INT_MULTI + 63] = &&entry_MP_BC_LOAD_CONST_SMALL_INT_MULTI, - [MP_BC_LOAD_FAST_MULTI ... MP_BC_LOAD_FAST_MULTI + 15] = &&entry_MP_BC_LOAD_FAST_MULTI, - [MP_BC_STORE_FAST_MULTI ... MP_BC_STORE_FAST_MULTI + 15] = &&entry_MP_BC_STORE_FAST_MULTI, - [MP_BC_UNARY_OP_MULTI ... MP_BC_UNARY_OP_MULTI + 6] = &&entry_MP_BC_UNARY_OP_MULTI, - [MP_BC_BINARY_OP_MULTI ... MP_BC_BINARY_OP_MULTI + 35] = &&entry_MP_BC_BINARY_OP_MULTI, -}; - -#if __clang__ -#pragma clang diagnostic pop -#endif // __clang__ diff --git a/user/mpy/py/vstr.c b/user/mpy/py/vstr.c deleted file mode 100644 index 8a00f6c..0000000 --- a/user/mpy/py/vstr.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "py/mpconfig.h" -#include "py/misc.h" -#include "py/mpprint.h" - -// returned value is always at least 1 greater than argument -#define ROUND_ALLOC(a) (((a) & ((~0U) - 7)) + 8) - -// Init the vstr so it allocs exactly given number of bytes. Set length to zero. -void vstr_init(vstr_t *vstr, size_t alloc) { - if (alloc < 1) { - alloc = 1; - } - vstr->alloc = alloc; - vstr->len = 0; - vstr->buf = m_new(char, vstr->alloc); - vstr->fixed_buf = false; -} - -// Init the vstr so it allocs exactly enough ram to hold a null-terminated -// string of the given length, and set the length. -void vstr_init_len(vstr_t *vstr, size_t len) { - vstr_init(vstr, len + 1); - vstr->len = len; -} - -void vstr_init_fixed_buf(vstr_t *vstr, size_t alloc, char *buf) { - vstr->alloc = alloc; - vstr->len = 0; - vstr->buf = buf; - vstr->fixed_buf = true; -} - -void vstr_init_print(vstr_t *vstr, size_t alloc, mp_print_t *print) { - vstr_init(vstr, alloc); - print->data = vstr; - print->print_strn = (mp_print_strn_t)vstr_add_strn; -} - -void vstr_clear(vstr_t *vstr) { - if (!vstr->fixed_buf) { - m_del(char, vstr->buf, vstr->alloc); - } - vstr->buf = NULL; -} - -vstr_t *vstr_new(size_t alloc) { - vstr_t *vstr = m_new_obj(vstr_t); - vstr_init(vstr, alloc); - return vstr; -} - -void vstr_free(vstr_t *vstr) { - if (vstr != NULL) { - if (!vstr->fixed_buf) { - m_del(char, vstr->buf, vstr->alloc); - } - m_del_obj(vstr_t, vstr); - } -} - -// Extend vstr strictly by requested size, return pointer to newly added chunk. -char *vstr_extend(vstr_t *vstr, size_t size) { - if (vstr->fixed_buf) { - return NULL; - } - char *new_buf = m_renew(char, vstr->buf, vstr->alloc, vstr->alloc + size); - char *p = new_buf + vstr->alloc; - vstr->alloc += size; - vstr->buf = new_buf; - return p; -} - -STATIC bool vstr_ensure_extra(vstr_t *vstr, size_t size) { - if (vstr->len + size > vstr->alloc) { - if (vstr->fixed_buf) { - return false; - } - size_t new_alloc = ROUND_ALLOC((vstr->len + size) + 16); - char *new_buf = m_renew(char, vstr->buf, vstr->alloc, new_alloc); - vstr->alloc = new_alloc; - vstr->buf = new_buf; - } - return true; -} - -void vstr_hint_size(vstr_t *vstr, size_t size) { - vstr_ensure_extra(vstr, size); -} - -char *vstr_add_len(vstr_t *vstr, size_t len) { - if (!vstr_ensure_extra(vstr, len)) { - return NULL; - } - char *buf = vstr->buf + vstr->len; - vstr->len += len; - return buf; -} - -// Doesn't increase len, just makes sure there is a null byte at the end -char *vstr_null_terminated_str(vstr_t *vstr) { - // If there's no more room, add single byte - if (vstr->alloc == vstr->len) { - if (vstr_extend(vstr, 1) == NULL) { - return NULL; - } - } - vstr->buf[vstr->len] = '\0'; - return vstr->buf; -} - -void vstr_add_byte(vstr_t *vstr, byte b) { - byte *buf = (byte*)vstr_add_len(vstr, 1); - if (buf == NULL) { - return; - } - buf[0] = b; -} - -void vstr_add_char(vstr_t *vstr, unichar c) { -#if MICROPY_PY_BUILTINS_STR_UNICODE - // TODO: Can this be simplified and deduplicated? - // Is it worth just calling vstr_add_len(vstr, 4)? - if (c < 0x80) { - byte *buf = (byte*)vstr_add_len(vstr, 1); - if (buf == NULL) { - return; - } - *buf = (byte)c; - } else if (c < 0x800) { - byte *buf = (byte*)vstr_add_len(vstr, 2); - if (buf == NULL) { - return; - } - buf[0] = (c >> 6) | 0xC0; - buf[1] = (c & 0x3F) | 0x80; - } else if (c < 0x10000) { - byte *buf = (byte*)vstr_add_len(vstr, 3); - if (buf == NULL) { - return; - } - buf[0] = (c >> 12) | 0xE0; - buf[1] = ((c >> 6) & 0x3F) | 0x80; - buf[2] = (c & 0x3F) | 0x80; - } else { - assert(c < 0x110000); - byte *buf = (byte*)vstr_add_len(vstr, 4); - if (buf == NULL) { - return; - } - buf[0] = (c >> 18) | 0xF0; - buf[1] = ((c >> 12) & 0x3F) | 0x80; - buf[2] = ((c >> 6) & 0x3F) | 0x80; - buf[3] = (c & 0x3F) | 0x80; - } -#else - vstr_add_byte(vstr, c); -#endif -} - -void vstr_add_str(vstr_t *vstr, const char *str) { - vstr_add_strn(vstr, str, strlen(str)); -} - -void vstr_add_strn(vstr_t *vstr, const char *str, size_t len) { - if (!vstr_ensure_extra(vstr, len)) { - // if buf is fixed, we got here because there isn't enough room left - // so just try to copy as much as we can, with room for a possible null byte - if (vstr->fixed_buf && vstr->len < vstr->alloc) { - len = vstr->alloc - vstr->len; - goto copy; - } - return; - } -copy: - memmove(vstr->buf + vstr->len, str, len); - vstr->len += len; -} - -STATIC char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) { - size_t l = vstr->len; - if (byte_pos > l) { - byte_pos = l; - } - if (byte_len > 0) { - // ensure room for the new bytes - if (!vstr_ensure_extra(vstr, byte_len)) { - return NULL; - } - // copy up the string to make room for the new bytes - memmove(vstr->buf + byte_pos + byte_len, vstr->buf + byte_pos, l - byte_pos); - // increase the length - vstr->len += byte_len; - } - return vstr->buf + byte_pos; -} - -void vstr_ins_byte(vstr_t *vstr, size_t byte_pos, byte b) { - char *s = vstr_ins_blank_bytes(vstr, byte_pos, 1); - if (s != NULL) { - *s = b; - } -} - -void vstr_ins_char(vstr_t *vstr, size_t char_pos, unichar chr) { - // TODO UNICODE - char *s = vstr_ins_blank_bytes(vstr, char_pos, 1); - if (s != NULL) { - *s = chr; - } -} - -void vstr_cut_head_bytes(vstr_t *vstr, size_t bytes_to_cut) { - vstr_cut_out_bytes(vstr, 0, bytes_to_cut); -} - -void vstr_cut_tail_bytes(vstr_t *vstr, size_t len) { - if (len > vstr->len) { - vstr->len = 0; - } else { - vstr->len -= len; - } -} - -void vstr_cut_out_bytes(vstr_t *vstr, size_t byte_pos, size_t bytes_to_cut) { - if (byte_pos >= vstr->len) { - return; - } else if (byte_pos + bytes_to_cut >= vstr->len) { - vstr->len = byte_pos; - } else { - memmove(vstr->buf + byte_pos, vstr->buf + byte_pos + bytes_to_cut, vstr->len - byte_pos - bytes_to_cut); - vstr->len -= bytes_to_cut; - } -} - -void vstr_printf(vstr_t *vstr, const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - vstr_vprintf(vstr, fmt, ap); - va_end(ap); -} - -void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap) { - mp_print_t print = {vstr, (mp_print_strn_t)vstr_add_strn}; - mp_vprintf(&print, fmt, ap); -} diff --git a/user/mpy/py/warning.c b/user/mpy/py/warning.c deleted file mode 100644 index 46b31ec..0000000 --- a/user/mpy/py/warning.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "py/emit.h" -#include "py/runtime.h" - -#if MICROPY_WARNINGS - -void mp_warning(const char *msg, ...) { - va_list args; - va_start(args, msg); - mp_print_str(&mp_plat_print, "Warning: "); - mp_vprintf(&mp_plat_print, msg, args); - mp_print_str(&mp_plat_print, "\n"); - va_end(args); -} - -void mp_emitter_warning(pass_kind_t pass, const char *msg) { - if (pass == MP_PASS_CODE_SIZE) { - mp_warning(msg, NULL); - } -} - -#endif // MICROPY_WARNINGS diff --git a/user/mpy/tools/.gitattributes b/user/mpy/tools/.gitattributes deleted file mode 100644 index 9206a0b..0000000 --- a/user/mpy/tools/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.tar.gz binary diff --git a/user/mpy/tools/.gitignore b/user/mpy/tools/.gitignore deleted file mode 100644 index 9f65f49..0000000 --- a/user/mpy/tools/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -tinytest/.gitignore -tinytest/.travis.yml -tinytest/Makefile -tinytest/Makefile.arm-cortex-m3-qemu -tinytest/Makefile.avr -tinytest/TODO -tinytest/portable_demo.c -tinytest/tinytest_demo.c diff --git a/user/mpy/tools/bootstrap_upip.sh b/user/mpy/tools/bootstrap_upip.sh deleted file mode 100755 index 667d084..0000000 --- a/user/mpy/tools/bootstrap_upip.sh +++ /dev/null @@ -1,30 +0,0 @@ -# This script performs bootstrap installation of upip package manager from PyPI -# All the other packages can be installed using it. - -saved="$PWD" - -if [ "$1" = "" ]; then - dest=~/.micropython/lib/ -else - dest="$1" -fi - -if [ -z "$TMPDIR" ]; then - cd /tmp -else - cd $TMPDIR -fi - -# Remove any stale old version -rm -rf micropython-upip-* -wget -nd -r -l1 https://pypi.python.org/pypi/micropython-upip/ --accept-regex ".*pypi.python.org/packages/source/.*.gz" --reject=html - -tar xfz micropython-upip-*.tar.gz -tmpd="$PWD" - -cd "$saved" -mkdir -p "$dest" -cp "$tmpd"/micropython-upip-*/upip*.py "$dest" - -echo "upip is installed. To use:" -echo "micropython -m upip --help" diff --git a/user/mpy/tools/build-stm-latest.sh b/user/mpy/tools/build-stm-latest.sh deleted file mode 100755 index 07cb168..0000000 --- a/user/mpy/tools/build-stm-latest.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# function for building firmware -function do_build() { - descr=$1 - board=$2 - shift - shift - echo "building $descr $board" - build_dir=/tmp/stm-build-$board - make -B $@ BOARD=$board BUILD=$build_dir || exit 1 - mv $build_dir/firmware.dfu $dest_dir/$descr-$date-$git_tag.dfu - rm -rf $build_dir -} - -# check/get parameters -if [ $# != 1 ]; then - echo "usage: $0 " - exit 1 -fi - -dest_dir=$1 - -# check we are in the correct directory -if [ ! -r modpyb.c ]; then - echo "must be in stm directory" - exit 1 -fi - -# get the date -date=$(date '+%Y-%m-%d') - -# get the git tag -git_tag="$(git describe --dirty || echo unknown)" - -# build the versions -do_build pybv3 PYBV3 -do_build pybv3-network PYBV3 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1 -do_build pybv10 PYBV10 -do_build pybv10-network PYBV10 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1 -do_build stm32f4disc STM32F4DISC -do_build espruino-pico ESPRUINO_PICO diff --git a/user/mpy/tools/cc1 b/user/mpy/tools/cc1 deleted file mode 100755 index 827d588..0000000 --- a/user/mpy/tools/cc1 +++ /dev/null @@ -1,262 +0,0 @@ -#!/usr/bin/env python3 - -""" -This is a middle-processor for MicroPython source files. It takes the output -of the C preprocessor, has the option to change it, then feeds this into the -C compiler. - -It currently has the ability to reorder static hash tables so they are actually -hashed, resulting in faster lookup times at runtime. - -To use, configure the Python variables below, and add the following line to the -Makefile: - -CFLAGS += -no-integrated-cpp -B$(shell pwd)/../tools -""" - -import sys -import os -import re - -################################################################################ -# these are the configuration variables -# TODO somehow make them externally configurable - -# this is the path to the true C compiler -cc1_path = '/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1' -#cc1_path = '/usr/lib/gcc/arm-none-eabi/5.3.0/cc1' - -# this must be the same as MICROPY_QSTR_BYTES_IN_HASH -bytes_in_qstr_hash = 2 - -# this must be 1 or more (can be a decimal) -# larger uses more code size but yields faster lookups -table_size_mult = 1 - -# these control output during processing -print_stats = True -print_debug = False - -# end configuration variables -################################################################################ - -# precompile regexs -re_preproc_line = re.compile(r'# [0-9]+ ') -re_map_entry = re.compile(r'\{.+?\(MP_QSTR_([A-Za-z0-9_]+)\).+\},') -re_mp_obj_dict_t = re.compile(r'(?P(static )?const mp_obj_dict_t (?P[a-z0-9_]+) = \{ \.base = \{&mp_type_dict\}, \.map = \{ \.all_keys_are_qstrs = 1, \.is_fixed = 1, \.is_ordered = )1(?P, \.used = .+ };)$') -re_mp_map_t = re.compile(r'(?P(static )?const mp_map_t (?P[a-z0-9_]+) = \{ \.all_keys_are_qstrs = 1, \.is_fixed = 1, \.is_ordered = )1(?P, \.used = .+ };)$') -re_mp_rom_map_elem_t = re.compile(r'static const mp_rom_map_elem_t [a-z_0-9]+\[\] = {$') - -# this must match the equivalent function in qstr.c -def compute_hash(qstr): - hash = 5381 - for char in qstr: - hash = (hash * 33) ^ ord(char) - # Make sure that valid hash is never zero, zero means "hash not computed" - return (hash & ((1 << (8 * bytes_in_qstr_hash)) - 1)) or 1 - -# this algo must match the equivalent in map.c -def hash_insert(map, key, value): - hash = compute_hash(key) - pos = hash % len(map) - start_pos = pos - if print_debug: - print(' insert %s: start at %u/%u -- ' % (key, pos, len(map)), end='') - while True: - if map[pos] is None: - # found empty slot, so key is not in table - if print_debug: - print('put at %u' % pos) - map[pos] = (key, value) - return - else: - # not yet found, keep searching - if map[pos][0] == key: - raise AssertionError("duplicate key '%s'" % (key,)) - pos = (pos + 1) % len(map) - assert pos != start_pos - -def hash_find(map, key): - hash = compute_hash(key) - pos = hash % len(map) - start_pos = pos - attempts = 0 - while True: - attempts += 1 - if map[pos] is None: - return attempts, None - elif map[pos][0] == key: - return attempts, map[pos][1] - else: - pos = (pos + 1) % len(map) - if pos == start_pos: - return attempts, None - -def process_map_table(file, line, output): - output.append(line) - - # consume all lines that are entries of the table and concat them - # (we do it this way because there can be multiple entries on one line) - table_contents = [] - while True: - line = file.readline() - if len(line) == 0: - print('unexpected end of input') - sys.exit(1) - line = line.strip() - if len(line) == 0: - # empty line - continue - if re_preproc_line.match(line): - # preprocessor line number comment - continue - if line == '};': - # end of table (we assume it appears on a single line) - break - table_contents.append(line) - - # make combined string of entries - entries_str = ''.join(table_contents) - - # split into individual entries - entries = [] - while entries_str: - # look for single entry, by matching nested braces - match = None - if entries_str[0] == '{': - nested_braces = 0 - for i in range(len(entries_str)): - if entries_str[i] == '{': - nested_braces += 1 - elif entries_str[i] == '}': - nested_braces -= 1 - if nested_braces == 0: - match = re_map_entry.match(entries_str[:i + 2]) - break - - if not match: - print('unknown line in table:', entries_str) - sys.exit(1) - - # extract single entry - line = match.group(0) - qstr = match.group(1) - entries_str = entries_str[len(line):].lstrip() - - # add the qstr and the whole line to list of all entries - entries.append((qstr, line)) - - # sort entries so hash table construction is deterministic - entries.sort() - - # create hash table - map = [None] * int(len(entries) * table_size_mult) - for qstr, line in entries: - # We assume that qstr does not have any escape sequences in it. - # This is reasonably safe, since keys in a module or class dict - # should be standard identifiers. - # TODO verify this and raise an error if escape sequence found - hash_insert(map, qstr, line) - - # compute statistics - total_attempts = 0 - for qstr, _ in entries: - attempts, line = hash_find(map, qstr) - assert line is not None - if print_debug: - print(' %s lookup took %u attempts' % (qstr, attempts)) - total_attempts += attempts - if len(entries): - stats = len(map), len(entries) / len(map), total_attempts / len(entries) - else: - stats = 0, 0, 0 - if print_debug: - print(' table stats: size=%d, load=%.2f, avg_lookups=%.1f' % stats) - - # output hash table - for row in map: - if row is None: - output.append('{ 0, 0 },\n') - else: - output.append(row[1] + '\n') - output.append('};\n') - - # skip to next non-blank line - while True: - line = file.readline() - if len(line) == 0: - print('unexpected end of input') - sys.exit(1) - line = line.strip() - if len(line) == 0: - continue - break - - # transform the is_ordered param from 1 to 0 - match = re_mp_obj_dict_t.match(line) - if match is None: - match = re_mp_map_t.match(line) - if match is None: - print('expecting mp_obj_dict_t or mp_map_t definition') - print(output[0]) - print(line) - sys.exit(1) - line = match.group('head') + '0' + match.group('tail') + '\n' - output.append(line) - - return (match.group('id'),) + stats - -def process_file(filename): - output = [] - file_changed = False - with open(filename, 'rt') as f: - while True: - line = f.readline() - if not line: - break - if re_mp_rom_map_elem_t.match(line): - file_changed = True - stats = process_map_table(f, line, output) - if print_stats: - print(' [%s: size=%d, load=%.2f, avg_lookups=%.1f]' % stats) - else: - output.append(line) - - if file_changed: - if print_debug: - print(' modifying static maps in', output[0].strip()) - with open(filename, 'wt') as f: - for line in output: - f.write(line) - -def main(): - # run actual C compiler - # need to quote args that have special characters in them - def quote(s): - if s.find('<') != -1 or s.find('>') != -1: - return "'" + s + "'" - else: - return s - ret = os.system(cc1_path + ' ' + ' '.join(quote(s) for s in sys.argv[1:])) - if ret != 0: - ret = (ret & 0x7f) or 127 # make it in range 0-127, but non-zero - sys.exit(ret) - - if sys.argv[1] == '-E': - # CPP has been run, now do our processing stage - for i, arg in enumerate(sys.argv): - if arg == '-o': - return process_file(sys.argv[i + 1]) - - print('%s: could not find "-o" option' % (sys.argv[0],)) - sys.exit(1) - elif sys.argv[1] == '-fpreprocessed': - # compiler has been run, nothing more to do - return - else: - # unknown processing stage - print('%s: unknown first option "%s"' % (sys.argv[0], sys.argv[1])) - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/user/mpy/tools/check_code_size.sh b/user/mpy/tools/check_code_size.sh deleted file mode 100755 index c5f0c6f..0000000 --- a/user/mpy/tools/check_code_size.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# This script check that changes don't lead to code size regressions. -# (Size of the language core (== minimal port should not grow)). -# - -REFERENCE=$HOME/persist/firmware.bin -#REFERENCE=/tmp/micropython -#TRAVIS_PULL_REQUEST=false - -if [ -f $REFERENCE ]; then - size_old=$(stat -c%s $REFERENCE) - size_new=$(stat -c%s minimal/build/firmware.bin) - echo "Old size: $size_old new size: $size_new" - if [ $size_new -gt $size_old ]; then - echo "Validation failure: Core code size increased" - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - exit 1 - fi - fi -else - echo "Warning: reference file doesn't exist, code size check didn't run" -fi diff --git a/user/mpy/tools/codestats.sh b/user/mpy/tools/codestats.sh deleted file mode 100755 index 5272f3e..0000000 --- a/user/mpy/tools/codestats.sh +++ /dev/null @@ -1,187 +0,0 @@ -#!/bin/sh -# -# This script generates statistics (build size, speed) for successive -# revisions of the code. It checks out git commits one an a time, compiles -# various ports to determine their size, and runs pystone on the unix port. -# Results are collected in the output file. -# -# Note: you will need to copy this file out of the tools directory before -# executing because it does not exist in old revisions of the repository. - -# check that we are in the root directory of the repository -if [ ! -d py -o ! -d unix -o ! -d stmhal ]; then - echo "script must be run from root of the repository" - exit 1 -fi - -# output file for the data; data is appended if file already exists -output=codestats.dat - -# utility programs -RM=/bin/rm -AWK=awk -MAKE="make -j2" - -# these are the binaries that are built; some have 2 or 3 depending on version -bin_unix=unix/micropython -bin_stmhal=stmhal/build-PYBV10/firmware.elf -bin_barearm_1=bare-arm/build/flash.elf -bin_barearm_2=bare-arm/build/firmware.elf -bin_minimal=minimal/build/firmware.elf -bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf -bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf -bin_cc3200_3=cc3200/build/WIPY/release/application.axf - -# start at zero size; if build fails reuse previous valid size -size_unix="0" -size_stmhal="0" -size_barearm="0" -size_minimal="0" -size_cc3200="0" - -# start at zero pystones -pystones="0" - -# this code runs pystone and averages the results -pystoneavg=/tmp/pystoneavg.py -cat > $pystoneavg << EOF -import pystone -samples = [pystone.pystones(300000)[1] for i in range(5)] -samples.sort() -stones = sum(samples[1:-1]) / (len(samples) - 2) # exclude smallest and largest -print("stones %g" % stones) -EOF - -function get_size() { - if [ -r $2 ]; then - size $2 | tail -n1 | $AWK '{print $1}' - else - echo $1 - fi -} - -function get_size2() { - if [ -r $2 ]; then - size $2 | tail -n1 | $AWK '{print $1}' - elif [ -r $3 ]; then - size $3 | tail -n1 | $AWK '{print $1}' - else - echo $1 - fi -} - -function get_size3() { - if [ -r $2 ]; then - size $2 | tail -n1 | $AWK '{print $1}' - elif [ -r $3 ]; then - size $3 | tail -n1 | $AWK '{print $1}' - elif [ -r $4 ]; then - size $4 | tail -n1 | $AWK '{print $1}' - else - echo $1 - fi -} - -# get the last revision in the data file; or start at v1.0 if no file -if [ -r $output ]; then - last_rev=$(tail -n1 $output | $AWK '{print $1}') -else - echo "# hash size_unix size_stmhal size_barearm size_minimal size_cc3200 pystones" > $output - last_rev="v1.0" -fi - -# get a list of hashes between last revision (exclusive) and master -hashes=$(git log --format=format:"%H" --reverse ${last_rev}..master) -#hashes=$(git log --format=format:"%H" --reverse ${last_rev}..master | $AWK '{if (NR % 10 == 0) print $0}') # do every 10th one - -for hash in $hashes; do - - #### checkout the revision #### - - git checkout $hash - if [ $? -ne 0 ]; then - echo "aborting" - exit 1 - fi - - #### apply patches to get it to build #### - - if grep -q '#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX' unix/modtime.c; then - echo apply patch - git apply - << EOF -diff --git a/unix/modtime.c b/unix/modtime.c -index 77d2945..dae0644 100644 ---- a/unix/modtime.c -+++ b/unix/modtime.c -@@ -55,10 +55,8 @@ void msec_sleep_tv(struct timeval *tv) { - #define MP_CLOCKS_PER_SEC CLOCKS_PER_SEC - #endif - --#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX --#define CLOCK_DIV 1000.0 --#elif defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000) // WIN32 --#define CLOCK_DIV 1.0 -+#if defined(MP_CLOCKS_PER_SEC) -+#define CLOCK_DIV (MP_CLOCKS_PER_SEC / 1000.0F) - #else - #error Unsupported clock() implementation - #endif -EOF - fi - - #### unix #### - - $RM $bin_unix - $MAKE -C unix CFLAGS_EXTRA=-DNDEBUG - size_unix=$(get_size $size_unix $bin_unix) - - # undo patch if it was applied - git checkout unix/modtime.c - - #### stmhal #### - - $RM $bin_stmhal - $MAKE -C stmhal board=PYBV10 - size_stmhal=$(get_size $size_stmhal $bin_stmhal) - - #### bare-arm #### - - $RM $bin_barearm_1 $bin_barearm_2 - $MAKE -C bare-arm - size_barearm=$(get_size2 $size_barearm $bin_barearm_1 $bin_barearm_2) - - #### minimal #### - - if [ -r minimal/Makefile ]; then - $RM $bin_minimal - $MAKE -C minimal CROSS=1 - size_minimal=$(get_size $size_minimal $bin_minimal) - fi - - #### cc3200 #### - - if [ -r cc3200/Makefile ]; then - $RM $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3 - $MAKE -C cc3200 BTARGET=application - size_cc3200=$(get_size3 $size_cc3200 $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3) - fi - - #### run pystone #### - - if [ -x $bin_unix ]; then - new_pystones=$($bin_unix $pystoneavg) - # only update the variable if pystone executed successfully - if echo $new_pystones | grep -q "^stones"; then - pystones=$(echo $new_pystones | $AWK '{print $2}') - fi - fi - - #### output data for this commit #### - - echo "$hash $size_unix $size_stmhal $size_barearm $size_minimal $size_cc3200 $pystones" >> $output - -done - -# checkout master and cleanup -git checkout master -$RM $pystoneavg diff --git a/user/mpy/tools/dfu.py b/user/mpy/tools/dfu.py deleted file mode 100755 index 54b6024..0000000 --- a/user/mpy/tools/dfu.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python - -# Written by Antonio Galea - 2010/11/18 -# Distributed under Gnu LGPL 3.0 -# see http://www.gnu.org/licenses/lgpl-3.0.txt - -import sys,struct,zlib,os -from optparse import OptionParser - -DEFAULT_DEVICE="0x0483:0xdf11" - -def named(tuple,names): - return dict(zip(names.split(),tuple)) -def consume(fmt,data,names): - n = struct.calcsize(fmt) - return named(struct.unpack(fmt,data[:n]),names),data[n:] -def cstring(string): - return string.split('\0',1)[0] -def compute_crc(data): - return 0xFFFFFFFF & -zlib.crc32(data) -1 - -def parse(file,dump_images=False): - print ('File: "%s"' % file) - data = open(file,'rb').read() - crc = compute_crc(data[:-4]) - prefix, data = consume('<5sBIB',data,'signature version size targets') - print ('%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix) - for t in range(prefix['targets']): - tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') - tprefix['num'] = t - if tprefix['named']: - tprefix['name'] = cstring(tprefix['name']) - else: - tprefix['name'] = '' - print ('%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix) - tsize = tprefix['size'] - target, data = data[:tsize], data[tsize:] - for e in range(tprefix['elements']): - eprefix, target = consume('<2I',target,'address size') - eprefix['num'] = e - print (' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix) - esize = eprefix['size'] - image, target = target[:esize], target[esize:] - if dump_images: - out = '%s.target%d.image%d.bin' % (file,t,e) - open(out,'wb').write(image) - print (' DUMPED IMAGE TO "%s"' % out) - if len(target): - print ("target %d: PARSE ERROR" % t) - suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') - print ('usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix) - if crc != suffix['crc']: - print ("CRC ERROR: computed crc32 is 0x%08x" % crc) - data = data[16:] - if data: - print ("PARSE ERROR") - -def build(file,targets,device=DEFAULT_DEVICE): - data = b'' - for t,target in enumerate(targets): - tdata = b'' - for image in target: - tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] - tdata = struct.pack('<6sBI255s2I',b'Target',0,1, b'ST...',len(tdata),len(target)) + tdata - data += tdata - data = struct.pack('<5sBIB',b'DfuSe',1,len(data)+11,len(targets)) + data - v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) - data += struct.pack('<4H3sB',0,d,v,0x011a,b'UFD',16) - crc = compute_crc(data) - data += struct.pack('= len(class_) or section[i] != class_[i]: - if i == 0: - filename = section[i].replace(' ', '_').lower() - rst = open(DOCPATH + filename + '.rst', 'w') - rst.write(HEADER) - rst.write(section[i] + '\n') - rst.write(RSTCHARS[0] * len(section[i])) - rst.write(time.strftime("\nGenerated %a %d %b %Y %X UTC\n\n", time.gmtime())) - toctree.append(filename) - else: - rst.write(section[i] + '\n') - rst.write(RSTCHARS[min(i, len(RSTCHARS)-1)] * len(section[i])) - rst.write('\n\n') - class_ = section - rst.write('.. _cpydiff_%s:\n\n' % output.name.rsplit('.', 1)[0]) - rst.write(output.desc + '\n') - rst.write('~' * len(output.desc) + '\n\n') - if output.cause != 'Unknown': - rst.write('**Cause:** ' + output.cause + '\n\n') - if output.workaround != 'Unknown': - rst.write('**Workaround:** ' + output.workaround + '\n\n') - - rst.write('Sample code::\n\n' + indent(output.code, TAB) + '\n') - output_cpy = indent(''.join(output.output_cpy[0:2]), TAB).rstrip() - output_cpy = ('::\n\n' if output_cpy != '' else '') + output_cpy - output_upy = indent(''.join(output.output_upy[0:2]), TAB).rstrip() - output_upy = ('::\n\n' if output_upy != '' else '') + output_upy - table = gen_table([['CPy output:', output_cpy], ['uPy output:', output_upy]]) - rst.write(table) - - template = open(INDEXTEMPLATE, 'r') - index = open(DOCPATH + INDEX, 'w') - index.write(HEADER) - index.write(template.read()) - for section in INDEXPRIORITY: - if section in toctree: - index.write(indent(section + '.rst', TAB)) - toctree.remove(section) - for section in toctree: - index.write(indent(section + '.rst', TAB)) - -def main(): - """ Main function """ - - # set search path so that test scripts find the test modules (and no other ones) - os.environ['PYTHONPATH'] = TESTPATH - os.environ['MICROPYPATH'] = TESTPATH - - files = readfiles() - results = run_tests(files) - gen_rst(results) - -main() diff --git a/user/mpy/tools/gendoc.py b/user/mpy/tools/gendoc.py deleted file mode 100644 index 61844d2..0000000 --- a/user/mpy/tools/gendoc.py +++ /dev/null @@ -1,528 +0,0 @@ -""" -Generate documentation for pyboard API from C files. -""" - -import os -import argparse -import re -import markdown - -# given a list of (name,regex) pairs, find the first one that matches the given line -def re_match_first(regexs, line): - for name, regex in regexs: - match = re.match(regex, line) - if match: - return name, match - return None, None - -def makedirs(d): - if not os.path.isdir(d): - os.makedirs(d) - -class Lexer: - class LexerError(Exception): - pass - - class EOF(Exception): - pass - - class Break(Exception): - pass - - def __init__(self, file): - self.filename = file - with open(file, 'rt') as f: - line_num = 0 - lines = [] - for line in f: - line_num += 1 - line = line.strip() - if line == '///': - lines.append((line_num, '')) - elif line.startswith('/// '): - lines.append((line_num, line[4:])) - elif len(lines) > 0 and lines[-1][1] is not None: - lines.append((line_num, None)) - if len(lines) > 0 and lines[-1][1] is not None: - lines.append((line_num, None)) - self.cur_line = 0 - self.lines = lines - - def opt_break(self): - if len(self.lines) > 0 and self.lines[0][1] is None: - self.lines.pop(0) - - def next(self): - if len(self.lines) == 0: - raise Lexer.EOF - else: - l = self.lines.pop(0) - self.cur_line = l[0] - if l[1] is None: - raise Lexer.Break - else: - return l[1] - - def error(self, msg): - print('({}:{}) {}'.format(self.filename, self.cur_line, msg)) - raise Lexer.LexerError - -class MarkdownWriter: - def __init__(self): - pass - - def start(self): - self.lines = [] - - def end(self): - return '\n'.join(self.lines) - - def heading(self, level, text): - if len(self.lines) > 0: - self.lines.append('') - self.lines.append(level * '#' + ' ' + text) - self.lines.append('') - - def para(self, text): - if len(self.lines) > 0 and self.lines[-1] != '': - self.lines.append('') - if isinstance(text, list): - self.lines.extend(text) - elif isinstance(text, str): - self.lines.append(text) - else: - assert False - self.lines.append('') - - def single_line(self, text): - self.lines.append(text) - - def module(self, name, short_descr, descr): - self.heading(1, 'module {}'.format(name)) - self.para(descr) - - def function(self, ctx, name, args, descr): - proto = '{}.{}{}'.format(ctx, self.name, self.args) - self.heading(3, '`' + proto + '`') - self.para(descr) - - def method(self, ctx, name, args, descr): - if name == '\\constructor': - proto = '{}{}'.format(ctx, args) - elif name == '\\call': - proto = '{}{}'.format(ctx, args) - else: - proto = '{}.{}{}'.format(ctx, name, args) - self.heading(3, '`' + proto + '`') - self.para(descr) - - def constant(self, ctx, name, descr): - self.single_line('`{}.{}` - {}'.format(ctx, name, descr)) - -class ReStructuredTextWriter: - head_chars = {1:'=', 2:'-', 3:'.'} - - def __init__(self): - pass - - def start(self): - self.lines = [] - - def end(self): - return '\n'.join(self.lines) - - def _convert(self, text): - return text.replace('`', '``').replace('*', '\\*') - - def heading(self, level, text, convert=True): - if len(self.lines) > 0: - self.lines.append('') - if convert: - text = self._convert(text) - self.lines.append(text) - self.lines.append(len(text) * self.head_chars[level]) - self.lines.append('') - - def para(self, text, indent=''): - if len(self.lines) > 0 and self.lines[-1] != '': - self.lines.append('') - if isinstance(text, list): - for t in text: - self.lines.append(indent + self._convert(t)) - elif isinstance(text, str): - self.lines.append(indent + self._convert(text)) - else: - assert False - self.lines.append('') - - def single_line(self, text): - self.lines.append(self._convert(text)) - - def module(self, name, short_descr, descr): - self.heading(1, ':mod:`{}` --- {}'.format(name, self._convert(short_descr)), convert=False) - self.lines.append('.. module:: {}'.format(name)) - self.lines.append(' :synopsis: {}'.format(short_descr)) - self.para(descr) - - def function(self, ctx, name, args, descr): - args = self._convert(args) - self.lines.append('.. function:: ' + name + args) - self.para(descr, indent=' ') - - def method(self, ctx, name, args, descr): - args = self._convert(args) - if name == '\\constructor': - self.lines.append('.. class:: ' + ctx + args) - elif name == '\\call': - self.lines.append('.. method:: ' + ctx + args) - else: - self.lines.append('.. method:: ' + ctx + '.' + name + args) - self.para(descr, indent=' ') - - def constant(self, ctx, name, descr): - self.lines.append('.. data:: ' + name) - self.para(descr, indent=' ') - -class DocValidateError(Exception): - pass - -class DocItem: - def __init__(self): - self.doc = [] - - def add_doc(self, lex): - try: - while True: - line = lex.next() - if len(line) > 0 or len(self.doc) > 0: - self.doc.append(line) - except Lexer.Break: - pass - - def dump(self, writer): - writer.para(self.doc) - -class DocConstant(DocItem): - def __init__(self, name, descr): - super().__init__() - self.name = name - self.descr = descr - - def dump(self, ctx, writer): - writer.constant(ctx, self.name, self.descr) - -class DocFunction(DocItem): - def __init__(self, name, args): - super().__init__() - self.name = name - self.args = args - - def dump(self, ctx, writer): - writer.function(ctx, self.name, self.args, self.doc) - -class DocMethod(DocItem): - def __init__(self, name, args): - super().__init__() - self.name = name - self.args = args - - def dump(self, ctx, writer): - writer.method(ctx, self.name, self.args, self.doc) - -class DocClass(DocItem): - def __init__(self, name, descr): - super().__init__() - self.name = name - self.descr = descr - self.constructors = {} - self.classmethods = {} - self.methods = {} - self.constants = {} - - def process_classmethod(self, lex, d): - name = d['id'] - if name == '\\constructor': - dict_ = self.constructors - else: - dict_ = self.classmethods - if name in dict_: - lex.error("multiple definition of method '{}'".format(name)) - method = dict_[name] = DocMethod(name, d['args']) - method.add_doc(lex) - - def process_method(self, lex, d): - name = d['id'] - dict_ = self.methods - if name in dict_: - lex.error("multiple definition of method '{}'".format(name)) - method = dict_[name] = DocMethod(name, d['args']) - method.add_doc(lex) - - def process_constant(self, lex, d): - name = d['id'] - if name in self.constants: - lex.error("multiple definition of constant '{}'".format(name)) - self.constants[name] = DocConstant(name, d['descr']) - lex.opt_break() - - def dump(self, writer): - writer.heading(1, 'class {}'.format(self.name)) - super().dump(writer) - if len(self.constructors) > 0: - writer.heading(2, 'Constructors') - for f in sorted(self.constructors.values(), key=lambda x:x.name): - f.dump(self.name, writer) - if len(self.classmethods) > 0: - writer.heading(2, 'Class methods') - for f in sorted(self.classmethods.values(), key=lambda x:x.name): - f.dump(self.name, writer) - if len(self.methods) > 0: - writer.heading(2, 'Methods') - for f in sorted(self.methods.values(), key=lambda x:x.name): - f.dump(self.name.lower(), writer) - if len(self.constants) > 0: - writer.heading(2, 'Constants') - for c in sorted(self.constants.values(), key=lambda x:x.name): - c.dump(self.name, writer) - -class DocModule(DocItem): - def __init__(self, name, descr): - super().__init__() - self.name = name - self.descr = descr - self.functions = {} - self.constants = {} - self.classes = {} - self.cur_class = None - - def new_file(self): - self.cur_class = None - - def process_function(self, lex, d): - name = d['id'] - if name in self.functions: - lex.error("multiple definition of function '{}'".format(name)) - function = self.functions[name] = DocFunction(name, d['args']) - function.add_doc(lex) - - #def process_classref(self, lex, d): - # name = d['id'] - # self.classes[name] = name - # lex.opt_break() - - def process_class(self, lex, d): - name = d['id'] - if name in self.classes: - lex.error("multiple definition of class '{}'".format(name)) - self.cur_class = self.classes[name] = DocClass(name, d['descr']) - self.cur_class.add_doc(lex) - - def process_classmethod(self, lex, d): - self.cur_class.process_classmethod(lex, d) - - def process_method(self, lex, d): - self.cur_class.process_method(lex, d) - - def process_constant(self, lex, d): - if self.cur_class is None: - # a module-level constant - name = d['id'] - if name in self.constants: - lex.error("multiple definition of constant '{}'".format(name)) - self.constants[name] = DocConstant(name, d['descr']) - lex.opt_break() - else: - # a class-level constant - self.cur_class.process_constant(lex, d) - - def validate(self): - if self.descr is None: - raise DocValidateError('module {} referenced but never defined'.format(self.name)) - - def dump(self, writer): - writer.module(self.name, self.descr, self.doc) - if self.functions: - writer.heading(2, 'Functions') - for f in sorted(self.functions.values(), key=lambda x:x.name): - f.dump(self.name, writer) - if self.constants: - writer.heading(2, 'Constants') - for c in sorted(self.constants.values(), key=lambda x:x.name): - c.dump(self.name, writer) - if self.classes: - writer.heading(2, 'Classes') - for c in sorted(self.classes.values(), key=lambda x:x.name): - writer.para('[`{}.{}`]({}) - {}'.format(self.name, c.name, c.name, c.descr)) - - def write_html(self, dir): - md_writer = MarkdownWriter() - md_writer.start() - self.dump(md_writer) - with open(os.path.join(dir, 'index.html'), 'wt') as f: - f.write(markdown.markdown(md_writer.end())) - for c in self.classes.values(): - class_dir = os.path.join(dir, c.name) - makedirs(class_dir) - md_writer.start() - md_writer.para('part of the [{} module](./)'.format(self.name)) - c.dump(md_writer) - with open(os.path.join(class_dir, 'index.html'), 'wt') as f: - f.write(markdown.markdown(md_writer.end())) - - def write_rst(self, dir): - rst_writer = ReStructuredTextWriter() - rst_writer.start() - self.dump(rst_writer) - with open(dir + '/' + self.name + '.rst', 'wt') as f: - f.write(rst_writer.end()) - for c in self.classes.values(): - rst_writer.start() - c.dump(rst_writer) - with open(dir + '/' + self.name + '.' + c.name + '.rst', 'wt') as f: - f.write(rst_writer.end()) - -class Doc: - def __init__(self): - self.modules = {} - self.cur_module = None - - def new_file(self): - self.cur_module = None - for m in self.modules.values(): - m.new_file() - - def check_module(self, lex): - if self.cur_module is None: - lex.error('module not defined') - - def process_module(self, lex, d): - name = d['id'] - if name not in self.modules: - self.modules[name] = DocModule(name, None) - self.cur_module = self.modules[name] - if self.cur_module.descr is not None: - lex.error("multiple definition of module '{}'".format(name)) - self.cur_module.descr = d['descr'] - self.cur_module.add_doc(lex) - - def process_moduleref(self, lex, d): - name = d['id'] - if name not in self.modules: - self.modules[name] = DocModule(name, None) - self.cur_module = self.modules[name] - lex.opt_break() - - def process_class(self, lex, d): - self.check_module(lex) - self.cur_module.process_class(lex, d) - - def process_function(self, lex, d): - self.check_module(lex) - self.cur_module.process_function(lex, d) - - def process_classmethod(self, lex, d): - self.check_module(lex) - self.cur_module.process_classmethod(lex, d) - - def process_method(self, lex, d): - self.check_module(lex) - self.cur_module.process_method(lex, d) - - def process_constant(self, lex, d): - self.check_module(lex) - self.cur_module.process_constant(lex, d) - - def validate(self): - for m in self.modules.values(): - m.validate() - - def dump(self, writer): - writer.heading(1, 'Modules') - writer.para('These are the Python modules that are implemented.') - for m in sorted(self.modules.values(), key=lambda x:x.name): - writer.para('[`{}`]({}/) - {}'.format(m.name, m.name, m.descr)) - - def write_html(self, dir): - md_writer = MarkdownWriter() - with open(os.path.join(dir, 'module', 'index.html'), 'wt') as f: - md_writer.start() - self.dump(md_writer) - f.write(markdown.markdown(md_writer.end())) - for m in self.modules.values(): - mod_dir = os.path.join(dir, 'module', m.name) - makedirs(mod_dir) - m.write_html(mod_dir) - - def write_rst(self, dir): - #with open(os.path.join(dir, 'module', 'index.html'), 'wt') as f: - # f.write(markdown.markdown(self.dump())) - for m in self.modules.values(): - m.write_rst(dir) - -regex_descr = r'(?P.*)' - -doc_regexs = ( - (Doc.process_module, re.compile(r'\\module (?P[a-z][a-z0-9]*) - ' + regex_descr + r'$')), - (Doc.process_moduleref, re.compile(r'\\moduleref (?P[a-z]+)$')), - (Doc.process_function, re.compile(r'\\function (?P[a-z0-9_]+)(?P\(.*\))$')), - (Doc.process_classmethod, re.compile(r'\\classmethod (?P\\?[a-z0-9_]+)(?P\(.*\))$')), - (Doc.process_method, re.compile(r'\\method (?P\\?[a-z0-9_]+)(?P\(.*\))$')), - (Doc.process_constant, re.compile(r'\\constant (?P[A-Za-z0-9_]+) - ' + regex_descr + r'$')), - #(Doc.process_classref, re.compile(r'\\classref (?P[A-Za-z0-9_]+)$')), - (Doc.process_class, re.compile(r'\\class (?P[A-Za-z0-9_]+) - ' + regex_descr + r'$')), -) - -def process_file(file, doc): - lex = Lexer(file) - doc.new_file() - try: - try: - while True: - line = lex.next() - fun, match = re_match_first(doc_regexs, line) - if fun == None: - lex.error('unknown line format: {}'.format(line)) - fun(doc, lex, match.groupdict()) - - except Lexer.Break: - lex.error('unexpected break') - - except Lexer.EOF: - pass - - except Lexer.LexerError: - return False - - return True - -def main(): - cmd_parser = argparse.ArgumentParser(description='Generate documentation for pyboard API from C files.') - cmd_parser.add_argument('--outdir', metavar='', default='gendoc-out', help='ouput directory') - cmd_parser.add_argument('--format', default='html', help='output format: html or rst') - cmd_parser.add_argument('files', nargs='+', help='input files') - args = cmd_parser.parse_args() - - doc = Doc() - for file in args.files: - print('processing', file) - if not process_file(file, doc): - return - try: - doc.validate() - except DocValidateError as e: - print(e) - - makedirs(args.outdir) - - if args.format == 'html': - doc.write_html(args.outdir) - elif args.format == 'rst': - doc.write_rst(args.outdir) - else: - print('unknown format:', args.format) - return - - print('written to', args.outdir) - -if __name__ == "__main__": - main() diff --git a/user/mpy/tools/insert-usb-ids.py b/user/mpy/tools/insert-usb-ids.py deleted file mode 100644 index cdccd3b..0000000 --- a/user/mpy/tools/insert-usb-ids.py +++ /dev/null @@ -1,34 +0,0 @@ -# Reads the USB VID and PID from the file specified by sys.argv[1] and then -# inserts those values into the template file specified by sys.argv[2], -# printing the result to stdout - -from __future__ import print_function - -import sys -import re -import string - -needed_keys = ('USB_PID_CDC_MSC', 'USB_PID_CDC_HID', 'USB_PID_CDC', 'USB_VID') - -def parse_usb_ids(filename): - rv = dict() - for line in open(filename).readlines(): - line = line.rstrip('\r\n') - match = re.match('^#define\s+(\w+)\s+\(0x([0-9A-Fa-f]+)\)$', line) - if match and match.group(1).startswith('USBD_'): - key = match.group(1).replace('USBD', 'USB') - val = match.group(2) - print("key =", key, "val =", val) - if key in needed_keys: - rv[key] = val - for k in needed_keys: - if k not in rv: - raise Exception("Unable to parse %s from %s" % (k, filename)) - return rv - -if __name__ == "__main__": - usb_ids_file = sys.argv[1] - template_file = sys.argv[2] - replacements = parse_usb_ids(usb_ids_file) - for line in open(template_file, 'r').readlines(): - print(string.Template(line).safe_substitute(replacements), end='') diff --git a/user/mpy/tools/make-frozen.py b/user/mpy/tools/make-frozen.py deleted file mode 100755 index 1051b52..0000000 --- a/user/mpy/tools/make-frozen.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -# Create frozen modules structure for MicroPython. -# -# Usage: -# -# Have a directory with modules to be frozen (only modules, not packages -# supported so far): -# -# frozen/foo.py -# frozen/bar.py -# -# Run script, passing path to the directory above: -# -# ./make-frozen.py frozen > frozen.c -# -# Include frozen.c in your build, having defined MICROPY_MODULE_FROZEN_STR in -# config. -# -from __future__ import print_function -import sys -import os - - -def module_name(f): - return f - -modules = [] - -root = sys.argv[1].rstrip("/") -root_len = len(root) - -for dirpath, dirnames, filenames in os.walk(root): - for f in filenames: - fullpath = dirpath + "/" + f - st = os.stat(fullpath) - modules.append((fullpath[root_len + 1:], st)) - -print("#include ") -print("const char mp_frozen_str_names[] = {") -for f, st in modules: - m = module_name(f) - print('"%s\\0"' % m) -print('"\\0"};') - -print("const uint32_t mp_frozen_str_sizes[] = {") - -for f, st in modules: - print("%d," % st.st_size) - -print("};") - -print("const char mp_frozen_str_content[] = {") -for f, st in modules: - data = open(sys.argv[1] + "/" + f, "rb").read() - - # We need to properly escape the script data to create a C string. - # When C parses hex characters of the form \x00 it keeps parsing the hex - # data until it encounters a non-hex character. Thus one must create - # strings of the form "data\x01" "abc" to properly encode this kind of - # data. We could just encode all characters as hex digits but it's nice - # to be able to read the resulting C code as ASCII when possible. - - data = bytearray(data) # so Python2 extracts each byte as an integer - esc_dict = {ord('\n'): '\\n', ord('\r'): '\\r', ord('"'): '\\"', ord('\\'): '\\\\'} - chrs = ['"'] - break_str = False - for c in data: - try: - chrs.append(esc_dict[c]) - except KeyError: - if 32 <= c <= 126: - if break_str: - chrs.append('" "') - break_str = False - chrs.append(chr(c)) - else: - chrs.append('\\x%02x' % c) - break_str = True - chrs.append('\\0"') - print(''.join(chrs)) - -print("};") diff --git a/user/mpy/tools/mpy-tool.py b/user/mpy/tools/mpy-tool.py deleted file mode 100755 index 887b3f5..0000000 --- a/user/mpy/tools/mpy-tool.py +++ /dev/null @@ -1,593 +0,0 @@ -#!/usr/bin/env python3 -# -# This file is part of the MicroPython project, http://micropython.org/ -# -# The MIT License (MIT) -# -# Copyright (c) 2016 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. - -# Python 2/3 compatibility code -from __future__ import print_function -import platform -if platform.python_version_tuple()[0] == '2': - str_cons = lambda val, enc=None: val - bytes_cons = lambda val, enc=None: bytearray(val) - is_str_type = lambda o: type(o) is str - is_bytes_type = lambda o: type(o) is bytearray - is_int_type = lambda o: type(o) is int or type(o) is long -else: - str_cons = str - bytes_cons = bytes - is_str_type = lambda o: type(o) is str - is_bytes_type = lambda o: type(o) is bytes - is_int_type = lambda o: type(o) is int -# end compatibility code - -import sys -import struct -from collections import namedtuple - -sys.path.append(sys.path[0] + '/../py') -import makeqstrdata as qstrutil - -class FreezeError(Exception): - def __init__(self, rawcode, msg): - self.rawcode = rawcode - self.msg = msg - - def __str__(self): - return 'error while freezing %s: %s' % (self.rawcode.source_file, self.msg) - -class Config: - MPY_VERSION = 2 - MICROPY_LONGINT_IMPL_NONE = 0 - MICROPY_LONGINT_IMPL_LONGLONG = 1 - MICROPY_LONGINT_IMPL_MPZ = 2 -config = Config() - -MP_OPCODE_BYTE = 0 -MP_OPCODE_QSTR = 1 -MP_OPCODE_VAR_UINT = 2 -MP_OPCODE_OFFSET = 3 - -# extra bytes: -MP_BC_MAKE_CLOSURE = 0x62 -MP_BC_MAKE_CLOSURE_DEFARGS = 0x63 -MP_BC_RAISE_VARARGS = 0x5c -# extra byte if caching enabled: -MP_BC_LOAD_NAME = 0x1c -MP_BC_LOAD_GLOBAL = 0x1d -MP_BC_LOAD_ATTR = 0x1e -MP_BC_STORE_ATTR = 0x26 - -def make_opcode_format(): - def OC4(a, b, c, d): - return a | (b << 2) | (c << 4) | (d << 6) - U = 0 - B = 0 - Q = 1 - V = 2 - O = 3 - return bytes_cons(( - # this table is taken verbatim from py/bc.c - OC4(U, U, U, U), # 0x00-0x03 - OC4(U, U, U, U), # 0x04-0x07 - OC4(U, U, U, U), # 0x08-0x0b - OC4(U, U, U, U), # 0x0c-0x0f - OC4(B, B, B, U), # 0x10-0x13 - OC4(V, U, Q, V), # 0x14-0x17 - OC4(B, V, V, Q), # 0x18-0x1b - OC4(Q, Q, Q, Q), # 0x1c-0x1f - OC4(B, B, V, V), # 0x20-0x23 - OC4(Q, Q, Q, B), # 0x24-0x27 - OC4(V, V, Q, Q), # 0x28-0x2b - OC4(U, U, U, U), # 0x2c-0x2f - OC4(B, B, B, B), # 0x30-0x33 - OC4(B, O, O, O), # 0x34-0x37 - OC4(O, O, U, U), # 0x38-0x3b - OC4(U, O, B, O), # 0x3c-0x3f - OC4(O, B, B, O), # 0x40-0x43 - OC4(B, B, O, U), # 0x44-0x47 - OC4(U, U, U, U), # 0x48-0x4b - OC4(U, U, U, U), # 0x4c-0x4f - OC4(V, V, U, V), # 0x50-0x53 - OC4(B, U, V, V), # 0x54-0x57 - OC4(V, V, V, B), # 0x58-0x5b - OC4(B, B, B, U), # 0x5c-0x5f - OC4(V, V, V, V), # 0x60-0x63 - OC4(V, V, V, V), # 0x64-0x67 - OC4(Q, Q, B, U), # 0x68-0x6b - OC4(U, U, U, U), # 0x6c-0x6f - - OC4(B, B, B, B), # 0x70-0x73 - OC4(B, B, B, B), # 0x74-0x77 - OC4(B, B, B, B), # 0x78-0x7b - OC4(B, B, B, B), # 0x7c-0x7f - OC4(B, B, B, B), # 0x80-0x83 - OC4(B, B, B, B), # 0x84-0x87 - OC4(B, B, B, B), # 0x88-0x8b - OC4(B, B, B, B), # 0x8c-0x8f - OC4(B, B, B, B), # 0x90-0x93 - OC4(B, B, B, B), # 0x94-0x97 - OC4(B, B, B, B), # 0x98-0x9b - OC4(B, B, B, B), # 0x9c-0x9f - OC4(B, B, B, B), # 0xa0-0xa3 - OC4(B, B, B, B), # 0xa4-0xa7 - OC4(B, B, B, B), # 0xa8-0xab - OC4(B, B, B, B), # 0xac-0xaf - - OC4(B, B, B, B), # 0xb0-0xb3 - OC4(B, B, B, B), # 0xb4-0xb7 - OC4(B, B, B, B), # 0xb8-0xbb - OC4(B, B, B, B), # 0xbc-0xbf - - OC4(B, B, B, B), # 0xc0-0xc3 - OC4(B, B, B, B), # 0xc4-0xc7 - OC4(B, B, B, B), # 0xc8-0xcb - OC4(B, B, B, B), # 0xcc-0xcf - - OC4(B, B, B, B), # 0xd0-0xd3 - OC4(B, B, B, B), # 0xd4-0xd7 - OC4(B, B, B, B), # 0xd8-0xdb - OC4(B, B, B, B), # 0xdc-0xdf - - OC4(B, B, B, B), # 0xe0-0xe3 - OC4(B, B, B, B), # 0xe4-0xe7 - OC4(B, B, B, B), # 0xe8-0xeb - OC4(B, B, B, B), # 0xec-0xef - - OC4(B, B, B, B), # 0xf0-0xf3 - OC4(B, B, B, B), # 0xf4-0xf7 - OC4(B, B, B, U), # 0xf8-0xfb - OC4(U, U, U, U), # 0xfc-0xff - )) - -# this function mirrors that in py/bc.c -def mp_opcode_format(bytecode, ip, opcode_format=make_opcode_format()): - opcode = bytecode[ip] - ip_start = ip - f = (opcode_format[opcode >> 2] >> (2 * (opcode & 3))) & 3 - if f == MP_OPCODE_QSTR: - ip += 3 - else: - extra_byte = ( - opcode == MP_BC_RAISE_VARARGS - or opcode == MP_BC_MAKE_CLOSURE - or opcode == MP_BC_MAKE_CLOSURE_DEFARGS - or config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE and ( - opcode == MP_BC_LOAD_NAME - or opcode == MP_BC_LOAD_GLOBAL - or opcode == MP_BC_LOAD_ATTR - or opcode == MP_BC_STORE_ATTR - ) - ) - ip += 1 - if f == MP_OPCODE_VAR_UINT: - while bytecode[ip] & 0x80 != 0: - ip += 1 - ip += 1 - elif f == MP_OPCODE_OFFSET: - ip += 2 - ip += extra_byte - return f, ip - ip_start - -def decode_uint(bytecode, ip): - unum = 0 - while True: - val = bytecode[ip] - ip += 1 - unum = (unum << 7) | (val & 0x7f) - if not (val & 0x80): - break - return ip, unum - -def extract_prelude(bytecode): - ip = 0 - ip, n_state = decode_uint(bytecode, ip) - ip, n_exc_stack = decode_uint(bytecode, ip) - scope_flags = bytecode[ip]; ip += 1 - n_pos_args = bytecode[ip]; ip += 1 - n_kwonly_args = bytecode[ip]; ip += 1 - n_def_pos_args = bytecode[ip]; ip += 1 - ip2, code_info_size = decode_uint(bytecode, ip) - ip += code_info_size - while bytecode[ip] != 0xff: - ip += 1 - ip += 1 - # ip now points to first opcode - # ip2 points to simple_name qstr - return ip, ip2, (n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args, code_info_size) - -class RawCode: - # a set of all escaped names, to make sure they are unique - escaped_names = set() - - def __init__(self, bytecode, qstrs, objs, raw_codes): - # set core variables - self.bytecode = bytecode - self.qstrs = qstrs - self.objs = objs - self.raw_codes = raw_codes - - # extract prelude - self.ip, self.ip2, self.prelude = extract_prelude(self.bytecode) - self.simple_name = self._unpack_qstr(self.ip2) - self.source_file = self._unpack_qstr(self.ip2 + 2) - - def _unpack_qstr(self, ip): - qst = self.bytecode[ip] | self.bytecode[ip + 1] << 8 - return global_qstrs[qst] - - def dump(self): - # dump children first - for rc in self.raw_codes: - rc.freeze() - # TODO - - def freeze(self, parent_name): - self.escaped_name = parent_name + self.simple_name.qstr_esc - - # make sure the escaped name is unique - i = 2 - while self.escaped_name in RawCode.escaped_names: - self.escaped_name = parent_name + self.simple_name.qstr_esc + str(i) - i += 1 - RawCode.escaped_names.add(self.escaped_name) - - # emit children first - for rc in self.raw_codes: - rc.freeze(self.escaped_name + '_') - - # generate bytecode data - print() - print('// frozen bytecode for file %s, scope %s%s' % (self.source_file.str, parent_name, self.simple_name.str)) - print('STATIC ', end='') - if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: - print('const ', end='') - print('byte bytecode_data_%s[%u] = {' % (self.escaped_name, len(self.bytecode))) - print(' ', end='') - for i in range(self.ip2): - print(' 0x%02x,' % self.bytecode[i], end='') - print() - print(' ', self.simple_name.qstr_id, '& 0xff,', self.simple_name.qstr_id, '>> 8,') - print(' ', self.source_file.qstr_id, '& 0xff,', self.source_file.qstr_id, '>> 8,') - print(' ', end='') - for i in range(self.ip2 + 4, self.ip): - print(' 0x%02x,' % self.bytecode[i], end='') - print() - ip = self.ip - while ip < len(self.bytecode): - f, sz = mp_opcode_format(self.bytecode, ip) - if f == 1: - qst = self._unpack_qstr(ip + 1).qstr_id - print(' ', '0x%02x,' % self.bytecode[ip], qst, '& 0xff,', qst, '>> 8,') - else: - print(' ', ''.join('0x%02x, ' % self.bytecode[ip + i] for i in range(sz))) - ip += sz - print('};') - - # generate constant objects - for i, obj in enumerate(self.objs): - obj_name = 'const_obj_%s_%u' % (self.escaped_name, i) - if is_str_type(obj) or is_bytes_type(obj): - if is_str_type(obj): - obj = bytes_cons(obj, 'utf8') - obj_type = 'mp_type_str' - else: - obj_type = 'mp_type_bytes' - print('STATIC const mp_obj_str_t %s = {{&%s}, %u, %u, (const byte*)"%s"};' - % (obj_name, obj_type, qstrutil.compute_hash(obj, config.MICROPY_QSTR_BYTES_IN_HASH), - len(obj), ''.join(('\\x%02x' % b) for b in obj))) - elif is_int_type(obj): - if config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_NONE: - # TODO check if we can actually fit this long-int into a small-int - raise FreezeError(self, 'target does not support long int') - elif config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_LONGLONG: - # TODO - raise FreezeError(self, 'freezing int to long-long is not implemented') - elif config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_MPZ: - neg = 0 - if obj < 0: - obj = -obj - neg = 1 - bits_per_dig = config.MPZ_DIG_SIZE - digs = [] - z = obj - while z: - digs.append(z & ((1 << bits_per_dig) - 1)) - z >>= bits_per_dig - ndigs = len(digs) - digs = ','.join(('%#x' % d) for d in digs) - print('STATIC const mp_obj_int_t %s = {{&mp_type_int}, ' - '{.neg=%u, .fixed_dig=1, .alloc=%u, .len=%u, .dig=(uint%u_t[]){%s}}};' - % (obj_name, neg, ndigs, ndigs, bits_per_dig, digs)) - elif type(obj) is float: - print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') - print('STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};' - % (obj_name, obj)) - print('#endif') - elif type(obj) is complex: - print('STATIC const mp_obj_complex_t %s = {{&mp_type_complex}, %.16g, %.16g};' - % (obj_name, obj.real, obj.imag)) - else: - # TODO - raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,)) - - # generate constant table, if it has any entries - const_table_len = len(self.qstrs) + len(self.objs) + len(self.raw_codes) - if const_table_len: - print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {' - % (self.escaped_name, const_table_len)) - for qst in self.qstrs: - print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id) - for i in range(len(self.objs)): - if type(self.objs[i]) is float: - print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') - print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) - print('#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C') - n = struct.unpack('> 8 - -def read_bytecode_qstrs(file, bytecode, ip): - while ip < len(bytecode): - f, sz = mp_opcode_format(bytecode, ip) - if f == 1: - read_qstr_and_pack(file, bytecode, ip + 1) - ip += sz - -def read_raw_code(f): - bc_len = read_uint(f) - bytecode = bytearray(f.read(bc_len)) - ip, ip2, prelude = extract_prelude(bytecode) - read_qstr_and_pack(f, bytecode, ip2) # simple_name - read_qstr_and_pack(f, bytecode, ip2 + 2) # source_file - read_bytecode_qstrs(f, bytecode, ip) - n_obj = read_uint(f) - n_raw_code = read_uint(f) - qstrs = [read_qstr(f) for _ in range(prelude[3] + prelude[4])] - objs = [read_obj(f) for _ in range(n_obj)] - raw_codes = [read_raw_code(f) for _ in range(n_raw_code)] - return RawCode(bytecode, qstrs, objs, raw_codes) - -def read_mpy(filename): - with open(filename, 'rb') as f: - header = bytes_cons(f.read(4)) - if header[0] != ord('M'): - raise Exception('not a valid .mpy file') - if header[1] != config.MPY_VERSION: - raise Exception('incompatible .mpy version') - feature_flags = header[2] - config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = (feature_flags & 1) != 0 - config.MICROPY_PY_BUILTINS_STR_UNICODE = (feature_flags & 2) != 0 - config.mp_small_int_bits = header[3] - return read_raw_code(f) - -def dump_mpy(raw_codes): - for rc in raw_codes: - rc.dump() - -def freeze_mpy(base_qstrs, raw_codes): - # add to qstrs - new = {} - for q in global_qstrs: - # don't add duplicates - if q.qstr_esc in base_qstrs or q.qstr_esc in new: - continue - new[q.qstr_esc] = (len(new), q.qstr_esc, q.str) - new = sorted(new.values(), key=lambda x: x[0]) - - print('#include "py/mpconfig.h"') - print('#include "py/objint.h"') - print('#include "py/objstr.h"') - print('#include "py/emitglue.h"') - print() - - print('#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != %u' % config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) - print('#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"') - print('#endif') - print() - - print('#if MICROPY_LONGINT_IMPL != %u' % config.MICROPY_LONGINT_IMPL) - print('#error "incompatible MICROPY_LONGINT_IMPL"') - print('#endif') - print() - - if config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_MPZ: - print('#if MPZ_DIG_SIZE != %u' % config.MPZ_DIG_SIZE) - print('#error "incompatible MPZ_DIG_SIZE"') - print('#endif') - print() - - - print('#if MICROPY_PY_BUILTINS_FLOAT') - print('typedef struct _mp_obj_float_t {') - print(' mp_obj_base_t base;') - print(' mp_float_t value;') - print('} mp_obj_float_t;') - print('#endif') - print() - - print('#if MICROPY_PY_BUILTINS_COMPLEX') - print('typedef struct _mp_obj_complex_t {') - print(' mp_obj_base_t base;') - print(' mp_float_t real;') - print(' mp_float_t imag;') - print('} mp_obj_complex_t;') - print('#endif') - print() - - print('enum {') - for i in range(len(new)): - if i == 0: - print(' MP_QSTR_%s = MP_QSTRnumber_of,' % new[i][1]) - else: - print(' MP_QSTR_%s,' % new[i][1]) - print('};') - - print() - print('extern const qstr_pool_t mp_qstr_const_pool;'); - print('const qstr_pool_t mp_qstr_frozen_const_pool = {') - print(' (qstr_pool_t*)&mp_qstr_const_pool, // previous pool') - print(' MP_QSTRnumber_of, // previous pool size') - print(' %u, // allocated entries' % len(new)) - print(' %u, // used entries' % len(new)) - print(' {') - for _, _, qstr in new: - print(' %s,' - % qstrutil.make_bytes(config.MICROPY_QSTR_BYTES_IN_LEN, config.MICROPY_QSTR_BYTES_IN_HASH, qstr)) - print(' },') - print('};') - - for rc in raw_codes: - rc.freeze(rc.source_file.str.replace('/', '_')[:-3] + '_') - - print() - print('const char mp_frozen_mpy_names[] = {') - for rc in raw_codes: - module_name = rc.source_file.str - print('"%s\\0"' % module_name) - print('"\\0"};') - - print('const mp_raw_code_t *const mp_frozen_mpy_content[] = {') - for rc in raw_codes: - print(' &raw_code_%s,' % rc.escaped_name) - print('};') - -def main(): - import argparse - cmd_parser = argparse.ArgumentParser(description='A tool to work with MicroPython .mpy files.') - cmd_parser.add_argument('-d', '--dump', action='store_true', - help='dump contents of files') - cmd_parser.add_argument('-f', '--freeze', action='store_true', - help='freeze files') - cmd_parser.add_argument('-q', '--qstr-header', - help='qstr header file to freeze against') - cmd_parser.add_argument('-mlongint-impl', choices=['none', 'longlong', 'mpz'], default='mpz', - help='long-int implementation used by target (default mpz)') - cmd_parser.add_argument('-mmpz-dig-size', metavar='N', type=int, default=16, - help='mpz digit size used by target (default 16)') - cmd_parser.add_argument('files', nargs='+', - help='input .mpy files') - args = cmd_parser.parse_args() - - # set config values relevant to target machine - config.MICROPY_LONGINT_IMPL = { - 'none':config.MICROPY_LONGINT_IMPL_NONE, - 'longlong':config.MICROPY_LONGINT_IMPL_LONGLONG, - 'mpz':config.MICROPY_LONGINT_IMPL_MPZ, - }[args.mlongint_impl] - config.MPZ_DIG_SIZE = args.mmpz_dig_size - - # set config values for qstrs, and get the existing base set of qstrs - if args.qstr_header: - qcfgs, base_qstrs = qstrutil.parse_input_headers([args.qstr_header]) - config.MICROPY_QSTR_BYTES_IN_LEN = int(qcfgs['BYTES_IN_LEN']) - config.MICROPY_QSTR_BYTES_IN_HASH = int(qcfgs['BYTES_IN_HASH']) - else: - config.MICROPY_QSTR_BYTES_IN_LEN = 1 - config.MICROPY_QSTR_BYTES_IN_HASH = 1 - base_qstrs = {} - - raw_codes = [read_mpy(file) for file in args.files] - - if args.dump: - dump_mpy(raw_codes) - elif args.freeze: - try: - freeze_mpy(base_qstrs, raw_codes) - except FreezeError as er: - print(er, file=sys.stderr) - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/user/mpy/tools/mpy_bin2res.py b/user/mpy/tools/mpy_bin2res.py deleted file mode 100755 index 0c89e7e..0000000 --- a/user/mpy/tools/mpy_bin2res.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python3 -# -# This tool converts binary resource files passed on the command line -# into a Python source file containing data from these files, which can -# be accessed using standard pkg_resources.resource_stream() function -# from micropython-lib: -# https://github.com/micropython/micropython-lib/tree/master/pkg_resources -# -import sys - -print("R = {") - -for fname in sys.argv[1:]: - with open(fname, "rb") as f: - b = f.read() - print("%r: %r," % (fname, b)) - -print("}") diff --git a/user/mpy/tools/mpy_cross_all.py b/user/mpy/tools/mpy_cross_all.py deleted file mode 100755 index 2bda71e..0000000 --- a/user/mpy/tools/mpy_cross_all.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import os -import os.path - -argparser = argparse.ArgumentParser(description="Compile all .py files to .mpy recursively") -argparser.add_argument("-o", "--out", help="output directory (default: input dir)") -argparser.add_argument("--target", help="select MicroPython target config") -argparser.add_argument("-mcache-lookup-bc", action="store_true", help="cache map lookups in the bytecode") -argparser.add_argument("dir", help="input directory") -args = argparser.parse_args() - -TARGET_OPTS = { - "unix": "-mcache-lookup-bc", - "baremetal": "", -} - -args.dir = args.dir.rstrip("/") - -if not args.out: - args.out = args.dir - -path_prefix_len = len(args.dir) + 1 - -for path, subdirs, files in os.walk(args.dir): - for f in files: - if f.endswith(".py"): - fpath = path + "/" + f - #print(fpath) - out_fpath = args.out + "/" + fpath[path_prefix_len:-3] + ".mpy" - out_dir = os.path.dirname(out_fpath) - if not os.path.isdir(out_dir): - os.makedirs(out_dir) - cmd = "mpy-cross -v -v %s -s %s %s -o %s" % (TARGET_OPTS.get(args.target, ""), - fpath[path_prefix_len:], fpath, out_fpath) - #print(cmd) - res = os.system(cmd) - assert res == 0 diff --git a/user/mpy/tools/pyboard.py b/user/mpy/tools/pyboard.py deleted file mode 100755 index d15f520..0000000 --- a/user/mpy/tools/pyboard.py +++ /dev/null @@ -1,461 +0,0 @@ -#!/usr/bin/env python -# -# This file is part of the MicroPython project, http://micropython.org/ -# -# The MIT License (MIT) -# -# Copyright (c) 2014-2016 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. - -""" -pyboard interface - -This module provides the Pyboard class, used to communicate with and -control the pyboard over a serial USB connection. - -Example usage: - - import pyboard - pyb = pyboard.Pyboard('/dev/ttyACM0') - -Or: - - pyb = pyboard.Pyboard('192.168.1.1') - -Then: - - pyb.enter_raw_repl() - pyb.exec('pyb.LED(1).on()') - pyb.exit_raw_repl() - -Note: if using Python2 then pyb.exec must be written as pyb.exec_. -To run a script from the local machine on the board and print out the results: - - import pyboard - pyboard.execfile('test.py', device='/dev/ttyACM0') - -This script can also be run directly. To execute a local script, use: - - ./pyboard.py test.py - -Or: - - python pyboard.py test.py - -""" - -import sys -import time -import os - -try: - stdout = sys.stdout.buffer -except AttributeError: - # Python2 doesn't have buffer attr - stdout = sys.stdout - -def stdout_write_bytes(b): - b = b.replace(b"\x04", b"") - stdout.write(b) - stdout.flush() - -class PyboardError(BaseException): - pass - -class TelnetToSerial: - def __init__(self, ip, user, password, read_timeout=None): - import telnetlib - self.tn = telnetlib.Telnet(ip, timeout=15) - self.read_timeout = read_timeout - if b'Login as:' in self.tn.read_until(b'Login as:', timeout=read_timeout): - self.tn.write(bytes(user, 'ascii') + b"\r\n") - - if b'Password:' in self.tn.read_until(b'Password:', timeout=read_timeout): - # needed because of internal implementation details of the telnet server - time.sleep(0.2) - self.tn.write(bytes(password, 'ascii') + b"\r\n") - - if b'for more information.' in self.tn.read_until(b'Type "help()" for more information.', timeout=read_timeout): - # login successful - from collections import deque - self.fifo = deque() - return - - raise PyboardError('Failed to establish a telnet connection with the board') - - def __del__(self): - self.close() - - def close(self): - try: - self.tn.close() - except: - # the telnet object might not exist yet, so ignore this one - pass - - def read(self, size=1): - while len(self.fifo) < size: - timeout_count = 0 - data = self.tn.read_eager() - if len(data): - self.fifo.extend(data) - timeout_count = 0 - else: - time.sleep(0.25) - if self.read_timeout is not None and timeout_count > 4 * self.read_timeout: - break - timeout_count += 1 - - data = b'' - while len(data) < size and len(self.fifo) > 0: - data += bytes([self.fifo.popleft()]) - return data - - def write(self, data): - self.tn.write(data) - return len(data) - - def inWaiting(self): - n_waiting = len(self.fifo) - if not n_waiting: - data = self.tn.read_eager() - self.fifo.extend(data) - return len(data) - else: - return n_waiting - - -class ProcessToSerial: - "Execute a process and emulate serial connection using its stdin/stdout." - - def __init__(self, cmd): - import subprocess - self.subp = subprocess.Popen(cmd.split(), bufsize=0, shell=True, preexec_fn=os.setsid, - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - - # Initially was implemented with selectors, but that adds Python3 - # dependency. However, there can be race conditions communicating - # with a particular child process (like QEMU), and selectors may - # still work better in that case, so left inplace for now. - # - #import selectors - #self.sel = selectors.DefaultSelector() - #self.sel.register(self.subp.stdout, selectors.EVENT_READ) - - import select - self.poll = select.poll() - self.poll.register(self.subp.stdout.fileno()) - - def close(self): - import signal - os.killpg(os.getpgid(self.subp.pid), signal.SIGTERM) - - def read(self, size=1): - data = b"" - while len(data) < size: - data += self.subp.stdout.read(size - len(data)) - return data - - def write(self, data): - self.subp.stdin.write(data) - return len(data) - - def inWaiting(self): - #res = self.sel.select(0) - res = self.poll.poll(0) - if res: - return 1 - return 0 - - -class ProcessPtyToTerminal: - """Execute a process which creates a PTY and prints slave PTY as - first line of its output, and emulate serial connection using - this PTY.""" - - def __init__(self, cmd): - import subprocess - import re - import serial - self.subp = subprocess.Popen(cmd.split(), bufsize=0, shell=False, preexec_fn=os.setsid, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - pty_line = self.subp.stderr.readline().decode("utf-8") - m = re.search(r"/dev/pts/[0-9]+", pty_line) - if not m: - print("Error: unable to find PTY device in startup line:", pty_line) - self.close() - sys.exit(1) - pty = m.group() - # rtscts, dsrdtr params are to workaround pyserial bug: - # http://stackoverflow.com/questions/34831131/pyserial-does-not-play-well-with-virtual-port - self.ser = serial.Serial(pty, interCharTimeout=1, rtscts=True, dsrdtr=True) - - def close(self): - import signal - os.killpg(os.getpgid(self.subp.pid), signal.SIGTERM) - - def read(self, size=1): - return self.ser.read(size) - - def write(self, data): - return self.ser.write(data) - - def inWaiting(self): - return self.ser.inWaiting() - - -class Pyboard: - def __init__(self, device, baudrate=115200, user='micro', password='python', wait=0): - if device.startswith("exec:"): - self.serial = ProcessToSerial(device[len("exec:"):]) - elif device.startswith("execpty:"): - self.serial = ProcessPtyToTerminal(device[len("qemupty:"):]) - elif device and device[0].isdigit() and device[-1].isdigit() and device.count('.') == 3: - # device looks like an IP address - self.serial = TelnetToSerial(device, user, password, read_timeout=10) - else: - import serial - delayed = False - for attempt in range(wait + 1): - try: - self.serial = serial.Serial(device, baudrate=baudrate, interCharTimeout=1) - break - except (OSError, IOError): # Py2 and Py3 have different errors - if wait == 0: - continue - if attempt == 0: - sys.stdout.write('Waiting {} seconds for pyboard '.format(wait)) - delayed = True - time.sleep(1) - sys.stdout.write('.') - sys.stdout.flush() - else: - if delayed: - print('') - raise PyboardError('failed to access ' + device) - if delayed: - print('') - - def close(self): - self.serial.close() - - def read_until(self, min_num_bytes, ending, timeout=10, data_consumer=None): - data = self.serial.read(min_num_bytes) - if data_consumer: - data_consumer(data) - timeout_count = 0 - while True: - if data.endswith(ending): - break - elif self.serial.inWaiting() > 0: - new_data = self.serial.read(1) - data = data + new_data - if data_consumer: - data_consumer(new_data) - timeout_count = 0 - else: - timeout_count += 1 - if timeout is not None and timeout_count >= 100 * timeout: - break - time.sleep(0.01) - return data - - def enter_raw_repl(self): - self.serial.write(b'\r\x03\x03') # ctrl-C twice: interrupt any running program - - # flush input (without relying on serial.flushInput()) - n = self.serial.inWaiting() - while n > 0: - self.serial.read(n) - n = self.serial.inWaiting() - - self.serial.write(b'\r\x01') # ctrl-A: enter raw REPL - data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n>') - if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'): - print(data) - raise PyboardError('could not enter raw repl') - - self.serial.write(b'\x04') # ctrl-D: soft reset - data = self.read_until(1, b'soft reboot\r\n') - if not data.endswith(b'soft reboot\r\n'): - print(data) - raise PyboardError('could not enter raw repl') - # By splitting this into 2 reads, it allows boot.py to print stuff, - # which will show up after the soft reboot and before the raw REPL. - data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n') - if not data.endswith(b'raw REPL; CTRL-B to exit\r\n'): - print(data) - raise PyboardError('could not enter raw repl') - - def exit_raw_repl(self): - self.serial.write(b'\r\x02') # ctrl-B: enter friendly REPL - - def follow(self, timeout, data_consumer=None): - # wait for normal output - data = self.read_until(1, b'\x04', timeout=timeout, data_consumer=data_consumer) - if not data.endswith(b'\x04'): - raise PyboardError('timeout waiting for first EOF reception') - data = data[:-1] - - # wait for error output - data_err = self.read_until(1, b'\x04', timeout=timeout) - if not data_err.endswith(b'\x04'): - raise PyboardError('timeout waiting for second EOF reception') - data_err = data_err[:-1] - - # return normal and error output - return data, data_err - - def exec_raw_no_follow(self, command): - if isinstance(command, bytes): - command_bytes = command - else: - command_bytes = bytes(command, encoding='utf8') - - # check we have a prompt - data = self.read_until(1, b'>') - if not data.endswith(b'>'): - raise PyboardError('could not enter raw repl') - - # write command - for i in range(0, len(command_bytes), 256): - self.serial.write(command_bytes[i:min(i + 256, len(command_bytes))]) - time.sleep(0.01) - self.serial.write(b'\x04') - - # check if we could exec command - data = self.serial.read(2) - if data != b'OK': - raise PyboardError('could not exec command (response: %s)' % data) - - def exec_raw(self, command, timeout=10, data_consumer=None): - self.exec_raw_no_follow(command); - return self.follow(timeout, data_consumer) - - def eval(self, expression): - ret = self.exec_('print({})'.format(expression)) - ret = ret.strip() - return ret - - def exec_(self, command): - ret, ret_err = self.exec_raw(command) - if ret_err: - raise PyboardError('exception', ret, ret_err) - return ret - - def execfile(self, filename): - with open(filename, 'rb') as f: - pyfile = f.read() - return self.exec_(pyfile) - - def get_time(self): - t = str(self.eval('pyb.RTC().datetime()'), encoding='utf8')[1:-1].split(', ') - return int(t[4]) * 3600 + int(t[5]) * 60 + int(t[6]) - -# in Python2 exec is a keyword so one must use "exec_" -# but for Python3 we want to provide the nicer version "exec" -setattr(Pyboard, "exec", Pyboard.exec_) - -def execfile(filename, device='/dev/ttyACM0', baudrate=115200, user='micro', password='python'): - pyb = Pyboard(device, baudrate, user, password) - pyb.enter_raw_repl() - output = pyb.execfile(filename) - stdout_write_bytes(output) - pyb.exit_raw_repl() - pyb.close() - -def main(): - import argparse - cmd_parser = argparse.ArgumentParser(description='Run scripts on the pyboard.') - cmd_parser.add_argument('--device', default='/dev/ttyACM0', help='the serial device or the IP address of the pyboard') - cmd_parser.add_argument('-b', '--baudrate', default=115200, help='the baud rate of the serial device') - cmd_parser.add_argument('-u', '--user', default='micro', help='the telnet login username') - cmd_parser.add_argument('-p', '--password', default='python', help='the telnet login password') - cmd_parser.add_argument('-c', '--command', help='program passed in as string') - cmd_parser.add_argument('-w', '--wait', default=0, type=int, help='seconds to wait for USB connected board to become available') - cmd_parser.add_argument('--follow', action='store_true', help='follow the output after running the scripts [default if no scripts given]') - cmd_parser.add_argument('files', nargs='*', help='input files') - args = cmd_parser.parse_args() - - # open the connection to the pyboard - try: - pyb = Pyboard(args.device, args.baudrate, args.user, args.password, args.wait) - except PyboardError as er: - print(er) - sys.exit(1) - - # run any command or file(s) - if args.command is not None or len(args.files): - # we must enter raw-REPL mode to execute commands - # this will do a soft-reset of the board - try: - pyb.enter_raw_repl() - except PyboardError as er: - print(er) - pyb.close() - sys.exit(1) - - def execbuffer(buf): - try: - ret, ret_err = pyb.exec_raw(buf, timeout=None, data_consumer=stdout_write_bytes) - except PyboardError as er: - print(er) - pyb.close() - sys.exit(1) - except KeyboardInterrupt: - sys.exit(1) - if ret_err: - pyb.exit_raw_repl() - pyb.close() - stdout_write_bytes(ret_err) - sys.exit(1) - - # run the command, if given - if args.command is not None: - execbuffer(args.command.encode('utf-8')) - - # run any files - for filename in args.files: - with open(filename, 'rb') as f: - pyfile = f.read() - execbuffer(pyfile) - - # exiting raw-REPL just drops to friendly-REPL mode - pyb.exit_raw_repl() - - # if asked explicitly, or no files given, then follow the output - if args.follow or (args.command is None and len(args.files) == 0): - try: - ret, ret_err = pyb.follow(timeout=None, data_consumer=stdout_write_bytes) - except PyboardError as er: - print(er) - sys.exit(1) - except KeyboardInterrupt: - sys.exit(1) - if ret_err: - pyb.close() - stdout_write_bytes(ret_err) - sys.exit(1) - - # close the connection to the pyboard - pyb.close() - -if __name__ == "__main__": - main() diff --git a/user/mpy/tools/pydfu.py b/user/mpy/tools/pydfu.py deleted file mode 100755 index 8c0220d..0000000 --- a/user/mpy/tools/pydfu.py +++ /dev/null @@ -1,540 +0,0 @@ -#!/usr/bin/env python -# This file is part of the OpenMV project. -# Copyright (c) 2013/2014 Ibrahim Abdelkader -# This work is licensed under the MIT license, see the file LICENSE for -# details. - -"""This module implements enough functionality to program the STM32F4xx over -DFU, without requiringdfu-util. - -See app note AN3156 for a description of the DFU protocol. -See document UM0391 for a dscription of the DFuse file. -""" - -from __future__ import print_function - -import argparse -import re -import struct -import sys -import usb.core -import usb.util -import zlib - -# VID/PID -__VID = 0x0483 -__PID = 0xdf11 - -# USB request __TIMEOUT -__TIMEOUT = 4000 - -# DFU commands -__DFU_DETACH = 0 -__DFU_DNLOAD = 1 -__DFU_UPLOAD = 2 -__DFU_GETSTATUS = 3 -__DFU_CLRSTATUS = 4 -__DFU_GETSTATE = 5 -__DFU_ABORT = 6 - -# DFU status -__DFU_STATE_APP_IDLE = 0x00 -__DFU_STATE_APP_DETACH = 0x01 -__DFU_STATE_DFU_IDLE = 0x02 -__DFU_STATE_DFU_DOWNLOAD_SYNC = 0x03 -__DFU_STATE_DFU_DOWNLOAD_BUSY = 0x04 -__DFU_STATE_DFU_DOWNLOAD_IDLE = 0x05 -__DFU_STATE_DFU_MANIFEST_SYNC = 0x06 -__DFU_STATE_DFU_MANIFEST = 0x07 -__DFU_STATE_DFU_MANIFEST_WAIT_RESET = 0x08 -__DFU_STATE_DFU_UPLOAD_IDLE = 0x09 -__DFU_STATE_DFU_ERROR = 0x0a - -_DFU_DESCRIPTOR_TYPE = 0x21 - - -# USB device handle -__dev = None - -__verbose = None - -# USB DFU interface -__DFU_INTERFACE = 0 - -import inspect -if 'length' in inspect.getargspec(usb.util.get_string).args: - # PyUSB 1.0.0.b1 has the length argument - def get_string(dev, index): - return usb.util.get_string(dev, 255, index) -else: - # PyUSB 1.0.0.b2 dropped the length argument - def get_string(dev, index): - return usb.util.get_string(dev, index) - - -def init(): - """Initializes the found DFU device so that we can program it.""" - global __dev - devices = get_dfu_devices(idVendor=__VID, idProduct=__PID) - if not devices: - raise ValueError('No DFU device found') - if len(devices) > 1: - raise ValueError("Multiple DFU devices found") - __dev = devices[0] - - # Claim DFU interface - usb.util.claim_interface(__dev, __DFU_INTERFACE) - - # Clear status - clr_status() - - -def clr_status(): - """Clears any error status (perhaps left over from a previous session).""" - __dev.ctrl_transfer(0x21, __DFU_CLRSTATUS, 0, __DFU_INTERFACE, - None, __TIMEOUT) - - -def get_status(): - """Get the status of the last operation.""" - stat = __dev.ctrl_transfer(0xA1, __DFU_GETSTATUS, 0, __DFU_INTERFACE, - 6, 20000) - # print (__DFU_STAT[stat[4]], stat) - return stat[4] - - -def mass_erase(): - """Performs a MASS erase (i.e. erases the entire device.""" - # Send DNLOAD with first byte=0x41 - __dev.ctrl_transfer(0x21, __DFU_DNLOAD, 0, __DFU_INTERFACE, - "\x41", __TIMEOUT) - - # Execute last command - if get_status() != __DFU_STATE_DFU_DOWNLOAD_BUSY: - raise Exception("DFU: erase failed") - - # Check command state - if get_status() != __DFU_STATE_DFU_DOWNLOAD_IDLE: - raise Exception("DFU: erase failed") - - -def page_erase(addr): - """Erases a single page.""" - if __verbose: - print("Erasing page: 0x%x..." % (addr)) - - # Send DNLOAD with first byte=0x41 and page address - buf = struct.pack(" 0: - write_size = size - if not mass_erase_used: - for segment in mem_layout: - if addr >= segment['addr'] and \ - addr <= segment['last_addr']: - # We found the page containing the address we want to - # write, erase it - page_size = segment['page_size'] - page_addr = addr & ~(page_size - 1) - if addr + write_size > page_addr + page_size: - write_size = page_addr + page_size - addr - page_erase(page_addr) - break - write_memory(addr, data[:write_size], progress, - elem_addr, elem_size) - data = data[write_size:] - addr += write_size - size -= write_size - if progress: - progress(elem_addr, addr - elem_addr, elem_size) - - -def cli_progress(addr, offset, size): - """Prints a progress report suitable for use on the command line.""" - width = 25 - done = offset * width // size - print("\r0x{:08x} {:7d} [{}{}] {:3d}% " - .format(addr, size, '=' * done, ' ' * (width - done), - offset * 100 // size), end="") - sys.stdout.flush() - if offset == size: - print("") - - -def main(): - """Test program for verifying this files functionality.""" - global __verbose - # Parse CMD args - parser = argparse.ArgumentParser(description='DFU Python Util') - #parser.add_argument("path", help="file path") - parser.add_argument( - "-l", "--list", - help="list available DFU devices", - action="store_true", - default=False - ) - parser.add_argument( - "-m", "--mass-erase", - help="mass erase device", - action="store_true", - default=False - ) - parser.add_argument( - "-u", "--upload", - help="read file from DFU device", - dest="path", - default=False - ) - parser.add_argument( - "-v", "--verbose", - help="increase output verbosity", - action="store_true", - default=False - ) - args = parser.parse_args() - - __verbose = args.verbose - - if args.list: - list_dfu_devices(idVendor=__VID, idProduct=__PID) - return - - init() - - if args.mass_erase: - print ("Mass erase...") - mass_erase() - - if args.path: - elements = read_dfu_file(args.path) - if not elements: - return - print("Writing memory...") - write_elements(elements, args.mass_erase, progress=cli_progress) - - print("Exiting DFU...") - exit_dfu() - return - - print("No command specified") - -if __name__ == '__main__': - main() diff --git a/user/mpy/tools/tinytest-codegen.py b/user/mpy/tools/tinytest-codegen.py deleted file mode 100755 index dadfea1..0000000 --- a/user/mpy/tools/tinytest-codegen.py +++ /dev/null @@ -1,70 +0,0 @@ -#! /usr/bin/env python3 - -import os, sys -from glob import glob -from re import sub - -def escape(s): - lookup = { - '\0': '\\0', - '\t': '\\t', - '\n': '\\n\"\n\"', - '\r': '\\r', - '\\': '\\\\', - '\"': '\\\"', - } - return "\"\"\n\"{}\"".format(''.join([lookup[x] if x in lookup else x for x in s])) - -def chew_filename(t): - return { 'func': "test_{}_fn".format(sub(r'/|\.|-', '_', t)), 'desc': t.split('/')[1] } - -def script_to_map(t): - r = { 'name': chew_filename(t)['func'] } - with open(t) as f: r['script'] = escape(''.join(f.readlines())) - return r - -test_function = ( - "void {name}(void* data) {{\n" - " const char * pystr = {script};\n" - " do_str(pystr);\n" - "}}" -) - -testcase_struct = ( - "struct testcase_t {name}_tests[] = {{\n{body}\n END_OF_TESTCASES\n}};" -) -testcase_member = ( - " {{ \"{desc}\", {func}, TT_ENABLED_, 0, 0 }}," -) - -testgroup_struct = ( - "struct testgroup_t groups[] = {{\n{body}\n END_OF_GROUPS\n}};" -) -testgroup_member = ( - " {{ \"{name}/\", {name}_tests }}," -) - -## XXX: may be we could have `--without ` argument... -# currently these tests are selected because they pass on qemu-arm -test_dirs = ('basics', 'micropython', 'float', 'extmod', 'inlineasm') # 'import', 'io', 'misc') -exclude_tests = ( - 'float/float2int_doubleprec_intbig.py', # requires double precision floating point to work - 'inlineasm/asmfpaddsub.py', 'inlineasm/asmfpcmp.py', 'inlineasm/asmfpldrstr.py', 'inlineasm/asmfpmuldiv.py', 'inlineasm/asmfpsqrt.py', - 'extmod/ticks_diff.py', 'extmod/time_ms_us.py', 'extmod/uheapq_timeq.py', - 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', 'extmod/vfs_fat_fsusermount.py', 'extmod/vfs_fat_oldproto.py', -) - -output = [] - -for group in test_dirs: - tests = [test for test in glob('{}/*.py'.format(group)) if test not in exclude_tests] - output.extend([test_function.format(**script_to_map(test)) for test in tests]) - testcase_members = [testcase_member.format(**chew_filename(test)) for test in tests] - output.append(testcase_struct.format(name=group, body='\n'.join(testcase_members))) - -testgroup_members = [testgroup_member.format(name=group) for group in test_dirs] - -output.append(testgroup_struct.format(body='\n'.join(testgroup_members))) - -## XXX: may be we could have `--output ` argument... -print('\n\n'.join(output)) diff --git a/user/mpy/tools/tinytest/README b/user/mpy/tools/tinytest/README deleted file mode 100644 index 902c4a2..0000000 --- a/user/mpy/tools/tinytest/README +++ /dev/null @@ -1,18 +0,0 @@ -Tinytest is a tiny little test framework written in C by Nick Mathewson. - -It is distributed under the 3-clause BSD license. You can use it in -your own programs so long as you follow the license's conditions. - -It's been tested on Windows, Mac, and many of the free Unixes. - -It knows how to fork before running certain tests, and it makes -text-mode output in a format I like. - -For info on how to use it, check out tinytest_demo.c. - -You can get the latest version using Git, by pulling from - git://github.com/nmathewson/tinytest.git - -Patches are welcome. Patches that turn this from tinytest to hugetest -will not be applied. If you want a huge test framework, use CUnit. - diff --git a/user/mpy/tools/tinytest/tinytest.c b/user/mpy/tools/tinytest/tinytest.c deleted file mode 100644 index 1ef957d..0000000 --- a/user/mpy/tools/tinytest/tinytest.c +++ /dev/null @@ -1,474 +0,0 @@ -/* tinytest.c -- Copyright 2009-2012 Nick Mathewson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifdef TINYTEST_LOCAL -#include "tinytest_local.h" -#endif - -#include -#include -#include -#include - -#ifndef NO_FORKING - -#ifdef _WIN32 -#include -#else -#include -#include -#include -#endif - -#if defined(__APPLE__) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) -#if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 && \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) -/* Workaround for a stupid bug in OSX 10.6 */ -#define FORK_BREAKS_GCOV -#include -#endif -#endif - -#endif /* !NO_FORKING */ - -#ifndef __GNUC__ -#define __attribute__(x) -#endif - -#include "tinytest.h" -#include "tinytest_macros.h" - -#define LONGEST_TEST_NAME 16384 - -static int in_tinytest_main = 0; /**< true if we're in tinytest_main().*/ -static int n_ok = 0; /**< Number of tests that have passed */ -static int n_bad = 0; /**< Number of tests that have failed. */ -static int n_skipped = 0; /**< Number of tests that have been skipped. */ - -static int opt_forked = 0; /**< True iff we're called from inside a win32 fork*/ -static int opt_nofork = 0; /**< Suppress calls to fork() for debugging. */ -static int opt_verbosity = 1; /**< -==quiet,0==terse,1==normal,2==verbose */ -const char *verbosity_flag = ""; - -const struct testlist_alias_t *cfg_aliases=NULL; - -enum outcome { SKIP=2, OK=1, FAIL=0 }; -static enum outcome cur_test_outcome = 0; -const char *cur_test_prefix = NULL; /**< prefix of the current test group */ -/** Name of the current test, if we haven't logged is yet. Used for --quiet */ -const char *cur_test_name = NULL; - -#ifdef _WIN32 -/* Copy of argv[0] for win32. */ -static char commandname[MAX_PATH+1]; -#endif - -static void usage(struct testgroup_t *groups, int list_groups) - __attribute__((noreturn)); -static int process_test_option(struct testgroup_t *groups, const char *test); - -static enum outcome -testcase_run_bare_(const struct testcase_t *testcase) -{ - void *env = NULL; - int outcome; - if (testcase->setup) { - env = testcase->setup->setup_fn(testcase); - if (!env) - return FAIL; - else if (env == (void*)TT_SKIP) - return SKIP; - } - - cur_test_outcome = OK; - testcase->fn(env); - outcome = cur_test_outcome; - - if (testcase->setup) { - if (testcase->setup->cleanup_fn(testcase, env) == 0) - outcome = FAIL; - } - - return outcome; -} - -#define MAGIC_EXITCODE 42 - -#ifndef NO_FORKING - -static enum outcome -testcase_run_forked_(const struct testgroup_t *group, - const struct testcase_t *testcase) -{ -#ifdef _WIN32 - /* Fork? On Win32? How primitive! We'll do what the smart kids do: - we'll invoke our own exe (whose name we recall from the command - line) with a command line that tells it to run just the test we - want, and this time without forking. - - (No, threads aren't an option. The whole point of forking is to - share no state between tests.) - */ - int ok; - char buffer[LONGEST_TEST_NAME+256]; - STARTUPINFOA si; - PROCESS_INFORMATION info; - DWORD exitcode; - - if (!in_tinytest_main) { - printf("\nERROR. On Windows, testcase_run_forked_ must be" - " called from within tinytest_main.\n"); - abort(); - } - if (opt_verbosity>0) - printf("[forking] "); - - snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s", - commandname, verbosity_flag, group->prefix, testcase->name); - - memset(&si, 0, sizeof(si)); - memset(&info, 0, sizeof(info)); - si.cb = sizeof(si); - - ok = CreateProcessA(commandname, buffer, NULL, NULL, 0, - 0, NULL, NULL, &si, &info); - if (!ok) { - printf("CreateProcess failed!\n"); - return 0; - } - WaitForSingleObject(info.hProcess, INFINITE); - GetExitCodeProcess(info.hProcess, &exitcode); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); - if (exitcode == 0) - return OK; - else if (exitcode == MAGIC_EXITCODE) - return SKIP; - else - return FAIL; -#else - int outcome_pipe[2]; - pid_t pid; - (void)group; - - if (pipe(outcome_pipe)) - perror("opening pipe"); - - if (opt_verbosity>0) - printf("[forking] "); - pid = fork(); -#ifdef FORK_BREAKS_GCOV - vproc_transaction_begin(0); -#endif - if (!pid) { - /* child. */ - int test_r, write_r; - char b[1]; - close(outcome_pipe[0]); - test_r = testcase_run_bare_(testcase); - assert(0<=(int)test_r && (int)test_r<=2); - b[0] = "NYS"[test_r]; - write_r = (int)write(outcome_pipe[1], b, 1); - if (write_r != 1) { - perror("write outcome to pipe"); - exit(1); - } - exit(0); - return FAIL; /* unreachable */ - } else { - /* parent */ - int status, r; - char b[1]; - /* Close this now, so that if the other side closes it, - * our read fails. */ - close(outcome_pipe[1]); - r = (int)read(outcome_pipe[0], b, 1); - if (r == 0) { - printf("[Lost connection!] "); - return 0; - } else if (r != 1) { - perror("read outcome from pipe"); - } - waitpid(pid, &status, 0); - close(outcome_pipe[0]); - return b[0]=='Y' ? OK : (b[0]=='S' ? SKIP : FAIL); - } -#endif -} - -#endif /* !NO_FORKING */ - -int -testcase_run_one(const struct testgroup_t *group, - const struct testcase_t *testcase) -{ - enum outcome outcome; - - if (testcase->flags & (TT_SKIP|TT_OFF_BY_DEFAULT)) { - if (opt_verbosity>0) - printf("%s%s: %s\n", - group->prefix, testcase->name, - (testcase->flags & TT_SKIP) ? "SKIPPED" : "DISABLED"); - ++n_skipped; - return SKIP; - } - - if (opt_verbosity>0 && !opt_forked) { - printf("%s%s: ", group->prefix, testcase->name); - } else { - if (opt_verbosity==0) printf("."); - cur_test_prefix = group->prefix; - cur_test_name = testcase->name; - } - -#ifndef NO_FORKING - if ((testcase->flags & TT_FORK) && !(opt_forked||opt_nofork)) { - outcome = testcase_run_forked_(group, testcase); - } else { -#else - { -#endif - outcome = testcase_run_bare_(testcase); - } - - if (outcome == OK) { - ++n_ok; - if (opt_verbosity>0 && !opt_forked) - puts(opt_verbosity==1?"OK":""); - } else if (outcome == SKIP) { - ++n_skipped; - if (opt_verbosity>0 && !opt_forked) - puts("SKIPPED"); - } else { - ++n_bad; - if (!opt_forked) - printf("\n [%s FAILED]\n", testcase->name); - } - - if (opt_forked) { - exit(outcome==OK ? 0 : (outcome==SKIP?MAGIC_EXITCODE : 1)); - return 1; /* unreachable */ - } else { - return (int)outcome; - } -} - -int -tinytest_set_flag_(struct testgroup_t *groups, const char *arg, int set, unsigned long flag) -{ - int i, j; - size_t length = LONGEST_TEST_NAME; - char fullname[LONGEST_TEST_NAME]; - int found=0; - if (strstr(arg, "..")) - length = strstr(arg,"..")-arg; - for (i=0; groups[i].prefix; ++i) { - for (j=0; groups[i].cases[j].name; ++j) { - struct testcase_t *testcase = &groups[i].cases[j]; - snprintf(fullname, sizeof(fullname), "%s%s", - groups[i].prefix, testcase->name); - if (!flag) { /* Hack! */ - printf(" %s", fullname); - if (testcase->flags & TT_OFF_BY_DEFAULT) - puts(" (Off by default)"); - else if (testcase->flags & TT_SKIP) - puts(" (DISABLED)"); - else - puts(""); - } - if (!strncmp(fullname, arg, length)) { - if (set) - testcase->flags |= flag; - else - testcase->flags &= ~flag; - ++found; - } - } - } - return found; -} - -static void -usage(struct testgroup_t *groups, int list_groups) -{ - puts("Options are: [--verbose|--quiet|--terse] [--no-fork]"); - puts(" Specify tests by name, or using a prefix ending with '..'"); - puts(" To skip a test, prefix its name with a colon."); - puts(" To enable a disabled test, prefix its name with a plus."); - puts(" Use --list-tests for a list of tests."); - if (list_groups) { - puts("Known tests are:"); - tinytest_set_flag_(groups, "..", 1, 0); - } - exit(0); -} - -static int -process_test_alias(struct testgroup_t *groups, const char *test) -{ - int i, j, n, r; - for (i=0; cfg_aliases && cfg_aliases[i].name; ++i) { - if (!strcmp(cfg_aliases[i].name, test)) { - n = 0; - for (j = 0; cfg_aliases[i].tests[j]; ++j) { - r = process_test_option(groups, cfg_aliases[i].tests[j]); - if (r<0) - return -1; - n += r; - } - return n; - } - } - printf("No such test alias as @%s!",test); - return -1; -} - -static int -process_test_option(struct testgroup_t *groups, const char *test) -{ - int flag = TT_ENABLED_; - int n = 0; - if (test[0] == '@') { - return process_test_alias(groups, test + 1); - } else if (test[0] == ':') { - ++test; - flag = TT_SKIP; - } else if (test[0] == '+') { - ++test; - ++n; - if (!tinytest_set_flag_(groups, test, 0, TT_OFF_BY_DEFAULT)) { - printf("No such test as %s!\n", test); - return -1; - } - } else { - ++n; - } - if (!tinytest_set_flag_(groups, test, 1, flag)) { - printf("No such test as %s!\n", test); - return -1; - } - return n; -} - -void -tinytest_set_aliases(const struct testlist_alias_t *aliases) -{ - cfg_aliases = aliases; -} - -int -tinytest_main(int c, const char **v, struct testgroup_t *groups) -{ - int i, j, n=0; - -#ifdef _WIN32 - const char *sp = strrchr(v[0], '.'); - const char *extension = ""; - if (!sp || stricmp(sp, ".exe")) - extension = ".exe"; /* Add an exe so CreateProcess will work */ - snprintf(commandname, sizeof(commandname), "%s%s", v[0], extension); - commandname[MAX_PATH]='\0'; -#endif - for (i=1; i= 1) - printf("%d tests ok. (%d skipped)\n", n_ok, n_skipped); - - return (n_bad == 0) ? 0 : 1; -} - -int -tinytest_get_verbosity_(void) -{ - return opt_verbosity; -} - -void -tinytest_set_test_failed_(void) -{ - if (opt_verbosity <= 0 && cur_test_name) { - if (opt_verbosity==0) puts(""); - printf("%s%s: ", cur_test_prefix, cur_test_name); - cur_test_name = NULL; - } - cur_test_outcome = 0; -} - -void -tinytest_set_test_skipped_(void) -{ - if (cur_test_outcome==OK) - cur_test_outcome = SKIP; -} - diff --git a/user/mpy/tools/tinytest/tinytest.h b/user/mpy/tools/tinytest/tinytest.h deleted file mode 100644 index dff440e..0000000 --- a/user/mpy/tools/tinytest/tinytest.h +++ /dev/null @@ -1,98 +0,0 @@ -/* tinytest.h -- Copyright 2009-2012 Nick Mathewson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TINYTEST_H_INCLUDED_ -#define TINYTEST_H_INCLUDED_ - -/** Flag for a test that needs to run in a subprocess. */ -#define TT_FORK (1<<0) -/** Runtime flag for a test we've decided to skip. */ -#define TT_SKIP (1<<1) -/** Internal runtime flag for a test we've decided to run. */ -#define TT_ENABLED_ (1<<2) -/** Flag for a test that's off by default. */ -#define TT_OFF_BY_DEFAULT (1<<3) -/** If you add your own flags, make them start at this point. */ -#define TT_FIRST_USER_FLAG (1<<4) - -typedef void (*testcase_fn)(void *); - -struct testcase_t; - -/** Functions to initialize/teardown a structure for a testcase. */ -struct testcase_setup_t { - /** Return a new structure for use by a given testcase. */ - void *(*setup_fn)(const struct testcase_t *); - /** Clean/free a structure from setup_fn. Return 1 if ok, 0 on err. */ - int (*cleanup_fn)(const struct testcase_t *, void *); -}; - -/** A single test-case that you can run. */ -struct testcase_t { - const char *name; /**< An identifier for this case. */ - testcase_fn fn; /**< The function to run to implement this case. */ - unsigned long flags; /**< Bitfield of TT_* flags. */ - const struct testcase_setup_t *setup; /**< Optional setup/cleanup fns*/ - void *setup_data; /**< Extra data usable by setup function */ -}; -#define END_OF_TESTCASES { NULL, NULL, 0, NULL, NULL } - -/** A group of tests that are selectable together. */ -struct testgroup_t { - const char *prefix; /**< Prefix to prepend to testnames. */ - struct testcase_t *cases; /** Array, ending with END_OF_TESTCASES */ -}; -#define END_OF_GROUPS { NULL, NULL} - -struct testlist_alias_t { - const char *name; - const char **tests; -}; -#define END_OF_ALIASES { NULL, NULL } - -/** Implementation: called from a test to indicate failure, before logging. */ -void tinytest_set_test_failed_(void); -/** Implementation: called from a test to indicate that we're skipping. */ -void tinytest_set_test_skipped_(void); -/** Implementation: return 0 for quiet, 1 for normal, 2 for loud. */ -int tinytest_get_verbosity_(void); -/** Implementation: Set a flag on tests matching a name; returns number - * of tests that matched. */ -int tinytest_set_flag_(struct testgroup_t *, const char *, int set, unsigned long); - -/** Set all tests in 'groups' matching the name 'named' to be skipped. */ -#define tinytest_skip(groups, named) \ - tinytest_set_flag_(groups, named, 1, TT_SKIP) - -/** Run a single testcase in a single group. */ -int testcase_run_one(const struct testgroup_t *,const struct testcase_t *); - -void tinytest_set_aliases(const struct testlist_alias_t *aliases); - -/** Run a set of testcases from an END_OF_GROUPS-terminated array of groups, - as selected from the command line. */ -int tinytest_main(int argc, const char **argv, struct testgroup_t *groups); - -#endif diff --git a/user/mpy/tools/tinytest/tinytest_macros.h b/user/mpy/tools/tinytest/tinytest_macros.h deleted file mode 100644 index 9ff69b1..0000000 --- a/user/mpy/tools/tinytest/tinytest_macros.h +++ /dev/null @@ -1,184 +0,0 @@ -/* tinytest_macros.h -- Copyright 2009-2012 Nick Mathewson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TINYTEST_MACROS_H_INCLUDED_ -#define TINYTEST_MACROS_H_INCLUDED_ - -/* Helpers for defining statement-like macros */ -#define TT_STMT_BEGIN do { -#define TT_STMT_END } while (0) - -/* Redefine this if your test functions want to abort with something besides - * "goto end;" */ -#ifndef TT_EXIT_TEST_FUNCTION -#define TT_EXIT_TEST_FUNCTION TT_STMT_BEGIN goto end; TT_STMT_END -#endif - -/* Redefine this if you want to note success/failure in some different way. */ -#ifndef TT_DECLARE -#define TT_DECLARE(prefix, args) \ - TT_STMT_BEGIN \ - printf("\n %s %s:%d: ",prefix,__FILE__,__LINE__); \ - printf args ; \ - TT_STMT_END -#endif - -/* Announce a failure. Args are parenthesized printf args. */ -#define TT_GRIPE(args) TT_DECLARE("FAIL", args) - -/* Announce a non-failure if we're verbose. */ -#define TT_BLATHER(args) \ - TT_STMT_BEGIN \ - if (tinytest_get_verbosity_()>1) TT_DECLARE(" OK", args); \ - TT_STMT_END - -#define TT_DIE(args) \ - TT_STMT_BEGIN \ - tinytest_set_test_failed_(); \ - TT_GRIPE(args); \ - TT_EXIT_TEST_FUNCTION; \ - TT_STMT_END - -#define TT_FAIL(args) \ - TT_STMT_BEGIN \ - tinytest_set_test_failed_(); \ - TT_GRIPE(args); \ - TT_STMT_END - -/* Fail and abort the current test for the reason in msg */ -#define tt_abort_printf(msg) TT_DIE(msg) -#define tt_abort_perror(op) TT_DIE(("%s: %s [%d]",(op),strerror(errno), errno)) -#define tt_abort_msg(msg) TT_DIE(("%s", msg)) -#define tt_abort() TT_DIE(("%s", "(Failed.)")) - -/* Fail but do not abort the current test for the reason in msg. */ -#define tt_failprint_f(msg) TT_FAIL(msg) -#define tt_fail_perror(op) TT_FAIL(("%s: %s [%d]",(op),strerror(errno), errno)) -#define tt_fail_msg(msg) TT_FAIL(("%s", msg)) -#define tt_fail() TT_FAIL(("%s", "(Failed.)")) - -/* End the current test, and indicate we are skipping it. */ -#define tt_skip() \ - TT_STMT_BEGIN \ - tinytest_set_test_skipped_(); \ - TT_EXIT_TEST_FUNCTION; \ - TT_STMT_END - -#define tt_want_(b, msg, fail) \ - TT_STMT_BEGIN \ - if (!(b)) { \ - tinytest_set_test_failed_(); \ - TT_GRIPE(("%s",msg)); \ - fail; \ - } else { \ - TT_BLATHER(("%s",msg)); \ - } \ - TT_STMT_END - -/* Assert b, but do not stop the test if b fails. Log msg on failure. */ -#define tt_want_msg(b, msg) \ - tt_want_(b, msg, ); - -/* Assert b and stop the test if b fails. Log msg on failure. */ -#define tt_assert_msg(b, msg) \ - tt_want_(b, msg, TT_EXIT_TEST_FUNCTION); - -/* Assert b, but do not stop the test if b fails. */ -#define tt_want(b) tt_want_msg( (b), "want("#b")") -/* Assert b, and stop the test if b fails. */ -#define tt_assert(b) tt_assert_msg((b), "assert("#b")") - -#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \ - setup_block,cleanup_block,die_on_fail) \ - TT_STMT_BEGIN \ - type val1_ = (type)(a); \ - type val2_ = (type)(b); \ - int tt_status_ = (test); \ - if (!tt_status_ || tinytest_get_verbosity_()>1) { \ - printf_type print_; \ - printf_type print1_; \ - printf_type print2_; \ - type value_ = val1_; \ - setup_block; \ - print1_ = print_; \ - value_ = val2_; \ - setup_block; \ - print2_ = print_; \ - TT_DECLARE(tt_status_?" OK":"FAIL", \ - ("assert(%s): "printf_fmt" vs "printf_fmt, \ - str_test, print1_, print2_)); \ - print_ = print1_; \ - cleanup_block; \ - print_ = print2_; \ - cleanup_block; \ - if (!tt_status_) { \ - tinytest_set_test_failed_(); \ - die_on_fail ; \ - } \ - } \ - TT_STMT_END - -#define tt_assert_test_type(a,b,str_test,type,test,fmt,die_on_fail) \ - tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \ - {print_=value_;},{},die_on_fail) - -/* Helper: assert that a op b, when cast to type. Format the values with - * printf format fmt on failure. */ -#define tt_assert_op_type(a,op,b,type,fmt) \ - tt_assert_test_type(a,b,#a" "#op" "#b,type,(val1_ op val2_),fmt, \ - TT_EXIT_TEST_FUNCTION) - -#define tt_int_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \ - "%ld",TT_EXIT_TEST_FUNCTION) - -#define tt_uint_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \ - (val1_ op val2_),"%lu",TT_EXIT_TEST_FUNCTION) - -#define tt_ptr_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,void*, \ - (val1_ op val2_),"%p",TT_EXIT_TEST_FUNCTION) - -#define tt_str_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \ - (strcmp(val1_,val2_) op 0),"<%s>",TT_EXIT_TEST_FUNCTION) - -#define tt_want_int_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_),"%ld",(void)0) - -#define tt_want_uint_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \ - (val1_ op val2_),"%lu",(void)0) - -#define tt_want_ptr_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,void*, \ - (val1_ op val2_),"%p",(void)0) - -#define tt_want_str_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \ - (strcmp(val1_,val2_) op 0),"<%s>",(void)0) - -#endif diff --git a/user/mpy/tools/upip.py b/user/mpy/tools/upip.py deleted file mode 100644 index 7b85c71..0000000 --- a/user/mpy/tools/upip.py +++ /dev/null @@ -1,307 +0,0 @@ -import sys -import gc -import uos as os -import uerrno as errno -import ujson as json -import uzlib -import upip_utarfile as tarfile -gc.collect() - - -debug = False -install_path = None -cleanup_files = [] -gzdict_sz = 16 + 15 - -file_buf = bytearray(512) - -class NotFoundError(Exception): - pass - -def op_split(path): - if path == "": - return ("", "") - r = path.rsplit("/", 1) - if len(r) == 1: - return ("", path) - head = r[0] - if not head: - head = "/" - return (head, r[1]) - -def op_basename(path): - return op_split(path)[1] - -# Expects *file* name -def _makedirs(name, mode=0o777): - ret = False - s = "" - comps = name.rstrip("/").split("/")[:-1] - if comps[0] == "": - s = "/" - for c in comps: - if s and s[-1] != "/": - s += "/" - s += c - try: - os.mkdir(s) - ret = True - except OSError as e: - if e.args[0] != errno.EEXIST and e.args[0] != errno.EISDIR: - raise - ret = False - return ret - - -def save_file(fname, subf): - global file_buf - with open(fname, "wb") as outf: - while True: - sz = subf.readinto(file_buf) - if not sz: - break - outf.write(file_buf, sz) - -def install_tar(f, prefix): - meta = {} - for info in f: - #print(info) - fname = info.name - try: - fname = fname[fname.index("/") + 1:] - except ValueError: - fname = "" - - save = True - for p in ("setup.", "PKG-INFO", "README"): - #print(fname, p) - if fname.startswith(p) or ".egg-info" in fname: - if fname.endswith("/requires.txt"): - meta["deps"] = f.extractfile(info).read() - save = False - if debug: - print("Skipping", fname) - break - - if save: - outfname = prefix + fname - if info.type != tarfile.DIRTYPE: - if debug: - print("Extracting " + outfname) - _makedirs(outfname) - subf = f.extractfile(info) - save_file(outfname, subf) - return meta - -def expandhome(s): - if "~/" in s: - h = os.getenv("HOME") - s = s.replace("~/", h + "/") - return s - -import ussl -import usocket -warn_ussl = True -def url_open(url): - global warn_ussl - - if debug: - print(url) - - proto, _, host, urlpath = url.split('/', 3) - try: - ai = usocket.getaddrinfo(host, 443) - except OSError as e: - fatal("Unable to resolve %s (no Internet?)" % host, e) - #print("Address infos:", ai) - addr = ai[0][4] - - s = usocket.socket(ai[0][0]) - try: - #print("Connect address:", addr) - s.connect(addr) - - if proto == "https:": - s = ussl.wrap_socket(s) - if warn_ussl: - print("Warning: %s SSL certificate is not validated" % host) - warn_ussl = False - - # MicroPython rawsocket module supports file interface directly - s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host)) - l = s.readline() - protover, status, msg = l.split(None, 2) - if status != b"200": - if status == b"404" or status == b"301": - raise NotFoundError("Package not found") - raise ValueError(status) - while 1: - l = s.readline() - if not l: - raise ValueError("Unexpected EOF in HTTP headers") - if l == b'\r\n': - break - except Exception as e: - s.close() - raise e - - return s - - -def get_pkg_metadata(name): - f = url_open("https://pypi.python.org/pypi/%s/json" % name) - try: - return json.load(f) - finally: - f.close() - - -def fatal(msg, exc=None): - print("Error:", msg) - if exc and debug: - raise exc - sys.exit(1) - -def install_pkg(pkg_spec, install_path): - data = get_pkg_metadata(pkg_spec) - - latest_ver = data["info"]["version"] - packages = data["releases"][latest_ver] - del data - gc.collect() - assert len(packages) == 1 - package_url = packages[0]["url"] - print("Installing %s %s from %s" % (pkg_spec, latest_ver, package_url)) - package_fname = op_basename(package_url) - f1 = url_open(package_url) - try: - f2 = uzlib.DecompIO(f1, gzdict_sz) - f3 = tarfile.TarFile(fileobj=f2) - meta = install_tar(f3, install_path) - finally: - f1.close() - del f3 - del f2 - gc.collect() - return meta - -def install(to_install, install_path=None): - # Calculate gzip dictionary size to use - global gzdict_sz - sz = gc.mem_free() + gc.mem_alloc() - if sz <= 65536: - gzdict_sz = 16 + 12 - - if install_path is None: - install_path = get_install_path() - if install_path[-1] != "/": - install_path += "/" - if not isinstance(to_install, list): - to_install = [to_install] - print("Installing to: " + install_path) - # sets would be perfect here, but don't depend on them - installed = [] - try: - while to_install: - if debug: - print("Queue:", to_install) - pkg_spec = to_install.pop(0) - if pkg_spec in installed: - continue - meta = install_pkg(pkg_spec, install_path) - installed.append(pkg_spec) - if debug: - print(meta) - deps = meta.get("deps", "").rstrip() - if deps: - deps = deps.decode("utf-8").split("\n") - to_install.extend(deps) - except Exception as e: - print("Error installing '{}': {}, packages may be partially installed".format( - pkg_spec, e), - file=sys.stderr) - -def get_install_path(): - global install_path - if install_path is None: - # sys.path[0] is current module's path - install_path = sys.path[1] - install_path = expandhome(install_path) - return install_path - -def cleanup(): - for fname in cleanup_files: - try: - os.unlink(fname) - except OSError: - print("Warning: Cannot delete " + fname) - -def help(): - print("""\ -upip - Simple PyPI package manager for MicroPython -Usage: micropython -m upip install [-p ] ... | -r -import upip; upip.install(package_or_list, []) - -If is not given, packages will be installed into sys.path[1] -(can be set from MICROPYPATH environment variable, if current system -supports that).""") - print("Current value of sys.path[1]:", sys.path[1]) - print("""\ - -Note: only MicroPython packages (usually, named micropython-*) are supported -for installation, upip does not support arbitrary code in setup.py. -""") - -def main(): - global debug - global install_path - install_path = None - - if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help": - help() - return - - if sys.argv[1] != "install": - fatal("Only 'install' command supported") - - to_install = [] - - i = 2 - while i < len(sys.argv) and sys.argv[i][0] == "-": - opt = sys.argv[i] - i += 1 - if opt == "-h" or opt == "--help": - help() - return - elif opt == "-p": - install_path = sys.argv[i] - i += 1 - elif opt == "-r": - list_file = sys.argv[i] - i += 1 - with open(list_file) as f: - while True: - l = f.readline() - if not l: - break - if l[0] == "#": - continue - to_install.append(l.rstrip()) - elif opt == "--debug": - debug = True - else: - fatal("Unknown/unsupported option: " + opt) - - to_install.extend(sys.argv[i:]) - if not to_install: - help() - return - - install(to_install) - - if not debug: - cleanup() - - -if __name__ == "__main__": - main() diff --git a/user/mpy/tools/upip_utarfile.py b/user/mpy/tools/upip_utarfile.py deleted file mode 100644 index 65ce0bd..0000000 --- a/user/mpy/tools/upip_utarfile.py +++ /dev/null @@ -1,94 +0,0 @@ -import uctypes - -# http://www.gnu.org/software/tar/manual/html_node/Standard.html -TAR_HEADER = { - "name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100), - "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 12), -} - -DIRTYPE = "dir" -REGTYPE = "file" - -def roundup(val, align): - return (val + align - 1) & ~(align - 1) - -class FileSection: - - def __init__(self, f, content_len, aligned_len): - self.f = f - self.content_len = content_len - self.align = aligned_len - content_len - - def read(self, sz=65536): - if self.content_len == 0: - return b"" - if sz > self.content_len: - sz = self.content_len - data = self.f.read(sz) - sz = len(data) - self.content_len -= sz - return data - - def readinto(self, buf): - if self.content_len == 0: - return 0 - if len(buf) > self.content_len: - buf = memoryview(buf)[:self.content_len] - sz = self.f.readinto(buf) - self.content_len -= sz - return sz - - def skip(self): - sz = self.content_len + self.align - if sz: - buf = bytearray(16) - while sz: - s = min(sz, 16) - self.f.readinto(buf, s) - sz -= s - -class TarInfo: - - def __str__(self): - return "TarInfo(%r, %s, %d)" % (self.name, self.type, self.size) - -class TarFile: - - def __init__(self, name=None, fileobj=None): - if fileobj: - self.f = fileobj - else: - self.f = open(name, "rb") - self.subf = None - - def next(self): - if self.subf: - self.subf.skip() - buf = self.f.read(512) - if not buf: - return None - - h = uctypes.struct(uctypes.addressof(buf), TAR_HEADER, uctypes.LITTLE_ENDIAN) - - # Empty block means end of archive - if h.name[0] == 0: - return None - - d = TarInfo() - d.name = str(h.name, "utf-8").rstrip() - d.size = int(bytes(h.size).rstrip(), 8) - d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"] - self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512)) - return d - - def __iter__(self): - return self - - def __next__(self): - v = self.next() - if v is None: - raise StopIteration - return v - - def extractfile(self, tarinfo): - return tarinfo.subf From 80d85821eb10365d18a7f79865e87e9bb76b0047 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Wed, 16 Aug 2017 14:03:02 +0800 Subject: [PATCH 3/6] Untracked micropython --- .gitmodules | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitmodules b/.gitmodules index ce29bcd..ff9227a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "user/mpy/micropython"] path = user/mpy/micropython url = git@github.com:micropython/micropython.git + ignore = untracked From c789a7a7cc3c11db4159bdfc7f045c628e5faab7 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Wed, 16 Aug 2017 14:03:34 +0800 Subject: [PATCH 4/6] Change micropython clean path --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bb549aa..dd25d0d 100644 --- a/Makefile +++ b/Makefile @@ -60,9 +60,9 @@ clean: ifneq "$(wildcard $(CMSIS) )" "" find $(CMSIS) -name "*.o" -type f -delete endif - rm -rf user/mpy/build - rm -rf user/mpy/*.o.d - rm -f user/mpy/py/*.o + rm -rf user/mpy/micropython/build + rm -rf user/mpy/micropython/*.o.d + rm -f user/mpy/micropython/py/*.o rm -f $(NAME).map $(NAME).lds rm -f $(NAME).elf $(NAME).bin From 0c85642aac4f49d3756bf26181a9e61bf4ac39cc Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Wed, 16 Aug 2017 14:03:51 +0800 Subject: [PATCH 5/6] Change path settings --- user/mpy/build.mk | 19 ++++++++++--------- user/mpy/py.mk | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/user/mpy/build.mk b/user/mpy/build.mk index e5de6ae..84f0adf 100644 --- a/user/mpy/build.mk +++ b/user/mpy/build.mk @@ -1,4 +1,4 @@ -TOP = user/mpy +TOP = user/mpy/micropython PY_SRC ?= $(TOP)/py BUILD = $(TOP)/build PY_BUILD = $(BUILD)/py @@ -9,7 +9,7 @@ HEADER_BUILD = $(BUILD)/genhdr # file containing qstr defs for the core Python bit PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h -include $(TOP)/py.mk +include $(TOP)/../py.mk # If qstr autogeneration is not disabled we specify the output header # for all collected qstrings. @@ -24,17 +24,18 @@ PYTHON = python3 CFLAGS += \ -Iuser/mpy \ - -Iuser/mpy/build \ + -I$(TOP) \ + -I$(BUILD) \ CSRC += \ - $(wildcard user/mpy/py/*.c) \ + $(wildcard $(PY_SRC)/*.c) \ user/mpy/mphalport.c \ user/mpy/_frozen_mpy.c \ - user/mpy/lib/utils/pyexec.c \ - user/mpy/lib/mp-readline/readline.c \ - user/mpy/extmod/moductypes.o \ - user/mpy/extmod/modujson.o \ - user/mpy/extmod/modure.o \ + $(TOP)/lib/utils/pyexec.c \ + $(TOP)/lib/mp-readline/readline.c \ + $(TOP)/extmod/moductypes.o \ + $(TOP)/extmod/modujson.o \ + $(TOP)/extmod/modure.o \ # user/mpy/extmod/moduzlib.o \ # user/mpy/extmod/moduheapq.o \ # user/mpy/extmod/modutimeq.o \ diff --git a/user/mpy/py.mk b/user/mpy/py.mk index a9afb96..6dc8cfd 100644 --- a/user/mpy/py.mk +++ b/user/mpy/py.mk @@ -273,7 +273,7 @@ MPCONFIGPORT_MK = $(wildcard mpconfigport.mk) # created before we run the script to generate the .h # Note: we need to protect the qstr names from the preprocessor, so we wrap # the lines in "" and then unwrap after the preprocessor is finished. -$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py $(TOP)/mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) +$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py $(TOP)/../mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) $(ECHO) "GEN $@" $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ From f336df90d1020802a588631007ebca8a962f6424 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Wed, 16 Aug 2017 14:59:12 +0800 Subject: [PATCH 6/6] Fix buliding system --- Makefile | 12 ++++++--- user/mpy/build.mk | 66 +++++++++++++++++++++++------------------------ user/mpy/py.mk | 2 +- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index dd25d0d..acecc17 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,12 @@ CSRC += \ libc/piko/mman.c \ $(LIBPIKO_CSRC) +.PHONY: all check clean distclean + +all: $(CMSIS)/$(TARGET) $(USER) + $(MAKE) $(NAME).lds + $(MAKE) $(NAME).bin + # micropython include user/mpy/build.mk @@ -40,15 +46,13 @@ OBJS := $(sort $(OBJS)) deps := $(OBJS:%.o=.%.o.d) -.PHONY: all check clean distclean - -all: $(CMSIS)/$(TARGET) $(NAME).lds $(NAME).bin # generic build rules include mk/flags.mk include mk/rules.mk include mk/cmsis.mk + prebuild: $(CMSIS)/$(TARGET) check: @@ -61,7 +65,7 @@ ifneq "$(wildcard $(CMSIS) )" "" find $(CMSIS) -name "*.o" -type f -delete endif rm -rf user/mpy/micropython/build - rm -rf user/mpy/micropython/*.o.d + rm -f user/mpy/micropython/*.o.d rm -f user/mpy/micropython/py/*.o rm -f $(NAME).map $(NAME).lds rm -f $(NAME).elf $(NAME).bin diff --git a/user/mpy/build.mk b/user/mpy/build.mk index 84f0adf..1342c93 100644 --- a/user/mpy/build.mk +++ b/user/mpy/build.mk @@ -9,6 +9,8 @@ HEADER_BUILD = $(BUILD)/genhdr # file containing qstr defs for the core Python bit PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h +$(USER): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h + include $(TOP)/../py.mk # If qstr autogeneration is not disabled we specify the output header @@ -33,38 +35,36 @@ CSRC += \ user/mpy/_frozen_mpy.c \ $(TOP)/lib/utils/pyexec.c \ $(TOP)/lib/mp-readline/readline.c \ - $(TOP)/extmod/moductypes.o \ - $(TOP)/extmod/modujson.o \ - $(TOP)/extmod/modure.o \ - # user/mpy/extmod/moduzlib.o \ - # user/mpy/extmod/moduheapq.o \ - # user/mpy/extmod/modutimeq.o \ - # user/mpy/extmod/moduhashlib.o \ - # user/mpy/extmod/modubinascii.o \ - # user/mpy/extmod/virtpin.o \ - # user/mpy/extmod/machine_mem.o \ - # user/mpy/extmod/machine_pinbase.o \ - # user/mpy/extmod/machine_signal.o \ - # user/mpy/extmod/machine_pulse.o \ - # user/mpy/extmod/machine_i2c.o \ - # user/mpy/extmod/machine_spi.o \ - # user/mpy/extmod/modussl_axtls.o \ - # user/mpy/extmod/modussl_mbedtls.o \ - # user/mpy/extmod/modurandom.o \ - # user/mpy/extmod/moduselect.o \ - # user/mpy/extmod/modwebsocket.o \ - # user/mpy/extmod/modwebrepl.o \ - # user/mpy/extmod/modframebuf.o \ - # user/mpy/extmod/vfs.o \ - # user/mpy/extmod/vfs_reader.o \ - # user/mpy/extmod/vfs_fat.o \ - # user/mpy/extmod/vfs_fat_diskio.o \ - # user/mpy/extmod/vfs_fat_file.o \ - # user/mpy/extmod/vfs_fat_misc.o \ - # user/mpy/extmod/utime_mphal.o \ - # user/mpy/extmod/uos_dupterm.o \ - # user/mpy/lib/embed/abort_.o \ - -CSRC := $(filter-out user/mpy/py/frozen_mpy.o, $(CSRC)) + # $(TOP)/extmod/moductypes.o \ + # $(TOP)/extmod/modujson.o \ + # $(TOP)/extmod/modure.o \ + # $(TOP)/extmod/moduzlib.o \ + # $(TOP)/extmod/moduheapq.o \ + # $(TOP)/extmod/modutimeq.o \ + # $(TOP)/extmod/moduhashlib.o \ + # $(TOP)/extmod/modubinascii.o \ + # $(TOP)/extmod/virtpin.o \ + # $(TOP)/extmod/machine_mem.o \ + # $(TOP)/extmod/machine_pinbase.o \ + # $(TOP)/extmod/machine_signal.o \ + # $(TOP)/extmod/machine_pulse.o \ + # $(TOP)/extmod/machine_i2c.o \ + # $(TOP)/extmod/machine_spi.o \ + # $(TOP)/extmod/modussl_axtls.o \ + # $(TOP)/extmod/modussl_mbedtls.o \ + # $(TOP)/extmod/modurandom.o \ + # $(TOP)/extmod/moduselect.o \ + # $(TOP)/extmod/modwebsocket.o \ + # $(TOP)/extmod/modwebrepl.o \ + # $(TOP)/extmod/modframebuf.o \ + # $(TOP)/extmod/vfs.o \ + # $(TOP)/extmod/vfs_reader.o \ + # $(TOP)/extmod/vfs_fat.o \ + # $(TOP)/extmod/vfs_fat_diskio.o \ + # $(TOP)/extmod/vfs_fat_file.o \ + # $(TOP)/extmod/vfs_fat_misc.o \ + # $(TOP)/extmod/utime_mphal.o \ + # $(TOP)/extmod/uos_dupterm.o \ + # $(TOP)/lib/embed/abort_.o \ include $(TOP)/py/mkrules.mk diff --git a/user/mpy/py.mk b/user/mpy/py.mk index 6dc8cfd..9dc322d 100644 --- a/user/mpy/py.mk +++ b/user/mpy/py.mk @@ -261,7 +261,7 @@ endif SRC_QSTR_IGNORE = nlr% emitnx86% emitnx64% emitnthumb% emitnarm% emitnxtensa% SRC_QSTR = $(SRC_MOD) $(addprefix py/,$(filter-out $(SRC_QSTR_IGNORE),$(PY_O_BASENAME:.o=.c)) emitnative.c) -$(HEADER_BUILD)/mpversion.h: | $(HEADER_BUILD) +$(HEADER_BUILD)/mpversion.h: $(HEADER_BUILD) $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ # mpconfigport.mk is optional, but changes to it may drastically change